Updating codebase to OpenCORE 2.0. More documentation on the changes to follow.
diff --git a/Android.mk b/Android.mk
index b7ba290..27a179f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,10 +1,18 @@
 ifneq ($(BUILD_WITHOUT_PV),true)
 LOCAL_PATH := $(call my-dir)
 PV_TOP := $(LOCAL_PATH)
-
 include $(CLEAR_VARS)
 
-PV_CFLAGS := -Wno-non-virtual-dtor -DENABLE_MEMORY_PLAYBACK
+PV_CFLAGS := -Wno-non-virtual-dtor -DENABLE_MEMORY_PLAYBACK -DUSE_CML2_CONFIG
+
+ifeq ($(ENABLE_PV_LOGGING),1)
+ PV_CFLAGS += -DPVLOGGER_INST_LEVEL=5
+endif
+
+ifeq ($(TARGET_ARCH),arm)
+  PV_CFLAGS += -DPV_ARM_GCC_V5
+endif
+
 include $(CLEAR_VARS)
 
 FORMAT := nj
@@ -25,39 +33,33 @@
 	$(PV_TOP)/oscl/oscl/config/shared \
 	$(PV_TOP)/engines/author/include \
 	$(PV_TOP)/android/drm/oma1/src \
-	$(TARGET_OUT_HEADERS)/$(PV_COPY_HEADERS_TO) 
+	$(PV_TOP)/build_config/opencore_dynamic \
+	$(TARGET_OUT_HEADERS)/$(PV_COPY_HEADERS_TO)
 
-ALTERNATE_CONFIG := $(if $(wildcard vendor/pv/pvplayer.conf),true)
-ifneq ($(ALTERNATE_CONFIG), true)
-$(call add-prebuilt-files, ETC, pvplayer.conf)
-else
-VALUE_ADD := 1
-PV_CFLAGS += -DPV_USE_VALUE_ADD=1
-endif
+$(call add-prebuilt-files, ETC, pvplayer.cfg)
 
-include $(PV_TOP)/pvcommon/Android.mk
-include $(PV_TOP)/pvplayer/Android.mk
-include $(PV_TOP)/pvauthor/Android.mk
-include $(PV_TOP)//baselibs/gen_data_structures/Android.mk
-include $(PV_TOP)//protocols/rtp/Android.mk
-include $(PV_TOP)//protocols/sdp/parser/Android.mk
-include $(PV_TOP)//protocols/rtp_payload_parser/Android.mk
-include $(PV_TOP)//protocols/rtsp_parcom/Android.mk
-include $(PV_TOP)//protocols/rtsp_client_engine/Android.mk
-include $(PV_TOP)//protocols/http_parcom/Android.mk
-include $(PV_TOP)//nodes/pvsocketnode/Android.mk
-include $(PV_TOP)//nodes/pvdownloadmanagernode/Android.mk
-include $(PV_TOP)//nodes/pvprotocolenginenode/Android.mk
-include $(PV_TOP)//nodes/streaming/jitterbuffernode/Android.mk
-include $(PV_TOP)//nodes/streaming/medialayernode/Android.mk
-include $(PV_TOP)//nodes/streaming/streamingmanager/Android.mk
-include $(PV_TOP)//pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk
-include $(PV_TOP)//codecs_v2/video/m4v_h263/dec/Android.mk
-include $(PV_TOP)//nodes/pvmp4ffparsernode/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_m4v/Android.mk
-include $(PV_TOP)//codecs_v2/audio/sbc/enc/Android.mk
-#include $(PV_TOP)//engines/player/sample_app/Android.mk
-#include $(PV_TOP)//engines/player/test/Android.mk
-#include $(PV_TOP)//engines/adapters/player/framemetadatautility/test/Android.mk
-#include $(PV_TOP)//engines/author/test/Android.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_common.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_author.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_player.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_2way.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_net_support.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_downloadreg.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_download.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_rtspreg.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_rtsp.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk
+include $(PV_TOP)/build_config/opencore_dynamic/Android_opencore_mp4local.mk
+include $(PV_TOP)/oscl/unit_test/Android.mk
+include $(PV_TOP)/engines/player/test/Android.mk
+include $(PV_TOP)/engines/author/test/Android.mk
+include $(PV_TOP)/engines/2way/test/Android.mk
 endif
diff --git a/Android_platform_extras.mk b/Android_platform_extras.mk
new file mode 100644
index 0000000..d02cf18
--- /dev/null
+++ b/Android_platform_extras.mk
@@ -0,0 +1,2 @@
+
+LOCAL_SHARED_LIBRARIES := libutils libcutils libui libhardware libandroid_runtime libdrm1 libmedia libsgl libvorbisidec libsonivox liblog libicuuc
diff --git a/Android_system_extras.mk b/Android_system_extras.mk
new file mode 100644
index 0000000..afe76ba
--- /dev/null
+++ b/Android_system_extras.mk
@@ -0,0 +1,9 @@
+
+LOCAL_LDLIBS := -lpthread
+
+ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
+LOCAL_LDLIBS += -ldl
+endif
+ifneq ($(TARGET_SIMULATOR),true)
+LOCAL_SHARED_LIBRARIES += libdl
+endif
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..f5155ec
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,274 @@
+/* ------------------------------------------------------------------

+ * Copyright (C) 2009 PacketVideo

+ *

+ * Licensed under the Apache License, Version 2.0 (the "License");

+ * you may not use this file except in compliance with the License.

+ * You may obtain a copy of the License at

+ *

+ *      http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing, software

+ * distributed under the License is distributed on an "AS IS" BASIS,

+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either

+ * express or implied.

+ * See the License for the specific language governing permissions

+ * and limitations under the License.

+ * -------------------------------------------------------------------

+ */

+

+Portions of the PacketVideo supplied code contain contributions which may be covered by the following copyright statements:

+

+

+/*     -------------------------------------------------------------------       *

+ *                    MPEG-4 Simple Profile Video Decoder           *

+ *     -------------------------------------------------------------------       *

+ *

+ * This software module was originally developed and/or edited by

+ *

+ *   Paulo Nunes (IST / ACTS-MoMuSyS)

+ *   Robert Danielsen (Telenor / ACTS-MoMuSyS)

+ *   Luis Ducla-Soares (IST / ACTS-MoMuSys).     	           	   	

+ *   Cor Quist (KPN / ACTS-MoMuSys).     			              	

+ *  Minhua Zhou (HHI / ACTS-MoMuSys).   	  	 	              	

+ *

+ * in the course of development of the MPEG-4 Video (ISO/IEC 14496-2) standard.

+ * This software module is an implementation of a part of one or more MPEG-4

+ * Video (ISO/IEC 14496-2) tools as specified by the MPEG-4 Video (ISO/IEC

+ * 14496-2) standard.

+ *

+ * ISO/IEC gives users of the MPEG-4 Video (ISO/IEC 14496-2) standard free

+ * license to this software module or modifications thereof for use in hardware

+ * or software products claiming conformance to the MPEG-4 Video (ISO/IEC

+ * 14496-2) standard.

+ *

+ * Those intending to use this software module in hardware or software products

+ * are advised that its use may infringe existing patents. The original

+ * developer of this software module and his/her company, the subsequent

+ * editors and their companies, and ISO/IEC have no liability for use of this

+ * software module or modifications thereof in an implementation. Copyright is

+ * not released for non MPEG-4 Video (ISO/IEC 14496-2) Standard conforming

+ * products.

+ *

+ * ACTS-MoMuSys partners retain full right to use the code for his/her own

+ * purpose, assign or donate the code to a third party and to inhibit third

+ * parties from using the code for non MPEG-4 Video (ISO/IEC 14496-2) Standard

+ * conforming products. This copyright notice must be included in all copies or

+ * derivative works.

+ *

+ * Copyright (c) 1996, 1997

+ *

+ *****************************************************************************/

+

+

+

+/****************************************************************************

+

+SC 29 Software Copyright Licencing Disclaimer:

+

+This software module was originally developed by

+  Coding Technologies

+

+and edited by

+  -

+

+in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 

+standards for reference purposes and its performance may not have been 

+optimized. This software module is an implementation of one or more tools as 

+specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.

+ISO/IEC gives users free license to this software module or modifications 

+thereof for use in products claiming conformance to audiovisual and 

+image-coding related ITU Recommendations and/or ISO/IEC International 

+Standards. ISO/IEC gives users the same free license to this software module or 

+modifications thereof for research purposes and further ISO/IEC standardisation.

+Those intending to use this software module in products are advised that its 

+use may infringe existing patents. ISO/IEC have no liability for use of this 

+software module or modifications thereof. Copyright is not released for 

+products that do not conform to audiovisual and image-coding related ITU 

+Recommendations and/or ISO/IEC International Standards.

+The original developer retains full right to modify and use the code for its 

+own purpose, assign or donate the code to a third party and to inhibit third 

+parties from using the code for products that do not conform to audiovisual and 

+image-coding related ITU Recommendations and/or ISO/IEC International Standards.

+This copyright notice must be included in all copies or derivative works.

+Copyright (c) ISO/IEC 2003.

+

+*******************************************************************************/

+

+

+/**************************************************************************

+

+This software module was originally developed by

+

+Mikko Suonio (Nokia)

+

+in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard

+ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an

+implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools

+as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives

+users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this

+software module or modifications thereof for use in hardware or

+software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio

+standards. Those intending to use this software module in hardware or

+software products are advised that this use may infringe existing

+patents. The original developer of this software module and his/her

+company, the subsequent editors and their companies, and ISO/IEC have

+no liability for use of this software module or modifications thereof

+in an implementation. Copyright is not released for non MPEG-2

+NBC/MPEG-4 Audio conforming products. The original developer retains

+full right to use the code for his/her own purpose, assign or donate

+the code to a third party and to inhibit third party from using the

+code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This

+copyright notice must be included in all copies or derivative works.

+

+Copyright (c) 1997.

+

+***************************************************************************/

+

+

+/**************************************************************************

+

+This software module was originally developed by

+Nokia in the course of development of the MPEG-2 AAC/MPEG-4 

+Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.

+This software module is an implementation of a part

+of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the

+MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the

+MPEG-2aac/MPEG-4 Audio standards free license to this software module

+or modifications thereof for use in hardware or software products

+claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those

+intending to use this software module in hardware or software products

+are advised that this use may infringe existing patents. The original

+developer of this software module, the subsequent

+editors and their companies, and ISO/IEC have no liability for use of

+this software module or modifications thereof in an

+implementation. Copyright is not released for non MPEG-2 aac/MPEG-4

+Audio conforming products. The original developer retains full right to

+use the code for the developer's own purpose, assign or donate the code to a

+third party and to inhibit third party from using the code for non

+MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice

+must be included in all copies or derivative works.

+Copyright (c)1997.  

+

+***************************************************************************/

+

+

+------------------------------------------------------------------------------

+

+MPEG-2 NBC Audio Decoder

+   "This software module was originally developed by AT&T, Dolby

+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development

+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and

+   3. This software module is an implementation of a part of one or more

+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4

+   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio

+   standards free license to this software module or modifications thereof

+   for use in hardware or software products claiming conformance to the

+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software

+   module in hardware or software products are advised that this use may

+   infringe existing patents. The original developer of this software

+   module and his/her company, the subsequent editors and their companies,

+   and ISO/IEC have no liability for use of this software module or

+   modifications thereof in an implementation. Copyright is not released

+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original

+   developer retains full right to use the code for his/her own purpose,

+   assign or donate the code to a third party and to inhibit third party

+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.

+   This copyright notice must be included in all copies or derivative

+   works." 

+   Copyright(c)1996.

+

+------------------------------------------------------------------------------

+

+

+/*

+ * snprintf.c - a portable implementation of snprintf

+ *

+ * AUTHOR

+ *   Mark Martinec <mark.martinec@ijs.si>, April 1999.

+ *

+ *   Copyright 1999, Mark Martinec. All rights reserved.

+ *

+ * TERMS AND CONDITIONS

+ *   This program is free software; you can redistribute it and/or modify

+ *   it under the terms of the "Frontier Artistic License" which comes

+ *   with this Kit.

+ *

+ *   This program is distributed in the hope that it will be useful,

+ *   but WITHOUT ANY WARRANTY; without even the implied warranty

+ *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

+ *   See the Frontier Artistic License for more details.

+ *

+ *

+ */

+

+The "Frontier Artistic License" may be found at

+ http://www.spinwardstars.com/frontier/fal.html

+

+

+

+

+

+

+

+/*---------------------------------------------------------------------------*/

+

+/*

+ * Copyright (c) 2005 The Khronos Group Inc.

+ *

+ * Permission is hereby granted, free of charge, to any person obtaining

+ * a copy of this software and associated documentation files (the

+ * "Software"), to deal in the Software without restriction, including

+ * without limitation the rights to use, copy, modify, merge, publish,

+ * distribute, sublicense, and/or sell copies of the Software, and to

+ * permit persons to whom the Software is furnished to do so, subject

+ * to the following conditions:

+ * The above copyright notice and this permission notice shall be included

+ * in all copies or substantial portions of the Software.

+ *

+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ *

+ */

+

+/*---------------------------------------------------------------------------*/

+

+/**@@@+++@@@@****************************************************************** 

+** 

+** Microsoft Windows Media 

+** Copyright (C) Microsoft Corporation. All rights reserved. 

+** 

+***@@@---@@@@****************************************************************** 

+*/ 

+

+

+

+----------------------------------------------------------------------------------------

+Portions of this file are derived from the following 3GPP standard:

+ 

+    3GPP TS 26.073

+    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec

+    Available from http://www.3gpp.org

+ 

+(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

+Permission to distribute, modify and use this file under the standard license

+terms listed above has been obtained from the copyright holder.

+-----------------------------------------------------------------------------------------

+

+

+----------------------------------------------------------------------------------------

+Portions of this file are derived from the following 3GPP standard:

+ 

+    3GPP TS 26.173

+    ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec

+    Available from http://www.3gpp.org

+ 

+(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

+Permission to distribute, modify and use this file under the standard license

+terms listed above has been obtained from the copyright holder.

+-----------------------------------------------------------------------------------------

+

diff --git a/README b/README
deleted file mode 100644
index c75da28..0000000
--- a/README
+++ /dev/null
@@ -1,65 +0,0 @@
-
-	Welcome to OpenCore
-
-OpenCore is the multmedia framework of Android 
-originally contributed by PacketVideo.  It provides 
-an extensible framework for multimedia rendering and 
-authoring and will add video telephony (3G-324M) support
-in a future release.
-
-The following is a brief overview of the directory 
-structure to make it easier to understand the organization.
-Below is a list of the top-level directories along with a brief
-note about the contents.
-
-__
-  |-- android  [Contains the components the interface OpenCore with 
-  |             other parts of Android]   
-  |-- baselibs [Contains basic libraries for data containers, MIME string
-  |             handling, messaging across thread boundaries, etc]
-  |-- codecs_v2 [Contains the implementations of PV's audio and video 
-  |              codecs as well as the OpenMax IL interface layer]
-  |-- doc       [Contains the documentation required to interface with
-  |              OpenCore]
-  |-- engines   [Contains the implementation of the player and author 
-  |              engines as well as a utility for metadata.]
-  |-- extern_libs_v2 [Contains 3rd-party libraries used by OpenCore. 
-  |                   Currently this directory contains header files 
-  |                   defining the Khronos OpenMax IL interface]
-  |-- fileformats  [Contains the libraries for parsing a variety of
-  |                 fileformats including mp4/3gp,mp3,wav,aac.]
-  |-- nodes     [Contains the OpenCore framework "nodes", which is 
-  |              the abstraction used to implement independent multimedia 
-  |              processing units that can be connected in a flow graph]
-  |-- oscl      [This is the Operating System Compatibility Layer which 
-  |              provides the mapping OS APIs as well as some basic 
-  |              data structures and utilities.]
-  |-- protocols [Contains parsers and composers for a variety of network
-  |              protocols such as HTTP, RTP/RTCP, RTSP, and SDP]
-  |-- pvauthor  [Contains build files for aggregating low-level libraries 
-  |              into a single shared library for pvauthor]
-  |-- pvcommon  [Contains build files for aggregating low-level libraries
-  |              used by author and player into a single shared library]
-  |-- pvmi     [Contains fundamental definitions that make up OpenCore.
-  |             The directory name is an abbreviation of PacketVideo 
-  |             Multimedia Infrastructure]
-  |-- pvplayer  [Contains build files for aggregating low-level libraries
-  |              into a single shared library for pvplayer]
-  |-- tools_v2  [Contains tools used to build the libraries outside of Android]
-
-Within each library the following directory structure, with a few exceptions,
-to organize the files:
-
-__
-  |-- build
-    |-- make    <- makefile to build outside of Android is here       
-  |-- doc       <- directory for any documentation specific to this lib
-  |-- include   <- header files that are part of the external interface go here
-  |-- src       <- source and internal header files of the library
-  |-- test      <- test code (follows a similar structure.
-    |-- build
-      |-- make
-    |-- include
-    |-- src
-  
-
diff --git a/android/Android.mk b/android/Android.mk
index 970fe27..2c99786 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -24,9 +24,11 @@
 	$(PV_TOP)/nodes/pvmp4ffcomposernode/include \
 	$(PV_TOP)/engines/player/include \
 	$(PV_TOP)/nodes/common/include \
-	external/icu4c/common \
-	external/tremor/Tremor \
 	libs/drm/mobile1/include \
+	include/graphics \
+	external/skia/include/corecg \
+	external/tremor/Tremor \
+	external/icu4c/common \
 	$(call include-path-for, graphics corecg)
 
 LOCAL_SHARED_LIBRARIES := libmedia libvorbisidec libicuuc
diff --git a/android/android_audio_input.cpp b/android/android_audio_input.cpp
new file mode 100644
index 0000000..3f1336a
--- /dev/null
+++ b/android/android_audio_input.cpp
@@ -0,0 +1,1090 @@
+/*
+ * Copyright (c) 2008, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "audio_input"
+#include <utils/Log.h>
+#include <utils/threads.h>
+
+#include "oscl_base.h"
+#include "android_audio_input.h"
+#include "pv_mime_string_utils.h"
+#include "oscl_dll.h"
+
+#include <media/AudioRecord.h>
+#include <sys/prctl.h>
+
+using namespace android;
+
+// TODO: get buffer size from AudioFlinger
+static const int kBufferSize = 2048;
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
+////////////////////////////////////////////////////////////////////////////
+AndroidAudioInput::AndroidAudioInput()
+    : OsclTimerObject(OsclActiveObject::EPriorityNominal, "AndroidAudioInput"),
+    iCmdIdCounter(0),
+    iPeer(NULL),
+    iThreadLoggedOn(false),
+    iAudioSamplingRate(8000),
+    iDataEventCounter(0),
+    iWriteCompleteAO(NULL),
+    iTimeStamp(0),
+    iMediaBufferMemPool(NULL),
+    iState(STATE_IDLE),
+    iMaxAmplitude(0),
+    iTrackMaxAmplitude(false)
+{
+    LOGV("AndroidAudioInput constructor %p", this);
+    // semaphore used to communicate between this  mio and the audio output thread
+    iAudioThreadSem = new OsclSemaphore();
+    iAudioThreadSem->Create(0);
+    iAudioThreadTermSem = new OsclSemaphore();
+    iAudioThreadTermSem->Create(0);
+
+    iAudioThreadStartLock = new Mutex();
+    iAudioThreadStartCV = new Condition();
+
+    //locks to access the queues by this mio and by the audio output thread
+    iWriteResponseQueueLock.Create();
+    iOSSRequestQueueLock.Create();
+
+
+    {
+        iAudioFormat=PVMF_FORMAT_UNKNOWN;
+        iAudioNumChannelsValid=false;
+        iAudioSamplingRateValid=false;
+        iExitAudioThread=false;
+
+        iCommandCounter=0;
+        iCommandResponseQueue.reserve(5);
+        iWriteResponseQueue.reserve(5);
+        iOSSRequestQueue.reserve(5);
+        iObserver=NULL;
+        iWriteBusy=false;
+        iWriteBusySeqNum=0;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+AndroidAudioInput::~AndroidAudioInput()
+{
+    LOGV("AndroidAudioInput destructor %p", this);
+
+    if(iWriteCompleteAO)
+    {
+        OSCL_DELETE(iWriteCompleteAO);
+        iWriteCompleteAO = NULL;
+    }
+
+    if(iMediaBufferMemPool)
+    {
+        OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+        iMediaBufferMemPool = NULL;
+    }
+
+    iWriteResponseQueueLock.Close();
+    iOSSRequestQueueLock.Close();
+    iAudioThreadSem->Close();
+    delete iAudioThreadSem;
+    iAudioThreadTermSem->Close();
+    delete iAudioThreadTermSem;
+
+    delete iAudioThreadStartLock;
+    delete iAudioThreadStartCV;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus AndroidAudioInput::connect(PvmiMIOSession& aSession, PvmiMIOObserver* aObserver)
+{
+    LOGV("connect");
+
+    if(!aObserver)
+    {
+        LOGV("aObserver is NULL");
+        return PVMFFailure;
+    }
+
+    int32 err = 0;
+    OSCL_TRY(err, iObservers.push_back(aObserver));
+    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
+    aSession = (PvmiMIOSession)(iObservers.size() - 1); // Session ID is the index of observer in the vector
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus AndroidAudioInput::disconnect(PvmiMIOSession aSession)
+{
+    LOGV("disconnect");
+    uint32 index = (uint32)aSession;
+    if(index >= iObservers.size())
+    {
+        // Invalid session ID
+        return PVMFFailure;
+    }
+
+    iObservers.erase(iObservers.begin()+index);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PvmiMediaTransfer* AndroidAudioInput::createMediaTransfer(PvmiMIOSession& aSession,
+        PvmiKvp* read_formats,
+        int32 read_flags,
+        PvmiKvp* write_formats,
+        int32 write_flags)
+{
+    LOGV("createMediaTransfer %p", this);
+    OSCL_UNUSED_ARG(read_formats);
+    OSCL_UNUSED_ARG(read_flags);
+    OSCL_UNUSED_ARG(write_formats);
+    OSCL_UNUSED_ARG(write_flags);
+
+    uint32 index = (uint32)aSession;
+    if(index >= iObservers.size())
+    {
+        LOGV("Invalid sessions ID: index %d, size%d", index, iObservers.size());
+        // Invalid session ID
+        OSCL_LEAVE(OsclErrArgument);
+        return NULL;
+    }
+
+    iWriteCompleteAO = OSCL_NEW(AndroidAudioInputThreadSafeCallbackAO,(this,5));
+
+    return (PvmiMediaTransfer*)this;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::deleteMediaTransfer(PvmiMIOSession& aSession,
+        PvmiMediaTransfer* media_transfer)
+{
+    LOGV("deleteMediaTransfer %p", this);
+    uint32 index = (uint32)aSession;
+    if(!media_transfer || index >= iObservers.size())
+    {
+        LOGV("Invalid sessions ID: index %d, size%d", index, iObservers.size());
+        // Invalid session ID
+        OSCL_LEAVE(OsclErrArgument);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::QueryUUID(const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+
+    int32 err = 0;
+    OSCL_TRY(err, aUuids.push_back(PVMI_CAPABILITY_AND_CONFIG_PVUUID););
+    OSCL_FIRST_CATCH_ANY(err, OSCL_LEAVE(OsclErrNoMemory););
+
+    return AddCmdToQueue(AI_CMD_QUERY_UUID, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::QueryInterface(const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    if(aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        PvmiCapabilityAndConfig* myInterface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*,this);
+        aInterfacePtr = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
+    else
+    {
+        aInterfacePtr = NULL;
+    }
+
+    return AddCmdToQueue(AI_CMD_QUERY_INTERFACE, aContext, (OsclAny*)&aInterfacePtr);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::Init(const OsclAny* aContext)
+{
+    LOGV("Init");
+    if(iState != STATE_IDLE)
+    {
+        LOGV("Invalid state");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(AI_CMD_INIT, aContext);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::Start(const OsclAny* aContext)
+{
+    LOGV("Start");
+    if(iState != STATE_INITIALIZED && iState != STATE_PAUSED)
+    {
+        LOGV("Invalid state");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(AI_CMD_START, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::Pause(const OsclAny* aContext)
+{
+    LOGV("Pause");
+    if(iState != STATE_STARTED)
+    {
+        LOGV("Invalid state");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(AI_CMD_PAUSE, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::Flush(const OsclAny* aContext)
+{
+    LOGV("Flush");
+    if(iState != STATE_STARTED || iState != STATE_PAUSED)
+    {
+        LOGV("Invalid state");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(AI_CMD_FLUSH, aContext);
+}
+
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::Reset(const OsclAny* aContext)
+{
+    LOGV("Reset");
+    if(iState != STATE_STARTED || iState != STATE_PAUSED)
+    {
+        LOGV("Invalid state");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(AI_CMD_RESET, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::DiscardData(PVMFTimestamp aTimestamp, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aTimestamp);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::DiscardData(const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::Stop(const OsclAny* aContext)
+{
+    LOGV("Stop %p", this);
+    if(iState != STATE_STARTED && iState != STATE_PAUSED)
+    {
+        LOGV("Invalid state");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(AI_CMD_STOP, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::ThreadLogon()
+{
+    LOGV("ThreadLogon %p", this);
+    if(!iThreadLoggedOn)
+    {
+        AddToScheduler();
+        iThreadLoggedOn = true;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::ThreadLogoff()
+{
+    LOGV("ThreadLogoff");
+    if(iThreadLoggedOn)
+    {
+        RemoveFromScheduler();
+        iThreadLoggedOn = false;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::CancelAllCommands( const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::CancelCommand( PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aCmdId);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::setPeer(PvmiMediaTransfer* aPeer)
+{
+    LOGV("setPeer");
+    if(iPeer || !aPeer)
+    {
+        OSCL_LEAVE(OsclErrGeneral);
+        return;
+    }
+
+    iPeer = aPeer;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::useMemoryAllocators(OsclMemAllocator* write_alloc)
+{
+    OSCL_UNUSED_ARG(write_alloc);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::writeAsync(uint8 aFormatType, int32 aFormatIndex,
+        uint8* aData, uint32 aDataLen,
+        const PvmiMediaXferHeader& data_header_info,
+        OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aFormatType);
+    OSCL_UNUSED_ARG(aFormatIndex);
+    OSCL_UNUSED_ARG(aData);
+    OSCL_UNUSED_ARG(aDataLen);
+    OSCL_UNUSED_ARG(data_header_info);
+    OSCL_UNUSED_ARG(aContext);
+    // This is an active data source. writeAsync is not supported.
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::writeComplete(PVMFStatus aStatus, PVMFCommandId write_cmd_id,
+        OsclAny* aContext)
+{
+    LOGV("writeComplete(%d, %p)", write_cmd_id, aContext);
+    OSCL_UNUSED_ARG(aContext);
+    if(aStatus != PVMFSuccess)
+    {
+        return;
+    }
+
+    if(iSentMediaData.empty())
+    {
+        // Error: Nothing to complete
+        return;
+    }
+
+    Oscl_Vector<AndroidAudioInputMediaData, OsclMemAllocator>::iterator it;
+    for(it = iSentMediaData.begin(); it != iSentMediaData.end(); it++)
+    {
+        if( it->iId == write_cmd_id )
+        {
+            iMediaBufferMemPool->deallocate(it->iData);
+            iSentMediaData.erase(it);
+            //check mem callback
+            AddDataEventToQueue(0);
+
+            //LOGE("writeComplete SentMediaQ out\n");
+            return;
+        }
+    }
+
+    // Error: unmatching ID. They should be in sequence
+    //LOGE("writeComplete ERROR SentMediaQ[0].iId %d write_cmd_id %d\n", iSentMediaData[0].iId, write_cmd_id);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::readAsync(uint8* data, uint32 max_data_len,
+        OsclAny* aContext, int32* formats, uint16 num_formats)
+{
+    OSCL_UNUSED_ARG(data);
+    OSCL_UNUSED_ARG(max_data_len);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(formats);
+    OSCL_UNUSED_ARG(num_formats);
+    // This is an active data source. readAsync is not supported.
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::readComplete(PVMFStatus aStatus, PVMFCommandId read_cmd_id,
+        int32 format_index, const PvmiMediaXferHeader& data_header_info,
+        OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aStatus);
+    OSCL_UNUSED_ARG(read_cmd_id);
+    OSCL_UNUSED_ARG(format_index);
+    OSCL_UNUSED_ARG(data_header_info);
+    OSCL_UNUSED_ARG(aContext);
+    // This is an active data source. readComplete is not supported.
+    OSCL_LEAVE(OsclErrNotSupported);
+    return;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::statusUpdate(uint32 status_flags)
+{
+    OSCL_UNUSED_ARG(status_flags);
+    // Ideally this routine should update the status of media input component.
+    // It should check then for the status. If media input buffer is consumed,
+    // media input object should be resheduled.
+    // Since the Media fileinput component is designed with single buffer, two
+    // asynchronous reads are not possible. So this function will not be required
+    // and hence not been implemented.
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::cancelCommand(PVMFCommandId aCmdId)
+{
+    OSCL_UNUSED_ARG(aCmdId);
+    // This cancel command ( with a small "c" in cancel ) is for the media transfer interface.
+    // implementation is similar to the cancel command of the media I/O interface.
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::cancelAllCommands()
+{
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus AndroidAudioInput::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    LOGV("getParametersSync(%s)", identifier);
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+    parameters = NULL;
+    num_parameter_elements = 0;
+    PVMFStatus status = PVMFFailure;
+
+    if( pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0 ||
+            pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
+        if(status != PVMFSuccess)
+        {
+            LOGV("AllocateKvp failed");
+        }
+        else
+        {
+            parameters[0].value.uint32_value = PVMF_PCM16;
+        }
+    }
+    else if(pv_mime_strcmp(identifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OUTPUT_TIMESCALE_CUR_VALUE, num_parameter_elements);
+        if(status != PVMFSuccess)
+        {
+            LOGV("AllocateKvp failed");
+            return status;
+        }
+
+        // XXX is it okay to hardcode this as the timescale?
+        parameters[0].value.uint32_value = 1000;
+    }
+
+    return status;
+}
+
+    ////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus AndroidAudioInput::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if(parameters)
+    {
+        iAlloc.deallocate((OsclAny*)parameters);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void AndroidAudioInput::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    LOGV("setParametersSync");
+    OSCL_UNUSED_ARG(session);
+    PVMFStatus status = PVMFSuccess;
+    ret_kvp = NULL;
+
+    for(int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+        if(status != PVMFSuccess)
+        {
+            LOGV("VerifyAndSetParameter failed");
+            ret_kvp = &(parameters[i]);
+            OSCL_LEAVE(OsclErrArgument);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId AndroidAudioInput::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 AndroidAudioInput::getCapabilityMetric (PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus AndroidAudioInput::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    return PVMFErrNotSupported;
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                            Private methods
+////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////
+void AndroidAudioInput::Run()
+{
+    if(!iCmdQueue.empty())
+    {
+        AndroidAudioInputCmd cmd = iCmdQueue[0];
+        iCmdQueue.erase(iCmdQueue.begin());
+
+        switch(cmd.iType)
+        {
+
+        case AI_CMD_INIT:
+            DoRequestCompleted(cmd, DoInit());
+            break;
+
+        case AI_CMD_START:
+            DoRequestCompleted(cmd, DoStart());
+            break;
+
+        case AI_CMD_PAUSE:
+            DoRequestCompleted(cmd, DoPause());
+            break;
+
+        case AI_CMD_FLUSH:
+            DoRequestCompleted(cmd, DoFlush());
+            break;
+
+        case AI_CMD_RESET:
+            DoRequestCompleted(cmd, DoReset());
+            break;
+
+        case AI_CMD_STOP:
+            DoRequestCompleted(cmd, DoStop());
+            break;
+
+        case AI_DATA_WRITE_EVENT:
+            DoRead();
+            break;
+
+        case AI_CMD_QUERY_UUID:
+        case AI_CMD_QUERY_INTERFACE:
+            DoRequestCompleted(cmd, PVMFSuccess);
+            break;
+
+        case AI_CMD_CANCEL_ALL_COMMANDS:
+        case AI_CMD_CANCEL_COMMAND:
+            DoRequestCompleted(cmd, PVMFFailure);
+            break;
+
+        default:
+            break;
+        }
+    }
+
+    if(!iCmdQueue.empty())
+    {
+        // Run again if there are more things to process
+        RunIfNotReady();
+    }
+
+    if(iState == STATE_STARTED)
+    {
+        SendMicData();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId AndroidAudioInput::AddCmdToQueue(AndroidAudioInputCmdType aType,
+        const OsclAny* aContext, OsclAny* aData1)
+{
+    if(aType == AI_DATA_WRITE_EVENT)
+        OSCL_LEAVE(OsclErrArgument);
+
+    AndroidAudioInputCmd cmd;
+    cmd.iType = aType;
+    cmd.iContext = OSCL_STATIC_CAST(OsclAny*, aContext);
+    cmd.iData1 = aData1;
+    cmd.iId = iCmdIdCounter;
+    ++iCmdIdCounter;
+    iCmdQueue.push_back(cmd);
+    RunIfNotReady();
+    return cmd.iId;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void AndroidAudioInput::AddDataEventToQueue(uint32 aMicroSecondsToEvent)
+{
+    AndroidAudioInputCmd cmd;
+    cmd.iType = AI_DATA_WRITE_EVENT;
+    iCmdQueue.push_back(cmd);
+    RunIfNotReady(aMicroSecondsToEvent);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void AndroidAudioInput::DoRequestCompleted(const AndroidAudioInputCmd& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    LOGV("DoRequestCompleted(%d, %d) this %p", aCmd.iId, aStatus, this);
+    PVMFCmdResp response(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+
+    for(uint32 i = 0; i < iObservers.size(); i++)
+        iObservers[i]->RequestCompleted(response);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::DoInit()
+{
+    LOGV("DoInit");
+
+    //calculate time for a buffer to fill
+    iAudioNumChannels = 1;
+    iMicroSecondsPerDataEvent = (int32)(1000000/iAudioSamplingRate);
+
+    iDataEventCounter = 0;
+
+    // Create memory pool for the media data, using the maximum frame size found earlier
+    int32 err = 0;
+    OSCL_TRY(err,
+        if(iMediaBufferMemPool)
+        {
+            OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+            iMediaBufferMemPool = NULL;
+        }
+        iMediaBufferMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (4));
+        if(!iMediaBufferMemPool)
+            OSCL_LEAVE(OsclErrNoMemory);
+    );
+    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
+
+    iState = STATE_INITIALIZED;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::DoStart()
+{
+    LOGV("DoStart");
+
+    iAudioThreadStartLock->lock();
+    iAudioThreadStarted = false;
+
+    OsclThread AudioInput_Thread;
+    OsclProcStatus::eOsclProcError ret = AudioInput_Thread.Create(
+            (TOsclThreadFuncPtr)start_audin_thread_func, 0,
+            (TOsclThreadFuncArg)this, Start_on_creation);
+
+    if ( OsclProcStatus::SUCCESS_ERROR != ret)
+    { // thread creation failed
+        LOGV("Failed to create thread");
+        iAudioThreadStartLock->unlock();
+        return PVMFFailure;
+    }
+
+    // wait for thread to set up AudioRecord
+    while (!iAudioThreadStarted)
+        iAudioThreadStartCV->wait(*iAudioThreadStartLock);
+
+    status_t startResult = iAudioThreadStartResult;
+    iAudioThreadStartLock->unlock();
+
+    if (startResult != NO_ERROR)
+        return PVMFFailure; // thread failed to set up AudioRecord
+
+    iState = STATE_STARTED;
+
+    AddDataEventToQueue(0);
+    return PVMFSuccess;
+}
+
+int AndroidAudioInput::start_audin_thread_func(TOsclThreadFuncArg arg)
+{
+    prctl(PR_SET_NAME, (unsigned long) "audio in", 0, 0, 0);
+    sp<AndroidAudioInput> obj =  (AndroidAudioInput *)arg;
+    return obj->audin_thread_func();
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::DoPause()
+{
+    LOGV("DoPause");
+    iExitAudioThread = true;
+    iState = STATE_PAUSED;
+    return PVMFSuccess;
+}
+
+PVMFStatus AndroidAudioInput::DoReset()
+{
+    LOGV("DoReset");
+    iExitAudioThread = true;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::DoFlush()
+{
+    // This method should stop capturing media data but continue to send captured
+    // media data that is already in buffer and then go to stopped state.
+    // However, in this case of file input we do not have such a buffer for
+    // captured data, so this behaves the same way as stop.
+    LOGV("DoFlush");
+    return DoStop();
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::DoStop()
+{
+    LOGV("DoStop");
+    iExitAudioThread = true;
+    iDataEventCounter = 0;
+    iState = STATE_STOPPED;
+    iAudioThreadSem->Signal();
+    iAudioThreadTermSem->Wait();
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::DoRead()
+{
+    LOGV("DoRead");
+    // Just copy from PVMFFileInputNode::HandleEventPortActivity.  The only difference
+    // is that data buffer is allocated by calling iMediaBufferMemPool->allocate(bytesToRead)
+    // and there's no need to wrap it in a PVMFSharedMediaDataPtr.  Also, you'll need to
+    // keep track of the data pointer and the write command id received from peer->writeAsync
+    // and put it in the iSentMediaData queue
+
+    if(iState != STATE_STARTED)
+    {
+        LOGV("not started");
+        return PVMFSuccess;
+    }
+
+    uint32 timeStamp = 0;
+    uint32 writeAsyncID = 0;
+
+    ++iDataEventCounter;
+
+    iOSSRequestQueueLock.Lock();
+    //allocate mem for the audio capture thread
+    // Create new media data buffer
+    int32 error = 0;
+    uint8* data = NULL;
+    OSCL_TRY(error,
+            data = (uint8*)iMediaBufferMemPool->allocate(kBufferSize);
+            );
+    if (error != OsclErrNone || !data )
+    {
+        LOGV("no data available");
+        iOSSRequestQueueLock.Unlock();
+
+        //TBD wait for mem callback
+        return PVMFSuccess;
+    }
+    else
+    {
+        iOSSRequestQueue.push_back(data);
+        iOSSRequestQueueLock.Unlock();
+        iAudioThreadSem->Signal();
+    }
+
+    // Queue the next data event
+    AddDataEventToQueue(iMicroSecondsPerDataEvent);
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+int AndroidAudioInput::audin_thread_func() {
+    // setup audio record session
+
+    iAudioThreadStartLock->lock();
+
+    LOGV("create AudioRecord %p", this);
+    android::AudioRecord
+            * record = new android::AudioRecord(
+                    android::AudioRecord::DEFAULT_INPUT, iAudioSamplingRate,
+                    android::AudioSystem::PCM_16_BIT, iAudioNumChannels, 4*kBufferSize/iAudioNumChannels/sizeof(int16));
+    LOGV("AudioRecord created %p, this %p", record, this);
+
+    status_t res = record->initCheck();
+    if (res == NO_ERROR)
+        res = record->start();
+
+    iAudioThreadStartResult = res;
+    iAudioThreadStarted = true;
+
+    iAudioThreadStartCV->signal();
+    iAudioThreadStartLock->unlock();
+
+    if (res == NO_ERROR) {
+
+        while (!iExitAudioThread) {
+            iOSSRequestQueueLock.Lock();
+            if (iOSSRequestQueue.empty()) {
+                iOSSRequestQueueLock.Unlock();
+                iAudioThreadSem->Wait();
+                continue;
+            }
+            uint8* data = iOSSRequestQueue[0];
+            iOSSRequestQueue.erase(&iOSSRequestQueue[0]);
+            iOSSRequestQueueLock.Unlock();
+
+            int numOfBytes = record->read(data, kBufferSize);
+            //LOGV("read %d bytes", numOfBytes);
+            if (numOfBytes <= 0)
+                break;
+
+            if (iTrackMaxAmplitude) {
+                short *p = (short*) data;
+                for (int i = numOfBytes >> 1; i > 0; --i) {
+                    short v = *p++;
+                    if (v < 0) {
+                        v = -v;
+                    }
+                    if (v > iMaxAmplitude) {
+                        iMaxAmplitude = v;
+                    }
+                }
+            }
+
+            int dataDuration = numOfBytes/iAudioNumChannels/ sizeof(short) * 1000
+                    / iAudioSamplingRate; //ms
+            MicData micdata(data, numOfBytes, iTimeStamp,
+                    dataDuration);
+            iWriteResponseQueueLock.Lock();
+            iWriteResponseQueue.push_back(micdata);
+            iWriteResponseQueueLock.Unlock();
+
+            iTimeStamp += dataDuration;
+            // Queue the next data event
+            OsclAny* P = NULL;
+            iWriteCompleteAO->ReceiveEvent(P);
+        }
+
+        LOGV("record->stop %p, this %p", record, this);
+        record->stop();
+    }
+
+    LOGV("delete record %p, this %p", record, this);
+    delete record;
+    iAudioThreadTermSem->Signal();
+    return 0;
+}
+
+void AndroidAudioInput::SendMicData(void)
+{
+    //LOGE("SendMicData in\n");
+    //ASSUMPTION: the output queue is always available. no wait
+    iWriteResponseQueueLock.Lock();
+    //LOGE("SendMicData QSize %d\n", iWriteResponseQueue.size());
+    if(iWriteResponseQueue.empty())
+    {
+        iWriteResponseQueueLock.Unlock();
+        return;
+    }
+    MicData &data = iWriteResponseQueue[0];
+    // send data to Peer & store the id
+    PvmiMediaXferHeader data_hdr;
+    data_hdr.seq_num=iDataEventCounter-1;
+    data_hdr.timestamp = data.iTimestamp;
+    data_hdr.flags=0;
+    data_hdr.duration = data.iDuration;
+    data_hdr.stream_id=0;
+    uint32 writeAsyncID = iPeer->writeAsync(0, 0, data.iData, data.iDataLen, data_hdr);
+
+    // Save the id and data pointer on iSentMediaData queue for writeComplete call
+    AndroidAudioInputMediaData sentData;
+    sentData.iId = writeAsyncID;
+    sentData.iData = data.iData;
+
+    iWriteResponseQueue.erase(&iWriteResponseQueue[0]);
+    iWriteResponseQueueLock.Unlock();
+
+    iSentMediaData.push_back(sentData);
+    //LOGE("SendMicData out SentQ size %d\n", iSentMediaData.size());
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
+{
+    uint8* buf = NULL;
+    uint32 keyLen = oscl_strlen(aKey) + 1;
+    int32 err = 0;
+
+    OSCL_TRY(err,
+            buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
+            if(!buf)
+            OSCL_LEAVE(OsclErrNoMemory);
+            );
+    OSCL_FIRST_CATCH_ANY(err, LOGV("allocation error"); return PVMFErrNoMemory;);
+
+    int32 i = 0;
+    PvmiKvp* curKvp = aKvp = new (buf) PvmiKvp;
+    buf += sizeof(PvmiKvp);
+    for(i = 1; i < aNumParams; i++)
+    {
+        curKvp += i;
+        curKvp = new (buf) PvmiKvp;
+        buf += sizeof(PvmiKvp);
+    }
+
+    for(i = 0; i < aNumParams; i++)
+    {
+        aKvp[i].key = (char*)buf;
+        oscl_strncpy(aKvp[i].key, aKey, keyLen);
+        buf += keyLen;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus AndroidAudioInput::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    if(!aKvp)
+    {
+        return PVMFFailure;
+    }
+
+    if(pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
+    {
+        if(aKvp->value.uint32_value == PVMF_PCM16)
+        {
+            return PVMFSuccess;
+        }
+        else
+        {
+            LOGV("unsupported format");
+            return PVMFFailure;
+        }
+    }
+
+    LOGV("unsupported parameter");
+    return PVMFFailure;
+}
+
+int AndroidAudioInput::maxAmplitude()
+{
+    // first call to this function activates tracking
+    if (!iTrackMaxAmplitude) {
+        iTrackMaxAmplitude = true;
+    }
+
+    int result = iMaxAmplitude;
+    iMaxAmplitude = 0;
+    return result;
+}
diff --git a/android/android_audio_input.h b/android/android_audio_input.h
new file mode 100644
index 0000000..2b96d66
--- /dev/null
+++ b/android/android_audio_input.h
@@ -0,0 +1,428 @@
+/*
+ * Copyright (c) 2008, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_INPUT_H_INCLUDED
+#define ANDROID_AUDIO_INPUT_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMI_MIO_CONTROL_H_INCLUDED
+#include "pvmi_mio_control.h"
+#endif
+#ifndef PVMI_MEDIA_TRANSFER_H_INCLUDED
+#include "pvmi_media_transfer.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+#ifndef ANDROID_AUDIO_INPUT_THREADSAFE_CALLBACK_AO_H_INCLUDED
+#include "android_audio_input_threadsafe_callbacks.h"
+#endif
+
+#include <utils/RefBase.h>
+
+namespace android {
+
+class AndroidAudioInput;
+class Mutex;
+class Condition;
+
+/**
+ * Enumerated list of asychronous commands for AndroidAudioInput
+ */
+typedef enum
+{
+    AI_CMD_QUERY_UUID,
+    AI_CMD_QUERY_INTERFACE,
+    AI_CMD_INIT,
+    AI_CMD_START,
+    AI_CMD_PAUSE,
+    AI_CMD_FLUSH,
+    AI_CMD_STOP,
+    AI_CMD_CANCEL_ALL_COMMANDS,
+    AI_CMD_CANCEL_COMMAND,
+    AI_CMD_RESET,
+    AI_DATA_READ_EVENT,
+    AI_DATA_WRITE_EVENT,
+    AI_INVALID_CMD
+} AndroidAudioInputCmdType;
+
+//Write command handling
+// the audio output thread queues the responses, this mio dequeues and processes them
+class WriteResponse
+{
+public:
+    WriteResponse(PVMFStatus s,PVMFCommandId id,const OsclAny* ctx,const PVMFTimestamp& ts)
+            :iStatus(s),iCmdId(id),iContext(ctx),iTimestamp(ts)
+    {}
+
+        PVMFStatus iStatus;
+        PVMFCommandId iCmdId;
+        const OsclAny* iContext;
+        PVMFTimestamp iTimestamp;
+};
+
+/**
+ * Class containing information for a command or data event
+ */
+class AndroidAudioInputCmd
+{
+public:
+    AndroidAudioInputCmd()
+    {
+        iId = 0;
+        iType = AI_INVALID_CMD;
+        iContext = NULL;
+        iData1 = NULL;
+    }
+
+    AndroidAudioInputCmd(const AndroidAudioInputCmd& aCmd)
+    {
+        Copy(aCmd);
+    }
+
+    ~AndroidAudioInputCmd() {}
+
+    AndroidAudioInputCmd& operator=(const AndroidAudioInputCmd& aCmd)
+    {
+        Copy(aCmd);
+        return (*this);
+    }
+
+    PVMFCommandId iId; /** ID assigned to this command */
+    int32 iType;  /** AndroidAudioInputCmdType value */
+    OsclAny* iContext;  /** Other data associated with this command */
+    OsclAny* iData1;  /** Other data associated with this command */
+
+private:
+
+    void Copy(const AndroidAudioInputCmd& aCmd)
+    {
+        iId = aCmd.iId;
+        iType = aCmd.iType;
+        iContext = aCmd.iContext;
+        iData1 = aCmd.iData1;
+    }
+};
+
+class AndroidAudioInputMediaData
+{
+public:
+    AndroidAudioInputMediaData()
+    {
+        iId = 0;
+        iData = NULL;
+    }
+
+    AndroidAudioInputMediaData(const AndroidAudioInputMediaData& aData)
+    {
+        iId = aData.iId;
+        iData = aData.iData;
+    }
+
+    PVMFCommandId iId;
+    OsclAny* iData;
+};
+
+
+//Audio output request handling
+// this mio queues the requests, the audio output thread dequeues and processes them
+class OSSRequest
+{
+public:
+    OSSRequest(uint8* data, uint32 len,PVMFCommandId id,const OsclAny* ctx,const PVMFTimestamp& ts)
+            :iData(data),iDataLen(len),iCmdId(id),iContext(ctx),iTimestamp(ts)
+    {}
+        uint8* iData;
+        uint32 iDataLen;
+        PVMFCommandId iCmdId;
+        const OsclAny* iContext;
+        PVMFTimestamp iTimestamp;
+};
+
+class MicData
+{
+public:
+    MicData(uint8* data, uint32 len, PVMFTimestamp& ts, int32 duration)
+        :iData(data),iDataLen(len),iTimestamp(ts),iDuration(duration)
+    {}
+    uint8* iData;
+    uint32 iDataLen;
+    PVMFTimestamp iTimestamp;
+    int32 iDuration;
+};
+
+
+class AndroidAudioInput : public OsclTimerObject,
+    public PvmiMIOControl,
+    public PvmiMediaTransfer,
+    public PvmiCapabilityAndConfig,
+    public RefBase
+{
+public:
+    AndroidAudioInput();
+    virtual ~AndroidAudioInput();
+
+    // Pure virtuals from PvmiMIOControl
+    OSCL_IMPORT_REF PVMFStatus connect(PvmiMIOSession& aSession, PvmiMIOObserver* aObserver);
+    OSCL_IMPORT_REF PVMFStatus disconnect(PvmiMIOSession aSession);
+    OSCL_IMPORT_REF PvmiMediaTransfer* createMediaTransfer(PvmiMIOSession& aSession,
+                                                         PvmiKvp* read_formats=NULL,
+                                                         int32 read_flags=0,
+                                                         PvmiKvp* write_formats=NULL,
+                                                         int32 write_flags=0);
+    OSCL_IMPORT_REF void deleteMediaTransfer(PvmiMIOSession& aSession,
+                                           PvmiMediaTransfer* media_transfer);
+    OSCL_IMPORT_REF PVMFCommandId QueryUUID(const PvmfMimeString& aMimeType,
+                                          Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+                                          bool aExactUuidsOnly=false,
+                                          const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId QueryInterface(const PVUuid& aUuid,
+                                               PVInterface*& aInterfacePtr,
+                                               const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId Init(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId Start(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId Reset(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId Pause(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId Flush(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId DiscardData(PVMFTimestamp aTimestamp, const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId DiscardData(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId Stop(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFCommandId aCmdId, const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(const OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF void ThreadLogon();
+    OSCL_IMPORT_REF void ThreadLogoff();
+
+    // Pure virtuals from PvmiMediaTransfer
+    OSCL_IMPORT_REF void setPeer(PvmiMediaTransfer* aPeer);
+    OSCL_IMPORT_REF void useMemoryAllocators(OsclMemAllocator* write_alloc=NULL);
+    OSCL_IMPORT_REF PVMFCommandId writeAsync(uint8 format_type, int32 format_index,
+                                           uint8* data, uint32 data_len,
+                                           const PvmiMediaXferHeader& data_header_info,
+                                           OsclAny* aContext=NULL);
+    OSCL_IMPORT_REF void writeComplete(PVMFStatus aStatus, PVMFCommandId write_cmd_id,
+                                     OsclAny* aContext);
+    OSCL_IMPORT_REF PVMFCommandId readAsync(uint8* data, uint32 max_data_len, OsclAny* aContext=NULL,
+                                          int32* formats=NULL, uint16 num_formats=0);
+    OSCL_IMPORT_REF void readComplete(PVMFStatus aStatus, PVMFCommandId read_cmd_id,
+                                    int32 format_index,
+                                    const PvmiMediaXferHeader& data_header_info,
+                                    OsclAny* aContext);
+    OSCL_IMPORT_REF void statusUpdate(uint32 status_flags);
+    OSCL_IMPORT_REF void cancelCommand(PVMFCommandId aCmdId);
+    OSCL_IMPORT_REF void cancelAllCommands();
+
+    // Pure virtuals from PvmiCapabilityAndConfig
+    OSCL_IMPORT_REF void setObserver (PvmiConfigAndCapabilityCmdObserver* aObserver);
+    OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                                               PvmiKvp*& aParameters, int& num_parameter_elements,
+                                               PvmiCapabilityContext aContext);
+    OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements);
+    OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+    OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                                            PvmiKvp* aParameters, int num_parameter_elements);
+    OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+    OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                         int num_elements, PvmiKvp * & aRet_kvp);
+    OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                                   int num_elements, PvmiKvp*& aRet_kvp,
+                                                   OsclAny* context=NULL);
+    OSCL_IMPORT_REF uint32 getCapabilityMetric (PvmiMIOSession aSession);
+    OSCL_IMPORT_REF PVMFStatus verifyParametersSync (PvmiMIOSession aSession,
+                                                   PvmiKvp* aParameters, int num_elements);
+
+    // Android-specific stuff
+
+    /* Returns the max absolute amplitude since the last call of this function. Used for
+     * visualization.
+     */
+    int maxAmplitude();
+
+private:
+    void Run();
+
+    int audin_thread_func();
+    static int start_audin_thread_func(TOsclThreadFuncArg arg);
+    void SendMicData(void);
+
+    PVMFCommandId AddCmdToQueue(AndroidAudioInputCmdType aType, const OsclAny* aContext, OsclAny* aData1 = NULL);
+    void AddDataEventToQueue(uint32 aMicroSecondsToEvent);
+    void DoRequestCompleted(const AndroidAudioInputCmd& aCmd, PVMFStatus aStatus, OsclAny* aEventData=NULL);
+    PVMFStatus DoInit();
+    PVMFStatus DoStart();
+    PVMFStatus DoReset();
+    PVMFStatus DoPause();
+    PVMFStatus DoFlush();
+    PVMFStatus DoStop();
+    PVMFStatus DoRead();
+
+    /**
+     * Allocate a specified number of key-value pairs and set the keys
+     *
+     * @param aKvp Output parameter to hold the allocated key-value pairs
+     * @param aKey Key for the allocated key-value pairs
+     * @param aNumParams Number of key-value pairs to be allocated
+     * @return Completion status
+     */
+    PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
+
+    /**
+     * Verify one key-value pair parameter against capability of the port and
+     * if the aSetParam flag is set, set the value of the parameter corresponding to
+     * the key.
+     *
+     * @param aKvp Key-value pair parameter to be verified
+     * @param aSetParam If true, set the value of parameter corresponding to the key.
+     * @return PVMFSuccess if parameter is supported, else PVMFFailure
+     */
+    PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam=false);
+
+    // Command queue
+    uint32 iCmdIdCounter;
+    Oscl_Vector<AndroidAudioInputCmd, OsclMemAllocator> iCmdQueue;
+
+    // PvmiMIO sessions
+    Oscl_Vector<PvmiMIOObserver*, OsclMemAllocator> iObservers;
+
+    PvmiMediaTransfer* iPeer;
+
+    // Thread logon
+    bool iThreadLoggedOn;
+
+    // semaphore used to communicate with the audio input thread
+    OsclSemaphore* iAudioThreadSem;
+    // and another one
+    OsclSemaphore* iAudioThreadTermSem;
+
+    volatile bool iExitAudioThread;
+    bool iWriteBusy;
+    uint32 iWriteBusySeqNum;
+
+    PvmiMIOObserver* iObserver;
+
+
+    uint32 iCommandCounter;
+
+    //Control command handling.
+    class CommandResponse
+    {
+    public:
+        CommandResponse(PVMFStatus s,PVMFCommandId id,const OsclAny* ctx)
+            :iStatus(s),iCmdId(id),iContext(ctx)
+        {}
+
+        PVMFStatus iStatus;
+        PVMFCommandId iCmdId;
+        const OsclAny* iContext;
+    };
+    Oscl_Vector<CommandResponse,OsclMemAllocator> iCommandResponseQueue;
+
+    //Audio parameters.
+    OSCL_HeapString<OsclMemAllocator> iAudioFormatString;
+    PVMFFormatType iAudioFormat;
+    int32 iAudioNumChannels;
+    bool iAudioNumChannelsValid;
+    int32 iAudioSamplingRate;
+    bool iAudioSamplingRateValid;
+
+    int32 iFrameSize;
+    int32 iDataEventCounter;
+
+    // Functions specific to this MIO
+
+    //request active object which the audio output thread uses to schedule this timer object to run
+    AndroidAudioInputThreadSafeCallbackAO *iWriteCompleteAO;
+
+    // write response queue, needs to use lock mechanism to access
+    //Oscl_Vector<WriteResponse,OsclMemAllocator> iWriteResponseQueue;
+    Oscl_Vector<MicData,OsclMemAllocator> iWriteResponseQueue;
+
+    // lock used to access the write response queue
+    OsclMutex iWriteResponseQueueLock;
+
+    // oss request queue, needs to use lock mechanism to access
+    //Oscl_Vector<OSSRequest,OsclMemAllocator> iOSSRequestQueue;
+    Oscl_Vector<uint8*, OsclMemAllocator> iOSSRequestQueue;
+
+    // lock used to access the oss request queue
+    OsclMutex iOSSRequestQueueLock;
+
+    // Timing
+    int32 iMilliSecondsPerDataEvent;
+    int32 iMicroSecondsPerDataEvent;
+    PVMFTimestamp iTimeStamp;
+
+    // Allocator for simple media data buffer
+    OsclMemAllocator iAlloc;
+    OsclMemPoolFixedChunkAllocator* iMediaBufferMemPool;
+
+    Oscl_Vector<AndroidAudioInputMediaData, OsclMemAllocator> iSentMediaData;
+
+    // State machine
+    enum AndroidAudioInputState
+    {
+        STATE_IDLE,
+        STATE_INITIALIZED,
+        STATE_STARTED,
+        STATE_FLUSHING,
+        STATE_PAUSED,
+        STATE_STOPPED
+    };
+
+    AndroidAudioInputState iState;
+
+    FILE *fp;
+
+    volatile int iMaxAmplitude;
+    volatile bool iTrackMaxAmplitude;
+
+    // synchronize startup of audio input thread, so we can return an error
+    // from DoStart() if something goes wrong
+    Mutex *iAudioThreadStartLock;
+    Condition *iAudioThreadStartCV;
+    volatile status_t iAudioThreadStartResult;
+    volatile bool iAudioThreadStarted;
+};
+
+}; // namespace android
+
+#endif // ANDROID_AUDIO_INPUT_H_INCLUDED
diff --git a/android/android_audio_mio.cpp b/android/android_audio_mio.cpp
old mode 100644
new mode 100755
index e49e318..165d683
--- a/android/android_audio_mio.cpp
+++ b/android/android_audio_mio.cpp
@@ -61,6 +61,7 @@
 
 void AndroidAudioMIO::initData()
 {
+    LOGV("initData in");
     ResetData();
 
     iCommandCounter = 0;
@@ -71,26 +72,29 @@
     iObserver = NULL;
     iLogger = NULL;
     iPeer = NULL;
-    iState = STATE_IDLE;
+    iState = STATE_MIO_IDLE;
     iWriteBusy = false;
-    iWriteBusySeqNum = 0;
     iFlushPending = false;
     iDataQueued = 0;
+    LOGV("initData out");
 }
 
 void AndroidAudioMIO::ResetData()
 //reset all data from this session.
 {
+    LOGV("ResetData in");
     // reset all the received media parameters.
-    iAudioFormat = PVMF_FORMAT_UNKNOWN;
+    iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iAudioNumChannelsValid = false;
     iAudioSamplingRateValid = false;
+    iAudioThreadCreatedAndMIOConfigured = false;
+    LOGV("ResetData out");
 }
 
 //cleanup all allocated memory and release resources.
 void AndroidAudioMIO::Cleanup()
 {
-    LOGV("Cleanup");
+    LOGV("Cleanup in");
     while (!iCommandResponseQueue.empty()) {
         if (iObserver) {
             iObserver->RequestCompleted(PVMFCmdResp(iCommandResponseQueue[0].iCmdId,
@@ -108,6 +112,7 @@
         iWriteCompleteAO = NULL;
     }
     iWriteResponseQueueLock.Close();
+    LOGV("Cleanup out");
 }
 
 PVMFStatus AndroidAudioMIO::connect(PvmiMIOSession& aSession, PvmiMIOObserver* aObserver)
@@ -158,6 +163,7 @@
 // return any held buffers to the engine
 void AndroidAudioMIO::ProcessWriteResponseQueue()
 {
+    //LOGV("ProcessWriteResponseQueue in [Response Q size %d]",iWriteResponseQueue.size());
     PVMFStatus status = 0;
     PVMFCommandId cmdId = 0;
     const OsclAny* context = 0;
@@ -170,12 +176,13 @@
         iWriteResponseQueue.erase(&iWriteResponseQueue[0]);
         iWriteResponseQueueLock.Unlock();
         if (iPeer) {
-            LOGV("Return buffer (%d)", cmdId);
+            LOGV("Return buffer(%d) status(%d) context(%p)", cmdId,status,context);
             iPeer->writeComplete(status, cmdId, (OsclAny*)context);
         }
         iWriteResponseQueueLock.Lock();
     }
     iWriteResponseQueueLock.Unlock();
+    //LOGV("ProcessWriteResponseQueue out");
 }
 
 PVMFCommandId AndroidAudioMIO::QueryUUID(const PvmfMimeString& aMimeType,
@@ -204,22 +211,23 @@
 {
     LOGV("Init (%p)", aContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::Init() called"));
-    iState=STATE_INITIALIZED;
+    iState=STATE_MIO_INITIALIZED;
     return QueueCmdResponse(PVMFSuccess, aContext);
 }
 
 PVMFCommandId AndroidAudioMIO::Reset(const OsclAny* aContext)
 {
-    // Do nothing for now
     LOGV("Reset (%p)", aContext);
-    return PVMFSuccess;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::Reset() called"));
+    return QueueCmdResponse(PVMFSuccess, aContext);
 }
 
 PVMFCommandId AndroidAudioMIO::Start(const OsclAny* aContext)
 {
+    // Start is NO-OP 
     LOGV("Start (%p)", aContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::Start() called"));
-    iState = STATE_STARTED;
+    iState = STATE_MIO_STARTED;
     return QueueCmdResponse(PVMFSuccess, aContext);
 }
 
@@ -227,7 +235,7 @@
 {
     LOGV("Pause (%p)", aContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::Pause() called"));
-    iState = STATE_PAUSED;
+    iState = STATE_MIO_PAUSED;
     return QueueCmdResponse(PVMFSuccess, aContext);
 }
 
@@ -236,7 +244,7 @@
 {
     LOGV("Flush (%p)", aContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::Flush() called"));
-    iState = STATE_INITIALIZED;
+    iState = STATE_MIO_INITIALIZED;
     return QueueCmdResponse(PVMFSuccess, aContext);
 }
 
@@ -258,7 +266,7 @@
 {
     LOGV("Stop (%p)", aContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::Stop() called"));
-    iState = STATE_INITIALIZED;
+    iState = STATE_MIO_INITIALIZED;
     return QueueCmdResponse(PVMFSuccess, aContext);
 }
 
@@ -290,21 +298,23 @@
 
 void AndroidAudioMIO::ThreadLogon()
 {
+    LOGV("ThreadLogon() called ");
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::ThreadLogon() called"));
-    if (iState == STATE_IDLE) {
+    if (iState == STATE_MIO_IDLE) {
         iLogger = PVLogger::GetLoggerObject("AndroidAudioMIO\n");
         AddToScheduler();
-        iState=STATE_LOGGED_ON;
+        iState=STATE_MIO_LOGGED_ON;
     }
 }
 
 void AndroidAudioMIO::ThreadLogoff()
 {
+    LOGV("ThreadLogoff() called");
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidAudioMIO::ThreadLogoff() called"));
-    if (iState!=STATE_IDLE) {
+    if (iState!=STATE_MIO_IDLE) {
         RemoveFromScheduler();
         iLogger = NULL;
-        iState = STATE_IDLE;
+        iState = STATE_MIO_IDLE;
         ResetData();
     }
 }
@@ -328,12 +338,24 @@
 PVMFCommandId AndroidAudioMIO::writeAsync(uint8 aFormatType, int32 aFormatIndex, uint8* aData, uint32 aDataLen,
                                         const PvmiMediaXferHeader& data_header_info, OsclAny* aContext)
 {
+    // Do a leave if MIO is not configured except when it is an EOS
+    if (!iAudioThreadCreatedAndMIOConfigured
+            &&
+            !((PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == aFormatType)
+              && (PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM == aFormatIndex)))
+    {
+        LOGE("ERROR :: data is pumped in before mio configured");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
     uint32 aSeqNum = data_header_info.seq_num;
     PVMFTimestamp aTimestamp = data_header_info.timestamp;
     uint32 flags = data_header_info.flags;
 
     bool bWriteComplete = true;
 
+    //LOGV("writeAsync() called seqnum %d ts %d flags %d context %d formattype %d formatindex %d",aSeqNum, aTimestamp, flags,aContext,aFormatType,aFormatIndex);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
         (0,"AndroidAudioMIO::writeAsync() seqnum %d ts %d flags %d context %d",
          aSeqNum, aTimestamp, flags,aContext));
@@ -382,7 +404,6 @@
 
                 //schedule an event to re-start the data flow.
                 iWriteBusy = true;
-                iWriteBusySeqNum = aSeqNum;
                 bWriteComplete = false;
 
                 // Rich:: commenting in this line.
@@ -396,7 +417,9 @@
                     // this buffer cannot be write completed until
                     // it has been processed by the audio output thread
                     bWriteComplete = false;
-                } else { PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                } else { 
+                       LOGE("writeAsync() called with aDataLen==0");
+                       PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
                             (0,"AndroidAudioMIO::writeAsync() called aDataLen==0."));
                 }
                 status = PVMFSuccess;
@@ -404,7 +427,7 @@
             break;
 
         default:
-            LOGV("aFormatIndex=%u", aFormatIndex);
+            LOGE("Error unrecognized format index =%u", aFormatIndex);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                 (0,"AndroidAudioMIO::writeAsync: Error - unrecognized format index"));
             status = PVMFFailure;
@@ -413,7 +436,7 @@
         break;
 
     default:
-        LOGV("aFormatType=%u", aFormatType);
+        LOGE("Error unrecognized format type =%u", aFormatType);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
             (0,"AndroidAudioMIO::writeAsync: Error - unrecognized format type"));
         status = PVMFFailure;
@@ -441,49 +464,83 @@
                                               PvmiKvp*& aParameters, int& num_parameter_elements,
                                               PvmiCapabilityContext aContext)
 {
+    LOGV("getParametersSync in %s",aIdentifier);
     OSCL_UNUSED_ARG(aSession);
     OSCL_UNUSED_ARG(aContext);
     aParameters=NULL;
     num_parameter_elements=0;
+    PVMFStatus status = PVMFFailure;
 
     if(pv_mime_strcmp(aIdentifier, INPUT_FORMATS_CAP_QUERY) == 0) {
         //This is a query for the list of supported formats.
         aParameters=(PvmiKvp*)oscl_malloc(2 * sizeof(PvmiKvp));
         if (aParameters) {
-            aParameters[num_parameter_elements++].value.uint32_value = PVMF_PCM16;
-            aParameters[num_parameter_elements++].value.uint32_value = PVMF_PCM8;
-            return PVMFSuccess;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM16;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM8;
+            status = PVMFSuccess;
         }
-        return PVMFErrNoMemory;
+        else{
+            status = PVMFErrNoMemory;
+        }
     }
     //other queries are not currently supported.
 
     //unrecognized key.
-    return PVMFFailure;
+    LOGV("getParametersSync out status %d",status);
+    return status;
 }
 
 PVMFStatus AndroidAudioMIO::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
 {
+    LOGV("releaseParameters in");
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(num_elements);
+    PVMFStatus status = PVMFFailure;
     //release parameters that were allocated by this component.
     if (aParameters) {
         oscl_free(aParameters);
-        return PVMFSuccess;
+        status = PVMFSuccess;
     }
-    return PVMFFailure;
+    LOGV("releaseParameters out status %d",status);
+    return status;
 }
 
+PVMFStatus AndroidAudioMIO::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    //LOGV("verifyParametersSync in");
+
+    // Go through each parameter
+    for (int32 i=0; i<num_elements; i++) {
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[i].key, compstr);
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media/format-type")) == 0) {
+            if ((pv_mime_strcmp(aParameters[i].value.pChar_value, PVMF_MIME_PCM8) == 0) ||
+                (pv_mime_strcmp(aParameters[i].value.pChar_value, PVMF_MIME_PCM16) == 0)
+               ) {
+                return PVMFSuccess;
+            }
+            else {
+                return PVMFErrNotSupported;
+            }
+        }
+    }
+    return PVMFSuccess;
+    //LOGV("verifyParametersSync out");
+
+}
 void AndroidAudioMIO::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
                                         int num_elements, PvmiKvp * & aRet_kvp)
 {
     OSCL_UNUSED_ARG(aSession);
-
+    //LOGV("setParametersSync in");
     aRet_kvp = NULL;
 
     for (int32 i=0;i<num_elements;i++) {
         //Check against known audio parameter keys...
         if (pv_mime_strcmp(aParameters[i].key, MOUT_AUDIO_FORMAT_KEY) == 0) {
             LOGV("Audio format: %s", aParameters[i].value.pChar_value);
-            iAudioFormat=GetFormatIndex(aParameters[i].value.pChar_value);
+            iAudioFormat=aParameters[i].value.pChar_value;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                 (0,"AndroidAudioOutput::setParametersSync() Audio Format Key, Value %s",aParameters[i].value.pChar_value));
         } else if (pv_mime_strcmp(aParameters[i].key, MOUT_AUDIO_SAMPLING_RATE_KEY) == 0) {
@@ -500,9 +557,8 @@
                 (0,"AndroidAudioMIO::setParametersSync() Audio Num Channels Key, Value %d",iAudioNumChannels));
         } else {
             //if we get here the key is unrecognized.
-
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                (0,"AndroidAudioMIO::setParametersSync() Error, unrecognized key "));
+                (0,"AndroidAudioMIO::setParametersSync() Error, unrecognized key %s",aParameters[i].key));
 
             //set the return value to indicate the unrecognized key
             //and return.
@@ -510,6 +566,8 @@
             return;
         }
     }
+
+    //LOGV("setParametersSync out");
 }
 
 //
@@ -557,112 +615,157 @@
 
 void AndroidAudioMIO::setAudioSink(const sp<MediaPlayerInterface::AudioSink>& audioSink)
 {
+    LOGV("setAudioSink in");
     mAudioSink = audioSink;
 }
 
-///------------------------------------------------------------------------
+//------------------------------------------------------------------------
 // Active timing support
 //
-OSCL_EXPORT_REF PVMFStatus AndroidAudioMIOActiveTimingSupport::SetClock(OsclClock *clockVal)
+OSCL_EXPORT_REF PVMFStatus AndroidAudioMIOActiveTimingSupport::SetClock(PVMFMediaClock *clockVal)
 {
+    LOGV("ATS :: SetClock in");
     iClock=clockVal;
-    if (iClock)
-        iClock->SetClockStateObserver(*this);
+    
     return PVMFSuccess;
 }
 
+void AndroidAudioMIOActiveTimingSupport::NotificationsInterfaceDestroyed()
+{
+    LOGV("ATS :: NotificationsInterfaceDestroyed in");
+    iClockNotificationsInf=NULL;
+}
+
+
 OSCL_EXPORT_REF bool AndroidAudioMIOActiveTimingSupport::queryInterface(const PVUuid& aUuid, PVInterface*& aInterface)
 {
     aInterface = NULL;
     PVUuid uuid;
     queryUuid(uuid);
+    bool status = false;
     if (uuid == aUuid) {
         PvmiClockExtensionInterface* myInterface = OSCL_STATIC_CAST(PvmiClockExtensionInterface*, this);
         aInterface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        return true;
+        status = true;
     }
-    return false;
+    LOGV("ATS :: queryInterface out status %d",status);
+    return status;
 }
 
 void AndroidAudioMIOActiveTimingSupport::queryUuid(PVUuid& uuid)
 {
+    LOGV("ATS :: queryUuid in");
     uuid = PvmiClockExtensionInterfaceUuid;
 }
 
 void AndroidAudioMIOActiveTimingSupport::ClockStateUpdated()
 {
+    LOGV("ATS :: ClockStateUpdated in");
     if (iClock) {
-        OsclClock::OsclClockState newClockState = iClock->GetState();
+       
+        PVMFMediaClock::PVMFMediaClockState newClockState = iClock->GetState();
         if (newClockState != iClockState) {
             iClockState = newClockState;
             switch (iClockState) {
-            case OsclClock::STOPPED:
+            case PVMFMediaClock::STOPPED:
                 LOGV("A/V clock stopped");
                 break;
-            case OsclClock::RUNNING:
+            case PVMFMediaClock::RUNNING:
                 LOGV("A/V clock running");
                 // must be seeking, get new clock offset for A/V sync
                 if (iUpdateClock) {
-                    iClock->GetCurrentTime64(iStartTime, OSCLCLOCK_MSEC);
+                    bool overflowFlag = false;
+                    uint32 currentTimeBase32 = 0;
+                    iClock->GetCurrentTime32(iStartTime, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, currentTimeBase32);
                     iFrameCount = 0;
                     iUpdateClock = false;
-                    LOGV("update iStartTime: %llu", iStartTime);
+                    LOGV("update iStartTime: %d", iStartTime);
                 }
                 LOGV("signal thread to start");
                 if (iAudioThreadSem) iAudioThreadSem->Signal();
                 break;
-            case OsclClock::PAUSED:
+            case PVMFMediaClock::PAUSED:
                 LOGV("A/V clock paused");
                 break;
             default:
+                LOGE("Wrong clock state!");
                 break;
             }
         }
     }
+    LOGV("ATS :: ClockStateUpdated out");
 }
 
 void AndroidAudioMIOActiveTimingSupport::UpdateClock()
 {
-    uint64 clockTime64, timeBaseTime64, updateClock;
-    int64 correction = 0;
-
-    if (iClock && (iClockState == OsclClock::RUNNING)) {
-
+    LOGV("ATS :: UpdateClock in");
+    if (iClock && (iClockState == PVMFMediaClock::RUNNING)) {
+        uint32 clockTime32, timeBaseTime32, updateClock32;
+        int32 correction = 0;
+        bool overflowFlag = false;
         // get current time
-        iClock->GetCurrentTime64(clockTime64, OSCLCLOCK_MSEC, timeBaseTime64);
-        LOGV("PV clock current = %llu", clockTime64);
+        iClock->GetCurrentTime32(clockTime32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timeBaseTime32);
+        LOGV("PV clock current = %u", clockTime32);
 
         // calculate sample clock
-        uint64 updateClock = iFrameCount * iMsecsPerFrame;
-        LOGV("sample clock = %llu", updateClock);
+        updateClock32 = iFrameCount * iMsecsPerFrame;
+        LOGV("sample clock = %u frameCount(%u) msecsPerFrame(%f)", updateClock32,iFrameCount,iMsecsPerFrame);
 
         // startup - force clock backwards to compensate for latency
-        if (updateClock < iDriverLatency) {
-            LOGV("iStartTime = %llu", iStartTime);
-            LOGV("iDriverLatency = %u", iDriverLatency);
-            LOGV("latency stall - forcing clock");
-            correction = iStartTime - clockTime64;
-            LOGV("latency correction = %lld", correction);
+        if (updateClock32 < iDriverLatency) {
+            LOGV("iStartTime = %u , iDriverLatency = %u",iStartTime, iDriverLatency);
+            correction = iStartTime - clockTime32;
+            LOGV("latency stall - forcing clock (correction = %d)",correction);
         }
 
         // normal play mode - check delta between PV engine clock and sample clock
         else {
-            correction = (updateClock - iDriverLatency) - (clockTime64 - iStartTime);
+            correction = (updateClock32 - iDriverLatency) - (clockTime32 - iStartTime);
+            LOGV("clock drift (correction = (updateClock32(%d)-iDriverLatency(%d))-(clockTime32(%d)-iStartTime(%d))= %d)",updateClock32,iDriverLatency,clockTime32,iStartTime,correction);
         }
 
         // do clock correction if drift exceeds threshold
-        LOGV("drift = %lld", correction);
         if (OSCL_ABS(correction) > iMinCorrection) {
             if (correction > iMaxCorrection) {
                 correction = iMaxCorrection;
             } else if (correction < -iMaxCorrection) {
                 correction = -iMaxCorrection;
             }
-            updateClock = clockTime64 + correction;
-            LOGV("drift correction = %lld, new clock = %llu", correction, updateClock);
-            if (!iClock->AdjustClockTime64(clockTime64, timeBaseTime64, updateClock, OSCLCLOCK_MSEC))
-                LOGE("Error adjusting clock");
+            updateClock32 = clockTime32 + correction;
+            LOGV("drift correction = %d, new clock = %u", correction, updateClock32);
+            PVMFMediaClockAdjustTimeStatus adjustmentstatus = 
+            iClock->AdjustClockTime32(clockTime32, timeBaseTime32, updateClock32,PVMF_MEDIA_CLOCK_MSEC,overflowFlag);
+
+            if ((PVMF_MEDIA_CLOCK_ADJUST_SUCCESS != adjustmentstatus))
+            {
+                LOGE("Error adjusting clock status = %d",adjustmentstatus);
+            }
+            if(overflowFlag) {
+            LOGE("Adjusting clock caused overflow");
+            }
+        }
+        else{
+            LOGV("ATS :: sample clock and pv clock are close enough no need to update");
         }
     }
+    LOGV("ATS :: UpdateClock out");
+}
+void AndroidAudioMIOActiveTimingSupport::setDriverLatency(uint32 latency)
+{
+    LOGV("ATS :: setDriverLatency in");
+    iDriverLatency = latency;
+    if (iClock){
+        LOGV("register latency to media clock and set clockobserver");
+        PVMFStatus ret = iClock->ConstructMediaClockNotificationsInterface(iClockNotificationsInf,*this,latency);
+        if(iClockNotificationsInf && (PVMFSuccess == ret))
+        {
+            iClockNotificationsInf->SetClockStateObserver(*this);
+        }
+        else
+        {
+            LOGE("latency could NOT be set !! set it later ");
+        }
+    }
+    LOGV("ATS :: setDriverLatency out");
 }
 
diff --git a/android/android_audio_mio.h b/android/android_audio_mio.h
old mode 100644
new mode 100755
index 146c5b1..232fd03
--- a/android/android_audio_mio.h
+++ b/android/android_audio_mio.h
@@ -46,9 +46,9 @@
 #ifndef ANDROID_AUDIO_OUTPUT_THREADSAFE_CALLBACK_AO_H_INCLUDED
 #include "android_audio_output_threadsafe_callbacks.h"
 #endif
-
-#include "oscl_clock.h"
-
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
 #ifdef PERFORMANCE_MEASUREMENTS_ENABLED
 #ifndef _PVPROFILE_H
 #include "pvprofile.h"
@@ -58,7 +58,7 @@
 #include <media/MediaPlayerInterface.h>
 
 class PVLogger;
-class OsclClock;
+class PVMFMediaClock;
 
 using namespace android;
 
@@ -79,13 +79,14 @@
 
 // Active timing support
 class AndroidAudioMIOActiveTimingSupport :
-    public PvmiClockExtensionInterface, public OsclClockStateObserver
+    public PvmiClockExtensionInterface, public PVMFMediaClockStateObserver 
 {
 public:
 
-    AndroidAudioMIOActiveTimingSupport(uint32 minCorrection=0, uint32 maxCorrection=0) :
+    AndroidAudioMIOActiveTimingSupport(int32 minCorrection=0, int32 maxCorrection=0) :
         iClock(NULL),
-        iClockState(OsclClock::STOPPED),
+        iClockNotificationsInf(NULL),
+        iClockState(PVMFMediaClock::STOPPED),
         iAudioThreadSem(0),
         iStartTime(0),
         iFrameCount(0),
@@ -99,46 +100,52 @@
 
     ~AndroidAudioMIOActiveTimingSupport()
     {
-        if (iClock)
-            iClock->RemoveClockStateObserver(*this);
+        if (iClock && iClockNotificationsInf)
+        {
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+            iClockNotificationsInf = NULL;
+        }
     }
 
     //from PvmiClockExtensionInterface
-    OSCL_IMPORT_REF PVMFStatus SetClock(OsclClock *clockVal);
+    OSCL_IMPORT_REF PVMFStatus SetClock(PVMFMediaClock* clockVal);
 
-    // from OsclClockStateObserver
+    // from PVMFMediaClockStateObserver
     void ClockStateUpdated();
 
     //from PVInterface
     OSCL_IMPORT_REF void addRef() {}
     OSCL_IMPORT_REF void removeRef() {}
     OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+    void NotificationsInterfaceDestroyed();
 
     void queryUuid(PVUuid& uuid);
 
     void ForceClockUpdate() { iUpdateClock = true; }
     void UpdateClock();
 
-    OsclClock::OsclClockState clockState() { return iClockState; }
+    PVMFMediaClock::PVMFMediaClockState clockState() { return iClockState; }
     void setThreadSemaphore(OsclSemaphore* s) { iAudioThreadSem = s; }
 
-    void setDriverLatency(uint32_t latency) { iDriverLatency = latency; }
+    void setDriverLatency(uint32 latency);
     void incFrameCount(uint32_t numFrames) { iFrameCount += numFrames; }
     void setFrameRate(float msecsPerFrame) { iMsecsPerFrame = msecsPerFrame; }
     float msecsPerFrame() { return iMsecsPerFrame; }
 
 private:
-    OsclClock* iClock;
-    OsclClock::OsclClockState iClockState;
+    PVMFMediaClock* iClock;
+    PVMFMediaClockNotificationsInterface *iClockNotificationsInf;
+    PVMFMediaClock::PVMFMediaClockState iClockState;
     OsclSemaphore* iAudioThreadSem;
 
-    uint64 iStartTime;
-    uint64 iFrameCount;
+    uint32 iStartTime;
+    uint32 iFrameCount;
     float iMsecsPerFrame;
     uint32 iDriverLatency;
     bool iUpdateClock;
-    int64 iMinCorrection;
-    int64 iMaxCorrection;
+    int32 iMinCorrection;
+    int32 iMaxCorrection;
 };
 
 // Audio MIO component
@@ -254,9 +261,7 @@
 
     uint32 getCapabilityMetric (PvmiMIOSession aSession) { return 0; }
 
-    PVMFStatus verifyParametersSync (PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements) {
-        return PVMFSuccess;
-    }
+    PVMFStatus verifyParametersSync (PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
 
     // Functions specific to this MIO
     void setAudioSink(const sp<MediaPlayerInterface::AudioSink>& audioSink);
@@ -297,15 +302,15 @@
     uint32 iCommandCounter;
 
     //State
-    enum PVRefFOState
+    enum PVAudioMIOState
     {
-        STATE_IDLE
-        ,STATE_LOGGED_ON
-        ,STATE_INITIALIZED
-        ,STATE_STARTED
-        ,STATE_PAUSED
+        STATE_MIO_IDLE
+        ,STATE_MIO_LOGGED_ON
+        ,STATE_MIO_INITIALIZED
+        ,STATE_MIO_STARTED
+        ,STATE_MIO_PAUSED
     };
-    PVRefFOState iState;
+    PVAudioMIOState iState;
 
     // Control command handling.
     class CommandResponse
@@ -330,16 +335,15 @@
     int32 iAudioSamplingRate;
     bool iAudioSamplingRateValid;
 
+    bool iAudioThreadCreatedAndMIOConfigured;
+
     // For logging
     PVLogger* iLogger;
 
     // For implementing the write flow control
     bool iWriteBusy;
-    uint32 iWriteBusySeqNum;
     bool CheckWriteBusy(uint32);
 
-    uint64 iDriverLatency;
-
     bool iFlushPending;
     uint32 iDataQueued;
 
diff --git a/android/android_audio_output.cpp b/android/android_audio_output.cpp
old mode 100644
new mode 100755
index 9e60974..ab20c83
--- a/android/android_audio_output.cpp
+++ b/android/android_audio_output.cpp
@@ -32,8 +32,8 @@
 static const int kNumOutputBuffers = 4;
 
 // maximum allowed clock drift before correction
-static const int32_t kMaxClockDriftInMsecs = 25;    // should be tight enough for reasonable sync
-static const int64 kMaxClockCorrection = 100;       // maximum clock correction per update
+static const int32 kMaxClockDriftInMsecs = 25;    // should be tight enough for reasonable sync
+static const int32 kMaxClockCorrection = 100;     // maximum clock correction per update
 
 /*
 / Packet Video Audio MIO component
@@ -47,10 +47,11 @@
 */
 OSCL_EXPORT_REF AndroidAudioOutput::AndroidAudioOutput() :
     AndroidAudioMIO("AndroidAudioOutput"),
-    iAudioThreadCreated(false),
     iExitAudioThread(false),
+    iReturnBuffers(false),
     iActiveTiming(NULL)
 {
+    LOGV("constructor");
     iClockTimeOfWriting_ns = 0;
     iInputFrameSizeInBytes = 0;
 
@@ -59,6 +60,10 @@
     iAudioThreadSem->Create(0);
     iAudioThreadTermSem = new OsclSemaphore();
     iAudioThreadTermSem->Create(0);
+    iAudioThreadReturnSem = new OsclSemaphore();
+    iAudioThreadReturnSem->Create(0);
+    iAudioThreadCreatedSem = new OsclSemaphore();
+    iAudioThreadCreatedSem->Create(0);
 
     // locks to access the queues by this mio and by the audio output thread
     iOSSRequestQueueLock.Create();
@@ -92,13 +97,17 @@
     delete iAudioThreadSem;
     iAudioThreadTermSem->Close();
     delete iAudioThreadTermSem;
+    iAudioThreadReturnSem->Close();
+    delete iAudioThreadReturnSem;
+    iAudioThreadCreatedSem->Close();
+    delete iAudioThreadCreatedSem;
 
     iOSSRequestQueueLock.Close();
 }
 
 PVMFCommandId AndroidAudioOutput::QueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, const OsclAny* aContext)
 {
-
+    LOGV("QueryInterface in");
     // check for active timing extension
     if (iActiveTiming && (aUuid == PvmiClockExtensionInterfaceUuid)) {
         PvmiClockExtensionInterface* myInterface = OSCL_STATIC_CAST(PvmiClockExtensionInterface*,iActiveTiming);
@@ -114,6 +123,7 @@
                                         Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
                                         bool aExactUuidsOnly, const OsclAny* aContext)
 {
+    LOGV("QueryUUID in");
     int32 err;
     OSCL_TRY(err,
         aUuids.push_back(PVMI_CAPABILITY_AND_CONFIG_PVUUID);
@@ -126,30 +136,27 @@
     return QueueCmdResponse(err == OsclErrNone ? PVMFSuccess : PVMFFailure, aContext);
 }
 
-// FIXME: Per PV, we should be exiting thread in Reset, not Stop. However, doing so
-// causes app death, so presumably PV is asserting somewhere and causing an abort.
-// When this gets fixed, remove this Stop function and bring back the Reset function.
 PVMFCommandId AndroidAudioOutput::Stop(const OsclAny* aContext)
 {
-    // request output thread to exit
-    LOGV("Stop (%p)", aContext);
-    RequestAndWaitForThreadExit();
+    LOGV("AndroidAudioOutput Stop (%p)", aContext);
+    // return all buffer by writecomplete
+    returnAllBuffers();
     return AndroidAudioMIO::Stop(aContext);
 }
 
-#if 0
 PVMFCommandId AndroidAudioOutput::Reset(const OsclAny* aContext)
 {
+    LOGV("AndroidAudioOutput Reset (%p)", aContext);
+    // return all buffer by writecomplete
+    returnAllBuffers();
     // request output thread to exit
-    LOGV("Reset (%p)", aContext);
     RequestAndWaitForThreadExit();
     return AndroidAudioMIO::Reset(aContext);
 }
-#endif
 
 void AndroidAudioOutput::cancelCommand(PVMFCommandId command_id)
 {
-    LOGV("cancelCommand (%u)", command_id);
+    LOGV("cancelCommand (%u) RequestQ size %d", command_id,iOSSRequestQueue.size());
     iOSSRequestQueueLock.Lock();
     for (uint32 i = 0; i < iOSSRequestQueue.size(); i++) {
         if (iOSSRequestQueue[i].iCmdId == command_id) {
@@ -168,7 +175,7 @@
 
 void AndroidAudioOutput::returnAllBuffers()
 {
-    LOGV("cancelAllCommands");
+    LOGV("returnAllBuffers RequestQ size %d",iOSSRequestQueue.size());
     iOSSRequestQueueLock.Lock();
     while (iOSSRequestQueue.size()) {
         iDataQueued -= iOSSRequestQueue[0].iDataLen;
@@ -178,28 +185,25 @@
     }
     iOSSRequestQueueLock.Unlock();
     LOGV("returnAllBuffers data queued = %u", iDataQueued);
+    if (iAudioThreadSem && iAudioThreadCreatedAndMIOConfigured) {
+        LOGV("signal thread to return buffers");
+        iReturnBuffers = true;
+        iAudioThreadSem->Signal();
+        while (iAudioThreadReturnSem->Wait() != OsclProcStatus::SUCCESS_ERROR)
+            ;
+        LOGV("return buffers signal completed");
+    }
 }
 
-PVMFCommandId AndroidAudioOutput::Start(const OsclAny* aContext)
-{
-    LOGV("Start (%p)", aContext);
-    if (!iAudioThreadCreated) {
-        LOGV("Audio thread not started");
-        return QueueCmdResponse(PVMFFailure, aContext);
-    }
-    return AndroidAudioMIO::Start(aContext);
-}
 
 PVMFCommandId AndroidAudioOutput::DiscardData(PVMFTimestamp aTimestamp, const OsclAny* aContext)
 {
-    LOGV("DiscardData (%u)", aTimestamp);
-    if (!iAudioThreadCreated) {
-        LOGV("Audio thread not started");
-        return QueueCmdResponse(PVMFFailure, aContext);
-    }
-
-    LOGV("Force clock update");
-    iActiveTiming->ForceClockUpdate();
+    LOGV("DiscardData timestamp(%u) RequestQ size %d", aTimestamp,iOSSRequestQueue.size());
+   
+    if(iActiveTiming){
+        LOGV("Force clock update");
+        iActiveTiming->ForceClockUpdate();
+	}
 
     bool sched = false;
     PVMFCommandId audcmdid;
@@ -218,10 +222,10 @@
             context = iOSSRequestQueue[i].iContext;
             timestamp = iOSSRequestQueue[i].iTimestamp;
             iDataQueued -= iOSSRequestQueue[i].iDataLen;
+            LOGV("discard buffer (%d) context(%p) timestamp(%u) Datalen(%d)", audcmdid,context, timestamp,iOSSRequestQueue[i].iDataLen);
             iOSSRequestQueue.erase(&iOSSRequestQueue[i]);
             sched = true;
 
-            LOGV("discard buffer (%d)", audcmdid);
             WriteResponse resp(PVMFSuccess, audcmdid, context, timestamp);
             iWriteResponseQueueLock.Lock();
             iWriteResponseQueue.push_back(resp);
@@ -241,37 +245,59 @@
 
 void AndroidAudioOutput::RequestAndWaitForThreadExit()
 {
-    if (iAudioThreadSem && iAudioThreadCreated) {
+    LOGV("RequestAndWaitForThreadExit In");
+    if (iAudioThreadSem && iAudioThreadCreatedAndMIOConfigured) {
         LOGV("signal thread for exit");
         iExitAudioThread = true;
         iAudioThreadSem->Signal();
         while (iAudioThreadTermSem->Wait() != OsclProcStatus::SUCCESS_ERROR)
             ;
         LOGV("thread term signal received");
-        iAudioThreadCreated = false;
+        iAudioThreadCreatedAndMIOConfigured = false;
     }
 }
 
 void AndroidAudioOutput::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
                                         int num_elements, PvmiKvp * & aRet_kvp)
 {
+    LOGV("AndroidAudioOutput setParametersSync In");
     AndroidAudioMIO::setParametersSync(aSession, aParameters, num_elements, aRet_kvp);
 
     // initialize thread when we have enough information
-    if (iAudioSamplingRateValid && iAudioNumChannelsValid && iAudioFormat != PVMF_FORMAT_UNKNOWN) {
+    if (iAudioSamplingRateValid && iAudioNumChannelsValid && iAudioFormat != PVMF_MIME_FORMAT_UNKNOWN) {
         LOGV("start audio thread");
         OsclThread AudioOutput_Thread;
         iExitAudioThread = false;
-        iAudioThreadCreated = true;
+        iReturnBuffers = false;
         OsclProcStatus::eOsclProcError ret = AudioOutput_Thread.Create((TOsclThreadFuncPtr)start_audout_thread_func,
                                                     0, (TOsclThreadFuncArg)this, Start_on_creation);
+
+        //Don't signal the MIO node that the configuration is complete until the driver latency has been set
+        while (iAudioThreadCreatedSem->Wait() != OsclProcStatus::SUCCESS_ERROR) 
+           ;
+
+        if(OsclProcStatus::SUCCESS_ERROR == ret){
+            iAudioThreadCreatedAndMIOConfigured = true;
+            if(iObserver){
+                LOGV("event PVMFMIOConfigurationComplete to peer");
+                iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+            }
+        }
+        else{
+            iAudioThreadCreatedAndMIOConfigured = false;
+            if(iObserver){
+                LOGE("event PVMFErrResourceConfiguration to peer");
+                iObserver->ReportErrorEvent(PVMFErrResourceConfiguration);
+            }
+        }
     }
+    LOGV("AndroidAudioOutput setParametersSync out");
 }
 
 void AndroidAudioOutput::Run()
 {
     // if running, update clock
-    if ((iState == STATE_STARTED) && iInputFrameSizeInBytes) {
+    if ((iState == STATE_MIO_STARTED) && iInputFrameSizeInBytes) {
         uint32 msecsQueued = iDataQueued / iInputFrameSizeInBytes * iActiveTiming->msecsPerFrame();
         LOGV("%u msecs of data queued, %u bytes of data queued", msecsQueued,iDataQueued);
         iActiveTiming->UpdateClock();
@@ -282,15 +308,15 @@
 void AndroidAudioOutput::writeAudioBuffer(uint8* aData, uint32 aDataLen, PVMFCommandId cmdId, OsclAny* aContext, PVMFTimestamp aTimestamp)
 {
     // queue up buffer and signal audio thread to process it
-    LOGV("send buffer (%d)", cmdId);
+    LOGV("writeAudioBuffer :: DataLen(%d), cmdId(%d), Context(%p), Timestamp (%d)",aDataLen, cmdId, aContext, aTimestamp);
     OSSRequest req(aData, aDataLen, cmdId, aContext, aTimestamp);
     iOSSRequestQueueLock.Lock();
     iOSSRequestQueue.push_back(req);
     iDataQueued += aDataLen;
 
     // wake up the audio output thread to process this buffer only if clock has started running
-    if (iActiveTiming->clockState() == OsclClock::RUNNING) {
-        LOGV("signal thread for data");
+    if (iActiveTiming->clockState() == PVMFMediaClock::RUNNING) {
+        LOGV("clock is ticking signal thread for data");
         iAudioThreadSem->Signal();
     }
     iOSSRequestQueueLock.Unlock();
@@ -308,9 +334,11 @@
 // communicates with the audio MIO via a semaphore, a request queue and a response queue
 /*static*/ int AndroidAudioOutput::start_audout_thread_func(TOsclThreadFuncArg arg)
 {
+    LOGV("start_audout_thread_func in");
     AndroidAudioOutput *obj = (AndroidAudioOutput *)arg;
     prctl(PR_SET_NAME, (unsigned long) "audio out", 0, 0, 0);
     int err = obj->audout_thread_func();
+    LOGV("start_audout_thread_func out return code %d",err);
     return err;
 }
 
@@ -325,18 +353,18 @@
     setpriority(PRIO_PROCESS, gettid(), ANDROID_PRIORITY_AUDIO);
 #endif
 
-    if (iAudioNumChannelsValid == false || iAudioSamplingRateValid == false || iAudioFormat == PVMF_FORMAT_UNKNOWN) {
+    if (iAudioNumChannelsValid == false || iAudioSamplingRateValid == false || iAudioFormat == PVMF_MIME_FORMAT_UNKNOWN) {
         LOGE("channel count or sample rate is invalid");
         return -1;
     }
 
     LOGV("Creating AudioTrack object: rate=%d, channels=%d, buffers=%d", iAudioSamplingRate, iAudioNumChannels, kNumOutputBuffers);
-    status_t ret = mAudioSink->open(iAudioSamplingRate, iAudioNumChannels, ((iAudioFormat==PVMF_PCM8)?AudioSystem::PCM_8_BIT:AudioSystem::PCM_16_BIT), kNumOutputBuffers);
+    status_t ret = mAudioSink->open(iAudioSamplingRate, iAudioNumChannels, ((iAudioFormat==PVMF_MIME_PCM8)?AudioSystem::PCM_8_BIT:AudioSystem::PCM_16_BIT), kNumOutputBuffers);
     iAudioSamplingRateValid = false; // purpose of these flags is over here, reset these for next validation recording.
     iAudioNumChannelsValid  = false;
-    iAudioFormat = PVMF_FORMAT_UNKNOWN;
+    iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     if (ret != 0) {
-        iAudioThreadCreated = false;
+        iAudioThreadCreatedAndMIOConfigured = false;
         LOGE("Error creating AudioTrack");
         return -1;
     }
@@ -344,13 +372,14 @@
     // calculate timing data
     int outputFrameSizeInBytes = mAudioSink->frameSize();
     float msecsPerFrame = mAudioSink->msecsPerFrame();
-    uint32_t latency = mAudioSink->latency();
-    LOGV("driver latency = %u", latency);
+    uint32 latency = mAudioSink->latency();
+    LOGV("driver latency(%u),bufferSizeInSamples(%d),outputFrameSizeInBytes(%d),msecsPerFrame(%f),frame count(%d)", latency,bufferSizeInSamples,outputFrameSizeInBytes,msecsPerFrame,mAudioSink->frameCount());
 
     // initialize active timing
     iActiveTiming->setFrameRate(msecsPerFrame);
     iActiveTiming->setDriverLatency(latency);
 
+    iAudioThreadCreatedSem->Signal();
     // this must be set after iActiveTiming->setFrameRate to prevent race
     // condition in Run()
     iInputFrameSizeInBytes = outputFrameSizeInBytes;
@@ -374,7 +403,7 @@
     {
         // if paused, stop the output track
         switch (iActiveTiming->clockState()) {
-        case OsclClock::RUNNING:
+        case PVMFMediaClock::RUNNING:
             // start output
             if (state != STARTED) {
                 if (iFlushPending) {
@@ -392,22 +421,26 @@
                     }
                 }
                 if (iDataQueued) {
-                    LOGV("start");
-                    mAudioSink->start();
-                    state = STARTED;
+					LOGV("start");
+					mAudioSink->start();
+					state = STARTED;
                 } else {
                     LOGV("clock running and no data queued - don't start track");
                 }
             }
+            else{
+                LOGV("audio sink already in started state");
+            }
             break;
-        case OsclClock::STOPPED:
-        case OsclClock::PAUSED:
+        case PVMFMediaClock::STOPPED:
+             LOGV("clock has been stopped...");
+        case PVMFMediaClock::PAUSED:
             if (state == STARTED) {
                 LOGV("pause");
                 mAudioSink->pause();
             }
             state = PAUSED;
-            if(!iExitAudioThread) {
+            if(!iExitAudioThread && !iReturnBuffers) {
                 LOGV("wait");
                 iAudioThreadSem->Wait();
                 LOGV("awake");
@@ -418,6 +451,7 @@
         }
         // if out of data, check the request queue
         if (len == 0) {
+            //LOGV("no playable data, Request Q size %d",iOSSRequestQueue.size());
             iOSSRequestQueueLock.Lock();
             bool empty = iOSSRequestQueue.empty();
             if (!empty) {
@@ -428,15 +462,14 @@
                 timestamp = iOSSRequestQueue[0].iTimestamp;
                 iDataQueued -= len;
                 iOSSRequestQueue.erase(&iOSSRequestQueue[0]);
-                LOGV("receive buffer (%d), timestamp = %u", cmdid, timestamp);
-                LOGV("data queued = %u", iDataQueued);
+                LOGV("receive buffer (%d), timestamp = %u data queued = %u", cmdid, timestamp,iDataQueued);
             }
             iOSSRequestQueueLock.Unlock();
 
             // if queue is empty, wait for more work
             // FIXME: Why do end up here so many times when stopping?
-            if (empty && !iExitAudioThread) {
-                LOGV("empty");
+            if (empty && !iExitAudioThread && !iReturnBuffers) {
+                LOGV("queue is empty, wait for more work");
                 iAudioThreadSem->Wait();
             }
 
@@ -473,6 +506,15 @@
             }
         }
 
+        if (iReturnBuffers) {
+            LOGV("Return buffers from the audio thread");
+            if (len) sendResponse(cmdid, context, timestamp);
+            iReturnBuffers=false;
+            data = 0;
+            len = 0;
+            iAudioThreadReturnSem->Signal();
+        }
+
         // check for exit signal
         if (iExitAudioThread) {
             LOGV("exit received");
@@ -487,24 +529,24 @@
             if (bytesAvailInBuffer == 0)
                 bytesAvailInBuffer = mAudioSink->bufferSize();
 
-            bytesToWrite = bytesAvailInBuffer > len ? len : bytesAvailInBuffer;
-            //
-            LOGV("8/16 bit :: len = %u, bytesAvailInBuffer = %u, bytesToWrite = %u", len, bytesAvailInBuffer, bytesToWrite);
-            bytesWritten = mAudioSink->write(data, bytesToWrite);
-            if (bytesWritten != bytesToWrite) {
-                LOGE("Error writing audio data");
-                iAudioThreadSem->Wait();
-            }
-            data += bytesWritten;
-            len -= bytesWritten;
-            iClockTimeOfWriting_ns = systemTime(SYSTEM_TIME_MONOTONIC);
+                bytesToWrite = bytesAvailInBuffer > len ? len : bytesAvailInBuffer;
+                //LOGV("16 bit :: cmdid = %d, len = %u, bytesAvailInBuffer = %u, bytesToWrite = %u", cmdid, len, bytesAvailInBuffer, bytesToWrite);
+                bytesWritten = mAudioSink->write(data, bytesToWrite);
+                if (bytesWritten != bytesToWrite) {
+                    LOGE("Error writing audio data");
+                    iAudioThreadSem->Wait();
+                }
+                data += bytesWritten;
+                len -= bytesWritten;
+                iClockTimeOfWriting_ns = systemTime(SYSTEM_TIME_MONOTONIC);
+
 
             // count bytes sent
             bytesAvailInBuffer -= bytesWritten;
 
             // update frame count for latency calculation
             iActiveTiming->incFrameCount(bytesWritten / outputFrameSizeInBytes);
-
+            //LOGV("outputFrameSizeInBytes = %u,bytesWritten = %u,bytesAvailInBuffer = %u", outputFrameSizeInBytes,bytesWritten,bytesAvailInBuffer);
             // if done with buffer - send response to MIO
             if (data && !len) {
                 LOGV("done with the data cmdid %d, context %p, timestamp %d ",cmdid, context, timestamp);
@@ -512,7 +554,7 @@
                 data = 0;
             }
         }
-    }
+    } // while loop
 
     LOGV("stop and delete track");
     mAudioSink->stop();
diff --git a/android/android_audio_output.h b/android/android_audio_output.h
old mode 100644
new mode 100755
index 87bad1d..c762921
--- a/android/android_audio_output.h
+++ b/android/android_audio_output.h
@@ -41,14 +41,13 @@
     virtual void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
             int num_elements, PvmiKvp * & aRet_kvp);
 
-    virtual PVMFCommandId Start(const OsclAny* aContext);
-    virtual PVMFCommandId DiscardData(PVMFTimestamp aTimestamp=0, const OsclAny* aContext=NULL);
+	virtual PVMFCommandId DiscardData(PVMFTimestamp aTimestamp=0, const OsclAny* aContext=NULL);
 
     virtual void cancelCommand(PVMFCommandId aCmdId);
 
-    // FIXME: see comment in AndroidAudioOutput::Stop() implementation
     virtual PVMFCommandId Stop(const OsclAny* aContext=NULL);
-    // virtual PVMFCommandId Reset(const OsclAny* aContext=NULL);
+	virtual PVMFCommandId Reset(const OsclAny* aContext=NULL);
+    
 
 private:
 
@@ -82,9 +81,11 @@
     // semaphores used to communicate with the audio output thread
     OsclSemaphore* iAudioThreadSem;
     OsclSemaphore* iAudioThreadTermSem;
+    OsclSemaphore* iAudioThreadReturnSem;
+    OsclSemaphore* iAudioThreadCreatedSem;
 
-    bool iAudioThreadCreated;
     volatile bool iExitAudioThread;
+    volatile bool iReturnBuffers;
 
     // active timing
     AndroidAudioMIOActiveTimingSupport* iActiveTiming;
diff --git a/android/android_audio_output_threadsafe_callbacks.cpp b/android/android_audio_output_threadsafe_callbacks.cpp
index 5075bd2..93ae40f 100644
--- a/android/android_audio_output_threadsafe_callbacks.cpp
+++ b/android/android_audio_output_threadsafe_callbacks.cpp
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2008, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #include "android_audio_output_threadsafe_callbacks.h"
 #include "android_audio_output.h"
 
diff --git a/android/android_audio_output_threadsafe_callbacks.h b/android/android_audio_output_threadsafe_callbacks.h
index 0bc9be0..a70314e 100644
--- a/android/android_audio_output_threadsafe_callbacks.h
+++ b/android/android_audio_output_threadsafe_callbacks.h
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2008, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #ifndef ANDROID_AUDIO_OUTPUT_THREADSAFE_CALLBACK_H_INCLUDED
 #define ANDROID_AUDIO_OUTPUT_THREADSAFE_CALLBACK_H_INCLUDED
 
diff --git a/android/android_audio_stream.cpp b/android/android_audio_stream.cpp
index 8042a03..d9a0f9b 100644
--- a/android/android_audio_stream.cpp
+++ b/android/android_audio_stream.cpp
@@ -92,13 +92,13 @@
     AndroidAudioMIO::setParametersSync(aSession, aParameters, num_elements, aRet_kvp);
 
     // initialize audio sink when we have enough information
-    if (iAudioSamplingRateValid && iAudioNumChannelsValid && iAudioFormat != PVMF_FORMAT_UNKNOWN) {
-        mAudioSink->open(iAudioSamplingRate, iAudioNumChannels, ((iAudioFormat==PVMF_PCM8)?AudioSystem::PCM_8_BIT:AudioSystem::PCM_16_BIT));
+    if (iAudioSamplingRateValid && iAudioNumChannelsValid && iAudioFormat != PVMF_MIME_FORMAT_UNKNOWN) {
+        mAudioSink->open(iAudioSamplingRate, iAudioNumChannels, ((iAudioFormat==PVMF_MIME_PCM8)?AudioSystem::PCM_8_BIT:AudioSystem::PCM_16_BIT));
 
         // reset flags for next time
         iAudioSamplingRateValid = false;
         iAudioNumChannelsValid  = false;
-        iAudioFormat = PVMF_FORMAT_UNKNOWN;
+        iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     }
 }
 
diff --git a/android/android_log_appender.h b/android/android_log_appender.h
index b3dc1ce..d05aa30 100644
--- a/android/android_log_appender.h
+++ b/android/android_log_appender.h
@@ -27,6 +27,10 @@
 #include "osclconfig_util.h"
 #endif
 
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
 #include <utils/Log.h>
 #undef LOG_TAG
 #define LOG_TAG "PV"
diff --git a/android/android_logger_config.h b/android/android_logger_config.h
new file mode 100644
index 0000000..bcca14f
--- /dev/null
+++ b/android/android_logger_config.h
@@ -0,0 +1,196 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef ANDROID_LOGGER_CONFIG_H
+#define ANDROID_LOGGER_CONFIG_H
+
+#include "author/authordriver.h"
+#include "android_log_appender.h"
+
+#define MAX_STRING_LEN  255
+
+FILE *file;
+
+class PVLoggerConfigFile{
+/*  
+    To configure logging at runtime, a file pvlogger.txt must be located in the sdcard.
+    The format for log level and logger tag in the file should be: "level,node".  Note that there should be no space between log level and logger tag.
+    For example, pvlogger.txt can look like:
+	1,PVPlayerEngine
+	8,PVSocketNode
+    Above example means log the message level PVLOGMSG_ALERT for PVPlayerEngine and PVLOGMSG_DEBUG for PVSocketNode.  See pvlogger.h for log level values.
+*/
+public:
+	PVLoggerConfigFile():iLogFileRead(false)
+	{
+		iFileServer.Connect();
+        iLogFileName[MAX_STRING_LEN] = '\0';
+		oscl_strncpy(iLogFileName,"/sdcard/pvlogger.txt", MAX_STRING_LEN);
+		oscl_memset(ibuffer, 0, sizeof(ibuffer));
+	}
+
+	~PVLoggerConfigFile()
+	{
+		iFileServer.Close();
+	}
+
+	bool IsLoggerConfigFilePresent()
+	{
+		if(-1 != ReadAndParseLoggerConfigFile())
+			return true;
+		return false;
+	}
+
+	//Read and parse the config file
+	//retval = -1 if the config file doesnt exist
+	int8 ReadAndParseLoggerConfigFile()
+	{
+		int8 retval = 1;
+
+		if(0 != iLogFile.Open(iLogFileName,Oscl_File::MODE_READ, iFileServer))
+		{
+			retval = -1;
+		}
+		else
+		{
+			if(!iLogFileRead)
+			{
+				int32 nCharRead = iLogFile.Read(ibuffer,1, sizeof(ibuffer));
+				//Parse the buffer for \n chars
+				Oscl_Vector<char*,OsclMemAllocator> LogConfigStrings;
+
+				//Get the logger strings
+				const char* const lnFd = "\n";
+				const int8 lnFdLen = oscl_strlen(lnFd);
+				int16 offset = 0;
+				char* lastValidBffrAddr = ibuffer + oscl_strlen(ibuffer);
+				const char* lnFdIndx = oscl_strstr(ibuffer, lnFd);
+				while(lnFdIndx!=NULL && lnFdIndx < lastValidBffrAddr)
+				{
+					oscl_memset((char*)lnFdIndx, '\0', lnFdLen);
+					LogConfigStrings.push_back(ibuffer + offset);
+					offset = (lnFdIndx + lnFdLen) - ibuffer;
+					lnFdIndx = oscl_strstr(ibuffer + offset, lnFd);
+				}
+				if(NULL == lnFdIndx && ((ibuffer + offset) < lastValidBffrAddr))
+				{
+					LogConfigStrings.push_back(ibuffer + offset);
+				}
+
+				//Populate the  LoggerConfigElements vector
+				{
+					if(!LogConfigStrings.empty())
+					{
+                        Oscl_Vector<char*,OsclMemAllocator>::iterator it;
+						if(LogConfigStrings.size() > 0)
+						{
+							for (it = LogConfigStrings.begin(); it!= LogConfigStrings.end(); it++)
+							{
+                                char* hashIndex = OSCL_CONST_CAST(char*, oscl_strstr(*it, "#"));
+                                char* CommaIndex = OSCL_CONST_CAST(char*, oscl_strstr(*it, ","));
+                                // Skip lines with hash
+                                if (hashIndex == NULL)
+                                {
+								    if(CommaIndex != NULL)
+								    {
+									    *CommaIndex = '\0';
+									    LoggerConfigElement obj;
+									    uint32 logLevel;
+									    PV_atoi(*it,'d',oscl_strlen(*it),logLevel);
+									    obj.iLogLevel = logLevel;
+									    obj.iLoggerString= CommaIndex +1;
+									    iLoggerConfigElements.push_back(obj);
+								    }
+                                    else
+					                {
+						                //Add the config element for logging all the modules with specified log level
+                                        LoggerConfigElement obj;
+                                        uint32 logLevel;
+									    PV_atoi(*it,'d',oscl_strlen(*it),logLevel);
+						                obj.iLoggerString = "";
+						                obj.iLogLevel = logLevel;
+						                iLoggerConfigElements.push_back(obj);
+					                }
+                                }
+							}
+						}
+					}
+                    else
+					{
+						//Add the config element for complete logging for all the modules
+						LoggerConfigElement obj;
+						obj.iLoggerString = "";
+						obj.iLogLevel = 8;
+						iLoggerConfigElements.push_back(obj);
+					}
+				}
+				iLogFile.Close();
+				iLogFileRead = true;
+			}
+		}
+		return retval;
+	}
+
+	void SetLoggerSettings()
+	{
+		Oscl_Vector<LoggerConfigElement, OsclMemAllocator>::iterator it;
+
+		PVLoggerAppender *appender=NULL;
+		OsclRefCounter *refCounter=NULL;
+		if(iLoggerConfigElements.empty())
+		{
+			return;
+		}
+		
+        appender = new AndroidLogAppender<TimeAndIdLayout,1024>();
+        OsclRefCounterSA<LogAppenderDestructDealloc<AndroidLogAppender<TimeAndIdLayout,1024> > > *appenderRefCounter =
+            new OsclRefCounterSA<LogAppenderDestructDealloc<AndroidLogAppender<TimeAndIdLayout,1024> > >(appender);
+        refCounter = appenderRefCounter;
+
+		OsclSharedPtr<PVLoggerAppender> appenderPtr(appender,refCounter);
+
+		for (it = iLoggerConfigElements.begin(); it!= iLoggerConfigElements.end(); it++)
+		{
+			PVLogger *node = NULL;
+			node = PVLogger::GetLoggerObject(it->iLoggerString);
+			node->AddAppender(appenderPtr);
+			node->SetLogLevel(it->iLogLevel);
+		}
+	}
+
+private:
+	class LoggerConfigElement{
+		public:
+		LoggerConfigElement()
+		{
+			iLoggerString = NULL;
+			iLogLevel = 8;
+		}
+		char *iLoggerString;
+		int8 iLogLevel;
+	};
+	bool iLogFileRead;
+	Oscl_File iLogFile;
+	Oscl_FileServer iFileServer;
+	char iLogFileName[MAX_STRING_LEN+1];
+	char ibuffer[1024];
+	Oscl_Vector<LoggerConfigElement, OsclMemAllocator> iLoggerConfigElements;
+};
+
+#endif
+
diff --git a/android/android_surface_output.cpp b/android/android_surface_output.cpp
old mode 100644
new mode 100755
index f42701f..d1ea8ee
--- a/android/android_surface_output.cpp
+++ b/android/android_surface_output.cpp
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 
-//#define LOG_NDEBUG 0
+#define LOG_NDEBUG 0
 #define LOG_TAG "VideoMIO"
 #include <utils/Log.h>
 
@@ -61,6 +61,7 @@
     mEmulation = false;
     mHardwareCodec = false;
     mPvPlayer = NULL;
+    mFrameBufferIndex = 0;
 
     // running in emulation?
     char value[PROPERTY_VALUE_MAX];
@@ -80,11 +81,11 @@
 void AndroidSurfaceOutput::initData()
 {
     iVideoHeight = iVideoWidth = iVideoDisplayHeight = iVideoDisplayWidth = 0;
-    iVideoFormat=PVMF_FORMAT_UNKNOWN;
+    iVideoFormat=PVMF_MIME_FORMAT_UNKNOWN;
     resetVideoParameterFlags();
 
     // hardware specific information
-    iVideoSubFormat = PVMF_FORMAT_UNKNOWN;
+    iVideoSubFormat = PVMF_MIME_FORMAT_UNKNOWN;
 
     iCommandCounter=0;
     iLogger=NULL;
@@ -94,6 +95,7 @@
     iLogger=NULL;
     iPeer=NULL;
     iState=STATE_IDLE;
+    iIsMIOConfigured = false;
 }
 
 void AndroidSurfaceOutput::ResetData()
@@ -103,8 +105,9 @@
 
     //reset all the received media parameters.
     iVideoFormatString="";
-    iVideoFormat=PVMF_FORMAT_UNKNOWN;
+    iVideoFormat=PVMF_MIME_FORMAT_UNKNOWN;
     resetVideoParameterFlags();
+    iIsMIOConfigured = false;
 }
 
 void AndroidSurfaceOutput::resetVideoParameterFlags()
@@ -114,7 +117,7 @@
     // FIXME: Hack required because subformat is not passed when
     // hardware accelerator is not present.
     // emulator never uses subformat
-    if (mEmulation) iVideoParameterFlags |= VIDEO_SUBFORMAT_VALID;
+    //if (mEmulation) iVideoParameterFlags |= VIDEO_SUBFORMAT_VALID;
 }
 
 bool AndroidSurfaceOutput::checkVideoParameterFlags()
@@ -125,6 +128,7 @@
 void AndroidSurfaceOutput::Cleanup()
 //cleanup all allocated memory and release resources.
 {
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidSurfaceOutput::Cleanup() In"));
     while (!iCommandResponseQueue.empty())
     {
         if (iObserver)
@@ -140,6 +144,8 @@
 
     // We'll close frame buf and delete here for now.
     CloseFrameBuf();
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"AndroidSurfaceOutput::Cleanup() Out"));
  }
 
 OSCL_EXPORT_REF AndroidSurfaceOutput::~AndroidSurfaceOutput()
@@ -259,12 +265,8 @@
     switch(iState)
     {
     case STATE_LOGGED_ON:
-
         status=PVMFSuccess;
-
-        if (status==PVMFSuccess)
-            iState=STATE_INITIALIZED;
-
+        iState=STATE_INITIALIZED;
         break;
 
     default:
@@ -280,8 +282,10 @@
 
 PVMFCommandId AndroidSurfaceOutput:: Reset(const OsclAny* aContext)
 {
-    // Do nothing for now.
+    ResetData();
     PVMFCommandId cmdid=iCommandCounter++;
+    CommandResponse resp(PVMFSuccess,cmdid,aContext);
+    QueueCommandResponse(resp);
     return cmdid;
 }
 
@@ -330,10 +334,14 @@
         status=PVMFSuccess;
 
         // post last buffer to prevent stale data
-        if (mHardwareCodec) {
-            mSurface->postBuffer(mOffset);
-        } else {
-            mSurface->postBuffer(mFrameBuffers[mFrameBufferIndex]);
+        // if not configured, PVMFMIOConfigurationComplete is not sent
+        // there should not be any media data.
+	if(iIsMIOConfigured) { 
+	if (mHardwareCodec) {
+		mSurface->postBuffer(mOffset);
+	} else {
+		mSurface->postBuffer(mFrameBuffers[mFrameBufferIndex]);
+	}
         }
         break;
 
@@ -536,6 +544,17 @@
 PVMFCommandId AndroidSurfaceOutput::writeAsync(uint8 aFormatType, int32 aFormatIndex, uint8* aData, uint32 aDataLen,
                                         const PvmiMediaXferHeader& data_header_info, OsclAny* aContext)
 {
+    // Do a leave if MIO is not configured except when it is an EOS
+    if (!iIsMIOConfigured
+            &&
+            !((PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == aFormatType)
+              && (PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM == aFormatIndex)))
+    {
+	    LOGE("data is pumped in before MIO is configured");
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
     uint32 aSeqNum=data_header_info.seq_num;
     PVMFTimestamp aTimestamp=data_header_info.timestamp;
     uint32 flags=data_header_info.flags;
@@ -738,9 +757,10 @@
     {
         aParameters=(PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
         if (aParameters == NULL) return PVMFErrNoMemory;
-        aParameters[num_parameter_elements++].value.uint32_value=(uint32) PVMF_YUV420;
-            return PVMFSuccess;
-        }
+        aParameters[num_parameter_elements++].value.pChar_value=(char*) PVMF_MIME_YUV420;
+
+        return PVMFSuccess;
+    }
 
     //unrecognized key.
     return PVMFFailure;
@@ -788,7 +808,7 @@
         if (pv_mime_strcmp(aParameters[i].key, MOUT_VIDEO_FORMAT_KEY) == 0)
         {
             iVideoFormatString=aParameters[i].value.pChar_value;
-            iVideoFormat=GetFormatIndex(iVideoFormatString.get_str());
+            iVideoFormat=iVideoFormatString.get_str();
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                 (0,"AndroidSurfaceOutput::setParametersSync() Video Format Key, Value %s",iVideoFormatString.get_str()));
         }
@@ -826,11 +846,12 @@
         }
         else if (pv_mime_strcmp(aParameters[i].key, MOUT_VIDEO_SUBFORMAT_KEY) == 0)
         {
-            iVideoSubFormat=(PVMFFormatType) aParameters[i].value.uint32_value;
+            iVideoSubFormat=aParameters[i].value.pChar_value;
             iVideoParameterFlags |= VIDEO_SUBFORMAT_VALID;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0,"AndroidSurfaceOutput::setParametersSync() Video SubFormat Key, Value %d",iVideoSubFormat));
-LOGV("VIDEO SUBFORMAT SET TO %d\n",iVideoSubFormat);
+                    (0,"AndroidSurfaceOutput::setParametersSync() Video SubFormat Key, Value %s",iVideoSubFormat.getMIMEStrPtr()));
+
+LOGV("VIDEO SUBFORMAT SET TO %s\n",iVideoSubFormat.getMIMEStrPtr());
         }
         else
         {
@@ -845,7 +866,21 @@
             return;
         }
     }
-    initCheck();
+    uint32 mycache = iVideoParameterFlags ;
+    if( checkVideoParameterFlags() )
+	initCheck();
+    iVideoParameterFlags = mycache;
+
+    // when all necessary parameters are received, send 
+    // PVMFMIOConfigurationComplete event to observer
+    if(!iIsMIOConfigured && checkVideoParameterFlags() )
+    {
+        iIsMIOConfigured = true;
+        if(iObserver)
+        {
+            iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+        }
+    }
 }
 
 PVMFCommandId AndroidSurfaceOutput::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
@@ -862,13 +897,28 @@
 
 PVMFStatus AndroidSurfaceOutput::verifyParametersSync (PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
 {
+    OSCL_UNUSED_ARG(aSession);
+
+    // Go through each parameter
+    for (int32 i=0; i<num_elements; i++) {
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[i].key, compstr);
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media/format-type")) == 0) {
+            if (pv_mime_strcmp(aParameters[i].value.pChar_value, PVMF_MIME_YUV420) == 0) {
+                return PVMFSuccess;
+            }
+            else {
+                return PVMFErrNotSupported;
+            }
+        }
+    }
     return PVMFSuccess;
 }
 
 //
 // For active timing support
 //
-OSCL_EXPORT_REF PVMFStatus AndroidSurfaceOutput_ActiveTimingSupport::SetClock(OsclClock *clockVal)
+OSCL_EXPORT_REF PVMFStatus AndroidSurfaceOutput_ActiveTimingSupport::SetClock(PVMFMediaClock *clockVal)
 {
     iClock=clockVal;
     return PVMFSuccess;
@@ -907,7 +957,7 @@
     {
         uint32 currentTime=0;
         bool overflow=false;
-        iClock->GetCurrentTime32(currentTime, overflow, OSCLCLOCK_MSEC);
+        iClock->GetCurrentTime32(currentTime, overflow, PVMF_MEDIA_CLOCK_MSEC);
         if(aTs>currentTime)
         {
             return aTs-currentTime;
@@ -965,7 +1015,7 @@
 
 #if HAVE_ANDROID_OS
     // Dream hardware codec uses semi-planar format
-    if (!mEmulation && iVideoSubFormat == PVMF_YUV420_SEMIPLANAR_YVU) {
+    if (!mEmulation && iVideoSubFormat == PVMF_MIME_YUV420_SEMIPLANAR_YVU) {
         LOGV("using hardware codec");
         mHardwareCodec = true;
     } else
@@ -988,12 +1038,13 @@
             frameSize = frameWidth * frameHeight * 2;
 
             // create frame buffer heap and register with surfaceflinger
+
             mFrameHeap = new MemoryHeapBase(frameSize * kBufferCount);
             if (mFrameHeap->heapID() < 0) {
                 LOGE("Error creating frame buffer heap");
                 return false;
             }
-            mSurface->registerBuffers(displayWidth, displayHeight, frameWidth, frameHeight, PIXEL_FORMAT_RGB_565, mFrameHeap);
+            status_t ret = mSurface->registerBuffers(displayWidth, displayHeight, frameWidth, frameHeight, PIXEL_FORMAT_RGB_565, mFrameHeap);
 
             // create frame buffers
             for (int i = 0; i < kBufferCount; i++) {
@@ -1023,7 +1074,7 @@
             mHeapPmem = new MemoryHeapPmem(master, 0);
             mHeapPmem->slap();
             master.clear();
-            mSurface->registerBuffers(displayWidth, displayHeight, frameWidth, frameHeight, PIXEL_FORMAT_YCbCr_420_SP, mHeapPmem);
+            status_t ret = mSurface->registerBuffers(displayWidth, displayHeight, frameWidth, frameHeight, PIXEL_FORMAT_YCbCr_420_SP, mHeapPmem);
 
             // create frame buffers
             for (int i = 0; i < kBufferCount; i++) {
@@ -1055,7 +1106,7 @@
         if (!mInitialized) {
             LOGV("initializing for hardware");
             // FIXME: Check for hardware codec - move to partners directory
-            if (iVideoSubFormat != PVMF_YUV420_SEMIPLANAR_YVU) return PVMFFailure;
+            if (iVideoSubFormat != PVMF_MIME_YUV420_SEMIPLANAR_YVU) return PVMFFailure;
             LOGV("got expected format");
             LOGV("private data pointer is 0%p\n", data_header_info.private_data_ptr);
 
@@ -1071,7 +1122,7 @@
             master.clear();
 
             // register frame buffers with SurfaceFlinger
-            mSurface->registerBuffers(iVideoDisplayWidth, iVideoDisplayHeight, iVideoWidth, iVideoHeight, PIXEL_FORMAT_YCbCr_420_SP, mHeapPmem);
+            status_t ret = mSurface->registerBuffers(iVideoDisplayWidth, iVideoDisplayHeight, iVideoWidth, iVideoHeight, PIXEL_FORMAT_YCbCr_420_SP, mHeapPmem);
 
             mInitialized = true;
         }
@@ -1111,7 +1162,7 @@
     if (mSurface.get()) {
         LOGV("unregisterBuffers");
         mSurface->unregisterBuffers();
-        mSurface.clear();
+//        mSurface.clear();
     }
 
     // free frame buffers
diff --git a/android/android_surface_output.h b/android/android_surface_output.h
old mode 100644
new mode 100755
index 2c2008b..5b294fc
--- a/android/android_surface_output.h
+++ b/android/android_surface_output.h
@@ -102,7 +102,7 @@
 }
 
 class PVLogger;
-class OsclClock;
+class PVMFMediaClock;
 class AndroidSurfaceOutput;
 
 using namespace android;
@@ -120,7 +120,7 @@
     {}
 
     //from PvmiClockExtensionInterface
-    OSCL_IMPORT_REF PVMFStatus SetClock(OsclClock *clockVal) ;
+    OSCL_IMPORT_REF PVMFStatus SetClock(PVMFMediaClock* clockVal) ;
 
     //from PVInterface
     OSCL_IMPORT_REF void addRef() ;
@@ -133,7 +133,7 @@
 
     uint32 iQueueLimit;
 
-    OsclClock* iClock;
+    PVMFMediaClock* iClock;
 };
 
 
@@ -372,6 +372,8 @@
     uint32                      mOffset;
 
     void convertFrame(void* src, void* dst, size_t len);
+    //This bool is set true when all necassary parameters have been received.
+    bool iIsMIOConfigured;
 
 #ifdef PERFORMANCE_MEASUREMENTS_ENABLED
         PVProfile PVOmapVideoProfile;
diff --git a/android/author/Android.mk b/android/author/Android.mk
index 8731f61..d7b213c 100644
--- a/android/author/Android.mk
+++ b/android/author/Android.mk
@@ -2,12 +2,12 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        authordriver.cpp \
-        PVMediaRecorder.cpp \
-        android_camera_input.cpp \
-        android_audio_input.cpp \
-        android_audio_input_threadsafe_callbacks.cpp \
-        ../thread_init.cpp \
+	authordriver.cpp \
+	PVMediaRecorder.cpp \
+	android_camera_input.cpp \
+	android_audio_input.cpp \
+	android_audio_input_threadsafe_callbacks.cpp \
+	../thread_init.cpp \
 
 LOCAL_CFLAGS := $(PV_CFLAGS)
 
@@ -17,18 +17,18 @@
 LOCAL_ARM_MODE := arm
 
 LOCAL_C_INCLUDES := $(PV_INCLUDES) \
-        $(PV_TOP)/engines/common/include \
-        $(PV_TOP)/codecs_v2/omx/omx_common/include \
-        $(PV_TOP)/fileformats/mp4/parser/include \
-        $(PV_TOP)/pvmi/media_io/pvmiofileoutput/include \
-        $(PV_TOP)/nodes/pvmediaoutputnode/include \
-        $(PV_TOP)/nodes/pvmediainputnode/include \
-        $(PV_TOP)/nodes/pvmp4ffcomposernode/include \
-        $(PV_TOP)/engines/player/include \
-        $(PV_TOP)/nodes/common/include \
-        external/tremor/Tremor \
-        libs/drm/mobile1/include \
-        $(call include-path-for, graphics corecg)
+	$(PV_TOP)/engines/common/include \
+	$(PV_TOP)/codecs_v2/omx/omx_common/include \
+	$(PV_TOP)/fileformats/mp4/parser/include \
+	$(PV_TOP)/pvmi/media_io/pvmiofileoutput/include \
+	$(PV_TOP)/nodes/pvmediaoutputnode/include \
+	$(PV_TOP)/nodes/pvmediainputnode/include \
+	$(PV_TOP)/nodes/pvmp4ffcomposernode/include \
+	$(PV_TOP)/engines/player/include \
+	$(PV_TOP)/nodes/common/include \
+	external/tremor/Tremor \
+	libs/drm/mobile1/include \
+    $(call include-path-for, graphics corecg)
 
 LOCAL_SHARED_LIBRARIES := libmedia
 
diff --git a/android/author/PVMediaRecorder.cpp b/android/author/PVMediaRecorder.cpp
index 1a5d8e4..0580c91 100644
--- a/android/author/PVMediaRecorder.cpp
+++ b/android/author/PVMediaRecorder.cpp
@@ -284,6 +284,7 @@
 status_t PVMediaRecorder::doStop()
 {
     LOGV("doStop");
+
     if (mAuthorDriverWrapper == NULL) {
         LOGE("author driver wrapper is not initialized yet");
         return UNKNOWN_ERROR;
diff --git a/android/author/android_audio_input.cpp b/android/author/android_audio_input.cpp
index 3f1336a..b55f26b 100644
--- a/android/author/android_audio_input.cpp
+++ b/android/author/android_audio_input.cpp
@@ -67,7 +67,7 @@
 
 
     {
-        iAudioFormat=PVMF_FORMAT_UNKNOWN;
+        iAudioFormat=PVMF_MIME_FORMAT_UNKNOWN;
         iAudioNumChannelsValid=false;
         iAudioSamplingRateValid=false;
         iExitAudioThread=false;
@@ -95,7 +95,7 @@
 
     if(iMediaBufferMemPool)
     {
-        OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+        OSCL_DELETE(iMediaBufferMemPool);
         iMediaBufferMemPool = NULL;
     }
 
@@ -362,7 +362,7 @@
 OSCL_EXPORT_REF void AndroidAudioInput::setPeer(PvmiMediaTransfer* aPeer)
 {
     LOGV("setPeer");
-    if(iPeer || !aPeer)
+    if(iPeer && aPeer)
     {
         OSCL_LEAVE(OsclErrGeneral);
         return;
@@ -521,7 +521,7 @@
         }
         else
         {
-            parameters[0].value.uint32_value = PVMF_PCM16;
+            parameters[0].value.pChar_value = (char*)PVMF_MIME_PCM16;
         }
     }
     else if(pv_mime_strcmp(identifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0)
@@ -762,7 +762,7 @@
     OSCL_TRY(err,
         if(iMediaBufferMemPool)
         {
-            OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+            OSCL_DELETE(iMediaBufferMemPool);
             iMediaBufferMemPool = NULL;
         }
         iMediaBufferMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (4));
@@ -1004,7 +1004,7 @@
     data_hdr.flags=0;
     data_hdr.duration = data.iDuration;
     data_hdr.stream_id=0;
-    uint32 writeAsyncID = iPeer->writeAsync(0, 0, data.iData, data.iDataLen, data_hdr);
+    uint32 writeAsyncID = iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA, 0, data.iData, data.iDataLen, data_hdr);
 
     // Save the id and data pointer on iSentMediaData queue for writeComplete call
     AndroidAudioInputMediaData sentData;
@@ -1062,7 +1062,7 @@
 
     if(pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
     {
-        if(aKvp->value.uint32_value == PVMF_PCM16)
+        if(pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_PCM16) == 0)
         {
             return PVMFSuccess;
         }
diff --git a/android/author/android_audio_input_threadsafe_callbacks.cpp b/android/author/android_audio_input_threadsafe_callbacks.cpp
index aa20793..3705ece 100644
--- a/android/author/android_audio_input_threadsafe_callbacks.cpp
+++ b/android/author/android_audio_input_threadsafe_callbacks.cpp
@@ -1,3 +1,21 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
 #include "android_audio_input_threadsafe_callbacks.h"
 #include "android_audio_input.h"
 
diff --git a/android/author/android_audio_input_threadsafe_callbacks.h b/android/author/android_audio_input_threadsafe_callbacks.h
index db6d76c..66ba027 100644
--- a/android/author/android_audio_input_threadsafe_callbacks.h
+++ b/android/author/android_audio_input_threadsafe_callbacks.h
@@ -1,3 +1,21 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
 #ifndef ANDROID_AUDIO_INPUT_THREADSAFE_CALLBACK_H_INCLUDED
 #define ANDROID_AUDIO_INPUT_THREADSAFE_CALLBACK_H_INCLUDED
 
diff --git a/android/author/android_camera_input.cpp b/android/author/android_camera_input.cpp
index d6e3bfc..7d8fae9 100644
--- a/android/author/android_camera_input.cpp
+++ b/android/author/android_camera_input.cpp
@@ -521,7 +521,7 @@
             LOGE("AllocateKvp failed for OUTPUT_FORMATS_VALTYP");
             return status;
         }
-        params[0].value.uint32_value = ANDROID_VIDEO_FORMAT;
+        params[0].value.pChar_value = (char*)PVMF_MIME_YUV420;
     } else if (!pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY)) {
         num_params = 1;
         status = AllocateKvp(params, VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_params);
@@ -719,7 +719,7 @@
 
         uint32 writeAsyncID = 0;
         int32 error = 0;
-        OSCL_TRY(error,writeAsyncID = iPeer->writeAsync(0, 0, (uint8*)data.iFrameBuffer,
+        OSCL_TRY(error,writeAsyncID = iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA, 0, (uint8*)data.iFrameBuffer,
                     data.iFrameSize, data.iXferHeader););
 
         if (!error) {
@@ -991,7 +991,7 @@
     }
 
     if (!pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE)) {
-        if (aKvp->value.uint32_value == ANDROID_VIDEO_FORMAT)  {
+		if(pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_YUV420) == 0) {
             return PVMFSuccess;
         } else  {
             LOGE("Unsupported format %d", aKvp->value.uint32_value);
diff --git a/android/author/android_camera_input.h b/android/author/android_camera_input.h
index 5efb0b8..3a200e7 100644
--- a/android/author/android_camera_input.h
+++ b/android/author/android_camera_input.h
@@ -79,11 +79,6 @@
 #define DEFAULT_FRAME_WIDTH        320
 #define DEFAULT_FRAME_HEIGHT       240
 #define DEFAULT_FRAME_RATE         20.0
-#define ANDROID_VIDEO_FORMAT       PVMF_YUV420
-
-#if ANDROID_VIDEO_FORMAT == PVMF_RGB16
-#error PV does not support RGB16
-#endif
 
 /**
  * Class containing information for a command or data event
diff --git a/android/author/authordriver.cpp b/android/author/authordriver.cpp
index e4baaee..1e68a3f 100644
--- a/android/author/authordriver.cpp
+++ b/android/author/authordriver.cpp
@@ -22,8 +22,10 @@
 #include <media/thread_init.h>
 #include <ui/ISurface.h>
 #include <ui/ICamera.h>
-#include "pv_omxmastercore.h"
 #include "authordriver.h"
+#include "pv_omxcore.h"
+#include <sys/prctl.h>
+
 
 using namespace android;
 
@@ -615,7 +617,7 @@
     }
 
     LOGV("OMX_Init");
-    PV_MasterOMX_Init();
+    OMX_Init();
 
     OsclScheduler::Init("AndroidAuthorDriver");
     LOGV("Create author ...");
@@ -652,7 +654,7 @@
 
    //moved below delete this, similar code on playerdriver.cpp caused a crash.
    //cleanup of oscl should happen at the end.
-    PV_MasterOMX_Deinit();
+    OMX_Deinit();
     UninitializeForThread();
     return 0;
 }
@@ -803,4 +805,3 @@
     return PVAE_STATE_IDLE;
 }
 
-
diff --git a/android/author/authordriver.h b/android/author/authordriver.h
index db0826e..3670657 100644
--- a/android/author/authordriver.h
+++ b/android/author/authordriver.h
@@ -25,6 +25,9 @@
 
 #include <utils.h>
 
+#include <ui/ICamera.h>
+
+
 #include <media/mediarecorder.h>
 
 #include "oscl_scheduler.h"
@@ -41,7 +44,6 @@
 #include "oscl_mem.h"
 #include "oscl_mem_audit.h"
 #include "oscl_error.h"
-#include "oscl_error_panic.h"
 #include "oscl_utf8conv.h"
 #include "oscl_string_utils.h"
 #include "android_camera_input.h"
diff --git a/android/drm/oma1/src/pvmf_cpmplugin_kmj_oma1.h b/android/drm/oma1/src/pvmf_cpmplugin_kmj_oma1.h
index 40805f6..19dbb23 100644
--- a/android/drm/oma1/src/pvmf_cpmplugin_kmj_oma1.h
+++ b/android/drm/oma1/src/pvmf_cpmplugin_kmj_oma1.h
@@ -713,7 +713,7 @@
     friend class PVMFCPMKmjPlugInOMA1LocalSyncAccessInterfaceImpl;
 };
 
-class PVMFCPMKmjPlugInOMA1LocalSyncAccessInterfaceImpl : public PVMFCPMPluginLocalSyncAccessInterface
+class PVMFCPMKmjPlugInOMA1LocalSyncAccessInterfaceImpl // : public PVMFCPMPluginLocalSyncAccessInterface
 {
 public:
     PVMFCPMKmjPlugInOMA1LocalSyncAccessInterfaceImpl(PVMFCPMKmjPlugInOMA1&c)
diff --git a/android/mediascanner.cpp b/android/mediascanner.cpp
index 6388c4a..bd6a3fa 100644
--- a/android/mediascanner.cpp
+++ b/android/mediascanner.cpp
@@ -1,6 +1,19 @@
-/* mediascanner.cpp
+/*
+ * Copyright (C) 2008, Google Inc.
  *
- * Android wrapper for media scanner
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
  */
 
 #include <media/mediascanner.h>
@@ -107,6 +120,7 @@
         // type should follow first semicolon
         const char* type = strchr(key, ';') + 1;
         if (type == 0) continue;
+
         
         const char* value = framevector[i]->value.pChar_value;
 
@@ -314,7 +328,7 @@
     oscl_UTF8ToUnicode((const char *)filename, oscl_strlen((const char *)filename), (oscl_wchar *)output, MAX_BUFF_SIZE);
     OSCL_wHeapString<OsclMemAllocator> mpegfilename(output);
 
-    IMpeg4File *mp4Input = IMpeg4File::readMP4File(mpegfilename, 1 /* parsing_mode */, &iFs);
+    IMpeg4File *mp4Input = IMpeg4File::readMP4File(mpegfilename, NULL, NULL, 1 /* parsing_mode */, &iFs);
     if (mp4Input)
     {
         // check to see if the file contains video
@@ -326,16 +340,18 @@
             mp4Input->getTrackIDList(tracks, count);
             for (int i = 0; i < count; ++i) {
                 uint32 trackType = mp4Input->getTrackMediaType(tracks[i]);
-                OSCL_wHeapString<OsclMemAllocator> streamtype = mp4Input->getTrackMIMEType(tracks[i]);
+                OSCL_HeapString<OsclMemAllocator> streamtype;
+                mp4Input->getTrackMIMEType(tracks[i], streamtype);
                 char streamtypeutf8[128];
-                if (oscl_UnicodeToUTF8(streamtype.get_cstr(),streamtype.get_size(), streamtypeutf8,
-                                                                            sizeof(streamtypeutf8)) > 0) {
-                    if (strcmp(streamtypeutf8,"UNKNOWN") != 0) {
-                        if (trackType ==  MEDIA_TYPE_AUDIO) {
-                            hasAudio = true;
-                        } else if (trackType ==  MEDIA_TYPE_VISUAL) {
-                            hasVideo = true;
-                        }
+		strncpy (streamtypeutf8, streamtype.get_str(), streamtype.get_size());
+                if (streamtypeutf8[0])
+		{                                                                           
+                    if (strcmp(streamtypeutf8,"FORMATUNKNOWN") != 0) {
+							if (trackType ==  MEDIA_TYPE_AUDIO) {
+								hasAudio = true;
+							} else if (trackType ==  MEDIA_TYPE_VISUAL) {
+								hasVideo = true;
+							}
                     } else {
                         //LOGI("@@@@@@@@ %100s: %s\n", filename, streamtypeutf8);
                     }
diff --git a/android/metadatadriver.cpp b/android/metadatadriver.cpp
index e1c54fd..1c709e2 100644
--- a/android/metadatadriver.cpp
+++ b/android/metadatadriver.cpp
@@ -99,7 +99,7 @@
         return -1;
     }
 
-    PV_MasterOMX_Init();
+    OMX_Init();
     OsclScheduler::Init("PVAuthorEngineWrapper");
     mState = STATE_CREATE;
     AddToScheduler();
@@ -109,7 +109,7 @@
 
     mSyncSem->Signal();  // Signal that doSetDataSource() is done.
     OsclScheduler::Cleanup();
-    PV_MasterOMX_Deinit();
+    OMX_Deinit();
     UninitializeForThread();
     return 0;
 }
@@ -479,9 +479,7 @@
 {
     LOGV("handleCreate");
     int error = 0;
-    OSCL_HeapString<OsclMemAllocator> outputFrameTypeString;
-    GetFormatString(PVMF_YUV420, outputFrameTypeString);
-    OSCL_TRY(error, mUtil = PVFrameAndMetadataFactory::CreateFrameAndMetadataUtility(outputFrameTypeString.get_str(), this, this, this));
+    OSCL_TRY(error, mUtil = PVFrameAndMetadataFactory::CreateFrameAndMetadataUtility((char*)PVMF_MIME_YUV420, this, this, this));
     if (error || mUtil->SetMode(PV_FRAME_METADATA_INTERFACE_MODE_SOURCE_METADATA_AND_THUMBNAIL) != PVMFSuccess) {
         handleCommandFailure();
     } else {
@@ -498,7 +496,7 @@
     mDataSource = new PVPlayerDataSourceURL;
     if (mDataSource) {
         mDataSource->SetDataSourceURL(mDataSourceUrl);
-        mDataSource->SetDataSourceFormatType(PVMF_FORMAT_UNKNOWN);
+        mDataSource->SetDataSourceFormatType((char*)PVMF_MIME_FORMAT_UNKNOWN);
         if (mMode & GET_FRAME_ONLY) {
 #if BEST_THUMBNAIL_MODE
             // Set the intent to thumbnails.
diff --git a/android/metadatadriver.h b/android/metadatadriver.h
index 301d5c4..458a8ec 100644
--- a/android/metadatadriver.h
+++ b/android/metadatadriver.h
@@ -29,13 +29,13 @@
 #include "oscl_mem_audit.h"
 #include "oscl_error.h"
 #include "oscl_snprintf.h"
-#include "oscl_error_panic.h"
+
 #include "oscl_scheduler.h"
 #include "oscl_utf8conv.h"
 #include "oscl_scheduler_ao.h"
 #include "cczoomrotation16.h"  // for color converter
 #include "omx_core.h"
-#include "pv_omxmastercore.h"
+#include "pv_omxcore.h"
 
 #define BEST_THUMBNAIL_MODE 1
 
diff --git a/android/playerdriver.cpp b/android/playerdriver.cpp
index 31f1a1e..cb1d4f4 100644
--- a/android/playerdriver.cpp
+++ b/android/playerdriver.cpp
@@ -47,7 +47,6 @@
 #include "oscl_mem.h"
 #include "oscl_mem_audit.h"
 #include "oscl_error.h"
-#include "oscl_error_panic.h"
 #include "oscl_utf8conv.h"
 #include "oscl_string_utils.h"
 #include "android_surface_output.h"
@@ -58,7 +57,7 @@
 #include "pvmf_source_context_data.h"
 #include "pvmf_download_data_source.h"
 #include "omx_core.h"
-#include "pv_omxmastercore.h"
+#include "pv_omxcore.h"
 
 // color converter
 #include "cczoomrotation16.h"
@@ -459,7 +458,7 @@
 
 int PlayerDriver::setupHttpStreamPre()
 {
-    mDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+    mDataSource->SetDataSourceFormatType((char*)PVMF_MIME_DATA_SOURCE_HTTP_URL);
     
     delete mDownloadContextData;
     mDownloadContextData = NULL;
@@ -509,10 +508,8 @@
 
     int error = 0;
 
-    // PV will set a default user agent value. The below string will be appended to the default value.
-    // The default value [PVPLAYER_ENGINE_SDKINFO_LABEL] can be found at device/extlibs/pv/engines/player/src/pv_player_sdkinfo.h 
     iKVPSetAsync.key = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
-    OSCL_wHeapString<OsclMemAllocator> userAgent = _STRLIT_WCHAR("(Linux;U;Android 1.0)(AndroidMediaPlayer 1.0)");
+    OSCL_wHeapString<OsclMemAllocator> userAgent = _STRLIT_WCHAR("CORE/6.101.1.1 OpenCORE/2.0 (Linux;Android 1.0)(AndroidMediaPlayer 1.0)");
     iKVPSetAsync.value.pWChar_value=userAgent.get_str();
     iErrorKVP=NULL;
     OSCL_TRY(error, mPlayerCapConfig->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
@@ -569,11 +566,11 @@
     wFileName.set(output, oscl_strlen(output));
     mDataSource->SetDataSourceURL(wFileName);
     if (strncmp(url, "rtsp:", strlen("rtsp:")) == 0) {
-        mDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+        mDataSource->SetDataSourceFormatType((char*)PVMF_MIME_DATA_SOURCE_RTSP_URL);
     } else if (strncmp(url, "http:", strlen("http:")) == 0) {
         setupHttpStreamPre();
     } else {
-        mDataSource->SetDataSourceFormatType(PVMF_FORMAT_UNKNOWN); // Let PV figure it out
+        mDataSource->SetDataSourceFormatType((char*)PVMF_MIME_FORMAT_UNKNOWN); // Let PV figure it out
     }
 
     OSCL_TRY(error, mPlayer->AddDataSource(*mDataSource, ec));
@@ -625,9 +622,9 @@
     mVideoSink = new PVPlayerDataSinkPVMFNode;
 
     ((PVPlayerDataSinkPVMFNode *)mVideoSink)->SetDataSinkNode(mVideoNode);
-    ((PVPlayerDataSinkPVMFNode *)mVideoSink)->SetDataSinkFormatType(PVMF_YUV420);
+    ((PVPlayerDataSinkPVMFNode *)mVideoSink)->SetDataSinkFormatType((char*)PVMF_MIME_YUV420);
 
-    OSCL_TRY(error, mPlayer->AddDataSink(*mVideoSink, ec));
+	OSCL_TRY(error, mPlayer->AddDataSink(*mVideoSink, ec));
     OSCL_FIRST_CATCH_ANY(error, commandFailed(ec));
 }
 
@@ -647,7 +644,7 @@
     mAudioSink = new PVPlayerDataSinkPVMFNode;
 
     ((PVPlayerDataSinkPVMFNode *)mAudioSink)->SetDataSinkNode(mAudioNode);
-    ((PVPlayerDataSinkPVMFNode *)mAudioSink)->SetDataSinkFormatType(PVMF_PCM16);
+    ((PVPlayerDataSinkPVMFNode *)mAudioSink)->SetDataSinkFormatType((char*)PVMF_MIME_PCM16);
 
     OSCL_TRY(error, mPlayer->AddDataSink(*mAudioSink, ec));
     OSCL_FIRST_CATCH_ANY(error, commandFailed(ec));
@@ -655,7 +652,17 @@
 
 void PlayerDriver::handlePrepare(PlayerPrepare* ec)
 {
-    int error = 0;
+    //Keep alive is sent during the play to prevent the firewall from closing ports while
+    //streming long clip
+    PvmiKvp iKVPSetAsync;
+    OSCL_StackString<64> iKeyStringSetAsync;
+    PvmiKvp *iErrorKVP = NULL;
+    int error=0;
+    iKeyStringSetAsync=_STRLIT_CHAR("x-pvmf/net/keep-alive-during-play;valtype=bool");
+    iKVPSetAsync.key=iKeyStringSetAsync.get_str();
+    iKVPSetAsync.value.bool_value=true;
+    iErrorKVP=NULL;
+    OSCL_TRY(error, mPlayerCapConfig->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP)); 
     OSCL_TRY(error, mPlayer->Prepare(ec));
     OSCL_FIRST_CATCH_ANY(error, commandFailed(ec));
 }
@@ -861,7 +868,7 @@
     }
 
     LOGV("OMX_Init");
-    PV_MasterOMX_Init();
+    OMX_Init();
 
     LOGV("OsclScheduler::Init");
     OsclScheduler::Init("AndroidPVWrapper");
@@ -919,7 +926,7 @@
     OsclScheduler::Cleanup();
     LOGV("OsclScheduler::Cleanup");
 
-    PV_MasterOMX_Deinit();
+    OMX_Deinit();
     UninitializeForThread();
     return 0;
 }
@@ -942,7 +949,7 @@
 
     for (uint32 i = 0; i < mMetaValueList.size(); ++i) {
         // Search for the duration
-        char* substr=oscl_strstr(mMetaValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
+        const char* substr=oscl_strstr(mMetaValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
         if (substr!=NULL) {
             uint32 timescale=1000;
             if (PV_atoi((substr+34), 'd', timescale) == false) {
@@ -954,7 +961,7 @@
             //set the timescale
                mcc.set_timescale(timescale);
             //set the clock to the duration as per the timescale
-               mcc.set_clock(duration,1);
+               mcc.set_clock(duration,0);
             //convert to millisec
                cmd->set(mcc.get_converted_ts(1000));
             }
diff --git a/android/thread_init.cpp b/android/thread_init.cpp
index a256024..7bd9861 100644
--- a/android/thread_init.cpp
+++ b/android/thread_init.cpp
@@ -22,12 +22,15 @@
 #include "android_log_appender.h"
 #include "pvlogger_time_and_id_layout.h"
 
-#include "pvlogger.h"
 #include "oscl_mem.h"
 #include "oscl_error.h"
 
 #include "omx_core.h"
 
+#if (PVLOGGER_INST_LEVEL > 0)
+#include "android_logger_config.h"
+#endif
+
 using namespace android;
 bool gotkey=false;
 pthread_key_t ptkey=NULL;
@@ -90,16 +93,12 @@
             LOGE("pthread_setspecific error %d", error);
             return false;
         }
-
-#if 0
-    PVLoggerAppender *appender = new AndroidLogAppender<TimeAndIdLayout,1024>();
-    OsclRefCounterSA<LogAppenderDestructDealloc<AndroidLogAppender<TimeAndIdLayout,1024> > > *appenderRefCounter =
-            new OsclRefCounterSA<LogAppenderDestructDealloc<AndroidLogAppender<TimeAndIdLayout,1024> > >(appender);
-    OsclRefCounter *refCounter = appenderRefCounter;
-    OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, refCounter);
-    PVLogger *rootnode = PVLogger::GetLoggerObject("");
-    rootnode->AddAppender(appenderPtr);
-    rootnode->SetLogLevel(PVLOGMSG_DEBUG);
+#if (PVLOGGER_INST_LEVEL > 0)
+        PVLoggerConfigFile obj;
+        if(obj.IsLoggerConfigFilePresent())
+        {
+            obj.SetLoggerSettings();
+        }
 #endif
     }
     return true;
diff --git a/baselibs/gen_data_structures/Android.mk b/baselibs/gen_data_structures/Android.mk
index 08cdc9e..ae8447e 100644
--- a/baselibs/gen_data_structures/Android.mk
+++ b/baselibs/gen_data_structures/Android.mk
@@ -3,38 +3,43 @@
 
 LOCAL_SRC_FILES := \
 	src/buf_frag_group.cpp \
-	src/pv_string.cpp \
-	src/rtsp_range_utils.cpp \
-	src/base64_codec.cpp \
-	src/bitstreamparser.cpp
-
+ 	src/pv_string.cpp \
+ 	src/pv_string_uri.cpp \
+ 	src/rtsp_range_utils.cpp \
+ 	src/base64_codec.cpp \
+ 	src/bitstreamparser.cpp
 
 
 LOCAL_MODULE := libpvgendatastruct
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//baselibs/gen_data_structures/src \
-	$(PV_TOP)//baselibs/gen_data_structures/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/buf_frag_group.h \
-	src/hash_functions.h \
-	src/hashtable.h \
-	src/linked_list.h \
-	src/pv_string.h \
-	src/rtsp_range_utils.h \
-	src/sorted_list.h \
-	src/bool_array.h \
-	src/rtsp_time_formats.h \
-	src/mime_registry.h \
-	src/base64_codec.h \
-	src/bitstreamparser.h
+ 	src/hash_functions.h \
+ 	src/hashtable.h \
+ 	src/linked_list.h \
+ 	src/pv_string.h \
+ 	src/pv_string_uri.h \
+ 	src/rtsp_range_utils.h \
+ 	src/sorted_list.h \
+ 	src/bool_array.h \
+ 	src/rtsp_time_formats.h \
+ 	src/mime_registry.h \
+ 	src/base64_codec.h \
+ 	src/bitstreamparser.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/baselibs/gen_data_structures/build/make/local.mk b/baselibs/gen_data_structures/build/make/local.mk
new file mode 100644
index 0000000..13da489
--- /dev/null
+++ b/baselibs/gen_data_structures/build/make/local.mk
@@ -0,0 +1,37 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvgendatastruct
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS := buf_frag_group.cpp \
+	pv_string.cpp \
+	pv_string_uri.cpp \
+	rtsp_range_utils.cpp \
+	base64_codec.cpp \
+	bitstreamparser.cpp
+
+HDRS := buf_frag_group.h \
+	hash_functions.h \
+	hashtable.h \
+	linked_list.h \
+	pv_string.h \
+	pv_string_uri.h \
+	rtsp_range_utils.h \
+	sorted_list.h \
+	bool_array.h \
+	rtsp_time_formats.h \
+	mime_registry.h \
+	base64_codec.h \
+	bitstreamparser.h
+
+include $(MK)/library.mk
+
diff --git a/baselibs/gen_data_structures/build/make/makefile b/baselibs/gen_data_structures/build/make/makefile
deleted file mode 100644
index 672a3f2..0000000
--- a/baselibs/gen_data_structures/build/make/makefile
+++ /dev/null
@@ -1,74 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvgendatastruct
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-# XINCDIRS += -I../../../fileformat/mp4/parser/include
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS = buf_frag_group.cpp \
-	pv_string.cpp \
-	rtsp_range_utils.cpp \
-	base64_codec.cpp \
-	bitstreamparser.cpp
-
-HDRS =  buf_frag_group.h \
-	hash_functions.h \
-	hashtable.h \
-	linked_list.h \
-	pv_string.h \
-	rtsp_range_utils.h \
-	sorted_list.h \
-	bool_array.h \
-	rtsp_time_formats.h \
-	mime_registry.h \
-	base64_codec.h \
-	bitstreamparser.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/baselibs/gen_data_structures/src/base64_codec.cpp b/baselibs/gen_data_structures/src/base64_codec.cpp
index 754d27e..ee7b00d 100644
--- a/baselibs/gen_data_structures/src/base64_codec.cpp
+++ b/baselibs/gen_data_structures/src/base64_codec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/base64_codec.h b/baselibs/gen_data_structures/src/base64_codec.h
index a22347a..00e669d 100644
--- a/baselibs/gen_data_structures/src/base64_codec.h
+++ b/baselibs/gen_data_structures/src/base64_codec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/bitstreamparser.cpp b/baselibs/gen_data_structures/src/bitstreamparser.cpp
index 759c79a..fc90fd0 100644
--- a/baselibs/gen_data_structures/src/bitstreamparser.cpp
+++ b/baselibs/gen_data_structures/src/bitstreamparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,15 +24,24 @@
 
 OSCL_EXPORT_REF BitStreamParser::BitStreamParser(uint8* stream, uint32 size)
 {
-    this->size = size;
-    start   = (uint8*)stream;
-    bytepos = (uint8*)start;
-    bitpos  = MOST_SIG_BIT;
+    ResetBitStreamParser(stream, size);
 }
 
+OSCL_EXPORT_REF void BitStreamParser::ResetBitStreamParser(uint8* stream, uint32 size)
+{
+    this->size = size;
+    start 	= OSCL_STATIC_CAST(uint8*, stream);
+    bytepos	= OSCL_STATIC_CAST(uint8*, start);
+    bitpos 	= MOST_SIG_BIT;
+}
 
 OSCL_EXPORT_REF uint32 BitStreamParser::ReadBits(uint8 numberOfBits)
 {
+    // Make sure bytepos won't exceed the size of the buffer while reading
+    if ((bytepos + numberOfBits) >= (start + size))
+    {
+        OSCL_LEAVE(OsclErrOverflow);
+    }
     //Initialize output to zero before shifting out bits.
     uint32 output = 0;
 
@@ -101,8 +110,11 @@
     //If bitpos is not on a byte boundary, have to use ReadBits...
     if (bitpos != MOST_SIG_BIT) return ReadBits(BITS_PER_UINT8);
 
-    //Otherwise, this is faster.
-    OSCL_ASSERT(bytepos < (start + size));
+    // Make sure the current bytepos doesn't exceed the size of the buffer
+    if (bytepos >= (start + size))
+    {
+        OSCL_LEAVE(OsclErrOverflow);
+    }
     uint8 read = *bytepos;
     bytepos++;
 
@@ -165,7 +177,10 @@
     }
     else
     {
-        OSCL_ASSERT(bytepos < (start + size));
+        if (bytepos >= (start + size))
+        {
+            OSCL_LEAVE(OsclErrOverflow);
+        }
         *bytepos = data;
         bytepos++;
     }
@@ -194,8 +209,11 @@
 
 OSCL_EXPORT_REF void BitStreamParser::NextBits(uint32 numberOfBits)
 {
-    //Check if we read past the end of the stream.
-    OSCL_ASSERT(bytepos < (start + size));
+    // Make sure bytepos won't exceed the size of the buffer while reading
+    if ((bytepos + numberOfBits) >= (start + size))
+    {
+        OSCL_LEAVE(OsclErrOverflow);
+    }
 
     //bitpos counts down from 7 to 0, so subtract it from 7 to get the ascending position.
     uint32 newbitpos = numberOfBits  + (MOST_SIG_BIT - bitpos);
diff --git a/baselibs/gen_data_structures/src/bitstreamparser.h b/baselibs/gen_data_structures/src/bitstreamparser.h
index 8ef2db1..f09f5ae 100644
--- a/baselibs/gen_data_structures/src/bitstreamparser.h
+++ b/baselibs/gen_data_structures/src/bitstreamparser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,8 @@
 
 
 #include "oscl_assert.h"
-
+#include "oscl_error_codes.h"
+#include "oscl_exception.h"
 
 #define MOST_SIG_BIT              7
 #define LEAST_SIG_BIT             0
@@ -42,6 +43,9 @@
         //Constructor requires a pointer to the stream and the size in bytes.
         OSCL_IMPORT_REF BitStreamParser(uint8* stream, uint32 size);
 
+        // Reset bitstream parser
+        OSCL_IMPORT_REF void ResetBitStreamParser(uint8* stream, uint32 size);
+
         //Returns the specified number of bits from the stream (up to 32 bits).
         OSCL_IMPORT_REF uint32 ReadBits(uint8 numberOfBits);
 
@@ -69,10 +73,16 @@
         //Skips over exactly one bit.  This is more efficient than NextBits(1).
         OSCL_EXPORT_REF inline void NextBit(void)
         {
-            if (0 != bitpos) bitpos--;
+            if (0 != bitpos)
+            {
+                bitpos--;
+            }
             else
             {
-                OSCL_ASSERT(bytepos < (start + size));
+                if (bytepos >= (start + size))
+                {
+                    OSCL_LEAVE(OsclErrOverflow);
+                }
                 bitpos = MOST_SIG_BIT;
                 bytepos++;
             }
diff --git a/baselibs/gen_data_structures/src/bool_array.h b/baselibs/gen_data_structures/src/bool_array.h
index 5cb8303..9ba8122 100644
--- a/baselibs/gen_data_structures/src/bool_array.h
+++ b/baselibs/gen_data_structures/src/bool_array.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/buf_frag_group.cpp b/baselibs/gen_data_structures/src/buf_frag_group.cpp
index d3849c3..119a074 100644
--- a/baselibs/gen_data_structures/src/buf_frag_group.cpp
+++ b/baselibs/gen_data_structures/src/buf_frag_group.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/buf_frag_group.h b/baselibs/gen_data_structures/src/buf_frag_group.h
index 851c7fc..a9880ba 100644
--- a/baselibs/gen_data_structures/src/buf_frag_group.h
+++ b/baselibs/gen_data_structures/src/buf_frag_group.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/hash_functions.h b/baselibs/gen_data_structures/src/hash_functions.h
index b5f4581..1b6e32b 100644
--- a/baselibs/gen_data_structures/src/hash_functions.h
+++ b/baselibs/gen_data_structures/src/hash_functions.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/hashtable.h b/baselibs/gen_data_structures/src/hashtable.h
index 9725747..86fef24 100644
--- a/baselibs/gen_data_structures/src/hashtable.h
+++ b/baselibs/gen_data_structures/src/hashtable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -500,7 +500,7 @@
 
 template <class keyclass, class hashclass> MTHashTable<keyclass, hashclass>::~MTHashTable()
 {
-    OSCL_TEMPLATED_DELETE(the_hash, HashTable<keyclass, hashclass>, HashTable);
+    OSCL_DELETE(the_hash);
 }
 
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/baselibs/gen_data_structures/src/linked_list.h b/baselibs/gen_data_structures/src/linked_list.h
index 4247e89..cd6893c 100644
--- a/baselibs/gen_data_structures/src/linked_list.h
+++ b/baselibs/gen_data_structures/src/linked_list.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -127,7 +127,7 @@
     while (num_elements && head)
     {
         tmp = head->next;
-        OSCL_TEMPLATED_DELETE(head, LinkedListElement<LLClass>, LinkedListElement);
+        OSCL_DELETE(head);
         --num_elements;
         head = tmp;
     }
@@ -142,19 +142,7 @@
 
     for (tmp = head, ii = 0; tmp ; ++ii, tmp = tmp->next);
 
-    if (ii != num_elements)
-    {
-        /*    UNCOND_LOGMSG(ERR_ALERT, (273, "(LinkedList): The number of elements %d "
-                                  "does not match first null %d\n",
-                                  num_elements, ii));
-        */
-        // fprintf(stderr, "Link list error...\n");
-    }
-
-
     return (ii == num_elements);
-
-
 }
 
 
@@ -238,7 +226,7 @@
                 tail = prev;
             }
 
-            OSCL_TEMPLATED_DELETE(tmp, LinkedListElement<LLClass>, LinkedListElement);
+            OSCL_DELETE(tmp);
             --num_elements;
             break;
         }
@@ -306,7 +294,7 @@
         tail = prev;
     }
 
-    OSCL_TEMPLATED_DELETE(tmp, LinkedListElement<LLClass>, LinkedListElement);
+    OSCL_DELETE(tmp);
     --num_elements;
 
     return 1;
diff --git a/baselibs/gen_data_structures/src/makefile b/baselibs/gen_data_structures/src/makefile
deleted file mode 100755
index 01673c2..0000000
--- a/baselibs/gen_data_structures/src/makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = gen_data_structures
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS += 
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCS =  pv_string.cpp \
-	buf_frag_group.cpp \
-	rtsp_range_utils.cpp
-
-HDRS =  hash_functions.h \
-	hashtable.h \
-	linked_list.h \
-	sorted_list.h \
-        pv_string.h \
-	buf_frag_group.h \
-	rtsp_time_formats.h \
-	rtsp_range_utils.h \
-	mime_registry.h \
-	bool_array.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
-
diff --git a/baselibs/gen_data_structures/src/mime_registry.h b/baselibs/gen_data_structures/src/mime_registry.h
index d51d823..d6b6a53 100644
--- a/baselibs/gen_data_structures/src/mime_registry.h
+++ b/baselibs/gen_data_structures/src/mime_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/pv_string.cpp b/baselibs/gen_data_structures/src/pv_string.cpp
index 8bae19c..a1fabd0 100644
--- a/baselibs/gen_data_structures/src/pv_string.cpp
+++ b/baselibs/gen_data_structures/src/pv_string.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/pv_string.h b/baselibs/gen_data_structures/src/pv_string.h
index 9319f2c..00d4c66 100644
--- a/baselibs/gen_data_structures/src/pv_string.h
+++ b/baselibs/gen_data_structures/src/pv_string.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/pv_string_uri.cpp b/baselibs/gen_data_structures/src/pv_string_uri.cpp
new file mode 100644
index 0000000..f14d42a
--- /dev/null
+++ b/baselibs/gen_data_structures/src/pv_string_uri.cpp
@@ -0,0 +1,213 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+//               P V S T R I N G URI   C L A S S
+
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+#include "pv_string_uri.h"
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVStringUri::PersentageToEscapedEncoding(char* aUrl, uint32 & aUrlMaxOutLength)
+{
+    int32 err;
+    uint32 Url_Counter   = 0;
+    uint32 Url_Tmp_Counter = 0;
+    aUrlMaxOutLength = 0;
+    mbchar* TempUrlBuffer = NULL;
+    uint32 iPersentage_Flag = false;
+    bool iRet = false;
+
+    OSCL_TRY(err, TempUrlBuffer = OSCL_ARRAY_NEW(mbchar, MAX_FULL_REQUEST_SIZE));
+    if ((err != OsclErrNone) || (TempUrlBuffer == NULL))
+    {
+        return false;
+    }
+
+    oscl_memset(TempUrlBuffer, 0, sizeof(TempUrlBuffer));
+    while (aUrl[Url_Counter] != '\0')
+    {
+
+        switch (aUrl[Url_Counter])
+        {
+            case PERSENTAGE:
+            {
+                if (!(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '0') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '1') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == 'A') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '7') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '8') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '9') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == 'B') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '4') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '6') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == 'C') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == 'F') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '5') &&
+                        !(aUrl[Url_Counter+1] == '2' && aUrl[Url_Counter+2] == '3') &&
+                        !(aUrl[Url_Counter+1] == '3' && aUrl[Url_Counter+2] == 'A') &&
+                        !(aUrl[Url_Counter+1] == '3' && aUrl[Url_Counter+2] == 'B') &&
+                        !(aUrl[Url_Counter+1] == '3' && aUrl[Url_Counter+2] == 'D') &&
+                        !(aUrl[Url_Counter+1] == '3' && aUrl[Url_Counter+2] == 'F') &&
+                        !(aUrl[Url_Counter+1] == '5' && aUrl[Url_Counter+2] == 'B') &&
+                        !(aUrl[Url_Counter+1] == '5' && aUrl[Url_Counter+2] == 'D') &&
+                        !(aUrl[Url_Counter+1] == '4' && aUrl[Url_Counter+2] == '0'))
+                {
+                    TempUrlBuffer[Url_Tmp_Counter] = '%';
+                    TempUrlBuffer[++Url_Tmp_Counter] = '2';
+                    TempUrlBuffer[++Url_Tmp_Counter] = '5';
+                    break;
+                }
+                iPersentage_Flag = true;
+                break;
+            }
+            default :
+                TempUrlBuffer[Url_Tmp_Counter] = aUrl[Url_Counter];
+                break;
+        }
+
+        if (iPersentage_Flag)
+        {
+            TempUrlBuffer[Url_Tmp_Counter] = aUrl[Url_Counter];
+            iPersentage_Flag = false;
+        }
+        Url_Counter++;
+        Url_Tmp_Counter++;
+    }
+
+    TempUrlBuffer[Url_Tmp_Counter] = '\0';
+    if (TempUrlBuffer && *TempUrlBuffer)
+    {
+        oscl_memset(aUrl, 0, sizeof(aUrl));
+        oscl_strncpy(aUrl, TempUrlBuffer, (Url_Tmp_Counter));
+        aUrl[oscl_strlen(TempUrlBuffer)] = '\0';
+        aUrlMaxOutLength = Url_Tmp_Counter;
+        iRet = true;
+    }
+
+    OSCL_ARRAY_DELETE(TempUrlBuffer);
+    TempUrlBuffer = NULL;
+    return iRet;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVStringUri::IllegalCharactersToEscapedEncoding(char* aUrl, uint32 &aUrlMaxOutLength)
+{
+
+    int32 err;
+    uint32 Url_Counter   = 0;
+    uint32 Url_Tmp_Counter = 0;
+    aUrlMaxOutLength = 0;
+    //mbchar IllegalTmpBuf[4];
+    unsigned char* IllegalTmpBuf = NULL;
+    uint32 Lenght = 0;
+    mbchar* TempUrlBuffer = NULL;
+    bool iRet = false;
+
+
+    OSCL_TRY(err, TempUrlBuffer = OSCL_ARRAY_NEW(mbchar, MAX_FULL_REQUEST_SIZE));
+    if ((err != OsclErrNone) || (TempUrlBuffer == NULL))
+    {
+        return false;
+    }
+
+
+    oscl_memset(TempUrlBuffer, 0, sizeof(TempUrlBuffer));
+
+    while (aUrl[Url_Counter] != '\0')
+    {
+        if (!(aUrl[Url_Counter] >= 63 && aUrl[Url_Counter] <= 91) &&
+                !(aUrl[Url_Counter] >= 97  && aUrl[Url_Counter] <= 122) &&
+                !(aUrl[Url_Counter] >= 35  && aUrl[Url_Counter] <= 59) &&
+                !(aUrl[Url_Counter] == 33) &&
+                !(aUrl[Url_Counter] == 61) &&
+                !(aUrl[Url_Counter] == 93) &&
+                !(aUrl[Url_Counter] == 95))
+        {
+            //Dec To Hexa Conversion
+
+            IllegalTmpBuf = DecimalToHexConverter(aUrl[Url_Counter] , Lenght);
+            TempUrlBuffer[Url_Tmp_Counter] = '%';
+            TempUrlBuffer[++Url_Tmp_Counter] = IllegalTmpBuf[1];
+            TempUrlBuffer[++Url_Tmp_Counter] = IllegalTmpBuf[2];
+            OSCL_ARRAY_DELETE(IllegalTmpBuf);
+            IllegalTmpBuf = NULL;
+        }
+
+        else
+        {
+            TempUrlBuffer[Url_Tmp_Counter] = aUrl[Url_Counter];
+
+
+        }
+
+        Url_Counter++;
+        Url_Tmp_Counter++;
+    }
+
+    TempUrlBuffer[Url_Tmp_Counter] = '\0';
+    if (TempUrlBuffer && *TempUrlBuffer)
+    {
+        oscl_memset(aUrl, 0, sizeof(aUrl));
+        oscl_strncpy(aUrl, TempUrlBuffer, Url_Tmp_Counter);
+        aUrl[oscl_strlen(TempUrlBuffer)] = '\0';
+
+        aUrlMaxOutLength = Url_Tmp_Counter;
+        iRet = true;
+    }
+
+    OSCL_ARRAY_DELETE(TempUrlBuffer);
+    TempUrlBuffer = NULL;
+    return iRet;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OSCL_EXPORT_REF unsigned char *PVStringUri::DecimalToHexConverter(unsigned char aNumberIn, uint32 & aUrlMaxConvertLenght)
+{
+    unsigned char* FinalBuffer = NULL;
+    //FinalBuffer = 0;
+
+    unsigned char size = sizeof(unsigned char) * 2;
+    FinalBuffer = OSCL_ARRAY_NEW(unsigned char, (size + 2));
+
+    mbchar *LookUpTable = OSCL_CONST_CAST(mbchar*, "0123456789ABCDEF"); //corresponding index.
+    unsigned char Temp = aNumberIn;
+
+    FinalBuffer[0] = ' ';
+    unsigned char mask = 0x000f;
+
+    for (unsigned char Counter = 0; Counter < size; Counter++)
+    {
+        Temp = aNumberIn;
+        Temp >>= (4 * Counter);
+        Temp &= mask;
+        FinalBuffer[size - Counter] = LookUpTable[Temp];
+    }
+
+    FinalBuffer[size + 1] = '\0';
+    aUrlMaxConvertLenght = oscl_strlen((char*)FinalBuffer);
+    return FinalBuffer;
+}
+
diff --git a/baselibs/gen_data_structures/src/pv_string_uri.h b/baselibs/gen_data_structures/src/pv_string_uri.h
new file mode 100644
index 0000000..b338da5
--- /dev/null
+++ b/baselibs/gen_data_structures/src/pv_string_uri.h
@@ -0,0 +1,109 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+// -*- c++ -*-
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+//                     pv_string_uri
+
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+/*! \addtogroup gen_data_structures
+ *
+ * @{
+ */
+
+
+/*! \pv_string_uri.h
+    \brief strinig uri management class
+
+*/
+
+#ifndef PV_STRING_URI_H_INCLUDE
+#define PV_STRING_URI_H_INCLUDE
+
+
+
+#include "oscl_stdstring.h"
+#include "oscl_mem_basic_functions.h"
+#include "oscl_mem.h"
+#include  "oscl_base_macros.h"
+#include "oscl_base.h"
+
+#define MAX_FULL_REQUEST_SIZE 4000
+#define PERSENTAGE '%'
+
+
+
+/**
+ * Pv_String_Uri is a non-templatized base class for Uri.
+ * The purpose of this base class is to Escaping the illigal character in the URI
+ * in the Pv_String_Uri implementation.
+ * Specially it will convert %NotMatch-Char to %25.
+ */
+
+
+class PVStringUri
+{
+
+    private:
+
+
+    public:
+        /**
+        * PersentageToEscapedEncoding utility function provides the Persentage Pct-Encoding to %25
+        * If Two Digit after % will not match in Legal Character List Of RFC-3896
+        * @param [in]/[Out] character Pointer; The complete URI
+        * @param [out] URL Lenght
+        *@return true if successful, otherwise false.
+        */
+        OSCL_IMPORT_REF static bool  PersentageToEscapedEncoding(char*, uint32 &);
+
+        /**
+        * IllegalCharactersToEscapedEncoding utility function provides the EscapedEncoding
+        * for illegal character , Which are not fall in URI-Legal Character List Of RFC-3896
+        * @param [in]/[Out] character Pointer; The complete URI
+        * @param [out] URL Lenght
+        *@return true if successful, otherwise false.
+        */
+
+        OSCL_IMPORT_REF static bool  IllegalCharactersToEscapedEncoding(char*, uint32 &);
+
+
+        /**
+        * DecimalToHexConverter utility function provides the Decimal To Hexa.
+        *
+        * @param [in] unsigned character Pointer.
+        * @param [out] Return The Hexa Value for a character.
+        * @return return Hexa Value for a character.
+        */
+
+        OSCL_IMPORT_REF static unsigned char* DecimalToHexConverter(unsigned char aNumberIn, uint32 & aUrlMaxConvertLenght);
+
+
+    protected:
+
+
+
+};
+
+
+
+#endif // PV_STRING_URI_H_INCLUDE
+/*! @} */
+
diff --git a/baselibs/gen_data_structures/src/rtsp_range_utils.cpp b/baselibs/gen_data_structures/src/rtsp_range_utils.cpp
index 58d88d8..441276c 100644
--- a/baselibs/gen_data_structures/src/rtsp_range_utils.cpp
+++ b/baselibs/gen_data_structures/src/rtsp_range_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/rtsp_range_utils.h b/baselibs/gen_data_structures/src/rtsp_range_utils.h
index 6c09236..4f207a8 100644
--- a/baselibs/gen_data_structures/src/rtsp_range_utils.h
+++ b/baselibs/gen_data_structures/src/rtsp_range_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/gen_data_structures/src/rtsp_time_formats.h b/baselibs/gen_data_structures/src/rtsp_time_formats.h
index 9620b7c..5537a8d 100644
--- a/baselibs/gen_data_structures/src/rtsp_time_formats.h
+++ b/baselibs/gen_data_structures/src/rtsp_time_formats.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,7 +33,9 @@
 #include "oscl_int64_utils.h"
 #endif
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
+#ifndef OSCL_MEM_BASIC_FUNCTIONS_H
+#include "oscl_mem_basic_functions.h"
+#endif
 
 
 
@@ -117,6 +119,15 @@
 
 struct RtspRangeType
 {
+    enum
+    {
+        PlaylistUrlLen = 1024
+    };
+
+    RtspRangeType(): format(UNKNOWN_RANGE), start_is_set(false), end_is_set(false)
+    {
+        oscl_memset(iPlaylistUrl, 0, (PlaylistUrlLen * sizeof(mbchar)));
+    }
     enum RtspRangeFormat { NPT_RANGE, SMPTE_RANGE, SMPTE_25_RANGE,
                            SMPTE_30_RANGE,
                            ABS_RANGE,
@@ -125,7 +136,6 @@
 //#endif //#ifdef RTSP_PLAYLIST_SUPPORT
                            UNKNOWN_RANGE, INVALID_RANGE
                          };
-
     RtspRangeFormat format;
     bool start_is_set;
     union
@@ -146,7 +156,7 @@
     };
 
 //#ifdef RTSP_PLAYLIST_SUPPORT
-    mbchar iPlaylistUrl[1024];
+    mbchar iPlaylistUrl[PlaylistUrlLen];
 //#endif //#ifdef RTSP_PLAYLIST_SUPPORT
     /***********************************************************************************/
     /*Function : int32 convertToMillisec(int32 &startTime, int32 &stopTime)                  */
diff --git a/baselibs/gen_data_structures/src/sorted_list.h b/baselibs/gen_data_structures/src/sorted_list.h
index 92d0707..feec330 100644
--- a/baselibs/gen_data_structures/src/sorted_list.h
+++ b/baselibs/gen_data_structures/src/sorted_list.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -132,7 +132,7 @@
     while (num_elements && head)
     {
         tmp = head->next;
-        OSCL_TEMPLATED_DELETE(head, SortedListElement<LLClass>, SortedListElement);
+        OSCL_DELETE(head);
         --num_elements;
         head = tmp;
     }
@@ -273,7 +273,7 @@
             }
 
 
-            OSCL_TEMPLATED_DELETE(tmp, SortedListElement<LLClass>, SortedListElement);
+            OSCL_DELETE(tmp);
             --num_elements;
             break;
         }
@@ -354,7 +354,7 @@
     }
 
 
-    OSCL_TEMPLATED_DELETE(tmp, SortedListElement<LLClass>, SortedListElement);
+    OSCL_DELETE(tmp);
     --num_elements;
 
 
diff --git a/baselibs/media_data_structures/Android.mk b/baselibs/media_data_structures/Android.mk
index b5dd4a6..394b3ce 100644
--- a/baselibs/media_data_structures/Android.mk
+++ b/baselibs/media_data_structures/Android.mk
@@ -3,36 +3,39 @@
 
 LOCAL_SRC_FILES := \
 	src/media_clock_converter.cpp \
-	src/pv_gau.cpp \
-	src/access_unit.cpp \
-	src/access_unit_impl.cpp \
-	src/time_comparison_utils.cpp \
-	src/au_utils.cpp
-
+ 	src/pv_gau.cpp \
+ 	src/access_unit.cpp \
+ 	src/access_unit_impl.cpp \
+ 	src/time_comparison_utils.cpp \
+ 	src/au_utils.cpp
 
 
 LOCAL_MODULE := libpvmediadatastruct
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//baselibs/media_data_structures/src \
-	$(PV_TOP)//baselibs/media_data_structures/src \
-	$(PV_TOP)//baselibs/media_data_structures/../../fileformats/mp4/parser/include \
-	$(PV_TOP)//baselibs/media_data_structures/../../pvmi/pvmf/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/baselibs/media_data_structures/src \
+ 	$(PV_TOP)/baselibs/media_data_structures/src \
+ 	$(PV_TOP)/fileformats/mp4/parser/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/access_unit.h \
-	src/access_unit_impl.h \
-	src/au_utils.h \
-	src/gau_object.h \
-	src/media_clock_converter.h \
-	src/time_comparison_utils.h \
-	src/pv_gau.h
+ 	src/access_unit_impl.h \
+ 	src/au_utils.h \
+ 	src/gau_object.h \
+ 	src/media_clock_converter.h \
+ 	src/time_comparison_utils.h \
+ 	src/pv_gau.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/baselibs/media_data_structures/build/make/local.mk b/baselibs/media_data_structures/build/make/local.mk
new file mode 100644
index 0000000..25e70a2
--- /dev/null
+++ b/baselibs/media_data_structures/build/make/local.mk
@@ -0,0 +1,37 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmediadatastruct
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+XINCDIRS += ../../../../fileformats/mp4/parser/include
+XINCDIRS += ../../../../pvmi/pvmf/include
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS :=	media_clock_converter.cpp \
+	pv_gau.cpp \
+	access_unit.cpp \
+	access_unit_impl.cpp \
+	time_comparison_utils.cpp \
+	au_utils.cpp
+
+
+HDRS := access_unit.h \
+	access_unit_impl.h \
+	au_utils.h \
+	gau_object.h \
+	media_clock_converter.h \
+	time_comparison_utils.h \
+	pv_gau.h
+
+
+include $(MK)/library.mk
+
diff --git a/baselibs/media_data_structures/build/make/makefile b/baselibs/media_data_structures/build/make/makefile
deleted file mode 100644
index f68cf4a..0000000
--- a/baselibs/media_data_structures/build/make/makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmediadatastruct
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../../../fileformats/mp4/parser/include
-XINCDIRS += -I../../../../pvmi/pvmf/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	media_clock_converter.cpp \
-	pv_gau.cpp \
-	access_unit.cpp \
-	access_unit_impl.cpp \
-	time_comparison_utils.cpp \
-	au_utils.cpp
-	
-
-
-HDRS =  access_unit.h \
-	access_unit_impl.h \
-	au_utils.h \
-	gau_object.h \
-	media_clock_converter.h \
-	time_comparison_utils.h \
-	pv_gau.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/baselibs/media_data_structures/src/access_unit.cpp b/baselibs/media_data_structures/src/access_unit.cpp
index ed1ae8a..509b190 100644
--- a/baselibs/media_data_structures/src/access_unit.cpp
+++ b/baselibs/media_data_structures/src/access_unit.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/access_unit.h b/baselibs/media_data_structures/src/access_unit.h
index e61b033..8fe7e21 100644
--- a/baselibs/media_data_structures/src/access_unit.h
+++ b/baselibs/media_data_structures/src/access_unit.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/access_unit_impl.cpp b/baselibs/media_data_structures/src/access_unit_impl.cpp
index 712bc82..2df5f91 100644
--- a/baselibs/media_data_structures/src/access_unit_impl.cpp
+++ b/baselibs/media_data_structures/src/access_unit_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -110,7 +110,10 @@
 
 
 // bit_pattern_masks assume MSB first
-const uint8 bit_pattern_masks[7] = { 0xfe, 0xfc, 0xf8, 0xf0, 0xE0, 0xC0, 0x80 };
+const uint8 bit_pattern_masks[7] =
+{
+    0xfe, 0xfc, 0xf8, 0xf0, 0xE0, 0xC0, 0x80
+};
 
 //
 // the follow routine seeks forward or backward, depending on delta_in_bytes
diff --git a/baselibs/media_data_structures/src/access_unit_impl.h b/baselibs/media_data_structures/src/access_unit_impl.h
index 773624c..1674b31 100644
--- a/baselibs/media_data_structures/src/access_unit_impl.h
+++ b/baselibs/media_data_structures/src/access_unit_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/au_utils.cpp b/baselibs/media_data_structures/src/au_utils.cpp
index 0c8a208..7511496 100644
--- a/baselibs/media_data_structures/src/au_utils.cpp
+++ b/baselibs/media_data_structures/src/au_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/au_utils.h b/baselibs/media_data_structures/src/au_utils.h
index 8685908..c24f36e 100644
--- a/baselibs/media_data_structures/src/au_utils.h
+++ b/baselibs/media_data_structures/src/au_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/gau_object.h b/baselibs/media_data_structures/src/gau_object.h
index 6057fdb..c9780d3 100644
--- a/baselibs/media_data_structures/src/gau_object.h
+++ b/baselibs/media_data_structures/src/gau_object.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/media_clock_converter.cpp b/baselibs/media_data_structures/src/media_clock_converter.cpp
index 5048fdc..6b89ace 100644
--- a/baselibs/media_data_structures/src/media_clock_converter.cpp
+++ b/baselibs/media_data_structures/src/media_clock_converter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,17 +15,19 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-//                                                                              //
-//  File: media_clock_converter.cpp                                             //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
 #include "media_clock_converter.h"
 
 // Use default DLL entry point for Symbian
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
+// All the rounding in this utility is using method rounding up
+// For example, normal calculation
+//   A / B
+// is replaced as
+//   (A + (B - 1))/ B
+// In an average roudning up is same as rounding down, but it resolve some issue
+
 //////////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF void MediaClockConverter::set_value(const MediaClockConverter& src)
 {
@@ -33,7 +35,8 @@
 
     value += src.get_current_timestamp();
 
-    value = (uint64(value) * timescale) / src.get_timescale();
+    // rounding up
+    value = (uint64(value) * timescale + uint64(src.get_timescale() - 1)) / src.get_timescale();
 
     wrap_count = ((uint32)(value >> 32)) % timescale;
 
@@ -46,7 +49,8 @@
     uint64 value = ((uint64)wrap_count) << 32;
     value += current_ts;
 
-    value = (value * new_timescale) / timescale;
+    // rounding up
+    value = (value * new_timescale + uint64(timescale - 1)) / timescale;
 
     timescale = new_timescale;
 
@@ -61,6 +65,8 @@
 {
     uint64 new_value = (uint64)value * timescale;
     uint64 in_timescale64Comp = (uint64)(in_timescale - 1);
+
+    // rounding up
     new_value = new_value + in_timescale64Comp ;
     new_value /= in_timescale;
 
@@ -75,7 +81,8 @@
         uint32 output_timescale)
 {
     // convert to native timescale
-    uint64 new_value = (uint64)value * timescale;
+    // rounding up
+    uint64 new_value = (uint64)value * timescale + uint64(in_timescale - 1);
     new_value /= in_timescale;
 
     uint32 new_timevalue = ((uint32)(new_value & 0xFFFFFFFF));
@@ -91,7 +98,8 @@
     uint32 diff = value - current_ts;
 
     // convert to output timescale
-    uint64 new_value = (uint64)diff * output_timescale;
+    // rounding up
+    uint64 new_value = (uint64)diff * output_timescale + uint64(timescale - 1);
     new_value /= timescale;
 
     diff = ((uint32)(new_value & 0xFFFFFFFF));
@@ -139,8 +147,8 @@
 {
 
     uint64 value = ((uint64)wrap_count) << 32;
-    //Accounting for a roundingoff error
-    value += (uint64(current_ts) * uint64(new_timescale) + uint64(timescale - 1)) / uint64(timescale);
+    // rounding up
+    value = ((value + uint64(current_ts)) * uint64(new_timescale) + uint64(timescale - 1)) / uint64(timescale);
 
     return ((uint32) value);
 
diff --git a/baselibs/media_data_structures/src/media_clock_converter.h b/baselibs/media_data_structures/src/media_clock_converter.h
index a432893..0813001 100644
--- a/baselibs/media_data_structures/src/media_clock_converter.h
+++ b/baselibs/media_data_structures/src/media_clock_converter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-//                                                                              //
-//  File: media_clock_converter.h                                               //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-/// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//               M E D I A   C L O C K   C O N V E R T E R   C L A S S
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-
 #ifndef __MEDIA_CLOCK_CONVERTER_H
 #define __MEDIA_CLOCK_CONVERTER_H
 
-// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
 #include "oscl_base.h"
 
 const uint32 WRAP_THRESHOLD = 0x80000000;
diff --git a/baselibs/media_data_structures/src/pv_gau.cpp b/baselibs/media_data_structures/src/pv_gau.cpp
index d73dc56..ca95c7d 100644
--- a/baselibs/media_data_structures/src/pv_gau.cpp
+++ b/baselibs/media_data_structures/src/pv_gau.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/pv_gau.h b/baselibs/media_data_structures/src/pv_gau.h
index cad1a5d..a7b2849 100644
--- a/baselibs/media_data_structures/src/pv_gau.h
+++ b/baselibs/media_data_structures/src/pv_gau.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/media_data_structures/src/time_comparison_utils.cpp b/baselibs/media_data_structures/src/time_comparison_utils.cpp
index 448ff55..b668e4c 100644
--- a/baselibs/media_data_structures/src/time_comparison_utils.cpp
+++ b/baselibs/media_data_structures/src/time_comparison_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 #include "media_clock_converter.h"
 
 
-OSCL_EXPORT_REF bool IsEarlier(uint32 aTimeA, uint32 aTimeB, uint32& delta)
+OSCL_EXPORT_REF bool PVTimeComparisonUtils::IsEarlier(uint32 aTimeA, uint32 aTimeB, uint32& delta)
 {
     delta = aTimeB - aTimeA;
     if (delta < WRAP_THRESHOLD)
@@ -29,10 +29,17 @@
     return false;
 }
 
-OSCL_EXPORT_REF MediaTimeStatus CheckTimeWindow(PVMFTimestamp aTimeStamp, uint32 aClock,
+OSCL_EXPORT_REF PVTimeComparisonUtils::MediaTimeStatus PVTimeComparisonUtils::CheckTimeWindow(PVMFTimestamp aTimeStamp, uint32 aClock,
         uint32 aEarlyMargin, uint32 aLateMargin, uint32 &aDelta)
 {
-    if (IsEarlier(aClock, aTimeStamp, aDelta))
+    bool flag = IsEarlier(aClock, aTimeStamp, aDelta);
+
+    if (0 == aDelta)
+    {
+        return MEDIA_ONTIME_WITHIN_WINDOW;
+    }
+
+    if (flag)
     {
         if (aDelta < aEarlyMargin)
             return MEDIA_EARLY_WITHIN_WINDOW;
diff --git a/baselibs/media_data_structures/src/time_comparison_utils.h b/baselibs/media_data_structures/src/time_comparison_utils.h
index 9567959..a426e27 100644
--- a/baselibs/media_data_structures/src/time_comparison_utils.h
+++ b/baselibs/media_data_structures/src/time_comparison_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,70 +32,76 @@
 #include "pvmf_timestamp.h"
 #endif
 
-typedef enum
+
+class PVTimeComparisonUtils
 {
-    MEDIA_EARLY_OUTSIDE_WINDOW,
-    MEDIA_EARLY_WITHIN_WINDOW,
-    MEDIA_LATE_WITHIN_WINDOW,
-    MEDIA_LATE_OUTSIDE_WINDOW
-} MediaTimeStatus;
+    public:
+        typedef enum
+        {
+            MEDIA_EARLY_OUTSIDE_WINDOW,
+            MEDIA_EARLY_WITHIN_WINDOW,
+            MEDIA_ONTIME_WITHIN_WINDOW,
+            MEDIA_LATE_WITHIN_WINDOW,
+            MEDIA_LATE_OUTSIDE_WINDOW
+        } MediaTimeStatus;
 
 
-/*!*********************************************************************
-**
-** Function:    IsEarlier
-**
-** Synopsis: This function returns true if TimeA is considered EARLIER than TimeB.
-**
-** Arguments :
-** @param  [aTimeA] -- Time stamp to be compared.
-** @param  [aTimeB] -- Time stamp to be compared.
-** @param  [delta]  -- delta is an output parameter and is always
-**                     a small positive value representing TimeB-TimeA if TimeA is earlier
-**                     than TimeB or TimeA-TimeB if TimeB is earlier than TimeA.
+        /*!*********************************************************************
+        **
+        ** Function:    IsEarlier
+        **
+        ** Synopsis: This function returns true if TimeA is considered EARLIER than TimeB.
+        **
+        ** Arguments :
+        ** @param  [aTimeA] -- Time stamp to be compared.
+        ** @param  [aTimeB] -- Time stamp to be compared.
+        ** @param  [delta]  -- delta is an output parameter and is always
+        **                     a small positive value representing TimeB-TimeA if TimeA is earlier
+        **                     than TimeB or TimeA-TimeB if TimeB is earlier than TimeA.
 
-** Returns:
-** @return  bool  -- returns true if TimeA is considered EARLIER than TimeB.
-**
-**
-** Notes:
-**
-**********************************************************************/
+        ** Returns:
+        ** @return  bool  -- returns true if TimeA is considered EARLIER than TimeB.
+        **
+        **
+        ** Notes:
+        **
+        **********************************************************************/
 
-OSCL_IMPORT_REF bool IsEarlier(
-    /*IN*/ uint32 aTimeA,
-    /*IN*/ uint32 aTimeB,
-    /*OUT*/ uint32& delta);
+        OSCL_IMPORT_REF static bool IsEarlier(
+            /*IN*/ uint32 aTimeA,
+            /*IN*/ uint32 aTimeB,
+            /*OUT*/ uint32& delta);
 
-/*!*********************************************************************
-**
-** Function:    CheckTimeWindow
-**
-** Synopsis: This function would return one of MEDIA_EARLY_OUTSIDE_WINDOW, MEDIA_EARLY_WITHIN_WINDOW,
-**           MEDIA_LATE_WITHIN_WINDOW or MEDIA_LATE_OUTSIDE_WINDOW depending on where the TimeStamp
-**           is within the window specified by (Clock-LateMargin) to (Clock+EarlyMargin).
-**
-** Arguments :
-** @param  [aTimeStamp]    -- Time stamp to be checked.
-** @param  [aClock]        -- present clock value.
-** @param  [aEarlyMargin]  -- early margin of the window
-** @param  [aLateMargin]   -- late margin of the window
-** @param  [aDelta]        -- aDelta is an output parameter and would contain the difference
-**                            in timestamp and clock in positive form.
+        /*!*********************************************************************
+        **
+        ** Function:    CheckTimeWindow
+        **
+        ** Synopsis: This function would return one of MEDIA_EARLY_OUTSIDE_WINDOW, MEDIA_EARLY_WITHIN_WINDOW,
+        **           MEDIA_LATE_WITHIN_WINDOW or MEDIA_LATE_OUTSIDE_WINDOW depending on where the TimeStamp
+        **           is within the window specified by (Clock-LateMargin) to (Clock+EarlyMargin).
+        **
+        ** Arguments :
+        ** @param  [aTimeStamp]    -- Time stamp to be checked.
+        ** @param  [aClock]        -- present clock value.
+        ** @param  [aEarlyMargin]  -- early margin of the window
+        ** @param  [aLateMargin]   -- late margin of the window
+        ** @param  [aDelta]        -- aDelta is an output parameter and would contain the difference
+        **                            in timestamp and clock in positive form.
 
-** Returns:
-** @return  MediaTimeStatus  -- returns one of the values from MediaTimeStatus enum.
-**
-**
-** Notes:
-**
-**********************************************************************/
+        ** Returns:
+        ** @return  MediaTimeStatus  -- returns one of the values from MediaTimeStatus enum.
+        **
+        **
+        ** Notes:
+        **
+        **********************************************************************/
 
-OSCL_IMPORT_REF MediaTimeStatus CheckTimeWindow(
-    /*IN*/ PVMFTimestamp aTimeStamp,
-    /*IN*/ uint32 aClock,
-    /*IN*/ uint32 aEarlyMargin,
-    /*IN*/ uint32 aLateMargin,
-    /*OUT*/ uint32 &aDelta);
+        OSCL_IMPORT_REF static MediaTimeStatus CheckTimeWindow(
+            /*IN*/ PVMFTimestamp aTimeStamp,
+            /*IN*/ uint32 aClock,
+            /*IN*/ uint32 aEarlyMargin,
+            /*IN*/ uint32 aLateMargin,
+            /*OUT*/ uint32 &aDelta);
 
+};
 #endif
diff --git a/baselibs/pv_mime_utils/Android.mk b/baselibs/pv_mime_utils/Android.mk
index 19f2c6c..daab586 100644
--- a/baselibs/pv_mime_utils/Android.mk
+++ b/baselibs/pv_mime_utils/Android.mk
@@ -2,24 +2,27 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pv_mime_string_utils.cpp
-
+ 	src/pv_mime_string_utils.cpp
 
 
 LOCAL_MODULE := libpvmimeutils
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//baselibs/pv_mime_utils/src \
-	$(PV_TOP)//baselibs/pv_mime_utils/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/baselibs/pv_mime_utils/src \
+ 	$(PV_TOP)/baselibs/pv_mime_utils/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	src/pv_mime_string_utils.h
+ 	src/pv_mime_string_utils.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/baselibs/pv_mime_utils/build/make/local.mk b/baselibs/pv_mime_utils/build/make/local.mk
new file mode 100644
index 0000000..0d68d38
--- /dev/null
+++ b/baselibs/pv_mime_utils/build/make/local.mk
@@ -0,0 +1,19 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmimeutils
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS :=	pv_mime_string_utils.cpp
+
+HDRS :=  pv_mime_string_utils.h
+
+include $(MK)/library.mk
diff --git a/baselibs/pv_mime_utils/build/make/makefile b/baselibs/pv_mime_utils/build/make/makefile
deleted file mode 100644
index 8862802..0000000
--- a/baselibs/pv_mime_utils/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmimeutils
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I ../../../common/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	pv_mime_string_utils.cpp
-
-HDRS =  pv_mime_string_utils.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/baselibs/pv_mime_utils/src/pv_mime_string_utils.cpp b/baselibs/pv_mime_utils/src/pv_mime_string_utils.cpp
index 78b2763..72c81dd 100644
--- a/baselibs/pv_mime_utils/src/pv_mime_string_utils.cpp
+++ b/baselibs/pv_mime_utils/src/pv_mime_string_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -264,7 +264,7 @@
         return RETVAL_NO_MATCH;
     }
     else
-    {    // must be len2 < len1
+    {	// must be len2 < len1
         // see comments on previous case for how to check for prefix condition
         if (mimestring1[i] == MIME_SUBTYPE_DELIMITER_CHAR)
         {
@@ -272,6 +272,7 @@
         }
         return RETVAL_NO_MATCH;
     }
+
 }
 
 
diff --git a/baselibs/pv_mime_utils/src/pv_mime_string_utils.h b/baselibs/pv_mime_utils/src/pv_mime_string_utils.h
index c82a622..d5427a9 100644
--- a/baselibs/pv_mime_utils/src/pv_mime_string_utils.h
+++ b/baselibs/pv_mime_utils/src/pv_mime_string_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/thread_messaging/Android.mk b/baselibs/thread_messaging/Android.mk
new file mode 100644
index 0000000..69cacfa
--- /dev/null
+++ b/baselibs/thread_messaging/Android.mk
@@ -0,0 +1,33 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pv_interface_proxy.cpp \
+ 	src/pv_interface_proxy_handler.cpp \
+ 	src/pv_interface_proxy_notifier.cpp
+
+
+LOCAL_MODULE := libpvthreadmessaging
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/baselibs/thread_messaging/src \
+ 	$(PV_TOP)/baselibs/thread_messaging/src \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	src/pv_interface_proxy.h \
+ 	src/pv_interface_proxy_handler.h \
+ 	src/pv_interface_proxy_notifier.h \
+ 	src/pv_proxied_interface.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/baselibs/thread_messaging/build/make/local.mk b/baselibs/thread_messaging/build/make/local.mk
new file mode 100644
index 0000000..0f014f2
--- /dev/null
+++ b/baselibs/thread_messaging/build/make/local.mk
@@ -0,0 +1,24 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvthreadmessaging
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS := pv_interface_proxy.cpp \
+        pv_interface_proxy_handler.cpp \
+        pv_interface_proxy_notifier.cpp
+
+HDRS := pv_interface_proxy.h \
+        pv_interface_proxy_handler.h \
+        pv_interface_proxy_notifier.h \
+        pv_proxied_interface.h \
+
+include $(MK)/library.mk
diff --git a/baselibs/thread_messaging/src/pv_interface_proxy.cpp b/baselibs/thread_messaging/src/pv_interface_proxy.cpp
new file mode 100644
index 0000000..c243829
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_interface_proxy.cpp
@@ -0,0 +1,634 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#include "pv_interface_proxy.h"
+#endif
+
+#ifndef PV_INTERFACE_PROXY_HANDLER_H_INCLUDED
+#include "pv_interface_proxy_handler.h"
+#endif
+
+#ifndef PV_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
+#include "pv_interface_proxy_notifier.h"
+#endif
+
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
+
+#include "oscl_mem.h"
+
+#include "pvlogger.h"
+
+#include "oscl_scheduler.h"
+#include "oscl_error.h"
+#include "oscl_error_trapcleanup.h"
+#include "oscl_tls.h"
+
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
+//
+//CPVInterfaceProxy
+//
+
+OSCL_EXPORT_REF CPVInterfaceProxy * CPVInterfaceProxy::NewL(
+    PVProxiedEngine& app
+    , Oscl_DefAlloc *alloc
+    , int32 stacksize
+    , uint32 nreserve1
+    , uint32 nreserve2
+    , int32 handlerPri
+    , int32 notifierPri)
+//called under app thread context
+{
+    OsclMemAllocator defallocL;
+    OsclAny *ptr = NULL;
+    if (alloc)
+    {
+        ptr = alloc->ALLOCATE(sizeof(CPVInterfaceProxy));
+        OsclError::LeaveIfNull(ptr);
+    }
+    else
+    {
+        ptr = defallocL.ALLOCATE(sizeof(CPVInterfaceProxy));
+    }
+    CPVInterfaceProxy *self = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxy(app, alloc, stacksize));
+    int32 err;
+    err = self->CPVIConstructL(nreserve1, nreserve2, handlerPri, notifierPri);
+    if (err != OSCL_ERR_NONE)
+    {
+        self->Delete();
+        return NULL;
+    }
+    return self;
+}
+
+OSCL_EXPORT_REF CPVInterfaceProxy::CPVInterfaceProxy(PVProxiedEngine& app, Oscl_DefAlloc*alloc, int32 stacksize)
+        : iPVApp(app)
+//called under app thread context
+{
+    iCommandIdCounter = 0;
+    iProxyIdCounter = 0;
+    iHandler = NULL;
+    iPVScheduler = NULL;
+    iNotifier = NULL;
+    iStacksize = stacksize;
+    iStopped = true;
+    iAlloc = (alloc) ? alloc : &iDefAlloc;
+    iLogger = NULL;
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::ConstructL(uint32 nreserve1, uint32 nreserve2, int32 handlerPri, int32 notifierPri)
+{
+    // Create the semaphores and critical sections
+    if (iInitSem.Create() != OsclProcStatus::SUCCESS_ERROR
+            || iExitedSem.Create() != OsclProcStatus::SUCCESS_ERROR
+            || iCounterCrit.Create() != OsclProcStatus::SUCCESS_ERROR
+            || iHandlerQueueCrit.Create() != OsclProcStatus::SUCCESS_ERROR
+            || iNotifierQueueCrit.Create() != OsclProcStatus::SUCCESS_ERROR
+            || iProxyListCrit.Create() != OsclProcStatus::SUCCESS_ERROR)
+    {
+        OsclError::Leave(OsclErrGeneral);
+    }
+    //reserve space in vectors...
+    if (nreserve1 > 0)
+        iProxyList.reserve(nreserve1);
+    if (nreserve2 > 0)
+    {
+        iCommandQueue.reserve(nreserve2);
+//		iNotificationQueue.reserve(nreserve2);
+    }
+
+    //create handler
+    OsclAny *ptr = iAlloc->ALLOCATE(sizeof(CPVInterfaceProxyHandler));
+    OsclError::LeaveIfNull(ptr);
+    iHandler = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxyHandler(this, handlerPri));
+
+    //create notifier
+    ptr = iAlloc->ALLOCATE(sizeof(CPVInterfaceProxyNotifier));
+    OsclError::LeaveIfNull(ptr);
+    iNotifier = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxyNotifier(this, notifierPri));
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::Delete()
+//called under app thread context
+{
+    this->~CPVInterfaceProxy();
+    iAlloc->deallocate(this);
+}
+
+OSCL_EXPORT_REF CPVInterfaceProxy::~CPVInterfaceProxy()
+//called under app thread context
+{
+    //make sure thread was stopped.
+    StopPVThread();
+
+    CleanupAppThreadQueues();
+
+    //delete handler and notifier
+    if (iHandler)
+    {
+        iHandler->~CPVInterfaceProxyHandler();
+        iAlloc->deallocate(iHandler);
+    }
+    iHandler = NULL;
+    if (iNotifier)
+    {
+        iNotifier->~CPVInterfaceProxyNotifier();
+        iAlloc->deallocate(iNotifier);
+    }
+    iNotifier = NULL;
+
+    iCounterCrit.Close();
+    iHandlerQueueCrit.Close();
+    iNotifierQueueCrit.Close();
+    iProxyListCrit.Close();
+    iInitSem.Close();
+    iExitedSem.Close();
+}
+
+//forward...
+TOsclThreadFuncRet OSCL_THREAD_DECL pvproxythreadmain(TOsclThreadFuncArg *aPtr);
+
+OSCL_EXPORT_REF bool CPVInterfaceProxy::StartPVThread()
+//called under app thread context
+{
+    if (!iStopped)
+        return false;//thread already active
+
+    //add notifier AO to app thread scheduler, if it has one.
+    if (PVThreadContext::ThreadHasScheduler())
+    {
+        //Add notification active object to API thread.
+        iNotifier->AddToScheduler();
+        iNotifier->PendForExec();
+    }
+
+    // Create the PV thread.
+    OsclProcStatus::eOsclProcError err;
+    err = iPVThread.Create((TOsclThreadFuncPtr)pvproxythreadmain,
+                           iStacksize,
+                           (TOsclThreadFuncArg)this);
+    if (err == OSCL_ERR_NONE)
+    {
+        iStopped = false;
+        //Wait for PV thread to initialize its scheduler.
+        if (iInitSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
+            OsclError::Leave(OsclErrSystemCallFailed);//unexpected sem error
+        return true;
+    }
+    else
+    {
+        //error cleanup
+        iNotifier->RemoveFromScheduler();
+        return false;
+    }
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::StopPVThread()
+//called under app thread context.
+{
+    //if called under the PV thread, we'll get deadlock..
+    //so don't allow it.
+    if (iPVThreadContext.IsSameThreadContext())
+        OsclError::Leave(OsclErrThreadContextIncorrect);
+
+    if (iStopped)
+        return ;
+
+    //deque notifier AO
+    iNotifierQueueCrit.Lock();
+    if (iNotifier && iNotifier->IsAdded())
+        iNotifier->RemoveFromScheduler();
+    iNotifierQueueCrit.Unlock();
+
+    //Stop the scheduler loop.
+    if (iPVScheduler)
+        iPVScheduler->StopScheduler();
+
+    //Wait for PV thread to finish up, then it's safe
+    //to delete the remaining stuff.
+    if (iExitedSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
+        OsclError::Leave(OsclErrSystemCallFailed);//unexpected sem error
+
+    //let the destructor know it's exited.
+    iStopped = true;
+
+    //The thread will exit on its own, but go ahead and
+    //forcibly terminate it now to make sure it's cleaned
+    //up by the time this call returns.
+    iPVThread.Terminate(0);
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::DeliverNotifications(int32 aTargetCount, int32& aNoticesPending)
+//deliver notifications off the queue, from the app thread size
+{
+    //make sure this isn't called under PV thread...
+    if (iPVThreadContext.IsSameThreadContext())
+        OsclError::Leave(OsclErrThreadContextIncorrect);
+
+    for (int32 count = 0;count < aTargetCount;)
+    {
+        //get next notification or cleanup message.
+        iNotifierQueueCrit.Lock();
+        CPVProxyMsg notice(0, 0, NULL);
+        if (iNotificationQueue.size() > 0)
+        {
+            notice = iNotificationQueue[0];
+            iNotificationQueue.erase(&iNotificationQueue[0]);
+        }
+        iNotifierQueueCrit.Unlock();
+
+        if (notice.iMsg)
+        {
+            count++;
+            CPVProxyInterface *ext = FindInterface(notice.iProxyId);
+            if (ext)
+                ext->iClient->HandleNotification(notice.iMsgId, notice.iMsg);
+            else
+            {	//since messages are cleaned up when interfaces
+                //get unregistered, we should not get here.
+                OSCL_ASSERT(0);//debug error.
+            }
+        }
+        else
+            break;//no more messages.
+    }
+    //return number of notices left after trying to process
+    //the desired number.
+    iNotifierQueueCrit.Lock();
+    aNoticesPending = iNotificationQueue.size();
+    iNotifierQueueCrit.Unlock();
+}
+
+void CPVInterfaceProxy::CleanupAppThreadQueues()
+//cleanup memory allocated in App thread.
+{
+    //un-sent commands...
+    iHandlerQueueCrit.Lock();
+    while (!iCommandQueue.empty())
+    {
+        CPVProxyMsg *msg = &iCommandQueue[0];
+        CPVProxyInterface *proxy = FindInterface(msg->iProxyId);
+        if (proxy)
+            proxy->iClient->CleanupCommand(msg->iMsgId, msg->iMsg);
+        iCommandQueue.erase(msg);
+    }
+    iCommandQueue.clear();
+    iCommandQueue.destroy();
+    iHandlerQueueCrit.Unlock();
+
+    //proxy list...
+    iProxyListCrit.Lock();
+    iProxyList.clear();
+    iProxyList.destroy();
+    iProxyListCrit.Unlock();
+}
+
+void CPVInterfaceProxy::CleanupPVThreadQueues()
+//cleanup memory allocated in PV thread.
+{
+    //un-sent notifications
+    iNotifierQueueCrit.Lock();
+    while (!iNotificationQueue.empty())
+    {
+        CPVProxyMsg *msg = &iNotificationQueue[0];
+        CPVProxyInterface *proxy = FindInterface(msg->iProxyId);
+        if (proxy)
+            proxy->iServer->CleanupNotification(msg->iMsgId, msg->iMsg);
+        iNotificationQueue.erase(msg);
+    }
+    iNotificationQueue.clear();
+    iNotificationQueue.destroy();
+    iNotifierQueueCrit.Unlock();
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::CancelCommand(TPVProxyId aProxyId, TPVProxyMsgId aMsgId)
+{
+    CleanupCommands(FindInterface(aProxyId), false, aMsgId);
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::CancelAllCommands(TPVProxyId aProxyId)
+{
+    CleanupCommands(FindInterface(aProxyId), true);
+}
+
+void CPVInterfaceProxy::CleanupCommands(CPVProxyInterface *aExt, bool aAll, TPVProxyMsgId aMsgId)
+{
+    if (!aExt)
+        return ;
+    iHandlerQueueCrit.Lock();
+    for (uint32 i = 0;i < iCommandQueue.size();i++)
+    {
+        CPVProxyMsg *msg = &iCommandQueue[i];
+        if (msg->iProxyId == aExt->iProxyId
+                && (aAll || msg->iMsgId == aMsgId))
+        {
+            aExt->iClient->CleanupCommand(msg->iMsgId, msg->iMsg);
+            iCommandQueue.erase(msg);
+            i--;//move back one since vecter gets scrunched.
+            if (!aAll)
+            {
+                iHandlerQueueCrit.Unlock();
+                return ;
+            }
+        }
+    }
+    iHandlerQueueCrit.Unlock();
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::CancelNotification(TPVProxyId aProxyId, TPVProxyMsgId aMsgId)
+{
+    CleanupNotifications(FindInterface(aProxyId), false, aMsgId);
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::CancelAllNotifications(TPVProxyId aProxyId)
+{
+    CleanupNotifications(FindInterface(aProxyId), true);
+}
+
+void CPVInterfaceProxy::CleanupNotifications(CPVProxyInterface *aExt, bool aAll, TPVProxyMsgId aMsgId)
+{
+    if (!aExt)
+        return ;
+    iNotifierQueueCrit.Lock();
+    for (uint i = 0;i < iNotificationQueue.size();i++)
+    {
+        CPVProxyMsg *msg = &iNotificationQueue[i];
+        if (msg->iProxyId == aExt->iProxyId
+                && (aAll || msg->iMsgId == aMsgId))
+        {
+            aExt->iServer->CleanupNotification(msg->iMsgId, msg->iMsg);
+            iNotificationQueue.erase(msg);
+            i--;//move back one since vector gets scrunched.
+            if (!aAll)
+            {
+                iNotifierQueueCrit.Unlock();
+                return ;
+            }
+        }
+    }
+    iNotifierQueueCrit.Unlock();
+}
+
+void CPVInterfaceProxy::CleanupInterfaceMessages(CPVProxyInterface *aExt)
+//cleanup all extension messages for a particular interface.
+{
+    CleanupCommands(aExt, true);
+    CleanupNotifications(aExt, true);
+}
+
+OSCL_EXPORT_REF TPVProxyId CPVInterfaceProxy::RegisterProxiedInterface(
+    PVProxiedInterfaceServer& server_proxy,
+    PVProxiedInterfaceClient& client_proxy)
+//Proxy extensions call this to register themselves.
+{
+    TPVProxyId id = ++iProxyIdCounter;
+    iProxyListCrit.Lock();
+    CPVProxyInterface proxy(id, &server_proxy, &client_proxy);
+    int32 err;
+    OSCL_TRY(err, iProxyList.push_back(proxy););
+    iProxyListCrit.Unlock();
+    OsclError::LeaveIfError(err);
+    return id;
+}
+
+OSCL_EXPORT_REF void CPVInterfaceProxy::UnregisterProxiedInterface(TPVProxyId aProxyId)
+//Proxy extensions call this to unregister themselves.
+{
+    iProxyListCrit.Lock();
+    CPVProxyInterface *ext = FindInterface(aProxyId, true);
+    if (ext)
+    {
+        //cleanup unprocessed messages and remove.
+        CleanupInterfaceMessages(ext);
+        iProxyList.erase(ext);
+    }
+    iProxyListCrit.Unlock();
+}
+
+OSCL_EXPORT_REF TPVProxyMsgId CPVInterfaceProxy::SendCommand(TPVProxyId aProxyId, OsclAny *aCmd)
+//Proxy extensions call this to send commands from app side
+//to PV side.
+{
+    int32 err = OSCL_ERR_NONE;
+    iCounterCrit.Lock();
+    TPVProxyMsgId id = ++iCommandIdCounter;
+    iCounterCrit.Unlock();
+    iHandlerQueueCrit.Lock();
+    CPVProxyMsg msg(aProxyId, id, aCmd);
+    OSCL_TRY(err, iCommandQueue.push_back(msg););
+    //if the queue was empty, signal the AO.
+    //note: when the queue is empty it is safe to assume the handler AO has a request
+    //pending.
+    if (iCommandQueue.size() == 1)
+        iHandler->PendComplete(OSCL_REQUEST_ERR_NONE);
+    iHandlerQueueCrit.Unlock();
+    //propagate any allocation failure...
+    OsclError::LeaveIfError(err);
+    return id;
+}
+
+OSCL_EXPORT_REF TPVProxyMsgId CPVInterfaceProxy::SendNotification(TPVProxyId aProxyId, OsclAny *aResp)
+//Proxy extensions call this to send notifications from PV
+//side to app side.
+{
+    int32 err = OSCL_ERR_NONE;
+    iCounterCrit.Lock();
+    TPVProxyMsgId id = ++iCommandIdCounter;
+    iCounterCrit.Unlock();
+    iNotifierQueueCrit.Lock();
+    CPVProxyMsg msg(aProxyId, id, aResp);
+    OSCL_TRY(err, iNotificationQueue.push_back(msg););
+    //if the queue was empty and the notifier is scheduled,
+    //signal it.
+    //note: when the queue is empty it is safe to assume the notifier AO has a request
+    //pending.
+    if (iNotifier
+            && iNotifier->IsAdded()
+            && iNotificationQueue.size() == 1)
+        iNotifier->PendComplete(OSCL_REQUEST_ERR_NONE);
+    iNotifierQueueCrit.Unlock();
+    //propagate any allocation failure...
+    OsclError::LeaveIfError(err);
+    return id;
+}
+
+CPVProxyInterface * CPVInterfaceProxy::FindInterface(TPVProxyId aId, bool locked)
+//lookup a registered proxy interface
+{
+    if (!locked)
+        iProxyListCrit.Lock();
+    for (uint32 i = 0;i < iProxyList.size();i++)
+    {
+        if (iProxyList[i].iProxyId == aId)
+        {
+            if (!locked)
+                iProxyListCrit.Unlock();
+            return &iProxyList[i];
+        }
+    }
+    if (!locked)
+        iProxyListCrit.Unlock();
+    return NULL;
+}
+
+void CPVInterfaceProxy::InThread()
+//this is the guts of the proxy thread routine.
+//it's a separate routine since it needs to be
+//run under a trap handler in order to avoid any
+//Cbase 66 panic from the cleanup stack.
+{
+    int32 errTerm(OsclErrNone);
+    int32 errSched(OsclErrNone);
+
+    //create & install scheduler
+    OsclScheduler::Init("PVProxy");
+    iPVScheduler = OsclExecScheduler::Current();
+
+    iPVThreadContext.EnterThreadContext();
+
+    //add handler to scheduler
+    iHandler->AddToScheduler();
+    iHandler->PendForExec();
+
+    //App thread logon...
+    int32 err;
+    err = AppThreadLogon();
+    if (err != OsclErrNone)
+        errTerm = err;
+
+    //Start scheduler.  This call blocks until scheduler is
+    //either stopped or exits due to an error.
+    err = AppStartScheduler();
+    if (err != OsclErrNone)
+    {
+        errSched = err;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "appstartscheduler error %d...", errSched));
+    }
+
+
+    //Cleanup un-processed data.
+    CleanupPVThreadQueues();
+
+    //App thread logoff...
+    err = AppThreadLogoff();
+    if (err != OSCL_ERR_NONE)
+        errTerm = err;
+
+    //Deque the handler AO
+    iHandlerQueueCrit.Lock();
+    iHandler->RemoveFromScheduler();
+    iHandlerQueueCrit.Unlock();
+
+    iPVThreadContext.ExitThreadContext();
+
+    //Uninstall scheduler
+    OsclScheduler::Cleanup();
+    iPVScheduler = NULL;
+
+    //Generate panics if any leaves happened.
+    OSCL_ASSERT(errTerm == OsclErrNone);//EPVProxyPanicEngineLeave
+    OSCL_ASSERT(errSched == OsclErrNone);//EPVProxyPanicSchedulerLeave
+}
+
+////////////////////////////////
+// OS-specific Thread routines
+////////////////////////////////
+
+
+#include "oscl_mem_audit.h"
+
+TOsclThreadFuncRet OSCL_THREAD_DECL pvproxythreadmain(TOsclThreadFuncArg *aPtr)
+//PV Thread main routine
+{
+
+    CPVInterfaceProxy *proxy = (CPVInterfaceProxy *) aPtr;
+
+    //Init OSCL and create logger.
+    OsclBase::Init();
+    OsclErrorTrap::Init();
+    OsclMem::Init();
+    PVLogger::Init();
+
+    //Call the proxied app routine to create its logger appenders.
+    proxy->iPVApp.CreateLoggerAppenders();
+    proxy->iLogger = PVLogger::GetLoggerObject("pvproxy");
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, proxy->iLogger, PVLOGMSG_NOTICE, (0, "PVPROXY:Proxy Thread 0x%x Entry...", OsclExecScheduler::GetId()));
+
+
+    int32 leave;
+    OSCL_TRY(leave, proxy->InThread(););
+
+    if (leave != OsclErrNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR, (0, "PVPROXY:Proxy Thread 0x%x Exit: Leave Reason %d", OsclExecScheduler::GetId(), leave));
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, proxy->iLogger, PVLOGMSG_NOTICE, (0, "PVPROXY:Proxy Thread 0x%x Exit: Normal", OsclExecScheduler::GetId()));
+    }
+
+    //Cleanup logger.
+    PVLogger::Cleanup();
+
+    OsclMem::Cleanup();
+    proxy->iLogger = NULL;
+    OsclErrorTrap::Cleanup();
+    OsclBase::Cleanup();
+
+    //Signal & Exit
+    proxy->iExitedSem.Signal();
+
+    return 0;
+}
+
+int32 CPVInterfaceProxy::CPVIConstructL(uint32 &aNreserve1, uint32 &aNreserve2, int32 &aHandlerPri, int32 &aNotifierPri)
+{
+    int32 err;
+    OSCL_TRY(err, ConstructL(aNreserve1, aNreserve2, aHandlerPri, aNotifierPri););
+    return err;
+}
+
+
+int32 CPVInterfaceProxy::AppThreadLogon()
+{
+    int32 err;
+    OSCL_TRY(err, iPVApp.PVThreadLogon(*this););
+    return err;
+}
+
+int32 CPVInterfaceProxy::AppThreadLogoff()
+{
+    int32 err;
+    OSCL_TRY(err, iPVApp.PVThreadLogoff(*this););
+    return err;
+}
+
+int32 CPVInterfaceProxy::AppStartScheduler()
+{
+    int32 err;
+    OSCL_TRY(err, iPVScheduler->StartScheduler(&iInitSem););
+    return err;
+}
+
diff --git a/baselibs/thread_messaging/src/pv_interface_proxy.h b/baselibs/thread_messaging/src/pv_interface_proxy.h
new file mode 100644
index 0000000..139d9b0
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_interface_proxy.h
@@ -0,0 +1,209 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/** \file pv_interface_proxy.h
+    \brief Main include file for PV Proxy Implementation.
+*/
+
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#define PV_INTERFACE_PROXY_H_INCLUDED
+
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef PV_PROXIED_INTERFACE_H_INCLUDED
+#include "pv_proxied_interface.h"
+#endif
+#ifndef OSCL_SCHEDULER_H_INCLUDED
+#include "oscl_scheduler.h"
+#endif
+#ifndef OSCL_MUTEX_H_INCLUDED
+#include "oscl_mutex.h"
+#endif
+#ifndef OSCL_SEMAPHORE_H_INCLUDED
+#include "oscl_semaphore.h"
+#endif
+
+class CPVInterfaceProxyHandler;
+class CPVInterfaceProxyNotifier;
+class OsclExecScheduler;
+class PVLogger;
+class Oscl_DefAlloc;
+
+
+/**
+//list element for the proxy message queues.
+*/
+class CPVProxyMsg
+{
+    public:
+        CPVProxyMsg(TPVProxyId id, TPVProxyMsgId MsgId, OsclAny *msg)
+                : iProxyId(id), iMsgId(MsgId), iMsg(msg)
+        {}
+        ~CPVProxyMsg()
+        {}
+        TPVProxyId iProxyId;
+        TPVProxyMsgId iMsgId;
+        OsclAny *iMsg;
+};
+
+/**
+//list element for the proxy interface list
+*/
+class CPVProxyInterface
+{
+    public:
+        CPVProxyInterface(TPVProxyId a, PVProxiedInterfaceServer* b, PVProxiedInterfaceClient* c): iProxyId(a), iServer(b), iClient(c)
+        {}
+        ~CPVProxyInterface()
+        {}
+        TPVProxyId iProxyId;
+        PVProxiedInterfaceServer *iServer;
+        PVProxiedInterfaceClient *iClient;
+};
+
+const int32 PVPROXY_DEFAULT_STACK_SIZE = 0x2000;
+
+
+/**
+** Implementation of PVMainProxy
+*/
+class CPVInterfaceProxy: public PVMainProxy
+{
+    public:
+        /**
+        ** Create the proxy.
+        ** @param app: the engine to create under the PV thread.
+        ** @param alloc: optional memory allocator.  If null, a default
+        **    allocator will be used.
+        ** @param stacksize: optional stacksize for the PV thread.
+        ** @param nreserveInterfaceList: optional reserve size for
+        **    the interface list-- to prevent dynamic allocation
+        **    in calls to RegisterProxiedInterfaceL.
+        ** @param nreserveMessageLists: optional reserve sizes for
+        **    the command and notification queues-- to prevent
+        **    dynamic allocation by SendCommandL and SendNotificationL
+        ** @param handlerPri: priority of the command handler active
+        **    object (in the PV thread).
+        ** @param notifierPri: priority of the notifier handler active
+        **    object in the app thread-- if there is one.
+        */
+        OSCL_IMPORT_REF static CPVInterfaceProxy * NewL(
+            PVProxiedEngine& app
+            , Oscl_DefAlloc *alloc = NULL
+                                     , int32 stacksize = PVPROXY_DEFAULT_STACK_SIZE
+                                                         , uint32 nreserveInterfaceList = 20
+                                                                                          , uint32 nreserveMessageLists = 20
+                                                                                                                          , int32 handlerPri = OsclActiveObject::EPriorityNominal + 1
+                                                                                                                                               , int32 notifierPri = OsclActiveObject::EPriorityNominal + 1
+        );
+
+        /**
+        ** Cleanup API.  This call will stop the PV thread if needed
+        ** and then delete the object.  This call differs from the
+        ** destructor only in that it uses the chosen memory allocator
+        ** to delete the memory.
+        */
+        OSCL_IMPORT_REF void Delete();
+
+        //From PVMainProxy
+        OSCL_IMPORT_REF TPVProxyId RegisterProxiedInterface(
+            PVProxiedInterfaceServer& server_proxy,
+            PVProxiedInterfaceClient& client_proxy) ;
+        OSCL_IMPORT_REF void UnregisterProxiedInterface(TPVProxyId aProxyId) ;
+        OSCL_IMPORT_REF TPVProxyMsgId SendCommand(TPVProxyId aProxyId, OsclAny *aCmd);
+        OSCL_IMPORT_REF void CancelCommand(TPVProxyId aProxyId, TPVProxyMsgId aMsgId);
+        OSCL_IMPORT_REF void CancelAllCommands(TPVProxyId aProxyId);
+        OSCL_IMPORT_REF TPVProxyMsgId SendNotification(TPVProxyId aProxyId, OsclAny *aResp);
+        OSCL_IMPORT_REF void CancelNotification(TPVProxyId aProxyId, TPVProxyMsgId aMsgId);
+        OSCL_IMPORT_REF void CancelAllNotifications(TPVProxyId aProxyId);
+        OSCL_IMPORT_REF void StopPVThread();
+        OSCL_IMPORT_REF bool StartPVThread();
+        OSCL_IMPORT_REF void DeliverNotifications(int32 aCount, int32& aNoticesPending);
+
+    protected:
+        int32 AppThreadLogon();
+        int32 AppThreadLogoff();
+        int32 AppStartScheduler();
+        int32 CPVIConstructL(uint32&, uint32&, int32&, int32&);
+        OSCL_IMPORT_REF CPVInterfaceProxy(PVProxiedEngine&, Oscl_DefAlloc*, int32);
+        OSCL_IMPORT_REF void ConstructL(uint32, uint32, int32, int32);
+        OSCL_IMPORT_REF virtual ~CPVInterfaceProxy();
+
+        //PV Thread stuff..
+        PVThreadContext iPVThreadContext;
+        int32 iStacksize;
+        OsclExecScheduler *iPVScheduler;
+        PVLogger *iLogger;
+        void InThread();
+        OsclThread iPVThread;
+
+        //The handler and notfier AOs.
+        CPVInterfaceProxyHandler *iHandler;
+        CPVInterfaceProxyNotifier *iNotifier;
+
+        OsclSemaphore iInitSem;
+        bool iStopped;
+        OsclSemaphore iExitedSem;
+
+        //proxy Id counter
+        int32 iProxyIdCounter;
+
+        //command Id counter
+        OsclNoYieldMutex iCounterCrit;
+        int32 iCommandIdCounter;
+
+        //the proxy list
+        OsclNoYieldMutex iProxyListCrit;
+        Oscl_Vector<CPVProxyInterface, OsclMemAllocator> iProxyList;
+        CPVProxyInterface* FindInterface(TPVProxyId aId, bool locked = false);
+        void CleanupInterfaceMessages(CPVProxyInterface *aExt);
+
+        //Note: The message queues need to be thread safe and therefore
+        //must use a basic allocator that does not use the PV memory management.
+
+        //The message queues-- handler side
+        OsclNoYieldMutex iHandlerQueueCrit;
+        Oscl_Vector<CPVProxyMsg, OsclMemAllocator> iCommandQueue;
+
+        //The message queues-- notifier side
+        OsclNoYieldMutex iNotifierQueueCrit;
+        Oscl_Vector<CPVProxyMsg, OsclMemAllocator> iNotificationQueue;
+
+        void CleanupAppThreadQueues();
+        void CleanupPVThreadQueues();
+        void CleanupNotifications(CPVProxyInterface *aExt, bool aAll, TPVProxyMsgId aMsgId = 0);
+        void CleanupCommands(CPVProxyInterface *aExt, bool aAll, TPVProxyMsgId aMsgId = 0);
+
+        OsclMemAllocator iDefAlloc;
+        Oscl_DefAlloc *iAlloc;
+
+        PVProxiedEngine &iPVApp;
+
+        friend class CPVInterfaceProxyHandler;
+        friend class CPVInterfaceProxyNotifier;
+        friend TOsclThreadFuncRet OSCL_THREAD_DECL pvproxythreadmain(TOsclThreadFuncArg *aPtr);
+};
+
+#endif //
+
+
diff --git a/baselibs/thread_messaging/src/pv_interface_proxy_handler.cpp b/baselibs/thread_messaging/src/pv_interface_proxy_handler.cpp
new file mode 100644
index 0000000..47f214b
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_interface_proxy_handler.cpp
@@ -0,0 +1,66 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#include "pv_interface_proxy.h"
+#endif
+
+#ifndef PV_INTERFACE_PROXY_HANDLER_H_INCLUDED
+#include "pv_interface_proxy_handler.h"
+#endif
+
+void CPVInterfaceProxyHandler::Run()
+{
+    if (Status() != OSCL_REQUEST_ERR_NONE)
+        return;
+
+    CPVProxyMsg command(0, 0, NULL);
+
+    //Enter critical section...
+    iProxy->iHandlerQueueCrit.Lock();
+
+    //check command queue...
+    if (iProxy->iCommandQueue.size() > 0)
+    {
+        command = iProxy->iCommandQueue[0];
+        iProxy->iCommandQueue.erase(&iProxy->iCommandQueue[0]);
+    }
+
+    PendForExec();
+
+    //if there's another message queued,
+    //go ahead and signal request complete.
+    if (iProxy->iCommandQueue.size() > 0)
+        PendComplete(OSCL_REQUEST_ERR_NONE);
+
+    //Leave critical section...
+    iProxy->iHandlerQueueCrit.Unlock();
+
+    //Process command
+    if (command.iMsg)
+    {
+        //call proxy server message handler
+        CPVProxyInterface *proxy = iProxy->FindInterface(command.iProxyId);
+        if (proxy)
+            proxy->iServer->HandleCommand(command.iMsgId, command.iMsg);
+        else
+            OSCL_ASSERT(0);//debug error.
+    }
+
+}
+
diff --git a/baselibs/thread_messaging/src/pv_interface_proxy_handler.h b/baselibs/thread_messaging/src/pv_interface_proxy_handler.h
new file mode 100644
index 0000000..63a2f0c
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_interface_proxy_handler.h
@@ -0,0 +1,49 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+
+#ifndef PV_INTERFACE_PROXY_HANDLER_H_INCLUDED
+#define PV_INTERFACE_PROXY_HANDLER_H_INCLUDED
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#include "pv_interface_proxy.h"
+#endif
+
+#include "oscl_scheduler_ao.h"
+
+class CPVInterfaceProxyHandler :
+            public OsclActiveObject
+{
+    public:
+        CPVInterfaceProxyHandler(CPVInterfaceProxy *aProxy, int32 pri):
+                OsclActiveObject(pri, "proxyHandler")
+                , iProxy(aProxy)
+        {}
+
+        virtual ~CPVInterfaceProxyHandler()
+        {}
+
+    private:
+        void Run();
+
+        CPVInterfaceProxy *iProxy;
+};
+
+#endif //
+
+
diff --git a/baselibs/thread_messaging/src/pv_interface_proxy_notifier.cpp b/baselibs/thread_messaging/src/pv_interface_proxy_notifier.cpp
new file mode 100644
index 0000000..cfe4a97
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_interface_proxy_notifier.cpp
@@ -0,0 +1,65 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#include "pv_interface_proxy.h"
+#endif
+
+#ifndef PV_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
+#include "pv_interface_proxy_notifier.h"
+#endif
+
+void CPVInterfaceProxyNotifier::Run()
+{
+    if (Status() != OSCL_REQUEST_ERR_NONE)
+        return;
+
+    CPVProxyMsg notice(0, 0, NULL);
+
+    //Enter critical section...
+    iProxy->iNotifierQueueCrit.Lock();
+
+    //check notice queue...
+    if (iProxy->iNotificationQueue.size() > 0)
+    {
+        notice = iProxy->iNotificationQueue[0];
+        iProxy->iNotificationQueue.erase(&iProxy->iNotificationQueue[0]);
+    }
+
+    PendForExec();
+
+    //if there's another message queued,
+    //go ahead and signal request complete.
+    if (iProxy->iNotificationQueue.size() > 0)
+        PendComplete(OSCL_REQUEST_ERR_NONE);
+
+    //Leave critical section...
+    iProxy->iNotifierQueueCrit.Unlock();
+
+    //Process the notice
+    if (notice.iMsg)
+    {
+        //call proxy client message handler.
+        CPVProxyInterface *proxy = iProxy->FindInterface(notice.iProxyId);
+        if (proxy)
+            proxy->iClient->HandleNotification(notice.iMsgId, notice.iMsg);
+        else
+            OSCL_ASSERT(0);//debug error.
+    }
+
+}
diff --git a/baselibs/thread_messaging/src/pv_interface_proxy_notifier.h b/baselibs/thread_messaging/src/pv_interface_proxy_notifier.h
new file mode 100644
index 0000000..d96dcf5
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_interface_proxy_notifier.h
@@ -0,0 +1,50 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+
+#ifndef PV_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
+#define PV_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
+
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#include "pv_interface_proxy.h"
+#endif
+
+#include "oscl_scheduler_ao.h"
+
+class CPVInterfaceProxyNotifier :
+            public OsclActiveObject
+{
+    public:
+        CPVInterfaceProxyNotifier(CPVInterfaceProxy *aProxy, int32 pri) :
+                OsclActiveObject(pri, "proxyNotifier")
+                , iProxy(aProxy)
+        {}
+
+        virtual ~CPVInterfaceProxyNotifier()
+        {}
+
+    private:
+        void Run();
+
+        CPVInterfaceProxy *iProxy;
+};
+
+#endif //
+
+
diff --git a/baselibs/thread_messaging/src/pv_proxied_interface.h b/baselibs/thread_messaging/src/pv_proxied_interface.h
new file mode 100644
index 0000000..76f86a9
--- /dev/null
+++ b/baselibs/thread_messaging/src/pv_proxied_interface.h
@@ -0,0 +1,390 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PV_PROXIED_INTERFACE__H
+#define PV_PROXIED_INTERFACE__H
+
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+
+#define PVUidProxiedInterface  PVUuid(0xf7076653,0x6088,0x47c6,0x88,0xc1,0xb7,0xed,0x28,0xe7,0x2b,0xea)
+
+class PVProxiedInterface;
+class PVProxiedInterfaceClient;
+class PVProxiedInterfaceServer;
+class PVProxiedEngine;
+
+typedef int32 TPVProxyId;
+typedef int32 TPVProxyMsgId;
+typedef PVUuid TPVProxyUUID;
+typedef PVProxiedInterface* TPVProxyInterfacePtr;
+
+/**
+** Main proxy class.  This class defines the public interface
+** to the PV proxy.
+*/
+class PVMainProxy
+{
+    public:
+        virtual ~PVMainProxy() {}
+
+        /**
+        ** This call registers a proxied interface with the main
+        ** proxy and assigns a unique interface ID.
+        ** Interfaces may be registered at any time during
+        ** the life of the main proxy.
+        **
+        ** @return aProxyId: the ID of this interface pair.
+        ** @param aServer: server side (PV Thread) implementation.
+        ** @param aClient: client side (app thread) implementation.
+        ** This function will leave if memory allocation fails.
+        */
+        virtual TPVProxyId RegisterProxiedInterface(
+            PVProxiedInterfaceServer& aServer,
+            PVProxiedInterfaceClient& aClient) = 0;
+
+        /**
+        ** This call un-registers a proxied interface with the main
+        ** proxy.  During this call, the main proxy will de-queue all
+        ** undelivered messages belonging to this interface and will
+        ** call their memory cleanup routine.
+        ** If the interface is not currently registered, this call
+        ** will have no effect.
+        ** Interfaces may be un-registered at any time during the
+        ** life of the main proxy.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @return : result code
+        **/
+        virtual void UnregisterProxiedInterface(TPVProxyId aProxyId) = 0;
+
+        /**
+        ** This API adds message to the command queue.  This would
+        ** typically be called from a PVProxiedInterfaceClient
+        ** module.  The message will be delivered asynchronously under
+        ** the PV thread.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @param aCmd: the command.
+        ** @return: a unique message ID, assigned by the proxy.
+        ** This function will leave if memory allocation fails.
+        **/
+        virtual TPVProxyMsgId SendCommand(TPVProxyId aProxyId, OsclAny* aCmd) = 0;
+
+        /**
+        ** This API will cancel a command that was previously sent
+        ** and may still be queued.  This is a synchronous operation.
+        ** The proxy will de-queue the message and call its memory cleanup
+        ** routine.  If the message is no longer queued, this call will
+        ** have no effect.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @param aMsgId: the command's ID, previously returned by SendCommand.
+        ** @return : result code
+        */
+        virtual void CancelCommand(TPVProxyId aProxyId, TPVProxyMsgId aMsgId) = 0;
+
+        /**
+        ** This API will de-queue and cleanup all commands that were
+        ** previously sent for an interface and may still be queued.
+        ** The cancel operation is synchronous.
+        ** If no commands are queued for the interface, this call has
+        ** no effect.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @return : result code
+        */
+        virtual void CancelAllCommands(TPVProxyId aProxyId) = 0;
+
+        /**
+        ** This API adds a message to the notification queue.
+        ** This would typically be called by a PVProxiedInterfaceServer
+        ** module.  The message will be delivered asynchronously under
+        ** the app thread.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @param aResp: the notification.
+        ** @return: a unique message ID, assigned by the proxy.
+        ** This function will leave if memory allocation fails.
+        **/
+        virtual TPVProxyMsgId SendNotification(TPVProxyId aProxyId, OsclAny* aResp) = 0;
+
+        /**
+        ** This API will cancel a notification that was previously sent
+        ** and may still be queued.  This is a synchronous operation.
+        ** The proxy will de-queue the message and call its memory cleanup
+        ** routine.  If the message is no longer queued, this call will
+        ** have no effect.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @param aMsgId: the message ID, previously returned by SendNotification.
+        ** @return : result code
+        */
+        virtual void CancelNotification(TPVProxyId aProxyId, TPVProxyMsgId aMsgId) = 0;
+
+        /**
+        ** This API will de-queue and cleanup all notifications that were
+        ** previously sent for an interface and may still be queued.
+        ** The cancel operation is synchronous.
+        ** If no notifications are queued for the interface, this call has
+        ** no effect.
+        **
+        ** @param aProxyId: the ID of this interface pair.
+        ** @return : result code
+        */
+        virtual void CancelAllNotifications(TPVProxyId aProxyId) = 0;
+
+        /**
+        ** This API will start the PV thread.  The call will block
+        ** until the thread starts up and the engine thread logon
+        ** completes.
+        **
+        **  @returns: true if thread creation succeeded-- false otherwise.
+        */
+        virtual bool StartPVThread() = 0;
+
+        /**
+        ** This API will stop the PV thread's scheduler and block
+        ** until the thread cleanup is complete.  During the thread
+        ** cleanup, the scheduler is stopped, all un-sent messages
+        ** are automatically cleaned up, and the engine Thread Logoff
+        ** routine is called.
+        **
+        ** Calling this API under the PV thread context is an error
+        ** and will leave
+        */
+        virtual void StopPVThread() = 0;
+
+        /**
+        ** This API may be used to run the client-side of the proxy
+        ** in a non-blocking mode, for cases where there is no Oscl
+        ** scheduler or native scheduler running in the application
+        ** thread.
+        ** The proxy client will run until all pending notifications
+        ** have been sent, or else the max count of notifications has
+        ** been reached.  This API also returns the count of notifications
+        ** still pending after the processing is complete.
+        ** Any call to this API from within the PV thread context is
+        ** an error and will leave
+        **
+        ** @param aMaxCount: (input param) the maximum of pending
+        **   notifications to process during the call.
+        ** @param aPendingCount: (output param) number of pending
+        **   notifications still remaining on the queue.
+        */
+        virtual void DeliverNotifications(int32 aMaxCount, int32& aPendingCount) = 0;
+};
+
+/**
+** A proxied engine must implement this class
+*/
+class PVProxiedEngine
+{
+    public:
+        virtual ~PVProxiedEngine() {}
+
+        /**
+        ** Create PV logger appenders for the PV thread.
+        ** Creating appenders in this call is optional and
+        ** allows logging by the PV thread related to thread
+        ** and scheduler initialization that occurs before
+        ** the thread logon.
+        **/
+        virtual void CreateLoggerAppenders() = 0;
+
+        /**
+        ** Perform all thread-specific engine creation and
+        ** initialization.
+        ** This call is made by the main proxy from the PV
+        ** Thread after Oscl has been initialized
+        ** in the thread, but before starting the scheduler.
+        **
+        ** @param proxy: reference to the caller.  The app
+        **   may save this pointer and use it to make calls
+        **   to the main proxy.
+        */
+        virtual void PVThreadLogon(PVMainProxy &proxy) = 0;
+
+        /**
+        ** Perform all thread-specific engine cleanup.
+        ** This call is made by the main proxy from the PV thread
+        ** after the scheduler has exited, but before Oscl has been
+        ** cleaned up.
+        **
+        ** @param proxy: reference to the caller.  The app
+        **   may save this pointer and use it to make calls
+        **   to the main proxy.
+        */
+        virtual void PVThreadLogoff(PVMainProxy &proxy) = 0;
+};
+
+/**
+** Proxied interface modules may implement this class
+** in order to provide a common interface query mechanism.
+*/
+class PVProxiedInterface : public PVInterface
+{
+    public:
+        /**
+        ** To query for supported (proxied) interfaces.
+        **
+        ** @param aUuid (input): the requested UUID
+        ** @param aInterfacePtr (output): a pointer to
+        **    the interface implementation, or NULL if not available.
+        **
+        ** The holder of the interface pointer must call
+        ** "removeRef" when it is done with the pointer.
+        */
+        virtual void QueryProxiedInterface(const TPVProxyUUID& aUuid, PVInterface*& aInterfacePtr) = 0;
+        /**
+        ** May be used to pass the main proxy pointer to
+        ** the implementation.
+        */
+        virtual void SetMainProxy(PVMainProxy*) = 0;
+};
+
+
+/**
+** Proxied interface modules must implement this class on the
+** PV thread side.
+*/
+class PVProxiedInterfaceServer
+{
+    public:
+        /**
+        ** PVMainProxy calls this under the PV thread to process a
+        ** command off the queue.
+        **
+        ** @param aId: the message ID assigned by the SendCommand call.
+        ** @param aMsg: the command data.
+        */
+        virtual void HandleCommand(TPVProxyMsgId aMsgId, OsclAny* aMsg) = 0;
+
+        /**
+        ** PVMainProxy calls this to cleanup an un-sent or canceled
+        ** notification.  The server module should clean up any
+        ** allocated memory.  The cleanup operation must be synchronous
+        ** and thread-safe.
+        **
+        ** @param aId: the message ID assigned by the SendNotification call.
+        ** @param aMsg: the notification data.
+        */
+        virtual void CleanupNotification(TPVProxyMsgId aId, OsclAny* aMsg) = 0;
+};
+
+/**
+** Proxied interface pairs must implement this class on the
+** app thread side.
+*/
+class PVProxiedInterfaceClient
+{
+    public:
+        PVProxiedInterfaceClient() {}
+
+        /**
+        ** PVMainProxy calls this to process a notification off the
+        ** queue.
+        ** @param aId: the message ID assigned by the SendNotification call.
+        ** @param aMsg: the notification data.
+        */
+        virtual void HandleNotification(TPVProxyMsgId aId, OsclAny* aMsg) = 0;
+
+        /**
+        ** PVMainProxy calls this to cleanup an un-sent or canceled
+        ** command.  The client module should clean up any allocated
+        ** memory.  The cleanup operation must be synchronous
+        ** and thread-safe.
+        **
+        ** @param aId: the message ID assigned by the SendCommand call.
+        ** @param aMsg: the command data.
+        */
+        virtual void CleanupCommand(TPVProxyMsgId aId, OsclAny* aMsg) = 0;
+};
+
+/**
+//A basic implemention of PVProxiedInterface.
+//Interface implementations
+//can derive from this.
+*/
+template<class Alloc>
+class PVProxiedInterfaceImpl : public PVProxiedInterface
+{
+    public:
+        PVProxiedInterfaceImpl(const PVUuid& uuid)
+                : iRefCounter(1)
+                , iUuid(uuid)
+                , iMainProxy(NULL)
+        {}
+        void SetUuid(const PVUuid& uuid)
+        {
+            iUuid = uuid;
+        }
+        bool TestUuid(const PVUuid& uuid)
+        {
+            return iUuid == uuid;
+        }
+        virtual ~PVProxiedInterfaceImpl()
+        {}
+        void removeRef()
+        {
+            --iRefCounter;
+            if (iRefCounter <= 0)
+            {
+                this->~PVProxiedInterfaceImpl();
+                Alloc alloc;
+                alloc.deallocate(this);
+            }
+        }
+        void addRef()
+        {
+            iRefCounter++;
+        }
+        bool queryInterface(const PVUuid&, PVInterface*&)
+        {
+            return false;
+        }
+
+        void SetMainProxy(PVMainProxy*p)
+        {
+            iMainProxy = p;
+        }
+        void QueryProxiedInterface(const TPVProxyUUID& aUuid, PVInterface*& aInterfacePtr)
+        {
+            if (aUuid == iUuid)
+                aInterfacePtr = (PVInterface*)this;
+            else
+                aInterfacePtr = NULL;
+        }
+    protected:
+        int32 iRefCounter;
+        PVUuid iUuid;
+        PVMainProxy *iMainProxy;
+};
+
+
+#endif
+
+
diff --git a/baselibs/threadsafe_callback_ao/Android.mk b/baselibs/threadsafe_callback_ao/Android.mk
index df63f1d..cefd142 100644
--- a/baselibs/threadsafe_callback_ao/Android.mk
+++ b/baselibs/threadsafe_callback_ao/Android.mk
@@ -3,25 +3,30 @@
 
 LOCAL_SRC_FILES := \
 	src/threadsafe_callback_ao.cpp \
-	src/threadsafe_mempool.cpp
-
+ 	src/threadsafe_mempool.cpp \
+ 	src/threadsafe_queue.cpp
 
 
 LOCAL_MODULE := libthreadsafe_callback_ao
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//baselibs/threadsafe_callback_ao/src \
-	$(PV_TOP)//baselibs/threadsafe_callback_ao/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/baselibs/threadsafe_callback_ao/src \
+ 	$(PV_TOP)/baselibs/threadsafe_callback_ao/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/threadsafe_callback_ao.h \
-	src/threadsafe_mempool.h
+ 	src/threadsafe_mempool.h \
+ 	src/threadsafe_queue.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/baselibs/threadsafe_callback_ao/build/make/local.mk b/baselibs/threadsafe_callback_ao/build/make/local.mk
new file mode 100644
index 0000000..85e7343
--- /dev/null
+++ b/baselibs/threadsafe_callback_ao/build/make/local.mk
@@ -0,0 +1,24 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := threadsafe_callback_ao
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS := threadsafe_callback_ao.cpp \
+        threadsafe_mempool.cpp \
+        threadsafe_queue.cpp
+
+
+HDRS := threadsafe_callback_ao.h \
+	threadsafe_mempool.h \
+	threadsafe_queue.h
+
+include $(MK)/library.mk
diff --git a/baselibs/threadsafe_callback_ao/build/make/makefile b/baselibs/threadsafe_callback_ao/build/make/makefile
deleted file mode 100644
index 4f8f4f2..0000000
--- a/baselibs/threadsafe_callback_ao/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = threadsafe_callback_ao
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS = threadsafe_callback_ao.cpp \
-       threadsafe_mempool.cpp
-
-HDRS = threadsafe_callback_ao.h \
-       threadsafe_mempool.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.cpp b/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.cpp
index a09389b..e402e8c 100644
--- a/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.cpp
+++ b/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.h b/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.h
index d285e9f..71a24f0 100644
--- a/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.h
+++ b/baselibs/threadsafe_callback_ao/src/threadsafe_callback_ao.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.cpp b/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.cpp
index f44a118..c114026 100644
--- a/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.cpp
+++ b/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -149,6 +149,7 @@
     else if (n > iChunkSize)
     {
         OSCL_LEAVE(OsclErrArgument);
+
     }
 
 
@@ -158,7 +159,6 @@
 
         iMemPoolMutex.Unlock();
         return NULL;
-        // OSCL_LEAVE(OsclErrNoResources);
     }
 
     // Return the next available chunk from the pool
diff --git a/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.h b/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.h
index 7e27559..91d4833 100644
--- a/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.h
+++ b/baselibs/threadsafe_callback_ao/src/threadsafe_mempool.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -99,7 +99,7 @@
 
         /* copy constructor - declared protected to prevent usage of the default copy constructor */
         /* NOTE: This copy constructor should never be used */
-        OSCL_IMPORT_REF ThreadSafeMemPoolFixedChunkAllocator(const ThreadSafeMemPoolFixedChunkAllocator &alloc): OsclMemPoolFixedChunkAllocator(alloc) {};
+        ThreadSafeMemPoolFixedChunkAllocator(const ThreadSafeMemPoolFixedChunkAllocator &alloc): OsclMemPoolFixedChunkAllocator(alloc) {};
 
 
     protected:
diff --git a/baselibs/threadsafe_callback_ao/src/threadsafe_queue.cpp b/baselibs/threadsafe_callback_ao/src/threadsafe_queue.cpp
new file mode 100644
index 0000000..443ad07
--- /dev/null
+++ b/baselibs/threadsafe_callback_ao/src/threadsafe_queue.cpp
@@ -0,0 +1,141 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "threadsafe_queue.h"
+
+//Only do sem wait on pre-emptive thread OS.
+//The reason is that sem wait is not always available on
+//non-pre-emptive OS (such as under Brew applet thread)
+#if !(OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT)
+#define USE_SEM_WAIT 1
+#else
+#define USE_SEM_WAIT 0
+#endif
+
+OSCL_EXPORT_REF ThreadSafeQueue::ThreadSafeQueue()
+        : OsclActiveObject(OsclActiveObject::EPriorityNominal, "ThreadSafeQueue")
+{
+    iObserver = NULL;
+    iCounter = 1;
+    if (OsclThread::GetId(iThreadId) != OsclProcStatus::SUCCESS_ERROR)
+        OsclError::Leave(OsclErrSystemCallFailed);
+#if USE_SEM_WAIT
+    iQueueReadySem.Create();
+#endif
+    iQueueMut.Create();
+    AddToScheduler();
+    PendForExec();
+    iQueueReadySem.Signal();
+}
+
+OSCL_EXPORT_REF ThreadSafeQueue::~ThreadSafeQueue()
+{
+    RemoveFromScheduler();
+#if USE_SEM_WAIT
+    iQueueReadySem.Close();
+#endif
+    iQueueMut.Close();
+}
+
+OSCL_EXPORT_REF bool ThreadSafeQueue::IsInThread()
+{
+    TOsclThreadId id;
+    if (OsclThread::GetId(id) == OsclProcStatus::SUCCESS_ERROR)
+    {
+        return OsclThread::CompareId(id, iThreadId);
+    }
+    return false;
+}
+
+OSCL_EXPORT_REF void ThreadSafeQueue::Configure(ThreadSafeQueueObserver* aObs, uint32 aReserve, uint32 aId)
+{
+    iQueueMut.Lock();
+    iObserver = aObs;
+    iQueue.reserve(aReserve);
+    iCounter = aId;
+    iQueueMut.Unlock();
+}
+
+OSCL_EXPORT_REF ThreadSafeQueueId ThreadSafeQueue::AddToQueue(OsclAny *EventData, ThreadSafeQueueId* aId)
+{
+    iQueueMut.Lock();
+    uint32 count = (aId) ? *aId : ++iCounter;
+    ThreadSafeQueueElement elem(count, EventData);
+    iQueue.push_back(elem);
+    uint32 size = iQueue.size();
+    iQueueMut.Unlock();
+
+    //Signal the AO.  Only signal when the queue was previously empty in order
+    // to minimize the amount of blocking in this call.
+    if (size == 1)
+    {
+#if USE_SEM_WAIT
+        //Wait on the AO to be ready to be signaled.
+        iQueueReadySem.Wait();
+        PendComplete(OSCL_REQUEST_ERR_NONE);
+#else
+        //To avoid problems under brew applet, don't do a sem wait here.
+        //instead just check AO status and signal if needed.  It should
+        //not be possible to lose data, since the only time AO is *not* ready
+        //to be signaled is when a notification is already pending.
+        //The reason to not do this in all platforms is that Status() call
+        //is not thread-safe, but on non-preemptive OS it's ok here.
+        if (Status() == OSCL_REQUEST_PENDING)
+            PendComplete(OSCL_REQUEST_ERR_NONE);
+#endif
+    }
+
+    return count;
+}
+
+OSCL_EXPORT_REF uint32 ThreadSafeQueue::DeQueue(ThreadSafeQueueId& aId, OsclAny*& aData)
+{
+    uint32 num = 0;
+    iQueueMut.Lock();
+    if (iQueue.size())
+    {
+        aId = iQueue[0].iId;
+        aData = iQueue[0].iData;
+        iQueue.erase(&iQueue[0]);
+        num++;
+    }
+    iQueueMut.Unlock();
+    return num;
+}
+
+void ThreadSafeQueue::Run()
+{
+    iQueueMut.Lock();
+    PendForExec();
+#if USE_SEM_WAIT
+    iQueueReadySem.Signal();
+#endif
+    uint32 count = iQueue.size();
+    ThreadSafeQueueObserver* obs = iObserver;
+    iQueueMut.Unlock();
+
+    //note: don't do the callback under the lock, in order to allow
+    //de-queueing the data in the callback.  this creates the possibility
+    //that queue size may not equal "count" in the callback.
+    if (count && obs)
+        obs->ThreadSafeQueueDataAvailable(this);
+}
+
+
+
+
diff --git a/baselibs/threadsafe_callback_ao/src/threadsafe_queue.h b/baselibs/threadsafe_callback_ao/src/threadsafe_queue.h
new file mode 100644
index 0000000..f988d31
--- /dev/null
+++ b/baselibs/threadsafe_callback_ao/src/threadsafe_queue.h
@@ -0,0 +1,142 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef THREADSAFE_QUEUE_H_INCLUDED
+#define THREADSAFE_QUEUE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_BASE_ALLOC_H_INCLUDED
+#include "oscl_base_alloc.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef OSCL_SEMAPHORE_H_INCLUDED
+#include "oscl_semaphore.h"
+#endif
+
+#ifndef OSCL_MUTEX_H_INCLUDED
+#include "oscl_mutex.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+class ThreadSafeQueue;
+class ThreadSafeQueueObserver
+{
+    public:
+        /*
+        ** Observer receives this callback when data has been added to the queue.
+        ** There may be multiple data available when this is called.  There will
+        ** not necessarily be one notice per item, so the observer should process
+        ** the entire queue when it receives this notice.
+        **
+        ** param (in) aQueue: originating queue, in case multiple queues share an observer.
+        */
+        OSCL_IMPORT_REF virtual void ThreadSafeQueueDataAvailable(ThreadSafeQueue* aQueue) = 0;
+};
+
+/*
+** A thread-safe queue.
+** This queue resides in a thread that has a scheduler.
+** Any thread(s) can add data.
+** The queue will call ThreadSafeQueueDataAvailable from the owner thread
+** when data has been added to the queue.
+*/
+
+typedef uint32 ThreadSafeQueueId;
+
+class ThreadSafeQueue: public OsclActiveObject
+{
+    public:
+
+        OSCL_IMPORT_REF ThreadSafeQueue();
+        OSCL_IMPORT_REF virtual ~ThreadSafeQueue();
+
+        /*
+        ** Configure
+        ** @param (in) aObs: observer
+        ** @param (in) aReserve: queue reserve
+        ** @param (in) aId: initial value for the assigned data IDs.
+        */
+        OSCL_IMPORT_REF void Configure(ThreadSafeQueueObserver* aObs, uint32 aReserve = 1, uint32 aId = 0);
+
+        /*
+        ** Add data to the queue from any thread.
+        ** @param (in) aData: item to queue
+        ** @param (in) aId: optional command ID.  If none is input, then one will be
+        **   generated from the internal counter.
+        ** @return: a unique ID for the data.
+        */
+        OSCL_IMPORT_REF ThreadSafeQueueId AddToQueue(OsclAny *aData, ThreadSafeQueueId* aId = NULL);
+
+        /*
+        ** DeQueue data from any thread.  Data is returned in FIFO order.
+        ** @param (out) aId: the ID that was returned by AddToQueue.
+        ** @param (out) aData: the queued item.
+        ** @return: number of items de-queued (either 0 or 1)
+        */
+        OSCL_IMPORT_REF uint32 DeQueue(ThreadSafeQueueId& aId, OsclAny*& aData);
+
+        /*
+        ** Checks whether calling context is the same as the queue thread context.
+        ** @return true if same thread context.
+        */
+        OSCL_IMPORT_REF bool IsInThread();
+
+    protected:
+
+        class ThreadSafeQueueElement
+        {
+            public:
+                ThreadSafeQueueElement(ThreadSafeQueueId aId, OsclAny* aData)
+                        : iId(aId)
+                        , iData(aData)
+                {}
+                ThreadSafeQueueElement(const ThreadSafeQueueElement& aElem)
+                        : iId(aElem.iId)
+                        , iData(aElem.iData)
+                {}
+                ThreadSafeQueueId iId;
+                OsclAny *iData;
+        };
+
+        void Run();
+
+        ThreadSafeQueueObserver *iObserver;
+
+        OsclSemaphore iQueueReadySem;//this sem is signaled when it's OK to signal the AO.
+        OsclNoYieldMutex iQueueMut; //data lock
+
+        Oscl_Vector<ThreadSafeQueueElement, _OsclBasicAllocator> iQueue;
+
+        uint32 iCounter;//data ID counter
+
+        TOsclThreadId iThreadId;
+
+        void Lock();
+        void Unlock();
+};
+
+#endif
diff --git a/build_config/common/local.mk b/build_config/common/local.mk
new file mode 100644
index 0000000..d84f220
--- /dev/null
+++ b/build_config/common/local.mk
@@ -0,0 +1,19 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# include the CML2 configuration
+include $(CFG_DIR)/pv_config.mk
+
+# define some basic preprocessor conditionals that may be needed
+# to get the pv_config.h file to be included
+#Replace double qoutes, escape spaces and prefix -D to each flag.
+XCONFIG_FLAGS:=$(call process_config_macros,$(strip $(CONFIG_FLAGS)))
+
+# $(info config_flags = $(CONFIG_FLAGS), xconfig_flags = $(XCONFIG_FLAGS))
+
+CPPFLAGS += $(XCONFIG_FLAGS)
+
+INCDIRS += -I$(SRC_ROOT)/oscl/oscl/config/$(BUILD_ARCH) -I$(SRC_ROOT)/oscl/oscl/config/shared
+
+INCDEPLIST := $(SRC_ROOT)/oscl/oscl/config/$(BUILD_ARCH),$(SRC_ROOT)/oscl/oscl/config/shared
+
diff --git a/build_config/default/setup b/build_config/default/setup
new file mode 100644
index 0000000..2726eca
--- /dev/null
+++ b/build_config/default/setup
@@ -0,0 +1,68 @@
+
+# Setup environment for necessary for the
+# makefiles, etc.
+
+# Set this flag for integarting CML2 config with the builds.
+# 
+setenv USE_CML2_CONFIG 1
+
+# How is VOB_BASE_DIR value set?
+# 1. If there is an argument to the setup script execution, use that. 
+# 2. Else, check if the value is already set and use that. 
+# 3. Throw an error.
+# @TODO : Obsolete VOB_BASE_DIR when that macro is no longer used.
+
+if ($# >= 1) then
+   setenv VOB_BASE_DIR $1
+   echo Set VOB_BASE_DIR to $VOB_BASE_DIR ...
+else
+   if (! $?VOB_BASE_DIR) then
+      echo "Error. !!!!!!!VOB_BASE_DIR is not set!!!!!!!"
+   else
+      echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
+   endif
+endif
+
+# Set the PV_TOP
+#
+setenv PV_TOP $VOB_BASE_DIR/oscl
+echo Set PV_TOP to $PV_TOP ...
+
+setenv PROJECT $PV_TOP
+echo Set PROJECT to $PROJECT ...
+
+setenv MK $VOB_BASE_DIR/tools_v2/build/make
+echo Set MK to $MK ...
+
+setenv CCASE_MAKE_COMPAT gnu
+echo Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ...
+
+if (! -f $MK/../bin/archtype) then
+   echo "Error. Cannot find archtype script $MK/../bin/archtype."
+endif
+
+set arch_bin_path = `$MK/../bin/archtype`
+set extern_tools_path = $VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
+set path = (./$arch_bin_path  $extern_tools_path $path)
+unset arch_bin_path
+unset extern_tools_path
+
+if ( -f ./setup.extras ) then
+  echo File setup.extras found, sourcing ...
+  source ./setup.extras
+else
+  echo File setup.extras not found, skipping ...
+endif
+
+# Rehash
+#
+rehash
+rehash
+
+# Finita
+#
+echo 
+echo Environment is ready if no errors reported
+echo 
+
+# END OF SCRIPT - NO CODE BEYOND THIS POINT 
diff --git a/build_config/default/setup.bat b/build_config/default/setup.bat
new file mode 100755
index 0000000..77f3209
--- /dev/null
+++ b/build_config/default/setup.bat
@@ -0,0 +1,42 @@
+@echo OFF
+IF (%1)==() echo.Usage ERROR! %0 VOB base directory "use double slashes" eg: C:\\static_view_dir [Static] D:\ [Dynamic]
+
+rem *** Setup environment for necessary for the makefiles, etc. ***
+
+rem *** Set this flag for integarting CML2 config with the builds ***
+set USE_CML2_CONFIG=1
+
+rem *** Set the VOB_BASE_DIR ***
+set VOB_BASE_DIR=%1
+echo Set VOB_BASE_DIR to %VOB_BASE_DIR% ...
+
+rem *** Set the PV_TOP ***
+set PV_TOP=%VOB_BASE_DIR%\\oscl
+echo Set PV_TOP to %PV_TOP% ...
+
+rem *** Set the PROJECT ***
+set PROJECT=%PV_TOP%
+echo Set PROJECT to %PROJECT% ...
+
+rem *** Set MK to path keeping the makefiles templates ***
+set MK=%VOB_BASE_DIR%\tools_v2\build\make
+echo Set MK to %MK% ...
+
+rem *** Append win32 make.exe path in PATH ***
+
+rem *** Set Defaults Path for Perl bin directory ***
+set PERL_HOME_PATH=C:\Perl\bin
+set PATH=%VOB_BASE_DIR%\extern_tools_v2\bin\win32;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\VC98\Bin;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;c:\Program Files\Microsoft Visual Studio 8\Common7\Tools;c:\windows;c:\windows\system32;C:\Windows\System32\Wbem;C:\Program Files\Rational\ClearCase\bin;C:\Program Files\Rational\common;C:\Program Files\AccuRev\bin
+
+rem ***Check if PERL_HOME is already defined ***
+if exist %PERL_HOME% set PERL_HOME_PATH=%PERL_HOME%
+
+rem *** Check if Perl is installed in the host machine ***
+if not exist %PERL_HOME_PATH%\perl.exe echo Error :"%PERL_HOME_PATH%\perl.exe Not found. Either install perl at 'C:\Perl\bin' or Set PERL_HOME to the Perl bin Directory."
+if exist %PERL_HOME_PATH%\perl.exe set PATH=%PERL_HOME_PATH%;%PATH%
+
+
+echo ******************************************
+echo Environment is ready if no errors reported
+echo ******************************************
+
diff --git a/build_config/default/setup.ksh b/build_config/default/setup.ksh
new file mode 100644
index 0000000..f209094
--- /dev/null
+++ b/build_config/default/setup.ksh
@@ -0,0 +1,62 @@
+echo Setting up build environment with default configuration ...
+
+# Setup environment for necessary for the
+# makefiles, etc.
+
+# Set this flag for integarting CML2 config with the builds.
+# 
+export USE_CML2_CONFIG=1
+
+# How is VOB_BASE_DIR value set?
+# 1. If there is an argument to the setup script execution, use that. 
+# 2. Else, check if the value is already set and use that. 
+# 3. Throw an error.
+# @TODO : Obsolete VOB_BASE_DIR when that macro is no longer used.
+
+if [[ $# -ge 1 ]]; then
+   export VOB_BASE_DIR="$1"
+   echo "Set VOB_BASE_DIR to $VOB_BASE_DIR ..."
+else
+   if [[ -z $VOB_BASE_DIR ]]; then
+      echo "Error. !!!!!!!VOB_BASE_DIR is not set!!!!!!!"
+   else   
+      echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
+   fi
+fi
+
+# Set the PV_TOP
+#
+export PV_TOP=$VOB_BASE_DIR/oscl
+echo Set PV_TOP to $PV_TOP ...
+
+export PROJECT=$PV_TOP
+echo "Set PROJECT to $PROJECT ..."
+
+export MK="$VOB_BASE_DIR/tools_v2/build/make"
+echo "Set MK to $MK ..."
+
+export CCASE_MAKE_COMPAT="gnu"
+echo "Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ..."
+
+if [[ ! -f "$MK/../bin/archtype" ]];  then
+  echo "Error. Cannot find archtype script $MK/../bin/archtype."
+fi
+
+export arch_bin_path=`$MK/../bin/archtype`
+export extern_tools_path=$VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
+export PATH=./$arch_bin_path:$extern_tools_path:$PATH
+
+export arch_bin_path=
+export extern_tools_path=
+
+if [[ -f ./setup.extras.ksh ]]; then
+   echo File setup.extras.ksh found, sourcing ...
+   . ./setup.extras.ksh
+else
+   echo File setup.extras not found, skipping ...
+fi 
+
+echo 
+echo Environment is ready if no errors reported
+echo
+
diff --git a/build_config/default/setup.sh b/build_config/default/setup.sh
new file mode 100644
index 0000000..f209094
--- /dev/null
+++ b/build_config/default/setup.sh
@@ -0,0 +1,62 @@
+echo Setting up build environment with default configuration ...
+
+# Setup environment for necessary for the
+# makefiles, etc.
+
+# Set this flag for integarting CML2 config with the builds.
+# 
+export USE_CML2_CONFIG=1
+
+# How is VOB_BASE_DIR value set?
+# 1. If there is an argument to the setup script execution, use that. 
+# 2. Else, check if the value is already set and use that. 
+# 3. Throw an error.
+# @TODO : Obsolete VOB_BASE_DIR when that macro is no longer used.
+
+if [[ $# -ge 1 ]]; then
+   export VOB_BASE_DIR="$1"
+   echo "Set VOB_BASE_DIR to $VOB_BASE_DIR ..."
+else
+   if [[ -z $VOB_BASE_DIR ]]; then
+      echo "Error. !!!!!!!VOB_BASE_DIR is not set!!!!!!!"
+   else   
+      echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
+   fi
+fi
+
+# Set the PV_TOP
+#
+export PV_TOP=$VOB_BASE_DIR/oscl
+echo Set PV_TOP to $PV_TOP ...
+
+export PROJECT=$PV_TOP
+echo "Set PROJECT to $PROJECT ..."
+
+export MK="$VOB_BASE_DIR/tools_v2/build/make"
+echo "Set MK to $MK ..."
+
+export CCASE_MAKE_COMPAT="gnu"
+echo "Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ..."
+
+if [[ ! -f "$MK/../bin/archtype" ]];  then
+  echo "Error. Cannot find archtype script $MK/../bin/archtype."
+fi
+
+export arch_bin_path=`$MK/../bin/archtype`
+export extern_tools_path=$VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
+export PATH=./$arch_bin_path:$extern_tools_path:$PATH
+
+export arch_bin_path=
+export extern_tools_path=
+
+if [[ -f ./setup.extras.ksh ]]; then
+   echo File setup.extras.ksh found, sourcing ...
+   . ./setup.extras.ksh
+else
+   echo File setup.extras not found, skipping ...
+fi 
+
+echo 
+echo Environment is ready if no errors reported
+echo
+
diff --git a/build_config/default/setup_nr.bat b/build_config/default/setup_nr.bat
new file mode 100755
index 0000000..07fb9bd
--- /dev/null
+++ b/build_config/default/setup_nr.bat
@@ -0,0 +1,38 @@
+@echo OFF
+IF (%1)==() echo.Usage !!!ERROR!!! %0 {Base Directory} Use capital letter for drive letter.
+
+rem *** Setup environment for necessary for the makefiles, etc. ***
+
+rem *** All build output goes under BUILD_ROOT including object files, dependency files, libraries, installed headers, etc ***
+set BUILD_ROOT=%PROJECT_DIR%\build
+echo Set BUILD_ROOT to %BUILD_ROOT%
+
+rem *** BASE_DIR is the base directory mainly to specify MK. ***
+rem *** Helps us to set path for some of the extern_tools required in the build. ***
+set BASE_DIR=%1
+echo Set BASE_DIR to %BASE_DIR%
+
+rem *** SRC_ROOT is the root of all the sources ***
+set SRC_ROOT=%BASE_DIR%
+echo Set SRC_ROOT to %SRC_ROOT%
+
+rem *** MK is where all the makefile templates are picked from. ***
+set MK=%BASE_DIR%\tools_v2\build\make_nr\tools_v2\build\make
+echo Set MK to %MK%
+
+rem *** Append win32 make.exe path in PATH ***
+set PATH=%BASE_DIR%\extern_tools_v2\bin\win32;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\VC98\Bin;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;c:\Program Files\Microsoft Visual Studio 8\Common7\Tools;%PATH%
+
+rem *** TOOLSET is used to determine which tools to use ***
+set TOOLSET=vc6
+echo Set TOOLSET to %TOOLSET%
+
+rem *** PLATFORM_EXTRAS is used to include platform specific templates ***
+set PLATFORM_EXTRAS=%MK%\projfile.mk
+echo Set PLATFORM_EXTRAS to %PLATFORM_EXTRAS%
+
+
+echo ******************************************
+echo Environment is ready if no errors reported
+echo ******************************************
+
diff --git a/build_config/default/setup_nr.sh b/build_config/default/setup_nr.sh
new file mode 100644
index 0000000..e18682a
--- /dev/null
+++ b/build_config/default/setup_nr.sh
@@ -0,0 +1,150 @@
+function print_menu()
+{
+    echo
+    echo "Build selection menu... choose from the following:"
+    echo
+    echo "1. Build for host platform"
+    echo "2. Arm device build using OpenCORE (Android) cross-compiler"
+    echo "3. Build using default linux-arm cross-compiler"
+    echo "4. Arm device build using OpenCORE (Android) cross-compiler inside AccuRev workspace"
+    echo
+
+}
+
+function clean_env()
+{
+  echo "**********************************"
+  echo "Cleaning ARCHITECTURE ..."
+  unset ARCHITECTURE
+  echo "Cleaning ANDROID_BASE ..."
+  unset ANDROID_BASE
+  echo "Setting PATH back to the original ..."
+  export PATH=$BASE_PATH
+  echo "**********************************"
+}
+
+function menu()
+{
+    if [ "$1" ] ; then
+        CHOICE=$1
+    else
+        print_menu
+        read -p "Which selection would you like? " CHOICE
+    fi
+
+    case $CHOICE in
+    1)
+        echo "Choice is to build for the host platform."
+        clean_env
+        ;;
+    2)
+        echo "Choice is to build for target with OpenCORE (Android) cross-compiler"
+        ## clean the environment
+        clean_env
+        ## set path up for linux OpenCore build
+        android_gcc_arm_path=/opt/environments/android/toolchain-eabi-4.2.1/bin
+        export ARCHITECTURE=linux_nj
+        echo "ARCHITECTURE=$ARCHITECTURE"
+        export PATH=$android_gcc_arm_path:$BASE_PATH
+        export ANDROID_BASE=/opt/environments/android
+        echo "ANDROID_BASE=$ANDROID_BASE"
+        ;;
+    3)
+        echo "Choice is to build for target with the default linux-arm cross-compiler"
+        # clean the environment
+        clean_env
+        # set path up for linux-arm compiler
+        linux_arm_path=/opt/environments/linux_arm/data/omapts/linux/arm-tc/gcc-3.4.0-1/bin
+        export ARCHITECTURE=linux_arm
+        export PATH=$linux_arm_path:$BASE_PATH
+        ;;
+    4)  
+        echo "Choice is to build for target with workspace's OpenCORE (Android) cross-compiler"
+        ## clean the environment
+        clean_env
+        ## set path up for linux OpenCore build
+        android_gcc_arm_path=$BASE_DIR/toolchains/android/toolchain-eabi-4.2.1/bin
+        export ARCHITECTURE=linux_nj
+        echo "ARCHITECTURE=$ARCHITECTURE"
+        export PATH=$android_gcc_arm_path:$BASE_PATH
+        export ANDROID_BASE=$BASE_DIR/toolchains/android
+        echo "ANDROID_BASE=$ANDROID_BASE"
+        ;;
+    *)
+        echo "Invalid selection.  Please enter your selection again."
+        print_menu
+        return
+        ;;
+    esac
+}
+
+function mkcmdcmpl()
+{
+    printf "\nGetting make cmdline completion values...\n"
+    export PV_MAKE_COMPLETION_TARGETS=`make -j -f makefile_nr completion_targets`
+    printf "Done getting make cmdline completion values.\n\n"
+}
+
+
+
+echo Setting up build environment with default configuration ...
+
+export PROJECT_DIR=$PWD
+
+# Set CFG_DIR
+#
+export CFG_DIR=$PWD
+echo "Set CFG_DIR to $CFG_DIR ..."
+
+if [[ $# -ge 1 ]]; then
+  export BASE_DIR=${1%/}
+  echo "Set BASE_DIR to $BASE_DIR ..."
+else
+   if [[ -z $BASE_DIR ]]; then
+      echo "Error. !!!!!!!BASE_DIR is not set!!!!!!!"
+   else   
+      echo BASE_DIR already defined as $BASE_DIR ...
+   fi
+fi
+
+export BUILD_ROOT=$PROJECT_DIR/build
+echo Set BUILD_ROOT to $BUILD_ROOT ...
+
+export SRC_ROOT=$BASE_DIR
+echo Set SRC_ROOT to $SRC_ROOT ...
+
+export MK=$BASE_DIR/tools_v2/build/make_nr/tools_v2/build/make
+echo Set MK to $MK ...
+
+
+extern_tools_path=$BASE_DIR/extern_tools_v2/bin/linux
+export PATH=$extern_tools_path:$PATH
+export BASE_PATH=$PATH
+
+_pv_make_completion()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="${PV_MAKE_COMPLETION_TARGETS}"
+
+    case "${prev}" in 
+      -f)
+        COMPREPLY=( $(compgen -f ${cur}) )
+        return 0
+        ;;
+    *)
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+        ;;
+    esac
+}
+
+complete -F _pv_make_completion make
+###
+
+echo 
+echo Environment is ready if no errors reported
+echo
+
diff --git a/build_config/default/setup_shell.bat b/build_config/default/setup_shell.bat
new file mode 100755
index 0000000..a6311f4
--- /dev/null
+++ b/build_config/default/setup_shell.bat
@@ -0,0 +1,20 @@
+@echo off
+
+rem *** Set the BASE_DIR ***
+set BASE_DIR=
+for /f "tokens=* delims=\" %%P in ('cd') do (
+	set mypath=%%P
+	)
+set array=%mypath:\= %
+	
+for %%E in (%array%) do (
+	if .%%E==. goto getout
+  if %%E==build_config goto getout
+  call set BASE_DIR=%%BASE_DIR%%\%%E
+)
+
+:getout 
+	set BASE_DIR=%BASE_DIR:~1%
+
+echo Set BASE_DIR to %BASE_DIR% ...
+
diff --git a/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk
new file mode 100644
index 0000000..eca9b66
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_aacdec_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_aac_component_lib \
+ 	libpv_aac_dec
+
+LOCAL_MODULE := libomx_aacdec_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_aac/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/aac/dec/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk
new file mode 100644
index 0000000..329fd6d
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_amrdec_sharedlibrary.mk
@@ -0,0 +1,21 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_amr_component_lib \
+ 	libpvdecoder_gsmamr \
+ 	libpvamrwbdecoder
+
+LOCAL_MODULE := libomx_amrdec_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_amr/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk
new file mode 100644
index 0000000..da7db8e
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_amrenc_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_amrenc_component_lib \
+ 	libpvencoder_gsmamr
+
+LOCAL_MODULE := libomx_amrenc_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common 
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_amrenc/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk
new file mode 100644
index 0000000..7d4d11e
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_avcdec_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_avc_component_lib \
+ 	libpvavcdecoder
+
+LOCAL_MODULE := libomx_avcdec_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_h264/Android.mk
+include   $(PV_TOP)/codecs_v2/video/avc_h264/dec/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk
new file mode 100644
index 0000000..bb68351
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_avcenc_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_avcenc_component_lib \
+ 	libpvavch264enc
+
+LOCAL_MODULE := libomx_avcenc_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common 
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_h264enc/Android.mk
+include   $(PV_TOP)/codecs_v2/video/avc_h264/enc/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk
new file mode 100644
index 0000000..6df5086
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_m4vdec_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_m4v_component_lib \
+ 	libpvmp4decoder
+
+LOCAL_MODULE := libomx_m4vdec_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common 
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_m4v/Android.mk
+include   $(PV_TOP)/codecs_v2/video/m4v_h263/dec/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk
new file mode 100644
index 0000000..bf46bad
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_m4venc_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_m4venc_component_lib \
+ 	libpvm4vencoder
+
+LOCAL_MODULE := libomx_m4venc_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common 
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_m4venc/Android.mk
+include   $(PV_TOP)/codecs_v2/video/m4v_h263/enc/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk
new file mode 100644
index 0000000..b9fe4bc
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_mp3dec_sharedlibrary.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_mp3_component_lib \
+ 	libpvmp3
+
+LOCAL_MODULE := libomx_mp3dec_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libomx_sharedlibrary libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_mp3/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/mp3/dec/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk b/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk
new file mode 100644
index 0000000..574f6f5
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_omx_sharedlibrary.mk
@@ -0,0 +1,25 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libomx_common_lib \
+ 	libomx_queue_lib \
+ 	libpvomx_proxy_lib \
+ 	libomx_baseclass_lib \
+ 	libpv_omx_interface
+
+LOCAL_MODULE := libomx_sharedlibrary
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/codecs_v2/omx/omx_common/Android.mk
+include   $(PV_TOP)/codecs_v2/omx/omx_queue/Android.mk
+include   $(PV_TOP)/codecs_v2/omx/omx_proxy/Android.mk
+include   $(PV_TOP)/codecs_v2/omx/omx_baseclass/Android.mk
+include   $(PV_TOP)/codecs_v2/omx/omx_sharedlibrary/interface/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_2way.mk b/build_config/opencore_dynamic/Android_opencore_2way.mk
new file mode 100644
index 0000000..ccba123
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_2way.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libpv2wayengine \
+ 	libpv324m \
+ 	libpvvideoparsernode \
+ 	libpvcommsionode \
+ 	libpvmio_comm_loopback \
+ 	libpvgeneraltools
+
+LOCAL_MODULE := libopencore_2way
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/engines/2way/Android.mk
+include   $(PV_TOP)/protocols/systems/3g-324m_pvterminal/Android.mk
+include   $(PV_TOP)/nodes/pvvideoparsernode/Android.mk
+include   $(PV_TOP)/nodes/pvcommsionode/Android.mk
+include   $(PV_TOP)/pvmi/media_io/pvmio_comm_loopback/Android.mk
+include   $(PV_TOP)/protocols/systems/common/Android.mk
+include   $(PV_TOP)/protocols/systems/tools/general/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_author.mk b/build_config/opencore_dynamic/Android_opencore_author.mk
new file mode 100644
index 0000000..5e4baef
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_author.mk
@@ -0,0 +1,24 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libpvmp4ffcomposer \
+ 	libpvmp4ffcomposernode \
+ 	libpvauthorengine
+
+LOCAL_WHOLE_STATIC_LIBRARIES +=  libandroidpvauthor
+
+LOCAL_MODULE := libopencore_author
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/fileformats/mp4/composer/Android.mk
+include   $(PV_TOP)/nodes/pvmp4ffcomposernode/Android.mk
+include   $(PV_TOP)/engines/author/Android.mk
+include $(PV_TOP)/android/author/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_common.mk b/build_config/opencore_dynamic/Android_opencore_common.mk
new file mode 100644
index 0000000..ba0a3a1
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_common.mk
@@ -0,0 +1,94 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libosclbase \
+ 	libosclerror \
+ 	libosclmemory \
+ 	libosclutil \
+ 	libosclproc \
+ 	libosclio \
+ 	libosclregserv \
+ 	libosclregcli \
+ 	liboscllib \
+ 	libomx_mastercore_lib \
+ 	libpv_avc_common_lib \
+ 	libpv_amr_nb_common_lib \
+ 	libpvgsmamrparser \
+ 	libgetactualaacconfig \
+ 	libm4v_config \
+ 	libpv_config_parser \
+ 	libcolorconvert \
+ 	libthreadsafe_callback_ao \
+ 	libpvmediadatastruct \
+ 	libpvmimeutils \
+ 	libpvgendatastruct \
+ 	libpvmf \
+ 	libpvfileoutputnode \
+ 	libpvmediainputnode \
+ 	libpvomxencnode \
+ 	libpvmiofileinput \
+ 	libpvmioaviwavfileinput \
+ 	libpvavifileparser \
+ 	libpvthreadmessaging \
+ 	libpvmiofileoutput \
+ 	libpvmediaoutputnode \
+ 	libpvomxvideodecnode \
+ 	libpvomxaudiodecnode \
+ 	libpvomxbasedecnode \
+ 	libpvlatmpayloadparser \
+ 	libpvwav \
+ 	libpvfileparserutils
+
+LOCAL_MODULE := libopencore_common
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/oscl/oscl/osclbase/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclerror/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclmemory/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclutil/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclproc/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclio/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclregserv/Android.mk
+include   $(PV_TOP)/oscl/oscl/osclregcli/Android.mk
+include   $(PV_TOP)/oscl/pvlogger/Android.mk
+include   $(PV_TOP)/oscl/oscl/oscllib/Android.mk
+include   $(PV_TOP)/codecs_v2/omx/omx_mastercore/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/gsm_amr/common/dec/Android.mk
+include   $(PV_TOP)/codecs_v2/video/avc_h264/common/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
+include   $(PV_TOP)/fileformats/rawgsmamr/parser/Android.mk
+include   $(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk
+include   $(PV_TOP)/codecs_v2/utilities/m4v_config_parser/Android.mk
+include   $(PV_TOP)/codecs_v2/utilities/pv_config_parser/Android.mk
+include   $(PV_TOP)/codecs_v2/utilities/colorconvert/Android.mk
+include   $(PV_TOP)/baselibs/threadsafe_callback_ao/Android.mk
+include   $(PV_TOP)/baselibs/media_data_structures/Android.mk
+include   $(PV_TOP)/baselibs/pv_mime_utils/Android.mk
+include   $(PV_TOP)/baselibs/gen_data_structures/Android.mk
+include   $(PV_TOP)/pvmi/pvmf/Android.mk
+include   $(PV_TOP)/nodes/pvfileoutputnode/Android.mk
+include   $(PV_TOP)/nodes/pvmediainputnode/Android.mk
+include   $(PV_TOP)/nodes/pvomxencnode/Android.mk
+include   $(PV_TOP)/pvmi/media_io/pvmi_mio_fileinput/Android.mk
+include   $(PV_TOP)/pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk
+include   $(PV_TOP)/fileformats/avi/parser/Android.mk
+include   $(PV_TOP)/baselibs/thread_messaging/Android.mk
+include   $(PV_TOP)/pvmi/media_io/pvmiofileoutput/Android.mk
+include   $(PV_TOP)/nodes/pvmediaoutputnode/Android.mk
+include   $(PV_TOP)/nodes/pvomxvideodecnode/Android.mk
+include   $(PV_TOP)/nodes/pvomxaudiodecnode/Android.mk
+include   $(PV_TOP)/nodes/pvomxbasedecnode/Android.mk
+include   $(PV_TOP)/protocols/rtp_payload_parser/util/build/Android.mk
+include   $(PV_TOP)/fileformats/wav/parser/Android.mk
+include   $(PV_TOP)/fileformats/common/parser/Android.mk
+include   $(PV_TOP)/nodes/common/Android.mk
+include   $(PV_TOP)/engines/common/Android.mk
+include   $(PV_TOP)/pvmi/content_policy_manager/plugins/common/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_download.mk b/build_config/opencore_dynamic/Android_opencore_download.mk
new file mode 100644
index 0000000..4de9eb8
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_download.mk
@@ -0,0 +1,21 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libprotocolenginenode \
+ 	libpvdownloadmanagernode \
+ 	libpvdownloadinterface
+
+LOCAL_MODULE := libopencore_download
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_net_support libopencore_player libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/nodes/pvprotocolenginenode/Android.mk
+include   $(PV_TOP)/nodes/pvdownloadmanagernode/Android.mk
+include   $(PV_TOP)/modules/linux_download/core/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_downloadreg.mk b/build_config/opencore_dynamic/Android_opencore_downloadreg.mk
new file mode 100644
index 0000000..2ab5090
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_downloadreg.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+ 	libpvdownloadreginterface
+
+LOCAL_MODULE := libopencore_downloadreg
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_player libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/modules/linux_download/node_registry/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_mp4local.mk b/build_config/opencore_dynamic/Android_opencore_mp4local.mk
new file mode 100644
index 0000000..e90759d
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_mp4local.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libpvmp4interface \
+ 	libpvmp4ffparsernode
+
+LOCAL_MODULE := libopencore_mp4local
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_common libopencore_player
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/modules/linux_mp4/core/Android.mk
+include   $(PV_TOP)/nodes/pvmp4ffparsernode/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk b/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk
new file mode 100644
index 0000000..2378bb6
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_mp4localreg.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libpvmp4reginterface \
+ 	libpvmp4ffrecognizer
+
+LOCAL_MODULE := libopencore_mp4localreg
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_player libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/modules/linux_mp4/node_registry/Android.mk
+include   $(PV_TOP)/pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_net_support.mk b/build_config/opencore_dynamic/Android_opencore_net_support.mk
new file mode 100644
index 0000000..a56f8d1
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_net_support.mk
@@ -0,0 +1,19 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libpvsocketnode \
+ 	libpv_http_parcom
+
+LOCAL_MODULE := libopencore_net_support
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/nodes/pvsocketnode/Android.mk
+include   $(PV_TOP)/protocols/http_parcom/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_player.mk b/build_config/opencore_dynamic/Android_opencore_player.mk
new file mode 100644
index 0000000..32d71f4
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_player.mk
@@ -0,0 +1,54 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libcpm \
+ 	libpassthru_oma1 \
+ 	libpvid3parcom \
+ 	libpvamrffparsernode \
+ 	libpvamrffrecognizer \
+ 	libpvmp3ff \
+ 	libpvmp3ffparsernode \
+ 	libpvmp3ffrecognizer \
+ 	libpvmp4ff \
+ 	libmp4recognizer_utility \
+ 	libpvaacparser \
+ 	libpvaacffparsernode \
+ 	libpvaacffrecognizer \
+ 	libpvwavffparsernode \
+ 	libpvwavffrecognizer \
+ 	libpvmfrecognizer \
+ 	libpvframemetadatautility \
+ 	libpvplayer_engine
+
+LOCAL_WHOLE_STATIC_LIBRARIES +=  libandroidpv
+
+LOCAL_MODULE := libopencore_player
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/pvmi/content_policy_manager/Android.mk
+include   $(PV_TOP)/pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk
+include   $(PV_TOP)/fileformats/id3parcom/Android.mk
+include   $(PV_TOP)/nodes/pvamrffparsernode/Android.mk
+include   $(PV_TOP)/pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk
+include   $(PV_TOP)/fileformats/mp3/parser/Android.mk
+include   $(PV_TOP)/nodes/pvmp3ffparsernode/Android.mk
+include   $(PV_TOP)/pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk
+include   $(PV_TOP)/fileformats/mp4/parser/Android.mk
+include   $(PV_TOP)/fileformats/mp4/parser/utils/mp4recognizer/Android.mk
+include   $(PV_TOP)/fileformats/rawaac/parser/Android.mk
+include   $(PV_TOP)/nodes/pvaacffparsernode/Android.mk
+include   $(PV_TOP)/pvmi/recognizer/plugins/pvaacffrecognizer/Android.mk
+include   $(PV_TOP)/nodes/pvwavffparsernode/Android.mk
+include   $(PV_TOP)/pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk
+include   $(PV_TOP)/pvmi/recognizer/Android.mk
+include   $(PV_TOP)/engines/adapters/player/framemetadatautility/Android.mk
+include   $(PV_TOP)/engines/player/Android.mk
+include $(PV_TOP)/android/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_rtsp.mk b/build_config/opencore_dynamic/Android_opencore_rtsp.mk
new file mode 100644
index 0000000..304a07f
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_rtsp.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+	libpvrtspinterface \
+ 	libpvstreamingmanagernode \
+ 	libpv_rtsp_parcom \
+ 	libpvrtsp_cli_eng_node \
+ 	librtppayloadparser \
+ 	librtprtcp \
+ 	libpvjitterbuffernode \
+ 	libpvmedialayernode \
+ 	libpvsdpparser
+
+LOCAL_MODULE := libopencore_rtsp
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_net_support libopencore_player libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/modules/linux_rtsp/core/Android.mk
+include   $(PV_TOP)/nodes/streaming/streamingmanager/Android.mk
+include   $(PV_TOP)/protocols/rtsp_parcom/Android.mk
+include   $(PV_TOP)/protocols/rtsp_client_engine/Android.mk
+include   $(PV_TOP)/protocols/rtp_payload_parser/Android.mk
+include   $(PV_TOP)/protocols/rtp/Android.mk
+include   $(PV_TOP)/nodes/streaming/jitterbuffernode/Android.mk
+include   $(PV_TOP)/nodes/streaming/medialayernode/Android.mk
+include   $(PV_TOP)/protocols/sdp/parser/Android.mk
+include   $(PV_TOP)/protocols/sdp/common/Android.mk
+
diff --git a/build_config/opencore_dynamic/Android_opencore_rtspreg.mk b/build_config/opencore_dynamic/Android_opencore_rtspreg.mk
new file mode 100644
index 0000000..5b20a27
--- /dev/null
+++ b/build_config/opencore_dynamic/Android_opencore_rtspreg.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+ 	libpvrtspreginterface
+
+LOCAL_MODULE := libopencore_rtspreg
+
+-include $(PV_TOP)/Android_platform_extras.mk
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+LOCAL_SHARED_LIBRARIES +=   libopencore_player libopencore_common
+
+include $(BUILD_SHARED_LIBRARY)
+include   $(PV_TOP)/modules/linux_rtsp/node_registry/Android.mk
+
diff --git a/build_config/opencore_dynamic/makefile_nr b/build_config/opencore_dynamic/makefile_nr
new file mode 100644
index 0000000..7530afb
--- /dev/null
+++ b/build_config/opencore_dynamic/makefile_nr
@@ -0,0 +1,14 @@
+
+include $(MK)/entry_point.mk
+
+FORMAT := nj
+
+include $(CFG_DIR)/../common/local.mk
+
+TESTAPPS="pvplayer_engine_test test_pvauthorengine pv2way_omx_engine_test"
+TESTAPP_DIR_pvplayer_engine_test="/engines/player/test/build/linux_nj"
+TESTAPP_DIR_test_pvauthorengine="/engines/author/test/build/linux_nj"
+TESTAPP_DIR_pv2way_omx_engine_test="/engines/2way/test/build/make"
+
+include $(MK)/cml2_shared.mk
+
diff --git a/build_config/opencore_dynamic/prelink-linux-arm.map b/build_config/opencore_dynamic/prelink-linux-arm.map
new file mode 100644
index 0000000..8043a03
--- /dev/null
+++ b/build_config/opencore_dynamic/prelink-linux-arm.map
@@ -0,0 +1,124 @@
+
+# 0xC0000000 - 0xFFFFFFFF Kernel
+# 0xB0100000 - 0xBFFFFFFF Thread 0 Stack
+# 0xB0000000 - 0xB00FFFFF Linker
+# 0xA0000000 - 0xBFFFFFFF Prelinked System Libraries
+# 0x90000000 - 0x9FFFFFFF Prelinked App Libraries
+# 0x80000000 - 0x8FFFFFFF Non-prelinked Libraries
+# 0x40000000 - 0x7FFFFFFF mmap'd stuff
+# 0x10000000 - 0x3FFFFFFF Thread Stacks
+# 0x00000000 - 0x0FFFFFFF .text / .data / heap
+
+# core system libraries
+libdl.so                0xAFF00000
+libc.so                 0xAFE00000
+libstdc++.so            0xAFD00000
+libm.so                 0xAFC00000
+liblog.so               0xAFBC0000
+libcutils.so            0xAFB00000
+libthread_db.so         0xAFA00000
+libz.so                 0xAF900000
+libevent.so             0xAF800000
+libssl.so               0xAF700000
+libcrypto.so            0xAF500000
+
+# extended system libraries
+libbluetooth.so         0xAEC00000
+libdbus.so              0xAE800000
+libril.so               0xAE400000
+libreference-ril.so     0xAE000000
+libwpa_client.so        0xADC00000
+libnetutils.so          0xADB00000
+
+# core dalvik runtime support
+libandroid_servers.so   0xAD900000
+libicudata.so           0xAD600000
+libicuuc.so             0xAD500000
+libicui18n.so           0xAD400000
+libandroid_runtime.so   0xAD300000
+libnativehelper.so      0xAD200000
+libdvm-ARM.so           0xAD100000
+libdvm.so               0xAD000000
+
+# graphics
+libpixelflinger.so      0xACF00000
+libcorecg.so            0xACE00000
+libsurfaceflinger.so    0xACD00000
+libagl.so               0xACC00000
+libGLES_CM.so           0xACB00000
+libexif.so              0xAC500000
+libui.so                0xAC400000
+libsgl.so               0xAC000000
+
+# audio
+libaudio.so             0xAB700000
+libsonivox.so           0xAB600000
+libsoundpool.so         0xAB500000
+libvorbisidec.so        0xAB400000
+libmedia_jni.so         0xAB300000
+libmediaplayerservice.so 0xAB280000
+libmedia.so             0xAB200000
+libFFTEm.so             0xAB100000
+libaudioflinger.so      0xAB000000
+
+# assorted system libraries
+libsqlite.so            0xAAC00000
+libexpat.so             0xAA800000
+libwebcore.so           0xAA000000
+libutils.so             0xA9D00000
+libcameraservice.so     0xA9C80000
+libhardware.so          0xA9C00000
+libapp_process.so       0xA9B00000
+libsystem_server.so     0xA9A00000
+libime.so               0xA9800000
+libgps.so               0xA9700000
+libcamera.so            0xA9680000
+libqcamera.so           0xA9400000
+
+# pv libraries
+libpvasf.so                    0xA7C26000
+libpvasfreg.so                 0xA7C00000
+libomx_sharedlibrary.so        0xA7BA0000
+libopencore_download.so        0xA7B40000
+libopencore_downloadreg.so     0xA7B00000
+libopencore_net_support.so     0xA7A00000
+libopencore_rtsp.so            0xA7900000
+libopencore_rtspreg.so         0xA7840000
+libopencore_author.so          0xA7700000
+libomx_aacdec_sharedlibrary.so 0xA76C0000
+libomx_amrdec_sharedlibrary.so 0xA76A0000
+libomx_amrenc_sharedlibrary.so 0xA7680000
+libomx_avcdec_sharedlibrary.so 0xA7660000
+libomx_avcenc_sharedlibrary.so 0xA7640000
+libomx_m4vdec_sharedlibrary.so 0xA7610000
+libomx_m4venc_sharedlibrary.so 0xA75E0000
+libomx_mp3dec_sharedlibrary.so 0xA75C0000
+libopencore_mp4local.so        0xA7400000
+libopencore_mp4localreg.so     0xA7300000
+libopencore_player.so          0xA7000000
+libopencore_common.so          0xA6000000
+libopencore_2way.so            0xA5A00000
+
+# libraries for specific apps or temporary libraries
+libcam_ipl.so           0x9F000000
+libwbxml.so             0x9E800000
+libwbxml_jni.so         0x9E400000
+libxml2wbxml.so         0x9E000000
+libaes.so               0x9DC00000
+libdrm1.so              0x9D800000
+libdrm1_jni.so          0x9D400000
+libwapcore.so           0x9D000000
+libstreetview.so        0x9CC00000
+libwapbrowsertest.so    0x9C800000
+libminiglobe.so         0x9C400000
+libearth.so             0x9C000000
+libembunit.so           0x9BC00000
+libneon.so              0x9B800000
+libjni_example.so       0x9B400000
+libjni_load_test.so     0x9B000000
+libjni_lib_test.so      0x9AC00000
+librunperf.so           0x9A800000
+libctest.so             0x9A700000
+libUAPI_jni.so          0x9A500000
+librpc.so               0x9A400000 
+libtrace_test.so        0x9A300000 
diff --git a/build_config/opencore_dynamic/pv_config.h b/build_config/opencore_dynamic/pv_config.h
new file mode 100644
index 0000000..f5fca67
--- /dev/null
+++ b/build_config/opencore_dynamic/pv_config.h
@@ -0,0 +1,1462 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+//
+// Automatically generated, don't edit
+//
+// At: Fri, 16 Jan 2009 06:11:38 +0000
+
+//
+// PV Code Base Configuration System
+//
+
+//
+// Menu for selecting supported features
+//
+#define module_support 1
+
+
+//
+// Menu for configuring runtime loadable modules
+//
+#define pv_so 0
+#define pvsplit_so 1
+#define streaming_support 1
+
+//
+// Menu for selecting streaming features
+//
+#define rtsp_support 1
+#define asf_streaming_support 0
+
+#define download_support 1
+#define mp4local_support 1
+#define asflocal_support 0
+#define janus_support 0
+#define wmdrmplat_support 0
+#define wmdrmdev_support 0
+#define mtp_db_support 0
+
+
+//
+// Menu for configuring Baselibs
+//
+#define csprng_lib 0
+#define pvcrypto_lib 0
+#define pventropysrc_lib 0
+#define pvgendatastruct_lib m
+#define pvmediadatastruct_lib m
+#define pvmimeutils_lib m
+#define threadsafe_callback_ao_lib m
+#define pvthreadmessaging_lib m
+
+
+//
+// Menu for configuring File Formats
+//
+#define pvasfff_lib 0
+#define pvmp3ff_lib m
+#define pvmp4ffcomposer_lib 0
+#define pvmp4ffcomposeropencore_lib m
+#define pvmp4ff_lib 0
+#define pvmp4ffopencore_lib m
+#define mp4recognizer_utility_lib m
+#define pvaacparser_lib m
+#define pvgsmamrparser_lib m
+#define pvrmff_lib 0
+#define pvrmffparser_lib 0
+#define pvfileparserutils_lib m
+#define pvid3parcom_lib m
+#define pvpvxparser_lib 0
+#define pvwav_lib m
+#define pvasxparser_lib 0
+#define pvavifileparser_lib m
+#define pvpvrff_lib 0
+#define asfrecognizer_utility_lib 0
+#define pv_divxfile_parser_lib 0
+
+
+//
+// Menu for configuring Codecs
+//
+
+//
+// Menu for configuring OMX Support
+//
+#define omx_mastercore_lib m
+#define MAX_NUMBER_OF_OMX_CORES 10
+#define MAX_NUMBER_OF_OMX_COMPONENTS 50
+#define pv_omx 1
+#define omx_avc_component_lib m
+#define omx_common_lib m
+#define omx_m4v_component_lib m
+#define omx_queue_lib m
+#define omx_wmv_component_lib 0
+#define pvomx_proxy_lib m
+#define omx_aac_component_lib m
+#define omx_amr_component_lib m
+#define omx_mp3_component_lib m
+#define omx_wma_component_lib 0
+#define omx_amrenc_component_lib m
+#define omx_m4venc_component_lib m
+#define omx_avcenc_component_lib m
+#define omx_baseclass_lib m
+
+
+//
+// Menu for configuring audio codecs
+//
+#define pv_aac_dec_lib m
+#define getactualaacconfig_lib m
+#define pv_amr_nb_common_lib m
+#define pvdecoder_gsmamr_lib m
+#define pvencoder_gsmamr_lib m
+#define pvamrwbdecoder_lib m
+#define gsm_amr_headers_lib m
+#define pvmp3_lib m
+#define pvra8decoder_lib 0
+#define wmadecoder_lib 0
+
+
+//
+// Menu for configuring video codecs
+//
+#define pv_avc_common_lib m
+#define pvavcdecoder_lib m
+#define wmvdecoder_lib 0
+#define pvmp4decoder_lib m
+#define rvdecoder_lib 0
+#define pvm4vencoder_lib m
+#define pvavch264enc_lib m
+
+
+//
+// Menu for configuring codecs utilities
+//
+#define m4v_config_lib m
+#define pv_config_parser_lib m
+#define colorconvert_lib m
+
+
+
+//
+// Menu for configuring Nodes
+//
+
+//
+// Menu for configuring Streaming
+//
+#define pvstreamingmanagernode_segments_lib m
+
+//
+// Menu for configuring Streaming Features
+//
+#define mshttp_support 0
+#define rtspunicast_support 1
+#define unicastpvr_support 0
+#define broadcastpvr_support 0
+#define pvrfileplayback_support 0
+
+#define pvstreamingmanagernode_lib 0
+#define pvstreamingmanagernode_3gpp_lib 0
+#define pvmedialayernode_lib m
+#define pvmedialayernode_opencore_lib 0
+#define pvjitterbuffernode_lib m
+#define pvjitterbuffernode_opencore_lib 0
+
+
+//
+// Menu for configuring Download
+//
+#define pvdownloadmanagernode_lib m
+
+//
+// Menu for configuring downloadmanager features
+//
+#define PVMF_DOWNLOADMANAGER_SUPPORT_PVX 0
+#define PVMF_DOWNLOADMANAGER_SUPPORT_PPB 1
+#define PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE 0
+#define PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB 13
+#define ENABLE_LARGE_MBDS_CACHE_SIZE 0
+
+
+
+//
+// Menu for configuring ProtocolEngine
+//
+#define pvprotocolenginenode_segments_lib m
+#define pvprotocolenginenode_lib 0
+
+//
+// Menu for configuring ProtocolEngine Features
+//
+#define ps_support 1
+#define pdl_support 1
+#define ftdl_support 0
+#define http_support 0
+
+
+#define pvfileoutputnode_lib m
+#define pvmediaoutputnode_lib m
+#define pvsocketnode_lib m
+#define pvavcdecnode_lib 0
+#define pvvideodecnode_lib 0
+#define pvwavffparsernode_lib m
+#define pvwmadecnode_lib 0
+#define pvwmvdecnode_lib 0
+#define pvomxencnode_lib m
+#define pvomxaudiodecnode_lib m
+#define pvomxbasedecnode_lib m
+#define pvomxvideodecnode_lib m
+#define aacdecnode_lib 0
+#define pvaacffparsernode_lib m
+#define gsmamrdecnode_lib 0
+#define pvamrffparsernode_lib m
+#define pvasfffparsernode_lib 0
+#define mp3decnode_lib 0
+#define pvmp3ffparsernode_lib m
+#define pvmp4ffparsernode_lib 0
+#define pvmp4ffparsernodeopencore_lib m
+#define pvrvdecnode_lib 0
+#define pvra8decnode_lib 0
+#define pvrmffparsernode_lib 0
+#define pvrtppacketsourcenode_lib 0
+#define nodes_common_headers_lib m
+#define pvamrencnode_lib 0
+#define pvmediainputnode_lib m
+#define pvmp4ffcomposernode_lib 0
+#define pvmp4ffcomposernodeopencore_lib m
+#define pvvideoencnode_lib 0
+#define pvavcencnode_lib 0
+#define pvpvr_lib 0
+#define pvpvrnode_lib 0
+#define pvcommsionode_lib m
+#define pvclientserversocketnode_lib m
+#define pvloopbacknode_lib m
+#define pvvideoparsernode_lib m
+#define pvdummyinputnode_lib m
+#define pvdummyoutputnode_lib m
+#define pvdivxffparsernode_lib 0
+
+
+//
+// Menu for configuring Oscl
+//
+#define build_oscl m
+#define unit_test_lib 1
+
+
+//
+// Menu for configuring Protocols
+//
+
+//
+// Menu for configuring Value Adds for 2way
+//
+#define twoway_value_add_config 1
+#define PV_2WAY_VALUE_ADD_NONE 1
+
+#define pv_http_parcom_lib m
+#define pvlatmpayloadparser_lib m
+#define sdp_common m
+
+//
+// Menu for configuring SDPParser
+//
+#define sdp_default 0
+#define sdp_opencore m
+
+#define rdt_parser_lib 0
+#define pv_rtsp_parcom_lib m
+#define pvrtsp_cli_eng_node_lib 0
+#define pvrtsp_cli_eng_node_3gpp_lib 0
+#define pvrtsp_cli_eng_node_opencore_lib m
+#define rtppayloadparser_lib m
+
+//
+// Menu for rtppayload parser plugins
+//
+#define rfc_2429 1
+#define rfc_3016 1
+#define rfc_3267 1
+#define rfc_3640 1
+#define rfc_3984 1
+#define asf_payload 0
+#define realmedia_payload 0
+
+#define rtprtcp_lib m
+#define pv324m_lib m
+#define pv324m_common_headers_lib m
+#define pvgeneraltools_lib m
+
+
+//
+// Menu for configuring Pvmi
+//
+
+//
+// Menu for configuring Recognizers
+//
+#define pvmfrecognizer_lib m
+#define pvaacffrecognizer_lib m
+#define pvamrffrecognizer_lib m
+#define pvoma1ffrecognizer_lib 0
+#define pvasfffrecognizer_lib 0
+#define pvmp3ffrecognizer_lib m
+#define pvmp4ffrecognizer_lib m
+#define pvwavffrecognizer_lib m
+#define pvrmffrecognizer_lib 0
+#define pvdivxffrecognizer_lib 0
+
+
+//
+// Menu for configuring Content Policy Manager
+//
+#define cpm_lib m
+#define passthru_oma1_lib m
+#define pvjanusplugin_lib 0
+#define cpm_headers_lib m
+#define pvoma1lockstream_lib 0
+
+
+//
+// Menu for configuring Media IO
+//
+#define pvmiofileinput_lib m
+#define pvmiofileoutput_lib m
+#define pvmioaviwavfileinput_lib m
+#define pvmio_comm_loopback_lib m
+
+
+//
+// Menu for configuring PacketSources
+//
+#define packetsources_default_lib 0
+
+//
+// Menu for configuring PacketSource Plugins
+//
+#define optimized_bcast_ps_support 0
+#define standard_bcast_ps_support 0
+
+
+#define pvmf_lib m
+#define realaudio_deinterleaver_lib 0
+#define pvdbmanager_lib 0
+
+
+//
+// Menu for configuring Engines
+//
+
+//
+// Menu for configuring Player
+//
+#define pvplayer_engine_lib m
+
+//
+// Menu for player engine tunables
+//
+#define PVPLAYERENGINE_CONFIG_SKIPTOREQUESTEDPOS_DEF 1
+#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_EARLY_DEF -200
+#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_LATE_DEF 200
+#define VIDEO_DEC_NODE_LOW_PRIORITY 1
+
+
+//
+// Menu for configuring player registry
+//
+#define BUILD_OMX_VIDEO_DEC_NODE 1
+#define BUILD_OMX_AUDIO_DEC_NODE 1
+#define BUILD_VIDEO_DEC_NODE 0
+#define BUILD_AVC_DEC_NODE 0
+#define BUILD_WMV_DEC_NODE 0
+#define BUILD_RV_DEC_NODE 0
+#define BUILD_WMA_DEC_NODE 0
+#define BUILD_G726_DEC_NODE 0
+#define BUILD_GSMAMR_DEC_NODE 0
+#define BUILD_AAC_DEC_NODE 0
+#define BUILD_MP3_DEC_NODE 0
+#define BUILD_RA8_DEC_NODE 0
+#define BUILD_MP4_FF_PARSER_NODE 0
+#define BUILD_AMR_FF_PARSER_NODE 1
+#define BUILD_AAC_FF_PARSER_NODE 1
+#define BUILD_MP3_FF_PARSER_NODE 1
+#define BUILD_WAV_FF_PARSER_NODE 1
+#define BUILD_ASF_FF_PARSER_NODE 0
+#define BUILD_RM_FF_PARSER_NODE 0
+#define BUILD_STREAMING_MANAGER_NODE 0
+#define BUILD_DOWNLOAD_MANAGER_NODE 0
+#define BUILD_STILL_IMAGE_NODE 0
+#define BUILD_MP4_FF_REC 0
+#define BUILD_ASF_FF_REC 0
+#define BUILD_OMA1_FF_REC 0
+#define BUILD_AAC_FF_REC 1
+#define BUILD_RM_FF_REC 0
+#define BUILD_MP3_FF_REC 1
+#define BUILD_WAV_FF_REC 1
+#define BUILD_AMR_FF_REC 1
+
+
+
+//
+// Menu for configuring Author
+//
+#define pvauthorengine_lib m
+
+
+//
+// Menu for configuring pv2way
+//
+#define pv2wayengine_lib m
+
+#define engines_common_headers_lib m
+#define pvframemetadatautility_lib m
+
+
+//
+// Menu for configuring Extern_libs
+//
+#define pvmtp_engine_lib 0
+#define pvsqlite_lib 0
+#define pvwmdrm_lib 0
+#define wmdrm_config 0
+
+
+//
+// Derived symbols
+//
+#define pvmediaoutputnode_y_mk ""
+#define LIBS_omxenc_shared "-lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib"
+#define pvavcencnode_y_lib ""
+#define pventropysrc_y_lib ""
+#define pvjitterbuffernode_y_mk ""
+#define pvvideoencnode_y_mk ""
+#define pvamrwbdecoder_imp_m_mk ""
+#define protocolenginenode_segments_m_lib "-lprotocolenginenode"
+#define aacdecnode_m_mk ""
+#define pvclientserversocketnode_y_lib ""
+#define pvencoder_gsmamr_y_lib ""
+#define pvstreamingmanagernode_m_lib ""
+#define pvmedialayernode_m_mk "/nodes/streaming/medialayernode/build/make"
+#define pvpvr_y_mk ""
+#define pvmp4ffcomposernode_m_lib ""
+#define pvwmdrmplatinterface_m_lib ""
+#define omx_amrenc_component_m_mk "/codecs_v2/omx/omx_amrenc/build/make_multithreaded"
+#define sdp_common_m_mk "/protocols/sdp/common/build/make"
+#define sdp_parser_mksegment_opencore "sdp_opencore.mk"
+#define pvloopbacknode_y_mk ""
+#define pvrtspreginterface_m_mk "/modules/linux_rtsp/node_registry/build/make"
+#define LIBDIR_oscl_static " /oscl/unit_test/build/make"
+#define SOLIBDIRS_omx_m4venc_sharedlibrary "/codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/video/m4v_h263/enc/build/make"
+#define pvrmff_m_lib ""
+#define pvjitterbuffernode_plugins_pvasfstreaming "jb_asf.mk"
+#define omx_wmv_component_y_lib ""
+#define pvwmdrm_m_mk ""
+#define omx_amrenc_component_m_lib "-lomx_amrenc_component_lib"
+#define pvdummyinputnode_y_mk ""
+#define pvfileparserutils_y_mk ""
+#define pvrmffparser_m_lib ""
+#define pvm4vencoder_m_mk "/codecs_v2/video/m4v_h263/enc/build/make"
+#define LIBDIR_omxdecimp_shared ""
+#define pv_aac_dec_y_mk ""
+#define DYNAMIC_LOAD_OMX_WMV_COMPONENT 0
+#define SOLIBS_omx_avcdec_sharedlibrary "-lomx_avc_component_lib -lpvavcdecoder"
+#define MODS_omx_aacdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common"
+#define rvdecoder_m_lib ""
+#define pvmimeutils_y_lib ""
+#define pvavch264enc_m_lib "-lpvavch264enc"
+#define pvmf_m_mk "/pvmi/pvmf/build/make"
+#define pv2wayengine_m_lib "-lpv2wayengine"
+#define pvrtspreginterface_m_lib "-lpvrtspreginterface"
+#define pvomxaudiodecnode_y_mk ""
+#define DYNAMIC_LOAD_OMX_AAC_COMPONENT 1
+#define SOLIBS_omx_wmvdec_sharedlibrary " "
+#define pvamrffrecognizer_m_lib "-lpvamrffrecognizer"
+#define pvgsmamrparser_m_lib "-lpvgsmamrparser"
+#define LIBS_codecs_v2_static "                                   "
+#define omx_wmv_component_m_mk ""
+#define DYNAMIC_LOAD_OMX_AMR_COMPONENT 1
+#define pvmp4ffcomposernode_m_mk ""
+#define pv_divxfile_parser_m_lib ""
+#define omx_mp3_component_m_lib "-lomx_mp3_component_lib"
+#define pvaacparser_m_lib "-lpvaacparser"
+#define mp4recognizer_utility_m_lib "-lmp4recognizer_utility"
+#define SOLIBDIRS_pvjanus " "
+#define USING_OMX 1
+#define pvmediainputnode_m_lib "-lpvmediainputnode"
+#define protocolenginenode_segments_m_mk "/nodes/pvprotocolenginenode/build/make_segments"
+#define asfrecognizer_utility_m_lib ""
+#define pvmp4ff_m_mk ""
+#define pvdecoder_gsmamr_y_mk ""
+#define pvavifileparser_m_lib "-lpvavifileparser"
+#define LIBS_omxencimp_static ""
+#define LIBS_codecs_v2_shared "-lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib  -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface   -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3  -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder  -lpvmp4decoder  -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert"
+#define omx_avcenc_component_m_lib "-lomx_avcenc_component_lib"
+#define pvavifileparser_y_mk ""
+#define MODS_opencore_2way "-lopencore_common"
+#define omx_m4v_component_y_lib ""
+#define omx_baseclass_y_lib ""
+#define LIBS_packetsources_static "n"
+#define pvdecoder_gsmamr_imp_m_lib ""
+#define LIBDIR_fileformats_shared "/fileformats/common/parser/build/make /fileformats/id3parcom/build/make  /fileformats/wav/parser/build/make  /fileformats/avi/parser/build/make  /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make    /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make  /fileformats/mp4/composer/build_opencore/make   "
+#define pvdummyoutputnode_m_mk "/nodes/pvdummyoutputnode/build/make"
+#define pvasfff_m_lib ""
+#define pvrmff_m_mk ""
+#define csprng_m_lib ""
+#define pv_avc_common_lib_y_mk ""
+#define pvavcdecoder_m_mk "/codecs_v2/video/avc_h264/dec/build/make"
+#define SOLIBDIRS_pvasfstreaming " /nodes/streaming/streamingmanager/build/make_segments /nodes/streaming/jitterbuffernode/build/make /nodes/streaming/medialayernode/build/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /nodes/pvprotocolenginenode/build/make_segments"
+#define LIBDIR_extern_libs_shared "    "
+#define protocolenginenode_y_mk ""
+#define omx_mastercore_m_mk "/codecs_v2/omx/omx_mastercore/build/make_multithreaded"
+#define m4v_config_m_mk "/codecs_v2/utilities/m4v_config_parser/build/make"
+#define pvcrypto_y_lib ""
+#define LIBDIR_packetsources_shared "n"
+#define pvfileparserutils_y_lib ""
+#define pvasfcommon_so_name ""
+#define LIBDIR_omxjoint_static "   "
+#define LIBDIR_video_static "      "
+#define wmadecoder_m_lib ""
+#define pv_amr_nb_common_lib_y_lib ""
+#define pventropysrc_m_mk ""
+#define asfrecognizer_utility_y_mk ""
+#define pv_amr_nb_common_lib_m_lib "-lpv_amr_nb_common_lib"
+#define pv_aac_dec_plugins "aacdec_util.mk"
+#define wmvdecoder_y_mk ""
+#define pvmp3ffrecognizer_y_mk ""
+#define REGISTER_OMX_H263ENC_COMPONENT 1
+#define LIBDIR_codecs_v2_shared "/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded  /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make   /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make  /codecs_v2/video/m4v_h263/dec/build/make  /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make"
+#define omx_amrenc_component_imp_m_mk ""
+#define omx_avc_component_m_mk "/codecs_v2/omx/omx_h264/build/make_multithreaded"
+#define pvdecoder_gsmamr_m_lib "-lpvdecoder_gsmamr"
+#define pvmf_y_mk ""
+#define omx_mastercore_m_lib "-lomx_mastercore_lib"
+#define getactualaacconfig_imp_m_lib "-lgetactualaacconfig"
+#define pvfileoutputnode_y_mk ""
+#define LIBDIR_recognizer_static "         "
+#define SOLIBS_pvwmdrmdev "n"
+#define realaudio_deinterleaver_y_lib ""
+#define cpm_m_lib "-lcpm"
+#define pvmp4ffcomposeropencore_m_lib "-lpvmp4ffcomposer"
+#define LIBDIR_engines_shared "/engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make"
+#define omx_amr_component_imp_m_lib ""
+#define pvdummyoutputnode_m_lib "-lpvdummyoutputnode"
+#define pvmp4ffcomposeropencore_m_mk "/fileformats/mp4/composer/build_opencore/make"
+#define SOLIBS_opencore_author " -lpvmp4ffcomposer  -lpvmp4ffcomposernode -lpvauthorengine"
+#define pvmp3ff_y_lib ""
+#define pv324m_plugins "default_support.mk"
+#define MODS_omx_wmadec_sharedlibrary "-lomx_sharedlibrary -lopencore_common"
+#define omx_m4vdec_sharedlibrary_so_name "omx_m4vdec_sharedlibrary"
+#define pvrtppacketsourcenode_y_mk ""
+#define pvmiofileinput_y_lib ""
+#define pvavcdecoder_m_lib "-lpvavcdecoder"
+#define LIBS_fileformats_static "                  "
+#define SOLIBDIRS_opencore_mp4localreg "/modules/linux_mp4/node_registry/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make"
+#define pvamrffrecognizer_y_mk ""
+#define REGISTER_OMX_WMV_COMPONENT 0
+#define omx_m4v_component_m_lib "-lomx_m4v_component_lib"
+#define pvmp3ffparsernode_y_mk ""
+#define pventropysrc_m_lib ""
+#define pvsdpparser_y_lib ""
+#define SOLIBDIRS_opencore_author " /fileformats/mp4/composer/build_opencore/make  /nodes/pvmp4ffcomposernode/build_opencore/make /engines/author/build/make"
+#define packetsources_default_y_lib ""
+#define LIBDIR_baselibs_shared "   /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make"
+#define pvomx_proxy_m_mk "/codecs_v2/omx/omx_proxy/build/make"
+#define LIBS_recognizer_shared "-lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer   -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer  "
+#define pvasf_streaming_so_name ""
+#define pvsocketnode_m_mk "/nodes/pvsocketnode/build/make"
+#define pvstreamingmanagernode_3gpp_m_mk ""
+#define pv2wayengine_y_lib ""
+#define pvwmadecnode_y_mk ""
+#define pvaacffrecognizer_y_lib ""
+#define pvpvrff_m_mk ""
+#define pvomxvideodecnode_y_lib ""
+#define LIBS_omxencimp_shared ""
+#define pvdownloadmanagernode_m_lib "-lpvdownloadmanagernode"
+#define pvdivxffrecognizer_m_lib ""
+#define pvmp4ffrecognizer_m_lib "-lpvmp4ffrecognizer"
+#define opencore_player_so_name "opencore_player"
+#define pvvideoparsernode_y_mk ""
+#define pvmp4ffcomposer_m_lib ""
+#define dl_common_mk "pe_dl_common.mk"
+#define pvjitterbuffernode_opencore_m_mk ""
+#define pvmp4ffcomposer_y_lib ""
+#define threadsafe_callback_ao_m_lib "-lthreadsafe_callback_ao"
+#define pvmp4ffopencore_m_lib "-lpvmp4ff"
+#define pvencoder_gsmamr_m_mk "/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make"
+#define sdp_common_y_mk ""
+#define pvdecoder_gsmamr_m_mk "/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make"
+#define MODS_pvwmdrmdev "-lopencore_player -lopencore_common"
+#define pvmio_comm_loopback_m_lib "-lpvmio_comm_loopback"
+#define pvrtppacketsourcenode_y_lib ""
+#define pvasfstreaminginterface_m_mk ""
+#define pvwmdrmdev_so_name ""
+#define rvdecoder_y_mk ""
+#define pvavifileparser_m_mk "/fileformats/avi/parser/build/make"
+#define pvjitterbuffernode_opencore_y_mk ""
+#define gsm_amr_headers_m_mk "/codecs_v2/audio/gsm_amr/common/dec/build/make"
+#define pvaacparser_y_mk ""
+#define pvaacffparsernode_m_mk "/nodes/pvaacffparsernode/build/make"
+#define LIBS_extern_libs_shared "    "
+#define LIBDIR_media_io_static "   "
+#define getactualaacconfig_m_mk "/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make"
+#define colorconvert_y_mk ""
+#define pvgendatastruct_y_lib ""
+#define LIBDIR_pvmi_shared "/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make   /pvmi/content_policy_manager/plugins/common/build/make  /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make   /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make    /pvmi/pvmf/build/make  "
+#define pvoma1ffrecognizer_m_mk ""
+#define csprng_y_mk ""
+#define pvdivxffparsernode_y_lib ""
+#define pvauthorengine_y_lib ""
+#define pvrtspinterface_m_lib "-lpvrtspinterface"
+#define pvmp3ff_y_mk ""
+#define pv_aac_dec_imp_m_lib ""
+#define rfc_3016_mk "rfc_3016.mk"
+#define pvwmdrm_so_name ""
+#define pvavcencnode_m_mk ""
+#define pvasflocalpbinterface_m_mk ""
+#define pvasxparser_y_lib ""
+#define pvdivxffparsernode_m_mk ""
+#define pvmp4decoder_m_mk "/codecs_v2/video/m4v_h263/dec/build/make"
+#define rdt_parser_y_lib ""
+#define pvvideodecnode_m_mk ""
+#define pvmimeutils_y_mk ""
+#define omx_m4venc_component_imp_m_mk ""
+#define pvwavffrecognizer_m_lib "-lpvwavffrecognizer"
+#define omx_amrenc_sharedlibrary_so_name "omx_amrenc_sharedlibrary"
+#define pvrtsp_cli_eng_node_y_lib ""
+#define gsmamrdecnode_m_lib ""
+#define pvencoder_gsmamr_imp_m_lib ""
+#define pvmp4ff_y_lib ""
+#define pvamrffparsernode_y_mk ""
+#define SOLIBDIRS_omx_wmadec_sharedlibrary " "
+#define wmadecoder_y_mk ""
+#define SOLIBS_pvjanus " "
+#define pvmf_m_lib "-lpvmf"
+#define LIBDIR_protocols_static "             "
+#define ps_support_mk "pe_ps.mk"
+#define pvavcdecnode_m_mk ""
+#define pvra8decnode_m_lib ""
+#define LIBDIR_codecs_utilities_shared "/codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make"
+#define LIBS_omxenc_static "  "
+#define broadcastpvr_support_mk ""
+#define pvstreamingmanagernode_y_mk ""
+#define pvmp4ffopencore_y_lib ""
+#define protocolenginenode_m_lib ""
+#define SOLIBS_opencore_mp4localreg "-lpvmp4reginterface -lpvmp4ffrecognizer"
+#define omx_m4venc_component_y_lib ""
+#define pvomxvideodecnode_m_lib "-lpvomxvideodecnode"
+#define omx_wma_component_m_lib ""
+#define pvpvrnode_m_lib ""
+#define pv_avc_common_lib_m_lib "-lpv_avc_common_lib"
+#define pvpvrff_m_lib ""
+#define pvframemetadatautility_y_lib ""
+#define pvmio_comm_loopback_m_mk "/pvmi/media_io/pvmio_comm_loopback/build/make"
+#define LIBS_baselibs_shared "   -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging"
+#define omx_avcenc_component_imp_m_mk ""
+#define omx_amr_component_m_mk "/codecs_v2/omx/omx_amr/build/make_multithreaded"
+#define pvwmdrmplat_so_name ""
+#define pv_omx_interface_m_mk "/codecs_v2/omx/omx_sharedlibrary/interface/build/make"
+#define pvdummyinputnode_m_mk "/nodes/pvdummyinputnode/build/make"
+#define pvasxparser_m_mk ""
+#define omx_avc_component_imp_m_lib ""
+#define pvavch264enc_y_lib ""
+#define pvmp3ff_m_lib "-lpvmp3ff"
+#define oscl_m_mk "/oscl"
+#define pvrvdecnode_y_lib ""
+#define pvclientserversocketnode_m_mk "/nodes/pvclientserversocketnode/build/make"
+#define PROTOCOL_PLUGINS "pe_dl_common.mk pe_ps.mk pe_pdl.mk  "
+#define LIBDIR_nodes_shared "/nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make  /nodes/pvprotocolenginenode/build/make_segments   /nodes/pvwavffparsernode/build/make   /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make  /nodes/pvaacffparsernode/build/make  /nodes/pvamrffparsernode/build/make   /nodes/pvmp3ffparsernode/build/make  /nodes/pvmp4ffparsernode/build_opencore/make     /nodes/common/build/make  /nodes/pvmediainputnode/build/make_pvauthor  /nodes/pvmp4ffcomposernode/build_opencore/make     /nodes/pvdownloadmanagernode/build/make   /nodes/streaming/streamingmanager/build/make_segments   /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /nodes/streaming/medialayernode/build/make  /nodes/streaming/jitterbuffernode/build/make  /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvvideoparsernode/build/make /nodes/pvdummyinputnode/build/make /nodes/pvdummyoutputnode/build/make "
+#define pvavcdecoder_imp_m_mk ""
+#define pvwmdrmdevinterface_m_lib ""
+#define pvdownloadinterface_m_lib "-lpvdownloadinterface"
+#define pvasfff_y_mk ""
+#define pvstreamingmanagernode_segments_y_lib ""
+#define pv_divxfile_parser_y_mk ""
+#define omx_amr_component_imp_m_mk ""
+#define csprng_y_lib ""
+#define getactualaacconfig_for_static_m_lib ""
+#define SOLIBS_omx_aacdec_sharedlibrary "-lomx_aac_component_lib -lpv_aac_dec"
+#define omx_queue_m_lib "-lomx_queue_lib"
+#define nodes_common_headers_y_mk ""
+#define pvaacparser_y_lib ""
+#define SOLIBDIRS_omx_sharedlibrary "/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_sharedlibrary/interface/build/make"
+#define omx_avcenc_component_m_mk "/codecs_v2/omx/omx_h264enc/build/make_multithreaded"
+#define wmvdecoder_y_lib ""
+#define pvamrffparsernode_y_lib ""
+#define cml2_support_flag "USE_CML2_CONFIG"
+#define MODS_opencore_rtsp "-lopencore_net_support -lopencore_player -lopencore_common"
+#define pvclientserversocketnode_m_lib "-lpvclientserversocketnode"
+#define pvsqlite_m_mk ""
+#define REGISTER_OMX_AMR_COMPONENT 1
+#define DYNAMIC_LOAD_OMX_MP3_COMPONENT 1
+#define omx_aac_component_y_lib ""
+#define pvavcdecoder_y_mk ""
+#define getactualaacconfig_y_lib ""
+#define pvrtsp_cli_eng_node_opencore_y_mk ""
+#define SOLIBDIRS_pvwmdrm "   "
+#define pvoma1lockstream_y_mk ""
+#define omx_amrenc_component_y_mk ""
+#define LIBS_omxjoint_static "   "
+#define pvauthorengine_m_lib "-lpvauthorengine"
+#define standard_bcast_ps_mk ""
+#define pvmediaoutputnode_y_lib ""
+#define pv2wayengine_y_mk ""
+#define pvmio_comm_loopback_y_mk ""
+#define pvmediaoutputnode_m_lib "-lpvmediaoutputnode"
+#define SOLIBS_pvasfstreamingreg "n"
+#define pvomxaudiodecnode_m_lib "-lpvomxaudiodecnode"
+#define pvid3parcom_y_lib ""
+#define pvwavffparsernode_y_lib ""
+#define pvrtsp_cli_eng_node_opencore_y_lib ""
+#define pvra8decoder_m_lib ""
+#define pvcommsionode_m_lib "-lpvcommsionode"
+#define DYNAMIC_LOAD_OMX_M4VENC_COMPONENT 1
+#define pv324m_y_mk ""
+#define LIBDIR_omxencimp_static ""
+#define pvrmffparser_y_mk ""
+#define pvmp4ffparsernode_y_mk ""
+#define pvmp4ffrecognizer_y_mk ""
+#define pvstreamingmanagernode_3gpp_y_mk ""
+#define pvlatmpayloadparser_y_mk ""
+#define protocolenginenode_segments_y_lib ""
+#define MODS_omx_m4venc_sharedlibrary "-lomx_sharedlibrary -lopencore_common "
+#define LIBDIR_omxdec_static "      "
+#define pvthreadmessaging_m_lib "-lpvthreadmessaging"
+#define pvmp4ff_y_mk ""
+#define pvpvr_m_mk ""
+#define MODS_omx_wmvdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common"
+#define omx_m4v_component_m_mk "/codecs_v2/omx/omx_m4v/build/make_multithreaded"
+#define pvmediaoutputnode_m_mk "/nodes/pvmediaoutputnode/build/make"
+#define pvvideoparsernode_m_mk "/nodes/pvvideoparsernode/build/make"
+#define LIBDIR_omxencimp_shared ""
+#define pvwmdrmplatinterface_m_mk ""
+#define config_asf_mk ""
+#define pvvideodecnode_y_lib ""
+#define pvmp4ffparsernodeopencore_y_lib ""
+#define SOLIBS_omx_m4venc_sharedlibrary "-lomx_m4venc_component_lib -lpvm4vencoder"
+#define passthru_oma1_m_mk "/pvmi/content_policy_manager/plugins/oma1/passthru/build/make"
+#define packetsources_default_plugins " "
+#define mp3decnode_y_mk ""
+#define omx_queue_y_lib ""
+#define pvmp3_imp_m_mk ""
+#define cpm_headers_y_mk ""
+#define pvdownloadinterface_m_mk "/modules/linux_download/core/build/make"
+#define pvwavffrecognizer_m_mk "/pvmi/recognizer/plugins/pvwavffrecognizer/build/make"
+#define pv_aac_dec_imp_m_mk ""
+#define pvthreadmessaging_y_mk ""
+#define pvasfff_y_lib ""
+#define pvdownloadreginterface_m_lib "-lpvdownloadreginterface"
+#define pvjanus_so_name ""
+#define pvpvr_m_lib ""
+#define omx_m4v_component_imp_m_mk ""
+#define rtspunicast_support_mk "rtspunicast.mk"
+#define mp3decnode_y_lib ""
+#define pvmfrecognizer_m_mk "/pvmi/recognizer/build/make"
+#define LIBDIR_media_io_shared "/pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /pvmi/media_io/pvmio_comm_loopback/build/make"
+#define unicastpvr_support_mk ""
+#define pvamrffparsernode_m_mk "/nodes/pvamrffparsernode/build/make"
+#define pvmp3ffrecognizer_m_lib "-lpvmp3ffrecognizer"
+#define LIBS_omxdecimp_shared ""
+#define pvasfffparsernode_y_mk ""
+#define http_support_mk ""
+#define REGISTER_OMX_AVCENC_COMPONENT 1
+#define pv_avc_common_lib_m_mk "/codecs_v2/video/avc_h264/common/build/make"
+#define pvdummyoutputnode_y_mk ""
+#define MODS_opencore_download "-lopencore_net_support -lopencore_player -lopencore_common"
+#define pvasxparser_y_mk ""
+#define pvstreamingmanagernode_segments_m_lib "-lpvstreamingmanagernode"
+#define pvdecoder_gsmamr_imp_m_mk ""
+#define pvomxbasedecnode_y_lib ""
+#define pvmiofileinput_m_mk "/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor"
+#define pvwavffparsernode_m_mk "/nodes/pvwavffparsernode/build/make"
+#define pvmedialayernode_opencore_y_lib ""
+#define LIBS_audio_static "        "
+#define colorconvert_m_mk "/codecs_v2/utilities/colorconvert/build/make"
+#define LIBDIR_omxdec_shared "/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded "
+#define opencore_rtsp_so_name "opencore_rtsp"
+#define pvwmadecnode_m_mk ""
+#define pvmp4ffcomposer_y_mk ""
+#define pvmedialayernode_m_lib "-lpvmedialayernode"
+#define pvomxencnode_m_lib "-lpvomxencnode"
+#define pvclientserversocketnode_y_mk ""
+#define pvdownloadmanagernode_y_lib ""
+#define pvmp3ffparsernode_m_mk "/nodes/pvmp3ffparsernode/build/make"
+#define pvdivxffrecognizer_y_lib ""
+#define LIBDIR_codecs_utilities_static "  "
+#define omx_amr_component_m_lib "-lomx_amr_component_lib"
+#define pvstreamingmanagernode_y_lib ""
+#define pvsdpparser_m_mk "/protocols/sdp/parser/build/make"
+#define unit_test_m_lib ""
+#define pvmedialayernode_opencore_y_mk ""
+#define pvsqlite_y_mk ""
+#define omx_queue_y_mk ""
+#define pvauthorengine_m_mk "/engines/author/build/make"
+#define pvgeneraltools_y_lib ""
+#define pvmp4interface_m_lib "-lpvmp4interface"
+#define MODS_pvasfstreaming "-lopencore_net_support -lopencore_player -lopencore_common -lpvasfcommon"
+#define pvomxvideodecnode_y_mk ""
+#define pv_avc_common_imp_lib_m_lib ""
+#define pvdivxffrecognizer_y_mk ""
+#define pvdbmanager_m_mk ""
+#define pvrtsp_cli_eng_node_3gpp_y_lib ""
+#define pvmediadatastruct_y_mk ""
+#define pvstreamingmanagernode_segments_y_mk ""
+#define MODS_pv ""
+#define pvdownloadmanagernode_y_mk ""
+#define pvplayer_engine_y_lib ""
+#define USE_LOADABLE_MODULES 1
+#define pvrmffrecognizer_y_mk ""
+#define SOLIBS_pvwmdrm "   "
+#define omx_sharedlibrary_so_name "omx_sharedlibrary"
+#define SOLIBDIRS_opencore_rtsp "/modules/linux_rtsp/core/build/make /nodes/streaming/streamingmanager/build/make_segments /protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build_opencore/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /nodes/streaming/jitterbuffernode/build/make /nodes/streaming/medialayernode/build/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make"
+#define omx_avc_component_imp_m_mk ""
+#define omx_avcenc_component_y_lib ""
+#define rtprtcp_y_mk ""
+#define MODS_pvasfcommon "-lopencore_player -lopencore_common"
+#define pvrtsp_cli_eng_node_m_lib ""
+#define SOLIBDIRS_omx_wmvdec_sharedlibrary " "
+#define pvpvxparser_m_mk ""
+#define pvvideoparsernode_m_lib "-lpvvideoparsernode"
+#define LIBDIR_module "/modules"
+#define pventropysrc_y_mk ""
+#define pvrmffparser_m_mk ""
+#define pv_omx_interface_m_lib "-lpv_omx_interface"
+#define SOLIBS_pvwmdrmplat "n"
+#define pvmp4ffparsernode_y_lib ""
+#define pvrmff_y_mk ""
+#define pvmp4ffcomposernode_y_mk ""
+#define pvm4vencoder_y_lib ""
+#define pvomx_proxy_y_mk ""
+#define pvgeneraltools_y_mk ""
+#define pvrmffrecognizer_m_lib ""
+#define pvsocketnode_y_mk ""
+#define pvmediainputnode_m_mk "/nodes/pvmediainputnode/build/make_pvauthor"
+#define pvrtsp_cli_eng_node_opencore_m_lib "-lpvrtsp_cli_eng_node"
+#define mp4recognizer_utility_m_mk "/fileformats/mp4/parser/utils/mp4recognizer/build/make"
+#define SOLIBDIRS_pv "/oscl   /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/enc/build/make  /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make  /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/colorconvert/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded  /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/media_io/pvmiofileoutput/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make  /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make  /fileformats/mp4/composer/build_opencore/make  /nodes/pvmp4ffcomposernode/build_opencore/make      /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmediaoutputnode/build/make /nodes/pvfileoutputnode/build/make /fileformats/rawgsmamr/parser/build/make /nodes/pvamrffparsernode/build/make  /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make  /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /fileformats/mp3/parser/build/make  /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make    /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make        /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make     /pvmi/recognizer/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make /engines/author/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /engines/2way/build/make /fileformats/avi/parser/build/make /baselibs/thread_messaging/build/make /protocols/rtp_payload_parser/util/build/latmparser/make "
+#define USE_DYNAMIC_LOAD_OMX_COMPONENTS 1
+#define LIBDIR_omxenc_static "  "
+#define pv_config_parser_m_mk "/codecs_v2/utilities/pv_config_parser/build/make"
+#define pvamrffrecognizer_m_mk "/pvmi/recognizer/plugins/pvamrffrecognizer/build/make"
+#define pv_avc_common_lib_y_lib ""
+#define SOLIBDIRS_opencore_downloadreg "/modules/linux_download/node_registry/build/make"
+#define SOLIBDIRS_pvasfstreamingreg "n"
+#define colorconvert_m_lib "-lcolorconvert"
+#define pvomxaudiodecnode_y_lib ""
+#define pvamrwbdecoder_y_lib ""
+#define pvjanusplugin_y_lib ""
+#define rtppayloadparser_y_mk ""
+#define pvid3parcom_m_mk "/fileformats/id3parcom/build/make"
+#define wmvdecoder_imp_m_lib "n"
+#define pvmp4ffrecognizer_y_lib ""
+#define pvmtp_engine_y_mk ""
+#define opencore_author_so_name "opencore_author"
+#define omx_wma_component_y_mk ""
+#define LIBS_protocols_shared "-lpv_http_parcom -lpvlatmpayloadparser  -lpvsdpparser  -lpv_rtsp_parcom   -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools"
+#define LIBDIR_video_shared "/codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make  /codecs_v2/video/m4v_h263/dec/build/make  /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make"
+#define SOLIBDIRS_opencore_rtspreg "/modules/linux_rtsp/node_registry/build/make"
+#define omx_baseclass_m_lib "-lomx_baseclass_lib"
+#define config_3gpp_asf_mk ""
+#define pvasflocalpbreg_so_name ""
+#define pvdummyinputnode_m_lib "-lpvdummyinputnode"
+#define pvamrencnode_y_mk ""
+#define pvwmadecnode_y_lib ""
+#define pvoma1ffrecognizer_y_mk ""
+#define unit_test_y_mk "/oscl/unit_test/build/make"
+#define pvgendatastruct_m_mk "/baselibs/gen_data_structures/build/make"
+#define pvmiofileinput_m_lib "-lpvmiofileinput"
+#define realaudio_deinterleaver_y_mk ""
+#define pv_aac_dec_m_lib "-lpv_aac_dec"
+#define pvpvr_y_lib ""
+#define omx_queue_m_mk "/codecs_v2/omx/omx_queue/build/make"
+#define omx_avcenc_sharedlibrary_so_name "omx_avcenc_sharedlibrary"
+#define pvdummyinputnode_y_lib ""
+#define omx_m4v_component_y_mk ""
+#define DYNAMIC_LOAD_OMX_AVC_COMPONENT 1
+#define pvwav_y_lib ""
+#define pvgendatastruct_y_mk ""
+#define pvra8decnode_y_lib ""
+#define omx_common_y_lib ""
+#define LIBS_extern_libs_static "  "
+#define pvmiofileoutput_y_lib ""
+#define pvjitterbuffernode_plugins "jb_default.mk"
+#define omx_wma_component_imp_m_mk "n"
+#define pvmfrecognizer_y_mk ""
+#define protocolenginenode_plugins "pe_dl_common.mk pe_ps.mk pe_pdl.mk  "
+#define pvpvrnode_m_mk ""
+#define gsm_amr_headers_y_mk ""
+#define gsmamrdecnode_m_mk ""
+#define protocolenginenode_y_lib ""
+#define omx_m4venc_sharedlibrary_so_name "omx_m4venc_sharedlibrary"
+#define pvmedialayernode_plugins_opencore_rtsp "ml_rtsp.mk"
+#define pvaacffparsernode_m_lib "-lpvaacffparsernode"
+#define REGISTER_OMX_M4V_COMPONENT 1
+#define pvasfstreamingreginterface_m_lib ""
+#define MODS_opencore_net_support "-lopencore_common"
+#define cpm_y_mk ""
+#define pvmp3_imp_m_lib ""
+#define LIBDIR_cpm_shared "/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make   /pvmi/content_policy_manager/plugins/common/build/make "
+#define threadsafe_callback_ao_y_mk ""
+#define MODS_pvjanus "-lopencore_player -lopencore_common -lpvwmdrm"
+#define pvstreamingmanagernode_3gpp_y_lib ""
+#define pvdummyoutputnode_y_lib ""
+#define pvm4vencoder_y_mk ""
+#define pvomxencnode_y_mk ""
+#define asfrecognizer_utility_y_lib ""
+#define omx_common_m_lib "-lomx_common_lib"
+#define pv_aac_dec_m_mk "/codecs_v2/audio/aac/dec/build/make"
+#define LIBS_oscl_shared "-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib"
+#define MODS_pvasflocalpb "-lopencore_player -lopencore_common -lpvasfcommon"
+#define pvframemetadatautility_m_lib "-lpvframemetadatautility"
+#define pvamrwbdecoder_m_lib "-lpvamrwbdecoder"
+#define omx_mastercore_y_lib ""
+#define pvmfrecognizer_y_lib ""
+#define pvmp3ff_m_mk "/fileformats/mp3/parser/build/make"
+#define rtppayloadparser_m_mk "/protocols/rtp_payload_parser/build/make"
+#define LIBS_engines_shared "-lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpvframemetadatautility"
+#define SOLIBDIRS_pvasfcommon " "
+#define pvomx_proxy_y_lib ""
+#define pvsdpparser_m_lib ""
+#define omx_wmv_component_imp_m_mk "n"
+#define pvasfstreaminginterface_m_lib ""
+#define oscl_y_lib ""
+#define pvwmvdecnode_m_lib ""
+#define rtprtcp_m_mk "/protocols/rtp/build/make"
+#define pv_http_parcom_m_mk "/protocols/http_parcom/build/make"
+#define LIBDIR_omxenc_shared "/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded"
+#define LIBS_protocols_static "            "
+#define pvrtppacketsourcenode_m_mk ""
+#define omx_common_y_mk ""
+#define opencore_net_support_so_name "opencore_net_support"
+#define MODS_omx_avcdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common"
+#define aacdecnode_y_lib ""
+#define LIBS_nodes_static "                                                 "
+#define pvcommsionode_y_lib ""
+#define pvasfffrecognizer_m_mk ""
+#define pvlatmpayloadparser_y_lib ""
+#define MODS_omx_amrdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common"
+#define pvmp4ffparsernode_m_mk ""
+#define LIBS_video_static "      "
+#define rtppayloadparser_plugins_pvasfstreaming "asf_payload_parser.mk"
+#define SOLIBS_omx_mp3dec_sharedlibrary "-lomx_mp3_component_lib -lpvmp3"
+#define pvpvxparser_y_mk ""
+#define pvsdpparser_opencore_m_lib "-lpvsdpparser"
+#define realmedia_payload_mk ""
+#define pv_divxfile_parser_y_lib ""
+#define pvfileparserutils_m_mk "/fileformats/common/parser/build/make"
+#define omx_amr_component_y_mk ""
+#define pv_amr_nb_common_imp_lib_m_lib ""
+#define pvasfffparsernode_m_lib ""
+#define omx_avc_component_y_mk ""
+#define pvdbmanager_y_lib ""
+#define pvasxparser_m_lib ""
+#define rfc_3640_mk "rfc_3640.mk"
+#define pvavifileparser_y_lib ""
+#define pvrtsp_cli_eng_node_3gpp_y_mk ""
+#define pv324m_y_lib ""
+#define pvasflocalpbreginterface_m_lib ""
+#define MODS_omx_sharedlibrary "-lopencore_common"
+#define pvvideodecnode_y_mk ""
+#define pvsocketnode_y_lib ""
+#define pvamrffparsernode_m_lib "-lpvamrffparsernode"
+#define pvomxencnode_m_mk "/nodes/pvomxencnode/build/make"
+#define SOLIBDIRS_opencore_mp4local "/modules/linux_mp4/core/build/make  /nodes/pvmp4ffparsernode/build_opencore/make"
+#define omx_m4venc_component_m_lib "-lomx_m4venc_component_lib"
+#define pvmp4ffcomposernodeopencore_m_lib "-lpvmp4ffcomposernode"
+#define rfc_3267_mk "rfc_3267.mk"
+#define getactualaacconfig_y_mk ""
+#define LIBS_media_io_shared "-lpvmiofileoutput -lpvmiofileinput -lpvmioaviwavfileinput -lpvmio_comm_loopback"
+#define LIBS_nodes_shared "-lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode  -lprotocolenginenode   -lpvwavffparsernode   -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode  -lpvaacffparsernode  -lpvamrffparsernode   -lpvmp3ffparsernode  -lpvmp4ffparsernode      -lpvmediainputnode  -lpvmp4ffcomposernode     -lpvdownloadmanagernode   -lpvstreamingmanagernode   -lpvrtspinterface -lpvrtspreginterface -lpvmedialayernode  -lpvjitterbuffernode  -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvvideoparsernode -lpvdummyinputnode -lpvdummyoutputnode "
+#define LIBS_audio_shared "  -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3  -lpvencoder_gsmamr"
+#define pvloopbacknode_m_mk "/nodes/pvloopbacknode/build/make"
+#define pvvideoparsernode_y_lib ""
+#define pvavch264enc_m_mk "/codecs_v2/video/avc_h264/enc/build/make"
+#define csprng_m_mk ""
+#define pvmp3_y_lib ""
+#define pvoma1lockstream_m_lib ""
+#define MODS_pvasfstreamingreg "-lopencore_player -lopencore_common"
+#define pvmf_y_lib ""
+#define pvjitterbuffernode_m_mk "/nodes/streaming/jitterbuffernode/build/make"
+#define pvmio_comm_loopback_y_lib ""
+#define pvmp4decoder_imp_m_mk ""
+#define pv_config_parser_y_lib ""
+#define pvmp3ffrecognizer_y_lib ""
+#define pvavcdecoder_y_lib ""
+#define m4v_config_m_lib "-lm4v_config"
+#define pv_rtsp_parcom_m_lib "-lpv_rtsp_parcom"
+#define omx_aac_component_y_mk ""
+#define protocolenginenode_plugins_pvdownload "pe_ps.mk pe_pdl.mk pe_dl_common.mk"
+#define pvaacffrecognizer_m_lib "-lpvaacffrecognizer"
+#define packetsources_default_y_mk ""
+#define rdt_parser_m_lib ""
+#define pvwmvdecnode_y_lib ""
+#define LIBDIR_omxjointimp_static "n"
+#define pvmtpdb_so_name ""
+#define pvmioaviwavfileinput_y_lib ""
+#define pvdecoder_gsmamr_y_lib ""
+#define pvwmdrm_m_lib ""
+#define cpm_m_mk "/pvmi/content_policy_manager/build/make"
+#define omx_amrdec_sharedlibrary_so_name "omx_amrdec_sharedlibrary"
+#define pvoma1lockstream_m_mk ""
+#define pvomxbasedecnode_y_mk ""
+#define pvloopbacknode_y_lib ""
+#define realaudio_deinterleaver_m_lib ""
+#define pv_amr_nb_common_lib_y_mk ""
+#define REGISTER_OMX_AMRENC_COMPONENT 1
+#define SOLIBS_pvasfcommon " "
+#define cpm_headers_m_mk "/pvmi/content_policy_manager/plugins/common/build/make"
+#define opencore_mp4localreg_so_name "opencore_mp4localreg"
+#define pvmp4ffrecognizer_m_mk "/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make"
+#define LIBS_cpm_static "   "
+#define SOLIBS_omx_m4vdec_sharedlibrary "-lomx_m4v_component_lib -lpvmp4decoder"
+#define pvid3parcom_m_lib "-lpvid3parcom"
+#define pvstreamingmanagernode_segments_m_mk "/nodes/streaming/streamingmanager/build/make_segments"
+#define pvrtsp_cli_eng_node_y_mk ""
+#define omx_avcenc_component_imp_m_lib ""
+#define pvmp4ffcomposernodeopencore_y_mk ""
+#define DYNAMIC_LOAD_OMX_H263ENC_COMPONENT 1
+#define pvasflocalpb_so_name ""
+#define pvsocketnode_m_lib "-lpvsocketnode"
+#define SOLIBDIRS_opencore_common "/oscl  /codecs_v2/omx/omx_mastercore/build/make_multithreaded              /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make   /fileformats/rawgsmamr/parser/build/make  /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /nodes/pvfileoutputnode/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvomxencnode/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /fileformats/avi/parser/build/make /baselibs/thread_messaging/build/make /pvmi/media_io/pvmiofileoutput/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/wav/parser/build/make /fileformats/common/parser/build/make /nodes/common/build/make /engines/common/build/make /pvmi/content_policy_manager/plugins/common/build/make"
+#define SOLIBS_opencore_common "-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib -lomx_mastercore_lib              -lpv_avc_common_lib -lpv_amr_nb_common_lib   -lpvgsmamrparser  -lgetactualaacconfig -lm4v_config -lpv_config_parser -lcolorconvert -lthreadsafe_callback_ao -lpvmediadatastruct -lpvmimeutils -lpvgendatastruct -lpvmf -lpvfileoutputnode -lpvmediainputnode -lpvomxencnode -lpvmiofileinput -lpvmioaviwavfileinput -lpvavifileparser -lpvthreadmessaging -lpvmiofileoutput -lpvmediaoutputnode -lpvomxvideodecnode -lpvomxaudiodecnode -lpvomxbasedecnode -lpvlatmpayloadparser -lpvwav -lpvfileparserutils"
+#define pvmp4decoder_y_lib ""
+#define rtprtcp_m_lib "-lrtprtcp"
+#define pvmimeutils_m_lib "-lpvmimeutils"
+#define pvasfff_m_mk ""
+#define pvgsmamrparser_m_mk "/fileformats/rawgsmamr/parser/build/make"
+#define pvframemetadatautility_y_mk ""
+#define pvmtp_engine_y_lib ""
+#define omx_mp3_component_y_lib ""
+#define rvdecoder_m_mk ""
+#define pvmedialayernode_plugins "ml_default.mk"
+#define pvjitterbuffernode_plugins_opencore_rtsp "jb_rtsp.mk"
+#define omx_mastercore_y_mk ""
+#define pvmp4ffcomposer_m_mk ""
+#define pvasflocalpbreginterface_m_mk ""
+#define pvasflocalpbinterface_m_lib ""
+#define SOLIBS_omx_amrdec_sharedlibrary "-lomx_amr_component_lib -lpvdecoder_gsmamr -lpvamrwbdecoder"
+#define pvra8decnode_y_mk ""
+#define pv324m_common_headers_m_mk "/protocols/systems/common/build/make/"
+#define pvwmdrmdevinterface_m_mk ""
+#define REGISTER_OMX_MP3_COMPONENT 1
+#define pvra8decoder_y_mk ""
+#define rtppayloadparser_plugins "rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk  "
+#define pvavcencnode_y_mk ""
+#define optimized_bcast_ps_mk ""
+#define pvmtp_engine_m_mk ""
+#define pvstreamingmanagernode_3gpp_m_lib ""
+#define pvplayer_engine_m_mk "/engines/player/build/make"
+#define LIBDIR_engines_static "    "
+#define LIBS_omxdec_shared "-lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib "
+#define LIBDIR_pvmi_static "                      "
+#define pvsdpparser_y_mk ""
+#define pv324m_common_headers_y_mk ""
+#define pvthreadmessaging_y_lib ""
+#define pvmp4decoder_y_mk ""
+#define pvthreadmessaging_m_mk "/baselibs/thread_messaging/build/make"
+#define pvmp4interface_m_mk "/modules/linux_mp4/core/build/make"
+#define REGISTER_OMX_AVC_COMPONENT 1
+#define pvaacffparsernode_y_lib ""
+#define SOLIBDIRS_omx_amrenc_sharedlibrary "/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make"
+#define LIBS_tools_v2_shared "-lpvrtspinterface -lpvrtspreginterface   -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface  "
+#define SOLIBS_pvasfstreaming " -lpvstreamingmanagernode -lpvjitterbuffernode -lpvmedialayernode -lrtppayloadparser -lrtprtcp -lprotocolenginenode"
+#define LIBS_pvmi_shared "-lcpm -lpassthru_oma1    -lpvmiofileoutput -lpvmiofileinput -lpvmioaviwavfileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer   -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer    -lpvmf  "
+#define pvmioaviwavfileinput_y_mk ""
+#define omx_mp3_component_imp_m_mk ""
+#define pvm4vencoder_imp_m_mk ""
+#define pvwavffrecognizer_y_mk ""
+#define m4v_config_y_lib ""
+#define pvdownloadreginterface_m_mk "/modules/linux_download/node_registry/build/make"
+#define pvrtppacketsourcenode_m_lib ""
+#define DYNAMIC_LOAD_OMX_WMA_COMPONENT 0
+#define omx_aac_component_imp_m_lib ""
+#define pvmp3_y_mk ""
+#define omx_wmv_component_y_mk ""
+#define omx_mp3_component_imp_m_lib ""
+#define SOLIBS_pvasflocalpb " "
+#define pvrtsp_cli_eng_node_3gpp_m_lib ""
+#define pvwmvdecnode_y_mk ""
+#define pvmp4ffparsernodeopencore_m_lib "-lpvmp4ffparsernode"
+#define SOLIBDIRS_pvasflocalpb " "
+#define passthru_oma1_y_lib ""
+#define pvamrencnode_m_mk ""
+#define SOLIBS_opencore_download "-lprotocolenginenode -lpvdownloadmanagernode -lpvdownloadinterface"
+#define oscllib_mk "/oscl/oscl/oscllib/build/make"
+#define DYNAMIC_LOAD_OMX_H263_COMPONENT 1
+#define pvomxencnode_y_lib ""
+#define omx_wma_component_imp_m_lib "n"
+#define getactualaacconfig_m_lib "-lgetactualaacconfig"
+#define sdp_parser_mksegment_default ""
+#define threadsafe_callback_ao_m_mk "/baselibs/threadsafe_callback_ao/build/make"
+#define pvasfstreamingreginterface_m_mk ""
+#define SOLIBDIRS_opencore_download "/nodes/pvprotocolenginenode/build/make_segments /nodes/pvdownloadmanagernode/build/make /modules/linux_download/core/build/make"
+#define mp3decnode_m_lib ""
+#define pvasf_streamingreg_so_name ""
+#define pvcommsionode_y_mk ""
+#define pvpvxparser_y_lib ""
+#define omx_baseclass_m_mk "/codecs_v2/omx/omx_baseclass/build/make"
+#define LIBDIR_oscl_shared "/oscl "
+#define pvencoder_gsmamr_imp_m_mk ""
+#define pvra8decoder_y_lib ""
+#define nodes_common_headers_m_mk "/nodes/common/build/make"
+#define LIBDIR_recognizer_shared "/pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make   /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make  "
+#define MODS_opencore_author "-lopencore_common"
+#define omx_wmv_component_m_lib ""
+#define MODS_pvasflocalpbreg "-lopencore_common -lpvasfcommon"
+#define pvrmffparsernode_m_lib ""
+#define pvrtsp_cli_eng_node_m_mk ""
+#define packetsources_default_m_mk ""
+#define pvaacffrecognizer_m_mk "/pvmi/recognizer/plugins/pvaacffrecognizer/build/make"
+#define pvoma1lockstream_y_lib ""
+#define LIBS_baselibs_static "       "
+#define pv_divxfile_parser_m_mk ""
+#define LIBDIR_protocols_shared "/protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make  /protocols/rtsp_parcom/build/make   /protocols/rtsp_client_engine/build_opencore/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make"
+#define LIBS_media_io_static "   "
+#define pv_avc_common_imp_lib_m_mk ""
+#define SOLIBDIRS_opencore_2way "/engines/2way/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /nodes/pvvideoparsernode/build/make /nodes/pvcommsionode/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make "
+#define pvmfrecognizer_m_lib "-lpvmfrecognizer"
+#define pvencoder_gsmamr_y_mk ""
+#define pvmedialayernode_y_mk ""
+#define pvoma1ffrecognizer_y_lib ""
+#define pvrtsp_cli_eng_node_3gpp_m_mk ""
+#define protocolenginenode_plugins_pvasfstreaming "pe_http.mk"
+#define pvdbmanager_y_mk ""
+#define pv_amr_nb_common_imp_lib_m_mk ""
+#define passthru_oma1_m_lib "-lpassthru_oma1"
+#define LIBDIR_extern_libs_static "  "
+#define pvwmdrm_y_lib ""
+#define opencore_common_so_name "opencore_common"
+#define pvmp4ffcomposernodeopencore_m_mk "/nodes/pvmp4ffcomposernode/build_opencore/make"
+#define pvrmff_y_lib ""
+#define omx_mp3_component_y_mk ""
+#define SOLIBS_opencore_2way "-lpv2wayengine -lpv324m -lpvvideoparsernode -lpvcommsionode -lpvmio_comm_loopback -lpvgeneraltools "
+#define SOLIBS_opencore_player "        -lcpm -lpassthru_oma1  -lpvid3parcom -lpvamrffparsernode -lpvamrffrecognizer -lpvmp3ff  -lpvmp3ffparsernode -lpvmp3ffrecognizer  -lpvmp4ff -lmp4recognizer_utility -lpvaacparser -lpvaacffparsernode  -lpvaacffrecognizer -lpvwavffparsernode -lpvwavffrecognizer           -lpvmfrecognizer   -lpvframemetadatautility -lpvplayer_engine"
+#define MODS_opencore_mp4localreg "-lopencore_player -lopencore_common"
+#define rdt_parser_y_mk ""
+#define LIBDIR_packetsources_static "n"
+#define SOLIBDIRS_omx_amrdec_sharedlibrary "/codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make"
+#define pvjanusplugininterface_m_mk ""
+#define pvmedialayernode_plugins_pvasfstreaming "ml_asf.mk"
+#define pv_rtsp_parcom_y_mk ""
+#define pvomxvideodecnode_m_mk "/nodes/pvomxvideodecnode/build/make"
+#define pvmiofileoutput_m_mk "/pvmi/media_io/pvmiofileoutput/build/make"
+#define aacdecnode_m_lib ""
+#define pvcrypto_m_mk ""
+#define rtppayloadparser_plugins_pvrtsp "rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk"
+#define DYNAMIC_LOAD_OMX_AVCENC_COMPONENT 1
+#define pvvideoencnode_m_lib ""
+#define USE_OMX_ENC_NODE 1
+#define pvamrwbdecoder_y_mk ""
+#define mp4recognizer_utility_y_lib ""
+#define pvrmffparsernode_y_lib ""
+#define DYNAMIC_LOAD_OMX_M4V_COMPONENT 1
+#define pvmp4ffparsernodeopencore_y_mk ""
+#define pvmp4ffopencore_y_mk ""
+#define LIBS_video_shared "-lpv_avc_common_lib -lpvavcdecoder  -lpvmp4decoder  -lpvm4vencoder -lpvavch264enc"
+#define colorconvert_y_lib ""
+#define pvm4vencoder_m_lib "-lpvm4vencoder"
+#define pv_aac_dec_y_lib ""
+#define omx_mp3dec_sharedlibrary_so_name "omx_mp3dec_sharedlibrary"
+#define omx_wma_component_m_mk ""
+#define SOLIBS_pvasflocalpbreg " "
+#define opencore_2way_so_name "opencore_2way"
+#define pv_http_parcom_y_mk ""
+#define pvgsmamrparser_y_lib ""
+#define pvfileoutputnode_m_lib "-lpvfileoutputnode"
+#define pvmedialayernode_opencore_m_mk ""
+#define omx_wmvdec_sharedlibrary_so_name ""
+#define opencore_rtspreg_so_name "opencore_rtspreg"
+#define rfc_2429_mk "rfc_2429.mk"
+#define SOLIBDIRS_opencore_net_support "/nodes/pvsocketnode/build/make /protocols/http_parcom/build/make"
+#define LIBDIR_audio_static "         "
+#define pvoma1ffrecognizer_m_lib ""
+#define wmvdecoder_m_mk ""
+#define rtprtcp_y_lib ""
+#define rfc_3984_mk "rfc_3984.mk"
+#define LIBDIR_shared "/oscl     /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded  /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make   /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make  /codecs_v2/video/m4v_h263/dec/build/make  /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make  /fileformats/wav/parser/build/make  /fileformats/avi/parser/build/make  /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make    /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make  /fileformats/mp4/composer/build_opencore/make    /protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make  /protocols/rtsp_parcom/build/make   /protocols/rtsp_client_engine/build_opencore/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make   /pvmi/content_policy_manager/plugins/common/build/make  /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make   /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make    /pvmi/pvmf/build/make        /nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make  /nodes/pvprotocolenginenode/build/make_segments   /nodes/pvwavffparsernode/build/make   /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make  /nodes/pvaacffparsernode/build/make  /nodes/pvamrffparsernode/build/make   /nodes/pvmp3ffparsernode/build/make  /nodes/pvmp4ffparsernode/build_opencore/make     /nodes/common/build/make  /nodes/pvmediainputnode/build/make_pvauthor  /nodes/pvmp4ffcomposernode/build_opencore/make     /nodes/pvdownloadmanagernode/build/make   /nodes/streaming/streamingmanager/build/make_segments   /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /nodes/streaming/medialayernode/build/make  /nodes/streaming/jitterbuffernode/build/make  /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvvideoparsernode/build/make /nodes/pvdummyinputnode/build/make /nodes/pvdummyoutputnode/build/make  /engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make   /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make  "
+#define pdl_support_mk "pe_pdl.mk"
+#define wmadecoder_m_mk ""
+#define omx_aacdec_sharedlibrary_so_name "omx_aacdec_sharedlibrary"
+#define pv_so_name ""
+#define asf_payload_mk ""
+#define pvmioaviwavfileinput_m_lib "-lpvmioaviwavfileinput"
+#define protocolenginenode_segments_y_mk ""
+#define pvamrencnode_m_lib ""
+#define pvrvdecnode_y_mk ""
+#define pvmp3ffrecognizer_m_mk "/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make"
+#define LIBDIR_omxjoint_shared "/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make"
+#define pv324m_m_mk "/protocols/systems/3g-324m_pvterminal/build/make/"
+#define pvavch264enc_imp_m_mk ""
+#define LIBS_shared "-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib    -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging -lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib  -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface   -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3  -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder  -lpvmp4decoder  -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert -lpvfileparserutils -lpvid3parcom  -lpvwav  -lpvavifileparser  -lpvmp3ff -lpvaacparser -lpvgsmamrparser   -lmp4recognizer_utility -lpvmp4ff  -lpvmp4ffcomposer    -lpv_http_parcom -lpvlatmpayloadparser  -lpvsdpparser  -lpv_rtsp_parcom   -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools -lcpm -lpassthru_oma1    -lpvmiofileoutput -lpvmiofileinput -lpvmioaviwavfileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer   -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer    -lpvmf        -lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode  -lprotocolenginenode   -lpvwavffparsernode   -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode  -lpvaacffparsernode  -lpvamrffparsernode   -lpvmp3ffparsernode  -lpvmp4ffparsernode      -lpvmediainputnode  -lpvmp4ffcomposernode     -lpvdownloadmanagernode   -lpvstreamingmanagernode   -lpvrtspinterface -lpvrtspreginterface -lpvmedialayernode  -lpvjitterbuffernode  -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvvideoparsernode -lpvdummyinputnode -lpvdummyoutputnode  -lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpvframemetadatautility -lpvrtspinterface -lpvrtspreginterface   -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface  "
+#define omx_amrenc_component_y_lib ""
+#define pvgeneraltools_m_lib "-lpvgeneraltools"
+#define REGISTER_OMX_AAC_COMPONENT 1
+#define SOLIBDIRS_pvwmdrmplat "n"
+#define pvwavffparsernode_m_lib "-lpvwavffparsernode"
+#define LIBS_packetsources_shared "n"
+#define pvstreamingmanagernode_plugins_opencore_rtsp "3gpp.mk rtspunicast.mk"
+#define LIBS_omxjoint_shared "-lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface"
+#define pvasfffrecognizer_m_lib ""
+#define SOLIBS_pv "-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib  -lpv_aac_dec -lpvmp3  -lpvdecoder_gsmamr -lpvencoder_gsmamr -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvavcdecoder -lpv_avc_common_lib -lpvavch264enc  -lpvmp4decoder -lpvm4vencoder  -lgetactualaacconfig -lcolorconvert -lm4v_config -lpv_config_parser -lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib  -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface -lthreadsafe_callback_ao -lpvmediadatastruct -lpvmimeutils -lpvgendatastruct -lpvmf -lcpm -lpassthru_oma1 -lpvmiofileoutput -lpvfileparserutils -lpvid3parcom  -lpvmp4ff -lmp4recognizer_utility  -lpvmp4ffcomposer  -lpvmp4ffcomposernode      -lpvmediainputnode -lpvmediaoutputnode -lpvfileoutputnode -lpvgsmamrparser -lpvamrffparsernode  -lpvamrffrecognizer -lpvaacparser -lpvaacffparsernode  -lpvaacffrecognizer -lpvmp3ff  -lpvmp3ffparsernode -lpvmp3ffrecognizer    -lpvomxvideodecnode -lpvomxaudiodecnode -lpvomxbasedecnode        -lpvwavffparsernode -lpvwavffrecognizer     -lpvmfrecognizer -lpvmiofileinput -lpvmioaviwavfileinput -lpvframemetadatautility -lpvplayer_engine -lpvauthorengine -lpv324m -lpv2wayengine -lpvavifileparser -lpvthreadmessaging -lpvlatmpayloadparser "
+#define pvmp3ffparsernode_y_lib ""
+#define pvjitterbuffernode_opencore_m_lib ""
+#define MODS_opencore_player "-lopencore_common"
+#define pvjitterbuffernode_m_lib "-lpvjitterbuffernode"
+#define MODS_pvwmdrmplat "-lopencore_player -lopencore_common"
+#define pvm4vencoder_imp_m_lib ""
+#define cpm_y_lib ""
+#define omx_wmadec_sharedlibrary_so_name ""
+#define pvgsmamrparser_y_mk ""
+#define rtppayloadparser_y_lib ""
+#define pvra8decoder_m_mk ""
+#define pvrmffparser_y_lib ""
+#define pvmp4decoder_m_lib "-lpvmp4decoder"
+#define omx_avc_component_m_lib "-lomx_avc_component_lib"
+#define MODS_omx_avcenc_sharedlibrary "-lomx_sharedlibrary -lopencore_common "
+#define pvwmvdecnode_m_mk ""
+#define pvwav_y_mk ""
+#define wmadecoder_imp_m_mk "n"
+#define MODS_opencore_downloadreg "-lopencore_player -lopencore_common"
+#define pvmiofileoutput_y_mk ""
+#define packetsources_default_m_lib ""
+#define pvaacparser_m_mk "/fileformats/rawaac/parser/build/make"
+#define omx_aac_component_m_lib "-lomx_aac_component_lib"
+#define SOLIBS_omx_wmadec_sharedlibrary " "
+#define SOLIBS_opencore_rtsp "-lpvrtspinterface -lpvstreamingmanagernode -lpv_rtsp_parcom -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpvjitterbuffernode -lpvmedialayernode  -lpvsdpparser"
+#define omx_amrenc_component_imp_m_lib ""
+#define pvjanusplugin_m_lib ""
+#define config_3gpp_mk "3gpp.mk"
+#define pvaacffrecognizer_y_mk ""
+#define pvvideoencnode_y_lib ""
+#define pvaacffparsernode_y_mk ""
+#define pvomx_proxy_m_lib "-lpvomx_proxy_lib"
+#define pvrvdecnode_m_mk ""
+#define pvavcdecoder_imp_m_lib ""
+#define pvframemetadatautility_m_mk "/engines/adapters/player/framemetadatautility/build/make"
+#define LIBS_omxjointimp_static "n"
+#define pvmediadatastruct_y_lib ""
+#define MODS_opencore_mp4local "-lopencore_common -lopencore_player"
+#define pvavch264enc_y_mk ""
+#define rtppayloadparser_m_lib "-lrtppayloadparser"
+#define pvcrypto_y_mk ""
+#define pvmp4ffparsernodeopencore_m_mk "/nodes/pvmp4ffparsernode/build_opencore/make"
+#define SOLIBDIRS_pvmtpdb "  "
+#define LIBDIR_codecs_v2_static "                                 "
+#define omx_m4v_component_imp_m_lib ""
+#define pvmp4ffcomposeropencore_y_mk ""
+#define oscl_y_mk ""
+#define MODS_pvmtpdb "-lopencore_player -lopencore_common -lpvwmdrm -lpvasfcommon -lpvasflocalpbreg"
+#define pvdivxffparsernode_y_mk ""
+#define LIBS_codecs_utilities_shared "-lm4v_config -lpv_config_parser -lcolorconvert"
+#define MODS_omx_m4vdec_sharedlibrary "-lomx_sharedlibrary -lopencore_common "
+#define LIBS_omxdecimp_static ""
+#define engines_common_headers_m_mk "/engines/common/build/make"
+#define pvmp4ff_m_lib ""
+#define pv2wayengine_m_mk "/engines/2way/build/make"
+#define MODS_opencore_rtspreg "-lopencore_player -lopencore_common"
+#define pvmtp_engine_m_lib ""
+#define pvdivxffparsernode_m_lib ""
+#define aacdecnode_y_mk ""
+#define pvasfffrecognizer_y_mk ""
+#define wmadecoder_y_lib ""
+#define engines_common_headers_y_mk ""
+#define MODS_omx_mp3dec_sharedlibrary "-lomx_sharedlibrary -lopencore_common"
+#define asfrecognizer_utility_m_mk ""
+#define oscllib_lib "-loscllib"
+#define pvrmffparsernode_m_mk ""
+#define realaudio_deinterleaver_m_mk ""
+#define pvauthorengine_y_mk ""
+#define LIBDIR_baselibs_static "       "
+#define pvwav_m_lib "-lpvwav"
+#define omx_avc_component_y_lib ""
+#define pvmp4decoder_imp_m_lib ""
+#define pv_rtsp_parcom_y_lib ""
+#define pvmedialayernode_opencore_m_lib ""
+#define pvmioaviwavfileinput_m_mk "/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make"
+#define omx_mp3_component_m_mk "/codecs_v2/omx/omx_mp3/build/make_multithreaded"
+#define pvwmdrm_y_mk ""
+#define LIBDIR_static " /oscl/unit_test/build/make                                                                                                                                                              "
+#define SOLIBS_opencore_mp4local "-lpvmp4interface  -lpvmp4ffparsernode"
+#define config_3gpp_pvr_asf_mk ""
+#define pvavch264enc_imp_m_lib ""
+#define pvloopbacknode_m_lib "-lpvloopbacknode"
+#define LIBS_omxdec_static "         "
+#define pvwmadecnode_m_lib ""
+#define REGISTER_OMX_WMA_COMPONENT 0
+#define pvrmffrecognizer_m_mk ""
+#define SOLIBS_opencore_net_support "-lpvsocketnode -lpv_http_parcom"
+#define pv_http_parcom_m_lib "-lpv_http_parcom"
+#define pvmediadatastruct_m_lib "-lpvmediadatastruct"
+#define pvlatmpayloadparser_m_lib "-lpvlatmpayloadparser"
+#define pv_config_parser_y_mk ""
+#define pvstreamingmanagernode_plugins "  3gpp.mk rtspunicast.mk    "
+#define TARGET_shared " opencore_common opencore_author opencore_player opencore_2way omx_sharedlibrary omx_avcdec_sharedlibrary omx_m4vdec_sharedlibrary  omx_aacdec_sharedlibrary omx_amrdec_sharedlibrary omx_mp3dec_sharedlibrary  omx_avcenc_sharedlibrary omx_m4venc_sharedlibrary omx_amrenc_sharedlibrary opencore_net_support opencore_downloadreg opencore_download opencore_rtspreg opencore_rtsp      opencore_mp4localreg opencore_mp4local     "
+#define pvsdpparser_opencore_y_lib ""
+#define omx_aac_component_m_mk "/codecs_v2/omx/omx_aac/build/make_multithreaded"
+#define LIBS_oscl_static " -lunit_test"
+#define pvomxbasedecnode_m_lib "-lpvomxbasedecnode"
+#define pvfileoutputnode_m_mk "/nodes/pvfileoutputnode/build/make"
+#define wmadecoder_imp_m_lib "n"
+#define pv_rtsp_parcom_m_mk "/protocols/rtsp_parcom/build/make"
+#define ftdl_support_mk ""
+#define omx_wma_component_y_lib ""
+#define pv_config_parser_m_lib "-lpv_config_parser"
+#define m4v_config_y_mk ""
+#define pvcrypto_m_lib ""
+#define SOLIBDIRS_omx_avcdec_sharedlibrary "/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/video/avc_h264/dec/build/make"
+#define LIBS_fileformats_shared "-lpvfileparserutils -lpvid3parcom  -lpvwav  -lpvavifileparser  -lpvmp3ff -lpvaacparser -lpvgsmamrparser   -lmp4recognizer_utility -lpvmp4ff  -lpvmp4ffcomposer   "
+#define gsmamrdecnode_y_mk ""
+#define LIBS_engines_static "   "
+#define pvjanusplugin_m_mk ""
+#define LIBS_static " -lunit_test                                                                                                                                                           "
+#define pvsqlite_y_lib ""
+#define pvasfffparsernode_y_lib ""
+#define pvmp3_m_lib "-lpvmp3"
+#define SOLIBDIRS_opencore_player "        /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make  /fileformats/id3parcom/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/mp3/parser/build/make  /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make  /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make  /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make           /pvmi/recognizer/build/make   /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make"
+#define pvfileoutputnode_y_lib ""
+#define pvstreamingmanagernode_plugins_pvasfstreaming "asf.mk mshttp.mk"
+#define omx_avcdec_sharedlibrary_so_name "omx_avcdec_sharedlibrary"
+#define pvsdpparser_plugins " sdp_opencore.mk"
+#define LIBS_recognizer_static "         "
+#define pvencoder_gsmamr_m_lib "-lpvencoder_gsmamr"
+#define SOLIBS_omx_amrenc_sharedlibrary "-lomx_amrenc_component_lib -lpvencoder_gsmamr"
+#define pvplayer_engine_m_lib "-lpvplayer_engine"
+#define pvpvxparser_m_lib ""
+#define pvmp3ffparsernode_m_lib "-lpvmp3ffparsernode"
+#define passthru_oma1_y_mk ""
+#define pvmp4ffcomposernode_y_lib ""
+#define gsmamrdecnode_y_lib ""
+#define LIBDIR_cpm_static "    "
+#define pvrtspinterface_m_mk "/modules/linux_rtsp/core/build/make"
+#define wmvdecoder_m_lib ""
+#define opencore_downloadreg_so_name "opencore_downloadreg"
+#define omx_avcenc_component_y_mk ""
+#define pvra8decnode_m_mk ""
+#define pvamrwbdecoder_imp_m_lib ""
+#define oscl_m_lib "-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test"
+#define CONFIG_FLAGS "USE_CML2_CONFIG"
+#define pvomxbasedecnode_m_mk "/nodes/pvomxbasedecnode/build/make"
+#define SOLIBDIRS_pvasflocalpbreg " "
+#define pvasfffrecognizer_y_lib ""
+#define mp4recognizer_utility_y_mk ""
+#define pvmediainputnode_y_mk ""
+#define REGISTER_OMX_H263_COMPONENT 1
+#define pvmp3_m_mk "/codecs_v2/audio/mp3/dec/build/make"
+#define LIBS_codecs_utilities_static "  "
+#define LIBDIR_omxjointimp_shared "/codecs_v2/omx/omx_mastercore/build/make_multithreaded"
+#define DRMCONFIG ""
+#define pvwavffparsernode_y_mk ""
+#define SOLIBDIRS_omx_aacdec_sharedlibrary "/codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/audio/aac/dec/build/make"
+#define pvmp4reginterface_m_lib "-lpvmp4reginterface"
+#define pvavcdecnode_m_lib ""
+#define pvpvrnode_y_lib ""
+#define unit_test_y_lib "-lunit_test"
+#define pvpvrff_y_lib ""
+#define pvrfileplayback_support_mk ""
+#define pvrvdecnode_m_lib ""
+#define omx_aac_component_imp_m_mk ""
+#define pvwav_m_mk "/fileformats/wav/parser/build/make"
+#define omx_m4venc_component_m_mk "/codecs_v2/omx/omx_m4venc/build/make_multithreaded"
+#define SOLIBDIRS_omx_m4vdec_sharedlibrary "/codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/video/m4v_h263/dec/build/make"
+#define pvcommsionode_m_mk "/nodes/pvcommsionode/build/make"
+#define pvmp4reginterface_m_mk "/modules/linux_mp4/node_registry/build/make"
+#define pvgeneraltools_m_mk "/protocols/systems/tools/general/build/make"
+#define unit_test_m_mk ""
+#define omx_m4venc_component_imp_m_lib ""
+#define pvomxaudiodecnode_m_mk "/nodes/pvomxaudiodecnode/build/make"
+#define pvjanusplugininterface_m_lib ""
+#define SOLIBS_omx_avcenc_sharedlibrary "-lomx_avcenc_component_lib -lpvavch264enc"
+#define pvvideodecnode_m_lib ""
+#define getactualaacconfig_imp_m_mk "/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make"
+#define pvrmffrecognizer_y_lib ""
+#define pvamrffrecognizer_y_lib ""
+#define omx_common_m_mk "/codecs_v2/omx/omx_common/build/make_multithreaded"
+#define SOLIBDIRS_omx_mp3dec_sharedlibrary "/codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/audio/mp3/dec/build/make"
+#define pvasfffparsernode_m_mk ""
+#define LIBS_omxjointimp_shared "-lomx_mastercore_lib"
+#define pvlatmpayloadparser_m_mk "/protocols/rtp_payload_parser/util/build/latmparser/make"
+#define pvrmffparsernode_y_mk ""
+#define getactualaacconfig_for_static_m_mk ""
+#define pvdbmanager_m_lib ""
+#define MODS_pvwmdrm "-lopencore_player -lopencore_common"
+#define wmvdecoder_imp_m_mk "n"
+#define pvamrwbdecoder_m_mk "/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make"
+#define pvrtsp_cli_eng_node_opencore_m_mk "/protocols/rtsp_client_engine/build_opencore/make"
+#define mshttp_support_mk ""
+#define opencore_download_so_name "opencore_download"
+#define SOLIBS_pvmtpdb "  "
+#define SOLIBS_opencore_downloadreg "-lpvdownloadreginterface"
+#define mp3decnode_m_mk ""
+#define SOLIBS_omx_sharedlibrary "-lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lpv_omx_interface"
+#define pvwavffrecognizer_y_lib ""
+#define pvavcencnode_m_lib ""
+#define pvjitterbuffernode_y_lib ""
+#define pvmediadatastruct_m_mk "/baselibs/media_data_structures/build/make"
+#define REGISTER_OMX_M4VENC_COMPONENT 1
+#define LIBDIR_fileformats_static "                   "
+#define pvpvrff_y_mk ""
+#define pvpvrnode_y_mk ""
+#define MODS_omx_amrenc_sharedlibrary "-lomx_sharedlibrary -lopencore_common "
+#define LIBS_cpm_shared "-lcpm -lpassthru_oma1   "
+#define pvmediainputnode_y_lib ""
+#define pvmiofileinput_y_mk ""
+#define pvmiofileoutput_m_lib "-lpvmiofileoutput"
+#define pvmp4ffparsernode_m_lib ""
+#define omx_m4venc_component_y_mk ""
+#define LIBDIR_omxdecimp_static ""
+#define omx_amr_component_y_lib ""
+#define rvdecoder_y_lib ""
+#define LIBS_pvmi_static "                     "
+#define pvplayer_engine_y_mk ""
+#define MODS_opencore_common ""
+#define pvsqlite_m_lib ""
+#define pvmp4ffopencore_m_mk "/fileformats/mp4/parser/build_opencore/make"
+#define pv_amr_nb_common_lib_m_mk "/codecs_v2/audio/gsm_amr/amr_nb/common/build/make"
+#define LIBDIR_tools_v2_shared "/modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make   /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make  "
+#define DYNAMIC_LOAD_OMX_AMRENC_COMPONENT 1
+#define pvamrencnode_y_lib ""
+#define pvjanusplugin_y_mk ""
+#define pv324m_m_lib "-lpv324m"
+#define pvvideoencnode_m_mk ""
+#define LIBDIR_nodes_static "                                                  "
+#define LIBDIR_audio_shared "  /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make"
+#define SOLIBDIRS_pvwmdrmdev "n"
+#define opencore_mp4local_so_name "opencore_mp4local"
+#define pvavcdecnode_y_lib ""
+#define threadsafe_callback_ao_y_lib ""
+#define pvmimeutils_m_mk "/baselibs/pv_mime_utils/build/make"
+#define pvmp4ffcomposernodeopencore_y_lib ""
+#define pvavcdecnode_y_mk ""
+#define pvjitterbuffernode_opencore_y_lib ""
+#define rdt_parser_m_mk ""
+#define omx_baseclass_y_mk ""
+#define pvmp4ffcomposeropencore_y_lib ""
+#define pvfileparserutils_m_lib "-lpvfileparserutils"
+#define pv_http_parcom_y_lib ""
+#define pvgendatastruct_m_lib "-lpvgendatastruct"
+#define omx_wmv_component_imp_m_lib "n"
+#define SOLIBS_opencore_rtspreg "-lpvrtspreginterface"
+#define protocolenginenode_m_mk ""
+#define pvmedialayernode_y_lib ""
+#define pvdivxffrecognizer_m_mk ""
+#define SOLIBDIRS_omx_avcenc_sharedlibrary "/codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/video/avc_h264/enc/build/make"
+#define pvdownloadmanagernode_m_mk "/nodes/pvdownloadmanagernode/build/make"
+#define pvid3parcom_y_mk ""
+#define pvstreamingmanagernode_m_mk ""
+//
+// That's all, folks!
diff --git a/build_config/opencore_dynamic/pv_config.mk b/build_config/opencore_dynamic/pv_config.mk
new file mode 100644
index 0000000..942aa1c
--- /dev/null
+++ b/build_config/opencore_dynamic/pv_config.mk
@@ -0,0 +1,1445 @@
+#
+# Automatically generated, don't edit
+#
+# At: Fri, 16 Jan 2009 06:11:38 +0000
+
+#
+# PV Code Base Configuration System
+#
+
+#
+# Menu for selecting supported features
+#
+module_support=y
+
+
+#
+# Menu for configuring runtime loadable modules
+#
+pv_so=n
+pvsplit_so=y
+streaming_support=y
+
+#
+# Menu for selecting streaming features
+#
+rtsp_support=y
+asf_streaming_support=n
+
+download_support=y
+mp4local_support=y
+asflocal_support=n
+janus_support=n
+wmdrmplat_support=n
+wmdrmdev_support=n
+mtp_db_support=n
+
+
+#
+# Menu for configuring Baselibs
+#
+csprng_lib=n
+pvcrypto_lib=n
+pventropysrc_lib=n
+pvgendatastruct_lib=m
+pvmediadatastruct_lib=m
+pvmimeutils_lib=m
+threadsafe_callback_ao_lib=m
+pvthreadmessaging_lib=m
+
+
+#
+# Menu for configuring File Formats
+#
+pvasfff_lib=n
+pvmp3ff_lib=m
+pvmp4ffcomposer_lib=n
+pvmp4ffcomposeropencore_lib=m
+pvmp4ff_lib=n
+pvmp4ffopencore_lib=m
+mp4recognizer_utility_lib=m
+pvaacparser_lib=m
+pvgsmamrparser_lib=m
+pvrmff_lib=n
+pvrmffparser_lib=n
+pvfileparserutils_lib=m
+pvid3parcom_lib=m
+pvpvxparser_lib=n
+pvwav_lib=m
+pvasxparser_lib=n
+pvavifileparser_lib=m
+pvpvrff_lib=n
+asfrecognizer_utility_lib=n
+pv_divxfile_parser_lib=n
+
+
+#
+# Menu for configuring Codecs
+#
+
+#
+# Menu for configuring OMX Support
+#
+omx_mastercore_lib=m
+MAX_NUMBER_OF_OMX_CORES=10
+MAX_NUMBER_OF_OMX_COMPONENTS=50
+pv_omx=y
+omx_avc_component_lib=m
+omx_common_lib=m
+omx_m4v_component_lib=m
+omx_queue_lib=m
+omx_wmv_component_lib=n
+pvomx_proxy_lib=m
+omx_aac_component_lib=m
+omx_amr_component_lib=m
+omx_mp3_component_lib=m
+omx_wma_component_lib=n
+omx_amrenc_component_lib=m
+omx_m4venc_component_lib=m
+omx_avcenc_component_lib=m
+omx_baseclass_lib=m
+
+
+#
+# Menu for configuring audio codecs
+#
+pv_aac_dec_lib=m
+getactualaacconfig_lib=m
+pv_amr_nb_common_lib=m
+pvdecoder_gsmamr_lib=m
+pvencoder_gsmamr_lib=m
+pvamrwbdecoder_lib=m
+gsm_amr_headers_lib=m
+pvmp3_lib=m
+pvra8decoder_lib=n
+wmadecoder_lib=n
+
+
+#
+# Menu for configuring video codecs
+#
+pv_avc_common_lib=m
+pvavcdecoder_lib=m
+wmvdecoder_lib=n
+pvmp4decoder_lib=m
+rvdecoder_lib=n
+pvm4vencoder_lib=m
+pvavch264enc_lib=m
+
+
+#
+# Menu for configuring codecs utilities
+#
+m4v_config_lib=m
+pv_config_parser_lib=m
+colorconvert_lib=m
+
+
+
+#
+# Menu for configuring Nodes
+#
+
+#
+# Menu for configuring Streaming
+#
+pvstreamingmanagernode_segments_lib=m
+
+#
+# Menu for configuring Streaming Features
+#
+mshttp_support=n
+rtspunicast_support=y
+unicastpvr_support=n
+broadcastpvr_support=n
+pvrfileplayback_support=n
+
+pvstreamingmanagernode_lib=n
+pvstreamingmanagernode_3gpp_lib=n
+pvmedialayernode_lib=m
+pvmedialayernode_opencore_lib=n
+pvjitterbuffernode_lib=m
+pvjitterbuffernode_opencore_lib=n
+
+
+#
+# Menu for configuring Download
+#
+pvdownloadmanagernode_lib=m
+
+#
+# Menu for configuring downloadmanager features
+#
+PVMF_DOWNLOADMANAGER_SUPPORT_PVX=n
+PVMF_DOWNLOADMANAGER_SUPPORT_PPB=y
+PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE=n
+PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB=13
+ENABLE_LARGE_MBDS_CACHE_SIZE=n
+
+
+
+#
+# Menu for configuring ProtocolEngine
+#
+pvprotocolenginenode_segments_lib=m
+pvprotocolenginenode_lib=n
+
+#
+# Menu for configuring ProtocolEngine Features
+#
+ps_support=y
+pdl_support=y
+ftdl_support=n
+http_support=n
+
+
+pvfileoutputnode_lib=m
+pvmediaoutputnode_lib=m
+pvsocketnode_lib=m
+pvavcdecnode_lib=n
+pvvideodecnode_lib=n
+pvwavffparsernode_lib=m
+pvwmadecnode_lib=n
+pvwmvdecnode_lib=n
+pvomxencnode_lib=m
+pvomxaudiodecnode_lib=m
+pvomxbasedecnode_lib=m
+pvomxvideodecnode_lib=m
+aacdecnode_lib=n
+pvaacffparsernode_lib=m
+gsmamrdecnode_lib=n
+pvamrffparsernode_lib=m
+pvasfffparsernode_lib=n
+mp3decnode_lib=n
+pvmp3ffparsernode_lib=m
+pvmp4ffparsernode_lib=n
+pvmp4ffparsernodeopencore_lib=m
+pvrvdecnode_lib=n
+pvra8decnode_lib=n
+pvrmffparsernode_lib=n
+pvrtppacketsourcenode_lib=n
+nodes_common_headers_lib=m
+pvamrencnode_lib=n
+pvmediainputnode_lib=m
+pvmp4ffcomposernode_lib=n
+pvmp4ffcomposernodeopencore_lib=m
+pvvideoencnode_lib=n
+pvavcencnode_lib=n
+pvpvr_lib=n
+pvpvrnode_lib=n
+pvcommsionode_lib=m
+pvclientserversocketnode_lib=m
+pvloopbacknode_lib=m
+pvvideoparsernode_lib=m
+pvdummyinputnode_lib=m
+pvdummyoutputnode_lib=m
+pvdivxffparsernode_lib=n
+
+
+#
+# Menu for configuring Oscl
+#
+build_oscl=m
+unit_test_lib=y
+
+
+#
+# Menu for configuring Protocols
+#
+
+#
+# Menu for configuring Value Adds for 2way
+#
+twoway_value_add_config=y
+PV_2WAY_VALUE_ADD_NONE=y
+
+pv_http_parcom_lib=m
+pvlatmpayloadparser_lib=m
+sdp_common=m
+
+#
+# Menu for configuring SDPParser
+#
+sdp_default=n
+sdp_opencore=m
+
+rdt_parser_lib=n
+pv_rtsp_parcom_lib=m
+pvrtsp_cli_eng_node_lib=n
+pvrtsp_cli_eng_node_3gpp_lib=n
+pvrtsp_cli_eng_node_opencore_lib=m
+rtppayloadparser_lib=m
+
+#
+# Menu for rtppayload parser plugins
+#
+rfc_2429=y
+rfc_3016=y
+rfc_3267=y
+rfc_3640=y
+rfc_3984=y
+asf_payload=n
+realmedia_payload=n
+
+rtprtcp_lib=m
+pv324m_lib=m
+pv324m_common_headers_lib=m
+pvgeneraltools_lib=m
+
+
+#
+# Menu for configuring Pvmi
+#
+
+#
+# Menu for configuring Recognizers
+#
+pvmfrecognizer_lib=m
+pvaacffrecognizer_lib=m
+pvamrffrecognizer_lib=m
+pvoma1ffrecognizer_lib=n
+pvasfffrecognizer_lib=n
+pvmp3ffrecognizer_lib=m
+pvmp4ffrecognizer_lib=m
+pvwavffrecognizer_lib=m
+pvrmffrecognizer_lib=n
+pvdivxffrecognizer_lib=n
+
+
+#
+# Menu for configuring Content Policy Manager
+#
+cpm_lib=m
+passthru_oma1_lib=m
+pvjanusplugin_lib=n
+cpm_headers_lib=m
+pvoma1lockstream_lib=n
+
+
+#
+# Menu for configuring Media IO
+#
+pvmiofileinput_lib=m
+pvmiofileoutput_lib=m
+pvmioaviwavfileinput_lib=m
+pvmio_comm_loopback_lib=m
+
+
+#
+# Menu for configuring PacketSources
+#
+packetsources_default_lib=n
+
+#
+# Menu for configuring PacketSource Plugins
+#
+optimized_bcast_ps_support=n
+standard_bcast_ps_support=n
+
+
+pvmf_lib=m
+realaudio_deinterleaver_lib=n
+pvdbmanager_lib=n
+
+
+#
+# Menu for configuring Engines
+#
+
+#
+# Menu for configuring Player
+#
+pvplayer_engine_lib=m
+
+#
+# Menu for player engine tunables
+#
+PVPLAYERENGINE_CONFIG_SKIPTOREQUESTEDPOS_DEF=y
+PVPLAYERENGINE_CONFIG_SYNCMARGIN_EARLY_DEF=-200
+PVPLAYERENGINE_CONFIG_SYNCMARGIN_LATE_DEF=200
+VIDEO_DEC_NODE_LOW_PRIORITY=y
+
+
+#
+# Menu for configuring player registry
+#
+BUILD_OMX_VIDEO_DEC_NODE=y
+BUILD_OMX_AUDIO_DEC_NODE=y
+BUILD_VIDEO_DEC_NODE=n
+BUILD_AVC_DEC_NODE=n
+BUILD_WMV_DEC_NODE=n
+BUILD_RV_DEC_NODE=n
+BUILD_WMA_DEC_NODE=n
+BUILD_G726_DEC_NODE=n
+BUILD_GSMAMR_DEC_NODE=n
+BUILD_AAC_DEC_NODE=n
+BUILD_MP3_DEC_NODE=n
+BUILD_RA8_DEC_NODE=n
+BUILD_MP4_FF_PARSER_NODE=n
+BUILD_AMR_FF_PARSER_NODE=y
+BUILD_AAC_FF_PARSER_NODE=y
+BUILD_MP3_FF_PARSER_NODE=y
+BUILD_WAV_FF_PARSER_NODE=y
+BUILD_ASF_FF_PARSER_NODE=n
+BUILD_RM_FF_PARSER_NODE=n
+BUILD_STREAMING_MANAGER_NODE=n
+BUILD_DOWNLOAD_MANAGER_NODE=n
+BUILD_STILL_IMAGE_NODE=n
+BUILD_MP4_FF_REC=n
+BUILD_ASF_FF_REC=n
+BUILD_OMA1_FF_REC=n
+BUILD_AAC_FF_REC=y
+BUILD_RM_FF_REC=n
+BUILD_MP3_FF_REC=y
+BUILD_WAV_FF_REC=y
+BUILD_AMR_FF_REC=y
+
+
+
+#
+# Menu for configuring Author
+#
+pvauthorengine_lib=m
+
+
+#
+# Menu for configuring pv2way
+#
+pv2wayengine_lib=m
+
+engines_common_headers_lib=m
+pvframemetadatautility_lib=m
+
+
+#
+# Menu for configuring Extern_libs
+#
+pvmtp_engine_lib=n
+pvsqlite_lib=n
+pvwmdrm_lib=n
+wmdrm_config=n
+
+
+#
+# Derived symbols
+#
+pvmediaoutputnode_y_mk=""
+LIBS_omxenc_shared="-lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib"
+pvavcencnode_y_lib=""
+pventropysrc_y_lib=""
+pvjitterbuffernode_y_mk=""
+pvvideoencnode_y_mk=""
+pvamrwbdecoder_imp_m_mk=""
+protocolenginenode_segments_m_lib="-lprotocolenginenode"
+aacdecnode_m_mk=""
+pvclientserversocketnode_y_lib=""
+pvencoder_gsmamr_y_lib=""
+pvstreamingmanagernode_m_lib=""
+pvmedialayernode_m_mk="/nodes/streaming/medialayernode/build/make"
+pvpvr_y_mk=""
+pvmp4ffcomposernode_m_lib=""
+pvwmdrmplatinterface_m_lib=""
+omx_amrenc_component_m_mk="/codecs_v2/omx/omx_amrenc/build/make_multithreaded"
+sdp_common_m_mk="/protocols/sdp/common/build/make"
+sdp_parser_mksegment_opencore="sdp_opencore.mk"
+pvloopbacknode_y_mk=""
+pvrtspreginterface_m_mk="/modules/linux_rtsp/node_registry/build/make"
+LIBDIR_oscl_static=" /oscl/unit_test/build/make"
+SOLIBDIRS_omx_m4venc_sharedlibrary="/codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/video/m4v_h263/enc/build/make"
+pvrmff_m_lib=""
+pvjitterbuffernode_plugins_pvasfstreaming="jb_asf.mk"
+omx_wmv_component_y_lib=""
+pvwmdrm_m_mk=""
+omx_amrenc_component_m_lib="-lomx_amrenc_component_lib"
+pvdummyinputnode_y_mk=""
+pvfileparserutils_y_mk=""
+pvrmffparser_m_lib=""
+pvm4vencoder_m_mk="/codecs_v2/video/m4v_h263/enc/build/make"
+LIBDIR_omxdecimp_shared=""
+pv_aac_dec_y_mk=""
+DYNAMIC_LOAD_OMX_WMV_COMPONENT=0
+SOLIBS_omx_avcdec_sharedlibrary="-lomx_avc_component_lib -lpvavcdecoder"
+MODS_omx_aacdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common"
+rvdecoder_m_lib=""
+pvmimeutils_y_lib=""
+pvavch264enc_m_lib="-lpvavch264enc"
+pvmf_m_mk="/pvmi/pvmf/build/make"
+pv2wayengine_m_lib="-lpv2wayengine"
+pvrtspreginterface_m_lib="-lpvrtspreginterface"
+pvomxaudiodecnode_y_mk=""
+DYNAMIC_LOAD_OMX_AAC_COMPONENT=1
+SOLIBS_omx_wmvdec_sharedlibrary=" "
+pvamrffrecognizer_m_lib="-lpvamrffrecognizer"
+pvgsmamrparser_m_lib="-lpvgsmamrparser"
+LIBS_codecs_v2_static="                                   "
+omx_wmv_component_m_mk=""
+DYNAMIC_LOAD_OMX_AMR_COMPONENT=1
+pvmp4ffcomposernode_m_mk=""
+pv_divxfile_parser_m_lib=""
+omx_mp3_component_m_lib="-lomx_mp3_component_lib"
+pvaacparser_m_lib="-lpvaacparser"
+mp4recognizer_utility_m_lib="-lmp4recognizer_utility"
+SOLIBDIRS_pvjanus=" "
+USING_OMX=1
+pvmediainputnode_m_lib="-lpvmediainputnode"
+protocolenginenode_segments_m_mk="/nodes/pvprotocolenginenode/build/make_segments"
+asfrecognizer_utility_m_lib=""
+pvmp4ff_m_mk=""
+pvdecoder_gsmamr_y_mk=""
+pvavifileparser_m_lib="-lpvavifileparser"
+LIBS_omxencimp_static=""
+LIBS_codecs_v2_shared="-lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib  -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface   -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3  -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder  -lpvmp4decoder  -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert"
+omx_avcenc_component_m_lib="-lomx_avcenc_component_lib"
+pvavifileparser_y_mk=""
+MODS_opencore_2way="-lopencore_common"
+omx_m4v_component_y_lib=""
+omx_baseclass_y_lib=""
+LIBS_packetsources_static="n"
+pvdecoder_gsmamr_imp_m_lib=""
+LIBDIR_fileformats_shared="/fileformats/common/parser/build/make /fileformats/id3parcom/build/make  /fileformats/wav/parser/build/make  /fileformats/avi/parser/build/make  /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make    /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make  /fileformats/mp4/composer/build_opencore/make   "
+pvdummyoutputnode_m_mk="/nodes/pvdummyoutputnode/build/make"
+pvasfff_m_lib=""
+pvrmff_m_mk=""
+csprng_m_lib=""
+pv_avc_common_lib_y_mk=""
+pvavcdecoder_m_mk="/codecs_v2/video/avc_h264/dec/build/make"
+SOLIBDIRS_pvasfstreaming=" /nodes/streaming/streamingmanager/build/make_segments /nodes/streaming/jitterbuffernode/build/make /nodes/streaming/medialayernode/build/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /nodes/pvprotocolenginenode/build/make_segments"
+LIBDIR_extern_libs_shared="    "
+protocolenginenode_y_mk=""
+omx_mastercore_m_mk="/codecs_v2/omx/omx_mastercore/build/make_multithreaded"
+m4v_config_m_mk="/codecs_v2/utilities/m4v_config_parser/build/make"
+pvcrypto_y_lib=""
+LIBDIR_packetsources_shared="n"
+pvfileparserutils_y_lib=""
+pvasfcommon_so_name=""
+LIBDIR_omxjoint_static="   "
+LIBDIR_video_static="      "
+wmadecoder_m_lib=""
+pv_amr_nb_common_lib_y_lib=""
+pventropysrc_m_mk=""
+asfrecognizer_utility_y_mk=""
+pv_amr_nb_common_lib_m_lib="-lpv_amr_nb_common_lib"
+pv_aac_dec_plugins="aacdec_util.mk"
+wmvdecoder_y_mk=""
+pvmp3ffrecognizer_y_mk=""
+REGISTER_OMX_H263ENC_COMPONENT=1
+LIBDIR_codecs_v2_shared="/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded  /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make   /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make  /codecs_v2/video/m4v_h263/dec/build/make  /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make"
+omx_amrenc_component_imp_m_mk=""
+omx_avc_component_m_mk="/codecs_v2/omx/omx_h264/build/make_multithreaded"
+pvdecoder_gsmamr_m_lib="-lpvdecoder_gsmamr"
+pvmf_y_mk=""
+omx_mastercore_m_lib="-lomx_mastercore_lib"
+getactualaacconfig_imp_m_lib="-lgetactualaacconfig"
+pvfileoutputnode_y_mk=""
+LIBDIR_recognizer_static="         "
+SOLIBS_pvwmdrmdev="n"
+realaudio_deinterleaver_y_lib=""
+cpm_m_lib="-lcpm"
+pvmp4ffcomposeropencore_m_lib="-lpvmp4ffcomposer"
+LIBDIR_engines_shared="/engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make"
+omx_amr_component_imp_m_lib=""
+pvdummyoutputnode_m_lib="-lpvdummyoutputnode"
+pvmp4ffcomposeropencore_m_mk="/fileformats/mp4/composer/build_opencore/make"
+SOLIBS_opencore_author=" -lpvmp4ffcomposer  -lpvmp4ffcomposernode -lpvauthorengine"
+pvmp3ff_y_lib=""
+pv324m_plugins="default_support.mk"
+MODS_omx_wmadec_sharedlibrary="-lomx_sharedlibrary -lopencore_common"
+omx_m4vdec_sharedlibrary_so_name="omx_m4vdec_sharedlibrary"
+pvrtppacketsourcenode_y_mk=""
+pvmiofileinput_y_lib=""
+pvavcdecoder_m_lib="-lpvavcdecoder"
+LIBS_fileformats_static="                  "
+SOLIBDIRS_opencore_mp4localreg="/modules/linux_mp4/node_registry/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make"
+pvamrffrecognizer_y_mk=""
+REGISTER_OMX_WMV_COMPONENT=0
+omx_m4v_component_m_lib="-lomx_m4v_component_lib"
+pvmp3ffparsernode_y_mk=""
+pventropysrc_m_lib=""
+pvsdpparser_y_lib=""
+SOLIBDIRS_opencore_author=" /fileformats/mp4/composer/build_opencore/make  /nodes/pvmp4ffcomposernode/build_opencore/make /engines/author/build/make"
+packetsources_default_y_lib=""
+LIBDIR_baselibs_shared="   /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make"
+pvomx_proxy_m_mk="/codecs_v2/omx/omx_proxy/build/make"
+LIBS_recognizer_shared="-lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer   -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer  "
+pvasf_streaming_so_name=""
+pvsocketnode_m_mk="/nodes/pvsocketnode/build/make"
+pvstreamingmanagernode_3gpp_m_mk=""
+pv2wayengine_y_lib=""
+pvwmadecnode_y_mk=""
+pvaacffrecognizer_y_lib=""
+pvpvrff_m_mk=""
+pvomxvideodecnode_y_lib=""
+LIBS_omxencimp_shared=""
+pvdownloadmanagernode_m_lib="-lpvdownloadmanagernode"
+pvdivxffrecognizer_m_lib=""
+pvmp4ffrecognizer_m_lib="-lpvmp4ffrecognizer"
+opencore_player_so_name="opencore_player"
+pvvideoparsernode_y_mk=""
+pvmp4ffcomposer_m_lib=""
+dl_common_mk="pe_dl_common.mk"
+pvjitterbuffernode_opencore_m_mk=""
+pvmp4ffcomposer_y_lib=""
+threadsafe_callback_ao_m_lib="-lthreadsafe_callback_ao"
+pvmp4ffopencore_m_lib="-lpvmp4ff"
+pvencoder_gsmamr_m_mk="/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make"
+sdp_common_y_mk=""
+pvdecoder_gsmamr_m_mk="/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make"
+MODS_pvwmdrmdev="-lopencore_player -lopencore_common"
+pvmio_comm_loopback_m_lib="-lpvmio_comm_loopback"
+pvrtppacketsourcenode_y_lib=""
+pvasfstreaminginterface_m_mk=""
+pvwmdrmdev_so_name=""
+rvdecoder_y_mk=""
+pvavifileparser_m_mk="/fileformats/avi/parser/build/make"
+pvjitterbuffernode_opencore_y_mk=""
+gsm_amr_headers_m_mk="/codecs_v2/audio/gsm_amr/common/dec/build/make"
+pvaacparser_y_mk=""
+pvaacffparsernode_m_mk="/nodes/pvaacffparsernode/build/make"
+LIBS_extern_libs_shared="    "
+LIBDIR_media_io_static="   "
+getactualaacconfig_m_mk="/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make"
+colorconvert_y_mk=""
+pvgendatastruct_y_lib=""
+LIBDIR_pvmi_shared="/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make   /pvmi/content_policy_manager/plugins/common/build/make  /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make   /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make    /pvmi/pvmf/build/make  "
+pvoma1ffrecognizer_m_mk=""
+csprng_y_mk=""
+pvdivxffparsernode_y_lib=""
+pvauthorengine_y_lib=""
+pvrtspinterface_m_lib="-lpvrtspinterface"
+pvmp3ff_y_mk=""
+pv_aac_dec_imp_m_lib=""
+rfc_3016_mk="rfc_3016.mk"
+pvwmdrm_so_name=""
+pvavcencnode_m_mk=""
+pvasflocalpbinterface_m_mk=""
+pvasxparser_y_lib=""
+pvdivxffparsernode_m_mk=""
+pvmp4decoder_m_mk="/codecs_v2/video/m4v_h263/dec/build/make"
+rdt_parser_y_lib=""
+pvvideodecnode_m_mk=""
+pvmimeutils_y_mk=""
+omx_m4venc_component_imp_m_mk=""
+pvwavffrecognizer_m_lib="-lpvwavffrecognizer"
+omx_amrenc_sharedlibrary_so_name="omx_amrenc_sharedlibrary"
+pvrtsp_cli_eng_node_y_lib=""
+gsmamrdecnode_m_lib=""
+pvencoder_gsmamr_imp_m_lib=""
+pvmp4ff_y_lib=""
+pvamrffparsernode_y_mk=""
+SOLIBDIRS_omx_wmadec_sharedlibrary=" "
+wmadecoder_y_mk=""
+SOLIBS_pvjanus=" "
+pvmf_m_lib="-lpvmf"
+LIBDIR_protocols_static="             "
+ps_support_mk="pe_ps.mk"
+pvavcdecnode_m_mk=""
+pvra8decnode_m_lib=""
+LIBDIR_codecs_utilities_shared="/codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make"
+LIBS_omxenc_static="  "
+broadcastpvr_support_mk=""
+pvstreamingmanagernode_y_mk=""
+pvmp4ffopencore_y_lib=""
+protocolenginenode_m_lib=""
+SOLIBS_opencore_mp4localreg="-lpvmp4reginterface -lpvmp4ffrecognizer"
+omx_m4venc_component_y_lib=""
+pvomxvideodecnode_m_lib="-lpvomxvideodecnode"
+omx_wma_component_m_lib=""
+pvpvrnode_m_lib=""
+pv_avc_common_lib_m_lib="-lpv_avc_common_lib"
+pvpvrff_m_lib=""
+pvframemetadatautility_y_lib=""
+pvmio_comm_loopback_m_mk="/pvmi/media_io/pvmio_comm_loopback/build/make"
+LIBS_baselibs_shared="   -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging"
+omx_avcenc_component_imp_m_mk=""
+omx_amr_component_m_mk="/codecs_v2/omx/omx_amr/build/make_multithreaded"
+pvwmdrmplat_so_name=""
+pv_omx_interface_m_mk="/codecs_v2/omx/omx_sharedlibrary/interface/build/make"
+pvdummyinputnode_m_mk="/nodes/pvdummyinputnode/build/make"
+pvasxparser_m_mk=""
+omx_avc_component_imp_m_lib=""
+pvavch264enc_y_lib=""
+pvmp3ff_m_lib="-lpvmp3ff"
+oscl_m_mk="/oscl"
+pvrvdecnode_y_lib=""
+pvclientserversocketnode_m_mk="/nodes/pvclientserversocketnode/build/make"
+PROTOCOL_PLUGINS="pe_dl_common.mk pe_ps.mk pe_pdl.mk  "
+LIBDIR_nodes_shared="/nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make  /nodes/pvprotocolenginenode/build/make_segments   /nodes/pvwavffparsernode/build/make   /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make  /nodes/pvaacffparsernode/build/make  /nodes/pvamrffparsernode/build/make   /nodes/pvmp3ffparsernode/build/make  /nodes/pvmp4ffparsernode/build_opencore/make     /nodes/common/build/make  /nodes/pvmediainputnode/build/make_pvauthor  /nodes/pvmp4ffcomposernode/build_opencore/make     /nodes/pvdownloadmanagernode/build/make   /nodes/streaming/streamingmanager/build/make_segments   /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /nodes/streaming/medialayernode/build/make  /nodes/streaming/jitterbuffernode/build/make  /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvvideoparsernode/build/make /nodes/pvdummyinputnode/build/make /nodes/pvdummyoutputnode/build/make "
+pvavcdecoder_imp_m_mk=""
+pvwmdrmdevinterface_m_lib=""
+pvdownloadinterface_m_lib="-lpvdownloadinterface"
+pvasfff_y_mk=""
+pvstreamingmanagernode_segments_y_lib=""
+pv_divxfile_parser_y_mk=""
+omx_amr_component_imp_m_mk=""
+csprng_y_lib=""
+getactualaacconfig_for_static_m_lib=""
+SOLIBS_omx_aacdec_sharedlibrary="-lomx_aac_component_lib -lpv_aac_dec"
+omx_queue_m_lib="-lomx_queue_lib"
+nodes_common_headers_y_mk=""
+pvaacparser_y_lib=""
+SOLIBDIRS_omx_sharedlibrary="/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_sharedlibrary/interface/build/make"
+omx_avcenc_component_m_mk="/codecs_v2/omx/omx_h264enc/build/make_multithreaded"
+wmvdecoder_y_lib=""
+pvamrffparsernode_y_lib=""
+cml2_support_flag="USE_CML2_CONFIG"
+MODS_opencore_rtsp="-lopencore_net_support -lopencore_player -lopencore_common"
+pvclientserversocketnode_m_lib="-lpvclientserversocketnode"
+pvsqlite_m_mk=""
+REGISTER_OMX_AMR_COMPONENT=1
+DYNAMIC_LOAD_OMX_MP3_COMPONENT=1
+omx_aac_component_y_lib=""
+pvavcdecoder_y_mk=""
+getactualaacconfig_y_lib=""
+pvrtsp_cli_eng_node_opencore_y_mk=""
+SOLIBDIRS_pvwmdrm="   "
+pvoma1lockstream_y_mk=""
+omx_amrenc_component_y_mk=""
+LIBS_omxjoint_static="   "
+pvauthorengine_m_lib="-lpvauthorengine"
+standard_bcast_ps_mk=""
+pvmediaoutputnode_y_lib=""
+pv2wayengine_y_mk=""
+pvmio_comm_loopback_y_mk=""
+pvmediaoutputnode_m_lib="-lpvmediaoutputnode"
+SOLIBS_pvasfstreamingreg="n"
+pvomxaudiodecnode_m_lib="-lpvomxaudiodecnode"
+pvid3parcom_y_lib=""
+pvwavffparsernode_y_lib=""
+pvrtsp_cli_eng_node_opencore_y_lib=""
+pvra8decoder_m_lib=""
+pvcommsionode_m_lib="-lpvcommsionode"
+DYNAMIC_LOAD_OMX_M4VENC_COMPONENT=1
+pv324m_y_mk=""
+LIBDIR_omxencimp_static=""
+pvrmffparser_y_mk=""
+pvmp4ffparsernode_y_mk=""
+pvmp4ffrecognizer_y_mk=""
+pvstreamingmanagernode_3gpp_y_mk=""
+pvlatmpayloadparser_y_mk=""
+protocolenginenode_segments_y_lib=""
+MODS_omx_m4venc_sharedlibrary="-lomx_sharedlibrary -lopencore_common "
+LIBDIR_omxdec_static="      "
+pvthreadmessaging_m_lib="-lpvthreadmessaging"
+pvmp4ff_y_mk=""
+pvpvr_m_mk=""
+MODS_omx_wmvdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common"
+omx_m4v_component_m_mk="/codecs_v2/omx/omx_m4v/build/make_multithreaded"
+pvmediaoutputnode_m_mk="/nodes/pvmediaoutputnode/build/make"
+pvvideoparsernode_m_mk="/nodes/pvvideoparsernode/build/make"
+LIBDIR_omxencimp_shared=""
+pvwmdrmplatinterface_m_mk=""
+config_asf_mk=""
+pvvideodecnode_y_lib=""
+pvmp4ffparsernodeopencore_y_lib=""
+SOLIBS_omx_m4venc_sharedlibrary="-lomx_m4venc_component_lib -lpvm4vencoder"
+passthru_oma1_m_mk="/pvmi/content_policy_manager/plugins/oma1/passthru/build/make"
+packetsources_default_plugins=" "
+mp3decnode_y_mk=""
+omx_queue_y_lib=""
+pvmp3_imp_m_mk=""
+cpm_headers_y_mk=""
+pvdownloadinterface_m_mk="/modules/linux_download/core/build/make"
+pvwavffrecognizer_m_mk="/pvmi/recognizer/plugins/pvwavffrecognizer/build/make"
+pv_aac_dec_imp_m_mk=""
+pvthreadmessaging_y_mk=""
+pvasfff_y_lib=""
+pvdownloadreginterface_m_lib="-lpvdownloadreginterface"
+pvjanus_so_name=""
+pvpvr_m_lib=""
+omx_m4v_component_imp_m_mk=""
+rtspunicast_support_mk="rtspunicast.mk"
+mp3decnode_y_lib=""
+pvmfrecognizer_m_mk="/pvmi/recognizer/build/make"
+LIBDIR_media_io_shared="/pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /pvmi/media_io/pvmio_comm_loopback/build/make"
+unicastpvr_support_mk=""
+pvamrffparsernode_m_mk="/nodes/pvamrffparsernode/build/make"
+pvmp3ffrecognizer_m_lib="-lpvmp3ffrecognizer"
+LIBS_omxdecimp_shared=""
+pvasfffparsernode_y_mk=""
+http_support_mk=""
+REGISTER_OMX_AVCENC_COMPONENT=1
+pv_avc_common_lib_m_mk="/codecs_v2/video/avc_h264/common/build/make"
+pvdummyoutputnode_y_mk=""
+MODS_opencore_download="-lopencore_net_support -lopencore_player -lopencore_common"
+pvasxparser_y_mk=""
+pvstreamingmanagernode_segments_m_lib="-lpvstreamingmanagernode"
+pvdecoder_gsmamr_imp_m_mk=""
+pvomxbasedecnode_y_lib=""
+pvmiofileinput_m_mk="/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor"
+pvwavffparsernode_m_mk="/nodes/pvwavffparsernode/build/make"
+pvmedialayernode_opencore_y_lib=""
+LIBS_audio_static="        "
+colorconvert_m_mk="/codecs_v2/utilities/colorconvert/build/make"
+LIBDIR_omxdec_shared="/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded "
+opencore_rtsp_so_name="opencore_rtsp"
+pvwmadecnode_m_mk=""
+pvmp4ffcomposer_y_mk=""
+pvmedialayernode_m_lib="-lpvmedialayernode"
+pvomxencnode_m_lib="-lpvomxencnode"
+pvclientserversocketnode_y_mk=""
+pvdownloadmanagernode_y_lib=""
+pvmp3ffparsernode_m_mk="/nodes/pvmp3ffparsernode/build/make"
+pvdivxffrecognizer_y_lib=""
+LIBDIR_codecs_utilities_static="  "
+omx_amr_component_m_lib="-lomx_amr_component_lib"
+pvstreamingmanagernode_y_lib=""
+pvsdpparser_m_mk="/protocols/sdp/parser/build/make"
+unit_test_m_lib=""
+pvmedialayernode_opencore_y_mk=""
+pvsqlite_y_mk=""
+omx_queue_y_mk=""
+pvauthorengine_m_mk="/engines/author/build/make"
+pvgeneraltools_y_lib=""
+pvmp4interface_m_lib="-lpvmp4interface"
+MODS_pvasfstreaming="-lopencore_net_support -lopencore_player -lopencore_common -lpvasfcommon"
+pvomxvideodecnode_y_mk=""
+pv_avc_common_imp_lib_m_lib=""
+pvdivxffrecognizer_y_mk=""
+pvdbmanager_m_mk=""
+pvrtsp_cli_eng_node_3gpp_y_lib=""
+pvmediadatastruct_y_mk=""
+pvstreamingmanagernode_segments_y_mk=""
+MODS_pv=""
+pvdownloadmanagernode_y_mk=""
+pvplayer_engine_y_lib=""
+USE_LOADABLE_MODULES=y
+pvrmffrecognizer_y_mk=""
+SOLIBS_pvwmdrm="   "
+omx_sharedlibrary_so_name="omx_sharedlibrary"
+SOLIBDIRS_opencore_rtsp="/modules/linux_rtsp/core/build/make /nodes/streaming/streamingmanager/build/make_segments /protocols/rtsp_parcom/build/make /protocols/rtsp_client_engine/build_opencore/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /nodes/streaming/jitterbuffernode/build/make /nodes/streaming/medialayernode/build/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make"
+omx_avc_component_imp_m_mk=""
+omx_avcenc_component_y_lib=""
+rtprtcp_y_mk=""
+MODS_pvasfcommon="-lopencore_player -lopencore_common"
+pvrtsp_cli_eng_node_m_lib=""
+SOLIBDIRS_omx_wmvdec_sharedlibrary=" "
+pvpvxparser_m_mk=""
+pvvideoparsernode_m_lib="-lpvvideoparsernode"
+LIBDIR_module="/modules"
+pventropysrc_y_mk=""
+pvrmffparser_m_mk=""
+pv_omx_interface_m_lib="-lpv_omx_interface"
+SOLIBS_pvwmdrmplat="n"
+pvmp4ffparsernode_y_lib=""
+pvrmff_y_mk=""
+pvmp4ffcomposernode_y_mk=""
+pvm4vencoder_y_lib=""
+pvomx_proxy_y_mk=""
+pvgeneraltools_y_mk=""
+pvrmffrecognizer_m_lib=""
+pvsocketnode_y_mk=""
+pvmediainputnode_m_mk="/nodes/pvmediainputnode/build/make_pvauthor"
+pvrtsp_cli_eng_node_opencore_m_lib="-lpvrtsp_cli_eng_node"
+mp4recognizer_utility_m_mk="/fileformats/mp4/parser/utils/mp4recognizer/build/make"
+SOLIBDIRS_pv="/oscl   /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/video/avc_h264/dec/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/enc/build/make  /codecs_v2/video/m4v_h263/dec/build/make /codecs_v2/video/m4v_h263/enc/build/make  /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/colorconvert/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded  /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make /pvmi/media_io/pvmiofileoutput/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make  /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make  /fileformats/mp4/composer/build_opencore/make  /nodes/pvmp4ffcomposernode/build_opencore/make      /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvmediaoutputnode/build/make /nodes/pvfileoutputnode/build/make /fileformats/rawgsmamr/parser/build/make /nodes/pvamrffparsernode/build/make  /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make  /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /fileformats/mp3/parser/build/make  /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make    /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make        /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make     /pvmi/recognizer/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make /engines/author/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /engines/2way/build/make /fileformats/avi/parser/build/make /baselibs/thread_messaging/build/make /protocols/rtp_payload_parser/util/build/latmparser/make "
+USE_DYNAMIC_LOAD_OMX_COMPONENTS=1
+LIBDIR_omxenc_static="  "
+pv_config_parser_m_mk="/codecs_v2/utilities/pv_config_parser/build/make"
+pvamrffrecognizer_m_mk="/pvmi/recognizer/plugins/pvamrffrecognizer/build/make"
+pv_avc_common_lib_y_lib=""
+SOLIBDIRS_opencore_downloadreg="/modules/linux_download/node_registry/build/make"
+SOLIBDIRS_pvasfstreamingreg="n"
+colorconvert_m_lib="-lcolorconvert"
+pvomxaudiodecnode_y_lib=""
+pvamrwbdecoder_y_lib=""
+pvjanusplugin_y_lib=""
+rtppayloadparser_y_mk=""
+pvid3parcom_m_mk="/fileformats/id3parcom/build/make"
+wmvdecoder_imp_m_lib="n"
+pvmp4ffrecognizer_y_lib=""
+pvmtp_engine_y_mk=""
+opencore_author_so_name="opencore_author"
+omx_wma_component_y_mk=""
+LIBS_protocols_shared="-lpv_http_parcom -lpvlatmpayloadparser  -lpvsdpparser  -lpv_rtsp_parcom   -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools"
+LIBDIR_video_shared="/codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make  /codecs_v2/video/m4v_h263/dec/build/make  /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make"
+SOLIBDIRS_opencore_rtspreg="/modules/linux_rtsp/node_registry/build/make"
+omx_baseclass_m_lib="-lomx_baseclass_lib"
+config_3gpp_asf_mk=""
+pvasflocalpbreg_so_name=""
+pvdummyinputnode_m_lib="-lpvdummyinputnode"
+pvamrencnode_y_mk=""
+pvwmadecnode_y_lib=""
+pvoma1ffrecognizer_y_mk=""
+unit_test_y_mk="/oscl/unit_test/build/make"
+pvgendatastruct_m_mk="/baselibs/gen_data_structures/build/make"
+pvmiofileinput_m_lib="-lpvmiofileinput"
+realaudio_deinterleaver_y_mk=""
+pv_aac_dec_m_lib="-lpv_aac_dec"
+pvpvr_y_lib=""
+omx_queue_m_mk="/codecs_v2/omx/omx_queue/build/make"
+omx_avcenc_sharedlibrary_so_name="omx_avcenc_sharedlibrary"
+pvdummyinputnode_y_lib=""
+omx_m4v_component_y_mk=""
+DYNAMIC_LOAD_OMX_AVC_COMPONENT=1
+pvwav_y_lib=""
+pvgendatastruct_y_mk=""
+pvra8decnode_y_lib=""
+omx_common_y_lib=""
+LIBS_extern_libs_static="  "
+pvmiofileoutput_y_lib=""
+pvjitterbuffernode_plugins="jb_default.mk"
+omx_wma_component_imp_m_mk="n"
+pvmfrecognizer_y_mk=""
+protocolenginenode_plugins="pe_dl_common.mk pe_ps.mk pe_pdl.mk  "
+pvpvrnode_m_mk=""
+gsm_amr_headers_y_mk=""
+gsmamrdecnode_m_mk=""
+protocolenginenode_y_lib=""
+omx_m4venc_sharedlibrary_so_name="omx_m4venc_sharedlibrary"
+pvmedialayernode_plugins_opencore_rtsp="ml_rtsp.mk"
+pvaacffparsernode_m_lib="-lpvaacffparsernode"
+REGISTER_OMX_M4V_COMPONENT=1
+pvasfstreamingreginterface_m_lib=""
+MODS_opencore_net_support="-lopencore_common"
+cpm_y_mk=""
+pvmp3_imp_m_lib=""
+LIBDIR_cpm_shared="/pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make   /pvmi/content_policy_manager/plugins/common/build/make "
+threadsafe_callback_ao_y_mk=""
+MODS_pvjanus="-lopencore_player -lopencore_common -lpvwmdrm"
+pvstreamingmanagernode_3gpp_y_lib=""
+pvdummyoutputnode_y_lib=""
+pvm4vencoder_y_mk=""
+pvomxencnode_y_mk=""
+asfrecognizer_utility_y_lib=""
+omx_common_m_lib="-lomx_common_lib"
+pv_aac_dec_m_mk="/codecs_v2/audio/aac/dec/build/make"
+LIBS_oscl_shared="-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib"
+MODS_pvasflocalpb="-lopencore_player -lopencore_common -lpvasfcommon"
+pvframemetadatautility_m_lib="-lpvframemetadatautility"
+pvamrwbdecoder_m_lib="-lpvamrwbdecoder"
+omx_mastercore_y_lib=""
+pvmfrecognizer_y_lib=""
+pvmp3ff_m_mk="/fileformats/mp3/parser/build/make"
+rtppayloadparser_m_mk="/protocols/rtp_payload_parser/build/make"
+LIBS_engines_shared="-lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpvframemetadatautility"
+SOLIBDIRS_pvasfcommon=" "
+pvomx_proxy_y_lib=""
+pvsdpparser_m_lib=""
+omx_wmv_component_imp_m_mk="n"
+pvasfstreaminginterface_m_lib=""
+oscl_y_lib=""
+pvwmvdecnode_m_lib=""
+rtprtcp_m_mk="/protocols/rtp/build/make"
+pv_http_parcom_m_mk="/protocols/http_parcom/build/make"
+LIBDIR_omxenc_shared="/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded"
+LIBS_protocols_static="            "
+pvrtppacketsourcenode_m_mk=""
+omx_common_y_mk=""
+opencore_net_support_so_name="opencore_net_support"
+MODS_omx_avcdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common"
+aacdecnode_y_lib=""
+LIBS_nodes_static="                                                 "
+pvcommsionode_y_lib=""
+pvasfffrecognizer_m_mk=""
+pvlatmpayloadparser_y_lib=""
+MODS_omx_amrdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common"
+pvmp4ffparsernode_m_mk=""
+LIBS_video_static="      "
+rtppayloadparser_plugins_pvasfstreaming="asf_payload_parser.mk"
+SOLIBS_omx_mp3dec_sharedlibrary="-lomx_mp3_component_lib -lpvmp3"
+pvpvxparser_y_mk=""
+pvsdpparser_opencore_m_lib="-lpvsdpparser"
+realmedia_payload_mk=""
+pv_divxfile_parser_y_lib=""
+pvfileparserutils_m_mk="/fileformats/common/parser/build/make"
+omx_amr_component_y_mk=""
+pv_amr_nb_common_imp_lib_m_lib=""
+pvasfffparsernode_m_lib=""
+omx_avc_component_y_mk=""
+pvdbmanager_y_lib=""
+pvasxparser_m_lib=""
+rfc_3640_mk="rfc_3640.mk"
+pvavifileparser_y_lib=""
+pvrtsp_cli_eng_node_3gpp_y_mk=""
+pv324m_y_lib=""
+pvasflocalpbreginterface_m_lib=""
+MODS_omx_sharedlibrary="-lopencore_common"
+pvvideodecnode_y_mk=""
+pvsocketnode_y_lib=""
+pvamrffparsernode_m_lib="-lpvamrffparsernode"
+pvomxencnode_m_mk="/nodes/pvomxencnode/build/make"
+SOLIBDIRS_opencore_mp4local="/modules/linux_mp4/core/build/make  /nodes/pvmp4ffparsernode/build_opencore/make"
+omx_m4venc_component_m_lib="-lomx_m4venc_component_lib"
+pvmp4ffcomposernodeopencore_m_lib="-lpvmp4ffcomposernode"
+rfc_3267_mk="rfc_3267.mk"
+getactualaacconfig_y_mk=""
+LIBS_media_io_shared="-lpvmiofileoutput -lpvmiofileinput -lpvmioaviwavfileinput -lpvmio_comm_loopback"
+LIBS_nodes_shared="-lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode  -lprotocolenginenode   -lpvwavffparsernode   -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode  -lpvaacffparsernode  -lpvamrffparsernode   -lpvmp3ffparsernode  -lpvmp4ffparsernode      -lpvmediainputnode  -lpvmp4ffcomposernode     -lpvdownloadmanagernode   -lpvstreamingmanagernode   -lpvrtspinterface -lpvrtspreginterface -lpvmedialayernode  -lpvjitterbuffernode  -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvvideoparsernode -lpvdummyinputnode -lpvdummyoutputnode "
+LIBS_audio_shared="  -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3  -lpvencoder_gsmamr"
+pvloopbacknode_m_mk="/nodes/pvloopbacknode/build/make"
+pvvideoparsernode_y_lib=""
+pvavch264enc_m_mk="/codecs_v2/video/avc_h264/enc/build/make"
+csprng_m_mk=""
+pvmp3_y_lib=""
+pvoma1lockstream_m_lib=""
+MODS_pvasfstreamingreg="-lopencore_player -lopencore_common"
+pvmf_y_lib=""
+pvjitterbuffernode_m_mk="/nodes/streaming/jitterbuffernode/build/make"
+pvmio_comm_loopback_y_lib=""
+pvmp4decoder_imp_m_mk=""
+pv_config_parser_y_lib=""
+pvmp3ffrecognizer_y_lib=""
+pvavcdecoder_y_lib=""
+m4v_config_m_lib="-lm4v_config"
+pv_rtsp_parcom_m_lib="-lpv_rtsp_parcom"
+omx_aac_component_y_mk=""
+protocolenginenode_plugins_pvdownload="pe_ps.mk pe_pdl.mk pe_dl_common.mk"
+pvaacffrecognizer_m_lib="-lpvaacffrecognizer"
+packetsources_default_y_mk=""
+rdt_parser_m_lib=""
+pvwmvdecnode_y_lib=""
+LIBDIR_omxjointimp_static="n"
+pvmtpdb_so_name=""
+pvmioaviwavfileinput_y_lib=""
+pvdecoder_gsmamr_y_lib=""
+pvwmdrm_m_lib=""
+cpm_m_mk="/pvmi/content_policy_manager/build/make"
+omx_amrdec_sharedlibrary_so_name="omx_amrdec_sharedlibrary"
+pvoma1lockstream_m_mk=""
+pvomxbasedecnode_y_mk=""
+pvloopbacknode_y_lib=""
+realaudio_deinterleaver_m_lib=""
+pv_amr_nb_common_lib_y_mk=""
+REGISTER_OMX_AMRENC_COMPONENT=1
+SOLIBS_pvasfcommon=" "
+cpm_headers_m_mk="/pvmi/content_policy_manager/plugins/common/build/make"
+opencore_mp4localreg_so_name="opencore_mp4localreg"
+pvmp4ffrecognizer_m_mk="/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make"
+LIBS_cpm_static="   "
+SOLIBS_omx_m4vdec_sharedlibrary="-lomx_m4v_component_lib -lpvmp4decoder"
+pvid3parcom_m_lib="-lpvid3parcom"
+pvstreamingmanagernode_segments_m_mk="/nodes/streaming/streamingmanager/build/make_segments"
+pvrtsp_cli_eng_node_y_mk=""
+omx_avcenc_component_imp_m_lib=""
+pvmp4ffcomposernodeopencore_y_mk=""
+DYNAMIC_LOAD_OMX_H263ENC_COMPONENT=1
+pvasflocalpb_so_name=""
+pvsocketnode_m_lib="-lpvsocketnode"
+SOLIBDIRS_opencore_common="/oscl  /codecs_v2/omx/omx_mastercore/build/make_multithreaded              /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make   /fileformats/rawgsmamr/parser/build/make  /codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/gen_data_structures/build/make /pvmi/pvmf/build/make /nodes/pvfileoutputnode/build/make /nodes/pvmediainputnode/build/make_pvauthor /nodes/pvomxencnode/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /fileformats/avi/parser/build/make /baselibs/thread_messaging/build/make /pvmi/media_io/pvmiofileoutput/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvomxvideodecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxbasedecnode/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /fileformats/wav/parser/build/make /fileformats/common/parser/build/make /nodes/common/build/make /engines/common/build/make /pvmi/content_policy_manager/plugins/common/build/make"
+SOLIBS_opencore_common="-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib -lomx_mastercore_lib              -lpv_avc_common_lib -lpv_amr_nb_common_lib   -lpvgsmamrparser  -lgetactualaacconfig -lm4v_config -lpv_config_parser -lcolorconvert -lthreadsafe_callback_ao -lpvmediadatastruct -lpvmimeutils -lpvgendatastruct -lpvmf -lpvfileoutputnode -lpvmediainputnode -lpvomxencnode -lpvmiofileinput -lpvmioaviwavfileinput -lpvavifileparser -lpvthreadmessaging -lpvmiofileoutput -lpvmediaoutputnode -lpvomxvideodecnode -lpvomxaudiodecnode -lpvomxbasedecnode -lpvlatmpayloadparser -lpvwav -lpvfileparserutils"
+pvmp4decoder_y_lib=""
+rtprtcp_m_lib="-lrtprtcp"
+pvmimeutils_m_lib="-lpvmimeutils"
+pvasfff_m_mk=""
+pvgsmamrparser_m_mk="/fileformats/rawgsmamr/parser/build/make"
+pvframemetadatautility_y_mk=""
+pvmtp_engine_y_lib=""
+omx_mp3_component_y_lib=""
+rvdecoder_m_mk=""
+pvmedialayernode_plugins="ml_default.mk"
+pvjitterbuffernode_plugins_opencore_rtsp="jb_rtsp.mk"
+omx_mastercore_y_mk=""
+pvmp4ffcomposer_m_mk=""
+pvasflocalpbreginterface_m_mk=""
+pvasflocalpbinterface_m_lib=""
+SOLIBS_omx_amrdec_sharedlibrary="-lomx_amr_component_lib -lpvdecoder_gsmamr -lpvamrwbdecoder"
+pvra8decnode_y_mk=""
+pv324m_common_headers_m_mk="/protocols/systems/common/build/make/"
+pvwmdrmdevinterface_m_mk=""
+REGISTER_OMX_MP3_COMPONENT=1
+pvra8decoder_y_mk=""
+rtppayloadparser_plugins="rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk  "
+pvavcencnode_y_mk=""
+optimized_bcast_ps_mk=""
+pvmtp_engine_m_mk=""
+pvstreamingmanagernode_3gpp_m_lib=""
+pvplayer_engine_m_mk="/engines/player/build/make"
+LIBDIR_engines_static="    "
+LIBS_omxdec_shared="-lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib "
+LIBDIR_pvmi_static="                      "
+pvsdpparser_y_mk=""
+pv324m_common_headers_y_mk=""
+pvthreadmessaging_y_lib=""
+pvmp4decoder_y_mk=""
+pvthreadmessaging_m_mk="/baselibs/thread_messaging/build/make"
+pvmp4interface_m_mk="/modules/linux_mp4/core/build/make"
+REGISTER_OMX_AVC_COMPONENT=1
+pvaacffparsernode_y_lib=""
+SOLIBDIRS_omx_amrenc_sharedlibrary="/codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make"
+LIBS_tools_v2_shared="-lpvrtspinterface -lpvrtspreginterface   -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface  "
+SOLIBS_pvasfstreaming=" -lpvstreamingmanagernode -lpvjitterbuffernode -lpvmedialayernode -lrtppayloadparser -lrtprtcp -lprotocolenginenode"
+LIBS_pvmi_shared="-lcpm -lpassthru_oma1    -lpvmiofileoutput -lpvmiofileinput -lpvmioaviwavfileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer   -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer    -lpvmf  "
+pvmioaviwavfileinput_y_mk=""
+omx_mp3_component_imp_m_mk=""
+pvm4vencoder_imp_m_mk=""
+pvwavffrecognizer_y_mk=""
+m4v_config_y_lib=""
+pvdownloadreginterface_m_mk="/modules/linux_download/node_registry/build/make"
+pvrtppacketsourcenode_m_lib=""
+DYNAMIC_LOAD_OMX_WMA_COMPONENT=0
+omx_aac_component_imp_m_lib=""
+pvmp3_y_mk=""
+omx_wmv_component_y_mk=""
+omx_mp3_component_imp_m_lib=""
+SOLIBS_pvasflocalpb=" "
+pvrtsp_cli_eng_node_3gpp_m_lib=""
+pvwmvdecnode_y_mk=""
+pvmp4ffparsernodeopencore_m_lib="-lpvmp4ffparsernode"
+SOLIBDIRS_pvasflocalpb=" "
+passthru_oma1_y_lib=""
+pvamrencnode_m_mk=""
+SOLIBS_opencore_download="-lprotocolenginenode -lpvdownloadmanagernode -lpvdownloadinterface"
+oscllib_mk="/oscl/oscl/oscllib/build/make"
+DYNAMIC_LOAD_OMX_H263_COMPONENT=1
+pvomxencnode_y_lib=""
+omx_wma_component_imp_m_lib="n"
+getactualaacconfig_m_lib="-lgetactualaacconfig"
+sdp_parser_mksegment_default=""
+threadsafe_callback_ao_m_mk="/baselibs/threadsafe_callback_ao/build/make"
+pvasfstreamingreginterface_m_mk=""
+SOLIBDIRS_opencore_download="/nodes/pvprotocolenginenode/build/make_segments /nodes/pvdownloadmanagernode/build/make /modules/linux_download/core/build/make"
+mp3decnode_m_lib=""
+pvasf_streamingreg_so_name=""
+pvcommsionode_y_mk=""
+pvpvxparser_y_lib=""
+omx_baseclass_m_mk="/codecs_v2/omx/omx_baseclass/build/make"
+LIBDIR_oscl_shared="/oscl "
+pvencoder_gsmamr_imp_m_mk=""
+pvra8decoder_y_lib=""
+nodes_common_headers_m_mk="/nodes/common/build/make"
+LIBDIR_recognizer_shared="/pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make   /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make  "
+MODS_opencore_author="-lopencore_common"
+omx_wmv_component_m_lib=""
+MODS_pvasflocalpbreg="-lopencore_common -lpvasfcommon"
+pvrmffparsernode_m_lib=""
+pvrtsp_cli_eng_node_m_mk=""
+packetsources_default_m_mk=""
+pvaacffrecognizer_m_mk="/pvmi/recognizer/plugins/pvaacffrecognizer/build/make"
+pvoma1lockstream_y_lib=""
+LIBS_baselibs_static="       "
+pv_divxfile_parser_m_mk=""
+LIBDIR_protocols_shared="/protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make  /protocols/rtsp_parcom/build/make   /protocols/rtsp_client_engine/build_opencore/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make"
+LIBS_media_io_static="   "
+pv_avc_common_imp_lib_m_mk=""
+SOLIBDIRS_opencore_2way="/engines/2way/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /nodes/pvvideoparsernode/build/make /nodes/pvcommsionode/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make "
+pvmfrecognizer_m_lib="-lpvmfrecognizer"
+pvencoder_gsmamr_y_mk=""
+pvmedialayernode_y_mk=""
+pvoma1ffrecognizer_y_lib=""
+pvrtsp_cli_eng_node_3gpp_m_mk=""
+protocolenginenode_plugins_pvasfstreaming="pe_http.mk"
+pvdbmanager_y_mk=""
+pv_amr_nb_common_imp_lib_m_mk=""
+passthru_oma1_m_lib="-lpassthru_oma1"
+LIBDIR_extern_libs_static="  "
+pvwmdrm_y_lib=""
+opencore_common_so_name="opencore_common"
+pvmp4ffcomposernodeopencore_m_mk="/nodes/pvmp4ffcomposernode/build_opencore/make"
+pvrmff_y_lib=""
+omx_mp3_component_y_mk=""
+SOLIBS_opencore_2way="-lpv2wayengine -lpv324m -lpvvideoparsernode -lpvcommsionode -lpvmio_comm_loopback -lpvgeneraltools "
+SOLIBS_opencore_player="        -lcpm -lpassthru_oma1  -lpvid3parcom -lpvamrffparsernode -lpvamrffrecognizer -lpvmp3ff  -lpvmp3ffparsernode -lpvmp3ffrecognizer  -lpvmp4ff -lmp4recognizer_utility -lpvaacparser -lpvaacffparsernode  -lpvaacffrecognizer -lpvwavffparsernode -lpvwavffrecognizer           -lpvmfrecognizer   -lpvframemetadatautility -lpvplayer_engine"
+MODS_opencore_mp4localreg="-lopencore_player -lopencore_common"
+rdt_parser_y_mk=""
+LIBDIR_packetsources_static="n"
+SOLIBDIRS_omx_amrdec_sharedlibrary="/codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make"
+pvjanusplugininterface_m_mk=""
+pvmedialayernode_plugins_pvasfstreaming="ml_asf.mk"
+pv_rtsp_parcom_y_mk=""
+pvomxvideodecnode_m_mk="/nodes/pvomxvideodecnode/build/make"
+pvmiofileoutput_m_mk="/pvmi/media_io/pvmiofileoutput/build/make"
+aacdecnode_m_lib=""
+pvcrypto_m_mk=""
+rtppayloadparser_plugins_pvrtsp="rfc_2429.mk rfc_3016.mk rfc_3267.mk rfc_3640.mk rfc_3984.mk"
+DYNAMIC_LOAD_OMX_AVCENC_COMPONENT=1
+pvvideoencnode_m_lib=""
+USE_OMX_ENC_NODE=1
+pvamrwbdecoder_y_mk=""
+mp4recognizer_utility_y_lib=""
+pvrmffparsernode_y_lib=""
+DYNAMIC_LOAD_OMX_M4V_COMPONENT=1
+pvmp4ffparsernodeopencore_y_mk=""
+pvmp4ffopencore_y_mk=""
+LIBS_video_shared="-lpv_avc_common_lib -lpvavcdecoder  -lpvmp4decoder  -lpvm4vencoder -lpvavch264enc"
+colorconvert_y_lib=""
+pvm4vencoder_m_lib="-lpvm4vencoder"
+pv_aac_dec_y_lib=""
+omx_mp3dec_sharedlibrary_so_name="omx_mp3dec_sharedlibrary"
+omx_wma_component_m_mk=""
+SOLIBS_pvasflocalpbreg=" "
+opencore_2way_so_name="opencore_2way"
+pv_http_parcom_y_mk=""
+pvgsmamrparser_y_lib=""
+pvfileoutputnode_m_lib="-lpvfileoutputnode"
+pvmedialayernode_opencore_m_mk=""
+omx_wmvdec_sharedlibrary_so_name=""
+opencore_rtspreg_so_name="opencore_rtspreg"
+rfc_2429_mk="rfc_2429.mk"
+SOLIBDIRS_opencore_net_support="/nodes/pvsocketnode/build/make /protocols/http_parcom/build/make"
+LIBDIR_audio_static="         "
+pvoma1ffrecognizer_m_lib=""
+wmvdecoder_m_mk=""
+rtprtcp_y_lib=""
+rfc_3984_mk="rfc_3984.mk"
+LIBDIR_shared="/oscl     /baselibs/gen_data_structures/build/make /baselibs/media_data_structures/build/make /baselibs/pv_mime_utils/build/make /baselibs/threadsafe_callback_ao/build/make /baselibs/thread_messaging/build/make /codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/omx/omx_m4v/build/make_multithreaded  /codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/omx/omx_amr/build/make_multithreaded /codecs_v2/omx/omx_mp3/build/make_multithreaded  /codecs_v2/omx/omx_amrenc/build/make_multithreaded /codecs_v2/omx/omx_m4venc/build/make_multithreaded /codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make   /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make /codecs_v2/video/avc_h264/common/build/make /codecs_v2/video/avc_h264/dec/build/make  /codecs_v2/video/m4v_h263/dec/build/make  /codecs_v2/video/m4v_h263/enc/build/make /codecs_v2/video/avc_h264/enc/build/make /codecs_v2/utilities/m4v_config_parser/build/make /codecs_v2/utilities/pv_config_parser/build/make /codecs_v2/utilities/colorconvert/build/make /fileformats/common/parser/build/make /fileformats/id3parcom/build/make  /fileformats/wav/parser/build/make  /fileformats/avi/parser/build/make  /fileformats/mp3/parser/build/make /fileformats/rawaac/parser/build/make /fileformats/rawgsmamr/parser/build/make    /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/mp4/parser/build_opencore/make  /fileformats/mp4/composer/build_opencore/make    /protocols/http_parcom/build/make /protocols/rtp_payload_parser/util/build/latmparser/make /protocols/sdp/parser/build/make /protocols/sdp/common/build/make  /protocols/rtsp_parcom/build/make   /protocols/rtsp_client_engine/build_opencore/make /protocols/rtp_payload_parser/build/make /protocols/rtp/build/make /protocols/systems/3g-324m_pvterminal/build/make/ /protocols/systems/common/build/make/ /protocols/systems/tools/general/build/make /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make   /pvmi/content_policy_manager/plugins/common/build/make  /pvmi/media_io/pvmiofileoutput/build/make /pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor /pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make /pvmi/media_io/pvmio_comm_loopback/build/make /pvmi/recognizer/build/make /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make   /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make /pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make    /pvmi/pvmf/build/make        /nodes/pvfileoutputnode/build/make /nodes/pvmediaoutputnode/build/make /nodes/pvsocketnode/build/make  /nodes/pvprotocolenginenode/build/make_segments   /nodes/pvwavffparsernode/build/make   /nodes/pvomxencnode/build/make /nodes/pvomxbasedecnode/build/make /nodes/pvomxaudiodecnode/build/make /nodes/pvomxvideodecnode/build/make  /nodes/pvaacffparsernode/build/make  /nodes/pvamrffparsernode/build/make   /nodes/pvmp3ffparsernode/build/make  /nodes/pvmp4ffparsernode/build_opencore/make     /nodes/common/build/make  /nodes/pvmediainputnode/build/make_pvauthor  /nodes/pvmp4ffcomposernode/build_opencore/make     /nodes/pvdownloadmanagernode/build/make   /nodes/streaming/streamingmanager/build/make_segments   /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make /nodes/streaming/medialayernode/build/make  /nodes/streaming/jitterbuffernode/build/make  /nodes/pvcommsionode/build/make /nodes/pvclientserversocketnode/build/make /nodes/pvloopbacknode/build/make /nodes/pvvideoparsernode/build/make /nodes/pvdummyinputnode/build/make /nodes/pvdummyoutputnode/build/make  /engines/player/build/make /engines/author/build/make /engines/2way/build/make /engines/common/build/make /engines/adapters/player/framemetadatautility/build/make /modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make   /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make  "
+pdl_support_mk="pe_pdl.mk"
+wmadecoder_m_mk=""
+omx_aacdec_sharedlibrary_so_name="omx_aacdec_sharedlibrary"
+pv_so_name=""
+asf_payload_mk=""
+pvmioaviwavfileinput_m_lib="-lpvmioaviwavfileinput"
+protocolenginenode_segments_y_mk=""
+pvamrencnode_m_lib=""
+pvrvdecnode_y_mk=""
+pvmp3ffrecognizer_m_mk="/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make"
+LIBDIR_omxjoint_shared="/codecs_v2/omx/omx_common/build/make_multithreaded /codecs_v2/omx/omx_queue/build/make /codecs_v2/omx/omx_proxy/build/make /codecs_v2/omx/omx_baseclass/build/make /codecs_v2/omx/omx_mastercore/build/make_multithreaded /codecs_v2/omx/omx_sharedlibrary/interface/build/make"
+pv324m_m_mk="/protocols/systems/3g-324m_pvterminal/build/make/"
+pvavch264enc_imp_m_mk=""
+LIBS_shared="-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib    -lpvgendatastruct -lpvmediadatastruct -lpvmimeutils -lthreadsafe_callback_ao -lpvthreadmessaging -lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib  -lomx_amrenc_component_lib -lomx_m4venc_component_lib -lomx_avcenc_component_lib -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface   -lpv_aac_dec -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvdecoder_gsmamr -lpvmp3  -lpvencoder_gsmamr -lpv_avc_common_lib -lpvavcdecoder  -lpvmp4decoder  -lpvm4vencoder -lpvavch264enc -lm4v_config -lpv_config_parser -lcolorconvert -lpvfileparserutils -lpvid3parcom  -lpvwav  -lpvavifileparser  -lpvmp3ff -lpvaacparser -lpvgsmamrparser   -lmp4recognizer_utility -lpvmp4ff  -lpvmp4ffcomposer    -lpv_http_parcom -lpvlatmpayloadparser  -lpvsdpparser  -lpv_rtsp_parcom   -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpv324m -lpvgeneraltools -lcpm -lpassthru_oma1    -lpvmiofileoutput -lpvmiofileinput -lpvmioaviwavfileinput -lpvmio_comm_loopback -lpvmfrecognizer -lpvaacffrecognizer -lpvamrffrecognizer   -lpvmp3ffrecognizer -lpvmp4ffrecognizer -lpvwavffrecognizer    -lpvmf        -lpvfileoutputnode -lpvmediaoutputnode -lpvsocketnode  -lprotocolenginenode   -lpvwavffparsernode   -lpvomxencnode -lpvomxbasedecnode -lpvomxaudiodecnode -lpvomxvideodecnode  -lpvaacffparsernode  -lpvamrffparsernode   -lpvmp3ffparsernode  -lpvmp4ffparsernode      -lpvmediainputnode  -lpvmp4ffcomposernode     -lpvdownloadmanagernode   -lpvstreamingmanagernode   -lpvrtspinterface -lpvrtspreginterface -lpvmedialayernode  -lpvjitterbuffernode  -lpvcommsionode -lpvclientserversocketnode -lpvloopbacknode -lpvvideoparsernode -lpvdummyinputnode -lpvdummyoutputnode  -lpvplayer_engine -lpvauthorengine -lpv2wayengine -lpvframemetadatautility -lpvrtspinterface -lpvrtspreginterface   -lpvdownloadinterface -lpvdownloadreginterface -lpvmp4interface -lpvmp4reginterface  "
+omx_amrenc_component_y_lib=""
+pvgeneraltools_m_lib="-lpvgeneraltools"
+REGISTER_OMX_AAC_COMPONENT=1
+SOLIBDIRS_pvwmdrmplat="n"
+pvwavffparsernode_m_lib="-lpvwavffparsernode"
+LIBS_packetsources_shared="n"
+pvstreamingmanagernode_plugins_opencore_rtsp="3gpp.mk rtspunicast.mk"
+LIBS_omxjoint_shared="-lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface"
+pvasfffrecognizer_m_lib=""
+SOLIBS_pv="-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test  -loscllib  -lpv_aac_dec -lpvmp3  -lpvdecoder_gsmamr -lpvencoder_gsmamr -lpv_amr_nb_common_lib -lpvamrwbdecoder -lpvavcdecoder -lpv_avc_common_lib -lpvavch264enc  -lpvmp4decoder -lpvm4vencoder  -lgetactualaacconfig -lcolorconvert -lm4v_config -lpv_config_parser -lomx_avc_component_lib -lomx_m4v_component_lib  -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib  -lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lomx_mastercore_lib -lpv_omx_interface -lthreadsafe_callback_ao -lpvmediadatastruct -lpvmimeutils -lpvgendatastruct -lpvmf -lcpm -lpassthru_oma1 -lpvmiofileoutput -lpvfileparserutils -lpvid3parcom  -lpvmp4ff -lmp4recognizer_utility  -lpvmp4ffcomposer  -lpvmp4ffcomposernode      -lpvmediainputnode -lpvmediaoutputnode -lpvfileoutputnode -lpvgsmamrparser -lpvamrffparsernode  -lpvamrffrecognizer -lpvaacparser -lpvaacffparsernode  -lpvaacffrecognizer -lpvmp3ff  -lpvmp3ffparsernode -lpvmp3ffrecognizer    -lpvomxvideodecnode -lpvomxaudiodecnode -lpvomxbasedecnode        -lpvwavffparsernode -lpvwavffrecognizer     -lpvmfrecognizer -lpvmiofileinput -lpvmioaviwavfileinput -lpvframemetadatautility -lpvplayer_engine -lpvauthorengine -lpv324m -lpv2wayengine -lpvavifileparser -lpvthreadmessaging -lpvlatmpayloadparser "
+pvmp3ffparsernode_y_lib=""
+pvjitterbuffernode_opencore_m_lib=""
+MODS_opencore_player="-lopencore_common"
+pvjitterbuffernode_m_lib="-lpvjitterbuffernode"
+MODS_pvwmdrmplat="-lopencore_player -lopencore_common"
+pvm4vencoder_imp_m_lib=""
+cpm_y_lib=""
+omx_wmadec_sharedlibrary_so_name=""
+pvgsmamrparser_y_mk=""
+rtppayloadparser_y_lib=""
+pvra8decoder_m_mk=""
+pvrmffparser_y_lib=""
+pvmp4decoder_m_lib="-lpvmp4decoder"
+omx_avc_component_m_lib="-lomx_avc_component_lib"
+MODS_omx_avcenc_sharedlibrary="-lomx_sharedlibrary -lopencore_common "
+pvwmvdecnode_m_mk=""
+pvwav_y_mk=""
+wmadecoder_imp_m_mk="n"
+MODS_opencore_downloadreg="-lopencore_player -lopencore_common"
+pvmiofileoutput_y_mk=""
+packetsources_default_m_lib=""
+pvaacparser_m_mk="/fileformats/rawaac/parser/build/make"
+omx_aac_component_m_lib="-lomx_aac_component_lib"
+SOLIBS_omx_wmadec_sharedlibrary=" "
+SOLIBS_opencore_rtsp="-lpvrtspinterface -lpvstreamingmanagernode -lpv_rtsp_parcom -lpvrtsp_cli_eng_node -lrtppayloadparser -lrtprtcp -lpvjitterbuffernode -lpvmedialayernode  -lpvsdpparser"
+omx_amrenc_component_imp_m_lib=""
+pvjanusplugin_m_lib=""
+config_3gpp_mk="3gpp.mk"
+pvaacffrecognizer_y_mk=""
+pvvideoencnode_y_lib=""
+pvaacffparsernode_y_mk=""
+pvomx_proxy_m_lib="-lpvomx_proxy_lib"
+pvrvdecnode_m_mk=""
+pvavcdecoder_imp_m_lib=""
+pvframemetadatautility_m_mk="/engines/adapters/player/framemetadatautility/build/make"
+LIBS_omxjointimp_static="n"
+pvmediadatastruct_y_lib=""
+MODS_opencore_mp4local="-lopencore_common -lopencore_player"
+pvavch264enc_y_mk=""
+rtppayloadparser_m_lib="-lrtppayloadparser"
+pvcrypto_y_mk=""
+pvmp4ffparsernodeopencore_m_mk="/nodes/pvmp4ffparsernode/build_opencore/make"
+SOLIBDIRS_pvmtpdb="  "
+LIBDIR_codecs_v2_static="                                 "
+omx_m4v_component_imp_m_lib=""
+pvmp4ffcomposeropencore_y_mk=""
+oscl_y_mk=""
+MODS_pvmtpdb="-lopencore_player -lopencore_common -lpvwmdrm -lpvasfcommon -lpvasflocalpbreg"
+pvdivxffparsernode_y_mk=""
+LIBS_codecs_utilities_shared="-lm4v_config -lpv_config_parser -lcolorconvert"
+MODS_omx_m4vdec_sharedlibrary="-lomx_sharedlibrary -lopencore_common "
+LIBS_omxdecimp_static=""
+engines_common_headers_m_mk="/engines/common/build/make"
+pvmp4ff_m_lib=""
+pv2wayengine_m_mk="/engines/2way/build/make"
+MODS_opencore_rtspreg="-lopencore_player -lopencore_common"
+pvmtp_engine_m_lib=""
+pvdivxffparsernode_m_lib=""
+aacdecnode_y_mk=""
+pvasfffrecognizer_y_mk=""
+wmadecoder_y_lib=""
+engines_common_headers_y_mk=""
+MODS_omx_mp3dec_sharedlibrary="-lomx_sharedlibrary -lopencore_common"
+asfrecognizer_utility_m_mk=""
+oscllib_lib="-loscllib"
+pvrmffparsernode_m_mk=""
+realaudio_deinterleaver_m_mk=""
+pvauthorengine_y_mk=""
+LIBDIR_baselibs_static="       "
+pvwav_m_lib="-lpvwav"
+omx_avc_component_y_lib=""
+pvmp4decoder_imp_m_lib=""
+pv_rtsp_parcom_y_lib=""
+pvmedialayernode_opencore_m_lib=""
+pvmioaviwavfileinput_m_mk="/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make"
+omx_mp3_component_m_mk="/codecs_v2/omx/omx_mp3/build/make_multithreaded"
+pvwmdrm_y_mk=""
+LIBDIR_static=" /oscl/unit_test/build/make                                                                                                                                                              "
+SOLIBS_opencore_mp4local="-lpvmp4interface  -lpvmp4ffparsernode"
+config_3gpp_pvr_asf_mk=""
+pvavch264enc_imp_m_lib=""
+pvloopbacknode_m_lib="-lpvloopbacknode"
+LIBS_omxdec_static="         "
+pvwmadecnode_m_lib=""
+REGISTER_OMX_WMA_COMPONENT=0
+pvrmffrecognizer_m_mk=""
+SOLIBS_opencore_net_support="-lpvsocketnode -lpv_http_parcom"
+pv_http_parcom_m_lib="-lpv_http_parcom"
+pvmediadatastruct_m_lib="-lpvmediadatastruct"
+pvlatmpayloadparser_m_lib="-lpvlatmpayloadparser"
+pv_config_parser_y_mk=""
+pvstreamingmanagernode_plugins="  3gpp.mk rtspunicast.mk    "
+TARGET_shared=" opencore_common opencore_author opencore_player opencore_2way omx_sharedlibrary omx_avcdec_sharedlibrary omx_m4vdec_sharedlibrary  omx_aacdec_sharedlibrary omx_amrdec_sharedlibrary omx_mp3dec_sharedlibrary  omx_avcenc_sharedlibrary omx_m4venc_sharedlibrary omx_amrenc_sharedlibrary opencore_net_support opencore_downloadreg opencore_download opencore_rtspreg opencore_rtsp      opencore_mp4localreg opencore_mp4local     "
+pvsdpparser_opencore_y_lib=""
+omx_aac_component_m_mk="/codecs_v2/omx/omx_aac/build/make_multithreaded"
+LIBS_oscl_static=" -lunit_test"
+pvomxbasedecnode_m_lib="-lpvomxbasedecnode"
+pvfileoutputnode_m_mk="/nodes/pvfileoutputnode/build/make"
+wmadecoder_imp_m_lib="n"
+pv_rtsp_parcom_m_mk="/protocols/rtsp_parcom/build/make"
+ftdl_support_mk=""
+omx_wma_component_y_lib=""
+pv_config_parser_m_lib="-lpv_config_parser"
+m4v_config_y_mk=""
+pvcrypto_m_lib=""
+SOLIBDIRS_omx_avcdec_sharedlibrary="/codecs_v2/omx/omx_h264/build/make_multithreaded /codecs_v2/video/avc_h264/dec/build/make"
+LIBS_fileformats_shared="-lpvfileparserutils -lpvid3parcom  -lpvwav  -lpvavifileparser  -lpvmp3ff -lpvaacparser -lpvgsmamrparser   -lmp4recognizer_utility -lpvmp4ff  -lpvmp4ffcomposer   "
+gsmamrdecnode_y_mk=""
+LIBS_engines_static="   "
+pvjanusplugin_m_mk=""
+LIBS_static=" -lunit_test                                                                                                                                                           "
+pvsqlite_y_lib=""
+pvasfffparsernode_y_lib=""
+pvmp3_m_lib="-lpvmp3"
+SOLIBDIRS_opencore_player="        /pvmi/content_policy_manager/build/make /pvmi/content_policy_manager/plugins/oma1/passthru/build/make  /fileformats/id3parcom/build/make /nodes/pvamrffparsernode/build/make /pvmi/recognizer/plugins/pvamrffrecognizer/build/make /fileformats/mp3/parser/build/make  /nodes/pvmp3ffparsernode/build/make /pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make  /fileformats/mp4/parser/build_opencore/make /fileformats/mp4/parser/utils/mp4recognizer/build/make /fileformats/rawaac/parser/build/make /nodes/pvaacffparsernode/build/make  /pvmi/recognizer/plugins/pvaacffrecognizer/build/make /nodes/pvwavffparsernode/build/make /pvmi/recognizer/plugins/pvwavffrecognizer/build/make           /pvmi/recognizer/build/make   /engines/adapters/player/framemetadatautility/build/make /engines/player/build/make"
+pvfileoutputnode_y_lib=""
+pvstreamingmanagernode_plugins_pvasfstreaming="asf.mk mshttp.mk"
+omx_avcdec_sharedlibrary_so_name="omx_avcdec_sharedlibrary"
+pvsdpparser_plugins=" sdp_opencore.mk"
+LIBS_recognizer_static="         "
+pvencoder_gsmamr_m_lib="-lpvencoder_gsmamr"
+SOLIBS_omx_amrenc_sharedlibrary="-lomx_amrenc_component_lib -lpvencoder_gsmamr"
+pvplayer_engine_m_lib="-lpvplayer_engine"
+pvpvxparser_m_lib=""
+pvmp3ffparsernode_m_lib="-lpvmp3ffparsernode"
+passthru_oma1_y_mk=""
+pvmp4ffcomposernode_y_lib=""
+gsmamrdecnode_y_lib=""
+LIBDIR_cpm_static="    "
+pvrtspinterface_m_mk="/modules/linux_rtsp/core/build/make"
+wmvdecoder_m_lib=""
+opencore_downloadreg_so_name="opencore_downloadreg"
+omx_avcenc_component_y_mk=""
+pvra8decnode_m_mk=""
+pvamrwbdecoder_imp_m_lib=""
+oscl_m_lib="-losclbase -losclerror -losclmemory -losclproc -losclregcli -losclregserv -losclutil -losclio -lunit_test"
+CONFIG_FLAGS="USE_CML2_CONFIG"
+pvomxbasedecnode_m_mk="/nodes/pvomxbasedecnode/build/make"
+SOLIBDIRS_pvasflocalpbreg=" "
+pvasfffrecognizer_y_lib=""
+mp4recognizer_utility_y_mk=""
+pvmediainputnode_y_mk=""
+REGISTER_OMX_H263_COMPONENT=1
+pvmp3_m_mk="/codecs_v2/audio/mp3/dec/build/make"
+LIBS_codecs_utilities_static="  "
+LIBDIR_omxjointimp_shared="/codecs_v2/omx/omx_mastercore/build/make_multithreaded"
+DRMCONFIG=""
+pvwavffparsernode_y_mk=""
+SOLIBDIRS_omx_aacdec_sharedlibrary="/codecs_v2/omx/omx_aac/build/make_multithreaded /codecs_v2/audio/aac/dec/build/make"
+pvmp4reginterface_m_lib="-lpvmp4reginterface"
+pvavcdecnode_m_lib=""
+pvpvrnode_y_lib=""
+unit_test_y_lib="-lunit_test"
+pvpvrff_y_lib=""
+pvrfileplayback_support_mk=""
+pvrvdecnode_m_lib=""
+omx_aac_component_imp_m_mk=""
+pvwav_m_mk="/fileformats/wav/parser/build/make"
+omx_m4venc_component_m_mk="/codecs_v2/omx/omx_m4venc/build/make_multithreaded"
+SOLIBDIRS_omx_m4vdec_sharedlibrary="/codecs_v2/omx/omx_m4v/build/make_multithreaded /codecs_v2/video/m4v_h263/dec/build/make"
+pvcommsionode_m_mk="/nodes/pvcommsionode/build/make"
+pvmp4reginterface_m_mk="/modules/linux_mp4/node_registry/build/make"
+pvgeneraltools_m_mk="/protocols/systems/tools/general/build/make"
+unit_test_m_mk=""
+omx_m4venc_component_imp_m_lib=""
+pvomxaudiodecnode_m_mk="/nodes/pvomxaudiodecnode/build/make"
+pvjanusplugininterface_m_lib=""
+SOLIBS_omx_avcenc_sharedlibrary="-lomx_avcenc_component_lib -lpvavch264enc"
+pvvideodecnode_m_lib=""
+getactualaacconfig_imp_m_mk="/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make"
+pvrmffrecognizer_y_lib=""
+pvamrffrecognizer_y_lib=""
+omx_common_m_mk="/codecs_v2/omx/omx_common/build/make_multithreaded"
+SOLIBDIRS_omx_mp3dec_sharedlibrary="/codecs_v2/omx/omx_mp3/build/make_multithreaded /codecs_v2/audio/mp3/dec/build/make"
+pvasfffparsernode_m_mk=""
+LIBS_omxjointimp_shared="-lomx_mastercore_lib"
+pvlatmpayloadparser_m_mk="/protocols/rtp_payload_parser/util/build/latmparser/make"
+pvrmffparsernode_y_mk=""
+getactualaacconfig_for_static_m_mk=""
+pvdbmanager_m_lib=""
+MODS_pvwmdrm="-lopencore_player -lopencore_common"
+wmvdecoder_imp_m_mk="n"
+pvamrwbdecoder_m_mk="/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make"
+pvrtsp_cli_eng_node_opencore_m_mk="/protocols/rtsp_client_engine/build_opencore/make"
+mshttp_support_mk=""
+opencore_download_so_name="opencore_download"
+SOLIBS_pvmtpdb="  "
+SOLIBS_opencore_downloadreg="-lpvdownloadreginterface"
+mp3decnode_m_mk=""
+SOLIBS_omx_sharedlibrary="-lomx_common_lib -lomx_queue_lib -lpvomx_proxy_lib -lomx_baseclass_lib -lpv_omx_interface"
+pvwavffrecognizer_y_lib=""
+pvavcencnode_m_lib=""
+pvjitterbuffernode_y_lib=""
+pvmediadatastruct_m_mk="/baselibs/media_data_structures/build/make"
+REGISTER_OMX_M4VENC_COMPONENT=1
+LIBDIR_fileformats_static="                   "
+pvpvrff_y_mk=""
+pvpvrnode_y_mk=""
+MODS_omx_amrenc_sharedlibrary="-lomx_sharedlibrary -lopencore_common "
+LIBS_cpm_shared="-lcpm -lpassthru_oma1   "
+pvmediainputnode_y_lib=""
+pvmiofileinput_y_mk=""
+pvmiofileoutput_m_lib="-lpvmiofileoutput"
+pvmp4ffparsernode_m_lib=""
+omx_m4venc_component_y_mk=""
+LIBDIR_omxdecimp_static=""
+omx_amr_component_y_lib=""
+rvdecoder_y_lib=""
+LIBS_pvmi_static="                     "
+pvplayer_engine_y_mk=""
+MODS_opencore_common=""
+pvsqlite_m_lib=""
+pvmp4ffopencore_m_mk="/fileformats/mp4/parser/build_opencore/make"
+pv_amr_nb_common_lib_m_mk="/codecs_v2/audio/gsm_amr/amr_nb/common/build/make"
+LIBDIR_tools_v2_shared="/modules/linux_rtsp/core/build/make /modules/linux_rtsp/node_registry/build/make   /modules/linux_download/core/build/make /modules/linux_download/node_registry/build/make /modules/linux_mp4/core/build/make /modules/linux_mp4/node_registry/build/make  "
+DYNAMIC_LOAD_OMX_AMRENC_COMPONENT=1
+pvamrencnode_y_lib=""
+pvjanusplugin_y_mk=""
+pv324m_m_lib="-lpv324m"
+pvvideoencnode_m_mk=""
+LIBDIR_nodes_static="                                                  "
+LIBDIR_audio_shared="  /codecs_v2/audio/aac/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/common/build/make /codecs_v2/audio/gsm_amr/amr_wb/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/dec/build/make /codecs_v2/audio/mp3/dec/build/make  /codecs_v2/audio/gsm_amr/common/dec/build/make /codecs_v2/audio/gsm_amr/amr_nb/enc/build/make"
+SOLIBDIRS_pvwmdrmdev="n"
+opencore_mp4local_so_name="opencore_mp4local"
+pvavcdecnode_y_lib=""
+threadsafe_callback_ao_y_lib=""
+pvmimeutils_m_mk="/baselibs/pv_mime_utils/build/make"
+pvmp4ffcomposernodeopencore_y_lib=""
+pvavcdecnode_y_mk=""
+pvjitterbuffernode_opencore_y_lib=""
+rdt_parser_m_mk=""
+omx_baseclass_y_mk=""
+pvmp4ffcomposeropencore_y_lib=""
+pvfileparserutils_m_lib="-lpvfileparserutils"
+pv_http_parcom_y_lib=""
+pvgendatastruct_m_lib="-lpvgendatastruct"
+omx_wmv_component_imp_m_lib="n"
+SOLIBS_opencore_rtspreg="-lpvrtspreginterface"
+protocolenginenode_m_mk=""
+pvmedialayernode_y_lib=""
+pvdivxffrecognizer_m_mk=""
+SOLIBDIRS_omx_avcenc_sharedlibrary="/codecs_v2/omx/omx_h264enc/build/make_multithreaded /codecs_v2/video/avc_h264/enc/build/make"
+pvdownloadmanagernode_m_mk="/nodes/pvdownloadmanagernode/build/make"
+pvid3parcom_y_mk=""
+pvstreamingmanagernode_m_mk=""
+#
+# That's all, folks!
diff --git a/build_config/opencore_dynamic/setup b/build_config/opencore_dynamic/setup
new file mode 100644
index 0000000..a94a4f9
--- /dev/null
+++ b/build_config/opencore_dynamic/setup
@@ -0,0 +1,28 @@
+
+echo Setting up build environment with default configuration ...
+
+# SDK_LOCAL is the local staging area (i.e., view private) for private
+# builds and installs of the corelibs libraries. 
+setenv SDK_LOCAL $PWD
+echo Set SDK_LOCAL to $SDK_LOCAL ...
+
+
+# Set CFG_DIR
+#
+setenv CFG_DIR $PWD
+echo Set CFG_DIR to $CFG_DIR ...
+
+
+# For picking the node registry and tunables, set this flag
+#
+setenv FORMAT nj
+
+# Setup the default environment
+#
+if (! $?DEFAULT_SETUP_PATH) then
+  setenv DEFAULT_SETUP_PATH ../default
+endif
+
+source $DEFAULT_SETUP_PATH/setup
+
+# END OF SCRIPT - NO CODE BEYOND THIS POINT 
diff --git a/build_config/opencore_dynamic/setup.ksh b/build_config/opencore_dynamic/setup.ksh
new file mode 100644
index 0000000..ab75c1a
--- /dev/null
+++ b/build_config/opencore_dynamic/setup.ksh
@@ -0,0 +1,24 @@
+echo Setting up build environment with default configuration ...
+
+# SDK_LOCAL is the local staging area (i.e., view private) for private
+# builds and installs of the corelibs libraries.  
+export SDK_LOCAL=$PWD
+echo "Set SDK_LOCAL to $SDK_LOCAL ..."
+
+
+# Set CFG_DIR
+#
+export CFG_DIR=$PWD
+echo "Set CFG_DIR to $CFG_DIR ..."
+
+# For picking the node registry and tunables, set this flag
+#
+export FORMAT=nj
+
+# Setup the default environment
+#
+if [[ -z $DEFAULT_SETUP_PATH ]]; then
+  export DEFAULT_SETUP_PATH=../default
+fi
+
+. $DEFAULT_SETUP_PATH/setup.ksh
diff --git a/build_config/opencore_dynamic/setup_nr b/build_config/opencore_dynamic/setup_nr
new file mode 100644
index 0000000..877b6ef
--- /dev/null
+++ b/build_config/opencore_dynamic/setup_nr
@@ -0,0 +1,40 @@
+# This file is suitable for tcsh, csh, etc.
+
+echo Setting up build environment with default configuration ...
+echo Using $PWD as top directory ...
+
+setenv PROJECT_DIR $PWD
+echo Set PROJECT_DIR to $PROJECT_DIR ...
+
+setenv CFG_DIR $PWD
+echo Set CFG_DIR to $CFG_DIR ...
+
+# In this case, set it based on the first argument if it is present
+if ($# >= 1) then
+   setenv BASE_DIR `echo $1 | sed 's/\/$//'`
+else if ($?BASE_DIR) then
+   echo  BASE_DIR already defined as $BASE_DIR ...
+else
+   echo ERROR - Must provide the BASE_DIR value as a argument or env variable
+   exit 1
+endif
+
+setenv BUILD_ROOT $PROJECT_DIR/build
+echo Set BUILD_ROOT to $BUILD_ROOT ...
+
+setenv SRC_ROOT $BASE_DIR
+echo Set SRC_ROOT to $SRC_ROOT ...
+
+setenv MK $BASE_DIR/tools_v2/build/make_nr/tools_v2/build/make
+echo Set MK to $MK ...
+
+set extern_tools_path = $BASE_DIR/extern_tools_v2/bin/linux
+set path = ($extern_tools_path $path)
+unset extern_tools_path
+
+rehash
+rehash
+
+echo 
+echo "Environment is ready if no errors reported"
+echo 
diff --git a/build_config/opencore_dynamic/setup_nr.sh b/build_config/opencore_dynamic/setup_nr.sh
new file mode 100644
index 0000000..73336df
--- /dev/null
+++ b/build_config/opencore_dynamic/setup_nr.sh
@@ -0,0 +1,22 @@
+echo Setting up build environment with default configuration ...
+
+export PROJECT_DIR=$PWD
+
+# Set CFG_DIR
+#
+export CFG_DIR=$PWD
+echo "Set CFG_DIR to $CFG_DIR ..."
+
+# Setup the default environment
+#
+. ../default/setup_nr.sh
+
+# include the android definitions for export to android makefiles.
+export PLATFORM_EXTRAS=$MK/android.mk
+
+# For make completion targets
+mkcmdcmpl
+
+
+
+
diff --git a/build_config/opencore_dynamic/smoke_nr.sh b/build_config/opencore_dynamic/smoke_nr.sh
new file mode 100644
index 0000000..aa6e597
--- /dev/null
+++ b/build_config/opencore_dynamic/smoke_nr.sh
@@ -0,0 +1,39 @@
+#
+# Player smoke test
+#
+
+echo "Setting lib path"
+export LD_LIBRARY_PATH=$CFG_DIR/build/installed_lib/linux
+echo "Lib Path" $LD_LIBRARY_PATH
+
+echo "Removing old output"
+rm -f smoke*.txt
+
+cd $CFG_DIR/build/bin/linux
+
+echo "Fetching config files"
+rm -f *.cfg
+cp $SRC_ROOT/tools_v2/build/package/opencore/*.cfg ./
+echo "Running player tests"
+
+echo "Copying test content"
+cp $SRC_ROOT/engines/player/test/data/test_m4v_amr.mp4 .
+cp $SRC_ROOT/engines/player/test/data/pv_amr_mpeg4.sdp .
+
+echo "MP4 Local..."
+./pvplayer_engine_test -output $CFG_DIR/smoke_local_mp4.txt -logfile -test 51 51
+
+echo "MP4 Download..."
+./pvplayer_engine_test -output $CFG_DIR/smoke_dl_mp4.txt -logfile -test 102 106 -source http://pvwmsoha.pv.com:7070/MediaDownloadContent/MP4/prog_dl/mpeg4+aac_metadata_qt.mp4
+
+echo "RTSP Streaming..."
+./pvplayer_engine_test -output $CFG_DIR/smoke_sm_rtsp.txt -logfile -test 851 851 
+
+echo "Done!"
+cd $CFG_DIR
+
+grep "Successes: " smoke*.txt
+grep "Failures: " smoke*.txt
+grep "Memory Leaks" smoke*.txt
+
+#END OF SCRIPT, NO TEXT BEYOND THIS LINE
diff --git a/codecs_v2/audio/aac/dec/Android.mk b/codecs_v2/audio/aac/dec/Android.mk
index ffe0089..fcd4c68 100644
--- a/codecs_v2/audio/aac/dec/Android.mk
+++ b/codecs_v2/audio/aac/dec/Android.mk
@@ -3,174 +3,172 @@
 
 LOCAL_SRC_FILES := \
 	src/analysis_sub_band.cpp \
-	src/apply_ms_synt.cpp \
-	src/apply_tns.cpp \
-	src/buf_getbits.cpp \
-	src/byte_align.cpp \
-	src/calc_auto_corr.cpp \
-	src/calc_gsfb_table.cpp \
-	src/calc_sbr_anafilterbank.cpp \
-	src/calc_sbr_envelope.cpp \
-	src/calc_sbr_synfilterbank.cpp \
-	src/check_crc.cpp \
-	src/dct16.cpp \
-	src/dct64.cpp \
-	src/decode_huff_cw_binary.cpp \
-	src/decode_noise_floorlevels.cpp \
-	src/decoder_aac.cpp \
-	src/deinterleave.cpp \
-	src/digit_reversal_tables.cpp \
-	src/dst16.cpp \
-	src/dst32.cpp \
-	src/dst8.cpp \
-	src/esc_iquant_scaling.cpp \
-	src/extractframeinfo.cpp \
-	src/fft_rx4_long.cpp \
-	src/fft_rx4_short.cpp \
-	src/fft_rx4_tables_fxp.cpp \
-	src/find_adts_syncword.cpp \
-	src/fwd_long_complex_rot.cpp \
-	src/fwd_short_complex_rot.cpp \
-	src/gen_rand_vector.cpp \
-	src/get_adif_header.cpp \
-	src/get_adts_header.cpp \
-	src/get_audio_specific_config.cpp \
-	src/get_dse.cpp \
-	src/get_ele_list.cpp \
-	src/get_ga_specific_config.cpp \
-	src/get_ics_info.cpp \
-	src/get_prog_config.cpp \
-	src/get_pulse_data.cpp \
-	src/get_sbr_bitstream.cpp \
-	src/get_sbr_startfreq.cpp \
-	src/get_sbr_stopfreq.cpp \
-	src/get_tns.cpp \
-	src/getfill.cpp \
-	src/getgroup.cpp \
-	src/getics.cpp \
-	src/getmask.cpp \
-	src/hcbtables_binary.cpp \
-	src/huffcb.cpp \
-	src/huffdecode.cpp \
-	src/hufffac.cpp \
-	src/huffspec_fxp.cpp \
-	src/idct16.cpp \
-	src/idct32.cpp \
-	src/idct8.cpp \
-	src/imdct_fxp.cpp \
-	src/infoinit.cpp \
-	src/init_sbr_dec.cpp \
-	src/intensity_right.cpp \
-	src/inv_long_complex_rot.cpp \
-	src/inv_short_complex_rot.cpp \
-	src/iquant_table.cpp \
-	src/long_term_prediction.cpp \
-	src/long_term_synthesis.cpp \
-	src/lt_decode.cpp \
-	src/mdct_fxp.cpp \
-	src/mdct_tables_fxp.cpp \
-	src/mdst.cpp \
-	src/mix_radix_fft.cpp \
-	src/ms_synt.cpp \
-	src/pns_corr.cpp \
-	src/pns_intensity_right.cpp \
-	src/pns_left.cpp \
-	src/ps_all_pass_filter_coeff.cpp \
-	src/ps_all_pass_fract_delay_filter.cpp \
-	src/ps_allocate_decoder.cpp \
-	src/ps_applied.cpp \
-	src/ps_bstr_decoding.cpp \
-	src/ps_channel_filtering.cpp \
-	src/ps_decode_bs_utils.cpp \
-	src/ps_decorrelate.cpp \
-	src/ps_fft_rx8.cpp \
-	src/ps_hybrid_analysis.cpp \
-	src/ps_hybrid_filter_bank_allocation.cpp \
-	src/ps_hybrid_synthesis.cpp \
-	src/ps_init_stereo_mixing.cpp \
-	src/ps_pwr_transient_detection.cpp \
-	src/ps_read_data.cpp \
-	src/ps_stereo_processing.cpp \
-	src/pulse_nc.cpp \
-	src/pv_div.cpp \
-	src/pv_log2.cpp \
-	src/pv_normalize.cpp \
-	src/pv_pow2.cpp \
-	src/pv_sine.cpp \
-	src/pv_sqrt.cpp \
-	src/pvmp4audiodecoderconfig.cpp \
-	src/pvmp4audiodecoderframe.cpp \
-	src/pvmp4audiodecodergetmemrequirements.cpp \
-	src/pvmp4audiodecoderinitlibrary.cpp \
-	src/pvmp4audiodecoderresetbuffer.cpp \
-	src/q_normalize.cpp \
-	src/qmf_filterbank_coeff.cpp \
-	src/sbr_aliasing_reduction.cpp \
-	src/sbr_applied.cpp \
-	src/sbr_code_book_envlevel.cpp \
-	src/sbr_crc_check.cpp \
-	src/sbr_create_limiter_bands.cpp \
-	src/sbr_dec.cpp \
-	src/sbr_decode_envelope.cpp \
-	src/sbr_decode_huff_cw.cpp \
-	src/sbr_downsample_lo_res.cpp \
-	src/sbr_envelope_calc_tbl.cpp \
-	src/sbr_envelope_unmapping.cpp \
-	src/sbr_extract_extended_data.cpp \
-	src/sbr_find_start_andstop_band.cpp \
-	src/sbr_generate_high_freq.cpp \
-	src/sbr_get_additional_data.cpp \
-	src/sbr_get_cpe.cpp \
-	src/sbr_get_dir_control_data.cpp \
-	src/sbr_get_envelope.cpp \
-	src/sbr_get_header_data.cpp \
-	src/sbr_get_noise_floor_data.cpp \
-	src/sbr_get_sce.cpp \
-	src/sbr_inv_filt_levelemphasis.cpp \
-	src/sbr_open.cpp \
-	src/sbr_read_data.cpp \
-	src/sbr_requantize_envelope_data.cpp \
-	src/sbr_reset_dec.cpp \
-	src/sbr_update_freq_scale.cpp \
-	src/set_mc_info.cpp \
-	src/sfb.cpp \
-	src/shellsort.cpp \
-	src/synthesis_sub_band.cpp \
-	src/tns_ar_filter.cpp \
-	src/tns_decode_coef.cpp \
-	src/tns_inv_filter.cpp \
-	src/trans4m_freq_2_time_fxp.cpp \
-	src/trans4m_time_2_freq_fxp.cpp \
-	src/unpack_idx.cpp \
-	src/window_tables_fxp.cpp \
-	src/pvmp4setaudioconfig.cpp
-
+ 	src/apply_ms_synt.cpp \
+ 	src/apply_tns.cpp \
+ 	src/buf_getbits.cpp \
+ 	src/byte_align.cpp \
+ 	src/calc_auto_corr.cpp \
+ 	src/calc_gsfb_table.cpp \
+ 	src/calc_sbr_anafilterbank.cpp \
+ 	src/calc_sbr_envelope.cpp \
+ 	src/calc_sbr_synfilterbank.cpp \
+ 	src/check_crc.cpp \
+ 	src/dct16.cpp \
+ 	src/dct64.cpp \
+ 	src/decode_huff_cw_binary.cpp \
+ 	src/decode_noise_floorlevels.cpp \
+ 	src/decoder_aac.cpp \
+ 	src/deinterleave.cpp \
+ 	src/digit_reversal_tables.cpp \
+ 	src/dst16.cpp \
+ 	src/dst32.cpp \
+ 	src/dst8.cpp \
+ 	src/esc_iquant_scaling.cpp \
+ 	src/extractframeinfo.cpp \
+ 	src/fft_rx4_long.cpp \
+ 	src/fft_rx4_short.cpp \
+ 	src/fft_rx4_tables_fxp.cpp \
+ 	src/find_adts_syncword.cpp \
+ 	src/fwd_long_complex_rot.cpp \
+ 	src/fwd_short_complex_rot.cpp \
+ 	src/gen_rand_vector.cpp \
+ 	src/get_adif_header.cpp \
+ 	src/get_adts_header.cpp \
+ 	src/get_audio_specific_config.cpp \
+ 	src/get_dse.cpp \
+ 	src/get_ele_list.cpp \
+ 	src/get_ga_specific_config.cpp \
+ 	src/get_ics_info.cpp \
+ 	src/get_prog_config.cpp \
+ 	src/get_pulse_data.cpp \
+ 	src/get_sbr_bitstream.cpp \
+ 	src/get_sbr_startfreq.cpp \
+ 	src/get_sbr_stopfreq.cpp \
+ 	src/get_tns.cpp \
+ 	src/getfill.cpp \
+ 	src/getgroup.cpp \
+ 	src/getics.cpp \
+ 	src/getmask.cpp \
+ 	src/hcbtables_binary.cpp \
+ 	src/huffcb.cpp \
+ 	src/huffdecode.cpp \
+ 	src/hufffac.cpp \
+ 	src/huffspec_fxp.cpp \
+ 	src/idct16.cpp \
+ 	src/idct32.cpp \
+ 	src/idct8.cpp \
+ 	src/imdct_fxp.cpp \
+ 	src/infoinit.cpp \
+ 	src/init_sbr_dec.cpp \
+ 	src/intensity_right.cpp \
+ 	src/inv_long_complex_rot.cpp \
+ 	src/inv_short_complex_rot.cpp \
+ 	src/iquant_table.cpp \
+ 	src/long_term_prediction.cpp \
+ 	src/long_term_synthesis.cpp \
+ 	src/lt_decode.cpp \
+ 	src/mdct_fxp.cpp \
+ 	src/mdct_tables_fxp.cpp \
+ 	src/mdst.cpp \
+ 	src/mix_radix_fft.cpp \
+ 	src/ms_synt.cpp \
+ 	src/pns_corr.cpp \
+ 	src/pns_intensity_right.cpp \
+ 	src/pns_left.cpp \
+ 	src/ps_all_pass_filter_coeff.cpp \
+ 	src/ps_all_pass_fract_delay_filter.cpp \
+ 	src/ps_allocate_decoder.cpp \
+ 	src/ps_applied.cpp \
+ 	src/ps_bstr_decoding.cpp \
+ 	src/ps_channel_filtering.cpp \
+ 	src/ps_decode_bs_utils.cpp \
+ 	src/ps_decorrelate.cpp \
+ 	src/ps_fft_rx8.cpp \
+ 	src/ps_hybrid_analysis.cpp \
+ 	src/ps_hybrid_filter_bank_allocation.cpp \
+ 	src/ps_hybrid_synthesis.cpp \
+ 	src/ps_init_stereo_mixing.cpp \
+ 	src/ps_pwr_transient_detection.cpp \
+ 	src/ps_read_data.cpp \
+ 	src/ps_stereo_processing.cpp \
+ 	src/pulse_nc.cpp \
+ 	src/pv_div.cpp \
+ 	src/pv_log2.cpp \
+ 	src/pv_normalize.cpp \
+ 	src/pv_pow2.cpp \
+ 	src/pv_sine.cpp \
+ 	src/pv_sqrt.cpp \
+ 	src/pvmp4audiodecoderconfig.cpp \
+ 	src/pvmp4audiodecoderframe.cpp \
+ 	src/pvmp4audiodecodergetmemrequirements.cpp \
+ 	src/pvmp4audiodecoderinitlibrary.cpp \
+ 	src/pvmp4audiodecoderresetbuffer.cpp \
+ 	src/q_normalize.cpp \
+ 	src/qmf_filterbank_coeff.cpp \
+ 	src/sbr_aliasing_reduction.cpp \
+ 	src/sbr_applied.cpp \
+ 	src/sbr_code_book_envlevel.cpp \
+ 	src/sbr_crc_check.cpp \
+ 	src/sbr_create_limiter_bands.cpp \
+ 	src/sbr_dec.cpp \
+ 	src/sbr_decode_envelope.cpp \
+ 	src/sbr_decode_huff_cw.cpp \
+ 	src/sbr_downsample_lo_res.cpp \
+ 	src/sbr_envelope_calc_tbl.cpp \
+ 	src/sbr_envelope_unmapping.cpp \
+ 	src/sbr_extract_extended_data.cpp \
+ 	src/sbr_find_start_andstop_band.cpp \
+ 	src/sbr_generate_high_freq.cpp \
+ 	src/sbr_get_additional_data.cpp \
+ 	src/sbr_get_cpe.cpp \
+ 	src/sbr_get_dir_control_data.cpp \
+ 	src/sbr_get_envelope.cpp \
+ 	src/sbr_get_header_data.cpp \
+ 	src/sbr_get_noise_floor_data.cpp \
+ 	src/sbr_get_sce.cpp \
+ 	src/sbr_inv_filt_levelemphasis.cpp \
+ 	src/sbr_open.cpp \
+ 	src/sbr_read_data.cpp \
+ 	src/sbr_requantize_envelope_data.cpp \
+ 	src/sbr_reset_dec.cpp \
+ 	src/sbr_update_freq_scale.cpp \
+ 	src/set_mc_info.cpp \
+ 	src/sfb.cpp \
+ 	src/shellsort.cpp \
+ 	src/synthesis_sub_band.cpp \
+ 	src/tns_ar_filter.cpp \
+ 	src/tns_decode_coef.cpp \
+ 	src/tns_inv_filter.cpp \
+ 	src/trans4m_freq_2_time_fxp.cpp \
+ 	src/trans4m_time_2_freq_fxp.cpp \
+ 	src/unpack_idx.cpp \
+ 	src/window_tables_fxp.cpp \
+ 	src/pvmp4setaudioconfig.cpp \
+ 	src/../util/getactualaacconfig/src/getactualaacconfig.cpp
 
 
 LOCAL_MODULE := libpv_aac_dec
 
-LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO  $(PV_CFLAGS)
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -D_ARM_GCC
- else
- LOCAL_CFLAGS += -DC_EQUIVALENT
- endif
+LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/include \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/src \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/aac/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/decoder_aac.h \
-	include/e_tmp4audioobjecttype.h \
-	include/pv_audio_type_defs.h \
-	include/pvmp4audiodecoder_api.h
+ 	include/e_tmp4audioobjecttype.h \
+ 	include/pv_audio_type_defs.h \
+ 	include/pvmp4audiodecoder_api.h \
+ 	include/../util/getactualaacconfig/include/getactualaacconfig.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/aac/dec/build/make/aacdec_util.mk b/codecs_v2/audio/aac/dec/build/make/aacdec_util.mk
new file mode 100644
index 0000000..c0c31fb
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/build/make/aacdec_util.mk
@@ -0,0 +1,5 @@
+# Makefile segment for aac utility when required along with the decoder
+
+SRCS += ../util/getactualaacconfig/src/getactualaacconfig.cpp
+
+HDRS += ../util/getactualaacconfig/include/getactualaacconfig.h
diff --git a/codecs_v2/audio/aac/dec/build/make/local.mk b/codecs_v2/audio/aac/dec/build/make/local.mk
new file mode 100644
index 0000000..bc50f9d
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/build/make/local.mk
@@ -0,0 +1,167 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv_aac_dec
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := analysis_sub_band.cpp \
+	apply_ms_synt.cpp \
+	apply_tns.cpp \
+	buf_getbits.cpp \
+	byte_align.cpp \
+	calc_auto_corr.cpp \
+	calc_gsfb_table.cpp \
+	calc_sbr_anafilterbank.cpp \
+	calc_sbr_envelope.cpp \
+	calc_sbr_synfilterbank.cpp \
+	check_crc.cpp \
+	dct16.cpp \
+	dct64.cpp \
+	decode_huff_cw_binary.cpp \
+	decode_noise_floorlevels.cpp \
+	decoder_aac.cpp \
+	deinterleave.cpp \
+	digit_reversal_tables.cpp \
+	dst16.cpp \
+	dst32.cpp \
+	dst8.cpp \
+	esc_iquant_scaling.cpp \
+	extractframeinfo.cpp \
+	fft_rx4_long.cpp \
+	fft_rx4_short.cpp \
+	fft_rx4_tables_fxp.cpp \
+	find_adts_syncword.cpp \
+	fwd_long_complex_rot.cpp \
+	fwd_short_complex_rot.cpp \
+	gen_rand_vector.cpp \
+	get_adif_header.cpp \
+	get_adts_header.cpp \
+	get_audio_specific_config.cpp \
+	get_dse.cpp \
+	get_ele_list.cpp \
+	get_ga_specific_config.cpp \
+	get_ics_info.cpp \
+	get_prog_config.cpp \
+	get_pulse_data.cpp \
+	get_sbr_bitstream.cpp \
+	get_sbr_startfreq.cpp \
+	get_sbr_stopfreq.cpp \
+	get_tns.cpp \
+	getfill.cpp \
+	getgroup.cpp \
+	getics.cpp \
+	getmask.cpp \
+	hcbtables_binary.cpp \
+	huffcb.cpp \
+	huffdecode.cpp \
+	hufffac.cpp \
+	huffspec_fxp.cpp \
+	idct16.cpp \
+	idct32.cpp \
+	idct8.cpp \
+	imdct_fxp.cpp \
+	infoinit.cpp \
+	init_sbr_dec.cpp \
+	intensity_right.cpp \
+	inv_long_complex_rot.cpp \
+	inv_short_complex_rot.cpp \
+	iquant_table.cpp \
+	long_term_prediction.cpp \
+	long_term_synthesis.cpp \
+	lt_decode.cpp \
+	mdct_fxp.cpp \
+	mdct_tables_fxp.cpp \
+	mdst.cpp \
+	mix_radix_fft.cpp \
+	ms_synt.cpp \
+	pns_corr.cpp \
+	pns_intensity_right.cpp \
+	pns_left.cpp \
+	ps_all_pass_filter_coeff.cpp \
+	ps_all_pass_fract_delay_filter.cpp \
+	ps_allocate_decoder.cpp \
+	ps_applied.cpp \
+	ps_bstr_decoding.cpp \
+	ps_channel_filtering.cpp \
+	ps_decode_bs_utils.cpp \
+	ps_decorrelate.cpp \
+	ps_fft_rx8.cpp \
+	ps_hybrid_analysis.cpp \
+	ps_hybrid_filter_bank_allocation.cpp \
+	ps_hybrid_synthesis.cpp \
+	ps_init_stereo_mixing.cpp \
+	ps_pwr_transient_detection.cpp \
+	ps_read_data.cpp \
+	ps_stereo_processing.cpp \
+	pulse_nc.cpp \
+	pv_div.cpp \
+	pv_log2.cpp \
+	pv_normalize.cpp \
+	pv_pow2.cpp \
+	pv_sine.cpp \
+	pv_sqrt.cpp \
+	pvmp4audiodecoderconfig.cpp \
+	pvmp4audiodecoderframe.cpp \
+	pvmp4audiodecodergetmemrequirements.cpp \
+	pvmp4audiodecoderinitlibrary.cpp \
+	pvmp4audiodecoderresetbuffer.cpp \
+	q_normalize.cpp \
+	qmf_filterbank_coeff.cpp \
+	sbr_aliasing_reduction.cpp \
+	sbr_applied.cpp \
+	sbr_code_book_envlevel.cpp \
+	sbr_crc_check.cpp \
+	sbr_create_limiter_bands.cpp \
+	sbr_dec.cpp \
+	sbr_decode_envelope.cpp \
+	sbr_decode_huff_cw.cpp \
+	sbr_downsample_lo_res.cpp \
+	sbr_envelope_calc_tbl.cpp \
+	sbr_envelope_unmapping.cpp \
+	sbr_extract_extended_data.cpp \
+	sbr_find_start_andstop_band.cpp \
+	sbr_generate_high_freq.cpp \
+	sbr_get_additional_data.cpp \
+	sbr_get_cpe.cpp \
+	sbr_get_dir_control_data.cpp \
+	sbr_get_envelope.cpp \
+	sbr_get_header_data.cpp \
+	sbr_get_noise_floor_data.cpp \
+	sbr_get_sce.cpp \
+	sbr_inv_filt_levelemphasis.cpp \
+	sbr_open.cpp \
+	sbr_read_data.cpp \
+	sbr_requantize_envelope_data.cpp \
+	sbr_reset_dec.cpp \
+	sbr_update_freq_scale.cpp \
+	set_mc_info.cpp \
+	sfb.cpp \
+	shellsort.cpp \
+	synthesis_sub_band.cpp \
+	tns_ar_filter.cpp \
+	tns_decode_coef.cpp \
+	tns_inv_filter.cpp \
+	trans4m_freq_2_time_fxp.cpp \
+	trans4m_time_2_freq_fxp.cpp \
+	unpack_idx.cpp \
+	window_tables_fxp.cpp \
+	pvmp4setaudioconfig.cpp
+
+
+HDRS := decoder_aac.h e_tmp4audioobjecttype.h pv_audio_type_defs.h pvmp4audiodecoder_api.h
+
+# include $(call process_include_list,$(LOCAL_PATH),$(pv_aac_dec_plugins))
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/audio/aac/dec/build/make/makefile b/codecs_v2/audio/aac/dec/build/make/makefile
deleted file mode 100644
index b9736c3..0000000
--- a/codecs_v2/audio/aac/dec/build/make/makefile
+++ /dev/null
@@ -1,211 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pv_aac_dec
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-
-XCPPFLAGS += -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO
-
-ifeq ($(ARCHITECTURE),linux_arm)
-XCPPFLAGS += -D_ARM_GCC
-else
-XCPPFLAGS += -DC_EQUIVALENT
-endif
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-XINCDIRS += -I ../../include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  analysis_sub_band.cpp \
-	apply_ms_synt.cpp \
-	apply_tns.cpp \
-	buf_getbits.cpp \
-	byte_align.cpp \
-	calc_auto_corr.cpp \
-	calc_gsfb_table.cpp \
-	calc_sbr_anafilterbank.cpp \
-	calc_sbr_envelope.cpp \
-	calc_sbr_synfilterbank.cpp \
-	check_crc.cpp \
-	dct16.cpp \
-	dct64.cpp \
-	decode_huff_cw_binary.cpp \
-	decode_noise_floorlevels.cpp \
-	decoder_aac.cpp \
-	deinterleave.cpp \
-	digit_reversal_tables.cpp \
-	dst16.cpp \
-	dst32.cpp \
-	dst8.cpp \
-	esc_iquant_scaling.cpp \
-	extractframeinfo.cpp \
-	fft_rx4_long.cpp \
-	fft_rx4_short.cpp \
-	fft_rx4_tables_fxp.cpp \
-	find_adts_syncword.cpp \
-	fwd_long_complex_rot.cpp \
-	fwd_short_complex_rot.cpp \
-	gen_rand_vector.cpp \
-	get_adif_header.cpp \
-	get_adts_header.cpp \
-	get_audio_specific_config.cpp \
-	get_dse.cpp \
-	get_ele_list.cpp \
-	get_ga_specific_config.cpp \
-	get_ics_info.cpp \
-	get_prog_config.cpp \
-	get_pulse_data.cpp \
-	get_sbr_bitstream.cpp \
-	get_sbr_startfreq.cpp \
-	get_sbr_stopfreq.cpp \
-	get_tns.cpp \
-	getfill.cpp \
-	getgroup.cpp \
-	getics.cpp \
-	getmask.cpp \
-	hcbtables_binary.cpp \
-	huffcb.cpp \
-	huffdecode.cpp \
-	hufffac.cpp \
-	huffspec_fxp.cpp \
-	idct16.cpp \
-	idct32.cpp \
-	idct8.cpp \
-	imdct_fxp.cpp \
-	infoinit.cpp \
-	init_sbr_dec.cpp \
-	intensity_right.cpp \
-	inv_long_complex_rot.cpp \
-	inv_short_complex_rot.cpp \
-	iquant_table.cpp \
-	long_term_prediction.cpp \
-	long_term_synthesis.cpp \
-	lt_decode.cpp \
-	mdct_fxp.cpp \
-	mdct_tables_fxp.cpp \
-	mdst.cpp \
-	mix_radix_fft.cpp \
-	ms_synt.cpp \
-	pns_corr.cpp \
-	pns_intensity_right.cpp \
-	pns_left.cpp \
-	ps_all_pass_filter_coeff.cpp \
-	ps_all_pass_fract_delay_filter.cpp \
-	ps_allocate_decoder.cpp \
-	ps_applied.cpp \
-	ps_bstr_decoding.cpp \
-	ps_channel_filtering.cpp \
-	ps_decode_bs_utils.cpp \
-	ps_decorrelate.cpp \
-	ps_fft_rx8.cpp \
-	ps_hybrid_analysis.cpp \
-	ps_hybrid_filter_bank_allocation.cpp \
-	ps_hybrid_synthesis.cpp \
-	ps_init_stereo_mixing.cpp \
-	ps_pwr_transient_detection.cpp \
-	ps_read_data.cpp \
-	ps_stereo_processing.cpp \
-	pulse_nc.cpp \
-	pv_div.cpp \
-	pv_log2.cpp \
-	pv_normalize.cpp \
-	pv_pow2.cpp \
-	pv_sine.cpp \
-	pv_sqrt.cpp \
-	pvmp4audiodecoderconfig.cpp \
-	pvmp4audiodecoderframe.cpp \
-	pvmp4audiodecodergetmemrequirements.cpp \
-	pvmp4audiodecoderinitlibrary.cpp \
-	pvmp4audiodecoderresetbuffer.cpp \
-	q_normalize.cpp \
-	qmf_filterbank_coeff.cpp \
-	sbr_aliasing_reduction.cpp \
-	sbr_applied.cpp \
-	sbr_code_book_envlevel.cpp \
-	sbr_crc_check.cpp \
-	sbr_create_limiter_bands.cpp \
-	sbr_dec.cpp \
-	sbr_decode_envelope.cpp \
-	sbr_decode_huff_cw.cpp \
-	sbr_downsample_lo_res.cpp \
-	sbr_envelope_calc_tbl.cpp \
-	sbr_envelope_unmapping.cpp \
-	sbr_extract_extended_data.cpp \
-	sbr_find_start_andstop_band.cpp \
-	sbr_generate_high_freq.cpp \
-	sbr_get_additional_data.cpp \
-	sbr_get_cpe.cpp \
-	sbr_get_dir_control_data.cpp \
-	sbr_get_envelope.cpp \
-	sbr_get_header_data.cpp \
-	sbr_get_noise_floor_data.cpp \
-	sbr_get_sce.cpp \
-	sbr_inv_filt_levelemphasis.cpp \
-	sbr_open.cpp \
-	sbr_read_data.cpp \
-	sbr_requantize_envelope_data.cpp \
-	sbr_reset_dec.cpp \
-	sbr_update_freq_scale.cpp \
-	set_mc_info.cpp \
-	sfb.cpp \
-	shellsort.cpp \
-	synthesis_sub_band.cpp \
-	tns_ar_filter.cpp \
-	tns_decode_coef.cpp \
-	tns_inv_filter.cpp \
-	trans4m_freq_2_time_fxp.cpp \
-	trans4m_time_2_freq_fxp.cpp \
-	unpack_idx.cpp \
-	window_tables_fxp.cpp \
-	pvmp4setaudioconfig.cpp
-
-	
-HDRS = decoder_aac.h e_tmp4audioobjecttype.h pv_audio_type_defs.h pvmp4audiodecoder_api.h
-	
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/aac/dec/include/decoder_aac.h b/codecs_v2/audio/aac/dec/include/decoder_aac.h
index 90b4785..68271f6 100644
--- a/codecs_v2/audio/aac/dec/include/decoder_aac.h
+++ b/codecs_v2/audio/aac/dec/include/decoder_aac.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h b/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h
index ee0b63f..83cccce 100644
--- a/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h
+++ b/codecs_v2/audio/aac/dec/include/e_tmp4audioobjecttype.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,18 +19,6 @@
 
  Pathname: ./include/e_tMP4AudioObjectType.h
 
-     Date: 06/28/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Fix ARM warning.
-
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
  This file contains enumerated types for MP4 Audio Object Types, as defined
  in ISO/IEC 14496-3, AMMENDMENT 1 Dated 2000-09-15
 
diff --git a/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h b/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h
index a167b76..49e14e9 100644
--- a/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h
+++ b/codecs_v2/audio/aac/dec/include/pv_audio_type_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,8 @@
  */
 /*
 ------------------------------------------------------------------------------
-
-
-
  Pathname: ./c/include/pv_audio_type_defs.h
 
-     Date: 02/14/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h b/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h
index 72a5bad..133603c 100644
--- a/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h
+++ b/codecs_v2/audio/aac/dec/include/pvmp4audiodecoder_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Name: PVMP4AudioDecoder_API.h
-
-     Date: 06/26/2001
+  Name: PVMP4AudioDecoder_API.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -37,6 +35,7 @@
  Description: add a new API to reset history buffer, the same change has been
               made on a 32-bits version(element \nd.e0352.wjin\1)
 
+ Who:                                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -57,7 +56,7 @@
 
   (Normally header files do not have a reference section)
 
-  ISO/EIC 14496-3:(1999) Document titled <-------- FIXME do better!
+  ISO/EIC 14496-3:(1999) Document titled
 ------------------------------------------------------------------------------
 */
 
@@ -334,24 +333,24 @@
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
 
-    UInt32 PVMP4AudioDecoderGetMemRequirements(void);
+    OSCL_IMPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void);
 
-    Int PVMP4AudioDecoderInitLibrary(
+    OSCL_IMPORT_REF Int PVMP4AudioDecoderInitLibrary(
         tPVMP4AudioDecoderExternal  *pExt,
         void                        *pMem);
 
-    Int PVMP4AudioDecodeFrame(
+    OSCL_IMPORT_REF Int PVMP4AudioDecodeFrame(
         tPVMP4AudioDecoderExternal  *pExt,
         void                        *pMem);
 
-    Int PVMP4AudioDecoderConfig(
+    OSCL_IMPORT_REF Int PVMP4AudioDecoderConfig(
         tPVMP4AudioDecoderExternal  *pExt,
         void                        *pMem);
 
-    void PVMP4AudioDecoderResetBuffer(
+    OSCL_IMPORT_REF void PVMP4AudioDecoderResetBuffer(
         void                        *pMem);
 
-    void PVMP4AudioDecoderDisableAacPlus(
+    OSCL_IMPORT_REF void PVMP4AudioDecoderDisableAacPlus(
         tPVMP4AudioDecoderExternal  *pExt,
         void                        *pMem);
 
diff --git a/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h b/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h
index 49684ba..fbd4dc5 100644
--- a/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h
+++ b/codecs_v2/audio/aac/dec/src/aac_mem_funcs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: aac_mem_funcs.h
  Funtions:
 
 
-     Date: 08/14/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp b/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp
index 80cb554..1ca53ff 100644
--- a/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp
+++ b/codecs_v2/audio/aac/dec/src/analysis_sub_band.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: analysis_sub_band.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/analysis_sub_band.h b/codecs_v2/audio/aac/dec/src/analysis_sub_band.h
index 859bf0b..2881cee 100644
--- a/codecs_v2/audio/aac/dec/src/analysis_sub_band.h
+++ b/codecs_v2/audio/aac/dec/src/analysis_sub_band.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/analysis_sub_band.h
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp b/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp
index dfddc9a..ab36c6a 100644
--- a/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp
+++ b/codecs_v2/audio/aac/dec/src/apply_ms_synt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
 
  Pathname: ./src/apply_ms_synt.c
 
-     Date: 09/05/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -29,6 +28,7 @@
 
  Description: Delete local variable start_indx, since it is never used.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/apply_ms_synt.h b/codecs_v2/audio/aac/dec/src/apply_ms_synt.h
index ec7d324..ed7fb7a 100644
--- a/codecs_v2/audio/aac/dec/src/apply_ms_synt.h
+++ b/codecs_v2/audio/aac/dec/src/apply_ms_synt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/apply_ms_synt.h
 
-     Date: 09/05/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/apply_tns.cpp b/codecs_v2/audio/aac/dec/src/apply_tns.cpp
index ee2d69a..96ecd27 100644
--- a/codecs_v2/audio/aac/dec/src/apply_tns.cpp
+++ b/codecs_v2/audio/aac/dec/src/apply_tns.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,79 +16,9 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: apply_tns.c
 
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    apply_tns.c
-
-     Date: 07/26/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments.
-
- Description: Updated to interface properly with new versionn
- of tns_ar_filter.c, which had an overflow problem.
-
- Description: Updated comment for coef to change to "array of
- input coefficients."
-
- Description: Updated per review comments.
-
- Description: Pass in the q-format of the LPC coefficients
- to tns_ar_filter.c and tns_inv_filter.c.  For now,
- this q-format is hard-coded to 11.  Eventually, it will be a passed-in
- parameter.
-
- Description: Fixed two problems uncovered from unit testing.
- (1) pCoef and pTNSinfo were not being incremented correctly at the end of the
-     1st for loop.
-
- (2) pWinSfbTop was being set incorrectly.
-
- (3) Initialization of shift_amt was moved outside the check on
-     inverse_flag.  Would cause incorrect execution for tns_inv_filter.
-
- Description: Updated to accept a one q-Format per scalefactor band strategy.
- This greatly simplifies the code.
-
- Description: Modified per the requests from review.
-
- Description: It was found, during system level testing, that pCoef
- was not being initialized properly.
-
- Description: Bug found during unit testing.  pQformat array was not being
- indexed correctly by the number of scalefactor bands per window.
-
- Description: Removed #include for aac_memfuncs.h
- Also, updated comments to reflect new variable, pStartQformat.
-
- Description:
- (1) Since tns_ar_filter was modified to no longer need scratch memory,
- tns_inv_filter is the only user of scratch memory at present time.  This
- allowed me to remove the typecast to (Int *) and change the interface.
-
- (2) Updated calls to tns_ar_filter and tns_inv_filter to reflect the fact
- that the q-format for the LPC coefficients will now be passed
- via pFilt->q_lpc.
-
- Description: Updated to reflect more efficient usage of memory by the TNS
- filters.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Modified definition of SHRT_MAX by INT16_MAX
-
- Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/aac/dec/src/apply_tns.h b/codecs_v2/audio/aac/dec/src/apply_tns.h
index fa82676..85fb851 100644
--- a/codecs_v2/audio/aac/dec/src/apply_tns.h
+++ b/codecs_v2/audio/aac/dec/src/apply_tns.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 
  Pathname: ./include/apply_tns.h
 
-     Date: 07/26/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -31,6 +29,7 @@
  Description: The scratch memory was mistakenly declared here as type "Int32"
  It should have been "Int"
 
+ Who:                       Date:
  Description:
 
 
diff --git a/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h b/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h
index ca8ed05..f9de6d0 100644
--- a/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h
+++ b/codecs_v2/audio/aac/dec/src/bit_reversal_swap.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,16 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-
  Pathname: ./include/bit_reversal_swap.h
 
-     Date: 02/25/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description:  Changed definitions from Int to Int32 for Data[]
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/buf_getbits.cpp b/codecs_v2/audio/aac/dec/src/buf_getbits.cpp
index b4187bb..34f4f60 100644
--- a/codecs_v2/audio/aac/dec/src/buf_getbits.cpp
+++ b/codecs_v2/audio/aac/dec/src/buf_getbits.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: buf_getbits.c
 
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/buf_getbits.h b/codecs_v2/audio/aac/dec/src/buf_getbits.h
index 3d2e133..967dd58 100644
--- a/codecs_v2/audio/aac/dec/src/buf_getbits.h
+++ b/codecs_v2/audio/aac/dec/src/buf_getbits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+  Filename: buf_getbits.h
 
 
- Filename: buf_getbits.h
-
-
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/buffer_normalization.h b/codecs_v2/audio/aac/dec/src/buffer_normalization.h
index 6b2d25f..fbac045 100644
--- a/codecs_v2/audio/aac/dec/src/buffer_normalization.h
+++ b/codecs_v2/audio/aac/dec/src/buffer_normalization.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 
  Pathname: ./include/buffer_normalization.h
 
-     Date: 07/05/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -28,6 +26,7 @@
 
  Description:  Added copyrigth notice, added 'const' definitions to function
 
+ Who:                          Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/byte_align.cpp b/codecs_v2/audio/aac/dec/src/byte_align.cpp
index 0c8d3b8..e75c79e 100644
--- a/codecs_v2/audio/aac/dec/src/byte_align.cpp
+++ b/codecs_v2/audio/aac/dec/src/byte_align.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,33 +16,6 @@
  * -------------------------------------------------------------------
  */
 /*
-
- Pathname: ./src/AAC_decod/byte_align.c
- Funtions:
-    byte_align
-
-
-     Date: 10/25/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original code
-
- Description:  Modified to use unary operators rather than mathematical
-               operations
-
- Description:  Modified to remove file I/O
-
- Description:  Change structure name
-
- Description:  Update per review comments
-
- Description:  Update pseudo-code per review comments
-
- Description:  Remove header file
-
- Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp b/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp
index 5c1bcf3..9ffe1d7 100644
--- a/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp
+++ b/codecs_v2/audio/aac/dec/src/calc_auto_corr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: calc_auto_corr.c
 
-     Date: 07/22/2003
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/calc_auto_corr.h b/codecs_v2/audio/aac/dec/src/calc_auto_corr.h
index 99a4d22..81513f5 100644
--- a/codecs_v2/audio/aac/dec/src/calc_auto_corr.h
+++ b/codecs_v2/audio/aac/dec/src/calc_auto_corr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: calc_auto_corr.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp b/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp
index f94f8ce..4047502 100644
--- a/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp
+++ b/codecs_v2/audio/aac/dec/src/calc_gsfb_table.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,10 @@
 
  Pathname: ./src/calc_gsfb_table.c
 
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description: (1) Modified to bring in-line with PV standards
               (2) Removed if(pFrameInfo->islong), only short windows will
@@ -32,6 +30,7 @@
 
  Description: Modified per review comments
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp b/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp
index 51765ce..5ec3f69 100644
--- a/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp
+++ b/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: calc_sbr_anafilterbank.c
 
-     Date: 07/16/2003
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h b/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h
index a199b83..277a42a 100644
--- a/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h
+++ b/codecs_v2/audio/aac/dec/src/calc_sbr_anafilterbank.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/16/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp b/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp
index 80c113e..a22054b 100644
--- a/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp
+++ b/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: calc_sbr_envelope.c
 
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h b/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h
index 98b147f..fc4bb4f 100644
--- a/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h
+++ b/codecs_v2/audio/aac/dec/src/calc_sbr_envelope.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp b/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp
index f0a4507..e557aa1 100644
--- a/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp
+++ b/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+  Filename: calc_sbr_synfilterbank.c
 
 
- Filename: calc_sbr_synfilterbank.c
-
-     Date: 07/16/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -105,7 +102,7 @@
 ----------------------------------------------------------------------------*/
 
 
-#if defined (_ARM)
+#if defined (PV_ARM_V5)
 
 
 __inline Int16 sat(Int32 y)
@@ -126,7 +123,7 @@
                                     d -= 2;
 
 
-#elif defined (_ARM_V4)
+#elif defined (PV_ARM_V4)
 
 
 __inline Int16 sat(Int32 y)
@@ -150,7 +147,7 @@
                                     c += 2;         \
                                     d -= 2;
 
-#elif defined(_ARM_GCC)
+#elif defined(PV_ARM_GCC_V5)
 
 __inline Int16 sat(Int32 y)
 {
@@ -174,6 +171,15 @@
                                     d -= 2;
 
 
+#elif defined(PV_ARM_MSC_EVC_V5)
+
+#include "armintr.h"
+
+#define saturate2( a, b, c, d)      *c = _DAddSatInt( a, a)>>16;   \
+                                    *d = _DAddSatInt( b, b)>>16;   \
+                                    c += 2;         \
+                                    d -= 2;
+
 #else
 
 
diff --git a/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h b/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h
index fb4c45f..b03662e 100644
--- a/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h
+++ b/codecs_v2/audio/aac/dec/src/calc_sbr_synfilterbank.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*
-
- Filename: calc_sbr_synfilterbank.h
- Funtions:
-    get_dse
-
-
-     Date: 07/16/2003
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Description:
-------------------------------------------------------------------------------
-
-*/
-
 /*----------------------------------------------------------------------------
 ; CONTINUE ONLY IF NOT ALREADY DEFINED
 ----------------------------------------------------------------------------*/
diff --git a/codecs_v2/audio/aac/dec/src/chans.h b/codecs_v2/audio/aac/dec/src/chans.h
index 208687f..7b30eba 100644
--- a/codecs_v2/audio/aac/dec/src/chans.h
+++ b/codecs_v2/audio/aac/dec/src/chans.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    chans.h
-
-     Date: 05/09/2001
+ Pathname:   chans.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/check_crc.cpp b/codecs_v2/audio/aac/dec/src/check_crc.cpp
index 9b84352..50a50e3 100644
--- a/codecs_v2/audio/aac/dec/src/check_crc.cpp
+++ b/codecs_v2/audio/aac/dec/src/check_crc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: check_crc.c
 
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/check_crc.h b/codecs_v2/audio/aac/dec/src/check_crc.h
index 30bb991..cece3ad 100644
--- a/codecs_v2/audio/aac/dec/src/check_crc.h
+++ b/codecs_v2/audio/aac/dec/src/check_crc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-
  Filename: check_crc.h
  Funtions:
     get_dse
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/dct16.cpp b/codecs_v2/audio/aac/dec/src/dct16.cpp
index 101f91c..75bd4ba 100644
--- a/codecs_v2/audio/aac/dec/src/dct16.cpp
+++ b/codecs_v2/audio/aac/dec/src/dct16.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: dct16.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/dct16.h b/codecs_v2/audio/aac/dec/src/dct16.h
index 408a8fb..6f8fcb2 100644
--- a/codecs_v2/audio/aac/dec/src/dct16.h
+++ b/codecs_v2/audio/aac/dec/src/dct16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/dct16.h
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/dct64.cpp b/codecs_v2/audio/aac/dec/src/dct64.cpp
index 5c0dcea..a21a814 100644
--- a/codecs_v2/audio/aac/dec/src/dct64.cpp
+++ b/codecs_v2/audio/aac/dec/src/dct64.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: dct64.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/dct64.h b/codecs_v2/audio/aac/dec/src/dct64.h
index 3c0a4db..3d5e82b 100644
--- a/codecs_v2/audio/aac/dec/src/dct64.h
+++ b/codecs_v2/audio/aac/dec/src/dct64.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/dct64.h
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp b/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp
index b1e9722..1df39c9 100644
--- a/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp
+++ b/codecs_v2/audio/aac/dec/src/decode_huff_cw_binary.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,7 +32,6 @@
     decode_huff_cw_tab11
     decode_huff_cw_scl
 
-     Date: 01/07/2002
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -52,6 +51,7 @@
               Eliminated casting and unused variables
 
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp b/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp
index 0b7457f..41cd187 100644
--- a/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp
+++ b/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: decode_noise_floorlevels.c
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -131,12 +127,12 @@
     Int32 env;
     Int32 i;
 
-    Int32 * frameInfo           = (Int32 *) & (hFrameData->frameInfo);
-    Int32   nNfb                =   hFrameData->nNfb;
-    Int32 * domain_vec          = (Int32 *) & (hFrameData->domain_vec2);
+    Int32 * frameInfo           = hFrameData->frameInfo;
+    Int32   nNfb                = hFrameData->nNfb;
+    Int32 * domain_vec          = hFrameData->domain_vec2;
 
-    Int32 * sbrNoiseFloorLevel_man = (Int32 *) & (hFrameData->sbrNoiseFloorLevel_man);
-    Int32 * prevNoiseLevel_man     = (Int32 *) & (hFrameData->prevNoiseLevel_man);
+    Int32 * sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
+    Int32 * prevNoiseLevel_man     = hFrameData->prevNoiseLevel_man;
 
     Int32 nEnv = frameInfo[(frameInfo[0] << 1) + 3];
 
diff --git a/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h b/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h
index 92c60ca..a9c3551 100644
--- a/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h
+++ b/codecs_v2/audio/aac/dec/src/decode_noise_floorlevels.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,11 @@
 
  Filename: decode_noise_floorlevels.h
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/decoder_aac.cpp b/codecs_v2/audio/aac/dec/src/decoder_aac.cpp
index ce50952..162bc39 100644
--- a/codecs_v2/audio/aac/dec/src/decoder_aac.cpp
+++ b/codecs_v2/audio/aac/dec/src/decoder_aac.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+//////////////////////////////////////////////////////////////////////////////////
 //                                                                              //
-//  File: decoder_aac.cpp                                                   //
+//  File: decoder_aac.cpp                                                       //
 //                                                                              //
 //////////////////////////////////////////////////////////////////////////////////
 
@@ -27,7 +28,7 @@
 
 #include "e_tmp4audioobjecttype.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
diff --git a/codecs_v2/audio/aac/dec/src/deinterleave.cpp b/codecs_v2/audio/aac/dec/src/deinterleave.cpp
index a2812e5..5298b19 100644
--- a/codecs_v2/audio/aac/dec/src/deinterleave.cpp
+++ b/codecs_v2/audio/aac/dec/src/deinterleave.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,10 @@
 
  Pathname: ./src/deinterleave.c
 
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description: (1) Modified with new template, rename variables
               (2) Removed for-loop to calculate win_inc, win_inc = SN2 (128)
@@ -33,6 +31,7 @@
 
  Description: Modified per review comments
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp b/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp
index 6703b58..ffa980d 100644
--- a/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp
+++ b/codecs_v2/audio/aac/dec/src/digit_reversal_tables.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,11 +20,10 @@
  Pathname: ./src/digit_reversal_tables.c
  Funtions:
 
-     Date: 9/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
   ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h b/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h
index 526e4fa..7fdaaf7 100644
--- a/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h
+++ b/codecs_v2/audio/aac/dec/src/digit_reversal_tables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,11 @@
 
  Pathname: ./include/DIGIT_REVERSAL_TABLES.h
 
-     Date: 08/21/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/dst16.cpp b/codecs_v2/audio/aac/dec/src/dst16.cpp
index 26892a7..41c9259 100644
--- a/codecs_v2/audio/aac/dec/src/dst16.cpp
+++ b/codecs_v2/audio/aac/dec/src/dst16.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: dst16.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/dst16.h b/codecs_v2/audio/aac/dec/src/dst16.h
index 125c56e..bce73ba 100644
--- a/codecs_v2/audio/aac/dec/src/dst16.h
+++ b/codecs_v2/audio/aac/dec/src/dst16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/dst16.h
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/dst32.cpp b/codecs_v2/audio/aac/dec/src/dst32.cpp
index 43db8aa..5edecf1 100644
--- a/codecs_v2/audio/aac/dec/src/dst32.cpp
+++ b/codecs_v2/audio/aac/dec/src/dst32.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: dst32.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/dst32.h b/codecs_v2/audio/aac/dec/src/dst32.h
index ff360df..c2bf1d2 100644
--- a/codecs_v2/audio/aac/dec/src/dst32.h
+++ b/codecs_v2/audio/aac/dec/src/dst32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/dst32.h
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/dst8.cpp b/codecs_v2/audio/aac/dec/src/dst8.cpp
index d92cf52..eaf8280 100644
--- a/codecs_v2/audio/aac/dec/src/dst8.cpp
+++ b/codecs_v2/audio/aac/dec/src/dst8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: dst8.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/dst8.h b/codecs_v2/audio/aac/dec/src/dst8.h
index f52dd69..2738e80 100644
--- a/codecs_v2/audio/aac/dec/src/dst8.h
+++ b/codecs_v2/audio/aac/dec/src/dst8.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/dst8.h
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/e_adif_const.h b/codecs_v2/audio/aac/dec/src/e_adif_const.h
index fcd695e..67272be 100644
--- a/codecs_v2/audio/aac/dec/src/e_adif_const.h
+++ b/codecs_v2/audio/aac/dec/src/e_adif_const.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/e_ADIF_Const.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_blockswitching.h b/codecs_v2/audio/aac/dec/src/e_blockswitching.h
index 9a55c88..d64b133 100644
--- a/codecs_v2/audio/aac/dec/src/e_blockswitching.h
+++ b/codecs_v2/audio/aac/dec/src/e_blockswitching.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/e_BlockSwitching.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_coupling_mode.h b/codecs_v2/audio/aac/dec/src/e_coupling_mode.h
index 9b1065f..68244bb 100644
--- a/codecs_v2/audio/aac/dec/src/e_coupling_mode.h
+++ b/codecs_v2/audio/aac/dec/src/e_coupling_mode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_coupling_mode.h
  Funtions:
 
-
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_elementid.h b/codecs_v2/audio/aac/dec/src/e_elementid.h
index 2612048..be748d5 100644
--- a/codecs_v2/audio/aac/dec/src/e_elementid.h
+++ b/codecs_v2/audio/aac/dec/src/e_elementid.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,14 +16,12 @@
  * -------------------------------------------------------------------
  */
 /*
-
  Pathname: ./include/e_BLOCKTYPE.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_huffmanconst.h b/codecs_v2/audio/aac/dec/src/e_huffmanconst.h
index 27cf4c1..cc690d8 100644
--- a/codecs_v2/audio/aac/dec/src/e_huffmanconst.h
+++ b/codecs_v2/audio/aac/dec/src/e_huffmanconst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/e_HuffmanConst.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_infoinitconst.h b/codecs_v2/audio/aac/dec/src/e_infoinitconst.h
index 21f74df..1a1d4bb 100644
--- a/codecs_v2/audio/aac/dec/src/e_infoinitconst.h
+++ b/codecs_v2/audio/aac/dec/src/e_infoinitconst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/e_infoinitConst.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_invf_mode.h b/codecs_v2/audio/aac/dec/src/e_invf_mode.h
index 6af42fa..57b3281 100644
--- a/codecs_v2/audio/aac/dec/src/e_invf_mode.h
+++ b/codecs_v2/audio/aac/dec/src/e_invf_mode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_invf_mode.h
  Funtions:
 
-
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_maskstatus.h b/codecs_v2/audio/aac/dec/src/e_maskstatus.h
index e74d5cc..010b6f8 100644
--- a/codecs_v2/audio/aac/dec/src/e_maskstatus.h
+++ b/codecs_v2/audio/aac/dec/src/e_maskstatus.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/e_MaskStatus.h
-
-     Date: 06/20/2001
+   Pathname: ./include/e_MaskStatus.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h b/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h
index 7d8d234..1006406 100644
--- a/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h
+++ b/codecs_v2/audio/aac/dec/src/e_mp4ff_const.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/e_MP4FF_const.h
-
-     Date: 07/10/2001
+ Pathname: e_MP4FF_const.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_progconfigconst.h b/codecs_v2/audio/aac/dec/src/e_progconfigconst.h
index 51d7c35..8c6ca51 100644
--- a/codecs_v2/audio/aac/dec/src/e_progconfigconst.h
+++ b/codecs_v2/audio/aac/dec/src/e_progconfigconst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/e_ProgConfigConst.h
-
-     Date: 05/18/2001
+ Pathname: e_ProgConfigConst.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h b/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h
index 70683b9..bceba1f 100644
--- a/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h
+++ b/codecs_v2/audio/aac/dec/src/e_rawbitstreamconst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/e_RawBitstreamConst.h
-
-     Date: 05/18/2001
+   Pathname: e_RawBitstreamConst.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h b/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h
index cc2c430..1b021ff 100644
--- a/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h
+++ b/codecs_v2/audio/aac/dec/src/e_sbr_element_id.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_sbr_element_id.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_sbr_error.h b/codecs_v2/audio/aac/dec/src/e_sbr_error.h
index df65445..b6c8a90 100644
--- a/codecs_v2/audio/aac/dec/src/e_sbr_error.h
+++ b/codecs_v2/audio/aac/dec/src/e_sbr_error.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,16 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_sbr_error.h
  Funtions:
 
 
-     Date: 10/31/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h b/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h
index ab856b9..5b2a43f 100644
--- a/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h
+++ b/codecs_v2/audio/aac/dec/src/e_sbr_header_status.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_sbr_header_status.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h b/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h
index 105d7cf..16e43a4 100644
--- a/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h
+++ b/codecs_v2/audio/aac/dec/src/e_sbr_master_status.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_sbr_master_status.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h b/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h
index 924567b..d9f8669 100644
--- a/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h
+++ b/codecs_v2/audio/aac/dec/src/e_sbr_sync_state.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_sbr_sync_state.h
  Funtions:
 
-
-     Date: 10/31/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_sr_mode.h b/codecs_v2/audio/aac/dec/src/e_sr_mode.h
index e7a9cd1..eff00dd 100644
--- a/codecs_v2/audio/aac/dec/src/e_sr_mode.h
+++ b/codecs_v2/audio/aac/dec/src/e_sr_mode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,16 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: e_sr_mode.h
  Funtions:
 
 
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/e_tns_const.h b/codecs_v2/audio/aac/dec/src/e_tns_const.h
index 32b86d9..157d471 100644
--- a/codecs_v2/audio/aac/dec/src/e_tns_const.h
+++ b/codecs_v2/audio/aac/dec/src/e_tns_const.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/e_TNS_Const.h
-
-     Date: 05/18/2001
+  Pathname: ./include/e_TNS_Const.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_window_sequence.h b/codecs_v2/audio/aac/dec/src/e_window_sequence.h
index 28dfaa4..c4b933e 100644
--- a/codecs_v2/audio/aac/dec/src/e_window_sequence.h
+++ b/codecs_v2/audio/aac/dec/src/e_window_sequence.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/e_WINDOW_SEQUENCE.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/e_window_shape.h b/codecs_v2/audio/aac/dec/src/e_window_shape.h
index c3981b2..3eca438 100644
--- a/codecs_v2/audio/aac/dec/src/e_window_shape.h
+++ b/codecs_v2/audio/aac/dec/src/e_window_shape.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/e_Window_shape.h
-
-     Date: 05/18/2001
+ Pathname: e_Window_shape.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp b/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp
index 7e16886..87cabfd 100644
--- a/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp
+++ b/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
  Pathname: ./src/esc_iquant_scaling.c
  Funtions:  esc_iquant_scaling
 
-     Date: 9/16/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -29,6 +27,7 @@
 
  Description:  Eliminated unused variables to avoid warnings, changed header
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -400,8 +399,7 @@
 #define pv_abs(x)	abs2(x)
 
 
-#elif defined(_ARM_GCC)
-
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 
 /*
  *  Absolute value for 16 bit-numbers
diff --git a/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h b/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h
index 1bfac54..5ac598c 100644
--- a/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h
+++ b/codecs_v2/audio/aac/dec/src/esc_iquant_scaling.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/esc_iquant_scaling.h
 
-     Date: 09/23/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp b/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp
index b0931ff..571cc98 100644
--- a/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp
+++ b/codecs_v2/audio/aac/dec/src/extractframeinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,16 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
- Filename: extractframeInfo.c
-
-     Date: 07/23/2003
+  Filename: extractframeInfo.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/extractframeinfo.h b/codecs_v2/audio/aac/dec/src/extractframeinfo.h
index e60a7b9..08b9d3c 100644
--- a/codecs_v2/audio/aac/dec/src/extractframeinfo.h
+++ b/codecs_v2/audio/aac/dec/src/extractframeinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: extractFrameInfo.h
 
 
-
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/fft_rx4.h b/codecs_v2/audio/aac/dec/src/fft_rx4.h
index dd6f109..8e7acb3 100644
--- a/codecs_v2/audio/aac/dec/src/fft_rx4.h
+++ b/codecs_v2/audio/aac/dec/src/fft_rx4.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,13 +19,12 @@
 
  Pathname: ./include/fft_rx4.h
 
-     Date: 08/09/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
         (1) modified definition of w_64rx4 from Int to Int16
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp b/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp
index 74f57b6..ee7ce55 100644
--- a/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp
+++ b/codecs_v2/audio/aac/dec/src/fft_rx4_long.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
  Pathname: ./src/fft_rx4_long.c
  Funtions: fft_rx4_long
 
-     Date: 9/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +42,7 @@
             (1) Added comment to explain max search elimination and
                 Q format during multiplications
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp b/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp
index a3fabe3..408bc83 100644
--- a/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp
+++ b/codecs_v2/audio/aac/dec/src/fft_rx4_short.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
  Pathname: ./src/fft_rx4_short.c
  Funtions: fft_rx4_short
 
-     Date: 9/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -41,6 +39,7 @@
                 numbers will not overflow when 2 consecutive adds are done
                 This was found during code review.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp b/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp
index ba10a65..9e72dba 100644
--- a/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/fft_rx4_tables_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
  Pathname: ./src/fft_rx4_tables_fxp.c
  Funtions:
 
-     Date: 9/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -39,6 +37,7 @@
         (2) modified definition of w_64rx4 from Int to Int16
 
 
+ Who:                           Date:
  Description:
 
   ----------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/find_adts_syncword.cpp b/codecs_v2/audio/aac/dec/src/find_adts_syncword.cpp
index 5d431c2..89ce45f 100644
--- a/codecs_v2/audio/aac/dec/src/find_adts_syncword.cpp
+++ b/codecs_v2/audio/aac/dec/src/find_adts_syncword.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 
  Pathname: ./src/find_adts_syncword.c
 
-     Date: 5/22/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/aac/dec/src/find_adts_syncword.h b/codecs_v2/audio/aac/dec/src/find_adts_syncword.h
index ae3d8b8..d147bc5 100644
--- a/codecs_v2/audio/aac/dec/src/find_adts_syncword.h
+++ b/codecs_v2/audio/aac/dec/src/find_adts_syncword.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/find_adts_syncword.h
 
-     Date: 05/22/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp b/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp
index 7ad949c..b85c7df 100644
--- a/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp
+++ b/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
  Pathname: ./src/fwd_long_complex_rot.c
  Funtions: fwd_long_complex_rot
 
-     Date: 9/30/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h b/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h
index 61980e7..5978906 100644
--- a/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h
+++ b/codecs_v2/audio/aac/dec/src/fwd_long_complex_rot.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,11 @@
 
  Pathname: ./include/fwd_long_complex_rot.h
 
-     Date: 08/21/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp b/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp
index 06617f4..964f766 100644
--- a/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp
+++ b/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,9 @@
  * -------------------------------------------------------------------
  */
 /*
-
  Pathname: ./src/fwd_short_complex_rot.c
  Funtions:  fwd_short_complex_rot
 
-     Date: 9/30/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h b/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h
index eb9658e..3d1e1f1 100644
--- a/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h
+++ b/codecs_v2/audio/aac/dec/src/fwd_short_complex_rot.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,13 @@
  */
 /*
 
- Pathname: ./include/fwd_short_complex_rot.h
-
-     Date: 08/21/2002
+ Pathname: .fwd_short_complex_rot.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32.h b/codecs_v2/audio/aac/dec/src/fxp_mul32.h
index 8c20798..230cef5 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/fxp_mul32.h
 
-     Date: 03/14/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -37,43 +33,40 @@
 #ifndef FXP_MUL32
 #define FXP_MUL32
 
-
-#if defined(_ARM)
+#if   defined(PV_ARM_V5)
 
 #include "fxp_mul32_arm_v5.h"
 
-#endif
+#elif defined(PV_ARM_V4)
 
-#if defined(C_EQUIVALENT)
+#include "fxp_mul32_arm_v4.h"
+
+#elif defined(PV_ARM_MSC_EVC_V4)
+
+#include "fxp_mul32_c_msc_evc.h"
+
+#elif defined(PV_ARM_MSC_EVC_V5)
+
+#include "fxp_mul32_c_msc_evc_armv5.h"
+
+#elif defined(PV_ARM_GCC_V5)
+
+#include "fxp_mul32_arm_gcc.h"
+
+#elif defined(PV_ARM_GCC_V4)
+
+#include "fxp_mul32_arm_v4_gcc.h"
+
+#else
+
+#ifndef C_EQUIVALENT
+#define C_EQUIVALENT
+#endif
 
 #include "fxp_mul32_c_equivalent.h"
 
 #endif
 
-#if defined(_ARM_V4)
-
-#include "fxp_mul32_arm_v4.h"
-
-#endif
-
-#if defined(_MSC_EVC)
-
-#include "fxp_mul32_c_msc_evc.h"
-
-#endif
-
-
-#if defined(_ARM_GCC)
-
-#include "fxp_mul32_arm_gcc.h"
-
-#endif
-
-#if defined(_ARM_V4_GCC)
-
-#include "fxp_mul32_arm_v4_gcc.h"
-
-#endif
 
 #endif   /*  FXP_MUL32  */
 
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h
index 5dc6c10..dc58976 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_gcc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/fxp_mul32_arm_gcc.h
 
-     Date: 12/06/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -47,7 +43,7 @@
 #include "pv_audio_type_defs.h"
 
 
-#if defined (_ARM_GCC) /* ARM GNU COMPILER  */
+#if (defined (PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5)) /* ARM GNU COMPILER  */
 
 
 
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4.h
index fb08eaf..6869c54 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: fxp_mul32_c_equivalent.h
 
 
- Pathname: ./c/include/fxp_mul32_c_equivalent.h
-
-     Date: 12/06/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -47,7 +44,7 @@
 #include "pv_audio_type_defs.h"
 
 
-#if defined(_ARM_V4)
+#if defined(PV_ARM_V4)
 
 #define preload_cache( a)
 
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h
old mode 100755
new mode 100644
index b9cae21..f4ab2f7
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v4_gcc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/fxp_mul32_arm_v4_gcc.h
-
-     Date: 1/26/2007
+ Pathname: fxp_mul32_arm_v4_gcc.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v5.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v5.h
index 364525a..8ab108f 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v5.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_arm_v5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/fxp_mul32_arm_v5.h
 
-     Date: 12/06/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -46,7 +42,7 @@
 #include "pv_audio_type_defs.h"
 
 
-#if defined(_ARM)
+#if defined(PV_ARM_V5)
 
 //#undef EXTENDED_ASM
 #define EXTENDED_ASM
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h
index 626bd14..f324bdf 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_c_equivalent.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./c/include/fxp_mul32_c_equivalent.h
 
-     Date: 12/06/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc.h
index cf699c9..3ae649d 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/fxp_mul32_msc_evc.h
-
-     Date: 07/09/2006
+ Pathname: fxp_mul32_msc_evc.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -47,7 +43,7 @@
 
 #include "pv_audio_type_defs.h"
 
-#if defined(_MSC_EVC)
+#if defined(PV_ARM_MSC_EVC_V4)
 
 #include "cmnintrin.h"
 
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc_armv5.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc_armv5.h
index 0f87be1..77d3dcd 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc_armv5.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_c_msc_evc_armv5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/fxp_mul32_msc_evc_armv5.h
-
-     Date: 08/31/2006
+ Pathname: .fxp_mul32_msc_evc_armv5.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -46,6 +42,131 @@
 
 #include "pv_audio_type_defs.h"
 
+#if defined(PV_ARM_MSC_EVC_V5)
+
+#include "armintr.h"
+#include "cmnintrin.h"
+
+#define preload_cache( a)
+
+#define shft_lft_1( L_var1)  _AddSatInt( L_var1, L_var1)
+
+#define fxp_mul_16_by_16bb( L_var1, L_var2)  _SmulLo_SW_SL( L_var1, L_var2)
+
+#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
+
+#define fxp_mul_16_by_16tb( L_var1, L_var2)  _SmulHiLo_SW_SL( L_var1, L_var2)
+
+#define fxp_mul_16_by_16bt( L_var1, L_var2)  _SmulLoHi_SW_SL( L_var1, L_var2)
+
+#define fxp_mul_16_by_16tt( L_var1, L_var2)  _SmulHi_SW_SL( L_var1, L_var2)
+
+#define fxp_mac_16_by_16( L_var1, L_var2, L_add)  _SmulAddLo_SW_SL( L_add, L_var1, L_var2)
+
+#define fxp_mac_16_by_16_bb(a, b, c)  fxp_mac_16_by_16(  a, b, c)
+
+#define fxp_mac_16_by_16_bt( L_var1, L_var2, L_add)  _SmulAddLoHi_SW_SL( L_add, L_var1, L_var2)
+
+
+    __inline  Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
+    {
+        Int32 result64_hi;
+
+        result64_hi = _SmulWHi_SW_SL(L_var1, cmplx);
+        result64_hi = _SmulAddWLo_SW_SL(result64_hi, L_var2, cmplx);
+
+        return (result64_hi);
+    }
+
+#define fxp_mul32_by_16( L_var1, L_var2)  _SmulWLo_SW_SL( L_var1, L_var2)
+
+#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
+
+#define fxp_mul32_by_16t( L_var1, L_var2)  _SmulWHi_SW_SL( L_var1, L_var2)
+
+#define fxp_mac32_by_16( L_var1, L_var2, L_add)  _SmulAddWLo_SW_SL( L_add, L_var1, L_var2)
+
+
+    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
+    {
+        sum += (int64)L_var1 * L_var2;
+        return (sum);
+    }
+
+#define fxp_mul32_Q31( a,  b)	_MulHigh( b, a)
+
+
+    __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
+    {
+        return (L_add + _MulHigh(b, a));
+    }
+
+
+    __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
+    {
+        return (L_sub - _MulHigh(b, a));
+    }
+
+
+    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 30);
+    }
+
+    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
+    {
+        return (L_add + (Int32)(((int64)(a) * b) >> 30));
+    }
+
+
+    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 29);
+    }
+
+    __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
+    {
+        return (L_add + (Int32)(((int64)(a) * b) >> 29));
+    }
+
+    __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
+    {
+        return (L_sub - (Int32)(((int64)(a) * b) >> 29));
+    }
+
+
+    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 28);
+    }
+
+    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 27);
+    }
+
+    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 26);
+    }
+
+    __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 20);
+    }
+
+    __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 15);
+    }
+
+    __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
+    {
+        return (Int32)(((int64)(a) * b) >> 14);
+    }
+
+
+#endif
 
 
 #ifdef __cplusplus
diff --git a/codecs_v2/audio/aac/dec/src/fxp_mul32_pentium.h b/codecs_v2/audio/aac/dec/src/fxp_mul32_pentium.h
index bb15e97..72862e7 100644
--- a/codecs_v2/audio/aac/dec/src/fxp_mul32_pentium.h
+++ b/codecs_v2/audio/aac/dec/src/fxp_mul32_pentium.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/fxp_mul32_pentium.h
-
-     Date: 12/06/2005
+ Pathname: .fxp_mul32_pentium.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp b/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp
index f97a747..08ccc4a 100644
--- a/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp
+++ b/codecs_v2/audio/aac/dec/src/gen_rand_vector.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,11 @@
  */
 /*
 
- Pathname: ./src/gen_rand_vector.c
-
-     Date: 10/25/2000
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to remove instances of pow() and sqrt(), and
  optimized for inclusion in fixed-point version of decoder.
diff --git a/codecs_v2/audio/aac/dec/src/gen_rand_vector.h b/codecs_v2/audio/aac/dec/src/gen_rand_vector.h
index 84e4969..7826694 100644
--- a/codecs_v2/audio/aac/dec/src/gen_rand_vector.h
+++ b/codecs_v2/audio/aac/dec/src/gen_rand_vector.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/gen_rand_vector.h
-
-     Date: 03/20/2001
+ Pathname: gen_rand_vector.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Added include of pv_audio_type_defs.h
 
+ Who:						Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/get_adif_header.cpp b/codecs_v2/audio/aac/dec/src/get_adif_header.cpp
index 821db38..cbe517d 100644
--- a/codecs_v2/audio/aac/dec/src/get_adif_header.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_adif_header.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    get_adif_header.c
-
-     Date: 10/25/2000
+ Pathname: get_adif_header.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -53,6 +42,7 @@
  Description: Updated the SW template to include the full pathname to the
  source file and a slightly modified copyright header.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_adif_header.h b/codecs_v2/audio/aac/dec/src/get_adif_header.h
index a101d04..8bc3411 100644
--- a/codecs_v2/audio/aac/dec/src/get_adif_header.h
+++ b/codecs_v2/audio/aac/dec/src/get_adif_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/get_adif_header.h
-
-     Date: 05/15/2001
+ Pathname: get_adif_header.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Add parameter to get_adif_header() function.
 
+ Who:                                      Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_adts_header.cpp b/codecs_v2/audio/aac/dec/src/get_adts_header.cpp
index 4b0f643..3ac2756 100644
--- a/codecs_v2/audio/aac/dec/src/get_adts_header.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_adts_header.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./src/get_adts_header.c
-
-     Date: 5/22/2001
+ Pathname: get_adts_header.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -33,6 +31,7 @@
               (3) use (profile + 1) when calling set_mc_info
               (4) use winmap when calling set_mc_info
 
+ Who:                                          Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_adts_header.h b/codecs_v2/audio/aac/dec/src/get_adts_header.h
index d08b6ce..13afa05 100644
--- a/codecs_v2/audio/aac/dec/src/get_adts_header.h
+++ b/codecs_v2/audio/aac/dec/src/get_adts_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/get_adts_header.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp b/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp
index 395615d..44f5ba2 100644
--- a/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_audio_specific_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 
  Pathname: ./src/get_audio_specific_config.c
 
-     Date: 07/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +42,7 @@
  Description: Added support for backward and non-backward (explicit)
               mode for Parametric Stereo (PS) used in enhanced AAC+
 
+ Who:                              Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -360,12 +359,17 @@
 
     channel_config =  get9_n_lessbits(LEN_CHAN_CONFIG,
                                       pInputStream);
-#if !defined(AAC_UTILITIES)
-    if (channel_config > 2)
+
+    if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled))
     {
-        status = 1; /* do not support more than two channels */
+        /*
+         * AAC lib does not support more than two channels
+         * signal error when in decoder mode
+         * do not test when in utility mode
+         */
+        status = 1;
+
     }
-#endif
 
     if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS)
     {
@@ -501,9 +505,9 @@
                         pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
                     }
 
+                    pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType;
                 }
             }
-            pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType;
         }
         else if (!status)
         {
diff --git a/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h b/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h
index c21c9d1..b7cfcf5 100644
--- a/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h
+++ b/codecs_v2/audio/aac/dec/src/get_audio_specific_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/get_audio_specific_config.h
 
-     Date: 07/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                              Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_dse.cpp b/codecs_v2/audio/aac/dec/src/get_dse.cpp
index df2f9b9..d64087f 100644
--- a/codecs_v2/audio/aac/dec/src/get_dse.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_dse.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,23 +17,6 @@
  */
 /*
 ------------------------------------------------------------------------------
-
-
- Pathname: ./src/AAC_decod/get_dse.c
- Funtions:
-    byte_align
-
-
-     Date: 11/14/2002
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Description: Added casting (Char) to avoid warnings
-
- Description:
-------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
  Inputs:
diff --git a/codecs_v2/audio/aac/dec/src/get_dse.h b/codecs_v2/audio/aac/dec/src/get_dse.h
index f179670..3563f71 100644
--- a/codecs_v2/audio/aac/dec/src/get_dse.h
+++ b/codecs_v2/audio/aac/dec/src/get_dse.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,17 +17,16 @@
  */
 /*
 
- Pathname: ./src/AAC_decod/get_dse.h
+ Pathname: get_dse.h
  Funtions:
     get_dse
 
 
-     Date: 11/14/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/get_ele_list.cpp b/codecs_v2/audio/aac/dec/src/get_ele_list.cpp
index 0cc0e5b..7d91e38 100644
--- a/codecs_v2/audio/aac/dec/src/get_ele_list.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_ele_list.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    get_ele_list.c
-
-     Date: 10/25/2000
+ Pathname: get_ele_list.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -55,6 +44,7 @@
 			  when the number of bits read is 9 or less and get1bits
 			  when only 1 bit is read.
 
+ Who:                                 Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/get_ele_list.h b/codecs_v2/audio/aac/dec/src/get_ele_list.h
index 5e2cc88..82f140b 100644
--- a/codecs_v2/audio/aac/dec/src/get_ele_list.h
+++ b/codecs_v2/audio/aac/dec/src/get_ele_list.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/get_ele_list.h
 
-     Date: 05/18/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp b/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp
index 6597c0f..6e7f5ce 100644
--- a/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_ga_specific_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    get_GA_specific_config.c
-
-     Date: 07/10/2001
+ Pathname: get_GA_specific_config.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -47,6 +36,7 @@
  Description: Replace some instances of getbits to get1bits
 			  when only 1 bit is read.
 
+ Who:                               Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -364,6 +354,9 @@
     extFlag = get1bits(pInputStream);       /*  LEN_EXT_FLAG,*/
 
 
+    /* Force checks for implicit channel configuration */
+    pVars->mc_info.implicit_channeling = 1;
+
     if (status == SUCCESS)
     {
 
@@ -374,8 +367,6 @@
 
             if (status != SUCCESS)
             {
-                /* this may be implicit channel configuration */
-                pVars->mc_info.implicit_channeling = 1;
                 pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono  */
                 pVars->mc_info.nch = 1;
                 pVars->prog_config.front.ele_tag[0] = 0;
diff --git a/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h b/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h
index b67d915..7c77da5 100644
--- a/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h
+++ b/codecs_v2/audio/aac/dec/src/get_ga_specific_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/get_GA_specific_config.h
-
-     Date: 07/10/2001
+ Pathname: get_GA_specific_config.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -27,6 +25,7 @@
  Description: (1) use enum type for audioObjectType
               (2) update revision history
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/get_ics_info.cpp b/codecs_v2/audio/aac/dec/src/get_ics_info.cpp
index 2802cbd..09cdac5 100644
--- a/codecs_v2/audio/aac/dec/src/get_ics_info.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_ics_info.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,12 +19,10 @@
 
  Pathname: ./src/get_ics_info.c
 
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -43,6 +41,7 @@
 			  when the number of bits read is 9 or less and get1bits
 			  when only 1 bit is read.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_ics_info.h b/codecs_v2/audio/aac/dec/src/get_ics_info.h
index f3c126c..b94ef8e 100644
--- a/codecs_v2/audio/aac/dec/src/get_ics_info.h
+++ b/codecs_v2/audio/aac/dec/src/get_ics_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,10 @@
 
  Pathname: ./include/get_ics_info.h
 
-     Date: 07/10/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_prog_config.cpp b/codecs_v2/audio/aac/dec/src/get_prog_config.cpp
index eac0cb5..ecf5376 100644
--- a/codecs_v2/audio/aac/dec/src/get_prog_config.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_prog_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,12 @@
  */
 /*
 
- Pathname: ./src/get_prog_config.c
-
-     Date: 10/25/2000
+ Pathname: get_prog_config.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -47,6 +45,7 @@
 			  when the number of bits read is 9 or less and get1bits
 			  when only 1 bit is read.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_prog_config.h b/codecs_v2/audio/aac/dec/src/get_prog_config.h
index 648971e..646ba46 100644
--- a/codecs_v2/audio/aac/dec/src/get_prog_config.h
+++ b/codecs_v2/audio/aac/dec/src/get_prog_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/get_prog_config.h
-
-     Date: 05/15/2001
+ Pathname: get_prog_config.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                      Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp b/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp
index b6c783b..2dd712c 100644
--- a/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_pulse_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,12 @@
  */
 /*
 
- Pathname: ./src/get_pulse_data.c
-
-     Date: 10/25/2000
+ Pathname: get_pulse_data.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -44,6 +42,7 @@
  Description: Replace some instances of getbits to get9_n_lessbits
 			  when the number of bits read is 9.
 
+ Who:                                  Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/get_pulse_data.h b/codecs_v2/audio/aac/dec/src/get_pulse_data.h
index 447b98a..267f534 100644
--- a/codecs_v2/audio/aac/dec/src/get_pulse_data.h
+++ b/codecs_v2/audio/aac/dec/src/get_pulse_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/get_pulse_data.h
-
-     Date: 05/21/2001
+ Pathname: get_pulse_data.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Change structure name.
 
+ Who:                                      Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp b/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp
index f66b570..0f9deaa 100644
--- a/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: get_sbr_bitstream.c
 
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h b/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h
index 978ec42..b95b6ab 100644
--- a/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h
+++ b/codecs_v2/audio/aac/dec/src/get_sbr_bitstream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp b/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp
index f620eb3..38ddc0b 100644
--- a/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: get_sbr_startfreq.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h b/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h
index e61c186..10fa160 100644
--- a/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h
+++ b/codecs_v2/audio/aac/dec/src/get_sbr_startfreq.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp b/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp
index a1295c0..e32c61d 100644
--- a/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: get_sbr_stopfreq.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h b/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h
index 8fcde93..341a3d4 100644
--- a/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h
+++ b/codecs_v2/audio/aac/dec/src/get_sbr_stopfreq.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/get_sign_bits.h b/codecs_v2/audio/aac/dec/src/get_sign_bits.h
index a103873..445d2f2 100644
--- a/codecs_v2/audio/aac/dec/src/get_sign_bits.h
+++ b/codecs_v2/audio/aac/dec/src/get_sign_bits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/get_sign_bits.h
-
-     Date: 02/09/2001
+ Pathname: get_sign_bits.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -31,6 +29,7 @@
 
  Description: Fix pathname above
 
+ Who:                                               Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_tns.cpp b/codecs_v2/audio/aac/dec/src/get_tns.cpp
index d66e8cf..f8e7862 100644
--- a/codecs_v2/audio/aac/dec/src/get_tns.cpp
+++ b/codecs_v2/audio/aac/dec/src/get_tns.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    get_tns.c
+ Pathname: get_tns.c
 
      Date: 10/25/2000
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -64,6 +55,7 @@
  Description: Replace some instances of getbits to get1bits
 			  when only 1 bit is read.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/get_tns.h b/codecs_v2/audio/aac/dec/src/get_tns.h
index 60c166b..fbadef2 100644
--- a/codecs_v2/audio/aac/dec/src/get_tns.h
+++ b/codecs_v2/audio/aac/dec/src/get_tns.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,10 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: get_tns.h
 
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    get_tns.h
-
+   Author:
      Date: 03/08/2001
 
 ------------------------------------------------------------------------------
@@ -50,6 +42,7 @@
  the combination of the get_tns and tns_setup_filter routines.  Also, moved
  pInputStream to be the 2nd parameter, for a slight optimization.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/getbits.h b/codecs_v2/audio/aac/dec/src/getbits.h
index a86af68..e854be5 100644
--- a/codecs_v2/audio/aac/dec/src/getbits.h
+++ b/codecs_v2/audio/aac/dec/src/getbits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/getbits.h
-
-     Date: 02/09/2001
+ Pathname: getbits.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -28,6 +26,7 @@
 
  Description: Move structur to another file
 
+ Who:                                            Date: MM/DD/YYYY
  Description:
 
 
diff --git a/codecs_v2/audio/aac/dec/src/getfill.cpp b/codecs_v2/audio/aac/dec/src/getfill.cpp
index 201704d..2d50a98 100644
--- a/codecs_v2/audio/aac/dec/src/getfill.cpp
+++ b/codecs_v2/audio/aac/dec/src/getfill.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./AAC_baseline/pv_aac_dec/c/src/getfill.c
+ Pathname: getfill.c
  Funtions: getfill
 
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -46,6 +42,7 @@
  Description: Replace some instances of getbits to get9_n_lessbits
 			  when the number of bits read is 9 or less.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/getfill.h b/codecs_v2/audio/aac/dec/src/getfill.h
index e3bca1a..3ba976a 100644
--- a/codecs_v2/audio/aac/dec/src/getfill.h
+++ b/codecs_v2/audio/aac/dec/src/getfill.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./AAC_baseline/pv_aac_dec/c/include/getfill.h
-
-     Date: 07/05/2001
+ Pathname: getfill.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -29,6 +25,7 @@
  Description: Changed "definition" to "declaration" on line 28 per
               review comments.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/getgroup.cpp b/codecs_v2/audio/aac/dec/src/getgroup.cpp
index e7567f4..2809fbb 100644
--- a/codecs_v2/audio/aac/dec/src/getgroup.cpp
+++ b/codecs_v2/audio/aac/dec/src/getgroup.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./src/getgroup.c
-
-     Date: 10/25/2000
+ Pathname: getgroup.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -39,6 +35,7 @@
  Description: Replace some instances of getbits to get9_n_lessbits
 			  when the number of bits read is 9 or less.
 
+ Who:                       Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/getics.cpp b/codecs_v2/audio/aac/dec/src/getics.cpp
index 37aae28..01eb811 100644
--- a/codecs_v2/audio/aac/dec/src/getics.cpp
+++ b/codecs_v2/audio/aac/dec/src/getics.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    getics.c
-
-     Date: 10/25/2000
+ Pathname: getics.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables
diff --git a/codecs_v2/audio/aac/dec/src/getmask.cpp b/codecs_v2/audio/aac/dec/src/getmask.cpp
index bfb3630..9c737f0 100644
--- a/codecs_v2/audio/aac/dec/src/getmask.cpp
+++ b/codecs_v2/audio/aac/dec/src/getmask.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,12 @@
  */
 /*
 
- Pathname: ./src/getmask.c
-
-     Date: 10/25/2000
+ Pathname: getmask.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -46,6 +44,7 @@
  Description: Replace some instances of getbits to get9_n_lessbits
 			  when the number of bits read is 9 or less.
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/hcbtables.h b/codecs_v2/audio/aac/dec/src/hcbtables.h
index 69fec26..a35fed0 100644
--- a/codecs_v2/audio/aac/dec/src/hcbtables.h
+++ b/codecs_v2/audio/aac/dec/src/hcbtables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./include/hcbtables.h
-
-     Date: 05/01/2001
+ Pathname: hcbtables.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -35,6 +31,7 @@
 
  Description: (1) Add declaration different huffman tables
 
+ Who:                              Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp b/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp
index 26b1ce9..d097af1 100644
--- a/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp
+++ b/codecs_v2/audio/aac/dec/src/hcbtables_binary.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,8 @@
  */
 /*
 
- Pathname: ./src/hcbtables.c
+ Pathname: hcbtables.c
 
-     Date: 01/07/2002
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -38,6 +37,7 @@
                 hcbbook_binary
 
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/huffcb.cpp b/codecs_v2/audio/aac/dec/src/huffcb.cpp
index a21f25b..139850c 100644
--- a/codecs_v2/audio/aac/dec/src/huffcb.cpp
+++ b/codecs_v2/audio/aac/dec/src/huffcb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,12 +22,10 @@
     huffcb
 
 
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
diff --git a/codecs_v2/audio/aac/dec/src/huffdecode.cpp b/codecs_v2/audio/aac/dec/src/huffdecode.cpp
index 821afa7..4c39ebb 100644
--- a/codecs_v2/audio/aac/dec/src/huffdecode.cpp
+++ b/codecs_v2/audio/aac/dec/src/huffdecode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    huffdecode.c
-
-     Date: 10/25/2000
+ Pathname: huffdecode.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -420,22 +409,28 @@
 
     pMcInfo = &pVars->mc_info;
 
+    /*
+     *  check if provided info (num of channels) on audio config,
+     *  matches read bitstream data, if not, allow update only once.
+     *  In almost all cases it should match.
+     */
     if ((pMcInfo->ch_info[0].cpe != id_syn_ele))
     {
-        if (pVars->mc_info.implicit_channeling)
+        if (pVars->mc_info.implicit_channeling)     /* check done only once */
         {
-            pMcInfo->ch_info[0].cpe = 1;  /* stream is really stereo */
-            pVars->mc_info.implicit_channeling = 0; /* disable flag, as this is allowed
-                                                     * only the first time
+            pMcInfo->ch_info[0].cpe = id_syn_ele & 1; /*  collect info from bitstream
+                                                     *  implicit_channeling flag is locked
+                                                     *  after 1st frame, to avoid toggling
+                                                     *  parameter in the middle of the clip
                                                      */
+            pMcInfo->nch = (id_syn_ele & 1) + 1;     /* update number of channels */
         }
         else
         {
-            status = 1; /* ERROR Code */
+            status = 1; /* ERROR break if syntax error persist  */
         }
     }
 
-
     if (status == SUCCESS)
     {
         if (id_syn_ele == ID_SCE)
diff --git a/codecs_v2/audio/aac/dec/src/hufffac.cpp b/codecs_v2/audio/aac/dec/src/hufffac.cpp
index 059057f..e5a9c59 100644
--- a/codecs_v2/audio/aac/dec/src/hufffac.cpp
+++ b/codecs_v2/audio/aac/dec/src/hufffac.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,10 @@
  Funtions:
     hufffac
 
-
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -50,6 +47,7 @@
 
  Description: Use decode_huff_scl function.
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/huffman.h b/codecs_v2/audio/aac/dec/src/huffman.h
index 0540c41..acb5e51 100644
--- a/codecs_v2/audio/aac/dec/src/huffman.h
+++ b/codecs_v2/audio/aac/dec/src/huffman.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/huffman.h
-
-     Date: 04/24/2001
+ Pathname: .huffman.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -48,6 +46,7 @@
  Description: Added function definition for table specific huffman decoding
 			  functions.
 
+ Who:                                         Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -155,7 +154,7 @@
     Int decode_huff_scl(
         BITS          *pInputStream);
 
-    void infoinit(
+    Int infoinit(
         const  Int sampling_rate_idx,
         FrameInfo   **ppWin_seq_info,
         Int    *pSfbwidth128);
diff --git a/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp b/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp
index 5518be0..629a280 100644
--- a/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/huffspec_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,17 +17,14 @@
  */
 /*
 
- Pathname:  ./src/huffspec_fxp.c
+ Pathname:  huffspec_fxp.c
  Funtions:
     huffspec_fxp
 
-
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -88,6 +85,7 @@
               /ropi option (Read-only position independent) for some
               compilers
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
@@ -471,6 +469,8 @@
                 case 11:
                     pDec_huff_tab = decode_huff_cw_tab11;
                     break;
+                default:
+                    return (-1); /* error condition */
             }
 
             /* move ptr to first sfb of current section */
diff --git a/codecs_v2/audio/aac/dec/src/ibstream.h b/codecs_v2/audio/aac/dec/src/ibstream.h
index 87d7592..8b644dc 100644
--- a/codecs_v2/audio/aac/dec/src/ibstream.h
+++ b/codecs_v2/audio/aac/dec/src/ibstream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/ibstream.h
-
-     Date: 02/21/2001
+ Pathname: ibstream.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -33,6 +31,7 @@
  Description: Change input buffer to UChar
               Add constant
 
+ Who:                                              Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/idct16.cpp b/codecs_v2/audio/aac/dec/src/idct16.cpp
index d9dd45d..324fe9e 100644
--- a/codecs_v2/audio/aac/dec/src/idct16.cpp
+++ b/codecs_v2/audio/aac/dec/src/idct16.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: idct16.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/idct16.h b/codecs_v2/audio/aac/dec/src/idct16.h
index f47c184..afade07 100644
--- a/codecs_v2/audio/aac/dec/src/idct16.h
+++ b/codecs_v2/audio/aac/dec/src/idct16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/idct16.h
-
-     Date: 02/04/2004
+  Pathname: idct16.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/idct32.cpp b/codecs_v2/audio/aac/dec/src/idct32.cpp
index 43c8621..ac9773b 100644
--- a/codecs_v2/audio/aac/dec/src/idct32.cpp
+++ b/codecs_v2/audio/aac/dec/src/idct32.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Filename: idct32.c
-
-     Date: 02/04/2004
+  Filename: idct32.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/idct32.h b/codecs_v2/audio/aac/dec/src/idct32.h
index 8903e17..12c685a 100644
--- a/codecs_v2/audio/aac/dec/src/idct32.h
+++ b/codecs_v2/audio/aac/dec/src/idct32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/idct32.h
-
-     Date: 02/04/2004
+ Pathname: idct32.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/idct8.cpp b/codecs_v2/audio/aac/dec/src/idct8.cpp
index 2e0eca4..0a9720c 100644
--- a/codecs_v2/audio/aac/dec/src/idct8.cpp
+++ b/codecs_v2/audio/aac/dec/src/idct8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: idct8.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/idct8.h b/codecs_v2/audio/aac/dec/src/idct8.h
index f29eaef..ad7eaae 100644
--- a/codecs_v2/audio/aac/dec/src/idct8.h
+++ b/codecs_v2/audio/aac/dec/src/idct8.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/idct8.h
-
-     Date: 02/04/2004
+ Pathname: idct8.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp b/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp
index a5557e4..ad67f20 100644
--- a/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/imdct_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,72 +17,9 @@
  */
 /*
 
- Pathname: ./src/imdct_fxp.c
+ Pathname: imdct_fxp.c
  Funtions: imdct_fxp
 
-     Date: 2/23/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Unscambled arrays are now of type const, stored in twiddle.h
-
- Description:  Convertion to fixed point
-
- Description:  Modified according to MDCT code review comments, which applied
-               to IMDCT
-
- Description:  Modified according to IMDCT code review comments
-
- Description:  Changed definitions from Int to Int32 for Data[]
-
-
- Description:  down shifting was change to avoid overflow.
-
- Description:  Modified pointer updating schemes to avoid setting the pointers
- outside the allowable range of memory, and then rewinding them back inside
- the allowable range.  No bug existed - this just seems to be a "safer"
- method, at no penalty.
-
- Description:  When type Int holds 16 bits, there is an overflow problem.
-               This problem has its origins on the normalization routine,
-               called before the imdct_fxp(). A simplification used on
-               buffer_adaptation() offers some cycle reduction, but it fails
-               to compute the max. when 16 bits are used. To overcome this
-               problem without sacrificing cycle count, the order of the
-               computation (before calling the FFT) has been changed.
-               The problem manifest when the spectral data is equal to 0x8000,
-               when multplied by -1, the number results 0x8000 (-1), creating
-               a sign flipping problem.
-
- Description:  Modified interface so a vector with extended precision is
-               returned, this is a 32 bit vector whose MSB 16 bits will be
-               extracted later. This avoid a constant shift down. Also, the
-               number of stack variables has been reduced and casting has been
-               added to support more platforms. Added copyright notice.
-
- Description:   Eliminate constant down shifting before call to IFFT. Highest
-                precision is kept now by adaptive shifting in buffer_adaptation().
-
- Description:   Introduced a mix-radix FFT and a routine that combines the
-                post-rotation, reorder sample sequencing and normalization of
-                the time domain data. Modified function interface to accomodate
-                the normalization now done in this function.
-
- Description:   modify the mix-radix FFT input arguments, no shifts.
-
- Description:
-            (1) Changed function interface to avoid passing same parameter with
-                just a casting difference (Int and Int32)
-            (2) Updated interfaces to functions inv_short_complex_rot() and
-                inv_long_complex_rot() so no max is returned.
-            (3) Eliminated shifting after post complex rotation
-            (4) Updated normalization calculation and shift constants
-
- Description:   Eliminated unused max1 variable.
-
- Description:
-
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/aac/dec/src/imdct_fxp.h b/codecs_v2/audio/aac/dec/src/imdct_fxp.h
index 1a08f29..99e1b7d 100644
--- a/codecs_v2/audio/aac/dec/src/imdct_fxp.h
+++ b/codecs_v2/audio/aac/dec/src/imdct_fxp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/imdct_fxp.h
-
-     Date: 02/25/2001
+ Pathname: imdct_fxp.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -34,6 +32,7 @@
  Description:   Modified function interface to accomodate the normalization
                 that now is done in this function.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/infoinit.cpp b/codecs_v2/audio/aac/dec/src/infoinit.cpp
index 26c23d4..7bdcdcd 100644
--- a/codecs_v2/audio/aac/dec/src/infoinit.cpp
+++ b/codecs_v2/audio/aac/dec/src/infoinit.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: infoinit.c
 
 
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    infoinit.c
-
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -61,6 +51,7 @@
               /ropi option (Read-only position independent) for some
               compilers
 
+ Who:                               Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -216,7 +207,7 @@
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
 
-void infoinit(
+Int infoinit(
     const Int samp_rate_idx,
     FrameInfo   **ppWin_seq_info,
     Int    *pSfbwidth128)
@@ -279,6 +270,9 @@
             pt_SFbands1024  = sfb_8_1024;
             pt_SFbands128   = sfb_8_128;
             break;
+        default:
+            // sampling rate not supported
+            return -1;
     }
 
     /* long block info */
@@ -356,7 +350,6 @@
 
     } /* for win_seq ends */
 
-    /*----------------------------------------------------------------------------
-    ; Return nothing
-    ----------------------------------------------------------------------------*/
+    return SUCCESS;
+
 } /* infoinit */
diff --git a/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp b/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp
index 664ba2c..fc47dd3 100644
--- a/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp
+++ b/codecs_v2/audio/aac/dec/src/init_sbr_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: init_sbr_dec.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/init_sbr_dec.h b/codecs_v2/audio/aac/dec/src/init_sbr_dec.h
index ac11964..844fa0e 100644
--- a/codecs_v2/audio/aac/dec/src/init_sbr_dec.h
+++ b/codecs_v2/audio/aac/dec/src/init_sbr_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/intensity_right.cpp b/codecs_v2/audio/aac/dec/src/intensity_right.cpp
index 8f9bf21..106298a 100644
--- a/codecs_v2/audio/aac/dec/src/intensity_right.cpp
+++ b/codecs_v2/audio/aac/dec/src/intensity_right.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./src/intensity_right.c
-
-     Date: 07/05/2000
+ Pathname: intensity_right.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/intensity_right.h b/codecs_v2/audio/aac/dec/src/intensity_right.h
index 20c16ed..823da07 100644
--- a/codecs_v2/audio/aac/dec/src/intensity_right.h
+++ b/codecs_v2/audio/aac/dec/src/intensity_right.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/intensity_right.h
-
-     Date: 07/05/2001
+ Pathname: intensity_right.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Change ms_used from Int to Bool
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp b/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp
index 2fc18bf..a29d382 100644
--- a/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp
+++ b/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
  */
 /*
 
- Pathname: ./src/inv_long_complex_rot.c
+ Pathname: .inv_long_complex_rot.c
  Funtions:  inv_long_complex_rot
 
-     Date: 9/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h b/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h
index 079593f..8b95867 100644
--- a/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h
+++ b/codecs_v2/audio/aac/dec/src/inv_long_complex_rot.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,13 @@
  */
 /*
 
- Pathname: ./include/inv_long_complex_rot.h
-
-     Date: 08/21/2002
+ Pathname: inv_long_complex_rot.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp b/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp
index 45688f1..5b4f1c5 100644
--- a/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp
+++ b/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
  */
 /*
 
- Pathname: ./src/inv_short_complex_rot.c
+ Pathname: inv_short_complex_rot.c
  Funtions:  inv_short_complex_rot
 
-     Date: 9/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h b/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h
index 182c009..97ed730 100644
--- a/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h
+++ b/codecs_v2/audio/aac/dec/src/inv_short_complex_rot.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/inv_short_complex_rot.h
-
-     Date: 08/21/2002
+ Pathname: inv_short_complex_rot.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/iquant_table.cpp b/codecs_v2/audio/aac/dec/src/iquant_table.cpp
index 1e28d74..aee47d6 100644
--- a/codecs_v2/audio/aac/dec/src/iquant_table.cpp
+++ b/codecs_v2/audio/aac/dec/src/iquant_table.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./src/iquant_table.c
-
-     Date: 05/10/2001
+ Pathname: iquant_table.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/iquant_table.h b/codecs_v2/audio/aac/dec/src/iquant_table.h
index b444513..dadc3d0 100644
--- a/codecs_v2/audio/aac/dec/src/iquant_table.h
+++ b/codecs_v2/audio/aac/dec/src/iquant_table.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/iquant_table.h
-
-     Date: 05/10/2001
+ Pathname: iquant_table.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp b/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp
index 8b438d2..69e4c46 100644
--- a/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp
+++ b/codecs_v2/audio/aac/dec/src/long_term_prediction.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./AAC_baseline/pv_aac_dec/c/src/long_term_prediction.c
-
-     Date: 07/12/2001
+ Pathname: long_term_prediction.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/long_term_prediction.h b/codecs_v2/audio/aac/dec/src/long_term_prediction.h
index c6cda7a..014934b 100644
--- a/codecs_v2/audio/aac/dec/src/long_term_prediction.h
+++ b/codecs_v2/audio/aac/dec/src/long_term_prediction.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./AAC_baseline/pv_aac_dec/c/include/long_term_prediction.h
-
-     Date: 07/13/2001
+ Pathname: long_term_prediction.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -43,6 +39,7 @@
 
  Description:  Updated function interface with new return type
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp b/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp
index d8d1312..58d104c 100644
--- a/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp
+++ b/codecs_v2/audio/aac/dec/src/long_term_synthesis.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,9 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: long_term_synthesis.c
 
- Pathname: ./AAC_baseline/pv_aac_dec/c/src/long_term_synthesis.c
-
-     Date: 07/12/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -44,6 +41,7 @@
  Description: Changed index "wnd" in previous line 584 with "wnd_offset"
               and made other correspondent changes to the code.
 
+
  Description: Based on Ken's suggestion, modified the function with the
               passing-in Q format as scalefactor band basis in order to
               simplify TNS block functions.
@@ -75,6 +73,7 @@
     pointer and a post-increment pointer in the same line. This may not
     work with all compilers.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/long_term_synthesis.h b/codecs_v2/audio/aac/dec/src/long_term_synthesis.h
index d8e9b2b..77ff5cd 100644
--- a/codecs_v2/audio/aac/dec/src/long_term_synthesis.h
+++ b/codecs_v2/audio/aac/dec/src/long_term_synthesis.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,12 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
- Pathname: ./AAC_baseline/pv_aac_dec/c/include/long_term_synthesis.h
-
-     Date: 07/12/2001
+ Pathname: long_term_synthesis.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -33,6 +29,7 @@
  Description: Modified prototype based on review comments for new version
 	      long_term_synthesis.c.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/lt_decode.cpp b/codecs_v2/audio/aac/dec/src/lt_decode.cpp
index 3f8c443..f521430 100644
--- a/codecs_v2/audio/aac/dec/src/lt_decode.cpp
+++ b/codecs_v2/audio/aac/dec/src/lt_decode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./src/lt_decode.c
+ Pathname: lt_decode.c
 
-     Date: 10/25/2000
 
 ------------------------------------------------------------------------------
 
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -44,6 +43,7 @@
 			  when the number of bits read is 9 or less and get1bits
 			  when only 1 bit is read.
 
+ Who:                                   Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/lt_decode.h b/codecs_v2/audio/aac/dec/src/lt_decode.h
index 1b65845..c27a3d6 100644
--- a/codecs_v2/audio/aac/dec/src/lt_decode.h
+++ b/codecs_v2/audio/aac/dec/src/lt_decode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,8 @@
  */
 /*
 
- Pathname: ./include/lt_decode.h
+ Pathname: lt_decode.h
 
-     Date: 06/12/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -28,6 +27,7 @@
 
  Description: Replaced "e_WINDOW_TYPE.h" with "e_WINDOW_SEQUENCE.h"
 
+ Who:						Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/lt_prediction.h b/codecs_v2/audio/aac/dec/src/lt_prediction.h
index b8137d7..e52a1e8 100644
--- a/codecs_v2/audio/aac/dec/src/lt_prediction.h
+++ b/codecs_v2/audio/aac/dec/src/lt_prediction.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/aac/dec/src/ltp_common_internal.h b/codecs_v2/audio/aac/dec/src/ltp_common_internal.h
index b747b16..efe7bd6 100644
--- a/codecs_v2/audio/aac/dec/src/ltp_common_internal.h
+++ b/codecs_v2/audio/aac/dec/src/ltp_common_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp b/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp
index f8a0c45..df371e8 100644
--- a/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/mdct_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,56 +17,9 @@
  */
 /*
 
- Pathname: ./src/mdct_fxp.c
+ Pathname: mdct_fxp.c
  Funtions: fft_rx2
 
-     Date: 2/23/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Unscambled arrays are now of type const, stored in twiddle.h
-
- Description:  Convertion to fixed point
-
- Description:  Modified according to code review comments
-
- Description:  Changed definitions from Int to Int32 for Data[]
-
- Description:  Modified pointer updating schemes to avoid setting the pointers
- outside the allowable range of memory, and then rewinding them back inside
- the allowable range.  No bug existed - this just seems to be a "safer"
- method, at no penalty.
-
- Description:  Modified interface so a vector with extended precision is
-               returned, this is a 32 bit vector whose MSB 16 bits will be
-               extracted later. This avoid a constant shift down. Also, the
-               number of stack variables has been reduced and casting has been
-               added to support more platforms. Added copyright notice.
-
- Description:   Eliminate constant down shifting before call to FFT. Highest
-                precision is kept now by adaptive shifting in buffer_adaptation().
-
- Description:   per review comments, added comments to explain new operations.
-
- Description:   Replaced radix 2 FFT with a mix-radix FFT. Also transfer complex
-                post-rotation functionality to functions fwd_long_complex_rot()
-                and fwd_short_complex_rot(). This saves unnecessary double access
-                to memory. Also added max calculation in complex the pre-rotation
-                to eliminate the use of buffer_adaptation().
-
- Description:
-            (1) Updated interfaces to functions fwd_short_complex_rot() and
-                fwd_long_complex_rot() so no max is returned.
-            (2) Eliminated shifting after post complex rotation
-            (3) Updated normalization calculation and shift constants
-
- Date: 10/28/2002
- Description:
-            (1) Added check for max1 == 0
-
- Description:
-
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/aac/dec/src/mdct_fxp.h b/codecs_v2/audio/aac/dec/src/mdct_fxp.h
index 440c3e9..8f374f8 100644
--- a/codecs_v2/audio/aac/dec/src/mdct_fxp.h
+++ b/codecs_v2/audio/aac/dec/src/mdct_fxp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/mdct_fxp.h
-
-     Date: 02/25/2001
+ Pathname: mdct_fxp.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -30,6 +28,7 @@
  Description:  Modified interface so a vector with extended precision is
                returned. Added copyright notice.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp b/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp
index ec29662..709cbf2 100644
--- a/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/mdct_tables_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
  */
 /*
 
- Pathname: ./src/mdct_tables_fxp.c
+ Pathname: mdct_tables_fxp.c
  Funtions:
 
-     Date: 2/23/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -29,6 +27,7 @@
 
  Description:  Modified to include forward and inverse tables
 
+ Who:                       Date:
  Description:
 
   ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/mdst.cpp b/codecs_v2/audio/aac/dec/src/mdst.cpp
index 54eb07b..19f82e3 100644
--- a/codecs_v2/audio/aac/dec/src/mdst.cpp
+++ b/codecs_v2/audio/aac/dec/src/mdst.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: mdst.c
 
-     Date: 01/28/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/mdst.h b/codecs_v2/audio/aac/dec/src/mdst.h
index 1ace318..5b3e1c9 100644
--- a/codecs_v2/audio/aac/dec/src/mdst.h
+++ b/codecs_v2/audio/aac/dec/src/mdst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/mdst.h
-
-     Date: 02/04/2004
+ Pathname: mdst.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp b/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp
index ae49489..6081c46 100644
--- a/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp
+++ b/codecs_v2/audio/aac/dec/src/mix_radix_fft.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
  */
 /*
 
- Pathname: ./src/mix_radix_fft.c
+ Pathname: mix_radix_fft.c
  Funtions: mix_radix_fft
 
-     Date: 8/30/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -39,6 +37,7 @@
 
  Description:  per code review comments, eliminated unnecessary headers
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/mix_radix_fft.h b/codecs_v2/audio/aac/dec/src/mix_radix_fft.h
index ba40b9c..563c280 100644
--- a/codecs_v2/audio/aac/dec/src/mix_radix_fft.h
+++ b/codecs_v2/audio/aac/dec/src/mix_radix_fft.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/mix_radix_fft.h
-
-     Date: 09/10/2002
+ Pathname: mix_radix_fft.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ms_map_mask.h b/codecs_v2/audio/aac/dec/src/ms_map_mask.h
index 1e27ec6..d06bd87 100644
--- a/codecs_v2/audio/aac/dec/src/ms_map_mask.h
+++ b/codecs_v2/audio/aac/dec/src/ms_map_mask.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,10 @@
  */
 /*
 
- Pathname: ./include/[filename].h
-
-     Date: MM/DD/YYYY
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ms_synt.cpp b/codecs_v2/audio/aac/dec/src/ms_synt.cpp
index 0779a74..1f25516 100644
--- a/codecs_v2/audio/aac/dec/src/ms_synt.cpp
+++ b/codecs_v2/audio/aac/dec/src/ms_synt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,12 @@
  */
 /*
 
- Pathname: ./src/ms_synt.c
-
-     Date: 10/25/2000
+ Pathname: ms_synt.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Cleaned up a bit, not finished.
 
diff --git a/codecs_v2/audio/aac/dec/src/ms_synt.h b/codecs_v2/audio/aac/dec/src/ms_synt.h
index d102462..a00e6e2 100644
--- a/codecs_v2/audio/aac/dec/src/ms_synt.h
+++ b/codecs_v2/audio/aac/dec/src/ms_synt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/ms_synt.h
-
-     Date: 06/18/2001
+ Pathname: ms_synt.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -27,6 +25,7 @@
  Description:  Updated to reflect new functionality of ms_synt() routine.
  (ms_synt now only decodes one grouped scalefactor band at a time.)
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pns_corr.cpp b/codecs_v2/audio/aac/dec/src/pns_corr.cpp
index 406163d..4cfe720 100644
--- a/codecs_v2/audio/aac/dec/src/pns_corr.cpp
+++ b/codecs_v2/audio/aac/dec/src/pns_corr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./src/pns_corr.c
-
-     Date: 07/06/2001
+ Pathname: pns_corr.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -32,6 +30,7 @@
               to Int32 before it is stored.
               *(pCoefRight++) = (Int32) tempInt2 * multiplier;
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/pns_corr.h b/codecs_v2/audio/aac/dec/src/pns_corr.h
index ebf8bd2..c892a8c 100644
--- a/codecs_v2/audio/aac/dec/src/pns_corr.h
+++ b/codecs_v2/audio/aac/dec/src/pns_corr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/pns_corr.h
-
-     Date: 07/05/2001
+ Pathname: pns_corr.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Made changes per review comments.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp b/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp
index b484ef3..f2d50c1 100644
--- a/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp
+++ b/codecs_v2/audio/aac/dec/src/pns_intensity_right.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,39 +17,8 @@
  */
 /*
 
- Pathname: ./src/pns_intensity_right.c
+ Pathname: pns_intensity_right.c
 
-     Date: 07/06/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes requested during review.
-
- Description: pFactorsRight and pFactorsLeft were being indexed on a
- tot_sfb basis, but in fact, these two arrays are packed when the
- windows are grouped.  This bug would appear in grouped short windows.
-
- Description: Fixed bug where pCoefRight and pCoefLeft were bumped up
- by the number of coefficients in the group.  The problem involved the
- modification of coef_per_win, which should have not been modified.  This
- bug would appear in decoding of files with grouped short windows.
-
- Description: add pFactorsRight += sfb_per_win * wins_in_group to update the
-              scalefactors pointer to next group
-
- Description: pass in hasmask parameter. update pseudo_code.
-
- Description: hasmask should also be used when intensity is called.  Both
- hasmask AND mask_enabled must be == 1 to flag a change in the phase inside
- the intensity block.
-
- Description: Updated to remove the function ms_synt, which is now called
- from within its own function, apply_ms_synt.c
-
- Description:  Changed name from right_ch_sfb_tools_ms to pns_intensity_right
-
- Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/aac/dec/src/pns_intensity_right.h b/codecs_v2/audio/aac/dec/src/pns_intensity_right.h
index 789edad..7b6f79f 100644
--- a/codecs_v2/audio/aac/dec/src/pns_intensity_right.h
+++ b/codecs_v2/audio/aac/dec/src/pns_intensity_right.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/pns_intensity_right.h
-
-     Date: 07/05/2001
+ Pathname: pns_intensity_right.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -29,6 +27,7 @@
  Description: Changed name to from right_ch_sfb_tools_ms to intensity_right
  to more correct reflect the purpose of the function.
 
+ Who:                                  Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pns_left.cpp b/codecs_v2/audio/aac/dec/src/pns_left.cpp
index 64ed1c5..800c5b7 100644
--- a/codecs_v2/audio/aac/dec/src/pns_left.cpp
+++ b/codecs_v2/audio/aac/dec/src/pns_left.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,12 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
- Pathname: ./src/pns_left.c
-
-     Date: 10/25/2000
+ Pathname: pns_left.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Brought code in-line with PV standards.
                Merged PNS and Intensity blocks into one function.
@@ -57,6 +52,7 @@
  Description:  Modified how groups and windows are handled, as the multigroup
  case was not correct
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/pns_left.h b/codecs_v2/audio/aac/dec/src/pns_left.h
index ad80e83..c44b13c 100644
--- a/codecs_v2/audio/aac/dec/src/pns_left.h
+++ b/codecs_v2/audio/aac/dec/src/pns_left.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/pns_left.h
-
-     Date: 07/25/2001
+ Pathname: pns_left.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -27,6 +25,7 @@
  Description: Removed #defines of LEFT and RIGHT, and the extra include
  file "e_huffmanconst.h"
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp b/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp
index 1c0a681..48432f8 100644
--- a/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_all_pass_filter_coeff.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h b/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h
index c731545..0358acb 100644
--- a/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h
+++ b/codecs_v2/audio/aac/dec/src/ps_all_pass_filter_coeff.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_all_pass_filter_coeff.h
-
-     Date: 01/11/2005
+ Pathname: ps_all_pass_filter_coeff.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp b/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp
index 011b5f5..81761a6 100644
--- a/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_all_pass_fract_delay_filter.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h b/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h
index 34457b9..7f0db37 100644
--- a/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h
+++ b/codecs_v2/audio/aac/dec/src/ps_all_pass_fract_delay_filter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_all_pass_fract_delay_filter.h
-
-     Date: 02/07/2005
+ Pathname: ps_all_pass_fract_delay_filter.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp b/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp
index 537fe5e..ab15651 100644
--- a/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_allocate_decoder.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h b/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h
index 04a2b13..8e68772 100644
--- a/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h
+++ b/codecs_v2/audio/aac/dec/src/ps_allocate_decoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_allocate_decoder.h
-
-     Date: 01/17/2005
+ Pathname: ps_allocate_decoder.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_applied.cpp b/codecs_v2/audio/aac/dec/src/ps_applied.cpp
index 23bc051..77fd8a7 100644
--- a/codecs_v2/audio/aac/dec/src/ps_applied.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_applied.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_applied.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_applied.h b/codecs_v2/audio/aac/dec/src/ps_applied.h
index 23bb691..b7c2a5d 100644
--- a/codecs_v2/audio/aac/dec/src/ps_applied.h
+++ b/codecs_v2/audio/aac/dec/src/ps_applied.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_applied.h
-
-     Date: 01/11/2005
+ Pathname: ps_applied.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp b/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp
index 6be80b4..c7ed60b 100644
--- a/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_bstr_decoding.c
 
-     Date: 01/10/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h b/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h
index 8abb782..5212bf8 100644
--- a/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h
+++ b/codecs_v2/audio/aac/dec/src/ps_bstr_decoding.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_bstr_decoding.h
-
-     Date: 01/10/2005
+ Pathname: ps_bstr_decoding.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp b/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp
index 43d0117..03a53df 100644
--- a/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_channel_filtering.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_hybrid_analysis.c
 
-     Date: 01/10/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h b/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h
index e47053b..4e3f3e8 100644
--- a/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h
+++ b/codecs_v2/audio/aac/dec/src/ps_channel_filtering.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_channel_filtering.h
-
-     Date: 01/10/2005
+ Pathname: ps_channel_filtering.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_constants.h b/codecs_v2/audio/aac/dec/src/ps_constants.h
index 63cc54f..d5b2ad4 100644
--- a/codecs_v2/audio/aac/dec/src/ps_constants.h
+++ b/codecs_v2/audio/aac/dec/src/ps_constants.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp b/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp
index 16812c5..241da34 100644
--- a/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_decode_bs_utils.c
 
@@ -28,12 +25,11 @@
         map34IndexTo20
         limitMinMax
 
-     Date: 01/10/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h b/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h
index 3ad4dae..4c06a71 100644
--- a/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h
+++ b/codecs_v2/audio/aac/dec/src/ps_decode_bs_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_decode_bs_utils.h
-
-     Date: 01/10/2005
+ Pathname: ps_decode_bs_utils.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp b/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp
index c0b58e0..6776d6e 100644
--- a/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_decorrelate.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_decorrelate.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_decorrelate.h b/codecs_v2/audio/aac/dec/src/ps_decorrelate.h
index 123696b..0554303 100644
--- a/codecs_v2/audio/aac/dec/src/ps_decorrelate.h
+++ b/codecs_v2/audio/aac/dec/src/ps_decorrelate.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_decorrelate.h
-
-     Date: 01/11/2005
+ Pathname: ps_decorrelate.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp b/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp
index 52b785b..7669be3 100644
--- a/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_fft_rx8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,16 +17,15 @@
  */
 /*
 
- Pathname: ./src/fft_rx8.c
+ Pathname: fft_rx8.c
  Funtions: ps_fft_rx8
 
-     Date: 1/06/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h b/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h
index 8edaec8..6c3482e 100644
--- a/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h
+++ b/codecs_v2/audio/aac/dec/src/ps_fft_rx8.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_fft_rx8.h
-
-     Date: 01/06/2005
+ Pathname: ps_fft_rx8.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp b/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp
index b825fa3..933b07e 100644
--- a/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_hybrid_analysis.c
 
-     Date: 01/10/2005
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h b/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h
index 09fa564..92367b7 100644
--- a/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h
+++ b/codecs_v2/audio/aac/dec/src/ps_hybrid_analysis.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_hybrid_analysis.h
-
-     Date: 01/11/2005
+ Pathname: ps_hybrid_analysis.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp b/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp
index 620a2dd..4ff2385 100644
--- a/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_hybrid_filter_bank_allocation.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h b/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h
index d8fad17..da548c9 100644
--- a/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h
+++ b/codecs_v2/audio/aac/dec/src/ps_hybrid_filter_bank_allocation.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_hybrid_filter_bank_allocation.h
-
-     Date: 01/11/2005
+ Pathname: ps_hybrid_filter_bank_allocation.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp b/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp
index 2994ef1..4fbd016 100644
--- a/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_hybrid_synthesis.c
 
-     Date: 01/10/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h b/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h
index 7e9bdcf..b14b791 100644
--- a/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h
+++ b/codecs_v2/audio/aac/dec/src/ps_hybrid_synthesis.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_hybrid_synthesis.h
-
-     Date: 01/11/2005
+ Pathname: ps_hybrid_synthesis.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp b/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp
index 1970004..7027b5c 100644
--- a/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_init_stereo_mixing.c
 
-     Date: 01/11/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h b/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h
index 499d828..78172d0 100644
--- a/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h
+++ b/codecs_v2/audio/aac/dec/src/ps_init_stereo_mixing.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_init_stereo_mixing.h
-
-     Date: 01/11/2005
+ Pathname: ps_init_stereo_mixing.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp b/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp
index 59855d6..a0e8c38 100644
--- a/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_pwr_transient_detection.c
 
-     Date: 02/08/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h b/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h
index e11d57a..0cbd577 100644
--- a/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h
+++ b/codecs_v2/audio/aac/dec/src/ps_pwr_transient_detection.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_pwr_transient_detection.h
-
-     Date: 02/07/2005
+ Pathname: ps_pwr_transient_detection.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_read_data.cpp b/codecs_v2/audio/aac/dec/src/ps_read_data.cpp
index 588b05e..c49eb3d 100644
--- a/codecs_v2/audio/aac/dec/src/ps_read_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_read_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_read_data.c
 
-     Date: 01/10/2005
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -314,22 +311,22 @@
             {
                 if (ps_dec->bFineIidQ)
                 {
-                    CurrentTable = (SbrHuffman) & aBookPsIidFineFreqDecode;
+                    CurrentTable = aBookPsIidFineFreqDecode;
                 }
                 else
                 {
-                    CurrentTable = (SbrHuffman) & aBookPsIidFreqDecode;
+                    CurrentTable = aBookPsIidFreqDecode;
                 }
             }
             else
             {
                 if (ps_dec->bFineIidQ)
                 {
-                    CurrentTable = (SbrHuffman) & aBookPsIidFineTimeDecode;
+                    CurrentTable = aBookPsIidFineTimeDecode;
                 }
                 else
                 {
-                    CurrentTable = (SbrHuffman) & aBookPsIidTimeDecode;
+                    CurrentTable = aBookPsIidTimeDecode;
                 }
             }
 
@@ -349,11 +346,11 @@
             dtFlag = buf_get_1bit(hBitBuf);
             if (!dtFlag)
             {
-                CurrentTable = (SbrHuffman) & aBookPsIccFreqDecode;
+                CurrentTable = aBookPsIccFreqDecode;
             }
             else
             {
-                CurrentTable = (SbrHuffman) & aBookPsIccTimeDecode;
+                CurrentTable = aBookPsIccTimeDecode;
             }
             for (gr = 0; gr < aNoIccBins[ps_dec->freqResIcc]; gr++)
             {
diff --git a/codecs_v2/audio/aac/dec/src/ps_read_data.h b/codecs_v2/audio/aac/dec/src/ps_read_data.h
index 748cd45..68921f9 100644
--- a/codecs_v2/audio/aac/dec/src/ps_read_data.h
+++ b/codecs_v2/audio/aac/dec/src/ps_read_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_read_data.h
-
-     Date: 01/10/2005
+ Pathname: ps_read_data.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp b/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp
index bf20447..813b55d 100644
--- a/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp
+++ b/codecs_v2/audio/aac/dec/src/ps_stereo_processing.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: ps_stereo_processing.c
 
-     Date: 01/10/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h b/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h
index b335da6..7d311a8 100644
--- a/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h
+++ b/codecs_v2/audio/aac/dec/src/ps_stereo_processing.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/ps_stereo_processing.h
-
-     Date: 01/11/2005
+ Pathname: ps_stereo_processing.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pulse_nc.cpp b/codecs_v2/audio/aac/dec/src/pulse_nc.cpp
index 317ce2c..565e254 100644
--- a/codecs_v2/audio/aac/dec/src/pulse_nc.cpp
+++ b/codecs_v2/audio/aac/dec/src/pulse_nc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,12 @@
  */
 /*
 
- Pathname: ./src/pulse_nc.c
-
-     Date: 10/25/2000
+ Pathname: pulse_nc.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Modified to pass variables by reference to eliminate use
                of global variables.
@@ -35,6 +33,7 @@
 
  Description: Went back to the if-statement to check for max.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pulse_nc.h b/codecs_v2/audio/aac/dec/src/pulse_nc.h
index 301c787..938740b 100644
--- a/codecs_v2/audio/aac/dec/src/pulse_nc.h
+++ b/codecs_v2/audio/aac/dec/src/pulse_nc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,15 @@
  */
 /*
 
- Pathname: ./include/pulse_nc.h
+ Pathname: pulse_nc.h
 
-     Date: 06/12/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Pass in max as input argument.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pv_div.cpp b/codecs_v2/audio/aac/dec/src/pv_div.cpp
index a9d5b03..86d2487 100644
--- a/codecs_v2/audio/aac/dec/src/pv_div.cpp
+++ b/codecs_v2/audio/aac/dec/src/pv_div.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: pv_div.c
 
-     Date: 02/26/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pv_div.h b/codecs_v2/audio/aac/dec/src/pv_div.h
index a322d8b..2dfa8a0 100644
--- a/codecs_v2/audio/aac/dec/src/pv_div.h
+++ b/codecs_v2/audio/aac/dec/src/pv_div.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/pv_div.h
-
-     Date: 02/26/2004
+ Pathname: pv_div.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pv_log2.cpp b/codecs_v2/audio/aac/dec/src/pv_log2.cpp
index 0c0dfd3..69cbe91 100644
--- a/codecs_v2/audio/aac/dec/src/pv_log2.cpp
+++ b/codecs_v2/audio/aac/dec/src/pv_log2.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: pv_log2.c
 
-     Date: 02/26/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pv_log2.h b/codecs_v2/audio/aac/dec/src/pv_log2.h
index 4f727de..4834e82 100644
--- a/codecs_v2/audio/aac/dec/src/pv_log2.h
+++ b/codecs_v2/audio/aac/dec/src/pv_log2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/pv_log2.h
-
-     Date: 03/14/2004
+ Pathname: pv_log2.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pv_normalize.cpp b/codecs_v2/audio/aac/dec/src/pv_normalize.cpp
index fca244d..365b5ad 100644
--- a/codecs_v2/audio/aac/dec/src/pv_normalize.cpp
+++ b/codecs_v2/audio/aac/dec/src/pv_normalize.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: pv_normalize.c
 
-     Date: 12/10/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -102,8 +98,7 @@
 ----------------------------------------------------------------------------*/
 
 #if defined(_ARM)
-#elif defined(_ARM_GCC)
-
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 /* function is inlined in header file */
 
 
diff --git a/codecs_v2/audio/aac/dec/src/pv_normalize.h b/codecs_v2/audio/aac/dec/src/pv_normalize.h
index f76af9f..dce080e 100644
--- a/codecs_v2/audio/aac/dec/src/pv_normalize.h
+++ b/codecs_v2/audio/aac/dec/src/pv_normalize.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+  Pathname: pv_normalize.h
 
 
- Pathname: ./c/include/pv_normalize.h
-
-     Date: 12/10/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -71,8 +68,7 @@
 }
 
 
-#elif defined(_ARM_GCC)
-
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 
 __inline Int pv_normalize(Int32 x)
 {
diff --git a/codecs_v2/audio/aac/dec/src/pv_pow2.cpp b/codecs_v2/audio/aac/dec/src/pv_pow2.cpp
index 52834e3..8dfca23 100644
--- a/codecs_v2/audio/aac/dec/src/pv_pow2.cpp
+++ b/codecs_v2/audio/aac/dec/src/pv_pow2.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: pv_pow2.c
 
-     Date: 02/26/2004
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pv_pow2.h b/codecs_v2/audio/aac/dec/src/pv_pow2.h
index ab565cb..04bfe93 100644
--- a/codecs_v2/audio/aac/dec/src/pv_pow2.h
+++ b/codecs_v2/audio/aac/dec/src/pv_pow2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/pv_pow2.h
-
-     Date: 03/14/2004
+ Pathname: pv_pow2.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pv_sine.cpp b/codecs_v2/audio/aac/dec/src/pv_sine.cpp
index d40047a..54319b1 100644
--- a/codecs_v2/audio/aac/dec/src/pv_sine.cpp
+++ b/codecs_v2/audio/aac/dec/src/pv_sine.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: pv_sine.c
 
-     Date: 10/05/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pv_sine.h b/codecs_v2/audio/aac/dec/src/pv_sine.h
index d514fd2..145013a 100644
--- a/codecs_v2/audio/aac/dec/src/pv_sine.h
+++ b/codecs_v2/audio/aac/dec/src/pv_sine.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/pv_sine.h
-
-     Date: 10/04/2004
+ Pathname: pv_sine.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp b/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp
index a472a71..065fa38 100644
--- a/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp
+++ b/codecs_v2/audio/aac/dec/src/pv_sqrt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: pv_sqrt.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/pv_sqrt.h b/codecs_v2/audio/aac/dec/src/pv_sqrt.h
index 3326bf2..45d6f52 100644
--- a/codecs_v2/audio/aac/dec/src/pv_sqrt.h
+++ b/codecs_v2/audio/aac/dec/src/pv_sqrt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/pv_sqrt.h
-
-     Date: 02/04/2004
+ Pathname: pv_sqrt.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp
index a6fec72..9208fa8 100644
--- a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp
+++ b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderconfig.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    PVMP4AudioDecoderConfig
-
-     Date: 01/15/2002
+ Pathname: PVMP4AudioDecoderConfig
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -41,6 +30,7 @@
 
  Description: Added support for AAC+
 
+ Who:                                         Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -185,7 +175,7 @@
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
 
-Int PVMP4AudioDecoderConfig(
+OSCL_EXPORT_REF Int PVMP4AudioDecoderConfig(
     tPVMP4AudioDecoderExternal  *pExt,
     void                        *pMem)
 {
@@ -223,9 +213,10 @@
          * Buffer is not overrun, then
          * decode the AudioSpecificConfig() structure
          */
-        status =
-            get_audio_specific_config(
-                pVars);
+
+        pVars->aacConfigUtilityEnabled = false;  /* set aac dec mode */
+
+        status = get_audio_specific_config(pVars);
 
     }
 
diff --git a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp
index 70ef5bb..7a279dc 100644
--- a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp
+++ b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderframe.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /codecs/audio/aac/c/src/pvmp4audiodecodeframe
-
-
-     Date: 10/25/2000
+ Pathname: pvmp4audiodecodeframe
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Pulled in loop structure from console.c, so that this function
                now decodes all frames in the file.
@@ -144,6 +138,7 @@
  Description: Added comments explaining how the ltp_buffer_state
  variable is updated.
 
+
  Description: Modified code to take advantage of new trans4m_freq_2_time_fxp,
  which writes the output directly into a 16-bit output buffer.  This
  improvement allows faster operation by reducing the amount of memory
@@ -507,7 +502,7 @@
 ----------------------------------------------------------------------------*/
 
 
-Int PVMP4AudioDecodeFrame(
+OSCL_EXPORT_REF Int PVMP4AudioDecodeFrame(
     tPVMP4AudioDecoderExternal  *pExt,
     void                        *pMem)
 {
@@ -1248,25 +1243,40 @@
                 }
 
             }
+
+#if defined(AAC_PLUS)
 #if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
-            else if ((pExt->aacPlusEnabled == false) && (pMC_Info->psPresentFlag == 1))
+
+            else if (pMC_Info->psPresentFlag == 1)
             {
-                /*
-                 *  Decoding eaac+ when only aac is enabled, copy L into R
-                 */
+                Int32 frameSize = 0;
+                if (pExt->aacPlusEnabled == false)
+                {
+                    /*
+                     *  Decoding eaac+ when only aac is enabled, copy L into R
+                     */
+                    frameSize = 1024;
+                }
+                else if (sbrDecoderData->SbrChannel[0].syncState != SBR_ACTIVE)
+                {
+                    /*
+                     *  Decoding eaac+ when no PS data was found, copy upsampled L into R
+                     */
+                    frameSize = 2048;
+                }
 
                 Int16 * pt  = &pExt->pOutputBuffer[0];
                 Int16 * pt2 = &pExt->pOutputBuffer[1];
                 Int i;
-                for (i = 0; i < 1024; i++)
+                for (i = 0; i < frameSize; i++)
                 {
                     *pt2 = *pt;
                     pt += 2;
                     pt2 += 2;
                 }
-
             }
 #endif
+#endif
 
         }
         else
@@ -1352,6 +1362,11 @@
             pExt->samplingRate =
                 samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate;
 
+            pVars->mc_info.implicit_channeling = 0; /* disable flag, as this is allowed
+                                                      * only the first time
+                                                      */
+
+
 #ifdef AAC_PLUS
 
             if (pMC_Info->upsamplingFactor == 2)
diff --git a/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp b/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp
index 4232e8c..7cdecd0 100644
--- a/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp
+++ b/codecs_v2/audio/aac/dec/src/pvmp4audiodecodergetmemrequirements.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./src/PVMP4AudioDecoderGetMemRequirements.c
-
-     Date: 10/25/2000
+ Pathname: PVMP4AudioDecoderGetMemRequirements.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -35,6 +33,7 @@
                   channel information is allocated by a DPI call outside this
                   API
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -146,7 +145,7 @@
 /*----------------------------------------------------------------------------
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
-UInt32 PVMP4AudioDecoderGetMemRequirements(void)
+OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void)
 {
     UInt32 size;
 
diff --git a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp
index 12277e9..146ba0f 100644
--- a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp
+++ b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderinitlibrary.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,10 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: PVMP4AudioDecoderInitLibrary.c
 
 
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    PVMP4AudioDecoderInitLibrary.c
-
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -61,6 +51,7 @@
 
  Description: Added PVMP4AudioDecoderDisableAacPlus to disable sbr decoding
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -247,7 +238,7 @@
 /*----------------------------------------------------------------------------
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
-Int PVMP4AudioDecoderInitLibrary(
+OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary(
     tPVMP4AudioDecoderExternal  *pExt,
     void                        *pMem)
 {
@@ -394,7 +385,7 @@
 ----------------------------------------------------------------------------*/
 
 
-void PVMP4AudioDecoderDisableAacPlus(
+OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus(
     tPVMP4AudioDecoderExternal  *pExt,
     void                        *pMem)
 {
diff --git a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp
index 0d117fb..c10423b 100644
--- a/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp
+++ b/codecs_v2/audio/aac/dec/src/pvmp4audiodecoderresetbuffer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    PVMP4AudioDecoderResetBuffer.c
-
-     Date: 01/29/2002
+ Pathname: PVMP4AudioDecoderResetBuffer.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -38,6 +27,7 @@
  Description: perChan[] is an array of structures in tDec_Int_File. Made
               corresponding changes.
 
+ Who:                                         Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -167,7 +157,7 @@
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
 
-void PVMP4AudioDecoderResetBuffer(void  *pMem)
+OSCL_EXPORT_REF void PVMP4AudioDecoderResetBuffer(void  *pMem)
 {
 
     tDec_Int_File *pVars;           /* Helper pointer */
diff --git a/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp b/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp
index 5845243..d183d84 100644
--- a/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp
+++ b/codecs_v2/audio/aac/dec/src/pvmp4setaudioconfig.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/aac/c/src/pvmp4setaudioconfigg
-
-     Date: 06/29/2006
+ Pathname: pvmp4setaudioconfigg
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                         Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/q_normalize.cpp b/codecs_v2/audio/aac/dec/src/q_normalize.cpp
index 17cb57f..5266966 100644
--- a/codecs_v2/audio/aac/dec/src/q_normalize.cpp
+++ b/codecs_v2/audio/aac/dec/src/q_normalize.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./src/q_normalize.c
-
-     Date: 05/10/2001
+ Pathname: q_normalize.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -54,6 +52,7 @@
  Description: Eliminated warning: non use variable "i" and memset function
     definition
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/q_normalize.h b/codecs_v2/audio/aac/dec/src/q_normalize.h
index b6d0f4e..63a9d53 100644
--- a/codecs_v2/audio/aac/dec/src/q_normalize.h
+++ b/codecs_v2/audio/aac/dec/src/q_normalize.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/q_normalize.h
-
-     Date: 05/10/2001
+ Pathname: q_normalize.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -28,6 +26,7 @@
  (1) Added PV Copyright notice.
  (2) Removed embedded TABS
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp b/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp
index fcc8673..ab1973c 100644
--- a/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp
+++ b/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./src/qmf_filterbank_coeff.c
-
-     Date: 07/16/2003
+ Pathname: qmf_filterbank_coeff.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                              Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h b/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h
index 45d8427..c8968cb 100644
--- a/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h
+++ b/codecs_v2/audio/aac/dec/src/qmf_filterbank_coeff.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/qmf_filterbank_coeff.h
-
-     Date: 07/16/2003
+ Pathname: qmf_filterbank_coeff.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/s_adif_header.h b/codecs_v2/audio/aac/dec/src/s_adif_header.h
index 3944ccf..74686ed 100644
--- a/codecs_v2/audio/aac/dec/src/s_adif_header.h
+++ b/codecs_v2/audio/aac/dec/src/s_adif_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/s_ADIF_Header.h
-
-     Date: 05/09/2001
+ Pathname: s_ADIF_Header.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_bit_buffer.h b/codecs_v2/audio/aac/dec/src/s_bit_buffer.h
index bfd8024..ad4f383 100644
--- a/codecs_v2/audio/aac/dec/src/s_bit_buffer.h
+++ b/codecs_v2/audio/aac/dec/src/s_bit_buffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_bit_buffer.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_bits.h b/codecs_v2/audio/aac/dec/src/s_bits.h
index 68ac46a..cae69ad 100644
--- a/codecs_v2/audio/aac/dec/src/s_bits.h
+++ b/codecs_v2/audio/aac/dec/src/s_bits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/s_BITS.h
-
-     Date: 05/09/2001
+ Pathname: s_BITS.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -32,6 +30,7 @@
 
  Description: Change buffer type from UInt32 to UChar.
 
+ Who:                                   Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_ch_info.h b/codecs_v2/audio/aac/dec/src/s_ch_info.h
index c29f279..9fd259c 100644
--- a/codecs_v2/audio/aac/dec/src/s_ch_info.h
+++ b/codecs_v2/audio/aac/dec/src/s_ch_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/s_Ch_Info.h
-
-     Date: 05/09/2001
+ Pathname: s_Ch_Info.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_crc_buffer.h b/codecs_v2/audio/aac/dec/src/s_crc_buffer.h
index 1aaa015..69250e7 100644
--- a/codecs_v2/audio/aac/dec/src/s_crc_buffer.h
+++ b/codecs_v2/audio/aac/dec/src/s_crc_buffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_crc_buffer.h
  Funtions:
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_elelist.h b/codecs_v2/audio/aac/dec/src/s_elelist.h
index 6a64bb0..52d42fd 100644
--- a/codecs_v2/audio/aac/dec/src/s_elelist.h
+++ b/codecs_v2/audio/aac/dec/src/s_elelist.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/s_EleList.h
-
-     Date: 04/25/2001
+ Pathname: s_EleList.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_frameinfo.h b/codecs_v2/audio/aac/dec/src/s_frameinfo.h
index 68a9009..871ae83 100644
--- a/codecs_v2/audio/aac/dec/src/s_frameinfo.h
+++ b/codecs_v2/audio/aac/dec/src/s_frameinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    s_frameinfo.h
-
-     Date: 04/25/2001
+ Pathname: s_frameinfo.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/s_hcb.h b/codecs_v2/audio/aac/dec/src/s_hcb.h
index bd0027a..6a64c27 100644
--- a/codecs_v2/audio/aac/dec/src/s_hcb.h
+++ b/codecs_v2/audio/aac/dec/src/s_hcb.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    s_Hcb.h
+ Pathname: s_Hcb.h
 
      Date: 05/07/2001
 
@@ -54,6 +45,7 @@
  Description: Modified the declaration of the structure so no pointers are
               used in the structure.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_huffman.h b/codecs_v2/audio/aac/dec/src/s_huffman.h
index 1044a2d..2db3dd9 100644
--- a/codecs_v2/audio/aac/dec/src/s_huffman.h
+++ b/codecs_v2/audio/aac/dec/src/s_huffman.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,13 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./include/s_Huffman.h
-
-     Date: 05/09/2001
+ Pathname: s_Huffman.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -35,6 +30,7 @@
 
  Description: Added definition for SBR Huffman, used for AAC plus
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/s_hybrid.h b/codecs_v2/audio/aac/dec/src/s_hybrid.h
index 15ac0d2..3880d30 100644
--- a/codecs_v2/audio/aac/dec/src/s_hybrid.h
+++ b/codecs_v2/audio/aac/dec/src/s_hybrid.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_hybrid.h
  Funtions:
 
-
-     Date: 01/10/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_lt_pred_status.h b/codecs_v2/audio/aac/dec/src/s_lt_pred_status.h
index 6ffb9c9..e603aa9 100644
--- a/codecs_v2/audio/aac/dec/src/s_lt_pred_status.h
+++ b/codecs_v2/audio/aac/dec/src/s_lt_pred_status.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,10 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
+ Pathname: LT_PRED_STATUS.h
 
 
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    LT_PRED_STATUS.h
-
-     Date: 05/09/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -63,6 +53,7 @@
  from a 32-bit to a 16-bit LTP buffer, the data is accessed only
  when it is needed.  This saves both MIPS and memory.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/s_mc_info.h b/codecs_v2/audio/aac/dec/src/s_mc_info.h
index db7c961..9006119 100644
--- a/codecs_v2/audio/aac/dec/src/s_mc_info.h
+++ b/codecs_v2/audio/aac/dec/src/s_mc_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/s_MC_Info.h
-
-     Date: 05/09/2001
+ Pathname: s_MC_Info.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: (1) use enum type for audioObjectType (2) update revision history
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/s_mixdown.h b/codecs_v2/audio/aac/dec/src/s_mixdown.h
index 026a717..3e7b5f7 100644
--- a/codecs_v2/audio/aac/dec/src/s_mixdown.h
+++ b/codecs_v2/audio/aac/dec/src/s_mixdown.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/s_MIXdown.h
-
-     Date: 05/09/2001
+ Pathname: s_MIXdown.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_patch.h b/codecs_v2/audio/aac/dec/src/s_patch.h
index 5090384..1e8c4b9 100644
--- a/codecs_v2/audio/aac/dec/src/s_patch.h
+++ b/codecs_v2/audio/aac/dec/src/s_patch.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,12 +21,11 @@
  Funtions:
 
 
-     Date: 11/07/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/s_progconfig.h b/codecs_v2/audio/aac/dec/src/s_progconfig.h
index 0ed12cb..9b4b226 100644
--- a/codecs_v2/audio/aac/dec/src/s_progconfig.h
+++ b/codecs_v2/audio/aac/dec/src/s_progconfig.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/s_ProgConfig.h
-
-     Date: 05/09/2001
+ Pathname: s_ProgConfig.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_ps_dec.h b/codecs_v2/audio/aac/dec/src/s_ps_dec.h
index 1d13bed..8b4391c 100644
--- a/codecs_v2/audio/aac/dec/src/s_ps_dec.h
+++ b/codecs_v2/audio/aac/dec/src/s_ps_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/aac/dec/src/s_pulseinfo.h b/codecs_v2/audio/aac/dec/src/s_pulseinfo.h
index 0fd6c75..a7ced04 100644
--- a/codecs_v2/audio/aac/dec/src/s_pulseinfo.h
+++ b/codecs_v2/audio/aac/dec/src/s_pulseinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/s_PulseInfo.h
-
-     Date: 04/25/2001
+ Pathname: s_PulseInfo.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -28,6 +26,7 @@
 
  Description:  Fix ARM warnings, update copyright.
 
+ Who:                                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_sbr_channel.h b/codecs_v2/audio/aac/dec/src/s_sbr_channel.h
index 6c65021..99e28dd 100644
--- a/codecs_v2/audio/aac/dec/src/s_sbr_channel.h
+++ b/codecs_v2/audio/aac/dec/src/s_sbr_channel.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_sbr_channel.h
  Funtions:
 
-
-     Date: 10/31/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_sbr_dec.h b/codecs_v2/audio/aac/dec/src/s_sbr_dec.h
index 2a6e161..0092c4d 100644
--- a/codecs_v2/audio/aac/dec/src/s_sbr_dec.h
+++ b/codecs_v2/audio/aac/dec/src/s_sbr_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 12/7/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/s_sbr_element_stream.h b/codecs_v2/audio/aac/dec/src/s_sbr_element_stream.h
index becc062..e9b6780 100644
--- a/codecs_v2/audio/aac/dec/src/s_sbr_element_stream.h
+++ b/codecs_v2/audio/aac/dec/src/s_sbr_element_stream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_sbr_element_stream.h
  Funtions:
 
-
-     Date: 10/31/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_sbr_frame_data.h b/codecs_v2/audio/aac/dec/src/s_sbr_frame_data.h
index 68dd72b..fc4b94d 100644
--- a/codecs_v2/audio/aac/dec/src/s_sbr_frame_data.h
+++ b/codecs_v2/audio/aac/dec/src/s_sbr_frame_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_sbr_frame_data.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h b/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h
index 7fadfe7..7d7d746 100644
--- a/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h
+++ b/codecs_v2/audio/aac/dec/src/s_sbr_header_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_sbr_header_data.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h b/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h
index b623e5c..609463a 100644
--- a/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h
+++ b/codecs_v2/audio/aac/dec/src/s_sbrbitstream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: s_sbrbitstream.h
  Funtions:
 
-
-     Date: 10/31/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/s_sectinfo.h b/codecs_v2/audio/aac/dec/src/s_sectinfo.h
index d9bcf13..83dcc31 100644
--- a/codecs_v2/audio/aac/dec/src/s_sectinfo.h
+++ b/codecs_v2/audio/aac/dec/src/s_sectinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,11 @@
 
  Pathname: ./include/s_SectInfo.h
 
-     Date: 04/25/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_sr_info.h b/codecs_v2/audio/aac/dec/src/s_sr_info.h
index b36664f..9b71003 100644
--- a/codecs_v2/audio/aac/dec/src/s_sr_info.h
+++ b/codecs_v2/audio/aac/dec/src/s_sr_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/s_SR_info.h
-
-     Date: 05/09/2001
+ Pathname: s_SR_info.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -27,6 +25,7 @@
  Description: Modified the declaration of the structure so no pointers are
               used in the structure.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h b/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h
index 9eb1c82..f7a3602 100644
--- a/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h
+++ b/codecs_v2/audio/aac/dec/src/s_tdec_int_chan.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    s_tDec_Int_Chan.h
-
-     Date: 05/09/2001
+ Pathname: s_tDec_Int_Chan.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -62,6 +51,7 @@
  Description:
  (1) Changed time_quant from 2048 Int32 buffer to 1024 Int32 buffer.
 
+ Who:                                         Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h b/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h
index 3837ed7..b850169 100644
--- a/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h
+++ b/codecs_v2/audio/aac/dec/src/s_tdec_int_file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    s_tDec_Int_File.h
-
-     Date: 05/09/2001
+ Pathname: s_tDec_Int_File.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -74,6 +63,7 @@
            (2) Updated the copyright header.
 
 
+ Who:                                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -157,6 +147,7 @@
         Int            status;  /* save the status */
 
         bool           aacPlusEnabled;
+        bool           aacConfigUtilityEnabled;
 
         Int            current_program;
         Int            frameLength;
diff --git a/codecs_v2/audio/aac/dec/src/s_tns_frame_info.h b/codecs_v2/audio/aac/dec/src/s_tns_frame_info.h
index f25ec72..61af0ac 100644
--- a/codecs_v2/audio/aac/dec/src/s_tns_frame_info.h
+++ b/codecs_v2/audio/aac/dec/src/s_tns_frame_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    s_TNS_frame_info.h
-
-     Date: 05/09/2001
+ Pathname: s_TNS_frame_info.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -59,6 +48,7 @@
  (1) Removed the array "coef_res", which is now a local variable on the
  stack inside get_tns.c
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/s_tnsfilt.h b/codecs_v2/audio/aac/dec/src/s_tnsfilt.h
index fb3fe22..b649d0a 100644
--- a/codecs_v2/audio/aac/dec/src/s_tnsfilt.h
+++ b/codecs_v2/audio/aac/dec/src/s_tnsfilt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    s_TNSfilt.h
-
-     Date: 05/09/2001
+ Pathname: s_TNSfilt.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -65,6 +54,7 @@
 
  (2) Updated the copyright header.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/s_wnd_shape.h b/codecs_v2/audio/aac/dec/src/s_wnd_shape.h
index f63ba87..c8a05c8 100644
--- a/codecs_v2/audio/aac/dec/src/s_wnd_shape.h
+++ b/codecs_v2/audio/aac/dec/src/s_wnd_shape.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,15 +17,14 @@
  */
 /*
 
- Pathname: ./include/s_Wnd_Shape.h
-
-     Date: 04/25/2001
+ Pathname: s_Wnd_Shape.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description:  Change data type to Int
 
+ Who:                                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.cpp b/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.cpp
index 55c1c34..efbab7d 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_aliasing_reduction.c
 
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h b/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h
index a9a7670..2ce99ec 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_aliasing_reduction.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_aliasing_reduction.h
  Funtions:
 
-
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_applied.cpp b/codecs_v2/audio/aac/dec/src/sbr_applied.cpp
index e20c905..c8b81b2 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_applied.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_applied.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Filename: sbr_applied.c
-
-     Date: 11/05/2003
+  Filename: sbr_applied.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_applied.h b/codecs_v2/audio/aac/dec/src/sbr_applied.h
index e5b58fa..4afc183 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_applied.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_applied.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp b/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp
index bd5cc17..9db3221 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_code_book_envlevel.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h b/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h
index 0d05cd1..3df0531 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_code_book_envlevel.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/sbr_code_book_envlevel.h
-
-     Date: 07/23/2003
+ Pathname: sbr_code_book_envlevel.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/sbr_constants.h b/codecs_v2/audio/aac/dec/src/sbr_constants.h
index 6d3a101..d54a699 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_constants.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_constants.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,12 +21,11 @@
  Funtions:
 
 
-     Date: 11/06/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp b/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp
index 2286bef..3bb4398 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_crc_check.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_crc_check.c
 
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_crc_check.h b/codecs_v2/audio/aac/dec/src/sbr_crc_check.h
index 56f9ba1..9e6b1be 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_crc_check.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_crc_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_crc_check.h
  Funtions:
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp b/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp
index 5b5d7d3..f23d6d5 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_create_limiter_bands.c
 
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h b/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h
index e5b5185..e93377b 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_create_limiter_bands.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_create_limiter_bands.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_dec.cpp b/codecs_v2/audio/aac/dec/src/sbr_dec.cpp
index 00e98de..19b34fd 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_dec.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_dec.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -408,8 +404,14 @@
 #ifdef PARAMETRICSTEREO
 
 
-    if (pVars->mc_info.psPresentFlag)
+    /*
+     * psPresentFlag set implies hParametricStereoDec !=NULL, second condition is
+     * is just here to prevent CodeSonar warnings.
+     */
+    if ((pVars->mc_info.psPresentFlag) && (applyProcessing) &&
+            (hParametricStereoDec != NULL))
     {
+
         /*
          *  qmfBufferReal uses the rigth aac channel ( perChan[1] is not used)
          *  followed by the buffer fxpCoef[2][2048]  which makes a total of
@@ -419,33 +421,33 @@
          */
 
 
-        hParametricStereoDec->qmfBufferReal = (Int32(*)[64]) & pVars->perChan[1];
-        hParametricStereoDec->qmfBufferImag = (Int32(*)[64]) & hParametricStereoDec->qmfBufferReal[38][0];
+        tDec_Int_Chan *tmpx = &pVars->perChan[1];
+        /*
+         *  dereferencing type-punned pointer avoid
+         *  breaking strict-aliasing rules
+         */
+        Int32 *tmp = (Int32 *)tmpx;
+        hParametricStereoDec->qmfBufferReal = (Int32(*)[64]) tmp;
 
+        tmp = (Int32 *) & hParametricStereoDec->qmfBufferReal[38][0];
+        hParametricStereoDec->qmfBufferImag = (Int32(*)[64]) tmp;
 
         for (i = 0; i < 32; i++)
         {
             Int   xoverBand;
 
-            if (applyProcessing)
+            if (i < ((hFrameData->frameInfo[1]) << 1))
             {
-                if (i < ((hFrameData->frameInfo[1]) << 1))
-                {
-                    xoverBand = sbrDec->prevLowSubband;
-                }
-                else
-                {
-                    xoverBand = sbrDec->lowSubband;
-                }
-
-                if (xoverBand > sbrDec->highSubband)
-                {
-                    xoverBand = 32; /* error condition, default to upsampling mode */
-                }
+                xoverBand = sbrDec->prevLowSubband;
             }
             else
             {
-                xoverBand = 32;
+                xoverBand = sbrDec->lowSubband;
+            }
+
+            if (xoverBand > sbrDec->highSubband)
+            {
+                xoverBand = 32; /* error condition, default to upsampling mode */
             }
 
             m = sbrDec->bufReadOffs + i;    /*  2 + i */
@@ -776,7 +778,7 @@
                 ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS];
 
 
-                for (k = (sbrDec->highSubband - xoverBand); k > 0; k--)
+                for (k = xoverBand; k < sbrDec->highSubband; k++)
                 {
                     *(ptr_tmp2++) = (*(ptr_tmp1++)) << 1;
                 }
@@ -814,13 +816,11 @@
                 ptr_tmp2 = &Sr[xoverBand];
 
 
-
-                for (k = (sbrDec->highSubband - xoverBand); k != 0; k--)
+                for (k = xoverBand; k < sbrDec->highSubband; k++)
                 {
                     *(ptr_tmp2++) = (*(ptr_tmp1++));
                 }
 
-
                 pv_memset((void *)ptr_tmp2,
                           0,
                           (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
@@ -842,7 +842,7 @@
                 ptr_tmp1 = &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS];
                 ptr_tmp2 = &Si[xoverBand];
 
-                for (k = (sbrDec->highSubband - xoverBand); k > 0; k--)
+                for (k = xoverBand; k < sbrDec->highSubband; k++)
                 {
                     *(ptr_tmp2++) = (*(ptr_tmp1++));
                 }
diff --git a/codecs_v2/audio/aac/dec/src/sbr_dec.h b/codecs_v2/audio/aac/dec/src/sbr_dec.h
index c8f4a3d..ae897f4 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_dec.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp b/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp
index 20d2c3f..771bb32 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_decode_envelope.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -146,13 +142,13 @@
     Int32 no_of_bands;
     Int32 band;
     Int32 freqRes;
-    Int32 *iEnvelope    = (Int32 *) & (hFrameData->iEnvelope_man);
-    Int32 *sfb_nrg_prev = (Int32 *) & (hFrameData->sfb_nrg_prev_man);
+    Int32 *iEnvelope    = hFrameData->iEnvelope_man;
+    Int32 *sfb_nrg_prev = hFrameData->sfb_nrg_prev_man;
 
-    Int32  offset       =   hFrameData->offset;
-    Int32 *nSfb         = (Int32 *) & (hFrameData->nSfb);
-    Int32 *domain_vec   = (Int32 *) & (hFrameData->domain_vec1);
-    Int32 *frameInfo    = (Int32 *) & (hFrameData->frameInfo);
+    Int32  offset       = hFrameData->offset;
+    Int32 *nSfb         = hFrameData->nSfb;
+    Int32 *domain_vec   = hFrameData->domain_vec1;
+    Int32 *frameInfo    = hFrameData->frameInfo;
 
 
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h b/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h
index 700491b..19c04a9 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_decode_envelope.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,12 +21,11 @@
  Funtions:
     decodeEnvelope
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp b/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp
index d7c3a51..290fd18 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_decode_huff_cw.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h b/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h
index 1ea3f66..9fe5e24 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_decode_huff_cw.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_decode_huff_cw.h
 
-
-
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp b/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp
index e47b2dd..665ffea 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_downsample_lo_res.c
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h b/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h
index d72385d..179c6af 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_downsample_lo_res.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp b/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp
index 2336532..2ed76dd 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_envelope_calc_tbl.c
 
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h b/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h
index 4a273a7..60e806d 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_envelope_calc_tbl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_envelope_calc_tbl.h
 
-
-
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp b/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp
index c8b2638..7fce46b 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_envelope_unmapping.c
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -160,25 +156,19 @@
 
 {
     Int32 i;
-
-
-
     Int32 tempLeft;
     Int32 tempRight;
 
-
     Int32 tmp;
-    Int32 *iEnvelopeLeft_man  = (Int32 *) & (hFrameData1->iEnvelope_man);
-    Int32 *iEnvelopeLeft_exp  = (Int32 *) & (hFrameData1->iEnvelope_exp);
+    Int32 *iEnvelopeLeft_man    = hFrameData1->iEnvelope_man;
+    Int32 *iEnvelopeLeft_exp    = hFrameData1->iEnvelope_exp;
+    Int32 *noiseFloorLeft_man   = hFrameData1->sbrNoiseFloorLevel_man;
+    Int32 *noiseFloorLeft_exp   = hFrameData1->sbrNoiseFloorLevel_exp;
 
-    Int32 *iEnvelopeRight_man = (Int32 *) & (hFrameData2->iEnvelope_man);
-    Int32 *iEnvelopeRight_exp = (Int32 *) & (hFrameData2->iEnvelope_exp);
-
-
-    Int32 *noiseFloorLeft_man   = (Int32 *) & (hFrameData1->sbrNoiseFloorLevel_man);
-    Int32 *noiseFloorLeft_exp   = (Int32 *) & (hFrameData1->sbrNoiseFloorLevel_exp);
-    Int32 *noiseFloorRight_man  = (Int32 *) & (hFrameData2->sbrNoiseFloorLevel_man);
-    Int32 *noiseFloorRight_exp  = (Int32 *) & (hFrameData2->sbrNoiseFloorLevel_exp);
+    Int32 *iEnvelopeRight_man   = hFrameData2->iEnvelope_man;
+    Int32 *iEnvelopeRight_exp   = hFrameData2->iEnvelope_exp;
+    Int32 *noiseFloorRight_man  = hFrameData2->sbrNoiseFloorLevel_man;
+    Int32 *noiseFloorRight_exp  = hFrameData2->sbrNoiseFloorLevel_exp;
 
 
     if (hFrameData2->ampRes)
@@ -194,7 +184,6 @@
             iEnvelopeRight_exp[i] = tempRight - 12;
             iEnvelopeRight_man[i] = Qfmt(1.000F);
 
-
             /*
              *  iEnvelopeRight[i] = tempLeft / (1 + tempRight);
              *  iEnvelopeLeft[i]  = tempRight * iEnvelopeRight[i];
@@ -214,7 +203,6 @@
                     iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
                 }
                 iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
             }
             else
             {
diff --git a/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h b/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h
index 0d331ff..b949830 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_envelope_unmapping.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_envelope_unmapping.h
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp
index 583a0af..92b22f7 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_extract_extended_data.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h b/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h
index 7c3e5e8..bbca3b9 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_extract_extended_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_extract_extended_data.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp b/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp
index 9b9292e..fc3d38f 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_find_start_andstop_band.c
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h b/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h
index 201882c..88283c6 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_find_start_andstop_band.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
  Filename: sbr_find_start_andstop_band.h
  Funtions:
     get_dse
 
-
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp b/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp
index d0ffe87..fafa974 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_generate_high_freq.c
 
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h b/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h
index dba15d9..0e9c928 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_generate_high_freq.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,13 +20,11 @@
  Filename: sbr_generate_high_freq.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp
index 46c05c6..60072dd 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_additional_data.c
 
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h b/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h
index 1595642..51285c5 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_additional_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,16 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_additional_data.h
  Funtions:
 
 
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp
index cc91912..657d032 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_cpe.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_cpe.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h b/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h
index daffd0b..b6f99f8 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_cpe.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_cpe.h
 
 
-
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp
index c9610e5..3d7ad8c 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_dir_control_data.c
 
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h b/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h
index 7edbc5b..3b587dc 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_dir_control_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,16 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_dir_control_data.h
  Funtions:
 
 
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp
index 02e8edd..e92abb1 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_envelope.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_envelope.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -203,13 +199,13 @@
         envDataTableCompFactor = 1;
         if (ampRes == SBR_AMP_RES_1_5)
         {
-            hcb_t = (SbrHuffman) & bookSbrEnvBalance10T;
-            hcb_f = (SbrHuffman) & bookSbrEnvBalance10F;
+            hcb_t = bookSbrEnvBalance10T;
+            hcb_f = bookSbrEnvBalance10F;
         }
         else
         {
-            hcb_t = (SbrHuffman) & bookSbrEnvBalance11T;
-            hcb_f = (SbrHuffman) & bookSbrEnvBalance11F;
+            hcb_t = bookSbrEnvBalance11T;
+            hcb_f = bookSbrEnvBalance11F;
         }
     }
     else
@@ -217,13 +213,13 @@
         envDataTableCompFactor = 0;
         if (ampRes == SBR_AMP_RES_1_5)
         {
-            hcb_t = (SbrHuffman) & bookSbrEnvLevel10T;
-            hcb_f = (SbrHuffman) & bookSbrEnvLevel10F;
+            hcb_t = bookSbrEnvLevel10T;
+            hcb_f = bookSbrEnvLevel10F;
         }
         else
         {
-            hcb_t = (SbrHuffman) & bookSbrEnvLevel11T;
-            hcb_f = (SbrHuffman) & bookSbrEnvLevel11F;
+            hcb_t = bookSbrEnvLevel11T;
+            hcb_f = bookSbrEnvLevel11F;
         }
     }
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h b/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h
index 920a8ab..96c008a 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_envelope.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_envelope.h
 
-
-
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp
index d0eea9f..44650d3 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_header_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_header_data.c
 
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h b/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h
index 44dadfd..7bfb272 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_header_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_header_data.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp
index c1f1527..8d86158 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_noise_floor_data.c
 
-     Date: 07/23/2003
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -156,14 +153,14 @@
 
     if (coupling == COUPLING_BAL)
     {
-        hcb_noise  = (SbrHuffman) & bookSbrNoiseBalance11T;
-        hcb_noiseF = (SbrHuffman) & bookSbrEnvBalance11F;  /* "bookSbrNoiseBalance11F" */
+        hcb_noise  = bookSbrNoiseBalance11T;
+        hcb_noiseF = bookSbrEnvBalance11F;  /* "bookSbrNoiseBalance11F" */
         envDataTableCompFactor = 1;
     }
     else
     {
-        hcb_noise  = (SbrHuffman) & bookSbrNoiseLevel11T;
-        hcb_noiseF = (SbrHuffman) & bookSbrEnvLevel11F;  /* "bookSbrNoiseLevel11F" */
+        hcb_noise  = bookSbrNoiseLevel11T;
+        hcb_noiseF = bookSbrEnvLevel11F;  /* "bookSbrNoiseLevel11F" */
         envDataTableCompFactor = 0;
     }
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h b/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h
index 816ebab..8fc759e 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_noise_floor_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_noise_floor_data.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp b/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp
index c299362..ba514f4 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_sce.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_sce.c
 
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_get_sce.h b/codecs_v2/audio/aac/dec/src/sbr_get_sce.h
index 7d2a329..b7c1ed0 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_get_sce.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_get_sce.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_get_sce.h
 
-
-
-     Date: 07/23/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp b/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp
index a15a24e..833ace3 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_inv_filt_levelemphasis.c
 
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h b/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h
index 8dcd76a..586214c 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_inv_filt_levelemphasis.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,20 +16,15 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_inv_filt_levelemphasis.h
  Funtions:
 
-
-     Date: 07/22/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_open.cpp b/codecs_v2/audio/aac/dec/src/sbr_open.cpp
index fc956f0..868819a 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_open.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_open.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_open.c
 
-     Date: 07/24/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_open.h b/codecs_v2/audio/aac/dec/src/sbr_open.h
index 8c5bcfb..8d17ffa 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_open.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_open.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,12 +22,11 @@
     get_dse
 
 
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp
index cf9a78b..ccc6bf9 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_read_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_read_data.c
 
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_read_data.h b/codecs_v2/audio/aac/dec/src/sbr_read_data.h
index d8c264f..895276b 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_read_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_read_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 11/05/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp b/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp
index 5385e2c..487496f 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_requantize_envelope_data.c
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
@@ -138,10 +134,10 @@
     Int32  nScaleFactors      =  hFrameData->nScaleFactors;
     Int32  nNoiseFactors      =  hFrameData->nNoiseFactors;
     Int32  ampRes             =  hFrameData->ampRes;
-    Int32 *iEnvelope_man      = (Int32 *) & (hFrameData->iEnvelope_man);
-    Int32 *iEnvelope_exp      = (Int32 *) & (hFrameData->iEnvelope_exp);
-    Int32 *sbrNoiseFloorLevel_man = (Int32 *) & (hFrameData->sbrNoiseFloorLevel_man);
-    Int32 *sbrNoiseFloorLevel_exp = (Int32 *) & (hFrameData->sbrNoiseFloorLevel_exp);
+    Int32 *iEnvelope_man      =  hFrameData->iEnvelope_man;
+    Int32 *iEnvelope_exp      =  hFrameData->iEnvelope_exp;
+    Int32 *sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
+    Int32 *sbrNoiseFloorLevel_exp = hFrameData->sbrNoiseFloorLevel_exp;
 
     /*
      *  ampRes could be 0 (resolution step = 1.5 dB) or
diff --git a/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h b/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h
index fc900ae..2113586 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_requantize_envelope_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_requantize_envelope_data.h
 
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp b/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp
index 58c696e..810a34a 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_reset_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_reset_dec.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h b/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h
index b0aa2c1..0ff94a5 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_reset_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 SC 29 Software Copyright Licencing Disclaimer:
diff --git a/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp b/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp
index 71f5eca..a6e9d23 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp
+++ b/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: sbr_update_freq_scale.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h b/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h
index 9d7755e..4acf3aa 100644
--- a/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h
+++ b/codecs_v2/audio/aac/dec/src/sbr_update_freq_scale.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/21/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/set_mc_info.cpp b/codecs_v2/audio/aac/dec/src/set_mc_info.cpp
index f4b2c07..5a11941 100644
--- a/codecs_v2/audio/aac/dec/src/set_mc_info.cpp
+++ b/codecs_v2/audio/aac/dec/src/set_mc_info.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 
  Pathname: ./src/set_mc_info.c
 
-     Date: 07/05/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -28,6 +26,7 @@
 
  Description: Change audioObjectType from Int to enum types
 
+ Who:                               Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -273,10 +272,14 @@
     {
         pMC_Info->sampling_rate_idx = sampling_rate_idx;
 
-        infoinit(
-            sampling_rate_idx,
-            pWinSeqInfo,
-            sfbwidth128);
+        Int status;
+        status = infoinit(sampling_rate_idx,
+                          pWinSeqInfo,
+                          sfbwidth128);
+        if (SUCCESS != status)
+        {
+            return 1;
+        }
     }
 
     /*
diff --git a/codecs_v2/audio/aac/dec/src/set_mc_info.h b/codecs_v2/audio/aac/dec/src/set_mc_info.h
index 181cb40..8043b3b 100644
--- a/codecs_v2/audio/aac/dec/src/set_mc_info.h
+++ b/codecs_v2/audio/aac/dec/src/set_mc_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,13 +19,13 @@
 
  Pathname: ./include/set_mc_info.h
 
-     Date: 07/05/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: (1) use enum type for audioObjectType (2) update revision history
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sfb.cpp b/codecs_v2/audio/aac/dec/src/sfb.cpp
index 8316695..f2d3a3e 100644
--- a/codecs_v2/audio/aac/dec/src/sfb.cpp
+++ b/codecs_v2/audio/aac/dec/src/sfb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
 
  Pathname: ./src/sfb.c
 
-     Date: 04/06/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -36,6 +35,7 @@
               - Eliminated references to contant vector addresses in
                 samp_rate_info
 
+ Who:                              Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/sfb.h b/codecs_v2/audio/aac/dec/src/sfb.h
index 99ce807..0cc1707 100644
--- a/codecs_v2/audio/aac/dec/src/sfb.h
+++ b/codecs_v2/audio/aac/dec/src/sfb.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/sfb.h
-
-     Date: 04/06/2001
+ Pathname: sfb.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/shellsort.cpp b/codecs_v2/audio/aac/dec/src/shellsort.cpp
index fb40416..5feb803 100644
--- a/codecs_v2/audio/aac/dec/src/shellsort.cpp
+++ b/codecs_v2/audio/aac/dec/src/shellsort.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: shellsort.c
 
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/shellsort.h b/codecs_v2/audio/aac/dec/src/shellsort.h
index 81072f6..a4658e3 100644
--- a/codecs_v2/audio/aac/dec/src/shellsort.h
+++ b/codecs_v2/audio/aac/dec/src/shellsort.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,13 +21,11 @@
  Funtions:
     get_dse
 
-
-     Date: 07/17/2003
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 ------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/aac/dec/src/stereo_2_mono.h b/codecs_v2/audio/aac/dec/src/stereo_2_mono.h
index 0975e9c..3e27c70 100644
--- a/codecs_v2/audio/aac/dec/src/stereo_2_mono.h
+++ b/codecs_v2/audio/aac/dec/src/stereo_2_mono.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,12 @@
  */
 /*
 
- Pathname: ./include/stereo_2_mono.h
-
-     Date: 07/20/2001
+ Pathname: stereo_2_mono.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp b/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp
index c168f18..c1418e3 100644
--- a/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp
+++ b/codecs_v2/audio/aac/dec/src/synthesis_sub_band.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,14 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: synthesis_sub_band.c
 
-     Date: 02/04/2004
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                   Date: MM/DD/YYYY
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h b/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h
index 84254cc..042c488 100644
--- a/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h
+++ b/codecs_v2/audio/aac/dec/src/synthesis_sub_band.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: ./c/include/synthesis_sub_band.h
-
-     Date: 02/04/2004
+ Pathname: synthesis_sub_band.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp b/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp
index c1357be..db31a63 100644
--- a/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp
+++ b/codecs_v2/audio/aac/dec/src/tns_ar_filter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    tns_ar_filter.c
-
-     Date: 10/25/2000
+ Pathname: tns_ar_filter.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Implemented 24-bit fixed point version
                Optimized C code
diff --git a/codecs_v2/audio/aac/dec/src/tns_ar_filter.h b/codecs_v2/audio/aac/dec/src/tns_ar_filter.h
index 721a690..2538b4d 100644
--- a/codecs_v2/audio/aac/dec/src/tns_ar_filter.h
+++ b/codecs_v2/audio/aac/dec/src/tns_ar_filter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/tns_ar_filter.h
-
-     Date: 05/18/2001
+ Pathname: tns_ar_filter.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -30,6 +28,7 @@
  Description: Removed the parameter "scratch_Int32_buffer" as this space
  in memory is no longer needed by this function.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp b/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp
index 4d2a03d..5e70521 100644
--- a/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp
+++ b/codecs_v2/audio/aac/dec/src/tns_decode_coef.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,24 +16,13 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                src/
-                                    tns_decode_coef.c
-
-     Date: 10/25/2000
+ Pathname: tns_decode_coef.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Implemented in 16-bit Fixed Point
 
@@ -72,6 +61,7 @@
 
  Description:  modified precision of coefficients
 
+ Who:                                   Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
diff --git a/codecs_v2/audio/aac/dec/src/tns_decode_coef.h b/codecs_v2/audio/aac/dec/src/tns_decode_coef.h
index 1ed21ab..a6bac6c 100644
--- a/codecs_v2/audio/aac/dec/src/tns_decode_coef.h
+++ b/codecs_v2/audio/aac/dec/src/tns_decode_coef.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,19 +16,8 @@
  * -------------------------------------------------------------------
  */
 /*
-------------------------------------------------------------------------------
 
-
-
- Pathname: /audio/
-                aac_mpeg4/
-                    AAC_baseline/
-                        pv_aac_dec/
-                            c/
-                                include/
-                                    tns_decode_coef.h
-
-     Date: 05/18/2001
+ Pathname: tns_decode_coef.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -57,6 +46,7 @@
 
  (2) Updated the copyright header.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp b/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp
index 72244cd..631f887 100644
--- a/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp
+++ b/codecs_v2/audio/aac/dec/src/tns_inv_filter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./src/tns_inv_filter.c
-
-     Date: 07/27/2001
+ Pathname: tns_inv_filter.c
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -38,6 +36,7 @@
  Description:
     Simplified MAC operations for filter by eliminating extra variables
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/tns_inv_filter.h b/codecs_v2/audio/aac/dec/src/tns_inv_filter.h
index 762741e..1b57fc1 100644
--- a/codecs_v2/audio/aac/dec/src/tns_inv_filter.h
+++ b/codecs_v2/audio/aac/dec/src/tns_inv_filter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/tns_inv_filter.h
-
-     Date: 07/20/2001
+ Pathname: tns_inv_filter.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -30,6 +28,7 @@
  Description: The scratch memory was mistakenly declared here as type "Int32"
  It should have been "Int"
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp b/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp
index b15096f..6ccc023 100644
--- a/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/trans4m_freq_2_time_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,10 +17,9 @@
  */
 /*
 
-  Pathname: ./src/trans4m_freq_2_time_fxp.c
+  Pathname: trans4m_freq_2_time_fxp.c
   Function: trans4m_freq_2_time_fxp
 
-      Date: 4/02/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -131,6 +130,7 @@
  Description:
     Replaced for-loop with memset and memcopy.
 
+ Who:                         Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -458,7 +458,7 @@
 #define  ROUNDING_SCALED     (ROUNDING<<(16 - SCALING))
 
 
-#if defined(_ARM)
+#if defined(PV_ARM_V5)
 
 
 __inline Int16 sat(Int32 y)
@@ -479,7 +479,7 @@
 
 
 
-#elif defined(_ARM_GCC)
+#elif defined(PV_ARM_GCC_V5)
 
 
 __inline Int16 sat(Int32 y)
@@ -503,6 +503,13 @@
 #define  limiter( y, x)   y = sat(x);
 
 
+#elif defined(PV_ARM_MSC_EVC_V5)
+
+
+#define  limiter( y, x)       z = x<< (15-SCALING); \
+                              y = _DAddSatInt( ROUNDING_SCALED, z)>>16;
+
+
 #else
 
 #define  limiter( y, x)   z = ((x + ROUNDING )>>SCALING); \
@@ -571,7 +578,7 @@
 
     Int  i;
     Int  wnd;
-#if !(defined( _ARM_GCC)||(_ARM))
+#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5))
     Int32 z;
 #endif
 
@@ -1575,7 +1582,7 @@
 
     Int  i;
     Int  wnd;
-#if !(defined( _ARM_GCC)||(_ARM))
+#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5))
     Int32 z;
 #endif
     Int16 *pFreqInfo;
diff --git a/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp b/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp
index 7d8b5a9..b1b44f0 100644
--- a/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/trans4m_time_2_freq_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
  */
 /*
 
-  Pathname: ./src/trans4m_time_2_freq_fxp.c
+  Pathname: trans4m_time_2_freq_fxp.c
   Function: trans4m_time_2_freq_fxp
 
-      Date: 5/29/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -60,6 +58,7 @@
               compilers.
 
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/unpack_idx.cpp b/codecs_v2/audio/aac/dec/src/unpack_idx.cpp
index b702264..c3c7fb0 100644
--- a/codecs_v2/audio/aac/dec/src/unpack_idx.cpp
+++ b/codecs_v2/audio/aac/dec/src/unpack_idx.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,17 +16,16 @@
  * -------------------------------------------------------------------
  */
 /*
+
  Pathname: ./src/unpack_idx.c
  Function:	unpack_idx
 			unpack_idx_sgn
 			unpack_idx_esc
 
-     Date: 10/25/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
- Description:  Modified from original code
+ Description:  Modified from original shareware code
 
  Description:  Eliminated 3 divisions and 1 multiplication through a table
  look-up method for calculating 1/mod and constant allocation of 1/mod^3
@@ -59,6 +58,7 @@
               updated (defaulted to 0), leading to block processing in other
               magnitude sensitive stages.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
@@ -247,7 +247,7 @@
 #define LOWER_5_BITS_MASK 0x1F
 
 
-#if ( defined(_ARM) || defined(_ARM_V4))
+#if ( defined(PV_ARM_V5) || defined(PV_ARM_V4))
 
 __inline Int32 abs1(Int32 x)
 {
diff --git a/codecs_v2/audio/aac/dec/src/unpack_idx.h b/codecs_v2/audio/aac/dec/src/unpack_idx.h
index 9515f92..17f12be 100644
--- a/codecs_v2/audio/aac/dec/src/unpack_idx.h
+++ b/codecs_v2/audio/aac/dec/src/unpack_idx.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,11 +19,11 @@
 
  Pathname: ./include/unpack_idx.h
 
-     Date: 04/18/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/window_block_fxp.h b/codecs_v2/audio/aac/dec/src/window_block_fxp.h
index 5c05322..f936199 100644
--- a/codecs_v2/audio/aac/dec/src/window_block_fxp.h
+++ b/codecs_v2/audio/aac/dec/src/window_block_fxp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,8 @@
  */
 /*
 
- Pathname: ./include/window_block_fxp.h
+ Pathname: window_block_fxp.h
 
-     Date: 04/02/2001
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
diff --git a/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp b/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp
index d6036d1..aa04225 100644
--- a/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp
+++ b/codecs_v2/audio/aac/dec/src/window_tables_fxp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,9 @@
  */
 /*
 
- Pathname: ./src/window_tables_fxp.c
+ Pathname: window_tables_fxp.c
  Funtions:
 
-     Date: 4/02/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +41,7 @@
               - Eliminated Long_Window_fxp and Short_Window_fxp as global
                 contants vectors
 
+ Who:                       Date:
  Description:
 
   ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/src/write_output.h b/codecs_v2/audio/aac/dec/src/write_output.h
index 761702c..0085a63 100644
--- a/codecs_v2/audio/aac/dec/src/write_output.h
+++ b/codecs_v2/audio/aac/dec/src/write_output.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,7 @@
  */
 /*
 
- Pathname: ./include/write_output.h
-
-     Date: 07/10/2001
+ Pathname: write_output.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -28,6 +26,7 @@
 
  Description: Remove CR/LF from unknown editor
 
+ Who:                                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk b/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk
index eb3f2c8..2f932b1 100644
--- a/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk
@@ -2,27 +2,42 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/getactualaacconfig.cpp
-
+	src/getactualaacconfig.cpp \
+ 	src/byte_align.cpp \
+ 	src/get_audio_specific_config.cpp \
+ 	src/get_ele_list.cpp \
+ 	src/get_ga_specific_config.cpp \
+ 	src/get_ics_info.cpp \
+ 	src/get_prog_config.cpp \
+ 	src/getgroup.cpp \
+ 	src/lt_decode.cpp \
+ 	src/infoinit.cpp \
+ 	src/pvmp4audiodecodergetmemrequirements.cpp \
+ 	src/pvmp4audiodecoderinitlibrary.cpp \
+ 	src/set_mc_info.cpp \
+ 	src/sfb.cpp
 
 
 LOCAL_MODULE := libgetactualaacconfig
 
-LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DC_EQUIVALENT -DAAC_UTILITIES  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/util/getactualaacconfig/include \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/util/getactualaacconfig/src \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/util/getactualaacconfig/../../include \
-	$(PV_TOP)//codecs_v2/audio/aac/dec/util/getactualaacconfig/../../src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/src \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/include \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/include \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/getactualaacconfig.h
+ 	include/getactualaacconfig.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/local.mk b/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/local.mk
new file mode 100644
index 0000000..0061ef6
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/local.mk
@@ -0,0 +1,39 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := getactualaacconfig
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO 
+
+XINCDIRS := ../../../../include ../../../../src
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+SRCS := getactualaacconfig.cpp\
+	byte_align.cpp\
+	get_audio_specific_config.cpp\
+	get_ele_list.cpp\
+	get_ga_specific_config.cpp\
+	get_ics_info.cpp\
+	get_prog_config.cpp\
+        getgroup.cpp\
+        lt_decode.cpp\
+	infoinit.cpp\
+	pvmp4audiodecodergetmemrequirements.cpp\
+	pvmp4audiodecoderinitlibrary.cpp\
+	set_mc_info.cpp\
+	sfb.cpp 
+
+
+HDRS := getactualaacconfig.h
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/makefile b/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/makefile
deleted file mode 100644
index cdda085..0000000
--- a/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = getactualaacconfig
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-XCPPFLAGS += -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DC_EQUIVALENT -DAAC_UTILITIES
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-XINCDIRS += -I ../../../../include -I ../../../../src
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-
-SRCDIR =../../src
-INCSRCDIR = ../../include
-SRCS =  getactualaacconfig.cpp
-
-    
-HDRS = getactualaacconfig.h
-
-#LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h b/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h
index e03c333..4b77015 100644
--- a/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/include/getactualaacconfig.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/byte_align.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/byte_align.cpp
new file mode 100644
index 0000000..e75c79e
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/byte_align.cpp
@@ -0,0 +1,179 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pInputStream = pointer to a BITS structure that holds information
+                   regarding the input stream.
+
+ Local Stores/Buffers/Pointers Needed:
+    None
+
+ Global Stores/Buffers/Pointers Needed:
+    None
+
+ Outputs:
+    None
+
+ Pointers and Buffers Modified:
+    pInputStream->usedBits is rounded up to a number that represents the next
+    byte boundary.
+
+ Local Stores Modified:
+    None
+
+ Global Stores Modified:
+    None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Makes the input stream structure pointed to align to the next byte boundary.
+ If it is already at a byte boundary it is left alone.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+  This function shall not use global or static variables.
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+void byte_align(
+    BITS  *pInputStream)
+
+    MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
+                (pInputStream->usedBits + 7) % 8)
+
+    RETURN(nothing)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+
+ STACK USAGE:
+
+     where:
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES:
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+
+
+#include "pv_audio_type_defs.h"
+#include "s_bits.h"
+#include "ibstream.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*
+ * A negative number was used for this mask so that it works on both
+ * 16-bit or 32-bit machines. The mask must be cast to unsigned int to
+ * work with TI compiler, ver 1.80.
+ */
+#define BYTE_ALIGN_MASK    ((UInt)(-8))
+
+#define BYTE_ALIGN_ROUNDUP  7
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL VARIABLE DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+void byte_align(
+    BITS  *pInputStream)
+{
+    /*
+     * Round up to the next byte by adding 7 and masking off with
+     * FFF8 or FFFFFFF8. The masking operation is a faster way to
+     * perform modulo arithmetic if the number is a power of 2.
+     *
+     * This code is the same as
+     * pInputStream->usedBits += (pInputStream->usedBits + 7) % 8
+     */
+    pInputStream->usedBits += BYTE_ALIGN_ROUNDUP;
+    pInputStream->usedBits &= BYTE_ALIGN_MASK;
+
+    return;
+}
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_audio_specific_config.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_audio_specific_config.cpp
new file mode 100644
index 0000000..44f5ba2
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_audio_specific_config.cpp
@@ -0,0 +1,684 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: ./src/get_audio_specific_config.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description: Modified per review comments
+
+ Description: Modified per second review comments
+              (1) change audioObjectType to Int
+              (2) do not set pVars->prog_config.profile
+              (3) clean up status flag, default to SUCCESS
+              (4) fix multiple lines comments
+
+ Description: Change getbits.h to ibstream.h
+
+ Description: Modified per review comments
+              (1) updated revision history
+              (2) declare audioObjectType as enum type
+
+ Description: Replace some instances of getbits to get9_n_lessbits
+              when the number of bits read is 9 or less.
+
+ Description: Added support for backward and non-backward (explicit)
+              mode for Parametric Stereo (PS) used in enhanced AAC+
+
+ Who:                              Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pVars = pointer to the structure that holds all information for
+            this instance of the library. pVars->prog_config is directly
+            used, and pVars->mc_info, pVars->prog_config,
+            pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly
+            for calling set_mc_info. Data type pointer to tDec_Int_File
+
+ Local Stores/Buffers/Pointers Needed:
+    None
+
+ Global Stores/Buffers/Pointers Needed:
+    None
+
+ Outputs:
+    status = 0 if successfully decoded AudioSpecificConfig
+             1 if un-supported config is used for this release
+
+ Pointers and Buffers Modified:
+    pVars->prog_config contents are updated with the information read in.
+    pVars->mc_info contents are updated with channel information.
+    pVars->pWinSeqInfo contents are updated with window information.
+    pVars->SFBWidth128 contents are updated with scale factor band width data.
+
+ Local Stores Modified:
+    None
+
+ Global Stores Modified:
+    None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function reads the bitstream for the structure "AudioSpecificConfig",
+ and sets the decoder configuration that is needed by the decoder to be able
+ to decode the media properly.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+ This function shall not use global variables
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) ISO/IEC 14496-3: 1999(E)
+ Part 3
+ Subpart 1  p18     1.6   Interface to MPEG-4 Systems
+ Subpart 4  p13     4.4.1 GA Specific Configuration
+ Amendment  p10     6.2.1 AudioSpecificInfo
+ Amendment  p78     8.2   Decoder configuration (GASpecificConfig)
+
+ (2) AAC DecoderSpecificInfo Information
+   PacketVideo descriptions - San Diego
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    status = SUCCESS;
+
+    pInputStream = &(pVars->inputStream);
+
+    temp = CALL getbits(
+                    neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
+                    pInputStream = pInputStream)
+           MODIFYING (pInputStream)
+           RETURNING (temp)
+
+    audioObjectType = (temp & 0x1f0) >> 4;
+
+    pVars->prog_config.profile = audioObjectType;
+
+    pVars->prog_config.sampling_rate_idx = temp & 0xf;
+
+    IF (pVars->prog_config.sampling_rate_idx == 0xf)
+    THEN
+        sampling_rate = CALL getbits(
+                            neededBits = LEN_SAMP_RATE,
+                            pInputStream = pInputStream);
+                        MODIFYING (pInputStream)
+                        RETURNING (sampling_rate)
+    ENDIF
+
+    channel_config = CALL getbits(
+                            neededBits = LEN_CHAN_CONFIG,
+                            pInputStream = pInputStream);
+                        MODIFYING (pInputStream)
+                        RETURNING (channel_config)
+
+    IF (channel_config > 2)
+    THEN
+        status = 1;
+    ENDIF
+
+    IF (((audioObjectType == MP4AUDIO_AAC_MAIN)     OR
+        (audioObjectType == MP4AUDIO_AAC_LC)        OR
+        (audioObjectType == MP4AUDIO_AAC_SSR)       OR
+        (audioObjectType == MP4AUDIO_LTP)           OR
+        (audioObjectType == MP4AUDIO_AAC_SCALABLE)  OR
+        (audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1))
+    THEN
+        status = CALL get_GA_specific_config(
+                            pVars = pVars,
+                            channel_config = channel_config,
+                            audioObjectType = audioObjectType,
+                            pInputStream = pInputStream);
+                      MODIFYING (pVars->mc_info,channel_config,pInputStream)
+                      RETURNING (status)
+
+    ENDIF
+
+    IF (audioObjectType == MP4AUDIO_CELP)
+    THEN
+        status = 1;
+    ENDIF
+
+    IF (audioObjectType == MP4AUDIO_HVXC)
+    THEN
+        status = 1;
+    ENDIF
+
+    IF (audioObjectType == MP4AUDIO_TTSI)
+    THEN
+        status = 1;
+    ENDIF
+
+    IF ((audioObjectType == 13) OR (audioObjectType == 14) OR
+        (audioObjectType == 15) OR (audioObjectType == 16))
+    THEN
+        status = 1;
+    ENDIF
+
+    IF (((audioObjectType == MP4AUDIO_ER_AAC_LC)       OR
+         (audioObjectType == MP4AUDIO_ER_AAC_LTP)      OR
+         (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
+         (audioObjectType == MP4AUDIO_ER_TWINVQ)       OR
+         (audioObjectType == MP4AUDIO_ER_BSAC)         OR
+         (audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1))
+    THEN
+        status = 1;
+    ENDIF
+
+    IF (audioObjectType == MP4AUDIO_ER_CELP)
+    THEN
+        status = 1;
+    ENDIF
+
+    IF (audioObjectType == MP4AUDIO_ER_HVXC)
+    THEN
+        status = 1;
+    ENDIF
+
+    IF ((audioObjectType == MP4AUDIO_ER_HILN) OR
+        (audioObjectType == MP4AUDIO_PARAMETRIC))
+    THEN
+        status = 1;
+    ENDIF
+
+    IF ((audioObjectType == MP4AUDIO_ER_AAC_LC)       OR
+        (audioObjectType == MP4AUDIO_ER_AAC_LTP)      OR
+        (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
+        (audioObjectType == MP4AUDIO_ER_TWINVQ)       OR
+        (audioObjectType == MP4AUDIO_ER_BSAC)         OR
+        (audioObjectType == MP4AUDIO_ER_AAC_LD)       OR
+        (audioObjectType == MP4AUDIO_ER_CELP)         OR
+        (audioObjectType == MP4AUDIO_ER_HVXC)         OR
+        (audioObjectType == MP4AUDIO_ER_HILN)         OR
+        (audioObjectType == MP4AUDIO_PARAMETRIC))
+    THEN
+        epConfig = CALL getbits(
+                            neededBits = LEN_EP_CONFIG,
+                            pInputStream = pInputStream);
+                      MODIFYING (pInputStream)
+                      RETURNING (epConfig)
+
+        IF (epConfig == 2)
+        THEN
+            status = 1;
+        ENDIF
+
+    ENDIF
+
+    RETURN status;
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include    "pv_audio_type_defs.h"
+#include    "e_mp4ff_const.h"
+#include    "e_tmp4audioobjecttype.h"
+#include    "get_audio_specific_config.h"
+#include    "get_ga_specific_config.h"
+#include    "ibstream.h"
+#include    "sfb.h"                   /* Where samp_rate_info[] is declared */
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+Int get_audio_specific_config(tDec_Int_File   * const pVars)
+{
+
+    UInt    temp;
+    tMP4AudioObjectType     audioObjectType;
+    //UInt32  sampling_rate;
+    UInt    channel_config;
+    UInt    syncExtensionType;
+    UInt    extensionAudioObjectType = 0;
+    UInt    extensionSamplingFrequencyIndex = 0;
+    BITS   *pInputStream;
+    Int     status;
+
+    status = SUCCESS;
+
+    pInputStream = &(pVars->inputStream);
+
+    pVars->mc_info.upsamplingFactor = 1;   /*  default to regular AAC */
+
+    temp =  get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
+                            pInputStream);
+
+    /*
+     * The following code can directly set the values of elements in
+     * MC_Info, rather than first setting the values in pVars->prog_config
+     * and then copy these values to MC_Info by calling set_mc_info.
+     * In order to keep consistent with get_prog_config (ADIF) and
+     * get_adts_header (ADTS), the code here is still copying
+     * the info, and set the pVars->current_program = 0
+     */
+
+    /* AudioObjectType */
+    audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4);
+
+    pVars->mc_info.ExtendedAudioObjectType =  audioObjectType;   /* default */
+    /* saving an audioObjectType into a profile field */
+    /* pVars->prog_config.profile = audioObjectType; */
+
+    /* sampling rate index */
+    pVars->prog_config.sampling_rate_idx = temp & 0xf;
+
+    if (pVars->prog_config.sampling_rate_idx == 0xf)
+    {
+        /*
+         * sampling rate not listed in Table 1.6.2,
+         * this release does not support this
+         */
+        /*sampling_rate =  getbits( LEN_SAMP_RATE,
+                                  pInputStream);*/
+        getbits(LEN_SAMP_RATE, pInputStream);
+
+        status = 1;
+    }
+
+    channel_config =  get9_n_lessbits(LEN_CHAN_CONFIG,
+                                      pInputStream);
+
+    if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled))
+    {
+        /*
+         * AAC lib does not support more than two channels
+         * signal error when in decoder mode
+         * do not test when in utility mode
+         */
+        status = 1;
+
+    }
+
+    if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS)
+    {
+        /* to disable explicit backward compatiblity check */
+        pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
+        pVars->mc_info.sbrPresentFlag = 1;
+
+        if (audioObjectType == MP4AUDIO_PS)
+        {
+            pVars->mc_info.psPresentFlag = 1;
+            pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS;
+        }
+
+        extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */
+            get9_n_lessbits(LEN_SAMP_RATE_IDX,
+                            pInputStream);
+        if (extensionSamplingFrequencyIndex == 0x0f)
+        {
+            /*
+             * sampling rate not listed in Table 1.6.2,
+             * this release does not support this
+                */
+            /*sampling_rate = getbits( LEN_SAMP_RATE,
+                                     pInputStream);*/
+            getbits(LEN_SAMP_RATE, pInputStream);
+        }
+
+        audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE ,
+                          pInputStream);
+    }
+
+
+    if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN)     ||*/
+                (audioObjectType == MP4AUDIO_AAC_LC)        ||
+                /*(audioObjectType == MP4AUDIO_AAC_SSR)       ||*/
+                (audioObjectType == MP4AUDIO_LTP)           /*||*/
+                /*(audioObjectType == MP4AUDIO_AAC_SCALABLE)  ||*/
+                /*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS))
+    {
+        status = get_GA_specific_config(pVars,
+                                        pInputStream,
+                                        channel_config,
+                                        audioObjectType);
+
+        /*
+         *  verify that Program config returned a supported audio object type
+         */
+
+        if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) &&
+                (pVars->mc_info.audioObjectType != MP4AUDIO_LTP))
+        {
+            status = 1;
+        }
+    }
+    else
+    {
+        status = 1;
+    }
+
+    /*
+     *  SBR tool explicit signaling ( backward compatible )
+     */
+    if (extensionAudioObjectType != MP4AUDIO_SBR)
+    {
+        syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
+                            pInputStream);
+
+        if (syncExtensionType == 0x2b7)
+        {
+            extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */
+                                           LEN_OBJ_TYPE,
+                                           pInputStream);
+
+            if (extensionAudioObjectType == MP4AUDIO_SBR)
+            {
+                pVars->mc_info.sbrPresentFlag = get1bits(pInputStream);  /* sbrPresentFlag */
+                if (pVars->mc_info.sbrPresentFlag == 1)
+                {
+                    extensionSamplingFrequencyIndex =
+                        get9_n_lessbits( /* extensionSamplingFrequencyIndex */
+                            LEN_SAMP_RATE_IDX,
+                            pInputStream);
+                    if (pVars->aacPlusEnabled == true)
+                    {
+#ifdef AAC_PLUS
+                        pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
+                                                          samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
+
+                        if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
+                        {
+                            /*
+                             *  Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
+                             */
+                            if (pVars->prog_config.sampling_rate_idx < 6)
+                            {
+                                pVars->aacPlusEnabled = false;
+                            }
+
+                            pVars->mc_info.bDownSampledSbr = true;
+                        }
+                        pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
+
+#endif
+                    }
+
+                    if (extensionSamplingFrequencyIndex == 0x0f)
+                    {
+                        /*
+                         * sampling rate not listed in Table 1.6.2,
+                         * this release does not support this
+                         */
+                        /*sampling_rate = getbits( LEN_SAMP_RATE,
+                                                 pInputStream);*/
+                        getbits(LEN_SAMP_RATE, pInputStream);
+                    }
+                    /* syncExtensionType */
+                    syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
+                                        pInputStream);
+                    if (syncExtensionType == 0x548)
+                    {
+                        pVars->mc_info.psPresentFlag = get1bits(pInputStream);  /* psPresentFlag */
+                        if (pVars->mc_info.psPresentFlag)
+                        {
+                            extensionAudioObjectType = MP4AUDIO_PS;
+                        }
+                    }
+                    else
+                    {
+                        /*
+                        * Rewind bitstream pointer so that the syncExtensionType reading has no
+                        * effect when decoding raw bitstream
+                            */
+                        pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
+                    }
+
+                    pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType;
+                }
+            }
+        }
+        else if (!status)
+        {
+            /*
+             * Rewind bitstream pointer so that the syncExtensionType reading has no
+             * effect when decoding raw bitstream
+             */
+            pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
+
+#ifdef AAC_PLUS
+
+            /*
+             *  For implicit signalling, no hint that sbr or ps is used, so we need to
+             *  check the sampling frequency of the aac content, if lesser or equal to
+             *  24 KHz, by defualt upsample, otherwise, do nothing
+             */
+            if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
+                    audioObjectType == MP4AUDIO_AAC_LC)
+            {
+                pVars->mc_info.upsamplingFactor = 2;
+                pVars->prog_config.sampling_rate_idx -= 3;
+                pVars->mc_info.sbrPresentFlag = 1;
+                pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
+                pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
+
+            }
+#endif
+
+        }
+    }
+    else    /*  MP4AUDIO_SBR was detected  */
+    {
+        /*
+         *  Set the real output frequency use by the SBR tool, define tentative upsample ratio
+         */
+        if (pVars->aacPlusEnabled == true)
+        {
+#ifdef AAC_PLUS
+            pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
+                                              samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
+
+            if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
+            {
+                /*
+                 *  Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
+                 */
+                if (pVars->prog_config.sampling_rate_idx < 6)
+                {
+                    pVars->aacPlusEnabled = false;
+                }
+                pVars->mc_info.bDownSampledSbr = true;
+            }
+            pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
+
+
+
+#endif
+
+
+
+
+        }
+
+    }  /*  if ( extensionAudioObjectType != MP4AUDIO_SBR ) */
+
+    /*
+     * The following object types are not supported in this release,
+     * however, keep these interfaces for future implementation
+     */
+
+    /*
+     *if (audioObjectType == MP4AUDIO_CELP)
+     *{
+     *    status = 1;
+     *}
+     */
+
+    /*
+     *if (audioObjectType == MP4AUDIO_HVXC)
+     *{
+     *    status = 1;
+     *}
+     */
+
+    /*
+     *if (audioObjectType == MP4AUDIO_TTSI)
+     *{
+     *    status = 1;
+     *}
+     */
+
+    /*
+     *if ((audioObjectType == 13) || (audioObjectType == 14) ||
+     *   (audioObjectType == 15) || (audioObjectType == 16))
+     *{
+     *    status = 1;
+     *}
+     */
+
+    /* The following objects are Amendment 1 objects */
+    /*
+     *if (((audioObjectType == MP4AUDIO_ER_AAC_LC)       ||
+     *    (audioObjectType == MP4AUDIO_ER_AAC_LTP)      ||
+     *    (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
+     *    (audioObjectType == MP4AUDIO_ER_TWINVQ)       ||
+     *    (audioObjectType == MP4AUDIO_ER_BSAC)         ||
+     *    (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1))
+     *{
+     */
+    /*
+     * should call get_GA_specific_config
+     * for this release, do not support Error Resilience
+     * temporary solution is set status flag and exit decoding
+     */
+    /*    status = 1;
+    *}
+    */
+
+    /*
+     *if (audioObjectType == MP4AUDIO_ER_CELP)
+     * {
+     *    status = 1;
+     *}
+     */
+
+    /*
+     *if (audioObjectType == MP4AUDIO_ER_HVXC)
+     *{
+     *    status = 1;
+     *}
+     */
+
+    /*
+     *if ((audioObjectType == MP4AUDIO_ER_HILN) ||
+     *    (audioObjectType == MP4AUDIO_PARAMETRIC))
+     *{
+     *    status = 1;
+     *}
+     */
+
+    /*
+     *if ((audioObjectType == MP4AUDIO_ER_AAC_LC)       ||
+     *    (audioObjectType == MP4AUDIO_ER_AAC_LTP)      ||
+     *    (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
+     *    (audioObjectType == MP4AUDIO_ER_TWINVQ)       ||
+     *    (audioObjectType == MP4AUDIO_ER_BSAC)         ||
+     *    (audioObjectType == MP4AUDIO_ER_AAC_LD)       ||
+     *    (audioObjectType == MP4AUDIO_ER_CELP)         ||
+     *    (audioObjectType == MP4AUDIO_ER_HVXC)         ||
+     *    (audioObjectType == MP4AUDIO_ER_HILN)         ||
+     *    (audioObjectType == MP4AUDIO_PARAMETRIC))
+     *{
+     */
+    /* error protection config */
+    /*
+     *     epConfig =
+     *       getbits(
+     *           LEN_EP_CONFIG,
+     *           pInputStream);
+     *
+     *   if (epConfig == 2)
+     *   {
+     */
+    /* should call ErrorProtectionSpecificConfig() */
+    /*
+     *       status = 1;
+     *   }
+     *
+     *}
+     */
+
+    return status;
+
+}
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ele_list.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ele_list.cpp
new file mode 100644
index 0000000..7d91e38
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ele_list.cpp
@@ -0,0 +1,243 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: get_ele_list.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Modified from original shareware code
+
+ Description:  Modified to pass variables by reference to eliminate use
+               of global variables.
+
+ Description: Change to PacketVideo standard, rename variables.
+
+ Description: Add own header file, make pInputStream second param for speed.
+
+ Description: Changes per code review:
+              1) Include header file
+              2) Convert to count down
+              3) Add return (not in review)
+
+ Description:
+ (1) Updated copyright header
+ (2) Replaced include of "interface.h" with "e_ProgConfig.h"
+
+ Description: Replace some instances of getbits to get9_n_lessbits
+			  when the number of bits read is 9 or less and get1bits
+			  when only 1 bit is read.
+
+ Who:                                 Date:
+ Description:
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pElementList = pointer to an EleList structure - only the field num_ele
+                   needs to be set. Data type pointer to EleList.
+
+   pInputStream = pointer to a BITS structure, used by the function getbits
+                   to provide data. Data type pointer to BITS
+
+    enableCPE = boolean value indicating the area to be read contains
+                a channel pair element field. Data type Bool
+
+
+ Local Stores/Buffers/Pointers Needed: None
+
+ Global Stores/Buffers/Pointers Needed: None
+
+ Outputs: None
+
+ Pointers and Buffers Modified:
+    pElementList contents are updated with information pertaining to channel
+        configuration.
+
+    pInputBuffer contents are updated to the next location to be read from
+        the input stream.
+
+ Local Stores Modified: None
+
+ Global Stores Modified: None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function is called several times by get_prog_config() to read in part of
+ the program configuration data related to channel setup.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+ This function shall not have static or global variables.
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
+   of moving pictures and associated audio information - Part 7: Advanced
+   Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
+   page 16, and section 8.5 "Program Config Element (PCE)", page 30.
+
+ (2) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    elementCount = pElementList->num_ele;
+
+    FOR (index = 0; index < elementCount; index++)
+        IF (enableCPE != FALSE) THEN
+            pElementList->ele_is_cpe[index] =
+                getbits(LEN_ELE_IS_CPE, pInputStream);
+        ELSE
+            pElementList->ele_is_cpe[index] = 0;
+        END IF
+
+        pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream);
+
+    END FOR
+
+    RETURNS nothing
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_audio_type_defs.h"
+#include "s_elelist.h"
+#include "s_bits.h"
+#include "e_progconfigconst.h"
+#include "ibstream.h"
+#include "get_ele_list.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+void get_ele_list(
+    EleList     *pElementList,
+    BITS        *pInputStream,
+    const Bool   enableCPE)
+{
+    Int index;
+    Int *pEleIsCPE;
+    Int *pEleTag;
+
+    pEleIsCPE = &pElementList->ele_is_cpe[0];
+    pEleTag   = &pElementList->ele_tag[0];
+
+    for (index = pElementList->num_ele; index > 0; index--)
+    {
+        if (enableCPE != FALSE)
+        {
+            *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream);
+        }
+        else
+        {
+            *pEleIsCPE++ = FALSE;
+        }
+
+        *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream);
+
+    } /* end for (index) */
+
+    return;
+
+} /* end get_ele_list */
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ga_specific_config.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ga_specific_config.cpp
new file mode 100644
index 0000000..6e7f5ce
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ga_specific_config.cpp
@@ -0,0 +1,473 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: get_GA_specific_config.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description: Modified per review comments
+
+ Description: Change getbits.h to ibstream.h
+
+ Description: (1) use enum type for audioObjectType (2) update revision history
+
+ Description: Updated the SW template to include the full pathname to the
+ source file and a slightly modified copyright header.
+
+ Description: Updated to use scratch memory for the temporary prog config.
+
+ Description: Replace some instances of getbits to get1bits
+			  when only 1 bit is read.
+
+ Who:                               Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+        pVars   = pointer to the structure that holds all information for
+                  this instance of the library. pVars->prog_config
+                  pVars->mc_info, pVars->pWinSeqInfo, pVars->SFBWidth128
+                  are needed for calling set_mc_info.
+                  Data type pointer to tDec_Int_File
+
+        channel_config = variable that indicates the channel configuration
+                         information, in this decoder library, only values
+                         0, 1, and 2 are allowed.
+                         Data type UInt
+
+        audioObjectType = variable that indicates the Audio Object Type.
+                          Data type UInt.
+
+        pInputStream = pointer to a BITS structure that holds information
+                       regarding the input stream.
+
+ Local Stores/Buffers/Pointers Needed:
+    None
+
+ Global Stores/Buffers/Pointers Needed:
+    None
+
+ Outputs:
+    status = 0 if success
+             1 otherwise
+
+ Pointers and Buffers Modified:
+    pVars->mc_info contents are updated with channel information.
+    if infoinit is called within set_mc_info, then
+    pVars->pWinSeqInfo contents are updated with window information.
+    pVars->SFBWidth128 contents are updated with scale factor band width data.
+
+ Local Stores Modified:
+    None
+
+ Global Stores Modified:
+    None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function takes the sampling_rate_idx, channel_config, and
+ audioObjectType from AudioSpecificConfig() and set the decoder configuration
+ necessary for the decoder to decode properly.
+ It also reads the bitstream for frame length, scalable bitstream information
+ and extension information to General Audio defined in MPEG-4 phase 1
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+  This function shall not use global variables
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) ISO/IEC 14496-3: 1999(E)
+ Part 3
+ Subpart 1  p18     1.6 Interface to MPEG-4 Systems
+ Subpart 4  p13     4.4.1 GA Specific Configuration
+ Amendment  p10     6.2.1 AudioSpecificInfo
+ Amendment  p78     8.2 Decoder configuration (GASpecificConfig)
+
+ (2) AAC DecoderSpecificInfo Information
+   PacketVideo descriptions - San Diego
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    frameLenFlag = CALL getbits(
+                            neededBits = LEN_FRAME_LEN_FLAG,
+                            pInputStream = pInputStream);
+                        MODIFYING (pInputStream)
+                        RETURNING (frameLenFlag)
+
+    dependsOnCoreCoder = CALL getbits(
+                               neededBits = LEN_DEPEND_ON_CORE,
+                               pInputStream = pInputStream);
+                        MODIFYING (pInputStream)
+                        RETURNING (dependsOnCoreCoder)
+
+    IF (dependsOnCoreCoder != FALSE)
+    THEN
+        coreCoderDelay = CALL getbits(
+                                neededBits = LEN_CORE_DELAY,
+                                pInputStream = pInputStream);
+                            MODIFYING (pInputStream)
+                            RETURNING (coreCoderDelay)
+    ENDIF
+
+    extFlag = CALL getbits(
+                      neededBits = LEN_EXT_FLAG,
+                      pInputStream = pInputStream);
+                   MODIFYING (pInputStream)
+                   RETURNING (extFlag)
+
+    IF (channel_config == 0)
+    THEN
+        status = CALL get_prog_config(
+                        pVars = pVars,
+                        pScratchPCE = &pVars->scratch_prog_config);
+                   MODIFYING (pVars, pScratchPCE)
+                   RETURNING (status)
+
+    ELSE
+        channel_config--;
+        pVars->prog_config.front.ele_is_cpe[0] = channel_config;
+        pVars->prog_config.front.ele_tag[0] = 0;
+
+        status = CALL set_mc_info(
+                        pMC_Info =  &(pVars->mc_info),
+                        audioObjectType = audioObjectType,
+                        sampling_rate_idx = pVars->prog_config.sampling_rate_idx,
+                        tag = pVars->prog_config.front.ele_tag[0],
+                        is_cpe = pVars->prog_config.front.ele_is_cpe[0],
+                        pWinSeqInfo = pVars->pWinSeqInfo,
+                        sfbwidth128 = pVars->SFBWidth128);
+                    MODIFYING (pMC_Info, pWinSeqInfo, sfbwidth128)
+                    RETURNING (SUCCESS)
+    ENDIF
+
+    IF ((audioObjectType == MP4AUDIO_AAC_SCALABLE) OR
+        (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE))
+    THEN
+        layer_num = CALL getbits(
+                            neededBits = LEN_LAYER_NUM,
+                            pInputStream = pInputStream);
+                        MODIFYING (pInputStream)
+                        RETURNING (layer_num)
+
+        status = 1;
+    ENDIF
+
+    IF (extFlag != FALSE)
+    THEN
+         IF (audioObjectType == MP4AUDIO_ER_BSAC)
+         THEN
+              numOfSubFrame = CALL getbits(
+                                     neededBits = LEN_SUB_FRAME,
+                                     pInputStream = pInputStream);
+                                MODIFYING (pInputStream)
+                                RETURNING (numOfSubFrame)
+
+              layer_len = CALL getbits(
+                                neededBits = LEN_LAYER_LEN,
+                                pInputStream = pInputStream);
+                               MODIFYING (pInputStream)
+                               RETURNING (layer_len)
+
+         ENDIF
+
+         IF (((audioObjectType > 16) AND (audioObjectType < 22)) OR
+             (audioObjectType == 23))
+         THEN
+             aacSectionDataResilienceFlag =
+                            CALL getbits(
+                                    neededBits = LEN_SECT_RES_FLAG,
+                                    pInputStream = pInputStream);
+                                MODIFYING (pInputStream)
+                                RETURNING (aacSectionDataResilienceFlag)
+
+             aacScalefactorDataResilienceFlag =
+                            CALL getbits(
+                                    neededBits = LEN_SFB_RES_FLAG,
+                                    pInputStream = pInputStream);
+                                MODIFYING (pInputStream)
+                                RETURNING (aacScalefactorDataResilienceFlag)
+
+             aacSpectralDataResilienceFlag =
+                            CALL getbits(
+                                    neededBits = LEN_SPEC_RES_FLAG,
+                                    pInputStream = pInputStream);
+                                MODIFYING (pInputStream)
+                                RETURNING (aacSpectralDataResilienceFlag)
+         ENDIF
+
+        status = 1;
+
+    ENDIF
+
+    RETURN status;
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include    "pv_audio_type_defs.h"
+#include    "e_mp4ff_const.h"
+#include    "e_tmp4audioobjecttype.h"
+#include    "s_tdec_int_file.h"
+#include    "get_ga_specific_config.h"
+#include    "set_mc_info.h"
+#include    "get_prog_config.h"
+#include    "ibstream.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+Int get_GA_specific_config(
+    tDec_Int_File * const pVars,
+    BITS    *pInputStream,
+    UInt     channel_config,
+    const tMP4AudioObjectType audioObjectType
+)
+{
+
+    Int status = SUCCESS;
+    UInt dependsOnCoreCoder;
+    /* Int coreCoderDelay; */
+    UInt extFlag;
+
+    /* These variables are left for future implementation */
+    /* UInt layer_num; */
+    /* UInt numOfSubFrame; */
+    /* UInt layer_len; */
+    /* UInt aacSectionDataResilienceFlag; */
+    /* UInt aacScalefactorDataResilienceFlag; */
+    /* UInt aacSpectralDataResilienceFlag; */
+    Int  extFlag3;
+
+    /*
+     * frame length flag == 0, 1024 samples/frame
+     * frame length flag == 1,  960 samples/frame
+     */
+    get1bits(/*            LEN_FRAME_LEN_FLAG,*/
+        pInputStream);
+
+    /*
+     * dependsOnCoreCoder == 1, core coder has different sampling rate
+     * in a scalable bitstream
+     */
+    dependsOnCoreCoder =
+        get1bits(/*            LEN_DEPEND_ON_CORE,*/
+            pInputStream);
+
+    if (dependsOnCoreCoder != FALSE)
+    {
+        /*coreCoderDelay =
+         *    getbits(
+         *        LEN_CORE_DELAY,
+         *        pInputStream);
+         */
+
+        status = 1; /* do not support scalable coding in this release */
+    }
+
+    /*
+     * extension flag indicates if Amendment 1 objects are used or not
+     * extension flag == 0 objects = 1, 2, 3, 4, 6, 7
+     * extension flag == 1 objects = 17, 19, 20, 21, 22, 23
+     */
+    extFlag = get1bits(pInputStream);       /*  LEN_EXT_FLAG,*/
+
+
+    /* Force checks for implicit channel configuration */
+    pVars->mc_info.implicit_channeling = 1;
+
+    if (status == SUCCESS)
+    {
+
+        if (channel_config == 0)
+        {
+            status = get_prog_config(pVars,
+                                     &pVars->scratch.scratch_prog_config);
+
+            if (status != SUCCESS)
+            {
+                pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono  */
+                pVars->mc_info.nch = 1;
+                pVars->prog_config.front.ele_tag[0] = 0;
+
+                status = SUCCESS;
+            }
+        }
+        else
+        {
+            /*
+             * dummy tag = 0 and
+             * set up decoding configurations
+             */
+            channel_config--;
+            pVars->prog_config.front.ele_is_cpe[0] = channel_config;
+            pVars->prog_config.front.ele_tag[0] = 0;
+
+            status =
+                set_mc_info(
+                    &(pVars->mc_info),
+                    audioObjectType, /* previously profile */
+                    pVars->prog_config.sampling_rate_idx,
+                    pVars->prog_config.front.ele_tag[0],
+                    pVars->prog_config.front.ele_is_cpe[0],
+                    pVars->winmap, /*pVars->pWinSeqInfo,*/
+                    pVars->SFBWidth128);
+
+        } /* if (channel_config) */
+
+    } /* if(status) */
+
+    /*
+     * This layer_num is not found in ISO/IEC specs,
+     * but it is defined in San Diego spec for scalable bitstream
+     */
+    if ((audioObjectType == MP4AUDIO_AAC_SCALABLE) ||
+            (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE))
+    {
+        /*layer_num =
+         *    getbits(
+         *        LEN_LAYER_NUM,
+         *        pInputStream);
+         */
+
+        status = 1; /* for this release only */
+    }
+
+    if (extFlag)
+    {
+        /*
+         * currently do not implement these functionalities
+         * defined in Amendment 1
+         * keep it here for future release
+         */
+        if (audioObjectType == MP4AUDIO_ER_BSAC)
+        {
+            status = 1;     /* NOT SUPPORTED */
+            /*
+            numOfSubFrame = getbits( LEN_SUB_FRAME, pInputStream);
+
+            layer_len = getbits( LEN_LAYER_LEN, pInputStream);
+            */
+        }
+
+        /*
+         * The following code is equivalent to
+         * if ((audioObjectType == 17) || (audioObjectType == 18) ||
+         *     (audioObjectType == 19) || (audioObjectType == 20) ||
+         *     (audioObjectType == 21) || (audioObjectType == 23))
+         */
+
+        if (((audioObjectType > 16) && (audioObjectType < 22)) ||
+                (audioObjectType == 23))
+        {
+            status = 1;     /* NOT SUPPORTED */
+            /*
+            aacSectionDataResilienceFlag = getbits( LEN_SECT_RES_FLAG,
+                                                    pInputStream);
+
+            aacScalefactorDataResilienceFlag = getbits( LEN_SCF_RES_FLAG,
+                                                        pInputStream);
+
+            aacSpectralDataResilienceFlag = getbits( LEN_SPEC_RES_FLAG,
+                                                     pInputStream);
+            */
+        }
+        /*
+         * this flag is tbd in version 3 of ISO/IEC spec
+         * if the encoder generates this bit, then it has to be read
+         * current adif2mp4ff does not write this bit. If this bit is to
+         * be read, it can be done by the following code:
+         */
+
+        extFlag3 = get1bits(pInputStream);       /*  LEN_EXT_FLAG3 */
+
+        if (extFlag3)
+        {
+            status = 1;     /* NOT SUPPORTED */
+        }
+
+    }
+
+    return status;
+}
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ics_info.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ics_info.cpp
new file mode 100644
index 0000000..09cdac5
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_ics_info.cpp
@@ -0,0 +1,608 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: ./src/get_ics_info.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Modified from original shareware code
+
+ Description:  Modified to pass variables by reference to eliminate use
+               of global variables.
+
+ Description:  Clean up code.
+
+ Description:  Fix comments before review, remove lpflag[]
+
+ Description:  Update per review comments, and match ISO/IEC 14496-3
+
+ Description:  Update per peer review comments.
+
+ Description:  Remove "rollback" of used bits, since lt_decode is to change.
+
+ Description: Replace some instances of getbits to get9_n_lessbits
+			  when the number of bits read is 9 or less and get1bits
+			  when only 1 bit is read.
+
+ Who:                                   Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    audioObjectType = MP4 Audio Object Type for the current song. Only if
+                    this is set to LTP (MP4AUDIO_LTP) will long term
+                    prediction bits be retrieved. Data type
+                    tMP4AudioObjectType, which is an enumeration, which in
+                    turn is an Int.
+
+    pInputStream  = pointer to a BITS structure, used by the function getbits
+                    to provide data. This is the second parameter to this
+                    function to match its position in getbits().
+                    Data type pointer to BITS structure
+
+    common_window = field read in huffdecode, which tells whether information
+                    is shared between the left and right channel. Long term
+                    prediction (LTP) data is NOT shared even if its a common
+                    window, so this flag is needed to see if another set of
+                    LTP possibly needs to be read. If this flag is false,
+                    pSecondLTPStatus is not touched, it could be NULL if
+                    need be. Data type Bool, which is Int.
+
+    pWindowSequence = pointer to where the the window type of the current
+                    frame and channel should be placed, of data type
+                    WINDOW_SEQUENCE, which is Int. It can take on one
+                    of four values: ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE,
+                    EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE,
+
+    pWindowShape =  pointer to where the window shape for the current frame
+                    and channel should be placed, of data type WINDOW_SHAPE,
+                    which is Int. It can take on the one of these two values:
+                    SINE_WINDOW, KAISER_BESSEL_WINDOW. It is used in the
+                    "filterbank" section of decoding.
+
+    group         = array that holds the index of the first window in each
+                    group. Data type array of Int, eight elements.
+
+    p_max_sfb     = pointer to where the maximum number of scale factor bands
+                    for the current frame and channel will be placed. Data
+                    type of pointer to Int.
+
+    p_winmap      = array of pointers to all of the possible four window
+                    configurations. This parameter did not need to be pointers,
+                    and could be changed in the future. Data type array of pointers
+                    to FrameInfo structures, length 4.
+
+    pFirstLTPStatus = pointer to a structure where the first LTP
+                    information will be stored. It would be confusing and wrong
+                    to call this left LTP status since if common_window = FALSE,
+                    this function will be called twice - once for the left, once
+                    for the right. It could be done, but extra conditional code
+                    would need to be done.
+                    Data type pointer to LT_PRED_STATUS structure.
+
+    pSecondLTPStatus = pointer to where the right channel of LTP
+                    information will be stored only if common_window is non-zero.
+                    Data type pointer to LT_PRED_STATUS structure.
+
+ Local Stores/Buffers/Pointers Needed: None.
+
+ Global Stores/Buffers/Pointers Needed: None.
+
+ Outputs:
+    status  = 0 implies no error occurred, non-zero otherwise.
+
+ Pointers and Buffers Modified:
+    pInputStream contents are modified in such a way that the number of bits
+        read increases.
+    pWindowSequence contents are updated with the current window for this
+        frame and channel
+    group[] contents will be modified to grouping information. See getgroup
+        source code for a better description of what this is.
+    p_max_sfb contents will be updated with the maximum scale factor bands
+        for this frame and channel.
+    pFirstLTPStatus contents may be updated if the stream has long term
+        prediction information.
+    pSecondLTPStatus contents may be updated if common_window != 0 and LTP data
+        is present.
+
+
+ Local Stores Modified: None
+
+ Global Stores Modified: None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function retrieves the individual channel stream (ICS) information
+ from the bitstream. The information read for the current
+ frame and channel is:
+ - window sequence
+ - window shape for use in the filter bank
+ - number of scale factor bands
+ - long term predication (LTP) information
+ - grouping information
+
+ This function does NOT support MPEG2 style AAC Frequency Domain Predictor,
+ not to be confused with LTP (Long Term Prediction). If such data is found
+ to be on the file an error is generated.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+ This function is not to use static or global data.
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+  (1) ISO/IEC 14496-3:1999(E) Titled "Information technology - Coding
+      of audio-visual objects Part 3: Audio Subpart 4:"
+      Table 4.4.6 - Syntax of ics_info(), page 16.
+
+
+ (2) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    status = 0;
+    first_ltp_data_present = FALSE;
+    second_ltp_data_present = FALSE;
+
+
+    CALL getbits(
+        neededBits = LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH,
+        pInputStream = pInputStream)
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    windowSequence = (temp >> LEN_WIN_SH) & ((0x1<<LEN_WIN_SEQ)-1);
+
+    *pWindowShape = (temp) & ((0x1<<LEN_WIN_SH)-1);
+
+    IF (windowSequence == EIGHT_SHORT_SEQUENCE)
+    THEN
+        CALL getbits(
+            neededBits = LEN_MAX_SFBS,
+            pInputStream = pInputStream)
+        MODIFYING(pInputStream)
+        RETURNING(local_max_sfb = returnValue)
+
+        CALL getgroup(
+            group = group,
+            pInputStream = pInputStream)
+        MODIFYING(group)
+        MODIFYING(pInputStream)
+        RETURNING(nothing)
+
+
+    ELSE
+
+        group[0] = 1;
+
+        CALL getbits(
+            neededBits = LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT,
+            pInputStream = pInputStream)
+        MODIFYING(pInputStream)
+        RETURNING(temp = returnValue)
+
+        predictor_data_present =
+            (Bool) getbits(
+                LEN_BOOLEAN,
+                pInputStream);
+
+        local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT);
+
+        predictor_data_present =
+            (Bool) (temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT)-1));
+
+        IF (local_max_sfb > allowed_max_sfb)
+        THEN
+            status = 1
+        ELSEIF (audioObjectType == MP4AUDIO_LTP)
+        THEN
+            IF (predictor_data_present != FALSE)
+            THEN
+                CALL getbits(
+                    neededBits = LEN_LTP_DATA_PRESENT,
+                    pInputStream = pInputStream)
+                MODIFYING(pInputStream)
+                RETURNING(first_ltp_data_present = returnValue)
+
+                IF (ltp_data_present != FALSE)
+                THEN
+
+                    CALL lt_decode(
+                        win_type = windowSequence,
+                        pInputStream  = pInputStream,
+                        max_sfb = local_max_sfb,
+                        pLt_pred = pFirstLTPStatus)
+                    MODIFYING(pInputStream)
+                    MODIFYING(pFirstLTPStatus)
+                    RETURNING(nothing)
+
+                ENDIF
+
+                IF (common_window != FALSE)
+                THEN
+                    CALL getbits(
+                        neededBits = LEN_LTP_DATA_PRESENT,
+                        pInputStream = pInputStream)
+                    MODIFYING(pInputStream)
+                    RETURNING(second_ltp_data_present = returnValue)
+
+                    IF (second_ltp_data_present != FALSE)
+                    THEN
+
+                        CALL lt_decode(
+                            win_type = windowSequence,
+                            pInputStream  = pInputStream,
+                            max_sfb = local_max_sfb,
+                            pLt_pred = pSecondLTPStatus)
+                        MODIFYING(pInputStream)
+                        MODIFYING(pSecondLTPStatus)
+                        RETURNING(nothing)
+                    ENDIF
+                ENDIF
+            ENDIF
+        ELSE
+            IF  (predictor_data_present != FALSE)
+            THEN
+                status = 1
+            ENDIF
+        END IF
+    ENDIF
+
+    pFirstLTPStatus->ltp_data_present = first_ltp_data_present;
+
+    IF (common_window != FALSE)
+    THEN
+        pSecondLTPStatus->ltp_data_present = second_ltp_data_present;
+    ENDIF
+
+    pFrameInfo = p_winmap[*p_wnd];
+    IF (local_max_sfb > pFrameInfo->sfb_per_frame)
+    THEN
+        status = 1;
+    ENDIF
+
+    *(p_max_sfb) = local_max_sfb;
+
+    MODIFY(*(pWindowSequence))
+    MODIFY(*(pWinShape))
+    MODIFY(*(p_max_sfb))
+    MODIFY(group[])
+    MODIFY(*pInputStream)
+    MODIFY(*pFirstLTPStatus)
+    MODIFY(*pSecondLTPStatus)
+    RETURN (status);
+
+
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_audio_type_defs.h"
+
+#include "e_rawbitstreamconst.h"
+#include "e_tmp4audioobjecttype.h"
+
+#include "s_bits.h"
+#include "s_frameinfo.h"
+#include "s_lt_pred_status.h"
+
+#include "ibstream.h"
+#include "lt_decode.h"
+#include "ltp_common_internal.h" /* For LEN_LTP_DATA_PRESENT constant */
+
+#include "get_ics_info.h"
+#include "huffman.h"        /* For the declaration of getgroup */
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+#define LEN_PREDICTOR_DATA_PRESENT (1)
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL VARIABLE DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+Int get_ics_info(
+    const tMP4AudioObjectType  audioObjectType,
+    BITS                      *pInputStream,
+    const Bool                 common_window,
+    WINDOW_SEQUENCE           *pWindowSequence,
+    WINDOW_SHAPE              *pWindowShape,
+    Int                        group[],
+    Int                       *p_max_sfb,
+    FrameInfo                 *p_winmap[],
+    LT_PRED_STATUS            *pFirstLTPStatus,
+    LT_PRED_STATUS            *pSecondLTPStatus)
+{
+    WINDOW_SEQUENCE       windowSequence;
+    UInt                  temp;
+    Bool                  predictor_data_present;
+    UInt                   local_max_sfb;
+    UInt                   allowed_max_sfb;
+    Int                   status = SUCCESS;
+    Bool                  first_ltp_data_present = FALSE;
+    Bool                  second_ltp_data_present = FALSE;
+
+    /*
+     * The following three calls to getbits have been replaced with one
+     * call for speed:
+     *
+     *                  getbits(LEN_ICS_RESERV, pInputStream);
+     * windowSequence = getbits(LEN_WIN_SEQ, pInputStream);
+     * *pWindowShape  = getbits(LEN_WIN_SH, pInputStream);
+     *
+     */
+
+    temp =
+        get9_n_lessbits(
+            LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH,
+            pInputStream);
+
+
+    windowSequence = (WINDOW_SEQUENCE)((temp >> LEN_WIN_SH) & ((0x1 << LEN_WIN_SEQ) - 1));
+
+    *pWindowShape = (WINDOW_SHAPE)((temp) & ((0x1 << LEN_WIN_SH) - 1));
+
+    /*
+     * This pointer should not be NULL as long as the initialization code
+     * has been run, so the test for NULL has been removed.
+     */
+    allowed_max_sfb = p_winmap[windowSequence]->sfb_per_win[0];
+
+    if (windowSequence == EIGHT_SHORT_SEQUENCE)
+    {
+        local_max_sfb =  get9_n_lessbits(LEN_MAX_SFBS,
+                                         pInputStream);
+
+        getgroup(
+            group,
+            pInputStream);
+
+        if (local_max_sfb > allowed_max_sfb)
+        {
+            status = 1;  /* ERROR CODE - needs to be updated */
+        }
+
+    } /* end of TRUE of if (windowSequence == EIGHT_SHORT_SEQUENCE) */
+    else
+    {
+        /* There is only one group for long windows. */
+        group[0] = 1;
+
+        /*
+         * The window is long, get the maximum scale factor bands,
+         * and get long term prediction info.
+         *
+         * Reference [1] states that the audioObjectType is first tested,
+         * then the predictor_data_present is read on either branch of the
+         * if (audioObjectType == MP4AUDIO_LTP). Instead, this code combines
+         * the two calls on both branches into one before the
+         * if, and then in turn combines with another call to getbits, all
+         * in the name of speed.
+         *
+         * This would be the individual calls, without checking the number
+         * of scale factor bands:
+         *
+         *   local_max_sfb =
+         *      (Int) getbits(
+         *          LEN_MAX_SFBL,
+         *           pInputStream);
+         *
+         *  if (audioObjectType == MP4AUDIO_LTP)
+         *  {
+         *        predictor_data_present =
+         *           (Bool) getbits(
+         *              LEN_PREDICTOR_DATA_PRESENT,
+         *              pInputStream);
+         *
+         *     .....   (read LTP data)
+         *
+         *    }
+         *    else
+         *    {
+         *
+         *        predictor_data_present =
+         *           (Bool) getbits(
+         *              LEN_PREDICTOR_DATA_PRESENT,
+         *              pInputStream);
+         *
+         *     .....   (its an error for this library)
+         *     }
+         */
+        temp =
+            get9_n_lessbits(
+                LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT,
+                pInputStream);
+
+        local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT);
+
+        predictor_data_present =
+            (Bool)(temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT) - 1));
+
+        if (local_max_sfb > allowed_max_sfb)
+        {
+            status = 1;  /* ERROR CODE - needs to be updated */
+        }
+        else if (audioObjectType == MP4AUDIO_LTP)
+        {
+            /*
+             * Note that the predictor data bit has already been
+             * read.
+             */
+
+            /*
+             * If the object type is LTP, the predictor data is
+             * LTP. If the object type is not LTP, the predictor data
+             * is so called "frequency predictor data", which is not
+             * supported by this implementation. Refer to (1)
+             */
+            if (predictor_data_present != FALSE)
+            {
+                first_ltp_data_present =
+                    (Bool) get1bits(/*                        LEN_LTP_DATA_PRESENT,*/
+                        pInputStream);
+
+                if (first_ltp_data_present != FALSE)
+                {
+                    lt_decode(
+                        windowSequence,
+                        pInputStream,
+                        local_max_sfb,
+                        pFirstLTPStatus);
+                }
+                if (common_window != FALSE)
+                {
+                    second_ltp_data_present =
+                        (Bool) get1bits(/*                            LEN_LTP_DATA_PRESENT,*/
+                            pInputStream);
+
+                    if (second_ltp_data_present != FALSE)
+                    {
+                        lt_decode(
+                            windowSequence,
+                            pInputStream,
+                            local_max_sfb,
+                            pSecondLTPStatus);
+                    }
+                } /* if (common_window != FALSE) */
+
+            } /* if (predictor_data_present != FALSE) */
+
+        } /* else if (audioObjectType == MP4AUDIO_LTP) */
+        else
+        {
+            /*
+             * Note that the predictor data bit has already been
+             * read.
+             */
+
+            /*
+             * The object type is not LTP. If there is data, its
+             * frequency predictor data, not supported by this
+             * implementation.
+             */
+            if (predictor_data_present != FALSE)
+            {
+                status = 1; /* ERROR CODE UPDATE LATER */
+            } /* if (predictor_data_present != FALSE) */
+
+        } /* end of "else" clause of if (audioObjectType == MP4AUDIO_LTP) */
+
+    } /*  if (windowSequence == EIGHT_SHORT_SEQUENCE) [FALSE branch] */
+
+
+    /*
+     * Save all local copies.
+     */
+    pFirstLTPStatus->ltp_data_present = first_ltp_data_present;
+    if (common_window != FALSE)
+    {
+        pSecondLTPStatus->ltp_data_present = second_ltp_data_present;
+    }
+
+    *p_max_sfb = local_max_sfb;
+
+    *pWindowSequence = windowSequence;
+
+    return (status);
+
+}  /* get_ics_info */
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_prog_config.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_prog_config.cpp
new file mode 100644
index 0000000..ecf5376
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/get_prog_config.cpp
@@ -0,0 +1,739 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: get_prog_config.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Modified from original shareware code
+
+ Description:  Modified to pass variables by reference to eliminate use
+               of global variables.
+
+ Description:  Move functionality from get_adif_header for when to change
+               the current program configuration, add a temporary config
+               to read into, clean up code, change function prototype.
+
+ Description:  Clean up
+
+ Description:  Update per review comments
+
+ Description:  Fix double 'could'
+
+ Description:  change enter_mc_info to set_mc_info
+
+ Description:  update comments
+
+ Description: Replace some instances of getbits to get9_n_lessbits
+			  when the number of bits read is 9 or less and get1bits
+			  when only 1 bit is read.
+
+ Who:                                   Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pVars      = pointer to the structure that holds all information for
+                 this instance of the library. pVars->prog_config is directly
+                 used, and pVars->mc_info, pVars->prog_config, pVars->winmap,
+                 pVars->SFBWidth128 are needed indirectly for calling
+                 set_mc_info. Data type  pointer to tDec_Int_File structure.
+
+    pScratchPCE = pointer to a temporary ProgConfig structure to be used
+                  to read in the program configuration element.
+
+ Local Stores/Buffers/Pointers Needed: None
+
+ Global Stores/Buffers/Pointers Needed: None
+
+ Outputs:
+    status     = zero if no error was found, non-zero otherwise.
+
+ Pointers and Buffers Modified:
+    pVars->prog_config contents are updated with the PCE read in.
+    pVars->mc_info contents are updated with channel information.
+    pVars->winmap contents are updated with window information.
+    pVars->SFBWidth128 contents are updated with scale factor band width data.
+
+ Local Stores Modified: None
+
+ Global Stores Modified: None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function reads from the input stream to memory for a temporary
+ program configuration element (PCE). If the PCE read is the first
+ encountered it is saved. Or, if the tag of the PCE read matches the tag of
+ the first PCE encounted, it is saved as well. This is a mechanism for
+ changing the sampling rate.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+ This function shall not use static or global variables.
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
+   of moving pictures and associated audio information - Part 7: Advanced
+   Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
+   page 16, and section 8.5 "Program Config Element (PCE)", page 30.
+
+ (2) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    status          = SUCCESS;
+    pInputStream   = &(pVars->inputStream);
+
+
+    CALL getbits(
+        neededBits = LEN_TAG,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( tag = returnValue )
+
+    CALL getbits(
+        neededBits = LEN_PROFILE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( pScratchPCE->profile = returnValue )
+
+    CALL getbits(
+        neededBits = LEN_PROFILE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( pScratchPCE->sampling_rate_idx = returnValue )
+
+    CALL getbits(
+        neededBits = LEN_NUM_ELE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    pScratchPCE->front.num_ele = temp;
+
+    CALL getbits(
+        neededBits = LEN_NUM_ELE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    pScratchPCE->side.num_ele = temp;
+
+    CALL getbits(
+        neededBits = LEN_NUM_ELE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    pScratchPCE->back.num_ele = temp;
+
+    CALL getbits(
+        neededBits = LEN_NUM_LFE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    pScratchPCE->lfe.num_ele = temp;
+
+    CALL getbits(
+        neededBits = LEN_NUM_DAT,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    pScratchPCE->data.num_ele = temp;
+
+    CALL getbits(
+        neededBits = LEN_NUM_CCE,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( temp = returnValue )
+
+    pScratchPCE->coupling.num_ele = temp;
+
+    CALL getbits(
+        neededBits = LEN_MIX_PRES,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( flag = returnValue )
+
+    pScratchPCE->mono_mix.present = flag;
+
+    IF (flag != FALSE)
+    THEN
+        CALL getbits(
+            neededBits = LEN_TAG,
+            pInputStream = pInputStream )
+        MODIFYING( pInputStream )
+        RETURNING( temp = returnValue )
+
+        pScratchPCE->mono_mix.ele_tag = temp;
+
+    ENDIF
+
+    CALL getbits(
+        neededBits = LEN_MIX_PRES,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( flag = returnValue )
+
+    pScratchPCE->stereo_mix.present = flag;
+
+    IF (flag != FALSE)
+    THEN
+
+        CALL getbits(
+            neededBits = LEN_TAG,
+            pInputStream = pInputStream )
+        MODIFYING( pInputStream )
+        RETURNING( temp = returnValue )
+
+        pScratchPCE->stereo_mix.ele_tag = temp;
+
+    ENDIF
+
+    CALL getbits(
+        neededBits = LEN_MIX_PRES,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( flag = returnValue )
+
+    flag =
+        getbits(
+            LEN_MIX_PRES,
+            pInputStream);
+
+    pScratchPCE->matrix_mix.present = flag;
+
+    IF (flag != FALSE)
+    THEN
+        CALL getbits(
+            neededBits = LEN_MMIX_IDX,
+            pInputStream = pInputStream )
+        MODIFYING( pInputStream )
+        RETURNING( temp = returnValue )
+
+        pScratchPCE->matrix_mix.ele_tag = temp;
+
+        CALL getbits(
+            neededBits = LEN_PSUR_ENAB,
+            pInputStream = pInputStream )
+        MODIFYING( pInputStream )
+        RETURNING( temp = returnValue )
+
+        pScratchPCE->matrix_mix.pseudo_enab = temp;
+
+    ENDIF
+
+
+    CALL get_ele_list(
+        pElementList = &pScratchPCE->front,
+        pInputStream = pInputStream,
+        enableCPE    = TRUE )
+    MODIFYING( pInputStream )
+    MODIFYING( pScratchPCE->front )
+    RETURNING( nothing )
+
+    CALL get_ele_list(
+        pElementList = &pScratchPCE->side,
+        pInputStream = pInputStream,
+        enableCPE    = TRUE )
+    MODIFYING( pInputStream )
+    MODIFYING( pScratchPCE->side )
+    RETURNING( nothing )
+
+    CALL get_ele_list(
+        pElementList = &pScratchPCE->back,
+        pInputStream = pInputStream,
+        enableCPE    = TRUE )
+    MODIFYING( pInputStream )
+    MODIFYING( pScratchPCE->back )
+    RETURNING( nothing )
+
+    CALL get_ele_list(
+        pElementList = &pScratchPCE->lfe,
+        pInputStream = pInputStream,
+        enableCPE    = FALSE )
+    MODIFYING( pInputStream )
+    MODIFYING( pScratchPCE->lfe )
+    RETURNING( nothing )
+
+    CALL get_ele_list(
+        pElementList = &pScratchPCE->data,
+        pInputStream = pInputStream,
+        enableCPE    = FALSE )
+    MODIFYING( pInputStream )
+    MODIFYING( pScratchPCE->data )
+    RETURNING( nothing )
+
+    CALL get_ele_list(
+        pElementList = &pScratchPCE->coupling,
+        pInputStream = pInputStream,
+        enableCPE    = TRUE )
+    MODIFYING( pInputStream )
+    MODIFYING( pScratchPCE->coupling )
+    RETURNING( nothing )
+
+
+    CALL byte_align(
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( nothing )
+
+    CALL getbits(
+        neededBits = LEN_COMMENT_BYTES,
+        pInputStream = pInputStream )
+    MODIFYING( pInputStream )
+    RETURNING( numChars = returnValue )
+
+    FOR (i = numChars; i > 0; i--)
+
+        CALL getbits(
+            neededBits = LEN_COMMENT_BYTES,
+            pInputStream = pInputStream )
+        MODIFYING( pInputStream )
+        RETURNING( nothing )
+
+    ENDFOR
+
+    IF (pVars->current_program < 0)
+    THEN
+        pVars->current_program = tag;
+    ENDIF
+
+
+    IF (tag == pVars->current_program)
+    THEN
+
+        CALL pv_memcpy(
+            to = &pVars->prog_config,
+            from = pScratchPCE,
+            n = sizeof(ProgConfig))
+        MODIFYING( pVars->prog_config )
+        RETURNING( nothing )
+
+        CALL set_mc_info(
+            pMC_Info = &pVars->mc_info,
+            objectType = pVars->prog_config.profile + 1,
+            samplin_rate_idx = pVars->prog_config.sampling_rate_idx,
+            tag = pVars->prog_config.front.ele_tag[0],
+            is_cpe = pVars->prog_config.front.ele_is_cpe[0],
+            pWinSeqInfo = pVars->winmap,
+            pSfbwidth128 = pVars->SFBWidth128)
+        MODIFYING( pVars->mc_info )
+        MODIFYING( pVars->winmap )
+        MODIFYING( pVars->SFBWidth128 )
+        RETURN( status = return_value )
+
+    ENDIF
+
+    MODIFY( pVars->mc_info )
+    MODIFY( pVars->winmap )
+    MODIFY( pVars->SFBWidth128 )
+    RETURN (status)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_audio_type_defs.h"
+#include "s_bits.h"
+#include "s_elelist.h"
+#include "s_tdec_int_file.h"
+#include "s_tdec_int_chan.h"
+#include "e_progconfigconst.h"
+#include "ibstream.h"
+#include "get_ele_list.h"
+#include "aac_mem_funcs.h"
+#include "set_mc_info.h"
+#include "get_prog_config.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL VARIABLE DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+Int get_prog_config(
+    tDec_Int_File *pVars,
+    ProgConfig    *pScratchPCE)
+{
+    Int    i;
+    UInt    tag;
+    Int    numChars;
+    UInt    temp;
+    Bool   flag;
+    Int    status          = SUCCESS;
+    BITS  *pInputStream   = &(pVars->inputStream);
+
+
+    /*
+     * The tag is used at the very end to see if this PCE is
+     * the one to be used. Otherwise it does not need to be saved for the
+     * the simple configurations to be used in this version of an AAC
+     * decoder.
+     *
+     * All of the bits of this PCE must be read even if this PCE will not
+     * be used. They are read into a temporary PCE, then later it is decided
+     * whether to keep this PCE.
+     *
+     * To allow quick removal of the fields from the ProgConfig structure
+     * that will probably not be used at a later date,
+     * while still advancing the bitstream pointer,the return value of
+     * getbits is saved into a temporary variable, then transfered to
+     * the structure item.
+     */
+    tag =
+        get9_n_lessbits(
+            LEN_TAG,
+            pInputStream);
+
+    pScratchPCE->profile =
+        get9_n_lessbits(
+            LEN_PROFILE,
+            pInputStream);
+
+    pScratchPCE->sampling_rate_idx =
+        get9_n_lessbits(
+            LEN_SAMP_IDX,
+            pInputStream);
+
+    if (!pVars->adif_test && pScratchPCE->sampling_rate_idx != pVars->prog_config.sampling_rate_idx)
+    {
+        /* rewind the pointer as implicit channel configuration maybe the case */
+        pInputStream->usedBits -= (LEN_TAG + LEN_PROFILE + LEN_SAMP_IDX);
+
+        return (1); /*  mismatch cannot happen */
+    }
+
+
+    /*
+     * Retrieve the number of element lists for each of
+     * front, side, back, lfe, data, and coupling.
+     *
+     * For two-channel stereo or mono, only the data in the front needs
+     * to be saved. However, ALL fields need to be skipped over in some
+     * fashion. Also, the number of elements needs to be temporarily saved
+     * to call get_ele_list(). If that function was changed to pass in
+     * the number of points to be read, the memory set aside inside the
+     * ProgConfig structure could be removed.
+     */
+
+    /*
+     * The next six function calls could be combined into one, then use
+     * shifts and masks to retrieve the individual fields.
+     */
+    temp =
+        get9_n_lessbits(
+            LEN_NUM_ELE,
+            pInputStream);
+
+    pScratchPCE->front.num_ele = temp;
+
+    /* Needed only to read in the element list. */
+    temp =
+        get9_n_lessbits(
+            LEN_NUM_ELE,
+            pInputStream);
+
+    pScratchPCE->side.num_ele = temp;
+
+    /* Needed only to read in the element list. */
+    temp =
+        get9_n_lessbits(
+            LEN_NUM_ELE,
+            pInputStream);
+
+    pScratchPCE->back.num_ele = temp;
+
+    /* Needed only to read in the element list. */
+    temp =
+        get9_n_lessbits(
+            LEN_NUM_LFE,
+            pInputStream);
+
+    pScratchPCE->lfe.num_ele = temp;
+
+    /* Needed only to read in the element list. */
+    temp =
+        get9_n_lessbits(
+            LEN_NUM_DAT,
+            pInputStream);
+    pScratchPCE->data.num_ele = temp;
+
+    /* Needed only to read in the element list. */
+    temp =
+        get9_n_lessbits(
+            LEN_NUM_CCE,
+            pInputStream);
+
+    pScratchPCE->coupling.num_ele = temp;
+
+    /*
+     * Read in mix down data.
+     *
+     * Whether these fields can be removed and have proper operation
+     * will be determined at a later date.
+     */
+
+    /* Read presence of mono_mix */
+    flag =
+        get1bits(/*            LEN_MIX_PRES,*/
+            pInputStream);
+
+    pScratchPCE->mono_mix.present = flag;
+
+    if (flag != FALSE)
+    {
+        temp =
+            get9_n_lessbits(
+                LEN_TAG,
+                pInputStream);
+
+        pScratchPCE->mono_mix.ele_tag = temp;
+
+    } /* end if (flag != FALSE) */
+
+    /* Read presence of stereo mix */
+    flag =
+        get1bits(/*            LEN_MIX_PRES,*/
+            pInputStream);
+
+    pScratchPCE->stereo_mix.present = flag;
+
+    if (flag != FALSE)
+    {
+        temp =
+            get9_n_lessbits(
+                LEN_TAG,
+                pInputStream);
+
+        pScratchPCE->stereo_mix.ele_tag = temp;
+
+    } /* end if (flag != FALSE) */
+
+    /* Read presence of matrix mix */
+    flag =
+        get1bits(/*            LEN_MIX_PRES,*/
+            pInputStream);
+
+    pScratchPCE->matrix_mix.present = flag;
+
+    if (flag != FALSE)
+    {
+        temp =
+            get9_n_lessbits(
+                LEN_MMIX_IDX,
+                pInputStream);
+
+        pScratchPCE->matrix_mix.ele_tag = temp;
+
+        temp =
+            get1bits(/*                LEN_PSUR_ENAB,*/
+                pInputStream);
+
+        pScratchPCE->matrix_mix.pseudo_enab = temp;
+
+    } /* end if (flag != FALSE) */
+
+    /*
+     * Get each of the element lists. Only the front information will be
+     * used for the PV decoder, but the usedBits field of pInputStream must
+     * be advanced appropriately.
+     *
+     * This could be optimized by advancing the bit stream for the
+     * elements that do not need to be read.
+     */
+    get_ele_list(
+        &pScratchPCE->front,
+        pInputStream,
+        TRUE);
+
+    get_ele_list(
+        &pScratchPCE->side,
+        pInputStream,
+        TRUE);
+
+    get_ele_list(
+        &pScratchPCE->back,
+        pInputStream,
+        TRUE);
+
+    get_ele_list(
+        &pScratchPCE->lfe,
+        pInputStream,
+        FALSE);
+
+    get_ele_list(
+        &pScratchPCE->data,
+        pInputStream,
+        FALSE);
+
+    get_ele_list(
+        &pScratchPCE->coupling,
+        pInputStream,
+        TRUE);
+
+    /*
+     * The standard requests a byte alignment before reading in the
+     * comment. This can be done because LEN_COMMENT_BYTES == 8.
+     */
+    byte_align(pInputStream);
+
+    numChars =
+        get9_n_lessbits(
+            LEN_COMMENT_BYTES, pInputStream);
+
+    /*
+     * Ignore the comment - it requires 65 bytes to store (or worse on DSP).
+     * If this field is restored, make sure to append a trailing '\0'
+     */
+    for (i = numChars; i > 0; i--)
+    {
+        pScratchPCE->comments[i] = (Char) get9_n_lessbits(LEN_BYTE,
+                                   pInputStream);
+
+    } /* end for */
+
+    if (pVars->current_program < 0)
+    {
+        /*
+         * If this is the first PCE, it becomes the current, regardless of
+         * its tag number.
+         */
+        pVars->current_program = tag;
+
+    } /* end if (pVars->current_program < 0) */
+
+
+    if (tag == (UInt)pVars->current_program)
+    {
+        /*
+         * This branch is reached under two conditions:
+         * 1) This is the first PCE found, it was selected in the above if
+         *    block. In all encoders found thus far, the tag value has been
+         *    zero.
+         * 2) A PCE has been sent by the encoder with a tag that matches the
+         *    the first one sent. It will then be re-read. No encoder found
+         *    thus far re-sends a PCE, when looking at ADIF files.
+         *
+         * Regardless, the temporary PCE will now be copied into the
+         * the one official program configuration.
+         */
+        pv_memcpy(
+            &pVars->prog_config,
+            pScratchPCE,
+            sizeof(ProgConfig));
+
+        /* enter configuration into MC_Info structure */
+        status =
+            set_mc_info(
+                &pVars->mc_info,
+                (tMP4AudioObjectType)(pVars->prog_config.profile + 1),
+                pVars->prog_config.sampling_rate_idx,
+                pVars->prog_config.front.ele_tag[0],
+                pVars->prog_config.front.ele_is_cpe[0],
+                pVars->winmap,
+                pVars->SFBWidth128);
+
+    } /* end if (tag == pVars->current_program) */
+
+    return (status);
+}
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp
index 2b516fc..92640ed 100644
--- a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getactualaacconfig.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@
  * -------------------------------------------------------------------
  */
 /*
+------------------------------------------------------------------------------
+
+
 
  Pathname: codecs/audio/aac/c/src/getactualAacConfig
 
@@ -255,6 +258,8 @@
          * Buffer is not overrun, then
          * decode the AudioSpecificConfig() structure
          */
+        pVars->aacConfigUtilityEnabled = true;  /* set aac utility mode */
+
         status = get_audio_specific_config(pVars);
 
     }
@@ -269,7 +274,18 @@
 
     *NumChannels = pVars->mc_info.nch;
 
-    *aAudioObjectType = pVars->mc_info.audioObjectType;
+    /*
+     *  Set the audio object type to the extended type, only if this is different
+     *  from the baseline object type (this only applies to explicit signaling)
+     */
+    if (pVars->mc_info.audioObjectType != pVars->mc_info.ExtendedAudioObjectType)
+    {
+        *aAudioObjectType = pVars->mc_info.ExtendedAudioObjectType;
+    }
+    else
+    {
+        *aAudioObjectType = pVars->mc_info.audioObjectType;
+    }
 
     /*
      *  Set parameters  based on the explicit information from the
@@ -284,7 +300,6 @@
         }
     }
 
-
     pVars->status = status;
 
     /*
@@ -296,11 +311,9 @@
         pMem = NULL;
     }
 
-    if (iAACDecExt)
-    {
-        OSCL_DELETE(iAACDecExt);
-        iAACDecExt = NULL;
-    }
+
+    OSCL_DELETE(iAACDecExt);
+    iAACDecExt = NULL;
 
     return status;
 }
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getgroup.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getgroup.cpp
new file mode 100644
index 0000000..2809fbb
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/getgroup.cpp
@@ -0,0 +1,255 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: getgroup.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Modified from original shareware code
+
+ Description:  Modified to pass variables by reference to eliminate use
+               of global variables.
+
+ Description: (1) Modified to bring code in-line with PV standards
+              (2) Eliminated if(first_short) statement, move for-loop
+                  inside if statement
+              (3) Modified UChar -> Int on data types of group
+
+ Description: Replace some instances of getbits to get9_n_lessbits
+			  when the number of bits read is 9 or less.
+
+ Who:                       Date: MM/DD/YYYY
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pInputStream = pointer to structure that holds input bitstream
+                   information. Type BITS
+
+    group[]     = array that holds the index of the first window in each
+                  group. Type Int
+
+ Local Stores/Buffers/Pointers Needed:
+    None
+
+ Global Stores/Buffers/Pointers Needed:
+    None
+
+ Outputs:
+    None
+
+ Pointers and Buffers Modified:
+    group   contains the index of first windows in each group
+
+ Local Stores Modified:
+    None
+
+ Global Stores Modified:
+    None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function reads the window grouping information associated with an
+ Individual Channel Stream (ICS). If the window sequence is
+ EIGHT_SHORT_SEQUENCE, scalefactor grouping information is transmitted. If a
+ set of short windows form a group then they share scalefactors, intensity
+ positions and PNS information. The first short window is always a new group
+ so no grouping bit is transmitted. Subsequent short windows are in the same
+ group if the associated grouping bit is 1. A new group is started if the
+ associated grouping bit is 0.
+ The pointer pGroup points to an array that stores the first window index
+ of next group. For example, if the window grouping is:
+
+ window index:    |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
+ grouping    :    |<-   0   ->|  1  |<-    2        ->|<-   3   ->|
+
+ Then:
+
+    group[]  :    |     2     |  3  |        6        |     8     |
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+ This function should replace the contents of the array pointed to by pGroup
+ with the first window indexes of groups starting from the second group.
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+ (2) ISO/IEC 14496-3: 1999(E)
+    Subpart 4
+                    p16 (Table 4.4.6)
+                    p55 (Recovering ics_info)
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    IF (pFrameInfo->coef_per_win[0] > SN2)
+
+        *pGroup++ = 1;
+        *pGroup   = 1;
+
+    ELSE
+
+        FOR (win = 1; win < pFrameInfo->num_win; win++)
+
+            IF (getbits(1,pInputStream) == 0)
+
+                *pGroup++ = win;
+
+            ENDIF
+
+        ENDFOR (win)
+
+        *pGroup = win;
+
+    ENDIF(pFrameInfo)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include    "pv_audio_type_defs.h"
+#include    "huffman.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define     SEVEN   7
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+void getgroup(
+    Int         group[],
+    BITS        *pInputStream)
+{
+    Int      win;
+    Int     *pGroup;
+    UInt     mask;
+    UInt     groupBits;
+
+    pGroup      = group;
+
+    mask        = 0x40;
+
+    /* only short-window sequences are grouped!
+     * first short window is always a new group,
+     * start reading bitstream from the second
+     * window, a new group is indicated by an
+     * "0" bit in the input stream
+     */
+    groupBits =
+        get9_n_lessbits(
+            SEVEN,
+            pInputStream);
+
+    for (win = 1; win < NUM_SHORT_WINDOWS; win++)
+    {
+        if ((groupBits & mask) == 0)
+        {
+            *pGroup++ = win;
+
+        } /* if (groupBits) */
+
+        mask >>= 1;
+
+    } /* for (win) */
+
+    *pGroup = win;
+
+} /* getgroup */
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/infoinit.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/infoinit.cpp
new file mode 100644
index 0000000..7bdcdcd
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/infoinit.cpp
@@ -0,0 +1,355 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: infoinit.c
+
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Modified from original shareware code
+
+ Description:  Modified to pass variables by reference to eliminate use
+               of global variables.
+
+ Description:  Pass eight_short_info and the array 'sfbwidth128'.
+               Change function arguments' names for clarity
+
+ Description:  move sfb definitions to "sfb.h", and "sfb.c", eliminated
+               the function "huffbookinit.c"
+
+ Description:  Remove initialization of the never used array,
+               pFrameInfo->group_offs
+
+ Description:
+ (1) Changed "stdinc.h" to <stdlib.h> - this avoids linking in the math
+ library and stdio.h.  (All for just defining the NULL pointer macro)
+
+ (2) Updated copyright header.
+
+ Description: Updated the SW template to include the full pathname to the
+ source file and a slightly modified copyright header.
+
+ Description: Addresses of constant vectors are now found by means of a
+              switch statement, this solve linking problem when using the
+              /ropi option (Read-only position independent) for some
+              compilers
+
+ Who:                               Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pSi              = pointer to sampling rate info
+    ppWin_seq_info   = pointer array to window sequence Info struct
+    pSfbwidth128     = pointer to sfb bandwidth array of short window
+
+ Local Stores/Buffers/Pointers Needed:
+
+ Global Stores/Buffers/Pointers Needed:
+
+ Outputs:
+
+ Pointers and Buffers Modified:
+
+    ppWin_seq_info[ONLY_LONG_WINDOW]{all structure members} = setup values
+    ppWin_seq_info[EIGHT_SHORT_WINDOW]{all structure members} = setup values
+
+ Local Stores Modified:
+
+ Global Stores Modified:
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function sets the values of 'Info' structure for blocks containing long
+ and short window sequences, the following structures are being set:
+
+ win_seq_info[ONLY_LONG_WINDOW], win_seq_info[EIGHT_SHORT_WINDOW],
+ only_long_info and eight_short_info
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+ (2) ISO/IEC 14496-3: 1999(E)
+    Subpart 4       p66     (sfb tables)
+                    p111    (4.6.10)
+                    p200    (Annex 4.B.5)
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    pFrameInfo  =   pointer to only_long_info;
+    win_seq_info[ONLY_LONG_WINDOW]  =   pFrameInfo;
+    pFrameInfo{all structure members} = setup values;
+
+
+    pFrameInfo  =   pointer to eight_short_info;
+    win_seq_info[EIGHT_SHORT_WINDOW]  =   pFrameInfo;
+    pFrameInfo{all structure.members} =   setup values;
+
+
+    FOR (window_seq = 0; window_seq < NUM_WIN_SEQ; win_seq++)
+
+        win_seq_info[window_seq].members = setup values;
+
+    ENDFOR
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE:
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES:
+
+------------------------------------------------------------------------------
+*/
+
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include    "pv_audio_type_defs.h"
+#include    "s_sr_info.h"
+#include    "s_frameinfo.h"
+#include    "e_blockswitching.h"
+#include    "e_huffmanconst.h"
+#include    "sfb.h"
+#include    "huffman.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+Int infoinit(
+    const Int samp_rate_idx,
+    FrameInfo   **ppWin_seq_info,
+    Int    *pSfbwidth128)
+
+{
+    /*----------------------------------------------------------------------------
+    ; Define all local variables
+    ----------------------------------------------------------------------------*/
+
+    Int     i;
+    Int     sfb_idx, sfb_sbk;
+    Int     bins_sbk;
+    Int     win_seq;
+    Int     start_idx, end_idx;
+    Int     nsfb_short;
+    Int16   *sfbands;
+    FrameInfo    *pFrameInfo;
+
+    const SR_Info *pSi = &(samp_rate_info[samp_rate_idx]);
+
+    const Int16 * pt_SFbands1024 = NULL;
+    const Int16 * pt_SFbands128  = NULL;
+
+    /*----------------------------------------------------------------------------
+    ; Function body here
+    ----------------------------------------------------------------------------*/
+
+    switch (pSi->samp_rate)
+    {
+        case 96000:
+        case 88200:
+            pt_SFbands1024  = sfb_96_1024;
+            pt_SFbands128   = sfb_64_128;  /* equal to table sfb_96_128, (eliminated) */
+            break;
+        case 64000:
+            pt_SFbands1024  = sfb_64_1024;
+            pt_SFbands128   = sfb_64_128;
+            break;
+        case 48000:
+        case 44100:
+            pt_SFbands1024  = sfb_48_1024;
+            pt_SFbands128   = sfb_48_128;
+            break;
+        case 32000:
+            pt_SFbands1024  = sfb_32_1024;
+            pt_SFbands128   = sfb_48_128;
+            break;
+        case 24000:
+        case 22050:
+            pt_SFbands1024  = sfb_24_1024;
+            pt_SFbands128   = sfb_24_128;
+            break;
+        case 16000:
+        case 12000:
+        case 11025:
+            pt_SFbands1024  = sfb_16_1024;
+            pt_SFbands128   = sfb_16_128;
+            break;
+        case 8000:
+            pt_SFbands1024  = sfb_8_1024;
+            pt_SFbands128   = sfb_8_128;
+            break;
+        default:
+            // sampling rate not supported
+            return -1;
+    }
+
+    /* long block info */
+
+    pFrameInfo = ppWin_seq_info[ONLY_LONG_WINDOW];
+    pFrameInfo->islong               = 1;
+    pFrameInfo->num_win              = 1;
+    pFrameInfo->coef_per_frame       = LN2; /* = 1024 */
+
+    pFrameInfo->sfb_per_win[0]  = pSi->nsfb1024;
+    pFrameInfo->sectbits[0]     = LONG_SECT_BITS;
+    pFrameInfo->win_sfb_top[0]  = (Int16 *)pt_SFbands1024;
+
+    pFrameInfo->sfb_width_128 = NULL; /* no short block sfb */
+    pFrameInfo->num_groups    = 1; /* long block, one group */
+    pFrameInfo->group_len[0]  = 1; /* only one window */
+
+    /* short block info */
+    pFrameInfo = ppWin_seq_info[EIGHT_SHORT_WINDOW];
+    pFrameInfo->islong                  = 0;
+    pFrameInfo->num_win                 = NSHORT;
+    pFrameInfo->coef_per_frame          = LN2;
+
+    for (i = 0; i < pFrameInfo->num_win; i++)
+    {
+        pFrameInfo->sfb_per_win[i] = pSi->nsfb128;
+        pFrameInfo->sectbits[i]    = SHORT_SECT_BITS;
+        pFrameInfo->win_sfb_top[i] = (Int16 *)pt_SFbands128;
+    }
+
+    /* construct sfb width table */
+    pFrameInfo->sfb_width_128 = pSfbwidth128;
+    for (i = 0, start_idx = 0, nsfb_short = pSi->nsfb128; i < nsfb_short; i++)
+    {
+        end_idx = pt_SFbands128[i];
+        pSfbwidth128[i] = end_idx - start_idx;
+        start_idx = end_idx;
+    }
+
+
+    /* common to long and short */
+    for (win_seq = 0; win_seq < NUM_WIN_SEQ; win_seq++)
+    {
+
+        if (ppWin_seq_info[win_seq] != NULL)
+        {
+            pFrameInfo                 = ppWin_seq_info[win_seq];
+            pFrameInfo->sfb_per_frame  = 0;
+            sfb_sbk                    = 0;
+            bins_sbk                   = 0;
+
+            for (i = 0; i < pFrameInfo->num_win; i++)
+            {
+
+                /* compute coef_per_win */
+                pFrameInfo->coef_per_win[i] =
+                    pFrameInfo->coef_per_frame / pFrameInfo->num_win;
+
+                /* compute sfb_per_frame */
+                pFrameInfo->sfb_per_frame += pFrameInfo->sfb_per_win[i];
+
+                /* construct default (non-interleaved) bk_sfb_top[] */
+                sfbands = pFrameInfo->win_sfb_top[i];
+                for (sfb_idx = 0; sfb_idx < pFrameInfo->sfb_per_win[i];
+                        sfb_idx++)
+                {
+                    pFrameInfo->frame_sfb_top[sfb_idx+sfb_sbk] =
+                        sfbands[sfb_idx] + bins_sbk;
+                }
+
+                bins_sbk += pFrameInfo->coef_per_win[i];
+                sfb_sbk  += pFrameInfo->sfb_per_win[i];
+            } /* for i = sbk ends */
+        }
+
+    } /* for win_seq ends */
+
+    return SUCCESS;
+
+} /* infoinit */
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/lt_decode.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/lt_decode.cpp
new file mode 100644
index 0000000..f521430
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/lt_decode.cpp
@@ -0,0 +1,507 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: lt_decode.c
+
+
+------------------------------------------------------------------------------
+
+ REVISION HISTORY
+
+ Description:  Modified from original shareware code
+
+ Description:  Modified to pass variables by reference to eliminate use
+               of global variables.
+
+ Description:  First round of optimizations.
+
+ Description:  pInputStream is now the 2nd parameter to this function.
+
+ Description:  Changed to work with MT's new get_ics_info.c function, which
+ only calls lt_decode if LTP is enabled.  This removes one grab from the
+ bitstream and one "if" from this code.  Also, changed setting of weight.
+ Now, rather than setting the actual weight, I only set the index into
+ a table in this function.
+
+ Description: Replace some instances of getbits to get9_n_lessbits
+			  when the number of bits read is 9 or less and get1bits
+			  when only 1 bit is read.
+
+ Who:                                   Date:
+ Description:
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    win_type        Type of window (SHORT or LONG)
+                    [WINDOW_TYPE]
+
+    max_sfb         Maximum number of active scalefactor bands
+                    [Int]
+
+    pLt_pred        Pointer to structure containing information for
+                    long-term prediction.
+                    [LT_PRED_STATUS *]
+
+    pInputStream    Pointer to structure containing bitstream
+                    information.
+                    [BITS *]
+
+ Local Stores/Buffers/Pointers Needed:
+    None
+
+ Global Stores/Buffers/Pointers Needed:
+    None
+
+ Outputs:
+    None
+
+ Pointers and Buffers Modified:
+    pLt_pred->weight_index - updated with index into weight table for LTP.
+
+ Local Stores Modified:
+    None
+
+ Global Stores Modified:
+    None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function decodes the bitstream elements for long term prediction
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by Nokia
+   in the course of development of the MPEG-2 AAC/MPEG-4 Audio standard
+   ISO/IEC13818-7, 14496-1, 2 and 3.  This software module is an implementation
+   of a part of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
+   MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the
+   MPEG-2aac/MPEG-4 Audio standards free license to this software module or
+   modifications thereof for use in hardware or software products claiming
+   conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those intending to
+   use this software module in hardware or software products are advised that
+   this use may infringe existing patents. The original developer of this
+   software module, the subsequent editors and their companies, and ISO/IEC
+   have no liability for use of this software module or modifications thereof
+   in an implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
+   Audio conforming products. The original developer retains full right to use
+   the code for the developer's own purpose, assign or donate the code to a
+   third party and to inhibit third party from using the code for non
+   MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
+   must be included in all copies or derivative works."
+   Copyright (c)1997.
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    pDelay[0] = (Int) getbits(
+                        LEN_LTP_LAG,
+                        pInputStream);
+
+    temp_reg  = (Int) getbits(
+                        LEN_LTP_COEF,
+                        pInputStream);
+
+    pLt_pred->weight = codebook[temp_reg];
+
+    last_band = max_sfb;
+
+    IF (win_type != EIGHT_SHORT_SEQUENCE)
+
+        IF (last_band > MAX_LT_PRED_LONG_SFB)
+
+            last_band = MAX_LT_PRED_LONG_SFB;
+
+        ENDIF
+
+        FOR (m = last_band; m > 0; m--)
+
+            *(pSfbPredictionUsed++) = (Int) getbits(
+                                               LEN_LTP_LONG_USED,
+                                               pInputStream);
+        ENDFOR
+
+        FOR (m = (max_sfb - last_band); m > 0; m--)
+
+            *(pSfbPredictionUsed++) = 0;
+
+        ENDFOR
+
+    ELSE
+
+        IF (last_band > MAX_LT_PRED_SHORT_SFB)
+
+            last_band = MAX_LT_PRED_SHORT_SFB;
+
+        ENDIF
+
+        prev_subblock = pDelay[0];
+
+        pWinPredictionUsed++;
+
+        pTempPtr = &pSfbPredictionUsed[0];
+
+        FOR (m = NUM_SHORT_WINDOWS; m > 0;)
+
+            m--;
+            temp_reg = (Int) getbits(
+                                LEN_LTP_SHORT_USED,
+                                pInputStream);
+
+            *(pWinPredictionUsed++) = temp_reg;
+
+            IF (temp_reg != FALSE)
+            {
+                *(pDelay++) = prev_subblock;
+
+                FOR (k = last_band; k > 0; k--)
+                {
+                    *(pTempPtr++) = 1;
+                }
+                break;
+            ELSE
+            {
+                pDelay++;
+                pTempPtr += last_band;
+            }
+
+        ENDFOR (m = NUM_SHORT_WINDOWS; m > 0;)
+
+        prev_subblock += LTP_LAG_OFFSET;
+
+        FOR (; m > 0; m--)
+
+            temp_reg = (Int) getbits (
+                                LEN_LTP_SHORT_USED,
+                                pInputStream);
+
+            *(pWinPredictionUsed++) = temp_reg;
+
+            IF (temp_reg != FALSE)
+
+                temp_reg = (Int) getbits(
+                                    LEN_LTP_SHORT_LAG_PRESENT,
+                                    pInputStream);
+                IF (temp_reg != 0)
+
+                    temp_reg  = (Int) getbits(
+                                         LEN_LTP_SHORT_LAG,
+                                         pInputStream);
+
+                    *(pDelay++) = prev_subblock - temp_reg;
+
+                ELSE
+
+                    *(pDelay++) = prev_subblock - LTP_LAG_OFFSET;
+
+                ENDIF
+
+                FOR (k = last_band; k > 0; k--)
+                    *(pTempPtr++) = 1;
+                ENDFOR
+
+            ELSE
+
+                pDelay++;
+                pTempPtr += last_band;
+
+            ENDIF
+
+        ENDFOR (; m > 0; m--)
+
+    ENDIF (win_type != EIGHT_SHORT_SEQUENCE)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_audio_type_defs.h"
+#include "lt_decode.h"
+#include "ltp_common_internal.h"
+#include "window_block_fxp.h"
+#include "e_window_sequence.h"
+#include "s_lt_pred_status.h"
+#include "s_bits.h"
+#include "ibstream.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+void lt_decode(
+    const WINDOW_SEQUENCE  win_type,
+    BITS            *pInputStream,
+    const Int              max_sfb,
+    LT_PRED_STATUS  *pLt_pred)
+{
+    Int wnd_num;
+    Int k;
+    Int last_band;
+    Int prev_subblock;
+    Int prev_subblock_nonzero;
+    Int temp_reg;
+
+    Bool *pWinPredictionUsed = pLt_pred->win_prediction_used;
+    Bool *pSfbPredictionUsed = pLt_pred->sfb_prediction_used;
+    Int  *pTempPtr;
+    Int  *pDelay = pLt_pred->delay;
+
+    pDelay[0] = (Int) get17_n_lessbits(
+                    LEN_LTP_LAG,  /* 11 bits */
+                    pInputStream);
+
+    pLt_pred->weight_index  = (Int) get9_n_lessbits(
+                                  LEN_LTP_COEF, /*  3 bits */
+                                  pInputStream);
+
+    last_band = max_sfb;
+
+    if (win_type != EIGHT_SHORT_SEQUENCE)
+    {
+
+        /* last_band = min(MAX_LT_PRED_LONG_SFB, max_sfb) MAX_SCFAC_BANDS */
+        if (last_band > MAX_LT_PRED_LONG_SFB)
+        {
+            last_band = MAX_LT_PRED_LONG_SFB;
+        }
+
+        for (k = last_band; k > 0; k--)
+        {
+            *(pSfbPredictionUsed++) = (Int) get1bits(pInputStream);
+        }
+
+        /*
+         * This is not a call to memset, because
+         * (max_sfb - last_band) should typically be a small value.
+         */
+        for (k = (max_sfb - last_band); k > 0; k--)
+        {
+            *(pSfbPredictionUsed++) = FALSE;
+        }
+    }
+    else /* (win_type == EIGHT_SHORT_SEQUENCE) */
+    {
+        /* last_band = min(MAX_LT_PRED_SHORT_SFB, max_sfb) */
+
+        if (last_band > MAX_LT_PRED_SHORT_SFB)
+        {
+            last_band = MAX_LT_PRED_SHORT_SFB;
+        }
+
+        /*
+         * The following two coding constructs are equivalent...
+         *
+         *  first_time == 1
+         *  for (wnd_num=NUM_SHORT_WINDOWS; wnd_num > 0; wnd_num--)
+         *  {
+         *     if (condition)
+         *     {
+         *       if (first_time == 1)
+         *       {
+         *           CODE SECTION A
+         *           first_time = 0;
+         *       }
+         *       else
+         *       {
+         *           CODE SECTION B
+         *       }
+         *     }
+         *  }
+         *
+         * -----------------------------------EQUIVALENT TO------------
+         *
+         *  wnd_num=NUM_SHORT_WINDOWS;
+         *
+         *  do
+         *  {
+         *     wnd_num--;
+         *     if (condition)
+         *     {
+         *         CODE SECTION A
+         *         break;
+         *     }
+         *  } while( wnd_num > 0)
+         *
+         *  while (wnd_num > 0)
+         *  {
+         *     if (condition)
+         *     {
+         *         CODE SECTION B
+         *     }
+         *     wnd_num--;
+         *  }
+         *
+         */
+
+        prev_subblock = pDelay[0];
+
+        pTempPtr = &pSfbPredictionUsed[0];
+
+        wnd_num = NUM_SHORT_WINDOWS;
+
+        prev_subblock_nonzero = prev_subblock;
+        prev_subblock += LTP_LAG_OFFSET;
+
+        do
+        {
+            /*
+             * Place decrement of wnd_num here, to insure
+             * that the decrement occurs before the
+             * break out of the do-while loop.
+             */
+            wnd_num--;
+
+            temp_reg = (Int) get1bits(pInputStream);
+
+            *(pWinPredictionUsed++) = temp_reg;
+
+            if (temp_reg != FALSE)
+            {
+                *(pDelay++) = prev_subblock_nonzero;
+
+                for (k = last_band; k > 0; k--)
+                {
+                    *(pTempPtr++) = TRUE;
+                }
+                for (k = (max_sfb - last_band); k > 0; k--)
+                {
+                    *(pTempPtr++) = FALSE;
+                }
+                break;
+
+            } /* if(pWinPredictionUsed) */
+            else
+            {
+                pDelay++;
+                pTempPtr += max_sfb;
+            }
+
+        }
+        while (wnd_num > 0);
+
+        /*
+         * This while loop picks up where the previous one left off.
+         * Notice that the code functions differently inside the loop
+         */
+
+        while (wnd_num > 0)
+        {
+            temp_reg = (Int) get1bits(pInputStream);
+
+            *(pWinPredictionUsed++) = temp_reg;
+
+            if (temp_reg != FALSE)
+            {
+                temp_reg = (Int) get1bits(pInputStream);
+                if (temp_reg != 0)
+                {
+                    temp_reg  = (Int) get9_n_lessbits(
+                                    LEN_LTP_SHORT_LAG,
+                                    pInputStream);
+
+                    *(pDelay++) = prev_subblock - temp_reg;
+                }
+                else
+                {
+                    *(pDelay++) = prev_subblock_nonzero;
+                }
+                for (k = last_band; k > 0; k--)
+                {
+                    *(pTempPtr++) = TRUE;
+                }
+                for (k = (max_sfb - last_band); k > 0; k--)
+                {
+                    *(pTempPtr++) = FALSE;
+                }
+
+            } /* if (temp_reg) */
+            else
+            {
+                pDelay++;
+                pTempPtr += max_sfb;
+            }
+
+            wnd_num--;
+
+        } /* while(wnd_num) */
+
+    } /* else (win_type == EIGHT_SHORT_SEQUENCE) */
+
+} /* lt_decode */
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecodergetmemrequirements.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecodergetmemrequirements.cpp
new file mode 100644
index 0000000..7cdecd0
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecodergetmemrequirements.cpp
@@ -0,0 +1,157 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: PVMP4AudioDecoderGetMemRequirements.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Copied from aac_decode_frame
+
+ Description: Cleaned up.
+
+ Description: (1) use UInt32 to replace size_t type
+              (2) memory of tDec_Int_File is splitted into 3 pieces,
+                  sizeof(tDec_Int_File) is only part of the total memory
+                  required. The additional memory required to decode per
+                  channel information is allocated by a DPI call outside this
+                  API
+
+ Who:                                   Date: MM/DD/YYYY
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs: None
+
+ Local Stores/Buffers/Pointers Needed: None
+
+ Global Stores/Buffers/Pointers Needed: None
+
+ Outputs:
+    size = amount of memory needed to be allocated by the calling
+        environment.
+
+ Pointers and Buffers Modified: None
+
+ Local Stores Modified: None
+
+ Global Stores Modified: None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function returns the amount of internal memory needed by the library.
+ Presently this is a constant value, but could later be more sophisticated
+ by taking into account mono or stereo, and whether LTP is to be used.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    size = sizeof(tDec_Int_File);
+
+ RETURN (size)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pv_audio_type_defs.h"
+#include "s_tdec_int_file.h"
+#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL VARIABLE DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void)
+{
+    UInt32 size;
+
+    size = (UInt32) sizeof(tDec_Int_File);
+
+    return (size);
+
+} /* PVMP4AudioDecoderGetMemRequirements() */
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecoderinitlibrary.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecoderinitlibrary.cpp
new file mode 100644
index 0000000..146ba0f
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/pvmp4audiodecoderinitlibrary.cpp
@@ -0,0 +1,418 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: PVMP4AudioDecoderInitLibrary.c
+
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:  Copied from aac_decode_frame
+
+ Description:  Clean up.
+
+ Description:  Update per review comments
+
+ Description:  Add frame_length, fix mistake in pseudo-code.
+               Change frame_length to frameLength, to matcht the API,
+               look more professional, etc.
+
+ Description:
+ (1) Added #include of "e_ProgConfigConst.h"
+     Previously, this function was relying on another include file
+     to include "e_ProgConfigConst.h"
+
+ (2) Updated the copyright header.
+
+ Description:
+ (1) Modified to initialize pointers for shared memory techniques.
+
+ Description: Since memory will be allocated continuously, it is initialized
+              in one spot
+
+ Description: Added field aacPlusUpsamplingFactor (default == 1) to have a
+              common interface for all AAC variations
+
+ Description: Added PVMP4AudioDecoderDisableAacPlus to disable sbr decoding
+
+ Who:                                   Date: MM/DD/YYYY
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pExt = pointer to the external application-program interface (API)
+           structure that a client program uses to communicate information
+           with this library. Among the items in this structure is a pointer
+           to the input and output buffers, data for handling the input buffer
+           and output information. Look in PVMP4AudioDecoder_API.h for all the
+           fields to this structure. Data type pointer to a
+           tPVMP4AudioDecoderExternal structure.
+
+   pMem =  pointer to allocated memory, of the size returned by the function
+           PVMP4AudioDecoderGetMemRequirements. This is a void pointer for
+           two reasons:
+           1) So the external program does not need all of the header files
+              for all of the fields in the structure tDec_Int_File
+           2) To hide data and the implementation of the program. Even knowing
+              how data is stored can help in reverse engineering software.
+
+ Local Stores/Buffers/Pointers Needed: None
+
+ Global Stores/Buffers/Pointers Needed: None
+
+ Outputs:
+    status = 0 (SUCCESS). Presently there is no error checking in this
+    function.
+
+ Pointers and Buffers Modified: None
+
+ Local Stores Modified: None
+
+ Global Stores Modified: None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Initializes the internal memory for the MP4 Audio Decoder library.
+ Also sets relevant values for the external interface structure, clears
+ the bit rate, channel count, sampling rate, and number of used buffer
+ elements.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    pVars = pMem;
+
+    CALL pv_memset(
+           to = pVars,
+           c  = 0,
+           n  = sizeof(tDec_Int_File))
+    MODIFYING(*pVars = 0)
+    RETURNING(nothing)
+
+    pVars->current_program = -1
+    pVars->mc_info.sampling_rate_idx = Fs_44
+    pVars->frameLength = LONG_WINDOW
+
+
+    pVars->winmap[ONLY_LONG_SEQUENCE]   = &pVars->longFrameInfo;
+    pVars->winmap[LONG_START_SEQUENCE]  = &pVars->longFrameInfo;
+    pVars->winmap[EIGHT_SHORT_SEQUENCE] = &pVars->shortFrameInfo;
+    pVars->winmap[LONG_STOP_SEQUENCE]   = &pVars->longFrameInfo;
+
+    CALL infoinit(
+        samp_rate_indx = pVars->mc_info.sampling_rate_idx,
+        ppWin_seq_info = pVars->winmap,
+        pSfbwidth128   = pVars->SFBWidth128)
+    MODIFYING(ppWinSeq_info)
+    MODIFYING(pSfbwidth128)
+    RETURNING(nothing)
+
+    pExt->bitRate = 0;
+    pExt->encodedChannels = 0;
+    pExt->samplingRate = 0;
+    pExt->inputBufferUsedLength = 0;
+
+    MODIFY(pExt)
+    MODIFY(pMem)
+    RETURN(SUCCESS)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pv_audio_type_defs.h"
+#include "s_tdec_int_file.h"
+#include "e_progconfigconst.h"
+
+#include "huffman.h"               /* For the definition of infoinit        */
+#include "aac_mem_funcs.h"         /* For pv_memset                         */
+#include "pvmp4audiodecoder_api.h" /* Where this function is declared       */
+#include "s_tdec_int_chan.h"
+#include "sfb.h"                   /* samp_rate_info[] is declared here     */
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL VARIABLE DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary(
+    tPVMP4AudioDecoderExternal  *pExt,
+    void                        *pMem)
+{
+    tDec_Int_File *pVars;
+
+    pVars = (tDec_Int_File *)pMem;
+
+    /*
+     * Initialize all memory. The pointers to channel memory will be
+     * set to zero also.
+     */
+    pv_memset(
+        pVars,
+        0,
+        sizeof(tDec_Int_File));
+
+    /*
+     * Pick default values for the library.
+     */
+    pVars->perChan[0].fxpCoef = pVars->fxpCoef[0];
+    pVars->perChan[1].fxpCoef = pVars->fxpCoef[1];
+
+    /* Here, the "shared memory" pointer is set to point
+     * at the 1024th element of fxpCoef, because those spaces
+     * in memory are not used until the filterbank is called.
+     *
+     * Therefore, any variables that are only used before
+     * the filterbank can occupy this same space in memory.
+     */
+
+    pVars->perChan[0].pShareWfxpCoef = (per_chan_share_w_fxpCoef *)
+                                       & (pVars->perChan[0].fxpCoef[1024]);
+
+    pVars->perChan[1].pShareWfxpCoef = (per_chan_share_w_fxpCoef *)
+                                       & (pVars->perChan[1].fxpCoef[1024]);
+
+    /*
+     * This next line informs the function get_prog_config that no
+     * configuration has been found thus far, so it is a default
+     * configuration.
+     */
+
+    pVars->current_program = -1;
+    pVars->mc_info.sampling_rate_idx = Fs_44; /* Fs_44 = 4, 44.1kHz */
+
+    /*
+     * In the future, the frame length will change with MP4 file format.
+     * Presently this variable is used to simply the unit test for
+     * the function PVMP4AudioDecodeFrame() .. otherwise the test would
+     * have to pass around 1024 length arrays.
+     */
+    pVars->frameLength = LONG_WINDOW; /* 1024*/
+
+    /*
+     * The window types ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, and
+     * LONG_STOP_SEQUENCE share the same information. The only difference
+     * between the windows is accounted for in the "filterbank", in
+     * the function trans4m_freq_2_time_fxp()
+     */
+
+    pVars->winmap[ONLY_LONG_SEQUENCE]   /* 0 */ = &pVars->longFrameInfo;
+    pVars->winmap[LONG_START_SEQUENCE]  /* 1 */ = &pVars->longFrameInfo;
+    pVars->winmap[EIGHT_SHORT_SEQUENCE] /* 2 */ = &pVars->shortFrameInfo;
+    pVars->winmap[LONG_STOP_SEQUENCE]   /* 3 */ = &pVars->longFrameInfo;
+
+    infoinit(
+        pVars->mc_info.sampling_rate_idx,
+        (FrameInfo   **)pVars->winmap,
+        pVars->SFBWidth128);
+
+
+    /*
+     * Clear out external output values. These values are set later at the end
+     * of PVMP4AudioDecodeFrames()
+     */
+    pExt->bitRate = 0;
+    pExt->encodedChannels = 0;
+    pExt->samplingRate = 0;
+    pExt->aacPlusUpsamplingFactor = 1;  /*  Default for regular AAC */
+    pVars->aacPlusEnabled = pExt->aacPlusEnabled;
+
+
+#if defined(AAC_PLUS)
+    pVars->sbrDecoderData.setStreamType = 1;        /* Enable Lock for AAC stream type setting  */
+#endif
+
+    /*
+     * Initialize input buffer variable.
+     */
+
+    pExt->inputBufferUsedLength = 0;
+
+    return (MP4AUDEC_SUCCESS);
+
+}  /* PVMP4AudioDecoderInitLibrary */
+
+
+/*
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pExt = pointer to the external application-program interface (API)
+           structure that a client program uses to communicate information
+           with this library. Among the items in this structure is a pointer
+           to the input and output buffers, data for handling the input buffer
+           and output information. Look in PVMP4AudioDecoder_API.h for all the
+           fields to this structure. Data type pointer to a
+           tPVMP4AudioDecoderExternal structure.
+
+   pMem =  pointer to allocated memory, of the size returned by the function
+           PVMP4AudioDecoderGetMemRequirements. This is a void pointer for
+           two reasons:
+           1) So the external program does not need all of the header files
+              for all of the fields in the structure tDec_Int_File
+           2) To hide data and the implementation of the program. Even knowing
+              how data is stored can help in reverse engineering software.
+
+ Local Stores/Buffers/Pointers Needed: None
+
+ Global Stores/Buffers/Pointers Needed: None
+
+ Outputs:
+    status = 0 (SUCCESS). Presently there is no error checking in this
+    function.
+
+ Pointers and Buffers Modified: None
+
+ Local Stores Modified: None
+
+ Global Stores Modified: None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Disable SBR decoding functionality and set parameters accordingly
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
+OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus(
+    tPVMP4AudioDecoderExternal  *pExt,
+    void                        *pMem)
+{
+    tDec_Int_File *pVars;
+
+    pVars = (tDec_Int_File *)pMem;
+
+    if ((pVars->aacPlusEnabled == true) && (pExt->aacPlusEnabled == true))
+    {
+        // disable only when makes sense
+        pVars->aacPlusEnabled = false;
+        pExt->aacPlusEnabled = false;
+
+#if defined(AAC_PLUS)
+        pVars->mc_info.upsamplingFactor = 1;
+        pVars->mc_info.psPresentFlag  = 0;
+        pVars->mc_info.sbrPresentFlag = 0;
+        pVars->prog_config.sampling_rate_idx += 3;
+        pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
+        pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
+
+
+        pExt->samplingRate = samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate;
+        pExt->aacPlusUpsamplingFactor = 1;
+#endif
+    }
+}  /* PVMP4AudioDecoderDisableAacPlus */
+
+
+
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/set_mc_info.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/set_mc_info.cpp
new file mode 100644
index 0000000..5a11941
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/set_mc_info.cpp
@@ -0,0 +1,309 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: ./src/set_mc_info.c
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description: Modified per review comments
+
+ Description: Change audioObjectType from Int to enum types
+
+ Who:                               Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+    pMC_Info    = pointer to structure MC_Info that holds information of
+                  multiple channels' configurations
+                  Data type pointer to MC_Info
+
+    objectType  = variable that holds the Audio Object Type of current
+                  file/bitstream.
+                  Data type Int
+
+    sampling_rate_idx = variable that indicates the sampling rate of the
+                        source file being encoded
+                        Data Type Int
+
+    tag         = variable that stores the element instance tag of the
+                  first (front) channel element.
+                  Data type Int
+
+    is_cpe      = variable that indicates if a Channel Pair Element (CPE)
+                  or a Single Channel Element (SCE) is used.
+                  Data type Int (maybe Boolean)
+
+    pWinSeqInfo = array of pointers that points to structures holding
+                  frame information of long and short window sequences.
+                  Data type FrameInfo
+
+    pSfbwidth128 = array that will store the scalefactor bandwidth of
+                   short window sequence frame.
+                   Data type Int array
+
+ Local Stores/Buffers/Pointers Needed:
+    None
+
+ Global Stores/Buffers/Pointers Needed:
+    None
+
+ Outputs:
+    return SUCCESS
+
+ Pointers and Buffers Modified:
+    pMC_Info->nch           contains the number of channels depending
+                            upon if CPE or SCE is used
+    pMC_Info->objectType    contents updated with the decoded Audio
+                            Object Type
+
+    pMC_Info->ch_info.tag   contents updated with the value of decoded
+                            channel element tag
+
+    PMC_Info->ch_info.cpe   contents updated depending upon if CPE or
+                            SCE is used
+
+    pWinSeqInfo             contents updated by calling infoinit if
+                            sampling_rate_idx is different from
+                            previous value
+
+    pSfbWidth128            contents updated by calling infoinit if
+                            sampling_rate_idx is different from
+                            previous value
+
+ Local Stores Modified:
+    None
+
+ Global Stores Modified:
+    None
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function initializes the channel configuration information. The
+ structure MC_Info stores the number of channels, channel element tag.
+ If sampling rate index is different from the previous value,
+ The frame information will be updated by calling infoinit.c
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+ This function shall update the relevant information on channel configs
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) MPEG-2 NBC Audio Decoder
+   "This software module was originally developed by AT&T, Dolby
+   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
+   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
+   3. This software module is an implementation of a part of one or more
+   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
+   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
+   standards free license to this software module or modifications thereof
+   for use in hardware or software products claiming conformance to the
+   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
+   module in hardware or software products are advised that this use may
+   infringe existing patents. The original developer of this software
+   module and his/her company, the subsequent editors and their companies,
+   and ISO/IEC have no liability for use of this software module or
+   modifications thereof in an implementation. Copyright is not released
+   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
+   developer retains full right to use the code for his/her own purpose,
+   assign or donate the code to a third party and to inhibit third party
+   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
+   This copyright notice must be included in all copies or derivative
+   works."
+   Copyright(c)1996.
+
+  (2) ISO/IEC 14496-3: 1999(E)
+    Subpart 1   p20 Table 1.6.3
+    Subpart 4   p30 5.1.2.1
+    Subpart 4   p31 4.5.2.1.1
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+    pMC_Info->nch   = 0;
+
+    pMC_Info->profile = objectType;
+
+    IF (pMC_Info->sampling_rate_idx != sampling_rate_idx)
+    THEN
+        pMC_Info->sampling_rate_idx = sampling_rate_idx;
+
+        CALL infoinit(
+                samp_rate_idx = sampling_rate_idx
+                ppWin_seq_info= pWinSeqInfo
+                pSfbwidth128  = pSfbwidth128)
+        MODIFYING(pWinSeqInfo, pSfbwidth128)
+        RETURNING(None)
+    ENDIF
+
+    pCh_Info = &pMC_Info->ch_info[0];
+    pCh_Info->tag = tag;
+
+    IF (is_cpe == FALSE)
+    THEN
+        pCh_Info->cpe = FALSE;
+
+        pMC_Info->nch = 1;
+
+    ELSE
+        pCh_Info->cpe = TRUE;
+        pCh_Info = &pMC_Info->ch_info[1];
+        pCh_Info->tag = tag;
+        pCh_Info->cpe = TRUE;
+
+        pMC_Info->nch = 2;
+
+    ENDIF
+
+    RETURN(SUCCESS)
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include    "pv_audio_type_defs.h"
+#include    "set_mc_info.h"
+#include    "huffman.h"
+#include    "s_ch_info.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+Int set_mc_info(
+    MC_Info     *pMC_Info,
+    const tMP4AudioObjectType audioObjectType, /* used to be profile */
+    const Int    sampling_rate_idx,
+    const Int    tag,   /* always pass-in last element's value */
+    const Int    is_cpe,
+    FrameInfo   *pWinSeqInfo[],
+    Int          sfbwidth128[]
+)
+{
+    Ch_Info *pCh_Info; /*optional task: eliminate this structure */
+
+    /*
+     *   audioObjectType and sampling rate
+     *   re-configure if new sampling rate
+     *
+     */
+    pMC_Info->audioObjectType = audioObjectType;
+
+    if (pMC_Info->sampling_rate_idx != sampling_rate_idx)
+    {
+        pMC_Info->sampling_rate_idx = sampling_rate_idx;
+
+        Int status;
+        status = infoinit(sampling_rate_idx,
+                          pWinSeqInfo,
+                          sfbwidth128);
+        if (SUCCESS != status)
+        {
+            return 1;
+        }
+    }
+
+    /*
+     * first setup values for mono config, Single Channel Element (SCE)
+     * then if stereo, go inside if(is_cpe != FALSE) branch to setup
+     * values for stereo.
+     * set the channel counts
+     * save tag for left channel
+     */
+    pMC_Info->nch   = 1 + is_cpe;
+
+    pCh_Info = &pMC_Info->ch_info[0];
+    pCh_Info->tag = tag;
+    pCh_Info->cpe = is_cpe;
+
+    /* This if branch maybe deleted in the future */
+    if (is_cpe != FALSE)
+    {
+        /* Channel Pair Element (CPE) */
+        /* right channel*/
+        pCh_Info = &pMC_Info->ch_info[1];
+        pCh_Info->cpe = TRUE;
+
+    }
+
+    return(SUCCESS); /* possible future error checkings */
+}
diff --git a/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/sfb.cpp b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/sfb.cpp
new file mode 100644
index 0000000..f2d3a3e
--- /dev/null
+++ b/codecs_v2/audio/aac/dec/util/getactualaacconfig/src/sfb.cpp
@@ -0,0 +1,275 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+
+ Pathname: ./src/sfb.c
+
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description: created to define the scalefactor bands for all sampling rates
+
+ Description: Change short to Int16
+
+ Description: Modified structure to avoid assigning addresses to constant
+              tables. This solve linking problem when using the
+              /ropi option (Read-only position independent) for some
+              compilers
+              - Eliminated redundant vector sfb_96_128.
+              - Eliminated references to contant vector addresses in
+                samp_rate_info
+
+ Who:                              Date:
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+
+ Local Stores/Buffers/Pointers Needed:
+
+ Global Stores/Buffers/Pointers Needed:
+
+ Outputs:
+
+ Pointers and Buffers Modified:
+
+
+ Local Stores Modified:
+
+ Global Stores Modified:
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ This function defines the scalefactor bands for all sampling rates
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ (1) ISO/IEC 14496-3: 1999(E)
+    Subpart 4       p66     (sfb tables)
+                    p111    (4.6.10)
+                    p200    (Annex 4.B.5)
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+ RESOURCES USED
+   When the code is written for a specific target processor the
+     the resources used should be documented below.
+
+ STACK USAGE: [stack count for this module] + [variable to represent
+          stack usage for each subroutine called]
+
+     where: [stack usage variable] = stack usage for [subroutine
+         name] (see [filename].ext)
+
+ DATA MEMORY USED: x words
+
+ PROGRAM MEMORY USED: x words
+
+ CLOCK CYCLES: [cycle count equation for this module] + [variable
+           used to represent cycle count for each subroutine
+           called]
+
+     where: [cycle count variable] = cycle count for [subroutine
+        name] (see [filename].ext)
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include    "pv_audio_type_defs.h"
+#include    "sfb.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+const Int16 sfb_96_1024[] =
+{
+    4, 8, 12, 16, 20, 24, 28,
+    32, 36, 40, 44, 48, 52, 56,
+    64, 72, 80, 88, 96, 108, 120,
+    132, 144, 156, 172, 188, 212, 240,
+    276, 320, 384, 448, 512, 576, 640,
+    704, 768, 832, 896, 960, 1024
+};         /* 41 scfbands */
+
+const Int16 sfb_64_1024[] =
+{
+    4, 8, 12, 16, 20, 24, 28,
+    32, 36, 40, 44, 48, 52, 56,
+    64, 72, 80, 88, 100, 112, 124,
+    140, 156, 172, 192, 216, 240, 268,
+    304, 344, 384, 424, 464, 504, 544,
+    584, 624, 664, 704, 744, 784, 824,
+    864, 904, 944, 984, 1024
+};               /* 41 scfbands 47 */
+
+const Int16 sfb_64_128[] =
+{
+    4, 8, 12, 16, 20, 24, 32,
+    40, 48, 64, 92, 128
+};                   /* 12 scfbands */
+
+
+const Int16 sfb_48_1024[] =
+{
+    4,  8,  12, 16, 20, 24, 28,
+    32, 36, 40, 48, 56, 64, 72,
+    80, 88, 96, 108,    120,    132,    144,
+    160,    176,    196,    216,    240,    264,    292,
+    320,    352,    384,    416,    448,    480,    512,
+    544,    576,    608,    640,    672,    704,    736,
+    768,    800,    832,    864,    896,    928,    1024
+};
+/* 49  scfbands*/
+
+const Int16 sfb_48_128[] =
+{
+    4,  8,  12, 16, 20, 28, 36,
+    44, 56, 68, 80, 96, 112, 128
+};         /* 14 scfbands */
+
+const Int16 sfb_32_1024[] =
+{
+    4,  8,  12, 16, 20, 24, 28,
+    32, 36, 40, 48, 56, 64, 72,
+    80, 88, 96, 108,    120,    132,    144,
+    160,    176,    196,    216,    240,    264,    292,
+    320,    352,    384,    416,    448,    480,    512,
+    544,    576,    608,    640,    672,    704,    736,
+    768,    800,    832,    864,    896,    928,    960,
+    992,    1024
+};                         /* 51 scfbands */
+
+const Int16 sfb_24_1024[] =
+{
+    4, 8, 12, 16, 20, 24, 28,
+    32, 36, 40, 44, 52, 60, 68,
+    76, 84, 92, 100, 108, 116, 124,
+    136, 148, 160, 172, 188, 204, 220,
+    240, 260, 284, 308, 336, 364, 396,
+    432, 468, 508, 552, 600, 652, 704,
+    768, 832, 896, 960, 1024
+};              /* 47 scfbands */
+
+const Int16 sfb_24_128[] =
+{
+    4, 8, 12, 16, 20, 24, 28,
+    36, 44, 52, 64, 76, 92, 108,
+    128
+};                                   /* 15 scfbands */
+
+const Int16 sfb_16_1024[] =
+{
+    8, 16, 24, 32, 40, 48, 56,
+    64, 72, 80, 88, 100, 112, 124,
+    136, 148, 160, 172, 184, 196, 212,
+    228, 244, 260, 280, 300, 320, 344,
+    368, 396, 424, 456, 492, 532, 572,
+    616, 664, 716, 772, 832, 896, 960,
+    1024
+};                                  /* 43 scfbands */
+
+const Int16 sfb_16_128[] =
+{
+    4, 8, 12, 16, 20, 24, 28,
+    32, 40, 48, 60, 72, 88, 108,
+    128
+};                                   /* 15 scfbands */
+
+const Int16 sfb_8_1024[] =
+{
+    12, 24, 36, 48, 60, 72, 84,
+    96, 108, 120, 132, 144, 156, 172,
+    188, 204, 220, 236, 252, 268, 288,
+    308, 328, 348, 372, 396, 420, 448,
+    476, 508, 544, 580, 620, 664, 712,
+    764, 820, 880, 944, 1024
+};               /* 40 scfbands */
+
+const Int16 sfb_8_128[] =
+{
+    4, 8, 12, 16, 20, 24, 28,
+    36, 44, 52, 60, 72, 88, 108,
+    128
+};                                   /* 15 scfbands */
+
+const SR_Info samp_rate_info[12] =
+{
+    /* sampling_frequency, #long sfb, #short sfb */
+    /* samp_rate, nsfb1024, nsfb128 */
+    {96000, 41, 12},       /* 96000 */
+    {88200, 41, 12},       /* 88200 */
+    {64000, 47, 12},       /* 64000 */
+    {48000, 49, 14},       /* 48000 */
+    {44100, 49, 14},       /* 44100 */
+    {32000, 51, 14},       /* 32000 */
+    {24000, 47, 15},       /* 24000 */
+    {22050, 47, 15},       /* 22050 */
+    {16000, 43, 15},       /* 16000 */
+    {12000, 43, 15},       /* 12000 */
+    {11025, 43, 15},       /* 11025 */
+    { 8000, 40, 15},       /* 8000  */
+};
+
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk b/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
index 75dd548..b22b43a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
@@ -3,82 +3,85 @@
 
 LOCAL_SRC_FILES := \
 	src/add.cpp \
-	src/az_lsp.cpp \
-	src/bitno_tab.cpp \
-	src/bitreorder_tab.cpp \
-	src/bits2prm.cpp \
-	src/bytesused.cpp \
-	src/c2_9pf_tab.cpp \
-	src/copy.cpp \
-	src/div_32.cpp \
-	src/div_s.cpp \
-	src/extract_h.cpp \
-	src/extract_l.cpp \
-	src/gains_tbl.cpp \
-	src/gc_pred.cpp \
-	src/gmed_n.cpp \
-	src/grid_tbl.cpp \
-	src/gray_tbl.cpp \
-	src/int_lpc.cpp \
-	src/inv_sqrt.cpp \
-	src/inv_sqrt_tbl.cpp \
-	src/l_abs.cpp \
-	src/l_deposit_h.cpp \
-	src/l_deposit_l.cpp \
-	src/l_shr_r.cpp \
-	src/log2.cpp \
-	src/log2_norm.cpp \
-	src/log2_tbl.cpp \
-	src/lsfwt.cpp \
-	src/lsp.cpp \
-	src/lsp_az.cpp \
-	src/lsp_lsf.cpp \
-	src/lsp_lsf_tbl.cpp \
-	src/lsp_tab.cpp \
-	src/mult_r.cpp \
-	src/norm_l.cpp \
-	src/norm_s.cpp \
-	src/overflow_tbl.cpp \
-	src/ph_disp_tab.cpp \
-	src/pow2.cpp \
-	src/pow2_tbl.cpp \
-	src/pred_lt.cpp \
-	src/q_plsf.cpp \
-	src/q_plsf_3.cpp \
-	src/q_plsf_3_tbl.cpp \
-	src/q_plsf_5.cpp \
-	src/q_plsf_5_tbl.cpp \
-	src/qua_gain_tbl.cpp \
-	src/reorder.cpp \
-	src/residu.cpp \
-	src/round.cpp \
-	src/set_zero.cpp \
-	src/shr.cpp \
-	src/shr_r.cpp \
-	src/sqrt_l.cpp \
-	src/sqrt_l_tbl.cpp \
-	src/sub.cpp \
-	src/syn_filt.cpp \
-	src/vad1.cpp \
-	src/weight_a.cpp \
-	src/window_tab.cpp
-
+ 	src/az_lsp.cpp \
+ 	src/bitno_tab.cpp \
+ 	src/bitreorder_tab.cpp \
+ 	src/bits2prm.cpp \
+ 	src/bytesused.cpp \
+ 	src/c2_9pf_tab.cpp \
+ 	src/copy.cpp \
+ 	src/div_32.cpp \
+ 	src/div_s.cpp \
+ 	src/extract_h.cpp \
+ 	src/extract_l.cpp \
+ 	src/gains_tbl.cpp \
+ 	src/gc_pred.cpp \
+ 	src/gmed_n.cpp \
+ 	src/grid_tbl.cpp \
+ 	src/gray_tbl.cpp \
+ 	src/int_lpc.cpp \
+ 	src/inv_sqrt.cpp \
+ 	src/inv_sqrt_tbl.cpp \
+ 	src/l_abs.cpp \
+ 	src/l_deposit_h.cpp \
+ 	src/l_deposit_l.cpp \
+ 	src/l_shr_r.cpp \
+ 	src/log2.cpp \
+ 	src/log2_norm.cpp \
+ 	src/log2_tbl.cpp \
+ 	src/lsfwt.cpp \
+ 	src/lsp.cpp \
+ 	src/lsp_az.cpp \
+ 	src/lsp_lsf.cpp \
+ 	src/lsp_lsf_tbl.cpp \
+ 	src/lsp_tab.cpp \
+ 	src/mult_r.cpp \
+ 	src/norm_l.cpp \
+ 	src/norm_s.cpp \
+ 	src/overflow_tbl.cpp \
+ 	src/ph_disp_tab.cpp \
+ 	src/pow2.cpp \
+ 	src/pow2_tbl.cpp \
+ 	src/pred_lt.cpp \
+ 	src/q_plsf.cpp \
+ 	src/q_plsf_3.cpp \
+ 	src/q_plsf_3_tbl.cpp \
+ 	src/q_plsf_5.cpp \
+ 	src/q_plsf_5_tbl.cpp \
+ 	src/qua_gain_tbl.cpp \
+ 	src/reorder.cpp \
+ 	src/residu.cpp \
+ 	src/round.cpp \
+ 	src/set_zero.cpp \
+ 	src/shr.cpp \
+ 	src/shr_r.cpp \
+ 	src/sqrt_l.cpp \
+ 	src/sqrt_l_tbl.cpp \
+ 	src/sub.cpp \
+ 	src/syn_filt.cpp \
+ 	src/vad1.cpp \
+ 	src/weight_a.cpp \
+ 	src/window_tab.cpp
 
 
 LOCAL_MODULE := libpv_amr_nb_common_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/common/include \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/common/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
+ 	
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/build/make/local.mk b/codecs_v2/audio/gsm_amr/amr_nb/common/build/make/local.mk
new file mode 100644
index 0000000..12ea1a0
--- /dev/null
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/build/make/local.mk
@@ -0,0 +1,79 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv_amr_nb_common_lib
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := add.cpp \
+	az_lsp.cpp \
+	bitno_tab.cpp \
+	bitreorder_tab.cpp \
+	bits2prm.cpp \
+	bytesused.cpp \
+	c2_9pf_tab.cpp \
+	copy.cpp \
+	div_32.cpp \
+	div_s.cpp \
+	extract_h.cpp \
+	extract_l.cpp \
+	gains_tbl.cpp \
+	gc_pred.cpp \
+	gmed_n.cpp \
+	grid_tbl.cpp \
+	gray_tbl.cpp \
+	int_lpc.cpp \
+	inv_sqrt.cpp \
+	inv_sqrt_tbl.cpp \
+	l_abs.cpp \
+	l_deposit_h.cpp \
+	l_deposit_l.cpp \
+	l_shr_r.cpp \
+	log2.cpp \
+	log2_norm.cpp \
+	log2_tbl.cpp \
+	lsfwt.cpp \
+	lsp.cpp \
+	lsp_az.cpp \
+	lsp_lsf.cpp \
+	lsp_lsf_tbl.cpp \
+	lsp_tab.cpp \
+	mult_r.cpp \
+	norm_l.cpp \
+	norm_s.cpp \
+	overflow_tbl.cpp \
+	ph_disp_tab.cpp \
+	pow2.cpp \
+	pow2_tbl.cpp \
+	pred_lt.cpp \
+	q_plsf.cpp \
+	q_plsf_3.cpp \
+	q_plsf_3_tbl.cpp \
+	q_plsf_5.cpp \
+	q_plsf_5_tbl.cpp \
+	qua_gain_tbl.cpp \
+	reorder.cpp \
+	residu.cpp \
+	round.cpp \
+	set_zero.cpp \
+	shr.cpp \
+	shr_r.cpp \
+	sqrt_l.cpp \
+	sqrt_l_tbl.cpp \
+	sub.cpp \
+	syn_filt.cpp \
+	vad1.cpp \
+	weight_a.cpp \
+	window_tab.cpp
+
+include $(MK)/library.mk
+
+
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/build/make/makefile b/codecs_v2/audio/gsm_amr/amr_nb/common/build/make/makefile
deleted file mode 100644
index 0cf8695..0000000
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/build/make/makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pv_amr_nb_common_lib
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DORIGINAL_TYPEDEF_H -DOSCL_BASE_H_INCLUDED -DOSCL_TYPES_H_INCLUDE -DOSCL_ASSERT_H_INCLUDED -DOSCL_MEM_BASIC_FUNCTIONS_H -DOSCL_MEM_IMP_H
-XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  add.cpp \
-	az_lsp.cpp \
-	bitno_tab.cpp \
-	bitreorder_tab.cpp \
-	bits2prm.cpp \
-	bytesused.cpp \
-	c2_9pf_tab.cpp \
-	copy.cpp \
-	div_32.cpp \
-	div_s.cpp \
-	extract_h.cpp \
-	extract_l.cpp \
-	gains_tbl.cpp \
-	gc_pred.cpp \
-	gmed_n.cpp \
-	grid_tbl.cpp \
-	gray_tbl.cpp \
-	int_lpc.cpp \
-	inv_sqrt.cpp \
-	inv_sqrt_tbl.cpp \
-	l_abs.cpp \
-	l_deposit_h.cpp \
-	l_deposit_l.cpp \
-	l_shr_r.cpp \
-	log2.cpp \
-	log2_norm.cpp \
-	log2_tbl.cpp \
-	lsfwt.cpp \
-	lsp.cpp \
-	lsp_az.cpp \
-	lsp_lsf.cpp \
-	lsp_lsf_tbl.cpp \
-	lsp_tab.cpp \
-	mult_r.cpp \
-	norm_l.cpp \
-	norm_s.cpp \
-	overflow_tbl.cpp \
-	ph_disp_tab.cpp \
-	pow2.cpp \
-	pow2_tbl.cpp \
-	pred_lt.cpp \
-	q_plsf.cpp \
-	q_plsf_3.cpp \
-	q_plsf_3_tbl.cpp \
-	q_plsf_5.cpp \
-	q_plsf_5_tbl.cpp \
-	qua_gain_tbl.cpp \
-	reorder.cpp \
-	residu.cpp \
-	round.cpp \
-	set_zero.cpp \
-	shr.cpp \
-	shr_r.cpp \
-	sqrt_l.cpp \
-	sqrt_l_tbl.cpp \
-	sub.cpp \
-	syn_filt.cpp \
-	vad1.cpp \
-	weight_a.cpp \
-	window_tab.cpp
-
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/abs_s.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/abs_s.h
index 750549c..8ae8c40 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/abs_s.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/abs_s.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/abs_s.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -41,6 +39,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/add.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/add.h
index 48a7849..9a978c9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/add.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/add.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,19 +27,10 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/add.h
 
 
-
-
-     Date: 08/11/2000
-
-
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -54,6 +45,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who: 							Date:
  Description:
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/az_lsp.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/az_lsp.h
index 3c9afcd..320ce64 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/az_lsp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/az_lsp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,18 +27,10 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/az_lsp.h.h
 
 
-
-     Date: 09/28/2000
-
-
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -49,6 +41,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who: 							Date:
  Description:
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op.h
index 7b1ba7e..46f1035 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./include/basic_op.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +43,7 @@
  Description: Including header files with platform specific inline assembly
               instructions.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -275,18 +274,21 @@
 
     static inline Word16 shl(Word16 var1, Word16 var2, Flag *pOverflow)
     {
-        Word16 var_out;
+        Word16 var_out = 0;
 
         OSCL_UNUSED_ARG(pOverflow);
 
         if (var2 < 0)
         {
-            var2 = (-var2) & (0xf);
-            var_out = var1 >> var2;
+            var2 = -var2;
+            if (var2 < 15)
+            {
+                var_out = var1 >> var2;
+            }
+
         }
         else
         {
-            var2 &= 0xf;
             var_out = var1 << var2;
             if (var_out >> var2 != var1)
             {
@@ -324,7 +326,7 @@
 
     static inline Word32 L_shl(Word32 L_var1, Word16 var2, Flag *pOverflow)
     {
-        Word32 L_var_out;
+        Word32 L_var_out = 0;
 
         OSCL_UNUSED_ARG(pOverflow);
 
@@ -338,8 +340,12 @@
         }
         else
         {
-            var2 = (-var2) & (0xf);
-            L_var_out = L_var1 >> var2;
+            var2 = -var2;
+            if (var2 < 31)
+            {
+                L_var_out = L_var1 >> var2;
+            }
+
         }
 
         return (L_var_out);
@@ -373,25 +379,29 @@
 
     static inline Word32 L_shr(Word32 L_var1, Word16 var2, Flag *pOverflow)
     {
-        Word32 L_var_out;
+        Word32 L_var_out = 0;
 
         OSCL_UNUSED_ARG(pOverflow);
 
-        if (var2 >= 0)
+        if (var2 > 0)
         {
-            L_var_out = L_var1 >> (var2 & 0x1f);
+            if (var2 < 31)
+            {
+                L_var_out = L_var1 >> var2;
+            }
         }
         else
         {
-            var2 = (Word16)(-var2);
-            var2 &= 0x1f;
-            L_var_out = L_var1 << var2;
-            if (L_var_out >> var2 != L_var1)
+            var2 = -var2;
+
+            L_var_out = L_var1 << (var2) ;
+            if ((L_var_out >> (var2)) != L_var1)
             {
                 L_var_out = (L_var1 >> 31) ^ MAX_32;
             }
 
         }
+
         return (L_var_out);
     }
 
@@ -420,18 +430,10 @@
     static inline Word16 abs_s(Word16 var1)
     {
 
-        if (var1 < 0)
-        {
-            if (var1 != MIN_16)
-            {
-                var1 = (Word16) - var1;
-            }
-            else
-            {
-                var1 = MAX_16;
-            }
-        }
-        return (var1);
+        Word16 y = var1 - (var1 < 0);
+        y = y ^(y >> 15);
+        return (y);
+
     }
     /*----------------------------------------------------------------------------
     ; END
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_gcc_v5.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_gcc_v5.h
old mode 100755
new mode 100644
index a0614f1..1fa2297
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_gcc_v5.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_gcc_v5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,12 @@
 ****************************************************************************************/
 /*
 
- Pathname: ./include/basic_op_arm_gcc_v5.h
-
-     Date: 01/30/2007
+  Pathname: ./include/basic_op_arm_gcc_v5.h
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -480,26 +479,21 @@
         register Word32 ra = var1;
         register Word32 rb = var2;
         Word32 product;
-        Word32 temp = 0x7FFF;
+        Word32 temp;
 
         OSCL_UNUSED_ARG(pOverflow);
 
-        asm volatile("smulbb %0, %1, %2"
-             : "=r"(product)
-                             : "r"(ra), "r"(rb)
-                            );
-        asm volatile("mov %0, %1, ASR #15"
-             : "=r"(product)
-                             : "r"(product)
-                            );
-        asm volatile("cmp %0, %1"
-             : "=r"(product)
-                             : "r"(temp)
-                            );
-        asm volatile("movge %0, %1"
-             : "=r"(product)
-                             : "r"(temp)
-                            );
+        asm volatile(
+            "smulbb %0, %1, %2"
+    : "=r"(temp)
+                    : "r"(ra), "r"(rb)
+                );
+        asm volatile(
+            "qadd %0, %1, %2\n\t"
+            "mov %0, %0, asr #16"
+    : "=&r*i"(product)
+                    : "r"(temp), "r"(temp)
+                );
 
         return ((Word16) product);
     }
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_v5.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_v5.h
old mode 100755
new mode 100644
index 247ffdf..02581cb
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_v5.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_arm_v5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,12 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./include/basic_op_arm_v5.h
 
-     Date: 01/30/2007
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_c_equivalent.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_c_equivalent.h
old mode 100755
new mode 100644
index ccb4bbe..ddf320a
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_c_equivalent.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basic_op_c_equivalent.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,11 +30,10 @@
 
  Pathname: ./include/basic_op_c_equivalent.h
 
-     Date: 01/30/2007
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basicop_malloc.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basicop_malloc.h
index 171f5c9..9251094 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/basicop_malloc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/basicop_malloc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,13 +30,12 @@
 
  Pathname: ./gsm-amr/c/include/basicop_malloc.h
 
-     Date: 08/10/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Added #ifdef __cplusplus after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitno_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitno_tab.h
index 8a7d522..a170750 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitno_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitno_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,9 +28,8 @@
 ****************************************************************************************/
 /*
 
- Pathname: .audio/gsm-amr/c/include/bitno_tab.h
+  Pathname: .audio/gsm-amr/c/include/bitno_tab.h
 
-     Date: 02/04/2002
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -40,6 +39,7 @@
 
  Description: Added #ifdef __cplusplus after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitreorder_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitreorder_tab.h
index 5245989..bfcb4cf 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitreorder_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bitreorder_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: .audio/gsm-amr/c/include/bitreorder.h
 
-     Date: 01/24/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Added #ifdef __cplusplus after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bits2prm.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bits2prm.h
index b36d050..8e1b432 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bits2prm.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bits2prm.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,6 +52,9 @@
 #include "typedef.h"
 #include "mode.h"
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
 
 #ifdef __cplusplus
 extern "C"
@@ -79,7 +82,7 @@
     *
     **************************************************************************
     */
-    void Bits2prm(
+    OSCL_IMPORT_REF void Bits2prm(
         enum Mode mode,
         Word16 bits[],   /* input : serial bits, (244 + bfi)               */
         Word16 prm[]     /* output: analysis parameters, (57+1 parameters) */
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bytesused.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bytesused.h
index d68075f..fe43cbb 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/bytesused.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/bytesused.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,13 +30,12 @@
 
  Pathname: .audio/gsm-amr/c/include/BytesUsed.h
 
-     Date: 07/26/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Added #ifdef __cplusplus after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst.h
index 18ddcf5..b648eb7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
 
  This file contains the Speech code (encoder, decoder, and postfilter)
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst_vad.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst_vad.h
index 1ad3e03..6877a1b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst_vad.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/cnst_vad.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/copy.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/copy.h
index 1400656..b539ebb 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/copy.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/copy.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_c.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_c.h
index eca6ba6..70868f4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_c.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_c.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,19 +27,15 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/include/d_gain_c.h
 
-     Date: 01/29/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_p.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_p.h
index b9774d8..fec072b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_p.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_gain_p.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_plsf.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_plsf.h
index f421fc4..0e5ca9a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_plsf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/d_plsf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/d_plsf.h
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_32.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_32.h
index f0d7578..8a55ed8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_32.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,13 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/div_32.h
 
-     Date: 09/08/2000
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -44,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_s.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_s.h
index 6784df3..441c5a4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_s.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/div_s.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/div_s.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/dtx_common_def.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/dtx_common_def.h
index 6701f78..c29b9e1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/dtx_common_def.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/dtx_common_def.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,18 +27,13 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/dtx_common_def.h
 
-     Date: 03/08/2005
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_h.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_h.h
index d6e3538..1d59ca2 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_h.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_h.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/extract_h.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_l.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_l.h
index 213a449..964123c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_l.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/extract_l.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/extract_l.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame.h
index b897006..f1fb197 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame_type_3gpp.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame_type_3gpp.h
index e489343..d11d240 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame_type_3gpp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/frame_type_3gpp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,12 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
 
  Pathname: ./audio/gsm-amr/c/include/frame_type_3gpp.h
 
-     Date: 08/06/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +37,7 @@
 
  Description: Added #ifdef __cplusplus after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/gc_pred.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/gc_pred.h
index 1e91b80..b82603c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/gc_pred.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/gc_pred.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/include/gc_pred.h
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +37,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/gmed_n.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/gmed_n.h
index 417c486..1c4ede2 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/gmed_n.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/gmed_n.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/gsm_amr_typedefs.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/gsm_amr_typedefs.h
index 1c3bc7c..83e8408 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/gsm_amr_typedefs.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/gsm_amr_typedefs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,12 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
 
  Pathname: codecs/audio/gsm_amr/gsm_two_way/c/include/gsm_amr_typedefs.h
 
-     Date:
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lpc.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lpc.h
index 730ac97..e95e6ca 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lpc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lpc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/lsp_avg.h
 
-     Date: 01/29/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lsf.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lsf.h
index ea8bbaa..35b4d02 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lsf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/int_lsf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,19 +27,15 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/int_lsf.h
 
-     Date: 01/23/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/inv_sqrt.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/inv_sqrt.h
index 499a256..4fb2b11 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/inv_sqrt.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/inv_sqrt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,17 +27,10 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/inv_sqrt.h
 
 
-
-     Date: 01/23/2002
-
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -51,6 +44,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                           Date:
  Description:
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_abs.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_abs.h
index bb2a37f..aa8ca0a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_abs.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_abs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/l_abs.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -39,6 +37,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section..
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add.h
index f5fe9fc..136b914 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_add.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -51,6 +46,7 @@
 
  Description: Providing support for ARM and Linux-ARM assembly instructions.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -110,7 +106,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 L_add(register Word32 L_var1, register Word32 L_var2, Flag *pOverflow)
     {
@@ -124,7 +120,7 @@
         return(result);
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     __inline Word32 L_add(register Word32 L_var1, register Word32 L_var2, Flag *pOverflow)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add_c.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add_c.h
index abf9826..1559dcc 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add_c.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_add_c.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_add_c.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +41,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_comp.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_comp.h
index 9660ead..02a4bb7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_comp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_comp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/l_comp.h
 
-     Date: 09/08/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_h.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_h.h
index db31021..abbddef 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_h.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_h.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/l_deposit_h.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_l.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_l.h
index 3e8a80a..388844c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_l.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_deposit_l.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/l_deposit_l.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_extract.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_extract.h
index 8a77c68..c28072e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_extract.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_extract.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_extract.h
 
-     Date: 09/08/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +39,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mac.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mac.h
index aebb8fe..b4af3aa 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mac.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mac.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/l_mac.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -109,7 +103,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 L_mac(Word32 L_var3, Word16 var1, Word16 var2, Flag *pOverflow)
     {
@@ -123,7 +117,7 @@
         return (L_sum);
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     static inline Word32 L_mac(Word32 L_var3, Word16 var1, Word16 var2, Flag *pOverflow)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_msu.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_msu.h
index 71289a0..3bafb00 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_msu.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_msu.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/l_msu.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +42,7 @@
 
  Description: Providing support for ARM and Linux-ARM assembly instructions.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -109,7 +104,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 L_msu(Word32 L_var3, Word16 var1, Word16 var2, Flag *pOverflow)
     {
@@ -127,7 +122,7 @@
         return (result);
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     __inline Word32 L_msu(Word32 L_var3, Word16 var1, Word16 var2, Flag *pOverflow)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mult.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mult.h
index 1452f41..a2eb91c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mult.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_mult.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_mult.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Providing support for ARM and Linux-ARM assembly instructions.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -108,7 +104,7 @@
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
 
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 L_mult(Word16 var1, Word16 var2, Flag *pOverflow)
     {
@@ -126,7 +122,7 @@
         return (result);
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     __inline Word32 L_mult(Word16 var1, Word16 var2, Flag *pOverflow)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_negate.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_negate.h
index 827023f..8ddb24a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_negate.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_negate.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/include/l_negate.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shl.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shl.h
index bf90d83..90b778b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shl.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_shl.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +41,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr.h
index 7078ff0..b749ce4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/l_shr.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr_r.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr_r.h
index 4062b18..e41a0c4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr_r.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_shr_r.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_shr_r.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +41,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_sub.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_sub.h
index 3cb67bb..e461a92 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_sub.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/l_sub.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/l_sub.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Providing support for ARM and Linux-ARM assembly instructions.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -108,7 +104,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 L_sub(Word32 L_var1, Word32 L_var2, Flag *pOverflow)
     {
@@ -125,7 +121,7 @@
 
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     __inline Word32 L_sub(Word32 L_var1, Word32 L_var2, Flag *pOverflow)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2.h
index e87b753..e589b2f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/log2.h
 
-     Date: 09/22/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section..
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2_norm.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2_norm.h
index eb10d8c..1f73c6d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2_norm.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/log2_norm.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/log2_norm.h
 
-     Date: 09/22/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +41,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsfwt.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsfwt.h
index cc58900..d9a1f80 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsfwt.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsfwt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/lsfwt.h
 
-     Date: 02/01/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp.h
index 14d16ff..26a4b34 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/lsp.h
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_az.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_az.h
index 846e466..e5d10e2 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_az.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_az.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,19 +27,15 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/lsp_az.h
 
-     Date: 01/23/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_lsf.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_lsf.h
index 331538d..186b4d3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_lsf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_lsf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/lsp_lsf.h
 
-     Date: 01/29/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_tab.h
index 1e90900..01b3317 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/lsp_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,13 +30,12 @@
 
  Pathname: .audio/gsm-amr/c/include/lsp_tab.h
 
-     Date: 02/06/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Added #ifdef __cplusplus after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mac_32.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mac_32.h
index 7ae2541..aeb0256 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mac_32.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mac_32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/mac_32.h
 
-     Date: 01/18/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -47,6 +42,7 @@
  Description: Inlined the functions from mac_32.cpp. A performance improvement
               change.
 
+ Who:                       Date:
  Description:
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mode.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mode.h
index ebeca97..f4695ca 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mode.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32.h
index 38ec7d1..a016241 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/mpy_32.h
 
-     Date: 09/08/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -107,7 +102,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 Mpy_32(Word16 L_var1_hi,
                            Word16 L_var1_lo,
@@ -141,7 +136,7 @@
         return (L_sum);
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     static inline Word32 Mpy_32(Word16 L_var1_hi,
                                 Word16 L_var1_lo,
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32_16.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32_16.h
index 14d3ef4..07debc3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32_16.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mpy_32_16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,30 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
 
-
-
- Filename: /audio/gsm_amr/c/include/mpy_32_16.h
-
-     Date: 09/08/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated function prototype declaration to reflect new interface.
-              A pointer to overflow flag is passed into the function. Updated
-              template.
-
- Description: Moved _cplusplus #ifdef after Include section.
-
- Description: 1. Updated the function to include ARM and Linux-ARM assembly
-                 instructions.
-              2. Added OSCL_UNUSED_ARG(pOverflow) to remove compiler warnings.
-
- Description: Fixed bug in the gcc-arm assembly.
-
- Description:
+  Filename: /audio/gsm_amr/c/include/mpy_32_16.h
 
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
@@ -110,7 +88,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM) /* Instructions for ARM Assembly on ADS*/
+#if defined(PV_ARM_V5) /* Instructions for ARM Assembly on ADS*/
 
     __inline Word32 Mpy_32_16(Word16 L_var1_hi,
                               Word16 L_var1_lo,
@@ -132,7 +110,7 @@
         return (L_sum);
     }
 
-#elif defined(PV_ARM_GCC) /* Instructions for ARM-linux cross-compiler*/
+#elif defined(PV_ARM_GCC_V5) /* Instructions for ARM-linux cross-compiler*/
 
     static inline Word32 Mpy_32_16(Word16 L_var1_hi,
                                    Word16 L_var1_lo,
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult.h
index 30df67d..639f1b3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/mult.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -51,6 +46,7 @@
 
  Description: Providing support for ARM and Linux-ARM assembly instructions.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -108,7 +104,7 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if defined(PV_ARM)
+#if defined(PV_ARM_V5)
 
     __inline Word16 mult(Word16 var1, Word16 var2, Flag *pOverflow)
     {
@@ -127,7 +123,7 @@
         return ((Word16) product);
     }
 
-#elif defined(PV_ARM_GCC)
+#elif defined(PV_ARM_GCC_V5)
 
     __inline Word16 mult(Word16 var1, Word16 var2, Flag *pOverflow)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult_r.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult_r.h
index 2528c62..4a904f4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult_r.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/mult_r.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/mult_r.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -50,6 +45,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/n_proc.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/n_proc.h
index 22a1afd..e5738c1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/n_proc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/n_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/negate.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/negate.h
index 5097f26..05d8a6f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/negate.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/negate.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/include/negate.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +39,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_l.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_l.h
index 6577082..756a850 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_l.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_l.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/include/norm_l.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +41,7 @@
 
  Description: Support for ARM and Linux-ARM assembly.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -103,16 +101,16 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
-#if ( !defined(PV_ARM)  && !defined(PV_ARM_GCC) )
+#if !( defined(PV_ARM_V5) || defined(PV_ARM_GCC_V5) )
 
     /* C EQUIVALENT */
     Word16 norm_l(Word32 L_var1);
 
-#elif defined(PV_ARM)
+#elif defined(PV_ARM_V5)
 
     __inline Word16 norm_l(Word32 L_var1)
     {
-        register Word16 var_out = 0;
+        register Word32 var_out = 0;
 
         __asm
         {
@@ -121,10 +119,10 @@
             CLZNE  var_out, L_var1
         }
 
-        return (var_out);
+        return ((Word16)var_out);
     }
 
-#elif defined(PV_ARM_GCC)
+#elif defined(PV_ARM_GCC_V5)
 
     static inline Word16 norm_l(Word32 L_var1)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_s.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_s.h
index 31fd453..0606af3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_s.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/norm_s.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/include/norm_s.h
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +39,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -101,8 +99,48 @@
     ; GLOBAL FUNCTION DEFINITIONS
     ; Function Prototype declaration
     ----------------------------------------------------------------------------*/
+#if !( defined(PV_ARM_V5) || defined(PV_ARM_GCC_V5) )
+
+    /* C EQUIVALENT */
+
     Word16 norm_s(Word16 var1);
 
+#elif defined(PV_ARM_V5)
+
+    __inline Word16  norm_s(Word16 var)
+    {
+        register Word32 var_out = 0;
+        Word32 var1 = var << 16;
+
+        __asm
+        {
+            CMP    var1, #0
+            EORNE  var1, var1, var1, LSL #1
+            CLZNE  var_out, var1
+        }
+
+        return ((Word16)var_out);
+    }
+
+#elif defined(PV_ARM_GCC_V5)
+
+    static inline Word16 norm_s(Word16 var1)
+    {
+        register Word32 var_out = 0;
+        register Word32 ra = var1 << 16;
+        if (ra)
+        {
+            ra ^= (ra << 1);
+            asm volatile(
+                "clz %0, %1"
+    : "=r"(var_out)
+                        : "r"(ra)
+                    );
+        }
+        return (var_out);
+    }
+
+#endif
     /*----------------------------------------------------------------------------
     ; END
     ----------------------------------------------------------------------------*/
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/oper_32b.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/oper_32b.h
index bbd0427..2611b16 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/oper_32b.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/oper_32b.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,14 +30,13 @@
 
  Pathname: ./gsm-amr/c/include/oper_32b.h
 
-     Date: 09/08/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Deleted inclusion of files that were not part of the original
 	      oper_32b.h file.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/p_ol_wgh.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/p_ol_wgh.h
index a4f55f1..6c277da 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/p_ol_wgh.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/p_ol_wgh.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/include/p_ol_wgh.h
 
-     Date: 02/05/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +37,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/pow2.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/pow2.h
index 2d9a985..639c068 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/pow2.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/pow2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/log2_norm.h
 
-     Date: 09/28/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +39,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/pred_lt.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/pred_lt.h
index fbf6719..45d9272 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/pred_lt.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/pred_lt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,19 +27,14 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/pred_lt.h
 
-     Date: 01/23/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/pvgsmamr.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/pvgsmamr.h
index 6acc502..b697524 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/pvgsmamr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/pvgsmamr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,12 +26,6 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
-//																				//
-//	File: PVGsmamr.h	                                                        //
-//																				//
-//////////////////////////////////////////////////////////////////////////////////
-
-
 #ifndef __PVGSMAMR_H
 #define __PVGSMAMR_H
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf.h
index bae08b1..431272a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/q_plsf.h
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf_5_tbl.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf_5_tbl.h
index 42deb8c..245b5f4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf_5_tbl.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/q_plsf_5_tbl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,11 +30,10 @@
 
  Pathname: .audio/gsm-amr/c/include/q_plsf_5_tbl.h
 
-     Date: 12/09/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                        Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/qgain475_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/qgain475_tab.h
index 9079fd8..ac1b1dd 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/qgain475_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/qgain475_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,11 +30,10 @@
 
  Pathname: .audio/gsm-amr/c/include/qgain475_tab.h
 
-     Date: 12/09/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                        Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain.h
index 27dfbe8..65b35ee 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/qua_gain.h
 
-     Date: 02/05/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain_tbl.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain_tbl.h
index 1da468e..a7691e7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain_tbl.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/qua_gain_tbl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,11 +30,10 @@
 
  Pathname: .audio/gsm-amr/c/include/qua_gain_tbl.h
 
-     Date: 12/09/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:                        Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/reorder.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/reorder.h
index da1de98..620cd0b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/reorder.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/reorder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,20 +27,14 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/reorder.h
 
-
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/residu.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/residu.h
index f178cd8..f4d0041 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/residu.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/residu.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/reverse_bits.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/reverse_bits.h
index 71f732f..fcc8df6 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/reverse_bits.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/reverse_bits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: .audio/gsm-amr/c/include/reverse_bits.h
 
-     Date: 07-24-2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +41,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                        Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/round.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/round.h
index fd93bf6..3129e27 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/round.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/round.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/round.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -49,6 +43,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/set_zero.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/set_zero.h
index c3dd78f..debd223 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/set_zero.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/set_zero.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/shl.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/shl.h
index 0effe26..de4aed7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/shl.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/shl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/shl.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr.h
index 1fef9c8..a7111c1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/shr.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr_r.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr_r.h
index a55ae3c..c4f9e2c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr_r.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/shr_r.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/include/shr_r.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +41,7 @@
 
  Description: Moved _cplusplus #define after Include section.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/sqrt_l.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/sqrt_l.h
index 79e554a..86209bd 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/sqrt_l.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/sqrt_l.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,17 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/sqrt_l.h
 
-
-
-     Date: 01/23/2002
-
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -50,6 +42,7 @@
 
  Description: Moved _cplusplus #ifdef before function prototype.
 
+ Who:                           Date:
  Description:
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/sub.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/sub.h
index dbb286c..ea7aa40 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/sub.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/sub.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/sub.h
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/syn_filt.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/syn_filt.h
index 874d6bf..7fff112 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/syn_filt.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/syn_filt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/typedef.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/typedef.h
index c855398..ee4d732 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/typedef.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/typedef.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad.h
index cc811e3..fbac230 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad1.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad1.h
index 245884a..c144ea0 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad1.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad1.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/include/vad_1.h
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad2.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad2.h
index 1813593..3197b3a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad2.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/vad2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/include/vad2.h
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -49,6 +43,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/weight_a.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/weight_a.h
index b89b042..0358c85 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/weight_a.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/weight_a.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/window_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/window_tab.h
index e66b2dd..7cb441f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/window_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/window_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,12 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: .audio/gsm-amr/c/include/window_tab.h
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
+ Who:						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/include/wmf_to_ets.h b/codecs_v2/audio/gsm_amr/amr_nb/common/include/wmf_to_ets.h
index bc2c729..b923e52 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/include/wmf_to_ets.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/include/wmf_to_ets.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/include/src/wmf_to_ets.h
 
-     Date: 01/22/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +40,7 @@
 
  Description: Moved _cplusplus #ifdef after Include section.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/add.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/add.cpp
index 97ad09a..f503d47 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/add.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/add.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/add.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +43,7 @@
 
  Description: Removed code that updates MOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/az_lsp.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/az_lsp.cpp
index d5b4c67..bd99b30 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/az_lsp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/az_lsp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,18 +27,12 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
 
  Pathname: ./audio/gsm-amr/c/src/az_lsp.c
  Funtions: Chebps
            Chebps_Wrapper
            Az_lsp
 
-     Date: 05/18/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -79,6 +73,7 @@
  Description:  Added casting to eliminate warnings
 
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitno_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitno_tab.cpp
index fd8bfe7..fed684d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitno_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitno_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: .audio/gsm-amr/c/src/bitno_tab.c
 
-     Date: 02/05/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +41,7 @@
 
  Description: Put "extern" back.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitreorder_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitreorder_tab.cpp
index 18a0a08..69b20fb 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitreorder_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bitreorder_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: .audio/gsm-amr/c/src/bitreorder.c
 
-     Date: 01/24/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -47,6 +45,7 @@
 
  Description: Put "extern" back.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bits2prm.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bits2prm.cpp
index 652ec89..1d6f7b1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bits2prm.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bits2prm.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/bits2prm.c
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description:  Replaced "int" and/or "char" with OSCL defined types.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -270,7 +266,7 @@
 /*----------------------------------------------------------------------------
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
-void Bits2prm(
+OSCL_EXPORT_REF void Bits2prm(
     enum Mode mode,     /* i : AMR mode                                    */
     Word16 bits[],      /* i : serial bits       (size <= MAX_SERIAL_SIZE) */
     Word16 prm[]        /* o : analysis parameters  (size <= MAX_PRM_SIZE) */
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bytesused.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bytesused.cpp
index ad2a27b..9552206 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/bytesused.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/bytesused.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,13 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
 
  Pathname: ./audio/gsm-amr/c/src/BytesUsed.c
 
-     Date: 07/27/2001
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +42,7 @@
 
  Description: Put "extern" back.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/c2_9pf_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/c2_9pf_tab.cpp
index 7a2032b..273abc3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/c2_9pf_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/c2_9pf_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,11 +28,7 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/c2_9pf_tab.c
-     Date: 01/29/2002
 
 ------------------------------------------------------------------------------
  REVISION HISTORY
@@ -47,6 +43,7 @@
 
  Description: Put "extern" back.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/copy.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/copy.cpp
index 93f6703..ee99b4a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/copy.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/copy.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,6 +53,7 @@
 */
 #include "typedef.h"
 #include "basic_op.h"
+#include "oscl_mem.h"
 
 /*
 ********************************************************************************
@@ -81,12 +82,5 @@
     Word16 L            /* i : vector length     */
 )
 {
-    Word16 i;
-
-    for (i = 0; i < L; i++)
-    {
-        y[i] = x[i];
-    }
-
-    return;
+    oscl_memcpy(y, x, L*sizeof(*x));
 }
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_32.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_32.cpp
index f9f6837..143e37c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_32.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_32.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/div_32.c
 
-     Date: 09/07/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -52,6 +47,7 @@
 
  Description:  Added casting to eliminate warnings
 
+ Who:                           Date:
  Description:
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_s.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_s.cpp
index 96cb04c..9e7d23a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_s.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/div_s.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,13 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
  Pathname: ./gsm-amr/c/src/div_s.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -51,6 +46,7 @@
                  pass, using only five iterations of the loop and saving
                  shifts cycles
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_h.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_h.cpp
index 2a80329..8f5036d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_h.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_h.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/src/extract_h.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +38,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_l.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_l.cpp
index f42cc39..e005bc5 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_l.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/extract_l.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/src/extract_l.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +37,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gains_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gains_tbl.cpp
index b34feb9..b086662 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gains_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gains_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,12 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
  Filename: /audio/gsm_amr/c/src/gains_tbl.c
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +42,7 @@
 
  Description: Put "extern" back.
 
+ Who:                               Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gc_pred.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gc_pred.cpp
index 4088c74..3650f3c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gc_pred.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gc_pred.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,9 +27,6 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/gc_pred.c
  Functions:
@@ -38,65 +35,6 @@
             gc_pred_update
             gc_pred_average_limited
 
-     Date: 04/18/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated template used to PV coding template. First attempt at
-          optimizing C code.
-
- Description: Updated file per comments gathered from Phase 2/3 review.
-
- Description: Added setting of Overflow flag in inlined code.
-
- Description: Fixed bug in gc_pred that causes it to not be bit-exact with
-              the original version. This was done by adding code that sign-
-              extends the means_ener value. Fixed tabs all over the code
-              and deleted all calls to test function in gc_pred.
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include files.
-
- Description: Replace basic_op.h and oper_32b.h with the header files of the
-              math functions used in the file. Fixed typecasting issue with
-              TI compiler.
-
- Description: Fixed more typecasting issue with TI C Compiler (per comments
-              from peer review).
-
- Description: Removed the functions gc_pred_init and gc_pred_exit.
- The gc_pred related structure is no longer dynamically allocated.
-
- Description: Adding pOverflow to the functions to remove global variables.
-              These changes are needed for the EPOC releases.
-
- Description:  For gc_pred() and gc_pred_copy()
-              1. Eliminated gc_pred_copy() (call replaced by memcpy).
-              2. Eliminated unused include files copy.h and typedef.h.
-              3. Replaced array addressing by pointers
-              4. Eliminated math operations that unnecessary checked for
-                 saturation, in some cases this by shifting before adding and
-                 in other cases by evaluating the operands
-              5. Unrolled loops to speed up processing
-
- Description:  Cleaned unused code
-
- Description:  Modified pointer update order in function gc_pred().
- 			   Previous order was accepted by Vcpp by failed when using
- 			   ARM tools. Current order is correct for all platforms
-
- Description:  Replaced OSCL mem type functions and eliminated include
-               files that now are chosen by OSCL definitions
-
- Description:  Replaced "int" and/or "char" with defined types.
-               Added proper casting (Word32) to some left shifting operations
-
- Description: Changed round function name to pv_round to avoid conflict with
-              round function in C standard library.
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gmed_n.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gmed_n.cpp
index 97c1a43..be76241 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gmed_n.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gmed_n.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/gmed_n.c
 
-     Date: 04/20/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -48,6 +42,7 @@
 
  Description:  Replaced "int" and/or "char" with OSCL defined types.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gray_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gray_tbl.cpp
index 80a407c..87a2993 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/gray_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/gray_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/gray_tbl.c
 
-     Date: 01/25/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/grid_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/grid_tbl.cpp
index 1cf1c86..af5fe32 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/grid_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/grid_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/grid_tbl.c
 
-     Date: 01/16/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/int_lpc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/int_lpc.cpp
index 8747866..806474d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/int_lpc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/int_lpc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,15 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/int_lpc.c
  Functions:
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -54,6 +48,7 @@
  Description:  Replaced "int" and/or "char" with OSCL defined types.
 
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt.cpp
index 74089cb..83f4d0c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/inv_sqrt.c
 
-     Date: 04/20/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -66,6 +60,7 @@
  Description:  Replaced "int" and/or "char" with defined types.
                Added proper casting (Word32) to some left shifting operations
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt_tbl.cpp
index e4e193d..bde2c4e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/inv_sqrt_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/inv_sqrt_tbl.c
 
-     Date: 01/24/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +40,7 @@
 
  Description: Put "extern" back.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_abs.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_abs.cpp
index a09ffe4..bcde5fa 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_abs.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_abs.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/src/l_abs.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +37,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -188,21 +186,8 @@
     ; Function body here
     ----------------------------------------------------------------------------*/
 
-    if (L_var1 < 0)
-    {
-        if (L_var1 == MIN_32)
-        {
-            L_var1 = MAX_32;
-        }
-        else
-        {
-            L_var1 = -L_var1;
-        }
-    }
-    /* else L_var1 = L_var1;*/
+    Word32 y = L_var1 - (L_var1 < 0);
+    y = y ^(y >> 31);
+    return (y);
 
-    /*----------------------------------------------------------------------------
-    ; Return nothing or data or data pointer
-    ----------------------------------------------------------------------------*/
-    return (L_var1);
 }
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_h.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_h.cpp
index 3c5b1d1..8aa7e02 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_h.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_h.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/src/l_deposit_h.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +37,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_l.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_l.cpp
index 0df913e..50977b8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_l.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_deposit_l.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: ./gsm-amr/c/src/l_deposit_l.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +37,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_shr_r.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_shr_r.cpp
index de5c165..f609a73 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_shr_r.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/l_shr_r.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
-
-
-
  Filename: /audio/gsm_amr/c/src/l_shr_r.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +40,7 @@
               global flag. Removed code that updates MOPS counter. Changed
               function return value name from "L_var_out" to "result".
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2.cpp
index 3374670..6007b3f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
-
-
-
  Filename: /audio/gsm_amr/c/src/log2.c
 
-     Date: 09/22/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -53,6 +47,7 @@
               2. Eliminated unused include files typedef.h and l_shl.h.
 
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_norm.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_norm.cpp
index 279c9d8..feda874 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_norm.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_norm.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/log2_norm.c
 
-     Date: 09/22/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -52,6 +47,7 @@
 
  Description: Removed inclusion of "log2.tab"
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_tbl.cpp
index 7141c27..159d29f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/log2_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/log2_tbl.c
 
-     Date: 01/25/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsfwt.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsfwt.cpp
index c9eb29d..6b511f7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsfwt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsfwt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,15 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/lsfwt.c
  Functions: Lsf_wt
 
-     Date: 02/01/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -51,6 +45,7 @@
 
  Description:  Replaced "int" and/or "char" with OSCL defined types.
 
+ Who:                       Date:
  Description:
 
  ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp.cpp
index ee69361..fcd7690 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,15 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/lsp.c
  Functions:
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -57,6 +51,7 @@
 
  Description:  Replaced "int" and/or "char" with OSCL defined types.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -183,9 +178,16 @@
     }
 
     /* Initialize quantization state */
-    Q_plsf_init(&s->qSt);
+    if (0 != Q_plsf_init(&s->qSt))
+    {
+        return -1;
+    }
 
-    lsp_reset(s);
+    if (0 != lsp_reset(s))
+    {
+        return -1;
+    }
+
     *st = s;
 
     return 0;
@@ -517,7 +519,10 @@
 
     /* update the LSPs for the next frame */
     oscl_memcpy(st->lsp_old,   lsp_new,   M*sizeof(Word16));
-    oscl_memcpy(st->lsp_old_q, lsp_new_q, M*sizeof(Word16));
 
+    if (used_mode != MRDTX)
+    {
+        oscl_memcpy(st->lsp_old_q, lsp_new_q, M*sizeof(Word16));
+    }
 }
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_az.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_az.cpp
index dc9945a..6b7b471 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_az.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_az.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,16 +27,11 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/lsp_az.c
  Funtions: Get_lsp_pol
            Lsp_Az
 
-     Date: 03/29/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -87,6 +82,7 @@
  Description:  Replaced "int" and/or "char" with defined types.
                Added proper casting (Word32) to some left shifting operations
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf.cpp
index fccbb1c..39d6eda 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,16 +27,10 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/lsp_lsf.c
  Functions: Lsp_lsf
             Lsf_lsp
 
-     Date: 03/28/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -68,6 +62,7 @@
 
  Description: Added #ifdef __cplusplus around extern'ed table.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf_tbl.cpp
index 3b273ad..cee0f32 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_lsf_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,13 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
-
-
  Filename: /audio/gsm_amr/c/src/lsp_lsf_tbl.c
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_tab.cpp
index 97e4eea..f6fc149 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/lsp_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: .audio/gsm-amr/c/src/lsp_tab.c
 
-     Date: 02/06/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -41,6 +39,7 @@
 
  Description: Put "extern" back.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/mult_r.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/mult_r.cpp
index 4d42417..04968ef 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/mult_r.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/mult_r.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/mult_r.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -50,6 +45,7 @@
 			  3) Removed code that updates MOPS counter
 			  4) Updated template and reference section
 
+ Who: 						Date:
  Description:
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/negate.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/negate.cpp
index d561b1a..ae37554 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/negate.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/negate.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/src/negate.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +38,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_l.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_l.cpp
index 08a11da..132fed6 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_l.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_l.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,13 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
  Pathname: ./gsm-amr/c/src/norm_l.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -53,6 +48,7 @@
 
  Description: 1. Support for ARM and Linux-ARM assembly instructions.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -200,7 +196,7 @@
 /*----------------------------------------------------------------------------
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
-#if ( !defined(PV_ARM) && !defined(PV_ARM_GCC) )
+#if !( defined(PV_ARM_V5) || defined(PV_ARM_GCC_V5) )
 Word16 norm_l(register Word32 L_var1)
 {
     /*----------------------------------------------------------------------------
@@ -212,8 +208,13 @@
     ; Function body here
     ----------------------------------------------------------------------------*/
 
-    if (L_var1 > 0)
+    if (L_var1)
     {
+
+        Word32 y = L_var1 - (L_var1 < 0);
+        L_var1 = y ^(y >> 31);
+
+
         while (!(0x40000000L & L_var1))
         {
             var_out++;
@@ -234,36 +235,7 @@
             var_out++;
             L_var1 <<= 4;
         }
-
     }
-    else
-    {
-        if (L_var1 < 0)
-        {
-            L_var1 = -L_var1;
-            while (!(0x40000000L & L_var1))
-            {
-                var_out++;
-                if ((0x20000000L & L_var1))
-                {
-                    break;
-                }
-                var_out++;
-                if ((0x10000000L & L_var1))
-                {
-                    break;
-                }
-                var_out++;
-                if ((0x08000000L & L_var1))
-                {
-                    break;
-                }
-                var_out++;
-                L_var1 <<= 4;
-            }
-        }
-    }
-
 
     /*----------------------------------------------------------------------------
     ; Return nothing or data or data pointer
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_s.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_s.cpp
index 35f5f9a..8cdcdb8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_s.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/norm_s.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/src/norm_s.c
 
-     Date: 08/13/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -46,6 +44,7 @@
 
  Description: Removed conditional code that updates WMOPS counter
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -193,42 +192,51 @@
 /*----------------------------------------------------------------------------
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
+#if !( defined(PV_ARM_V5) || defined(PV_ARM_GCC_V5) )
+
 Word16 norm_s(register Word16 var1)
 {
     /*----------------------------------------------------------------------------
     ; Define all local variables
     ----------------------------------------------------------------------------*/
-    register Word16 var_out;
+
+    register Word16 var_out = 0;
 
     /*----------------------------------------------------------------------------
     ; Function body here
     ----------------------------------------------------------------------------*/
-    if (var1 == 0)
-    {
-        var_out = 0;
-    }
-    else
-    {
-        if (var1 == (Word16) 0xffff)
-        {
-            var_out = 15;
-        }
-        else
-        {
-            if (var1 < 0)
-            {
-                var1 = ~var1;
-            }
-            for (var_out = 0; var1 < 0x4000; var_out++)
-            {
-                var1 <<= 1;
-            }
-        }
-    }
 
+    if (var1)
+    {
+        Word16 y = var1 - (var1 < 0);
+        var1 = y ^(y >> 15);
+
+        while (!(0x4000 & var1))
+        {
+            var_out++;
+            if ((0x2000 & var1))
+            {
+                break;
+            }
+            var_out++;
+            if ((0x1000 & var1))
+            {
+                break;
+            }
+            var_out++;
+            if ((0x0800 & var1))
+            {
+                break;
+            }
+            var_out++;
+            var1 <<= 4;
+        }
+    }
 
     /*----------------------------------------------------------------------------
     ; Return nothing or data or data pointer
     ----------------------------------------------------------------------------*/
     return (var_out);
 }
+
+#endif
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/overflow_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/overflow_tbl.cpp
index abc05c0..2a9bad7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/overflow_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/overflow_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/overflow_tbl.c
 
-     Date: 01/16/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/ph_disp_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/ph_disp_tab.cpp
index 38471ec..c20037b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/ph_disp_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/ph_disp_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/ph_disp_tab.c
 
-     Date: 01/16/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2.cpp
index e42c898..aae9b9e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,23 +28,16 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/pow2.c
 
-
-     Date: 09/28/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
-
-
  Description: Updated template. Changed function interface to pass in a
               pointer to overflow flag into the function instead of using a
               global flag. Removed inclusion of "pow2.tab"
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2_tbl.cpp
index 316f472..710429f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/pow2_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/pow2_tbl.c
 
-     Date: 01/25/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -43,6 +38,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/pred_lt.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/pred_lt.cpp
index 772b11b..a18b838 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/pred_lt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/pred_lt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/pred_lt.c
 
-     Date: 04/05/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -74,6 +68,7 @@
  Description: Changed round function name to pv_round to avoid conflict with
               round function in C standard library.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf.cpp
index 92f92c5..75392e9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3.cpp
index 9e0cadc..cc06454 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,9 +27,6 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/q_plsf_3.c
  Funtions: Vq_subvec4
@@ -38,8 +35,6 @@
            Test_Vq_subvec3
            Q_plsf_3
 
-     Date: 05/18/00
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -84,6 +79,7 @@
 
  Description: Added #ifdef __cplusplus around extern'ed table.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -246,7 +242,7 @@
     lsf_r1[0] = *p_dico++;
     lsf_r1[1] = *p_dico++;
     lsf_r1[2] = *p_dico++;
-    lsf_r1[3] = *p_dico++;
+    lsf_r1[3] = *p_dico;
 
     return index;
 
@@ -346,7 +342,7 @@
     *lsf_r1++ = *p_dico++;
     *lsf_r1++ = *p_dico++;
     *lsf_r1++ = *p_dico++;
-    *lsf_r1 = *p_dico++;
+    *lsf_r1 = *p_dico;
 
     return(index);
 
@@ -679,7 +675,7 @@
     /* Reading the selected vector */
     *lsf_r1++ = *p_dico++;
     *lsf_r1++ = *p_dico++;
-    *lsf_r1 = *p_dico++;
+    *lsf_r1 = *p_dico;
 
     return(index);
 }
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3_tbl.cpp
index 634e63b..533ca0d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_3_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,12 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
  Filename: /audio/gsm_amr/c/src/q_plsf_3_tbl.c
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +40,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5.cpp
index 1987296..2f9e40e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,15 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/q_plsf_5.c
  Funtions:
 
-     Date: 02/05/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -75,6 +69,7 @@
 
  Description: Added #ifdef __cplusplus around extern'ed table.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -295,7 +290,7 @@
     lsf_r1[0] = *p_dico++;
     lsf_r1[1] = *p_dico++;
     lsf_r2[0] = *p_dico++;
-    lsf_r2[1] = *p_dico++;
+    lsf_r2[1] = *p_dico;
 
     return index;
 
@@ -486,7 +481,7 @@
         lsf_r1[0] = - (*p_dico++);
         lsf_r1[1] = - (*p_dico++);
         lsf_r2[0] = - (*p_dico++);
-        lsf_r2[1] = - (*p_dico++);
+        lsf_r2[1] = - (*p_dico);
         index +=  1;
     }
     else
@@ -494,7 +489,7 @@
         lsf_r1[0] = *p_dico++;
         lsf_r1[1] = *p_dico++;
         lsf_r2[0] = *p_dico++;
-        lsf_r2[1] = *p_dico++;
+        lsf_r2[1] = *p_dico;
     }
 
     return index;
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5_tbl.cpp
index e955293..c26453e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/q_plsf_5_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,12 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
  Filename: /audio/gsm_amr/c/src/q_plsf_5_tbl.c
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -47,6 +43,7 @@
 
  Description: Put "extern" back.
 
+ Who: 						Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/qua_gain_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/qua_gain_tbl.cpp
index 777c445..f3cbe3e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/qua_gain_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/qua_gain_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,12 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
  Filename: /audio/gsm_amr/c/src/qua_gain_tbl.c
 
-     Date: 02/05/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -44,6 +40,7 @@
 
  Description: Put "extern" back.
 
+ Who:                               Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/reorder.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/reorder.cpp
index c428f51..b1e4711 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/reorder.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/reorder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Filename: /audio/gsm_amr/c/src/reorder.c
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -47,6 +41,7 @@
 
  Description:  Replaced "int" and/or "char" with OSCL defined types.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/residu.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/residu.cpp
index 9168e3b..b25d3be 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/residu.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/residu.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/residu.c
 
-     Date: 03/29/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -66,6 +61,7 @@
  Description: Changed round function name to pv_round to avoid conflict with
               round function in C standard library.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/round.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/round.cpp
index 1935cd9..7710be2 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/round.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/round.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/round.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -59,6 +54,7 @@
  Description: Changed function name to pv_round to avoid conflict with
               round function in C standard library.
 
+ Who:   					Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/set_zero.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/set_zero.cpp
index bdf94c0..be23b25 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/set_zero.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/set_zero.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr.cpp
index 240ae50..dbb1cea 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/shr.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -61,6 +56,7 @@
 
  Description: Further optimized typecasting for overflow case
 
+ Who:		  				Date:
  Description:
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr_r.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr_r.cpp
index 62f294d..6656f93 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr_r.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/shr_r.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,6 @@
 
  Pathname: ./gsm-amr/c/src/shr_r.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -40,6 +38,7 @@
 
  Description: Passing around pOverflow as per EPOC changes.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l.cpp
index 1f75872..2b77b44 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/sqrt_l.c
 
-     Date: 01/23/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -47,6 +42,7 @@
  Description: Removed inclusion of sqrt_l.tab file. Changed the array name
               "table" to "sqrt_l_tbl". Fixed typos.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l_tbl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l_tbl.cpp
index cc868db..c108196 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l_tbl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/sqrt_l_tbl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,13 +28,8 @@
 ****************************************************************************************/
 /*
 
-
-
-
  Filename: /audio/gsm_amr/c/src/sqrt_l_tbl.c
 
-     Date: 01/24/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -45,6 +40,7 @@
 
  Description: Put "extern" back.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/sub.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/sub.cpp
index 17f423c..d936128 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/sub.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/sub.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Filename: /audio/gsm_amr/c/src/sub.c
 
-     Date: 08/11/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -58,6 +53,7 @@
               1. Modified if-else structure to save cycles by processing
                  the most common case faster.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/syn_filt.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/syn_filt.cpp
index 060f1ae..5ffa044 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/syn_filt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/syn_filt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/syn_filt.c
 
-     Date: 03/27/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -88,6 +82,7 @@
 
  Description: Replacing fxp_arithmetic.h with basic_op.h.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/vad1.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/vad1.cpp
index c5867fe..7597d22 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/vad1.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/vad1.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,15 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
-
  Pathname: ./audio/gsm-amr/c/src/vad1.c
  Functions:
 
-     Date: 02/04/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -55,6 +49,7 @@
  Description: Changed round function name to pv_round to avoid conflict with
               round function in C standard library.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/weight_a.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/weight_a.cpp
index 4ea7e69..2e2efc4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/weight_a.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/weight_a.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,14 +27,9 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-------------------------------------------------------------------------------
-
-
 
  Pathname: ./audio/gsm-amr/c/src/weight_a.c
 
-     Date: 04/20/2000
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -57,6 +52,7 @@
  Description: Changed round function name to pv_round to avoid conflict with
               round function in C standard library.
 
+ Who:                           Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/common/src/window_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/common/src/window_tab.cpp
index 6a9e6f8..fa5faa6 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/common/src/window_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/common/src/window_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,8 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Pathname: .audio/gsm-amr/c/src/window_tab.c
 
-     Date: 01/31/2002
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
@@ -42,6 +39,7 @@
 
  Description: Put "extern" back.
 
+ Who:                       Date:
  Description:
 
 ------------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk b/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
index 52e5ece..65a327d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
@@ -3,61 +3,63 @@
 
 LOCAL_SRC_FILES := \
 	src/decoder_gsm_amr.cpp \
-	src/a_refl.cpp \
-	src/agc.cpp \
-	src/amrdecode.cpp \
-	src/b_cn_cod.cpp \
-	src/bgnscd.cpp \
-	src/c_g_aver.cpp \
-	src/d1035pf.cpp \
-	src/d2_11pf.cpp \
-	src/d2_9pf.cpp \
-	src/d3_14pf.cpp \
-	src/d4_17pf.cpp \
-	src/d8_31pf.cpp \
-	src/d_gain_c.cpp \
-	src/d_gain_p.cpp \
-	src/d_plsf.cpp \
-	src/d_plsf_3.cpp \
-	src/d_plsf_5.cpp \
-	src/dec_amr.cpp \
-	src/dec_gain.cpp \
-	src/dec_input_format_tab.cpp \
-	src/dec_lag3.cpp \
-	src/dec_lag6.cpp \
-	src/dtx_dec.cpp \
-	src/ec_gains.cpp \
-	src/ex_ctrl.cpp \
-	src/if2_to_ets.cpp \
-	src/int_lsf.cpp \
-	src/lsp_avg.cpp \
-	src/ph_disp.cpp \
-	src/post_pro.cpp \
-	src/preemph.cpp \
-	src/pstfilt.cpp \
-	src/qgain475_tab.cpp \
-	src/sp_dec.cpp \
-	src/wmf_to_ets.cpp
-
+ 	src/a_refl.cpp \
+ 	src/agc.cpp \
+ 	src/amrdecode.cpp \
+ 	src/b_cn_cod.cpp \
+ 	src/bgnscd.cpp \
+ 	src/c_g_aver.cpp \
+ 	src/d1035pf.cpp \
+ 	src/d2_11pf.cpp \
+ 	src/d2_9pf.cpp \
+ 	src/d3_14pf.cpp \
+ 	src/d4_17pf.cpp \
+ 	src/d8_31pf.cpp \
+ 	src/d_gain_c.cpp \
+ 	src/d_gain_p.cpp \
+ 	src/d_plsf.cpp \
+ 	src/d_plsf_3.cpp \
+ 	src/d_plsf_5.cpp \
+ 	src/dec_amr.cpp \
+ 	src/dec_gain.cpp \
+ 	src/dec_input_format_tab.cpp \
+ 	src/dec_lag3.cpp \
+ 	src/dec_lag6.cpp \
+ 	src/dtx_dec.cpp \
+ 	src/ec_gains.cpp \
+ 	src/ex_ctrl.cpp \
+ 	src/if2_to_ets.cpp \
+ 	src/int_lsf.cpp \
+ 	src/lsp_avg.cpp \
+ 	src/ph_disp.cpp \
+ 	src/post_pro.cpp \
+ 	src/preemph.cpp \
+ 	src/pstfilt.cpp \
+ 	src/qgain475_tab.cpp \
+ 	src/sp_dec.cpp \
+ 	src/wmf_to_ets.cpp
 
 
 LOCAL_MODULE := libpvdecoder_gsmamr
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/dec/include \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/dec/src \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/dec/../common/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/decoder_gsm_amr.h \
-	include/pvamrnbdecoder_api.h
+ 	include/pvamrnbdecoder_api.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make/local.mk b/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make/local.mk
new file mode 100644
index 0000000..9df9ddb
--- /dev/null
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make/local.mk
@@ -0,0 +1,59 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvdecoder_gsmamr
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS := ../../../common/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := decoder_gsm_amr.cpp \
+	a_refl.cpp \
+	agc.cpp \
+	amrdecode.cpp \
+	b_cn_cod.cpp \
+	bgnscd.cpp \
+	c_g_aver.cpp \
+	d1035pf.cpp \
+	d2_11pf.cpp \
+	d2_9pf.cpp \
+	d3_14pf.cpp \
+	d4_17pf.cpp \
+	d8_31pf.cpp \
+	d_gain_c.cpp \
+	d_gain_p.cpp \
+	d_plsf.cpp \
+	d_plsf_3.cpp \
+	d_plsf_5.cpp \
+	dec_amr.cpp \
+	dec_gain.cpp \
+	dec_input_format_tab.cpp \
+	dec_lag3.cpp \
+	dec_lag6.cpp \
+	dtx_dec.cpp \
+	ec_gains.cpp \
+	ex_ctrl.cpp \
+	if2_to_ets.cpp \
+	int_lsf.cpp \
+	lsp_avg.cpp \
+	ph_disp.cpp \
+	post_pro.cpp \
+	preemph.cpp \
+	pstfilt.cpp \
+	qgain475_tab.cpp \
+	sp_dec.cpp \
+	wmf_to_ets.cpp
+
+HDRS := decoder_gsm_amr.h pvamrnbdecoder_api.h
+
+include $(MK)/library.mk
+
+
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make/makefile b/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make/makefile
deleted file mode 100644
index 3967272..0000000
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make/makefile
+++ /dev/null
@@ -1,96 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pvdecoder_gsmamr
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DORIGINAL_TYPEDEF_H -DOSCL_BASE_H_INCLUDED -DOSCL_TYPES_H_INCLUDE -DOSCL_ASSERT_H_INCLUDED -DOSCL_MEM_BASIC_FUNCTIONS_H -DOSCL_MEM_IMP_H
-XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-XINCDIRS += -I ../../../common/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  decoder_gsm_amr.cpp \
-	a_refl.cpp \
-	agc.cpp \
-	amrdecode.cpp \
-	b_cn_cod.cpp \
-	bgnscd.cpp \
-	c_g_aver.cpp \
-	d1035pf.cpp \
-	d2_11pf.cpp \
-	d2_9pf.cpp \
-	d3_14pf.cpp \
-	d4_17pf.cpp \
-	d8_31pf.cpp \
-	d_gain_c.cpp \
-	d_gain_p.cpp \
-	d_plsf.cpp \
-	d_plsf_3.cpp \
-	d_plsf_5.cpp \
-	dec_amr.cpp \
-	dec_gain.cpp \
-	dec_input_format_tab.cpp \
-	dec_lag3.cpp \
-	dec_lag6.cpp \
-	dtx_dec.cpp \
-	ec_gains.cpp \
-	ex_ctrl.cpp \
-	if2_to_ets.cpp \
-	int_lsf.cpp \
-	lsp_avg.cpp \
-	ph_disp.cpp \
-	post_pro.cpp \
-	preemph.cpp \
-	pstfilt.cpp \
-	qgain475_tab.cpp \
-	sp_dec.cpp \
-	wmf_to_ets.cpp
-
-LIBS =
-
-HDRS = decoder_gsm_amr.h pvamrnbdecoder_api.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/include/decoder_gsm_amr.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/include/decoder_gsm_amr.h
index ea9053e..7db5211 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/include/decoder_gsm_amr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/include/decoder_gsm_amr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/include/pvamrnbdecoder_api.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/include/pvamrnbdecoder_api.h
index f791d2d..31887c4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/include/pvamrnbdecoder_api.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/include/pvamrnbdecoder_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,15 +27,13 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
  Name: pvamrnbdecoder_api.h
 
-     Date: 05/09/2007
-
 ------------------------------------------------------------------------------
  REVISION HISTORY
 
 
+ Who:                                       Date:
  Description:
 
 ------------------------------------------------------------------------------
@@ -47,15 +45,9 @@
  with the library. The internal data structures within the library are
  purposely hidden.
 
- ---* Need description of the input buffering. *-------
-
- ---* Need an example of calling the library here *----
-
 ------------------------------------------------------------------------------
  REFERENCES
 
-  (Normally header files do not have a reference section)
-
 ------------------------------------------------------------------------------
 */
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.cpp
index ff8fcf1..fb7cff3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.h
index e9ad5c1..4028e1e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/a_refl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.cpp
index d5c5b24..4c66d54 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,70 +40,6 @@
            agc
            agc2
 
-     Date: 03/28/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Fixed some problems with overflow and negative saturation.
-
- Description: Made changes based on comments from the review meeting. Removed
-    more calls to L_shl in agc and agc2.
-
- Description: Synchronized code with the UMTS version 3.2.0. Updated Pseudo-
-              code section on all functions to show the latest version of
-              code that was optimized. Removed hard tabs. Updated to most
-              current PV coding template.
-
- Description: Removed basic_op.h and replaced it with the header files of
-              the math functions used by the file. Removed unnecessary
-              include files.
-
- Description: Made the following changes per comments from Phase 2/3 review:
-              1. Changed FOR loops to count down.
-              2. Reordered IF statement to take advantage of branch prediction.
-              3. Declared one local variable per line.
-              4. Copied detailed function description of agc() from the
-                 header file.
-              5. Made minor cosmetic changes.
-              6. Fixed typecasting issue using a TI C compiler.
-
- Description: Made the following changes to make the library EPOC compatible.
-             1. energy_old(): Passed in pointer to overflow flag. Changed
-              call to L_add() to include overflow flag.
-              2. energy_new(): Passed in pointer to overflow flag. Changed
-              function calls to L_add() and energy_old() to include overflow
-              flag.
-              3. agc(): Passed in pointer to overflow flag. Changed function
-              calls to energy_new(), L_shl(), round(), L_shr(), Inv_sqrt(),
-              mult(), add() and L_mult() to include overflow flag.
-              3. agc2(): Passed in pointer to overflow flag. Changed function
-              calls to energy_new(), L_shl(), round(), L_shr(), Inv_sqrt(),
-              mult(), add() and L_mult() to include overflow flag.
-
- Description: Added wrapper functions for energy_old() and energy_new() for
-             access by unit tests.
- Description: Corrected return type for energy_old() and energy_new() wrapper
-              functions. Removed unneeded header files. Cleaned up code.
-
- Description: Fixed bug found in the FOR loop calculation of gain[n] in agc().
-              Updated copyright year.
-
- Description: Removed the functions agc_init() and agc_exit().  The agc
- related structure is no longer dynamically allocated.
-
- Description: Updated Ouputs section for all functions.
-
- Description: Optimized agc() to reduce clock cycle usage. Updated
-              copyright year and removed unused files in Include section.
-
- Description: Changed function name to pv_round to avoid conflict with
-              round function in C standard library.
-
- Description: Removed the usage of l_deposit_l().
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
@@ -237,23 +173,13 @@
 
 {
     Word32  s = 0;
-    Word32  L_temp;
     Word16  i;
     Word16  temp;
 
-    for (i = l_trm - 1; i >= 0; i--)
+    for (i = 0; i < l_trm; i++)
     {
-        temp = in[i];
-        if (temp < 0)
-        {
-            temp = ~(~temp >> 2);
-        }
-        else
-        {
-            temp = temp >> 2;
-        }
-        L_temp = (((Word32) temp) * temp) << 1;
-        s = L_add(s, L_temp, pOverflow);
+        temp = in[i] >> 2;
+        s = L_mac(s, temp, temp, pOverflow);
     }
 
     return(s);
@@ -449,25 +375,16 @@
 
 {
     Word32  s = 0;
-    Word32  L_temp;
     Word16  i;
     Flag    ov_save;
 
     ov_save = *(pOverflow);  /* save overflow flag in case energy_old */
     /* must be called                        */
 
-    for (i = l_trm - 1; i >= 0; i--)
+
+    for (i = 0; i < l_trm; i++)
     {
-        L_temp = ((Word32) in[i]) * in[i];
-        if (L_temp != (Word32) 0x40000000L)
-        {
-            L_temp = L_temp << 1;
-        }
-        else
-        {
-            L_temp = MAX_32;
-        }
-        s = L_add(s, L_temp, pOverflow);
+        s = L_mac(s, in[i], in[i], pOverflow);
     }
 
     /* check for overflow */
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.h
index 9c3510e..9788caa 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/agc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.cpp
index 02e3560..eab24a3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.h
index aab3659..db951b9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/amrdecode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.cpp
index 61875c7..30d3fee 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.h
index 29c15e2..743237c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/b_cn_cod.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.cpp
index a7195a2..50f603d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,51 +29,11 @@
 /*
 ------------------------------------------------------------------------------
 
-
-
  Pathname: ./audio/gsm-amr/c/src/bgnscd.c
  Functions:
            Bgn_scd_reset
            Bgn_scd
 
-     Date: 03/28/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made prereview changes so the structure of the module conforms
-    with the others. Added checks for overflow on the shift functions.
-
- Description: Made changes based on comments from the review meeting.
-
- Description: Fixed a bug found during unit testing.
-
- Description: Synchronized code with UMTS version 3.2.0. Updated coding
-              template.
-
- Description: Made the following changes per comments from Phase 2/3 review:
-              1. Used TRUE/FALSE #defines instead of hard-coded 1/0 in
-                 Bgn_scd code.
-              2. Fixed typecasting issue with TI compiler.
-              3. Modified FOR loop to count down.
-
- Description: Modified FOR loop on line 740 to count up.
-
- Description: Removed the functions bgn_scd_init and bgn_scd_exit.
- The bgn_scd related structure is no longer dynamically allocated.
-
- Description: Making changes for EPOC. Passing in pOverflow instead of having
-              it act as a global variable. Updated include files and added
-              more description about pOverflow.
-
- Description:  Replaced OSCL mem type functions and eliminated include
-               files that now are chosen by OSCL definitions
-
- Description:  Replaced "int" and/or "char" with defined types.
-               Added proper casting (Word32) to some left shifting operations
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.h
index 226e3e2..41349d9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/bgnscd.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.cpp
index 11981bb..37e262c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.h
index 049b86c..0b53753 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/c_g_aver.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.cpp
index 43c37c1..899daba 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.h
index b4cecee..e3bbf4c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d1035pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.cpp
index adee421..e1e544f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.h
index 08aeb8a..aaf2e08 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_11pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.cpp
index 7a8dd38..2c36706 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.h
index 0398900..38076d8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d2_9pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.cpp
index 6ec4629..d1912cf 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.h
index 8845b39..1e2e0cd 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d3_14pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.cpp
index 93063fb..ece82c0 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.h
index 5ac4d97..5dc43f3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d4_17pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.cpp
index 63aabda..4cc8db4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.h
index da6f94e..162685f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d8_31pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_c.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_c.cpp
index 1433a02..b016de8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_c.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_c.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_p.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_p.cpp
index bd2ada9..99446db 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_p.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_gain_p.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf.cpp
index 17ffe08..0dab255 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_3.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_3.cpp
index ecf7452..38ca513 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_3.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_3.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,33 +34,6 @@
  Pathname: ./audio/gsm-amr/c/src/d_plsf_3.c
  Functions: D_plsf_3
 
-     Date: 01/31/2002
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated to accept new parameter, Flag *pOverflow.  Placed
- file in the proper PV Software template.
-
- Description:
- (1) Removed "count.h" and "basic_op.h" and replaced with individual include
-     files (add.h, sub.h, etc.)
-
- Description:
- (1) Removed optimization -- mult(i, 3, pOverflow) is NOT the same as adding
-     i to itself 3 times.  The reason is because the mult function does a
-     right shift by 15, which will obliterate smaller numbers.
-
- Description:
- (1) Logic error -- a comparison against zero should have been DOES NOT EQUAL
- zero, but instead, was translated into EQUALS ZERO.  The bug has been fixed.
-
- Description:  Replaced "int" and/or "char" with OSCL defined types.
-
- Description: Added #ifdef __cplusplus around extern'ed table.
-
- Description:
-
  ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_5.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_5.cpp
index 3c5d895..08b690d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_5.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/d_plsf_5.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.cpp
index 28d6df2..3241354 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,66 +29,11 @@
 /*
 ------------------------------------------------------------------------------
 
-
-
  Pathname: ./audio/gsm-amr/c/src/dec_amr.c
  Funtions: Decoder_amr_init
            Decoder_amr_reset
            Decoder_amr
 
-     Date: 04/11/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated template used to PV coding template. First attempt at
-          optimizing C code.
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include files.
-
- Description: Made the following changes per comments from Phase 2/3 review:
-              1. Fixed Input/Output descriptions by adding typedefs and
-                 clarifying definitions.
-              2. Used #define instead of hard-coded loop counts.
-              3. Modified FOR loops to count down.
-              4. Copied function descriptions from dec_amr.h header file.
-              5. Defined one local variable per line.
-
- Description: Copied function descriptions from header file (forgot to do it
-              prior to checking-in -- oops!).
-
- Description: Removed the function decoder_amr_exit.
- The decoder_amr related structure is no longer dynamically allocated.
-
- Also, modified function calls throughout to reflect the fact that the members
- of the structure Decoder_amrState are no longer pointers to be set via
- malloc, but full-blown structures.  (Changes of the type D_plsfState *lsfState
- to D_plsfState lsfState)
-
- Description: Fixed bug in the Decoder_amr() caused non-bit exactness. The
-              Overflow flag was inadvertently taken out of the IF statement
-              that calls agc2 and Syn_filt. It was restored to the original
-              form. Updated copyright year.
-
- Description: Adding changes for EPOC regarding pOverflow being passed in
-              rather than being a global variable.
-
- Description: Initialize overflow flag in Decoder_amr_init() and
-               Decoder_amr_reset(). Initialize pointer to overflow flag in
-               Decoder_amr().
-
- Description: Changed round function name to pv_round to avoid conflict with
-              round function in C standard library.
-
- Description:  Replaced OSCL mem type functions and eliminated include
-               files that now are chosen by OSCL definitions
-
- Description:  Replaced "int" and/or "char" with defined types.
-               Added proper casting (Word32) to some left shifting operations
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.h
index d7574ca..a229243 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_amr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.cpp
index 9765386..eae7e61 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.h
index c7c43ec..b9c6a8d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_gain.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_input_format_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_input_format_tab.cpp
index e24c76c..a59f5fa 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_input_format_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_input_format_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.cpp
index 0276234..70baaba 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.h
index 4c562f4..0679973 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag3.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.cpp
index 13084e0..7dc7a8d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.h
index e44b31f..7322bc8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dec_lag6.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr.cpp
index f5859a6..6f1566b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,17 +26,12 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
-//                                                                              //
-//  File: decoder_gsm_amr.cpp                                                   //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
 #include "decoder_gsm_amr.h"
 #include "sp_dec.h"
 #include "amrdecode.h"
 #include "pvamrnbdecoder_api.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 #include "oscl_error_codes.h"
 #include "oscl_exception.h"
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr_dpi.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr_dpi.h
deleted file mode 100644
index e548f30..0000000
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/decoder_gsm_amr_dpi.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/****************************************************************************************
-Portions of this file are derived from the following 3GPP standard:
-
-    3GPP TS 26.073
-    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
-    Available from http://www.3gpp.org
-
-(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
-Permission to distribute, modify and use this file under the standard license
-terms listed above has been obtained from the copyright holder.
-****************************************************************************************/
-//////////////////////////////////////////////////////////////////////////////////
-//																				//
-//	File: Decoder_GSMAMR.h	                                                    //
-//																				//
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef __DECODER_GSMAMR_H
-#define __DECODER_GSMAMR_H
-
-//#include "gsmamr_dec.h"
-#include "oscl_base.h"
-//#include "PVGSMAMRDecoder.h"
-#include "gsmamrdpidecoder.h"
-
-
-// CDecoder_GSMAMR
-class CDecoder_GSMAMR
-{
-    public:
-        OSCL_IMPORT_REF void ConstructL();
-        OSCL_IMPORT_REF static CDecoder_GSMAMR *CDecoder_GSMAMR::NewL();
-        OSCL_IMPORT_REF ~CDecoder_GSMAMR();
-        OSCL_IMPORT_REF CDecoder_GSMAMR() : iDsp(NULL), iAudioAmrDecoder(NULL), iDecState(NULL) {};
-
-        OSCL_IMPORT_REF int32 StartL();
-
-        OSCL_IMPORT_REF int32 ExecuteL(Frame_Type_3GPP aType[],
-                                       uint8* aCompressedBlock, uint8* aAudioBuffer, int32 aFormat);
-
-        OSCL_IMPORT_REF int32 ExecuteL(Frame_Type_3GPP aType,
-                                       uint8* aCompressedBlock, uint8* aAudioBuffer, int32 aFormat);
-
-        OSCL_IMPORT_REF int32 ResetDecoderL(void);
-        OSCL_IMPORT_REF void StopL();
-        OSCL_IMPORT_REF void TerminateDecoderL();
-
-    private:
-        void* iDecState;
-        CPvGsmAmrDPIDecoder *iAudioAmrDecoder;
-        CPVDsp	*iDsp;
-};
-
-#endif
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.cpp
index 89590d0..6565270 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,54 +38,6 @@
            dtx_dec_activity_update
            rx_dtx_handler
 
-     Date: 04/17/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: First attempt at optimization.
-
- Description: Made changes based on comments from the review.
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include files.
-
- Description: Made the following changes per comments from Phase 2/3 review:
-              1. Modified FOR loops to count down.
-              2. Made some cosmetic changes.
-              3. Replaced call to "abs" with "abs_s".
-              4. Added lsp.tab and q_plsf_5.tab to the Include section.
-              5. Fixed typecasting issue with TI C compiler.
-              6. Replaced basic_op.h and oper_32b.h with the header files
-                 of the math functions used by the file.
-
- Description: Removed the functions dtx_dec_init and dtx_dec_exit.
- The dtx_dec related structure is no longer dynamically allocated.
-
- Description: Made the following changes to make code bit-exact:
-              1. Fixed inlining of shl() function in parts of dtx_dec and
-                 dtx_dec_activity_update functions.
-              2. Fixed optimazation bugs in dtx_dec function.
-              3. Modified some FOR loops in dtx_dec to count up.
-              4. Added call to add() function in rx_dtx_handler function.
-              5. Updated copyright year.
-
- Description: Passing in pOverflow rather than accessing it as a global
-              variable.
-
- Description: Synchronized file with UMTS (3GPP) version 3.3.0 == GSM version
-              7.6.0 == 3GPP Release 4, version 4.1.0.
-
- Description: Removed call to test() on line 843.
-
- Description:  Replaced OSCL mem type functions and eliminated include
-               files that now are chosen by OSCL definitions
-
- Description:  Replaced "int" and/or "char" with defined types.
-               Added proper casting (Word32) to some left shifting operations
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.h
index 0bf1df1..2b5a614 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/dtx_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.cpp
index 3d91868..e73db62 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.h
index c774c5e..e05a0af 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ec_gains.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.cpp
index 3e7c050..f18054b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.h
index a3e895b..e055035 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ex_ctrl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/gsmamr_dec.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/gsmamr_dec.h
index 1f9f450..673a94a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/gsmamr_dec.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/gsmamr_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.cpp
index 5a0a25a..0d24fc8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,26 +29,9 @@
 /*
 ------------------------------------------------------------------------------
 
-
-
  Pathname: ./audio/gsm-amr/c/src/if2_to_ets.c
  Funtions: if2_to_ets
 
-     Date: 01/21/2002
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed mode into frame_type_3gpp. Modified the function to save
-              memory and improve speed. bitreorder.h was changed to
-              bitreorder_tab.h.
-
- Description: Fixed a bug in the code where the third FOR loop executes more
-              than it should.
-
- Description:
-
-------------------------------------------------------------------------------
 */
 
 /*----------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.h
index d87c4b3..df3d289 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/if2_to_ets.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/int_lsf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/int_lsf.cpp
index d32210b..c5aefe4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/int_lsf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/int_lsf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.cpp
index d930716..790ba95 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.h
index d9efb84..b289c08 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/lsp_avg.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.cpp
index d48b05e..da5445b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.h
index 8054c3c..d0ffa2a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/ph_disp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.cpp
index 89ff761..ce31793 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.h
index a3141aa..85e5888 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/post_pro.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.cpp
index 887e614..9864325 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.h
index 4b8683e..20bab71 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/preemph.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.cpp
index 602efaa..8d5e85d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.h
index cb06e4d..29c0d84 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pstfilt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.cpp
index d0b5eea..95b0b47 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,10 +26,6 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
-//                                                                              //
-//  File: PVGSMAMRDecoder.cpp                                                   //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
 
 #include "PVGSMAMRDecoder.h"
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.h
index b8392a7..bfdc07d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,10 +26,6 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
-//                                                                              //
-//  File: PVGSMAMRDecoder.h                                                     //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
 
 #ifndef __PVGSMAMRDECODER_H
 #define __PVGSMAMRDECODER_H
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder_dpi.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder_dpi.h
index 5171114..09c778e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder_dpi.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/pvgsmamrdecoder_dpi.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,10 +26,6 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
-//                                                                              //
-//  File: PVGSMAMRDecoder.h                                                     //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
 
 #ifndef __PVGSMAMRDECODER_H
 #define __PVGSMAMRDECODER_H
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/qgain475_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/qgain475_tab.cpp
index 39c7fb2..33b551e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/qgain475_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/qgain475_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.cpp
index 570ab2d..b685b5e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
 
  Description: Add PV coding template. Filled out template sections and
               reformatted code to follow C coding standard. Removed code that
-              was put in to handle SID in GSMFrameDecode.
+              handles SID in GSMFrameDecode.
 
  Description: Made the following changes per comments from Phase 2/3 review:
               1. Updated to more recent PV C coding template.
@@ -267,7 +267,12 @@
     if (Decoder_amr_init(&s->decoder_amrState)
             || Post_Process_reset(&s->postHP_state))
     {
-        void** tempVoid = (void**) & s;
+        Speech_Decode_FrameState *tmp = s;
+        /*
+         *  dereferencing type-punned pointer avoid
+         *  breaking strict-aliasing rules
+         */
+        void** tempVoid = (void**) tmp;
         GSMDecodeFrameExit(tempVoid);
         return (-1);
     }
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.h b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.h
index b63ea4f..e61519d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/sp_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/wmf_to_ets.cpp b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/wmf_to_ets.cpp
index 4d4ca44..4dfbb67 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/dec/src/wmf_to_ets.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/dec/src/wmf_to_ets.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk b/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk
index 2d3cf52..01810b3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk
@@ -3,82 +3,84 @@
 
 LOCAL_SRC_FILES := \
 	src/amrencode.cpp \
-	src/autocorr.cpp \
-	src/c1035pf.cpp \
-	src/c2_11pf.cpp \
-	src/c2_9pf.cpp \
-	src/c3_14pf.cpp \
-	src/c4_17pf.cpp \
-	src/c8_31pf.cpp \
-	src/calc_cor.cpp \
-	src/calc_en.cpp \
-	src/cbsearch.cpp \
-	src/cl_ltp.cpp \
-	src/cod_amr.cpp \
-	src/convolve.cpp \
-	src/cor_h.cpp \
-	src/cor_h_x.cpp \
-	src/cor_h_x2.cpp \
-	src/corrwght_tab.cpp \
-	src/dtx_enc.cpp \
-	src/enc_lag3.cpp \
-	src/enc_lag6.cpp \
-	src/enc_output_format_tab.cpp \
-	src/ets_to_if2.cpp \
-	src/ets_to_wmf.cpp \
-	src/g_adapt.cpp \
-	src/g_code.cpp \
-	src/g_pitch.cpp \
-	src/gain_q.cpp \
-	src/hp_max.cpp \
-	src/inter_36.cpp \
-	src/inter_36_tab.cpp \
-	src/l_comp.cpp \
-	src/l_extract.cpp \
-	src/l_negate.cpp \
-	src/lag_wind.cpp \
-	src/lag_wind_tab.cpp \
-	src/levinson.cpp \
-	src/lpc.cpp \
-	src/ol_ltp.cpp \
-	src/p_ol_wgh.cpp \
-	src/pitch_fr.cpp \
-	src/pitch_ol.cpp \
-	src/pre_big.cpp \
-	src/pre_proc.cpp \
-	src/prm2bits.cpp \
-	src/q_gain_c.cpp \
-	src/q_gain_p.cpp \
-	src/qgain475.cpp \
-	src/qgain795.cpp \
-	src/qua_gain.cpp \
-	src/s10_8pf.cpp \
-	src/set_sign.cpp \
-	src/sid_sync.cpp \
-	src/sp_enc.cpp \
-	src/spreproc.cpp \
-	src/spstproc.cpp \
-	src/ton_stab.cpp \
-	src/gsmamr_encoder_wrapper.cpp
-
+ 	src/autocorr.cpp \
+ 	src/c1035pf.cpp \
+ 	src/c2_11pf.cpp \
+ 	src/c2_9pf.cpp \
+ 	src/c3_14pf.cpp \
+ 	src/c4_17pf.cpp \
+ 	src/c8_31pf.cpp \
+ 	src/calc_cor.cpp \
+ 	src/calc_en.cpp \
+ 	src/cbsearch.cpp \
+ 	src/cl_ltp.cpp \
+ 	src/cod_amr.cpp \
+ 	src/convolve.cpp \
+ 	src/cor_h.cpp \
+ 	src/cor_h_x.cpp \
+ 	src/cor_h_x2.cpp \
+ 	src/corrwght_tab.cpp \
+ 	src/dtx_enc.cpp \
+ 	src/enc_lag3.cpp \
+ 	src/enc_lag6.cpp \
+ 	src/enc_output_format_tab.cpp \
+ 	src/ets_to_if2.cpp \
+ 	src/ets_to_wmf.cpp \
+ 	src/g_adapt.cpp \
+ 	src/g_code.cpp \
+ 	src/g_pitch.cpp \
+ 	src/gain_q.cpp \
+ 	src/hp_max.cpp \
+ 	src/inter_36.cpp \
+ 	src/inter_36_tab.cpp \
+ 	src/l_comp.cpp \
+ 	src/l_extract.cpp \
+ 	src/l_negate.cpp \
+ 	src/lag_wind.cpp \
+ 	src/lag_wind_tab.cpp \
+ 	src/levinson.cpp \
+ 	src/lpc.cpp \
+ 	src/ol_ltp.cpp \
+ 	src/p_ol_wgh.cpp \
+ 	src/pitch_fr.cpp \
+ 	src/pitch_ol.cpp \
+ 	src/pre_big.cpp \
+ 	src/pre_proc.cpp \
+ 	src/prm2bits.cpp \
+ 	src/q_gain_c.cpp \
+ 	src/q_gain_p.cpp \
+ 	src/qgain475.cpp \
+ 	src/qgain795.cpp \
+ 	src/qua_gain.cpp \
+ 	src/s10_8pf.cpp \
+ 	src/set_sign.cpp \
+ 	src/sid_sync.cpp \
+ 	src/sp_enc.cpp \
+ 	src/spreproc.cpp \
+ 	src/spstproc.cpp \
+ 	src/ton_stab.cpp \
+ 	src/gsmamr_encoder_wrapper.cpp
 
 
 LOCAL_MODULE := libpvencoder_gsmamr
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/enc/include \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/enc/src \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/enc/../common/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/gsmamr_encoder_wrapper.h
+ 	include/gsmamr_encoder_wrapper.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make/local.mk b/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make/local.mk
new file mode 100644
index 0000000..6e2ec66
--- /dev/null
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make/local.mk
@@ -0,0 +1,89 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+
+TARGET := pvencoder_gsmamr
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS += 
+
+XINCDIRS +=  ../../../common/include
+
+XLIBDIRS += 
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := amrencode.cpp \
+	autocorr.cpp \
+	c1035pf.cpp \
+	c2_11pf.cpp \
+	c2_9pf.cpp \
+	c3_14pf.cpp \
+	c4_17pf.cpp \
+	c8_31pf.cpp \
+	calc_cor.cpp \
+	calc_en.cpp \
+	cbsearch.cpp \
+	cl_ltp.cpp \
+	cod_amr.cpp \
+	convolve.cpp \
+	cor_h.cpp \
+	cor_h_x.cpp \
+	cor_h_x2.cpp \
+	corrwght_tab.cpp \
+	dtx_enc.cpp \
+	enc_lag3.cpp \
+	enc_lag6.cpp \
+	enc_output_format_tab.cpp \
+	ets_to_if2.cpp \
+	ets_to_wmf.cpp \
+	g_adapt.cpp \
+	g_code.cpp \
+	g_pitch.cpp \
+	gain_q.cpp \
+	hp_max.cpp \
+	inter_36.cpp \
+	inter_36_tab.cpp \
+	l_comp.cpp \
+	l_extract.cpp \
+	l_negate.cpp \
+	lag_wind.cpp \
+	lag_wind_tab.cpp \
+	levinson.cpp \
+	lpc.cpp \
+	ol_ltp.cpp \
+	p_ol_wgh.cpp \
+	pitch_fr.cpp \
+	pitch_ol.cpp \
+	pre_big.cpp \
+	pre_proc.cpp \
+	prm2bits.cpp \
+	q_gain_c.cpp \
+	q_gain_p.cpp \
+	qgain475.cpp \
+	qgain795.cpp \
+	qua_gain.cpp \
+	s10_8pf.cpp \
+	set_sign.cpp \
+	sid_sync.cpp \
+	sp_enc.cpp \
+	spreproc.cpp \
+	spstproc.cpp \
+	ton_stab.cpp \
+	gsmamr_encoder_wrapper.cpp 
+
+HDRS := gsmamr_encoder_wrapper.h
+
+LIBS =
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make/makefile b/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make/makefile
deleted file mode 100644
index a100636..0000000
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make/makefile
+++ /dev/null
@@ -1,118 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pvencoder_gsmamr
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DORIGINAL_TYPEDEF_H -DOSCL_BASE_H_INCLUDED -DOSCL_TYPES_H_INCLUDE -DOSCL_ASSERT_H_INCLUDED -DOSCL_MEM_BASIC_FUNCTIONS_H -DOSCL_MEM_IMP_H
-XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-XINCDIRS += -I ../../../common/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  amrencode.cpp \
-	autocorr.cpp \
-	c1035pf.cpp \
-	c2_11pf.cpp \
-	c2_9pf.cpp \
-	c3_14pf.cpp \
-	c4_17pf.cpp \
-	c8_31pf.cpp \
-	calc_cor.cpp \
-	calc_en.cpp \
-	cbsearch.cpp \
-	cl_ltp.cpp \
-	cod_amr.cpp \
-	convolve.cpp \
-	cor_h.cpp \
-	cor_h_x.cpp \
-	cor_h_x2.cpp \
-	corrwght_tab.cpp \
-	dtx_enc.cpp \
-	enc_lag3.cpp \
-	enc_lag6.cpp \
-	enc_output_format_tab.cpp \
-	ets_to_if2.cpp \
-	ets_to_wmf.cpp \
-	g_adapt.cpp \
-	g_code.cpp \
-	g_pitch.cpp \
-	gain_q.cpp \
-	hp_max.cpp \
-	inter_36.cpp \
-	inter_36_tab.cpp \
-	l_comp.cpp \
-	l_extract.cpp \
-	l_negate.cpp \
-	lag_wind.cpp \
-	lag_wind_tab.cpp \
-	levinson.cpp \
-	lpc.cpp \
-	ol_ltp.cpp \
-	p_ol_wgh.cpp \
-	pitch_fr.cpp \
-	pitch_ol.cpp \
-	pre_big.cpp \
-	pre_proc.cpp \
-	prm2bits.cpp \
-	q_gain_c.cpp \
-	q_gain_p.cpp \
-	qgain475.cpp \
-	qgain795.cpp \
-	qua_gain.cpp \
-	s10_8pf.cpp \
-	set_sign.cpp \
-	sid_sync.cpp \
-	sp_enc.cpp \
-	spreproc.cpp \
-	spstproc.cpp \
-	ton_stab.cpp \
-	gsmamr_encoder_wrapper.cpp 
-
-HDRS = gsmamr_encoder_wrapper.h
-
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/include/gsmamr_encoder_wrapper.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/include/gsmamr_encoder_wrapper.h
index 1451fe3..6de9c69 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/include/gsmamr_encoder_wrapper.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/include/gsmamr_encoder_wrapper.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -153,7 +153,7 @@
         //                      d0 d1 d2 d3 d4 d5 d6 d7
         // USAGE:       The authoring application is required to fill this in.
         //              The CAEI will use the value to setup the codec library.
-        bool iBitStreamFormatIf2;
+        int32 iBitStreamFormat;
 
         // DESCRIPTION: Audio object type for the output bitstream; only applies
         //              to AAC codec
@@ -246,6 +246,12 @@
         */
         OSCL_IMPORT_REF int32 CleanupEncoder();
 
+        /**
+        *  This function reset the encoder workspace.
+        */
+        OSCL_IMPORT_REF int32 Reset();
+
+
     public:
         // GSM AMR modes
         // ** values should be the same as the Mode enum specified by AMR library
@@ -296,7 +302,7 @@
         int32 iMaxOutputBufferSize;
 
         // bit stream format
-        int32 iBitStreamFormatIf2;
+        int32 iBitStreamFormat;
 
 };
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.cpp
index 958d52b..d07c846 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.h
index f96f6b4..1e85db1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/amrencode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.cpp
index 0a01702..0d3acac 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.h
index e7d83a0..6045d6e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/autocorr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.cpp
index 288f48e..83c7a71 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.h
index 8f394a5..be45cbb 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c1035pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.cpp
index cd6b73a..87fa9b8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.h
index c4a10fb..f963ae1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_11pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.cpp
index cec7851..a33cdf7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.h
index c69f261..203e1d9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c2_9pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.cpp
index 0b96f49..58ab2fa 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.h
index 87b89ae..15e2f1a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c3_14pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.cpp
index 5a11a69..d52b43b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.h
index a8dc672..4dc66a9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c4_17pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.cpp
index a9713ce..07c2efd 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.h
index d868d31..03225ce 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/c8_31pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.cpp
index 6f16056..db786a6 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.h
index e683d02..d96a70e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_cor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.cpp
index 083ed61..6cf6867 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,41 +36,6 @@
            calc_filt_energies
            calc_target_energy
 
-     Date: 06/16/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  After review changes
-
- Description:  Replaced the inlined code for norm_l and saturation checks
-    with the original code to fix a bug with 4.75k encode.
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include files.
-
- Description: Replaced basic_op.h and oper_32b.h with the header files of the
-              math functions used by the file.
-
- Description: Undid optimization in the loop that calculates various dot
-              products in calc_filt_energies. Added calls to L_mac function
-              instead of doing a straight multiply-accumulate. Updated
-              copyright year. Fixed typecasting issue with TI C compiler.
-
- Description: Add pOverflow as a passed in variable for the EPOC changes.
-              Updated code as per review comments regarding pOverflow.
-
- Description: Changed round function name to pv_round to avoid conflict with
-              round function in C standard library.
-
- Description:  Replaced "int" and/or "char" with OSCL defined types.
-
- Description: Using inlines from fxp_arithmetic.h .
-
- Description: Replacing fxp_arithmetic.h with basic_op.h.
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.h
index 0a47460..052f5b4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/calc_en.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.cpp
index 880c2ff..a02b891 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.h
index 992fda0..4e28007 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cbsearch.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.cpp
index f6d4d4e..c9cc350 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.h
index 2502b0b..3e9b587 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cl_ltp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.cpp
index 95c3e87..1be361a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.h
index 69ad979..7360c0a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cod_amr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.cpp
index e75c102..e9ce7ba 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.h
index 4ee03ee..1f2b503 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/convolve.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.cpp
index 3838472..e46d99f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.h
index 65a02b7..2132859 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,44 +26,6 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
-/*
-
- Pathname: ./audio/gsm-amr/c/include/cor_h.h
-
-     Date: 09/07/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Created separate header file for cor_h_x. Sync'ed up with the
-	      PV header template. Added include to cor_h_x.h for legacy files
-	      that include cor_h.h when invoking cor_h_x function.
-
- Description: Added cor_h_x2.h in the include section.
-
- Description: Removed cnst.h in the Include section. Putting it here confuses
-              Visual C++ when building the unit test. The source code
-              includes cnst.h prior to cor_h.h.
-
- Description: Updated copyright year and pathname.
-
- Description: Updated function prototype to reflect
- inclusion of pOverflow flag.
-
- Description: Updated template to make it build in Symbian. Updated copyright
-              year.
-
- Description: Moved _cplusplus #ifdef after Include section.
-
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file contains prototype declaration for cor_h function.
-
-------------------------------------------------------------------------------
-*/
 /*----------------------------------------------------------------------------
 ; CONTINUE ONLY IF NOT ALREADY DEFINED
 ----------------------------------------------------------------------------*/
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.cpp
index 042bf19..beb2aec 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.h
index 478b0e7..0073ff5 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,26 +27,6 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
- Pathname: ./include/cor_h_x.h
-
-     Date: 09/07/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Created separate header file for cor_h_x.
-
- Description: Changed to reflect inclusion of pOverflow flag in the cor_h_x
- function.
-
- Description: Updated template to make it build in Symbian. Updated copyright
-              year.
-
- Description: Moved _cplusplus #ifdef after Include section.
-
- Description:
-
 ------------------------------------------------------------------------------
  INCLUDE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.cpp
index a6ec3f9..da60640 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.h
index 92b3972..f2b482c 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/cor_h_x2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/corrwght_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/corrwght_tab.cpp
index d3aa5e6..9a73ea1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/corrwght_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/corrwght_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.cpp
index 66e55a5..0e2b8f4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.h
index e2ace23..5bb168d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/dtx_enc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.cpp
index 040f38d..a1fc008 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.h
index 557445b..949cd97 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag3.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.cpp
index bdb4673..2c7863e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.h
index e71c98a..0438321 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_lag6.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_output_format_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_output_format_tab.cpp
index b0c4b25..147989f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_output_format_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/enc_output_format_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.cpp
index 5ec1d28..01b8627 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,35 +29,9 @@
 /*
 ------------------------------------------------------------------------------
 
-
-
  Pathname: ./audio/gsm-amr/c/src/ets_to_if2.c
  Funtions: ets_to_if2
 
-     Date: 01/23/2002
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Added new method of formatting the frame for modes greater than
-              eight. This is to improve speed and was done per review comments.
-              bitreorder.h was changed to bitreorder_tab.h
-
- Description: Removed the #define of 244 for MAX_NUM_BITS since it was not
-              used in this function and should not have been defined in this
-              local way.
-
- Description: Added IF statement around packing of first octet for the case
-              where frame_type_3gpp >= AMR_SID.
-
- Description: Fixed bug that causes code to overwrite the memory location
-              one past the last location of the IF2 output buffer.
-
- Description:  Replaced "int" and/or "char" with OSCL defined types.
-
- Description:
-
-------------------------------------------------------------------------------
 */
 
 /*----------------------------------------------------------------------------
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.h
index 1785c13..5503706 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_if2.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.cpp
index ef69de4..9da3fb8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.h
index f60e6e8..3ff6f27 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ets_to_wmf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.cpp
index 5984d28..73114f2 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.h
index 275adaa..2ea508b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_adapt.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.cpp
index 5fa9597..f937cb7 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.h
index 89eff15..c62cba6 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_code.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.cpp
index 0142334..f6235ad 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.h
index b21e4af..6ea06ea 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/g_pitch.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.cpp
index 5d82158..67510e8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.h
index 4ac8d0f..a5c7f4e 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gain_q.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_enc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_enc.h
index f34ad04..390a44d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_enc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_enc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_encoder_wrapper.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_encoder_wrapper.cpp
index 364c1a7..20021b0 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_encoder_wrapper.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/gsmamr_encoder_wrapper.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@
     iSidState = NULL;
     iGsmAmrMode = (GSM_AMR_MODES)KDFLT_GAMR_MODE;
     iLastModeUsed = 0;
-    iBitStreamFormatIf2 = AMR_TX_WMF;
+    iBitStreamFormat = AMR_TX_WMF;
     iNumSamplesPerFrame = KGAMR_NUM_SAMPLES_PER_FRAME;
 }
 ///////////////////////////////////////////////////////////////////////////////
@@ -99,7 +99,7 @@
         dfltProps.iInClockRate = dfltProps.iInSamplingRate;
         dfltProps.iInNumChannels = KDFLT_GAMR_NUM_CHANNELS;
         iGsmAmrMode = (GSM_AMR_MODES)KDFLT_GAMR_MODE;
-        iBitStreamFormatIf2 = AMR_TX_WMF;
+        iBitStreamFormat = AMR_TX_WMF;
     }
     else
     {
@@ -114,13 +114,17 @@
         }
         // set AMR mode (bits per second)
         iGsmAmrMode = (GSM_AMR_MODES)aProps->iMode;
-        if (aProps->iBitStreamFormatIf2 == false)
+        if (aProps->iBitStreamFormat == AMR_TX_WMF)
         {
-            iBitStreamFormatIf2 = AMR_TX_WMF;
+            iBitStreamFormat = AMR_TX_WMF;
+        }
+        else if (aProps->iBitStreamFormat == AMR_TX_IF2)
+        {
+            iBitStreamFormat = AMR_TX_IF2;
         }
         else
         {
-            iBitStreamFormatIf2 = AMR_TX_IF2;
+            iBitStreamFormat = AMR_TX_ETS;
         }
     }
 
@@ -140,6 +144,7 @@
     return GSMAMR_ENC_NO_ERROR;
 }
 
+
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF int32 CPvGsmAmrEncoder::Encode(TInputAudioStream& aInStream,
         TOutputAudioStream& aOutStream)
@@ -148,7 +153,6 @@
     if (IsModeValid(aInStream.iMode) == false)
         return GSMAMR_ENC_INVALID_MODE;
 
-
     // set AMR mode for this set of samples
     iGsmAmrMode = (GSM_AMR_MODES)aInStream.iMode;
 
@@ -166,12 +170,14 @@
         // //////////////////////////////////////////
         // encode this frame
         // //////////////////////////////////////////
+        int32 * temp = & iLastModeUsed;
         Word16 nStatus = AMREncode(iEncState, iSidState, 	// BX, Word16 instead of int32 to avoid wierd case(IF2 format): the function returns 31, but nStatus ends up with a big wierd number
                                    (Mode)iGsmAmrMode,
                                    (Word16 *)pFrameIn,
                                    (unsigned char *)pFrameOut,
-                                   (Frame_Type_3GPP*) & iLastModeUsed,
-                                   iBitStreamFormatIf2);
+                                   (Frame_Type_3GPP*) temp,
+                                   iBitStreamFormat);
+
         if (nStatus < 0)
         {
             // an error when encoding was received, so quit
@@ -202,3 +208,17 @@
     return GSMAMR_ENC_NO_ERROR;
 }
 
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF int32 CPvGsmAmrEncoder::Reset()
+{
+    // reset GSM AMR encoder (state memory and SID sync function.)
+    Word16 nStatus = AMREncodeReset(&iEncState, &iSidState);
+
+    if (nStatus < 0)
+    {
+        return GSMAMR_ENC_CODEC_ENCODE_FAILURE;
+    }
+    return GSMAMR_ENC_NO_ERROR;
+}
+
+
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.cpp
index 58de9f6..d086594 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.h
index d712e44..b668924 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/hp_max.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.cpp
index 380fc1a..87766a9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.h
index 4fee118..f35a5c5 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.cpp
index e28e89b..27f33e9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Pathname: .audio/gsm-amr/c/src/inter_36_tab.c
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.h
index 782a731..21ade69 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/inter_36_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Pathname: .audio/gsm-amr/c/include/inter_36_tab.h
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_comp.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_comp.cpp
index 5bd395d..64be4dd 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_comp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_comp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,18 +27,6 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
- Pathname: ./gsm-amr/c/src/l_comp.c
-
-     Date: 09/07/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Passing in pOverflow for EPOC changes
-
- Description:
-
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_extract.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_extract.cpp
index 77d1400..39155db 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_extract.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_extract.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_negate.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_negate.cpp
index c21a335..2986a7d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_negate.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/l_negate.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,21 +27,6 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
-
- Pathname: ./gsm-amr/c/src/l_negate.c
-
-     Date: 08/11/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Created separate file for the L_negate function. Sync'ed up
-	      with the current template and fixed tabs.
-
- Description: Removed conditional code that updates WMOPS counter
-
- Description:
-
 ------------------------------------------------------------------------------
  INPUT AND OUTPUT DEFINITIONS
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.cpp
index 3afbed7..0b2d2a1 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.h
index 3934aba..4928ac4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.cpp
index bae4942..53889bb 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Pathname: .audio/gsm-amr/c/src/lag_wind_tab.c
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.h
index b3394c9..c210932 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lag_wind_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Pathname: .audio/gsm-amr/c/include/lag_wind_tab.h
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.cpp
index 0cdea5a..207a6be 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,55 +37,6 @@
            Levinson_exit
            Levinson
 
-     Date: 06/02/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated template used to PV coding template. First attempt at
-          optimizing C code.
-
- Description: Updated file per comments gathered from Phase 2/3 review.
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include files.
-
- Description: Replaced basic_op.h and oper_32b.h with the header files of
-              the math functions used in the file.
-
- Description: Defined one local variable per line.
-
- Description: Added pOverflow as a variable passed into levinson as per
-              changed needed for EPOC.
-
- Description: Removed nested function calls by adding temp variables.
-
- Description: Fixed a bug where the returned value (32bit) was being stored in
-              a 16 bit temp variable. This was changed, and the value is now
-              stored in temp32_3.
-
- Description:  For levinson()
-              1. Eliminated unused include files.
-              2. Replaced array addressing by pointers
-              3. Eliminated math operations that unnecessary checked for
-                 saturation, by evaluating the operands
-              4. Combined shift operations to eliminate calls to mult() and
-                 shr(), extrac_h(), extract_l()
-              5. Eliminated if-else statements for sign extension when
-                 right-shifting
-
- Description:  1. Replaced OSCL mem type functions and eliminated include
-                  files that now are chosen by OSCL definitions
-               2. Modified "int" definition by Word16
-
- Description:  Replaced "int" and/or "char" with OSCL defined types.
-
-
- Description: Changed round function name to pv_round to avoid conflict with
-              round function in C standard library.
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.h
index 2119121..65ba481 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/levinson.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.cpp
index fd927e2..3f2b3f4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.h
index 5b2745a..705a1d4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/lpc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.cpp
index b5078fd..7d034e0 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.h
index 16b8c5d..f8c1481 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ol_ltp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/p_ol_wgh.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/p_ol_wgh.cpp
index 9c7af4b..36ed9db 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/p_ol_wgh.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/p_ol_wgh.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.cpp
index 7014ab9..1b28397 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.h
index 0a4de0e..5e87cc9 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_fr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.cpp
index a09cc60..70f00ba 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,60 +35,6 @@
  Funtions: Pitch_ol
            Lag_max
 
-     Date: 06/15/2000
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Placed into PV template and began optimization.
-
- Description: Made changes based on review meeting.
-
- Description: Fixed bug in Pitch_ol that causes function to not be bit-exact
-          with the original version. This was done by adding an extra
-          call to mult after the first IF statement when comparing the
-          three section maximums (towards the end of the function). Fixed
-          tabs. Synced-up Lag_max_wrapper with template.
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include file.
-
- Description: Added code that compares max1 to THRESHOLD value prior to
-              comparison with max3.
-
- Description: Replaced basic_op.h and oper_32b.h with the header files of the
-              math functions used in this file. Fixed typecasting issue with
-              the TI C compiler.
-
- Description: Made the following changes per comments from Phase 2/3 review:
-              1. Defined one local variable per line.
-              2. Added more comments to the code.
-
- Description: Passing in pointer to overflow flag for EPOC compatibility
-
- Description:  For Lag_max() and Pitch_ol()
-              1. Eliminated unused include files.
-              2. Replaced array addressing by pointers
-              3. Eliminated math operations that unnecessary checked for
-                 saturation, in some cases this by shifting before adding and
-                 in other cases by evaluating the operands
-              4. Unrolled loops to speed up processing, use decrement loops
-              5. Eliminated if-else statements for sign extension when
-                 right-shifting
-              6. Replaced for-loop with memcpy()
-
- Description:  Replaced OSCL mem type functions and eliminated include
-               files that now are chosen by OSCL definitions
-
- Description:  Replaced "int" and/or "char" with OSCL defined types.
-
- Description: Added l_add.h in Include section.
-
- Description: Using intrinsics from fxp_arithmetic.h .
-
- Description: Replacing fxp_arithmetic.h with basic_op.h.
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
@@ -1083,26 +1029,32 @@
     if (t0 == MAX_32)     /* Test for overflow */
     {
 
-        for (i = (pit_max + L_frame + 1) >> 1; i != 0; i--)
+        for (i = (pit_max + L_frame) >> 1; i != 0; i--)
         {
             *(scal_sig++) = (Word16)(((Word32) * (p_signal++) >> 3));
             *(scal_sig++) = (Word16)(((Word32) * (p_signal++) >> 3));
         }
 
-        *(scal_sig++) = (Word16)(((Word32) * (p_signal++) >> 3));
+        if ((pit_max + L_frame) & 1)
+        {
+            *(scal_sig) = (Word16)(((Word32) * (p_signal) >> 3));
+        }
 
         scal_fac = 3;
     }
     else if (t0 < (Word32)1048576L)
         /* if (t0 < 2^20) */
     {
-        for (i = (pit_max + L_frame + 1) >> 1; i != 0; i--)
+        for (i = (pit_max + L_frame) >> 1; i != 0; i--)
         {
             *(scal_sig++) = (Word16)(((Word32) * (p_signal++) << 3));
             *(scal_sig++) = (Word16)(((Word32) * (p_signal++) << 3));
         }
 
-        *(scal_sig++) = (Word16)(((Word32) * (p_signal++) << 3));
+        if ((pit_max + L_frame) & 1)
+        {
+            *(scal_sig) = (Word16)(((Word32) * (p_signal) << 3));
+        }
         scal_fac = -3;
     }
     else
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.h
index 368edfe..df7f307 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pitch_ol.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.cpp
index 5d00f0f..02544cf 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.h
index a559e6e..6b47bfe 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_big.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.cpp
index 1243244..0526c0f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.h
index cb0beae..abe676f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/pre_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.cpp
index e2fc9ac..9088f7d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.h
index 98cff24..8ad11a8 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/prm2bits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.cpp
index d726b38..c58b687 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.h
index c8611a2..621143d 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_c.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.cpp
index 81c260a..c1aff6b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.h
index 6eac6d3..233ccb0 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/q_gain_p.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.cpp
index bbd3823..f8da589 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,36 +36,6 @@
            MR475_update_unq_pred
            MR475_gain_quant
 
-     Date: 05/17/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Synchronized file with UMTS version 3.2.0. Updated coding
-              template. Removed unnecessary include files.
-
- Description: Made the following chnages per comments from Phase 2/3 review:
-              1. Updated copyright year,
-              2. Used short-hand notation for math operations, e.g., "+=",
-                 in the code.
-              3. Defined one local variable per line.
-              4. Moved #defines to qgain475.h.
-
- Description: Added parameter "pOverflow" for EPOC compatibility.
-
- Description: Removed bug where a variable was incorrectly used as a
- temporary placeholder.
-
- Description: Optimized file to reduce clock cycle usage. Updated copyright
-              year. Removed unused files in Include section.
-
- Description:  Replaced "int" and/or "char" with OSCL defined types.
-
- Description: Changed round function name to pv_round to avoid conflict with
-              round function in C standard library.
-
- Description:
-
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.h
index ca665ba..45682d5 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain475.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.cpp
index 0ff3abd..d09fbe3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.h
index ed3c1ec..b739dad 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qgain795.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qua_gain.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qua_gain.cpp
index 2af4f2f..740abcb 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qua_gain.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/qua_gain.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.cpp
index f5271ac..117f78a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.h
index f105a00..fe98493 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/s10_8pf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.cpp
index 069c2dd..dedf91a 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.h
index d07c295..d0de0a3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/set_sign.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.cpp
index d62d7ca..dd9e022 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.h
index 93c25dd..c3cb1cf 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sid_sync.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.cpp
index 5ace919..124673f 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -241,7 +241,8 @@
     if (Pre_Process_init(&s->pre_state) ||
             cod_amr_init(&s->cod_amr_state, s->dtx))
     {
-        GSMEncodeFrameExit((void**)&s);
+        Speech_Encode_FrameState** temp = &s;
+        GSMEncodeFrameExit((void**)temp);
         return -1;
     }
 
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.h
index 21ec8e4..8eb2a9b 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/sp_enc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.cpp
index 3663e05..3ca6c23 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.h
index 3dcfe21..77d35fc 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spreproc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.cpp
index 37e0409..b9574aa 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.h
index 61b5af7..edc43e4 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/spstproc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.cpp b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.cpp
index 70d4edc..ec20bf3 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.h b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.h
index 2efb1b9..fb06e64 100644
--- a/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.h
+++ b/codecs_v2/audio/gsm_amr/amr_nb/enc/src/ton_stab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk b/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
index e184178..064b740 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
@@ -3,69 +3,66 @@
 
 LOCAL_SRC_FILES := \
 	src/agc2_amr_wb.cpp \
-	src/band_pass_6k_7k.cpp \
-	src/dec_acelp_2p_in_64.cpp \
-	src/dec_acelp_4p_in_64.cpp \
-	src/dec_alg_codebook.cpp \
-	src/dec_gain2_amr_wb.cpp \
-	src/decoder_amr_wb.cpp \
-	src/deemphasis_32.cpp \
-	src/dtx_decoder_amr_wb.cpp \
-	src/get_amr_wb_bits.cpp \
-	src/highpass_400hz_at_12k8.cpp \
-	src/highpass_50hz_at_12k8.cpp \
-	src/homing_amr_wb_dec.cpp \
-	src/interpolate_isp.cpp \
-	src/isf_extrapolation.cpp \
-	src/isp_az.cpp \
-	src/isp_isf.cpp \
-	src/lagconceal.cpp \
-	src/low_pass_filt_7k.cpp \
-	src/median5.cpp \
-	src/mime_io.cpp \
-	src/noise_gen_amrwb.cpp \
-	src/normalize_amr_wb.cpp \
-	src/oversamp_12k8_to_16k.cpp \
-	src/phase_dispersion.cpp \
-	src/pit_shrp.cpp \
-	src/pred_lt4.cpp \
-	src/preemph_amrwb_dec.cpp \
-	src/pvamrwb_math_op.cpp \
-	src/pvamrwbdecoder.cpp \
-	src/q_gain2_tab.cpp \
-	src/qisf_ns.cpp \
-	src/qisf_ns_tab.cpp \
-	src/qpisf_2s.cpp \
-	src/qpisf_2s_tab.cpp \
-	src/scale_signal.cpp \
-	src/synthesis_amr_wb.cpp \
-	src/voice_factor.cpp \
-	src/wb_syn_filt.cpp \
-	src/weight_amrwb_lpc.cpp
-
+ 	src/band_pass_6k_7k.cpp \
+ 	src/dec_acelp_2p_in_64.cpp \
+ 	src/dec_acelp_4p_in_64.cpp \
+ 	src/dec_alg_codebook.cpp \
+ 	src/dec_gain2_amr_wb.cpp \
+ 	src/decoder_amr_wb.cpp \
+ 	src/deemphasis_32.cpp \
+ 	src/dtx_decoder_amr_wb.cpp \
+ 	src/get_amr_wb_bits.cpp \
+ 	src/highpass_400hz_at_12k8.cpp \
+ 	src/highpass_50hz_at_12k8.cpp \
+ 	src/homing_amr_wb_dec.cpp \
+ 	src/interpolate_isp.cpp \
+ 	src/isf_extrapolation.cpp \
+ 	src/isp_az.cpp \
+ 	src/isp_isf.cpp \
+ 	src/lagconceal.cpp \
+ 	src/low_pass_filt_7k.cpp \
+ 	src/median5.cpp \
+ 	src/mime_io.cpp \
+ 	src/noise_gen_amrwb.cpp \
+ 	src/normalize_amr_wb.cpp \
+ 	src/oversamp_12k8_to_16k.cpp \
+ 	src/phase_dispersion.cpp \
+ 	src/pit_shrp.cpp \
+ 	src/pred_lt4.cpp \
+ 	src/preemph_amrwb_dec.cpp \
+ 	src/pvamrwb_math_op.cpp \
+ 	src/pvamrwbdecoder.cpp \
+ 	src/q_gain2_tab.cpp \
+ 	src/qisf_ns.cpp \
+ 	src/qisf_ns_tab.cpp \
+ 	src/qpisf_2s.cpp \
+ 	src/qpisf_2s_tab.cpp \
+ 	src/scale_signal.cpp \
+ 	src/synthesis_amr_wb.cpp \
+ 	src/voice_factor.cpp \
+ 	src/wb_syn_filt.cpp \
+ 	src/weight_amrwb_lpc.cpp
 
 
 LOCAL_MODULE := libpvamrwbdecoder
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -D_ARM_GCC
- else
- LOCAL_CFLAGS += -DC_EQUIVALENT
- endif
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_wb/dec/include \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/amr_wb/dec/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/decoder_amr_wb.h \
-	include/pvamrwbdecoder_api.h
+ 	include/pvamrwbdecoder_api.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make/local.mk b/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make/local.mk
new file mode 100644
index 0000000..c131aa6
--- /dev/null
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make/local.mk
@@ -0,0 +1,60 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvamrwbdecoder
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+SRCS := agc2_amr_wb.cpp \
+	band_pass_6k_7k.cpp \
+	dec_acelp_2p_in_64.cpp \
+	dec_acelp_4p_in_64.cpp \
+	dec_alg_codebook.cpp \
+	dec_gain2_amr_wb.cpp \
+	decoder_amr_wb.cpp \
+	deemphasis_32.cpp \
+	dtx_decoder_amr_wb.cpp \
+	get_amr_wb_bits.cpp \
+	highpass_400hz_at_12k8.cpp \
+	highpass_50hz_at_12k8.cpp \
+	homing_amr_wb_dec.cpp \
+	interpolate_isp.cpp \
+	isf_extrapolation.cpp \
+	isp_az.cpp \
+	isp_isf.cpp \
+	lagconceal.cpp \
+	low_pass_filt_7k.cpp \
+	median5.cpp \
+	mime_io.cpp \
+	noise_gen_amrwb.cpp \
+	normalize_amr_wb.cpp \
+	oversamp_12k8_to_16k.cpp \
+	phase_dispersion.cpp \
+	pit_shrp.cpp \
+	pred_lt4.cpp \
+	preemph_amrwb_dec.cpp \
+	pvamrwb_math_op.cpp \
+	pvamrwbdecoder.cpp \
+	q_gain2_tab.cpp \
+	qisf_ns.cpp \
+	qisf_ns_tab.cpp \
+	qpisf_2s.cpp \
+	qpisf_2s_tab.cpp \
+	scale_signal.cpp \
+	synthesis_amr_wb.cpp \
+	voice_factor.cpp \
+	wb_syn_filt.cpp \
+	weight_amrwb_lpc.cpp
+
+
+HDRS := decoder_amr_wb.h pvamrwbdecoder_api.h
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make/makefile b/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make/makefile
deleted file mode 100644
index 040aa8b..0000000
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make/makefile
+++ /dev/null
@@ -1,105 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pvamrwbdecoder
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DORIGINAL_TYPEDEF_H -DOSCL_BASE_H_INCLUDED -DOSCL_TYPES_H_INCLUDE -DOSCL_ASSERT_H_INCLUDED -DOSCL_MEM_BASIC_FUNCTIONS_H -DOSCL_MEM_IMP_H
-XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-
-ifeq ($(ARCHITECTURE),linux_arm)
-XCPPFLAGS += -D_ARM_GCC
-else
-XCPPFLAGS += -DC_EQUIVALENT
-endif
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-SRCS =  agc2_amr_wb.cpp \
-	band_pass_6k_7k.cpp \
-	dec_acelp_2p_in_64.cpp \
-	dec_acelp_4p_in_64.cpp \
-	dec_alg_codebook.cpp \
-	dec_gain2_amr_wb.cpp \
-	decoder_amr_wb.cpp \
-	deemphasis_32.cpp \
-	dtx_decoder_amr_wb.cpp \
-	get_amr_wb_bits.cpp \
-	highpass_400hz_at_12k8.cpp \
-	highpass_50hz_at_12k8.cpp \
-	homing_amr_wb_dec.cpp \
-	interpolate_isp.cpp \
-	isf_extrapolation.cpp \
-	isp_az.cpp \
-	isp_isf.cpp \
-	lagconceal.cpp \
-	low_pass_filt_7k.cpp \
-	median5.cpp \
-	mime_io.cpp \
-	noise_gen_amrwb.cpp \
-	normalize_amr_wb.cpp \
-	oversamp_12k8_to_16k.cpp \
-	phase_dispersion.cpp \
-	pit_shrp.cpp \
-	pred_lt4.cpp \
-	preemph_amrwb_dec.cpp \
-	pvamrwb_math_op.cpp \
-	pvamrwbdecoder.cpp \
-	q_gain2_tab.cpp \
-	qisf_ns.cpp \
-	qisf_ns_tab.cpp \
-	qpisf_2s.cpp \
-	qpisf_2s_tab.cpp \
-	scale_signal.cpp \
-	synthesis_amr_wb.cpp \
-	voice_factor.cpp \
-	wb_syn_filt.cpp \
-	weight_amrwb_lpc.cpp
-	
-HDRS = decoder_amr_wb.h pvamrwbdecoder_api.h
-
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/include/decoder_amr_wb.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/include/decoder_amr_wb.h
index ce068b0..4b59dbd 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/include/decoder_amr_wb.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/include/decoder_amr_wb.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/include/pvamrwbdecoder_api.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/include/pvamrwbdecoder_api.h
index 6aa9270..0ba8663 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/include/pvamrwbdecoder_api.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/include/pvamrwbdecoder_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Name: pvamrwbdecoder_api.h
 
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/agc2_amr_wb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/agc2_amr_wb.cpp
index 9f68580..2e53d13 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/agc2_amr_wb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/agc2_amr_wb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/band_pass_6k_7k.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/band_pass_6k_7k.cpp
index bb06086..97c7402 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/band_pass_6k_7k.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/band_pass_6k_7k.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_2p_in_64.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_2p_in_64.cpp
index db29e9c..740bc16 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_2p_in_64.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_2p_in_64.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_4p_in_64.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_4p_in_64.cpp
index 38f50cf..4868822 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_4p_in_64.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_acelp_4p_in_64.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_alg_codebook.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_alg_codebook.cpp
index 5ad2e84..95860eb 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_alg_codebook.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_alg_codebook.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_gain2_amr_wb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_gain2_amr_wb.cpp
index 8228823..8cae559 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_gain2_amr_wb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dec_gain2_amr_wb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/decoder_amr_wb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/decoder_amr_wb.cpp
index b5f7998..e2c9f47 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/decoder_amr_wb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/decoder_amr_wb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 Permission to distribute, modify and use this file under the standard license
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
+//////////////////////////////////////////////////////////////////////////////////
 //                                                                              //
 //  File: decoder_amr_wb.cpp                                                   //
 //                                                                              //
@@ -38,7 +39,7 @@
 #include "dtx.h"
 
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 #include "oscl_error_codes.h"
 #include "oscl_exception.h"
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/deemphasis_32.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/deemphasis_32.cpp
index bd1dc2f..b80555b 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/deemphasis_32.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/deemphasis_32.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx.h
index 11be649..ce80068 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx_decoder_amr_wb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx_decoder_amr_wb.cpp
index 524b96b..7c798cc 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx_decoder_amr_wb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/dtx_decoder_amr_wb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/e_pv_amrwbdec.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/e_pv_amrwbdec.h
index 59d44b4..251a3ce 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/e_pv_amrwbdec.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/e_pv_amrwbdec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.cpp
index 51ab276..d7287f3 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.h
index 5498f76..0a2e47b 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/get_amr_wb_bits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_400hz_at_12k8.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_400hz_at_12k8.cpp
index 4a7cb18..6503454 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_400hz_at_12k8.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_400hz_at_12k8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_50hz_at_12k8.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_50hz_at_12k8.cpp
index d5973b8..c70c163 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_50hz_at_12k8.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/highpass_50hz_at_12k8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -189,7 +189,8 @@
         y1_lo = (int16)((L_tmp1 - (y1_hi << 16)) >> 1);
 
         /* coeff Q14 --> Q15 with saturation */
-        *(pt_sign++) = (int16)((L_tmp1 + 0x00004000) >> 15);
+        *(pt_sign++) = amr_wb_shl1_round(L_tmp1);
+
     }
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/homing_amr_wb_dec.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/homing_amr_wb_dec.cpp
index 44aff22..59c6c0a 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/homing_amr_wb_dec.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/homing_amr_wb_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/interpolate_isp.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/interpolate_isp.cpp
index 7bf6686..3ccebdb 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/interpolate_isp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/interpolate_isp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isf_extrapolation.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isf_extrapolation.cpp
index 7b823d0..e445615 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isf_extrapolation.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isf_extrapolation.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_az.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_az.cpp
index ebda736..40093f5 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_az.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_az.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_isf.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_isf.cpp
index 81f08fd..41db7e3 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_isf.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/isp_isf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/lagconceal.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/lagconceal.cpp
index f25f98c..c699808 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/lagconceal.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/lagconceal.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/low_pass_filt_7k.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/low_pass_filt_7k.cpp
index a966cd8..ec1d6e0 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/low_pass_filt_7k.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/low_pass_filt_7k.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/median5.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/median5.cpp
index 50545e4..b922de5 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/median5.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/median5.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.cpp
index 83843cd..cb91d4a 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
 
  Pathname: ./src/mime_io.cpp
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.h
index 14eeb97..3be1d9c 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/mime_io.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/noise_gen_amrwb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/noise_gen_amrwb.cpp
index 46a7d90..2c1059f 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/noise_gen_amrwb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/noise_gen_amrwb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.cpp
index ffa904f..0325311 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -112,8 +112,8 @@
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
 
-#if defined(_ARM_V5)
-#elif defined(_ARM_GCC)
+#if defined(PV_ARM_V5)
+#elif defined(PV_ARM_GCC_V5)
 
 /* function is inlined in header file */
 
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.h
index ea463d6..e4c80ef 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/normalize_amr_wb.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@
 ; DEFINES AND SIMPLE TYPEDEF'S
 ----------------------------------------------------------------------------*/
 
-#if defined(_ARM_V5)
+#if defined(PV_ARM_V5)
 
 __inline int16 normalize_amr_wb(int32 x)
 {
@@ -82,7 +82,7 @@
 }
 
 
-#elif defined(_ARM_GCC)
+#elif defined(PV_ARM_GCC_V5)
 
 
 __inline int16 normalize_amr_wb(int32 x)
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/oversamp_12k8_to_16k.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/oversamp_12k8_to_16k.cpp
index b468fa5..43aaef7 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/oversamp_12k8_to_16k.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/oversamp_12k8_to_16k.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -252,7 +252,7 @@
         if (frac)
         {
             *(pt_sig_u++) = AmrWbInterpol(&sig_d[i],
-                                          (const int16 *) & fir_up[(FAC5-1) - frac],
+                                          fir_up[(FAC5-1) - frac],
                                           N_LOOP_COEF_UP);
         }
         else
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/phase_dispersion.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/phase_dispersion.cpp
index f705d19..f90a534 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/phase_dispersion.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/phase_dispersion.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pit_shrp.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pit_shrp.cpp
index 8e9fa5b..4bfcf9c 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pit_shrp.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pit_shrp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pred_lt4.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pred_lt4.cpp
index dd33684..d5a7984 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pred_lt4.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pred_lt4.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -185,7 +185,7 @@
     }
     pt_exc -= (L_INTERPOL2 - 1);
 
-    pt_inter4_2 = (const int16 *) & inter4_2[UP_SAMP-1 - frac];
+    pt_inter4_2 = inter4_2[UP_SAMP-1 - frac];
 
     for (j = 0; j < (L_subfr >> 2); j++)
     {
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/preemph_amrwb_dec.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/preemph_amrwb_dec.cpp
index f4ebf5f..3eb5cda 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/preemph_amrwb_dec.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/preemph_amrwb_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pv_amr_wb_type_defs.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pv_amr_wb_type_defs.h
index ae986af..7c28612 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pv_amr_wb_type_defs.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pv_amr_wb_type_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.cpp
index bf5406f..d1ec790 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.h
index 29c3841..8951e5c 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwb_math_op.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.cpp
index 6a4fb5b..b8cfefa 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@
     /* Decoder states */
     Decoder_State *st = &(((PV_AmrWbDec *)pt_st)->state);
 
-    *ScratchMem = (int16 *)(&(((PV_AmrWbDec *)pt_st)->ScratchMem));
+    *ScratchMem = ((PV_AmrWbDec *)pt_st)->ScratchMem;
     /*
      *  Init dtx decoding
      */
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.h
index 5a98471..7fc7495 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Name: pvamrwbdecoder.h
 
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_acelp.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_acelp.h
index 28fd725..5967115 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_acelp.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_acelp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op.h
index a512d4b..48aff1e 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -226,25 +226,22 @@
 
 
 
-
-
-#if defined(_ARM_V5)
+#if defined(PV_ARM_V5)
 
 #include "pvamrwbdecoder_basic_op_armv5.h"
 
-#endif
-
-#if defined(C_EQUIVALENT)
-
-#include "pvamrwbdecoder_basic_op_cequivalent.h"
-
-#endif
-
-
-#if defined(_ARM_GCC)
+#elif defined(PV_ARM_GCC_V5)
 
 #include "pvamrwbdecoder_basic_op_gcc_armv5.h"
 
+#else
+
+#ifndef C_EQUIVALENT
+#define C_EQUIVALENT		// default to C_EQUIVALENT
+#endif
+
+#include "pvamrwbdecoder_basic_op_cequivalent.h"
+
 #endif
 
 
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_armv5.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_armv5.h
index a6629a6..c800a2e 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_armv5.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_armv5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
 
 
 
-#if defined(_ARM_V5)
+#if defined(PV_ARM_V5)
 
     __inline int16 add_int16(int16 var1, int16 var2)
     {
@@ -180,6 +180,20 @@
     }
 
 
+
+    __inline int16 amr_wb_shl1_round(int32 L_var1)
+    {
+        int32 L_var_out;
+
+        __asm
+        {
+            qadd L_var_out, L_var1, L_var1
+            qadd L_var_out, L_var_out, (int32) 0x00008000L
+            mov L_var_out, L_var_out, asr #16
+        }
+        return L_var_out;
+    }
+
     __inline int32 mul_32by16(int16 hi, int16 lo, int16 n)
     {
         int32 H_32;
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_cequivalent.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_cequivalent.h
index 59fda19..4c198d8 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_cequivalent.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_cequivalent.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -454,21 +454,56 @@
         return ((int16)(L_var1 >> 16));
     }
 
+
     /*----------------------------------------------------------------------------
-         Function Name : mul_32by16
 
-         Multiply a 16 bit integer by a 32 bit (DPF). The result is divided
-         by 2^15
+         Function Name : amr_wb_shl1_round
 
-                L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1
+         Shift the 32 bit input number to the left by 1, round up the result and
+    	 shift down by 16
+                     amr_wb_shl1_round(L_var1) = round(L_shl(L_var1,1))
 
          Inputs :
+          L_var1
+                   32 bit long signed integer (int32 ) whose value falls in the
+                   range : 0x8000 0000 <= L_var1 <= 0x7fff ffff.
 
-         hi          hi part of 32 bit number.
-         lo          lo part of 32 bit number.
-         n           16 bit number.
+         Return Value :
+                   16 bit short signed integer (int16) whose value falls in the
+                   range : 0xffff 8000 <= var_out <= 0x0000 7fff.
 
      ----------------------------------------------------------------------------*/
+    __inline int16 amr_wb_shl1_round(int32 L_var1)
+    {
+        int16 var_out;
+
+        if ((L_var1 << 1) >> 1 == L_var1)
+        {
+            var_out = (int16)((L_var1 + 0x00004000) >> 15);
+        }
+        else
+        {
+            var_out = (int16)(((L_var1 >> 31) ^ MAX_32) >> 16);
+        }
+
+        return (var_out);
+    }
+
+    /*----------------------------------------------------------------------------
+             Function Name : mul_32by16
+
+             Multiply a 16 bit integer by a 32 bit (DPF). The result is divided
+             by 2^15
+
+                    L_32 = (hi1*lo2)<<1 + ((lo1*lo2)>>15)<<1
+
+             Inputs :
+
+             hi          hi part of 32 bit number.
+             lo          lo part of 32 bit number.
+             n           16 bit number.
+
+         ----------------------------------------------------------------------------*/
 
 
     __inline int32 mul_32by16(int16 hi, int16 lo, int16 n)
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_gcc_armv5.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_gcc_armv5.h
index 7dc6c0f..741b584 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_gcc_armv5.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_basic_op_gcc_armv5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,8 +54,7 @@
 #endif
 
 
-#if defined(_ARM_GCC)
-
+#if (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 
     static inline int16 sub_int16(int16 var1, int16 var2)
     {
@@ -239,6 +238,23 @@
         return (int16)L_var_out;
     }
 
+    static inline int16 amr_wb_shl1_round(int32 L_var1)
+{
+        register int32 L_var_out;
+        register int32 ra = (int32)L_var1;
+        register int32 rb = (int32)0x00008000L;
+
+        asm volatile(
+            "qadd %0, %1, %1\n"
+            "qadd %0, %0, %2\n"
+            "mov %0, %0, asr #16"
+    : "=&r*i"(L_var_out)
+                    : "r"(ra),
+                    "r"(rb));
+        return (int16)L_var_out;
+    }
+
+
     static inline int32 fxp_mac_16by16(const int16 L_var1, const int16 L_var2, int32 L_add)
 {
         register int32 tmp;
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_cnst.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_cnst.h
index a2c89cd..ecf1bf3 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_cnst.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_cnst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 terms listed above has been obtained from the copyright holder.
 ****************************************************************************************/
 /*
+------------------------------------------------------------------------------
 
  Name: pvamrwbdecoder_cnst.h
 
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_mem_funcs.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_mem_funcs.h
index f1aba36..ac383cd 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_mem_funcs.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/pvamrwbdecoder_mem_funcs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_gain2_tab.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_gain2_tab.cpp
index 912175b..92c235f 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_gain2_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_gain2_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_pulse.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_pulse.h
index 0828961..0ac52b3 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_pulse.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/q_pulse.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.cpp
index 3c3ac4b..07e342b 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.h
index 32c576a..4e9f67e 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns_tab.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns_tab.cpp
index 2d7872c..e5630e8 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qisf_ns_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.cpp
index 5a75f3f..0d465c6 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.h
index 1a5f972..61f8c06 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s_tab.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s_tab.cpp
index 493dbe1..d57522e 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s_tab.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/qpisf_2s_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/scale_signal.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/scale_signal.cpp
index 1c79678..b2b02b1 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/scale_signal.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/scale_signal.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.cpp
index 5531b65..c3aa887 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.h b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.h
index 3388a45..4bfc3c5 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.h
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/synthesis_amr_wb.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/voice_factor.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/voice_factor.cpp
index 4b433b0..6153c67 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/voice_factor.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/voice_factor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/wb_syn_filt.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/wb_syn_filt.cpp
index c2362ae..e1af6d4 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/wb_syn_filt.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/wb_syn_filt.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/weight_amrwb_lpc.cpp b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/weight_amrwb_lpc.cpp
index bf5e7c3..63d2e00 100644
--- a/codecs_v2/audio/gsm_amr/amr_wb/dec/src/weight_amrwb_lpc.cpp
+++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/src/weight_amrwb_lpc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/gsm_amr/common/dec/Android.mk b/codecs_v2/audio/gsm_amr/common/dec/Android.mk
index c372c3a..bc39492 100644
--- a/codecs_v2/audio/gsm_amr/common/dec/Android.mk
+++ b/codecs_v2/audio/gsm_amr/common/dec/Android.mk
@@ -1,22 +1,28 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_SRC_FILES := \
+ 	
 
 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/common/dec/include \
-	$(PV_TOP)//codecs_v2/audio/gsm_amr/common/dec/ \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/gsm_amr/common/dec/build/make \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/common/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvgsmamrdecoderinterface.h
+ 	include/pvgsmamrdecoderinterface.h
 
 include $(BUILD_COPY_HEADERS)
-
diff --git a/codecs_v2/audio/gsm_amr/common/dec/build/make/local.mk b/codecs_v2/audio/gsm_amr/common/dec/build/make/local.mk
new file mode 100644
index 0000000..477a46f
--- /dev/null
+++ b/codecs_v2/audio/gsm_amr/common/dec/build/make/local.mk
@@ -0,0 +1,17 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET :=
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+INCSRCDIR := ../../include
+
+HDRS := pvgsmamrdecoderinterface.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/audio/gsm_amr/common/dec/build/make/makefile b/codecs_v2/audio/gsm_amr/common/dec/build/make/makefile
deleted file mode 100644
index c34ea5f..0000000
--- a/codecs_v2/audio/gsm_amr/common/dec/build/make/makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET =
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DORIGINAL_TYPEDEF_H -DOSCL_BASE_H_INCLUDED -DOSCL_TYPES_H_INCLUDE -DOSCL_ASSERT_H_INCLUDED -DOSCL_MEM_BASIC_FUNCTIONS_H -DOSCL_MEM_IMP_H
-XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-
-INCSRCDIR = ../../include
-
-HDRS = pvgsmamrdecoderinterface.h
-
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/gsm_amr/common/dec/include/pvgsmamrdecoderinterface.h b/codecs_v2/audio/gsm_amr/common/dec/include/pvgsmamrdecoderinterface.h
index 4c5efc9..59a2f73 100644
--- a/codecs_v2/audio/gsm_amr/common/dec/include/pvgsmamrdecoderinterface.h
+++ b/codecs_v2/audio/gsm_amr/common/dec/include/pvgsmamrdecoderinterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/Android.mk b/codecs_v2/audio/mp3/dec/Android.mk
index 254cb6b..26e69b0 100644
--- a/codecs_v2/audio/mp3/dec/Android.mk
+++ b/codecs_v2/audio/mp3/dec/Android.mk
@@ -3,68 +3,65 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmp3_normalize.cpp \
-	src/pvmp3_alias_reduction.cpp \
-	src/pvmp3_crc.cpp \
-	src/pvmp3_decode_header.cpp \
-	src/pvmp3_decode_huff_cw.cpp \
-	src/pvmp3_decoder.cpp \
-	src/pvmp3_getbits.cpp \
-	src/pvmp3_dequantize_sample.cpp \
-	src/pvmp3_framedecoder.cpp \
-	src/pvmp3_get_main_data_size.cpp \
-	src/pvmp3_get_side_info.cpp \
-	src/pvmp3_get_scale_factors.cpp \
-	src/pvmp3_mpeg2_get_scale_data.cpp \
-	src/pvmp3_mpeg2_get_scale_factors.cpp \
-	src/pvmp3_mpeg2_stereo_proc.cpp \
-	src/pvmp3_huffman_decoding.cpp \
-	src/pvmp3_huffman_parsing.cpp \
-	src/pvmp3_tables.cpp \
-	src/pvmp3_imdct_synth.cpp \
-	src/pvmp3_mdct_6.cpp \
-	src/pvmp3_dct_6.cpp \
-	src/pvmp3_poly_phase_synthesis.cpp \
-	src/pvmp3_equalizer.cpp \
-	src/pvmp3_seek_synch.cpp \
-	src/pvmp3_stereo_proc.cpp \
-	src/pvmp3_reorder.cpp
-	
+ 	src/pvmp3_alias_reduction.cpp \
+ 	src/pvmp3_crc.cpp \
+ 	src/pvmp3_decode_header.cpp \
+ 	src/pvmp3_decode_huff_cw.cpp \
+ 	src/pvmp3_decoder.cpp \
+ 	src/pvmp3_getbits.cpp \
+ 	src/pvmp3_dequantize_sample.cpp \
+ 	src/pvmp3_framedecoder.cpp \
+ 	src/pvmp3_get_main_data_size.cpp \
+ 	src/pvmp3_get_side_info.cpp \
+ 	src/pvmp3_get_scale_factors.cpp \
+ 	src/pvmp3_mpeg2_get_scale_data.cpp \
+ 	src/pvmp3_mpeg2_get_scale_factors.cpp \
+ 	src/pvmp3_mpeg2_stereo_proc.cpp \
+ 	src/pvmp3_huffman_decoding.cpp \
+ 	src/pvmp3_huffman_parsing.cpp \
+ 	src/pvmp3_tables.cpp \
+ 	src/pvmp3_imdct_synth.cpp \
+ 	src/pvmp3_mdct_6.cpp \
+ 	src/pvmp3_dct_6.cpp \
+ 	src/pvmp3_poly_phase_synthesis.cpp \
+ 	src/pvmp3_equalizer.cpp \
+ 	src/pvmp3_seek_synch.cpp \
+ 	src/pvmp3_stereo_proc.cpp \
+ 	src/pvmp3_reorder.cpp \
+ 	src/pvmp3_polyphase_filter_window.cpp \
+ 	src/pvmp3_mdct_18.cpp \
+ 	src/pvmp3_dct_9.cpp \
+ 	src/pvmp3_dct_16.cpp
+
 ifeq ($(TARGET_ARCH),arm)
 LOCAL_SRC_FILES += \
 	src/asm/pvmp3_polyphase_filter_window_gcc.s \
-	src/asm/pvmp3_mdct_18_gcc.s \
-	src/asm/pvmp3_dct_9_gcc.s \
-	src/asm/pvmp3_dct_16_gcc.s 
-else        
-LOCAL_SRC_FILES += \
-	src/pvmp3_polyphase_filter_window.cpp \
-	src/pvmp3_mdct_18.cpp \
-	src/pvmp3_dct_9.cpp \
-	src/pvmp3_dct_16.cpp 
+ 	src/asm/pvmp3_mdct_18_gcc.s \
+ 	src/asm/pvmp3_dct_9_gcc.s \
+	src/asm/pvmp3_dct_16_gcc.s
 endif
 
+
 LOCAL_MODULE := libpvmp3
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -DPV_ARM_GCC
- else
- LOCAL_CFLAGS += -DC_EQUIVALENT
- endif
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)/codecs_v2/audio/mp3/dec/include \
-	$(PV_TOP)/codecs_v2/audio/mp3/dec/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/audio/mp3/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/mp3/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmp3_decoder.h \
-	include/pvmp3decoder_api.h \
-	include/pvmp3_audio_type_defs.h
+ 	include/pvmp3decoder_api.h \
+ 	include/pvmp3_audio_type_defs.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/audio/mp3/dec/build/make/g++_arm.mk b/codecs_v2/audio/mp3/dec/build/make/g++_arm.mk
new file mode 100644
index 0000000..9c1614e
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/build/make/g++_arm.mk
@@ -0,0 +1,5 @@
+# Additional assembly files for linux-arm
+SRCS+=  asm/pvmp3_polyphase_filter_window_gcc.s \
+        asm/pvmp3_mdct_18_gcc.s \
+        asm/pvmp3_dct_9_gcc.s \
+        asm/pvmp3_dct_16_gcc.s 
diff --git a/codecs_v2/audio/mp3/dec/build/make/local.mk b/codecs_v2/audio/mp3/dec/build/make/local.mk
new file mode 100644
index 0000000..ee6d439
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/build/make/local.mk
@@ -0,0 +1,53 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp3
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+
+SRCS := pvmp3_normalize.cpp \
+	pvmp3_alias_reduction.cpp \
+	pvmp3_crc.cpp \
+	pvmp3_decode_header.cpp \
+	pvmp3_decode_huff_cw.cpp \
+	pvmp3_decoder.cpp \
+	pvmp3_getbits.cpp \
+	pvmp3_dequantize_sample.cpp \
+	pvmp3_framedecoder.cpp \
+	pvmp3_get_main_data_size.cpp \
+	pvmp3_get_side_info.cpp \
+	pvmp3_get_scale_factors.cpp \
+	pvmp3_mpeg2_get_scale_data.cpp \
+	pvmp3_mpeg2_get_scale_factors.cpp \
+	pvmp3_mpeg2_stereo_proc.cpp \
+	pvmp3_huffman_decoding.cpp \
+	pvmp3_huffman_parsing.cpp \
+	pvmp3_tables.cpp \
+	pvmp3_imdct_synth.cpp \
+	pvmp3_mdct_6.cpp \
+	pvmp3_dct_6.cpp \
+	pvmp3_poly_phase_synthesis.cpp \
+	pvmp3_equalizer.cpp \
+	pvmp3_seek_synch.cpp \
+	pvmp3_stereo_proc.cpp \
+	pvmp3_reorder.cpp \
+	pvmp3_polyphase_filter_window.cpp \
+	pvmp3_mdct_18.cpp \
+	pvmp3_dct_9.cpp \
+	pvmp3_dct_16.cpp 
+
+
+HDRS := pvmp3_decoder.h pvmp3decoder_api.h pvmp3_audio_type_defs.h
+
+include $(MK)/library.mk
+
+
diff --git a/codecs_v2/audio/mp3/dec/build/make/makefile b/codecs_v2/audio/mp3/dec/build/make/makefile
deleted file mode 100644
index 5a2596f..0000000
--- a/codecs_v2/audio/mp3/dec/build/make/makefile
+++ /dev/null
@@ -1,103 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pvmp3
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-
-ifeq ($(ARCHITECTURE),linux_arm)
-XCPPFLAGS += -DPV_ARM_GCC
-else
-XCPPFLAGS += -DC_EQUIVALENT
-endif
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-
-SRCS =  pvmp3_normalize.cpp \
-	pvmp3_alias_reduction.cpp \
-	pvmp3_crc.cpp \
-	pvmp3_decode_header.cpp \
-	pvmp3_decode_huff_cw.cpp \
-	pvmp3_decoder.cpp \
-	pvmp3_getbits.cpp \
-	pvmp3_dequantize_sample.cpp \
-	pvmp3_framedecoder.cpp \
-	pvmp3_get_main_data_size.cpp \
-	pvmp3_get_side_info.cpp \
-	pvmp3_get_scale_factors.cpp \
-	pvmp3_mpeg2_get_scale_data.cpp \
-	pvmp3_mpeg2_get_scale_factors.cpp \
-	pvmp3_mpeg2_stereo_proc.cpp \
-	pvmp3_huffman_decoding.cpp \
-	pvmp3_huffman_parsing.cpp \
-	pvmp3_tables.cpp \
-	pvmp3_imdct_synth.cpp \
-	pvmp3_mdct_6.cpp \
-	pvmp3_dct_6.cpp \
-	pvmp3_poly_phase_synthesis.cpp \
-	pvmp3_equalizer.cpp \
-	pvmp3_seek_synch.cpp \
-	pvmp3_stereo_proc.cpp \
-	pvmp3_reorder.cpp 
-
-
-ifeq ($(ARCHITECTURE),linux_arm)
-SRCS+=  asm/pvmp3_polyphase_filter_window_gcc.s \
-        asm/pvmp3_mdct_18_gcc.s \
-        asm/pvmp3_dct_9_gcc.s \
-        asm/pvmp3_dct_16_gcc.s 
-else
-SRCS+=  pvmp3_polyphase_filter_window.cpp \
-        pvmp3_mdct_18.cpp \
-        pvmp3_dct_9.cpp \
-        pvmp3_dct_16.cpp 
-endif
-
-HDRS = pvmp3_decoder.h pvmp3decoder_api.h pvmp3_audio_type_defs.h
-
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h b/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h
index b33efd6..e287433 100644
--- a/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h
+++ b/codecs_v2/audio/mp3/dec/include/mp3_decoder_selection.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h b/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h
index c3d0454..e298524 100644
--- a/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h
+++ b/codecs_v2/audio/mp3/dec/include/pvmp3_audio_type_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h b/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h
index 82355b0..3c2370c 100644
--- a/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h
+++ b/codecs_v2/audio/mp3/dec/include/pvmp3_decoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h b/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h
index 4d1ca40..e98d63d 100644
--- a/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h
+++ b/codecs_v2/audio/mp3/dec/include/pvmp3decoder_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s
index 63da1a6..f83732b 100644
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_16_gcc.s
@@ -1,5 +1,5 @@
 @ ------------------------------------------------------------------
-@ Copyright (C) 2008 PacketVideo
+@ Copyright (C) 1998-2009 PacketVideo
 @
 @ Licensed under the Apache License, Version 2.0 (the "License");
 @ you may not use this file except in compliance with the License.
@@ -19,7 +19,13 @@
 @
 @   Filename: pvmp3_dct_16_gcc.s
 @
-@     Date: 09/21/2007
+@
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who:                                   Date: MM/DD/YYYY
+@ Description: 
 @
 @------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9.s
deleted file mode 100644
index 5b8ded2..0000000
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9.s
+++ /dev/null
@@ -1,205 +0,0 @@
-; ------------------------------------------------------------------
-; Copyright (C) 2008 PacketVideo
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;      http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-; express or implied.
-; See the License for the specific language governing permissions
-; and limitations under the License.
-; -------------------------------------------------------------------
-
-;
-;
-;   Filename: pvmp3_dct_9.s
-;
-;     Date: 09/21/2007
-;
-;------------------------------------------------------------------------------
-
-  AREA  |.drectve|, DRECTVE
-
-    DCB "-defaultlib:coredll.lib "
-    DCB "-defaultlib:corelibc.lib "
-
-  IMPORT pvmp3_mdct_18 ; pvmp3_mdct_18.cpp
-
-;------------------------------------------------------------------------------
-
-  AREA  |.rdata|, DATA, READONLY
-  % 4
-
-
-;------------------------------------------------------------------------------
-
-  AREA  |.text|, CODE, READONLY
-
-
-;------------------------------------------------------------------------------
-
- EXPORT |pvmp3_dct_9|
-
-|pvmp3_dct_9| PROC
-        stmfd    sp!,{r4-r10,lr}
-        ldr      r2, [r0, #0x20]
-        ldr      r3, [r0]
-        ldr      r12,[r0, #4]
-        add      r1,r2,r3
-        sub      lr,r2,r3
-        ldr      r3,[r0, #0x1c]
-        ldr      r4,[r0, #0x18]
-        add      r2,r3,r12
-        ldr      r5,[r0,#8]
-        sub      r3,r3,r12
-        add      r12,r4,r5
-        sub      r4,r4,r5
-        ldr      r5,[r0, #0x14]
-        ldr      r7,[r0, #0xc]
-        ldr      r9,[r0, #0x10]
-        add      r6,r5,r7
-        sub      r5,r5,r7
-        add      r7,r1,r12
-        add      r8,r9,r2
-        add      r7,r7,r6
-        add      r10,r7,r8
-        rsb      r7,r8,r7,asr #1
-        str      r7,[r0, #0x18]
-        rsb      r2,r9,r2,asr #1
-        str      r10,[r0]
-        ldr      r11,|cos_2pi_9|
-        rsb      r7,r2,#0
-
-        mov      r9,r1,lsl #1
-		mov      r1,r9			;;;;;;  !!!!!!
-        mov      r8,r7
-
-;    vec[4]  = fxp_mac32_Q32( vec[4], tmp0<<1, cos_2pi_9); 
-
-        smlal    r1,r8,r11,r9
-        ldr      r10,|cos_4pi_9|
-        ldr      r11,|cos_pi_9|
-
-;    vec[8]  = fxp_mac32_Q32( vec[8], tmp0<<1, cos_4pi_9);
-
-        smlal    r1,r7,r10,r9
-
-
-
-;    vec[2]  = fxp_mac32_Q32( vec[2], tmp0<<1, cos_pi_9);
-
-        smlal    r9,r2,r11,r9
-        mov      r1,r12,lsl #1
-        rsb      r9,r10,#0
-        ldr      r11,|cos_5pi_9|
-
-        smlal    r12,r2,r9,r1
-
-
-
-;    vec[2]  = fxp_mac32_Q32( vec[2], tmp2<<1, cos_5pi_9);
-
-        ldr      r9,|cos_2pi_9|
-        mov      r12,r1			;;;;;;  !!!!!!
-        smlal    r12,r8,r11,r1
-
-
-;    vec[8]  = fxp_mac32_Q32( vec[8], tmp2<<1, cos_2pi_9);
-
-        smlal    r1,r7,r9,r1
-        mov      r1,r6,lsl #1
-        smlal    r12,r7,r11,r1
-        and      r6,r10,r11,asr #14
-        smlal    r12,r8,r6,r1
-        ldr      r10,|cos_11pi_18|
-        add      r12,r11,r6
-        smlal    r1,r2,r12,r1
-        ldr      r9,|cos_8pi_9|
-        str      r2,[r0,#8]
-        mov      r1,r5,lsl #1
-
-;    vec[8]  = fxp_mac32_Q32( vec[8], tmp3<<1, cos_8pi_9);
-
-        smull    r2,r6,r9,r1
-        str      r7,[r0,#0x20]
-        mov      r2,r4,lsl #1
-        ldr      r7,|cos_13pi_18|
-        smlal    r12,r6,r10,r2
-
-        mov      r3,r3,lsl #1
-
-;    vec[5]  = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18);
-
-        smlal    r12,r6,r7,r3
-        add      r4,r5,r4
-        mov      r12,lr,lsl #1
-        sub      lr,r4,lr
-        ldr      r7,|cos_17pi_18|
-        str      r8,[r0, #0x10]
-        ldr      r4,|cos_pi_6|
-
-        mov      lr,lr,lsl #1
-
-;    vec[1]  = fxp_mac32_Q32( vec[1], tmp8<<1, cos_17pi_18);
-
-        smlal    r8,r6,r7,r12
-
-;    vec[3]  = fxp_mul32_Q32((tmp5 + tmp6  - tmp8)<<1, cos_pi_6);
-
-        smull    r5,lr,r4,lr
-        str      r6,[r0, #4]
-        str      lr,[r0, #0xc]
-
-
-;    vec[5]  = fxp_mul32_Q32(tmp5<<1, cos_17pi_18);
-        smull    r5,lr,r7,r1
-        rsb      r6,r9,#0
-;    vec[5]  = fxp_mac32_Q32( vec[5], tmp6<<1,  cos_7pi_18);
-        smlal    r5,lr,r6,r2
-;    vec[5]  = fxp_mac32_Q32( vec[5], tmp7<<1,    cos_pi_6);
-        smlal    r5,lr,r4,r3
-;    vec[5]  = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18);
-        smlal    r5,lr,r10,r12
-        str      lr,[r0, #0x14]
-        rsb      lr,r10,#0
-
-;    vec[7]  = fxp_mul32_Q32(tmp5<<1, cos_5pi_18);
-        smull    r5,r1,lr,r1
-;    vec[7]  = fxp_mac32_Q32( vec[7], tmp6<<1, cos_17pi_18);
-        smlal    r2,r1,r7,r2
-;    vec[7]  = fxp_mac32_Q32( vec[7], tmp7<<1,    cos_pi_6);
-        smlal    r3,r1,r4,r3
-;    vec[7]  = fxp_mac32_Q32( vec[7], tmp8<<1, cos_11pi_18);
-        smlal    r12,r1,r9,r12
-        str      r1,[r0, #0x1c]
-        ldmfd    sp!,{r4-r10,pc}
-|cos_2pi_9|
-        DCD      0x620dbe80
-|cos_4pi_9|
-        DCD      0x163a1a80
-|cos_pi_9|
-        DCD      0x7847d900
-|cos_5pi_9|
-        DCD      0x87b82700
-|cos_8pi_9|
-        DCD      0xd438af00
-|cos_11pi_18|
-        DCD      0xadb92280
-|cos_13pi_18|
-        DCD      0x91261480
-|cos_17pi_18|
-        DCD      0x81f1d200
-|cos_pi_6|
-        DCD      0x6ed9eb80
-        ENDP
-
-
-
-
-
-        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_arm.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_arm.s
new file mode 100644
index 0000000..3a6dd4f
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_arm.s
@@ -0,0 +1,210 @@
+; ------------------------------------------------------------------
+; Copyright (C) 1998-2009 PacketVideo
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+; express or implied.
+; See the License for the specific language governing permissions
+; and limitations under the License.
+; -------------------------------------------------------------------
+
+;
+;
+;   Filename: pvmp3_dct_9.s
+;
+;------------------------------------------------------------------------------
+; REVISION HISTORY
+;
+;
+; Who:                                   Date: MM/DD/YYYY
+; Description: 
+;
+;------------------------------------------------------------------------------
+
+  AREA  |.drectve|, DRECTVE
+
+    DCB "-defaultlib:coredll.lib "
+    DCB "-defaultlib:corelibc.lib "
+
+  IMPORT pvmp3_mdct_18 ; pvmp3_mdct_18.cpp
+
+;------------------------------------------------------------------------------
+
+  AREA  |.rdata|, DATA, READONLY
+  % 4
+
+
+;------------------------------------------------------------------------------
+
+  AREA  |.text|, CODE, READONLY
+
+
+;------------------------------------------------------------------------------
+
+ EXPORT |pvmp3_dct_9|
+
+|pvmp3_dct_9| PROC
+        stmfd    sp!,{r4-r10,lr}
+        ldr      r2, [r0, #0x20]
+        ldr      r3, [r0]
+        ldr      r12,[r0, #4]
+        add      r1,r2,r3
+        sub      lr,r2,r3
+        ldr      r3,[r0, #0x1c]
+        ldr      r4,[r0, #0x18]
+        add      r2,r3,r12
+        ldr      r5,[r0,#8]
+        sub      r3,r3,r12
+        add      r12,r4,r5
+        sub      r4,r4,r5
+        ldr      r5,[r0, #0x14]
+        ldr      r7,[r0, #0xc]
+        ldr      r9,[r0, #0x10]
+        add      r6,r5,r7
+        sub      r5,r5,r7
+        add      r7,r1,r12
+        add      r8,r9,r2
+        add      r7,r7,r6
+        add      r10,r7,r8
+        rsb      r7,r8,r7,asr #1
+        str      r7,[r0, #0x18]
+        rsb      r2,r9,r2,asr #1
+        str      r10,[r0]
+        ldr      r11,|cos_2pi_9|
+        rsb      r7,r2,#0
+
+        mov      r9,r1,lsl #1
+		mov      r1,r9			;;;;;;  !!!!!!
+        mov      r8,r7
+
+;    vec[4]  = fxp_mac32_Q32( vec[4], tmp0<<1, cos_2pi_9); 
+
+        smlal    r1,r8,r11,r9
+        ldr      r10,|cos_4pi_9|
+        ldr      r11,|cos_pi_9|
+
+;    vec[8]  = fxp_mac32_Q32( vec[8], tmp0<<1, cos_4pi_9);
+
+        smlal    r1,r7,r10,r9
+
+
+
+;    vec[2]  = fxp_mac32_Q32( vec[2], tmp0<<1, cos_pi_9);
+
+        smlal    r9,r2,r11,r9
+        mov      r1,r12,lsl #1
+        rsb      r9,r10,#0
+        ldr      r11,|cos_5pi_9|
+
+        smlal    r12,r2,r9,r1
+
+
+
+;    vec[2]  = fxp_mac32_Q32( vec[2], tmp2<<1, cos_5pi_9);
+
+        ldr      r9,|cos_2pi_9|
+        mov      r12,r1			;;;;;;  !!!!!!
+        smlal    r12,r8,r11,r1
+
+
+;    vec[8]  = fxp_mac32_Q32( vec[8], tmp2<<1, cos_2pi_9);
+
+        smlal    r1,r7,r9,r1
+        mov      r1,r6,lsl #1
+        smlal    r12,r7,r11,r1
+        and      r6,r10,r11,asr #14
+        smlal    r12,r8,r6,r1
+        ldr      r10,|cos_11pi_18|
+        add      r12,r11,r6
+        smlal    r1,r2,r12,r1
+        ldr      r9,|cos_8pi_9|
+        str      r2,[r0,#8]
+        mov      r1,r5,lsl #1
+
+;    vec[8]  = fxp_mac32_Q32( vec[8], tmp3<<1, cos_8pi_9);
+
+        smull    r2,r6,r9,r1
+        str      r7,[r0,#0x20]
+        mov      r2,r4,lsl #1
+        ldr      r7,|cos_13pi_18|
+        smlal    r12,r6,r10,r2
+
+        mov      r3,r3,lsl #1
+
+;    vec[5]  = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18);
+
+        smlal    r12,r6,r7,r3
+        add      r4,r5,r4
+        mov      r12,lr,lsl #1
+        sub      lr,r4,lr
+        ldr      r7,|cos_17pi_18|
+        str      r8,[r0, #0x10]
+        ldr      r4,|cos_pi_6|
+
+        mov      lr,lr,lsl #1
+
+;    vec[1]  = fxp_mac32_Q32( vec[1], tmp8<<1, cos_17pi_18);
+
+        smlal    r8,r6,r7,r12
+
+;    vec[3]  = fxp_mul32_Q32((tmp5 + tmp6  - tmp8)<<1, cos_pi_6);
+
+        smull    r5,lr,r4,lr
+        str      r6,[r0, #4]
+        str      lr,[r0, #0xc]
+
+
+;    vec[5]  = fxp_mul32_Q32(tmp5<<1, cos_17pi_18);
+        smull    r5,lr,r7,r1
+        rsb      r6,r9,#0
+;    vec[5]  = fxp_mac32_Q32( vec[5], tmp6<<1,  cos_7pi_18);
+        smlal    r5,lr,r6,r2
+;    vec[5]  = fxp_mac32_Q32( vec[5], tmp7<<1,    cos_pi_6);
+        smlal    r5,lr,r4,r3
+;    vec[5]  = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18);
+        smlal    r5,lr,r10,r12
+        str      lr,[r0, #0x14]
+        rsb      lr,r10,#0
+
+;    vec[7]  = fxp_mul32_Q32(tmp5<<1, cos_5pi_18);
+        smull    r5,r1,lr,r1
+;    vec[7]  = fxp_mac32_Q32( vec[7], tmp6<<1, cos_17pi_18);
+        smlal    r2,r1,r7,r2
+;    vec[7]  = fxp_mac32_Q32( vec[7], tmp7<<1,    cos_pi_6);
+        smlal    r3,r1,r4,r3
+;    vec[7]  = fxp_mac32_Q32( vec[7], tmp8<<1, cos_11pi_18);
+        smlal    r12,r1,r9,r12
+        str      r1,[r0, #0x1c]
+        ldmfd    sp!,{r4-r10,pc}
+|cos_2pi_9|
+        DCD      0x620dbe80
+|cos_4pi_9|
+        DCD      0x163a1a80
+|cos_pi_9|
+        DCD      0x7847d900
+|cos_5pi_9|
+        DCD      0x87b82700
+|cos_8pi_9|
+        DCD      0xd438af00
+|cos_11pi_18|
+        DCD      0xadb92280
+|cos_13pi_18|
+        DCD      0x91261480
+|cos_17pi_18|
+        DCD      0x81f1d200
+|cos_pi_6|
+        DCD      0x6ed9eb80
+        ENDP
+
+
+
+
+
+        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s
index b0ef57d..618c50e 100644
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_dct_9_gcc.s
@@ -1,5 +1,5 @@
 @ ------------------------------------------------------------------
-@ Copyright (C) 2008 PacketVideo
+@ Copyright (C) 1998-2009 PacketVideo
 @
 @ Licensed under the Apache License, Version 2.0 (the "License");
 @ you may not use this file except in compliance with the License.
@@ -19,7 +19,12 @@
 @
 @   Filename: pvmp3_dct_9_gcc.s
 @
-@     Date: 09/21/2007
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who:                                   Date: MM/DD/YYYY
+@ Description: 
 @
 @------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.asm b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.asm
deleted file mode 100644
index 851a569..0000000
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.asm
+++ /dev/null
@@ -1,361 +0,0 @@
-; ------------------------------------------------------------------
-; Copyright (C) 2008 PacketVideo
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;      http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-; express or implied.
-; See the License for the specific language governing permissions
-; and limitations under the License.
-; -------------------------------------------------------------------
-
-;
-;
-;   Filename: pvmp3_dct_18.s
-;
-;     Date: 09/21/2007
-;
-;------------------------------------------------------------------------------
-
-        EXPORT |pvmp3_mdct_18|
-
-        IMPORT pvmp3_dct_9
-
-
-;------------------------------------------------------------------------------
-
- AREA |.text|, CODE, READONLY, ALIGN=2
-
-
-;------------------------------------------------------------------------------
-
-|pvmp3_mdct_18| PROC
-        stmfd    sp!,{r4-r10,lr}
-        mov      r7,r2
-        ldr      r2,table
-        mov      r6,r1
-        add      r3,r2,#0x24
-        add      r12,r3,#0x44
-        add      r1,r0,#0x44
-        mov      r5,r0
-
-;    for ( i=9; i!=0; i--)
-;    {
-
-        mov      r4,#9
-Loop_1
-
-;       tmp  = *(pt_vec);
-;		tmp1 = *(pt_vec_o);
-
-        ldr      lr,[r0]		;; tmp  == lr
-        ldr      r8,[r3],#4		;; tmp1 == r8
-
-;        tmp  = fxp_mul32_Q32( tmp<<1,  *(pt_cos++  ));
-;        tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--));
-
-        mov      lr,lr,lsl #1
-        smull    r10,lr,r8,lr
-        ldr      r8,[r12],#-4
-        ldr      r9,[r1]
-        subs     r4,r4,#1
-        smull    r9,r10,r8,r9
-        mov      r8,r9,lsr #27
-        add      r8,r8,r10,lsl #5
-
-;        *(pt_vec++)   =   tmp + tmp1 ;
-;        *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++));
-
-        add      r9,lr,r8
-        sub      r8,lr,r8
-        ldr      lr,[r2],#4
-        str      r9,[r0],#4
-        smull    r8,r9,lr,r8
-        mov      lr,r8,lsr #28
-        add      lr,lr,r9,lsl #4
-        str      lr,[r1],#-4
-        bne      Loop_1
-
-;		}
-
-        mov      r0,r5			;; r0 = vec
-        bl       pvmp3_dct_9
-        add      r0,r5,#0x24	;; r0 = &vec[9]
-        bl       pvmp3_dct_9
-
-        ldr      r0,[r5,#0x20]
-        ldr      r2,[r5,#0x40]
-        str      r0,[r5,#0x40]
-        ldr      r0,[r5,#0x1c]
-        ldr      r3,[r5,#0x38]
-        str      r0,[r5,#0x38]
-        ldr      r1,[r5,#0x18]
-        ldr      r0,[r5,#0x30]
-        str      r1,[r5,#0x30]
-        ldr      r12,[r5,#0x14]
-        ldr      r1,[r5,#0x28]
-        str      r12,[r5,#0x28]
-        ldr      r12,[r5,#0x10]
-        str      r12,[r5,#0x20]
-        ldr      r12,[r5,#0xc]
-        str      r12,[r5,#0x18]
-        ldr      r12,[r5,#8]
-        str      r12,[r5,#0x10]
-        ldr      r12,[r5,#4]
-        str      r12,[r5,#8]
-        ldr      r12,[r5,#0x24]
-        sub      r12,r12,r1
-        str      r12,[r5,#4]
-        ldr      r12,[r5,#0x2c]
-        sub      r1,r12,r1
-        str      r1,[r5,#0xc]
-        sub      r1,r12,r0
-        str      r1,[r5,#0x14]
-        ldr      r1,[r5,#0x34]
-        sub      r0,r1,r0
-        str      r0,[r5,#0x1c]
-        sub      r0,r1,r3
-        str      r0,[r5,#0x24]
-        ldr      r1,[r5,#0x3c]
-        sub      r3,r1,r3
-        sub      r1,r1,r2
-        str      r1,[r5,#0x34]
-        str      r3,[r5,#0x2c]
-        ldr      r1,[r5,#0x44]
-        sub      r1,r1,r2
-        str      r1,[r5,#0x3c]
-        ldr      r12,[r5,#0]
-
-Loop_2
-        add      r1,r5,r4,lsl #2
-        ldr      r2,[r1,#0x28]
-        ldr      r3,[r6,r4,lsl #2]
-        add      r0,r0,r2
-        str      r0,[r1,#0x28]
-        ldr      lr,[r7,r4,lsl #2]
-        ldr      r1,[r1,#4]
-        smlal    r0,r3,lr,r0
-        mov      r0,r2
-        add      r2,r12,r1
-        rsb      r2,r2,#0
-        str      r3,[r5,r4,lsl #2]
-        str      r2,[r6,r4,lsl #2]
-        add      r4,r4,#1
-        cmp      r4,#6
-        mov      r12,r1
-
-        blt      Loop_2
-
-        ldr      r1,[r5,#0x40]
-        ldr      r2,[r6,#0x18]
-        add      r3,r0,r1
-        str      r3,[r5,#0x40]
-        ldr      lr,[r7,r4,lsl #2]
-        mov      r3,r3,lsl #1
-        ldr      r0,[r5,#0x1c]
-        smlal    r3,r2,lr,r3
-        add      r3,r12,r0
-        str      r2,[r5,#0x18]
-        ldr      r2,[r6,#0x1c]
-        rsb      r3,r3,#0
-        str      r3,[r6,#0x18]
-        ldr      r3,[r5,#0x20]
-        add      r0,r3,r0
-        rsb      r0,r0,#0
-        str      r0,[r6,#0x1c]
-        ldr      r3,[r5,#0x44]
-        ldr      r0,[r6,#0x20]
-        add      r3,r3,r1
-        mov      r1,r2
-        ldr      r10,[r7,#0x1c]
-        mov      r2,r3,lsl #1
-        smlal    r12,r1,r10,r2
-        str      r1,[r5,#0x1c]
-        ldr      r1,[r5,#0x20]
-        ldr      r3,[r5,#0x24]
-        add      r1,r1,r3
-        rsb      r1,r1,#0
-        str      r1,[r6,#0x20]
-        ldr      r1,[r5,#0x44]
-        ldr      r3,[r7,#0x20]
-        mov      r1,r1,lsl #1
-        smlal    r12,r0,r3,r1
-        ldr      lr,[r7,#0x24]
-        ldr      r3,[r6,#0x24]
-        str      r0,[r5,#0x20]
-        smlal    r1,r3,lr,r1
-        ldr      r0,[r6,#0x40]
-        ldr      r12,[r6,#0x44]
-        str      r3,[r5,#0x24]
-        ldr      r1,[r5,#0x28]
-        ldr      r3,[r7,#0x44]
-        mov      r1,r1,lsl #1
-        smlal    r1,r12,r3,r1
-        ldr      r1,[r5,#0x40]
-        str      r12,[r5,#0x44]
-        rsb      r8,r1,#0
-        str      r8,[r5,#0x28]
-        ldr      r1,[r5,#0x2c]
-        ldr      r3,[r7,#0x40]
-        mov      r1,r1,lsl #1
-        smlal    r1,r0,r3,r1
-        str      r0,[r5,#0x40]
-        ldr      r0,[r5,#0x3c]
-        ldr      r1,[r6,#0x38]
-        ldr      r3,[r6,#0x3c]
-        rsb      r9,r0,#0
-        str      r9,[r5,#0x2c]
-        ldr      r0,[r5,#0x30]
-        ldr      r12,[r7,#0x3c]
-        mov      r0,r0,lsl #1
-        smlal    r0,r3,r12,r0
-        str      r3,[r5,#0x3c]
-        ldr      r0,[r5,#0x38]
-        rsb      r0,r0,#0
-        str      r0,[r5,#0x30]
-        ldr      r3,[r5,#0x34]
-        ldr      r12,[r7,#0x38]
-        mov      r3,r3,lsl #1
-        smlal    r3,r1,r12,r3
-        mov      r0,r0,lsl #1
-        str      r1,[r5,#0x38]
-        ldr      r4,[r7,#0x34]
-        ldr      r1,[r6,#0x34]
-        ldr      r3,[r6,#0x30]
-        smlal    r0,r1,r4,r0
-        ldr      r12,[r6,#0x2c]
-        ldr      lr,[r6,#0x28]
-        str      r1,[r5,#0x34]
-        ldr      r1,[r7,#0x30]
-        mov      r0,r9,lsl #1
-        smlal    r0,r3,r1,r0
-        mov      r0,r8,lsl #1
-        ldr      r1,[r7,#0x2c]
-        str      r3,[r5,#0x30]
-        smlal    r0,r12,r1,r0
-        ldr      r0,[r7,#0x28]
-        str      r12,[r5,#0x2c]
-        smlal    r2,lr,r0,r2
-        str      lr,[r5,#0x28]
-        ldr      r1,[r6,#4]
-        ldr      r12,[r7,#0x48]
-        mov      r2,r1,lsl #1
-        ldr      r1,[r6,#0x20]
-        ldr      r0,[r6]
-        mov      r1,r1,lsl #1
-        smull    r4,lr,r12,r1
-        ldr      r3,[r6,#0x1c]
-        str      lr,[r6]
-        ldr      r12,[r7,#0x4c]
-        mov      r3,r3,lsl #1
-        smull    r4,lr,r12,r3
-        mov      r0,r0,lsl #1
-        ldr      r12,[r7,#0x64]
-        str      lr,[r6,#4]
-        smull    r4,lr,r12,r2
-        ldr      r12,[r7,#0x68]
-        str      lr,[r6,#0x1c]
-        smull    r4,lr,r12,r0
-        ldr      r12,[r7,#0x6c]
-        str      lr,[r6,#0x20]
-        smull    lr,r0,r12,r0
-        ldr      r12,[r7,#0x70]
-        str      r0,[r6,#0x24]
-        smull    r0,r2,r12,r2
-        ldr      r0,[r7,#0x88]
-        str      r2,[r6,#0x28]
-        smull    r3,r2,r0,r3
-        ldr      r0,[r7,#0x8c]
-        str      r2,[r6,#0x40]
-        smull    r2,r1,r0,r1
-        str      r1,[r6,#0x44]
-        ldr      r0,[r6,#0x18]
-        ldr      lr,[r7,#0x50]
-        mov      r1,r0,lsl #1
-        ldr      r0,[r6,#0x14]
-        smull    r5,r4,lr,r1
-        ldr      r12,[r6,#0x10]
-        mov      r3,r0,lsl #1
-        ldr      r0,[r6,#0xc]
-        mov      r12,r12,lsl #1
-        mov      r2,r0,lsl #1
-        ldr      r0,[r6,#8]
-        str      r4,[r6,#8]
-        ldr      lr,[r7,#0x54]
-        mov      r0,r0,lsl #1
-        smull    r5,r4,lr,r3
-        ldr      lr,[r7,#0x58]
-        str      r4,[r6,#0xc]
-        smull    r5,r4,lr,r12
-        ldr      lr,[r7,#0x5c]
-        str      r4,[r6,#0x10]
-        smull    r5,r4,lr,r2
-        ldr      lr,[r7,#0x60]
-        str      r4,[r6,#0x14]
-        smull    r5,r4,lr,r0
-        ldr      lr,[r7,#0x74]
-        str      r4,[r6,#0x18]
-        smull    r4,r0,lr,r0
-        ldr      lr,[r7,#0x78]
-        str      r0,[r6,#0x2c]
-        smull    r0,r2,lr,r2
-        ldr      r0,[r7,#0x7c]
-        str      r2,[r6,#0x30]
-        smull    r12,r2,r0,r12
-        ldr      r0,[r7,#0x80]
-        str      r2,[r6,#0x34]
-        smull    r3,r2,r0,r3
-        ldr      r0,[r7,#0x84]
-        str      r2,[r6,#0x38]
-        smull    r2,r1,r0,r1
-        str      r1,[r6,#0x3c]
-        ldmfd    sp!,{r4-r10,pc}
-table
-        DCD      cosTerms_dct18
-        ENDP
-
-;------------------------------------------------------------------------------
-
- AREA |.constdata|, DATA, READONLY, ALIGN=2
-
-;------------------------------------------------------------------------------
-
-cosTerms_dct18
-        DCD      0x0807d2b0
-        DCD      0x08483ee0
-        DCD      0x08d3b7d0
-        DCD      0x09c42570
-        DCD      0x0b504f30
-        DCD      0x0df29440
-        DCD      0x12edfb20
-        DCD      0x1ee8dd40
-        DCD      0x5bca2a00
-cosTerms_1_ov_cos_phi
-        DCD      0x400f9c00
-        DCD      0x408d6080
-        DCD      0x418dcb80
-        DCD      0x431b1a00
-        DCD      0x4545ea00
-        DCD      0x48270680
-        DCD      0x4be25480
-        DCD      0x50ab9480
-        DCD      0x56ce4d80
-        DCD      0x05ebb630
-        DCD      0x06921a98
-        DCD      0x0771d3a8
-        DCD      0x08a9a830
-        DCD      0x0a73d750
-        DCD      0x0d4d5260
-        DCD      0x127b1ca0
-        DCD      0x1ea52b40
-        DCD      0x5bb3cc80
-
-
-
-        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.s
deleted file mode 100644
index d4fcad5..0000000
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18.s
+++ /dev/null
@@ -1,364 +0,0 @@
-; ------------------------------------------------------------------
-; Copyright (C) 2008 PacketVideo
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;      http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-; express or implied.
-; See the License for the specific language governing permissions
-; and limitations under the License.
-; -------------------------------------------------------------------
-
-;
-;
-;   Filename: pvmp3_dct_18.s
-;
-;     Date: 09/21/2007
-;
-;------------------------------------------------------------------------------
-
-        EXPORT pvmp3_mdct_18
-
-        IMPORT ||Lib$$Request$$armlib|| [WEAK]
-        IMPORT ||Lib$$Request$$cpplib|| [WEAK]
-        IMPORT pvmp3_dct_9
-
-
-;------------------------------------------------------------------------------
-
- AREA |.text|, CODE, READONLY, ALIGN=2
-
-
-;------------------------------------------------------------------------------
-
-|pvmp3_mdct_18| PROC
-        stmfd    sp!,{r4-r10,lr}
-        mov      r7,r2
-        ldr      r2,table
-        mov      r6,r1
-        add      r3,r2,#0x24
-        add      r12,r3,#0x44
-        add      r1,r0,#0x44
-        mov      r5,r0
-
-;    for ( i=9; i!=0; i--)
-;    {
-
-        mov      r4,#9
-Loop_1
-
-;       tmp  = *(pt_vec);
-;		tmp1 = *(pt_vec_o);
-
-        ldr      lr,[r0]		;; tmp  == lr
-        ldr      r8,[r3],#4		;; tmp1 == r8
-
-;        tmp  = fxp_mul32_Q32( tmp<<1,  *(pt_cos++  ));
-;        tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--));
-
-        mov      lr,lr,lsl #1
-        smull    r10,lr,r8,lr
-        ldr      r8,[r12],#-4
-        ldr      r9,[r1]
-        subs     r4,r4,#1
-        smull    r9,r10,r8,r9
-        mov      r8,r9,lsr #27
-        add      r8,r8,r10,lsl #5
-
-;        *(pt_vec++)   =   tmp + tmp1 ;
-;        *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++));
-
-        add      r9,lr,r8
-        sub      r8,lr,r8
-        ldr      lr,[r2],#4
-        str      r9,[r0],#4
-        smull    r8,r9,lr,r8
-        mov      lr,r8,lsr #28
-        add      lr,lr,r9,lsl #4
-        str      lr,[r1],#-4
-        bne      Loop_1
-
-;		}
-
-        mov      r0,r5			;; r0 = vec
-        bl       pvmp3_dct_9
-        add      r0,r5,#0x24	;; r0 = &vec[9]
-        bl       pvmp3_dct_9
-
-        ldr      r0,[r5,#0x20]
-        ldr      r2,[r5,#0x40]
-        str      r0,[r5,#0x40]
-        ldr      r0,[r5,#0x1c]
-        ldr      r3,[r5,#0x38]
-        str      r0,[r5,#0x38]
-        ldr      r1,[r5,#0x18]
-        ldr      r0,[r5,#0x30]
-        str      r1,[r5,#0x30]
-        ldr      r12,[r5,#0x14]
-        ldr      r1,[r5,#0x28]
-        str      r12,[r5,#0x28]
-        ldr      r12,[r5,#0x10]
-        str      r12,[r5,#0x20]
-        ldr      r12,[r5,#0xc]
-        str      r12,[r5,#0x18]
-        ldr      r12,[r5,#8]
-        str      r12,[r5,#0x10]
-        ldr      r12,[r5,#4]
-        str      r12,[r5,#8]
-        ldr      r12,[r5,#0x24]
-        sub      r12,r12,r1
-        str      r12,[r5,#4]
-        ldr      r12,[r5,#0x2c]
-        sub      r1,r12,r1
-        str      r1,[r5,#0xc]
-        sub      r1,r12,r0
-        str      r1,[r5,#0x14]
-        ldr      r1,[r5,#0x34]
-        sub      r0,r1,r0
-        str      r0,[r5,#0x1c]
-        sub      r0,r1,r3
-        str      r0,[r5,#0x24]
-        ldr      r1,[r5,#0x3c]
-        sub      r3,r1,r3
-        sub      r1,r1,r2
-        str      r1,[r5,#0x34]
-        str      r3,[r5,#0x2c]
-        ldr      r1,[r5,#0x44]
-        sub      r1,r1,r2
-        str      r1,[r5,#0x3c]
-        ldr      r12,[r5,#0]
-
-Loop_2
-        add      r1,r5,r4,lsl #2
-        ldr      r2,[r1,#0x28]
-        ldr      r3,[r6,r4,lsl #2]
-        add      r0,r0,r2
-        str      r0,[r1,#0x28]
-        ldr      lr,[r7,r4,lsl #2]
-        ldr      r1,[r1,#4]
-        smlal    r0,r3,lr,r0
-        mov      r0,r2
-        add      r2,r12,r1
-        rsb      r2,r2,#0
-        str      r3,[r5,r4,lsl #2]
-        str      r2,[r6,r4,lsl #2]
-        add      r4,r4,#1
-        cmp      r4,#6
-        mov      r12,r1
-
-        blt      Loop_2
-
-        ldr      r1,[r5,#0x40]
-        ldr      r2,[r6,#0x18]
-        add      r3,r0,r1
-        str      r3,[r5,#0x40]
-        ldr      lr,[r7,r4,lsl #2]
-        mov      r3,r3,lsl #1
-        ldr      r0,[r5,#0x1c]
-        smlal    r3,r2,lr,r3
-        add      r3,r12,r0
-        str      r2,[r5,#0x18]
-        ldr      r2,[r6,#0x1c]
-        rsb      r3,r3,#0
-        str      r3,[r6,#0x18]
-        ldr      r3,[r5,#0x20]
-        add      r0,r3,r0
-        rsb      r0,r0,#0
-        str      r0,[r6,#0x1c]
-        ldr      r3,[r5,#0x44]
-        ldr      r0,[r6,#0x20]
-        add      r3,r3,r1
-        mov      r1,r2
-        ldr      r10,[r7,#0x1c]
-        mov      r2,r3,lsl #1
-        smlal    r12,r1,r10,r2
-        str      r1,[r5,#0x1c]
-        ldr      r1,[r5,#0x20]
-        ldr      r3,[r5,#0x24]
-        add      r1,r1,r3
-        rsb      r1,r1,#0
-        str      r1,[r6,#0x20]
-        ldr      r1,[r5,#0x44]
-        ldr      r3,[r7,#0x20]
-        mov      r1,r1,lsl #1
-        smlal    r12,r0,r3,r1
-        ldr      lr,[r7,#0x24]
-        ldr      r3,[r6,#0x24]
-        str      r0,[r5,#0x20]
-        smlal    r1,r3,lr,r1
-        ldr      r0,[r6,#0x40]
-        ldr      r12,[r6,#0x44]
-        str      r3,[r5,#0x24]
-        ldr      r1,[r5,#0x28]
-        ldr      r3,[r7,#0x44]
-        mov      r1,r1,lsl #1
-        smlal    r1,r12,r3,r1
-        ldr      r1,[r5,#0x40]
-        str      r12,[r5,#0x44]
-        rsb      r8,r1,#0
-        str      r8,[r5,#0x28]
-        ldr      r1,[r5,#0x2c]
-        ldr      r3,[r7,#0x40]
-        mov      r1,r1,lsl #1
-        smlal    r1,r0,r3,r1
-        str      r0,[r5,#0x40]
-        ldr      r0,[r5,#0x3c]
-        ldr      r1,[r6,#0x38]
-        ldr      r3,[r6,#0x3c]
-        rsb      r9,r0,#0
-        str      r9,[r5,#0x2c]
-        ldr      r0,[r5,#0x30]
-        ldr      r12,[r7,#0x3c]
-        mov      r0,r0,lsl #1
-        smlal    r0,r3,r12,r0
-        str      r3,[r5,#0x3c]
-        ldr      r0,[r5,#0x38]
-        rsb      r0,r0,#0
-        str      r0,[r5,#0x30]
-        ldr      r3,[r5,#0x34]
-        ldr      r12,[r7,#0x38]
-        mov      r3,r3,lsl #1
-        smlal    r3,r1,r12,r3
-        mov      r0,r0,lsl #1
-        str      r1,[r5,#0x38]
-        ldr      r4,[r7,#0x34]
-        ldr      r1,[r6,#0x34]
-        ldr      r3,[r6,#0x30]
-        smlal    r0,r1,r4,r0
-        ldr      r12,[r6,#0x2c]
-        ldr      lr,[r6,#0x28]
-        str      r1,[r5,#0x34]
-        ldr      r1,[r7,#0x30]
-        mov      r0,r9,lsl #1
-        smlal    r0,r3,r1,r0
-        mov      r0,r8,lsl #1
-        ldr      r1,[r7,#0x2c]
-        str      r3,[r5,#0x30]
-        smlal    r0,r12,r1,r0
-        ldr      r0,[r7,#0x28]
-        str      r12,[r5,#0x2c]
-        smlal    r2,lr,r0,r2
-        str      lr,[r5,#0x28]
-        ldr      r1,[r6,#4]
-        ldr      r12,[r7,#0x48]
-        mov      r2,r1,lsl #1
-        ldr      r1,[r6,#0x20]
-        ldr      r0,[r6]
-        mov      r1,r1,lsl #1
-        smull    r4,lr,r12,r1
-        ldr      r3,[r6,#0x1c]
-        str      lr,[r6]
-        ldr      r12,[r7,#0x4c]
-        mov      r3,r3,lsl #1
-        smull    r4,lr,r12,r3
-        mov      r0,r0,lsl #1
-        ldr      r12,[r7,#0x64]
-        str      lr,[r6,#4]
-        smull    r4,lr,r12,r2
-        ldr      r12,[r7,#0x68]
-        str      lr,[r6,#0x1c]
-        smull    r4,lr,r12,r0
-        ldr      r12,[r7,#0x6c]
-        str      lr,[r6,#0x20]
-        smull    lr,r0,r12,r0
-        ldr      r12,[r7,#0x70]
-        str      r0,[r6,#0x24]
-        smull    r0,r2,r12,r2
-        ldr      r0,[r7,#0x88]
-        str      r2,[r6,#0x28]
-        smull    r3,r2,r0,r3
-        ldr      r0,[r7,#0x8c]
-        str      r2,[r6,#0x40]
-        smull    r2,r1,r0,r1
-        str      r1,[r6,#0x44]
-        ldr      r0,[r6,#0x18]
-        ldr      lr,[r7,#0x50]
-        mov      r1,r0,lsl #1
-        ldr      r0,[r6,#0x14]
-        smull    r5,r4,lr,r1
-        ldr      r12,[r6,#0x10]
-        mov      r3,r0,lsl #1
-        ldr      r0,[r6,#0xc]
-        mov      r12,r12,lsl #1
-        mov      r2,r0,lsl #1
-        ldr      r0,[r6,#8]
-        str      r4,[r6,#8]
-        ldr      lr,[r7,#0x54]
-        mov      r0,r0,lsl #1
-        smull    r5,r4,lr,r3
-        ldr      lr,[r7,#0x58]
-        str      r4,[r6,#0xc]
-        smull    r5,r4,lr,r12
-        ldr      lr,[r7,#0x5c]
-        str      r4,[r6,#0x10]
-        smull    r5,r4,lr,r2
-        ldr      lr,[r7,#0x60]
-        str      r4,[r6,#0x14]
-        smull    r5,r4,lr,r0
-        ldr      lr,[r7,#0x74]
-        str      r4,[r6,#0x18]
-        smull    r4,r0,lr,r0
-        ldr      lr,[r7,#0x78]
-        str      r0,[r6,#0x2c]
-        smull    r0,r2,lr,r2
-        ldr      r0,[r7,#0x7c]
-        str      r2,[r6,#0x30]
-        smull    r12,r2,r0,r12
-        ldr      r0,[r7,#0x80]
-        str      r2,[r6,#0x34]
-        smull    r3,r2,r0,r3
-        ldr      r0,[r7,#0x84]
-        str      r2,[r6,#0x38]
-        smull    r2,r1,r0,r1
-        str      r1,[r6,#0x3c]
-        ldmfd    sp!,{r4-r10,pc}
-table
-        DCD      ||.constdata$1||
-        ENDP
-
-;------------------------------------------------------------------------------
-
- AREA |.constdata|, DATA, READONLY, ALIGN=2
-
-;------------------------------------------------------------------------------
-
-||.constdata$1||
-cosTerms_dct18
-        DCD      0x0807d2b0
-        DCD      0x08483ee0
-        DCD      0x08d3b7d0
-        DCD      0x09c42570
-        DCD      0x0b504f30
-        DCD      0x0df29440
-        DCD      0x12edfb20
-        DCD      0x1ee8dd40
-        DCD      0x5bca2a00
-cosTerms_1_ov_cos_phi
-        DCD      0x400f9c00
-        DCD      0x408d6080
-        DCD      0x418dcb80
-        DCD      0x431b1a00
-        DCD      0x4545ea00
-        DCD      0x48270680
-        DCD      0x4be25480
-        DCD      0x50ab9480
-        DCD      0x56ce4d80
-        DCD      0x05ebb630
-        DCD      0x06921a98
-        DCD      0x0771d3a8
-        DCD      0x08a9a830
-        DCD      0x0a73d750
-        DCD      0x0d4d5260
-        DCD      0x127b1ca0
-        DCD      0x1ea52b40
-        DCD      0x5bb3cc80
-
-
-
-        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_arm.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_arm.s
new file mode 100644
index 0000000..9401d8c
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_arm.s
@@ -0,0 +1,369 @@
+; ------------------------------------------------------------------
+; Copyright (C) 1998-2009 PacketVideo
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+; express or implied.
+; See the License for the specific language governing permissions
+; and limitations under the License.
+; -------------------------------------------------------------------
+
+;
+;
+;   Filename: pvmp3_dct_18.s
+;
+;------------------------------------------------------------------------------
+; REVISION HISTORY
+;
+;
+; Who:                                   Date: MM/DD/YYYY
+; Description: 
+;
+;------------------------------------------------------------------------------
+
+        EXPORT pvmp3_mdct_18
+
+        IMPORT ||Lib$$Request$$armlib|| [WEAK]
+        IMPORT ||Lib$$Request$$cpplib|| [WEAK]
+        IMPORT pvmp3_dct_9
+
+
+;------------------------------------------------------------------------------
+
+ AREA |.text|, CODE, READONLY, ALIGN=2
+
+
+;------------------------------------------------------------------------------
+
+|pvmp3_mdct_18| PROC
+        stmfd    sp!,{r4-r10,lr}
+        mov      r7,r2
+        ldr      r2,table
+        mov      r6,r1
+        add      r3,r2,#0x24
+        add      r12,r3,#0x44
+        add      r1,r0,#0x44
+        mov      r5,r0
+
+;    for ( i=9; i!=0; i--)
+;    {
+
+        mov      r4,#9
+Loop_1
+
+;       tmp  = *(pt_vec);
+;		tmp1 = *(pt_vec_o);
+
+        ldr      lr,[r0]		;; tmp  == lr
+        ldr      r8,[r3],#4		;; tmp1 == r8
+
+;        tmp  = fxp_mul32_Q32( tmp<<1,  *(pt_cos++  ));
+;        tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--));
+
+        mov      lr,lr,lsl #1
+        smull    r10,lr,r8,lr
+        ldr      r8,[r12],#-4
+        ldr      r9,[r1]
+        subs     r4,r4,#1
+        smull    r9,r10,r8,r9
+        mov      r8,r9,lsr #27
+        add      r8,r8,r10,lsl #5
+
+;        *(pt_vec++)   =   tmp + tmp1 ;
+;        *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++));
+
+        add      r9,lr,r8
+        sub      r8,lr,r8
+        ldr      lr,[r2],#4
+        str      r9,[r0],#4
+        smull    r8,r9,lr,r8
+        mov      lr,r8,lsr #28
+        add      lr,lr,r9,lsl #4
+        str      lr,[r1],#-4
+        bne      Loop_1
+
+;		}
+
+        mov      r0,r5			;; r0 = vec
+        bl       pvmp3_dct_9
+        add      r0,r5,#0x24	;; r0 = &vec[9]
+        bl       pvmp3_dct_9
+
+        ldr      r0,[r5,#0x20]
+        ldr      r2,[r5,#0x40]
+        str      r0,[r5,#0x40]
+        ldr      r0,[r5,#0x1c]
+        ldr      r3,[r5,#0x38]
+        str      r0,[r5,#0x38]
+        ldr      r1,[r5,#0x18]
+        ldr      r0,[r5,#0x30]
+        str      r1,[r5,#0x30]
+        ldr      r12,[r5,#0x14]
+        ldr      r1,[r5,#0x28]
+        str      r12,[r5,#0x28]
+        ldr      r12,[r5,#0x10]
+        str      r12,[r5,#0x20]
+        ldr      r12,[r5,#0xc]
+        str      r12,[r5,#0x18]
+        ldr      r12,[r5,#8]
+        str      r12,[r5,#0x10]
+        ldr      r12,[r5,#4]
+        str      r12,[r5,#8]
+        ldr      r12,[r5,#0x24]
+        sub      r12,r12,r1
+        str      r12,[r5,#4]
+        ldr      r12,[r5,#0x2c]
+        sub      r1,r12,r1
+        str      r1,[r5,#0xc]
+        sub      r1,r12,r0
+        str      r1,[r5,#0x14]
+        ldr      r1,[r5,#0x34]
+        sub      r0,r1,r0
+        str      r0,[r5,#0x1c]
+        sub      r0,r1,r3
+        str      r0,[r5,#0x24]
+        ldr      r1,[r5,#0x3c]
+        sub      r3,r1,r3
+        sub      r1,r1,r2
+        str      r1,[r5,#0x34]
+        str      r3,[r5,#0x2c]
+        ldr      r1,[r5,#0x44]
+        sub      r1,r1,r2
+        str      r1,[r5,#0x3c]
+        ldr      r12,[r5,#0]
+
+Loop_2
+        add      r1,r5,r4,lsl #2
+        ldr      r2,[r1,#0x28]
+        ldr      r3,[r6,r4,lsl #2]
+        add      r0,r0,r2
+        str      r0,[r1,#0x28]
+        ldr      lr,[r7,r4,lsl #2]
+        ldr      r1,[r1,#4]
+        smlal    r0,r3,lr,r0
+        mov      r0,r2
+        add      r2,r12,r1
+        rsb      r2,r2,#0
+        str      r3,[r5,r4,lsl #2]
+        str      r2,[r6,r4,lsl #2]
+        add      r4,r4,#1
+        cmp      r4,#6
+        mov      r12,r1
+
+        blt      Loop_2
+
+        ldr      r1,[r5,#0x40]
+        ldr      r2,[r6,#0x18]
+        add      r3,r0,r1
+        str      r3,[r5,#0x40]
+        ldr      lr,[r7,r4,lsl #2]
+        mov      r3,r3,lsl #1
+        ldr      r0,[r5,#0x1c]
+        smlal    r3,r2,lr,r3
+        add      r3,r12,r0
+        str      r2,[r5,#0x18]
+        ldr      r2,[r6,#0x1c]
+        rsb      r3,r3,#0
+        str      r3,[r6,#0x18]
+        ldr      r3,[r5,#0x20]
+        add      r0,r3,r0
+        rsb      r0,r0,#0
+        str      r0,[r6,#0x1c]
+        ldr      r3,[r5,#0x44]
+        ldr      r0,[r6,#0x20]
+        add      r3,r3,r1
+        mov      r1,r2
+        ldr      r10,[r7,#0x1c]
+        mov      r2,r3,lsl #1
+        smlal    r12,r1,r10,r2
+        str      r1,[r5,#0x1c]
+        ldr      r1,[r5,#0x20]
+        ldr      r3,[r5,#0x24]
+        add      r1,r1,r3
+        rsb      r1,r1,#0
+        str      r1,[r6,#0x20]
+        ldr      r1,[r5,#0x44]
+        ldr      r3,[r7,#0x20]
+        mov      r1,r1,lsl #1
+        smlal    r12,r0,r3,r1
+        ldr      lr,[r7,#0x24]
+        ldr      r3,[r6,#0x24]
+        str      r0,[r5,#0x20]
+        smlal    r1,r3,lr,r1
+        ldr      r0,[r6,#0x40]
+        ldr      r12,[r6,#0x44]
+        str      r3,[r5,#0x24]
+        ldr      r1,[r5,#0x28]
+        ldr      r3,[r7,#0x44]
+        mov      r1,r1,lsl #1
+        smlal    r1,r12,r3,r1
+        ldr      r1,[r5,#0x40]
+        str      r12,[r5,#0x44]
+        rsb      r8,r1,#0
+        str      r8,[r5,#0x28]
+        ldr      r1,[r5,#0x2c]
+        ldr      r3,[r7,#0x40]
+        mov      r1,r1,lsl #1
+        smlal    r1,r0,r3,r1
+        str      r0,[r5,#0x40]
+        ldr      r0,[r5,#0x3c]
+        ldr      r1,[r6,#0x38]
+        ldr      r3,[r6,#0x3c]
+        rsb      r9,r0,#0
+        str      r9,[r5,#0x2c]
+        ldr      r0,[r5,#0x30]
+        ldr      r12,[r7,#0x3c]
+        mov      r0,r0,lsl #1
+        smlal    r0,r3,r12,r0
+        str      r3,[r5,#0x3c]
+        ldr      r0,[r5,#0x38]
+        rsb      r0,r0,#0
+        str      r0,[r5,#0x30]
+        ldr      r3,[r5,#0x34]
+        ldr      r12,[r7,#0x38]
+        mov      r3,r3,lsl #1
+        smlal    r3,r1,r12,r3
+        mov      r0,r0,lsl #1
+        str      r1,[r5,#0x38]
+        ldr      r4,[r7,#0x34]
+        ldr      r1,[r6,#0x34]
+        ldr      r3,[r6,#0x30]
+        smlal    r0,r1,r4,r0
+        ldr      r12,[r6,#0x2c]
+        ldr      lr,[r6,#0x28]
+        str      r1,[r5,#0x34]
+        ldr      r1,[r7,#0x30]
+        mov      r0,r9,lsl #1
+        smlal    r0,r3,r1,r0
+        mov      r0,r8,lsl #1
+        ldr      r1,[r7,#0x2c]
+        str      r3,[r5,#0x30]
+        smlal    r0,r12,r1,r0
+        ldr      r0,[r7,#0x28]
+        str      r12,[r5,#0x2c]
+        smlal    r2,lr,r0,r2
+        str      lr,[r5,#0x28]
+        ldr      r1,[r6,#4]
+        ldr      r12,[r7,#0x48]
+        mov      r2,r1,lsl #1
+        ldr      r1,[r6,#0x20]
+        ldr      r0,[r6]
+        mov      r1,r1,lsl #1
+        smull    r4,lr,r12,r1
+        ldr      r3,[r6,#0x1c]
+        str      lr,[r6]
+        ldr      r12,[r7,#0x4c]
+        mov      r3,r3,lsl #1
+        smull    r4,lr,r12,r3
+        mov      r0,r0,lsl #1
+        ldr      r12,[r7,#0x64]
+        str      lr,[r6,#4]
+        smull    r4,lr,r12,r2
+        ldr      r12,[r7,#0x68]
+        str      lr,[r6,#0x1c]
+        smull    r4,lr,r12,r0
+        ldr      r12,[r7,#0x6c]
+        str      lr,[r6,#0x20]
+        smull    lr,r0,r12,r0
+        ldr      r12,[r7,#0x70]
+        str      r0,[r6,#0x24]
+        smull    r0,r2,r12,r2
+        ldr      r0,[r7,#0x88]
+        str      r2,[r6,#0x28]
+        smull    r3,r2,r0,r3
+        ldr      r0,[r7,#0x8c]
+        str      r2,[r6,#0x40]
+        smull    r2,r1,r0,r1
+        str      r1,[r6,#0x44]
+        ldr      r0,[r6,#0x18]
+        ldr      lr,[r7,#0x50]
+        mov      r1,r0,lsl #1
+        ldr      r0,[r6,#0x14]
+        smull    r5,r4,lr,r1
+        ldr      r12,[r6,#0x10]
+        mov      r3,r0,lsl #1
+        ldr      r0,[r6,#0xc]
+        mov      r12,r12,lsl #1
+        mov      r2,r0,lsl #1
+        ldr      r0,[r6,#8]
+        str      r4,[r6,#8]
+        ldr      lr,[r7,#0x54]
+        mov      r0,r0,lsl #1
+        smull    r5,r4,lr,r3
+        ldr      lr,[r7,#0x58]
+        str      r4,[r6,#0xc]
+        smull    r5,r4,lr,r12
+        ldr      lr,[r7,#0x5c]
+        str      r4,[r6,#0x10]
+        smull    r5,r4,lr,r2
+        ldr      lr,[r7,#0x60]
+        str      r4,[r6,#0x14]
+        smull    r5,r4,lr,r0
+        ldr      lr,[r7,#0x74]
+        str      r4,[r6,#0x18]
+        smull    r4,r0,lr,r0
+        ldr      lr,[r7,#0x78]
+        str      r0,[r6,#0x2c]
+        smull    r0,r2,lr,r2
+        ldr      r0,[r7,#0x7c]
+        str      r2,[r6,#0x30]
+        smull    r12,r2,r0,r12
+        ldr      r0,[r7,#0x80]
+        str      r2,[r6,#0x34]
+        smull    r3,r2,r0,r3
+        ldr      r0,[r7,#0x84]
+        str      r2,[r6,#0x38]
+        smull    r2,r1,r0,r1
+        str      r1,[r6,#0x3c]
+        ldmfd    sp!,{r4-r10,pc}
+table
+        DCD      ||.constdata$1||
+        ENDP
+
+;------------------------------------------------------------------------------
+
+ AREA |.constdata|, DATA, READONLY, ALIGN=2
+
+;------------------------------------------------------------------------------
+
+||.constdata$1||
+cosTerms_dct18
+        DCD      0x0807d2b0
+        DCD      0x08483ee0
+        DCD      0x08d3b7d0
+        DCD      0x09c42570
+        DCD      0x0b504f30
+        DCD      0x0df29440
+        DCD      0x12edfb20
+        DCD      0x1ee8dd40
+        DCD      0x5bca2a00
+cosTerms_1_ov_cos_phi
+        DCD      0x400f9c00
+        DCD      0x408d6080
+        DCD      0x418dcb80
+        DCD      0x431b1a00
+        DCD      0x4545ea00
+        DCD      0x48270680
+        DCD      0x4be25480
+        DCD      0x50ab9480
+        DCD      0x56ce4d80
+        DCD      0x05ebb630
+        DCD      0x06921a98
+        DCD      0x0771d3a8
+        DCD      0x08a9a830
+        DCD      0x0a73d750
+        DCD      0x0d4d5260
+        DCD      0x127b1ca0
+        DCD      0x1ea52b40
+        DCD      0x5bb3cc80
+
+
+
+        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s
index ada3f24..96230c5 100644
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_gcc.s
@@ -1,5 +1,5 @@
 @ ------------------------------------------------------------------
-@ Copyright (C) 2008 PacketVideo
+@ Copyright (C) 1998-2009 PacketVideo
 @
 @ Licensed under the Apache License, Version 2.0 (the "License");
 @ you may not use this file except in compliance with the License.
@@ -19,7 +19,12 @@
 @
 @   Filename: pvmp3_dct_18_gcc.s
 @
-@     Date: 09/21/2007
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who:                                   Date: MM/DD/YYYY
+@ Description: 
 @
 @------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_wm.asm b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_wm.asm
new file mode 100644
index 0000000..5be75d4
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_mdct_18_wm.asm
@@ -0,0 +1,366 @@
+; ------------------------------------------------------------------
+; Copyright (C) 1998-2009 PacketVideo
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+; express or implied.
+; See the License for the specific language governing permissions
+; and limitations under the License.
+; -------------------------------------------------------------------
+
+;
+;
+;   Filename: pvmp3_dct_18.s
+;
+;------------------------------------------------------------------------------
+; REVISION HISTORY
+;
+;
+; Who:                                   Date: MM/DD/YYYY
+; Description: 
+;
+;------------------------------------------------------------------------------
+
+        EXPORT |pvmp3_mdct_18|
+
+        IMPORT pvmp3_dct_9
+
+
+;------------------------------------------------------------------------------
+
+ AREA |.text|, CODE, READONLY, ALIGN=2
+
+
+;------------------------------------------------------------------------------
+
+|pvmp3_mdct_18| PROC
+        stmfd    sp!,{r4-r10,lr}
+        mov      r7,r2
+        ldr      r2,table
+        mov      r6,r1
+        add      r3,r2,#0x24
+        add      r12,r3,#0x44
+        add      r1,r0,#0x44
+        mov      r5,r0
+
+;    for ( i=9; i!=0; i--)
+;    {
+
+        mov      r4,#9
+Loop_1
+
+;       tmp  = *(pt_vec);
+;		tmp1 = *(pt_vec_o);
+
+        ldr      lr,[r0]		;; tmp  == lr
+        ldr      r8,[r3],#4		;; tmp1 == r8
+
+;        tmp  = fxp_mul32_Q32( tmp<<1,  *(pt_cos++  ));
+;        tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--));
+
+        mov      lr,lr,lsl #1
+        smull    r10,lr,r8,lr
+        ldr      r8,[r12],#-4
+        ldr      r9,[r1]
+        subs     r4,r4,#1
+        smull    r9,r10,r8,r9
+        mov      r8,r9,lsr #27
+        add      r8,r8,r10,lsl #5
+
+;        *(pt_vec++)   =   tmp + tmp1 ;
+;        *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++));
+
+        add      r9,lr,r8
+        sub      r8,lr,r8
+        ldr      lr,[r2],#4
+        str      r9,[r0],#4
+        smull    r8,r9,lr,r8
+        mov      lr,r8,lsr #28
+        add      lr,lr,r9,lsl #4
+        str      lr,[r1],#-4
+        bne      Loop_1
+
+;		}
+
+        mov      r0,r5			;; r0 = vec
+        bl       pvmp3_dct_9
+        add      r0,r5,#0x24	;; r0 = &vec[9]
+        bl       pvmp3_dct_9
+
+        ldr      r0,[r5,#0x20]
+        ldr      r2,[r5,#0x40]
+        str      r0,[r5,#0x40]
+        ldr      r0,[r5,#0x1c]
+        ldr      r3,[r5,#0x38]
+        str      r0,[r5,#0x38]
+        ldr      r1,[r5,#0x18]
+        ldr      r0,[r5,#0x30]
+        str      r1,[r5,#0x30]
+        ldr      r12,[r5,#0x14]
+        ldr      r1,[r5,#0x28]
+        str      r12,[r5,#0x28]
+        ldr      r12,[r5,#0x10]
+        str      r12,[r5,#0x20]
+        ldr      r12,[r5,#0xc]
+        str      r12,[r5,#0x18]
+        ldr      r12,[r5,#8]
+        str      r12,[r5,#0x10]
+        ldr      r12,[r5,#4]
+        str      r12,[r5,#8]
+        ldr      r12,[r5,#0x24]
+        sub      r12,r12,r1
+        str      r12,[r5,#4]
+        ldr      r12,[r5,#0x2c]
+        sub      r1,r12,r1
+        str      r1,[r5,#0xc]
+        sub      r1,r12,r0
+        str      r1,[r5,#0x14]
+        ldr      r1,[r5,#0x34]
+        sub      r0,r1,r0
+        str      r0,[r5,#0x1c]
+        sub      r0,r1,r3
+        str      r0,[r5,#0x24]
+        ldr      r1,[r5,#0x3c]
+        sub      r3,r1,r3
+        sub      r1,r1,r2
+        str      r1,[r5,#0x34]
+        str      r3,[r5,#0x2c]
+        ldr      r1,[r5,#0x44]
+        sub      r1,r1,r2
+        str      r1,[r5,#0x3c]
+        ldr      r12,[r5,#0]
+
+Loop_2
+        add      r1,r5,r4,lsl #2
+        ldr      r2,[r1,#0x28]
+        ldr      r3,[r6,r4,lsl #2]
+        add      r0,r0,r2
+        str      r0,[r1,#0x28]
+        ldr      lr,[r7,r4,lsl #2]
+        ldr      r1,[r1,#4]
+        smlal    r0,r3,lr,r0
+        mov      r0,r2
+        add      r2,r12,r1
+        rsb      r2,r2,#0
+        str      r3,[r5,r4,lsl #2]
+        str      r2,[r6,r4,lsl #2]
+        add      r4,r4,#1
+        cmp      r4,#6
+        mov      r12,r1
+
+        blt      Loop_2
+
+        ldr      r1,[r5,#0x40]
+        ldr      r2,[r6,#0x18]
+        add      r3,r0,r1
+        str      r3,[r5,#0x40]
+        ldr      lr,[r7,r4,lsl #2]
+        mov      r3,r3,lsl #1
+        ldr      r0,[r5,#0x1c]
+        smlal    r3,r2,lr,r3
+        add      r3,r12,r0
+        str      r2,[r5,#0x18]
+        ldr      r2,[r6,#0x1c]
+        rsb      r3,r3,#0
+        str      r3,[r6,#0x18]
+        ldr      r3,[r5,#0x20]
+        add      r0,r3,r0
+        rsb      r0,r0,#0
+        str      r0,[r6,#0x1c]
+        ldr      r3,[r5,#0x44]
+        ldr      r0,[r6,#0x20]
+        add      r3,r3,r1
+        mov      r1,r2
+        ldr      r10,[r7,#0x1c]
+        mov      r2,r3,lsl #1
+        smlal    r12,r1,r10,r2
+        str      r1,[r5,#0x1c]
+        ldr      r1,[r5,#0x20]
+        ldr      r3,[r5,#0x24]
+        add      r1,r1,r3
+        rsb      r1,r1,#0
+        str      r1,[r6,#0x20]
+        ldr      r1,[r5,#0x44]
+        ldr      r3,[r7,#0x20]
+        mov      r1,r1,lsl #1
+        smlal    r12,r0,r3,r1
+        ldr      lr,[r7,#0x24]
+        ldr      r3,[r6,#0x24]
+        str      r0,[r5,#0x20]
+        smlal    r1,r3,lr,r1
+        ldr      r0,[r6,#0x40]
+        ldr      r12,[r6,#0x44]
+        str      r3,[r5,#0x24]
+        ldr      r1,[r5,#0x28]
+        ldr      r3,[r7,#0x44]
+        mov      r1,r1,lsl #1
+        smlal    r1,r12,r3,r1
+        ldr      r1,[r5,#0x40]
+        str      r12,[r5,#0x44]
+        rsb      r8,r1,#0
+        str      r8,[r5,#0x28]
+        ldr      r1,[r5,#0x2c]
+        ldr      r3,[r7,#0x40]
+        mov      r1,r1,lsl #1
+        smlal    r1,r0,r3,r1
+        str      r0,[r5,#0x40]
+        ldr      r0,[r5,#0x3c]
+        ldr      r1,[r6,#0x38]
+        ldr      r3,[r6,#0x3c]
+        rsb      r9,r0,#0
+        str      r9,[r5,#0x2c]
+        ldr      r0,[r5,#0x30]
+        ldr      r12,[r7,#0x3c]
+        mov      r0,r0,lsl #1
+        smlal    r0,r3,r12,r0
+        str      r3,[r5,#0x3c]
+        ldr      r0,[r5,#0x38]
+        rsb      r0,r0,#0
+        str      r0,[r5,#0x30]
+        ldr      r3,[r5,#0x34]
+        ldr      r12,[r7,#0x38]
+        mov      r3,r3,lsl #1
+        smlal    r3,r1,r12,r3
+        mov      r0,r0,lsl #1
+        str      r1,[r5,#0x38]
+        ldr      r4,[r7,#0x34]
+        ldr      r1,[r6,#0x34]
+        ldr      r3,[r6,#0x30]
+        smlal    r0,r1,r4,r0
+        ldr      r12,[r6,#0x2c]
+        ldr      lr,[r6,#0x28]
+        str      r1,[r5,#0x34]
+        ldr      r1,[r7,#0x30]
+        mov      r0,r9,lsl #1
+        smlal    r0,r3,r1,r0
+        mov      r0,r8,lsl #1
+        ldr      r1,[r7,#0x2c]
+        str      r3,[r5,#0x30]
+        smlal    r0,r12,r1,r0
+        ldr      r0,[r7,#0x28]
+        str      r12,[r5,#0x2c]
+        smlal    r2,lr,r0,r2
+        str      lr,[r5,#0x28]
+        ldr      r1,[r6,#4]
+        ldr      r12,[r7,#0x48]
+        mov      r2,r1,lsl #1
+        ldr      r1,[r6,#0x20]
+        ldr      r0,[r6]
+        mov      r1,r1,lsl #1
+        smull    r4,lr,r12,r1
+        ldr      r3,[r6,#0x1c]
+        str      lr,[r6]
+        ldr      r12,[r7,#0x4c]
+        mov      r3,r3,lsl #1
+        smull    r4,lr,r12,r3
+        mov      r0,r0,lsl #1
+        ldr      r12,[r7,#0x64]
+        str      lr,[r6,#4]
+        smull    r4,lr,r12,r2
+        ldr      r12,[r7,#0x68]
+        str      lr,[r6,#0x1c]
+        smull    r4,lr,r12,r0
+        ldr      r12,[r7,#0x6c]
+        str      lr,[r6,#0x20]
+        smull    lr,r0,r12,r0
+        ldr      r12,[r7,#0x70]
+        str      r0,[r6,#0x24]
+        smull    r0,r2,r12,r2
+        ldr      r0,[r7,#0x88]
+        str      r2,[r6,#0x28]
+        smull    r3,r2,r0,r3
+        ldr      r0,[r7,#0x8c]
+        str      r2,[r6,#0x40]
+        smull    r2,r1,r0,r1
+        str      r1,[r6,#0x44]
+        ldr      r0,[r6,#0x18]
+        ldr      lr,[r7,#0x50]
+        mov      r1,r0,lsl #1
+        ldr      r0,[r6,#0x14]
+        smull    r5,r4,lr,r1
+        ldr      r12,[r6,#0x10]
+        mov      r3,r0,lsl #1
+        ldr      r0,[r6,#0xc]
+        mov      r12,r12,lsl #1
+        mov      r2,r0,lsl #1
+        ldr      r0,[r6,#8]
+        str      r4,[r6,#8]
+        ldr      lr,[r7,#0x54]
+        mov      r0,r0,lsl #1
+        smull    r5,r4,lr,r3
+        ldr      lr,[r7,#0x58]
+        str      r4,[r6,#0xc]
+        smull    r5,r4,lr,r12
+        ldr      lr,[r7,#0x5c]
+        str      r4,[r6,#0x10]
+        smull    r5,r4,lr,r2
+        ldr      lr,[r7,#0x60]
+        str      r4,[r6,#0x14]
+        smull    r5,r4,lr,r0
+        ldr      lr,[r7,#0x74]
+        str      r4,[r6,#0x18]
+        smull    r4,r0,lr,r0
+        ldr      lr,[r7,#0x78]
+        str      r0,[r6,#0x2c]
+        smull    r0,r2,lr,r2
+        ldr      r0,[r7,#0x7c]
+        str      r2,[r6,#0x30]
+        smull    r12,r2,r0,r12
+        ldr      r0,[r7,#0x80]
+        str      r2,[r6,#0x34]
+        smull    r3,r2,r0,r3
+        ldr      r0,[r7,#0x84]
+        str      r2,[r6,#0x38]
+        smull    r2,r1,r0,r1
+        str      r1,[r6,#0x3c]
+        ldmfd    sp!,{r4-r10,pc}
+table
+        DCD      cosTerms_dct18
+        ENDP
+
+;------------------------------------------------------------------------------
+
+ AREA |.constdata|, DATA, READONLY, ALIGN=2
+
+;------------------------------------------------------------------------------
+
+cosTerms_dct18
+        DCD      0x0807d2b0
+        DCD      0x08483ee0
+        DCD      0x08d3b7d0
+        DCD      0x09c42570
+        DCD      0x0b504f30
+        DCD      0x0df29440
+        DCD      0x12edfb20
+        DCD      0x1ee8dd40
+        DCD      0x5bca2a00
+cosTerms_1_ov_cos_phi
+        DCD      0x400f9c00
+        DCD      0x408d6080
+        DCD      0x418dcb80
+        DCD      0x431b1a00
+        DCD      0x4545ea00
+        DCD      0x48270680
+        DCD      0x4be25480
+        DCD      0x50ab9480
+        DCD      0x56ce4d80
+        DCD      0x05ebb630
+        DCD      0x06921a98
+        DCD      0x0771d3a8
+        DCD      0x08a9a830
+        DCD      0x0a73d750
+        DCD      0x0d4d5260
+        DCD      0x127b1ca0
+        DCD      0x1ea52b40
+        DCD      0x5bb3cc80
+
+
+
+        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.asm b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.asm
deleted file mode 100644
index 1ac08dc..0000000
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.asm
+++ /dev/null
@@ -1,226 +0,0 @@
-; ------------------------------------------------------------------
-; Copyright (C) 2008 PacketVideo
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;      http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-; express or implied.
-; See the License for the specific language governing permissions
-; and limitations under the License.
-; -------------------------------------------------------------------
-
-;
-;
-;   Filename: pvmp3_polyphase_filter_window.s
-;
-;     Date: 09/21/2007
-;
-;------------------------------------------------------------------------------
-
-	CODE32
-
-	AREA	|.drectve|, DRECTVE
-
-	EXPORT	|pvmp3_polyphase_filter_window|
-	IMPORT	|pqmfSynthWin|
-
-	AREA	|.pdata|, PDATA
-
-	AREA	|.text|, CODE, ARM
-
-|pvmp3_polyphase_filter_window| PROC
-        stmfd    sp!,{r0-r2,r4-r11,lr}
-
-        sub      sp,sp,#4
-        ldr      r2,[sp,#0xc]
-        ldr      r1,PolyPh_filter_coeff
-		
-        sub      r2,r2,#1
-        mov      r10,#1
-        str      r2,[sp]
-
-; Accumulators r9, r11::> Initialization
-
-Loop_j
-        mov      r9,  #0x20
-        mov      r11, #0x20
-        mov      r4,  #0x10
-Loop_i
-        add      r2,r4,r10
-        add      r3,r0,r2,lsl #2
-        sub      r2,r4,r10
-        ldr      r5,[r3]
-        ldr      lr,[r1]
-        add      r12,r0,r2,lsl #2
-        ldr      r6,[r12,#0x780]
-        smlal    r2,r9,lr,r5
-        smlal    r2,r11,lr,r6
-        ldr      r2,[r1,#4]
-        ldr      r7,[r12,#0x80]
-        smlal    r5,r11,r2,r5
-        smull    r6,r5,r2,r6
-        sub      r9,r9,r5
-        ldr      r5,[r1,#8]
-        ldr      r8,[r3,#0x700]
-        add      r4,r4,#0x200
-        smlal    r6,r9,r5,r7
-        smull    r6,r2,r5,r8
-        ldr      r5,[r1,#0xc]
-        sub      r11,r11,r2
-        smlal    r8,r9,r5,r8
-        smlal    r7,r11,r5,r7
-        ldr      r5,[r3,#0x100]
-        ldr      r2,[r1,#0x10]
-        ldr      r6,[r12,#0x680]
-        smlal    lr,r9,r2,r5
-        smlal    lr,r11,r2,r6
-        ldr      r2,[r1,#0x14]
-        ldr      r7,[r12,#0x180]
-        smlal    r5,r11,r2,r5
-        smull    r6,r5,r2,r6
-        ldr      r6,[r1,#0x18]
-        ldr      r8,[r3,#0x600]
-        sub      r9,r9,r5
-        smlal    r5,r9,r6,r7
-        smull    r2,r5,r6,r8
-        ldr      r6,[r1,#0x1c]
-        sub      r11,r11,r5
-        smlal    r8,r9,r6,r8
-        ldr      r2,[r1,#0x20]
-        ldr      r5,[r3,#0x200]
-        smlal    r7,r11,r6,r7
-        ldr      r6,[r12,#0x580]
-        smlal    lr,r9,r2,r5
-        smlal    lr,r11,r2,r6
-        ldr      r2,[r1,#0x24]
-        ldr      r7,[r12,#0x280]
-        smlal    r5,r11,r2,r5
-        smull    r6,r5,r2,r6
-        ldr      r6,[r1,#0x28]
-        ldr      r8,[r3,#0x500]
-        sub      r9,r9,r5
-        smlal    r5,r9,r6,r7
-        smull    r2,r5,r6,r8
-        ldr      r6,[r1,#0x2c]
-        sub      r11,r11,r5
-
-        smlal    r8,r9,r6,r8
-        smlal    r7,r11,r6,r7
-        ldr      r5,[r3,#0x300]
-        ldr      r8,[r1,#0x30]
-        ldr      r6,[r12,#0x480]
-        smlal    r7,r9,r8,r5
-        smlal    r7,r11,r8,r6
-        ldr      r8,[r1,#0x34]
-        ldr      r12,[r12,#0x380]
-        smlal    r5,r11,r8,r5
-        smull    r6,r5,r8,r6
-        ldr      r6,[r1,#0x38]
-
-
-        ldr      r3,[r3,#0x400]
-        sub      r9,r9,r5
-        smlal    r7,r9,r6,r12
-        smull    r8,r7,r6,r3
-        cmp      r4,#0x210
-        sub      r11,r11,r7
-
-        ldr      r2,[r1,#0x3c]
-        add      r1,r1,#0x40
-        smlal    r3,r9,r2,r3
-        smlal    r12,r11,r2,r12
-
-        blt      Loop_i
-
-        mov      r3,r9, asr #6
-        mov      r4,r3, asr #15
-        teq      r4,r3, asr #31
-        ldr      r12,LOW_16BITS
-        ldr      r2,[sp]
-        eorne    r3,r12,r3,asr #31
-        ldr      r4,[sp,#8]
-        mov      r2,r10,lsl r2
-        add      r4,r4,r2,lsl #1
-        strh     r3,[r4]
-
-        mov      r3,r11,asr #6
-        mov      r4,r3,asr #15
-        teq      r4,r3,asr #31
-        eorne    r3,r12,r3,asr #31
-        ldr      r12,[sp,#0xc]
-        ldr      r11,[sp,#8]
-        rsb      r2,r2,r12,lsl #5
-        add      r2,r11,r2,lsl #1
-        strh     r3,[r2]
-
-        add      r10,r10,#1
-        cmp      r10,#0x10
-        blt      Loop_j
-
-; Accumulators r4, r5 Initialization
-
-        mov      r4,#0x20
-        mov      r5,#0x20
-        mov      r3,#0x10
-PolyPh_filter_loop2
-        add      r2,r0,r3,lsl #2
-        ldr      r12,[r2]
-        ldr      r8,[r1]
-        ldr      r6,[r2,#0x80]
-        smlal    r12,r4,r8,r12
-        ldr      r12,[r1,#4]
-        ldr      r7,[r2,#0x40]
-        smlal    r6,r4,r12,r6
-
-        ldr      r12,[r1,#8]
-        ldr      r6,[r2,#0x180]
-        smlal    r7,r5,r12,r7
-        ldr      r12,[r2,#0x100]
-        ldr      r7,[r1,#0xc]
-        ldr      r2,[r2,#0x140]
-        smlal    r12,r4,r7,r12
-        ldr      r12,[r1,#0x10]
-        add      r3,r3,#0x80
-        smlal    r6,r4,r12,r6
-        ldr      r6,[r1,#0x14]
-        cmp      r3,#0x210
-        smlal    r2,r5,r6,r2
-        add      r1,r1,#0x18
-
-        blt      PolyPh_filter_loop2
-        mov      r0,r4,asr #6
-        mov      r2,r0,asr #15
-        teq      r2,r0,asr #31
-        ldrne    r12,LOW_16BITS
-        ldr      r1,[sp,#8]
-        eorne    r0,r12,r0,asr #31
-        strh     r0,[r1,#0]
-        mov      r0,r5,asr #6
-        mov      r2,r0,asr #15
-        teq      r2,r0,asr #31
-        ldrne    r12,LOW_16BITS
-        ldr      r2,[sp]
-        mov      r1,#0x10
-        eorne    r0,r12,r0,asr #31
-        ldr      r12,[sp,#8]
-        mov      r1,r1,lsl r2
-        add      r1,r12,r1,lsl #1
-        strh     r0,[r1]
-        add      sp,sp,#0x10
-        ldmfd    sp!,{r4-r11,pc}
-
-
-PolyPh_filter_coeff
-        DCD      pqmfSynthWin
-LOW_16BITS
-        DCD      0x00007fff
-	
-		ENDP  ; |pvmp3_polyphase_filter_window|
-		END
-
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.s
deleted file mode 100644
index 75d7b23..0000000
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window.s
+++ /dev/null
@@ -1,232 +0,0 @@
-; ------------------------------------------------------------------
-; Copyright (C) 2008 PacketVideo
-;
-; Licensed under the Apache License, Version 2.0 (the "License");
-; you may not use this file except in compliance with the License.
-; You may obtain a copy of the License at
-;
-;      http://www.apache.org/licenses/LICENSE-2.0
-;
-; Unless required by applicable law or agreed to in writing, software
-; distributed under the License is distributed on an "AS IS" BASIS,
-; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
-; express or implied.
-; See the License for the specific language governing permissions
-; and limitations under the License.
-; -------------------------------------------------------------------
-
-;
-;
-;   Filename: pvmp3_polyphase_filter_window.s
-;
-;     Date: 09/21/2007
-;
-;------------------------------------------------------------------------------
-
-        EXPORT pvmp3_polyphase_filter_window
-
-        IMPORT ||Lib$$Request$$armlib|| [WEAK]
-        IMPORT ||Lib$$Request$$cpplib|| [WEAK]
-        IMPORT pqmfSynthWin
-
-
-
-;------------------------------------------------------------------------------
-
- AREA |.text|, CODE, READONLY, ALIGN=2
-
-
-;------------------------------------------------------------------------------
-
-|pvmp3_polyphase_filter_window| PROC
-
-        stmfd    sp!,{r0-r2,r4-r11,lr}
-
-        sub      sp,sp,#4
-        ldr      r2,[sp,#0xc]
-        ldr      r1,PolyPh_filter_coeff
-		
-        sub      r2,r2,#1
-        mov      r10,#1
-        str      r2,[sp]
-
-; Accumulators r9, r11::> Initialization
-
-Loop_j
-        mov      r9,  #0x20
-        mov      r11, #0x20
-        mov      r4,  #0x10
-Loop_i
-        add      r2,r4,r10
-        add      r3,r0,r2,lsl #2
-        sub      r2,r4,r10
-        ldr      r5,[r3]
-        ldr      lr,[r1]
-        add      r12,r0,r2,lsl #2
-        ldr      r6,[r12,#0x780]
-        smlal    r2,r9,lr,r5
-        smlal    r2,r11,lr,r6
-        ldr      r2,[r1,#4]
-        ldr      r7,[r12,#0x80]
-        smlal    r5,r11,r2,r5
-        smull    r6,r5,r2,r6
-        sub      r9,r9,r5
-        ldr      r5,[r1,#8]
-        ldr      r8,[r3,#0x700]
-        add      r4,r4,#0x200
-        smlal    r6,r9,r5,r7
-        smull    r6,r2,r5,r8
-        ldr      r5,[r1,#0xc]
-        sub      r11,r11,r2
-        smlal    r8,r9,r5,r8
-        smlal    r7,r11,r5,r7
-        ldr      r5,[r3,#0x100]
-        ldr      r2,[r1,#0x10]
-        ldr      r6,[r12,#0x680]
-        smlal    lr,r9,r2,r5
-        smlal    lr,r11,r2,r6
-        ldr      r2,[r1,#0x14]
-        ldr      r7,[r12,#0x180]
-        smlal    r5,r11,r2,r5
-        smull    r6,r5,r2,r6
-        ldr      r6,[r1,#0x18]
-        ldr      r8,[r3,#0x600]
-        sub      r9,r9,r5
-        smlal    r5,r9,r6,r7
-        smull    r2,r5,r6,r8
-        ldr      r6,[r1,#0x1c]
-        sub      r11,r11,r5
-        smlal    r8,r9,r6,r8
-        ldr      r2,[r1,#0x20]
-        ldr      r5,[r3,#0x200]
-        smlal    r7,r11,r6,r7
-        ldr      r6,[r12,#0x580]
-        smlal    lr,r9,r2,r5
-        smlal    lr,r11,r2,r6
-        ldr      r2,[r1,#0x24]
-        ldr      r7,[r12,#0x280]
-        smlal    r5,r11,r2,r5
-        smull    r6,r5,r2,r6
-        ldr      r6,[r1,#0x28]
-        ldr      r8,[r3,#0x500]
-        sub      r9,r9,r5
-        smlal    r5,r9,r6,r7
-        smull    r2,r5,r6,r8
-        ldr      r6,[r1,#0x2c]
-        sub      r11,r11,r5
-
-        smlal    r8,r9,r6,r8
-        smlal    r7,r11,r6,r7
-        ldr      r5,[r3,#0x300]
-        ldr      r8,[r1,#0x30]
-        ldr      r6,[r12,#0x480]
-        smlal    r7,r9,r8,r5
-        smlal    r7,r11,r8,r6
-        ldr      r8,[r1,#0x34]
-        ldr      r12,[r12,#0x380]
-        smlal    r5,r11,r8,r5
-        smull    r6,r5,r8,r6
-        ldr      r6,[r1,#0x38]
-
-
-        ldr      r3,[r3,#0x400]
-        sub      r9,r9,r5
-        smlal    r7,r9,r6,r12
-        smull    r8,r7,r6,r3
-        cmp      r4,#0x210
-        sub      r11,r11,r7
-
-        ldr      r2,[r1,#0x3c]
-        add      r1,r1,#0x40
-        smlal    r3,r9,r2,r3
-        smlal    r12,r11,r2,r12
-
-        blt      Loop_i
-
-        mov      r3,r9, asr #6
-        mov      r4,r3, asr #15
-        teq      r4,r3, asr #31
-        ldr      r12,LOW_16BITS
-        ldr      r2,[sp]
-        eorne    r3,r12,r3,asr #31
-        ldr      r4,[sp,#8]
-        mov      r2,r10,lsl r2
-        add      r4,r4,r2,lsl #1
-        strh     r3,[r4]
-
-        mov      r3,r11,asr #6
-        mov      r4,r3,asr #15
-        teq      r4,r3,asr #31
-        eorne    r3,r12,r3,asr #31
-        ldr      r12,[sp,#0xc]
-        ldr      r11,[sp,#8]
-        rsb      r2,r2,r12,lsl #5
-        add      r2,r11,r2,lsl #1
-        strh     r3,[r2]
-
-        add      r10,r10,#1
-        cmp      r10,#0x10
-        blt      Loop_j
-
-; Accumulators r4, r5 Initialization
-
-        mov      r4,#0x20
-        mov      r5,#0x20
-        mov      r3,#0x10
-PolyPh_filter_loop2
-        add      r2,r0,r3,lsl #2
-        ldr      r12,[r2]
-        ldr      r8,[r1]
-        ldr      r6,[r2,#0x80]
-        smlal    r12,r4,r8,r12
-        ldr      r12,[r1,#4]
-        ldr      r7,[r2,#0x40]
-        smlal    r6,r4,r12,r6
-
-        ldr      r12,[r1,#8]
-        ldr      r6,[r2,#0x180]
-        smlal    r7,r5,r12,r7
-        ldr      r12,[r2,#0x100]
-        ldr      r7,[r1,#0xc]
-        ldr      r2,[r2,#0x140]
-        smlal    r12,r4,r7,r12
-        ldr      r12,[r1,#0x10]
-        add      r3,r3,#0x80
-        smlal    r6,r4,r12,r6
-        ldr      r6,[r1,#0x14]
-        cmp      r3,#0x210
-        smlal    r2,r5,r6,r2
-        add      r1,r1,#0x18
-
-        blt      PolyPh_filter_loop2
-        mov      r0,r4,asr #6
-        mov      r2,r0,asr #15
-        teq      r2,r0,asr #31
-        ldrne    r12,LOW_16BITS
-        ldr      r1,[sp,#8]
-        eorne    r0,r12,r0,asr #31
-        strh     r0,[r1,#0]
-        mov      r0,r5,asr #6
-        mov      r2,r0,asr #15
-        teq      r2,r0,asr #31
-        ldrne    r12,LOW_16BITS
-        ldr      r2,[sp]
-        mov      r1,#0x10
-        eorne    r0,r12,r0,asr #31
-        ldr      r12,[sp,#8]
-        mov      r1,r1,lsl r2
-        add      r1,r12,r1,lsl #1
-        strh     r0,[r1]
-        add      sp,sp,#0x10
-        ldmfd    sp!,{r4-r11,pc}
-
-
-PolyPh_filter_coeff
-        DCD      pqmfSynthWin
-LOW_16BITS
-        DCD      0x00007fff
-
-        ENDP
-
-
-        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_arm.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_arm.s
new file mode 100644
index 0000000..abec599
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_arm.s
@@ -0,0 +1,237 @@
+; ------------------------------------------------------------------
+; Copyright (C) 1998-2009 PacketVideo
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+; express or implied.
+; See the License for the specific language governing permissions
+; and limitations under the License.
+; -------------------------------------------------------------------
+
+;
+;
+;   Filename: pvmp3_polyphase_filter_window.s
+;
+;------------------------------------------------------------------------------
+; REVISION HISTORY
+;
+;
+; Who:                                   Date: MM/DD/YYYY
+; Description: 
+;
+;------------------------------------------------------------------------------
+
+        EXPORT pvmp3_polyphase_filter_window
+
+        IMPORT ||Lib$$Request$$armlib|| [WEAK]
+        IMPORT ||Lib$$Request$$cpplib|| [WEAK]
+        IMPORT pqmfSynthWin
+
+
+
+;------------------------------------------------------------------------------
+
+ AREA |.text|, CODE, READONLY, ALIGN=2
+
+
+;------------------------------------------------------------------------------
+
+|pvmp3_polyphase_filter_window| PROC
+
+        stmfd    sp!,{r0-r2,r4-r11,lr}
+
+        sub      sp,sp,#4
+        ldr      r2,[sp,#0xc]
+        ldr      r1,PolyPh_filter_coeff
+		
+        sub      r2,r2,#1
+        mov      r10,#1
+        str      r2,[sp]
+
+; Accumulators r9, r11::> Initialization
+
+Loop_j
+        mov      r9,  #0x20
+        mov      r11, #0x20
+        mov      r4,  #0x10
+Loop_i
+        add      r2,r4,r10
+        add      r3,r0,r2,lsl #2
+        sub      r2,r4,r10
+        ldr      r5,[r3]
+        ldr      lr,[r1]
+        add      r12,r0,r2,lsl #2
+        ldr      r6,[r12,#0x780]
+        smlal    r2,r9,lr,r5
+        smlal    r2,r11,lr,r6
+        ldr      r2,[r1,#4]
+        ldr      r7,[r12,#0x80]
+        smlal    r5,r11,r2,r5
+        smull    r6,r5,r2,r6
+        sub      r9,r9,r5
+        ldr      r5,[r1,#8]
+        ldr      r8,[r3,#0x700]
+        add      r4,r4,#0x200
+        smlal    r6,r9,r5,r7
+        smull    r6,r2,r5,r8
+        ldr      r5,[r1,#0xc]
+        sub      r11,r11,r2
+        smlal    r8,r9,r5,r8
+        smlal    r7,r11,r5,r7
+        ldr      r5,[r3,#0x100]
+        ldr      r2,[r1,#0x10]
+        ldr      r6,[r12,#0x680]
+        smlal    lr,r9,r2,r5
+        smlal    lr,r11,r2,r6
+        ldr      r2,[r1,#0x14]
+        ldr      r7,[r12,#0x180]
+        smlal    r5,r11,r2,r5
+        smull    r6,r5,r2,r6
+        ldr      r6,[r1,#0x18]
+        ldr      r8,[r3,#0x600]
+        sub      r9,r9,r5
+        smlal    r5,r9,r6,r7
+        smull    r2,r5,r6,r8
+        ldr      r6,[r1,#0x1c]
+        sub      r11,r11,r5
+        smlal    r8,r9,r6,r8
+        ldr      r2,[r1,#0x20]
+        ldr      r5,[r3,#0x200]
+        smlal    r7,r11,r6,r7
+        ldr      r6,[r12,#0x580]
+        smlal    lr,r9,r2,r5
+        smlal    lr,r11,r2,r6
+        ldr      r2,[r1,#0x24]
+        ldr      r7,[r12,#0x280]
+        smlal    r5,r11,r2,r5
+        smull    r6,r5,r2,r6
+        ldr      r6,[r1,#0x28]
+        ldr      r8,[r3,#0x500]
+        sub      r9,r9,r5
+        smlal    r5,r9,r6,r7
+        smull    r2,r5,r6,r8
+        ldr      r6,[r1,#0x2c]
+        sub      r11,r11,r5
+
+        smlal    r8,r9,r6,r8
+        smlal    r7,r11,r6,r7
+        ldr      r5,[r3,#0x300]
+        ldr      r8,[r1,#0x30]
+        ldr      r6,[r12,#0x480]
+        smlal    r7,r9,r8,r5
+        smlal    r7,r11,r8,r6
+        ldr      r8,[r1,#0x34]
+        ldr      r12,[r12,#0x380]
+        smlal    r5,r11,r8,r5
+        smull    r6,r5,r8,r6
+        ldr      r6,[r1,#0x38]
+
+
+        ldr      r3,[r3,#0x400]
+        sub      r9,r9,r5
+        smlal    r7,r9,r6,r12
+        smull    r8,r7,r6,r3
+        cmp      r4,#0x210
+        sub      r11,r11,r7
+
+        ldr      r2,[r1,#0x3c]
+        add      r1,r1,#0x40
+        smlal    r3,r9,r2,r3
+        smlal    r12,r11,r2,r12
+
+        blt      Loop_i
+
+        mov      r3,r9, asr #6
+        mov      r4,r3, asr #15
+        teq      r4,r3, asr #31
+        ldr      r12,LOW_16BITS
+        ldr      r2,[sp]
+        eorne    r3,r12,r3,asr #31
+        ldr      r4,[sp,#8]
+        mov      r2,r10,lsl r2
+        add      r4,r4,r2,lsl #1
+        strh     r3,[r4]
+
+        mov      r3,r11,asr #6
+        mov      r4,r3,asr #15
+        teq      r4,r3,asr #31
+        eorne    r3,r12,r3,asr #31
+        ldr      r12,[sp,#0xc]
+        ldr      r11,[sp,#8]
+        rsb      r2,r2,r12,lsl #5
+        add      r2,r11,r2,lsl #1
+        strh     r3,[r2]
+
+        add      r10,r10,#1
+        cmp      r10,#0x10
+        blt      Loop_j
+
+; Accumulators r4, r5 Initialization
+
+        mov      r4,#0x20
+        mov      r5,#0x20
+        mov      r3,#0x10
+PolyPh_filter_loop2
+        add      r2,r0,r3,lsl #2
+        ldr      r12,[r2]
+        ldr      r8,[r1]
+        ldr      r6,[r2,#0x80]
+        smlal    r12,r4,r8,r12
+        ldr      r12,[r1,#4]
+        ldr      r7,[r2,#0x40]
+        smlal    r6,r4,r12,r6
+
+        ldr      r12,[r1,#8]
+        ldr      r6,[r2,#0x180]
+        smlal    r7,r5,r12,r7
+        ldr      r12,[r2,#0x100]
+        ldr      r7,[r1,#0xc]
+        ldr      r2,[r2,#0x140]
+        smlal    r12,r4,r7,r12
+        ldr      r12,[r1,#0x10]
+        add      r3,r3,#0x80
+        smlal    r6,r4,r12,r6
+        ldr      r6,[r1,#0x14]
+        cmp      r3,#0x210
+        smlal    r2,r5,r6,r2
+        add      r1,r1,#0x18
+
+        blt      PolyPh_filter_loop2
+        mov      r0,r4,asr #6
+        mov      r2,r0,asr #15
+        teq      r2,r0,asr #31
+        ldrne    r12,LOW_16BITS
+        ldr      r1,[sp,#8]
+        eorne    r0,r12,r0,asr #31
+        strh     r0,[r1,#0]
+        mov      r0,r5,asr #6
+        mov      r2,r0,asr #15
+        teq      r2,r0,asr #31
+        ldrne    r12,LOW_16BITS
+        ldr      r2,[sp]
+        mov      r1,#0x10
+        eorne    r0,r12,r0,asr #31
+        ldr      r12,[sp,#8]
+        mov      r1,r1,lsl r2
+        add      r1,r12,r1,lsl #1
+        strh     r0,[r1]
+        add      sp,sp,#0x10
+        ldmfd    sp!,{r4-r11,pc}
+
+
+PolyPh_filter_coeff
+        DCD      pqmfSynthWin
+LOW_16BITS
+        DCD      0x00007fff
+
+        ENDP
+
+
+        END
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
index a405b8d..4f45737 100644
--- a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
@@ -1,5 +1,5 @@
 @ ------------------------------------------------------------------
-@ Copyright (C) 2008 PacketVideo
+@ Copyright (C) 1998-2009 PacketVideo
 @
 @ Licensed under the Apache License, Version 2.0 (the "License");
 @ you may not use this file except in compliance with the License.
@@ -19,7 +19,12 @@
 @
 @   Filename: pvmp3_polyphase_filter_window.s
 @
-@     Date: 09/21/2007
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who:                                   Date: MM/DD/YYYY
+@ Description: 
 @
 @------------------------------------------------------------------------------
 
diff --git a/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_wm.asm b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_wm.asm
new file mode 100644
index 0000000..f957267
--- /dev/null
+++ b/codecs_v2/audio/mp3/dec/src/asm/pvmp3_polyphase_filter_window_wm.asm
@@ -0,0 +1,231 @@
+; ------------------------------------------------------------------
+; Copyright (C) 1998-2009 PacketVideo
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+;      http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+; express or implied.
+; See the License for the specific language governing permissions
+; and limitations under the License.
+; -------------------------------------------------------------------
+
+;
+;
+;   Filename: pvmp3_polyphase_filter_window.s
+;
+;------------------------------------------------------------------------------
+; REVISION HISTORY
+;
+;
+; Who:                                   Date: MM/DD/YYYY
+; Description: 
+;
+;------------------------------------------------------------------------------
+
+	CODE32
+
+	AREA	|.drectve|, DRECTVE
+
+	EXPORT	|pvmp3_polyphase_filter_window|
+	IMPORT	|pqmfSynthWin|
+
+	AREA	|.pdata|, PDATA
+
+	AREA	|.text|, CODE, ARM
+
+|pvmp3_polyphase_filter_window| PROC
+        stmfd    sp!,{r0-r2,r4-r11,lr}
+
+        sub      sp,sp,#4
+        ldr      r2,[sp,#0xc]
+        ldr      r1,PolyPh_filter_coeff
+		
+        sub      r2,r2,#1
+        mov      r10,#1
+        str      r2,[sp]
+
+; Accumulators r9, r11::> Initialization
+
+Loop_j
+        mov      r9,  #0x20
+        mov      r11, #0x20
+        mov      r4,  #0x10
+Loop_i
+        add      r2,r4,r10
+        add      r3,r0,r2,lsl #2
+        sub      r2,r4,r10
+        ldr      r5,[r3]
+        ldr      lr,[r1]
+        add      r12,r0,r2,lsl #2
+        ldr      r6,[r12,#0x780]
+        smlal    r2,r9,lr,r5
+        smlal    r2,r11,lr,r6
+        ldr      r2,[r1,#4]
+        ldr      r7,[r12,#0x80]
+        smlal    r5,r11,r2,r5
+        smull    r6,r5,r2,r6
+        sub      r9,r9,r5
+        ldr      r5,[r1,#8]
+        ldr      r8,[r3,#0x700]
+        add      r4,r4,#0x200
+        smlal    r6,r9,r5,r7
+        smull    r6,r2,r5,r8
+        ldr      r5,[r1,#0xc]
+        sub      r11,r11,r2
+        smlal    r8,r9,r5,r8
+        smlal    r7,r11,r5,r7
+        ldr      r5,[r3,#0x100]
+        ldr      r2,[r1,#0x10]
+        ldr      r6,[r12,#0x680]
+        smlal    lr,r9,r2,r5
+        smlal    lr,r11,r2,r6
+        ldr      r2,[r1,#0x14]
+        ldr      r7,[r12,#0x180]
+        smlal    r5,r11,r2,r5
+        smull    r6,r5,r2,r6
+        ldr      r6,[r1,#0x18]
+        ldr      r8,[r3,#0x600]
+        sub      r9,r9,r5
+        smlal    r5,r9,r6,r7
+        smull    r2,r5,r6,r8
+        ldr      r6,[r1,#0x1c]
+        sub      r11,r11,r5
+        smlal    r8,r9,r6,r8
+        ldr      r2,[r1,#0x20]
+        ldr      r5,[r3,#0x200]
+        smlal    r7,r11,r6,r7
+        ldr      r6,[r12,#0x580]
+        smlal    lr,r9,r2,r5
+        smlal    lr,r11,r2,r6
+        ldr      r2,[r1,#0x24]
+        ldr      r7,[r12,#0x280]
+        smlal    r5,r11,r2,r5
+        smull    r6,r5,r2,r6
+        ldr      r6,[r1,#0x28]
+        ldr      r8,[r3,#0x500]
+        sub      r9,r9,r5
+        smlal    r5,r9,r6,r7
+        smull    r2,r5,r6,r8
+        ldr      r6,[r1,#0x2c]
+        sub      r11,r11,r5
+
+        smlal    r8,r9,r6,r8
+        smlal    r7,r11,r6,r7
+        ldr      r5,[r3,#0x300]
+        ldr      r8,[r1,#0x30]
+        ldr      r6,[r12,#0x480]
+        smlal    r7,r9,r8,r5
+        smlal    r7,r11,r8,r6
+        ldr      r8,[r1,#0x34]
+        ldr      r12,[r12,#0x380]
+        smlal    r5,r11,r8,r5
+        smull    r6,r5,r8,r6
+        ldr      r6,[r1,#0x38]
+
+
+        ldr      r3,[r3,#0x400]
+        sub      r9,r9,r5
+        smlal    r7,r9,r6,r12
+        smull    r8,r7,r6,r3
+        cmp      r4,#0x210
+        sub      r11,r11,r7
+
+        ldr      r2,[r1,#0x3c]
+        add      r1,r1,#0x40
+        smlal    r3,r9,r2,r3
+        smlal    r12,r11,r2,r12
+
+        blt      Loop_i
+
+        mov      r3,r9, asr #6
+        mov      r4,r3, asr #15
+        teq      r4,r3, asr #31
+        ldr      r12,LOW_16BITS
+        ldr      r2,[sp]
+        eorne    r3,r12,r3,asr #31
+        ldr      r4,[sp,#8]
+        mov      r2,r10,lsl r2
+        add      r4,r4,r2,lsl #1
+        strh     r3,[r4]
+
+        mov      r3,r11,asr #6
+        mov      r4,r3,asr #15
+        teq      r4,r3,asr #31
+        eorne    r3,r12,r3,asr #31
+        ldr      r12,[sp,#0xc]
+        ldr      r11,[sp,#8]
+        rsb      r2,r2,r12,lsl #5
+        add      r2,r11,r2,lsl #1
+        strh     r3,[r2]
+
+        add      r10,r10,#1
+        cmp      r10,#0x10
+        blt      Loop_j
+
+; Accumulators r4, r5 Initialization
+
+        mov      r4,#0x20
+        mov      r5,#0x20
+        mov      r3,#0x10
+PolyPh_filter_loop2
+        add      r2,r0,r3,lsl #2
+        ldr      r12,[r2]
+        ldr      r8,[r1]
+        ldr      r6,[r2,#0x80]
+        smlal    r12,r4,r8,r12
+        ldr      r12,[r1,#4]
+        ldr      r7,[r2,#0x40]
+        smlal    r6,r4,r12,r6
+
+        ldr      r12,[r1,#8]
+        ldr      r6,[r2,#0x180]
+        smlal    r7,r5,r12,r7
+        ldr      r12,[r2,#0x100]
+        ldr      r7,[r1,#0xc]
+        ldr      r2,[r2,#0x140]
+        smlal    r12,r4,r7,r12
+        ldr      r12,[r1,#0x10]
+        add      r3,r3,#0x80
+        smlal    r6,r4,r12,r6
+        ldr      r6,[r1,#0x14]
+        cmp      r3,#0x210
+        smlal    r2,r5,r6,r2
+        add      r1,r1,#0x18
+
+        blt      PolyPh_filter_loop2
+        mov      r0,r4,asr #6
+        mov      r2,r0,asr #15
+        teq      r2,r0,asr #31
+        ldrne    r12,LOW_16BITS
+        ldr      r1,[sp,#8]
+        eorne    r0,r12,r0,asr #31
+        strh     r0,[r1,#0]
+        mov      r0,r5,asr #6
+        mov      r2,r0,asr #15
+        teq      r2,r0,asr #31
+        ldrne    r12,LOW_16BITS
+        ldr      r2,[sp]
+        mov      r1,#0x10
+        eorne    r0,r12,r0,asr #31
+        ldr      r12,[sp,#8]
+        mov      r1,r1,lsl r2
+        add      r1,r12,r1,lsl #1
+        strh     r0,[r1]
+        add      sp,sp,#0x10
+        ldmfd    sp!,{r4-r11,pc}
+
+
+PolyPh_filter_coeff
+        DCD      pqmfSynthWin
+LOW_16BITS
+        DCD      0x00007fff
+	
+		ENDP  ; |pvmp3_polyphase_filter_window|
+		END
+
diff --git a/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h b/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h
index 553efaf..2037ee7 100644
--- a/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h
+++ b/codecs_v2/audio/mp3/dec/src/mp3_mem_funcs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h b/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h
index c47a54a..d74bd5d 100644
--- a/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h
+++ b/codecs_v2/audio/mp3/dec/src/pv_mp3_huffman.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h
index c7f7cea..f14e2de 100644
--- a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h
+++ b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,25 +52,28 @@
 #endif
 
 
-#if defined(PV_ARM)
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
 
 #include "pv_mp3dec_fxd_op_arm.h"
 
-#endif
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 
-#if defined(C_EQUIVALENT)
+#include "pv_mp3dec_fxd_op_arm_gcc.h"
+
+#elif (defined(PV_ARM_MSC_EVC_V5)||defined(PV_ARM_MSC_EVC_V4))
+
+#include "pv_mp3dec_fxd_op_msc_evc.h"
+
+#else
+
+#ifndef C_EQUIVALENT
+#define C_EQUIVALENT
+#endif
 
 #include "pv_mp3dec_fxd_op_c_equivalent.h"
 
 #endif
 
-#if defined(PV_ARM_GCC)
-
-#include "pv_mp3dec_fxd_op_arm_gcc.h"
-
-#endif
-
-
 
 #ifdef __cplusplus
 }
diff --git a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm.h b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm.h
index a954aec..76a8229 100644
--- a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm.h
+++ b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@
 #include "pvmp3_audio_type_defs.h"
 
 
-#if defined(PV_ARM)
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
 
 
     __inline  Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
diff --git a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h
index 00d8b14..71fbd20 100644
--- a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h
+++ b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_arm_gcc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@
 #include "pvmp3_audio_type_defs.h"
 
 
-#if defined(PV_ARM_GCC)
+#if (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 
 #define Qfmt_31(a)   (int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
 
diff --git a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h
index c68621a..ba43820 100644
--- a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h
+++ b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_c_equivalent.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_msc_evc.h b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_msc_evc.h
index 942b613..29b3014 100644
--- a/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_msc_evc.h
+++ b/codecs_v2/audio/mp3/dec/src/pv_mp3dec_fxd_op_msc_evc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,79 @@
 #include "pvmp3_audio_type_defs.h"
 
 
+#if (defined(PV_ARM_MSC_EVC_V5)||defined(PV_ARM_MSC_EVC_V4))
+#include "armintr.h"
+#include "cmnintrin.h"
+
+
+    __inline int32 fxp_mul32_Q30(const int32 a, const int32 b)
+    {
+        return (int32)(((int64)(a) * b) >> 30);
+    }
+
+
+    __inline int32 fxp_mac32_Q30(const int32 a, const int32 b, int32 L_add)
+    {
+        return (L_add + (int32)(((int64)(a) * b) >> 30));
+    }
+
+
+#define Qfmt_31(a)   (int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
+
+#define Qfmt15(x)   (Int16)(x*((int32)1<<15) + (x>=0?0.5F:-0.5F))
+
+#define fxp_mul32_Q32( a,  b)	_MulHigh( b, a)
+
+
+
+    __inline int32 fxp_mul32_Q28(const int32 a, const int32 b)
+    {
+        return (int32)(((int64)(a) * b) >> 28);
+    }
+
+
+    __inline int32 fxp_mul32_Q27(const int32 a, const int32 b)
+    {
+        return (int32)(((int64)(a) * b) >> 27);
+    }
+
+
+
+    __inline int32 fxp_mul32_Q26(const int32 a, const int32 b)
+    {
+        return (int32)(((int64)(a) * b) >> 26);
+    }
+
+
+    __inline int32 fxp_mac32_Q32(int32 L_add, const int32 a, const int32 b)
+    {
+        return (L_add + _MulHigh(b, a));
+    }
+
+
+    __inline int32 fxp_msb32_Q32(int32 L_sub, const int32 a, const int32 b)
+    {
+        return (L_sub - _MulHigh(b, a));
+    }
+
+
+
+    __inline int32 fxp_mul32_Q29(const int32 a, const int32 b)
+    {
+        return (int32)(((int64)(a) * b) >> 29);
+    }
+
+
+
+    __inline int32 pv_abs(int32 a)
+    {
+        int32 b = (a < 0) ? -a : a;
+        return b;
+    }
+
+
+
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp
index d7302d6..32c76c6 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h b/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h
index 714f239..0650f05 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_alias_reduction.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp
index 25172d8..20d0d82 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_crc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h b/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h
index d24dd6d..c67aca7 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_crc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp
index 9307646..a71efc4 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@
 ------------------------------------------------------------------------------
 */
 
-
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) )
 /*----------------------------------------------------------------------------
 ; INCLUDES
 ----------------------------------------------------------------------------*/
@@ -407,4 +407,4 @@
 
 }
 
-
+#endif
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h
index a9ef8c9..e8bf76e 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp
index e7d9701..4c5fb03 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_6.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp
index a3ece53..ce3ec64 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dct_9.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,7 +58,7 @@
 ------------------------------------------------------------------------------
 */
 
-
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
 /*----------------------------------------------------------------------------
 ; INCLUDES
 ----------------------------------------------------------------------------*/
@@ -164,4 +164,4 @@
 
 
 
-
+#endif // If not assembly
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h b/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h
index bcd34b3..47ffe5d 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dec_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp
index ca9617d..8b0250a 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h
index f14c356..7f1515a 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp
index e65c07e..6e45a18 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h
index 249a507..941ca6d 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_decode_huff_cw.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp
index 47f87aa..47bab72 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_decoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -105,7 +105,7 @@
 
 #define KCAI_CODEC_INIT_FAILURE -1
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp
index 0cc2695..69e1987 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -128,11 +128,12 @@
     Q30_fmt(1.41421356237310),   Q30_fmt(1.68179283050743)
 };
 
-const int32 two_cubic_roots[6] =
+const int32 two_cubic_roots[7] =
 {
     Q29_fmt(0),                  Q29_fmt(1.25992104989487),
     Q29_fmt(1.58740105196820),   Q29_fmt(2.00000000000000),
-    Q29_fmt(2.51984209978975),   Q29_fmt(3.17480210393640)
+    Q29_fmt(2.51984209978975),   Q29_fmt(3.17480210393640),
+    Q29_fmt(3.99999999999999)
 };
 
 /*----------------------------------------------------------------------------
@@ -152,28 +153,26 @@
 
 int32 power_1_third(int32 xx)
 {
+
     if (xx <= 512)
     {
         return (power_one_third[xx] >> 1);
     }
     else
     {
-        // 'xx' is supposed to be < 8192, but in practice it can be slightly
-        // higher, depending on the encoder and the material.
-        // Use 16320 as the cutoff, because it's much higher than anything
-        // you'd see with even the most weirdly encoded material, and also
-        // is equal to 0x3fc0, which only needs 1 ARM instruction to generate.
-        if (xx > 16320)
+        if (xx >> 15)
         {
-            xx = 16320;
+            return 0x7FFFFFFF;  /* saturate any value over 32767 */
         }
+        else
+        {
+            int32 x = xx;
+            int32 m = 22 - pvmp3_normalize(xx);
 
-        int32 x = xx;
-        int32 m = 22 - pvmp3_normalize(xx);
-
-        xx >>= m;
-        xx = (power_one_third[xx]) + (((power_one_third[xx+1] - power_one_third[xx]) >> m) * (x & ((1 << m) - 1)));
-        return (fxp_mul32_Q30(xx, two_cubic_roots[m]));
+            xx >>= m;
+            xx = (power_one_third[xx]) + (((power_one_third[xx+1] - power_one_third[xx]) >> m) * (x & ((1 << m) - 1)));
+            return (fxp_mul32_Q30(xx, two_cubic_roots[m]));
+        }
 
     }
 }
@@ -294,9 +293,10 @@
 
             /* 0 < abs(is[ss]) < 8192 */
 
-
             int32 tmp = fxp_mul32_Q30((is[ss] << 16), power_1_third(pv_abs(is[ ss])));
+
             tmp = fxp_mul32_Q30(tmp, two_raise_one_fourth);
+
             if (global_gain < 0)
             {
                 int32 temp = - global_gain;
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h b/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h
index c0e93c2..9393eb1 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_dequantize_sample.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp
index 1bc3ee7..f4a4efb 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h b/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h
index 56cb2d8..65484b5 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_equalizer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp
index 94c929c..6b82071 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -349,12 +349,13 @@
                     }
                     else
                     {
+                        int32 * tmp = pVars->Scratch_mem;
                         pvmp3_mpeg2_get_scale_factors(&pVars->scaleFactors[ch],
                                                       &pVars->sideInfo,
                                                       gr,
                                                       ch,
                                                       info,
-                                                      (uint32 *)pVars->Scratch_mem,
+                                                      (uint32 *)tmp,
                                                       &pVars->mainDataStream);
                     }
 
@@ -398,12 +399,13 @@
                     }
                     else
                     {
+                        int32 * tmp = pVars->Scratch_mem;
                         pvmp3_mpeg2_stereo_proc(pChVars[ LEFT]->work_buf_int32,
                                                 pChVars[RIGHT]->work_buf_int32,
                                                 &pVars->scaleFactors[RIGHT],
                                                 &pVars->sideInfo.ch[ LEFT].gran[gr],
                                                 &pVars->sideInfo.ch[RIGHT].gran[gr],
-                                                (uint32 *)pVars->Scratch_mem,
+                                                (uint32 *)tmp,
                                                 used_freq_lines,
                                                 info);
                     }
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h b/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h
index 36821a9..324c515 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_framedecoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp
index fc5924e..423a7b1 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h b/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h
index 9f4d5ef..3a25d31 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_get_main_data_size.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp
index f8cd110..f1a3ff8 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h b/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h
index 68e4046..e2743fe 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_get_scale_factors.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp
index 66d88a2..7eaa860 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h b/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h
index 40f4bc1..0b23028 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_get_side_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp
index e9d7c90..8ff7953 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h b/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h
index e169276..679c76d 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_getbits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp
index 4f254d2..5d58cd2 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_decoding.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp
index 5a64f09..491c0cc 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_huffman_parsing.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp
index e64b744..11961d1 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h b/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h
index cb06be2..37a855c 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_imdct_synth.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp
index db7b212..09a735b 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@
 ------------------------------------------------------------------------------
 */
 
-
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
 /*----------------------------------------------------------------------------
 ; INCLUDES
 ----------------------------------------------------------------------------*/
@@ -286,4 +286,4 @@
     history[11] = fxp_mul32_Q32(tmp,  window[29]);
 }
 
-
+#endif // If not assembly
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h
index 1ae292b..e497aee 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_18.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp
index 2cf7bf9..6a72aad 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h
index 2b2587d..6ba53d7 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mdct_6.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp
index ca9ea11..67246c1 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h
index 2a19876..55facbb 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp
index 6fc134b..e4d29d6 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h
index de7ba40..131010a 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_get_scale_factors.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp
index dd80544..bc4c227 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -448,7 +448,7 @@
                         {
                             sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */
                             sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
-                            if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])    /* RF bug fix 30-09-2002 */
+                            if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])
                             {
                                 pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo);
                             }
@@ -546,7 +546,7 @@
                         sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */
                         sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
 
-                        if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])   /* RF bug fix 30-9-2002 */
+                        if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])
                         {
                             pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo);
                         }
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h
index d2be1b7..823854e 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_mpeg2_stereo_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp
index 7822ff9..e579bbd 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -101,8 +101,9 @@
 ; FUNCTION CODE
 ----------------------------------------------------------------------------*/
 
-#if defined(PV_ARM)
-#elif defined(PV_ARM_GCC)
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
+
 
 /* function is inlined in header file */
 
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h b/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h
index 29b0eb2..5471771 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_normalize.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
 ; DEFINES AND SIMPLE TYPEDEF'S
 ----------------------------------------------------------------------------*/
 
-#if defined(PV_ARM)
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
 
 __inline int32 pvmp3_normalize(int32 x)
 {
@@ -71,8 +71,7 @@
 }
 
 
-#elif defined(PV_ARM_GCC)
-
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
 
 __inline int32 pvmp3_normalize(int32 x)
 {
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp
index 1ad4b7b..33c8e61 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h b/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h
index f1d0180..b6634c0 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_poly_phase_synthesis.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp
index 5c9f252..8a89134 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@
 ------------------------------------------------------------------------------
 */
 
-
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
 /*----------------------------------------------------------------------------
 ; INCLUDES
 ----------------------------------------------------------------------------*/
@@ -235,5 +235,5 @@
 
 }
 
-
+#endif // If not assembly
 
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h b/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h
index f15ec59..b9eccad 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_polyphase_filter_window.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@
 #endif
 
 
-#if defined(PV_ARM)
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
 
 
     __inline int16 saturate16(int32 sample)
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp
index 5a4de60..35b6475 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h b/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h
index 13d74c9..611b8ac 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_reorder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp
index ab375da..82faafd 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h b/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h
index f025468..3996765 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_seek_synch.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp
index 5fdae55..7db9977 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,15 +29,6 @@
     pvmp3_st_intensity
     pvmp3_stereo_proc
 
-     Date: 09/21/2007
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Description:
-
-
 ------------------------------------------------------------------------------
 
 pvmp3_st_mid_side
@@ -381,7 +372,7 @@
                             sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */
                             sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo;
 
-                            if (scalefac->s[j][sfbTemp] != 7)         /* RF bug fix 30-09-2002  */
+                            if (scalefac->s[j][sfbTemp] != 7)
                             {
                                 pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo);
                             }
@@ -457,7 +448,7 @@
                             sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */
                             sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo;
 
-                            if (scalefac->s[j][sfbTemp] != 7)  /* RF bug fix 30-09-2002 */
+                            if (scalefac->s[j][sfbTemp] != 7)
                             {
                                 pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo);
                             }
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h b/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h
index 31c566e..3565f23 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_stereo_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp b/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp
index 44434bf..920dc29 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_tables.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h b/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h
index 4d649b5..b54c5bf 100644
--- a/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h
+++ b/codecs_v2/audio/mp3/dec/src/pvmp3_tables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h b/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h
index 5a8f6f7..ef66a7f 100644
--- a/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h
+++ b/codecs_v2/audio/mp3/dec/src/s_huffcodetab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/s_mp3bits.h b/codecs_v2/audio/mp3/dec/src/s_mp3bits.h
index 78a9b13..b905b9a 100644
--- a/codecs_v2/audio/mp3/dec/src/s_mp3bits.h
+++ b/codecs_v2/audio/mp3/dec/src/s_mp3bits.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h b/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h
index 710f589..d969e8b 100644
--- a/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h
+++ b/codecs_v2/audio/mp3/dec/src/s_tmp3dec_chan.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h b/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h
index e4f5141..9fc40d2 100644
--- a/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h
+++ b/codecs_v2/audio/mp3/dec/src/s_tmp3dec_file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/Android.mk b/codecs_v2/audio/sbc/enc/Android.mk
deleted file mode 100644
index 4542e3a..0000000
--- a/codecs_v2/audio/sbc/enc/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/pvsbcencoder.cpp \
-	src/pvsbcencoder_factory.cpp \
-	src/sbc_encoder.cpp \
-	src/sbcenc_allocation.cpp \
-	src/sbcenc_bitstream.cpp \
-	src/sbcenc_crc8.cpp \
-	src/sbcenc_filter.cpp \
-	src/scalefactors.cpp
-
-
-LOCAL_MODULE := libsbcencoder
-
-LOCAL_CFLAGS := $(PV_CFLAGS)
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/audio/sbc/enc/include \
-	$(PV_INCLUDES) 
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/pvsbcencoderinterface.h \
-	include/pvsbcencoder_factory.h
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/audio/sbc/enc/build/make/local.mk b/codecs_v2/audio/sbc/enc/build/make/local.mk
new file mode 100644
index 0000000..61c9ee2
--- /dev/null
+++ b/codecs_v2/audio/sbc/enc/build/make/local.mk
@@ -0,0 +1,36 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+
+TARGET := pv_sbc_enc
+
+
+
+
+XINCDIRS +=  ../../include
+
+
+XLIBDIRS += 
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := sbcenc_allocation.cpp \
+	sbcenc_bitstream.cpp \
+	sbcenc_crc8.cpp \
+	sbcenc_filter.cpp \
+	sbc_encoder.cpp \
+	scalefactors.cpp \
+	pvsbcencoder.cpp \
+	pvsbcencoder_factory.cpp
+	
+HDRS := pvsbcencoder_factory.h pvsbcencoderinterface.h
+LIBS =
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/audio/sbc/enc/build/make/makefile b/codecs_v2/audio/sbc/enc/build/make/makefile
deleted file mode 100755
index f7928f6..0000000
--- a/codecs_v2/audio/sbc/enc/build/make/makefile
+++ /dev/null
@@ -1,67 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pv_sbc_enc
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-XINCDIRS += -I ../../include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  sbcenc_allocation.cpp \
-	sbcenc_bitstream.cpp \
-	sbcenc_crc8.cpp \
-	sbcenc_filter.cpp \
-	sbc_encoder.cpp \
-	scalefactors.cpp \
-	pvsbcencoder.cpp \
-	pvsbcencoder_factory.cpp
-	
-HDRS = pvsbcencoder_factory.h pvsbcencoderinterface.h
-LIBS =
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/audio/sbc/enc/include/pvsbcencoder_factory.h b/codecs_v2/audio/sbc/enc/include/pvsbcencoder_factory.h
old mode 100755
new mode 100644
index 225cd7d..65ef882
--- a/codecs_v2/audio/sbc/enc/include/pvsbcencoder_factory.h
+++ b/codecs_v2/audio/sbc/enc/include/pvsbcencoder_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/include/pvsbcencoderinterface.h b/codecs_v2/audio/sbc/enc/include/pvsbcencoderinterface.h
old mode 100755
new mode 100644
index 2a9dbf2..d0cb917
--- a/codecs_v2/audio/sbc/enc/include/pvsbcencoderinterface.h
+++ b/codecs_v2/audio/sbc/enc/include/pvsbcencoderinterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/pvsbcencoder.cpp b/codecs_v2/audio/sbc/enc/src/pvsbcencoder.cpp
old mode 100755
new mode 100644
index 12522b8..02fb4fc
--- a/codecs_v2/audio/sbc/enc/src/pvsbcencoder.cpp
+++ b/codecs_v2/audio/sbc/enc/src/pvsbcencoder.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "oscl_mem.h"
 
@@ -21,7 +23,7 @@
 
 OSCL_EXPORT_REF CPVSbcEncoder* CPVSbcEncoder::New()
 {
-	return new(CPVSbcEncoder);
+    return new(CPVSbcEncoder);
 }
 
 OSCL_EXPORT_REF CPVSbcEncoder::~CPVSbcEncoder()
@@ -30,58 +32,58 @@
 
 OSCL_EXPORT_REF TPvSbcEncStatus CPVSbcEncoder::Init()
 {
-	iEncConfig = (TPvSbcEncConfig *)oscl_malloc(sizeof(TPvSbcEncConfig));
-	if(!iEncConfig)
-		return TPVSBCENC_FAIL;
+    iEncConfig = (TPvSbcEncConfig *)oscl_malloc(sizeof(TPvSbcEncConfig));
+    if (!iEncConfig)
+        return TPVSBCENC_FAIL;
 
-	status = encoder_init(iEncConfig);
-	if(status == false)
-		return TPVSBCENC_FAIL;
-	
-	return TPVSBCENC_SUCCESS;
+    status = encoder_init(iEncConfig);
+    if (status == false)
+        return TPVSBCENC_FAIL;
+
+    return TPVSBCENC_SUCCESS;
 }
 
 OSCL_EXPORT_REF TPvSbcEncStatus CPVSbcEncoder::SetInput(TPvSbcEncConfig *config)
 {
-	iEncConfig->sampling_frequency = config->sampling_frequency;
-	iEncConfig->nrof_channels = config->nrof_channels;
-	iEncConfig->block_len = config->block_len;
-	iEncConfig->nrof_subbands = config->nrof_subbands;
-	iEncConfig->allocation_method = config->allocation_method;
-	iEncConfig->bitpool = config->bitpool;
-	iEncConfig->channel_mode = config->channel_mode;
-	iEncConfig->join = config->join;
+    iEncConfig->sampling_frequency = config->sampling_frequency;
+    iEncConfig->nrof_channels = config->nrof_channels;
+    iEncConfig->block_len = config->block_len;
+    iEncConfig->nrof_subbands = config->nrof_subbands;
+    iEncConfig->allocation_method = config->allocation_method;
+    iEncConfig->bitpool = config->bitpool;
+    iEncConfig->channel_mode = config->channel_mode;
+    iEncConfig->join = config->join;
 
-	return TPVSBCENC_SUCCESS;
+    return TPVSBCENC_SUCCESS;
 }
 
 
 OSCL_EXPORT_REF TPvSbcEncStatus CPVSbcEncoder::Execute(uint16* pcmbuffer, uint inBufSize,
-	                                   uint8 *bitstream, uint *outBufSize)
+        uint8 *bitstream, uint *outBufSize)
 {
-	iEncConfig->pcmbuffer = pcmbuffer;
-	iEncConfig->bitstream = bitstream;
+    iEncConfig->pcmbuffer = pcmbuffer;
+    iEncConfig->bitstream = bitstream;
 
-	if (inBufSize != (uint)(iEncConfig->block_len * iEncConfig->nrof_subbands * iEncConfig->nrof_channels))
-		return TPVSBCENC_INSUFFICIENT_INPUT_DATA;
+    if (inBufSize != (uint)(iEncConfig->block_len * iEncConfig->nrof_subbands * iEncConfig->nrof_channels))
+        return TPVSBCENC_INSUFFICIENT_INPUT_DATA;
 
-	status = encoder_execute(iEncConfig, iEncConfig->pcmbuffer);
-	if(status == false)
-		return TPVSBCENC_FAIL;
-	*outBufSize = iEncConfig->framelen;
-	
-	return TPVSBCENC_SUCCESS;
+    status = encoder_execute(iEncConfig, iEncConfig->pcmbuffer);
+    if (status == false)
+        return TPVSBCENC_FAIL;
+    *outBufSize = iEncConfig->framelen;
+
+    return TPVSBCENC_SUCCESS;
 }
 
 OSCL_EXPORT_REF TPvSbcEncStatus CPVSbcEncoder::Reset()
 {
-	status = encoder_delete(iEncConfig);
-	if(status == false)
-		return TPVSBCENC_FAIL;
+    status = encoder_delete(iEncConfig);
+    if (status == false)
+        return TPVSBCENC_FAIL;
 
-	oscl_free(iEncConfig);
+    oscl_free(iEncConfig);
 
-	return TPVSBCENC_SUCCESS;
+    return TPVSBCENC_SUCCESS;
 }
 
 
diff --git a/codecs_v2/audio/sbc/enc/src/pvsbcencoder.h b/codecs_v2/audio/sbc/enc/src/pvsbcencoder.h
old mode 100755
new mode 100644
index 71103b0..8058474
--- a/codecs_v2/audio/sbc/enc/src/pvsbcencoder.h
+++ b/codecs_v2/audio/sbc/enc/src/pvsbcencoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/pvsbcencoder_factory.cpp b/codecs_v2/audio/sbc/enc/src/pvsbcencoder_factory.cpp
old mode 100755
new mode 100644
index c064f1b..02276af
--- a/codecs_v2/audio/sbc/enc/src/pvsbcencoder_factory.cpp
+++ b/codecs_v2/audio/sbc/enc/src/pvsbcencoder_factory.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 /**
  * @file pvsbcencoder_factory.cpp
  * @brief Singleton factory for CPVSbcEncoder
@@ -26,7 +28,7 @@
 #include "oscl_error_codes.h"
 #include "oscl_exception.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 
 OSCL_DLL_ENTRY_POINT_DEFAULT()
@@ -35,24 +37,24 @@
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVSbcEncoderInterface* PVSbcEncoderFactory::CreatePVSbcEncoder()
 {
-	PVSbcEncoderInterface* sbcenc = NULL;
-	sbcenc = CPVSbcEncoder::New();
-	if (sbcenc==NULL)
-	{
-		OSCL_LEAVE(OsclErrNoMemory);
-	}
-	return sbcenc;
+    PVSbcEncoderInterface* sbcenc = NULL;
+    sbcenc = CPVSbcEncoder::New();
+    if (sbcenc == NULL)
+    {
+        OSCL_LEAVE(OsclErrNoMemory);
+    }
+    return sbcenc;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF bool PVSbcEncoderFactory::DeletePVSbcEncoder(PVSbcEncoderInterface* aSbcEnc)
 {
-	if(aSbcEnc)
-	{
-		OSCL_DELETE(aSbcEnc);
-		return true;
-	}
+    if (aSbcEnc)
+    {
+        OSCL_DELETE(aSbcEnc);
+        return true;
+    }
 
-	return false;
+    return false;
 }
 
diff --git a/codecs_v2/audio/sbc/enc/src/sbc.h b/codecs_v2/audio/sbc/enc/src/sbc.h
old mode 100755
new mode 100644
index 9b167b9..8c8cb5a
--- a/codecs_v2/audio/sbc/enc/src/sbc.h
+++ b/codecs_v2/audio/sbc/enc/src/sbc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/sbc_encoder.cpp b/codecs_v2/audio/sbc/enc/src/sbc_encoder.cpp
old mode 100755
new mode 100644
index e321642..9f2edef
--- a/codecs_v2/audio/sbc/enc/src/sbc_encoder.cpp
+++ b/codecs_v2/audio/sbc/enc/src/sbc_encoder.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "oscl_mem.h"
 #include "sbc_encoder.h"
@@ -33,36 +35,36 @@
 bool encoder_init(TPvSbcEncConfig *config)
 {
 
-    if(NULL != config)
+    if (NULL != config)
     {
-		oscl_memset(config, 0, sizeof(TPvSbcEncConfig));
-        if(NULL != (config->state = (enc_state_t *) oscl_malloc(sizeof(enc_state_t))))
+        oscl_memset(config, 0, sizeof(TPvSbcEncConfig));
+        if (NULL != (config->state = (enc_state_t *) oscl_malloc(sizeof(enc_state_t))))
         {
-           oscl_memset(config->state, 0, sizeof(enc_state_t));
+            oscl_memset(config->state, 0, sizeof(enc_state_t));
         }
         else
         {
-           //fprintf(stderr, "not enough memory\n");
-		   return false;
+            //fprintf(stderr, "not enough memory\n");
+            return false;
         }
     }
     else
     {
-       // fprintf(stderr, "not enough memory\n");
-		return false;
+        // fprintf(stderr, "not enough memory\n");
+        return false;
     }
 
     // default encoding parameters
     config->sampling_frequency = 44100;
     config->allocation_method = AM_SNR;
     config->nrof_channels = 1;
-	config->channel_mode = CM_MONO;
+    config->channel_mode = CM_MONO;
     config->nrof_subbands = 8;
     config->block_len = 16;
     config->bitpool = 53;
     config->join = 0;
 
-	return true;
+    return true;
 }
 
 
@@ -75,11 +77,11 @@
 
 bool encoder_delete(TPvSbcEncConfig *config)
 {
-    if(!config) return false;
-	if(config->state) 
-			oscl_free(config->state);
-    
-	return true;
+    if (!config) return false;
+    if (config->state)
+        oscl_free(config->state);
+
+    return true;
 }
 
 /*
@@ -92,24 +94,32 @@
     /*~~~~~~~~~~~~~~~~~~~~~~~~*/
     enc_state_t *state;
     Int         i, framelen;
-	Int *ptr, *ptr1;
+    Int *ptr, *ptr1;
     /*~~~~~~~~~~~~~~~~~~~~~~~~*/
 
     state = (enc_state_t *)config->state;
-	
-    if(!state->init)
+
+    if (!state->init)
     {
-        switch(config->sampling_frequency)
+        switch (config->sampling_frequency)
         {
-        case 16000: state->sbc.sf_index = SF_16; break;
-        case 32000: state->sbc.sf_index = SF_32; break;
-        case 44100: state->sbc.sf_index = SF_44; break;
-        case 48000: state->sbc.sf_index = SF_48; break;
-        default:    ;   /* return (-2); */
+            case 16000:
+                state->sbc.sf_index = SF_16;
+                break;
+            case 32000:
+                state->sbc.sf_index = SF_32;
+                break;
+            case 44100:
+                state->sbc.sf_index = SF_44;
+                break;
+            case 48000:
+                state->sbc.sf_index = SF_48;
+                break;
+            default:    ;   /* return (-2); */
         }
 
-        state->sbc.channels = config->nrof_channels;     
-        state->sbc.channel_mode = config->channel_mode;        
+        state->sbc.channels = config->nrof_channels;
+        state->sbc.channel_mode = config->channel_mode;
         state->sbc.allocation_method = config->allocation_method;
         state->sbc.subbands = config->nrof_subbands;
         state->sbc.blocks = config->block_len;
@@ -122,110 +132,110 @@
         )
         {
             encoder_delete(config);
-			return false;
+            return false;
         }
 
-       state->init = Btrue;
+        state->init = Btrue;
     }
 
-	if(config->nrof_channels == 1)
-	{		
-		if (state->sbc.subbands == 4)
-		{	
-			ptr = &state->filter.X[0][63];
-			for(i = state->sbc.blocks; i != 0; i--)
-			{
-				Word16 s1 = *data++;
-				Word16 s2 = *data++;
-				Word16 s3 = *data++;
-				Word16 s4 = *data++;
-				
-				*ptr-- = s1;	
-				*ptr-- = s2;	
-				*ptr-- = s3;	
-				*ptr-- = s4;	
-			}
+    if (config->nrof_channels == 1)
+    {
+        if (state->sbc.subbands == 4)
+        {
+            ptr = &state->filter.X[0][63];
+            for (i = state->sbc.blocks; i != 0; i--)
+            {
+                Word16 s1 = *data++;
+                Word16 s2 = *data++;
+                Word16 s3 = *data++;
+                Word16 s4 = *data++;
 
-			analysis_filter_4 (&state->filter, &state->sbc);		
-		}
-		else
-		{
-			ptr = &state->filter.X[0][127];
-			for(i = (state->sbc.blocks << 1); i != 0 ; i--)
-			{
-				Word16 s1 = *data++;
-				Word16 s2 = *data++;
-				Word16 s3 = *data++;
-				Word16 s4 = *data++;
+                *ptr-- = s1;
+                *ptr-- = s2;
+                *ptr-- = s3;
+                *ptr-- = s4;
+            }
 
-				*ptr-- = s1;	
-				*ptr-- = s2;	
-				*ptr-- = s3;	
-				*ptr-- = s4;					
-			}
+            analysis_filter_4(&state->filter, &state->sbc);
+        }
+        else
+        {
+            ptr = &state->filter.X[0][127];
+            for (i = (state->sbc.blocks << 1); i != 0 ; i--)
+            {
+                Word16 s1 = *data++;
+                Word16 s2 = *data++;
+                Word16 s3 = *data++;
+                Word16 s4 = *data++;
 
-			analysis_filter_8 (&state->filter, &state->sbc);
-		}	
-		
-	}
-	else
-	{
-		if (state->sbc.subbands == 4)
-		{	
-			ptr = &state->filter.X[0][63];
-			ptr1 = &state->filter.X[1][63];
-			for(i = (state->sbc.blocks << 1); i != 0; i--)
-			{
-				Word16 s1 = *data++;
-				Word16 s2 = *data++;
-				Word16 s3 = *data++;
-				Word16 s4 = *data++;
+                *ptr-- = s1;
+                *ptr-- = s2;
+                *ptr-- = s3;
+                *ptr-- = s4;
+            }
 
-				*ptr-- = s1;	
-				*ptr-- = s3;
-				*ptr1-- = s2;	
-				*ptr1-- = s4;
-			}
+            analysis_filter_8(&state->filter, &state->sbc);
+        }
 
-			analysis_filter_4 (&state->filter, &state->sbc);		
-		}
-		else
-		{
-			ptr = &state->filter.X[0][127];
-			ptr1 = &state->filter.X[1][127];
-			for(i = (state->sbc.blocks << 1); i != 0 ; i--)
-			{
-				Word16 s1 = *data++;
-				Word16 s2 = *data++;
-				Word16 s3 = *data++;
-				Word16 s4 = *data++;
+    }
+    else
+    {
+        if (state->sbc.subbands == 4)
+        {
+            ptr = &state->filter.X[0][63];
+            ptr1 = &state->filter.X[1][63];
+            for (i = (state->sbc.blocks << 1); i != 0; i--)
+            {
+                Word16 s1 = *data++;
+                Word16 s2 = *data++;
+                Word16 s3 = *data++;
+                Word16 s4 = *data++;
 
-				Word16 s5 = *data++;
-				Word16 s6 = *data++;
-				Word16 s7 = *data++;
-				Word16 s8 = *data++;
-				
-				*ptr-- = s1;	
-				*ptr-- = s3;	
-				*ptr-- = s5;	
-				*ptr-- = s7;
-				
-				*ptr1-- = s2;	
-				*ptr1-- = s4;	
-				*ptr1-- = s6;	
-				*ptr1-- = s8;	
-			}
-			analysis_filter_8 (&state->filter, &state->sbc);
-		}			
-	}			
-   
+                *ptr-- = s1;
+                *ptr-- = s3;
+                *ptr1-- = s2;
+                *ptr1-- = s4;
+            }
+
+            analysis_filter_4(&state->filter, &state->sbc);
+        }
+        else
+        {
+            ptr = &state->filter.X[0][127];
+            ptr1 = &state->filter.X[1][127];
+            for (i = (state->sbc.blocks << 1); i != 0 ; i--)
+            {
+                Word16 s1 = *data++;
+                Word16 s2 = *data++;
+                Word16 s3 = *data++;
+                Word16 s4 = *data++;
+
+                Word16 s5 = *data++;
+                Word16 s6 = *data++;
+                Word16 s7 = *data++;
+                Word16 s8 = *data++;
+
+                *ptr-- = s1;
+                *ptr-- = s3;
+                *ptr-- = s5;
+                *ptr-- = s7;
+
+                *ptr1-- = s2;
+                *ptr1-- = s4;
+                *ptr1-- = s6;
+                *ptr1-- = s8;
+            }
+            analysis_filter_8(&state->filter, &state->sbc);
+        }
+    }
+
     compute_scalefactors(state);
 
     derive_allocation(&state->sbc, state->sbc.bits);
- 
+
     framelen = pack_bitstream(config->bitstream, state, MAX_SZOF_BS_BUFF);
 
     config->framelen = framelen;
-	
-	return true;
+
+    return true;
 }
diff --git a/codecs_v2/audio/sbc/enc/src/sbc_encoder.h b/codecs_v2/audio/sbc/enc/src/sbc_encoder.h
old mode 100755
new mode 100644
index c547114..740d7ed
--- a/codecs_v2/audio/sbc/enc/src/sbc_encoder.h
+++ b/codecs_v2/audio/sbc/enc/src/sbc_encoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/sbc_type_defs.h b/codecs_v2/audio/sbc/enc/src/sbc_type_defs.h
old mode 100755
new mode 100644
index 7098cba..61f42f2
--- a/codecs_v2/audio/sbc/enc/src/sbc_type_defs.h
+++ b/codecs_v2/audio/sbc/enc/src/sbc_type_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.cpp b/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.cpp
old mode 100755
new mode 100644
index e17760e..db65368
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.cpp
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "sbc.h"
 #include "sbc_encoder.h"
@@ -69,49 +71,49 @@
 {
     /*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
     const UInt  sf = sbc->sf_index;
-	Int	  t_var;
+    Int	  t_var;
     /*~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
-    if(sbc->channel_mode == CM_MONO || sbc->channel_mode == CM_DUAL_CHANNEL)
+    if (sbc->channel_mode == CM_MONO || sbc->channel_mode == CM_DUAL_CHANNEL)
     {
         /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
         Int bitneed[2][8], loudness, max_bitneed, bitcount, slicecount, bitslice;
         Int ch, sb, tmp1, tmp2, tmp3, tmp4;
-		Int *ptr1;
-		const UWord32 *ptr2;
+        Int *ptr1;
+        const UWord32 *ptr2;
         /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 
-		for(ch = 0; ch < sbc->channels; ch++) 
-		{
-			ptr1 = &bitneed[ch][0];
-			ptr2 = &sbc->scale_factor[ch][0];
-			if(sbc->allocation_method == AM_SNR)
+        for (ch = 0; ch < sbc->channels; ch++)
+        {
+            ptr1 = &bitneed[ch][0];
+            ptr2 = &sbc->scale_factor[ch][0];
+            if (sbc->allocation_method == AM_SNR)
             {
-                for(sb = sbc->subbands >> 2; sb != 0; sb--)
+                for (sb = sbc->subbands >> 2; sb != 0; sb--)
                 {
                     tmp1 = *ptr2++;
-					tmp2 = *ptr2++;
-					tmp3 = *ptr2++;
-					tmp4 = *ptr2++;
-					
-					*ptr1++ = tmp1;
-					*ptr1++ = tmp2;
-					*ptr1++ = tmp3;
-					*ptr1++ = tmp4;
+                    tmp2 = *ptr2++;
+                    tmp3 = *ptr2++;
+                    tmp4 = *ptr2++;
+
+                    *ptr1++ = tmp1;
+                    *ptr1++ = tmp2;
+                    *ptr1++ = tmp3;
+                    *ptr1++ = tmp4;
                 }
             }
 
             else
             {
-                for(sb = 0; sb < sbc->subbands; sb++)
+                for (sb = 0; sb < sbc->subbands; sb++)
                 {
-                    if(sbc->scale_factor[ch][sb] == 0)
+                    if (sbc->scale_factor[ch][sb] == 0)
                     {
                         bitneed[ch][sb] = -5;
                     }
                     else
                     {
-                        if(sbc->subbands == 4)
+                        if (sbc->subbands == 4)
                         {
                             loudness = sbc->scale_factor[ch][sb] - sbc_offset4[sf][sb];
                         }
@@ -120,7 +122,7 @@
                             loudness = sbc->scale_factor[ch][sb] - sbc_offset8[sf][sb];
                         }
 
-                        if(loudness > 0)
+                        if (loudness > 0)
                         {
                             bitneed[ch][sb] = loudness >> 1;
                         }
@@ -133,9 +135,9 @@
             }
 
             max_bitneed = 0;
-            for(sb = 0; sb < sbc->subbands; sb++)
+            for (sb = 0; sb < sbc->subbands; sb++)
             {
-                if(bitneed[ch][sb] > max_bitneed) max_bitneed = bitneed[ch][sb];
+                if (bitneed[ch][sb] > max_bitneed) max_bitneed = bitneed[ch][sb];
             }
 
             bitcount = 0;
@@ -146,61 +148,62 @@
                 bitslice--;
                 bitcount += slicecount;
                 slicecount = 0;
-                for(sb = 0; sb < sbc->subbands; sb++)
+                for (sb = 0; sb < sbc->subbands; sb++)
                 {
                     t_var = bitneed[ch][sb];
-					if((t_var > bitslice + 1) && (t_var < bitslice + 16))
+                    if ((t_var > bitslice + 1) && (t_var < bitslice + 16))
                     {
                         slicecount++;
                     }
-                    else if(t_var == bitslice + 1)
+                    else if (t_var == bitslice + 1)
                     {
                         slicecount += 2;
                     }
                 }
-            } while(bitcount + slicecount < sbc->bitpool);
+            }
+            while (bitcount + slicecount < sbc->bitpool);
 
-            if(bitcount + slicecount == sbc->bitpool)
+            if (bitcount + slicecount == sbc->bitpool)
             {
                 bitcount += slicecount;
                 bitslice--;
             }
 
-            for(sb = 0; sb < sbc->subbands; sb++)
+            for (sb = 0; sb < sbc->subbands; sb++)
             {
-                if(bitneed[ch][sb] < bitslice + 2)
+                if (bitneed[ch][sb] < bitslice + 2)
                 {
                     bits[ch][sb] = 0;
                 }
                 else
                 {
                     bits[ch][sb] = bitneed[ch][sb] - bitslice;
-                    if(bits[ch][sb] > 16) bits[ch][sb] = 16;
+                    if (bits[ch][sb] > 16) bits[ch][sb] = 16;
                 }
             }
 
             sb = 0;
-            while(bitcount < sbc->bitpool && sb < sbc->subbands)
+            while (bitcount < sbc->bitpool && sb < sbc->subbands)
             {
                 t_var = bits[ch][sb];
-				if((t_var >= 2) && (t_var < 16))
+                if ((t_var >= 2) && (t_var < 16))
                 {
                     t_var++;
                     bitcount++;
                 }
-                else if((bitneed[ch][sb] == bitslice + 1) && (sbc->bitpool > bitcount + 1))
+                else if ((bitneed[ch][sb] == bitslice + 1) && (sbc->bitpool > bitcount + 1))
                 {
                     t_var = 2;
                     bitcount += 2;
                 }
-				bits[ch][sb] = t_var;
+                bits[ch][sb] = t_var;
                 sb++;
             }
 
             sb = 0;
-            while(bitcount < sbc->bitpool && sb < sbc->subbands)
+            while (bitcount < sbc->bitpool && sb < sbc->subbands)
             {
-                if(bits[ch][sb] < 16)
+                if (bits[ch][sb] < 16)
                 {
                     bits[ch][sb]++;
                     bitcount++;
@@ -211,76 +214,76 @@
         }
 
     }
-    else if(sbc->channel_mode == CM_STEREO || sbc->channel_mode == CM_JOINT_STEREO)
+    else if (sbc->channel_mode == CM_STEREO || sbc->channel_mode == CM_JOINT_STEREO)
     {
         /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
         Int bitneed[2][8], loudness, max_bitneed, bitcount, slicecount, bitslice;
         Int ch, sb, tmp1, tmp2, tmp3, tmp4, tmp;
-		Int * ptr1, *ptr3, *ptr4, *ptr5;
-		const UWord32 * ptr2;
+        Int * ptr1, *ptr3, *ptr4, *ptr5;
+        const UWord32 * ptr2;
         /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-		
-		max_bitneed = 0;
 
-        if(sbc->allocation_method == AM_SNR)
+        max_bitneed = 0;
+
+        if (sbc->allocation_method == AM_SNR)
         {
-			tmp = sbc->subbands >> 2;
-			ptr1 =  &bitneed[0][0];
-			ptr2 =  &sbc->scale_factor[0][0];		
-				
-			for(sb = tmp; sb != 0; sb--)
-            {
-				tmp1 = *ptr2++;
-				tmp2 = *ptr2++;
-				tmp3 = *ptr2++;
-				tmp4 = *ptr2++;
-						
-				*ptr1++ = tmp1;
-				*ptr1++ = tmp2;
-				*ptr1++ = tmp3;
-				*ptr1++ = tmp4;
+            tmp = sbc->subbands >> 2;
+            ptr1 =  &bitneed[0][0];
+            ptr2 =  &sbc->scale_factor[0][0];
 
-				if(tmp1 > max_bitneed) max_bitneed = tmp1;
-				if(tmp2 > max_bitneed) max_bitneed = tmp2;
-				if(tmp3 > max_bitneed) max_bitneed = tmp3;
-				if(tmp4 > max_bitneed) max_bitneed = tmp4;
-            }
-
-			ptr1 =  &bitneed[1][0];
-			ptr2 =  &sbc->scale_factor[1][0];
-
-			for(sb = tmp; sb != 0; sb--)
+            for (sb = tmp; sb != 0; sb--)
             {
                 tmp1 = *ptr2++;
-				tmp2 = *ptr2++;
-				tmp3 = *ptr2++;
-				tmp4 = *ptr2++;
-					
-				*ptr1++ = tmp1;
-				*ptr1++ = tmp2;
-				*ptr1++ = tmp3;
-				*ptr1++ = tmp4;
+                tmp2 = *ptr2++;
+                tmp3 = *ptr2++;
+                tmp4 = *ptr2++;
 
-				if(tmp1 > max_bitneed) max_bitneed = tmp1;
-				if(tmp2 > max_bitneed) max_bitneed = tmp2;
-				if(tmp3 > max_bitneed) max_bitneed = tmp3;
-				if(tmp4 > max_bitneed) max_bitneed = tmp4;
+                *ptr1++ = tmp1;
+                *ptr1++ = tmp2;
+                *ptr1++ = tmp3;
+                *ptr1++ = tmp4;
+
+                if (tmp1 > max_bitneed) max_bitneed = tmp1;
+                if (tmp2 > max_bitneed) max_bitneed = tmp2;
+                if (tmp3 > max_bitneed) max_bitneed = tmp3;
+                if (tmp4 > max_bitneed) max_bitneed = tmp4;
+            }
+
+            ptr1 =  &bitneed[1][0];
+            ptr2 =  &sbc->scale_factor[1][0];
+
+            for (sb = tmp; sb != 0; sb--)
+            {
+                tmp1 = *ptr2++;
+                tmp2 = *ptr2++;
+                tmp3 = *ptr2++;
+                tmp4 = *ptr2++;
+
+                *ptr1++ = tmp1;
+                *ptr1++ = tmp2;
+                *ptr1++ = tmp3;
+                *ptr1++ = tmp4;
+
+                if (tmp1 > max_bitneed) max_bitneed = tmp1;
+                if (tmp2 > max_bitneed) max_bitneed = tmp2;
+                if (tmp3 > max_bitneed) max_bitneed = tmp3;
+                if (tmp4 > max_bitneed) max_bitneed = tmp4;
             }
 
         }
         else
         {
-            for(ch = 0; ch < 2; ch++)
+            for (ch = 0; ch < 2; ch++)
             {
-                for(sb = 0; sb < sbc->subbands; sb++)
+                for (sb = 0; sb < sbc->subbands; sb++)
                 {
-                    if(sbc->scale_factor[ch][sb] == 0)
+                    if (sbc->scale_factor[ch][sb] == 0)
                     {
                         bitneed[ch][sb] = -5;
                     }
                     else
                     {
-                        if(sbc->subbands == 4)
+                        if (sbc->subbands == 4)
                         {
                             loudness = sbc->scale_factor[ch][sb] - sbc_offset4[sf][sb];
                         }
@@ -289,9 +292,9 @@
                             loudness = sbc->scale_factor[ch][sb] - sbc_offset8[sf][sb];
                         }
 
-                        if(loudness > 0)
+                        if (loudness > 0)
                         {
-							bitneed[ch][sb] = loudness >> 1;
+                            bitneed[ch][sb] = loudness >> 1;
                         }
                         else
                         {
@@ -299,126 +302,127 @@
                         }
                     }
 
-					if(bitneed[ch][sb] > max_bitneed) max_bitneed = bitneed[ch][sb];
+                    if (bitneed[ch][sb] > max_bitneed) max_bitneed = bitneed[ch][sb];
                 }
             }
         }
-       
+
 
         bitcount = 0;
         slicecount = 0;
         bitslice = max_bitneed + 1;
-     
-		do
+
+        do
         {
             bitslice--;
             bitcount += slicecount;
-            slicecount = 0;        
-          
-			ptr1 = &bitneed[0][0];
-			ptr3 = &bitneed[1][0];
-			for(sb = sbc->subbands; sb != 0; sb--)
+            slicecount = 0;
+
+            ptr1 = &bitneed[0][0];
+            ptr3 = &bitneed[1][0];
+            for (sb = sbc->subbands; sb != 0; sb--)
             {
                 t_var = *ptr1++;
-				tmp1 = *ptr3++;
+                tmp1 = *ptr3++;
 
-				if((t_var > bitslice + 1) && (t_var < bitslice + 16))
-					slicecount++;                    
-                else if(t_var == bitslice + 1)
+                if ((t_var > bitslice + 1) && (t_var < bitslice + 16))
+                    slicecount++;
+                else if (t_var == bitslice + 1)
                     slicecount += 2;
 
-				if((tmp1 > bitslice + 1) && (tmp1 < bitslice + 16))
-					slicecount++;
-                    
-                else if(tmp1 == bitslice + 1)
-                    slicecount += 2;               
-            }			
-            
-        } while(bitcount + slicecount < sbc->bitpool);
+                if ((tmp1 > bitslice + 1) && (tmp1 < bitslice + 16))
+                    slicecount++;
+
+                else if (tmp1 == bitslice + 1)
+                    slicecount += 2;
+            }
+
+        }
+        while (bitcount + slicecount < sbc->bitpool);
 
 
-		if(bitcount + slicecount == sbc->bitpool)
+        if (bitcount + slicecount == sbc->bitpool)
         {
             bitcount += slicecount;
             bitslice--;
         }
-		
-        ptr1 = &bitneed[0][0];
-		ptr3 = &bits[0][0];
 
-		ptr4 = &bitneed[1][0];
-		ptr5 = &bits[1][0];
-		for(sb = sbc->subbands; sb != 0 ; sb--)
+        ptr1 = &bitneed[0][0];
+        ptr3 = &bits[0][0];
+
+        ptr4 = &bitneed[1][0];
+        ptr5 = &bits[1][0];
+        for (sb = sbc->subbands; sb != 0 ; sb--)
         {
             tmp1 = *ptr1++;
-			tmp2 = *ptr3;			
+            tmp2 = *ptr3;
 
-			if(tmp1 < bitslice + 2)               
-                tmp2 = 0;               
+            if (tmp1 < bitslice + 2)
+                tmp2 = 0;
             else
             {
                 tmp2 = tmp1 - bitslice;
-                if(tmp2 > 16) tmp2 = 16;
+                if (tmp2 > 16) tmp2 = 16;
             }
-			*ptr3++ = tmp2;
-			
-			tmp1 = *ptr4++;
-			tmp2 = *ptr5;
+            *ptr3++ = tmp2;
 
-			if(tmp1 < bitslice + 2)               
-                tmp2 = 0;               
+            tmp1 = *ptr4++;
+            tmp2 = *ptr5;
+
+            if (tmp1 < bitslice + 2)
+                tmp2 = 0;
             else
             {
                 tmp2 = tmp1 - bitslice;
-                if(tmp2 > 16) tmp2 = 16;
+                if (tmp2 > 16) tmp2 = 16;
             }
-			*ptr5++ = tmp2;
-        }		
+            *ptr5++ = tmp2;
+        }
 
-		for(sb = 0; (sb < sbc->subbands) &&  (bitcount < sbc->bitpool) ; sb++)
-		{			
-			t_var = bits[0][sb];
-			if((t_var >= 2) && (t_var < 16))
-			{
-				t_var++;
-				bitcount++;
-			}
-			else if((bitneed[0][sb] == bitslice + 1) && (sbc->bitpool > bitcount + 1))
-			{
-				t_var = 2;
-				bitcount += 2;
-			}
-			bits[0][sb] = t_var;
+        for (sb = 0; (sb < sbc->subbands) && (bitcount < sbc->bitpool) ; sb++)
+        {
+            t_var = bits[0][sb];
+            if ((t_var >= 2) && (t_var < 16))
+            {
+                t_var++;
+                bitcount++;
+            }
+            else if ((bitneed[0][sb] == bitslice + 1) && (sbc->bitpool > bitcount + 1))
+            {
+                t_var = 2;
+                bitcount += 2;
+            }
+            bits[0][sb] = t_var;
 
-			if(bitcount < sbc->bitpool)
-			{
-				t_var = bits[1][sb];
-				if((t_var >= 2) && (t_var < 16))
-				{
-					t_var++;
-					bitcount++;
-				}
-				else if((bitneed[1][sb] == bitslice + 1) && (sbc->bitpool > bitcount + 1))
-				{
-					t_var = 2;
-					bitcount += 2;
-				}
-				bits[1][sb] = t_var;
-			}
-		
-		}
+            if (bitcount < sbc->bitpool)
+            {
+                t_var = bits[1][sb];
+                if ((t_var >= 2) && (t_var < 16))
+                {
+                    t_var++;
+                    bitcount++;
+                }
+                else if ((bitneed[1][sb] == bitslice + 1) && (sbc->bitpool > bitcount + 1))
+                {
+                    t_var = 2;
+                    bitcount += 2;
+                }
+                bits[1][sb] = t_var;
+            }
 
-        for(sb = 0; (sb < sbc->subbands) &&  (bitcount < sbc->bitpool) ; sb++)
-		{
-			for(ch = 0; (ch < 2 &&  bitcount < sbc->bitpool) ; ch++)
-			{
-				if(bits[ch][sb] < 16)
-				{
-				  bits[ch][sb]++;
-				  bitcount++;
-				}
-			}
-		}  
-	}
+        }
+
+        for (sb = 0; (sb < sbc->subbands) && (bitcount < sbc->bitpool) ; sb++)
+        {
+            for (ch = 0; (ch < 2 &&  bitcount < sbc->bitpool) ; ch++)
+            {
+                if (bits[ch][sb] < 16)
+                {
+                    bits[ch][sb]++;
+                    bitcount++;
+                }
+            }
+        }
+    }
 }
 
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.h b/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.h
old mode 100755
new mode 100644
index af11a5c..a1642a5
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.h
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_allocation.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.cpp b/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.cpp
old mode 100755
new mode 100644
index 3b50936..2aae6e0
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.cpp
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "sbc.h"
 #include "sbcenc_crc8.h"
@@ -22,177 +24,177 @@
 #include "sbcenc_bitstream.h"
 
 
-Int pack_bitstream (UWord8 *data, enc_state_t *state, UInt len)
+Int pack_bitstream(UWord8 *data, enc_state_t *state, UInt len)
 {
-	Int ch, sb, blk, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, t_var1, t_var2, temp ;
-	Int *ptr1, *ptr2, levels[16], audio_samp;
-	sbc_t *sbc;
-	crc_t *crc;
-		
-	sbc = &state->sbc;
-	crc = &state->crc;	
-	
-	oscl_memset (crc, 0, sizeof (crc_t));	
-	oscl_memset (data, 0, len );	
-	
-	tmp0 = (sbc->sf_index << 6);
-	
-	switch (sbc->blocks)
-	{	
-	case 8:    
-		tmp0 |= 16; 
-		break;
-	
-	case 12:   
-		tmp0 |= 32; 
-		break;
-	
-	case 16:  
-		tmp0 |= 48; 
-		break;
-	}
-	
-	tmp0 |= (sbc->channel_mode & 0x03) << 2;
-	tmp0 |= (sbc->allocation_method & 0x01) << 1;
-	tmp2 = sbc->subbands;
-	
-	if (tmp2 == 8)
-		tmp0 |= 0x01;
-	
-	data[0] = 0x9C;
-	data[1] = tmp0;
-	data[2] = sbc->bitpool;
-	data[3] = 0x00;        
-	
-	sbc->bitpointer = 32;
-	crc->crc_buffer[0] = data[1];
-	crc->crc_buffer[1] = data[2];
-	crc->crc_consumed = 16;
-	
-	if (sbc->channel_mode == CM_JOINT_STEREO)
-	{
-		if ((len << 3) < (UInt)(32 + tmp2))
-			return(-1);
-		else
-		{
-			tmp0 = sbc->join;
-			tmp1 = 0;
+    Int ch, sb, blk, tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, t_var1, t_var2, temp ;
+    Int *ptr1, *ptr2, levels[16], audio_samp;
+    sbc_t *sbc;
+    crc_t *crc;
 
-			for (sb = 0; sb < tmp2 -1  ; sb ++)
-				tmp1 |= ((tmp0 >> sb) & 0x01) << (7 - sb);
-						
-			if (tmp2 == 4)
-				crc->crc_buffer[2] = tmp1 & 0xf0;
-			else
-				crc->crc_buffer[2] = tmp1;
-						
-			sbc->bitpointer = tmp2 + 32;
-			crc->crc_consumed += tmp2;
-		}
+    sbc = &state->sbc;
+    crc = &state->crc;
 
-		data[4] = tmp1;
-	}
-	
-	tmp0 = crc->crc_consumed;
-	tmp1 = sbc->bitpointer;
+    oscl_memset(crc, 0, sizeof(crc_t));
+    oscl_memset(data, 0, len);
 
-	if ((len << 3) < (UInt)(tmp1 + ((tmp2 * sbc->channels) << 2)))
-		return -1;
-	else
-	{
-		for (ch = 0; ch < sbc->channels; ch ++)
-		{
-			for (sb = 0; sb < tmp2; sb ++)
-			{
-				tmp3 = sbc->scale_factor[ch][sb];
-				tmp3 &= 0x0f;
+    tmp0 = (sbc->sf_index << 6);
 
-				tmp4 = tmp1 & 0x07;
-				tmp4 = 4 - tmp4;
-				tmp4 = tmp3 << tmp4;
-				tmp5 = tmp1 >> 3;
-				data [tmp5] |= tmp4;
-				
-				crc->crc_buffer[tmp0 >> 3] |= (tmp3 << (4 - (tmp0 & 0x07)));
-				
-				tmp1 += 4;
-				tmp0 += 4;
-			}
-		}
-	}
-	sbc->bitpointer = tmp1;
-	crc->crc_consumed = tmp0;
-	
-	data[3] = crc8(crc->crc_buffer, crc->crc_consumed);
-	
-	ptr1 = &levels[0];
-	for(ch = 0; ch < sbc->channels; ch++)
-	{
-		ptr2 = &sbc->bits[ch][0];
-		
-		for(sb = (tmp2 >>2); sb != 0 ; sb--)
-		{
-			tmp1 = *ptr2++;
-			tmp3 = *ptr2++;
-			
-			*ptr1++ = (1 << tmp1) - 1;
-			*ptr1++ = (1 << tmp3) - 1;	
-			
-			tmp4 = *ptr2++;
-			tmp5 = *ptr2++;								
-			*ptr1++ = (1 << tmp4) - 1;
-			*ptr1++ = (1 << tmp5) - 1;
-		}
-	}
+    switch (sbc->blocks)
+    {
+        case 8:
+            tmp0 |= 16;
+            break;
 
-	t_var1 = sbc->bitpointer;
-	for(blk = 0; blk < sbc->blocks; blk++)
-	{
-		ptr1 = &levels[0];
-		for(ch = 0; ch < sbc->channels; ch++)
-		{				
-			for(sb = 0; sb < sbc->subbands; sb++)
-			{
-				tmp1 = *ptr1++;
-				
-				if(tmp1 > 0)
-				{					
-					//Changed the order of multiplication & right shifting
-			
-					temp = (sbc->sb_sample[blk][ch][sb] >> 1);
-					tmp5 = (32768 << sbc->scale_factor[ch][sb]);
-					audio_samp = FMULT_2((temp + tmp5), tmp1) ;
-					audio_samp = audio_samp >> sbc->scale_factor[ch][sb] ;	
+        case 12:
+            tmp0 |= 32;
+            break;
 
-					t_var2 = sbc->bits[ch][sb];					
-					
-					if (8 - (t_var1 & 0x7) >= t_var2)
-					{
-						data[t_var1 >> 3] |= audio_samp << (8 - (t_var1 & 0x7) - t_var2);
-						t_var1 += t_var2;						
-					}
-					else if (16 - (t_var1 & 0x7) >= t_var2)
-					{
-						data[t_var1 >> 3] |= audio_samp >> (t_var2 + (t_var1 & 0x7) - 8);
-						data[(t_var1 >> 3) + 1] = audio_samp << (16 - (t_var1 & 0x7) - t_var2);
-						t_var1 += t_var2;						
-					}
-					else
-					{
-						data[t_var1 >> 3] |= audio_samp >> (t_var2 + (t_var1 & 0x7) - 8);
-						data[(t_var1 >> 3) + 1] = (audio_samp >> ((t_var1 & 0x7) + t_var2 - 16)) & 0xff;
-						data[(t_var1 >> 3) + 2] = audio_samp << (24 - (t_var1 & 0x7) - t_var2);
-						t_var1 += t_var2;						
-					}					
-				}
+        case 16:
+            tmp0 |= 48;
+            break;
+    }
+
+    tmp0 |= (sbc->channel_mode & 0x03) << 2;
+    tmp0 |= (sbc->allocation_method & 0x01) << 1;
+    tmp2 = sbc->subbands;
+
+    if (tmp2 == 8)
+        tmp0 |= 0x01;
+
+    data[0] = 0x9C;
+    data[1] = tmp0;
+    data[2] = sbc->bitpool;
+    data[3] = 0x00;
+
+    sbc->bitpointer = 32;
+    crc->crc_buffer[0] = data[1];
+    crc->crc_buffer[1] = data[2];
+    crc->crc_consumed = 16;
+
+    if (sbc->channel_mode == CM_JOINT_STEREO)
+    {
+        if ((len << 3) < (UInt)(32 + tmp2))
+            return(-1);
+        else
+        {
+            tmp0 = sbc->join;
+            tmp1 = 0;
+
+            for (sb = 0; sb < tmp2 - 1  ; sb ++)
+                tmp1 |= ((tmp0 >> sb) & 0x01) << (7 - sb);
+
+            if (tmp2 == 4)
+                crc->crc_buffer[2] = tmp1 & 0xf0;
+            else
+                crc->crc_buffer[2] = tmp1;
+
+            sbc->bitpointer = tmp2 + 32;
+            crc->crc_consumed += tmp2;
+        }
+
+        data[4] = tmp1;
+    }
+
+    tmp0 = crc->crc_consumed;
+    tmp1 = sbc->bitpointer;
+
+    if ((len << 3) < (UInt)(tmp1 + ((tmp2 * sbc->channels) << 2)))
+        return -1;
+    else
+    {
+        for (ch = 0; ch < sbc->channels; ch ++)
+        {
+            for (sb = 0; sb < tmp2; sb ++)
+            {
+                tmp3 = sbc->scale_factor[ch][sb];
+                tmp3 &= 0x0f;
+
+                tmp4 = tmp1 & 0x07;
+                tmp4 = 4 - tmp4;
+                tmp4 = tmp3 << tmp4;
+                tmp5 = tmp1 >> 3;
+                data [tmp5] |= tmp4;
+
+                crc->crc_buffer[tmp0 >> 3] |= (tmp3 << (4 - (tmp0 & 0x07)));
+
+                tmp1 += 4;
+                tmp0 += 4;
             }
         }
     }
-	
-	if (t_var1 & 0x7)    
-		t_var1 += 8 - (t_var1 & 0x7);
+    sbc->bitpointer = tmp1;
+    crc->crc_consumed = tmp0;
 
-	sbc->bitpointer = t_var1;
+    data[3] = crc8(crc->crc_buffer, crc->crc_consumed);
 
-	return(sbc->bitpointer >> 3);
+    ptr1 = &levels[0];
+    for (ch = 0; ch < sbc->channels; ch++)
+    {
+        ptr2 = &sbc->bits[ch][0];
+
+        for (sb = (tmp2 >> 2); sb != 0 ; sb--)
+        {
+            tmp1 = *ptr2++;
+            tmp3 = *ptr2++;
+
+            *ptr1++ = (1 << tmp1) - 1;
+            *ptr1++ = (1 << tmp3) - 1;
+
+            tmp4 = *ptr2++;
+            tmp5 = *ptr2++;
+            *ptr1++ = (1 << tmp4) - 1;
+            *ptr1++ = (1 << tmp5) - 1;
+        }
+    }
+
+    t_var1 = sbc->bitpointer;
+    for (blk = 0; blk < sbc->blocks; blk++)
+    {
+        ptr1 = &levels[0];
+        for (ch = 0; ch < sbc->channels; ch++)
+        {
+            for (sb = 0; sb < sbc->subbands; sb++)
+            {
+                tmp1 = *ptr1++;
+
+                if (tmp1 > 0)
+                {
+                    //Changed the order of multiplication & right shifting
+
+                    temp = (sbc->sb_sample[blk][ch][sb] >> 1);
+                    tmp5 = (32768 << sbc->scale_factor[ch][sb]);
+                    audio_samp = FMULT_2((temp + tmp5), tmp1) ;
+                    audio_samp = audio_samp >> sbc->scale_factor[ch][sb] ;
+
+                    t_var2 = sbc->bits[ch][sb];
+
+                    if (8 - (t_var1 & 0x7) >= t_var2)
+                    {
+                        data[t_var1 >> 3] |= audio_samp << (8 - (t_var1 & 0x7) - t_var2);
+                        t_var1 += t_var2;
+                    }
+                    else if (16 - (t_var1 & 0x7) >= t_var2)
+                    {
+                        data[t_var1 >> 3] |= audio_samp >> (t_var2 + (t_var1 & 0x7) - 8);
+                        data[(t_var1 >> 3) + 1] = audio_samp << (16 - (t_var1 & 0x7) - t_var2);
+                        t_var1 += t_var2;
+                    }
+                    else
+                    {
+                        data[t_var1 >> 3] |= audio_samp >> (t_var2 + (t_var1 & 0x7) - 8);
+                        data[(t_var1 >> 3) + 1] = (audio_samp >> ((t_var1 & 0x7) + t_var2 - 16)) & 0xff;
+                        data[(t_var1 >> 3) + 2] = audio_samp << (24 - (t_var1 & 0x7) - t_var2);
+                        t_var1 += t_var2;
+                    }
+                }
+            }
+        }
+    }
+
+    if (t_var1 & 0x7)
+        t_var1 += 8 - (t_var1 & 0x7);
+
+    sbc->bitpointer = t_var1;
+
+    return(sbc->bitpointer >> 3);
 }
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.h b/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.h
old mode 100755
new mode 100644
index 815c8b4..8317816
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.h
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_bitstream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.cpp b/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.cpp
old mode 100755
new mode 100644
index a7ccbe9..050f0a8
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.cpp
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "sbc_type_defs.h"
 #include "sbcenc_crc8.h"
@@ -24,7 +26,7 @@
 
 #if defined(USE_CRC_TABLE)
 
-static const UWord8 crctable[256] = 
+static const UWord8 crctable[256] =
 {
     0x00, 0x1D, 0x3A, 0x27, 0x74, 0x69, 0x4E, 0x53, 0xE8, 0xF5, 0xD2, 0xCF, 0x9C, 0x81, 0xA6, 0xBB,
     0xCD, 0xD0, 0xF7, 0xEA, 0xB9, 0xA4, 0x83, 0x9E, 0x25, 0x38, 0x1F, 0x02, 0x51, 0x4C, 0x6B, 0x76,
@@ -49,8 +51,8 @@
  *    CRC Check:
  *    The error detection method used is "CRC-8" with generator polynomial
  *
- *           G(X) = X8 + X4 + X3 + X2 + 1 (CRC-8) 
- *           
+ *           G(X) = X8 + X4 + X3 + X2 + 1 (CRC-8)
+ *
  *           i.e. [1:0001:1101] => Polynomial is 0x1D
  *
  *    Reference: ftp://ftp.adelaide.edu.au/pub/rocksoft/crc_v3.txt
@@ -58,7 +60,7 @@
  */
 UWord8 crc8(const UWord8 *data, UInt len)
 {
-    /******************************************************************************** 
+    /********************************************************************************
      * For loop need to be optimized and number of local variable should be reduced *
      ********************************************************************************/
     /*~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -70,20 +72,20 @@
     UWord8  bit;
     /*~~~~~~~~~~~~~~~~~~~~~~~~*/
 
-    for(i = 0; i < nBytes; i++) 
+    for (i = 0; i < nBytes; i++)
     {
         CrcReg = crctable[CrcReg ^ data[i]];
     }
 
     octet = data[i];
 
-    for(i = 0; i < nBits; i++)
+    for (i = 0; i < nBits; i++)
     {
-        bit = (UWord8) (((octet ^ CrcReg) & 0x80) >> 7);
+        bit = (UWord8)(((octet ^ CrcReg) & 0x80) >> 7);
 
-        CrcReg = (UWord8) (((CrcReg & 0x7F) << 1) ^ (bit ? CRC_POLY : 0));
+        CrcReg = (UWord8)(((CrcReg & 0x7F) << 1) ^(bit ? CRC_POLY : 0));
 
-        octet = (UWord8) (octet << 1);
+        octet = (UWord8)(octet << 1);
     }
 
     return(CrcReg);
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.h b/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.h
old mode 100755
new mode 100644
index fc8837d..2988c99
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.h
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_crc8.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_filter.cpp b/codecs_v2/audio/sbc/enc/src/sbcenc_filter.cpp
old mode 100755
new mode 100644
index fc9139b..a7adb14
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_filter.cpp
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_filter.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "sbc.h"
 #include "sbcenc_filter.h"
@@ -29,38 +31,38 @@
  */
 
 
-static const Word32  sbc_proto_4_40[40] = 
+static const Word32  sbc_proto_4_40[40] =
 {
-	0 ,			576115 ,    1601898 ,   2935298 , 
-	4120164,	4179059 ,   2003406 ,  -3285782 , 
-	11718563, 	21945682 ,	31005088 ,  34567968 , 
-	27784982, 	6584670 ,  -30947094 , -83372136 , 
-	145592176,	209366608 , 264824096 , 302610720 ,	
-	316018688,	302610720 , 264824096 , 209366608 , 
-   -145592176, -83372136 , -30947094 ,  6584670 , 
-	27784982, 	34567968 ,  31005088 ,  21945682 , 
-   -11718563,  -3285782 ,   2003406 ,   4179059 , 
-	4120164, 	2935298 ,   1601898 ,   576115 
+    0 ,			576115 ,    1601898 ,   2935298 ,
+    4120164,	4179059 ,   2003406 ,  -3285782 ,
+    11718563, 	21945682 ,	31005088 ,  34567968 ,
+    27784982, 	6584670 ,  -30947094 , -83372136 ,
+    145592176,	209366608 , 264824096 , 302610720 ,
+    316018688,	302610720 , 264824096 , 209366608 ,
+    -145592176, -83372136 , -30947094 ,  6584670 ,
+    27784982, 	34567968 ,  31005088 ,  21945682 ,
+    -11718563,  -3285782 ,   2003406 ,   4179059 ,
+    4120164, 	2935298 ,   1601898 ,   576115
 };
 
-static const Word32 sbc_proto_8_80[80] = 
+static const Word32 sbc_proto_8_80[80] =
 {
-	0 ,			168122 ,    368569 ,    595519 ,    884677 , 
-	1223985 ,   1585274 ,   1915252 ,   2160181 ,   2258852 ,	
-	2141627 , 	1735771 ,   968681 ,   -191991 ,   -1771385 , 
-   -3755063 , 	6076836 ,   8621515 ,   11229669 ,  13687238 ,
-	15733030 , 	17077392 ,  17417002 ,  16448018 ,  13891192 , 
-	9510749 , 	3139712 ,  -5278279 ,  -15720018 , -28035266 ,
-   -41956612 , -57109432 ,  73013312 ,  89104208 ,  104770776 , 
-	119396536 , 132354304,  143091584 , 151132928 , 156111152 ,
-	157791808 , 156111152 , 151132928 , 143091584 , 132354304 , 
-	119396536 , 104770776 , 89104208 , -73013312 , -57109432 ,	
-   -41956612 , -28035266 , -15720018 , -5278279 ,   3139712 , 
-	9510749 ,   13891192 ,  16448018 ,  17417002 ,  17077392 ,
-	15733030 , 	13687238 ,  11229669 ,  8621515 ,  -6076836 , 
-   -3755063 ,  -1771385 ,  -191991 ,    968681 ,    1735771 ,	
-	2141627 ,   2258852 ,   2160181 ,   1915252 ,   1585274 , 
-	1223985 , 	884677 ,    595519 ,    368569 ,    168122
+    0 ,			168122 ,    368569 ,    595519 ,    884677 ,
+    1223985 ,   1585274 ,   1915252 ,   2160181 ,   2258852 ,
+    2141627 , 	1735771 ,   968681 ,   -191991 ,   -1771385 ,
+    -3755063 , 	6076836 ,   8621515 ,   11229669 ,  13687238 ,
+    15733030 , 	17077392 ,  17417002 ,  16448018 ,  13891192 ,
+    9510749 , 	3139712 ,  -5278279 ,  -15720018 , -28035266 ,
+    -41956612 , -57109432 ,  73013312 ,  89104208 ,  104770776 ,
+    119396536 , 132354304,  143091584 , 151132928 , 156111152 ,
+    157791808 , 156111152 , 151132928 , 143091584 , 132354304 ,
+    119396536 , 104770776 , 89104208 , -73013312 , -57109432 ,
+    -41956612 , -28035266 , -15720018 , -5278279 ,   3139712 ,
+    9510749 ,   13891192 ,  16448018 ,  17417002 ,  17077392 ,
+    15733030 , 	13687238 ,  11229669 ,  8621515 ,  -6076836 ,
+    -3755063 ,  -1771385 ,  -191991 ,    968681 ,    1735771 ,
+    2141627 ,   2258852 ,   2160181 ,   1915252 ,   1585274 ,
+    1223985 , 	884677 ,    595519 ,    368569 ,    168122
 };
 
 /*$F
@@ -81,11 +83,11 @@
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 //Q30 format for the table
-static const Word32 M_8x16[11]=
+static const Word32 M_8x16[11] =
 {
-     759250112,  410903200,  992008064,  892783680, 
-     596539008,  209476640, 1053110144, -209476640, 
-   -1053110144, -596539008,  892783680
+    759250112,  410903200,  992008064,  892783680,
+    596539008,  209476640, 1053110144, -209476640,
+    -1053110144, -596539008,  892783680
 };
 
 /*$F
@@ -145,200 +147,200 @@
  ===============================================================================
  */
 
-void analysis_filter_4 (analysis_filter_t *filter, sbc_t *sbc)
+void analysis_filter_4(analysis_filter_t *filter, sbc_t *sbc)
 {
-    Int *ptr,*ptr1,t_var2, t_var1, arr_tmp[16], ch, blk, i, *X_ptr;
+    Int *ptr, *ptr1, t_var2, t_var1, arr_tmp[16], ch, blk, i, *X_ptr;
     Int  t_var4, tmp1, tmp2, tmp3, tmp4;
-	const Word32 *ptr2;	
-	const Word32 *ptr3;	
-	    
-	for (ch = 0; ch < sbc->channels; ch++)
-    {	
-		X_ptr = &filter->X[ch][60];
-		for(blk = 0; blk < sbc->blocks; blk++)
-		{             
-			ptr1 = X_ptr;          
-            		
-		    ptr2 = &sbc_proto_4_40[0];
-			ptr = &arr_tmp[0];
-            
+    const Word32 *ptr2;
+    const Word32 *ptr3;
+
+    for (ch = 0; ch < sbc->channels; ch++)
+    {
+        X_ptr = &filter->X[ch][60];
+        for (blk = 0; blk < sbc->blocks; blk++)
+        {
+            ptr1 = X_ptr;
+
+            ptr2 = &sbc_proto_4_40[0];
+            ptr = &arr_tmp[0];
+
             for (i = 4; i != 0; i --)
             {
                 tmp1 = ptr2[0];
-				tmp2 = ptr2[1];	
-				tmp3 = ptr1[0];
-				tmp4 = ptr1[1];
-				
-				t_var2 = FMULT(tmp1 , tmp3);
-				t_var1 = FMULT(tmp2 , tmp4);
-				
-				tmp1 = ptr2[8];
-				tmp2 = ptr2[9];
-				tmp3 = ptr1[8];
-				tmp4 = ptr1[9];
+                tmp2 = ptr2[1];
+                tmp3 = ptr1[0];
+                tmp4 = ptr1[1];
 
-				t_var2 += FMULT(tmp1 , tmp3);
+                t_var2 = FMULT(tmp1 , tmp3);
+                t_var1 = FMULT(tmp2 , tmp4);
+
+                tmp1 = ptr2[8];
+                tmp2 = ptr2[9];
+                tmp3 = ptr1[8];
+                tmp4 = ptr1[9];
+
+                t_var2 += FMULT(tmp1 , tmp3);
                 t_var1 += FMULT(tmp2 , tmp4);
-				
-				tmp1 = ptr2[16];
-				tmp2 = ptr2[17];
-				tmp3 = ptr1[16];
-				tmp4 = ptr1[17];
 
-				t_var2 += FMULT(tmp1 , tmp3);
-    			t_var1 += FMULT(tmp2 , tmp4);
-				
-				tmp1 = ptr2[24];
-				tmp2 = ptr2[25];
-				tmp3 = ptr1[24];
-				tmp4 = ptr1[25];
+                tmp1 = ptr2[16];
+                tmp2 = ptr2[17];
+                tmp3 = ptr1[16];
+                tmp4 = ptr1[17];
 
-				t_var2 += FMULT(tmp1 , tmp3);
-				t_var1 += FMULT(tmp2 , tmp4);
-				
-				tmp1 = ptr2[32];
-				tmp2 = ptr2[33];
-				tmp3 = ptr1[32];
-				tmp4 = ptr1[33];
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
 
-				t_var2 += FMULT(tmp1 , tmp3);
-				t_var1 += FMULT(tmp2 , tmp4);	
-				
-				*ptr++ = t_var2;
-				*ptr++ = t_var1;
-				
-				ptr2 +=2;
-				ptr1 +=2;				
-								
-             }
+                tmp1 = ptr2[24];
+                tmp2 = ptr2[25];
+                tmp3 = ptr1[24];
+                tmp4 = ptr1[25];
 
-			ptr -= 8;
-			ptr3 = M_8x16;
-            
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
+
+                tmp1 = ptr2[32];
+                tmp2 = ptr2[33];
+                tmp3 = ptr1[32];
+                tmp4 = ptr1[33];
+
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
+
+                *ptr++ = t_var2;
+                *ptr++ = t_var1;
+
+                ptr2 += 2;
+                ptr1 += 2;
+
+            }
+
+            ptr -= 8;
+            ptr3 = M_8x16;
+
             tmp1 = ptr[0] + ptr[4];
             tmp2 = ptr[1] + ptr[3];
             tmp3 = ptr[5] - ptr[7];
 
-            t_var4  = FMULT_1 (tmp1, *ptr3++);
+            t_var4  = FMULT_1(tmp1, *ptr3++);
             t_var2  = ptr[2] + t_var4;
             t_var4  = ptr[2] - t_var4;
 
-            tmp4     = FMULT_1 (tmp3, *ptr3  );
-            tmp1     = FMULT_1 (tmp2, *ptr3++);
-            tmp4    += FMULT_1 (tmp2, *ptr3  );
-            tmp1    -= FMULT_1 (tmp3, *ptr3  );
-            
+            tmp4     = FMULT_1(tmp3, *ptr3);
+            tmp1     = FMULT_1(tmp2, *ptr3++);
+            tmp4    += FMULT_1(tmp2, *ptr3);
+            tmp1    -= FMULT_1(tmp3, *ptr3);
+
             sbc->sb_sample[blk][ch][0]  = t_var2 + tmp4;
             sbc->sb_sample[blk][ch][3]  = t_var2 - tmp4;
             sbc->sb_sample[blk][ch][1]  = t_var4 + tmp1;
             sbc->sb_sample[blk][ch][2]  = t_var4 - tmp1;
 
-			X_ptr -= 4;			
+            X_ptr -= 4;
         }
     }
-	
-	tmp2 = 64 - (sbc->blocks << 2);
-	for (ch = 0; ch < sbc->channels; ch++) 
-	{	
-		ptr =  &filter->X[ch][tmp2];
-		ptr1 = &filter->X[ch][64];
 
-		oscl_memmove(ptr1, ptr, 36 * sizeof(Int));		
-	}	
-	
+    tmp2 = 64 - (sbc->blocks << 2);
+    for (ch = 0; ch < sbc->channels; ch++)
+    {
+        ptr =  &filter->X[ch][tmp2];
+        ptr1 = &filter->X[ch][64];
+
+        oscl_memmove(ptr1, ptr, 36 * sizeof(Int));
+    }
+
 }
 
-void analysis_filter_8 (analysis_filter_t *filter, sbc_t *sbc)
-{     
-    Int *ptr,*ptr1,t_var2, t_var1, arr_tmp[16], ch, blk, i, *X_ptr;
+void analysis_filter_8(analysis_filter_t *filter, sbc_t *sbc)
+{
+    Int *ptr, *ptr1, t_var2, t_var1, arr_tmp[16], ch, blk, i, *X_ptr;
     Int t_var3;
     Int t_var4;
     Int t_var5;
     Int t_var6;
-	Int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
-	const Word32 *ptr2;	
-	const Word32 *ptr3;	
-	
-    for(ch = 0; ch < sbc->channels; ch++)
+    Int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
+    const Word32 *ptr2;
+    const Word32 *ptr3;
+
+    for (ch = 0; ch < sbc->channels; ch++)
     {
         X_ptr = &filter->X[ch][120];
-		for(blk = 0; blk < sbc->blocks; blk++)
-        {         
-			ptr = X_ptr;
+        for (blk = 0; blk < sbc->blocks; blk++)
+        {
+            ptr = X_ptr;
 
-			/* Windowing by 80 coefficients */
-			ptr1=&arr_tmp[0];
-			ptr2=&sbc_proto_8_80[0];
+            /* Windowing by 80 coefficients */
+            ptr1 = &arr_tmp[0];
+            ptr2 = &sbc_proto_8_80[0];
 
-			/* Partial calculation */
-			for(i = 8; i != 0; i--)
-			{
+            /* Partial calculation */
+            for (i = 8; i != 0; i--)
+            {
 
-				tmp1 = ptr2[0];
-				tmp2 = ptr2[1];
-				tmp3 = ptr[0];
-				tmp4 = ptr[1];	
-				
-				t_var2  = FMULT(tmp1 , tmp3);
-				t_var1  = FMULT(tmp2 , tmp4);
+                tmp1 = ptr2[0];
+                tmp2 = ptr2[1];
+                tmp3 = ptr[0];
+                tmp4 = ptr[1];
 
-				tmp1 = ptr2[16];
-				tmp2 = ptr2[17];
-				tmp3 = ptr[16];
-				tmp4 = ptr[17];
+                t_var2  = FMULT(tmp1 , tmp3);
+                t_var1  = FMULT(tmp2 , tmp4);
 
-				t_var2 += FMULT (tmp1 , tmp3);
-                t_var1 += FMULT (tmp2 , tmp4);
+                tmp1 = ptr2[16];
+                tmp2 = ptr2[17];
+                tmp3 = ptr[16];
+                tmp4 = ptr[17];
 
-				tmp1 = ptr2[32];
-				tmp2 = ptr2[33];
-				tmp3 = ptr[32];
-				tmp4 = ptr[33];
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
 
-				t_var2 += FMULT (tmp1 , tmp3);
-                t_var1 += FMULT (tmp2 , tmp4);
+                tmp1 = ptr2[32];
+                tmp2 = ptr2[33];
+                tmp3 = ptr[32];
+                tmp4 = ptr[33];
 
-				tmp1 = ptr2[48];
-				tmp2 = ptr2[49];
-				tmp3 = ptr[48];
-				tmp4 = ptr[49];
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
 
-				t_var2 += FMULT (tmp1 , tmp3);
-                t_var1 += FMULT (tmp2 , tmp4);
+                tmp1 = ptr2[48];
+                tmp2 = ptr2[49];
+                tmp3 = ptr[48];
+                tmp4 = ptr[49];
 
-				tmp1 = ptr2[64];
-				tmp2 = ptr2[65];
-				tmp3 = ptr[64];
-				tmp4 = ptr[65];
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
 
-				t_var2 += FMULT (tmp1 , tmp3);
-                t_var1 += FMULT (tmp2 , tmp4);
+                tmp1 = ptr2[64];
+                tmp2 = ptr2[65];
+                tmp3 = ptr[64];
+                tmp4 = ptr[65];
 
-				ptr2 += 2;
-				ptr +=2 ;
+                t_var2 += FMULT(tmp1 , tmp3);
+                t_var1 += FMULT(tmp2 , tmp4);
 
-				*ptr1++=t_var2;
-				*ptr1++=t_var1;
-			}
-			/* Calculate 8 subband samples by Matrixing */
-			ptr=& sbc->sb_sample[blk][ch][0];
-			ptr3 = M_8x16;
-			ptr1-=16;			
-		
+                ptr2 += 2;
+                ptr += 2 ;
+
+                *ptr1++ = t_var2;
+                *ptr1++ = t_var1;
+            }
+            /* Calculate 8 subband samples by Matrixing */
+            ptr = & sbc->sb_sample[blk][ch][0];
+            ptr3 = M_8x16;
+            ptr1 -= 16;
+
             tmp1 = ptr1[ 0] + ptr1[ 8];
             tmp3 = ptr1[ 2] + ptr1[ 6];
             tmp6 = ptr1[10] - ptr1[14];
 
-            
-            t_var5  = FMULT_1( tmp1, *ptr3++);
+
+            t_var5  = FMULT_1(tmp1, *ptr3++);
             t_var2  = ptr1[4] + t_var5 ;
             t_var5  = ptr1[4] - t_var5;
             t_var3  = t_var2;
             t_var6  = t_var5;
-            tmp8    = FMULT_1( tmp6, *ptr3  );
-            tmp1    = FMULT_1( tmp3, *ptr3++);
-            tmp8   += FMULT_1( tmp3, *ptr3  );
-            tmp1   -= FMULT_1( tmp6, *ptr3++);
+            tmp8    = FMULT_1(tmp6, *ptr3);
+            tmp1    = FMULT_1(tmp3, *ptr3++);
+            tmp8   += FMULT_1(tmp3, *ptr3);
+            tmp1   -= FMULT_1(tmp6, *ptr3++);
             t_var2 += tmp8;
             t_var3 -= tmp8;
             t_var5 += tmp1;
@@ -346,53 +348,53 @@
 
             tmp2 = ptr1[ 1] + ptr1[ 7];
             tmp5 = ptr1[ 9] - ptr1[15];
-            
-            t_var1  = -FMULT_1( tmp2, *ptr3  );
-            t_var4  = -FMULT_1( tmp5, *ptr3++);
-            t_var1 -=  FMULT_1( tmp5, *ptr3  );
-            t_var4 +=  FMULT_1( tmp2, *ptr3++);
+
+            t_var1  = -FMULT_1(tmp2, *ptr3);
+            t_var4  = -FMULT_1(tmp5, *ptr3++);
+            t_var1 -=  FMULT_1(tmp5, *ptr3);
+            t_var4 +=  FMULT_1(tmp2, *ptr3++);
 
             tmp7 = ptr1[11] - ptr1[13];
             tmp4 = ptr1[ 3] + ptr1[ 5];
-            
-            t_var1 -=  FMULT_1( tmp7, *ptr3  );
-            t_var4 -=  FMULT_1( tmp4, *ptr3++);
-            t_var1 -=  FMULT_1( tmp4, *ptr3  );
-            t_var4 +=  FMULT_1( tmp7, *ptr3++);
-            
-            ptr[0]  = t_var2 - t_var1;			
-            ptr[7]  = t_var2 + t_var1;			                            
-            ptr[3]  = t_var3 - t_var4;			
-            ptr[4]  = t_var3 + t_var4;			                
-            
 
-            t_var1  = -FMULT_1( tmp2, *ptr3  );
-            t_var4  =  FMULT_1( tmp5, *ptr3++);
-            t_var1 -=  FMULT_1( tmp5, *ptr3  );
-            t_var4 -=  FMULT_1( tmp2, *ptr3++);
-            
-            t_var1 -=  FMULT_1( tmp7, *ptr3  );
-            t_var4 +=  FMULT_1( tmp4, *ptr3++);
-            t_var1 -=  FMULT_1( tmp4, *ptr3  );
-            t_var4 -=  FMULT_1( tmp7, *ptr3  );
-                        
-            ptr[1]  = t_var5 - t_var1;			
-            ptr[6]  = t_var5 + t_var1;			                            
-            ptr[2]  = t_var6 - t_var4;			
-            ptr[5]  = t_var6 + t_var4;		
-            
-            
-			X_ptr -= 8;
-		}
-	}
+            t_var1 -=  FMULT_1(tmp7, *ptr3);
+            t_var4 -=  FMULT_1(tmp4, *ptr3++);
+            t_var1 -=  FMULT_1(tmp4, *ptr3);
+            t_var4 +=  FMULT_1(tmp7, *ptr3++);
 
-	tmp2 = 128 - (sbc->blocks << 3);
-	for (ch = 0; ch < sbc->channels; ch++) 
-	{	
-		ptr =  &filter->X[ch][tmp2];
-		ptr1 = &filter->X[ch][128];
+            ptr[0]  = t_var2 - t_var1;
+            ptr[7]  = t_var2 + t_var1;
+            ptr[3]  = t_var3 - t_var4;
+            ptr[4]  = t_var3 + t_var4;
 
-		oscl_memmove(ptr1, ptr, 72 * sizeof(Int));		
-	}
+
+            t_var1  = -FMULT_1(tmp2, *ptr3);
+            t_var4  =  FMULT_1(tmp5, *ptr3++);
+            t_var1 -=  FMULT_1(tmp5, *ptr3);
+            t_var4 -=  FMULT_1(tmp2, *ptr3++);
+
+            t_var1 -=  FMULT_1(tmp7, *ptr3);
+            t_var4 +=  FMULT_1(tmp4, *ptr3++);
+            t_var1 -=  FMULT_1(tmp4, *ptr3);
+            t_var4 -=  FMULT_1(tmp7, *ptr3);
+
+            ptr[1]  = t_var5 - t_var1;
+            ptr[6]  = t_var5 + t_var1;
+            ptr[2]  = t_var6 - t_var4;
+            ptr[5]  = t_var6 + t_var4;
+
+
+            X_ptr -= 8;
+        }
+    }
+
+    tmp2 = 128 - (sbc->blocks << 3);
+    for (ch = 0; ch < sbc->channels; ch++)
+    {
+        ptr =  &filter->X[ch][tmp2];
+        ptr1 = &filter->X[ch][128];
+
+        oscl_memmove(ptr1, ptr, 72 * sizeof(Int));
+    }
 
 }
diff --git a/codecs_v2/audio/sbc/enc/src/sbcenc_filter.h b/codecs_v2/audio/sbc/enc/src/sbcenc_filter.h
old mode 100755
new mode 100644
index 32a264c..092ec72
--- a/codecs_v2/audio/sbc/enc/src/sbcenc_filter.h
+++ b/codecs_v2/audio/sbc/enc/src/sbcenc_filter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/audio/sbc/enc/src/scalefactors.cpp b/codecs_v2/audio/sbc/enc/src/scalefactors.cpp
old mode 100755
new mode 100644
index 6d7f56a..0f79dcf
--- a/codecs_v2/audio/sbc/enc/src/scalefactors.cpp
+++ b/codecs_v2/audio/sbc/enc/src/scalefactors.cpp
@@ -1,18 +1,20 @@
-/***************************************************************************
- * This Software has been authored by or modified by PacketVideo Corporation.
- * Title and ownership, including all intellectual
- * property rights in and to the Software shall remain with PacketVideo
- * Corporation. The Software is protected by the patent and copyright laws of
- * the United States and by international treaty.
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
  *
- * No part of this software may be modified, reproduced or distributed without
- * the prior written consent of PacketVideo Corporation.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- * Copyright (c) 1998, 2007, PacketVideo Corporation. All Rights Reserved.
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Release: NJ_SRCHREL_071018
- *
- ***************************************************************************/
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
 #include "oscl_types.h"
 #include "sbc.h"
 #include "sbc_encoder.h"
@@ -27,167 +29,167 @@
 {
     Int      sb, blk;           /* channel, subband, block and bit counters */
     sbc_t    *sbc = &state->sbc;
-	UWord32  tmp1, tmp2, tmp3, tmp4, *ptr1, *ptr3;     
-    
-	if(sbc->channels == 1)
-	{	
-	   ptr1 = &sbc->scale_factor[0][0];
-	   
-	   for(sb = 0; sb < sbc->subbands; sb++)
-       {
+    UWord32  tmp1, tmp2, tmp3, tmp4, *ptr1, *ptr3;
+
+    if (sbc->channels == 1)
+    {
+        ptr1 = &sbc->scale_factor[0][0];
+
+        for (sb = 0; sb < sbc->subbands; sb++)
+        {
             tmp1 = 0;
-		    tmp2 = 2;
-            for(blk = 0; blk < sbc->blocks ; blk+=4)
+            tmp2 = 2;
+            for (blk = 0; blk < sbc->blocks ; blk += 4)
             {
-               while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk][0][sb]) >> 15))
-               {
-		           tmp1++;
-	    		   tmp2 <<= 1;
-               }
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+1][0][sb]) >> 15))
-               {
-		           tmp1++;
-	    		   tmp2 <<= 1;
-               }
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+2][0][sb]) >> 15))
-               {
-		           tmp1++;
-	    		   tmp2 <<= 1;
-               }
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+3][0][sb]) >> 15))
-               {
-		           tmp1++;
-	    		   tmp2 <<= 1;
-               }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+1][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+2][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+3][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
             }
 
-			*ptr1++ = tmp1;
-		}
-	}
-	else
-	{
-		ptr1 = &sbc->scale_factor[0][0];
-		ptr3 = &sbc->scale_factor[1][0];		
-
-		for(sb = 0; sb < sbc->subbands; sb++)
-		{
-		   tmp1 = 0;
-		   tmp2 = 2;
-
-		   tmp3 = 0;
-		   tmp4 = 2;
-		   for(blk = 0; blk < sbc->blocks ; blk+=4)
-		   {
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk][0][sb]) >> 15))
-			   {
-				   tmp1++;
-	    		   tmp2 <<= 1;
-			   }
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+1][0][sb]) >> 15))
-			   {
-				   tmp1++;
-	    		   tmp2 <<= 1;
-			   }
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+2][0][sb]) >> 15))
-			   {
-				   tmp1++;
-	    		   tmp2 <<= 1;
-			   }
-			   while(tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+3][0][sb]) >> 15))
-			   {
-				   tmp1++;
-	    		   tmp2 <<= 1;
-			   }
-			   while(tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk][1][sb]) >> 15))
-			   {
-				   tmp3++;
-    			   tmp4 <<= 1;
-			   }
-			   while(tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk+1][1][sb]) >> 15))
-			   {
-				   tmp3++;
-    			   tmp4 <<= 1;
-			   }
-			   while(tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk+2][1][sb]) >> 15))
-			   {
-				   tmp3++;
-    			   tmp4 <<= 1;
-			   }
-			   while(tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk+3][1][sb]) >> 15))
-			   {
-				   tmp3++;
-    			   tmp4 <<= 1;
-			   }
-			}
-
-			*ptr1++ = tmp1;
-			*ptr3++ = tmp3;			
-		}		
-		   
-	}
-
-	/********************************************************************************/
-	//Optimized code
-
-	if(sbc->channel_mode == CM_JOINT_STEREO)
+            *ptr1++ = tmp1;
+        }
+    }
+    else
     {
-        Int		sb_sample_j_0[16], sb_sample_j_1[16]; 
+        ptr1 = &sbc->scale_factor[0][0];
+        ptr3 = &sbc->scale_factor[1][0];
+
+        for (sb = 0; sb < sbc->subbands; sb++)
+        {
+            tmp1 = 0;
+            tmp2 = 2;
+
+            tmp3 = 0;
+            tmp4 = 2;
+            for (blk = 0; blk < sbc->blocks ; blk += 4)
+            {
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+1][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+2][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp2 <= (UWord32)(fabs(sbc->sb_sample[blk+3][0][sb]) >> 15))
+                {
+                    tmp1++;
+                    tmp2 <<= 1;
+                }
+                while (tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk][1][sb]) >> 15))
+                {
+                    tmp3++;
+                    tmp4 <<= 1;
+                }
+                while (tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk+1][1][sb]) >> 15))
+                {
+                    tmp3++;
+                    tmp4 <<= 1;
+                }
+                while (tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk+2][1][sb]) >> 15))
+                {
+                    tmp3++;
+                    tmp4 <<= 1;
+                }
+                while (tmp4 <= (UWord32)(fabs(sbc->sb_sample[blk+3][1][sb]) >> 15))
+                {
+                    tmp3++;
+                    tmp4 <<= 1;
+                }
+            }
+
+            *ptr1++ = tmp1;
+            *ptr3++ = tmp3;
+        }
+
+    }
+
+    /********************************************************************************/
+    //Optimized code
+
+    if (sbc->channel_mode == CM_JOINT_STEREO)
+    {
+        Int		sb_sample_j_0[16], sb_sample_j_1[16];
         UWord32 tmp1, tmp2, tmp3, tmp4;
-		Int		*ptr1, *ptr2, tmp5, tmp6;
-        
-		sbc->join = 0;
-        for(sb = 0; sb < sbc->subbands - 1; sb++)
-        {            
-			tmp1 = 0;
-			tmp2 = 2;
-			tmp3 = 0;
-			tmp4 = 2;
-			
-			ptr1 = &sb_sample_j_0[0];
-			ptr2 = &sb_sample_j_1[0];
-			for(blk = 0; blk < sbc->blocks; blk++)
+        Int		*ptr1, *ptr2, tmp5, tmp6;
+
+        sbc->join = 0;
+        for (sb = 0; sb < sbc->subbands - 1; sb++)
+        {
+            tmp1 = 0;
+            tmp2 = 2;
+            tmp3 = 0;
+            tmp4 = 2;
+
+            ptr1 = &sb_sample_j_0[0];
+            ptr2 = &sb_sample_j_1[0];
+            for (blk = 0; blk < sbc->blocks; blk++)
             {
                 tmp5 = (sbc->sb_sample[blk][0][sb] + sbc->sb_sample[blk][1][sb]) >> 1;
                 tmp6 = (sbc->sb_sample[blk][0][sb]  - sbc->sb_sample[blk][1][sb]) >> 1 ;
 
-				while(tmp2 <= (UWord32)(fabs(tmp5) >> 15))
+                while (tmp2 <= (UWord32)(fabs(tmp5) >> 15))
                 {
-					tmp1++;
-					tmp2 <<= 1;
+                    tmp1++;
+                    tmp2 <<= 1;
                 }
 
-				while(tmp4 <= (UWord32)(fabs(tmp6) >> 15))
+                while (tmp4 <= (UWord32)(fabs(tmp6) >> 15))
                 {
-					tmp3++;
-					tmp4 <<= 1;
+                    tmp3++;
+                    tmp4 <<= 1;
                 }
-				*ptr1++ = tmp5;
-				*ptr2++ = tmp6;
+                *ptr1++ = tmp5;
+                *ptr2++ = tmp6;
             }
-			
-			ptr1 -=sbc->blocks;
-			ptr2-=sbc->blocks;
 
-			if((sbc->scale_factor[0][sb] + sbc->scale_factor[1][sb]) > (tmp1 + tmp3))
-			{
-				sbc->join |= 1 << sb;
+            ptr1 -= sbc->blocks;
+            ptr2 -= sbc->blocks;
+
+            if ((sbc->scale_factor[0][sb] + sbc->scale_factor[1][sb]) > (tmp1 + tmp3))
+            {
+                sbc->join |= 1 << sb;
                 sbc->scale_factor[0][sb] = tmp1;
                 sbc->scale_factor[1][sb] = tmp3;
-                
-                for(blk = 0; blk < sbc->blocks ; blk+=2)
+
+                for (blk = 0; blk < sbc->blocks ; blk += 2)
                 {
                     tmp2 = *ptr1++;
                     tmp4 = *ptr1++;
                     tmp5 = *ptr2++;
                     tmp6 = *ptr2++;
-                    
+
                     sbc->sb_sample[blk][0][sb] = tmp2;
                     sbc->sb_sample[blk][1][sb] = tmp5;
-                    
+
                     sbc->sb_sample[blk+1][0][sb] = tmp4;
                     sbc->sb_sample[blk+1][1][sb] = tmp6;
                 }
             }
-        }  
-	}
+        }
+    }
 }
diff --git a/codecs_v2/audio/sbc/enc/src/scalefactors.h b/codecs_v2/audio/sbc/enc/src/scalefactors.h
old mode 100755
new mode 100644
index 202b9a3..ede77dc
--- a/codecs_v2/audio/sbc/enc/src/scalefactors.h
+++ b/codecs_v2/audio/sbc/enc/src/scalefactors.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/omx/factories/omx_m4v_factory/Android.mk b/codecs_v2/omx/factories/omx_m4v_factory/Android.mk
deleted file mode 100644
index aa92e0d..0000000
--- a/codecs_v2/omx/factories/omx_m4v_factory/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/omx_m4v_component_interface.cpp
-
-
-
-LOCAL_MODULE := libomx_m4v_component_interface
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/include \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/src \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/../../../../codecs_v2/omx/omx_m4v/include \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/../../../../codecs_v2/omx/omx_m4v/src \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/../../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/../../../../codecs_v2/video/m4v_h263/dec/src \
-	$(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/../../../../codecs_v2/video/m4v_h263/dec/include \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/omx_m4v_component_interface.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/factories/omx_m4v_factory/build/make/makefile b/codecs_v2/omx/factories/omx_m4v_factory/build/make/makefile
deleted file mode 100644
index 9619454..0000000
--- a/codecs_v2/omx/factories/omx_m4v_factory/build/make/makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_m4v_component_interface
-
-XINCDIRS += \
-	-I ../../../../../../codecs_v2/omx/omx_m4v/include \
-	-I ../../../../../../codecs_v2/omx/omx_m4v/src \
-	-I ../../../../../../extern_libs_v2/khronos/openmax/include \
-	-I ../../../../../../codecs_v2/video/m4v_h263/dec/src \
-	-I ../../../../../../codecs_v2/video/m4v_h263/dec/include
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = 	omx_m4v_component_interface.cpp
-
-
-HDRS = omx_m4v_component_interface.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/factories/omx_m4v_factory/include/omx_m4v_component_interface.h b/codecs_v2/omx/factories/omx_m4v_factory/include/omx_m4v_component_interface.h
deleted file mode 100644
index bbeb613..0000000
--- a/codecs_v2/omx/factories/omx_m4v_factory/include/omx_m4v_component_interface.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-#define OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-
-#include "omx_core.h"
-
-#define PV_OMX_M4V_TYPE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6b)
-#define PV_OMX_H263_TYPE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6c)
-
-class OsclSharedLibrary;
-
-class OmxM4vComponentFactory
-{
-    public:
-        static OMX_ERRORTYPE M4vCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-        static OMX_ERRORTYPE M4vDestructor(OMX_IN OMX_HANDLETYPE pHandle);
-        static OMX_ERRORTYPE H263Create(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-        static OMX_ERRORTYPE H263Destructor(OMX_IN OMX_HANDLETYPE pHandle);
-
-    private:
-        static OsclSharedLibrary* iOmxLib;
-        static int iRefCount;
-};
-
-#endif // OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-
diff --git a/codecs_v2/omx/factories/omx_m4v_factory/src/omx_m4v_component_interface.cpp b/codecs_v2/omx/factories/omx_m4v_factory/src/omx_m4v_component_interface.cpp
deleted file mode 100644
index 4730fb0..0000000
--- a/codecs_v2/omx/factories/omx_m4v_factory/src/omx_m4v_component_interface.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "omx_m4v_component_interface.h"
-
-#include "pv_omxdefs.h"
-#include "omx_mpeg4_component.h"
-
-#include "oscl_shared_library.h"
-
-#include "pvmf_node_shared_lib_interface.h"
-#include "pv_omx_shared_lib_interface.h"
-
-#define M4V_MAX_LIB_PATH 32
-
-#define OMX_M4V_LIB_NAME "libopencoremp4.so"
-
-// Since iOmxLib is a static member variable, it must be assigned here before
-// it can be used.
-OsclSharedLibrary* OmxM4vComponentFactory::iOmxLib = NULL;
-int OmxM4vComponentFactory::iRefCount = 0;
-
-// This function is called by OMX_GetHandle and it creates an instance of the m4v component AO
-// by loading the library where libomx_m4v_component_lib is located
-OMX_ERRORTYPE OmxM4vComponentFactory::M4vCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
-{
-    OSCL_StackString<M4V_MAX_LIB_PATH> omxLibName(OMX_M4V_LIB_NAME);
-    OsclSharedLibrary* lib = NULL;
-
-    // If iOmxLib is NULL, this is the first time this has been called.
-    // Theoretically, there shouldn't ever be a case where iOmxLib is opened
-    // twice, but this check is in here just in case.
-    if (NULL == OmxM4vComponentFactory::iOmxLib)
-    {
-        lib = OSCL_NEW(OsclSharedLibrary, (omxLibName));
-    }
-    else
-    {
-        lib = OmxM4vComponentFactory::iOmxLib;
-    }
-
-    // Keep track of the number of times iOmxLib is accessed
-    OmxM4vComponentFactory::iRefCount++;
-
-    // Load the associated library. If successful, call the corresponding
-    // create function for OMX M4V.
-    if (OsclLibSuccess == lib->LoadLib())
-    {
-        OsclAny* interfacePtr = NULL;
-        lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr);
-
-        OmxSharedLibraryInterface* omxIntPtr =
-            OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
-
-        OsclAny* createCompTemp =
-            omxIntPtr->QueryOmxComponentInterface(PV_OMX_M4V_TYPE, PV_OMX_CREATE_INTERFACE);
-
-        // createComp is the function pointer to store the creation function
-        // for the omx component
-        OMX_ERRORTYPE(*createComp)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-        createComp =
-            OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_OUT OMX_HANDLETYPE*, OMX_IN OMX_PTR), createCompTemp);
-
-        OMX_ERRORTYPE returnStatus = (*createComp)(pHandle, pAppData);
-
-        // Store the shared library so it can be closed later
-        OmxM4vComponentFactory::iOmxLib = lib;
-
-        return returnStatus;
-    }
-    else
-    {
-        lib->Close();
-
-        // If this is the last time to close the library, delete the
-        // OsclSharedLibrary object and be sure to set iOmxLib back to NULL
-        OmxM4vComponentFactory::iRefCount--;
-        if (0 == OmxM4vComponentFactory::iRefCount)
-        {
-            OSCL_DELETE(lib);
-            OmxM4vComponentFactory::iOmxLib = NULL;
-        }
-    }
-
-    return OMX_ErrorUndefined;
-}
-
-OMX_ERRORTYPE OmxM4vComponentFactory::M4vDestructor(OMX_IN OMX_HANDLETYPE pHandle)
-{
-    OsclSharedLibrary* lib = OmxM4vComponentFactory::iOmxLib;
-
-    // lib must not be NULL at this point. If the omx component has been
-    // created, lib is necessary to destroy the component correctly and
-    // cleanup used memory.
-    OSCL_ASSERT(NULL != lib);
-
-    // Need to get the function pointer for the destroy function through the
-    // shared library interface.
-    OsclAny* interfacePtr = NULL;
-    lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr);
-
-    OmxSharedLibraryInterface* omxIntPtr =
-        OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
-
-    OsclAny* destroyCompTemp =
-        omxIntPtr->QueryOmxComponentInterface(PV_OMX_M4V_TYPE, PV_OMX_DESTROY_INTERFACE);
-
-    // destroyComp is the function pointer to store the function for
-    // destroying the omx m4v component.
-    OMX_ERRORTYPE(*destroyComp)(OMX_IN OMX_HANDLETYPE pHandle);
-    destroyComp =
-        OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_IN OMX_HANDLETYPE), destroyCompTemp);
-
-    OMX_ERRORTYPE returnStatus = (*destroyComp)(pHandle);
-
-    // Finish memory cleanup by closing the shared library and deleting
-    lib->Close();
-
-    // If this is the last time to close the library, delete the
-    // OsclSharedLibrary object and be sure to set iOmxLib back to NULL
-    OmxM4vComponentFactory::iRefCount--;
-    if (0 == OmxM4vComponentFactory::iRefCount)
-    {
-        OSCL_DELETE(lib);
-        OmxM4vComponentFactory::iOmxLib = NULL;
-    }
-
-    return returnStatus;
-}
-
-// This function is called by OMX_GetHandle and it creates an instance of the m4v component AO
-// by loading the library where libomx_m4v_component_lib is located
-OMX_ERRORTYPE OmxM4vComponentFactory::H263Create(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
-{
-    OSCL_StackString<M4V_MAX_LIB_PATH> omxLibName(OMX_M4V_LIB_NAME);
-    OsclSharedLibrary* lib = NULL;
-
-    // If iOmxLib is NULL, this is the first time this has been called.
-    // Theoretically, there shouldn't ever be a case where iOmxLib is opened
-    // twice, but this check is in here just in case.
-    if (NULL == OmxM4vComponentFactory::iOmxLib)
-    {
-        lib = OSCL_NEW(OsclSharedLibrary, (omxLibName));
-    }
-    else
-    {
-        lib = OmxM4vComponentFactory::iOmxLib;
-    }
-
-    // Keep track of the number of times iOmxLib is accessed
-    OmxM4vComponentFactory::iRefCount++;
-
-    // Load the associated library. If successful, call the corresponding
-    // create function for OMX M4V.
-    if (OsclLibSuccess == lib->LoadLib())
-    {
-        OsclAny* interfacePtr = NULL;
-        lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr);
-
-        OmxSharedLibraryInterface* omxIntPtr =
-            OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
-
-        OsclAny* createCompTemp =
-            omxIntPtr->QueryOmxComponentInterface(PV_OMX_H263_TYPE, PV_OMX_CREATE_INTERFACE);
-
-        // createComp is the function pointer to store the creation function
-        // for the omx component
-        OMX_ERRORTYPE(*createComp)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-        createComp =
-            OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_OUT OMX_HANDLETYPE*, OMX_IN OMX_PTR), createCompTemp);
-
-        OMX_ERRORTYPE returnStatus = (*createComp)(pHandle, pAppData);
-
-        // Store the shared library so it can be closed later
-        OmxM4vComponentFactory::iOmxLib = lib;
-
-        return returnStatus;
-    }
-    else
-    {
-        lib->Close();
-
-        // If this is the last time to close the library, delete the
-        // OsclSharedLibrary object and be sure to set iOmxLib back to NULL
-        OmxM4vComponentFactory::iRefCount--;
-        if (0 == OmxM4vComponentFactory::iRefCount)
-        {
-            OSCL_DELETE(lib);
-            OmxM4vComponentFactory::iOmxLib = NULL;
-        }
-    }
-
-    return OMX_ErrorUndefined;
-}
-
-OMX_ERRORTYPE OmxM4vComponentFactory::H263Destructor(OMX_IN OMX_HANDLETYPE pHandle)
-{
-    OsclSharedLibrary* lib = OmxM4vComponentFactory::iOmxLib;
-
-    // lib must not be NULL at this point. If the omx component has been
-    // created, lib is necessary to destroy the component correctly and
-    // cleanup used memory.
-    OSCL_ASSERT(NULL != lib);
-
-    // Need to get the function pointer for the destroy function through the
-    // shared library interface.
-    OsclAny* interfacePtr = NULL;
-    lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr);
-
-    OmxSharedLibraryInterface* omxIntPtr =
-        OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
-
-    OsclAny* destroyCompTemp =
-        omxIntPtr->QueryOmxComponentInterface(PV_OMX_H263_TYPE, PV_OMX_DESTROY_INTERFACE);
-
-    // destroyComp is the function pointer to store the function for
-    // destroying the omx m4v component.
-    OMX_ERRORTYPE(*destroyComp)(OMX_IN OMX_HANDLETYPE pHandle);
-    destroyComp =
-        OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_IN OMX_HANDLETYPE), destroyCompTemp);
-
-    OMX_ERRORTYPE returnStatus = (*destroyComp)(pHandle);
-
-    // Finish memory cleanup by closing the shared library and deleting
-    lib->Close();
-
-    // If this is the last time to close the library, delete the
-    // OsclSharedLibrary object and be sure to set iOmxLib back to NULL
-    OmxM4vComponentFactory::iRefCount--;
-    if (0 == OmxM4vComponentFactory::iRefCount)
-    {
-        OSCL_DELETE(lib);
-        OmxM4vComponentFactory::iOmxLib = NULL;
-    }
-
-    return returnStatus;
-}
-
diff --git a/codecs_v2/omx/omx_aac/Android.mk b/codecs_v2/omx/omx_aac/Android.mk
index 31938b3..fcd3985 100644
--- a/codecs_v2/omx/omx_aac/Android.mk
+++ b/codecs_v2/omx/omx_aac/Android.mk
@@ -3,31 +3,34 @@
 
 LOCAL_SRC_FILES := \
 	src/aac_decode_frame.cpp \
-	src/omx_aac_component.cpp \
-	src/aac_timestamp.cpp
-
+ 	src/omx_aac_component.cpp \
+ 	src/aac_timestamp.cpp
 
 
 LOCAL_MODULE := libomx_aac_component_lib
 
-LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_aac/include \
-	$(PV_TOP)//codecs_v2/omx/omx_aac/src \
-	$(PV_TOP)//codecs_v2/omx/omx_aac/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//codecs_v2/omx/omx_aac/../../audio/aac/dec/src \
-	$(PV_TOP)//codecs_v2/omx/omx_aac/../../audio/aac/dec/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_aac/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_aac/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/omx/omx_baseclass/include \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/aac_dec.h \
-	include/omx_aac_component.h \
-	include/aac_timestamp.h
+ 	include/omx_aac_component.h \
+ 	include/aac_timestamp.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_aac/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_aac/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..79ef0ab
--- /dev/null
+++ b/codecs_v2/omx/omx_aac/build/make_multithreaded/local.mk
@@ -0,0 +1,35 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_aac_component_lib
+
+XCPPFLAGS += -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO
+
+XINCDIRS += \
+    ../../../../../extern_libs_v2/khronos/openmax/include \
+    ../../../../omx/omx_baseclass/include \
+    ../../../../audio/aac/dec/src \
+    ../../../../audio/aac/dec/include
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := aac_decode_frame.cpp \
+        omx_aac_component.cpp \
+        aac_timestamp.cpp  
+
+
+HDRS := aac_dec.h \
+        omx_aac_component.h \
+        aac_timestamp.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_aac/build/make_multithreaded/makefile b/codecs_v2/omx/omx_aac/build/make_multithreaded/makefile
deleted file mode 100644
index cc9bbe0..0000000
--- a/codecs_v2/omx/omx_aac/build/make_multithreaded/makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_aac_component_lib
-
-XCPPFLAGS += -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO
-
-XINCDIRS += \
-	-I ../../../../../extern_libs_v2/khronos/openmax/include \
-	-I ../../../../audio/aac/dec/src \
-	-I ../../../../audio/aac/dec/include
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  aac_decode_frame.cpp \
-        omx_aac_component.cpp \
-        aac_timestamp.cpp  
-
-
-HDRS =  aac_dec.h \
-        omx_aac_component.h \
-        aac_timestamp.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_aac/include/aac_dec.h b/codecs_v2/omx/omx_aac/include/aac_dec.h
index e8f283f..8d58881 100644
--- a/codecs_v2/omx/omx_aac/include/aac_dec.h
+++ b/codecs_v2/omx/omx_aac/include/aac_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,10 @@
 #ifndef AAC_DEC_H_INCLUDED
 #define AAC_DEC_H_INCLUDED
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #ifndef OMX_Component_h
 #include "omx_component.h"
 #endif
@@ -46,7 +50,7 @@
                             OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer,
                             OMX_AUDIO_PARAM_PCMMODETYPE* aAudioPcmParam,
                             OMX_AUDIO_PARAM_AACPROFILETYPE* aAudioAacParam,
-                            OMX_S32* aSamplesPerFrame, OMX_BOOL* aResizeFlag);
+                            OMX_U32* aSamplesPerFrame, OMX_BOOL* aResizeFlag);
 
         void UpdateAACPlusEnabled(OMX_BOOL flag);
 
@@ -63,6 +67,7 @@
         tPVMP4AudioDecoderExternal  iExt;
         OMX_U32 iNumOfChannels;
         OMX_U32  iMemReq;
+        OMX_S32 iConfigUpSamplingFactor;
 
 };
 
diff --git a/codecs_v2/omx/omx_aac/include/aac_timestamp.h b/codecs_v2/omx/omx_aac/include/aac_timestamp.h
index a4577b0..0d32d3b 100644
--- a/codecs_v2/omx/omx_aac/include/aac_timestamp.h
+++ b/codecs_v2/omx/omx_aac/include/aac_timestamp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/omx/omx_aac/include/omx_aac_component.h b/codecs_v2/omx/omx_aac/include/omx_aac_component.h
index cd3824d..8632f04 100644
--- a/codecs_v2/omx/omx_aac/include/omx_aac_component.h
+++ b/codecs_v2/omx/omx_aac/include/omx_aac_component.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,378 +24,59 @@
 #ifndef OMX_AAC_COMPONENT_H_INCLUDED
 #define OMX_AAC_COMPONENT_H_INCLUDED
 
-#ifndef OMX_Component_h
-#include "omx_component.h"
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
 #endif
 
 #ifndef AAC_DEC_H_INCLUDED
 #include "aac_dec.h"
 #endif
 
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PV_OMX_QUEUE_H_INCLUDED
-#include "pv_omx_queue.h"
-#endif
-
-#ifndef PV_OMXCORE_H_INCLUDED
-#include "pv_omxcore.h"
-#endif
-
 #ifndef AAC_TIMESTAMP_H_INCLUDED
 #include "aac_timestamp.h"
 #endif
 
 
-#define OMX_PORT_INPUTPORT_INDEX OMX_DirInput
-#define OMX_PORT_OUTPUTPORT_INDEX OMX_DirOutput
-#define OMX_PORT_ALLPORT_INDEX -1
-
-
 #define INPUT_BUFFER_SIZE_AAC 1536
 #define OUTPUT_BUFFER_SIZE_AAC 8192
 
 #define NUMBER_INPUT_BUFFER_AAC  10
-#define NUMBER_OUTPUT_BUFFER_AAC  2
+#define NUMBER_OUTPUT_BUFFER_AAC  9
 
 
-/* Application's private data */
-typedef struct AacPrivateType
-{
-    OMX_HANDLETYPE AacHandle;
-
-}AacPrivateType;
-
-
-/**
- * This is the Component template from which all
- * other Component instances are factored by the core.
- */
-
-
-/**
- * The structure for port Type.
- */
-typedef struct AacComponentPortType
-{
-    /** @param pBuffer An array of pointers to buffer headers. */
-    OMX_BUFFERHEADERTYPE** pBuffer;
-    /** @param BufferState The State of the Buffer whether assigned or allocated */
-    OMX_U32* BufferState;
-    /** @param NumAssignedBuffers Number of buffer assigned on each port */
-    OMX_U32 NumAssignedBuffers;
-    /** @param pBufferQueue queue for buffer to be processed by the port */
-    QueueType* pBufferQueue;
-    OMX_STATETYPE TransientState;
-    /** @param BufferUnderProcess  Boolean variables indicate whether the port is processing any buffer */
-    OMX_BOOL BufferUnderProcess;
-    OMX_PARAM_PORTDEFINITIONTYPE PortParam;
-    /** @param NumBufferFlushed Number of buffer Flushed */
-    OMX_U32 NumBufferFlushed;
-    /** @param IsPortFlushed Boolean variables indicate port is being flushed at the moment */
-    OMX_BOOL IsPortFlushed;
-
-    OMX_AUDIO_PARAM_PORTFORMATTYPE AudioParam;
-    OMX_AUDIO_PARAM_PCMMODETYPE AudioPcmMode;
-    OMX_AUDIO_PARAM_AACPROFILETYPE AudioAacParam;
-
-    //Added these flags as a replacement of semaphores on win32 platform
-    OMX_BOOL LoadedToIdleFlag ;
-    OMX_BOOL IdleToLoadedFlag ;
-
-} AacComponentPortType;
-
-
-class OpenmaxAacAO : public OsclActiveObject
+class OpenmaxAacAO : public OmxComponentAudio
 {
     public:
 
         OpenmaxAacAO();
         ~OpenmaxAacAO();
 
-        /** Component entry points declarations without proxy interface*/
-        static OMX_ERRORTYPE BaseComponentGetComponentVersion(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STRING pComponentName,
-            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
-            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
-            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
 
-        static OMX_ERRORTYPE BaseComponentGetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
 
-        static OMX_ERRORTYPE BaseComponentSetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+        void ProcessData();
+        void SyncWithInputTimestamp();
+        void ProcessInBufferFlag();
 
-        static OMX_ERRORTYPE BaseComponentGetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_INOUT OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentSetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentGetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        static OMX_ERRORTYPE BaseComponentGetState(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STATETYPE* pState);
-
-        static OMX_ERRORTYPE BaseComponentUseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentAllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        static OMX_ERRORTYPE BaseComponentFreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_U32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        static OMX_ERRORTYPE BaseComponentComponentDeInit(
-            OMX_IN  OMX_HANDLETYPE hComponent);
-
-        static OMX_ERRORTYPE BaseComponentEmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentFillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        static void AacComponentGetRolesOfComponent(OMX_STRING* aRoleString);
-
-        /*NON STATIC COUNTERPARTS OF STATIC MEMBER API'S */
-
-        OMX_ERRORTYPE GetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
-
-        OMX_ERRORTYPE SetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
-
+        void UpdateAACPlusFlag(OMX_BOOL aAacPlusFlag);
+        void ResetComponent();
         OMX_ERRORTYPE GetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE SetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        OMX_ERRORTYPE GetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        void GetState(OMX_OUT OMX_STATETYPE* pState);
-
-        OMX_ERRORTYPE UseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        OMX_ERRORTYPE AllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        OMX_ERRORTYPE FreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_S32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        OMX_ERRORTYPE EmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE FillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData);
-        OMX_ERRORTYPE DestroyComponent();
-
-        OMX_PTR GetOmxHandle()
-        {
-            return &iOmxComponent;
-        };
-
-        /*OTHER PROCESSING FUNCTIONS */
-
-        void AacComponentBufferMgmtFunction();
-        OMX_BOOL AacBufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE*);
-        void AacDecode();
-        OMX_BOOL AacComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer);
-
-        OMX_ERRORTYPE AacComponentMessageHandler(CoreMessage* Message);
-        OMX_ERRORTYPE AacComponentDoStateSet(OMX_U32);
-
-        OMX_ERRORTYPE AacComponentDisablePort(OMX_S32 PortIndex);
-        void AacComponentDisableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE AacComponentEnablePort(OMX_S32 PortIndex);
-        void AacComponentEnableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE AacComponentFlushPort(OMX_S32 PortIndex);
-        void AacComponentSetPortFlushFlag(OMX_S32, OMX_S32 index, OMX_BOOL value);
-        void AacComponentSetNumBufferFlush(OMX_S32, OMX_S32 index, OMX_S32 value);
-
-        OMX_S32 AacComponentPanic();
-
-        void AacComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, AacComponentPortType *pPort);
-        void AacComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, AacComponentPortType *pPort);
-
-        OMX_ERRORTYPE AacComponentInit();
-        OMX_ERRORTYPE AacComponentDeInit();
-
-        OMX_ERRORTYPE AacComponentTunnelRequest(
-            OMX_IN  OMX_HANDLETYPE hComp,
-            OMX_IN  OMX_U32 nPort,
-            OMX_IN  OMX_HANDLETYPE hTunneledComp,
-            OMX_IN  OMX_U32 nTunneledPort,
-            OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
-
-        OMX_ERRORTYPE BaseComponentParameterSanityCheck(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_PTR pStructure,
-            OMX_IN  size_t size);
-
-        void SetHeader(OMX_PTR aheader, OMX_U32 asize);
-        OMX_ERRORTYPE CheckHeader(OMX_PTR aheader, OMX_U32 asize);
-
-        //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-        OMX_BOOL			iBufferExecuteFlag;
-        AacPrivateType*	ipAppPriv;
-
 
     private:
 
-        PVLogger* iLogger;
-
-        void Run();
         void CheckForSilenceInsertion();
         void DoSilenceInsertion();
 
-        OMX_CALLBACKTYPE*	ipCallbacks;
-        OMX_PTR				iCallbackData;
-        OMX_STATETYPE		iState;
 
-        CoreDescriptorType* ipCoreDescriptor;
-        OMX_U32				iNumInputBuffer;
-
-        OMX_U8*				ipFrameDecodeBuffer;
-        OMX_BOOL			iPartialFrameAssembly;
-        OMX_BOOL			iIsInputBufferEnded;
-        OMX_BOOL			iEndofStream;
-        OMX_U8*				ipTempInputBuffer;
-        OMX_U32				iTempInputBufferLength;
-        OMX_COMPONENTTYPE*	ipTargetComponent;
-        OMX_PTR				iTargetMarkData;
-        OMX_BOOL			iNewInBufferRequired;
-        OMX_BOOL			iNewOutBufRequired;
-        OMX_U32				iTempConsumedLength;
-        OMX_U32				iOutBufferCount;
-        OMX_BOOL			iCodecReady;
-        OMX_U8*				ipInputCurrBuffer;
-        OMX_U32				iInputCurrLength;
-        OMX_S32				iFrameCount;
-        OMX_BOOL			iStateTransitionFlag;
-        OMX_BOOL			iFlushPortFlag;
-        OMX_BOOL				iEndOfFrameFlag;
-        OMX_BUFFERHEADERTYPE*	ipAacInputBuffer;
-        OMX_BUFFERHEADERTYPE*	ipAacOutputBuffer;
-
-        OMX_U32					iOutputFrameLength;
-
-        OMX_COMPONENTTYPE iOmxComponent;	// structure
-        OMX_U32			iNumPorts;
-
-        PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
-
-        //The ports of the component
-        AacComponentPortType** ipPorts;
-        //Indicate whether component has been already initialized */
-        OMX_BOOL iIsInit;
-        //OpenMAX standard parameter that contains a short description of the available ports
-        OMX_PORT_PARAM_TYPE iPortTypesParam;
-        OMX_U32 iGroupPriority;
-        //ID of a group of components that share the same logical chain
-        OMX_U32 iGroupID;
-        //Roles of the component
-        OMX_U8 iComponentRole[OMX_MAX_STRINGNAME_SIZE];
-        //This field holds the private data associated with a mark request, if any
-        OMX_MARKTYPE* ipMark;
-
-        OMX_BOOL				iFirstFragment;
-        OMX_TICKS				iFrameTimestamp;
-        AacTimeStampCalc		iCurrentFrameTS;
-        OMX_BOOL				iRepositionFlag;
-        OMX_S32					iSamplesPerFrame;
-        OMX_BOOL				iResizePending;
-        OMX_BOOL				iSilenceInsertionInProgress;
-        OMX_U32					iSilenceFramesNeeded;
-        OMX_U32					iOutputMilliSecPerFrame;
-
-
-        //Aac specific structure
-
+        AacTimeStampCalc iCurrentFrameTS;
         OmxAacDecoder* ipAacDec;
 };
 
diff --git a/codecs_v2/omx/omx_aac/src/aac_decode_frame.cpp b/codecs_v2/omx/omx_aac/src/aac_decode_frame.cpp
index 31b28d9..9ff292b 100644
--- a/codecs_v2/omx/omx_aac/src/aac_decode_frame.cpp
+++ b/codecs_v2/omx/omx_aac/src/aac_decode_frame.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,6 +58,7 @@
 void OmxAacDecoder::AacDecDeinit()
 {
     oscl_free(ipMem);
+    ipMem = NULL;
 }
 
 void OmxAacDecoder::ResetDecoder()
@@ -75,12 +76,11 @@
                                    OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer,
                                    OMX_AUDIO_PARAM_PCMMODETYPE* aAudioPcmParam,
                                    OMX_AUDIO_PARAM_AACPROFILETYPE* aAudioAacParam,
-                                   OMX_S32* aSamplesPerFrame,
+                                   OMX_U32* aSamplesPerFrame,
                                    OMX_BOOL* aResizeFlag)
 {
     Int   Status;
     Int32 StreamType;
-    static Int32 ConfigUpSamplingFactor;
 
 
     *aResizeFlag = OMX_FALSE;
@@ -121,10 +121,13 @@
     //Decode the config buffer
     if (0 == iAacInitFlag)
     {
-        iAacInitFlag = 1;
         Status = PVMP4AudioDecoderConfig(&iExt, ipMem);
+        if (MP4AUDEC_SUCCESS == Status)
+        {
+            iAacInitFlag = 1;
+        }
 
-        ConfigUpSamplingFactor = iExt.aacPlusUpsamplingFactor;
+        iConfigUpSamplingFactor = iExt.aacPlusUpsamplingFactor;
 
         if (2 == iExt.aacPlusUpsamplingFactor)
         {
@@ -185,11 +188,12 @@
         {
             StreamType = (Int32) RetrieveDecodedStreamType();
 
-            if ((0 == StreamType) && (2 == ConfigUpSamplingFactor))
+            if ((0 == StreamType) && (2 == iConfigUpSamplingFactor))
             {
                 PVMP4AudioDecoderDisableAacPlus(&iExt, &ipMem);
                 *aSamplesPerFrame = AACDEC_PCM_FRAME_SAMPLE_SIZE;
                 aAudioAacParam->eAACProfile = OMX_AUDIO_AACObjectMain;
+                aAudioAacParam->nFrameLength = AACDEC_PCM_FRAME_SAMPLE_SIZE;
             }
 
             //Output Port Parameters
@@ -221,7 +225,7 @@
 }
 
 
-
+//Retrieve the Stream Type of AAC input-bitstream
 Int OmxAacDecoder::RetrieveDecodedStreamType()
 {
 
@@ -242,8 +246,10 @@
     return -1;   /*  Error evaluating the stream type */
 }
 
+
+//Change the AACEnable flag, according to the AAC profile set by the client in SetParameter API
 void OmxAacDecoder::UpdateAACPlusEnabled(OMX_BOOL flag)
 {
     //Mark this flag as false if client sets any non HE AAC profile in SetParameter call
-    iExt.aacPlusEnabled = flag;
+    iExt.aacPlusEnabled = (OMX_TRUE == flag) ? true : false;
 }
diff --git a/codecs_v2/omx/omx_aac/src/aac_timestamp.cpp b/codecs_v2/omx/omx_aac/src/aac_timestamp.cpp
index bbf28e4..7dbeeb9 100644
--- a/codecs_v2/omx/omx_aac/src/aac_timestamp.cpp
+++ b/codecs_v2/omx/omx_aac/src/aac_timestamp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/omx/omx_aac/src/omx_aac_component.cpp b/codecs_v2/omx/omx_aac/src/omx_aac_component.cpp
index 66f782a..dc981a5 100644
--- a/codecs_v2/omx/omx_aac/src/omx_aac_component.cpp
+++ b/codecs_v2/omx/omx_aac/src/omx_aac_component.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,19 +15,18 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#include "oscl_base.h"
 #include "pv_omxdefs.h"
-#include "oscl_types.h"
 
-#include <string.h>
 #include "omx_aac_component.h"
 
-extern OMX_U32 g_ComponentIndex; // this is determined outside the component
-
 #if PROXY_INTERFACE
-
 #include "omx_proxy_interface.h"
-extern ProxyApplication_OMX* pProxyTerm[];
+#endif
 
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
 #endif
 
 #define OMX_HALFRANGE_THRESHOLD 0x7FFFFFFF
@@ -35,12 +34,20 @@
 #define AAC_MONO_SILENCE_FRAME_SIZE 10
 #define AAC_STEREO_SILENCE_FRAME_SIZE 11
 
-static const OMX_U8 AAC_MONO_SILENCE_FRAME[]   = {0x01, 0x40, 0x20, 0x06, 0x4F, 0xDE, 0x02, 0x70, 0x0C, 0x1C};		// 10 bytes
+static const OMX_U8 AAC_MONO_SILENCE_FRAME[]   = {0x01, 0x40, 0x20, 0x06, 0x4F, 0xDE, 0x02, 0x70, 0x0C, 0x1C};      // 10 bytes
 static const OMX_U8 AAC_STEREO_SILENCE_FRAME[] = {0x21, 0x10, 0x05, 0x00, 0xA0, 0x19, 0x33, 0x87, 0xC0, 0x00, 0x7E}; // 11 bytes)
 
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
 // This function is called by OMX_GetHandle and it creates an instance of the aac component AO
-OMX_ERRORTYPE AacOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
+OSCL_EXPORT_REF OMX_ERRORTYPE AacOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     OpenmaxAacAO* pOpenmaxAOType;
     OMX_ERRORTYPE Status;
 
@@ -54,7 +61,7 @@
     }
 
     //Call the construct component to initialize OMX types
-    Status = pOpenmaxAOType->ConstructComponent(pAppData);
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
 
     *pHandle = pOpenmaxAOType->GetOmxHandle();
 
@@ -63,8 +70,12 @@
 }
 
 // This function is called by OMX_FreeHandle when component AO needs to be destroyed
-OMX_ERRORTYPE AacOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle)
+OSCL_EXPORT_REF OMX_ERRORTYPE AacOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     // get pointer to component AO
     OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
 
@@ -77,35 +88,86 @@
     return OMX_ErrorNone;
 }
 
+#if DYNAMIC_LOAD_OMX_AAC_COMPONENT
+class AacOmxSharedLibraryInterface: public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static AacOmxSharedLibraryInterface *Instance()
+        {
+            static AacOmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_AACDEC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AacOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AacOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        AacOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return AacOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-OMX_ERRORTYPE OpenmaxAacAO::ConstructComponent(OMX_PTR pAppData)
+OMX_ERRORTYPE OpenmaxAacAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
 {
-    AacComponentPortType* pInPort, *pOutPort;
-    OMX_U32 ii;
+    ComponentPortType* pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
 
     iNumPorts = 2;
     iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
     iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
     iOmxComponent.pApplicationPrivate = pAppData; // init the App data
 
 
 #if PROXY_INTERFACE
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
 
-    iOmxComponent.SendCommand = WrapperSendCommand;
-    iOmxComponent.GetParameter = WrapperGetParameter;
-    iOmxComponent.SetParameter = WrapperSetParameter;
-    iOmxComponent.GetConfig = WrapperGetConfig;
-    iOmxComponent.SetConfig = WrapperSetConfig;
-    iOmxComponent.GetExtensionIndex = WrapperGetExtensionIndex;
-    iOmxComponent.GetState = WrapperGetState;
-    iOmxComponent.UseBuffer = WrapperUseBuffer;
-    iOmxComponent.AllocateBuffer = WrapperAllocateBuffer;
-    iOmxComponent.FreeBuffer = WrapperFreeBuffer;
-    iOmxComponent.EmptyThisBuffer = WrapperEmptyThisBuffer;
-    iOmxComponent.FillThisBuffer = WrapperFillThisBuffer;
+    iOmxComponent.SendCommand = OpenmaxAacAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OpenmaxAacAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OpenmaxAacAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OpenmaxAacAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OpenmaxAacAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OpenmaxAacAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OpenmaxAacAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OpenmaxAacAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OpenmaxAacAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OpenmaxAacAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OpenmaxAacAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OpenmaxAacAO::BaseComponentProxyFillThisBuffer;
 
 #else
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
@@ -134,6 +196,9 @@
     iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
 
     if (ipAppPriv)
     {
@@ -141,60 +206,23 @@
         ipAppPriv = NULL;
     }
 
-    ipAppPriv = (AacPrivateType*) oscl_malloc(sizeof(AacPrivateType));
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
     if (NULL == ipAppPriv)
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    if (iNumPorts)
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
     {
-        if (ipPorts)
-        {
-            oscl_free(ipPorts);
-            ipPorts = NULL;
-        }
-
-        ipPorts = (AacComponentPortType**) oscl_calloc(iNumPorts, sizeof(AacComponentPortType*));
-        if (!ipPorts)
-        {
-            return OMX_ErrorInsufficientResources;
-        }
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii] = (AacComponentPortType*) oscl_calloc(1, sizeof(AacComponentPortType));
-            if (!ipPorts[ii])
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            ipPorts[ii]->TransientState = OMX_StateMax;
-            SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            ipPorts[ii]->PortParam.nPortIndex = ii;
-
-            /** Allocate and initialize buffer Queue */
-            ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-
-            if (NULL == ipPorts[ii]->pBufferQueue)
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            QueueInit(ipPorts[ii]->pBufferQueue);
-
-            ipPorts[ii]->LoadedToIdleFlag = OMX_FALSE;
-            ipPorts[ii]->IdleToLoadedFlag = OMX_FALSE;
-
-        }
-
-        AacComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-        AacComponentSetNumBufferFlush(iNumPorts, -1, OMX_FALSE);
+        return Status;
     }
 
     /** Domain specific section for the ports. */
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
-    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = "audio/mpeg";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"audio/mpeg";
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
@@ -208,7 +236,7 @@
 
 
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
-    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = "raw";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"raw";
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
@@ -227,7 +255,7 @@
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.nAudioBandWidth = 0;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.nFrameLength = 2048; // use HE_PS frame size as default
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.eChannelMode = OMX_AUDIO_ChannelModeStereo;
-    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.eAACProfile = OMX_AUDIO_AACObjectHE_PS;	//OMX_AUDIO_AACObjectLC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.eAACProfile = OMX_AUDIO_AACObjectHE_PS;    //OMX_AUDIO_AACObjectLC;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS;
 
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nChannels = 2;
@@ -242,8 +270,8 @@
     iPortTypesParam.nPorts = 2;
     iPortTypesParam.nStartPortNumber = 0;
 
-    pInPort = (AacComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    pOutPort = (AacComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
     SetHeader(&pInPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
     pInPort->AudioParam.nPortIndex = 0;
@@ -255,59 +283,7 @@
     pOutPort->AudioParam.nIndex = 0;
     pOutPort->AudioParam.eEncoding = OMX_AUDIO_CodingPCM;
 
-    iCodecReady = OMX_FALSE;
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-    ipTempInputBuffer = NULL;
-    iTempInputBufferLength = 0;
-    iNumInputBuffer = 0;
-    iPartialFrameAssembly = OMX_FALSE;
-    iEndofStream = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iNewOutBufRequired = OMX_TRUE;
     iOutputFrameLength = OUTPUT_BUFFER_SIZE_AAC;
-    iRepositionFlag = OMX_FALSE;
-
-    /* Initialize the asynchronous command Queue */
-    if (ipCoreDescriptor)
-    {
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType));
-    if (NULL == ipCoreDescriptor)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    ipCoreDescriptor->pMessageQueue = NULL;
-    ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-    if (NULL == ipCoreDescriptor->pMessageQueue)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    QueueInit(ipCoreDescriptor->pMessageQueue);
-
-    /** Default parameters setting */
-    iIsInit = OMX_FALSE;
-    iGroupPriority = 0;
-    iGroupID = 0;
-    ipMark = NULL;
-
-    SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-
-    iOutBufferCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    iFirstFragment = OMX_FALSE;
-
-    //Will be used in case of partial frame assembly
-    ipInputCurrBuffer = NULL;
-    ipAppPriv->AacHandle = &iOmxComponent;
 
     if (ipAacDec)
     {
@@ -328,476 +304,110 @@
 
 #if PROXY_INTERFACE
 
-    pProxyTerm[g_ComponentIndex]->ComponentSendCommand = BaseComponentSendCommand;
-    pProxyTerm[g_ComponentIndex]->ComponentGetParameter = BaseComponentGetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentSetParameter = BaseComponentSetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentGetConfig = BaseComponentGetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentSetConfig = BaseComponentSetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
-    pProxyTerm[g_ComponentIndex]->ComponentGetState = BaseComponentGetState;
-    pProxyTerm[g_ComponentIndex]->ComponentUseBuffer = BaseComponentUseBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFreeBuffer = BaseComponentFreeBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
 
 #endif
     return OMX_ErrorNone;
 }
 
 
-/*********************
- *
- * Component verfication routines
- *
- **********************/
+/** This function is called by the omx core when the component
+    * is disposed by the IL client with a call to FreeHandle().
+    */
 
-void OpenmaxAacAO::SetHeader(OMX_PTR aHeader, OMX_U32 aSize)
+OMX_ERRORTYPE OpenmaxAacAO::DestroyComponent()
 {
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-    *((OMX_U32*) aHeader) = aSize;
-
-    pVersion->s.nVersionMajor = SPECVERSIONMAJOR;
-    pVersion->s.nVersionMinor = SPECVERSIONMINOR;
-    pVersion->s.nRevision = SPECREVISION;
-    pVersion->s.nStep = SPECSTEP;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize)
-{
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-
-    if (NULL == aHeader)
+    if (iIsInit != OMX_FALSE)
     {
-        return OMX_ErrorBadParameter;
+        ComponentDeInit();
     }
 
-    if (*((OMX_U32*) aHeader) != aSize)
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipAacDec)
     {
-        return OMX_ErrorBadParameter;
+        OSCL_DELETE(ipAacDec);
+        ipAacDec = NULL;
     }
 
-    if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR ||
-            pVersion->s.nVersionMinor != SPECVERSIONMINOR ||
-            pVersion->s.nRevision != SPECREVISION ||
-            pVersion->s.nStep != SPECSTEP)
+    if (ipAppPriv)
     {
-        return OMX_ErrorVersionMismatch;
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
     }
 
     return OMX_ErrorNone;
-}
-
-
-/**
- * This function verify component state and structure header
- */
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentParameterSanityCheck(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_PTR pStructure,
-    OMX_IN  size_t size)
-{
-
-    if (iState != OMX_StateLoaded &&
-            iState != OMX_StateWaitForResources)
-    {
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if (nPortIndex >= iNumPorts)
-    {
-        return OMX_ErrorBadPortIndex;
-    }
-
-    return CheckHeader(pStructure, size);
-}
-
-/**
- * Set/Reset Port Flush Flag
- */
-void OpenmaxAacAO::AacComponentSetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    {
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->IsPortFlushed = value;
-    }
 
 }
 
-/**
- * Set Number of Buffer Flushed with the value Specified
- */
-void OpenmaxAacAO::AacComponentSetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value)
+
+/* This routine will extract the input timestamp, verify whether silence insertion
+ * is required or not and also handle the various tasks associated with repositioning */
+void OpenmaxAacAO::SyncWithInputTimestamp()
 {
-    OMX_S32 ii;
-
-    if (-1 == index)
-    { // For all ComponentPort
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->NumBufferFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->NumBufferFlushed = value;
-    }
-}
-
-
-/** This function assembles multiple input buffers into
-	* one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set
-	*/
-
-OMX_BOOL OpenmaxAacAO::AacComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentAssemblePartialFrames IN"));
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    AacComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-    ipAacInputBuffer = aInputBuffer;
-
-    if (!iPartialFrameAssembly)
-    {
-        if (iNumInputBuffer > 0)
-        {
-            if (ipAacInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-            {
-                iInputCurrLength = ipAacInputBuffer->nFilledLen;
-                ipFrameDecodeBuffer = ipAacInputBuffer->pBuffer + ipAacInputBuffer->nOffset;
-                //capture the timestamp to be send to the corresponding output buffer
-                iFrameTimestamp = ipAacInputBuffer->nTimeStamp;
-            }
-            else
-            {
-                iInputCurrLength = 0;
-                iPartialFrameAssembly = OMX_TRUE;
-                iFirstFragment = OMX_TRUE;
-                iFrameTimestamp = ipAacInputBuffer->nTimeStamp;
-                ipFrameDecodeBuffer = ipInputCurrBuffer;
-            }
-
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentAssemblePartialFrames ERROR"));
-            return OMX_FALSE;
-        }
-
-    }
-
-    //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked
-    if (iPartialFrameAssembly)
-    {
-        while (iNumInputBuffer > 0)
-        {
-            if (OMX_FALSE == iFirstFragment)
-            {
-                /* If the timestamp of curr fragment doesn't match with previous,
-                 * discard the previous fragments & start reconstructing from new
-                 */
-                if (iFrameTimestamp != ipAacInputBuffer->nTimeStamp)
-                {
-                    iInputCurrLength = 0;
-                    iPartialFrameAssembly = OMX_TRUE;
-                    iFirstFragment = OMX_TRUE;
-                    iFrameTimestamp = ipAacInputBuffer->nTimeStamp;
-                    ipFrameDecodeBuffer = ipInputCurrBuffer;
-                }
-            }
-
-            if ((ipAacInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
-            {
-                break;
-            }
-
-            iInputCurrLength += ipAacInputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAacInputBuffer->pBuffer + ipAacInputBuffer->nOffset), ipAacInputBuffer->nFilledLen); // copy buffer data
-            ipFrameDecodeBuffer += ipAacInputBuffer->nFilledLen; // move the ptr
-
-            ipAacInputBuffer->nFilledLen = 0;
-
-            AacComponentReturnInputBuffer(ipAacInputBuffer, pInPort);
-
-            iFirstFragment = OMX_FALSE;
-
-            if (iNumInputBuffer > 0)
-            {
-                ipAacInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (ipAacInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentAssemblePartialFrames EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers
-        if (0 == iNumInputBuffer)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentAssemblePartialFrames OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            // we have found the buffer that is the last piece of the frame.
-            // Copy the buffer, but do not release it yet (this will be done after decoding for consistency)
-
-            iInputCurrLength += ipAacInputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAacInputBuffer->pBuffer + ipAacInputBuffer->nOffset), ipAacInputBuffer->nFilledLen); // copy buffer data
-            ipFrameDecodeBuffer += ipAacInputBuffer->nFilledLen; // move the ptr
-
-            ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer
-            iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentAssemblePartialFrames OUT"));
-    return OMX_TRUE;
-}
-
-
-/** This is the central function for buffers processing and decoding.
-	* It is called through the Run() of active object when the component is in executing state
-	* and is signalled each time a new buffer is available on the given ports
-	* This function will process the input buffers & return output buffers
-	*/
-
-void OpenmaxAacAO::AacComponentBufferMgmtFunction()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentBufferMgmtFunction IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    AacComponentPortType* pInPort = (AacComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-    OMX_BOOL PartialFrameReturn, Status;
     OMX_AUDIO_AACSTREAMFORMATTYPE InFormat = ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.eAACStreamFormat;
 
-    /* Don't dequeue any further buffer after endofstream buffer has been dequeued
-     * till we send the callback and reset the flag back to false
-     */
-    if (OMX_FALSE == iEndofStream)
+    //Do not check for silence insertion if the clip is repositioned
+    if (OMX_FALSE == iRepositionFlag)
     {
-        //More than one frame can't be dequeued in case of outbut blocked
-        if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
+        CheckForSilenceInsertion();
+    }
+
+
+    /* Set the current timestamp equal to input buffer timestamp in case of
+     * a) first frame for ADIF format
+     * b) All input frames for other formats
+     * c) First frame after repositioning */
+    if (OMX_FALSE == iSilenceInsertionInProgress)
+    {
+        if ((0 == iFrameCount) || (iFrameCount > 0 && OMX_AUDIO_AACStreamFormatADIF != InFormat)
+                || (OMX_TRUE == iRepositionFlag))
         {
-            ipAacInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
+            iCurrentFrameTS.SetFromInputTimestamp(iFrameTimestamp);
 
-            if (ipAacInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
+            //Reset the flag back to false, once timestamp has been updated from input frame
+            if (OMX_TRUE == iRepositionFlag)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentBufferMgmtFunction EndOfStream arrived"));
-                iEndofStream = OMX_TRUE;
+                iRepositionFlag = OMX_FALSE;
             }
+        }
+    }
+}
 
-            if (ipAacInputBuffer->nFilledLen != 0)
-            {
-                if (0 == iFrameCount)
-                {
-                    //Set the marker flag (iEndOfFrameFlag) if first frame has the EndOfFrame flag marked.
-                    if (ipAacInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentBufferMgmtFunction EndOfFrame flag present"));
-                        iEndOfFrameFlag = OMX_TRUE;
-                    }
-                    //Get the initial default value for the milli seconds per frame
-                    iOutputMilliSecPerFrame = iCurrentFrameTS.GetFrameDuration();
-                }
-
-                /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is
-                 *  not marked in all the input buffers
-                 */
-                if (!iEndOfFrameFlag)
-                {
-                    Status = AacBufferMgmtWithoutMarker(ipAacInputBuffer);
-                    if (OMX_FALSE == Status)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-
-                }
-                //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here
-                else
-                {
-                    PartialFrameReturn = AacComponentAssemblePartialFrames(ipAacInputBuffer);
-                    if (OMX_FALSE == PartialFrameReturn)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-                    iIsInputBufferEnded = OMX_FALSE;
-                }
-
-                ipTargetComponent = (OMX_COMPONENTTYPE*) ipAacInputBuffer->hMarkTargetComponent;
-
-                iTargetMarkData = ipAacInputBuffer->pMarkData;
-                if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventMark,
-                     1,
-                     0,
-                     ipAacInputBuffer->pMarkData);
-                }
-
-                //Do not check for silence insertion if the clip is repositioned
-                if (OMX_FALSE == iRepositionFlag)
-                {
-                    CheckForSilenceInsertion();
-                }
-
-
-                /* Set the current timestamp equal to input buffer timestamp in case of
-                 * a) first frame for ADIF format
-                 * b) All input frames for other formats
-                 * c) First frame after repositioning */
-                if (OMX_FALSE == iSilenceInsertionInProgress)
-                {
-                    if ((0 == iFrameCount) || (iFrameCount > 0 && OMX_AUDIO_AACStreamFormatADIF != InFormat)
-                            || (OMX_TRUE == iRepositionFlag))
-                    {
-                        iCurrentFrameTS.SetFromInputTimestamp(iFrameTimestamp);
-
-                        //Reset the flag back to false, once timestamp has been updated from input frame
-                        if (OMX_TRUE == iRepositionFlag)
-                        {
-                            iRepositionFlag = OMX_FALSE;
-                        }
-                    }
-                }
-
-            }	//end braces for if (ipAacInputBuffer->nFilledLen != 0)
-            else
-            {
-                AacComponentReturnInputBuffer(ipAacInputBuffer, pInPort);
-            }
-
-        }	//end braces for if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
-    }	//if (OMX_FALSE == iEndofStream)
-
-    AacDecode();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentBufferMgmtFunction OUT"));
-    return;
+/* A component specific routine called from BufferMgmtWithoutMarker */
+void OpenmaxAacAO::ProcessInBufferFlag()
+{
+    iIsInputBufferEnded = OMX_FALSE;
 }
 
 
-OMX_BOOL OpenmaxAacAO::AacBufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE* pAacInputBuffer)
+void OpenmaxAacAO::ProcessData()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacBufferMgmtWithoutMarker IN"));
-
-    AacComponentPortType*	pInPort = (AacComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    ipAacInputBuffer = pAacInputBuffer;
-
-    /* Assembling of partial frame will be done based on max input buf size
-     * If Flushport flag is true, that means its not a partial frame
-     * but an unconsumed frame, process it independently
-     * Same is true for endofstream condition, process the buffer independently
-     */
-    if ((ipAacInputBuffer->nFilledLen < ipAacInputBuffer->nAllocLen)
-            && (iEndofStream != OMX_TRUE) && (OMX_FALSE == iFlushPortFlag))
-    {
-        if (!iPartialFrameAssembly)
-        {
-            iInputCurrLength = 0;
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-        }
-
-        while (iNumInputBuffer > 0)
-        {
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAacInputBuffer->pBuffer + ipAacInputBuffer->nOffset), ipAacInputBuffer->nFilledLen);
-            ipFrameDecodeBuffer += ipAacInputBuffer->nFilledLen; // move the ptr
-
-            iFrameTimestamp = ipAacInputBuffer->nTimeStamp;
-
-            if (((iInputCurrLength += ipAacInputBuffer->nFilledLen) >= ipAacInputBuffer->nAllocLen)
-                    || OMX_TRUE == iEndofStream)
-            {
-                break;
-            }
-
-            //Set the filled len to zero to indiacte buffer is fully consumed
-            ipAacInputBuffer->nFilledLen = 0;
-            AacComponentReturnInputBuffer(ipAacInputBuffer, pInPort);
-
-            if (iNumInputBuffer > 0)
-            {
-                ipAacInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (ipAacInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacBufferMgmtWithoutMarker EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        if (((iInputCurrLength < ipAacInputBuffer->nAllocLen)) && OMX_TRUE != iEndofStream)
-        {
-            iPartialFrameAssembly = OMX_TRUE;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacBufferMgmtWithoutMarker OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-            iPartialFrameAssembly = OMX_FALSE;
-            iIsInputBufferEnded = OMX_FALSE;
-        }
-    }
-    else
-    {
-        if (iNumInputBuffer > 0)
-        {
-            iInputCurrLength = ipAacInputBuffer->nFilledLen;
-            ipFrameDecodeBuffer = ipAacInputBuffer->pBuffer + ipAacInputBuffer->nOffset;
-            iFrameTimestamp = ipAacInputBuffer->nTimeStamp;
-            iIsInputBufferEnded = OMX_FALSE;
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacBufferMgmtWithoutMarker OUT"));
-            return OMX_FALSE; // nothing to decode
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacBufferMgmtWithoutMarker OUT"));
-    return OMX_TRUE;
-
-}
-
-
-void OpenmaxAacAO::AacDecode()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacDecodeWithoutMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData IN"));
 
     QueueType* pInputQueue  = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
 
-    AacComponentPortType* pInPort = (AacComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    AacComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
     OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
 
-    OMX_U8*	pOutBuffer;
-    OMX_U32	OutputLength;
+    OMX_U8* pOutBuffer;
+    OMX_U32 OutputLength;
     OMX_S32 DecodeReturn;
     OMX_BOOL ResizeNeeded = OMX_FALSE;
 
@@ -822,38 +432,100 @@
             //Check whether a new output buffer is available or not
             if (0 == (GetQueueNumElem(pOutputQueue)))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacDecodeWithoutMarker OUT output buffer unavailable"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData OUT output buffer unavailable"));
                 return;
             }
 
-            ipAacOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipAacOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData Error, output buffer dequeue returned NULL, OUT"));
+                return;
+            }
+
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipAacOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+            ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+
+            // Copy the output buffer that was stored locally before dynamic port reconfiguration
+            // in the new omx buffer received.
+
+            if (OMX_TRUE == iSendOutBufferAfterPortReconfigFlag)
+            {
+                if ((ipTempOutBufferForPortReconfig)
+                        && (iSizeOutBufferForPortReconfig <= ipOutputBuffer->nAllocLen))
+                {
+                    oscl_memcpy(ipOutputBuffer->pBuffer, ipTempOutBufferForPortReconfig, iSizeOutBufferForPortReconfig);
+                    ipOutputBuffer->nFilledLen = iSizeOutBufferForPortReconfig;
+                    ipOutputBuffer->nTimeStamp = iTimestampOutBufferForPortReconfig;
+                }
+
+                iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
+
+                //Send the output buffer back only when it has become full
+
+                if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
+                {
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                }
+
+
+                //Free the temp output buffer
+
+                if (ipTempOutBufferForPortReconfig)
+                {
+                    oscl_free(ipTempOutBufferForPortReconfig);
+                    ipTempOutBufferForPortReconfig = NULL;
+                    iSizeOutBufferForPortReconfig = 0;
+                }
+
+                //Dequeue new output buffer to continue decoding the next frame
+
+                if (OMX_TRUE == iNewOutBufRequired)
+                {
+                    if (0 == (GetQueueNumElem(pOutputQueue)))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData OUT, output buffer unavailable"));
+                        return;
+                    }
+
+                    ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+                    if (NULL == ipOutputBuffer)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData Error, output buffer dequeue returned NULL, OUT"));
+                        return;
+                    }
+
+                    ipOutputBuffer->nFilledLen = 0;
+                    iNewOutBufRequired = OMX_FALSE;
+                    ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+                }
+            }
         }
 
+
         /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
          * command and hMarkTargetComponent as given by the specifications
          */
         if (ipMark != NULL)
         {
-            ipAacOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipAacOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if (ipTargetComponent != NULL)
         {
-            ipAacOutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipAacOutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
 
         }
         //Mark buffer code ends here
 
-        pOutBuffer = &ipAacOutputBuffer->pBuffer[ipAacOutputBuffer->nFilledLen];
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
         OutputLength = 0;
 
         /* Copy the left-over data from last input buffer that is stored in temporary
@@ -892,17 +564,42 @@
 
                 iCurrentFrameTS.SetParameters(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nSamplingRate, iSamplesPerFrame);
                 iOutputMilliSecPerFrame = iCurrentFrameTS.GetFrameDuration();
-                //Set the current timestamp to the output buffer timestamp for the first output frame
-                //Later it will be done at the time of dequeue
-                //(reason here is that at the time of dequeue, output buffer timestamp was equal to timestamp of config input buffer, not the first input buffer)
-                ipAacOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+
             }
 
-            // send port settings changed event
-            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->AacHandle;
-
+            // set the flag to disable further processing until Client reacts to this
+            //  by doing dynamic port reconfiguration
             iResizePending = OMX_TRUE;
 
+            /* Do not return the output buffer generated yet, store it locally
+             * and wait for the dynamic port reconfig to complete */
+
+            if ((NULL == ipTempOutBufferForPortReconfig))
+            {
+                ipTempOutBufferForPortReconfig = (OMX_U8*) oscl_malloc(sizeof(uint8) * OutputLength * 2);
+                if (NULL == ipTempOutBufferForPortReconfig)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData error, insufficient resources"));
+                    return;
+                }
+            }
+
+            //Copy the omx output buffer to the temporary internal buffer
+            oscl_memcpy(ipTempOutBufferForPortReconfig, pOutBuffer, OutputLength * 2);
+            iSizeOutBufferForPortReconfig = OutputLength * 2;
+
+            //Set the current timestamp to the output buffer timestamp for the first output frame, Later it will be done at the time of dequeue
+            //(reason here is that at the time of dequeue, output buffer timestamp was equal to timestamp of config input buffer, not the first input buffer)
+            iTimestampOutBufferForPortReconfig = iCurrentFrameTS.GetConvertedTs();
+
+            iCurrentFrameTS.UpdateTimestamp(iSamplesPerFrame);
+            //Make this length 0 so that no output buffer is returned by the component
+            OutputLength = 0;
+
+
+            // send port settings changed event
+            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
+
             (*(ipCallbacks->EventHandler))
             (pHandle,
              iCallbackData,
@@ -914,9 +611,9 @@
 
 
         //Output length for a buffer of OMX_U8* will be double as that of OMX_S16*
-        ipAacOutputBuffer->nFilledLen += OutputLength * 2;
+        ipOutputBuffer->nFilledLen += OutputLength * 2;
         //offset not required in our case, set it to zero
-        ipAacOutputBuffer->nOffset = 0;
+        ipOutputBuffer->nOffset = 0;
 
         if (OutputLength > 0)
         {
@@ -930,7 +627,7 @@
         {
             if ((0 == iInputCurrLength) || (MP4AUDEC_SUCCESS != DecodeReturn))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacDecodeWithoutMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -942,10 +639,12 @@
 
                 iEndofStream = OMX_FALSE;
 
-                ipAacOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
 
-                AacComponentReturnOutputBuffer(ipAacOutputBuffer, pOutPort);
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacDecodeWithoutMarker OUT"));
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData OUT"));
 
                 return;
             }
@@ -954,7 +653,7 @@
 
         if (MP4AUDEC_SUCCESS == DecodeReturn)
         {
-            ipAacInputBuffer->nFilledLen = iInputCurrLength;
+            ipInputBuffer->nFilledLen = iInputCurrLength;
         }
         else if (MP4AUDEC_INCOMPLETE_FRAME == DecodeReturn)
         {
@@ -962,519 +661,112 @@
              * this indicates the input buffer contains less than a frame data that
              * can't be processed by the decoder.
              * Copy it to a temp buffer to be used in next decode call
+             * buffers can be overlapping, use memmove() instead of memcpy()
              */
-            oscl_memcpy(ipTempInputBuffer, ipFrameDecodeBuffer, iInputCurrLength);
+            oscl_memmove(ipTempInputBuffer, ipFrameDecodeBuffer, iInputCurrLength);
             iTempInputBufferLength = iInputCurrLength;
-            ipAacInputBuffer->nFilledLen = 0;
+            ipInputBuffer->nFilledLen = 0;
             iInputCurrLength = 0;
         }
         else
         {
+            OMX_U32 error = OMX_ErrorStreamCorrupt;
+            if (ipAacDec->iAacInitFlag == 0)
+            {
+                // If first frame, it means that the config has an issue.
+                error = OMX_ErrorBadParameter;
+            }
             //bitstream error, discard the current data as it can't be decoded further
-            ipAacInputBuffer->nFilledLen = 0;
+            ipInputBuffer->nFilledLen = 0;
+            iInputCurrLength = 0;
 
             //Report it to the client via a callback
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacDecodeWithoutMarker ErrorStreamCorrupt callback send"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData ErrorStreamCorrupt callback send"));
 
             (*(ipCallbacks->EventHandler))
             (pHandle,
              iCallbackData,
              OMX_EventError,
-             OMX_ErrorStreamCorrupt,
+             error,
              0,
              NULL);
 
         }
 
         //Return the input buffer if it has been consumed fully by the decoder
-        if (0 == ipAacInputBuffer->nFilledLen)
+        if (0 == ipInputBuffer->nFilledLen)
         {
-            AacComponentReturnInputBuffer(ipAacInputBuffer, pInPort);
+            ReturnInputBuffer(ipInputBuffer, pInPort);
             iIsInputBufferEnded = OMX_TRUE;
+            iInputCurrLength = 0;
+            ipInputBuffer = NULL;
         }
 
         //Send the output buffer back when it has become full
-        if (((ipAacOutputBuffer->nAllocLen - ipAacOutputBuffer->nFilledLen) < (iOutputFrameLength))
-                || (OMX_TRUE == ResizeNeeded))
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < (iOutputFrameLength))
         {
-            AacComponentReturnOutputBuffer(ipAacOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         /* If there is some more processing left with current buffers, re-schedule the AO
          * Do not go for more than one round of processing at a time.
          * This may block the AO longer than required.
          */
-        if ((ipAacInputBuffer->nFilledLen != 0 || GetQueueNumElem(pInputQueue) > 0)
-                && (GetQueueNumElem(pOutputQueue) > 0) || (OMX_FALSE == iNewOutBufRequired)
+        if (((iInputCurrLength != 0) || (GetQueueNumElem(pInputQueue) > 0))
+                && ((GetQueueNumElem(pOutputQueue) > 0) || (OMX_FALSE == iNewOutBufRequired))
                 && (ResizeNeeded == OMX_FALSE))
         {
             RunIfNotReady();
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacDecodeWithoutMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ProcessData OUT"));
     return;
 }
 
-void OpenmaxAacAO::AacComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pAacInputBuffer, AacComponentPortType *pPort)
+
+/* This routine will reset the decoder library and some of the associated flags*/
+void OpenmaxAacAO::ResetComponent()
 {
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    if (iNumInputBuffer)
-    {
-        iNumInputBuffer--;
-    }
-
-    //Callback for releasing the input buffer
-    (*(ipCallbacks->EmptyBufferDone))
-    (pHandle, iCallbackData, pAacInputBuffer);
-
-    pAacInputBuffer = NULL;
-
-}
-
-/**
- * Returns Output Buffer back to the IL client
- */
-void OpenmaxAacAO::AacComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pAacOutputBuffer,
-        AacComponentPortType *pPort)
-{
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    //Callback for sending back the output buffer
-    (*(ipCallbacks->FillBufferDone))
-    (pHandle, iCallbackData, pAacOutputBuffer);
-
-    if (iOutBufferCount)
-    {
-        iOutBufferCount--;
-    }
-
-    pPort->NumBufferFlushed++;
-    iNewOutBufRequired = OMX_TRUE;
-}
-
-/** The panic function that exits from the application.
- */
-OMX_S32 OpenmaxAacAO::AacComponentPanic()
-{
-    OSCL_ASSERT(false);
-    OsclError::Panic("PVERROR", OsclErrGeneral);
-    return 0;
-}
-
-
-/** Flushes all the buffers under processing by the given port.
-	* This function is called due to a state change of the component, typically
-	* @param Component the component which owns the port to be flushed
-	* @param PortIndex the ID of the port to be flushed
-	*/
-
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentFlushPort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentFlushPort IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_BUFFERHEADERTYPE* pOutputBuff;
-    OMX_BUFFERHEADERTYPE* pInputBuff;
-
-    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        while ((GetQueueNumElem(pInputQueue) > 0))
-        {
-            pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, pInputBuff);
-            iNumInputBuffer--;
-        }
-
-        if (ipAacInputBuffer && (OMX_FALSE == iIsInputBufferEnded))
-        {
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, ipAacInputBuffer);
-            iNumInputBuffer--;
-
-            iIsInputBufferEnded = OMX_TRUE;
-            ipAacDec->iInputUsedLength = 0;
-        }
-
-    }
-
-    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        if ((OMX_FALSE == iNewOutBufRequired) && (iOutBufferCount > 0))
-        {
-            if (ipAacOutputBuffer)
-            {
-                (*(ipCallbacks->FillBufferDone))
-                (pHandle, iCallbackData, ipAacOutputBuffer);
-                iOutBufferCount--;
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-
-        while ((GetQueueNumElem(pOutputQueue) > 0))
-        {
-            pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            pOutputBuff->nFilledLen = 0;
-            (*(ipCallbacks->FillBufferDone))
-            (pHandle, iCallbackData, pOutputBuff);
-            iOutBufferCount--;
-        }
-
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentFlushPort OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** This function is called by the omx core when the component
-	* is disposed by the IL client with a call to FreeHandle().
-	* \param Component, the component to be disposed
-	*/
-
-OMX_ERRORTYPE OpenmaxAacAO::DestroyComponent()
-{
-    OMX_U32 ii;
-
-    if (iIsInit != OMX_FALSE)
-    {
-        AacComponentDeInit();
-    }
-
-    /*Deinitialize and free ports semaphores and Queue*/
-    for (ii = 0; ii < iNumPorts; ii++)
-    {
-        if (ipPorts[ii]->pBufferQueue != NULL)
-        {
-            QueueDeinit(ipPorts[ii]->pBufferQueue);
-            oscl_free(ipPorts[ii]->pBufferQueue);
-            ipPorts[ii]->pBufferQueue = NULL;
-        }
-        /*Free port*/
-        if (ipPorts[ii] != NULL)
-        {
-            oscl_free(ipPorts[ii]);
-            ipPorts[ii] = NULL;
-        }
-    }
-
-    if (ipPorts)
-    {
-        oscl_free(ipPorts);
-        ipPorts = NULL;
-    }
-
-    iState = OMX_StateLoaded;
-
-    if (ipInputCurrBuffer)
-    {
-        oscl_free(ipInputCurrBuffer);
-        ipInputCurrBuffer = NULL;
-    }
-
-    if (ipTempInputBuffer)
-    {
-        oscl_free(ipTempInputBuffer);
-        ipTempInputBuffer = NULL;
-    }
-
+    // reset decoder
     if (ipAacDec)
     {
-        OSCL_DELETE(ipAacDec);
-        ipAacDec = NULL;
+        ipAacDec->ResetDecoder();
+        ipAacDec->iInputUsedLength = 0;
     }
 
-    if (ipCoreDescriptor != NULL)
-    {
-
-        if (ipCoreDescriptor->pMessageQueue != NULL)
-        {
-            /* De-initialize the asynchronous command queue */
-            QueueDeinit(ipCoreDescriptor->pMessageQueue);
-            oscl_free(ipCoreDescriptor->pMessageQueue);
-            ipCoreDescriptor->pMessageQueue = NULL;
-        }
-
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    if (ipAppPriv)
-    {
-        ipAppPriv->AacHandle = NULL;
-
-        oscl_free(ipAppPriv);
-        ipAppPriv = NULL;
-    }
-
-    return OMX_ErrorNone;
 }
 
 
-/**
- * Disable Single Port
- */
-void OpenmaxAacAO::AacComponentDisableSinglePort(OMX_U32 PortIndex)
+
+/* Routine to call the respective function of the decoder library for updating the
+ * AAC+ flag, A separate routine is written here because the direct call can't be
+ * done from GetParameter of common audio base class */
+
+void OpenmaxAacAO::UpdateAACPlusFlag(OMX_BOOL aAacPlusFlag)
 {
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE;
-
-    if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->IdleToLoadedFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_FALSE;
-        }
-    }
-
-    ipPorts[PortIndex]->NumBufferFlushed = 0;
+    ipAacDec->UpdateAACPlusEnabled(aAacPlusFlag);
 }
 
 
-/** Disables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be disabled
-	* @param PortIndex the ID of the port to be disabled
-	*/
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentDisablePort(OMX_S32 PortIndex)
+void OpenmaxAacAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
 {
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDisablePort IN"));
-    OMX_U32 ii;
-
-    if (-1 == PortIndex)
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_TRUE;
-        }
-
-        /*Flush all ports*/
-        AacComponentFlushPort(PortIndex);
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_FALSE;
-        }
-    }
-    else
-    {
-        /*Flush the port specified*/
-        ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE;
-        AacComponentFlushPort(PortIndex);
-        ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE;
-    }
-
-    /*Disable ports*/
-    if (PortIndex != -1)
-    {
-        AacComponentDisableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            AacComponentDisableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDisablePort OUT"));
-
-    return OMX_ErrorNone;
+    *aRoleString = (OMX_STRING)"audio_decoder.aac";
 }
 
-/**
- * Enable Single Port
- */
-void OpenmaxAacAO::AacComponentEnableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE;
-
-    if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->LoadedToIdleFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_TRUE;
-        }
-    }
-}
-
-/** Enables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be enabled
-	* @param PortIndex the ID of the port to be enabled
-	*/
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentEnablePort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentEnablePort IN"));
-
-    OMX_U32 ii;
-
-    /*Enable port/s*/
-    if (PortIndex != -1)
-    {
-        AacComponentEnableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            AacComponentEnableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentEnablePort OUT"));
-    return OMX_ErrorNone;
-}
-
-//Not implemented & supported in case of base profile components
-
-void OpenmaxAacAO::AacComponentGetRolesOfComponent(OMX_STRING* aRoleString)
-{
-    *aRoleString = "audio_decoder.aac";
-}
-
-
-
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentTunnelRequest(
-    OMX_IN  OMX_HANDLETYPE hComp,
-    OMX_IN  OMX_U32 nPort,
-    OMX_IN  OMX_HANDLETYPE hTunneledComp,
-    OMX_IN  OMX_U32 nTunneledPort,
-    OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState)
-{
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-
-    pOpenmaxAOType->GetState(pState);
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxAacAO::GetState(OMX_OUT OMX_STATETYPE* pState)
-{
-    *pState = iState;
-}
-
-
 
 //Active object constructor
-OpenmaxAacAO::OpenmaxAacAO() :
-        OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXAacDec")
+OpenmaxAacAO::OpenmaxAacAO()
 {
-
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXAudioDecNode");
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : constructed"));
-
-    //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-    iBufferExecuteFlag = OMX_FALSE;
-    ipAppPriv = NULL;
-    //iLogger = NULL;
-
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-
-
-    ipCoreDescriptor = NULL;
-    iNumInputBuffer = 0;
-
-    ipFrameDecodeBuffer = NULL;
-    iPartialFrameAssembly = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iEndofStream = OMX_FALSE;
-    ipTempInputBuffer = NULL;
-
-
-    ipTargetComponent = NULL;
-    iTargetMarkData = NULL;
-    iNewOutBufRequired = OMX_TRUE;
-
-    iTempConsumedLength = 0;
-    iOutBufferCount = 0;
-    iCodecReady = OMX_FALSE;
-    ipInputCurrBuffer = NULL;
-    iInputCurrLength = 0;
-    iFrameCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    ipAacInputBuffer = NULL;
-    ipAacOutputBuffer = NULL;
-
-
-    iFirstFragment = OMX_FALSE;
-    iResizePending = OMX_FALSE;
-
-    iFrameTimestamp = 0;
-    iSilenceInsertionInProgress = OMX_FALSE;
-
-    iNumPorts = 0;
-    ipPorts = NULL;
-
-    //Indicate whether component has been already initialized */
-    iIsInit = OMX_FALSE;
-
-    iGroupPriority = 0;
-    iGroupID = 0;
-
-    ipMark = NULL;
-
     ipAacDec = NULL;
 
-
     if (!IsAdded())
     {
         AddToScheduler();
     }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : constructed"));
 }
 
 
@@ -1492,15 +784,15 @@
 
 /** The Initialization function
  */
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentInit()
+OMX_ERRORTYPE OpenmaxAacAO::ComponentInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ComponentInit IN"));
 
     OMX_BOOL Status = OMX_TRUE;
 
     if (OMX_TRUE == iIsInit)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentInit error incorrect operation"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ComponentInit error incorrect operation"));
         return OMX_ErrorIncorrectStateOperation;
     }
     iIsInit = OMX_TRUE;
@@ -1512,11 +804,12 @@
         iCodecReady = OMX_TRUE;
     }
 
+    //ipAacDec->iAacInitFlag = 0;
     iInputCurrLength = 0;
     //Used in dynamic port reconfiguration
     iFrameCount = 0;
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ComponentInit OUT"));
 
     if (OMX_TRUE == Status)
     {
@@ -1529,11 +822,11 @@
 }
 
 /** This function is called upon a transition to the idle or invalid state.
- *  Also it is called by the AacComponentDestructor() function
+ *  Also it is called by the ComponentDestructor() function
  */
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentDeInit()
+OMX_ERRORTYPE OpenmaxAacAO::ComponentDeInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDeInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ComponentDeInit IN"));
 
     iIsInit = OMX_FALSE;
 
@@ -1543,1987 +836,17 @@
         iCodecReady = OMX_FALSE;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDeInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : ComponentDeInit OUT"));
 
     return OMX_ErrorNone;
 
 }
 
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentGetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return Status;
-
-}
-
-OMX_ERRORTYPE OpenmaxAacAO::GetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter IN"));
-
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
-    OMX_PORT_PARAM_TYPE* pPortDomains;
-    OMX_U32 PortIndex;
-
-    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
-    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
-    OMX_AUDIO_PARAM_AACPROFILETYPE* pAudioAac;
-
-    AacComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamPriorityMgmt:
-        {
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
-            pPrioMgmt->nGroupPriority = iGroupPriority;
-            pPrioMgmt->nGroupID = iGroupID;
-        }
-        break;
-
-        case OMX_IndexParamAudioInit:
-        {
-            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-
-        //Following 3 cases have a single common piece of code to be executed
-        case OMX_IndexParamVideoInit:
-        case OMX_IndexParamImageInit:
-        case OMX_IndexParamOtherInit:
-        {
-            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
-            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
-            pPortDomains->nPorts = 0;
-            pPortDomains->nStartPortNumber = 0;
-        }
-        break;
-
-        case OMX_IndexParamAudioPortFormat:
-        {
-            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            if (pAudioPortFormat->nIndex > ipPorts[pAudioPortFormat->nPortIndex]->AudioParam.nIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error index out of range"));
-                return OMX_ErrorNoMore;
-            }
-            SetHeader(pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            if (pAudioPortFormat->nPortIndex <= 1)
-            {
-                pComponentPort = (AacComponentPortType*) ipPorts[pAudioPortFormat->nPortIndex];
-                oscl_memcpy(pAudioPortFormat, &pComponentPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamAudioPcm:
-        {
-            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
-            if (pAudioPcmMode->nPortIndex > 1)
-            {
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioPcmMode->nPortIndex;
-            oscl_memcpy(pAudioPcmMode, &ipPorts[PortIndex]->AudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-            SetHeader(pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioAac:
-        {
-            pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure;
-            if (pAudioAac->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioAac->nPortIndex;
-            oscl_memcpy(pAudioAac, &ipPorts[PortIndex]->AudioAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
-            SetHeader(pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-
-            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
-            {
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-            else
-            {
-                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-        }
-        break;
-
-        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
-        {
-            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
-            if (NULL == pCap_flags)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error pCap_flags NULL"));
-                return OMX_ErrorBadParameter;
-            }
-            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
-
-        }
-        break;
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter error Unsupported Index"));
-            return OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : GetParameter OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::SetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter IN"));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
-    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
-    OMX_AUDIO_PARAM_AACPROFILETYPE* pAudioAac;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
-    OMX_U32 PortIndex;
-    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
-
-    AacComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamAudioInit:
-        {
-            /*Check Structure Header*/
-            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error audio init failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioPortFormat:
-        {
-            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            PortIndex = pAudioPortFormat->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            if (PortIndex <= 1)
-            {
-                pComponentPort = (AacComponentPortType*) ipPorts[PortIndex];
-                oscl_memcpy(&pComponentPort->AudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamAudioPcm:
-        {
-            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
-            PortIndex = pAudioPcmMode->nPortIndex;
-            /*Check Structure Header and verify component State*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-            oscl_memcpy(&ipPorts[PortIndex]->AudioPcmMode, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioAac:
-        {
-            OMX_BOOL AacPlusFlag = OMX_TRUE;
-
-            pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure;
-            PortIndex = pAudioAac->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->AudioAacParam, pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
-
-            if ((ipPorts[PortIndex]->AudioAacParam.eAACProfile == OMX_AUDIO_AACObjectHE)
-                    || (ipPorts[PortIndex]->AudioAacParam.eAACProfile == OMX_AUDIO_AACObjectHE_PS))
-            {
-                AacPlusFlag = OMX_TRUE;
-            }
-            else
-            {
-                AacPlusFlag = OMX_FALSE;
-            }
-
-            ipAacDec->UpdateAACPlusEnabled(AacPlusFlag);
-        }
-        break;
-
-        case OMX_IndexParamPriorityMgmt:
-        {
-            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error incorrect state error"));
-                return OMX_ErrorIncorrectStateOperation;
-            }
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            iGroupPriority = pPrioMgmt->nGroupPriority;
-            iGroupID = pPrioMgmt->nGroupID;
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
-            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-            if (OMX_ErrorIncorrectStateOperation == ErrorType)
-            {
-                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error incorrect state error"));
-                    return OMX_ErrorIncorrectStateOperation;
-                }
-            }
-            else if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter OUT"));
-                return OMX_ErrorNone;
-            }
-
-            ErrorType = OMX_ErrorNone;
-        }
-        break;
-
-        case OMX_IndexParamStandardComponentRole:
-        {
-            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            strcpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole);
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter error bad parameter"));
-            return OMX_ErrorBadParameter;
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetParameter OUT"));
-    return ErrorType;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::UseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : UseBuffer IN"));
-    AacComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : UseBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : UseBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : UseBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer;
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFilledLen = 0;
-            pBaseComponentPort->pBuffer[ii]->nOffset = 0;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            pBaseComponentPort->pBuffer[ii]->nTickCount = 0;
-            pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0;
-            *ppBufferHdr = pBaseComponentPort->pBuffer[ii];
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            else
-            {
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-            pBaseComponentPort->NumAssignedBuffers++;
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : UseBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : UseBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::AllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer IN"));
-
-    AacComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            /* allocate the buffer */
-            pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes);
-            if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            *pBuffer = pBaseComponentPort->pBuffer[ii];
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts;
-            }
-            else
-            {
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-            }
-
-            pBaseComponentPort->NumAssignedBuffers++;
-
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AllocateBuffer OUT"));
-    return OMX_ErrorInsufficientResources;
-}
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::FreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FreeBuffer IN"));
-
-    AacComponentPortType* pBaseComponentPort;
-
-    OMX_U32 ii;
-    OMX_BOOL FoundBuffer;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FreeBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateLoaded
-            && pBaseComponentPort->TransientState != OMX_StateInvalid)
-    {
-
-        (*(ipCallbacks->EventHandler))
-        (hComponent,
-         iCallbackData,
-         OMX_EventError, /* The command was completed */
-         OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */
-         nPortIndex, /* The State has been changed in message->MessageParam2 */
-         NULL);
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-            oscl_free(pBuffer->pBuffer);
-            pBuffer->pBuffer = NULL;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-        else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) &&
-                 (pBaseComponentPort->pBuffer[ii] == pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-    }
-
-    FoundBuffer = OMX_FALSE;
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE)
-        {
-            FoundBuffer = OMX_TRUE;
-            break;
-        }
-    }
-    if (!FoundBuffer)
-    {
-        pBaseComponentPort->PortParam.bPopulated = OMX_FALSE;
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation
-            RunIfNotReady();
-            //Set the corresponding flags
-            pBaseComponentPort->IdleToLoadedFlag = OMX_TRUE;
-            pBaseComponentPort->LoadedToIdleFlag = OMX_FALSE;
-            iStateTransitionFlag = OMX_FALSE;
-            //Reset the decoding flags while freeing buffers
-            if (OMX_PORT_INPUTPORT_INDEX == nPortIndex)
-            {
-                iIsInputBufferEnded = OMX_TRUE;
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-            }
-            else if (OMX_PORT_OUTPUTPORT_INDEX == nPortIndex)
-            {
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-        if (NULL != pBaseComponentPort->pBuffer)
-        {
-            oscl_free(pBaseComponentPort->pBuffer);
-            pBaseComponentPort->pBuffer = NULL;
-            oscl_free(pBaseComponentPort->BufferState);
-            pBaseComponentPort->BufferState = NULL;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FreeBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs
-	* @param hComponent the handle of the component
-	* @param ipCallbacks the OpenMAX standard structure that holds the callback pointers
-	* @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed
-    */
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAacAO::SetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SetCallbacks"));
-    ipCallbacks = pCallbacks;
-    iCallbackData = pAppData;
-
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAacAO::SendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_S32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand IN"));
-
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone;
-    QueueType* pMessageQueue;
-    CoreMessage* Message = NULL;
-
-    pMessageQueue = ipCoreDescriptor->pMessageQueue;
-
-    if (OMX_StateInvalid == iState)
-    {
-        ErrMsgHandler = OMX_ErrorInvalidState;
-    }
-
-    switch (Cmd)
-    {
-        case OMX_CommandStateSet:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandStateSet;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState))
-            {
-                ErrMsgHandler = AacComponentInit();
-
-                if (ErrMsgHandler != OMX_ErrorNone)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error component init"));
-                    return OMX_ErrorInsufficientResources;
-                }
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    ipPorts[ii]->TransientState = OMX_StateIdle;
-                }
-            }
-            else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState))
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else if (OMX_StateInvalid == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateInvalid;
-                    }
-                }
-            }
-            else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam))
-                     && (OMX_StateExecuting == iState))
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-
-        }
-        break;
-
-        case OMX_CommandFlush:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandFlush;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-
-            }
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            //Assume that reposition command has come
-            iRepositionFlag = OMX_TRUE;
-            //Reset the silence insertion logic also
-            iSilenceInsertionInProgress = OMX_FALSE;
-            // reset decoder
-            if (ipAacDec)
-            {
-                ipAacDec->ResetDecoder();
-            }
-
-            AacComponentSetPortFlushFlag(iNumPorts, nParam, OMX_TRUE);
-            AacComponentSetNumBufferFlush(iNumPorts, -1, 0);
-        }
-        break;
-
-        case OMX_CommandPortDisable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            iResizePending = OMX_FALSE;
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (!PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else
-            {
-                if (!PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateLoaded;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-                Message->MessageParam2 = nParam;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-                Message->MessageParam2 = ErrMsgHandler;
-            }
-            Message->MessageParam1 = OMX_CommandPortDisable;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandPortEnable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateIdle;
-                    }
-                }
-            }
-            else
-            {
-                if (PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateIdle;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-            }
-
-            Message->MessageParam1 = OMX_CommandPortEnable;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandMarkBuffer:
-        {
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-            }
-
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandMarkBuffer;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand error unsupported index"));
-            ErrMsgHandler = OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    Queue(pMessageQueue, Message);
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : SendCommand OUT"));
-    return ErrMsgHandler;
-}
-
-
-/** This is called by the OMX core in its message processing
- * thread context upon a component request. A request is made
- * by the component when some asynchronous services are needed:
- * 1) A SendCommand() is to be processed
- * 2) An error needs to be notified
- * \param Message, the message that has been passed to core
- */
-
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentMessageHandler(CoreMessage* Message)
-{
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-
-    /** Dealing with a SendCommand call.
-     * -MessageParam1 contains the command to execute
-     * -MessageParam2 contains the parameter of the command
-     *  (destination state in case of a state change command).
-     */
-
-    OMX_STATETYPE orig_state = iState;
-    if (SENDCOMMAND_MSG_TYPE == Message->MessageType)
-    {
-        switch (Message->MessageParam1)
-        {
-            case OMX_CommandStateSet:
-            {
-                /* Do the actual state change */
-                ErrorType = AacComponentDoStateSet(Message->MessageParam2);
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                //Do not send the callback now till the State gets changed
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    /* And run the callback */
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventCmdComplete, /* The command was completed */
-                     OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
-                     Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-            }
-            break;
-
-            case OMX_CommandFlush:
-            {
-                /*Flush ports*/
-                ErrorType = AacComponentFlushPort(Message->MessageParam2);
-
-                AacComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Flush all port*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {/*Flush input/output port*/
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-                AacComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-            }
-            break;
-
-            case OMX_CommandPortDisable:
-            {
-                /** This condition is added to pass the tests, it is not significant for the environment */
-                ErrorType = AacComponentDisablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Disable all ports*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandPortEnable:
-            {
-                ErrorType = AacComponentEnablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The State has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (Message->MessageParam2 != -1)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                    else
-                    {
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The State has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandMarkBuffer:
-            {
-                ipMark = (OMX_MARKTYPE *)Message->pCmdData;
-            }
-            break;
-
-            default:
-            {
-
-            }
-            break;
-        }
-        /* Dealing with an asynchronous error condition
-         */
-    }
-
-    if (orig_state != OMX_StateInvalid)
-    {
-        ErrorType = OMX_ErrorNone;
-    }
-
-    return ErrorType;
-}
-
-/** Changes the state of a component taking proper actions depending on
- * the transiotion requested
- * \param Component, the component which state is to be changed
- * \param aDestinationState the requested target state.
- */
-
-OMX_ERRORTYPE OpenmaxAacAO::AacComponentDoStateSet(OMX_U32 aDestinationState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
-                    (0, "OpenmaxAacAO : AacComponentDoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_U32 ii;
-
-    if (OMX_StateLoaded == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateLoaded;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->IdleToLoadedFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_FALSE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet Waiting port to be de-populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateLoaded;
-
-                iNumInputBuffer = 0;
-                iOutBufferCount = 0;
-                iPartialFrameAssembly = OMX_FALSE;
-                iEndofStream = OMX_FALSE;
-                iIsInputBufferEnded = OMX_TRUE;
-                iNewOutBufRequired = OMX_TRUE;
-                iFirstFragment = OMX_FALSE;
-                ipAacDec->iAacInitFlag = 0;
-
-                AacComponentDeInit();
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateWaitForResources == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                iState = OMX_StateWaitForResources;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateIdle == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            !PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->LoadedToIdleFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_TRUE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet Waiting port to be populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateIdle;
-
-                //Used in case of partial frame assembly
-                if (!ipInputCurrBuffer)
-                {
-                    //Keep the size of temp buffer double to be on safer side
-                    ipInputCurrBuffer = (OMX_U8*) oscl_malloc(10 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-                    if (NULL == ipInputCurrBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                if (!ipTempInputBuffer)
-                {
-                    ipTempInputBuffer = (OMX_U8*) oscl_malloc(10 * sizeof(uint8) * ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
-                    if (NULL == ipTempInputBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            //Both the below cases have same body
-            case OMX_StateExecuting:
-            case OMX_StatePause:
-            {
-                AacComponentSetNumBufferFlush(iNumPorts, -1, 0);
-                AacComponentSetPortFlushFlag(iNumPorts, -1, OMX_TRUE);
-
-                AacComponentPortType* pInPort = (AacComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-                //Return all the buffers if still occupied
-                QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-                while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0))
-                {
-                    AacComponentFlushPort(OMX_PORT_INPUTPORT_INDEX);
-                }
-                // if a buffer was previously dequeued, it wasnt freed in above loop. return it now
-                if (iNumInputBuffer > 0)
-                {
-                    ipAacInputBuffer->nFilledLen = 0;
-                    AacComponentReturnInputBuffer(ipAacInputBuffer, pInPort);
-                    iIsInputBufferEnded = OMX_TRUE;
-                }
-
-                //Mark these flags as true
-                iIsInputBufferEnded = OMX_TRUE;
-                iEndofStream = OMX_FALSE;
-
-                //Reset the decoder's input buffers/flags
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-
-                //Assume for this state transition that reposition command has come
-                iRepositionFlag = OMX_TRUE;
-                //Reset the silence insertion logic also
-                iSilenceInsertionInProgress = OMX_FALSE;
-                // reset decoder
-                if (ipAacDec)
-                {
-                    ipAacDec->ResetDecoder();
-                }
-
-                while (iOutBufferCount > 0)
-                {
-                    AacComponentFlushPort(OMX_PORT_OUTPUTPORT_INDEX);
-                }
-
-                AacComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-                AacComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet OUT"));
-        return ErrorType;
-    }
-
-    if (OMX_StatePause == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            //Falling through to the next case
-            case OMX_StateExecuting:
-            case OMX_StateIdle:
-            {
-                iState = OMX_StatePause;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateExecuting == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                iState = OMX_StateExecuting;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                iState = OMX_StateExecuting;
-                /* A trigger to start the processing of buffers when component
-                 * transitions to executing from pause, as it is already
-                 * holding the required buffers
-                 */
-                RunIfNotReady();
-            }
-            break;
-
-            case OMX_StateExecuting:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateInvalid == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            default:
-            {
-                iState = OMX_StateInvalid;
-                if (iIsInit != OMX_FALSE)
-                {
-                    AacComponentDeInit();
-                }
-            }
-            break;
-        }
-
-        if (iIsInit != OMX_FALSE)
-        {
-            AacComponentDeInit();
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : AacComponentDoStateSet OUT"));
-    return OMX_ErrorNone;
-}
-
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer);
-
-    return Status;
-
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::EmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer IN"));
-    //Do not queue buffers if component is in invalid state
-    if (OMX_StateInvalid == iState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState))
-    {
-        OMX_U32 PortIndex;
-        QueueType* pInputQueue;
-        OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-        PortIndex = pBuffer->nInputPortIndex;
-
-        //Validate the port index & Queue the buffers available only at the input port
-        if (PortIndex >= iNumPorts ||
-                ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer error bad port index"));
-            return OMX_ErrorBadPortIndex;
-        }
-
-        //Port should be in enabled state before accepting buffers
-        if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        /* The number of buffers the component can queue at a time
-         * depends upon the number of buffers allocated/assigned on the input port
-         */
-        if (iNumInputBuffer == (ipPorts[PortIndex]->NumAssignedBuffers))
-
-        {
-            RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        //Finally after passing all the conditions, queue the buffer in Input queue
-        pInputQueue = ipPorts[PortIndex]->pBufferQueue;
-
-        if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer error check header failed"));
-            return ErrorType;
-        }
-
-        iNumInputBuffer++;
-        Queue(pInputQueue, pBuffer);
-
-        //Signal the AO about the incoming buffer
-        RunIfNotReady();
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer error incorrect state"));
-        //This macro is not accepted in any other state except the three mentioned above
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : EmptyThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAacAO::BaseComponentFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxAacAO* pOpenmaxAOType = (OpenmaxAacAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAacAO::FillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FillThisBuffer IN"));
-
-    OMX_U32 PortIndex;
-
-    QueueType* pOutputQueue;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-    PortIndex = pBuffer->nOutputPortIndex;
-    //Validate the port index & Queue the buffers available only at the output port
-    if (PortIndex >= iNumPorts ||
-            ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FillThisBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pOutputQueue = ipPorts[PortIndex]->pBufferQueue;
-    if (iState != OMX_StateExecuting &&
-            iState != OMX_StatePause &&
-            iState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FillThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    //Port should be in enabled state before accepting buffers
-    if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FillThisBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FillThisBuffer error check header failed"));
-        return ErrorType;
-    }
-
-    //Queue the buffer in output queue
-    Queue(pOutputQueue, pBuffer);
-    iOutBufferCount++;
-
-    //Signal the AO about the incoming buffer
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : FillThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-
-void OpenmaxAacAO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : Run IN"));
-
-    CoreMessage* pCoreMessage;
-
-    //Execute the commands from the message handler queue
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue);
-
-        if (OMX_CommandStateSet == pCoreMessage->MessageParam1)
-        {
-            if (OMX_StateExecuting == pCoreMessage->MessageParam2)
-            {
-                iBufferExecuteFlag = OMX_TRUE;
-            }
-            else
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-        }
-
-        AacComponentMessageHandler(pCoreMessage);
-
-        /* If some allocations/deallocations are required before the state transition
-         * then queue the command again to be executed later on
-         */
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage);
-            // Don't reschedule. Wait for arriving buffers to do it
-            //RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : Run OUT"));
-            return;
-        }
-
-        else
-        {
-            oscl_free(pCoreMessage);
-            pCoreMessage = NULL;
-        }
-    }
-
-    /* If the component is in executing state, call the Buffer management function.
-     * Stop calling this function as soon as state transition request is received.
-     */
-    if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending))
-    {
-        AacComponentBufferMgmtFunction();
-    }
-
-    //Check for any more commands in the message handler queue & schedule them for later
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : Run OUT"));
-
-    return;
-}
-
 //Check whether silence insertion is required here or not
 void OpenmaxAacAO::CheckForSilenceInsertion()
 {
     OMX_AUDIO_AACSTREAMFORMATTYPE InFormat = ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioAacParam.eAACStreamFormat;
-    uint32 CurrTimestamp, TimestampGap;
+    OMX_TICKS CurrTimestamp, TimestampGap;
     //Set the flag to false by default
     iSilenceInsertionInProgress = OMX_FALSE;
 
@@ -3547,7 +870,10 @@
     {
         iSilenceInsertionInProgress = OMX_TRUE;
         //Determine the number of silence frames to insert
-        iSilenceFramesNeeded = TimestampGap / iOutputMilliSecPerFrame;
+        if (0 != iOutputMilliSecPerFrame)
+        {
+            iSilenceFramesNeeded = TimestampGap / iOutputMilliSecPerFrame;
+        }
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : CheckForSilenceInsertion OUT - Silence Insertion required here"));
     }
 
@@ -3559,10 +885,11 @@
 {
     OMX_S32 NumOfChannels = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nChannels;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-    AacComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
-    OMX_U8*	pOutBuffer, *SilenceInputBuffer;
-    OMX_U32	OutputLength, SilenceFrameLength;
+    OMX_U8* pOutBuffer = NULL;
+    OMX_U8* pSilenceInputBuffer = NULL;
+    OMX_U32 OutputLength, SilenceFrameLength;
     OMX_S32 DecodeReturn;
     OMX_BOOL ResizeNeeded = OMX_FALSE;
 
@@ -3583,36 +910,42 @@
                 return;
             }
 
-            ipAacOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipAacOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : DoSilenceInsertion Error, output buffer dequeue returned NULL, OUT"));
+                iSilenceInsertionInProgress = OMX_TRUE;
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipAacOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+            ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
         }
 
         // Setup the input side for silence frame
         if (NumOfChannels > 1)
         {
             // Stereo silence frame
-            SilenceInputBuffer = (OMX_U8*) AAC_STEREO_SILENCE_FRAME;
+            pSilenceInputBuffer = (OMX_U8*) AAC_STEREO_SILENCE_FRAME;
             SilenceFrameLength = AAC_STEREO_SILENCE_FRAME_SIZE;
         }
         else
         {
             // Mono silence frame
-            SilenceInputBuffer = (OMX_U8*) AAC_MONO_SILENCE_FRAME;
+            pSilenceInputBuffer = (OMX_U8*) AAC_MONO_SILENCE_FRAME;
             SilenceFrameLength = AAC_MONO_SILENCE_FRAME_SIZE;
         }
 
 
-        pOutBuffer = &ipAacOutputBuffer->pBuffer[ipAacOutputBuffer->nFilledLen];
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
         OutputLength = 0;
 
         //Decode the silence frame
         DecodeReturn = ipAacDec->AacDecodeFrames((OMX_S16*) pOutBuffer,
                        (OMX_U32*) & OutputLength,
-                       &(SilenceInputBuffer),
+                       &(pSilenceInputBuffer),
                        &SilenceFrameLength,
                        &iFrameCount,
                        &(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode),
@@ -3623,9 +956,9 @@
 
 
         //Output length for a buffer of OMX_U8* will be double as that of OMX_S16*
-        ipAacOutputBuffer->nFilledLen += OutputLength * 2;
+        ipOutputBuffer->nFilledLen += OutputLength * 2;
         //offset not required in our case, set it to zero
-        ipAacOutputBuffer->nOffset = 0;
+        ipOutputBuffer->nOffset = 0;
 
         if (OutputLength > 0)
         {
@@ -3643,9 +976,10 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAacAO : DoSilenceInsertion - silence frame decoded"));
 
         //Send the output buffer back when it has become full
-        if ((ipAacOutputBuffer->nAllocLen - ipAacOutputBuffer->nFilledLen) < iOutputFrameLength)
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
         {
-            AacComponentReturnOutputBuffer(ipAacOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         // Decrement the silence frame counter
@@ -3661,3 +995,15 @@
 
     return;
 }
+
+OMX_ERRORTYPE OpenmaxAacAO::GetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    OSCL_UNUSED_ARG(nIndex);
+    OSCL_UNUSED_ARG(pComponentConfigStructure);
+
+    return OMX_ErrorNotImplemented;
+}
diff --git a/codecs_v2/omx/omx_aacenc/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_aacenc/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..55a3543
--- /dev/null
+++ b/codecs_v2/omx/omx_aacenc/build/make_multithreaded/local.mk
@@ -0,0 +1,33 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_aacenc_component_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../audio/aac/enc/src \
+  ../../../../audio/aac/enc/include 
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := aac_enc.cpp \
+	omx_aacenc_component.cpp
+
+
+HDRS := aac_enc.h \
+	omx_aacenc_component.h
+	
+
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_aacenc/include/aac_enc.h b/codecs_v2/omx/omx_aacenc/include/aac_enc.h
new file mode 100644
index 0000000..1f67a55
--- /dev/null
+++ b/codecs_v2/omx/omx_aacenc/include/aac_enc.h
@@ -0,0 +1,69 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AAC_ENC_H_INCLUDED
+#define AAC_ENC_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#ifndef _AAC_ENC_LIB_H_
+#include "aacenc_lib.h"
+#endif
+
+
+class OmxAacEncoder
+{
+    public:
+        OmxAacEncoder();
+
+        OMX_BOOL AacEncInit(OMX_AUDIO_PARAM_PCMMODETYPE aPcmMode,
+                            OMX_AUDIO_PARAM_AACPROFILETYPE aAacParam,
+                            OMX_U32* aInputFrameLength);
+
+        void AacEncDeinit();
+
+        OMX_BOOL AacEncodeFrame(OMX_U8* aOutputBuffer,
+                                OMX_U32* aOutputLength,
+                                OMX_U8* aInBuffer,
+                                OMX_U32 aInBufSize);
+
+    private:
+
+        OMX_S32 AacEncConfigDefaultSettings(ENC_CONFIGURATION* pConfig);
+        //Encoder settings
+        ENC_CONFIGURATION iAacEncConfig;
+        HANDLE_AACENCODER iAacEncoder;
+
+        OMX_U32 iAscSize;
+        OMX_U8  iAscBuf[12];
+        OMX_BOOL iAscFlag;
+
+        OMX_U8* iAacInputBuffer;
+        OMX_U8* iAacOutputBuffer;
+
+};
+
+
+
+#endif	//#ifndef AAC_ENC_H_INCLUDED
+
diff --git a/codecs_v2/omx/omx_aacenc/include/omx_aacenc_component.h b/codecs_v2/omx/omx_aacenc/include/omx_aacenc_component.h
new file mode 100644
index 0000000..afb5b54
--- /dev/null
+++ b/codecs_v2/omx/omx_aacenc/include/omx_aacenc_component.h
@@ -0,0 +1,76 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+	@file omx_aacenc_component.h
+	OpenMax encoder component file.
+*/
+
+#ifndef OMX_AACENC_COMPONENT_H_INCLUDED
+#define OMX_AACENC_COMPONENT_H_INCLUDED
+
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
+#endif
+
+#ifndef AAC_DEC_H_INCLUDED
+#include "aac_enc.h"
+#endif
+
+#ifndef AACENC_TIMESTAMP_H_INCLUDED
+#include "aacenc_timestamp.h"
+#endif
+
+
+#define INPUT_BUFFER_SIZE_AAC_ENC (INPUTBUFFER_SIZE * 2)
+
+#define OUTPUT_BUFFER_SIZE_AAC_ENC OUTPUTBUFFER_SIZE
+
+#define NUMBER_INPUT_BUFFER_AAC_ENC  5
+#define NUMBER_OUTPUT_BUFFER_AAC_ENC  2
+
+
+class OmxComponentAacEncoderAO : public OmxComponentAudio
+{
+    public:
+
+        OmxComponentAacEncoderAO();
+        ~OmxComponentAacEncoderAO();
+
+
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
+
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
+
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+
+        void ProcessData();
+
+        void ProcessInBufferFlag();
+        void SyncWithInputTimestamp();
+
+    private:
+
+        OMX_U32			iInputFrameLength;
+
+        AacEncTimeStampCalc iCurrentFrameTS;
+        OmxAacEncoder*  ipAacEnc;
+};
+
+#endif // OMX_AACENC_COMPONENT_H_INCLUDED
diff --git a/codecs_v2/omx/omx_aacenc/src/aac_enc.cpp b/codecs_v2/omx/omx_aacenc/src/aac_enc.cpp
new file mode 100644
index 0000000..eda0cd8
--- /dev/null
+++ b/codecs_v2/omx/omx_aacenc/src/aac_enc.cpp
@@ -0,0 +1,307 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "aac_enc.h"
+
+#ifndef USE_HEAAC
+#define BITRATE_DEFAULT 128000
+#else
+#define BITRATE_DEFAULT  56000
+#endif
+
+#define BANDWIDTH_DEFAULT      0
+
+
+OmxAacEncoder::OmxAacEncoder()
+{
+    iAacEncoder = NULL;
+    iAacInputBuffer = NULL;
+    iAacOutputBuffer = NULL;
+    iAscSize = 12;
+    iAscFlag = OMX_FALSE;
+
+    oscl_memset(&iAacEncConfig, 0, sizeof(ENC_CONFIGURATION));
+}
+
+OMX_S32 OmxAacEncoder::AacEncConfigDefaultSettings(ENC_CONFIGURATION* pConfig)
+{
+    pConfig->bitrate     = BITRATE_DEFAULT;     /* bitstream bitrate */
+    pConfig->bitrateMode = 0;                   /* constant bitrate */
+    pConfig->bandwidth   = BANDWIDTH_DEFAULT;
+    pConfig->dualMono    = 0;                   /* no dualMono by default */
+
+#ifndef USE_HEAAC
+    pConfig->useAOT      = AOT_AAC_LC;          /* AAC-LC by default */
+#else
+    pConfig->useAOT      = AOT_SBR;             /* otherwise AAC/SBR */
+#endif
+
+    pConfig->useTransmux = TT_MP4_ADTS;         /* ADTS header by default */
+    pConfig->useCRC      = 0;                   /* no CRC by default */
+    pConfig->useTns      = 1;                   /* TNS activated by default */
+    pConfig->usePns      = 1;                   /* PNS activated by default.
+                                                * Depending on channelBitrate this might be set to 0 later */
+#ifdef AFTER_BURNER
+    pConfig->useRequant  = 1;                   /* Afterburner activated by default */
+#endif
+    pConfig->ancFlag     = 0;                   /* no ancillary data by default */
+
+    pConfig->downmix = 0;
+
+    return 0;
+}
+
+
+/* Decoder Initialization function */
+OMX_BOOL OmxAacEncoder::AacEncInit(OMX_AUDIO_PARAM_PCMMODETYPE aPcmMode,
+                                   OMX_AUDIO_PARAM_AACPROFILETYPE aAacParam,
+                                   OMX_U32* aInputFrameLength)
+{
+    OMX_S32 Status;
+    AAC_ENCODER_ERROR ErrorStatus;
+
+
+    // Configure Encoder
+    Status = aacEncConfigure(&iAacEncoder, &iAacEncConfig);
+    if (Status)
+    {
+        // Failure occurred during initialization so return right away
+        return OMX_FALSE;
+    }
+
+    // Get default settings
+    AacEncConfigDefaultSettings(&iAacEncConfig);
+
+    //Now Apply the parameter settings from the client
+    iAacEncConfig.sampleRate = aAacParam.nSampleRate;
+    iAacEncConfig.nChannelsIn = aPcmMode.nChannels;
+    iAacEncConfig.nChannelsOut = aAacParam.nChannels;
+
+    iAacEncConfig.bitrate = aAacParam.nBitRate;
+
+    if (0 != aAacParam.nAudioBandWidth)
+    {
+        iAacEncConfig.bandwidth = aAacParam.nAudioBandWidth;
+    }
+
+    if (OMX_AUDIO_ChannelModeDual == aAacParam.eChannelMode)
+    {
+        iAacEncConfig.dualMono = 1;
+    }
+
+    if (OMX_AUDIO_ChannelModeMono == aAacParam.eChannelMode)
+    {
+        iAacEncConfig.nChannelsOut = 1;
+    }
+
+
+    if (OMX_AUDIO_AACObjectMain == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_AAC_MAIN;
+    }
+    else if (OMX_AUDIO_AACObjectLC == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_AAC_LC;
+    }
+    else if (OMX_AUDIO_AACObjectSSR == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_AAC_SSR;
+    }
+    else if (OMX_AUDIO_AACObjectLTP == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_AAC_LTP;
+    }
+    else if (OMX_AUDIO_AACObjectHE == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_SBR;
+    }
+    else if (OMX_AUDIO_AACObjectScalable == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_AAC_SCAL;
+    }
+    else if (OMX_AUDIO_AACObjectERLC == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_ER_AAC_LC;
+    }
+    else if (OMX_AUDIO_AACObjectLD == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_ER_AAC_LD;
+    }
+    else if (OMX_AUDIO_AACObjectHE_PS == aAacParam.eAACProfile)
+    {
+        iAacEncConfig.useAOT = AOT_PS;
+    }
+    else
+    {
+        return OMX_FALSE;
+    }
+
+
+    if ((OMX_AUDIO_AACStreamFormatMP2ADTS == aAacParam.eAACStreamFormat) ||
+            (OMX_AUDIO_AACStreamFormatMP4ADTS == aAacParam.eAACStreamFormat))
+    {
+        iAacEncConfig.useTransmux = TT_MP4_ADTS;
+    }
+    else if (OMX_AUDIO_AACStreamFormatMP4LOAS == aAacParam.eAACStreamFormat)
+    {
+        iAacEncConfig.useTransmux = TT_MP4_LOAS;
+    }
+    else if (OMX_AUDIO_AACStreamFormatMP4LATM == aAacParam.eAACStreamFormat)
+    {
+        iAacEncConfig.useTransmux = TT_MP4_RAWLATM;
+    }
+    else if (OMX_AUDIO_AACStreamFormatADIF == aAacParam.eAACStreamFormat)
+    {
+        iAacEncConfig.useTransmux = TT_MP4_ADIF;
+    }
+    else if (OMX_AUDIO_AACStreamFormatMP4FF == aAacParam.eAACStreamFormat)
+    {
+        iAacEncConfig.useTransmux = TT_MP4_MP4F;
+    }
+    else if (OMX_AUDIO_AACStreamFormatRAW == aAacParam.eAACStreamFormat)
+    {
+        iAacEncConfig.useTransmux = TT_MP4_RAWPACKETS;
+    }
+    else
+    {
+        return OMX_FALSE;
+    }
+
+
+    if (0 == (OMX_AUDIO_AACToolTNS & aAacParam.nAACtools))
+    {
+        iAacEncConfig.useTns = 0;
+    }
+
+    if (0 == (OMX_AUDIO_AACToolPNS & aAacParam.nAACtools))
+    {
+        iAacEncConfig.usePns = 0;
+    }
+
+
+    //Allocating memory for input and output buffers
+    iAacInputBuffer = (OMX_U8*) oscl_malloc(INPUTBUFFER_SIZE * 2 * sizeof(OMX_U8));
+    iAacOutputBuffer = (OMX_U8*) oscl_malloc(OUTPUTBUFFER_SIZE * sizeof(OMX_U8));
+
+    // Initialize and open the encoder
+    Status = aacEncOpen(iAacEncoder, &iAacEncConfig, (INT_PCM*) iAacInputBuffer, iAacOutputBuffer);
+    if (Status)
+    {
+        // Failure occurred during initialization so return right away
+        return OMX_FALSE;
+    }
+
+    /* RTP access unit simulation: write access unit length (4 byte) before audio specific config */
+    if (TT_MP4_RAWPACKETS == iAacEncConfig.useTransmux)
+    {
+        ErrorStatus = aacEncGetAsc(iAacEncoder, (UINT*) & iAscSize, iAscBuf);
+        if (AAC_ENC_OK != ErrorStatus)
+        {
+            // Failure occurred during initialization so return right away
+            return OMX_FALSE;
+        }
+    }
+
+    *aInputFrameLength = iAacEncConfig.nSamplesRead << 1;
+
+    return OMX_TRUE;
+}
+
+
+/* Decoder De-Initialization function */
+void OmxAacEncoder::AacEncDeinit()
+{
+    if (iAacInputBuffer)
+    {
+        oscl_free(iAacInputBuffer);
+        iAacInputBuffer = NULL;
+    }
+
+    if (iAacOutputBuffer)
+    {
+        oscl_free(iAacOutputBuffer);
+        iAacOutputBuffer = NULL;
+    }
+
+    if (iAacEncoder)
+    {
+        aacEncClose(&iAacEncoder);
+        iAacEncoder = NULL;
+    }
+}
+
+
+/* Decode function for all the input formats */
+OMX_BOOL OmxAacEncoder::AacEncodeFrame(OMX_U8*    aOutputBuffer,
+                                       OMX_U32*   aOutputLength,
+                                       OMX_U8*    aInBuffer,
+                                       OMX_U32	  aInBufSize)
+{
+
+    OMX_S32 NumImputSamples = iAacEncConfig.nSamplesRead;
+    OMX_S32 Status;
+    OMX_S32 OutputOffset = 0;
+
+    if (TT_MP4_RAWPACKETS == iAacEncConfig.useTransmux)
+    {
+        if (OMX_FALSE == iAscFlag)
+        {
+            oscl_memcpy(aOutputBuffer, &iAscSize, 4);
+            oscl_memcpy((aOutputBuffer + 4), iAscBuf, iAscSize);
+            iAscFlag = OMX_TRUE;
+            OutputOffset = 4 + iAscSize;
+        }
+        //Four bytes to write the size of frame after it has been encoded
+        OutputOffset += 4;
+    }
+
+    iAacEncConfig.pOutBuffer = aOutputBuffer + OutputOffset;
+
+    if (aInBufSize < NumImputSamples)
+    {
+        NumImputSamples = aInBufSize >> 1;
+    }
+
+    oscl_memcpy(iAacEncConfig.pInBuffer, aInBuffer, (NumImputSamples << 1));
+
+    // Encode frame
+    Status = aacEncEncode(iAacEncoder,
+                          &iAacEncConfig,
+                          (INT32*) aOutputLength,
+                          NumImputSamples);
+
+    // Check to find if error occurred
+    if (Status)
+    {
+        return OMX_FALSE;
+    }
+
+    if (TT_MP4_RAWPACKETS == iAacEncConfig.useTransmux)
+    {
+        oscl_memcpy((aOutputBuffer + (OutputOffset - 4)), &(*aOutputLength), 4);
+    }
+
+    return OMX_TRUE;
+}
+
+
+
diff --git a/codecs_v2/omx/omx_aacenc/src/omx_aacenc_component.cpp b/codecs_v2/omx/omx_aacenc/src/omx_aacenc_component.cpp
new file mode 100644
index 0000000..a4530b4
--- /dev/null
+++ b/codecs_v2/omx/omx_aacenc/src/omx_aacenc_component.cpp
@@ -0,0 +1,683 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "omx_aacenc_component.h"
+
+#if PROXY_INTERFACE
+#include "omx_proxy_interface.h"
+#endif
+
+
+
+// This function is called by OMX_GetHandle and it creates an instance of the aac component AO
+OMX_ERRORTYPE AacEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    OmxComponentAacEncoderAO* pOpenmaxAOType;
+    OMX_ERRORTYPE Status;
+
+    // move InitAacOmxComponentFields content to actual constructor
+
+    pOpenmaxAOType = (OmxComponentAacEncoderAO*) OSCL_NEW(OmxComponentAacEncoderAO, ());
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Call the construct component to initialize OMX types
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
+
+    *pHandle = pOpenmaxAOType->GetOmxHandle();
+
+    return Status;
+    ///////////////////////////////////////////////////////////////////////////////////////
+}
+
+// This function is called by OMX_FreeHandle when component AO needs to be destroyed
+OMX_ERRORTYPE AacEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    // get pointer to component AO
+    OmxComponentAacEncoderAO* pOpenmaxAOType = (OmxComponentAacEncoderAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
+
+    // clean up encoder, OMX component stuff
+    pOpenmaxAOType->DestroyComponent();
+
+    // destroy the AO class
+    OSCL_DELETE(pOpenmaxAOType);
+
+    return OMX_ErrorNone;
+}
+
+#if DYNAMIC_LOAD_OMX_AACENC_COMPONENT
+class AacEncOmxSharedLibraryInterface:  public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static AacEncOmxSharedLibraryInterface *Instance()
+        {
+            static AacEncOmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_AACENC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AacEncOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AacEncOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        AacEncOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return AacEncOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OMX_ERRORTYPE OmxComponentAacEncoderAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
+{
+    ComponentPortType* pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
+
+    iNumPorts = 2;
+    iCompressedFormatPortNum = OMX_PORT_OUTPUTPORT_INDEX;
+    iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
+    iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
+    iOmxComponent.pApplicationPrivate = pAppData; // init the App data
+
+
+#if PROXY_INTERFACE
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
+
+    iOmxComponent.SendCommand = OmxComponentAacEncoderAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OmxComponentAacEncoderAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OmxComponentAacEncoderAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OmxComponentAacEncoderAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OmxComponentAacEncoderAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentAacEncoderAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentAacEncoderAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OmxComponentAacEncoderAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentAacEncoderAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentAacEncoderAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentAacEncoderAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentAacEncoderAO::BaseComponentProxyFillThisBuffer;
+
+#else
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
+
+    iOmxComponent.SendCommand = OmxComponentAacEncoderAO::BaseComponentSendCommand;
+    iOmxComponent.GetParameter = OmxComponentAacEncoderAO::BaseComponentGetParameter;
+    iOmxComponent.SetParameter = OmxComponentAacEncoderAO::BaseComponentSetParameter;
+    iOmxComponent.GetConfig = OmxComponentAacEncoderAO::BaseComponentGetConfig;
+    iOmxComponent.SetConfig = OmxComponentAacEncoderAO::BaseComponentSetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentAacEncoderAO::BaseComponentGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentAacEncoderAO::BaseComponentGetState;
+    iOmxComponent.UseBuffer = OmxComponentAacEncoderAO::BaseComponentUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentAacEncoderAO::BaseComponentAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentAacEncoderAO::BaseComponentFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentAacEncoderAO::BaseComponentEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentAacEncoderAO::BaseComponentFillThisBuffer;
+#endif
+
+    iOmxComponent.SetCallbacks = OmxComponentAacEncoderAO::BaseComponentSetCallbacks;
+    iOmxComponent.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
+    iOmxComponent.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
+    iOmxComponent.nVersion.s.nRevision = SPECREVISION;
+    iOmxComponent.nVersion.s.nStep = SPECSTEP;
+
+    // PV capability
+    iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
+
+    if (ipAppPriv)
+    {
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
+    if (NULL == ipAppPriv)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
+    {
+        return Status;
+    }
+
+    /** Domain specific section for the ports */
+    /* Input port is raw/pcm for AAC encoder */
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"raw";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDir = OMX_DirInput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_INPUT_BUFFER_AAC_ENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize = INPUT_BUFFER_SIZE_AAC_ENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+
+    /* Output port is aac format for AAC encoder */
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"audio/mpeg";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDir = OMX_DirOutput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_OUTPUT_BUFFER_AAC_ENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferSize = OUTPUT_BUFFER_SIZE_AAC_ENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+    //Default values for PCM input audio param port
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.nChannels = 2;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.eNumData = OMX_NumericalDataSigned;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.bInterleaved = OMX_TRUE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.nBitPerSample = 16;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.nSamplingRate = 44100;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.ePCMMode = OMX_AUDIO_PCMModeLinear;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
+
+    //Default values for AAC output audio param port
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nChannels = 2;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nSampleRate = 48000;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nBitRate = 128000;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nAudioBandWidth = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nFrameLength = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nAACtools = OMX_AUDIO_AACToolAll;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nAACERtools = OMX_AUDIO_AACERNone;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.eAACProfile = OMX_AUDIO_AACObjectLC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.eChannelMode = OMX_AUDIO_ChannelModeStereo;
+
+
+    iPortTypesParam.nPorts = 2;
+    iPortTypesParam.nStartPortNumber = 0;
+
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+
+    SetHeader(&pInPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+    pInPort->AudioParam.nPortIndex = 0;
+    pInPort->AudioParam.nIndex = 0;
+    pInPort->AudioParam.eEncoding = OMX_AUDIO_CodingPCM;
+
+    SetHeader(&pOutPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+    pOutPort->AudioParam.nPortIndex = 1;
+    pOutPort->AudioParam.nIndex = 0;
+    pOutPort->AudioParam.eEncoding = OMX_AUDIO_CodingAAC;
+
+    if (ipAacEnc)
+    {
+        OSCL_DELETE(ipAacEnc);
+        ipAacEnc = NULL;
+    }
+
+    ipAacEnc = OSCL_NEW(OmxAacEncoder, ());
+    if (NULL == ipAacEnc)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    iOutputFrameLength = OUTPUTBUFFER_SIZE;
+
+
+#if PROXY_INTERFACE
+
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+
+#endif
+    return OMX_ErrorNone;
+}
+
+
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	* \param Component, the component to be disposed
+	*/
+
+OMX_ERRORTYPE OmxComponentAacEncoderAO::DestroyComponent()
+{
+    if (iIsInit != OMX_FALSE)
+    {
+        ComponentDeInit();
+    }
+
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipAacEnc)
+    {
+        OSCL_DELETE(ipAacEnc);
+        ipAacEnc = NULL;
+    }
+
+    if (ipAppPriv)
+    {
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+
+/* This routine will extract the input timestamp from the input buffer */
+void OmxComponentAacEncoderAO::SyncWithInputTimestamp()
+{
+    iCurrentFrameTS.SetFromInputTimestamp(iFrameTimestamp);
+}
+
+
+void OmxComponentAacEncoderAO::ProcessData()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ProcessData IN"));
+
+    QueueType* pInputQueue  = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    ComponentPortType* pInPort  = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    OMX_COMPONENTTYPE* pHandle  = &iOmxComponent;
+
+    OMX_U8*	 pOutBuffer;
+    OMX_U32	 OutputLength;
+    OMX_S32  EncodeReturn;
+
+    OMX_U32 TempInputBufferSize = (2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
+
+    if ((!iIsInputBufferEnded) || iEndofStream)
+    {
+        //Check whether prev output bufer has been released or not
+        if (OMX_TRUE == iNewOutBufRequired)
+        {
+            //Check whether a new output buffer is available or not
+            if (0 == (GetQueueNumElem(pOutputQueue)))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ProcessData OUT output buffer unavailable"));
+                return;
+            }
+
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer->nFilledLen = 0;
+            iNewOutBufRequired = OMX_FALSE;
+
+            //Set the current timestamp to the output buffer timestamp
+            ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+        }
+
+        /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
+         * command and hMarkTargetComponent as given by the specifications
+         */
+        if (ipMark != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipMark = NULL;
+        }
+
+        if (ipTargetComponent != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
+            ipTargetComponent = NULL;
+
+        }
+        //Mark buffer code ends here
+
+
+        if ((iTempInputBufferLength > 0) &&
+                ((iInputCurrLength + iTempInputBufferLength) <= TempInputBufferSize))
+        {
+            oscl_memcpy(&ipTempInputBuffer[iTempInputBufferLength], ipFrameDecodeBuffer, iInputCurrLength);
+            iInputCurrLength += iTempInputBufferLength;
+            iTempInputBufferLength = 0;
+            ipFrameDecodeBuffer = ipTempInputBuffer;
+        }
+
+        if ((iInputCurrLength >= iInputFrameLength) || (OMX_TRUE == iEndofStream))
+        {
+            pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
+            OutputLength = 0;
+
+            EncodeReturn = ipAacEnc->AacEncodeFrame(pOutBuffer,
+                                                    &OutputLength,
+                                                    ipFrameDecodeBuffer,
+                                                    iInputCurrLength);
+
+
+            ipOutputBuffer->nFilledLen += OutputLength;
+            ipOutputBuffer->nOffset = 0;
+
+            if (OutputLength > 0)
+            {
+                iCurrentFrameTS.UpdateTimestamp((iInputFrameLength >> 1));
+            }
+
+
+            /* If EOS flag has come from the client & there are no more
+             * input buffers to decode, send the callback to the client
+             */
+            if (OMX_TRUE == iEndofStream)
+            {
+                if ((0 == OutputLength) || (OMX_TRUE != EncodeReturn))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ProcessData EOS callback send"));
+
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventBufferFlag,
+                     1,
+                     OMX_BUFFERFLAG_EOS,
+                     NULL);
+
+                    iEndofStream = OMX_FALSE;
+
+                    ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ProcessData OUT"));
+
+                    return;
+                }
+            }
+
+
+            if (OMX_TRUE == EncodeReturn)
+            {
+                if (iInputCurrLength >= iInputFrameLength)
+                {
+                    iInputCurrLength -= iInputFrameLength;
+                }
+                else
+                {
+                    iInputCurrLength = 0;
+                }
+
+                if (0 == iInputCurrLength)
+                {
+                    if (ipInputBuffer)
+                    {
+                        //Input bytes consumed now, return the buffer
+                        ipInputBuffer->nFilledLen = 0;
+                        ReturnInputBuffer(ipInputBuffer, pInPort);
+                        ipInputBuffer = NULL;
+                    }
+                    iIsInputBufferEnded = OMX_TRUE;
+                }
+                else if (iInputCurrLength >= iInputFrameLength)
+                {
+                    //Do not return the input buffer in case it has more than one frame data to encode
+                    ipFrameDecodeBuffer += iInputFrameLength;
+                }
+                else
+                {
+                    /* If there are some remainder bytes out of the last buffer, copy into a temp buffer
+                     * to be used in next decode cycle and return the existing input buffer*/
+                    oscl_memmove(ipTempInputBuffer, &ipFrameDecodeBuffer[iInputFrameLength], iInputCurrLength);
+                    iTempInputBufferLength = iInputCurrLength;
+
+                    if (ipInputBuffer)
+                    {
+                        ipInputBuffer->nFilledLen = 0;
+                        ReturnInputBuffer(ipInputBuffer, pInPort);
+                        ipInputBuffer = NULL;
+                    }
+                    iIsInputBufferEnded = OMX_TRUE;
+                    iInputCurrLength = 0;
+                }
+            }
+            //In case of error, discard the bitstream and report data corruption error via callback
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ProcessData ErrorStreamCorrupt callback send"));
+
+                if (ipInputBuffer)
+                {
+                    ipInputBuffer->nFilledLen = 0;
+                    ReturnInputBuffer(ipInputBuffer, pInPort);
+                    ipInputBuffer = NULL;
+                }
+                iIsInputBufferEnded = OMX_TRUE;
+                iInputCurrLength = 0;
+
+                (*(ipCallbacks->EventHandler))
+                (pHandle,
+                 iCallbackData,
+                 OMX_EventError,
+                 OMX_ErrorStreamCorrupt,
+                 0,
+                 NULL);
+            }
+        }
+        else
+        {
+            oscl_memmove(ipTempInputBuffer, &ipFrameDecodeBuffer[iInputFrameLength], iInputCurrLength);
+            iTempInputBufferLength = iInputCurrLength;
+
+            if (ipInputBuffer)
+            {
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
+                ipInputBuffer = NULL;
+            }
+            iIsInputBufferEnded = OMX_TRUE;
+            iInputCurrLength = 0;
+        }
+
+
+        /* Send the output buffer back when it has become full*/
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < (iOutputFrameLength))
+        {
+            //Attach the end of frame flag while sending out the output buffer
+            ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+        }
+
+
+        /* If there is some more processing left with current buffers, re-schedule the AO
+         * Do not go for more than one round of processing at a time.
+         * This may block the AO longer than required.
+         */
+        if (((iInputCurrLength != 0) || (GetQueueNumElem(pInputQueue) > 0))
+                && ((GetQueueNumElem(pOutputQueue) > 0) || (OMX_FALSE == iNewOutBufRequired)))
+        {
+            RunIfNotReady();
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ProcessData OUT"));
+    return;
+}
+
+
+//Not implemented & supported in case of base profile components
+
+void OmxComponentAacEncoderAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
+{
+    *aRoleString = (OMX_STRING)"audio_encoder.aac";
+}
+
+
+//Component constructor
+OmxComponentAacEncoderAO::OmxComponentAacEncoderAO()
+{
+    ipAacEnc = NULL;
+    iInputFrameLength = 0;
+    iOutputFrameLength = 0;
+
+    if (!IsAdded())
+    {
+        AddToScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : constructed"));
+}
+
+
+//Active object destructor
+OmxComponentAacEncoderAO::~OmxComponentAacEncoderAO()
+{
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : destructed"));
+}
+
+
+/** The Initialization function
+ */
+OMX_ERRORTYPE OmxComponentAacEncoderAO::ComponentInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ComponentInit IN"));
+
+    OMX_BOOL Status = OMX_TRUE;
+
+    if (OMX_TRUE == iIsInit)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ComponentInit error incorrect operation"));
+        return OMX_ErrorIncorrectStateOperation;
+    }
+    iIsInit = OMX_TRUE;
+
+    //aac encoder lib init
+    if (!iCodecReady)
+    {
+        Status = ipAacEnc->AacEncInit(ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode,
+                                      ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam,
+                                      &iInputFrameLength);
+
+        iCodecReady = OMX_TRUE;
+
+        iCurrentFrameTS.SetParameters(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAacParam.nSampleRate, (iInputFrameLength >> 1));
+    }
+
+    iInputCurrLength = 0;
+
+    if (OMX_TRUE == Status)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ComponentInit OUT"));
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : Error ComponentInit, OUT"));
+        return OMX_ErrorInvalidComponent;
+    }
+}
+
+
+
+/** This function is called upon a transition to the idle or invalid state.
+ *  Also it is called by the ComponentDestructor() function
+ */
+OMX_ERRORTYPE OmxComponentAacEncoderAO::ComponentDeInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ComponentDeInit IN"));
+
+    iIsInit = OMX_FALSE;
+
+    if (iCodecReady)
+    {
+        ipAacEnc->AacEncDeinit();
+        iCodecReady = OMX_FALSE;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAacEncoderAO : ComponentDeInit OUT"));
+
+    return OMX_ErrorNone;
+
+}
+
+
+/* A component specific routine called from BufferMgmtWithoutMarker */
+void OmxComponentAacEncoderAO::ProcessInBufferFlag()
+{
+    iIsInputBufferEnded = OMX_FALSE;
+}
diff --git a/codecs_v2/omx/omx_amr/Android.mk b/codecs_v2/omx/omx_amr/Android.mk
index c66db3c..40b95b1 100644
--- a/codecs_v2/omx/omx_amr/Android.mk
+++ b/codecs_v2/omx/omx_amr/Android.mk
@@ -3,36 +3,39 @@
 
 LOCAL_SRC_FILES := \
 	src/amr_decode_frame.cpp \
-	src/omx_amr_component.cpp \
-	src/d_homing.cpp
-
+ 	src/omx_amr_component.cpp \
+ 	src/d_homing.cpp
 
 
 LOCAL_MODULE := libomx_amr_component_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/src \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/amr_nb/dec/src \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/amr_nb/dec/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/amr_nb/common/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/common/dec/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/amr_wb/common/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/amr_wb/dec/include \
-	$(PV_TOP)//codecs_v2/omx/omx_amr/../../audio/gsm_amr/amr_wb/dec/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_amr/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_amr/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/omx/omx_baseclass/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/common/dec/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/common/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/dec/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_wb/dec/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/amr_dec.h \
-	include/omx_amr_component.h \
-	include/d_homing.h
+ 	include/omx_amr_component.h \
+ 	include/d_homing.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_amr/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_amr/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..5e5b66c
--- /dev/null
+++ b/codecs_v2/omx/omx_amr/build/make_multithreaded/local.mk
@@ -0,0 +1,38 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_amr_component_lib
+
+XINCDIRS += \
+        ../../../../../extern_libs_v2/khronos/openmax/include \
+        ../../../../omx/omx_baseclass/include \
+        ../../../../audio/gsm_amr/amr_nb/dec/src \
+        ../../../../audio/gsm_amr/amr_nb/dec/include \
+        ../../../../audio/gsm_amr/amr_nb/common/include \
+        ../../../../audio/gsm_amr/common/dec/include \
+        ../../../../audio/gsm_amr/amr_wb/common/include \
+        ../../../../audio/gsm_amr/amr_wb/dec/include \
+        ../../../../audio/gsm_amr/amr_wb/dec/src
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := amr_decode_frame.cpp \
+	omx_amr_component.cpp \
+	d_homing.cpp
+
+
+HDRS := amr_dec.h \
+	omx_amr_component.h \
+	d_homing.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_amr/build/make_multithreaded/makefile b/codecs_v2/omx/omx_amr/build/make_multithreaded/makefile
deleted file mode 100644
index a0de232..0000000
--- a/codecs_v2/omx/omx_amr/build/make_multithreaded/makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_amr_component_lib
-
-
-
-XINCDIRS += \
-    -I ../../../../../extern_libs_v2/khronos/openmax/include \
-    -I ../../../../audio/gsm_amr/amr_nb/dec/src \
-    -I ../../../../audio/gsm_amr/amr_nb/dec/include \
-    -I ../../../../audio/gsm_amr/amr_nb/common/include \
-    -I ../../../../audio/gsm_amr/common/dec/include \
-    -I ../../../../audio/gsm_amr/amr_wb/common/include \
-    -I ../../../../audio/gsm_amr/amr_wb/dec/include \
-    -I ../../../../audio/gsm_amr/amr_wb/dec/src
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  amr_decode_frame.cpp \
-    omx_amr_component.cpp \
-    d_homing.cpp
-
-
-HDRS =  amr_dec.h \
-    omx_amr_component.h \
-    d_homing.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_amr/include/amr_dec.h b/codecs_v2/omx/omx_amr/include/amr_dec.h
index 01bc83e..58c04f3 100644
--- a/codecs_v2/omx/omx_amr/include/amr_dec.h
+++ b/codecs_v2/omx/omx_amr/include/amr_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,8 +39,6 @@
 #endif
 
 
-//Taken this value from iFrameSizeVector size in fileinput node
-#define TOC_TABLE_SIZE				500
 
 class OmxAmrDecoder
 {
@@ -66,13 +64,13 @@
 
     private:
 
-        Frame_Type_3GPP GetFrameTypeLength(OMX_U8*, OMX_S32*);
+        Frame_Type_3GPP GetFrameTypeLength(OMX_U8* &ptr, OMX_S32 *pLength);
         void GetStartPointsForIETFCombinedMode(OMX_U8* aPtrIn, OMX_U32 aLength,
                                                OMX_U8* &aTocPtr, OMX_S32* aNumOfBytes);
 
         OMX_S16 iOmxInputFormat;
-        OMX_U8  iTocTable[TOC_TABLE_SIZE];
-        OMX_S32 iBytesProcessed;
+        OMX_U8  *iTocTablePtr;
+        OMX_S32 iAMRFramesinTOC;
 
 
         //CDecoder_AMR_NB* iAudioAmrDecoder;
@@ -82,6 +80,9 @@
         OMX_U32 iOutputFrameSize;
         OMX_BOOL iNarrowBandFlag;
 
+        OMX_S16 iDecHomingFlag;
+        OMX_S16 iDecHomingFlagOld;
+
 };
 
 
diff --git a/codecs_v2/omx/omx_amr/include/d_homing.h b/codecs_v2/omx/omx_amr/include/d_homing.h
index 03503f9..8018f43 100644
--- a/codecs_v2/omx/omx_amr/include/d_homing.h
+++ b/codecs_v2/omx/omx_amr/include/d_homing.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/omx/omx_amr/include/d_homing.tab b/codecs_v2/omx/omx_amr/include/d_homing.tab
index bae2137..28969ff 100644
--- a/codecs_v2/omx/omx_amr/include/d_homing.tab
+++ b/codecs_v2/omx/omx_amr/include/d_homing.tab
@@ -24,7 +24,7 @@
 #include "bitno_tab.h"
 
 
-static const Word16 dhf_MR475[PRMNO_MR475] =
+const Word16 dhf_MR475[PRMNO_MR475] =
 {
     0x00F8,
     0x009D,
@@ -45,7 +45,7 @@
     0x0003 
 };
    
-static const Word16 dhf_MR515[PRMNO_MR515] =
+const Word16 dhf_MR515[PRMNO_MR515] =
 {
     0x00F8,
     0x009D,
@@ -68,7 +68,7 @@
     0x001F 
 };
 
-static const Word16 dhf_MR59[PRMNO_MR59] =
+const Word16 dhf_MR59[PRMNO_MR59] =
 {
     0x00F8,
     0x00E3,
@@ -91,7 +91,7 @@
     0x0037 
 };
 
-static const Word16 dhf_MR67[PRMNO_MR67] =
+const Word16 dhf_MR67[PRMNO_MR67] =
 {
     0x00F8,
     0x00E3,
@@ -114,7 +114,7 @@
     0x0000 
 };
 
-static const Word16 dhf_MR74[PRMNO_MR74] =
+const Word16 dhf_MR74[PRMNO_MR74] =
 {
     0x00F8,
     0x00E3,
@@ -137,7 +137,7 @@
     0x0000 
 };
 
-static const Word16 dhf_MR795[PRMNO_MR795] =
+const Word16 dhf_MR795[PRMNO_MR795] =
 {
     0x00C2,
     0x00E3,
@@ -164,7 +164,7 @@
     0x0001 
 };
 
-static const Word16 dhf_MR102[PRMNO_MR102] =
+const Word16 dhf_MR102[PRMNO_MR102] =
 {
     0x00F8,
     0x00E3,
@@ -207,7 +207,7 @@
     0x0030 
 };
 
-static const Word16 dhf_MR122[PRMNO_MR122] =
+const Word16 dhf_MR122[PRMNO_MR122] =
 {
     0x0004,
     0x002A,
@@ -272,7 +272,8 @@
 
 /* overall table with the parameters of the
    decoder homing frames for all modes */
-static const Word16 *dhf[] =
+// extra const needed for symbian
+const Word16* const dhf[] =
 {
    dhf_MR475,
    dhf_MR515,
diff --git a/codecs_v2/omx/omx_amr/include/omx_amr_component.h b/codecs_v2/omx/omx_amr/include/omx_amr_component.h
index 37b4e66..8a8998b 100644
--- a/codecs_v2/omx/omx_amr/include/omx_amr_component.h
+++ b/codecs_v2/omx/omx_amr/include/omx_amr_component.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,381 +26,62 @@
 #ifndef OMX_AMR_COMPONENT_H_INCLUDED
 #define OMX_AMR_COMPONENT_H_INCLUDED
 
-#ifndef OMX_Component_h
-#include "omx_component.h"
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
 #endif
 
 #ifndef AMR_DEC_H_INCLUDED
 #include "amr_dec.h"
 #endif
 
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PV_OMX_QUEUE_H_INCLUDED
-#include "pv_omx_queue.h"
-#endif
-
-#ifndef PV_OMXCORE_H_INCLUDED
-#include "pv_omxcore.h"
-#endif
-
-#define OMX_PORT_INPUTPORT_INDEX OMX_DirInput
-#define OMX_PORT_OUTPUTPORT_INDEX OMX_DirOutput
-#define OMX_PORT_ALLPORT_INDEX -1
-
-
 #define INPUT_BUFFER_SIZE_AMR 2000
 #define OUTPUT_BUFFER_SIZE_AMR 640
 
 #define NUMBER_INPUT_BUFFER_AMR  10
-#define NUMBER_OUTPUT_BUFFER_AMR  2
+#define NUMBER_OUTPUT_BUFFER_AMR  9
 
 
-/* Application's private data */
-typedef struct AmrPrivateType
-{
-    OMX_HANDLETYPE AmrHandle;
-
-}AmrPrivateType;
-
-
-/**
- * This is the Component template from which all
- * other Component instances are factored by the core.
- */
-
-
-/**
- * The structure for port Type.
- */
-typedef struct AmrComponentPortType
-{
-    /** @param pBuffer An array of pointers to buffer headers. */
-    OMX_BUFFERHEADERTYPE** pBuffer;
-    /** @param BufferState The State of the Buffer whether assigned or allocated */
-    OMX_U32* BufferState;
-    /** @param NumAssignedBuffers Number of buffer assigned on each port */
-    OMX_U32 NumAssignedBuffers;
-    /** @param pBufferQueue queue for buffer to be processed by the port */
-    QueueType* pBufferQueue;
-    OMX_STATETYPE TransientState;
-    /** @param BufferUnderProcess  Boolean variables indicate whether the port is processing any buffer */
-    OMX_BOOL BufferUnderProcess;
-    OMX_PARAM_PORTDEFINITIONTYPE PortParam;
-    /** @param NumBufferFlushed Number of buffer Flushed */
-    OMX_U32 NumBufferFlushed;
-    /** @param IsPortFlushed Boolean variables indicate port is being flushed at the moment */
-    OMX_BOOL IsPortFlushed;
-
-    OMX_AUDIO_PARAM_PORTFORMATTYPE AudioParam;
-    OMX_AUDIO_PARAM_PCMMODETYPE AudioPcmMode;
-    OMX_AUDIO_PARAM_AMRTYPE AudioAmrParam;
-
-    //Added these flags as a replacement of semaphores on win32 platform
-    OMX_BOOL LoadedToIdleFlag;
-    OMX_BOOL IdleToLoadedFlag;
-
-} AmrComponentPortType;
-
-
-class OpenmaxAmrAO : public OsclActiveObject
+class OpenmaxAmrAO : public OmxComponentAudio
 {
     public:
 
         OpenmaxAmrAO();
         ~OpenmaxAmrAO();
 
-        /** Component entry points declarations without proxy interface*/
-        static OMX_ERRORTYPE BaseComponentGetComponentVersion(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STRING pComponentName,
-            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
-            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
-            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
 
-        static OMX_ERRORTYPE BaseComponentGetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
 
-        static OMX_ERRORTYPE BaseComponentSetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
 
-        static OMX_ERRORTYPE BaseComponentGetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_INOUT OMX_PTR pComponentConfigStructure);
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+        void ProcessData();
 
-        static OMX_ERRORTYPE BaseComponentSetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
+        void DecodeWithoutMarker();
+        void DecodeWithMarker();
 
-        static OMX_ERRORTYPE BaseComponentGetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
+        void ComponentBufferMgmtWithoutMarker();
+        void SyncWithInputTimestamp();
+        void ProcessInBufferFlag();
 
-        static OMX_ERRORTYPE BaseComponentGetState(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STATETYPE* pState);
-
-        static OMX_ERRORTYPE BaseComponentUseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentAllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        static OMX_ERRORTYPE BaseComponentFreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_U32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        static OMX_ERRORTYPE BaseComponentComponentDeInit(
-            OMX_IN  OMX_HANDLETYPE hComponent);
-
-        static OMX_ERRORTYPE BaseComponentEmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentFillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        static void AmrComponentGetRolesOfComponent(OMX_STRING* aRoleString);
-
-        /*NON STATIC COUNTERPARTS OF STATIC MEMBER API'S */
-
-        OMX_ERRORTYPE GetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
-
-        OMX_ERRORTYPE SetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        void ResetComponent();
 
         OMX_ERRORTYPE GetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE SetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        OMX_ERRORTYPE GetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        void GetState(OMX_OUT OMX_STATETYPE* pState);
-
-        OMX_ERRORTYPE UseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        OMX_ERRORTYPE AllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        OMX_ERRORTYPE FreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_S32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        OMX_ERRORTYPE EmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE FillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData);
-        OMX_ERRORTYPE DestroyComponent();
-
-        OMX_PTR GetOmxHandle()
-        {
-            return &iOmxComponent;
-        };
-
-        /*OTHER PROCESSING FUNCTIONS */
-
-        void AmrComponentBufferMgmtFunction();
-        void AmrBufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE*);
-        void AmrDecodeWithoutMarker();
-        void AmrDecodeWithMarker(OMX_BUFFERHEADERTYPE*);
-        OMX_BOOL AmrComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer);
-
-        OMX_ERRORTYPE AmrComponentMessageHandler(CoreMessage* Message);
-        OMX_ERRORTYPE AmrComponentDoStateSet(OMX_U32);
-
-        OMX_ERRORTYPE AmrComponentDisablePort(OMX_S32 PortIndex);
-        void AmrComponentDisableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE AmrComponentEnablePort(OMX_S32 PortIndex);
-        void AmrComponentEnableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE AmrComponentFlushPort(OMX_S32 PortIndex);
-        void AmrComponentSetPortFlushFlag(OMX_S32, OMX_S32 index, OMX_BOOL value);
-        void AmrComponentSetNumBufferFlush(OMX_S32, OMX_S32 index, OMX_S32 value);
-
-        OMX_S32 AmrComponentPanic();
-
-        void AmrComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, AmrComponentPortType *pPort);
-        void AmrComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, AmrComponentPortType *pPort);
-
-        OMX_ERRORTYPE AmrComponentInit();
-        OMX_ERRORTYPE AmrComponentDeInit();
-
-        OMX_ERRORTYPE AmrComponentTunnelRequest(
-            OMX_IN  OMX_HANDLETYPE hComp,
-            OMX_IN  OMX_U32 nPort,
-            OMX_IN  OMX_HANDLETYPE hTunneledComp,
-            OMX_IN  OMX_U32 nTunneledPort,
-            OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
-
-        OMX_ERRORTYPE BaseComponentParameterSanityCheck(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_PTR pStructure,
-            OMX_IN  size_t size);
-
-        void SetHeader(OMX_PTR aheader, OMX_U32 asize);
-        OMX_ERRORTYPE CheckHeader(OMX_PTR aheader, OMX_U32 asize);
-
-        //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-        OMX_BOOL			iBufferExecuteFlag;
-        AmrPrivateType*	ipAppPriv;
-
-
     private:
 
-        PVLogger* iLogger;
-
-        void Run();
         void CheckForSilenceInsertion();
         void DoSilenceInsertion();
 
-        OMX_CALLBACKTYPE*	ipCallbacks;
-        OMX_PTR				iCallbackData;
-        OMX_STATETYPE		iState;
-
-        CoreDescriptorType* ipCoreDescriptor;
-        OMX_U32				iNumInputBuffer;
-
-        OMX_U8*				ipFrameDecodeBuffer;
-        OMX_BOOL			iPartialFrameAssembly;
-        OMX_BOOL			iIsInputBufferEnded;
-        OMX_BOOL			iEndofStream;
-        OMX_U8*				ipTempInputBuffer;
-        OMX_U32				iTempInputBufferFilledLength;
-        OMX_COMPONENTTYPE*	ipTargetComponent;
-        OMX_PTR				iTargetMarkData;
-        OMX_COMPONENTTYPE*	ipTempTargetComponent;
-        OMX_PTR				iTempTargetMarkData;
-        OMX_BOOL			iMarkPropagate;
-        OMX_BOOL			iNewInBufferRequired;
-        OMX_BOOL			iNewOutBufRequired;
-        OMX_U32				iTempConsumedLength;
-        OMX_U32				iOutBufferCount;
-        OMX_BOOL			iCodecReady;
-        OMX_U8*				ipInputCurrBuffer;
-        OMX_U32				iInputCurrLength;
-        OMX_S32				iFrameCount;
-        OMX_BOOL			iStateTransitionFlag;
-        OMX_BOOL			iFlushPortFlag;
-        OMX_BOOL				iEndOfFrameFlag;
-        OMX_BUFFERHEADERTYPE*	ipAmrInputBuffer;
-        OMX_BUFFERHEADERTYPE*	ipAmrOutputBuffer;
-
-        OMX_U32					iOutputFrameLength;
-
-        OMX_COMPONENTTYPE iOmxComponent;	// structure
-        OMX_U32			iNumPorts;
-
-        PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
-
-        //The ports of the component
-        AmrComponentPortType** ipPorts;
-        //Indicate whether component has been already initialized */
-        OMX_BOOL iIsInit;
-        //OpenMAX standard parameter that contains a short description of the available ports
-        OMX_PORT_PARAM_TYPE iPortTypesParam;
-        OMX_U32 iGroupPriority;
-        //ID of a group of components that share the same logical chain
-        OMX_U32 iGroupID;
-        //Roles of the component
-        OMX_U8 iComponentRole[OMX_MAX_STRINGNAME_SIZE];
-        //This field holds the private data associated with a mark request, if any
-        OMX_MARKTYPE* ipMark;
-
-        OMX_BOOL				iFirstFragment;
-        OMX_BOOL				iResizePending;
-        OMX_TICKS				iFrameTimestamp;
         OMX_TICKS				iCurrentTimestamp;
-        OMX_BOOL				iRepositionFlag;
-        //Without marker flags and variables
-        OMX_S32					iInputBufferRemainingBytes;
         OMX_S32 				iPreviousFrameLength;
-
-        OMX_BOOL				iSilenceInsertionInProgress;
-        OMX_U32					iSilenceFramesNeeded;
         OMX_U32					iZeroFramesNeeded;
 
-        //Amr specific structure
         OmxAmrDecoder* ipAmrDec;
 };
 
-
-
 #endif // OMX_AMR_COMPONENT_H_INCLUDED
diff --git a/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp b/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp
index 7bd1bec..ff2cb27 100644
--- a/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp
+++ b/codecs_v2/omx/omx_amr/src/amr_decode_frame.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -85,12 +85,30 @@
     , 1		// AMR Frame No Data
 };
 
-
+static const OMX_S32 IF2FrameSize[16] =
+{
+    13		// AMR 4.75 Kbps
+    , 14		// AMR 5.15 Kbps
+    , 16		// AMR 5.90 Kbps
+    , 18		// AMR 6.70 Kbps
+    , 19		// AMR 7.40 Kbps
+    , 21		// AMR 7.95 Kbps
+    , 26		// AMR 10.2 Kbps
+    , 31		// AMR 12.2 Kbps
+    , 6		// AMR Frame SID
+    , 6		// AMR Frame GSM EFR SID
+    , 6		// AMR Frame TDMA EFR SID
+    , 6		// AMR Frame PDC EFR SID
+    , 1		// future use; 0 length but set to 1 to skip the frame type byte
+    , 1		// future use; 0 length but set to 1 to skip the frame type byte
+    , 1		// future use; 0 length but set to 1 to skip the frame type byte
+    , 1		// AMR Frame No Data
+};
 
 OmxAmrDecoder::OmxAmrDecoder()
 {
     iOmxInputFormat = PV_AMR_ETS;
-    iBytesProcessed = 0;
+    iAMRFramesinTOC = 0;
     iAmrInitFlag = 0;
     iNarrowBandFlag = OMX_TRUE;
 
@@ -99,6 +117,10 @@
 
     iCodecExternals = NULL;
     iAudioAmrDecoder = NULL;
+    iTocTablePtr = NULL;
+    /* Initialize decoder homing flags */
+    iDecHomingFlag = 0;
+    iDecHomingFlagOld = 1;
 }
 
 /* Decoder Initialization function */
@@ -226,7 +248,10 @@
     {
         iAudioAmrDecoder->ResetDecoderL();
     }
+    iAMRFramesinTOC = 0;
 }
+
+
 /* Find the start point & size of TOC table in case of IETF_Combined format */
 void OmxAmrDecoder::GetStartPointsForIETFCombinedMode
 (OMX_U8* aPtrIn, OMX_U32 aLength, OMX_U8* &aTocPtr, OMX_S32* aNumOfBytes)
@@ -252,9 +277,6 @@
                                        OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer,
                                        OMX_BOOL* aResizeFlag)
 {
-    /* Initialize decoder homing flags */
-    static OMX_S16 DecHomingFlag = 0;        /* Decoder currently not homed  */
-    static OMX_S16 DecHomingFlagOld = 1;    /* Decoder was previously homed */
     OMX_BOOL Status = OMX_TRUE;
 
     *aResizeFlag = OMX_FALSE;
@@ -264,7 +286,6 @@
 
     /* 3GPP Frame Type Buffer */
     Frame_Type_3GPP FrameType3gpp;
-    OMX_U8* pTocPtr;
 
     /* Takes care of extra bytes above the decoded ones
      * e.g. toc length for ietf_combined, frame header length &
@@ -274,7 +295,7 @@
 
     /* Reset speech_bits buffer pointer */
     OMX_U8* pSpeechBits = *aInBuffer;
-
+    OMX_U8 *pTocPtr;
     //ETS mode requires a 16-bit pointer
     OMX_S16* pEtsSpeechBits = (OMX_S16*) * aInBuffer;
 
@@ -283,23 +304,24 @@
     {
         if ((PV_AMR_IETF_COMBINED == iOmxInputFormat) || (PV_AMRWB_IETF_PAYLOAD == iOmxInputFormat))
         {
-            if (0 == iBytesProcessed)
+            if (0 == iAMRFramesinTOC)
             {
                 pTocPtr = NULL;
                 GetStartPointsForIETFCombinedMode(pSpeechBits, *aInBufSize,
-                                                  pTocPtr, &iBytesProcessed);
-                pSpeechBits += iBytesProcessed;
-                FrameBytesProcessed = iBytesProcessed;
-                oscl_memcpy(iTocTable, pTocPtr, iBytesProcessed);
-                iBytesProcessed--;
+                                                  pTocPtr, &iAMRFramesinTOC);
+                pSpeechBits += iAMRFramesinTOC;
+                FrameBytesProcessed = iAMRFramesinTOC;
+
+                iTocTablePtr = pTocPtr;
+                iAMRFramesinTOC--; // ctr of amr frames
             }
             else
             {
-                iBytesProcessed--;
+                iAMRFramesinTOC--;
                 FrameBytesProcessed = 0;
             }
 
-            FrameType3gpp = GetFrameTypeLength(iTocTable, &FrameLength);
+            FrameType3gpp = GetFrameTypeLength(iTocTablePtr, &FrameLength);
         }
         else //iOmxInputFormat == PV_AMR_IETF or (PV_AMRWB_IETF == iOmxInputFormat)
         {
@@ -316,65 +338,92 @@
             FrameType3gpp = GetFrameTypeLength(pSpeechBits, &FrameLength);
         }
 
-        /* Set up pointer to the start of frame to be decoded */
-
-        iCodecExternals->frame_type = (uint32)FrameType3gpp;
-        iCodecExternals->mode = (uint32)FrameType3gpp;
-        iCodecExternals->pInputBuffer = (uint8*) pSpeechBits;
-        iCodecExternals->pOutputBuffer = (int16*) aOutputBuffer;
-
-        ByteOffset = iAudioAmrDecoder->ExecuteL(iCodecExternals);
-
-        if (PV_GSMAMR_DECODE_STATUS_ERR == ByteOffset)
-        {
-            Status = OMX_FALSE;
-            printf("DEECODER RETURNED FALSE \n");
-        }
-
+        // check if the frame size exceeds buffer boundaries
         if ((FrameLength + FrameBytesProcessed) <= (OMX_S32) *aInBufSize)
         {
-            *aInBufSize -= (FrameLength + FrameBytesProcessed);
-            *aInBuffer += (FrameLength + FrameBytesProcessed);
-            *aOutputLength = iOutputFrameSize;
+            /* Set up pointer to the start of frame to be decoded */
+
+            iCodecExternals->frame_type = (uint32)FrameType3gpp;
+            iCodecExternals->mode = (uint32)FrameType3gpp;
+            iCodecExternals->pInputBuffer = (uint8*) pSpeechBits;
+            iCodecExternals->pOutputBuffer = (int16*) aOutputBuffer;
+
+            ByteOffset = iAudioAmrDecoder->ExecuteL(iCodecExternals);
+
+            if (PV_GSMAMR_DECODE_STATUS_ERR == ByteOffset)
+            {
+                *aInBufSize = 0;
+                *aOutputLength = 0;
+                iAMRFramesinTOC = 0; // make sure the TOC table (if necessary) gets initialized for the next time
+                Status = OMX_FALSE;
+            }
+            else
+            {
+                *aInBufSize -= (FrameLength + FrameBytesProcessed);
+                *aInBuffer += (FrameLength + FrameBytesProcessed);
+                *aOutputLength = iOutputFrameSize;
+                // in case of TOC, make sure that
+                // a) if no more data in the buffer and TOC indicates more data, reset TOC
+                // b) if TOC indicates no more data, and there is more data in the buffer, reset the buffer
+                if ((PV_AMR_IETF_COMBINED == iOmxInputFormat) || (PV_AMRWB_IETF_PAYLOAD == iOmxInputFormat))
+                {
+                    if ((0 == iAMRFramesinTOC) || (0 == *aInBufSize))
+                    {
+                        *aInBufSize = 0;
+                        iAMRFramesinTOC = 0;
+                    }
+                }
+
+            }
         }
         else
         {
             *aInBufSize = 0;
             *aOutputLength = 0;
+            iAMRFramesinTOC = 0; // make sure the TOC table (if necessary) gets initialized for the next time
+            Status = OMX_FALSE; // treat buffer overrun as an error
         }
 
     }
     else if (PV_AMR_IF2 == iOmxInputFormat)
     {
         FrameType3gpp = (Frame_Type_3GPP)(pSpeechBits[0] & 0xF);
+        FrameLength = IF2FrameSize[FrameType3gpp];
 
-        /* Set up pointer to the start of frame to be decoded */
-        iCodecExternals->frame_type = (uint32)FrameType3gpp;
-        iCodecExternals->mode = (uint32)FrameType3gpp;
-        iCodecExternals->pInputBuffer = (uint8*) pSpeechBits;
-        iCodecExternals->pOutputBuffer = (int16*) aOutputBuffer;
-
-        ByteOffset = iAudioAmrDecoder->ExecuteL(iCodecExternals);
-
-        if (PV_GSMAMR_DECODE_STATUS_ERR == ByteOffset)
+        // check if the frame size exceeds buffer boundaries
+        if ((FrameLength + FrameBytesProcessed) <= (OMX_S32) *aInBufSize)
         {
-            Status = OMX_FALSE;
-        }
+            /* Set up pointer to the start of frame to be decoded */
+            iCodecExternals->frame_type = (uint32)FrameType3gpp;
+            iCodecExternals->mode = (uint32)FrameType3gpp;
+            iCodecExternals->pInputBuffer = (uint8*) pSpeechBits;
+            iCodecExternals->pOutputBuffer = (int16*) aOutputBuffer;
 
-        //Frame type is a part of ByteOffset.
-        if (ByteOffset <= (OMX_S32) *aInBufSize)
-        {
-            *aInBufSize -= ByteOffset;
-            *aInBuffer += ByteOffset;
-            *aOutputLength = iOutputFrameSize;
+            ByteOffset = iAudioAmrDecoder->ExecuteL(iCodecExternals);
+
+            if (PV_GSMAMR_DECODE_STATUS_ERR == ByteOffset)
+            {
+                Status = OMX_FALSE;
+            }
+
+            if (ByteOffset <= (OMX_S32)*aInBufSize)
+            {
+                *aInBufSize -= ByteOffset;
+                *aInBuffer += ByteOffset;
+                *aOutputLength = iOutputFrameSize;
+            }
+            else
+            {
+                *aInBufSize = 0;
+                *aOutputLength = 0;
+                Status = OMX_FALSE;
+            }
         }
-        /* EOS has arrived & the data is less than a full frame,
-         * discard that data so that EOS callback can be send.
-         * This is done to pass BufferFlagTest conformance */
         else
         {
             *aInBufSize = 0;
             *aOutputLength = 0;
+            Status = OMX_FALSE; // treat buffer overrun as an error
         }
     }
     else if (PV_AMR_ETS == iOmxInputFormat)
@@ -425,16 +474,16 @@
         }
 
         /* if homed: check if this frame is another homing frame */
-        if (1 == DecHomingFlagOld)
+        if (1 == iDecHomingFlagOld)
         {
             /* only check until end of first subframe */
-            DecHomingFlag = decoder_homing_frame_test_first(
-                                (OMX_S16*) & pEtsSpeechBits[1],
-                                (enum Mode) FrameType3gpp);
+            iDecHomingFlag = decoder_homing_frame_test_first(
+                                 (OMX_S16*) & pEtsSpeechBits[1],
+                                 (enum Mode) FrameType3gpp);
         }
 
         /* produce encoder homing frame if homed & input=decoder homing frame */
-        if ((0 != DecHomingFlag) && (0 != DecHomingFlagOld))
+        if ((0 != iDecHomingFlag) && (0 != iDecHomingFlagOld))
         {
             for (ii = 0; ii < L_FRAME; ii++)
             {
@@ -459,20 +508,20 @@
         }
 
         /* if not homed: check whether current frame is a homing frame */
-        if (0 == DecHomingFlagOld)
+        if (0 == iDecHomingFlagOld)
         {
             /* check whole frame */
-            DecHomingFlag = decoder_homing_frame_test(
-                                (OMX_S16*) & pEtsSpeechBits[1],
-                                (enum Mode) FrameType3gpp);
+            iDecHomingFlag = decoder_homing_frame_test(
+                                 (OMX_S16*) & pEtsSpeechBits[1],
+                                 (enum Mode) FrameType3gpp);
         }
         /* reset decoder if current frame is a homing frame */
-        if (0 != DecHomingFlag)
+        if (0 != iDecHomingFlag)
         {
             iAudioAmrDecoder->ResetDecoderL();
         }
 
-        DecHomingFlagOld = DecHomingFlag;
+        iDecHomingFlagOld = iDecHomingFlag;
 
         //Input buffer requirement per frame is constant at ETS_INPUT_FRAME_SIZE
         *aInBufSize -= ETS_INPUT_FRAME_SIZE;
@@ -521,10 +570,10 @@
 
 
 /* Get Frame type for format == PVMF_AMR_IETF or PVMF_AMR_IETF_COMBINED and the WB counterparts*/
-Frame_Type_3GPP OmxAmrDecoder::GetFrameTypeLength(OMX_U8* aFrame, OMX_S32* aFrameLength)
+Frame_Type_3GPP OmxAmrDecoder::GetFrameTypeLength(OMX_U8* &aFrame, OMX_S32* aFrameLength)
 {
     Frame_Type_3GPP  FrameType3gpp;
-    OMX_S32 ii;
+
 
     FrameType3gpp = (Frame_Type_3GPP)((aFrame[0] >> 3) & 0x0F);
 
@@ -539,18 +588,18 @@
     }
 
 
+
     if (PV_AMR_IETF_COMBINED == iOmxInputFormat || PV_AMRWB_IETF_PAYLOAD == iOmxInputFormat)
     {
+        // move ptr for TOC
         aFrame++;
-        (*aFrameLength)--;
+        (*aFrameLength)--; // account for the 1 byte of length being not in the frame, but in the TOC
     }
-    else
+    else if ((PV_AMR_IETF == iOmxInputFormat) || (PV_AMRWB_IETF == iOmxInputFormat))
     {
-        for (ii = 0; ii < *aFrameLength; ii++)
-        {
-            aFrame[ii] = aFrame[ii+1];
-        }
+        aFrame++; // move ptr to data to skip the frame type/size field
     }
 
+
     return (FrameType3gpp);
 }
diff --git a/codecs_v2/omx/omx_amr/src/d_homing.cpp b/codecs_v2/omx/omx_amr/src/d_homing.cpp
index f5a628c..4f1c31a 100644
--- a/codecs_v2/omx/omx_amr/src/d_homing.cpp
+++ b/codecs_v2/omx/omx_amr/src/d_homing.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
 */
 
 #include "d_homing.h"
-const char d_homing_id[] = "@(#)$Id $" d_homing_h;
+//const char d_homing_id[] = "@(#)$Id $" d_homing_h;
 
 /*
 *****************************************************************************
@@ -53,7 +53,7 @@
 #include "d_homing.tab"
 
 /* get rid of compiler warning "`bitno' defined but never used" */
-static void* dummy[] = {(void *) bitno, (void *) dummy };
+//static void* dummy[] = { (void *) bitno, (void *) dummy };
 
 
 /*
@@ -108,6 +108,7 @@
     return !j;
 }
 
+
 /*
 *****************************************************************************
 *                         PUBLIC PROGRAM CODE
diff --git a/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp b/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp
index aae582f..4fb02c7 100644
--- a/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp
+++ b/codecs_v2/omx/omx_amr/src/omx_amr_component.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,18 +15,17 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#include "oscl_base.h"
 #include "pv_omxdefs.h"
-#include "oscl_types.h"
-#include <string.h>
 #include "omx_amr_component.h"
 
-extern OMX_U32 g_ComponentIndex; // this is determined outside the component
-
 #if PROXY_INTERFACE
-
 #include "omx_proxy_interface.h"
-extern ProxyApplication_OMX* pProxyTerm[];
+#endif
 
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
 #endif
 
 #define OMX_HALFRANGE_THRESHOLD 0x7FFFFFFF
@@ -34,9 +33,16 @@
 /**** Note that AMR sampling rate is always 8khz, so a frame of 20 ms always corresponds to 160 (16-bit) samples = 320 bytes */
 #define OMX_AMR_DEC_FRAME_INTERVAL 20
 
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
 // This function is called by OMX_GetHandle and it creates an instance of the amr component AO
-OMX_ERRORTYPE AmrOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
+OSCL_EXPORT_REF OMX_ERRORTYPE AmrOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     OpenmaxAmrAO* pOpenmaxAOType;
     OMX_ERRORTYPE Status;
 
@@ -50,7 +56,7 @@
     }
 
     //Call the construct component to initialize OMX types
-    Status = pOpenmaxAOType->ConstructComponent(pAppData);
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
 
     *pHandle = pOpenmaxAOType->GetOmxHandle();
 
@@ -59,8 +65,12 @@
 }
 
 // This function is called by OMX_FreeHandle when component AO needs to be destroyed
-OMX_ERRORTYPE AmrOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle)
+OSCL_EXPORT_REF OMX_ERRORTYPE AmrOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     // get pointer to component AO
     OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
 
@@ -73,35 +83,85 @@
     return OMX_ErrorNone;
 }
 
+#if DYNAMIC_LOAD_OMX_AMR_COMPONENT
+class AmrOmxSharedLibraryInterface: public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static AmrOmxSharedLibraryInterface *Instance()
+        {
+            static AmrOmxSharedLibraryInterface amromxinterface;
+            return &amromxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_AMRDEC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AmrOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AmrOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+    private:
+        AmrOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return AmrOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-OMX_ERRORTYPE OpenmaxAmrAO::ConstructComponent(OMX_PTR pAppData)
+OMX_ERRORTYPE OpenmaxAmrAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
 {
-    AmrComponentPortType* pInPort, *pOutPort;
-    OMX_U32 ii;
+    ComponentPortType* pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
 
     iNumPorts = 2;
     iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
     iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
     iOmxComponent.pApplicationPrivate = pAppData; // init the App data
 
 
 #if PROXY_INTERFACE
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
 
-    iOmxComponent.SendCommand = WrapperSendCommand;
-    iOmxComponent.GetParameter = WrapperGetParameter;
-    iOmxComponent.SetParameter = WrapperSetParameter;
-    iOmxComponent.GetConfig = WrapperGetConfig;
-    iOmxComponent.SetConfig = WrapperSetConfig;
-    iOmxComponent.GetExtensionIndex = WrapperGetExtensionIndex;
-    iOmxComponent.GetState = WrapperGetState;
-    iOmxComponent.UseBuffer = WrapperUseBuffer;
-    iOmxComponent.AllocateBuffer = WrapperAllocateBuffer;
-    iOmxComponent.FreeBuffer = WrapperFreeBuffer;
-    iOmxComponent.EmptyThisBuffer = WrapperEmptyThisBuffer;
-    iOmxComponent.FillThisBuffer = WrapperFillThisBuffer;
+    iOmxComponent.SendCommand = OpenmaxAmrAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OpenmaxAmrAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OpenmaxAmrAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OpenmaxAmrAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OpenmaxAmrAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OpenmaxAmrAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OpenmaxAmrAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OpenmaxAmrAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OpenmaxAmrAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OpenmaxAmrAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OpenmaxAmrAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OpenmaxAmrAO::BaseComponentProxyFillThisBuffer;
 
 #else
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
@@ -130,6 +190,9 @@
     iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
 
     if (ipAppPriv)
     {
@@ -137,60 +200,23 @@
         ipAppPriv = NULL;
     }
 
-    ipAppPriv = (AmrPrivateType*) oscl_malloc(sizeof(AmrPrivateType));
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
     if (NULL == ipAppPriv)
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    if (iNumPorts)
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
     {
-        if (ipPorts)
-        {
-            oscl_free(ipPorts);
-            ipPorts = NULL;
-        }
-
-        ipPorts = (AmrComponentPortType**) oscl_calloc(iNumPorts, sizeof(AmrComponentPortType*));
-        if (!ipPorts)
-        {
-            return OMX_ErrorInsufficientResources;
-        }
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii] = (AmrComponentPortType*) oscl_calloc(1, sizeof(AmrComponentPortType));
-            if (!ipPorts[ii])
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            ipPorts[ii]->TransientState = OMX_StateMax;
-            SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            ipPorts[ii]->PortParam.nPortIndex = ii;
-
-            /** Allocate and initialize buffer Queue */
-            ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-
-            if (NULL == ipPorts[ii]->pBufferQueue)
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            QueueInit(ipPorts[ii]->pBufferQueue);
-
-            ipPorts[ii]->LoadedToIdleFlag = OMX_FALSE;
-            ipPorts[ii]->IdleToLoadedFlag = OMX_FALSE;
-
-        }
-
-        AmrComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-        AmrComponentSetNumBufferFlush(iNumPorts, -1, OMX_FALSE);
+        return Status;
     }
 
     /** Domain specific section for the ports. */
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
-    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = "audio/mpeg";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"audio/mpeg";
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingAMR;
@@ -204,7 +230,7 @@
 
 
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
-    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = "raw";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"raw";
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
@@ -235,8 +261,8 @@
     iPortTypesParam.nPorts = 2;
     iPortTypesParam.nStartPortNumber = 0;
 
-    pInPort = (AmrComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    pOutPort = (AmrComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
     SetHeader(&pInPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
     pInPort->AudioParam.nPortIndex = 0;
@@ -248,61 +274,8 @@
     pOutPort->AudioParam.nIndex = 0;
     pOutPort->AudioParam.eEncoding = OMX_AUDIO_CodingPCM;
 
-    iCodecReady = OMX_FALSE;
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-    ipTempInputBuffer = NULL;
-    iTempInputBufferFilledLength = 0;
-    iNumInputBuffer = 0;
-    iPartialFrameAssembly = OMX_FALSE;
-    iEndofStream = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iNewOutBufRequired = OMX_TRUE;
-    iOutputFrameLength = OUTPUT_BUFFER_SIZE_AMR;
-    iRepositionFlag = OMX_FALSE;
     iInputBufferRemainingBytes = 0;
 
-    /* Initialize the asynchronous command Queue */
-    if (ipCoreDescriptor)
-    {
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType));
-    if (NULL == ipCoreDescriptor)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    ipCoreDescriptor->pMessageQueue = NULL;
-    ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-    if (NULL == ipCoreDescriptor->pMessageQueue)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    QueueInit(ipCoreDescriptor->pMessageQueue);
-
-    /** Default parameters setting */
-    iIsInit = OMX_FALSE;
-    iGroupPriority = 0;
-    iGroupID = 0;
-    ipMark = NULL;
-
-    SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-
-    iOutBufferCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    iFirstFragment = OMX_FALSE;
-
-    //Will be used in case of partial frame assembly
-    ipInputCurrBuffer = NULL;
-    ipAppPriv->AmrHandle = &iOmxComponent;
-
     if (ipAmrDec)
     {
         OSCL_DELETE(ipAmrDec);
@@ -320,535 +293,150 @@
 
 #if PROXY_INTERFACE
 
-    pProxyTerm[g_ComponentIndex]->ComponentSendCommand = BaseComponentSendCommand;
-    pProxyTerm[g_ComponentIndex]->ComponentGetParameter = BaseComponentGetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentSetParameter = BaseComponentSetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentGetConfig = BaseComponentGetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentSetConfig = BaseComponentSetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
-    pProxyTerm[g_ComponentIndex]->ComponentGetState = BaseComponentGetState;
-    pProxyTerm[g_ComponentIndex]->ComponentUseBuffer = BaseComponentUseBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFreeBuffer = BaseComponentFreeBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
 
 #endif
     return OMX_ErrorNone;
 }
 
 
-/*********************
- *
- * Component verfication routines
- *
- **********************/
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	* \param Component, the component to be disposed
+	*/
 
-void OpenmaxAmrAO::SetHeader(OMX_PTR aHeader, OMX_U32 aSize)
+OMX_ERRORTYPE OpenmaxAmrAO::DestroyComponent()
 {
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-    *((OMX_U32*) aHeader) = aSize;
-
-    pVersion->s.nVersionMajor = SPECVERSIONMAJOR;
-    pVersion->s.nVersionMinor = SPECVERSIONMINOR;
-    pVersion->s.nRevision = SPECREVISION;
-    pVersion->s.nStep = SPECSTEP;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize)
-{
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-
-    if (NULL == aHeader)
+    if (iIsInit != OMX_FALSE)
     {
-        return OMX_ErrorBadParameter;
+        ComponentDeInit();
     }
 
-    if (*((OMX_U32*) aHeader) != aSize)
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipAmrDec)
     {
-        return OMX_ErrorBadParameter;
+        OSCL_DELETE(ipAmrDec);
+        ipAmrDec = NULL;
     }
 
-    if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR ||
-            pVersion->s.nVersionMinor != SPECVERSIONMINOR ||
-            pVersion->s.nRevision != SPECREVISION ||
-            pVersion->s.nStep != SPECSTEP)
+    if (ipAppPriv)
     {
-        return OMX_ErrorVersionMismatch;
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
     }
 
     return OMX_ErrorNone;
 }
 
 
-/**
- * This function verify component state and structure header
+/* This routine will extract the input timestamp, verify whether silence insertion
+ * is required or not and also handle the various tasks associated with repositioning */
+void OpenmaxAmrAO::SyncWithInputTimestamp()
+{
+    //Do not check for silence insertion if the clip is repositioned
+    if (OMX_FALSE == iRepositionFlag)
+    {
+        CheckForSilenceInsertion();
+    }
+
+
+    /* Set the current timestamp equal to input buffer timestamp in case of
+     * a) All input frames
+     * b) First frame after repositioning */
+    if (OMX_FALSE == iSilenceInsertionInProgress || OMX_TRUE == iRepositionFlag)
+    {
+        iCurrentTimestamp = iFrameTimestamp;
+
+        //Reset the flag back to false, once timestamp has been updated from input frame
+        if (OMX_TRUE == iRepositionFlag)
+        {
+            iRepositionFlag = OMX_FALSE;
+        }
+    }
+}
+
+
+/* Reset the decoder library in case of repositioning or flush command or
+ * state transition (Executing ->Idle) */
+void OpenmaxAmrAO::ResetComponent()
+{
+    // reset decoder
+    if (ipAmrDec)
+    {
+        ipAmrDec->ResetDecoder();
+    }
+}
+
+/* A component specific routine called from BufferMgmtWithoutMarker */
+void OpenmaxAmrAO::ProcessInBufferFlag()
+{
+    /* Used in timestamp calculation
+     * Since we copy one buffer in advance, so let the first buffer finish up
+     * before applying 2nd buffers timestamp into the output timestamp */
+    if (iInputBufferRemainingBytes <= 0)
+    {
+        if (0 == iFrameCount)
+        {
+            iPreviousFrameLength = ipInputBuffer->nFilledLen;
+            iCurrentTimestamp = iFrameTimestamp;
+        }
+
+        iInputBufferRemainingBytes += iPreviousFrameLength;
+    }
+
+    iPreviousFrameLength = ipInputBuffer->nFilledLen;
+}
+
+
+/* This function will be called in case of buffer management without marker bit present
+ * The purpose is to copy the current input buffer into a big temporary buffer, so that
+ * an incomplete/partial frame is never passed to the decoder library for decode
  */
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentParameterSanityCheck(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_PTR pStructure,
-    OMX_IN  size_t size)
+void OpenmaxAmrAO::ComponentBufferMgmtWithoutMarker()
 {
-
-    if (iState != OMX_StateLoaded &&
-            iState != OMX_StateWaitForResources)
-    {
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if (nPortIndex >= iNumPorts)
-    {
-        return OMX_ErrorBadPortIndex;
-    }
-
-    return CheckHeader(pStructure, size);
-}
-
-/**
- * Set/Reset Port Flush Flag
- */
-void OpenmaxAmrAO::AmrComponentSetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    {
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->IsPortFlushed = value;
-    }
-
-}
-
-/**
- * Set Number of Buffer Flushed with the value Specified
- */
-void OpenmaxAmrAO::AmrComponentSetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    { // For all ComponentPort
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->NumBufferFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->NumBufferFlushed = value;
-    }
+    //This common routine has been written in the base class
+    TempInputBufferMgmtWithoutMarker();
 }
 
 
-/** This function assembles multiple input buffers into
-	* one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set
-	*/
-
-OMX_BOOL OpenmaxAmrAO::AmrComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer)
+void OpenmaxAmrAO::ProcessData()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentAssemblePartialFrames IN"));
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    AmrComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-
-    ipAmrInputBuffer = aInputBuffer;
-
-    if (!iPartialFrameAssembly)
-    {
-        if (iNumInputBuffer > 0)
-        {
-            if (ipAmrInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-            {
-                iInputCurrLength = ipAmrInputBuffer->nFilledLen;
-                ipFrameDecodeBuffer = ipAmrInputBuffer->pBuffer + ipAmrInputBuffer->nOffset;
-                //capture the timestamp to be send to the corresponding output buffer
-                iFrameTimestamp = ipAmrInputBuffer->nTimeStamp;
-            }
-            else
-            {
-                iInputCurrLength = 0;
-                iPartialFrameAssembly = OMX_TRUE;
-                iFirstFragment = OMX_TRUE;
-                iFrameTimestamp = ipAmrInputBuffer->nTimeStamp;
-                ipFrameDecodeBuffer = ipInputCurrBuffer;
-            }
-
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentAssemblePartialFrames ERROR"));
-            return OMX_FALSE;
-        }
-
-    }
-
-    //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked
-    if (iPartialFrameAssembly)
-    {
-        while (iNumInputBuffer > 0)
-        {
-            if (OMX_FALSE == iFirstFragment)
-            {
-                /* If the timestamp of curr fragment doesn't match with previous,
-                 * discard the previous fragments & start reconstructing from new
-                 */
-                if (iFrameTimestamp != ipAmrInputBuffer->nTimeStamp)
-                {
-                    iInputCurrLength = 0;
-                    iPartialFrameAssembly = OMX_TRUE;
-                    iFirstFragment = OMX_TRUE;
-                    iFrameTimestamp = ipAmrInputBuffer->nTimeStamp;
-                    ipFrameDecodeBuffer = ipInputCurrBuffer;
-                }
-            }
-
-            if ((ipAmrInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
-            {
-                break;
-            }
-
-            iInputCurrLength += ipAmrInputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAmrInputBuffer->pBuffer + ipAmrInputBuffer->nOffset), ipAmrInputBuffer->nFilledLen); // copy buffer data
-            ipFrameDecodeBuffer += ipAmrInputBuffer->nFilledLen; // move the ptr
-
-            ipAmrInputBuffer->nFilledLen = 0;
-
-            AmrComponentReturnInputBuffer(ipAmrInputBuffer, pInPort);
-
-            iFirstFragment = OMX_FALSE;
-
-            if (iNumInputBuffer > 0)
-            {
-                ipAmrInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (ipAmrInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentAssemblePartialFrames EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers
-        if (0 == iNumInputBuffer)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentAssemblePartialFrames OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            // we have found the buffer that is the last piece of the frame.
-            // Copy the buffer, but do not release it yet (this will be done after decoding for consistency)
-
-            iInputCurrLength += ipAmrInputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAmrInputBuffer->pBuffer + ipAmrInputBuffer->nOffset), ipAmrInputBuffer->nFilledLen); // copy buffer data
-            ipFrameDecodeBuffer += ipAmrInputBuffer->nFilledLen; // move the ptr
-
-            ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer
-            iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentAssemblePartialFrames OUT"));
-    return OMX_TRUE;
-}
-
-
-/** This is the central function for buffers processing and decoding.
-	* It is called through the Run() of active object when the component is in executing state
-	* and is signalled each time a new buffer is available on the given ports
-	* This function will process the input buffers & return output buffers
-	*/
-
-void OpenmaxAmrAO::AmrComponentBufferMgmtFunction()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentBufferMgmtFunction IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    AmrComponentPortType* pInPort = (AmrComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-    OMX_BOOL PartialFrameReturn;
-
-    /* Don't dequeue any further buffer after endofstream buffer has been dequeued
-     * till we send the callback and reset the flag back to false
-     */
-    if (OMX_FALSE == iEndofStream)
-    {
-        //More than one frame can't be dequeued in case of outbut blocked
-        if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
-        {
-            ipAmrInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-
-            if (ipAmrInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentBufferMgmtFunction EndOfStream arrived"));
-                iEndofStream = OMX_TRUE;
-            }
-
-            if (ipAmrInputBuffer->nFilledLen != 0)
-            {
-                if (0 == iFrameCount)
-                {
-                    //Set the marker flag (iEndOfFrameFlag) if first frame has the EndOfFrame flag marked.
-                    if (ipAmrInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentBufferMgmtFunction EndOfFrame flag present"));
-                        iEndOfFrameFlag = OMX_TRUE;
-                    }
-                }
-
-                /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is
-                 *  not marked in all the input buffers
-                 */
-                if (!iEndOfFrameFlag)
-                {
-                    AmrBufferMgmtWithoutMarker(ipAmrInputBuffer);
-
-                }
-                //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here
-                else
-                {
-                    PartialFrameReturn = AmrComponentAssemblePartialFrames(ipAmrInputBuffer);
-                    if (OMX_FALSE == PartialFrameReturn)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-                    iIsInputBufferEnded = OMX_FALSE;
-
-                    ipTargetComponent = (OMX_COMPONENTTYPE*) ipAmrInputBuffer->hMarkTargetComponent;
-
-                    iTargetMarkData = ipAmrInputBuffer->pMarkData;
-                    if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventMark,
-                         1,
-                         0,
-                         ipAmrInputBuffer->pMarkData);
-                    }
-
-                    //Do not check for silence insertion if the clip is repositioned
-                    if (OMX_FALSE == iRepositionFlag)
-                    {
-                        CheckForSilenceInsertion();
-                    }
-
-
-                    /* Set the current timestamp equal to input buffer timestamp in case of
-                     * a) All input frames
-                     * b) First frame after repositioning */
-                    if (OMX_FALSE == iSilenceInsertionInProgress || OMX_TRUE == iRepositionFlag)
-                    {
-                        iCurrentTimestamp = iFrameTimestamp;
-
-                        //Reset the flag back to false, once timestamp has been updated from input frame
-                        if (OMX_TRUE == iRepositionFlag)
-                        {
-                            iRepositionFlag = OMX_FALSE;
-                        }
-                    }
-                }
-
-            }	//end braces for if (ipAmrInputBuffer->nFilledLen != 0)
-            else
-            {
-                AmrComponentReturnInputBuffer(ipAmrInputBuffer, pInPort);
-            }
-
-        }	//end braces for if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
-    }	//if (OMX_FALSE == iEndofStream)
-
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ProcessData IN"));
     if (!iEndOfFrameFlag)
     {
-        AmrDecodeWithoutMarker();
+        DecodeWithoutMarker();
     }
     else
     {
-        AmrDecodeWithMarker(ipAmrInputBuffer);
+        DecodeWithMarker();
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentBufferMgmtFunction OUT"));
-    return;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ProcessData OUT"));
 }
 
 
-void OpenmaxAmrAO::AmrBufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE* pAmrInputBuffer)
+void OpenmaxAmrAO::DecodeWithoutMarker()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrBufferMgmtWithoutMarker IN"));
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    AmrComponentPortType*	pInPort = (AmrComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_U32 TempInputBufferSize = (2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-
-    /* Assembling of partial frame will be done based on max input buf size
-     * If Flushport flag is true, that means its not a partial frame
-     * but an unconsumed frame, process it independently
-     * Same is true for endofstream condition, process the buffer independently
-     */
-    if ((pAmrInputBuffer->nFilledLen < pAmrInputBuffer->nAllocLen)
-            && (iEndofStream != OMX_TRUE) && (OMX_FALSE == iFlushPortFlag))
-    {
-        if (!iPartialFrameAssembly)
-        {
-            iInputCurrLength = 0;
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-        }
-
-        while (iNumInputBuffer > 0)
-        {
-            oscl_memcpy(ipFrameDecodeBuffer, (pAmrInputBuffer->pBuffer + pAmrInputBuffer->nOffset), pAmrInputBuffer->nFilledLen);
-            ipFrameDecodeBuffer += pAmrInputBuffer->nFilledLen; // move the ptr
-
-            iFrameTimestamp = pAmrInputBuffer->nTimeStamp;
-
-            if (((iInputCurrLength += pAmrInputBuffer->nFilledLen) >= pAmrInputBuffer->nAllocLen)
-                    || OMX_TRUE == iEndofStream)
-            {
-                break;
-            }
-
-            //Set the filled len to zero to indiacte buffer is fully consumed
-            pAmrInputBuffer->nFilledLen = 0;
-            AmrComponentReturnInputBuffer(pAmrInputBuffer, pInPort);
-
-            if (iNumInputBuffer > 0)
-            {
-                pAmrInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (pAmrInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrBufferMgmtWithoutMarker EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        if (((iInputCurrLength < pAmrInputBuffer->nAllocLen)) && OMX_TRUE != iEndofStream)
-        {
-            iPartialFrameAssembly = OMX_TRUE;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrBufferMgmtWithoutMarker OUT"));
-            return;
-        }
-        else
-        {
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-            /* Used in timestamp calculation
-             * Since we coyp one buffer in advance, so let the first buffer finish up
-             * before applying 2nd buffers timestamp into the output timestamp */
-            if (iInputBufferRemainingBytes <= 0)
-            {
-                if (0 == iFrameCount)
-                {
-                    iPreviousFrameLength = pAmrInputBuffer->nFilledLen;
-                    iCurrentTimestamp = iFrameTimestamp;
-                }
-
-                iInputBufferRemainingBytes += iPreviousFrameLength;
-            }
-            iPreviousFrameLength = pAmrInputBuffer->nFilledLen;
-
-            iPartialFrameAssembly = OMX_FALSE;
-        }
-    }
-    else
-    {
-        if (iNumInputBuffer > 0)
-        {
-            iInputCurrLength = pAmrInputBuffer->nFilledLen;
-            ipFrameDecodeBuffer = pAmrInputBuffer->pBuffer + pAmrInputBuffer->nOffset;
-            iFrameTimestamp = pAmrInputBuffer->nTimeStamp;
-
-            //Used in timestamp calculation
-            if (iInputBufferRemainingBytes <= 0)
-            {
-                if (0 == iFrameCount)
-                {
-                    iPreviousFrameLength = pAmrInputBuffer->nFilledLen;
-                    iCurrentTimestamp = iFrameTimestamp;
-                }
-
-                iInputBufferRemainingBytes += iPreviousFrameLength;
-            }
-            iPreviousFrameLength = pAmrInputBuffer->nFilledLen;
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrBufferMgmtWithoutMarker OUT"));
-            return; // nothing to decode
-        }
-    }
-
-    if (iTempInputBufferFilledLength < (TempInputBufferSize >> 1))
-    {
-        oscl_memmove(ipTempInputBuffer, &ipTempInputBuffer[iTempConsumedLength], iTempInputBufferFilledLength);
-        iIsInputBufferEnded = OMX_TRUE;
-        iTempConsumedLength = 0;
-    }
-
-    if ((iTempInputBufferFilledLength + iTempConsumedLength
-            + iInputCurrLength) <= TempInputBufferSize)
-    {
-        oscl_memcpy(&ipTempInputBuffer[iTempInputBufferFilledLength + iTempConsumedLength], ipFrameDecodeBuffer, iInputCurrLength);
-        iTempInputBufferFilledLength += iInputCurrLength;
-
-        if (iTempInputBufferFilledLength + (TempInputBufferSize >> 1) <= TempInputBufferSize)
-        {
-            iNewInBufferRequired = OMX_TRUE;
-        }
-        else
-        {
-            iNewInBufferRequired = OMX_FALSE;
-        }
-
-        ipTargetComponent = (OMX_COMPONENTTYPE*) pAmrInputBuffer->hMarkTargetComponent;
-
-        iTargetMarkData = pAmrInputBuffer->pMarkData;
-        if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-        {
-            (*(ipCallbacks->EventHandler))
-            (pHandle,
-             iCallbackData,
-             OMX_EventMark,
-             1,
-             0,
-             pAmrInputBuffer->pMarkData);
-        }
-        pAmrInputBuffer->nFilledLen = 0;
-        AmrComponentReturnInputBuffer(pAmrInputBuffer, pInPort);
-
-    }
-
-    if (iTempInputBufferFilledLength >= (TempInputBufferSize >> 1))
-    {
-        iIsInputBufferEnded = OMX_FALSE;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrBufferMgmtWithoutMarker OUT"));
-    return;
-
-}
-
-void OpenmaxAmrAO::AmrDecodeWithoutMarker()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker IN"));
 
     QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-    AmrComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
     OMX_COMPONENTTYPE  *pHandle = &iOmxComponent;
 
     OMX_U8*					pOutBuffer;
@@ -869,7 +457,7 @@
             //Check whether a new output buffer is available or not
             if (0 == (GetQueueNumElem(pOutputQueue)))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker OUT output buffer unavailable"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker OUT output buffer unavailable"));
                 //Store the mark data for output buffer, as it will be overwritten next time
                 if (NULL != ipTargetComponent)
                 {
@@ -880,12 +468,68 @@
                 return;
             }
 
-            ipAmrOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipAmrOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker Error, Output Buffer Dequeue returned NULL, OUT"));
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipAmrOutputBuffer->nTimeStamp = iCurrentTimestamp;
+            ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
+
+            // Copy the output buffer that was stored locally before dynamic port reconfiguration
+            // in the new omx buffer received.
+            if (OMX_TRUE == iSendOutBufferAfterPortReconfigFlag)
+            {
+                if ((ipTempOutBufferForPortReconfig)
+                        && (iSizeOutBufferForPortReconfig <= ipOutputBuffer->nAllocLen))
+                {
+                    oscl_memcpy(ipOutputBuffer->pBuffer, ipTempOutBufferForPortReconfig, iSizeOutBufferForPortReconfig);
+                    ipOutputBuffer->nFilledLen = iSizeOutBufferForPortReconfig;
+                    ipOutputBuffer->nTimeStamp = iTimestampOutBufferForPortReconfig;
+                }
+
+                iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
+
+                //Send the output buffer back only when it has become full
+                if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
+                {
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                }
+
+                //Free the temp output buffer
+                if (ipTempOutBufferForPortReconfig)
+                {
+                    oscl_free(ipTempOutBufferForPortReconfig);
+                    ipTempOutBufferForPortReconfig = NULL;
+                    iSizeOutBufferForPortReconfig = 0;
+                }
+
+                //Dequeue new output buffer if required to continue decoding the next frame
+                if (OMX_TRUE == iNewOutBufRequired)
+                {
+                    if (0 == (GetQueueNumElem(pOutputQueue)))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker OUT output buffer unavailable"));
+                        return;
+                    }
+
+                    ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+                    if (NULL == ipOutputBuffer)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker Error, Output Buffer Dequeue returned NULL, OUT"));
+                        return;
+                    }
+
+                    ipOutputBuffer->nFilledLen = 0;
+                    iNewOutBufRequired = OMX_FALSE;
+
+                    ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
+                }
+            }
         }
 
         /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
@@ -893,35 +537,35 @@
          */
         if (ipMark != NULL)
         {
-            ipAmrOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipAmrOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if ((OMX_TRUE == iMarkPropagate) && (ipTempTargetComponent != ipTargetComponent))
         {
-            ipAmrOutputBuffer->hMarkTargetComponent = ipTempTargetComponent;
-            ipAmrOutputBuffer->pMarkData = iTempTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTempTargetComponent;
+            ipOutputBuffer->pMarkData = iTempTargetMarkData;
             ipTempTargetComponent = NULL;
             iMarkPropagate = OMX_FALSE;
         }
         else if (ipTargetComponent != NULL)
         {
-            ipAmrOutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipAmrOutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
             iMarkPropagate = OMX_FALSE;
 
         }
         //Mark buffer code ends here
 
-        if (iTempInputBufferFilledLength > 0)
+        if (iTempInputBufferLength > 0)
         {
-            pOutBuffer = &ipAmrOutputBuffer->pBuffer[ipAmrOutputBuffer->nFilledLen];
+            pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
             OutputLength = 0;
 
             pTempInBuffer = ipTempInputBuffer + iTempConsumedLength;
-            TempInLength = iTempInputBufferFilledLength;
+            TempInLength = iTempInputBufferLength;
 
             //Output buffer is passed as a short pointer
             DecodeReturn = ipAmrDec->AmrDecodeFrame((OMX_S16*) pOutBuffer,
@@ -931,15 +575,11 @@
                                                     &iFrameCount,
                                                     &ResizeNeeded);
 
-            ipAmrOutputBuffer->nFilledLen += OutputLength;
-
-            //offset not required in our case, set it to zero
-            ipAmrOutputBuffer->nOffset = 0;
 
             //If decoder returned error, report it to the client via a callback
             if (OMX_FALSE == DecodeReturn && OMX_FALSE == iEndofStream)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker ErrorStreamCorrupt callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker ErrorStreamCorrupt callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -955,14 +595,35 @@
                 if (0 != OutputLength)
                 {
                     iOutputFrameLength = OutputLength;
-                    //For the first buffer, assign the input buffer timestamp into it
-                    ipAmrOutputBuffer->nTimeStamp = iCurrentTimestamp;
                 }
-                // send port settings changed event
-                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->AmrHandle;
 
                 iResizePending = OMX_TRUE;
 
+                /* Do not return the output buffer generated yet, store it locally
+                 * and wait for the dynamic port reconfig to complete */
+                if ((NULL == ipTempOutBufferForPortReconfig))
+                {
+                    ipTempOutBufferForPortReconfig = (OMX_U8*) oscl_malloc(sizeof(uint8) * OutputLength);
+                    if (NULL == ipTempOutBufferForPortReconfig)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker error, insufficient resources"));
+                        return;
+                    }
+                }
+
+                //Copy the omx output buffer to the temporary internal buffer
+                oscl_memcpy(ipTempOutBufferForPortReconfig, pOutBuffer, OutputLength);
+                iSizeOutBufferForPortReconfig = OutputLength;
+
+                iTimestampOutBufferForPortReconfig = iCurrentTimestamp;
+
+                iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
+                //Make this length 0 so that no output buffer is returned by the component
+                OutputLength = 0;
+
+                // send port settings changed event
+                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
+
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
                  iCallbackData,
@@ -973,15 +634,20 @@
 
             }
 
+            ipOutputBuffer->nFilledLen += OutputLength;
+
+            //offset not required in our case, set it to zero
+            ipOutputBuffer->nOffset = 0;
+
             if (OutputLength > 0)
             {
                 iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
             }
 
-            iTempConsumedLength += (iTempInputBufferFilledLength - TempInLength);
-            iInputBufferRemainingBytes -= (iTempInputBufferFilledLength - TempInLength);
+            iTempConsumedLength += (iTempInputBufferLength - TempInLength);
+            iInputBufferRemainingBytes -= (iTempInputBufferLength - TempInLength);
 
-            iTempInputBufferFilledLength = TempInLength;
+            iTempInputBufferLength = TempInLength;
 
             if (iInputBufferRemainingBytes <= 0)
             {
@@ -1002,9 +668,9 @@
          */
         if (OMX_TRUE == iEndofStream)
         {
-            if ((0 == iTempInputBufferFilledLength) || (OMX_FALSE == DecodeReturn))
+            if ((0 == iTempInputBufferLength) || (OMX_FALSE == DecodeReturn))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1017,46 +683,49 @@
                 iNewInBufferRequired = OMX_TRUE;
                 iEndofStream = OMX_FALSE;
 
-                ipAmrOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
-                AmrComponentReturnOutputBuffer(ipAmrOutputBuffer, pOutPort);
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
 
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker OUT"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker OUT"));
 
                 return;
             }
         }
 
         //Send the output buffer back after decode
-        if (((ipAmrOutputBuffer->nAllocLen - ipAmrOutputBuffer->nFilledLen) < (iOutputFrameLength))
-                || (OMX_TRUE == ResizeNeeded))
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < (iOutputFrameLength))
         {
-            AmrComponentReturnOutputBuffer(ipAmrOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         /* If there is some more processing left with current buffers, re-schedule the AO
          * Do not go for more than one round of processing at a time.
          * This may block the AO longer than required.
          */
-        if ((TempInLength != 0 || GetQueueNumElem(pInputQueue) > 0)	&& (GetQueueNumElem(pOutputQueue) > 0) && (ResizeNeeded == OMX_FALSE))
+        if ((iTempInputBufferLength != 0 || GetQueueNumElem(pInputQueue) > 0)
+                && (GetQueueNumElem(pOutputQueue) > 0) && (ResizeNeeded == OMX_FALSE))
+
         {
             RunIfNotReady();
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithoutMarker OUT"));
     return;
 }
 
 
-void OpenmaxAmrAO::AmrDecodeWithMarker(OMX_BUFFERHEADERTYPE* pAmrInputBuffer)
+void OpenmaxAmrAO::DecodeWithMarker()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker IN"));
 
     QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
 
-    AmrComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    AmrComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
     OMX_U8*					pOutBuffer;
     OMX_U32					OutputLength;
@@ -1082,16 +751,73 @@
             //Check whether a new output buffer is available or not
             if (0 == (GetQueueNumElem(pOutputQueue)))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithoutMarker OUT output buffer unavailable"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker OUT output buffer unavailable"));
                 return;
             }
 
-            ipAmrOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipAmrOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker Error, Output Buffer Dequeue returned NULL, OUT"));
+                return;
+            }
+
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipAmrOutputBuffer->nTimeStamp = iCurrentTimestamp;
+            ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
+
+            // Copy the output buffer that was stored locally before dynamic port reconfiguration
+            // in the new omx buffer received.
+            if (OMX_TRUE == iSendOutBufferAfterPortReconfigFlag)
+            {
+                if ((ipTempOutBufferForPortReconfig)
+                        && (iSizeOutBufferForPortReconfig <= ipOutputBuffer->nAllocLen))
+                {
+                    oscl_memcpy(ipOutputBuffer->pBuffer, ipTempOutBufferForPortReconfig, iSizeOutBufferForPortReconfig);
+                    ipOutputBuffer->nFilledLen = iSizeOutBufferForPortReconfig;
+                    ipOutputBuffer->nTimeStamp = iTimestampOutBufferForPortReconfig;
+                }
+
+                iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
+
+                //Send the output buffer back only when it has become full
+                if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
+                {
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                }
+
+                //Free the temp output buffer
+                if (ipTempOutBufferForPortReconfig)
+                {
+                    oscl_free(ipTempOutBufferForPortReconfig);
+                    ipTempOutBufferForPortReconfig = NULL;
+                    iSizeOutBufferForPortReconfig = 0;
+                }
+
+                //Dequeue new output buffer if required to continue decoding the next frame
+                if (OMX_TRUE == iNewOutBufRequired)
+                {
+                    if (0 == (GetQueueNumElem(pOutputQueue)))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO :DecodeWithMarker OUT output buffer unavailable"));
+                        return;
+                    }
+
+                    ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+                    if (NULL == ipOutputBuffer)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker Error, Output Buffer Dequeue returned NULL, OUT"));
+                        return;
+                    }
+
+                    ipOutputBuffer->nFilledLen = 0;
+                    iNewOutBufRequired = OMX_FALSE;
+
+                    ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
+                }
+            }
         }
 
         /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
@@ -1099,15 +825,15 @@
          */
         if (ipMark != NULL)
         {
-            ipAmrOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipAmrOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if (ipTargetComponent != NULL)
         {
-            ipAmrOutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipAmrOutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
 
         }
@@ -1115,7 +841,7 @@
 
         if (iInputCurrLength > 0)
         {
-            pOutBuffer = &ipAmrOutputBuffer->pBuffer[ipAmrOutputBuffer->nFilledLen];
+            pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
             OutputLength = 0;
 
             //Output buffer is passed as a short pointer
@@ -1129,7 +855,7 @@
             //If decoder returned error, report it to the client via a callback
             if ((OMX_FALSE == DecodeReturn) && (OMX_FALSE == iEndofStream))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithMarker ErrorStreamCorrupt callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker ErrorStreamCorrupt callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1146,17 +872,39 @@
                 {
                     iOutputFrameLength = OutputLength;
 
-                    //Set the current timestamp to the output buffer timestamp for the first output frame
-                    //Later it will be done at the time of dequeue
-                    //(reason here is that at the time of dequeue, output buffer timestamp was equal to timestamp of config input buffer, not the first input buffer)
-                    ipAmrOutputBuffer->nTimeStamp = iCurrentTimestamp;
                 }
 
-                // send port settings changed event
-                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->AmrHandle;
-
                 iResizePending = OMX_TRUE;
 
+                /* Do not return the output buffer generated yet, store it locally
+                 * and wait for the dynamic port reconfig to complete */
+                if ((NULL == ipTempOutBufferForPortReconfig))
+                {
+                    ipTempOutBufferForPortReconfig = (OMX_U8*) oscl_malloc(sizeof(uint8) * OutputLength);
+                    if (NULL == ipTempOutBufferForPortReconfig)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker error, insufficient resources"));
+                        return;
+                    }
+                }
+
+                //Copy the omx output buffer to the temporary internal buffer
+                oscl_memcpy(ipTempOutBufferForPortReconfig, pOutBuffer, OutputLength);
+                iSizeOutBufferForPortReconfig = OutputLength;
+
+                iTimestampOutBufferForPortReconfig = iCurrentTimestamp;
+
+                iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
+                //Make this length 0 so that no output buffer is returned by the component
+                OutputLength = 0;
+
+
+                // send port settings changed event
+                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
+
+                // set the flag to disable further processing until Client reacts to this
+                //	by doing dynamic port reconfiguration
+
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
                  iCallbackData,
@@ -1167,22 +915,24 @@
 
             }
 
-            ipAmrOutputBuffer->nFilledLen += OutputLength;
+            ipOutputBuffer->nFilledLen += OutputLength;
             if (OutputLength > 0)
             {
                 iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
             }
             //offset not required in our case, set it to zero
-            ipAmrOutputBuffer->nOffset = 0;
+            ipOutputBuffer->nOffset = 0;
 
 
             /* Return the input buffer it has been consumed fully or decoder returned error*/
             if ((iInputCurrLength == 0) || (OMX_FALSE == DecodeReturn))
             {
-                pAmrInputBuffer->nFilledLen = 0;
-                AmrComponentReturnInputBuffer(pAmrInputBuffer, pInPort);
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
                 iNewInBufferRequired = OMX_TRUE;
                 iIsInputBufferEnded = OMX_TRUE;
+                iInputCurrLength = 0;
+                ipInputBuffer = NULL;
             }
             else
             {
@@ -1199,7 +949,7 @@
         {
             if ((0 == iInputCurrLength) || (OMX_FALSE == DecodeReturn))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1213,20 +963,21 @@
                 //Mark this flag false once the callback has been send back
                 iEndofStream = OMX_FALSE;
 
-                ipAmrOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
-                AmrComponentReturnOutputBuffer(ipAmrOutputBuffer, pOutPort);
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
 
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithMarker OUT"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker OUT"));
                 return;
             }
 
         }
 
         //Send the output buffer back when it has become full
-        if (((ipAmrOutputBuffer->nAllocLen - ipAmrOutputBuffer->nFilledLen) < (iOutputFrameLength))
-                || (OMX_TRUE == ResizeNeeded))
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < (iOutputFrameLength))
         {
-            AmrComponentReturnOutputBuffer(ipAmrOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         /* If there is some more processing left with current buffers, re-schedule the AO
@@ -1240,466 +991,31 @@
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrDecodeWithMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DecodeWithMarker OUT"));
     return;
 }
 
-void OpenmaxAmrAO::AmrComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pAmrInputBuffer, AmrComponentPortType *pPort)
-{
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
 
-    if (iNumInputBuffer)
-    {
-        iNumInputBuffer--;
-    }
-
-    //Callback for releasing the input buffer
-    (*(ipCallbacks->EmptyBufferDone))
-    (pHandle, iCallbackData, pAmrInputBuffer);
-
-    pAmrInputBuffer = NULL;
-
-}
-
-/**
- * Returns Output Buffer back to the IL client
- */
-void OpenmaxAmrAO::AmrComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pAmrOutputBuffer,
-        AmrComponentPortType *pPort)
-{
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    //Callback for sending back the output buffer
-    (*(ipCallbacks->FillBufferDone))
-    (pHandle, iCallbackData, pAmrOutputBuffer);
-
-    if (iOutBufferCount)
-    {
-        iOutBufferCount--;
-    }
-
-    pPort->NumBufferFlushed++;
-    iNewOutBufRequired = OMX_TRUE;
-}
-
-/** The panic function that exits from the application.
- */
-OMX_S32 OpenmaxAmrAO::AmrComponentPanic()
-{
-    OSCL_ASSERT(false);
-    OsclError::Panic("PVERROR", OsclErrGeneral);
-    return 0;
-}
-
-
-/** Flushes all the buffers under processing by the given port.
-	* This function is called due to a state change of the component, typically
-	* @param Component the component which owns the port to be flushed
-	* @param PortIndex the ID of the port to be flushed
-	*/
-
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentFlushPort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentFlushPort IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_BUFFERHEADERTYPE* pOutputBuff;
-    OMX_BUFFERHEADERTYPE* pInputBuff;
-
-    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        while ((GetQueueNumElem(pInputQueue) > 0))
-        {
-            pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, pInputBuff);
-            iNumInputBuffer--;
-        }
-        // if a buffer was previously dequeued, it wasnt freed in above loop. return it now
-        if ((iNumInputBuffer > 0) && (OMX_FALSE == iIsInputBufferEnded) && ipAmrInputBuffer)
-        {
-            ipAmrInputBuffer->nFilledLen = 0;
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, ipAmrInputBuffer);
-            iNumInputBuffer--;
-            iIsInputBufferEnded = OMX_TRUE;
-            iInputCurrLength = 0;
-        }
-    }
-
-    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        if ((OMX_FALSE == iNewOutBufRequired) && (iOutBufferCount > 0))
-        {
-            if (ipAmrOutputBuffer)
-            {
-                (*(ipCallbacks->FillBufferDone))
-                (pHandle, iCallbackData, ipAmrOutputBuffer);
-                iOutBufferCount--;
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-
-        while ((GetQueueNumElem(pOutputQueue) > 0))
-        {
-            pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            pOutputBuff->nFilledLen = 0;
-            (*(ipCallbacks->FillBufferDone))
-            (pHandle, iCallbackData, pOutputBuff);
-            iOutBufferCount--;
-        }
-
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentFlushPort OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** This function is called by the omx core when the component
-	* is disposed by the IL client with a call to FreeHandle().
-	* \param Component, the component to be disposed
-	*/
-
-OMX_ERRORTYPE OpenmaxAmrAO::DestroyComponent()
-{
-    OMX_U32 ii;
-
-    if (iIsInit != OMX_FALSE)
-    {
-        AmrComponentDeInit();
-    }
-
-    /*Deinitialize and free ports semaphores and Queue*/
-    for (ii = 0; ii < iNumPorts; ii++)
-    {
-        if (ipPorts[ii]->pBufferQueue != NULL)
-        {
-            QueueDeinit(ipPorts[ii]->pBufferQueue);
-            oscl_free(ipPorts[ii]->pBufferQueue);
-            ipPorts[ii]->pBufferQueue = NULL;
-        }
-        /*Free port*/
-        if (ipPorts[ii] != NULL)
-        {
-            oscl_free(ipPorts[ii]);
-            ipPorts[ii] = NULL;
-        }
-    }
-
-    if (ipPorts)
-    {
-        oscl_free(ipPorts);
-        ipPorts = NULL;
-    }
-
-    iState = OMX_StateLoaded;
-
-    if (ipInputCurrBuffer)
-    {
-        oscl_free(ipInputCurrBuffer);
-        ipInputCurrBuffer = NULL;
-    }
-
-    if (ipTempInputBuffer)
-    {
-        oscl_free(ipTempInputBuffer);
-        ipTempInputBuffer = NULL;
-    }
-
-    if (ipAmrDec)
-    {
-        OSCL_DELETE(ipAmrDec);
-        ipAmrDec = NULL;
-    }
-
-    if (ipCoreDescriptor != NULL)
-    {
-
-        if (ipCoreDescriptor->pMessageQueue != NULL)
-        {
-            /* De-initialize the asynchronous command queue */
-            QueueDeinit(ipCoreDescriptor->pMessageQueue);
-            oscl_free(ipCoreDescriptor->pMessageQueue);
-            ipCoreDescriptor->pMessageQueue = NULL;
-        }
-
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    if (ipAppPriv)
-    {
-        ipAppPriv->AmrHandle = NULL;
-
-        oscl_free(ipAppPriv);
-        ipAppPriv = NULL;
-    }
-
-    return OMX_ErrorNone;
-}
-
-
-/**
- * Disable Single Port
- */
-void OpenmaxAmrAO::AmrComponentDisableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE;
-
-    if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->IdleToLoadedFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_FALSE;
-        }
-    }
-
-    ipPorts[PortIndex]->NumBufferFlushed = 0;
-}
-
-
-/** Disables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be disabled
-	* @param PortIndex the ID of the port to be disabled
-	*/
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentDisablePort(OMX_S32 PortIndex)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDisablePort IN"));
-    OMX_U32 ii;
-
-    if (-1 == PortIndex)
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_TRUE;
-        }
-
-        /*Flush all ports*/
-        AmrComponentFlushPort(PortIndex);
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_FALSE;
-        }
-    }
-    else
-    {
-        /*Flush the port specified*/
-        ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE;
-        AmrComponentFlushPort(PortIndex);
-        ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE;
-    }
-
-    /*Disable ports*/
-    if (PortIndex != -1)
-    {
-        AmrComponentDisableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            AmrComponentDisableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDisablePort OUT"));
-
-    return OMX_ErrorNone;
-}
-
-/**
- * Enable Single Port
- */
-void OpenmaxAmrAO::AmrComponentEnableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE;
-
-    if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->LoadedToIdleFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_TRUE;
-        }
-    }
-}
-
-/** Enables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be enabled
-	* @param PortIndex the ID of the port to be enabled
-	*/
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentEnablePort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentEnablePort IN"));
-
-    OMX_U32 ii;
-
-    /*Enable port/s*/
-    if (PortIndex != -1)
-    {
-        AmrComponentEnableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            AmrComponentEnableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentEnablePort OUT"));
-    return OMX_ErrorNone;
-}
 
 //Not implemented & supported in case of base profile components
 
-void OpenmaxAmrAO::AmrComponentGetRolesOfComponent(OMX_STRING* aRoleString)
+void OpenmaxAmrAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
 {
-    *aRoleString = "audio_decoder.amr";
+    *aRoleString = (OMX_STRING)"audio_decoder.amr";
 }
 
 
-
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentTunnelRequest(
-    OMX_IN  OMX_HANDLETYPE hComp,
-    OMX_IN  OMX_U32 nPort,
-    OMX_IN  OMX_HANDLETYPE hTunneledComp,
-    OMX_IN  OMX_U32 nTunneledPort,
-    OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup)
+//Component constructor
+OpenmaxAmrAO::OpenmaxAmrAO()
 {
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState)
-{
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-
-    pOpenmaxAOType->GetState(pState);
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxAmrAO::GetState(OMX_OUT OMX_STATETYPE* pState)
-{
-    *pState = iState;
-}
-
-
-
-//Active object constructor
-OpenmaxAmrAO::OpenmaxAmrAO() :
-        OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXAmrDec")
-{
-
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXAudioDecNode");
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : constructed"));
-
-    //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-    iBufferExecuteFlag = OMX_FALSE;
-    ipAppPriv = NULL;
-
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-
-
-    ipCoreDescriptor = NULL;
-    iNumInputBuffer = 0;
-
-    ipFrameDecodeBuffer = NULL;
-    iPartialFrameAssembly = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iEndofStream = OMX_FALSE;
-    ipTempInputBuffer = NULL;
-
-
-    ipTargetComponent = NULL;
-    iTargetMarkData = NULL;
-    iNewOutBufRequired = OMX_TRUE;
-
-    iTempConsumedLength = 0;
-    iOutBufferCount = 0;
-    iCodecReady = OMX_FALSE;
-    ipInputCurrBuffer = NULL;
-    iInputCurrLength = 0;
-    iFrameCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    ipAmrInputBuffer = NULL;
-    ipAmrOutputBuffer = NULL;
-
-
-    iFirstFragment = OMX_FALSE;
-    iResizePending = OMX_FALSE;
-
-    iFrameTimestamp = 0;
-    iSilenceInsertionInProgress = OMX_FALSE;
-
-    iNumPorts = 0;
-    ipPorts = NULL;
-
-    //Indicate whether component has been already initialized */
-    iIsInit = OMX_FALSE;
-
-    iGroupPriority = 0;
-    iGroupID = 0;
-
-    ipMark = NULL;
-
     ipAmrDec = NULL;
 
     if (!IsAdded())
     {
         AddToScheduler();
     }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : constructed"));
 }
 
 
@@ -1717,15 +1033,15 @@
 
 /** The Initialization function
  */
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentInit()
+OMX_ERRORTYPE OpenmaxAmrAO::ComponentInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ComponentInit IN"));
 
-    OMX_BOOL Status;
+    OMX_BOOL Status = OMX_TRUE;
 
     if (OMX_TRUE == iIsInit)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentInit error incorrect operation"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ComponentInit error incorrect operation"));
         return OMX_ErrorIncorrectStateOperation;
     }
     iIsInit = OMX_TRUE;
@@ -1737,11 +1053,12 @@
         iCodecReady = OMX_TRUE;
     }
 
+    //ipAmrDec->iAmrInitFlag = 0;
     iInputCurrLength = 0;
     //Used in dynamic port reconfiguration
     iFrameCount = 0;
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ComponentInit OUT"));
 
     if (OMX_TRUE == Status)
     {
@@ -1753,12 +1070,14 @@
     }
 }
 
+
+
 /** This function is called upon a transition to the idle or invalid state.
- *  Also it is called by the AmrComponentDestructor() function
+ *  Also it is called by the ComponentDestructor() function
  */
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentDeInit()
+OMX_ERRORTYPE OpenmaxAmrAO::ComponentDeInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDeInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ComponentDeInit IN"));
 
     iIsInit = OMX_FALSE;
 
@@ -1768,1976 +1087,12 @@
         iCodecReady = OMX_FALSE;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDeInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : ComponentDeInit OUT"));
 
     return OMX_ErrorNone;
 
 }
 
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentGetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return Status;
-
-}
-
-OMX_ERRORTYPE OpenmaxAmrAO::GetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter IN"));
-
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
-    OMX_PORT_PARAM_TYPE* pPortDomains;
-    OMX_U32 PortIndex;
-
-    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
-    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
-    OMX_AUDIO_PARAM_AMRTYPE* pAudioAmr;
-
-    AmrComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamPriorityMgmt:
-        {
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
-            pPrioMgmt->nGroupPriority = iGroupPriority;
-            pPrioMgmt->nGroupID = iGroupID;
-        }
-        break;
-
-        case OMX_IndexParamAudioInit:
-        {
-            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-
-        //Following 3 cases have a single common piece of code to be executed
-        case OMX_IndexParamVideoInit:
-        case OMX_IndexParamImageInit:
-        case OMX_IndexParamOtherInit:
-        {
-            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
-            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
-            pPortDomains->nPorts = 0;
-            pPortDomains->nStartPortNumber = 0;
-        }
-        break;
-
-        case OMX_IndexParamAudioPortFormat:
-        {
-            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            if (pAudioPortFormat->nIndex > ipPorts[pAudioPortFormat->nPortIndex]->AudioParam.nIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error index out of range"));
-                return OMX_ErrorNoMore;
-            }
-            SetHeader(pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            if (pAudioPortFormat->nPortIndex <= 1)
-            {
-                pComponentPort = (AmrComponentPortType*) ipPorts[pAudioPortFormat->nPortIndex];
-                oscl_memcpy(pAudioPortFormat, &pComponentPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamAudioPcm:
-        {
-            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
-            if (pAudioPcmMode->nPortIndex > 1)
-            {
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioPcmMode->nPortIndex;
-            oscl_memcpy(pAudioPcmMode, &ipPorts[PortIndex]->AudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-            SetHeader(pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioAmr:
-        {
-            pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure;
-            if (pAudioAmr->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioAmr->nPortIndex;
-            oscl_memcpy(pAudioAmr, &ipPorts[PortIndex]->AudioAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
-            SetHeader(pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-
-            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
-            {
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-            else
-            {
-                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-        }
-        break;
-
-        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
-        {
-            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
-            if (NULL == pCap_flags)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error pCap_flags NULL"));
-                return OMX_ErrorBadParameter;
-            }
-            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
-
-        }
-        break;
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter error Unsupported Index"));
-            return OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : GetParameter OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::SetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter IN"));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
-    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
-    OMX_AUDIO_PARAM_AMRTYPE* pAudioAmr;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
-    OMX_U32 PortIndex;
-    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
-
-    AmrComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamAudioInit:
-        {
-            /*Check Structure Header*/
-            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error audio init failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioPortFormat:
-        {
-            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            PortIndex = pAudioPortFormat->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            if (PortIndex <= 1)
-            {
-                pComponentPort = (AmrComponentPortType*) ipPorts[PortIndex];
-                oscl_memcpy(&pComponentPort->AudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamAudioPcm:
-        {
-            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
-            PortIndex = pAudioPcmMode->nPortIndex;
-            /*Check Structure Header and verify component State*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-            oscl_memcpy(&ipPorts[PortIndex]->AudioPcmMode, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioAmr:
-        {
-            pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure;
-            PortIndex = pAudioAmr->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->AudioAmrParam, pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
-
-            //If the band mode turns out to be WB, set the sampling freq to 16KHz
-            if ((pAudioAmr->eAMRBandMode >= OMX_AUDIO_AMRBandModeWB0) &&
-                    (pAudioAmr->eAMRBandMode <= OMX_AUDIO_AMRBandModeWB8))
-            {
-                ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nSamplingRate = 16000;
-            }
-        }
-        break;
-
-        case OMX_IndexParamPriorityMgmt:
-        {
-            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error incorrect state error"));
-                return OMX_ErrorIncorrectStateOperation;
-            }
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            iGroupPriority = pPrioMgmt->nGroupPriority;
-            iGroupID = pPrioMgmt->nGroupID;
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
-            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-            if (OMX_ErrorIncorrectStateOperation == ErrorType)
-            {
-                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error incorrect state error"));
-                    return OMX_ErrorIncorrectStateOperation;
-                }
-            }
-            else if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter OUT"));
-                return OMX_ErrorNone;
-            }
-
-            ErrorType = OMX_ErrorNone;
-        }
-        break;
-
-        case OMX_IndexParamStandardComponentRole:
-        {
-            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            strcpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole);
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter error bad parameter"));
-            return OMX_ErrorBadParameter;
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetParameter OUT"));
-    return ErrorType;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::UseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : UseBuffer IN"));
-    AmrComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : UseBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : UseBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : UseBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer;
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFilledLen = 0;
-            pBaseComponentPort->pBuffer[ii]->nOffset = 0;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            pBaseComponentPort->pBuffer[ii]->nTickCount = 0;
-            pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0;
-            *ppBufferHdr = pBaseComponentPort->pBuffer[ii];
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            else
-            {
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-            pBaseComponentPort->NumAssignedBuffers++;
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : UseBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : UseBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::AllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer IN"));
-
-    AmrComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            /* allocate the buffer */
-            pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes);
-            if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            *pBuffer = pBaseComponentPort->pBuffer[ii];
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts;
-            }
-            else
-            {
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-            }
-
-            pBaseComponentPort->NumAssignedBuffers++;
-
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AllocateBuffer OUT"));
-    return OMX_ErrorInsufficientResources;
-}
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::FreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FreeBuffer IN"));
-
-    AmrComponentPortType* pBaseComponentPort;
-
-    OMX_U32 ii;
-    OMX_BOOL FoundBuffer;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FreeBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateLoaded
-            && pBaseComponentPort->TransientState != OMX_StateInvalid)
-    {
-
-        (*(ipCallbacks->EventHandler))
-        (hComponent,
-         iCallbackData,
-         OMX_EventError, /* The command was completed */
-         OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */
-         nPortIndex, /* The State has been changed in message->MessageParam2 */
-         NULL);
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-            oscl_free(pBuffer->pBuffer);
-            pBuffer->pBuffer = NULL;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-        else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) &&
-                 (pBaseComponentPort->pBuffer[ii] == pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-    }
-
-    FoundBuffer = OMX_FALSE;
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE)
-        {
-            FoundBuffer = OMX_TRUE;
-            break;
-        }
-    }
-    if (!FoundBuffer)
-    {
-        pBaseComponentPort->PortParam.bPopulated = OMX_FALSE;
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation
-            RunIfNotReady();
-            //Set the corresponding flags
-            pBaseComponentPort->IdleToLoadedFlag = OMX_TRUE;
-            pBaseComponentPort->LoadedToIdleFlag = OMX_FALSE;
-            iStateTransitionFlag = OMX_FALSE;
-            //Reset the decoding flags while freeing buffers
-            if (OMX_PORT_INPUTPORT_INDEX == nPortIndex)
-            {
-                iIsInputBufferEnded = OMX_TRUE;
-                iTempInputBufferFilledLength = 0;
-                iTempConsumedLength = 0;
-            }
-            else if (OMX_PORT_OUTPUTPORT_INDEX == nPortIndex)
-            {
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-        if (NULL != pBaseComponentPort->pBuffer)
-        {
-            oscl_free(pBaseComponentPort->pBuffer);
-            pBaseComponentPort->pBuffer = NULL;
-            oscl_free(pBaseComponentPort->BufferState);
-            pBaseComponentPort->BufferState = NULL;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FreeBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs
-	* @param hComponent the handle of the component
-	* @param ipCallbacks the OpenMAX standard structure that holds the callback pointers
-	* @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed
-    */
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAmrAO::SetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SetCallbacks"));
-    ipCallbacks = pCallbacks;
-    iCallbackData = pAppData;
-
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAmrAO::SendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_S32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand IN"));
-
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone;
-    QueueType* pMessageQueue;
-    CoreMessage* Message;
-
-    pMessageQueue = ipCoreDescriptor->pMessageQueue;
-
-    if (OMX_StateInvalid == iState)
-    {
-        ErrMsgHandler = OMX_ErrorInvalidState;
-    }
-
-    switch (Cmd)
-    {
-        case OMX_CommandStateSet:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandStateSet;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState))
-            {
-                ErrMsgHandler = AmrComponentInit();
-
-                if (ErrMsgHandler != OMX_ErrorNone)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error component init"));
-                    return OMX_ErrorInsufficientResources;
-                }
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    ipPorts[ii]->TransientState = OMX_StateIdle;
-                }
-            }
-            else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState))
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else if (OMX_StateInvalid == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateInvalid;
-                    }
-                }
-            }
-            else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam))
-                     && (OMX_StateExecuting == iState))
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-
-        }
-        break;
-
-        case OMX_CommandFlush:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandFlush;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-
-            }
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            //Assume that reposition command has come
-            iRepositionFlag = OMX_TRUE;
-            //Reset the silence insertion logic also
-            iSilenceInsertionInProgress = OMX_FALSE;
-            // reset decoder
-            if (ipAmrDec)
-            {
-                ipAmrDec->ResetDecoder();
-            }
-
-            AmrComponentSetPortFlushFlag(iNumPorts, nParam, OMX_TRUE);
-            AmrComponentSetNumBufferFlush(iNumPorts, -1, 0);
-        }
-        break;
-
-        case OMX_CommandPortDisable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            iResizePending = OMX_FALSE;
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (!PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else
-            {
-                if (!PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateLoaded;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-                Message->MessageParam2 = nParam;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-                Message->MessageParam2 = ErrMsgHandler;
-            }
-            Message->MessageParam1 = OMX_CommandPortDisable;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandPortEnable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateIdle;
-                    }
-                }
-            }
-            else
-            {
-                if (PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateIdle;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-            }
-
-            Message->MessageParam1 = OMX_CommandPortEnable;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandMarkBuffer:
-        {
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-            }
-
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandMarkBuffer;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand error unsupported index"));
-            ErrMsgHandler = OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    Queue(pMessageQueue, Message);
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : SendCommand OUT"));
-    return ErrMsgHandler;
-}
-
-
-/** This is called by the OMX core in its message processing
- * thread context upon a component request. A request is made
- * by the component when some asynchronous services are needed:
- * 1) A SendCommand() is to be processed
- * 2) An error needs to be notified
- * \param Message, the message that has been passed to core
- */
-
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentMessageHandler(CoreMessage* Message)
-{
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-
-    /** Dealing with a SendCommand call.
-     * -MessageParam1 contains the command to execute
-     * -MessageParam2 contains the parameter of the command
-     *  (destination state in case of a state change command).
-     */
-
-    OMX_STATETYPE orig_state = iState;
-    if (SENDCOMMAND_MSG_TYPE == Message->MessageType)
-    {
-        switch (Message->MessageParam1)
-        {
-            case OMX_CommandStateSet:
-            {
-                /* Do the actual state change */
-                ErrorType = AmrComponentDoStateSet(Message->MessageParam2);
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                //Do not send the callback now till the State gets changed
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    /* And run the callback */
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventCmdComplete, /* The command was completed */
-                     OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
-                     Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-            }
-            break;
-
-            case OMX_CommandFlush:
-            {
-                /*Flush ports*/
-                ErrorType = AmrComponentFlushPort(Message->MessageParam2);
-
-                AmrComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Flush all port*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {/*Flush input/output port*/
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-                AmrComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-            }
-            break;
-
-            case OMX_CommandPortDisable:
-            {
-                /** This condition is added to pass the tests, it is not significant for the environment */
-                ErrorType = AmrComponentDisablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Disable all ports*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandPortEnable:
-            {
-                ErrorType = AmrComponentEnablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The State has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (Message->MessageParam2 != -1)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                    else
-                    {
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The State has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandMarkBuffer:
-            {
-                ipMark = (OMX_MARKTYPE *)Message->pCmdData;
-            }
-            break;
-
-            default:
-            {
-
-            }
-            break;
-        }
-        /* Dealing with an asynchronous error condition
-         */
-    }
-
-    if (orig_state != OMX_StateInvalid)
-    {
-        ErrorType = OMX_ErrorNone;
-    }
-
-    return ErrorType;
-}
-
-/** Changes the state of a component taking proper actions depending on
- * the transiotion requested
- * \param Component, the component which state is to be changed
- * \param aDestinationState the requested target state.
- */
-
-OMX_ERRORTYPE OpenmaxAmrAO::AmrComponentDoStateSet(OMX_U32 aDestinationState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
-                    (0, "OpenmaxAmrAO : AmrComponentDoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_U32 ii;
-
-    if (OMX_StateLoaded == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateLoaded;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->IdleToLoadedFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_FALSE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet Waiting port to be de-populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateLoaded;
-
-                iNumInputBuffer = 0;
-                iOutBufferCount = 0;
-                iPartialFrameAssembly = OMX_FALSE;
-                iEndofStream = OMX_FALSE;
-                iIsInputBufferEnded = OMX_TRUE;
-                iNewOutBufRequired = OMX_TRUE;
-                iFirstFragment = OMX_FALSE;
-                ipAmrDec->iAmrInitFlag = 0;
-
-                AmrComponentDeInit();
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateWaitForResources == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                iState = OMX_StateWaitForResources;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateIdle == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            !PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->LoadedToIdleFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_TRUE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet Waiting port to be populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateIdle;
-
-                //Used in case of partial frame assembly
-                if (!ipInputCurrBuffer)
-                {
-                    //Keep the size of temp buffer double to be on safer side
-                    ipInputCurrBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-                    if (NULL == ipInputCurrBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                if (!ipTempInputBuffer)
-                {
-                    ipTempInputBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
-                    if (NULL == ipTempInputBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                iTempInputBufferFilledLength = 0;
-                iTempConsumedLength = 0;
-                iInputBufferRemainingBytes = 0;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            //Both the below cases have same body
-            case OMX_StateExecuting:
-            case OMX_StatePause:
-            {
-                AmrComponentSetNumBufferFlush(iNumPorts, -1, 0);
-                AmrComponentSetPortFlushFlag(iNumPorts, -1, OMX_TRUE);
-
-                AmrComponentPortType* pInPort = (AmrComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-                //Return all the buffers if still occupied
-                QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-                while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0))
-                {
-                    AmrComponentFlushPort(OMX_PORT_INPUTPORT_INDEX);
-                }
-                // if a buffer was previously dequeued, it wasnt freed in above loop. return it now
-                if (iNumInputBuffer > 0)
-                {
-                    ipAmrInputBuffer->nFilledLen = 0;
-                    AmrComponentReturnInputBuffer(ipAmrInputBuffer, pInPort);
-                    iIsInputBufferEnded = OMX_TRUE;
-                }
-
-                //Mark these flags as true
-                iIsInputBufferEnded = OMX_TRUE;
-                iEndofStream = OMX_FALSE;
-
-                //Reset the decoder's input buffers/flags
-                iTempInputBufferFilledLength = 0;
-                iTempConsumedLength = 0;
-                iInputBufferRemainingBytes = 0;
-
-                //Assume for this state transition that reposition command has come
-                iRepositionFlag = OMX_TRUE;
-                //Reset the silence insertion logic also
-                iSilenceInsertionInProgress = OMX_FALSE;
-                // reset decoder
-                if (ipAmrDec)
-                {
-                    ipAmrDec->ResetDecoder();
-                }
-
-                while (iOutBufferCount > 0)
-                {
-                    AmrComponentFlushPort(OMX_PORT_OUTPUTPORT_INDEX);
-                }
-
-                AmrComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-                AmrComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet OUT"));
-        return ErrorType;
-    }
-
-    if (OMX_StatePause == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            //Falling through to the next case
-            case OMX_StateExecuting:
-            case OMX_StateIdle:
-            {
-                iState = OMX_StatePause;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateExecuting == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                iState = OMX_StateExecuting;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                iState = OMX_StateExecuting;
-                /* A trigger to start the processing of buffers when component
-                 * transitions to executing from pause, as it is already
-                 * holding the required buffers
-                 */
-                RunIfNotReady();
-            }
-            break;
-
-            case OMX_StateExecuting:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateInvalid == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            default:
-            {
-                iState = OMX_StateInvalid;
-                if (iIsInit != OMX_FALSE)
-                {
-                    AmrComponentDeInit();
-                }
-            }
-            break;
-        }
-
-        if (iIsInit != OMX_FALSE)
-        {
-            AmrComponentDeInit();
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : AmrComponentDoStateSet OUT"));
-    return OMX_ErrorNone;
-}
-
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer);
-
-    return Status;
-
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::EmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer IN"));
-    //Do not queue buffers if component is in invalid state
-    if (OMX_StateInvalid == iState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState))
-    {
-        OMX_U32 PortIndex;
-        QueueType* pInputQueue;
-        OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-        PortIndex = pBuffer->nInputPortIndex;
-
-        //Validate the port index & Queue the buffers available only at the input port
-        if (PortIndex >= iNumPorts ||
-                ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer error bad port index"));
-            return OMX_ErrorBadPortIndex;
-        }
-
-        //Port should be in enabled state before accepting buffers
-        if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        /* The number of buffers the component can queue at a time
-         * depends upon the number of buffers allocated/assigned on the input port
-         */
-        if (iNumInputBuffer == (ipPorts[PortIndex]->NumAssignedBuffers))
-
-        {
-            RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        //Finally after passing all the conditions, queue the buffer in Input queue
-        pInputQueue = ipPorts[PortIndex]->pBufferQueue;
-
-        if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer error check header failed"));
-            return ErrorType;
-        }
-
-        iNumInputBuffer++;
-        Queue(pInputQueue, pBuffer);
-
-        //Signal the AO about the incoming buffer
-        RunIfNotReady();
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer error incorrect state"));
-        //This macro is not accepted in any other state except the three mentioned above
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : EmptyThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAmrAO::BaseComponentFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxAmrAO* pOpenmaxAOType = (OpenmaxAmrAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAmrAO::FillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FillThisBuffer IN"));
-
-    OMX_U32 PortIndex;
-
-    QueueType* pOutputQueue;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-    PortIndex = pBuffer->nOutputPortIndex;
-    //Validate the port index & Queue the buffers available only at the output port
-    if (PortIndex >= iNumPorts ||
-            ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FillThisBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pOutputQueue = ipPorts[PortIndex]->pBufferQueue;
-    if (iState != OMX_StateExecuting &&
-            iState != OMX_StatePause &&
-            iState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FillThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    //Port should be in enabled state before accepting buffers
-    if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FillThisBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FillThisBuffer error check header failed"));
-        return ErrorType;
-    }
-
-    //Queue the buffer in output queue
-    Queue(pOutputQueue, pBuffer);
-    iOutBufferCount++;
-
-    //Signal the AO about the incoming buffer
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : FillThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-
-void OpenmaxAmrAO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : Run IN"));
-
-
-    CoreMessage* pCoreMessage;
-
-    //Execute the commands from the message handler queue
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue);
-
-        if (OMX_CommandStateSet == pCoreMessage->MessageParam1)
-        {
-            if (OMX_StateExecuting == pCoreMessage->MessageParam2)
-            {
-                iBufferExecuteFlag = OMX_TRUE;
-            }
-            else
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-        }
-
-        AmrComponentMessageHandler(pCoreMessage);
-
-        /* If some allocations/deallocations are required before the state transition
-         * then queue the command again to be executed later on
-         */
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage);
-            // Don't reschedule. Wait for arriving buffers to do it
-            //RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : Run OUT"));
-            return;
-        }
-
-        else
-        {
-            oscl_free(pCoreMessage);
-            pCoreMessage = NULL;
-        }
-    }
-
-    /* If the component is in executing state, call the Buffer management function.
-     * Stop calling this function as soon as state transition request is received.
-     */
-    if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending))
-    {
-        AmrComponentBufferMgmtFunction();
-    }
-
-    //Check for any more commands in the message handler queue & schedule them for later
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : Run OUT"));
-
-    return;
-}
 
 //Check whether silence insertion is required here or not
 void OpenmaxAmrAO::CheckForSilenceInsertion()
@@ -3771,10 +1126,11 @@
 void OpenmaxAmrAO::DoSilenceInsertion()
 {
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-    AmrComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
-    OMX_U8*	pOutBuffer;
+    OMX_U8*	pOutBuffer = NULL;
     OMX_U32	OutputLength;
+    //OMX_BOOL ResizeNeeded = OMX_FALSE;
     OMX_BOOL DecodeReturn;
 
 
@@ -3794,15 +1150,21 @@
                 return;
             }
 
-            ipAmrOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipAmrOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DoSilenceInsertion Error, Output Buffer Dequeue returned NULL, OUT"));
+                iSilenceInsertionInProgress = OMX_TRUE;
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipAmrOutputBuffer->nTimeStamp = iCurrentTimestamp;
+            ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
         }
 
-        pOutBuffer = &ipAmrOutputBuffer->pBuffer[ipAmrOutputBuffer->nFilledLen];
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
         OutputLength = 0;
 
         //Decode the silence frame
@@ -3819,9 +1181,9 @@
         }
 
         //Output length for a buffer of OMX_U8* will be double as that of OMX_S16*
-        ipAmrOutputBuffer->nFilledLen += OutputLength;
+        ipOutputBuffer->nFilledLen += OutputLength;
         //offset not required in our case, set it to zero
-        ipAmrOutputBuffer->nOffset = 0;
+        ipOutputBuffer->nOffset = 0;
 
         if (OutputLength > 0)
         {
@@ -3831,9 +1193,10 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DoSilenceInsertion - silence frame decoded"));
 
         //Send the output buffer back when it has become full
-        if ((ipAmrOutputBuffer->nAllocLen - ipAmrOutputBuffer->nFilledLen) < iOutputFrameLength)
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
         {
-            AmrComponentReturnOutputBuffer(ipAmrOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         // Decrement the silence frame counter
@@ -3855,27 +1218,34 @@
                 return;
             }
 
-            ipAmrOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipAmrOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DoSilenceInsertion Error, Output Buffer Dequeue returned NULL, OUT"));
+                iSilenceInsertionInProgress = OMX_TRUE;
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipAmrOutputBuffer->nTimeStamp = iCurrentTimestamp;
+            ipOutputBuffer->nTimeStamp = iCurrentTimestamp;
         }
 
-        pOutBuffer = &ipAmrOutputBuffer->pBuffer[ipAmrOutputBuffer->nFilledLen];
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
         oscl_memset(pOutBuffer, 0, iOutputFrameLength);
 
-        ipAmrOutputBuffer->nFilledLen += iOutputFrameLength;
-        ipAmrOutputBuffer->nOffset = 0;
+        ipOutputBuffer->nFilledLen += iOutputFrameLength;
+        ipOutputBuffer->nOffset = 0;
         iCurrentTimestamp += OMX_AMR_DEC_FRAME_INTERVAL;
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAmrAO : DoSilenceInsertion - One frame of zeros inserted"));
 
         //Send the output buffer back when it has become full
-        if ((ipAmrOutputBuffer->nAllocLen - ipAmrOutputBuffer->nFilledLen) < iOutputFrameLength)
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
         {
-            AmrComponentReturnOutputBuffer(ipAmrOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         // Decrement the silence frame counter
@@ -3891,3 +1261,14 @@
 
     return;
 }
+
+OMX_ERRORTYPE OpenmaxAmrAO::GetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    OSCL_UNUSED_ARG(nIndex);
+    OSCL_UNUSED_ARG(pComponentConfigStructure);
+    return OMX_ErrorNotImplemented;
+}
diff --git a/codecs_v2/omx/omx_amrenc/Android.mk b/codecs_v2/omx/omx_amrenc/Android.mk
new file mode 100644
index 0000000..ade9cd8
--- /dev/null
+++ b/codecs_v2/omx/omx_amrenc/Android.mk
@@ -0,0 +1,35 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/amr_enc.cpp \
+ 	src/omx_amrenc_component.cpp
+
+
+LOCAL_MODULE := libomx_amrenc_component_lib
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_amrenc/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_amrenc/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/include \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/src \
+ 	$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/amr_enc.h \
+ 	include/omx_amrenc_component.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/omx/omx_amrenc/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_amrenc/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..8436a1e
--- /dev/null
+++ b/codecs_v2/omx/omx_amrenc/build/make_multithreaded/local.mk
@@ -0,0 +1,35 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_amrenc_component_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../audio/gsm_amr/amr_nb/common/src \
+  ../../../../audio/gsm_amr/amr_nb/common/include \
+  ../../../../audio/gsm_amr/amr_nb/enc/src \
+  ../../../../audio/gsm_amr/amr_nb/enc/include 
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := amr_enc.cpp \
+	omx_amrenc_component.cpp
+
+
+HDRS := amr_enc.h \
+	omx_amrenc_component.h
+	
+
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_amrenc/include/amr_enc.h b/codecs_v2/omx/omx_amrenc/include/amr_enc.h
new file mode 100644
index 0000000..08e1a30
--- /dev/null
+++ b/codecs_v2/omx/omx_amrenc/include/amr_enc.h
@@ -0,0 +1,84 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AMR_ENC_H_INCLUDED
+#define AMR_ENC_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#ifndef GSMAMR_ENCODER_H_INCLUDED
+#include "gsmamr_encoder_wrapper.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+
+#define AMR_FRAME_LENGTH_IN_TIMESTAMP 20
+#define MAX_AMR_FRAME_SIZE 32
+#define MAX_NUM_OUTPUT_FRAMES_PER_BUFFER 10
+
+
+class OmxAmrEncoder
+{
+    public:
+        OmxAmrEncoder();
+
+        OMX_BOOL AmrEncInit(OMX_AUDIO_PARAM_PCMMODETYPE aPcmMode,
+                            OMX_AUDIO_PARAM_AMRTYPE aAmrParam,
+                            OMX_U32* aInputFrameLength,
+                            OMX_U32* aMaxNumberOutputFrames);
+
+        void AmrEncDeinit();
+
+        OMX_BOOL AmrEncodeFrame(OMX_U8* aOutputBuffer,
+                                OMX_U32* aOutputLength,
+                                OMX_U8* aInBuffer,
+                                OMX_U32 aInBufSize,
+                                OMX_TICKS aInTimeStamp,
+                                OMX_TICKS* aOutTimeStamp);
+
+    private:
+
+        //Codec and encoder settings
+        CPvGsmAmrEncoder*  ipGsmEncoder;
+        TEncodeProperties* ipEncProps;
+
+        //Encoding Settings parameters
+
+        int32*			 ipSizeArrayForOutputFrames;
+        uint32			 iNextStartTime;
+        uint32			 iMaxNumOutputFramesPerBuffer;
+        uint32			 iOneInputFrameLength;
+        uint32			 iMaxInputSize;
+        PVMFFormatType	 iOutputFormat;
+
+        OMX_S32 iAmrInitFlag;
+
+};
+
+
+
+#endif	//#ifndef AMR_ENC_H_INCLUDED
+
diff --git a/codecs_v2/omx/omx_amrenc/include/omx_amrenc_component.h b/codecs_v2/omx/omx_amrenc/include/omx_amrenc_component.h
new file mode 100644
index 0000000..8c81ac6
--- /dev/null
+++ b/codecs_v2/omx/omx_amrenc/include/omx_amrenc_component.h
@@ -0,0 +1,76 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+	@file omx_amrenc_component.h
+	OpenMax encoder component file.
+*/
+
+#ifndef OMX_AMRENC_COMPONENT_H_INCLUDED
+#define OMX_AMRENC_COMPONENT_H_INCLUDED
+
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
+#endif
+
+#ifndef AMR_DEC_H_INCLUDED
+#include "amr_enc.h"
+#endif
+
+
+#define INPUT_BUFFER_SIZE_AMR_ENC (320 * MAX_NUM_OUTPUT_FRAMES_PER_BUFFER)	//3200
+
+#define OUTPUT_BUFFER_SIZE_AMR_ENC (MAX_NUM_OUTPUT_FRAMES_PER_BUFFER * MAX_AMR_FRAME_SIZE)	//10 * 32 = 320
+
+#define NUMBER_INPUT_BUFFER_AMR_ENC  5
+#define NUMBER_OUTPUT_BUFFER_AMR_ENC  2
+
+
+#define omx_min(a, b)  ((a) <= (b) ? (a) : (b));
+
+class OmxComponentAmrEncoderAO : public OmxComponentAudio
+{
+    public:
+
+        OmxComponentAmrEncoderAO();
+        ~OmxComponentAmrEncoderAO();
+
+
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
+
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
+
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+
+        void ProcessData();
+
+        void ProcessInBufferFlag();
+        void SyncWithInputTimestamp();
+
+    private:
+
+        OMX_U32			iInputFrameLength;
+        OMX_U32			iMaxNumberOutputFrames;
+        OMX_U32			iActualNumberOutputFrames;
+
+        OMX_TICKS		iCurrentTimestamp;
+        OmxAmrEncoder*  ipAmrEnc;
+};
+
+#endif // OMX_AMRENC_COMPONENT_H_INCLUDED
diff --git a/codecs_v2/omx/omx_amrenc/src/amr_enc.cpp b/codecs_v2/omx/omx_amrenc/src/amr_enc.cpp
new file mode 100644
index 0000000..d1a247a
--- /dev/null
+++ b/codecs_v2/omx/omx_amrenc/src/amr_enc.cpp
@@ -0,0 +1,247 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "amr_enc.h"
+
+
+OmxAmrEncoder::OmxAmrEncoder()
+{
+    // Codec and encoder setting structure
+    ipGsmEncoder = NULL;
+    ipEncProps   = NULL;
+    iNextStartTime = 0;
+
+    iOutputFormat			  = PVMF_MIME_AMR_IETF;
+    ipSizeArrayForOutputFrames = NULL;
+    iNextStartTime			  = 0;
+
+    iMaxNumOutputFramesPerBuffer = MAX_NUM_OUTPUT_FRAMES_PER_BUFFER;
+    iOneInputFrameLength		 = 320;
+    iMaxInputSize				 = 0;
+
+    iAmrInitFlag = 0;
+}
+
+
+/* Decoder Initialization function */
+OMX_BOOL OmxAmrEncoder::AmrEncInit(OMX_AUDIO_PARAM_PCMMODETYPE aPcmMode,
+                                   OMX_AUDIO_PARAM_AMRTYPE aAmrParam,
+                                   OMX_U32* aInputFrameLength,
+                                   OMX_U32* aMaxNumberOutputFrames)
+{
+    OMX_U32	MaxOutputBufferSize;
+
+
+    iAmrInitFlag = 0;
+
+    ipGsmEncoder = OSCL_NEW(CPvGsmAmrEncoder, ());
+    if (!ipGsmEncoder)
+    {
+        return OMX_FALSE;
+    }
+
+    // for encoder properties
+    ipEncProps = OSCL_NEW(TEncodeProperties, ());
+    if (!ipEncProps)
+    {
+        return OMX_FALSE;
+    }
+
+    //Extracting the output format information
+    if (OMX_AUDIO_AMRFrameFormatFSF == aAmrParam.eAMRFrameFormat)
+    {
+        iOutputFormat = PVMF_MIME_AMR_IETF;
+    }
+    else if (OMX_AUDIO_AMRFrameFormatIF2 == aAmrParam.eAMRFrameFormat)
+    {
+        iOutputFormat = PVMF_MIME_AMR_IF2;
+    }
+    else
+    {
+        //unsupported format
+        return OMX_FALSE;
+    }
+
+
+    if (OMX_AUDIO_AMRBandModeNB0 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_4_75;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB1 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_5_15;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB2 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_5_90;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB3 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_6_70;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB4 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_7_40;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB5 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_7_95;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB6 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_10_2;
+    }
+    else if (OMX_AUDIO_AMRBandModeNB7 == aAmrParam.eAMRBandMode)
+    {
+        ipEncProps->iMode = ipGsmEncoder->GSM_AMR_12_2;
+    }
+    else
+    {
+        //unsupported mode
+        return OMX_FALSE;
+    }
+
+    //Adding all the param verification here before allocating them into ipEncProps
+    if ((16 != aPcmMode.nBitPerSample) ||
+            (8000 != aPcmMode.nSamplingRate) ||
+            (1 != aPcmMode.nChannels))
+    {
+        return OMX_FALSE;
+    }
+
+
+    ipEncProps->iInBitsPerSample  = aPcmMode.nBitPerSample;
+    ipEncProps->iInSamplingRate   = aPcmMode.nSamplingRate;
+    ipEncProps->iInClockRate      = 1000;
+    ipEncProps->iInNumChannels    = (uint8)aPcmMode.nChannels;
+    ipEncProps->iInInterleaveMode = TEncodeProperties::EINTERLEAVE_LR;
+
+    ipEncProps->iBitStreamFormat = (iOutputFormat == PVMF_MIME_AMR_IF2);
+    ipEncProps->iAudioObjectType    = 0; // only for AAC encoder
+    ipEncProps->iOutSamplingRate    = aPcmMode.nSamplingRate;
+    ipEncProps->iOutNumChannels     = (uint8)aPcmMode.nChannels;
+    ipEncProps->iOutClockRate       = ipEncProps->iInClockRate;
+
+    // initialize the amr encoder
+    MaxOutputBufferSize = iMaxNumOutputFramesPerBuffer * MAX_AMR_FRAME_SIZE;
+    if (ipGsmEncoder->InitializeEncoder(MaxOutputBufferSize, ipEncProps) < 0)
+    {
+        return OMX_FALSE;
+    }
+
+    ipSizeArrayForOutputFrames = (int32*) oscl_malloc(iMaxNumOutputFramesPerBuffer * sizeof(int32));
+    oscl_memset(ipSizeArrayForOutputFrames, 0, iMaxNumOutputFramesPerBuffer * sizeof(int32));
+
+    iOneInputFrameLength = AMR_FRAME_LENGTH_IN_TIMESTAMP * ipEncProps->iInSamplingRate * ipEncProps->iInBitsPerSample / 8000;
+    iMaxInputSize = iMaxNumOutputFramesPerBuffer * iOneInputFrameLength;
+
+    *aInputFrameLength = iOneInputFrameLength;
+
+    *aMaxNumberOutputFrames = iMaxNumOutputFramesPerBuffer;
+
+    return OMX_TRUE;
+}
+
+
+/* Decoder De-Initialization function */
+void OmxAmrEncoder::AmrEncDeinit()
+{
+    if (ipGsmEncoder)
+    {
+        ipGsmEncoder->CleanupEncoder();
+        OSCL_DELETE(ipGsmEncoder);
+        ipGsmEncoder = NULL;
+    }
+
+    if (ipEncProps)
+    {
+        OSCL_DELETE(ipEncProps);
+        ipEncProps = NULL;
+    }
+
+    if (ipSizeArrayForOutputFrames)
+    {
+        oscl_free(ipSizeArrayForOutputFrames);
+        ipSizeArrayForOutputFrames = NULL;
+    }
+}
+
+
+/* Decode function for all the input formats */
+OMX_BOOL OmxAmrEncoder::AmrEncodeFrame(OMX_U8*    aOutputBuffer,
+                                       OMX_U32*   aOutputLength,
+                                       OMX_U8*    aInBuffer,
+                                       OMX_U32    aInBufSize,
+                                       OMX_TICKS  aInTimeStamp,
+                                       OMX_TICKS* aOutTimeStamp)
+{
+
+    TInputAudioStream StreamInput;
+    TOutputAudioStream StreamOutput;
+    int32 InputFrameNum;
+
+    StreamOutput.iBitStreamBuffer = (uint8*) aOutputBuffer;
+    StreamOutput.iNumSampleFrames = 0;
+    StreamOutput.iSampleFrameSize = ipSizeArrayForOutputFrames;
+
+    //Calculate the number of input frames to be encoded
+    InputFrameNum = aInBufSize / iOneInputFrameLength;
+
+    StreamInput.iSampleBuffer = (uint8*) aInBuffer;
+    StreamInput.iSampleLength = (int32) aInBufSize;
+    StreamInput.iMode		  = ipEncProps->iMode;
+    StreamInput.iStartTime	  = (iNextStartTime >= aInTimeStamp  ? iNextStartTime : aInTimeStamp);
+    StreamInput.iStopTime	  = StreamInput.iStartTime + AMR_FRAME_LENGTH_IN_TIMESTAMP * InputFrameNum;
+    iNextStartTime			  = StreamInput.iStopTime; // for the next encoding
+
+    // Do encoding at one time for multiple frame input
+    if (ipGsmEncoder->Encode(StreamInput, StreamOutput) < 0 || StreamOutput.iNumSampleFrames != InputFrameNum)
+    {
+        return OMX_FALSE;
+    }
+
+    // For IETF, make a conversion from WMF
+    uint8* TmpBuffer = StreamOutput.iBitStreamBuffer;
+    uint32 ii;
+
+    for (ii = 0; ii < (uint32)StreamOutput.iNumSampleFrames; ii++)
+    {
+        // for IETF format, we need to make change
+        if (!ipEncProps->iBitStreamFormat)
+        {
+            // non-IF2 => IETF format, not WMF format
+            TmpBuffer[0] = (uint8)(((TmpBuffer[0] << 3) | 0x4) & 0x7C); // IETF frame header: P(1) + FT(4) + Q(1) + P(2) , Q=1 for good frame, P=padding bit, 0
+            TmpBuffer += StreamOutput.iSampleFrameSize[ii];
+        }
+
+        // Set fragment length
+        *aOutputLength += StreamOutput.iSampleFrameSize[ii];
+    }
+
+    //Set the output buffer timestamp equal to the input buffer start time.
+    *aOutTimeStamp = StreamInput.iStartTime;
+
+    return OMX_TRUE;
+}
+
+
+
diff --git a/codecs_v2/omx/omx_amrenc/src/omx_amrenc_component.cpp b/codecs_v2/omx/omx_amrenc/src/omx_amrenc_component.cpp
new file mode 100644
index 0000000..e41d138
--- /dev/null
+++ b/codecs_v2/omx/omx_amrenc/src/omx_amrenc_component.cpp
@@ -0,0 +1,689 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "omx_amrenc_component.h"
+
+#if PROXY_INTERFACE
+#include "omx_proxy_interface.h"
+#endif
+
+
+
+// This function is called by OMX_GetHandle and it creates an instance of the amr component AO
+OMX_ERRORTYPE AmrEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    OmxComponentAmrEncoderAO* pOpenmaxAOType;
+    OMX_ERRORTYPE Status;
+
+    // move InitAmrOmxComponentFields content to actual constructor
+
+    pOpenmaxAOType = (OmxComponentAmrEncoderAO*) OSCL_NEW(OmxComponentAmrEncoderAO, ());
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Call the construct component to initialize OMX types
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
+
+    *pHandle = pOpenmaxAOType->GetOmxHandle();
+
+    return Status;
+    ///////////////////////////////////////////////////////////////////////////////////////
+}
+
+// This function is called by OMX_FreeHandle when component AO needs to be destroyed
+OMX_ERRORTYPE AmrEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    // get pointer to component AO
+    OmxComponentAmrEncoderAO* pOpenmaxAOType = (OmxComponentAmrEncoderAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
+
+    // clean up encoder, OMX component stuff
+    pOpenmaxAOType->DestroyComponent();
+
+    // destroy the AO class
+    OSCL_DELETE(pOpenmaxAOType);
+
+    return OMX_ErrorNone;
+}
+
+#if DYNAMIC_LOAD_OMX_AMRENC_COMPONENT
+class AmrEncOmxSharedLibraryInterface:  public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static AmrEncOmxSharedLibraryInterface *Instance()
+        {
+            static AmrEncOmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_AMRENC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AmrEncOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AmrEncOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        AmrEncOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return AmrEncOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+OMX_ERRORTYPE OmxComponentAmrEncoderAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
+{
+    ComponentPortType* pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
+
+    iNumPorts = 2;
+    iCompressedFormatPortNum = OMX_PORT_OUTPUTPORT_INDEX;
+    iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
+    iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
+    iOmxComponent.pApplicationPrivate = pAppData; // init the App data
+
+
+#if PROXY_INTERFACE
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
+
+    iOmxComponent.SendCommand = OmxComponentAmrEncoderAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OmxComponentAmrEncoderAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OmxComponentAmrEncoderAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OmxComponentAmrEncoderAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OmxComponentAmrEncoderAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentAmrEncoderAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentAmrEncoderAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OmxComponentAmrEncoderAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentAmrEncoderAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentAmrEncoderAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentAmrEncoderAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentAmrEncoderAO::BaseComponentProxyFillThisBuffer;
+
+#else
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
+
+    iOmxComponent.SendCommand = OmxComponentAmrEncoderAO::BaseComponentSendCommand;
+    iOmxComponent.GetParameter = OmxComponentAmrEncoderAO::BaseComponentGetParameter;
+    iOmxComponent.SetParameter = OmxComponentAmrEncoderAO::BaseComponentSetParameter;
+    iOmxComponent.GetConfig = OmxComponentAmrEncoderAO::BaseComponentGetConfig;
+    iOmxComponent.SetConfig = OmxComponentAmrEncoderAO::BaseComponentSetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentAmrEncoderAO::BaseComponentGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentAmrEncoderAO::BaseComponentGetState;
+    iOmxComponent.UseBuffer = OmxComponentAmrEncoderAO::BaseComponentUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentAmrEncoderAO::BaseComponentAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentAmrEncoderAO::BaseComponentFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentAmrEncoderAO::BaseComponentEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentAmrEncoderAO::BaseComponentFillThisBuffer;
+#endif
+
+    iOmxComponent.SetCallbacks = OmxComponentAmrEncoderAO::BaseComponentSetCallbacks;
+    iOmxComponent.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
+    iOmxComponent.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
+    iOmxComponent.nVersion.s.nRevision = SPECREVISION;
+    iOmxComponent.nVersion.s.nStep = SPECSTEP;
+
+    // PV capability
+    iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
+
+    if (ipAppPriv)
+    {
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
+    if (NULL == ipAppPriv)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
+    {
+        return Status;
+    }
+
+    /** Domain specific section for the ports */
+    /* Input port is raw/pcm for AMR encoder */
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"raw";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDir = OMX_DirInput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_INPUT_BUFFER_AMR_ENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize = INPUT_BUFFER_SIZE_AMR_ENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+
+    /* Output port is amr format for AMR encoder */
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"audio/mpeg";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingAMR;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDir = OMX_DirOutput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_OUTPUT_BUFFER_AMR_ENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferSize = OUTPUT_BUFFER_SIZE_AMR_ENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+    //Default values for PCM input audio param port
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.nChannels = 1;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.eNumData = OMX_NumericalDataSigned;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.bInterleaved = OMX_TRUE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.nBitPerSample = 16;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.nSamplingRate = 8000;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.ePCMMode = OMX_AUDIO_PCMModeLinear;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
+
+    //Default values for AMR output audio param port
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAmrParam.nChannels = 1;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAmrParam.nBitRate = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAmrParam.eAMRBandMode = OMX_AUDIO_AMRBandModeNB7;	//AMRNB Mode 7 = 12200 bps
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAmrParam.eAMRDTXMode = OMX_AUDIO_AMRDTXModeOnVAD1;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAmrParam.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;	//PVMF_AMR_IETF
+
+    iPortTypesParam.nPorts = 2;
+    iPortTypesParam.nStartPortNumber = 0;
+
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+
+    SetHeader(&pInPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+    pInPort->AudioParam.nPortIndex = 0;
+    pInPort->AudioParam.nIndex = 0;
+    pInPort->AudioParam.eEncoding = OMX_AUDIO_CodingPCM;
+
+    SetHeader(&pOutPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+    pOutPort->AudioParam.nPortIndex = 1;
+    pOutPort->AudioParam.nIndex = 0;
+    pOutPort->AudioParam.eEncoding = OMX_AUDIO_CodingAMR;
+
+    iInputBufferRemainingBytes = 0;
+
+    if (ipAmrEnc)
+    {
+        OSCL_DELETE(ipAmrEnc);
+        ipAmrEnc = NULL;
+    }
+
+    ipAmrEnc = OSCL_NEW(OmxAmrEncoder, ());
+    if (NULL == ipAmrEnc)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+
+#if PROXY_INTERFACE
+
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+
+#endif
+    return OMX_ErrorNone;
+}
+
+
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	* \param Component, the component to be disposed
+	*/
+
+OMX_ERRORTYPE OmxComponentAmrEncoderAO::DestroyComponent()
+{
+    if (iIsInit != OMX_FALSE)
+    {
+        ComponentDeInit();
+    }
+
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipAmrEnc)
+    {
+        OSCL_DELETE(ipAmrEnc);
+        ipAmrEnc = NULL;
+    }
+
+    if (ipAppPriv)
+    {
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+
+/* This routine will extract the input timestamp from the input buffer */
+void OmxComponentAmrEncoderAO::SyncWithInputTimestamp()
+{
+    iCurrentTimestamp = iFrameTimestamp;
+}
+
+
+void OmxComponentAmrEncoderAO::ProcessData()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ProcessData IN"));
+
+    QueueType* pInputQueue  = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    ComponentPortType* pInPort  = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    OMX_COMPONENTTYPE* pHandle  = &iOmxComponent;
+
+    OMX_U8*	 pOutBuffer;
+    OMX_U32	 OutputLength;
+    OMX_S32  EncodeReturn;
+    OMX_U32  RemainderInputBytes = 0;
+    OMX_TICKS OutputTimeStamp;
+
+    OMX_U32 TempInputBufferSize = (2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
+
+    OMX_U32 AllocNumberOutputFrames;
+    OMX_U32 ExtraInputBytes = 0;
+
+    if ((!iIsInputBufferEnded) || iEndofStream)
+    {
+        //Check whether prev output bufer has been released or not
+        if (OMX_TRUE == iNewOutBufRequired)
+        {
+            //Check whether a new output buffer is available or not
+            if (0 == (GetQueueNumElem(pOutputQueue)))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ProcessData OUT output buffer unavailable"));
+                return;
+            }
+
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer->nFilledLen = 0;
+            iNewOutBufRequired = OMX_FALSE;
+
+            //At the first frame count, detrermine the output parameters
+            if (0 == iFrameCount)
+            {
+                //How many frames can be accomodated in the output buffer
+                AllocNumberOutputFrames = ipOutputBuffer->nAllocLen / MAX_AMR_FRAME_SIZE;
+                iActualNumberOutputFrames = omx_min(AllocNumberOutputFrames, iMaxNumberOutputFrames);
+
+                /* Keep the minimum of the two:
+                	-frames accomodated and
+                	-maximum frames defined by component */
+                iOutputFrameLength = iActualNumberOutputFrames * MAX_AMR_FRAME_SIZE;
+            }
+        }
+
+        /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
+         * command and hMarkTargetComponent as given by the specifications
+         */
+        if (ipMark != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipMark = NULL;
+        }
+
+        if (ipTargetComponent != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
+            ipTargetComponent = NULL;
+
+        }
+        //Mark buffer code ends here
+
+
+        if ((iTempInputBufferLength > 0) &&
+                ((iInputCurrLength + iTempInputBufferLength) <= TempInputBufferSize))
+        {
+            oscl_memcpy(&ipTempInputBuffer[iTempInputBufferLength], ipFrameDecodeBuffer, iInputCurrLength);
+            iInputCurrLength += iTempInputBufferLength;
+            iTempInputBufferLength = 0;
+            ipFrameDecodeBuffer = ipTempInputBuffer;
+        }
+
+
+        //If the number of output buffers to be produced from the current iInputCurrLength
+        //are more than our requirement, send only the required data for encoding
+        if (iInputCurrLength / iInputFrameLength > iActualNumberOutputFrames)
+        {
+            ExtraInputBytes = iInputCurrLength - (iInputFrameLength * iActualNumberOutputFrames);
+            iInputCurrLength -= ExtraInputBytes;
+        }
+        else
+        {
+            /* Before sending the input buffer to the encoder, ensure that the data is multiple
+             * of one amr input frame length*/
+            RemainderInputBytes = iInputCurrLength % iInputFrameLength;
+            iInputCurrLength -= RemainderInputBytes;
+        }
+
+
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
+        OutputLength = 0;
+
+        EncodeReturn = ipAmrEnc->AmrEncodeFrame(pOutBuffer,
+                                                &OutputLength,
+                                                ipFrameDecodeBuffer,
+                                                iInputCurrLength,
+                                                iCurrentTimestamp,
+                                                &OutputTimeStamp);
+
+
+        //Attach the timestamp to the output buffer only when we have fetched the new output buffer
+        //If we are reusing the same output buffer again, no need to modify the previous timestamp, as it should be of the first frame in that buffer
+
+        if (0 == ipOutputBuffer->nFilledLen)
+        {
+            ipOutputBuffer->nTimeStamp = OutputTimeStamp;
+        }
+
+
+        ipOutputBuffer->nFilledLen += OutputLength;
+        //offset not required in our case, set it to zero
+        ipOutputBuffer->nOffset = 0;
+
+        //It has to be incremented atleast one time, so that 'equality with zero' checks added above hold true only once
+        iFrameCount++;
+
+
+        /* If EOS flag has come from the client & there are no more
+         * input buffers to decode, send the callback to the client
+         */
+        if (OMX_TRUE == iEndofStream)
+        {
+            if ((0 == iInputCurrLength) || (OMX_TRUE != EncodeReturn))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ProcessData EOS callback send"));
+
+                (*(ipCallbacks->EventHandler))
+                (pHandle,
+                 iCallbackData,
+                 OMX_EventBufferFlag,
+                 1,
+                 OMX_BUFFERFLAG_EOS,
+                 NULL);
+
+                iEndofStream = OMX_FALSE;
+
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ProcessData OUT"));
+
+                return;
+            }
+        }
+
+
+        if (OMX_TRUE == EncodeReturn)
+        {
+            //Do not return the input buffer in case it has more than one frame data to encode
+            if (ExtraInputBytes > 0)
+            {
+                ipFrameDecodeBuffer += iInputCurrLength;
+                iInputCurrLength = ExtraInputBytes;
+            }
+            else
+            {
+
+                /* If there are some remainder bytes out of the last buffer, copy into a temp buffer
+                 * to be used in next decode cycle and return the existing input buffer*/
+                if (RemainderInputBytes > 0)
+                {
+                    oscl_memcpy(ipTempInputBuffer, &ipFrameDecodeBuffer[iInputCurrLength], RemainderInputBytes);
+                    iTempInputBufferLength = RemainderInputBytes;
+                }
+
+                //Input bytes consumed now, return the buffer
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
+                iIsInputBufferEnded = OMX_TRUE;
+                iInputCurrLength = 0;
+
+            }
+        }
+        //In case of error, discard the bitstream and report data corruption error via callback
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ProcessData ErrorStreamCorrupt callback send"));
+
+            ipInputBuffer->nFilledLen = 0;
+            ReturnInputBuffer(ipInputBuffer, pInPort);
+            iIsInputBufferEnded = OMX_TRUE;
+            iInputCurrLength = 0;
+
+
+            (*(ipCallbacks->EventHandler))
+            (pHandle,
+             iCallbackData,
+             OMX_EventError,
+             OMX_ErrorStreamCorrupt,
+             0,
+             NULL);
+        }
+
+
+        /* Send the output buffer back when it has the following conditions as true:
+        1) Output buffer contain desired number of frames, calculated above
+        2) Output buffer can no longer hold the desired number of frames that
+           we will encode in next encode call
+        */
+        if ((ipOutputBuffer->nFilledLen >= iOutputFrameLength)
+                || (ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
+        {
+            //Attach the end of frame flag while sending out the output buffer
+            ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+        }
+
+
+        /* If there is some more processing left with current buffers, re-schedule the AO
+         * Do not go for more than one round of processing at a time.
+         * This may block the AO longer than required.
+         */
+        if (((ipInputBuffer->nFilledLen != 0) || (GetQueueNumElem(pInputQueue) > 0))
+                && ((GetQueueNumElem(pOutputQueue) > 0) || (OMX_FALSE == iNewOutBufRequired)))
+        {
+            RunIfNotReady();
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ProcessData OUT"));
+    return;
+}
+
+
+//Not implemented & supported in case of base profile components
+
+void OmxComponentAmrEncoderAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
+{
+    *aRoleString = (OMX_STRING)"audio_encoder.amr";
+}
+
+
+//Component constructor
+OmxComponentAmrEncoderAO::OmxComponentAmrEncoderAO()
+{
+    ipAmrEnc = NULL;
+    iInputFrameLength = 0;
+    iOutputFrameLength = 0;
+    iActualNumberOutputFrames = 0;
+    iMaxNumberOutputFrames = 0;
+
+    if (!IsAdded())
+    {
+        AddToScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : constructed"));
+}
+
+
+//Active object destructor
+OmxComponentAmrEncoderAO::~OmxComponentAmrEncoderAO()
+{
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : destructed"));
+}
+
+
+/** The Initialization function
+ */
+OMX_ERRORTYPE OmxComponentAmrEncoderAO::ComponentInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ComponentInit IN"));
+
+    OMX_BOOL Status = OMX_TRUE;
+
+    if (OMX_TRUE == iIsInit)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ComponentInit error incorrect operation"));
+        return OMX_ErrorIncorrectStateOperation;
+    }
+    iIsInit = OMX_TRUE;
+
+    //amr encoder lib init
+    if (!iCodecReady)
+    {
+        Status = ipAmrEnc->AmrEncInit(ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioPcmMode,
+                                      ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioAmrParam,
+                                      &iInputFrameLength, &iMaxNumberOutputFrames);
+
+        iCodecReady = OMX_TRUE;
+    }
+
+    iInputCurrLength = 0;
+
+    //Used in dynamic port reconfiguration
+    iFrameCount = 0;
+
+    if (OMX_TRUE == Status)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ComponentInit OUT"));
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : Error ComponentInit, OUT"));
+        return OMX_ErrorInvalidComponent;
+    }
+}
+
+
+
+/** This function is called upon a transition to the idle or invalid state.
+ *  Also it is called by the ComponentDestructor() function
+ */
+OMX_ERRORTYPE OmxComponentAmrEncoderAO::ComponentDeInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ComponentDeInit IN"));
+
+    iIsInit = OMX_FALSE;
+
+    if (iCodecReady)
+    {
+        ipAmrEnc->AmrEncDeinit();
+        iCodecReady = OMX_FALSE;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAmrEncoderAO : ComponentDeInit OUT"));
+
+    return OMX_ErrorNone;
+
+}
+
+
+/* A component specific routine called from BufferMgmtWithoutMarker */
+void OmxComponentAmrEncoderAO::ProcessInBufferFlag()
+{
+    iIsInputBufferEnded = OMX_FALSE;
+}
diff --git a/codecs_v2/omx/omx_baseclass/Android.mk b/codecs_v2/omx/omx_baseclass/Android.mk
new file mode 100644
index 0000000..f0b8049
--- /dev/null
+++ b/codecs_v2/omx/omx_baseclass/Android.mk
@@ -0,0 +1,29 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pv_omxcomponent.cpp
+
+
+LOCAL_MODULE := libomx_baseclass_lib
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_baseclass/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_baseclass/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	include/pv_omxcomponent.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/omx/omx_baseclass/build/make/local.mk b/codecs_v2/omx/omx_baseclass/build/make/local.mk
new file mode 100644
index 0000000..8841546
--- /dev/null
+++ b/codecs_v2/omx/omx_baseclass/build/make/local.mk
@@ -0,0 +1,22 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_baseclass_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += ../../../../../extern_libs_v2/khronos/openmax/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_omxcomponent.cpp
+
+HDRS := pv_omxcomponent.h
+
+include $(MK)/library.mk
diff --git a/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h b/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h
new file mode 100644
index 0000000..a5b8cc5
--- /dev/null
+++ b/codecs_v2/omx/omx_baseclass/include/pv_omxcomponent.h
@@ -0,0 +1,571 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+	@file pv_omxcomponent.h
+	OpenMax decoder_component base header file.
+
+*/
+
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#define PV_OMXCOMPONENT_H_INCLUDED
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+
+#ifndef OSCL_SCHEDULER_H_INCLUDED
+#include "oscl_scheduler.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PV_OMX_QUEUE_H_INCLUDED
+#include "pv_omx_queue.h"
+#endif
+
+#ifndef PV_OMXCORE_H_INCLUDED
+#include "pv_omxcore.h"
+#endif
+
+#define OMX_PORT_INPUTPORT_INDEX OMX_DirInput
+#define OMX_PORT_OUTPUTPORT_INDEX OMX_DirOutput
+#define OMX_PORT_ALLPORT_INDEX -1
+
+#define OMX_PORT_NUMBER_FORMATS_SUPPORTED 3
+
+
+/* Application's private data */
+typedef struct ComponentPrivateType
+{
+    OMX_HANDLETYPE CompHandle;
+
+}ComponentPrivateType;
+
+/**
+ * This is the Component template from which all
+ * other Component instances are factored by the core.
+ */
+/**
+ * The structure for port Type.
+ */
+typedef struct ComponentPortType
+{
+    /** @param pBuffer An array of pointers to buffer headers. */
+    OMX_BUFFERHEADERTYPE** pBuffer;
+    /** @param BufferState The State of the Buffer whether assigned or allocated */
+    OMX_U32* BufferState;
+    /** @param NumAssignedBuffers Number of buffer assigned on each port */
+    OMX_U32 NumAssignedBuffers;
+    /** @param pBufferQueue queue for buffer to be processed by the port */
+    QueueType* pBufferQueue;
+    OMX_STATETYPE TransientState;
+    /** @param BufferUnderProcess  Boolean variables indicate whether the port is processing any buffer */
+    OMX_BOOL BufferUnderProcess;
+    OMX_PARAM_PORTDEFINITIONTYPE PortParam;
+    /** @param NumBufferFlushed Number of buffer Flushed */
+    OMX_U32 NumBufferFlushed;
+    /** @param IsPortFlushed Boolean variables indicate port is being flushed at the moment */
+    OMX_BOOL IsPortFlushed;
+
+    //AUDIO SPECIFIC PARAMETERS
+    OMX_AUDIO_PARAM_PORTFORMATTYPE	AudioParam;
+    OMX_AUDIO_PARAM_PCMMODETYPE		AudioPcmMode;
+    OMX_AUDIO_PARAM_WMATYPE			AudioWmaParam;
+    OMX_AUDIO_PARAM_MP3TYPE			AudioMp3Param;
+    OMX_AUDIO_CONFIG_EQUALIZERTYPE	AudioEqualizerType;
+    OMX_AUDIO_PARAM_AACPROFILETYPE	AudioAacParam;
+    OMX_AUDIO_PARAM_AMRTYPE			AudioAmrParam;
+
+    //VIDEO SPECIFIC PARAMETERS
+    OMX_VIDEO_PARAM_PORTFORMATTYPE	 VideoParam[OMX_PORT_NUMBER_FORMATS_SUPPORTED];
+    OMX_VIDEO_PARAM_PROFILELEVELTYPE ProfileLevel;
+    OMX_VIDEO_PARAM_MPEG4TYPE		 VideoMpeg4;
+    OMX_VIDEO_PARAM_H263TYPE		 VideoH263;
+    OMX_VIDEO_PARAM_AVCTYPE			 VideoAvc;
+    OMX_VIDEO_PARAM_WMVTYPE			 VideoWmv;
+
+    //VIDEO ENCODER SPECIFIC PARAMETERS
+    OMX_CONFIG_ROTATIONTYPE				VideoOrientationType;
+    OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE VideoErrorCorrection;
+    OMX_VIDEO_PARAM_BITRATETYPE			VideoRateType;		//Only for rate control type in mpeg4
+    OMX_VIDEO_PARAM_QUANTIZATIONTYPE	VideoQuantType;
+    OMX_VIDEO_PARAM_VBSMCTYPE			VideoBlockMotionSize;
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE	VideoMotionVector;
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE	VideoIntraRefresh;
+    OMX_VIDEO_PARAM_AVCSLICEFMO			AvcSliceFMO;
+
+    OMX_CONFIG_FRAMERATETYPE			VideoConfigFrameRateType;
+    OMX_VIDEO_CONFIG_BITRATETYPE		VideoConfigBitRateType;
+
+    //This will be used to dynamically request the Iframe using SetConfig API
+    OMX_CONFIG_INTRAREFRESHVOPTYPE		VideoIFrame;
+
+    OMX_U32  ActualNumPortFormatsSupported;
+
+} ComponentPortType;
+
+
+
+class OmxComponentBase : public OsclActiveObject
+{
+    public:
+
+        OmxComponentBase();
+        virtual ~OmxComponentBase() {}
+
+        /** Component entry points declarations without proxy interface*/
+        static OMX_ERRORTYPE BaseComponentGetComponentVersion(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_OUT OMX_STRING pComponentName,
+            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
+            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
+            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+
+        static OMX_ERRORTYPE BaseComponentGetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_INOUT OMX_PTR pComponentConfigStructure);
+
+        static OMX_ERRORTYPE BaseComponentSetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_IN  OMX_PTR pComponentConfigStructure);
+
+        static OMX_ERRORTYPE BaseComponentGetExtensionIndex(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_STRING cParameterName,
+            OMX_OUT OMX_INDEXTYPE* pIndexType);
+
+        static OMX_ERRORTYPE BaseComponentGetState(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_OUT OMX_STATETYPE* pState);
+
+        static OMX_ERRORTYPE BaseComponentGetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+        static OMX_ERRORTYPE BaseComponentSetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_IN  OMX_PTR ComponentParameterStructure);
+
+        static OMX_ERRORTYPE BaseComponentUseBuffer(
+            OMX_IN OMX_HANDLETYPE hComponent,
+            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+            OMX_IN OMX_U32 nPortIndex,
+            OMX_IN OMX_PTR pAppPrivate,
+            OMX_IN OMX_U32 nSizeBytes,
+            OMX_IN OMX_U8* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentAllocateBuffer(
+            OMX_IN OMX_HANDLETYPE hComponent,
+            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
+            OMX_IN OMX_U32 nPortIndex,
+            OMX_IN OMX_PTR pAppPrivate,
+            OMX_IN OMX_U32 nSizeBytes);
+
+        static OMX_ERRORTYPE BaseComponentFreeBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_U32 nPortIndex,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentSendCommand(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_COMMANDTYPE Cmd,
+            OMX_IN  OMX_U32 nParam,
+            OMX_IN  OMX_PTR pCmdData);
+
+        static OMX_ERRORTYPE BaseComponentComponentDeInit(
+            OMX_IN  OMX_HANDLETYPE hComponent);
+
+        static OMX_ERRORTYPE BaseComponentEmptyThisBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentFillThisBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentSetCallbacks(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+            OMX_IN  OMX_PTR pAppData);
+
+        /** Component entry points declarations with proxy interface*/
+#if PROXY_INTERFACE
+        static OMX_ERRORTYPE BaseComponentProxyGetComponentVersion(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_OUT OMX_STRING pComponentName,
+            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
+            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
+            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+
+        static OMX_ERRORTYPE BaseComponentProxyGetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+        static OMX_ERRORTYPE BaseComponentProxySetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_IN  OMX_PTR ComponentParameterStructure);
+
+        static OMX_ERRORTYPE BaseComponentProxyGetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_INOUT OMX_PTR pComponentConfigStructure);
+
+        static OMX_ERRORTYPE BaseComponentProxySetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_IN  OMX_PTR pComponentConfigStructure);
+
+        static OMX_ERRORTYPE BaseComponentProxyGetExtensionIndex(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_STRING cParameterName,
+            OMX_OUT OMX_INDEXTYPE* pIndexType);
+
+        static OMX_ERRORTYPE BaseComponentProxyGetState(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_OUT OMX_STATETYPE* pState);
+
+        static OMX_ERRORTYPE BaseComponentProxyUseBuffer(
+            OMX_IN OMX_HANDLETYPE hComponent,
+            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+            OMX_IN OMX_U32 nPortIndex,
+            OMX_IN OMX_PTR pAppPrivate,
+            OMX_IN OMX_U32 nSizeBytes,
+            OMX_IN OMX_U8* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentProxyAllocateBuffer(
+            OMX_IN OMX_HANDLETYPE hComponent,
+            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
+            OMX_IN OMX_U32 nPortIndex,
+            OMX_IN OMX_PTR pAppPrivate,
+            OMX_IN OMX_U32 nSizeBytes);
+
+        static OMX_ERRORTYPE BaseComponentProxyFreeBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_U32 nPortIndex,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentProxySendCommand(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_COMMANDTYPE Cmd,
+            OMX_IN  OMX_U32 nParam,
+            OMX_IN  OMX_PTR pCmdData);
+
+        static OMX_ERRORTYPE BaseComponentProxyComponentDeInit(
+            OMX_IN  OMX_HANDLETYPE hComponent);
+
+        static OMX_ERRORTYPE BaseComponentProxyEmptyThisBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentProxyFillThisBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        static OMX_ERRORTYPE BaseComponentProxySetCallbacks(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+            OMX_IN  OMX_PTR pAppData);
+
+#endif // PROXY_INTERFACE
+
+        /*NON STATIC COUNTERPARTS OF STATIC MEMBER API'S */
+
+        //Pure virtual functions, definition to be written in derived class
+        virtual OMX_ERRORTYPE GetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_INOUT OMX_PTR ComponentParameterStructure) = 0;
+
+        virtual OMX_ERRORTYPE SetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_IN  OMX_PTR ComponentParameterStructure) = 0;
+
+        virtual OMX_ERRORTYPE GetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_INOUT OMX_PTR pComponentConfigStructure);
+
+        //Making Setconfig as virtual function to be implemented in respective component class
+        virtual OMX_ERRORTYPE SetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_IN  OMX_PTR pComponentConfigStructure);
+
+        OMX_ERRORTYPE GetExtensionIndex(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_STRING cParameterName,
+            OMX_OUT OMX_INDEXTYPE* pIndexType);
+
+        void GetState(OMX_OUT OMX_STATETYPE* pState);
+
+        OMX_ERRORTYPE UseBuffer(
+            OMX_IN OMX_HANDLETYPE hComponent,
+            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+            OMX_IN OMX_U32 nPortIndex,
+            OMX_IN OMX_PTR pAppPrivate,
+            OMX_IN OMX_U32 nSizeBytes,
+            OMX_IN OMX_U8* pBuffer);
+
+        OMX_ERRORTYPE AllocateBuffer(
+            OMX_IN OMX_HANDLETYPE hComponent,
+            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
+            OMX_IN OMX_U32 nPortIndex,
+            OMX_IN OMX_PTR pAppPrivate,
+            OMX_IN OMX_U32 nSizeBytes);
+
+        OMX_ERRORTYPE FreeBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_U32 nPortIndex,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        OMX_ERRORTYPE SendCommand(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_COMMANDTYPE Cmd,
+            OMX_IN  OMX_S32 nParam,
+            OMX_IN  OMX_PTR pCmdData);
+
+        OMX_ERRORTYPE EmptyThisBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        OMX_ERRORTYPE FillThisBuffer(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
+
+        OMX_ERRORTYPE SetCallbacks(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+            OMX_IN  OMX_PTR pAppData);
+
+
+        OMX_PTR GetOmxHandle()
+        {
+            return &iOmxComponent;
+        };
+
+        /*OTHER PROCESSING FUNCTIONS */
+
+        //Pure virtual function called from base, must have a definition in derived components
+        //virtual void Decode() = 0;
+        virtual void ProcessData() = 0;
+
+        virtual void BufferMgmtFunction();
+        virtual OMX_BOOL BufferMgmtWithoutMarker();
+        //Extra routines called from BufferMgmtWithoutMarker that may vary from component to component
+        virtual void ComponentBufferMgmtWithoutMarker();
+        void TempInputBufferMgmtWithoutMarker();
+
+
+        virtual void ProcessInBufferFlag() {};
+
+        /* This function will exist only for audio components, thats why can't be made puire virtual
+           Also putting it into the audio base class will require a check everytime in the
+           BufferMgmtFunction() to create either an audio or video pointer to access this function
+        */
+        virtual void SyncWithInputTimestamp() {};
+        virtual void ResetComponent() {};
+        virtual OMX_ERRORTYPE ReAllocatePartialAssemblyBuffers(OMX_BUFFERHEADERTYPE* aInputBufferHdr)
+        {
+            OSCL_UNUSED_ARG(aInputBufferHdr);
+            return OMX_ErrorNone;
+        }
+
+        OMX_BOOL AssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer);
+        OMX_ERRORTYPE MessageHandler(CoreMessage* Message);
+        OMX_ERRORTYPE DoStateSet(OMX_U32);
+
+        OMX_ERRORTYPE DisablePort(OMX_S32 PortIndex);
+        void DisableSinglePort(OMX_U32 PortIndex);
+
+        OMX_ERRORTYPE EnablePort(OMX_S32 PortIndex);
+        void EnableSinglePort(OMX_U32 PortIndex);
+
+        OMX_ERRORTYPE FlushPort(OMX_S32 PortIndex);
+        void SetPortFlushFlag(OMX_S32, OMX_S32 index, OMX_BOOL value);
+        void SetNumBufferFlush(OMX_S32, OMX_S32 index, OMX_S32 value);
+
+        void ReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, ComponentPortType* pPort);
+        void ReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, ComponentPortType* pPort);
+
+        virtual OMX_ERRORTYPE ComponentInit() = 0;
+        virtual OMX_ERRORTYPE ComponentDeInit() = 0;
+
+        OMX_ERRORTYPE ConstructBaseComponent(OMX_PTR pAppData);
+        OMX_ERRORTYPE DestroyBaseComponent();
+
+        OMX_ERRORTYPE TunnelRequest(
+            OMX_IN  OMX_HANDLETYPE hComp,
+            OMX_IN  OMX_U32 nPort,
+            OMX_IN  OMX_HANDLETYPE hTunneledComp,
+            OMX_IN  OMX_U32 nTunneledPort,
+            OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
+
+        OMX_ERRORTYPE ParameterSanityCheck(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_U32 nPortIndex,
+            OMX_IN  OMX_PTR pStructure,
+            OMX_IN  size_t size);
+
+        void SetHeader(OMX_PTR aheader, OMX_U32 asize);
+        OMX_ERRORTYPE CheckHeader(OMX_PTR aheader, OMX_U32 asize);
+
+        void ResetAfterFlush(OMX_S32 PortIndex);
+
+        //Flag to call BufferMgmtFunction in the RunL() when the component state is executing
+        OMX_BOOL				iBufferExecuteFlag;
+        ComponentPrivateType*	ipAppPriv;
+
+
+    protected:
+
+        PVLogger* iLogger;
+
+        void Run();
+
+        OMX_CALLBACKTYPE*	ipCallbacks;
+        OMX_PTR				iCallbackData;
+        OMX_STATETYPE		iState;
+
+        CoreDescriptorType* ipCoreDescriptor;
+        OMX_U32				iNumInputBuffer;
+
+        OMX_U8*				ipFrameDecodeBuffer;
+        OMX_BOOL			iPartialFrameAssembly;
+        OMX_BOOL			iIsInputBufferEnded;
+        OMX_BOOL			iEndofStream;
+        OMX_U8*				ipTempInputBuffer;
+        OMX_U32				iTempInputBufferLength;
+        OMX_COMPONENTTYPE*	ipTargetComponent;
+        OMX_PTR				iTargetMarkData;
+        OMX_COMPONENTTYPE*	ipTempTargetComponent;
+        OMX_PTR				iTempTargetMarkData;
+        OMX_BOOL			iMarkPropagate;
+        OMX_BOOL			iNewInBufferRequired;
+        OMX_BOOL			iNewOutBufRequired;
+        OMX_U32				iTempConsumedLength;
+        OMX_U32				iOutBufferCount;
+        OMX_BOOL			iCodecReady;
+        OMX_U8*				ipInputCurrBuffer;
+        OMX_U32				iInputCurrBufferSize;
+        OMX_U32				iInputCurrLength;
+        OMX_S32				iFrameCount;
+        OMX_BOOL			iStateTransitionFlag;
+
+        OMX_BOOL				iEndOfFrameFlag;
+        OMX_BUFFERHEADERTYPE*	ipInputBuffer;
+        OMX_BUFFERHEADERTYPE*	ipOutputBuffer;
+        OMX_U32					iOutputFrameLength;
+        OMX_COMPONENTTYPE		iOmxComponent;	// structure
+        OMX_U32					iNumPorts;
+        OMX_U32					iCompressedFormatPortNum;
+        OMX_PTR					ipComponentProxy;
+
+        PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
+
+        //The ports of the component
+        ComponentPortType** ipPorts;
+        //Indicate whether component has been already initialized */
+        OMX_BOOL iIsInit;
+        //OpenMAX standard parameter that contains a short description of the available ports
+        OMX_PORT_PARAM_TYPE iPortTypesParam;
+        OMX_U32 iGroupPriority;
+        //ID of a group of components that share the same logical chain
+        OMX_U32 iGroupID;
+        //Roles of the component
+        OMX_U8 iComponentRole[OMX_MAX_STRINGNAME_SIZE];
+        //This field holds the private data associated with a mark request, if any
+        OMX_MARKTYPE* ipMark;
+
+        OMX_BOOL				iEosProcessing;
+        OMX_BOOL				iFirstFragment;
+        OMX_TICKS				iFrameTimestamp;
+        OMX_BOOL				iRepositionFlag;
+        OMX_U32					iSamplesPerFrame;
+        OMX_BOOL				iSilenceInsertionInProgress;
+        OMX_U32					iSilenceFramesNeeded;
+        OMX_U32					iOutputMilliSecPerFrame;
+        OMX_BOOL				iIsFirstOutputFrame;
+        OMX_S32					iInputBufferRemainingBytes;
+        OMX_BOOL				iResizePending;
+        OMX_U8*					ipTempOutBufferForPortReconfig;
+        OMX_U32					iSizeOutBufferForPortReconfig;
+        OMX_BOOL				iSendOutBufferAfterPortReconfigFlag;
+        OMX_TICKS				iTimestampOutBufferForPortReconfig;
+
+
+        OMX_BOOL				iIsAudioComponent;
+
+
+};
+
+
+class OmxComponentAudio : public OmxComponentBase
+{
+    public:
+        OmxComponentAudio();
+        virtual ~OmxComponentAudio() {}
+
+        OMX_ERRORTYPE GetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+        OMX_ERRORTYPE SetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_IN  OMX_PTR ComponentParameterStructure);
+
+        virtual void UpdateAACPlusFlag(OMX_BOOL aAacPlusFlag)
+        {
+            OSCL_UNUSED_ARG(aAacPlusFlag);
+        }
+};
+
+
+
+class OmxComponentVideo : public OmxComponentBase
+{
+    public:
+        OmxComponentVideo();
+        virtual ~OmxComponentVideo() {}
+
+        OMX_ERRORTYPE GetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_INOUT OMX_PTR ComponentParameterStructure);
+
+        OMX_ERRORTYPE SetParameter(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nParamIndex,
+            OMX_IN  OMX_PTR ComponentParameterStructure);
+
+
+};
+
+
+#endif		//#ifndef PV_OMXCOMPONENT_H_INCLUDED
diff --git a/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp b/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp
new file mode 100644
index 0000000..7f5a63f
--- /dev/null
+++ b/codecs_v2/omx/omx_baseclass/src/pv_omxcomponent.cpp
@@ -0,0 +1,4527 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_omxcomponent.h"
+#include "pv_omxdefs.h"
+#include "oscl_types.h"
+
+#if PROXY_INTERFACE
+#include "omx_proxy_interface.h"
+#endif
+
+
+OmxComponentBase::OmxComponentBase() :
+        OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXComponent")
+{
+    iLogger = PVLogger::GetLoggerObject("OmxComponentBase");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : constructed"));
+
+    //Flag to call BufferMgmtFunction in the Run() when the component state is executing
+    iBufferExecuteFlag = OMX_FALSE;
+    ipAppPriv = NULL;
+
+    ipCallbacks = NULL;
+    iCallbackData = NULL;
+    iState = OMX_StateLoaded;
+
+    ipCoreDescriptor = NULL;
+    iNumInputBuffer = 0;
+
+    ipFrameDecodeBuffer = NULL;
+    iPartialFrameAssembly = OMX_FALSE;
+    iIsInputBufferEnded = OMX_TRUE;
+    iEndofStream = OMX_FALSE;
+    ipTempInputBuffer = NULL;
+    iTempInputBufferLength = 0;
+
+    ipTargetComponent = NULL;
+    iTargetMarkData = NULL;
+    iNewInBufferRequired = OMX_TRUE;
+    iNewOutBufRequired = OMX_TRUE;
+
+    iTempConsumedLength = 0;
+    iOutBufferCount = 0;
+    iCodecReady = OMX_FALSE;
+    ipInputCurrBuffer = NULL;
+    iInputCurrLength = 0;
+    iFrameCount = 0;
+    iStateTransitionFlag = OMX_FALSE;
+    iEndOfFrameFlag = OMX_FALSE;
+    ipInputBuffer = NULL;
+    ipOutputBuffer = NULL;
+    iInputCurrBufferSize = 0;
+
+    iEosProcessing = OMX_FALSE;
+    iFirstFragment = OMX_FALSE;
+    iResizePending = OMX_FALSE;
+    iFrameTimestamp = 0;
+    iIsFirstOutputFrame = OMX_TRUE;
+    iSilenceInsertionInProgress = OMX_FALSE;
+
+    iNumPorts = 0;
+    iCompressedFormatPortNum = OMX_PORT_INPUTPORT_INDEX;
+    ipPorts = NULL;
+
+    //Indicate whether component has been already initialized */
+    iIsInit = OMX_FALSE;
+
+    iGroupPriority = 0;
+    iGroupID = 0;
+
+    ipTempOutBufferForPortReconfig = NULL;
+    iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
+    iSizeOutBufferForPortReconfig = 0;
+
+
+    ipMark = NULL;
+
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::ConstructBaseComponent(OMX_PTR pAppData)
+{
+    OSCL_UNUSED_ARG(pAppData);
+    OMX_U32 ii, jj;
+
+    if (iNumPorts)
+    {
+        if (ipPorts)
+        {
+            oscl_free(ipPorts);
+            ipPorts = NULL;
+        }
+
+        ipPorts = (ComponentPortType**) oscl_calloc(iNumPorts, sizeof(ComponentPortType*));
+        if (!ipPorts)
+        {
+            return OMX_ErrorInsufficientResources;
+        }
+
+        for (ii = 0; ii < iNumPorts; ii++)
+        {
+            ipPorts[ii] = (ComponentPortType*) oscl_calloc(1, sizeof(ComponentPortType));
+            if (!ipPorts[ii])
+            {
+                return OMX_ErrorInsufficientResources;
+            }
+
+            ipPorts[ii]->TransientState = OMX_StateMax;
+            SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+            ipPorts[ii]->PortParam.nPortIndex = ii;
+
+            /** Allocate and initialize buffer Queue */
+            ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
+
+            if (NULL == ipPorts[ii]->pBufferQueue)
+            {
+                return OMX_ErrorInsufficientResources;
+            }
+
+            if (OMX_ErrorNone != QueueInit(ipPorts[ii]->pBufferQueue))
+            {
+                return OMX_ErrorInsufficientResources;
+            }
+
+            for (jj = 0; jj < OMX_PORT_NUMBER_FORMATS_SUPPORTED; jj++)
+            {
+                oscl_memset(&ipPorts[ii]->VideoParam[jj], 0, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+            }
+        }
+
+        SetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
+        SetNumBufferFlush(iNumPorts, -1, OMX_FALSE);
+    }
+
+
+    iCodecReady = OMX_FALSE;
+    ipCallbacks = NULL;
+    iCallbackData = NULL;
+    iState = OMX_StateLoaded;
+    ipTempInputBuffer = NULL;
+    iTempInputBufferLength = 0;
+    iNumInputBuffer = 0;
+    iPartialFrameAssembly = OMX_FALSE;
+    iEndofStream = OMX_FALSE;
+    iIsInputBufferEnded = OMX_TRUE;
+    iNewOutBufRequired = OMX_TRUE;
+    iEosProcessing = OMX_FALSE;
+    iRepositionFlag = OMX_FALSE;
+    iIsFirstOutputFrame = OMX_TRUE;
+    iMarkPropagate = OMX_FALSE;
+    ipTempOutBufferForPortReconfig = NULL;
+    iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
+    iSizeOutBufferForPortReconfig = 0;
+
+
+
+    /* Initialize the asynchronous command Queue */
+    if (ipCoreDescriptor)
+    {
+        oscl_free(ipCoreDescriptor);
+        ipCoreDescriptor = NULL;
+    }
+
+    ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType));
+    if (NULL == ipCoreDescriptor)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    ipCoreDescriptor->pMessageQueue = NULL;
+    ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
+    if (NULL == ipCoreDescriptor->pMessageQueue)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    if (OMX_ErrorNone != QueueInit(ipCoreDescriptor->pMessageQueue))
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    /** Default parameters setting */
+    iIsInit = OMX_FALSE;
+    iGroupPriority = 0;
+    iGroupID = 0;
+    ipMark = NULL;
+
+    SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
+
+    iOutBufferCount = 0;
+    iStateTransitionFlag = OMX_FALSE;
+    iEndOfFrameFlag = OMX_FALSE;
+    iFirstFragment = OMX_FALSE;
+
+    //Will be used in case of partial frame assembly
+    ipInputCurrBuffer = NULL;
+    iInputCurrBufferSize = 0;
+    ipAppPriv->CompHandle = &iOmxComponent;
+
+    return OMX_ErrorNone;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::DestroyBaseComponent()
+{
+    OMX_U32 ii;
+
+    /*Deinitialize and free ports semaphores and Queue*/
+    for (ii = 0; ii < iNumPorts; ii++)
+    {
+        if (NULL != ipPorts[ii]->pBufferQueue)
+        {
+            QueueDeinit(ipPorts[ii]->pBufferQueue);
+            oscl_free(ipPorts[ii]->pBufferQueue);
+            ipPorts[ii]->pBufferQueue = NULL;
+        }
+        /*Free port*/
+        if (NULL != ipPorts[ii])
+        {
+            oscl_free(ipPorts[ii]);
+            ipPorts[ii] = NULL;
+        }
+    }
+
+    if (ipPorts)
+    {
+        oscl_free(ipPorts);
+        ipPorts = NULL;
+    }
+
+    iState = OMX_StateLoaded;
+
+    //Free the temp output buffer
+    if (ipTempOutBufferForPortReconfig)
+    {
+        oscl_free(ipTempOutBufferForPortReconfig);
+        ipTempOutBufferForPortReconfig = NULL;
+        iSizeOutBufferForPortReconfig = 0;
+    }
+
+    if (ipInputCurrBuffer)
+    {
+        oscl_free(ipInputCurrBuffer);
+        ipInputCurrBuffer = NULL;
+        iInputCurrBufferSize = 0;
+    }
+
+    if (ipTempInputBuffer)
+    {
+        oscl_free(ipTempInputBuffer);
+        ipTempInputBuffer = NULL;
+    }
+
+    if (NULL != ipCoreDescriptor)
+    {
+
+        if (NULL != ipCoreDescriptor->pMessageQueue)
+        {
+            /* De-initialize the asynchronous command queue */
+            QueueDeinit(ipCoreDescriptor->pMessageQueue);
+            oscl_free(ipCoreDescriptor->pMessageQueue);
+            ipCoreDescriptor->pMessageQueue = NULL;
+        }
+
+        oscl_free(ipCoreDescriptor);
+        ipCoreDescriptor = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+/*********************
+ *
+ * Component verfication routines
+ *
+ **********************/
+
+void OmxComponentBase::SetHeader(OMX_PTR aHeader, OMX_U32 aSize)
+{
+    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
+    *((OMX_U32*) aHeader) = aSize;
+
+    pVersion->s.nVersionMajor = SPECVERSIONMAJOR;
+    pVersion->s.nVersionMinor = SPECVERSIONMINOR;
+    pVersion->s.nRevision = SPECREVISION;
+    pVersion->s.nStep = SPECSTEP;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize)
+{
+    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
+
+    if (NULL == aHeader)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    if (*((OMX_U32*) aHeader) != aSize)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR ||
+            pVersion->s.nVersionMinor != SPECVERSIONMINOR ||
+            pVersion->s.nRevision != SPECREVISION ||
+            pVersion->s.nStep != SPECSTEP)
+    {
+        return OMX_ErrorVersionMismatch;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+/**
+ * This function verify component state and structure header
+ */
+OMX_ERRORTYPE OmxComponentBase::ParameterSanityCheck(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_U32 nPortIndex,
+    OMX_IN  OMX_PTR pStructure,
+    OMX_IN  size_t size)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    if (iState != OMX_StateLoaded &&
+            iState != OMX_StateWaitForResources)
+    {
+        return OMX_ErrorIncorrectStateOperation;
+    }
+
+    if (nPortIndex >= iNumPorts)
+    {
+        return OMX_ErrorBadPortIndex;
+    }
+
+    return CheckHeader(pStructure, size);
+}
+
+/**
+ * Set/Reset Port Flush Flag
+ */
+void OmxComponentBase::SetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value)
+{
+    OMX_S32 ii;
+
+    if (-1 == index)
+    {
+        for (ii = 0; ii < NumPorts; ii++)
+        {
+            ipPorts[ii]->IsPortFlushed = value;
+        }
+    }
+    else
+    {
+        ipPorts[index]->IsPortFlushed = value;
+    }
+
+}
+
+/**
+ * Set Number of Buffer Flushed with the value Specified
+ */
+void OmxComponentBase::SetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value)
+{
+    OMX_S32 ii;
+
+    if (-1 == index)
+    {
+        // For all ComponentPort
+        for (ii = 0; ii < NumPorts; ii++)
+        {
+            ipPorts[ii]->NumBufferFlushed = value;
+        }
+    }
+    else
+    {
+        ipPorts[index]->NumBufferFlushed = value;
+    }
+}
+
+/** This function assembles multiple input buffers into
+	* one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set
+	*/
+
+OMX_BOOL OmxComponentBase::AssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames IN"));
+
+    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+
+    ComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    OMX_U32 BytesToCopy = 0;
+
+    ipInputBuffer = aInputBuffer;
+
+    if (!iPartialFrameAssembly)
+    {
+        if (iNumInputBuffer > 0)
+        {
+            if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
+            {
+                iInputCurrLength = ipInputBuffer->nFilledLen;
+
+                //Only applicable for H.264 component
+#ifdef INSERT_NAL_START_CODE
+                // this is the case of 1 full NAL in 1 buffer
+                // if start codes are inserted, skip the start code
+                iInputCurrLength = ipInputBuffer->nFilledLen - 4;
+                ipInputBuffer->nOffset += 4;
+#endif
+                ipFrameDecodeBuffer = ipInputBuffer->pBuffer + ipInputBuffer->nOffset;
+                //capture the timestamp to be send to the corresponding output buffer
+                iFrameTimestamp = ipInputBuffer->nTimeStamp;
+            }
+            else
+            {
+                iInputCurrLength = 0;
+                iPartialFrameAssembly = OMX_TRUE;
+                iFirstFragment = OMX_TRUE;
+                iFrameTimestamp = ipInputBuffer->nTimeStamp;
+                ipFrameDecodeBuffer = ipInputCurrBuffer;
+            }
+
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames ERROR"));
+            return OMX_FALSE;
+        }
+
+    }
+
+    //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked
+    if (iPartialFrameAssembly)
+    {
+        while (iNumInputBuffer > 0)
+        {
+            if (OMX_FALSE == iFirstFragment)
+            {
+                /* If the timestamp of curr fragment doesn't match with previous,
+                 * discard the previous fragments & start reconstructing from new
+                 */
+                if (iFrameTimestamp != ipInputBuffer->nTimeStamp)
+                {
+                    iInputCurrLength = 0;
+                    iPartialFrameAssembly = OMX_TRUE;
+                    iFirstFragment = OMX_TRUE;
+                    iFrameTimestamp = ipInputBuffer->nTimeStamp;
+                    ipFrameDecodeBuffer = ipInputCurrBuffer;
+
+                    //Send a stream corrupt callback
+                    OMX_COMPONENTTYPE  *pHandle = &iOmxComponent;
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventError,
+                     OMX_ErrorStreamCorrupt,
+                     0,
+                     NULL);
+                }
+            }
+
+#ifdef INSERT_NAL_START_CODE
+            else
+            {
+                // this is the case of a partial NAL in 1 buffer
+                // this is the first fragment of a nal
+
+                // if start codes are inserted, skip the start code
+                ipInputBuffer->nFilledLen -= 4;
+                ipInputBuffer->nOffset += 4;
+            }
+#endif
+
+            if ((ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
+            {
+                break;
+            }
+
+            // check if the buffer size can take the new piece, or it needs to expand
+            BytesToCopy = ipInputBuffer->nFilledLen;
+
+            if (iInputCurrBufferSize < (iInputCurrLength + BytesToCopy))
+            {
+                // allocate new partial frame buffer
+                OMX_U8* pTempNewBuffer = NULL;
+                pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
+
+                // in the event that new buffer cannot be allocated
+                if (NULL == pTempNewBuffer)
+                {
+                    // copy into what space is available, and let the decoder complain
+                    BytesToCopy = iInputCurrLength - iInputCurrBufferSize;
+                }
+                else
+                {
+
+                    // copy contents of the old buffer into the new one
+                    oscl_memcpy(pTempNewBuffer, ipInputCurrBuffer, iInputCurrBufferSize);
+                    // free the old buffer
+                    if (ipInputCurrBuffer)
+                    {
+                        oscl_free(ipInputCurrBuffer);
+                    }
+                    // assign new one
+                    ipInputCurrBuffer = pTempNewBuffer;
+                    iInputCurrBufferSize = (iInputCurrLength + BytesToCopy);
+                    ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
+                }
+            }
+
+            iInputCurrLength += BytesToCopy;
+            oscl_memcpy(ipFrameDecodeBuffer, (ipInputBuffer->pBuffer + ipInputBuffer->nOffset), BytesToCopy); // copy buffer data
+            ipFrameDecodeBuffer += BytesToCopy; // move the ptr
+
+            ipInputBuffer->nFilledLen = 0;
+
+            ReturnInputBuffer(ipInputBuffer, pInPort);
+            ipInputBuffer = NULL;
+
+            iFirstFragment = OMX_FALSE;
+
+            if (iNumInputBuffer > 0)
+            {
+                ipInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
+                if (NULL == ipInputBuffer)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames ERROR DeQueue() returned NULL"));
+                    return OMX_FALSE;
+                }
+
+                if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames EndOfStream arrived"));
+                    iEndofStream = OMX_TRUE;
+                }
+            }
+        }
+
+        // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers
+        if (0 == iNumInputBuffer)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames OUT"));
+            return OMX_FALSE;
+        }
+        else
+        {
+            // we have found the buffer that is the last piece of the frame.
+            // Copy the buffer, but do not release it yet (this will be done after decoding for consistency)
+
+            BytesToCopy = ipInputBuffer->nFilledLen;
+            // check if the buffer size can take the new piece, or it needs to expand
+            if (iInputCurrBufferSize < (iInputCurrLength + BytesToCopy))
+            {
+                // allocate new partial frame buffer
+                OMX_U8* pTempNewBuffer = NULL;
+                pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
+
+                // if you cannot allocate new buffer, just copy what data you can
+                if (NULL == pTempNewBuffer)
+                {
+                    BytesToCopy = iInputCurrBufferSize - iInputCurrLength;
+                }
+                else
+                {
+
+                    // copy contents of the old one into new one
+                    oscl_memcpy(pTempNewBuffer, ipInputCurrBuffer, iInputCurrBufferSize);
+                    // free the old buffer
+                    if (ipInputCurrBuffer)
+                    {
+                        oscl_free(ipInputCurrBuffer);
+                    }
+                    // assign new one
+                    ipInputCurrBuffer = pTempNewBuffer;
+                    iInputCurrBufferSize = (iInputCurrLength + BytesToCopy);
+                    ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
+                }
+            }
+
+            iInputCurrLength += BytesToCopy;
+            oscl_memcpy(ipFrameDecodeBuffer, (ipInputBuffer->pBuffer + ipInputBuffer->nOffset), BytesToCopy); // copy buffer data
+            ipFrameDecodeBuffer += BytesToCopy; // move the ptr
+
+            ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer
+            iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AssemblePartialFrames OUT"));
+    return OMX_TRUE;
+}
+
+
+void OmxComponentBase::ReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, ComponentPortType* pPort)
+{
+    OSCL_UNUSED_ARG(pPort);
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+
+    if (iNumInputBuffer)
+    {
+        iNumInputBuffer--;
+    }
+
+    //Callback for releasing the input buffer
+    (*(ipCallbacks->EmptyBufferDone))
+    (pHandle, iCallbackData, pInputBuffer);
+
+}
+
+/**
+ * Returns Output Buffer back to the IL client
+ */
+void OmxComponentBase::ReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer,
+        ComponentPortType *pPort)
+{
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+
+    //Callback for sending back the output buffer
+    (*(ipCallbacks->FillBufferDone))
+    (pHandle, iCallbackData, pOutputBuffer);
+
+    if (iOutBufferCount)
+    {
+        iOutBufferCount--;
+    }
+
+    pPort->NumBufferFlushed++;
+    iNewOutBufRequired = OMX_TRUE;
+}
+
+
+/** Flushes all the buffers under processing by the given port.
+	* This function is called due to a state change of the component, typically
+	* @param PortIndex the ID of the port to be flushed
+	*/
+
+OMX_ERRORTYPE OmxComponentBase::FlushPort(OMX_S32 PortIndex)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort IN"));
+
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+
+
+    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    OMX_BUFFERHEADERTYPE* pOutputBuff;
+    OMX_BUFFERHEADERTYPE* pInputBuff;
+
+    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
+    {
+        iPartialFrameAssembly = OMX_FALSE;
+
+        //Release all the input buffers in queue
+        while ((GetQueueNumElem(pInputQueue) > 0))
+        {
+            pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
+            if (NULL == pInputBuff)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort ERROR DeQueue() returned NULL"));
+                return OMX_ErrorUndefined;
+            }
+            (*(ipCallbacks->EmptyBufferDone))
+            (pHandle, iCallbackData, pInputBuff);
+            iNumInputBuffer--;
+        }
+
+        //Release the current buffer that is being processed by the component.
+        if (iNumInputBuffer > 0 && ipInputBuffer && (OMX_FALSE == iIsInputBufferEnded))
+        {
+            (*(ipCallbacks->EmptyBufferDone))
+            (pHandle, iCallbackData, ipInputBuffer);
+            iNumInputBuffer--;
+
+            iIsInputBufferEnded = OMX_TRUE;
+            iInputCurrLength = 0;
+        }
+    }
+
+    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
+    {
+        //Release the current output buffer if present that is being processed by the component.
+        if ((OMX_FALSE == iNewOutBufRequired) && (iOutBufferCount > 0))
+        {
+            if (ipOutputBuffer)
+            {
+                (*(ipCallbacks->FillBufferDone))
+                (pHandle, iCallbackData, ipOutputBuffer);
+                iOutBufferCount--;
+                iNewOutBufRequired = OMX_TRUE;
+            }
+        }
+
+        //Release all other output buffers in queue
+        while ((GetQueueNumElem(pOutputQueue) > 0))
+        {
+            pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == pOutputBuff)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort ERROR DeQueue() returned NULL"));
+                return OMX_ErrorUndefined;
+            }
+
+            pOutputBuff->nFilledLen = 0;
+            (*(ipCallbacks->FillBufferDone))
+            (pHandle, iCallbackData, pOutputBuff);
+            iOutBufferCount--;
+        }
+
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FlushPort OUT"));
+    return OMX_ErrorNone;
+}
+
+/**
+ * Disable Single Port
+ */
+void OmxComponentBase::DisableSinglePort(OMX_U32 PortIndex)
+{
+    ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE;
+
+    if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
+    {
+        iStateTransitionFlag = OMX_TRUE;
+        return;
+    }
+
+    ipPorts[PortIndex]->NumBufferFlushed = 0;
+}
+
+
+/** Disables the specified port. This function is called due to a request by the IL client
+	* @param PortIndex the ID of the port to be disabled
+	*/
+OMX_ERRORTYPE OmxComponentBase::DisablePort(OMX_S32 PortIndex)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DisablePort IN"));
+    OMX_U32 ii;
+
+    if (-1 == PortIndex)
+    {
+        for (ii = 0; ii < iNumPorts; ii++)
+        {
+            ipPorts[ii]->IsPortFlushed = OMX_TRUE;
+        }
+
+        /*Flush all ports*/
+        FlushPort(PortIndex);
+
+        for (ii = 0; ii < iNumPorts; ii++)
+        {
+            ipPorts[ii]->IsPortFlushed = OMX_FALSE;
+        }
+    }
+    else
+    {
+        /*Flush the port specified*/
+        ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE;
+        FlushPort(PortIndex);
+        ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE;
+    }
+
+    /*Disable ports*/
+    if (PortIndex != -1)
+    {
+        DisableSinglePort(PortIndex);
+    }
+    else
+    {
+        for (ii = 0; ii < iNumPorts; ii++)
+        {
+            DisableSinglePort(ii);
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DisablePort OUT"));
+
+    return OMX_ErrorNone;
+}
+
+/**
+ * Enable Single Port
+ */
+void OmxComponentBase::EnableSinglePort(OMX_U32 PortIndex)
+{
+    ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE;
+
+    if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
+    {
+        iStateTransitionFlag = OMX_TRUE;
+        return;
+    }
+}
+
+/** Enables the specified port. This function is called due to a request by the IL client
+	* @param PortIndex the ID of the port to be enabled
+	*/
+OMX_ERRORTYPE OmxComponentBase::EnablePort(OMX_S32 PortIndex)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EnablePort IN"));
+
+    OMX_U32 ii;
+
+    /*Enable port/s*/
+    if (PortIndex != -1)
+    {
+        EnableSinglePort(PortIndex);
+    }
+    else
+    {
+        for (ii = 0; ii < iNumPorts; ii++)
+        {
+            EnableSinglePort(ii);
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EnablePort OUT"));
+    return OMX_ErrorNone;
+}
+
+//Not implemented & supported in case of base profile components
+
+OMX_ERRORTYPE OmxComponentBase::TunnelRequest(
+    OMX_IN  OMX_HANDLETYPE hComp,
+    OMX_IN  OMX_U32 nPort,
+    OMX_IN  OMX_HANDLETYPE hTunneledComp,
+    OMX_IN  OMX_U32 nTunneledPort,
+    OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup)
+{
+    OSCL_UNUSED_ARG(hComp);
+    OSCL_UNUSED_ARG(nPort);
+    OSCL_UNUSED_ARG(hTunneledComp);
+    OSCL_UNUSED_ARG(nTunneledPort);
+    OSCL_UNUSED_ARG(pTunnelSetup);
+
+    return OMX_ErrorNotImplemented;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentGetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->GetConfig(hComponent, nIndex, pComponentConfigStructure);
+    return Status;
+}
+
+
+
+OMX_ERRORTYPE OmxComponentBase::GetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig IN"));
+
+    OMX_U32 PortIndex;
+    OMX_CONFIG_INTRAREFRESHVOPTYPE* pVideoIFrame;
+    OMX_CONFIG_FRAMERATETYPE* pFrameRateType;
+    OMX_VIDEO_CONFIG_BITRATETYPE* pConfigBitRateType;
+
+    if (NULL == pComponentConfigStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nIndex)
+    {
+        case OMX_IndexConfigVideoIntraVOPRefresh:
+        {
+            pVideoIFrame = (OMX_CONFIG_INTRAREFRESHVOPTYPE*) pComponentConfigStructure;
+            if (pVideoIFrame->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad port index for OMX_IndexConfigVideoIntraVOPRefresh"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoIFrame->nPortIndex;
+            oscl_memcpy(pVideoIFrame, &ipPorts[PortIndex]->VideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+            SetHeader(pVideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+        }
+        break;
+
+        case OMX_IndexConfigVideoFramerate:
+        {
+            pFrameRateType = (OMX_CONFIG_FRAMERATETYPE*) pComponentConfigStructure;
+            if (pFrameRateType->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad port index for OMX_IndexConfigVideoFramerate"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pFrameRateType->nPortIndex;
+            oscl_memcpy(pFrameRateType, &ipPorts[PortIndex]->VideoConfigFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE));
+            SetHeader(pFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE));
+        }
+        break;
+
+        case OMX_IndexConfigVideoBitrate:
+        {
+            pConfigBitRateType = (OMX_VIDEO_CONFIG_BITRATETYPE*) pComponentConfigStructure;
+            if (pConfigBitRateType->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig error bad port index for OMX_IndexConfigVideoBitrate"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pConfigBitRateType->nPortIndex;
+            oscl_memcpy(pConfigBitRateType, &ipPorts[PortIndex]->VideoConfigBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE));
+            SetHeader(pConfigBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE));
+        }
+        break;
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetParameter error Unsupported Index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : GetConfig OUT"));
+
+    return OMX_ErrorNone;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentSetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_IN  OMX_PTR pComponentConfigStructure)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->SetConfig(hComponent, nIndex, pComponentConfigStructure);
+    return Status;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::SetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_IN  OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    OSCL_UNUSED_ARG(nIndex);
+    OSCL_UNUSED_ARG(pComponentConfigStructure);
+
+    return OMX_ErrorNotImplemented;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentGetExtensionIndex(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_STRING cParameterName,
+    OMX_OUT OMX_INDEXTYPE* pIndexType)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    OSCL_UNUSED_ARG(cParameterName);
+    OSCL_UNUSED_ARG(pIndexType);
+
+    return OMX_ErrorNotImplemented;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentGetState(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_OUT OMX_STATETYPE* pState)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+
+    pOpenmaxAOType->GetState(pState);
+
+    return OMX_ErrorNone;
+}
+
+
+void OmxComponentBase::GetState(OMX_OUT OMX_STATETYPE* pState)
+{
+    *pState = iState;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentGetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+    return Status;
+
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentSetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_IN  OMX_PTR ComponentParameterStructure)
+{
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+
+    return Status;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentUseBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes,
+    OMX_IN OMX_U8* pBuffer)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
+
+    return Status;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::UseBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes,
+    OMX_IN OMX_U8* pBuffer)
+{
+    OSCL_UNUSED_ARG(hComponent);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer IN"));
+    ComponentPortType* pBaseComponentPort;
+    OMX_U32 ii;
+
+    if (nPortIndex >= iNumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error bad port index"));
+        return OMX_ErrorBadPortIndex;
+    }
+
+    pBaseComponentPort = ipPorts[nPortIndex];
+
+    if (pBaseComponentPort->TransientState != OMX_StateIdle)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error incorrect state"));
+        return OMX_ErrorIncorrectStateTransition;
+    }
+
+    if (NULL == pBaseComponentPort->pBuffer)
+    {
+        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
+        if (NULL == pBaseComponentPort->pBuffer)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error insufficient resources"));
+            return OMX_ErrorInsufficientResources;
+        }
+
+        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
+        if (NULL == pBaseComponentPort->BufferState)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error insufficient resources"));
+            return OMX_ErrorInsufficientResources;
+        }
+    }
+
+    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
+    {
+        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
+                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
+        {
+            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
+            if (NULL == pBaseComponentPort->pBuffer[ii])
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
+            pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer;
+            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
+            pBaseComponentPort->pBuffer[ii]->nFilledLen = 0;
+            pBaseComponentPort->pBuffer[ii]->nOffset = 0;
+            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
+            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
+            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
+            pBaseComponentPort->pBuffer[ii]->nTickCount = 0;
+            pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0;
+            *ppBufferHdr = pBaseComponentPort->pBuffer[ii];
+            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
+            {
+                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
+                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index
+            }
+            else
+            {
+                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
+                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index
+            }
+            pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED;
+            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
+            pBaseComponentPort->NumAssignedBuffers++;
+            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
+            {
+                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
+
+                if (OMX_TRUE == iStateTransitionFlag)
+                {
+                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
+                    RunIfNotReady();
+                    iStateTransitionFlag = OMX_FALSE;
+                }
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer OUT"));
+            return OMX_ErrorNone;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : UseBuffer OUT"));
+    return OMX_ErrorNone;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentAllocateBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
+
+    return Status;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::AllocateBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes)
+{
+    OSCL_UNUSED_ARG(hComponent);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer IN"));
+
+    ComponentPortType* pBaseComponentPort;
+    OMX_U32 ii;
+
+    if (nPortIndex >= iNumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error bad port index"));
+        return OMX_ErrorBadPortIndex;
+    }
+
+    pBaseComponentPort = ipPorts[nPortIndex];
+
+    if (pBaseComponentPort->TransientState != OMX_StateIdle)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error incorrect state"));
+        return OMX_ErrorIncorrectStateTransition;
+    }
+
+    if (NULL == pBaseComponentPort->pBuffer)
+    {
+        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
+        if (NULL == pBaseComponentPort->pBuffer)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources"));
+            return OMX_ErrorInsufficientResources;
+        }
+
+        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
+        if (NULL == pBaseComponentPort->BufferState)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources"));
+            return OMX_ErrorInsufficientResources;
+        }
+    }
+
+    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
+    {
+        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
+                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
+        {
+            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
+            if (NULL == pBaseComponentPort->pBuffer[ii])
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
+            /* allocate the buffer */
+            pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes);
+            if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
+            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
+            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
+            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
+            *pBuffer = pBaseComponentPort->pBuffer[ii];
+            pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED;
+            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
+
+            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
+            {
+                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
+                // here is assigned a non-valid port index
+                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts;
+            }
+            else
+            {
+                // here is assigned a non-valid port index
+                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts;
+                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
+            }
+
+            pBaseComponentPort->NumAssignedBuffers++;
+
+            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
+            {
+                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
+
+                if (OMX_TRUE == iStateTransitionFlag)
+                {
+                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
+                    RunIfNotReady();
+                    iStateTransitionFlag = OMX_FALSE;
+                }
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer OUT"));
+            return OMX_ErrorNone;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : AllocateBuffer OUT"));
+    return OMX_ErrorInsufficientResources;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentFreeBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_U32 nPortIndex,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer);
+
+    return Status;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::FreeBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_U32 nPortIndex,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FreeBuffer IN"));
+
+    ComponentPortType* pBaseComponentPort;
+
+    OMX_U32 ii;
+    OMX_BOOL FoundBuffer;
+
+    if (nPortIndex >= iNumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FreeBuffer error bad port index"));
+        return OMX_ErrorBadPortIndex;
+    }
+
+    pBaseComponentPort = ipPorts[nPortIndex];
+
+    if (pBaseComponentPort->TransientState != OMX_StateLoaded
+            && pBaseComponentPort->TransientState != OMX_StateInvalid)
+    {
+
+        (*(ipCallbacks->EventHandler))
+        (hComponent,
+         iCallbackData,
+         OMX_EventError, /* The command was completed */
+         OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */
+         nPortIndex, /* The State has been changed in message->MessageParam2 */
+         NULL);
+    }
+
+    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
+    {
+        if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
+                (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer))
+        {
+
+            pBaseComponentPort->NumAssignedBuffers--;
+            oscl_free(pBuffer->pBuffer);
+            pBuffer->pBuffer = NULL;
+
+            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
+            {
+                oscl_free(pBuffer);
+                pBuffer = NULL;
+            }
+            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
+            break;
+        }
+        else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) &&
+                 (pBaseComponentPort->pBuffer[ii] == pBuffer))
+        {
+
+            pBaseComponentPort->NumAssignedBuffers--;
+
+            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
+            {
+                oscl_free(pBuffer);
+                pBuffer = NULL;
+            }
+
+            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
+            break;
+        }
+    }
+
+    FoundBuffer = OMX_FALSE;
+
+    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
+    {
+        if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE)
+        {
+            FoundBuffer = OMX_TRUE;
+            break;
+        }
+    }
+    if (!FoundBuffer)
+    {
+        pBaseComponentPort->PortParam.bPopulated = OMX_FALSE;
+
+        if (OMX_TRUE == iStateTransitionFlag)
+        {
+            //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation
+            RunIfNotReady();
+            iStateTransitionFlag = OMX_FALSE;
+
+            //Reset the decoding flags while freeing buffers
+            if (OMX_PORT_INPUTPORT_INDEX == nPortIndex)
+            {
+                iIsInputBufferEnded = OMX_TRUE;
+                iTempInputBufferLength = 0;
+                iTempConsumedLength = 0;
+                iNewInBufferRequired = OMX_TRUE;
+            }
+            else if (OMX_PORT_OUTPUTPORT_INDEX == nPortIndex)
+            {
+                iNewOutBufRequired = OMX_TRUE;
+            }
+        }
+
+        if (NULL != pBaseComponentPort->pBuffer)
+        {
+            oscl_free(pBaseComponentPort->pBuffer);
+            pBaseComponentPort->pBuffer = NULL;
+            oscl_free(pBaseComponentPort->BufferState);
+            pBaseComponentPort->BufferState = NULL;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FreeBuffer OUT"));
+    return OMX_ErrorNone;
+}
+
+
+/** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs
+	* @param hComponent the handle of the component
+	* @param ipCallbacks the OpenMAX standard structure that holds the callback pointers
+	* @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed
+    */
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentSetCallbacks(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+    OMX_IN  OMX_PTR pAppData)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData);
+
+    return Status;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::SetCallbacks(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+    OMX_IN  OMX_PTR pAppData)
+{
+    OSCL_UNUSED_ARG(hComponent);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SetCallbacks"));
+    ipCallbacks = pCallbacks;
+    iCallbackData = pAppData;
+
+    return OMX_ErrorNone;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentSendCommand(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_COMMANDTYPE Cmd,
+    OMX_IN  OMX_U32 nParam,
+    OMX_IN  OMX_PTR pCmdData)
+{
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData);
+
+    return Status;
+}
+
+OMX_ERRORTYPE OmxComponentBase::SendCommand(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_COMMANDTYPE Cmd,
+    OMX_IN  OMX_S32 nParam,
+    OMX_IN  OMX_PTR pCmdData)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand IN"));
+
+    OMX_U32 ii;
+    OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone;
+    QueueType* pMessageQueue;
+    CoreMessage* Message = NULL;
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+
+    pMessageQueue = ipCoreDescriptor->pMessageQueue;
+
+    if (OMX_StateInvalid == iState)
+    {
+        ErrMsgHandler = OMX_ErrorInvalidState;
+    }
+
+    switch (Cmd)
+    {
+        case OMX_CommandStateSet:
+        {
+            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
+
+            if (NULL == Message)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+
+            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
+            Message->MessageType = SENDCOMMAND_MSG_TYPE;
+            Message->MessageParam1 = OMX_CommandStateSet;
+            Message->MessageParam2 = nParam;
+            Message->pCmdData = pCmdData;
+
+            if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState))
+            {
+                ErrMsgHandler = pOpenmaxAOType->ComponentInit();
+
+                if (OMX_ErrorNone != ErrMsgHandler)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error component init"));
+                    return OMX_ErrorInsufficientResources;
+                }
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    ipPorts[ii]->TransientState = OMX_StateIdle;
+                }
+            }
+            else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState))
+            {
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    if (PORT_IS_ENABLED(ipPorts[ii]))
+                    {
+                        ipPorts[ii]->TransientState = OMX_StateLoaded;
+                    }
+                }
+            }
+            else if (OMX_StateInvalid == nParam)
+            {
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    if (PORT_IS_ENABLED(ipPorts[ii]))
+                    {
+                        ipPorts[ii]->TransientState = OMX_StateInvalid;
+                    }
+                }
+            }
+            else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam))
+                     && (OMX_StateExecuting == iState))
+            {
+                iBufferExecuteFlag = OMX_FALSE;
+            }
+
+        }
+        break;
+
+        case OMX_CommandFlush:
+        {
+            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
+
+            if (NULL == Message)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+
+            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
+            Message->MessageType = SENDCOMMAND_MSG_TYPE;
+            Message->MessageParam1 = OMX_CommandFlush;
+            Message->MessageParam2 = nParam;
+            Message->pCmdData = pCmdData;
+
+            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state"));
+                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
+                break;
+
+            }
+            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            SetPortFlushFlag(iNumPorts, nParam, OMX_TRUE);
+            SetNumBufferFlush(iNumPorts, -1, 0);
+        }
+        break;
+
+        case OMX_CommandPortDisable:
+        {
+            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            iResizePending = OMX_FALSE; // reset the flag to enable processing
+            iSendOutBufferAfterPortReconfigFlag = OMX_TRUE;
+
+
+            if (-1 == nParam)
+            {
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    if (!PORT_IS_ENABLED(ipPorts[ii]))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state"));
+                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
+                        break;
+                    }
+                    else
+                    {
+                        ipPorts[ii]->TransientState = OMX_StateLoaded;
+                    }
+                }
+            }
+            else
+            {
+                if (!PORT_IS_ENABLED(ipPorts[nParam]))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state"));
+                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
+                    break;
+                }
+                else
+                {
+                    ipPorts[nParam]->TransientState = OMX_StateLoaded;
+                }
+            }
+
+            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
+            if (NULL == Message)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+
+            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
+            if (OMX_ErrorNone == ErrMsgHandler)
+            {
+                Message->MessageType = SENDCOMMAND_MSG_TYPE;
+                Message->MessageParam2 = nParam;
+            }
+            else
+            {
+                Message->MessageType = ERROR_MSG_TYPE;
+                Message->MessageParam2 = ErrMsgHandler;
+            }
+            Message->MessageParam1 = OMX_CommandPortDisable;
+            Message->pCmdData = pCmdData;
+        }
+        break;
+
+
+        case OMX_CommandPortEnable:
+        {
+            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            if (-1 == nParam)
+            {
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    if (PORT_IS_ENABLED(ipPorts[ii]))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state"));
+                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
+                        break;
+                    }
+                    else
+                    {
+                        ipPorts[ii]->TransientState = OMX_StateIdle;
+                    }
+                }
+            }
+            else
+            {
+                if (PORT_IS_ENABLED(ipPorts[nParam]))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state"));
+                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
+                    break;
+                }
+                else
+                {
+                    ipPorts[nParam]->TransientState = OMX_StateIdle;
+                }
+            }
+
+            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
+            if (NULL == Message)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+
+            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
+            if (OMX_ErrorNone == ErrMsgHandler)
+            {
+                Message->MessageType = SENDCOMMAND_MSG_TYPE;
+            }
+            else
+            {
+                Message->MessageType = ERROR_MSG_TYPE;
+            }
+
+            Message->MessageParam1 = OMX_CommandPortEnable;
+            Message->MessageParam2 = nParam;
+            Message->pCmdData = pCmdData;
+        }
+        break;
+
+
+        case OMX_CommandMarkBuffer:
+        {
+            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error incorrect state"));
+                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
+                break;
+            }
+
+            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
+            if (NULL == Message)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error insufficient resources"));
+                return OMX_ErrorInsufficientResources;
+            }
+            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
+            Message->MessageType = SENDCOMMAND_MSG_TYPE;
+            Message->MessageParam1 = OMX_CommandMarkBuffer;
+            Message->MessageParam2 = nParam;
+            Message->pCmdData = pCmdData;
+        }
+        break;
+
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error unsupported index"));
+            ErrMsgHandler = OMX_ErrorUnsupportedIndex;
+        }
+        break;
+    }
+
+    if (OMX_ErrorNone != Queue(pMessageQueue, Message))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand error, Queuing command failed"));
+        return OMX_ErrorInsufficientResources;
+    }
+
+    RunIfNotReady();
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : SendCommand OUT"));
+    return ErrMsgHandler;
+}
+
+
+
+/* This routine will reset all the buffers and flag associated with decoding
+ * when receiving a flush command on the respective port*/
+void OmxComponentBase::ResetAfterFlush(OMX_S32 PortIndex)
+{
+
+    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
+    {
+        iIsInputBufferEnded = OMX_TRUE;
+        iEndofStream = OMX_FALSE;
+        iNewInBufferRequired = OMX_TRUE;
+        iPartialFrameAssembly = OMX_FALSE;
+        iTempInputBufferLength = 0;
+        iTempConsumedLength = 0;
+        iInputBufferRemainingBytes = 0;
+        iInputCurrLength = 0;
+
+        //Assume for this state transition that reposition command has come
+        iRepositionFlag = OMX_TRUE;
+        //Reset the silence insertion logic also
+        iSilenceInsertionInProgress = OMX_FALSE;
+    }
+
+    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
+    {
+        iNewOutBufRequired = OMX_TRUE;
+    }
+
+    return;
+}
+
+
+/** This is called by the OMX core in its message processing
+ * thread context upon a component request. A request is made
+ * by the component when some asynchronous services are needed:
+ * 1) A SendCommand() is to be processed
+ * 2) An error needs to be notified
+ * \param Message, the message that has been passed to core
+ */
+
+OMX_ERRORTYPE OmxComponentBase::MessageHandler(CoreMessage* Message)
+{
+
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate;
+    OMX_U32 ii;
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+
+
+    /** Dealing with a SendCommand call.
+     * -MessageParam1 contains the command to execute
+     * -MessageParam2 contains the parameter of the command
+     *  (destination state in case of a state change command).
+     */
+
+    OMX_STATETYPE orig_state = iState;
+    if (SENDCOMMAND_MSG_TYPE == Message->MessageType)
+    {
+        switch (Message->MessageParam1)
+        {
+            case OMX_CommandStateSet:
+            {
+                /* Do the actual state change */
+                ErrorType = DoStateSet(Message->MessageParam2);
+
+                if (OMX_TRUE == iStateTransitionFlag)
+                {
+                    return OMX_ErrorNone;
+                }
+
+                //Do not send the callback now till the State gets changed
+                if (ErrorType != OMX_ErrorNone)
+                {
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventError, /* The command was completed */
+                     ErrorType, /* The commands was a OMX_CommandStateSet */
+                     0, /* The iState has been changed in Message->MessageParam2 */
+                     NULL);
+                }
+                else
+                {
+                    /* And run the callback */
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventCmdComplete, /* The command was completed */
+                     OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
+                     Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
+                     NULL);
+                }
+            }
+            break;
+
+            case OMX_CommandFlush:
+            {
+                /*Flush ports*/
+                ErrorType = FlushPort(Message->MessageParam2);
+
+                SetNumBufferFlush(iNumPorts, -1, 0);
+
+                ResetAfterFlush(Message->MessageParam2);
+
+                //If Flush Command has come at the input port, reset the individual component as well
+                if (OMX_PORT_INPUTPORT_INDEX == Message->MessageParam2
+                        || OMX_PORT_ALLPORT_INDEX == Message->MessageParam2)
+                {
+                    /* Component specific flush routine for input buffer where individual components
+                     * may set/reset some flags/buffer lengths if required.*/
+
+                    pOpenmaxAOType->ResetComponent();
+                }
+
+                if (ErrorType != OMX_ErrorNone)
+                {
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventError, /* The command was completed */
+                     ErrorType, /* The commands was a OMX_CommandStateSet */
+                     0, /* The iState has been changed in Message->MessageParam2 */
+                     NULL);
+                }
+                else
+                {
+                    if (-1 == Message->MessageParam2)
+                    {
+                        /*Flush all port*/
+                        for (ii = 0; ii < iNumPorts; ii++)
+                        {
+                            (*(ipCallbacks->EventHandler))
+                            (pHandle,
+                             iCallbackData,
+                             OMX_EventCmdComplete, /* The command was completed */
+                             OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
+                             ii, /* The iState has been changed in Message->MessageParam2 */
+                             NULL);
+                        }
+                    }
+                    else
+                    {
+                        /*Flush input/output port*/
+                        (*(ipCallbacks->EventHandler))
+                        (pHandle,
+                         iCallbackData,
+                         OMX_EventCmdComplete, /* The command was completed */
+                         OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
+                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
+                         NULL);
+                    }
+                }
+                SetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
+            }
+            break;
+
+            case OMX_CommandPortDisable:
+            {
+                /** This condition is added to pass the tests, it is not significant for the environment */
+                ErrorType = DisablePort(Message->MessageParam2);
+                if (OMX_TRUE == iStateTransitionFlag)
+                {
+                    return OMX_ErrorNone;
+                }
+
+                if (ErrorType != OMX_ErrorNone)
+                {
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventError, /* The command was completed */
+                     ErrorType, /* The commands was a OMX_CommandStateSet */
+                     0, /* The iState has been changed in Message->MessageParam2 */
+                     NULL);
+                }
+                else
+                {
+                    if (-1 == Message->MessageParam2)
+                    {
+                        /*Disable all ports*/
+                        for (ii = 0; ii < iNumPorts; ii++)
+                        {
+                            (*(ipCallbacks->EventHandler))
+                            (pHandle,
+                             iCallbackData,
+                             OMX_EventCmdComplete, /* The command was completed */
+                             OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
+                             ii, /* The iState has been changed in Message->MessageParam2 */
+                             NULL);
+                        }
+                    }
+                    else
+                    {
+                        (*(ipCallbacks->EventHandler))
+                        (pHandle,
+                         iCallbackData,
+                         OMX_EventCmdComplete, /* The command was completed */
+                         OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
+                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
+                         NULL);
+                    }
+                }
+            }
+            break;
+
+            case OMX_CommandPortEnable:
+            {
+                ErrorType = EnablePort(Message->MessageParam2);
+                if (OMX_TRUE == iStateTransitionFlag)
+                {
+                    return OMX_ErrorNone;
+                }
+
+                if (ErrorType != OMX_ErrorNone)
+                {
+                    (*(ipCallbacks->EventHandler))
+                    (pHandle,
+                     iCallbackData,
+                     OMX_EventError, /* The command was completed */
+                     ErrorType, /* The commands was a OMX_CommandStateSet */
+                     0, /* The State has been changed in Message->MessageParam2 */
+                     NULL);
+                }
+                else
+                {
+                    if (Message->MessageParam2 != -1)
+                    {
+                        (*(ipCallbacks->EventHandler))
+                        (pHandle,
+                         iCallbackData,
+                         OMX_EventCmdComplete, /* The command was completed */
+                         OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
+                         Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */
+                         NULL);
+                    }
+                    else
+                    {
+                        for (ii = 0; ii < iNumPorts; ii++)
+                        {
+                            (*(ipCallbacks->EventHandler))
+                            (pHandle,
+                             iCallbackData,
+                             OMX_EventCmdComplete, /* The command was completed */
+                             OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
+                             ii, /* The State has been changed in Message->MessageParam2 */
+                             NULL);
+                        }
+                    }
+                }
+            }
+            break;
+
+            case OMX_CommandMarkBuffer:
+            {
+                ipMark = (OMX_MARKTYPE *)Message->pCmdData;
+            }
+            break;
+
+            default:
+            {
+
+            }
+            break;
+        }
+        /* Dealing with an asynchronous error condition
+         */
+    }
+
+    if (orig_state != OMX_StateInvalid)
+    {
+        ErrorType = OMX_ErrorNone;
+    }
+
+    return ErrorType;
+}
+
+/** Changes the state of a component taking proper actions depending on
+ * the transiotion requested
+ * \param aDestinationState the requested target state.
+ */
+
+OMX_ERRORTYPE OmxComponentBase::DoStateSet(OMX_U32 aDestinationState)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "OmxComponentBase : DoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState));
+
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    OMX_U32 ii;
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate;
+
+    if (OMX_StateLoaded == aDestinationState)
+    {
+        switch (iState)
+        {
+            case OMX_StateInvalid:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+                return OMX_ErrorInvalidState;
+            }
+
+            case OMX_StateWaitForResources:
+            {
+                iState = OMX_StateLoaded;
+            }
+            break;
+
+            case OMX_StateLoaded:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state"));
+                return OMX_ErrorSameState;
+            }
+
+            case OMX_StateIdle:
+            {
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    if (PORT_IS_ENABLED(ipPorts[ii]) && PORT_IS_POPULATED(ipPorts[ii]))
+                    {
+                        iStateTransitionFlag = OMX_TRUE;
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet Waiting port to be de-populated"));
+                        return OMX_ErrorNone;
+                    }
+                }
+
+                iState = OMX_StateLoaded;
+
+                iNumInputBuffer = 0;
+                iOutBufferCount = 0;
+                iPartialFrameAssembly = OMX_FALSE;
+                iEndofStream = OMX_FALSE;
+                iIsInputBufferEnded = OMX_TRUE;
+                iNewOutBufRequired = OMX_TRUE;
+                iNewInBufferRequired = OMX_TRUE;
+                iFirstFragment = OMX_FALSE;
+
+                pOpenmaxAOType->ComponentDeInit();
+            }
+            break;
+
+            default:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state"));
+                return OMX_ErrorIncorrectStateTransition;
+            }
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT"));
+        return OMX_ErrorNone;
+    }
+
+    if (OMX_StateWaitForResources == aDestinationState)
+    {
+        switch (iState)
+        {
+            case OMX_StateInvalid:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+                return OMX_ErrorInvalidState;
+            }
+
+            case OMX_StateLoaded:
+            {
+                iState = OMX_StateWaitForResources;
+            }
+            break;
+
+            case OMX_StateWaitForResources:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state"));
+                return OMX_ErrorSameState;
+            }
+
+            default:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state"));
+                return OMX_ErrorIncorrectStateTransition;
+            }
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT"));
+        return OMX_ErrorNone;
+    }
+
+    if (OMX_StateIdle == aDestinationState)
+    {
+        switch (iState)
+        {
+            case OMX_StateInvalid:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+                return OMX_ErrorInvalidState;
+            }
+
+            case OMX_StateWaitForResources:
+            {
+                iState = OMX_StateIdle;
+            }
+            break;
+
+            case OMX_StateLoaded:
+            {
+                for (ii = 0; ii < iNumPorts; ii++)
+                {
+                    if (PORT_IS_ENABLED(ipPorts[ii]) && !PORT_IS_POPULATED(ipPorts[ii]))
+                    {
+                        iStateTransitionFlag = OMX_TRUE;
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet Waiting port to be populated"));
+                        return OMX_ErrorNone;
+                    }
+                }
+
+                iState = OMX_StateIdle;
+
+                //Used in case of partial frame assembly
+                if (!ipInputCurrBuffer)
+                {
+                    //Keep the size of temp buffer double to be on safer side
+                    iInputCurrBufferSize = 2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
+
+                    ipInputCurrBuffer = (OMX_U8*) oscl_malloc(iInputCurrBufferSize);
+                    if (NULL == ipInputCurrBuffer)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error insufficient resources"));
+                        return OMX_ErrorInsufficientResources;
+                    }
+
+                }
+
+                //Used when the buffers are not marked with EndOfFrame flag
+                if (!ipTempInputBuffer)
+                {
+                    ipTempInputBuffer = (OMX_U8*) oscl_malloc(iInputCurrBufferSize);
+                    if (NULL == ipTempInputBuffer)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error insufficient resources"));
+                        return OMX_ErrorInsufficientResources;
+                    }
+                }
+
+                iTempInputBufferLength = 0;
+                iTempConsumedLength = 0;
+                iInputBufferRemainingBytes = 0;
+            }
+            break;
+
+            case OMX_StateIdle:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state"));
+                return OMX_ErrorSameState;
+            }
+
+            //Both the below cases have same body
+            case OMX_StateExecuting:
+            case OMX_StatePause:
+            {
+                SetNumBufferFlush(iNumPorts, -1, 0);
+                SetPortFlushFlag(iNumPorts, -1, OMX_TRUE);
+
+                ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+
+                //Return all the buffers if still occupied
+                QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+
+                while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0))
+                {
+                    FlushPort(OMX_PORT_INPUTPORT_INDEX);
+                }
+
+                // if a buffer was previously dequeued, it wasnt freed in above loop. return it now
+                if (iNumInputBuffer > 0)
+                {
+                    ipInputBuffer->nFilledLen = 0;
+                    ReturnInputBuffer(ipInputBuffer, pInPort);
+                    iNewInBufferRequired = OMX_TRUE;
+                    iIsInputBufferEnded = OMX_TRUE;
+                    iInputCurrLength = 0;
+                    ipInputBuffer = NULL;
+                }
+
+                //Return all the buffers if still occupied
+                while ((iNumInputBuffer > 0))
+                {
+                    FlushPort(OMX_PORT_INPUTPORT_INDEX);
+                }
+
+                //Return all the output buffers if still occupied
+                while (iOutBufferCount > 0)
+                {
+                    FlushPort(OMX_PORT_OUTPUTPORT_INDEX);
+                }
+
+                //Call the reset funstion here to reset the flags and buffer length variables
+                ResetAfterFlush(OMX_PORT_ALLPORT_INDEX);
+
+
+                SetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
+                SetNumBufferFlush(iNumPorts, -1, 0);
+
+                pOpenmaxAOType->ResetComponent();
+
+                iState = OMX_StateIdle;
+            }
+            break;
+
+            default:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state"));
+                return OMX_ErrorIncorrectStateTransition;
+            }
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT"));
+        return ErrorType;
+    }
+
+    if (OMX_StatePause == aDestinationState)
+    {
+        switch (iState)
+        {
+            case OMX_StateInvalid:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+                return OMX_ErrorInvalidState;
+            }
+
+            case OMX_StatePause:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state"));
+                return OMX_ErrorSameState;
+            }
+
+            //Falling through to the next case
+            case OMX_StateExecuting:
+            case OMX_StateIdle:
+            {
+                iState = OMX_StatePause;
+            }
+            break;
+
+            default:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state"));
+                return OMX_ErrorIncorrectStateTransition;
+            }
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT"));
+        return OMX_ErrorNone;
+    }
+
+    if (OMX_StateExecuting == aDestinationState)
+    {
+        switch (iState)
+        {
+            case OMX_StateInvalid:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+                return OMX_ErrorInvalidState;
+            }
+
+            case OMX_StateIdle:
+            {
+                iState = OMX_StateExecuting;
+            }
+            break;
+
+            case OMX_StatePause:
+            {
+                iState = OMX_StateExecuting;
+                /* A trigger to start the processing of buffers when component
+                 * transitions to executing from pause, as it is already
+                 * holding the required buffers
+                 */
+                RunIfNotReady();
+            }
+            break;
+
+            case OMX_StateExecuting:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error same state"));
+                return OMX_ErrorSameState;
+            }
+
+            default:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error incorrect state"));
+                return OMX_ErrorIncorrectStateTransition;
+            }
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT"));
+        return OMX_ErrorNone;
+    }
+
+    if (OMX_StateInvalid == aDestinationState)
+    {
+        switch (iState)
+        {
+            case OMX_StateInvalid:
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+                return OMX_ErrorInvalidState;
+            }
+
+            default:
+            {
+                iState = OMX_StateInvalid;
+                if (iIsInit != OMX_FALSE)
+                {
+                    pOpenmaxAOType->ComponentDeInit();
+                }
+            }
+            break;
+        }
+
+        if (iIsInit != OMX_FALSE)
+        {
+            pOpenmaxAOType->ComponentDeInit();
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error invalid state"));
+        return OMX_ErrorInvalidState;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet OUT"));
+    return OMX_ErrorNone;
+}
+
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentEmptyThisBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer);
+
+    return Status;
+
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::EmptyThisBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+
+{
+    OSCL_UNUSED_ARG(hComponent);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer IN"));
+    //Do not queue buffers if component is in invalid state
+    if (OMX_StateInvalid == iState)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error invalid state"));
+        return OMX_ErrorInvalidState;
+    }
+
+    if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState))
+    {
+        OMX_U32 PortIndex;
+        QueueType* pInputQueue;
+        OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+
+        PortIndex = pBuffer->nInputPortIndex;
+
+        //Validate the port index & Queue the buffers available only at the input port
+        if (PortIndex >= iNumPorts ||
+                ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error bad port index"));
+            return OMX_ErrorBadPortIndex;
+        }
+
+        //Port should be in enabled state before accepting buffers
+        if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error incorrect state"));
+            return OMX_ErrorIncorrectStateOperation;
+        }
+
+        /* The number of buffers the component can queue at a time
+         * depends upon the number of buffers allocated/assigned on the input port
+         */
+        if (iNumInputBuffer == (ipPorts[PortIndex]->NumAssignedBuffers))
+        {
+            RunIfNotReady();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error incorrect state"));
+            return OMX_ErrorIncorrectStateOperation;
+        }
+
+        //Finally after passing all the conditions, queue the buffer in Input queue
+        pInputQueue = ipPorts[PortIndex]->pBufferQueue;
+
+        if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error check header failed"));
+            return ErrorType;
+        }
+
+        if (OMX_ErrorNone != Queue(pInputQueue, pBuffer))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error, Queuing buffer failed"));
+            return OMX_ErrorInsufficientResources;
+        }
+        iNumInputBuffer++;
+
+        //Signal the AO about the incoming buffer
+        RunIfNotReady();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer error incorrect state"));
+        //This macro is not accepted in any other state except the three mentioned above
+        return OMX_ErrorIncorrectStateOperation;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : EmptyThisBuffer OUT"));
+
+    return OMX_ErrorNone;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentFillThisBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    OMX_ERRORTYPE Status;
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer);
+
+    return Status;
+}
+
+OMX_ERRORTYPE OmxComponentBase::FillThisBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+
+{
+    OSCL_UNUSED_ARG(hComponent);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer IN"));
+
+    OMX_U32 PortIndex;
+
+    QueueType* pOutputQueue;
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+
+    PortIndex = pBuffer->nOutputPortIndex;
+    //Validate the port index & Queue the buffers available only at the output port
+    if (PortIndex >= iNumPorts ||
+            ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error bad port index"));
+        return OMX_ErrorBadPortIndex;
+    }
+
+    pOutputQueue = ipPorts[PortIndex]->pBufferQueue;
+    if (iState != OMX_StateExecuting &&
+            iState != OMX_StatePause &&
+            iState != OMX_StateIdle)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error invalid state"));
+        return OMX_ErrorInvalidState;
+    }
+
+    //Port should be in enabled state before accepting buffers
+    if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error incorrect state"));
+        return OMX_ErrorIncorrectStateOperation;
+    }
+
+    if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error check header failed"));
+        return ErrorType;
+    }
+
+    //Queue the buffer in output queue
+    if (OMX_ErrorNone != Queue(pOutputQueue, pBuffer))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer error, queuing buffer failed"));
+        return OMX_ErrorInsufficientResources;
+    }
+
+    iOutBufferCount++;
+
+    //Signal the AO about the incoming buffer
+    RunIfNotReady();
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : FillThisBuffer OUT"));
+
+    return OMX_ErrorNone;
+}
+
+
+/** This is the central function for buffers processing and decoding.
+	* It is called through the Run() of active object when the component is in executing state
+	* and is signalled each time a new buffer is available on the given ports
+	* This function will process the input buffers & return output buffers
+	*/
+
+void OmxComponentBase::BufferMgmtFunction()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction IN"));
+
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate;
+
+    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+    ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+
+    OMX_BOOL PartialFrameReturn, Status;
+
+    /* Don't dequeue any further buffer after endofstream buffer has been dequeued
+     * till we send the callback and reset the flag back to false
+     */
+    if (OMX_FALSE == iEndofStream)
+    {
+        //More than one frame can't be dequeued in case of outbut blocked
+        if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
+        {
+            ipInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
+            if (NULL == ipInputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction ERROR DeQueue() returned NULL"));
+                return;
+            }
+
+            if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction EndOfStream arrived"));
+                iEndofStream = OMX_TRUE;
+            }
+
+            // To do: test this second condition newly added
+            if ((ipInputBuffer->nFilledLen != 0) ||
+                    ((OMX_TRUE == iEndofStream) && (OMX_TRUE == iPartialFrameAssembly)))
+            {
+                // if we already started assembling frames, it means
+                // we didn't get marker bit yet, but may be getting it
+                // when the first frame assembly is over
+                // If so, we'll set iEndOfFrameFlag to TRUE in BufferMgmtWithoutMarker assembly
+                if (0 == iFrameCount && iPartialFrameAssembly == OMX_FALSE)
+                {
+                    //Set the marker flag (iEndOfFrameFlag) if first frame has the EndOfFrame flag marked.
+                    if ((ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction EndOfFrame flag present"));
+                        iEndOfFrameFlag = OMX_TRUE;
+                    }
+
+                    /* This routine will allocate the internal input buffers that are required to
+                     * assemble partial frames in both with and without marker mode for H.263 decoder component.
+                     * The size of partial frame assembly buffer will be in proportion to the W & H of the clip.
+                     * We require maximum of first 12 bytes of data (this will be checked */
+
+
+                    if (OMX_ErrorNone != pOpenmaxAOType->ReAllocatePartialAssemblyBuffers(ipInputBuffer))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction Error Memory Re-allocation of partial frame assembly buffer failed, OUT"));
+                        return;
+                    }
+
+                }
+
+                /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is
+                 *  not marked in all the input buffers
+                 */
+                if (!iEndOfFrameFlag)
+                {
+                    Status = pOpenmaxAOType->BufferMgmtWithoutMarker();
+                    if (OMX_FALSE == Status)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction OUT"));
+                        return;
+                    }
+
+                }
+                //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here
+                else
+                {
+                    PartialFrameReturn = AssemblePartialFrames(ipInputBuffer);
+                    if (OMX_FALSE == PartialFrameReturn)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction OUT"));
+                        return;
+                    }
+                    iIsInputBufferEnded = OMX_FALSE;
+
+                    ipTargetComponent = (OMX_COMPONENTTYPE*) ipInputBuffer->hMarkTargetComponent;
+
+                    iTargetMarkData = ipInputBuffer->pMarkData;
+                    if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
+                    {
+                        (*(ipCallbacks->EventHandler))
+                        (pHandle,
+                         iCallbackData,
+                         OMX_EventMark,
+                         1,
+                         0,
+                         ipInputBuffer->pMarkData);
+                    }
+                }
+
+                /* This routine will take care of any audio component specific tasks like
+                   -> Reading the input buffer timestamp
+                   -> Checking for Silence insertion
+                   -> Repostioning implementation etc
+                */
+                if (OMX_TRUE == iIsAudioComponent)
+                {
+                    pOpenmaxAOType->SyncWithInputTimestamp();
+                }
+
+
+            }	//end braces for if (ipInputBuffer->nFilledLen != 0)
+            else
+            {
+                //Reschedule the AO if there are more buffers in queue
+                if ((GetQueueNumElem(pInputQueue) > 0) &&
+                        ((GetQueueNumElem(pOutputQueue) > 0) || (OMX_FALSE == iNewOutBufRequired)))
+                {
+                    RunIfNotReady();
+                }
+
+                ReturnInputBuffer(ipInputBuffer, pInPort);
+                ipInputBuffer = NULL;
+            }
+
+        }	//end braces for if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
+    }	//if (OMX_FALSE == iEndofStream)
+
+
+    //Component specific Encode/Decode routine
+    pOpenmaxAOType->ProcessData();
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtFunction OUT"));
+    return;
+}
+
+
+OMX_BOOL OmxComponentBase::BufferMgmtWithoutMarker()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker IN"));
+
+    ComponentPortType*	pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate;
+
+
+    /* If the buffer has enough data or EndofStream is true, and
+     * partial frame assembly is not turned on, process the buffer independently */
+
+    if (((ipInputBuffer->nFilledLen >= (iInputCurrBufferSize >> 1)) || (iEndofStream == OMX_TRUE))
+            && (OMX_FALSE == iPartialFrameAssembly))
+    {
+        //This is a new piece of buffer, process it independently
+        if (iNumInputBuffer > 0)
+        {
+            iInputCurrLength = ipInputBuffer->nFilledLen;
+            ipFrameDecodeBuffer = ipInputBuffer->pBuffer + ipInputBuffer->nOffset;
+            iFrameTimestamp = ipInputBuffer->nTimeStamp;
+
+            /* Components not implementing ComponentBufferMgmtWithoutMarker(), will reset
+             * iIsInputBufferEnded flag in the below routine */
+            pOpenmaxAOType->ProcessInBufferFlag();
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker OUT"));
+            return OMX_FALSE; // nothing to decode
+        }
+    }
+    else
+    {
+        if (!iPartialFrameAssembly)
+        {
+            iInputCurrLength = 0;
+            ipFrameDecodeBuffer = ipInputCurrBuffer;
+        }
+
+        while (iNumInputBuffer > 0)
+        {
+            int32 BytesToCopy = ipInputBuffer->nFilledLen;
+
+            if ((iInputCurrLength + BytesToCopy) > iInputCurrBufferSize)
+            {
+                // allocate new partial frame buffers
+                OMX_U8* pTempNewBuffer = NULL;
+                pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
+
+                if (NULL != pTempNewBuffer)
+                {
+                    // copy contents of the old buffer into the new one
+                    oscl_memcpy(pTempNewBuffer, ipTempInputBuffer, iTempInputBufferLength);
+                    // free the old buffer
+                    if (ipTempInputBuffer)
+                    {
+                        oscl_free(ipTempInputBuffer);
+                    }
+                    // assign new one
+                    ipTempInputBuffer = pTempNewBuffer;
+
+                    pTempNewBuffer = NULL;
+                    pTempNewBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
+
+                    // in the event that new buffer cannot be allocated
+                    if (NULL == pTempNewBuffer)
+                    {
+                        // copy into what space is available, and let the decoder complain
+                        BytesToCopy = iInputCurrLength - iInputCurrBufferSize;
+                    }
+                    else
+                    {
+                        // copy contents of the old buffer into the new one
+                        oscl_memcpy(pTempNewBuffer, ipInputCurrBuffer, iInputCurrBufferSize);
+                        // free the old buffer
+                        if (ipInputCurrBuffer)
+                        {
+                            oscl_free(ipInputCurrBuffer);
+                        }
+                        // assign new memory location
+                        ipInputCurrBuffer = pTempNewBuffer;
+                        iInputCurrBufferSize = (iInputCurrLength + BytesToCopy);
+                        ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
+                    }
+                }
+                //No memory to allocate ipTempInputBuffer
+                else
+                {
+                    // copy into what space is available, and let the decoder complain
+                    BytesToCopy = iInputCurrLength - iInputCurrBufferSize;
+                }
+            }
+
+            oscl_memcpy(ipFrameDecodeBuffer, (ipInputBuffer->pBuffer + ipInputBuffer->nOffset), BytesToCopy);
+            ipFrameDecodeBuffer += ipInputBuffer->nFilledLen; // move the ptr
+            iInputCurrLength += BytesToCopy;
+
+            iFrameTimestamp = ipInputBuffer->nTimeStamp;
+
+            // check if we've encountered end of frame flag while trying to assemble the very first frame
+            if ((0 == iFrameCount) && ((ipInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker EndOfFrameFlag finally arrived"));
+                iEndOfFrameFlag = OMX_TRUE;
+            }
+
+            if ((iInputCurrLength >= (iInputCurrBufferSize >> 1))
+                    || (OMX_TRUE == iEndofStream) || (OMX_TRUE == iEndOfFrameFlag))
+            {
+                break;
+            }
+
+            //Set the filled len to zero to indicate buffer is fully consumed
+            ipInputBuffer->nFilledLen = 0;
+            ReturnInputBuffer(ipInputBuffer, pInPort);
+            ipInputBuffer = NULL;
+
+            if (iNumInputBuffer > 0)
+            {
+                ipInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
+                if (NULL == ipInputBuffer)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker Error, Input buffer Dequeue returned NULL"));
+                    return OMX_FALSE;
+                }
+
+                if (ipInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker EndOfStream arrived"));
+                    iEndofStream = OMX_TRUE;
+                }
+            }
+        }
+
+        if (iEndOfFrameFlag)
+        {
+            // if we have encountered end of frame, 1st frame has been assembled
+            // and we can switch to "end of frame flag" mode
+            iIsInputBufferEnded = OMX_FALSE;
+            iNewInBufferRequired = OMX_FALSE;
+            ipFrameDecodeBuffer = ipInputCurrBuffer; // rewind buffer ptr to beginning of inputcurrbuffer
+            iPartialFrameAssembly = OMX_FALSE;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker Found end of frame flag - OUT"));
+            return OMX_TRUE;
+
+        }
+
+        if ((((iInputCurrLength + iTempInputBufferLength) < (iInputCurrBufferSize >> 1)))
+                && (OMX_TRUE != iEndofStream))
+        {
+            iPartialFrameAssembly = OMX_TRUE;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker OUT"));
+            return OMX_FALSE;
+        }
+        else
+        {
+            ipFrameDecodeBuffer = ipInputCurrBuffer;
+            iPartialFrameAssembly = OMX_FALSE;
+
+            /* Components not implementing ComponentBufferMgmtWithoutMarker(), will reset
+             * iIsInputBufferEnded flag in the below routine */
+            pOpenmaxAOType->ProcessInBufferFlag();
+        }
+
+    }
+
+
+    //Different components may choose to do some extra processing here.
+    //e.g. video components and also amr component copies the collected data into temp input buffers here.
+    pOpenmaxAOType->ComponentBufferMgmtWithoutMarker();
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : BufferMgmtWithoutMarker OUT"));
+    return OMX_TRUE;
+
+}
+
+
+
+//Propagate here the buffer mark through output port in case of BufferMgmtWithoutMarker
+void OmxComponentBase::ComponentBufferMgmtWithoutMarker()
+{
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+
+    ipTargetComponent = (OMX_COMPONENTTYPE*) ipInputBuffer->hMarkTargetComponent;
+
+    iTargetMarkData = ipInputBuffer->pMarkData;
+    if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
+    {
+        (*(ipCallbacks->EventHandler))
+        (pHandle,
+         iCallbackData,
+         OMX_EventMark,
+         1,
+         0,
+         ipInputBuffer->pMarkData);
+    }
+}
+
+
+/* A part of buffer management without marker routine, this function will
+ * copy the current input buffer into a big temporary buffer, so that
+ * an incomplete/partial frame is never passed to the decoder library for decode
+*/
+void OmxComponentBase::TempInputBufferMgmtWithoutMarker()
+{
+    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
+    ComponentPortType*	pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    OMX_U32 TempInputBufferSize = iInputCurrBufferSize;
+
+    if (iTempInputBufferLength < (TempInputBufferSize >> 1))
+    {
+        oscl_memmove(ipTempInputBuffer, &ipTempInputBuffer[iTempConsumedLength], iTempInputBufferLength);
+        iIsInputBufferEnded = OMX_TRUE;
+        iTempConsumedLength = 0;
+    }
+
+    if ((iTempInputBufferLength + iTempConsumedLength + iInputCurrLength)
+            <= TempInputBufferSize)
+    {
+        oscl_memcpy(&ipTempInputBuffer[iTempInputBufferLength + iTempConsumedLength], ipFrameDecodeBuffer, iInputCurrLength);
+        iTempInputBufferLength += iInputCurrLength;
+
+        if (iTempInputBufferLength + (TempInputBufferSize >> 1) <= TempInputBufferSize)
+        {
+            iNewInBufferRequired = OMX_TRUE;
+        }
+        else
+        {
+            iNewInBufferRequired = OMX_FALSE;
+        }
+
+        ipTargetComponent = (OMX_COMPONENTTYPE*) ipInputBuffer->hMarkTargetComponent;
+
+        iTargetMarkData = ipInputBuffer->pMarkData;
+        if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
+        {
+            (*(ipCallbacks->EventHandler))
+            (pHandle,
+             iCallbackData,
+             OMX_EventMark,
+             1,
+             0,
+             ipInputBuffer->pMarkData);
+        }
+        ipInputBuffer->nFilledLen = 0;
+        ReturnInputBuffer(ipInputBuffer, pInPort);
+        ipInputBuffer = NULL;
+
+    }
+
+    if (iTempInputBufferLength >= (TempInputBufferSize >> 1))
+    {
+        iIsInputBufferEnded = OMX_FALSE;
+    }
+}
+
+
+
+void OmxComponentBase::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Run IN"));
+
+    CoreMessage* pCoreMessage;
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*) iOmxComponent.pComponentPrivate;
+
+    //Execute the commands from the message handler queue
+    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
+    {
+        pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue);
+
+        if (OMX_CommandStateSet == pCoreMessage->MessageParam1)
+        {
+            if (OMX_StateExecuting == pCoreMessage->MessageParam2)
+            {
+                iBufferExecuteFlag = OMX_TRUE;
+            }
+            else
+            {
+                iBufferExecuteFlag = OMX_FALSE;
+            }
+        }
+
+        MessageHandler(pCoreMessage);
+
+        /* If some allocations/deallocations are required before the state transition
+         * then queue the command again to be executed later on
+         */
+        if (OMX_TRUE == iStateTransitionFlag)
+        {
+            if (OMX_ErrorNone != Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Error, Queue command failed, Run OUT"));
+                return;
+            }
+
+            // Don't reschedule. Wait for arriving buffers to do it
+            //RunIfNotReady();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Run OUT"));
+            return;
+        }
+
+        else
+        {
+            oscl_free(pCoreMessage);
+            pCoreMessage = NULL;
+        }
+    }
+
+    /* If the component is in executing state, call the Buffer management function.
+     * Stop calling this function as soon as state transition request is received.
+     */
+    if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending))
+    {
+        pOpenmaxAOType->BufferMgmtFunction();
+    }
+
+    //Check for any more commands in the message handler queue & schedule them for later
+    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
+    {
+        RunIfNotReady();
+    }
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : Run OUT"));
+
+    return;
+}
+
+
+/**************************
+ AUDIO BASE CLASS ROUTINES
+ **************************/
+OmxComponentAudio::OmxComponentAudio()
+{
+    iIsAudioComponent = OMX_TRUE;
+
+}
+
+
+OMX_ERRORTYPE OmxComponentAudio::GetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter IN"));
+
+    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
+    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
+    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
+    OMX_PORT_PARAM_TYPE* pPortDomains;
+    OMX_U32 PortIndex;
+
+    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
+    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
+    OMX_AUDIO_PARAM_WMATYPE* pAudioWma;
+    OMX_AUDIO_PARAM_MP3TYPE* pAudioMp3;
+    OMX_AUDIO_CONFIG_EQUALIZERTYPE* pAudioEqualizer;
+    OMX_AUDIO_PARAM_AACPROFILETYPE* pAudioAac;
+    OMX_AUDIO_PARAM_AMRTYPE* pAudioAmr;
+
+    ComponentPortType* pComponentPort;
+
+    if (NULL == ComponentParameterStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nParamIndex)
+    {
+        case OMX_IndexParamPriorityMgmt:
+        {
+            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
+            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
+            pPrioMgmt->nGroupPriority = iGroupPriority;
+            pPrioMgmt->nGroupID = iGroupID;
+        }
+        break;
+
+        case OMX_IndexParamAudioInit:
+        {
+            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
+            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
+        }
+        break;
+
+
+        //Following 3 cases have a single common piece of code to be executed
+        case OMX_IndexParamVideoInit:
+        case OMX_IndexParamImageInit:
+        case OMX_IndexParamOtherInit:
+        {
+            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
+            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
+            pPortDomains->nPorts = 0;
+            pPortDomains->nStartPortNumber = 0;
+        }
+        break;
+
+        case OMX_IndexParamAudioPortFormat:
+        {
+            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
+            //Added to pass parameter test
+            if (pAudioPortFormat->nIndex > ipPorts[pAudioPortFormat->nPortIndex]->AudioParam.nIndex)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error index out of range"));
+                return OMX_ErrorNoMore;
+            }
+            SetHeader(pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+            if (pAudioPortFormat->nPortIndex <= 1)
+            {
+                pComponentPort = (ComponentPortType*) ipPorts[pAudioPortFormat->nPortIndex];
+                oscl_memcpy(pAudioPortFormat, &pComponentPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+        }
+        break;
+
+        case OMX_IndexParamAudioPcm:
+        {
+            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
+            if (pAudioPcmMode->nPortIndex > 1)
+            {
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pAudioPcmMode->nPortIndex;
+            oscl_memcpy(pAudioPcmMode, &ipPorts[PortIndex]->AudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+            SetHeader(pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioMp3:
+        {
+            pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure;
+            if (pAudioMp3->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pAudioMp3->nPortIndex;
+            oscl_memcpy(pAudioMp3, &ipPorts[PortIndex]->AudioMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+            SetHeader(pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioWma:
+        {
+            pAudioWma = (OMX_AUDIO_PARAM_WMATYPE*) ComponentParameterStructure;
+            if (pAudioWma->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pAudioWma->nPortIndex;
+            oscl_memcpy(pAudioWma, &ipPorts[PortIndex]->AudioWmaParam, sizeof(OMX_AUDIO_PARAM_WMATYPE));
+            SetHeader(pAudioWma, sizeof(OMX_AUDIO_PARAM_WMATYPE));
+        }
+        break;
+
+        case OMX_IndexConfigAudioEqualizer:
+        {
+            pAudioEqualizer = (OMX_AUDIO_CONFIG_EQUALIZERTYPE*) ComponentParameterStructure;
+            if (pAudioEqualizer->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pAudioEqualizer->nPortIndex;
+            oscl_memcpy(pAudioEqualizer, &ipPorts[PortIndex]->AudioEqualizerType, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
+            SetHeader(pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioAac:
+        {
+            pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure;
+            if (pAudioAac->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pAudioAac->nPortIndex;
+            oscl_memcpy(pAudioAac, &ipPorts[PortIndex]->AudioAacParam, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
+            SetHeader(pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioAmr:
+        {
+            pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure;
+            if (pAudioAmr->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pAudioAmr->nPortIndex;
+            oscl_memcpy(pAudioAmr, &ipPorts[PortIndex]->AudioAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
+            SetHeader(pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
+        }
+        break;
+
+        case OMX_IndexParamPortDefinition:
+        {
+            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
+            PortIndex = pPortDef->nPortIndex;
+            if (PortIndex >= iNumPorts)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamCompBufferSupplier:
+        {
+            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
+            PortIndex = pBufSupply->nPortIndex;
+            if (PortIndex >= iNumPorts)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+
+            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
+            {
+                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
+            }
+            else
+            {
+                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
+            }
+        }
+        break;
+
+        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
+        {
+            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
+            if (NULL == pCap_flags)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error pCap_flags NULL"));
+                return OMX_ErrorBadParameter;
+            }
+            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
+
+        }
+        break;
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter error Unsupported Index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : GetParameter OUT"));
+
+    return OMX_ErrorNone;
+
+}
+
+
+OMX_ERRORTYPE OmxComponentAudio::SetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_IN  OMX_PTR ComponentParameterStructure)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter IN"));
+
+    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
+    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
+    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
+    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
+    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
+    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
+    ComponentPortType* pComponentPort;
+
+    OMX_AUDIO_PARAM_WMATYPE* pAudioWma;
+    OMX_AUDIO_PARAM_MP3TYPE* pAudioMp3;
+    OMX_AUDIO_CONFIG_EQUALIZERTYPE* pAudioEqualizer;
+    OMX_AUDIO_PARAM_AACPROFILETYPE* pAudioAac;
+    OMX_AUDIO_PARAM_AMRTYPE* pAudioAmr;
+
+    OMX_U32 PortIndex;
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    OmxComponentAudio* pOpenmaxAOType = (OmxComponentAudio*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+
+
+    if (NULL == ComponentParameterStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nParamIndex)
+    {
+        case OMX_IndexParamAudioInit:
+        {
+            /*Check Structure Header*/
+            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error audio init failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioPortFormat:
+        {
+            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
+            PortIndex = pAudioPortFormat->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            if (PortIndex <= 1)
+            {
+                pComponentPort = (ComponentPortType*) ipPorts[PortIndex];
+                oscl_memcpy(&pComponentPort->AudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+        }
+        break;
+
+        case OMX_IndexParamAudioPcm:
+        {
+            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
+            PortIndex = pAudioPcmMode->nPortIndex;
+            /*Check Structure Header and verify component State*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+            oscl_memcpy(&ipPorts[PortIndex]->AudioPcmMode, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioMp3:
+        {
+            pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure;
+            PortIndex = pAudioMp3->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->AudioMp3Param, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioWma:
+        {
+
+
+            pAudioWma = (OMX_AUDIO_PARAM_WMATYPE*) ComponentParameterStructure;
+            PortIndex = pAudioWma->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioWma, sizeof(OMX_AUDIO_PARAM_WMATYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->AudioWmaParam, pAudioWma, sizeof(OMX_AUDIO_PARAM_WMATYPE));
+        }
+        break;
+
+        case OMX_IndexConfigAudioEqualizer:
+        {
+            pAudioEqualizer = (OMX_AUDIO_CONFIG_EQUALIZERTYPE*) ComponentParameterStructure;
+            PortIndex = pAudioEqualizer->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->AudioEqualizerType, pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
+        }
+        break;
+
+        case OMX_IndexParamAudioAac:
+        {
+            OMX_BOOL AacPlusFlag = OMX_TRUE;
+
+            pAudioAac = (OMX_AUDIO_PARAM_AACPROFILETYPE*) ComponentParameterStructure;
+            PortIndex = pAudioAac->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->AudioAacParam, pAudioAac, sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
+
+            if ((ipPorts[PortIndex]->AudioAacParam.eAACProfile == OMX_AUDIO_AACObjectHE)
+                    || (ipPorts[PortIndex]->AudioAacParam.eAACProfile == OMX_AUDIO_AACObjectHE_PS))
+            {
+                AacPlusFlag = OMX_TRUE;
+            }
+            else
+            {
+                AacPlusFlag = OMX_FALSE;
+            }
+
+            pOpenmaxAOType->UpdateAACPlusFlag(AacPlusFlag);
+        }
+        break;
+
+        case OMX_IndexParamAudioAmr:
+        {
+            pAudioAmr = (OMX_AUDIO_PARAM_AMRTYPE*) ComponentParameterStructure;
+            PortIndex = pAudioAmr->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->AudioAmrParam, pAudioAmr, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
+
+            //If the band mode turns out to be WB, set the sampling freq to 16KHz
+            if ((pAudioAmr->eAMRBandMode >= OMX_AUDIO_AMRBandModeWB0) &&
+                    (pAudioAmr->eAMRBandMode <= OMX_AUDIO_AMRBandModeWB8))
+            {
+                ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nSamplingRate = 16000;
+            }
+        }
+        break;
+
+        case OMX_IndexParamPriorityMgmt:
+        {
+            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error incorrect state error"));
+                return OMX_ErrorIncorrectStateOperation;
+            }
+            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
+            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
+            {
+                break;
+            }
+            iGroupPriority = pPrioMgmt->nGroupPriority;
+            iGroupID = pPrioMgmt->nGroupID;
+        }
+        break;
+
+        case OMX_IndexParamPortDefinition:
+        {
+            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
+            PortIndex = pPortDef->nPortIndex;
+
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+
+            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
+            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
+
+            oscl_memcpy(&ipPorts[PortIndex]->PortParam.format.audio, &pPortDef->format.audio, sizeof(OMX_AUDIO_PORTDEFINITIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamCompBufferSupplier:
+        {
+            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
+            PortIndex = pBufSupply->nPortIndex;
+
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+            if (OMX_ErrorIncorrectStateOperation == ErrorType)
+            {
+                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error incorrect state error"));
+                    return OMX_ErrorIncorrectStateOperation;
+                }
+            }
+            else if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+
+            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter OUT"));
+                return OMX_ErrorNone;
+            }
+
+            ErrorType = OMX_ErrorNone;
+        }
+        break;
+
+        case OMX_IndexParamStandardComponentRole:
+        {
+            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
+            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
+            {
+                break;
+            }
+            oscl_strncpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole, OMX_MAX_STRINGNAME_SIZE);
+        }
+        break;
+
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter error Unsupported index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAudio : SetParameter OUT"));
+    return ErrorType;
+
+}
+
+
+/*************************
+ VIDEO BASE CLASS ROUTINES
+ *************************/
+OmxComponentVideo::OmxComponentVideo()
+{
+    iIsAudioComponent = OMX_FALSE;
+
+}
+
+
+OMX_ERRORTYPE OmxComponentVideo::GetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter IN"));
+
+    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
+    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
+    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
+    OMX_PORT_PARAM_TYPE* pPortDomains;
+    OMX_U32 PortIndex;
+
+    OMX_VIDEO_PARAM_PORTFORMATTYPE* pVideoPortFormat;
+    OMX_VIDEO_PARAM_PROFILELEVELTYPE* pProfileLevel;
+
+    OMX_VIDEO_PARAM_MPEG4TYPE* pVideoMpeg4;
+    OMX_VIDEO_PARAM_H263TYPE* pVideoH263;
+    OMX_VIDEO_PARAM_AVCTYPE* pVideoAvc;
+    OMX_VIDEO_PARAM_WMVTYPE* pVideoWmv;
+
+    //Video encoder configuration parameters
+    OMX_CONFIG_ROTATIONTYPE*			 pVideoRotation;
+    OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* pVideoErrCorr;
+    OMX_VIDEO_PARAM_BITRATETYPE*		 pVideoRateControl;
+    OMX_VIDEO_PARAM_QUANTIZATIONTYPE*	 pVideoQuant;
+    OMX_VIDEO_PARAM_VBSMCTYPE*			 pVideoBlock;
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE*	 pVideoMotionVector;
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE*	 pVideoIntraRefresh;
+
+    if (NULL == ComponentParameterStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nParamIndex)
+    {
+        case OMX_IndexParamPriorityMgmt:
+        {
+            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
+            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
+            pPrioMgmt->nGroupPriority = iGroupPriority;
+            pPrioMgmt->nGroupID = iGroupID;
+        }
+        break;
+
+        case OMX_IndexParamVideoInit:
+        {
+            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
+            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
+        }
+        break;
+
+
+        //Following 3 cases have a single common piece of code to be executed
+        case OMX_IndexParamAudioInit:
+        case OMX_IndexParamImageInit:
+        case OMX_IndexParamOtherInit:
+        {
+            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
+            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
+            pPortDomains->nPorts = 0;
+            pPortDomains->nStartPortNumber = 0;
+        }
+        break;
+
+        case OMX_IndexParamVideoPortFormat:
+        {
+            pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
+
+            //Check for valid port index
+            PortIndex = pVideoPortFormat->nPortIndex;
+            if (PortIndex >= iNumPorts)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            OMX_U32 QueriedIndex = pVideoPortFormat->nIndex;
+            if (QueriedIndex >= ipPorts[PortIndex]->ActualNumPortFormatsSupported)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error index out of range"));
+                return OMX_ErrorNoMore;
+            }
+            else
+            {
+                SetHeader(pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+                oscl_memcpy(pVideoPortFormat, &ipPorts[PortIndex]->VideoParam[QueriedIndex], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+            }
+        }
+
+        break;
+
+        case OMX_IndexParamVideoMpeg4:
+        {
+            pVideoMpeg4 = (OMX_VIDEO_PARAM_MPEG4TYPE*) ComponentParameterStructure;
+            if (pVideoMpeg4->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoMpeg4->nPortIndex;
+            oscl_memcpy(pVideoMpeg4, &ipPorts[PortIndex]->VideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+            SetHeader(pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoH263:
+        {
+            pVideoH263 = (OMX_VIDEO_PARAM_H263TYPE*) ComponentParameterStructure;
+            if (pVideoH263->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoH263->nPortIndex;
+            oscl_memcpy(pVideoH263, &ipPorts[PortIndex]->VideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+            SetHeader(pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoAvc:
+        {
+            pVideoAvc = (OMX_VIDEO_PARAM_AVCTYPE*) ComponentParameterStructure;
+            if (pVideoAvc->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoAvc->nPortIndex;
+            oscl_memcpy(pVideoAvc, &ipPorts[PortIndex]->VideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+            SetHeader(pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoWmv:
+        {
+            pVideoWmv = (OMX_VIDEO_PARAM_WMVTYPE*)ComponentParameterStructure;
+            if (pVideoWmv->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoWmv->nPortIndex;
+            oscl_memcpy(pVideoWmv, &ipPorts[PortIndex]->VideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+            SetHeader(pVideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoProfileLevelQuerySupported:
+        {
+            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
+
+            PortIndex = pProfileLevel->nPortIndex;
+            if (pProfileLevel->nProfileIndex > ipPorts[PortIndex]->ProfileLevel.nProfileIndex)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error profile not supported"));
+                return OMX_ErrorNoMore;
+            }
+
+            oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+            SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoProfileLevelCurrent:
+        {
+            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
+
+            PortIndex = pProfileLevel->nPortIndex;
+
+            oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+            SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+        }
+        break;
+
+        case OMX_IndexParamPortDefinition:
+        {
+            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
+            PortIndex = pPortDef->nPortIndex;
+            if (PortIndex >= iNumPorts)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamCompBufferSupplier:
+        {
+            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
+            PortIndex = pBufSupply->nPortIndex;
+            if (PortIndex >= iNumPorts)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+
+            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
+            {
+                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
+            }
+            else
+            {
+                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
+            }
+        }
+        break;
+
+        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
+        {
+            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
+            if (NULL == pCap_flags)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error pCap_flags NULL"));
+                return OMX_ErrorBadParameter;
+            }
+            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
+
+        }
+        break;
+
+        case OMX_IndexConfigCommonRotate:
+        {
+            pVideoRotation = (OMX_CONFIG_ROTATIONTYPE*) ComponentParameterStructure;
+            if (pVideoRotation->nPortIndex >= iNumPorts)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoRotation->nPortIndex;
+            oscl_memcpy(pVideoRotation, &ipPorts[PortIndex]->VideoOrientationType, sizeof(OMX_CONFIG_ROTATIONTYPE));
+            SetHeader(pVideoRotation, sizeof(OMX_CONFIG_ROTATIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoErrorCorrection:
+        {
+            pVideoErrCorr = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE*) ComponentParameterStructure;
+            if (pVideoErrCorr->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoErrCorr->nPortIndex;
+            oscl_memcpy(pVideoErrCorr, &ipPorts[PortIndex]->VideoErrorCorrection, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+            SetHeader(pVideoErrCorr, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoBitrate:
+        {
+            pVideoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE*) ComponentParameterStructure;
+            if (pVideoRateControl->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoRateControl->nPortIndex;
+            oscl_memcpy(pVideoRateControl, &ipPorts[PortIndex]->VideoRateType, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
+            SetHeader(pVideoRateControl, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoQuantization:
+        {
+            pVideoQuant = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE*) ComponentParameterStructure;
+            if (pVideoQuant->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoQuant->nPortIndex;
+            oscl_memcpy(pVideoQuant, &ipPorts[PortIndex]->VideoQuantType, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
+            SetHeader(pVideoQuant, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoVBSMC:
+        {
+            pVideoBlock = (OMX_VIDEO_PARAM_VBSMCTYPE*) ComponentParameterStructure;
+            if (pVideoBlock->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoBlock->nPortIndex;
+            oscl_memcpy(pVideoBlock, &ipPorts[PortIndex]->VideoBlockMotionSize, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+            SetHeader(pVideoBlock, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoMotionVector:
+        {
+            pVideoMotionVector = (OMX_VIDEO_PARAM_MOTIONVECTORTYPE*) ComponentParameterStructure;
+            if (pVideoMotionVector->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoMotionVector->nPortIndex;
+            oscl_memcpy(pVideoMotionVector, &ipPorts[PortIndex]->VideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+            SetHeader(pVideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoIntraRefresh:
+        {
+            pVideoIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE*) ComponentParameterStructure;
+            if (pVideoIntraRefresh->nPortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+            PortIndex = pVideoIntraRefresh->nPortIndex;
+            oscl_memcpy(pVideoIntraRefresh, &ipPorts[PortIndex]->VideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+            SetHeader(pVideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+        }
+        break;
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter error Unsupported Index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : GetParameter OUT"));
+
+    return OMX_ErrorNone;
+
+}
+
+
+OMX_ERRORTYPE OmxComponentVideo::SetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_IN  OMX_PTR ComponentParameterStructure)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter IN"));
+
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
+    OMX_VIDEO_PARAM_PORTFORMATTYPE* pVideoPortFormat;
+    OMX_VIDEO_PARAM_PROFILELEVELTYPE* pProfileLevel;
+    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
+    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
+    OMX_U32 PortIndex;
+
+    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
+    OMX_VIDEO_PARAM_MPEG4TYPE*   pVideoMpeg4;
+    OMX_VIDEO_PARAM_H263TYPE*    pVideoH263;
+    OMX_VIDEO_PARAM_WMVTYPE*     pVideoWmv;
+    OMX_VIDEO_PARAM_AVCTYPE*     pVideoAvc;
+
+    //Video encoder configuration parameters
+    OMX_CONFIG_ROTATIONTYPE*			 pVideoRotation;
+    OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* pVideoErrCorr;
+    OMX_VIDEO_PARAM_BITRATETYPE*		 pVideoRateControl;
+    OMX_VIDEO_PARAM_QUANTIZATIONTYPE*	 pVideoQuant;
+    OMX_VIDEO_PARAM_VBSMCTYPE*			 pVideoBlock;
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE*	 pVideoMotionVector;
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE*	 pVideoIntraRefresh;
+
+
+    ComponentPortType* pComponentPort;
+
+    if (NULL == ComponentParameterStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nParamIndex)
+    {
+        case OMX_IndexParamVideoInit:
+        {
+            /*Check Structure Header*/
+            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error video init check header failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoPortFormat:
+        {
+            pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoPortFormat->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            if (PortIndex <= 1)
+            {
+                pComponentPort = (ComponentPortType*) ipPorts[PortIndex];
+                oscl_memcpy(&pComponentPort->VideoParam, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error bad port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+        }
+        break;
+
+        case OMX_IndexParamVideoMpeg4:
+        {
+            pVideoMpeg4 = (OMX_VIDEO_PARAM_MPEG4TYPE*) ComponentParameterStructure;
+            PortIndex = pVideoMpeg4->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoMpeg4, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoH263:
+        {
+            pVideoH263 = (OMX_VIDEO_PARAM_H263TYPE*) ComponentParameterStructure;
+            PortIndex = pVideoH263->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoH263, pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoAvc:
+        {
+            pVideoAvc = (OMX_VIDEO_PARAM_AVCTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoAvc->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoAvc, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoWmv:
+        {
+            pVideoWmv = (OMX_VIDEO_PARAM_WMVTYPE*)ComponentParameterStructure;
+            PortIndex = pVideoWmv->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoWmv, pVideoWmv, sizeof(OMX_VIDEO_PARAM_WMVTYPE));
+        }
+        break;
+
+
+        case OMX_IndexParamVideoProfileLevelCurrent:
+        {
+            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
+            PortIndex = pProfileLevel->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+            if (OMX_ErrorNone != ErrorType)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->ProfileLevel, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
+        }
+        break;
+
+        case OMX_IndexParamPriorityMgmt:
+        {
+            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error incorrect state error"));
+                return OMX_ErrorIncorrectStateOperation;
+            }
+            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
+            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
+            {
+                break;
+            }
+            iGroupPriority = pPrioMgmt->nGroupPriority;
+            iGroupID = pPrioMgmt->nGroupID;
+        }
+        break;
+
+        case OMX_IndexParamPortDefinition:
+        {
+            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
+            PortIndex = pPortDef->nPortIndex;
+
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+
+            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
+            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
+
+            oscl_memcpy(&ipPorts[PortIndex]->PortParam.format.video, &pPortDef->format.video, sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
+
+        }
+        break;
+
+        case OMX_IndexParamCompBufferSupplier:
+        {
+            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
+            PortIndex = pBufSupply->nPortIndex;
+
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
+            if (OMX_ErrorIncorrectStateOperation == ErrorType)
+            {
+                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error incorrect state error"));
+                    return OMX_ErrorIncorrectStateOperation;
+                }
+            }
+            else if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error parameter sanity check error"));
+                return ErrorType;
+            }
+
+            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter OUT"));
+                return OMX_ErrorNone;
+            }
+
+            ErrorType = OMX_ErrorNone;
+        }
+        break;
+
+        case OMX_IndexParamStandardComponentRole:
+        {
+            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
+            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
+            {
+                break;
+            }
+            oscl_strncpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole, OMX_MAX_STRINGNAME_SIZE);
+        }
+        break;
+
+
+        case OMX_IndexConfigCommonRotate:
+        {
+            pVideoRotation = (OMX_CONFIG_ROTATIONTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoRotation->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoRotation, sizeof(OMX_CONFIG_ROTATIONTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoOrientationType, pVideoRotation, sizeof(OMX_CONFIG_ROTATIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoErrorCorrection:
+        {
+            pVideoErrCorr = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoErrCorr->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoErrCorr, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoErrorCorrection, pVideoErrCorr, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoBitrate:
+        {
+            pVideoRateControl = (OMX_VIDEO_PARAM_BITRATETYPE*) ComponentParameterStructure;
+            PortIndex = pVideoRateControl->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoRateControl, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoRateType, pVideoRateControl, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoQuantization:
+        {
+            pVideoQuant = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoQuant->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoQuant, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoQuantType, pVideoQuant, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoVBSMC:
+        {
+            pVideoBlock = (OMX_VIDEO_PARAM_VBSMCTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoBlock->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoBlock, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoBlockMotionSize, pVideoBlock, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoMotionVector:
+        {
+            pVideoMotionVector = (OMX_VIDEO_PARAM_MOTIONVECTORTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoMotionVector->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoMotionVector, pVideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+        }
+        break;
+
+        case OMX_IndexParamVideoIntraRefresh:
+        {
+            pVideoIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE*) ComponentParameterStructure;
+            PortIndex = pVideoIntraRefresh->nPortIndex;
+            /*Check Structure Header and verify component state*/
+            ErrorType = ParameterSanityCheck(hComponent, PortIndex, pVideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error param check failed"));
+                return ErrorType;
+            }
+            oscl_memcpy(&ipPorts[PortIndex]->VideoIntraRefresh, pVideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+        }
+        break;
+
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter error Unsupported index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentVideo : SetParameter OUT"));
+    return ErrorType;
+
+}
+#if PROXY_INTERFACE
+
+/** Component entry points declarations with proxy interface*/
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetConfig(hComponent, nIndex, pComponentConfigStructure);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_IN  OMX_PTR pComponentConfigStructure)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySetConfig(hComponent, nIndex, pComponentConfigStructure);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetExtensionIndex(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_STRING cParameterName,
+    OMX_OUT OMX_INDEXTYPE* pIndexType)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetExtensionIndex(hComponent, cParameterName, pIndexType);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetState(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_OUT OMX_STATETYPE* pState)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetState(hComponent, pState);
+    return ReturnValue;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyGetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_INOUT OMX_PTR ComponentParameterStructure)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue = OMX_ErrorNone;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyGetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+    return ReturnValue;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySetParameter(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nParamIndex,
+    OMX_IN  OMX_PTR ComponentParameterStructure)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySetParameter(hComponent, nParamIndex, ComponentParameterStructure);
+    return ReturnValue;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyUseBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes,
+    OMX_IN OMX_U8* pBuffer)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyUseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyAllocateBuffer(
+    OMX_IN OMX_HANDLETYPE hComponent,
+    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
+    OMX_IN OMX_U32 nPortIndex,
+    OMX_IN OMX_PTR pAppPrivate,
+    OMX_IN OMX_U32 nSizeBytes)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyAllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyFreeBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_U32 nPortIndex,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyFreeBuffer(hComponent, nPortIndex, pBuffer);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySetCallbacks(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
+    OMX_IN  OMX_PTR pAppData)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySetCallbacks(hComponent, pCallbacks, pAppData);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxySendCommand(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_COMMANDTYPE Cmd,
+    OMX_IN  OMX_U32 nParam,
+    OMX_IN  OMX_PTR pCmdData)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxySendCommand(hComponent, Cmd, nParam, pCmdData);
+    return ReturnValue;
+}
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyEmptyThisBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyEmptyThisBuffer(hComponent, pBuffer);
+    return ReturnValue;
+}
+
+
+OMX_ERRORTYPE OmxComponentBase::BaseComponentProxyFillThisBuffer(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+{
+    OmxComponentBase* pOpenmaxAOType = (OmxComponentBase*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    OMX_ERRORTYPE ReturnValue;
+
+    ReturnValue = ((ProxyApplication_OMX*)(pOpenmaxAOType->ipComponentProxy))->ProxyFillThisBuffer(hComponent, pBuffer);
+    return ReturnValue;
+}
+
+#endif // PROXY_INTERFACE
diff --git a/codecs_v2/omx/omx_common/Android.mk b/codecs_v2/omx/omx_common/Android.mk
old mode 100755
new mode 100644
index 01b42ff..6b96e7e
--- a/codecs_v2/omx/omx_common/Android.mk
+++ b/codecs_v2/omx/omx_common/Android.mk
@@ -2,50 +2,31 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        src/\
-        src/pv_omxcore.cpp \
-        src/pv_omxregistry.cpp \
-        src/pv_omxmastercore.cpp \
-        src/qc_omxcore.cpp
+	src/pv_omxcore.cpp \
+ 	src/pv_omxregistry.cpp
 
 
 LOCAL_MODULE := libomx_common_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-# board-specific configuration
-LOCAL_CFLAGS += $(BOARD_OPENCORE_FLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-        $(PV_TOP)//codecs_v2/omx/omx_common/include \
-        $(PV_TOP)//codecs_v2/omx/omx_common/src \
-        $(PV_TOP)//codecs_v2/omx/omx_common/../../../extern_libs_v2/khronos/openmax/include \
-        $(PV_INCLUDES)
+LOCAL_STATIC_LIBRARIES := 
 
-ifeq ($(ARCHITECTURE), linux_nj)
-   LOCAL_C_INCLUDES += $(PV_TOP)//codecs_v2/omx/omx_common/config/linux_nj
-else
-   ifeq ($(FORMAT), 3gpp)
-      LOCAL_C_INCLUDES += $(PV_TOP)//codecs_v2/omx/omx_common/config/linux_3gpp
-   else
-      ifeq ($(FORMAT), nj)
-         LOCAL_C_INCLUDES += $(PV_TOP)//codecs_v2/omx/omx_common/config/linux_nj
-      else
-         LOCAL_C_INCLUDES += $(PV_TOP)//codecs_v2/omx/omx_common/config/default
-      endif
-   endif
-endif
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_common/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_common/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-        include/pv_omxmastercore.h \
-        include/pv_omxcore.h \
-        include/pv_omxdefs.h \
-        include/pv_omx_shared_lib_interface.h \
-        include/qc_omxcore.h \
-        include/pv_omxwrapperbase.h
+	include/pv_omxcore.h \
+ 	include/pv_omxdefs.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_common/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_common/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..c1faaf2
--- /dev/null
+++ b/codecs_v2/omx/omx_common/build/make_multithreaded/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_common_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../../pvmi/pvmf/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := \
+    pv_omxcore.cpp \
+    pv_omxregistry.cpp
+
+
+HDRS := \
+    pv_omxcore.h \
+    pv_omxdefs.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_common/build/make_multithreaded/makefile b/codecs_v2/omx/omx_common/build/make_multithreaded/makefile
deleted file mode 100755
index 489533b..0000000
--- a/codecs_v2/omx/omx_common/build/make_multithreaded/makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_common_lib
-
-XINCDIRS += \
-	-I ../../../../../extern_libs_v2/khronos/openmax/include 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = 	\
-	pv_omxcore.cpp \
-	pv_omxregistry.cpp \
-	pv_omxmastercore.cpp \
-	qc_omxcore.cpp
-
-ifeq ($(ARCHITECTURE), linux_nj)
-   XINCDIRS += -I ../../config/linux_nj
-else
-   ifeq ($(FORMAT), 3gpp)
-      XINCDIRS += -I ../../config/linux_3gpp
-   else
-      ifeq ($(FORMAT), nj)
-         XINCDIRS += -I ../../config/linux_nj
-      else
-         XINCDIRS += -I ../../config/default
-      endif
-   endif
-endif
-
-HDRS =	\
-        pv_omxmastercore.h \
-	pv_omxcore.h \
-	pv_omxdefs.h \
-	pv_omx_shared_lib_interface.h \
-	qc_omxcore.h \
- 	pv_omxwrapperbase.h
-	
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_common/config/linux_nj/pv_omxregistry.h b/codecs_v2/omx/omx_common/config/linux_nj/pv_omxregistry.h
deleted file mode 100644
index a744a47..0000000
--- a/codecs_v2/omx/omx_common/config/linux_nj/pv_omxregistry.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-
-#define REGISTER_OMX_AVC_COMPONENT 1
-
-#define REGISTER_OMX_M4V_COMPONENT 1
-
-#define REGISTER_OMX_H263_COMPONENT 1
-
-#ifndef REGISTER_OMX_WMV_COMPONENT
-#if PV_USE_VALUE_ADD
-#define REGISTER_OMX_WMV_COMPONENT 1
-#else
-#define REGISTER_OMX_WMV_COMPONENT 0
-#endif
-#endif
-
-#define REGISTER_OMX_AAC_COMPONENT 1
-
-#define REGISTER_OMX_AMR_COMPONENT 1
-
-#define REGISTER_OMX_MP3_COMPONENT 1
diff --git a/codecs_v2/omx/omx_common/include/pv_omx_shared_lib_interface.h b/codecs_v2/omx/omx_common/include/pv_omx_shared_lib_interface.h
deleted file mode 100644
index c7038b2..0000000
--- a/codecs_v2/omx/omx_common/include/pv_omx_shared_lib_interface.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_OMX_SHARED_LIB_INTERFACE_H_INCLUDED
-#define PV_OMX_SHARED_LIB_INTERFACE_H_INCLUDED
-
-#define PV_OMX_SHARED_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x67)
-#define PV_OMX_CREATE_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x68)
-#define PV_OMX_DESTROY_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x69)
-
-class OmxSharedLibraryInterface
-{
-    public:
-        virtual OsclAny* QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId) = 0;
-};
-
-#endif // PV_OMX_SHARED_LIB_INTERFACE_H_INCLUDED
diff --git a/codecs_v2/omx/omx_common/include/pv_omxcore.h b/codecs_v2/omx/omx_common/include/pv_omxcore.h
old mode 100755
new mode 100644
index 91242b0..4b35a05
--- a/codecs_v2/omx/omx_common/include/pv_omxcore.h
+++ b/codecs_v2/omx/omx_common/include/pv_omxcore.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,12 +26,83 @@
 #include "pv_omx_queue.h"
 #endif
 
+#ifndef OMX_Types_h
+#include "omx_types.h"
+#endif
+
+#ifndef OSCL_BASE_INCLUDED_H
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_UUID_H_INCLUDED
+#include "oscl_uuid.h"
+#endif
+
+
 #ifndef OMX_Core_h
 #include "omx_core.h"
 #endif
 
-#ifndef PV_OMXWRAPPERBASE_H_INCLUDED
-#include "pv_omxwrapperbase.h"
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#if PROXY_INTERFACE
+#ifndef OMX_PROXY_INTERFACE_H_INCLUDED
+#include "omx_proxy_interface.h"
+#endif
+#endif
+
+#ifndef USE_CML2_CONFIG
+
+
+#ifdef ANDROID
+
+// NOTE: if at least one component uses dynamic loading,
+// USE_DYNAMIC_LOAD_OMX_COMPONENT needs to be 1
+#define USE_DYNAMIC_LOAD_OMX_COMPONENTS 0
+
+#define DYNAMIC_LOAD_OMX_AVC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_M4V_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_H263_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_WMV_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AAC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AMR_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_MP3_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_WMA_COMPONENT 0
+
+#define DYNAMIC_LOAD_OMX_AMRENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_M4VENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_H263ENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AVCENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AACENC_COMPONENT 0
+
+#else
+
+#define USE_DYNAMIC_LOAD_OMX_COMPONENTS 0
+
+#define DYNAMIC_LOAD_OMX_AVC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_M4V_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_H263_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_WMV_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AAC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AMR_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_MP3_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_WMA_COMPONENT 0
+
+#define DYNAMIC_LOAD_OMX_AMRENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_M4VENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_H263ENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AVCENC_COMPONENT 0
+#define DYNAMIC_LOAD_OMX_AACENC_COMPONENT 0
+
+#endif
+#endif
+
+#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
 #endif
 
 #ifdef __cplusplus
@@ -39,32 +110,74 @@
 {
 #endif
 
-    OMX_API OMX_ERRORTYPE PVOMX_GetComponentsOfRole(
+    OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetComponentsOfRole(
         OMX_IN		OMX_STRING role,
         OMX_INOUT	OMX_U32	*pNumComps,
         OMX_INOUT	OMX_U8	**compNames);
 
-    OMX_API OMX_ERRORTYPE OMX_APIENTRY PVOMX_ComponentNameEnum(
+    OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
         OMX_OUT OMX_STRING cComponentName,
         OMX_IN  OMX_U32 nNameLength,
         OMX_IN  OMX_U32 nIndex);
 
-    OMX_API OMX_ERRORTYPE OMX_APIENTRY PVOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
+    OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
 
-    OMX_API OMX_ERRORTYPE OMX_APIENTRY PVOMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
+    OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
             OMX_IN  OMX_STRING cComponentName,
             OMX_IN  OMX_PTR pAppData,
             OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
 
-    OMX_API OMX_ERRORTYPE PVOMX_GetRolesOfComponent(
+    OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetRolesOfComponent(
         OMX_IN      OMX_STRING compName,
         OMX_INOUT   OMX_U32* pNumRoles,
         OMX_OUT     OMX_U8** roles);
 
+    OSCL_IMPORT_REF  OMX_ERRORTYPE OMX_SetupTunnel(
+        OMX_IN  OMX_HANDLETYPE hOutput,
+        OMX_IN  OMX_U32 nPortOutput,
+        OMX_IN  OMX_HANDLETYPE hInput,
+        OMX_IN  OMX_U32 nPortInput);
+
+    OSCL_IMPORT_REF OMX_ERRORTYPE   OMX_GetContentPipe(
+        OMX_OUT  OMX_HANDLETYPE *hPipe,
+        OMX_IN   OMX_STRING szURI);
+
+
+
 #ifdef __cplusplus
 }
 #endif
 
+
+
+#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
+//Dynamic loading interface definitions
+#define PV_OMX_SHARED_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x67)
+#define PV_OMX_CREATE_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x68)
+#define PV_OMX_DESTROY_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x69)
+#define PV_OMX_AVCDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6a)
+#define PV_OMX_M4VDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6b)
+#define PV_OMX_H263DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6c)
+#define PV_OMX_WMVDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6d)
+#define PV_OMX_AACDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6e)
+#define PV_OMX_AMRDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6f)
+#define PV_OMX_MP3DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x70)
+#define PV_OMX_WMADEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x71)
+#define PV_OMX_AVCENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x72)
+#define PV_OMX_M4VENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x73)
+#define PV_OMX_H263ENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x74)
+#define PV_OMX_AMRENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x75)
+#define PV_OMX_AACENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x76)
+
+#define OMX_MAX_LIB_PATH 256
+
+class OmxSharedLibraryInterface
+{
+    public:
+        virtual OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId) = 0;
+};
+#endif // USE_DYNAMIC_LOAD_OMX_COMPONENTS
+
 class ComponentRegistrationType
 {
     public:
@@ -72,28 +185,24 @@
         OMX_STRING		ComponentName;
         OMX_STRING		RoleString;
         // pointer to factory function to be called when component needs to be instantiated
-        OMX_ERRORTYPE(*FunctionPtrCreateComponent)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
+        OMX_ERRORTYPE(*FunctionPtrCreateComponent)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData,
+                OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
         // pointer to function that destroys the component and its AO
-        OMX_ERRORTYPE(*FunctionPtrDestroyComponent)(OMX_IN OMX_HANDLETYPE pHandle);
+        OMX_ERRORTYPE(*FunctionPtrDestroyComponent)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
         //This function will return the role string
         void GetRolesOfComponent(OMX_STRING* aRole_string)
         {
             *aRole_string = RoleString;
         }
 
+        // for dynamic loading
+        OMX_STRING             SharedLibraryName;
+        OMX_PTR                SharedLibraryPtr;
+        OMX_PTR                SharedLibraryOsclUuid;
+        OMX_U32                SharedLibraryRefCounter;
+
 };
 
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentGetHandle(
-    OMX_OUT OMX_HANDLETYPE* pHandle,
-    OMX_IN  OMX_STRING cComponentName, OMX_IN  OMX_PTR pAppData,
-    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentFreeHandle(
-    OMX_IN OMX_HANDLETYPE hComponent);
-
-
-
 typedef struct CoreDescriptorType
 {
     QueueType* pMessageQueue; // The output queue for the messages to be send to the components
@@ -117,38 +226,59 @@
     OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
     OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
     OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
+    OMX_BOOL iOMXComponentSupportsPartialFrames;
+    OMX_BOOL iOMXComponentNeedsNALStartCode;
+    OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
 
 } PV_OMXComponentCapabilityFlagsType;
 
-
-typedef class PV_OMX_Wrapper
-            : public PV_OMX_WrapperBase
+class OMXGlobalData
 {
     public:
-        PV_OMX_Wrapper();
-        static PV_OMX_WrapperBase *New();
-        void Delete();
-        ~PV_OMX_Wrapper() {};
+        OMXGlobalData()
+                : iInstanceCount(1),
+                iOsclInit(false),
+                iNumBaseInstance(0),
+                iComponentIndex(0)
+        {
+            for (OMX_S32 ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+            {
+                ipInstantiatedComponentReg[ii] = NULL;
+            }
+        }
 
-        tpOMX_Init GetpOMX_Init();
+        uint32 iInstanceCount;
 
-        tpOMX_Deinit GetpOMX_Deinit();
+        bool iOsclInit; //did we do OsclInit in OMX_Init?  if so we must cleanup in OMX_Deinit.
 
-        tpOMX_ComponentNameEnum GetpOMX_ComponentNameEnum();
 
-        tpOMX_GetHandle GetpOMX_GetHandle();
+        //Number of base instances
+        OMX_U32 iNumBaseInstance;
 
-        tpOMX_FreeHandle GetpOMX_FreeHandle();
+        // Array to store component handles for future recognition of components etc.
+        OMX_HANDLETYPE iComponentHandle[MAX_INSTANTIATED_COMPONENTS];
+        OMX_U32 iComponentIndex;
 
-        tpOMX_GetComponentsOfRole GetpOMX_GetComponentsOfRole();
+        // Array of supported component types (e.g. MP4, AVC, AAC, etc.)
+        // they need to be registered
+        // For each OMX Component type (e.g. Mp3, AVC, AAC) there is one entry in this table that contains info
+        // such as component type, factory, destructor functions, library name for dynamic loading etc.
+        // when the omx component is registered (at OMX_Init)
+        ComponentRegistrationType* ipRegTemplateList[MAX_SUPPORTED_COMPONENTS];
 
-        tpOMX_GetRolesOfComponent GetpOMX_GetRolesOfComponent();
 
-        tpOMX_SetupTunnel GetpOMX_SetupTunnel();
+        // Array of pointers - For each OMX component that gets instantiated - the pointer to its registry structure
+        // is saved here. This information is needed when the component is to be destroyed
 
-        tpOMX_GetContentPipe GetpOMX_GetContentPipe();
+        ComponentRegistrationType* ipInstantiatedComponentReg[MAX_INSTANTIATED_COMPONENTS];
+        // array of function pointers. For each component, a destructor function is assigned
+        //OMX_ERRORTYPE(*ComponentDestructor[MAX_INSTANTIATED_COMPONENTS])(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
 
-} PV_OMX_Wrapper;
+#if PROXY_INTERFACE
+        ProxyApplication_OMX* ipProxyTerm[MAX_INSTANTIATED_COMPONENTS];
+#endif
+
+};
 
 
 #endif
diff --git a/codecs_v2/omx/omx_common/include/pv_omxdefs.h b/codecs_v2/omx/omx_common/include/pv_omxdefs.h
index b0595d2..5dedb99 100644
--- a/codecs_v2/omx/omx_common/include/pv_omxdefs.h
+++ b/codecs_v2/omx/omx_common/include/pv_omxdefs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,11 @@
 #define PV_OMXDEFS_H_INCLUDED
 
 /** Maximum number of base_component component instances */
-#define MAX_SUPPORTED_COMPONENTS 10 		// e.g. 10 = PV -MP4, PV-H263, PV-AVC, PV-WMV, PV-AAC, PV-AMR, PV-MP3, ...
-#define MAX_INSTANTIATED_COMPONENTS 32
+//#define MAX_SUPPORTED_COMPONENTS 10 		// e.g. 10 = PV -MP4, PV-H263, PV-AVC, PV-WMV, PV-AAC, PV-AMR, PV-MP3, ...
+#define MAX_SUPPORTED_COMPONENTS 15 		// e.g. 10 = PV -MP4, PV-H263, PV-AVC, PV-WMV, PV-AAC, PV-AMR, PV-MP3, ...
+#define MAX_INSTANTIATED_COMPONENTS 7
+
+//#define INSERT_NAL_START_CODE
 
 // maximum length of component names
 #define PV_OMX_MAX_COMPONENT_NAME_LENGTH 128
@@ -35,11 +38,6 @@
 // 1 - Multithreaded, 0 - AO
 #define PROXY_INTERFACE 1
 
-//Enable/disable HW codec
-#ifndef HARDWARE_OMX
-#define HARDWARE_OMX 0
-#endif
-
 // The following is needed for dll linking of APIs
 #define __OMX_EXPORTS
 
@@ -49,7 +47,7 @@
 /** Defines the major version of the core */
 #define SPECVERSIONMAJOR  1
 /** Defines the minor version of the core */
-#define SPECVERSIONMINOR  1
+#define SPECVERSIONMINOR  0
 /** Defines the revision of the core */
 #define SPECREVISION      0
 /** Defines the step version of the core */
diff --git a/codecs_v2/omx/omx_common/include/pv_omxmastercore.h b/codecs_v2/omx/omx_common/include/pv_omxmastercore.h
deleted file mode 100644
index a1a85c7..0000000
--- a/codecs_v2/omx/omx_common/include/pv_omxmastercore.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_OMXMASTERCORE_H_INCLUDED
-#define PV_OMXMASTERCORE_H_INCLUDED
-
-// get definitions of omx core methods
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef PV_OMXWRAPPERBASE_H_INCLUDED
-#include "pv_omxwrapperbase.h"
-#endif
-
-OMX_ERRORTYPE OMX_APIENTRY PV_MasterOMX_Init();
-
-OMX_ERRORTYPE OMX_APIENTRY PV_MasterOMX_Deinit();
-
-OMX_API OMX_ERRORTYPE PV_MasterOMX_GetComponentsOfRole(
-    OMX_IN	OMX_STRING role,
-    OMX_INOUT	OMX_U32	*pNumComps,
-    OMX_INOUT	OMX_U8	**compNames);
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY 	PV_MasterOMX_GetHandle(
-    OMX_OUT OMX_HANDLETYPE* pHandle,
-    OMX_IN  OMX_STRING cComponentName,
-    OMX_IN  OMX_PTR pAppData,
-    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY PV_MasterOMX_FreeHandle(
-    OMX_IN OMX_HANDLETYPE hComponent);
-
-
-#endif
-
-
-
-
-
-
-
-
-
diff --git a/codecs_v2/omx/omx_common/include/pv_omxwrapperbase.h b/codecs_v2/omx/omx_common/include/pv_omxwrapperbase.h
deleted file mode 100644
index 02ebe3c..0000000
--- a/codecs_v2/omx/omx_common/include/pv_omxwrapperbase.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_OMXWRAPPERBASE_H_INCLUDED
-#define PV_OMXWRAPPERBASE_H_INCLUDED
-
-
-
-// get definitions of omx core methods
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-
-// ptrs to all omx core methods
-// will be set in the derived classes
-typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_Init)(void);
-
-typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_Deinit)(void);
-
-typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_ComponentNameEnum)(
-    OMX_OUT OMX_STRING cComponentName,
-    OMX_IN  OMX_U32 nNameLength,
-    OMX_IN  OMX_U32 nIndex);
-
-
-typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_GetHandle)(
-    OMX_OUT OMX_HANDLETYPE* pHandle,
-    OMX_IN  OMX_STRING cComponentName,
-    OMX_IN  OMX_PTR pAppData,
-    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
-
-
-typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_FreeHandle)(
-    OMX_IN  OMX_HANDLETYPE hComponent);
-
-typedef OMX_ERRORTYPE(*tpOMX_GetComponentsOfRole)(
-    OMX_IN      OMX_STRING role,
-    OMX_INOUT   OMX_U32 *pNumComps,
-    OMX_INOUT   OMX_U8  **compNames);
-
-
-typedef OMX_ERRORTYPE(*tpOMX_GetRolesOfComponent)(
-    OMX_IN      OMX_STRING compName,
-    OMX_INOUT   OMX_U32 *pNumRoles,
-    OMX_OUT     OMX_U8 **roles);
-
-
-typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_SetupTunnel)(
-    OMX_IN  OMX_HANDLETYPE hOutput,
-    OMX_IN  OMX_U32 nPortOutput,
-    OMX_IN  OMX_HANDLETYPE hInput,
-    OMX_IN  OMX_U32 nPortInput);
-
-
-typedef OMX_ERRORTYPE(*tpOMX_GetContentPipe)(
-    OMX_OUT OMX_HANDLETYPE *hPipe,
-    OMX_IN OMX_STRING szURI);
-
-
-typedef class PV_OMX_WrapperBase
-{
-    public:
-        PV_OMX_WrapperBase()
-        {
-            pOMX_Init = 0;
-            pOMX_Deinit = 0;
-            pOMX_ComponentNameEnum = 0;
-            pOMX_GetHandle = 0;
-            pOMX_FreeHandle = 0;
-            pOMX_GetComponentsOfRole = 0;
-            pOMX_GetRolesOfComponent = 0;
-            pOMX_SetupTunnel = 0;
-            pOMX_GetContentPipe = 0;
-        };
-
-        static PV_OMX_WrapperBase *New();
-
-        void Delete()
-        {
-            this->~PV_OMX_WrapperBase();
-            free(this);
-        };
-
-        ~PV_OMX_WrapperBase() {};
-
-        tpOMX_Init GetpOMX_Init()
-        {
-            return pOMX_Init;
-        };
-
-        tpOMX_Deinit GetpOMX_Deinit()
-        {
-            return  pOMX_Deinit;
-        };
-
-        tpOMX_ComponentNameEnum GetpOMX_ComponentNameEnum()
-        {
-            return pOMX_ComponentNameEnum;
-        };
-
-        tpOMX_GetHandle GetpOMX_GetHandle()
-        {
-            return pOMX_GetHandle;
-        };
-
-        tpOMX_FreeHandle GetpOMX_FreeHandle()
-        {
-            return pOMX_FreeHandle;
-        };
-
-        tpOMX_GetComponentsOfRole GetpOMX_GetComponentsOfRole()
-        {
-            return pOMX_GetComponentsOfRole;
-        };
-
-        tpOMX_GetRolesOfComponent GetpOMX_GetRolesOfComponent()
-        {
-            return pOMX_GetRolesOfComponent;
-        };
-
-        tpOMX_SetupTunnel GetpOMX_SetupTunnel()
-        {
-            return pOMX_SetupTunnel;
-        };
-
-        tpOMX_GetContentPipe GetpOMX_GetContentPipe()
-        {
-            return pOMX_GetContentPipe;
-        };
-
-
-        // ptrs to all omx core methods
-        // will be set in the derived classes
-        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_Init)(void);
-
-        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_Deinit)(void);
-
-        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_ComponentNameEnum)(
-            OMX_OUT OMX_STRING cComponentName,
-            OMX_IN  OMX_U32 nNameLength,
-            OMX_IN  OMX_U32 nIndex);
-
-
-        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_GetHandle)(
-            OMX_OUT OMX_HANDLETYPE* pHandle,
-            OMX_IN  OMX_STRING cComponentName,
-            OMX_IN  OMX_PTR pAppData,
-            OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
-
-
-        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_FreeHandle)(
-            OMX_IN  OMX_HANDLETYPE hComponent);
-
-        OMX_ERRORTYPE(*pOMX_GetComponentsOfRole)(
-            OMX_IN      OMX_STRING role,
-            OMX_INOUT   OMX_U32 *pNumComps,
-            OMX_INOUT   OMX_U8  **compNames);
-
-
-        OMX_ERRORTYPE(*pOMX_GetRolesOfComponent)(
-            OMX_IN      OMX_STRING compName,
-            OMX_INOUT   OMX_U32 *pNumRoles,
-            OMX_OUT     OMX_U8 **roles);
-
-
-        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_SetupTunnel)(
-            OMX_IN  OMX_HANDLETYPE hOutput,
-            OMX_IN  OMX_U32 nPortOutput,
-            OMX_IN  OMX_HANDLETYPE hInput,
-            OMX_IN  OMX_U32 nPortInput);
-
-
-        OMX_ERRORTYPE(*pOMX_GetContentPipe)(
-            OMX_OUT OMX_HANDLETYPE *hPipe,
-            OMX_IN OMX_STRING szURI);
-
-
-
-} PV_OMX_WrapperBase;
-#endif
-
diff --git a/codecs_v2/omx/omx_common/include/qc_omxcore.h b/codecs_v2/omx/omx_common/include/qc_omxcore.h
deleted file mode 100644
index 3a6420b..0000000
--- a/codecs_v2/omx/omx_common/include/qc_omxcore.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef QC_OMXCORE_H_INCLUDED
-#define QC_OMXCORE_H_INCLUDED
-
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef PV_OMXWRAPPERBASE_H_INCLUDED
-#include "pv_omxwrapperbase.h"
-#endif
-
-#ifndef PV_OMXDEFS_H_INCLUDED
-#include "pv_omxdefs.h"
-#endif
-
-#include <new>
-
-#if HARDWARE_OMX
-
-typedef class QC_OMX_Wrapper
-            : public PV_OMX_WrapperBase
-{
-    public:
-        QC_OMX_Wrapper();
-        static PV_OMX_WrapperBase *New();
-        void Delete();
-        ~QC_OMX_Wrapper() {};
-
-        tpOMX_Init GetpOMX_Init();
-
-        tpOMX_Deinit GetpOMX_Deinit();
-
-        tpOMX_ComponentNameEnum GetpOMX_ComponentNameEnum();
-
-        tpOMX_GetHandle GetpOMX_GetHandle();
-
-        tpOMX_FreeHandle GetpOMX_FreeHandle();
-
-        tpOMX_GetComponentsOfRole GetpOMX_GetComponentsOfRole();
-
-        tpOMX_GetRolesOfComponent GetpOMX_GetRolesOfComponent();
-
-        tpOMX_SetupTunnel GetpOMX_SetupTunnel();
-
-        tpOMX_GetContentPipe GetpOMX_GetContentPipe();
-
-} QC_OMX_Wrapper;
-#endif // HARDWARE_OMX
-
-#endif
diff --git a/codecs_v2/omx/omx_common/src/pv_omxcore.cpp b/codecs_v2/omx/omx_common/src/pv_omxcore.cpp
old mode 100755
new mode 100644
index 6f6137f..2ba8d0f
--- a/codecs_v2/omx/omx_common/src/pv_omxcore.cpp
+++ b/codecs_v2/omx/omx_common/src/pv_omxcore.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,278 +15,736 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
 
+#ifndef PV_OMXDEFS_H_INCLUDED
 #include "pv_omxdefs.h"
+#endif
+
+#ifndef OMX_Component_h
 #include "omx_component.h"
+#endif
+
+#ifndef PV_OMXCORE_H_INCLUDED
 #include "pv_omxcore.h"
+#endif
+
+#ifndef OSCL_MEM_BASIC_FUNCTIONS_H
+#include "oscl_mem_basic_functions.h"
+#endif
+
+#ifndef OSCL_STDSTRING_H_INCLUDED
+#include "oscl_stdstring.h"
+#endif
+
+#ifndef OSCL_ERROR_H_INCLUDED
+#include "oscl_error.h"
+#endif
+
+#ifndef OSCL_INIT_H_INCLUDED
+#include "oscl_init.h"
+#endif
+
+// pv_omxregistry.h is only needed if NOT using CML2
+#ifndef USE_CML2_CONFIG
 #include "pv_omxregistry.h"
+#endif
 
-//Number of base instances
-OMX_U32 NumBaseInstance = 0;
-OMX_U32 g_ComponentIndex = 0;
-// varaible that counts the number of instances for which OMX init is called
-OMX_U32 NumOMXInitInstances = 0;
-// Array of supported component types (e.g. MP4, AVC, AAC, etc.)
-// they need to be registered
-ComponentRegistrationType *pRegTemplateList[MAX_SUPPORTED_COMPONENTS] = {NULL};
+#include "oscl_init.h"
 
-#if PROXY_INTERFACE
-
-#include "omx_proxy_interface.h"
-extern OsclThreadLock ThreadLock;
-ProxyApplication_OMX* pProxyTerm[MAX_INSTANTIATED_COMPONENTS] = {NULL};
-
-#endif //PROXY_INTERFACE
-
-
-
-/* Array to store component handles for future recognition of components etc.*/
-OMX_HANDLETYPE ComponentHandle[MAX_INSTANTIATED_COMPONENTS] = {NULL};
-// array of function pointers. For each component, a destructor function is assigned
-OMX_ERRORTYPE(*ComponentDestructor[MAX_INSTANTIATED_COMPONENTS])(OMX_IN OMX_HANDLETYPE pHandle) = {NULL};
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
 
 #if REGISTER_OMX_M4V_COMPONENT
-#ifndef OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-#include "omx_m4v_component_interface.h"
-#endif
-OMX_ERRORTYPE Mpeg4Register(ComponentRegistrationType **);
+OMX_ERRORTYPE Mpeg4Register();
 #endif
 
 #if REGISTER_OMX_H263_COMPONENT
-#ifndef OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-#include "omx_m4v_component_interface.h"
-#endif
-OMX_ERRORTYPE H263Register(ComponentRegistrationType **);
+OMX_ERRORTYPE H263Register();
 #endif
 
 #if REGISTER_OMX_AVC_COMPONENT
-OMX_ERRORTYPE AvcRegister(ComponentRegistrationType **);
+OMX_ERRORTYPE AvcRegister();
 #endif
 
 #if REGISTER_OMX_WMV_COMPONENT
-#include "omx_wmv_component_interface.h"
-OMX_ERRORTYPE WmvRegister(ComponentRegistrationType **);
+OMX_ERRORTYPE WmvRegister();
 #endif
 
 #if REGISTER_OMX_AAC_COMPONENT
-OMX_ERRORTYPE AacRegister(ComponentRegistrationType **);
+OMX_ERRORTYPE AacRegister();
 #endif
 
 #if REGISTER_OMX_AMR_COMPONENT
-OMX_ERRORTYPE AmrRegister(ComponentRegistrationType **);
+OMX_ERRORTYPE AmrRegister();
 #endif
 
 #if REGISTER_OMX_MP3_COMPONENT
-OMX_ERRORTYPE Mp3Register(ComponentRegistrationType **);
+OMX_ERRORTYPE Mp3Register();
 #endif
 
+#if REGISTER_OMX_WMA_COMPONENT
+OMX_ERRORTYPE WmaRegister();
+#endif
+
+#if REGISTER_OMX_AMRENC_COMPONENT
+OMX_ERRORTYPE AmrEncRegister();
+#endif
+
+#if REGISTER_OMX_M4VENC_COMPONENT
+OMX_ERRORTYPE Mpeg4EncRegister();
+#endif
+
+#if REGISTER_OMX_H263ENC_COMPONENT
+OMX_ERRORTYPE H263EncRegister();
+#endif
+
+#if REGISTER_OMX_AVCENC_COMPONENT
+OMX_ERRORTYPE AvcEncRegister();
+#endif
+
+#if REGISTER_OMX_AACENC_COMPONENT
+OMX_ERRORTYPE AacEncRegister();
+#endif
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
 /* Initializes the component */
-OMX_ERRORTYPE PVOMX_Init()
+static OMX_ERRORTYPE _OMX_Init()
 {
     OMX_ERRORTYPE Status = OMX_ErrorNone;
-    OMX_U32 ii;
-    NumOMXInitInstances ++;
-
-    if (NumOMXInitInstances == 1)
+    int32 error;
+    //get global data structure
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (error) // can't access registry
     {
-        /* Initialize template list to NULL at the beginning */
-        for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-        {
-            pRegTemplateList[ii] = NULL;
-        }
+        return OMX_ErrorInsufficientResources;
+    }
+    else if (!data) // singleton object has been destroyed
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        return OMX_ErrorInsufficientResources;
+    }
 
-        for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-        {
-            ComponentHandle[ii] = NULL;
-            ComponentDestructor[ii] = NULL;
 #if PROXY_INTERFACE
-            pProxyTerm[ii] = NULL;
+    ProxyApplication_OMX** pProxyTerm = data->ipProxyTerm;
 #endif
-        }
+    OMX_U32 ii;
 
-        // REGISTER COMPONENT TYPES (ONE BY ONE)
+    /* Initialize template list to NULL at the beginning */
+    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
+    {
+        data->ipRegTemplateList[ii] = NULL;
+    }
+
+    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+    {
+        data->iComponentHandle[ii] = NULL;
+        data->ipInstantiatedComponentReg[ii] = NULL;
+#if PROXY_INTERFACE
+        pProxyTerm[ii] = NULL;
+#endif
+    }
+
+    //Release the singleton.
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    if (error)
+    {
+        //registry error
+        Status = OMX_ErrorUndefined;
+        return Status;
+    }
+
+    // REGISTER COMPONENT TYPES (ONE BY ONE)
 #if REGISTER_OMX_M4V_COMPONENT
-        // MPEG4
-        Status = Mpeg4Register(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    // MPEG4
+    Status = Mpeg4Register();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
 
 #if REGISTER_OMX_H263_COMPONENT
-        //H263
-        Status = H263Register(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    //H263
+    Status = H263Register();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
 
 #if REGISTER_OMX_AVC_COMPONENT
-        // AVC
-        Status = AvcRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    // AVC
+    Status = AvcRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
 
 #if REGISTER_OMX_WMV_COMPONENT
-        // WMV
-        Status = WmvRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    // WMV
+    Status = WmvRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
 
 #if REGISTER_OMX_AAC_COMPONENT
-        // AAC
-        Status = AacRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    // AAC
+    Status = AacRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
 
 #if REGISTER_OMX_AMR_COMPONENT
-        // AMR
-        Status = AmrRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    // AMR
+    Status = AmrRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
 
 #if REGISTER_OMX_MP3_COMPONENT
-        // MP3
-        Status = Mp3Register(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
+    // MP3
+    Status = Mp3Register();
+    if (Status != OMX_ErrorNone)
+        return Status;
 #endif
-    }
+
+#if REGISTER_OMX_WMA_COMPONENT
+    // WMA
+    Status = WmaRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
+#endif
+
+#if REGISTER_OMX_AMRENC_COMPONENT
+    //AMR ENCODER
+    Status = AmrEncRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
+#endif
+
+#if REGISTER_OMX_M4VENC_COMPONENT
+    //MPEG4 Encoder
+    Status = Mpeg4EncRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
+#endif
+
+#if REGISTER_OMX_H263ENC_COMPONENT
+    //H263 Encoder
+    Status = H263EncRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
+#endif
+#if REGISTER_OMX_AVCENC_COMPONENT
+    //H264/AVC Encoder
+    Status = AvcEncRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
+#endif
+
+#if REGISTER_OMX_AACENC_COMPONENT
+    //AAC Encoder
+    Status = AacEncRegister();
+    if (Status != OMX_ErrorNone)
+        return Status;
+#endif
+
     return OMX_ErrorNone;
 }
 
+//this routine is needed to avoid a longjmp clobber warning
+static void _Try_OMX_Init(int32& aError, OMX_ERRORTYPE& aStatus)
+{
+    OSCL_TRY(aError, aStatus = _OMX_Init(););
+}
+//this routine is needed to avoid a longjmp clobber warning
+static void _Try_OMX_Create(int32& aError, OMXGlobalData*& aData)
+{
+    OSCL_TRY(aError, aData = OSCL_NEW(OMXGlobalData, ()););
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_Init()
+{
+    OMX_ERRORTYPE status = OMX_ErrorNone;
+
+    //Check the global instance counter and only init OMX on the first call.
+    bool osclInit = false;
+    int32 error;
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+
+    //Check for whether Oscl is initialized in this thread.  If not, we will
+    //initialize it here.
+    if (error == EPVErrorBaseNotInstalled)
+    {
+        //init all Oscl layers except Oscl scheduler.
+        OsclSelect select;
+        select.iOsclScheduler = false;
+        OsclInit::Init(error, &select);
+        if (error)
+        {
+            status = OMX_ErrorUndefined;//can't init Oscl
+            return status;
+        }
+        else
+        {
+            osclInit = true;
+        }
+    }
+
+    if (data)
+    {
+        //Just update the instance counter.
+        data->iInstanceCount++;
+
+        //Release the singleton.
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        if (error)
+        {
+            status = OMX_ErrorUndefined;
+            return status;
+        }
+    }
+    else
+    {
+        //First call--
+        //create the OMX singleton
+        _Try_OMX_Create(error, data);
+        if (error != OsclErrNone)
+        {
+            status = OMX_ErrorInsufficientResources;//some leave happened.
+        }
+
+        //Release the singleton.
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        if (error)
+        {
+            //registry error
+            status = OMX_ErrorUndefined;
+            return status;
+        }
+
+        //If create succeeded, then init the OMX globals.
+        if (status == OMX_ErrorNone)
+        {
+            _Try_OMX_Init(error, status);
+            if (error != OsclErrNone)
+            {
+                status = OMX_ErrorUndefined;//probably no memory.
+            }
+            else
+            {
+                //keep track of whether we did Oscl init internally,
+                //so we can cleanup later.
+                data->iOsclInit = osclInit;
+            }
+        }
+    }
+
+    if (error && status == OMX_ErrorNone)
+        status = OMX_ErrorUndefined;//registry error
+
+    return status;
+}
+
 
 
 /* De-initializes the component*/
-OMX_ERRORTYPE PVOMX_Deinit()
+static OMX_ERRORTYPE _OMX_Deinit(OMXGlobalData* data)
 {
     OMX_S32 ii;
-    NumOMXInitInstances--;
-    if (NumOMXInitInstances == 0)
+#if PROXY_INTERFACE
+    ProxyApplication_OMX** pProxyTerm = data->ipProxyTerm;
+#endif
+    OMX_HANDLETYPE* componentHandle = data->iComponentHandle;
+
+
+    // go through all component instnaces and delete leftovers if necessary
+    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
     {
 
-        // go through all component instnaces and delete leftovers if necessary
-        for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+#if PROXY_INTERFACE
+        if (pProxyTerm[ii])
+        {
+            // delete leftover components
+            // call the OMX_FreeHandle through the proxy
+            if ((componentHandle[ii] != NULL) && (data->ipInstantiatedComponentReg[ii] != NULL))
+                pProxyTerm[ii]->ProxyFreeHandle(componentHandle[ii]);
+
+            // exit thread
+            pProxyTerm[ii]->Exit();
+            delete pProxyTerm[ii];
+            // delete array entries associated with pProxyTerm and Component handle
+            pProxyTerm[ii] = NULL;
+            componentHandle[ii] = NULL;
+            data->ipInstantiatedComponentReg[ii] = NULL;
+        }
+#else
+        if ((componentHandle[ii] != NULL) && (data->ipInstantiatedComponentReg[ii] != NULL))
         {
 
-#if PROXY_INTERFACE
-            if (pProxyTerm[ii])
-            {
-                // delete leftover components
-                // call the OMX_FreeHandle through the proxy
-                if ((ComponentHandle[ii] != NULL) && (ComponentDestructor[ii] != NULL))
-                    pProxyTerm[ii]->ProxyFreeHandle(ComponentHandle[ii]);
-
-                // exit thread
-                pProxyTerm[ii]->Exit();
-                delete pProxyTerm[ii];
-                // delete array entries associated with pProxyTerm and Component handle
-                pProxyTerm[ii] = NULL;
-                ComponentHandle[ii] = NULL;
-                ComponentDestructor[ii] = NULL;
-            }
-#else
-            if ((ComponentHandle[ii] != NULL) && (ComponentDestructor[ii] != NULL))
-            {
-
-                // call destructor with the corresponding handle as argument
-                ComponentDestructor[ii](ComponentHandle[ii]);
-            }
-
-            ComponentHandle[ii] = NULL;
-            ComponentDestructor[ii] = NULL;
-#endif
+            // call destructor with the corresponding handle as argument
+            OMX_PTR &aOmxLib = data->ipInstantiatedComponentReg[ii]->SharedLibraryPtr;
+            OMX_PTR aOsclUuid = data->ipInstantiatedComponentReg[ii]->SharedLibraryOsclUuid;
+            OMX_U32 &aRefCount = data->ipInstantiatedComponentReg[ii]->SharedLibraryRefCounter;
+            (data->ipInstantiatedComponentReg[ii]->FunctionPtrDestroyComponent)(componentHandle[ii], aOmxLib, aOsclUuid, aRefCount);
         }
 
-        //Finally de-register all the components
-        for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-        {
+        componentHandle[ii] = NULL;
+        data->ipInstantiatedComponentReg[ii] = NULL;
+#endif
+    }
 
-            if (pRegTemplateList[ii])
+    //Finally de-register all the components
+    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
+    {
+
+        if (data->ipRegTemplateList[ii])
+        {
+            if (data->ipRegTemplateList[ii]->SharedLibraryOsclUuid)
             {
-                oscl_free(pRegTemplateList[ii]);
-                pRegTemplateList[ii] = NULL;
+                oscl_free(data->ipRegTemplateList[ii]->SharedLibraryOsclUuid);
+                data->ipRegTemplateList[ii]->SharedLibraryOsclUuid = NULL;
+            }
+#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
+            if (data->ipRegTemplateList[ii]->SharedLibraryPtr)
+            {
+                OsclSharedLibrary *lib = (OsclSharedLibrary *)(data->ipRegTemplateList[ii]->SharedLibraryPtr);
+                lib->Close();
+                OSCL_DELETE(lib);
+                data->ipRegTemplateList[ii]->SharedLibraryPtr = NULL;
+            }
+#endif
+            oscl_free(data->ipRegTemplateList[ii]);
+            data->ipRegTemplateList[ii] = NULL;
+        }
+        else
+        {
+            break;
+        }
+    }
+
+    return OMX_ErrorNone;
+}
+
+//this routine is needed to avoid a longjmp clobber warning.
+static void _Try_OMX_Deinit(int32 &aError, OMX_ERRORTYPE& aStatus, OMXGlobalData* data)
+{
+    OSCL_TRY(aError, aStatus = _OMX_Deinit(data););
+}
+
+//this routine is needed to avoid a longjmp clobber warning.
+static void _Try_Data_Cleanup(int32 &aError, OMXGlobalData* aData)
+{
+    OSCL_TRY(aError, OSCL_DELETE(aData););
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_Deinit()
+{
+    OMX_ERRORTYPE status = OMX_ErrorNone;
+
+    //Check the global instance counter and only cleanup OMX on the last call.
+    bool osclInit = false;
+    int32 error;
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (data)
+    {
+        data->iInstanceCount--;
+        if (data->iInstanceCount == 0)
+        {
+            //save the "OsclInit" flag to decide whether to cleanup Oscl later.
+            osclInit = data->iOsclInit;
+
+            //Cleanup the OMX globals.
+            _Try_OMX_Deinit(error, status, data);
+            if (error != OsclErrNone)
+                status = OMX_ErrorUndefined;//some leave happened.
+
+            //Regardless of the cleanup result, cleanup the OMX singleton.
+            _Try_Data_Cleanup(error, data);
+            data = NULL;
+            if (error != OsclErrNone)
+                status = OMX_ErrorUndefined;//some leave happened.
+
+        }
+    }
+
+    //Release the singleton.
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+
+    //If this is the last call and we initialized Oscl in OMX_Init,
+    //then clean it up here.
+    if (osclInit)
+    {
+        //cleanup all layers except Oscl scheduler.
+        OsclSelect select;
+        select.iOsclScheduler = false;
+        OsclInit::Cleanup(error, &select);
+        //ignore errors here.
+    }
+
+    return status;
+}
+
+#if PROXY_INTERFACE
+static void _Cleanup_Component(ProxyApplication_OMX* aProxyTerm, OMX_OUT OMX_HANDLETYPE aHandle,
+                               OMX_STRING cComponentName)
+{
+    if (aProxyTerm)
+    {
+        aProxyTerm->Exit();
+        delete aProxyTerm;
+    }
+
+    if (!aHandle)
+    {
+        return;
+    }
+
+    //find the component destructor and call it
+    OMX_S32 ii;
+    int32 error;
+
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+
+    if (error || !data)
+    {
+        return;
+    }
+
+    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
+    {
+        // go through the list of supported components and find the component based on its name (identifier)
+        if (data->ipRegTemplateList[ii] != NULL)
+        {
+            if (!oscl_strcmp((data->ipRegTemplateList[ii])->ComponentName, cComponentName))
+            {
+                // found a matching name. Use this destructor
+                OMX_PTR &aOmxLib = data->ipRegTemplateList[ii]->SharedLibraryPtr;
+                OMX_PTR aOsclUuid = data->ipRegTemplateList[ii]->SharedLibraryOsclUuid;
+                OMX_U32 &aRefCount = data->ipRegTemplateList[ii]->SharedLibraryRefCounter;
+                (data->ipRegTemplateList[ii]->FunctionPtrDestroyComponent)(aHandle, aOmxLib, aOsclUuid, aRefCount);
+                break;
+            }
+        }
+        else
+        {
+            break;
+        }
+    }
+
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+}
+#endif
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
+        OMX_IN  OMX_STRING cComponentName,
+        OMX_IN  OMX_PTR pAppData,
+        OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
+{
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    int32 error;
+
+#if PROXY_INTERFACE
+    ProxyApplication_OMX* pTempProxyTerm = new ProxyApplication_OMX;
+
+    if (pTempProxyTerm->GetMemPoolPtr() == NULL)
+    {
+        _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
+        ErrorType = OMX_ErrorInsufficientResources;
+        return ErrorType;
+    }
+    pTempProxyTerm->Start();
+
+    ErrorType = pTempProxyTerm->ProxyGetHandle(pHandle, cComponentName, pAppData, pCallBacks);
+
+    //Get registry to store values
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (error) // can't access registry
+    {
+        _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
+        return OMX_ErrorInvalidState;
+    }
+    else if (!data) // singleton object has been destroyed
+    {
+        // Unlock registry before calling cleanup otherwise it'll lead to deadlock.
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
+        return OMX_ErrorInvalidState;
+    }
+
+    OMX_U32* componentIndex = &(data->iComponentIndex);
+    OMX_HANDLETYPE* componentHandle = data->iComponentHandle;
+
+    // First, find an empty slot in the proxy/component handle array to store the component/proxy handle
+    OMX_U32 jj;
+    for (jj = 0; jj < MAX_INSTANTIATED_COMPONENTS; jj++)
+    {
+        if (componentHandle[jj] == NULL)
+            break;
+    }
+    // can't find a free slot
+    if (jj == MAX_INSTANTIATED_COMPONENTS)
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
+        ErrorType = OMX_ErrorInsufficientResources;
+        return ErrorType;
+    }
+    else
+    {
+        *componentIndex = jj;
+    }
+
+    ProxyApplication_OMX** pProxyTerm = data->ipProxyTerm;
+
+    pProxyTerm[*componentIndex] = pTempProxyTerm;
+
+    if (*pHandle)
+    {
+        // now that we got the component handle, store the handle in the componentHandle array
+        componentHandle[*componentIndex] = *pHandle;
+
+        // record the component destructor function ptr;
+        OMX_S32 ii;
+        OMX_U8 componentFoundflag = false;
+
+        for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
+        {
+            // go through the list of supported components and find the component based on its name (identifier)
+            if (data->ipRegTemplateList[ii] != NULL)
+            {
+                if (!oscl_strcmp((data->ipRegTemplateList[ii])->ComponentName, cComponentName))
+                {
+                    // found a matching name
+                    componentFoundflag = true;
+                    // save the Registry Ptr into the array of instantiated components
+                    data->ipInstantiatedComponentReg[*componentIndex] = data->ipRegTemplateList[ii];
+                    break;
+                }
             }
             else
             {
                 break;
             }
         }
+
+        if (!componentFoundflag)
+        {
+            OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+            _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
+
+            pProxyTerm[*componentIndex] = NULL;
+            componentHandle[*componentIndex] = NULL;
+
+            ErrorType = OMX_ErrorComponentNotFound;
+            return ErrorType;
+        }
+
+        data->iNumBaseInstance++;
+        if (data->iNumBaseInstance > MAX_INSTANTIATED_COMPONENTS)
+        {
+            //Cleanup and unlock registry
+            OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+            _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
+
+            pProxyTerm[*componentIndex] = NULL;
+            componentHandle[*componentIndex] = NULL;
+            data->ipInstantiatedComponentReg[*componentIndex] = NULL;
+
+            ErrorType = OMX_ErrorInsufficientResources;
+            return ErrorType;
+        }
     }
-    return OMX_ErrorNone;
-}
+    else
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        _Cleanup_Component(pTempProxyTerm, *pHandle, cComponentName);
 
+        ErrorType = OMX_ErrorUndefined;
+        return ErrorType;
+    }
 
-OMX_API OMX_ERRORTYPE OMX_APIENTRY PVOMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
-        OMX_IN  OMX_STRING cComponentName,
-        OMX_IN  OMX_PTR pAppData,
-        OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
-{
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+#else
+    //Get registry to store values
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (error) // can't access registry
+    {
+        return OMX_ErrorInvalidState;
+    }
+    else if (!data) // singleton object has been destroyed
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        return OMX_ErrorInvalidState;
+    }
+
+    OMX_U32* componentIndex = &(data->iComponentIndex);
+    OMX_HANDLETYPE* componentHandle = data->iComponentHandle;
 
     // First, find an empty slot in the proxy/component handle array to store the component/proxy handle
     OMX_U32 jj;
     for (jj = 0; jj < MAX_INSTANTIATED_COMPONENTS; jj++)
     {
-        if (ComponentHandle[jj] == NULL)
+        if (componentHandle[jj] == NULL)
             break;
     }
     // can't find a free slot
     if (jj == MAX_INSTANTIATED_COMPONENTS)
     {
-        return OMX_ErrorInsufficientResources;
+        //Release the singleton.
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        ErrorType = OMX_ErrorInsufficientResources;
+        return ErrorType;
     }
     else
     {
-        g_ComponentIndex = jj;
+        *componentIndex = jj;
     }
 
-#if PROXY_INTERFACE
-
-    pProxyTerm[g_ComponentIndex] = new ProxyApplication_OMX;
-
-    if (pProxyTerm[g_ComponentIndex]->GetMemPoolPtr() == NULL)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-    pProxyTerm[g_ComponentIndex]->Start();
-
-    ErrorType = pProxyTerm[g_ComponentIndex]->ProxyGetHandle(pHandle, cComponentName, pAppData, pCallBacks);
-
-#else
-
     OMX_S32 ii;
 
     for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
     {
         // go through the list of supported components and find the component based on its name (identifier)
-        if (pRegTemplateList[ii] != NULL)
+        if (data->ipRegTemplateList[ii] != NULL)
         {
-            if (!strcmp(pRegTemplateList[ii]->ComponentName, cComponentName))
+            if (!oscl_strcmp((data->ipRegTemplateList[ii])->ComponentName, cComponentName))
             {
                 // found a matching name
                 // call the factory for the component
-                if ((pRegTemplateList[ii]->FunctionPtrCreateComponent)(pHandle, pAppData) == OMX_ErrorNone)
+                OMX_STRING aOmxLibName = data->ipRegTemplateList[ii]->SharedLibraryName;
+                OMX_PTR &aOmxLib = data->ipRegTemplateList[ii]->SharedLibraryPtr;
+                OMX_PTR aOsclUuid = data->ipRegTemplateList[ii]->SharedLibraryOsclUuid;
+                OMX_U32 &aRefCount = data->ipRegTemplateList[ii]->SharedLibraryRefCounter;
+                if ((data->ipRegTemplateList[ii]->FunctionPtrCreateComponent)(pHandle, pAppData, NULL, aOmxLibName, aOmxLib, aOsclUuid, aRefCount) == OMX_ErrorNone)
                 {
-                    // now that we got the component handle, store the handle in the ComponentHandle array
-                    ComponentHandle[g_ComponentIndex] = *pHandle;
-                    // also, record the component destructor function ptr
-                    ComponentDestructor[g_ComponentIndex] = pRegTemplateList[ii]->FunctionPtrDestroyComponent;
+                    // now that we got the component handle, store the handle in the componentHandle array
+                    componentHandle[*componentIndex] = *pHandle;
 
-                    NumBaseInstance++;
+                    // also, record the component registration info to be able to destroy it
+                    data->ipInstantiatedComponentReg[*componentIndex] = (data->ipRegTemplateList[ii]);
 
-                    if (NumBaseInstance > MAX_INSTANTIATED_COMPONENTS)
+                    data->iNumBaseInstance++;
+
+                    if (data->iNumBaseInstance > MAX_INSTANTIATED_COMPONENTS)
                     {
-                        return OMX_ErrorInsufficientResources;
+                        //cleanup
+                        ((data->ipRegTemplateList[ii])->FunctionPtrDestroyComponent)(componentHandle[*componentIndex], aOmxLib, aOsclUuid, aRefCount);
+                        componentHandle[*componentIndex] = NULL;
+                        data->ipInstantiatedComponentReg[*componentIndex] = NULL;
+
+                        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+                        ErrorType = OMX_ErrorInsufficientResources;
+                        return ErrorType;
                     }
 
                     ((OMX_COMPONENTTYPE*)*pHandle)->SetCallbacks(*pHandle, pCallBacks, pAppData);
                 }
                 else
                 {
-                    return OMX_ErrorInsufficientResources;
+                    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+                    ErrorType = OMX_ErrorInsufficientResources;
+                    return ErrorType;
                 }
             }
 
@@ -298,29 +756,46 @@
 
     }
     // can't find the component after going through all of them
-    if (ComponentHandle[g_ComponentIndex] == NULL)
+    if (componentHandle[*componentIndex] == NULL)
     {
-        return OMX_ErrorComponentNotFound;
+        ErrorType =  OMX_ErrorComponentNotFound;
     }
 
 #endif
 
-    return ErrorType;
+    //Release the singleton
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    if (error)
+    {
+        //registry error
+        return OMX_ErrorInvalidState;
+    }
 
+    return ErrorType;
 }
 
 
-OMX_API OMX_ERRORTYPE OMX_APIENTRY PVOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
 {
     OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
+    int32 error;
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (error) // can't access registry
+    {
+        return OMX_ErrorInvalidState;
+    }
+    else if (!data) // singleton object has been destroyed
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        return OMX_ErrorInvalidState;
+    }
 
     OMX_S32 ii, ComponentNumber = 0;
 
     // Find the component index in the array of handles
     for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS ; ii++)
     {
-        if (hComponent == ComponentHandle[ii])
+        if (hComponent == data->iComponentHandle[ii])
         {
             ComponentNumber = ii;
             break;
@@ -329,140 +804,88 @@
 
     // cannot find the component handle
     if (ii == MAX_INSTANTIATED_COMPONENTS)
-        return OMX_ErrorInvalidComponent;
-
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        ErrorType = OMX_ErrorInvalidComponent;
+        return ErrorType;
+    }
 
 #if PROXY_INTERFACE
+    ProxyApplication_OMX* pTempProxyTerm = data->ipProxyTerm[ComponentNumber];
+
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    if (error)
+    {
+        ErrorType = OMX_ErrorUndefined;
+        return ErrorType;
+    }
     // call the OMX_FreeHandle through the proxy
-    ErrorType = pProxyTerm[ComponentNumber]->ProxyFreeHandle(hComponent);
+    ErrorType = pTempProxyTerm->ProxyFreeHandle(hComponent);
 
     // exit thread
-    pProxyTerm[ComponentNumber]->Exit();
+    pTempProxyTerm->Exit();
+
+    data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (error) // can't access registry
+    {
+        return OMX_ErrorInvalidState;
+    }
+    else if (!data) // singleton object has been destroyed
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        return OMX_ErrorInvalidState;
+    }
+
+    ProxyApplication_OMX** pProxyTerm = data->ipProxyTerm;
+
     delete pProxyTerm[ComponentNumber];
     // delete array entries associated with pProxyTerm and Component handle
     pProxyTerm[ComponentNumber] = NULL;
-    ComponentHandle[ComponentNumber] = NULL;
-    ComponentDestructor[ComponentNumber] = NULL;
+    data->iComponentHandle[ComponentNumber] = NULL;
+    data->ipInstantiatedComponentReg[ComponentNumber] = NULL;
 
 #else
 
-
     // call the component AO destructor through the function pointer
-    ErrorType = ComponentDestructor[ComponentNumber](hComponent);
+    OMX_PTR &aOmxLib = data->ipInstantiatedComponentReg[ii]->SharedLibraryPtr;
+    OMX_PTR aOsclUuid = data->ipInstantiatedComponentReg[ii]->SharedLibraryOsclUuid;
+    OMX_U32 &aRefCount = data->ipInstantiatedComponentReg[ii]->SharedLibraryRefCounter;
+    ErrorType = (data->ipInstantiatedComponentReg[ComponentNumber]->FunctionPtrDestroyComponent)(hComponent, aOmxLib, aOsclUuid, aRefCount);
 
-    ComponentHandle[ComponentNumber] = NULL;
-    ComponentDestructor[ComponentNumber] = NULL;
+    data->iComponentHandle[ComponentNumber] = NULL;
+    data->ipInstantiatedComponentReg[ComponentNumber] = NULL;
 
-    NumBaseInstance--;
+    data->iNumBaseInstance--;
 
 #endif
 
+    //Release the singleton.
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    if (error)
+    {
+        ErrorType = OMX_ErrorUndefined;
+        return ErrorType;
+    }
     return ErrorType;
 
 }
 
-#if PROXY_INTERFACE
-
-// Note that g_ComponentIndex was determined outside this function (prior to using the proxy)
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentGetHandle(
-    OMX_OUT OMX_HANDLETYPE* pHandle,
-    OMX_IN  OMX_STRING cComponentName,
-    OMX_IN  OMX_PTR pAppData,
-    OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
-{
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_S32 ii;
-
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
-    {
-
-        if (pRegTemplateList[ii] != NULL)
-        {
-            if (!oscl_strcmp(pRegTemplateList[ii]->ComponentName, cComponentName))
-            {
-                // found a matching name
-                // call the factory for the component
-                if ((pRegTemplateList[ii]->FunctionPtrCreateComponent)(pHandle, pAppData) == OMX_ErrorNone)
-                {
-                    NumBaseInstance++;
-
-                    if (NumBaseInstance > MAX_INSTANTIATED_COMPONENTS)
-                    {
-                        return OMX_ErrorInsufficientResources;
-                    }
-
-                    //Store handle to identify the corresponding proxy later on
-                    ComponentHandle[g_ComponentIndex] = *pHandle;
-
-                    // record the component destructor function ptr;
-                    ComponentDestructor[g_ComponentIndex] = pRegTemplateList[ii]->FunctionPtrDestroyComponent;
-
-                    ((OMX_COMPONENTTYPE*)*pHandle)->SetCallbacks(*pHandle, pCallBacks, pAppData);
-                }
-                else
-                {
-                    return OMX_ErrorInsufficientResources;
-                }
-            }
-
-        }
-        else
-        {
-            break;
-        }
-    }
-
-    // can't find the component after going through all of them
-    if (ComponentHandle[g_ComponentIndex] == NULL)
-    {
-        return OMX_ErrorComponentNotFound;
-    }
-
-    return ErrorType;
-}
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentFreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
-{
-
-    //ThreadLock.Lock();
-    OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)hComponent;
-    OMX_U32 ii;
-
-    // find the component index based on handle
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (pHandle == ComponentHandle[ii])
-            break;
-    }
-    // cannot find the component handle
-    if (ii == MAX_INSTANTIATED_COMPONENTS)
-        return OMX_ErrorInvalidComponent;
-
-
-    // call the component destructor through the function pointer recorder earlier
-    // using hComponent as argument
-    ComponentDestructor[ii](hComponent);
-
-
-
-    NumBaseInstance--;
-    //ThreadLock.Unlock();
-
-    return OMX_ErrorNone;
-}
-#endif
-
-
 //This is a method to be called directly under testapp thread
-OMX_API OMX_ERRORTYPE OMX_APIENTRY PVOMX_ComponentNameEnum(
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
     OMX_OUT OMX_STRING cComponentName,
     OMX_IN  OMX_U32 nNameLength,
     OMX_IN  OMX_U32 nIndex)
 {
+    int32 error;
+
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (!data)
+    {
+        return OMX_ErrorUndefined;
+    }
     OMX_U32 Index = 0;
 
-    while (pRegTemplateList[Index] != NULL)
+    while (data->ipRegTemplateList[Index] != NULL)
     {
         if (Index == nIndex)
         {
@@ -471,9 +894,9 @@
         Index++;
     }
 
-    if (pRegTemplateList[Index] != NULL)
+    if (data->ipRegTemplateList[Index] != NULL)
     {
-        strncpy(cComponentName, pRegTemplateList[Index]->ComponentName, nNameLength);
+        oscl_strncpy(cComponentName, (data->ipRegTemplateList[Index])->ComponentName, nNameLength);
     }
     else
     {
@@ -484,7 +907,7 @@
 
 }
 
-OMX_API OMX_ERRORTYPE PVOMX_SetupTunnel(
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
     OMX_IN  OMX_HANDLETYPE hOutput,
     OMX_IN  OMX_U32 nPortOutput,
     OMX_IN  OMX_HANDLETYPE hInput,
@@ -497,7 +920,9 @@
     return OMX_ErrorNotImplemented;
 }
 
-OMX_API OMX_ERRORTYPE   PVOMX_GetContentPipe(
+
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
     OMX_OUT OMX_HANDLETYPE *hPipe,
     OMX_IN OMX_STRING szURI)
 {
@@ -506,32 +931,37 @@
     return OMX_ErrorNotImplemented;
 }
 
+
 /////////////////////////////////////////////////////
 /////////////// Given a compName, find the component and then return its role(s)
 ///////////////// It's the caller's responsibility to provide enough space for the role(s)
 ////////////////////////////////////////////////////////////////////////////
-OMX_API OMX_ERRORTYPE PVOMX_GetRolesOfComponent(
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_GetRolesOfComponent(
     OMX_IN      OMX_STRING compName,
     OMX_INOUT   OMX_U32* pNumRoles,
     OMX_OUT     OMX_U8** roles)
 {
+    int32 error;
+
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (!data)
+    {
+        return OMX_ErrorUndefined;
+    }
+
     OMX_STRING RoleString = NULL;
     OMX_S32 ii;
 
     // first check if there is a component with the correct name
     for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
     {
-        if (pRegTemplateList[ii])
+        if (data->ipRegTemplateList[ii])
         {
-            if (!strcmp(pRegTemplateList[ii]->ComponentName, compName))
+            if (!oscl_strcmp(data->ipRegTemplateList[ii]->ComponentName, compName))
             {
-                pRegTemplateList[ii]->GetRolesOfComponent(&RoleString);
+                (data->ipRegTemplateList[ii])->GetRolesOfComponent(&RoleString);
                 break;
             }
-            //else
-            //{
-            //	break;
-            //}
         }
     }
 
@@ -549,7 +979,7 @@
     *pNumRoles = 1;
     if (roles != NULL)
     {
-        strcpy((OMX_STRING) roles[0], (OMX_STRING)RoleString);
+        oscl_strncpy((OMX_STRING) roles[0], (OMX_STRING)RoleString, oscl_strlen((OMX_STRING)RoleString) + 1);
     }
 
     return OMX_ErrorNone;
@@ -562,12 +992,18 @@
 //////////// so it may need to make the call twice. Once to find number of components, and 2nd time
 //////////// to find their actual names
 //////////////////////////////////////////////////////////////////////////////////
-OMX_API OMX_ERRORTYPE PVOMX_GetComponentsOfRole(
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_GetComponentsOfRole(
     OMX_IN		OMX_STRING role,
     OMX_INOUT	OMX_U32	*pNumComps,
     OMX_INOUT	OMX_U8	**compNames)
 {
+    int32 error;
 
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (!data)
+    {
+        return OMX_ErrorUndefined;
+    }
 
     OMX_U32 ii;
     OMX_STRING RoleString;
@@ -577,18 +1013,19 @@
     // go through all components and check if they support the given role
     for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
     {
-        if (pRegTemplateList[ii])
+        if (data->ipRegTemplateList[ii])
         {
             // get the component role
-            pRegTemplateList[ii]->GetRolesOfComponent(&RoleString);
+            (data->ipRegTemplateList[ii])->GetRolesOfComponent(&RoleString);
 
             // if the role matches, increment the counter and record the comp. name
-            if (!strcmp(RoleString, role))
+            if (!oscl_strcmp(RoleString, role))
             {
                 // if a placeholder for compNames is provided, copy the component name into it
                 if (compNames != NULL)
                 {
-                    strcpy((OMX_STRING) compNames[*pNumComps], pRegTemplateList[ii]->ComponentName);
+                    oscl_strncpy((OMX_STRING) compNames[*pNumComps], (data->ipRegTemplateList[ii])->ComponentName,
+                                 oscl_strlen((data->ipRegTemplateList[ii])->ComponentName) + 1);
                 }
                 // increment the counter
                 *pNumComps = (*pNumComps + 1);
@@ -600,78 +1037,3 @@
     return OMX_ErrorNone;
 
 }
-
-// WRAPPER CLASS METHODS VISIBLE FROM OUTSIDE THE LIBRARY
-
-PV_OMX_Wrapper::PV_OMX_Wrapper()
-{
-    // initialize f. ptrs
-    pOMX_Init = PVOMX_Init;
-    pOMX_Deinit = PVOMX_Deinit;
-    pOMX_ComponentNameEnum = PVOMX_ComponentNameEnum;
-    pOMX_GetHandle = PVOMX_GetHandle;
-    pOMX_FreeHandle = PVOMX_FreeHandle;
-    pOMX_GetComponentsOfRole = PVOMX_GetComponentsOfRole;
-    pOMX_GetRolesOfComponent = PVOMX_GetRolesOfComponent;
-    pOMX_SetupTunnel = PVOMX_SetupTunnel;
-    pOMX_GetContentPipe = PVOMX_GetContentPipe;
-};
-
-PV_OMX_WrapperBase *PV_OMX_Wrapper::New()
-{
-    void *tmp = malloc(sizeof(PV_OMX_Wrapper));
-    PV_OMX_WrapperBase *x = (PV_OMX_WrapperBase *) new(tmp) PV_OMX_Wrapper();
-    return x;
-}
-
-void PV_OMX_Wrapper::Delete()
-{
-
-    this->~PV_OMX_Wrapper();
-    free(this);
-}
-
-tpOMX_Init PV_OMX_Wrapper::GetpOMX_Init()
-{
-    return pOMX_Init;
-};
-
-tpOMX_Deinit PV_OMX_Wrapper::GetpOMX_Deinit()
-{
-    return pOMX_Deinit;
-};
-
-tpOMX_ComponentNameEnum PV_OMX_Wrapper::GetpOMX_ComponentNameEnum()
-{
-    return pOMX_ComponentNameEnum;
-};
-
-tpOMX_GetHandle PV_OMX_Wrapper::GetpOMX_GetHandle()
-{
-    return pOMX_GetHandle;
-};
-
-tpOMX_FreeHandle PV_OMX_Wrapper::GetpOMX_FreeHandle()
-{
-    return pOMX_FreeHandle;
-};
-
-tpOMX_GetComponentsOfRole PV_OMX_Wrapper::GetpOMX_GetComponentsOfRole()
-{
-    return pOMX_GetComponentsOfRole;
-};
-
-tpOMX_GetRolesOfComponent PV_OMX_Wrapper::GetpOMX_GetRolesOfComponent()
-{
-    return pOMX_GetRolesOfComponent;
-};
-
-tpOMX_SetupTunnel PV_OMX_Wrapper::GetpOMX_SetupTunnel()
-{
-    return pOMX_SetupTunnel;
-};
-
-tpOMX_GetContentPipe PV_OMX_Wrapper::GetpOMX_GetContentPipe()
-{
-    return pOMX_GetContentPipe;
-};
diff --git a/codecs_v2/omx/omx_common/src/pv_omxmastercore.cpp b/codecs_v2/omx/omx_common/src/pv_omxmastercore.cpp
deleted file mode 100644
index 77910b2..0000000
--- a/codecs_v2/omx/omx_common/src/pv_omxmastercore.cpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pv_omxdefs.h"
-#include "omx_component.h"
-#include "pv_omxcore.h"
-#include "pv_omxwrapperbase.h"
-
-#include "pv_omxmastercore.h"
-#include "oscl_mutex.h"
-
-#include "qc_omxcore.h"
-
-//Number of base instances
-OsclMutex g_OMX_Mutex;
-OMX_U32 g_NumMasterOMXInstances = 0;
-void *g_Wrapper = NULL;
-void *g_MasterRegistry = NULL;
-void *g_OMXCompHandles = NULL;
-OMX_U32 g_TotalNumOMXComponents = 0;
-
-typedef struct PVOMXMasterRegistryStruct
-{
-    OMX_U8 CompName[PV_OMX_MAX_COMPONENT_NAME_LENGTH];
-    OMX_U8 CompRole[PV_OMX_MAX_COMPONENT_NAME_LENGTH];
-    OMX_U32 OMXCoreIndex;
-} PVOMXMasterRegistryStruct;
-
-typedef struct PVOMXCompHandles
-{
-    OMX_HANDLETYPE handle;
-    OMX_U32 OMXCoreIndex;
-} PVOMXCompHandles;
-
-// this is the number of vendor OMX cores
-#if HARDWARE_OMX
-#define NUMBER_OF_OMX_CORES 2
-#else
-#define NUMBER_OF_OMX_CORES 1
-#endif
-
-#define MAX_NUMBER_OF_OMX_COMPONENTS 50
-
-OMX_ERRORTYPE OMX_APIENTRY  PV_MasterOMX_Init()
-{
-    OMX_ERRORTYPE Status = OMX_ErrorNone;
-    OMX_U32 jj;
-    OMX_U32 index;
-    OMX_U32 master_index = 0;
-
-    g_OMX_Mutex.Lock();
-    g_NumMasterOMXInstances++;
-
-    if (g_NumMasterOMXInstances == 1)
-    {
-
-        // array of ptrs to various cores
-        PV_OMX_WrapperBase **pWrapper = (PV_OMX_WrapperBase **)malloc(NUMBER_OF_OMX_CORES * sizeof(PV_OMX_WrapperBase *));
-        if (pWrapper == NULL)
-        {
-            g_OMX_Mutex.Unlock();
-            return OMX_ErrorInsufficientResources;
-        }
-        // set the global ptr to this array
-        g_Wrapper = (void*)pWrapper;
-
-        PVOMXMasterRegistryStruct *pOMXMasterRegistry = (PVOMXMasterRegistryStruct *)malloc(MAX_NUMBER_OF_OMX_COMPONENTS * sizeof(PVOMXMasterRegistryStruct));
-        if (pOMXMasterRegistry == NULL)
-        {
-            g_OMX_Mutex.Unlock();
-            return OMX_ErrorInsufficientResources;
-        }
-        g_MasterRegistry = (void*)pOMXMasterRegistry;
-
-        PVOMXCompHandles *pOMXCompHandles = (PVOMXCompHandles *)malloc(MAX_NUMBER_OF_OMX_COMPONENTS * sizeof(PVOMXCompHandles));
-        if (pOMXCompHandles == NULL)
-        {
-            g_OMX_Mutex.Unlock();
-            return OMX_ErrorInsufficientResources;
-        }
-        g_OMXCompHandles = (void*)pOMXCompHandles;
-        // init the array
-        memset(pOMXCompHandles, 0, MAX_NUMBER_OF_OMX_COMPONENTS*sizeof(PVOMXCompHandles));
-
-
-        // initialize pointers to omx methods for different vendor OMX cores
-
-        //pWrapper[0] = Vendor0_Wrapper::New();
-        //pWrapper[1] = Vendor1_Wrapper::New();
-
-        //NOTE: Instantiate PV as the last core
-#if HARDWARE_OMX
-        pWrapper[0] = QC_OMX_Wrapper::New();
-#endif
-        pWrapper[NUMBER_OF_OMX_CORES-1] = PV_OMX_Wrapper::New(); // initialize pointers to omx methods
-
-        // loop over all cores
-        master_index = 0;
-        OMX_STRING ComponentName = (OMX_STRING) malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
-
-        for (jj = 0; jj < NUMBER_OF_OMX_CORES; jj++)
-        {
-            // first call OMX_Init
-            Status = (*(pWrapper[jj]->GetpOMX_Init()))();
-            if (Status == OMX_ErrorNone)
-            {
-                // enumerate components to get their number etc.
-                OMX_ERRORTYPE stat = OMX_ErrorNone;
-
-                index = 0;
-                while (stat != OMX_ErrorNoMore)
-                {
-                    // clear, then get next  component name
-                    memset(ComponentName, 0, PV_OMX_MAX_COMPONENT_NAME_LENGTH*sizeof(OMX_U8));
-
-                    stat = (*(pWrapper[jj]->GetpOMX_ComponentNameEnum()))(
-                               ComponentName,
-                               PV_OMX_MAX_COMPONENT_NAME_LENGTH,
-                               index);
-                    if (stat == OMX_ErrorNoMore)
-                        break;
-
-                    // check number roles of the component
-                    OMX_U32 numRoles;
-                    numRoles = 0;
-                    stat = (*(pWrapper[jj]->GetpOMX_GetRolesOfComponent()))(
-                               ComponentName,
-                               &numRoles,
-                               NULL);
-                    if ((numRoles > 0) && (stat == OMX_ErrorNone))
-                    {
-                        // allocate space for roles of the component
-                        OMX_U32 role;
-                        OMX_U8 **ComponentRoles = (OMX_U8 **) malloc(numRoles * sizeof(OMX_U8 *));
-
-                        for (role = 0;role < numRoles; role++)
-                            ComponentRoles[role] = (OMX_U8 *) malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
-
-
-                        // get the array of strings with component roles
-                        stat = (*(pWrapper[jj]->GetpOMX_GetRolesOfComponent()))(
-                                   ComponentName,
-                                   &numRoles,
-                                   ComponentRoles);
-
-                        //register all components separately in master registry
-                        if (stat == OMX_ErrorNone)
-                        {
-                            for (role = 0;role < numRoles; role++)
-                            {
-                                strncpy((OMX_STRING)pOMXMasterRegistry[master_index].CompName, ComponentName, PV_OMX_MAX_COMPONENT_NAME_LENGTH);
-                                strncpy((OMX_STRING)pOMXMasterRegistry[master_index].CompRole, (OMX_STRING)ComponentRoles[role], PV_OMX_MAX_COMPONENT_NAME_LENGTH);
-                                pOMXMasterRegistry[master_index].OMXCoreIndex = jj;
-                                master_index++;
-                            }
-                        }
-
-                        // dealloc space for component roles
-                        for (role = 0;role < numRoles; role++)
-                            free(ComponentRoles[role]);
-
-                        free(ComponentRoles);
-
-
-                    } // done with roles of component represented by index
-
-                    index++; // get next component from the jj-th core
-
-                } // done with all components from jj-th core
-
-            } // end of if(Status==OMX_ErrorNone)
-
-        }//end of for(jj=...
-        // at this point, all cores were init, and all components registered
-
-        free(ComponentName);
-        g_TotalNumOMXComponents = master_index;
-    }
-
-    g_OMX_Mutex.Unlock();
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OMX_APIENTRY PV_MasterOMX_Deinit()
-{
-    OMX_U32 jj;
-    OMX_ERRORTYPE Status = OMX_ErrorNone;
-
-    g_OMX_Mutex.Lock();
-    g_NumMasterOMXInstances--;
-    if (g_NumMasterOMXInstances == 0)
-    {
-        //free master registry
-        g_TotalNumOMXComponents = 0;
-        PVOMXMasterRegistryStruct *pOMXMasterRegistry = (PVOMXMasterRegistryStruct *) g_MasterRegistry;
-        if (pOMXMasterRegistry)
-            free(pOMXMasterRegistry);
-        g_MasterRegistry = NULL;
-
-        PVOMXCompHandles *pOMXCompHandles = (PVOMXCompHandles *)g_OMXCompHandles;
-        if (pOMXCompHandles)
-            free(pOMXCompHandles);
-        g_OMXCompHandles = NULL;
-
-        PV_OMX_WrapperBase **pWrapper = (PV_OMX_WrapperBase **) g_Wrapper;
-        //call Deinit for each core
-        if (pWrapper)
-        {
-            for (jj = 0; jj < NUMBER_OF_OMX_CORES; jj++)
-            {
-                Status = (*(pWrapper[jj]->GetpOMX_Deinit()))();
-                pWrapper[jj]->Delete();
-            }
-
-            free(pWrapper);
-            g_Wrapper = NULL;
-        }
-
-
-    }
-    g_OMX_Mutex.Unlock();
-    return OMX_ErrorNone;
-}
-
-// look for the component
-OMX_API OMX_ERRORTYPE PV_MasterOMX_GetComponentsOfRole(
-    OMX_IN	OMX_STRING role,
-    OMX_INOUT	OMX_U32	*pNumComps,
-    OMX_INOUT	OMX_U8	**compNames)
-{
-
-    OMX_U32 ii;
-    // initialize
-    *pNumComps = 0;
-    g_OMX_Mutex.Lock();
-    PVOMXMasterRegistryStruct *pOMXMasterRegistry = (PVOMXMasterRegistryStruct *) g_MasterRegistry;
-    if (pOMXMasterRegistry == NULL)
-    {
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorNone;
-    }
-
-
-    // go through all components and check if they support the given role
-    for (ii = 0; ii < g_TotalNumOMXComponents; ii ++)
-    {
-        // if the role matches, increment the counter and record the comp. name
-        if (!strcmp((OMX_STRING)pOMXMasterRegistry[ii].CompRole, role))
-        {
-            // if a placeholder for compNames is provided, copy the component name into it
-            if (compNames != NULL)
-            {
-                strcpy((OMX_STRING) compNames[*pNumComps], (OMX_STRING)pOMXMasterRegistry[ii].CompName);
-            }
-            // increment the counter
-            *pNumComps = (*pNumComps + 1);
-
-        }
-    }
-
-    g_OMX_Mutex.Unlock();
-    return OMX_ErrorNone;
-
-}
-
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY 	PV_MasterOMX_GetHandle(
-    OMX_OUT OMX_HANDLETYPE* pHandle,
-    OMX_IN  OMX_STRING cComponentName,
-    OMX_IN  OMX_PTR pAppData,
-    OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
-{
-    OMX_ERRORTYPE Status = OMX_ErrorNone;
-    OMX_U32 ii, kk;
-
-    g_OMX_Mutex.Lock();
-    PVOMXMasterRegistryStruct *pOMXMasterRegistry = (PVOMXMasterRegistryStruct *) g_MasterRegistry;
-    if (pOMXMasterRegistry == NULL)
-    {
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorComponentNotFound;
-    }
-    PVOMXCompHandles *pOMXCompHandles = (PVOMXCompHandles *)g_OMXCompHandles;
-    if (pOMXCompHandles == NULL)
-    {
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorComponentNotFound;
-    }
-
-    for (ii = 0; ii < g_TotalNumOMXComponents; ii ++)
-    {
-        // go through the list of supported components and find the component based on its name (identifier)
-        if (!strcmp((OMX_STRING) pOMXMasterRegistry[ii].CompName, cComponentName))
-        {
-            // found a matching name
-            break;
-        }
-
-    }
-
-    if (ii == g_TotalNumOMXComponents)
-    {
-        // could not find a component with the given name
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorComponentNotFound;
-    }
-
-    // call the appropriate GetHandle for the component
-    PV_OMX_WrapperBase **pWrapper = (PV_OMX_WrapperBase **) g_Wrapper;
-    if (pWrapper)
-    {
-        //save component handle with the OMX core index, so it can be retrieved
-        // later when freehandle is called
-        // find an empty slot to write the pair handle/index:
-        for (kk = 0;kk < MAX_NUMBER_OF_OMX_COMPONENTS; kk++)
-        {
-            if (pOMXCompHandles[kk].handle == NULL)
-            {
-                break;
-            }
-        }
-        if (kk == MAX_NUMBER_OF_OMX_COMPONENTS)
-        {
-            g_OMX_Mutex.Unlock();
-            return OMX_ErrorComponentNotFound;
-        }
-
-        OMX_U32 index = pOMXMasterRegistry[ii].OMXCoreIndex;
-        Status = (*(pWrapper[index]->GetpOMX_GetHandle()))(pHandle, cComponentName, pAppData, pCallBacks);
-        if (Status == OMX_ErrorNone)
-        {
-            // write the pair handle/index
-            pOMXCompHandles[kk].handle = *pHandle;
-            pOMXCompHandles[kk].OMXCoreIndex = index;
-        }
-        g_OMX_Mutex.Unlock();
-        return Status;
-    }
-    else
-    {
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorInsufficientResources;
-    }
-
-}
-
-OMX_API OMX_ERRORTYPE OMX_APIENTRY PV_MasterOMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
-{
-
-    OMX_ERRORTYPE Status = OMX_ErrorNone;
-    OMX_U32 ii;
-// here, we need to first find the handle among instantiated components
-// then we retrieve the core based on component handle
-// finally, call the OMX_FreeHandle for appropriate core
-    g_OMX_Mutex.Lock();
-    PVOMXCompHandles *pOMXCompHandles = (PVOMXCompHandles *)g_OMXCompHandles;
-    if (pOMXCompHandles == NULL)
-    {
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorComponentNotFound;
-    }
-    for (ii = 0; ii < MAX_NUMBER_OF_OMX_COMPONENTS; ii ++)
-    {
-        // go through the list of supported components and find the component handle
-        if (pOMXCompHandles[ii].handle == hComponent)
-        {
-            // found a matching handle
-            break;
-        }
-
-    }
-    if (ii == MAX_NUMBER_OF_OMX_COMPONENTS)
-    {
-        // could not find a component with the given name
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorComponentNotFound;
-    }
-
-    // call the appropriate GetHandle for the component
-    PV_OMX_WrapperBase **pWrapper = (PV_OMX_WrapperBase **) g_Wrapper;
-    if (pWrapper)
-    {
-        OMX_U32 index = pOMXCompHandles[ii].OMXCoreIndex;
-        Status = (*(pWrapper[index]->GetpOMX_FreeHandle()))(hComponent);
-        //we're done with this, so get rid of the component handle
-        pOMXCompHandles[ii].handle = NULL;
-        g_OMX_Mutex.Unlock();
-        return Status;
-    }
-    else
-    {
-        g_OMX_Mutex.Unlock();
-        return OMX_ErrorInsufficientResources;
-    }
-
-}
-
diff --git a/codecs_v2/omx/omx_common/src/pv_omxregistry.cpp b/codecs_v2/omx/omx_common/src/pv_omxregistry.cpp
old mode 100755
new mode 100644
index d13304c..4d71c84
--- a/codecs_v2/omx/omx_common/src/pv_omxregistry.cpp
+++ b/codecs_v2/omx/omx_common/src/pv_omxregistry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,167 +15,71 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PV_OMXDEFS_H_INCLUDED
 #include "pv_omxdefs.h"
+#endif
+
+#ifndef OSCL_ERROR_H_INCLUDED
+#include "oscl_error.h"
+#endif
+
 #include "omx_component.h"
 #include "pv_omxcore.h"
-#include "oscl_types.h"
+
+// pv_omxregistry.h is only needed if NOT using CML2
+#ifndef USE_CML2_CONFIG
 #include "pv_omxregistry.h"
-
-extern ComponentRegistrationType *pRegTemplateList[];
-extern OMX_HANDLETYPE ComponentHandle[];
-extern OMX_ERRORTYPE(*ComponentDestructor[])(OMX_IN OMX_HANDLETYPE pHandle);
-extern OMX_U32 NumOMXInitInstances;
-
-
-#if PROXY_INTERFACE
-#include "omx_proxy_interface.h"
-extern ProxyApplication_OMX* pProxyTerm[];
 #endif
 
-#if REGISTER_OMX_M4V_COMPONENT
-#ifndef OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-#include "omx_m4v_component_interface.h"
-#endif
-OMX_ERRORTYPE Mpeg4Register(ComponentRegistrationType **);
+
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
 #endif
 
-#if REGISTER_OMX_H263_COMPONENT
-#ifndef OMX_M4V_COMPONENT_INTERFACE_H_INCLUDED
-#include "omx_m4v_component_interface.h"
-#endif
-OMX_ERRORTYPE H263Register(ComponentRegistrationType **);
+
+#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
+OMX_ERRORTYPE OmxComponentFactoryDynamicCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+OMX_ERRORTYPE OmxComponentFactoryDynamicDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
 #endif
 
-#if REGISTER_OMX_AVC_COMPONENT
-OMX_ERRORTYPE AvcRegister(ComponentRegistrationType **);
-#endif
 
-#if REGISTER_OMX_WMV_COMPONENT
-#include "omx_wmv_component_interface.h"
-OMX_ERRORTYPE WmvRegister(ComponentRegistrationType **);
-#endif
-
-#if REGISTER_OMX_AAC_COMPONENT
-OMX_ERRORTYPE AacRegister(ComponentRegistrationType **);
-#endif
-
-#if REGISTER_OMX_AMR_COMPONENT
-OMX_ERRORTYPE AmrRegister(ComponentRegistrationType **);
-#endif
-
-#if REGISTER_OMX_MP3_COMPONENT
-OMX_ERRORTYPE Mp3Register(ComponentRegistrationType **);
-#endif
-
-/* Initializes the component */
-OMX_ERRORTYPE OMX_Init()
+OMX_ERRORTYPE ComponentRegister(ComponentRegistrationType *pCRT)
 {
-    OMX_ERRORTYPE Status = OMX_ErrorNone;
-    OMX_U32 ii;
-
-    NumOMXInitInstances++;
-
-    if (NumOMXInitInstances == 1)
-    {
-        /* Initialize template list to NULL at the beginning */
-        for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-        {
-            pRegTemplateList[ii] = NULL;
-        }
-
-        for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-        {
-            ComponentHandle[ii] = NULL;
-            ComponentDestructor[ii] = NULL;
-#if PROXY_INTERFACE
-            pProxyTerm[ii] = NULL;
-#endif
-        }
-
-        // REGISTER COMPONENT TYPES (ONE BY ONE)
-#if REGISTER_OMX_M4V_COMPONENT
-        // MPEG4
-        Status = Mpeg4Register(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-
-#if REGISTER_OMX_H263_COMPONENT
-        //H263
-        Status = H263Register(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-
-#if REGISTER_OMX_AVC_COMPONENT
-        // AVC
-        Status = AvcRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-
-#if REGISTER_OMX_WMV_COMPONENT
-        // WMV
-        Status = WmvRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-
-#if REGISTER_OMX_AAC_COMPONENT
-        // AAC
-        Status = AacRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-
-#if REGISTER_OMX_AMR_COMPONENT
-        // AMR
-        Status = AmrRegister(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-
-#if REGISTER_OMX_MP3_COMPONENT
-        // MP3
-        Status = Mp3Register(pRegTemplateList);
-        if (Status != OMX_ErrorNone)
-            return Status;
-#endif
-    }
-    return OMX_ErrorNone;
-}
-
-
-#if REGISTER_OMX_M4V_COMPONENT
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE Mpeg4Register(ComponentRegistrationType **aTemplateList)
-{
-
+    int32 error;
     OMX_S32 ii;
-    ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
-    if (pCRT)
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (error) // can't access registry
     {
-        pCRT->ComponentName = "OMX.PV.mpeg4dec";
-        pCRT->RoleString = "video_decoder.mpeg4";
-        pCRT->FunctionPtrCreateComponent = OmxM4vComponentFactory::M4vCreate;
-        pCRT->FunctionPtrDestroyComponent = OmxM4vComponentFactory::M4vDestructor;
-
+        return OMX_ErrorInvalidState;
     }
-    else
+    else if (!data) // singleton object has been destroyed
     {
-        return OMX_ErrorInsufficientResources;
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        return OMX_ErrorInvalidState;
     }
 
     for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
     {
-        if (NULL == aTemplateList[ii])
+        if (NULL == data->ipRegTemplateList[ii])
         {
-            aTemplateList[ii] = pCRT;
+            data->ipRegTemplateList[ii] = pCRT;
             break;
         }
     }
 
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    if (error)
+    {
+        //registry error
+        return OMX_ErrorUndefined;
+    }
+
     if (MAX_SUPPORTED_COMPONENTS == ii)
     {
         return OMX_ErrorInsufficientResources;
@@ -183,25 +87,91 @@
 
     return OMX_ErrorNone;
 }
+
+#if REGISTER_OMX_M4V_COMPONENT
+#if (DYNAMIC_LOAD_OMX_M4V_COMPONENT == 0)
+// external factory functions needed for creation of each component (or stubs for testing)
+extern OMX_ERRORTYPE Mpeg4OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE Mpeg4OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE Mpeg4Register()
+{
+    ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.mpeg4dec";
+        pCRT->RoleString = (OMX_STRING)"video_decoder.mpeg4";
+#if DYNAMIC_LOAD_OMX_M4V_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4vdec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_M4VDEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
+        pCRT->FunctionPtrCreateComponent = &Mpeg4OmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &Mpeg4OmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return  ComponentRegister(pCRT);
+}
+
+
 #endif
 //////////////////////////////////////////////////////////////////////////////
 
 #if REGISTER_OMX_H263_COMPONENT
-
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_H263_COMPONENT == 0)
+extern OMX_ERRORTYPE H263OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE H263OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
 /////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE H263Register(ComponentRegistrationType **aTemplateList)
+OMX_ERRORTYPE H263Register()
 {
-
-    OMX_S32 ii;
     ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
-
     if (pCRT)
     {
-        pCRT->ComponentName = "OMX.PV.h263dec";
-        pCRT->RoleString = "video_decoder.h263";
-        pCRT->FunctionPtrCreateComponent = OmxM4vComponentFactory::H263Create;
-        pCRT->FunctionPtrDestroyComponent = OmxM4vComponentFactory::H263Destructor;
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.h263dec";
+        pCRT->RoleString = (OMX_STRING)"video_decoder.h263";
+#if DYNAMIC_LOAD_OMX_H263_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4vdec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_H263DEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
+        pCRT->FunctionPtrCreateComponent = &H263OmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &H263OmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
 
     }
     else
@@ -209,42 +179,45 @@
         return OMX_ErrorInsufficientResources;
     }
 
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-    {
-        if (NULL == aTemplateList[ii])
-        {
-            aTemplateList[ii] = pCRT;
-            break;
-        }
-    }
-
-    if (MAX_SUPPORTED_COMPONENTS == ii)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    return OMX_ErrorNone;
+    return  ComponentRegister(pCRT);
 }
 #endif
 ////////////////////////////////////////////////////////////////////////////////////
 
 #if REGISTER_OMX_AVC_COMPONENT
-extern OMX_ERRORTYPE AvcOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-extern OMX_ERRORTYPE AvcOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle);
-
+#if (DYNAMIC_LOAD_OMX_AVC_COMPONENT == 0)
+extern OMX_ERRORTYPE AvcOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE AvcOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
 /////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE AvcRegister(ComponentRegistrationType **aTemplateList)
+OMX_ERRORTYPE AvcRegister()
 {
-
-    OMX_S32 ii;
     ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
     if (pCRT)
     {
-        pCRT->ComponentName = "OMX.PV.avcdec";
-        pCRT->RoleString = "video_decoder.avc";
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.avcdec";
+        pCRT->RoleString = (OMX_STRING)"video_decoder.avc";
+#if DYNAMIC_LOAD_OMX_AVC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_avcdec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_AVCDEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
         pCRT->FunctionPtrCreateComponent = &AvcOmxComponentFactory;
         pCRT->FunctionPtrDestroyComponent = &AvcOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
 
     }
     else
@@ -252,126 +225,139 @@
         return OMX_ErrorInsufficientResources;
     }
 
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-    {
-        if (NULL == aTemplateList[ii])
-        {
-            aTemplateList[ii] = pCRT;
-            break;
-        }
-    }
-
-    if (MAX_SUPPORTED_COMPONENTS == ii)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    return OMX_ErrorNone;
+    return  ComponentRegister(pCRT);
 }
 #endif
 ////////////////////////////////////////////////////////////////////////////////////
 
 #if REGISTER_OMX_WMV_COMPONENT
-/////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE WmvRegister(ComponentRegistrationType **aTemplateList)
-{
 
-    OMX_S32 ii;
+#if (DYNAMIC_LOAD_OMX_WMV_COMPONENT == 0)
+extern OMX_ERRORTYPE WmvOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE WmvOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE WmvRegister()
+{
     ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
     if (pCRT)
     {
-        pCRT->ComponentName = "OMX.PV.wmvdec";
-        pCRT->RoleString = "video_decoder.wmv";
-        pCRT->FunctionPtrCreateComponent = OmxWmvComponentFactory::Create;
-        pCRT->FunctionPtrDestroyComponent = OmxWmvComponentFactory::Destructor;
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.wmvdec";
+        pCRT->RoleString = (OMX_STRING)"video_decoder.wmv";
+#if DYNAMIC_LOAD_OMX_WMV_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_wmvdec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
 
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_WMVDEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
+        pCRT->FunctionPtrCreateComponent = &WmvOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &WmvOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
     }
     else
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-    {
-        if (NULL == aTemplateList[ii])
-        {
-            aTemplateList[ii] = pCRT;
-            break;
-        }
-    }
-
-    if (MAX_SUPPORTED_COMPONENTS == ii)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    return OMX_ErrorNone;
+    return  ComponentRegister(pCRT);
 }
 #endif
 ///////////////////////////////////////////////////////////////////////////////////////////////
 #if REGISTER_OMX_AAC_COMPONENT
 // external factory functions needed for creation of each component (or stubs for testing)
-extern OMX_ERRORTYPE AacOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-extern OMX_ERRORTYPE AacOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle);
+#if (DYNAMIC_LOAD_OMX_AAC_COMPONENT == 0)
+extern OMX_ERRORTYPE AacOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE AacOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
 
 /////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE AacRegister(ComponentRegistrationType **aTemplateList)
+OMX_ERRORTYPE AacRegister()
 {
-
-    OMX_S32 ii;
     ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
     if (pCRT)
     {
-        pCRT->ComponentName = "OMX.PV.aacdec";
-        pCRT->RoleString = "audio_decoder.aac";
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.aacdec";
+        pCRT->RoleString = (OMX_STRING)"audio_decoder.aac";
+#if DYNAMIC_LOAD_OMX_AAC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_aacdec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_AACDEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
         pCRT->FunctionPtrCreateComponent = &AacOmxComponentFactory;
         pCRT->FunctionPtrDestroyComponent = &AacOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
 
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
     }
     else
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-    {
-        if (NULL == aTemplateList[ii])
-        {
-            aTemplateList[ii] = pCRT;
-            break;
-        }
-    }
-
-    if (MAX_SUPPORTED_COMPONENTS == ii)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    return OMX_ErrorNone;
+    return  ComponentRegister(pCRT);
 }
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 #if REGISTER_OMX_AMR_COMPONENT
 // external factory functions needed for creation of each component (or stubs for testing)
-extern OMX_ERRORTYPE AmrOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-extern OMX_ERRORTYPE AmrOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle);
-
+#if (DYNAMIC_LOAD_OMX_AMR_COMPONENT == 0)
+extern OMX_ERRORTYPE AmrOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE AmrOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
 /////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE AmrRegister(ComponentRegistrationType **aTemplateList)
+OMX_ERRORTYPE AmrRegister()
 {
-
-    OMX_S32 ii;
     ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
     if (pCRT)
     {
-        pCRT->ComponentName = "OMX.PV.amrdec";
-        pCRT->RoleString = "audio_decoder.amr";
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.amrdec";
+        pCRT->RoleString = (OMX_STRING)"audio_decoder.amr";
+#if DYNAMIC_LOAD_OMX_AMR_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_amrdec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_AMRDEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+
+#else
         pCRT->FunctionPtrCreateComponent = &AmrOmxComponentFactory;
         pCRT->FunctionPtrDestroyComponent = &AmrOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
 
     }
     else
@@ -379,43 +365,46 @@
         return OMX_ErrorInsufficientResources;
     }
 
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-    {
-        if (NULL == aTemplateList[ii])
-        {
-            aTemplateList[ii] = pCRT;
-            break;
-        }
-    }
-
-    if (MAX_SUPPORTED_COMPONENTS == ii)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    return OMX_ErrorNone;
+    return  ComponentRegister(pCRT);
 }
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 #if REGISTER_OMX_MP3_COMPONENT
 // external factory functions needed for creation of each component (or stubs for testing)
-extern OMX_ERRORTYPE Mp3OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-extern OMX_ERRORTYPE Mp3OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle);
-
+#if (DYNAMIC_LOAD_OMX_MP3_COMPONENT == 0)
+extern OMX_ERRORTYPE Mp3OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE Mp3OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
 /////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE Mp3Register(ComponentRegistrationType **aTemplateList)
+OMX_ERRORTYPE Mp3Register()
 {
-
-    OMX_S32 ii;
     ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
 
     if (pCRT)
     {
-        pCRT->ComponentName = "OMX.PV.mp3dec";
-        pCRT->RoleString = "audio_decoder.mp3";
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.mp3dec";
+        pCRT->RoleString = (OMX_STRING)"audio_decoder.mp3";
+#if DYNAMIC_LOAD_OMX_MP3_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_mp3dec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_MP3DEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
         pCRT->FunctionPtrCreateComponent = &Mp3OmxComponentFactory;
         pCRT->FunctionPtrDestroyComponent = &Mp3OmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
 
     }
     else
@@ -423,21 +412,445 @@
         return OMX_ErrorInsufficientResources;
     }
 
-    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
-    {
-        if (NULL == aTemplateList[ii])
-        {
-            aTemplateList[ii] = pCRT;
-            break;
-        }
-    }
+    return  ComponentRegister(pCRT);
+}
+#endif
 
-    if (MAX_SUPPORTED_COMPONENTS == ii)
+///////////////////////////////////////////////////////////////////////////////////////////////
+#if REGISTER_OMX_WMA_COMPONENT
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_WMA_COMPONENT == 0)
+extern OMX_ERRORTYPE WmaOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE WmaOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE WmaRegister()
+{
+    ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.wmadec";
+        pCRT->RoleString = (OMX_STRING)"audio_decoder.wma";
+#if DYNAMIC_LOAD_OMX_WMA_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_wmadec_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_WMADEC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
+        pCRT->FunctionPtrCreateComponent = &WmaOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &WmaOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+    }
+    else
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    return OMX_ErrorNone;
+    return  ComponentRegister(pCRT);
 }
 #endif
 
+///////////////////////////////////////////////////////////////////////////////////////////////
+#if REGISTER_OMX_AMRENC_COMPONENT
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_AMRENC_COMPONENT == 0)
+extern OMX_ERRORTYPE AmrEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE AmrEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE AmrEncRegister()
+{
+    ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.amrenc";
+        pCRT->RoleString = (OMX_STRING)"audio_encoder.amr";
+#if DYNAMIC_LOAD_OMX_AMRENC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_amrenc_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_AMRENC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+#else
+        pCRT->FunctionPtrCreateComponent = &AmrEncOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &AmrEncOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return  ComponentRegister(pCRT);
+}
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+#if REGISTER_OMX_M4VENC_COMPONENT
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_M4VENC_COMPONENT == 0)
+extern OMX_ERRORTYPE Mpeg4EncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE Mpeg4EncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE Mpeg4EncRegister()
+{
+    ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.mpeg4enc";
+        pCRT->RoleString = (OMX_STRING)"video_encoder.mpeg4";
+#if DYNAMIC_LOAD_OMX_M4VENC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4venc_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_M4VENC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+
+#else
+        pCRT->FunctionPtrCreateComponent = &Mpeg4EncOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &Mpeg4EncOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return  ComponentRegister(pCRT);
+}
+#endif
+#if REGISTER_OMX_H263ENC_COMPONENT
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_H263ENC_COMPONENT == 0)
+extern OMX_ERRORTYPE H263EncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE H263EncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE H263EncRegister()
+{
+    ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.h263enc";
+        pCRT->RoleString = (OMX_STRING)"video_encoder.h263";
+#if DYNAMIC_LOAD_OMX_H263ENC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4venc_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_H263ENC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+
+#else
+        pCRT->FunctionPtrCreateComponent = &H263EncOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &H263EncOmxComponentDestructor;
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return  ComponentRegister(pCRT);
+}
+#endif
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+#if REGISTER_OMX_AVCENC_COMPONENT
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_AVCENC_COMPONENT == 0)
+extern OMX_ERRORTYPE AvcEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE AvcEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE AvcEncRegister()
+{
+    ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.avcenc";
+        pCRT->RoleString = (OMX_STRING)"video_encoder.avc";
+#if DYNAMIC_LOAD_OMX_AVCENC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_avcenc_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_AVCENC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+
+#else
+        pCRT->FunctionPtrCreateComponent = &AvcEncOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &AvcEncOmxComponentDestructor;
+
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return  ComponentRegister(pCRT);
+}
+#endif
+
+///////////////////////////////////////////////////////////////////////////////////////////////
+#if REGISTER_OMX_AACENC_COMPONENT
+// external factory functions needed for creation of each component (or stubs for testing)
+#if (DYNAMIC_LOAD_OMX_AACENC_COMPONENT == 0)
+extern OMX_ERRORTYPE AacEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+extern OMX_ERRORTYPE AacEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+#endif
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE AacEncRegister()
+{
+    ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
+
+    if (pCRT)
+    {
+        pCRT->ComponentName = (OMX_STRING)"OMX.PV.aacenc";
+        pCRT->RoleString = (OMX_STRING)"audio_encoder.aac";
+#if DYNAMIC_LOAD_OMX_AACENC_COMPONENT
+        pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
+        pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
+        pCRT->SharedLibraryName = (OMX_STRING)"libomx_aacenc_sharedlibrary.so";
+        pCRT->SharedLibraryPtr = NULL;
+
+        OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
+        OSCL_PLACEMENT_NEW(temp, PV_OMX_AACENC_UUID);
+
+        pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
+        pCRT->SharedLibraryRefCounter = 0;
+
+#else
+        pCRT->FunctionPtrCreateComponent = &AacEncOmxComponentFactory;
+        pCRT->FunctionPtrDestroyComponent = &AacEncOmxComponentDestructor;
+
+        pCRT->SharedLibraryName = NULL;
+        pCRT->SharedLibraryPtr = NULL;
+
+        pCRT->SharedLibraryOsclUuid = NULL;
+        pCRT->SharedLibraryRefCounter = 0;
+#endif
+
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return  ComponentRegister(pCRT);
+}
+#endif
+
+
+// In case of dynamic loading of individual omx components,
+// this function is called by OMX_GetHandle (either through proxy or directly).
+// The method dynamically loads the library and creates an instance of the omx component AO
+// NOTE: This method is called when singleton is locked. Access & modification of various
+// variables should be (and is) thread-safe
+#if USE_DYNAMIC_LOAD_OMX_COMPONENTS
+
+OMX_ERRORTYPE OmxComponentFactoryDynamicCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OMX_ERRORTYPE returnStatus = OMX_ErrorUndefined;
+
+    //OSCL_StackString<M4V_MAX_LIB_PATH> omxLibName(OMX_M4V_LIB_NAME);
+
+    OsclSharedLibrary* lib = NULL;
+
+    // If aOmxLib is NULL, this is the first time this method has been called
+    if (NULL == aOmxLib)
+    {
+        OSCL_StackString<OMX_MAX_LIB_PATH> Libname(aOmxLibName);
+        lib = OSCL_NEW(OsclSharedLibrary, (Libname));
+    }
+    else
+    {
+        lib = (OsclSharedLibrary *) aOmxLib;
+    }
+
+    // Keep track of the number of times OmxLib is accessed
+    aRefCount++;
+
+    // Load the associated library. If successful, call the corresponding
+    // create function located inside the loaded library
+
+    if (OsclLibSuccess == lib->LoadLib())
+    {
+        // look for the interface
+
+        OsclAny* interfacePtr = NULL;
+        if (OsclLibSuccess == lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr))
+        {
+
+
+            // the interface ptr should be ok, but check just in case
+            if (interfacePtr != NULL)
+            {
+                OmxSharedLibraryInterface* omxIntPtr =
+                    OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
+
+
+                OsclUuid *temp = (OsclUuid*) aOsclUuid;
+                OsclAny* createCompTemp =
+                    omxIntPtr->QueryOmxComponentInterface(*temp, PV_OMX_CREATE_INTERFACE);
+
+                // check if the component contains the correct ptr
+                if (createCompTemp != NULL)
+                {
+
+                    // createComp is the function pointer to store the creation function
+                    // for the omx component located inside the loaded library
+                    OMX_ERRORTYPE(*createComp)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+
+                    createComp = OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_OUT OMX_HANDLETYPE * pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR , OMX_STRING, OMX_PTR &, OMX_PTR , OMX_U32 &), createCompTemp);
+
+                    // call the component AO factory inside the loaded library
+                    returnStatus = (*createComp)(pHandle, pAppData, pProxy, aOmxLibName, aOmxLib, aOsclUuid, aRefCount);
+
+                    // Store the shared library so it can be closed later
+                    aOmxLib = (OMX_PTR) lib;
+                }
+            }
+        }
+    }
+
+    // if everything is OK, the AO factory should have returned OMX_ErrorNone
+    if (returnStatus != OMX_ErrorNone)
+    {
+        lib->Close();
+
+        // If this is the last time to close the library, delete the
+        // OsclSharedLibrary object and be sure to set aOmxLib back to NULL
+        aRefCount--;
+        if (0 == aRefCount)
+        {
+            OSCL_DELETE(lib);
+            aOmxLib = NULL;
+        }
+    }
+    return returnStatus;
+}
+
+OMX_ERRORTYPE OmxComponentFactoryDynamicDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OsclSharedLibrary* lib = (OsclSharedLibrary *) aOmxLib;
+    OMX_ERRORTYPE returnStatus = OMX_ErrorUndefined;
+
+    // lib must not be NULL at this point. If the omx component has been
+    // created, lib is necessary to destroy the component correctly and
+    // cleanup used memory.
+    OSCL_ASSERT(NULL != lib);
+    if (lib == NULL)
+    {
+        return returnStatus;
+    }
+
+    // Need to get the function pointer for the destroy function through the
+    // shared library interface.
+
+    // first, try to get the interface
+    OsclAny* interfacePtr = NULL;
+    if (OsclLibSuccess == lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr))
+    {
+
+        if (interfacePtr != NULL)
+        {
+            OmxSharedLibraryInterface* omxIntPtr =
+                OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
+
+            // try to get the function ptr to the omx component AO destructor inside the loaded library
+            OsclUuid *temp = (OsclUuid*) aOsclUuid;
+            OsclAny* destroyCompTemp =
+                omxIntPtr->QueryOmxComponentInterface(*temp, PV_OMX_DESTROY_INTERFACE);
+
+            if (destroyCompTemp != NULL)
+            {
+                // destroyComp is the function pointer to store the function for
+                // destroying the omx component AO
+                OMX_ERRORTYPE(*destroyComp)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+                destroyComp = OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_IN OMX_HANDLETYPE, OMX_PTR &, OMX_PTR, OMX_U32 &), destroyCompTemp);
+
+                // call the destructor through the function ptr
+                returnStatus = (*destroyComp)(pHandle, aOmxLib, aOsclUuid, aRefCount);
+            }
+        }
+    }
+
+    //Whatever the outcome of the interface queries, this needs to be done
+    // Finish memory cleanup by closing the shared library and deleting
+    lib->Close();
+
+    // If this is the last time to close the library, delete the
+    // OsclSharedLibrary object and be sure to set iOmxLib back to NULL
+    aRefCount--;
+    if (0 == aRefCount)
+    {
+        OSCL_DELETE(lib);
+        aOmxLib = NULL;
+    }
+
+    return returnStatus;
+}
+
+#endif // USE_DYNAMIC_LOAD_OMX_COMPONENTS
+
diff --git a/codecs_v2/omx/omx_common/src/qc_omxcore.cpp b/codecs_v2/omx/omx_common/src/qc_omxcore.cpp
deleted file mode 100644
index 85fdbff..0000000
--- a/codecs_v2/omx/omx_common/src/qc_omxcore.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// WRAPPER CLASS METHODS VISIBLE FROM OUTSIDE THE LIBRARY
-#include "qc_omxcore.h"
-
-#if HARDWARE_OMX
-
-QC_OMX_Wrapper::QC_OMX_Wrapper()
-{
-    // initialize f. ptrs
-    pOMX_Init = OMX_Init;
-    pOMX_Deinit = OMX_Deinit;
-    pOMX_ComponentNameEnum = OMX_ComponentNameEnum;
-    pOMX_GetHandle = OMX_GetHandle;
-    pOMX_FreeHandle = OMX_FreeHandle;
-    pOMX_GetComponentsOfRole = OMX_GetComponentsOfRole;
-    pOMX_GetRolesOfComponent = OMX_GetRolesOfComponent;
-    pOMX_SetupTunnel = OMX_SetupTunnel;
-    pOMX_GetContentPipe = OMX_GetContentPipe;
-};
-
-PV_OMX_WrapperBase *QC_OMX_Wrapper::New()
-{
-    void *tmp = malloc(sizeof(QC_OMX_Wrapper));
-    PV_OMX_WrapperBase *x = (PV_OMX_WrapperBase *) new(tmp) QC_OMX_Wrapper();
-    return x;
-}
-
-void QC_OMX_Wrapper::Delete()
-{
-
-    this->~QC_OMX_Wrapper();
-    free(this);
-}
-
-tpOMX_Init QC_OMX_Wrapper::GetpOMX_Init()
-{
-    return pOMX_Init;
-};
-
-tpOMX_Deinit QC_OMX_Wrapper::GetpOMX_Deinit()
-{
-    return pOMX_Deinit;
-};
-
-tpOMX_ComponentNameEnum QC_OMX_Wrapper::GetpOMX_ComponentNameEnum()
-{
-    return pOMX_ComponentNameEnum;
-};
-
-tpOMX_GetHandle QC_OMX_Wrapper::GetpOMX_GetHandle()
-{
-    return pOMX_GetHandle;
-};
-
-tpOMX_FreeHandle QC_OMX_Wrapper::GetpOMX_FreeHandle()
-{
-    return pOMX_FreeHandle;
-};
-
-tpOMX_GetComponentsOfRole QC_OMX_Wrapper::GetpOMX_GetComponentsOfRole()
-{
-    return pOMX_GetComponentsOfRole;
-};
-
-tpOMX_GetRolesOfComponent QC_OMX_Wrapper::GetpOMX_GetRolesOfComponent()
-{
-    return pOMX_GetRolesOfComponent;
-};
-
-tpOMX_SetupTunnel QC_OMX_Wrapper::GetpOMX_SetupTunnel()
-{
-    return pOMX_SetupTunnel;
-};
-
-tpOMX_GetContentPipe QC_OMX_Wrapper::GetpOMX_GetContentPipe()
-{
-    return pOMX_GetContentPipe;
-};
-#endif // HARDWARE_OMX
diff --git a/codecs_v2/omx/omx_core_plugins/template/src/pv_omx_interface.cpp b/codecs_v2/omx/omx_core_plugins/template/src/pv_omx_interface.cpp
new file mode 100644
index 0000000..411fbe3
--- /dev/null
+++ b/codecs_v2/omx/omx_core_plugins/template/src/pv_omx_interface.cpp
@@ -0,0 +1,137 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#define LOG_TAG "omx_interface"
+#include <utils/Log.h>
+
+#include "pvlogger.h"
+
+#include "pv_omxcore.h"
+#include "omx_interface.h"
+
+#define OMX_CORE_LIBRARY "libOmxCore.so"
+
+class PVOMXInterface : public OMXInterface
+{
+    public:
+        // Handle to the OMX core library
+        void* ipHandle;
+
+        ~PVOMXInterface()
+        {
+            if ((NULL != ipHandle) && (0 != dlclose(ipHandle)))
+            {
+                // dlclose() returns non-zero value if close failed, check for errors
+                const char* pErr = dlerror();
+                if (NULL != pErr)
+                {
+                    LOGE("PVOMXInterface: Error closing library: %s\n", pErr);
+                }
+                else
+                {
+                    LOGE("OsclSharedLibrary::Close: Error closing library, no error reported");
+                }
+            }
+
+            ipHandle = NULL;
+        };
+
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            // Make sure ipHandle is valid. If ipHandle is NULL, the dlopen
+            // call failed.
+            if (ipHandle && aInterfaceId == OMX_INTERFACE_ID)
+            {
+                // the library lookup was successful
+                return this;
+            }
+            // the ID doesn't match
+            return NULL;
+        };
+
+        static PVOMXInterface* Instance()
+        {
+            return OSCL_NEW(PVOMXInterface, ());
+        };
+
+        bool UnloadWhenNotUsed(void)
+        {
+            // As of 9/22/08, the PV OMX core library can not be
+            // safely unloaded and reloaded when the proxy interface
+            // is enabled.
+            return false;
+        };
+
+    private:
+
+        PVOMXInterface()
+        {
+            ipHandle = dlopen(OMX_CORE_LIBRARY, RTLD_NOW);
+
+            if (NULL == ipHandle)
+            {
+                pOMX_Init = NULL;
+                pOMX_Deinit = NULL;
+                pOMX_ComponentNameEnum = NULL;
+                pOMX_GetHandle = NULL;
+                pOMX_FreeHandle = NULL;
+                pOMX_GetComponentsOfRole = NULL;
+                pOMX_GetRolesOfComponent = NULL;
+                pOMX_SetupTunnel = NULL;
+                pOMX_GetContentPipe = NULL;
+
+                // check for errors
+                const char* pErr = dlerror();
+                if (NULL == pErr)
+                {
+                    // No error reported, but no handle to the library
+                    LOGE("OsclLib::LoadLibrary: Error opening "
+                         "library (%s) but no error reported\n", OMX_CORE_LIBRARY);
+                }
+                else
+                {
+                    // Error reported
+                    LOGE("OsclLib::LoadLibrary: Error opening "
+                         "library (%s): %s\n", OMX_CORE_LIBRARY, pErr);
+                }
+            }
+            else
+            {
+                // Lookup all the symbols in the OMX core
+                pOMX_Init = (tpOMX_Init)dlsym(ipHandle, "OMX_Init");
+                pOMX_Deinit = (tpOMX_Deinit)dlsym(ipHandle, "OMX_Deinit");
+                pOMX_ComponentNameEnum = (tpOMX_ComponentNameEnum)dlsym(ipHandle, "OMX_ComponentNameEnum");
+                pOMX_GetHandle = (tpOMX_GetHandle)dlsym(ipHandle, "OMX_GetHandle");
+                pOMX_FreeHandle = (tpOMX_FreeHandle)dlsym(ipHandle, "OMX_FreeHandle");
+                pOMX_GetComponentsOfRole = (tpOMX_GetComponentsOfRole)dlsym(ipHandle, "OMX_GetComponentsOfRole");
+                pOMX_GetRolesOfComponent = (tpOMX_GetRolesOfComponent)dlsym(ipHandle, "OMX_GetRolesOfComponent");
+                pOMX_SetupTunnel = (tpOMX_SetupTunnel)dlsym(ipHandle, "OMX_SetupTunnel");
+                pOMX_GetContentPipe = (tpOMX_GetContentPipe)dlsym(ipHandle, "OMX_GetContentPipe");
+            }
+        };
+
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return PVOMXInterface::Instance();
+    }
+}
+
diff --git a/codecs_v2/omx/omx_h264/Android.mk b/codecs_v2/omx/omx_h264/Android.mk
old mode 100755
new mode 100644
index 475c7f8..1c7277b
--- a/codecs_v2/omx/omx_h264/Android.mk
+++ b/codecs_v2/omx/omx_h264/Android.mk
@@ -3,29 +3,32 @@
 
 LOCAL_SRC_FILES := \
 	src/avc_dec.cpp \
-	src/omx_avc_component.cpp
-
+ 	src/omx_avc_component.cpp
 
 
 LOCAL_MODULE := libomx_avc_component_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_h264/include \
-	$(PV_TOP)//codecs_v2/omx/omx_h264/src \
-	$(PV_TOP)//codecs_v2/omx/omx_h264/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//codecs_v2/omx/omx_h264/../../video/avc_h264/dec/src \
-	$(PV_TOP)//codecs_v2/omx/omx_h264/../../video/avc_h264/dec/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_h264/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_h264/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/omx/omx_baseclass/include \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/dec/src \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/avc_dec.h \
-	include/omx_avc_component.h
+ 	include/omx_avc_component.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_h264/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_h264/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..0f08092
--- /dev/null
+++ b/codecs_v2/omx/omx_h264/build/make_multithreaded/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_avc_component_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += ../../../../../extern_libs_v2/khronos/openmax/include \
+            ../../../../omx/omx_baseclass/include \
+            ../../../../video/avc_h264/dec/src \
+            ../../../../video/avc_h264/dec/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := avc_dec.cpp \
+	omx_avc_component.cpp 
+
+
+HDRS := avc_dec.h \
+	omx_avc_component.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_h264/build/make_multithreaded/makefile b/codecs_v2/omx/omx_h264/build/make_multithreaded/makefile
deleted file mode 100755
index 0c2144a..0000000
--- a/codecs_v2/omx/omx_h264/build/make_multithreaded/makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_avc_component_lib
-
-
-XINCDIRS += \
-	-I ../../../../../extern_libs_v2/khronos/openmax/include \
-	-I ../../../../video/avc_h264/dec/src \
-	-I ../../../../video/avc_h264/dec/include
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = 	avc_dec.cpp \
-	omx_avc_component.cpp 
-
-
-HDRS =	avc_dec.h \
-	omx_avc_component.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_h264/include/avc_dec.h b/codecs_v2/omx/omx_h264/include/avc_dec.h
old mode 100755
new mode 100644
index 72c0342..6548ff0
--- a/codecs_v2/omx/omx_h264/include/avc_dec.h
+++ b/codecs_v2/omx/omx_h264/include/avc_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,24 +53,22 @@
     public:
         AvcDecoder_OMX()
         {
-            iAvcDecoderCounterInstance++;
-        };
-        ~AvcDecoder_OMX()
-        {
-            iAvcDecoderCounterInstance--;
+            CurrInputTimestamp = 0;
+            pDpbBuffer = NULL;
+            FrameSize = 0;
+            oscl_memset(DisplayTimestampArray, 0, sizeof(OMX_TICKS)*AVC_DEC_TIMESTAMP_ARRAY_SIZE);
         };
 
+        ~AvcDecoder_OMX() { };
+
         AVCCleanupObject_OMX*	pCleanObject;
-        static AVCHandle		AvcHandle;
-        static AVCDecSPSInfo	SeqInfo;
-        static uint32			FrameSize;
-        static uint8*			pDpbBuffer;
-        uint8*			pNalBufferTemp;
-        int32			NalSizeTemp;
-        OMX_BOOL		DecodeSliceFlag;
-        static OMX_TICKS		DisplayTimestampArray[AVC_DEC_TIMESTAMP_ARRAY_SIZE];
-        static OMX_TICKS		CurrInputTimestamp;
-        static OMX_U32			iAvcDecoderCounterInstance;
+        AVCHandle		AvcHandle;
+        AVCDecSPSInfo	SeqInfo;
+        uint32			FrameSize;
+        uint8*			pDpbBuffer;
+        OMX_TICKS		DisplayTimestampArray[AVC_DEC_TIMESTAMP_ARRAY_SIZE];
+        OMX_TICKS		CurrInputTimestamp;
+        OMX_U32			InputBytesConsumed;
 
 
         OMX_ERRORTYPE AvcDecInit_OMX();
@@ -93,6 +91,12 @@
         static int32 AllocateBuffer_OMX(void* aUserData, int32 i, uint8** aYuvBuffer);
 
         static int32 ActivateSPS_OMX(void* aUserData, uint aSizeInMbs, uint aNumBuffers);
+
+        int32 NSAllocateBuffer_OMX(void* aUserData, int32 i, uint8** aYuvBuffer);
+
+        int32 NSActivateSPS_OMX(void* aUserData, uint aSizeInMbs, uint aNumBuffers);
+
+        void ResetDecoder(); // for repositioning
 };
 
 typedef class AvcDecoder_OMX AvcDecoder_OMX;
diff --git a/codecs_v2/omx/omx_h264/include/omx_avc_component.h b/codecs_v2/omx/omx_h264/include/omx_avc_component.h
old mode 100755
new mode 100644
index a4f918e..78fa75a
--- a/codecs_v2/omx/omx_h264/include/omx_avc_component.h
+++ b/codecs_v2/omx/omx_h264/include/omx_avc_component.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@
 #ifndef OMX_AVC_COMPONENT_H_INCLUDED
 #define OMX_AVC_COMPONENT_H_INCLUDED
 
-#ifndef OMX_Component_h
-#include "omx_component.h"
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
 #endif
 
 #ifndef AVC_DEC_H_INCLUDED
@@ -33,28 +33,6 @@
 #endif
 
 
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PV_OMX_QUEUE_H_INCLUDED
-#include "pv_omx_queue.h"
-#endif
-
-#ifndef PV_OMXCORE_H_INCLUDED
-#include "pv_omxcore.h"
-#endif
-
-
-#define OMX_PORT_INPUTPORT_INDEX OMX_DirInput
-#define OMX_PORT_OUTPUTPORT_INDEX OMX_DirOutput
-#define OMX_PORT_ALLPORT_INDEX -1
-
-
 #define INPUT_BUFFER_SIZE_AVC 2000
 #define OUTPUT_BUFFER_SIZE_AVC 65536
 
@@ -62,332 +40,36 @@
 #define NUMBER_OUTPUT_BUFFER_AVC  2
 
 
-/* Application's private data */
-typedef struct AvcPrivateType
-{
-    OMX_HANDLETYPE AvcHandle;
-
-}AvcPrivateType;
-
-
-/**
- * This is the Component template from which all
- * other Component instances are factored by the core.
- */
-
-
-/**
- * The structure for port Type.
- */
-typedef struct AvcComponentPortType
-{
-    /** @param pBuffer An array of pointers to buffer headers. */
-    OMX_BUFFERHEADERTYPE** pBuffer;
-    /** @param BufferState The State of the Buffer whether assigned or allocated */
-    OMX_U32* BufferState;
-    /** @param NumAssignedBuffers Number of buffer assigned on each port */
-    OMX_U32 NumAssignedBuffers;
-    /** @param pBufferQueue queue for buffer to be processed by the port */
-    QueueType* pBufferQueue;
-    OMX_STATETYPE TransientState;
-    /** @param BufferUnderProcess  Boolean variables indicate whether the port is processing any buffer */
-    OMX_BOOL BufferUnderProcess;
-    OMX_PARAM_PORTDEFINITIONTYPE PortParam;
-    /** @param NumBufferFlushed Number of buffer Flushed */
-    OMX_U32 NumBufferFlushed;
-    /** @param IsPortFlushed Boolean variables indicate port is being flushed at the moment */
-    OMX_BOOL IsPortFlushed;
-
-    OMX_VIDEO_PARAM_PORTFORMATTYPE VideoParam;
-    OMX_VIDEO_PARAM_AVCTYPE VideoAvc;
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE ProfileLevel;
-
-    //Added these flags as a replacement of semaphores on win32 platform
-    OMX_BOOL LoadedToIdleFlag ;
-    OMX_BOOL IdleToLoadedFlag ;
-
-} AvcComponentPortType;
-
-
-class OpenmaxAvcAO : public OsclActiveObject
+class OpenmaxAvcAO : public OmxComponentVideo
 {
     public:
 
         OpenmaxAvcAO();
         ~OpenmaxAvcAO();
 
-        /** Component entry points declarations without proxy interface*/
-        static OMX_ERRORTYPE BaseComponentGetComponentVersion(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STRING pComponentName,
-            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
-            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
-            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
 
-        static OMX_ERRORTYPE BaseComponentGetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
 
-        static OMX_ERRORTYPE BaseComponentSetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
 
-        static OMX_ERRORTYPE BaseComponentGetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_INOUT OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentSetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentGetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        static OMX_ERRORTYPE BaseComponentGetState(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STATETYPE* pState);
-
-        static OMX_ERRORTYPE BaseComponentUseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentAllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        static OMX_ERRORTYPE BaseComponentFreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_U32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        static OMX_ERRORTYPE BaseComponentComponentDeInit(
-            OMX_IN  OMX_HANDLETYPE hComponent);
-
-        static OMX_ERRORTYPE BaseComponentEmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentFillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        static void AvcComponentGetRolesOfComponent(OMX_STRING* aRoleString);
-
-        /*NON STATIC COUNTERPARTS OF STATIC MEMBER API'S */
-
-        OMX_ERRORTYPE GetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
-
-        OMX_ERRORTYPE SetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
-
+        void ComponentBufferMgmtWithoutMarker();
+        void ProcessData();
+        void DecodeWithoutMarker();
+        void DecodeWithMarker();
+        void ResetComponent();
         OMX_ERRORTYPE GetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE SetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        OMX_ERRORTYPE GetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        void GetState(OMX_OUT OMX_STATETYPE* pState);
-
-        OMX_ERRORTYPE UseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        OMX_ERRORTYPE AllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        OMX_ERRORTYPE FreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_S32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        OMX_ERRORTYPE EmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE FillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData);
-        OMX_ERRORTYPE DestroyComponent();
-
-        OMX_PTR GetOmxHandle()
-        {
-            return &iOmxComponent;
-        };
-
-        /*OTHER PROCESSING FUNCTIONS */
-
-        void AvcComponentBufferMgmtFunction();
-        void AvcBufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE*);
-        void AvcDecodeWithoutMarker();
-        void AvcDecodeWithMarker(OMX_BUFFERHEADERTYPE*);
-        OMX_BOOL AvcComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer);
-
-        OMX_ERRORTYPE AvcComponentMessageHandler(CoreMessage* Message);
-        OMX_ERRORTYPE AvcComponentDoStateSet(OMX_U32);
-
-        OMX_ERRORTYPE AvcComponentDisablePort(OMX_S32 PortIndex);
-        void AvcComponentDisableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE AvcComponentEnablePort(OMX_S32 PortIndex);
-        void AvcComponentEnableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE AvcComponentFlushPort(OMX_S32 PortIndex);
-        void AvcComponentSetPortFlushFlag(OMX_S32, OMX_S32 index, OMX_BOOL value);
-        void AvcComponentSetNumBufferFlush(OMX_S32, OMX_S32 index, OMX_S32 value);
-
-        OMX_S32 AvcComponentPanic();
-
-        void AvcComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, AvcComponentPortType *pPort);
-        void AvcComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, AvcComponentPortType *pPort);
-
-        OMX_ERRORTYPE AvcComponentInit();
-        OMX_ERRORTYPE AvcComponentDeInit();
-
-        OMX_ERRORTYPE AvcComponentTunnelRequest(
-            OMX_IN  OMX_HANDLETYPE hComp,
-            OMX_IN  OMX_U32 nPort,
-            OMX_IN  OMX_HANDLETYPE hTunneledComp,
-            OMX_IN  OMX_U32 nTunneledPort,
-            OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
-
-        OMX_ERRORTYPE BaseComponentParameterSanityCheck(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_PTR pStructure,
-            OMX_IN  size_t size);
-
-        void SetHeader(OMX_PTR aheader, OMX_U32 asize);
-        OMX_ERRORTYPE CheckHeader(OMX_PTR aheader, OMX_U32 asize);
-
-        //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-        OMX_BOOL			iBufferExecuteFlag;
-        AvcPrivateType*	ipAppPriv;
-
 
     private:
 
-        PVLogger* iLogger;
-
-        void Run();
-
-        OMX_CALLBACKTYPE*	ipCallbacks;
-        OMX_PTR				iCallbackData;
-        OMX_STATETYPE		iState;
-
-        CoreDescriptorType* ipCoreDescriptor;
-        OMX_U32				iNumInputBuffer;
-
-        OMX_U8*				ipFrameDecodeBuffer;
-        OMX_BOOL			iPartialFrameAssembly;
-        OMX_BOOL			iIsInputBufferEnded;
-        OMX_BOOL			iEndofStream;
-        OMX_U8*				ipTempInputBuffer;
-        OMX_U32				iTempInputBufferLength;
-        OMX_COMPONENTTYPE*	ipTargetComponent;
-        OMX_PTR				iTargetMarkData;
-        OMX_COMPONENTTYPE*	ipTempTargetComponent;
-        OMX_PTR				iTempTargetMarkData;
-        OMX_BOOL			iMarkPropagate;
-        OMX_BOOL			iNewInBufferRequired;
-        OMX_BOOL			iNewOutBufRequired;
-        OMX_U32				iTempConsumedLength;
-        OMX_U32				iOutBufferCount;
-        OMX_BOOL			iCodecReady;
-        OMX_U8*				ipInputCurrBuffer;
-        OMX_U32				iInputCurrBufferSize;
-        OMX_U32				iInputCurrLength;
-        OMX_S32				iFrameCount;
-        OMX_BOOL			iStateTransitionFlag;
-        OMX_BOOL			iFlushPortFlag;
-        OMX_BOOL				iEndOfFrameFlag;
-        OMX_BUFFERHEADERTYPE*	ipAvcInputBuffer;
-        OMX_BUFFERHEADERTYPE*	ipAvcOutputBuffer;
-
-        OMX_BOOL				iFirstFragment;
-        OMX_BOOL				iResizePending;
-
-        OMX_TICKS				iFrameTimestamp;
-
-        OMX_COMPONENTTYPE iOmxComponent;	// structure
-        OMX_U32			iNumPorts;
-
-        PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
-
-        //The ports of the component
-        AvcComponentPortType** ipPorts;
-        //Indicate whether component has been already initialized */
-        OMX_BOOL iIsInit;
-        //OpenMAX standard parameter that contains a short description of the available ports
-        OMX_PORT_PARAM_TYPE iPortTypesParam;
-        OMX_U32 iGroupPriority;
-        //ID of a group of components that share the same logical chain
-        OMX_U32 iGroupID;
-        //Roles of the component
-        OMX_U8 iComponentRole[OMX_MAX_STRINGNAME_SIZE];
-        //This field holds the private data associated with a mark request, if any
-        OMX_MARKTYPE* ipMark;
-
-        //AVC specific structure
         AvcDecoder_OMX* ipAvcDec;
+        OMX_BOOL				iDecodeReturn;
 };
 
 
diff --git a/codecs_v2/omx/omx_h264/src/avc_dec.cpp b/codecs_v2/omx/omx_h264/src/avc_dec.cpp
index 345c432..8c221ce 100644
--- a/codecs_v2/omx/omx_h264/src/avc_dec.cpp
+++ b/codecs_v2/omx/omx_h264/src/avc_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,20 +18,11 @@
 #include "oscl_types.h"
 #include "avc_dec.h"
 #include "avcdec_int.h"
-#include "pv_omxcore.h"
 
 
 /*************************************/
 /* functions needed for video engine */
 /*************************************/
-// init static members of AvcDecoder class
-OMX_TICKS AvcDecoder_OMX::CurrInputTimestamp = 0;
-uint8* AvcDecoder_OMX::pDpbBuffer = NULL;
-uint32 AvcDecoder_OMX::FrameSize = 0;
-OMX_U32 AvcDecoder_OMX::iAvcDecoderCounterInstance = 0;
-OMX_TICKS	AvcDecoder_OMX::DisplayTimestampArray[] = {0};
-AVCHandle	AvcDecoder_OMX::AvcHandle;
-AVCDecSPSInfo	AvcDecoder_OMX::SeqInfo;
 
 /* These two functions are for callback functions of AvcHandle */
 int32 CBAVC_Malloc_OMX(void* aUserData, int32 aSize, int32 aAttribute)
@@ -59,14 +50,18 @@
     return AVCDEC_FAIL;  /* nothing for now */
 }
 
-
 int32 AvcDecoder_OMX::AllocateBuffer_OMX(void* aUserData, int32 i, uint8** aYuvBuffer)
 {
-    OSCL_UNUSED_ARG(aUserData);
-    //printf("Index %d\n", i);
-    *aYuvBuffer = pDpbBuffer + i * FrameSize;
+    AvcDecoder_OMX* pAvcDecoder_OMX = (AvcDecoder_OMX*)aUserData;
+
+    if (NULL == pAvcDecoder_OMX)
+    {
+        return 0;
+    }
+
+    *aYuvBuffer = pAvcDecoder_OMX->pDpbBuffer + i * pAvcDecoder_OMX->FrameSize;
     //Store the input timestamp at the correct index
-    DisplayTimestampArray[i] = CurrInputTimestamp;
+    pAvcDecoder_OMX->DisplayTimestampArray[i] = pAvcDecoder_OMX->CurrInputTimestamp;
     return 1;
 }
 
@@ -80,19 +75,25 @@
 
 int32 AvcDecoder_OMX::ActivateSPS_OMX(void* aUserData, uint aSizeInMbs, uint aNumBuffers)
 {
-    OSCL_UNUSED_ARG(aUserData);
-    PVAVCDecGetSeqInfo(&(AvcHandle), &(SeqInfo));
+    AvcDecoder_OMX* pAvcDecoder_OMX = (AvcDecoder_OMX*)aUserData;
 
-    if (pDpbBuffer)
+    if (NULL == pAvcDecoder_OMX)
     {
-        oscl_free(pDpbBuffer);
-        pDpbBuffer = NULL;
+        return 0;
     }
 
-    FrameSize = (aSizeInMbs << 7) * 3;
-    pDpbBuffer = (uint8*) oscl_malloc(aNumBuffers * (FrameSize));
-    return 1;
+    PVAVCDecGetSeqInfo(&(pAvcDecoder_OMX->AvcHandle), &(pAvcDecoder_OMX->SeqInfo));
 
+    if (pAvcDecoder_OMX->pDpbBuffer)
+    {
+        oscl_free(pAvcDecoder_OMX->pDpbBuffer);
+        pAvcDecoder_OMX->pDpbBuffer = NULL;
+    }
+
+    pAvcDecoder_OMX->FrameSize = (aSizeInMbs << 7) * 3;
+    pAvcDecoder_OMX->pDpbBuffer = (uint8*) oscl_malloc(aNumBuffers * (pAvcDecoder_OMX->FrameSize));
+
+    return 1;
 }
 
 /* initialize video decoder */
@@ -100,7 +101,7 @@
 {
     /* Initialize AvcHandle */
     AvcHandle.AVCObject = NULL;
-    AvcHandle.userData = NULL;
+    AvcHandle.userData = (void*)this;
     AvcHandle.CBAVC_DPBAlloc = ActivateSPS_OMX;
     AvcHandle.CBAVC_FrameBind = AllocateBuffer_OMX;
     AvcHandle.CBAVC_FrameUnbind = UnbindBuffer_OMX;
@@ -159,9 +160,6 @@
     //Set up the cleanup object in order to do clean up work automatically
     pCleanObject = OSCL_NEW(AVCCleanupObject_OMX, (&AvcHandle));
 
-    DecodeSliceFlag = OMX_FALSE;
-    pNalBufferTemp = NULL;
-
     return OMX_ErrorNone;
 }
 
@@ -176,9 +174,9 @@
     OMX_S32 Width, Height;
     OMX_S32 crop_top, crop_bottom, crop_right, crop_left;
     uint8* pNalBuffer;
-    int32 NalSize, NalType, NalRefId, PicType;
+    int32 NalSize, NalType, NalRefId;
+    //int32 PicType;
     AVCDecObject* pDecVid;
-    static int32 FrameNo;
 
     *aResizeFlag = OMX_FALSE;
     OMX_U32 OldWidth, OldHeight;
@@ -187,25 +185,6 @@
     OldHeight = aPortParam->format.video.nFrameHeight;
 
 
-    if (OMX_TRUE == DecodeSliceFlag)
-    {
-        Status = (AVCDec_Status) FlushOutput_OMX(aOutBuffer, aOutputLength, aOutTimestamp, OldWidth, OldHeight);
-
-        if ((Status = PVAVCDecodeSlice(&(AvcHandle), pNalBufferTemp, NalSizeTemp)) == AVCDEC_PICTURE_OUTPUT_READY)
-        {
-            DecodeSliceFlag = OMX_TRUE;
-        }
-        else
-        {
-            if (pNalBufferTemp)
-                oscl_free(pNalBufferTemp);
-            pNalBufferTemp = NULL;
-            DecodeSliceFlag = OMX_FALSE;
-        }
-
-        return OMX_TRUE;
-    }
-
     if (!aMarkerFlag)
     {
         if (AVCDEC_FAIL == GetNextFullNAL_OMX(&pNalBuffer, &NalSize, *aInputBuf, aInBufSize))
@@ -277,7 +256,7 @@
         // FORCE RESIZE ALWAYS FOR SPS
         *aResizeFlag = OMX_TRUE;
 
-        *iFrameCount = 1;
+        (*iFrameCount)++;
 
     }
 
@@ -294,22 +273,30 @@
     {
         if ((Status = PVAVCDecodeSlice(&(AvcHandle), pNalBuffer, NalSize)) == AVCDEC_PICTURE_OUTPUT_READY)
         {
-            Status = (AVCDec_Status) FlushOutput_OMX(aOutBuffer, aOutputLength, aOutTimestamp, OldWidth, OldHeight);
+            FlushOutput_OMX(aOutBuffer, aOutputLength, aOutTimestamp, OldWidth, OldHeight);
 
-            if ((Status = PVAVCDecodeSlice(&(AvcHandle), pNalBuffer, NalSize)) == AVCDEC_PICTURE_OUTPUT_READY)
+            //Input buffer not consumed yet, do not mark it free.
+            if (aMarkerFlag)
             {
-                pNalBufferTemp = (uint8*) oscl_malloc(NalSize);
-                oscl_memcpy(pNalBufferTemp, pNalBuffer, NalSize);
-                NalSizeTemp = NalSize;
-                DecodeSliceFlag = OMX_TRUE;
-
+                *aInBufSize = NalSize;
+            }
+            else
+            {
+                *aInBufSize += InputBytesConsumed;
+                aInputBuf -= InputBytesConsumed;
             }
         }
 
         if (Status == AVCDEC_PICTURE_READY)
         {
-            FrameNo++;
-            //printf("decode frame %d \n", FrameNo);
+            (*iFrameCount)++;
+        }
+
+        if ((AVCDEC_NO_DATA == Status) || (AVCDEC_PACKET_LOSS == Status) ||
+                (AVCDEC_NO_BUFFER == Status) || (AVCDEC_MEMORY_FAIL == Status) ||
+                (AVCDEC_FAIL == Status))
+        {
+            return OMX_FALSE;
         }
     }
 
@@ -323,18 +310,21 @@
 
     else if ((AVCNalUnitType)NalType == AVC_NALTYPE_AUD)
     {
-        PicType = pNalBuffer[1] >> 5;
+        //PicType = pNalBuffer[1] >> 5;
     }
 
-    else if ((AVCNalUnitType)NalType == AVC_NALTYPE_EOSTREAM) // end of stream
+    else if ((AVCNalUnitType)NalType == AVC_NALTYPE_EOSTREAM || // end of stream
+             (AVCNalUnitType)NalType == AVC_NALTYPE_EOSEQ || // end of sequence
+             (AVCNalUnitType)NalType == AVC_NALTYPE_FILL) // filler data
     {
         return OMX_TRUE;
     }
 
-    else
-    {
-        printf("\nNAL_type = %d, unsupported nal type or not sure what to do for this type\n", NalType);
-    }
+    //else
+    //{
+    //printf("\nNAL_type = %d, unsupported nal type or not sure what to do for this type\n", NalType);
+    //	return OMX_FALSE;
+    //}
     return OMX_TRUE;
 
 }
@@ -360,7 +350,6 @@
 
 AVCDec_Status AvcDecoder_OMX::GetNextFullNAL_OMX(uint8** aNalBuffer, int32* aNalSize, OMX_U8* aInputBuf, OMX_U32* aInBufSize)
 {
-    uint32 BuffConsumed;
     uint8* pBuff = aInputBuf;
     OMX_U32 InputSize;
 
@@ -374,9 +363,9 @@
         return AVCDEC_FAIL;
     }
 
-    BuffConsumed = ((*aNalSize) + (int32)(*aNalBuffer - pBuff));
-    aInputBuf += BuffConsumed;
-    *aInBufSize = InputSize - BuffConsumed;
+    InputBytesConsumed = ((*aNalSize) + (int32)(*aNalBuffer - pBuff));
+    aInputBuf += InputBytesConsumed;
+    *aInBufSize = InputSize - InputBytesConsumed;
 
     return AVCDEC_SUCCESS;
 }
@@ -387,3 +376,8 @@
 
 }
 
+void AvcDecoder_OMX::ResetDecoder()
+{
+    PVAVCDecReset(&(AvcHandle));
+}
+
diff --git a/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp b/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp
old mode 100755
new mode 100644
index 7daa121..d81b5dd
--- a/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp
+++ b/codecs_v2/omx/omx_h264/src/omx_avc_component.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,22 +15,30 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#include "oscl_base.h"
+#include "omx_types.h"
 #include "pv_omxdefs.h"
-#include "oscl_types.h"
 #include "omx_avc_component.h"
 
-
-extern OMX_U32 g_ComponentIndex; // this is determined outside the component
-
 #if PROXY_INTERFACE
-
 #include "omx_proxy_interface.h"
-extern ProxyApplication_OMX* pProxyTerm[];
 #endif
 
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
 // This function is called by OMX_GetHandle and it creates an instance of the avc component AO
-OMX_ERRORTYPE AvcOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
+OSCL_EXPORT_REF OMX_ERRORTYPE AvcOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy , OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     OpenmaxAvcAO* pOpenmaxAOType;
     OMX_ERRORTYPE Status;
 
@@ -44,7 +52,7 @@
     }
 
     //Call the construct component to initialize OMX types
-    Status = pOpenmaxAOType->ConstructComponent(pAppData);
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
 
     *pHandle = pOpenmaxAOType->GetOmxHandle();
 
@@ -53,8 +61,12 @@
 }
 
 // This function is called by OMX_FreeHandle when component AO needs to be destroyed
-OMX_ERRORTYPE AvcOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle)
+OSCL_EXPORT_REF OMX_ERRORTYPE AvcOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     // get pointer to component AO
     OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
 
@@ -67,34 +79,86 @@
     return OMX_ErrorNone;
 }
 
+#if DYNAMIC_LOAD_OMX_AVC_COMPONENT
+class OsclSharedLibraryInterface;
+class AvcOmxSharedLibraryInterface: public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static AvcOmxSharedLibraryInterface *Instance()
+        {
+            static AvcOmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_AVCDEC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AvcOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AvcOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        AvcOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return AvcOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE OpenmaxAvcAO::ConstructComponent(OMX_PTR pAppData)
+OMX_ERRORTYPE OpenmaxAvcAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
 {
-    AvcComponentPortType* pInPort, *pOutPort;
-    OMX_U32 ii;
+    ComponentPortType* pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
 
     iNumPorts = 2;
     iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
     iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
     iOmxComponent.pApplicationPrivate = pAppData; // init the App data
 
 
 #if PROXY_INTERFACE
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
 
-    iOmxComponent.SendCommand = WrapperSendCommand;
-    iOmxComponent.GetParameter = WrapperGetParameter;
-    iOmxComponent.SetParameter = WrapperSetParameter;
-    iOmxComponent.GetConfig = WrapperGetConfig;
-    iOmxComponent.SetConfig = WrapperSetConfig;
-    iOmxComponent.GetExtensionIndex = WrapperGetExtensionIndex;
-    iOmxComponent.GetState = WrapperGetState;
-    iOmxComponent.UseBuffer = WrapperUseBuffer;
-    iOmxComponent.AllocateBuffer = WrapperAllocateBuffer;
-    iOmxComponent.FreeBuffer = WrapperFreeBuffer;
-    iOmxComponent.EmptyThisBuffer = WrapperEmptyThisBuffer;
-    iOmxComponent.FillThisBuffer = WrapperFillThisBuffer;
+    iOmxComponent.SendCommand = OpenmaxAvcAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OpenmaxAvcAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OpenmaxAvcAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OpenmaxAvcAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OpenmaxAvcAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OpenmaxAvcAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OpenmaxAvcAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OpenmaxAvcAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OpenmaxAvcAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OpenmaxAvcAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OpenmaxAvcAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OpenmaxAvcAO::BaseComponentProxyFillThisBuffer;
 
 #else
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
@@ -123,6 +187,9 @@
     iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
 
     if (ipAppPriv)
     {
@@ -130,60 +197,23 @@
         ipAppPriv = NULL;
     }
 
-    ipAppPriv = (AvcPrivateType*) oscl_malloc(sizeof(AvcPrivateType));
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
     if (NULL == ipAppPriv)
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    if (iNumPorts)
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
     {
-        if (ipPorts)
-        {
-            oscl_free(ipPorts);
-            ipPorts = NULL;
-        }
-
-        ipPorts = (AvcComponentPortType**) oscl_calloc(iNumPorts, sizeof(AvcComponentPortType*));
-        if (!ipPorts)
-        {
-            return OMX_ErrorInsufficientResources;
-        }
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii] = (AvcComponentPortType*) oscl_calloc(1, sizeof(AvcComponentPortType));
-            if (!ipPorts[ii])
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            ipPorts[ii]->TransientState = OMX_StateMax;
-            SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            ipPorts[ii]->PortParam.nPortIndex = ii;
-
-            /** Allocate and initialize buffer Queue */
-            ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-
-            if (NULL == ipPorts[ii]->pBufferQueue)
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            QueueInit(ipPorts[ii]->pBufferQueue);
-
-            ipPorts[ii]->LoadedToIdleFlag = OMX_FALSE;
-            ipPorts[ii]->IdleToLoadedFlag = OMX_FALSE;
-
-        }
-
-        AvcComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-        AvcComponentSetNumBufferFlush(iNumPorts, -1, OMX_FALSE);
+        return Status;
     }
 
     /** Domain specific section for the ports. */
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainVideo;
-    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.cMIMEType = "video/Avc";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"video/Avc";
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.pNativeRender = 0;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
@@ -202,7 +232,7 @@
 
 
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainVideo;
-    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.cMIMEType = "raw";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"raw";
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.pNativeRender = 0;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
@@ -231,75 +261,30 @@
     iPortTypesParam.nPorts = 2;
     iPortTypesParam.nStartPortNumber = 0;
 
-    pInPort = (AvcComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    pOutPort = (AvcComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
-    SetHeader(&pInPort->VideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-    pInPort->VideoParam.nPortIndex = 0;
-    pInPort->VideoParam.nIndex = 0;
-    pInPort->VideoParam.eCompressionFormat = OMX_VIDEO_CodingAVC;
-    pInPort->VideoParam.eColorFormat = OMX_COLOR_FormatUnused;
+    pInPort->ActualNumPortFormatsSupported = 1;
 
-    SetHeader(&pOutPort->VideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-    pOutPort->VideoParam.nPortIndex = 1;
-    pOutPort->VideoParam.nIndex = 0;
-    pOutPort->VideoParam.eCompressionFormat = OMX_VIDEO_CodingUnused;
-    pOutPort->VideoParam.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE INPUT PORT SETTINGS
+    //On input port for index 0
+    SetHeader(&pInPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[0].nPortIndex = 0;
+    pInPort->VideoParam[0].nIndex = 0;
+    pInPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingAVC;
+    pInPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatUnused;
 
-    iCodecReady = OMX_FALSE;
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-    ipTempInputBuffer = NULL;
-    iTempInputBufferLength = 0;
-    iNumInputBuffer = 0;
-    iPartialFrameAssembly = OMX_FALSE;
-    iEndofStream = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iNewInBufferRequired = OMX_TRUE;
-    iNewOutBufRequired = OMX_TRUE;
+    pOutPort->ActualNumPortFormatsSupported = 1;
 
-    /* Initialize the asynchronous command Queue  */
-    if (ipCoreDescriptor)
-    {
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE OUTPUT PORT SETTINGS
+    //On output port for index 0
+    SetHeader(&pOutPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pOutPort->VideoParam[0].nPortIndex = 1;
+    pOutPort->VideoParam[0].nIndex = 0;
+    pOutPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pOutPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatYUV420Planar;
 
-    ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType));
-    if (NULL == ipCoreDescriptor)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    ipCoreDescriptor->pMessageQueue = NULL;
-    ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-    if (NULL == ipCoreDescriptor->pMessageQueue)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    QueueInit(ipCoreDescriptor->pMessageQueue);
-
-    /** Default parameters setting */
-    iIsInit = OMX_FALSE;
-    iGroupPriority = 0;
-    iGroupID = 0;
-    ipMark = NULL;
-
-    SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-
-    iOutBufferCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    iFirstFragment = OMX_FALSE;
-    iMarkPropagate = OMX_FALSE;
-
-    //Will be used in case of partial frame assembly
-    ipInputCurrBuffer = NULL;
-    iInputCurrBufferSize = 0;
-    ipAppPriv->AvcHandle = &iOmxComponent;
+    iDecodeReturn = OMX_FALSE;
 
     if (ipAvcDec)
     {
@@ -317,18 +302,18 @@
 
 #if PROXY_INTERFACE
 
-    pProxyTerm[g_ComponentIndex]->ComponentSendCommand = BaseComponentSendCommand;
-    pProxyTerm[g_ComponentIndex]->ComponentGetParameter = BaseComponentGetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentSetParameter = BaseComponentSetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentGetConfig = BaseComponentGetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentSetConfig = BaseComponentSetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
-    pProxyTerm[g_ComponentIndex]->ComponentGetState = BaseComponentGetState;
-    pProxyTerm[g_ComponentIndex]->ComponentUseBuffer = BaseComponentUseBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFreeBuffer = BaseComponentFreeBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
 
 #endif
 
@@ -336,541 +321,80 @@
 }
 
 
-/*********************
- *
- * Component verfication routines
- *
- **********************/
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	* \param Component, the component to be disposed
+	*/
 
-void OpenmaxAvcAO::SetHeader(OMX_PTR aHeader, OMX_U32 aSize)
+OMX_ERRORTYPE OpenmaxAvcAO::DestroyComponent()
 {
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-    *((OMX_U32*) aHeader) = aSize;
-
-    pVersion->s.nVersionMajor = SPECVERSIONMAJOR;
-    pVersion->s.nVersionMinor = SPECVERSIONMINOR;
-    pVersion->s.nRevision = SPECREVISION;
-    pVersion->s.nStep = SPECSTEP;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize)
-{
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-
-    if (NULL == aHeader)
+    if (iIsInit != OMX_FALSE)
     {
-        return OMX_ErrorBadParameter;
+        ComponentDeInit();
     }
 
-    if (*((OMX_U32*) aHeader) != aSize)
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipAvcDec)
     {
-        return OMX_ErrorBadParameter;
+        OSCL_DELETE(ipAvcDec);
+        ipAvcDec = NULL;
     }
 
-    if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR ||
-            pVersion->s.nVersionMinor != SPECVERSIONMINOR ||
-            pVersion->s.nRevision != SPECREVISION ||
-            pVersion->s.nStep != SPECSTEP)
+    if (ipAppPriv)
     {
-        return OMX_ErrorVersionMismatch;
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
     }
 
     return OMX_ErrorNone;
 }
 
 
-/**
- * This function verify component state and structure header
+/* This function will be called in case of buffer management without marker bit present
+ * The purpose is to copy the current input buffer into a big temporary buffer, so that
+ * an incomplete/partial frame is never passed to the decoder library for decode
  */
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentParameterSanityCheck(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_PTR pStructure,
-    OMX_IN  size_t size)
+void OpenmaxAvcAO::ComponentBufferMgmtWithoutMarker()
 {
-
-    OSCL_UNUSED_ARG(hComponent);
-    if (iState != OMX_StateLoaded &&
-            iState != OMX_StateWaitForResources)
-    {
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if (nPortIndex >= iNumPorts)
-    {
-        return OMX_ErrorBadPortIndex;
-    }
-
-    return CheckHeader(pStructure, size);
-}
-
-/**
- * Set/Reset Port Flush Flag
- */
-void OpenmaxAvcAO::AvcComponentSetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    {
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->IsPortFlushed = value;
-    }
-
-}
-
-/**
- * Set Number of Buffer Flushed with the value Specified
- */
-void OpenmaxAvcAO::AvcComponentSetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    { // For all ComponentPort
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->NumBufferFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->NumBufferFlushed = value;
-    }
+    //This common routine has been written in the base class
+    TempInputBufferMgmtWithoutMarker();
 }
 
 
-/** This function assembles multiple input buffers into
-	* one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set
-	*/
 
-OMX_BOOL OpenmaxAvcAO::AvcComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer)
+void OpenmaxAvcAO::ProcessData()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentAssemblePartialFrames IN"));
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    AvcComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    ipAvcInputBuffer = aInputBuffer;
-    OMX_U32 BytesToCopy = 0;
-
-    if (!iPartialFrameAssembly)
-    {
-        if (iNumInputBuffer > 0)
-        {
-            if (ipAvcInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-            {
-                iInputCurrLength = ipAvcInputBuffer->nFilledLen;
-                ipFrameDecodeBuffer = ipAvcInputBuffer->pBuffer + ipAvcInputBuffer->nOffset;
-                //capture the timestamp to be send to the corresponding output buffer
-                iFrameTimestamp = ipAvcInputBuffer->nTimeStamp;
-            }
-            else
-            {
-                iInputCurrLength = 0;
-                iPartialFrameAssembly = OMX_TRUE;
-                iFirstFragment = OMX_TRUE;
-                iFrameTimestamp = ipAvcInputBuffer->nTimeStamp;
-                ipFrameDecodeBuffer = ipInputCurrBuffer;
-            }
-
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentAssemblePartialFrames ERROR"));
-            return OMX_FALSE;
-        }
-
-    }
-
-    //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked
-    if (iPartialFrameAssembly)
-    {
-        while (iNumInputBuffer > 0)
-        {
-            if (OMX_FALSE == iFirstFragment)
-            {
-                /* If the timestamp of curr fragment doesn't match with previous,
-                 * discard the previous fragments & start reconstructing from new
-                 */
-                if (iFrameTimestamp != ipAvcInputBuffer->nTimeStamp)
-                {
-                    iInputCurrLength = 0;
-                    iPartialFrameAssembly = OMX_TRUE;
-                    iFirstFragment = OMX_TRUE;
-                    iFrameTimestamp = ipAvcInputBuffer->nTimeStamp;
-                    ipFrameDecodeBuffer = ipInputCurrBuffer;
-                }
-            }
-
-            if ((ipAvcInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
-            {
-                break;
-            }
-
-            // check if the buffer size can take the new piece, or it needs to expand
-            BytesToCopy = ipAvcInputBuffer->nFilledLen;
-
-            if (iInputCurrBufferSize < (iInputCurrLength + BytesToCopy))
-            {
-
-
-                // allocate new partial frame buffer
-                OMX_U8 *temp_new_buffer = NULL;
-                temp_new_buffer = (OMX_U8 *) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
-
-                // in the event that new buffer cannot be allocated
-                if (temp_new_buffer == NULL)
-                {
-                    // copy into what space is available, and let the decoder complain
-                    BytesToCopy = iInputCurrLength - iInputCurrBufferSize;
-                }
-                else
-                {
-
-                    // copy contents of the old buffer into the new one
-                    oscl_memcpy(temp_new_buffer, ipInputCurrBuffer, iInputCurrBufferSize);
-                    // free the old buffer
-                    if (ipInputCurrBuffer)
-                        oscl_free(ipInputCurrBuffer);
-                    // assign new one
-                    ipInputCurrBuffer = temp_new_buffer;
-                    iInputCurrBufferSize = (iInputCurrLength + BytesToCopy);
-                    ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
-                }
-            }
-
-
-            iInputCurrLength += BytesToCopy;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAvcInputBuffer->pBuffer + ipAvcInputBuffer->nOffset), BytesToCopy); // copy buffer data
-            ipFrameDecodeBuffer += BytesToCopy; // move the ptr
-
-            ipAvcInputBuffer->nFilledLen = 0;
-
-            AvcComponentReturnInputBuffer(ipAvcInputBuffer, pInPort);
-
-            iFirstFragment = OMX_FALSE;
-
-            if (iNumInputBuffer > 0)
-            {
-                ipAvcInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (ipAvcInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentAssemblePartialFrames EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers
-        if (0 == iNumInputBuffer)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentAssemblePartialFrames OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            // we have found the buffer that is the last piece of the frame.
-            // Copy the buffer, but do not release it yet (this will be done after decoding for consistency)
-
-            BytesToCopy = ipAvcInputBuffer->nFilledLen;
-            // check if the buffer size can take the new piece, or it needs to expand
-            if (iInputCurrBufferSize < (iInputCurrLength + BytesToCopy))
-            {
-                // allocate new partial frame buffer
-                OMX_U8 *temp_new_buffer = NULL;
-                temp_new_buffer = (OMX_U8 *) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
-
-                // if you cannot allocate new buffer, just copy what data you can
-                if (temp_new_buffer == NULL)
-                {
-                    BytesToCopy = iInputCurrBufferSize - iInputCurrLength;
-                }
-                else
-                {
-
-                    // copy contents of the old one into new one
-                    oscl_memcpy(temp_new_buffer, ipInputCurrBuffer, iInputCurrBufferSize);
-                    // free the old buffer
-                    if (ipInputCurrBuffer)
-                        oscl_free(ipInputCurrBuffer);
-                    // assign new one
-                    ipInputCurrBuffer = temp_new_buffer;
-                    iInputCurrBufferSize = (iInputCurrLength + BytesToCopy);
-                    ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
-                }
-            }
-
-            iInputCurrLength += BytesToCopy;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipAvcInputBuffer->pBuffer + ipAvcInputBuffer->nOffset), BytesToCopy); // copy buffer data
-            ipFrameDecodeBuffer += BytesToCopy; // move the ptr
-
-            ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer
-            iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentAssemblePartialFrames OUT"));
-    return OMX_TRUE;
-}
-
-
-/** This is the central function for buffers processing and decoding.
-	* It is called through the Run() of active object when the component is in executing state
-	* and is signalled each time a new buffer is available on the given ports
-	* This function will process the input buffers & return output buffers
-	*/
-
-void OpenmaxAvcAO::AvcComponentBufferMgmtFunction()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentBufferMgmtFunction IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    AvcComponentPortType* pInPort = (AvcComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-    OMX_BOOL PartialFrameReturn;
-
-    /* Don't dequeue any further buffer after endofstream buffer has been dequeued
-     * till we send the callback and reset the flag back to false
-     */
-    if (OMX_FALSE == iEndofStream)
-    {
-        //More than one frame can't be dequeued in case of outbut blocked
-        if ((OMX_TRUE == iNewInBufferRequired) && (GetQueueNumElem(pInputQueue) > 0))
-        {
-            ipAvcInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-
-            if (ipAvcInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentBufferMgmtFunction EndOfStream arrived"));
-                iEndofStream = OMX_TRUE;
-            }
-
-            if (0 != ipAvcInputBuffer->nFilledLen)
-            {
-                if (0 == iFrameCount)
-                {
-                    //Set the marker flag (iEndOfFrameFlag) if first frame has the EnfOfFrame flag marked.
-                    if (ipAvcInputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentBufferMgmtFunction EndOfFrame flag present"));
-                        iEndOfFrameFlag = OMX_TRUE;
-                    }
-                }
-
-                /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is
-                 *  not marked in all the input buffers
-                 */
-                if (!iEndOfFrameFlag)
-                {
-                    AvcBufferMgmtWithoutMarker(ipAvcInputBuffer);
-
-                }
-                //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here
-                else
-                {
-                    PartialFrameReturn = AvcComponentAssemblePartialFrames(ipAvcInputBuffer);
-                    if (OMX_FALSE == PartialFrameReturn)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-                    iIsInputBufferEnded = OMX_FALSE;
-
-                    ipTargetComponent = (OMX_COMPONENTTYPE*) ipAvcInputBuffer->hMarkTargetComponent;
-
-                    iTargetMarkData = ipAvcInputBuffer->pMarkData;
-                    if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventMark,
-                         1,
-                         0,
-                         ipAvcInputBuffer->pMarkData);
-                    }
-                }
-
-            }	//end braces for if (ipAvcInputBuffer->nFilledLen != 0)
-            else
-            {
-                AvcComponentReturnInputBuffer(ipAvcInputBuffer, pInPort);
-            }
-
-        }	//end braces for if ((OMX_TRUE == iNewInBufferRequired) && (GetQueueNumElem(pInputQueue) > 0))
-    }	//if (OMX_FALSE == iEndofStream)
-
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ProcessData IN"));
     if (!iEndOfFrameFlag)
     {
-        AvcDecodeWithoutMarker();
+        DecodeWithoutMarker();
     }
     else
     {
-        AvcDecodeWithMarker(ipAvcInputBuffer);
+        DecodeWithMarker();
     }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentBufferMgmtFunction OUT"));
-    return;
-}
-
-/* Assemble the partial frames in case of buffers without end of frame flag marked */
-
-void OpenmaxAvcAO::AvcBufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE* pAvcInputBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcBufferMgmtWithoutMarker IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    AvcComponentPortType*	pInPort = (AvcComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_U32 TempInputBufferSize = (2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-
-
-    /* Assembling of partial frame will be done based on max input buf size
-     * If Flushport flag is true, that means its not a partial frame
-     * but an unconsumed frame, process it independently
-     * Same is true for endofstream condition, process the buffer independently
-     */
-    if ((pAvcInputBuffer->nFilledLen < pAvcInputBuffer->nAllocLen)
-            && (OMX_TRUE != iEndofStream) && (OMX_FALSE == iFlushPortFlag))
-    {
-        if (!iPartialFrameAssembly)
-        {
-            iInputCurrLength = 0;
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-        }
-
-        while (iNumInputBuffer > 0)
-        {
-            oscl_memcpy(ipFrameDecodeBuffer, (pAvcInputBuffer->pBuffer + pAvcInputBuffer->nOffset), pAvcInputBuffer->nFilledLen);
-            ipFrameDecodeBuffer += pAvcInputBuffer->nFilledLen; // move the ptr
-
-            iFrameTimestamp = pAvcInputBuffer->nTimeStamp;
-
-            if (((iInputCurrLength += pAvcInputBuffer->nFilledLen) >= pAvcInputBuffer->nAllocLen)
-                    || OMX_TRUE == iEndofStream)
-            {
-                break;
-            }
-
-            //Set the filled len to zero to indiacte buffer is fully consumed
-            pAvcInputBuffer->nFilledLen = 0;
-            AvcComponentReturnInputBuffer(pAvcInputBuffer, pInPort);
-
-            if (iNumInputBuffer > 0)
-            {
-                pAvcInputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (pAvcInputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcBufferMgmtWithoutMarker EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        if (((iInputCurrLength < pAvcInputBuffer->nAllocLen)) && OMX_TRUE != iEndofStream)
-        {
-            iPartialFrameAssembly = OMX_TRUE;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcBufferMgmtWithoutMarker OUT"));
-            return;
-        }
-        else
-        {
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-            iPartialFrameAssembly = OMX_FALSE;
-        }
-    }
-    else
-    {
-        if (iNumInputBuffer > 0)
-        {
-            iInputCurrLength = pAvcInputBuffer->nFilledLen;
-            ipFrameDecodeBuffer = pAvcInputBuffer->pBuffer + pAvcInputBuffer->nOffset;
-            iFrameTimestamp = pAvcInputBuffer->nTimeStamp;
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcBufferMgmtWithoutMarker OUT"));
-            return; // nothing to decode
-        }
-    }
-
-    if (iTempInputBufferLength < (TempInputBufferSize >> 1))
-    {
-        oscl_memmove(ipTempInputBuffer, &ipTempInputBuffer[iTempConsumedLength], iTempInputBufferLength);
-        iIsInputBufferEnded = OMX_TRUE;
-        iTempConsumedLength = 0;
-    }
-
-    if ((iTempInputBufferLength + iTempConsumedLength + iInputCurrLength)
-            <= TempInputBufferSize)
-    {
-        oscl_memcpy(&ipTempInputBuffer[iTempInputBufferLength + iTempConsumedLength], ipFrameDecodeBuffer, iInputCurrLength);
-        iTempInputBufferLength += iInputCurrLength;
-
-        if (iTempInputBufferLength + (TempInputBufferSize >> 1) <= TempInputBufferSize)
-        {
-            iNewInBufferRequired = OMX_TRUE;
-        }
-        else
-        {
-            iNewInBufferRequired = OMX_FALSE;
-        }
-
-        ipTargetComponent = (OMX_COMPONENTTYPE*) pAvcInputBuffer->hMarkTargetComponent;
-
-        iTargetMarkData = pAvcInputBuffer->pMarkData;
-        if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-        {
-            (*(ipCallbacks->EventHandler))
-            (pHandle,
-             iCallbackData,
-             OMX_EventMark,
-             1,
-             0,
-             pAvcInputBuffer->pMarkData);
-        }
-        pAvcInputBuffer->nFilledLen = 0;
-        AvcComponentReturnInputBuffer(pAvcInputBuffer, pInPort);
-
-    }
-
-    if (iTempInputBufferLength >= (TempInputBufferSize >> 1))
-    {
-        iIsInputBufferEnded = OMX_FALSE;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcBufferMgmtWithoutMarker OUT"));
-    return;
-
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ProcessData OUT"));
 }
 
 
 /* Decoding function for input buffers without end of frame flag marked */
-void OpenmaxAvcAO::AvcDecodeWithoutMarker()
+void OpenmaxAvcAO::DecodeWithoutMarker()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithoutMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker IN"));
 
     QueueType*				pInputQueue  = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType*				pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-    AvcComponentPortType*	pOutPort =     ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType*	pOutPort =     ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
     OMX_COMPONENTTYPE *		pHandle =      &iOmxComponent;
 
     OMX_U8*					pOutBuffer;
     OMX_U32					OutputLength;
     OMX_U8*					pTempInBuffer;
     OMX_U32					TempInLength;
-    OMX_BOOL				DecodeReturn;
     OMX_BOOL				MarkerFlag = OMX_FALSE;
     OMX_TICKS				TempTimestamp;
     OMX_BOOL				ResizeNeeded = OMX_FALSE;
@@ -888,7 +412,7 @@
             //Check whether a new output buffer is available or not
             if (0 == (GetQueueNumElem(pOutputQueue)))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithoutMarker OUT output buffer unavailable"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker OUT output buffer unavailable"));
                 //Store the mark data for output buffer, as it will be overwritten next time
                 if (NULL != ipTargetComponent)
                 {
@@ -899,15 +423,22 @@
                 return;
             }
 
-            ipAvcOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            //Do not proceed if the output buffer can't fit the YUV data
-            if (ipAvcOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) * ((CurrHeight + 15)&(~15)) * 3 / 2))
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
             {
-                ipAvcOutputBuffer->nFilledLen = 0;
-                AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker Error, output buffer dequeue returned NULL, OUT"));
                 return;
             }
-            ipAvcOutputBuffer->nFilledLen = 0;
+
+            //Do not proceed if the output buffer can't fit the YUV data
+            if (ipOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) * ((CurrHeight + 15)&(~15)) * 3 / 2))
+            {
+                ipOutputBuffer->nFilledLen = 0;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
         }
 
@@ -917,56 +448,56 @@
          */
         if (NULL != ipMark)
         {
-            ipAvcOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipAvcOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if ((OMX_TRUE == iMarkPropagate) && (ipTempTargetComponent != ipTargetComponent))
         {
-            ipAvcOutputBuffer->hMarkTargetComponent = ipTempTargetComponent;
-            ipAvcOutputBuffer->pMarkData = iTempTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTempTargetComponent;
+            ipOutputBuffer->pMarkData = iTempTargetMarkData;
             ipTempTargetComponent = NULL;
             iMarkPropagate = OMX_FALSE;
         }
         else if (ipTargetComponent != NULL)
         {
-            ipAvcOutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipAvcOutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
             iMarkPropagate = OMX_FALSE;
         }
         //Mark buffer code ends here
 
-        pOutBuffer = ipAvcOutputBuffer->pBuffer;
+        pOutBuffer = ipOutputBuffer->pBuffer;
         OutputLength = 0;
 
         pTempInBuffer = ipTempInputBuffer + iTempConsumedLength;
         TempInLength = iTempInputBufferLength;
 
         //Output buffer is passed as a short pointer
-        DecodeReturn = ipAvcDec->AvcDecodeVideo_OMX(pOutBuffer, (OMX_U32*) & OutputLength,
-                       &(pTempInBuffer),
-                       &TempInLength,
-                       &(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam),
-                       &iFrameCount,
-                       MarkerFlag, &TempTimestamp, &ResizeNeeded);
+        iDecodeReturn = ipAvcDec->AvcDecodeVideo_OMX(pOutBuffer, (OMX_U32*) & OutputLength,
+                        &(pTempInBuffer),
+                        &TempInLength,
+                        &(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam),
+                        &iFrameCount,
+                        MarkerFlag, &TempTimestamp, &ResizeNeeded);
 
-        ipAvcOutputBuffer->nFilledLen = OutputLength;
+        ipOutputBuffer->nFilledLen = OutputLength;
 
         //offset not required in our case, set it to zero
-        ipAvcOutputBuffer->nOffset = 0;
+        ipOutputBuffer->nOffset = 0;
 
         //Set the timestamp equal to the input buffer timestamp
-        ipAvcOutputBuffer->nTimeStamp = iFrameTimestamp;
+        ipOutputBuffer->nTimeStamp = iFrameTimestamp;
 
         iTempConsumedLength += (iTempInputBufferLength - TempInLength);
         iTempInputBufferLength = TempInLength;
 
         //If decoder returned error, report it to the client via a callback
-        if (!DecodeReturn && OMX_FALSE == iEndofStream)
+        if (!iDecodeReturn && OMX_FALSE == iEndofStream)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithoutMarker ErrorStreamCorrupt callback send"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker ErrorStreamCorrupt callback send"));
 
             (*(ipCallbacks->EventHandler))
             (pHandle,
@@ -987,7 +518,7 @@
 
         if (ResizeNeeded == OMX_TRUE)
         {
-            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->AvcHandle;
+            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
 
             iResizePending = OMX_TRUE;
             (*(ipCallbacks->EventHandler))
@@ -1004,9 +535,9 @@
          */
         if (OMX_TRUE == iEndofStream)
         {
-            if ((0 == iTempInputBufferLength) && !DecodeReturn)
+            if ((0 == iTempInputBufferLength) && !iDecodeReturn)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithoutMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1019,19 +550,22 @@
                 iNewInBufferRequired = OMX_TRUE;
                 iEndofStream = OMX_FALSE;
 
-                ipAvcOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
 
-                AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithoutMarker OUT"));
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker OUT"));
 
                 return;
             }
         }
 
         //Send the output buffer back when it has some data in it
-        if (ipAvcOutputBuffer->nFilledLen > 0)
+        if (ipOutputBuffer->nFilledLen > 0)
         {
-            AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         /* If there is some more processing left with current buffers, re-schedule the AO
@@ -1045,26 +579,25 @@
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithoutMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithoutMarker OUT"));
     return;
 }
 
 
 /* Decoding function for input buffers with end of frame flag marked */
-void OpenmaxAvcAO::AvcDecodeWithMarker(OMX_BUFFERHEADERTYPE* pAvcInputBuffer)
+void OpenmaxAvcAO::DecodeWithMarker()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker IN"));
 
     OMX_COMPONENTTYPE  *pHandle = &iOmxComponent;
     QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
 
-    AvcComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    AvcComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
     OMX_U8*					pOutBuffer;
     OMX_U32					OutputLength;
-    static OMX_BOOL			DecodeReturn = OMX_FALSE;
     OMX_BOOL				MarkerFlag = OMX_TRUE;
     OMX_BOOL				Status;
     OMX_BOOL				ResizeNeeded = OMX_FALSE;
@@ -1081,20 +614,27 @@
             if (0 == (GetQueueNumElem(pOutputQueue)))
             {
                 iNewInBufferRequired = OMX_FALSE;
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker OUT output buffer unavailable"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker OUT output buffer unavailable"));
                 return;
             }
 
-            ipAvcOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                iNewInBufferRequired = OMX_FALSE;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker Error, output buffer dequeue returned NULL, OUT"));
+                return;
+            }
 
             //Do not proceed if the output buffer can't fit the YUV data
-            if (ipAvcOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) * ((CurrHeight + 15)&(~15)) * 3 / 2))
+            if (ipOutputBuffer->nAllocLen < (OMX_U32)(((CurrWidth + 15)&(~15)) * ((CurrHeight + 15)&(~15)) * 3 / 2))
             {
-                ipAvcOutputBuffer->nFilledLen = 0;
-                AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
+                ipOutputBuffer->nFilledLen = 0;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
                 return;
             }
-            ipAvcOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
         }
 
@@ -1103,21 +643,21 @@
          */
         if (NULL != ipMark)
         {
-            ipAvcOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipAvcOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if (NULL != ipTargetComponent)
         {
-            ipAvcOutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipAvcOutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
 
         }
         //Mark buffer code ends here
 
-        pOutBuffer = ipAvcOutputBuffer->pBuffer;
+        pOutBuffer = ipOutputBuffer->pBuffer;
         OutputLength = 0;
 
         if (iInputCurrLength > 0)
@@ -1126,27 +666,29 @@
             ipAvcDec->CurrInputTimestamp = iFrameTimestamp;
 
             //Output buffer is passed as a short pointer
-            DecodeReturn = ipAvcDec->AvcDecodeVideo_OMX(pOutBuffer, (OMX_U32*) & OutputLength,
-                           &(ipFrameDecodeBuffer),
-                           &(iInputCurrLength),
-                           &(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam),
-                           &iFrameCount,
-                           MarkerFlag,
-                           &(ipAvcOutputBuffer->nTimeStamp), &ResizeNeeded);
+            iDecodeReturn = ipAvcDec->AvcDecodeVideo_OMX(pOutBuffer, (OMX_U32*) & OutputLength,
+                            &(ipFrameDecodeBuffer),
+                            &(iInputCurrLength),
+                            &(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam),
+                            &iFrameCount,
+                            MarkerFlag,
+                            &(ipOutputBuffer->nTimeStamp), &ResizeNeeded);
 
-            ipAvcOutputBuffer->nFilledLen = OutputLength;
+            ipOutputBuffer->nFilledLen = OutputLength;
             //offset not required in our case, set it to zero
-            ipAvcOutputBuffer->nOffset = 0;
+            ipOutputBuffer->nOffset = 0;
 
             if (ResizeNeeded == OMX_TRUE)
             {
-                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->AvcHandle;
+                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
 
                 // set the flag. Do not process any more frames until
                 // IL Client sends PortDisable event (thus starting the procedure for
                 // dynamic port reconfiguration)
                 iResizePending = OMX_TRUE;
 
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : Sending the PortSettings Changed Callback"));
+
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
                  iCallbackData,
@@ -1158,9 +700,9 @@
 
 
             //If decoder returned error, report it to the client via a callback
-            if (!DecodeReturn && OMX_FALSE == iEndofStream)
+            if (!iDecodeReturn && OMX_FALSE == iEndofStream)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker ErrorStreamCorrupt callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker ErrorStreamCorrupt callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1174,25 +716,38 @@
 
             if (0 == iInputCurrLength)
             {
-                pAvcInputBuffer->nFilledLen = 0;
-                AvcComponentReturnInputBuffer(pAvcInputBuffer, pInPort);
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
                 iNewInBufferRequired = OMX_TRUE;
                 iIsInputBufferEnded = OMX_TRUE;
+                ipInputBuffer = NULL;
             }
             else
             {
                 iNewInBufferRequired = OMX_FALSE;
             }
         }
+        else if (iEndofStream == OMX_FALSE)
+        {
+            // it's possible that after partial frame assembly, the input buffer still remains empty (due to
+            // client erroneously sending such buffers). This may cause error in processing/returning buffers
+            // This code adds robustness in the sense that it returns such buffer to the client
+
+            ipInputBuffer->nFilledLen = 0;
+            ReturnInputBuffer(ipInputBuffer, pInPort);
+            ipInputBuffer = NULL;
+            iNewInBufferRequired = OMX_TRUE;
+            iIsInputBufferEnded = OMX_TRUE;
+        }
 
 
         /* If EOS flag has come from the client & there are no more
          * input buffers to decode, send the callback to the client*/
         if (OMX_TRUE == iEndofStream)
         {
-            if (!DecodeReturn)
+            if (!iDecodeReturn)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1205,38 +760,43 @@
                 iNewInBufferRequired = OMX_TRUE;
                 iEndofStream = OMX_FALSE;
 
-                ipAvcOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
-                AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
 
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker OUT"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker OUT"));
 
                 return;
             }
-            else if (DecodeReturn)
+            else if (iDecodeReturn)
             {
-                Status = ipAvcDec->FlushOutput_OMX(pOutBuffer, &OutputLength, &(ipAvcOutputBuffer->nTimeStamp), pOutPort->PortParam.format.video.nFrameWidth, pOutPort->PortParam.format.video.nFrameHeight);
-                ipAvcOutputBuffer->nFilledLen = OutputLength;
+                Status = ipAvcDec->FlushOutput_OMX(pOutBuffer, &OutputLength, &(ipOutputBuffer->nTimeStamp), pOutPort->PortParam.format.video.nFrameWidth, pOutPort->PortParam.format.video.nFrameHeight);
+                ipOutputBuffer->nFilledLen = OutputLength;
 
-                ipAvcOutputBuffer->nOffset = 0;
+                ipOutputBuffer->nOffset = 0;
 
                 if (OMX_FALSE != Status)
                 {
-                    AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker OUT"));
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                    ipOutputBuffer = NULL;
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker OUT"));
+                    RunIfNotReady();
                     return;
                 }
                 else
                 {
-                    DecodeReturn = OMX_FALSE;
+                    iDecodeReturn = OMX_FALSE;
                     RunIfNotReady();
                 }
             }
         }
 
         //Send the output buffer back when it has some data in it
-        if (ipAvcOutputBuffer->nFilledLen > 0)
+        if (ipOutputBuffer->nFilledLen > 0)
         {
-            AvcComponentReturnOutputBuffer(ipAvcOutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
 
@@ -1251,480 +811,32 @@
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcDecodeWithMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : DecodeWithMarker OUT"));
     return;
 }
 
 
-void OpenmaxAvcAO::AvcComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pAvcInputBuffer, AvcComponentPortType *pPort)
+void OpenmaxAvcAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
 {
-    OSCL_UNUSED_ARG(pPort);
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    if (iNumInputBuffer)
-    {
-        iNumInputBuffer--;
-    }
-
-    //Callback for releasing the input buffer
-    (*(ipCallbacks->EmptyBufferDone))
-    (pHandle, iCallbackData, pAvcInputBuffer);
-
-    pAvcInputBuffer = NULL;
-
-}
-
-
-/**
- * Returns Output Buffer back to the IL client
- */
-void OpenmaxAvcAO::AvcComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pAvcOutputBuffer,
-        AvcComponentPortType *pPort)
-{
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    //Callback for sending back the output buffer
-    (*(ipCallbacks->FillBufferDone))
-    (pHandle, iCallbackData, pAvcOutputBuffer);
-
-    if (iOutBufferCount)
-    {
-        iOutBufferCount--;
-    }
-
-    pPort->NumBufferFlushed++;
-    iNewOutBufRequired = OMX_TRUE;
-}
-
-/** The panic function that exits from the application.
- */
-OMX_S32 OpenmaxAvcAO::AvcComponentPanic()
-{
-    OSCL_ASSERT(false);
-    OsclError::Panic("PVERROR", OsclErrGeneral);
-    return 0;
-}
-
-
-/** Flushes all the buffers under processing by the given port.
-	* This function is called due to a state change of the component, typically
-	* @param Component the component which owns the port to be flushed
-	* @param PortIndex the ID of the port to be flushed
-	*/
-
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentFlushPort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentFlushPort IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_BUFFERHEADERTYPE* pOutputBuff;
-    OMX_BUFFERHEADERTYPE* pInputBuff;
-
-    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        while ((GetQueueNumElem(pInputQueue) > 0))
-        {
-            pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, pInputBuff);
-            iNumInputBuffer--;
-        }
-
-    }
-
-    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        if ((OMX_FALSE == iNewOutBufRequired) && (iOutBufferCount > 0))
-        {
-            if (ipAvcOutputBuffer)
-            {
-                (*(ipCallbacks->FillBufferDone))
-                (pHandle, iCallbackData, ipAvcOutputBuffer);
-                iOutBufferCount--;
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-
-        while ((GetQueueNumElem(pOutputQueue) > 0))
-        {
-            pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            pOutputBuff->nFilledLen = 0;
-            (*(ipCallbacks->FillBufferDone))
-            (pHandle, iCallbackData, pOutputBuff);
-            iOutBufferCount--;
-        }
-
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentFlushPort OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** This function is called by the omx core when the component
-	* is disposed by the IL client with a call to FreeHandle().
-	* \param Component, the component to be disposed
-	*/
-
-OMX_ERRORTYPE OpenmaxAvcAO::DestroyComponent()
-{
-    OMX_U32 ii;
-
-    if (iIsInit != OMX_FALSE)
-    {
-        AvcComponentDeInit();
-    }
-
-    /*Deinitialize and free ports semaphores and Queue*/
-    for (ii = 0; ii < iNumPorts; ii++)
-    {
-        if (ipPorts[ii]->pBufferQueue != NULL)
-        {
-            QueueDeinit(ipPorts[ii]->pBufferQueue);
-            oscl_free(ipPorts[ii]->pBufferQueue);
-            ipPorts[ii]->pBufferQueue = NULL;
-        }
-        /*Free port*/
-        if (ipPorts[ii] != NULL)
-        {
-            oscl_free(ipPorts[ii]);
-            ipPorts[ii] = NULL;
-        }
-    }
-
-    if (ipPorts)
-    {
-        oscl_free(ipPorts);
-        ipPorts = NULL;
-    }
-
-    iState = OMX_StateLoaded;
-
-    if (ipInputCurrBuffer)
-    {
-        oscl_free(ipInputCurrBuffer);
-        ipInputCurrBuffer = NULL;
-        iInputCurrBufferSize = 0;
-    }
-
-    if (ipTempInputBuffer)
-    {
-
-        oscl_free(ipTempInputBuffer);
-        ipTempInputBuffer = NULL;
-    }
-
-    if (ipAvcDec)
-    {
-        OSCL_DELETE(ipAvcDec);
-        ipAvcDec = NULL;
-    }
-
-    if (ipCoreDescriptor != NULL)
-    {
-        if (ipCoreDescriptor->pMessageQueue != NULL)
-        {
-            /* De-initialize the asynchronous command queue */
-            QueueDeinit(ipCoreDescriptor->pMessageQueue);
-            oscl_free(ipCoreDescriptor->pMessageQueue);
-            ipCoreDescriptor->pMessageQueue = NULL;
-        }
-
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    if (ipAppPriv)
-    {
-        ipAppPriv->AvcHandle = NULL;
-
-        oscl_free(ipAppPriv);
-        ipAppPriv = NULL;
-    }
-
-    return OMX_ErrorNone;
-}
-
-
-/**
- * Disable Single Port
- */
-void OpenmaxAvcAO::AvcComponentDisableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE;
-
-    if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->IdleToLoadedFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_FALSE;
-        }
-    }
-
-    ipPorts[PortIndex]->NumBufferFlushed = 0;
-}
-
-
-/** Disables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be disabled
-	* @param PortIndex the ID of the port to be disabled
-	*/
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentDisablePort(OMX_S32 PortIndex)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDisablePort IN"));
-    OMX_U32 ii;
-
-    if (-1 == PortIndex)
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_TRUE;
-        }
-
-        /*Flush all ports*/
-        AvcComponentFlushPort(PortIndex);
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_FALSE;
-        }
-    }
-    else
-    {
-        /*Flush the port specified*/
-        ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE;
-        AvcComponentFlushPort(PortIndex);
-        ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE;
-    }
-
-    /*Disable ports*/
-    if (PortIndex != -1)
-    {
-        AvcComponentDisableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            AvcComponentDisableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDisablePort OUT"));
-
-    return OMX_ErrorNone;
-}
-
-/**
- * Enable Single Port
- */
-void OpenmaxAvcAO::AvcComponentEnableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE;
-
-    if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->LoadedToIdleFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_TRUE;
-        }
-    }
-}
-
-/** Enables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be enabled
-	* @param PortIndex the ID of the port to be enabled
-	*/
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentEnablePort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentEnablePort IN"));
-
-    OMX_U32 ii;
-
-    /*Enable port/s*/
-    if (PortIndex != -1)
-    {
-        AvcComponentEnableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            AvcComponentEnableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentEnablePort OUT"));
-    return OMX_ErrorNone;
-}
-
-//Not implemented & supported in case of base profile components
-
-void OpenmaxAvcAO::AvcComponentGetRolesOfComponent(OMX_STRING* aRoleString)
-{
-    *aRoleString = "video_decoder.avc";
+    *aRoleString = (OMX_STRING)"video_decoder.avc";
 }
 
 
 
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentTunnelRequest(
-    OMX_IN  OMX_HANDLETYPE hComp,
-    OMX_IN  OMX_U32 nPort,
-    OMX_IN  OMX_HANDLETYPE hTunneledComp,
-    OMX_IN  OMX_U32 nTunneledPort,
-    OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup)
+//Component object constructor
+OpenmaxAvcAO::OpenmaxAvcAO()
 {
-    OSCL_UNUSED_ARG(hComp);
-    OSCL_UNUSED_ARG(nPort);
-    OSCL_UNUSED_ARG(hTunneledComp);
-    OSCL_UNUSED_ARG(nTunneledPort);
-    OSCL_UNUSED_ARG(pTunnelSetup);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    OSCL_UNUSED_ARG(nIndex);
-    OSCL_UNUSED_ARG(pComponentConfigStructure);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    OSCL_UNUSED_ARG(nIndex);
-    OSCL_UNUSED_ARG(pComponentConfigStructure);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    OSCL_UNUSED_ARG(cParameterName);
-    OSCL_UNUSED_ARG(pIndexType);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState)
-{
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-
-    pOpenmaxAOType->GetState(pState);
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxAvcAO::GetState(OMX_OUT OMX_STATETYPE* pState)
-{
-    *pState = iState;
-}
-
-
-
-//Active object constructor
-OpenmaxAvcAO::OpenmaxAvcAO() :
-        OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXAvcDec")
-{
-
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXVideoDecNode");
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : constructed"));
-
-    //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-    iBufferExecuteFlag = OMX_FALSE;
-    ipAppPriv = NULL;
-    //iLogger = NULL;
-
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-
-
-    ipCoreDescriptor = NULL;
-    iNumInputBuffer = 0;
-
-    ipFrameDecodeBuffer = NULL;
-    iPartialFrameAssembly = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iEndofStream = OMX_FALSE;
-    ipTempInputBuffer = NULL;
-
-
-    ipTargetComponent = NULL;
-    iTargetMarkData = NULL;
-    iNewInBufferRequired = OMX_TRUE;
-    iNewOutBufRequired = OMX_TRUE;
-
-    iTempConsumedLength = 0;
-    iOutBufferCount = 0;
-    iCodecReady = OMX_FALSE;
-    ipInputCurrBuffer = NULL;
-    iInputCurrBufferSize = 0;
-    iInputCurrLength = 0;
-    iFrameCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    ipAvcInputBuffer = NULL;
-    ipAvcOutputBuffer = NULL;
-    iFirstFragment = OMX_FALSE;
-    iResizePending = OMX_FALSE;
-
-    iFrameTimestamp = 0;
-
-    iNumPorts = 0;
-    ipPorts = NULL;
-
-    //Indicate whether component has been already initialized */
-    iIsInit = OMX_FALSE;
-
-    iGroupPriority = 0;
-    iGroupID = 0;
-
-    ipMark = NULL;
-
     ipAvcDec = NULL;
 
-
     if (!IsAdded())
     {
         AddToScheduler();
     }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : constructed"));
 }
 
 
-//Active object destructor
+//Component object destructor
 OpenmaxAvcAO::~OpenmaxAvcAO()
 {
     if (IsAdded())
@@ -1738,15 +850,15 @@
 
 /** The Initialization function
  */
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentInit()
+OMX_ERRORTYPE OpenmaxAvcAO::ComponentInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ComponentInit IN"));
 
     OMX_ERRORTYPE Status = OMX_ErrorNone;
 
     if (OMX_TRUE == iIsInit)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentInit error incorrect operation"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ComponentInit error incorrect operation"));
         return OMX_ErrorIncorrectStateOperation;
     }
     iIsInit = OMX_TRUE;
@@ -1761,7 +873,7 @@
     iInputCurrLength = 0;
     //Used in dynamic port reconfiguration
     iFrameCount = 0;
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ComponentInit OUT"));
 
     return Status;
 
@@ -1770,9 +882,9 @@
 /** This function is called upon a transition to the idle or invalid state.
  *  Also it is called by the AvcComponentDestructor() function
  */
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentDeInit()
+OMX_ERRORTYPE OpenmaxAvcAO::ComponentDeInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDeInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ComponentDeInit IN"));
 
     OMX_ERRORTYPE Status = OMX_ErrorNone;
 
@@ -1784,1967 +896,31 @@
         iCodecReady = OMX_FALSE;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDeInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : ComponentDeInit OUT"));
 
     return Status;
 
 }
 
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentGetParameter(
+
+OMX_ERRORTYPE OpenmaxAvcAO::GetConfig(
     OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status = OMX_ErrorNone;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return Status;
-
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::GetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
 {
     OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter IN"));
-
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
-    OMX_PORT_PARAM_TYPE* pPortDomains;
-    OMX_U32 PortIndex;
-    AvcComponentPortType* pComponentPort;
-    OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat;
-    OMX_VIDEO_PARAM_AVCTYPE *pVideoAvc;
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE * pProfileLevel;
-
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamPriorityMgmt:
-        {
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
-            pPrioMgmt->nGroupPriority = iGroupPriority;
-            pPrioMgmt->nGroupID = iGroupID;
-        }
-        break;
-
-        case OMX_IndexParamVideoInit:
-        {
-            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-
-        //Following 3 cases have a single common piece of code to be executed
-        case OMX_IndexParamAudioInit:
-        case OMX_IndexParamImageInit:
-        case OMX_IndexParamOtherInit:
-        {
-            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
-            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
-            pPortDomains->nPorts = 0;
-            pPortDomains->nStartPortNumber = 0;
-        }
-        break;
-
-        case OMX_IndexParamVideoPortFormat:
-        {
-            pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            if (pVideoPortFormat->nIndex > ipPorts[pVideoPortFormat->nPortIndex]->VideoParam.nIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error index out of range"));
-                return OMX_ErrorNoMore;
-            }
-            SetHeader(pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            if (pVideoPortFormat->nPortIndex <= 1)
-            {
-                pComponentPort = (AvcComponentPortType*) ipPorts[pVideoPortFormat->nPortIndex];
-                oscl_memcpy(pVideoPortFormat, &pComponentPort->VideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-
-        break;
-
-        case OMX_IndexParamVideoAvc:
-        {
-            pVideoAvc = (OMX_VIDEO_PARAM_AVCTYPE*) ComponentParameterStructure;
-            if (pVideoAvc->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pVideoAvc->nPortIndex;
-            oscl_memcpy(pVideoAvc, &ipPorts[PortIndex]->VideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
-            SetHeader(pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoProfileLevelQuerySupported:
-        {
-            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            PortIndex = pProfileLevel->nPortIndex;
-            if (pProfileLevel->nProfileIndex > ipPorts[PortIndex]->ProfileLevel.nProfileIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error profile not supported"));
-                return OMX_ErrorNoMore;
-            }
-
-            oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-            SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoProfileLevelCurrent:
-        {
-            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            PortIndex = pProfileLevel->nPortIndex;
-
-            oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-            SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-
-            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
-            {
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-            else
-            {
-                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-        }
-        break;
-
-        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
-        {
-            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
-            if (NULL == pCap_flags)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error pCap_flags NULL"));
-                return OMX_ErrorBadParameter;
-            }
-            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
-
-        }
-        break;
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter error Unsupported Index"));
-            return OMX_ErrorUnsupportedIndex;
-        }
-        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : GetParameter OUT"));
-
-    return OMX_ErrorNone;
+    OSCL_UNUSED_ARG(nIndex);
+    OSCL_UNUSED_ARG(pComponentConfigStructure);
+    return OMX_ErrorNotImplemented;
 }
 
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
+/* This routine will reset the decoder library and some of the associated flags*/
+void OpenmaxAvcAO::ResetComponent()
 {
-
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
+    // reset decoder
+    if (ipAvcDec)
     {
-        return OMX_ErrorBadParameter;
+        ipAvcDec->ResetDecoder();
     }
 
-    Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::SetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter IN"));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat;
-    OMX_VIDEO_PARAM_AVCTYPE *pVideoAvc;
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE * pProfileLevel;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
-    OMX_U32 PortIndex;
-    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
-
-    AvcComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamVideoInit:
-        {
-            /*Check Structure Header*/
-            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error video init failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoPortFormat:
-        {
-            pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            PortIndex = pVideoPortFormat->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            if (PortIndex <= 1)
-            {
-                pComponentPort = (AvcComponentPortType*) ipPorts[PortIndex];
-                oscl_memcpy(&pComponentPort->VideoParam, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamVideoAvc:
-        {
-            pVideoAvc = (OMX_VIDEO_PARAM_AVCTYPE*) ComponentParameterStructure;
-            PortIndex = pVideoAvc->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->VideoAvc, pVideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoProfileLevelCurrent:
-        {
-            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
-            PortIndex = pProfileLevel->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->ProfileLevel, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPriorityMgmt:
-        {
-            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error incorrect state error"));
-                return OMX_ErrorIncorrectStateOperation;
-            }
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            iGroupPriority = pPrioMgmt->nGroupPriority;
-            iGroupID = pPrioMgmt->nGroupID;
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
-            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-            if (OMX_ErrorIncorrectStateOperation == ErrorType)
-            {
-                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error incorrect state error"));
-                    return OMX_ErrorIncorrectStateOperation;
-                }
-            }
-            else if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter OUT"));
-                return OMX_ErrorNone;
-            }
-
-            ErrorType = OMX_ErrorNone;
-        }
-        break;
-
-        case OMX_IndexParamStandardComponentRole:
-        {
-            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            strcpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole);
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter error bad parameter"));
-            return OMX_ErrorBadParameter;
-        }
-        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetParameter OUT"));
-    return ErrorType;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::UseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : UseBuffer IN"));
-    AvcComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : UseBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : UseBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : UseBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer;
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFilledLen = 0;
-            pBaseComponentPort->pBuffer[ii]->nOffset = 0;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            pBaseComponentPort->pBuffer[ii]->nTickCount = 0;
-            pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0;
-            *ppBufferHdr = pBaseComponentPort->pBuffer[ii];
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            else
-            {
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-            pBaseComponentPort->NumAssignedBuffers++;
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : UseBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : UseBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::AllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer IN"));
-
-    AvcComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            /* allocate the buffer */
-            pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes);
-            if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            *pBuffer = pBaseComponentPort->pBuffer[ii];
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts;
-            }
-            else
-            {
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-            }
-
-            pBaseComponentPort->NumAssignedBuffers++;
-
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AllocateBuffer OUT"));
-    return OMX_ErrorInsufficientResources;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::FreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FreeBuffer IN"));
-
-    AvcComponentPortType* pBaseComponentPort;
-
-    OMX_U32 ii;
-    OMX_BOOL FoundBuffer;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FreeBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateLoaded
-            && pBaseComponentPort->TransientState != OMX_StateInvalid)
-    {
-
-        (*(ipCallbacks->EventHandler))
-        (hComponent,
-         iCallbackData,
-         OMX_EventError, /* The command was completed */
-         OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */
-         nPortIndex, /* The State has been changed in message->MessageParam2 */
-         NULL);
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-            oscl_free(pBuffer->pBuffer);
-            pBuffer->pBuffer = NULL;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-        else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) &&
-                 (pBaseComponentPort->pBuffer[ii] == pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-    }
-
-    FoundBuffer = OMX_FALSE;
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE)
-        {
-            FoundBuffer = OMX_TRUE;
-            break;
-        }
-    }
-    if (!FoundBuffer)
-    {
-        pBaseComponentPort->PortParam.bPopulated = OMX_FALSE;
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation
-            RunIfNotReady();
-            //Set the corresponding flags
-            pBaseComponentPort->IdleToLoadedFlag = OMX_TRUE;
-            pBaseComponentPort->LoadedToIdleFlag = OMX_FALSE;
-            iStateTransitionFlag = OMX_FALSE;
-            //Reset the decoding flags while freeing buffers
-            if (OMX_PORT_INPUTPORT_INDEX == nPortIndex)
-            {
-                iIsInputBufferEnded = OMX_TRUE;
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-                iNewInBufferRequired = OMX_TRUE;
-            }
-            else if (OMX_PORT_OUTPUTPORT_INDEX == nPortIndex)
-            {
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-        if (NULL != pBaseComponentPort->pBuffer)
-        {
-            oscl_free(pBaseComponentPort->pBuffer);
-            pBaseComponentPort->pBuffer = NULL;
-            oscl_free(pBaseComponentPort->BufferState);
-            pBaseComponentPort->BufferState = NULL;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FreeBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs
-	* @param hComponent the handle of the component
-	* @param ipCallbacks the OpenMAX standard structure that holds the callback pointers
-	* @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed
-    */
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::SetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SetCallbacks"));
-    ipCallbacks = pCallbacks;
-    iCallbackData = pAppData;
-
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::SendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_S32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand IN"));
-
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone;
-    QueueType* pMessageQueue;
-    CoreMessage* Message = NULL;
-
-    pMessageQueue = ipCoreDescriptor->pMessageQueue;
-
-    if (OMX_StateInvalid == iState)
-    {
-        ErrMsgHandler = OMX_ErrorInvalidState;
-    }
-
-    switch (Cmd)
-    {
-        case OMX_CommandStateSet:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandStateSet;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState))
-            {
-                ErrMsgHandler = AvcComponentInit();
-
-                if (ErrMsgHandler != OMX_ErrorNone)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error component init"));
-                    return OMX_ErrorInsufficientResources;
-                }
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    ipPorts[ii]->TransientState = OMX_StateIdle;
-                }
-            }
-            else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState))
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else if (OMX_StateInvalid == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateInvalid;
-                    }
-                }
-            }
-            else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam))
-                     && (OMX_StateExecuting == iState))
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-
-        }
-        break;
-
-        case OMX_CommandFlush:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandFlush;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-
-            }
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            AvcComponentSetPortFlushFlag(iNumPorts, nParam, OMX_TRUE);
-            AvcComponentSetNumBufferFlush(iNumPorts, -1, 0);
-        }
-        break;
-
-        case OMX_CommandPortDisable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            iResizePending = OMX_FALSE; //this will enable processing
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (!PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else
-            {
-                if (!PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateLoaded;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-                Message->MessageParam2 = nParam;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-                Message->MessageParam2 = ErrMsgHandler;
-            }
-            Message->MessageParam1 = OMX_CommandPortDisable;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandPortEnable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateIdle;
-                    }
-                }
-            }
-            else
-            {
-                if (PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateIdle;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-            }
-
-            Message->MessageParam1 = OMX_CommandPortEnable;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandMarkBuffer:
-        {
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-            }
-
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandMarkBuffer;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand error unsupported index"));
-            ErrMsgHandler = OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    Queue(pMessageQueue, Message);
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : SendCommand OUT"));
-    return ErrMsgHandler;
-}
-
-
-/** This is called by the OMX core in its message processing
- * thread context upon a component request. A request is made
- * by the component when some asynchronous services are needed:
- * 1) A SendCommand() is to be processed
- * 2) An error needs to be notified
- * \param Message, the message that has been passed to core
- */
-
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentMessageHandler(CoreMessage* Message)
-{
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-
-    /** Dealing with a SendCommand call.
-     * -MessageParam1 contains the command to execute
-     * -MessageParam2 contains the parameter of the command
-     *  (destination state in case of a state change command).
-     */
-
-    OMX_STATETYPE orig_state = iState;
-    if (SENDCOMMAND_MSG_TYPE == Message->MessageType)
-    {
-        switch (Message->MessageParam1)
-        {
-            case OMX_CommandStateSet:
-            {
-                /* Do the actual state change */
-                ErrorType = AvcComponentDoStateSet(Message->MessageParam2);
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                //Do not send the callback now till the State gets changed
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    /* And run the callback */
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventCmdComplete, /* The command was completed */
-                     OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
-                     Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-            }
-            break;
-
-            case OMX_CommandFlush:
-            {
-                /*Flush ports*/
-                ErrorType = AvcComponentFlushPort(Message->MessageParam2);
-
-                AvcComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Flush all port*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {/*Flush input/output port*/
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-                AvcComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-            }
-            break;
-
-            case OMX_CommandPortDisable:
-            {
-                /** This condition is added to pass the tests, it is not significant for the environment */
-                ErrorType = AvcComponentDisablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Disable all ports*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandPortEnable:
-            {
-                ErrorType = AvcComponentEnablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The State has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (Message->MessageParam2 != -1)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                    else
-                    {
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The State has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandMarkBuffer:
-            {
-                ipMark = (OMX_MARKTYPE *)Message->pCmdData;
-            }
-            break;
-
-            default:
-            {
-
-            }
-            break;
-        }
-        /* Dealing with an asynchronous error condition
-         */
-    }
-
-    if (orig_state != OMX_StateInvalid)
-    {
-        ErrorType = OMX_ErrorNone;
-    }
-
-    return ErrorType;
-}
-
-/** Changes the state of a component taking proper actions depending on
- *  the transiotion requested
- * \param Component, the component which state is to be changed
- * \param aDestinationState the requested target state.
- */
-
-OMX_ERRORTYPE OpenmaxAvcAO::AvcComponentDoStateSet(OMX_U32 aDestinationState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
-                    (0, "OpenmaxAvcAO : AvcComponentDoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_U32 ii;
-
-    if (OMX_StateLoaded == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateLoaded;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateIdle:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->IdleToLoadedFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_FALSE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet Waiting port to be de-populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateLoaded;
-
-                iNumInputBuffer = 0;
-                iOutBufferCount = 0;
-                iPartialFrameAssembly = OMX_FALSE;
-                iEndofStream = OMX_FALSE;
-                iIsInputBufferEnded = OMX_TRUE;
-                iNewInBufferRequired = OMX_TRUE;
-                iNewOutBufRequired = OMX_TRUE;
-                iFirstFragment = OMX_FALSE;
-
-                AvcComponentDeInit();
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateWaitForResources == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateLoaded:
-            {
-                iState = OMX_StateWaitForResources;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateIdle == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            !PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->LoadedToIdleFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_TRUE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet Waiting port to be populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateIdle;
-
-                //Used in case of partial frame assembly
-                if (!ipInputCurrBuffer)
-                {
-                    //Keep the size of temp buffer double to be on safer side
-                    ipInputCurrBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-                    if (NULL == ipInputCurrBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                    iInputCurrBufferSize = 2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
-                }
-
-                if (!ipTempInputBuffer)
-                {
-                    ipTempInputBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
-                    if (NULL == ipTempInputBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            //Both the below cases have same body
-            case OMX_StateExecuting:
-            case OMX_StatePause:
-            {
-                AvcComponentSetNumBufferFlush(iNumPorts, -1, 0);
-                AvcComponentSetPortFlushFlag(iNumPorts, -1, OMX_TRUE);
-
-                AvcComponentPortType* pInPort = (AvcComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-                //Return all the buffers if still occupied
-                QueueType *pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-                while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0))
-                {
-                    AvcComponentFlushPort(OMX_PORT_INPUTPORT_INDEX);
-                }
-                // if a buffer was previously dequeued, it wasnt freed in above loop. return it now
-                if (iNumInputBuffer > 0)
-                {
-                    ipAvcInputBuffer->nFilledLen = 0;
-                    AvcComponentReturnInputBuffer(ipAvcInputBuffer, pInPort);
-                    iNewInBufferRequired = OMX_TRUE;
-                    iIsInputBufferEnded = OMX_TRUE;
-                }
-
-                //Mark these flags as true
-                iIsInputBufferEnded = OMX_TRUE;
-                iEndofStream = OMX_FALSE;
-                iNewInBufferRequired = OMX_TRUE;
-
-                //Added these statement here
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-
-                while (iOutBufferCount > 0)
-                {
-                    AvcComponentFlushPort(OMX_PORT_OUTPUTPORT_INDEX);
-                }
-
-                AvcComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-                AvcComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet OUT"));
-        return ErrorType;
-    }
-
-    if (OMX_StatePause == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StatePause:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            //Falling through to the next case
-            case OMX_StateExecuting:
-            case OMX_StateIdle:
-            {
-                iState = OMX_StatePause;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateExecuting == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateIdle:
-            {
-                iState = OMX_StateExecuting;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                iState = OMX_StateExecuting;
-                /* A trigger to start the processing of buffers when component
-                 * transitions to executing from pause, as it is already
-                 * holding the required buffers
-                 */
-                RunIfNotReady();
-            }
-            break;
-
-            case OMX_StateExecuting:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateInvalid == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            default:
-            {
-                iState = OMX_StateInvalid;
-                if (iIsInit != OMX_FALSE)
-                {
-                    AvcComponentDeInit();
-                }
-            }
-            break;
-        }
-
-        if (iIsInit != OMX_FALSE)
-        {
-            AvcComponentDeInit();
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : AvcComponentDoStateSet OUT"));
-    return OMX_ErrorNone;
-}
-
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer);
-
-    return Status;
-
 }
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::EmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer IN"));
-    //Do not queue buffers if component is in invalid state
-    if (OMX_StateInvalid == iState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState))
-    {
-        OMX_U32 PortIndex;
-        QueueType* pInputQueue;
-        OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-        PortIndex = pBuffer->nInputPortIndex;
-
-        //Validate the port index & Queue the buffers available only at the input port
-        if (PortIndex >= iNumPorts || ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer error bad port index"));
-            return OMX_ErrorBadPortIndex;
-        }
-
-        //Port should be in enabled state before accepting buffers
-        if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        /* The number of buffers the component can queue at a time
-         * depends upon the number of buffers allocated/assigned on the input port
-         */
-        if (iNumInputBuffer == ipPorts[PortIndex]->NumAssignedBuffers)
-        {
-            RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        //Finally after passing all the conditions, queue the buffer in Input queue
-        pInputQueue = ipPorts[PortIndex]->pBufferQueue;
-
-        if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer error check header failed"));
-            return ErrorType;
-        }
-
-        iNumInputBuffer++;
-        Queue(pInputQueue, pBuffer);
-
-        //Signal the AO about the incoming buffer
-        RunIfNotReady();
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer error incorrect state"));
-        //This macro is not accepted in any other state except the three mentioned above
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : EmptyThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxAvcAO::BaseComponentFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxAvcAO* pOpenmaxAOType = (OpenmaxAvcAO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxAvcAO::FillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FillThisBuffer IN"));
-
-    OMX_U32 PortIndex;
-
-    QueueType* pOutputQueue;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-    PortIndex = pBuffer->nOutputPortIndex;
-    //Validate the port index & Queue the buffers available only at the output port
-    if (PortIndex >= iNumPorts ||
-            ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FillThisBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pOutputQueue = ipPorts[PortIndex]->pBufferQueue;
-    if (iState != OMX_StateExecuting &&
-            iState != OMX_StatePause &&
-            iState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FillThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    //Port should be in enabled state before accepting buffers
-    if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FillThisBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FillThisBuffer error check header failed"));
-        return ErrorType;
-    }
-
-    //Queue the buffer in output queue
-    Queue(pOutputQueue, pBuffer);
-    iOutBufferCount++;
-
-    //Signal the AO about the incoming buffer
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : FillThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxAvcAO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : Run IN"));
-
-    CoreMessage* pCoreMessage;
-
-    //Execute the commands from the message handler queue
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue);
-
-        if (OMX_CommandStateSet == pCoreMessage->MessageParam1)
-        {
-            if (OMX_StateExecuting == pCoreMessage->MessageParam2)
-            {
-                iBufferExecuteFlag = OMX_TRUE;
-            }
-            else
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-        }
-
-        AvcComponentMessageHandler(pCoreMessage);
-
-        /* If some allocations/deallocations are required before the state transition
-         * then queue the command again to be executed later on
-         */
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage);
-            // Don't reschedule. Wait for arriving buffers to do it
-            //RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : Run OUT"));
-            return;
-        }
-
-        else
-        {
-            oscl_free(pCoreMessage);
-            pCoreMessage = NULL;
-        }
-    }
-
-    /* If the component is in executing state, call the Buffer management function.
-     * Stop calling this function as soon as state transition request is received.
-     */
-    if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending))
-    {
-        AvcComponentBufferMgmtFunction();
-    }
-
-    //Check for any more commands in the message handler queue & schedule them for later
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxAvcAO : Run OUT"));
-
-    return;
-}
-
-
diff --git a/codecs_v2/omx/omx_h264enc/Android.mk b/codecs_v2/omx/omx_h264enc/Android.mk
new file mode 100644
index 0000000..6cba566
--- /dev/null
+++ b/codecs_v2/omx/omx_h264enc/Android.mk
@@ -0,0 +1,36 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/avc_enc.cpp \
+ 	src/omx_avcenc_component.cpp
+
+
+LOCAL_MODULE := libomx_avcenc_component_lib
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_h264enc/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_h264enc/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/enc/src \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/enc/include \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/common/src \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/common/include \
+ 	$(PV_TOP)/codecs_v2/utilities/colorconvert/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/avc_enc.h \
+ 	include/omx_avcenc_component.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/omx/omx_h264enc/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_h264enc/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..97bdafd
--- /dev/null
+++ b/codecs_v2/omx/omx_h264enc/build/make_multithreaded/local.mk
@@ -0,0 +1,35 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_avcenc_component_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../video/avc_h264/enc/src \
+  ../../../../video/avc_h264/enc/include \
+  ../../../../video/avc_h264/common/src \
+  ../../../../video/avc_h264/common/include \
+  ../../../../utilities/colorconvert/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := avc_enc.cpp \
+	omx_avcenc_component.cpp
+
+
+HDRS := avc_enc.h \
+	omx_avcenc_component.h
+	
+
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_h264enc/include/avc_enc.h b/codecs_v2/omx/omx_h264enc/include/avc_enc.h
new file mode 100644
index 0000000..666b2b6
--- /dev/null
+++ b/codecs_v2/omx/omx_h264enc/include/avc_enc.h
@@ -0,0 +1,127 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AVC_ENC_H_INCLUDED
+#define AVC_ENC_H_INCLUDED
+
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#ifndef AVCENC_API_H_INCLUDED
+#include "avcenc_api.h"
+#endif
+
+#ifndef CCRGB24TOYUV420_H_INCLUDED
+#include "ccrgb24toyuv420.h"
+#endif
+
+#ifndef CCRGB12TOYUV420_H_INCLUDED
+#include "ccrgb12toyuv420.h"
+#endif
+
+#ifndef CCYUV420SEMITOYUV420_H_INCLUDED
+#include "ccyuv420semitoyuv420.h"
+#endif
+
+class AvcEncoder_OMX
+{
+    public:
+
+        AvcEncoder_OMX();
+        ~AvcEncoder_OMX();
+
+        OMX_ERRORTYPE AvcEncInit(OMX_VIDEO_PORTDEFINITIONTYPE aInputParam,
+                                 OMX_CONFIG_ROTATIONTYPE aInputOrientationType,
+                                 OMX_VIDEO_PORTDEFINITIONTYPE aEncodeParam,
+                                 OMX_VIDEO_PARAM_AVCTYPE aEncodeAvcParam,
+                                 OMX_VIDEO_PARAM_BITRATETYPE aRateControlType,
+                                 OMX_VIDEO_PARAM_QUANTIZATIONTYPE aQuantType,
+                                 OMX_VIDEO_PARAM_MOTIONVECTORTYPE aSearchRange,
+                                 OMX_VIDEO_PARAM_INTRAREFRESHTYPE aIntraRefresh,
+                                 OMX_VIDEO_PARAM_VBSMCTYPE aVbsmcType);
+
+
+        AVCEnc_Status AvcEncodeVideo(OMX_U8*    aOutBuffer,
+                                     OMX_U32*   aOutputLength,
+                                     OMX_BOOL*  aBufferOverRun,
+                                     OMX_U8**   aOverBufferPointer,
+                                     OMX_U8*    aInBuffer,
+                                     OMX_U32*   aInBufSize,
+                                     OMX_TICKS  aInTimeStamp,
+                                     OMX_TICKS* aOutTimeStamp,
+                                     OMX_BOOL*  aSyncFlag);
+
+        OMX_BOOL AvcEncodeSendInput(OMX_U8*    aInBuffer,
+                                    OMX_U32*   aInBufSize,
+                                    OMX_TICKS  aInTimeStamp);
+
+
+        OMX_ERRORTYPE AvcEncDeinit();
+
+        OMX_ERRORTYPE AvcRequestIFrame();
+        OMX_BOOL AvcUpdateBitRate(OMX_U32 aEncodedBitRate);
+        OMX_BOOL AvcUpdateFrameRate(OMX_U32 aEncodeFramerate);
+
+        /* for avc encoder lib callback functions */
+        int		AVC_DPBAlloc(uint frame_size_in_mbs, uint num_buffers);
+        int		AVC_FrameBind(int indx, uint8** yuv);
+        void	AVC_FrameUnbind(int indx);
+
+
+    private:
+
+        void CopyToYUVIn(uint8* YUV, int width, int height, int width_16, int height_16);
+
+        /* RGB->YUV conversion */
+        ColorConvertBase *ccRGBtoYUV;
+
+        int		iSrcWidth;
+        int		iSrcHeight;
+        int		iFrameOrientation;
+
+        OMX_COLOR_FORMATTYPE 	iVideoFormat;
+
+        /* variables needed in operation */
+        AVCHandle iAvcHandle;
+        AVCFrameIO iVidIn;
+        uint8*	iYUVIn;
+        uint8*	iVideoIn;
+        uint8*	iVideoOut;
+        uint32	iTimeStamp;
+        OMX_BOOL	iIDR;
+        int		iDispOrd;
+
+        uint8*	iDPB;
+        bool*	iFrameUsed;
+        uint8** iFramePtr;
+        int		iNumFrames;
+
+        OMX_BOOL  iInitialized;
+        OMX_BOOL  iSpsPpsHeaderFlag;
+        OMX_BOOL  iReadyForNextFrame;
+
+
+};
+
+
+#endif ///#ifndef AVC_ENC_H_INCLUDED
diff --git a/codecs_v2/omx/omx_h264enc/include/omx_avcenc_component.h b/codecs_v2/omx/omx_h264enc/include/omx_avcenc_component.h
new file mode 100644
index 0000000..0c63cd4
--- /dev/null
+++ b/codecs_v2/omx/omx_h264enc/include/omx_avcenc_component.h
@@ -0,0 +1,80 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+	@file omx_avcenc_component.h
+	OpenMax encoder_component component.
+
+*/
+
+#ifndef OMX_AVCENC_COMPONENT_H_INCLUDED
+#define OMX_AVCENC_COMPONENT_H_INCLUDED
+
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
+#endif
+
+#ifndef AVC_ENC_H_INCLUDED
+#include "avc_enc.h"
+#endif
+
+
+#define INPUT_BUFFER_SIZE_AVCENC 38016			//(176 * 144 * 1.5) for YUV 420 format.
+#define OUTPUT_BUFFER_SIZE_AVCENC 38135
+
+#define NUMBER_INPUT_BUFFER_AVCENC  5
+#define NUMBER_OUTPUT_BUFFER_AVCENC  2
+
+
+
+class OmxComponentAvcEncAO : public OmxComponentVideo
+{
+    public:
+
+        OmxComponentAvcEncAO();
+        ~OmxComponentAvcEncAO();
+
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
+
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
+
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+        void ProcessInBufferFlag();
+
+        void ProcessData();
+
+        OMX_ERRORTYPE SetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_IN  OMX_PTR pComponentConfigStructure);
+
+    private:
+
+        OMX_BOOL CopyDataToOutputBuffer();
+
+        AvcEncoder_OMX*   ipAvcEncoderObject;
+
+        OMX_BOOL		  iBufferOverRun;
+        OMX_U8*			  ipInternalOutBuffer;
+        OMX_U32			  iInternalOutBufFilledLen;
+        OMX_TICKS		  iOutputTimeStamp;
+        OMX_BOOL		  iSyncFlag;
+};
+
+#endif // OMX_AVCENC_COMPONENT_H_INCLUDED
diff --git a/codecs_v2/omx/omx_h264enc/src/avc_enc.cpp b/codecs_v2/omx/omx_h264enc/src/avc_enc.cpp
new file mode 100644
index 0000000..9737bfc
--- /dev/null
+++ b/codecs_v2/omx/omx_h264enc/src/avc_enc.cpp
@@ -0,0 +1,1034 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "avc_enc.h"
+
+
+#define MAX_SUPPORTED_LAYER 1
+
+/* global static functions */
+
+void CbAvcEncDebugLog_OMX(uint32 *userData, AVCLogType type, char *string1, int val1, int val2)
+{
+    OSCL_UNUSED_ARG(userData);
+    OSCL_UNUSED_ARG(type);
+    OSCL_UNUSED_ARG(string1);
+    OSCL_UNUSED_ARG(val1);
+    OSCL_UNUSED_ARG(val2);
+
+    return;
+}
+
+int CbAvcEncMalloc_OMX(void *userData, int32 size, int attribute)
+{
+    OSCL_UNUSED_ARG(userData);
+    OSCL_UNUSED_ARG(attribute);
+
+    uint8 *mem;
+
+    mem = (uint8*) oscl_malloc(size);
+
+    return (int)mem;
+}
+
+void CbAvcEncFree_OMX(void *userData, int mem)
+{
+    OSCL_UNUSED_ARG(userData);
+
+    oscl_free((void*)mem);
+
+    return;
+}
+
+
+int CbAvcEncDPBAlloc_OMX(void *userData, uint frame_size_in_mbs, uint num_buffers)
+{
+    AvcEncoder_OMX* pAvcEnc = (AvcEncoder_OMX*) userData;
+
+    return pAvcEnc->AVC_DPBAlloc(frame_size_in_mbs, num_buffers);
+}
+
+
+void CbAvcEncFrameUnbind_OMX(void *userData, int indx)
+{
+    AvcEncoder_OMX* pAvcEnc = (AvcEncoder_OMX*) userData;
+
+    pAvcEnc->AVC_FrameUnbind(indx);
+
+    return;
+}
+
+int CbAvcEncFrameBind_OMX(void *userData, int indx, uint8 **yuv)
+{
+    AvcEncoder_OMX* pAvcEnc = (AvcEncoder_OMX*) userData;
+
+    return pAvcEnc->AVC_FrameBind(indx, yuv);
+}
+
+
+
+//Class constructor function
+AvcEncoder_OMX::AvcEncoder_OMX()
+{
+    iInitialized = OMX_FALSE;
+    iSpsPpsHeaderFlag = OMX_FALSE;
+    iReadyForNextFrame = OMX_TRUE;
+
+    oscl_memset((void *)&iAvcHandle, 0, sizeof(AVCHandle));
+
+    iAvcHandle.CBAVC_DPBAlloc = &CbAvcEncDPBAlloc_OMX;
+    iAvcHandle.CBAVC_FrameBind = &CbAvcEncFrameBind_OMX;
+    iAvcHandle.CBAVC_FrameUnbind = &CbAvcEncFrameUnbind_OMX;
+    iAvcHandle.CBAVC_Free = &CbAvcEncFree_OMX;
+    iAvcHandle.CBAVC_Malloc = &CbAvcEncMalloc_OMX;
+    iAvcHandle.CBAVC_DebugLog = &CbAvcEncDebugLog_OMX;
+    iAvcHandle.userData = this;
+
+    ccRGBtoYUV = NULL;
+    iYUVIn = NULL;
+    iFramePtr = NULL;
+    iDPB = NULL;
+    iFrameUsed = NULL;
+}
+
+
+//Class destructor function
+AvcEncoder_OMX::~AvcEncoder_OMX()
+{
+    //In case encoder cleanup has not been done yet, do it here
+    AvcEncDeinit();
+}
+
+
+/* Encoder Initialization routine */
+OMX_ERRORTYPE AvcEncoder_OMX::AvcEncInit(OMX_VIDEO_PORTDEFINITIONTYPE aInputParam,
+        OMX_CONFIG_ROTATIONTYPE aInputOrientationType,
+        OMX_VIDEO_PORTDEFINITIONTYPE aEncodeParam,
+        OMX_VIDEO_PARAM_AVCTYPE aEncodeAvcParam,
+        OMX_VIDEO_PARAM_BITRATETYPE aRateControlType,
+        OMX_VIDEO_PARAM_QUANTIZATIONTYPE aQuantType,
+        OMX_VIDEO_PARAM_MOTIONVECTORTYPE aSearchRange,
+        OMX_VIDEO_PARAM_INTRAREFRESHTYPE aIntraRefresh,
+        OMX_VIDEO_PARAM_VBSMCTYPE aVbsmcType)
+{
+
+    AVCEncParams aEncOption; /* encoding options */
+
+
+    iSrcWidth = aInputParam.nFrameWidth;
+    iSrcHeight = aInputParam.nFrameHeight;
+    iFrameOrientation = aInputOrientationType.nRotation;
+
+
+    if ((OMX_COLOR_FormatYUV420Planar == aInputParam.eColorFormat) ||
+            (OMX_COLOR_Format24bitRGB888 == aInputParam.eColorFormat) ||
+            (OMX_COLOR_Format12bitRGB444 == aInputParam.eColorFormat) ||
+            (OMX_COLOR_FormatYUV420SemiPlanar == aInputParam.eColorFormat))
+    {
+        iVideoFormat = aInputParam.eColorFormat;
+    }
+    else
+    {
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+
+    if (OMX_TRUE == iInitialized)
+    {
+        /* clean up before re-initialized */
+        PVAVCCleanUpEncoder(&iAvcHandle);
+        iAvcHandle.AVCObject = NULL;
+
+        if (iYUVIn)
+        {
+            oscl_free(iYUVIn);
+            iYUVIn = NULL;
+        }
+
+    }
+
+    //Verify the input compression format
+    if (OMX_VIDEO_CodingUnused != aInputParam.eCompressionFormat)
+    {
+        //Input port must have no compression supported
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+    // allocate iYUVIn
+    if ((iSrcWidth & 0xF) || (iSrcHeight & 0xF) || (OMX_COLOR_FormatYUV420Planar != iVideoFormat)) /* Not multiple of 16 */
+    {
+        iYUVIn = (uint8*) oscl_malloc(((((iSrcWidth + 15) >> 4) * ((iSrcHeight + 15) >> 4)) * 3) << 7);
+        if (NULL == iYUVIn)
+        {
+            return OMX_ErrorInsufficientResources;
+        }
+    }
+
+    /* Initialize the color conversion */
+    if (OMX_COLOR_Format24bitRGB888 == iVideoFormat)
+    {
+        ccRGBtoYUV = CCRGB24toYUV420::New();
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 180 ? CCBOTTOM_UP : 0));
+    }
+    if (OMX_COLOR_Format12bitRGB444 == iVideoFormat)
+    {
+        ccRGBtoYUV = CCRGB12toYUV420::New();
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 180 ? CCBOTTOM_UP : 0));
+    }
+    if (OMX_COLOR_FormatYUV420SemiPlanar == iVideoFormat)
+    {
+        ccRGBtoYUV = CCYUV420SEMItoYUV420::New();
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth , iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 180 ? CCBOTTOM_UP : 0));
+    }
+
+    aEncOption.width = aEncodeParam.nFrameWidth;
+    aEncOption.height = aEncodeParam.nFrameHeight;
+    aEncOption.frame_rate = (uint32)(1000 * ((aEncodeParam.xFramerate >> 16) + (OsclFloat)(aEncodeParam.xFramerate & 0xFFFF) / (1 << 16)));
+
+    switch (aRateControlType.eControlRate)
+    {
+        case OMX_Video_ControlRateDisable:
+        {
+            aEncOption.rate_control = AVC_OFF;
+            aEncOption.bitrate = 48000; // default
+        }
+        break;
+
+        //Both the below cases have same body
+        case OMX_Video_ControlRateConstant:
+        case OMX_Video_ControlRateVariable:
+        {
+            aEncOption.rate_control = AVC_ON;
+            aEncOption.bitrate = aEncodeParam.nBitrate;
+        }
+        break;
+
+        default:
+            return OMX_ErrorUnsupportedSetting;
+    }
+
+    //Set the profile of encoder
+    switch (aEncodeAvcParam.eProfile)
+    {
+        case OMX_VIDEO_AVCProfileBaseline:
+        {
+            aEncOption.profile = AVC_BASELINE;
+        }
+        break;
+
+        case OMX_VIDEO_AVCProfileMain:
+        {
+            aEncOption.profile = AVC_MAIN;
+        }
+        break;
+
+        case OMX_VIDEO_AVCProfileExtended:
+        {
+            aEncOption.profile = AVC_EXTENDED;
+        }
+        break;
+
+        case OMX_VIDEO_AVCProfileHigh:
+        {
+            aEncOption.profile = AVC_HIGH;
+        }
+        break;
+
+        case OMX_VIDEO_AVCProfileHigh10:
+        {
+            aEncOption.profile = AVC_HIGH10;
+        }
+        break;
+
+        case OMX_VIDEO_AVCProfileHigh422:
+        {
+            aEncOption.profile = AVC_HIGH422;
+        }
+        break;
+
+        case OMX_VIDEO_AVCProfileHigh444:
+        {
+            aEncOption.profile = AVC_HIGH444;
+        }
+        break;
+
+        default:
+        {
+            aEncOption.profile = AVC_BASELINE;
+        }
+        break;
+    }
+
+
+    //Set the level of avc encoder
+    switch (aEncodeAvcParam.eLevel)
+    {
+        case OMX_VIDEO_AVCLevel1:
+        {
+            aEncOption.level = AVC_LEVEL1;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel1b:
+        {
+            aEncOption.level = AVC_LEVEL1_B;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel11:
+        {
+            aEncOption.level = AVC_LEVEL1_1;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel12:
+        {
+            aEncOption.level = AVC_LEVEL1_2;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel13:
+        {
+            aEncOption.level = AVC_LEVEL1_3;
+        }
+        break;
+
+
+        case OMX_VIDEO_AVCLevel2:
+        {
+            aEncOption.level = AVC_LEVEL2;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel21:
+        {
+            aEncOption.level = AVC_LEVEL2_1;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel22:
+        {
+            aEncOption.level = AVC_LEVEL2_2;
+        }
+        break;
+
+
+        case OMX_VIDEO_AVCLevel3:
+        {
+            aEncOption.level = AVC_LEVEL3;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel31:
+        {
+            aEncOption.level = AVC_LEVEL3_1;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel32:
+        {
+            aEncOption.level = AVC_LEVEL3_2;
+        }
+        break;
+
+
+        case OMX_VIDEO_AVCLevel4:
+        {
+            aEncOption.level = AVC_LEVEL4;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel41:
+        {
+            aEncOption.level = AVC_LEVEL4_1;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel42:
+        {
+            aEncOption.level = AVC_LEVEL4_2;
+        }
+        break;
+
+
+        case OMX_VIDEO_AVCLevel5:
+        {
+            aEncOption.level = AVC_LEVEL5;
+        }
+        break;
+        case OMX_VIDEO_AVCLevel51:
+        {
+            aEncOption.level = AVC_LEVEL5_1;
+        }
+        break;
+
+        default:
+        {
+            aEncOption.level = AVC_LEVEL5_1;
+        }
+        break;
+    }
+
+    aEncOption.initQP = aQuantType.nQpP;
+
+    aEncOption.init_CBP_removal_delay = 1600;	//Default value
+    aEncOption.CPB_size = ((uint32)(2 * aEncOption.bitrate));
+    if (OMX_VIDEO_PictureTypeI == aEncodeAvcParam.nAllowedPictureTypes) // I-only
+    {
+        aEncOption.idr_period = 1;
+    }
+    else
+    {
+        //IPPPPPPPPPP, no I frame for a long period of time
+        if (0xFFFFFFFF == aEncodeAvcParam.nPFrames)
+        {
+            aEncOption.idr_period = -1;
+        }
+        else
+        {
+            aEncOption.idr_period = aEncodeAvcParam.nPFrames + 1;
+        }
+    }
+
+    if ((OMX_VIDEO_IntraRefreshCyclic == aIntraRefresh.eRefreshMode) ||
+            (OMX_VIDEO_IntraRefreshBoth == aIntraRefresh.eRefreshMode))
+    {
+        aEncOption.intramb_refresh = aIntraRefresh.nCirMBs;
+    }
+
+
+    if ((OMX_VIDEO_IntraRefreshAdaptive == aIntraRefresh.eRefreshMode) ||
+            (OMX_VIDEO_IntraRefreshBoth == aIntraRefresh.eRefreshMode))
+    {
+        aEncOption.auto_scd = AVC_ON;
+    }
+    else
+    {
+        aEncOption.auto_scd = AVC_OFF;
+    }
+
+    aEncOption.out_of_band_param_set = AVC_ON;		//Default value
+
+    /* default values */
+    aEncOption.poc_type = 2;
+    aEncOption.log2_max_poc_lsb_minus_4 = 12;
+    aEncOption.delta_poc_zero_flag = 0;
+    aEncOption.offset_poc_non_ref = 0;
+    aEncOption.offset_top_bottom  = 0;
+    aEncOption.num_ref_in_cycle = 0;
+    aEncOption.offset_poc_ref = NULL;
+
+    aEncOption.num_ref_frame = 1;	//We only support this value
+
+    //Since FMO is disabled in our case, num of slice group is always 1
+    aEncOption.num_slice_group = 1;
+    aEncOption.fmo_type = 0;	//Disabled in this case
+
+    aEncOption.db_filter = AVC_ON;
+
+    if (OMX_VIDEO_AVCLoopFilterEnable == aEncodeAvcParam.eLoopFilterMode)
+    {
+        aEncOption.disable_db_idc = 0;
+    }
+    else if (OMX_VIDEO_AVCLoopFilterDisable == aEncodeAvcParam.eLoopFilterMode)
+    {
+        aEncOption.disable_db_idc = 1;
+    }
+    else if (OMX_VIDEO_AVCLoopFilterDisableSliceBoundary == aEncodeAvcParam.eLoopFilterMode)
+    {
+        aEncOption.disable_db_idc = 2;
+    }
+    else
+    {
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+    aEncOption.alpha_offset = 0;
+    aEncOption.beta_offset = 0;
+    aEncOption.constrained_intra_pred = (OMX_TRUE == aEncodeAvcParam.bconstIpred) ? AVC_ON : AVC_OFF;
+
+    aEncOption.data_par = AVC_OFF;
+    aEncOption.fullsearch = AVC_OFF;
+    aEncOption.search_range = (aSearchRange.sXSearchRange <= aSearchRange.sYSearchRange ? aSearchRange.sXSearchRange : aSearchRange.sYSearchRange);
+
+    if (OMX_Video_MotionVectorPixel == aSearchRange.eAccuracy)
+    {
+        aEncOption.sub_pel = AVC_OFF;
+    }
+    else
+    {
+        aEncOption.sub_pel = AVC_ON;
+    }
+
+    if (aVbsmcType.b16x16 != OMX_TRUE)
+    {
+        return OMX_ErrorBadParameter;
+    }
+
+    aEncOption.submb_pred =  AVC_OFF; // default for now, ignore aVbsmcType.8x16, 16x8, 8x8, etc.
+    aEncOption.rdopt_mode = AVC_OFF;
+    aEncOption.bidir_pred = AVC_OFF;
+
+    /***** Initlaize the encoder *****/
+    if (AVCENC_SUCCESS != PVAVCEncInitialize(&iAvcHandle, &aEncOption, NULL, NULL))
+    {
+        iInitialized = OMX_FALSE;
+        return OMX_ErrorBadParameter;
+    }
+
+    iIDR = OMX_TRUE;
+    iDispOrd = 0;
+    iInitialized = OMX_TRUE;
+    iReadyForNextFrame = OMX_TRUE;
+
+    return OMX_ErrorNone;
+
+}
+
+
+OMX_BOOL AvcEncoder_OMX::AvcEncodeSendInput(OMX_U8*    aInBuffer,
+        OMX_U32*   aInBufSize,
+        OMX_TICKS  aInTimeStamp)
+{
+    AVCEnc_Status AvcStatus;
+
+    if (OMX_COLOR_FormatYUV420Planar == iVideoFormat)
+    {
+        /* Input Buffer Size Check
+         * Input buffer size should be equal to one frame, otherwise drop the frame
+         * as it is a corrupt data and don't encode it */
+        if (*aInBufSize < (OMX_U32)((iSrcWidth * iSrcHeight * 3) >> 1))
+        {
+            //Mark the inpur buffer consumed to indicate corrupt frame
+            *aInBufSize = 0;
+            return OMX_FALSE;
+        }
+
+        if (iYUVIn) /* iSrcWidth is not multiple of 4 or iSrcHeight is odd number */
+        {
+            CopyToYUVIn(aInBuffer, iSrcWidth, iSrcHeight,
+                        ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
+            iVideoIn = iYUVIn;
+        }
+        else /* otherwise, we can just use aVidIn->iSource */
+        {
+            iVideoIn = aInBuffer;
+        }
+    }
+    else if (OMX_COLOR_Format12bitRGB444 == iVideoFormat)
+    {
+        if (*aInBufSize < (OMX_U32)(iSrcWidth * iSrcHeight * 2))
+        {
+            //Mark the inpur buffer consumed to indicate corrupt frame
+            *aInBufSize = 0;
+            return OMX_FALSE;
+        }
+        ccRGBtoYUV->Convert((uint8*)aInBuffer, iYUVIn);
+        iVideoIn = iYUVIn;
+    }
+    else if (OMX_COLOR_Format24bitRGB888 == iVideoFormat)
+    {
+        if (*aInBufSize < (OMX_U32)(iSrcWidth * iSrcHeight * 3))
+        {
+            //Mark the inpur buffer consumed to indicate corrupt frame
+            *aInBufSize = 0;
+            return OMX_FALSE;
+        }
+        ccRGBtoYUV->Convert((uint8*)aInBuffer, iYUVIn);
+        iVideoIn = iYUVIn;
+    }
+    else if (OMX_COLOR_FormatYUV420SemiPlanar == iVideoFormat)
+    {
+        if (*aInBufSize < (OMX_U32)(iSrcWidth * iSrcHeight * 3) >> 1)
+        {
+            //Mark the inpur buffer consumed to indicate corrupt frame
+            *aInBufSize = 0;
+            return OMX_FALSE;
+        }
+        ccRGBtoYUV->Convert((uint8*)aInBuffer, iYUVIn);
+        iVideoIn = iYUVIn;
+    }
+
+    /* assign with backward-P or B-Vop this timestamp must be re-ordered */
+    iTimeStamp = aInTimeStamp;
+
+    iVidIn.height = ((iSrcHeight + 15) >> 4) << 4;
+    iVidIn.pitch = ((iSrcWidth + 15) >> 4) << 4;
+    iVidIn.coding_timestamp = iTimeStamp;
+    iVidIn.YCbCr[0] = (uint8*)iVideoIn;
+    iVidIn.YCbCr[1] = (uint8*)(iVideoIn + iVidIn.height * iVidIn.pitch);
+    iVidIn.YCbCr[2] = iVidIn.YCbCr[1] + ((iVidIn.height * iVidIn.pitch) >> 2);
+    iVidIn.disp_order = iDispOrd;
+
+    AvcStatus = PVAVCEncSetInput(&iAvcHandle, &iVidIn);
+    //Mark the inpur buffer consumed after caling SetInput api
+    *aInBufSize = 0;
+
+    if (AVCENC_SUCCESS == AvcStatus)
+    {
+        iDispOrd++;
+        iReadyForNextFrame = OMX_FALSE;
+        return OMX_TRUE;
+    }
+    else if (AVCENC_NEW_IDR == AvcStatus)
+    {
+        iDispOrd++;
+        iIDR = OMX_TRUE;
+        iReadyForNextFrame = OMX_FALSE;
+        return OMX_TRUE;
+    }
+    else
+    {
+        return OMX_FALSE;
+    }
+
+}
+
+
+/*Encode routine */
+AVCEnc_Status AvcEncoder_OMX::AvcEncodeVideo(OMX_U8* aOutBuffer,
+        OMX_U32*   aOutputLength,
+        OMX_BOOL*  aBufferOverRun,
+        OMX_U8**   aOverBufferPointer,
+        OMX_U8*    aInBuffer,
+        OMX_U32*   aInBufSize,
+        OMX_TICKS  aInTimeStamp,
+        OMX_TICKS* aOutTimeStamp,
+        OMX_BOOL*  aSyncFlag)
+{
+    AVCEnc_Status AvcStatus;
+    AVCEnc_Status ReturnValue;
+    OMX_BOOL	SetInputStatus = OMX_TRUE;
+    AVCFrameIO recon;
+    uint Size;
+    int  NALType;
+
+    if (OMX_FALSE == iSpsPpsHeaderFlag)
+    {
+        Size = *aOutputLength;
+        AvcStatus =	PVAVCEncodeNAL(&iAvcHandle, aOutBuffer, &Size, &NALType);
+
+        //No more SPS and PPS NAL's to come, mark the header flag as true
+        if (AVCENC_WRONG_STATE == AvcStatus)
+        {
+            *aOutputLength = 0;
+            iSpsPpsHeaderFlag = OMX_TRUE;
+            return AVCENC_WRONG_STATE;
+        }
+
+        switch (NALType)
+        {
+            case AVC_NALTYPE_SPS:
+            case AVC_NALTYPE_PPS:
+            {
+                *aOutputLength = Size;
+                //Mark the SPS and PPS buffers with the first input bufer timestamp
+                *aOutTimeStamp = aInTimeStamp;
+                return AVCENC_SUCCESS;
+            }
+
+            default:
+            {
+                //No more SPS and PPS NAL's to come, mark the header flag as true
+                *aOutputLength = 0;
+                iSpsPpsHeaderFlag = OMX_TRUE;
+                return AVCENC_FAIL;
+            }
+        }
+    }
+
+
+    if (OMX_TRUE == iReadyForNextFrame)
+    {
+        SetInputStatus = AvcEncodeSendInput(aInBuffer, aInBufSize, aInTimeStamp);
+    }
+
+    if (OMX_TRUE == SetInputStatus)		//success
+    {
+        Size = *aOutputLength;
+
+        AvcStatus = PVAVCEncodeNAL(&iAvcHandle, (uint8*)aOutBuffer, &Size, &NALType);
+
+        if (AVCENC_SUCCESS == AvcStatus)
+        {
+            *aSyncFlag = iIDR;
+            //Calling the overrun buffer api to see whether overrun buffer has been used or not
+            *aOverBufferPointer = PVAVCEncGetOverrunBuffer(&iAvcHandle);
+
+            if (NULL != *aOverBufferPointer)
+            {
+                //Output data has been filled in the over run buffer, mark the flag as true
+                *aBufferOverRun = OMX_TRUE;
+            }
+
+            ReturnValue = AVCENC_SUCCESS;
+        }
+        else if (AVCENC_PICTURE_READY == AvcStatus)
+        {
+            //Calling the overrun buffer api to see whether overrun buffer has been used or not
+            *aOverBufferPointer = PVAVCEncGetOverrunBuffer(&iAvcHandle);
+
+            if (NULL != *aOverBufferPointer)
+            {
+                //Output data has been filled in the over run buffer, mark the flag as true
+                *aBufferOverRun = OMX_TRUE;
+            }
+
+            *aSyncFlag = iIDR;
+            if (iIDR == OMX_TRUE)
+            {
+                iIDR = OMX_FALSE;
+            }
+            ReturnValue = AVCENC_PICTURE_READY;
+            iReadyForNextFrame = OMX_TRUE;	//ready to receive another set of input frame
+
+            AvcStatus = PVAVCEncGetRecon(&iAvcHandle, &recon);
+            if (AVCENC_SUCCESS == AvcStatus)
+            {
+                PVAVCEncReleaseRecon(&iAvcHandle, &recon);
+            }
+        }
+        else
+        {
+            *aOutputLength = 0;
+            iReadyForNextFrame = OMX_TRUE;	//ready to receive another set of input frame
+            return AVCENC_FAIL;
+        }
+
+        *aOutputLength = Size;
+        *aOutTimeStamp = iTimeStamp;
+
+        return ReturnValue;
+
+    }
+    else
+    {
+        *aOutputLength = 0;
+        return AVCENC_FAIL;
+    }
+}
+
+
+//Deinitialize the avc encoder here and perform the cleanup and free operations
+OMX_ERRORTYPE AvcEncoder_OMX::AvcEncDeinit()
+{
+    if (OMX_TRUE == iInitialized)
+    {
+        PVAVCCleanUpEncoder(&iAvcHandle);
+        iAvcHandle.AVCObject = NULL;
+
+        iInitialized = OMX_FALSE;
+        iReadyForNextFrame = OMX_TRUE;
+
+        if (iYUVIn)
+        {
+            oscl_free(iYUVIn);
+            iYUVIn = NULL;
+        }
+    }
+
+    if (iFrameUsed)
+    {
+        oscl_free(iFrameUsed);
+        iFrameUsed = NULL;
+    }
+
+    if (ccRGBtoYUV)
+    {
+        OSCL_DELETE(ccRGBtoYUV);
+        ccRGBtoYUV = NULL;
+    }
+
+    if (iDPB)
+    {
+        oscl_free(iDPB);
+        iDPB = NULL;
+    }
+
+    if (iFramePtr)
+    {
+        oscl_free(iFramePtr);
+        iFramePtr = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+int AvcEncoder_OMX::AVC_DPBAlloc(uint frame_size_in_mbs, uint num_buffers)
+{
+    int ii;
+    uint frame_size = (frame_size_in_mbs << 8) + (frame_size_in_mbs << 7);
+
+    if (iDPB) oscl_free(iDPB); // free previous one first
+
+    iDPB = (uint8*) oscl_malloc(sizeof(uint8) * frame_size * num_buffers);
+    if (iDPB == NULL)
+    {
+        return 0;
+    }
+
+    iNumFrames = num_buffers;
+
+    if (iFrameUsed) oscl_free(iFrameUsed); // free previous one
+
+    iFrameUsed = (bool*) oscl_malloc(sizeof(bool) * num_buffers);
+    if (iFrameUsed == NULL)
+    {
+        return 0;
+    }
+
+    if (iFramePtr) oscl_free(iFramePtr); // free previous one
+    iFramePtr = (uint8**) oscl_malloc(sizeof(uint8*) * num_buffers);
+    if (iFramePtr == NULL)
+    {
+        return 0;
+    }
+
+    iFramePtr[0] = iDPB;
+    iFrameUsed[0] = false;
+
+    for (ii = 1; ii < (int)num_buffers; ii++)
+    {
+        iFrameUsed[ii] = false;
+        iFramePtr[ii] = iFramePtr[ii-1] + frame_size;
+    }
+
+    return 1;
+}
+
+
+//Request for an I frame while encoding is in process
+OMX_ERRORTYPE AvcEncoder_OMX::AvcRequestIFrame()
+{
+    if (AVCENC_SUCCESS != PVAVCEncIDRRequest(&iAvcHandle))
+    {
+        return OMX_ErrorUndefined;
+    }
+
+    return OMX_ErrorNone;
+
+}
+
+//Routine to update bitrate dynamically when encoding is in progress
+OMX_BOOL AvcEncoder_OMX::AvcUpdateBitRate(OMX_U32 aEncodedBitRate)
+{
+    int32 BitRate[2] = {0, 0};
+    BitRate[0] = aEncodedBitRate;
+
+    if (AVCENC_SUCCESS != PVAVCEncUpdateBitRate(&iAvcHandle, BitRate[0]))
+    {
+        return OMX_FALSE;
+    }
+
+    return OMX_TRUE;
+}
+
+//Routine to update frame rate dynamically when encoding is in progress
+OMX_BOOL AvcEncoder_OMX::AvcUpdateFrameRate(OMX_U32 aEncodeFramerate)
+{
+    OMX_U32 EncFrameRate[2] = {0, 0};
+    EncFrameRate[0] = aEncodeFramerate >> 16;
+
+    if (AVCENC_SUCCESS != PVAVCEncUpdateFrameRate(&iAvcHandle, (uint32)(1000*EncFrameRate[0]), 1000))
+    {
+        return OMX_FALSE;
+    }
+
+    return OMX_TRUE;
+
+}
+
+
+
+/* ///////////////////////////////////////////////////////////////////////// */
+void AvcEncoder_OMX::AVC_FrameUnbind(int indx)
+{
+    /*if (indx < iNumFrames)
+    {
+    	iFrameUsed[indx] = false;
+    }*/
+
+    OSCL_UNUSED_ARG(indx);
+    return ;
+}
+
+/* ///////////////////////////////////////////////////////////////////////// */
+int AvcEncoder_OMX::AVC_FrameBind(int indx, uint8** yuv)
+{
+    /*if ((iFrameUsed[indx]==true) || (indx >= iNumFrames))
+    {
+    	return 0; // already in used
+    }
+    iFrameUsed[indx] = true;*/
+
+    *yuv = iFramePtr[indx];
+    return 1;
+}
+
+
+
+/* ///////////////////////////////////////////////////////////////////////// */
+/* Copy from YUV input to YUV frame inside AvcEnc lib						*/
+/* When input is not YUV, the color conv will write it directly to iVideoInOut. */
+/* ///////////////////////////////////////////////////////////////////////// */
+
+void AvcEncoder_OMX::CopyToYUVIn(uint8 *YUV, int width, int height, int width_16, int height_16)
+{
+    uint8 *y, *u, *v, *yChan, *uChan, *vChan;
+    int y_ind, ilimit, jlimit, i, j, ioffset;
+    int size = width * height;
+    int size16 = width_16 * height_16;
+
+    /* do padding at the bottom first */
+    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
+    if (height < height_16 || width < width_16) /* if padding */
+    {
+        int offset = (height < height_16) ? height : height_16;
+
+        offset = (offset * width_16);
+
+        if (width < width_16)
+        {
+            offset -= (width_16 - width);
+        }
+
+        yChan = (uint8*)(iYUVIn + offset);
+        oscl_memset(yChan, 16, size16 - offset); /* pad with zeros */
+
+        uChan = (uint8*)(iYUVIn + size16 + (offset >> 2));
+        oscl_memset(uChan, 128, (size16 - offset) >> 2);
+
+        vChan = (uint8*)(iYUVIn + size16 + (size16 >> 2) + (offset >> 2));
+        oscl_memset(vChan, 128, (size16 - offset) >> 2);
+    }
+
+    /* then do padding on the top */
+    yChan = (uint8*)iYUVIn; /* Normal order */
+    uChan = (uint8*)(iYUVIn + size16);
+    vChan = (uint8*)(uChan + (size16 >> 2));
+
+    u = (uint8*)(&(YUV[size]));
+    v = (uint8*)(&(YUV[size*5/4]));
+
+    /* To center the output */
+    if (height_16 > height)   /* output taller than input */
+    {
+        if (width_16 >= width)  /* output wider than or equal input */
+        {
+            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+        }
+        else  /* output narrower than input */
+        {
+            i = ((height_16 - height) >> 1) * width_16;
+            j = ((height_16 - height) >> 2) * (width_16 >> 1);
+            YUV += ((width - width_16) >> 1);
+            u += ((width - width_16) >> 2);
+            v += ((width - width_16) >> 2);
+        }
+        oscl_memset((uint8 *)yChan, 16, i);
+        yChan += i;
+        oscl_memset((uint8 *)uChan, 128, j);
+        uChan += j;
+        oscl_memset((uint8 *)vChan, 128, j);
+        vChan += j;
+    }
+    else   /* output shorter or equal input */
+    {
+        if (width_16 >= width)   /* output wider or equal input */
+        {
+            i = (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+            YUV += (((height - height_16) >> 1) * width);
+            u += (((height - height_16) >> 1) * width) >> 2;
+            v += (((height - height_16) >> 1) * width) >> 2;
+        }
+        else  /* output narrower than input */
+        {
+            i = 0;
+            j = 0;
+            YUV += (((height - height_16) >> 1) * width + ((width - width_16) >> 1));
+            u += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 2;
+            v += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 2;
+        }
+        oscl_memset((uint8 *)yChan, 16, i);
+        yChan += i;
+        oscl_memset((uint8 *)uChan, 128, j);
+        uChan += j;
+        oscl_memset((uint8 *)vChan, 128, j);
+        vChan += j;
+    }
+
+    /* Copy with cropping or zero-padding */
+    if (height < height_16)
+        jlimit = height;
+    else
+        jlimit = height_16;
+
+    if (width < width_16)
+    {
+        ilimit = width;
+        ioffset = width_16 - width;
+    }
+    else
+    {
+        ilimit = width_16;
+        ioffset = 0;
+    }
+
+    /* Copy Y */
+    /* Set up pointer for fast looping */
+    y = (uint8*)YUV;
+
+    if (width == width_16 && height == height_16) /* no need to pad */
+    {
+        oscl_memcpy(yChan, y, size);
+    }
+    else
+    {
+        for (y_ind = 0; y_ind < (jlimit - 1) ;y_ind++)
+        {
+            oscl_memcpy(yChan, y, ilimit);
+            oscl_memset(yChan + ilimit, 16, ioffset); /* pad with zero */
+            yChan += width_16;
+            y += width;
+        }
+        oscl_memcpy(yChan, y, ilimit); /* last line no padding */
+    }
+    /* Copy U and V */
+    /* Set up pointers for fast looping */
+    if (width == width_16 && height == height_16) /* no need to pad */
+    {
+        oscl_memcpy(uChan, u, size >> 2);
+        oscl_memcpy(vChan, v, size >> 2);
+    }
+    else
+    {
+        for (y_ind = 0; y_ind < (jlimit >> 1) - 1;y_ind++)
+        {
+            oscl_memcpy(uChan, u, ilimit >> 1);
+            oscl_memcpy(vChan, v, ilimit >> 1);
+            oscl_memset(uChan + (ilimit >> 1), 128, ioffset >> 1);
+            oscl_memset(vChan + (ilimit >> 1), 128, ioffset >> 1);
+            uChan += (width_16 >> 1);
+            u += (width >> 1);
+            vChan += (width_16 >> 1);
+            v += (width >> 1);
+        }
+        oscl_memcpy(uChan, u, ilimit >> 1); /* last line no padding */
+        oscl_memcpy(vChan, v, ilimit >> 1);
+    }
+
+    return ;
+}
+
diff --git a/codecs_v2/omx/omx_h264enc/src/omx_avcenc_component.cpp b/codecs_v2/omx/omx_h264enc/src/omx_avcenc_component.cpp
new file mode 100644
index 0000000..011d15b
--- /dev/null
+++ b/codecs_v2/omx/omx_h264enc/src/omx_avcenc_component.cpp
@@ -0,0 +1,1002 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "omx_avcenc_component.h"
+
+#if PROXY_INTERFACE
+#include "omx_proxy_interface.h"
+#endif
+
+
+// This function is called by OMX_GetHandle and it creates an instance of the avc component AO
+OMX_ERRORTYPE AvcEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+
+    OmxComponentAvcEncAO* pOpenmaxAOType;
+    OMX_ERRORTYPE Status;
+
+    // move InitAvcOmxComponentFields content to actual constructor
+
+    pOpenmaxAOType = (OmxComponentAvcEncAO*) OSCL_NEW(OmxComponentAvcEncAO, ());
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Call the construct component to initialize OMX types
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
+
+    *pHandle = pOpenmaxAOType->GetOmxHandle();
+
+    return Status;
+}
+
+
+// This function is called by OMX_FreeHandle when component AO needs to be destroyed
+OMX_ERRORTYPE AvcEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    // get pointer to component AO
+    OmxComponentAvcEncAO* pOpenmaxAOType = (OmxComponentAvcEncAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
+
+    // clean up decoder, OMX component stuff
+    pOpenmaxAOType->DestroyComponent();
+
+    // destroy the AO class
+    OSCL_DELETE(pOpenmaxAOType);
+
+    return OMX_ErrorNone;
+}
+
+#if DYNAMIC_LOAD_OMX_AVCENC_COMPONENT
+
+class AvcEncOmxSharedLibraryInterface: public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static AvcEncOmxSharedLibraryInterface *Instance()
+        {
+            static AvcEncOmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_AVCENC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AvcEncOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&AvcEncOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        AvcEncOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return AvcEncOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
+
+
+OMX_ERRORTYPE OmxComponentAvcEncAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
+{
+    ComponentPortType *pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
+
+    iNumPorts = 2;
+    iCompressedFormatPortNum = OMX_PORT_OUTPUTPORT_INDEX;
+    iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
+    iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
+    iOmxComponent.pApplicationPrivate = pAppData; // init the App data
+
+
+#if PROXY_INTERFACE
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
+
+    iOmxComponent.SendCommand = OmxComponentAvcEncAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OmxComponentAvcEncAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OmxComponentAvcEncAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OmxComponentAvcEncAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OmxComponentAvcEncAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentAvcEncAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentAvcEncAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OmxComponentAvcEncAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentAvcEncAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentAvcEncAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentAvcEncAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentAvcEncAO::BaseComponentProxyFillThisBuffer;
+
+#else
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
+
+    iOmxComponent.SendCommand = OmxComponentAvcEncAO::BaseComponentSendCommand;
+    iOmxComponent.GetParameter = OmxComponentAvcEncAO::BaseComponentGetParameter;
+    iOmxComponent.SetParameter = OmxComponentAvcEncAO::BaseComponentSetParameter;
+    iOmxComponent.GetConfig = OmxComponentAvcEncAO::BaseComponentGetConfig;
+    iOmxComponent.SetConfig = OmxComponentAvcEncAO::BaseComponentSetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentAvcEncAO::BaseComponentGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentAvcEncAO::BaseComponentGetState;
+    iOmxComponent.UseBuffer = OmxComponentAvcEncAO::BaseComponentUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentAvcEncAO::BaseComponentAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentAvcEncAO::BaseComponentFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentAvcEncAO::BaseComponentEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentAvcEncAO::BaseComponentFillThisBuffer;
+#endif
+
+    iOmxComponent.SetCallbacks = OmxComponentAvcEncAO::BaseComponentSetCallbacks;
+    iOmxComponent.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
+    iOmxComponent.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
+    iOmxComponent.nVersion.s.nRevision = SPECREVISION;
+    iOmxComponent.nVersion.s.nStep = SPECSTEP;
+
+    // PV capability
+    iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
+
+    if (ipAppPriv)
+    {
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
+    if (NULL == ipAppPriv)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
+    {
+        return Status;
+    }
+
+    /** Domain specific section for input raw port */ //OMX_PARAM_PORTDEFINITIONTYPE
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainVideo;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"raw";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.pNativeRender = 0;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.bFlagErrorConcealment = OMX_FALSE;
+
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.nFrameWidth = 176;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.nFrameHeight = 144;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.nBitrate = 64000;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.xFramerate = (15 << 16);
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDir = OMX_DirInput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_INPUT_BUFFER_AVCENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize = INPUT_BUFFER_SIZE_AVCENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+
+    /** Domain specific section for output avc port */
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainVideo;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"video/avc";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.pNativeRender = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.bFlagErrorConcealment = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameWidth = 176;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameHeight = 144;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nBitrate = 64000;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.xFramerate = (15 << 16);
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDir = OMX_DirOutput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_OUTPUT_BUFFER_AVCENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferSize = OUTPUT_BUFFER_SIZE_AVCENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+
+    //OMX_VIDEO_PARAM_AVCTYPE	//Default values for avc video output param port
+    oscl_memset(&ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc, 0, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+    SetHeader(&ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc, sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.eProfile = OMX_VIDEO_AVCProfileBaseline;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.eLevel = OMX_VIDEO_AVCLevel1b;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.nPFrames = 0xFFFFFFFF;	//Default value
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.nBFrames = 0;		//No support for B frames
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.nRefFrames = 1;	//Only support this value
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.bEnableFMO = OMX_FALSE;	//Default value is false
+
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.bFrameMBsOnly = OMX_TRUE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.bMBAFF = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.bEntropyCodingCABAC = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.bWeightedPPrediction = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc.bDirect8x8Inference = OMX_FALSE;
+
+
+    //OMX_VIDEO_PARAM_PROFILELEVELTYPE structure
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel.nProfileIndex = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel.eProfile = OMX_VIDEO_AVCProfileBaseline;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel.eLevel = OMX_VIDEO_AVCLevel1b;
+
+
+    iPortTypesParam.nPorts = 2;
+    iPortTypesParam.nStartPortNumber = 0;
+
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+
+    pInPort->ActualNumPortFormatsSupported = 4;
+
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE INPUT PORT SETTINGS
+    //On input port for index 0
+    SetHeader(&pInPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[0].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[0].nIndex = 0;
+    pInPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    pInPort->VideoParam[0].xFramerate = (15 << 16);
+
+    //On input port for index 1
+    SetHeader(&pInPort->VideoParam[1], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[1].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[1].nIndex = 1;
+    pInPort->VideoParam[1].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[1].eColorFormat = OMX_COLOR_Format24bitRGB888;
+    pInPort->VideoParam[1].xFramerate = (15 << 16);
+
+    //On input port for index 2
+    SetHeader(&pInPort->VideoParam[2], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[2].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[2].nIndex = 2;
+    pInPort->VideoParam[2].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[2].eColorFormat = OMX_COLOR_Format12bitRGB444;
+    pInPort->VideoParam[2].xFramerate = (15 << 16);
+
+    //On input port for index 3
+    SetHeader(&pInPort->VideoParam[3], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[3].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[3].nIndex = 3;
+    pInPort->VideoParam[3].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[3].eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+    pInPort->VideoParam[3].xFramerate = (15 << 16);
+
+    pOutPort->ActualNumPortFormatsSupported = 1;
+
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE OUTPUT PORT SETTINGS
+    //On output port for index 0
+    SetHeader(&pOutPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pOutPort->VideoParam[0].nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoParam[0].nIndex = 0;
+    pOutPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatUnused;
+    pOutPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingAVC;
+    pOutPort->VideoParam[0].xFramerate = (15 << 16);
+
+
+    //OMX_CONFIG_ROTATIONTYPE SETTINGS ON INPUT PORT
+    SetHeader(&pInPort->VideoOrientationType, sizeof(OMX_CONFIG_ROTATIONTYPE));
+    pInPort->VideoOrientationType.nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoOrientationType.nRotation = -1;  //For all the YUV formats that are other than RGB
+
+
+    //OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE settings of output port
+    oscl_memset(&pOutPort->VideoErrorCorrection, 0, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+    SetHeader(&pOutPort->VideoErrorCorrection, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+    pOutPort->VideoErrorCorrection.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoErrorCorrection.bEnableDataPartitioning = OMX_FALSE;
+
+
+    //OMX_VIDEO_PARAM_BITRATETYPE settings of output port
+    SetHeader(&pOutPort->VideoRateType, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
+    pOutPort->VideoRateType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoRateType.eControlRate = OMX_Video_ControlRateConstant;
+    pOutPort->VideoRateType.nTargetBitrate = 64000;
+
+
+    //OMX_CONFIG_FRAMERATETYPE default seetings (specified in khronos conformance test)
+    SetHeader(&pOutPort->VideoConfigFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE));
+    pOutPort->VideoConfigFrameRateType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoConfigFrameRateType.xEncodeFramerate = (15 << 16);
+
+    //OMX_VIDEO_CONFIG_BITRATETYPE default settings (specified in khronos conformance test)
+    SetHeader(&pOutPort->VideoConfigBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE));
+    pOutPort->VideoConfigBitRateType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoConfigBitRateType.nEncodeBitrate = 64000;
+
+
+    //OMX_VIDEO_PARAM_QUANTIZATIONTYPE settings of output port
+    SetHeader(&pOutPort->VideoQuantType, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
+    pOutPort->VideoQuantType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoQuantType.nQpI = 0;	//Not required by encoder
+    pOutPort->VideoQuantType.nQpP = 0;	//Default is 0
+    pOutPort->VideoQuantType.nQpB = 0;	//Not required by encoder
+
+
+    //OMX_VIDEO_PARAM_VBSMCTYPE settings of output port
+    oscl_memset(&pOutPort->VideoBlockMotionSize, 0, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+    SetHeader(&pOutPort->VideoBlockMotionSize, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+    pOutPort->VideoBlockMotionSize.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoBlockMotionSize.b16x16 = OMX_TRUE;		//Encoder only support this mode
+
+
+    //OMX_VIDEO_PARAM_MOTIONVECTORTYPE settings of output port
+    oscl_memset(&pOutPort->VideoMotionVector, 0, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+    SetHeader(&pOutPort->VideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+    pOutPort->VideoMotionVector.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoMotionVector.eAccuracy = OMX_Video_MotionVectorQuarterPel;
+    pOutPort->VideoMotionVector.bUnrestrictedMVs = OMX_TRUE;		//Only support true
+    pOutPort->VideoMotionVector.sXSearchRange = 16;
+    pOutPort->VideoMotionVector.sYSearchRange = 16;
+
+
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE settings of output port
+    oscl_memset(&pOutPort->VideoIntraRefresh, 0, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+    SetHeader(&pOutPort->VideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+    pOutPort->VideoIntraRefresh.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoIntraRefresh.eRefreshMode = OMX_VIDEO_IntraRefreshCyclic;
+    pOutPort->VideoIntraRefresh.nCirMBs = 0;
+
+    //OMX_VIDEO_PARAM_AVCSLICEFMO settings on output port
+    oscl_memset(&pOutPort->AvcSliceFMO, 0, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO));
+    SetHeader(&pOutPort->AvcSliceFMO, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO));
+    pOutPort->AvcSliceFMO.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->AvcSliceFMO.eSliceMode = OMX_VIDEO_SLICEMODE_AVCDefault;
+    pOutPort->AvcSliceFMO.nNumSliceGroups = 1;
+    pOutPort->AvcSliceFMO.nSliceGroupMapType = 1;			//Only support map type of 1
+
+
+    //OMX_CONFIG_INTRAREFRESHVOPTYPE settings of output port
+    oscl_memset(&pOutPort->VideoIFrame, 0, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+    SetHeader(&pOutPort->VideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+    pOutPort->VideoIFrame.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoIFrame.IntraRefreshVOP = OMX_FALSE;
+
+
+    //Construct the encoder object
+    if (ipAvcEncoderObject)
+    {
+        OSCL_DELETE(ipAvcEncoderObject);
+        ipAvcEncoderObject = NULL;
+    }
+
+    ipAvcEncoderObject = OSCL_NEW(AvcEncoder_OMX, ());
+
+#if PROXY_INTERFACE
+
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+
+#endif
+
+    return OMX_ErrorNone;
+}
+
+
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	*/
+
+OMX_ERRORTYPE OmxComponentAvcEncAO::DestroyComponent()
+{
+    if (OMX_FALSE != iIsInit)
+    {
+        ComponentDeInit();
+    }
+
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipAvcEncoderObject)
+    {
+        OSCL_DELETE(ipAvcEncoderObject);
+        ipAvcEncoderObject = NULL;
+    }
+
+    if (ipAppPriv)
+    {
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+void OmxComponentAvcEncAO::ProcessData()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData IN"));
+
+    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    ComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+
+    OMX_U8*					pOutBuffer;
+    OMX_U32					OutputLength;
+    AVCEnc_Status			EncodeReturn = AVCENC_SUCCESS;
+    OMX_COMPONENTTYPE*		pHandle = &iOmxComponent;
+
+    if ((!iIsInputBufferEnded) || (iEndofStream))
+    {
+        //Check whether prev output bufer has been released or not
+        if (OMX_TRUE == iNewOutBufRequired)
+        {
+            //Check whether a new output buffer is available or not
+            if (0 == (GetQueueNumElem(pOutputQueue)))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData OUT output buffer unavailable"));
+                return;
+            }
+
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer->nFilledLen = 0;
+            iNewOutBufRequired = OMX_FALSE;
+
+
+            /* If some output data was left to be send from the last processing due to
+             * unavailability of required number of output buffers,
+             * copy it now and send back before processing new input frame */
+            if (iInternalOutBufFilledLen > 0)
+            {
+                if (OMX_FALSE == CopyDataToOutputBuffer())
+                {
+                    //We fell short of output buffers, exit now and wait for some more buffers to get queued
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData OUT output buffer unavailable"));
+                    return;
+                }
+                else
+                {
+                    //Attach the end of frame flag while sending out the last piece of output buffer
+                    ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+                    if (OMX_TRUE == iSyncFlag)
+                    {
+                        ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+                        iSyncFlag = OMX_FALSE;
+                    }
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+
+                    //Dequeue new output buffer to continue encoding the next frame
+                    if (0 == (GetQueueNumElem(pOutputQueue)))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData OUT output buffer unavailable"));
+                        return;
+                    }
+
+                    ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+                    ipOutputBuffer->nFilledLen = 0;
+                    iNewOutBufRequired = OMX_FALSE;
+                }
+            }
+        }
+
+        /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
+         * command and hMarkTargetComponent as given by the specifications
+         */
+        if (ipMark != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipMark = NULL;
+        }
+
+        if (ipTargetComponent != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
+            ipTargetComponent = NULL;
+
+        }
+        //Mark buffer code ends here
+
+        //Call the encoder only if there is some data to encode
+        if (iInputCurrLength > 0)
+        {
+            pOutBuffer = ipOutputBuffer->pBuffer;
+            OutputLength = ipOutputBuffer->nAllocLen;
+
+            //Output buffer is passed as a short pointer
+            EncodeReturn = ipAvcEncoderObject->AvcEncodeVideo(pOutBuffer,
+                           &OutputLength,
+                           &iBufferOverRun,
+                           &ipInternalOutBuffer,
+                           ipFrameDecodeBuffer,
+                           &iInputCurrLength,
+                           iFrameTimestamp,
+                           &iOutputTimeStamp,
+                           &iSyncFlag);
+
+
+            //Chk whether output data has been generated or not
+            if (OutputLength > 0)
+            {
+                //offset not required in our case, set it to zero
+                ipOutputBuffer->nOffset = 0;
+                ipOutputBuffer->nTimeStamp = iOutputTimeStamp;
+
+                if (OMX_FALSE == iBufferOverRun)
+                {
+                    //No internal buffer is maintained
+                    ipOutputBuffer->nFilledLen = OutputLength;
+                }
+                else
+                {
+                    iInternalOutBufFilledLen = OutputLength;
+                    iBufferOverRun = OMX_FALSE;
+                    CopyDataToOutputBuffer();
+
+                }	//else loop of if (OMX_FALSE == iMantainOutInternalBuffer)
+            }	//if (OutputLength > 0)	 loop
+
+
+            //If encoder returned error in case of frame skip/corrupt frame, report it to the client via a callback
+            if ((AVCENC_FAIL == EncodeReturn) && (OMX_FALSE == iEndofStream))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : Frame skipped, ProcessData ErrorStreamCorrupt callback send"));
+
+                (*(ipCallbacks->EventHandler))
+                (pHandle,
+                 iCallbackData,
+                 OMX_EventError,
+                 OMX_ErrorStreamCorrupt,
+                 0,
+                 NULL);
+            }
+
+
+            //Return the input buffer that has been consumed fully
+            if (0 == iInputCurrLength)
+            {
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
+                ipInputBuffer = NULL;
+
+                iIsInputBufferEnded = OMX_TRUE;
+                iInputCurrLength = 0;
+            }
+
+            iFrameCount++;
+        }
+
+
+        /* If EOS flag has come from the client & there are no more
+         * input buffers to decode, send the callback to the client
+         */
+        if (OMX_TRUE == iEndofStream)
+        {
+            if (((0 == iInputCurrLength) || (AVCENC_FAIL == EncodeReturn)) &&
+                    (0 == iInternalOutBufFilledLen))
+            {
+
+                (*(ipCallbacks->EventHandler))
+                (pHandle,
+                 iCallbackData,
+                 OMX_EventBufferFlag,
+                 1,
+                 OMX_BUFFERFLAG_EOS,
+                 NULL);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData EOS callback sent"));
+
+
+                //Mark this flag false once the callback has been send back
+                iEndofStream = OMX_FALSE;
+
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                if (OMX_TRUE == iSyncFlag)
+                {
+                    ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+                    iSyncFlag = OMX_FALSE;
+                }
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData OUT"));
+                return;
+            }
+
+        }
+
+        //Send the output buffer back after decode
+        if ((ipOutputBuffer->nFilledLen > 0) && (OMX_FALSE == iNewOutBufRequired))
+        {
+            //Attach the end of frame flag while sending out the last piece of output buffer
+            ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+            if (OMX_TRUE == iSyncFlag)
+            {
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+                iSyncFlag = OMX_FALSE;
+            }
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+        }
+
+
+        /* If there is some more processing left with current buffers, re-schedule the AO
+         * Do not go for more than one round of processing at a time.
+         * This may block the AO longer than required.
+         */
+        if ((iInputCurrLength != 0 || GetQueueNumElem(pInputQueue) > 0)
+                && (GetQueueNumElem(pOutputQueue) > 0))
+        {
+            RunIfNotReady();
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ProcessData OUT"));
+}
+
+
+OMX_BOOL OmxComponentAvcEncAO::CopyDataToOutputBuffer()
+{
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    while (iInternalOutBufFilledLen > 0)
+    {
+        if (ipOutputBuffer->nAllocLen >= iInternalOutBufFilledLen)
+        {
+            //Pack the whole  data into the output buffer Alloc length data in one buffer and return it
+            oscl_memcpy(ipOutputBuffer->pBuffer, ipInternalOutBuffer, iInternalOutBufFilledLen);
+            ipOutputBuffer->nFilledLen = iInternalOutBufFilledLen;
+
+        }
+        else
+        {
+            oscl_memcpy(ipOutputBuffer->pBuffer, ipInternalOutBuffer, ipOutputBuffer->nAllocLen);
+            ipOutputBuffer->nFilledLen = ipOutputBuffer->nAllocLen;
+        }
+
+        iInternalOutBufFilledLen -= ipOutputBuffer->nFilledLen;
+        ipInternalOutBuffer += ipOutputBuffer->nFilledLen;
+
+
+        if (0 != iInternalOutBufFilledLen)
+        {
+            //Mark the sync Flag in every piece of IDR NAL
+            if (OMX_TRUE == iSyncFlag)
+            {
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+            }
+            //Return the partial output buffer and try to fetch a new output buffer for filling the remaining data
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+
+            //Check whether a new output buffer is available or not
+            if (0 == (GetQueueNumElem(pOutputQueue)))
+            {
+                return OMX_FALSE;
+            }
+
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer->nTimeStamp = iOutputTimeStamp;
+            ipOutputBuffer->nOffset = 0;
+            iNewOutBufRequired = OMX_FALSE;
+        }
+    }	//while (iInternalOutBufFilledLen > 0)
+
+    return OMX_TRUE;
+
+}
+
+
+//Not implemented & supported in case of base profile components
+
+void OmxComponentAvcEncAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
+{
+    *aRoleString = (OMX_STRING)"video_encoder.avc";
+}
+
+
+//Component constructor
+OmxComponentAvcEncAO::OmxComponentAvcEncAO()
+{
+    ipAvcEncoderObject = NULL;
+    ipInternalOutBuffer = NULL;
+    iInternalOutBufFilledLen = 0;
+    iSyncFlag = OMX_FALSE;
+    iBufferOverRun = OMX_FALSE;
+
+    if (!IsAdded())
+    {
+        AddToScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : constructed"));
+}
+
+
+//Active object destructor
+OmxComponentAvcEncAO::~OmxComponentAvcEncAO()
+{
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : destructed"));
+}
+
+
+OMX_ERRORTYPE OmxComponentAvcEncAO::SetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_IN  OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig IN"));
+
+    OMX_U32 PortIndex;
+
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    OMX_CONFIG_INTRAREFRESHVOPTYPE* pAvcIFrame;
+    OMX_VIDEO_CONFIG_BITRATETYPE* pBitRateType;
+    OMX_CONFIG_FRAMERATETYPE* pFrameRateType;
+
+
+
+    if (NULL == pComponentConfigStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nIndex)
+    {
+        case OMX_IndexConfigVideoIntraVOPRefresh:
+        {
+            pAvcIFrame = (OMX_CONFIG_INTRAREFRESHVOPTYPE*) pComponentConfigStructure;
+            PortIndex = pAvcIFrame->nPortIndex;
+
+            if (PortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error invalid port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            /*Check Structure Header*/
+            ErrorType = CheckHeader(pAvcIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error param check failed"));
+                return ErrorType;
+            }
+
+            //Call the RequestI frame routine of the encoder in case of setconfig call
+            if (OMX_TRUE == pAvcIFrame->IntraRefreshVOP)
+            {
+                ipAvcEncoderObject->AvcRequestIFrame();
+
+            }
+        }
+        break;
+
+        case OMX_IndexConfigVideoBitrate:
+        {
+            pBitRateType = (OMX_VIDEO_CONFIG_BITRATETYPE*) pComponentConfigStructure;
+            PortIndex = pBitRateType->nPortIndex;
+
+            if (PortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error invalid port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            /*Check Structure Header*/
+            ErrorType = CheckHeader(pBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error param check failed"));
+                return ErrorType;
+            }
+
+            //Call the corresponding routine of the encoder in case of setconfig call
+            if (OMX_FALSE == (ipAvcEncoderObject->AvcUpdateBitRate(pBitRateType->nEncodeBitrate)))
+            {
+                return OMX_ErrorBadParameter;
+
+            }
+
+            ipPorts[PortIndex]->VideoConfigBitRateType.nEncodeBitrate = pBitRateType->nEncodeBitrate;
+        }
+        break;
+
+        case OMX_IndexConfigVideoFramerate:
+        {
+            pFrameRateType = (OMX_CONFIG_FRAMERATETYPE*) pComponentConfigStructure;
+            PortIndex = pFrameRateType->nPortIndex;
+
+            if (PortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error invalid port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            /*Check Structure Header*/
+            ErrorType = CheckHeader(pFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error param check failed"));
+                return ErrorType;
+            }
+
+            //Call the corresponding routine of the encoder in case of setconfig call
+            if (OMX_FALSE == (ipAvcEncoderObject->AvcUpdateFrameRate(pFrameRateType->xEncodeFramerate)))
+            {
+                return OMX_ErrorBadParameter;
+            }
+
+            ipPorts[PortIndex]->VideoConfigFrameRateType.xEncodeFramerate = pFrameRateType->xEncodeFramerate;
+        }
+        break;
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig error Unsupported Index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+        break;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : SetConfig OUT"));
+    return OMX_ErrorNone;
+
+}
+
+
+
+/** The Initialization function
+ */
+OMX_ERRORTYPE OmxComponentAvcEncAO::ComponentInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ComponentInit IN"));
+
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+
+    if (OMX_TRUE == iIsInit)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ComponentInit error incorrect operation"));
+        return OMX_ErrorIncorrectStateOperation;
+    }
+    iIsInit = OMX_TRUE;
+
+
+    if (!iCodecReady)
+    {
+        iCodecReady = OMX_TRUE;
+    }
+
+    //Verify the parameters and return failure in case they cannot be supported by our encoder
+    OMX_VIDEO_PARAM_AVCTYPE* pAvcParam = (OMX_VIDEO_PARAM_AVCTYPE*) & ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc;
+    OMX_VIDEO_PARAM_AVCSLICEFMO* pAvcSliceFMO = (OMX_VIDEO_PARAM_AVCSLICEFMO*) & ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AvcSliceFMO;
+
+    //FMO enabled is not supported in the encoder
+    if ((pAvcParam->nBFrames > 0) ||
+            (0 == (pAvcParam->nAllowedPictureTypes &
+                   (OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP))) ||
+            (OMX_FALSE == pAvcParam->bFrameMBsOnly) ||
+            (OMX_TRUE == pAvcParam->bMBAFF) ||
+            (OMX_TRUE == pAvcParam->bEntropyCodingCABAC) ||
+            (OMX_TRUE == pAvcParam->bWeightedPPrediction) ||
+            (OMX_TRUE == pAvcParam->bDirect8x8Inference) ||
+            (OMX_TRUE == pAvcParam->bEnableFMO) ||
+            (1 != pAvcSliceFMO->nSliceGroupMapType))
+    {
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+
+    //Library init routine
+    Status = ipAvcEncoderObject->AvcEncInit(
+                 ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video,
+                 ipPorts[OMX_PORT_INPUTPORT_INDEX]->VideoOrientationType,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoAvc,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoRateType,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoQuantType,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMotionVector,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoIntraRefresh,
+                 ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoBlockMotionSize);
+
+    iInputCurrLength = 0;
+
+    //Used in dynamic port reconfiguration
+    iFrameCount = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ComponentInit OUT"));
+
+    return Status;
+
+}
+
+/** This function is called upon a transition to the idle or invalid state.
+ *  Also it is called by the ComponentDestructor() function
+ */
+OMX_ERRORTYPE OmxComponentAvcEncAO::ComponentDeInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ComponentDeInit IN"));
+
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+
+    iIsInit = OMX_FALSE;
+
+    if (iCodecReady)
+    {
+        Status = ipAvcEncoderObject->AvcEncDeinit();
+        iCodecReady = OMX_FALSE;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentAvcEncAO : ComponentDeInit OUT"));
+
+    return Status;
+
+}
+
+/* A component specific routine called from BufferMgmtWithoutMarker */
+void OmxComponentAvcEncAO::ProcessInBufferFlag()
+{
+    iIsInputBufferEnded = OMX_FALSE;
+}
diff --git a/codecs_v2/omx/omx_m4v/Android.mk b/codecs_v2/omx/omx_m4v/Android.mk
old mode 100755
new mode 100644
index b3de036..63ecf75
--- a/codecs_v2/omx/omx_m4v/Android.mk
+++ b/codecs_v2/omx/omx_m4v/Android.mk
@@ -2,33 +2,34 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/m4v_io.cpp \
 	src/omx_mpeg4_component.cpp \
-	src/mpeg4_dec.cpp
-
+ 	src/mpeg4_dec.cpp
 
 
 LOCAL_MODULE := libomx_m4v_component_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_m4v/include \
-	$(PV_TOP)//codecs_v2/omx/omx_m4v/src \
-	$(PV_TOP)//codecs_v2/omx/omx_m4v/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//codecs_v2/omx/omx_m4v/../../video/m4v_h263/dec/src \
-	$(PV_TOP)//codecs_v2/omx/omx_m4v/../../video/m4v_h263/dec/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_m4v/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_m4v/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/omx/omx_baseclass/include \
+ 	$(PV_TOP)/codecs_v2/video/m4v_h263/dec/src \
+ 	$(PV_TOP)/codecs_v2/video/m4v_h263/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/m4v_io.h \
 	include/omx_mpeg4_component.h \
-	include/mpeg4_dec.h \
-	include/mpeg4video_frame.h
+ 	include/mpeg4_dec.h \
+ 	include/mpeg4video_frame.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_m4v/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_m4v/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..b06aec0
--- /dev/null
+++ b/codecs_v2/omx/omx_m4v/build/make_multithreaded/local.mk
@@ -0,0 +1,33 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_m4v_component_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+        ../../../../../extern_libs_v2/khronos/openmax/include \
+        ../../../../omx/omx_baseclass/include \
+        ../../../../video/m4v_h263/dec/src \
+        ../../../../video/m4v_h263/dec/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS :=	omx_mpeg4_component.cpp \
+	mpeg4_dec.cpp 
+
+
+HDRS :=	omx_mpeg4_component.h \
+	mpeg4_dec.h \
+	mpeg4video_frame.h
+
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_m4v/build/make_multithreaded/makefile b/codecs_v2/omx/omx_m4v/build/make_multithreaded/makefile
deleted file mode 100755
index 508bed7..0000000
--- a/codecs_v2/omx/omx_m4v/build/make_multithreaded/makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_m4v_component_lib
-
-XINCDIRS += \
-	-I ../../../../../extern_libs_v2/khronos/openmax/include \
-	-I ../../../../video/m4v_h263/dec/src \
-	-I ../../../../video/m4v_h263/dec/include
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = 	m4v_io.cpp \
-	omx_mpeg4_component.cpp \
-	mpeg4_dec.cpp 
-
-
-HDRS =	m4v_io.h \
-	omx_mpeg4_component.h \
-	mpeg4_dec.h \
-	mpeg4video_frame.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_m4v/include/m4v_io.h b/codecs_v2/omx/omx_m4v/include/m4v_io.h
deleted file mode 100755
index 24f71e4..0000000
--- a/codecs_v2/omx/omx_m4v/include/m4v_io.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- *
- * Release: 050926
- *
- ***************************************************************************/
-#ifndef _M4VIO_H_
-#define _M4VIO_H_
-
-#define BIT_BUFF_SIZE 8024000
-#define TRUE 1
-#define FALSE 0
-
-#include "oscl_types.h"
-
-int32 m4v_getVideoHeader(int32 layer, uint8 *buf, int32 max_size);
-int32 m4v_getNextVideoSample(int32 layer_id, uint8 **buf, int32 max_buffer_size, uint32 *ts);
-
-#endif
diff --git a/codecs_v2/omx/omx_m4v/include/mpeg4_dec.h b/codecs_v2/omx/omx_m4v/include/mpeg4_dec.h
old mode 100755
new mode 100644
index 3c4ae90..2c47290
--- a/codecs_v2/omx/omx_m4v/include/mpeg4_dec.h
+++ b/codecs_v2/omx/omx_m4v/include/mpeg4_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,10 +30,6 @@
 #include "mp4dec_lib.h"
 #endif
 
-#ifndef _M4VIO_H_
-#include "m4v_io.h"
-#endif
-
 class Mpeg4Decoder_OMX
 {
     public:
@@ -48,10 +44,12 @@
         OMX_BOOL Mp4DecodeVideo(OMX_U8* aOutBuffer, OMX_U32* aOutputLength,
                                 OMX_U8** aInputBuf, OMX_U32* aInBufSize,
                                 OMX_PARAM_PORTDEFINITIONTYPE* aPortParam,
-                                OMX_S32* aIsFirstBuffer, OMX_BOOL aMarkerFlag, OMX_BOOL *aResizeFlag);
+                                OMX_S32* aFrameCount, OMX_BOOL aMarkerFlag, OMX_BOOL *aResizeFlag);
 
         OMX_ERRORTYPE Mp4DecDeinit();
 
+        OMX_S32 GetVideoHeader(int32 aLayer, uint8 *aBuf, int32 aMaxSize);
+
         OMX_S32 Mpeg4InitFlag;
 
     private:
@@ -59,7 +57,8 @@
         VideoDecControls VideoCtrl;
 
         OMX_U8* pFrame0, *pFrame1;
-
+        OMX_S32 iDisplay_Width, iDisplay_Height;
+        OMX_S32 iShortVideoHeader;
 
         OMX_U8 VO_START_CODE1[4];
         OMX_U8 VOSH_START_CODE1[4];
diff --git a/codecs_v2/omx/omx_m4v/include/mpeg4video_frame.h b/codecs_v2/omx/omx_m4v/include/mpeg4video_frame.h
old mode 100755
new mode 100644
index aa52f3d..1d37055
--- a/codecs_v2/omx/omx_m4v/include/mpeg4video_frame.h
+++ b/codecs_v2/omx/omx_m4v/include/mpeg4video_frame.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,43 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*
-
-	=====================================================================
-	File: mpeg4VideoDecoder.h
-	Description: MPEG-4 video decoder class header.
-	Rev:   1.0 A
-	Created: April 11, 2000
-	=====================================================================
-
-	Revision History:
-		Rev:	NONE
-		Date:
-		Author:
-		Description:
-
-/////////////////////////////////////////////////////////////////////////
-*/
 
 #include "mp4dec_api.h"
 
-/* //////////////////////////////////////////////////////////////////////
-
-	=====================================================================
-	File: mpeg4VideoDecoder.h
-	Description: MPEG-4 video decoder application class.
-	Rev:   1.0 A
-	Created: April 11, 2000
-	=====================================================================
-
-	Revision History:
-		Rev:	NONE
-		Date:
-		Author:
-		Description:
-
-/////////////////////////////////////////////////////////////////////////
-*/
 int InitializeVideoDecode(int32 *width, int32 *height,
                           unsigned char **buffer, int32 *size, int32 *max_size, int postproc);
 
diff --git a/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h b/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h
old mode 100755
new mode 100644
index 1ded78d..9f908ab
--- a/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h
+++ b/codecs_v2/omx/omx_m4v/include/omx_mpeg4_component.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@
 #ifndef OMX_MPEG4_COMPONENT_H_INCLUDED
 #define OMX_MPEG4_COMPONENT_H_INCLUDED
 
-#ifndef OMX_Component_h
-#include "omx_component.h"
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
 #endif
 
 #ifndef MPEG4_DEC_H_INCLUDED
@@ -33,48 +33,13 @@
 #endif
 
 
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PV_OMX_QUEUE_H_INCLUDED
-#include "pv_omx_queue.h"
-#endif
-
-#ifndef PV_OMXCORE_H_INCLUDED
-#include "pv_omxcore.h"
-#endif
-
-
-#define OMX_PORT_INPUTPORT_INDEX OMX_DirInput
-#define OMX_PORT_OUTPUTPORT_INDEX OMX_DirOutput
-#define OMX_PORT_ALLPORT_INDEX -1
-
-
-#define INPUT_BUFFER_SIZE_MP4 64000
+#define INPUT_BUFFER_SIZE_MP4 16000
 #define OUTPUT_BUFFER_SIZE_MP4 152064
 
 #define NUMBER_INPUT_BUFFER_MP4  10
 #define NUMBER_OUTPUT_BUFFER_MP4  2
 
-
-/* Application's private data */
-typedef struct Mpeg4PrivateType
-{
-    OMX_HANDLETYPE Mpeg4Handle;
-
-}Mpeg4PrivateType;
-
-
-/**
- * This is the Component template from which all
- * other Component instances are factored by the core.
- */
-
+#define MINIMUM_H263_SHORT_HEADER_SIZE 12
 /**
  * The structure for port Type.
  */
@@ -84,319 +49,49 @@
     MODE_MPEG4
 };
 
-typedef struct Mpeg4ComponentPortType
-{
-    /** @param pBuffer An array of pointers to buffer headers. */
-    OMX_BUFFERHEADERTYPE** pBuffer;
-    /** @param BufferState The State of the Buffer whether assigned or allocated */
-    OMX_U32* BufferState;
-    /** @param NumAssignedBuffers Number of buffer assigned on each port */
-    OMX_U32 NumAssignedBuffers;
-    /** @param pBufferQueue queue for buffer to be processed by the port */
-    QueueType* pBufferQueue;
-    OMX_STATETYPE TransientState;
-    /** @param BufferUnderProcess  Boolean variables indicate whether the port is processing any buffer */
-    OMX_BOOL BufferUnderProcess;
-    OMX_PARAM_PORTDEFINITIONTYPE PortParam;
-    /** @param NumBufferFlushed Number of buffer Flushed */
-    OMX_U32 NumBufferFlushed;
-    /** @param IsPortFlushed Boolean variables indicate port is being flushed at the moment */
-    OMX_BOOL IsPortFlushed;
 
-    OMX_VIDEO_PARAM_PORTFORMATTYPE VideoParam;
-    OMX_VIDEO_PARAM_MPEG4TYPE VideoMpeg4;
-    OMX_VIDEO_PARAM_H263TYPE VideoH263;
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE ProfileLevel;
-
-    //Added these flags as a replacement of semaphores on win32 platform
-    OMX_BOOL LoadedToIdleFlag ;
-    OMX_BOOL IdleToLoadedFlag ;
-
-} Mpeg4ComponentPortType;
-
-
-class OpenmaxMpeg4AO : public OsclActiveObject
+class OpenmaxMpeg4AO : public OmxComponentVideo
 {
     public:
 
         OpenmaxMpeg4AO();
         ~OpenmaxMpeg4AO();
 
-        /** Component entry points declarations */
-        static OMX_ERRORTYPE BaseComponentGetComponentVersion(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STRING pComponentName,
-            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
-            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
-            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
 
-        static OMX_ERRORTYPE BaseComponentGetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
 
-        static OMX_ERRORTYPE BaseComponentSetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
 
-        static OMX_ERRORTYPE BaseComponentGetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_INOUT OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentSetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentGetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        static OMX_ERRORTYPE BaseComponentGetState(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STATETYPE* pState);
-
-        static OMX_ERRORTYPE BaseComponentUseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentAllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        static OMX_ERRORTYPE BaseComponentFreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_U32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        static OMX_ERRORTYPE BaseComponentComponentDeInit(
-            OMX_IN  OMX_HANDLETYPE hComponent);
-
-        static OMX_ERRORTYPE BaseComponentEmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentFillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        static void Mpeg4ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
-
-        /*NON STATIC COUNTERPARTS OF STATIC MEMBER API'S */
-
-        OMX_ERRORTYPE GetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
-
-        OMX_ERRORTYPE SetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        void SetDecoderMode(int);
+        void ComponentBufferMgmtWithoutMarker();
+        void ProcessData();
+        void DecodeWithoutMarker();
+        void DecodeWithMarker();
 
         OMX_ERRORTYPE GetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE SetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        OMX_ERRORTYPE GetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        void GetState(OMX_OUT OMX_STATETYPE* pState);
-
-        OMX_ERRORTYPE UseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        OMX_ERRORTYPE AllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        OMX_ERRORTYPE FreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_S32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        OMX_ERRORTYPE EmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE FillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData);
-        OMX_ERRORTYPE DestroyComponent();
-
-        OMX_PTR GetOmxHandle()
-        {
-            return &iOmxComponent;
-        };
-
-        void SetDecoderMode(int);
-        /*OTHER PROCESSING FUNCTIONS */
-
-        void Mpeg4ComponentBufferMgmtFunction();
-        void Mpeg4BufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE*);
-        void Mpeg4DecodeWithoutMarker();
-        void Mpeg4DecodeWithMarker(OMX_BUFFERHEADERTYPE*);
-        OMX_BOOL Mpeg4ComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer);
-
-        OMX_ERRORTYPE Mpeg4ComponentMessageHandler(CoreMessage* Message);
-        OMX_ERRORTYPE Mpeg4ComponentDoStateSet(OMX_U32);
-
-        OMX_ERRORTYPE Mpeg4ComponentDisablePort(OMX_S32 PortIndex);
-        void Mpeg4ComponentDisableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE Mpeg4ComponentEnablePort(OMX_S32 PortIndex);
-        void Mpeg4ComponentEnableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE Mpeg4ComponentFlushPort(OMX_S32 PortIndex);
-
-        void Mpeg4ComponentSetPortFlushFlag(OMX_S32, OMX_S32 index, OMX_BOOL value);
-        void Mpeg4ComponentSetNumBufferFlush(OMX_S32, OMX_S32 index, OMX_S32 value);
-
-        OMX_S32 Mpeg4ComponentPanic();
-
-        void Mpeg4ComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, Mpeg4ComponentPortType *pPort);
-        void Mpeg4ComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, Mpeg4ComponentPortType *pPort);
-
-        OMX_ERRORTYPE Mpeg4ComponentInit();
-        OMX_ERRORTYPE Mpeg4ComponentDeInit();
-
-        OMX_ERRORTYPE Mpeg4ComponentTunnelRequest(
-            OMX_IN  OMX_HANDLETYPE hComp,
-            OMX_IN  OMX_U32 nPort,
-            OMX_IN  OMX_HANDLETYPE hTunneledComp,
-            OMX_IN  OMX_U32 nTunneledPort,
-            OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
-
-        OMX_ERRORTYPE BaseComponentParameterSanityCheck(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_PTR pStructure,
-            OMX_IN  size_t size);
-
-        void SetHeader(OMX_PTR aheader, OMX_U32 asize);
-        OMX_ERRORTYPE CheckHeader(OMX_PTR aheader, OMX_U32 asize);
-
-        //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-        OMX_BOOL			iBufferExecuteFlag;
-        Mpeg4PrivateType*	ipAppPriv;
-
+        OMX_ERRORTYPE ReAllocatePartialAssemblyBuffers(OMX_BUFFERHEADERTYPE* aInputBufferHdr);
 
     private:
 
-        PVLogger* iLogger;
+        OMX_BOOL DecodeH263Header(OMX_U8* aInputBuffer, OMX_U32* aBufferSize);
 
-        void Run();
-
-        OMX_CALLBACKTYPE*	ipCallbacks;
-        OMX_PTR				iCallbackData;
-        OMX_STATETYPE		iState;
-
-        CoreDescriptorType* ipCoreDescriptor;
-        OMX_U32				iNumInputBuffer;
-        //OMX_U32				iNumComponentPorts;
-        OMX_U8*				ipFrameDecodeBuffer;
-        OMX_BOOL			iPartialFrameAssembly;
-        OMX_BOOL			iIsInputBufferEnded;
-        OMX_BOOL			iEndofStream;
-        OMX_U8*				ipTempInputBuffer;
-        OMX_U32				iTempInputBufferFilledLength;
-        OMX_COMPONENTTYPE*	ipTargetComponent;
-        OMX_PTR				iTargetMarkData;
-        OMX_COMPONENTTYPE*	ipTempTargetComponent;
-        OMX_PTR				iTempTargetMarkData;
-        OMX_BOOL			iMarkPropagate;
-        OMX_BOOL			iNewInBufferRequired;
-        OMX_U32				iTempConsumedLength;
-        OMX_U32				iOutBufferCount;
-        OMX_BOOL			iCodecReady;
-        OMX_U8*				ipInputCurrBuffer;
-        OMX_U32				iInputCurrLength;
-        OMX_S32				iFrameCount;
-        OMX_BOOL			iStateTransitionFlag;
-        OMX_BOOL			iFlushPortFlag;
-        OMX_BOOL				iEndOfFrameFlag;
-        OMX_BUFFERHEADERTYPE*	ipMpeg4InputBuffer;
-        OMX_BUFFERHEADERTYPE*	ipMpeg4OutputBuffer;
-        OMX_U32					iTempInputBufferAllocLength;
-
-        OMX_BOOL				iFirstFragment;
-        OMX_BOOL				iResizePending;
+        void ReadBits(OMX_U8* aStream, uint8 aNumBits, uint32* aOutData);
 
         OMX_BOOL				iUseExtTimestamp;
-        OMX_TICKS				iFrameTimestamp;
-
-        OMX_COMPONENTTYPE iOmxComponent;	// structure
-        OMX_U32			iNumPorts;
-
-        PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
-
-        //The ports of the component
-        Mpeg4ComponentPortType** ipPorts;
-        //Indicate whether component has been already initialized */
-        OMX_BOOL iIsInit;
-        //OpenMAX standard parameter that contains a short description of the available ports
-        OMX_PORT_PARAM_TYPE iPortTypesParam;
-        OMX_U32 iGroupPriority;
-        //ID of a group of components that share the same logical chain
-        OMX_U32 iGroupID;
-        //Roles of the component
-        OMX_U8 iComponentRole[OMX_MAX_STRINGNAME_SIZE];
-        //This field holds the private data associated with a mark request, if any
-        OMX_MARKTYPE* ipMark;
-
-        //Mpeg4 specific parameter
         Mpeg4Decoder_OMX* ipMpegDecoderObject;
-        int iDecMode;
+        OMX_S32 iDecMode;
+
+        //Parameters required for H.263 source format parsing
+        OMX_U32 iH263DataBitPos;
+        OMX_U32	iH263BitPos;
+        OMX_U32 iH263BitBuf;
 };
 
 
diff --git a/codecs_v2/omx/omx_m4v/src/m4v_io.cpp b/codecs_v2/omx/omx_m4v/src/m4v_io.cpp
deleted file mode 100755
index 5e6496f..0000000
--- a/codecs_v2/omx/omx_m4v/src/m4v_io.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- *
- * Release: 050926
- *
- ***************************************************************************/
-/* //////////////////////////////////////////////////////////////// */
-/*	Program	: m4v_io.cpp											*/
-/*	Date	: Dec. 22, 2000											*/
-/* ---------------------------------------------------------------- */
-/*	The MPEG-4 raw video bitstream I/O routines.					*/
-/* //////////////////////////////////////////////////////////////// */
-#include "m4v_io.h"
-#include "oscl_base_macros.h"
-
-static int32 nLayer;
-
-static uint8 VOSH_START_CODE[] = { 0x00, 0x00, 0x01, 0xB0 };
-static uint8 VO_START_CODE[] = { 0x00, 0x00, 0x01, 0x00 };
-static uint8 VOP_START_CODE[] = { 0x00, 0x00, 0x01, 0xB6 };
-static uint8 H263_START_CODE[] = { 0x00, 0x00, 0x80};
-
-static int short_video_header = FALSE;
-
-
-int32 m4v_getVideoLayerNumber()
-{
-    return nLayer;
-}
-
-int32 m4v_getVideoHeader(int32 layer, uint8 *buf, int32 max_size)
-{
-    OSCL_UNUSED_ARG(layer);
-
-    int32 count = 0;
-    char my_sc[4];
-
-    uint8 *tmp_bs = buf;
-
-    memcpy(my_sc, tmp_bs, 4);
-    my_sc[3] &= 0xf0;
-
-    if (max_size >= 4)
-    {
-        if (memcmp(my_sc, VOSH_START_CODE, 4) && memcmp(my_sc, VO_START_CODE, 4))
-        {
-            count = 0;
-            short_video_header = TRUE;
-        }
-        else
-        {
-            count = 0;
-            short_video_header = FALSE;
-            while (memcmp(tmp_bs + count, VOP_START_CODE, 4))
-            {
-                count++;
-                if (count > 1000)
-                {
-                    short_video_header = TRUE;
-                    break;
-                }
-            }
-            if (short_video_header == TRUE)
-            {
-                count = 0;
-                while (memcmp(tmp_bs + count, H263_START_CODE, 3))
-                {
-                    count++;
-                }
-            }
-        }
-    }
-    return count;
-}
-
-
diff --git a/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp b/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp
old mode 100755
new mode 100644
index 96bb8c2..4b37eea
--- a/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp
+++ b/codecs_v2/omx/omx_m4v/src/mpeg4_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
 
 #include "mpeg4_dec.h"
 #include "oscl_mem.h"
@@ -26,13 +29,16 @@
 #define PVH263DEFAULTWIDTH 352
 
 // from m4v_config_parser.h
-OSCL_IMPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int length, int *width, int *height, int *, int *);
+OSCL_IMPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *, int32 *);
 
 Mpeg4Decoder_OMX::Mpeg4Decoder_OMX()
 {
     pFrame0 = NULL;
     pFrame1 = NULL;
 
+    iDisplay_Width = 0;
+    iDisplay_Height = 0;
+
     VO_START_CODE1[0] = 0x00;
     VO_START_CODE1[1] = 0x00;
     VO_START_CODE1[2] = 0x01;
@@ -67,10 +73,9 @@
 OMX_BOOL Mpeg4Decoder_OMX::Mp4DecodeVideo(OMX_U8* aOutBuffer, OMX_U32* aOutputLength,
         OMX_U8** aInputBuf, OMX_U32* aInBufSize,
         OMX_PARAM_PORTDEFINITIONTYPE* aPortParam,
-        OMX_S32* aIsFirstBuffer, OMX_BOOL aMarkerFlag, OMX_BOOL *aResizeFlag)
+        OMX_S32* aFrameCount, OMX_BOOL aMarkerFlag, OMX_BOOL *aResizeFlag)
 {
     OMX_BOOL Status = OMX_TRUE;
-    static OMX_S32 display_Width, display_Height;
     OMX_S32 OldWidth, OldHeight, OldFrameSize;
 
     OldWidth = aPortParam->format.video.nFrameWidth;
@@ -80,67 +85,74 @@
 #ifdef _DEBUG
     static OMX_U32 FrameCount = 0;
 #endif
-    OMX_U32 UseExtTimestamp = 0;
-    OMX_S32 TimeStamp;
-    OMX_S32 MaxSize = BIT_BUFF_SIZE, FrameSize, InputSize, InitSize;
+    uint32 UseExtTimestamp = 0;
+    uint32 TimeStamp;
+    //OMX_S32 MaxSize = BIT_BUFF_SIZE;
+    OMX_S32 FrameSize, InputSize, InitSize;
     OMX_U8* pTempFrame, *pSrc[3];
 
     if (Mpeg4InitFlag == 0)
     {
         if (!aMarkerFlag)
         {
-            InitSize = m4v_getVideoHeader(0, *aInputBuf, *aInBufSize);
+            InitSize = GetVideoHeader(0, *aInputBuf, *aInBufSize);
         }
         else
         {
             InitSize = *aInBufSize;
         }
 
-        if (PV_TRUE != InitializeVideoDecode(&display_Width, &display_Height,
+        if (PV_TRUE != InitializeVideoDecode(&iDisplay_Width, &iDisplay_Height,
                                              aInputBuf, (OMX_S32*)aInBufSize, MPEG4_MODE))
             return OMX_FALSE;
 
         Mpeg4InitFlag = 1;
-        aPortParam->format.video.nFrameWidth = display_Width;
-        aPortParam->format.video.nFrameHeight = display_Height;
-        if ((display_Width != OldWidth) || (display_Height != OldHeight))
+        aPortParam->format.video.nFrameWidth = iDisplay_Width;
+        aPortParam->format.video.nFrameHeight = iDisplay_Height;
+        if ((iDisplay_Width != OldWidth) || (iDisplay_Height != OldHeight))
             *aResizeFlag = OMX_TRUE;
 
-        *aIsFirstBuffer = 1;
+        *aFrameCount = 1;
         *aInBufSize -= InitSize;
         return OMX_TRUE;
     }
 
-    MaxSize = *aInBufSize;
+    //MaxSize = *aInBufSize;
 
     if ((* (OMX_S32*)aInBufSize) <= 0)
     {
         return OMX_FALSE;
     }
 
-    TimeStamp = -1;
+    TimeStamp = 0xFFFFFFFF;
     InputSize = *aInBufSize;
 
     // in case of H263, read the 1st frame to find out the sizes (use the m4v_config)
-    if ((0 == *aIsFirstBuffer) && (H263_MODE == CodecMode))
+    if ((0 == *aFrameCount) && (H263_MODE == CodecMode))
     {
-        OMX_S32 aligned_width, aligned_height;
-        if (iGetM4VConfigInfo(*aInputBuf, *aInBufSize, (int *) &aligned_width, (int *) &aligned_height, (int*) &display_Width, (int *) &display_Height))
-            return OMX_FALSE;
+        int32 aligned_width, aligned_height;
+        int32 display_width, display_height;
 
-        aPortParam->format.video.nFrameWidth = display_Width; // use non 16byte aligned values (display_width) for H263
-        aPortParam->format.video.nFrameHeight = display_Height; // like in the case of M4V (PVGetVideoDimensions also returns display_width/height)
-        if ((display_Width != OldWidth) || (display_Height != OldHeight))
+        if (iGetM4VConfigInfo(*aInputBuf, *aInBufSize, &aligned_width, &aligned_height, &display_width, &display_height))
+        {
+            return OMX_FALSE;
+        }
+
+        iDisplay_Width = display_width;
+        iDisplay_Height = display_height;
+        aPortParam->format.video.nFrameWidth = iDisplay_Width; // use non 16byte aligned values (display_width) for H263
+        aPortParam->format.video.nFrameHeight = iDisplay_Height; // like in the case of M4V (PVGetVideoDimensions also returns display_width/height)
+        if ((iDisplay_Width != OldWidth) || (iDisplay_Height != OldHeight))
             *aResizeFlag = OMX_TRUE;
 
-        *aIsFirstBuffer = 1;
+        *aFrameCount = 1;
         return OMX_TRUE;
     }
 
     Status = (OMX_BOOL) PVDecodeVideoFrame(&VideoCtrl, aInputBuf,
-                                           (uint32*) & TimeStamp,
+                                           &TimeStamp,
                                            (int32*)aInBufSize,
-                                           (uint32*) & UseExtTimestamp,
+                                           &UseExtTimestamp,
                                            (OMX_U8*) pFrame0);
 
     if (Status == PV_TRUE)
@@ -156,15 +168,18 @@
         pFrame0 = (OMX_U8*) pFrame1;
         pFrame1 = (OMX_U8*) pTempFrame;
 
-        PVGetVideoDimensions(&VideoCtrl, (int32*) &display_Width, (int32*) &display_Height);
-        if ((display_Width != OldWidth) || (display_Height != OldHeight))
+        int32 display_width, display_height;
+        PVGetVideoDimensions(&VideoCtrl, &display_width, &display_height);
+        iDisplay_Width = display_width;
+        iDisplay_Height = display_height;
+        if ((iDisplay_Width != OldWidth) || (iDisplay_Height != OldHeight))
         {
 
-            aPortParam->format.video.nFrameWidth = display_Width;
-            aPortParam->format.video.nFrameHeight = display_Height;
+            aPortParam->format.video.nFrameWidth = iDisplay_Width;
+            aPortParam->format.video.nFrameHeight = iDisplay_Height;
             *aResizeFlag = OMX_TRUE;
         }
-        FrameSize = (((display_Width + 15) >> 4) << 4) * (((display_Height + 15) >> 4) << 4);
+        FrameSize = (((iDisplay_Width + 15) >> 4) << 4) * (((iDisplay_Height + 15) >> 4) << 4);
         OldFrameSize = (((OldWidth + 15) >> 4) << 4) * (((OldHeight + 15) >> 4) << 4);
 
         // THIS SHOULD NEVER HAPPEN, but just in case
@@ -188,7 +203,7 @@
             *aOutputLength = 0;
         }
 
-
+        (*aFrameCount)++;
     }
     else
     {
@@ -263,3 +278,48 @@
     return OMX_ErrorNone;
 }
 
+OMX_S32 Mpeg4Decoder_OMX::GetVideoHeader(int32 aLayer, uint8* aBuf, int32 aMaxSize)
+{
+    OSCL_UNUSED_ARG(aLayer);
+
+    int32 count = 0;
+    char my_sc[4];
+
+    uint8 *tmp_bs = aBuf;
+
+    oscl_memcpy(my_sc, tmp_bs, 4);
+    my_sc[3] &= 0xf0;
+
+    if (aMaxSize >= 4)
+    {
+        if (oscl_memcmp(my_sc, VOSH_START_CODE1, 4) && oscl_memcmp(my_sc, VO_START_CODE1, 4))
+        {
+            count = 0;
+            iShortVideoHeader = OMX_TRUE;
+        }
+        else
+        {
+            count = 0;
+            iShortVideoHeader = FALSE;
+            while (oscl_memcmp(tmp_bs + count, VOP_START_CODE1, 4))
+            {
+                count++;
+                if (count > 1000)
+                {
+                    iShortVideoHeader = OMX_TRUE;
+                    break;
+                }
+            }
+            if (iShortVideoHeader == OMX_TRUE)
+            {
+                count = 0;
+                while (oscl_memcmp(tmp_bs + count, H263_START_CODE1, 3))
+                {
+                    count++;
+                }
+            }
+        }
+    }
+    return count;
+}
+
diff --git a/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp b/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp
old mode 100755
new mode 100644
index 789f24e..c9eaaa3
--- a/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp
+++ b/codecs_v2/omx/omx_m4v/src/omx_mpeg4_component.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,21 +15,42 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-
+#include "oscl_base.h"
 #include "pv_omxdefs.h"
 #include "omx_mpeg4_component.h"
 
-
-extern OMX_U32 g_ComponentIndex; // this is determined outside the component
-
 #if PROXY_INTERFACE
 #include "omx_proxy_interface.h"
-extern ProxyApplication_OMX* pProxyTerm[];
 #endif
 
-// This function is called by OMX_GetHandle and it creates an instance of the mpeg4 component AO
-OMX_ERRORTYPE Mpeg4OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+static const uint32 mask[33] =
 {
+    0x00000000, 0x00000001, 0x00000003, 0x00000007,
+    0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
+    0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
+    0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
+    0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
+    0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
+    0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
+    0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
+    0xffffffff
+};
+
+// This function is called by OMX_GetHandle and it creates an instance of the mpeg4 component AO
+OSCL_EXPORT_REF OMX_ERRORTYPE Mpeg4OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy , OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
 
     OpenmaxMpeg4AO* pOpenmaxAOType;
     OMX_ERRORTYPE Status;
@@ -47,7 +68,7 @@
     pOpenmaxAOType->SetDecoderMode(MODE_MPEG4);
 
     //Call the construct component to initialize OMX types
-    Status = pOpenmaxAOType->ConstructComponent(pAppData);
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
 
     *pHandle = pOpenmaxAOType->GetOmxHandle();
 
@@ -56,8 +77,12 @@
 }
 
 // This function is called by OMX_FreeHandle when component AO needs to be destroyed
-OMX_ERRORTYPE Mpeg4OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle)
+OSCL_EXPORT_REF OMX_ERRORTYPE Mpeg4OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     // get pointer to component AO
     OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
 
@@ -71,8 +96,12 @@
 }
 
 // This function is called by OMX_GetHandle and it creates an instance of the h263 component AO
-OMX_ERRORTYPE H263OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
+OSCL_EXPORT_REF OMX_ERRORTYPE H263OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
 
     OpenmaxMpeg4AO* pOpenmaxAOType;
     OMX_ERRORTYPE Status;
@@ -90,7 +119,7 @@
     pOpenmaxAOType->SetDecoderMode(MODE_H263);
 
     //Call the construct component to initialize OMX types
-    Status = pOpenmaxAOType->ConstructComponent(pAppData);
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
 
     *pHandle = pOpenmaxAOType->GetOmxHandle();
 
@@ -99,8 +128,12 @@
 }
 
 // This function is called by OMX_FreeHandle when component AO needs to be destroyed
-OMX_ERRORTYPE H263OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle)
+OSCL_EXPORT_REF OMX_ERRORTYPE H263OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     // get pointer to component AO
     OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
 
@@ -113,6 +146,67 @@
     return OMX_ErrorNone;
 }
 
+#if (DYNAMIC_LOAD_OMX_M4V_COMPONENT || DYNAMIC_LOAD_OMX_H263_COMPONENT)
+class Mpeg4H263OmxSharedLibraryInterface: public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static Mpeg4H263OmxSharedLibraryInterface *Instance()
+        {
+            static Mpeg4H263OmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_M4VDEC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&Mpeg4OmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&Mpeg4OmxComponentDestructor));
+                }
+            }
+            else if (PV_OMX_H263DEC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&H263OmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&H263OmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+    private:
+        Mpeg4H263OmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return Mpeg4H263OmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
+
 void OpenmaxMpeg4AO::SetDecoderMode(int mode)
 {
     iDecMode = mode;
@@ -122,33 +216,33 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-OMX_ERRORTYPE OpenmaxMpeg4AO::ConstructComponent(OMX_PTR pAppData)
+OMX_ERRORTYPE OpenmaxMpeg4AO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
 {
-
-    Mpeg4ComponentPortType *pInPort, *pOutPort;
-    OMX_U32 ii;
+    ComponentPortType *pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
 
     iNumPorts = 2;
     iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
     iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
     iOmxComponent.pApplicationPrivate = pAppData; // init the App data
 
 
 #if PROXY_INTERFACE
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
 
-    iOmxComponent.SendCommand = WrapperSendCommand;
-    iOmxComponent.GetParameter = WrapperGetParameter;
-    iOmxComponent.SetParameter = WrapperSetParameter;
-    iOmxComponent.GetConfig = WrapperGetConfig;
-    iOmxComponent.SetConfig = WrapperSetConfig;
-    iOmxComponent.GetExtensionIndex = WrapperGetExtensionIndex;
-    iOmxComponent.GetState = WrapperGetState;
-    iOmxComponent.UseBuffer = WrapperUseBuffer;
-    iOmxComponent.AllocateBuffer = WrapperAllocateBuffer;
-    iOmxComponent.FreeBuffer = WrapperFreeBuffer;
-    iOmxComponent.EmptyThisBuffer = WrapperEmptyThisBuffer;
-    iOmxComponent.FillThisBuffer = WrapperFillThisBuffer;
+    iOmxComponent.SendCommand = OpenmaxMpeg4AO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OpenmaxMpeg4AO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OpenmaxMpeg4AO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OpenmaxMpeg4AO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OpenmaxMpeg4AO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OpenmaxMpeg4AO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OpenmaxMpeg4AO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OpenmaxMpeg4AO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OpenmaxMpeg4AO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OpenmaxMpeg4AO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OpenmaxMpeg4AO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OpenmaxMpeg4AO::BaseComponentProxyFillThisBuffer;
 
 #else
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
@@ -177,6 +271,9 @@
     iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
 
     if (ipAppPriv)
     {
@@ -184,60 +281,19 @@
         ipAppPriv = NULL;
     }
 
-    ipAppPriv = (Mpeg4PrivateType*) oscl_malloc(sizeof(Mpeg4PrivateType));
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
 
     if (NULL == ipAppPriv)
     {
         return OMX_ErrorInsufficientResources;
     }
 
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
 
-    if (iNumPorts)
+    if (OMX_ErrorNone != Status)
     {
-        // ipPorts is initialized to NULL
-        if (ipPorts)
-        {
-            oscl_free(ipPorts);
-            ipPorts = NULL;
-        }
-
-        ipPorts = (Mpeg4ComponentPortType**) oscl_calloc(iNumPorts,
-                  sizeof(Mpeg4ComponentPortType*));
-
-        if (!ipPorts)
-        {
-            return OMX_ErrorInsufficientResources;
-        }
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii] = (Mpeg4ComponentPortType*) oscl_calloc(1, sizeof(Mpeg4ComponentPortType));
-            if (!ipPorts[ii])
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            ipPorts[ii]->TransientState = OMX_StateMax;
-            SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            ipPorts[ii]->PortParam.nPortIndex = ii;
-
-            /** Allocate and initialize buffer Queue */
-            ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-
-            if (NULL == ipPorts[ii]->pBufferQueue)
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            QueueInit(ipPorts[ii]->pBufferQueue);
-
-            ipPorts[ii]->LoadedToIdleFlag = OMX_FALSE;
-            ipPorts[ii]->IdleToLoadedFlag = OMX_FALSE;
-
-        }
-
-        Mpeg4ComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-        Mpeg4ComponentSetNumBufferFlush(iNumPorts, -1, OMX_FALSE);
+        return Status;
     }
 
     /** Domain specific section for the ports. */
@@ -308,83 +364,42 @@
     iPortTypesParam.nPorts = 2;
     iPortTypesParam.nStartPortNumber = 0;
 
-    pInPort = (Mpeg4ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    pOutPort = (Mpeg4ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
-    SetHeader(&pInPort->VideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-    pInPort->VideoParam.nPortIndex = 0;
-    pInPort->VideoParam.nIndex = 0;
+    pInPort->ActualNumPortFormatsSupported = 1;
+
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE INPUT PORT SETTINGS
+    //On input port for index 0
+    SetHeader(&pInPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[0].nPortIndex = 0;
+    pInPort->VideoParam[0].nIndex = 0;
 
     if (iDecMode == MODE_MPEG4)
     {
-        pInPort->VideoParam.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+        pInPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingMPEG4;
 
     }
     else if (iDecMode == MODE_H263)
     {
-        pInPort->VideoParam.eCompressionFormat = OMX_VIDEO_CodingH263;
+        pInPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingH263;
     }
 
-    pInPort->VideoParam.eColorFormat = OMX_COLOR_FormatUnused;
+    pInPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatUnused;
 
-    SetHeader(&pOutPort->VideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-    pOutPort->VideoParam.nPortIndex = 1;
-    pOutPort->VideoParam.nIndex = 0;
-    pOutPort->VideoParam.eCompressionFormat = OMX_VIDEO_CodingUnused;
-    pOutPort->VideoParam.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    pOutPort->ActualNumPortFormatsSupported = 1;
 
-    iCodecReady = OMX_FALSE;
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-    ipTempInputBuffer = NULL;
-    iTempInputBufferFilledLength = 0;
-    iNumInputBuffer = 0;
-    iPartialFrameAssembly = OMX_FALSE;
-    iEndofStream = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iNewInBufferRequired = OMX_TRUE;
-    iMarkPropagate = OMX_FALSE;
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE OUTPUT PORT SETTINGS
+    //On output port for index 0
+    SetHeader(&pOutPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pOutPort->VideoParam[0].nPortIndex = 1;
+    pOutPort->VideoParam[0].nIndex = 0;
+    pOutPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pOutPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatYUV420Planar;
 
-    /* Initialize the asynchronous command Queue  */
-    if (ipCoreDescriptor)
-    {
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
 
-    ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType));
-    if (NULL == ipCoreDescriptor)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    ipCoreDescriptor->pMessageQueue = NULL;
-    ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-    if (NULL == ipCoreDescriptor->pMessageQueue)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    QueueInit(ipCoreDescriptor->pMessageQueue);
-
-    /** Default parameters setting */
-    iIsInit = OMX_FALSE;
-    iGroupPriority = 0;
-    iGroupID = 0;
-    ipMark = NULL;
-
-    SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-
-    iOutBufferCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    iFirstFragment = OMX_FALSE;
     iUseExtTimestamp = OMX_TRUE;
 
-    //Will be used in case of partial frame assembly
-    ipInputCurrBuffer = NULL;
-    ipAppPriv->Mpeg4Handle = &iOmxComponent;
 
     if (ipMpegDecoderObject)
     {
@@ -396,18 +411,18 @@
 
 #if PROXY_INTERFACE
 
-    pProxyTerm[g_ComponentIndex]->ComponentSendCommand = BaseComponentSendCommand;
-    pProxyTerm[g_ComponentIndex]->ComponentGetParameter = BaseComponentGetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentSetParameter = BaseComponentSetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentGetConfig = BaseComponentGetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentSetConfig = BaseComponentSetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
-    pProxyTerm[g_ComponentIndex]->ComponentGetState = BaseComponentGetState;
-    pProxyTerm[g_ComponentIndex]->ComponentUseBuffer = BaseComponentUseBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFreeBuffer = BaseComponentFreeBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
 
 #endif
 
@@ -415,578 +430,73 @@
 }
 
 
-/*********************
- *
- * Component verfication routines
- *
- **********************/
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	*/
 
-void OpenmaxMpeg4AO::SetHeader(OMX_PTR aHeader, OMX_U32 aSize)
+OMX_ERRORTYPE OpenmaxMpeg4AO::DestroyComponent()
 {
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-    *((OMX_U32*) aHeader) = aSize;
-
-    pVersion->s.nVersionMajor = SPECVERSIONMAJOR;
-    pVersion->s.nVersionMinor = SPECVERSIONMINOR;
-    pVersion->s.nRevision = SPECREVISION;
-    pVersion->s.nStep = SPECSTEP;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize)
-{
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-
-    if (NULL == aHeader)
+    if (OMX_FALSE != iIsInit)
     {
-        return OMX_ErrorBadParameter;
+        ComponentDeInit();
     }
 
-    if (*((OMX_U32*) aHeader) != aSize)
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipMpegDecoderObject)
     {
-        return OMX_ErrorBadParameter;
+        OSCL_DELETE(ipMpegDecoderObject);
+        ipMpegDecoderObject = NULL;
     }
 
-    if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR ||
-            pVersion->s.nVersionMinor != SPECVERSIONMINOR ||
-            pVersion->s.nRevision != SPECREVISION ||
-            pVersion->s.nStep != SPECSTEP)
+    if (ipAppPriv)
     {
-        return OMX_ErrorVersionMismatch;
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
     }
 
     return OMX_ErrorNone;
 }
 
 
-/**
- * This function verify component state and structure header
+
+/* This function will be called in case of buffer management without marker bit present
+ * The purpose is to copy the current input buffer into a big temporary buffer, so that
+ * an incomplete/partial frame is never passed to the decoder library for decode
  */
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentParameterSanityCheck(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_PTR pStructure,
-    OMX_IN  size_t size)
+void OpenmaxMpeg4AO::ComponentBufferMgmtWithoutMarker()
 {
-    OSCL_UNUSED_ARG(hComponent);
-
-    if (iState != OMX_StateLoaded &&
-            iState != OMX_StateWaitForResources)
-    {
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if (nPortIndex >= iNumPorts)
-    {
-        return OMX_ErrorBadPortIndex;
-    }
-
-    return CheckHeader(pStructure, size);
-}
-
-/**
- * Set/Reset Port Flush Flag
- */
-void OpenmaxMpeg4AO::Mpeg4ComponentSetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    {
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->IsPortFlushed = value;
-    }
-
-}
-
-/**
- * Set Number of Buffer Flushed with the value Specified
- */
-void OpenmaxMpeg4AO::Mpeg4ComponentSetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    { // For all ComponentPort
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->NumBufferFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->NumBufferFlushed = value;
-    }
+    //This common routine has been written in the base class
+    TempInputBufferMgmtWithoutMarker();
 }
 
 
-/** This function assembles multiple input buffers into
-  * one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set
-  */
-
-OMX_BOOL OpenmaxMpeg4AO::Mpeg4ComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer)
+void OpenmaxMpeg4AO::ProcessData()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentAssemblePartialFrames IN"));
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    OMX_U8 *pTempBuffer = NULL;
-    OMX_U32 BytesToCopy = 0;
-
-    Mpeg4ComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    ipMpeg4InputBuffer = aInputBuffer;
-
-    if (!iPartialFrameAssembly)
-    {
-        if (iNumInputBuffer > 0)
-        {
-
-            if (ipMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-            {
-                iInputCurrLength = ipMpeg4InputBuffer->nFilledLen;
-                ipFrameDecodeBuffer = ipMpeg4InputBuffer->pBuffer + ipMpeg4InputBuffer->nOffset;
-                //capture the timestamp to be send to the corresponding output buffer
-                iFrameTimestamp = ipMpeg4InputBuffer->nTimeStamp;
-            }
-            else
-            {
-                iInputCurrLength = 0;
-                iPartialFrameAssembly = OMX_TRUE;
-                iFirstFragment = OMX_TRUE;
-                iFrameTimestamp = ipMpeg4InputBuffer->nTimeStamp;
-                ipFrameDecodeBuffer = ipInputCurrBuffer;
-            }
-
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentAssemblePartialFrames ERROR"));
-            return OMX_FALSE;
-        }
-
-    }
-
-    //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked
-    if (iPartialFrameAssembly)
-    {
-        while (iNumInputBuffer > 0)
-        {
-            if (OMX_FALSE == iFirstFragment)
-            {
-                /* If the timestamp of curr fragment doesn't match with previous,
-                 * discard the previous fragments & start reconstructing from new
-                 */
-                if (iFrameTimestamp != ipMpeg4InputBuffer->nTimeStamp)
-                {
-                    iInputCurrLength = 0;
-                    iPartialFrameAssembly = OMX_TRUE;
-                    iFirstFragment = OMX_TRUE;
-                    iFrameTimestamp = ipMpeg4InputBuffer->nTimeStamp;
-                    ipFrameDecodeBuffer = ipInputCurrBuffer;
-
-                    OMX_COMPONENTTYPE  *pHandle = &iOmxComponent;
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError,
-                     OMX_ErrorStreamCorrupt,
-                     0,
-                     NULL);
-
-                }
-            }
-
-
-            if ((ipMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
-            {
-                break;
-            }
-
-            BytesToCopy = ipMpeg4InputBuffer->nFilledLen;
-
-            // check if there is enough space in the buffer
-
-            if (iInputCurrLength + BytesToCopy > iTempInputBufferAllocLength)
-            {
-                pTempBuffer = NULL;
-                pTempBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
-
-                // in the unlikely event of a problem allocating a new buffer
-                // copy what data we can, and try to decode with partial data (this may generate an error)
-                if (pTempBuffer == NULL)
-                {
-                    // copy to fill the remaining space in the buffer
-                    BytesToCopy = (iTempInputBufferAllocLength - iInputCurrLength);
-
-                }
-                else
-                {
-
-                    // adjust the size
-                    iTempInputBufferAllocLength = iInputCurrLength + BytesToCopy;
-                    // copy current data into new buffer
-                    oscl_memcpy(pTempBuffer, ipInputCurrBuffer, iInputCurrLength);
-                    // free old buffer
-                    oscl_free(ipInputCurrBuffer);
-                    ipInputCurrBuffer = pTempBuffer;
-                    // set the ptr
-                    ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
-
-                }
-            }
-
-
-            iInputCurrLength += BytesToCopy; //ipMpeg4InputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipMpeg4InputBuffer->pBuffer + ipMpeg4InputBuffer->nOffset), BytesToCopy); // copy buffer data
-            ipFrameDecodeBuffer += BytesToCopy; // move the ptr
-
-            ipMpeg4InputBuffer->nFilledLen = 0;
-
-            Mpeg4ComponentReturnInputBuffer(ipMpeg4InputBuffer, pInPort);
-
-            iFirstFragment = OMX_FALSE;
-            if (iNumInputBuffer > 0)
-            {
-                ipMpeg4InputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-
-                if (ipMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentAssemblePartialFrames EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers
-        if (0 == iNumInputBuffer)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentAssemblePartialFrames OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            BytesToCopy = ipMpeg4InputBuffer->nFilledLen;
-            // adjust the size of input buffer if necessary
-            if (iInputCurrLength + BytesToCopy > iTempInputBufferAllocLength)
-            {
-                pTempBuffer = NULL;
-                pTempBuffer = (OMX_U8*) oscl_malloc(sizeof(OMX_U8) * (iInputCurrLength + BytesToCopy));
-
-                // in the unlikely event of a problem allocating a new buffer
-                // copy what data we can, and try to decode with partial data (the decoder will complain most likely)
-                if (pTempBuffer == NULL)
-                {
-
-                    // copy to fill the remaining space in the buffer
-                    BytesToCopy = (iTempInputBufferAllocLength - iInputCurrLength);
-
-                }
-                else
-                {
-
-                    iTempInputBufferAllocLength = (iInputCurrLength + BytesToCopy);
-
-                    oscl_memcpy(pTempBuffer, ipInputCurrBuffer, iInputCurrLength);
-                    oscl_free(ipInputCurrBuffer);
-                    ipInputCurrBuffer = pTempBuffer;
-                    ipFrameDecodeBuffer = ipInputCurrBuffer + iInputCurrLength;
-                }
-            }
-
-            // we have found the buffer that is the last piece of the frame.
-            // Copy the buffer, but do not release it yet (this will be done after decoding for consistency)
-
-            iInputCurrLength += BytesToCopy;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipMpeg4InputBuffer->pBuffer + ipMpeg4InputBuffer->nOffset), BytesToCopy); // copy buffer data
-            ipFrameDecodeBuffer += BytesToCopy; // move the ptr
-
-            ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer
-            iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more
-        }
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentAssemblePartialFrames OUT"));
-    return OMX_TRUE;
-}
-
-
-/** This is the central function for buffers processing and decoding.
-  * It is called through the Run() of active object when the component is in executing state
-  * and is signalled each time a new buffer is available on the given ports
-  * This function will process the input buffers & return output buffers
-  */
-
-void OpenmaxMpeg4AO::Mpeg4ComponentBufferMgmtFunction()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentBufferMgmtFunction IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue =
-        ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_BOOL				PartialFrameReturn;
-
-    Mpeg4ComponentPortType*	pInPort =
-        (Mpeg4ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-    /* Don't dequeue any further buffer after endofstream buffer has been dequeued
-     * till we send the callback and reset the flag back to false
-     */
-    if (OMX_FALSE == iEndofStream)
-    {
-        //More than one frame can't be dequeued in case of outbut blocked
-        if ((OMX_TRUE == iNewInBufferRequired) && (GetQueueNumElem(pInputQueue) > 0))
-        {
-            ipMpeg4InputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-
-            if (ipMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentBufferMgmtFunction EndOfStream arrived"));
-                iEndofStream = OMX_TRUE;
-            }
-
-            if (ipMpeg4InputBuffer->nFilledLen != 0)
-            {
-                // if we already started assembling frames, it means
-                //	we didn't get marker bit yet, but may be getting it
-                //  when the first frame assembly is over
-                //  If so, we'll set iEndOfFrameFlag to TRUE in Mgeg4BufferMgmtWithoutMarker assembly
-                if (0 == iFrameCount && iPartialFrameAssembly == OMX_FALSE)
-                {
-                    //Set the marker flag (iEndOfFrameFlag) if first frame has the EnfOfFrame flag marked.
-                    if ((ipMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentBufferMgmtFunction EndOfFrame flag present"));
-                        iEndOfFrameFlag = OMX_TRUE;
-                    }
-                }
-
-                /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is
-                 *  not marked in all the input buffers
-                 */
-                if (!iEndOfFrameFlag)
-                {
-                    Mpeg4BufferMgmtWithoutMarker(ipMpeg4InputBuffer);
-
-                }
-                //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here
-                else
-                {
-                    PartialFrameReturn = Mpeg4ComponentAssemblePartialFrames(ipMpeg4InputBuffer);
-                    if (OMX_FALSE == PartialFrameReturn)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-                    iIsInputBufferEnded = OMX_FALSE;
-
-                    ipTargetComponent = (OMX_COMPONENTTYPE*) ipMpeg4InputBuffer->hMarkTargetComponent;
-
-                    iTargetMarkData = ipMpeg4InputBuffer->pMarkData;
-                    if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventMark,
-                         1,
-                         0,
-                         ipMpeg4InputBuffer->pMarkData);
-                    }
-                }
-
-            }	//end braces for if (ipMpeg4InputBuffer->nFilledLen != 0)
-            else
-            {
-                Mpeg4ComponentReturnInputBuffer(ipMpeg4InputBuffer, pInPort);
-            }
-
-        }	//end braces for if ((OMX_TRUE == iNewInBufferRequired) && (GetQueueNumElem(pInputQueue) > 0))
-    }	//if (OMX_FALSE == iEndofStream)
-
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ProcessData IN"));
     if (!iEndOfFrameFlag)
     {
-        Mpeg4DecodeWithoutMarker();
+        DecodeWithoutMarker();
     }
     else
     {
-        Mpeg4DecodeWithMarker(ipMpeg4InputBuffer);
+        DecodeWithMarker();
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentBufferMgmtFunction OUT"));
-    return;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ProcessData OUT"));
 }
 
 
-void OpenmaxMpeg4AO::Mpeg4BufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE* pMpeg4InputBuffer)
+void OpenmaxMpeg4AO::DecodeWithoutMarker()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker IN"));
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    Mpeg4ComponentPortType*	pInPort = (Mpeg4ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_U32 TempInputBufferSize = (2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-
-    /* Assembling of partial frame will be done based on max input buf size
-     * If Flushport flag is true, that means its not a partial frame
-     * but an unconsumed frame, process it independently
-     * Same is true for endofstream condition, process the buffer independently
-     */
-    if ((pMpeg4InputBuffer->nFilledLen < pMpeg4InputBuffer->nAllocLen) && (iEndofStream != OMX_TRUE))
-    {
-        if (!iPartialFrameAssembly)
-        {
-            iInputCurrLength = 0;
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-        }
-
-        while (iNumInputBuffer > 0)
-        {
-            oscl_memcpy(ipFrameDecodeBuffer, (pMpeg4InputBuffer->pBuffer + pMpeg4InputBuffer->nOffset), pMpeg4InputBuffer->nFilledLen);
-            ipFrameDecodeBuffer += pMpeg4InputBuffer->nFilledLen; // move the ptr
-
-            iFrameTimestamp = pMpeg4InputBuffer->nTimeStamp;
-
-            // check if we've encountered end of frame flag while trying to assemble the very first frame
-            if ((iFrameCount == 0) && ((pMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker EndOfFrameFlag finally arrived"));
-                iEndOfFrameFlag = OMX_TRUE;
-            }
-
-            if (((iInputCurrLength += pMpeg4InputBuffer->nFilledLen) >= pMpeg4InputBuffer->nAllocLen)
-                    || (OMX_TRUE == iEndofStream) || (OMX_TRUE == iEndOfFrameFlag))
-            {
-                break;
-            }
-
-            //Set the filled len to zero to indiacte buffer is fully consumed
-            pMpeg4InputBuffer->nFilledLen = 0;
-            Mpeg4ComponentReturnInputBuffer(pMpeg4InputBuffer, pInPort);
-
-            if (iNumInputBuffer > 0)
-            {
-                pMpeg4InputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (pMpeg4InputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        if (iEndOfFrameFlag)
-        {
-            // if we have encountered end of frame, 1st frame has been assembled
-            // and we can switch to "end of frame flag" mode
-            iIsInputBufferEnded = OMX_FALSE;
-            iNewInBufferRequired = OMX_FALSE;
-            ipFrameDecodeBuffer = ipInputCurrBuffer; // rewind buffer ptr to beginning of inputcurrbuffer
-            ipMpeg4InputBuffer = pMpeg4InputBuffer; // since ipMpeg4InputBuffer (global) is returned to client, make sure
-            // that it points to the correct buffer - the latest one dequeued
-            iPartialFrameAssembly = OMX_FALSE;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker Found end of frame flag - OUT"));
-            return;
-
-        }
-
-        if (((iInputCurrLength < pMpeg4InputBuffer->nAllocLen)) && OMX_TRUE != iEndofStream)
-        {
-            iPartialFrameAssembly = OMX_TRUE;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker OUT"));
-            return;
-        }
-        else
-        {
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-            iPartialFrameAssembly = OMX_FALSE;
-        }
-    }
-    else
-    {
-        if (iNumInputBuffer > 0)
-        {
-            iInputCurrLength = pMpeg4InputBuffer->nFilledLen;
-            ipFrameDecodeBuffer = pMpeg4InputBuffer->pBuffer + pMpeg4InputBuffer->nOffset;
-            iFrameTimestamp = pMpeg4InputBuffer->nTimeStamp;
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker OUT"));
-            return; // nothing to decode
-        }
-    }
-
-    if (iTempInputBufferFilledLength < (TempInputBufferSize >> 1))
-    {
-        oscl_memmove(ipTempInputBuffer, &ipTempInputBuffer[iTempConsumedLength], iTempInputBufferFilledLength);
-        iIsInputBufferEnded = OMX_TRUE;
-        iTempConsumedLength = 0;
-    }
-
-    if ((iTempInputBufferFilledLength + iTempConsumedLength
-            + iInputCurrLength) <= TempInputBufferSize)
-    {
-        oscl_memcpy(&ipTempInputBuffer[iTempInputBufferFilledLength + iTempConsumedLength], ipFrameDecodeBuffer, iInputCurrLength);
-        iTempInputBufferFilledLength += iInputCurrLength;
-
-        if (iTempInputBufferFilledLength + (TempInputBufferSize >> 1) <= TempInputBufferSize)
-        {
-            iNewInBufferRequired = OMX_TRUE;
-        }
-        else
-        {
-            iNewInBufferRequired = OMX_FALSE;
-        }
-
-        ipTargetComponent = (OMX_COMPONENTTYPE*) pMpeg4InputBuffer->hMarkTargetComponent;
-
-        iTargetMarkData = pMpeg4InputBuffer->pMarkData;
-        if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-        {
-            (*(ipCallbacks->EventHandler))
-            (pHandle,
-             iCallbackData,
-             OMX_EventMark,
-             1,
-             0,
-             pMpeg4InputBuffer->pMarkData);
-        }
-        pMpeg4InputBuffer->nFilledLen = 0;
-        Mpeg4ComponentReturnInputBuffer(pMpeg4InputBuffer, pInPort);
-
-    }
-
-    if (iTempInputBufferFilledLength >= (TempInputBufferSize >> 1))
-    {
-        (*(ipCallbacks->EventHandler))
-        (pHandle,
-         iCallbackData,
-         OMX_EventError,
-         OMX_ErrorInsufficientResources,
-         0,
-         NULL);
-        iIsInputBufferEnded = OMX_FALSE;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4BufferMgmtWithoutMarker OUT"));
-    return;
-
-}
-
-
-
-void OpenmaxMpeg4AO::Mpeg4DecodeWithoutMarker()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithoutMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker IN"));
 
     QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-    Mpeg4ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
     OMX_COMPONENTTYPE  *pHandle = &iOmxComponent;
 
     OMX_U8*					pOutBuffer;
@@ -1007,7 +517,7 @@
         //Check whether a new output buffer is available or not
         if (0 == (GetQueueNumElem(pOutputQueue)))
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithoutMarker OUT output buffer unavailable"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker OUT output buffer unavailable"));
             //Store the mark data for output buffer, as it will be overwritten next time
             if (NULL != ipTargetComponent)
             {
@@ -1018,17 +528,23 @@
             return;
         }
 
-        ipMpeg4OutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-
-        //Do not proceed if the output buffer can't fit the YUV data
-        if (ipMpeg4OutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) * (((CurrHeight + 15) >> 4) << 4) * 3 / 2))
+        ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+        if (NULL == ipOutputBuffer)
         {
-            ipMpeg4OutputBuffer->nFilledLen = 0;
-            Mpeg4ComponentReturnOutputBuffer(ipMpeg4OutputBuffer, pOutPort);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker Error, output buffer dequeue returned NULL, OUT"));
             return;
         }
 
-        ipMpeg4OutputBuffer->nFilledLen = 0;
+        //Do not proceed if the output buffer can't fit the YUV data
+        if (ipOutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) * (((CurrHeight + 15) >> 4) << 4) * 3 / 2))
+        {
+            ipOutputBuffer->nFilledLen = 0;
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
+            return;
+        }
+
+        ipOutputBuffer->nFilledLen = 0;
 
 
         /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
@@ -1036,33 +552,33 @@
          */
         if (ipMark != NULL)
         {
-            ipMpeg4OutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipMpeg4OutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if ((OMX_TRUE == iMarkPropagate) && (ipTempTargetComponent != ipTargetComponent))
         {
-            ipMpeg4OutputBuffer->hMarkTargetComponent = ipTempTargetComponent;
-            ipMpeg4OutputBuffer->pMarkData = iTempTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTempTargetComponent;
+            ipOutputBuffer->pMarkData = iTempTargetMarkData;
             ipTempTargetComponent = NULL;
             iMarkPropagate = OMX_FALSE;
         }
         else if (ipTargetComponent != NULL)
         {
-            ipMpeg4OutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipMpeg4OutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
             iMarkPropagate = OMX_FALSE;
 
         }
         //Mark buffer code ends here
 
-        pOutBuffer = ipMpeg4OutputBuffer->pBuffer;
+        pOutBuffer = ipOutputBuffer->pBuffer;
         OutputLength = 0;
 
         pTempInBuffer = ipTempInputBuffer + iTempConsumedLength;
-        TempInLength = iTempInputBufferFilledLength;
+        TempInLength = iTempInputBufferLength;
 
         //Output buffer is passed as a short pointer
         DecodeReturn = ipMpegDecoderObject->Mp4DecodeVideo(pOutBuffer, (OMX_U32*) & OutputLength,
@@ -1073,15 +589,15 @@
                        MarkerFlag,
                        &ResizeNeeded);
 
-        ipMpeg4OutputBuffer->nFilledLen = OutputLength;
+        ipOutputBuffer->nFilledLen = OutputLength;
 
         //offset not required in our case, set it to zero
-        ipMpeg4OutputBuffer->nOffset = 0;
+        ipOutputBuffer->nOffset = 0;
 
         //If decoder returned error, report it to the client via a callback
         if (!DecodeReturn && OMX_FALSE == iEndofStream)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithoutMarker ErrorStreamCorrupt callback send"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker ErrorStreamCorrupt callback send"));
 
             (*(ipCallbacks->EventHandler))
             (pHandle,
@@ -1096,7 +612,7 @@
         if (ResizeNeeded == OMX_TRUE)
         {
             // send port settings changed event
-            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->Mpeg4Handle;
+            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
 
             // set the flag to disable further processing until Client reacts to this
             //	by doing dynamic port reconfiguration
@@ -1112,10 +628,10 @@
 
         }
         //Set the timestamp equal to the input buffer timestamp
-        ipMpeg4OutputBuffer->nTimeStamp = iFrameTimestamp;
+        ipOutputBuffer->nTimeStamp = iFrameTimestamp;
 
-        iTempConsumedLength += (iTempInputBufferFilledLength - TempInLength);
-        iTempInputBufferFilledLength = TempInLength;
+        iTempConsumedLength += (iTempInputBufferLength - TempInLength);
+        iTempInputBufferLength = TempInLength;
 
         //Do not decode if big buffer is less than half the size
         if (TempInLength < (TempInputBufferSize >> 1))
@@ -1130,9 +646,9 @@
          */
         if (OMX_TRUE == iEndofStream)
         {
-            if ((0 == iTempInputBufferFilledLength) || (!DecodeReturn))
+            if ((0 == iTempInputBufferLength) || (!DecodeReturn))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithoutMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1145,17 +661,19 @@
                 iNewInBufferRequired = OMX_TRUE;
                 iEndofStream = OMX_FALSE;
 
-                ipMpeg4OutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
-                Mpeg4ComponentReturnOutputBuffer(ipMpeg4OutputBuffer, pOutPort);
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
 
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithoutMarker OUT"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker OUT"));
 
                 return;
             }
         }
 
         //Send the output buffer back after decode
-        Mpeg4ComponentReturnOutputBuffer(ipMpeg4OutputBuffer, pOutPort);
+        ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+        ipOutputBuffer = NULL;
 
         /* If there is some more processing left with current buffers, re-schedule the AO
          * Do not go for more than one round of processing at a time.
@@ -1167,20 +685,20 @@
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithoutMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithoutMarker OUT"));
     return;
 }
 
 
-void OpenmaxMpeg4AO::Mpeg4DecodeWithMarker(OMX_BUFFERHEADERTYPE* pMpeg4InputBuffer)
+void OpenmaxMpeg4AO::DecodeWithMarker()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker IN"));
 
     QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
 
-    Mpeg4ComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    Mpeg4ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
     OMX_U8*					pOutBuffer;
     OMX_U32					OutputLength;
@@ -1197,35 +715,43 @@
         //Check whether a new output buffer is available or not
         if (0 == (GetQueueNumElem(pOutputQueue)))
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithMarker OUT output buffer unavailable"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker OUT output buffer unavailable"));
             iNewInBufferRequired = OMX_FALSE;
             return;
         }
 
-        ipMpeg4OutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-        //Do not proceed if the output buffer can't fit the YUV data
-        if (ipMpeg4OutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) * (((CurrHeight + 15) >> 4) << 4) * 3 / 2))
+        ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+        if (NULL == ipOutputBuffer)
         {
-            ipMpeg4OutputBuffer->nFilledLen = 0;
-            Mpeg4ComponentReturnOutputBuffer(ipMpeg4OutputBuffer, pOutPort);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker Error, output buffer dequeue returned NULL, OUT"));
+            iNewInBufferRequired = OMX_FALSE;
             return;
         }
-        ipMpeg4OutputBuffer->nFilledLen = 0;
+
+        //Do not proceed if the output buffer can't fit the YUV data
+        if (ipOutputBuffer->nAllocLen < (OMX_U32)((((CurrWidth + 15) >> 4) << 4) * (((CurrHeight + 15) >> 4) << 4) * 3 / 2))
+        {
+            ipOutputBuffer->nFilledLen = 0;
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
+            return;
+        }
+        ipOutputBuffer->nFilledLen = 0;
 
         /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
          * command and hMarkTargetComponent as given by the specifications
          */
         if (ipMark != NULL)
         {
-            ipMpeg4OutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipMpeg4OutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if (ipTargetComponent != NULL)
         {
-            ipMpeg4OutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipMpeg4OutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
 
         }
@@ -1233,7 +759,7 @@
 
         if (iInputCurrLength > 0)
         {
-            pOutBuffer = ipMpeg4OutputBuffer->pBuffer;
+            pOutBuffer = ipOutputBuffer->pBuffer;
             OutputLength = 0;
 
             //Output buffer is passed as a short pointer
@@ -1245,14 +771,14 @@
                            MarkerFlag,
                            &ResizeNeeded);
 
-            ipMpeg4OutputBuffer->nFilledLen = OutputLength;
+            ipOutputBuffer->nFilledLen = OutputLength;
             //offset not required in our case, set it to zero
-            ipMpeg4OutputBuffer->nOffset = 0;
+            ipOutputBuffer->nOffset = 0;
 
             //If decoder returned error, report it to the client via a callback
             if (!DecodeReturn && OMX_FALSE == iEndofStream)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithMarker ErrorStreamCorrupt callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker ErrorStreamCorrupt callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1266,7 +792,7 @@
             if (ResizeNeeded == OMX_TRUE)
             {
                 // send port settings changed event
-                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->Mpeg4Handle;
+                OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
 
                 iResizePending = OMX_TRUE;
                 (*(ipCallbacks->EventHandler))
@@ -1281,14 +807,15 @@
             //Set the timestamp equal to the input buffer timestamp
             if (OMX_TRUE == iUseExtTimestamp)
             {
-                ipMpeg4OutputBuffer->nTimeStamp = iFrameTimestamp;
+                ipOutputBuffer->nTimeStamp = iFrameTimestamp;
             }
 
             /* Discard the input frame if it is with the marker bit & decoder fails*/
             if (iInputCurrLength == 0 || !DecodeReturn)
             {
-                pMpeg4InputBuffer->nFilledLen = 0;
-                Mpeg4ComponentReturnInputBuffer(pMpeg4InputBuffer, pInPort);
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
+                ipInputBuffer = NULL;
                 iNewInBufferRequired = OMX_TRUE;
                 iIsInputBufferEnded = OMX_TRUE;
                 iUseExtTimestamp = OMX_TRUE;
@@ -1301,6 +828,20 @@
                 iUseExtTimestamp = OMX_FALSE;
             }
         }
+        else if (iEndofStream == OMX_FALSE)
+        {
+            // it's possible that after partial frame assembly, the input buffer still remains empty (due to
+            // client erroneously sending such buffers). This code adds robustness in the sense that it returns such buffer to the client
+
+            ipInputBuffer->nFilledLen = 0;
+            ReturnInputBuffer(ipInputBuffer, pInPort);
+            ipInputBuffer = NULL;
+            iNewInBufferRequired = OMX_TRUE;
+            iIsInputBufferEnded = OMX_TRUE;
+            iUseExtTimestamp = OMX_TRUE;
+        }
+
+
 
 
         /* If EOS flag has come from the client & there are no more
@@ -1310,7 +851,7 @@
         {
             if (!DecodeReturn)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -1324,24 +865,27 @@
                 //Mark this flag false once the callback has been send back
                 iEndofStream = OMX_FALSE;
 
-                ipMpeg4OutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
-                Mpeg4ComponentReturnOutputBuffer(ipMpeg4OutputBuffer, pOutPort);
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
 
-                if (iNumInputBuffer != 0)
+                if ((iNumInputBuffer != 0) && (NULL != ipInputBuffer))
                 {
-                    Mpeg4ComponentReturnInputBuffer(pMpeg4InputBuffer, pInPort);
+                    ReturnInputBuffer(ipInputBuffer, pInPort);
+                    ipInputBuffer = NULL;
                     iIsInputBufferEnded = OMX_TRUE;
                     iInputCurrLength = 0;
                 }
 
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithMarker OUT"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker OUT"));
                 return;
             }
 
         }
 
         //Send the output buffer back after decode
-        Mpeg4ComponentReturnOutputBuffer(ipMpeg4OutputBuffer, pOutPort);
+        ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+        ipOutputBuffer = NULL;
 
 
         /* If there is some more processing left with current buffers, re-schedule the AO
@@ -1355,483 +899,37 @@
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4DecodeWithMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : DecodeWithMarker OUT"));
     return;
 }
 
-void OpenmaxMpeg4AO::Mpeg4ComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pMpeg4InputBuffer, Mpeg4ComponentPortType *pPort)
-{
-    OSCL_UNUSED_ARG(pPort);
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    if (iNumInputBuffer)
-    {
-        iNumInputBuffer--;
-    }
-
-    //Callback for releasing the input buffer
-    (*(ipCallbacks->EmptyBufferDone))
-    (pHandle, iCallbackData, pMpeg4InputBuffer);
-
-    pMpeg4InputBuffer = NULL;
-
-}
-
-/**
- * Returns Output Buffer back to the IL client
- */
-void OpenmaxMpeg4AO::Mpeg4ComponentReturnOutputBuffer(
-    OMX_BUFFERHEADERTYPE* pMpeg4OutputBuffer,
-    Mpeg4ComponentPortType *pPort)
-{
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-
-    //Callback for sending back the output buffer
-    (*(ipCallbacks->FillBufferDone))
-    (pHandle, iCallbackData, pMpeg4OutputBuffer);
-
-    if (iOutBufferCount)
-    {
-        iOutBufferCount--;
-    }
-
-    pPort->NumBufferFlushed++;
-}
-
-/** The panic function that exits from the application.
- */
-OMX_S32 OpenmaxMpeg4AO::Mpeg4ComponentPanic()
-{
-    OSCL_ASSERT(false);
-    OsclError::Panic("PVERROR", OsclErrGeneral);
-    return 0;
-}
-
-
-/** Flushes all the buffers under processing by the given port.
-	* This function is called due to a state change of the component, typically
-	* @param Component the component which owns the port to be flushed
-	* @param PortIndex the ID of the port to be flushed
-	*/
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentFlushPort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentFlushPort IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_BUFFERHEADERTYPE* pOutputBuff;
-    OMX_BUFFERHEADERTYPE* pInputBuff;
-
-    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        iPartialFrameAssembly = OMX_FALSE;
-        while ((GetQueueNumElem(pInputQueue) > 0))
-        {
-            pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, pInputBuff);
-            iNumInputBuffer--;
-        }
-        if (iNumInputBuffer > 0 && ipMpeg4InputBuffer)
-        {
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, ipMpeg4InputBuffer);
-            iNumInputBuffer--;
-            iIsInputBufferEnded = OMX_TRUE;
-            iInputCurrLength = 0;
-        }
-
-    }
-
-    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        while ((GetQueueNumElem(pOutputQueue) > 0))
-        {
-            pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            pOutputBuff->nFilledLen = 0;
-            (*(ipCallbacks->FillBufferDone))
-            (pHandle, iCallbackData, pOutputBuff);
-            iOutBufferCount--;
-        }
-
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentFlushPort OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** This function is called by the omx core when the component
-	* is disposed by the IL client with a call to FreeHandle().
-	* \param Component, the component to be disposed
-	*/
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::DestroyComponent()
-{
-    OMX_U32 ii;
-
-    if (iIsInit != OMX_FALSE)
-    {
-        Mpeg4ComponentDeInit();
-    }
-
-    /*Deinitialize and free ports semaphores and Queue*/
-    for (ii = 0; ii < iNumPorts; ii++)
-    {
-        if (ipPorts[ii]->pBufferQueue != NULL)
-        {
-            QueueDeinit(ipPorts[ii]->pBufferQueue);
-            oscl_free(ipPorts[ii]->pBufferQueue);
-            ipPorts[ii]->pBufferQueue = NULL;
-        }
-        /*Free port*/
-        if (ipPorts[ii] != NULL)
-        {
-            oscl_free(ipPorts[ii]);
-            ipPorts[ii] = NULL;
-        }
-    }
-
-    if (ipPorts)
-    {
-        oscl_free(ipPorts);
-        ipPorts = NULL;
-    }
-
-    iState = OMX_StateLoaded;
-
-    if (ipInputCurrBuffer)
-    {
-        oscl_free(ipInputCurrBuffer);
-        ipInputCurrBuffer = NULL;
-    }
-
-    if (ipMpegDecoderObject)
-    {
-        OSCL_DELETE(ipMpegDecoderObject);
-        ipMpegDecoderObject = NULL;
-    }
-
-    if (ipTempInputBuffer)
-    {
-        oscl_free(ipTempInputBuffer);
-        ipTempInputBuffer = NULL;
-    }
-
-    if (ipCoreDescriptor != NULL)
-    {
-
-        if (ipCoreDescriptor->pMessageQueue != NULL)
-        {
-            /* De-initialize the asynchronous command queue */
-            QueueDeinit(ipCoreDescriptor->pMessageQueue);
-            oscl_free(ipCoreDescriptor->pMessageQueue);
-            ipCoreDescriptor->pMessageQueue = NULL;
-        }
-
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    if (ipAppPriv)
-    {
-        ipAppPriv->Mpeg4Handle = NULL;
-
-        oscl_free(ipAppPriv);
-        ipAppPriv = NULL;
-    }
-
-    return OMX_ErrorNone;
-}
-
-
-/**
- * Disable Single Port
- */
-void OpenmaxMpeg4AO::Mpeg4ComponentDisableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE;
-
-    if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->IdleToLoadedFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_FALSE;
-        }
-    }
-
-    ipPorts[PortIndex]->NumBufferFlushed = 0;
-}
-
-
-/** Disables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be disabled
-	* @param PortIndex the ID of the port to be disabled
-	*/
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentDisablePort(OMX_S32 PortIndex)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDisablePort IN"));
-    OMX_U32 ii;
-
-    if (-1 == PortIndex)
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_TRUE;
-        }
-
-        /*Flush all ports*/
-        Mpeg4ComponentFlushPort(PortIndex);
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_FALSE;
-        }
-    }
-    else
-    {
-        /*Flush the port specified*/
-        ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE;
-        Mpeg4ComponentFlushPort(PortIndex);
-        ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE;
-    }
-
-    /*Disable ports*/
-    if (PortIndex != -1)
-    {
-        Mpeg4ComponentDisableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            Mpeg4ComponentDisableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDisablePort OUT"));
-
-    return OMX_ErrorNone;
-}
-
-/**
- * Enable Single Port
- */
-void OpenmaxMpeg4AO::Mpeg4ComponentEnableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE;
-
-    if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->LoadedToIdleFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_TRUE;
-        }
-    }
-}
-
-/** Enables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be enabled
-	* @param PortIndex the ID of the port to be enabled
-	*/
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentEnablePort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentEnablePort IN"));
-
-    OMX_U32 ii;
-
-    /*Enable port/s*/
-    if (PortIndex != -1)
-    {
-        Mpeg4ComponentEnableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            Mpeg4ComponentEnableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentEnablePort OUT"));
-    return OMX_ErrorNone;
-}
 
 //Not implemented & supported in case of base profile components
 
-void OpenmaxMpeg4AO::Mpeg4ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
+void OpenmaxMpeg4AO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
 {
     *aRoleString = (OMX_STRING)"video_decoder.mpeg4";
 }
 
 
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentTunnelRequest(
-    OMX_IN  OMX_HANDLETYPE hComp,
-    OMX_IN  OMX_U32 nPort,
-    OMX_IN  OMX_HANDLETYPE hTunneledComp,
-    OMX_IN  OMX_U32 nTunneledPort,
-    OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup)
+//Component constructor
+OpenmaxMpeg4AO::OpenmaxMpeg4AO()
 {
-    OSCL_UNUSED_ARG(hComp);
-    OSCL_UNUSED_ARG(nPort);
-    OSCL_UNUSED_ARG(hTunneledComp);
-    OSCL_UNUSED_ARG(nTunneledPort);
-    OSCL_UNUSED_ARG(pTunnelSetup);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    OSCL_UNUSED_ARG(nIndex);
-    OSCL_UNUSED_ARG(pComponentConfigStructure);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    OSCL_UNUSED_ARG(nIndex);
-    OSCL_UNUSED_ARG(pComponentConfigStructure);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType)
-{
-    OSCL_UNUSED_ARG(hComponent);
-    OSCL_UNUSED_ARG(cParameterName);
-    OSCL_UNUSED_ARG(pIndexType);
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState)
-{
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-
-    pOpenmaxAOType->GetState(pState);
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxMpeg4AO::GetState(OMX_OUT OMX_STATETYPE* pState)
-{
-    *pState = iState;
-}
-
-
-
-//Active object constructor
-OpenmaxMpeg4AO::OpenmaxMpeg4AO() :
-        OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXMpeg4Dec")
-{
-
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXMpeg4DecNode");
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : constructed"));
-
-// INIT ALL CLASS MEMBERS
-    iBufferExecuteFlag = OMX_FALSE;
-    ipAppPriv = NULL;
-    //iLogger = NULL;
-
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-
-
-    ipCoreDescriptor = NULL;
-    iNumInputBuffer = 0;
-
-
-    ipFrameDecodeBuffer = NULL;
-    iPartialFrameAssembly = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iEndofStream = OMX_FALSE;
-    ipTempInputBuffer = NULL;
-    iTempInputBufferFilledLength = 0;
-
-    ipTargetComponent = NULL;
-    iTargetMarkData = NULL;
-    iNewInBufferRequired = OMX_TRUE;
-
-    iTempConsumedLength = 0;
-    iOutBufferCount = 0;
-    iCodecReady = OMX_FALSE;
-    ipInputCurrBuffer = NULL;
-    iInputCurrLength = 0;
-    iFrameCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    ipMpeg4InputBuffer = NULL;
-    ipMpeg4OutputBuffer = NULL;
-    iTempInputBufferAllocLength = 0;
-
-    iFirstFragment = OMX_FALSE;
-    iResizePending = OMX_FALSE;
     iUseExtTimestamp = OMX_TRUE;
-    iFrameTimestamp = 0;
-
-    iNumPorts = 0;
-    ipPorts = NULL;
-
-    //Indicate whether component has been already initialized */
-    iIsInit = OMX_FALSE;
-
-    iGroupPriority = 0;
-    iGroupID = 0;
-
-    ipMark = NULL;
-
-    //Mpeg4 specific parameter
     ipMpegDecoderObject = NULL;
 
-    // iDecMode will be set separately
-
-
-
-
     if (!IsAdded())
     {
         AddToScheduler();
     }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : constructed"));
 }
 
 
 //Active object destructor
 OpenmaxMpeg4AO::~OpenmaxMpeg4AO()
 {
-
     if (IsAdded())
     {
         RemoveFromScheduler();
@@ -1843,41 +941,63 @@
 
 /** The Initialization function
  */
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentInit()
+OMX_ERRORTYPE OpenmaxMpeg4AO::ComponentInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ComponentInit IN"));
 
     OMX_ERRORTYPE Status = OMX_ErrorNone;
 
     if (OMX_TRUE == iIsInit)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentInit error incorrect operation"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ComponentInit error incorrect operation"));
         return OMX_ErrorIncorrectStateOperation;
     }
     iIsInit = OMX_TRUE;
 
-    //mp4 lib init
+
     if (!iCodecReady)
     {
-        Status = ipMpegDecoderObject->Mp4DecInit();
+        //Call the init routine here in case of H263 mode, without waiting for buffers
+
+        if (iDecMode == MODE_H263)
+        {
+            OMX_S32 Width, Height, Size = 0;
+            OMX_U8* Buff = NULL;
+
+            //Pass dummy pointers during initializations
+            if (OMX_TRUE != ipMpegDecoderObject->InitializeVideoDecode(&Width, &Height, &Buff, &Size, iDecMode))
+            {
+                Status = OMX_ErrorInsufficientResources;
+            }
+
+            ipMpegDecoderObject->Mpeg4InitFlag = 1;
+        }
+        else
+        {
+            //mp4 lib init
+            Status = ipMpegDecoderObject->Mp4DecInit();
+        }
+
         iCodecReady = OMX_TRUE;
     }
 
+    iUseExtTimestamp = OMX_TRUE;
     iInputCurrLength = 0;
+
     //Used in dynamic port reconfiguration
     iFrameCount = 0;
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ComponentInit OUT"));
 
     return Status;
 
 }
 
 /** This function is called upon a transition to the idle or invalid state.
- *  Also it is called by the Mpeg4ComponentDestructor() function
+ *  Also it is called by the ComponentDestructor() function
  */
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentDeInit()
+OMX_ERRORTYPE OpenmaxMpeg4AO::ComponentDeInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDeInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ComponentDeInit IN"));
 
     OMX_ERRORTYPE Status = OMX_ErrorNone;
 
@@ -1889,2041 +1009,293 @@
         iCodecReady = OMX_FALSE;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDeInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : ComponentDeInit OUT"));
 
     return Status;
 
 }
 
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentGetParameter(
+OMX_ERRORTYPE OpenmaxMpeg4AO::GetConfig(
     OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return Status;
-
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::GetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
 {
     OSCL_UNUSED_ARG(hComponent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter IN"));
-
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
-    OMX_PORT_PARAM_TYPE* pPortDomains;
-    OMX_U32 PortIndex;
-    Mpeg4ComponentPortType* pComponentPort;
-    OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat;
-    OMX_VIDEO_PARAM_MPEG4TYPE *pVideoMpeg4;
-    OMX_VIDEO_PARAM_H263TYPE *pVideoH263;
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE * pProfileLevel;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamPriorityMgmt:
-        {
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
-            pPrioMgmt->nGroupPriority = iGroupPriority;
-            pPrioMgmt->nGroupID = iGroupID;
-        }
-        break;
-
-        case OMX_IndexParamVideoInit:
-        {
-            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-
-        //Following 3 cases have a single common piece of code to be executed
-        case OMX_IndexParamAudioInit:
-        case OMX_IndexParamImageInit:
-        case OMX_IndexParamOtherInit:
-        {
-            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
-            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
-            pPortDomains->nPorts = 0;
-            pPortDomains->nStartPortNumber = 0;
-        }
-        break;
-
-        case OMX_IndexParamVideoPortFormat:
-        {
-            pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            if (pVideoPortFormat->nIndex > ipPorts[pVideoPortFormat->nPortIndex]->VideoParam.nIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error index out of range"));
-                return OMX_ErrorNoMore;
-            }
-            SetHeader(pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            if (pVideoPortFormat->nPortIndex <= 1)
-            {
-                pComponentPort = (Mpeg4ComponentPortType*) ipPorts[pVideoPortFormat->nPortIndex];
-                oscl_memcpy(pVideoPortFormat, &pComponentPort->VideoParam, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-
-        break;
-
-        case OMX_IndexParamVideoMpeg4:
-        {
-            pVideoMpeg4 = (OMX_VIDEO_PARAM_MPEG4TYPE*) ComponentParameterStructure;
-            if (pVideoMpeg4->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pVideoMpeg4->nPortIndex;
-            oscl_memcpy(pVideoMpeg4, &ipPorts[PortIndex]->VideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
-            SetHeader(pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoH263:
-        {
-            pVideoH263 = (OMX_VIDEO_PARAM_H263TYPE*) ComponentParameterStructure;
-            if (pVideoH263->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pVideoH263->nPortIndex;
-            oscl_memcpy(pVideoH263, &ipPorts[PortIndex]->VideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
-            SetHeader(pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoProfileLevelQuerySupported:
-        {
-            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            PortIndex = pProfileLevel->nPortIndex;
-            if (pProfileLevel->nProfileIndex > ipPorts[PortIndex]->ProfileLevel.nProfileIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error profile not supported"));
-                return OMX_ErrorNoMore;
-            }
-
-            oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-            SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-        }
-        break;
-
-        case OMX_IndexParamVideoProfileLevelCurrent:
-        {
-            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            PortIndex = pProfileLevel->nPortIndex;
-
-            oscl_memcpy(pProfileLevel, &ipPorts[PortIndex]->ProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-            SetHeader(pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-
-            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
-            {
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-            else
-            {
-                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-        }
-        break;
-
-        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
-        {
-            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
-            if (NULL == pCap_flags)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error pCap_flags NULL"));
-                return OMX_ErrorBadParameter;
-            }
-            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
-
-        }
-        break;
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter error Unsupported Index"));
-            return OMX_ErrorUnsupportedIndex;
-        }
-        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : GetParameter OUT"));
-
-    return OMX_ErrorNone;
+    OSCL_UNUSED_ARG(nIndex);
+    OSCL_UNUSED_ARG(pComponentConfigStructure);
+    return OMX_ErrorNotImplemented;
 }
 
 
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
+OMX_ERRORTYPE OpenmaxMpeg4AO::ReAllocatePartialAssemblyBuffers(OMX_BUFFERHEADERTYPE* aInputBufferHdr)
 {
 
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
+    // check if there is enough data in the buffer to read the information that we need
+    if (aInputBufferHdr->nFilledLen >= MINIMUM_H263_SHORT_HEADER_SIZE)
     {
-        return OMX_ErrorBadParameter;
-    }
+        OMX_U8 *pInputBuffer = (aInputBufferHdr->pBuffer + aInputBufferHdr->nOffset);
 
-    Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::SetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter IN"));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortFormat;
-    OMX_VIDEO_PARAM_MPEG4TYPE *pVideoMpeg4;
-    OMX_VIDEO_PARAM_H263TYPE *pVideoH263;
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE * pProfileLevel;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
-    OMX_U32 PortIndex;
-    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
-
-
-
-    Mpeg4ComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamVideoInit:
+        if (MODE_H263 == iDecMode)
         {
-            /*Check Structure Header*/
-            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error video init check header failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
+            OMX_BOOL Status = OMX_TRUE;
 
-        case OMX_IndexParamVideoPortFormat:
-        {
-            pVideoPortFormat = (OMX_VIDEO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            PortIndex = pVideoPortFormat->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            if (PortIndex <= 1)
-            {
-                pComponentPort = (Mpeg4ComponentPortType*) ipPorts[PortIndex];
-                oscl_memcpy(&pComponentPort->VideoParam, pVideoPortFormat, sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
+            Status = DecodeH263Header(pInputBuffer, &iInputCurrBufferSize);
 
-        case OMX_IndexParamVideoMpeg4:
-        {
-            pVideoMpeg4 = (OMX_VIDEO_PARAM_MPEG4TYPE*) ComponentParameterStructure;
-            PortIndex = pVideoMpeg4->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
-            if (ErrorType != OMX_ErrorNone)
+            // Re-allocate the partial frame buffer in case the stream is not corrupted,
+            // otherwise leave the buffer size as it is
+            if (OMX_TRUE == Status)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error param check failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->VideoMpeg4, pVideoMpeg4, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
-        }
-        break;
-        case OMX_IndexParamVideoH263:
-        {
-            pVideoH263 = (OMX_VIDEO_PARAM_H263TYPE*) ComponentParameterStructure;
-            PortIndex = pVideoH263->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error param check failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->VideoH263, pVideoH263, sizeof(OMX_VIDEO_PARAM_H263TYPE));
-        }
-        break;
-
-
-        case OMX_IndexParamVideoProfileLevelCurrent:
-        {
-            pProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*) ComponentParameterStructure;
-            PortIndex = pProfileLevel->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->ProfileLevel, pProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPriorityMgmt:
-        {
-            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error incorrect state error"));
-                return OMX_ErrorIncorrectStateOperation;
-            }
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            iGroupPriority = pPrioMgmt->nGroupPriority;
-            iGroupID = pPrioMgmt->nGroupID;
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
-            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-            if (OMX_ErrorIncorrectStateOperation == ErrorType)
-            {
-                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
+                if (NULL != ipInputCurrBuffer)
                 {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error incorrect state error"));
-                    return OMX_ErrorIncorrectStateOperation;
-                }
-            }
-            else if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
-            {
-                return OMX_ErrorNone;
-            }
-
-            ErrorType = OMX_ErrorNone;
-        }
-        break;
-
-        case OMX_IndexParamStandardComponentRole:
-        {
-            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            strcpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole);
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter error bad parameter"));
-            return OMX_ErrorBadParameter;
-        }
-        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetParameter OUT"));
-    return ErrorType;
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::UseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OSCL_UNUSED_ARG(hComponent);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : UseBuffer IN"));
-    Mpeg4ComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : UseBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : UseBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : UseBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer;
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFilledLen = 0;
-            pBaseComponentPort->pBuffer[ii]->nOffset = 0;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            pBaseComponentPort->pBuffer[ii]->nTickCount = 0;
-            pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0;
-            *ppBufferHdr = pBaseComponentPort->pBuffer[ii];
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            else
-            {
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-            pBaseComponentPort->NumAssignedBuffers++;
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : UseBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : UseBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::AllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OSCL_UNUSED_ARG(hComponent);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer IN"));
-
-    Mpeg4ComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            /* allocate the buffer */
-            pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes);
-            if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            *pBuffer = pBaseComponentPort->pBuffer[ii];
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts;
-            }
-            else
-            {
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-            }
-
-            pBaseComponentPort->NumAssignedBuffers++;
-
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : AllocateBuffer OUT"));
-    return OMX_ErrorInsufficientResources;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::FreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FreeBuffer IN"));
-
-    Mpeg4ComponentPortType* pBaseComponentPort;
-
-    OMX_U32 ii;
-    OMX_BOOL FoundBuffer;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FreeBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateLoaded
-            && pBaseComponentPort->TransientState != OMX_StateInvalid)
-    {
-
-        (*(ipCallbacks->EventHandler))
-        (hComponent,
-         iCallbackData,
-         OMX_EventError, /* The command was completed */
-         OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */
-         nPortIndex, /* The State has been changed in message->MessageParam2 */
-         NULL);
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-            oscl_free(pBuffer->pBuffer);
-            pBuffer->pBuffer = NULL;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-        else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) &&
-                 (pBaseComponentPort->pBuffer[ii] == pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-    }
-
-    FoundBuffer = OMX_FALSE;
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE)
-        {
-            FoundBuffer = OMX_TRUE;
-            break;
-        }
-    }
-    if (!FoundBuffer)
-    {
-        pBaseComponentPort->PortParam.bPopulated = OMX_FALSE;
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation
-            RunIfNotReady();
-            //Set the corresponding flags
-            pBaseComponentPort->IdleToLoadedFlag = OMX_TRUE;
-            pBaseComponentPort->LoadedToIdleFlag = OMX_FALSE;
-            iStateTransitionFlag = OMX_FALSE;
-            //Reset the decoding flags while freeing buffers
-            if (OMX_PORT_INPUTPORT_INDEX == nPortIndex)
-            {
-                iIsInputBufferEnded = OMX_TRUE;
-                iTempInputBufferFilledLength = 0;
-                iTempConsumedLength = 0;
-                iNewInBufferRequired = OMX_TRUE;
-            }
-        }
-
-        if (NULL != pBaseComponentPort->pBuffer)
-        {
-            oscl_free(pBaseComponentPort->pBuffer);
-            pBaseComponentPort->pBuffer = NULL;
-            oscl_free(pBaseComponentPort->BufferState);
-            pBaseComponentPort->BufferState = NULL;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FreeBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs
-	* @param hComponent the handle of the component
-	* @param ipCallbacks the OpenMAX standard structure that holds the callback pointers
-	* @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed
-    */
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::SetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OSCL_UNUSED_ARG(hComponent);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SetCallbacks"));
-
-    ipCallbacks = pCallbacks;
-    iCallbackData = pAppData;
-
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::SendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_S32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand IN"));
-
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone;
-    QueueType* pMessageQueue;
-    CoreMessage* Message = NULL;
-
-    pMessageQueue = ipCoreDescriptor->pMessageQueue;
-
-    if (OMX_StateInvalid == iState)
-    {
-        ErrMsgHandler = OMX_ErrorInvalidState;
-    }
-
-    switch (Cmd)
-    {
-        case OMX_CommandStateSet:
-        {
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandStateSet;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState))
-            {
-                ErrMsgHandler = Mpeg4ComponentInit();
-
-                if (ErrMsgHandler != OMX_ErrorNone)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error component init"));
-                    return OMX_ErrorInsufficientResources;
-                }
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    ipPorts[ii]->TransientState = OMX_StateIdle;
-                }
-            }
-            else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState))
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else if (OMX_StateInvalid == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateInvalid;
-                    }
-                }
-            }
-            else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam))
-                     && (OMX_StateExecuting == iState))
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-
-        }
-        break;
-
-        case OMX_CommandFlush:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandFlush;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-
-            }
-            if ((nParam != -1) && ((OMX_U32)nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            Mpeg4ComponentSetPortFlushFlag(iNumPorts, nParam, OMX_TRUE);
-            Mpeg4ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-        }
-        break;
-
-        case OMX_CommandPortDisable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            iResizePending = OMX_FALSE; // reset the flag to enable processing
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (!PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else
-            {
-                if (!PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateLoaded;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-                Message->MessageParam2 = nParam;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-                Message->MessageParam2 = ErrMsgHandler;
-            }
-            Message->MessageParam1 = OMX_CommandPortDisable;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandPortEnable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateIdle;
-                    }
-                }
-            }
-            else
-            {
-                if (PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateIdle;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-            }
-
-            Message->MessageParam1 = OMX_CommandPortEnable;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandMarkBuffer:
-        {
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-            }
-
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandMarkBuffer;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand error unsupported index"));
-            ErrMsgHandler = OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    Queue(pMessageQueue, Message);
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : SendCommand OUT"));
-    return ErrMsgHandler;
-}
-
-
-/** This is called by the OMX core in its message processing
- * thread context upon a component request. A request is made
- * by the component when some asynchronous services are needed:
- * 1) A SendCommand() is to be processed
- * 2) An error needs to be notified
- * \param Message, the message that has been passed to core
- */
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentMessageHandler(CoreMessage* Message)
-{
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-
-    /** Dealing with a SendCommand call.
-     * -MessageParam1 contains the command to execute
-     * -MessageParam2 contains the parameter of the command
-     *  (destination state in case of a state change command).
-     */
-
-    OMX_STATETYPE orig_state = iState;
-    if (SENDCOMMAND_MSG_TYPE == Message->MessageType)
-    {
-        switch (Message->MessageParam1)
-        {
-            case OMX_CommandStateSet:
-            {
-                /* Do the actual state change */
-                ErrorType = Mpeg4ComponentDoStateSet(Message->MessageParam2);
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                //Do not send the callback now till the State gets changed
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    /* And run the callback */
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventCmdComplete, /* The command was completed */
-                     OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
-                     Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-            }
-            break;
-
-            case OMX_CommandFlush:
-            {
-                /*Flush ports*/
-                ErrorType = Mpeg4ComponentFlushPort(Message->MessageParam2);
-
-                Mpeg4ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-                if (OMX_PORT_INPUTPORT_INDEX == Message->MessageParam2
-                        || OMX_PORT_ALLPORT_INDEX == Message->MessageParam2)
-                {
-                    iIsInputBufferEnded = OMX_TRUE;
-                    iEndofStream = OMX_FALSE;
-                    iNewInBufferRequired = OMX_TRUE;
-                    iPartialFrameAssembly = OMX_FALSE;
-
-                    iTempInputBufferFilledLength = 0;
-                    iTempConsumedLength = 0;
-                    iInputCurrLength = 0;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Flush all port*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {/*Flush input/output port*/
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-                Mpeg4ComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-            }
-            break;
-
-            case OMX_CommandPortDisable:
-            {
-                /** This condition is added to pass the tests, it is not significant for the environment */
-                ErrorType = Mpeg4ComponentDisablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Disable all ports*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandPortEnable:
-            {
-                ErrorType = Mpeg4ComponentEnablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The State has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (Message->MessageParam2 != -1)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                    else
-                    {
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The State has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandMarkBuffer:
-            {
-                ipMark = (OMX_MARKTYPE *)Message->pCmdData;
-            }
-            break;
-
-            default:
-            {
-
-            }
-            break;
-        }
-        /* Dealing with an asynchronous error condition
-         */
-    }
-
-    if (orig_state != OMX_StateInvalid)
-    {
-        ErrorType = OMX_ErrorNone;
-    }
-
-    return ErrorType;
-}
-
-/** Changes the state of a component taking proper actions depending on
- * the transiotion requested
- * \param Component, the component which state is to be changed
- * \param aDestinationState the requested target state.
- */
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::Mpeg4ComponentDoStateSet(OMX_U32 aDestinationState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
-                    (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_U32 ii;
-
-    if (OMX_StateLoaded == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateLoaded;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateIdle:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->IdleToLoadedFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_FALSE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet Waiting port to be un-populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateLoaded;
-
-                iNumInputBuffer = 0;
-                iOutBufferCount = 0;
-                iPartialFrameAssembly = OMX_FALSE;
-                iEndofStream = OMX_FALSE;
-                iIsInputBufferEnded = OMX_TRUE;
-                iNewInBufferRequired = OMX_TRUE;
-                iFirstFragment = OMX_FALSE;
-                iUseExtTimestamp = OMX_TRUE;
-                ipMpegDecoderObject->Mpeg4InitFlag = 0;
-
-                Mpeg4ComponentDeInit();
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateWaitForResources == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateLoaded:
-            {
-                iState = OMX_StateWaitForResources;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateIdle == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            !PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->LoadedToIdleFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_TRUE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet Waiting port to be populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateIdle;
-
-                //Used in case of partial frame assembly wih EndOfFrame flag marked
-                if (!ipInputCurrBuffer)
-                {
-                    //Keep the size of temp buffer double to be on safer side
-                    ipInputCurrBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
+                    ipInputCurrBuffer = (OMX_U8*) oscl_realloc(ipInputCurrBuffer, iInputCurrBufferSize);
                     if (NULL == ipInputCurrBuffer)
                     {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error insufficient resources"));
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error insufficient resources"));
                         return OMX_ErrorInsufficientResources;
                     }
                 }
 
                 //Used when the buffers are not marked with EndOfFrame flag
-                if (!ipTempInputBuffer)
+                if (NULL != ipTempInputBuffer)
                 {
-                    ipTempInputBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
+                    ipTempInputBuffer = (OMX_U8*) oscl_realloc(ipTempInputBuffer, iInputCurrBufferSize);
                     if (NULL == ipTempInputBuffer)
                     {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error insufficient resources"));
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentBase : DoStateSet error insufficient resources"));
                         return OMX_ErrorInsufficientResources;
                     }
                 }
-
-                //Call the init routine here in case of H263 mode, without waiting for buffers
-                if (iDecMode == MODE_H263)
-                {
-                    OMX_S32 Width, Height, Size = 0;
-                    OMX_U8* Buff;
-                    //Pass dummy pointers during initializations
-                    ipMpegDecoderObject->InitializeVideoDecode(&Width, &Height, &Buff, &Size, iDecMode);
-                    ipMpegDecoderObject->Mpeg4InitFlag = 1;
-                }
-
-                iTempInputBufferFilledLength = 0;
-                iTempConsumedLength = 0;
-                iTempInputBufferAllocLength = 2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
             }
-            break;
-
-            case OMX_StateIdle:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            //Both the below cases have same body
-            case OMX_StateExecuting:
-            case OMX_StatePause:
-            {
-                Mpeg4ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-                Mpeg4ComponentSetPortFlushFlag(iNumPorts, -1, OMX_TRUE);
-
-                // take care of buffer still in decoder
-                Mpeg4ComponentPortType* pInPort = (Mpeg4ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-                //Return all the buffers if still occupied
-                QueueType *pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-                while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0))
-                {
-                    Mpeg4ComponentFlushPort(OMX_PORT_INPUTPORT_INDEX);
-                }
-                // if a buffer was dequeued earlier, but not processed, return it now
-                if (iNumInputBuffer > 0)
-                {
-                    ipMpeg4InputBuffer->nFilledLen = 0;
-                    Mpeg4ComponentReturnInputBuffer(ipMpeg4InputBuffer, pInPort);
-                    iNewInBufferRequired = OMX_TRUE;
-                    iIsInputBufferEnded = OMX_TRUE;
-                    iUseExtTimestamp = OMX_TRUE;
-                    iInputCurrLength = 0;
-                }
-
-                //Return all the buffers if still occupied
-                while ((iNumInputBuffer > 0))
-                {
-                    Mpeg4ComponentFlushPort(OMX_PORT_INPUTPORT_INDEX);
-                }
-
-                while (iOutBufferCount > 0)
-                {
-                    Mpeg4ComponentFlushPort(OMX_PORT_OUTPUTPORT_INDEX);
-                }
-                //Mark these flags as true
-                iIsInputBufferEnded = OMX_TRUE;
-                iEndofStream = OMX_FALSE;
-                iNewInBufferRequired = OMX_TRUE;
-                iPartialFrameAssembly = OMX_FALSE;
-
-                //Added these statement here
-                iTempInputBufferFilledLength = 0;
-                iTempConsumedLength = 0;
-                //ipMpegDecoderObject->Mpeg4InitFlag = 0;
-                iInputCurrLength = 0;
-
-                Mpeg4ComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-                Mpeg4ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
         }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet OUT"));
-        return ErrorType;
-    }
 
-    if (OMX_StatePause == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StatePause:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            //Falling through to the next case
-            case OMX_StateExecuting:
-            case OMX_StateIdle:
-            {
-                iState = OMX_StatePause;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet OUT"));
         return OMX_ErrorNone;
     }
-
-    if (OMX_StateExecuting == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            case OMX_StateIdle:
-            {
-                iState = OMX_StateExecuting;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                iState = OMX_StateExecuting;
-                /* A trigger to start the processing of buffers when component
-                 * transitions to executing from pause, as it is already
-                 * holding the required buffers
-                 */
-                RunIfNotReady();
-            }
-            break;
-
-            case OMX_StateExecuting:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateInvalid == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-            default:
-            {
-                iState = OMX_StateInvalid;
-                if (iIsInit != OMX_FALSE)
-                {
-                    Mpeg4ComponentDeInit();
-                }
-            }
-            break;
-        }
-
-        if (iIsInit != OMX_FALSE)
-        {
-            Mpeg4ComponentDeInit();
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Mpeg4ComponentDoStateSet OUT"));
-    return OMX_ErrorNone;
-}
-
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer);
-
-    return Status;
-
-}
-
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::EmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    OSCL_UNUSED_ARG(hComponent);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer IN"));
-    //Do not queue buffers if component is in invalid state
-    if (OMX_StateInvalid == iState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState))
-    {
-        OMX_U32 PortIndex;
-        QueueType* pInputQueue;
-        OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-        PortIndex = pBuffer->nInputPortIndex;
-
-        //Validate the port index & Queue the buffers available only at the input port
-        if (PortIndex >= iNumPorts ||
-                ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer error bad port index"));
-            return OMX_ErrorBadPortIndex;
-        }
-
-        //Port should be in enabled state before accepting buffers
-        if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        /* The number of buffers the component can queue at a time
-         * depends upon the number of buffers allocated/assigned on the input port
-         */
-        if (iNumInputBuffer ==
-                (ipPorts[PortIndex]->NumAssignedBuffers))
-        {
-            RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        //Finally after passing all the conditions, queue the buffer in Input queue
-        pInputQueue = ipPorts[PortIndex]->pBufferQueue;
-
-        if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer error check header failed"));
-            return ErrorType;
-        }
-
-        iNumInputBuffer++;
-        Queue(pInputQueue, pBuffer);
-
-        //Signal the AO about the incoming buffer
-        RunIfNotReady();
-    }
     else
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer error incorrect state"));
-        //This macro is not accepted in any other state except the three mentioned above
-        return OMX_ErrorIncorrectStateOperation;
+        return OMX_ErrorInsufficientResources;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : EmptyThisBuffer OUT"));
-
-    return OMX_ErrorNone;
 }
 
-
-OMX_ERRORTYPE OpenmaxMpeg4AO::BaseComponentFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+OMX_BOOL OpenmaxMpeg4AO::DecodeH263Header(OMX_U8* aInputBuffer,
+        OMX_U32* aBufferSize)
 {
+    uint32 codeword;
+    int32	extended_PTYPE = 0;
+    int32 UFEP = 0;
+    int32 custom_PFMT = 0;
 
-    OpenmaxMpeg4AO* pOpenmaxAOType = (OpenmaxMpeg4AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
+    //Reset the data bit position to the start of the stream
+    iH263DataBitPos = 0;
+    iH263BitPos = 0;
+    //BitBuf contains the first 4 bytes of the aInputBuffer
+    iH263BitBuf = (aInputBuffer[0] << 24) | (aInputBuffer[1] << 16) | (aInputBuffer[2] << 8) | aInputBuffer[3];
 
-    if (NULL == pOpenmaxAOType)
+    ReadBits(aInputBuffer, 22, &codeword);
+    if (codeword !=  0x20)
     {
-        return OMX_ErrorBadParameter;
+        return OMX_FALSE;
     }
 
-    Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer);
+    ReadBits(aInputBuffer, 8, &codeword);
 
-    return Status;
-}
+    ReadBits(aInputBuffer, 1, &codeword);
+    if (codeword == 0) return OMX_FALSE;
 
-OMX_ERRORTYPE OpenmaxMpeg4AO::FillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+    ReadBits(aInputBuffer, 1, &codeword);
+    if (codeword == 1) return OMX_FALSE;
 
-{
-    OSCL_UNUSED_ARG(hComponent);
+    ReadBits(aInputBuffer, 1, &codeword);
+    if (codeword == 1) return OMX_FALSE;
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FillThisBuffer IN"));
+    ReadBits(aInputBuffer, 1, &codeword);
+    if (codeword == 1) return OMX_FALSE;
 
-    OMX_U32 PortIndex;
+    ReadBits(aInputBuffer, 1, &codeword);
+    if (codeword == 1) return OMX_FALSE;
 
-    QueueType* pOutputQueue;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-    PortIndex = pBuffer->nOutputPortIndex;
-    //Validate the port index & Queue the buffers available only at the output port
-    if (PortIndex >= iNumPorts ||
-            ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput)
+    /* source format */
+    ReadBits(aInputBuffer, 3, &codeword);
+    switch (codeword)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FillThisBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
+        case 1:
+            *aBufferSize = 32000;
+            break;
+
+        case 2:
+            *aBufferSize = 32000;
+            break;
+
+        case 3:
+            *aBufferSize = 128000;
+            break;
+
+        case 4:
+            *aBufferSize = 256000;
+            break;
+
+        case 5:
+            *aBufferSize = 512000;
+            break;
+
+        case 7:
+            extended_PTYPE = 1;
+            break;
+        default:
+            /* Msg("H.263 source format not legal\n"); */
+            return OMX_FALSE;
     }
 
-    pOutputQueue = ipPorts[PortIndex]->pBufferQueue;
-    if (iState != OMX_StateExecuting &&
-            iState != OMX_StatePause &&
-            iState != OMX_StateIdle)
+    if (extended_PTYPE == 0)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FillThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
+        return OMX_TRUE;
     }
 
-    //Port should be in enabled state before accepting buffers
-    if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
+    /* source format */
+    ReadBits(aInputBuffer, 3, &codeword);
+    UFEP = codeword;
+    if (UFEP == 1)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FillThisBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FillThisBuffer error check header failed"));
-        return ErrorType;
-    }
-
-    //Queue the buffer in output queue
-    Queue(pOutputQueue, pBuffer);
-    iOutBufferCount++;
-
-    //Signal the AO about the incoming buffer
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : FillThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxMpeg4AO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Run IN"));
-
-    CoreMessage* pCoreMessage;
-
-    //Execute the commands from the message handler queue
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue);
-
-        if (OMX_CommandStateSet == pCoreMessage->MessageParam1)
+        ReadBits(aInputBuffer, 3, &codeword);
+        switch (codeword)
         {
-            if (OMX_StateExecuting == pCoreMessage->MessageParam2)
-            {
-                iBufferExecuteFlag = OMX_TRUE;
-            }
-            else
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
+            case 1:
+                *aBufferSize = 32000;
+                break;
+
+            case 2:
+                *aBufferSize = 32000;
+                break;
+
+            case 3:
+                *aBufferSize = 128000;
+                break;
+
+            case 4:
+                *aBufferSize = 256000;
+                break;
+
+            case 5:
+                *aBufferSize = 512000;
+                break;
+
+            case 6:
+                custom_PFMT = 1;
+                break;
+            default:
+                /* Msg("H.263 source format not legal\n"); */
+                return OMX_FALSE;
+        }
+        if (custom_PFMT == 0)
+        {
+            return OMX_TRUE;
         }
 
-        Mpeg4ComponentMessageHandler(pCoreMessage);
 
-        /* If some allocations/deallocations are required before the state transition
-         * then queue the command again to be executed later on
-         */
-        if (OMX_TRUE == iStateTransitionFlag)
+        ReadBits(aInputBuffer, 1, &codeword);
+        ReadBits(aInputBuffer, 1, &codeword);
+        if (codeword) return OMX_FALSE;
+        ReadBits(aInputBuffer, 1, &codeword);
+        if (codeword) return OMX_FALSE;
+        ReadBits(aInputBuffer, 1, &codeword);
+        if (codeword) return OMX_FALSE;
+        ReadBits(aInputBuffer, 3, &codeword);
+        ReadBits(aInputBuffer, 3, &codeword);
+        if (codeword) return OMX_FALSE; 			/* RPS, ISD, AIV */
+        ReadBits(aInputBuffer, 1, &codeword);
+        ReadBits(aInputBuffer, 4, &codeword);
+        if (codeword != 8) return OMX_FALSE;
+    }
+
+    if (UFEP == 0 || UFEP == 1)
+    {
+        ReadBits(aInputBuffer, 3, &codeword);
+        if (codeword > 1) return OMX_FALSE;
+        ReadBits(aInputBuffer, 1, &codeword);
+        if (codeword) return OMX_FALSE;
+        ReadBits(aInputBuffer, 1, &codeword);
+        if (codeword) return OMX_FALSE;
+        ReadBits(aInputBuffer, 1, &codeword);
+        ReadBits(aInputBuffer, 3, &codeword);
+        if (codeword != 1) return OMX_FALSE;
+    }
+    else
+    {
+        return OMX_FALSE;
+    }
+
+    ReadBits(aInputBuffer, 1, &codeword);
+    if (codeword) return OMX_FALSE; /* CPM */
+    if (custom_PFMT == 1 && UFEP == 1)
+    {
+        OMX_U32 DisplayWidth, Width, DisplayHeight, Height, Resolution;
+
+        ReadBits(aInputBuffer, 4, &codeword);
+        if (codeword == 0) return OMX_FALSE;
+        if (codeword == 0xf)
         {
-            Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage);
-            // Don't reschedule. Buffers arriving will do the scheduling
-            //RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Run OUT"));
-            return;
+            ReadBits(aInputBuffer, 8, &codeword);
+            ReadBits(aInputBuffer, 8, &codeword);
         }
+        ReadBits(aInputBuffer, 9, &codeword);
+        DisplayWidth = (codeword + 1) << 2;
+        Width = (DisplayWidth + 15) & -16;
 
-        else
+        ReadBits(aInputBuffer, 1, &codeword);
+        if (codeword != 1) return OMX_FALSE;
+        ReadBits(aInputBuffer, 9, &codeword);
+        if (codeword == 0) return OMX_FALSE;
+        DisplayHeight = codeword << 2;
+        Height = (DisplayHeight + 15) & -16;
+
+        Resolution = Width * Height;
+
+        if (Resolution <= 25344)		//25344 = 176x144 (QCIF)
         {
-            oscl_free(pCoreMessage);
-            pCoreMessage = NULL;
+            *aBufferSize = 32000;
+        }
+        else if (Resolution <= 101376)	//101376 = 352x288 (CIF)
+        {
+            *aBufferSize = 128000;
+        }
+        else if (Resolution <= 405504)	//405504 = 704*576 (4CIF)
+        {
+            *aBufferSize = 256000;
+        }
+        else							//1408x1152 (16CIF)
+        {
+            //This is the max buffer size that we want to allocate
+            *aBufferSize = 512000;
         }
     }
 
-    /* If the component is in executing state, call the Buffer management function.
-     * Stop calling this function as soon as state transition request is received.
-     */
-    if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending))
-    {
-        Mpeg4ComponentBufferMgmtFunction();
+    return OMX_TRUE;
+}
 
+
+void OpenmaxMpeg4AO::ReadBits(OMX_U8* aStream,           /* Input Stream */
+                              uint8 aNumBits,                     /* nr of bits to read */
+                              uint32* aOutData                 /* output target */
+                             )
+{
+    uint8 *bits;
+    uint32 dataBitPos = iH263DataBitPos;
+    uint32 bitPos = iH263BitPos;
+    uint32 dataBytePos;
+
+    if (aNumBits > (32 - bitPos))    /* not enough bits */
+    {
+        dataBytePos = dataBitPos >> 3;    /* Byte Aligned Position */
+        bitPos = dataBitPos & 7; /* update bit position */
+        bits = &aStream[dataBytePos];
+        iH263BitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
     }
 
-    //Check for any more commands in the message handler queue & schedule them for later
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        RunIfNotReady();
-    }
+    iH263DataBitPos += aNumBits;
+    iH263BitPos      = (unsigned char)(bitPos + aNumBits);
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMpeg4AO : Run OUT"));
+    *aOutData = (iH263BitBuf >> (32 - iH263BitPos)) & mask[(uint16)aNumBits];
 
     return;
 }
+
diff --git a/codecs_v2/omx/omx_m4venc/Android.mk b/codecs_v2/omx/omx_m4venc/Android.mk
new file mode 100644
index 0000000..38eff43
--- /dev/null
+++ b/codecs_v2/omx/omx_m4venc/Android.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/mpeg4_enc.cpp \
+ 	src/omx_mpeg4enc_component.cpp
+
+
+LOCAL_MODULE := libomx_m4venc_component_lib
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_m4venc/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_m4venc/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/video/m4v_h263/enc/src \
+ 	$(PV_TOP)/codecs_v2/video/m4v_h263/enc/include \
+ 	$(PV_TOP)/codecs_v2/utilities/colorconvert/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/mpeg4_enc.h \
+ 	include/omx_mpeg4enc_component.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/omx/omx_m4venc/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_m4venc/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..7d69335
--- /dev/null
+++ b/codecs_v2/omx/omx_m4venc/build/make_multithreaded/local.mk
@@ -0,0 +1,33 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_m4venc_component_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../video/m4v_h263/enc/src \
+  ../../../../video/m4v_h263/enc/include \
+  ../../../../utilities/colorconvert/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := mpeg4_enc.cpp \
+	omx_mpeg4enc_component.cpp
+
+
+HDRS := mpeg4_enc.h \
+	omx_mpeg4enc_component.h
+	
+
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_m4venc/include/mpeg4_enc.h b/codecs_v2/omx/omx_m4venc/include/mpeg4_enc.h
new file mode 100644
index 0000000..fb1fa43
--- /dev/null
+++ b/codecs_v2/omx/omx_m4venc/include/mpeg4_enc.h
@@ -0,0 +1,127 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef MPEG4_ENC_H_INCLUDED
+#define MPEG4_ENC_H_INCLUDED
+
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#ifndef _MP4ENC_API_H_
+#include "mp4enc_api.h"
+#endif
+
+#ifndef CCRGB24TOYUV420_H_INCLUDED
+#include "ccrgb24toyuv420.h"
+#endif
+
+#ifndef CCRGB12TOYUV420_H_INCLUDED
+#include "ccrgb12toyuv420.h"
+#endif
+
+#ifndef CCYUV420SEMITOYUV420_H_INCLUDED
+#include "ccyuv420semitoyuv420.h"
+#endif
+
+const uint32 DEFAULT_VOL_HEADER_LENGTH = 28;
+const uint32 PVMFTIMESTAMP_LESSTHAN_THRESHOLD = 0x80000000;
+
+enum
+{
+    MODE_H263 = 0,
+    MODE_MPEG4
+};
+
+
+class Mpeg4Encoder_OMX
+{
+    public:
+
+        Mpeg4Encoder_OMX();
+
+        OMX_ERRORTYPE Mp4EncInit(OMX_S32 iEncMode,
+                                 OMX_VIDEO_PORTDEFINITIONTYPE aInputParam,
+                                 OMX_CONFIG_ROTATIONTYPE aInputOrientationType,
+                                 OMX_VIDEO_PORTDEFINITIONTYPE aEncodeParam,
+                                 OMX_VIDEO_PARAM_MPEG4TYPE aEncodeMpeg4Param,
+                                 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE aErrorCorrection,
+                                 OMX_VIDEO_PARAM_BITRATETYPE aRateControlType,
+                                 OMX_VIDEO_PARAM_QUANTIZATIONTYPE aQuantType,
+                                 OMX_VIDEO_PARAM_MOTIONVECTORTYPE aSearchRange,
+                                 OMX_VIDEO_PARAM_INTRAREFRESHTYPE aIntraRefresh,
+                                 OMX_VIDEO_PARAM_H263TYPE aH263Type,
+                                 OMX_VIDEO_PARAM_PROFILELEVELTYPE* aProfileLevel);
+
+
+        OMX_BOOL Mp4EncodeVideo(OMX_U8*    aOutBuffer,
+                                OMX_U32*   aOutputLength,
+                                OMX_BOOL*  aBufferOverRun,
+                                OMX_U8**   aOverBufferPointer,
+                                OMX_U8*    aInBuffer,
+                                OMX_U32    aInBufSize,
+                                OMX_TICKS  aInTimeStamp,
+                                OMX_TICKS* aOutTimeStamp,
+                                OMX_BOOL*  aSyncFlag);
+
+        OMX_ERRORTYPE Mp4RequestIFrame();
+        OMX_BOOL Mp4UpdateBitRate(OMX_U32 aEncodedBitRate);
+        OMX_BOOL Mp4UpdateFrameRate(OMX_U32 aEncodeFramerate);
+
+        OMX_ERRORTYPE Mp4EncDeinit();
+
+
+    private:
+
+        void CopyToYUVIn(uint8* YUV, int width, int height, int width_16, int height_16);
+
+        /* RGB->YUV conversion */
+        ColorConvertBase *ccRGBtoYUV;
+
+        //Routine to compare two timestamps a and b
+        OMX_BOOL LessThan(uint32& a, uint32& b, uint32 Threshold);
+
+        VideoEncControls	 iEncoderControl;
+        OMX_BOOL			 iInitialized;
+        OMX_COLOR_FORMATTYPE iVideoFormat;
+
+        int		iSrcWidth;
+        int		iSrcHeight;
+        int		iFrameOrientation;
+        uint32	iSrcFrameRate;
+        uint8*	iYUVIn;
+        uint8*	iVideoIn;
+        uint8*	iVideoOut;
+        uint32	iNextModTime;
+        MP4HintTrack iHintTrack;
+        MP4EncodingMode	ENC_Mode;
+
+        OMX_U8 iVolHeader[DEFAULT_VOL_HEADER_LENGTH]; /** Vol header */
+        OMX_U32 iVolHeaderSize;
+        OMX_BOOL iVolHeaderFlag;
+
+        bool iSupport64bitTimestamp;
+
+};
+
+
+#endif ///#ifndef MPEG4_ENC_H_INCLUDED
diff --git a/codecs_v2/omx/omx_m4venc/include/omx_mpeg4enc_component.h b/codecs_v2/omx/omx_m4venc/include/omx_mpeg4enc_component.h
new file mode 100644
index 0000000..828eb6e
--- /dev/null
+++ b/codecs_v2/omx/omx_m4venc/include/omx_mpeg4enc_component.h
@@ -0,0 +1,84 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+	@file omx_mpeg4enc_component.h
+	OpenMax encoder_component component.
+
+*/
+
+#ifndef OMX_MPEG4ENC_COMPONENT_H_INCLUDED
+#define OMX_MPEG4ENC_COMPONENT_H_INCLUDED
+
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
+#endif
+
+#ifndef MPEG4_ENC_H_INCLUDED
+#include "mpeg4_enc.h"
+#endif
+
+
+#define INPUT_BUFFER_SIZE_MP4ENC 38016			//(176 * 144 * 1.5) for YUV 420 format.
+#define OUTPUT_BUFFER_SIZE_MP4ENC 8192
+
+
+#define NUMBER_INPUT_BUFFER_MP4ENC  5
+#define NUMBER_OUTPUT_BUFFER_MP4ENC  2
+
+
+
+class OmxComponentMpeg4EncAO : public OmxComponentVideo
+{
+    public:
+
+        OmxComponentMpeg4EncAO();
+        ~OmxComponentMpeg4EncAO();
+
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
+
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
+
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+
+        void SetEncoderMode(OMX_S32 aMode);
+        void ProcessInBufferFlag();
+
+        void ProcessData();
+
+        OMX_ERRORTYPE SetConfig(
+            OMX_IN  OMX_HANDLETYPE hComponent,
+            OMX_IN  OMX_INDEXTYPE nIndex,
+            OMX_IN  OMX_PTR pComponentConfigStructure);
+
+    private:
+
+        OMX_BOOL CopyDataToOutputBuffer();
+
+        Mpeg4Encoder_OMX* ipMpegEncoderObject;
+        OMX_S32			  iEncMode;
+
+        OMX_BOOL		  iBufferOverRun;
+        OMX_U8*			  ipInternalOutBuffer;
+        OMX_U32			  iInternalOutBufFilledLen;
+        OMX_TICKS		  iOutputTimeStamp;
+        OMX_BOOL		  iSyncFlag;
+};
+
+#endif // OMX_MPEG4ENC_COMPONENT_H_INCLUDED
diff --git a/codecs_v2/omx/omx_m4venc/src/mpeg4_enc.cpp b/codecs_v2/omx/omx_m4venc/src/mpeg4_enc.cpp
new file mode 100644
index 0000000..c1e01f7
--- /dev/null
+++ b/codecs_v2/omx/omx_m4venc/src/mpeg4_enc.cpp
@@ -0,0 +1,1041 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "mpeg4_enc.h"
+#include "oscl_mem.h"
+
+#define MAX_SUPPORTED_LAYER 1
+
+const uint8 DEFAULT_VOL_HEADER[DEFAULT_VOL_HEADER_LENGTH] =
+{
+    0x00, 0x00, 0x01, 0xB0, 0x08, 0x00, 0x00, 0x01,
+    0xB5, 0x09,	0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x01, 0x20, 0x00, 0x84, 0x40, 0xFA, 0x28, 0x2C,
+    0x20, 0x90, 0xA2, 0x1F
+};
+
+
+
+Mpeg4Encoder_OMX::Mpeg4Encoder_OMX()
+{
+    iVolHeaderFlag = OMX_FALSE;
+
+    iInitialized = OMX_FALSE;
+    iYUVIn = NULL;
+    ccRGBtoYUV = NULL;
+
+    // Create a default VOL header
+    oscl_memset(iVolHeader, 0, DEFAULT_VOL_HEADER_LENGTH);
+    oscl_memcpy(iVolHeader, (OsclAny*)DEFAULT_VOL_HEADER, DEFAULT_VOL_HEADER_LENGTH);
+    iVolHeaderSize = DEFAULT_VOL_HEADER_LENGTH;
+
+    // DV: first check whether compiler supports 64 bits
+    OMX_TICKS test_var = 0x80000000;
+
+    iSupport64bitTimestamp = false;
+
+    if (((test_var << 1) >> 1) == test_var)
+    {
+        iSupport64bitTimestamp = true;
+    }
+
+}
+
+
+/* Initialization routine */
+OMX_ERRORTYPE Mpeg4Encoder_OMX::Mp4EncInit(OMX_S32 iEncMode,
+        OMX_VIDEO_PORTDEFINITIONTYPE aInputParam,
+        OMX_CONFIG_ROTATIONTYPE aInputOrientationType,
+        OMX_VIDEO_PORTDEFINITIONTYPE aEncodeParam,
+        OMX_VIDEO_PARAM_MPEG4TYPE aEncodeMpeg4Param,
+        OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE aErrorCorrection,
+        OMX_VIDEO_PARAM_BITRATETYPE aRateControlType,
+        OMX_VIDEO_PARAM_QUANTIZATIONTYPE aQuantType,
+        OMX_VIDEO_PARAM_MOTIONVECTORTYPE aSearchRange,
+        OMX_VIDEO_PARAM_INTRAREFRESHTYPE aIntraRefresh,
+        OMX_VIDEO_PARAM_H263TYPE aH263Type,
+        OMX_VIDEO_PARAM_PROFILELEVELTYPE* aProfileLevel)
+{
+    OMX_U8* pMemBuffer;
+    VideoEncOptions aEncOption; /* encoding options */
+
+    Int	quantType[2] = {0, 0};		/* default H.263 quant*/
+
+    oscl_memset((void*) &iEncoderControl, 0, sizeof(VideoEncControls));
+
+    switch (iEncMode)
+    {
+        case MODE_H263:
+        {
+            if (aH263Type.nGOBHeaderInterval > 0)
+            {
+                ENC_Mode = H263_MODE_WITH_ERR_RES;
+            }
+            else
+            {
+                ENC_Mode = H263_MODE;
+            }
+        }
+        break;
+
+        case MODE_MPEG4:
+        {
+            if (OMX_TRUE == aEncodeMpeg4Param.bSVH)
+            {
+                if (aH263Type.nGOBHeaderInterval > 0)
+                {
+                    ENC_Mode = SHORT_HEADER_WITH_ERR_RES;
+                }
+                else
+                {
+                    ENC_Mode = SHORT_HEADER;
+                }
+            }
+            else
+            {
+                if (OMX_TRUE == aErrorCorrection.bEnableDataPartitioning)
+                {
+                    ENC_Mode = DATA_PARTITIONING_MODE;
+                }
+                else if (OMX_TRUE == aErrorCorrection.bEnableResync)
+                {
+                    ENC_Mode = COMBINE_MODE_WITH_ERR_RES;
+                }
+                else
+                {
+                    ENC_Mode = COMBINE_MODE_NO_ERR_RES;
+                }
+            }
+        }
+        break;
+
+        default:
+        {
+            return OMX_ErrorUnsupportedSetting;
+        }
+    }
+
+    iSrcWidth = aInputParam.nFrameWidth;
+    iSrcHeight = aInputParam.nFrameHeight;
+    iSrcFrameRate = aInputParam.xFramerate;
+
+    iFrameOrientation = aInputOrientationType.nRotation;
+
+
+    if ((OMX_COLOR_FormatYUV420Planar == aInputParam.eColorFormat) ||
+            (OMX_COLOR_Format24bitRGB888 == aInputParam.eColorFormat) ||
+            (OMX_COLOR_Format12bitRGB444 == aInputParam.eColorFormat) ||
+            (OMX_COLOR_FormatYUV420SemiPlanar == aInputParam.eColorFormat))
+    {
+        iVideoFormat = aInputParam.eColorFormat;
+    }
+    else
+    {
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+    //Verify the input compression format
+    if (OMX_VIDEO_CodingUnused != aInputParam.eCompressionFormat)
+    {
+        //Input port must have no compression supported
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+
+    if (OMX_TRUE == iInitialized)
+    {
+        /* clean up before re-initialized */
+        PVCleanUpVideoEncoder(&iEncoderControl);
+        if (iYUVIn)
+        {
+            oscl_free(iYUVIn);
+            iYUVIn = NULL;
+        }
+
+    }
+
+    // allocate iYUVIn
+    if (((iSrcWidth & 0xF) || (iSrcHeight & 0xF)) || OMX_COLOR_FormatYUV420Planar != iVideoFormat) /* Not multiple of 16 */
+    {
+        iYUVIn = (uint8*) oscl_malloc(((((iSrcWidth + 15) >> 4) * ((iSrcHeight + 15) >> 4)) * 3) << 7);
+        if (NULL == iYUVIn)
+        {
+            return OMX_ErrorInsufficientResources;
+        }
+    }
+
+    /* Initialize the color conversion */
+    if (OMX_COLOR_Format24bitRGB888 == iVideoFormat)
+    {
+        ccRGBtoYUV = CCRGB24toYUV420::New();
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 180 ? CCBOTTOM_UP : 0));
+    }
+    if (OMX_COLOR_Format12bitRGB444 == iVideoFormat)
+    {
+        ccRGBtoYUV = CCRGB12toYUV420::New();
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 180 ? CCBOTTOM_UP : 0));
+    }
+    if (OMX_COLOR_FormatYUV420SemiPlanar == iVideoFormat)
+    {
+        ccRGBtoYUV = CCYUV420SEMItoYUV420::New();
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 180 ? CCBOTTOM_UP : 0));
+    }
+
+
+    PVGetDefaultEncOption(&aEncOption, 0);
+
+    aEncOption.encWidth[0] = aEncodeParam.nFrameWidth;
+    aEncOption.encHeight[0] = aEncodeParam.nFrameHeight;
+    aEncOption.encFrameRate[0] = (aEncodeParam.xFramerate >> 16) + (OsclFloat)(aEncodeParam.xFramerate & 0xFFFF) / (1 << 16);
+
+
+
+    switch (aRateControlType.eControlRate)
+    {
+        case OMX_Video_ControlRateDisable:
+        {
+            aEncOption.rcType = CONSTANT_Q;
+            aEncOption.vbvDelay = (float)10.0;
+        }
+        break;
+
+        case OMX_Video_ControlRateConstant:
+        {
+            aEncOption.rcType = CBR_1;
+            aEncOption.vbvDelay = (float)2.0;
+        }
+        break;
+
+        case OMX_Video_ControlRateVariable:
+        {
+            aEncOption.rcType = VBR_1;
+            aEncOption.vbvDelay = (float)5.0;
+        }
+        break;
+
+        default:
+            return OMX_ErrorUnsupportedSetting;
+    }
+
+    //Set the profile level of encoder
+    switch (aEncodeMpeg4Param.eProfile)
+    {
+        case OMX_VIDEO_MPEG4ProfileSimple:
+        {
+            if (OMX_VIDEO_MPEG4Level0 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_PROFILE_LEVEL0;
+            }
+            else if (OMX_VIDEO_MPEG4Level1 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_PROFILE_LEVEL1;
+            }
+            else if (OMX_VIDEO_MPEG4Level2 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_PROFILE_LEVEL2;
+            }
+            else if (OMX_VIDEO_MPEG4Level3 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_PROFILE_LEVEL3;
+            }
+            else
+            {
+                return OMX_ErrorUnsupportedSetting;
+            }
+        }
+        break;
+
+        case OMX_VIDEO_MPEG4ProfileSimpleScalable:
+        {
+            if (OMX_VIDEO_MPEG4Level0 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_SCALABLE_PROFILE_LEVEL0;
+            }
+            else if (OMX_VIDEO_MPEG4Level1 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_SCALABLE_PROFILE_LEVEL1;
+            }
+            else if (OMX_VIDEO_MPEG4Level2 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = SIMPLE_SCALABLE_PROFILE_LEVEL2;
+            }
+            else
+            {
+                return OMX_ErrorUnsupportedSetting;
+            }
+        }
+        break;
+
+        case OMX_VIDEO_MPEG4ProfileCore:
+        {
+            if (OMX_VIDEO_MPEG4Level1 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = CORE_PROFILE_LEVEL1;
+            }
+            else if (OMX_VIDEO_MPEG4Level2 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = CORE_PROFILE_LEVEL2;
+            }
+            else
+            {
+                return OMX_ErrorUnsupportedSetting;
+            }
+        }
+        break;
+
+        case OMX_VIDEO_MPEG4ProfileCoreScalable:
+        {
+            if (OMX_VIDEO_MPEG4Level1 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = CORE_SCALABLE_PROFILE_LEVEL1;
+            }
+            else if (OMX_VIDEO_MPEG4Level2 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = CORE_SCALABLE_PROFILE_LEVEL2;
+            }
+            else if (OMX_VIDEO_MPEG4Level3 == aEncodeMpeg4Param.eLevel)
+            {
+                aEncOption.profile_level = CORE_SCALABLE_PROFILE_LEVEL3;
+            }
+            else
+            {
+                return OMX_ErrorUnsupportedSetting;
+            }
+        }
+        break;
+
+        default:
+        {
+            return OMX_ErrorUnsupportedSetting;
+        }
+
+    }
+
+    aEncOption.encMode = ENC_Mode;
+
+    if (DATA_PARTITIONING_MODE == ENC_Mode)
+    {
+        aEncOption.packetSize = aEncodeMpeg4Param.nMaxPacketSize;
+    }
+    else
+    {
+        aEncOption.packetSize = aErrorCorrection.nResynchMarkerSpacing / 8;
+    }
+
+    if ((OMX_TRUE == aErrorCorrection.bEnableRVLC) ||
+            (OMX_TRUE == aEncodeMpeg4Param.bReversibleVLC))
+    {
+        aEncOption.rvlcEnable = PV_ON;
+    }
+    else
+    {
+        aEncOption.rvlcEnable = PV_OFF;
+    }
+
+    aEncOption.numLayers = MAX_SUPPORTED_LAYER;
+    if ((aEncodeMpeg4Param.nTimeIncRes << 16) > iSrcFrameRate)
+    {
+        aEncOption.timeIncRes = aEncodeMpeg4Param.nTimeIncRes;
+    }
+    else
+    {
+        //Default value
+        aEncOption.timeIncRes = 1000;
+    }
+
+    if (iSrcFrameRate > 0)
+    {
+        aEncOption.tickPerSrc = (aEncOption.timeIncRes << 16) / iSrcFrameRate;
+    }
+
+    aEncOption.bitRate[0] = aEncodeParam.nBitrate;
+    aEncOption.iQuant[0] = aQuantType.nQpI;
+    aEncOption.pQuant[0] = aQuantType.nQpP;
+    aEncOption.quantType[0] = quantType[0]; /* default to H.263 */
+
+
+    aEncOption.noFrameSkipped = PV_OFF;
+
+    //IPPPPPPPPPP, indicates I-frame followed by all P-frames
+    if (0xFFFFFFFF == aEncodeMpeg4Param.nPFrames)
+    {
+        aEncOption.intraPeriod = -1;
+    }
+    else
+    {
+        aEncOption.intraPeriod = aEncodeMpeg4Param.nPFrames + 1;
+    }
+
+    //No support for B Frames
+    if (aEncodeMpeg4Param.nBFrames > 0)
+    {
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+    //Encoder support only I and P frames picture type
+    if (0 == (aEncodeMpeg4Param.nAllowedPictureTypes &
+              (OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP)))
+    {
+        return OMX_ErrorUnsupportedSetting;
+    }
+
+    if (OMX_VIDEO_PictureTypeI == aEncodeMpeg4Param.nAllowedPictureTypes) // I-only
+    {
+        aEncOption.intraPeriod = 1;
+    }
+
+
+    if ((OMX_VIDEO_IntraRefreshCyclic == aIntraRefresh.eRefreshMode) ||
+            (OMX_VIDEO_IntraRefreshBoth == aIntraRefresh.eRefreshMode))
+    {
+        aEncOption.numIntraMB = aIntraRefresh.nCirMBs;
+    }
+
+    if ((OMX_VIDEO_IntraRefreshAdaptive == aIntraRefresh.eRefreshMode) ||
+            (OMX_VIDEO_IntraRefreshBoth == aIntraRefresh.eRefreshMode))
+    {
+        aEncOption.sceneDetect = PV_ON;
+    }
+    else
+    {
+        aEncOption.sceneDetect = PV_OFF;
+    }
+
+    aEncOption.searchRange = (aSearchRange.sXSearchRange <= aSearchRange.sYSearchRange ? aSearchRange.sXSearchRange : aSearchRange.sYSearchRange);
+    aEncOption.mv8x8Enable = PV_OFF; //disable for now(aSearchRange.bFourMV == OMX_TRUE) ? PV_ON : PV_OFF;
+
+    aEncOption.gobHeaderInterval = aH263Type.nGOBHeaderInterval;
+
+    aEncOption.useACPred = ((aEncodeMpeg4Param.bACPred == OMX_TRUE) ? PV_ON : PV_OFF);
+
+    aEncOption.intraDCVlcTh = aEncodeMpeg4Param.nIDCVLCThreshold;
+    /* note aEncOption.intraDCVlcTh will be clipped btw (0,7) inside PV M4V encoder */
+
+    //Checking the range of parameters that the encoder can't support here
+    // and return OMX_ErrorUnsupportedSetting
+
+    /***** Initlaize the encoder *****/
+    if (PV_FALSE == PVInitVideoEncoder(&iEncoderControl, &aEncOption))
+    {
+        iInitialized = OMX_FALSE;
+        return OMX_ErrorBadParameter;
+    }
+
+    iInitialized = OMX_TRUE;
+    iNextModTime = 0;
+
+
+    //Update the vol header for non-h263 modes
+    if ((DATA_PARTITIONING_MODE == ENC_Mode) ||
+            (COMBINE_MODE_WITH_ERR_RES == ENC_Mode) ||
+            (COMBINE_MODE_NO_ERR_RES == ENC_Mode) ||
+            (SHORT_HEADER == ENC_Mode) ||
+            (SHORT_HEADER_WITH_ERR_RES == ENC_Mode))
+    {
+        // M4V output, get VOL header
+        iVolHeaderSize = 32; // Encoder requires that buffer size is greater than vol header size (28)
+
+        pMemBuffer = (OMX_U8*) oscl_malloc(iVolHeaderSize);
+        oscl_memset(pMemBuffer, 0, iVolHeaderSize);
+
+        int32 Length = iVolHeaderSize;
+
+        if (PV_FALSE == PVGetVolHeader(&iEncoderControl, (uint8*)pMemBuffer, &Length, 0))
+        {
+            return OMX_ErrorBadParameter;
+        }
+
+        iVolHeaderSize = Length;
+        oscl_memcpy(iVolHeader, (OsclAny*)pMemBuffer, iVolHeaderSize);
+
+        oscl_free(pMemBuffer);
+        pMemBuffer = NULL;
+    }
+
+
+    //Updating the profile and level from the encoder after initialization
+    if (MODE_MPEG4 == iEncMode)
+    {
+        ProfileLevelType EncProfileLevel;
+        Int temp;
+
+        if (PV_FALSE == PVGetMPEG4ProfileLevelID(&iEncoderControl, &temp, 0))
+        {
+            return OMX_ErrorBadParameter;
+        }
+        EncProfileLevel = (ProfileLevelType) temp;
+
+        //Convert the EncProfileLevel to appropriate profile and level of openmax
+        if (SIMPLE_PROFILE_LEVEL0 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level0;
+
+        }
+        else if (SIMPLE_PROFILE_LEVEL1 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level1;
+        }
+        else if (SIMPLE_PROFILE_LEVEL2 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level2;
+        }
+        else if (SIMPLE_PROFILE_LEVEL3 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level3;
+        }
+        else if (CORE_PROFILE_LEVEL1 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileCore;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level1;
+        }
+        else if (CORE_PROFILE_LEVEL2 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileCore;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level2;
+        }
+        else if (SIMPLE_SCALABLE_PROFILE_LEVEL0 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level0;
+        }
+        else if (SIMPLE_SCALABLE_PROFILE_LEVEL1 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level1;
+        }
+        else if (SIMPLE_SCALABLE_PROFILE_LEVEL2 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level2;
+        }
+        else if (CORE_SCALABLE_PROFILE_LEVEL1 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level1;
+        }
+        else if (CORE_SCALABLE_PROFILE_LEVEL2 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level2;
+        }
+        else if (CORE_SCALABLE_PROFILE_LEVEL3 == EncProfileLevel)
+        {
+            aProfileLevel->eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable;
+            aProfileLevel->eLevel = OMX_VIDEO_MPEG4Level3;
+        }
+        else
+        {
+            //None of the supported parameter found
+            return OMX_ErrorBadParameter;
+        }
+    }
+    //mode H263
+    else
+    {
+        Int ProfileID, LevelID;
+
+        if (PV_FALSE == PVGetH263ProfileLevelID(&iEncoderControl, &ProfileID, &LevelID))
+        {
+            return OMX_ErrorBadParameter;
+        }
+
+        //Converting the encoder level into the openmax parameters
+        //Profile is set constant at baseline
+        if (10 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level10;
+        }
+        else if (20 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level20;
+        }
+        else if (30 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level30;
+        }
+        else if (40 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level40;
+        }
+        else if (50 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level50;
+        }
+        else if (60 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level60;
+        }
+        else if (70 == LevelID)
+        {
+            aProfileLevel->eLevel = OMX_VIDEO_H263Level70;
+        }
+        else
+        {
+            //None of the supported parameter found
+            return OMX_ErrorBadParameter;
+        }
+    }
+
+    return OMX_ErrorNone;
+
+}
+
+
+OMX_ERRORTYPE Mpeg4Encoder_OMX::Mp4RequestIFrame()
+{
+    if (PV_TRUE != PVIFrameRequest(&iEncoderControl))
+    {
+        return OMX_ErrorUndefined;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+OMX_BOOL Mpeg4Encoder_OMX::Mp4UpdateBitRate(OMX_U32 aEncodedBitRate)
+{
+    Int	BitRate[2] = {0, 0};
+    OMX_BOOL Status = OMX_TRUE;
+
+    //Update the bit rate only if encoder has been initialized
+    if (OMX_TRUE == iInitialized)
+    {
+        BitRate[0] = aEncodedBitRate;
+
+        Status = (OMX_BOOL) PVUpdateBitRate(&iEncoderControl, BitRate);
+    }
+    return Status;
+}
+
+
+OMX_BOOL Mpeg4Encoder_OMX::Mp4UpdateFrameRate(OMX_U32 aEncodeFramerate)
+{
+    float EncFrameRate[2] = {0., 0.};
+    OMX_BOOL Status = OMX_TRUE;
+
+    //Update the frame rate only if encoder has been initialized
+    if (OMX_TRUE == iInitialized)
+    {
+        EncFrameRate[0] = (float)(aEncodeFramerate >> 16);
+        Status = (OMX_BOOL) PVUpdateEncFrameRate(&iEncoderControl, EncFrameRate);
+    }
+    return Status;
+
+}
+
+
+
+
+/*Encode routine */
+OMX_BOOL Mpeg4Encoder_OMX::Mp4EncodeVideo(OMX_U8*    aOutBuffer,
+        OMX_U32*   aOutputLength,
+        OMX_BOOL*  aBufferOverRun,
+        OMX_U8**   aOverBufferPointer,
+        OMX_U8*    aInBuffer,
+        OMX_U32    aInBufSize,
+        OMX_TICKS  aInTimeStamp,
+        OMX_TICKS* aOutTimeStamp,
+        OMX_BOOL*  aSyncFlag)
+{
+    *aSyncFlag = OMX_FALSE;
+
+    if (OMX_FALSE == iVolHeaderFlag)
+    {
+        iVolHeaderFlag = OMX_TRUE;
+        iNextModTime = aInTimeStamp;
+
+        //Send the first output buffer as vol header in case of m4v format
+        if ((DATA_PARTITIONING_MODE == ENC_Mode) ||
+                (COMBINE_MODE_WITH_ERR_RES == ENC_Mode) ||
+                (COMBINE_MODE_NO_ERR_RES == ENC_Mode) ||
+                (SHORT_HEADER == ENC_Mode) ||
+                (SHORT_HEADER_WITH_ERR_RES == ENC_Mode))
+        {
+            oscl_memcpy(aOutBuffer, iVolHeader, iVolHeaderSize);
+            *aOutputLength = iVolHeaderSize;
+            *aOutTimeStamp = aInTimeStamp;
+            return OMX_TRUE;
+        }
+    }
+
+
+    /* Input Buffer Size Check
+     * Input buffer size should be equal to one frame, otherwise drop the frame
+     * as it is a corrupt data and don't encode it */
+
+    if (OMX_COLOR_FormatYUV420Planar == iVideoFormat)
+    {
+        if (aInBufSize < (OMX_U32)((iSrcWidth * iSrcHeight * 3) >> 1))
+        {
+            *aOutputLength = 0;
+            return OMX_FALSE;
+        }
+    }
+    else if (OMX_COLOR_Format24bitRGB888 == iVideoFormat)
+    {
+        if (aInBufSize < (OMX_U32)(iSrcWidth * iSrcHeight * 3))
+        {
+            *aOutputLength = 0;
+            return OMX_FALSE;
+        }
+    }
+    else if	(OMX_COLOR_Format12bitRGB444 == iVideoFormat)
+    {
+        if (aInBufSize < (OMX_U32)(iSrcWidth * iSrcHeight * 2))
+        {
+            *aOutputLength = 0;
+            return OMX_FALSE;
+        }
+    }
+    else if (OMX_COLOR_FormatYUV420SemiPlanar == iVideoFormat)
+    {
+        if (aInBufSize < (OMX_U32)((iSrcWidth * iSrcHeight * 3) >> 1))
+        {
+            *aOutputLength = 0;
+            return OMX_FALSE;
+        }
+    }
+
+    //Now encode the input buffer
+    VideoEncFrameIO vid_in, vid_out;
+    Int Size;
+    Bool status;
+    ULong modTime;
+    Int nLayer = 0;
+    uint32 UpperTimeStamp = 0;
+
+
+
+    if (iSupport64bitTimestamp)
+    {
+        //Considering the difference in data types of aInTimeStamp and iNextModTime
+        OMX_U64 temp = 0x00000000FFFFFFFF;
+
+        UpperTimeStamp = (aInTimeStamp & (temp << 32)) >> 32;
+        if (UpperTimeStamp > 0)
+        {
+            //The data is more than 32 bits, save the upper 32 bits to be copied later in the output timestamp
+            aInTimeStamp = aInTimeStamp & 0x00000000FFFFFFFF;
+        }
+    }
+    // else, timestamp just remains what it is
+
+    // Time to encode if aInTimeStamp >= iNextModTime */
+    uint32 temp = (uint32)aInTimeStamp; /* for type-punned reference warning in the next line*/
+    if (OMX_TRUE == LessThan(iNextModTime, (uint32&)temp, PVMFTIMESTAMP_LESSTHAN_THRESHOLD))
+    {
+        Size = *aOutputLength;
+
+        if (iVideoFormat == OMX_COLOR_FormatYUV420Planar)
+        {
+            if (iYUVIn) /* iSrcWidth or iSrcHeight is not multiple of 16 */
+            {
+                CopyToYUVIn(aInBuffer, iSrcWidth, iSrcHeight,
+                            ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
+                iVideoIn = iYUVIn;
+            }
+            else /* otherwise, we can just use aVidIn->iSource */
+            {
+                iVideoIn = aInBuffer;
+            }
+        }
+
+        else if ((iVideoFormat == OMX_COLOR_Format12bitRGB444) || (iVideoFormat == OMX_COLOR_Format24bitRGB888) || (iVideoFormat == OMX_COLOR_FormatYUV420SemiPlanar))
+        {
+            ccRGBtoYUV->Convert((uint8*)aInBuffer, iYUVIn);
+            iVideoIn = iYUVIn;
+        }
+
+        /* with backward-P or B-Vop this timestamp must be re-ordered */
+        *aOutTimeStamp = aInTimeStamp;
+
+        vid_in.height = ((iSrcHeight + 15) >> 4) << 4;
+        vid_in.pitch = ((iSrcWidth + 15) >> 4) << 4;
+        vid_in.timestamp = aInTimeStamp;
+        vid_in.yChan = (UChar*)iVideoIn;
+        vid_in.uChan = (UChar*)(iVideoIn + vid_in.height * vid_in.pitch);
+        vid_in.vChan = vid_in.uChan + ((vid_in.height * vid_in.pitch) >> 2);
+
+        status = PVEncodeVideoFrame(&iEncoderControl, &vid_in, &vid_out,
+                                    &modTime, (UChar*)aOutBuffer,
+                                    &Size, &nLayer);
+
+
+        if (status == PV_TRUE)
+        {
+            iNextModTime = modTime;
+
+            if ((nLayer >= 0) && ((OMX_U32) Size > *aOutputLength))	// overrun buffer is used by the encoder
+            {
+                *aOverBufferPointer = PVGetOverrunBuffer(&iEncoderControl);
+                *aBufferOverRun = OMX_TRUE;
+            }
+
+            *aOutputLength = Size;
+
+            if (Size > 0)
+            {
+                *aOutTimeStamp = vid_out.timestamp;
+
+                if (iSupport64bitTimestamp)
+                {
+                    if (UpperTimeStamp > 0)
+                    {
+                        //Copy the upper 32 bits value back to the output timestamp
+                        OMX_S64 TempValue = UpperTimeStamp;
+                        TempValue = TempValue << 32;
+                        *aOutTimeStamp |= TempValue;
+                    }
+                }
+
+                PVGetHintTrack(&iEncoderControl, &iHintTrack);
+                if (0 == iHintTrack.CodeType)
+                {
+                    //Its an I Frame, mark the sync flag as true
+                    *aSyncFlag = OMX_TRUE;
+                }
+            }
+
+            return OMX_TRUE;
+        }
+        else
+        {
+            *aOutputLength = 0;
+            return OMX_FALSE;
+        }
+    }
+    else /* if(aInTimeStamp >= iNextModTime) */
+    {
+        *aOutputLength = 0;
+        return OMX_TRUE;
+    }
+}
+
+
+
+OMX_ERRORTYPE Mpeg4Encoder_OMX::Mp4EncDeinit()
+{
+    if (OMX_TRUE == iInitialized)
+    {
+        PVCleanUpVideoEncoder(&iEncoderControl);
+        iInitialized = OMX_FALSE;
+
+        if (iYUVIn)
+        {
+            oscl_free(iYUVIn);
+            iYUVIn = NULL;
+        }
+
+        if (ccRGBtoYUV)
+        {
+            OSCL_DELETE(ccRGBtoYUV);
+            ccRGBtoYUV = NULL;
+        }
+
+    }
+    return OMX_ErrorNone;
+}
+
+
+/* COLOUR CONVERSION ROUTINES ARE WRITTEN BELOW*/
+
+/* ///////////////////////////////////////////////////////////////////////// */
+/* Copy from YUV input to YUV frame inside M4VEnc lib						*/
+/* When input is not YUV, the color conv will write it directly to iVideoInOut. */
+/* ///////////////////////////////////////////////////////////////////////// */
+
+void Mpeg4Encoder_OMX::CopyToYUVIn(uint8 *YUV, Int width, Int height, Int width_16, Int height_16)
+{
+    UChar *y, *u, *v, *yChan, *uChan, *vChan;
+    Int y_ind, ilimit, jlimit, i, j, ioffset;
+    Int size = width * height;
+    Int size16 = width_16 * height_16;
+
+    /* do padding at the bottom first */
+    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
+    if (height < height_16 || width < width_16) /* if padding */
+    {
+        Int offset = (height < height_16) ? height : height_16;
+
+        offset = (offset * width_16);
+
+        if (width < width_16)
+        {
+            offset -= (width_16 - width);
+        }
+
+        yChan = (UChar*)(iYUVIn + offset);
+        oscl_memset(yChan, 16, size16 - offset); /* pad with zeros */
+
+        uChan = (UChar*)(iYUVIn + size16 + (offset >> 2));
+        oscl_memset(uChan, 128, (size16 - offset) >> 2);
+
+        vChan = (UChar*)(iYUVIn + size16 + (size16 >> 2) + (offset >> 2));
+        oscl_memset(vChan, 128, (size16 - offset) >> 2);
+    }
+
+    /* then do padding on the top */
+    yChan = (UChar*)iYUVIn; /* Normal order */
+    uChan = (UChar*)(iYUVIn + size16);
+    vChan = (UChar*)(uChan + (size16 >> 2));
+
+    u = (UChar*)(&(YUV[size]));
+    v = (UChar*)(&(YUV[size*5/4]));
+
+    /* To center the output */
+    if (height_16 > height)
+    {  /* output taller than input */
+        if (width_16 >= width)
+        { /* output wider than or equal input */
+            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+        }
+        else
+        { /* output narrower than input */
+            i = ((height_16 - height) >> 1) * width_16;
+            j = ((height_16 - height) >> 2) * (width_16 >> 1);
+            YUV += ((width - width_16) >> 1);
+            u += ((width - width_16) >> 2);
+            v += ((width - width_16) >> 2);
+        }
+        oscl_memset((uint8 *)yChan, 16, i);
+        yChan += i;
+        oscl_memset((uint8 *)uChan, 128, j);
+        uChan += j;
+        oscl_memset((uint8 *)vChan, 128, j);
+        vChan += j;
+    }
+    else
+    {  /* output shorter or equal input */
+        if (width_16 >= width)
+        {  /* output wider or equal input */
+            i = (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+            YUV += (((height - height_16) >> 1) * width);
+            u += (((height - height_16) >> 1) * width) >> 2;
+            v += (((height - height_16) >> 1) * width) >> 2;
+        }
+        else
+        { /* output narrower than input */
+            i = 0;
+            j = 0;
+            YUV += (((height - height_16) >> 1) * width + ((width - width_16) >> 1));
+            u += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 2;
+            v += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 2;
+        }
+        oscl_memset((uint8 *)yChan, 16, i);
+        yChan += i;
+        oscl_memset((uint8 *)uChan, 128, j);
+        uChan += j;
+        oscl_memset((uint8 *)vChan, 128, j);
+        vChan += j;
+    }
+
+    /* Copy with cropping or zero-padding */
+    if (height < height_16)
+        jlimit = height;
+    else
+        jlimit = height_16;
+
+    if (width < width_16)
+    {
+        ilimit = width;
+        ioffset = width_16 - width;
+    }
+    else
+    {
+        ilimit = width_16;
+        ioffset = 0;
+    }
+
+    /* Copy Y */
+    /* Set up pointer for fast looping */
+    y = (UChar*)YUV;
+
+    if (width == width_16 && height == height_16) /* no need to pad */
+    {
+        oscl_memcpy(yChan, y, size);
+    }
+    else
+    {
+        for (y_ind = 0; y_ind < (jlimit - 1) ;y_ind++)
+        {
+            oscl_memcpy(yChan, y, ilimit);
+            oscl_memset(yChan + ilimit, 16, ioffset); /* pad with zero */
+            yChan += width_16;
+            y += width;
+        }
+        oscl_memcpy(yChan, y, ilimit); /* last line no padding */
+    }
+    /* Copy U and V */
+    /* Set up pointers for fast looping */
+    if (width == width_16 && height == height_16) /* no need to pad */
+    {
+        oscl_memcpy(uChan, u, size >> 2);
+        oscl_memcpy(vChan, v, size >> 2);
+    }
+    else
+    {
+        for (y_ind = 0; y_ind < (jlimit >> 1) - 1;y_ind++)
+        {
+            oscl_memcpy(uChan, u, ilimit >> 1);
+            oscl_memcpy(vChan, v, ilimit >> 1);
+            oscl_memset(uChan + (ilimit >> 1), 128, ioffset >> 1);
+            oscl_memset(vChan + (ilimit >> 1), 128, ioffset >> 1);
+            uChan += (width_16 >> 1);
+            u += (width >> 1);
+            vChan += (width_16 >> 1);
+            v += (width >> 1);
+        }
+        oscl_memcpy(uChan, u, ilimit >> 1); /* last line no padding */
+        oscl_memcpy(vChan, v, ilimit >> 1);
+    }
+
+    return ;
+}
+
+
+/**
+ * Compares two timestamps and reports if the first occurred before (is less than)
+ * the second value.
+ * @param a first timestamp value in the comparison
+ * @param b second timestamp value in the comparison
+ * @return true if a < b, false otherwise.
+ *
+ */
+OMX_BOOL Mpeg4Encoder_OMX::LessThan(uint32& a, uint32& b,
+                                    uint32 Threshold = PVMFTIMESTAMP_LESSTHAN_THRESHOLD)
+{
+    uint32 c = b;
+    c -= a;
+
+    if (c < Threshold)
+    {
+        return OMX_TRUE;
+    }
+
+    return OMX_FALSE;
+}
diff --git a/codecs_v2/omx/omx_m4venc/src/omx_mpeg4enc_component.cpp b/codecs_v2/omx/omx_m4venc/src/omx_mpeg4enc_component.cpp
new file mode 100644
index 0000000..ef3775a
--- /dev/null
+++ b/codecs_v2/omx/omx_m4venc/src/omx_mpeg4enc_component.cpp
@@ -0,0 +1,1104 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "omx_mpeg4enc_component.h"
+
+#if PROXY_INTERFACE
+#include "omx_proxy_interface.h"
+#endif
+
+
+
+// This function is called by OMX_GetHandle and it creates an instance of the mpeg4 component AO
+OMX_ERRORTYPE Mpeg4EncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+
+    OmxComponentMpeg4EncAO* pOpenmaxAOType;
+    OMX_ERRORTYPE Status;
+
+    // move InitMpeg4OmxComponentFields content to actual constructor
+
+    pOpenmaxAOType = (OmxComponentMpeg4EncAO*) OSCL_NEW(OmxComponentMpeg4EncAO, ());
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    // set encoding mode to H263
+    pOpenmaxAOType->SetEncoderMode(MODE_MPEG4);
+
+    //Call the construct component to initialize OMX types
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
+
+    *pHandle = pOpenmaxAOType->GetOmxHandle();
+
+    return Status;
+}
+
+
+// This function is called by OMX_FreeHandle when component AO needs to be destroyed
+OMX_ERRORTYPE Mpeg4EncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    // get pointer to component AO
+    OmxComponentMpeg4EncAO* pOpenmaxAOType = (OmxComponentMpeg4EncAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
+
+    // clean up decoder, OMX component stuff
+    pOpenmaxAOType->DestroyComponent();
+
+    // destroy the AO class
+    OSCL_DELETE(pOpenmaxAOType);
+
+    return OMX_ErrorNone;
+}
+
+
+// This function is called by OMX_GetHandle and it creates an instance of the h263 component AO
+OMX_ERRORTYPE H263EncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+
+    OmxComponentMpeg4EncAO* pOpenmaxAOType;
+    OMX_ERRORTYPE Status;
+
+    // move InitMpeg4OmxComponentFields content to actual constructor
+
+    pOpenmaxAOType = (OmxComponentMpeg4EncAO*) OSCL_NEW(OmxComponentMpeg4EncAO, ());
+
+    if (NULL == pOpenmaxAOType)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    // set encoding mode to H263
+    pOpenmaxAOType->SetEncoderMode(MODE_H263);
+
+    //Call the construct component to initialize OMX types
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
+
+    *pHandle = pOpenmaxAOType->GetOmxHandle();
+
+    return Status;
+    ///////////////////////////////////////////////////////////////////////////////////////
+}
+
+
+// This function is called by OMX_FreeHandle when component AO needs to be destroyed
+OMX_ERRORTYPE H263EncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
+{
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
+    // get pointer to component AO
+    OmxComponentMpeg4EncAO* pOpenmaxAOType = (OmxComponentMpeg4EncAO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
+
+    // clean up decoder, OMX component stuff
+    pOpenmaxAOType->DestroyComponent();
+
+    // destroy the AO class
+    OSCL_DELETE(pOpenmaxAOType);
+
+    return OMX_ErrorNone;
+}
+
+#if (DYNAMIC_LOAD_OMX_M4VENC_COMPONENT || DYNAMIC_LOAD_OMX_H263ENC_COMPONENT)
+class Mpeg4H263EncOmxSharedLibraryInterface:  public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+
+{
+    public:
+        static Mpeg4H263EncOmxSharedLibraryInterface *Instance()
+        {
+            static Mpeg4H263EncOmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
+
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_M4VENC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&Mpeg4EncOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&Mpeg4EncOmxComponentDestructor));
+                }
+            }
+            else if (PV_OMX_H263ENC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&H263EncOmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&H263EncOmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        Mpeg4H263EncOmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return Mpeg4H263EncOmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
+
+void OmxComponentMpeg4EncAO::SetEncoderMode(OMX_S32 aMode)
+{
+    iEncMode = aMode;
+}
+
+
+
+OMX_ERRORTYPE OmxComponentMpeg4EncAO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
+{
+    ComponentPortType *pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
+
+    iNumPorts = 2;
+    iCompressedFormatPortNum = OMX_PORT_OUTPUTPORT_INDEX;
+    iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
+    iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
+    ipComponentProxy = pProxy;
+    iOmxComponent.pApplicationPrivate = pAppData; // init the App data
+
+
+#if PROXY_INTERFACE
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
+
+    iOmxComponent.SendCommand = OmxComponentMpeg4EncAO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OmxComponentMpeg4EncAO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OmxComponentMpeg4EncAO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OmxComponentMpeg4EncAO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OmxComponentMpeg4EncAO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentMpeg4EncAO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentMpeg4EncAO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OmxComponentMpeg4EncAO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentMpeg4EncAO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentMpeg4EncAO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentMpeg4EncAO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentMpeg4EncAO::BaseComponentProxyFillThisBuffer;
+
+#else
+    iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
+
+    iOmxComponent.SendCommand = OmxComponentMpeg4EncAO::BaseComponentSendCommand;
+    iOmxComponent.GetParameter = OmxComponentMpeg4EncAO::BaseComponentGetParameter;
+    iOmxComponent.SetParameter = OmxComponentMpeg4EncAO::BaseComponentSetParameter;
+    iOmxComponent.GetConfig = OmxComponentMpeg4EncAO::BaseComponentGetConfig;
+    iOmxComponent.SetConfig = OmxComponentMpeg4EncAO::BaseComponentSetConfig;
+    iOmxComponent.GetExtensionIndex = OmxComponentMpeg4EncAO::BaseComponentGetExtensionIndex;
+    iOmxComponent.GetState = OmxComponentMpeg4EncAO::BaseComponentGetState;
+    iOmxComponent.UseBuffer = OmxComponentMpeg4EncAO::BaseComponentUseBuffer;
+    iOmxComponent.AllocateBuffer = OmxComponentMpeg4EncAO::BaseComponentAllocateBuffer;
+    iOmxComponent.FreeBuffer = OmxComponentMpeg4EncAO::BaseComponentFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OmxComponentMpeg4EncAO::BaseComponentEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OmxComponentMpeg4EncAO::BaseComponentFillThisBuffer;
+#endif
+
+    iOmxComponent.SetCallbacks = OmxComponentMpeg4EncAO::BaseComponentSetCallbacks;
+    iOmxComponent.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
+    iOmxComponent.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
+    iOmxComponent.nVersion.s.nRevision = SPECREVISION;
+    iOmxComponent.nVersion.s.nStep = SPECSTEP;
+
+    // PV capability
+    iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
+
+    if (ipAppPriv)
+    {
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
+    if (NULL == ipAppPriv)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
+    {
+        return Status;
+    }
+
+    /** Domain specific section for input raw port */ //OMX_PARAM_PORTDEFINITIONTYPE
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainVideo;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"raw";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.pNativeRender = 0;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.bFlagErrorConcealment = OMX_FALSE;
+
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.nFrameWidth = 176;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.nFrameHeight = 144;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.nBitrate = 64000;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video.xFramerate = (15 << 16);
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDir = OMX_DirInput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_INPUT_BUFFER_MP4ENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize = INPUT_BUFFER_SIZE_MP4ENC;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+
+    /** Domain specific section for output mpeg4/h263 port */
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainVideo;
+    if (MODE_MPEG4 == iEncMode)
+    {
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"video/mpeg4";
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+
+    }
+    else if (MODE_H263 == iEncMode)
+    {
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.cMIMEType = (OMX_STRING)"video/h263";
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+    }
+
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.pNativeRender = 0;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.bFlagErrorConcealment = OMX_FALSE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameWidth = 176;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nFrameHeight = 144;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.nBitrate = 64000;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video.xFramerate = (15 << 16);
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDir = OMX_DirOutput;
+    //Set to a default value, will change later during setparameter call
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountActual = NUMBER_OUTPUT_BUFFER_MP4ENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferCountMin = 1;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.nBufferSize = OUTPUT_BUFFER_SIZE_MP4ENC;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bEnabled = OMX_TRUE;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.bPopulated = OMX_FALSE;
+
+
+    //OMX_VIDEO_PARAM_MPEG4TYPE
+    //Default values for mpeg4 video output param port
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.eProfile = OMX_VIDEO_MPEG4ProfileCore;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.eLevel = OMX_VIDEO_MPEG4Level2;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.nPFrames = 10;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.nBFrames = 0;		//No support for B frames
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.nMaxPacketSize = 256;	//Default value
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4.bGov = OMX_FALSE;
+
+    //This will be an additional structure maintained on output port if the encoder is H.263
+    if (MODE_H263 == iEncMode)
+    {
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.eProfile = OMX_VIDEO_H263ProfileBaseline;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.eLevel = OMX_VIDEO_H263Level45;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.bPLUSPTYPEAllowed = OMX_FALSE;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.bForceRoundingTypeToZero = OMX_TRUE;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.nPictureHeaderRepetition = 0;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263.nGOBHeaderInterval = 0;
+    }
+
+
+    if (MODE_MPEG4 == iEncMode)
+    {
+        //OMX_VIDEO_PARAM_PROFILELEVELTYPE structure
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel.nProfileIndex = 0;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel.eProfile = OMX_VIDEO_MPEG4ProfileCore;
+        ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel.eLevel = OMX_VIDEO_MPEG4Level2;
+    }
+    else if (MODE_H263 == iEncMode)
+    {
+        ipPorts[OMX_PORT_INPUTPORT_INDEX]->ProfileLevel.nProfileIndex = 0;
+        ipPorts[OMX_PORT_INPUTPORT_INDEX]->ProfileLevel.eProfile = OMX_VIDEO_H263ProfileBaseline;
+        ipPorts[OMX_PORT_INPUTPORT_INDEX]->ProfileLevel.eLevel = OMX_VIDEO_H263Level45;
+    }
+
+
+    iPortTypesParam.nPorts = 2;
+    iPortTypesParam.nStartPortNumber = 0;
+
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+
+    pInPort->ActualNumPortFormatsSupported = 4;
+
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE INPUT PORT SETTINGS
+    //On input port for index 0
+    SetHeader(&pInPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[0].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[0].nIndex = 0;
+    pInPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    pInPort->VideoParam[0].xFramerate = (15 << 16);
+
+    //On input port for index 1
+    SetHeader(&pInPort->VideoParam[1], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[1].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[1].nIndex = 1;
+    pInPort->VideoParam[1].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[1].eColorFormat = OMX_COLOR_Format24bitRGB888;
+    pInPort->VideoParam[1].xFramerate = (15 << 16);
+
+    //On input port for index 2
+    SetHeader(&pInPort->VideoParam[2], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[2].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[2].nIndex = 2;
+    pInPort->VideoParam[2].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[2].eColorFormat = OMX_COLOR_Format12bitRGB444;
+    pInPort->VideoParam[2].xFramerate = (15 << 16);
+
+    //On input port for index 3
+    SetHeader(&pInPort->VideoParam[3], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pInPort->VideoParam[3].nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoParam[3].nIndex = 3;
+    pInPort->VideoParam[3].eCompressionFormat = OMX_VIDEO_CodingUnused;
+    pInPort->VideoParam[3].eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+    pInPort->VideoParam[3].xFramerate = (15 << 16);
+
+
+    pOutPort->ActualNumPortFormatsSupported = 1;
+
+    //OMX_VIDEO_PARAM_PORTFORMATTYPE OUTPUT PORT SETTINGS
+    //On output port for index 0
+    SetHeader(&pOutPort->VideoParam[0], sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE));
+    pOutPort->VideoParam[0].nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoParam[0].nIndex = 0;
+    pOutPort->VideoParam[0].eColorFormat = OMX_COLOR_FormatUnused;
+    pOutPort->VideoParam[0].xFramerate = (15 << 16);
+    if (iEncMode == MODE_MPEG4)
+    {
+        pOutPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+
+    }
+    else if (iEncMode == MODE_H263)
+    {
+        pOutPort->VideoParam[0].eCompressionFormat = OMX_VIDEO_CodingH263;
+    }
+
+
+    //OMX_CONFIG_ROTATIONTYPE SETTINGS ON INPUT PORT
+    SetHeader(&pInPort->VideoOrientationType, sizeof(OMX_CONFIG_ROTATIONTYPE));
+    pInPort->VideoOrientationType.nPortIndex = OMX_PORT_INPUTPORT_INDEX;
+    pInPort->VideoOrientationType.nRotation = -1;  //For all the YUV formats that are other than RGB
+
+
+    //OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE settings of output port
+    oscl_memset(&pOutPort->VideoErrorCorrection, 0, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+    SetHeader(&pOutPort->VideoErrorCorrection, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
+    pOutPort->VideoErrorCorrection.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoErrorCorrection.bEnableDataPartitioning = OMX_FALSE;	//As in node default is h263
+
+
+    //OMX_VIDEO_PARAM_BITRATETYPE settings of output port
+    SetHeader(&pOutPort->VideoRateType, sizeof(OMX_VIDEO_PARAM_BITRATETYPE));
+    pOutPort->VideoRateType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoRateType.eControlRate = OMX_Video_ControlRateConstant;
+    pOutPort->VideoRateType.nTargetBitrate = 64000;
+
+
+    //OMX_CONFIG_FRAMERATETYPE default seetings (specified in khronos conformance test)
+    SetHeader(&pOutPort->VideoConfigFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE));
+    pOutPort->VideoConfigFrameRateType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoConfigFrameRateType.xEncodeFramerate = (15 << 16);
+
+    //OMX_VIDEO_CONFIG_BITRATETYPE default settings (specified in khronos conformance test)
+    SetHeader(&pOutPort->VideoConfigBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE));
+    pOutPort->VideoConfigBitRateType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoConfigBitRateType.nEncodeBitrate = 64000;
+
+
+    //OMX_VIDEO_PARAM_QUANTIZATIONTYPE settings of output port
+    SetHeader(&pOutPort->VideoQuantType, sizeof(OMX_VIDEO_PARAM_QUANTIZATIONTYPE));
+    pOutPort->VideoQuantType.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoQuantType.nQpI = 15;
+    pOutPort->VideoQuantType.nQpP = 12;
+    pOutPort->VideoQuantType.nQpB = 12;
+
+
+    //OMX_VIDEO_PARAM_VBSMCTYPE settings of output port
+    oscl_memset(&pOutPort->VideoBlockMotionSize, 0, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+    SetHeader(&pOutPort->VideoBlockMotionSize, sizeof(OMX_VIDEO_PARAM_VBSMCTYPE));
+    pOutPort->VideoBlockMotionSize.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoBlockMotionSize.b16x16 = OMX_TRUE;
+
+
+    //OMX_VIDEO_PARAM_MOTIONVECTORTYPE settings of output port
+    oscl_memset(&pOutPort->VideoMotionVector, 0, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+    SetHeader(&pOutPort->VideoMotionVector, sizeof(OMX_VIDEO_PARAM_MOTIONVECTORTYPE));
+    pOutPort->VideoMotionVector.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoMotionVector.eAccuracy = OMX_Video_MotionVectorHalfPel;
+    pOutPort->VideoMotionVector.bUnrestrictedMVs = OMX_TRUE;
+    pOutPort->VideoMotionVector.sXSearchRange = 16;
+    pOutPort->VideoMotionVector.sYSearchRange = 16;
+
+
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE settings of output port
+    oscl_memset(&pOutPort->VideoIntraRefresh, 0, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+    SetHeader(&pOutPort->VideoIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE));
+    pOutPort->VideoIntraRefresh.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoIntraRefresh.eRefreshMode = OMX_VIDEO_IntraRefreshCyclic;
+    pOutPort->VideoIntraRefresh.nCirMBs = 0;
+
+
+    //OMX_CONFIG_INTRAREFRESHVOPTYPE settings of output port
+    oscl_memset(&pOutPort->VideoIFrame, 0, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+    SetHeader(&pOutPort->VideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+    pOutPort->VideoIFrame.nPortIndex = OMX_PORT_OUTPUTPORT_INDEX;
+    pOutPort->VideoIFrame.IntraRefreshVOP = OMX_FALSE;
+
+
+    //Construct the encoder object
+    if (ipMpegEncoderObject)
+    {
+        OSCL_DELETE(ipMpegEncoderObject);
+        ipMpegEncoderObject = NULL;
+    }
+
+    ipMpegEncoderObject = OSCL_NEW(Mpeg4Encoder_OMX, ());
+
+#if PROXY_INTERFACE
+
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+
+#endif
+
+    return OMX_ErrorNone;
+}
+
+
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	*/
+
+OMX_ERRORTYPE OmxComponentMpeg4EncAO::DestroyComponent()
+{
+    if (OMX_FALSE != iIsInit)
+    {
+        ComponentDeInit();
+    }
+
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipMpegEncoderObject)
+    {
+        OSCL_DELETE(ipMpegEncoderObject);
+        ipMpegEncoderObject = NULL;
+    }
+
+    if (ipAppPriv)
+    {
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+void OmxComponentMpeg4EncAO::ProcessData()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData IN"));
+
+    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    ComponentPortType*	pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+
+    OMX_U8*					pOutBuffer;
+    OMX_U32					OutputLength;
+    OMX_BOOL				EncodeReturn = OMX_FALSE;
+    OMX_COMPONENTTYPE*		pHandle = &iOmxComponent;
+
+    if ((!iIsInputBufferEnded) || (iEndofStream))
+    {
+        //Check whether prev output bufer has been released or not
+        if (OMX_TRUE == iNewOutBufRequired)
+        {
+            //Check whether a new output buffer is available or not
+            if (0 == (GetQueueNumElem(pOutputQueue)))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData OUT output buffer unavailable"));
+                return;
+            }
+
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer->nFilledLen = 0;
+            iNewOutBufRequired = OMX_FALSE;
+
+
+            /* If some output data was left to be send from the last processing due to
+             * unavailability of required number of output buffers,
+             * copy it now and send back before processing new input frame */
+            if (iInternalOutBufFilledLen > 0)
+            {
+                if (OMX_FALSE == CopyDataToOutputBuffer())
+                {
+                    //We fell short of output buffers, exit now and wait for some more buffers to get queued
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData OUT output buffer unavailable"));
+                    return;
+                }
+                else
+                {
+                    //Attach the end of frame flag while sending out the last piece of output buffer
+                    ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+                    if (OMX_TRUE == iSyncFlag)
+                    {
+                        ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+                        iSyncFlag = OMX_FALSE;
+                    }
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+
+                    //Dequeue new output buffer to continue encoding the next frame
+                    if (0 == (GetQueueNumElem(pOutputQueue)))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData OUT output buffer unavailable"));
+                        return;
+                    }
+
+                    ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+                    ipOutputBuffer->nFilledLen = 0;
+                    iNewOutBufRequired = OMX_FALSE;
+                }
+            }
+        }
+
+        /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
+         * command and hMarkTargetComponent as given by the specifications
+         */
+        if (ipMark != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
+            ipMark = NULL;
+        }
+
+        if (ipTargetComponent != NULL)
+        {
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
+            ipTargetComponent = NULL;
+
+        }
+        //Mark buffer code ends here
+
+        //Call the encoder only if there is some data to encode
+        if (iInputCurrLength > 0)
+        {
+            pOutBuffer = ipOutputBuffer->pBuffer;
+            OutputLength = ipOutputBuffer->nAllocLen;
+
+            //Output buffer is passed as a short pointer
+            EncodeReturn = ipMpegEncoderObject->Mp4EncodeVideo(pOutBuffer,
+                           &OutputLength,
+                           &iBufferOverRun,
+                           &ipInternalOutBuffer,
+                           ipFrameDecodeBuffer,
+                           iInputCurrLength,
+                           iFrameTimestamp,
+                           &iOutputTimeStamp,
+                           &iSyncFlag);
+
+
+            //Chk whether output data has been generated or not
+            if (OutputLength > 0)
+            {
+                //offset not required in our case, set it to zero
+                ipOutputBuffer->nOffset = 0;
+                ipOutputBuffer->nTimeStamp = iOutputTimeStamp;
+
+                if (OMX_FALSE == iBufferOverRun)
+                {
+                    //No internal buffer is maintained
+                    ipOutputBuffer->nFilledLen = OutputLength;
+                }
+                else
+                {
+                    iInternalOutBufFilledLen = OutputLength;
+                    iBufferOverRun = OMX_FALSE;
+                    CopyDataToOutputBuffer();
+
+                }	//else loop of if (OMX_FALSE == iMantainOutInternalBuffer)
+            }	//if (OutputLength > 0)	 loop
+
+
+            //If encoder returned error in case of frame skip/corrupt frame, report it to the client via a callback
+            if ((OMX_FALSE == EncodeReturn) && (OMX_FALSE == iEndofStream))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : Frame skipped, ProcessData ErrorStreamCorrupt callback send"));
+
+                (*(ipCallbacks->EventHandler))
+                (pHandle,
+                 iCallbackData,
+                 OMX_EventError,
+                 OMX_ErrorStreamCorrupt,
+                 0,
+                 NULL);
+            }
+
+
+            //For the first time, encoder returns the volheader in output buffer and input remains unconsumed
+            //so do not return the input buffer yet
+            if (0 != iFrameCount)
+            {
+                //Input bytes consumed now, return the buffer
+                ipInputBuffer->nFilledLen = 0;
+                ReturnInputBuffer(ipInputBuffer, pInPort);
+                ipInputBuffer = NULL;
+
+                iIsInputBufferEnded = OMX_TRUE;
+                iInputCurrLength = 0;
+            }
+
+            iFrameCount++;
+        }
+
+
+        /* If EOS flag has come from the client & there are no more
+         * input buffers to decode, send the callback to the client
+         */
+        if (OMX_TRUE == iEndofStream)
+        {
+            if (((0 == iInputCurrLength) || (OMX_FALSE == EncodeReturn)) &&
+                    (0 == iInternalOutBufFilledLen))
+            {
+
+                (*(ipCallbacks->EventHandler))
+                (pHandle,
+                 iCallbackData,
+                 OMX_EventBufferFlag,
+                 1,
+                 OMX_BUFFERFLAG_EOS,
+                 NULL);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData EOS callback sent"));
+
+
+                //Mark this flag false once the callback has been send back
+                iEndofStream = OMX_FALSE;
+
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                if (OMX_TRUE == iSyncFlag)
+                {
+                    ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+                    iSyncFlag = OMX_FALSE;
+                }
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData OUT"));
+                return;
+            }
+
+        }
+
+        //Send the output buffer back after decode
+        if ((ipOutputBuffer->nFilledLen > 0) && (OMX_FALSE == iNewOutBufRequired))
+        {
+            //Attach the end of frame flag while sending out the last piece of output buffer
+            ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+            if (OMX_TRUE == iSyncFlag)
+            {
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+                iSyncFlag = OMX_FALSE;
+            }
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+        }
+
+
+        /* If there is some more processing left with current buffers, re-schedule the AO
+         * Do not go for more than one round of processing at a time.
+         * This may block the AO longer than required.
+         */
+        if ((iInputCurrLength != 0 || GetQueueNumElem(pInputQueue) > 0)
+                && (GetQueueNumElem(pOutputQueue) > 0))
+        {
+            RunIfNotReady();
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ProcessData OUT"));
+}
+
+
+OMX_BOOL OmxComponentMpeg4EncAO::CopyDataToOutputBuffer()
+{
+    ComponentPortType*	pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
+
+    while (iInternalOutBufFilledLen > 0)
+    {
+        if (ipOutputBuffer->nAllocLen >= iInternalOutBufFilledLen)
+        {
+            //Pack the whole  data into the output buffer Alloc length data in one buffer and return it
+            oscl_memcpy(ipOutputBuffer->pBuffer, ipInternalOutBuffer, iInternalOutBufFilledLen);
+            ipOutputBuffer->nFilledLen = iInternalOutBufFilledLen;
+
+        }
+        else
+        {
+            oscl_memcpy(ipOutputBuffer->pBuffer, ipInternalOutBuffer, ipOutputBuffer->nAllocLen);
+            ipOutputBuffer->nFilledLen = ipOutputBuffer->nAllocLen;
+        }
+
+        iInternalOutBufFilledLen -= ipOutputBuffer->nFilledLen;
+        ipInternalOutBuffer += ipOutputBuffer->nFilledLen;
+
+
+        if (0 != iInternalOutBufFilledLen)
+        {
+            //Mark sync flag in each piece of partial output buffer
+            if (OMX_TRUE == iSyncFlag)
+            {
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+            }
+            //Return the partial output buffer and try to fetch a new output buffer for filling the remaining data
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+
+            //Check whether a new output buffer is available or not
+            if (0 == (GetQueueNumElem(pOutputQueue)))
+            {
+                return OMX_FALSE;
+            }
+
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            ipOutputBuffer->nFilledLen = 0;
+            ipOutputBuffer->nTimeStamp = iOutputTimeStamp;
+            ipOutputBuffer->nOffset = 0;
+            iNewOutBufRequired = OMX_FALSE;
+        }
+    }	//while (iInternalOutBufFilledLen > 0)
+
+    return OMX_TRUE;
+
+}
+
+
+//Not implemented & supported in case of base profile components
+
+void OmxComponentMpeg4EncAO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
+{
+    *aRoleString = (OMX_STRING)"video_encoder.mpeg4";
+}
+
+
+//Component constructor
+OmxComponentMpeg4EncAO::OmxComponentMpeg4EncAO()
+{
+    ipMpegEncoderObject = NULL;
+    iEncMode = MODE_H263;
+    //iMantainOutInternalBuffer = OMX_FALSE;
+    ipInternalOutBuffer = NULL;
+    iInternalOutBufFilledLen = 0;
+    iSyncFlag = OMX_FALSE;
+    iBufferOverRun = OMX_FALSE;
+
+    if (!IsAdded())
+    {
+        AddToScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : constructed"));
+}
+
+
+//Active object destructor
+OmxComponentMpeg4EncAO::~OmxComponentMpeg4EncAO()
+{
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : destructed"));
+}
+
+
+OMX_ERRORTYPE OmxComponentMpeg4EncAO::SetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_IN  OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig IN"));
+
+    OMX_U32 PortIndex;
+
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    OMX_CONFIG_INTRAREFRESHVOPTYPE* pVideoIFrame;
+    OMX_VIDEO_CONFIG_BITRATETYPE* pBitRateType;
+    OMX_CONFIG_FRAMERATETYPE* pFrameRateType;
+
+
+
+    if (NULL == pComponentConfigStructure)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error bad parameter"));
+        return OMX_ErrorBadParameter;
+    }
+
+    switch (nIndex)
+    {
+        case OMX_IndexConfigVideoIntraVOPRefresh:
+        {
+            pVideoIFrame = (OMX_CONFIG_INTRAREFRESHVOPTYPE*) pComponentConfigStructure;
+            PortIndex = pVideoIFrame->nPortIndex;
+
+            if (PortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error invalid port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            /*Check Structure Header*/
+            ErrorType = CheckHeader(pVideoIFrame, sizeof(OMX_CONFIG_INTRAREFRESHVOPTYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error param check failed"));
+                return ErrorType;
+            }
+
+            //Call the RequestI frame routine of the encoder in case of setconfig call
+            if (OMX_TRUE == pVideoIFrame->IntraRefreshVOP)
+            {
+                ipMpegEncoderObject->Mp4RequestIFrame();
+
+            }
+        }
+        break;
+
+        case OMX_IndexConfigVideoBitrate:
+        {
+            pBitRateType = (OMX_VIDEO_CONFIG_BITRATETYPE*) pComponentConfigStructure;
+            PortIndex = pBitRateType->nPortIndex;
+
+            if (PortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error invalid port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            /*Check Structure Header*/
+            ErrorType = CheckHeader(pBitRateType, sizeof(OMX_VIDEO_CONFIG_BITRATETYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error param check failed"));
+                return ErrorType;
+            }
+
+            //Call the corresponding routine of the encoder in case of setconfig call
+            if (OMX_FALSE == (ipMpegEncoderObject->Mp4UpdateBitRate(pBitRateType->nEncodeBitrate)))
+            {
+                return OMX_ErrorUnsupportedSetting;
+            }
+            ipPorts[PortIndex]->VideoConfigBitRateType.nEncodeBitrate = pBitRateType->nEncodeBitrate;
+        }
+        break;
+
+        case OMX_IndexConfigVideoFramerate:
+        {
+            pFrameRateType = (OMX_CONFIG_FRAMERATETYPE*) pComponentConfigStructure;
+            PortIndex = pFrameRateType->nPortIndex;
+
+            if (PortIndex != iCompressedFormatPortNum)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error invalid port index"));
+                return OMX_ErrorBadPortIndex;
+            }
+
+            /*Check Structure Header*/
+            ErrorType = CheckHeader(pFrameRateType, sizeof(OMX_CONFIG_FRAMERATETYPE));
+            if (ErrorType != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error param check failed"));
+                return ErrorType;
+            }
+
+            //Call the corresponding routine of the encoder in case of setconfig call
+            if (OMX_FALSE == (ipMpegEncoderObject->Mp4UpdateFrameRate(pFrameRateType->xEncodeFramerate)))
+            {
+                return OMX_ErrorUnsupportedSetting;
+            }
+
+            ipPorts[PortIndex]->VideoConfigFrameRateType.xEncodeFramerate = pFrameRateType->xEncodeFramerate;
+        }
+        break;
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig error Unsupported Index"));
+            return OMX_ErrorUnsupportedIndex;
+        }
+        break;
+
+    }
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : SetConfig OUT"));
+
+    return OMX_ErrorNone;
+
+}
+
+
+
+/** The Initialization function
+ */
+OMX_ERRORTYPE OmxComponentMpeg4EncAO::ComponentInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ComponentInit IN"));
+
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+
+    if (OMX_TRUE == iIsInit)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ComponentInit error incorrect operation"));
+        return OMX_ErrorIncorrectStateOperation;
+    }
+    iIsInit = OMX_TRUE;
+
+
+    if (!iCodecReady)
+    {
+        iCodecReady = OMX_TRUE;
+    }
+
+    //Check the H.263 parameters before initializing the encoder if there was any change in the SetParameter call
+    if (MODE_H263 == iEncMode)
+    {
+        OMX_VIDEO_PARAM_H263TYPE* H263Param = (OMX_VIDEO_PARAM_H263TYPE*) & ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263;
+
+        if ((OMX_VIDEO_H263ProfileBaseline != H263Param->eProfile) ||
+                (H263Param->eLevel > OMX_VIDEO_H263Level45) ||
+                (OMX_TRUE == H263Param->bPLUSPTYPEAllowed) ||
+                (0 == (H263Param->nAllowedPictureTypes & (OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP))) ||
+                (0 != H263Param->nPictureHeaderRepetition))
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ComponentInit Error, unsupported H.263 settings, OUT"));
+            return OMX_ErrorUnsupportedSetting;
+        }
+    }
+
+
+    //Library init routine
+    Status = ipMpegEncoderObject->Mp4EncInit(iEncMode,
+             ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.video,
+             ipPorts[OMX_PORT_INPUTPORT_INDEX]->VideoOrientationType,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.video,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMpeg4,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoErrorCorrection,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoRateType,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoQuantType,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoMotionVector,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoIntraRefresh,
+             ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->VideoH263,
+             &(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->ProfileLevel));
+
+    iInputCurrLength = 0;
+
+    //Used in dynamic port reconfiguration
+    iFrameCount = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ComponentInit OUT"));
+
+    return Status;
+
+}
+
+/** This function is called upon a transition to the idle or invalid state.
+ *  Also it is called by the ComponentDestructor() function
+ */
+OMX_ERRORTYPE OmxComponentMpeg4EncAO::ComponentDeInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ComponentDeInit IN"));
+
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+
+    iIsInit = OMX_FALSE;
+
+    if (iCodecReady)
+    {
+        Status = ipMpegEncoderObject->Mp4EncDeinit();
+        iCodecReady = OMX_FALSE;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OmxComponentMpeg4EncAO : ComponentDeInit OUT"));
+
+    return Status;
+
+}
+
+/* A component specific routine called from BufferMgmtWithoutMarker */
+void OmxComponentMpeg4EncAO::ProcessInBufferFlag()
+{
+    iIsInputBufferEnded = OMX_FALSE;
+}
diff --git a/codecs_v2/omx/omx_mastercore/Android.mk b/codecs_v2/omx/omx_mastercore/Android.mk
new file mode 100644
index 0000000..e1087af
--- /dev/null
+++ b/codecs_v2/omx/omx_mastercore/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pv_omxmastercore.cpp
+
+
+LOCAL_MODULE := libomx_mastercore_lib
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_mastercore/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_mastercore/include \
+ 	$(PV_TOP)/codecs_v2/omx/omx_common/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	include/omx_interface.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/omx/omx_mastercore/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_mastercore/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..0649e6e
--- /dev/null
+++ b/codecs_v2/omx/omx_mastercore/build/make_multithreaded/local.mk
@@ -0,0 +1,29 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_mastercore_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+         ../../../omx_common/include \
+	 ../../../../../extern_libs_v2/khronos/openmax/include 
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR    := ../../src
+INCSRCDIR := ../../include
+
+SRCS := 	\
+	pv_omxmastercore.cpp
+
+HDRS :=	omx_interface.h 
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_mastercore/include/omx_interface.h b/codecs_v2/omx/omx_mastercore/include/omx_interface.h
new file mode 100644
index 0000000..45da195
--- /dev/null
+++ b/codecs_v2/omx/omx_mastercore/include/omx_interface.h
@@ -0,0 +1,194 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef OMX_INTERFACE_H_INCLUDED
+#define OMX_INTERFACE_H_INCLUDED
+
+
+
+// get definitions of omx core methods
+#ifndef OMX_Core_h
+#include "omx_core.h"
+#endif
+
+#ifndef OSCL_SHARED_LIB_INTERFACE_H_INCLUDED
+#include "oscl_shared_lib_interface.h"
+#endif
+
+
+// ID used to identify OMX shared library interface
+#define OMX_INTERFACE_ID OsclUuid(0xa054369c,0x22c5,0x412e,0x19,0x17,0x87,0x4c,0x1a,0x19,0xd4,0x5f)
+
+
+// ptrs to all omx core methods
+// will be set in the derived classes
+typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_Init)(void);
+
+typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_Deinit)(void);
+
+typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_ComponentNameEnum)(
+    OMX_OUT OMX_STRING cComponentName,
+    OMX_IN  OMX_U32 nNameLength,
+    OMX_IN  OMX_U32 nIndex);
+
+
+typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_GetHandle)(
+    OMX_OUT OMX_HANDLETYPE* pHandle,
+    OMX_IN  OMX_STRING cComponentName,
+    OMX_IN  OMX_PTR pAppData,
+    OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
+
+
+typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_FreeHandle)(
+    OMX_IN  OMX_HANDLETYPE hComponent);
+
+typedef OMX_ERRORTYPE(*tpOMX_GetComponentsOfRole)(
+    OMX_IN      OMX_STRING role,
+    OMX_INOUT   OMX_U32 *pNumComps,
+    OMX_INOUT   OMX_U8  **compNames);
+
+
+typedef OMX_ERRORTYPE(*tpOMX_GetRolesOfComponent)(
+    OMX_IN      OMX_STRING compName,
+    OMX_INOUT   OMX_U32 *pNumRoles,
+    OMX_OUT     OMX_U8 **roles);
+
+
+typedef OMX_ERRORTYPE OMX_APIENTRY(*tpOMX_SetupTunnel)(
+    OMX_IN  OMX_HANDLETYPE hOutput,
+    OMX_IN  OMX_U32 nPortOutput,
+    OMX_IN  OMX_HANDLETYPE hInput,
+    OMX_IN  OMX_U32 nPortInput);
+
+
+typedef OMX_ERRORTYPE(*tpOMX_GetContentPipe)(
+    OMX_OUT OMX_HANDLETYPE *hPipe,
+    OMX_IN OMX_STRING szURI);
+
+
+class OMXInterface : public OsclSharedLibraryInterface
+{
+    public:
+        OMXInterface()
+        {
+            pOMX_Init = NULL;
+            pOMX_Deinit = NULL;
+            pOMX_ComponentNameEnum = NULL;
+            pOMX_GetHandle = NULL;
+            pOMX_FreeHandle = NULL;
+            pOMX_GetComponentsOfRole = NULL;
+            pOMX_GetRolesOfComponent = NULL;
+            pOMX_SetupTunnel = NULL;
+            pOMX_GetContentPipe = NULL;
+        };
+
+        /* return true when the core library can be safely unloaded */
+        /* and reloaded at runtime                                  */
+        virtual bool UnloadWhenNotUsed(void) = 0;
+
+        tpOMX_Init GetpOMX_Init()
+        {
+            return pOMX_Init;
+        };
+
+        tpOMX_Deinit GetpOMX_Deinit()
+        {
+            return  pOMX_Deinit;
+        };
+
+        tpOMX_ComponentNameEnum GetpOMX_ComponentNameEnum()
+        {
+            return pOMX_ComponentNameEnum;
+        };
+
+        tpOMX_GetHandle GetpOMX_GetHandle()
+        {
+            return pOMX_GetHandle;
+        };
+
+        tpOMX_FreeHandle GetpOMX_FreeHandle()
+        {
+            return pOMX_FreeHandle;
+        };
+
+        tpOMX_GetComponentsOfRole GetpOMX_GetComponentsOfRole()
+        {
+            return pOMX_GetComponentsOfRole;
+        };
+
+        tpOMX_GetRolesOfComponent GetpOMX_GetRolesOfComponent()
+        {
+            return pOMX_GetRolesOfComponent;
+        };
+
+        tpOMX_SetupTunnel GetpOMX_SetupTunnel()
+        {
+            return pOMX_SetupTunnel;
+        };
+
+        tpOMX_GetContentPipe GetpOMX_GetContentPipe()
+        {
+            return pOMX_GetContentPipe;
+        };
+
+        // ptrs to all omx core methods
+        // will be set in the derived classes
+        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_Init)(void);
+
+        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_Deinit)(void);
+
+        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_ComponentNameEnum)(
+            OMX_OUT OMX_STRING cComponentName,
+            OMX_IN  OMX_U32 nNameLength,
+            OMX_IN  OMX_U32 nIndex);
+
+
+        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_GetHandle)(
+            OMX_OUT OMX_HANDLETYPE* pHandle,
+            OMX_IN  OMX_STRING cComponentName,
+            OMX_IN  OMX_PTR pAppData,
+            OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
+
+
+        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_FreeHandle)(
+            OMX_IN  OMX_HANDLETYPE hComponent);
+
+        OMX_ERRORTYPE(*pOMX_GetComponentsOfRole)(
+            OMX_IN      OMX_STRING role,
+            OMX_INOUT   OMX_U32 *pNumComps,
+            OMX_INOUT   OMX_U8  **compNames);
+
+
+        OMX_ERRORTYPE(*pOMX_GetRolesOfComponent)(
+            OMX_IN      OMX_STRING compName,
+            OMX_INOUT   OMX_U32 *pNumRoles,
+            OMX_OUT     OMX_U8 **roles);
+
+
+        OMX_ERRORTYPE OMX_APIENTRY(*pOMX_SetupTunnel)(
+            OMX_IN  OMX_HANDLETYPE hOutput,
+            OMX_IN  OMX_U32 nPortOutput,
+            OMX_IN  OMX_HANDLETYPE hInput,
+            OMX_IN  OMX_U32 nPortInput);
+
+
+        OMX_ERRORTYPE(*pOMX_GetContentPipe)(
+            OMX_OUT OMX_HANDLETYPE *hPipe,
+            OMX_IN OMX_STRING szURI);
+};
+#endif
+
diff --git a/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp b/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp
new file mode 100644
index 0000000..402b91a
--- /dev/null
+++ b/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp
@@ -0,0 +1,868 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_omxdefs.h"
+#include "omx_component.h"
+#include "omx_core.h"
+#include "omx_interface.h"
+
+#include "pvlogger.h"
+#include "oscl_base.h"
+#include "oscl_file_find.h"
+#include "oscl_library_list.h"
+#include "oscl_shared_library.h"
+#include "oscl_configfile_list.h"
+#include "osclconfig_lib.h"
+#include "oscl_string.h"
+#include "oscl_mem.h"
+#include "oscl_stdstring.h"
+
+#define MAX_PATHNAME_LENGTH 512
+
+#ifndef USE_CML2_CONFIG
+#define MAX_NUMBER_OF_OMX_CORES 10
+#define MAX_NUMBER_OF_OMX_COMPONENTS 50
+#endif /* USE_CML2_CONFIG */
+
+
+typedef class OMXMasterCoreGlobalData
+{
+    public:
+        OMXMasterCoreGlobalData()
+                : iNumMasterOMXInstances(1),
+                iInterface(NULL),
+                iOMXLibrary(NULL),
+                iMasterRegistry(NULL),
+                iOMXCompHandles(NULL),
+                iTotalNumOMXComponents(0),
+                iNumOMXCores(0)
+        {
+
+        };
+        //Counter of number of instances - so that init and deinit is done only once
+        OMX_U32 iNumMasterOMXInstances;
+
+        // Array of interfaces
+        void *iInterface;
+
+        // ptr to array of ptrs to libraries
+        void *iOMXLibrary;
+
+        // ptr to registry of all omx components from various cores
+        void *iMasterRegistry;
+
+        // ptr to array of component handles (when a component is instantiated - needed to be able to free the component)
+        void *iOMXCompHandles;
+
+        // total number of all componenents from various cores
+        OMX_U32 iTotalNumOMXComponents;
+
+        // number of omx cores from different vendors
+        OMX_U32 iNumOMXCores;
+
+} OMXMasterCoreGlobalData;
+
+typedef struct PVOMXMasterRegistryStruct
+{
+    OMX_U8 CompName[PV_OMX_MAX_COMPONENT_NAME_LENGTH];
+    OMX_U8 CompRole[PV_OMX_MAX_COMPONENT_NAME_LENGTH];
+    OMX_U32 OMXCoreIndex;
+    OMX_U32 CompIndex;
+} PVOMXMasterRegistryStruct;
+
+typedef struct PVOMXCompHandles
+{
+    OMX_HANDLETYPE handle;
+    OMX_U32 OMXCoreIndex;
+} PVOMXCompHandles;
+
+
+// helper function to obtain the registry index for a given handle
+// NOTE: 2 or more instances of the player/author are using this same OmxCompHandles array
+// However,the component handles recorded into the array or deleted from it by one instance/thread don't
+// affect other handles in other instances. In other words, for most purposes - it is safe to search through the array without
+// actually locking it - even if another
+// instance of the player/author modifies this array (by adding or deleting its own component handles) in the meanwhile.
+OMX_ERRORTYPE GetRegIndexForHandle(OMX_HANDLETYPE hComponent, OMX_U32 &index, OMXMasterCoreGlobalData *data)
+{
+    // we need to first find the handle among instantiated components
+    // then we retrieve the core based on component handle
+
+    // locking and unlocking of global data takes place outside of this method if necessary
+    PVOMXCompHandles *pOMXCompHandles = (PVOMXCompHandles*)(data->iOMXCompHandles);
+    if (pOMXCompHandles == NULL)
+    {
+        return OMX_ErrorComponentNotFound;
+    }
+
+    for (index = 0; index < MAX_NUMBER_OF_OMX_COMPONENTS; index++)
+    {
+        // go through the list of supported components and find the component handle
+        if (pOMXCompHandles[index].handle == hComponent)
+        {
+            // found a matching handle
+            break;
+        }
+    }
+
+    if (index == MAX_NUMBER_OF_OMX_COMPONENTS)
+    {
+        // could not find a component with the given name
+        return OMX_ErrorComponentNotFound;
+    }
+
+    return OMX_ErrorNone;
+}
+
+// ALL the standard OpenMAX IL core functions are implemented below
+static OMX_ERRORTYPE _OMX_Init(OMXMasterCoreGlobalData *data)
+{
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+    OMX_U32 jj;
+    OMX_U32 index;
+    OMX_U32 master_index = 0;
+    OMX_U32 component_index = 0;
+
+    /*
+    ** Step 1. Populate all the config files present in the specified path.
+    ** Step 2. Populate all the libraries from the .cfg files that claim to support the OMX_INTERFACE_ID.
+    ** Step 3. For these libraries, validate whether they really support the ID by doing a QueryInterface().
+    */
+
+    // Step 1
+    OsclConfigFileList aCfgList;
+    OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH;
+    aCfgList.Populate(configFilePath, OsclConfigFileList::ESortByName);
+
+    // array of ptrs to various cores, one for every valid configuration
+    OMXInterface** pInterface = (OMXInterface**)OSCL_MALLOC(aCfgList.Size() * sizeof(OMXInterface *));
+    if (pInterface == NULL)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+    // set the global ptr to this array
+    data->iInterface = (void*)pInterface;
+
+    // array of ptrs to the omx shared libraries, one for every valid configuration
+    OsclSharedLibrary** pLibrary = (OsclSharedLibrary**)OSCL_MALLOC(aCfgList.Size() * sizeof(OsclSharedLibrary *));
+    if (pLibrary == NULL)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+    // set the global ptr to this array
+    //
+    data->iOMXLibrary = (void*)pLibrary;
+
+    for (uint ii = 0; ii < aCfgList.Size(); ii++)
+    {
+        // Step 2
+        OsclLibraryList libList;
+        libList.Populate(OMX_INTERFACE_ID, aCfgList.GetConfigfileAt(ii));
+
+        for (uint jj = 0; (jj < libList.Size()) && ((data->iNumOMXCores) < aCfgList.Size()); jj++)
+        {
+            OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
+            if (lib->LoadLib(libList.GetLibraryPathAt(jj)) == OsclLibSuccess)
+            {
+                OsclAny* interfacePtr = NULL;
+                // Step 3
+                OsclLibStatus result = lib->QueryInterface(OMX_INTERFACE_ID, (OsclAny*&)interfacePtr);
+                if (result == OsclLibSuccess && interfacePtr != NULL)
+                {
+                    pLibrary[(data->iNumOMXCores)] = lib;
+                    OMXInterface* coreIntPtr = OSCL_DYNAMIC_CAST(OMXInterface*, interfacePtr);
+                    pInterface[(data->iNumOMXCores)] = coreIntPtr;
+                    (data->iNumOMXCores)++;
+                    continue;
+                }
+            }
+            lib->Close();
+            OSCL_DELETE(lib);
+        }
+    }
+
+    // allocate space for the OMX component registry
+    PVOMXMasterRegistryStruct* pOMXMasterRegistry = (PVOMXMasterRegistryStruct*)OSCL_MALLOC(MAX_NUMBER_OF_OMX_COMPONENTS * sizeof(PVOMXMasterRegistryStruct));
+    if (pOMXMasterRegistry == NULL)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+    data->iMasterRegistry = (void*)pOMXMasterRegistry;
+
+    PVOMXCompHandles* pOMXCompHandles = (PVOMXCompHandles*)OSCL_MALLOC(MAX_NUMBER_OF_OMX_COMPONENTS * sizeof(PVOMXCompHandles));
+    if (pOMXCompHandles == NULL)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+    data->iOMXCompHandles = (void*)pOMXCompHandles;
+
+    // init the array
+    memset(pOMXCompHandles, 0, MAX_NUMBER_OF_OMX_COMPONENTS*sizeof(PVOMXCompHandles));
+
+    // loop over all cores
+    master_index = 0;
+    OMX_STRING ComponentName = (OMX_STRING)OSCL_MALLOC(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
+
+    for (jj = 0; jj < data->iNumOMXCores; jj++)
+    {
+        // first call OMX_Init
+        Status = (*(pInterface[jj]->GetpOMX_Init()))();
+
+        if (Status == OMX_ErrorNone)
+        {
+            // enumerate components to get their number etc.
+            OMX_ERRORTYPE stat = OMX_ErrorNone;
+
+            index = 0;
+            while (stat != OMX_ErrorNoMore)
+            {
+                // clear, then get next component name
+                memset(ComponentName, 0, PV_OMX_MAX_COMPONENT_NAME_LENGTH*sizeof(OMX_U8));
+
+                stat = (*(pInterface[jj]->GetpOMX_ComponentNameEnum()))(
+                           ComponentName,
+                           PV_OMX_MAX_COMPONENT_NAME_LENGTH,
+                           index);
+
+                if (stat == OMX_ErrorNoMore)
+                    break;
+
+                // check number roles of the component
+                OMX_U32 numRoles;
+                numRoles = 0;
+                stat = (*(pInterface[jj]->GetpOMX_GetRolesOfComponent()))(
+                           ComponentName,
+                           &numRoles,
+                           NULL);
+
+                if ((numRoles > 0) && (stat == OMX_ErrorNone))
+                {
+                    // allocate space for roles of the component
+                    OMX_U32 role;
+                    OMX_U8 **ComponentRoles = (OMX_U8**)OSCL_MALLOC(numRoles * sizeof(OMX_U8 *));
+
+                    for (role = 0; role < numRoles; role++)
+                        ComponentRoles[role] = (OMX_U8*)OSCL_MALLOC(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
+
+
+                    // get the array of strings with component roles
+                    stat = (*(pInterface[jj]->GetpOMX_GetRolesOfComponent()))(
+                               ComponentName,
+                               &numRoles,
+                               ComponentRoles);
+
+                    //register all components separately in master registry
+                    if (stat == OMX_ErrorNone)
+                    {
+                        for (role = 0; (role < numRoles) && (master_index < MAX_NUMBER_OF_OMX_COMPONENTS); role++)
+                        {
+                            strncpy((OMX_STRING)pOMXMasterRegistry[master_index].CompName, ComponentName, PV_OMX_MAX_COMPONENT_NAME_LENGTH);
+                            strncpy((OMX_STRING)pOMXMasterRegistry[master_index].CompRole, (OMX_STRING)ComponentRoles[role], PV_OMX_MAX_COMPONENT_NAME_LENGTH);
+                            pOMXMasterRegistry[master_index].OMXCoreIndex = jj;
+                            pOMXMasterRegistry[master_index].CompIndex = component_index;
+                            master_index++;
+
+                        }
+                    }
+
+                    // dealloc space for component roles
+                    for (role = 0; role < numRoles; role++)
+                        OSCL_FREE(ComponentRoles[role]);
+
+                    OSCL_FREE(ComponentRoles);
+
+
+                } // done with roles of component represented by index
+
+                index++; // get next component from the jj-th core
+                component_index++; // increase the global component index
+
+            } // done with all components from jj-th core
+        } // end of if(Status==OMX_ErrorNone)
+
+    }//end of for loop
+    // at this point, all cores were init, and all components registered
+
+    OSCL_FREE(ComponentName);
+    data->iTotalNumOMXComponents = master_index;
+
+
+    return OMX_ErrorNone;
+}
+
+//this routine is needed to avoid a longjmp clobber warning
+static void _Try_OMX_Init(int32& aError, OMX_ERRORTYPE& aStatus, OMXMasterCoreGlobalData *data)
+{
+    OSCL_TRY(aError, aStatus = _OMX_Init(data););
+}
+//this routine is needed to avoid a longjmp clobber warning
+static void _Try_OMX_Create(int32& aError, OMXMasterCoreGlobalData*& aData)
+{
+    OSCL_TRY(aError, aData = OSCL_NEW(OMXMasterCoreGlobalData, ()););
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_Init()
+{
+    OMX_ERRORTYPE status = OMX_ErrorNone;
+
+    //Check the global instance counter and only init OMX on the first call
+    int32 error;
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+
+    if (data)
+    {
+        // If singleton was already created
+        //Just update the instance counter.
+        data->iNumMasterOMXInstances++;
+
+        //Release the singleton.
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+        if (error)
+        {
+            status = OMX_ErrorUndefined;
+            return status;
+        }
+    }
+    else
+    {
+        //First call
+        //create the OMX Master Core singleton data
+        _Try_OMX_Create(error, data);
+        if (error != OsclErrNone)
+        {
+            status = OMX_ErrorInsufficientResources;//some leave happened.
+        }
+
+        //If create succeeded, then init the OMX globals.
+        if (status == OMX_ErrorNone)
+        {
+            _Try_OMX_Init(error, status, data);
+            if (error != OsclErrNone)
+            {
+                status = OMX_ErrorUndefined;//probably no memory.
+            }
+        }
+
+        //Release the singleton.
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+        if (error)
+        {
+            //registry error
+            status = OMX_ErrorUndefined;
+            return status;
+        }
+
+
+    }
+
+    if (error && status == OMX_ErrorNone)
+        status = OMX_ErrorUndefined;//registry error
+
+    return status;
+}
+
+
+static OMX_ERRORTYPE _OMX_Deinit(OMXMasterCoreGlobalData *data)
+{
+    OMX_U32 jj;
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+
+    //free master registry
+    data->iTotalNumOMXComponents = 0;
+    PVOMXMasterRegistryStruct* pOMXMasterRegistry = (PVOMXMasterRegistryStruct*)(data->iMasterRegistry);
+
+    if (pOMXMasterRegistry)
+        OSCL_FREE(pOMXMasterRegistry);
+
+    data->iMasterRegistry = NULL;
+
+    PVOMXCompHandles* pOMXCompHandles = (PVOMXCompHandles*)(data->iOMXCompHandles);
+    if (pOMXCompHandles)
+        OSCL_FREE(pOMXCompHandles);
+    data->iOMXCompHandles = NULL;
+
+
+    OMXInterface** pInterface = (OMXInterface**)(data->iInterface);
+    //call Deinit for each core
+    if (pInterface)
+    {
+        for (jj = 0; jj < data->iNumOMXCores; jj++)
+        {
+            Status = (*(pInterface[jj]->GetpOMX_Deinit()))();
+            OSCL_DELETE(pInterface[jj]);
+        }
+
+        OSCL_FREE(pInterface);
+        data->iInterface = NULL;
+    }
+
+
+    OsclSharedLibrary** pLibrary = (OsclSharedLibrary**)(data->iOMXLibrary);
+    if (pLibrary)
+    {
+        for (jj = 0; jj < data->iNumOMXCores; jj++)
+        {
+            if (pLibrary[jj])
+            {
+                pLibrary[jj]->Close();
+                OSCL_DELETE(pLibrary[jj]);
+            }
+        }
+        OSCL_FREE(pLibrary);
+        data->iOMXLibrary = NULL;
+    }
+    data->iNumOMXCores = 0;
+
+    return OMX_ErrorNone;
+}
+
+//this routine is needed to avoid a longjmp clobber warning.
+static void _Try_OMX_Deinit(int32 &aError, OMX_ERRORTYPE& aStatus, OMXMasterCoreGlobalData* data)
+{
+    OSCL_TRY(aError, aStatus = _OMX_Deinit(data););
+}
+
+//this routine is needed to avoid a longjmp clobber warning.
+static void _Try_Data_Cleanup(int32 &aError, OMXMasterCoreGlobalData* aData)
+{
+    OSCL_TRY(aError, OSCL_DELETE(aData););
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_Deinit()
+{
+    OMX_ERRORTYPE status = OMX_ErrorNone;
+
+    //Check the global instance counter and only cleanup OMX on the last call.
+    int32 error;
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+
+    if (data)
+    {
+        data->iNumMasterOMXInstances--;
+        if (data->iNumMasterOMXInstances == 0)
+        {
+
+            //Cleanup the OMX globals.
+            _Try_OMX_Deinit(error, status, data);
+            if (error != OsclErrNone)
+                status = OMX_ErrorUndefined;//some leave happened.
+
+            //Regardless of the cleanup result, cleanup the OMX singleton.
+            _Try_Data_Cleanup(error, data);
+            data = NULL;
+            if (error != OsclErrNone)
+                status = OMX_ErrorUndefined;//some leave happened.
+
+        }
+    }
+
+    //Release the singleton.
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+
+    return status;
+}
+
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
+    OMX_OUT OMX_STRING cComponentName,
+    OMX_IN  OMX_U32 nNameLength,
+    OMX_IN  OMX_U32 nIndex)
+{
+    OSCL_UNUSED_ARG(nNameLength);
+    OMX_U32 ii;
+
+    OSCL_UNUSED_ARG(nNameLength);
+    int32 error;
+    // this method just reads from the master registry (which does not change) - so no lock is needed
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+    if (data)
+    {
+        PVOMXMasterRegistryStruct* pOMXMasterRegistry = (PVOMXMasterRegistryStruct*)(data->iMasterRegistry);
+        if (NULL == pOMXMasterRegistry)
+        {
+            return OMX_ErrorNoMore;
+        }
+
+        // go through alll the components and find the one with the correct index
+        for (ii = 0; ii < data->iTotalNumOMXComponents; ii++)
+        {
+            if (pOMXMasterRegistry[ii].CompIndex == nIndex)
+            {
+                oscl_strncpy((OMX_STRING)cComponentName,
+                             (OMX_STRING)pOMXMasterRegistry[ii].CompName,
+                             PV_OMX_MAX_COMPONENT_NAME_LENGTH);
+                break;
+            }
+        }
+
+        if (ii == data->iTotalNumOMXComponents)
+        {
+            return OMX_ErrorNoMore;
+        }
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        return OMX_ErrorNoMore;
+    }
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY   OMX_GetHandle(
+    OMX_OUT OMX_HANDLETYPE* pHandle,
+    OMX_IN  OMX_STRING cComponentName,
+    OMX_IN  OMX_PTR pAppData,
+    OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
+{
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+    OMX_U32 ii, kk;
+
+    int32 error;
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+
+    if (data)
+    {
+        PVOMXMasterRegistryStruct* pOMXMasterRegistry = (PVOMXMasterRegistryStruct*)(data->iMasterRegistry);
+        OMXInterface** pInterface = (OMXInterface**)(data->iInterface);
+        PVOMXCompHandles* pOMXCompHandles = (PVOMXCompHandles*)(data->iOMXCompHandles);
+
+        if ((pOMXMasterRegistry == NULL) || (pInterface == NULL) || (pOMXCompHandles == NULL))
+        {
+            // unlock singleton before returning
+            OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+            if (error)
+            {
+                //registry error
+                Status = OMX_ErrorUndefined;
+                return Status;
+            }
+            return OMX_ErrorInsufficientResources;
+        }
+
+        for (ii = 0; ii < (data->iTotalNumOMXComponents); ii++)
+        {
+            // go through the list of supported components and find the component based on its name (identifier)
+            if (!oscl_strcmp((OMX_STRING)pOMXMasterRegistry[ii].CompName, cComponentName))
+            {
+                // found a matching name
+                break;
+            }
+        }
+        if (ii == (data->iTotalNumOMXComponents))
+        {
+            // could not find a component with the given name
+            OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+            if (error)
+            {
+                //registry error
+                Status = OMX_ErrorUndefined;
+                return Status;
+            }
+            return OMX_ErrorComponentNotFound;
+        }
+
+        // call the appropriate GetHandle for the component
+
+        // save component handle with the OMX core index, so it can be retrieved
+        // later when freehandle is called
+        // find an empty slot to write the pair handle/index:
+        for (kk = 0; kk < MAX_NUMBER_OF_OMX_COMPONENTS; kk++)
+        {
+            if (pOMXCompHandles[kk].handle == NULL)
+            {
+                break;
+            }
+        }
+        if (kk == MAX_NUMBER_OF_OMX_COMPONENTS)
+        {
+            // no empty slot was found
+            return OMX_ErrorComponentNotFound;
+        }
+
+        OMX_U32 index = pOMXMasterRegistry[ii].OMXCoreIndex;
+
+        Status = (*(pInterface[index]->GetpOMX_GetHandle()))(pHandle, cComponentName, pAppData, pCallBacks);
+        if (Status == OMX_ErrorNone)
+        {
+            // write the pair handle/index
+            pOMXCompHandles[kk].handle       = *pHandle;
+            pOMXCompHandles[kk].OMXCoreIndex = index;
+        }
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+        if (error)
+        {
+            //registry error
+            Status = OMX_ErrorUndefined;
+
+        }
+        return Status;
+    }
+    else
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+        if (error)
+        {
+            //registry error
+            Status = OMX_ErrorUndefined;
+            return Status;
+        }
+        return OMX_ErrorInsufficientResources;
+    }
+
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
+{
+    OMX_ERRORTYPE Status = OMX_ErrorNone;
+    OMX_U32 RegIndex;
+
+    int32 error;
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+
+    if (data)
+    {
+        PVOMXCompHandles* pOMXCompHandles = (PVOMXCompHandles*)(data->iOMXCompHandles);
+        OMXInterface** pInterface = (OMXInterface**)(data->iInterface);
+
+        if ((pOMXCompHandles == NULL) || (pInterface == NULL))
+        {
+            OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+            if (error)
+            {
+                //registry error
+                Status = OMX_ErrorUndefined;
+                return Status;
+            }
+            return OMX_ErrorInsufficientResources;
+        }
+        // get the core index for the handle
+        Status = GetRegIndexForHandle(hComponent, RegIndex, data);
+
+        if (OMX_ErrorNone != Status)
+        {
+            OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+            return Status;
+        }
+
+        // call the appropriate GetHandle for the component
+
+        OMX_U32 index = pOMXCompHandles[RegIndex].OMXCoreIndex;
+        Status = (*(pInterface[index]->GetpOMX_FreeHandle()))(hComponent);
+        //we're done with this, so get rid of the component handle
+        pOMXCompHandles[RegIndex].handle = NULL;
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+        if (error)
+        {
+            //registry error
+            Status = OMX_ErrorUndefined;
+
+        }
+        return Status;
+    }
+    else
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+        return OMX_ErrorInsufficientResources;
+    }
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
+    OMX_IN  OMX_HANDLETYPE hOutput,
+    OMX_IN  OMX_U32 nPortOutput,
+    OMX_IN  OMX_HANDLETYPE hInput,
+    OMX_IN  OMX_U32 nPortInput)
+{
+    OMX_ERRORTYPE Status;
+    OMX_U32 RegIndex1;
+    OMX_U32 RegIndex2;
+
+    int32 error;
+    // no need to lock - a different instance/thread does not affect the global array searches in this thread
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+    if (data)
+    {
+        Status = GetRegIndexForHandle(hOutput, RegIndex1, data);
+        if (OMX_ErrorNone != Status)
+        {
+            return Status;
+        }
+
+        Status = GetRegIndexForHandle(hInput, RegIndex2, data);
+        if (OMX_ErrorNone != Status)
+        {
+            return Status;
+        }
+
+        PVOMXCompHandles* pOMXCompHandles = (PVOMXCompHandles*)(data->iOMXCompHandles);
+        OMXInterface** pInterface = (OMXInterface**)(data->iInterface);
+
+        if ((pOMXCompHandles == NULL) || (pInterface == NULL))
+        {
+            return OMX_ErrorInsufficientResources;
+        }
+
+        //if (pOMXCompHandles[RegIndex1].OMXCoreIndex != pOMXCompHandles[RegIndex2].OMXCoreIndex)
+        //{
+        // the components are from different omx cores
+        // it is not clear if setting up a tunnel between them is supported
+        //  return OMX_ErrorNotImplemented;
+        //}
+
+
+
+        OMX_U32 index = pOMXCompHandles[RegIndex1].OMXCoreIndex;
+        Status = (*(pInterface[index]->GetpOMX_SetupTunnel()))(
+                     hOutput,
+                     nPortOutput,
+                     hInput,
+                     nPortInput);
+
+        return Status;
+
+
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
+    OMX_OUT OMX_HANDLETYPE *hPipe,
+    OMX_IN OMX_STRING szURI)
+{
+    OMX_ERRORTYPE Status = OMX_ErrorNotImplemented;
+    OMX_U32 ii;
+
+    int32 error;
+    // no need to lock
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+    if (data)
+    {
+        // try to get the content pipe from any of the omx cores
+        // return the first valid one
+        OMXInterface** pInterface = (OMXInterface**)(data->iInterface);
+        if (pInterface)
+        {
+            for (ii = 0; ii < data->iNumOMXCores; ii++)
+            {
+                Status = (*(pInterface[ii]->GetpOMX_GetContentPipe()))(hPipe, szURI);
+                if (OMX_ErrorNone == Status)
+                {
+                    break;
+                }
+            }
+        }
+        else
+        {
+            return OMX_ErrorInsufficientResources;
+        }
+    }
+    else
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+
+    return Status;
+}
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_GetComponentsOfRole(
+    OMX_IN      OMX_STRING role,
+    OMX_INOUT   OMX_U32 *pNumComps,
+    OMX_INOUT   OMX_U8  **compNames)
+{
+    OMX_U32 ii;
+
+    // initialize the number of components found to 0
+    *pNumComps = 0;
+    int32 error;
+    // no need to lock - just reading from master registry that does not change
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+    if (data)
+    {
+        PVOMXMasterRegistryStruct* pOMXMasterRegistry = (PVOMXMasterRegistryStruct*)(data->iMasterRegistry);
+        if (pOMXMasterRegistry == NULL)
+        {
+            return OMX_ErrorNone;
+        }
+
+        // go through all components and check if they support the given role
+        for (ii = 0; ii < data->iTotalNumOMXComponents; ii++)
+        {
+            // if the role matches, increment the counter and record the comp. name
+            if (!oscl_strcmp((OMX_STRING)pOMXMasterRegistry[ii].CompRole, role))
+            {
+                // if a placeholder for compNames is provided, copy the component name into it
+                if (NULL != compNames)
+                {
+                    oscl_strncpy((OMX_STRING)compNames[*pNumComps],
+                                 (OMX_STRING)pOMXMasterRegistry[ii].CompName,
+                                 PV_OMX_MAX_COMPONENT_NAME_LENGTH);
+                }
+                // increment the counter
+                *pNumComps = (*pNumComps + 1);
+            }
+        }
+    }
+
+    return OMX_ErrorNone;
+}
+
+
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_GetRolesOfComponent(
+    OMX_IN      OMX_STRING compName,
+    OMX_INOUT   OMX_U32* pNumRoles,
+    OMX_OUT     OMX_U8** roles)
+{
+    OMX_U32 ii;
+
+    *pNumRoles = 0;
+
+    int32 error;
+    // no need to lock - just reading from master registry that does not change
+    OMXMasterCoreGlobalData* data = (OMXMasterCoreGlobalData*)OsclSingletonRegistry::getInstance(OSCL_SINGLETON_ID_OMXMASTERCORE, error);
+    if (data)
+    {
+        PVOMXMasterRegistryStruct* pOMXMasterRegistry = (PVOMXMasterRegistryStruct*)(data->iMasterRegistry);
+        if (pOMXMasterRegistry == NULL)
+        {
+            return OMX_ErrorNone;
+        }
+
+        // go through all components
+        for (ii = 0; ii < data->iTotalNumOMXComponents; ii++)
+        {
+            // if the name  matches, increment the counter and record the comp. role
+            if (!oscl_strcmp((OMX_STRING)pOMXMasterRegistry[ii].CompName, compName))
+            {
+                // if a placeholder for roles is provided, copy the component role into it
+                if (NULL != roles)
+                {
+                    oscl_strncpy((OMX_STRING)roles[*pNumRoles],
+                                 (OMX_STRING)pOMXMasterRegistry[ii].CompRole,
+                                 PV_OMX_MAX_COMPONENT_NAME_LENGTH);
+                }
+                // increment the counter
+                *pNumRoles = (*pNumRoles + 1);
+            }
+        }
+    }
+
+    return OMX_ErrorNone;
+}
+
+
diff --git a/codecs_v2/omx/omx_mp3/Android.mk b/codecs_v2/omx/omx_mp3/Android.mk
index 390dc24..da538ff 100644
--- a/codecs_v2/omx/omx_mp3/Android.mk
+++ b/codecs_v2/omx/omx_mp3/Android.mk
@@ -3,31 +3,34 @@
 
 LOCAL_SRC_FILES := \
 	src/mp3_dec.cpp \
-	src/omx_mp3_component.cpp \
-	src/mp3_timestamp.cpp
-
+ 	src/omx_mp3_component.cpp \
+ 	src/mp3_timestamp.cpp
 
 
 LOCAL_MODULE := libomx_mp3_component_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_mp3/include \
-	$(PV_TOP)//codecs_v2/omx/omx_mp3/src \
-	$(PV_TOP)//codecs_v2/omx/omx_mp3/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//codecs_v2/omx/omx_mp3/../../audio/mp3/pv_dec/src \
-	$(PV_TOP)//codecs_v2/omx/omx_mp3/../../audio/mp3/pv_dec/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_mp3/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_mp3/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/omx/omx_baseclass/include \
+ 	$(PV_TOP)/codecs_v2/audio/mp3/dec/src \
+ 	$(PV_TOP)/codecs_v2/audio/mp3/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/mp3_dec.h \
-	include/omx_mp3_component.h \
-	include/mp3_timestamp.h
+ 	include/omx_mp3_component.h \
+ 	include/mp3_timestamp.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_mp3/build/make_multithreaded/local.mk b/codecs_v2/omx/omx_mp3/build/make_multithreaded/local.mk
new file mode 100644
index 0000000..8b1deb7
--- /dev/null
+++ b/codecs_v2/omx/omx_mp3/build/make_multithreaded/local.mk
@@ -0,0 +1,34 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_mp3_component_lib
+
+
+XINCDIRS += \
+        ../../../../../extern_libs_v2/khronos/openmax/include \
+        ../../../../omx/omx_baseclass/include \
+        ../../../../audio/mp3/dec/src \
+        ../../../../audio/mp3/dec/include
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := mp3_dec.cpp \
+	omx_mp3_component.cpp \
+	mp3_timestamp.cpp  
+
+
+HDRS := mp3_dec.h \
+	omx_mp3_component.h \
+	mp3_timestamp.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_mp3/build/make_multithreaded/makefile b/codecs_v2/omx/omx_mp3/build/make_multithreaded/makefile
deleted file mode 100644
index 56b4196..0000000
--- a/codecs_v2/omx/omx_mp3/build/make_multithreaded/makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_mp3_component_lib
-
-
-
-XINCDIRS += \
-    -I ../../../../../extern_libs_v2/khronos/openmax/include \
-    -I ../../../../audio/mp3/pv_dec/src \
-    -I ../../../../audio/mp3/pv_dec/include
-
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  mp3_dec.cpp \
-    omx_mp3_component.cpp \
-    mp3_timestamp.cpp  
-
-
-HDRS =  mp3_dec.h \
-    omx_mp3_component.h \
-    mp3_timestamp.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_mp3/include/mp3_dec.h b/codecs_v2/omx/omx_mp3/include/mp3_dec.h
index 7d6b506..4668f4e 100644
--- a/codecs_v2/omx/omx_mp3/include/mp3_dec.h
+++ b/codecs_v2/omx/omx_mp3/include/mp3_dec.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
         Int Mp3DecodeAudio(OMX_S16* aOutBuff,
                            OMX_U32* aOutputLength, OMX_U8** aInputBuf,
                            OMX_U32* aInBufSize,
-                           OMX_S32* aIsFirstBuffer,
+                           OMX_S32* aFrameCount,
                            OMX_AUDIO_PARAM_PCMMODETYPE* aAudioPcmParam,
                            OMX_AUDIO_PARAM_MP3TYPE* aAudioMp3Param,
                            OMX_BOOL aMarkerFlag,
diff --git a/codecs_v2/omx/omx_mp3/include/mp3_timestamp.h b/codecs_v2/omx/omx_mp3/include/mp3_timestamp.h
index 573361f..9983acc 100644
--- a/codecs_v2/omx/omx_mp3/include/mp3_timestamp.h
+++ b/codecs_v2/omx/omx_mp3/include/mp3_timestamp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/omx/omx_mp3/include/omx_mp3_component.h b/codecs_v2/omx/omx_mp3/include/omx_mp3_component.h
index f30d4fe..49ea43e 100644
--- a/codecs_v2/omx/omx_mp3/include/omx_mp3_component.h
+++ b/codecs_v2/omx/omx_mp3/include/omx_mp3_component.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,378 +24,60 @@
 #ifndef OMX_MP3_COMPONENT_H_INCLUDED
 #define OMX_MP3_COMPONENT_H_INCLUDED
 
-#ifndef OMX_Component_h
-#include "omx_component.h"
+#ifndef PV_OMXCOMPONENT_H_INCLUDED
+#include "pv_omxcomponent.h"
 #endif
 
 #ifndef MP3_DEC_H_INCLUDED
 #include "mp3_dec.h"
 #endif
 
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PV_OMX_QUEUE_H_INCLUDED
-#include "pv_omx_queue.h"
-#endif
-
-#ifndef PV_OMXCORE_H_INCLUDED
-#include "pv_omxcore.h"
-#endif
 
 #ifndef MP3_TIMESTAMP_H_INCLUDED
 #include "mp3_timestamp.h"
 #endif
 
 
-#define OMX_PORT_INPUTPORT_INDEX OMX_DirInput
-#define OMX_PORT_OUTPUTPORT_INDEX OMX_DirOutput
-#define OMX_PORT_ALLPORT_INDEX -1
-
 
 #define INPUT_BUFFER_SIZE_MP3 8192
 #define OUTPUT_BUFFER_SIZE_MP3 4608
 
 #define NUMBER_INPUT_BUFFER_MP3  10
-#define NUMBER_OUTPUT_BUFFER_MP3  2
+#define NUMBER_OUTPUT_BUFFER_MP3  9
 
 
-/* Application's private data */
-typedef struct Mp3PrivateType
-{
-    OMX_HANDLETYPE Mp3Handle;
-
-}Mp3PrivateType;
-
-
-/**
- * This is the Component template from which all
- * other Component instances are factored by the core.
- */
-
-
-/**
- * The structure for port Type.
- */
-typedef struct Mp3ComponentPortType
-{
-    /** @param pBuffer An array of pointers to buffer headers. */
-    OMX_BUFFERHEADERTYPE** pBuffer;
-    /** @param BufferState The State of the Buffer whether assigned or allocated */
-    OMX_U32* BufferState;
-    /** @param NumAssignedBuffers Number of buffer assigned on each port */
-    OMX_U32 NumAssignedBuffers;
-    /** @param pBufferQueue queue for buffer to be processed by the port */
-    QueueType* pBufferQueue;
-    OMX_STATETYPE TransientState;
-    /** @param BufferUnderProcess  Boolean variables indicate whether the port is processing any buffer */
-    OMX_BOOL BufferUnderProcess;
-    OMX_PARAM_PORTDEFINITIONTYPE PortParam;
-    /** @param NumBufferFlushed Number of buffer Flushed */
-    OMX_U32 NumBufferFlushed;
-    /** @param IsPortFlushed Boolean variables indicate port is being flushed at the moment */
-    OMX_BOOL IsPortFlushed;
-
-    OMX_AUDIO_PARAM_PORTFORMATTYPE	AudioParam;
-    OMX_AUDIO_PARAM_MP3TYPE			AudioMp3Param;
-    OMX_AUDIO_PARAM_PCMMODETYPE		AudioPcmMode;
-    OMX_AUDIO_CONFIG_EQUALIZERTYPE	AudioEqualizerType;
-
-    //Added these flags as a replacement of semaphores on win32 platform
-    OMX_BOOL LoadedToIdleFlag ;
-    OMX_BOOL IdleToLoadedFlag ;
-
-} Mp3ComponentPortType;
-
-
-class OpenmaxMp3AO : public OsclActiveObject
+class OpenmaxMp3AO : public OmxComponentAudio
 {
     public:
 
         OpenmaxMp3AO();
         ~OpenmaxMp3AO();
 
-        /** Component entry points declarations without proxy interface*/
-        static OMX_ERRORTYPE BaseComponentGetComponentVersion(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STRING pComponentName,
-            OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
-            OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
-            OMX_OUT OMX_UUIDTYPE* pComponentUUID);
+        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy);
+        OMX_ERRORTYPE DestroyComponent();
 
-        static OMX_ERRORTYPE BaseComponentGetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
+        OMX_ERRORTYPE ComponentInit();
+        OMX_ERRORTYPE ComponentDeInit();
 
-        static OMX_ERRORTYPE BaseComponentSetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
+        static void ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
+        void ProcessData();
+        void SyncWithInputTimestamp();
+        void ProcessInBufferFlag();
 
-        static OMX_ERRORTYPE BaseComponentGetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_INOUT OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentSetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        static OMX_ERRORTYPE BaseComponentGetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        static OMX_ERRORTYPE BaseComponentGetState(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_OUT OMX_STATETYPE* pState);
-
-        static OMX_ERRORTYPE BaseComponentUseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentAllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        static OMX_ERRORTYPE BaseComponentFreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_U32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        static OMX_ERRORTYPE BaseComponentComponentDeInit(
-            OMX_IN  OMX_HANDLETYPE hComponent);
-
-        static OMX_ERRORTYPE BaseComponentEmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentFillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        static OMX_ERRORTYPE BaseComponentSetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        static void Mp3ComponentGetRolesOfComponent(OMX_STRING* aRoleString);
-
-        /*NON STATIC COUNTERPARTS OF STATIC MEMBER API'S */
-
-        OMX_ERRORTYPE GetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_INOUT OMX_PTR ComponentParameterStructure);
-
-        OMX_ERRORTYPE SetParameter(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nParamIndex,
-            OMX_IN  OMX_PTR ComponentParameterStructure);
-
+        void ResetComponent();
         OMX_ERRORTYPE GetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE SetConfig(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_INDEXTYPE nIndex,
-            OMX_IN  OMX_PTR pComponentConfigStructure);
-
-        OMX_ERRORTYPE GetExtensionIndex(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_STRING cParameterName,
-            OMX_OUT OMX_INDEXTYPE* pIndexType);
-
-        void GetState(OMX_OUT OMX_STATETYPE* pState);
-
-        OMX_ERRORTYPE UseBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes,
-            OMX_IN OMX_U8* pBuffer);
-
-        OMX_ERRORTYPE AllocateBuffer(
-            OMX_IN OMX_HANDLETYPE hComponent,
-            OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-            OMX_IN OMX_U32 nPortIndex,
-            OMX_IN OMX_PTR pAppPrivate,
-            OMX_IN OMX_U32 nSizeBytes);
-
-        OMX_ERRORTYPE FreeBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SendCommand(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_COMMANDTYPE Cmd,
-            OMX_IN  OMX_S32 nParam,
-            OMX_IN  OMX_PTR pCmdData);
-
-        OMX_ERRORTYPE EmptyThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE FillThisBuffer(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-        OMX_ERRORTYPE SetCallbacks(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-            OMX_IN  OMX_PTR pAppData);
-
-        OMX_ERRORTYPE ConstructComponent(OMX_PTR pAppData);
-        OMX_ERRORTYPE DestroyComponent();
-
-        OMX_PTR GetOmxHandle()
-        {
-            return &iOmxComponent;
-        };
-
-        /*OTHER PROCESSING FUNCTIONS */
-
-        void Mp3ComponentBufferMgmtFunction();
-        OMX_BOOL Mp3BufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE*);
-        void Mp3Decode();
-        OMX_BOOL Mp3ComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer);
-
-        OMX_ERRORTYPE Mp3ComponentMessageHandler(CoreMessage* Message);
-        OMX_ERRORTYPE Mp3ComponentDoStateSet(OMX_U32);
-
-        OMX_ERRORTYPE Mp3ComponentDisablePort(OMX_S32 PortIndex);
-        void Mp3ComponentDisableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE Mp3ComponentEnablePort(OMX_S32 PortIndex);
-        void Mp3ComponentEnableSinglePort(OMX_U32 PortIndex);
-
-        OMX_ERRORTYPE Mp3ComponentFlushPort(OMX_S32 PortIndex);
-        void Mp3ComponentSetPortFlushFlag(OMX_S32, OMX_S32 index, OMX_BOOL value);
-        void Mp3ComponentSetNumBufferFlush(OMX_S32, OMX_S32 index, OMX_S32 value);
-
-        OMX_S32 Mp3ComponentPanic();
-
-        void Mp3ComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pInputBuffer, Mp3ComponentPortType *pPort);
-        void Mp3ComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pOutputBuffer, Mp3ComponentPortType *pPort);
-
-        OMX_ERRORTYPE Mp3ComponentInit();
-        OMX_ERRORTYPE Mp3ComponentDeInit();
-
-        OMX_ERRORTYPE Mp3ComponentTunnelRequest(
-            OMX_IN  OMX_HANDLETYPE hComp,
-            OMX_IN  OMX_U32 nPort,
-            OMX_IN  OMX_HANDLETYPE hTunneledComp,
-            OMX_IN  OMX_U32 nTunneledPort,
-            OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup);
-
-        OMX_ERRORTYPE BaseComponentParameterSanityCheck(
-            OMX_IN  OMX_HANDLETYPE hComponent,
-            OMX_IN  OMX_U32 nPortIndex,
-            OMX_IN  OMX_PTR pStructure,
-            OMX_IN  size_t size);
-
-        void SetHeader(OMX_PTR aheader, OMX_U32 asize);
-        OMX_ERRORTYPE CheckHeader(OMX_PTR aheader, OMX_U32 asize);
-
-        //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-        OMX_BOOL			iBufferExecuteFlag;
-        Mp3PrivateType*	ipAppPriv;
-
-
     private:
 
-        PVLogger* iLogger;
-
-        void Run();
         void CheckForSilenceInsertion();
         void DoSilenceInsertion();
 
-        OMX_CALLBACKTYPE*	ipCallbacks;
-        OMX_PTR				iCallbackData;
-        OMX_STATETYPE		iState;
+        Mp3Decoder* 	 ipMp3Dec;
+        Mp3TimeStampCalc iCurrentFrameTS;
 
-        CoreDescriptorType* ipCoreDescriptor;
-        OMX_U32				iNumInputBuffer;
-
-        OMX_U8*				ipFrameDecodeBuffer;
-        OMX_BOOL			iPartialFrameAssembly;
-        OMX_BOOL			iIsInputBufferEnded;
-        OMX_BOOL			iEndofStream;
-        OMX_U8*				ipTempInputBuffer;
-        OMX_U32				iTempInputBufferLength;
-        OMX_COMPONENTTYPE*	ipTargetComponent;
-        OMX_PTR				iTargetMarkData;
-        OMX_BOOL			iNewInBufferRequired;
-        OMX_BOOL			iNewOutBufRequired;
-        OMX_U32				iTempConsumedLength;
-        OMX_U32				iOutBufferCount;
-        OMX_BOOL			iCodecReady;
-        OMX_U8*				ipInputCurrBuffer;
-        OMX_U32				iInputCurrLength;
-        OMX_S32				iFrameCount;
-        OMX_BOOL			iStateTransitionFlag;
-        OMX_BOOL			iFlushPortFlag;
-        OMX_BOOL				iEndOfFrameFlag;
-        OMX_BUFFERHEADERTYPE*	ipMp3InputBuffer;
-        OMX_BUFFERHEADERTYPE*	ipMp3OutputBuffer;
-
-        OMX_U32					iOutputFrameLength;
-
-        OMX_COMPONENTTYPE iOmxComponent;	// structure
-        OMX_U32			iNumPorts;
-
-        PV_OMXComponentCapabilityFlagsType iPVCapabilityFlags;
-
-        //The ports of the component
-        Mp3ComponentPortType** ipPorts;
-        //Indicate whether component has been already initialized */
-        OMX_BOOL iIsInit;
-        //OpenMAX standard parameter that contains a short description of the available ports
-        OMX_PORT_PARAM_TYPE iPortTypesParam;
-        OMX_U32 iGroupPriority;
-        //ID of a group of components that share the same logical chain
-        OMX_U32 iGroupID;
-        //Roles of the component
-        OMX_U8 iComponentRole[OMX_MAX_STRINGNAME_SIZE];
-        //This field holds the private data associated with a mark request, if any
-        OMX_MARKTYPE* ipMark;
-
-        //Mp3 specific structure
-        Mp3Decoder* ipMp3Dec;
-
-        OMX_BOOL				iFirstFragment;
-        OMX_BOOL				iResizePending;
-        OMX_TICKS				iFrameTimestamp;
-        Mp3TimeStampCalc		iCurrentFrameTS;
-        OMX_BOOL				iRepositionFlag;
-        OMX_S32					iSamplesPerFrame;
-        OMX_BOOL				iSilenceInsertionInProgress;
-        OMX_U32					iSilenceFramesNeeded;
-        OMX_U32					iOutputMilliSecPerFrame;
 
 };
 
diff --git a/codecs_v2/omx/omx_mp3/src/mp3_dec.cpp b/codecs_v2/omx/omx_mp3/src/mp3_dec.cpp
index e79e7d2..29c93b8 100644
--- a/codecs_v2/omx/omx_mp3/src/mp3_dec.cpp
+++ b/codecs_v2/omx/omx_mp3/src/mp3_dec.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #include "mp3_dec.h"
 #include "pvmp3decoder_api.h"
 
@@ -87,7 +91,7 @@
 
 Int Mp3Decoder::Mp3DecodeAudio(OMX_S16* aOutBuff,
                                OMX_U32* aOutputLength, OMX_U8** aInputBuf,
-                               OMX_U32* aInBufSize, OMX_S32* aIsFirstBuffer,
+                               OMX_U32* aInBufSize, OMX_S32* aFrameCount,
                                OMX_AUDIO_PARAM_PCMMODETYPE* aAudioPcmParam,
                                OMX_AUDIO_PARAM_MP3TYPE* aAudioMp3Param,
                                OMX_BOOL aMarkerFlag,
@@ -102,7 +106,7 @@
     {
         //Initialization is required again when the client inbetween rewinds the input bitstream
         //Added to pass khronous conformance tests
-        if (*aIsFirstBuffer != 0)
+        if (*aFrameCount != 0)
         {
             e_equalization EqualizType = iMP3DecExt->equalizerType;
             iMP3DecExt->inputBufferCurrentLength = 0;
@@ -121,28 +125,38 @@
 
     if (OMX_FALSE == aMarkerFlag)
     {
-        //If the marker flag is not set, find out the frame boundaries
-        Status = iAudioMp3Decoder->SeekMp3Synchronization(iMP3DecExt);
-
-        if (1 == Status)
+        //If the input buffer has finished off, do not check the frame boundaries just return from here
+        //This will detect the EOS for without marker test case.
+        if (0 == iMP3DecExt->inputBufferCurrentLength)
         {
-            if (0 == iMP3DecExt->inputBufferCurrentLength)
-            {
-                //This indicates the case of corrupt frame, discard input bytes equal to inputBufferMaxLength
-                *aInBufSize -= iMP3DecExt->inputBufferMaxLength;
-                iInputUsedLength += iMP3DecExt->inputBufferMaxLength;
-                iMP3DecExt->inputBufferUsedLength += iMP3DecExt->inputBufferMaxLength;;
+            iInputUsedLength = 0;
+            return MP3DEC_INCOMPLETE_FRAME;
+        }
+        //If the marker flag is not set, find out the frame boundaries
+        else
+        {
+            Status = iAudioMp3Decoder->SeekMp3Synchronization(iMP3DecExt);
 
-                //return sucess so that we can continue decoding with rest of the buffer,
-                //after discarding the corrupted bit-streams
-                return MP3DEC_SUCCESS;
-            }
-            else
+            if (1 == Status)
             {
-                *aInputBuf += iInputUsedLength;
-                iMP3DecExt->inputBufferUsedLength = 0;
-                iInputUsedLength = 0;
-                return MP3DEC_INCOMPLETE_FRAME;
+                if (0 == iMP3DecExt->inputBufferCurrentLength)
+                {
+                    //This indicates the case of corrupt frame, discard input bytes equal to inputBufferMaxLength
+                    *aInBufSize -= iMP3DecExt->inputBufferMaxLength;
+                    iInputUsedLength += iMP3DecExt->inputBufferMaxLength;
+                    iMP3DecExt->inputBufferUsedLength += iMP3DecExt->inputBufferMaxLength;;
+
+                    //return sucess so that we can continue decoding with rest of the buffer,
+                    //after discarding the corrupted bit-streams
+                    return MP3DEC_SUCCESS;
+                }
+                else
+                {
+                    *aInputBuf += iInputUsedLength;
+                    iMP3DecExt->inputBufferUsedLength = 0;
+                    iInputUsedLength = 0;
+                    return MP3DEC_INCOMPLETE_FRAME;
+                }
             }
         }
     }
@@ -165,9 +179,8 @@
         *aOutputLength = iMP3DecExt->outputFrameSize * iMP3DecExt->num_channels;
 
         //After decoding the first frame, update all the input & output port settings
-        if (0 == *aIsFirstBuffer)
+        if (0 == *aFrameCount)
         {
-            (*aIsFirstBuffer)++;
 
             //Output Port Parameters
             aAudioPcmParam->nSamplingRate = iMP3DecExt->samplingRate;
@@ -180,6 +193,8 @@
             *aResizeFlag = OMX_TRUE;
         }
 
+        (*aFrameCount)++;
+
         return Status;
 
     }
@@ -200,6 +215,8 @@
         iInputUsedLength = 0;
     }
 
+    (*aFrameCount)++;
+
     return Status;
 
 }
diff --git a/codecs_v2/omx/omx_mp3/src/mp3_timestamp.cpp b/codecs_v2/omx/omx_mp3/src/mp3_timestamp.cpp
index c60f62b..54bd10c 100644
--- a/codecs_v2/omx/omx_mp3/src/mp3_timestamp.cpp
+++ b/codecs_v2/omx/omx_mp3/src/mp3_timestamp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/omx/omx_mp3/src/omx_mp3_component.cpp b/codecs_v2/omx/omx_mp3/src/omx_mp3_component.cpp
index 59dd27e..ad6e56f 100644
--- a/codecs_v2/omx/omx_mp3/src/omx_mp3_component.cpp
+++ b/codecs_v2/omx/omx_mp3/src/omx_mp3_component.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,26 +15,31 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#include "oscl_base.h"
 #include "pv_omxdefs.h"
-#include "oscl_types.h"
-#include <string.h>
 #include "omx_mp3_component.h"
 
-extern OMX_U32 g_ComponentIndex; // this is determined outside the component
-
 #if PROXY_INTERFACE
-
 #include "omx_proxy_interface.h"
-extern ProxyApplication_OMX* pProxyTerm[];
-
 #endif
 
+// Use default DLL entry point
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
 
 #define OMX_HALFRANGE_THRESHOLD 0x7FFFFFFF
 
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
 // This function is called by OMX_GetHandle and it creates an instance of the mp3 component AO
-OMX_ERRORTYPE Mp3OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData)
+OSCL_EXPORT_REF OMX_ERRORTYPE Mp3OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLibName);
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     OpenmaxMp3AO* pOpenmaxAOType;
     OMX_ERRORTYPE Status;
 
@@ -48,7 +53,7 @@
     }
 
     //Call the construct component to initialize OMX types
-    Status = pOpenmaxAOType->ConstructComponent(pAppData);
+    Status = pOpenmaxAOType->ConstructComponent(pAppData, pProxy);
 
     *pHandle = pOpenmaxAOType->GetOmxHandle();
 
@@ -57,8 +62,12 @@
 }
 
 // This function is called by OMX_FreeHandle when component AO needs to be destroyed
-OMX_ERRORTYPE Mp3OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle)
+OSCL_EXPORT_REF OMX_ERRORTYPE Mp3OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
 {
+    OSCL_UNUSED_ARG(aOmxLib);
+    OSCL_UNUSED_ARG(aOsclUuid);
+    OSCL_UNUSED_ARG(aRefCount);
+
     // get pointer to component AO
     OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)pHandle)->pComponentPrivate;
 
@@ -70,36 +79,86 @@
 
     return OMX_ErrorNone;
 }
+#if DYNAMIC_LOAD_OMX_MP3_COMPONENT
+class Mp3OmxSharedLibraryInterface: public OsclSharedLibraryInterface,
+            public OmxSharedLibraryInterface
+{
+    public:
+        static Mp3OmxSharedLibraryInterface *Instance()
+        {
+            static Mp3OmxSharedLibraryInterface omxinterface;
+            return &omxinterface;
+        };
 
+        OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
+        {
+            if (PV_OMX_MP3DEC_UUID == aOmxTypeId)
+            {
+                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&Mp3OmxComponentFactory));
+                }
+                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(&Mp3OmxComponentDestructor));
+                }
+            }
+            return NULL;
+        };
+        OsclAny *SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+    private:
+        Mp3OmxSharedLibraryInterface() {};
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return Mp3OmxSharedLibraryInterface::Instance();
+    }
+}
+
+#endif
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-OMX_ERRORTYPE OpenmaxMp3AO::ConstructComponent(OMX_PTR pAppData)
+OMX_ERRORTYPE OpenmaxMp3AO::ConstructComponent(OMX_PTR pAppData, OMX_PTR pProxy)
 {
-    Mp3ComponentPortType* pInPort, *pOutPort;
-    OMX_U32 ii;
+    ComponentPortType* pInPort, *pOutPort;
+    OMX_ERRORTYPE Status;
 
     iNumPorts = 2;
     iOmxComponent.nSize = sizeof(OMX_COMPONENTTYPE);
     iOmxComponent.pComponentPrivate = (OMX_PTR) this;  // pComponentPrivate points to THIS component AO class
     iOmxComponent.pApplicationPrivate = pAppData; // init the App data
 
+    ipComponentProxy = pProxy;
+
 
 #if PROXY_INTERFACE
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
 
-    iOmxComponent.SendCommand = WrapperSendCommand;
-    iOmxComponent.GetParameter = WrapperGetParameter;
-    iOmxComponent.SetParameter = WrapperSetParameter;
-    iOmxComponent.GetConfig = WrapperGetConfig;
-    iOmxComponent.SetConfig = WrapperSetConfig;
-    iOmxComponent.GetExtensionIndex = WrapperGetExtensionIndex;
-    iOmxComponent.GetState = WrapperGetState;
-    iOmxComponent.UseBuffer = WrapperUseBuffer;
-    iOmxComponent.AllocateBuffer = WrapperAllocateBuffer;
-    iOmxComponent.FreeBuffer = WrapperFreeBuffer;
-    iOmxComponent.EmptyThisBuffer = WrapperEmptyThisBuffer;
-    iOmxComponent.FillThisBuffer = WrapperFillThisBuffer;
+    iOmxComponent.SendCommand = OpenmaxMp3AO::BaseComponentProxySendCommand;
+    iOmxComponent.GetParameter = OpenmaxMp3AO::BaseComponentProxyGetParameter;
+    iOmxComponent.SetParameter = OpenmaxMp3AO::BaseComponentProxySetParameter;
+    iOmxComponent.GetConfig = OpenmaxMp3AO::BaseComponentProxyGetConfig;
+    iOmxComponent.SetConfig = OpenmaxMp3AO::BaseComponentProxySetConfig;
+    iOmxComponent.GetExtensionIndex = OpenmaxMp3AO::BaseComponentProxyGetExtensionIndex;
+    iOmxComponent.GetState = OpenmaxMp3AO::BaseComponentProxyGetState;
+    iOmxComponent.UseBuffer = OpenmaxMp3AO::BaseComponentProxyUseBuffer;
+    iOmxComponent.AllocateBuffer = OpenmaxMp3AO::BaseComponentProxyAllocateBuffer;
+    iOmxComponent.FreeBuffer = OpenmaxMp3AO::BaseComponentProxyFreeBuffer;
+    iOmxComponent.EmptyThisBuffer = OpenmaxMp3AO::BaseComponentProxyEmptyThisBuffer;
+    iOmxComponent.FillThisBuffer = OpenmaxMp3AO::BaseComponentProxyFillThisBuffer;
 
 #else
     iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_FALSE;
@@ -128,6 +187,9 @@
     iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_TRUE;
     iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
+    iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
+    iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
 
     if (ipAppPriv)
     {
@@ -135,60 +197,23 @@
         ipAppPriv = NULL;
     }
 
-    ipAppPriv = (Mp3PrivateType*) oscl_malloc(sizeof(Mp3PrivateType));
+    ipAppPriv = (ComponentPrivateType*) oscl_malloc(sizeof(ComponentPrivateType));
     if (NULL == ipAppPriv)
     {
         return OMX_ErrorInsufficientResources;
     }
 
-    if (iNumPorts)
+    //Construct base class now
+    Status = ConstructBaseComponent(pAppData);
+
+    if (OMX_ErrorNone != Status)
     {
-        if (ipPorts)
-        {
-            oscl_free(ipPorts);
-            ipPorts = NULL;
-        }
-
-        ipPorts = (Mp3ComponentPortType**) oscl_calloc(iNumPorts, sizeof(Mp3ComponentPortType*));
-        if (!ipPorts)
-        {
-            return OMX_ErrorInsufficientResources;
-        }
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii] = (Mp3ComponentPortType*) oscl_calloc(1, sizeof(Mp3ComponentPortType));
-            if (!ipPorts[ii])
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            ipPorts[ii]->TransientState = OMX_StateMax;
-            SetHeader(&ipPorts[ii]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            ipPorts[ii]->PortParam.nPortIndex = ii;
-
-            /** Allocate and initialize buffer Queue */
-            ipPorts[ii]->pBufferQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-
-            if (NULL == ipPorts[ii]->pBufferQueue)
-            {
-                return OMX_ErrorInsufficientResources;
-            }
-
-            QueueInit(ipPorts[ii]->pBufferQueue);
-
-            ipPorts[ii]->LoadedToIdleFlag = OMX_FALSE;
-            ipPorts[ii]->IdleToLoadedFlag = OMX_FALSE;
-
-        }
-
-        Mp3ComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-        Mp3ComponentSetNumBufferFlush(iNumPorts, -1, OMX_FALSE);
+        return Status;
     }
 
     /** Domain specific section for the ports. */
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
-    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = "audio/mpeg";
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"audio/mpeg";
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingMP3;
@@ -202,7 +227,7 @@
 
 
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.eDomain = OMX_PortDomainAudio;
-    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = "raw";
+    ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.cMIMEType = (OMX_STRING)"raw";
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.pNativeRender = 0;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.bFlagErrorConcealment = OMX_FALSE;
     ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->PortParam.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
@@ -220,6 +245,7 @@
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioMp3Param.nSampleRate = 44100;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioMp3Param.nAudioBandWidth = 0;
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioMp3Param.eChannelMode = OMX_AUDIO_ChannelModeStereo;
+    ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioMp3Param.eFormat = OMX_AUDIO_MP3StreamFormatMP1Layer3;
 
     ipPorts[OMX_PORT_INPUTPORT_INDEX]->AudioEqualizerType.sBandIndex.nMin = 0;
     //Taken these value from from mp3 decoder component
@@ -239,8 +265,8 @@
     iPortTypesParam.nPorts = 2;
     iPortTypesParam.nStartPortNumber = 0;
 
-    pInPort = (Mp3ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    pOutPort = (Mp3ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    pOutPort = (ComponentPortType*) ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
 
     SetHeader(&pInPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
     pInPort->AudioParam.nPortIndex = 0;
@@ -252,59 +278,7 @@
     pOutPort->AudioParam.nIndex = 0;
     pOutPort->AudioParam.eEncoding = OMX_AUDIO_CodingPCM;
 
-    iCodecReady = OMX_FALSE;
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-    ipTempInputBuffer = NULL;
-    iTempInputBufferLength = 0;
-    iNumInputBuffer = 0;
-    iPartialFrameAssembly = OMX_FALSE;
-    iEndofStream = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iNewOutBufRequired = OMX_TRUE;
     iOutputFrameLength = OUTPUT_BUFFER_SIZE_MP3;
-    iRepositionFlag = OMX_FALSE;
-
-    /* Initialize the asynchronous command Queue  */
-    if (ipCoreDescriptor)
-    {
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    ipCoreDescriptor = (CoreDescriptorType*) oscl_malloc(sizeof(CoreDescriptorType));
-    if (NULL == ipCoreDescriptor)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    ipCoreDescriptor->pMessageQueue = NULL;
-    ipCoreDescriptor->pMessageQueue = (QueueType*) oscl_malloc(sizeof(QueueType));
-    if (NULL == ipCoreDescriptor->pMessageQueue)
-    {
-        return OMX_ErrorInsufficientResources;
-    }
-
-    QueueInit(ipCoreDescriptor->pMessageQueue);
-
-    /** Default parameters setting */
-    iIsInit = OMX_FALSE;
-    iGroupPriority = 0;
-    iGroupID = 0;
-    ipMark = NULL;
-
-    SetHeader(&iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-
-    iOutBufferCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    iFirstFragment = OMX_FALSE;
-
-    //Will be used in case of partial frame assembly
-    ipInputCurrBuffer = NULL;
-    ipAppPriv->Mp3Handle = &iOmxComponent;
 
     if (ipMp3Dec)
     {
@@ -325,470 +299,109 @@
 
 #if PROXY_INTERFACE
 
-    pProxyTerm[g_ComponentIndex]->ComponentSendCommand = BaseComponentSendCommand;
-    pProxyTerm[g_ComponentIndex]->ComponentGetParameter = BaseComponentGetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentSetParameter = BaseComponentSetParameter;
-    pProxyTerm[g_ComponentIndex]->ComponentGetConfig = BaseComponentGetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentSetConfig = BaseComponentSetConfig;
-    pProxyTerm[g_ComponentIndex]->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
-    pProxyTerm[g_ComponentIndex]->ComponentGetState = BaseComponentGetState;
-    pProxyTerm[g_ComponentIndex]->ComponentUseBuffer = BaseComponentUseBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFreeBuffer = BaseComponentFreeBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
-    pProxyTerm[g_ComponentIndex]->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSendCommand = BaseComponentSendCommand;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetParameter = BaseComponentGetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetParameter = BaseComponentSetParameter;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetConfig = BaseComponentGetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentSetConfig = BaseComponentSetConfig;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetExtensionIndex = BaseComponentGetExtensionIndex;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentGetState = BaseComponentGetState;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentUseBuffer = BaseComponentUseBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentAllocateBuffer = BaseComponentAllocateBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFreeBuffer = BaseComponentFreeBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentEmptyThisBuffer = BaseComponentEmptyThisBuffer;
+    ((ProxyApplication_OMX*)ipComponentProxy)->ComponentFillThisBuffer = BaseComponentFillThisBuffer;
 
 #endif
     return OMX_ErrorNone;
 }
 
 
-/*********************
- *
- * Component verfication routines
- *
- **********************/
+/** This function is called by the omx core when the component
+	* is disposed by the IL client with a call to FreeHandle().
+	*/
 
-void OpenmaxMp3AO::SetHeader(OMX_PTR aHeader, OMX_U32 aSize)
+OMX_ERRORTYPE OpenmaxMp3AO::DestroyComponent()
 {
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-    *((OMX_U32*) aHeader) = aSize;
-
-    pVersion->s.nVersionMajor = SPECVERSIONMAJOR;
-    pVersion->s.nVersionMinor = SPECVERSIONMINOR;
-    pVersion->s.nRevision = SPECREVISION;
-    pVersion->s.nStep = SPECSTEP;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::CheckHeader(OMX_PTR aHeader, OMX_U32 aSize)
-{
-    OMX_VERSIONTYPE* pVersion = (OMX_VERSIONTYPE*)((OMX_STRING) aHeader + sizeof(OMX_U32));
-
-    if (NULL == aHeader)
+    if (iIsInit != OMX_FALSE)
     {
-        return OMX_ErrorBadParameter;
+        ComponentDeInit();
     }
 
-    if (*((OMX_U32*) aHeader) != aSize)
+    //Destroy the base class now
+    DestroyBaseComponent();
+
+    if (ipMp3Dec)
     {
-        return OMX_ErrorBadParameter;
+        OSCL_DELETE(ipMp3Dec);
+        ipMp3Dec = NULL;
     }
 
-    if (pVersion->s.nVersionMajor != SPECVERSIONMAJOR ||
-            pVersion->s.nVersionMinor != SPECVERSIONMINOR ||
-            pVersion->s.nRevision != SPECREVISION ||
-            pVersion->s.nStep != SPECSTEP)
+    if (ipAppPriv)
     {
-        return OMX_ErrorVersionMismatch;
+        ipAppPriv->CompHandle = NULL;
+
+        oscl_free(ipAppPriv);
+        ipAppPriv = NULL;
     }
 
     return OMX_ErrorNone;
 }
 
 
-/**
- * This function verify component state and structure header
- */
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentParameterSanityCheck(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_PTR pStructure,
-    OMX_IN  size_t size)
+void OpenmaxMp3AO::SyncWithInputTimestamp()
 {
-    if (iState != OMX_StateLoaded &&
-            iState != OMX_StateWaitForResources)
+    //Do not check for silence insertion if the clip is repositioned
+    if (OMX_FALSE == iRepositionFlag)
     {
-        return OMX_ErrorIncorrectStateOperation;
+        CheckForSilenceInsertion();
     }
 
-    if (nPortIndex >= iNumPorts)
+    /* Set the current timestamp equal to input buffer timestamp in case of
+     * a) All input frames
+     * b) First frame after repositioning */
+    if (OMX_FALSE == iSilenceInsertionInProgress || OMX_TRUE == iRepositionFlag)
     {
-        return OMX_ErrorBadPortIndex;
-    }
+        // Set the current timestamp equal to input buffer timestamp
+        iCurrentFrameTS.SetFromInputTimestamp(iFrameTimestamp);
 
-    return CheckHeader(pStructure, size);
-}
-
-/**
- * Set/Reset Port Flush Flag
- */
-void OpenmaxMp3AO::Mp3ComponentSetPortFlushFlag(OMX_S32 NumPorts, OMX_S32 index, OMX_BOOL value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    {
-        for (ii = 0; ii < NumPorts; ii++)
+        //Reset the flag back to false, once timestamp has been updated from input frame
+        if (OMX_TRUE == iRepositionFlag)
         {
-            ipPorts[ii]->IsPortFlushed = value;
+            iRepositionFlag = OMX_FALSE;
         }
     }
-    else
-    {
-        ipPorts[index]->IsPortFlushed = value;
-    }
-
-}
-
-/**
- * Set Number of Buffer Flushed with the value Specified
- */
-void OpenmaxMp3AO::Mp3ComponentSetNumBufferFlush(OMX_S32 NumPorts, OMX_S32 index, OMX_S32 value)
-{
-    OMX_S32 ii;
-
-    if (-1 == index)
-    { // For all ComponentPort
-        for (ii = 0; ii < NumPorts; ii++)
-        {
-            ipPorts[ii]->NumBufferFlushed = value;
-        }
-    }
-    else
-    {
-        ipPorts[index]->NumBufferFlushed = value;
-    }
 }
 
-
-/** This function assembles multiple input buffers into
-	* one frame with the marker flag OMX_BUFFERFLAG_ENDOFFRAME set
-	*/
-
-OMX_BOOL OpenmaxMp3AO::Mp3ComponentAssemblePartialFrames(OMX_BUFFERHEADERTYPE* aInputBuffer)
+void OpenmaxMp3AO::ResetComponent()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentAssemblePartialFrames IN"));
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    Mp3ComponentPortType* pInPort = ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-
-    ipMp3InputBuffer = aInputBuffer;
-
-    if (!iPartialFrameAssembly)
+    // reset decoder
+    if (ipMp3Dec)
     {
-        if (iNumInputBuffer > 0)
-        {
-            if (ipMp3InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-            {
-                iInputCurrLength = ipMp3InputBuffer->nFilledLen;
-                ipFrameDecodeBuffer = ipMp3InputBuffer->pBuffer + ipMp3InputBuffer->nOffset;
-                //capture the timestamp to be send to the corresponding output buffer
-                iFrameTimestamp = ipMp3InputBuffer->nTimeStamp;
-            }
-            else
-            {
-                iInputCurrLength = 0;
-                iPartialFrameAssembly = OMX_TRUE;
-                iFirstFragment = OMX_TRUE;
-                iFrameTimestamp = ipMp3InputBuffer->nTimeStamp;
-                ipFrameDecodeBuffer = ipInputCurrBuffer;
-            }
-
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentAssemblePartialFrames ERROR"));
-            return OMX_FALSE;
-        }
-
+        ipMp3Dec->ResetDecoder();
     }
 
-    //Assembling of partial frame will be done based on OMX_BUFFERFLAG_ENDOFFRAME flag marked
-    if (iPartialFrameAssembly)
-    {
-        while (iNumInputBuffer > 0)
-        {
-            if (OMX_FALSE == iFirstFragment)
-            {
-                /* If the timestamp of curr fragment doesn't match with previous,
-                 * discard the previous fragments & start reconstructing from new
-                 */
-                if (iFrameTimestamp != ipMp3InputBuffer->nTimeStamp)
-                {
-                    iInputCurrLength = 0;
-                    iPartialFrameAssembly = OMX_TRUE;
-                    iFirstFragment = OMX_TRUE;
-                    iFrameTimestamp = ipMp3InputBuffer->nTimeStamp;
-                    ipFrameDecodeBuffer = ipInputCurrBuffer;
-                }
-            }
-
-            if ((ipMp3InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) != 0)
-            {
-                break;
-            }
-
-            iInputCurrLength += ipMp3InputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipMp3InputBuffer->pBuffer + ipMp3InputBuffer->nOffset), ipMp3InputBuffer->nFilledLen); // copy buffer data
-            ipFrameDecodeBuffer += ipMp3InputBuffer->nFilledLen; // move the ptr
-
-            ipMp3InputBuffer->nFilledLen = 0;
-
-            Mp3ComponentReturnInputBuffer(ipMp3InputBuffer, pInPort);
-
-            iFirstFragment = OMX_FALSE;
-
-            if (iNumInputBuffer > 0)
-            {
-                ipMp3InputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (ipMp3InputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentAssemblePartialFrames EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        // if we broke out of the while loop because of lack of buffers, then return and wait for more input buffers
-        if (0 == iNumInputBuffer)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentAssemblePartialFrames OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            // we have found the buffer that is the last piece of the frame.
-            // Copy the buffer, but do not release it yet (this will be done after decoding for consistency)
-
-            iInputCurrLength += ipMp3InputBuffer->nFilledLen;
-            oscl_memcpy(ipFrameDecodeBuffer, (ipMp3InputBuffer->pBuffer + ipMp3InputBuffer->nOffset), ipMp3InputBuffer->nFilledLen); // copy buffer data
-            ipFrameDecodeBuffer += ipMp3InputBuffer->nFilledLen; // move the ptr
-
-            ipFrameDecodeBuffer = ipInputCurrBuffer; // reset the pointer back to beginning of assembly buffer
-            iPartialFrameAssembly = OMX_FALSE; // we have finished with assembling the frame, so this is not needed any more
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentAssemblePartialFrames OUT"));
-    return OMX_TRUE;
+    //Set this length to zero for flushing the current input buffer
+    ipMp3Dec->iInputUsedLength = 0;
+    //ipMp3Dec->iInitFlag = 0;
 }
 
 
-/** This is the central function for buffers processing and decoding.
-	* It is called through the Run() of active object when the component is in executing state
-	* and is signalled each time a new buffer is available on the given ports
-	* This function will process the input buffers & return output buffers
-	*/
-
-void OpenmaxMp3AO::Mp3ComponentBufferMgmtFunction()
+void OpenmaxMp3AO::ProcessInBufferFlag()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentBufferMgmtFunction IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    Mp3ComponentPortType* pInPort = (Mp3ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-    OMX_BOOL PartialFrameReturn, Status;
-
-    /* Don't dequeue any further buffer after endofstream buffer has been dequeued
-     * till we send the callback and reset the flag back to false
-     */
-    if (OMX_FALSE == iEndofStream)
-    {
-        //More than one frame can't be dequeued in case of outbut blocked
-        if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
-        {
-            ipMp3InputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-
-            if (ipMp3InputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentBufferMgmtFunction EndOfStream arrived"));
-                iEndofStream = OMX_TRUE;
-            }
-
-            if (ipMp3InputBuffer->nFilledLen != 0)
-            {
-                if (0 == iFrameCount)
-                {
-                    //Set the marker flag (iEndOfFrameFlag) if first frame has the EnfOfFrame flag marked.
-                    if (ipMp3InputBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentBufferMgmtFunction EndOfFrame flag present"));
-                        iEndOfFrameFlag = OMX_TRUE;
-                    }
-
-                    //Get the initial default value for the milli seconds per frame
-                    iOutputMilliSecPerFrame = iCurrentFrameTS.GetFrameDuration();
-                }
-
-                /* This condition will be true if OMX_BUFFERFLAG_ENDOFFRAME flag is
-                 *  not marked in all the input buffers
-                 */
-                if (!iEndOfFrameFlag)
-                {
-                    Status = Mp3BufferMgmtWithoutMarker(ipMp3InputBuffer);
-                    if (OMX_FALSE == Status)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-
-                }
-                //If OMX_BUFFERFLAG_ENDOFFRAME flag is marked, come here
-                else
-                {
-                    PartialFrameReturn = Mp3ComponentAssemblePartialFrames(ipMp3InputBuffer);
-                    if (OMX_FALSE == PartialFrameReturn)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentBufferMgmtFunction OUT"));
-                        return;
-                    }
-                    iIsInputBufferEnded = OMX_FALSE;
-                }
-
-                ipTargetComponent = (OMX_COMPONENTTYPE*) ipMp3InputBuffer->hMarkTargetComponent;
-
-                iTargetMarkData = ipMp3InputBuffer->pMarkData;
-                if (ipTargetComponent == (OMX_COMPONENTTYPE*) pHandle)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventMark,
-                     1,
-                     0,
-                     ipMp3InputBuffer->pMarkData);
-                }
-
-
-                //Do not check for silence insertion if the clip is repositioned
-                if (OMX_FALSE == iRepositionFlag)
-                {
-                    CheckForSilenceInsertion();
-                }
-
-                /* Set the current timestamp equal to input buffer timestamp in case of
-                 * a) All input frames
-                 * b) First frame after repositioning */
-                if (OMX_FALSE == iSilenceInsertionInProgress || OMX_TRUE == iRepositionFlag)
-                {
-                    // Set the current timestamp equal to input buffer timestamp
-                    iCurrentFrameTS.SetFromInputTimestamp(iFrameTimestamp);
-
-                    //Reset the flag back to false, once timestamp has been updated from input frame
-                    if (OMX_TRUE == iRepositionFlag)
-                    {
-                        iRepositionFlag = OMX_FALSE;
-                    }
-                }
-
-
-            }	//end braces for if (ipMp3InputBuffer->nFilledLen != 0)
-            else
-            {
-                Mp3ComponentReturnInputBuffer(ipMp3InputBuffer, pInPort);
-            }
-
-        }	//end braces for if ((OMX_TRUE == iIsInputBufferEnded) && (GetQueueNumElem(pInputQueue) > 0))
-    }	//if (OMX_FALSE == iEndofStream)
-
-    Mp3Decode();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentBufferMgmtFunction OUT"));
-    return;
+    iIsInputBufferEnded = OMX_FALSE;
 }
 
 
-OMX_BOOL OpenmaxMp3AO::Mp3BufferMgmtWithoutMarker(OMX_BUFFERHEADERTYPE* pMp3InputBuffer)
+void OpenmaxMp3AO::ProcessData()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3BufferMgmtWithoutMarker IN"));
-
-
-    Mp3ComponentPortType*	pInPort = (Mp3ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-    ipMp3InputBuffer = pMp3InputBuffer;
-
-    /* Assembling of partial frame will be done based on max input buf size
-     * If Flushport flag is true, that means its not a partial frame
-     * but an unconsumed frame, process it independently
-     * Same is true for endofstream condition, process the buffer independently
-     */
-    if ((ipMp3InputBuffer->nFilledLen < ipMp3InputBuffer->nAllocLen)
-            && (iEndofStream != OMX_TRUE) && (OMX_FALSE == iFlushPortFlag))
-    {
-        if (!iPartialFrameAssembly)
-        {
-            iInputCurrLength = 0;
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-        }
-
-        while (iNumInputBuffer > 0)
-        {
-            oscl_memcpy(ipFrameDecodeBuffer, (ipMp3InputBuffer->pBuffer + ipMp3InputBuffer->nOffset), ipMp3InputBuffer->nFilledLen);
-            ipFrameDecodeBuffer += ipMp3InputBuffer->nFilledLen; // move the ptr
-
-            iFrameTimestamp = ipMp3InputBuffer->nTimeStamp;
-
-            if (((iInputCurrLength += ipMp3InputBuffer->nFilledLen) >= ipMp3InputBuffer->nAllocLen)
-                    || OMX_TRUE == iEndofStream)
-            {
-                break;
-            }
-
-            //Set the filled len to zero to indiacte buffer is fully consumed
-            ipMp3InputBuffer->nFilledLen = 0;
-            Mp3ComponentReturnInputBuffer(ipMp3InputBuffer, pInPort);
-
-            if (iNumInputBuffer > 0)
-            {
-                ipMp3InputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-                if (ipMp3InputBuffer->nFlags & OMX_BUFFERFLAG_EOS)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3BufferMgmtWithoutMarker EndOfStream arrived"));
-                    iEndofStream = OMX_TRUE;
-                }
-            }
-        }
-
-        if (((iInputCurrLength < ipMp3InputBuffer->nAllocLen)) && OMX_TRUE != iEndofStream)
-        {
-            iPartialFrameAssembly = OMX_TRUE;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3BufferMgmtWithoutMarker OUT"));
-            return OMX_FALSE;
-        }
-        else
-        {
-            ipFrameDecodeBuffer = ipInputCurrBuffer;
-            iPartialFrameAssembly = OMX_FALSE;
-            iIsInputBufferEnded = OMX_FALSE;
-        }
-    }
-    else
-    {
-        if (iNumInputBuffer > 0)
-        {
-            iInputCurrLength = ipMp3InputBuffer->nFilledLen;
-            ipFrameDecodeBuffer = ipMp3InputBuffer->pBuffer + ipMp3InputBuffer->nOffset;
-            iFrameTimestamp = ipMp3InputBuffer->nTimeStamp;
-            iIsInputBufferEnded = OMX_FALSE;
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3BufferMgmtWithoutMarker OUT"));
-            return OMX_FALSE; // nothing to decode
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3BufferMgmtWithoutMarker OUT"));
-    return OMX_TRUE;
-
-}
-
-
-void OpenmaxMp3AO::Mp3Decode()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3DecodeWithMarker IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData IN"));
 
     QueueType* pInputQueue  = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
 
-    Mp3ComponentPortType* pInPort = (Mp3ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-    Mp3ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType* pInPort = (ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
     OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
 
     OMX_U8*	pOutBuffer;
@@ -800,7 +413,6 @@
 
     if ((!iIsInputBufferEnded) || iEndofStream)
     {
-
         if (OMX_TRUE == iSilenceInsertionInProgress)
         {
             DoSilenceInsertion();
@@ -810,22 +422,79 @@
                 return;
             }
         }
+
         //Check whether prev output bufer has been released or not
         if (OMX_TRUE == iNewOutBufRequired)
         {
-
             //Check whether a new output buffer is available or not
             if (0 == (GetQueueNumElem(pOutputQueue)))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3DecodeWithMarker OUT output buffer unavailable"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData OUT output buffer unavailable"));
                 return;
             }
 
-            ipMp3OutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipMp3OutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData Error, Output Buffer Dequeue returned NULL, OUT"));
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
+
             //Set the current timestamp to the output buffer timestamp
-            ipMp3OutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+            ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+
+            // Copy the output buffer that was stored locally before dynamic port reconfiguration
+            // in the new omx buffer received.
+            if (OMX_TRUE == iSendOutBufferAfterPortReconfigFlag)
+            {
+                if ((ipTempOutBufferForPortReconfig)
+                        && (iSizeOutBufferForPortReconfig <= ipOutputBuffer->nAllocLen))
+                {
+                    oscl_memcpy(ipOutputBuffer->pBuffer, ipTempOutBufferForPortReconfig, iSizeOutBufferForPortReconfig);
+                    ipOutputBuffer->nFilledLen = iSizeOutBufferForPortReconfig;
+                    ipOutputBuffer->nTimeStamp = iTimestampOutBufferForPortReconfig;
+                }
+
+                iSendOutBufferAfterPortReconfigFlag = OMX_FALSE;
+
+                //Send the output buffer back only when it has become full
+                if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
+                {
+                    ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                }
+
+                //Free the temp output buffer
+                if (ipTempOutBufferForPortReconfig)
+                {
+                    oscl_free(ipTempOutBufferForPortReconfig);
+                    ipTempOutBufferForPortReconfig = NULL;
+                    iSizeOutBufferForPortReconfig = 0;
+                }
+
+                //Dequeue new output buffer if required to continue decoding the next frame
+                if (OMX_TRUE == iNewOutBufRequired)
+                {
+                    if (0 == (GetQueueNumElem(pOutputQueue)))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData OUT, output buffer unavailable"));
+                        return;
+                    }
+
+                    ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+                    if (NULL == ipOutputBuffer)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData Error, Output Buffer Dequeue returned NULL, OUT"));
+                        return;
+                    }
+
+                    ipOutputBuffer->nFilledLen = 0;
+                    iNewOutBufRequired = OMX_FALSE;
+
+                    ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+                }
+            }
         }
 
         /* Code for the marking buffer. Takes care of the OMX_CommandMarkBuffer
@@ -833,21 +502,21 @@
          */
         if (ipMark != NULL)
         {
-            ipMp3OutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
-            ipMp3OutputBuffer->pMarkData = ipMark->pMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipMark->hMarkTargetComponent;
+            ipOutputBuffer->pMarkData = ipMark->pMarkData;
             ipMark = NULL;
         }
 
         if (ipTargetComponent != NULL)
         {
-            ipMp3OutputBuffer->hMarkTargetComponent = ipTargetComponent;
-            ipMp3OutputBuffer->pMarkData = iTargetMarkData;
+            ipOutputBuffer->hMarkTargetComponent = ipTargetComponent;
+            ipOutputBuffer->pMarkData = iTargetMarkData;
             ipTargetComponent = NULL;
 
         }
         //Mark buffer code ends here
 
-        pOutBuffer = &ipMp3OutputBuffer->pBuffer[ipMp3OutputBuffer->nFilledLen];
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
         OutputLength = 0;
 
         /* Copy the left-over data from last input buffer that is stored in temporary
@@ -873,7 +542,6 @@
                                                 iEndOfFrameFlag,
                                                 &ResizeNeeded);
 
-
         if (ResizeNeeded == OMX_TRUE)
         {
             if (0 != OutputLength)
@@ -886,16 +554,39 @@
                 iCurrentFrameTS.SetParameters(ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->AudioPcmMode.nSamplingRate, iSamplesPerFrame);
                 iOutputMilliSecPerFrame = iCurrentFrameTS.GetFrameDuration();
 
-                //Set the current timestamp to the output buffer timestamp for the first output frame
-                //Later it will be done at the time of dequeue
-                ipMp3OutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
             }
 
-            // send port settings changed event
-            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->Mp3Handle;
-
+            // set the flag to disable further processing until Client reacts to this
+            //	by doing dynamic port reconfiguration
             iResizePending = OMX_TRUE;
 
+            /* Do not return the output buffer generated yet, store it locally
+             * and wait for the dynamic port reconfig to complete */
+            if ((NULL == ipTempOutBufferForPortReconfig))
+            {
+                ipTempOutBufferForPortReconfig = (OMX_U8*) oscl_malloc(sizeof(uint8) * OutputLength * 2);
+                if (NULL == ipTempOutBufferForPortReconfig)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData error, insufficient resources"));
+                    return;
+                }
+            }
+
+            //Copy the omx output buffer to the temporary internal buffer
+            oscl_memcpy(ipTempOutBufferForPortReconfig, pOutBuffer, OutputLength * 2);
+            iSizeOutBufferForPortReconfig = OutputLength * 2;
+
+            //Set the current timestamp to the output buffer timestamp for the first output frame
+            //Later it will be done at the time of dequeue
+            iTimestampOutBufferForPortReconfig = iCurrentFrameTS.GetConvertedTs();
+
+            iCurrentFrameTS.UpdateTimestamp(iSamplesPerFrame);
+            //Make this length 0 so that no output buffer is returned by the component
+            OutputLength = 0;
+
+            // send port settings changed event
+            OMX_COMPONENTTYPE* pHandle = (OMX_COMPONENTTYPE*) ipAppPriv->CompHandle;
+
             (*(ipCallbacks->EventHandler))
             (pHandle,
              iCallbackData,
@@ -905,9 +596,9 @@
              NULL);
         }
 
-        ipMp3OutputBuffer->nFilledLen += OutputLength * 2;
+        ipOutputBuffer->nFilledLen += OutputLength * 2;
         //offset not required in our case, set it to zero
-        ipMp3OutputBuffer->nOffset = 0;
+        ipOutputBuffer->nOffset = 0;
 
         if (OutputLength > 0)
         {
@@ -926,7 +617,7 @@
              */
             if (MP3DEC_SUCCESS != DecodeReturn)
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3DecodeWithMarker EOS callback send"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData EOS callback send"));
 
                 (*(ipCallbacks->EventHandler))
                 (pHandle,
@@ -938,10 +629,12 @@
 
                 iEndofStream = OMX_FALSE;
 
-                ipMp3OutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
+                ipOutputBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
 
-                Mp3ComponentReturnOutputBuffer(ipMp3OutputBuffer, pOutPort);
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3DecodeWithMarker OUT"));
+                ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+                ipOutputBuffer = NULL;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData OUT"));
 
                 return;
             }
@@ -950,7 +643,7 @@
 
         if (MP3DEC_SUCCESS == DecodeReturn)
         {
-            ipMp3InputBuffer->nFilledLen = iInputCurrLength;
+            ipInputBuffer->nFilledLen = iInputCurrLength;
         }
         else if (MP3DEC_INCOMPLETE_FRAME == DecodeReturn)
         {
@@ -960,16 +653,17 @@
              */
             oscl_memcpy(ipTempInputBuffer, ipFrameDecodeBuffer, iInputCurrLength);
             iTempInputBufferLength = iInputCurrLength;
-            ipMp3InputBuffer->nFilledLen = 0;
+            ipInputBuffer->nFilledLen = 0;
             iInputCurrLength = 0;
         }
         else
         {
             //bitstream error, discard the current data as it can't be decoded further
-            ipMp3InputBuffer->nFilledLen = 0;
+            ipInputBuffer->nFilledLen = 0;
+            iInputCurrLength = 0;
 
             //Report it to the client via a callback
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3Decode ErrorStreamCorrupt callback send"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData ErrorStreamCorrupt callback send"));
 
             (*(ipCallbacks->EventHandler))
             (pHandle,
@@ -982,18 +676,19 @@
         }
 
         //Return the input buffer if it has been consumed fully by the decoder
-        if (0 == ipMp3InputBuffer->nFilledLen)
+        if (0 == ipInputBuffer->nFilledLen)
         {
-            Mp3ComponentReturnInputBuffer(ipMp3InputBuffer, pInPort);
+            ReturnInputBuffer(ipInputBuffer, pInPort);
+            ipInputBuffer = NULL;
             iIsInputBufferEnded = OMX_TRUE;
-            iInputCurrLength = 0; //make sure to reset to prevent eos issue
+            iInputCurrLength = 0;
         }
 
         //Send the output buffer back when it has become full
-        if (((ipMp3OutputBuffer->nAllocLen - ipMp3OutputBuffer->nFilledLen) < (iOutputFrameLength))
-                || (OMX_TRUE == ResizeNeeded))
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < (iOutputFrameLength))
         {
-            Mp3ComponentReturnOutputBuffer(ipMp3OutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         /* If there is some more processing left with current buffers, re-schedule the AO
@@ -1008,468 +703,28 @@
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3DecodeWithMarker OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ProcessData OUT"));
     return;
 }
 
 
-void OpenmaxMp3AO::Mp3ComponentReturnInputBuffer(OMX_BUFFERHEADERTYPE* pMp3InputBuffer, Mp3ComponentPortType *pPort)
+void OpenmaxMp3AO::ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
 {
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    if (iNumInputBuffer)
-    {
-        iNumInputBuffer--;
-    }
-
-    //Callback for releasing the input buffer
-    (*(ipCallbacks->EmptyBufferDone))
-    (pHandle, iCallbackData, pMp3InputBuffer);
-
-    pMp3InputBuffer = NULL;
-
+    *aRoleString = (OMX_STRING)"audio_decoder.mp3";
 }
 
-/**
- * Returns Output Buffer back to the IL client
- */
-void OpenmaxMp3AO::Mp3ComponentReturnOutputBuffer(OMX_BUFFERHEADERTYPE* pMp3OutputBuffer,
-        Mp3ComponentPortType *pPort)
-{
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    //Callback for sending back the output buffer
-    (*(ipCallbacks->FillBufferDone))
-    (pHandle, iCallbackData, pMp3OutputBuffer);
-
-    if (iOutBufferCount)
-    {
-        iOutBufferCount--;
-    }
-
-    pPort->NumBufferFlushed++;
-    iNewOutBufRequired = OMX_TRUE;
-}
-
-/** The panic function that exits from the application.
- */
-OMX_S32 OpenmaxMp3AO::Mp3ComponentPanic()
-{
-    OSCL_ASSERT(false);
-    OsclError::Panic("PVERROR", OsclErrGeneral);
-    return 0;
-}
-
-
-/** Flushes all the buffers under processing by the given port.
-	* This function is called due to a state change of the component, typically
-	* @param Component the component which owns the port to be flushed
-	* @param PortIndex the ID of the port to be flushed
-	*/
-
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentFlushPort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentFlushPort IN"));
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-
-    QueueType* pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-    QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-
-    OMX_BUFFERHEADERTYPE* pOutputBuff;
-    OMX_BUFFERHEADERTYPE* pInputBuff;
-
-    if (OMX_PORT_INPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        while ((GetQueueNumElem(pInputQueue) > 0))
-        {
-            pInputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pInputQueue);
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, pInputBuff);
-            iNumInputBuffer--;
-        }
-
-        if (iNumInputBuffer > 0 && ipMp3InputBuffer && (OMX_FALSE == iIsInputBufferEnded))
-        {
-            ipMp3InputBuffer->nFilledLen = 0;
-            (*(ipCallbacks->EmptyBufferDone))
-            (pHandle, iCallbackData, ipMp3InputBuffer);
-            iNumInputBuffer--;
-
-            iIsInputBufferEnded = OMX_TRUE;
-            iInputCurrLength = 0;
-            ipMp3Dec->iInputUsedLength = 0;
-        }
-
-    }
-
-    if (OMX_PORT_OUTPUTPORT_INDEX == PortIndex || OMX_PORT_ALLPORT_INDEX == PortIndex)
-    {
-        if ((OMX_FALSE == iNewOutBufRequired) && (iOutBufferCount > 0))
-        {
-            if (ipMp3OutputBuffer)
-            {
-                (*(ipCallbacks->FillBufferDone))
-                (pHandle, iCallbackData, ipMp3OutputBuffer);
-                iOutBufferCount--;
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-
-        while ((GetQueueNumElem(pOutputQueue) > 0))
-        {
-            pOutputBuff = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            pOutputBuff->nFilledLen = 0;
-            (*(ipCallbacks->FillBufferDone))
-            (pHandle, iCallbackData, pOutputBuff);
-            iOutBufferCount--;
-        }
-
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentFlushPort OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** This function is called by the omx core when the component
-	* is disposed by the IL client with a call to FreeHandle().
-	* \param Component, the component to be disposed
-	*/
-
-OMX_ERRORTYPE OpenmaxMp3AO::DestroyComponent()
-{
-    OMX_U32 ii;
-
-    if (iIsInit != OMX_FALSE)
-    {
-        Mp3ComponentDeInit();
-    }
-
-    /*Deinitialize and free ports semaphores and Queue*/
-    for (ii = 0; ii < iNumPorts; ii++)
-    {
-        if (ipPorts[ii]->pBufferQueue != NULL)
-        {
-            QueueDeinit(ipPorts[ii]->pBufferQueue);
-            oscl_free(ipPorts[ii]->pBufferQueue);
-            ipPorts[ii]->pBufferQueue = NULL;
-        }
-        /*Free port*/
-        if (ipPorts[ii] != NULL)
-        {
-            oscl_free(ipPorts[ii]);
-            ipPorts[ii] = NULL;
-        }
-    }
-
-    if (ipPorts)
-    {
-        oscl_free(ipPorts);
-        ipPorts = NULL;
-    }
-
-    iState = OMX_StateLoaded;
-
-    if (ipInputCurrBuffer)
-    {
-        oscl_free(ipInputCurrBuffer);
-        ipInputCurrBuffer = NULL;
-    }
-
-    if (ipTempInputBuffer)
-    {
-        oscl_free(ipTempInputBuffer);
-        ipTempInputBuffer = NULL;
-    }
-
-    if (ipMp3Dec)
-    {
-        OSCL_DELETE(ipMp3Dec);
-        ipMp3Dec = NULL;
-    }
-
-    if (ipCoreDescriptor != NULL)
-    {
-
-        if (ipCoreDescriptor->pMessageQueue != NULL)
-        {
-            /* De-initialize the asynchronous command queue */
-            QueueDeinit(ipCoreDescriptor->pMessageQueue);
-            oscl_free(ipCoreDescriptor->pMessageQueue);
-            ipCoreDescriptor->pMessageQueue = NULL;
-        }
-
-        oscl_free(ipCoreDescriptor);
-        ipCoreDescriptor = NULL;
-    }
-
-    if (ipAppPriv)
-    {
-        ipAppPriv->Mp3Handle = NULL;
-
-        oscl_free(ipAppPriv);
-        ipAppPriv = NULL;
-    }
-
-    return OMX_ErrorNone;
-}
-
-
-/**
- * Disable Single Port
- */
-void OpenmaxMp3AO::Mp3ComponentDisableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_FALSE;
-
-    if (PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->IdleToLoadedFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_FALSE;
-        }
-    }
-
-    ipPorts[PortIndex]->NumBufferFlushed = 0;
-}
-
-
-/** Disables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be disabled
-	* @param PortIndex the ID of the port to be disabled
-	*/
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentDisablePort(OMX_S32 PortIndex)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDisablePort IN"));
-    OMX_U32 ii;
-
-    if (-1 == PortIndex)
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_TRUE;
-        }
-
-        /*Flush all ports*/
-        Mp3ComponentFlushPort(PortIndex);
-
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            ipPorts[ii]->IsPortFlushed = OMX_FALSE;
-        }
-    }
-    else
-    {
-        /*Flush the port specified*/
-        ipPorts[PortIndex]->IsPortFlushed = OMX_TRUE;
-        Mp3ComponentFlushPort(PortIndex);
-        ipPorts[PortIndex]->IsPortFlushed = OMX_FALSE;
-    }
-
-    /*Disable ports*/
-    if (PortIndex != -1)
-    {
-        Mp3ComponentDisableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            Mp3ComponentDisableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDisablePort OUT"));
-
-    return OMX_ErrorNone;
-}
-
-/**
- * Enable Single Port
- */
-void OpenmaxMp3AO::Mp3ComponentEnableSinglePort(OMX_U32 PortIndex)
-{
-    ipPorts[PortIndex]->PortParam.bEnabled = OMX_TRUE;
-
-    if (!PORT_IS_POPULATED(ipPorts[PortIndex]) && OMX_TRUE == iIsInit)
-    {
-        if (OMX_FALSE == ipPorts[PortIndex]->LoadedToIdleFlag)
-        {
-            iStateTransitionFlag = OMX_TRUE;
-            return;
-        }
-        else
-        {
-            ipPorts[PortIndex]->PortParam.bPopulated = OMX_TRUE;
-        }
-    }
-}
-
-/** Enables the specified port. This function is called due to a request by the IL client
-	* @param Component the component which owns the port to be enabled
-	* @param PortIndex the ID of the port to be enabled
-	*/
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentEnablePort(OMX_S32 PortIndex)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentEnablePort IN"));
-
-    OMX_U32 ii;
-
-    /*Enable port/s*/
-    if (PortIndex != -1)
-    {
-        Mp3ComponentEnableSinglePort(PortIndex);
-    }
-    else
-    {
-        for (ii = 0; ii < iNumPorts; ii++)
-        {
-            Mp3ComponentEnableSinglePort(ii);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentEnablePort OUT"));
-    return OMX_ErrorNone;
-}
-
-//Not implemented & supported in case of base profile components
-
-void OpenmaxMp3AO::Mp3ComponentGetRolesOfComponent(OMX_STRING* aRoleString)
-{
-    *aRoleString = "audio_decoder.mp3";
-}
-
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentTunnelRequest(
-    OMX_IN  OMX_HANDLETYPE hComp,
-    OMX_IN  OMX_U32 nPort,
-    OMX_IN  OMX_HANDLETYPE hTunneledComp,
-    OMX_IN  OMX_U32 nTunneledPort,
-    OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType)
-{
-    return OMX_ErrorNotImplemented;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState)
-{
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-
-    pOpenmaxAOType->GetState(pState);
-
-    return OMX_ErrorNone;
-}
-
-void OpenmaxMp3AO::GetState(OMX_OUT OMX_STATETYPE* pState)
-{
-    *pState = iState;
-}
-
-
 
 //Active object constructor
-OpenmaxMp3AO::OpenmaxMp3AO() :
-        OsclActiveObject(OsclActiveObject::EPriorityNominal, "OMXMp3Dec")
+OpenmaxMp3AO::OpenmaxMp3AO()
 {
-
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXAudioDecNode");
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : constructed"));
-
-    //Flag to call BufferMgmtFunction in the Run() when the component state is executing
-    iBufferExecuteFlag = OMX_FALSE;
-    ipAppPriv = NULL;
-
-    ipCallbacks = NULL;
-    iCallbackData = NULL;
-    iState = OMX_StateLoaded;
-
-
-    ipCoreDescriptor = NULL;
-    iNumInputBuffer = 0;
-
-    ipFrameDecodeBuffer = NULL;
-    iPartialFrameAssembly = OMX_FALSE;
-    iIsInputBufferEnded = OMX_TRUE;
-    iEndofStream = OMX_FALSE;
-    ipTempInputBuffer = NULL;
-
-    ipTargetComponent = NULL;
-    iTargetMarkData = NULL;
-    iNewOutBufRequired = OMX_TRUE;
-
-    iTempConsumedLength = 0;
-    iOutBufferCount = 0;
-    iCodecReady = OMX_FALSE;
-    ipInputCurrBuffer = NULL;
-    iInputCurrLength = 0;
-    iFrameCount = 0;
-    iStateTransitionFlag = OMX_FALSE;
-    iFlushPortFlag = OMX_FALSE;
-    iEndOfFrameFlag = OMX_FALSE;
-    ipMp3InputBuffer = NULL;
-    ipMp3OutputBuffer = NULL;
-
-
-    iFirstFragment = OMX_FALSE;
-    iResizePending = OMX_FALSE;
-    iFrameTimestamp = 0;
-    iSilenceInsertionInProgress = OMX_FALSE;
-
-    iNumPorts = 0;
-    ipPorts = NULL;
-
-    //Indicate whether component has been already initialized */
-    iIsInit = OMX_FALSE;
-
-    iGroupPriority = 0;
-    iGroupID = 0;
-
-    ipMark = NULL;
-
     ipMp3Dec = NULL;
 
     if (!IsAdded())
     {
         AddToScheduler();
     }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : constructed"));
 }
 
 
@@ -1487,15 +742,15 @@
 
 /** The Initialization function
  */
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentInit()
+OMX_ERRORTYPE OpenmaxMp3AO::ComponentInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ComponentInit IN"));
 
-    OMX_BOOL Status;
+    OMX_BOOL Status = OMX_FALSE;
 
     if (OMX_TRUE == iIsInit)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentInit error incorrect operation"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ComponentInit error incorrect operation"));
         return OMX_ErrorIncorrectStateOperation;
     }
     iIsInit = OMX_TRUE;
@@ -1511,7 +766,7 @@
     //Used in dynamic port reconfiguration
     iFrameCount = 0;
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ComponentInit OUT"));
 
     if (OMX_TRUE == Status)
     {
@@ -1526,9 +781,9 @@
 /** This function is called upon a transition to the idle or invalid state.
  *  Also it is called by the Mp3ComponentDestructor() function
  */
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentDeInit()
+OMX_ERRORTYPE OpenmaxMp3AO::ComponentDeInit()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDeInit IN"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ComponentDeInit IN"));
 
     iIsInit = OMX_FALSE;
 
@@ -1538,2002 +793,13 @@
         iCodecReady = OMX_FALSE;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDeInit OUT"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : ComponentDeInit OUT"));
 
     return OMX_ErrorNone;
 
 }
 
 
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentGetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return Status;
-
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::GetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter IN"));
-
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef;
-    OMX_PORT_PARAM_TYPE* pPortDomains;
-    OMX_U32 PortIndex;
-
-    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
-    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
-    OMX_AUDIO_PARAM_MP3TYPE* pAudioMp3;
-    OMX_AUDIO_CONFIG_EQUALIZERTYPE* pAudioEqualizer;
-
-    Mp3ComponentPortType* pComponentPort;
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamPriorityMgmt:
-        {
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            SetHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE));
-            pPrioMgmt->nGroupPriority = iGroupPriority;
-            pPrioMgmt->nGroupID = iGroupID;
-        }
-        break;
-
-        case OMX_IndexParamAudioInit:
-        {
-            SetHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            oscl_memcpy(ComponentParameterStructure, &iPortTypesParam, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-
-        //Following 3 cases have a single common piece of code to be executed
-        case OMX_IndexParamVideoInit:
-        case OMX_IndexParamImageInit:
-        case OMX_IndexParamOtherInit:
-        {
-            pPortDomains = (OMX_PORT_PARAM_TYPE*) ComponentParameterStructure;
-            SetHeader(pPortDomains, sizeof(OMX_PORT_PARAM_TYPE));
-            pPortDomains->nPorts = 0;
-            pPortDomains->nStartPortNumber = 0;
-        }
-        break;
-
-        case OMX_IndexParamAudioPortFormat:
-        {
-            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            //Added to pass parameter test
-            if (pAudioPortFormat->nIndex > ipPorts[pAudioPortFormat->nPortIndex]->AudioParam.nIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error index out of range"));
-                return OMX_ErrorNoMore;
-            }
-            SetHeader(pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            if (pAudioPortFormat->nPortIndex <= 1)
-            {
-                pComponentPort = (Mp3ComponentPortType*) ipPorts[pAudioPortFormat->nPortIndex];
-                oscl_memcpy(pAudioPortFormat, &pComponentPort->AudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamAudioPcm:
-        {
-            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
-            if (pAudioPcmMode->nPortIndex > 1)
-            {
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioPcmMode->nPortIndex;
-            oscl_memcpy(pAudioPcmMode, &ipPorts[PortIndex]->AudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-            SetHeader(pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioMp3:
-        {
-            pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure;
-            if (pAudioMp3->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioMp3->nPortIndex;
-            oscl_memcpy(pAudioMp3, &ipPorts[PortIndex]->AudioMp3Param, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
-            SetHeader(pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
-        }
-        break;
-
-        case OMX_IndexConfigAudioEqualizer:
-        {
-            pAudioEqualizer = (OMX_AUDIO_CONFIG_EQUALIZERTYPE*) ComponentParameterStructure;
-            if (pAudioEqualizer->nPortIndex != 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            PortIndex = pAudioEqualizer->nPortIndex;
-            oscl_memcpy(pAudioEqualizer, &ipPorts[PortIndex]->AudioEqualizerType, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
-            SetHeader(pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            oscl_memcpy(pPortDef, &ipPorts[PortIndex]->PortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-            if (PortIndex >= iNumPorts)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-
-            if (OMX_DirInput == ipPorts[PortIndex]->PortParam.eDir)
-            {
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-            else
-            {
-                SetHeader(pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-                pBufSupply->eBufferSupplier = OMX_BufferSupplyUnspecified;
-            }
-        }
-        break;
-
-        case(OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
-        {
-            PV_OMXComponentCapabilityFlagsType *pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
-            if (NULL == pCap_flags)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error pCap_flags NULL"));
-                return OMX_ErrorBadParameter;
-            }
-            oscl_memcpy(pCap_flags, &iPVCapabilityFlags, sizeof(iPVCapabilityFlags));
-
-        }
-        break;
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter error Unsupported Index"));
-            return OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : GetParameter OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-{
-
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::SetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter IN"));
-
-    OMX_PRIORITYMGMTTYPE* pPrioMgmt;
-    OMX_AUDIO_PARAM_PORTFORMATTYPE* pAudioPortFormat;
-    OMX_AUDIO_PARAM_PCMMODETYPE* pAudioPcmMode;
-    OMX_AUDIO_PARAM_MP3TYPE* pAudioMp3;
-    OMX_PARAM_BUFFERSUPPLIERTYPE* pBufSupply;
-    OMX_PARAM_PORTDEFINITIONTYPE* pPortDef ;
-    OMX_PARAM_COMPONENTROLETYPE* pCompRole;
-    Mp3ComponentPortType* pComponentPort;
-
-    OMX_U32 PortIndex;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_AUDIO_CONFIG_EQUALIZERTYPE* pAudioEqualizer;
-
-
-    if (NULL == ComponentParameterStructure)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error bad parameter"));
-        return OMX_ErrorBadParameter;
-    }
-
-    switch (nParamIndex)
-    {
-        case OMX_IndexParamAudioInit:
-        {
-            /*Check Structure Header*/
-            CheckHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error audio init failed"));
-                return ErrorType;
-            }
-            oscl_memcpy(&iPortTypesParam, ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioPortFormat:
-        {
-            pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*) ComponentParameterStructure;
-            PortIndex = pAudioPortFormat->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            if (PortIndex <= 1)
-            {
-                pComponentPort = (Mp3ComponentPortType*) ipPorts[PortIndex];
-                oscl_memcpy(&pComponentPort->AudioParam, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-        }
-        break;
-
-        case OMX_IndexParamAudioPcm:
-        {
-            pAudioPcmMode = (OMX_AUDIO_PARAM_PCMMODETYPE*) ComponentParameterStructure;
-            PortIndex = pAudioPcmMode->nPortIndex;
-            /*Check Structure Header and verify component State*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-            oscl_memcpy(&ipPorts[PortIndex]->AudioPcmMode, pAudioPcmMode, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
-        }
-        break;
-
-        case OMX_IndexParamAudioMp3:
-        {
-            pAudioMp3 = (OMX_AUDIO_PARAM_MP3TYPE*) ComponentParameterStructure;
-            PortIndex = pAudioMp3->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->AudioMp3Param, pAudioMp3, sizeof(OMX_AUDIO_PARAM_MP3TYPE));
-        }
-        break;
-
-        case OMX_IndexConfigAudioEqualizer:
-        {
-            pAudioEqualizer = (OMX_AUDIO_CONFIG_EQUALIZERTYPE*) ComponentParameterStructure;
-            PortIndex = pAudioEqualizer->nPortIndex;
-            /*Check Structure Header and verify component state*/
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-            oscl_memcpy(&ipPorts[PortIndex]->AudioEqualizerType, pAudioEqualizer, sizeof(OMX_AUDIO_CONFIG_EQUALIZERTYPE));
-        }
-        break;
-
-        case OMX_IndexParamPriorityMgmt:
-        {
-            if (iState != OMX_StateLoaded && iState != OMX_StateWaitForResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error incorrect state error"));
-                return OMX_ErrorIncorrectStateOperation;
-            }
-            pPrioMgmt = (OMX_PRIORITYMGMTTYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pPrioMgmt, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            iGroupPriority = pPrioMgmt->nGroupPriority;
-            iGroupID = pPrioMgmt->nGroupID;
-        }
-        break;
-
-        case OMX_IndexParamPortDefinition:
-        {
-            pPortDef  = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
-            PortIndex = pPortDef->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
-            if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            ipPorts[PortIndex]->PortParam.nBufferCountActual = pPortDef->nBufferCountActual;
-            ipPorts[PortIndex]->PortParam.nBufferSize = pPortDef->nBufferSize;
-        }
-        break;
-
-        case OMX_IndexParamCompBufferSupplier:
-        {
-            pBufSupply = (OMX_PARAM_BUFFERSUPPLIERTYPE*) ComponentParameterStructure;
-            PortIndex = pBufSupply->nPortIndex;
-
-            ErrorType = BaseComponentParameterSanityCheck(hComponent, PortIndex, pBufSupply, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
-            if (OMX_ErrorIncorrectStateOperation == ErrorType)
-            {
-                if (PORT_IS_ENABLED(ipPorts[pBufSupply->nPortIndex]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error incorrect state error"));
-                    return OMX_ErrorIncorrectStateOperation;
-                }
-            }
-            else if (ErrorType != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error parameter sanity check error"));
-                return ErrorType;
-            }
-
-            if (pBufSupply->eBufferSupplier == OMX_BufferSupplyUnspecified)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter OUT"));
-                return OMX_ErrorNone;
-            }
-
-            ErrorType = OMX_ErrorNone;
-        }
-        break;
-
-        case OMX_IndexParamStandardComponentRole:
-        {
-            pCompRole = (OMX_PARAM_COMPONENTROLETYPE*) ComponentParameterStructure;
-            if ((ErrorType = CheckHeader(pCompRole, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone)
-            {
-                break;
-            }
-            strcpy((OMX_STRING)iComponentRole, (OMX_STRING)pCompRole->cRole);
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter error bad parameter"));
-            return OMX_ErrorBadParameter;
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetParameter OUT"));
-    return ErrorType;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->UseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::UseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : UseBuffer IN"));
-    Mp3ComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : UseBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : UseBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : UseBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            pBaseComponentPort->pBuffer[ii]->pBuffer = pBuffer;
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFilledLen = 0;
-            pBaseComponentPort->pBuffer[ii]->nOffset = 0;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            pBaseComponentPort->pBuffer[ii]->nTickCount = 0;
-            pBaseComponentPort->pBuffer[ii]->nTimeStamp = 0;
-            *ppBufferHdr = pBaseComponentPort->pBuffer[ii];
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            else
-            {
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts; // here is assigned a non-valid port index
-            }
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ASSIGNED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-            pBaseComponentPort->NumAssignedBuffers++;
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : UseBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : UseBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->AllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::AllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer IN"));
-
-    Mp3ComponentPortType* pBaseComponentPort;
-    OMX_U32 ii;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateTransition;
-    }
-
-    if (NULL == pBaseComponentPort->pBuffer)
-    {
-        pBaseComponentPort->pBuffer = (OMX_BUFFERHEADERTYPE**) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_BUFFERHEADERTYPE*));
-        pBaseComponentPort->BufferState = (OMX_U32*) oscl_calloc(pBaseComponentPort->PortParam.nBufferCountActual, sizeof(OMX_U32));
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (!(pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                !(pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED))
-        {
-            pBaseComponentPort->pBuffer[ii] = (OMX_BUFFERHEADERTYPE*) oscl_malloc(sizeof(OMX_BUFFERHEADERTYPE));
-            if (NULL == pBaseComponentPort->pBuffer[ii])
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            SetHeader(pBaseComponentPort->pBuffer[ii], sizeof(OMX_BUFFERHEADERTYPE));
-            /* allocate the buffer */
-            pBaseComponentPort->pBuffer[ii]->pBuffer = (OMX_BYTE) oscl_malloc(nSizeBytes);
-            if (NULL == pBaseComponentPort->pBuffer[ii]->pBuffer)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            pBaseComponentPort->pBuffer[ii]->nAllocLen = nSizeBytes;
-            pBaseComponentPort->pBuffer[ii]->nFlags = 0;
-            pBaseComponentPort->pBuffer[ii]->pPlatformPrivate = pBaseComponentPort;
-            pBaseComponentPort->pBuffer[ii]->pAppPrivate = pAppPrivate;
-            *pBuffer = pBaseComponentPort->pBuffer[ii];
-            pBaseComponentPort->BufferState[ii] |= BUFFER_ALLOCATED;
-            pBaseComponentPort->BufferState[ii] |= HEADER_ALLOCATED;
-
-            if (OMX_DirInput == pBaseComponentPort->PortParam.eDir)
-            {
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = nPortIndex;
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = iNumPorts;
-            }
-            else
-            {
-                // here is assigned a non-valid port index
-                pBaseComponentPort->pBuffer[ii]->nInputPortIndex = iNumPorts;
-                pBaseComponentPort->pBuffer[ii]->nOutputPortIndex = nPortIndex;
-            }
-
-            pBaseComponentPort->NumAssignedBuffers++;
-
-            if (pBaseComponentPort->PortParam.nBufferCountActual == pBaseComponentPort->NumAssignedBuffers)
-            {
-                pBaseComponentPort->PortParam.bPopulated = OMX_TRUE;
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    //Reschedule the AO for a state change (Loaded->Idle) if its pending on buffer allocation
-                    RunIfNotReady();
-                    //Set the corresponding flags
-                    pBaseComponentPort->LoadedToIdleFlag = OMX_TRUE;
-                    pBaseComponentPort->IdleToLoadedFlag = OMX_FALSE;
-                    iStateTransitionFlag = OMX_FALSE;
-                }
-            }
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer OUT"));
-            return OMX_ErrorNone;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : AllocateBuffer OUT"));
-    return OMX_ErrorInsufficientResources;
-}
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FreeBuffer(hComponent, nPortIndex, pBuffer);
-
-    return Status;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::FreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FreeBuffer IN"));
-
-    Mp3ComponentPortType* pBaseComponentPort;
-
-    OMX_U32 ii;
-    OMX_BOOL FoundBuffer;
-
-    if (nPortIndex >= iNumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FreeBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pBaseComponentPort = ipPorts[nPortIndex];
-
-    if (pBaseComponentPort->TransientState != OMX_StateLoaded
-            && pBaseComponentPort->TransientState != OMX_StateInvalid)
-    {
-
-        (*(ipCallbacks->EventHandler))
-        (hComponent,
-         iCallbackData,
-         OMX_EventError, /* The command was completed */
-         OMX_ErrorPortUnpopulated, /* The commands was a OMX_CommandStateSet */
-         nPortIndex, /* The State has been changed in message->MessageParam2 */
-         NULL);
-    }
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if ((pBaseComponentPort->BufferState[ii] & BUFFER_ALLOCATED) &&
-                (pBaseComponentPort->pBuffer[ii]->pBuffer == pBuffer->pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-            oscl_free(pBuffer->pBuffer);
-            pBuffer->pBuffer = NULL;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-        else if ((pBaseComponentPort->BufferState[ii] & BUFFER_ASSIGNED) &&
-                 (pBaseComponentPort->pBuffer[ii] == pBuffer))
-        {
-
-            pBaseComponentPort->NumAssignedBuffers--;
-
-            if (pBaseComponentPort->BufferState[ii] & HEADER_ALLOCATED)
-            {
-                oscl_free(pBuffer);
-                pBuffer = NULL;
-            }
-
-            pBaseComponentPort->BufferState[ii] = BUFFER_FREE;
-            break;
-        }
-    }
-
-    FoundBuffer = OMX_FALSE;
-
-    for (ii = 0; ii < pBaseComponentPort->PortParam.nBufferCountActual; ii++)
-    {
-        if (pBaseComponentPort->BufferState[ii] != BUFFER_FREE)
-        {
-            FoundBuffer = OMX_TRUE;
-            break;
-        }
-    }
-    if (!FoundBuffer)
-    {
-        pBaseComponentPort->PortParam.bPopulated = OMX_FALSE;
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            //Reschedule the AO for a state change (Idle->Loaded) if its pending on buffer de-allocation
-            RunIfNotReady();
-            //Set the corresponding flags
-            pBaseComponentPort->IdleToLoadedFlag = OMX_TRUE;
-            pBaseComponentPort->LoadedToIdleFlag = OMX_FALSE;
-            iStateTransitionFlag = OMX_FALSE;
-            //Reset the decoding flags while freeing buffers
-            if (OMX_PORT_INPUTPORT_INDEX == nPortIndex)
-            {
-                iIsInputBufferEnded = OMX_TRUE;
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-            }
-            else if (OMX_PORT_OUTPUTPORT_INDEX == nPortIndex)
-            {
-                iNewOutBufRequired = OMX_TRUE;
-            }
-        }
-
-        if (NULL != pBaseComponentPort->pBuffer)
-        {
-            oscl_free(pBaseComponentPort->pBuffer);
-            pBaseComponentPort->pBuffer = NULL;
-            oscl_free(pBaseComponentPort->BufferState);
-            pBaseComponentPort->BufferState = NULL;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FreeBuffer OUT"));
-    return OMX_ErrorNone;
-}
-
-
-/** Set Callbacks. It stores in the component private structure the pointers to the user application callbacs
-	* @param hComponent the handle of the component
-	* @param ipCallbacks the OpenMAX standard structure that holds the callback pointers
-	* @param pAppData a pointer to a private structure, not covered by OpenMAX standard, in needed
-    */
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SetCallbacks(hComponent, pCallbacks, pAppData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMp3AO::SetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SetCallbacks"));
-    ipCallbacks = pCallbacks;
-    iCallbackData = pAppData;
-
-    return OMX_ErrorNone;
-}
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->SendCommand(hComponent, Cmd, nParam, pCmdData);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMp3AO::SendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_S32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand IN"));
-
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrMsgHandler = OMX_ErrorNone;
-    QueueType* pMessageQueue;
-    CoreMessage* Message;
-
-    pMessageQueue = ipCoreDescriptor->pMessageQueue;
-
-    if (OMX_StateInvalid == iState)
-    {
-        ErrMsgHandler = OMX_ErrorInvalidState;
-    }
-
-    switch (Cmd)
-    {
-        case OMX_CommandStateSet:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandStateSet;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((OMX_StateIdle == nParam) && (OMX_StateLoaded == iState))
-            {
-                ErrMsgHandler = Mp3ComponentInit();
-
-                if (ErrMsgHandler != OMX_ErrorNone)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error component init"));
-                    return OMX_ErrorInsufficientResources;
-                }
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    ipPorts[ii]->TransientState = OMX_StateIdle;
-                }
-            }
-            else if ((OMX_StateLoaded == nParam) && (OMX_StateIdle == iState))
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else if (OMX_StateInvalid == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateInvalid;
-                    }
-                }
-            }
-            else if (((OMX_StateIdle == nParam) || (OMX_StatePause == nParam))
-                     && (OMX_StateExecuting == iState))
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-
-        }
-        break;
-
-        case OMX_CommandFlush:
-        {
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandFlush;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-
-            }
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-            //Assume that reposition command has come
-            iRepositionFlag = OMX_TRUE;
-            //Reset the silence insertion logic also
-            iSilenceInsertionInProgress = OMX_FALSE;
-            // reset decoder
-            if (ipMp3Dec)
-            {
-                ipMp3Dec->ResetDecoder();
-            }
-
-            Mp3ComponentSetPortFlushFlag(iNumPorts, nParam, OMX_TRUE);
-            Mp3ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-        }
-        break;
-
-        case OMX_CommandPortDisable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            iResizePending = OMX_FALSE;// disable the flag to enable further processing
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (!PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateLoaded;
-                    }
-                }
-            }
-            else
-            {
-                if (!PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateLoaded;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-                Message->MessageParam2 = nParam;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-                Message->MessageParam2 = ErrMsgHandler;
-            }
-            Message->MessageParam1 = OMX_CommandPortDisable;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandPortEnable:
-        {
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            if (-1 == nParam)
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error incorrect state"));
-                        ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                        break;
-                    }
-                    else
-                    {
-                        ipPorts[ii]->TransientState = OMX_StateIdle;
-                    }
-                }
-            }
-            else
-            {
-                if (PORT_IS_ENABLED(ipPorts[nParam]))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error incorrect state"));
-                    ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                    break;
-                }
-                else
-                {
-                    ipPorts[nParam]->TransientState = OMX_StateIdle;
-                }
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            if (OMX_ErrorNone == ErrMsgHandler)
-            {
-                Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            }
-            else
-            {
-                Message->MessageType = ERROR_MSG_TYPE;
-            }
-
-            Message->MessageParam1 = OMX_CommandPortEnable;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        case OMX_CommandMarkBuffer:
-        {
-            if ((iState != OMX_StateExecuting) && (iState != OMX_StatePause))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error incorrect state"));
-                ErrMsgHandler = OMX_ErrorIncorrectStateOperation;
-                break;
-            }
-
-            if ((nParam != -1) && ((OMX_U32) nParam >= iNumPorts))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error bad port index"));
-                return OMX_ErrorBadPortIndex;
-            }
-
-            Message = (CoreMessage*) oscl_malloc(sizeof(CoreMessage));
-            if (NULL == Message)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error insufficient resources"));
-                return OMX_ErrorInsufficientResources;
-            }
-            Message->pComponent = (OMX_COMPONENTTYPE *) hComponent;
-            Message->MessageType = SENDCOMMAND_MSG_TYPE;
-            Message->MessageParam1 = OMX_CommandMarkBuffer;
-            Message->MessageParam2 = nParam;
-            Message->pCmdData = pCmdData;
-        }
-        break;
-
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand error unsupported index"));
-            ErrMsgHandler = OMX_ErrorUnsupportedIndex;
-        }
-        break;
-    }
-
-    Queue(pMessageQueue, Message);
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : SendCommand OUT"));
-    return ErrMsgHandler;
-}
-
-
-/** This is called by the OMX core in its message processing
- * thread context upon a component request. A request is made
- * by the component when some asynchronous services are needed:
- * 1) A SendCommand() is to be processed
- * 2) An error needs to be notified
- * \param Message, the message that has been passed to core
- */
-
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentMessageHandler(CoreMessage* Message)
-{
-
-    OMX_COMPONENTTYPE* pHandle = &iOmxComponent;
-    OMX_U32 ii;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-
-    /** Dealing with a SendCommand call.
-     * -MessageParam1 contains the command to execute
-     * -MessageParam2 contains the parameter of the command
-     *  (destination state in case of a state change command).
-     */
-
-    OMX_STATETYPE orig_state = iState;
-    if (SENDCOMMAND_MSG_TYPE == Message->MessageType)
-    {
-        switch (Message->MessageParam1)
-        {
-            case OMX_CommandStateSet:
-            {
-                /* Do the actual state change */
-                ErrorType = Mp3ComponentDoStateSet(Message->MessageParam2);
-
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                //Do not send the callback now till the State gets changed
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    /* And run the callback */
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventCmdComplete, /* The command was completed */
-                     OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
-                     Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-            }
-            break;
-
-            case OMX_CommandFlush:
-            {
-                /*Flush ports*/
-                ErrorType = Mp3ComponentFlushPort(Message->MessageParam2);
-
-                Mp3ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Flush all port*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {/*Flush input/output port*/
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-                Mp3ComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-            }
-            break;
-
-            case OMX_CommandPortDisable:
-            {
-                /** This condition is added to pass the tests, it is not significant for the environment */
-                ErrorType = Mp3ComponentDisablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The iState has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (-1 == Message->MessageParam2)
-                    { /*Disable all ports*/
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The iState has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                    else
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The iState has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandPortEnable:
-            {
-                ErrorType = Mp3ComponentEnablePort(Message->MessageParam2);
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    return OMX_ErrorNone;
-                }
-
-                if (ErrorType != OMX_ErrorNone)
-                {
-                    (*(ipCallbacks->EventHandler))
-                    (pHandle,
-                     iCallbackData,
-                     OMX_EventError, /* The command was completed */
-                     ErrorType, /* The commands was a OMX_CommandStateSet */
-                     0, /* The State has been changed in Message->MessageParam2 */
-                     NULL);
-                }
-                else
-                {
-                    if (Message->MessageParam2 != -1)
-                    {
-                        (*(ipCallbacks->EventHandler))
-                        (pHandle,
-                         iCallbackData,
-                         OMX_EventCmdComplete, /* The command was completed */
-                         OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                         Message->MessageParam2, /* The State has been changed in Message->MessageParam2 */
-                         NULL);
-                    }
-                    else
-                    {
-                        for (ii = 0; ii < iNumPorts; ii++)
-                        {
-                            (*(ipCallbacks->EventHandler))
-                            (pHandle,
-                             iCallbackData,
-                             OMX_EventCmdComplete, /* The command was completed */
-                             OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
-                             ii, /* The State has been changed in Message->MessageParam2 */
-                             NULL);
-                        }
-                    }
-                }
-            }
-            break;
-
-            case OMX_CommandMarkBuffer:
-            {
-                ipMark = (OMX_MARKTYPE *)Message->pCmdData;
-            }
-            break;
-
-            default:
-            {
-
-            }
-            break;
-        }
-        /* Dealing with an asynchronous error condition
-         */
-    }
-
-    if (orig_state != OMX_StateInvalid)
-    {
-        ErrorType = OMX_ErrorNone;
-    }
-
-    return ErrorType;
-}
-
-/** Changes the state of a component taking proper actions depending on
- * the transiotion requested
- * \param Component, the component which state is to be changed
- * \param aDestinationState the requested target state.
- */
-
-OMX_ERRORTYPE OpenmaxMp3AO::Mp3ComponentDoStateSet(OMX_U32 aDestinationState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
-                    (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet IN : iState (%i) aDestinationState (%i)", iState, aDestinationState));
-
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-    OMX_U32 ii;
-
-    if (OMX_StateLoaded == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateLoaded;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->IdleToLoadedFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_FALSE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet Waiting port to be de-populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateLoaded;
-
-                iNumInputBuffer = 0;
-                iOutBufferCount = 0;
-                iPartialFrameAssembly = OMX_FALSE;
-                iEndofStream = OMX_FALSE;
-                iIsInputBufferEnded = OMX_TRUE;
-                iNewOutBufRequired = OMX_TRUE;
-                iFirstFragment = OMX_FALSE;
-                ipMp3Dec->iInitFlag = 0;
-
-                Mp3ComponentDeInit();
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateWaitForResources == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                iState = OMX_StateWaitForResources;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateIdle == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateWaitForResources:
-            {
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            case OMX_StateLoaded:
-            {
-                for (ii = 0; ii < iNumPorts; ii++)
-                {
-                    if (PORT_IS_ENABLED(ipPorts[ii]) &&
-                            !PORT_IS_POPULATED(ipPorts[ii]))
-                    {
-                        if (OMX_FALSE == ipPorts[ii]->LoadedToIdleFlag)
-                        {
-                            iStateTransitionFlag = OMX_TRUE;
-                        }
-                        else
-                        {
-                            ipPorts[ii]->PortParam.bPopulated = OMX_TRUE;
-                            ipPorts[ii]->TransientState = OMX_StateMax;
-                        }
-                    }
-                }
-                if (OMX_TRUE == iStateTransitionFlag)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet Waiting port to be populated"));
-                    return OMX_ErrorNone;
-                }
-
-                iState = OMX_StateIdle;
-
-                //Used in case of partial frame assembly
-                if (!ipInputCurrBuffer)
-                {
-                    //Keep the size of temp buffer double to be on safer side
-                    ipInputCurrBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * (ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize));
-                    if (NULL == ipInputCurrBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                if (!ipTempInputBuffer)
-                {
-                    ipTempInputBuffer = (OMX_U8*) oscl_malloc(2 * sizeof(uint8) * ipPorts[OMX_PORT_INPUTPORT_INDEX]->PortParam.nBufferSize);
-                    if (NULL == ipTempInputBuffer)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error insufficient resources"));
-                        return OMX_ErrorInsufficientResources;
-                    }
-                }
-
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            //Both the below cases have same body
-            case OMX_StateExecuting:
-            case OMX_StatePause:
-            {
-                Mp3ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-                Mp3ComponentSetPortFlushFlag(iNumPorts, -1, OMX_TRUE);
-
-                Mp3ComponentPortType* pInPort = (Mp3ComponentPortType*) ipPorts[OMX_PORT_INPUTPORT_INDEX];
-
-                //Return all the buffers if still occupied
-                QueueType *pInputQueue = ipPorts[OMX_PORT_INPUTPORT_INDEX]->pBufferQueue;
-
-                while ((iNumInputBuffer > 0) && (GetQueueNumElem(pInputQueue) > 0))
-                {
-                    Mp3ComponentFlushPort(OMX_PORT_INPUTPORT_INDEX);
-                }
-                // if a buffer was previously dequeued, it wasnt freed in above loop. return it now
-                if (iNumInputBuffer > 0)
-                {
-                    ipMp3InputBuffer->nFilledLen = 0;
-                    Mp3ComponentReturnInputBuffer(ipMp3InputBuffer, pInPort);
-                    iIsInputBufferEnded = OMX_TRUE;
-                    iInputCurrLength = 0;
-                }
-
-                //Mark these flags as true
-                iIsInputBufferEnded = OMX_TRUE;
-                iEndofStream = OMX_FALSE;
-
-                //Added these statement here
-                iTempInputBufferLength = 0;
-                iTempConsumedLength = 0;
-                //Assume for this state transition that reposition command has come
-                iRepositionFlag = OMX_TRUE;
-                //Reset the silence insertion logic also
-                iSilenceInsertionInProgress = OMX_FALSE;
-                // reset decoder
-                if (ipMp3Dec)
-                {
-                    ipMp3Dec->ResetDecoder();
-                }
-
-                while (iOutBufferCount > 0)
-                {
-                    Mp3ComponentFlushPort(OMX_PORT_OUTPUTPORT_INDEX);
-                }
-
-                Mp3ComponentSetPortFlushFlag(iNumPorts, -1, OMX_FALSE);
-                Mp3ComponentSetNumBufferFlush(iNumPorts, -1, 0);
-
-                iState = OMX_StateIdle;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet OUT"));
-        return ErrorType;
-    }
-
-    if (OMX_StatePause == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            //Falling through to the next case
-            case OMX_StateExecuting:
-            case OMX_StateIdle:
-            {
-                iState = OMX_StatePause;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateExecuting == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            case OMX_StateIdle:
-            {
-                iState = OMX_StateExecuting;
-            }
-            break;
-
-            case OMX_StatePause:
-            {
-                iState = OMX_StateExecuting;
-                /* A trigger to start the processing of buffers when component
-                 * transitions to executing from pause, as it is already
-                 * holding the required buffers
-                 */
-                RunIfNotReady();
-            }
-            break;
-
-            case OMX_StateExecuting:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error same state"));
-                return OMX_ErrorSameState;
-            }
-            break;
-
-            default:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error incorrect state"));
-                return OMX_ErrorIncorrectStateTransition;
-            }
-            break;
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet OUT"));
-        return OMX_ErrorNone;
-    }
-
-    if (OMX_StateInvalid == aDestinationState)
-    {
-        switch (iState)
-        {
-            case OMX_StateInvalid:
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-                return OMX_ErrorInvalidState;
-            }
-            break;
-
-            default:
-            {
-                iState = OMX_StateInvalid;
-                if (iIsInit != OMX_FALSE)
-                {
-                    Mp3ComponentDeInit();
-                }
-            }
-            break;
-        }
-
-        if (iIsInit != OMX_FALSE)
-        {
-            Mp3ComponentDeInit();
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Mp3ComponentDoStateSet OUT"));
-    return OMX_ErrorNone;
-}
-
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE *)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->EmptyThisBuffer(hComponent, pBuffer);
-
-    return Status;
-
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::EmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer IN"));
-    //Do not queue buffers if component is in invalid state
-    if (OMX_StateInvalid == iState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    if ((OMX_StateIdle == iState) || (OMX_StatePause == iState) || (OMX_StateExecuting == iState))
-    {
-        OMX_U32 PortIndex;
-        QueueType* pInputQueue;
-        OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-        PortIndex = pBuffer->nInputPortIndex;
-
-        //Validate the port index & Queue the buffers available only at the input port
-        if (PortIndex >= iNumPorts ||
-                ipPorts[PortIndex]->PortParam.eDir != OMX_DirInput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer error bad port index"));
-            return OMX_ErrorBadPortIndex;
-        }
-
-        //Port should be in enabled state before accepting buffers
-        if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        /* The number of buffers the component can queue at a time
-         * depends upon the number of buffers allocated/assigned on the input port
-         */
-        if (iNumInputBuffer == (ipPorts[PortIndex]->NumAssignedBuffers))
-
-        {
-            RunIfNotReady();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer error incorrect state"));
-            return OMX_ErrorIncorrectStateOperation;
-        }
-
-        //Finally after passing all the conditions, queue the buffer in Input queue
-        pInputQueue = ipPorts[PortIndex]->pBufferQueue;
-
-        if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer error check header failed"));
-            return ErrorType;
-        }
-
-        iNumInputBuffer++;
-        Queue(pInputQueue, pBuffer);
-
-        //Signal the AO about the incoming buffer
-        RunIfNotReady();
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer error incorrect state"));
-        //This macro is not accepted in any other state except the three mentioned above
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : EmptyThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-OMX_ERRORTYPE OpenmaxMp3AO::BaseComponentFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-
-    OpenmaxMp3AO* pOpenmaxAOType = (OpenmaxMp3AO*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
-    OMX_ERRORTYPE Status;
-
-    if (NULL == pOpenmaxAOType)
-    {
-        return OMX_ErrorBadParameter;
-    }
-
-    Status = pOpenmaxAOType->FillThisBuffer(hComponent, pBuffer);
-
-    return Status;
-}
-
-OMX_ERRORTYPE OpenmaxMp3AO::FillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FillThisBuffer IN"));
-
-    OMX_U32 PortIndex;
-
-    QueueType* pOutputQueue;
-    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
-
-    PortIndex = pBuffer->nOutputPortIndex;
-    //Validate the port index & Queue the buffers available only at the output port
-    if (PortIndex >= iNumPorts ||
-            ipPorts[PortIndex]->PortParam.eDir != OMX_DirOutput)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FillThisBuffer error bad port index"));
-        return OMX_ErrorBadPortIndex;
-    }
-
-    pOutputQueue = ipPorts[PortIndex]->pBufferQueue;
-    if (iState != OMX_StateExecuting &&
-            iState != OMX_StatePause &&
-            iState != OMX_StateIdle)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FillThisBuffer error invalid state"));
-        return OMX_ErrorInvalidState;
-    }
-
-    //Port should be in enabled state before accepting buffers
-    if (!PORT_IS_ENABLED(ipPorts[PortIndex]))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FillThisBuffer error incorrect state"));
-        return OMX_ErrorIncorrectStateOperation;
-    }
-
-    if ((ErrorType = CheckHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FillThisBuffer error check header failed"));
-        return ErrorType;
-    }
-
-    //Queue the buffer in output queue
-    Queue(pOutputQueue, pBuffer);
-    iOutBufferCount++;
-
-    //Signal the AO about the incoming buffer
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : FillThisBuffer OUT"));
-
-    return OMX_ErrorNone;
-}
-
-
-
-void OpenmaxMp3AO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Run IN"));
-
-
-    CoreMessage* pCoreMessage;
-
-    //Execute the commands from the message handler queue
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        pCoreMessage = (CoreMessage*) DeQueue(ipCoreDescriptor->pMessageQueue);
-
-        if (OMX_CommandStateSet == pCoreMessage->MessageParam1)
-        {
-            if (OMX_StateExecuting == pCoreMessage->MessageParam2)
-            {
-                iBufferExecuteFlag = OMX_TRUE;
-            }
-            else
-            {
-                iBufferExecuteFlag = OMX_FALSE;
-            }
-        }
-
-        Mp3ComponentMessageHandler(pCoreMessage);
-
-        /* If some allocations/deallocations are required before the state transition
-         * then queue the command again to be executed later on
-         */
-        if (OMX_TRUE == iStateTransitionFlag)
-        {
-            Queue(ipCoreDescriptor->pMessageQueue, pCoreMessage);
-            // Don't reschedule. Wait for arriving buffers to do it
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Run OUT"));
-            return;
-        }
-
-        else
-        {
-            oscl_free(pCoreMessage);
-            pCoreMessage = NULL;
-        }
-    }
-
-    /* If the component is in executing state, call the Buffer management function.
-     * Stop calling this function as soon as state transition request is received.
-     */
-    if ((OMX_TRUE == iBufferExecuteFlag) && (OMX_TRUE != iResizePending))
-    {
-        Mp3ComponentBufferMgmtFunction();
-    }
-
-    //Check for any more commands in the message handler queue & schedule them for later
-    if ((GetQueueNumElem(ipCoreDescriptor->pMessageQueue) > 0))
-    {
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : Run OUT"));
-
-    return;
-}
-
 //Check whether silence insertion is required here or not
 void OpenmaxMp3AO::CheckForSilenceInsertion()
 {
@@ -3570,7 +836,7 @@
 void OpenmaxMp3AO::DoSilenceInsertion()
 {
     QueueType* pOutputQueue = ipPorts[OMX_PORT_OUTPUTPORT_INDEX]->pBufferQueue;
-    Mp3ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
+    ComponentPortType* pOutPort = ipPorts[OMX_PORT_OUTPUTPORT_INDEX];
     OMX_U8*	pOutBuffer = NULL;
 
 
@@ -3590,28 +856,35 @@
                 return;
             }
 
-            ipMp3OutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
-            ipMp3OutputBuffer->nFilledLen = 0;
+            ipOutputBuffer = (OMX_BUFFERHEADERTYPE*) DeQueue(pOutputQueue);
+            if (NULL == ipOutputBuffer)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : DoSilenceInsertion Error, Output Buffer Dequeue returned NULL, OUT"));
+                iSilenceInsertionInProgress = OMX_TRUE;
+                return;
+            }
+            ipOutputBuffer->nFilledLen = 0;
             iNewOutBufRequired = OMX_FALSE;
 
             //Set the current timestamp to the output buffer timestamp
-            ipMp3OutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
+            ipOutputBuffer->nTimeStamp = iCurrentFrameTS.GetConvertedTs();
         }
 
 
-        pOutBuffer = &ipMp3OutputBuffer->pBuffer[ipMp3OutputBuffer->nFilledLen];
+        pOutBuffer = &ipOutputBuffer->pBuffer[ipOutputBuffer->nFilledLen];
         oscl_memset(pOutBuffer, 0, iOutputFrameLength);
 
-        ipMp3OutputBuffer->nFilledLen += iOutputFrameLength;
-        ipMp3OutputBuffer->nOffset = 0;
+        ipOutputBuffer->nFilledLen += iOutputFrameLength;
+        ipOutputBuffer->nOffset = 0;
         iCurrentFrameTS.UpdateTimestamp(iSamplesPerFrame);
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "OpenmaxMp3AO : DoSilenceInsertion - One frame of zeros inserted"));
 
         //Send the output buffer back when it has become full
-        if ((ipMp3OutputBuffer->nAllocLen - ipMp3OutputBuffer->nFilledLen) < iOutputFrameLength)
+        if ((ipOutputBuffer->nAllocLen - ipOutputBuffer->nFilledLen) < iOutputFrameLength)
         {
-            Mp3ComponentReturnOutputBuffer(ipMp3OutputBuffer, pOutPort);
+            ReturnOutputBuffer(ipOutputBuffer, pOutPort);
+            ipOutputBuffer = NULL;
         }
 
         // Decrement the silence frame counter
@@ -3627,3 +900,15 @@
 
     return;
 }
+
+
+OMX_ERRORTYPE OpenmaxMp3AO::GetConfig(
+    OMX_IN  OMX_HANDLETYPE hComponent,
+    OMX_IN  OMX_INDEXTYPE nIndex,
+    OMX_INOUT OMX_PTR pComponentConfigStructure)
+{
+    OSCL_UNUSED_ARG(hComponent);
+    OSCL_UNUSED_ARG(nIndex);
+    OSCL_UNUSED_ARG(pComponentConfigStructure);
+    return OMX_ErrorNotImplemented;
+}
diff --git a/codecs_v2/omx/omx_proxy/Android.mk b/codecs_v2/omx/omx_proxy/Android.mk
old mode 100755
new mode 100644
index bec5739..909c6b1
--- a/codecs_v2/omx/omx_proxy/Android.mk
+++ b/codecs_v2/omx/omx_proxy/Android.mk
@@ -3,33 +3,37 @@
 
 LOCAL_SRC_FILES := \
 	src/omx_proxy_interface.cpp \
-	src/pv_omx_interface_proxy.cpp \
-	src/pv_omx_interface_proxy_handler.cpp \
-	src/pv_omx_interface_proxy_notifier.cpp
-
+ 	src/pv_omx_interface_proxy.cpp \
+ 	src/pv_omx_interface_proxy_handler.cpp \
+ 	src/pv_omx_interface_proxy_notifier.cpp
 
 
 LOCAL_MODULE := libpvomx_proxy_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_proxy/src \
-	$(PV_TOP)//codecs_v2/omx/omx_proxy/src \
-	$(PV_TOP)//codecs_v2/omx/omx_proxy/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_proxy/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_proxy/src \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/omx_proxy_interface.h \
-	src/omx_proxy_vector.h \
-	src/pv_omx_interface_proxy.h \
-	src/pv_omx_interface_proxy_handler.h \
-	src/pv_omx_interface_proxy_notifier.h \
-	src/pv_omx_proxied_interface.h
+ 	src/omx_proxy_vector.h \
+ 	src/pv_omx_interface_proxy.h \
+ 	src/pv_omx_interface_proxy_handler.h \
+ 	src/pv_omx_interface_proxy_notifier.h \
+ 	src/pv_omx_proxied_interface.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_proxy/build/make/local.mk b/codecs_v2/omx/omx_proxy/build/make/local.mk
new file mode 100644
index 0000000..04a8e15
--- /dev/null
+++ b/codecs_v2/omx/omx_proxy/build/make/local.mk
@@ -0,0 +1,40 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvomx_proxy_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS +=
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../../pvmi/pvmf/include \
+  ../../../../../engines/common/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := omx_proxy_interface.cpp \
+	pv_omx_interface_proxy.cpp \
+	pv_omx_interface_proxy_handler.cpp \
+	pv_omx_interface_proxy_notifier.cpp 
+
+
+HDRS := omx_proxy_interface.h \
+	omx_proxy_vector.h \
+	pv_omx_interface_proxy.h \
+	pv_omx_interface_proxy_handler.h \
+	pv_omx_interface_proxy_notifier.h \
+	pv_omx_proxied_interface.h
+
+
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_proxy/build/make/makefile b/codecs_v2/omx/omx_proxy/build/make/makefile
deleted file mode 100755
index 244071e..0000000
--- a/codecs_v2/omx/omx_proxy/build/make/makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvomx_proxy_lib
-XCPPFLAGS +=
-
-XINCDIRS += \
-	-I ../../../../../extern_libs_v2/khronos/openmax/include 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS = 	omx_proxy_interface.cpp \
-	pv_omx_interface_proxy.cpp \
-	pv_omx_interface_proxy_handler.cpp \
-	pv_omx_interface_proxy_notifier.cpp 
-
-
-HDRS =	omx_proxy_interface.h \
-	omx_proxy_vector.h \
-	pv_omx_interface_proxy.h \
-	pv_omx_interface_proxy_handler.h \
-	pv_omx_interface_proxy_notifier.h \
-	pv_omx_proxied_interface.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.cpp b/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.cpp
index 5a455dc..f167fb2 100644
--- a/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.cpp
+++ b/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef OSCLCONFIG_H_INCLUDED
+#include "osclconfig.h"
+#endif
 
 #ifndef PV_OMXDEFS_H_INCLUDED
 #include "pv_omxdefs.h"
@@ -28,16 +31,16 @@
 #include "pv_omxcore.h"
 #endif
 
-#ifndef THREADSAFE_MEMPOOL_H_INCLUDED
+#ifndef PV_THREADSAFE_MEMPOOL_H_INCLUDED
 #include "threadsafe_mempool.h"
 #endif
 
+#ifndef OSCL_ERROR_H_INCLUDED
+#include "oscl_error.h"
+#endif
+
 #if PROXY_INTERFACE
 
-extern ProxyApplication_OMX*	pProxyTerm[];
-extern OMX_HANDLETYPE		ComponentHandle[];
-
-
 // the messages include input and output buffer circulation and cmd msgs into omx
 // MAX_NUMBER_OF_OMX_PROXY_MSGS must be larger than the sum of:
 // a) total number of omx output buffers
@@ -54,7 +57,7 @@
 
 
 //Constructor function for class ProxyApplication
-ProxyApplication_OMX::ProxyApplication_OMX()
+OSCL_EXPORT_REF ProxyApplication_OMX::ProxyApplication_OMX()
 {
     iNumMessage = iNumNotice = 0;
     iMemCmd = 0;
@@ -79,7 +82,7 @@
 }
 
 //Destructor function for class ProxyApplication
-ProxyApplication_OMX::~ProxyApplication_OMX()
+OSCL_EXPORT_REF ProxyApplication_OMX::~ProxyApplication_OMX()
 {
     iInitSemOmx.Close();
     if (iMemoryPool)
@@ -91,26 +94,26 @@
 }
 
 /* Initialize the proxy objects & create a new thread */
-void ProxyApplication_OMX::Start()
+OSCL_EXPORT_REF bool ProxyApplication_OMX::Start()
 {
-    // obtain the global memory lock (if one exists, it will be non-null)
-
-    OsclLockBase *thread_mem_lock = OsclMem::GetLock();
-
-    // if this lock exists, i.e. if this (master) thread already did  OsclMem::Init(lock)
-    //	we'll use the same lock in the new thread to do OsclMem::Init(lock). This will provide
-    // mem lock
-
     // if the global lock is NULL, there will be no mem lock control
-    ipProxy = CPVInterfaceProxy_OMX::NewL(*this, thread_mem_lock);
+    ipProxy = CPVInterfaceProxy_OMX::NewL(*this);
 
+    if (!ipProxy)
+    {
+        return false;
+    }
 
-    ipProxy->StartPVThread();
+    return ipProxy->StartPVThread();
 }
 
 /* De-Initialize the proxy object & destroy the new thread */
-void ProxyApplication_OMX::Exit()
+OSCL_EXPORT_REF void ProxyApplication_OMX::Exit()
 {
+    if (NULL == ipProxy)
+    {
+        return;
+    }
     //this will stop proxy scheduler and thread.
     ipProxy->Delete();
     ipProxy = NULL;
@@ -275,12 +278,13 @@
             EmptyBufMsg* Command = (EmptyBufMsg*) cmd;
             // Do not use wait/signal semaphore for queuing input/output buffers
             // allow the client thread to keep going without having to check the status (assume its OK)
-            ComponentEmptyThisBuffer(Command->hComponent, Command->pBuffer);
+            ReturnValueOmxApi = ComponentEmptyThisBuffer(Command->hComponent, Command->pBuffer);
             //delete Command;
             iMemoryPool->deallocate((OsclAny*)Command);
 
             iMemCmd--;
 
+
         }
         break;
 
@@ -289,11 +293,12 @@
             FillBufMsg* Command = (FillBufMsg*) cmd;
             // Do not use wait/signal semaphore for queuing input/output buffers
             // allow the client thread to keep going without having to check the status (assume its OK)
-            ComponentFillThisBuffer(Command->hComponent, Command->pBuffer);
+            ReturnValueOmxApi = ComponentFillThisBuffer(Command->hComponent, Command->pBuffer);
             //delete Command;
             iMemoryPool->deallocate((OsclAny*)Command);
 
             iMemCmd--;
+
         }
         break;
 
@@ -302,7 +307,7 @@
             GetHandleMsg* Command = (GetHandleMsg*) cmd;
 
             ReturnValueOmxApi = GlobalProxyComponentGetHandle(Command->pHandle, Command->cComponentName,
-                                Command->pAppData, Command->pCallBacks);
+                                Command->pAppData, Command->pCallBacks, (OMX_PTR)this);
             //delete Command;
             iMemoryPool->deallocate((OsclAny*)Command);
 
@@ -405,7 +410,7 @@
 THESE API'S ARE BEING CALLED FROM THE WRAPPER FUNCTIONS
 ****************************/
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetConfig(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetConfig(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_INDEXTYPE nIndex,
     OMX_INOUT OMX_PTR pComponentConfigStructure)
@@ -434,7 +439,7 @@
 
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxySetConfig(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxySetConfig(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_INDEXTYPE nIndex,
     OMX_IN  OMX_PTR pComponentConfigStructure)
@@ -461,7 +466,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetExtensionIndex(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetExtensionIndex(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_STRING cParameterName,
     OMX_OUT OMX_INDEXTYPE* pIndexType)
@@ -487,7 +492,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetState(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetState(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_OUT OMX_STATETYPE* pState)
 {
@@ -514,7 +519,7 @@
 }
 
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetParameter(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetParameter(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_INDEXTYPE nParamIndex,
     OMX_INOUT OMX_PTR ComponentParameterStructure)
@@ -542,7 +547,7 @@
 }
 
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxySetParameter(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxySetParameter(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_INDEXTYPE nParamIndex,
     OMX_IN  OMX_PTR ComponentParameterStructure)
@@ -571,7 +576,7 @@
 }
 
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyUseBuffer(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyUseBuffer(
     OMX_IN OMX_HANDLETYPE hComponent,
     OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
     OMX_IN OMX_U32 nPortIndex,
@@ -601,7 +606,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyAllocateBuffer(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyAllocateBuffer(
     OMX_IN OMX_HANDLETYPE hComponent,
     OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
     OMX_IN OMX_U32 nPortIndex,
@@ -629,7 +634,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyFreeBuffer(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyFreeBuffer(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_U32 nPortIndex,
     OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
@@ -655,7 +660,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxySetCallbacks(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxySetCallbacks(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
     OMX_IN  OMX_PTR pAppData)
@@ -680,7 +685,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxySendCommand(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxySendCommand(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_COMMANDTYPE Cmd,
     OMX_IN  OMX_U32 nParam,
@@ -706,7 +711,7 @@
     return ReturnValueOmxApi;
 }
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyEmptyThisBuffer(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyEmptyThisBuffer(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
 {
@@ -730,11 +735,11 @@
     // Do not use wait/signal semaphore for queuing input/output buffers
     // allow the client thread to keep going without having to wait for the status (assume its OK)
 
-    return OMX_ErrorNone;
+    return ReturnValueOmxApi;
 }
 
 
-OMX_ERRORTYPE ProxyApplication_OMX::ProxyFillThisBuffer(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyFillThisBuffer(
     OMX_IN  OMX_HANDLETYPE hComponent,
     OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
 {
@@ -758,11 +763,13 @@
     // Do not use wait/signal semaphore for queuing input/output buffers
     // allow the client thread to keep going without having to wait for the status (assume its OK)
 
-    return OMX_ErrorNone;
+
+
+    return ReturnValueOmxApi;
 }
 
 
-OMX_API OMX_ERRORTYPE OMX_APIENTRY ProxyApplication_OMX::ProxyGetHandle(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyGetHandle(
     OMX_OUT OMX_HANDLETYPE* pHandle,
     OMX_IN  OMX_STRING cComponentName, OMX_IN  OMX_PTR pAppData,
     OMX_IN  OMX_CALLBACKTYPE* pCallBacks)
@@ -785,12 +792,11 @@
     }
 
     iInitSemOmx.Wait();
-
     return ReturnValueOmxApi;
 }
 
 
-OMX_API OMX_ERRORTYPE OMX_APIENTRY ProxyApplication_OMX::ProxyFreeHandle(
+OSCL_EXPORT_REF OMX_ERRORTYPE ProxyApplication_OMX::ProxyFreeHandle(
     OMX_IN OMX_HANDLETYPE hComponent)
 {
     OsclAny *ptr = iMemoryPool->allocate(MAX_SIZE_OF_OMX_PROXY_MSG * sizeof(uint8));
@@ -815,291 +821,124 @@
     return ReturnValueOmxApi;
 }
 
-
 /**********************************
-WRAPPER FUNCTIONS START FROM HERE
-THESE FUNCTIONS ARE MAPPED TO THE OPENMAX MACROS AND METHODS
+COMPONENT HANDLE FUNCTIONS
 ***********************************/
 
-OMX_ERRORTYPE WrapperGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure)
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentGetHandle(
+    OMX_OUT OMX_HANDLETYPE* pHandle,
+    OMX_IN  OMX_STRING cComponentName,
+    OMX_IN  OMX_PTR pAppData,
+    OMX_IN  OMX_CALLBACKTYPE* pCallBacks,
+    OMX_IN	OMX_PTR	pProxy)
 {
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    int32 error;
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (!data)
     {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        ErrorType = OMX_ErrorInvalidState;
+        return ErrorType;
     }
 
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyGetConfig(hComponent, nIndex, pComponentConfigStructure);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxySetConfig(hComponent, nIndex, pComponentConfigStructure);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyGetExtensionIndex(hComponent, cParameterName, pIndexType);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyGetState(hComponent, pState);
-    return ReturnValue;
-}
-
-
-OMX_ERRORTYPE WrapperGetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure)
-{
-    OMX_ERRORTYPE ReturnValue = OMX_ErrorNone;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyGetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return ReturnValue;
-}
-
-
-OMX_ERRORTYPE WrapperSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxySetParameter(hComponent, nParamIndex, ComponentParameterStructure);
-    return ReturnValue;
-}
-
-
-OMX_ERRORTYPE WrapperUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyUseBuffer(hComponent, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyAllocateBuffer(hComponent, pBuffer, nPortIndex, pAppPrivate, nSizeBytes);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyFreeBuffer(hComponent, nPortIndex, pBuffer);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxySetCallbacks(hComponent, pCallbacks, pAppData);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData)
-{
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
-    {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
-    }
-
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxySendCommand(hComponent, Cmd, nParam, pCmdData);
-    return ReturnValue;
-}
-
-OMX_ERRORTYPE WrapperEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
-{
-    OMX_ERRORTYPE ReturnValue;
     OMX_S32 ii;
-    OMX_S32 ComponentNumber = 0;
+    OMX_U8 componentFoundflag = false;
 
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+    for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii ++)
     {
-        if (hComponent == ComponentHandle[ii])
+        if (data->ipRegTemplateList[ii] != NULL)
         {
-            ComponentNumber = ii;
+            if (!oscl_strcmp(data->ipRegTemplateList[ii]->ComponentName, cComponentName))
+            {
+                // found a matching name
+                // call the factory for the component
+                OMX_STRING aOmxLibName = data->ipRegTemplateList[ii]->SharedLibraryName;
+                OMX_PTR &aOmxLib = data->ipRegTemplateList[ii]->SharedLibraryPtr;
+                OMX_PTR aOsclUuid = data->ipRegTemplateList[ii]->SharedLibraryOsclUuid;
+                OMX_U32 &aRefCount = data->ipRegTemplateList[ii]->SharedLibraryRefCounter;
+                if ((data->ipRegTemplateList[ii]->FunctionPtrCreateComponent)(pHandle, pAppData, pProxy, aOmxLibName, aOmxLib, aOsclUuid, aRefCount) == OMX_ErrorNone)
+                {
+                    componentFoundflag = true;
+                    ((OMX_COMPONENTTYPE*)*pHandle)->SetCallbacks(*pHandle, pCallBacks, pAppData);
+                }
+                else
+                {
+                    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+                    ErrorType = OMX_ErrorInsufficientResources;
+                    return ErrorType;
+                }
+            }
+        }
+        else
+        {
             break;
         }
     }
 
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyEmptyThisBuffer(hComponent, pBuffer);
-    return ReturnValue;
+    // can't find the component after going through all of them
+    if (!componentFoundflag)
+    {
+        ErrorType = OMX_ErrorComponentNotFound;
+    }
+
+    //Release the singleton.
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    return ErrorType;
 }
 
-
-OMX_ERRORTYPE WrapperFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer)
+OSCL_EXPORT_REF OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentFreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
 {
-    OMX_ERRORTYPE ReturnValue;
-    OMX_S32 ii, ComponentNumber = 0;
-
-    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+    //ThreadLock.Lock();
+    OMX_ERRORTYPE ErrorType = OMX_ErrorNone;
+    int32 error;
+    OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
+    if (!data)
     {
-        if (hComponent == ComponentHandle[ii])
-        {
-            ComponentNumber = ii;
-            break;
-        }
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        ErrorType = OMX_ErrorInvalidState;
+        return ErrorType;
     }
 
-    ReturnValue = pProxyTerm[ComponentNumber]->ProxyFillThisBuffer(hComponent, pBuffer);
-    return ReturnValue;
+    OMX_HANDLETYPE* componentHandle = data->iComponentHandle;
+    OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)hComponent;
+    OMX_U32 ii;
+
+    // find the component index based on handle
+    for (ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
+    {
+        if (pHandle == componentHandle[ii])
+            break;
+    }
+    // cannot find the component handle
+    if (ii == MAX_INSTANTIATED_COMPONENTS)
+    {
+        OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+        ErrorType = OMX_ErrorInvalidComponent;
+        return ErrorType;
+    }
+
+    // call the component destructor through the function pointer recorder earlier
+    // using hComponent as argument
+
+    OMX_ERRORTYPE(*destroyComp)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
+    // First, obtain the destructor function
+    destroyComp = data->ipInstantiatedComponentReg[ii]->FunctionPtrDestroyComponent;
+
+    OMX_PTR &aOmxLib = data->ipInstantiatedComponentReg[ii]->SharedLibraryPtr;
+    OMX_PTR aOsclUuid = data->ipInstantiatedComponentReg[ii]->SharedLibraryOsclUuid;
+    OMX_U32 &aRefCount = data->ipInstantiatedComponentReg[ii]->SharedLibraryRefCounter;
+
+    (*destroyComp)(pHandle, aOmxLib, aOsclUuid, aRefCount);
+
+    data->iNumBaseInstance--;
+    //ThreadLock.Unlock();
+
+    ErrorType = OMX_ErrorNone;
+
+    //Release the singleton.
+    OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
+    return ErrorType;
 }
 
 #endif // PROXY_INTERFACE
diff --git a/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.h b/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.h
index 81194c1..998bb27 100644
--- a/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.h
+++ b/codecs_v2/omx/omx_proxy/src/omx_proxy_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -99,10 +99,10 @@
             , public PVProxiedInterfaceClient_OMX
 {
     public:
-        ProxyApplication_OMX();
-        virtual ~ProxyApplication_OMX();
-        void Start();
-        void Exit();
+        OSCL_IMPORT_REF ProxyApplication_OMX();
+        OSCL_IMPORT_REF virtual ~ProxyApplication_OMX();
+        OSCL_IMPORT_REF bool Start();
+        OSCL_IMPORT_REF void Exit();
         void TermCmd();
 
         void CreateLoggerAppenders()
@@ -122,36 +122,36 @@
         void HandleNotification(TPVProxyMsgId , OsclAny* aData);
         void CleanupCommand(TPVProxyMsgId , OsclAny* aData);
 
-        OMX_ERRORTYPE ProxyGetConfig(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyGetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE ProxySetConfig(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxySetConfig(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nIndex,
             OMX_IN  OMX_PTR pComponentConfigStructure);
 
-        OMX_ERRORTYPE ProxyGetExtensionIndex(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyGetExtensionIndex(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_STRING cParameterName,
             OMX_OUT OMX_INDEXTYPE* pIndexType) ;
 
-        OMX_ERRORTYPE ProxyGetState(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyGetState(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_OUT OMX_STATETYPE* pState);
 
-        OMX_ERRORTYPE ProxyGetParameter(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyGetParameter(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nParamIndex,
             OMX_INOUT OMX_PTR ComponentParameterStructure);
 
-        OMX_ERRORTYPE ProxySetParameter(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxySetParameter(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_INDEXTYPE nParamIndex,
             OMX_IN  OMX_PTR ComponentParameterStructure);
 
-        OMX_ERRORTYPE ProxyUseBuffer(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyUseBuffer(
             OMX_IN OMX_HANDLETYPE hComponent,
             OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
             OMX_IN OMX_U32 nPortIndex,
@@ -159,44 +159,44 @@
             OMX_IN OMX_U32 nSizeBytes,
             OMX_IN OMX_U8* pBuffer);
 
-        OMX_ERRORTYPE ProxyAllocateBuffer(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyAllocateBuffer(
             OMX_IN OMX_HANDLETYPE hComponent,
             OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
             OMX_IN OMX_U32 nPortIndex,
             OMX_IN OMX_PTR pAppPrivate,
             OMX_IN OMX_U32 nSizeBytes);
 
-        OMX_ERRORTYPE ProxyFreeBuffer(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyFreeBuffer(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_U32 nPortIndex,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-        OMX_ERRORTYPE ProxySetCallbacks(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxySetCallbacks(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
             OMX_IN  OMX_PTR pAppData);
 
-        OMX_ERRORTYPE ProxySendCommand(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxySendCommand(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_COMMANDTYPE Cmd,
             OMX_IN  OMX_U32 nParam,
             OMX_IN  OMX_PTR pCmdData);
 
-        OMX_ERRORTYPE ProxyEmptyThisBuffer(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyEmptyThisBuffer(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-        OMX_ERRORTYPE ProxyFillThisBuffer(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyFillThisBuffer(
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-        OMX_API OMX_ERRORTYPE OMX_APIENTRY ProxyGetHandle(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyGetHandle(
             OMX_OUT OMX_HANDLETYPE* pHandle,
             OMX_IN  OMX_STRING cComponentName,
             OMX_IN  OMX_PTR pAppData,
             OMX_IN  OMX_CALLBACKTYPE* pCallBacks);
 
-        OMX_API OMX_ERRORTYPE OMX_APIENTRY ProxyFreeHandle(
+        OSCL_IMPORT_REF OMX_ERRORTYPE ProxyFreeHandle(
             OMX_IN OMX_HANDLETYPE hComponent);
 
         /************************
@@ -562,74 +562,17 @@
         }
 };
 
-//Wrapper functions above Proxy layer
-OMX_ERRORTYPE WrapperGetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_INOUT OMX_PTR pComponentConfigStructure);
 
-OMX_ERRORTYPE WrapperSetConfig(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nIndex,
-    OMX_IN  OMX_PTR pComponentConfigStructure);
+/*Component Handle Functions*/
+OMX_API OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentGetHandle(
+    OMX_OUT OMX_HANDLETYPE* pHandle,
+    OMX_IN  OMX_STRING cComponentName, OMX_IN  OMX_PTR pAppData,
+    OMX_IN  OMX_CALLBACKTYPE* pCallBacks,
+    OMX_IN	OMX_PTR pProxy);
 
-OMX_ERRORTYPE WrapperGetExtensionIndex(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_STRING cParameterName,
-    OMX_OUT OMX_INDEXTYPE* pIndexType) ;
+OMX_API OMX_ERRORTYPE OMX_APIENTRY GlobalProxyComponentFreeHandle(
+    OMX_IN OMX_HANDLETYPE hComponent);
 
-OMX_ERRORTYPE WrapperGetState(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_OUT OMX_STATETYPE* pState);
-
-OMX_ERRORTYPE WrapperGetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_INOUT OMX_PTR ComponentParameterStructure);
-
-OMX_ERRORTYPE WrapperSetParameter(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_INDEXTYPE nParamIndex,
-    OMX_IN  OMX_PTR ComponentParameterStructure);
-
-OMX_ERRORTYPE WrapperUseBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes,
-    OMX_IN OMX_U8* pBuffer);
-
-OMX_ERRORTYPE WrapperAllocateBuffer(
-    OMX_IN OMX_HANDLETYPE hComponent,
-    OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,
-    OMX_IN OMX_U32 nPortIndex,
-    OMX_IN OMX_PTR pAppPrivate,
-    OMX_IN OMX_U32 nSizeBytes);
-
-OMX_ERRORTYPE WrapperFreeBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_U32 nPortIndex,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-OMX_ERRORTYPE WrapperSetCallbacks(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_CALLBACKTYPE* pCallbacks,
-    OMX_IN  OMX_PTR pAppData);
-
-OMX_ERRORTYPE WrapperSendCommand(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_COMMANDTYPE Cmd,
-    OMX_IN  OMX_U32 nParam,
-    OMX_IN  OMX_PTR pCmdData);
-
-OMX_ERRORTYPE WrapperEmptyThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
-
-OMX_ERRORTYPE WrapperFillThisBuffer(
-    OMX_IN  OMX_HANDLETYPE hComponent,
-    OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 #endif // PROXY_INTERFACE
 
 #endif //OMX_PROXY_INTERFACE_H_INCLUDED
diff --git a/codecs_v2/omx/omx_proxy/src/omx_proxy_vector.h b/codecs_v2/omx/omx_proxy/src/omx_proxy_vector.h
index 23940d7..f9a03fe 100644
--- a/codecs_v2/omx/omx_proxy/src/omx_proxy_vector.h
+++ b/codecs_v2/omx/omx_proxy/src/omx_proxy_vector.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,11 @@
 #include "oscl_base_alloc.h"
 #endif
 
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
+
+#if PROXY_INTERFACE
 
 //Memory allocator/deallocator class that don't use OSCL TLS
 class Oscl_Vector_Allocator : public Oscl_DefAlloc
@@ -265,6 +270,6 @@
         }
 
 };
-
+#endif //PROXY_INTERFACE
 #endif
 
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.cpp b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.cpp
index 7ec5d82..cd40b8c 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.cpp
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
 
 #ifndef PV_OMX_INTERFACE_PROXY_H_INCLUDED
 #include "pv_omx_interface_proxy.h"
@@ -41,16 +43,16 @@
 #include "pvlogger.h"
 #endif
 
-
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
+#if PROXY_INTERFACE
+
 //
 //CPVInterfaceProxy_OMX
 //
 
 OSCL_EXPORT_REF CPVInterfaceProxy_OMX * CPVInterfaceProxy_OMX::NewL(
     PVProxiedEngine_OMX& app
-    , OsclLockBase *lock
     , Oscl_DefAlloc *alloc
     , int32 stacksize
     , uint32 nreserve1
@@ -76,7 +78,7 @@
     {
         ptr = defallocL.ALLOCATE(sizeof(CPVInterfaceProxy_OMX));
     }
-    CPVInterfaceProxy_OMX *self = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxy_OMX(app, lock, alloc, stacksize));
+    CPVInterfaceProxy_OMX *self = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxy_OMX(app, alloc, stacksize));
     bool err;
     //Commented OSCL_TRY to remove oscl initialization dependency
     err = self->ConstructL(nreserve1, nreserve2, handlerPri, notifierPri);
@@ -88,9 +90,8 @@
     return self;
 }
 
-CPVInterfaceProxy_OMX::CPVInterfaceProxy_OMX(PVProxiedEngine_OMX& app, OsclLockBase *lock, Oscl_DefAlloc*alloc, int32 stacksize)
+CPVInterfaceProxy_OMX::CPVInterfaceProxy_OMX(PVProxiedEngine_OMX& app, Oscl_DefAlloc*alloc, int32 stacksize)
         : iPVApp(app)
-        , iLock(lock)
 //called under app thread context
 {
     iCommandIdCounter = 0;
@@ -103,6 +104,7 @@
     iStopped = true;
     iAlloc = (alloc) ? alloc : &iDefAlloc;
     iLogger = NULL;
+    iOMXThreadCreated = false;
 }
 
 //Commented all the OsclError::Leave statements to remove oscl tls dependency
@@ -116,7 +118,8 @@
             || iCounterCrit.Create() != OsclProcStatus::SUCCESS_ERROR
             || iHandlerQueueCrit.Create() != OsclProcStatus::SUCCESS_ERROR
             || iNotifierQueueCrit.Create() != OsclProcStatus::SUCCESS_ERROR
-            || iProxyListCrit.Create() != OsclProcStatus::SUCCESS_ERROR)
+            || iProxyListCrit.Create() != OsclProcStatus::SUCCESS_ERROR
+            || iThreadCreatedSem.Create() != OsclProcStatus::SUCCESS_ERROR)
     {
         return false;
     }
@@ -182,6 +185,7 @@
     iHandlerQueueCrit.Close();
     iNotifierQueueCrit.Close();
     iProxyListCrit.Close();
+    iThreadCreatedSem.Close();
     iInitSem.Close();
     iExitedSem.Close();
 }
@@ -202,8 +206,26 @@
     err = iPVThread.Create((TOsclThreadFuncPtr)pvproxythreadmain_omx,
                            iStacksize,
                            (TOsclThreadFuncArg)this);
+
+
     if (err == OSCL_ERR_NONE)
     {
+        // the iThreadCreated semaphore blocks the app thread until the new thread initializes oscl etc.
+        // we use it before checking the flag "iOMXThreadCreated"
+        // In case of either success or error the new thread signals this semaphore
+        if (iThreadCreatedSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
+        {
+            iNotifier->RemoveFromScheduler();
+            return false;
+        }
+        // check if the thread was created OK
+        if (!iOMXThreadCreated)
+        {
+            //error cleanup
+            iNotifier->RemoveFromScheduler();
+            return false;
+        }
+
         iStopped = false;
         //Wait for PV thread to initialize its scheduler.
         if (iInitSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
@@ -272,7 +294,7 @@
 {
     //make sure this isn't called under PV thread...
     if (iPVThreadContext.IsSameThreadContext())
-        OsclError::Panic("PVPROXY", EPVProxyPanicWrongThreadContext);
+        OsclError::Leave(OsclErrThreadContextIncorrect);
 
     for (int32 count = 0;count < aTargetCount;)
     {
@@ -297,7 +319,7 @@
             else
             {	//since messages are cleaned up when interfaces
                 //get unregistered, we should not get here.
-                OsclError::Panic("PVPROXYDEBUG", 0);//debug error.
+                OSCL_ASSERT(NULL != ext);//debug error.
             }
         }
         else
@@ -550,6 +572,9 @@
     if (err != OsclErrNone)
         errTerm = err;
 
+    iOMXThreadCreated = true;
+    // now it's safe to signal the thread create sema
+    iThreadCreatedSem.Signal();
 
     //Start scheduler.  This call blocks until scheduler is
     //either stopped or exits due to an error.
@@ -575,12 +600,11 @@
     //Uninstall scheduler
     OsclScheduler::Cleanup();
     iPVScheduler = NULL;
+    iOMXThreadCreated = false;
 
     //Generate panics if any leaves happened.
-    if (errTerm != OsclErrNone)
-        OsclError::Panic("PVPROXY", EPVProxyPanicEngineLeave);
-    if (errSched != OsclErrNone)
-        OsclError::Panic("PVPROXY", EPVProxyPanicSchedulerLeave);
+    OSCL_ASSERT(errTerm == OsclErrNone);//EPVProxyPanicEngineLeave
+    OSCL_ASSERT(errSched == OsclErrNone);//EPVProxyPanicSchedulerLeave
 }
 
 ////////////////////////////////
@@ -597,9 +621,19 @@
     CPVInterfaceProxy_OMX *proxy = (CPVInterfaceProxy_OMX *) aPtr;
 
     //Init OSCL and create logger.
-    OsclBase::Init();
-    OsclErrorTrap::Init();
-    OsclMem::Init(proxy->iLock); // the mem lock for this thread is the same lock object as in the master thread or NULL
+    int error = OsclBase::Init();
+    if (error)
+    {
+        proxy->iThreadCreatedSem.Signal(); // signal to let the app thread run
+        return 0;
+    }
+    error = OsclErrorTrap::Init();
+    if (error)
+    {
+        proxy->iThreadCreatedSem.Signal(); // signal to let the app thread run
+        return 0;
+    }
+    OsclMem::Init();
     PVLogger::Init();
 
 #if defined( OSCL_SET_THREAD_NAME)
@@ -614,14 +648,9 @@
 
 
     int32 leave;
-    TPVErrorPanic panic;
-    OSCL_PANIC_TRAP(leave, panic, proxy->InThread(););
+    OSCL_TRY(leave, proxy->InThread(););
 
-    if (panic.iReason != OsclErrNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR, (0, "PVPROXY:Proxy Thread 0x%x Exit: Panic Cat '%s' Reason %d", OsclExecScheduler::GetId(), panic.iCategory.Str(), panic.iReason));
-    }
-    else if (leave != OsclErrNone)
+    if (leave != OsclErrNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR, (0, "PVPROXY:Proxy Thread 0x%x Exit: Leave Reason %d", OsclExecScheduler::GetId(), leave));
     }
@@ -630,101 +659,8 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, proxy->iLogger, PVLOGMSG_NOTICE, (0, "PVPROXY:Proxy Thread 0x%x Exit: Normal", OsclExecScheduler::GetId()));
     }
 
-#if !(OSCL_BYPASS_MEMMGT)
-    //Show mem stats
-    {
-        OsclAuditCB auditCB;
-        OsclMemInit(auditCB);
-        if (auditCB.pAudit)
-        {
-            MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
-            if (stats)
-            {
-                //We need to re-init logger to report these, but that will create
-                //additional allocations, so save the current stats.
-                int32 peakNumAllocs = stats->peakNumAllocs;
-                int32 peakNumBytes = stats->peakNumBytes;
-                int32 numAllocFails = stats->numAllocFails;
-                int32 numAllocs = stats->numAllocs;
-                int32 numBytes = stats->numBytes;
+    proxy->iThreadCreatedSem.Signal(); // signal to let the app thread run just in case
 
-                PVLogger::Init();
-                proxy->iLogger = PVLogger::GetLoggerObject("pvproxy");
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_INFO
-                                , (0, "PVPROXY: Memory Stats:"));
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_INFO
-                                , (0, "PVPROXY:   peakNumAllocs %d", peakNumAllocs));
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_INFO
-                                , (0, "PVPROXY:   peakNumBytes %d", peakNumBytes));
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_INFO
-                                , (0, "PVPROXY:   numAllocFails %d", numAllocFails));
-                if (numAllocs)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                    , (0, "PVPROXY: ERROR: Memory Leaks! numAllocs %d, numBytes %d", numAllocs, numBytes));
-                }
-            }
-        }
-    }
-#endif
-
-
-#if !(OSCL_BYPASS_MEMMGT)
-    {
-        //Check for memory leaks before cleaning up OsclMem.
-        OsclAuditCB auditCB;
-        OsclMemInit(auditCB);
-        if (auditCB.pAudit)
-        {
-            uint32 leaks = auditCB.pAudit->MM_GetNumAllocNodes();
-            if (leaks != 0)
-            {
-                //If we found leaks we need to re-init logger so we can report them.
-                //But this will create some new allocations, so make a note of the
-                //current allocation number to weed them out of the report.
-                uint32 allocafterleaks = auditCB.pAudit->MM_GetAllocNo();
-                PVLogger::Init();
-                proxy->iLogger = PVLogger::GetLoggerObject("pvproxy");
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                , (0, "PVPROXY: ERROR: %d Memory leaks detected in PV Thread!", leaks));
-
-                //Allocate space for the leak info.
-                uint32 nodes = auditCB.pAudit->MM_GetNumAllocNodes();
-                MM_AllocQueryInfo*info = auditCB.pAudit->MM_CreateAllocNodeInfo(nodes);
-                uint32 leakinfo = auditCB.pAudit->MM_GetAllocNodeInfo(info, nodes, 0);
-                if (leakinfo < nodes)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                    , (0, "PVPROXY: ERROR: Leak info is incomplete."));
-                }
-                //Report only the original leaks before the logger allocations.
-                for (uint32 i = 0;i < leakinfo;i++)
-                {
-                    if (info[i].allocNum < allocafterleaks)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY: Leak Info:"));
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY:   allocNum %d", info[i].allocNum));
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY:   fileName %s", info[i].fileName));
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY:   lineNo %d", info[i].lineNo));
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY:   size %d", info[i].size));
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY:   pMemBlock 0x%x", info[i].pMemBlock));
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR
-                                        , (0, "PVPROXY:   tag %s", info[i].tag));
-                    }
-                }
-                auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
-            }
-        }
-    }
-#endif
     //Cleanup logger.
     PVLogger::Cleanup();
 
@@ -738,7 +674,7 @@
 
     return 0;
 }
-
+#endif // PROXY_INTERFACE
 
 
 
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.h b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.h
index 74428a0..96178ac 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.h
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,6 +46,12 @@
 #include "omx_proxy_vector.h"
 #endif
 
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
+
+#if PROXY_INTERFACE
+
 class CPVInterfaceProxyHandler_OMX;
 class CPVInterfaceProxyNotifier_OMX;
 class OsclExecScheduler;
@@ -109,26 +115,6 @@
         PVProxiedInterfaceClient_OMX *iClient;
 };
 
-/**
-//Panics generated by the proxy, with "PVPROXY" category
-*/
-enum TPVProxyPanic
-{
-    EPVProxyPanicEngineLeave = 1
-    //a leave happened in the PVThreadLogon or
-    //PVThreadLogoff call.
-
-    , EPVProxyPanicSchedulerLeave = 2
-    //a leave happened in a Run call under the PV
-    //thread's scheduler.
-
-    , EPVProxyPanicWrongThreadContext = 3
-    //a call happened from the incorrect thread context.
-
-    , EPVProxyPanicInterfaceAlreadyRegistered = 4
-    //Generated by a call to RegisterProxiedInterface
-    //with a duplicate interface ID.
-};
 
 const int32 PVPROXY_DEFAULT_STACK_SIZE = 0x2000;
 
@@ -141,9 +127,6 @@
         /**
         ** Create the proxy.
         ** @param app: the engine to create under the PV thread.
-        ** @param lock: A lock object for use with Oscl Memory.
-        **   This object must match the lock used in the App thread to
-        **   ensure proper operation.
         ** @param alloc: optional memory allocator.  If null, a default
         **    allocator will be used.
         ** @param stacksize: optional stacksize for the PV thread.
@@ -160,13 +143,12 @@
         */
         OSCL_IMPORT_REF static CPVInterfaceProxy_OMX * NewL(
             PVProxiedEngine_OMX& app
-            , OsclLockBase *lock = NULL
-                                   , Oscl_DefAlloc *alloc = NULL
-                                                            , int32 stacksize = PVPROXY_DEFAULT_STACK_SIZE
-                                                                                , uint32 nreserveInterfaceList = 20
-                                                                                                                 , uint32 nreserveMessageLists = 20
-                                                                                                                                                 , int32 handlerPri = OsclActiveObject::EPriorityNominal + 1
-                                                                                                                                                                      , int32 notifierPri = OsclActiveObject::EPriorityNominal + 1
+            , Oscl_DefAlloc *alloc = NULL
+                                     , int32 stacksize = PVPROXY_DEFAULT_STACK_SIZE
+                                                         , uint32 nreserveInterfaceList = 20
+                                                                                          , uint32 nreserveMessageLists = 20
+                                                                                                                          , int32 handlerPri = OsclActiveObject::EPriorityNominal + 1
+                                                                                                                                               , int32 notifierPri = OsclActiveObject::EPriorityNominal + 1
         );
 
         /**
@@ -193,7 +175,7 @@
         OSCL_IMPORT_REF void DeliverNotifications(int32 aCount, int32& aNoticesPending);
 
     protected:
-        CPVInterfaceProxy_OMX(PVProxiedEngine_OMX&, OsclLockBase*, Oscl_DefAlloc*, int32);
+        CPVInterfaceProxy_OMX(PVProxiedEngine_OMX&, Oscl_DefAlloc*, int32);
         //Changed return type to use a different fail mechanism
         bool ConstructL(uint32, uint32, int32, int32);
         virtual ~CPVInterfaceProxy_OMX();
@@ -203,6 +185,8 @@
         int32 iStacksize;
         OsclExecScheduler *iPVScheduler;
         PVLogger *iLogger;
+        OsclSemaphore iThreadCreatedSem;
+        bool iOMXThreadCreated;
         void InThread();
         OsclThread iPVThread;
 
@@ -251,13 +235,12 @@
         Oscl_DefAlloc *iAlloc;
 
         PVProxiedEngine_OMX &iPVApp;
-        OsclLockBase *iLock;
 
         friend class CPVInterfaceProxyHandler_OMX;
         friend class CPVInterfaceProxyNotifier_OMX;
         friend TOsclThreadFuncRet OSCL_THREAD_DECL pvproxythreadmain_omx(TOsclThreadFuncArg *aPtr);
 };
-
+#endif // PROXY_INTERFACE
 #endif //
 
 
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.cpp b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.cpp
index 9e7c131..fc01f76 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.cpp
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
+
 
 #ifndef PV_OMX_INTERFACE_PROXY_H_INCLUDED
 #include "pv_omx_interface_proxy.h"
@@ -24,6 +28,8 @@
 #include "pv_omx_interface_proxy_handler.h"
 #endif
 
+
+#if PROXY_INTERFACE
 void CPVInterfaceProxyHandler_OMX::Run()
 {
     if (Status() != OSCL_REQUEST_ERR_NONE)
@@ -59,8 +65,9 @@
         if (proxy)
             proxy->iServer->HandleCommand(command.iMsgId, command.iCmdId, command.iMsg);
         else
-            OsclError::Panic("PVPROXYDEBUG", 0);//debug error.
+            OSCL_ASSERT(NULL != proxy);//debug error.
     }
 
 }
 
+#endif // PROXY_INTERFACE
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.h b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.h
index c37a608..a52adf8 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.h
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_handler.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,10 @@
 #ifndef PV_OMX_INTERFACE_PROXY_HANDLER_H_INCLUDED
 #define PV_OMX_INTERFACE_PROXY_HANDLER_H_INCLUDED
 
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
+
 #ifndef PV_OMX_INTERFACE_PROXY_H_INCLUDED
 #include "pv_omx_interface_proxy.h"
 #endif
@@ -30,6 +34,8 @@
 
 #include "oscl_scheduler_ao.h"
 
+#if PROXY_INTERFACE
+
 class CPVInterfaceProxyHandler_OMX :
             public OsclActiveObject
 {
@@ -48,6 +54,7 @@
         CPVInterfaceProxy_OMX *iProxy;
 };
 
+#endif // PROXY_INTERFACE
 #endif //
 
 
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.cpp b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.cpp
index dc5ae9f..5a4090d 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.cpp
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
+
 
 #ifndef PV_OMX_INTERFACE_PROXY_H_INCLUDED
 #include "pv_omx_interface_proxy.h"
@@ -24,6 +28,7 @@
 #include "pv_omx_interface_proxy_notifier.h"
 #endif
 
+#if PROXY_INTERFACE
 void CPVInterfaceProxyNotifier_OMX::Run()
 {
     if (Status() != OSCL_REQUEST_ERR_NONE)
@@ -59,7 +64,8 @@
         if (proxy)
             proxy->iClient->HandleNotification(notice.iMsgId, notice.iMsg);
         else
-            OsclError::Panic("PVPROXYDEBUG", 2);//debug error.
+            OSCL_ASSERT(NULL != proxy);//debug error.
     }
 
 }
+#endif
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.h b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.h
index eb6ec1b..38f94ab 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.h
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_interface_proxy_notifier.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,12 +20,16 @@
 #ifndef PV_OMX_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
 #define PV_OMX_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
 
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
 
 #ifndef PV_OMX_INTERFACE_PROXY_H_INCLUDED
 #include "pv_omx_interface_proxy.h"
 #endif
 
 #include "oscl_scheduler_ao.h"
+#if PROXY_INTERFACE
 
 class CPVInterfaceProxyNotifier_OMX :
             public OsclActiveObject
@@ -44,7 +48,7 @@
 
         CPVInterfaceProxy_OMX *iProxy;
 };
-
+#endif //PROXY_INTERFACE
 #endif //
 
 
diff --git a/codecs_v2/omx/omx_proxy/src/pv_omx_proxied_interface.h b/codecs_v2/omx/omx_proxy/src/pv_omx_proxied_interface.h
index 8579afb..d66251f 100644
--- a/codecs_v2/omx/omx_proxy/src/pv_omx_proxied_interface.h
+++ b/codecs_v2/omx/omx_proxy/src/pv_omx_proxied_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,8 +29,12 @@
 #ifndef PV_INTERFACE_H_INCLUDED
 #include "pv_interface.h"
 #endif
+#ifndef PV_OMXDEFS_H_INCLUDED
+#include "pv_omxdefs.h"
+#endif
 
 #define PVUidProxiedInterface  PVUuid(0xf7076653,0x6088,0x47c6,0x88,0xc1,0xb7,0xed,0x28,0xe7,0x2b,0xeb)
+#if PROXY_INTERFACE
 
 class PVProxiedInterface_OMX;
 class PVProxiedInterfaceClient_OMX;
@@ -175,7 +179,7 @@
         ** routine is called.
         **
         ** Calling this API under the PV thread context is an error
-        ** and will generate a panic.
+        ** and will leave.
         */
         virtual void StopPVThread() = 0;
 
@@ -189,7 +193,7 @@
         ** been reached.  This API also returns the count of notifications
         ** still pending after the processing is complete.
         ** Any call to this API from within the PV thread context is
-        ** an error and will generate a panic.
+        ** an error and will leave.
         **
         ** @param aMaxCount: (input param) the maximum of pending
         **   notifications to process during the call.
@@ -383,7 +387,7 @@
         PVMainProxy_OMX *iMainProxy;
 };
 
-
+#endif // PROXY_INTERFACE
 #endif
 
 
diff --git a/codecs_v2/omx/omx_queue/Android.mk b/codecs_v2/omx/omx_queue/Android.mk
old mode 100755
new mode 100644
index 88956af..d4ea6c2
--- a/codecs_v2/omx/omx_queue/Android.mk
+++ b/codecs_v2/omx/omx_queue/Android.mk
@@ -2,26 +2,29 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pv_omx_queue.cpp
-
+ 	src/pv_omx_queue.cpp
 
 
 LOCAL_MODULE := libomx_queue_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/omx/omx_queue/src \
-	$(PV_TOP)//codecs_v2/omx/omx_queue/src \
-	$(PV_TOP)//codecs_v2/omx/omx_queue/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_queue/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_queue/src \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	src/pv_omx_queue.h
+ 	src/pv_omx_queue.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/omx/omx_queue/build/make/local.mk b/codecs_v2/omx/omx_queue/build/make/local.mk
new file mode 100644
index 0000000..6c3329d
--- /dev/null
+++ b/codecs_v2/omx/omx_queue/build/make/local.mk
@@ -0,0 +1,27 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := omx_queue_lib
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS += \
+  ../../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../../pvmi/pvmf/include 
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pv_omx_queue.cpp 
+
+
+HDRS := pv_omx_queue.h 
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_queue/build/make/makefile b/codecs_v2/omx/omx_queue/build/make/makefile
deleted file mode 100755
index cdf245a..0000000
--- a/codecs_v2/omx/omx_queue/build/make/makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = omx_queue_lib
-
-XINCDIRS += \
-	-I ../../../../../extern_libs_v2/khronos/openmax/include 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS = 	pv_omx_queue.cpp 
-
-
-HDRS =	pv_omx_queue.h 
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/omx/omx_queue/src/pv_omx_queue.cpp b/codecs_v2/omx/omx_queue/src/pv_omx_queue.cpp
old mode 100755
new mode 100644
index c9b61fd..77d70ff
--- a/codecs_v2/omx/omx_queue/src/pv_omx_queue.cpp
+++ b/codecs_v2/omx/omx_queue/src/pv_omx_queue.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,56 +18,136 @@
 
 #include "pv_omx_queue.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #ifndef OSCL_DLL_H_INCLUDED
 #include "oscl_dll.h"
 #endif
 
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
-OSCL_EXPORT_REF void QueueInit(QueueType* aQueue)
+OSCL_EXPORT_REF OMX_ERRORTYPE QueueInit(QueueType* aQueue)
 {
-    aQueue->inptr = 0;
-    aQueue->outptr = 0;
+    OMX_S32 ii;
+    QueueElement* pTempQElement = NULL;
+    aQueue->pFirst = NULL;
+
+    aQueue->pFirst = (QueueElement*) oscl_malloc(sizeof(QueueElement));
+    if (NULL == aQueue->pFirst)
+    {
+        return OMX_ErrorInsufficientResources;
+    }
+    oscl_memset(aQueue->pFirst, 0, sizeof(QueueElement));
+
+    aQueue->pLast = aQueue->pFirst;
+    aQueue->NumElem = 0;
+    aQueue->NumElemAdded = 0;
+
+    for (ii = 0; ii < MAX_QUEUE_ELEMENTS - 1; ii++)
+    {
+        pTempQElement = (QueueElement*) oscl_malloc(sizeof(QueueElement));
+        if (NULL == pTempQElement)
+        {
+            return OMX_ErrorInsufficientResources;
+        }
+
+        oscl_memset(pTempQElement, 0, sizeof(QueueElement));
+
+        aQueue->pLast->pQueueNext = pTempQElement;
+        aQueue->pLast = pTempQElement;
+        pTempQElement = NULL;
+    }
+
+    aQueue->pLast->pQueueNext = aQueue->pFirst;
+    aQueue->pLast = aQueue->pFirst;
+
+    return OMX_ErrorNone;
+
+}
+
+OSCL_EXPORT_REF OMX_BOOL AddQueueElem(QueueType* aQueue)
+{
+    QueueElement* pTempQElement = NULL;
+
+    pTempQElement = (QueueElement*) oscl_malloc(sizeof(QueueElement));
+    if (NULL == pTempQElement)
+    {
+        return OMX_FALSE;
+    }
+
+    oscl_memset(pTempQElement, 0, sizeof(QueueElement));
+    aQueue->pLast->pQueueNext = pTempQElement;
+    pTempQElement->pQueueNext = aQueue->pFirst;
+
+    aQueue->NumElemAdded++;
+
+    return OMX_TRUE;
+
 }
 
 OSCL_EXPORT_REF void QueueDeinit(QueueType* aQueue)
 {
-    aQueue->inptr = 0;
-    aQueue->outptr = 0;
+    OMX_S32 ii;
+    QueueElement* pTempQElement;
+
+    OMX_S32 QueueElemCount = aQueue->NumElemAdded + MAX_QUEUE_ELEMENTS;
+
+    pTempQElement = aQueue->pFirst;
+
+    for (ii = 0; ii < QueueElemCount	; ii++)
+    {
+        if (pTempQElement != NULL)
+        {
+            pTempQElement = pTempQElement->pQueueNext;
+            oscl_free(aQueue->pFirst);
+            aQueue->pFirst = pTempQElement;
+        }
+    }
 }
 
-OSCL_EXPORT_REF void Queue(QueueType* aQueue, void* aData)
+OSCL_EXPORT_REF OMX_ERRORTYPE Queue(QueueType* aQueue, void* aData)
 {
-    aQueue->queue[aQueue->inptr++] = aData;
-    if (aQueue->inptr >= MAX_QUEUE_ELEMENTS)
+    if (aQueue->NumElem == (MAX_QUEUE_ELEMENTS + aQueue->NumElemAdded))
     {
-        aQueue->inptr = 0;
+        if (OMX_FALSE == AddQueueElem(aQueue))
+        {
+            return OMX_ErrorInsufficientResources;
+        }
     }
+
+    if (aQueue->NumElem != 0)
+    {
+        aQueue->pLast = aQueue->pLast->pQueueNext;
+    }
+
+    aQueue->pLast->pData = aData;
+    aQueue->NumElem++;
+
+    return OMX_ErrorNone;
 }
 
 OSCL_EXPORT_REF void* DeQueue(QueueType* aQueue)
 {
-    if (aQueue->inptr == aQueue->outptr)
+    void* pData;
+    if (NULL == aQueue->pFirst->pData)
     {
         return NULL;
     }
 
-    void *ret =  aQueue->queue[aQueue->outptr++];
-    if (aQueue->outptr >= MAX_QUEUE_ELEMENTS)
+    pData = aQueue->pFirst->pData;
+    aQueue->pFirst->pData = NULL;
+    aQueue->pFirst = aQueue->pFirst->pQueueNext;
+    aQueue->NumElem--;
+
+    if (0 == aQueue->NumElem)
     {
-        aQueue->outptr = 0;
+        aQueue->pLast = aQueue->pFirst;
     }
-    return ret;
+
+    return pData;
 }
 
 OSCL_EXPORT_REF OMX_S32 GetQueueNumElem(QueueType* aQueue)
 {
-    int num = aQueue->inptr - aQueue->outptr;
-    if (num < 0)
-    {
-        num += MAX_QUEUE_ELEMENTS;
-    }
-    return num;
+    return aQueue->NumElem;
 }
 
diff --git a/codecs_v2/omx/omx_queue/src/pv_omx_queue.h b/codecs_v2/omx/omx_queue/src/pv_omx_queue.h
old mode 100755
new mode 100644
index 9887dc5..67aeeef
--- a/codecs_v2/omx/omx_queue/src/pv_omx_queue.h
+++ b/codecs_v2/omx/omx_queue/src/pv_omx_queue.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,11 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/**
-	Implements a simple FIFO structure used for queueing OMX buffers.
-*/
+
+/*******************
+ * Implementation of a FIFO structure for queueing OMX buffers and commands.
+********************/
+
 
 #ifndef PV_OMX_QUEUE_H_INCLUDED
 #define PV_OMX_QUEUE_H_INCLUDED
@@ -30,33 +32,50 @@
 #include "omx_types.h"
 #endif
 
-/* Maximum number of elements in a queue.
- * Note that we make no attempt to deal with buffer-full
- * situations. This is OK, since there is a limited number
- * of buffers that can be enqueued, so we will never
- * fill up the queue as long as the queue is bigger than
- * the number of buffers.
- */
-#define MAX_QUEUE_ELEMENTS 32
+#ifndef OMX_Core_h
+#include "omx_core.h"
+#endif
+
+/* Queue Depth i.e maximum number of elements */
+#define MAX_QUEUE_ELEMENTS 12
+
+
+/* Queue Element Type */
+struct QueueElement
+{
+    QueueElement* pQueueNext;
+    void* pData;
+};
 
 typedef struct QueueType
 {
-    void *queue[MAX_QUEUE_ELEMENTS];
-    int inptr;
-    int outptr;
+    QueueElement* pFirst;	/** Queue Front */
+    QueueElement* pLast;	/** Queue Rear (last filled element of queue) */
+    OMX_S32 NumElem;		/** Number of elements currently in the queue */
+    OMX_S32 NumElemAdded;	/** Number of elements added extra at run time*/
 }QueueType;
 
-OSCL_IMPORT_REF void QueueInit(QueueType* aQueue);
 
+
+//QUEUE OPERATIONS
+
+/* Queue initialization routine */
+OSCL_IMPORT_REF OMX_ERRORTYPE QueueInit(QueueType* aQueue);
+
+/* Queue deinitialization routine */
 OSCL_IMPORT_REF void QueueDeinit(QueueType* aQueue);
 
-OSCL_IMPORT_REF void Queue(QueueType* aQueue, void* aData);
+/* Function to queue an element in the given queue*/
+OSCL_IMPORT_REF OMX_ERRORTYPE Queue(QueueType* aQueue, void* aData);
 
-// returns NULL if the queue is empty
+/* Function to dequeue an element from the given queue
+ * Returns NULL if the queue is empty */
 OSCL_IMPORT_REF void* DeQueue(QueueType* aQueue);
 
+/* Function to get number of elements currently in the queue */
 OSCL_IMPORT_REF OMX_S32 GetQueueNumElem(QueueType* aQueue);
 
+/* Add new element in the queue if required */
+OSCL_IMPORT_REF OMX_BOOL AddQueueElem(QueueType* aQueue);
+
 #endif		//#ifndef PV_OMX_QUEUE_H_INCLUDED
-
-
diff --git a/protocols/rtp_payload_parser/util/payload_parser_test.doc b/codecs_v2/omx/omx_sharedlibrary/10_pvomx.cfg.example
similarity index 100%
rename from protocols/rtp_payload_parser/util/payload_parser_test.doc
rename to codecs_v2/omx/omx_sharedlibrary/10_pvomx.cfg.example
diff --git a/codecs_v2/omx/omx_sharedlibrary/interface/Android.mk b/codecs_v2/omx/omx_sharedlibrary/interface/Android.mk
new file mode 100644
index 0000000..c016901
--- /dev/null
+++ b/codecs_v2/omx/omx_sharedlibrary/interface/Android.mk
@@ -0,0 +1,29 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pv_omx_interface.cpp
+
+
+LOCAL_MODULE := libpv_omx_interface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/omx/omx_sharedlibrary/interface/src \
+ 	$(PV_TOP)/codecs_v2/omx/omx_sharedlibrary/interface/build/make \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/omx/omx_sharedlibrary/interface/build/make/local.mk b/codecs_v2/omx/omx_sharedlibrary/interface/build/make/local.mk
new file mode 100644
index 0000000..46e86b6
--- /dev/null
+++ b/codecs_v2/omx/omx_sharedlibrary/interface/build/make/local.mk
@@ -0,0 +1,23 @@
+# Get the current local path as the first operation 
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+TARGET := pv_omx_interface
+
+XINCDIRS += \
+        ../../../../../../extern_libs_v2/khronos/openmax/include
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS :=	pv_omx_interface.cpp
+HDRS := 
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/omx/omx_sharedlibrary/interface/src/pv_omx_interface.cpp b/codecs_v2/omx/omx_sharedlibrary/interface/src/pv_omx_interface.cpp
new file mode 100644
index 0000000..aaba91b
--- /dev/null
+++ b/codecs_v2/omx/omx_sharedlibrary/interface/src/pv_omx_interface.cpp
@@ -0,0 +1,78 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvlogger.h"
+
+#include "pv_omxcore.h"
+#include "omx_interface.h"
+
+
+
+class PVOMXInterface : public OMXInterface
+{
+    public:
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == OMX_INTERFACE_ID)
+            {
+                // the library lookup was successful
+                return this;
+            }
+            // the ID doesn't match
+            return NULL;
+        };
+
+        static PVOMXInterface* Instance()
+        {
+            return OSCL_NEW(PVOMXInterface, ());
+        };
+
+        bool UnloadWhenNotUsed(void)
+        {
+            // As of 9/22/08, the PV OMX core library can not be
+            // safely unloaded and reloaded when the proxy interface
+            // is enabled.
+            return false;
+        };
+
+    private:
+
+        PVOMXInterface()
+        {
+            // set the pointers to the omx core methods
+            pOMX_Init = OMX_Init;
+            pOMX_Deinit = OMX_Deinit;
+            pOMX_ComponentNameEnum = OMX_ComponentNameEnum;
+            pOMX_GetHandle = OMX_GetHandle;
+            pOMX_FreeHandle = OMX_FreeHandle;
+            pOMX_GetComponentsOfRole = OMX_GetComponentsOfRole;
+            pOMX_GetRolesOfComponent = OMX_GetRolesOfComponent;
+            pOMX_SetupTunnel = OMX_SetupTunnel;
+            pOMX_GetContentPipe = OMX_GetContentPipe;
+        };
+
+};
+
+// function to obtain the interface object from the shared library
+extern "C"
+{
+    OSCL_EXPORT_REF OsclAny* PVGetInterface()
+    {
+        return PVOMXInterface::Instance();
+    }
+
+}
diff --git a/codecs_v2/standalone_headerfiles/arbt_base.h b/codecs_v2/standalone_headerfiles/arbt_base.h
new file mode 100644
index 0000000..ff8ac18
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_base.h
@@ -0,0 +1,356 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ARBT_BASE_H_INCLUDED
+#define ARBT_BASE_H_INCLUDED
+
+#include "arbt_config.h"
+#include "arbt_types.h"
+#include "arbt_error.h"
+
+class ArbtBase
+{
+    public:
+        OSCL_IMPORT_REF  static void Init() {};
+        OSCL_IMPORT_REF  static void Cleanup() {};
+};
+
+class ArbtErrorTrap
+{
+    public:
+
+        OSCL_IMPORT_REF  static void Init() {};
+        OSCL_IMPORT_REF  static void Cleanup() {};
+        OSCL_IMPORT_REF  static void leave(int) {};
+};
+
+class ArbtMem
+{
+    public:
+        OSCL_IMPORT_REF  static void Init() {};
+        OSCL_IMPORT_REF  static void Cleanup() {};
+};
+
+class ArbtRequestStatus
+{
+    public:
+        ArbtRequestStatus();
+        ArbtRequestStatus(int32 aVal)
+        {
+            (void)(aVal);
+        };
+        int32 operator=(int32 aVal);
+        int32 operator==(int32 aVal) const;
+        int32 operator!=(int32 aVal) const;
+        int32 operator>=(int32 aVal) const;
+        int32 operator<=(int32 aVal) const;
+        int32 operator>(int32 aVal) const;
+        int32 operator<(int32 aVal) const;
+        int32 Int() const;
+    private:
+        int32 iStatus;
+};
+
+class OsclActiveObject
+{
+    public:
+        /**
+         * Scheduling priorities.
+         */
+        enum TPriority
+        {
+            /**
+            A low priority, useful for active objects representing
+            background processing.
+            */
+            EPriorityIdle = -100,
+            /**
+            A priority higher than EPriorityIdle but lower than EPriorityStandard.
+            */
+            EPriorityLow = -20,
+            /**
+            Most active objects will have this priority.
+            */
+            EPriorityStandard = 0,
+            /**
+            A priority higher than EPriorityStandard; useful for active objects
+            handling user input.
+            */
+            EPriorityUserInput = 10,
+            /**
+            A priority higher than EPriorityUserInput.
+            */
+            EPriorityHigh = 20
+        };
+
+        /**
+         * Constructor.
+         * @param aPriority (input param): scheduling priority
+         * @param name (inpup param): optional name for this AO.
+         */
+        OSCL_IMPORT_REF OsclActiveObject(int32 aPriority, const char name[]);
+
+        /**
+         * Destructor.
+         */
+        OSCL_IMPORT_REF virtual ~OsclActiveObject();
+
+        /**
+         * Set request active for this AO.
+         * Will panic if the request is already active,
+         * or the active object is not added to any scheduler,
+         * or the calling thread context does not match
+         * the scheduler thread.
+         */
+        OSCL_IMPORT_REF void SetBusy();
+
+        /**
+         * Return true if this AO is active,
+         * false otherwise.
+         */
+        OSCL_IMPORT_REF bool IsBusy() const;
+
+        /**
+         * Set request active for this AO and set the status to pending.
+         * PendForExec is identical to SetBusy, but it
+         * additionally sets the request status to OSCL_REQUEST_PENDING.
+         *
+         */
+        OSCL_IMPORT_REF void PendForExec();
+
+        /**
+         * Complate the active request for the AO.  Can be
+         * called from any thread.
+         * @param aStatus: request completion status.
+         */
+        OSCL_IMPORT_REF void PendComplete(int32 aStatus);
+
+
+        /**
+         * Add this AO to the current thread's scheduler.
+         */
+        OSCL_IMPORT_REF void AddToScheduler();
+
+        /**
+         * Return true if this AO is added to the scheduler,
+         * false otherwise.
+         */
+        OSCL_IMPORT_REF bool IsAdded() const;
+
+        /**
+         * Remove this AO from its scheduler.
+         * Will panic if the calling thread context does
+         * not match the scheduling thread.
+         * Cancels any active request before removing.
+         */
+        OSCL_IMPORT_REF void RemoveFromScheduler();
+
+        /**
+         * Deque is identical to RemoveFromScheduler
+         * It's only needed to prevent accidental usage
+         * of Symbian CActive::Deque.
+         */
+        OSCL_IMPORT_REF void Deque();
+
+        /**
+         * Complete this AO's request immediately.
+         * If the AO is already active, this will do nothing.
+         * Will panic if the AO is not acced to any scheduler,
+         * or if the calling thread context does not match the
+         * scheduling thread.
+         */
+        OSCL_IMPORT_REF void RunIfNotReady();
+
+        /**
+         * Cancel any active request.
+         * If the request is active, this will call the DoCancel
+         * routine, wait for the request to cancel, then set the
+         * request inactive.  The AO will not run.
+         * If the request is not active, it does nothing.
+         * Request must be canceled from the same thread
+         * in which it is scheduled.
+         */
+        OSCL_IMPORT_REF void Cancel();
+
+        /**
+        * Return scheduling priority of this active object.
+        */
+        OSCL_IMPORT_REF int32 Priority() const;
+
+        /**
+        * Request status access
+        */
+        OSCL_IMPORT_REF int32 Status()const;
+        OSCL_IMPORT_REF void SetStatus(int32);
+        OSCL_IMPORT_REF int32 StatusRef();
+
+    protected:
+        /**
+         * Cancel request handler.
+         * This gets called by scheduler when the request
+         * is cancelled.  The default routine will complete
+         * the request.  If any additional action is needed,
+         * the derived class may override this.  If the derived class
+         * does override DoCancel, it must complete the request.
+         */
+        //OSCL_IMPORT_REF virtual void DoCancel();
+
+        /**
+        * Run Error handler.
+        * This gets called by scheduler when the Run routine leaves.
+        * The default implementation simply returns the leave code.
+        * If the derived class wants to handle errors from Run,
+        * it may override this.  The RunError should return OsclErrNone
+        * if it handles the error, otherwise it should return the
+        * input error code.
+        * @param aError: the leave code generated by the Run.
+        */
+        //OSCL_IMPORT_REF virtual int32 RunError(int32 aError);
+};
+
+
+class OsclTimerObject
+{
+    public:
+        /**
+         * Constructor.
+         * @param aPriority (input param): scheduling priority
+         * @param name (input param): optional name for this AO.
+         */
+        OSCL_IMPORT_REF OsclTimerObject(int32 aPriority, const char name[]);
+
+        /**
+         * Destructor.
+         */
+
+        //OSCL_IMPORT_REF virtual ~OsclTimerObject();
+
+        /**
+         * Add this AO to the current thread's scheduler.
+         */
+        OSCL_IMPORT_REF void AddToScheduler();
+
+        /**
+         * Return true if this AO is added to the scheduler,
+         * false otherwise.
+         */
+        OSCL_IMPORT_REF bool IsAdded() const;
+
+        /**
+         * Remove this AO from its scheduler.
+         * Will panic if the calling thread context does
+         * not match the scheduling thread.
+         * Cancels any active request before removing.
+         */
+        OSCL_IMPORT_REF void RemoveFromScheduler();
+
+        /**
+         * Deque is identical to RemoveFromScheduler
+         * It's only needed to prevent accidental usage
+         * of Symbian CActive::Deque.
+         */
+        OSCL_IMPORT_REF void Deque();
+
+        /**
+        * 'After' sets the request active, with request status
+        * OSCL_REQUEST_STATUS_PENDING, and starts a timer.
+        * When the timer expires, the request will complete with
+        * status OSCL_REQUEST_ERR_NONE.
+        * Must be called from the same thread in which the
+        * active object is scheduled.
+        * Will panic if the request is already active, the object
+        * is not added to any scheduler, or the calling thread
+        * does not match the scheduling thread.
+        * @param anInterval: timeout interval in microseconds.
+        */
+        OSCL_IMPORT_REF void After(int32 aDelayMicrosec);
+
+        /**
+         * Complete the request after a time interval.
+         * RunIfNotReady is identical to After() except that it
+         * first checks the request status, and if it is already
+         * active, it does nothing.
+         *
+         * @param aDelayMicrosec (input param): delay in microseconds.
+         */
+        OSCL_IMPORT_REF void RunIfNotReady(uint32 aDelayMicrosec = 0);
+
+        /**
+         * Set request active for this AO.
+         * Will panic if the request is already active,
+         * or the active object is not added to any scheduler,
+         * or the calling thread context does not match
+         * the scheduler thread.
+         */
+        OSCL_IMPORT_REF void SetBusy();
+
+        /**
+         * Return true if this AO is active,
+         * false otherwise.
+         */
+        OSCL_IMPORT_REF bool IsBusy() const;
+
+        /**
+         * Cancel any active request.
+         * If the request is active, this will call the DoCancel
+         * routine, wait for the request to cancel, then set the
+         * request inactive.  The AO will not run.
+         * If the request is not active, it does nothing.
+         * Request must be canceled from the same thread
+         * in which it is scheduled.
+         */
+        OSCL_IMPORT_REF void Cancel();
+
+        /**
+        * Return scheduling priority of this active object.
+        */
+        OSCL_IMPORT_REF int32 Priority() const;
+        /**
+        * Request status access
+        */
+        OSCL_IMPORT_REF int32 Status()const;
+        OSCL_IMPORT_REF void SetStatus(int32);
+        OSCL_IMPORT_REF int32 StatusRef();
+
+    protected:
+        /**
+         * Cancel request handler.
+         * This gets called by scheduler when the request
+         * is cancelled.  The default routine will cancel
+         * the timer.  If any additional action is needed,
+         * the derived class may override this.  If the
+         * derived class does override this, it should explicitly
+         * call OsclTimerObject::DoCancel in its own DoCancel
+         * routine.
+         */
+        //OSCL_IMPORT_REF virtual void DoCancel();
+
+        /**
+        * Run Error handler.
+        * This gets called by scheduler when the Run routine leaves.
+        * The default implementation simply returns the leave code.
+        * If the derived class wants to handle errors from Run,
+        * it may override this.  The RunError should return OsclErrNone
+        * if it handles the error, otherwise it should return the
+        * input error code.
+        * @param aError: the leave code generated by the Run.
+        */
+        //OSCL_IMPORT_REF virtual int32 RunError(int32 aError);
+};
+
+#endif // ARBT_BASE_H_INCLUDED
+
diff --git a/codecs_v2/standalone_headerfiles/arbt_config.h b/codecs_v2/standalone_headerfiles/arbt_config.h
new file mode 100644
index 0000000..deb4873
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_config.h
@@ -0,0 +1,28 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ARBT_CONFIG_H_INCLUDED
+#define ARBT_CONFIG_H_INCLUDED
+
+#define ARBT_HAS_BREW_SUPPORT 0   //Not yet supported
+
+#define ARBT_HAS_SYMBIAN_SUPPORT 0 // Not yet supported
+
+#define ARBT_HAS_LINUX_SUPPORT 1
+
+#endif // ARBT_CONFIG_H_INCLUDED
+
diff --git a/codecs_v2/standalone_headerfiles/arbt_dll.h b/codecs_v2/standalone_headerfiles/arbt_dll.h
new file mode 100644
index 0000000..46a8154
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_dll.h
@@ -0,0 +1,40 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ARBT_DLL_H_INCLUDED
+#define ARBT_DLL_H_INCLUDED
+
+#define ARBT_DLL_ENTRY_POINT() void arbt_dll_entry_point() {}
+
+
+/**
+ * Default DLL entry/exit point function.
+ *
+ * The body of the DLL entry point is given.  The macro
+ * only needs to be declared within the source file.
+ *
+ * Usage :
+ *
+ * ARBT_DLL_ENTRY_POINT_DEFAULT()
+ */
+
+#define ARBT_DLL_ENTRY_POINT_DEFAULT()
+
+
+
+#endif // ARBT_DLL_H_INCLUDED
+
diff --git a/codecs_v2/standalone_headerfiles/arbt_error.h b/codecs_v2/standalone_headerfiles/arbt_error.h
new file mode 100644
index 0000000..b25e3b5
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_error.h
@@ -0,0 +1,105 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ARBT_ERROR_H_INCLUDED
+#define ARBT_ERROR_H_INCLUDED
+
+#if 0
+
+//! Use this macro to cause a Leave. It terminates the execution of the current active function
+/*!
+	It also tries to cleanup the items on the cleanup stack.
+   \param arbt_leave_status tells the cause for the Leave
+*/
+#define ARBT_LEAVE(_leave_status) ArbtError::Leave(_leave_status)
+
+
+//! This macro will be used to set up a try block
+/*!
+   The try block identifies a block of code that might throw exceptions
+   (or leave)
+   \param arbt_leave_status arbt_leave_status will receive the result of any
+   ARBT_LEAVE (which will get called from a ARBT_THROW) on systems that do not
+   support exception handling.This is unused on systems that do support
+   exception handling
+   \param statements is a statement or block of statements that could throw
+   exceptions and will be executed in the try block
+*/
+#define ARBT_TRY(_leave_status,_statements) _PV_TRAP(_leave_status,_statements)
+
+//! This section defines the macros to be used in the catch block following the try block
+
+//! Use this macro to call a function that handles all exception types thrown in the preceding try block
+/*!
+   \param _leave_status
+   \param _statements is a statement or block of statements that will
+   catch all the exception types thrown by the preceding try block
+   This is a standalone macro and should not be used with any of the macros above
+*/
+#define ARBT_FIRST_CATCH_ANY(_leave_status, _statements) \
+   if (_leave_status!=ArbtErrNone) { _statements; }
+
+//! Use this macro to define a block of code that catches the first exception type thrown in the preceding try block
+/*!
+   \param arbt_leave_status is the leave code that was returned by ARBT_THROW
+   \param exceptiontype is the exception handled by this catch block
+   This macro MUST be used in conjunction with either ARBT_LAST_CATCH or ARBT_CATCH_ANY
+*/
+#define ARBT_FIRST_CATCH( _leave_status, _catch_value, _statements) \
+	if (_leave_status!=ArbtErrNone && _leave_status == _catch_value){_statements;}
+
+//! Use this macro to define a block of code for catching additional exception types
+/*!
+   ARBT_FIRST_CATCH can be used to catch one exception type. Then the
+   ARBT_CATCH macro can be used to catch each subsequent type. The catch
+   block must end with ARBT_LAST_CATCH or ARBT_CATCH_ANY
+   \param arbt_leave_status is the result of any ARBT_THROW
+   \param exceptiontype is the exception handled by this catch block
+*/
+#define ARBT_CATCH( _leave_status, _catch_value, _statements) \
+	else if (_leave_status!=ArbtErrNone && _leave_status == _catch_value){_statements;}
+
+//! Use this macro to call a function that will catch all remaining exception types
+/*!
+   \param _leave_status
+   \param _statements is a statement or block of statements to
+   handle all remaining exception types.
+   This macro ends the try block.
+*/
+#define ARBT_CATCH_ANY(_leave_status,_statements) \
+	else if (_leave_status!=ArbtErrNone){ _statements;}
+
+//! Use this macro if ARBT_CATCH_ANY has not been used. It will mark the end of the catch block
+/*!
+   \param _leave_status will be propagated up the call stack
+   This macro will do an ARBT_LEAVE if the leave has not been handled by the calls above.
+   This macro ends the try block.
+*/
+
+#define ARBT_LAST_CATCH(_leave_status) \
+	else if (_leave_status!=ArbtErrNone){ARBT_LEAVE(_leave_status);}
+
+
+
+#else
+
+#define ARBT_LEAVE(x)
+
+#endif // if 0
+
+#endif //ARBT_ERROR_H_INCLUDED
+
diff --git a/codecs_v2/standalone_headerfiles/arbt_error_codes.h b/codecs_v2/standalone_headerfiles/arbt_error_codes.h
new file mode 100644
index 0000000..a5ea2f4
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_error_codes.h
@@ -0,0 +1,59 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef ARBT_ERROR_CODES_H_INCLUDED
+#define ARBT_ERROR_CODES_H_INCLUDED
+
+
+/** Leave Codes
+*/
+typedef int32 ArbtLeaveCode;
+
+#define ArbtErrNone 0
+#define ArbtErrGeneral 100
+#define ArbtErrNoMemory 101
+#define ArbtErrCancelled 102
+#define ArbtErrNotSupported 103
+#define ArbtErrArgument 104
+#define ArbtErrBadHandle 105
+#define ArbtErrAlreadyExists 106
+#define ArbtErrBusy 107
+#define ArbtErrNotReady 108
+#define ArbtErrCorrupt 109
+#define ArbtErrTimeout 110
+#define ArbtErrOverflow 111
+#define ArbtErrUnderflow 112
+#define ArbtErrInvalidState 113
+#define ArbtErrNoResources 114
+
+/** For backward compatibility with old definitions
+*/
+#define ARBT_ERR_NONE ArbtErrNone
+#define ARBT_BAD_ALLOC_EXCEPTION_CODE ArbtErrNoMemory
+
+/** Return Codes
+*/
+typedef int32 ArbtReturnCode;
+
+#define  ArbtSuccess 0
+#define  ArbtPending 1
+#define  ArbtFailure -1
+
+#endif
+
+/*! @} */
diff --git a/codecs_v2/standalone_headerfiles/arbt_exception.h b/codecs_v2/standalone_headerfiles/arbt_exception.h
new file mode 100644
index 0000000..befeaf2
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_exception.h
@@ -0,0 +1,26 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef ARBT_EXCEPTION_H_INCLUDED
+#define ARBT_EXCEPTION_H_INCLUDED
+
+
+
+#endif // INCLUDED_ARBT_EXCEPTION_H
+
+
diff --git a/codecs_v2/standalone_headerfiles/arbt_math.h b/codecs_v2/standalone_headerfiles/arbt_math.h
new file mode 100644
index 0000000..698fa63
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_math.h
@@ -0,0 +1,34 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ARBT_MATH_H_INCLUDED
+#define ARBT_MATH_H_INCLUDED
+
+#include <e32math.h>
+
+
+
+#define arbt_pow		pow
+#define arbt_exp		exp
+#define arbt_sqrt		sqrt
+#define arbt_log		log
+#define arbt_cos		cos
+#define arbt_sin		sin
+#define arbt_tan		tan
+#define arbt_asin		asin
+
+#endif // ARBT_MATH_H_INCLUDED
diff --git a/codecs_v2/standalone_headerfiles/arbt_mem.h b/codecs_v2/standalone_headerfiles/arbt_mem.h
new file mode 100644
index 0000000..d197c9e
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_mem.h
@@ -0,0 +1,37 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ARBT_MEM_H_INCLUDED
+#define ARBT_MEM_H_INCLUDED
+
+#include "arbt_types.h"
+
+#define ARBTMemSizeT size_t
+
+#define arbt_memcpy(dest, src, count)		memcpy((void *)(dest), (const void *)(src), (ARBTMemSizeT)(count))
+#define arbt_memset(dest, ch, count)		memset((void *)(dest), (unsigned char)(ch), (ARBTMemSizeT)(count))
+#define arbt_memmove(dest, src, bytecount)	memmove((void *)(dest), (const void *)(src), (ARBTMemSizeT)(bytecount))
+#define arbt_memcmp(buf1, buf2, count)		memcmp( (const void *)(buf1), (const void *)(buf2), (ARBTMemSizeT)(count))
+#define arbt_malloc(size)					   malloc((ARBTMemSizeT)(size))
+#define arbt_free(memblock)					free((void *)(memblock))
+#define ARBT_ARRAY_DELETE(ptr)				delete [] ptr
+#define ARBT_ARRAY_NEW(T, count)			new T[count]
+#define ARBT_DELETE(memblock)				delete memblock
+#define ARBT_NEW(arg)						new arg
+
+#endif // ARBT_MEM_H_INCLUDED
+
diff --git a/codecs_v2/standalone_headerfiles/arbt_types.h b/codecs_v2/standalone_headerfiles/arbt_types.h
new file mode 100644
index 0000000..6b3c822
--- /dev/null
+++ b/codecs_v2/standalone_headerfiles/arbt_types.h
@@ -0,0 +1,146 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*! \file oscl_types.h
+    \brief This file contains basic type definitions for common use across platforms.
+
+*/
+
+
+
+#ifndef ARBT_TYPES_H_INCLUDED
+#define ARBT_TYPES_H_INCLUDED
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <limits.h>
+#include <string.h>
+
+#if defined(WIN32) || defined(_WIN32)
+#include <windows.h>
+#define ARBT_HAS_MSWIN_SUPPORT         1
+#endif
+
+#if defined(_GNU_SOURCE) || (ARBT_HAS_LINUX_SUPPORT)
+#define LINUX		1
+#endif
+
+//! A typedef for a signed 8 bit integer.
+#ifndef int8
+typedef signed char int8;
+#endif
+
+//! A typedef for an unsigned 8 bit integer.
+#ifndef uint8
+typedef unsigned char uint8;
+#endif
+
+//! A typedef for a signed 16 bit integer.
+#ifndef int16
+typedef short int16;
+#endif
+
+//! A typedef for an unsigned 16 bit integer.
+#ifndef uint16
+typedef unsigned short uint16;
+#endif
+
+//! A typedef for a signed 32 bit integer.
+#ifndef int32
+typedef long int32;
+#endif
+
+//! A typedef for an unsigned 32 bit integer.
+#ifndef uint32
+typedef unsigned long uint32;
+#endif
+
+#ifndef sint8
+typedef signed char sint8;
+#endif
+
+#ifndef OsclFloat
+typedef float OsclFloat;
+#endif
+
+#ifndef uint
+typedef unsigned int uint;
+#endif
+
+
+#ifndef int64
+#define ARBT_HAS_NATIVE_INT64_TYPE 1
+
+#if defined(LINUX)
+#define ARBT_NATIVE_INT64_TYPE long long
+#else // Other platforms
+#define ARBT_NATIVE_INT64_TYPE __int64
+#endif // LINUX
+
+typedef ARBT_NATIVE_INT64_TYPE int64;
+
+#endif // int64
+
+#ifndef uint64
+#define ARBT_HAS_NATIVE_UINT64_TYPE  1
+
+#if defined(LINUX)
+#define ARBT_NATIVE_UINT64_TYPE unsigned long long
+#else // Other platforms
+#define ARBT_NATIVE_UINT64_TYPE unsigned __int64
+#endif // LINUX
+typedef ARBT_NATIVE_UINT64_TYPE uint64;
+#endif // uint64
+
+
+
+#define ARBT_UNUSED_ARG(x) (void)(x)
+
+#ifndef OSCL_EXPORT_REF
+#define OSCL_EXPORT_REF
+#endif
+
+#ifndef OSCL_IMPORT_REF
+#define OSCL_IMPORT_REF
+#endif
+
+#if defined(ARBT_DISABLE_INLINES)
+#define ARBT_INLINE
+#define OSCL_COND_EXPORT_REF OSCL_EXPORT_REF
+#define OSCL_COND_IMPORT_REF OSCL_IMPORT_REF
+#else
+#define ARBT_INLINE inline
+#define OSCL_COND_IMPORT_REF
+#define OSCL_COND_IMPORT_REF
+#endif
+
+#ifndef INT64
+#define INT64 int64
+#endif
+
+#ifndef UINT64
+#define UINT64 uint64
+#endif
+
+#ifndef UINT64_HILO
+#define UINT64_HILO(a,b) ((a<<32) | b)
+#endif
+
+
+#endif // ARBT_TYPES_H_INCLUDED
diff --git a/codecs_v2/utilities/colorconvert/Android.mk b/codecs_v2/utilities/colorconvert/Android.mk
index 6475ab6..7fdad07 100644
--- a/codecs_v2/utilities/colorconvert/Android.mk
+++ b/codecs_v2/utilities/colorconvert/Android.mk
@@ -2,36 +2,52 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/cczoomrotation12.cpp \
-	src/cczoomrotation16.cpp \
-	src/cczoomrotation24.cpp \
-	src/cczoomrotation32.cpp \
-	src/cczoomrotationbase.cpp \
-	src/ccyuv422toyuv420.cpp
-
+	src/ccrgb16toyuv420.cpp \
+ 	src/ccrgb24torgb16.cpp \
+ 	src/ccyuv422toyuv420.cpp \
+ 	src/cczoomrotation12.cpp \
+ 	src/cczoomrotation16.cpp \
+ 	src/cczoomrotation24.cpp \
+ 	src/cczoomrotation32.cpp \
+ 	src/cczoomrotationbase.cpp \
+ 	src/cpvvideoblend.cpp \
+ 	src/ccrgb24toyuv420.cpp \
+ 	src/ccrgb12toyuv420.cpp \
+ 	src/ccyuv420semiplnrtoyuv420plnr.cpp \
+ 	src/ccyuv420toyuv420semi.cpp
 
 
 LOCAL_MODULE := libcolorconvert
 
-LOCAL_CFLAGS := -DFALSE=false  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DFALSE=false $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/utilities/colorconvert/include \
-	$(PV_TOP)//codecs_v2/utilities/colorconvert/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/utilities/colorconvert/src \
+ 	$(PV_TOP)/codecs_v2/utilities/colorconvert/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/cczoomrotation12.h \
-	include/cczoomrotation16.h \
-	include/cczoomrotation24.h \
-	include/cczoomrotation32.h \
 	include/cczoomrotationbase.h \
-	include/ccyuv422toyuv420.h \
-	include/colorconv_config.h
+ 	include/cczoomrotation12.h \
+ 	include/cczoomrotation16.h \
+ 	include/cczoomrotation24.h \
+ 	include/cczoomrotation32.h \
+ 	include/ccrgb16toyuv420.h \
+ 	include/ccrgb24torgb16.h \
+ 	include/ccyuv422toyuv420.h \
+ 	include/colorconv_config.h \
+ 	include/pvvideoblend.h \
+ 	include/ccrgb24toyuv420.h \
+ 	include/ccrgb12toyuv420.h \
+ 	include/ccyuv420semitoyuv420.h \
+ 	include/ccyuv420toyuv420semi.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/utilities/colorconvert/build/make/local.mk b/codecs_v2/utilities/colorconvert/build/make/local.mk
new file mode 100644
index 0000000..9fde49b
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/build/make/local.mk
@@ -0,0 +1,47 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := colorconvert
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS += -DFALSE=false
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS :=	ccrgb16toyuv420.cpp \
+	ccrgb24torgb16.cpp \
+	ccyuv422toyuv420.cpp \
+	cczoomrotation12.cpp \
+	cczoomrotation16.cpp \
+	cczoomrotation24.cpp \
+	cczoomrotation32.cpp \
+	cczoomrotationbase.cpp \
+	cpvvideoblend.cpp \
+	ccrgb24toyuv420.cpp \
+	ccrgb12toyuv420.cpp \
+	ccyuv420semiplnrtoyuv420plnr.cpp \
+	ccyuv420toyuv420semi.cpp
+
+HDRS :=  cczoomrotationbase.h \
+	cczoomrotation12.h \
+	cczoomrotation16.h \
+	cczoomrotation24.h \
+	cczoomrotation32.h \
+	ccrgb16toyuv420.h \
+	ccrgb24torgb16.h \
+	ccyuv422toyuv420.h \
+	colorconv_config.h \
+	pvvideoblend.h \
+	ccrgb24toyuv420.h \
+	ccrgb12toyuv420.h \
+	ccyuv420semitoyuv420.h \
+	ccyuv420toyuv420semi.h
+
+include $(MK)/library.mk
diff --git a/codecs_v2/utilities/colorconvert/build/make/makefile b/codecs_v2/utilities/colorconvert/build/make/makefile
deleted file mode 100755
index a30bb5b..0000000
--- a/codecs_v2/utilities/colorconvert/build/make/makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = colorconvert
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS +=
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-XCPPFLAGS += -DFALSE=false
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	cczoomrotation12.cpp cczoomrotation16.cpp cczoomrotation24.cpp cczoomrotation32.cpp cczoomrotationbase.cpp ccyuv422toyuv420.cpp
-
-HDRS =  cczoomrotation12.h cczoomrotation16.h cczoomrotation24.h  cczoomrotation32.h cczoomrotationbase.h ccyuv422toyuv420.h colorconv_config.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/utilities/colorconvert/include/ccrgb12toyuv420.h b/codecs_v2/utilities/colorconvert/include/ccrgb12toyuv420.h
new file mode 100644
index 0000000..c94ed0d
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/include/ccrgb12toyuv420.h
@@ -0,0 +1,129 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CCRGB12TOYUV420_H_INCLUDED
+#define CCRGB12TOYUV420_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef CCZOOMROTATIONBASE_H_INCLUDED
+#include "cczoomrotationbase.h"
+#endif
+
+
+class CCRGB12toYUV420 : public ColorConvertBase
+{
+
+    public:
+        OSCL_IMPORT_REF static ColorConvertBase* New();
+        OSCL_IMPORT_REF ~CCRGB12toYUV420();
+
+
+        /**
+        	*	@brief The function initializes necessary lookup tables and verify the capability of the library before starting the operation.
+        	*   This function performs some initializations and memory allocations for the Y, Cb, Cr tables.
+
+        	*	@param Src_width specifies the width in pixel from the source to be color converted.
+        	*	@param Src_height specifies the height in pixel from the source to be color converted.
+        	*	@param Src_pitch is the actual memory width or stride of the source.
+        	*	@param Dst_width specifies the width in pixel of the output.
+        	*	@param Dst_height specifies the height in pixel of the output.
+        	*	@param Dst_pitch is the stride size of the destination memory.
+        	*	@param nRotation specifies whether rotation is to be applied. The value can be one of the followings
+        	*	CCROTATE_NONE (0), CCROTATE_CNTRCLKWISE (1) or CCROTATE_CLKWISE (3).
+        	*	When rotation is chosen, the Dst_width and Dst_height is still relative to the source coordinate,
+        	*	i.e., to rotate a QCIF image, the output width will be 144 and height will be 176.
+        	*	@return It returns 1 if success, 0 if fail, i.e.any of the above parameters is an odd number.
+        */
+        int32 Init(int32 Src_width,
+                   int32 Src_height,
+                   int32 Src_pitch,
+                   int32 Dst_width,
+                   int32 Dst_height,
+                   int32 Dst_pitch,
+                   int32 nRotation = 0);
+
+        /**
+        *	@brief As opposed to the definition defined in cczoomrotationbase.h, this function
+        sets the memory height of the YUV buffer which is the output instead of the input.
+        */
+
+        void SetMemHeight(int32 a_mHeight)
+        {
+            _mDst_mheight = a_mHeight;
+        };
+
+        /**
+        	*	@brief This function specifies whether the output will use the attribute specified
+        	*	in the Init(.) function or perform regular color conversion without scaling or rotation.
+        	*	@param nMode When set to 0, 1-to-1 color conversion only is done. When NMode is 1,
+        	*	the output is be of the size and orientation specified in Init().
+        	*	@return 0 if fails (capability not supported or not initialized), 1 if success.
+        */
+        int32 SetMode(int32 nMode);
+
+        /**
+        	*	@brief These functions convert input RGB into corresponding YUV output.
+        	*	@param rgb12 is a pointer to an input buffer.
+        	*	@param yuv420  is a pointer to an output buffer of Y plane assuming that the U and V planes are contiguous to the Y plane.
+        	*	@return This function return 1 if success, 0 if fail.
+        */
+        int32 Convert(uint8 *rgb12,
+                      uint8 *yuv420);
+
+        int32 Convert(uint8 *rgb12, uint8 **yuv420);
+
+
+        /**
+        	* @brief This function gives the size of the output YUV420 buffer
+        	* @return buffer size in bytes
+        */
+        int32 GetOutputBufferSize(void);
+
+        /**
+        	* @brief Implemenation of a virtual function for range.
+        	* @return default to 1.
+        */
+        int32  SetYuvFullRange(bool range);
+
+    private:
+
+        CCRGB12toYUV420();
+
+        /**
+         @brief This function frees the memory allocated for the YUV tables
+        */
+        void freeRGB2YUVTables();
+
+        /** @brief	Tables in color coversion */
+        uint8	*iY_Table, *iCb_Table, *iCr_Table;
+        uint8   *ipCb_Table, *ipCr_Table;
+
+        /** @brief  Memory height of the output YUV420 image, default to mDstHeight. **/
+        int32 _mDst_mheight;
+        bool	iBottomUp;
+
+};
+
+#endif // CCRGB12TOYUV420_H_INCLUDED
+
diff --git a/codecs_v2/utilities/colorconvert/include/ccrgb16toyuv420.h b/codecs_v2/utilities/colorconvert/include/ccrgb16toyuv420.h
old mode 100755
new mode 100644
index 9064637..ba3171b
--- a/codecs_v2/utilities/colorconvert/include/ccrgb16toyuv420.h
+++ b/codecs_v2/utilities/colorconvert/include/ccrgb16toyuv420.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,8 +100,6 @@
         int32 Convert(uint8 *rgb16,
                       uint8 *yuv420);
 
-
-
         /**
         	*	@brief These functions convert input YUV into corresponding RGB output.
         	*	@param yuv420 is an array of pointers to Y,U and V plane in increasing order.
@@ -109,7 +107,7 @@
         	*	@return This function return 1 if success, 0 if fail in the case of the rgbBuf
         	*	and/or yuvBuf[0] address are not word-aligned (multiple of 4).
         */
-        int32 Convert(uint8 **yuv420, uint8 *rgb16);
+        int32 Convert(uint8 *rgb16, uint8 **yuv420);
 
 
         /**
@@ -152,6 +150,8 @@
         /** @brief  Flag for using color key or not. **/
         bool	mUseColorKey;
 
+        bool	iBottomUp;
+
 };
 
 #endif // CCRGB16TOYUV420_H_INCLUDED
diff --git a/codecs_v2/utilities/colorconvert/include/ccrgb24torgb16.h b/codecs_v2/utilities/colorconvert/include/ccrgb24torgb16.h
old mode 100755
new mode 100644
index 2a1f6dd..4b83011
--- a/codecs_v2/utilities/colorconvert/include/ccrgb24torgb16.h
+++ b/codecs_v2/utilities/colorconvert/include/ccrgb24torgb16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/include/ccrgb24toyuv420.h b/codecs_v2/utilities/colorconvert/include/ccrgb24toyuv420.h
new file mode 100644
index 0000000..110e68a
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/include/ccrgb24toyuv420.h
@@ -0,0 +1,136 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CCRGB24TOYUV420_H_INCLUDED
+#define CCRGB24TOYUV420_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef CCZOOMROTATIONBASE_H_INCLUDED
+#include "cczoomrotationbase.h"
+#endif
+
+
+class CCRGB24toYUV420 : public ColorConvertBase
+{
+
+    public:
+        OSCL_IMPORT_REF static ColorConvertBase* New();
+        OSCL_IMPORT_REF ~CCRGB24toYUV420();
+
+
+        /**
+        	*	@brief The function initializes necessary lookup tables and verify the capability of the library before starting the operation.
+        	*   This function performs some initializations and memory allocations for the Y, Cb, Cr tables.
+
+        	*	@param Src_width specifies the width in pixel from the source to be color converted.
+        	*	@param Src_height specifies the height in pixel from the source to be color converted.
+        	*	@param Src_pitch is the actual memory width or stride of the source.
+        	*	@param Dst_width specifies the width in pixel of the output.
+        	*	@param Dst_height specifies the height in pixel of the output.
+        	*	@param Dst_pitch is the stride size of the destination memory.
+        	*	@param nRotation specifies whether rotation is to be applied. The value can be one of the followings
+        	*	CCROTATE_NONE (0), CCROTATE_CNTRCLKWISE (1) or CCROTATE_CLKWISE (3).
+        	*	When rotation is chosen, the Dst_width and Dst_height is still relative to the source coordinate,
+        	*	i.e., to rotate a QCIF image, the output width will be 144 and height will be 176.
+        	*	@return It returns 1 if success, 0 if fail, i.e.any of the above parameters is an odd number.
+        */
+        int32 Init(int32 Src_width,
+                   int32 Src_height,
+                   int32 Src_pitch,
+                   int32 Dst_width,
+                   int32 Dst_height,
+                   int32 Dst_pitch,
+                   int32 nRotation = 0);
+
+        /**
+        *	@brief As opposed to the definition defined in cczoomrotationbase.h, this function
+        sets the memory height of the YUV buffer which is the output instead of the input.
+        */
+
+        void SetMemHeight(int32 a_mHeight)
+        {
+            _mDst_mheight = a_mHeight;
+        };
+
+        /**
+        	*	@brief This function specifies whether the output will use the attribute specified
+        	*	in the Init(.) function or perform regular color conversion without scaling or rotation.
+        	*	@param nMode When set to 0, 1-to-1 color conversion only is done. When NMode is 1,
+        	*	the output is be of the size and orientation specified in Init().
+        	*	@return 0 if fails (capability not supported or not initialized), 1 if success.
+        */
+        int32 SetMode(int32 nMode);
+
+        /**
+        	*	@brief These functions convert input RGB into corresponding YUV output.
+        	*	@param rgb24 is a pointer to an input buffer.
+        	*	@param yuv420  is a pointer to an output buffer of Y plane assuming that the U and V planes are contiguous to the Y plane.
+        	*	@return This function return 1 if success, 0 if fail.
+        */
+        int32 Convert(uint8 *rgb24,
+                      uint8 *yuv420);
+
+        /**
+        	*	@brief These functions convert input YUV into corresponding RGB output.
+        	*	@param yuv420 is an array of pointers to Y,U and V plane in increasing order.
+        	*	@param rgb24 is a pointer to an output buffer.
+        	*	@return This function return 1 if success, 0 if fail in the case of the rgbBuf
+        	*	and/or yuvBuf[0] address are not word-aligned (multiple of 4).
+        */
+        int32 Convert(uint8 *rgb24, uint8 **yuv420);
+
+
+        /**
+        	* @brief This function gives the size of the output YUV420 buffer
+        	* @return buffer size in bytes
+        */
+        int32 GetOutputBufferSize(void);
+
+        /**
+        	* @brief Implemenation of a virtual function for range.
+        	* @return default to 1.
+        */
+        int32  SetYuvFullRange(bool range);
+
+    private:
+
+        CCRGB24toYUV420();
+
+        /**
+         @brief This function frees the memory allocated for the YUV tables
+        */
+        void freeRGB2YUVTables();
+
+        /** @brief	Tables in color coversion */
+        uint8	*iY_Table, *iCb_Table, *iCr_Table;
+        uint8   *ipCb_Table, *ipCr_Table;
+
+        /** @brief  Memory height of the output YUV420 image, default to mDstHeight. **/
+        int32 _mDst_mheight;
+        bool	iBottomUp;
+
+};
+
+#endif // CCRGB24TOYUV420_H_INCLUDED
+
diff --git a/codecs_v2/utilities/colorconvert/include/ccyuv420semitoyuv420.h b/codecs_v2/utilities/colorconvert/include/ccyuv420semitoyuv420.h
new file mode 100644
index 0000000..0a27c5c
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/include/ccyuv420semitoyuv420.h
@@ -0,0 +1,135 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CCYUV420SEMITOYUV420_H_INCLUDED
+#define CCYUV420SEMITOYUV420_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef CCZOOMROTATIONBASE_H_INCLUDED
+#include "cczoomrotationbase.h"
+#endif
+
+#ifndef COLORCONV_CONFIG_H_INCLUDED
+#include " colorconv_config.h"
+#endif
+
+#define SWAP_4(x)	((x<<24) | ((x&0xFF00)<<8) | ((x>>8)&0xFF00) | (x>>24))
+
+
+class CCYUV420SEMItoYUV420 : public ColorConvertBase
+{
+
+    public:
+
+        OSCL_IMPORT_REF static ColorConvertBase* New();
+        OSCL_IMPORT_REF ~CCYUV420SEMItoYUV420();
+
+        /**
+        	*	@brief The function initializes necessary lookup tables and verify the capability of the library before starting the operation.
+
+        	*	@param Src_width specifies the width in pixel from the source to be color converted.
+        	*	@param Src_height specifies the height in pixel from the source to be color converted.
+        	*	@param Src_pitch is the actual memory width or stride of the source.
+        	*	@param Dst_width specifies the width in pixel of the output.
+        	*	@param Dst_height specifies the height in pixel of the output.
+        	*	@param Dst_pitch is the stride size of the destination memory.
+        	*	@param nRotation specifies whether rotation is to be applied. The value can be one of the followings
+        	*	Rotation0, Rotation90,Rotation180, Rotation270
+        	*	When rotation is chosen, the Dst_width and Dst_height is still relative to the source coordinate,
+        	*	i.e., to rotate a QCIF image, the output width will be 144 and height will be 176.
+        	*	@return  Returns 1 if success, 0 if fail, i.e.,if output dimensions are different from the input dimensions,hence no scaling.
+        */
+
+        int32 Init(int32 Src_width,
+                   int32 Src_height,
+                   int32 Src_pitch,
+                   int32 Dst_width,
+                   int32 Dst_height,
+                   int32 Dst_pitch,
+                   int32 nRotation = 0);
+
+        /**
+        *	@brief As opposed to the definition defined in cczoomrotationbase.h, this function
+        sets the memory height of the YUV buffer which is the output instead of the input.
+        */
+
+        void SetMemHeight(int32 a_mHeight)
+        {
+            _mDst_mheight = a_mHeight;
+        };
+
+
+        /**
+        	*	@brief This function specifies whether the output will use the attribute specified
+        	*	in the Init(.) function or perform regular color conversion without scaling or rotation.
+        	*	@param nMode When set to 0, 1-to-1 color conversion only is done. When NMode is 1,
+        	*	the output is be of the size and orientation specified in Init().
+        	*	@return 0 if fails (capability not supported or not initialized), 1 if success.
+        */
+        int32 SetMode(int32 nMode);
+
+        /**
+        	*	@brief These functions convert input YUV420SEMI into corresponding YUV420 output.
+        	*	@param inyuv is a pointer to an input buffer.
+        	*	@param outyuv  is a pointer to an output buffer of Y plane assuming that the U and V planes are contiguous to the Y plane.
+        	*	@return This function return 1 if success, 0 if fail.
+        */
+        int32 Convert(uint8 *inyuv, uint8 *outyuv);
+
+        /**
+        	*	@brief These functions convert input YUV420SEMI into corresponding YUV420 output.
+        	*	@param yuvBuf is an array of pointers to Y,U and V plane in increasing order.
+        	*	@param outyuvBuf is a pointer to an output buffer.
+        	*	@return This function return 1 if success, 0 if fail in the case of the rgbBuf
+        	*	and/or yuvBuf[0] address are not word-aligned (multiple of 4).
+        */
+        int32 Convert(uint8 *inyuvBuf, uint8 **outyuvBuf);
+
+
+        /**
+        	* @brief This function gives the size of the output YUV420 buffer
+        	* @return buffer size in bytes
+        **/
+        int32 GetOutputBufferSize(void);
+
+        /**
+        *         *       @brief This function specifies the range of the YCbCr input such that the
+        *                 *       conversion to RGB is done accordingly (see ISO/IEC 14496-2:2004/FPDAM 3)..
+        *                         *       @param range  a boolean, false or zero means the range of the Y is 16-235,
+        *                                 *   true or one means the full range of 0-255 is used. The default range is false.
+        *                                         */
+
+        virtual int32  SetYuvFullRange(bool range);
+
+    private:
+        CCYUV420SEMItoYUV420();
+
+        int32 _mSrc_width, _mSrc_height, _mSrc_pitch, _mDst_width, _mDst_height, _mDst_pitch;
+        int32 _mRotation;
+        int32 _mDst_mheight;
+
+};
+
+#endif // CCYUV420SEMITOYUV420_H_INCLUDED
+
diff --git a/codecs_v2/utilities/colorconvert/include/ccyuv420toyuv420semi.h b/codecs_v2/utilities/colorconvert/include/ccyuv420toyuv420semi.h
new file mode 100644
index 0000000..5e946d9
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/include/ccyuv420toyuv420semi.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CCYUV420TOYUV420SEMI_H_INCLUDED
+#define CCYUV420TOYUV420SEMI_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef CCZOOMROTATIONBASE_H_INCLUDED
+#include "cczoomrotationbase.h"
+#endif
+
+class ColorConvertYUV420SEMI: public ColorConvertBase
+{
+    public:
+
+        OSCL_IMPORT_REF static ColorConvertBase* NewL(void);
+        OSCL_IMPORT_REF ~ColorConvertYUV420SEMI();
+
+        int32 Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation = 0);
+        int32 SetYuvFullRange(bool range);
+        int32 SetMode(int32 nMode);	//nMode : 0 Off, 1 On
+        int32 Convert(uint8 *yuvBuf, uint8 *rgbBuf);
+        int32 Convert(uint8 **yuvBuf, uint8 *rgbBuf);
+        int32 GetOutputBufferSize(void);
+
+    private:
+        ColorConvertYUV420SEMI();
+
+};
+
+#endif // CCYUV420TOYUV420SEMI_H_INCLUDED
+
+
+
diff --git a/codecs_v2/utilities/colorconvert/include/ccyuv422toyuv420.h b/codecs_v2/utilities/colorconvert/include/ccyuv422toyuv420.h
old mode 100755
new mode 100644
index 44444d9..0ab04c7
--- a/codecs_v2/utilities/colorconvert/include/ccyuv422toyuv420.h
+++ b/codecs_v2/utilities/colorconvert/include/ccyuv422toyuv420.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/include/cczoomrotation12.h b/codecs_v2/utilities/colorconvert/include/cczoomrotation12.h
index 3125b66..7ef0df3 100644
--- a/codecs_v2/utilities/colorconvert/include/cczoomrotation12.h
+++ b/codecs_v2/utilities/colorconvert/include/cczoomrotation12.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/include/cczoomrotation16.h b/codecs_v2/utilities/colorconvert/include/cczoomrotation16.h
index 31ffbcc..3f1e7ba 100644
--- a/codecs_v2/utilities/colorconvert/include/cczoomrotation16.h
+++ b/codecs_v2/utilities/colorconvert/include/cczoomrotation16.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/include/cczoomrotation24.h b/codecs_v2/utilities/colorconvert/include/cczoomrotation24.h
index 1222878..fc48f09 100644
--- a/codecs_v2/utilities/colorconvert/include/cczoomrotation24.h
+++ b/codecs_v2/utilities/colorconvert/include/cczoomrotation24.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/include/cczoomrotation32.h b/codecs_v2/utilities/colorconvert/include/cczoomrotation32.h
index 7d3c022..8c3cac3 100644
--- a/codecs_v2/utilities/colorconvert/include/cczoomrotation32.h
+++ b/codecs_v2/utilities/colorconvert/include/cczoomrotation32.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@
 
         int32 get_frame32(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *COFF_TBL);
         int32 cc32ZoomIn(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *COFF_TBL);
-
+        int32 cc32Rotate(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *COFF_TBL);
         int32(ColorConvert32::*mPtrYUV2RGB)(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *COFF_TBL);
 };
 
@@ -60,3 +60,6 @@
 
 
 
+
+
+
diff --git a/codecs_v2/utilities/colorconvert/include/cczoomrotationbase.h b/codecs_v2/utilities/colorconvert/include/cczoomrotationbase.h
index 5e78905..55e16b7 100644
--- a/codecs_v2/utilities/colorconvert/include/cczoomrotationbase.h
+++ b/codecs_v2/utilities/colorconvert/include/cczoomrotationbase.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@
 #define CCROTATE_180			 2
 #define CCROTATE_CLKWISE         3
 #define	CCFLIP					 4
+#define CCBOTTOM_UP				 8
 
 /**
 *	Description - This is the base class of color converter classes.
@@ -126,17 +127,6 @@
         virtual	int32 Convert(uint8 *srcBuf, uint8 *destBuf) = 0;
 
         /**
-        *	@brief These functions convert the input buffer data into the output format
-        *   and write the converted data to the output buffer.
-        *	@param srcBuf is an array of pointers to Y,U and V plane in increasing order.
-        *	@param destBuf is a pointer to an output buffer.
-        *	@return This function return 1 if success, 0 if fail in the case of the destBuf
-        *	and/or srcBuf address are not word-aligned (multiple of 4).
-        */
-
-        virtual int32 Convert(uint8 **srcBuf, uint8 *destBuf) = 0;
-
-        /**
         *	@brief This function returns the size of output buffer that users need
         *	to allocate and pass it in as an input argument to Convert() function.
         *	Depending on the input argument to SetMode(), the buffer size can change.
diff --git a/codecs_v2/utilities/colorconvert/include/colorconv_config.h b/codecs_v2/utilities/colorconvert/include/colorconv_config.h
old mode 100755
new mode 100644
index 8795493..53af1b9
--- a/codecs_v2/utilities/colorconvert/include/colorconv_config.h
+++ b/codecs_v2/utilities/colorconvert/include/colorconv_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/include/pvvideoblend.h b/codecs_v2/utilities/colorconvert/include/pvvideoblend.h
old mode 100755
new mode 100644
index 82d80f6..b1d048a
--- a/codecs_v2/utilities/colorconvert/include/pvvideoblend.h
+++ b/codecs_v2/utilities/colorconvert/include/pvvideoblend.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/src/ccrgb12toyuv420.cpp b/codecs_v2/utilities/colorconvert/src/ccrgb12toyuv420.cpp
new file mode 100644
index 0000000..6ac7191
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/ccrgb12toyuv420.cpp
@@ -0,0 +1,530 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/** class CCRGB12toYUV420.cpp
+*/
+#include "ccrgb12toyuv420.h"
+
+OSCL_EXPORT_REF ColorConvertBase* CCRGB12toYUV420 :: New()
+{
+    CCRGB12toYUV420* self = OSCL_NEW(CCRGB12toYUV420, ());
+    return OSCL_STATIC_CAST(ColorConvertBase*, self);
+}
+
+
+CCRGB12toYUV420::CCRGB12toYUV420()
+{
+}
+
+
+OSCL_EXPORT_REF CCRGB12toYUV420 :: ~CCRGB12toYUV420()
+{
+// add destructor code here
+    if (_mInitialized == true)
+    {
+        freeRGB2YUVTables();
+    }
+}
+
+
+void CCRGB12toYUV420::freeRGB2YUVTables()
+{
+    if (iY_Table) oscl_free(iY_Table);
+    if (iCb_Table) oscl_free(iCb_Table);
+    if (iCr_Table) oscl_free(iCr_Table);
+
+    iY_Table  = NULL;
+    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
+
+}
+
+
+int32 CCRGB12toYUV420:: Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width,
+                             int32 Dst_height, int32 Dst_pitch, int32 nRotation)
+{
+    int i;
+    uint8 *pTable;
+
+    if ((Src_width != Dst_width) || (Src_height != Dst_height) || (nRotation != 0 && nRotation != CCBOTTOM_UP))
+    {
+        return 0;
+    }
+
+    iBottomUp = false;
+    if (nRotation == CCBOTTOM_UP)
+    {
+        iBottomUp = true;
+    }
+
+    if (_mInitialized == true)
+    {
+        freeRGB2YUVTables();
+        _mInitialized = false;
+    }
+
+    /* memory allocation */
+    if ((iY_Table = (uint8*)oscl_malloc(384)) == NULL)
+        return 0;
+
+    if ((iCb_Table = (uint8*)oscl_malloc(768 * 2)) == NULL)
+        return 0;
+
+    if ((iCr_Table = (uint8*)oscl_malloc(768 * 2)) == NULL)
+        return 0;
+
+#define pv_max(a, b)	((a) >= (b) ? (a) : (b))
+#define pv_min(a, b)	((a) <= (b) ? (a) : (b))
+
+    /* Table generation */
+    for (i = 0; i < 384; i++)
+        iY_Table[i] = (uint8) pv_max(pv_min(255, (int32)(0.7152 * i + 16 + 0.5)), 0);
+
+    pTable = iCb_Table + 384;
+    for (i = -384; i < 384; i++)
+        pTable[i] = (uint8) pv_max(pv_min(255, (int32)(0.386 * i + 128 + 0.5)), 0);
+    ipCb_Table = iCb_Table + 384;
+
+    pTable = iCr_Table + 384;
+    for (i = -384; i < 384; i++)
+        pTable[i] = (uint8) pv_max(pv_min(255, (int32)(0.454 * i + 128 + 0.5)), 0);
+    ipCr_Table = iCr_Table + 384;
+
+
+    _mSrc_width  = Src_width;
+    _mSrc_height = Src_height;
+    _mSrc_pitch = Src_pitch;
+    _mDst_width = Dst_width;
+    _mDst_height = Dst_height;
+    _mDst_mheight = Dst_height;
+    _mDst_pitch = Dst_pitch;
+    _mInitialized = true;
+
+    SetMode(0);
+
+    return 1;
+}
+
+
+int32 CCRGB12toYUV420::GetOutputBufferSize(void)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    // only return value for _mState = 0 case
+    return ((((_mSrc_width + 15) >> 4) << 4) * (((_mSrc_height + 15) >> 4) << 4) * 3 / 2);
+}
+
+
+int32 CCRGB12toYUV420::SetMode(int32 nMode)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    if (nMode == 1) // do not allow scaling nor rotation
+    {
+        _mState = 1;
+        return 0;
+    }
+    else
+    {
+        _mState = 0;
+        return 1;
+    }
+}
+
+int32 CCRGB12toYUV420::SetYuvFullRange(bool range)
+{
+    OSCL_ASSERT(_mInitialized == true);
+    if (range == true)
+    {
+        return 0; // not supported yet
+    }
+    else
+    {
+        return 1;
+    }
+}
+
+extern "C"
+{
+    int32 ccrgb12toyuv(uint8 *rgb12, uint8 *yuv[], uint32 *param, uint8 *table[]);
+}
+
+int32 CCRGB12toYUV420::Convert(uint8 *rgb12, uint8 *yuv420)
+{
+    uint32 param[3];
+    uint8 *table[3];
+    int32 size16 = _mDst_pitch * _mDst_mheight;
+    uint8 *yuv[3];
+
+    OSCL_ASSERT(rgb12);
+    OSCL_ASSERT(yuv420);
+    OSCL_ASSERT(_mInitialized == true);
+
+    param[0] = (uint32) _mSrc_width;
+    param[1] = (uint32) _mSrc_height;
+    param[2] = (uint32) iBottomUp;
+
+    table[0] = iY_Table;
+    table[1] = ipCb_Table;
+    table[2] = ipCr_Table;
+
+    yuv[0] = yuv420;
+    yuv[1] = yuv420 + size16;
+    yuv[2] = yuv[1] + (size16 >> 2);
+
+    return ccrgb12toyuv(rgb12, yuv, param, table);
+
+}
+
+int32 CCRGB12toYUV420::Convert(uint8 *rgb12, uint8 **yuv420)
+{
+    uint32 param[3];
+    uint8 *table[3];
+
+    OSCL_ASSERT(rgb12);
+    OSCL_ASSERT(yuv420);
+    OSCL_ASSERT(yuv420[0]);
+    OSCL_ASSERT(yuv420[1]);
+    OSCL_ASSERT(yuv420[2]);
+    OSCL_ASSERT(_mInitialized == true);
+
+    param[0] = (uint32) _mSrc_width;
+    param[1] = (uint32) _mSrc_height;
+    param[2] = (uint32) iBottomUp;
+
+    table[0] = iY_Table;
+    table[1] = ipCb_Table;
+    table[2] = ipCr_Table;
+
+    return ccrgb12toyuv(rgb12, yuv420, param, table);
+
+}
+
+int32 ccrgb12toyuv(uint8 *rgb12, uint8 *yuv[], uint32 *param, uint8 *table[])
+{
+    uint32 *inputRGB = NULL;
+    int i, j, ilimit, jlimit;
+    uint32 *tempY, *tempU, *tempV;
+    uint32 pixels;
+    uint32 pixels_nextRow;
+    uint32 yuv_value;
+    uint32 yuv_value1;
+    uint32 yuv_value2;
+    int R_ds; /* "_ds" is the downsample version */
+    int G_ds; /* "_ds" is the downsample version */
+    int B_ds; /* "_ds" is the downsample version */
+    int tmp;
+    uint32 temp;
+
+    int32 width = param[0];
+    int32 height = param[1];
+    int32 width_16 = ((width + 15) >> 4) << 4;
+    int32 height_16 = ((height + 15) >> 4) << 4;
+    uint32 iBottomUp = param[2];
+    uint8 *y_tab = table[0];
+    uint8 *cb_tab = table[1];
+    uint8 *cr_tab = table[2];
+    int32 size16 = height_16 * width_16;
+    int adjust = (width >> 1);
+
+    inputRGB = (uint32*) rgb12;
+
+    /* do padding at the bottom first */
+    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
+    if (height < height_16 || width < width_16)
+    { /* if padding */
+        int offset = (height < height_16) ? height : height_16;
+
+        offset = (offset * width_16);
+
+        if (width < width_16)
+        {
+            offset -= (width_16 - width);
+        }
+
+        tempY = (uint32 *)yuv[0] + (offset >> 2);
+        oscl_memset((uint8 *)tempY, 16, size16 - offset); /* pad with zeros */
+
+        tempU = (uint32 *)yuv[0] + (size16 >> 2) + (offset >> 4);
+        oscl_memset((uint8 *)tempU, 128, (size16 - offset) >> 2);
+
+        tempV = (uint32 *)yuv[0] + (size16 >> 2) + (size16 >> 4) + (offset >> 4);
+        oscl_memset((uint8 *)tempV, 128, (size16 - offset) >> 2);
+    }
+
+    /* then do padding on the top */
+    tempY = (uint32 *)yuv[0]; /* Normal order */
+    tempU = tempY + ((size16) >> 2);
+    tempV = tempU + ((size16) >> 4);
+
+    /* To center the output */
+    if (height_16 > height)
+    {
+        if (width_16 >= width)
+        {
+            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+        }
+        else
+        {
+            i = ((height_16 - height) >> 1) * width_16;
+            j = ((height_16 - height) >> 2) * (width_16 >> 1);
+            inputRGB += (width - width_16) >> 2;
+        }
+        oscl_memset((uint8 *)tempY, 16, i);
+        tempY += (i >> 2);
+        oscl_memset((uint8 *)tempU, 128, j);
+        tempU += (j >> 2);
+        oscl_memset((uint8 *)tempV, 128, j);
+        tempV += (j >> 2);
+    }
+    else
+    {
+        if (width_16 >= width)
+        {
+            i = (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+            inputRGB += (((height - height_16) >> 1) * width) >> 1;
+
+            oscl_memset((uint8 *)tempY, 16, i);
+            tempY += (i >> 2);
+            oscl_memset((uint8 *)tempU, 128, j);
+            tempU += (j >> 2);
+            oscl_memset((uint8 *)tempV, 128, j);
+            tempV += (j >> 2);
+
+        }
+        else
+        {
+            i = 0;
+            j = 0;
+            inputRGB += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 1 ;
+        }
+    }
+
+    /* ColorConv RGB12-to-YUV420 with cropping or zero-padding */
+    if (height < height_16)
+    {
+        jlimit = height;
+    }
+    else
+    {
+        jlimit = height_16;
+    }
+
+    if (width < width_16)
+    {
+        ilimit = width >> 1;
+    }
+    else
+    {
+        ilimit = width_16 >> 1;
+    }
+
+    if (iBottomUp == 1)
+    {
+        inputRGB += (jlimit - 1) * (width >> 1) ; // move to last row
+        adjust = -adjust;
+    }
+
+    width = width_16 - width;
+
+
+    for (j = 0; j < jlimit; j++)
+    {
+
+        for (i = 0; i < ilimit; i += 4)
+        {
+            pixels =  inputRGB[i];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            yuv_value = (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
+
+            pixels =  inputRGB[i+1];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            *tempY++ = (yuv_value                                                         |
+                        (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
+
+            pixels =  inputRGB[i+2];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            yuv_value = (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
+
+            pixels =  inputRGB[i+3];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            *tempY++ = (yuv_value                                                         |
+                        (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
+
+
+            /* downsampling U, V */
+
+            pixels_nextRow = inputRGB[i+3+adjust/*(width>>1)*/];
+            G_ds    =  pixels & 0x00F000F0;
+            G_ds   += (pixels_nextRow & 0x00F000F0);
+            G_ds   += (G_ds >> 16);
+
+            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
+
+            pixels &= 0x0F0F0F0F;
+            pixels += (pixels_nextRow & 0x0F0F0F0F);
+
+            pixels += (pixels >> 16);
+
+            B_ds = (pixels & 0x0003F) << 4;
+
+            R_ds = (pixels & 0x03F00) >> 4;
+
+            tmp  = B_ds - R_ds;
+
+            yuv_value1 = cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 24;
+            yuv_value2 = cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 24;
+
+            pixels =  inputRGB[i+2];
+            pixels_nextRow = inputRGB[i+2+adjust/*(width>>1)*/];
+
+            G_ds    =  pixels & 0x00F000F0;
+            G_ds   += (pixels_nextRow & 0x00F000F0);
+            G_ds   += (G_ds >> 16);
+
+            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
+
+            pixels &= 0x0F0F0F0F;
+            pixels += (pixels_nextRow & 0x0F0F0F0F);
+
+            pixels += (pixels >> 16);
+
+            B_ds = (pixels & 0x0003F) << 4;
+
+            R_ds = (pixels & 0x03F00) >> 4;
+            tmp  = B_ds - R_ds;
+
+            yuv_value1 |= cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 16;
+            yuv_value2 |= cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 16;
+
+            pixels =  inputRGB[i+1];
+            pixels_nextRow = inputRGB[i+1+adjust /*(width>>1)*/];
+
+            G_ds    =  pixels & 0x00F000F0;
+            G_ds   += (pixels_nextRow & 0x00F000F0);
+            G_ds   += (G_ds >> 16);
+
+            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
+
+            pixels &= 0x0F0F0F0F;
+            pixels += (pixels_nextRow & 0x0F0F0F0F);
+
+            pixels += (pixels >> 16);
+
+            B_ds = (pixels & 0x0003F) << 4;
+
+            R_ds = (pixels & 0x03F00) >> 4;
+            tmp  = B_ds - R_ds;
+
+
+            yuv_value1 |= cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 8;
+            yuv_value2 |= cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 8;
+
+            pixels =  inputRGB[i];
+            pixels_nextRow = inputRGB[i+adjust/*(width>>1)*/];
+
+            G_ds    =  pixels & 0x00F000F0;
+            G_ds   += (pixels_nextRow & 0x00F000F0);
+            G_ds   += (G_ds >> 16);
+
+            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
+
+            pixels &= 0x0F0F0F0F;
+            pixels += (pixels_nextRow & 0x0F0F0F0F);
+
+            pixels += (pixels >> 16);
+
+            B_ds = (pixels & 0x0003F) << 4;
+
+            R_ds = (pixels & 0x03F00) >> 4;
+            tmp  = B_ds - R_ds;
+
+            *tempU++ = yuv_value1 | (cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18]);
+            *tempV++ = yuv_value2 | (cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18]);
+        }
+
+        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
+
+        if ((width > 0) && j < jlimit - 1)
+        {
+            oscl_memset((uint8 *)tempY, 16/*(*(tempY-1))>>24*/, width);
+            tempY += width >> 2;
+        }
+
+        if (j++ == (jlimit - 1))
+        {
+            break; /* dealing with a odd height */
+        }
+
+        if ((width > 0) && j < jlimit - 1)
+        {
+            oscl_memset((uint8 *)tempU, 128/*(*(tempU-1))>>24*/, width >> 1);
+            tempU += width >> 3;
+            oscl_memset((uint8 *)tempV, 128/*(*(tempV-1))>>24*/, width >> 1);
+            tempV += width >> 3;
+        }
+
+        inputRGB += adjust; /* (160/2 = 80 ) */ /*(width>>1)*/; /* move to the next row */
+
+        for (i = 0; i < ilimit; i += 4)
+        {
+            pixels =  inputRGB[i];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            yuv_value = (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
+
+            pixels =  inputRGB[i+1];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            *tempY++ = (yuv_value                                                         |
+                        (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
+
+            pixels =  inputRGB[i+2];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            yuv_value = (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
+
+            pixels =  inputRGB[i+3];
+            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
+            *tempY++ = (yuv_value                                                         |
+                        (y_tab[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
+                         (y_tab[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
+
+        }
+
+        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
+        if ((width > 0) && j < jlimit - 1)
+        {
+            oscl_memset((uint8 *)tempY, 16/*(*(tempY-1))>>24*/, width);
+            tempY += width >> 2;
+        }
+
+        inputRGB += adjust; /* (160/2 = 80 ) */ /*(width>>1)*/; /* move to the next row */
+
+    } /* for(j=0; j<jlimit; j++)*/
+
+    return 1;
+}
diff --git a/codecs_v2/utilities/colorconvert/src/ccrgb16toyuv420.cpp b/codecs_v2/utilities/colorconvert/src/ccrgb16toyuv420.cpp
new file mode 100644
index 0000000..28308c9
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/ccrgb16toyuv420.cpp
@@ -0,0 +1,529 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/** class CCRGB16toYUV420.cpp
+*/
+#include "ccrgb16toyuv420.h"
+
+OSCL_EXPORT_REF ColorConvertBase* CCRGB16toYUV420 :: New()
+{
+    CCRGB16toYUV420* self = OSCL_NEW(CCRGB16toYUV420, ());
+    return OSCL_STATIC_CAST(ColorConvertBase*, self);
+}
+
+
+CCRGB16toYUV420::CCRGB16toYUV420()
+{
+}
+
+
+OSCL_EXPORT_REF CCRGB16toYUV420 :: ~CCRGB16toYUV420()
+{
+// add destructor code here
+    if (_mInitialized == true)
+    {
+        freeRGB2YUVTables();
+    }
+}
+
+
+void CCRGB16toYUV420::freeRGB2YUVTables()
+{
+    if (iY_Table) oscl_free(iY_Table);
+    if (iCb_Table) oscl_free(iCb_Table);
+    if (iCr_Table) oscl_free(iCr_Table);
+
+    iY_Table  = NULL;
+    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
+
+}
+
+
+int32 CCRGB16toYUV420:: Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width,
+                             int32 Dst_height, int32 Dst_pitch, int32 nRotation)
+{
+    int i;
+    uint8 *pTable;
+
+    if ((Src_width != Dst_width) || (Src_height != Dst_height) || (nRotation != 0 && nRotation != CCBOTTOM_UP))
+    {
+        return 0;
+    }
+
+    iBottomUp = false;
+    if (nRotation == CCBOTTOM_UP)
+    {
+        iBottomUp = true;
+    }
+
+    if (_mInitialized == true)
+    {
+        freeRGB2YUVTables();
+        _mInitialized = false;
+    }
+
+    /* memory allocation */
+    if ((iY_Table = (uint8*)oscl_malloc(384)) == NULL)
+        return 0;
+
+    if ((iCb_Table = (uint8*)oscl_malloc(768 * 2)) == NULL)
+        return 0;
+
+    if ((iCr_Table = (uint8*)oscl_malloc(768 * 2)) == NULL)
+        return 0;
+
+#define pv_max(a, b)	((a) >= (b) ? (a) : (b))
+#define pv_min(a, b)	((a) <= (b) ? (a) : (b))
+
+    /* Table generation */
+    for (i = 0; i < 384; i++)
+        iY_Table[i] = (uint8) pv_max(pv_min(255, (int32)(0.7152 * i + 16 + 0.5)), 0);
+
+    pTable = iCb_Table + 384;
+    for (i = -384; i < 384; i++)
+        pTable[i] = (uint8) pv_max(pv_min(255, (int32)(0.386 * i + 128 + 0.5)), 0);
+    ipCb_Table = iCb_Table + 384;
+
+    pTable = iCr_Table + 384;
+    for (i = -384; i < 384; i++)
+        pTable[i] = (uint8) pv_max(pv_min(255, (int32)(0.454 * i + 128 + 0.5)), 0);
+    ipCr_Table = iCr_Table + 384;
+
+
+    _mSrc_width  = Src_width;
+    _mSrc_height = Src_height;
+    _mSrc_pitch = Src_pitch;
+    _mDst_width = Dst_width;
+    _mDst_height = Dst_height;
+    _mDst_mheight = Dst_height;
+    _mDst_pitch = Dst_pitch;
+
+    mUseColorKey = false;
+    _mInitialized = true;
+
+    SetMode(0); // called after init
+
+    return 1;
+}
+
+
+int32 CCRGB16toYUV420::GetOutputBufferSize(void)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    return ((((_mSrc_width + 15) >> 4) << 4) * (((_mSrc_height + 15) >> 4) << 4) * 3 / 2);
+}
+
+
+int32 CCRGB16toYUV420::SetMode(int32 nMode)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    if (nMode == 1) // do not allow scaling nor rotation
+    {
+        _mState = 1;
+        return 0;
+    }
+    else
+    {
+        _mState = 0;
+        return 1;
+    }
+}
+
+
+void CCRGB16toYUV420:: SetColorkey(int16 colorkey)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    mColorKey = colorkey;
+    mUseColorKey = true;
+}
+
+
+int32 CCRGB16toYUV420::SetYuvFullRange(bool range)
+{
+    OSCL_ASSERT(_mInitialized == true);
+    if (range == true)
+    {
+        return 0; // not supported yet
+    }
+    else
+    {
+        return 1;
+    }
+}
+
+extern "C"
+{
+    int32 ccrgb16toyuv(uint8 *rgb16, uint8 *yuv[], uint32 *param, uint8 *table[]);
+    int32 ccrgb16toyuv_wo_colorkey(uint8 *rgb16, uint8 *yuv[], uint32 *param, uint8 *table[]);
+}
+
+int32 CCRGB16toYUV420::Convert(uint8 *rgb16, uint8 *yuv420)
+{
+    uint32 param[7];
+    uint8 *table[3];
+    int32 size16 = _mDst_pitch * _mDst_mheight;
+    uint8 *yuv[3];
+
+    OSCL_ASSERT(rgb16);
+    OSCL_ASSERT(yuv420);
+    OSCL_ASSERT(_mInitialized == true);
+
+    param[0] = (uint32) _mDst_width;
+    param[1] = (uint32) _mDst_height;
+    param[2] = (uint32) _mDst_pitch;
+    param[3] = (uint32) _mDst_mheight;
+    param[4] = (uint32) _mSrc_pitch;
+    param[5] = (uint32) mColorKey;
+    param[6] = (uint32) iBottomUp;
+
+    table[0] = iY_Table;
+    table[1] = ipCb_Table;
+    table[2] = ipCr_Table;
+
+    yuv[0] = yuv420;
+    yuv[1] = yuv420 + size16;
+    yuv[2] = yuv[1] + (size16 >> 2);
+
+    if (mUseColorKey == true)
+    {
+        return ccrgb16toyuv(rgb16, yuv, param, table);
+    }
+    else
+    {
+        return ccrgb16toyuv_wo_colorkey(rgb16, yuv, param, table);
+    }
+}
+
+extern "C"
+{
+
+    int32 ccrgb16toyuv(uint8 *rgb16, uint8 *yuv[], uint32 *param, uint8 *table[])
+    {
+        uint16 *inputRGB = (uint16*)rgb16;
+        int32 width_dst = param[0];
+        int32 height_dst = param[1];
+        int32 pitch_dst = param[2];
+        int32 pitch_src = param[4];
+        uint16 colorkey = param[5];
+        uint8 *y_tab = table[0];
+        uint8 *cb_tab = table[1];
+        uint8 *cr_tab = table[2];
+
+        int32 i, j, count;
+        int32 ilimit, jlimit;
+        uint8 *tempY, *tempU, *tempV;
+        uint16 pixels;
+        uint8 yuv_value;
+        int32 R_ds; /* "_ds" is the downsample version */
+        int32 G_ds; /* "_ds" is the downsample version */
+        int32 B_ds; /* "_ds" is the downsample version */
+        int   tmp;
+        uint32 temp;
+        uint16 cb, cr;
+
+        //for writing to the YUV buffer which is a pointer to uint32
+        tempY = yuv[0];
+        tempU = yuv[1];
+        tempV = yuv[2];
+
+        jlimit = height_dst;
+        ilimit = width_dst;
+
+#define ALPHA 413		// 413  = (int) ((0.0722/0.7152)* (2^12)) for B, 2^12 is for hitting 16bit range for SIMD calculation,
+#define BETA  1218		// 1218 = (int) ((0.2126/0.7152)* (2^12)) for R  5bit B/R => ALPHA and BETA < 2^11
+#define SHIFT_INDEX1 9  // 9    = 12 - 3, 3 refers to the number of bits right shifted for 5 bit B/R in an 8-bit octet
+#define SHIFT_INDEX2 25 // 25   = 9  + 16
+
+        for (j = 0; j < jlimit; j += 2)
+        {
+            for (i = 0; i < ilimit; i += 2)
+            {
+                G_ds = B_ds = R_ds = count = 0;
+
+                pixels =  inputRGB[i];
+                if (pixels != colorkey)
+                {
+                    temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                    yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                    *tempY = yuv_value;
+
+                    G_ds    += (pixels >> 1) & 0x03E0;
+                    B_ds    += (pixels << 5) & 0x03E0;
+                    R_ds    += (pixels >> 6) & 0x03E0;
+                    count++;
+                }
+
+                pixels =  inputRGB[i+pitch_src];
+                if (pixels != colorkey)
+                {
+                    temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                    yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                    *(tempY + pitch_dst) = yuv_value;
+
+                    G_ds    += (pixels >> 1) & 0x03E0;
+                    B_ds    += (pixels << 5) & 0x03E0;
+                    R_ds    += (pixels >> 6) & 0x03E0;
+                    count++;
+                }
+
+                tempY++;
+
+                pixels =  inputRGB[i+1];
+                if (pixels != colorkey)
+                {
+                    temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                    yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                    *tempY = yuv_value;
+
+                    G_ds    += (pixels >> 1) & 0x03E0;
+                    B_ds    += (pixels << 5) & 0x03E0;
+                    R_ds    += (pixels >> 6) & 0x03E0;
+                    count++;
+                }
+
+                pixels =  inputRGB[i+1+pitch_src];
+                if (pixels != colorkey)
+                {
+                    temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                    yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                    *(tempY + pitch_dst) = yuv_value;
+
+                    G_ds    += (pixels >> 1) & 0x03E0;
+                    B_ds    += (pixels << 5) & 0x03E0;
+                    R_ds    += (pixels >> 6) & 0x03E0;
+                    count++;
+                }
+
+                tempY++;
+
+                if (count == 1) // three matches
+                {
+                    tmp = B_ds - R_ds;
+
+                    cb = cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18];
+                    cr = cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18];
+
+                    *tempU = (cb + 3 * (*tempU)) >> 2;
+                    *tempV = (cr + 3 * (*tempV)) >> 2;
+
+                }
+                else if (count == 2) // two matches
+                {
+                    R_ds >>= 1;
+                    B_ds >>= 1;
+                    G_ds >>= 1;
+
+                    tmp = B_ds - R_ds;
+
+                    cb = cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18];
+                    cr = cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18];
+
+                    *tempU = (cb + (*tempU)) >> 1;
+                    *tempV = (cr + (*tempV)) >> 1;
+
+                }
+                else if (count == 3) // one match
+                {
+                    R_ds = R_ds / 3;
+                    B_ds = B_ds / 3;
+                    G_ds = G_ds / 3;
+
+                    tmp = B_ds - R_ds;
+
+                    cb = cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18];
+                    cr = cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18];
+
+                    *tempU = (3 * cb + *tempU) >> 2;
+                    *tempV = (3 * cr + *tempV) >> 2;
+
+                }
+                else if (count == 4) // no match
+                {
+                    R_ds >>= 2;
+                    B_ds >>= 2;
+                    G_ds >>= 2;
+
+                    tmp = B_ds - R_ds;
+
+                    *tempU = cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18];
+                    *tempV = cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18];
+                }
+
+                tempU++;
+                tempV++;
+            }
+
+            inputRGB += pitch_src << 1;
+            tempY += (pitch_dst - width_dst) + pitch_dst;
+            tempU += ((pitch_dst - width_dst)) >> 1;
+            tempV += ((pitch_dst - width_dst)) >> 1;
+        }
+
+        return 1;
+    }
+
+
+    int32 ccrgb16toyuv_wo_colorkey(uint8 *rgb16, uint8 *yuv[], uint32 *param, uint8 *table[])
+    {
+        uint16 *inputRGB = (uint16*)rgb16;
+        int32 width_dst = param[0];
+        int32 height_dst = param[1];
+        int32 pitch_dst = param[2];
+        int32 pitch_src = param[4];
+        uint32 iBottomUp = param[6];
+        uint8 *y_tab = table[0];
+        uint8 *cb_tab = table[1];
+        uint8 *cr_tab = table[2];
+
+        int32 i, j, count;
+        int32 ilimit, jlimit;
+        uint8 *tempY, *tempU, *tempV;
+        uint16 pixels;
+        uint8 yuv_value;
+        int32 R_ds; /* "_ds" is the downsample version */
+        int32 G_ds; /* "_ds" is the downsample version */
+        int32 B_ds; /* "_ds" is the downsample version */
+        int   tmp;
+        uint32 temp;
+
+        //for writing to the YUV buffer which is a pointer to uint32
+        tempY = yuv[0];
+        tempU = yuv[1];
+        tempV = yuv[2];
+
+        jlimit = height_dst;
+        ilimit = width_dst;
+
+        if (iBottomUp == 1)
+        {
+            inputRGB += (jlimit - 1) * width_dst; // move to last row
+            pitch_src = -pitch_src;
+        }
+
+#define ALPHA 413		// 413  = (int) ((0.0722/0.7152)* (2^12)) for B, 2^12 is for hitting 16bit range for SIMD calculation,
+#define BETA  1218		// 1218 = (int) ((0.2126/0.7152)* (2^12)) for R  5bit B/R => ALPHA and BETA < 2^11
+#define SHIFT_INDEX1 9  // 9    = 12 - 3, 3 refers to the number of bits right shifted for 5 bit B/R in an 8-bit octet
+#define SHIFT_INDEX2 25 // 25   = 9  + 16
+
+        for (j = 0; j < jlimit; j += 2)
+        {
+            for (i = 0; i < ilimit; i += 2)
+            {
+                G_ds = B_ds = R_ds = count = 0;
+
+                pixels =  inputRGB[i];
+                temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                *tempY = yuv_value;
+
+                G_ds    += (pixels >> 1) & 0x03E0;
+                B_ds    += (pixels << 5) & 0x03E0;
+                R_ds    += (pixels >> 6) & 0x03E0;
+
+                pixels =  inputRGB[i+pitch_src];
+                temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                *(tempY + pitch_dst) = yuv_value;
+
+                G_ds    += (pixels >> 1) & 0x03E0;
+                B_ds    += (pixels << 5) & 0x03E0;
+                R_ds    += (pixels >> 6) & 0x03E0;
+
+                tempY++;
+
+                pixels =  inputRGB[i+1];
+                temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                *tempY = yuv_value;
+
+                G_ds    += (pixels >> 1) & 0x03E0;
+                B_ds    += (pixels << 5) & 0x03E0;
+                R_ds    += (pixels >> 6) & 0x03E0;
+
+                pixels =  inputRGB[i+1+pitch_src];
+                temp = (ALPHA * (pixels & 0x001F) + BETA * (pixels >> 11));
+                yuv_value = y_tab[(temp>>SHIFT_INDEX1) + ((pixels>>3) & 0x00FC)];
+                *(tempY + pitch_dst) = yuv_value;
+
+                G_ds    += (pixels >> 1) & 0x03E0;
+                B_ds    += (pixels << 5) & 0x03E0;
+                R_ds    += (pixels >> 6) & 0x03E0;
+
+                tempY++;
+
+                R_ds >>= 2;
+                B_ds >>= 2;
+                G_ds >>= 2;
+
+                tmp = B_ds - R_ds;
+
+                *tempU = cb_tab[(((B_ds-G_ds)<<16) + 19525*tmp)>>18];
+                *tempV = cr_tab[(((R_ds-G_ds)<<16) -  6640*tmp)>>18];
+
+                tempU++;
+                tempV++;
+            }
+
+            inputRGB += pitch_src << 1;
+            tempY += (pitch_dst - width_dst) + pitch_dst;
+            tempU += ((pitch_dst - width_dst)) >> 1;
+            tempV += ((pitch_dst - width_dst)) >> 1;
+        }
+
+        return 1;
+    }
+
+}
+
+// in this overload, yuv420 is the output, rgb16 is input
+int32 CCRGB16toYUV420::Convert(uint8 *rgb16, uint8 **yuv420)
+{
+    uint32 param[6];
+    uint8 *table[3];
+
+    OSCL_ASSERT(rgb16);
+    OSCL_ASSERT(yuv420);
+    OSCL_ASSERT(yuv420[0]);
+    OSCL_ASSERT(yuv420[1]);
+    OSCL_ASSERT(yuv420[2]);
+    OSCL_ASSERT(_mInitialized == true);
+
+    param[0] = (uint32) _mDst_width;
+    param[1] = (uint32) _mDst_height;
+    param[2] = (uint32) _mDst_pitch;
+    param[3] = (uint32) _mDst_mheight;
+    param[4] = (uint32) _mSrc_pitch;
+    param[5] = (uint32) mColorKey;
+
+    table[0] = iY_Table;
+    table[1] = ipCb_Table;
+    table[2] = ipCr_Table;
+
+    if (mUseColorKey == true)
+    {
+        return ccrgb16toyuv(rgb16, yuv420, param, table);
+    }
+    else
+    {
+        return ccrgb16toyuv_wo_colorkey(rgb16, yuv420, param, table);
+    }
+}
+
+
diff --git a/codecs_v2/utilities/colorconvert/src/ccrgb24torgb16.cpp b/codecs_v2/utilities/colorconvert/src/ccrgb24torgb16.cpp
new file mode 100644
index 0000000..86e7cca
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/ccrgb24torgb16.cpp
@@ -0,0 +1,1229 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/** Class CCRGB24toRGB16. convert RGB24 to RGB16 by truncating the least significant bits. */
+#include "colorconv_config.h"
+#include "ccrgb24torgb16.h"
+
+
+OSCL_EXPORT_REF ColorConvertBase* CCRGB24toRGB16::NewL(void)
+{
+    CCRGB24toRGB16* self = OSCL_NEW(CCRGB24toRGB16, ());
+    return OSCL_STATIC_CAST(ColorConvertBase*, self);
+}
+
+
+CCRGB24toRGB16::CCRGB24toRGB16()
+{
+}
+
+
+OSCL_EXPORT_REF CCRGB24toRGB16::~CCRGB24toRGB16()
+{
+}
+
+int32 CCRGB24toRGB16::Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation)
+{
+
+    if (ColorConvertBase::Init(Src_width, Src_height, Src_pitch, Dst_width, Dst_height, Dst_pitch, nRotation) == 0)
+    {
+        return 0;
+    }
+
+    //default no zoom
+    _mInitialized = true;
+
+    SetMode(0); // called after init
+
+    return 1;
+}
+
+
+int32 CCRGB24toRGB16::SetYuvFullRange(bool range)
+{
+    OSCL_UNUSED_ARG(range);
+    OSCL_ASSERT(_mInitialized == true);
+
+    return 1;  // do nothing here.
+}
+
+int32 CCRGB24toRGB16::SetMode(int32 nMode)	//nMode : 0 Off, 1 On
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    if (nMode == 0)
+    {
+        //		mPtrConv = cc16Rotate;
+        //		_mState		= 1;
+        mPtrConv	=	&CCRGB24toRGB16::getframe;
+        _mState		=	0;
+        _mDisp.src_pitch = _mSrc_pitch  ;
+        _mDisp.dst_pitch = _mSrc_width  ;
+        _mDisp.src_width = _mSrc_width	;
+        _mDisp.src_height = _mSrc_height ;
+        _mDisp.dst_width = _mSrc_width	;
+        _mDisp.dst_height = _mSrc_height ;
+    }
+    else
+    {
+#if CCSCALING
+        if (_mIsZoom)
+        {
+#if CCROTATE
+            if (_mRotation&0x1) /* zoom and rotate */
+            {
+                mPtrConv = &CCRGB24toRGB16::zoomRotate;
+            }
+            else /* zoom only */
+#endif
+            {
+                mPtrConv	=	&CCRGB24toRGB16::zoom;
+            }
+        }
+        else
+#endif
+        {
+#if CCROTATE
+            if (_mRotation&0x1) /* rotate only*/
+            {
+                mPtrConv = &CCRGB24toRGB16::rotate;
+            }
+            else /* no zoom, no rotate, SetMode(1) = SetMode(0) */
+#endif
+            {
+                mPtrConv	=	&CCRGB24toRGB16::getframe;
+            }
+        }
+        _mState		=	nMode;
+        _mDisp.src_pitch = _mSrc_pitch  ;
+        _mDisp.dst_pitch = _mDst_pitch	;
+        _mDisp.src_width = _mSrc_width	;
+        _mDisp.src_height = _mSrc_height ;
+        _mDisp.dst_width = _mDst_width	;
+        _mDisp.dst_height = _mDst_height ;
+    }
+
+    return 1;
+}
+
+
+int32 CCRGB24toRGB16::GetOutputBufferSize(void)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    if (_mIsZoom)
+    {
+        // for zoom, need extra line of RGB_FORMAT buffer for processing otherwise memory will corrupt.
+        return	_mState ? ((_mDst_height + 2)*_mDst_pitch*2) : (_mSrc_width*_mSrc_height*2);
+    }
+    else
+    {
+        return	_mState ? ((_mDst_height)*_mDst_pitch*2) : (_mSrc_width*_mSrc_height*2);
+    }
+}
+
+
+int32 CCRGB24toRGB16::Convert(uint8 **srcBuf, uint8 *destBuf)
+{
+    OSCL_ASSERT(_mInitialized == true);
+    OSCL_ASSERT(srcBuf);
+    OSCL_ASSERT(srcBuf[0]);
+    OSCL_ASSERT(srcBuf[1]);
+    OSCL_ASSERT(srcBuf[2]);
+    OSCL_ASSERT(destBuf);
+
+    if (((uint32)destBuf)&0x3 || ((uint32)srcBuf[0])&0x3) /* address is not word align */
+    {
+        return 0;
+    }
+
+    return (*this.*mPtrConv)(srcBuf[0], destBuf, &_mDisp);
+}
+
+
+int32 CCRGB24toRGB16::Convert(uint8 *srcBuf, uint8 *destBuf)
+{
+    OSCL_ASSERT(_mInitialized == true);
+    OSCL_ASSERT(srcBuf);
+    OSCL_ASSERT(destBuf);
+
+    if (((uint32)srcBuf)&0x3 || ((uint32)destBuf)&0x3) /* address is not word align */
+    {
+        return 0;
+    }
+
+    return (*this.*mPtrConv)(srcBuf, destBuf, &_mDisp);
+}
+
+int32 reverse(uint8 *src, uint8 *dst, int32 *disp);
+int32 normal(uint8 *src, uint8 *dst, int32 *disp);
+
+int32 CCRGB24toRGB16::getframe(uint8 *src, uint8 *dst, DisplayProperties *disp)
+{
+    int32 disp_prop[8];
+
+    disp_prop[0] = disp->src_pitch;
+    disp_prop[1] = disp->dst_pitch;
+    disp_prop[2] = disp->src_width;
+    disp_prop[3] = disp->src_height;
+    disp_prop[4] = disp->dst_width;
+    disp_prop[5] = disp->dst_height;
+    disp_prop[6] = (_mRotation > 0 ? 1 : 0);
+    disp_prop[7] = _mIsFlip;
+
+    if (disp_prop[6] ^ disp_prop[7])	/* either flip or rotate 180*/
+    {
+#if (!CCROTATE)
+        return 0;
+#else
+        return reverse(src, dst, disp_prop);
+#endif
+    }
+    else
+    {
+        return normal(src, dst, disp_prop);
+    }
+}
+
+int32 normal(uint8 *src, uint8 *dst, int32 *disp)
+{
+    uint8	*pSrc;
+    uint16	*pDst;
+    int32		src_pitch, dst_pitch, src_width, src_height;
+    int32		half1, half2;
+    int32		deltaSrc, deltaDst;
+    int32		row, col;
+    uint32		rgb, tmp0;
+
+    src_pitch	=	disp[0];
+    dst_pitch	=	disp[1];
+    src_width	=	disp[2];
+    src_height  =   disp[3];
+
+    if (disp[6]) /* rotate 180 and flip */
+    {	/* move the starting point to the bottom-left corner of the picture */
+        deltaSrc = src_pitch * (src_height - 1) * 3;
+        pSrc = (uint8*)(src + deltaSrc);
+        deltaSrc = -(src_width + src_pitch) * 3;
+    }
+    else
+    {
+        deltaSrc	=	(src_pitch - src_width) * 3;
+        pSrc =  src;
+    }
+
+    deltaDst	=	(dst_pitch - src_width);
+    pDst =	(uint16 *)dst;
+
+    for (row = src_height; row > 0; row--)
+    {
+
+        for (col = src_width - 1; col >= 0; col -= 2)
+        {
+
+
+            half1 = *((uint16*)(pSrc));  /* read 2 bytes, G0 R0 or G0 B0 */
+            half2 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 B0 or B1 R0 */
+
+#if RGB_FORMAT
+            rgb = half1 & 0xF8;  /* get 5 bits of R0 */
+            half1 = (half1 >> 5) & 0x7E0;  /* get 6 bits of G0 */
+            rgb = (rgb << 8) | half1;				/*  R0, G0 */
+            half1 = (half2 >> 3) & 0x1F;		/* get 5 bits of B0 */
+            rgb |= half1;			/*  R0,G0,B0 */
+
+            half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, B1 G1 */
+
+            half2 &= 0xF800;			/* get 5 bits of R1 */
+            tmp0 = half1 & 0xFC;			/* get 6 bits of G1 */
+            tmp0 = (tmp0 << 3) | half2;  /* R1 G1 */
+            tmp0 |= (half1 >> 11);		/* R1 G1 B1 */
+#else //BGR
+            rgb = half2 & 0xF8;  /* get 5 bits of R0 */
+            tmp0 = (half1 >> 5) & 0x7E0;  /* get 6 bits of G0 */
+            rgb = (rgb << 8) | tmp0;				/*  R0, G0 */
+            half1 = (half1 >> 3) & 0x1F;		/* get 5 bits of B0 */
+            rgb |= half1;			/*  R0,G0,B0 */
+
+            half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 G1 */
+
+            tmp0 = half1 & 0xF800;		/* get 5 bits of R1 */
+            half1 = (half1 << 3) & 0x7C0;  /* get G1 in the middle */
+            tmp0 |= half1;             /* R1 G1 */
+            tmp0 |= (half2 >> 11);     /* R1 G1 B1 */
+#endif
+            rgb = rgb | (tmp0 << 16);
+
+            *((uint32*)pDst) = rgb;
+            pDst += 2;
+            pSrc += 2;
+
+        }
+
+        pSrc += deltaSrc;
+        pDst += deltaDst;
+    }
+
+    return 1;
+}
+
+#if CCROTATE
+int32 reverse(uint8 *src, uint8 *dst, int32 *disp)
+{
+    uint8	*pSrc;
+    uint16	*pDst;
+    int32		src_pitch, dst_pitch, src_width, src_height;
+    int32		half1, half2;
+    int32		deltaSrc, deltaDst;
+    int32		row, col;
+    uint32		rgb, tmp0;
+    int	nextrow, mIsFlip;
+
+    src_pitch	=	disp[0];
+    dst_pitch	=	disp[1];
+    src_width	=	disp[2];
+    src_height  =   disp[3];
+    mIsFlip		=   disp[7];
+
+    deltaDst	=	(dst_pitch - src_width);
+    pDst =	(uint16 *)dst;
+
+    if (disp[6]) /* rotation, only */
+    {  /* move the starting point to the bottom-right corner of the picture */
+        nextrow = src_pitch * src_height * 3;
+        pSrc = (src + nextrow - 6);
+        deltaSrc	=	(src_width - src_pitch) * 3;
+    }
+    else	/* flip only */
+    {   /* move the starting point to the top-right corner of the picture */
+        pSrc = (src + src_width * 3 - 6);
+        deltaSrc = (src_width + src_pitch) * 3;
+    }
+
+    for (row = src_height; row > 0; row--)
+    {
+
+        for (col = src_width - 1; col >= 0; col -= 2)
+        {
+
+
+            half1 = *((uint16*)(pSrc));  /* read 2 bytes, G0 R0 or G0 B0 */
+            half2 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 B0 or B1 R0 */
+
+#if RGB_FORMAT
+            rgb = half1 & 0xF8;  /* get 5 bits of R0 */
+            half1 = (half1 >> 5) & 0x7E0;  /* get 6 bits of G0 */
+            rgb = (rgb << 8) | half1;				/*  R0, G0 */
+            half1 = (half2 >> 3) & 0x1F;		/* get 5 bits of B0 */
+            rgb |= half1;			/*  R0,G0,B0 */
+
+            half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, B1 G1 */
+
+            half2 &= 0xF800;			/* get 5 bits of R1 */
+            tmp0 = half1 & 0xFC;			/* get 6 bits of G1 */
+            tmp0 = (tmp0 << 3) | half2;  /* R1 G1 */
+            tmp0 |= (half1 >> 11);		/* R1 G1 B1 */
+#else //BGR
+            rgb = half2 & 0xF8;  /* get 5 bits of R0 */
+            tmp0 = (half1 >> 5) & 0x7E0;  /* get 6 bits of G0 */
+            rgb = (rgb << 8) | tmp0;				/*  R0, G0 */
+            half1 = (half1 >> 3) & 0x1F;		/* get 5 bits of B0 */
+            rgb |= half1;			/*  R0,G0,B0 */
+
+            half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 G1 */
+
+            tmp0 = half1 & 0xF800;		/* get 5 bits of R1 */
+            half1 = (half1 << 3) & 0x7C0;  /* get G1 in the middle */
+            tmp0 |= half1;             /* R1 G1 */
+            tmp0 |= (half2 >> 11);     /* R1 G1 B1 */
+#endif
+            rgb = tmp0 | (rgb << 16);
+
+            *((uint32*)pDst) = rgb;
+            pDst += 2;
+            pSrc -= 10;
+
+        }
+
+        pSrc += deltaSrc;
+        pDst += deltaDst;
+    }
+
+    return 1;
+}
+
+
+int32 CCRGB24toRGB16::rotate(uint8 *src, uint8 *dst, DisplayProperties *disp)
+{
+    OSCL_UNUSED_ARG(src);
+    OSCL_UNUSED_ARG(dst);
+    OSCL_UNUSED_ARG(disp);
+// To be implemented
+    return 1;
+}
+
+#endif // CCROTATE
+
+int32 scaledown(uint8*src, uint8 *dst, int32 *disp_prop, uint8 *_mRowPix, uint8 *_mColPix);
+int32 scaleup(uint8*src, uint8 *dst, int32 *disp_prop, uint8 *_mRowPix, uint8 *_mColPix);
+
+int32 CCRGB24toRGB16::zoom(uint8 *src, uint8 *dst, DisplayProperties *disp)
+{
+#if (!CCSCALING)
+    OSCL_UNUSED_ARG(src);
+    OSCL_UNUSED_ARG(dst);
+    OSCL_UNUSED_ARG(disp);
+    return 0;
+#else
+    int32 disp_prop[8];
+    int32 src_width, src_height, dst_width, dst_height;
+
+    disp_prop[0] = disp->src_pitch;
+    disp_prop[1] = disp->dst_pitch;
+    disp_prop[2] = src_width = disp->src_width;
+    disp_prop[3] = src_height = disp->src_height;
+    disp_prop[4] = dst_width = disp->dst_width;
+    disp_prop[5] = dst_height = disp->dst_height;
+    disp_prop[6] = (_mRotation > 0 ? 1 : 0);
+    disp_prop[7] = _mIsFlip;
+
+    if (src_width > dst_width) /* scale down in width */
+    {
+        return scaledown(src, dst, disp_prop, _mRowPix, _mColPix);
+    }
+    else
+    {
+        return scaleup(src, dst, disp_prop, _mRowPix, _mColPix);
+    }
+
+    return 1;
+#endif // CCSCALING
+}
+
+#if CCSCALING
+int32 scaledown(uint8*src, uint8 *dst, int32 *disp, uint8 *_mRowPix, uint8 *_mColPix)
+{
+    uint8	*pSrc;
+    uint16	*pDst;
+    int32	src_pitch, dst_pitch, src_width, src_height, dst_width;
+    int32	half1, half2;
+    int32	deltaSrc;
+    int32	row, col;
+    uint32	rgb, R0, G0, B0, R1, G1, B1, R2, G2, B2;
+    int		temp, denom, row_interp;
+    int		 mIsFlip;
+    uint8 *rowpix, *colpix;
+
+    src_pitch	=	disp[0];
+    dst_pitch	=	disp[1];
+    src_width	=	disp[2];
+    src_height  =   disp[3];
+    dst_width   =   disp[4];
+    mIsFlip		=   disp[7];
+
+    if ((disp[6] ^ mIsFlip) == 1) /* rotate 180 and  no flip || rotate 0 and  with flip */
+    {
+        if (disp[6] == 1) /*rotate 180 and  no flip */
+        {
+            temp = src_pitch * src_height * 3;
+            pSrc = (src + temp - 6);
+            deltaSrc = (src_width - src_pitch) * 3;
+        }
+        else /* rotate 0 and  with flip */
+        {
+            pSrc = (src + src_width * 3 - 6);
+            deltaSrc = (src_width + src_pitch) * 3;
+        }
+        pDst =	(uint16 *)dst;
+        colpix = _mColPix + src_height - 1;
+        row_interp = 0;
+
+        for (row = src_height; row > 0; row--)
+        {/* decrement index, _mColPix[.] is
+			symmetric to increment index */
+
+            /*	if(*colpix--==0)
+            	{
+            		pSrc+=src_width*3;
+            		pSrc+=deltaSrc;
+            		continue;
+            	}*/
+
+            rowpix = _mRowPix + src_width - 1;
+            denom = 1;
+            R2 = G2 = B2 = 0;
+
+            for (col = src_width; col > 0; col -= 2)
+            { /* decrement index, _mRowPix[.] is
+				symmetric to increment index */
+
+                half1 = *((uint16*)(pSrc));  /* read 2 bytes, G0 R0 or G0 B0 */
+                half2 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 B0 or B1 R0 */
+
+#if RGB_FORMAT
+                R1 = (half1 >> 3) & 0x1F;
+                G1 = (half1 >> 10);
+                B1 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, B1 G1 */
+                R0 = half2 >> 11;
+                G0 = (half1 >> 2) & 0x3F;
+                B0 = half1 >> 11;
+#else
+                B1 = (half1 >> 3) & 0x1F;
+                G1 = (half1 >> 10);
+                R1 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 G1 */
+                B0 = half2 >> 11;
+                G0 = (half1 >> 2) & 0x3F;
+                R0 = half1 >> 11;
+#endif
+                pSrc -= 10;
+
+                temp = *rowpix--;
+
+                R2 += R0;
+                G2 += G0;
+                B2 += B0;
+                if (temp)
+                {
+                    R2 = (R2 + (denom / 2)) / denom;
+                    G2 = (G2 + (denom / 2)) / denom;
+                    B2 = (B2 + (denom / 2)) / denom;
+                    // re-use R0,G0,B0,half1, do row interpolation
+                    if (row_interp)
+                    {
+                        half1 = *pDst;
+                        R0 = half1 >> 11;
+                        G0 = (half1 >> 5) & 0x3F;
+                        B0 = half1 & 0x1F;
+                        R2 = (R2 + R0 + 1) >> 1;
+                        G2 = (G2 + G0 + 1) >> 1;
+                        B2 = (B2 + B0 + 1) >> 1;
+                    }
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    R2 = G2 = B2 = 0;
+                    denom = 1;
+                    *pDst++ = rgb;
+                }
+                else
+                {
+                    denom++;
+                }
+
+                temp = *rowpix--;
+                R2 += R1;
+                G2 += G1;
+                B2 += B1;
+                if (temp)
+                {
+                    R2 = (R2 + (denom / 2)) / denom;
+                    G2 = (G2 + (denom / 2)) / denom;
+                    B2 = (B2 + (denom / 2)) / denom;
+                    // re-use R0,G0,B0,half1, do row interpolation
+                    if (row_interp)
+                    {
+                        half1 = *pDst;
+                        R0 = half1 >> 11;
+                        G0 = (half1 >> 5) & 0x3F;
+                        B0 = half1 & 0x1F;
+                        R2 = (R2 + R0 + 1) >> 1;
+                        G2 = (G2 + G0 + 1) >> 1;
+                        B2 = (B2 + B0 + 1) >> 1;
+                    }
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    R2 = G2 = B2 = 0;
+                    denom = 1;
+                    *pDst++ = rgb;
+                }
+                else
+                {
+                    denom++;
+                }
+            }
+            if (*colpix-- == 1)
+            {
+                pDst += (dst_pitch - dst_width);
+                row_interp = 0;
+            }
+            else
+            {
+                pDst -= dst_width;
+                row_interp = 1;
+            }
+            pSrc += deltaSrc;
+        }
+    }
+    else
+    {
+        if (disp[6] == 1) /* rotate 180 and  with flip */
+        {
+            /* move the starting point to the bottom-left corner of the picture */
+            deltaSrc = src_pitch * (src_height - 1);
+            pSrc = src + deltaSrc * 3;
+            deltaSrc = -(src_pitch + src_width) * 3;
+        }
+        else
+        {	// only scale down, no rotation ,no flip
+            deltaSrc	=	(src_pitch - src_width) * 3;
+            pSrc = src;
+        }
+
+        pDst =	(uint16 *)dst;
+        colpix = _mColPix + src_height - 1;
+        row_interp = 0;
+
+        for (row = src_height; row > 0; row--)
+        {/* decrement index, _mColPix[.] is
+			symmetric to increment index */
+
+            /*	if(*colpix--==0)
+            	{
+            		pSrc+=src_width*3;
+            		pSrc+=deltaSrc;
+            		continue;
+            	}*/
+
+            rowpix = _mRowPix + src_width - 1;
+            denom = 1;
+            R2 = G2 = B2 = 0;
+
+            for (col = src_width; col > 0; col -= 2)
+            { /* decrement index, _mRowPix[.] is
+				symmetric to increment index */
+
+                half1 = *((uint16*)(pSrc));  /* read 2 bytes, G0 R0 or G0 B0 */
+                half2 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 B0 or B1 R0 */
+
+#if RGB_FORMAT
+                R0 = (half1 >> 3) & 0x1F;
+                G0 = (half1 >> 10);
+                B0 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, B1 G1 */
+                R1 = half2 >> 11;
+                G1 = (half1 >> 2) & 0x3F;
+                B1 = half1 >> 11;
+#else
+                B0 = (half1 >> 3) & 0x1F;
+                G0 = (half1 >> 10);
+                R0 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 G1 */
+                B1 = half2 >> 11;
+                G1 = (half1 >> 2) & 0x3F;
+                R1 = half1 >> 11;
+#endif
+                pSrc += 2;
+
+                temp = *rowpix--;
+
+                R2 += R0;
+                G2 += G0;
+                B2 += B0;
+                if (temp)
+                {
+                    R2 = (R2 + (denom / 2)) / denom;
+                    G2 = (G2 + (denom / 2)) / denom;
+                    B2 = (B2 + (denom / 2)) / denom;
+                    // re-use R0,G0,B0,half1, do row interpolation
+                    if (row_interp)
+                    {
+                        half1 = *pDst;
+                        R0 = half1 >> 11;
+                        G0 = (half1 >> 5) & 0x3F;
+                        B0 = half1 & 0x1F;
+                        R2 = (R2 + R0 + 1) >> 1;
+                        G2 = (G2 + G0 + 1) >> 1;
+                        B2 = (B2 + B0 + 1) >> 1;
+                    }
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    R2 = G2 = B2 = 0;
+                    denom = 1;
+                    *pDst++ = rgb;
+                }
+                else
+                {
+                    denom++;
+                }
+
+                temp = *rowpix--;
+                R2 += R1;
+                G2 += G1;
+                B2 += B1;
+                if (temp)
+                {
+                    R2 = (R2 + (denom / 2)) / denom;
+                    G2 = (G2 + (denom / 2)) / denom;
+                    B2 = (B2 + (denom / 2)) / denom;
+                    // re-use R0,G0,B0,half1, do row interpolation
+                    if (row_interp)
+                    {
+                        half1 = *pDst;
+                        R0 = half1 >> 11;
+                        G0 = (half1 >> 5) & 0x3F;
+                        B0 = half1 & 0x1F;
+                        R2 = (R2 + R0 + 1) >> 1;
+                        G2 = (G2 + G0 + 1) >> 1;
+                        B2 = (B2 + B0 + 1) >> 1;
+                    }
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    R2 = G2 = B2 = 0;
+                    denom = 1;
+                    *pDst++ = rgb;
+                }
+                else
+                {
+                    denom++;
+                }
+            }
+            if (*colpix-- == 1)
+            {
+                pDst += (dst_pitch - dst_width);
+                row_interp = 0;
+            }
+            else
+            {
+                pDst -= dst_width;
+                row_interp = 1;
+            }
+            pSrc += deltaSrc;
+        }
+    }
+
+    return 1;
+}
+
+int32 scaleup(uint8*src, uint8 *dst, int32 *disp, uint8 *_mRowPix, uint8 *_mColPix)
+{
+    uint8	*pSrc = NULL;
+    uint16	*pDst = NULL, *pTop = NULL, *pLine = NULL;
+    int32	src_pitch, dst_pitch, src_width, src_height, dst_width;
+    int32	half1, half2;
+    int32	deltaSrc;
+    int32	row, col;
+    uint32	rgb, tmp, R0, G0, B0, R1, G1, B1, R2, G2, B2;
+    int		temp;
+    int	nextrow, mIsFlip;
+    uint8 *rowpix, *colpix;
+
+    src_pitch	=	disp[0];
+    dst_pitch	=	disp[1];
+    src_width	=	disp[2];
+    src_height  =   disp[3];
+    dst_width   =   disp[4];
+    mIsFlip		=   disp[7];
+
+    if (((disp[6] == 0) && (mIsFlip == 1)) || ((disp[6] == 1) && (mIsFlip == 0))) /* rotate 180 and  no flip || rotate 0 and  with flip */
+    {
+        if (disp[6] == 1) /*rotate 0 and  with flip */
+        {
+            nextrow = src_pitch * src_height * 3;
+            pSrc = (src + nextrow - 6);
+            deltaSrc = (src_width - src_pitch) * 3;
+        }
+        else /* rotate 180 and  no flip */
+        {
+            pSrc = (src + src_width * 3 - 6);
+            deltaSrc = (src_width + src_pitch) * 3;
+        }
+
+        pDst =	(uint16 *)dst;
+        colpix = _mColPix + disp[3] - 1;
+
+        for (row = src_height; row > 0; row--)
+        {/* decrement index, _mColPix[.] is
+			symmetric to increment index */
+            rowpix = _mRowPix + src_width - 1;
+
+            for (col = src_width; col > 0; col -= 2)
+            { /* decrement index, _mRowPix[.] is
+				symmetric to increment index */
+
+                half1 = *((uint16*)(pSrc));  /* read 2 bytes, G0 R0 or G0 B0 */
+                half2 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 B0 or B1 R0 */
+
+#if RGB_FORMAT
+                R1 = (half1 >> 3) & 0x1F;
+                G1 = (half1 >> 10);
+                B1 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, B1 G1 */
+                R0 = half2 >> 11;
+                G0 = (half1 >> 2) & 0x3F;
+                B0 = half1 >> 11;
+#else
+                B1 = (half1 >> 3) & 0x1F;
+                G1 = (half1 >> 10);
+                R1 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 G1 */
+                B0 = half2 >> 11;
+                G0 = (half1 >> 2) & 0x3F;
+                R0 = half1 >> 11;
+#endif
+                pSrc -= 10;
+
+                temp = rowpix[0] + rowpix[-1];
+                rowpix -= 2;
+                rgb = (R0 << 6) | G0;
+                rgb = (rgb << 5) | B0;
+                tmp = (R1 << 6) | G1;
+                tmp = (tmp << 5) | B1;
+
+                *pDst++ = rgb;
+                if (temp == 3)
+                {
+                    R0 = (R0 + R1 + 1) >> 1;
+                    G0 = (G0 + G1 + 1) >> 1;
+                    B0 = (B0 + B1 + 1) >> 1;
+                    rgb = (R0 << 6) | G0;
+                    rgb = (rgb << 5) | B0;
+                    *pDst++ = rgb;
+                }
+                else if (temp == 4)
+                {
+                    R2 = (2 * R0 + R1 + 1) / 3;
+                    R1 = (2 * R1 + R0 + 1) / 3;
+                    G2 = (2 * G0 + G1 + 1) / 3;
+                    G1 = (2 * G1 + G0 + 1) / 3;
+                    rgb = (R2 << 6) | G2;
+                    B2 = (2 * B0 + B1 + 1) / 3;
+                    B1 = (2 * B1 + B0 + 1) / 3;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    rgb = (R1 << 6) | G1;
+                    rgb = (rgb << 5) | B1;
+                    *pDst++ = rgb;
+                }
+                else if (temp == 5)
+                {
+                    R2 = (3 * R0 + R1 + 2) / 4;
+                    G2 = (3 * G0 + G1 + 2) / 4;
+                    B2 = (3 * B0 + B1 + 2) / 4;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (R0 + R1 + 1) / 2;
+                    G2 = (G0 + G1 + 1) / 2;
+                    B2 = (B0 + B1 + 1) / 2;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (R0 + 3 * R1 + 2) / 4;
+                    G2 = (G0 + 3 * G1 + 2) / 4;
+                    B2 = (B0 + 3 * B1 + 2) / 4;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                }
+                else if (temp == 6)
+                {
+                    R2 = (4 * R0 + R1 + 2) / 5;
+                    G2 = (4 * G0 + G1 + 2) / 5;
+                    B2 = (4 * B0 + B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (3 * R0 + 2 * R1 + 2) / 5;
+                    G2 = (3 * G0 + 2 * G1 + 2) / 5;
+                    B2 = (3 * B0 + 2 * B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (2 * R0 + 3 * R1 + 2) / 5;
+                    G2 = (2 * G0 + 3 * G1 + 2) / 5;
+                    B2 = (2 * B0 + 3 * B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (R0 + 4 * R1 + 2) / 5;
+                    G2 = (G0 + 4 * G1 + 2) / 5;
+                    B2 = (B0 + 4 * B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                }
+
+                *pDst++ = tmp;
+            }
+
+            if (!(row&1)) /* even row */
+            {
+                // have to leave some space for row interpolation
+                pDst -= dst_width;
+                pTop = pDst;
+                pDst += dst_pitch * (colpix[0] + colpix[-1] - 1);
+                colpix--;
+            }
+            else /* odd row */ // do the row interpolation
+            {
+                temp = colpix[0] + colpix[1];
+                pDst -= dst_width; // back to the beginning of bottom line
+
+                if (temp != 2) // need to interpolate
+                {
+                    pLine = pDst - dst_pitch;
+                    for (col = dst_width; col > 0; col--)
+                    {
+                        rgb = *pTop++;
+                        tmp = *pDst++;
+                        // now averager rgb and tmp
+                        R0 = rgb >> 11;
+                        R1 = tmp >> 11;
+                        G0 = (rgb >> 5) & 0x3F;
+                        G1 = (tmp >> 5) & 0x3F;
+                        B0 = rgb & 0x1F;
+                        B1 = tmp & 0x1F;
+                        if (temp == 3)
+                        {
+                            R2 = (R0 + R1 + 1) >> 1;
+                            G2 = (G0 + G1 + 1) >> 1;
+                            B2 = (B0 + B1 + 1) >> 1;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            *pLine++ = rgb;
+                        }
+                        else if (temp == 4)
+                        {
+                            R2 = (2 * R0 + R1 + 1) / 3;
+                            R1 = (2 * R1 + R0 + 1) / 3;
+                            G2 = (2 * G0 + G1 + 1) / 3;
+                            G1 = (2 * G1 + G0 + 1) / 3;
+                            rgb = (R2 << 6) | G2;
+                            B2 = (2 * B0 + B1 + 1) / 3;
+                            B1 = (2 * B1 + B0 + 1) / 3;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch] = rgb; // line above
+                            rgb = (R1 << 6) | G1;
+                            rgb = (rgb << 5) | B1;
+                            *pLine++ = rgb;
+                        }
+                        else if (temp == 5)
+                        {
+                            R2 = (3 * R0 + R1 + 2) / 4;
+                            G2 = (3 * G0 + G1 + 2) / 4;
+                            B2 = (3 * B0 + B1 + 2) / 4;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-(dst_pitch<<1)] = rgb;
+                            R2 = (R0 + R1 + 1) / 2;
+                            G2 = (G0 + G1 + 1) / 2;
+                            B2 = (B0 + B1 + 1) / 2;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch] = rgb;
+                            R2 = (R0 + 3 * R1 + 2) / 4;
+                            G2 = (G0 + 3 * G1 + 2) / 4;
+                            B2 = (B0 + 3 * B1 + 2) / 4;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            *pLine++ = rgb;
+                        }
+                        else if (temp == 6)
+                        {
+                            R2 = (4 * R0 + R1 + 2) / 5;
+                            G2 = (4 * G0 + G1 + 2) / 5;
+                            B2 = (4 * B0 + B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch*3] = rgb;
+                            R2 = (3 * R0 + 2 * R1 + 2) / 5;
+                            G2 = (3 * G0 + 2 * G1 + 2) / 5;
+                            B2 = (3 * B0 + 2 * B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-(dst_pitch<<1)] = rgb;
+                            R2 = (2 * R0 + 3 * R1 + 2) / 5;
+                            G2 = (2 * G0 + 3 * G1 + 2) / 5;
+                            B2 = (2 * B0 + 3 * B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch] = rgb;
+                            R2 = (R0 + 4 * R1 + 2) / 5;
+                            G2 = (G0 + 4 * G1 + 2) / 5;
+                            B2 = (B0 + 4 * B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            *pLine++ = rgb;
+                        }
+                    }
+                    pDst -= dst_width;
+                }
+                pDst += dst_pitch;
+                colpix--;
+            }
+
+            pSrc += deltaSrc;
+        }
+    }
+    else  /* rotate 180 and  with flip || no rotation ,no flip */
+    {
+        if (disp[6] == 1) /* rotate 180 and  with flip */
+        {
+            /* move the starting point to the bottom-left corner of the picture */
+            deltaSrc = src_pitch * (src_height - 1);
+            pSrc = src + deltaSrc * 3;
+            deltaSrc = -(src_pitch + src_width) * 3;
+        }
+        else
+        {	// only scale up, no rotation ,no flip
+            deltaSrc	=	(src_pitch - src_width) * 3;
+            pSrc = src;
+        }
+
+        pDst =	(uint16 *)dst;
+        colpix = _mColPix + src_height - 1;
+
+        for (row = src_height; row > 0; row--)
+        {/* decrement index, _mColPix[.] is
+			symmetric to increment index */
+            rowpix = _mRowPix + src_width - 1;
+
+            for (col = src_width; col > 0; col -= 2)
+            { /* decrement index, _mRowPix[.] is
+				symmetric to increment index */
+
+                half1 = *((uint16*)(pSrc));  /* read 2 bytes, G0 R0 or G0 B0 */
+                half2 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 B0 or B1 R0 */
+
+#if RGB_FORMAT
+                R0 = (half1 >> 3) & 0x1F;
+                G0 = (half1 >> 10);
+                B0 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, B1 G1 */
+                R1 = half2 >> 11;
+                G1 = (half1 >> 2) & 0x3F;
+                B1 = half1 >> 11;
+#else
+                B0 = (half1 >> 3) & 0x1F;
+                G0 = (half1 >> 10);
+                R0 = (half2 >> 3) & 0x1F;
+                half1 = *((uint16*)(pSrc += 2)); /* read 2 bytes, R1 G1 */
+                B1 = half2 >> 11;
+                G1 = (half1 >> 2) & 0x3F;
+                R1 = half1 >> 11;
+#endif
+                pSrc += 2;
+
+                temp = rowpix[0] + rowpix[-1];
+                rowpix -= 2;
+                rgb = (R0 << 6) | G0;
+                rgb = (rgb << 5) | B0;
+                tmp = (R1 << 6) | G1;
+                tmp = (tmp << 5) | B1;
+
+                *pDst++ = rgb;
+                if (temp == 3)
+                {
+                    R0 = (R0 + R1 + 1) >> 1;
+                    G0 = (G0 + G1 + 1) >> 1;
+                    B0 = (B0 + B1 + 1) >> 1;
+                    rgb = (R0 << 6) | G0;
+                    rgb = (rgb << 5) | B0;
+                    *pDst++ = rgb;
+                }
+                else if (temp == 4)
+                {
+                    R2 = (2 * R0 + R1 + 1) / 3;
+                    R1 = (2 * R1 + R0 + 1) / 3;
+                    G2 = (2 * G0 + G1 + 1) / 3;
+                    G1 = (2 * G1 + G0 + 1) / 3;
+                    rgb = (R2 << 6) | G2;
+                    B2 = (2 * B0 + B1 + 1) / 3;
+                    B1 = (2 * B1 + B0 + 1) / 3;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    rgb = (R1 << 6) | G1;
+                    rgb = (rgb << 5) | B1;
+                    *pDst++ = rgb;
+                }
+                else if (temp == 5)
+                {
+                    R2 = (3 * R0 + R1 + 2) / 4;
+                    G2 = (3 * G0 + G1 + 2) / 4;
+                    B2 = (3 * B0 + B1 + 2) / 4;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (R0 + R1 + 1) / 2;
+                    G2 = (G0 + G1 + 1) / 2;
+                    B2 = (B0 + B1 + 1) / 2;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (R0 + 3 * R1 + 2) / 4;
+                    G2 = (G0 + 3 * G1 + 2) / 4;
+                    B2 = (B0 + 3 * B1 + 2) / 4;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                }
+                else if (temp == 6)
+                {
+                    R2 = (4 * R0 + R1 + 2) / 5;
+                    G2 = (4 * G0 + G1 + 2) / 5;
+                    B2 = (4 * B0 + B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (3 * R0 + 2 * R1 + 2) / 5;
+                    G2 = (3 * G0 + 2 * G1 + 2) / 5;
+                    B2 = (3 * B0 + 2 * B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (2 * R0 + 3 * R1 + 2) / 5;
+                    G2 = (2 * G0 + 3 * G1 + 2) / 5;
+                    B2 = (2 * B0 + 3 * B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                    R2 = (R0 + 4 * R1 + 2) / 5;
+                    G2 = (G0 + 4 * G1 + 2) / 5;
+                    B2 = (B0 + 4 * B1 + 2) / 5;
+                    rgb = (R2 << 6) | G2;
+                    rgb = (rgb << 5) | B2;
+                    *pDst++ = rgb;
+                }
+
+                *pDst++ = tmp;
+            }
+
+            if (!(row&1)) /* even row */
+            {
+                // have to leave some space for row interpolation
+                pDst -= dst_width;
+                pTop = pDst;
+                pDst += dst_pitch * (colpix[0] + colpix[-1] - 1);
+                colpix--;
+            }
+            else /* odd row */ // do the row interpolation
+            {
+                temp = colpix[0] + colpix[1];
+                pDst -= dst_width; // back to the beginning of bottom line
+
+                if (temp != 2) // need to interpolate
+                {
+                    pLine = pDst - dst_pitch;
+                    for (col = dst_width; col > 0; col--)
+                    {
+                        rgb = *pTop++;
+                        tmp = *pDst++;
+                        // now averager rgb and tmp
+                        R0 = rgb >> 11;
+                        R1 = tmp >> 11;
+                        G0 = (rgb >> 5) & 0x3F;
+                        G1 = (tmp >> 5) & 0x3F;
+                        B0 = rgb & 0x1F;
+                        B1 = tmp & 0x1F;
+                        if (temp == 3)
+                        {
+                            R2 = (R0 + R1 + 1) >> 1;
+                            G2 = (G0 + G1 + 1) >> 1;
+                            B2 = (B0 + B1 + 1) >> 1;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            *pLine++ = rgb;
+                        }
+                        else if (temp == 4)
+                        {
+                            R2 = (2 * R0 + R1 + 1) / 3;
+                            R1 = (2 * R1 + R0 + 1) / 3;
+                            G2 = (2 * G0 + G1 + 1) / 3;
+                            G1 = (2 * G1 + G0 + 1) / 3;
+                            rgb = (R2 << 6) | G2;
+                            B2 = (2 * B0 + B1 + 1) / 3;
+                            B1 = (2 * B1 + B0 + 1) / 3;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch] = rgb; // line above
+                            rgb = (R1 << 6) | G1;
+                            rgb = (rgb << 5) | B1;
+                            *pLine++ = rgb;
+                        }
+                        else if (temp == 5)
+                        {
+                            R2 = (3 * R0 + R1 + 2) / 4;
+                            G2 = (3 * G0 + G1 + 2) / 4;
+                            B2 = (3 * B0 + B1 + 2) / 4;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-(dst_pitch<<1)] = rgb;
+                            R2 = (R0 + R1 + 1) / 2;
+                            G2 = (G0 + G1 + 1) / 2;
+                            B2 = (B0 + B1 + 1) / 2;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch] = rgb;
+                            R2 = (R0 + 3 * R1 + 2) / 4;
+                            G2 = (G0 + 3 * G1 + 2) / 4;
+                            B2 = (B0 + 3 * B1 + 2) / 4;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            *pLine++ = rgb;
+                        }
+                        else if (temp == 6)
+                        {
+                            R2 = (4 * R0 + R1 + 2) / 5;
+                            G2 = (4 * G0 + G1 + 2) / 5;
+                            B2 = (4 * B0 + B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch*3] = rgb;
+                            R2 = (3 * R0 + 2 * R1 + 2) / 5;
+                            G2 = (3 * G0 + 2 * G1 + 2) / 5;
+                            B2 = (3 * B0 + 2 * B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-(dst_pitch<<1)] = rgb;
+                            R2 = (2 * R0 + 3 * R1 + 2) / 5;
+                            G2 = (2 * G0 + 3 * G1 + 2) / 5;
+                            B2 = (2 * B0 + 3 * B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            pLine[-dst_pitch] = rgb;
+                            R2 = (R0 + 4 * R1 + 2) / 5;
+                            G2 = (G0 + 4 * G1 + 2) / 5;
+                            B2 = (B0 + 4 * B1 + 2) / 5;
+                            rgb = (R2 << 6) | G2;
+                            rgb = (rgb << 5) | B2;
+                            *pLine++ = rgb;
+                        }
+                    }
+                    pDst -= dst_width;
+                }
+                pDst += dst_pitch;
+                colpix--;
+            }
+
+            pSrc += deltaSrc;
+        }
+    }
+    return 1;
+}
+#endif //CCSCALING
+
+int32 CCRGB24toRGB16::zoomRotate(uint8 *src, uint8 *dst, DisplayProperties *disp)
+{
+    // To be implemented
+    OSCL_UNUSED_ARG(src);
+    OSCL_UNUSED_ARG(dst);
+    OSCL_UNUSED_ARG(disp);
+    return 1;
+}
+
+
+
diff --git a/codecs_v2/utilities/colorconvert/src/ccrgb24toyuv420.cpp b/codecs_v2/utilities/colorconvert/src/ccrgb24toyuv420.cpp
new file mode 100644
index 0000000..7ffad16
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/ccrgb24toyuv420.cpp
@@ -0,0 +1,376 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/** class CCRGB24toYUV420.cpp
+*/
+#include "ccrgb24toyuv420.h"
+
+OSCL_EXPORT_REF ColorConvertBase* CCRGB24toYUV420 :: New()
+{
+    CCRGB24toYUV420* self = OSCL_NEW(CCRGB24toYUV420, ());
+    return OSCL_STATIC_CAST(ColorConvertBase*, self);
+}
+
+
+CCRGB24toYUV420::CCRGB24toYUV420()
+{
+}
+
+
+OSCL_EXPORT_REF CCRGB24toYUV420 :: ~CCRGB24toYUV420()
+{
+// add destructor code here
+    if (_mInitialized == true)
+    {
+        freeRGB2YUVTables();
+    }
+}
+
+
+void CCRGB24toYUV420::freeRGB2YUVTables()
+{
+    if (iY_Table) oscl_free(iY_Table);
+    if (iCb_Table) oscl_free(iCb_Table);
+    if (iCr_Table) oscl_free(iCr_Table);
+
+    iY_Table  = NULL;
+    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
+
+}
+
+
+int32 CCRGB24toYUV420:: Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width,
+                             int32 Dst_height, int32 Dst_pitch, int32 nRotation)
+{
+    int i;
+    uint8 *pTable;
+
+    if ((Src_width != Dst_width) || (Src_height != Dst_height) || (nRotation != 0 && nRotation != CCBOTTOM_UP))
+    {
+        return 0;
+    }
+
+    iBottomUp = false;
+    if (nRotation == CCBOTTOM_UP)
+    {
+        iBottomUp = true;
+    }
+
+
+    if (_mInitialized == true)
+    {
+        freeRGB2YUVTables();
+        _mInitialized = false;
+    }
+
+    /* memory allocation */
+    if ((iY_Table = (uint8*)oscl_malloc(384)) == NULL)
+        return 0;
+
+    if ((iCb_Table = (uint8*)oscl_malloc(768 * 2)) == NULL)
+        return 0;
+
+    if ((iCr_Table = (uint8*)oscl_malloc(768 * 2)) == NULL)
+        return 0;
+
+#define pv_max(a, b)	((a) >= (b) ? (a) : (b))
+#define pv_min(a, b)	((a) <= (b) ? (a) : (b))
+
+    /* Table generation */
+    for (i = 0; i < 384; i++)
+        iY_Table[i] = (uint8) pv_max(pv_min(255, (int32)(0.7152 * i + 16 + 0.5)), 0);
+
+    pTable = iCb_Table + 384;
+    for (i = -384; i < 384; i++)
+        pTable[i] = (uint8) pv_max(pv_min(255, (int32)(0.386 * i + 128 + 0.5)), 0);
+    ipCb_Table = iCb_Table + 384;
+
+    pTable = iCr_Table + 384;
+    for (i = -384; i < 384; i++)
+        pTable[i] = (uint8) pv_max(pv_min(255, (int32)(0.454 * i + 128 + 0.5)), 0);
+    ipCr_Table = iCr_Table + 384;
+
+
+    _mSrc_width  = Src_width;
+    _mSrc_height = Src_height;
+    _mSrc_pitch = Src_pitch;
+    _mDst_width = Dst_width;
+    _mDst_height = Dst_height;
+    _mDst_mheight = Dst_height;
+    _mDst_pitch = Dst_pitch;
+    _mInitialized = true;
+
+    SetMode(0);
+
+    return 1;
+}
+
+
+int32 CCRGB24toYUV420::GetOutputBufferSize(void)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    // only return value for _mState = 0 case
+    return ((((_mSrc_width + 15) >> 4) << 4) * (((_mSrc_height + 15) >> 4) << 4) * 3 / 2);
+}
+
+
+int32 CCRGB24toYUV420::SetMode(int32 nMode)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    if (nMode == 1) // do not allow scaling nor rotation
+    {
+        _mState = 1;
+        return 0;
+    }
+    else
+    {
+        _mState = 0;
+        return 1;
+    }
+}
+
+int32 CCRGB24toYUV420::SetYuvFullRange(bool range)
+{
+    OSCL_ASSERT(_mInitialized == true);
+    if (range == true)
+    {
+        return 0; // not supported yet
+    }
+    else
+    {
+        return 1;
+    }
+}
+
+extern "C"
+{
+    int32 ccrgb24toyuv(uint8 *rgb24, uint8 *yuv[], uint32 *param, uint8 *table[]);
+}
+
+int32 CCRGB24toYUV420::Convert(uint8 *rgb24, uint8 *yuv420)
+{
+    uint32 param[3];
+    uint8 *table[3];
+    int32 size16 = _mDst_pitch * _mDst_mheight;
+    uint8 *yuv[3];
+
+    OSCL_ASSERT(rgb24);
+    OSCL_ASSERT(yuv420);
+    OSCL_ASSERT(_mInitialized == true);
+
+    param[0] = (uint32) _mSrc_width;
+    param[1] = (uint32) _mSrc_height;
+    param[2] = (uint32) iBottomUp;
+
+    table[0] = iY_Table;
+    table[1] = ipCb_Table;
+    table[2] = ipCr_Table;
+
+    yuv[0] = yuv420;
+    yuv[1] = yuv420 + size16;
+    yuv[2] = yuv[1] + (size16 >> 2);
+
+    return ccrgb24toyuv(rgb24, yuv, param, table);
+
+}
+
+// in this overload, yuv420 is the output, rgb24 is input
+int32 CCRGB24toYUV420::Convert(uint8 *rgb24, uint8 **yuv420)
+{
+    uint32 param[3];
+    uint8 *table[3];
+
+    OSCL_ASSERT(rgb24);
+    OSCL_ASSERT(yuv420);
+    OSCL_ASSERT(yuv420[0]);
+    OSCL_ASSERT(yuv420[1]);
+    OSCL_ASSERT(yuv420[2]);
+    OSCL_ASSERT(_mInitialized == true);
+
+    param[0] = (uint32) _mSrc_width;
+    param[1] = (uint32) _mSrc_height;
+    param[2] = (uint32) iBottomUp;
+
+    table[0] = iY_Table;
+    table[1] = ipCb_Table;
+    table[2] = ipCr_Table;
+
+    return ccrgb24toyuv(rgb24, yuv420, param, table);
+
+}
+
+int32 ccrgb24toyuv(uint8 *rgb24, uint8 *yuv[], uint32 *param, uint8 *table[])
+{
+    uint8 *inputRGB = NULL;
+    int i, j, ilimit, jlimit;
+    uint8 *tempY, *tempU, *tempV;
+    uint8 *inputRGB_prevRow = NULL;
+
+    int32 width = param[0];
+    int32 height = param[1];
+    int32 width_16 = ((width + 15) >> 4) << 4;
+    int32 height_16 = ((height + 15) >> 4) << 4;
+    uint32 iBottomUp = param[2];
+    uint8 *y_tab = table[0];
+    uint8 *cb_tab = table[1];
+    uint8 *cr_tab = table[2];
+    int32 size16 = height_16 * width_16;
+    int32 adjust = (width + (width << 1));
+
+    inputRGB = rgb24;
+
+    /* do padding at the bottom first */
+    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
+    if (height < height_16 || width < width_16) /* if padding */
+    {
+        int offset = (height < height_16) ? height : height_16;
+
+        offset = (offset * width_16);
+
+        if (width < width_16)
+        {
+            offset -= (width_16 - width);
+        }
+        tempY = yuv[0] + offset;
+        oscl_memset((uint8 *)tempY, 16, size16 - offset); /* pad with zeros */
+
+        tempU = yuv[0] + size16 + (offset >> 2);
+        oscl_memset((uint8 *)tempU, 128, (size16 - offset) >> 2);
+
+        tempV = yuv[0] + size16 + (size16 >> 2) + (offset >> 2);
+        oscl_memset((uint8 *)tempV, 128, (size16 - offset) >> 2);
+    }
+
+    /* then do padding on the top */
+    tempY = yuv[0]; /* Normal order */
+    tempU = yuv[0] + size16;
+    tempV = tempU + (size16 >> 2);
+
+    /* To center the output */
+    if (height_16 > height)
+    {
+        if (width_16 >= width)
+        {
+            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+        }
+        else
+        {
+            i = ((height_16 - height) >> 1) * width_16;
+            j = ((height_16 - height) >> 2) * (width_16 >> 1);
+            inputRGB += ((width - width_16) >> 1) * 3;
+        }
+        oscl_memset((uint8 *)tempY, 16, i);
+        tempY += i;
+        oscl_memset((uint8 *)tempU, 128, j);
+        tempU += j;
+        oscl_memset((uint8 *)tempV, 128, j);
+        tempV += j;
+    }
+    else
+    {
+        if (width_16 >= width)
+        {
+            i = (((width_16 - width) >> 3) << 2);
+            /* make sure that (width_16-width)>>1 is divisible by 4 */
+            j = (((width_16 - width) >> 4) << 2);
+            /* make sure that (width_16-width)>>2 is divisible by 4 */
+            inputRGB += (((height - height_16) >> 1) * width) * 3;
+        }
+        else
+        {
+            i = 0;
+            j = 0;
+            inputRGB += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) * 3;
+        }
+        oscl_memset((uint8 *)tempY, 16, i);
+        tempY += i;
+        oscl_memset((uint8 *)tempU, 128, j);
+        tempU += j;
+        oscl_memset((uint8 *)tempV, 128, j);
+        tempV += j;
+    }
+
+    /* ColorConv RGB24-to-YUV420 with cropping or zero-padding */
+    if (height < height_16)
+        jlimit = height;
+    else
+        jlimit = height_16;
+
+    if (width < width_16)
+        ilimit = width;
+    else
+        ilimit = width_16;
+
+    if (iBottomUp == 1)
+    {
+        inputRGB += (jlimit - 1) * width * 3 ; // move to last row
+        adjust = -adjust;
+    }
+
+    for (j = 0; j < jlimit; j++)
+    {
+        for (i = 0; i < ilimit*3; i += 3)
+        {
+
+            *tempY++ = y_tab[(6616*inputRGB[i] + (inputRGB[i+1] << 16) + 19481 * inputRGB[i+2]) >> 16];
+
+            /* downsampling U, V */
+            if (j % 2 == 1 && i % 2 == 1)
+            {
+
+                *tempU++ = (unsigned char)((cb_tab[((inputRGB[i] << 16) - (inputRGB[i+1] << 16) + 19525 * (inputRGB[i] - inputRGB[i+2])) >> 16] + /* bottom right(current) */
+                                            cb_tab[((inputRGB[i-3] << 16) - (inputRGB[i-2] << 16) + 19525 * (inputRGB[i-3] - inputRGB[i-1])) >> 16] + /* bottom left */
+                                            cb_tab[((inputRGB_prevRow[i] << 16) - (inputRGB_prevRow[i+1] << 16) + 19525 * (inputRGB_prevRow[i] - inputRGB_prevRow[i+2])) >> 16] + /* top right */
+                                            cb_tab[((inputRGB_prevRow[i-3] << 16) - (inputRGB_prevRow[i-2] << 16) + 19525 * (inputRGB_prevRow[i-3] - inputRGB_prevRow[i-1])) >> 16]  + /* top left */
+                                            2) >> 2);
+
+
+                *tempV++ = (unsigned char)((cr_tab[((inputRGB[i+2] << 16) - (inputRGB[i+1] << 16) + 6640 * (inputRGB[i+2] - inputRGB[i])) >> 16] + /* bottom right(current) */
+                                            cr_tab[((inputRGB[i-1] << 16) - (inputRGB[i-2] << 16) + 6640 * (inputRGB[i-1] - inputRGB[i-3])) >> 16] + /* bottom left */
+                                            cr_tab[((inputRGB_prevRow[i+2] << 16) - (inputRGB_prevRow[i+1] << 16) + 6640 * (inputRGB_prevRow[i+2] - inputRGB_prevRow[i])) >> 16] + /* top right */
+                                            cr_tab[((inputRGB_prevRow[i-1] << 16) - (inputRGB_prevRow[i-2] << 16) + 6640 * (inputRGB_prevRow[i-1] - inputRGB_prevRow[i-3])) >> 16]  + /* top left */
+                                            2) >> 2);
+
+            }
+        }
+
+        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
+        if (width < width_16 && j < jlimit - 1)
+        {
+            oscl_memset(tempY, 16/* *(tempY-1)*/, width_16 - width);
+            tempY += (width_16 - width);
+
+            if (j % 2 == 1)
+            {
+                oscl_memset(tempU, 128/* *(tempU-1)*/, (width_16 - width) >> 1);
+                tempU += (width_16 - width) >> 1;
+                oscl_memset(tempV, 128/* *(tempV-1)*/, (width_16 - width) >> 1);
+                tempV += (width_16 - width) >> 1;
+            }
+        }
+
+        inputRGB_prevRow = inputRGB;
+        inputRGB += adjust ; /* move to the next row */
+    }
+
+    return 1;
+}
diff --git a/codecs_v2/utilities/colorconvert/src/ccyuv420semiplnrtoyuv420plnr.cpp b/codecs_v2/utilities/colorconvert/src/ccyuv420semiplnrtoyuv420plnr.cpp
new file mode 100644
index 0000000..7ae985f
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/ccyuv420semiplnrtoyuv420plnr.cpp
@@ -0,0 +1,368 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*******************************************************************************************
+ Class :: CCYUV420SEMItoYUV420.cpp
+------------------------------------
+The YUV420SEMI is semi interleaved and output format is YUV420 planar
+
+********************************************************************************************/
+#include "colorconv_config.h"
+#include "ccyuv420semitoyuv420.h"
+
+
+OSCL_EXPORT_REF ColorConvertBase* CCYUV420SEMItoYUV420 :: New()
+{
+    CCYUV420SEMItoYUV420* self = OSCL_NEW(CCYUV420SEMItoYUV420, ());
+    return OSCL_STATIC_CAST(ColorConvertBase*, self);
+}
+
+
+CCYUV420SEMItoYUV420 :: CCYUV420SEMItoYUV420()
+{
+}
+
+
+OSCL_EXPORT_REF CCYUV420SEMItoYUV420 :: ~CCYUV420SEMItoYUV420()
+{
+}
+
+
+int32 CCYUV420SEMItoYUV420:: Init(int32 SrcWidth, int32 SrcHeight, int32 SrcPitch, int32 DstWidth, int32 DstHeight, int32 DstPitch, int32 nRotation)
+{
+    /* no scaled outputs */
+    if (!(nRotation&0x1))
+    {
+        if ((SrcWidth != DstWidth) || (SrcHeight != DstHeight))
+        {
+            return 0;
+        }
+    }
+    else // with rotation
+    {
+        if ((SrcWidth != DstHeight) || (SrcHeight != DstWidth))
+        {
+            return 0;
+        }
+    }
+
+    if (SrcPitch != SrcWidth) // not support source cropping
+    {
+        return 0;
+    }
+    else
+    {
+        _mSrc_width = SrcWidth;
+        _mSrc_height = SrcHeight;
+        _mSrc_pitch = SrcPitch;
+        _mDst_width = DstWidth;
+        _mDst_height = DstHeight;
+        _mDst_pitch = DstPitch;
+        _mDst_mheight = DstHeight;
+        _mRotation = nRotation;
+
+        _mInitialized = true;
+
+        return 1;
+    }
+
+}
+
+
+int32 CCYUV420SEMItoYUV420:: GetOutputBufferSize(void)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    return((_mDst_pitch * _mDst_mheight*3) >> 1);
+}
+
+
+int32 CCYUV420SEMItoYUV420::SetMode(int32 nMode)
+{
+    OSCL_UNUSED_ARG(nMode);
+    OSCL_ASSERT(_mInitialized == true);
+
+    return 1;
+}
+
+int32 CCYUV420SEMItoYUV420::SetYuvFullRange(bool range)
+{
+    OSCL_UNUSED_ARG(range);
+    OSCL_ASSERT(_mInitialized == true);
+
+    return 1;  // has no meaning in this class. Always return 1
+}
+
+int32 CCYUV420SEMItoYUV420::Convert(uint8 *inyuvBuf, uint8 *outyuvBuf)
+{
+    uint8 *yuvBuf[3] = {NULL, NULL, NULL };
+    int outYsize = (_mDst_pitch * _mDst_mheight);
+    OSCL_ASSERT(inyuvBuf);
+    OSCL_ASSERT(outyuvBuf);
+
+    yuvBuf[0] = outyuvBuf;
+    yuvBuf[1] = (outyuvBuf + outYsize);
+    yuvBuf[2] = (outyuvBuf + outYsize + (outYsize >> 2));
+
+    return (Convert(inyuvBuf, yuvBuf));
+}
+
+
+int32 CCYUV420SEMItoYUV420::Convert(uint8 *inyuv, uint8 **outyuv)
+{
+
+    int32 i, j;
+    uint16 *outcb, *outcr;
+    uint32 *outy;
+    uint32 *inyuv_4;
+    uint32 temp, tempU, tempV;
+    int outYsize, offset;
+
+    int lpitch = _mDst_pitch;
+    int lheight = _mSrc_height;
+
+    OSCL_ASSERT(inyuv);
+    OSCL_ASSERT(outyuv);
+    OSCL_ASSERT(_mInitialized == true);
+
+    outYsize = (lpitch * _mDst_mheight);
+
+    inyuv_4 = (uint32 *)inyuv;
+
+    switch (_mRotation)
+    {
+        case 0://Rotation0
+
+            outy = (uint32*) outyuv[0];
+            outcb = (uint16*) outyuv[1];
+            outcr = (uint16*) outyuv[2];
+
+            offset = lpitch - _mSrc_width;
+
+            /* Y copying */
+            for (i = lheight; i > 0; i--)
+            {
+                for (j = _mSrc_width >> 2; j > 0; j--)
+                {
+                    temp = *inyuv_4++;
+                    *outy++ = temp;
+                }
+                /* in case the dest pitch is larger than width */
+                outy += (offset >> 2);
+            }
+
+            /* U & V copying */
+            for (i = lheight >> 1; i > 0; i--)
+            {
+                for (j = _mSrc_width >> 2; j > 0; j--)
+                {
+                    temp = *inyuv_4++; /* V1U1V0U0 */
+                    tempU = temp & 0xFF; // U0
+                    tempU = tempU | ((temp >> 8) & 0xFF00); //U1U0
+
+                    tempV = (temp >> 8) & 0xFF; // V0
+                    tempV = tempV | ((temp >> 16) & 0xFF00); //V1V0
+
+                    *outcb++ = tempU;
+                    *outcr++ = tempV;
+                }
+                /* in case the dest pitch is larger than width */
+                outcb += (offset >> 2);
+                outcr += (offset >> 2);
+            }
+
+            break;
+
+        case 1: // Rotation90 CW
+            /* To traverse in raster scan for output and vertical scan on the input.
+            ** You can write output 4 bytes at a time.
+            ** However, it takes more number of variables and more code size.
+            */
+            uint32 temp1;
+            outy = (uint32*) outyuv[0];
+            outcb = (uint16*) outyuv[1];
+            outcr = (uint16*) outyuv[2];
+
+            outy  = outy + (lpitch >> 2) - 1;
+            outcb = outcb + (lpitch >> 2) - 1;
+            outcr = outcr + (lpitch >> 2) - 1;
+
+            /* Y copying */
+            for (i = _mSrc_width; i > 0; i--)
+            {
+                for (j = lheight >> 2; j > 0; j--)
+                {
+                    temp = (*inyuv);
+                    inyuv += _mSrc_width;
+                    temp = (temp << 8) | (*inyuv);
+                    inyuv += _mSrc_width;
+                    temp = (temp << 8) | (*inyuv);
+                    inyuv += _mSrc_width;
+                    temp = (temp << 8) | (*inyuv);
+                    inyuv += _mSrc_width;
+                    *outy = temp;
+                    outy--;
+                }
+                inyuv = inyuv - (lheight * _mSrc_width) + 1;
+                outy = outy + (lheight >> 2) + (lpitch >> 2);
+                /* in case the dest pitch is larger than width */
+            }
+
+            inyuv = inyuv + (lheight * _mSrc_width) - _mSrc_width;
+
+            /* U & V copying */
+            for (i = _mSrc_width >> 1; i > 0; i--)
+            {
+                for (j = lheight >> 2; j > 0; j--)
+                {
+                    temp = *inyuv++; //U0
+                    temp1 = *inyuv--; //V0
+                    inyuv += _mSrc_width;
+                    temp = (temp << 8) | (*inyuv); //U1U0
+                    inyuv++;
+                    temp1 = (temp1 << 8) | (*inyuv); //V1V0
+                    inyuv--;
+                    inyuv += _mSrc_width;
+
+                    *outcb = temp;
+                    *outcr = temp1;
+                    outcb--;
+                    outcr--;
+                }
+                /* in case the dest pitch is larger than width */
+                inyuv = inyuv - ((lheight >> 1) * _mSrc_width) + 2;
+                outcb = outcb + (lheight >> 2) + (lpitch >> 2);
+                outcr = outcr + (lheight >> 2) + (lpitch >> 2);
+            }
+            break;
+
+        case 2://Rotation180
+
+            outy  = (uint32*)((uint8*)outyuv[0] + outYsize - 4);
+            outcb = (uint16*)((uint8*)outyuv[1] + (outYsize >> 2) - 4);
+            outcr = (uint16*)((uint8*)outyuv[2] + (outYsize >> 2) - 4);
+
+            offset = lpitch - _mSrc_width;
+
+            /* Y copying */
+            for (i = lheight; i > 0; i--)
+            {
+                for (j = _mSrc_width >> 2; j > 0; j--)
+                {
+                    temp = *inyuv_4++;
+                    *outy-- = SWAP_4(temp);
+                }
+                /* in case the dest pitch is larger than width */
+                outy -= (offset >> 2);
+            }
+
+            /* U & V copying */
+            for (i = lheight >> 1; i > 0; i--)
+            {
+                for (j = _mSrc_width >> 2; j > 0; j--)
+                {
+                    temp = *inyuv_4++; /* V1U1V0U0 */
+                    tempU = temp & 0xFF; // U0
+                    tempU = (tempU << 8) | ((temp >> 16) & 0xFF); //U0U1
+
+                    tempV = (temp >> 8) & 0xFF; // V0
+                    tempV = (tempV << 8) | (temp >> 24); //V0V1
+
+                    *outcb-- = tempU;
+                    *outcr-- = tempV;
+                }
+                /* in case the dest pitch is larger than width */
+                outcb -= (offset >> 2);
+                outcr -= (offset >> 2);
+            }
+
+            break;
+
+        case 3: // Rotation270	CW
+            /* To traverse in raster scan for output and vertical scan on the input.
+            ** You can write output 4 bytes at a time.
+            ** However, it takes more number of variables and more code size.
+            */
+            outy = (uint32*) outyuv[0];
+            outcb = (uint16*) outyuv[1];
+            outcr = (uint16*) outyuv[2];
+
+            outy  = outy + ((lpitch >> 2) * (_mSrc_width - 1));
+            outcb = outcb + ((lpitch >> 2) * ((_mSrc_width >> 1) - 1));
+            outcr = outcr + ((lpitch >> 2) * ((_mSrc_width >> 1) - 1));
+
+            /* Y copying */
+            for (i = _mSrc_width; i > 0; i--)
+            {
+                for (j = lheight >> 2; j > 0; j--)
+                {
+                    temp = (*inyuv);
+                    inyuv += _mSrc_width;
+                    temp |= ((*inyuv) << 8);
+                    inyuv += _mSrc_width;
+                    temp |= ((*inyuv) << 16);
+                    inyuv += _mSrc_width;
+                    temp |= ((*inyuv) << 24);
+                    inyuv += _mSrc_width;
+                    *outy = temp;
+                    outy++;
+                }
+                inyuv = inyuv - (lheight * _mSrc_width) + 1;
+                outy = outy - ((lheight >> 2) + (lpitch >> 2));
+                /* in case the dest pitch is larger than width */
+            }
+
+            inyuv = inyuv + (lheight * _mSrc_width) - _mSrc_width;
+
+            /* U & V copying */
+            for (i = _mSrc_width >> 1; i > 0; i--)
+            {
+                for (j = lheight >> 2; j > 0; j--)
+                {
+                    temp = *inyuv++; //U0
+                    temp1 = *inyuv--; //V0
+                    inyuv += _mSrc_width;
+                    temp |= ((*inyuv) << 8); //U0U1
+                    inyuv++;
+                    temp1 |= ((*inyuv) << 8); //V0V1
+                    inyuv--;
+                    inyuv += _mSrc_width;
+
+                    *outcb = temp;
+                    *outcr = temp1;
+                    outcb++;
+                    outcr++;
+                }
+                /* in case the dest pitch is larger than width */
+                inyuv = inyuv - ((lheight >> 1) * _mSrc_width) + 2;
+                outcb = outcb - ((lheight >> 2) + (lpitch >> 2));
+                outcr = outcr - ((lheight >> 2) + (lpitch >> 2));
+            }
+            break;
+
+        default:
+            break;
+
+    }//switch
+
+    return 1;
+}
+
+
+
+
+
diff --git a/codecs_v2/utilities/colorconvert/src/ccyuv420toyuv420semi.cpp b/codecs_v2/utilities/colorconvert/src/ccyuv420toyuv420semi.cpp
new file mode 100644
index 0000000..77f54b5
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/ccyuv420toyuv420semi.cpp
@@ -0,0 +1,158 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/** Class ColorConvertYUV420SEMI, convert YUV to YUV420SEMI PLANAR */
+#include "colorconv_config.h"
+#include "ccyuv420toyuv420semi.h"
+#include "osclconfig_compiler_warnings.h"
+
+OSCL_EXPORT_REF ColorConvertBase* ColorConvertYUV420SEMI::NewL(void)
+{
+    ColorConvertYUV420SEMI* self = OSCL_NEW(ColorConvertYUV420SEMI, ());
+    return OSCL_STATIC_CAST(ColorConvertBase*, self);
+}
+
+
+ColorConvertYUV420SEMI::ColorConvertYUV420SEMI()
+{
+}
+
+
+OSCL_EXPORT_REF ColorConvertYUV420SEMI::~ColorConvertYUV420SEMI()
+{
+}
+
+
+int32 ColorConvertYUV420SEMI::Init(int32 Src_width, int32 Src_height, int32 Src_pitch, int32 Dst_width, int32 Dst_height, int32 Dst_pitch, int32 nRotation)
+{
+    if (ColorConvertBase::Init(Src_width, Src_height, Src_pitch, Dst_width, Dst_height, Dst_pitch, nRotation) == 0)
+    {
+        return 0;
+    }
+
+    _mInitialized = true;
+
+    return 1;
+}
+
+int32  ColorConvertYUV420SEMI::SetYuvFullRange(bool range)
+{
+    OSCL_UNUSED_ARG(range);
+    OSCL_ASSERT(_mInitialized == true);
+    return 1;
+}
+
+
+int32 ColorConvertYUV420SEMI::SetMode(int32 nMode)	//iMode : 0 Off, 1 On
+{
+    OSCL_UNUSED_ARG(nMode);
+    OSCL_ASSERT(_mInitialized == true);
+    return 1;
+}
+
+
+int32 ColorConvertYUV420SEMI::GetOutputBufferSize(void)
+{
+    OSCL_ASSERT(_mInitialized == true);
+
+    return	_mState ? ((_mDst_height*_mDst_pitch*3) / 2) : ((_mSrc_width*_mSrc_height*3) / 2);
+}
+
+
+int32 ColorConvertYUV420SEMI::Convert(uint8 **yuvBuf, uint8 *rgbBuf)
+{
+    OSCL_ASSERT(_mInitialized == true);
+    OSCL_ASSERT(yuvBuf);
+    OSCL_ASSERT(yuvBuf[0]);
+    OSCL_ASSERT(yuvBuf[1]);
+    OSCL_ASSERT(yuvBuf[2]);
+    OSCL_ASSERT(rgbBuf);
+
+    int i, j;
+    uint8 *inCb, *inCr;
+    uint32 *inY, *outYUV420SEMI;
+    uint32 temp, tempU, tempV;
+    int offset;
+
+    if (((uint32)rgbBuf)&0x3 || ((uint32)yuvBuf[0])&0x3) /* address is not word align */
+    {
+        return 0;
+    }
+
+    inY = (uint32*) yuvBuf[0];
+    inCb = yuvBuf[1];
+    inCr = yuvBuf[2];
+    outYUV420SEMI = (uint32 *)rgbBuf;
+
+    offset = _mDst_pitch - _mSrc_width;
+
+    /* Y copying */
+    for (i = _mSrc_height; i > 0; i--)
+    {
+        for (j = _mSrc_width >> 2; j > 0; j--)
+        {
+            temp = *inY++;
+            *outYUV420SEMI++ = temp;
+        }
+        /* in case the dest pitch is larger than width */
+        outYUV420SEMI += (offset >> 2);
+    }
+
+    /* U & V copying */
+    for (i = _mSrc_height >> 1; i > 0; i--)
+    {
+        for (j = _mSrc_width >> 2; j > 0; j--)
+        {
+            tempU = *inCb++;	//U0
+            tempV = *inCr++;	//V0
+            temp = tempU | (tempV << 8) ; //V0U0
+            tempU = *inCb++;	//U1
+            tempV = *inCr++;	//V1
+            tempU = tempU | (tempV << 8) ; //V1U1
+            temp |= (tempU << 16); //V1U1V0U0
+            *outYUV420SEMI++ = temp;
+        }
+        /* in case the dest pitch is larger than width */
+        outYUV420SEMI += (offset >> 2);
+    }
+
+    return 1;
+}
+
+
+int32 ColorConvertYUV420SEMI::Convert(uint8 *yuvBuf, uint8 *rgbBuf)
+{
+    //this conversion will cause problems when do src clipping. However, if they want, they must give more info
+    uint8 *TmpYuvBuf[3];
+
+    OSCL_ASSERT(_mInitialized == true);
+    OSCL_ASSERT(yuvBuf);
+    OSCL_ASSERT(rgbBuf);
+
+    if (((uint32)rgbBuf)&0x3 || ((uint32)yuvBuf)&0x3) /* address is not word align */
+    {
+        return 0;
+    }
+
+    TmpYuvBuf[0]	=	yuvBuf;
+    TmpYuvBuf[1]	=	yuvBuf + (_mSrc_pitch) * (_mSrc_mheight);
+    TmpYuvBuf[2]	=	TmpYuvBuf[1] + (_mSrc_pitch * _mSrc_mheight) / 4;
+
+    return (Convert(TmpYuvBuf, rgbBuf));
+}
+
+
diff --git a/codecs_v2/utilities/colorconvert/src/ccyuv422toyuv420.cpp b/codecs_v2/utilities/colorconvert/src/ccyuv422toyuv420.cpp
index d6510d7..874fb38 100644
--- a/codecs_v2/utilities/colorconvert/src/ccyuv422toyuv420.cpp
+++ b/codecs_v2/utilities/colorconvert/src/ccyuv422toyuv420.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,10 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-//                                                                              //
-//  File: ccyuv422toyuv420.cpp                                                //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
 /*******************************************************************************************
  Class :: CCYUV422toYUV420.cpp
 ------------------------------------
diff --git a/codecs_v2/utilities/colorconvert/src/cczoomrotation12.cpp b/codecs_v2/utilities/colorconvert/src/cczoomrotation12.cpp
index 18b73b2..4582529 100644
--- a/codecs_v2/utilities/colorconvert/src/cczoomrotation12.cpp
+++ b/codecs_v2/utilities/colorconvert/src/cczoomrotation12.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -197,8 +197,16 @@
 {
     OSCL_ASSERT(_mInitialized == true);
 
-    // for zoom, need extra line of RGB buffer for processing otherwise memory will corrupt.
-    return	_mState ? ((_mDst_height + 1)*_mDst_pitch*2) : (_mSrc_width*_mSrc_height*2);
+    if (_mIsZoom)
+    {
+        // for zoom, need extra line of RGB buffer for processing otherwise memory will corrupt.
+        return	_mState ? ((_mDst_height + 1)*_mDst_pitch*2) : (_mSrc_width*_mSrc_height*2);
+    }
+    else
+    {
+        return	_mState ? ((_mDst_height)*_mDst_pitch*2) : (_mSrc_width*_mSrc_height*2);
+    }
+
 }
 
 
diff --git a/codecs_v2/utilities/colorconvert/src/cczoomrotation16.cpp b/codecs_v2/utilities/colorconvert/src/cczoomrotation16.cpp
index 679636c..6c150c2 100644
--- a/codecs_v2/utilities/colorconvert/src/cczoomrotation16.cpp
+++ b/codecs_v2/utilities/colorconvert/src/cczoomrotation16.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,10 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-//                                                                              //
-//  File: cczoomrotation16.cpp                                                //
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
 /** Class ColorConvert16, convert YUV to RGB16 in 5-6-5 format. */
 #include "colorconv_config.h"
 #include "cczoomrotation16.h"
diff --git a/codecs_v2/utilities/colorconvert/src/cczoomrotation24.cpp b/codecs_v2/utilities/colorconvert/src/cczoomrotation24.cpp
index c48ff9a..fbebcaa 100644
--- a/codecs_v2/utilities/colorconvert/src/cczoomrotation24.cpp
+++ b/codecs_v2/utilities/colorconvert/src/cczoomrotation24.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 #include "cczoomrotation24.h"
 
 
+
 OSCL_EXPORT_REF ColorConvertBase* ColorConvert24::NewL(void)
 {
     ColorConvert24* self = OSCL_NEW(ColorConvert24, ());
@@ -154,7 +155,14 @@
 {
     OSCL_ASSERT(_mInitialized == true);
     // for zoom, need extra line of RGB buffer for processing otherwise memory will corrupt.
-    return	_mState ? ((_mDst_height + 1)*_mDst_pitch*3) : (_mSrc_width*_mSrc_height*3);
+    if (_mIsZoom)
+    {
+        return	_mState ? ((_mDst_height + 1)*_mDst_pitch*3) : (_mSrc_width*_mSrc_height*3);
+    }
+    else
+    {
+        return	_mState ? ((_mDst_height)*_mDst_pitch*3) : (_mSrc_width*_mSrc_height*3);
+    }
 }
 
 
@@ -226,6 +234,8 @@
     }
 }
 
+
+
 int32 cc24(uint8 **src, uint8 *dst, int32 *disp, uint8 *clip)
 {
     uint8 *pCb, *pCr;
@@ -495,6 +505,7 @@
 
 
 
+
 int32 ColorConvert24::cc24Rotate(uint8 **src, uint8 *dst, DisplayProperties *disp, uint8 *clip)
 {
 #ifdef CCROTATE
diff --git a/codecs_v2/utilities/colorconvert/src/cczoomrotation32.cpp b/codecs_v2/utilities/colorconvert/src/cczoomrotation32.cpp
index 8c1d74c..513d288 100644
--- a/codecs_v2/utilities/colorconvert/src/cczoomrotation32.cpp
+++ b/codecs_v2/utilities/colorconvert/src/cczoomrotation32.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,9 @@
 #include "cczoomrotation32.h"
 #include "osclconfig_compiler_warnings.h"
 
+
+
+
 OSCL_EXPORT_REF ColorConvertBase* ColorConvert32::NewL(void)
 {
     ColorConvert32* self = OSCL_NEW(ColorConvert32, ());
@@ -224,6 +227,7 @@
     }
 }
 
+
 int32 cc32(uint8 **src, uint8 *dst, int32 *disp, uint8 *clip)
 {
     uint8		*pCb, *pCr;
@@ -359,7 +363,6 @@
     return 1;
 }
 
-
 // platform specific C function
 int32 cc32scaledown(uint8 **src, uint8 *dst, int32 *disp,
                     uint8 *coff_tbl, uint8 *_mRowPix, uint8 *_mColPix);
@@ -828,4 +831,3 @@
 #endif
 }
 
-
diff --git a/codecs_v2/utilities/colorconvert/src/cczoomrotationbase.cpp b/codecs_v2/utilities/colorconvert/src/cczoomrotationbase.cpp
index 57ce408..ea64a81 100644
--- a/codecs_v2/utilities/colorconvert/src/cczoomrotationbase.cpp
+++ b/codecs_v2/utilities/colorconvert/src/cczoomrotationbase.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/utilities/colorconvert/src/cpvvideoblend.cpp b/codecs_v2/utilities/colorconvert/src/cpvvideoblend.cpp
new file mode 100644
index 0000000..87cebcf
--- /dev/null
+++ b/codecs_v2/utilities/colorconvert/src/cpvvideoblend.cpp
@@ -0,0 +1,374 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+//class CPVVideoBlend.cpp
+#include "pvvideoblend.h"
+
+// Use default DLL entry point
+#include "oscl_dll.h"
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+OSCL_EXPORT_REF CPVVideoBlend* CPVVideoBlend :: New()
+{
+    CPVVideoBlend *pobj = OSCL_NEW(CPVVideoBlend, ()) ;
+
+
+    return pobj;
+}
+
+CPVVideoBlend :: CPVVideoBlend()
+{
+    int err;
+
+    OSCL_TRY(err,
+             CameraInput = (CCYUV422toYUV420*) CCYUV422toYUV420::New();
+             BitmapInput = (CCRGB16toYUV420*) CCRGB16toYUV420::New();
+             DecoderOutput = (ColorConvert16*) ColorConvert16::NewL();
+             EncoderInput = (ColorConvert16*) ColorConvert16::NewL();
+            );
+
+    if (err != OsclErrNone)
+    {
+        OSCL_LEAVE(err);
+    }
+}
+
+
+
+OSCL_EXPORT_REF CPVVideoBlend :: ~CPVVideoBlend()
+{
+
+}
+
+
+OSCL_EXPORT_REF int32 CPVVideoBlend::InitInputBlend(PVDimension *frameSize, PVRotationCLKWise rotation)
+{
+    uint32 width_src, height_src, pitch_src, width_dst, height_dst, pitch_dst;
+    int rot = 0;
+
+    mInitInputBlend = false;
+
+    width_src = frameSize->width;
+    height_src = frameSize->height;
+    pitch_src = frameSize->width;
+
+    switch (rotation)
+    {
+        case Rotation0	:
+            rot = 0;
+            break;
+        case Rotation90	:
+            rot = 3;
+            break;
+        case Rotation180	:
+            rot = 2;
+            break;
+        case Rotation270	:
+            rot = 1;
+            break;
+    }
+
+    if (rotation&1) /* rotation 90 or 270 degree */
+    {
+        width_dst = height_src;
+        height_dst = width_src;
+        pitch_dst = height_src;
+    }
+    else
+    {
+        width_dst = width_src;
+        height_dst = height_src;
+        pitch_dst = pitch_src;
+    }
+
+    if (!CameraInput->Init(width_src, height_src, pitch_src, width_dst, height_dst, pitch_dst, rot))
+    {
+        return 0;
+    }
+
+    if (!BitmapInput->Init(width_dst, height_dst, pitch_dst, width_dst, height_dst, pitch_dst, 0))
+    {
+        return 0;
+    }
+
+    mInitInputBlend = true;
+
+    return 1;
+}
+
+// Still need some optimization to save time during the init.
+// If the param is the same, we shouldn't call init all the time.
+OSCL_EXPORT_REF int32 CPVVideoBlend :: BlendInput(PVBlendFrame *pCameraInput, PVBitmap *pBitmap, PVBlendFrame *pToEncode)
+{
+    uint8 *inputRGB;
+    uint8 *outYUV;
+    uint8 *srcBuffer, *dstBuffer;
+    PVYUVFormat format;
+    uint32 width_src, height_src, pitch_src, width_dst, height_dst, pitch_dst;
+    int16 colorkey;
+
+    if (mInitInputBlend == false || (pCameraInput == NULL && pBitmap == NULL) || (pToEncode == NULL))
+    {
+        return 0;
+    }
+
+    /*********** For YUV422 to YUV420 conversion **********/
+    if (pCameraInput != NULL)
+    {
+        srcBuffer = pCameraInput->pBuffer;
+        width_src = pCameraInput->width;
+        height_src = pCameraInput->height;
+        format = pCameraInput->format;
+        pitch_src = width_src;
+
+        dstBuffer = pToEncode->pBuffer;
+        Dst_width = pToEncode->width; // 1:1, so equal to source
+        Dst_height = pToEncode->height; // 1:1, so equal to source
+        pitch_dst = pToEncode->width; // width of the destination buffer
+
+        if (format == YUV422)
+        {
+            /* check the buffer size */
+            if ((pCameraInput->bufSize < pitch_src*height_src*2) ||
+                    (pToEncode->bufSize < ((pitch_dst*Dst_height*3) >> 1)))
+            {
+                return 0;
+            }
+
+            /* perform the conversion */
+            if (!CameraInput->Convert(srcBuffer, dstBuffer))
+            {
+                return 0;
+            }
+
+        }
+        else
+        {
+            return 0;
+        }
+    }
+
+    /********** For RGB16 to YUV420 conversion **********/
+    if (pBitmap != NULL)
+    {
+        inputRGB = pBitmap->pBuffer;
+        width_src	 = pBitmap->width;
+        height_src	 = pBitmap->height;
+        colorkey = pBitmap->color_key;
+        pitch_src = width_src; // equal to the source width
+
+        // to YUV420 output
+        outYUV = pToEncode->pBuffer;
+        width_dst = width_src; // 1:1, set it to source
+        height_dst = height_src; // 1:1, set it to source
+        pitch_dst = pToEncode->width;
+        Dst_height = pToEncode->height; // 1:1, so equal to source
+
+        /* check buffer size */
+        if ((pBitmap->bufSize < (pitch_src*height_src*2)) ||
+                (pToEncode->bufSize < ((pitch_dst*Dst_height*3) >> 1)))
+        {
+            return 0;
+        }
+
+        if (pCameraInput != NULL)	// use color key when camera input is present
+        {
+            BitmapInput->SetColorkey(colorkey);
+        }
+
+        if (!BitmapInput->Convert(inputRGB, outYUV))
+        {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
+
+OSCL_EXPORT_REF int32 CPVVideoBlend :: InitOutputBlend(PVDimension *srcDecodeFrm,
+        PVDimension *dstDecodeFrm,
+        PVDimension *srcEncodeFrm,
+        PVDimension *dstEncodeFrm,
+        int32 rotateMirrorForEncFrm,
+        int32 pitch)
+{
+
+    mInitOutputBlend = false;
+
+    if (srcDecodeFrm != NULL)
+    {
+        Src_width = srcDecodeFrm->width;
+        Src_height = srcDecodeFrm->height;
+        Src_pitch = Src_width;
+
+        Dst_width = dstDecodeFrm->width;
+        Dst_height = dstDecodeFrm->height;
+        Dst_pitch = pitch;
+
+        Rotation = 0;
+
+        if (!DecoderOutput->Init(Src_width, Src_height, Src_pitch, Dst_width, Dst_height, Dst_pitch, Rotation))
+        {
+            return 0;
+        }
+
+        if (!DecoderOutput->SetMode(1))
+        {
+            return 0;
+        }
+    }
+
+    if (srcEncodeFrm != NULL)
+    {
+        Src_width = srcEncodeFrm->width;
+        Src_height = srcEncodeFrm->height;
+        Src_pitch = Src_width;
+
+        Dst_width = dstEncodeFrm->width;
+        Dst_height = dstEncodeFrm->height;
+        Dst_pitch = pitch;
+
+        Rotation = rotateMirrorForEncFrm; // for clockwise rotation CC16.lib supports counter clock wise rotation
+        switch (Rotation)
+        {
+            case 0	:
+                Rotation = 0;
+                break;
+            case 1	:
+                Rotation = 3;
+                break;
+            case 2	:
+                Rotation = 2;
+                break;
+            case 3	:
+                Rotation = 1;
+                break;
+            case 4  :
+                Rotation = 4;
+                break;
+            case 5  :
+                Rotation = 7;
+                break;
+            case 6  :
+                Rotation = 6;
+                break;
+            case 7  :
+                Rotation = 5;
+                break;
+            default	:
+                break;
+        }
+
+
+        if (!EncoderInput->Init(Src_width, Src_height, Src_pitch, Dst_width, Dst_height, Dst_pitch, Rotation))
+        {
+            return 0;
+        }
+        if (!EncoderInput->SetMode(1))
+        {
+            return 0;
+        }
+    }
+
+    mInitOutputBlend = true;
+
+    return 1;
+}
+
+
+OSCL_EXPORT_REF int32 CPVVideoBlend :: BlendOutput(PVBlendFrame *pFromDecode, PVCoordinate *pos1,
+        PVBlendFrame *pToEncode, PVCoordinate *pos2,
+        PVBitmap *pDropDownMenu, PVCoordinate *pos3,
+        uint32 changeOutputOrder,
+        PVBitmap *pDisplayOutput)
+{
+
+    uint8 *yuvBuf[3], *yuvBufDec[3], *rgbBuf = NULL, *temprgbBuf;
+    int32 srcFrameSizeEnc = 0;
+    int32 srcFrameSizeDec = 0;
+
+    if (mInitOutputBlend == false)
+    {
+        return 0;
+    }
+
+    rgbBuf = pDisplayOutput->pBuffer;
+
+    if (pToEncode)
+    {
+        srcFrameSizeEnc = pToEncode->width * pToEncode->height;
+    }
+
+    if (pFromDecode)
+    {
+        srcFrameSizeDec = pFromDecode->width * pFromDecode->height;
+    }
+
+    if (changeOutputOrder)
+    {
+        if (pToEncode != NULL)
+        {
+            yuvBuf[0] = pToEncode->pBuffer;
+            yuvBuf[1] = yuvBuf[0] + srcFrameSizeEnc;
+            yuvBuf[2] = yuvBuf[1] + srcFrameSizeEnc / 4;
+            EncoderInput->Convert(yuvBuf, rgbBuf + (pos2->y * pDisplayOutput->width + pos2->x)*2);
+        }
+        if (pFromDecode != NULL)
+        {
+            yuvBufDec[0] = pFromDecode->pBuffer;
+            yuvBufDec[1] = yuvBufDec[0] + srcFrameSizeDec;
+            yuvBufDec[2] = yuvBufDec[1] + srcFrameSizeDec / 4;
+            DecoderOutput->Convert(yuvBufDec, rgbBuf + (pos1->y * pDisplayOutput->width + pos1->x)*2);
+        }
+    }
+    else
+    {
+        if (pFromDecode != NULL)
+        {
+            yuvBufDec[0] = pFromDecode->pBuffer;
+            yuvBufDec[1] = yuvBufDec[0] + srcFrameSizeDec;
+            yuvBufDec[2] = yuvBufDec[1] + srcFrameSizeDec / 4;
+            DecoderOutput->Convert(yuvBufDec, rgbBuf + (pos1->y * pDisplayOutput->width + pos1->x)*2);
+        }
+        if (pToEncode != NULL)
+        {
+            yuvBuf[0] = pToEncode->pBuffer;
+            yuvBuf[1] = yuvBuf[0] + srcFrameSizeEnc;
+            yuvBuf[2] = yuvBuf[1] + srcFrameSizeEnc / 4;
+            EncoderInput->Convert(yuvBuf, rgbBuf + (pos2->y * pDisplayOutput->width + pos2->x)*2);
+        }
+    }
+
+    if (pDropDownMenu != NULL)
+    {
+        temprgbBuf = pDropDownMenu->pBuffer ;
+        rgbBuf += (pos3->y * pDisplayOutput->width + pos3->x) * 2;
+        for (int i = 0; i < pDropDownMenu->height; i++)
+        {
+            for (int j = 0; j < pDropDownMenu->width*2; j++)
+            {
+                *rgbBuf++ = *temprgbBuf++;
+            }
+
+            rgbBuf += (Dst_pitch * 2) - (pDropDownMenu->width * 2);
+        }
+    }
+
+    return 1;
+}
+
diff --git a/codecs_v2/utilities/m4v_config_parser/Android.mk b/codecs_v2/utilities/m4v_config_parser/Android.mk
index 69cb3d1..4de7115 100644
--- a/codecs_v2/utilities/m4v_config_parser/Android.mk
+++ b/codecs_v2/utilities/m4v_config_parser/Android.mk
@@ -2,26 +2,27 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/\
-	src/m4v_config_parser.cpp
-
+ 	src/m4v_config_parser.cpp
 
 
 LOCAL_MODULE := libm4v_config
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/utilities/m4v_config_parser/include \
-	$(PV_TOP)//codecs_v2/utilities/m4v_config_parser/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/utilities/m4v_config_parser/src \
+ 	$(PV_TOP)/codecs_v2/utilities/m4v_config_parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/m4v_config_parser.h
+ 	include/m4v_config_parser.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/utilities/m4v_config_parser/build/make/local.mk b/codecs_v2/utilities/m4v_config_parser/build/make/local.mk
new file mode 100644
index 0000000..feed096
--- /dev/null
+++ b/codecs_v2/utilities/m4v_config_parser/build/make/local.mk
@@ -0,0 +1,25 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := m4v_config
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := \
+	m4v_config_parser.cpp
+
+HDRS := \
+	m4v_config_parser.h
+
+include $(MK)/library.mk
diff --git a/codecs_v2/utilities/m4v_config_parser/build/make/makefile b/codecs_v2/utilities/m4v_config_parser/build/make/makefile
deleted file mode 100644
index 2e6fea3..0000000
--- a/codecs_v2/utilities/m4v_config_parser/build/make/makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = m4v_config
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please includie a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I ../../../../pvmf/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = \
-	m4v_config_parser.cpp
-
-HDRS = \
-	m4v_config_parser.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/codecs_v2/utilities/m4v_config_parser/include/m4v_config_parser.h b/codecs_v2/utilities/m4v_config_parser/include/m4v_config_parser.h
index 3e40c72..50fbd4a 100644
--- a/codecs_v2/utilities/m4v_config_parser/include/m4v_config_parser.h
+++ b/codecs_v2/utilities/m4v_config_parser/include/m4v_config_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
 #include "oscl_base.h"
 #include "oscl_types.h"
 
+#define USE_LATER 0  // for some code that will be needed in the future
+
 #define MP4_INVALID_VOL_PARAM -1
 #define SHORT_HEADER_MODE -4
 
@@ -80,16 +82,23 @@
 );
 
 
-
-int16 iDecodeVOLHeader(mp4StreamType *psBits, int *width, int *height, int *, int *);
-OSCL_IMPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int length, int *width, int *height, int *, int *);
+OSCL_IMPORT_REF int16 iDecodeVOLHeader(mp4StreamType *psBits, int32 *width, int32 *height, int32 *, int32 *, int32 *profilelevel);
+OSCL_IMPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *, int32 *);
 int16 DecodeUserData(mp4StreamType *pStream);
-OSCL_IMPORT_REF int16 iDecodeShortHeader(mp4StreamType *psBits, int *width, int *height, int *, int *);
-OSCL_IMPORT_REF int16 iGetAVCConfigInfo(uint8 *buffer, int length, int *width, int *height, int *, int *);
-int16 DecodeSPS(mp4StreamType *psBits, int *width, int *height, int *display_width, int *display_height);
+OSCL_IMPORT_REF int16 iDecodeShortHeader(mp4StreamType *psBits, int32 *width, int32 *height, int32 *, int32 *);
+OSCL_IMPORT_REF int16 iGetAVCConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *, int32 *, int32 *profile, int32 *level);
+
+int32 FindNAL(uint8** nal_pnt, uint8* buffer, int32 length);
+int16 DecodeSPS(mp4StreamType *psBits, int32 *width, int32 *height, int32 *display_width, int32 *display_height, int32 *profile_idc, int32 *level_idc);
+#if USE_LATER
+int32 DecodeHRD(mp4StreamType *psBits);
+int32 DecodeVUI(mp4StreamType *psBits);
+#endif
+int32 DecodePPS(mp4StreamType *psBits);
+
 void ue_v(mp4StreamType *psBits, uint32 *codeNum);
 void se_v(mp4StreamType *psBits, int32 *value);
-void Parser_EBSPtoRBSP(uint8 *nal_unit, int *size);
+void Parser_EBSPtoRBSP(uint8 *nal_unit, int32 *size);
 
 #endif //PV_M4V_CONFIG_PARSER_H_INCLUDED
 
diff --git a/codecs_v2/utilities/m4v_config_parser/src/m4v_config_parser.cpp b/codecs_v2/utilities/m4v_config_parser/src/m4v_config_parser.cpp
index a5b4c3a..cbbf63e 100644
--- a/codecs_v2/utilities/m4v_config_parser/src/m4v_config_parser.cpp
+++ b/codecs_v2/utilities/m4v_config_parser/src/m4v_config_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
 
 int32 LocateFrameHeader(uint8 *ptr, int32 size)
 {
-    int count = 0;
+    int32 count = 0;
     int32 i = size;
 
     if (size < 1)
@@ -99,7 +99,7 @@
     return status;
 }
 
-OSCL_EXPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int length, int *width, int *height, int *display_width, int *display_height)
+OSCL_EXPORT_REF int16 iGetM4VConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *display_width, int32 *display_height)
 {
     int16 status;
     mp4StreamType psBits;
@@ -110,29 +110,40 @@
     psBits.bytePos = 0;
     psBits.dataBitPos = 0;
     *width = *height = *display_height = *display_width = 0;
-    status = iDecodeVOLHeader(&psBits, width, height, display_width, display_height);
+
+    if (length == 0)
+    {
+        return MP4_INVALID_VOL_PARAM;
+    }
+    int32 profilelevel = 0; // dummy value discarded here
+    status = iDecodeVOLHeader(&psBits, width, height, display_width, display_height, &profilelevel);
     return status;
 }
 
 // name: iDecodeVOLHeader
 // Purpose: decode VOL header
 // return:  error code
-int16 iDecodeVOLHeader(mp4StreamType *psBits, int *width, int *height, int *display_width, int *display_height)
+OSCL_EXPORT_REF int16 iDecodeVOLHeader(mp4StreamType *psBits, int32 *width, int32 *height, int32 *display_width, int32 *display_height, int32 *profilelevel)
 {
-
     int16 iErrorStat;
     uint32 codeword;
-    int time_increment_resolution, nbits_time_increment;
-    int i, j;
+    int32 time_increment_resolution, nbits_time_increment;
+    int32 i, j;
+
+    *profilelevel = 0x0000FFFF; // init to some invalid value. When this value is returned, then no profilelevel info is available
 
     ShowBits(psBits, 32, &codeword);
 
     if (codeword == VISUAL_OBJECT_SEQUENCE_START_CODE)
     {
-        psBits->dataBitPos += 32;
+        //DV: this is the wrong way to skip bits, use FLush or Read psBits->dataBitPos += 32;
+        ReadBits(psBits, 32, &codeword); // skip 32 bits of the Start code
 
         ReadBits(psBits, 8, &codeword);
 
+        // record profile and level
+        *profilelevel = (int) codeword;
+
         ShowBits(psBits, 32, &codeword);
         if (codeword == USER_DATA_START_CODE)
         {
@@ -240,17 +251,18 @@
             }
         }
 decode_vol:
-        /* vol_id (4 bits) */
-        ReadBits(psBits, 4, & codeword);
 
+        uint32 vol_id;
+
+        /* vol_id (4 bits) */
+        ReadBits(psBits, 4, & vol_id);
 
         // RandomAccessibleVOLFlag
         ReadBits(psBits, 1, &codeword);
 
-
         //Video Object Type Indication
         ReadBits(psBits, 8, &codeword);
-        if (codeword > 2)
+        if (codeword != 1)
         {
             return MP4_INVALID_VOL_PARAM;
         }
@@ -366,14 +378,14 @@
 
         /* this should be 176 for QCIF */
         ReadBits(psBits, 13, &codeword);
-        *display_width = (int)codeword;
+        *display_width = (int32)codeword;
         ReadBits(psBits, 1, &codeword);
         if (codeword != 1)
             return MP4_INVALID_VOL_PARAM;
 
         /* this should be 144 for QCIF */
         ReadBits(psBits, 13, &codeword);
-        *display_height = (int)codeword;
+        *display_height = (int32)codeword;
 
         *width = (*display_width + 15) & -16;
         *height = (*display_height + 15) & -16;
@@ -409,15 +421,15 @@
 
 OSCL_EXPORT_REF
 int16 iDecodeShortHeader(mp4StreamType *psBits,
-                         int *width,
-                         int *height,
-                         int *display_width,
-                         int *display_height)
+                         int32 *width,
+                         int32 *height,
+                         int32 *display_width,
+                         int32 *display_height)
 {
     uint32 codeword;
-    int	extended_PTYPE = 0;
-    int UFEP = 0;
-    int custom_PFMT = 0;
+    int32	extended_PTYPE = 0;
+    int32 UFEP = 0;
+    int32 custom_PFMT = 0;
 
     ShowBits(psBits, 22, &codeword);
 
@@ -752,7 +764,7 @@
 
     while (codeword != 1)
     {
-        /* Discard user data for now.  CJ 04/05/2000 */
+        /* Discard user data for now. */
         iErrorStat = ReadBits(pStream, 8, &codeword);
         if (iErrorStat) return iErrorStat;
         iErrorStat = ShowBits(pStream, 24, &codeword);
@@ -762,22 +774,23 @@
 }
 
 
-OSCL_EXPORT_REF int16 iGetAVCConfigInfo(uint8 *buffer, int length, int *width, int *height, int *display_width, int *display_height)
+OSCL_EXPORT_REF int16 iGetAVCConfigInfo(uint8 *buffer, int32 length, int32 *width, int32 *height, int32 *display_width, int32 *display_height, int32 *profile_idc, int32 *level_idc)
 {
     int16 status;
     mp4StreamType psBits;
-    uint16 sps_length;
-    int size;
-    int i = 0;
-    uint8* nal_unit = buffer;
-    uint8* temp_ptr = NULL;
+    uint16 sps_length, pps_length;
+    int32 size;
+    int32 i = 0;
+    uint8* sps = NULL;
     uint8* temp = (uint8 *)OSCL_MALLOC(sizeof(uint8) * length);
+    uint8* pps = NULL;
+
 
     if (temp)
     {
-        temp_ptr = temp; // Make a copy of the original pointer to be freed later
+        sps = temp; // Make a copy of the original pointer to be freed later
         // Successfull allocation... copy input buffer
-        oscl_memcpy(temp, buffer, length);
+        oscl_memcpy(sps, buffer, length);
     }
     else
     {
@@ -785,96 +798,100 @@
         return MP4_INVALID_VOL_PARAM;
     }
 
+    if (length < 3)
+    {
+        OSCL_FREE(temp);
+        return MP4_INVALID_VOL_PARAM;
+    }
+
     *width = *height = *display_height = *display_width = 0;
 
-    if (temp[0] == 0 && temp[1] == 0)
+    if (sps[0] == 0 && sps[1] == 0)
     {
         /* find SC at the beginning of the NAL */
-        while (nal_unit[i++] == 0 && i < length)
+        while (sps[i++] == 0 && i < length)
         {
         }
 
-        if (nal_unit[i-1] == 1)
+        if (sps[i-1] == 1)
         {
-            temp = nal_unit + i;
+            sps += i;
+
+            sps_length = 0;
+            // search for the next start code
+            while (!(sps[sps_length] == 0 && sps[sps_length+1] == 0 && sps[sps_length+2] == 1) &&
+                    sps_length < length - i - 2)
+            {
+                sps_length++;
+            }
+
+            if (sps_length >= length - i - 2)
+            {
+                OSCL_FREE(temp);
+                return MP4_INVALID_VOL_PARAM;
+            }
+
+            pps_length = length - i - sps_length - 3;
+            pps = sps + sps_length + 3;
         }
         else
         {
-            if (temp_ptr)
-            {
-                OSCL_FREE(temp_ptr);
-            }
+            OSCL_FREE(temp);
             return MP4_INVALID_VOL_PARAM;
         }
-
-        sps_length = length - i;
     }
     else
     {
-        sps_length = (uint16)(temp[1] << 8) | temp[0];
-        temp += 2;
+        sps_length = (uint16)(sps[1] << 8) | sps[0];
+        sps += 2;
+        pps = sps + sps_length;
+        pps_length = (uint16)(pps[1] << 8) | pps[0];
+        pps += 2;
     }
 
-    if (sps_length > length)
+    if (sps_length + pps_length > length)
     {
-        if (temp_ptr)
-        {
-            OSCL_FREE(temp_ptr);
-        }
+        OSCL_FREE(temp);
         return MP4_INVALID_VOL_PARAM;
     }
 
     size = sps_length;
 
-#if 0
-// FLAGG
-    uint32 ii = 0;
-    uint32 count = size;
-    printf("iGetAVCConfigInfo() before size %d\n", size);
-    for (ii = 0; ii < count; ii++)
-    {
-        printf("%02x ", temp[ii]);
-        if ((ii + 1) % 16 == 0)
-        {
-            printf("\n");
-        }
-    }
-    printf("\n");
-#endif
+    Parser_EBSPtoRBSP(sps, &size);
 
-    Parser_EBSPtoRBSP(temp, &size);
-
-#if 0
-    ii = 0;
-    count = size;
-    printf("iGetAVCConfigInfo() after size %d\n", size);
-    for (ii = 0; ii < count; ii++)
-    {
-        printf("%02x ", temp[ii]);
-        if ((ii + 1) % 16 == 0)
-        {
-            printf("\n");
-        }
-    }
-    printf("\n");
-#endif
-
-    psBits.data = temp;
+    psBits.data = sps;
     psBits.numBytes = size;
     psBits.bitBuf = 0;
     psBits.bitPos = 32;
     psBits.bytePos = 0;
     psBits.dataBitPos = 0;
 
-    status = DecodeSPS(&psBits, width, height, display_width, display_height);
-    if (temp_ptr)
+    if (DecodeSPS(&psBits, width, height, display_width, display_height, profile_idc, level_idc))
     {
-        OSCL_FREE(temp_ptr);
+        OSCL_FREE(temp);
+        return MP4_INVALID_VOL_PARAM;
     }
+
+    // now do PPS
+    size = pps_length;
+
+    Parser_EBSPtoRBSP(pps, &size);
+    psBits.data = pps;
+    psBits.numBytes = size;
+    psBits.bitBuf = 0;
+    psBits.bitPos = 32;
+    psBits.bytePos = 0;
+    psBits.dataBitPos = 0;
+
+    status = DecodePPS(&psBits);
+
+    OSCL_FREE(temp);
+
     return status;
 }
 
-int16 DecodeSPS(mp4StreamType *psBits, int *width, int *height, int *display_width, int *display_height)
+
+int16 DecodeSPS(mp4StreamType *psBits, int32 *width, int32 *height, int32 *display_width, int32 *display_height, int32 *profile_idc, int32 *level_idc)
 {
     uint32 temp;
     int32 temp0;
@@ -883,18 +900,25 @@
 
     ReadBits(psBits, 8, &temp);
 
+
+
     if ((temp & 0x1F) != 7) return MP4_INVALID_VOL_PARAM;
 
     ReadBits(psBits, 8, &temp);
+
+    *profile_idc = temp;
+
     ReadBits(psBits, 1, &temp);
     ReadBits(psBits, 1, &temp);
     ReadBits(psBits, 1, &temp);
     ReadBits(psBits, 5, &temp);
     ReadBits(psBits, 8, &temp);
+
+    *level_idc = temp;
+
     if (temp > 51)
         return MP4_INVALID_VOL_PARAM;
 
-
     ue_v(psBits, &temp);
     ue_v(psBits, &temp);
     ue_v(psBits, &temp);
@@ -925,15 +949,14 @@
     *display_height = *height = (temp + 1) << 4;
 
 
-
     ReadBits(psBits, 1, &temp);
-
     if (!temp)
     {
-        ReadBits(psBits, 1, &temp);
+        // we do not support if frame_mb_only_flag is off
+        return MP4_INVALID_VOL_PARAM;
+        //ReadBits(psBits,1, &temp);
     }
 
-
     ReadBits(psBits, 1, &temp);
 
     ReadBits(psBits, 1, &temp);
@@ -948,6 +971,163 @@
         *display_width = *width - 2 * (right_offset + left_offset);
         *display_height = *height - 2 * (top_offset + bottom_offset);
     }
+
+    /*	no need to check further */
+#if USE_LATER
+    ReadBits(psBits, 1, &temp);
+    if (temp)
+    {
+        if (!DecodeVUI(psBits))
+        {
+            return MP4_INVALID_VOL_PARAM;
+        }
+    }
+#endif
+    return 0; // return 0 for success
+}
+
+#if USE_LATER
+/* unused for now */
+int32 DecodeVUI(mp4StreamType *psBits)
+{
+    uint temp;
+    uint32 temp32;
+    uint aspect_ratio_idc, overscan_appopriate_flag, video_format, video_full_range_flag;
+    int32 status;
+
+    ReadBits(psBits, 1, &temp); /* aspect_ratio_info_present_flag */
+    if (temp)
+    {
+        ReadBits(psBits, 8, &aspect_ratio_idc);
+        if (aspect_ratio_idc == 255)
+        {
+            ReadBits(psBits, 16, &temp); /* sar_width */
+            ReadBits(psBits, 16, &temp); /* sar_height */
+        }
+    }
+    ReadBits(psBits, 1, &temp); /* overscan_info_present */
+    if (temp)
+    {
+        ReadBits(psBits, 1, &overscan_appopriate_flag);
+    }
+    ReadBits(psBits, 1, &temp); /* video_signal_type_present_flag */
+    if (temp)
+    {
+        ReadBits(psBits, 3, &video_format);
+        ReadBits(psBits, 1, &video_full_range_flag);
+        ReadBits(psBits, 1, &temp); /* colour_description_present_flag */
+        if (temp)
+        {
+            ReadBits(psBits, 8, &temp); /* colour_primaries */
+            ReadBits(psBits, 8, &temp); /* transfer_characteristics */
+            ReadBits(psBits, 8, &temp); /* matrix coefficients */
+        }
+    }
+    ReadBits(psBits, 1, &temp);/*	chroma_loc_info_present_flag */
+    if (temp)
+    {
+        ue_v(psBits, &temp); /*  chroma_sample_loc_type_top_field */
+        ue_v(psBits, &temp); /*  chroma_sample_loc_type_bottom_field */
+    }
+
+    ReadBits(psBits, 1, &temp); /*	timing_info_present_flag*/
+    if (temp)
+    {
+        ReadBits(psBits, 32, &temp32); /*  num_unit_in_tick*/
+        ReadBits(psBits, 32, &temp32); /*	time_scale */
+        ReadBits(psBits, 1, &temp); /*	fixed_frame_rate_flag */
+    }
+
+    ReadBits(psBits, 1, &temp); /*	nal_hrd_parameters_present_flag */
+    if (temp)
+    {
+        if (!DecodeHRD(psBits))
+        {
+            return 1;
+        }
+    }
+    ReadBits(psBits, 1, &temp32); /*	vcl_hrd_parameters_present_flag*/
+    if (temp32)
+    {
+        if (!DecodeHRD(psBits))
+        {
+            return 1;
+        }
+    }
+    if (temp || temp32)
+    {
+        ReadBits(psBits, 1, &temp);		/*	low_delay_hrd_flag */
+    }
+    ReadBits(psBits, 1, &temp); /*	pic_struct_present_flag */
+    status = ReadBits(psBits, 1, &temp); /*	_restriction_flag */
+    if (status != 0) // buffer overrun
+    {
+        return 1;
+    }
+
+    if (temp)
+    {
+        ReadBits(psBits, 1, &temp); /*	motion_vectors_over_pic_boundaries_flag */
+        ue_v(psBits, &temp); /*	max_bytes_per_pic_denom */
+        ue_v(psBits, &temp); /*	max_bits_per_mb_denom */
+        ue_v(psBits, &temp); /*	log2_max_mv_length_horizontal */
+        ue_v(psBits, &temp); /*	log2_max_mv_length_vertical */
+        ue_v(psBits, &temp); /*	num_reorder_frames */
+        ue_v(psBits, &temp); /*	max_dec_frame_buffering */
+    }
+
+    return 0; // 0 for success
+}
+
+/* unused for now */
+int32 DecodeHRD(mp4StreamType *psBits)
+{
+    uint temp;
+    uint cpb_cnt_minus1;
+    uint i;
+    int32 status;
+
+    ue_v(psBits, &cpb_cnt_minus1);
+    ReadBits(psBits, 4, &temp); /*	bit_rate_scale */
+    ReadBits(psBits, 4, &temp); /*	cpb_size_scale */
+    for (i = 0; i <= cpb_cnt_minus1; i++)
+    {
+        ue_v(psBits, &temp); /*	bit_rate_value_minus1[i] */
+        ue_v(psBits, &temp); /*	cpb_size_value_minus1[i] */
+        ue_v(psBits, &temp); /*	cbr_flag[i] */
+    }
+    ReadBits(psBits, 5, &temp); /*	initial_cpb_removal_delay_length_minus1 */
+    ReadBits(psBits, 5, &temp); /*	cpb_removal_delay_length_minus1 */
+    ReadBits(psBits, 5, &temp); /*	dpb_output_delay_length_minus1 */
+    status = ReadBits(psBits, 5, &temp); /*	time_offset_length	*/
+
+    if (status != 0) // buffer overrun
+    {
+        return 1;
+    }
+
+    return 0; // 0 for success
+}
+#endif
+
+// only check for entropy coding mode
+int32 DecodePPS(mp4StreamType *psBits)
+{
+    uint32 temp, pic_parameter_set_id, seq_parameter_set_id, entropy_coding_mode_flag;
+
+    ReadBits(psBits, 8, &temp);
+
+    if ((temp & 0x1F) != 8) return MP4_INVALID_VOL_PARAM;
+
+    ue_v(psBits, &pic_parameter_set_id);
+    ue_v(psBits, &seq_parameter_set_id);
+
+    ReadBits(psBits, 1, &entropy_coding_mode_flag);
+    if (entropy_coding_mode_flag)
+    {
+        return 1;
+    }
+
     return 0;
 }
 
@@ -955,7 +1135,7 @@
 {
     uint32 temp;
     uint tmp_cnt;
-    int leading_zeros = 0;
+    int32 leading_zeros = 0;
     ShowBits(psBits, 16, &temp);
     tmp_cnt = temp  | 0x1;
 
@@ -977,7 +1157,7 @@
 
 void se_v(mp4StreamType *psBits, int32 *value)
 {
-    int leadingZeros = 0;
+    int32 leadingZeros = 0;
     uint32 temp;
 
     OSCL_UNUSED_ARG(value);
@@ -994,10 +1174,10 @@
     ReadBits(psBits, leadingZeros, &temp);
 }
 
-void Parser_EBSPtoRBSP(uint8 *nal_unit, int *size)
+void Parser_EBSPtoRBSP(uint8 *nal_unit, int32 *size)
 {
-    int i, j;
-    int count = 0;
+    int32 i, j;
+    int32 count = 0;
 
 
     for (i = 0; i < *size; i++)
diff --git a/codecs_v2/utilities/pv_config_parser/Android.mk b/codecs_v2/utilities/pv_config_parser/Android.mk
new file mode 100644
index 0000000..356a4a8
--- /dev/null
+++ b/codecs_v2/utilities/pv_config_parser/Android.mk
@@ -0,0 +1,31 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pv_video_config_parser.cpp \
+ 	src/pv_audio_config_parser.cpp
+
+
+LOCAL_MODULE := libpv_config_parser
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+LOCAL_ARM_MODE := arm
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/utilities/pv_config_parser/src \
+ 	$(PV_TOP)/codecs_v2/utilities/pv_config_parser/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pv_video_config_parser.h \
+ 	include/pv_audio_config_parser.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/codecs_v2/utilities/pv_config_parser/build/make/local.mk b/codecs_v2/utilities/pv_config_parser/build/make/local.mk
new file mode 100644
index 0000000..65d684a
--- /dev/null
+++ b/codecs_v2/utilities/pv_config_parser/build/make/local.mk
@@ -0,0 +1,27 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv_config_parser
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XINCDIRS = ../../../../../pvmi/pvmf/include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_video_config_parser.cpp \
+	pv_audio_config_parser.cpp
+
+HDRS := pv_video_config_parser.h \
+	pv_audio_config_parser.h
+
+include $(MK)/library.mk
diff --git a/codecs_v2/utilities/pv_config_parser/include/pv_audio_config_parser.h b/codecs_v2/utilities/pv_config_parser/include/pv_audio_config_parser.h
new file mode 100644
index 0000000..204d7b8
--- /dev/null
+++ b/codecs_v2/utilities/pv_config_parser/include/pv_audio_config_parser.h
@@ -0,0 +1,46 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_AUDIO_CONFIG_PARSER_H_INCLUDED
+#define PV_AUDIO_CONFIG_PARSER_H_INCLUDED
+
+#include "oscl_base.h"
+#include "oscl_types.h"
+#include "pvmf_format_type.h"
+
+typedef struct
+{
+    uint8* inPtr;
+    uint32 inBytes;
+    PVMFFormatType iMimeType;
+} pvAudioConfigParserInputs;
+
+
+typedef struct
+{
+    uint16 Channels;
+    uint16 BitsPerSample;
+    uint32 SamplesPerSec;
+} pvAudioConfigParserOutputs;
+
+
+OSCL_IMPORT_REF int32 pv_audio_config_parser(pvAudioConfigParserInputs *aInputs, pvAudioConfigParserOutputs *aOutputs);
+
+
+#endif //PV_AUDIO_CONFIG_PARSER_H_INCLUDED
+
+
diff --git a/codecs_v2/utilities/pv_config_parser/include/pv_video_config_parser.h b/codecs_v2/utilities/pv_config_parser/include/pv_video_config_parser.h
new file mode 100644
index 0000000..022b8b3
--- /dev/null
+++ b/codecs_v2/utilities/pv_config_parser/include/pv_video_config_parser.h
@@ -0,0 +1,45 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_VIDEO_CONFIG_PARSER_H_INCLUDED
+#define PV_VIDEO_CONFIG_PARSER_H_INCLUDED
+
+#include "oscl_base.h"
+#include "oscl_types.h"
+#include "pvmf_format_type.h"
+
+typedef struct
+{
+    uint8 *inPtr;
+    uint32 inBytes;
+    PVMFFormatType iMimeType;
+} pvVideoConfigParserInputs;
+
+typedef struct
+{
+    uint32 width;
+    uint32 height;
+    uint32 profile;
+    uint32 level;
+} pvVideoConfigParserOutputs;
+
+OSCL_IMPORT_REF int16 pv_video_config_parser(pvVideoConfigParserInputs *aInputs, pvVideoConfigParserOutputs *aOutputs);
+
+
+#endif //PV_VIDEO_CONFIG_PARSER_H_INCLUDED
+
+
diff --git a/codecs_v2/utilities/pv_config_parser/src/pv_audio_config_parser.cpp b/codecs_v2/utilities/pv_config_parser/src/pv_audio_config_parser.cpp
new file mode 100644
index 0000000..7c51374
--- /dev/null
+++ b/codecs_v2/utilities/pv_config_parser/src/pv_audio_config_parser.cpp
@@ -0,0 +1,392 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "pv_audio_config_parser.h"
+#include "oscl_mem.h"
+#include "getactualaacconfig.h"
+
+
+#include "oscl_dll.h"
+
+//Macros for WMA
+#define GetUnalignedWord( pb, w ) \
+            (w) = ((uint16) *(pb + 1) << 8) + *pb;
+
+#define GetUnalignedDword( pb, dw ) \
+            (dw) = ((uint32) *(pb + 3) << 24) + \
+                   ((uint32) *(pb + 2) << 16) + \
+                   ((uint16) *(pb + 1) << 8) + *pb;
+
+#define GetUnalignedWordEx( pb, w )     GetUnalignedWord( pb, w ); (pb) += sizeof(uint16);
+#define GetUnalignedDwordEx( pb, dw )   GetUnalignedDword( pb, dw ); (pb) += sizeof(uint32);
+
+#define LoadWORD( w, p )    GetUnalignedWordEx( p, w )
+#define LoadDWORD( dw, p )  GetUnalignedDwordEx( p, dw )
+
+
+#define WAVE_FORMAT_MSAUDIO1  0x0160
+#define WAVE_FORMAT_WMAUDIO2  0x0161
+#define WAVE_FORMAT_WMAUDIO3  0x0162
+#define WAVE_FORMAT_WMAUDIO_LOSSLESS  0x0163
+#define WAVE_FORMAT_WMAUDIO2_ES  0x0165
+#define WAVE_FORMAT_WMASPDIF 0x164
+#define WAVE_FORMAT_WMAUDIO3_ES  0x0166
+#define WAVE_FORMAT_WMAUDIO_LOSSLESS_ES  0x0167
+
+#define WAVE_FORMAT_MSSPEECH  10
+
+//AdvancedEncodeOpt
+#define ENCOPT4_PLUSVER   0xe000
+#define ENCOPT4_PLUSV1    0xc000
+#define ENCOPT4_PLUSV1ALT 0x8000
+#define ENCOPT4_PLUSV2    0x2000
+#define ENCOPT4_PLUSV3    0x4000
+
+//The following is from \codecs_v2\wma\dec\src\macros.h
+//-------------------------------------------------------------------------------------
+//If no build is defined in the pre-processor definitions, then code for all supported wma formats will be included
+#if !defined(BUILD_WMASTD) && !defined(BUILD_WMAPRO) && !defined(BUILD_WMALSL) && !defined(BUILD_WMAPROPLUS)
+#define BUILD_WMASTD
+#define BUILD_WMAPRO
+#define BUILD_WMAPROPLUS
+//#define BUILD_WMAPRO_PLLM
+//#define BUILD_WMALSL
+#endif // !BUILD_WMASTD && !BUILD_WMAPRO && !BUILD_WMAPROPLUS && !BUILD_WMALSL
+
+#if defined(BUILD_WMAPROPLUS) && !defined(BUILD_WMAPRO)
+#define BUILD_WMAPRO
+#endif
+
+#if defined(BUILD_WMAPRO) && !defined(BUILD_WMAPROPLUS)
+#define BUILD_WMAPROPLUS
+#endif
+//-------------------------------------------------------------------------------------
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
+// This routine parses the wma config header and returns Sampling Rate, Number of Channels, and Bits Per Sample
+OSCL_EXPORT_REF int32 pv_audio_config_parser(pvAudioConfigParserInputs *aInputs, pvAudioConfigParserOutputs *aOutputs)
+{
+    bool bBitStreamValid = true;
+    bool bBitStreamSupported = true;
+
+    if (aInputs->iMimeType == PVMF_MIME_WMA)
+    {
+        uint16 wdata;
+        uint32 dwdata;
+        uint32 AvgBytesPerSec;
+        uint16 AdvancedEncodeOpt;
+
+        /**** decoder header *******/
+        uint8* tp = aInputs->inPtr;
+        LoadWORD(wdata , tp);
+
+        switch (wdata)
+        {
+                // WMA Lossless
+            case WAVE_FORMAT_WMAUDIO_LOSSLESS:
+            {
+                if (aInputs->inBytes < 36)
+                {
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                LoadWORD(wdata, tp);
+                aOutputs->Channels        = wdata;
+                LoadDWORD(dwdata, tp);
+                aOutputs->SamplesPerSec   = dwdata;
+                LoadDWORD(dwdata, tp);
+                AvgBytesPerSec  = dwdata;
+
+                tp = aInputs->inPtr + 14;
+                LoadWORD(wdata , tp);
+                // Round up to the byte to get the container size
+                aOutputs->BitsPerSample = 8 * ((wdata + 7) / 8);
+
+                // Has V3 specific info
+                tp = aInputs->inPtr + 34;
+                LoadWORD(wdata , tp);
+                AdvancedEncodeOpt = wdata;
+
+#if !defined(BUILD_WMALSL)
+                bBitStreamSupported = false;
+#endif	// BUILD_WMALSL	
+
+                // more limits according to the current PV WMA implementation
+                // do not supoprt multi-channel
+                if (aOutputs->Channels > 2)
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+
+                // do not support 24-bit
+                if	(aOutputs->BitsPerSample > 16)
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+            }
+            break;
+
+            // WMA Pro, Pro+
+            case WAVE_FORMAT_WMAUDIO3:
+            {
+                if (aInputs->inBytes < 36)
+                {
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                LoadWORD(wdata, tp);
+                aOutputs->Channels        = wdata;
+                LoadDWORD(dwdata, tp);
+                aOutputs->SamplesPerSec   = dwdata;
+                LoadDWORD(dwdata, tp);
+                AvgBytesPerSec  = dwdata;
+
+                tp = aInputs->inPtr + 14;
+                LoadWORD(wdata , tp);	//iValidBitsPerSample
+                // Round up to the byte to get the container size
+                aOutputs->BitsPerSample = 8 * ((wdata + 7) / 8);
+
+                // Has V3 specific info
+                tp = aInputs->inPtr + 34;
+                LoadWORD(wdata , tp);
+                AdvancedEncodeOpt = wdata;
+
+#if !defined(BUILD_WMAPRO)
+                bBitStreamSupported = false;
+                break;
+#endif	// BUILD_WMAPRO
+
+#if !defined(BUILD_WMAPROPLUS)
+                if (0 != (AdvancedEncodeOpt & ENCOPT4_PLUSVER))
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+#endif	// BUILD_WMAPROPLUS
+
+                // more limits according to the current PV WMA implementation
+                // do not supoprt multi-channel
+                if (aOutputs->Channels > 2)
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+
+                // do not support 24-bit
+                if	(aOutputs->BitsPerSample > 16)
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+
+#if defined(WMAPLUS_64KBPS_PROFILE_ONLY)
+                // limit to M0-profile bitrate and sampling rate
+                if (AvgBytesPerSec > 192000 || aOutputs->SamplesPerSec > 48000)
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+
+                // only decode PLUSV1 (not including PLUSV1ALT)
+                if	(ENCOPT4_PLUSV1 != (AdvancedEncodeOpt & ENCOPT4_PLUSVER))
+                {
+                    bBitStreamSupported = false;
+                    break;
+                }
+#endif // WMAPLUS_64KBPS_PROFILE_ONLY
+            }
+            break;
+
+            //WMA Standard
+            case WAVE_FORMAT_WMAUDIO2:
+            {
+                if (aInputs->inBytes < 28)
+                {
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                LoadWORD(wdata, tp);
+                aOutputs->Channels        = wdata;
+                LoadDWORD(dwdata, tp);
+                aOutputs->SamplesPerSec   = dwdata;
+
+                tp = aInputs->inPtr + 14;
+                LoadWORD(wdata , tp);
+                aOutputs->BitsPerSample = wdata;
+
+                if (aOutputs->SamplesPerSec > 48000)
+                {
+                    // not a valid sample rate for WMA Std spec
+                    bBitStreamValid = false;
+                    break;
+                }
+                if (aOutputs->Channels > 2)
+                {
+                    // not a valid number of channels for the WMA Std spec
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                if (aOutputs->BitsPerSample != 16)
+                {
+                    // not a valid number of bits per sample for the WMA Std spec
+                    bBitStreamValid = false;
+                    break;
+                }
+
+#if !defined(BUILD_WMASTD)
+                bBitStreamSupported = false;
+#endif // BUILD_WMASTD
+            }
+            break;
+
+            //WMA Standard (bitstream v1)
+            case WAVE_FORMAT_MSAUDIO1:
+            {
+                if (aInputs->inBytes < 22)
+                {
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                tp = aInputs->inPtr +  4;
+                LoadDWORD(dwdata, tp);
+                aOutputs->SamplesPerSec = dwdata;
+                tp = aInputs->inPtr +  2;
+                LoadWORD(wdata , tp);
+                aOutputs->Channels = wdata;
+
+                tp = aInputs->inPtr + 14;
+                LoadWORD(wdata , tp);
+                aOutputs->BitsPerSample = wdata;
+
+                if (aOutputs->SamplesPerSec > 48000)
+                {
+                    // not a valid sample rate for WMA Std spec
+                    bBitStreamValid = false;
+                    break;
+                }
+                if (aOutputs->Channels > 2)
+                {
+                    // not a valid number of channels for the WMA Std spec
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                if (aOutputs->BitsPerSample != 16)
+                {
+                    // not a valid number of bits per sample for the WMA Std spec
+                    bBitStreamValid = false;
+                    break;
+                }
+
+#if !defined(BUILD_WMASTD)
+                bBitStreamSupported = false;
+#endif // BUILD_WMASTD
+            }
+            break;
+
+            // WMA Voice
+            case WAVE_FORMAT_MSSPEECH:
+            {
+                if (aInputs->inBytes < 18)
+                {
+                    bBitStreamValid = false;
+                    break;
+                }
+
+                tp = aInputs->inPtr +  4;
+                LoadDWORD(dwdata, tp);
+                aOutputs->SamplesPerSec  = dwdata;
+                tp = aInputs->inPtr +  8;
+                LoadDWORD(dwdata, tp);
+                //AvgBytesPerSec = dwdata;
+                tp = aInputs->inPtr + 12;
+                LoadWORD(wdata , tp);
+                //BlockAlign     = wdata;
+                tp = aInputs->inPtr +  2;
+                LoadWORD(wdata , tp);
+                aOutputs->Channels       = wdata;
+                tp = aInputs->inPtr +  14;
+                LoadWORD(wdata , tp);
+                aOutputs->BitsPerSample  = wdata;
+
+#if !defined(BUILD_WMAVOICE)
+                bBitStreamSupported = false;
+#endif // BUILD_WMAVOICE
+            }
+            break;
+
+            case WAVE_FORMAT_WMASPDIF:
+            case WAVE_FORMAT_WMAUDIO2_ES:
+            case WAVE_FORMAT_WMAUDIO3_ES:
+            case WAVE_FORMAT_WMAUDIO_LOSSLESS_ES:
+            {
+                // these formats aren't supported
+                bBitStreamSupported = false;
+            }
+            break;
+
+            default:
+            {
+                // invalid wma format
+                bBitStreamValid = false;
+            }
+        }
+    }
+    else if (aInputs->iMimeType == PVMF_MIME_MPEG4_AUDIO || // AAC
+             aInputs->iMimeType == PVMF_MIME_LATM ||
+             aInputs->iMimeType == PVMF_MIME_ADIF ||
+             aInputs->iMimeType == PVMF_MIME_ASF_MPEG4_AUDIO ||
+             aInputs->iMimeType == PVMF_MIME_AAC_SIZEHDR)
+    {
+        int32   bytes_consumed, status;
+        uint8   aAudioObjectType, SamplingRateIndex;
+        uint32  NumChannels;
+
+        bytes_consumed = (int32)aInputs->inBytes;
+
+        status = GetActualAacConfig(aInputs->inPtr,
+                                    &aAudioObjectType,
+                                    &bytes_consumed,
+                                    &SamplingRateIndex,
+                                    &NumChannels);
+
+        aOutputs->Channels = (uint16)NumChannels;
+        if (aOutputs->Channels > 2)
+        {
+            // not a valid number of channels for the AAC
+            bBitStreamValid = false;
+        }
+
+    }
+
+    if (!bBitStreamValid)
+    {
+        bBitStreamSupported = false;
+    }
+
+    return (bBitStreamSupported ? 1 : 0);
+}
diff --git a/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp b/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp
new file mode 100644
index 0000000..10b424d
--- /dev/null
+++ b/codecs_v2/utilities/pv_config_parser/src/pv_video_config_parser.cpp
@@ -0,0 +1,288 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "pv_video_config_parser.h"
+#include "m4v_config_parser.h"
+#include "oscl_mem.h"
+
+#include "oscl_dll.h"
+
+#define GetUnalignedWord( pb, w ) \
+            (w) = ((uint16) *(pb + 1) << 8) + *pb;
+
+#define GetUnalignedDword( pb, dw ) \
+            (dw) = ((uint32) *(pb + 3) << 24) + \
+                   ((uint32) *(pb + 2) << 16) + \
+                   ((uint16) *(pb + 1) << 8) + *pb;
+
+#define GetUnalignedWordEx( pb, w )     GetUnalignedWord( pb, w ); (pb) += sizeof(uint16);
+#define GetUnalignedDwordEx( pb, dw )   GetUnalignedDword( pb, dw ); (pb) += sizeof(uint32);
+#define GetUnalignedQwordEx( pb, qw )   GetUnalignedQword( pb, qw ); (pb) += sizeof(uint64);
+
+#define LoadBYTE( b, p )    b = *(uint8 *)p;  p += sizeof( uint8 )
+
+#define LoadWORD( w, p )    GetUnalignedWordEx( p, w )
+#define LoadDWORD( dw, p )  GetUnalignedDwordEx( p, dw )
+#define LoadQWORD( qw, p )  GetUnalignedQwordEx( p, qw )
+
+#ifndef MAKEFOURCC_WMC
+#define MAKEFOURCC_WMC(ch0, ch1, ch2, ch3) \
+        ((uint32)(uint8)(ch0) | ((uint32)(uint8)(ch1) << 8) |   \
+        ((uint32)(uint8)(ch2) << 16) | ((uint32)(uint8)(ch3) << 24 ))
+
+#define mmioFOURCC_WMC(ch0, ch1, ch2, ch3)  MAKEFOURCC_WMC(ch0, ch1, ch2, ch3)
+#endif
+
+#define FOURCC_WMV2     mmioFOURCC_WMC('W','M','V','2')
+#define FOURCC_WMV3     mmioFOURCC_WMC('W','M','V','3')
+#define FOURCC_WMVA		mmioFOURCC_WMC('W','M','V','A')
+#define FOURCC_WVC1		mmioFOURCC_WMC('W','V','C','1')
+//For WMVA
+#define ASFBINDING_SIZE                   1   // size of ASFBINDING is 1 byte
+#define FOURCC_MP42		mmioFOURCC_WMC('M','P','4','2')
+#define FOURCC_MP43		mmioFOURCC_WMC('M','P','4','3')
+#define FOURCC_mp42		mmioFOURCC_WMC('m','p','4','2')
+#define FOURCC_mp43		mmioFOURCC_WMC('m','p','4','3')
+
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+int32 GetNAL_Config(uint8** bitstream, int32* size);
+
+OSCL_EXPORT_REF int16 pv_video_config_parser(pvVideoConfigParserInputs *aInputs, pvVideoConfigParserOutputs *aOutputs)
+{
+    if (aInputs->iMimeType == PVMF_MIME_M4V) //m4v
+    {
+        mp4StreamType psBits;
+        psBits.data = aInputs->inPtr;
+        if (aInputs->inBytes <= 0)
+        {
+            return -1;
+        }
+        psBits.numBytes = aInputs->inBytes;
+        psBits.bytePos = 0;
+        psBits.bitBuf = 0;
+        psBits.dataBitPos = 0;
+        psBits.bitPos = 32;
+
+        int32 width, height, display_width, display_height = 0;
+        int32 profile_level = 0;
+        int16 retval = 0;
+        retval = iDecodeVOLHeader(&psBits, &width, &height, &display_width, &display_height, &profile_level);
+        if (retval != 0)
+        {
+            return retval;
+        }
+        aOutputs->width  = (uint32)display_width;
+        aOutputs->height = (uint32)display_height;
+        aOutputs->profile = (uint32)profile_level; // for mp4, profile/level info is packed
+        aOutputs->level = 0;
+    }
+    else if (aInputs->iMimeType == PVMF_MIME_H2631998 ||
+             aInputs->iMimeType == PVMF_MIME_H2632000)//h263
+    {
+        // Nothing to do for h263
+        aOutputs->width  = 0;
+        aOutputs->height = 0;
+        aOutputs->profile = 0;
+        aOutputs->level = 0;
+    }
+    else if (aInputs->iMimeType == PVMF_MIME_H264_VIDEO ||
+             aInputs->iMimeType == PVMF_MIME_H264_VIDEO_MP4) //avc
+    {
+        int32 width, height, display_width, display_height = 0;
+        int32 profile_idc, level_idc = 0;
+
+        uint8 *tp = aInputs->inPtr;
+
+        if (aInputs->inBytes > 1)
+        {
+            if (tp[0] == 0 && tp[1] == 0)
+            {
+                // ByteStream Format
+                uint8* tmp_ptr = tp;
+                uint8* buffer_begin = tp;
+                int16 length = 0;
+                int initbufsize = aInputs->inBytes;
+                int tConfigSize = 0;
+                do
+                {
+                    tmp_ptr += length;
+                    length = GetNAL_Config(&tmp_ptr, &initbufsize);
+                    buffer_begin[0] = length & 0xFF;
+                    buffer_begin[1] = (length >> 8) & 0xFF;
+                    oscl_memcpy(buffer_begin + 2, tmp_ptr, length);
+                    buffer_begin += (length + 2);
+                    tConfigSize += (length + 2);
+                }
+                while (initbufsize > 0);
+            }
+        }
+
+        // check codec info and get settings
+        int16 retval;
+        retval = iGetAVCConfigInfo(tp,
+                                   aInputs->inBytes,
+                                   (int*) & width,
+                                   (int*) & height,
+                                   (int*) & display_width,
+                                   (int*) & display_height,
+                                   (int*) & profile_idc,
+                                   (int*) & level_idc);
+        if (retval != 0)
+        {
+            return retval;
+        }
+        aOutputs->width  = (uint32)display_width;
+        aOutputs->height = (uint32)display_height;
+        aOutputs->profile = (uint32)profile_idc;
+        aOutputs->level = (uint32) level_idc;
+    }
+    else if (aInputs->iMimeType == PVMF_MIME_WMV) //wmv
+    {
+        uint32 dwdat;
+        uint16 wdat;
+        uint8 bdat;
+        uint8 *pData = aInputs->inPtr;
+
+        LoadDWORD(dwdat, pData); // Window width
+        LoadDWORD(dwdat, pData); // Window height
+        LoadBYTE(bdat, pData);
+        LoadWORD(wdat, pData);  // Size of image info.
+
+        // BITMAPINFOHEADER
+        LoadDWORD(dwdat, pData); // Size of BMAPINFOHDR
+        LoadDWORD(dwdat, pData);
+        aOutputs->width = dwdat;
+        LoadDWORD(dwdat, pData);
+        aOutputs->height = dwdat;
+
+        /* WMV1 and WMV2 are not supported. Rejected here. */
+        /* Code to Check if comp is WMV1 then return not supported */
+        pData += 4;
+        LoadDWORD(dwdat, pData);
+        uint32 NewCompression = dwdat;
+        uint32 NewSeqHeader = 0;
+        uint32 NewProfile = 0;
+        // in case of WMV store "Compression Type as Level"
+        aOutputs->level = NewCompression;
+
+        if (NewCompression != FOURCC_WMV2 &&
+                NewCompression != FOURCC_WMV3 &&
+                NewCompression != FOURCC_WVC1 &&
+                NewCompression != FOURCC_WMVA &&
+                NewCompression != FOURCC_MP42 &&
+                NewCompression != FOURCC_MP43 &&
+                NewCompression != FOURCC_mp42 &&
+                NewCompression != FOURCC_mp43)
+        {
+            return -1;
+        }
+        // get profile etc.
+        // Check sequence header
+        switch (NewCompression)
+        {
+            case FOURCC_WMV3:
+            {
+                // start fresh
+                pData = aInputs->inPtr;
+                pData += (11 + 40); //sizeof(BITMAPINFOHEADER); // position to sequence header
+
+                LoadDWORD(dwdat, pData);
+                NewSeqHeader = dwdat; // this is little endian read sequence header
+
+                NewProfile = (NewSeqHeader & 0xC0) >> 6; // 0 - simple , 1- main, 3 - complex, 2-forbidden
+
+                break;
+            }
+            case FOURCC_WMVA:
+            {
+                pData = aInputs->inPtr;
+                pData += (11 + 40 + ASFBINDING_SIZE); //sizeof(BITMAPINFOHEADER); // position to sequence header
+
+                LoadDWORD(dwdat, pData); // prefix	// this is little endian read sequence header
+                LoadDWORD(dwdat, pData);
+                NewSeqHeader = dwdat;
+
+                NewProfile = (NewSeqHeader & 0xC0) >> 6; // this must be 3
+            }
+            break;
+
+            default:
+
+                NewProfile = 0;
+                break;
+        }
+
+        aOutputs->profile = NewProfile;
+
+    }
+    else
+    {
+        return -1;
+    }
+    return 0;
+}
+
+
+/* This function finds a nal from the SC's, moves the bitstream pointer to the beginning of the NAL unit, returns the
+	size of the NAL, and at the same time, updates the remaining size in the bitstream buffer that is passed in */
+int32 GetNAL_Config(uint8** bitstream, int32* size)
+{
+    int i = 0;
+    int j;
+    uint8* nal_unit = *bitstream;
+    int count = 0;
+
+    /* find SC at the beginning of the NAL */
+    while (nal_unit[i++] == 0 && i < *size)
+    {
+    }
+
+    if (nal_unit[i-1] == 1)
+    {
+        *bitstream = nal_unit + i;
+    }
+    else
+    {
+        j = *size;
+        *size = 0;
+        return j;  // no SC at the beginning, not supposed to happen
+    }
+
+    j = i;
+
+    /* found the SC at the beginning of the NAL, now find the SC at the beginning of the next NAL */
+    while (i < *size)
+    {
+        if (count == 2 && nal_unit[i] == 0x01)
+        {
+            i -= 2;
+            break;
+        }
+
+        if (nal_unit[i])
+            count = 0;
+        else
+            count++;
+        i++;
+    }
+
+    *size -= i;
+    return (i -j);
+}
diff --git a/codecs_v2/utilities/pv_video_config_parser/Android.mk b/codecs_v2/utilities/pv_video_config_parser/Android.mk
deleted file mode 100644
index 0c09314..0000000
--- a/codecs_v2/utilities/pv_video_config_parser/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/pv_video_config_parser.cpp
-
-
-
-LOCAL_MODULE := libpv_video_config_parser
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-LOCAL_ARM_MODE := arm
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/utilities/pv_video_config_parser/include \
-	$(PV_TOP)//codecs_v2/utilities/pv_video_config_parser/src \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/pv_video_config_parser.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/utilities/pv_video_config_parser/build/make/makefile b/codecs_v2/utilities/pv_video_config_parser/build/make/makefile
deleted file mode 100644
index ebe961e..0000000
--- a/codecs_v2/utilities/pv_video_config_parser/build/make/makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pv_video_config_parser
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please includie a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pv_video_config_parser.cpp
-
-HDRS = pv_video_config_parser.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/codecs_v2/utilities/pv_video_config_parser/include/pv_video_config_parser.h b/codecs_v2/utilities/pv_video_config_parser/include/pv_video_config_parser.h
deleted file mode 100644
index a187650..0000000
--- a/codecs_v2/utilities/pv_video_config_parser/include/pv_video_config_parser.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_VIDEO_CONFIG_PARSER_H_INCLUDED
-#define PV_VIDEO_CONFIG_PARSER_H_INCLUDED
-
-#include "oscl_base.h"
-#include "oscl_types.h"
-#include "pvmf_format_type.h"
-
-typedef struct
-{
-    uint8 *inPtr;
-    uint32 inBytes;
-    PVMFFormatType iMimeType;
-} pvVideoConfigParserInputs;
-
-typedef struct
-{
-    uint32 width;
-    uint32 height;
-} pvVideoConfigParserOutputs;
-
-OSCL_IMPORT_REF int16 pv_video_config_parser(pvVideoConfigParserInputs *aInputs, pvVideoConfigParserOutputs *aOutputs);
-
-#endif //PV_VIDEO_CONFIG_PARSER_H_INCLUDED
-
-
diff --git a/codecs_v2/utilities/pv_video_config_parser/src/pv_video_config_parser.cpp b/codecs_v2/utilities/pv_video_config_parser/src/pv_video_config_parser.cpp
deleted file mode 100644
index 1fcaf02..0000000
--- a/codecs_v2/utilities/pv_video_config_parser/src/pv_video_config_parser.cpp
+++ /dev/null
@@ -1,228 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-#include "pv_video_config_parser.h"
-#include "m4v_config_parser.h"
-#include "oscl_mem.h"
-
-#include "oscl_dll.h"
-
-#define GetUnalignedWord( pb, w ) \
-            (w) = ((uint16) *(pb + 1) << 8) + *pb;
-
-#define GetUnalignedDword( pb, dw ) \
-            (dw) = ((uint32) *(pb + 3) << 24) + \
-                   ((uint32) *(pb + 2) << 16) + \
-                   ((uint16) *(pb + 1) << 8) + *pb;
-
-#define GetUnalignedWordEx( pb, w )     GetUnalignedWord( pb, w ); (pb) += sizeof(uint16);
-#define GetUnalignedDwordEx( pb, dw )   GetUnalignedDword( pb, dw ); (pb) += sizeof(uint32);
-#define GetUnalignedQwordEx( pb, qw )   GetUnalignedQword( pb, qw ); (pb) += sizeof(uint64);
-
-#define LoadBYTE( b, p )    b = *(uint8 *)p;  p += sizeof( uint8 )
-
-#define LoadWORD( w, p )    GetUnalignedWordEx( p, w )
-#define LoadDWORD( dw, p )  GetUnalignedDwordEx( p, dw )
-#define LoadQWORD( qw, p )  GetUnalignedQwordEx( p, qw )
-
-#ifndef MAKEFOURCC_WMC
-#define MAKEFOURCC_WMC(ch0, ch1, ch2, ch3) \
-        ((uint32)(uint8)(ch0) | ((uint32)(uint8)(ch1) << 8) |   \
-        ((uint32)(uint8)(ch2) << 16) | ((uint32)(uint8)(ch3) << 24 ))
-
-#define mmioFOURCC_WMC(ch0, ch1, ch2, ch3)  MAKEFOURCC_WMC(ch0, ch1, ch2, ch3)
-#endif
-
-#define FOURCC_WMV3     mmioFOURCC_WMC('W','M','V','3')
-#define FOURCC_WMVA		mmioFOURCC_WMC('W','M','V','A')
-#define FOURCC_WVC1		mmioFOURCC_WMC('W','V','C','1')
-
-
-OSCL_DLL_ENTRY_POINT_DEFAULT()
-
-int32 GetNAL_Config(uint8** bitstream, int32* size);
-
-OSCL_EXPORT_REF int16 pv_video_config_parser(pvVideoConfigParserInputs *aInputs, pvVideoConfigParserOutputs *aOutputs)
-{
-    switch (aInputs->iMimeType)
-    {
-        case PVMF_M4V: //m4v
-        {
-            mp4StreamType psBits;
-            psBits.data = aInputs->inPtr;
-            psBits.numBytes = aInputs->inBytes;
-            psBits.bytePos = 0;
-            psBits.bitBuf = 0;
-            psBits.dataBitPos = 0;
-            psBits.bitPos = 32;
-
-            int32 width, height, display_width, display_height = 0;
-            int16 retval = 0;
-            retval = iDecodeVOLHeader(&psBits, &width, &height, &display_width, &display_height);
-            if (retval != 0)
-            {
-                return retval;
-            }
-            aOutputs->width  = (uint32)display_width;
-            aOutputs->height = (uint32)display_height;
-        }
-        break;
-
-        case PVMF_H263: //h263
-        {
-            // Nothing to do for h263
-            aOutputs->width  = 0;
-            aOutputs->height = 0;
-        }
-        break;
-
-        case PVMF_H264: //avc
-        case PVMF_H264_MP4:
-        {
-            int32 width, height, display_width, display_height = 0;
-            uint8 *tp = aInputs->inPtr;
-
-            if (aInputs->inBytes > 1)
-            {
-                if (tp[0] == 0 && tp[1] == 0)
-                {
-                    // ByteStream Format
-                    uint8* tmp_ptr = tp;
-                    uint8* buffer_begin = tp;
-                    int16 length = 0;
-                    int initbufsize = aInputs->inBytes;
-                    int tConfigSize = 0;
-                    do
-                    {
-                        tmp_ptr += length;
-                        length = GetNAL_Config(&tmp_ptr, &initbufsize);
-                        buffer_begin[0] = length & 0xFF;
-                        buffer_begin[1] = (length >> 8) & 0xFF;
-                        oscl_memcpy(buffer_begin + 2, tmp_ptr, length);
-                        buffer_begin += (length + 2);
-                        tConfigSize += (length + 2);
-                    }
-                    while (initbufsize > 0);
-                }
-            }
-
-            // check codec info and get settings
-            int16 retval;
-            retval = iGetAVCConfigInfo(tp,
-                                       aInputs->inBytes,
-                                       (int*) & width,
-                                       (int*) & height,
-                                       (int*) & display_width,
-                                       (int*) & display_height);
-            if (retval != 0)
-            {
-                return retval;
-            }
-            aOutputs->width  = (uint32)display_width;
-            aOutputs->height = (uint32)display_height;
-        }
-        break;
-
-        case PVMF_WMV: //wmv
-        {
-            uint32 dwdat;
-            uint16 wdat;
-            uint8 bdat;
-            uint8 *pData = aInputs->inPtr;
-
-            LoadDWORD(dwdat, pData); // Window width
-            LoadDWORD(dwdat, pData); // Window height
-            LoadBYTE(bdat, pData);
-            LoadWORD(wdat, pData);  // Size of image info.
-
-            // BITMAPINFOHEADER
-            LoadDWORD(dwdat, pData); // Size of BMAPINFOHDR
-            LoadDWORD(dwdat, pData);
-            aOutputs->width = dwdat;
-            LoadDWORD(dwdat, pData);
-            aOutputs->height = dwdat;
-
-            /* WMV1 and WMV2 are not supported. Rejected here. */
-            pData += 4;
-            LoadDWORD(dwdat, pData);
-            uint32 NewCompression = dwdat;
-            if (NewCompression != FOURCC_WMV3 &&
-                    NewCompression != FOURCC_WVC1 &&
-                    NewCompression != FOURCC_WMVA)
-            {
-                return -1;
-            }
-        }
-        break;
-
-        default:
-            return -1;
-            break;
-    }
-    return 0;
-}
-
-
-/* This function finds a nal from the SC's, moves the bitstream pointer to the beginning of the NAL unit, returns the
-	size of the NAL, and at the same time, updates the remaining size in the bitstream buffer that is passed in */
-int32 GetNAL_Config(uint8** bitstream, int32* size)
-{
-    int i = 0;
-    int j;
-    uint8* nal_unit = *bitstream;
-    int count = 0;
-
-    /* find SC at the beginning of the NAL */
-    while (nal_unit[i++] == 0 && i < *size)
-    {
-    }
-
-    if (nal_unit[i-1] == 1)
-    {
-        *bitstream = nal_unit + i;
-    }
-    else
-    {
-        j = *size;
-        *size = 0;
-        return j;  // no SC at the beginning, not supposed to happen
-    }
-
-    j = i;
-
-    /* found the SC at the beginning of the NAL, now find the SC at the beginning of the next NAL */
-    while (i < *size)
-    {
-        if (count == 2 && nal_unit[i] == 0x01)
-        {
-            i -= 2;
-            break;
-        }
-
-        if (nal_unit[i])
-            count = 0;
-        else
-            count++;
-        i++;
-    }
-
-    *size -= i;
-    return (i -j);
-}
-
-
diff --git a/codecs_v2/video/avc_h264/common/Android.mk b/codecs_v2/video/avc_h264/common/Android.mk
index f270a7d..b3604aa 100644
--- a/codecs_v2/video/avc_h264/common/Android.mk
+++ b/codecs_v2/video/avc_h264/common/Android.mk
@@ -3,30 +3,32 @@
 
 LOCAL_SRC_FILES := \
 	src/deblock.cpp \
-	src/dpb.cpp \
-	src/fmo.cpp \
-	src/mb_access.cpp \
-	src/reflist.cpp
-
+ 	src/dpb.cpp \
+ 	src/fmo.cpp \
+ 	src/mb_access.cpp \
+ 	src/reflist.cpp
 
 
 LOCAL_MODULE := libpv_avc_common_lib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/video/avc_h264/common/include \
-	$(PV_TOP)//codecs_v2/video/avc_h264/common/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/video/avc_h264/common/src \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/avcapi_common.h \
-	include/avcint_common.h \
-	include/avclib_common.h
+ 	include/avcint_common.h \
+ 	include/avclib_common.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/video/avc_h264/common/build/make/local.mk b/codecs_v2/video/avc_h264/common/build/make/local.mk
new file mode 100644
index 0000000..396b67e
--- /dev/null
+++ b/codecs_v2/video/avc_h264/common/build/make/local.mk
@@ -0,0 +1,25 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv_avc_common_lib
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := deblock.cpp \
+	dpb.cpp \
+	fmo.cpp \
+	mb_access.cpp \
+	reflist.cpp
+
+HDRS :=  avcapi_common.h avcint_common.h avclib_common.h
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/video/avc_h264/common/build/make/makefile b/codecs_v2/video/avc_h264/common/build/make/makefile
deleted file mode 100644
index 6e5cb9a..0000000
--- a/codecs_v2/video/avc_h264/common/build/make/makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pv_avc_common_lib
-
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  deblock.cpp \
-	dpb.cpp \
-	fmo.cpp \
-	mb_access.cpp \
-	reflist.cpp
-
-HDRS =  avcapi_common.h avcint_common.h avclib_common.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/codecs_v2/video/avc_h264/common/include/avcapi_common.h b/codecs_v2/video/avc_h264/common/include/avcapi_common.h
index b1ba081..219921d 100644
--- a/codecs_v2/video/avc_h264/common/include/avcapi_common.h
+++ b/codecs_v2/video/avc_h264/common/include/avcapi_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /**
-This file contains common type defitionitions and enumerations used by AVC encoder
+This file contains common type definitions and enumerations used by AVC encoder
 and decoder libraries which are exposed to the users.
 @publishedAll
 */
@@ -61,6 +61,7 @@
 */
 typedef enum
 {
+    AVC_LEVEL_AUTO = 0,
     AVC_LEVEL1_B = 9,
     AVC_LEVEL1 = 10,
     AVC_LEVEL1_1 = 11,
diff --git a/codecs_v2/video/avc_h264/common/include/avcint_common.h b/codecs_v2/video/avc_h264/common/include/avcint_common.h
index 4f6a223..2c8fe4c 100644
--- a/codecs_v2/video/avc_h264/common/include/avcint_common.h
+++ b/codecs_v2/video/avc_h264/common/include/avcint_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,24 +31,6 @@
 #include "avcapi_common.h"
 #endif
 
-#if 0 /* no need for this, replaced by oscl_type.h*/
-/**
-This type definition can be mapped back to oscl.
-*/
-typedef unsigned char	uint8;
-typedef char			int8;
-typedef unsigned short	uint16;
-typedef short			int16;
-typedef unsigned long	uint32;
-typedef long			int32;
-typedef int	bool;
-/**
-This type is for native integer which could be either 16 or 32 bits.
-It is used to eliminate casting and only when the range of value fits 16 bits.
-@publishedAll
-*/
-typedef unsigned int	uint;
-#endif
 
 #ifndef TRUE
 #define TRUE  1
@@ -244,21 +226,6 @@
 } AVCResidualType;
 
 
-#if 0 /* NOT USED!!! Parameters get absorbed into AVCDecObject. */
-/**
-This structure contains NAL unit information after removal of emulation prevention code.
-@publishedAll
-*/
-typedef struct tagNALUnit
-{
-    uint		NumBytesInRBSP;
-    int		forbidden_bit;
-    int		nal_ref_idc;
-    AVCNalUnitType	nal_unit_type;
-    uint8	*rbsp_byte; /* RBSP buffer, will be assigned to bitstreamBuffer */
-} AVCNALUnit
-#endif
-
 /**
 This structure contains VUI parameters as specified in Annex E.
 Some variables may be removed from the structure if they are found to be useless to store.
@@ -269,8 +236,8 @@
     uint  cpb_cnt_minus1;									/* ue(v), range 0..31 */
     uint  bit_rate_scale;                          /* u(4) */
     uint  cpb_size_scale;                          /* u(4) */
-    uint32  bit_rate_value [MAXIMUMVALUEOFcpb_cnt];/* ue(v), range 0..2^32-2 */
-    uint32  cpb_size_value[MAXIMUMVALUEOFcpb_cnt]; /* ue(v), range 0..2^32-2 */
+    uint32  bit_rate_value_minus1[MAXIMUMVALUEOFcpb_cnt];/* ue(v), range 0..2^32-2 */
+    uint32  cpb_size_value_minus1[MAXIMUMVALUEOFcpb_cnt]; /* ue(v), range 0..2^32-2 */
     uint  cbr_flag[MAXIMUMVALUEOFcpb_cnt];         /* u(1) */
     uint  initial_cpb_removal_delay_length_minus1;   /* u(5), default 23 */
     uint  cpb_removal_delay_length_minus1;           /* u(5), default 23 */
@@ -299,8 +266,8 @@
     uint  transfer_characteristics;           /* u(8), Table E-4, default 2, unspecified */
     uint  matrix_coefficients;                /* u(8), Table E-5, default 2, unspecified */
     uint      chroma_location_info_present_flag;  /* u(1) */
-    uint  chroma_location_frame;                /* ue(v), Fig. E-1range 0..5, default 0 */
-    uint  chroma_location_field;                /* ue(v) */
+    uint  chroma_sample_loc_type_top_field;                /* ue(v), Fig. E-1range 0..5, default 0 */
+    uint  chroma_sample_loc_type_bottom_field;                /* ue(v) */
     uint      timing_info_present_flag;           /* u(1) */
     uint  num_units_in_tick;                    /* u(32), must be > 0 */
     uint  time_scale;                           /* u(32), must be > 0 */
@@ -606,8 +573,8 @@
 {
     AVCIntraChromaPredMode	intra_chroma_pred_mode;  /* ue(v) */
 
-    int16 mvL0[32];  /* motion vectors */
-    int16 mvL1[32];
+    int32 mvL0[16];  /* motion vectors, 16 bit packed (x,y) per element  */
+    int32 mvL1[16];
     int16 ref_idx_L0[4];
     int16 ref_idx_L1[4];
     uint16 RefIdx[4]; /* ref index, has value of AVCPictureData->RefIdx */
@@ -886,7 +853,7 @@
                                      13, 14, 255, 255, 255, 255, 255, 255, 255, 255
                                     };
 /* map back from index to Level IDC */
-const static uint8 mapIdx2Lev[MAX_LEVEL_IDX] = {0, 1, 2, 3, 10, 11, 12, 20, 21, 22, 30, 31, 32, 40, 41};
+const static uint8 mapIdx2Lev[MAX_LEVEL_IDX] = {10, 11, 12, 13, 20, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51};
 
 /**
 from the index map to the MaxDPB value times 2 */
diff --git a/codecs_v2/video/avc_h264/common/include/avclib_common.h b/codecs_v2/video/avc_h264/common/include/avclib_common.h
index a0e3d19..9203470 100644
--- a/codecs_v2/video/avc_h264/common/include/avclib_common.h
+++ b/codecs_v2/video/avc_h264/common/include/avclib_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,9 +78,8 @@
 This function finds empty frame in the decoded picture buffer to be used for the
 current picture, initializes the corresponding picture structure with Sl, Scb, Scr,
 width, height and pitch.
+\param "avcHandle" "Pointer to the main handle object."
 \param "video"	"Pointer to AVCCommonObj."
-\param "CurrPicNum" "Current picture number (only used in decoder)."
-\param "enc_flag" "Encoding flag (used by encoder)."
 \return "AVC_SUCCESS or AVC_FAIL."
 */
 AVCStatus DPBInitBuffer(AVCHandle *avcHandle, AVCCommonObj *video);
@@ -96,8 +95,17 @@
 void DPBInitPic(AVCCommonObj *video, int CurrPicNum);
 
 /**
+This function releases the current frame back to the available pool for skipped frame after encoding.
+\param "avcHandle" "Pointer to the main handle object."
+\param "video" "Pointer to the AVCCommonObj."
+\return "void."
+*/
+void DPBReleaseCurrentFrame(AVCHandle *avcHandle, AVCCommonObj *video);
+
+/**
 This function performs decoded reference picture marking process and store the current picture to the
 corresponding frame storage in the decoded picture buffer.
+\param "avcHandle" "Pointer to the main handle object."
 \param "video" "Pointer to the AVCCommonObj."
 \return "AVC_SUCCESS or AVC_FAIL."
 */
@@ -106,6 +114,7 @@
 /**
 This function perform sliding window operation on the reference picture lists, see subclause 8.2.5.3.
 It removes short-term ref frames with smallest FrameNumWrap from the reference list.
+\param "avcHandle" "Pointer to the main handle object."
 \param "video" "Pointer to the AVCCommonObj."
 \param "dpb"  "Pointer to the AVCDecPicBuffer."
 \return "AVC_SUCCESS or AVC_FAIL (contradicting values or scenario as in the Note in the draft)."
diff --git a/codecs_v2/video/avc_h264/common/src/deblock.cpp b/codecs_v2/video/avc_h264/common/src/deblock.cpp
index 7ae5794..ee6b50f 100644
--- a/codecs_v2/video/avc_h264/common/src/deblock.cpp
+++ b/codecs_v2/video/avc_h264/common/src/deblock.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -306,6 +306,7 @@
     int 	mbNum = mb_y * video->PicWidthInMbs + mb_x;
     int		*clipTable, *clipTable_c, *qp_clip_tab;
     uint8	Strength[16];
+    void*     str;
 
     MbQ = &(video->mblock[mbNum]);		// current Mb
 
@@ -320,7 +321,7 @@
         filterTopMbEdgeFlag  = mb_is_available(video->mblock, video->PicSizeInMbs, mbNum - video->PicWidthInMbs, mbNum);
     }
 
-    /* NOTE: edge=0 and edge=1~3 are seperate cases because of the difference of MbP, index A and indexB calculation */
+    /* NOTE: edge=0 and edge=1~3 are separate cases because of the difference of MbP, index A and indexB calculation */
     /*       for edge = 1~3, MbP, indexA and indexB remain the same, and thus there is no need to re-calculate them for each edge */
 
     qp_clip_tab = (int *)QP_CLIP_TAB + 12;
@@ -332,7 +333,8 @@
         //GetStrength(video, Strength, MbP, MbQ, 0, 0); // Strength for 4 blks in 1 stripe, 0 => vertical edge
         GetStrength_Edge0(Strength, MbP, MbQ, 0);
 
-        if (*((int*)Strength))    // only if one of the 4 Strength bytes is != 0
+        str = (void*)Strength; //de-ref type-punned pointer fix
+        if (*((uint32*)str))    // only if one of the 4 Strength bytes is != 0
         {
             QP = (MbP->QPy + MbQ->QPy + 1) >> 1; // Average QP of the two blocks;
             indexA = QP + video->FilterOffsetA;
@@ -438,7 +440,8 @@
         MbP = MbQ - video->PicWidthInMbs;
         //GetStrength(video, Strength, MbP, MbQ, 1, 0); // Strength for 4 blks in 1 stripe, 0 => vertical edge
         GetStrength_Edge0(Strength, MbP, MbQ, 1);
-        if (*((int*)Strength))    // only if one of the 4 Strength bytes is != 0
+        str = (void*)Strength; //de-ref type-punned pointer fix
+        if (*((uint32*)str))    // only if one of the 4 Strength bytes is != 0
         {
             QP = (MbP->QPy + MbQ->QPy + 1) >> 1; // Average QP of the two blocks;
             indexA = QP + video->FilterOffsetA;
@@ -535,7 +538,9 @@
 {
     int tmp;
     int16 *ptrQ, *ptrP;
+    void* vptr;
     uint8 *pStrength;
+    void* refIdx;
 
     if (MbP->mbMode == AVC_I4 || MbP->mbMode == AVC_I16 ||
             MbQ->mbMode == AVC_I4 || MbQ->mbMode == AVC_I16)
@@ -552,8 +557,10 @@
         {
 
             //1. Check the ref_frame_id
-            ptrQ = (int16*)MbQ->RefIdx;
-            ptrP = (int16*)MbP->RefIdx;
+            refIdx = (void*) MbQ->RefIdx; //de-ref type-punned pointer fix
+            ptrQ = (int16*)refIdx;
+            refIdx = (void*)MbP->RefIdx; //de-ref type-punned pointer fix
+            ptrP = (int16*)refIdx;
             pStrength = Strength;
             if (ptrQ[0] != ptrP[1]) pStrength[0] = 1;
             if (ptrQ[2] != ptrP[3]) pStrength[2] = 1;
@@ -567,8 +574,9 @@
             if (MbQ->nz_coeff[12] != 0 || MbP->nz_coeff[15] != 0) pStrength[3] = 2;
 
             //3. Only need to check the mv difference
-            ptrQ = MbQ->mvL0;
-            ptrP = MbP->mvL0 + 6; // points to 4x4 block #3 (the 4th column)
+            vptr = (void*)MbQ->mvL0;  // for deref type-punned pointer
+            ptrQ = (int16*)vptr;
+            ptrP = (int16*)(MbP->mvL0 + 3); // points to 4x4 block #3 (the 4th column)
 
             // 1st blk
             if (*pStrength == 0)
@@ -638,8 +646,10 @@
         {
 
             //1. Check the ref_frame_id
-            ptrQ = (int16*)MbQ->RefIdx;
-            ptrP = (int16*)MbP->RefIdx;
+            refIdx = (void*)MbQ->RefIdx;  //de-ref type-punned pointer
+            ptrQ = (int16*)refIdx;
+            refIdx = (void*)MbP->RefIdx;  //de-ref type-punned pointer
+            ptrP = (int16*)refIdx;
             pStrength = Strength;
             if (ptrQ[0] != ptrP[2]) pStrength[0] = 1;
             if (ptrQ[1] != ptrP[3]) pStrength[2] = 1;
@@ -653,8 +663,9 @@
             if (MbQ->nz_coeff[3] != 0 || MbP->nz_coeff[15] != 0) pStrength[3] = 2;
 
             //3. Only need to check the mv difference
-            ptrQ = MbQ->mvL0;
-            ptrP = MbP->mvL0 + 24; // points to 4x4 block #12 (the 4th row)
+            vptr = (void*)MbQ->mvL0;
+            ptrQ = (int16*)vptr;
+            ptrP = (int16*)(MbP->mvL0 + 12); // points to 4x4 block #12 (the 4th row)
 
             // 1st blk
             if (*pStrength == 0)
@@ -732,6 +743,7 @@
     int16	*ptr, *pmvx, *pmvy;
     uint8   *pnz;
     uint8	*pStrength, *pStr;
+    void* refIdx;
 
     if (MbQ->mbMode == AVC_I4 || MbQ->mbMode == AVC_I16)
     {
@@ -747,7 +759,8 @@
         *((int*)(Strength + 8)) = 0;
 
         //1. Check the ref_frame_id
-        ptr = (int16*)MbQ->RefIdx;
+        refIdx = (void*)MbQ->RefIdx;  //de-ref type-punned pointer fix
+        ptr = (int16*)refIdx;
         pStrength = Strength;
         if (ptr[0] != ptr[1]) pStrength[4] = 1;
         if (ptr[2] != ptr[3]) pStrength[6] = 1;
@@ -755,8 +768,8 @@
         pStrength[7] = pStrength[6];
 
         //2. Check the nz_coeff block and mv difference
-        pmvx = MbQ->mvL0 + 2; // points to 4x4 block #1,not #0
-        pmvy = MbQ->mvL0 + 3;
+        pmvx = (int16*)(MbQ->mvL0 + 1); // points to 4x4 block #1,not #0
+        pmvy = pmvx + 1;
         for (idx = 0; idx < 4; idx += 2) // unroll the loop, make 4 iterations to 2
         {
             // first/third row : 1,2,3 or 9,10,12
@@ -904,6 +917,7 @@
     int		idx, tmp;
     int16	*ptr, *pmvx, *pmvy;
     uint8	*pStrength, *pStr;
+    void* refIdx;
 
     if (MbQ->mbMode == AVC_I4 || MbQ->mbMode == AVC_I16)
     {
@@ -920,7 +934,8 @@
 
 
         //1. Check the ref_frame_id
-        ptr = (int16*)MbQ->RefIdx;
+        refIdx = (void*) MbQ->RefIdx; // de-ref type-punned fix
+        ptr = (int16*) refIdx;
         pStrength = Strength;
         if (ptr[0] != ptr[2]) pStrength[4] = 1;
         if (ptr[1] != ptr[3]) pStrength[6] = 1;
@@ -928,8 +943,8 @@
         pStrength[7] = pStrength[6];
 
         //2. Check the nz_coeff block and mv difference
-        pmvx = MbQ->mvL0 + 8; // points to 4x4 block #4,not #0
-        pmvy = MbQ->mvL0 + 9;
+        pmvx = (int16*)(MbQ->mvL0 + 4); // points to 4x4 block #4,not #0
+        pmvy = pmvx + 1;
         for (idx = 0; idx < 4; idx += 2) // unroll the loop, make 4 iterations to 2
         {
             // first/third row : 1,2,3 or 9,10,12
diff --git a/codecs_v2/video/avc_h264/common/src/dpb.cpp b/codecs_v2/video/avc_h264/common/src/dpb.cpp
index fb18ec9..d1c90b0 100644
--- a/codecs_v2/video/avc_h264/common/src/dpb.cpp
+++ b/codecs_v2/video/avc_h264/common/src/dpb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@
 {
     void *userData = avcHandle->userData;
     AVCDecPicBuffer *dpb = video->decPicBuf;
-    int framesize, i; /* size of one frame */
+    int framesize, ii; /* size of one frame */
     uint PicWidthInMbs, PicHeightInMapUnits, FrameHeightInMbs, PicSizeInMapUnits;
     uint num_fs;
     /* derived variables from SPS */
@@ -121,10 +121,10 @@
     if (video->PicSizeInMapUnits != PicSizeInMapUnits || video->currSeqParams->level_idc != video->level_idc)
     {
         /* make sure you mark all the frames as unused for reference for flushing*/
-        for (i = 0; i < dpb->num_fs; i++)
+        for (ii = 0; ii < dpb->num_fs; ii++)
         {
-            dpb->fs[i]->IsReference = 0;
-            dpb->fs[i]->IsOutputted |= 0x02;
+            dpb->fs[ii]->IsReference = 0;
+            dpb->fs[ii]->IsOutputted |= 0x02;
         }
 
         num_fs = (uint32)(MaxDPBX2[(uint32)mapLev2Idx[video->currSeqParams->level_idc]] << 2) / (3 * PicSizeInMapUnits) + 1;
@@ -160,9 +160,9 @@
         {
             return AVC_FAIL;
         }
-        for (i = 0; i < framesize; i++)
+        for (ii = 0; ii < framesize; ii++)
         {
-            video->mblock[i].slice_id = -1;
+            video->mblock[ii].slice_id = -1;
         }
         /* Allocate memory for intra prediction */
 #ifdef MB_BASED_DEBLOCK
@@ -195,6 +195,8 @@
         {
             return AVC_FAIL;
         }
+        video->PicSizeInMapUnits = PicSizeInMapUnits;
+        video->level_idc = video->currSeqParams->level_idc;
 
     }
     return AVC_SUCCESS;
@@ -203,15 +205,15 @@
 AVCStatus CleanUpDPB(AVCHandle *avcHandle, AVCCommonObj *video)
 {
     AVCDecPicBuffer *dpb = video->decPicBuf;
-    int i;
+    int ii;
     void *userData = avcHandle->userData;
 
-    for (i = 0; i < MAX_FS; i++)
+    for (ii = 0; ii < MAX_FS; ii++)
     {
-        if (dpb->fs[i] != NULL)
+        if (dpb->fs[ii] != NULL)
         {
-            avcHandle->CBAVC_Free(userData, (int)dpb->fs[i]);
-            dpb->fs[i] = NULL;
+            avcHandle->CBAVC_Free(userData, (int)dpb->fs[ii]);
+            dpb->fs[ii] = NULL;
         }
     }
 #ifndef PV_MEMORY_POOL
@@ -230,7 +232,7 @@
 AVCStatus DPBInitBuffer(AVCHandle *avcHandle, AVCCommonObj *video)
 {
     AVCDecPicBuffer *dpb = video->decPicBuf;
-    int i, status;
+    int ii, status;
 
     /* Before doing any decoding, check if there's a frame memory available */
     /* look for next unused dpb->fs, or complementary field pair */
@@ -238,14 +240,14 @@
 
     /* There's also restriction on the frame_num, see page 59 of JVT-I1010.doc. */
 
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
         /* looking for the one not used or not reference and has been outputted */
-        if (dpb->fs[i]->IsReference == 0 && dpb->fs[i]->IsOutputted == 3)
+        if (dpb->fs[ii]->IsReference == 0 && dpb->fs[ii]->IsOutputted == 3)
         {
-            video->currFS = dpb->fs[i];
+            video->currFS = dpb->fs[ii];
 #ifdef PV_MEMORY_POOL
-            status = avcHandle->CBAVC_FrameBind(avcHandle->userData, i, &(video->currFS->base_dpb));
+            status = avcHandle->CBAVC_FrameBind(avcHandle->userData, ii, &(video->currFS->base_dpb));
             if (status == AVC_FAIL)
             {
                 return AVC_NO_BUFFER; /* this should not happen */
@@ -254,7 +256,7 @@
             break;
         }
     }
-    if (i == dpb->num_fs)
+    if (ii == dpb->num_fs)
     {
         return AVC_PICTURE_OUTPUT_READY; /* no empty frame available */
     }
@@ -270,7 +272,7 @@
     /* used in GetOutput API */
     video->currFS->PicOrderCnt = video->PicOrderCnt;
     video->currFS->FrameNum = video->sliceHdr->frame_num;
-    video->currFS->FrameNumWrap = CurrPicNum;    //
+    video->currFS->FrameNumWrap = CurrPicNum;    // MC_FIX
     /* initialize everything to zero */
     video->currFS->IsOutputted = 0;
     video->currFS->IsReference = 0;
@@ -310,13 +312,38 @@
     video->currPic->PicNum = CurrPicNum;
 }
 
+/* to release skipped frame after encoding */
+void DPBReleaseCurrentFrame(AVCHandle *avcHandle, AVCCommonObj *video)
+{
+    AVCDecPicBuffer *dpb = video->decPicBuf;
+    int ii;
+
+    video->currFS->IsOutputted = 3; // return this buffer.
+
+#ifdef PV_MEMORY_POOL /* for non-memory pool, no need to do anything */
+
+    /* search for current frame index */
+    ii = dpb->num_fs;
+    while (ii--)
+    {
+        if (dpb->fs[ii] == video->currFS)
+        {
+            avcHandle->CBAVC_FrameUnbind(avcHandle->userData, ii);
+            break;
+        }
+    }
+#endif
+
+    return ;
+}
+
 /* see subclause 8.2.5.1 */
 AVCStatus StorePictureInDPB(AVCHandle *avcHandle, AVCCommonObj *video)
 {
     AVCStatus status;
     AVCDecPicBuffer *dpb = video->decPicBuf;
     AVCSliceHeader *sliceHdr = video->sliceHdr;
-    int i, num_ref;
+    int ii, num_ref;
 
     /* number 1 of 8.2.5.1, we handle gaps in frame_num differently without using the memory */
     /* to be done!!!! */
@@ -324,17 +351,17 @@
     /* number 3 of 8.2.5.1 */
     if (video->nal_unit_type == AVC_NALTYPE_IDR)
     {
-        for (i = 0; i < dpb->num_fs; i++)
+        for (ii = 0; ii < dpb->num_fs; ii++)
         {
-            if (dpb->fs[i] != video->currFS) /* not current frame */
+            if (dpb->fs[ii] != video->currFS) /* not current frame */
             {
-                dpb->fs[i]->IsReference = 0; /* mark as unused for reference */
-                dpb->fs[i]->IsLongTerm = 0;  /* but still used until output */
-                dpb->fs[i]->IsOutputted |= 0x02;
+                dpb->fs[ii]->IsReference = 0; /* mark as unused for reference */
+                dpb->fs[ii]->IsLongTerm = 0;  /* but still used until output */
+                dpb->fs[ii]->IsOutputted |= 0x02;
 #ifdef PV_MEMORY_POOL
-                if (dpb->fs[i]->IsOutputted == 3)
+                if (dpb->fs[ii]->IsOutputted == 3)
                 {
-                    avcHandle->CBAVC_FrameUnbind(avcHandle->userData, i);
+                    avcHandle->CBAVC_FrameUnbind(avcHandle->userData, ii);
                 }
 #endif
             }
@@ -358,18 +385,18 @@
         }
         if (sliceHdr->no_output_of_prior_pics_flag)
         {
-            for (i = 0; i < dpb->num_fs; i++)
+            for (ii = 0; ii < dpb->num_fs; ii++)
             {
-                if (dpb->fs[i] != video->currFS) /* not current frame */
+                if (dpb->fs[ii] != video->currFS) /* not current frame */
                 {
-                    dpb->fs[i]->IsOutputted = 3;
+                    dpb->fs[ii]->IsOutputted = 3;
 #ifdef PV_MEMORY_POOL
-                    avcHandle->CBAVC_FrameUnbind(avcHandle->userData, i);
+                    avcHandle->CBAVC_FrameUnbind(avcHandle->userData, ii);
 #endif
                 }
             }
         }
-        video->mem_mgr_ctrl_eq_5 = TRUE;    /* flush reference frames  */
+        video->mem_mgr_ctrl_eq_5 = TRUE;    /* flush reference frames MC_FIX */
     }
     else
     {
@@ -411,9 +438,9 @@
 
     /* check if number of reference frames doesn't exceed num_ref_frames */
     num_ref = 0;
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
-        if (dpb->fs[i]->IsReference)
+        if (dpb->fs[ii]->IsReference)
         {
             num_ref++;
         }
@@ -430,22 +457,22 @@
 
 AVCStatus sliding_window_process(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb)
 {
-    int i, numShortTerm, numLongTerm;
+    int ii, numShortTerm, numLongTerm;
     int32 MinFrameNumWrap;
     int	MinIdx;
 
 
     numShortTerm = 0;
     numLongTerm = 0;
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
-        if (dpb->fs[i] != video->currFS) /* do not count the current frame */
+        if (dpb->fs[ii] != video->currFS) /* do not count the current frame */
         {
-            if (dpb->fs[i]->IsLongTerm)
+            if (dpb->fs[ii]->IsLongTerm)
             {
                 numLongTerm++;
             }
-            else if (dpb->fs[i]->IsReference)
+            else if (dpb->fs[ii]->IsReference)
             {
                 numShortTerm++;
             }
@@ -464,14 +491,14 @@
 
         MinFrameNumWrap = 0x7FFFFFFF;
         MinIdx = -1;
-        for (i = 0; i < dpb->num_fs; i++)
+        for (ii = 0; ii < dpb->num_fs; ii++)
         {
-            if (dpb->fs[i]->IsReference && !dpb->fs[i]->IsLongTerm)
+            if (dpb->fs[ii]->IsReference && !dpb->fs[ii]->IsLongTerm)
             {
-                if (dpb->fs[i]->FrameNumWrap < MinFrameNumWrap)
+                if (dpb->fs[ii]->FrameNumWrap < MinFrameNumWrap)
                 {
-                    MinFrameNumWrap = dpb->fs[i]->FrameNumWrap;
-                    MinIdx = i;
+                    MinFrameNumWrap = dpb->fs[ii]->FrameNumWrap;
+                    MinIdx = ii;
                 }
             }
         }
@@ -500,25 +527,25 @@
 /* see subclause 8.2.5.4 */
 AVCStatus adaptive_memory_marking(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, AVCSliceHeader *sliceHdr)
 {
-    int i;
+    int ii;
 
-    i = 0;
-    while (i < MAX_DEC_REF_PIC_MARKING && sliceHdr->memory_management_control_operation[i] != 0)
+    ii = 0;
+    while (ii < MAX_DEC_REF_PIC_MARKING && sliceHdr->memory_management_control_operation[ii] != 0)
     {
-        switch (sliceHdr->memory_management_control_operation[i])
+        switch (sliceHdr->memory_management_control_operation[ii])
         {
             case 1:
-                MemMgrCtrlOp1(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[i]);
+                MemMgrCtrlOp1(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[ii]);
                 //		update_ref_list(dpb);
                 break;
             case 2:
-                MemMgrCtrlOp2(avcHandle, dpb, sliceHdr->long_term_pic_num[i]);
+                MemMgrCtrlOp2(avcHandle, dpb, sliceHdr->long_term_pic_num[ii]);
                 break;
             case 3:
-                MemMgrCtrlOp3(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[i], sliceHdr->long_term_frame_idx[i]);
+                MemMgrCtrlOp3(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[ii], sliceHdr->long_term_frame_idx[ii]);
                 break;
             case 4:
-                MemMgrCtrlOp4(avcHandle, video, dpb, sliceHdr->max_long_term_frame_idx_plus1[i]);
+                MemMgrCtrlOp4(avcHandle, video, dpb, sliceHdr->max_long_term_frame_idx_plus1[ii]);
                 break;
             case 5:
                 MemMgrCtrlOp5(avcHandle, video, dpb);
@@ -526,13 +553,13 @@
                 video->currFS->PicOrderCnt = 0;
                 break;
             case 6:
-                MemMgrCtrlOp6(avcHandle, video, dpb, sliceHdr->long_term_frame_idx[i]);
+                MemMgrCtrlOp6(avcHandle, video, dpb, sliceHdr->long_term_frame_idx[ii]);
                 break;
         }
-        i++;
+        ii++;
     }
 
-    if (i == MAX_DEC_REF_PIC_MARKING)
+    if (ii == MAX_DEC_REF_PIC_MARKING)
     {
         return AVC_FAIL; /* exceed the limit */
     }
@@ -544,17 +571,17 @@
 /* see subclause 8.2.5.4.1, mark short-term picture as "unused for reference" */
 void MemMgrCtrlOp1(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, int difference_of_pic_nums_minus1)
 {
-    int picNumX, i;
+    int picNumX, ii;
 
     picNumX = video->CurrPicNum - (difference_of_pic_nums_minus1 + 1);
 
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
-        if (dpb->fs[i]->IsReference == 3 && dpb->fs[i]->IsLongTerm == 0)
+        if (dpb->fs[ii]->IsReference == 3 && dpb->fs[ii]->IsLongTerm == 0)
         {
-            if (dpb->fs[i]->frame.PicNum == picNumX)
+            if (dpb->fs[ii]->frame.PicNum == picNumX)
             {
-                unmark_for_reference(avcHandle, dpb, i);
+                unmark_for_reference(avcHandle, dpb, ii);
                 return ;
             }
         }
@@ -566,15 +593,15 @@
 /* see subclause 8.2.5.4.2 mark long-term picture as "unused for reference" */
 void MemMgrCtrlOp2(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, int long_term_pic_num)
 {
-    int i;
+    int ii;
 
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
-        if (dpb->fs[i]->IsLongTerm == 3)
+        if (dpb->fs[ii]->IsLongTerm == 3)
         {
-            if (dpb->fs[i]->frame.LongTermPicNum == long_term_pic_num)
+            if (dpb->fs[ii]->frame.LongTermPicNum == long_term_pic_num)
             {
-                unmark_for_reference(avcHandle, dpb, i);
+                unmark_for_reference(avcHandle, dpb, ii);
             }
         }
     }
@@ -584,7 +611,7 @@
 void MemMgrCtrlOp3(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint difference_of_pic_nums_minus1,
                    uint long_term_frame_idx)
 {
-    int picNumX, i;
+    int picNumX, ii;
 
     picNumX = video->CurrPicNum - (difference_of_pic_nums_minus1 + 1);
 
@@ -595,18 +622,18 @@
 
     /* now mark the picture with picNumX to long term frame idx */
 
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
-        if (dpb->fs[i]->IsReference == 3)
+        if (dpb->fs[ii]->IsReference == 3)
         {
-            if ((dpb->fs[i]->frame.isLongTerm == FALSE) && (dpb->fs[i]->frame.PicNum == picNumX))
+            if ((dpb->fs[ii]->frame.isLongTerm == FALSE) && (dpb->fs[ii]->frame.PicNum == picNumX))
             {
-                dpb->fs[i]->LongTermFrameIdx = long_term_frame_idx;
-                dpb->fs[i]->frame.LongTermPicNum = long_term_frame_idx;
+                dpb->fs[ii]->LongTermFrameIdx = long_term_frame_idx;
+                dpb->fs[ii]->frame.LongTermPicNum = long_term_frame_idx;
 
-                dpb->fs[i]->frame.isLongTerm = TRUE;
+                dpb->fs[ii]->frame.isLongTerm = TRUE;
 
-                dpb->fs[i]->IsLongTerm = 3;
+                dpb->fs[ii]->IsLongTerm = 3;
                 return;
             }
         }
@@ -617,18 +644,18 @@
 /* see subclause 8.2.5.4.4, MaxLongTermFrameIdx */
 void MemMgrCtrlOp4(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint max_long_term_frame_idx_plus1)
 {
-    int i;
+    int ii;
 
     video->MaxLongTermFrameIdx = max_long_term_frame_idx_plus1 - 1;
 
     /* then mark long term frame with exceeding LongTermFrameIdx to unused for reference. */
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
-        if (dpb->fs[i]->IsLongTerm && dpb->fs[i] != video->currFS)
+        if (dpb->fs[ii]->IsLongTerm && dpb->fs[ii] != video->currFS)
         {
-            if (dpb->fs[i]->LongTermFrameIdx > video->MaxLongTermFrameIdx)
+            if (dpb->fs[ii]->LongTermFrameIdx > video->MaxLongTermFrameIdx)
             {
-                unmark_for_reference(avcHandle, dpb, i);
+                unmark_for_reference(avcHandle, dpb, ii);
             }
         }
     }
@@ -638,14 +665,14 @@
 MaxLongTermFrameIdx to "no long-term frame indices" */
 void MemMgrCtrlOp5(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb)
 {
-    int i;
+    int ii;
 
     video->MaxLongTermFrameIdx = -1;
-    for (i = 0; i < dpb->num_fs; i++)
+    for (ii = 0; ii < dpb->num_fs; ii++) /* including the current frame ??????*/
     {
-        if (dpb->fs[i] != video->currFS)
+        if (dpb->fs[ii] != video->currFS) // MC_FIX
         {
-            unmark_for_reference(avcHandle, dpb, i);
+            unmark_for_reference(avcHandle, dpb, ii);
         }
     }
 
@@ -687,13 +714,13 @@
 
 void unmark_long_term_frame_for_reference_by_frame_idx(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint long_term_frame_idx)
 {
-    int i;
-    for (i = 0; i < dpb->num_fs; i++)
+    int ii;
+    for (ii = 0; ii < dpb->num_fs; ii++)
     {
 
-        if (dpb->fs[i]->IsLongTerm && (dpb->fs[i]->LongTermFrameIdx == (int)long_term_frame_idx))
+        if (dpb->fs[ii]->IsLongTerm && (dpb->fs[ii]->LongTermFrameIdx == (int)long_term_frame_idx))
         {
-            unmark_for_reference(avcHandle, dpb, i);
+            unmark_for_reference(avcHandle, dpb, ii);
         }
 
     }
diff --git a/codecs_v2/video/avc_h264/common/src/fmo.cpp b/codecs_v2/video/avc_h264/common/src/fmo.cpp
index 31e78cd..3cac775 100644
--- a/codecs_v2/video/avc_h264/common/src/fmo.cpp
+++ b/codecs_v2/video/avc_h264/common/src/fmo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/common/src/mb_access.cpp b/codecs_v2/video/avc_h264/common/src/mb_access.cpp
index 72274e9..7dec409 100644
--- a/codecs_v2/video/avc_h264/common/src/mb_access.cpp
+++ b/codecs_v2/video/avc_h264/common/src/mb_access.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -195,7 +195,7 @@
     int i, j, offset_MbPart_indx, refIdxLXA, refIdxLXB, refIdxLXC = 0, curr_ref_idx;
     int pmv_A_x, pmv_B_x, pmv_C_x = 0, pmv_A_y, pmv_B_y, pmv_C_y = 0;
 
-    /* we have to take care of Intra/skip blocks somewhere, i.e. set MV to  0 and set ref to -1! MC */
+    /* we have to take care of Intra/skip blocks somewhere, i.e. set MV to  0 and set ref to -1! */
     /* we have to populate refIdx as well */
 
 
@@ -208,16 +208,16 @@
         currMB->ref_idx_L0[0] = currMB->ref_idx_L0[1] = currMB->ref_idx_L0[2] = currMB->ref_idx_L0[3] = 0;
         if (video->mbAvailA && video->mbAvailB)
         {
-            if ((MB_A->ref_idx_L0[1] == 0 && MB_A->mvL0[6] == 0 &&  MB_A->mvL0[7] == 0) ||
-                    (MB_B->ref_idx_L0[2] == 0 && MB_B->mvL0[24] == 0 &&  MB_B->mvL0[25] == 0))
+            if ((MB_A->ref_idx_L0[1] == 0 && MB_A->mvL0[3] == 0) ||
+                    (MB_B->ref_idx_L0[2] == 0 && MB_B->mvL0[12] == 0))
             {
-                oscl_memset(currMB->mvL0, 0, sizeof(int16)*32);
+                oscl_memset(currMB->mvL0, 0, sizeof(int32)*16);
                 return;
             }
         }
         else
         {
-            oscl_memset(currMB->mvL0, 0, sizeof(int16)*32);
+            oscl_memset(currMB->mvL0, 0, sizeof(int32)*16);
             return;
         }
         video->mvd_l0[0][0][0] = 0;
@@ -238,7 +238,7 @@
 
         for (subMbPartIdx = 0; subMbPartIdx < currMB->NumSubMbPart[mbPartIdx]; subMbPartIdx++)
         {
-            block_x = mbPartIdx_X + ((subMbPartIdx + offset_indx) & 1);  // check this MC
+            block_x = mbPartIdx_X + ((subMbPartIdx + offset_indx) & 1);
             block_y = mbPartIdx_Y + (((subMbPartIdx + offset_indx) >> 1) & 1);
 
             block_x_1 = block_x - 1;
@@ -250,7 +250,7 @@
             {
                 avail_a = 1;
                 refIdxLXA = currMB->ref_idx_L0[(block_y & 2) + (block_x_1 >> 1)];
-                mv = &currMB->mvL0[0] + (block_y << 3) + (block_x_1 << 1);
+                mv = (int16*)(currMB->mvL0 + (block_y << 2) + block_x_1);
                 pmv_A_x = *mv++;
                 pmv_A_y = *mv;
             }
@@ -260,7 +260,7 @@
                 if (avail_a)
                 {
                     refIdxLXA = MB_A->ref_idx_L0[(block_y & 2) + 1];
-                    mv = &MB_A->mvL0[0] + (block_y << 3) + 6;
+                    mv = (int16*)(MB_A->mvL0 + (block_y << 2) + 3);
                     pmv_A_x = *mv++;
                     pmv_A_y = *mv;
                 }
@@ -270,7 +270,7 @@
             {
                 avail_b = 1;
                 refIdxLXB = currMB->ref_idx_L0[(block_y_1 & 2) + (block_x >> 1)];
-                mv = &currMB->mvL0[0] + (block_y_1 << 3) + (block_x << 1);
+                mv = (int16*)(currMB->mvL0 + (block_y_1 << 2) + block_x);
                 pmv_B_x = *mv++;
                 pmv_B_y = *mv;
             }
@@ -281,7 +281,7 @@
                 if (avail_b)
                 {
                     refIdxLXB = MB_B->ref_idx_L0[2 + (block_x >> 1)];
-                    mv = &MB_B->mvL0[0] + 24 + (block_x << 1);
+                    mv = (int16*)(MB_B->mvL0 + 12 + block_x);
                     pmv_B_x = *mv++;
                     pmv_B_y = *mv;
                 }
@@ -292,9 +292,9 @@
 
             if (avail_c)
             {
-                /* it guaranteed that block_y > 0 && new_block_x<3 ) MC */
+                /* it guaranteed that block_y > 0 && new_block_x<3 ) */
                 refIdxLXC = currMB->ref_idx_L0[(block_y_1 & 2) + ((new_block_x+1) >> 1)];
-                mv = &currMB->mvL0[0] + (block_y_1 << 3) + ((new_block_x + 1) << 1);
+                mv = (int16*)(currMB->mvL0 + (block_y_1 << 2) + (new_block_x + 1));
                 pmv_C_x = *mv++;
                 pmv_C_y = *mv;
             }
@@ -306,7 +306,7 @@
                     if (avail_c)
                     {
                         refIdxLXC = MB_B->ref_idx_L0[2 + ((new_block_x+1)>>1)];
-                        mv = &MB_B->mvL0[0] + 24 + ((new_block_x + 1) << 1);
+                        mv = (int16*)(MB_B->mvL0 + 12 + (new_block_x + 1));
                         pmv_C_x = *mv++;
                         pmv_C_y = *mv;
                     }
@@ -317,7 +317,7 @@
                     if (avail_c)
                     {
                         refIdxLXC = MB_C->ref_idx_L0[2];
-                        mv = &MB_C->mvL0[0] + 24;
+                        mv = (int16*)(MB_C->mvL0 + 12);
                         pmv_C_x = *mv++;
                         pmv_C_y = *mv;
                     }
@@ -329,7 +329,7 @@
                     {
                         avail_c = 1;
                         refIdxLXC =  currMB->ref_idx_L0[(block_y_1 & 2) + (block_x_1 >> 1)];
-                        mv = &currMB->mvL0[0] + (block_y_1 << 3) + (block_x_1 << 1);
+                        mv = (int16*)(currMB->mvL0 + (block_y_1 << 2) + block_x_1);
                         pmv_C_x = *mv++;
                         pmv_C_y = *mv;
                     }
@@ -339,7 +339,7 @@
                         if (avail_c)
                         {
                             refIdxLXC =  MB_A->ref_idx_L0[(block_y_1 & 2) + 1];
-                            mv = &MB_A->mvL0[0] + (block_y_1 << 3) + 6;
+                            mv = (int16*)(MB_A->mvL0 + (block_y_1 << 2) + 3);
                             pmv_C_x = *mv++;
                             pmv_C_y = *mv;
                         }
@@ -350,7 +350,7 @@
                         if (avail_c)
                         {
                             refIdxLXC = MB_B->ref_idx_L0[2 + (block_x_1 >> 1)];
-                            mv = &MB_B->mvL0[0] + 24 + (block_x_1 << 1);
+                            mv = (int16*)(MB_B->mvL0 + 12 + block_x_1);
                             pmv_C_x = *mv++;
                             pmv_C_y = *mv;
                         }
@@ -361,7 +361,7 @@
                         if (avail_c)
                         {
                             refIdxLXC = MB_D->ref_idx_L0[3];
-                            mv = &MB_D->mvL0[0] + 30;
+                            mv = (int16*)(MB_D->mvL0 + 15);
                             pmv_C_x = *mv++;
                             pmv_C_y = *mv;
                         }
@@ -402,7 +402,7 @@
                 pmv_y = AVC_MEDIAN(pmv_A_y, pmv_B_y, pmv_C_y);
             }
 
-            /* overwrite if special case  MC*/
+            /* overwrite if special case */
             if (currMB->NumMbPart == 2)
             {
                 if (currMB->MbPartWidth == 16)
@@ -439,7 +439,7 @@
                 }
             }
 
-            mv = &currMB->mvL0[0] + (block_x << 1) + (block_y << 3);
+            mv = (int16*)(currMB->mvL0 + block_x + (block_y << 2));
 
             if (encFlag) /* calculate residual MV video->mvd_l0 */
             {
diff --git a/codecs_v2/video/avc_h264/common/src/reflist.cpp b/codecs_v2/video/avc_h264/common/src/reflist.cpp
index 188f488..86569ae 100644
--- a/codecs_v2/video/avc_h264/common/src/reflist.cpp
+++ b/codecs_v2/video/avc_h264/common/src/reflist.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -231,22 +231,27 @@
     int i;
     int maxPicNum, currPicNum, picNumLXNoWrap, picNumLXPred, picNumLX;
     int refIdxLX = 0;
+    void* tmp;
 
     if (!isL1) /* list 0 */
     {
         list_size = &(video->refList0Size);
         num_ref_idx_lX_active_minus1 = sliceHdr->num_ref_idx_l0_active_minus1;
         remapping_of_pic_nums_idc = sliceHdr->reordering_of_pic_nums_idc_l0;
-        abs_diff_pic_num_minus1 = (int*)sliceHdr->abs_diff_pic_num_minus1_l0;
-        long_term_pic_idx = (int*)sliceHdr->long_term_pic_num_l0;
+        tmp = (void*)sliceHdr->abs_diff_pic_num_minus1_l0;
+        abs_diff_pic_num_minus1 = (int*) tmp;
+        tmp = (void*)sliceHdr->long_term_pic_num_l0;
+        long_term_pic_idx = (int*) tmp;
     }
     else
     {
         list_size = &(video->refList1Size);
         num_ref_idx_lX_active_minus1 = sliceHdr->num_ref_idx_l1_active_minus1;
         remapping_of_pic_nums_idc = sliceHdr->reordering_of_pic_nums_idc_l1;
-        abs_diff_pic_num_minus1 = (int*)sliceHdr->abs_diff_pic_num_minus1_l1;
-        long_term_pic_idx = (int*)sliceHdr->long_term_pic_num_l1;
+        tmp = (void*) sliceHdr->abs_diff_pic_num_minus1_l1;
+        abs_diff_pic_num_minus1 = (int*) tmp;
+        tmp = (void*) sliceHdr->long_term_pic_num_l1;
+        long_term_pic_idx = (int*)tmp;
     }
 
     maxPicNum = video->MaxPicNum;
diff --git a/codecs_v2/video/avc_h264/dec/Android.mk b/codecs_v2/video/avc_h264/dec/Android.mk
index 1a62b10..abc9b06 100644
--- a/codecs_v2/video/avc_h264/dec/Android.mk
+++ b/codecs_v2/video/avc_h264/dec/Android.mk
@@ -3,36 +3,38 @@
 
 LOCAL_SRC_FILES := \
 	src/avcdec_api.cpp \
-	src/avc_bitstream.cpp \
-	src/header.cpp \
-	src/itrans.cpp \
-	src/pred_inter.cpp \
-	src/pred_intra.cpp \
-	src/pvavcdecoder.cpp \
-	src/pvavcdecoder_factory.cpp \
-	src/residual.cpp \
-	src/slice.cpp \
-	src/vlc.cpp
-
+ 	src/avc_bitstream.cpp \
+ 	src/header.cpp \
+ 	src/itrans.cpp \
+ 	src/pred_inter.cpp \
+ 	src/pred_intra.cpp \
+ 	src/pvavcdecoder.cpp \
+ 	src/pvavcdecoder_factory.cpp \
+ 	src/residual.cpp \
+ 	src/slice.cpp \
+ 	src/vlc.cpp
 
 
 LOCAL_MODULE := libpvavcdecoder
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/video/avc_h264/dec/include \
-	$(PV_TOP)//codecs_v2/video/avc_h264/dec/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/video/avc_h264/dec/src \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvavcdecoder.h \
-	include/pvavcdecoder_factory.h \
-	include/pvavcdecoderinterface.h
+ 	include/pvavcdecoder_factory.h \
+ 	include/pvavcdecoderinterface.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/video/avc_h264/dec/build/make/local.mk b/codecs_v2/video/avc_h264/dec/build/make/local.mk
new file mode 100644
index 0000000..e51a556
--- /dev/null
+++ b/codecs_v2/video/avc_h264/dec/build/make/local.mk
@@ -0,0 +1,32 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvavcdecoder
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := avcdec_api.cpp \
+	avc_bitstream.cpp \
+	header.cpp \
+	itrans.cpp \
+	pred_inter.cpp \
+	pred_intra.cpp \
+	pvavcdecoder.cpp \
+	pvavcdecoder_factory.cpp \
+	residual.cpp \
+	slice.cpp \
+	vlc.cpp
+
+HDRS := pvavcdecoder.h \
+	pvavcdecoder_factory.h \
+	pvavcdecoderinterface.h
+
+include $(MK)/library.mk
diff --git a/codecs_v2/video/avc_h264/dec/build/make/makefile b/codecs_v2/video/avc_h264/dec/build/make/makefile
deleted file mode 100644
index 1e739d5..0000000
--- a/codecs_v2/video/avc_h264/dec/build/make/makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvavcdecoder
-
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  avcdec_api.cpp \
-	avc_bitstream.cpp \
-	header.cpp \
-	itrans.cpp \
-	pred_inter.cpp \
-	pred_intra.cpp \
-	pvavcdecoder.cpp \
-	pvavcdecoder_factory.cpp \
-	residual.cpp \
-	slice.cpp \
-	vlc.cpp
-
-HDRS =  pvavcdecoder.h \
-	pvavcdecoder_factory.h \
-	pvavcdecoderinterface.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/codecs_v2/video/avc_h264/dec/include/avcdec_api.h b/codecs_v2/video/avc_h264/dec/include/avcdec_api.h
index 0630d78..6888577 100644
--- a/codecs_v2/video/avc_h264/dec/include/avcdec_api.h
+++ b/codecs_v2/video/avc_h264/dec/include/avcdec_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,10 @@
 #ifndef _AVCDEC_API_H_
 #define _AVCDEC_API_H_
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #include "avcapi_common.h"
 
 /**
@@ -89,7 +93,7 @@
     \return	"AVCDEC_SUCCESS if success, AVCDEC_FAIL if no first start code is found, AVCDEC_NO_NEX_SC if
     		the first start code is found, but the second start code is missing (potential partial NAL)."
     */
-    AVCDec_Status PVAVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit, int *size);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit, int *size);
 
     /**
     This function sniffs the nal_unit_type such that users can call corresponding APIs.
@@ -98,7 +102,7 @@
     \param "nal_unit_type" "Pointer to the return value of nal unit type."
     \return	"AVCDEC_SUCCESS if success, AVCDEC_FAIL otherwise."
     */
-    AVCDec_Status PVAVCDecGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
 
     /**
     This function decodes the sequence parameters set, initializes related parameters and
@@ -112,7 +116,7 @@
     		AVCDEC_FAIL if profile and level is not supported,
     		AVCDEC_MEMORY_FAIL if memory allocations return null."
     */
-    AVCDec_Status	PVAVCDecSeqParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecSeqParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
 
     /**
     This function returns sequence parameters such as dimension and field flag of the most recently
@@ -124,7 +128,7 @@
     \return "AVCDEC_SUCCESS if success and AVCDEC_FAIL if fail."
     \note "This API can be combined with PVAVCInitSequence if wanted to be consistent with m4vdec lib."
     */
-    AVCDec_Status	PVAVCDecGetSeqInfo(AVCHandle *avcHandle, AVCDecSPSInfo *seqInfo);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetSeqInfo(AVCHandle *avcHandle, AVCDecSPSInfo *seqInfo);
 
     /**
     This function decodes the picture parameters set and initializes related parameters. Note thate
@@ -135,7 +139,7 @@
     \param "nal_size"		"size of the bitstream NumBytesInNALunit."
     \return	"AVCDEC_SUCCESS if success, AVCDEC_FAIL if profile and level is not supported."
     */
-    AVCDec_Status	PVAVCDecPicParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecPicParamSet(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
 
     /**
     This function decodes one NAL unit of bitstream. The type of nal unit is one of the
@@ -154,9 +158,9 @@
     		AVCDEC_REDUNDANT_PICTURE if error has been detected in the primary picture and redundant picture is available,
     		AVCDEC_CONCEALED_PICTURE if error has been detected and decoder has concealed it."
     */
-    AVCDec_Status	PVAVCDecSEI(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecSEI(AVCHandle *avcHandle, uint8 *nal_unit, int nal_size);
 
-    AVCDec_Status PVAVCDecodeSlice(AVCHandle *avcHandle, uint8 *buffer, int buf_size);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecodeSlice(AVCHandle *avcHandle, uint8 *buffer, int buf_size);
 
     /**
     Check the availability of the decoded picture in decoding order (frame_num).
@@ -169,19 +173,19 @@
     \return "AVCDEC_SUCCESS for success, AVCDEC_FAIL if no picture is available to be displayed,
     		AVCDEC_PICTURE_READY if there is another picture to be displayed."
     */
-    AVCDec_Status PVAVCDecGetOutput(AVCHandle *avcHandle, int *indx, int *release_flag, AVCFrameIO *output);
+    OSCL_IMPORT_REF AVCDec_Status PVAVCDecGetOutput(AVCHandle *avcHandle, int *indx, int *release_flag, AVCFrameIO *output);
 
     /**
     This function resets the decoder and expects to see the next IDR slice.
     \param "avcHandle"	"Handle to the AVC decoder library object."
     */
-    void	PVAVCDecReset(AVCHandle *avcHandle);
+    OSCL_IMPORT_REF void	PVAVCDecReset(AVCHandle *avcHandle);
 
     /**
     This function performs clean up operation including memory deallocation.
     \param "avcHandle"	"Handle to the AVC decoder library object."
     */
-    void	PVAVCCleanUpDecoder(AVCHandle *avcHandle);
+    OSCL_IMPORT_REF void	PVAVCCleanUpDecoder(AVCHandle *avcHandle);
 //AVCDec_Status EBSPtoRBSP(uint8 *nal_unit,int *size);
 
 #if 0
diff --git a/codecs_v2/video/avc_h264/dec/include/pvavcdecoder.h b/codecs_v2/video/avc_h264/dec/include/pvavcdecoder.h
index 61d528a..648e454 100644
--- a/codecs_v2/video/avc_h264/dec/include/pvavcdecoder.h
+++ b/codecs_v2/video/avc_h264/dec/include/pvavcdecoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/include/pvavcdecoder_factory.h b/codecs_v2/video/avc_h264/dec/include/pvavcdecoder_factory.h
index aa07113..b9cfeaf 100644
--- a/codecs_v2/video/avc_h264/dec/include/pvavcdecoder_factory.h
+++ b/codecs_v2/video/avc_h264/dec/include/pvavcdecoder_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/include/pvavcdecoderinterface.h b/codecs_v2/video/avc_h264/dec/include/pvavcdecoderinterface.h
index da9b208..3bf9136 100644
--- a/codecs_v2/video/avc_h264/dec/include/pvavcdecoderinterface.h
+++ b/codecs_v2/video/avc_h264/dec/include/pvavcdecoderinterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/avc_bitstream.cpp b/codecs_v2/video/avc_h264/dec/src/avc_bitstream.cpp
index 4caa406..ec40c77 100644
--- a/codecs_v2/video/avc_h264/dec/src/avc_bitstream.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/avc_bitstream.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/avcdec_api.cpp b/codecs_v2/video/avc_h264/dec/src/avcdec_api.cpp
index f599043..4219e95 100644
--- a/codecs_v2/video/avc_h264/dec/src/avcdec_api.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/avcdec_api.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -97,8 +97,8 @@
 	}
    }"
 */
-AVCDec_Status PVAVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit,
-                                    int *size)
+OSCL_EXPORT_REF AVCDec_Status PVAVCAnnexBGetNALUnit(uint8 *bitstream, uint8 **nal_unit,
+        int *size)
 {
     int i, j, FoundStartCode = 0;
     int end;
@@ -162,8 +162,8 @@
 /*	Return   : AVCDEC_SUCCESS if succeed, AVC_FAIL if fail.					*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCDec_Status PVAVCDecGetNALType(uint8 *bitstream, int size,
-                                 int *nal_type, int *nal_ref_idc)
+OSCL_EXPORT_REF AVCDec_Status PVAVCDecGetNALType(uint8 *bitstream, int size,
+        int *nal_type, int *nal_ref_idc)
 {
     int forbidden_zero_bit;
     if (size > 0)
@@ -188,8 +188,8 @@
 /*	Modified :																*/
 /* ======================================================================== */
 
-AVCDec_Status	PVAVCDecSeqParamSet(AVCHandle *avcHandle, uint8 *nal_unit,
-                                  int nal_size)
+OSCL_EXPORT_REF AVCDec_Status	PVAVCDecSeqParamSet(AVCHandle *avcHandle, uint8 *nal_unit,
+        int nal_size)
 {
     AVCDec_Status status;
     AVCDecObject *decvid;
@@ -321,44 +321,44 @@
 /*	12/20/03:  change input argument, use structure instead.				*/
 /* ======================================================================== */
 
-AVCDec_Status PVAVCDecGetSeqInfo(AVCHandle *avcHandle, AVCDecSPSInfo *seqInfo)
+OSCL_EXPORT_REF AVCDec_Status PVAVCDecGetSeqInfo(AVCHandle *avcHandle, AVCDecSPSInfo *seqInfo)
 {
     AVCDecObject *decvid = (AVCDecObject*) avcHandle->AVCObject;
     AVCCommonObj *video;
     int PicWidthInMbs, PicHeightInMapUnits, FrameHeightInMbs;
 
-    if (decvid == NULL)
+    if (decvid == NULL || decvid->seqParams[0] == NULL)
     {
         return AVCDEC_FAIL;
     }
 
     video = decvid->common;
 
-    PicWidthInMbs = video->currSeqParams->pic_width_in_mbs_minus1 + 1;
-    PicHeightInMapUnits = video->currSeqParams->pic_height_in_map_units_minus1 + 1 ;
-    FrameHeightInMbs = (2 - video->currSeqParams->frame_mbs_only_flag) * PicHeightInMapUnits ;
+    PicWidthInMbs = decvid->seqParams[0]->pic_width_in_mbs_minus1 + 1;
+    PicHeightInMapUnits = decvid->seqParams[0]->pic_height_in_map_units_minus1 + 1 ;
+    FrameHeightInMbs = (2 - decvid->seqParams[0]->frame_mbs_only_flag) * PicHeightInMapUnits ;
 
     seqInfo->FrameWidth = PicWidthInMbs << 4;
     seqInfo->FrameHeight = FrameHeightInMbs << 4;
 
-    seqInfo->frame_only_flag = video->currSeqParams->frame_mbs_only_flag;
+    seqInfo->frame_only_flag = decvid->seqParams[0]->frame_mbs_only_flag;
 
-    if (video->currSeqParams->frame_cropping_flag)
+    if (decvid->seqParams[0]->frame_cropping_flag)
     {
-        seqInfo->frame_crop_left = 2 * video->currSeqParams->frame_crop_left_offset;
-        seqInfo->frame_crop_right = seqInfo->FrameWidth - (2 * video->currSeqParams->frame_crop_right_offset + 1);
+        seqInfo->frame_crop_left = 2 * decvid->seqParams[0]->frame_crop_left_offset;
+        seqInfo->frame_crop_right = seqInfo->FrameWidth - (2 * decvid->seqParams[0]->frame_crop_right_offset + 1);
 
         if (seqInfo->frame_only_flag)
         {
-            seqInfo->frame_crop_top = 2 * video->currSeqParams->frame_crop_top_offset;
-            seqInfo->frame_crop_bottom = seqInfo->FrameHeight - (2 * video->currSeqParams->frame_crop_bottom_offset + 1);
+            seqInfo->frame_crop_top = 2 * decvid->seqParams[0]->frame_crop_top_offset;
+            seqInfo->frame_crop_bottom = seqInfo->FrameHeight - (2 * decvid->seqParams[0]->frame_crop_bottom_offset + 1);
             /* Note in 7.4.2.1, there is a contraint on the value of frame_crop_left and frame_crop_top
             such that they have to be less than or equal to frame_crop_right/2 and frame_crop_bottom/2, respectively. */
         }
         else
         {
-            seqInfo->frame_crop_top = 4 * video->currSeqParams->frame_crop_top_offset;
-            seqInfo->frame_crop_bottom = seqInfo->FrameHeight - (4 * video->currSeqParams->frame_crop_bottom_offset + 1);
+            seqInfo->frame_crop_top = 4 * decvid->seqParams[0]->frame_crop_top_offset;
+            seqInfo->frame_crop_bottom = seqInfo->FrameHeight - (4 * decvid->seqParams[0]->frame_crop_bottom_offset + 1);
             /* Note in 7.4.2.1, there is a contraint on the value of frame_crop_left and frame_crop_top
             such that they have to be less than or equal to frame_crop_right/2 and frame_crop_bottom/4, respectively. */
         }
@@ -385,8 +385,8 @@
 /**
 Since PPS doesn't contain much data, most of the picture initialization will
 be done after decoding the slice header in PVAVCDecodeSlice. */
-AVCDec_Status	PVAVCDecPicParamSet(AVCHandle *avcHandle, uint8 *nal_unit,
-                                  int nal_size)
+OSCL_EXPORT_REF AVCDec_Status	PVAVCDecPicParamSet(AVCHandle *avcHandle, uint8 *nal_unit,
+        int nal_size)
 {
     AVCDec_Status status;
     AVCDecObject *decvid = (AVCDecObject*) avcHandle->AVCObject;
@@ -426,8 +426,8 @@
     return AVCDEC_SUCCESS;
 }
 
-AVCDec_Status	PVAVCDecSEI(AVCHandle *avcHandle, uint8 *nal_unit,
-                          int nal_size)
+OSCL_EXPORT_REF AVCDec_Status	PVAVCDecSEI(AVCHandle *avcHandle, uint8 *nal_unit,
+        int nal_size)
 {
     OSCL_UNUSED_ARG(avcHandle);
     OSCL_UNUSED_ARG(nal_unit);
@@ -480,8 +480,8 @@
 /*	Return   : See enum AVCDec_Status for return values.					*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCDec_Status PVAVCDecodeSlice(AVCHandle *avcHandle, uint8 *buffer,
-                               int buf_size)
+OSCL_EXPORT_REF AVCDec_Status PVAVCDecodeSlice(AVCHandle *avcHandle, uint8 *buffer,
+        int buf_size)
 {
     AVCDecObject *decvid = (AVCDecObject*) avcHandle->AVCObject;
     AVCCommonObj *video;
@@ -541,7 +541,7 @@
         BitstreamInit(bitstream, buffer + 1, buf_size - 1);
 
 
-        /* 2.1 Decode Slice Header (seperate function)*/
+        /* 2.1 Decode Slice Header (separate function)*/
         status = DecodeSliceHeader(decvid, video, bitstream);
         if (status != AVCDEC_SUCCESS)
         {
@@ -559,7 +559,7 @@
                 ConcealSlice(decvid, video->PicSizeInMbs - video->numMBs, video->PicSizeInMbs);  // Conceal
                 video->numMBs = 0;
 
-//				DeblockPicture(video);   // No need to deblock
+                //				DeblockPicture(video);   // No need to deblock
 
                 /* 3.2 Decoded frame reference marking. */
                 /* 3.3 Put the decoded picture in output buffers */
@@ -687,7 +687,7 @@
         if (video->nal_ref_idc == 0)
         {
             video->currPic->isReference = FALSE;
-            video->currFS->IsOutputted |= 0x02;		/* The MASK 0x02 means not needed for reference, or returned MC */
+            video->currFS->IsOutputted |= 0x02;		/* The MASK 0x02 means not needed for reference, or returned */
             /* node need to check for freeing of this buffer */
         }
 
@@ -770,7 +770,7 @@
 /*	Modified :																*/
 /* ======================================================================== */
 
-AVCDec_Status PVAVCDecGetOutput(AVCHandle *avcHandle, int *indx, int *release, AVCFrameIO *output)
+OSCL_EXPORT_REF AVCDec_Status PVAVCDecGetOutput(AVCHandle *avcHandle, int *indx, int *release, AVCFrameIO *output)
 {
     AVCDecObject *decvid = (AVCDecObject*) avcHandle->AVCObject;
     AVCCommonObj *video;
@@ -955,7 +955,7 @@
 /*	Return   :	void														*/
 /*	Modified :																*/
 /* ======================================================================== */
-void	PVAVCDecReset(AVCHandle *avcHandle)
+OSCL_EXPORT_REF void	PVAVCDecReset(AVCHandle *avcHandle)
 {
     AVCDecObject *decvid = (AVCDecObject*) avcHandle->AVCObject;
     AVCCommonObj *video;
@@ -993,6 +993,7 @@
     video->prevFrameNumOffset = 0;
     video->FrameNumOffset = 0;
     video->mbNum = 0;
+    video->numMBs = 0;
 
     return ;
 }
@@ -1007,7 +1008,7 @@
 /*	Modified :																*/
 /* ======================================================================== */
 
-void PVAVCCleanUpDecoder(AVCHandle *avcHandle)
+OSCL_EXPORT_REF void PVAVCCleanUpDecoder(AVCHandle *avcHandle)
 {
     AVCDecObject *decvid = (AVCDecObject*) avcHandle->AVCObject;
     AVCCommonObj *video;
diff --git a/codecs_v2/video/avc_h264/dec/src/avcdec_bitstream.h b/codecs_v2/video/avc_h264/dec/src/avcdec_bitstream.h
index e946202..0824737 100644
--- a/codecs_v2/video/avc_h264/dec/src/avcdec_bitstream.h
+++ b/codecs_v2/video/avc_h264/dec/src/avcdec_bitstream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/avcdec_int.h b/codecs_v2/video/avc_h264/dec/src/avcdec_int.h
index a0a0858..21f002a 100644
--- a/codecs_v2/video/avc_h264/dec/src/avcdec_int.h
+++ b/codecs_v2/video/avc_h264/dec/src/avcdec_int.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/avcdec_lib.h b/codecs_v2/video/avc_h264/dec/src/avcdec_lib.h
index b3458c9..f9df469 100644
--- a/codecs_v2/video/avc_h264/dec/src/avcdec_lib.h
+++ b/codecs_v2/video/avc_h264/dec/src/avcdec_lib.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/header.cpp b/codecs_v2/video/avc_h264/dec/src/header.cpp
index 3916088..28f678c 100644
--- a/codecs_v2/video/avc_h264/dec/src/header.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/header.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -973,7 +973,7 @@
                 i++;
             }
             while (sliceHdr->memory_management_control_operation[i-1] != 0 && i < MAX_DEC_REF_PIC_MARKING);
-            if (i == MAX_DEC_REF_PIC_MARKING && sliceHdr->memory_management_control_operation[i-1] != 0)
+            if (i >= MAX_DEC_REF_PIC_MARKING)
             {
                 return AVCDEC_FAIL; /* we're screwed!!, not enough memory */
             }
diff --git a/codecs_v2/video/avc_h264/dec/src/itrans.cpp b/codecs_v2/video/avc_h264/dec/src/itrans.cpp
index d5c4d9f..42eefbc 100644
--- a/codecs_v2/video/avc_h264/dec/src/itrans.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/itrans.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/pred_inter.cpp b/codecs_v2/video/avc_h264/dec/src/pred_inter.cpp
index 388c308..7302653 100644
--- a/codecs_v2/video/avc_h264/dec/src/pred_inter.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/pred_inter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@
         {
             block_x = (mbPartIdx_X << 1) + ((subMbPartIdx + offset_indx) & 1);  // check this
             block_y = (mbPartIdx_Y << 1) + (((subMbPartIdx + offset_indx) >> 1) & 1);
-            mv = &currMB->mvL0[0] + (block_x << 1) + (block_y << 3);
+            mv = (int16*)(currMB->mvL0 + block_x + (block_y << 2));
             offset_x = x_position + (block_x << 2);
             offset_y = y_position + (block_y << 2);
             x_pos = (offset_x << 2) + *mv++;   /*quarter pel */
@@ -370,13 +370,13 @@
     int offset, out_offset;
     uint32 prev_pix, result, pix1, pix2, pix4;
 
-    ref += y_pos * picwidth;// + x_pos;
     out_offset = 24 - blkwidth;
 
     //switch(x_pos&0x3){
     switch (((uint32)ref)&0x3)
     {
         case 1:
+            ref += y_pos * picwidth;
             offset =  picwidth - blkwidth - 3;
             for (j = 0; j < blkheight; j++)
             {
@@ -400,6 +400,7 @@
             }
             break;
         case 2:
+            ref += y_pos * picwidth;
             offset =  picwidth - blkwidth - 2;
             for (j = 0; j < blkheight; j++)
             {
@@ -420,6 +421,7 @@
             }
             break;
         case 3:
+            ref += y_pos * picwidth;
             offset =  picwidth - blkwidth - 1;
             for (j = 0; j < blkheight; j++)
             {
diff --git a/codecs_v2/video/avc_h264/dec/src/pred_intra.cpp b/codecs_v2/video/avc_h264/dec/src/pred_intra.cpp
index 739f26e..545bd72 100644
--- a/codecs_v2/video/avc_h264/dec/src/pred_intra.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/pred_intra.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/pvavcdecoder.cpp b/codecs_v2/video/avc_h264/dec/src/pvavcdecoder.cpp
index 4885179..7af2cd5 100644
--- a/codecs_v2/video/avc_h264/dec/src/pvavcdecoder.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/pvavcdecoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/pvavcdecoder_factory.cpp b/codecs_v2/video/avc_h264/dec/src/pvavcdecoder_factory.cpp
index b97ab58..60e7f6b 100644
--- a/codecs_v2/video/avc_h264/dec/src/pvavcdecoder_factory.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/pvavcdecoder_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
 #include "oscl_error_codes.h"
 #include "oscl_exception.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 
 OSCL_DLL_ENTRY_POINT_DEFAULT()
diff --git a/codecs_v2/video/avc_h264/dec/src/residual.cpp b/codecs_v2/video/avc_h264/dec/src/residual.cpp
index 391b624..937daae 100644
--- a/codecs_v2/video/avc_h264/dec/src/residual.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/residual.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/dec/src/slice.cpp b/codecs_v2/video/avc_h264/dec/src/slice.cpp
index 5ea0380..2390ca3 100644
--- a/codecs_v2/video/avc_h264/dec/src/slice.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/slice.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -626,7 +626,7 @@
     {
         InterpretMBModeI(mblock, mb_type - 5);
         /* set MV and Ref_Idx codes of Intra blocks in P-slices  */
-        oscl_memset(mblock->mvL0, 0, sizeof(int16)*32);
+        oscl_memset(mblock->mvL0, 0, sizeof(int32)*16);
         mblock->ref_idx_L0[0] = mblock->ref_idx_L0[1] = mblock->ref_idx_L0[2] = mblock->ref_idx_L0[3] = -1;
     }
     return ;
diff --git a/codecs_v2/video/avc_h264/dec/src/vlc.cpp b/codecs_v2/video/avc_h264/dec/src/vlc.cpp
index c653150..af8bbc4 100644
--- a/codecs_v2/video/avc_h264/dec/src/vlc.cpp
+++ b/codecs_v2/video/avc_h264/dec/src/vlc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/Android.mk b/codecs_v2/video/avc_h264/enc/Android.mk
index bd91367..bdbabdf 100644
--- a/codecs_v2/video/avc_h264/enc/Android.mk
+++ b/codecs_v2/video/avc_h264/enc/Android.mk
@@ -3,44 +3,46 @@
 
 LOCAL_SRC_FILES := \
 	src/avcenc_api.cpp \
-	src/bitstream_io.cpp \
-	src/block.cpp \
-	src/findhalfpel.cpp \
-	src/header.cpp \
-	src/init.cpp \
-	src/intra_est.cpp \
-	src/motion_comp.cpp \
-	src/motion_est.cpp \
-	src/pvavcencoder.cpp \
-	src/pvavcencoder_factory.cpp \
-	src/rate_control.cpp \
-	src/residual.cpp \
-	src/sad.cpp \
-	src/sad_halfpel.cpp \
-	src/slice.cpp \
-	src/vlc_encode.cpp
-
+ 	src/bitstream_io.cpp \
+ 	src/block.cpp \
+ 	src/findhalfpel.cpp \
+ 	src/header.cpp \
+ 	src/init.cpp \
+ 	src/intra_est.cpp \
+ 	src/motion_comp.cpp \
+ 	src/motion_est.cpp \
+ 	src/pvavcencoder.cpp \
+ 	src/pvavcencoder_factory.cpp \
+ 	src/rate_control.cpp \
+ 	src/residual.cpp \
+ 	src/sad.cpp \
+ 	src/sad_halfpel.cpp \
+ 	src/slice.cpp \
+ 	src/vlc_encode.cpp
 
 
 LOCAL_MODULE := libpvavch264enc
 
-LOCAL_CFLAGS := -D__arm__ -DYUV_INPUT -DRGB24_INPUT -DRGB12_INPUT  $(PV_CFLAGS)
+LOCAL_CFLAGS := -D__arm__ -DYUV_INPUT -DRGB24_INPUT -DRGB12_INPUT $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/video/avc_h264/enc/include \
-	$(PV_TOP)//codecs_v2/video/avc_h264/enc/src \
-	$(PV_TOP)/$(SDK_LOCAL)/installed_include \
-	$(PV_TOP)//codecs_v2/video/avc_h264/enc/../common/include \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/video/avc_h264/enc/src \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/enc/include \
+ 	$(PV_TOP)/codecs_v2/video/avc_h264/common/include \
+ 	$(PV_TOP)/codecs_v2/utilities/colorconvert/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvavcencoder.h \
-	include/pvavcencoder_factory.h \
-	include/pvavcencoderinterface.h
+ 	include/pvavcencoder_factory.h \
+ 	include/pvavcencoderinterface.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/video/avc_h264/enc/build/make/local.mk b/codecs_v2/video/avc_h264/enc/build/make/local.mk
new file mode 100644
index 0000000..71cd046
--- /dev/null
+++ b/codecs_v2/video/avc_h264/enc/build/make/local.mk
@@ -0,0 +1,49 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+
+TARGET := pvavch264enc
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS += -D__arm__ -DYUV_INPUT -DRGB24_INPUT -DRGB12_INPUT
+
+XINCDIRS += ../../../common/include  ../../../../../utilities/colorconvert/include
+
+XLIBDIRS += 
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := avcenc_api.cpp \
+	bitstream_io.cpp \
+	block.cpp \
+	findhalfpel.cpp \
+	header.cpp \
+	init.cpp \
+	intra_est.cpp \
+	motion_comp.cpp \
+	motion_est.cpp \
+	pvavcencoder.cpp \
+	pvavcencoder_factory.cpp \
+	rate_control.cpp \
+	residual.cpp \
+	sad.cpp \
+	sad_halfpel.cpp \
+	slice.cpp \
+	vlc_encode.cpp
+
+HDRS := pvavcencoder.h \
+       pvavcencoder_factory.h \
+       pvavcencoderinterface.h
+
+
+include $(MK)/library.mk
+
diff --git a/codecs_v2/video/avc_h264/enc/build/make/makefile b/codecs_v2/video/avc_h264/enc/build/make/makefile
deleted file mode 100644
index c2d787d..0000000
--- a/codecs_v2/video/avc_h264/enc/build/make/makefile
+++ /dev/null
@@ -1,78 +0,0 @@
-#Include the project-wide makefile to get
-# appropriate definitions
-
-include $(PV_TOP)/makefile.pv
-
-
-# BE CAREFUL NOT TO HAVE ANY TRAILING WHITESPACE FOR THE NEXT 3 LINES BELOW OR IT WILL NOT WORK!
-WHAT = library
-TARGET = pvavch264enc
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = "
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS = 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -Wall -g -DUSE_UNICODE -D_POSIX_PTHREAD_SEMANTICS
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DORIGINAL_TYPEDEF_H -DOSCL_BASE_H_INCLUDED -DOSCL_TYPES_H_INCLUDE -DOSCL_ASSERT_H_INCLUDED -DOSCL_MEM_BASIC_FUNCTIONS_H -DOSCL_MEM_IMP_H
-XCPPFLAGS += -D__arm__ -DYUV_INPUT -DRGB24_INPUT -DRGB12_INPUT
-
-# Use XINCDIRS for extra include directories. These should be proceeded
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS +=
-XINCDIRS += -I$(SDK_LOCAL)/installed_include
-XINCDIRS += -I../../../common/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded
-# with "-L" just as they would be when passing to the linker.
-# Used for building executables.
-#
-XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS +=
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  avcenc_api.cpp \
-	bitstream_io.cpp \
-	block.cpp \
-	findhalfpel.cpp \
-	header.cpp \
-	init.cpp \
-	intra_est.cpp \
-	motion_comp.cpp \
-	motion_est.cpp \
-	pvavcencoder.cpp \
-	pvavcencoder_factory.cpp \
-	rate_control.cpp \
-	residual.cpp \
-	sad.cpp \
-	sad_halfpel.cpp \
-	slice.cpp \
-	vlc_encode.cpp
-
-HDRS = pvavcencoder.h \
-       pvavcencoder_factory.h \
-       pvavcencoderinterface.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/codecs_v2/video/avc_h264/enc/include/pvavcencoder.h b/codecs_v2/video/avc_h264/enc/include/pvavcencoder.h
index 756e6cb..bd1f695 100644
--- a/codecs_v2/video/avc_h264/enc/include/pvavcencoder.h
+++ b/codecs_v2/video/avc_h264/enc/include/pvavcencoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,32 +26,35 @@
 #include "avcenc_api.h"
 #endif
 
+#include "ccrgb24toyuv420.h"
+#include "ccrgb12toyuv420.h"
+#include "ccyuv420semitoyuv420.h"
+
 /** AVC encoder class interface. See PVAVCEncoderInterface APIs for
 virtual functions definitions. */
 class PVAVCEncoder : public PVAVCEncoderInterface
 {
 
     public:
-        static PVAVCEncoder* New(void);
-        virtual ~PVAVCEncoder();
+        OSCL_IMPORT_REF static PVAVCEncoder* New(void);
+        OSCL_IMPORT_REF virtual ~PVAVCEncoder();
 
-        virtual TAVCEI_RETVAL Initialize(TAVCEIInputFormat* aVidInFormat, TAVCEIEncodeParam* aEncParam);
-        virtual TAVCEI_RETVAL Initialize(TAVCEIInputFormat *aVidInFormat, TAVCEIEncodeParam *aEncParam,
-                                         void* extSPS, void* extPPS);
-        virtual TAVCEI_RETVAL Encode(TAVCEIInputData* aVidIn);
-        virtual TAVCEI_RETVAL GetParameterSet(uint8* paramSet, int32* size, int* nalType);
-        virtual TAVCEI_RETVAL GetOutput(TAVCEIOutputData* aVidOut);
-        virtual TAVCEI_RETVAL FlushInput();
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL Initialize(TAVCEIInputFormat* aVidInFormat, TAVCEIEncodeParam* aEncParam);
+        OSCL_IMPORT_REF virtual int32 GetMaxOutputBufferSize();
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL Encode(TAVCEIInputData* aVidIn);
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL GetParameterSet(uint8* paramSet, int32* size, int* nalType);
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL GetOutput(TAVCEIOutputData* aVidOut, int *aRemainingBytes);
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL FlushInput();
         virtual TAVCEI_RETVAL CleanupEncoder();
 
-        virtual TAVCEI_RETVAL UpdateBitRate(int32* aBitRate);
-        virtual TAVCEI_RETVAL UpdateFrameRate(OsclFloat* aFrameRate);
-        virtual TAVCEI_RETVAL UpdateIDRFrameInterval(int32 aIFrameInterval);
-        virtual TAVCEI_RETVAL IDRRequest();
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL UpdateBitRate(int32* aBitRate);
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL UpdateFrameRate(OsclFloat* aFrameRate);
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL UpdateIDRFrameInterval(int32 aIFrameInterval);
+        OSCL_IMPORT_REF virtual TAVCEI_RETVAL IDRRequest();
 
-        virtual int32 GetEncodeWidth(int32 aLayer);
-        virtual int32 GetEncodeHeight(int32 aLayer);
-        virtual OsclFloat GetEncodeFrameRate(int32 aLayer);
+        OSCL_IMPORT_REF virtual int32 GetEncodeWidth(int32 aLayer);
+        OSCL_IMPORT_REF virtual int32 GetEncodeHeight(int32 aLayer);
+        OSCL_IMPORT_REF virtual OsclFloat GetEncodeFrameRate(int32 aLayer);
 
         /* for avc encoder lib callback functions */
         int		AVC_DPBAlloc(uint frame_size_in_mbs, uint num_buffers);
@@ -67,17 +70,10 @@
 #ifdef	YUV_INPUT
         void CopyToYUVIn(uint8* YUV, int width, int height, int width_16, int height_16);
 #endif
-        /* RGB->YUV conversion */
-#if defined(RGB12_INPUT)||defined(RGB24_INPUT)
-        bool initRGB2YUVTables();
-        void freeRGB2YUVTables();
-#endif
-        //void RGB2YUV420_12bit(uint16 *inputRGB, int width, int height,int width_16,int height_16);
-#ifdef RGB12_INPUT
-        void RGB2YUV420_12bit(uint32* inputRGB, int width, int height, int width_16, int height_16);
-#endif
-#ifdef RGB24_INPUT
-        void RGB2YUV420_24bit(uint8* inputRGB, int width, int height, int width_16, int height_16);
+
+        /** Color conversion instance RGB24/RGB12/YUV420SEMI to YUV 420 */
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
+        ColorConvertBase *ccRGBtoYUV;
 #endif
 
 #ifdef FOR_3GPP_COMPLIANCE
@@ -116,6 +112,9 @@
         uint8*	iVideoOut;
         uint32	iTimeStamp;
         uint32  iPacketSize;
+        uint8*	iOverrunBuffer;
+        int		iOBSize;
+        AVCEnc_Status iEncStatus;
         bool	iIDR;
         int		iDispOrd;
 
diff --git a/codecs_v2/video/avc_h264/enc/include/pvavcencoder_factory.h b/codecs_v2/video/avc_h264/enc/include/pvavcencoder_factory.h
index f5e09b8..681806a 100644
--- a/codecs_v2/video/avc_h264/enc/include/pvavcencoder_factory.h
+++ b/codecs_v2/video/avc_h264/enc/include/pvavcencoder_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/include/pvavcencoderinterface.h b/codecs_v2/video/avc_h264/enc/include/pvavcencoderinterface.h
index d1a361d..9058e55 100644
--- a/codecs_v2/video/avc_h264/enc/include/pvavcencoderinterface.h
+++ b/codecs_v2/video/avc_h264/enc/include/pvavcencoderinterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,8 @@
     EAVCEI_INPUT_ERROR, // error with input buffers
 
     /** GetOutput return values */
-    EAVCEI_MORE_DATA,  // there are more data to be retrieve
+    EAVCEI_MORE_DATA,  // there are more data to be retrieve (multiple fragments of a NAL)
+    EAVCEI_MORE_NAL		// there is more NAL to be retrieved
 
 } ;
 
@@ -46,7 +47,8 @@
     EAVCEI_VDOFMT_RGB24,
     EAVCEI_VDOFMT_RGB12,
     EAVCEI_VDOFMT_YUV420,
-    EAVCEI_VDOFMT_UYVY
+    EAVCEI_VDOFMT_UYVY,
+    EAVCEI_VDOFMT_YUV420SEMIPLANAR
 };
 
 /** Type of contents for optimal encoding mode. */
@@ -227,6 +229,12 @@
     /** Specifies the duration of the clip in millisecond, needed for VBR encode. Set to 0 if unknown.*/
     int32				iClipDuration;
 
+    /** Specify FSI Buffer input */
+    uint8*				iFSIBuff;
+
+    /** Specify FSI Buffer Length */
+    int					iFSIBuffLength;
+
 };
 
 
@@ -306,16 +314,10 @@
         \return  fail if there is any errors. Otherwise, the function returns success.*/
         virtual  TAVCEI_RETVAL Initialize(TAVCEIInputFormat* aVidInFormat, TAVCEIEncodeParam* aEncParam) = 0;
 
-        /** \brief Alternative initialization function to set the input video format and the
-        encoding parameters using external sequence parameter set (SPS) and picture parameter set (PPS). The
-        exact structure  of SPS and PPS must be known by the app.
-        \parm  aVidInFormat contains input related attributes.
-        \parm  aEncParam contains encoding parameters setting.
-        \parm  extSPS contains PV's SPS structure.
-        \parm  extPPS contains PV's PPS structure.
-        \return  fail if there is any errors. Otherwise, the function returns success.*/
-        virtual  TAVCEI_RETVAL Initialize(TAVCEIInputFormat *aVidInFormat, TAVCEIEncodeParam *aEncParam,
-                                          void* extSPS, void* extPPS) = 0;
+
+        /** \brief Get suggested output buffer size to be allocated such that no frames are dropped.
+        \return  Size to be allocated. 0 means the encoder is not initialized. */
+        virtual  int32 GetMaxOutputBufferSize() = 0;
 
         /** \brief This function sends in an input video data structure containing a source
         frame and the associated timestamp. It can start processing such as frame analysis, decision to
@@ -337,7 +339,7 @@
         /** \brief This function returns a compressed bitstream.
         \parm	aVidOut is the structure to contain the output information.
         \return	one of these, SUCCESS, MORE_DATA, NOT_READY, INPUT_ERROR, FAIL */
-        virtual  TAVCEI_RETVAL GetOutput(TAVCEIOutputData* aVidOut) = 0;
+        virtual  TAVCEI_RETVAL GetOutput(TAVCEIOutputData* aVidOut, int *aRemainingBytes) = 0;
 
         /** This function is used to flush all the unencoded frames store inside the encoder (if there exist).
         It is used for random re-positioning. Or free all the input. Note that if users want to flush output
diff --git a/codecs_v2/video/avc_h264/enc/src/avcenc_api.cpp b/codecs_v2/video/avc_h264/enc/src/avcenc_api.cpp
index 14ad8af..3e875d4 100644
--- a/codecs_v2/video/avc_h264/enc/src/avcenc_api.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/avcenc_api.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,8 +28,8 @@
 /*	Return   : AVCENC_SUCCESS if succeed, AVCENC_FAIL if fail.				*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCEnc_Status PVAVCEncGetNALType(unsigned char *bitstream, int size,
-                                 int *nal_type, int *nal_ref_idc)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncGetNALType(unsigned char *bitstream, int size,
+        int *nal_type, int *nal_ref_idc)
 {
     int forbidden_zero_bit;
     if (size > 0)
@@ -55,8 +55,8 @@
 /*	Return   : AVCENC_SUCCESS for success.									*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCEnc_Status PVAVCEncInitialize(AVCHandle *avcHandle, AVCEncParams *encParam,
-                                 void* extSPS, void* extPPS)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncInitialize(AVCHandle *avcHandle, AVCEncParams *encParam,
+        void* extSPS, void* extPPS)
 {
     AVCEnc_Status status;
     AVCEncObject *encvid;
@@ -100,6 +100,7 @@
     {
         return AVCENC_MEMORY_FAIL;
     }
+    encvid->bitstream->encvid = encvid; /* to point back for reallocation */
 
     /* allocate sequence parameter set structure */
     video->currSeqParams = (AVCSeqParamSet*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCSeqParamSet), DEFAULT_ATTR);
@@ -155,6 +156,26 @@
         return status;
     }
 
+    if (encParam->use_overrun_buffer == AVC_ON)
+    {
+        /* allocate overrun buffer */
+        encvid->oBSize = encvid->rateCtrl->cpbSize;
+        if (encvid->oBSize > DEFAULT_OVERRUN_BUFFER_SIZE)
+        {
+            encvid->oBSize = DEFAULT_OVERRUN_BUFFER_SIZE;
+        }
+        encvid->overrunBuffer = (uint8*) avcHandle->CBAVC_Malloc(userData, encvid->oBSize, DEFAULT_ATTR);
+        if (encvid->overrunBuffer == NULL)
+        {
+            return AVCENC_MEMORY_FAIL;
+        }
+    }
+    else
+    {
+        encvid->oBSize = 0;
+        encvid->overrunBuffer = NULL;
+    }
+
     /* allocate frame size dependent structures */
     framesize = video->FrameHeightInMbs * video->PicWidthInMbs;
 
@@ -231,6 +252,30 @@
 }
 
 /* ======================================================================== */
+/*	Function : PVAVCEncGetMaxOutputSize()							        */
+/*	Date     : 11/29/2008													*/
+/*	Purpose  : Return max output buffer size that apps should allocate for  */
+/*				output buffer.												*/
+/*	In/out   :																*/
+/*	Return   : AVCENC_SUCCESS for success.									*/
+/*	Modified :	 size														*/
+/* ======================================================================== */
+
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncGetMaxOutputBufferSize(AVCHandle *avcHandle, int* size)
+{
+    AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
+
+    if (encvid == NULL)
+    {
+        return AVCENC_UNINITIALIZED;
+    }
+
+    *size = encvid->rateCtrl->cpbSize;
+
+    return AVCENC_SUCCESS;
+}
+
+/* ======================================================================== */
 /*	Function : PVAVCEncSetInput()											*/
 /*	Date     : 4/18/2004													*/
 /*	Purpose  : To feed an unencoded original frame to the encoder library.	*/
@@ -238,7 +283,7 @@
 /*	Return   : AVCENC_SUCCESS for success.									*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCEnc_Status PVAVCEncSetInput(AVCHandle *avcHandle, AVCFrameIO *input)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncSetInput(AVCHandle *avcHandle, AVCFrameIO *input)
 {
     AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
     AVCCommonObj *video = encvid->common;
@@ -275,17 +320,6 @@
         return AVCENC_SKIPPED_PICTURE; /* not time to encode, thus skipping */
     }
 
-    if (video->nal_unit_type == AVC_NALTYPE_IDR)
-    {
-        /* no need to set sliceHdr->frame_num here, it's done in InitFrame */
-
-        /* flexible macroblock ordering */
-        /* populate video->mapUnitToSliceGroupMap and video->MbToSliceGroupMap */
-        /* It changes once per each PPS. */
-
-        FMOInit(video);
-    }
-
     /* we may not need this line */
     //nextFrmModTime = (uint32)((((frameNum+1)*1000)/rateCtrl->frame_rate) + modTimeRef); /* rec. time */
     //encvid->nextModTime = nextFrmModTime - (encvid->frameInterval>>1) - 1; /* between current and next frame */
@@ -310,8 +344,8 @@
         else // assuming that in-band paramset keeps sending new SPS and PPS.
         {
             encvid->enc_state = AVCEnc_Encoding_SPS;
-            video->currSeqParams->seq_parameter_set_id++;
-            if (video->currSeqParams->seq_parameter_set_id > 31) // range check
+            //video->currSeqParams->seq_parameter_set_id++;
+            //if(video->currSeqParams->seq_parameter_set_id > 31) // range check
             {
                 video->currSeqParams->seq_parameter_set_id = 0;  // reset
             }
@@ -341,7 +375,7 @@
 /*	Return   : AVCENC_SUCCESS for success.									*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCEnc_Status PVAVCEncodeNAL(AVCHandle *avcHandle, unsigned char *buffer, unsigned int *buf_nal_size, int *nal_type)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncodeNAL(AVCHandle *avcHandle, unsigned char *buffer, unsigned int *buf_nal_size, int *nal_type)
 {
     AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
     AVCCommonObj *video = encvid->common;
@@ -359,8 +393,8 @@
             return AVCENC_UNINITIALIZED;
         case AVCEnc_Encoding_SPS:
             /* initialized the structure */
-            buffer[0] = (1 << 5) | AVC_NALTYPE_SPS;
-            BitstreamEncInit(bitstream, buffer + 1, *buf_nal_size - 1);
+            BitstreamEncInit(bitstream, buffer, *buf_nal_size, NULL, 0);
+            BitstreamWriteBits(bitstream, 8, (1 << 5) | AVC_NALTYPE_SPS);
 
             /* encode SPS */
             status = EncodeSPS(encvid, bitstream);
@@ -377,13 +411,13 @@
                 video->currPicParams->seq_parameter_set_id = video->currSeqParams->seq_parameter_set_id;
                 video->currPicParams->pic_parameter_set_id++;
                 *nal_type = AVC_NALTYPE_SPS;
-                *buf_nal_size = bitstream->write_pos + 1;
+                *buf_nal_size = bitstream->write_pos;
             }
             break;
         case AVCEnc_Encoding_PPS:
             /* initialized the structure */
-            buffer[0] = (1 << 5) | AVC_NALTYPE_PPS;
-            BitstreamEncInit(bitstream, buffer + 1, *buf_nal_size - 1);
+            BitstreamEncInit(bitstream, buffer, *buf_nal_size, NULL, 0);
+            BitstreamWriteBits(bitstream, 8, (1 << 5) | AVC_NALTYPE_PPS);
 
             /* encode PPS */
             status = EncodePPS(encvid, bitstream);
@@ -406,14 +440,14 @@
                 }
 
                 *nal_type = AVC_NALTYPE_PPS;
-                *buf_nal_size = bitstream->write_pos + 1;
+                *buf_nal_size = bitstream->write_pos;
             }
             break;
 
         case AVCEnc_Encoding_Frame:
             /* initialized the structure */
-            buffer[0] = (video->nal_ref_idc << 5) | (video->nal_unit_type);
-            BitstreamEncInit(bitstream, buffer + 1, *buf_nal_size - 1);
+            BitstreamEncInit(bitstream, buffer, *buf_nal_size, encvid->overrunBuffer, encvid->oBSize);
+            BitstreamWriteBits(bitstream, 8, (video->nal_ref_idc << 5) | (video->nal_unit_type));
 
             /* Re-order the reference list according to the ref_pic_list_reordering() */
             /* We don't have to reorder the list for the encoder here. This can only be done
@@ -440,7 +474,7 @@
             /* closing the NAL with trailing bits */
             BitstreamTrailingBits(bitstream, buf_nal_size);
 
-            *buf_nal_size = bitstream->write_pos + 1;
+            *buf_nal_size = bitstream->write_pos;
 
             encvid->rateCtrl->numFrameBits += ((*buf_nal_size) << 3);
 
@@ -451,7 +485,7 @@
                 status = RCUpdateFrame(encvid);
                 if (status == AVCENC_SKIPPED_PICTURE) /* skip current frame */
                 {
-                    video->currFS->IsOutputted = 3; // return this buffer.
+                    DPBReleaseCurrentFrame(avcHandle, video);
                     encvid->enc_state = AVCEnc_Analyzing_Frame;
 
                     return status;
@@ -487,6 +521,30 @@
 }
 
 /* ======================================================================== */
+/*	Function : PVAVCEncGetOverrunBuffer()									*/
+/*	Purpose  : To retrieve the overrun buffer. Check whether overrun buffer */
+/*				is used or not before returning								*/
+/*	In/out   :																*/
+/*	Return   : Pointer to the internal overrun buffer.						*/
+/*	Modified :																*/
+/* ======================================================================== */
+OSCL_EXPORT_REF uint8* PVAVCEncGetOverrunBuffer(AVCHandle* avcHandle)
+{
+    AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
+    AVCEncBitstream *bitstream = encvid->bitstream;
+
+    if (bitstream->overrunBuffer == bitstream->bitstreamBuffer) /* OB is used */
+    {
+        return encvid->overrunBuffer;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+
+/* ======================================================================== */
 /*	Function : PVAVCEncGetRecon()											*/
 /*	Date     : 4/29/2004													*/
 /*	Purpose  : To retrieve the most recently encoded frame.					*/
@@ -499,7 +557,7 @@
 /*	Return   : AVCENC_SUCCESS for success.									*/
 /*	Modified :																*/
 /* ======================================================================== */
-AVCEnc_Status PVAVCEncGetRecon(AVCHandle *avcHandle, AVCFrameIO *recon)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncGetRecon(AVCHandle *avcHandle, AVCFrameIO *recon)
 {
     AVCEncObject *encvid = (AVCEncObject*)avcHandle->AVCObject;
     AVCCommonObj *video = encvid->common;
@@ -524,7 +582,7 @@
     return AVCENC_SUCCESS;
 }
 
-AVCEnc_Status PVAVCEncReleaseRecon(AVCHandle *avcHandle, AVCFrameIO *recon)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncReleaseRecon(AVCHandle *avcHandle, AVCFrameIO *recon)
 {
     OSCL_UNUSED_ARG(avcHandle);
     OSCL_UNUSED_ARG(recon);
@@ -540,7 +598,7 @@
 /*	Return   : AVCENC_SUCCESS for success.									*/
 /*	Modified :																*/
 /* ======================================================================== */
-void	PVAVCCleanUpEncoder(AVCHandle *avcHandle)
+OSCL_EXPORT_REF void	PVAVCCleanUpEncoder(AVCHandle *avcHandle)
 {
     AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
     AVCCommonObj *video;
@@ -577,6 +635,11 @@
             avcHandle->CBAVC_Free(userData, (int)encvid->rateCtrl);
         }
 
+        if (encvid->overrunBuffer)
+        {
+            avcHandle->CBAVC_Free(userData, (int)encvid->overrunBuffer);
+        }
+
         video = encvid->common;
         if (video != NULL)
         {
@@ -621,11 +684,14 @@
         }
 
         avcHandle->CBAVC_Free(userData, (int)encvid);
+
+        avcHandle->AVCObject = NULL;
     }
+
     return ;
 }
 
-AVCEnc_Status PVAVCEncUpdateBitRate(AVCHandle *avcHandle, uint32 bitrate)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateBitRate(AVCHandle *avcHandle, uint32 bitrate)
 {
     OSCL_UNUSED_ARG(avcHandle);
     OSCL_UNUSED_ARG(bitrate);
@@ -633,7 +699,7 @@
     return AVCENC_FAIL;
 }
 
-AVCEnc_Status PVAVCEncUpdateFrameRate(AVCHandle *avcHandle, uint32 num, uint32 denom)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateFrameRate(AVCHandle *avcHandle, uint32 num, uint32 denom)
 {
     OSCL_UNUSED_ARG(avcHandle);
     OSCL_UNUSED_ARG(num);
@@ -642,7 +708,7 @@
     return AVCENC_FAIL;
 }
 
-AVCEnc_Status PVAVCEncUpdateIDRInterval(AVCHandle *avcHandle, int IDRInterval)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateIDRInterval(AVCHandle *avcHandle, int IDRInterval)
 {
     OSCL_UNUSED_ARG(avcHandle);
     OSCL_UNUSED_ARG(IDRInterval);
@@ -650,14 +716,14 @@
     return AVCENC_FAIL;
 }
 
-AVCEnc_Status PVAVCEncIDRRequest(AVCHandle *avcHandle)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncIDRRequest(AVCHandle *avcHandle)
 {
     OSCL_UNUSED_ARG(avcHandle);
 
     return AVCENC_FAIL;
 }
 
-AVCEnc_Status PVAVCEncUpdateIMBRefresh(AVCHandle *avcHandle, int numMB)
+OSCL_EXPORT_REF AVCEnc_Status PVAVCEncUpdateIMBRefresh(AVCHandle *avcHandle, int numMB)
 {
     OSCL_UNUSED_ARG(avcHandle);
     OSCL_UNUSED_ARG(numMB);
@@ -670,12 +736,11 @@
     AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
     AVCRateControl *rateCtrl = encvid->rateCtrl;
 
-    avcStats->avgFrameQP = rateCtrl->PAveFrameQP;
+    avcStats->avgFrameQP = GetAvgFrameQP(rateCtrl);
     avcStats->numIntraMBs = encvid->numIntraMB;
-    avcStats->numDetected = encvid->numDetected;
-    avcStats->numFalseAlarm = encvid->numFalseAlarm;
-    avcStats->numMisDetected = encvid->numMisDetected;
 
     return ;
 }
 
+
+
diff --git a/codecs_v2/video/avc_h264/enc/src/avcenc_api.h b/codecs_v2/video/avc_h264/enc/src/avcenc_api.h
index c7f24c9..4b76b23 100644
--- a/codecs_v2/video/avc_h264/enc/src/avcenc_api.h
+++ b/codecs_v2/video/avc_h264/enc/src/avcenc_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,10 @@
 #ifndef AVCENC_API_H_INCLUDED
 #define AVCENC_API_H_INCLUDED
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #ifndef OSCL_TYPES_H_INCLUDED
 #include "oscl_types.h"
 #endif
@@ -157,6 +161,8 @@
 
     AVCFlag out_of_band_param_set; /* flag to set whether param sets are to be retrieved up front or not */
 
+    AVCFlag use_overrun_buffer;  /* do not throw away the frame if output buffer is not big enough.
+									copy excess bits to the overrun buffer */
 } AVCEncParams;
 
 
@@ -193,7 +199,22 @@
     		 AVCENC_MEMORY_FAIL for memory allocation failure,
     		 AVCENC_FAIL for generic failure."
     */
-    AVCEnc_Status PVAVCEncInitialize(AVCHandle *avcHandle, AVCEncParams *encParam, void* extSPS, void* extPPS);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncInitialize(AVCHandle *avcHandle, AVCEncParams *encParam, void* extSPS, void* extPPS);
+
+
+    /**
+    Since the output buffer size is not known prior to encoding a frame, users need to
+    allocate big enough buffer otherwise, that frame will be dropped. This function returns
+    the size of the output buffer to be allocated by the users that guarantees to hold one frame.
+    It follows the CPB spec for a particular level.  However, when the users set use_overrun_buffer
+    flag, this API is useless as excess output bits are saved in the overrun buffer waiting to be
+    copied out in small chunks, i.e. users can allocate any size of output buffer.
+    \param "avcHandle"	"Handle to the AVC encoder library object."
+    \param "size"	"Pointer to the size to be modified."
+    \return "AVCENC_SUCCESS for success, AVCENC_UNINITIALIZED when level is not known.
+    */
+
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncGetMaxOutputBufferSize(AVCHandle *avcHandle, int* size);
 
     /**
     Users call this function to provide an input structure to the encoder library which will keep
@@ -210,7 +231,7 @@
     		AVCENC_NO_PICTURE if the input frame coding timestamp is too early, users must
     		get next frame or adjust the coding timestamp."
     */
-    AVCEnc_Status PVAVCEncSetInput(AVCHandle *avcHandle, AVCFrameIO *input);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncSetInput(AVCHandle *avcHandle, AVCFrameIO *input);
 
     /**
     This function is called to encode a NAL unit which can be an SPS NAL, a PPS NAL or
@@ -229,7 +250,7 @@
     		 AVCENC_PICTURE_READY for the completion of a frame encoding,
     		 AVCENC_FAIL for failure (this should not occur, though)."
     */
-    AVCEnc_Status PVAVCEncodeNAL(AVCHandle *avcHandle, uint8 *buffer, uint *buf_nal_size, int *nal_type);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncodeNAL(AVCHandle *avcHandle, uint8 *buffer, uint *buf_nal_size, int *nal_type);
 
     /**
     This function sniffs the nal_unit_type such that users can call corresponding APIs.
@@ -239,7 +260,15 @@
     \param "nal_unit_type" "Pointer to the return value of nal unit type."
     \return	"AVCENC_SUCCESS if success, AVCENC_FAIL otherwise."
     */
-    AVCEnc_Status PVAVCEncGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncGetNALType(uint8 *bitstream, int size, int *nal_type, int *nal_ref_idc);
+
+    /**
+    This function returns the pointer to internal overrun buffer. Users can call this to query
+    whether the overrun buffer has been used to encode the current NAL.
+    \param "avcHandle"	"Pointer to the handle."
+    \return "Pointer to overrun buffer if it is used, otherwise, NULL."
+    */
+    OSCL_IMPORT_REF uint8* PVAVCEncGetOverrunBuffer(AVCHandle* avcHandle);
 
     /**
     This function returns the reconstructed frame of the most recently encoded frame.
@@ -249,7 +278,7 @@
     \param "output"		"Pointer to the input structure."
     \return "AVCENC_SUCCESS for success, AVCENC_NO_PICTURE if no picture to be outputted."
     */
-    AVCEnc_Status PVAVCEncGetRecon(AVCHandle *avcHandle, AVCFrameIO *recon);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncGetRecon(AVCHandle *avcHandle, AVCFrameIO *recon);
 
     /**
     This function is used to return the recontructed frame back to the AVC encoder library
@@ -261,7 +290,7 @@
     \param "output"		 "Pointer to the AVCFrameIO structure."
     \return "AVCENC_SUCCESS for success, AVCENC_FAIL for fail for id not found."
     */
-    AVCEnc_Status PVAVCEncReleaseRecon(AVCHandle *avcHandle, AVCFrameIO *recon);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncReleaseRecon(AVCHandle *avcHandle, AVCFrameIO *recon);
 
     /**
     This function performs clean up operation including memory deallocation.
@@ -270,8 +299,7 @@
     and free them accordingly.
     \param "avcHandle"	"Handle to the AVC encoder library object."
     */
-    void	PVAVCCleanUpEncoder(AVCHandle *avcHandle);
-
+    OSCL_IMPORT_REF void	PVAVCCleanUpEncoder(AVCHandle *avcHandle);
 
     /**
     This function extracts statistics of the current frame. If the encoder has not finished
@@ -282,16 +310,15 @@
     */
     void PVAVCEncGetFrameStats(AVCHandle *avcHandle, AVCEncFrameStats *avcStats);
 
-
     /**
     These functions are used for the modification of encoding parameters.
     To be polished.
     */
-    AVCEnc_Status PVAVCEncUpdateBitRate(AVCHandle *avcHandle, uint32 bitrate);
-    AVCEnc_Status PVAVCEncUpdateFrameRate(AVCHandle *avcHandle, uint32 num, uint32 denom);
-    AVCEnc_Status PVAVCEncUpdateIDRInterval(AVCHandle *avcHandle, int IDRInterval);
-    AVCEnc_Status PVAVCEncIDRRequest(AVCHandle *avcHandle);
-    AVCEnc_Status PVAVCEncUpdateIMBRefresh(AVCHandle *avcHandle, int numMB);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateBitRate(AVCHandle *avcHandle, uint32 bitrate);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateFrameRate(AVCHandle *avcHandle, uint32 num, uint32 denom);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateIDRInterval(AVCHandle *avcHandle, int IDRInterval);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncIDRRequest(AVCHandle *avcHandle);
+    OSCL_IMPORT_REF AVCEnc_Status PVAVCEncUpdateIMBRefresh(AVCHandle *avcHandle, int numMB);
 
 
 #ifdef __cplusplus
diff --git a/codecs_v2/video/avc_h264/enc/src/avcenc_int.h b/codecs_v2/video/avc_h264/enc/src/avcenc_int.h
index 2a3c1ee..f0057a5 100644
--- a/codecs_v2/video/avc_h264/enc/src/avcenc_int.h
+++ b/codecs_v2/video/avc_h264/enc/src/avcenc_int.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,11 @@
 /* for sub-pel search and interpolation */
 #define SUBPEL_PRED_BLK_SIZE 576 // 24x24
 #define REF_CENTER 75
+#define V2Q_H0Q 1
+#define V0Q_H2Q 2
+#define V2Q_H2Q 3
+
+/*
 #define V3Q_H0Q 1
 #define V3Q_H1Q 2
 #define V0Q_H1Q 3
@@ -74,6 +79,10 @@
 #define V3Q_H2Q 13
 #define V0Q_H2Q 14
 #define V1Q_H2Q 15
+*/
+
+
+#define DEFAULT_OVERRUN_BUFFER_SIZE 1000
 
 // associated with the above cost model
 const uint8 COEFF_COST[2][16] =
@@ -125,6 +134,10 @@
     int count_zeros;   /* count number of consecutive zero */
     uint current_word;	/* byte-swapped (MSB left) current word to write to buffer */
     int bit_left;      /* number of bit left in current_word */
+    uint8   *overrunBuffer;  /* extra output buffer to prevent current skip due to output buffer overrun*/
+    int		oBSize;		/* size of allocated overrun buffer */
+    void   *encvid; /* pointer to the main object */
+
 } AVCEncBitstream;
 
 /**
@@ -133,6 +146,70 @@
 should be in this structure.
 @publishedAll
 */
+
+
+typedef struct tagRDInfo
+{
+    int QP;
+    int actual_bits;
+    OsclFloat mad;
+    OsclFloat R_D;
+} RDInfo;
+
+typedef struct tagMultiPass
+{
+    /* multipass rate control data */
+    int target_bits;	/* target bits for current frame, = rc->T */
+    int actual_bits;	/* actual bits for current frame obtained after encoding, = rc->Rc*/
+    int QP;				/* quantization level for current frame, = rc->Qc*/
+    int prev_QP;		/* quantization level for previous frame */
+    int prev_prev_QP;	/* quantization level for previous frame before last*/
+    OsclFloat mad;			/* mad for current frame, = video->avgMAD*/
+    int bitrate;		/* bitrate for current frame */
+    OsclFloat framerate;	/* framerate for current frame*/
+
+    int nRe_Quantized;	/* control variable for multipass encoding, */
+    /* 0 : first pass */
+    /* 1 : intermediate pass(quantization and VLC loop only) */
+    /* 2 : final pass(de-quantization, idct, etc) */
+    /* 3 : macroblock level rate control */
+
+    int encoded_frames;		/* counter for all encoded frames */
+    int re_encoded_frames;	/* counter for all multipass encoded frames*/
+    int re_encoded_times;	/* counter for all times of multipass frame encoding */
+
+    /* Multiple frame prediction*/
+    RDInfo **pRDSamples;		/* pRDSamples[30][32], 30->30fps, 32 -> 5 bit quantizer, 32 candidates*/
+    int framePos;				/* specific position in previous multiple frames*/
+    int frameRange;				/* number of overall previous multiple frames */
+    int samplesPerFrame[30];	/* number of samples per frame, 30->30fps */
+
+    /* Bit allocation for scene change frames and high motion frames */
+    OsclFloat sum_mad;
+    int counter_BTsrc;	/* BT = Bit Transfer, bit transfer from low motion frames or less complicatedly compressed frames */
+    int counter_BTdst;	/* BT = Bit Transfer, bit transfer to scene change frames or high motion frames or more complicatedly compressed frames */
+    OsclFloat sum_QP;
+    int diff_counter;	/* diff_counter = -diff_counter_BTdst, or diff_counter_BTsrc */
+
+    /* For target bitrate or framerate update */
+    OsclFloat target_bits_per_frame;		/* = C = bitrate/framerate */
+    OsclFloat target_bits_per_frame_prev;	/* previous C */
+    OsclFloat aver_mad;						/* so-far average mad could replace sum_mad */
+    OsclFloat aver_mad_prev;				/* previous average mad */
+    int   overlapped_win_size;			/* transition period of time */
+    int   encoded_frames_prev;			/* previous encoded_frames */
+} MultiPass;
+
+
+typedef struct tagdataPointArray
+{
+    int Qp;
+    int Rp;
+    OsclFloat Mp;	/* for MB-based RC */
+    struct tagdataPointArray *next;
+    struct tagdataPointArray *prev;
+} dataPointArray;
+
 typedef struct tagAVCRateControl
 {
 
@@ -171,80 +248,71 @@
     int lambda_mf; /* for example */
     int totalSAD;	 /* SAD of current frame */
 
-    /* rate control variables according to JVT document K-049 */
-    /* just take the variable names first. after it's working, cleanup names later */
+    /*******************************************/
+    /* this part comes from MPEG4 rate control */
+    int alpha;	/* weight for I frame */
+    int	Rs; 	/*bit rate for the sequence (or segment) e.g., 24000 bits/sec */
+    int Rc;		/*bits used for the current frame. It is the bit count obtained after encoding. */
+    int Rp;		/*bits to be removed from the buffer per picture. */
+    /*? is this the average one, or just the bits coded for the previous frame */
+    int Rps;	/*bit to be removed from buffer per src frame */
+    OsclFloat Ts; 	/*number of seconds for the sequence  (or segment). e.g., 10 sec */
+    OsclFloat Ep;
+    OsclFloat Ec;	/*mean absolute difference for the current frame after motion compensation.*/
+    /*If the macroblock is intra coded, the original spatial pixel values are summed.*/
+    int Qc;		/*quantization level used for the current frame. */
+    int Nr;		/*number of P frames remaining for encoding.*/
+    int Rr;	/*number of bits remaining for encoding this sequence (or segment).*/
+    int Rr_Old;
+    int T;		/*target bit to be used for the current frame.*/
+    int S;		/*number of bits used for encoding the previous frame.*/
+    int Hc;	/*header and motion vector bits used in the current frame. It includes all the 	information except to the residual information.*/
+    int Hp;	/*header and motion vector bits used in the previous frame. It includes all the 	information except to the residual information.*/
+    int Ql;	/*quantization level used in the previous frame */
+    int Bs;	/*buffer size e.g., R/2 */
+    int B;		/*current buffer level e.g., R/4 - start from the middle of the buffer */
+    OsclFloat X1;
+    OsclFloat X2;
+    OsclFloat X11;
+    OsclFloat M;			/*safe margin for the buffer */
+    OsclFloat smTick;	 /*ratio of src versus enc frame rate */
+    double remnant;	 /*remainder frame of src/enc frame for fine frame skipping */
+    int timeIncRes;	/* vol->timeIncrementResolution */
 
-    int NumberofCodedPFrame;
-    int NumberofGOP;
-    int TotalQpforPPicture;
-    int NumberofPPicture;
-    int NumberofCodedMacroBlocks;
-    int NumberofHeaderBits;
-    int NumberofTextureBits;
-    int NumberofBasicUnitHeaderBits;
-    int NumberofBasicUnitTextureBits;
-    double TotalMADBasicUnit;
-    double *MADofMB;
+    dataPointArray   *end; /*quantization levels for the past (20) frames */
+
+    int		frameNumber; /* ranging from 0 to 20 nodes*/
+    int		w;
+    int		Nr_Original;
+    int		Nr_Old, Nr_Old2;
+    int		skip_next_frame;
+    int		Qdep;		/* smooth Q adjustment */
+    int		VBR_Enabled;
+
+    int totalFrameNumber; /* total coded frames, for debugging!!*/
+
+    char    oFirstTime;
 
     int numFrameBits; /* keep track of number of bits of the current frame */
+    int NumberofHeaderBits;
+    int NumberofTextureBits;
     int numMBHeaderBits;
     int	numMBTextureBits;
-
-    /* rate control model parameters */
-    int R;
-    int Np;
-    int32 T;
-    double DeltaP;
+    double *MADofMB;
     int32 bitsPerFrame;
-    int32 CurrentBufferFullness;
-    int32 TargetBufferLevel;
 
-    //HRD consideration
-    int   curr_skip;
-    int32 UpperBound1;
-    int32 LowerBound;
+    /* BX rate control, something like TMN8 rate control*/
 
-    /*quadratic rate-distortion model*/
-    int32 Wp;
-    double PMADPictureC1;
-    double PMADPictureC2;
-    double PPictureMAD[21];
-    double ReferenceMAD[21];
-    double m_rgQp[20];
-    double m_rgRp[20];
-    double m_X1;
-    double m_X2;
-    int m_Qc;
-    int	Pm_Qp;
-    int PPreHeader;
+    MultiPass *pMP;
 
-    int TotalFrameQP;
-    int NumberofBasicUnit;
-    int PAveHeaderBits1;
-    int PAveHeaderBits2;
-    int PAveHeaderBits3;
-    int PAveFrameQP;
-    int TotalNumberofBasicUnit;
-
-    double CurrentFrameMAD;
-    double PreviousFrameMAD;
-    double PreviousWholeFrameMAD;
-
-    int m_windowSize;
-    int MADm_windowSize;
-    int DDquant;
-
-    int QPLastPFrame;
-    int QPLastGOP;
-    bool GOPOverdue;
-
-    double *BUPFMAD;
-    double *BUCFMAD;
-
-    /* RC3 additional variables */
-    int RCISliceBits;
-    int RCPSliceBits;
-    double RCISliceBitRatio;
+    int     TMN_W;
+    int     TMN_TH;
+    int     VBV_fullness;
+    int		max_BitVariance_num; /* the number of the maximum bit variance within the given buffer with the unit of 10% of bitrate/framerate*/
+    int		encoded_frames; /* counter for all encoded frames */
+    int		low_bound;				/* bound for underflow detection, usually low_bound=-Bs/2, but could be changed in H.263 mode */
+    int		VBV_fullness_offset;    /* offset of VBV_fullness, usually is zero, but can be changed in H.263 mode*/
+    /* End BX */
 
 } AVCRateControl;
 
@@ -303,6 +371,8 @@
     AVCCommonObj *common;
 
     AVCEncBitstream		*bitstream; /* for current NAL */
+    uint8   *overrunBuffer;  /* extra output buffer to prevent current skip due to output buffer overrun*/
+    int		oBSize;		/* size of allocated overrun buffer */
 
     /* rate control */
     AVCRateControl		*rateCtrl; /* pointer to the rate control structure */
@@ -335,11 +405,12 @@
     AVCMV(*mot8x8)[4];		/* Saved motion vectors for 8x8 block*/
 
     /********* subpel position **************************************/
-    uint32  subpel_pred[SUBPEL_PRED_BLK_SIZE<<2]; /* all 16 sub-pel positions  */
+    uint32  subpel_pred[SUBPEL_PRED_BLK_SIZE/*<<2*/]; /* all 16 sub-pel positions  */
     uint8   *hpel_cand[9];		/* pointer to half-pel position */
     int		best_hpel_pos;			/* best position */
-    uint8   *qpel_cand[9][8];		/* pointer to quarter-pel position */
+    uint8   qpel_cand[8][24*16];		/* pointer to quarter-pel position */
     int		best_qpel_pos;
+    uint8   *bilin_base[9][4];    /* pointer to 4 position at top left of bilinear quarter-pel */
 
     /* need for intra refresh rate */
     uint8   *intraSearch;		/* Intra Array for MBs to be intra searched */
@@ -364,9 +435,6 @@
 
     /* statistics */
     int	numIntraMB;			/* keep track of number of intra MB */
-    int numFalseAlarm;
-    int numMisDetected;
-    int numDetected;
 
     /* encoding complexity control */
     uint fullsearch_enable; /* flag to enable full-pel full-search */
@@ -374,6 +442,9 @@
     /* misc.*/
     bool outOfBandParamSet; /* flag to enable out-of-band param set */
 
+    AVCSeqParamSet extSPS; /* for external SPS */
+    AVCPicParamSet extPPS; /* for external PPS */
+
     /* time control */
     uint32	prevFrameNum;	/* previous frame number starting from modTimeRef */
     uint32	modTimeRef;		/* Reference modTime update every I-Vop*/
diff --git a/codecs_v2/video/avc_h264/enc/src/avcenc_lib.h b/codecs_v2/video/avc_h264/enc/src/avcenc_lib.h
index 44acc9e..6f5a612 100644
--- a/codecs_v2/video/avc_h264/enc/src/avcenc_lib.h
+++ b/codecs_v2/video/avc_h264/enc/src/avcenc_lib.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -150,6 +150,23 @@
     AVCEnc_Status EncodeSPS(AVCEncObject *encvid, AVCEncBitstream *stream);
 
     /**
+    This function encodes the VUI parameters into the sequence parameter set bitstream.
+    \param "stream" "Pointer to AVCEncBitstream."
+    \param "vui"	"Pointer to AVCVUIParams."
+    \return "nothing."
+    */
+    void EncodeVUI(AVCEncBitstream* stream, AVCVUIParams* vui);
+
+    /**
+    This function encodes HRD parameters into the sequence parameter set bitstream
+    \param "stream" "Pointer to AVCEncBitstream."
+    \param "hrd"	"Pointer to AVCHRDParams."
+    \return "nothing."
+    */
+    void EncodeHRD(AVCEncBitstream* stream, AVCHRDParams* hrd);
+
+
+    /**
     This function performs bitstream encoding of the picture parameter set NAL.
     \param "encvid"	"Pointer to the AVCEncObject."
     \param "stream" "Pointer to AVCEncBitstream."
@@ -211,9 +228,12 @@
     \param "bitstream"	"Pointer to the AVCEncBitstream structure."
     \param "buffer"		"Pointer to the unsigned char buffer for output."
     \param "buf_size"	"The size of the buffer in bytes."
+    \param "overrunBuffer"	"Pointer to extra overrun buffer."
+    \param "oBSize"		"Size of overrun buffer in bytes."
     \return "AVCENC_SUCCESS if success, AVCENC_BITSTREAM_INIT_FAIL if fail"
     */
-    AVCEnc_Status BitstreamEncInit(AVCEncBitstream *bitstream, uint8 *buffer, int buf_size);
+    AVCEnc_Status BitstreamEncInit(AVCEncBitstream *bitstream, uint8 *buffer, int buf_size,
+                                   uint8 *overrunBuffer, int oBSize);
 
     /**
     This function writes the data from the cache into the bitstream buffer. It also adds the
@@ -257,6 +277,17 @@
     */
     bool byte_aligned(AVCEncBitstream *stream);
 
+
+    /**
+    This function checks the availability of overrun buffer and switches to use it when
+    normal bufffer is not big enough.
+    \param "stream" "Pointer to the bitstream structure."
+    \param "numExtraBytes" "Number of extra byte needed."
+    \return "AVCENC_SUCCESS or AVCENC_FAIL."
+    */
+    AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtraBytes);
+
+
     /*-------------- intra_est.c ---------------*/
 
     /** This function performs intra/inter decision based on ABE.
@@ -267,7 +298,8 @@
     \return "Boolean for intra mode."
     */
 
-    bool IntraDecisionABE(AVCEncObject *encvid, int min_cost, uint8 *curL, int picPitch);
+//bool IntraDecisionABE(AVCEncObject *encvid, int min_cost, uint8 *curL, int picPitch);
+    bool IntraDecision(int *min_cost, uint8 *cur, int pitch, bool ave);
 
     /**
     This function performs intra prediction mode search.
@@ -584,10 +616,10 @@
     \param "ypos"	"The current MB position in y."
     \param "hp_guess"	"Input to help speedup the search."
     \param "cmvx, cmvy" "Predicted motion vector use for mvcost."
-    \return "void."
+    \return "Minimal cost (SATD) without MV cost. (for rate control purpose)"
     */
-    void AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
-                          int xpos, int ypos, int hp_guess, int cmvx, int cmvy);
+    int AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
+                         int xpos, int ypos, int hp_guess, int cmvx, int cmvy);
 
     /**
     This function generates sub-pel pixels required to do subpel MV search.
@@ -596,7 +628,25 @@
     \param "lx" "Pitch of the ref frame."
     \return "void"
      */
-    void GenerateSubPelPred(uint8* subpel_pred, uint8 *ncand, int lx);
+    void GenerateHalfPelPred(uint8 *subpel_pred, uint8 *ncand, int lx);
+
+    /**
+    This function calculate vertical interpolation at half-point of size 4x17.
+    \param "dst" "Pointer to destination."
+    \param "ref" "Pointer to the starting reference pixel."
+    \return "void."
+    */
+    void VertInterpWClip(uint8 *dst, uint8 *ref);
+
+    /**
+    This function generates quarter-pel pixels around the best half-pel result
+    during the sub-pel MV search.
+    \param "bilin_base"  "Array of pointers to be used as basis for q-pel interp."
+    \param "qpel_pred"  "Array of pointers pointing to quarter-pel candidates."
+    \param "hpel_pos" "Best half-pel position at the center."
+    \return "void"
+    */
+    void GenerateQuartPelPred(uint8 **bilin_base, uint8 *qpel_pred, int hpel_pos);
 
     /**
     This function calculates the SATD of a subpel candidate.
@@ -609,6 +659,12 @@
 
     /*------------- rate_control.c -------------------*/
 
+    /** This function is a utility function. It returns average QP of the previously encoded frame.
+    \param "rateCtrl" "Pointer to AVCRateControl structure."
+    \return "Average QP."
+    */
+    int GetAvgFrameQP(AVCRateControl *rateCtrl);
+
     /**
     This function takes the timestamp of the input and determine whether it should be encoded
     or skipped.
@@ -682,6 +738,16 @@
     void RCInitMBQP(AVCEncObject *encvid);
 
     /**
+    This function updates bits usage stats after encoding an macroblock.
+    \param "video" "Pointer to AVCCommonObj."
+    \param "rateCtrl" "Pointer to AVCRateControl."
+    \param "num_header_bits" "Number of bits used for MB header."
+    \param "num_texture_bits" "Number of bits used for MB texture."
+    \return "void"
+    */
+    void RCPostMB(AVCCommonObj *video, AVCRateControl *rateCtrl, int num_header_bits, int num_texture_bits);
+
+    /**
     This function calculates the difference between prediction and original MB.
     \param "encvid" "Pointer to the encoder object."
     \param "currMB" "Pointer to the current macroblock structure."
diff --git a/codecs_v2/video/avc_h264/enc/src/bitstream_io.cpp b/codecs_v2/video/avc_h264/enc/src/bitstream_io.cpp
index 446f03a..a549998 100644
--- a/codecs_v2/video/avc_h264/enc/src/bitstream_io.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/bitstream_io.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
  * -------------------------------------------------------------------
  */
 #include "avcenc_lib.h"
+#include "oscl_mem.h"
 
 #define WORD_SIZE 32
 
@@ -42,7 +43,8 @@
 	 bit_left
  ======================================================================== */
 
-AVCEnc_Status BitstreamEncInit(AVCEncBitstream *stream, uint8 *buffer, int buf_size)
+AVCEnc_Status BitstreamEncInit(AVCEncBitstream *stream, uint8 *buffer, int buf_size,
+                               uint8 *overrunBuffer, int oBSize)
 {
     if (stream == NULL || buffer == NULL || buf_size <= 0)
     {
@@ -61,6 +63,10 @@
 
     stream->bit_left = WORD_SIZE;
 
+    stream->overrunBuffer = overrunBuffer;
+
+    stream->oBSize = oBSize;
+
     return AVCENC_SUCCESS;
 }
 
@@ -82,16 +88,19 @@
 
     /* check number of bytes in current_word, must always be byte-aligned!!!! */
     num_bits = WORD_SIZE - stream->bit_left; /* must be multiple of 8 !!*/
-    write_pnt = stream->bitstreamBuffer + stream->write_pos;
 
-    if (stream->buf_size - stream->write_pos <= (num_bits >> 3))
+    if (stream->buf_size - stream->write_pos <= (num_bits >> 3) + 2) /* 2 more bytes for possible EPBS */
     {
-        return AVCENC_BITSTREAM_BUFFER_FULL;
+        if (AVCENC_SUCCESS != AVCBitstreamUseOverrunBuffer(stream, (num_bits >> 3) + 2))
+        {
+            return AVCENC_BITSTREAM_BUFFER_FULL;
+        }
     }
 
     /* write word, byte-by-byte */
+    write_pnt = stream->bitstreamBuffer + stream->write_pos;
     current_word = stream->current_word;
-    while (num_bits && stream->write_pos < stream->buf_size)
+    while (num_bits) /* no need to check stream->buf_size and stream->write_pos, taken care already */
     {
         num_bits -= 8;
         byte = (current_word >> num_bits) & 0xFF;
@@ -106,8 +115,8 @@
             stream->count_zeros++;
             *write_pnt++ = byte;
             stream->write_pos++;
-            if (stream->count_zeros == 2) /* don't have to check write_pos here */
-            {
+            if (stream->count_zeros == 2)
+            {	/* for num_bits = 32, this can add 2 more bytes extra for EPBS */
                 *write_pnt++ = 0x3;
                 stream->write_pos++;
                 stream->count_zeros = 0;
@@ -119,12 +128,6 @@
     stream->current_word = 0;
     stream->bit_left = WORD_SIZE;
 
-    /* not enough to put into the buffer */
-    if (stream->write_pos >= stream->buf_size)
-    {
-        return AVCENC_BITSTREAM_BUFFER_FULL;
-    }
-
     return AVCENC_SUCCESS;
 }
 
@@ -139,7 +142,7 @@
 /* ======================================================================== */
 AVCEnc_Status BitstreamWriteBits(AVCEncBitstream *stream, int nBits, uint code)
 {
-    AVCEnc_Status status;
+    AVCEnc_Status status = AVCENC_SUCCESS;
     int bit_left = stream->bit_left;
     uint current_word = stream->current_word;
 
@@ -163,25 +166,20 @@
     }
     else
     {
-        if (nBits > bit_left + ((stream->buf_size - stream->write_pos) << 3))
-        {
-            return AVCENC_BITSTREAM_BUFFER_FULL;
-        }
-
         stream->current_word = (current_word << bit_left) | (code >> (nBits - bit_left));
 
         nBits -= bit_left;
 
         stream->bit_left = 0;
 
-        AVCBitstreamSaveWord(stream); /* save current word */
+        status = AVCBitstreamSaveWord(stream); /* save current word */
 
         stream->bit_left = WORD_SIZE - nBits;
 
         stream->current_word = code; /* no extra masking for code, must be handled before saving */
     }
 
-    return AVCENC_SUCCESS;
+    return status;
 }
 
 
@@ -233,6 +231,7 @@
 
     bit_left &= 0x7; /* modulo by 8 */
     if (bit_left == 0) bit_left = 8;
+    /* bitstream->bit_left == 0 cannot happen here since it would have been Saved already */
 
     status = BitstreamWriteBits(bitstream, bit_left, trailing_bits[bit_left]);
 
@@ -242,7 +241,7 @@
     }
 
     /* if it's not saved, save it. */
-    if (bitstream->bit_left < (WORD_SIZE << 3))
+    //if(bitstream->bit_left<(WORD_SIZE<<3)) /* in fact, no need to check */
     {
         status = AVCBitstreamSaveWord(bitstream);
     }
@@ -258,3 +257,81 @@
     else
         return true;
 }
+
+
+/* determine whether overrun buffer can be used or not */
+AVCEnc_Status AVCBitstreamUseOverrunBuffer(AVCEncBitstream* stream, int numExtraBytes)
+{
+    AVCEncObject *encvid = (AVCEncObject*)stream->encvid;
+
+    if (stream->overrunBuffer != NULL) // overrunBuffer is set
+    {
+        if (stream->bitstreamBuffer != stream->overrunBuffer) // not already used
+        {
+            if (stream->write_pos + numExtraBytes >= stream->oBSize)
+            {
+                stream->oBSize = stream->write_pos + numExtraBytes + 100;
+                stream->oBSize &= (~0x3); // make it multiple of 4
+
+                // allocate new overrun Buffer
+                if (encvid->overrunBuffer)
+                {
+                    encvid->avcHandle->CBAVC_Free((uint32*)encvid->avcHandle->userData,
+                                                  (int)encvid->overrunBuffer);
+                }
+
+                encvid->oBSize = stream->oBSize;
+                encvid->overrunBuffer = (uint8*) encvid->avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
+                                        stream->oBSize, DEFAULT_ATTR);
+
+                stream->overrunBuffer = encvid->overrunBuffer;
+                if (stream->overrunBuffer == NULL)
+                {
+                    return AVCENC_FAIL;
+                }
+            }
+
+            // copy everything to overrun buffer and start using it.
+            oscl_memcpy(stream->overrunBuffer, stream->bitstreamBuffer, stream->write_pos);
+            stream->bitstreamBuffer = stream->overrunBuffer;
+            stream->buf_size = stream->oBSize;
+        }
+        else // overrun buffer is already used
+        {
+            stream->oBSize = stream->write_pos + numExtraBytes + 100;
+            stream->oBSize &= (~0x3); // make it multiple of 4
+
+            // allocate new overrun buffer
+            encvid->oBSize = stream->oBSize;
+            encvid->overrunBuffer = (uint8*) encvid->avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
+                                    stream->oBSize, DEFAULT_ATTR);
+
+            if (encvid->overrunBuffer == NULL)
+            {
+                return AVCENC_FAIL;
+            }
+
+
+            // copy from the old buffer to new buffer
+            oscl_memcpy(encvid->overrunBuffer, stream->overrunBuffer, stream->write_pos);
+            // free old buffer
+            encvid->avcHandle->CBAVC_Free((uint32*)encvid->avcHandle->userData,
+                                          (int)stream->overrunBuffer);
+
+            // assign pointer to new buffer
+            stream->overrunBuffer = encvid->overrunBuffer;
+            stream->bitstreamBuffer = stream->overrunBuffer;
+            stream->buf_size = stream->oBSize;
+        }
+
+        return AVCENC_SUCCESS;
+    }
+    else // overrunBuffer is not enable.
+    {
+        return AVCENC_FAIL;
+    }
+
+}
+
+
+
diff --git a/codecs_v2/video/avc_h264/enc/src/block.cpp b/codecs_v2/video/avc_h264/enc/src/block.cpp
index dbb27bb..21510f8 100644
--- a/codecs_v2/video/avc_h264/enc/src/block.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/block.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1110,248 +1110,6 @@
     return ;
 }
 
-#if 0
-void TransQuantZZ(AVCEncObject *encvid, AVCMacroblock *currMB, int slice_type,
-                  uint8 *curL, uint8 *curCb, uint8 *curCr)
-{
-    int block_y, block_x, i8x8, i, j;
-    int ncoeff, start_k = 0;
-    AVCEnc_Status status;
-    AVCCommonObj *video = encvid->common;
-    uint8 *predBlock = video->pred_block;
-    int16 *dataBlock = video->block;
-
-    int Qq, Rq, q_bits, qp_const, quant;
-    int data, lev, zero_run;
-    int k, idx, idx2;
-
-    int *level, *run;
-
-    int picPitch = video->currPic->pitch;
-
-    if (currMB->mbMode == AVC_I16)
-    {
-        start_k = 1;
-    }
-
-    Qq    = video->QPy_div_6;
-    Rq    = video->QPy_mod_6;
-    q_bits    = 15 + Qq;
-
-    if (slice_type == AVC_I_SLICE)
-    {
-        qp_const = (1 << q_bits) / 3;    // intra
-    }
-    else
-    {
-        qp_const = (1 << q_bits) / 6;    // inter
-    }
-
-    level = encvid->level[0];
-    run = encvid->run[0];
-    currMB->CBP = 0;
-
-    for (block_y = 0; block_y < 4; block_y += 2)
-    {
-        for (block_x = 0; block_x < 4; block_x += 2)
-        {
-            i8x8 = block_y + (block_x >> 1);
-
-            for (j = block_y; j < block_y + 2; j++)
-            {
-                for (i = block_x; i < block_x + 2; i++)
-                {
-                    if (currMB->mbMode == AVC_I4) /* perform prediction in the loop */
-                    {
-                        status = Intra_4x4(video, i, j, curL); /* prediction */
-                    }
-                    /* residue, transform, quant & dequant and zigzag scan */
-
-                    trans(curL, picPitch, predBlock, dataBlock);  /* residue and transform */
-
-                    zero_run = 0;
-                    ncoeff = 0;
-
-                    for (k = start_k; k < 16; k++) /* in zigzag scan order */
-                    {
-                        idx = ZZ_SCAN_BLOCK[k]; /* map back to raster scan order */
-                        data = dataBlock[idx];
-                        idx2 = ZZ_SCAN[k];
-                        quant = quant_coef[Rq][idx2];
-                        if (data > 0)
-                        {
-                            lev = data * quant + qp_const;
-                        }
-                        else
-                        {
-                            lev = -data * quant + qp_const;
-                        }
-                        lev >>= q_bits;
-                        if (lev)
-                        {	/* dequant */
-                            quant = dequant_coef[Rq][idx2];
-                            if (data > 0)
-                            {
-                                level[ncoeff] = lev;
-                                dataBlock[idx] = (lev * quant) << Qq;
-                            }
-                            else
-                            {
-                                level[ncoeff] = -lev;
-                                dataBlock[idx] = (-lev * quant) << Qq;
-                            }
-                            run[ncoeff++] = zero_run;
-                            zero_run = 0;
-                        }
-                        else
-                        {
-                            zero_run++;
-                            dataBlock[idx] = 0;
-                        }
-                    }
-
-                    if (ncoeff)
-                    {
-                        currMB->CBP |= (1 << i8x8);
-                        video->cbp4x4 |= (1 << ((j << 2) + i));
-
-                        currMB->nz_coeff[(j<<2)+i] = ncoeff;
-
-                        /* inverse transform and add prediction*/
-                        if (currMB->mbMode != AVC_I16)
-                        {
-                            itrans(dataBlock, predBlock, curL, picPitch);
-                        }
-                    }
-                    else if (currMB->mbMode != AVC_I16)
-                    {
-                        copy_block(predBlock, curL, picPitch);
-                    }
-
-                    level += 16;
-                    run += 16;
-                    dataBlock += 4;
-                    predBlock += 4;
-                    curL += 4;
-                }
-                level += 32;
-                run += 32;
-                dataBlock += 56;
-                predBlock += 56;
-                curL += ((picPitch << 2) - 8);
-            }
-            level -= 96;
-            run -= 96;
-            dataBlock -= 120;
-            predBlock -= 120;
-            curL += (8 - (picPitch << 3));
-        }
-        level += 64;
-        run += 64;
-        dataBlock += 112;
-        predBlock += 112;
-        curL += ((picPitch << 3) - 16);
-    }
-
-    /* chroma */
-    Qq    = video->QPc_div_6;
-    Rq    = video->QPc_mod_6;
-    q_bits    = 15 + Qq;
-
-    if (slice_type == AVC_I_SLICE)
-    {
-        qp_const = (1 << q_bits) / 3;    // intra
-    }
-    else
-    {
-        qp_const = (1 << q_bits) / 6;    // inter
-    }
-
-    curL = curCb;
-
-    for (block_x = 0; block_x < 4; block_x += 2) /* for iCbCr */
-    {
-        for (j = 4; j < 6; j++)  /* for each block inside Cb or Cr */
-        {
-            for (i = block_x; i < block_x + 2; i++)
-            {
-                /* transform, quant & dequant and zigzag scan */
-                /* only do zigzag for AC */
-                /* residue, transform, quant & dequant and zigzag scan */
-
-                trans(curL, picPitch, predBlock, dataBlock);  /* residue and transform */
-
-                zero_run = 0;
-                ncoeff = 0;
-
-                for (k = 1; k < 16; k++) /* in zigzag scan order */
-                {
-                    idx = ZZ_SCAN_BLOCK[k]; /* map back to raster scan order */
-                    data = dataBlock[idx];
-                    idx2 = ZZ_SCAN[k];
-                    quant = quant_coef[Rq][idx2];
-                    if (data > 0)
-                    {
-                        lev = data * quant + qp_const;
-                    }
-                    else
-                    {
-                        lev = -data * quant + qp_const;
-                    }
-                    lev >>= q_bits;
-                    if (lev)
-                    {	/* dequant */
-                        quant = dequant_coef[Rq][idx2];
-                        if (data > 0)
-                        {
-                            level[ncoeff] = lev;
-                            dataBlock[idx] = (lev * quant) << Qq;
-                        }
-                        else
-                        {
-                            level[ncoeff] = -lev;
-                            dataBlock[idx] = (-lev * quant) << Qq;
-                        }
-                        run[ncoeff++] = zero_run;
-                        zero_run = 0;
-                    }
-                    else
-                    {
-                        zero_run++;
-                        dataBlock[idx] = 0;
-                    }
-                }
-
-                if (ncoeff)
-                {
-                    currMB->CBP |= (2 << 4);
-                    video->cbp4x4 |= (1 << ((j << 2) + i));
-                }
-                /* do not do inverse transform yet, have to do DC transform first */
-
-                currMB->nz_coeff[(j<<2)+i] = ncoeff;
-                level += 16;
-                run += 16;
-                dataBlock += 4;
-                predBlock += 4;
-                curL += 4;
-            }
-            level += 32;
-            run += 32;
-            dataBlock += 56;
-            predBlock += 56;
-            curL += ((picPitch << 1) - 8);
-        }
-        level -= 96;
-        run -= 96;
-        dataBlock -= 120;
-        predBlock -= 120;
-        curL = curCr;
-    }
-
-    return ;
-}
-#endif
 
 /* only DC transform */
 int TransQuantIntra16DC(AVCEncObject *encvid)
@@ -1403,26 +1161,6 @@
         j--;
     }
 
-#if 0
-    zero_run = 0;
-    ncoeff = 0;
-
-    for (k = 0; k < 16; k++) /* in zigzag scan order */
-    {
-        idx = ZIGZAG2RASTERDC[k];
-        data = block[idx];
-        if (data)
-        {
-            level[ncoeff] = data;
-            run[ncoeff++] = zero_run;
-            zero_run = 0;
-        }
-        else
-        {
-            zero_run++;
-        }
-    }
-#else
     quant = quant_coef[Rq][0];
     q_bits    = 15 + Qq;
     qp_const = (1 << q_bits) / 3;    // intra
@@ -1464,7 +1202,6 @@
             block[idx] = 0;
         }
     }
-#endif
     return ncoeff;
 }
 
@@ -1491,26 +1228,6 @@
     block[64] = r0 + r1 - r2 - r3;
     block[68] = r0 - r1 - r2 + r3;
 
-#if 0
-    zero_run = 0;
-    ncoeff = 0;
-
-    for (k = 0; k < 4; k++) /* in zigzag scan order */
-    {
-        idx = ((k >> 1) << 6) + ((k & 1) << 2);
-        data = block[idx];
-        if (data)
-        {
-            level[ncoeff] = data;
-            run[ncoeff++] = zero_run;
-            zero_run = 0;
-        }
-        else
-        {
-            zero_run++;
-        }
-    }
-#else
     Qq    = video->QPc_div_6;
     Rq    = video->QPc_mod_6;
     quant = quant_coef[Rq][0];
@@ -1561,7 +1278,6 @@
             block[idx] = 0;
         }
     }
-#endif
     return ncoeff;
 }
 
diff --git a/codecs_v2/video/avc_h264/enc/src/findhalfpel.cpp b/codecs_v2/video/avc_h264/enc/src/findhalfpel.cpp
index e05cf42..4456192 100644
--- a/codecs_v2/video/avc_h264/enc/src/findhalfpel.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/findhalfpel.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,14 @@
     {1, 0, 1, 2, 3, 2, 1, 0, 0}
 };
 
+#define CLIP_RESULT(x) 		if((uint)x > 0xFF){ \
+			     x = 0xFF & (~(x>>31));}
+
+#define CLIP_UPPER16(x)     if((uint)x >= 0x20000000){ \
+		x = 0xFF0000 & (~(x>>31));} \
+		else { \
+		x = (x>>5)&0xFF0000; \
+		}
 
 /*=====================================================================
 	Function:	AVCFindHalfPelMB
@@ -44,20 +52,20 @@
 	Purpose:	Find half pel resolution MV surrounding the full-pel MV
 =====================================================================*/
 
-void AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
-                      int xpos, int ypos, int hp_guess, int cmvx, int cmvy)
+int AVCFindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
+                     int xpos, int ypos, int hp_guess, int cmvx, int cmvy)
 {
     AVCPictureData *currPic = encvid->common->currPic;
     int lx = currPic->pitch;
-    int d, dmin;
+    int d, dmin, satd_min;
     uint8* cand;
     int lambda_motion = encvid->lambda_motion;
     uint8 *mvbits = encvid->mvbits;
     int mvcost;
     /* list of candidate to go through for half-pel search*/
-    uint8* subpel_pred = (uint8*) encvid->subpel_pred; // all 16 sub-pel positions
-    uint8** hpel_cand = (uint8**) encvid->hpel_cand; /* half-pel position */
-    uint8**	qpel_cand;
+    uint8 *subpel_pred = (uint8*) encvid->subpel_pred; // all 16 sub-pel positions
+    uint8 **hpel_cand = (uint8**) encvid->hpel_cand; /* half-pel position */
+
     int xh[9] = {0, 0, 2, 2, 2, 0, -2, -2, -2};
     int yh[9] = {0, -2, -2, 0, 2, 2, 2, 0, -2};
     int xq[8] = {0, 1, 1, 1, 0, -1, -1, -1};
@@ -68,7 +76,7 @@
     OSCL_UNUSED_ARG(ypos);
     OSCL_UNUSED_ARG(hp_guess);
 
-    GenerateSubPelPred(subpel_pred, ncand, lx);
+    GenerateHalfPelPred(subpel_pred, ncand, lx);
 
     cur = encvid->currYMB; // pre-load current original MB
 
@@ -77,6 +85,7 @@
     // find cost for the current full-pel position
     dmin = SATD_MB(cand, cur, 65535); // get Hadamaard transform SAD
     mvcost = MV_COST_S(lambda_motion, mot->x, mot->y, cmvx, cmvy);
+    satd_min = dmin;
     dmin += mvcost;
     hmin = 0;
 
@@ -91,6 +100,7 @@
         {
             dmin = d;
             hmin = h;
+            satd_min = d - mvcost;
         }
     }
 
@@ -100,18 +110,20 @@
     encvid->best_hpel_pos = hmin;
 
     /*** search for quarter-pel ****/
-    qpel_cand = encvid->qpel_cand[hmin];
+    GenerateQuartPelPred(encvid->bilin_base[hmin], &(encvid->qpel_cand[0][0]), hmin);
+
     encvid->best_qpel_pos = qmin = -1;
 
     for (q = 0; q < 8; q++)
     {
-        d = SATD_MB(qpel_cand[q], cur, dmin);
+        d = SATD_MB(encvid->qpel_cand[q], cur, dmin);
         mvcost = MV_COST_S(lambda_motion, mot->x + xq[q], mot->y + yq[q], cmvx, cmvy);
         d += mvcost;
         if (d < dmin)
         {
             dmin = d;
             qmin = q;
+            satd_min = d - mvcost;
         }
     }
 
@@ -123,120 +135,29 @@
         encvid->best_qpel_pos = qmin;
     }
 
-    return ;
+    return satd_min;
 }
 
-#if 0
-void FindHalfPelMB(AVCEncObject *encvid, uint8 *cur, AVCMV *mot, uint8 *ncand,
-                   int xpos, int ypos, int hp_guess, int cmvx, int cmvy)
-{
-//	hp_mem = ULong *vertArray; /* 20x17 */
-//			 ULong *horzArray; /* 20x16 */
-//			 ULong *diagArray; /* 20x17 */
-    int dmin, d;
 
-    int xh, yh;
-    int k, kmin = 0;
-    int imin, jmin, ilow, jlow;
-    int in_range[9] = {0, 1, 1, 1, 1, 1, 1, 1, 1}; /*  3/29/01 */
-    int range = encvid->rateCtrl->mvRange;
-    AVCPictureData *currPic = encvid->common->currPic;
-    int lx = currPic->pitch;
-    int width = currPic->width; /*  padding */
-    int height = currPic->height;
-    int (**SAD_MB_HalfPel)(uint8*, uint8*, int, void*) =
-        encvid->functionPointer->SAD_MB_HalfPel;
-    void *extra_info = encvid->sad_extra_info;
-
-    int next_hp_pos[9][2] = {{0, 0}, {2, 0}, {1, 1}, {0, 2}, { -1, 1}, { -2, 0}, { -1, -1}, {0, -2}, {0, -1}};
-    int next_ncand[9] = {0, 1 , lx, lx, 0, -1, -1, -lx, -lx};
-    int xhmin, yhmin;
-    int lambda_motion = encvid->lambda_motion;
-    uint8 *mvbits = encvid->mvbits;
-    int mvcost;
-
-    cur = encvid->currYMB; // pre-load current original MB
-
-    /**************** check range ***************************/
-    /*  3/29/01 */
-    imin = xpos + (mot[0].x >> 2);
-    jmin = ypos + (mot[0].y >> 2);
-    ilow = xpos - range;
-    jlow = ypos - range;
-
-    if (imin <= -15 || imin == ilow)
-        in_range[1] = in_range[7] = in_range[8] = 0;
-    else if (imin >= width - 1)
-        in_range[3] = in_range[4] = in_range[5] = 0;
-    if (jmin <= -15 || jmin == jlow)
-        in_range[1] = in_range[2] = in_range[3] = 0;
-    else if (jmin >= height - 1)
-        in_range[5] = in_range[6] = in_range[7] = 0;
-
-    xhmin = 0;
-    yhmin = 0;
-    dmin = mot->sad;
-
-    xh = 0;
-    yh = -1;
-    ncand -= lx; /* initial position */
-
-    for (k = 2; k <= 8; k += 2)
-    {
-        if (distance_tab[hp_guess][k] < HP_DISTANCE_TH)
-        {
-            if (in_range[k])
-            {
-                d = (*(SAD_MB_HalfPel[((yh&1)<<1)+(xh&1)]))(ncand, cur, (dmin << 16) | lx, extra_info);
-                mvcost = MV_COST_S(lambda_motion, mot[0].x + (xh << 1), mot[0].y + (yh << 1), cmvx, cmvy);
-                d += mvcost;
-
-                if (d < dmin)
-                {
-                    dmin = d;
-                    xhmin = xh;
-                    yhmin = yh;
-                    kmin = k;
-                }
-            }
-        }
-        xh += next_hp_pos[k][0];
-        yh += next_hp_pos[k][1];
-        ncand += next_ncand[k];
-
-        if (k == 8)
-        {
-            if (xhmin != 0 || yhmin != 0)
-            {
-                k = -1;
-                hp_guess = kmin;
-            }
-        }
-    }
-
-    mot->sad = dmin;
-    mot->x += (xhmin << 1);
-    mot->y += (yhmin << 1);
-
-    return ;
-}
-#endif
 
 /** This function generates sub-pel prediction around the full-pel candidate.
 Each sub-pel position array is 20 pixel wide (for word-alignment) and 17 pixel tall. */
 /** The sub-pel position is labeled in spiral manner from the center. */
 
-void GenerateSubPelPred(uint8* subpel_pred, uint8 *ncand, int lx)
+void GenerateHalfPelPred(uint8* subpel_pred, uint8 *ncand, int lx)
 {
     /* let's do straightforward way first */
     uint8 *ref;
-    uint8 *dst, *dst2, *dst3, *dst4, *dst5, *src;
+    uint8 *dst;
     uint8 tmp8;
     int32 tmp32;
     int16 tmp_horz[18*22], *dst_16, *src_16;
+    register int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0; // temp register
+    int msk;
     int i, j;
 
     /* first copy full-pel to the first array */
+    /* to be optimized later based on byte-offset load */
     ref = ncand - 3 - lx - (lx << 1); /* move back (-3,-3) */
     dst = subpel_pred;
 
@@ -263,232 +184,442 @@
     ref = subpel_pred + 2;
     dst_16 = tmp_horz; /* 17 x 22 */
 
-    for (j = -2; j < 0; j++)
+    for (j = 4; j > 0; j--)
     {
-        for (i = 0; i < 16; i++)
+        for (i = 16; i > 0; i -= 4)
         {
-            *dst_16++ =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-            ref++;
+            a = ref[-2];
+            b = ref[-1];
+            c = ref[0];
+            d = ref[1];
+            e = ref[2];
+            f = ref[3];
+            *dst_16++ = a + f - 5 * (b + e) + 20 * (c + d);
+            a = ref[4];
+            *dst_16++ = b + a - 5 * (c + f) + 20 * (d + e);
+            b = ref[5];
+            *dst_16++ = c + b - 5 * (d + a) + 20 * (e + f);
+            c = ref[6];
+            *dst_16++ = d + c - 5 * (e + b) + 20 * (f + a);
+
+            ref += 4;
         }
         /* do the 17th column here */
-        *dst_16 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
+        d = ref[3];
+        *dst_16 =  e + d - 5 * (f + c) + 20 * (a + b);
         dst_16 += 2; /* stride for tmp_horz is 18 */
         ref += 8;  /* stride for ref is 24 */
+        if (j == 3)  // move 18 lines down
+        {
+            dst_16 += 324;//18*18;
+            ref += 432;//18*24;
+        }
     }
 
+    ref -= 480;//20*24;
+    dst_16 -= 360;//20*18;
     dst = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* go to the 14th array 17x18*/
 
-    for (i = 0; i < 16; i++)
+    for (j = 18; j > 0; j--)
     {
-        tmp32 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-        *dst_16++ = tmp32;
-        ref++;
-        tmp32 = (tmp32 + 16) >> 5;
-        *dst++ = AVC_CLIP(tmp32);
-    }
-    /* do the 17th column here */
-    tmp32 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-    *dst_16 = tmp32;
-    tmp32 = (tmp32 + 16) >> 5;
-    *dst = AVC_CLIP(tmp32);
-
-    dst += 8;  /* stride for dst is 24 */
-    dst_16 += 2; /* stride for tmp_horz is 18 */
-    ref += 8;  /* stride for ref is 24 */
-
-    dst3 = subpel_pred + V0Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 3rd array 17x16 */
-    dst4 = subpel_pred + V0Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 7th array 17x16 */
-
-    for (j = 0; j < 16; j++)
-    {
-        for (i = 0; i < 16; i++)
+        for (i = 16; i > 0; i -= 4)
         {
-            tmp32 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
+            a = ref[-2];
+            b = ref[-1];
+            c = ref[0];
+            d = ref[1];
+            e = ref[2];
+            f = ref[3];
+            tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
             *dst_16++ = tmp32;
-            ref++;
             tmp32 = (tmp32 + 16) >> 5;
-            tmp32 = AVC_CLIP(tmp32);
+            CLIP_RESULT(tmp32)
             *dst++ = tmp32;
-            *dst3++ = (tmp32 + ref[-1] + 1) >> 1;
-            *dst4++ = (tmp32 + ref[0] + 1) >> 1;
+
+            a = ref[4];
+            tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
+            *dst_16++ = tmp32;
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *dst++ = tmp32;
+
+            b = ref[5];
+            tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
+            *dst_16++ = tmp32;
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *dst++ = tmp32;
+
+            c = ref[6];
+            tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
+            *dst_16++ = tmp32;
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *dst++ = tmp32;
+
+            ref += 4;
         }
         /* do the 17th column here */
-        tmp32 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
+        d = ref[3];
+        tmp32 =  e + d - 5 * (f + c) + 20 * (a + b);
         *dst_16 = tmp32;
         tmp32 = (tmp32 + 16) >> 5;
-        tmp32 = AVC_CLIP(tmp32);
+        CLIP_RESULT(tmp32)
         *dst = tmp32;
-        *dst3 = (tmp32 + ref[0] + 1) >> 1;
-        *dst4 = (tmp32 + ref[1] + 1) >> 1;
 
         dst += 8;  /* stride for dst is 24 */
-        dst3 += 8;
-        dst4 += 8;
         dst_16 += 2; /* stride for tmp_horz is 18 */
         ref += 8;  /* stride for ref is 24 */
     }
 
-    for (i = 0; i < 16; i++)
-    {
-        tmp32 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-        *dst_16++ = tmp32;
-        ref++;
-        tmp32 = (tmp32 + 16) >> 5;
-        *dst++ = AVC_CLIP(tmp32);
-    }
-    /* do the 17th column here */
-    tmp32 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-    *dst_16 = tmp32;
-    tmp32 = (tmp32 + 16) >> 5;
-    *dst = AVC_CLIP(tmp32);
 
-    dst += 8;  /* stride for dst is 24 */
-    dst_16 += 2; /* stride for tmp_horz is 18 */
-    ref += 8;  /* stride for ref is 24 */
-
-    for (j = 17; j < 19; j++)
-    {
-        for (i = 0; i < 16; i++)
-        {
-            *dst_16++ =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-            ref++;
-        }
-        /* do the 17th column here */
-        *dst_16 =  ref[-2] + ref[3] - 5 * (ref[-1] + ref[2]) + 20 * (ref[0] + ref[1]);
-        dst_16 += 2; /* stride for tmp_horz is 18 */
-        ref += 8;  /* stride for ref is 24 */
-    }
-
-    /* Do vertical filtering and vertical cross */
+    /* Do middle point filtering*/
     src_16 = tmp_horz; /* 17 x 22 */
-    src = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 14th array 17x18 */
     dst = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 12th array 17x17*/
-    dst3 = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 15th array 17x17 */
-    dst4 = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 13th array 17x17 */
-
     dst -= 24; // offset
-    dst3 -= 24;
-    dst4 -= 24;
     for (i = 0; i < 17; i++)
     {
-        for (j = 0; j < 17; j++)
+        for (j = 16; j > 0; j -= 4)
         {
-            tmp32 = src_16[0] + src_16[18*5] - 5 * (src_16[18] + src_16[18*4]) + 20 * (src_16[18*2] + src_16[18*3]);
+            a = *src_16;
+            b = *(src_16 += 18);
+            c = *(src_16 += 18);
+            d = *(src_16 += 18);
+            e = *(src_16 += 18);
+            f = *(src_16 += 18);
+
+            tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
             tmp32 = (tmp32 + 512) >> 10;
-            tmp32 = AVC_CLIP(tmp32);
+            CLIP_RESULT(tmp32)
             *(dst += 24) = tmp32;
-            *(dst3 += 24) = (tmp32 + *src + 1) >> 1;
-            *(dst4 += 24) = (tmp32 + *(src += 24) + 1) >> 1;
-            src_16 += 18;
+
+            a = *(src_16 += 18);
+            tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
+            tmp32 = (tmp32 + 512) >> 10;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;
+
+            b = *(src_16 += 18);
+            tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
+            tmp32 = (tmp32 + 512) >> 10;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;
+
+            c = *(src_16 += 18);
+            tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
+            tmp32 = (tmp32 + 512) >> 10;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;
+
+            src_16 -= (18 << 2);
         }
-        src_16 -= ((18 * 17) - 1);
-        dst -= ((24 * 17) - 1);
-        dst3 -= ((24 * 17) - 1);
-        dst4 -= ((24 * 17) - 1);
-        src -= ((24 * 17) - 1);
+
+        d = src_16[90]; // 18*5
+        tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
+        tmp32 = (tmp32 + 512) >> 10;
+        CLIP_RESULT(tmp32)
+        dst[24] = tmp32;
+
+        src_16 -= ((18 << 4) - 1);
+        dst -= ((24 << 4) - 1);
     }
 
     /* do vertical interpolation */
     ref = subpel_pred + 2;
     dst = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 10th array 18x17 */
     dst -= 24; // offset
-    src = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 12th array 17x17 */
-    src -= 24; // offset
-    dst4 = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 11th array 17x17 */
-    dst4 -= 24; // offset
 
-    for (j = 0; j < 17; j++)
+    for (i = 2; i > 0; i--)
     {
-        tmp32 = ref[0] + ref[24*5] - 5 * (ref[24] + ref[24*4]) + 20 * (ref[24*2] + ref[24*3]);
-        ref += 24;
-        tmp32 = (tmp32 + 16) >> 5;
-        tmp32 = AVC_CLIP(tmp32);
-        *(dst += 24) = tmp32;
-        *(dst4 += 24) = (tmp32 + *(src += 24) + 1) >> 1;
-    }
-    dst -= ((24 * 17) - 1);
-    dst4 -= ((24 * 17) - 1);
-    ref -= ((24 * 17) - 1);
-    src -= ((24 * 17) - 1); // 12th
-
-    dst2 = subpel_pred + V1Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 5th array 16x17 */
-    dst2 -= 24; //offset
-    dst3 = subpel_pred + V3Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 1st array 16x17 */
-    dst3 -= 24; //offset
-    dst5 = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 9th array 17x17 */
-    dst5 -= 24; //offset
-
-    for (i = 0; i < 16; i++)
-    {
-        for (j = 0; j < 17; j++)
+        for (j = 16; j > 0; j -= 4)
         {
-            tmp32 = ref[0] + ref[24*5] - 5 * (ref[24] + ref[24*4]) + 20 * (ref[24*2] + ref[24*3]);
-            ref += 24;
+            a = *ref;
+            b = *(ref += 24);
+            c = *(ref += 24);
+            d = *(ref += 24);
+            e = *(ref += 24);
+            f = *(ref += 24);
+
+            tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
             tmp32 = (tmp32 + 16) >> 5;
-            tmp32 = AVC_CLIP(tmp32);
+            CLIP_RESULT(tmp32)
             *(dst += 24) = tmp32;  // 10th
-            *(dst2 += 24) = (tmp32 + ref[24] + 1) >> 1;  // 5th
-            *(dst3 += 24) = (tmp32 + ref[24*2] + 1) >> 1; // 1st
-            *(dst4 += 24) = (tmp32 + *(src += 24) + 1) >> 1; // 11th
-            *(dst5 += 24) = (tmp32 + src[-1] + 1) >> 1;  // 9th
+
+            a = *(ref += 24);
+            tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            b = *(ref += 24);
+            tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            c = *(ref += 24);
+            tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            ref -= (24 << 2);
         }
 
-        dst -= ((24 * 17) - 1);
-        dst2 -= ((24 * 17) - 1);
-        dst3 -= ((24 * 17) - 1);
-        dst4 -= ((24 * 17) - 1);
-        dst5 -= ((24 * 17) - 1);
-        ref -= ((24 * 17) - 1);
-        src -= ((24 * 17) - 1);
-    }
-
-    src--;
-    for (j = 0; j < 17; j++)
-    {
-        tmp32 = ref[0] + ref[24*5] - 5 * (ref[24] + ref[24*4]) + 20 * (ref[24*2] + ref[24*3]);
-        ref += 24;
+        d = ref[120]; // 24*5
+        tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
         tmp32 = (tmp32 + 16) >> 5;
-        tmp32 = AVC_CLIP(tmp32);
-        *(dst += 24) = tmp32;
-        *(dst5 += 24) = (tmp32 + *(src += 24) + 1) >> 1;
+        CLIP_RESULT(tmp32)
+        dst[24] = tmp32;  // 10th
+
+        dst -= ((24 << 4) - 1);
+        ref -= ((24 << 4) - 1);
     }
 
-    /* now diagonal direction */
-    ref = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE;  // 14th
-    src = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE;  // 10th
-    dst = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE;  // 4th
-    dst2 = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE; // 6th
-    dst3 = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE; // 2th
-    dst4 = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE; // 8th
-
-    for (j = 0; j < 17; j++)
+    // note that using SIMD here doesn't help much, the cycle almost stays the same
+    // one can just use the above code and change the for(i=2 to for(i=18
+    for (i = 16; i > 0; i -= 4)
     {
-        for (i = 0; i < 17; i++)
+        msk = 0;
+        for (j = 17; j > 0; j--)
         {
-            *dst3++ = (ref[24] + *src + 1) >> 1;
-            *dst2++ = (*ref + src[1] + 1) >> 1;
-            *dst4++ = (ref[24] + src[1] + 1) >> 1;
-            *dst++ = (*ref++ + *src++ + 1) >> 1;
+            a = *((uint32*)ref); /* load 4 bytes */
+            b = (a >> 8) & 0xFF00FF; /* second and fourth byte */
+            a &= 0xFF00FF;
+
+            c = *((uint32*)(ref + 120));
+            d = (c >> 8) & 0xFF00FF;
+            c &= 0xFF00FF;
+
+            a += c;
+            b += d;
+
+            e = *((uint32*)(ref + 72)); /* e, f */
+            f = (e >> 8) & 0xFF00FF;
+            e &= 0xFF00FF;
+
+            c = *((uint32*)(ref + 48));	/* c, d */
+            d = (c >> 8) & 0xFF00FF;
+            c &= 0xFF00FF;
+
+            c += e;
+            d += f;
+
+            a += 20 * c;
+            b += 20 * d;
+            a += 0x100010;
+            b += 0x100010;
+
+            e = *((uint32*)(ref += 24)); /* e, f */
+            f = (e >> 8) & 0xFF00FF;
+            e &= 0xFF00FF;
+
+            c = *((uint32*)(ref + 72)); /* c, d */
+            d = (c >> 8) & 0xFF00FF;
+            c &= 0xFF00FF;
+
+            c += e;
+            d += f;
+
+            a -= 5 * c;
+            b -= 5 * d;
+
+            c = a << 16;
+            d = b << 16;
+            CLIP_UPPER16(a)
+            CLIP_UPPER16(c)
+            CLIP_UPPER16(b)
+            CLIP_UPPER16(d)
+
+            a |= (c >> 16);
+            b |= (d >> 16);
+            //	a>>=5;
+            //	b>>=5;
+            /* clip */
+            //	msk |= b;  msk|=a;
+            //	a &= 0xFF00FF;
+            //	b &= 0xFF00FF;
+            a |= (b << 8);  /* pack it back */
+
+            *((uint16*)(dst += 24)) = a & 0xFFFF; //dst is not word-aligned.
+            *((uint16*)(dst + 2)) = a >> 16;
+
         }
-        dst += 7;
-        dst2 += 7;
-        dst3 += 7;
-        dst4 += 7;
-        ref += 7;
-        src += 7;
+        dst -= 404; // 24*17-4
+        ref -= 404;
+        /*		if(msk & 0xFF00FF00) // need clipping
+        		{
+        			VertInterpWClip(dst,ref); // re-do 4 column with clip
+        		}*/
     }
 
     return ;
 }
 
+void VertInterpWClip(uint8 *dst, uint8 *ref)
+{
+    int i, j;
+    int a, b, c, d, e, f;
+    int32 tmp32;
+
+    dst -= 4;
+    ref -= 4;
+
+    for (i = 4; i > 0; i--)
+    {
+        for (j = 16; j > 0; j -= 4)
+        {
+            a = *ref;
+            b = *(ref += 24);
+            c = *(ref += 24);
+            d = *(ref += 24);
+            e = *(ref += 24);
+            f = *(ref += 24);
+
+            tmp32 = a + f - 5 * (b + e) + 20 * (c + d);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            a = *(ref += 24);
+            tmp32 = b + a - 5 * (c + f) + 20 * (d + e);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            b = *(ref += 24);
+            tmp32 = c + b - 5 * (d + a) + 20 * (e + f);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            c = *(ref += 24);
+            tmp32 = d + c - 5 * (e + b) + 20 * (f + a);
+            tmp32 = (tmp32 + 16) >> 5;
+            CLIP_RESULT(tmp32)
+            *(dst += 24) = tmp32;  // 10th
+
+            ref -= (24 << 2);
+        }
+
+        d = ref[120]; // 24*5
+        tmp32 = e + d - 5 * (f + c) + 20 * (a + b);
+        tmp32 = (tmp32 + 16) >> 5;
+        CLIP_RESULT(tmp32)
+        dst[24] = tmp32;  // 10th
+
+        dst -= ((24 << 4) - 1);
+        ref -= ((24 << 4) - 1);
+    }
+
+    return ;
+}
+
+
+void GenerateQuartPelPred(uint8 **bilin_base, uint8 *qpel_cand, int hpel_pos)
+{
+    // for even value of hpel_pos, start with pattern 1, otherwise, start with pattern 2
+    int i, j;
+
+    uint8 *c1 = qpel_cand;
+    uint8 *tl = bilin_base[0];
+    uint8 *tr = bilin_base[1];
+    uint8 *bl = bilin_base[2];
+    uint8 *br = bilin_base[3];
+    int a, b, c, d;
+    int offset = 1 - (384 * 7);
+
+    if (!(hpel_pos&1)) // diamond pattern
+    {
+        j = 16;
+        while (j--)
+        {
+            i = 16;
+            while (i--)
+            {
+                d = tr[24];
+                a = *tr++;
+                b = bl[1];
+                c = *br++;
+
+                *c1 = (c + a + 1) >> 1;
+                *(c1 += 384) = (b + a + 1) >> 1; /* c2 */
+                *(c1 += 384) = (b + c + 1) >> 1; /* c3 */
+                *(c1 += 384) = (b + d + 1) >> 1; /* c4 */
+
+                b = *bl++;
+
+                *(c1 += 384) = (c + d + 1) >> 1;  /* c5 */
+                *(c1 += 384) = (b + d + 1) >> 1;  /* c6 */
+                *(c1 += 384) = (b + c + 1) >> 1;  /* c7 */
+                *(c1 += 384) = (b + a + 1) >> 1;  /* c8 */
+
+                c1 += offset;
+            }
+            // advance to the next line, pitch is 24
+            tl += 8;
+            tr += 8;
+            bl += 8;
+            br += 8;
+            c1 += 8;
+        }
+    }
+    else // star pattern
+    {
+        j = 16;
+        while (j--)
+        {
+            i = 16;
+            while (i--)
+            {
+                a = *br++;
+                b = *tr++;
+                c = tl[1];
+                *c1 = (a + b + 1) >> 1;
+                b = bl[1];
+                *(c1 += 384) = (a + c + 1) >> 1; /* c2 */
+                c = tl[25];
+                *(c1 += 384) = (a + b + 1) >> 1; /* c3 */
+                b = tr[23];
+                *(c1 += 384) = (a + c + 1) >> 1; /* c4 */
+                c = tl[24];
+                *(c1 += 384) = (a + b + 1) >> 1; /* c5 */
+                b = *bl++;
+                *(c1 += 384) = (a + c + 1) >> 1; /* c6 */
+                c = *tl++;
+                *(c1 += 384) = (a + b + 1) >> 1; /* c7 */
+                *(c1 += 384) = (a + c + 1) >> 1; /* c8 */
+
+                c1 += offset;
+            }
+            // advance to the next line, pitch is 24
+            tl += 8;
+            tr += 8;
+            bl += 8;
+            br += 8;
+            c1 += 8;
+        }
+    }
+
+    return ;
+}
+
+
 /* assuming cand always has a pitch of 24 */
 int SATD_MB(uint8 *cand, uint8 *cur, int dmin)
 {
     int cost;
-    int j, k;
+
+#if 1
+
+    dmin = (dmin << 16) | 24;
+    cost = AVCSAD_Macroblock_C(cand, cur, dmin, NULL);
+
+    return cost;
+#else
     int16 res[256], *pres; // residue
     int m0, m1, m2, m3;
-
+    int j, k;
     // calculate SATD
     pres = res;
     // horizontal transform
@@ -553,6 +684,7 @@
     }
 
     return (cost >> 1);
+#endif
 }
 
 
diff --git a/codecs_v2/video/avc_h264/enc/src/header.cpp b/codecs_v2/video/avc_h264/enc/src/header.cpp
index b12aeb8..f70c83a 100644
--- a/codecs_v2/video/avc_h264/enc/src/header.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/header.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 {
     AVCCommonObj *video = encvid->common;
     AVCSeqParamSet *seqParam = video->currSeqParams;
+    AVCVUIParams *vui = &(seqParam->vui_parameters);
     int i;
     AVCEnc_Status status = AVCENC_SUCCESS;
 
@@ -101,12 +102,124 @@
     if (seqParam->vui_parameters_present_flag)
     {
         /* not supported */
-        return AVCENC_SPS_FAIL;
+        //return AVCENC_SPS_FAIL;
+        EncodeVUI(stream, vui);
     }
 
     return status;
 }
 
+
+void EncodeVUI(AVCEncBitstream* stream, AVCVUIParams* vui)
+{
+    int temp;
+
+    temp = vui->aspect_ratio_info_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        BitstreamWriteBits(stream, 8, vui->aspect_ratio_idc);
+        if (vui->aspect_ratio_idc == 255)
+        {
+            BitstreamWriteBits(stream, 16, vui->sar_width);
+            BitstreamWriteBits(stream, 16, vui->sar_height);
+        }
+    }
+    temp = vui->overscan_info_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        BitstreamWrite1Bit(stream, vui->overscan_appropriate_flag);
+    }
+    temp = vui->video_signal_type_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        BitstreamWriteBits(stream, 3, vui->video_format);
+        BitstreamWrite1Bit(stream, vui->video_full_range_flag);
+        temp = vui->colour_description_present_flag;
+        BitstreamWrite1Bit(stream, temp);
+        if (temp)
+        {
+            BitstreamWriteBits(stream, 8, vui->colour_primaries);
+            BitstreamWriteBits(stream, 8, vui->transfer_characteristics);
+            BitstreamWriteBits(stream, 8, vui->matrix_coefficients);
+        }
+    }
+    temp = vui->chroma_location_info_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        ue_v(stream, vui->chroma_sample_loc_type_top_field);
+        ue_v(stream, vui->chroma_sample_loc_type_bottom_field);
+    }
+
+    temp = vui->timing_info_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        BitstreamWriteBits(stream, 32, vui->num_units_in_tick);
+        BitstreamWriteBits(stream, 32, vui->time_scale);
+        BitstreamWrite1Bit(stream, vui->fixed_frame_rate_flag);
+    }
+
+    temp = vui->nal_hrd_parameters_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        EncodeHRD(stream, &(vui->nal_hrd_parameters));
+    }
+    temp = vui->vcl_hrd_parameters_present_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        EncodeHRD(stream, &(vui->vcl_hrd_parameters));
+    }
+    if (vui->nal_hrd_parameters_present_flag || vui->vcl_hrd_parameters_present_flag)
+    {
+        BitstreamWrite1Bit(stream, vui->low_delay_hrd_flag);
+    }
+    BitstreamWrite1Bit(stream, vui->pic_struct_present_flag);
+    temp = vui->bitstream_restriction_flag;
+    BitstreamWrite1Bit(stream, temp);
+    if (temp)
+    {
+        BitstreamWrite1Bit(stream, vui->motion_vectors_over_pic_boundaries_flag);
+        ue_v(stream, vui->max_bytes_per_pic_denom);
+        ue_v(stream, vui->max_bits_per_mb_denom);
+        ue_v(stream, vui->log2_max_mv_length_horizontal);
+        ue_v(stream, vui->log2_max_mv_length_vertical);
+        ue_v(stream, vui->max_dec_frame_reordering);
+        ue_v(stream, vui->max_dec_frame_buffering);
+    }
+
+    return ;
+}
+
+
+void EncodeHRD(AVCEncBitstream* stream, AVCHRDParams* hrd)
+{
+    int i;
+
+    ue_v(stream, hrd->cpb_cnt_minus1);
+    BitstreamWriteBits(stream, 4, hrd->bit_rate_scale);
+    BitstreamWriteBits(stream, 4, hrd->cpb_size_scale);
+    for (i = 0; i <= (int)hrd->cpb_cnt_minus1; i++)
+    {
+        ue_v(stream, hrd->bit_rate_value_minus1[i]);
+        ue_v(stream, hrd->cpb_size_value_minus1[i]);
+        ue_v(stream, hrd->cbr_flag[i]);
+    }
+    BitstreamWriteBits(stream, 5, hrd->initial_cpb_removal_delay_length_minus1);
+    BitstreamWriteBits(stream, 5, hrd->cpb_removal_delay_length_minus1);
+    BitstreamWriteBits(stream, 5, hrd->dpb_output_delay_length_minus1);
+    BitstreamWriteBits(stream, 5, hrd->time_offset_length);
+
+    return ;
+}
+
+
+
 /** see subclause 7.4.2.2 */
 /* no need for checking the valid range , already done in SetEncodeParam().
 If we have to send another SPS, the ranges should be verified first before
diff --git a/codecs_v2/video/avc_h264/enc/src/init.cpp b/codecs_v2/video/avc_h264/enc/src/init.cpp
index dffaf05..e3bf7d6 100644
--- a/codecs_v2/video/avc_h264/enc/src/init.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/init.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
  */
 #include "avcenc_lib.h"
 #include "avcenc_api.h"
+#include "oscl_string.h"
 
 #define LOG2_MAX_FRAME_NUM_MINUS4	12   /* 12 default */
 #define SLICE_GROUP_CHANGE_CYCLE	1    /* default */
@@ -40,6 +41,7 @@
 
     if (extSPS) extS = (AVCSeqParamSet*) extSPS;
     if (extPPS) extP = (AVCPicParamSet*) extPPS;
+
     /* This part sets the default values of the encoding options this
     library supports in seqParam, picParam and sliceHdr structures and
     also copy the values from the encParam into the above 3 structures.
@@ -87,7 +89,7 @@
 
     if (!extS && !extP)
     {
-        maxFrameNum = (encParam->idr_period == 0) ? (1 << 16) : encParam->idr_period;
+        maxFrameNum = (encParam->idr_period == -1) ? (1 << 16) : encParam->idr_period;
         ii = 0;
         while (maxFrameNum > 0)
         {
@@ -155,7 +157,7 @@
         seqParam->log2_max_frame_num_minus4 = extS->log2_max_frame_num_minus4;
         video->MaxFrameNum = 1 << (extS->log2_max_frame_num_minus4 + 4);
         video->MaxPicNum = video->MaxFrameNum;
-        if (encParam->idr_period > (int)(video->MaxFrameNum))
+        if (encParam->idr_period > (int)(video->MaxFrameNum) || (encParam->idr_period == -1))
         {
             encParam->idr_period = (int)video->MaxFrameNum;
         }
@@ -206,11 +208,6 @@
         }
 
         seqParam->direct_8x8_inference_flag = extS->direct_8x8_inference_flag;
-        if (extS->direct_8x8_inference_flag != FALSE)
-        {
-            return AVCENC_NOT_SUPPORTED;
-        }
-
         seqParam->frame_cropping_flag = extS->frame_cropping_flag ;
         if (extS->frame_cropping_flag != FALSE)
         {
@@ -221,7 +218,11 @@
         seqParam->frame_crop_left_offset = 0;
         seqParam->frame_crop_right_offset = 0;
         seqParam->frame_crop_top_offset = 0;
-        seqParam->vui_parameters_present_flag = FALSE; /* default */
+        seqParam->vui_parameters_present_flag = extS->vui_parameters_present_flag;
+        if (extS->vui_parameters_present_flag)
+        {
+            oscl_memcpy(&(seqParam->vui_parameters), &(extS->vui_parameters), sizeof(AVCVUIParams));
+        }
     }
 
     /***************** now PPS ******************************/
@@ -422,7 +423,7 @@
         }
 
         picParam->weighted_pred_flag = 0; /* no weighted prediction supported */
-        picParam->weighted_bipred_idc = 0; /* range 0,1,2 */
+        picParam->weighted_bipred_idc = extP->weighted_bipred_idc; /* range 0,1,2 */
         if (/*picParam->weighted_bipred_idc < 0 || (no need, it's unsigned) */
             picParam->weighted_bipred_idc > 2)
         {
@@ -452,7 +453,7 @@
         {
             return AVCENC_NOT_SUPPORTED;
         }
-        picParam->redundant_pic_cnt_present_flag = 0; /* default */
+        picParam->redundant_pic_cnt_present_flag = extP->redundant_pic_cnt_present_flag; /* default */
     }
 
     /****************** now set up some SliceHeader parameters ***********/
@@ -493,12 +494,13 @@
 
     /* now the rate control and performance related parameters */
     rateCtrl->scdEnable = (encParam->auto_scd == AVC_ON) ? TRUE : FALSE;
-    rateCtrl->idrPeriod = encParam->idr_period;
+    rateCtrl->idrPeriod = encParam->idr_period + 1;
     rateCtrl->intraMBRate = encParam->intramb_refresh;
     rateCtrl->dpEnable = (encParam->data_par == AVC_ON) ? TRUE : FALSE;
 
     rateCtrl->subPelEnable = (encParam->sub_pel == AVC_ON) ? TRUE : FALSE;
     rateCtrl->mvRange = encParam->search_range;
+
     rateCtrl->subMBEnable = (encParam->submb_pred == AVC_ON) ? TRUE : FALSE;
     rateCtrl->rdOptEnable = (encParam->rdopt_mode == AVC_ON) ? TRUE : FALSE;
     rateCtrl->bidirPred = (encParam->bidir_pred == AVC_ON) ? TRUE : FALSE;
@@ -646,10 +648,10 @@
         {
             if (mb_per_sec <= MaxMBPS[ii] &&
                     video->PicSizeInMbs <= (uint)MaxFS[ii] &&
-                    rateCtrl->bitRate <= (int32)MaxBR[ii] &&
-                    rateCtrl->cpbSize <= (int32)MaxCPB[ii] &&
+                    rateCtrl->bitRate <= (int32)MaxBR[ii]*1000 &&
+                    rateCtrl->cpbSize <= (int32)MaxCPB[ii]*1000 &&
                     rateCtrl->mvRange <= MaxVmvR[ii] &&
-                    dpb_size <= MaxDPBX2[ii])
+                    dpb_size <= MaxDPBX2[ii]*512)
             {
                 seqParam->level_idc = mapIdx2Lev[ii];
                 break;
@@ -711,6 +713,11 @@
         }
     }
 
+    /* flexible macroblock ordering (every frame)*/
+    /* populate video->mapUnitToSliceGroupMap and video->MbToSliceGroupMap */
+    /* It changes once per each PPS. */
+    FMOInit(video);
+
     ret = DPBInitBuffer(encvid->avcHandle, video); // get new buffer
 
     if (ret != AVC_SUCCESS)
@@ -767,9 +774,6 @@
     video->mbNum = 0; /* start from zero MB */
     encvid->currSliceGroup = 0; /* start from slice group #0 */
     encvid->numIntraMB = 0; /* reset this counter */
-    encvid->numDetected = 0;
-    encvid->numFalseAlarm = 0;
-    encvid->numMisDetected = 0;
 
     if (video->nal_unit_type == AVC_NALTYPE_IDR)
     {
diff --git a/codecs_v2/video/avc_h264/enc/src/intra_est.cpp b/codecs_v2/video/avc_h264/enc/src/intra_est.cpp
index 58b3dfe..538b5c5 100644
--- a/codecs_v2/video/avc_h264/enc/src/intra_est.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/intra_est.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -195,7 +195,7 @@
         chroma_intra_search(encvid);
 
         /* need to set this in order for the MBInterPrediction to work!! */
-        oscl_memset(currMB->mvL0, 0, sizeof(int16)*32);
+        oscl_memset(currMB->mvL0, 0, sizeof(int32)*16);
         currMB->ref_idx_L0[0] = currMB->ref_idx_L0[1] =
                                     currMB->ref_idx_L0[2] = currMB->ref_idx_L0[3] = -1;
     }
@@ -1042,7 +1042,7 @@
         Q_y = (P_I + 2 * P_J + P_K + 2) >> 2;
         R_y = (P_J + 2 * P_K + P_L + 2) >> 2;
 
-        /* we can pack these MC */
+        /* we can pack these */
         temp =  D | (P_x << 8);   //[D   P_x Q_x R_x]
         //[P_y D   P_x Q_x]
         temp |= (Q_x << 16); //[Q_y P_y D   P_x]
@@ -1132,7 +1132,7 @@
         S0 >>= 1;
 
 
-        /* we can pack these MC */
+        /* we can pack these */
         temp = P0 | (D << 8);   //[P0 D  P2 Q2]
         //[Q0 P1 P0 D ]
         temp |= (P2 << 16);  //[R0 Q1 Q0 P1]
@@ -2005,8 +2005,8 @@
     }
 
     /* also reset the motion vectors */
-    /* set MV and Ref_Idx codes of Intra blocks in P-slices MC */
-    oscl_memset(currMB->mvL0, 0, sizeof(int16)*32);
+    /* set MV and Ref_Idx codes of Intra blocks in P-slices */
+    oscl_memset(currMB->mvL0, 0, sizeof(int32)*16);
     currMB->ref_idx_L0[0] = -1;
     currMB->ref_idx_L0[1] = -1;
     currMB->ref_idx_L0[2] = -1;
@@ -2248,8 +2248,8 @@
         }
 
         /* also reset the motion vectors */
-        /* set MV and Ref_Idx codes of Intra blocks in P-slices MC */
-        oscl_memset(currMB->mvL0, 0, sizeof(int16)*32);
+        /* set MV and Ref_Idx codes of Intra blocks in P-slices */
+        oscl_memset(currMB->mvL0, 0, sizeof(int32)*16);
         oscl_memset(currMB->ref_idx_L0, -1, sizeof(int16)*4);
 
     }
diff --git a/codecs_v2/video/avc_h264/enc/src/motion_comp.cpp b/codecs_v2/video/avc_h264/enc/src/motion_comp.cpp
index 920b556..e6af141 100644
--- a/codecs_v2/video/avc_h264/enc/src/motion_comp.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/motion_comp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -86,9 +86,9 @@
 
         for (subMbPartIdx = 0; subMbPartIdx < currMB->NumSubMbPart[mbPartIdx]; subMbPartIdx++)
         {
-            block_x = (mbPartIdx_X << 1) + ((subMbPartIdx + offset_indx) & 1);  // check this MC
+            block_x = (mbPartIdx_X << 1) + ((subMbPartIdx + offset_indx) & 1);
             block_y = (mbPartIdx_Y << 1) + (((subMbPartIdx + offset_indx) >> 1) & 1);
-            mv = &currMB->mvL0[0] + (block_x << 1) + (block_y << 3);
+            mv = (int16*)(currMB->mvL0 + block_x + (block_y << 2));
             offset_x = x_position + (block_x << 2);
             offset_y = y_position + (block_y << 2);
             x_pos = (offset_x << 2) + *mv++;   /*quarter pel */
@@ -1834,7 +1834,7 @@
 }
 
 
-/* SIMD routines, unroll the loops in vertical direction, decreasing loops (things to be done) MC */
+/* SIMD routines, unroll the loops in vertical direction, decreasing loops (things to be done) */
 void eChromaDiagonalMC_SIMD(uint8 *pRef, int srcPitch, int dx, int dy,
                             uint8 *pOut, int predPitch, int blkwidth, int blkheight)
 {
@@ -1922,7 +1922,7 @@
             ref += 32;
         }
         pOut += 4;
-        ref = temp + 4; /* since it can only iterate twice max MC */
+        ref = temp + 4; /* since it can only iterate twice max */
     }
     return;
 }
diff --git a/codecs_v2/video/avc_h264/enc/src/motion_est.cpp b/codecs_v2/video/avc_h264/enc/src/motion_est.cpp
index 631b5a8..5ac29b9 100644
--- a/codecs_v2/video/avc_h264/enc/src/motion_est.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/motion_est.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,8 +65,6 @@
 #define FIXED_SUBMB_MODE	AVC_4x4
 /*************************************************************************/
 
-
-
 /* Initialize arrays necessary for motion search */
 AVCEnc_Status InitMotionSearchModule(AVCHandle *avcHandle)
 {
@@ -113,101 +111,61 @@
     encvid->hpel_cand[0] = subpel_pred + REF_CENTER;
     encvid->hpel_cand[1] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1 ;
     encvid->hpel_cand[2] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
-    encvid->hpel_cand[3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 73;
+    encvid->hpel_cand[3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
     encvid->hpel_cand[4] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
     encvid->hpel_cand[5] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 25;
     encvid->hpel_cand[6] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
-    encvid->hpel_cand[7] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 72;
+    encvid->hpel_cand[7] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
     encvid->hpel_cand[8] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
 
-    encvid->qpel_cand[0][0] = subpel_pred + V3Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 1st */
-    encvid->qpel_cand[0][1] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 2nd */
-    encvid->qpel_cand[0][2] = subpel_pred + V0Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 3rd */
-    encvid->qpel_cand[0][3] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 4th */
-    encvid->qpel_cand[0][4] = subpel_pred + V1Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 5th */
-    encvid->qpel_cand[0][5] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 6th */
-    encvid->qpel_cand[0][6] = subpel_pred + V0Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 7th */
-    encvid->qpel_cand[0][7] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 8th */
+    /* For quarter-pel interpolation around best half-pel result */
 
-    /* top */
-    encvid->qpel_cand[1][0] = subpel_pred + V1Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 5th */
-    encvid->qpel_cand[1][1] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 4th */
-    encvid->qpel_cand[1][2] = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 11th */
-    encvid->qpel_cand[1][3] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 2nd */
-    encvid->qpel_cand[1][4] = subpel_pred + V3Q_H0Q * SUBPEL_PRED_BLK_SIZE; /* 1st */
-    encvid->qpel_cand[1][5] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 8th */
-    encvid->qpel_cand[1][6] = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 9th */
-    encvid->qpel_cand[1][7] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 6th */
+    encvid->bilin_base[0][0] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[0][1] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
+    encvid->bilin_base[0][2] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
+    encvid->bilin_base[0][3] = subpel_pred + REF_CENTER;
 
-    /* corner */
-    encvid->qpel_cand[2][0] = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1; /* 15th */
-    encvid->qpel_cand[2][1] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE + 1; /* 6th */
-    encvid->qpel_cand[2][2] = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE + 1; /* 9th */
-    encvid->qpel_cand[2][3] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE + 1; /* 8th */
-    encvid->qpel_cand[2][4] = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1; /* 13th */
-    encvid->qpel_cand[2][5] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 2nd */
-    encvid->qpel_cand[2][6] = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 11th */
-    encvid->qpel_cand[2][7] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 4th */
 
-    /* right */
-    encvid->qpel_cand[3][0] = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1; /* 13th */
-    encvid->qpel_cand[3][1] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE + 1; /* 8th */
-    encvid->qpel_cand[3][2] = subpel_pred + V0Q_H3Q * SUBPEL_PRED_BLK_SIZE + 1; /* 7th */
-    encvid->qpel_cand[3][3] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE + 25; /* 6th */
-    encvid->qpel_cand[3][4] = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25; /* 15th */
-    encvid->qpel_cand[3][5] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 4th */
-    encvid->qpel_cand[3][6] = subpel_pred + V0Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 3rd */
-    encvid->qpel_cand[3][7] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE + 1; /* 2nd */
+    encvid->bilin_base[1][0] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[1][1] = subpel_pred + REF_CENTER - 24;
+    encvid->bilin_base[1][2] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[1][3] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
 
-    /* corner */
-    encvid->qpel_cand[4][0] = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25; /* 15th */
-    encvid->qpel_cand[4][1] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE + 25; /* 6th */
-    encvid->qpel_cand[4][2] = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE + 25; /* 9th */
-    encvid->qpel_cand[4][3] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE + 25; /* 8th */
-    encvid->qpel_cand[4][4] = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25; /* 13th */
-    encvid->qpel_cand[4][5] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 2nd */
-    encvid->qpel_cand[4][6] = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 11th */
-    encvid->qpel_cand[4][7] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 4th */
+    encvid->bilin_base[2][0] = subpel_pred + REF_CENTER - 24;
+    encvid->bilin_base[2][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
+    encvid->bilin_base[2][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
+    encvid->bilin_base[2][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
 
-    /* bottom */
-    encvid->qpel_cand[5][0] = subpel_pred + V1Q_H0Q * SUBPEL_PRED_BLK_SIZE + 24; /* 5th */
-    encvid->qpel_cand[5][1] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 4th */
-    encvid->qpel_cand[5][2] = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 11th */
-    encvid->qpel_cand[5][3] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE + 25; /* 2nd */
-    encvid->qpel_cand[5][4] = subpel_pred + V3Q_H0Q * SUBPEL_PRED_BLK_SIZE + 24; /* 1st */
-    encvid->qpel_cand[5][5] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 8th */
-    encvid->qpel_cand[5][6] = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 9th */
-    encvid->qpel_cand[5][7] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 6th */
+    encvid->bilin_base[3][0] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 1;
+    encvid->bilin_base[3][1] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 1;
+    encvid->bilin_base[3][2] = subpel_pred + REF_CENTER;
+    encvid->bilin_base[3][3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
 
-    /* corner */
-    encvid->qpel_cand[6][0] = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24; /* 15th */
-    encvid->qpel_cand[6][1] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 6th */
-    encvid->qpel_cand[6][2] = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 9th */
-    encvid->qpel_cand[6][3] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 8th */
-    encvid->qpel_cand[6][4] = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24; /* 13th */
-    encvid->qpel_cand[6][5] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE + 24; /* 2nd */
-    encvid->qpel_cand[6][6] = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE + 24; /* 11th */
-    encvid->qpel_cand[6][7] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 24; /* 4th */
+    encvid->bilin_base[4][0] = subpel_pred + REF_CENTER;
+    encvid->bilin_base[4][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
+    encvid->bilin_base[4][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 25;
+    encvid->bilin_base[4][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 25;
 
-    /* left */
-    encvid->qpel_cand[7][0] = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 13th */
-    encvid->qpel_cand[7][1] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 8th */
-    encvid->qpel_cand[7][2] = subpel_pred + V0Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 7th */
-    encvid->qpel_cand[7][3] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE + 24; /* 6th */
-    encvid->qpel_cand[7][4] = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24; /* 15th */
-    encvid->qpel_cand[7][5] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE + 24; /* 4th */
-    encvid->qpel_cand[7][6] = subpel_pred + V0Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 3rd */
-    encvid->qpel_cand[7][7] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 2nd */
+    encvid->bilin_base[5][0] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
+    encvid->bilin_base[5][1] = subpel_pred + REF_CENTER;
+    encvid->bilin_base[5][2] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
+    encvid->bilin_base[5][3] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 25;
 
-    /* corner */
-    encvid->qpel_cand[8][0] = subpel_pred + V1Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 15th */
-    encvid->qpel_cand[8][1] = subpel_pred + V1Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 6th */
-    encvid->qpel_cand[8][2] = subpel_pred + V2Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 9th */
-    encvid->qpel_cand[8][3] = subpel_pred + V3Q_H3Q * SUBPEL_PRED_BLK_SIZE; /* 8th */
-    encvid->qpel_cand[8][4] = subpel_pred + V3Q_H2Q * SUBPEL_PRED_BLK_SIZE; /* 13th */
-    encvid->qpel_cand[8][5] = subpel_pred + V3Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 2nd */
-    encvid->qpel_cand[8][6] = subpel_pred + V2Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 11th */
-    encvid->qpel_cand[8][7] = subpel_pred + V1Q_H1Q * SUBPEL_PRED_BLK_SIZE; /* 4th */
+    encvid->bilin_base[6][0] = subpel_pred + REF_CENTER - 1;
+    encvid->bilin_base[6][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
+    encvid->bilin_base[6][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE + 24;
+    encvid->bilin_base[6][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
+
+    encvid->bilin_base[7][0] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[7][1] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[7][2] = subpel_pred + REF_CENTER - 1;
+    encvid->bilin_base[7][3] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE + 24;
+
+    encvid->bilin_base[8][0] = subpel_pred + REF_CENTER - 25;
+    encvid->bilin_base[8][1] = subpel_pred + V0Q_H2Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[8][2] = subpel_pred + V2Q_H0Q * SUBPEL_PRED_BLK_SIZE;
+    encvid->bilin_base[8][3] = subpel_pred + V2Q_H2Q * SUBPEL_PRED_BLK_SIZE;
+
 
     return AVCENC_SUCCESS;
 }
@@ -226,6 +184,55 @@
     return ;
 }
 
+
+bool IntraDecisionABE(int *min_cost, uint8 *cur, int pitch, bool ave)
+{
+    int j;
+    uint8 *out;
+    int temp, SBE;
+    OsclFloat ABE;
+    bool intra = true;
+
+    SBE = 0;
+    /* top neighbor */
+    out = cur - pitch;
+    for (j = 0; j < 16; j++)
+    {
+        temp = out[j] - cur[j];
+        SBE += ((temp >= 0) ? temp : -temp);
+    }
+
+    /* left neighbor */
+    out = cur - 1;
+    out -= pitch;
+    cur -= pitch;
+    for (j = 0; j < 16; j++)
+    {
+        temp = *(out += pitch) - *(cur += pitch);
+        SBE += ((temp >= 0) ? temp : -temp);
+    }
+
+    /* compare mincost/384 and SBE/64 */
+    ABE = SBE / 32.0; //ABE = SBE/64.0; //
+    if (ABE >= *min_cost / 256.0) //if( ABE*0.8 >= min_cost/384.0) //
+    {
+        intra = false; // no possibility of intra, just use inter
+    }
+    else
+    {
+        if (ave == true)
+        {
+            *min_cost = (*min_cost + (int)(SBE * 8)) >> 1; // possibility of intra, averaging the cost
+        }
+        else
+        {
+            *min_cost = (int)(SBE * 8);
+        }
+    }
+
+    return intra;
+}
+
 /******* main function for macroblock prediction for the entire frame ***/
 /* if turns out to be IDR frame, set video->nal_unit_type to AVC_NALTYPE_IDR */
 void AVCMotionEstimation(AVCEncObject *encvid)
@@ -251,6 +258,7 @@
     uint8 *cur, *best_cand[5];
     int totalSAD = 0;	/* average SAD for rate control */
     int type_pred;
+    int abe_cost;
 
 #ifdef HTFM
     /***** HYPOTHESIS TESTING ********/  /* 2/28/01 */
@@ -359,9 +367,7 @@
                     AVCMBMotionSearch(encvid, cur, best_cand, i << 4, j << 4, type_pred,
                                       FS_en, &hp_guess);
 
-                    totalSAD += mot_mb_16x16->sad;
-
-                    encvid->min_cost[mbnum] = mot_mb_16x16->sad;
+                    abe_cost = encvid->min_cost[mbnum] = mot_mb_16x16->sad;
 
                     /* set mbMode and MVs */
                     currMB->mbMode = AVC_P16;
@@ -369,23 +375,44 @@
                     mv_uint32 = ((mot_mb_16x16->y) << 16) | ((mot_mb_16x16->x) & 0xffff);
                     for (k = 0; k < 32; k += 2)
                     {
-                        *((uint32*)(&currMB->mvL0[k])) = mv_uint32;
+                        currMB->mvL0[k>>1] = mv_uint32;
                     }
 
                     /* make a decision whether it should be tested for intra or not */
+                    if (i != mbwidth - 1 && j != mbheight - 1 && i != 0 && j != 0)
                     {
-                        // NumIntraSearch++; // This will be used for scene change detection.
-                        // intraSearch[mbnum] = 1;
+                        if (false == IntraDecisionABE(&abe_cost, cur, pitch, true))
+                        {
+                            intraSearch[mbnum] = 0;
+                        }
+                        else
+                        {
+                            NumIntraSearch++;
+                            rateCtrl->MADofMB[mbnum] = abe_cost;
+                        }
                     }
+                    else // boundary MBs, always do intra search
+                    {
+                        NumIntraSearch++;
+                    }
+
+                    totalSAD += (int) rateCtrl->MADofMB[mbnum];//mot_mb_16x16->sad;
                 }
-                else 	/* INTRA update, use for prediction 3/23/01 */
+                else 	/* INTRA update, use for prediction */
                 {
                     mot_mb_16x16[0].x = mot_mb_16x16[0].y = 0;
 
                     /* reset all other MVs to zero */
                     /* mot_mb_16x8, mot_mb_8x16, mot_mb_8x8, etc. */
+                    abe_cost = encvid->min_cost[mbnum] = 0x7FFFFFFF;  /* max value for int */
 
-                    encvid->min_cost[mbnum] = 0x7FFFFFFF;  /* max value for int */
+                    if (i != mbwidth - 1 && j != mbheight - 1 && i != 0 && j != 0)
+                    {
+                        IntraDecisionABE(&abe_cost, cur, pitch, false);
+
+                        rateCtrl->MADofMB[mbnum] = abe_cost;
+                        totalSAD += abe_cost;
+                    }
 
                     NumIntraSearch++ ;
                     /* cannot do I16 prediction here because it needs full decoding. */
@@ -404,15 +431,24 @@
         if (incr_i > 1 && numLoop) /* scene change on and first loop */
         {
             //if(NumIntraSearch > ((totalMB>>3)<<1) + (totalMB>>3)) /* 75% of 50%MBs */
-            if (NumIntraSearch*20 > (3*totalMB)) /* 15% of 50%MBs */
+            if (NumIntraSearch*99 > (48*totalMB)) /* 20% of 50%MBs */
                 /* need to do more investigation about this threshold since the NumIntraSearch
                 only show potential intra MBs, not the actual one */
             {
                 /* we can choose to just encode I_SLICE without IDR */
-                video->nal_unit_type = AVC_NALTYPE_IDR;
-                /* cannot do I16 prediction here because it needs full decoding. */
-
+                //video->nal_unit_type = AVC_NALTYPE_IDR;
+                video->nal_unit_type = AVC_NALTYPE_SLICE;
+                video->sliceHdr->slice_type = AVC_I_ALL_SLICE;
+                video->slice_type = AVC_I_SLICE;
                 oscl_memset(intraSearch, 1, sizeof(uint8)*totalMB);
+                i = totalMB;
+                while (i--)
+                {
+                    mblock[i].mb_intra = 1;
+                    encvid->min_cost[i] = 0x7FFFFFFF;  /* max value for int */
+                }
+
+                rateCtrl->totalSAD = totalSAD * 2;	/* SAD */
 
                 return ;
             }
@@ -425,7 +461,7 @@
     rateCtrl->totalSAD = totalSAD;	/* SAD */
 
 #ifdef HTFM
-    /***** HYPOTHESIS TESTING ********/  /* 2/28/01 */
+    /***** HYPOTHESIS TESTING ********/
     if (collect)
     {
         collect = 0;
@@ -434,19 +470,6 @@
     /*********************************/
 #endif
 
-#if 0
-    if (1) /* scene change detected, need to check the logic in the upper layer */
-    {
-        video->nal_unit_type = AVC_NALTYPE_IDR;
-        video->prevFrameNum = video->MaxFrameNum;
-        video->PrevRefFrameNum = 0;
-        video->sliceHdr->frame_num = 0;
-        video->CurrPicNum = 0;
-        InitPOC(encvid); /* redo the POC */
-        RefListInit(video);
-        return AVCENC_NEW_IDR;
-    }
-#endif
     return ;
 }
 
@@ -565,6 +588,7 @@
         {
             (mblock + indx)->mb_intra = 1;
             encvid->intraSearch[indx++] = 1;
+            i++;
         }
     }
 
@@ -782,7 +806,8 @@
 
 void	AVCPrepareCurMB(AVCEncObject *encvid, uint8 *cur, int pitch)
 {
-    uint32 *currYMB = (uint32*)(encvid->currYMB);
+    void* tmp = (void*)(encvid->currYMB);
+    uint32 *currYMB = (uint32*) tmp;
     int i;
 
     cur -= pitch;
@@ -909,7 +934,7 @@
 
         for (subMbPartIdx = 0; subMbPartIdx < 4; subMbPartIdx++)
         {
-            mv = &currMB->mvL0[0] + (mbPartIdx << 3) + (subMbPartIdx << 1);
+            mv = (int16*)(currMB->mvL0 + (mbPartIdx << 2) + subMbPartIdx);
 
             *mv++ = FIXED_MVX;
             *mv = FIXED_MVY;
@@ -1188,10 +1213,10 @@
     if (rateCtrl->subPelEnable) // always enable half-pel search
     {
         /* find half-pel resolution motion vector */
-        AVCFindHalfPelMB(encvid, cur, mot16x16 + mbnum, best_cand[0], i0, j0, *hp_guess, cmvx, cmvy);
+        min_sad = AVCFindHalfPelMB(encvid, cur, mot16x16 + mbnum, best_cand[0], i0, j0, *hp_guess, cmvx, cmvy);
 
-        /** do motion comp here for now */
-        ref = currPic->Sl + i0 + j0 * lx;
+        encvid->rateCtrl->MADofMB[mbnum] = min_sad / 256.0;
+
 
         if (encvid->best_qpel_pos == -1)
         {
@@ -1199,22 +1224,26 @@
         }
         else
         {
-            ncand = encvid->qpel_cand[encvid->best_hpel_pos][encvid->best_qpel_pos];
-        }
-
-        for (j = 0; j < 16; j++)
-        {
-            for (i = 0; i < 16; i++)
-            {
-                *ref++ = *ncand++;
-            }
-            ref += (lx - 16);
-            ncand += 8;
+            ncand = encvid->qpel_cand[encvid->best_qpel_pos];
         }
     }
+    else
+    {
+        encvid->rateCtrl->MADofMB[mbnum] = min_sad / 256.0;
+    }
 
-
-
+    /** do motion comp here for now */
+    ref = currPic->Sl + i0 + j0 * lx;
+    /* copy from the best result to current Picture */
+    for (j = 0; j < 16; j++)
+    {
+        for (i = 0; i < 16; i++)
+        {
+            *ref++ = *ncand++;
+        }
+        ref += (lx - 16);
+        ncand += 8;
+    }
 
     return ;
 }
diff --git a/codecs_v2/video/avc_h264/enc/src/pvavcencoder.cpp b/codecs_v2/video/avc_h264/enc/src/pvavcencoder.cpp
index 517b071..6be20b4 100644
--- a/codecs_v2/video/avc_h264/enc/src/pvavcencoder.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/pvavcencoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -80,12 +80,18 @@
 /* ///////////////////////////////////////////////////////////////////////// */
 PVAVCEncoder::PVAVCEncoder()
 {
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
+    ccRGBtoYUV = NULL;
+#endif
 //iEncoderControl
 }
 
 /* ///////////////////////////////////////////////////////////////////////// */
 OSCL_EXPORT_REF PVAVCEncoder::~PVAVCEncoder()
 {
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
+    OSCL_DELETE(ccRGBtoYUV);
+#endif
     CleanupEncoder();
 }
 
@@ -123,33 +129,13 @@
 }
 
 /* ///////////////////////////////////////////////////////////////////////// */
-/** overload function */
-OSCL_EXPORT_REF TAVCEI_RETVAL PVAVCEncoder::Initialize(TAVCEIInputFormat *aVidInFormat, TAVCEIEncodeParam *aEncParam,
-        void* extSPS, void* extPPS)
-{
-    AVCEncParams aEncOption; /* encoding options */
-
-    if (EAVCEI_SUCCESS != Init(aVidInFormat, aEncParam, aEncOption))
-    {
-        return EAVCEI_FAIL;
-    }
-
-    if (AVCENC_SUCCESS != PVAVCEncInitialize(&iAvcHandle, &aEncOption, extSPS, extPPS))
-    {
-        return EAVCEI_FAIL;
-    }
-
-    iIDR = true;
-    iState = EInitialized; // change state to initialized
-
-    return EAVCEI_SUCCESS;
-}
-
-/* ///////////////////////////////////////////////////////////////////////// */
 OSCL_EXPORT_REF TAVCEI_RETVAL PVAVCEncoder::Initialize(TAVCEIInputFormat *aVidInFormat, TAVCEIEncodeParam *aEncParam)
 {
     AVCEncParams aEncOption; /* encoding options */
 
+    iOverrunBuffer = NULL;
+    iOBSize = 0;
+
     if (EAVCEI_SUCCESS != Init(aVidInFormat, aEncParam, aEncOption))
     {
         return EAVCEI_FAIL;
@@ -169,6 +155,16 @@
 }
 
 /* ///////////////////////////////////////////////////////////////////////// */
+int32 PVAVCEncoder::GetMaxOutputBufferSize()
+{
+    int32 size = 0;
+
+    PVAVCEncGetMaxOutputBufferSize(&iAvcHandle, &size);
+
+    return size;
+}
+
+/* ///////////////////////////////////////////////////////////////////////// */
 TAVCEI_RETVAL PVAVCEncoder::Init(TAVCEIInputFormat* aVidInFormat, TAVCEIEncodeParam* aEncParam, AVCEncParams& aEncOption)
 {
     if (iState == EInitialized || iState == EEncoding)  /* clean up before re-initialized */
@@ -180,14 +176,7 @@
             oscl_free(iYUVIn);
             iYUVIn = NULL;
         }
-        if (iVideoFormat == EAVCEI_VDOFMT_RGB24 || iVideoFormat == EAVCEI_VDOFMT_RGB12)
-        {
-#if defined(RGB24_INPUT)||defined(RGB12_INPUT)
-            freeRGB2YUVTables();
-#else
-            return EAVCEI_FAIL;
-#endif
-        }
+
     }
 
     iState = ECreated; // change state back to created
@@ -219,16 +208,41 @@
         }
     }
 
-    /* Initialize the color conversion table if needed*/
-    if (iVideoFormat == EAVCEI_VDOFMT_RGB24 || iVideoFormat == EAVCEI_VDOFMT_RGB12)
+    /* Initialize the color conversion pointers */
+    if (iVideoFormat == EAVCEI_VDOFMT_RGB24)
     {
-#if defined(RGB24_INPUT)||defined(RGB12_INPUT)
-        initRGB2YUVTables();
+#ifdef RGB24_INPUT
+        ccRGBtoYUV = CCRGB24toYUV420::New();
 #else
         return EAVCEI_FAIL;
 #endif
     }
 
+    if (iVideoFormat == EAVCEI_VDOFMT_RGB12)
+    {
+#ifdef RGB12_INPUT
+        ccRGBtoYUV = CCRGB12toYUV420::New();
+#else
+        return EAVCEI_FAIL;
+#endif
+    }
+
+    if (iVideoFormat == EAVCEI_VDOFMT_YUV420SEMIPLANAR)
+    {
+#ifdef YUV420SEMIPLANAR_INPUT
+        ccRGBtoYUV = CCYUV420SEMItoYUV420::New();
+#else
+        return EAVCEI_FAIL;
+#endif
+    }
+
+    if ((iVideoFormat == EAVCEI_VDOFMT_RGB24) || (iVideoFormat == EAVCEI_VDOFMT_RGB12) || (iVideoFormat == EAVCEI_VDOFMT_YUV420SEMIPLANAR))
+    {
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined (YUV420SEMIPLANAR_INPUT)
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 1 ? CCBOTTOM_UP : 0));
+#endif
+    }
+
     if (aEncParam->iNumLayer > 1)
     {
         return EAVCEI_FAIL;
@@ -236,6 +250,7 @@
 
     aEncOption.width = iEncWidth = aEncParam->iFrameWidth[0];
     aEncOption.height = iEncHeight = aEncParam->iFrameHeight[0];
+
     iEncFrameRate = aEncParam->iFrameRate[0];
     aEncOption.frame_rate = (uint32)(1000 * iEncFrameRate);
 
@@ -273,10 +288,10 @@
     switch (aEncParam->iIFrameInterval)
     {
         case -1:
-            aEncOption.idr_period = 0;
+            aEncOption.idr_period = -1;
             break;
         case 0:
-            aEncOption.idr_period = 1;
+            aEncOption.idr_period = 0;
             break;
         default:
             aEncOption.idr_period = (int)(aEncParam->iIFrameInterval *  aVidInFormat->iFrameRate);
@@ -286,11 +301,13 @@
     aEncOption.intramb_refresh = aEncParam->iNumIntraMBRefresh;
     aEncOption.auto_scd = (aEncParam->iSceneDetection == true) ? AVC_ON : AVC_OFF;
     aEncOption.out_of_band_param_set = (aEncParam->iOutOfBandParamSet == true) ? AVC_ON : AVC_OFF;
+    aEncOption.use_overrun_buffer = AVC_OFF; // hardcode it to off
 
     /* default values */
     aEncOption.poc_type = 0;
-    aEncOption.log2_max_poc_lsb_minus_4 = 12;
     aEncOption.num_ref_frame = 1;
+
+    aEncOption.log2_max_poc_lsb_minus_4 = 12;
     aEncOption.num_slice_group = 1;
     aEncOption.fmo_type = 0; /// FMO is disabled for now.
     aEncOption.db_filter = AVC_ON;
@@ -307,7 +324,6 @@
     aEncOption.rdopt_mode = AVC_OFF;
     aEncOption.bidir_pred = AVC_OFF;
 
-
     return EAVCEI_SUCCESS;
 }
 
@@ -345,6 +361,7 @@
             *size = 0;
             return EAVCEI_FAIL;
     }
+
 }
 
 #ifdef PVAUTHOR_PROFILING
@@ -361,7 +378,7 @@
 {
     AVCEnc_Status status;
 
-    if (aVidIn == NULL)
+    if ((aVidIn == NULL) || (aVidIn->iSource == NULL))
     {
         return EAVCEI_INPUT_ERROR;
     }
@@ -398,27 +415,15 @@
 #else
         return EAVCEI_INPUT_ERROR;
 #endif
-    if (iVideoFormat == EAVCEI_VDOFMT_RGB12)
-#ifdef RGB12_INPUT
+    if ((iVideoFormat == EAVCEI_VDOFMT_RGB24) || (iVideoFormat == EAVCEI_VDOFMT_RGB12) || (iVideoFormat == EAVCEI_VDOFMT_YUV420SEMIPLANAR))
     {
-        RGB2YUV420_12bit((uint32 *)aVidIn->iSource, iSrcWidth, iSrcHeight,
-        ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined (YUV420SEMIPLANAR_INPUT)
+        ccRGBtoYUV->Convert((uint8*)aVidIn->iSource, iYUVIn);
         iVideoIn = iYUVIn;
-    }
 #else
         return EAVCEI_INPUT_ERROR;
 #endif
-    if (iVideoFormat == EAVCEI_VDOFMT_RGB24)
-#ifdef RGB24_INPUT
-    {
-        RGB2YUV420_24bit(aVidIn->iSource, iSrcWidth, iSrcHeight,
-        ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
-        iVideoIn = iYUVIn;
     }
-#else
-        return EAVCEI_INPUT_ERROR;
-#endif
-
 
 #ifdef PVAUTHOR_PROFILING
     if (aParam1)((CPVAuthorProfile*)aParam1)->Stop(CPVAuthorProfile::EColorInput);
@@ -463,7 +468,7 @@
 }
 
 /* ///////////////////////////////////////////////////////////////////////// */
-OSCL_EXPORT_REF TAVCEI_RETVAL PVAVCEncoder::GetOutput(TAVCEIOutputData *aVidOut
+OSCL_EXPORT_REF TAVCEI_RETVAL PVAVCEncoder::GetOutput(TAVCEIOutputData *aVidOut, int *aRemainingBytes
 #ifdef PVAUTHOR_PROFILING
         , void *aParam1
 #endif
@@ -474,6 +479,7 @@
     uint Size;
     int nalType;
     AVCFrameIO recon;
+    *aRemainingBytes = 0;
 
     if (iState != EEncoding)
     {
@@ -486,28 +492,69 @@
     }
 
 
+    if (iOverrunBuffer) // more output buffer to be copied out.
+    {
+        aVidOut->iFragment = true;
+        aVidOut->iTimeStamp = iTimeStamp;
+        aVidOut->iKeyFrame = iIDR;
+        aVidOut->iLastNAL = (iEncStatus == AVCENC_PICTURE_READY) ? true : false;
+
+        if (iOBSize > aVidOut->iBitstreamSize)
+        {
+            oscl_memcpy(aVidOut->iBitstream, iOverrunBuffer, aVidOut->iBitstreamSize);
+            iOBSize -= aVidOut->iBitstreamSize;
+            iOverrunBuffer += aVidOut->iBitstreamSize;
+            aVidOut->iLastFragment = false;
+            *aRemainingBytes = iOBSize;
+
+            return EAVCEI_MORE_DATA;
+        }
+        else
+        {
+            oscl_memcpy(aVidOut->iBitstream, iOverrunBuffer, iOBSize);
+            aVidOut->iBitstreamSize = iOBSize;
+            iOverrunBuffer = NULL;
+            iOBSize = 0;
+            aVidOut->iLastFragment = true;
+            *aRemainingBytes = 0;
+
+            if (iEncStatus == AVCENC_PICTURE_READY)
+            {
+                iState = EInitialized;
+                if (iIDR == true)
+                {
+                    iIDR = false;
+                }
+
+                return EAVCEI_SUCCESS;
+            }
+            else
+            {
+                return EAVCEI_MORE_NAL;
+            }
+        }
+    }
+
+    // Otherwise, call library to encode another NAL
+
     Size = aVidOut->iBitstreamSize;
 
 #ifdef PVAUTHOR_PROFILING
     if (aParam1)((CPVAuthorProfile*)aParam1)->Start();
 #endif
 
-    status = PVAVCEncodeNAL(&iAvcHandle, (uint8*)aVidOut->iBitstream, &Size, &nalType);
+    iEncStatus = PVAVCEncodeNAL(&iAvcHandle, (uint8*)aVidOut->iBitstream, &Size, &nalType);
 
-    if (status == AVCENC_SUCCESS)
+    if (iEncStatus == AVCENC_SUCCESS)
     {
         aVidOut->iLastNAL = false;
         aVidOut->iKeyFrame = iIDR;
-        ret = EAVCEI_MORE_DATA;
+        ret = EAVCEI_MORE_NAL;
     }
-    else if (status == AVCENC_PICTURE_READY)
+    else if (iEncStatus == AVCENC_PICTURE_READY)
     {
         aVidOut->iLastNAL = true;
         aVidOut->iKeyFrame = iIDR;
-        if (iIDR == true)
-        {
-            iIDR = false;
-        }
         ret = EAVCEI_SUCCESS;
         iState = EInitialized;
 
@@ -515,24 +562,66 @@
         if (status == AVCENC_SUCCESS)
         {
             aVidOut->iFrame = recon.YCbCr[0];
+
             PVAVCEncReleaseRecon(&iAvcHandle, &recon);
         }
     }
+    else if (iEncStatus == AVCENC_SKIPPED_PICTURE)
+    {
+        aVidOut->iLastFragment = true;
+        aVidOut->iFragment = false;
+        aVidOut->iBitstreamSize = 0;
+        aVidOut->iTimeStamp = iTimeStamp;
+        iState = EInitialized;
+        return EAVCEI_FRAME_DROP;
+    }
     else
     {
         return EAVCEI_FAIL;
     }
 
+#ifdef PVAUTHOR_PROFILING
+    if (aParam1)((CPVAuthorProfile*)aParam1)->Stop(CPVAuthorProfile::EVideoEncode);
+#endif
+
+    iOverrunBuffer = PVAVCEncGetOverrunBuffer(&iAvcHandle);
+
+    if (iOverrunBuffer) // OB is used
+    {
+        if (Size < (uint)aVidOut->iBitstreamSize) // encoder decides to use OB even though the buffer is big enough
+        {
+            oscl_memcpy(aVidOut->iBitstream, iOverrunBuffer, Size);
+            iOverrunBuffer = NULL; // reset it
+            iOBSize = 0;
+        }
+        else
+        {
+            oscl_memcpy(aVidOut->iBitstream, iOverrunBuffer, aVidOut->iBitstreamSize);
+            iOBSize = Size - aVidOut->iBitstreamSize;
+            iOverrunBuffer += aVidOut->iBitstreamSize;
+            if (iOBSize > 0) // there are more data
+            {
+                iState = EEncoding; // still encoding..
+                aVidOut->iLastFragment = false;
+                aVidOut->iFragment = true;
+                aVidOut->iTimeStamp = iTimeStamp;
+                return EAVCEI_MORE_DATA; // only copy out from iOverrunBuffer next time.
+            }
+        }
+
+    }
+
     aVidOut->iLastFragment = true; /* for now */
     aVidOut->iFragment = false;  /* for now */
     aVidOut->iBitstreamSize = Size;
     aVidOut->iTimeStamp = iTimeStamp;
 
-#ifdef PVAUTHOR_PROFILING
-    if (aParam1)((CPVAuthorProfile*)aParam1)->Stop(CPVAuthorProfile::EVideoEncode);
-#endif
-    return ret;
+    if (iEncStatus == AVCENC_PICTURE_READY && iIDR == true)
+    {
+        iIDR = false;
+    }
 
+    return ret;
 }
 
 /* ///////////////////////////////////////////////////////////////////////// */
@@ -555,12 +644,6 @@
             oscl_free(iYUVIn);
             iYUVIn = NULL;
         }
-
-#if defined(RGB12_INPUT)||defined(RGB24_INPUT)
-        if (iVideoFormat == EAVCEI_VDOFMT_RGB24 || iVideoFormat == EAVCEI_VDOFMT_RGB12)
-            freeRGB2YUVTables();
-#endif
-
     }
     if (iFrameUsed)
     {
@@ -799,621 +882,6 @@
 }
 #endif
 
-#if defined(RGB12_INPUT) || defined(RGB24_INPUT)
-/* ///////////////////////////////////////////////////////////////////////// */
-/* The following four functions are for RGB->YUV, convert				   */
-/* RGB input(12bit/24bit) to YUV frame inside M4VEnc lib				   */
-/* ///////////////////////////////////////////////////////////////////////// */
-bool PVAVCEncoder::initRGB2YUVTables()
-{
-    int i;
-    uint16 *pTable;
-
-    iY_Table  = NULL;
-    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
-
-    /* memory allocation */
-    if ((iY_Table = (uint8*)oscl_malloc(384)) == NULL)
-        return false;
-
-    if ((iCb_Table = (uint16*)oscl_malloc(768 * 2)) == NULL)
-        return false;
-
-    if ((iCr_Table = (uint16*)oscl_malloc(768 * 2)) == NULL)
-        return false;
-
-#define pv_max(a, b)	((a) >= (b) ? (a) : (b))
-#define pv_min(a, b)	((a) <= (b) ? (a) : (b))
-
-    /* Table generation */
-    for (i = 0; i < 384; i++)
-        iY_Table[i] = (uint8) pv_max(pv_min(255, (int)(0.7152 * i + 16 + 0.5)), 0);
-
-    pTable = iCb_Table + 384;
-    for (i = -384; i < 384; i++)
-        pTable[i] = (uint16) pv_max(pv_min(255, (int)(0.386 * i + 128 + 0.5)), 0);
-    ipCb_Table = iCb_Table + 384;
-
-    pTable = iCr_Table + 384;
-    for (i = -384; i < 384; i++)
-        pTable[i] = (uint16) pv_max(pv_min(255, (int)(0.454 * i + 128 + 0.5)), 0);
-    ipCr_Table = iCr_Table + 384;
-
-    return true;
-
-}
-
-void PVAVCEncoder::freeRGB2YUVTables()
-{
-    if (iY_Table) oscl_free(iY_Table);
-    if (iCb_Table) oscl_free(iCb_Table);
-    if (iCr_Table) oscl_free(iCr_Table);
-
-    iY_Table  = NULL;
-    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
-
-}
-#endif
-#ifdef RGB12_INPUT
-#ifdef VERSION_0
-/* Assume B is in the first 4 bits, G is in the second 4 bits, and R is in the third 4 bits, of a whole 16bit unsigned integer */
-void PVAVCEncoder::RGB2YUV420_12bit(uint16 *inputRGB, int width, int height, int width_16, int height_16)
-{
-    int i, j;
-    uint8 *tempY, *tempU, *tempV;
-    uint16 *inputRGB_prevRow = NULL;
-
-
-    tempY = iYUVIn; /* Normal order */
-    tempU = iYUVIn + height_16 * width_16;
-    tempV = iYUVIn + height_16 * width_16 + (height_16 * width_16 >> 2);
-
-    for (j = 0; j < height; j++)
-    {
-        for (i = 0; i < width; i++)
-        {
-
-            *tempY++ = iY_Table[(6616*(inputRGB[i] << 4 & 0x00f0) + ((inputRGB[i] & 0x00f0) << 16) + 19481 * (inputRGB[i] >> 4 & 0x00f0)) >> 16];
-
-            /* downsampling U, V */
-            if (j % 2 == 1 && i % 2 == 1)
-            {
-
-                *tempU++ = (uint8)(ipCb_Table[(((inputRGB[i] << 4 & 0x00f0) << 16) - ((inputRGB[i] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB[i] << 4 & 0x00f0) - (inputRGB[i] >> 4 & 0x00f0))) >> 16] + /* bottom right(current) */
-
-                                   ipCb_Table[(((inputRGB[i-1] << 4 & 0x00f0) << 16) - ((inputRGB[i-1] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB[i-1] << 4 & 0x00f0) - (inputRGB[i-1] >> 4 & 0x00f0))) >> 16] + /* bottom left */
-
-                                   ipCb_Table[(((inputRGB_prevRow[i] << 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB_prevRow[i] << 4 & 0x00f0) - (inputRGB_prevRow[i] >> 4 & 0x00f0))) >> 16] + /* top right */
-
-                                   ipCb_Table[(((inputRGB_prevRow[i-1] << 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i-1] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB_prevRow[i-1] << 4 & 0x00f0) - (inputRGB_prevRow[i-1] >> 4 & 0x00f0))) >> 16] + /* top left */
-
-                                   2 >> 2);
-
-
-                *tempV++ = (uint8)(ipCr_Table[(((inputRGB[i] >> 4 & 0x00f0) << 16) - ((inputRGB[i] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB[i] >> 4 & 0x00f0) - (inputRGB[i] << 4 & 0x00f0))) >> 16] + /* bottom right(current) */
-
-                                   ipCr_Table[(((inputRGB[i-1] >> 4 & 0x00f0) << 16) - ((inputRGB[i-1] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB[i-1] >> 4 & 0x00f0) - (inputRGB[i-1] << 4 & 0x00f0))) >> 16] + /* bottom left */
-
-                                   ipCr_Table[(((inputRGB_prevRow[i] >> 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB_prevRow[i] >> 4 & 0x00f0) - (inputRGB_prevRow[i] << 4 & 0x00f0))) >> 16] + /* top right */
-
-                                   ipCr_Table[(((inputRGB_prevRow[i-1] >> 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i-1] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB_prevRow[i-1] >> 4 & 0x00f0) - (inputRGB_prevRow[i-1] << 4 & 0x00f0))) >> 16] + /* top left */
-
-                                   2 >> 2);
-            }
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-        if (width < width_16)
-        {
-            oscl_memset(tempY, *(tempY - 1), width_16 - width);
-            tempY += (width_16 - width);
-
-            if (j % 2 == 1)
-            {
-                oscl_memset(tempU, *(tempU - 1), (width_16 - width) >> 1);
-                tempU += (width_16 - width) >> 1;
-                oscl_memset(tempV, *(tempV - 1), (width_16 - width) >> 1);
-                tempV += (width_16 - width) >> 1;
-            }
-        }
-
-        inputRGB_prevRow = inputRGB;
-        inputRGB += width;	/* move to the next row */
-    }
-
-    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
-    if (height < height_16)
-    {
-        tempY = iYUVIn + height * width_16;
-        tempU = tempY - width_16;/* tempU is for temporary use, not meaning U stuff */
-        for (i = height; i < height_16; i++)
-        {
-            oscl_memcpy(tempY, tempU, width_16);
-            tempY += width_16;
-        }
-
-        tempU = iYUVIn + height_16 * width_16 + (height * width_16 >> 2);
-        tempV = tempU - (width_16 >> 1); /* tempV is for temporary use, not meaning V stuff */
-        for (i = height >> 1; i<height_16 >> 1; i++)
-        {
-            oscl_memcpy(tempU, tempV, (width_16 >> 1));
-            tempU += (width_16 >> 1);
-        }
-
-        tempV = iYUVIn + height_16 * width_16 + (height_16 * width_16 >> 2) + (height * width_16 >> 2);
-        tempY = tempV - (width_16 >> 1); /* tempY is for temporary use, not meaning Y stuff */
-        for (i = height >> 1; i<height_16 >> 1; i++)
-        {
-            oscl_memcpy(tempV, tempY, (width_16 >> 1));
-            tempV += (width_16 >> 1);
-        }
-
-    }
-
-}
-#endif
-
-/* Assume width is divisible by 8 */
-void PVAVCEncoder::RGB2YUV420_12bit(
-    uint32 *inputRGB,
-    int     width,
-    int     height,
-    int     width_16,
-    int     height_16)
-{
-    int i;
-    int j;
-    int ilimit;
-    int jlimit;
-    uint32 *tempY;
-    uint32 *tempU;
-    uint32 *tempV;
-    uint32 pixels;
-    uint32 pixels_nextRow;
-    uint32 yuv_value;
-    uint32 yuv_value1;
-    uint32 yuv_value2;
-    int R_ds; /* "_ds" is the downsample version */
-    int G_ds; /* "_ds" is the downsample version */
-    int B_ds; /* "_ds" is the downsample version */
-    int adjust = (width >> 1);
-    int size16 = height_16 * width_16;
-    int tmp;
-    uint32 temp;
-
-    /* do padding at the bottom first */
-    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
-    if (height < height_16 || width < width_16)
-    { /* if padding */
-        int offset = (height < height_16) ? height : height_16;
-
-        offset = (offset * width_16);
-
-        if (width < width_16)
-        {
-            offset -= (width_16 - width);
-        }
-
-        tempY = (uint32 *)iYUVIn + (offset >> 2);
-        oscl_memset((uint8 *)tempY, 16, size16 - offset); /* pad with zeros */
-
-        tempU = (uint32 *)iYUVIn + (size16 >> 2) + (offset >> 4);
-        oscl_memset((uint8 *)tempU, 128, (size16 - offset) >> 2);
-
-        tempV = (uint32 *)iYUVIn + (size16 >> 2) + (size16 >> 4) + (offset >> 4);
-        oscl_memset((uint8 *)tempV, 128, (size16 - offset) >> 2);
-    }
-
-    /* then do padding on the top */
-    tempY = (uint32 *)iYUVIn; /* Normal order */
-    tempU = tempY + ((size16) >> 2);
-    tempV = tempU + ((size16) >> 4);
-
-    /* To center the output */
-    if (height_16 > height)
-    {
-        if (width_16 >= width)
-        {
-            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-        }
-        else
-        {
-            i = ((height_16 - height) >> 1) * width_16;
-            j = ((height_16 - height) >> 2) * (width_16 >> 1);
-            inputRGB += (width - width_16) >> 2;
-        }
-        oscl_memset((uint8 *)tempY, 16, i);
-        tempY += (i >> 2);
-        oscl_memset((uint8 *)tempU, 128, j);
-        tempU += (j >> 2);
-        oscl_memset((uint8 *)tempV, 128, j);
-        tempV += (j >> 2);
-    }
-    else
-    {
-        if (width_16 >= width)
-        {
-            i = (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-            inputRGB += (((height - height_16) >> 1) * width) >> 1;
-
-            oscl_memset((uint8 *)tempY, 16, i);
-            tempY += (i >> 2);
-            oscl_memset((uint8 *)tempU, 128, j);
-            tempU += (j >> 2);
-            oscl_memset((uint8 *)tempV, 128, j);
-            tempV += (j >> 2);
-
-        }
-        else
-        {
-            i = 0;
-            j = 0;
-            inputRGB += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 1 ;
-        }
-    }
-
-    /* ColorConv RGB12-to-YUV420 with cropping or zero-padding */
-    if (height < height_16)
-    {
-        jlimit = height;
-    }
-    else
-    {
-        jlimit = height_16;
-    }
-
-    if (width < width_16)
-    {
-        ilimit = width >> 1;
-    }
-    else
-    {
-        ilimit = width_16 >> 1;
-    }
-
-    width = width_16 - width;
-
-
-    for (j = 0; j < jlimit; j++)
-    {
-
-        for (i = 0; i < ilimit; i += 4)
-        {
-            pixels =  inputRGB[i];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+1];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-            pixels =  inputRGB[i+2];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+3];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-
-            /* downsampling U, V */
-
-            pixels_nextRow = inputRGB[i+3+adjust/*(width>>1)*/];
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-
-            tmp  = B_ds - R_ds;
-
-            yuv_value1 = ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 24;
-            yuv_value2 = ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 24;
-
-            pixels =  inputRGB[i+2];
-            pixels_nextRow = inputRGB[i+2+adjust/*(width>>1)*/];
-
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-            tmp  = B_ds - R_ds;
-
-            yuv_value1 |= ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 16;
-            yuv_value2 |= ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 16;
-
-            pixels =  inputRGB[i+1];
-            pixels_nextRow = inputRGB[i+1+adjust /*(width>>1)*/];
-
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-            tmp  = B_ds - R_ds;
-
-
-            yuv_value1 |= ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 8;
-            yuv_value2 |= ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 8;
-
-            pixels =  inputRGB[i];
-            pixels_nextRow = inputRGB[i+adjust/*(width>>1)*/];
-
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-            tmp  = B_ds - R_ds;
-
-            *tempU++ = yuv_value1 | (ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18]);
-            *tempV++ = yuv_value2 | (ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18]);
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-
-        if ((width > 0) && j < jlimit - 1)
-        {
-            oscl_memset((uint8 *)tempY, 16/*(*(tempY-1))>>24*/, width);
-            tempY += width >> 2;
-            oscl_memset((uint8 *)tempU, 128/*(*(tempU-1))>>24*/, width >> 1);
-            tempU += width >> 3;
-            oscl_memset((uint8 *)tempV, 128/*(*(tempV-1))>>24*/, width >> 1);
-            tempV += width >> 3;
-        }
-
-        if (j++ == (jlimit - 1))
-        {
-            break;          /* dealing with a odd height  */
-        }
-
-        inputRGB += adjust; /* (160/2 = 80 ) */ /*(width>>1)*/; /* move to the next row */
-
-        for (i = 0; i < ilimit; i += 4)
-        {
-            pixels =  inputRGB[i];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+1];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-            pixels =  inputRGB[i+2];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+3];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-        if ((width > 0) && j < jlimit - 1)
-        {
-            oscl_memset((uint8 *)tempY, 16/*(*(tempY-1))>>24*/, width);
-            tempY += width >> 2;
-        }
-
-        inputRGB += adjust; /* (160/2 = 80 ) */ /*(width>>1)*/; /* move to the next row */
-
-    } /* for(j=0; j<jlimit; j++)*/
-}
-#endif
-#ifdef RGB24_INPUT
-/* Assume B is in the first byte, G is in the second byte, and R is in the third byte, of a whole 3-octct group */
-void PVAVCEncoder::RGB2YUV420_24bit(uint8 *inputRGB, int width, int height, int width_16, int height_16)
-{
-    int i, j, ilimit, jlimit;
-    uint8 *tempY, *tempU, *tempV;
-    uint8 *inputRGB_prevRow = NULL;
-    int32 size16 = height_16 * width_16;
-    int32 adjust = (width + (width << 1));
-
-    /* do padding at the bottom first */
-    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
-    if (height < height_16 || width < width_16) /* if padding */
-    {
-        int offset = (height < height_16) ? height : height_16;
-
-        offset = (offset * width_16);
-
-        if (width < width_16)
-        {
-            offset -= (width_16 - width);
-        }
-        tempY = iYUVIn + offset;
-        oscl_memset((uint8 *)tempY, 16, size16 - offset); /* pad with zeros */
-
-        tempU = iYUVIn + size16 + (offset >> 2);
-        oscl_memset((uint8 *)tempU, 128, (size16 - offset) >> 2);
-
-        tempV = iYUVIn + size16 + (size16 >> 2) + (offset >> 2);
-        oscl_memset((uint8 *)tempV, 128, (size16 - offset) >> 2);
-    }
-
-    /* then do padding on the top */
-    tempY = iYUVIn; /* Normal order */
-    tempU = iYUVIn + size16;
-    tempV = tempU + (size16 >> 2);
-
-    /* To center the output */
-    if (height_16 > height)
-    {
-        if (width_16 >= width)
-        {
-            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-        }
-        else
-        {
-            i = ((height_16 - height) >> 1) * width_16;
-            j = ((height_16 - height) >> 2) * (width_16 >> 1);
-            inputRGB += ((width - width_16) >> 1) * 3;
-        }
-        oscl_memset((uint8 *)tempY, 16, i);
-        tempY += i;
-        oscl_memset((uint8 *)tempU, 128, j);
-        tempU += j;
-        oscl_memset((uint8 *)tempV, 128, j);
-        tempV += j;
-    }
-    else
-    {
-        if (width_16 >= width)
-        {
-            i = (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-            inputRGB += (((height - height_16) >> 1) * width) * 3;
-        }
-        else
-        {
-            i = 0;
-            j = 0;
-            inputRGB += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) * 3;
-        }
-        oscl_memset((uint8 *)tempY, 16, i);
-        tempY += i;
-        oscl_memset((uint8 *)tempU, 128, j);
-        tempU += j;
-        oscl_memset((uint8 *)tempV, 128, j);
-        tempV += j;
-    }
-
-    /* ColorConv RGB24-to-YUV420 with cropping or zero-padding */
-    if (height < height_16)
-        jlimit = height;
-    else
-        jlimit = height_16;
-
-    if (width < width_16)
-        ilimit = width;
-    else
-        ilimit = width_16;
-
-    if (iFrameOrientation > 0)		//Bottom_UP RGB
-    {
-        inputRGB += (jlimit - 1) * width * 3 ; // move to last row
-        adjust = -adjust;
-    }
-
-    for (j = 0; j < jlimit; j++)
-    {
-        for (i = 0; i < ilimit*3; i += 3)
-        {
-
-            *tempY++ = iY_Table[(6616*inputRGB[i] + (inputRGB[i+1] << 16) + 19481 * inputRGB[i+2]) >> 16];
-
-            /* downsampling U, V */
-            if (j % 2 == 1 && i % 2 == 1)
-            {
-
-                *tempU++ = (unsigned char)((ipCb_Table[((inputRGB[i] << 16) - (inputRGB[i+1] << 16) + 19525 * (inputRGB[i] - inputRGB[i+2])) >> 16] + /* bottom right(current) */
-                                            ipCb_Table[((inputRGB[i-3] << 16) - (inputRGB[i-2] << 16) + 19525 * (inputRGB[i-3] - inputRGB[i-1])) >> 16] + /* bottom left */
-                                            ipCb_Table[((inputRGB_prevRow[i] << 16) - (inputRGB_prevRow[i+1] << 16) + 19525 * (inputRGB_prevRow[i] - inputRGB_prevRow[i+2])) >> 16] + /* top right */
-                                            ipCb_Table[((inputRGB_prevRow[i-3] << 16) - (inputRGB_prevRow[i-2] << 16) + 19525 * (inputRGB_prevRow[i-3] - inputRGB_prevRow[i-1])) >> 16]  + /* top left */
-                                            2) >> 2);
-
-
-                *tempV++ = (unsigned char)((ipCr_Table[((inputRGB[i+2] << 16) - (inputRGB[i+1] << 16) + 6640 * (inputRGB[i+2] - inputRGB[i])) >> 16] + /* bottom right(current) */
-                                            ipCr_Table[((inputRGB[i-1] << 16) - (inputRGB[i-2] << 16) + 6640 * (inputRGB[i-1] - inputRGB[i-3])) >> 16] + /* bottom left */
-                                            ipCr_Table[((inputRGB_prevRow[i+2] << 16) - (inputRGB_prevRow[i+1] << 16) + 6640 * (inputRGB_prevRow[i+2] - inputRGB_prevRow[i])) >> 16] + /* top right */
-                                            ipCr_Table[((inputRGB_prevRow[i-1] << 16) - (inputRGB_prevRow[i-2] << 16) + 6640 * (inputRGB_prevRow[i-1] - inputRGB_prevRow[i-3])) >> 16]  + /* top left */
-                                            2) >> 2);
-
-            }
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-        if (width < width_16 && j < jlimit - 1)
-        {
-            oscl_memset(tempY, 16/* *(tempY-1)*/, width_16 - width);
-            tempY += (width_16 - width);
-
-            if (j % 2 == 1)
-            {
-                oscl_memset(tempU, 128/* *(tempU-1)*/, (width_16 - width) >> 1);
-                tempU += (width_16 - width) >> 1;
-                oscl_memset(tempV, 128/* *(tempV-1)*/, (width_16 - width) >> 1);
-                tempV += (width_16 - width) >> 1;
-            }
-        }
-
-        inputRGB_prevRow = inputRGB;
-        inputRGB += adjust ; /* move to the next row */
-    }
-
-}
-#endif
-
 #ifdef FOR_3GPP_COMPLIANCE
 void PVAVCEncoder::Check3GPPCompliance(TAVCEIEncodeParam *aEncParam, int *aEncWidth, int *aEncHeight)
 {
@@ -1478,6 +946,8 @@
     switch (in)
     {
         case EAVCEI_LEVEL_AUTODETECT:
+            out = AVC_LEVEL_AUTO;
+            break;
         case EAVCEI_LEVEL_1:
             out = AVC_LEVEL1;
             break;
diff --git a/codecs_v2/video/avc_h264/enc/src/pvavcencoder_factory.cpp b/codecs_v2/video/avc_h264/enc/src/pvavcencoder_factory.cpp
index 59683b8..71406fd 100644
--- a/codecs_v2/video/avc_h264/enc/src/pvavcencoder_factory.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/pvavcencoder_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/rate_control.cpp b/codecs_v2/video/avc_h264/enc/src/rate_control.cpp
index 7749342..ede544a 100644
--- a/codecs_v2/video/avc_h264/enc/src/rate_control.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/rate_control.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,30 +18,36 @@
 #include "avcenc_lib.h"
 #include "oscl_base_macros.h"
 #include "oscl_math.h"
+#include "oscl_string.h"
 
 /* rate control variables */
-#define OMEGA  0.9
-#define GAMMAP 0.5
-#define BETAP  0.5
 #define RC_MAX_QUANT 51
-#define RC_MIN_QUANT 10   //cap to 10 to prevent rate fluctuation    
-#define MINVALUE 4.0
-#define QP_DELTA 5   	//Define the largest variation of quantization parameters
-#define QP_DELTA_I  10
-#define I_SLICE_BIT_RATIO 1.0 // ratio of I-frame size over P-frame size
-#define I_OVER_P_RATIO   3.8
+#define RC_MIN_QUANT 0   //cap to 10 to prevent rate fluctuation    
+
+#define MAD_MIN 1 /* handle the case of devision by zero in RC */
+
 
 /* local functions */
-void RCUpdateRCModel(AVCEncObject *encvid);
-double ComputeFrameMAD(AVCCommonObj *video, AVCRateControl *rateCtrl);
-void RCModelEstimator(AVCRateControl *rateCtrl, int n_windowSize, bool *m_rgRejected);
-void updateMADModel(AVCCommonObj *video, AVCRateControl *rateCtrl);
-void MADModelEstimator(AVCCommonObj *video, AVCRateControl *rateCtrl, int n_windowSize,
-                       double *MADPictureC1, double *MADPictureC2, bool *PictureRejected);
-
 double QP2Qstep(int QP);
 int Qstep2QP(double Qstep);
 
+double ComputeFrameMAD(AVCCommonObj *video, AVCRateControl *rateCtrl);
+
+void targetBitCalculation(AVCEncObject *encvid, AVCCommonObj *video, AVCRateControl *rateCtrl, MultiPass *pMP);
+
+void calculateQuantizer_Multipass(AVCEncObject *encvid, AVCCommonObj *video,
+                                  AVCRateControl *rateCtrl, MultiPass *pMP);
+
+void updateRC_PostProc(AVCRateControl *rateCtrl, MultiPass *pMP);
+
+void AVCSaveRDSamples(MultiPass *pMP, int counter_samples);
+
+void updateRateControl(AVCRateControl *rateControl, int nal_type);
+
+int GetAvgFrameQP(AVCRateControl *rateCtrl)
+{
+    return rateCtrl->Qc;
+}
 
 AVCEnc_Status RCDetermineFrameNum(AVCEncObject *encvid, AVCRateControl *rateCtrl, uint32 modTime, uint *frameNum)
 {
@@ -84,19 +90,24 @@
 
         currFrameNum = (int32)(((modTime - modTimeRef) * rateCtrl->frame_rate + 200) / 1000); /* add small roundings */
 
-        if (currFrameNum <= (int32)video->prevFrameNum || currFrameNum == (int32)encvid->prevProcFrameNum)
+        if (currFrameNum <= (int32)encvid->prevProcFrameNum)
         {
             return AVCENC_FAIL;  /* this is a late frame do not encode it */
         }
 
-        frameInc = currFrameNum - video->prevFrameNum;
+        frameInc = currFrameNum - encvid->prevProcFrameNum;
 
-        RCUpdateBuffer(video, rateCtrl, frameInc);	/* in case more frames dropped */
+        if (frameInc < rateCtrl->skip_next_frame + 1)
+        {
+            return AVCENC_FAIL;  /* frame skip required to maintain the target bit rate. */
+        }
+
+        RCUpdateBuffer(video, rateCtrl, frameInc - rateCtrl->skip_next_frame);	/* in case more frames dropped */
 
         *frameNum = currFrameNum;
 
         /* This part would be similar to DetermineVopType of m4venc */
-        if ((*frameNum >= (uint)rateCtrl->idrPeriod && rateCtrl->idrPeriod > 0) || *frameNum > video->MaxFrameNum) /* first frame or IDR*/
+        if ((*frameNum >= (uint)rateCtrl->idrPeriod && rateCtrl->idrPeriod > 0) || (*frameNum > video->MaxFrameNum)) /* first frame or IDR*/
         {
             /* set frame type to IDR-frame */
             if (rateCtrl->idrPeriod)
@@ -113,15 +124,16 @@
             video->nal_unit_type = AVC_NALTYPE_IDR;
             sliceHdr->slice_type = AVC_I_ALL_SLICE;
             video->slice_type = AVC_I_SLICE;
+            encvid->prevProcFrameNum = *frameNum;
         }
         else
         {
             video->nal_unit_type = AVC_NALTYPE_SLICE;
             sliceHdr->slice_type = AVC_P_ALL_SLICE;
             video->slice_type = AVC_P_SLICE;
+            encvid->prevProcFrameNum = currFrameNum;
         }
 
-        encvid->prevProcFrameNum = currFrameNum;
     }
 
     return AVCENC_SUCCESS;
@@ -130,6 +142,7 @@
 void RCUpdateBuffer(AVCCommonObj *video, AVCRateControl *rateCtrl, int frameInc)
 {
     int tmp;
+    MultiPass *pMP = rateCtrl->pMP;
 
     OSCL_UNUSED_ARG(video);
 
@@ -138,10 +151,15 @@
         if (frameInc > 1)
         {
             tmp = rateCtrl->bitsPerFrame * (frameInc - 1);
-            rateCtrl->CurrentBufferFullness -= tmp;
-            if (rateCtrl->CurrentBufferFullness < 0)
+            rateCtrl->VBV_fullness -= tmp;
+            pMP->counter_BTsrc += 10 * (frameInc - 1);
+
+            /* Check buffer underflow */
+            if (rateCtrl->VBV_fullness < rateCtrl->low_bound)
             {
-                rateCtrl->CurrentBufferFullness = 0;
+                rateCtrl->VBV_fullness = rateCtrl->low_bound; // -rateCtrl->Bs/2;
+                rateCtrl->TMN_W = rateCtrl->VBV_fullness - rateCtrl->low_bound;
+                pMP->counter_BTsrc = pMP->counter_BTdst + (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
             }
         }
     }
@@ -155,82 +173,79 @@
     AVCRateControl *rateCtrl = encvid->rateCtrl;
     double L1, L2, L3, bpp;
     int qp;
-    int i;
-    double BufferSize;
+    int i, j;
+
+    rateCtrl->basicUnit = video->PicSizeInMbs;
 
     rateCtrl->MADofMB = (double*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
                         video->PicSizeInMbs * sizeof(double), DEFAULT_ATTR);
 
+    if (!rateCtrl->MADofMB)
+    {
+        goto CLEANUP_RC;
+    }
+
     if (rateCtrl->rcEnable == TRUE)
     {
-        rateCtrl->basicUnit = video->PicSizeInMbs;//video->PicWidthInMbs; //  // default
-        if (rateCtrl->idrPeriod == 1 && rateCtrl->basicUnit < (int)video->PicSizeInMbs) // all I's
+        rateCtrl->pMP = (MultiPass*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData, sizeof(MultiPass), DEFAULT_ATTR);
+        if (!rateCtrl->pMP)
         {
-            rateCtrl->basicUnit = video->PicSizeInMbs; // only do frame-level RC for this case
+            goto CLEANUP_RC;
+        }
+        oscl_memset(rateCtrl->pMP, 0, sizeof(MultiPass));
+        rateCtrl->pMP->encoded_frames = -1; /* forget about the very first I frame */
+
+        /* RDInfo **pRDSamples */
+        rateCtrl->pMP->pRDSamples = (RDInfo **)avcHandle->CBAVC_Malloc(encvid->avcHandle->userData, (30 * sizeof(RDInfo *)), DEFAULT_ATTR);
+        if (!rateCtrl->pMP->pRDSamples)
+        {
+            goto CLEANUP_RC;
         }
 
-
-        rateCtrl->BUCFMAD = (double*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
-                            video->PicHeightInMbs * sizeof(double), DEFAULT_ATTR);
-
-        rateCtrl->BUPFMAD = (double*) avcHandle->CBAVC_Malloc(encvid->avcHandle->userData,
-                            video->PicHeightInMbs * sizeof(double), DEFAULT_ATTR);
-
-        if (!rateCtrl->MADofMB || !rateCtrl->BUCFMAD || !rateCtrl->BUPFMAD)
+        for (i = 0; i < 30; i++)
         {
-            CleanupRateControlModule(avcHandle);
-            return AVCENC_MEMORY_FAIL;
+            rateCtrl->pMP->pRDSamples[i] = (RDInfo *)avcHandle->CBAVC_Malloc(encvid->avcHandle->userData, (32 * sizeof(RDInfo)), DEFAULT_ATTR);
+            if (!rateCtrl->pMP->pRDSamples[i])
+            {
+                goto CLEANUP_RC;
+            }
+            for (j = 0; j < 32; j++)	oscl_memset(&(rateCtrl->pMP->pRDSamples[i][j]), 0, sizeof(RDInfo));
         }
+        rateCtrl->pMP->frameRange = (int)(rateCtrl->frame_rate * 1.0); /* 1.0s time frame*/
+        rateCtrl->pMP->frameRange = AVC_MAX(rateCtrl->pMP->frameRange, 5);
+        rateCtrl->pMP->frameRange = AVC_MIN(rateCtrl->pMP->frameRange, 30);
 
-        /// at the sequence level
-        if (rateCtrl->basicUnit > (int)video->PicSizeInMbs)
-            rateCtrl->basicUnit = video->PicSizeInMbs;
-        if (rateCtrl->basicUnit < (int)video->PicSizeInMbs)
-            rateCtrl->TotalNumberofBasicUnit = video->PicSizeInMbs / rateCtrl->basicUnit;
+        rateCtrl->pMP->framePos = -1;
 
-        /*initialize the parameters of fluid flow traffic model*/
 
         rateCtrl->bitsPerFrame = (int32)(rateCtrl->bitRate / rateCtrl->frame_rate);
 
-        BufferSize = rateCtrl->cpbSize;
-        //BufferSize = rateCtrl->bitRate * 2.56; // for testing
-        rateCtrl->CurrentBufferFullness = 0;
+        /* BX rate control */
+        rateCtrl->skip_next_frame = 0; /* must be initialized */
 
-        /*HRD consideration*/
-        rateCtrl->initDelayOffset = (int32)(BufferSize * 0.8); // for testing
+        rateCtrl->Bs = rateCtrl->cpbSize;
+        rateCtrl->TMN_W = 0;
+        rateCtrl->VBV_fullness = (int)(rateCtrl->Bs * 0.5); /* rateCtrl->Bs */
+        rateCtrl->encoded_frames = 0;
 
-        /*initialize the previous window size*/
-        rateCtrl->m_windowSize = 0;
-        rateCtrl->MADm_windowSize = 0;
-        rateCtrl->NumberofCodedPFrame = 0;
-        rateCtrl->NumberofGOP = 0;
-        /*remaining # of bits in GOP */
-        rateCtrl->R = 0;
+        rateCtrl->TMN_TH = rateCtrl->bitsPerFrame;
 
-        /*quadratic rate-distortion model*/
-        rateCtrl->PPreHeader = 0;
+        rateCtrl->max_BitVariance_num = (int)((OsclFloat)(rateCtrl->Bs - rateCtrl->VBV_fullness) / (rateCtrl->bitsPerFrame / 10.0)) - 5;
+        if (rateCtrl->max_BitVariance_num < 0) rateCtrl->max_BitVariance_num += 5;
 
-        rateCtrl->m_X1 = rateCtrl->bitRate * 1.0;
-        rateCtrl->m_X2 = 0.0;
-        /* linear prediction model for P picture*/
-        rateCtrl->PMADPictureC1 = 1.0;
-        rateCtrl->PMADPictureC2 = 0.0;
+        // Set the initial buffer fullness
+        /* According to the spec, the initial buffer fullness needs to be set to 1/3 */
+        rateCtrl->VBV_fullness = (int)(rateCtrl->Bs / 3.0 - rateCtrl->Bs / 2.0); /* the buffer range is [-Bs/2, Bs/2] */
+        rateCtrl->pMP->counter_BTsrc = (int)((rateCtrl->Bs / 2.0 - rateCtrl->Bs / 3.0) / (rateCtrl->bitsPerFrame / 10.0));
+        rateCtrl->TMN_W = (int)(rateCtrl->VBV_fullness + rateCtrl->pMP->counter_BTsrc * (rateCtrl->bitsPerFrame / 10.0));
 
-        for (i = 0;i < 20;i++)
-        {
-            rateCtrl->m_rgQp[i] = 0;
-            rateCtrl->m_rgRp[i] = 0.0;
-            rateCtrl->PPictureMAD[i] = 0.0;
-        }
-        rateCtrl->PPictureMAD[20] = 0.0;
+        rateCtrl->low_bound = -rateCtrl->Bs / 2;
+        rateCtrl->VBV_fullness_offset = 0;
 
-        /*basic unit layer rate control*/
-        rateCtrl->PAveHeaderBits1 = 0;
-        rateCtrl->PAveHeaderBits3 = 0;
-        if (rateCtrl->TotalNumberofBasicUnit >= 9)
-            rateCtrl->DDquant = 1;
-        else
-            rateCtrl->DDquant = 2;
+        /* Setting the bitrate and framerate */
+        rateCtrl->pMP->bitrate = rateCtrl->bitRate;
+        rateCtrl->pMP->framerate = rateCtrl->frame_rate;
+        rateCtrl->pMP->target_bits_per_frame = rateCtrl->pMP->bitrate / rateCtrl->pMP->framerate;
 
         /*compute the initial QP*/
         bpp = 1.0 * rateCtrl->bitRate / (rateCtrl->frame_rate * (video->PicSizeInMbs << 8));
@@ -268,10 +283,16 @@
             rateCtrl->initQP = qp;
         }
 
-        rateCtrl->PAveFrameQP = rateCtrl->initQP;
+        rateCtrl->Qc = rateCtrl->initQP;
     }
 
     return AVCENC_SUCCESS;
+
+CLEANUP_RC:
+
+    CleanupRateControlModule(avcHandle);
+    return AVCENC_MEMORY_FAIL;
+
 }
 
 
@@ -279,18 +300,27 @@
 {
     AVCEncObject *encvid = (AVCEncObject*) avcHandle->AVCObject;
     AVCRateControl *rateCtrl = encvid->rateCtrl;
+    int i;
 
     if (rateCtrl->MADofMB)
     {
         avcHandle->CBAVC_Free(avcHandle->userData, (int)(rateCtrl->MADofMB));
     }
-    if (rateCtrl->BUCFMAD)
+
+    if (rateCtrl->pMP)
     {
-        avcHandle->CBAVC_Free(avcHandle->userData, (int)(rateCtrl->BUCFMAD));
-    }
-    if (rateCtrl->BUPFMAD)
-    {
-        avcHandle->CBAVC_Free(avcHandle->userData, (int)(rateCtrl->BUPFMAD));
+        if (rateCtrl->pMP->pRDSamples)
+        {
+            for (i = 0; i < 30; i++)
+            {
+                if (rateCtrl->pMP->pRDSamples[i])
+                {
+                    avcHandle->CBAVC_Free(avcHandle->userData, (int)rateCtrl->pMP->pRDSamples[i]);
+                }
+            }
+            avcHandle->CBAVC_Free(avcHandle->userData, (int)rateCtrl->pMP->pRDSamples);
+        }
+        avcHandle->CBAVC_Free(avcHandle->userData, (int)(rateCtrl->pMP));
     }
 
     return ;
@@ -298,236 +328,65 @@
 
 void RCInitGOP(AVCEncObject *encvid)
 {
-    AVCCommonObj *video = encvid->common;
-    AVCRateControl *rateCtrl = encvid->rateCtrl;
+    /* in BX RC, there's no GOP-level RC */
 
-    int np = rateCtrl->idrPeriod - 1;
-    bool Overum = FALSE;
-    int OverBits;
-    int OverDuantQp;
-    int AllocatedBits;
-    int GOPDquant;
-    int PAverageQp;
-    OsclFloat denom, numer;
-    bool initGOP = TRUE;
-
-    if (rateCtrl->rcEnable == TRUE)
-    {
-
-        /*** additional part from JM12.4 RC3 ****/
-        if (np < 0)
-        {
-            np = video->MaxFrameNum - 1;   // IPPPPPP
-        }
-        else if (np == 0)
-        {
-            np = (1 << 16) - 1; // IIIIIII
-            if (rateCtrl->first_frame == FALSE)
-            {
-                initGOP = FALSE;
-            }
-        }
-
-        if (initGOP == TRUE)
-        {
-            numer = (OsclFloat)((np + 1) * rateCtrl->bitsPerFrame);
-            denom = (OsclFloat)((np + 1) + I_SLICE_BIT_RATIO - 1);
-
-            rateCtrl->RCPSliceBits = (int)(numer / denom + 0.5);
-            rateCtrl->RCISliceBits = (np == 0) ? (int)(I_SLICE_BIT_RATIO * rateCtrl->RCPSliceBits + 0.5) : 0;
-
-            /* check if the last GOP over uses its budget. If yes, the initial QP of the I frame in
-            the coming  GOP will be increased.*/
-
-            if (rateCtrl->R < 0)
-                Overum = TRUE;
-            OverBits = -rateCtrl->R;
-
-            /*initialize the lower bound and the upper bound for the target bits of each frame, HRD consideration*/
-            rateCtrl->LowerBound = (int32)(rateCtrl->R + rateCtrl->bitsPerFrame);
-            rateCtrl->UpperBound1 = (int32)(rateCtrl->R + rateCtrl->initDelayOffset);
-
-            /*compute the total number of bits for the current GOP*/
-            AllocatedBits = (int)((1 + np) * rateCtrl->bitsPerFrame);
-            rateCtrl->R += AllocatedBits;
-            rateCtrl->Np  = np;
-
-            OverDuantQp = (int)(8 * OverBits / AllocatedBits + 0.5);
-            rateCtrl->GOPOverdue = FALSE;
-
-            /*Compute InitialQp for each GOP*/
-            rateCtrl->NumberofGOP++;
-            if (rateCtrl->NumberofGOP == 1)
-            {
-                //rateCtrl->QPLastGOP = rateCtrl->initQP ; this causes too much quality fluctuation in I-frame
-            }
-            else
-            {
-                /*compute the average QP of P frames in the previous GOP*/
-                PAverageQp = (int)(1.0 * rateCtrl->TotalQpforPPicture / rateCtrl->NumberofPPicture + 0.5);
-
-                GOPDquant = (int)(0.5 + 1.0 * (np + 1) / 15);
-                if (GOPDquant > 2)
-                    GOPDquant = 2;
-
-                PAverageQp -= GOPDquant;
-
-                if (rateCtrl->basicUnit < (int)video->PicSizeInMbs)
-                {
-                    if (PAverageQp > (int)(rateCtrl->QPLastPFrame - 2))
-                        PAverageQp--;
-                    // this clipping causes too much quality fluctuation in I-frame
-                    //PAverageQp = AVC_MAX(rateCtrl->QPLastGOP-2,  PAverageQp);
-                    //PAverageQp = AVC_MIN(rateCtrl->QPLastGOP+2, PAverageQp);
-                    PAverageQp = AVC_MIN(RC_MAX_QUANT, PAverageQp);
-                    PAverageQp = AVC_MAX(RC_MIN_QUANT, PAverageQp);
-                }
-
-                //rateCtrl->QPLastGOP =
-                rateCtrl->initQP = PAverageQp;
-                rateCtrl->Pm_Qp = PAverageQp;
-                rateCtrl->PAveFrameQP = PAverageQp;
-            }
-
-            rateCtrl->TotalQpforPPicture = 0;
-            rateCtrl->NumberofPPicture = 0;
-        }
-    }
+    OSCL_UNUSED_ARG(encvid);
 
     return ;
 }
 
+
 void RCInitFrameQP(AVCEncObject *encvid)
 {
     AVCCommonObj *video = encvid->common;
     AVCRateControl *rateCtrl = encvid->rateCtrl;
     AVCPicParamSet *picParam = video->currPicParams;
-    int i;
-    int32 T = 0, T1 = 0;
-    int32 UpperBound;
-    int np = rateCtrl->idrPeriod - 1; // TotalPFrame
-    int bits;
+    MultiPass *pMP = rateCtrl->pMP;
 
     if (rateCtrl->rcEnable == TRUE)
     {
-
-        if (np < 0) np = video->MaxFrameNum - 1; // IPPPPP case
-        else if (np == 0) np = (1 << 16) - 1;
-
-        rateCtrl->NumberofCodedMacroBlocks = 0;
-
-        if ((video->slice_type == AVC_P_SLICE) || (rateCtrl->idrPeriod == 1 && rateCtrl->first_frame == FALSE))
-        {
-            /* predefine the  target buffer level for each picture.
-               frame layer rate control */
-            if (rateCtrl->basicUnit == (int)video->PicSizeInMbs)
-            {
-                if (rateCtrl->NumberofPPicture == 1)
-                {
-                    rateCtrl->TargetBufferLevel = rateCtrl->CurrentBufferFullness;
-                    rateCtrl->DeltaP = rateCtrl->CurrentBufferFullness / (np - 1);
-                    rateCtrl->TargetBufferLevel -= (int)rateCtrl->DeltaP;
-                }
-                else if (rateCtrl->NumberofPPicture > 1)
-                    rateCtrl->TargetBufferLevel -= (int)rateCtrl->DeltaP;
-            }
-            /* basic unit layer rate control */
-            else
-            {
-                if (rateCtrl->NumberofCodedPFrame > 0)
-                {
-                    for (i = 0;i < rateCtrl->TotalNumberofBasicUnit;i++)
-                        rateCtrl->BUPFMAD[i] = rateCtrl->BUCFMAD[i];
-                }
-
-                if (rateCtrl->NumberofGOP == 1)
-                {
-                    if (rateCtrl->NumberofPPicture == 1)
-                    {
-                        rateCtrl->TargetBufferLevel = rateCtrl->CurrentBufferFullness;
-                        rateCtrl->DeltaP = rateCtrl->CurrentBufferFullness / (np - 1);
-                        rateCtrl->TargetBufferLevel -= (int)rateCtrl->DeltaP;
-                    }
-                    else if (rateCtrl->NumberofPPicture > 1)
-                        rateCtrl->TargetBufferLevel -= (int)rateCtrl->DeltaP;
-                }
-                else if (rateCtrl->NumberofGOP > 1)
-                {
-                    if (rateCtrl->NumberofPPicture == 0)
-                    {
-                        rateCtrl->TargetBufferLevel = rateCtrl->CurrentBufferFullness;
-                        rateCtrl->DeltaP = rateCtrl->CurrentBufferFullness / np;
-                        rateCtrl->TargetBufferLevel -= (int)rateCtrl->DeltaP;
-                    }
-                    else if (rateCtrl->NumberofPPicture > 0)
-                        rateCtrl->TargetBufferLevel -= (int)rateCtrl->DeltaP;
-                }
-            }
-        }
-
-        /* additional code from RC3 */
-        if (video->slice_type == AVC_P_SLICE || rateCtrl->first_frame == 0)
-        {
-            if (rateCtrl->NumberofCodedPFrame > 0)
-            {
-                if (rateCtrl->idrPeriod == 1) // all I frames
-                {
-                    T = rateCtrl->R / (rateCtrl->Np + 1);  // ratio
-                    T1 = (int32)(rateCtrl->bitsPerFrame - GAMMAP * (rateCtrl->CurrentBufferFullness - rateCtrl->TargetBufferLevel) + 0.5);
-                    T1 = AVC_MAX(0, T1);
-                    T = (int32)(BETAP * T + (1.0 - BETAP) * T1 + 0.5);
-                }
-                else
-                {
-                    bits = (video->slice_type == AVC_P_SLICE) ? rateCtrl->RCPSliceBits : rateCtrl->RCISliceBits;
-
-                    // this part deviates from the JM code */
-                    T = (bits * rateCtrl->R) / (rateCtrl->bitsPerFrame * (rateCtrl->Np + 1));  // ratio
-
-                    if (video->slice_type == AVC_I_SLICE)
-                    {
-                        T = (int32)(T / (I_OVER_P_RATIO * 4));
-                    }
-                    else
-                    {
-                        T1 = (int32)(rateCtrl->bitsPerFrame - GAMMAP * (rateCtrl->CurrentBufferFullness - rateCtrl->TargetBufferLevel) + 0.5);
-                        T1 = AVC_MAX(0, T1);
-                        T = (int32)(BETAP * T + (1.0 - BETAP) * T1 + 0.5);
-                    }
-                }
-            }
-
-            /* reserve some bits for smoothing, commented out  */
-            /* HRD consideration */
-            if (video->slice_type == AVC_P_SLICE || rateCtrl->idrPeriod == 1)
-            {
-                UpperBound = (int32)(OMEGA * rateCtrl->UpperBound1);
-                T = AVC_MAX(T, rateCtrl->LowerBound);
-                rateCtrl->T = AVC_MIN(T, UpperBound);
-            }
-            else
-            {
-                rateCtrl->T = T;
-            }
-        }
-
         /* frame layer rate control */
+        if (rateCtrl->encoded_frames == 0)
+        {
+            video->QPy = rateCtrl->Qc = rateCtrl->initQP;
+        }
+        else
+        {
+            calculateQuantizer_Multipass(encvid, video, rateCtrl, pMP);
+            video->QPy = rateCtrl->Qc;
+        }
+
         rateCtrl->NumberofHeaderBits = 0;
         rateCtrl->NumberofTextureBits = 0;
-
-        /* basic unit layer rate control */
-        if (rateCtrl->basicUnit < (int)video->PicSizeInMbs)
-        {
-            rateCtrl->TotalFrameQP = 0;
-            rateCtrl->NumberofBasicUnitHeaderBits = 0;
-            rateCtrl->NumberofBasicUnitTextureBits = 0;
-            rateCtrl->TotalMADBasicUnit = 0;
-            rateCtrl->NumberofBasicUnit = rateCtrl->TotalNumberofBasicUnit;
-        }
-        video->QPy = rateCtrl->m_Qc = rateCtrl->PAveFrameQP = RCCalculateQP(encvid, rateCtrl);
-
         rateCtrl->numFrameBits = 0; // reset
 
+        /* update pMP->framePos */
+        if (++pMP->framePos == pMP->frameRange)	pMP->framePos = 0;
+
+        if (rateCtrl->T == 0)
+        {
+            pMP->counter_BTdst = (int)(rateCtrl->frame_rate * 7.5 + 0.5); /* 0.75s time frame */
+            pMP->counter_BTdst = AVC_MIN(pMP->counter_BTdst, (int)(rateCtrl->max_BitVariance_num / 2 * 0.40)); /* 0.75s time frame may go beyond VBV buffer if we set the buffer size smaller than 0.75s */
+            pMP->counter_BTdst = AVC_MAX(pMP->counter_BTdst, (int)((rateCtrl->Bs / 2 - rateCtrl->VBV_fullness) * 0.30 / (rateCtrl->TMN_TH / 10.0) + 0.5)); /* At least 30% of VBV buffer size/2 */
+            pMP->counter_BTdst = AVC_MIN(pMP->counter_BTdst, 20); /* Limit the target to be smaller than 3C */
+
+            pMP->target_bits = rateCtrl->T = rateCtrl->TMN_TH = (int)(rateCtrl->TMN_TH * (1.0 + pMP->counter_BTdst * 0.1));
+            pMP->diff_counter = pMP->counter_BTdst;
+        }
+
+        /* collect the necessary data: target bits, actual bits, mad and QP */
+        pMP->target_bits = rateCtrl->T;
+        pMP->QP  = video->QPy;
+
+        pMP->mad =	(OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs;//ComputeFrameMAD(video, rateCtrl);
+        if (pMP->mad < MAD_MIN)	pMP->mad = MAD_MIN; /* MAD_MIN is defined as 1 in mp4def.h */
+
+        pMP->bitrate = rateCtrl->bitRate; /* calculated in RCVopQPSetting */
+        pMP->framerate = rateCtrl->frame_rate;
+
+        /* first pass encoding */
+        pMP->nRe_Quantized = 0;
+
     } // rcEnable
     else
     {
@@ -548,288 +407,291 @@
     return ;
 }
 
-
-
-int RCCalculateQP(AVCEncObject *encvid, AVCRateControl *rateCtrl)
+/* Mad based variable bit allocation + QP calculation with a new quadratic method */
+void calculateQuantizer_Multipass(AVCEncObject *encvid, AVCCommonObj *video,
+                                  AVCRateControl *rateCtrl, MultiPass *pMP)
 {
-    AVCCommonObj *video = encvid->common;
-    double dtmp;
-    int m_Bits;
-    int PAverageQP;
-    int SumofBasicUnit;
-    int i;
-    double sqrt_dtmp;
-    double PreviousPictureMAD;
-    double MADPictureC1;
-    double MADPictureC2;
-    double m_X1 = rateCtrl->m_X1;
-    double m_X2 = rateCtrl->m_X2;
-    int m_Qc ;
-    double m_Qstep;
-    int m_Qp;
-    double CurrentBUMAD;
-    double TotalBUMAD;
-    int m_Hp;
-    int TotalBasicUnitBits;
-    int np = rateCtrl->idrPeriod - 1;
+    int prev_actual_bits = 0, curr_target, /*pos=0,*/i, j;
+    OsclFloat Qstep, prev_QP = 0.625;
 
-    if (np < 0) np = video->MaxFrameNum - 1; // IPPPPP case
-    else if (np == 0) np = (1 << 16) - 1; // IIIIII case
+    OsclFloat curr_mad, prev_mad, curr_RD, prev_RD, average_mad, aver_QP;
 
-    int Qstep2QP(double Qstep);
+    /* Mad based variable bit allocation */
+    targetBitCalculation(encvid, video, rateCtrl, pMP);
 
-    /* frame layer rate control */
-    if (rateCtrl->basicUnit == (int)video->PicSizeInMbs || (video->slice_type != AVC_P_SLICE && rateCtrl->idrPeriod == 1)) // I_slice for basic unit comes here too
+    if (rateCtrl->T <= 0 || rateCtrl->totalSAD == 0)
     {
-        if (rateCtrl->first_frame) //(video->slice_type==AVC_I_SLICE)
-        {
-            m_Qc = rateCtrl->initQP;
-            rateCtrl->Pm_Qp = m_Qc;
-            return m_Qc;
-        }
-        else if ((rateCtrl->first_frame == FALSE) && (rateCtrl->NumberofPPicture == 0)) /* first P-frame */
-        {
-            m_Qc = rateCtrl->initQP;
-            //if(active_sps->frame_mbs_only_flag)
-            rateCtrl->TotalQpforPPicture += m_Qc;
-            rateCtrl->Pm_Qp = m_Qc;
-            return m_Qc;
-        }
-        else /* subsequent frames */
-        {
-            MADPictureC1 = rateCtrl->PMADPictureC1;
-            MADPictureC2 = rateCtrl->PMADPictureC2;
-            PreviousPictureMAD = rateCtrl->PPictureMAD[0];
-            m_Qp = rateCtrl->Pm_Qp;
-            m_Hp = rateCtrl->PPreHeader;
-
-            if (rateCtrl->basicUnit < (int)video->PicSizeInMbs && video->slice_type != AVC_P_SLICE)
-            {
-                PreviousPictureMAD = rateCtrl->PreviousWholeFrameMAD;
-            }
-
-            if (video->slice_type == AVC_I_SLICE)
-            {
-                m_Hp = 0;
-            }
-
-            /* predict the MAD of current picture*/
-            rateCtrl->CurrentFrameMAD = MADPictureC1 * PreviousPictureMAD + MADPictureC2;
-
-            /*compute the number of bits for the texture*/
-            if (rateCtrl->T < 0) /* if target bits is already below zero, just increase Qp */
-            {
-                m_Qc = m_Qp + QP_DELTA;
-                m_Qc = AVC_MIN(m_Qc, RC_MAX_QUANT); // clipping
-            }
-            else /* get QP from R-Q model */
-            {
-                if (video->slice_type != AVC_P_SLICE && rateCtrl->idrPeriod != 1)
-                {
-                    if (rateCtrl->basicUnit < (int)video->PicSizeInMbs)
-                    {
-                        m_Bits = (rateCtrl->T - m_Hp) / rateCtrl->TotalNumberofBasicUnit;
-                    }
-                    else
-                    {
-                        m_Bits = rateCtrl->T - m_Hp;
-                    }
-                }
-                else
-                {
-                    m_Bits = rateCtrl->T - m_Hp;
-                    m_Bits = AVC_MAX(m_Bits, (int)(rateCtrl->bitsPerFrame / MINVALUE));
-                }
-
-                dtmp = rateCtrl->CurrentFrameMAD * m_X1 * rateCtrl->CurrentFrameMAD * m_X1 \
-                       + 4 * m_X2 * rateCtrl->CurrentFrameMAD * m_Bits;
-
-                if (dtmp > 0) sqrt_dtmp = oscl_sqrt(dtmp);
-                else sqrt_dtmp = 0.0;
-
-                if ((m_X2 == 0.0) || (dtmp < 0) || ((sqrt_dtmp - m_X1 * rateCtrl->CurrentFrameMAD) <= 0.0)) // fall back 1st order mode
-                    m_Qstep = (float)(m_X1 * rateCtrl->CurrentFrameMAD / (double) m_Bits);
-                else // 2nd order mode
-                    m_Qstep = (float)((2 * m_X2 * rateCtrl->CurrentFrameMAD) / (sqrt_dtmp - m_X1 * rateCtrl->CurrentFrameMAD));
-
-                m_Qc = Qstep2QP(m_Qstep);
-                m_Qc = AVC_MIN(m_Qc, RC_MAX_QUANT); // clipping
-                m_Qc = AVC_MAX(RC_MIN_QUANT, m_Qc);
-
-                if (video->slice_type == AVC_P_SLICE)
-                {
-                    m_Qc = AVC_MIN(m_Qp + QP_DELTA,  m_Qc);  // control variation
-                    m_Qc = AVC_MAX(m_Qp - QP_DELTA, m_Qc); // control variation
-                }
-                else
-                {
-                    m_Qc = AVC_MIN(m_Qp + QP_DELTA_I,  m_Qc);  // control variation
-                    m_Qc = AVC_MAX(m_Qp - QP_DELTA_I, m_Qc); // control variation
-                }
-
-            }
-            rateCtrl->TotalQpforPPicture += m_Qc;
-            rateCtrl->Pm_Qp = m_Qc;
-
-            return m_Qc;
-        }
+        if (rateCtrl->T < 0)	rateCtrl->Qc = RC_MAX_QUANT;
+        return;
     }
-    /**********basic unit layer rate control*********/
+
+    /* ---------------------------------------------------------------------------------------------------*/
+    /* current frame QP estimation */
+    curr_target = rateCtrl->T;
+    curr_mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs;
+    if (curr_mad < MAD_MIN)	curr_mad = MAD_MIN; /* MAD_MIN is defined as 1 in mp4def.h */
+    curr_RD  = (OsclFloat)curr_target / curr_mad;
+
+    if (rateCtrl->skip_next_frame == -1) // previous was skipped
+    {
+        i = pMP->framePos;
+        prev_mad = pMP->pRDSamples[i][0].mad;
+        prev_QP = pMP->pRDSamples[i][0].QP;
+        prev_actual_bits = pMP->pRDSamples[i][0].actual_bits;
+    }
     else
     {
-        if (rateCtrl->first_frame) //(video->slice_type==AVC_I_SLICE)
+        /* Another version of search the optimal point */
+        prev_mad = 0.0;
+        i = 0;
+        while (i < pMP->frameRange && prev_mad < 0.001) /* find first one with nonzero prev_mad */
         {
-            m_Qc = rateCtrl->initQP;
-            rateCtrl->Pm_Qp = m_Qc;
-            return m_Qc;
+            prev_mad = pMP->pRDSamples[i][0].mad;
+            i++;
         }
-        else //if(video->slice_type==AVC_P_SLICE)
+
+        if (i < pMP->frameRange)
         {
-            if ((rateCtrl->NumberofGOP == 1) && (rateCtrl->NumberofPPicture == 0))
+            prev_actual_bits = pMP->pRDSamples[i-1][0].actual_bits;
+
+            for (j = 0; i < pMP->frameRange; i++)
             {
-                /*top field of the first P frame*/
-                m_Qc = rateCtrl->initQP;
-                rateCtrl->NumberofBasicUnitHeaderBits = 0;
-                rateCtrl->NumberofBasicUnitTextureBits = 0;
-                rateCtrl->NumberofBasicUnit--;
-                /*bottom field of the first P frame*/
-                if (rateCtrl->NumberofBasicUnit == 0)
+                if (pMP->pRDSamples[i][0].mad != 0 &&
+                        AVC_ABS(prev_mad - curr_mad) > AVC_ABS(pMP->pRDSamples[i][0].mad - curr_mad))
                 {
-                    rateCtrl->TotalQpforPPicture += m_Qc;
-                    rateCtrl->PAveFrameQP = m_Qc;
-                    rateCtrl->PAveHeaderBits3 = rateCtrl->PAveHeaderBits2;
+                    prev_mad = pMP->pRDSamples[i][0].mad;
+                    prev_actual_bits = pMP->pRDSamples[i][0].actual_bits;
+                    j = i;
                 }
-                rateCtrl->Pm_Qp = m_Qc;
-                rateCtrl->TotalFrameQP += m_Qc;
-                return m_Qc;
             }
-            else /* subsequent P-frames */
+            prev_QP = QP2Qstep(pMP->pRDSamples[j][0].QP);
+
+            for (i = 1; i < pMP->samplesPerFrame[j]; i++)
             {
-                m_Hp = rateCtrl->PPreHeader;
-                m_Qp = rateCtrl->Pm_Qp;
-                MADPictureC1 = rateCtrl->PMADPictureC1;
-                MADPictureC2 = rateCtrl->PMADPictureC2;
-
-                SumofBasicUnit = rateCtrl->TotalNumberofBasicUnit;
-                /*the average QP of the previous frame is used to coded the first basic unit of the current frame or field*/
-                if (rateCtrl->NumberofBasicUnit == SumofBasicUnit)
+                if (AVC_ABS(prev_actual_bits - curr_target) > AVC_ABS(pMP->pRDSamples[j][i].actual_bits - curr_target))
                 {
-                    if (rateCtrl->T <= 0)
-                    {
-                        m_Qc = rateCtrl->PAveFrameQP + 2;
-                        if (m_Qc > RC_MAX_QUANT)
-                            m_Qc = RC_MAX_QUANT;
-                        rateCtrl->GOPOverdue = TRUE;
-                    }
-                    else
-                    {
-                        m_Qc = rateCtrl->PAveFrameQP;
-                    }
-                    rateCtrl->TotalFrameQP += m_Qc;
-                    rateCtrl->NumberofBasicUnit--;
-                    rateCtrl->Pm_Qp = rateCtrl->PAveFrameQP;
-                    return m_Qc;
+                    prev_actual_bits = pMP->pRDSamples[j][i].actual_bits;
+                    prev_QP = QP2Qstep(pMP->pRDSamples[j][i].QP);
                 }
-                else
-                {
-                    /*compute the number of remaining bits*/
-                    TotalBasicUnitBits = rateCtrl->NumberofBasicUnitHeaderBits + rateCtrl->NumberofBasicUnitTextureBits;
-                    rateCtrl->T -= TotalBasicUnitBits;
-                    rateCtrl->NumberofBasicUnitHeaderBits = 0;
-                    rateCtrl->NumberofBasicUnitTextureBits = 0;
-                    if (rateCtrl->T < 0)
-                    {
-                        if (rateCtrl->GOPOverdue == TRUE)
-                            m_Qc = m_Qp + 2;
-                        else
-                            m_Qc = m_Qp + rateCtrl->DDquant;//2
-                        m_Qc = AVC_MIN(m_Qc, RC_MAX_QUANT);  // clipping
-                        if (rateCtrl->basicUnit >= (int)video->PicWidthInMbs)
-                            m_Qc = AVC_MIN(m_Qc, rateCtrl->PAveFrameQP + 6);
-                        else
-                            m_Qc = AVC_MIN(m_Qc, rateCtrl->PAveFrameQP + 3);
-
-                        rateCtrl->TotalFrameQP += m_Qc;
-                        rateCtrl->NumberofBasicUnit--;
-                        if (rateCtrl->NumberofBasicUnit == 0)
-                        {
-                            PAverageQP = (int)(1.0 * rateCtrl->TotalFrameQP / rateCtrl->TotalNumberofBasicUnit + 0.5);
-                            if (rateCtrl->NumberofPPicture == (np - 1))
-                                rateCtrl->QPLastPFrame = PAverageQP;
-
-                            rateCtrl->TotalQpforPPicture += PAverageQP;
-                            rateCtrl->PAveFrameQP = PAverageQP;
-                            rateCtrl->PAveHeaderBits3 = rateCtrl->PAveHeaderBits2;
-                        }
-                        if (rateCtrl->GOPOverdue == TRUE)
-                            rateCtrl->Pm_Qp = rateCtrl->PAveFrameQP;
-                        else
-                            rateCtrl->Pm_Qp = m_Qc;
-                        return m_Qc;
-                    }
-                    else
-                    {
-                        /*predict the MAD of current picture*/
-                        rateCtrl->CurrentFrameMAD = MADPictureC1 * rateCtrl->BUPFMAD[rateCtrl->TotalNumberofBasicUnit-rateCtrl->NumberofBasicUnit] + MADPictureC2;
-                        TotalBUMAD = 0;
-                        for (i = rateCtrl->TotalNumberofBasicUnit - 1; i >= (rateCtrl->TotalNumberofBasicUnit - rateCtrl->NumberofBasicUnit);i--)
-                        {
-                            CurrentBUMAD = MADPictureC1 * rateCtrl->BUPFMAD[i] + MADPictureC2;
-                            TotalBUMAD += CurrentBUMAD * CurrentBUMAD;
-                        }
-
-                        /*compute the total number of bits for the current basic unit*/
-                        m_Bits = (int)(rateCtrl->T * rateCtrl->CurrentFrameMAD * rateCtrl->CurrentFrameMAD / TotalBUMAD);
-                        /*compute the number of texture bits*/
-                        m_Bits -= rateCtrl->PAveHeaderBits2;
-
-                        m_Bits = AVC_MAX(m_Bits, (int)(rateCtrl->bitsPerFrame / (MINVALUE * rateCtrl->TotalNumberofBasicUnit)));
-
-                        dtmp = rateCtrl->CurrentFrameMAD * m_X1 * rateCtrl->CurrentFrameMAD * m_X1 \
-                               + 4 * m_X2 * rateCtrl->CurrentFrameMAD * m_Bits;
-                        if ((m_X2 == 0.0) || (dtmp < 0) || ((oscl_sqrt(dtmp) - m_X1 * rateCtrl->CurrentFrameMAD) <= 0.0))   // fall back 1st order mode
-                            m_Qstep = (float)(m_X1 * rateCtrl->CurrentFrameMAD / (double) m_Bits);
-                        else // 2nd order mode
-                            m_Qstep = (float)((2 * m_X2 * rateCtrl->CurrentFrameMAD) / (oscl_sqrt(dtmp) - m_X1 * rateCtrl->CurrentFrameMAD));
-
-                        m_Qc = Qstep2QP(m_Qstep);
-                        m_Qc = AVC_MIN(m_Qp + rateCtrl->DDquant,  m_Qc); // control variation
-                        if (rateCtrl->basicUnit >= (int)video->PicWidthInMbs)
-                            m_Qc = AVC_MIN(rateCtrl->PAveFrameQP + 6, m_Qc);
-                        else
-                            m_Qc = AVC_MIN(rateCtrl->PAveFrameQP + 3, m_Qc);
-
-                        m_Qc = AVC_MIN(m_Qc, RC_MAX_QUANT);  // clipping
-
-                        m_Qc = AVC_MAX(m_Qp - rateCtrl->DDquant, m_Qc);  // control variation
-                        if (rateCtrl->basicUnit >= (int)video->PicWidthInMbs)
-                            m_Qc = AVC_MAX(rateCtrl->PAveFrameQP - 6, m_Qc);
-                        else
-                            m_Qc = AVC_MAX(rateCtrl->PAveFrameQP - 3, m_Qc);
-
-                        m_Qc = AVC_MAX(RC_MIN_QUANT, m_Qc);
-
-                        rateCtrl->TotalFrameQP += m_Qc;
-                        rateCtrl->Pm_Qp = m_Qc;
-                        rateCtrl->NumberofBasicUnit--;
-                        if ((rateCtrl->NumberofBasicUnit == 0) && (video->slice_type == AVC_P_SLICE))
-                        {
-                            /*frame coding or field coding*/
-                            PAverageQP = (int)(1.0 * rateCtrl->TotalFrameQP / rateCtrl->TotalNumberofBasicUnit + 0.5);
-                            if (rateCtrl->NumberofPPicture == (np - 1))
-                                rateCtrl->QPLastPFrame = PAverageQP;
-
-                            rateCtrl->TotalQpforPPicture += PAverageQP;
-                            rateCtrl->PAveFrameQP = PAverageQP;
-                            rateCtrl->PAveHeaderBits3 = rateCtrl->PAveHeaderBits2;
-                        }
-                        return m_Qc;
-                    }
-                }
-            } /* subsequent P-frames */
-        } /* AVC_P_SLICE */
+            }
+        }
     }
-    return m_Qc;
+
+    // quadratic approximation
+    if (prev_mad > 0.001) // only when prev_mad is greater than 0, otherwise keep using the same QP
+    {
+        prev_RD = (OsclFloat)prev_actual_bits / prev_mad;
+        //rateCtrl->Qc = (Int)(prev_QP * sqrt(prev_actual_bits/curr_target) + 0.4);
+        if (prev_QP == 0.625) // added this to allow getting out of QP = 0 easily
+        {
+            Qstep = (int)(prev_RD / curr_RD + 0.5);
+        }
+        else
+        {
+            //		rateCtrl->Qc =(Int)(prev_QP * M4VENC_SQRT(prev_RD/curr_RD) + 0.9);
+
+            if (prev_RD / curr_RD > 0.5 && prev_RD / curr_RD < 2.0)
+                Qstep = (int)(prev_QP * (oscl_sqrt(prev_RD / curr_RD) + prev_RD / curr_RD) / 2.0 + 0.9); /* Quadratic and linear approximation */
+            else
+                Qstep = (int)(prev_QP * (oscl_sqrt(prev_RD / curr_RD) + oscl_pow(prev_RD / curr_RD, 1.0 / 3.0)) / 2.0 + 0.9);
+        }
+        // lower bound on Qc should be a function of curr_mad
+        // When mad is already low, lower bound on Qc doesn't have to be small.
+        // Note, this doesn't work well for low complexity clip encoded at high bit rate
+        // it doesn't hit the target bit rate due to this QP lower bound.
+        ///	if((curr_mad < 8) && (rateCtrl->Qc < 12))	rateCtrl->Qc = 12;
+        //	else	if((curr_mad < 128) && (rateCtrl->Qc < 3)) rateCtrl->Qc = 3;
+
+        rateCtrl->Qc = Qstep2QP(Qstep);
+
+        if (rateCtrl->Qc < RC_MIN_QUANT) rateCtrl->Qc = RC_MIN_QUANT;
+        if (rateCtrl->Qc > RC_MAX_QUANT)	rateCtrl->Qc = RC_MAX_QUANT;
+    }
+
+    /* active bit resource protection */
+    aver_QP = (pMP->encoded_frames == 0 ? 0 : pMP->sum_QP / (OsclFloat)pMP->encoded_frames);
+    average_mad = (pMP->encoded_frames == 0 ? 0 : pMP->sum_mad / (OsclFloat)pMP->encoded_frames); /* this function is called from the scond encoded frame*/
+    if (pMP->diff_counter == 0 &&
+            ((OsclFloat)rateCtrl->Qc <= aver_QP*1.1 || curr_mad <= average_mad*1.1) &&
+            pMP->counter_BTsrc <= (pMP->counter_BTdst + (int)(pMP->framerate*1.0 + 0.5)))
+    {
+        rateCtrl->TMN_TH -= (int)(pMP->target_bits_per_frame / 10.0);
+        rateCtrl->T = rateCtrl->TMN_TH - rateCtrl->TMN_W;
+        pMP->counter_BTsrc++;
+        pMP->diff_counter--;
+    }
+
+}
+
+void targetBitCalculation(AVCEncObject *encvid, AVCCommonObj *video, AVCRateControl *rateCtrl, MultiPass *pMP)
+{
+    OSCL_UNUSED_ARG(encvid);
+    OsclFloat curr_mad;//, average_mad;
+    int diff_counter_BTsrc, diff_counter_BTdst, prev_counter_diff, curr_counter_diff, bound;
+    /* BT = Bit Transfer, for pMP->counter_BTsrc, pMP->counter_BTdst */
+
+    /* some stuff about frame dropping remained here to be done because pMP cannot be inserted into updateRateControl()*/
+    updateRC_PostProc(rateCtrl, pMP);
+
+    /* update pMP->counter_BTsrc and pMP->counter_BTdst to avoid interger overflow */
+    if (pMP->counter_BTsrc > 1000 && pMP->counter_BTdst > 1000)
+    {
+        pMP->counter_BTsrc -= 1000;
+        pMP->counter_BTdst -= 1000;
+    }
+
+    /* ---------------------------------------------------------------------------------------------------*/
+    /* target calculation */
+    curr_mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs;
+    if (curr_mad < MAD_MIN)	curr_mad = MAD_MIN; /* MAD_MIN is defined as 1 in mp4def.h */
+    diff_counter_BTsrc = diff_counter_BTdst = 0;
+    pMP->diff_counter = 0;
+
+
+    /*1.calculate average mad */
+    pMP->sum_mad += curr_mad;
+    //average_mad = (pMP->encoded_frames < 1 ? curr_mad : pMP->sum_mad/(OsclFloat)(pMP->encoded_frames+1)); /* this function is called from the scond encoded frame*/
+    //pMP->aver_mad = average_mad;
+    if (pMP->encoded_frames >= 0) /* pMP->encoded_frames is set to -1 initially, so forget about the very first I frame */
+        pMP->aver_mad = (pMP->aver_mad * pMP->encoded_frames + curr_mad) / (pMP->encoded_frames + 1);
+
+    if (pMP->overlapped_win_size > 0 && pMP->encoded_frames_prev >= 0)
+        pMP->aver_mad_prev = (pMP->aver_mad_prev * pMP->encoded_frames_prev + curr_mad) / (pMP->encoded_frames_prev + 1);
+
+    /*2.average_mad, mad ==> diff_counter_BTsrc, diff_counter_BTdst */
+    if (pMP->overlapped_win_size == 0)
+    {
+        /* original verison */
+        if (curr_mad > pMP->aver_mad*1.1)
+        {
+            if (curr_mad / (pMP->aver_mad + 0.0001) > 2)
+                diff_counter_BTdst = (int)(oscl_sqrt(curr_mad / (pMP->aver_mad + 0.0001)) * 10 + 0.4) - 10;
+            //diff_counter_BTdst = (int)((sqrt(curr_mad/pMP->aver_mad)*2+curr_mad/pMP->aver_mad)/(3*0.1) + 0.4) - 10;
+            else
+                diff_counter_BTdst = (int)(curr_mad / (pMP->aver_mad + 0.0001) * 10 + 0.4) - 10;
+        }
+        else /* curr_mad <= average_mad*1.1 */
+            //diff_counter_BTsrc = 10 - (int)((sqrt(curr_mad/pMP->aver_mad) + pow(curr_mad/pMP->aver_mad, 1.0/3.0))/(2.0*0.1) + 0.4);
+            diff_counter_BTsrc = 10 - (int)(oscl_sqrt(curr_mad / (pMP->aver_mad + 0.0001)) * 10 + 0.5);
+
+        /* actively fill in the possible gap */
+        if (diff_counter_BTsrc == 0 && diff_counter_BTdst == 0 &&
+                curr_mad <= pMP->aver_mad*1.1 && pMP->counter_BTsrc < pMP->counter_BTdst)
+            diff_counter_BTsrc = 1;
+
+    }
+    else if (pMP->overlapped_win_size > 0)
+    {
+        /* transition time: use previous average mad "pMP->aver_mad_prev" instead of the current average mad "pMP->aver_mad" */
+        if (curr_mad > pMP->aver_mad_prev*1.1)
+        {
+            if (curr_mad / pMP->aver_mad_prev > 2)
+                diff_counter_BTdst = (int)(oscl_sqrt(curr_mad / (pMP->aver_mad_prev + 0.0001)) * 10 + 0.4) - 10;
+            //diff_counter_BTdst = (int)((M4VENC_SQRT(curr_mad/pMP->aver_mad_prev)*2+curr_mad/pMP->aver_mad_prev)/(3*0.1) + 0.4) - 10;
+            else
+                diff_counter_BTdst = (int)(curr_mad / (pMP->aver_mad_prev + 0.0001) * 10 + 0.4) - 10;
+        }
+        else /* curr_mad <= average_mad*1.1 */
+            //diff_counter_BTsrc = 10 - (Int)((sqrt(curr_mad/pMP->aver_mad_prev) + pow(curr_mad/pMP->aver_mad_prev, 1.0/3.0))/(2.0*0.1) + 0.4);
+            diff_counter_BTsrc = 10 - (int)(oscl_sqrt(curr_mad / (pMP->aver_mad_prev + 0.0001)) * 10 + 0.5);
+
+        /* actively fill in the possible gap */
+        if (diff_counter_BTsrc == 0 && diff_counter_BTdst == 0 &&
+                curr_mad <= pMP->aver_mad_prev*1.1 && pMP->counter_BTsrc < pMP->counter_BTdst)
+            diff_counter_BTsrc = 1;
+
+        if (--pMP->overlapped_win_size <= 0)	pMP->overlapped_win_size = 0;
+    }
+
+
+    /* if difference is too much, do clipping */
+    /* First, set the upper bound for current bit allocation variance: 80% of available buffer */
+    bound = (int)((rateCtrl->Bs / 2 - rateCtrl->VBV_fullness) * 0.6 / (pMP->target_bits_per_frame / 10)); /* rateCtrl->Bs */
+    diff_counter_BTsrc =  AVC_MIN(diff_counter_BTsrc, bound);
+    diff_counter_BTdst =  AVC_MIN(diff_counter_BTdst, bound);
+
+    /* Second, set another upper bound for current bit allocation: 4-5*bitrate/framerate */
+    bound = 50;
+//	if(video->encParams->RC_Type == CBR_LOWDELAY)
+//  not necessary		bound = 10;  -- For Low delay */
+
+    diff_counter_BTsrc =  AVC_MIN(diff_counter_BTsrc, bound);
+    diff_counter_BTdst =  AVC_MIN(diff_counter_BTdst, bound);
+
+
+    /* Third, check the buffer */
+    prev_counter_diff = pMP->counter_BTdst - pMP->counter_BTsrc;
+    curr_counter_diff = prev_counter_diff + (diff_counter_BTdst - diff_counter_BTsrc);
+
+    if (AVC_ABS(prev_counter_diff) >= rateCtrl->max_BitVariance_num || AVC_ABS(curr_counter_diff) >= rateCtrl->max_BitVariance_num)
+    {	//diff_counter_BTsrc = diff_counter_BTdst = 0;
+
+        if (curr_counter_diff > rateCtrl->max_BitVariance_num && diff_counter_BTdst)
+        {
+            diff_counter_BTdst = (rateCtrl->max_BitVariance_num - prev_counter_diff) + diff_counter_BTsrc;
+            if (diff_counter_BTdst < 0) diff_counter_BTdst = 0;
+        }
+
+        else if (curr_counter_diff < -rateCtrl->max_BitVariance_num && diff_counter_BTsrc)
+        {
+            diff_counter_BTsrc = diff_counter_BTdst - (-rateCtrl->max_BitVariance_num - prev_counter_diff);
+            if (diff_counter_BTsrc < 0) diff_counter_BTsrc = 0;
+        }
+    }
+
+
+    /*3.diff_counter_BTsrc, diff_counter_BTdst ==> TMN_TH */
+    rateCtrl->TMN_TH = (int)(pMP->target_bits_per_frame);
+    pMP->diff_counter = 0;
+
+    if (diff_counter_BTsrc)
+    {
+        rateCtrl->TMN_TH -= (int)(pMP->target_bits_per_frame * diff_counter_BTsrc * 0.1);
+        pMP->diff_counter = -diff_counter_BTsrc;
+    }
+    else if (diff_counter_BTdst)
+    {
+        rateCtrl->TMN_TH += (int)(pMP->target_bits_per_frame * diff_counter_BTdst * 0.1);
+        pMP->diff_counter = diff_counter_BTdst;
+    }
+
+
+    /*4.update pMP->counter_BTsrc, pMP->counter_BTdst */
+    pMP->counter_BTsrc += diff_counter_BTsrc;
+    pMP->counter_BTdst += diff_counter_BTdst;
+
+
+    /*5.target bit calculation */
+    rateCtrl->T = rateCtrl->TMN_TH - rateCtrl->TMN_W;
+
+    return ;
+}
+
+void updateRC_PostProc(AVCRateControl *rateCtrl, MultiPass *pMP)
+{
+    if (rateCtrl->skip_next_frame > 0) /* skip next frame */
+    {
+        pMP->counter_BTsrc += 10 * rateCtrl->skip_next_frame;
+
+    }
+    else if (rateCtrl->skip_next_frame == -1) /* skip current frame */
+    {
+        pMP->counter_BTdst -= pMP->diff_counter;
+        pMP->counter_BTsrc += 10;
+
+        pMP->sum_mad -= pMP->mad;
+        pMP->aver_mad = (pMP->aver_mad * pMP->encoded_frames - pMP->mad) / (pMP->encoded_frames - 1 + 0.0001);
+        pMP->sum_QP  -= pMP->QP;
+        pMP->encoded_frames --;
+    }
+    /* some stuff in update VBV_fullness remains here */
+    //if(rateCtrl->VBV_fullness < -rateCtrl->Bs/2) /* rateCtrl->Bs */
+    if (rateCtrl->VBV_fullness < rateCtrl->low_bound)
+    {
+        rateCtrl->VBV_fullness = rateCtrl->low_bound; // -rateCtrl->Bs/2;
+        rateCtrl->TMN_W = rateCtrl->VBV_fullness - rateCtrl->low_bound;
+        pMP->counter_BTsrc = pMP->counter_BTdst + (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
+    }
 }
 
 
@@ -878,26 +740,32 @@
 void RCInitMBQP(AVCEncObject *encvid)
 {
     AVCCommonObj *video =  encvid->common;
-    AVCRateControl *rateCtrl = encvid->rateCtrl;
     AVCMacroblock *currMB = video->currMB;
 
     currMB->QPy = video->QPy; /* set to previous value or picture level */
 
-    if (rateCtrl->rcEnable == TRUE)
-    {
-        if (((video->slice_type == AVC_P_SLICE) || (rateCtrl->idrPeriod == 1 && rateCtrl->first_frame == FALSE)) && (rateCtrl->NumberofCodedMacroBlocks > 0)
-                && (rateCtrl->NumberofCodedMacroBlocks % rateCtrl->basicUnit == 0))
-        {
-
-            RCUpdateRCModel(encvid);
-            currMB->QPy = rateCtrl->m_Qc = RCCalculateQP(encvid, rateCtrl);
-        }
-    }
-
     RCInitChromaQP(encvid);
 
 }
 
+void RCPostMB(AVCCommonObj *video, AVCRateControl *rateCtrl, int num_header_bits, int num_texture_bits)
+{
+    OSCL_UNUSED_ARG(video);
+    rateCtrl->numMBHeaderBits = num_header_bits;
+    rateCtrl->numMBTextureBits = num_texture_bits;
+    rateCtrl->NumberofHeaderBits += rateCtrl->numMBHeaderBits;
+    rateCtrl->NumberofTextureBits += rateCtrl->numMBTextureBits;
+}
+
+void RCRestoreQP(AVCMacroblock *currMB, AVCCommonObj *video, AVCEncObject *encvid)
+{
+    currMB->QPy = video->QPy; /* use previous QP */
+    RCInitChromaQP(encvid);
+
+    return ;
+}
+
+
 void RCCalculateMAD(AVCEncObject *encvid, AVCMacroblock *currMB, uint8 *orgL, int orgPitch)
 {
     AVCCommonObj *video = encvid->common;
@@ -920,85 +788,60 @@
             }
         }
         /* for INTER, we have already saved it with the MV search */
-
-        if (rateCtrl->basicUnit < (int)video->PicSizeInMbs)
-        {
-            rateCtrl->TotalMADBasicUnit += rateCtrl->MADofMB[video->mbNum];
-        }
     }
 
     return ;
 }
 
-void RCRestoreQP(AVCMacroblock *currMB, AVCCommonObj *video, AVCEncObject *encvid)
-{
-    currMB->QPy = video->QPy; /* use previous QP */
-    RCInitChromaQP(encvid);
 
-    return ;
-}
 
 AVCEnc_Status RCUpdateFrame(AVCEncObject *encvid)
 {
     AVCCommonObj *video = encvid->common;
     AVCRateControl *rateCtrl = encvid->rateCtrl;
     AVCEnc_Status status = AVCENC_SUCCESS;
+    MultiPass *pMP = rateCtrl->pMP;
+    int diff_BTCounter;
+    int nal_type = video->nal_unit_type;
 
-    int nbits = rateCtrl->numFrameBits;
-    int32 tmp;
     /* update the complexity weight of I, P, B frame */
-    int Avem_Qc;
-    int X = 0;
 
     if (rateCtrl->rcEnable == TRUE)
     {
-        /* frame layer rate control */
-        if (rateCtrl->basicUnit == (int)video->PicSizeInMbs)
-            X = (int)(nbits * rateCtrl->m_Qc + 0.5);
-        /* basic unit layer rate control */
+        pMP->actual_bits = rateCtrl->numFrameBits;
+        pMP->mad = (OsclFloat)rateCtrl->totalSAD / video->PicSizeInMbs; //ComputeFrameMAD(video, rateCtrl);
+
+        AVCSaveRDSamples(pMP, 0);
+
+        pMP->encoded_frames++;
+
+        /* for pMP->samplesPerFrame */
+        pMP->samplesPerFrame[pMP->framePos] = 0;
+
+        pMP->sum_QP += pMP->QP;
+
+        /* update pMP->counter_BTsrc, pMP->counter_BTdst */
+        /* re-allocate the target bit again and then stop encoding */
+        diff_BTCounter = (int)((OsclFloat)(rateCtrl->TMN_TH - rateCtrl->TMN_W - pMP->actual_bits) /
+                               (pMP->bitrate / (pMP->framerate + 0.0001) + 0.0001) / 0.1);
+        if (diff_BTCounter >= 0)
+            pMP->counter_BTsrc += diff_BTCounter; /* pMP->actual_bits is smaller */
         else
-        {
-            if (video->slice_type == AVC_P_SLICE)
-            {
-                Avem_Qc = rateCtrl->TotalFrameQP / rateCtrl->TotalNumberofBasicUnit;
-                X = (int)(nbits * Avem_Qc + 0.5);
-            }
-        }
+            pMP->counter_BTdst -= diff_BTCounter; /* pMP->actual_bits is bigger */
 
-        if (video->slice_type == AVC_P_SLICE || (rateCtrl->idrPeriod == 1))
-        {
-            rateCtrl->Np--;
-            rateCtrl->Wp = X;
-            rateCtrl->NumberofCodedPFrame++;
-            rateCtrl->NumberofPPicture++;
+        rateCtrl->TMN_TH -= (int)((OsclFloat)pMP->bitrate / (pMP->framerate + 0.0001) * (diff_BTCounter * 0.1));
+        rateCtrl->T = pMP->target_bits = rateCtrl->TMN_TH - rateCtrl->TMN_W;
+        pMP->diff_counter -= diff_BTCounter;
 
-        }
+        rateCtrl->Rc = rateCtrl->numFrameBits;	/* Total Bits for current frame */
+        rateCtrl->Hc = rateCtrl->NumberofHeaderBits;	/* Total Bits in Header and Motion Vector */
 
-        tmp = (int32)(rateCtrl->bitsPerFrame - nbits);
-        rateCtrl->CurrentBufferFullness -= tmp;
-#if 1 // this part may not be necessary
-        if (rateCtrl->CurrentBufferFullness > rateCtrl->cpbSize*0.8 && video->slice_type != AVC_I_SLICE) /* skip current frame */
+        /* BX_RC */
+        updateRateControl(rateCtrl, nal_type);
+        if (rateCtrl->skip_next_frame == -1) // skip current frame
         {
-            rateCtrl->curr_skip = 1;
-            rateCtrl->CurrentBufferFullness += tmp;
             status = AVCENC_SKIPPED_PICTURE;
         }
-        else
-        {
-            rateCtrl->curr_skip = 0;
-            /*update the lower bound and the upper bound for the target bits of each frame, HRD consideration*/
-            rateCtrl->R -= nbits; /* remaining # of bits in GOP */
-            rateCtrl->LowerBound  += tmp;
-            rateCtrl->UpperBound1 += tmp;
-        }
-#endif
-
-        if (video->slice_type == AVC_P_SLICE || (rateCtrl->idrPeriod == 1/* && !rateCtrl->first_frame*/))
-        {
-            RCUpdateRCModel(encvid);
-
-            rateCtrl->PreviousWholeFrameMAD = ComputeFrameMAD(video, rateCtrl);
-        }
     }
 
     rateCtrl->first_frame = 0;  // reset here after we encode the first frame.
@@ -1006,122 +849,58 @@
     return status;
 }
 
-void RCUpdateRCModel(AVCEncObject *encvid)
+void AVCSaveRDSamples(MultiPass *pMP, int counter_samples)
 {
-    AVCCommonObj *video = encvid->common;
-    AVCRateControl *rateCtrl = encvid->rateCtrl;
-    int		n_windowSize;
-    int		i;
-    double	error[20], std = 0.0, threshold;
-    int		m_Nc;
-    bool	MADModelFlag = FALSE;
-    bool	m_rgRejected[21];
-    int		CodedBasicUnit;
-
-    /*frame layer rate control*/
-    if (rateCtrl->basicUnit == (int)video->PicSizeInMbs)
-    {
-        rateCtrl->CurrentFrameMAD = ComputeFrameMAD(video, rateCtrl);
-        m_Nc = rateCtrl->NumberofCodedPFrame;
-    }
-    /*basic unit layer rate control*/
-    else
-    {
-        /*compute the MAD of the current basic unit*/
-        rateCtrl->CurrentFrameMAD = rateCtrl->TotalMADBasicUnit / rateCtrl->basicUnit;
-
-
-        rateCtrl->TotalMADBasicUnit = 0;
-
-        /* compute the average number of header bits*/
-
-        CodedBasicUnit = rateCtrl->TotalNumberofBasicUnit - rateCtrl->NumberofBasicUnit;
-        if (CodedBasicUnit > 0)
-        {
-            rateCtrl->PAveHeaderBits1 = (int)(1.0 * (rateCtrl->PAveHeaderBits1 * (CodedBasicUnit - 1) + \
-                                              + rateCtrl->NumberofBasicUnitHeaderBits) / CodedBasicUnit + 0.5);
-            if (rateCtrl->PAveHeaderBits3 == 0)
-                rateCtrl->PAveHeaderBits2 = rateCtrl->PAveHeaderBits1;
-            else
-                rateCtrl->PAveHeaderBits2 = (int)(1.0 * (rateCtrl->PAveHeaderBits1 * CodedBasicUnit + \
-                                                  + rateCtrl->PAveHeaderBits3 * rateCtrl->NumberofBasicUnit) / rateCtrl->TotalNumberofBasicUnit + 0.5);
-        }
-        /*update the record of MADs for reference*/
-        rateCtrl->BUCFMAD[rateCtrl->TotalNumberofBasicUnit-1-rateCtrl->NumberofBasicUnit] = rateCtrl->CurrentFrameMAD;
-
-        if (rateCtrl->NumberofBasicUnit != 0)
-            m_Nc = rateCtrl->NumberofCodedPFrame * rateCtrl->TotalNumberofBasicUnit + CodedBasicUnit;
-        else
-            m_Nc = (rateCtrl->NumberofCodedPFrame - 1) * rateCtrl->TotalNumberofBasicUnit + CodedBasicUnit;
-
-    }
-
-    if (m_Nc > 1)
-        MADModelFlag = TRUE;
-
-    rateCtrl->PPreHeader = rateCtrl->NumberofHeaderBits;
-    for (i = 19; i > 0; i--)
-    {// update the history
-        rateCtrl->m_rgQp[i] = rateCtrl->m_rgQp[i - 1];
-        rateCtrl->m_rgRp[i] = rateCtrl->m_rgRp[i - 1];
-    }
-    rateCtrl->m_rgQp[0] = QP2Qstep(rateCtrl->m_Qc); //*1.0/rateCtrl->CurrentFrameMAD;
-    /*frame layer rate control*/
-    if (rateCtrl->basicUnit == (int)video->PicSizeInMbs)
-        rateCtrl->m_rgRp[0] = rateCtrl->NumberofTextureBits * 1.0 / rateCtrl->CurrentFrameMAD;
-    /*basic unit layer rate control*/
-    else
-        rateCtrl->m_rgRp[0] = rateCtrl->NumberofBasicUnitTextureBits * 1.0 / rateCtrl->CurrentFrameMAD;
-
-
-    /*compute the size of window*/
-    n_windowSize = (rateCtrl->CurrentFrameMAD > rateCtrl->PreviousFrameMAD) ? (int)(rateCtrl->PreviousFrameMAD / rateCtrl->CurrentFrameMAD * 20)\
-                   : (int)(rateCtrl->CurrentFrameMAD / rateCtrl->PreviousFrameMAD * 20);
-    n_windowSize = AVC_MAX(n_windowSize, 1);
-    n_windowSize = AVC_MIN(n_windowSize, m_Nc);
-    n_windowSize = AVC_MIN(n_windowSize, rateCtrl->m_windowSize + 1);
-    n_windowSize = AVC_MIN(n_windowSize, 20);
-
-    /*update the previous window size*/
-    rateCtrl->m_windowSize = n_windowSize;
-
-    for (i = 0; i < 20; i++)
-    {
-        m_rgRejected[i] = FALSE;
-    }
-
-    // initial RD model estimator
-    RCModelEstimator(rateCtrl, n_windowSize, m_rgRejected);
-
-    n_windowSize = rateCtrl->m_windowSize;
-    // remove outlier
-
-    for (i = 0; i < (int) n_windowSize; i++)
-    {
-        error[i] = rateCtrl->m_X1 / rateCtrl->m_rgQp[i] + rateCtrl->m_X2 / (rateCtrl->m_rgQp[i] * rateCtrl->m_rgQp[i]) - rateCtrl->m_rgRp[i];
-        std += error[i] * error[i];
-    }
-    threshold = (n_windowSize == 2) ? 0 : oscl_sqrt(std / n_windowSize);
-    for (i = 0; i < (int) n_windowSize; i++)
-    {
-        if (AVC_ABS(error[i]) > threshold)
-            m_rgRejected[i] = TRUE;
-    }
-    // always include the last data point
-    m_rgRejected[0] = FALSE;
-
-    // second RD model estimator
-    RCModelEstimator(rateCtrl, n_windowSize, m_rgRejected);
-
-    if (MADModelFlag)
-        updateMADModel(video, rateCtrl);
-    else if (video->slice_type == AVC_P_SLICE || rateCtrl->idrPeriod == 1)
-        rateCtrl->PPictureMAD[0] = rateCtrl->CurrentFrameMAD;
-
+    /* for pMP->pRDSamples */
+    pMP->pRDSamples[pMP->framePos][counter_samples].QP    = pMP->QP;
+    pMP->pRDSamples[pMP->framePos][counter_samples].actual_bits = pMP->actual_bits;
+    pMP->pRDSamples[pMP->framePos][counter_samples].mad   = pMP->mad;
+    pMP->pRDSamples[pMP->framePos][counter_samples].R_D = (OsclFloat)pMP->actual_bits / (pMP->mad + 0.0001);
 
     return ;
 }
 
+void updateRateControl(AVCRateControl *rateCtrl, int nal_type)
+{
+    int	 frame_bits;
+    MultiPass *pMP = rateCtrl->pMP;
+
+    /* BX rate contro\l */
+    frame_bits = (int)(rateCtrl->bitRate / rateCtrl->frame_rate);
+    rateCtrl->TMN_W += (rateCtrl->Rc - rateCtrl->TMN_TH);
+    rateCtrl->VBV_fullness += (rateCtrl->Rc - frame_bits); //rateCtrl->Rp);
+    //if(rateCtrl->VBV_fullness < 0) rateCtrl->VBV_fullness = -1;
+
+    rateCtrl->encoded_frames++;
+
+    /* frame dropping */
+    rateCtrl->skip_next_frame = 0;
+
+    if ((rateCtrl->VBV_fullness > rateCtrl->Bs / 2) && nal_type != AVC_NALTYPE_IDR) /* skip the current frame */ /* rateCtrl->Bs */
+    {
+        rateCtrl->TMN_W -= (rateCtrl->Rc - rateCtrl->TMN_TH);
+        rateCtrl->VBV_fullness -= rateCtrl->Rc;
+        rateCtrl->skip_next_frame = -1;
+    }
+    else if ((OsclFloat)(rateCtrl->VBV_fullness - rateCtrl->VBV_fullness_offset) > (rateCtrl->Bs / 2 - rateCtrl->VBV_fullness_offset)*0.95) /* skip next frame */
+    {
+        rateCtrl->VBV_fullness -= frame_bits; //rateCtrl->Rp;
+        rateCtrl->skip_next_frame = 1;
+        pMP->counter_BTsrc -= (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
+        /* BX_1, skip more than 1 frames  */
+        //while(rateCtrl->VBV_fullness > rateCtrl->Bs*0.475)
+        while ((rateCtrl->VBV_fullness - rateCtrl->VBV_fullness_offset) > (rateCtrl->Bs / 2 - rateCtrl->VBV_fullness_offset)*0.95)
+        {
+            rateCtrl->VBV_fullness -= frame_bits; //rateCtrl->Rp;
+            rateCtrl->skip_next_frame++;
+            pMP->counter_BTsrc -= (int)((OsclFloat)(rateCtrl->Bs / 2 - rateCtrl->low_bound) / 2.0 / (pMP->target_bits_per_frame / 10));
+        }
+
+        /* END BX_1 */
+    }
+}
+
+
 double ComputeFrameMAD(AVCCommonObj *video, AVCRateControl *rateCtrl)
 {
     double TotalMAD;
@@ -1133,226 +912,9 @@
     return TotalMAD;
 }
 
-void RCModelEstimator(AVCRateControl *rateCtrl, int n_windowSize, bool *m_rgRejected)
-{
-    int n_realSize = n_windowSize;
-    int i;
-    double oneSampleQ = 0;
-    double a00 = 0.0, a01 = 0.0, a10 = 0.0, a11 = 0.0, b0 = 0.0, b1 = 0.0;
-    double MatrixValue;
-    bool estimateX2 = FALSE;
-    double m_X1, m_X2;
-
-    for (i = 0; i < n_windowSize; i++)
-    {// find the number of samples which are not rejected
-        if (m_rgRejected[i])
-            n_realSize--;
-    }
-
-    // default RD model estimation results
-
-    m_X1 = m_X2 = 0.0;
-
-    for (i = 0; i < n_windowSize; i++)
-    {
-        if (!m_rgRejected[i])
-            oneSampleQ = rateCtrl->m_rgQp[i];
-    }
-    for (i = 0; i < n_windowSize; i++)
-    {// if all non-rejected Q are the same, take 1st order model
-        if ((rateCtrl->m_rgQp[i] != oneSampleQ) && !m_rgRejected[i])
-            estimateX2 = TRUE;
-        if (!m_rgRejected[i])
-            m_X1 += (rateCtrl->m_rgQp[i] * rateCtrl->m_rgRp[i]) / n_realSize;
-    }
-
-    // take 2nd order model to estimate X1 and X2
-    if ((n_realSize >= 1) && estimateX2)
-    {
-        for (i = 0; i < n_windowSize; i++)
-        {
-            if (!m_rgRejected[i])
-            {
-                a00 = a00 + 1.0;
-                a01 += 1.0 / rateCtrl->m_rgQp[i];
-                a10 = a01;
-                a11 += 1.0 / (rateCtrl->m_rgQp[i] * rateCtrl->m_rgQp[i]);
-                b0 += rateCtrl->m_rgQp[i] * rateCtrl->m_rgRp[i];
-                b1 += rateCtrl->m_rgRp[i];
-            }
-        }
-        // solve the equation of AX = B
-        MatrixValue = a00 * a11 - a01 * a10;
-        if (AVC_ABS(MatrixValue) > 0.000001)
-        {
-            m_X1 = (b0 * a11 - b1 * a01) / MatrixValue;
-            m_X2 = (b1 * a00 - b0 * a10) / MatrixValue;
-        }
-        else
-        {
-            m_X1 = b0 / a00;
-            m_X2 = 0.0;
-        }
-    }
-
-    rateCtrl->m_X1 = m_X1;
-    rateCtrl->m_X2 = m_X2;
-}
-
-void updateMADModel(AVCCommonObj *video, AVCRateControl *rateCtrl)
-{
-
-    int n_windowSize;
-    int i;
-    double error[20], std = 0.0, threshold;
-    int m_Nc;
-    double MADPictureC1;
-    double MADPictureC2;
-    bool PictureRejected[21];
-    int	CodedBasicUnit = rateCtrl->TotalNumberofBasicUnit - rateCtrl->NumberofBasicUnit;
-
-    if (rateCtrl->NumberofCodedPFrame > 0)
-    {
-        //assert (img->type!=P_SLICE);
-
-        /*frame layer rate control*/
-        if (rateCtrl->basicUnit == (int)video->PicSizeInMbs)
-            m_Nc = rateCtrl->NumberofCodedPFrame;
-        /*basic unit layer rate control*/
-        else
-            m_Nc = rateCtrl->NumberofCodedPFrame * rateCtrl->TotalNumberofBasicUnit + CodedBasicUnit;
-
-        for (i = 19; i > 0; i--)
-        {// update the history
-            rateCtrl->PPictureMAD[i] = rateCtrl->PPictureMAD[i - 1];
-            rateCtrl->ReferenceMAD[i] = rateCtrl->ReferenceMAD[i-1];
-        }
-        rateCtrl->PPictureMAD[0] = rateCtrl->CurrentFrameMAD;
-
-        if (rateCtrl->basicUnit == (int)video->PicSizeInMbs)
-            rateCtrl->ReferenceMAD[0] = rateCtrl->PPictureMAD[1];
-        else
-        {
-            rateCtrl->ReferenceMAD[0] = rateCtrl->BUPFMAD[rateCtrl->TotalNumberofBasicUnit-1-rateCtrl->NumberofBasicUnit];
-        }
-        MADPictureC1 = rateCtrl->PMADPictureC1;
-        MADPictureC2 = rateCtrl->PMADPictureC2;
 
 
-        /*compute the size of window*/
 
-        n_windowSize = (rateCtrl->CurrentFrameMAD > rateCtrl->PreviousFrameMAD) ? (int)(rateCtrl->PreviousFrameMAD / rateCtrl->CurrentFrameMAD * 20)\
-                       : (int)(rateCtrl->CurrentFrameMAD / rateCtrl->PreviousFrameMAD * 20);
-        n_windowSize = AVC_MIN(n_windowSize, (m_Nc - 1));
-        n_windowSize = AVC_MAX(n_windowSize, 1);
-        n_windowSize = AVC_MIN(n_windowSize, rateCtrl->MADm_windowSize + 1);
-        n_windowSize = AVC_MIN(20, n_windowSize);
-        /*update the previous window size*/
-        rateCtrl->MADm_windowSize = n_windowSize;
-
-        for (i = 0; i < 20; i++)
-        {
-            PictureRejected[i] = FALSE;
-        }
-        //update the MAD for the previous frame
-        if (video->slice_type == AVC_P_SLICE)
-            rateCtrl->PreviousFrameMAD = rateCtrl->CurrentFrameMAD;
-
-        // initial MAD model estimator
-        MADModelEstimator(video, rateCtrl, n_windowSize, &MADPictureC1, &MADPictureC2,
-                          PictureRejected);
-
-        // remove outlier
-
-        for (i = 0; i < (int) n_windowSize; i++)
-        {
-            error[i] = MADPictureC1 * rateCtrl->ReferenceMAD[i] + MADPictureC2 - rateCtrl->PPictureMAD[i];
-            std += error[i] * error[i];
-        }
-        threshold = (n_windowSize == 2) ? 0 : oscl_sqrt(std / n_windowSize);
-        for (i = 0; i < (int) n_windowSize; i++)
-        {
-            if (AVC_ABS(error[i]) > threshold)
-                PictureRejected[i] = TRUE;
-        }
-        // always include the last data point
-        PictureRejected[0] = FALSE;
-
-        // second MAD model estimator
-        MADModelEstimator(video, rateCtrl, n_windowSize, &MADPictureC1, &MADPictureC2,
-                          PictureRejected);
-    }
-}
-
-void MADModelEstimator(AVCCommonObj *video, AVCRateControl *rateCtrl, int n_windowSize,
-                       double *MADPictureC1, double *MADPictureC2, bool *PictureRejected)
-{
-    int n_realSize = n_windowSize;
-    int i;
-    double oneSampleQ = 0;
-    double a00 = 0.0, a01 = 0.0, a10 = 0.0, a11 = 0.0, b0 = 0.0, b1 = 0.0;
-    double MatrixValue;
-    bool estimateX2 = FALSE;
-
-    for (i = 0; i < n_windowSize; i++)
-    {// find the number of samples which are not rejected
-        if (PictureRejected[i])
-            n_realSize--;
-    }
-
-    // default MAD model estimation results
-
-    *MADPictureC1 = *MADPictureC2 = 0.0;
-
-    for (i = 0; i < n_windowSize; i++)
-    {
-        if (!PictureRejected[i])
-            oneSampleQ = rateCtrl->PPictureMAD[i];
-    }
-
-    for (i = 0; i < n_windowSize; i++)
-    {// if all non-rejected MAD are the same, take 1st order model
-        if ((rateCtrl->PPictureMAD[i] != oneSampleQ) && !PictureRejected[i])
-            estimateX2 = TRUE;
-        if (!PictureRejected[i])
-            *MADPictureC1 += rateCtrl->PPictureMAD[i] / (rateCtrl->ReferenceMAD[i] * n_realSize);
-    }
-
-    // take 2nd order model to estimate X1 and X2
-    if ((n_realSize >= 1) && estimateX2)
-    {
-        for (i = 0; i < n_windowSize; i++)
-        {
-            if (!PictureRejected[i])
-            {
-                a00 = a00 + 1.0;
-                a01 += rateCtrl->ReferenceMAD[i];
-                a10 = a01;
-                a11 += rateCtrl->ReferenceMAD[i] * rateCtrl->ReferenceMAD[i];
-                b0 += rateCtrl->PPictureMAD[i];
-                b1 += rateCtrl->PPictureMAD[i] * rateCtrl->ReferenceMAD[i];
-            }
-        }
-        // solve the equation of AX = B
-        MatrixValue = a00 * a11 - a01 * a10;
-        if (AVC_ABS(MatrixValue) > 0.000001)
-        {
-            *MADPictureC2 = (b0 * a11 - b1 * a01) / MatrixValue;
-            *MADPictureC1 = (b1 * a00 - b0 * a10) / MatrixValue;
-        }
-        else
-        {
-            *MADPictureC1 = b0 / a01;
-            *MADPictureC2 = 0.0;
-        }
-
-    }
-    if (video->slice_type == AVC_P_SLICE)
-    {
-        rateCtrl->PMADPictureC1 = *MADPictureC1;
-        rateCtrl->PMADPictureC2 = *MADPictureC2;
-    }
-}
 
 /* convert from QP to Qstep */
 double QP2Qstep(int QP)
diff --git a/codecs_v2/video/avc_h264/enc/src/residual.cpp b/codecs_v2/video/avc_h264/enc/src/residual.cpp
index ee8cc51..c223105 100644
--- a/codecs_v2/video/avc_h264/enc/src/residual.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/residual.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/sad.cpp b/codecs_v2/video/avc_h264/enc/src/sad.cpp
index f2d6d18..f575ef5 100644
--- a/codecs_v2/video/avc_h264/enc/src/sad.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/sad.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/sad_halfpel.cpp b/codecs_v2/video/avc_h264/enc/src/sad_halfpel.cpp
index 14995ae..b626f96 100644
--- a/codecs_v2/video/avc_h264/enc/src/sad_halfpel.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/sad_halfpel.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/sad_halfpel_inline.h b/codecs_v2/video/avc_h264/enc/src/sad_halfpel_inline.h
index b90e66d..7d6ee9d 100644
--- a/codecs_v2/video/avc_h264/enc/src/sad_halfpel_inline.h
+++ b/codecs_v2/video/avc_h264/enc/src/sad_halfpel_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/sad_inline.h b/codecs_v2/video/avc_h264/enc/src/sad_inline.h
index e9afa39..e44b5d9 100644
--- a/codecs_v2/video/avc_h264/enc/src/sad_inline.h
+++ b/codecs_v2/video/avc_h264/enc/src/sad_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/sad_mb_offset.h b/codecs_v2/video/avc_h264/enc/src/sad_mb_offset.h
index 5fd977c..8b922e8 100644
--- a/codecs_v2/video/avc_h264/enc/src/sad_mb_offset.h
+++ b/codecs_v2/video/avc_h264/enc/src/sad_mb_offset.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/avc_h264/enc/src/slice.cpp b/codecs_v2/video/avc_h264/enc/src/slice.cpp
index fca43c1..ca67084 100644
--- a/codecs_v2/video/avc_h264/enc/src/slice.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/slice.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -217,7 +217,8 @@
     /****** for intra prediction, pred is already done *******/
     /****** for I4, the recon is ready and Xfrm coefs are ready to be encoded *****/
 
-    RCCalculateMAD(encvid, currMB, orgL, orgPitch);
+    //RCCalculateMAD(encvid,currMB,orgL,orgPitch); // no need to re-calculate MAD for Intra
+    // not used since totalSAD is used instead
 
     /* compute the prediction */
     /* output is video->pred_block */
@@ -243,7 +244,7 @@
                 currMB->nz_coeff[blkidx] = numcoeff;
                 if (numcoeff)
                 {
-                    video->cbp4x4 |= (1 << blkidx); //not needed??
+                    video->cbp4x4 |= (1 << blkidx);
                     currMB->CBP |= (1 << b8);
                 }
 
@@ -303,6 +304,8 @@
     }
     else	/* Intra prediction */
     {
+        encvid->numIntraMB++;
+
         if (currMB->mbMode == AVC_I16) /* do prediction for the whole macroblock */
         {
             currMB->CBP = 0;
@@ -340,7 +343,7 @@
 
                 if (!video->mbAvailA || !video->mbAvailB)
                 {
-                    if (currMB->mvL0[0] == 0 && currMB->mvL0[1] == 0) /* both mv components are zeros.*/
+                    if (currMB->mvL0[0] == 0) /* both mv components are zeros.*/
                     {
                         currMB->mbMode = AVC_SKIP;
                         video->mvd_l0[0][0][0] = 0;
@@ -349,10 +352,10 @@
                 }
                 else
                 {
-                    if ((MB_A->ref_idx_L0[1] == 0 && MB_A->mvL0[6] == 0 &&  MB_A->mvL0[7] == 0) ||
-                            (MB_B->ref_idx_L0[2] == 0 && MB_B->mvL0[24] == 0 &&  MB_B->mvL0[25] == 0))
+                    if ((MB_A->ref_idx_L0[1] == 0 && MB_A->mvL0[3] == 0) ||
+                            (MB_B->ref_idx_L0[2] == 0 && MB_B->mvL0[12] == 0))
                     {
-                        if (currMB->mvL0[0] == 0 && currMB->mvL0[1] == 0) /* both mv components are zeros.*/
+                        if (currMB->mvL0[0] == 0) /* both mv components are zeros.*/
                         {
                             currMB->mbMode = AVC_SKIP;
                             video->mvd_l0[0][0][0] = 0;
@@ -496,17 +499,8 @@
 
     num_bits = 32 + (encvid->bitstream->write_pos << 3) - encvid->bitstream->bit_left;
 
-    rateCtrl->numMBHeaderBits = start_text_bits - start_mb_bits;
-    rateCtrl->numMBTextureBits = num_bits - start_text_bits;
-    rateCtrl->NumberofHeaderBits += rateCtrl->numMBHeaderBits;
-    rateCtrl->NumberofTextureBits += rateCtrl->numMBTextureBits;
-    if (rateCtrl->basicUnit < (int)video->PicSizeInMbs)
-    {
-        rateCtrl->NumberofBasicUnitHeaderBits += rateCtrl->numMBHeaderBits;
-        rateCtrl->NumberofBasicUnitTextureBits += rateCtrl->numMBTextureBits;
-    }
-    rateCtrl->NumberofCodedMacroBlocks++;
-
+    RCPostMB(video, rateCtrl, start_text_bits - start_mb_bits,
+             num_bits - start_text_bits);
 
 //	num_bits -= start_mb_bits;
 //	fprintf(fdebug,"MB #%d: %d bits\n",CurrMbAddr,num_bits);
diff --git a/codecs_v2/video/avc_h264/enc/src/vlc_encode.cpp b/codecs_v2/video/avc_h264/enc/src/vlc_encode.cpp
index 697ba08..222e709 100644
--- a/codecs_v2/video/avc_h264/enc/src/vlc_encode.cpp
+++ b/codecs_v2/video/avc_h264/enc/src/vlc_encode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/Android.mk b/codecs_v2/video/m4v_h263/dec/Android.mk
index 94f3b76..91d9241 100644
--- a/codecs_v2/video/m4v_h263/dec/Android.mk
+++ b/codecs_v2/video/m4v_h263/dec/Android.mk
@@ -3,60 +3,62 @@
 
 LOCAL_SRC_FILES := \
 	src/adaptive_smooth_no_mmx.cpp \
-	src/bitstream.cpp \
-	src/block_idct.cpp \
-	src/cal_dc_scaler.cpp \
-	src/chvr_filter.cpp \
-	src/chv_filter.cpp \
-	src/combined_decode.cpp \
-	src/conceal.cpp \
-	src/datapart_decode.cpp \
-	src/dcac_prediction.cpp \
-	src/dec_pred_intra_dc.cpp \
-	src/deringing_chroma.cpp \
-	src/deringing_luma.cpp \
-	src/find_min_max.cpp \
-	src/get_pred_adv_b_add.cpp \
-	src/get_pred_outside.cpp \
-	src/idct.cpp \
-	src/idct_vca.cpp \
-	src/mb_motion_comp.cpp \
-	src/mb_utils.cpp \
-	src/pvm4vdecoder.cpp \
-	src/pvm4vdecoder_factory.cpp \
-	src/packet_util.cpp \
-	src/post_filter.cpp \
-	src/post_proc_semaphore.cpp \
-	src/pp_semaphore_chroma_inter.cpp \
-	src/pp_semaphore_luma.cpp \
-	src/pvdec_api.cpp \
-	src/scaling_tab.cpp \
-	src/vlc_decode.cpp \
-	src/vlc_dequant.cpp \
-	src/vlc_tab.cpp \
-	src/vop.cpp \
-	src/zigzag_tab.cpp
-
+ 	src/bitstream.cpp \
+ 	src/block_idct.cpp \
+ 	src/cal_dc_scaler.cpp \
+ 	src/chvr_filter.cpp \
+ 	src/chv_filter.cpp \
+ 	src/combined_decode.cpp \
+ 	src/conceal.cpp \
+ 	src/datapart_decode.cpp \
+ 	src/dcac_prediction.cpp \
+ 	src/dec_pred_intra_dc.cpp \
+ 	src/deringing_chroma.cpp \
+ 	src/deringing_luma.cpp \
+ 	src/find_min_max.cpp \
+ 	src/get_pred_adv_b_add.cpp \
+ 	src/get_pred_outside.cpp \
+ 	src/idct.cpp \
+ 	src/idct_vca.cpp \
+ 	src/mb_motion_comp.cpp \
+ 	src/mb_utils.cpp \
+ 	src/pvm4vdecoder.cpp \
+ 	src/pvm4vdecoder_factory.cpp \
+ 	src/packet_util.cpp \
+ 	src/post_filter.cpp \
+ 	src/post_proc_semaphore.cpp \
+ 	src/pp_semaphore_chroma_inter.cpp \
+ 	src/pp_semaphore_luma.cpp \
+ 	src/pvdec_api.cpp \
+ 	src/scaling_tab.cpp \
+ 	src/vlc_decode.cpp \
+ 	src/vlc_dequant.cpp \
+ 	src/vlc_tab.cpp \
+ 	src/vop.cpp \
+ 	src/zigzag_tab.cpp
 
 
 LOCAL_MODULE := libpvmp4decoder
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/video/m4v_h263/dec/include \
-	$(PV_TOP)//codecs_v2/video/m4v_h263/dec/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/video/m4v_h263/dec/src \
+ 	$(PV_TOP)/codecs_v2/video/m4v_h263/dec/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvm4vdecoder.h \
-	include/pvm4vdecoder_factory.h \
-	include/pvvideodecoderinterface.h \
-	include/visual_header.h
+ 	include/pvm4vdecoder_factory.h \
+ 	include/pvvideodecoderinterface.h \
+ 	include/visual_header.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/video/m4v_h263/dec/build/make/local.mk b/codecs_v2/video/m4v_h263/dec/build/make/local.mk
new file mode 100644
index 0000000..e21876f
--- /dev/null
+++ b/codecs_v2/video/m4v_h263/dec/build/make/local.mk
@@ -0,0 +1,57 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4decoder
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := adaptive_smooth_no_mmx.cpp \
+	bitstream.cpp \
+	block_idct.cpp \
+	cal_dc_scaler.cpp \
+	chvr_filter.cpp \
+	chv_filter.cpp \
+	combined_decode.cpp \
+	conceal.cpp \
+	datapart_decode.cpp \
+	dcac_prediction.cpp \
+	dec_pred_intra_dc.cpp \
+	deringing_chroma.cpp \
+	deringing_luma.cpp \
+	find_min_max.cpp \
+	get_pred_adv_b_add.cpp \
+	get_pred_outside.cpp \
+	idct.cpp \
+	idct_vca.cpp \
+	mb_motion_comp.cpp \
+	mb_utils.cpp \
+	pvm4vdecoder.cpp \
+	pvm4vdecoder_factory.cpp \
+	packet_util.cpp \
+	post_filter.cpp \
+	post_proc_semaphore.cpp \
+	pp_semaphore_chroma_inter.cpp \
+	pp_semaphore_luma.cpp \
+	pvdec_api.cpp \
+	scaling_tab.cpp \
+	vlc_decode.cpp \
+	vlc_dequant.cpp \
+	vlc_tab.cpp \
+	vop.cpp \
+	zigzag_tab.cpp
+
+HDRS := pvm4vdecoder.h \
+	pvm4vdecoder_factory.h \
+	pvvideodecoderinterface.h \
+	visual_header.h
+
+
+include $(MK)/library.mk
diff --git a/codecs_v2/video/m4v_h263/dec/build/make/makefile b/codecs_v2/video/m4v_h263/dec/build/make/makefile
deleted file mode 100644
index f50464b..0000000
--- a/codecs_v2/video/m4v_h263/dec/build/make/makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4decoder
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  adaptive_smooth_no_mmx.cpp \
-	bitstream.cpp \
-	block_idct.cpp \
-	cal_dc_scaler.cpp \
-	chvr_filter.cpp \
-	chv_filter.cpp \
-	combined_decode.cpp \
-	conceal.cpp \
-	datapart_decode.cpp \
-	dcac_prediction.cpp \
-	dec_pred_intra_dc.cpp \
-	deringing_chroma.cpp \
-	deringing_luma.cpp \
-	find_min_max.cpp \
-	get_pred_adv_b_add.cpp \
-	get_pred_outside.cpp \
-	idct.cpp \
-	idct_vca.cpp \
-	mb_motion_comp.cpp \
-	mb_utils.cpp \
-	pvm4vdecoder.cpp \
-	pvm4vdecoder_factory.cpp \
-	packet_util.cpp \
-	post_filter.cpp \
-	post_proc_semaphore.cpp \
-	pp_semaphore_chroma_inter.cpp \
-	pp_semaphore_luma.cpp \
-	pvdec_api.cpp \
-	scaling_tab.cpp \
-	vlc_decode.cpp \
-	vlc_dequant.cpp \
-	vlc_tab.cpp \
-	vop.cpp \
-	zigzag_tab.cpp
-
-HDRS =  pvm4vdecoder.h \
-	pvm4vdecoder_factory.h \
-	pvvideodecoderinterface.h \
-	visual_header.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/codecs_v2/video/m4v_h263/dec/include/mp4dec_api.h b/codecs_v2/video/m4v_h263/dec/include/mp4dec_api.h
index c086622..d5ab593 100644
--- a/codecs_v2/video/m4v_h263/dec/include/mp4dec_api.h
+++ b/codecs_v2/video/m4v_h263/dec/include/mp4dec_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,10 @@
 #ifndef _MP4DEC_API_H_
 #define _MP4DEC_API_H_
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #ifndef OSCL_TYPES_H_INCLUDED
 #include "oscl_types.h"
 #endif
@@ -78,20 +82,18 @@
 typedef struct tagvideoDecControls
 {
     /* The following fucntion pointer is copied to BitstreamDecVideo structure	*/
-    /*    upon initialization and never used again.  This extra copy is just	*/
-    /*    used to keep outside users of our SDK from snooping into our code.	*/
-    /*    CJ 04/11/2000.														*/
+    /*    upon initialization and never used again.	*/
     int (*readBitstreamData)(uint8 *buf, int nbytes_required, void *appData);
     applicationData appData;
 
     uint8 *outputFrame;
     void *videoDecoderData;		/* this is an internal pointer that is only used */
-    /* in the decoder library.   CJ 04/11/2000       */
+    /* in the decoder library.   */
 #ifdef PV_MEMORY_POOL
     int32 size;
 #endif
     int nLayers;
-    /* pointers to VOL data for frame-based decoding.  CJ 08/30/2000 */
+    /* pointers to VOL data for frame-based decoding. */
     uint8 *volbuf[2];			/* maximum of 2 layers for now */
     int32 volbuf_size[2];
 
@@ -151,26 +153,26 @@
 #endif
 
 
-    Bool	PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[], int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode);
+    OSCL_IMPORT_REF Bool	PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[], int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode);
     Bool	PVAllocVideoData(VideoDecControls *decCtrl, int width, int height, int nLayers);
-    Bool	PVCleanUpVideoDecoder(VideoDecControls *decCtrl);
+    OSCL_IMPORT_REF Bool	PVCleanUpVideoDecoder(VideoDecControls *decCtrl);
     Bool	PVResetVideoDecoder(VideoDecControls *decCtrl);
-    void	PVSetReferenceYUV(VideoDecControls *decCtrl, uint8 *refYUV);
+    OSCL_IMPORT_REF void	PVSetReferenceYUV(VideoDecControls *decCtrl, uint8 *refYUV);
     Bool	PVDecSetReference(VideoDecControls *decCtrl, uint8 *refYUV, uint32 timestamp);
     Bool	PVDecSetEnhReference(VideoDecControls *decCtrl, uint8 *refYUV, uint32 timestamp);
-    Bool	PVDecodeVideoFrame(VideoDecControls *decCtrl, uint8 *bitstream[], uint32 *timestamp, int32 *buffer_size, uint use_ext_timestamp[], uint8* currYUV);
+    OSCL_IMPORT_REF Bool	PVDecodeVideoFrame(VideoDecControls *decCtrl, uint8 *bitstream[], uint32 *timestamp, int32 *buffer_size, uint use_ext_timestamp[], uint8* currYUV);
     Bool	PVDecodeVopHeader(VideoDecControls *decCtrl, uint8 *buffer[], uint32 timestamp[], int32 buffer_size[], VopHeaderInfo *header_info, uint use_ext_timestamp[], uint8 *currYUV);
     Bool	PVDecodeVopBody(VideoDecControls *decCtrl, int32 buffer_size[]);
     void	PVDecPostProcess(VideoDecControls *decCtrl, uint8 *outputYUV);
-    void	PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height);
-    void	PVSetPostProcType(VideoDecControls *decCtrl, int mode);
+    OSCL_IMPORT_REF void	PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height);
+    OSCL_IMPORT_REF void	PVSetPostProcType(VideoDecControls *decCtrl, int mode);
     uint32	PVGetVideoTimeStamp(VideoDecControls *decoderControl);
     int		PVGetDecBitrate(VideoDecControls *decCtrl);
     int		PVGetDecFramerate(VideoDecControls *decCtrl);
     uint8	*PVGetDecOutputFrame(VideoDecControls *decCtrl);
     int		PVGetLayerID(VideoDecControls *decCtrl);
     int32	PVGetDecMemoryUsage(VideoDecControls *decCtrl);
-    MP4DecodingMode PVGetDecBitstreamMode(VideoDecControls *decCtrl);
+    OSCL_IMPORT_REF MP4DecodingMode PVGetDecBitstreamMode(VideoDecControls *decCtrl);
     Bool	PVExtractVolHeader(uint8 *video_buffer, uint8 *vol_header, int32 *vol_header_size);
     int32	PVLocateFrameHeader(uint8 *video_buffer, int32 vop_size);
     int32	PVLocateH263FrameHeader(uint8 *video_buffer, int32 vop_size);
diff --git a/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder.h b/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder.h
index bad05cc..76bd596 100644
--- a/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder.h
+++ b/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_dpi.h b/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_dpi.h
index b6da5fa..8d18973 100644
--- a/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_dpi.h
+++ b/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_dpi.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_factory.h b/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_factory.h
index 4602750..3076f5a 100644
--- a/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_factory.h
+++ b/codecs_v2/video/m4v_h263/dec/include/pvm4vdecoder_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/include/pvvideodecoderinterface.h b/codecs_v2/video/m4v_h263/dec/include/pvvideodecoderinterface.h
index 2b0cd30..72239e3 100644
--- a/codecs_v2/video/m4v_h263/dec/include/pvvideodecoderinterface.h
+++ b/codecs_v2/video/m4v_h263/dec/include/pvvideodecoderinterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/include/visual_header.h b/codecs_v2/video/m4v_h263/dec/include/visual_header.h
index 54a5e68..4d9ebcb 100644
--- a/codecs_v2/video/m4v_h263/dec/include/visual_header.h
+++ b/codecs_v2/video/m4v_h263/dec/include/visual_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp b/codecs_v2/video/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp
index a54043d..366ea76 100644
--- a/codecs_v2/video/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/adaptive_smooth_no_mmx.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/bitstream.cpp b/codecs_v2/video/m4v_h263/dec/src/bitstream.cpp
index 4079af3..e337963 100644
--- a/codecs_v2/video/m4v_h263/dec/src/bitstream.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/bitstream.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/bitstream.h b/codecs_v2/video/m4v_h263/dec/src/bitstream.h
index f32652c..dea8b40 100644
--- a/codecs_v2/video/m4v_h263/dec/src/bitstream.h
+++ b/codecs_v2/video/m4v_h263/dec/src/bitstream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/block_idct.cpp b/codecs_v2/video/m4v_h263/dec/src/block_idct.cpp
index d92aa7c..ee959dc 100644
--- a/codecs_v2/video/m4v_h263/dec/src/block_idct.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/block_idct.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/cal_dc_scaler.cpp b/codecs_v2/video/m4v_h263/dec/src/cal_dc_scaler.cpp
index f850131..4fc17ae 100644
--- a/codecs_v2/video/m4v_h263/dec/src/cal_dc_scaler.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/cal_dc_scaler.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/chv_filter.cpp b/codecs_v2/video/m4v_h263/dec/src/chv_filter.cpp
index 5d23697..c15e8b9 100644
--- a/codecs_v2/video/m4v_h263/dec/src/chv_filter.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/chv_filter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/chvr_filter.cpp b/codecs_v2/video/m4v_h263/dec/src/chvr_filter.cpp
index 83c98e0..1c22555 100644
--- a/codecs_v2/video/m4v_h263/dec/src/chvr_filter.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/chvr_filter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/combined_decode.cpp b/codecs_v2/video/m4v_h263/dec/src/combined_decode.cpp
index f0359ac..e23f5be 100644
--- a/codecs_v2/video/m4v_h263/dec/src/combined_decode.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/combined_decode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/conceal.cpp b/codecs_v2/video/m4v_h263/dec/src/conceal.cpp
index bb112a4..9944595 100644
--- a/codecs_v2/video/m4v_h263/dec/src/conceal.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/conceal.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/datapart_decode.cpp b/codecs_v2/video/m4v_h263/dec/src/datapart_decode.cpp
index 718c9ca..23614f1 100644
--- a/codecs_v2/video/m4v_h263/dec/src/datapart_decode.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/datapart_decode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/dcac_prediction.cpp b/codecs_v2/video/m4v_h263/dec/src/dcac_prediction.cpp
index 5381a2f..80069d7 100644
--- a/codecs_v2/video/m4v_h263/dec/src/dcac_prediction.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/dcac_prediction.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/dec_pred_intra_dc.cpp b/codecs_v2/video/m4v_h263/dec/src/dec_pred_intra_dc.cpp
index 337b3e1..c19c23a 100644
--- a/codecs_v2/video/m4v_h263/dec/src/dec_pred_intra_dc.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/dec_pred_intra_dc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/deringing_chroma.cpp b/codecs_v2/video/m4v_h263/dec/src/deringing_chroma.cpp
index 253a475..6bfb652 100644
--- a/codecs_v2/video/m4v_h263/dec/src/deringing_chroma.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/deringing_chroma.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/deringing_luma.cpp b/codecs_v2/video/m4v_h263/dec/src/deringing_luma.cpp
index 6f8fbd4..87f55fa 100644
--- a/codecs_v2/video/m4v_h263/dec/src/deringing_luma.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/deringing_luma.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/find_min_max.cpp b/codecs_v2/video/m4v_h263/dec/src/find_min_max.cpp
index 1aaac04..157a90b 100644
--- a/codecs_v2/video/m4v_h263/dec/src/find_min_max.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/find_min_max.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/get_pred_adv_b_add.cpp b/codecs_v2/video/m4v_h263/dec/src/get_pred_adv_b_add.cpp
index 6c08674..7fa4c59 100644
--- a/codecs_v2/video/m4v_h263/dec/src/get_pred_adv_b_add.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/get_pred_adv_b_add.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/get_pred_outside.cpp b/codecs_v2/video/m4v_h263/dec/src/get_pred_outside.cpp
index 1cd6f02..ba04213 100644
--- a/codecs_v2/video/m4v_h263/dec/src/get_pred_outside.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/get_pred_outside.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/idct.cpp b/codecs_v2/video/m4v_h263/dec/src/idct.cpp
index b4b8658..e334b3b 100644
--- a/codecs_v2/video/m4v_h263/dec/src/idct.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/idct.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@
 ------------------------------------------------------------------------------
  MODULE DESCRIPTION
 
- This file contains the functions that transform an 8x8 image block from
- dequantized DCT coefficients to spatial domain pixel values by calculating
+ This file contains the functions that transform an 8r8 image block from
+ dequantized DCT coefficients to spatial domain pirel values by calculating
  inverse discrete cosine transform (IDCT).
 
 ------------------------------------------------------------------------------
@@ -41,7 +41,7 @@
 
  Inputs:
  	blk = pointer to the buffer containing the dequantized DCT
-	      coefficients of type int for an 8x8 image block;
+	      coefficients of type int for an 8r8 image block;
 	      values range from (-2048, 2047) which defined as standard.
 
  Local Stores/Buffers/Pointers Needed:
@@ -54,7 +54,7 @@
 	None
 
  Pointers and Buffers Modified:
-	blk points to the found IDCT values for an 8x8 image block.
+	blk points to the found IDCT values for an 8r8 image block.
 
  Local Stores Modified:
 	None
@@ -65,12 +65,12 @@
 ------------------------------------------------------------------------------
  FUNCTION DESCRIPTION FOR idct
 
- This function transforms an 8x8 image block from dequantized DCT coefficients
- (F(u,v)) to spatial domain pixel values (f(x,y)) by performing the two
+ This function transforms an 8r8 image block from dequantized DCT coefficients
+ (F(u,v)) to spatial domain pirel values (f(r,y)) by performing the two
  dimensional inverse discrete cosine transform (IDCT).
 
 		 _7_ _7_      C(u) C(v)
-	f(x,y) = \   \	F(u,v)---- ----cos[(2x+1)*u*pi/16]cos[(2y+1)*v*pi/16]
+	f(r,y) = \   \	F(u,v)---- ----cos[(2r+1)*u*pi/16]cos[(2y+1)*v*pi/16]
 		 /__ /__	2    2
 		 u=0 v=0
 
@@ -79,11 +79,11 @@
 
  2-D IDCT can be separated as horizontal(row-wise) and vertical(column-wise)
  1-D IDCTs. Therefore, 2-D IDCT values are found by the following two steps:
- 1. Find horizontal 1-D IDCT values for each row from 8x8 dequantized DCT
+ 1. Find horizontal 1-D IDCT values for each row from 8r8 dequantized DCT
     coefficients by row IDCT operation.
 
  		  _7_        C(u)
-	g(x,v) =  \   F(u,v) ---- cos[(2x+1)*u*pi/16]
+	g(r,v) =  \   F(u,v) ---- cos[(2r+1)*u*pi/16]
 		  /__ 	      2
 		  u=0
 
@@ -91,7 +91,7 @@
     by column IDCT operation.
 
     		  _7_ 	     C(v)
-	f(x,y) =  \   g(x,v) ---- cos[(2y+1)*v*pi/16]
+	f(r,y) =  \   g(r,v) ---- cos[(2y+1)*v*pi/16]
 		  /__ 	      2
 		  v=0
 
@@ -110,7 +110,7 @@
  11 mults, 29 adds per DCT
  sE, 18.8.91
 
- coefficients extended to 12 bit for IEEE1180-1990
+ coefficients ertended to 12 bit for IEEE1180-1990
  compliance                           sE,  2.1.94
 */
 
@@ -128,7 +128,7 @@
     int	i;
     int32	tmpBLK[64];
     int32	*tmpBLK32 = &tmpBLK[0];
-    int32	x0, x1, x2, x3, x4, x5, x6, x7, x8;	/* butterfly nodes */
+    int32	r0, r1, r2, r3, r4, r5, r6, r7, r8;	/* butterfly nodes */
     int32	a;
     int offset = width - 8;
     /*----------------------------------------------------------------------------
@@ -142,23 +142,23 @@
     {
         /* initialize butterfly nodes at first stage */
 
-        x1 = blk[B_SIZE * 4 + i] << 11;
+        r1 = blk[B_SIZE * 4 + i] << 11;
         /* since row IDCT results have net left shift by 3 */
         /* this left shift by 8 gives net left shift by 11 */
         /* in order to maintain the same scale as that of  */
         /* coefficients Wi */
 
-        x2 = blk[B_SIZE * 6 + i];
-        x3 = blk[B_SIZE * 2 + i];
-        x4 = blk[B_SIZE * 1 + i];
-        x5 = blk[B_SIZE * 7 + i];
-        x6 = blk[B_SIZE * 5 + i];
-        x7 = blk[B_SIZE * 3 + i];
+        r2 = blk[B_SIZE * 6 + i];
+        r3 = blk[B_SIZE * 2 + i];
+        r4 = blk[B_SIZE * 1 + i];
+        r5 = blk[B_SIZE * 7 + i];
+        r6 = blk[B_SIZE * 5 + i];
+        r7 = blk[B_SIZE * 3 + i];
 
-        if (!(x1 | x2 | x3 | x4 | x5 | x6 | x7))
+        if (!(r1 | r2 | r3 | r4 | r5 | r6 | r7))
         {
             /* shortcut */
-            /* execute if values of g(x,1) to g(x,7) in a column*/
+            /* execute if values of g(r,1) to g(r,7) in a column*/
             /* are all zeros */
 
             /* make output of IDCT >>3 or scaled by 1/8 and */
@@ -175,39 +175,39 @@
         }
         else
         {
-            x0 = (blk[8 * 0 + i] << 11) + 128;
+            r0 = (blk[8 * 0 + i] << 11) + 128;
 
             /* first stage */
 
-            x8 = W7 * (x4 + x5);
-            x4 = (x8 + (W1 - W7) * x4);
+            r8 = W7 * (r4 + r5);
+            r4 = (r8 + (W1 - W7) * r4);
             /* Multiplication with Wi increases the net left */
             /* shift from 11 to 14,we have to shift back by 3*/
-            x5 = (x8 - (W1 + W7) * x5);
-            x8 = W3 * (x6 + x7);
-            x6 = (x8 - (W3 - W5) * x6);
-            x7 = (x8 - (W3 + W5) * x7);
+            r5 = (r8 - (W1 + W7) * r5);
+            r8 = W3 * (r6 + r7);
+            r6 = (r8 - (W3 - W5) * r6);
+            r7 = (r8 - (W3 + W5) * r7);
 
             /* second stage */
-            x8 = x0 + x1;
-            x0 -= x1;
+            r8 = r0 + r1;
+            r0 -= r1;
 
-            x1 = W6 * (x3 + x2);
-            x2 = (x1 - (W2 + W6) * x2);
-            x3 = (x1 + (W2 - W6) * x3);
+            r1 = W6 * (r3 + r2);
+            r2 = (r1 - (W2 + W6) * r2);
+            r3 = (r1 + (W2 - W6) * r3);
 
-            x1 = x4 + x6;
-            x4 -= x6;
-            x6 = x5 + x7;
-            x5 -= x7;
+            r1 = r4 + r6;
+            r4 -= r6;
+            r6 = r5 + r7;
+            r5 -= r7;
 
             /* third stage */
-            x7 = x8 + x3;
-            x8 -= x3;
-            x3 = x0 + x2;
-            x0 -= x2;
-            x2 = (181 * (x4 + x5) + 128) >> 8;	/* rounding */
-            x4 = (181 * (x4 - x5) + 128) >> 8;
+            r7 = r8 + r3;
+            r8 -= r3;
+            r3 = r0 + r2;
+            r0 -= r2;
+            r2 = (181 * (r4 + r5) + 128) >> 8;	/* rounding */
+            r4 = (181 * (r4 - r5) + 128) >> 8;
 
             /* fourth stage */
             /* net shift of IDCT is >>3 after the following	*/
@@ -215,14 +215,14 @@
             /* scaled by 1/8, that is scaled twice by       */
             /* 1/(2*sqrt(2)) for row IDCT and column IDCT.  */
             /* see detail analysis in design doc.	        */
-            tmpBLK32[0 + i] = (x7 + x1) >> 8;
-            tmpBLK32[(1<<3) + i] = (x3 + x2) >> 8;
-            tmpBLK32[(2<<3) + i] = (x0 + x4) >> 8;
-            tmpBLK32[(3<<3) + i] = (x8 + x6) >> 8;
-            tmpBLK32[(4<<3) + i] = (x8 - x6) >> 8;
-            tmpBLK32[(5<<3) + i] = (x0 - x4) >> 8;
-            tmpBLK32[(6<<3) + i] = (x3 - x2) >> 8;
-            tmpBLK32[(7<<3) + i] = (x7 - x1) >> 8;
+            tmpBLK32[0 + i] = (r7 + r1) >> 8;
+            tmpBLK32[(1<<3) + i] = (r3 + r2) >> 8;
+            tmpBLK32[(2<<3) + i] = (r0 + r4) >> 8;
+            tmpBLK32[(3<<3) + i] = (r8 + r6) >> 8;
+            tmpBLK32[(4<<3) + i] = (r8 - r6) >> 8;
+            tmpBLK32[(5<<3) + i] = (r0 - r4) >> 8;
+            tmpBLK32[(6<<3) + i] = (r3 - r2) >> 8;
+            tmpBLK32[(7<<3) + i] = (r7 - r1) >> 8;
         }
     }
     /* row (horizontal) IDCT */
@@ -230,20 +230,20 @@
     {
         /* initialize butterfly nodes at the first stage */
 
-        x1 = ((int32)tmpBLK32[4+(i<<3)]) << 8;
-        /* x1 left shift by 11 is to maintain the same	*/
+        r1 = ((int32)tmpBLK32[4+(i<<3)]) << 8;
+        /* r1 left shift by 11 is to maintain the same	*/
         /* scale as that of coefficients (W1,...W7)	*/
         /* since blk[4] won't multiply with Wi.		*/
         /* see detail diagram in design document.	*/
 
-        x2 = tmpBLK32[6+(i<<3)];
-        x3 = tmpBLK32[2+(i<<3)];
-        x4 = tmpBLK32[1+(i<<3)];
-        x5 = tmpBLK32[7+(i<<3)];
-        x6 = tmpBLK32[5+(i<<3)];
-        x7 = tmpBLK32[3+(i<<3)];
+        r2 = tmpBLK32[6+(i<<3)];
+        r3 = tmpBLK32[2+(i<<3)];
+        r4 = tmpBLK32[1+(i<<3)];
+        r5 = tmpBLK32[7+(i<<3)];
+        r6 = tmpBLK32[5+(i<<3)];
+        r7 = tmpBLK32[3+(i<<3)];
 
-        if (!(x1 | x2 | x3 | x4 | x5 | x6 | x7))
+        if (!(r1 | r2 | r3 | r4 | r5 | r6 | r7))
         {
             /* shortcut */
             /* execute if values of F(1,v) to F(7,v) in a row*/
@@ -267,65 +267,65 @@
         else
         {
             /* for proper rounding in the fourth stage */
-            x0 = (((int32)tmpBLK32[0+(i<<3)]) << 8) + 8192;
+            r0 = (((int32)tmpBLK32[0+(i<<3)]) << 8) + 8192;
 
             /* first stage */
 
-            x8 = W7 * (x4 + x5) + 4;
-            x4 = (x8 + (W1 - W7) * x4) >> 3;
-            x5 = (x8 - (W1 + W7) * x5) >> 3;
+            r8 = W7 * (r4 + r5) + 4;
+            r4 = (r8 + (W1 - W7) * r4) >> 3;
+            r5 = (r8 - (W1 + W7) * r5) >> 3;
 
-            x8 = W3 * (x6 + x7) + 4;
-            x6 = (x8 - (W3 - W5) * x6) >> 3;
-            x7 = (x8 - (W3 + W5) * x7) >> 3;
+            r8 = W3 * (r6 + r7) + 4;
+            r6 = (r8 - (W3 - W5) * r6) >> 3;
+            r7 = (r8 - (W3 + W5) * r7) >> 3;
 
             /* second stage */
-            x8 = x0 + x1;
-            x0 -= x1;
+            r8 = r0 + r1;
+            r0 -= r1;
 
-            x1 = W6 * (x3 + x2) + 4;
-            x2 = (x1 - (W2 + W6) * x2) >> 3;
-            x3 = (x1 + (W2 - W6) * x3) >> 3;
+            r1 = W6 * (r3 + r2) + 4;
+            r2 = (r1 - (W2 + W6) * r2) >> 3;
+            r3 = (r1 + (W2 - W6) * r3) >> 3;
 
-            x1 = x4 + x6;
-            x4 -= x6;
-            x6 = x5 + x7;
-            x5 -= x7;
+            r1 = r4 + r6;
+            r4 -= r6;
+            r6 = r5 + r7;
+            r5 -= r7;
 
             /* third stage */
-            x7 = x8 + x3;
-            x8 -= x3;
-            x3 = x0 + x2;
-            x0 -= x2;
-            x2 = (181 * (x4 + x5) + 128) >> 8;    /* rounding */
-            x4 = (181 * (x4 - x5) + 128) >> 8;
+            r7 = r8 + r3;
+            r8 -= r3;
+            r3 = r0 + r2;
+            r0 -= r2;
+            r2 = (181 * (r4 + r5) + 128) >> 8;    /* rounding */
+            r4 = (181 * (r4 - r5) + 128) >> 8;
 
             /* fourth stage */
             /* net shift of this function is <<3 after the	  */
             /* following shift operation, it makes output of  */
             /* row IDCT scaled by 8 to retain 3 bits precision*/
-            a = ((x7 + x1) >> 14);
+            a = ((r7 + r1) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x3 + x2) >> 14);
+            a = ((r3 + r2) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x0 + x4) >> 14);
+            a = ((r0 + r4) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x8 + x6) >> 14);
+            a = ((r8 + r6) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x8 - x6) >> 14);
+            a = ((r8 - r6) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x0 - x4) >> 14);
+            a = ((r0 - r4) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x3 - x2) >> 14);
+            a = ((r3 - r2) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
-            a = ((x7 - x1) >> 14);
+            a = ((r7 - r1) >> 14);
             CLIP_RESULT(a)
             *comp++ = a;
 
@@ -350,7 +350,7 @@
     int	i;
     int32	tmpBLK[64];
     int32	*tmpBLK32 = &tmpBLK[0];
-    int32	x0, x1, x2, x3, x4, x5, x6, x7, x8;	/* butterfly nodes */
+    int32	r0, r1, r2, r3, r4, r5, r6, r7, r8;	/* butterfly nodes */
     int32	a;
     int res;
 
@@ -365,23 +365,23 @@
     {
         /* initialize butterfly nodes at first stage */
 
-        x1 = blk[B_SIZE * 4 + i] << 11;
+        r1 = blk[B_SIZE * 4 + i] << 11;
         /* since row IDCT results have net left shift by 3 */
         /* this left shift by 8 gives net left shift by 11 */
         /* in order to maintain the same scale as that of  */
         /* coefficients Wi */
 
-        x2 = blk[B_SIZE * 6 + i];
-        x3 = blk[B_SIZE * 2 + i];
-        x4 = blk[B_SIZE * 1 + i];
-        x5 = blk[B_SIZE * 7 + i];
-        x6 = blk[B_SIZE * 5 + i];
-        x7 = blk[B_SIZE * 3 + i];
+        r2 = blk[B_SIZE * 6 + i];
+        r3 = blk[B_SIZE * 2 + i];
+        r4 = blk[B_SIZE * 1 + i];
+        r5 = blk[B_SIZE * 7 + i];
+        r6 = blk[B_SIZE * 5 + i];
+        r7 = blk[B_SIZE * 3 + i];
 
-        if (!(x1 | x2 | x3 | x4 | x5 | x6 | x7))
+        if (!(r1 | r2 | r3 | r4 | r5 | r6 | r7))
         {
             /* shortcut */
-            /* execute if values of g(x,1) to g(x,7) in a column*/
+            /* execute if values of g(r,1) to g(r,7) in a column*/
             /* are all zeros */
 
             /* make output of IDCT >>3 or scaled by 1/8 and */
@@ -398,39 +398,39 @@
         }
         else
         {
-            x0 = (blk[8 * 0 + i] << 11) + 128;
+            r0 = (blk[8 * 0 + i] << 11) + 128;
 
             /* first stage */
 
-            x8 = W7 * (x4 + x5);
-            x4 = (x8 + (W1 - W7) * x4);
+            r8 = W7 * (r4 + r5);
+            r4 = (r8 + (W1 - W7) * r4);
             /* Multiplication with Wi increases the net left */
             /* shift from 11 to 14,we have to shift back by 3*/
-            x5 = (x8 - (W1 + W7) * x5);
-            x8 = W3 * (x6 + x7);
-            x6 = (x8 - (W3 - W5) * x6);
-            x7 = (x8 - (W3 + W5) * x7);
+            r5 = (r8 - (W1 + W7) * r5);
+            r8 = W3 * (r6 + r7);
+            r6 = (r8 - (W3 - W5) * r6);
+            r7 = (r8 - (W3 + W5) * r7);
 
             /* second stage */
-            x8 = x0 + x1;
-            x0 -= x1;
+            r8 = r0 + r1;
+            r0 -= r1;
 
-            x1 = W6 * (x3 + x2);
-            x2 = (x1 - (W2 + W6) * x2);
-            x3 = (x1 + (W2 - W6) * x3);
+            r1 = W6 * (r3 + r2);
+            r2 = (r1 - (W2 + W6) * r2);
+            r3 = (r1 + (W2 - W6) * r3);
 
-            x1 = x4 + x6;
-            x4 -= x6;
-            x6 = x5 + x7;
-            x5 -= x7;
+            r1 = r4 + r6;
+            r4 -= r6;
+            r6 = r5 + r7;
+            r5 -= r7;
 
             /* third stage */
-            x7 = x8 + x3;
-            x8 -= x3;
-            x3 = x0 + x2;
-            x0 -= x2;
-            x2 = (181 * (x4 + x5) + 128) >> 8;	/* rounding */
-            x4 = (181 * (x4 - x5) + 128) >> 8;
+            r7 = r8 + r3;
+            r8 -= r3;
+            r3 = r0 + r2;
+            r0 -= r2;
+            r2 = (181 * (r4 + r5) + 128) >> 8;	/* rounding */
+            r4 = (181 * (r4 - r5) + 128) >> 8;
 
             /* fourth stage */
             /* net shift of IDCT is >>3 after the following	*/
@@ -438,14 +438,14 @@
             /* scaled by 1/8, that is scaled twice by       */
             /* 1/(2*sqrt(2)) for row IDCT and column IDCT.  */
             /* see detail analysis in design doc.	        */
-            tmpBLK32[0 + i] = (x7 + x1) >> 8;
-            tmpBLK32[(1<<3) + i] = (x3 + x2) >> 8;
-            tmpBLK32[(2<<3) + i] = (x0 + x4) >> 8;
-            tmpBLK32[(3<<3) + i] = (x8 + x6) >> 8;
-            tmpBLK32[(4<<3) + i] = (x8 - x6) >> 8;
-            tmpBLK32[(5<<3) + i] = (x0 - x4) >> 8;
-            tmpBLK32[(6<<3) + i] = (x3 - x2) >> 8;
-            tmpBLK32[(7<<3) + i] = (x7 - x1) >> 8;
+            tmpBLK32[0 + i] = (r7 + r1) >> 8;
+            tmpBLK32[(1<<3) + i] = (r3 + r2) >> 8;
+            tmpBLK32[(2<<3) + i] = (r0 + r4) >> 8;
+            tmpBLK32[(3<<3) + i] = (r8 + r6) >> 8;
+            tmpBLK32[(4<<3) + i] = (r8 - r6) >> 8;
+            tmpBLK32[(5<<3) + i] = (r0 - r4) >> 8;
+            tmpBLK32[(6<<3) + i] = (r3 - r2) >> 8;
+            tmpBLK32[(7<<3) + i] = (r7 - r1) >> 8;
         }
     }
     /* row (horizontal) IDCT */
@@ -453,20 +453,20 @@
     {
         /* initialize butterfly nodes at the first stage */
 
-        x1 = ((int32)tmpBLK32[4+(i<<3)]) << 8;
-        /* x1 left shift by 11 is to maintain the same	*/
+        r1 = ((int32)tmpBLK32[4+(i<<3)]) << 8;
+        /* r1 left shift by 11 is to maintain the same	*/
         /* scale as that of coefficients (W1,...W7)	*/
         /* since blk[4] won't multiply with Wi.		*/
         /* see detail diagram in design document.	*/
 
-        x2 = tmpBLK32[6+(i<<3)];
-        x3 = tmpBLK32[2+(i<<3)];
-        x4 = tmpBLK32[1+(i<<3)];
-        x5 = tmpBLK32[7+(i<<3)];
-        x6 = tmpBLK32[5+(i<<3)];
-        x7 = tmpBLK32[3+(i<<3)];
+        r2 = tmpBLK32[6+(i<<3)];
+        r3 = tmpBLK32[2+(i<<3)];
+        r4 = tmpBLK32[1+(i<<3)];
+        r5 = tmpBLK32[7+(i<<3)];
+        r6 = tmpBLK32[5+(i<<3)];
+        r7 = tmpBLK32[3+(i<<3)];
 
-        if (!(x1 | x2 | x3 | x4 | x5 | x6 | x7))
+        if (!(r1 | r2 | r3 | r4 | r5 | r6 | r7))
         {
             /* shortcut */
             /* execute if values of F(1,v) to F(7,v) in a row*/
@@ -488,51 +488,51 @@
         else
         {
             /* for proper rounding in the fourth stage */
-            x0 = (((int32)tmpBLK32[0+(i<<3)]) << 8) + 8192;
+            r0 = (((int32)tmpBLK32[0+(i<<3)]) << 8) + 8192;
 
             /* first stage */
 
-            x8 = W7 * (x4 + x5) + 4;
-            x4 = (x8 + (W1 - W7) * x4) >> 3;
-            x5 = (x8 - (W1 + W7) * x5) >> 3;
+            r8 = W7 * (r4 + r5) + 4;
+            r4 = (r8 + (W1 - W7) * r4) >> 3;
+            r5 = (r8 - (W1 + W7) * r5) >> 3;
 
-            x8 = W3 * (x6 + x7) + 4;
-            x6 = (x8 - (W3 - W5) * x6) >> 3;
-            x7 = (x8 - (W3 + W5) * x7) >> 3;
+            r8 = W3 * (r6 + r7) + 4;
+            r6 = (r8 - (W3 - W5) * r6) >> 3;
+            r7 = (r8 - (W3 + W5) * r7) >> 3;
 
             /* second stage */
-            x8 = x0 + x1;
-            x0 -= x1;
+            r8 = r0 + r1;
+            r0 -= r1;
 
-            x1 = W6 * (x3 + x2) + 4;
-            x2 = (x1 - (W2 + W6) * x2) >> 3;
-            x3 = (x1 + (W2 - W6) * x3) >> 3;
+            r1 = W6 * (r3 + r2) + 4;
+            r2 = (r1 - (W2 + W6) * r2) >> 3;
+            r3 = (r1 + (W2 - W6) * r3) >> 3;
 
-            x1 = x4 + x6;
-            x4 -= x6;
-            x6 = x5 + x7;
-            x5 -= x7;
+            r1 = r4 + r6;
+            r4 -= r6;
+            r6 = r5 + r7;
+            r5 -= r7;
 
             /* third stage */
-            x7 = x8 + x3;
-            x8 -= x3;
-            x3 = x0 + x2;
-            x0 -= x2;
-            x2 = (181 * (x4 + x5) + 128) >> 8;    /* rounding */
-            x4 = (181 * (x4 - x5) + 128) >> 8;
+            r7 = r8 + r3;
+            r8 -= r3;
+            r3 = r0 + r2;
+            r0 -= r2;
+            r2 = (181 * (r4 + r5) + 128) >> 8;    /* rounding */
+            r4 = (181 * (r4 - r5) + 128) >> 8;
 
             /* fourth stage */
             /* net shift of this function is <<3 after the	  */
             /* following shift operation, it makes output of  */
             /* row IDCT scaled by 8 to retain 3 bits precision*/
-            blk[0+(i<<3)] = (x7 + x1) >> 14;
-            blk[1+(i<<3)] = (x3 + x2) >> 14;
-            blk[2+(i<<3)] = (x0 + x4) >> 14;
-            blk[3+(i<<3)] = (x8 + x6) >> 14;
-            blk[4+(i<<3)] = (x8 - x6) >> 14;
-            blk[5+(i<<3)] = (x0 - x4) >> 14;
-            blk[6+(i<<3)] = (x3 - x2) >> 14;
-            blk[7+(i<<3)] = (x7 - x1) >> 14;
+            blk[0+(i<<3)] = (r7 + r1) >> 14;
+            blk[1+(i<<3)] = (r3 + r2) >> 14;
+            blk[2+(i<<3)] = (r0 + r4) >> 14;
+            blk[3+(i<<3)] = (r8 + r6) >> 14;
+            blk[4+(i<<3)] = (r8 - r6) >> 14;
+            blk[5+(i<<3)] = (r0 - r4) >> 14;
+            blk[6+(i<<3)] = (r3 - r2) >> 14;
+            blk[7+(i<<3)] = (r7 - r1) >> 14;
         }
         /*  add with prediction ,  08/03/05 */
         res = (*pred++ + block[0+(i<<3)]);
diff --git a/codecs_v2/video/m4v_h263/dec/src/idct.h b/codecs_v2/video/m4v_h263/dec/src/idct.h
index f34dc8c..d0c2fb0 100644
--- a/codecs_v2/video/m4v_h263/dec/src/idct.h
+++ b/codecs_v2/video/m4v_h263/dec/src/idct.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/idct_vca.cpp b/codecs_v2/video/m4v_h263/dec/src/idct_vca.cpp
index c9626c1..e989f2d 100644
--- a/codecs_v2/video/m4v_h263/dec/src/idct_vca.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/idct_vca.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/max_level.h b/codecs_v2/video/m4v_h263/dec/src/max_level.h
index cc069f5..4e74865 100644
--- a/codecs_v2/video/m4v_h263/dec/src/max_level.h
+++ b/codecs_v2/video/m4v_h263/dec/src/max_level.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/mb_motion_comp.cpp b/codecs_v2/video/m4v_h263/dec/src/mb_motion_comp.cpp
index c45cca1..3999382 100644
--- a/codecs_v2/video/m4v_h263/dec/src/mb_motion_comp.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/mb_motion_comp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/mb_utils.cpp b/codecs_v2/video/m4v_h263/dec/src/mb_utils.cpp
index ba55a7f..8c1cc3c 100644
--- a/codecs_v2/video/m4v_h263/dec/src/mb_utils.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/mb_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/mbtype_mode.h b/codecs_v2/video/m4v_h263/dec/src/mbtype_mode.h
index d5e3f1e..c45bb5f 100644
--- a/codecs_v2/video/m4v_h263/dec/src/mbtype_mode.h
+++ b/codecs_v2/video/m4v_h263/dec/src/mbtype_mode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/motion_comp.h b/codecs_v2/video/m4v_h263/dec/src/motion_comp.h
index 81c82c6..d97b6d7 100644
--- a/codecs_v2/video/m4v_h263/dec/src/motion_comp.h
+++ b/codecs_v2/video/m4v_h263/dec/src/motion_comp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/mp4dec_lib.h b/codecs_v2/video/m4v_h263/dec/src/mp4dec_lib.h
index a0f3c71..42dfb15 100644
--- a/codecs_v2/video/m4v_h263/dec/src/mp4dec_lib.h
+++ b/codecs_v2/video/m4v_h263/dec/src/mp4dec_lib.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/mp4def.h b/codecs_v2/video/m4v_h263/dec/src/mp4def.h
index a8ee0ba..677aafc 100644
--- a/codecs_v2/video/m4v_h263/dec/src/mp4def.h
+++ b/codecs_v2/video/m4v_h263/dec/src/mp4def.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/mp4lib_int.h b/codecs_v2/video/m4v_h263/dec/src/mp4lib_int.h
index 2b04fe8..47b1d7d 100644
--- a/codecs_v2/video/m4v_h263/dec/src/mp4lib_int.h
+++ b/codecs_v2/video/m4v_h263/dec/src/mp4lib_int.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/packet_util.cpp b/codecs_v2/video/m4v_h263/dec/src/packet_util.cpp
index a52029b..9ab0fcf 100644
--- a/codecs_v2/video/m4v_h263/dec/src/packet_util.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/packet_util.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/post_filter.cpp b/codecs_v2/video/m4v_h263/dec/src/post_filter.cpp
index 0075100..ef29834 100644
--- a/codecs_v2/video/m4v_h263/dec/src/post_filter.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/post_filter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/post_proc.h b/codecs_v2/video/m4v_h263/dec/src/post_proc.h
index 8d5fc66..de026aa 100644
--- a/codecs_v2/video/m4v_h263/dec/src/post_proc.h
+++ b/codecs_v2/video/m4v_h263/dec/src/post_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/post_proc_semaphore.cpp b/codecs_v2/video/m4v_h263/dec/src/post_proc_semaphore.cpp
index d2e1f13..8254545 100644
--- a/codecs_v2/video/m4v_h263/dec/src/post_proc_semaphore.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/post_proc_semaphore.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp b/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp
index 00ad036..ad4a59d 100644
--- a/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_chroma_inter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_luma.cpp b/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_luma.cpp
index bab90e3..1f04842 100644
--- a/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_luma.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/pp_semaphore_luma.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
 		   luminance frame (uint8)
 	pstprcTypPrv = pointer the previous frame's post processing type
 	               (uint8)
-	ll = pointer to the buffer containing ?? (int)
+	ll = pointer to the buffer (int)
 	mv_loc = flag indicating location of the motion compensated
 		 (x,y) position with respect to the luminance MB (int);
 		 0 -> inside MB, 1 -> outside MB
diff --git a/codecs_v2/video/m4v_h263/dec/src/pvdec_api.cpp b/codecs_v2/video/m4v_h263/dec/src/pvdec_api.cpp
index 4bc46d6..acf2cac 100644
--- a/codecs_v2/video/m4v_h263/dec/src/pvdec_api.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/pvdec_api.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,8 +65,8 @@
 /*	Return   : PV_TRUE if successed, PV_FALSE if failed.					*/
 /*	Modified :																*/
 /* ======================================================================== */
-Bool PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[],
-                        int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode)
+OSCL_EXPORT_REF Bool PVInitVideoDecoder(VideoDecControls *decCtrl, uint8 *volbuf[],
+                                        int32 *volbuf_size, int nLayers, int width, int height, MP4DecodingMode mode)
 {
     VideoDecData *video = (VideoDecData *) decCtrl->videoDecoderData;
     Bool status = PV_TRUE;
@@ -563,7 +563,7 @@
 /*	Return   : PV_TRUE if successed, PV_FALSE if failed.					*/
 /*	Modified :																*/
 /* ======================================================================== */
-Bool PVCleanUpVideoDecoder(VideoDecControls *decCtrl)
+OSCL_EXPORT_REF Bool PVCleanUpVideoDecoder(VideoDecControls *decCtrl)
 {
     int	idx;
     VideoDecData *video = (VideoDecData *) decCtrl->videoDecoderData;
@@ -728,7 +728,7 @@
 /*				not want to expose our internal data structure.				*/
 /*	Modified :																*/
 /* ======================================================================== */
-void PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height)
+OSCL_EXPORT_REF void PVGetVideoDimensions(VideoDecControls *decCtrl, int32 *display_width, int32 *display_height)
 {
     VideoDecData *video = (VideoDecData *)decCtrl->videoDecoderData;
     *display_width = video->displayWidth;
@@ -760,7 +760,7 @@
 /*	Note     :																*/
 /*	Modified : . 08/29/2000 changes the name for consistency.				*/
 /* ======================================================================== */
-void PVSetPostProcType(VideoDecControls *decCtrl, int mode)
+OSCL_EXPORT_REF void PVSetPostProcType(VideoDecControls *decCtrl, int mode)
 {
     VideoDecData *video = (VideoDecData *)decCtrl->videoDecoderData;
     video->postFilterType = mode;
@@ -861,7 +861,7 @@
 /*	Note     :																*/
 /*	Modified :																*/
 /* ======================================================================== */
-MP4DecodingMode PVGetDecBitstreamMode(VideoDecControls *decCtrl)
+OSCL_EXPORT_REF MP4DecodingMode PVGetDecBitstreamMode(VideoDecControls *decCtrl)
 {
     VideoDecData *video = (VideoDecData *)decCtrl->videoDecoderData;
     if (video->shortVideoHeader)
@@ -1005,8 +1005,8 @@
 /*			 : 08/22/2002 break up into 2 functions PVDecodeVopHeader and */
 /*							PVDecodeVopBody									*/
 /* ======================================================================== */
-Bool PVDecodeVideoFrame(VideoDecControls *decCtrl, uint8 *buffer[],
-                        uint32 timestamp[], int32 buffer_size[], uint use_ext_timestamp[], uint8 *currYUV)
+OSCL_EXPORT_REF Bool PVDecodeVideoFrame(VideoDecControls *decCtrl, uint8 *buffer[],
+                                        uint32 timestamp[], int32 buffer_size[], uint use_ext_timestamp[], uint8 *currYUV)
 {
     PV_STATUS status = PV_FAIL;
     VopHeaderInfo header_info;
@@ -1106,7 +1106,6 @@
             else if (display_time == timestamp[idx])
             {
                 /* we have to handle either SNR or spatial scalability here. */
-                /*										 09/??/2000		 */
             }
         }
         if (target_layer < 0) return PV_FALSE;
@@ -1338,7 +1337,7 @@
 #endif
         video->vop_coding_type = currVop->predictionType; /*  07/09/01 */
         /* the following is necessary to avoid displaying an notCoded I-VOP at the beginning of a session
-        		or after random positioning  07/03/02*/
+        or after random positioning  07/03/02*/
         if (currVop->predictionType == I_VOP)
         {
             video->vop_coding_type = P_VOP;
@@ -1472,7 +1471,7 @@
 }
 
 #ifdef PV_MEMORY_POOL
-void PVSetReferenceYUV(VideoDecControls *decCtrl, uint8 *YUV)
+OSCL_EXPORT_REF void PVSetReferenceYUV(VideoDecControls *decCtrl, uint8 *YUV)
 {
     VideoDecData *video = (VideoDecData *)decCtrl->videoDecoderData;
     video->prevVop->yChan = (PIXEL *)YUV;
diff --git a/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder.cpp b/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder.cpp
index 20bde2f..04d2b1f 100644
--- a/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder_factory.cpp b/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder_factory.cpp
index 2b17edd..da8503e 100644
--- a/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder_factory.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/pvm4vdecoder_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/scaling.h b/codecs_v2/video/m4v_h263/dec/src/scaling.h
index 0375465..1e61500 100644
--- a/codecs_v2/video/m4v_h263/dec/src/scaling.h
+++ b/codecs_v2/video/m4v_h263/dec/src/scaling.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/scaling_tab.cpp b/codecs_v2/video/m4v_h263/dec/src/scaling_tab.cpp
index 924fe3d..eb234f2 100644
--- a/codecs_v2/video/m4v_h263/dec/src/scaling_tab.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/scaling_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/vlc_dec_tab.h b/codecs_v2/video/m4v_h263/dec/src/vlc_dec_tab.h
index 6a361d5..147724f 100644
--- a/codecs_v2/video/m4v_h263/dec/src/vlc_dec_tab.h
+++ b/codecs_v2/video/m4v_h263/dec/src/vlc_dec_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/vlc_decode.cpp b/codecs_v2/video/m4v_h263/dec/src/vlc_decode.cpp
index 2551cc4..676b48c 100644
--- a/codecs_v2/video/m4v_h263/dec/src/vlc_decode.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/vlc_decode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/vlc_decode.h b/codecs_v2/video/m4v_h263/dec/src/vlc_decode.h
index c5858fc..5817690 100644
--- a/codecs_v2/video/m4v_h263/dec/src/vlc_decode.h
+++ b/codecs_v2/video/m4v_h263/dec/src/vlc_decode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/vlc_dequant.cpp b/codecs_v2/video/m4v_h263/dec/src/vlc_dequant.cpp
index 773a1a4..26ac8ae 100644
--- a/codecs_v2/video/m4v_h263/dec/src/vlc_dequant.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/vlc_dequant.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -857,13 +857,13 @@
         if ((CBP & (1 << (5 - comp))) == 0)
         {
 #ifdef FAST_IDCT
-            bitmapcol[0] = 128;
-            bitmapcol[1] = bitmapcol[2] = bitmapcol[3] = bitmapcol[4] = bitmapcol[5] = bitmapcol[6] = bitmapcol[7] = 0;
+        bitmapcol[0] = 128;
+        bitmapcol[1] = bitmapcol[2] = bitmapcol[3] = bitmapcol[4] = bitmapcol[5] = bitmapcol[6] = bitmapcol[7] = 0;
 #endif
-            datablock[0] <<= 3;  /* no need to clip */
-            return 1;//ncoeffs;
-        }
-        else
+        datablock[0] <<= 3;  /* no need to clip */
+        return 1;//ncoeffs;
+    }
+    else
         {
             /* enter the zero run decoding loop */
             do
diff --git a/codecs_v2/video/m4v_h263/dec/src/vlc_tab.cpp b/codecs_v2/video/m4v_h263/dec/src/vlc_tab.cpp
index 48f939a..c8cec56 100644
--- a/codecs_v2/video/m4v_h263/dec/src/vlc_tab.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/vlc_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/vop.cpp b/codecs_v2/video/m4v_h263/dec/src/vop.cpp
index 08c0c78..005f1e0 100644
--- a/codecs_v2/video/m4v_h263/dec/src/vop.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/vop.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/zigzag.h b/codecs_v2/video/m4v_h263/dec/src/zigzag.h
index 5ec7b95..d96fe79 100644
--- a/codecs_v2/video/m4v_h263/dec/src/zigzag.h
+++ b/codecs_v2/video/m4v_h263/dec/src/zigzag.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/dec/src/zigzag_tab.cpp b/codecs_v2/video/m4v_h263/dec/src/zigzag_tab.cpp
index 2aa4c78..f9e9f0f 100644
--- a/codecs_v2/video/m4v_h263/dec/src/zigzag_tab.cpp
+++ b/codecs_v2/video/m4v_h263/dec/src/zigzag_tab.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/Android.mk b/codecs_v2/video/m4v_h263/enc/Android.mk
index b8a18b8..a9a3c08 100644
--- a/codecs_v2/video/m4v_h263/enc/Android.mk
+++ b/codecs_v2/video/m4v_h263/enc/Android.mk
@@ -3,46 +3,46 @@
 
 LOCAL_SRC_FILES := \
 	src/bitstream_io.cpp \
-	src/combined_encode.cpp \
-	src/datapart_encode.cpp \
-	src/dct.cpp \
-	src/findhalfpel.cpp \
-	src/fastcodemb.cpp \
-	src/fastidct.cpp \
-	src/fastquant.cpp \
-	src/pvm4vencoder.cpp \
-	src/me_utils.cpp \
-	src/mp4enc_api.cpp \
-	src/rate_control.cpp \
-	src/motion_est.cpp \
-	src/motion_comp.cpp \
-	src/sad.cpp \
-	src/sad_halfpel.cpp \
-	src/vlc_encode.cpp \
-	src/vop.cpp
-
+ 	src/combined_encode.cpp \
+ 	src/datapart_encode.cpp \
+ 	src/dct.cpp \
+ 	src/findhalfpel.cpp \
+ 	src/fastcodemb.cpp \
+ 	src/fastidct.cpp \
+ 	src/fastquant.cpp \
+ 	src/pvm4vencoder.cpp \
+ 	src/me_utils.cpp \
+ 	src/mp4enc_api.cpp \
+ 	src/rate_control.cpp \
+ 	src/motion_est.cpp \
+ 	src/motion_comp.cpp \
+ 	src/sad.cpp \
+ 	src/sad_halfpel.cpp \
+ 	src/vlc_encode.cpp \
+ 	src/vop.cpp
 
 
 LOCAL_MODULE := libpvm4vencoder
 
-LOCAL_CFLAGS := -DBX_RC -D__arm__ -DYUV_INPUT -DRGB12_INPUT -DRGB24_INPUT  $(PV_CFLAGS)
-ifeq ($(TARGET_ARCH),arm)
- LOCAL_CFLAGS += -DPV_ARM_GCC 
- endif
+LOCAL_CFLAGS := -DBX_RC -DYUV_INPUT -DRGB12_INPUT -DRGB24_INPUT $(PV_CFLAGS)
 
 LOCAL_ARM_MODE := arm
 
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//codecs_v2/video/m4v_h263/enc/include \
-	$(PV_TOP)//codecs_v2/video/m4v_h263/enc/src \
-	$(PV_INCLUDES) 
+LOCAL_STATIC_LIBRARIES := 
 
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/codecs_v2/video/m4v_h263/enc/src \
+ 	$(PV_TOP)/codecs_v2/video/m4v_h263/enc/include \
+ 	$(PV_TOP)/codecs_v2/utilities/colorconvert/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/cvei.h \
-	include/pvm4vencoder.h \
-	include/mp4enc_api.h
+ 	include/pvm4vencoder.h \
+ 	include/mp4enc_api.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/codecs_v2/video/m4v_h263/enc/build/make/local.mk b/codecs_v2/video/m4v_h263/enc/build/make/local.mk
new file mode 100644
index 0000000..133d1e3
--- /dev/null
+++ b/codecs_v2/video/m4v_h263/enc/build/make/local.mk
@@ -0,0 +1,46 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvm4vencoder
+
+XINCDIRS +=  ../../../../../utilities/colorconvert/include
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE := true
+
+XCPPFLAGS += -DBX_RC -DYUV_INPUT -DRGB12_INPUT -DRGB24_INPUT 
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := bitstream_io.cpp \
+        combined_encode.cpp \
+	datapart_encode.cpp \
+	dct.cpp \
+        findhalfpel.cpp \
+	fastcodemb.cpp \
+	fastidct.cpp \
+	fastquant.cpp \
+	pvm4vencoder.cpp \
+	me_utils.cpp \
+	mp4enc_api.cpp \
+	rate_control.cpp \
+	motion_est.cpp \
+	motion_comp.cpp \
+	sad.cpp \
+	sad_halfpel.cpp \
+	vlc_encode.cpp \
+	vop.cpp 
+
+HDRS := cvei.h \
+	pvm4vencoder.h \
+	mp4enc_api.h
+
+
+
+include $(MK)/library.mk
+ 
diff --git a/codecs_v2/video/m4v_h263/enc/build/make/makefile b/codecs_v2/video/m4v_h263/enc/build/make/makefile
deleted file mode 100644
index e3cc731..0000000
--- a/codecs_v2/video/m4v_h263/enc/build/make/makefile
+++ /dev/null
@@ -1,49 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvm4vencoder
-
-# XINCDIRS += -I ../../common/include
-
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-XCPPFLAGS += -DBX_RC -D__arm__ -DYUV_INPUT -DRGB12_INPUT -DRGB24_INPUT 
-
-ifeq ($(ARCHITECTURE),linux_arm)
-XCPPFLAGS += -DPV_ARM_GCC 
-endif
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  bitstream_io.cpp \
-        combined_encode.cpp \
-	datapart_encode.cpp \
-	dct.cpp \
-        findhalfpel.cpp \
-	fastcodemb.cpp \
-	fastidct.cpp \
-	fastquant.cpp \
-	pvm4vencoder.cpp \
-	me_utils.cpp \
-	mp4enc_api.cpp \
-	rate_control.cpp \
-	motion_est.cpp \
-	motion_comp.cpp \
-	sad.cpp \
-	sad_halfpel.cpp \
-	vlc_encode.cpp \
-	vop.cpp 
-
-HDRS =  cvei.h \
-	pvm4vencoder.h \
-	mp4enc_api.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
- 
diff --git a/codecs_v2/video/m4v_h263/enc/include/cvei.h b/codecs_v2/video/m4v_h263/enc/include/cvei.h
index 0d98cca..9751f76 100644
--- a/codecs_v2/video/m4v_h263/enc/include/cvei.h
+++ b/codecs_v2/video/m4v_h263/enc/include/cvei.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+/*********************************************************************************/
 /*	File: cvei.h                                                                */
 /*	Purpose:																	*/
 /*	Date:																		*/
@@ -57,7 +58,8 @@
 {
     ECVEI_SUCCESS,
     ECVEI_FAIL,
-    ECVEI_FLUSH
+    ECVEI_FLUSH,
+    ECVEI_MORE_OUTPUT
 } ;
 
 /** Returned events with the callback function. */
@@ -82,7 +84,8 @@
     ECVEI_RGB24,
     ECVEI_RGB12,
     ECVEI_YUV420,
-    ECVEI_UYVY
+    ECVEI_UYVY,
+    ECVEI_YUV420SEMIPLANAR
 };
 
 /** Type of contents for optimal encoding mode. */
@@ -132,7 +135,6 @@
     ECVEI_CORE_SCALABLE_LEVEL3
 };
 
-
 /** This structure contains encoder settings. */
 struct TPVVideoEncodeParam
 {
@@ -169,7 +171,7 @@
     the encoder will try to meet the specified frame rate regardless of the frame quality.*/
     bool				iEnableFrameQuality;
 
-    /** Specifies the maximum period in seconds between 2 INTRA frames. An INTRA mode is
+    /** Specifies the maximum number of P-frames between 2 INTRA frames. An INTRA mode is
     forced to a frame once this interval is reached. When there is only one I-frame is present
     at the beginning of the clip, iIFrameInterval should be set to -1. */
     int32				iIFrameInterval;
@@ -248,6 +250,14 @@
     other settings will be checked against the range allowable by this target profile
     and level. Fail may be returned from the Initialize call. */
     TPVM4VProfileLevel	iProfileLevel;
+
+    /** Specifies FSI Buffer input */
+    uint8*				iFSIBuff;
+
+    /** Specifies FSI Buffer Length */
+    int				iFSIBuffLength;
+
+
 };
 
 
@@ -361,8 +371,10 @@
         The input timestamp may not correspond to the output timestamp. User can send
         an input structure in without getting any encoded data back or getting an encoded
         frame in the past. This function returns ECVEI_ERROR if there is any errors.
-        Otherwise, the function returns ECVEI_SUCCESS. */
-        virtual  TCVEI_RETVAL EncodeFrame(TPVVideoInputData  *aVidIn, TPVVideoOutputData *aVidOut
+        Otherwise, the function returns ECVEI_SUCCESS.
+        In case of Overrun Buffer usage, it is possible that return value is ECVEI_MORE_OUTPUT
+        which indicates that frame cannot fit in the current buffer*/
+        virtual  TCVEI_RETVAL EncodeFrame(TPVVideoInputData  *aVidIn, TPVVideoOutputData *aVidOut, int *aRemainingBytes
 #ifdef PVAUTHOR_PROFILING
                                           , void *aParam1 = 0
 #endif
diff --git a/codecs_v2/video/m4v_h263/enc/include/mp4enc_api.h b/codecs_v2/video/m4v_h263/enc/include/mp4enc_api.h
index 9566845..a2d0ce6 100644
--- a/codecs_v2/video/m4v_h263/enc/include/mp4enc_api.h
+++ b/codecs_v2/video/m4v_h263/enc/include/mp4enc_api.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,10 @@
 #ifndef _MP4ENC_API_H_
 #define _MP4ENC_API_H_
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #ifndef _PV_TYPES_
 #define _PV_TYPES_
 typedef unsigned char UChar;
@@ -140,6 +144,9 @@
     /** @brief Enables reversible variable length code (RVLC) mode. Normally it is set to PV_OFF.*/
     ParamEncMode		rvlcEnable;
 
+    /** @brief Set the frequency of GOB header interval */
+    Int					gobHeaderInterval;
+
     /** @brief Sets the number of bitstream layers: 1 is base only: 2 is base + enhancement */
     Int					numLayers;
 
@@ -189,13 +196,13 @@
     *			However, users can force no frame skipping with this flag, but buffer constraint may be violated.*/
     ParamEncMode		noFrameSkipped;
 
-    /** @brief Sets the maximum time in seconds between two intra frames. Intra frames mode are periodically forced
-    *			if no I-Vop is encoded after the specified period to add error resiliency and help resynchronize in case of errors.
-    *			If scene change detection can add additional I-Vop if new scenes are detected.
+    /** @brief Sets the maximum number of P-frames between two I-frames. I-frame mode is periodically forced
+    *			if no I-frame is encoded after the specified period to add error resiliency and help resynchronize in case of errors.
+    *			If scene change detection can add additional I-frame if new scenes are detected.
     *			intraPeriod is the I frame interval in terms of second.
     *			intraPeriod =0 indicates I-frame encoding only;
-    *			intraPeriod = -1  indicates I-frame followed by all P-frames;
-    *			intraPeriod = N, indicates intra period of N seconds. The default is intraPeriod = 5.*/
+    *			intraPeriod = -1  indicates I-frame followed by all P-frames; (default)
+    *			intraPeriod = N, indicates the number of P-frames between 2 I-frames.*/
     Int					intraPeriod;
 
 
@@ -222,6 +229,13 @@
     ParamEncMode		mv8x8Enable;
 
 
+    /** @brief Set the threshold for using intra DC VLC.
+    *           Value must range from 0-7.*/
+    Int                 intraDCVlcTh;
+
+    /** @brief This flag turns on the use of AC prediction */
+    Bool                useACPred;
+
 } VideoEncOptions;
 
 #ifdef __cplusplus
@@ -240,14 +254,14 @@
     *			 are assigned to streaming use-case as compared to download use-case. It can be project dependent too.
     *	@return true for correct operation; false if error happens
     */
-    Bool PVGetDefaultEncOption(VideoEncOptions *encOption, Int encUseCase);
+    OSCL_IMPORT_REF Bool PVGetDefaultEncOption(VideoEncOptions *encOption, Int encUseCase);
 
     /**
     *	@brief  Verifies the consistency of encoding parameters, allocates memory needed and set necessary internal variables.
     *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVInitVideoEncoder(VideoEncControls *encCtrl, VideoEncOptions *encOption);
+    OSCL_IMPORT_REF Bool	PVInitVideoEncoder(VideoEncControls *encCtrl, VideoEncOptions *encOption);
 
     /* acquiring encoder info APIs */
     /**
@@ -261,7 +275,7 @@
     *	@param	layer is the layer of the requested VOL header.
     *	@return true for correct operation; false if error happens.
     */
-    Bool	PVGetVolHeader(VideoEncControls *encCtrl, UChar *volHeader, Int *size, Int layer);
+    OSCL_IMPORT_REF Bool	PVGetVolHeader(VideoEncControls *encCtrl, UChar *volHeader, Int *size, Int layer);
 
     /**
     *	@brief  This function returns the profile and level in H.263 coding when the encoding parameters are set
@@ -270,7 +284,16 @@
     *	@param	levelID is the pointer of the level ID that could be 10-70.
     *	@return true for correct operation; false if error happens.
     */
-    Bool	PVGetH263ProfileLevelID(VideoEncControls *encCtrl, Int *profileID, Int *levelID);
+    OSCL_IMPORT_REF Bool	PVGetH263ProfileLevelID(VideoEncControls *encCtrl, Int *profileID, Int *levelID);
+
+    /**
+    *	@brief  This function returns the profile and level of MPEG4 when the encoding parameters are set
+    *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs.
+    *	@param	profile_level is the pointer of the profile enumeration
+    *	@param	nLayer is the index of the layer of interest
+    *	@return true for correct operation; false if error happens.
+    */
+    OSCL_IMPORT_REF Bool	PVGetMPEG4ProfileLevelID(VideoEncControls *encCtrl, Int *profile_level, Int nLayer);
 
     /**
     *	@brief  This function returns maximum frame size in bytes
@@ -278,7 +301,7 @@
     *	@param	maxVideoFrameSize is the pointer of the maximum frame size
     *	@return true for correct operation; false if error happens
     */
-    Bool    PVGetMaxVideoFrameSize(VideoEncControls *encCtrl, Int *maxVideoFrameSize);
+    OSCL_IMPORT_REF Bool    PVGetMaxVideoFrameSize(VideoEncControls *encCtrl, Int *maxVideoFrameSize);
 
 #ifndef LIMITED_API
     /**
@@ -286,7 +309,7 @@
     *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs
     *	@return true for correct operation; false if error happens
     */
-    Int		PVGetEncMemoryUsage(VideoEncControls *encCtrl);
+    OSCL_IMPORT_REF Int		PVGetEncMemoryUsage(VideoEncControls *encCtrl);
 
     /**
     *	@brief  This function is used by PVAuthor to get the size of the VBV buffer.
@@ -294,7 +317,7 @@
     *	@param	VBVSize is the pointer of The size of the VBV buffer in bytes.
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVGetVBVSize(VideoEncControls *encCtrl, Int *VBVSize);
+    OSCL_IMPORT_REF Bool	PVGetVBVSize(VideoEncControls *encCtrl, Int *VBVSize);
 #endif
 
     /**
@@ -313,9 +336,21 @@
     *	@param	nLayer is the layer of the encoded frame either 0 for base or 1 for enhancement layer. The value -1 indicates skipped frame due to buffer overflow.
     *	@return true newfor correct operation; false if error happens
     */
-    Bool	PVEncodeVideoFrame(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, VideoEncFrameIO *vid_out,
-                            ULong *nextModTime, UChar *bstream, Int *size, Int *nLayer);
-#ifndef NO_SLICE_ENCODE
+    OSCL_IMPORT_REF Bool	PVEncodeVideoFrame(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, VideoEncFrameIO *vid_out,
+                                            ULong *nextModTime, UChar *bstream, Int *size, Int *nLayer);
+
+
+    /**
+    *	@brief	This function is used to query overrun buffer. It is used when PVEncodeVideoFrame.returns size that is
+    *			larger than the input size.
+    *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs
+    *	@return Pointer to the overrun buffer. NULL if overrun buffer is not used.
+    */
+    OSCL_IMPORT_REF UChar* PVGetOverrunBuffer(VideoEncControls *encCtrl);
+
+#ifndef NO_SLICE_ENCODE   /* This set of APIs are not working. This functionality has been partially 
+    replaced by the introduction of overrun buffer. */
+
     /* slice-based coding */
     /**
     *	@brief  This function sets the input YUV frame and timestamp to be encoded by the slice-based encoding function PVEncodeSlice().
@@ -329,7 +364,7 @@
     *	@param	nLayer is the layer of the encoded frame either 0 for base or 1 for enhancement layer. The value -1 indicates skipped frame due to buffer overflow.
     *	@return true newfor correct operation; false if error happens
     */
-    Bool	PVEncodeFrameSet(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, ULong *nextModTime, Int *nLayer);
+    OSCL_IMPORT_REF Bool	PVEncodeFrameSet(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, ULong *nextModTime, Int *nLayer);
     /**
     *	@brief  This function encodes a GOB (short header mode) or a packet (data partitioning mode or combined mode with resync marker)
     *			and output the reconstructed frame and MPEG4 bitstream. The application is required to allocate memory for the bitstream buffer.
@@ -347,8 +382,8 @@
     *	@param	nextModTime is the timestamp encoder expects from the next input
     *	@return true newfor correct operation; false if error happens
     */
-    Bool	PVEncodeSlice(VideoEncControls *encCtrl, UChar *bstream, Int *size,
-                       Int *endofFrame, VideoEncFrameIO *vid_out, ULong *nextModTime);
+    OSCL_IMPORT_REF Bool	PVEncodeSlice(VideoEncControls *encCtrl, UChar *bstream, Int *size,
+                                       Int *endofFrame, VideoEncFrameIO *vid_out, ULong *nextModTime);
 #endif
 
     /**
@@ -357,7 +392,7 @@
     *	@param	info is the structure for MP4 hint track information
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVGetHintTrack(VideoEncControls *encCtrl, MP4HintTrack *info);
+    OSCL_IMPORT_REF Bool	PVGetHintTrack(VideoEncControls *encCtrl, MP4HintTrack *info);
 
 #ifndef LIMITED_API
     /**
@@ -367,7 +402,7 @@
     *			frameRate[n] represents the n-th layer's target frame rate.
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVUpdateEncFrameRate(VideoEncControls *encCtrl, float *frameRate); /* for 2-way */
+    OSCL_IMPORT_REF Bool	PVUpdateEncFrameRate(VideoEncControls *encCtrl, float *frameRate); /* for 2-way */
 
 
     /**
@@ -377,17 +412,17 @@
     *			bitRate[n] represents the n-th layer's target bit rate.
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVUpdateBitRate(VideoEncControls *encCtrl, Int *bitRate);			/* for 2-way */
+    OSCL_IMPORT_REF Bool	PVUpdateBitRate(VideoEncControls *encCtrl, Int *bitRate);			/* for 2-way */
 
 
     /**
     *	@brief  updates the INTRA frame refresh interval while encoding operation is ongoing.
     *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs
-    *	@param	aIFramePeriod is a new value of INTRA frame interval in the unit of second
+    *	@param	aIFramePeriod is a new value of INTRA frame interval in the unit of number of coded frames.
     *	@return true for correct operation; false if error happens
     */
 
-    Bool	PVUpdateIFrameInterval(VideoEncControls *encCtrl, Int aIFramePeriod);/* for 2-way */
+    OSCL_IMPORT_REF Bool	PVUpdateIFrameInterval(VideoEncControls *encCtrl, Int aIFramePeriod);/* for 2-way */
 
     /**
     *	@brief  specifies the number Intra MBs to be refreshed
@@ -395,14 +430,14 @@
     *	@param	numMB is the number of Intra MBs to be refreshed
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVUpdateNumIntraMBRefresh(VideoEncControls *encCtrl, Int numMB);  /* for 2-way */
+    OSCL_IMPORT_REF Bool	PVUpdateNumIntraMBRefresh(VideoEncControls *encCtrl, Int numMB);  /* for 2-way */
 
     /**
     *	@brief  This function is called whenever users want the next base frame to be encoded as an I-Vop.
     *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVIFrameRequest(VideoEncControls *encCtrl);							/* for 2-way */
+    OSCL_IMPORT_REF Bool	PVIFrameRequest(VideoEncControls *encCtrl);							/* for 2-way */
 
 #endif // LIMITED_API
 
@@ -412,7 +447,7 @@
     *	@param	encCtrl is video encoder control structure that is always passed as input in all APIs
     *	@return true for correct operation; false if error happens
     */
-    Bool	PVCleanUpVideoEncoder(VideoEncControls *encCtrl);
+    OSCL_IMPORT_REF Bool	PVCleanUpVideoEncoder(VideoEncControls *encCtrl);
 
 #ifdef __cplusplus
 }
diff --git a/codecs_v2/video/m4v_h263/enc/include/pvm4vencoder.h b/codecs_v2/video/m4v_h263/enc/include/pvm4vencoder.h
index 2f10320..a986c13 100644
--- a/codecs_v2/video/m4v_h263/enc/include/pvm4vencoder.h
+++ b/codecs_v2/video/m4v_h263/enc/include/pvm4vencoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,8 +26,31 @@
 
 #include "cvei.h"
 #include "mp4enc_api.h"
+#include "ccrgb24toyuv420.h"
+#include "ccrgb12toyuv420.h"
+#include "ccyuv420semitoyuv420.h"
 
 #define KCVEIMaxOutputBuffer	10
+#define VISUAL_OBJECT_SEQUENCE_START_CODE 	0x01B0
+#define VISUAL_OBJECT_SEQUENCE_END_CODE 	0x01B1
+#define VISUAL_OBJECT_START_CODE   0x01B5
+#define VO_START_CODE 		    0x8
+#define VO_HEADER_LENGTH        32
+#define VOL_START_CODE 0x12
+#define VOL_START_CODE_LENGTH 28
+
+#define GROUP_START_CODE	0x01B3
+#define GROUP_START_CODE_LENGTH  32
+
+#define VOP_ID_CODE_LENGTH		5
+#define VOP_TEMP_REF_CODE_LENGTH	16
+
+#define USER_DATA_START_CODE	    0x01B2
+#define USER_DATA_START_CODE_LENGTH 32
+
+#define SHORT_VIDEO_START_MARKER		0x20
+#define SHORT_VIDEO_START_MARKER_LENGTH  22
+
 
 /** Encoding mode specific to MPEG4. */
 enum TMP4EncodingMode
@@ -52,6 +75,29 @@
     EPV_ON
 };
 
+typedef struct
+{
+    uint8 *data;
+    uint32 numBytes;
+    uint32 bytePos;
+    uint32 bitBuf;
+    uint32 dataBitPos;
+    uint32  bitPos;
+} mp4StreamType;
+
+static const uint32 MASK[33] =
+{
+    0x00000000, 0x00000001, 0x00000003, 0x00000007,
+    0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
+    0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
+    0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
+    0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
+    0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
+    0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
+    0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
+    0xffffffff
+};
+
 /** MPEG4 encoder class interface. See CommonVideoEncoder APIs for
 virtual functions definitions. */
 class CPVM4VEncoder : public CommonVideoEncoder
@@ -69,7 +115,7 @@
         OSCL_IMPORT_REF virtual int32 GetBufferSize();
         OSCL_IMPORT_REF virtual TCVEI_RETVAL GetVolHeader(uint8 *volHeader, int32 *size, int32 layer);
 
-        OSCL_IMPORT_REF virtual TCVEI_RETVAL EncodeFrame(TPVVideoInputData  *aVidIn, TPVVideoOutputData *aVidOut
+        OSCL_IMPORT_REF virtual TCVEI_RETVAL EncodeFrame(TPVVideoInputData  *aVidIn, TPVVideoOutputData *aVidOut, int *aRemainingBytes
 #ifdef PVAUTHOR_PROFILING
                 , void *aParam1 = 0
 #endif
@@ -95,27 +141,28 @@
 #ifdef	YUV_INPUT
         void CopyToYUVIn(uint8 *YUV, int width, int height, int width_16, int height_16);
 #endif
-        /* RGB->YUV conversion */
-#if defined(RGB12_INPUT)||defined(RGB24_INPUT)
-        TCVEI_RETVAL initRGB2YUVTables();
-        void freeRGB2YUVTables();
-#endif
-        //void RGB2YUV420_12bit(uint16 *inputRGB, int width, int height,int width_16,int height_16);
-#ifdef RGB12_INPUT
-        void RGB2YUV420_12bit(uint32 *inputRGB, int width, int height, int width_16, int height_16);
-#endif
-#ifdef RGB24_INPUT
-        void RGB2YUV420_24bit(uint8 *inputRGB, int width, int height, int width_16, int height_16);
+
+        /** Color conversion instance RGB24/RGB12/YUV420SEMI to YUV 420 */
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
+        ColorConvertBase *ccRGBtoYUV;
 #endif
 
 #ifdef FOR_3GPP_COMPLIANCE
         void Check3GPPCompliance(TPVVideoEncodeParam *aEncParam, int *aEncWidth, int *aEncHeight);
 #endif
 
+        /* Parsing FSI */
+        TCVEI_RETVAL ParseFSI(uint8* aFSIBuff, int FSILength, VideoEncOptions *aEncOption);
+        int16 ShowBits(mp4StreamType *pStream, uint8 ucNBits, uint32 *pulOutData);
+        int16 FlushBits(mp4StreamType *pStream, uint8 ucNBits);
+        int16 ReadBits(mp4StreamType *pStream, uint8 ucNBits, uint32 *pulOutData);
+        int16 ByteAlign(mp4StreamType *pStream);
+        int16 iDecodeShortHeader(mp4StreamType *psBits, VideoEncOptions *aEncOption);
+
+
         /* Pure virtuals from OsclActiveObject implemented in this derived class */
         virtual void Run(void);
         virtual void DoCancel(void);
-
         MPVCVEIObserver *iObserver;
 
         int		iSrcWidth;
@@ -137,6 +184,8 @@
         int32		iNumOutputData;
         uint32		iTimeStamp;
         uint32		iNextModTime;
+        uint8	*iOverrunBuffer;
+        int		iOBSize;
 
         /* Tables in color coversion */
         uint8  *iY_Table;
diff --git a/codecs_v2/video/m4v_h263/enc/src/bitstream_io.cpp b/codecs_v2/video/m4v_h263/enc/src/bitstream_io.cpp
index 9383323..747ef35 100644
--- a/codecs_v2/video/m4v_h263/enc/src/bitstream_io.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/bitstream_io.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -73,6 +73,9 @@
 #endif
     stream->byteCount = 0;
 
+    stream->overrunBuffer = NULL;
+    stream->oBSize = 0;
+
     return stream;
 }
 
@@ -99,6 +102,7 @@
     }
 }
 
+
 /* ======================================================================== */
 /*	Function : BitstreamPutBits(BitstreamEncVideo *stream, Int Length,
 						 Int Value)											*/
@@ -207,7 +211,11 @@
     /* assume that stream->bitLeft is always zero when this function is called */
     if (stream->byteCount + WORD_SIZE > stream->bufferSize)
     {
-        return PV_FAIL;
+        if (PV_SUCCESS != BitstreamUseOverrunBuffer(stream, WORD_SIZE))
+        {
+            stream->byteCount += WORD_SIZE;
+            return PV_FAIL;
+        }
     }
 
     ptr = stream->bitstreamBuffer + stream->byteCount;
@@ -257,7 +265,11 @@
 
     if (stream->byteCount + numbyte > stream->bufferSize)
     {
-        return PV_FAIL;
+        if (PV_SUCCESS != BitstreamUseOverrunBuffer(stream, numbyte))
+        {
+            stream->byteCount += numbyte;
+            return PV_FAIL;
+        }
     }
 
     ptr = stream->bitstreamBuffer + stream->byteCount;
@@ -286,8 +298,8 @@
     }
 
     if (*fraction)
-    {
-        *ptr = (UChar)((word >> shift) & 0xFF); /* need to do it for the last fractional byte */
+    {// this could lead to buffer overrun when ptr is already out of bound.
+        //	*ptr = (UChar)((word>>shift)&0xFF); /* need to do it for the last fractional byte */
     }
 
     /* save new values */
@@ -348,14 +360,14 @@
        need to check with  */
     /*if (!(getPointerENC(index1, index2)%8) && short_video_header[0]) return 0;*/
 
-    /* need stuffing bits,  08/23/1999 */
+    /* need stuffing bits, */
     BitstreamPutBits(stream, 1, 0);
 
     restBits = (stream->bitLeft & 0x7); /* modulo 8 */
 
     if (restBits)  /*short_video_header[0] is 1 in h263 baseline*/
     {
-        /* need stuffing bits,  08/23/1999 */
+        /* need stuffing bits, */
         BitstreamPutBits(stream, restBits, Mask[restBits]);
     }
 
@@ -432,7 +444,11 @@
     /* we read one byte from bitstream2 and use BitstreamPutBits to do the job */
     if (bitstream1->byteCount + bitstream2->byteCount + offset > bitstream1->bufferSize)
     {
-        return PV_FAIL;
+        if (PV_SUCCESS != BitstreamUseOverrunBuffer(bitstream1, bitstream2->byteCount + offset))
+        {
+            bitstream1->byteCount += (bitstream2->byteCount + offset);
+            return PV_FAIL;
+        }
     }
 
     ptrBS1 = bitstream1->bitstreamBuffer + bitstream1->byteCount; /* move ptr bs1*/
@@ -480,8 +496,11 @@
 
     if (bitstream1->byteCount + bitstream2->byteCount  > bitstream1->bufferSize)
     {
-        bitstream1->byteCount += bitstream2->byteCount; /* legacy, to keep track of total bytes */
-        return PV_FAIL;
+        if (PV_SUCCESS != BitstreamUseOverrunBuffer(bitstream1, bitstream2->byteCount))
+        {
+            bitstream1->byteCount += bitstream2->byteCount; /* legacy, to keep track of total bytes */
+            return PV_FAIL;
+        }
     }
 
     ptrBS1 = bitstream1->bitstreamBuffer + bitstream1->byteCount; /* move ptr bs1*/
@@ -751,3 +770,89 @@
     return ;
 }
 
+/* This function set the overrun buffer, and VideoEncData context for callback to reallocate
+overrun buffer.  */
+Void  BitstreamSetOverrunBuffer(BitstreamEncVideo* stream, UChar* overrunBuffer, Int oBSize, VideoEncData *video)
+{
+    stream->overrunBuffer = overrunBuffer;
+    stream->oBSize = oBSize;
+    stream->video = video;
+
+    return ;
+}
+
+
+/* determine whether overrun buffer can be used or not */
+PV_STATUS BitstreamUseOverrunBuffer(BitstreamEncVideo* stream, Int numExtraBytes)
+{
+    VideoEncData *video = stream->video;
+
+    if (stream->overrunBuffer != NULL) // overrunBuffer is set
+    {
+        if (stream->bitstreamBuffer != stream->overrunBuffer) // not already used
+        {
+            if (stream->byteCount + numExtraBytes >= stream->oBSize)
+            {
+                stream->oBSize = stream->byteCount + numExtraBytes + 100;
+                stream->oBSize &= (~0x3); // make it multiple of 4
+
+                // allocate new overrun Buffer
+                if (video->overrunBuffer)
+                {
+                    M4VENC_FREE(video->overrunBuffer);
+                }
+                video->oBSize = stream->oBSize;
+                video->overrunBuffer = (UChar*) M4VENC_MALLOC(sizeof(UChar) * stream->oBSize);
+                stream->overrunBuffer = video->overrunBuffer;
+                if (stream->overrunBuffer == NULL)
+                {
+                    return PV_FAIL;
+                }
+            }
+
+            // copy everything to overrun buffer and start using it.
+            oscl_memcpy(stream->overrunBuffer, stream->bitstreamBuffer, stream->byteCount);
+            stream->bitstreamBuffer = stream->overrunBuffer;
+            stream->bufferSize = stream->oBSize;
+        }
+        else // overrun buffer is already used
+        {
+            if (stream->byteCount + numExtraBytes >= stream->oBSize)
+            {
+                stream->oBSize = stream->byteCount + numExtraBytes + 100;
+            }
+
+            // allocate new overrun buffer
+            stream->oBSize &= (~0x3); // make it multiple of 4
+            video->oBSize = stream->oBSize;
+            video->overrunBuffer = (UChar*) M4VENC_MALLOC(sizeof(UChar) * stream->oBSize);
+            if (video->overrunBuffer == NULL)
+            {
+                return PV_FAIL;
+            }
+
+            // copy from the old buffer to new buffer
+            oscl_memcpy(video->overrunBuffer, stream->overrunBuffer, stream->byteCount);
+            // free old buffer
+            M4VENC_FREE(stream->overrunBuffer);
+            // assign pointer to new buffer
+            stream->overrunBuffer = video->overrunBuffer;
+            stream->bitstreamBuffer = stream->overrunBuffer;
+            stream->bufferSize = stream->oBSize;
+        }
+
+        return PV_SUCCESS;
+    }
+    else // overrunBuffer is not enable.
+    {
+        return PV_FAIL;
+    }
+
+}
+
+
+
+
+
+
+
diff --git a/codecs_v2/video/m4v_h263/enc/src/bitstream_io.h b/codecs_v2/video/m4v_h263/enc/src/bitstream_io.h
index bdeaf89..a422a8b 100644
--- a/codecs_v2/video/m4v_h263/enc/src/bitstream_io.h
+++ b/codecs_v2/video/m4v_h263/enc/src/bitstream_io.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,6 +46,10 @@
     PV_STATUS BitstreamPrependPacket(BitstreamEncVideo *bitstream1, BitstreamEncVideo *bitstream2);
 
 
+    Void  BitstreamSetOverrunBuffer(BitstreamEncVideo *stream, UChar *overrunBuffer, Int oBSize, VideoEncData *video);
+    PV_STATUS BitstreamUseOverrunBuffer(BitstreamEncVideo* stream, Int numExtraBytes);
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/codecs_v2/video/m4v_h263/enc/src/combined_encode.cpp b/codecs_v2/video/m4v_h263/enc/src/combined_encode.cpp
index 7a28d5e..3b77c25 100644
--- a/codecs_v2/video/m4v_h263/enc/src/combined_encode.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/combined_encode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,22 +46,22 @@
     Int	ind_x, ind_y;
     Int start_packet_header = 0;
     UChar *QPMB = video->QPMB;
-    Int QP, QP_prev;
-    Int mbnum = 0, slice_counter = 0;
+    Int QP;
+    Int mbnum = 0, slice_counter = 0, curr_slice_counter = 0;
     Int num_bits, packet_size = encParams->ResyncPacketsize;
-    Bool GOB_Header_enabled = encParams->GOB_Header_Enabled;
+    Int GOB_Header_Interval = encParams->GOB_Header_Interval;
     BitstreamEncVideo *bs1 = video->bitstream1;
     Int numHeaderBits;
     approxDCT fastDCTfunction;
     Int ncoefblck[6] = {64, 64, 64, 64, 64, 64}; /* for FastCodeMB,  5/18/2001 */
     PV_STATUS(*CodeMB)(VideoEncData *, approxDCT *, Int, Int[]);
-    void (*MBVlcEncode)(VideoEncData*, Int, Int[], void *);
+    void (*MBVlcEncode)(VideoEncData*, Int[], void *);
     void (*BlockCodeCoeff)(RunLevelBlock*, BitstreamEncVideo*, Int, Int, UChar);
 
     /* for H263 GOB changes */
 //MP4RateControlType rc_type = encParams->RC_Type;
 
-    QPMB[0] = QP_prev = QP = currVop->quantizer;
+    video->QP_prev = currVop->quantizer;
 
     numHeaderBits = BitstreamGetPos(bs1);
 
@@ -101,6 +101,9 @@
     if (currVol->shortVideoHeader && currVop->gobFrameID != currVop->predictionType)
         currVop->gobFrameID = currVop->predictionType;
 
+
+    video->usePrevQP = 0;
+
     for (ind_y = 0;ind_y < currVol->nMBPerCol;ind_y++) 	/* Col MB Loop */
     {
 
@@ -109,12 +112,13 @@
         if (currVol->shortVideoHeader) 	/* ShortVideoHeader Mode */
         {
 
-            if (slice_counter && GOB_Header_enabled && (ind_y % 2 == 0))  	/* Encode GOB Header */
+            if (slice_counter && GOB_Header_Interval && (ind_y % GOB_Header_Interval == 0))  	/* Encode GOB Header */
             {
                 QP = QPMB[mbnum];	 /* Get quant_scale */
                 video->header_bits -= BitstreamGetPos(currVol->stream); /* Header Bits */
                 status = EncodeGOBHeader(video, slice_counter, QP, 0);	//ind_y		/* Encode GOB Header */
                 video->header_bits += BitstreamGetPos(currVol->stream); /* Header Bits */
+                curr_slice_counter = slice_counter;
             }
         }
 
@@ -122,9 +126,10 @@
         {
             video->outputMB->mb_x = ind_x; /*  5/28/01 */
             video->mbnum = mbnum;
+            QP = QPMB[mbnum];   /* always read new QP */
 
-            if (GOB_Header_enabled)
-                video->sliceNo[mbnum] = (ind_y % 2 == 0 ? slice_counter : slice_counter - 1);	/* Update MB slice number */
+            if (GOB_Header_Interval)
+                video->sliceNo[mbnum] = curr_slice_counter;	/* Update MB slice number */
             else
                 video->sliceNo[mbnum] = slice_counter;
 
@@ -138,12 +143,13 @@
             {
                 slice_counter++;						/* Increment slice counter */
                 video->sliceNo[mbnum] = slice_counter;	/* Update MB slice number*/
-                QP_prev = QP = QPMB[mbnum];						/* store QP */
                 video->header_bits -= BitstreamGetPos(bs1); /* Header Bits */
-                status = EncodeVideoPacketHeader(video, mbnum, QP, 0);
+                video->QP_prev = currVop->quantizer;
+                status = EncodeVideoPacketHeader(video, mbnum, video->QP_prev, 0);
                 video->header_bits += BitstreamGetPos(bs1); /* Header Bits */
                 numHeaderBits = BitstreamGetPos(bs1);
                 start_packet_header = 0;
+                video->usePrevQP = 0;
             }
 #endif
             /***********************************************/
@@ -156,7 +162,7 @@
             /* MB VLC Encode: VLC Encode MB     */
             /************************************/
 
-            (*MBVlcEncode)(video, QP_prev, ncoefblck, (void*)BlockCodeCoeff);
+            (*MBVlcEncode)(video, ncoefblck, (void*)BlockCodeCoeff);
 
             /*************************************************************/
             /* Assemble Packets:  Assemble the MB VLC codes into Packets */
@@ -205,7 +211,7 @@
         if (currVol->shortVideoHeader)  /* ShortVideoHeader = 1 */
         {
 
-            if (GOB_Header_enabled)  slice_counter++;
+            if (GOB_Header_Interval)  slice_counter++;
         }
 
     } /* End of For ind_y */
@@ -267,7 +273,6 @@
 //	rateControl *rc = encParams->rc[video->currLayer];
     UChar *QPMB = video->QPMB;
     Int QP;
-    Int QP_prev = 31;
     Int	ind_x = video->outputMB->mb_x, ind_y = video->outputMB->mb_y;
     Int offset = video->offset;					/* get current MB location */
     Int mbnum = video->mbnum, slice_counter = video->sliceNo[mbnum]; /* get current MB location */
@@ -285,9 +290,11 @@
     Short outputMB[6][64];
     Int k;
     PV_STATUS(*CodeMB)(VideoEncData *, approxDCT *, Int, Int[]);
-    void (*MBVlcEncode)(VideoEncData*, Int, Int[], void *);
+    void (*MBVlcEncode)(VideoEncData*, Int[], void *);
     void (*BlockCodeCoeff)(RunLevelBlock*, BitstreamEncVideo*, Int, Int, UChar);
 
+    video->QP_prev = 31;
+
 #define H263_GOB_CHANGES
 
 
@@ -305,14 +312,15 @@
 
     if (mbnum == 0) /* only do this at the start of a frame */
     {
-        QPMB[0] = QP_prev = QP = currVop->quantizer;
+        QPMB[0] = video->QP_prev = QP = currVop->quantizer;
+        video->usePrevQP = 0;
 
         numHeaderBits = BitstreamGetPos(bs1);
     }
 
     /* Re-assign fast functions on every slice, don't have to put it in the memory */
     QP = QPMB[mbnum];
-    if (mbnum > 0)	 QP_prev = QPMB[mbnum-1];
+    if (mbnum > 0)	 video->QP_prev = QPMB[mbnum-1];
 
     /* determine type of quantization	*/
 #ifndef NO_MPEG_QUANT
@@ -396,17 +404,19 @@
             getMotionCompensatedMB(video, ind_x, ind_y, offset);
 
 JUMP_IN:
+            QP = QPMB[mbnum];   /* always read new QP */
 #ifndef H263_ONLY
             if (start_packet_header)
             {
                 slice_counter++;						/* Increment slice counter */
                 video->sliceNo[mbnum] = slice_counter;	/* Update MB slice number*/
-                QP_prev = QP = QPMB[mbnum];						/* store QP */
+                video->QP_prev = currVop->quantizer;						/* store QP */
                 num_bits = BitstreamGetPos(bs1);
-                status = EncodeVideoPacketHeader(video, mbnum, QP, 1);
+                status = EncodeVideoPacketHeader(video, mbnum, video->QP_prev, 1);
                 numHeaderBits = BitstreamGetPos(bs1) - num_bits;
                 video->header_bits += numHeaderBits; /* Header Bits */
                 start_packet_header = 0;
+                video->usePrevQP = 0;
             }
             else  /* don't encode the first MB in packet again */
 #endif /* H263_ONLY */
@@ -414,7 +424,6 @@
                 /***********************************************/
                 /* Code_MB:  DCT, Q, Q^(-1), IDCT, Motion Comp */
                 /***********************************************/
-
                 status = (*CodeMB)(video, &fastDCTfunction, (offset << 5) + QP, ncoefblck);
             }
 
@@ -437,7 +446,7 @@
             }
             /*************************************/
 
-            (*MBVlcEncode)(video, QP_prev, ncoefblck, (void*)BlockCodeCoeff);
+            (*MBVlcEncode)(video, ncoefblck, (void*)BlockCodeCoeff);
 
             /*************************************************************/
             /* Assemble Packets:  Assemble the MB VLC codes into Packets */
diff --git a/codecs_v2/video/m4v_h263/enc/src/datapart_encode.cpp b/codecs_v2/video/m4v_h263/enc/src/datapart_encode.cpp
index 0b88e60..e2f719a 100644
--- a/codecs_v2/video/m4v_h263/enc/src/datapart_encode.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/datapart_encode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@
     Int	ind_x, ind_y;
     Int start_packet_header = 0;
     UChar *QPMB = video->QPMB;
-    Int QP, QP_prev;
+    Int QP;
     Int mbnum = 0, slice_counter = 0;
     Int num_bits, packet_size = encParams->ResyncPacketsize;
     BitstreamEncVideo *bs1 = video->bitstream1;
@@ -55,10 +55,10 @@
     approxDCT fastDCTfunction;
     Int ncoefblck[6] = {64, 64, 64, 64, 64, 64}; /* for FastCodeMB,  5/18/2001 */
     PV_STATUS(*CodeMB)(VideoEncData *, approxDCT *, Int, Int[]);
-    void (*MBVlcEncode)(VideoEncData*, Int, Int[], void *);
+    void (*MBVlcEncode)(VideoEncData*, Int[], void *);
     void (*BlockCodeCoeff)(RunLevelBlock*, BitstreamEncVideo*, Int, Int, UChar);
 
-    QPMB[0] = QP_prev = QP = currVop->quantizer;
+    video->QP_prev = currVop->quantizer;
 
     numHeaderBits = BitstreamGetPos(bs1); /* Number of bits in VOP Header */
 
@@ -90,6 +90,8 @@
     else
         BlockCodeCoeff = &BlockCodeCoeff_Normal;
 
+    video->usePrevQP = 0;
+
     for (ind_y = 0;ind_y < currVol->nMBPerCol;ind_y++) 	/* Col MB Loop */
     {
 
@@ -100,6 +102,7 @@
             video->outputMB->mb_x = ind_x; /*  5/28/01 */
             video->mbnum = mbnum;
             video->sliceNo[mbnum] = slice_counter;		/* Update MB slice number */
+            QP = QPMB[mbnum];   /* always read new QP */
 
             /****************************************************************************************/
             /* MB Prediction:Put into MC macroblock, substract from currVop, put in predMB */
@@ -111,12 +114,13 @@
             {
                 slice_counter++;						/* Increment slice counter */
                 video->sliceNo[mbnum] = slice_counter;	/* Update MB slice number*/
-                QP_prev = QP = QPMB[mbnum];						/* store QP */
                 video->header_bits -= BitstreamGetPos(bs1); /* Header Bits */
-                status = EncodeVideoPacketHeader(video, mbnum, QP, 0);
+                video->QP_prev = currVop->quantizer;						/* store QP */
+                status = EncodeVideoPacketHeader(video, mbnum, video->QP_prev, 0);
                 video->header_bits += BitstreamGetPos(bs1); /* Header Bits */
                 numHeaderBits = BitstreamGetPos(bs1);
                 start_packet_header = 0;
+                video->usePrevQP = 0;
             }
 
             /***********************************************/
@@ -129,7 +133,7 @@
             /* MB VLC Encode: VLC Encode MB     */
             /************************************/
 
-            MBVlcEncode(video, QP_prev, ncoefblck, (void*)BlockCodeCoeff);
+            MBVlcEncode(video, ncoefblck, (void*)BlockCodeCoeff);
 
             /*************************************************************/
             /* Assemble Packets:  Assemble the MB VLC codes into Packets */
@@ -215,7 +219,7 @@
     Int width = currVop->width; /* has to be Vop, for multiple of 16 */
     Int lx = currVop->pitch; /* , with pading */
     UChar *QPMB = video->QPMB;
-    Int QP, QP_prev = 31;
+    Int QP;
     Int	ind_x = video->outputMB->mb_x, ind_y = video->outputMB->mb_y;
     Int offset = video->offset;					/* get current MB location */
     Int mbnum = video->mbnum, slice_counter = video->sliceNo[mbnum]; /* get current MB location */
@@ -233,10 +237,12 @@
     UChar CBP;
     Short outputMB[6][64];
     PV_STATUS(*CodeMB)(VideoEncData *, approxDCT *, Int, Int[]);
-    void (*MBVlcEncode)(VideoEncData*, Int, Int[], void *);
+    void (*MBVlcEncode)(VideoEncData*, Int[], void *);
     void (*BlockCodeCoeff)(RunLevelBlock*, BitstreamEncVideo*, Int, Int, UChar);
     Int k;
 
+    video->QP_prev = 31;
+
     if (video->end_of_buf) /* left-over from previous run */
     {
         status = BitstreamAppendPacketNoOffset(currVol->stream, bs1);
@@ -250,7 +256,8 @@
 
     if (mbnum == 0) /* only do this at the start of a frame */
     {
-        QPMB[0] = QP_prev = QP = currVop->quantizer;
+        QPMB[0] = video->QP_prev = QP = currVop->quantizer;
+        video->usePrevQP = 0;
 
         numHeaderBits = BitstreamGetPos(bs1); /* Number of bits in VOP Header */
 
@@ -259,7 +266,7 @@
 
     /* Re-assign fast functions on every slice, don't have to put it in the memory */
     QP = QPMB[mbnum];
-    if (mbnum > 0)	 QP_prev = QPMB[mbnum-1];
+    if (mbnum > 0)	 video->QP_prev = QPMB[mbnum-1];
 
     /* determine type of quantization	*/
 #ifndef NO_MPEG_QUANT
@@ -311,17 +318,19 @@
 
 JUMP_IN:
 
+            QP = QPMB[mbnum];   /* always read new QP */
 
             if (start_packet_header)
             {
                 slice_counter++;						/* Increment slice counter */
                 video->sliceNo[mbnum] = slice_counter;	/* Update MB slice number*/
-                QP_prev = QP = QPMB[mbnum];						/* store QP */
+                video->QP_prev = currVop->quantizer;						/* store QP */
                 num_bits = BitstreamGetPos(bs1);
-                status = EncodeVideoPacketHeader(video, mbnum, QP, 0);
+                status = EncodeVideoPacketHeader(video, mbnum, video->QP_prev, 0);
                 numHeaderBits = BitstreamGetPos(bs1) - num_bits;
                 video->header_bits += numHeaderBits; /* Header Bits */
                 start_packet_header = 0;
+                video->usePrevQP = 0;
             }
             else  /* don't encode the first MB in packet again */
             {
@@ -355,7 +364,7 @@
 
             /*************************************/
 
-            MBVlcEncode(video, QP_prev, ncoefblck, (void*)BlockCodeCoeff);
+            MBVlcEncode(video, ncoefblck, (void*)BlockCodeCoeff);
 
             /*************************************************************/
             /* Assemble Packets:  Assemble the MB VLC codes into Packets */
diff --git a/codecs_v2/video/m4v_h263/enc/src/dct.cpp b/codecs_v2/video/m4v_h263/enc/src/dct.cpp
index 01169e8..42a7479 100644
--- a/codecs_v2/video/m4v_h263/enc/src/dct.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/dct.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/dct.h b/codecs_v2/video/m4v_h263/enc/src/dct.h
index 15fca68..3dceb66 100644
--- a/codecs_v2/video/m4v_h263/enc/src/dct.h
+++ b/codecs_v2/video/m4v_h263/enc/src/dct.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/dct_inline.h b/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
index 86474b2..62aae7a 100644
--- a/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
+++ b/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
 #ifndef _DCT_INLINE_H_
 #define _DCT_INLINE_H_
 
-#if !defined(PV_ARM_GCC)&& defined(__arm__)
+#if !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4)
 
 #include "oscl_base_macros.h"
 
@@ -266,7 +266,7 @@
     return abs_sum;
 }
 
-#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#elif ( defined(PV_ARM_GCC_V5) || defined(PV_ARM_GCC_V4) )  /* ARM GNU COMPILER  */
 
 __inline int32 mla724(int32 op1, int32 op2, int32 op3)
 {
diff --git a/codecs_v2/video/m4v_h263/enc/src/fastcodemb.cpp b/codecs_v2/video/m4v_h263/enc/src/fastcodemb.cpp
index 1a5ad8f..225d097 100644
--- a/codecs_v2/video/m4v_h263/enc/src/fastcodemb.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/fastcodemb.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/fastcodemb.h b/codecs_v2/video/m4v_h263/enc/src/fastcodemb.h
index 960c5fa..7063423 100644
--- a/codecs_v2/video/m4v_h263/enc/src/fastcodemb.h
+++ b/codecs_v2/video/m4v_h263/enc/src/fastcodemb.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/fastidct.cpp b/codecs_v2/video/m4v_h263/enc/src/fastidct.cpp
index 4acd39a..1b18ed3 100644
--- a/codecs_v2/video/m4v_h263/enc/src/fastidct.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/fastidct.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/fastquant.cpp b/codecs_v2/video/m4v_h263/enc/src/fastquant.cpp
index 0811c4f..6a0ed33 100644
--- a/codecs_v2/video/m4v_h263/enc/src/fastquant.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/fastquant.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h b/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
index 6a35d43..4e8bd3a 100644
--- a/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
+++ b/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+/*********************************************************************************/
 /*  Filename: fastquant_inline.h														*/
 /*  Description: Implementation for in-line functions used in dct.cpp			*/
 /*  Modified:																	*/
@@ -25,7 +26,7 @@
 #include "mp4def.h"
 #include "oscl_base_macros.h"
 
-#if !defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#if !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) /* ARM GNU COMPILER  */
 
 __inline int32 aan_scale(int32 q_value, int32 coeff, int32 round, int32 QPdiv2)
 {
@@ -423,7 +424,7 @@
     return q_value;
 }
 
-#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#elif ( defined(PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5) ) /* ARM GNU COMPILER  */
 
 __inline int32 aan_scale(int32 q_value, int32 coeff,
                          int32 round, int32 QPdiv2)
diff --git a/codecs_v2/video/m4v_h263/enc/src/findhalfpel.cpp b/codecs_v2/video/m4v_h263/enc/src/findhalfpel.cpp
index d5e4faf..2d84446 100644
--- a/codecs_v2/video/m4v_h263/enc/src/findhalfpel.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/findhalfpel.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/m4venc_oscl.h b/codecs_v2/video/m4v_h263/enc/src/m4venc_oscl.h
index 374ad61..72d7fed 100644
--- a/codecs_v2/video/m4v_h263/enc/src/m4venc_oscl.h
+++ b/codecs_v2/video/m4v_h263/enc/src/m4venc_oscl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/me_utils.cpp b/codecs_v2/video/m4v_h263/enc/src/me_utils.cpp
index 55e811c..8415023 100644
--- a/codecs_v2/video/m4v_h263/enc/src/me_utils.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/me_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/motion_comp.cpp b/codecs_v2/video/m4v_h263/enc/src/motion_comp.cpp
index 9a7f44d..962f811 100644
--- a/codecs_v2/video/m4v_h263/enc/src/motion_comp.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/motion_comp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/motion_est.cpp b/codecs_v2/video/m4v_h263/enc/src/motion_est.cpp
index 016aa07..d717728 100644
--- a/codecs_v2/video/m4v_h263/enc/src/motion_est.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/motion_est.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -697,7 +697,8 @@
 
 void	HTFMPrepareCurMB(VideoEncData *video, HTFM_Stat *htfm_stat, UChar *cur)
 {
-    ULong *htfmMB = (ULong*)(video->currYMB);
+    void* tmp = (void*)(video->currYMB);
+    ULong *htfmMB = (ULong*)tmp;
     UChar *ptr, byte;
     Int *offset;
     Int i;
@@ -761,7 +762,8 @@
 
 void	PrepareCurMB(VideoEncData *video, UChar *cur)
 {
-    ULong *currYMB = (ULong*)(video->currYMB);
+    void* tmp = (void*)(video->currYMB);
+    ULong *currYMB = (ULong*)tmp;
     Int i;
     Int width = video->currVop->width;
 
diff --git a/codecs_v2/video/m4v_h263/enc/src/mp4def.h b/codecs_v2/video/m4v_h263/enc/src/mp4def.h
index d01b3ee..966e1e6 100644
--- a/codecs_v2/video/m4v_h263/enc/src/mp4def.h
+++ b/codecs_v2/video/m4v_h263/enc/src/mp4def.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -206,6 +206,10 @@
 #define NCOEFF_U NCOEFF_BLOCK
 #define NCOEFF_V NCOEFF_BLOCK
 
+/* overrun buffer size  */
+#define DEFAULT_OVERRUN_BUFFER_SIZE 1000
+
+
 #if 0
 const static Int MBtype_mode[] =
 {
diff --git a/codecs_v2/video/m4v_h263/enc/src/mp4enc_api.cpp b/codecs_v2/video/m4v_h263/enc/src/mp4enc_api.cpp
index afd8709..ac4fff7 100644
--- a/codecs_v2/video/m4v_h263/enc/src/mp4enc_api.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/mp4enc_api.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -154,11 +154,11 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVGetDefaultEncOption(VideoEncOptions *encOption, Int encUseCase)
+OSCL_EXPORT_REF Bool PVGetDefaultEncOption(VideoEncOptions *encOption, Int encUseCase)
 {
     VideoEncOptions defaultUseCase = {H263_MODE, profile_level_max_packet_size[SIMPLE_PROFILE_LEVEL0] >> 3,
-                                      SIMPLE_PROFILE_LEVEL0, PV_OFF, 1, 1000, 33, {144, 144}, {176, 176}, {15, 30}, {64000, 128000},
-                                      {10, 10}, {12, 12}, {0, 0}, CBR_1, 0.0, PV_OFF, 5, 0, PV_OFF, 16, PV_OFF
+                                      SIMPLE_PROFILE_LEVEL0, PV_OFF, 0, 1, 1000, 33, {144, 144}, {176, 176}, {15, 30}, {64000, 128000},
+                                      {10, 10}, {12, 12}, {0, 0}, CBR_1, 0.0, PV_OFF, -1, 0, PV_OFF, 16, PV_OFF, 0, PV_ON
                                      };
 
     OSCL_UNUSED_ARG(encUseCase); // unused for now. Later we can add more defaults setting and use this
@@ -183,7 +183,7 @@
 /*	Modified :	5/21/01, allocate only yChan and assign uChan & vChan	*/
 /*				12/12/05, add encoding option as input argument			*/
 /* ======================================================================== */
-Bool 	PVInitVideoEncoder(VideoEncControls *encoderControl, VideoEncOptions *encOption)
+OSCL_EXPORT_REF Bool 	PVInitVideoEncoder(VideoEncControls *encoderControl, VideoEncOptions *encOption)
 {
 
     Bool		status = PV_TRUE;
@@ -217,20 +217,6 @@
     }
     encoderControl->videoEncoderInit = 0;	/* reset this value */
 
-    /* Check whether the input packetsize is valid (Note: put code here (before any memory allocation) in order to avoid memory leak */
-    if ((Int)profile_level < (Int)(SIMPLE_SCALABLE_PROFILE_LEVEL0))  /* non-scalable profile */
-    {
-        profile_level_table = (Int *)profile_level_max_packet_size;
-        profile_table_index = (Int)profile_level;
-    }
-    else   /* scalable profile */
-    {
-        profile_level_table = (Int *)scalable_profile_level_max_packet_size;
-        profile_table_index = (Int)profile_level - (Int)(SIMPLE_SCALABLE_PROFILE_LEVEL0);
-    }
-
-    if (PacketSize > profile_level_table[profile_table_index]) return PV_FALSE;
-
     video = (VideoEncData *)M4VENC_MALLOC(sizeof(VideoEncData)); /* allocate memory for encData */
 
     if (video == NULL)
@@ -242,19 +228,77 @@
 
     video->encParams = (VideoEncParams *)M4VENC_MALLOC(sizeof(VideoEncParams));
     if (video->encParams == NULL)
-        return PV_FALSE;
+        goto CLEAN_UP;
 
     M4VENC_MEMSET(video->encParams, 0, sizeof(VideoEncParams));
 
     encParams = video->encParams;
+    encParams->nLayers = encOption->numLayers;
+
+    /* Check whether the input packetsize is valid (Note: put code here (before any memory allocation) in order to avoid memory leak */
+    if ((Int)profile_level < (Int)(SIMPLE_SCALABLE_PROFILE_LEVEL0))  /* non-scalable profile */
+    {
+        profile_level_table = (Int *)profile_level_max_packet_size;
+        profile_table_index = (Int)profile_level;
+        if (encParams->nLayers != 1)
+        {
+            goto CLEAN_UP;
+        }
+
+        encParams->LayerMaxMbsPerSec[0] = profile_level_max_mbsPerSec[profile_table_index];
+
+    }
+    else   /* scalable profile */
+    {
+        profile_level_table = (Int *)scalable_profile_level_max_packet_size;
+        profile_table_index = (Int)profile_level - (Int)(SIMPLE_SCALABLE_PROFILE_LEVEL0);
+        if (encParams->nLayers < 2)
+        {
+            goto CLEAN_UP;
+        }
+        for (i = 0; i < encParams->nLayers; i++)
+        {
+            encParams->LayerMaxMbsPerSec[i] = scalable_profile_level_max_mbsPerSec[profile_table_index];
+        }
+
+    }
+
+    /* cannot have zero size packet with these modes */
+    if (PacketSize == 0)
+    {
+        if (encOption->encMode == DATA_PARTITIONING_MODE)
+        {
+            goto CLEAN_UP;
+        }
+        if (encOption->encMode == COMBINE_MODE_WITH_ERR_RES)
+        {
+            encOption->encMode = COMBINE_MODE_NO_ERR_RES;
+        }
+    }
+
+    if (encOption->gobHeaderInterval == 0)
+    {
+        if (encOption->encMode == H263_MODE_WITH_ERR_RES)
+        {
+            encOption->encMode = H263_MODE;
+        }
+
+        if (encOption->encMode == SHORT_HEADER_WITH_ERR_RES)
+        {
+            encOption->encMode = SHORT_HEADER;
+        }
+    }
+
+    if (PacketSize > profile_level_table[profile_table_index])
+        goto CLEAN_UP;
 
     /* Initial Defaults for all Modes */
 
-    encParams->nLayers = encOption->numLayers;
     encParams->SequenceStartCode = 1;
     encParams->GOV_Enabled = 0;
     encParams->RoundingType = 0;
-    encParams->IntraDCVlcThr = 0;
+    encParams->IntraDCVlcThr = PV_MAX(PV_MIN(encOption->intraDCVlcTh, 7), 0);
+    encParams->ACDCPrediction = ((encOption->useACPred == PV_ON) ? TRUE : FALSE);
     encParams->RC_Type = encOption->rcType;
     encParams->Refresh = encOption->numIntraMB;
     encParams->ResyncMarkerDisable = 0; /* Enable Resync Marker */
@@ -272,7 +316,7 @@
         }
         else
         {
-            return PV_FALSE;
+            goto CLEAN_UP;
         }
         if (encOption->iQuant[i] >= 1 && encOption->iQuant[i] <= 31)
         {
@@ -280,7 +324,7 @@
         }
         else
         {
-            return PV_FALSE;
+            goto CLEAN_UP;
         }
     }
 
@@ -293,7 +337,7 @@
     encParams->MV8x8_Enabled = 0;// comment out for now!! encOption->mv8x8Enable;
 #endif
     encParams->H263_Enabled = 0;
-    encParams->GOB_Header_Enabled = 0;
+    encParams->GOB_Header_Interval = 0; // need to be reset to 0
     encParams->IntraPeriod = encOption->intraPeriod;	/* Intra update period update default*/
     encParams->SceneChange_Det = encOption->sceneDetect;
     encParams->FineFrameSkip_Enabled = 0;
@@ -324,13 +368,10 @@
             encParams->IntraDCVlcThr = 7;	/* use_intra_dc_vlc = 0 */
             encParams->MV8x8_Enabled = 0;
 
+            encParams->GOB_Header_Interval = encOption->gobHeaderInterval;
             encParams->H263_Enabled = 2;
             encParams->GOV_Enabled = 0;
             encParams->TimeIncrementRes = 30000;		/* timeIncrementRes for H263 */
-
-            if (encOption->encMode == SHORT_HEADER_WITH_ERR_RES)
-                encParams->GOB_Header_Enabled = 1;
-
             break;
 
         case H263_MODE:
@@ -350,9 +391,6 @@
             encParams->GOV_Enabled = 0;
             encParams->TimeIncrementRes = 30000;		/* timeIncrementRes for H263 */
 
-            if (encOption->encMode == H263_MODE_WITH_ERR_RES)
-                encParams->GOB_Header_Enabled = 1;
-
             break;
 #ifndef H263_ONLY
         case DATA_PARTITIONING_MODE:
@@ -383,7 +421,7 @@
             break;
 #endif
         default:
-            return PV_FALSE;
+            goto CLEAN_UP;
     }
     /* Set the constraints (maximum values) according to the input profile and level */
     /* Note that profile_table_index is already figured out above */
@@ -391,12 +429,6 @@
     /* base layer */
     encParams->profile_table_index    = profile_table_index; /* Used to limit the profile and level in SetProfile_BufferSize() */
 
-    /* New check: given the scalable profile, the number of the layers should not be 1, or
-    			  given the non-scalable profile, the number of the layers should not be 2 */
-    if ((encParams->LayerMaxMbsPerSec[1] > 0 && encParams->nLayers == 1) ||
-            (encParams->LayerMaxMbsPerSec[1] == 0 && encParams->nLayers == 2))
-        return FALSE;
-
     /* check timeIncRes */
     timeIncRes = encOption->timeIncRes;
     timeInc = encOption->tickPerSrc;
@@ -416,7 +448,7 @@
     }
     else
     {
-        return PV_FALSE;
+        goto CLEAN_UP;
     }
 
     /* check frame dimension */
@@ -426,28 +458,28 @@
         {
             case 128:
                 if (encOption->encHeight[0] != 96) /* source_format = 1 */
-                    return PV_FALSE;
+                    goto CLEAN_UP;
                 break;
             case 176:
                 if (encOption->encHeight[0] != 144) /* source_format = 2 */
-                    return PV_FALSE;
+                    goto CLEAN_UP;
                 break;
             case 352:
                 if (encOption->encHeight[0] != 288) /* source_format = 2 */
-                    return PV_FALSE;
+                    goto CLEAN_UP;
                 break;
 
             case 704:
                 if (encOption->encHeight[0] != 576) /* source_format = 2 */
-                    return PV_FALSE;
+                    goto CLEAN_UP;
                 break;
             case 1408:
                 if (encOption->encHeight[0] != 1152) /* source_format = 2 */
-                    return PV_FALSE;
+                    goto CLEAN_UP;
                 break;
 
             default:
-                return PV_FALSE;
+                goto CLEAN_UP;
         }
     }
     for (i = 0; i < encParams->nLayers;i++)
@@ -466,7 +498,7 @@
     {
         if (encOption->encFrameRate[0] == encOption->encFrameRate[1] ||
                 encOption->encFrameRate[0] == 0. || encOption->encFrameRate[1] == 0.) /* 7/31/03 */
-            return PV_FALSE;
+            goto CLEAN_UP;
     }
     /* set max frame rate */
     for (i = 0; i < encParams->nLayers;i++)
@@ -495,7 +527,7 @@
     {
         if (encOption->bitRate[0] == encOption->bitRate[1] ||
                 encOption->bitRate[0] == 0 || encOption->bitRate[1] == 0) /* 7/31/03 */
-            return PV_FALSE;
+            goto CLEAN_UP;
     }
     /* check rate control and vbv delay*/
     encParams->RC_Type = encOption->rcType;
@@ -562,17 +594,6 @@
 #endif
     }
 
-    if ((video->encParams->IntraPeriod > 0) && ((video->encParams->IntraPeriod * video->encParams->LayerFrameRate[0]) < 1))
-    {
-        video->encParams->IntraPeriod = (Int)((1 / video->encParams->LayerFrameRate[0]) + 1);
-    }
-
-//  No longer enforce this rule, let users choose num refresh MB even if without error resilience
-//	if((video->encParams->ResyncMarkerDisable != 0) && (video->encParams->GOB_Header_Enabled != 1))
-//	{
-//		video->encParams->Refresh = 0; /* no refresh MB */
-//	}
-
     /******************************************/
     /******************************************/
 
@@ -603,7 +624,7 @@
     if (video->encParams->RC_Type == CBR_LOWDELAY) video->encParams->VBV_delay = 0.5; /* For CBR_LOWDELAY, we set 0.5sec buffer */
     status = SetProfile_BufferSize(video, video->encParams->VBV_delay, 1);
     if (status != PV_TRUE)
-        return PV_FALSE;
+        goto CLEAN_UP;
 
     /****************************************/
     /* memory allocation and initialization */
@@ -616,7 +637,6 @@
 
     //video->currLayer = 0;	/* Set current Layer to 0 */
     //video->currFrameNo = 0; /* Set current frame Number to 0 */
-    video->wrapModTime = 0;
     video->nextModTime = 0;
     video->nextEncIVop = 0; /* Sets up very first frame to be I-VOP! */
     video->numVopsInGOP = 0; /* counter for Vops in Gop, 2/8/01 */
@@ -686,6 +706,26 @@
     video->bitstream3 = BitStreamCreateEnc(2 * 4096); /*allocate working stream 3*/
     if (video->bitstream3 == NULL) goto CLEAN_UP;
 
+    /* allocate overrun buffer */
+    // this buffer is used when user's buffer is too small to hold one frame.
+    // It is not needed for slice-based encoding.
+    if (nLayers == 1)
+    {
+        video->oBSize = encParams->BufferSize[0] >> 3;
+    }
+    else
+    {
+        video->oBSize = PV_MAX((encParams->BufferSize[0] >> 3), (encParams->BufferSize[1] >> 3));
+    }
+
+    if (video->oBSize > DEFAULT_OVERRUN_BUFFER_SIZE || encParams->RC_Type == CONSTANT_Q) // set limit
+    {
+        video->oBSize = DEFAULT_OVERRUN_BUFFER_SIZE;
+    }
+    video->overrunBuffer = (UChar*) M4VENC_MALLOC(sizeof(UChar) * video->oBSize);
+    if (video->overrunBuffer == NULL) goto CLEAN_UP;
+
+
     video->currVop = (Vop *) M4VENC_MALLOC(sizeof(Vop)); /* Memory for Current VOP */
     if (video->currVop == NULL) goto CLEAN_UP;
 
@@ -1035,7 +1075,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool	PVCleanUpVideoEncoder(VideoEncControls *encoderControl)
+OSCL_EXPORT_REF Bool	PVCleanUpVideoEncoder(VideoEncControls *encoderControl)
 {
     Int	idx, i;
     VideoEncData *video = (VideoEncData *)encoderControl->videoEncoderData;
@@ -1108,6 +1148,8 @@
         if (video->bitstream2)BitstreamCloseEnc(video->bitstream2);
         if (video->bitstream3)BitstreamCloseEnc(video->bitstream3);
 
+        if (video->overrunBuffer) M4VENC_FREE(video->overrunBuffer);
+
         max_width = video->encParams->LayerWidth[0];
         max_width = (((max_width + 15) >> 4) << 4); /* 09/19/05 */
         if (video->encParams->H263_Enabled)
@@ -1237,7 +1279,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVGetVolHeader(VideoEncControls *encCtrl, UChar *volHeader, Int *size, Int layer)
+OSCL_EXPORT_REF Bool PVGetVolHeader(VideoEncControls *encCtrl, UChar *volHeader, Int *size, Int layer)
 {
     VideoEncData	*encData;
     PV_STATUS	EncodeVOS_Start(VideoEncControls *encCtrl);
@@ -1272,6 +1314,29 @@
     return PV_TRUE;
 }
 
+/* ======================================================================== */
+/*	Function : PVGetOverrunBuffer()											*/
+/*	Purpose  : Get the overrun buffer `										*/
+/*	In/out   :																*/
+/*	Return   : Pointer to overrun buffer.									*/
+/*	Modified :																*/
+/* ======================================================================== */
+
+OSCL_EXPORT_REF UChar* PVGetOverrunBuffer(VideoEncControls *encCtrl)
+{
+    VideoEncData *video = (VideoEncData *)encCtrl->videoEncoderData;
+    Int currLayer = video->currLayer;
+    Vol *currVol = video->vol[currLayer];
+
+    if (currVol->stream->bitstreamBuffer != video->overrunBuffer) // not used
+    {
+        return NULL;
+    }
+
+    return video->overrunBuffer;
+}
+
+
 #if 0
 static Int PVTIMESTAMP[2] = {0, 0};
 static Int PVMS = 0;
@@ -1293,8 +1358,8 @@
 /*				Finishing new timestamp 32-bit input 						*/
 /*				Applications need to take care of wrap-around				*/
 /* ======================================================================== */
-Bool PVEncodeVideoFrame(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, VideoEncFrameIO *vid_out,
-                        ULong *nextModTime, UChar *bstream, Int *size, Int *nLayer)
+OSCL_EXPORT_REF Bool PVEncodeVideoFrame(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, VideoEncFrameIO *vid_out,
+                                        ULong *nextModTime, UChar *bstream, Int *size, Int *nLayer)
 {
     Bool status = PV_TRUE;
     PV_STATUS pv_status;
@@ -1374,6 +1439,7 @@
     currVol->stream->bitstreamBuffer = bstream;
     currVol->stream->bufferSize = *size;
     BitstreamEncReset(currVol->stream);
+    BitstreamSetOverrunBuffer(currVol->stream, video->overrunBuffer, video->oBSize, video);
 
     /***********************************************************/
     /* Encode VOS and VOL Headers on first call for each layer */
@@ -1427,7 +1493,7 @@
     video->currVop->timeInc = currVol->timeIncrement;
     video->currVop->vopCoded = 1;
     video->currVop->roundingType = 0;
-    video->currVop->intraDCVlcThr = 0;
+    video->currVop->intraDCVlcThr = encParams->IntraDCVlcThr;
 
     if (currLayer == 0
 #ifdef RANDOM_REFSELCODE   /* add random selection of reference Vop */
@@ -1498,7 +1564,7 @@
 
     /* If I-VOP was encoded, reset IntraPeriod */
     if ((currLayer == 0) && (encParams->IntraPeriod > 0) && (video->currVop->predictionType == I_VOP))
-        video->nextEncIVop = encParams->IntraPeriod * encParams->LayerFrameRate[encParams->nLayers-1];
+        video->nextEncIVop = encParams->IntraPeriod;
 
     /* Set HintTrack Information */
     if (currLayer != -1)
@@ -1589,7 +1655,7 @@
 /*	Modified :																*/
 /*																			*/
 /* ======================================================================== */
-Bool PVEncodeFrameSet(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, ULong *nextModTime, Int *nLayer)
+OSCL_EXPORT_REF Bool PVEncodeFrameSet(VideoEncControls *encCtrl, VideoEncFrameIO *vid_in, ULong *nextModTime, Int *nLayer)
 {
     Bool status = PV_TRUE;
     VideoEncData *video = (VideoEncData *)encCtrl->videoEncoderData;
@@ -1701,7 +1767,7 @@
     video->currVop->timeInc = currVol->timeIncrement;
     video->currVop->vopCoded = 1;
     video->currVop->roundingType = 0;
-    video->currVop->intraDCVlcThr = 0;
+    video->currVop->intraDCVlcThr = encParams->IntraDCVlcThr;
 
     if (currLayer == 0
 #ifdef RANDOM_REFSELCODE   /* add random selection of reference Vop */
@@ -1779,8 +1845,8 @@
 /*	Modified :																*/
 /*																			*/
 /* ======================================================================== */
-Bool PVEncodeSlice(VideoEncControls *encCtrl, UChar *bstream, Int *size,
-                   Int *endofFrame, VideoEncFrameIO *vid_out, ULong *nextModTime)
+OSCL_EXPORT_REF Bool PVEncodeSlice(VideoEncControls *encCtrl, UChar *bstream, Int *size,
+                                   Int *endofFrame, VideoEncFrameIO *vid_out, ULong *nextModTime)
 {
     PV_STATUS pv_status;
     VideoEncData *video = (VideoEncData *)encCtrl->videoEncoderData;
@@ -1842,7 +1908,7 @@
 
         /* If I-VOP was encoded, reset IntraPeriod */
         if ((currLayer == 0) && (encParams->IntraPeriod > 0) && (video->currVop->predictionType == I_VOP))
-            video->nextEncIVop = encParams->IntraPeriod * encParams->LayerFrameRate[encParams->nLayers-1];
+            video->nextEncIVop = encParams->IntraPeriod;
 
         /**********************************************************/
         /* Copy Reconstructed Buffer to Output Video Frame Buffer */
@@ -1917,7 +1983,7 @@
 /*			   max_h263_width[2], max_h263_height[2] are global				*/
 /*																			*/
 /* ======================================================================== */
-Bool PVGetH263ProfileLevelID(VideoEncControls *encCtrl, Int *profileID, Int *levelID)
+OSCL_EXPORT_REF Bool PVGetH263ProfileLevelID(VideoEncControls *encCtrl, Int *profileID, Int *levelID)
 {
     VideoEncData *encData;
     Int width, height;
@@ -1978,6 +2044,48 @@
     }
 }
 
+/* ======================================================================== */
+/*	Function : PVGetMPEG4ProfileLevelID()									*/
+/*	Date     : 26/06/2008													*/
+/*	Purpose  : Get MPEG4 Level after initialized			 				*/
+/*	In/out   : profile_level according to interface							*/
+/*	Return   : PV_TRUE if successed, PV_FALSE if failed.					*/
+/*	Modified :																*/
+/*																			*/
+/* ======================================================================== */
+OSCL_EXPORT_REF Bool PVGetMPEG4ProfileLevelID(VideoEncControls *encCtrl, Int *profile_level, Int nLayer)
+{
+    VideoEncData* video;
+    Int i;
+
+    video = (VideoEncData *)encCtrl->videoEncoderData;
+
+    if (nLayer == 0)
+    {
+        for (i = 0; i < 8; i++)
+        {
+            if (video->encParams->ProfileLevel[0] == profile_level_code[i])
+            {
+                break;
+            }
+        }
+        *profile_level = i;
+    }
+    else
+    {
+        for (i = 0; i < 8; i++)
+        {
+            if (video->encParams->ProfileLevel[0] == scalable_profile_level_code[i])
+            {
+                break;
+            }
+        }
+        *profile_level = i + SIMPLE_SCALABLE_PROFILE_LEVEL0;
+    }
+
+    return true;
+}
+
 #ifndef LIMITED_API
 /* ======================================================================== */
 /*	Function : PVUpdateEncFrameRate											*/
@@ -1990,7 +2098,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVUpdateEncFrameRate(VideoEncControls *encCtrl, float *frameRate)
+OSCL_EXPORT_REF Bool PVUpdateEncFrameRate(VideoEncControls *encCtrl, float *frameRate)
 {
     VideoEncData	*encData;
     Int i;// nTotalMB, mbPerSec;
@@ -2031,7 +2139,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVUpdateBitRate(VideoEncControls *encCtrl, Int *bitRate)
+OSCL_EXPORT_REF Bool PVUpdateBitRate(VideoEncControls *encCtrl, Int *bitRate)
 {
     VideoEncData	*encData;
     Int i;
@@ -2109,7 +2217,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVUpdateIFrameInterval(VideoEncControls *encCtrl, Int aIFramePeriod)
+OSCL_EXPORT_REF Bool PVUpdateIFrameInterval(VideoEncControls *encCtrl, Int aIFramePeriod)
 {
     VideoEncData	*encData;
 
@@ -2134,7 +2242,7 @@
 /*	Modified :																*/
 /*																			*/
 /* ======================================================================== */
-Bool	PVUpdateNumIntraMBRefresh(VideoEncControls *encCtrl, Int numMB)
+OSCL_EXPORT_REF Bool	PVUpdateNumIntraMBRefresh(VideoEncControls *encCtrl, Int numMB)
 {
     VideoEncData	*encData;
 
@@ -2159,7 +2267,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVIFrameRequest(VideoEncControls *encCtrl)
+OSCL_EXPORT_REF Bool PVIFrameRequest(VideoEncControls *encCtrl)
 {
     VideoEncData	*encData;
 
@@ -2185,7 +2293,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Int PVGetEncMemoryUsage(VideoEncControls *encCtrl)
+OSCL_EXPORT_REF Int PVGetEncMemoryUsage(VideoEncControls *encCtrl)
 {
     VideoEncData	*encData;
 
@@ -2209,7 +2317,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVGetHintTrack(VideoEncControls *encCtrl, MP4HintTrack *info)
+OSCL_EXPORT_REF Bool PVGetHintTrack(VideoEncControls *encCtrl, MP4HintTrack *info)
 {
     VideoEncData	*encData;
 
@@ -2237,7 +2345,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVGetMaxVideoFrameSize(VideoEncControls *encCtrl, Int *maxVideoFrameSize)
+OSCL_EXPORT_REF Bool PVGetMaxVideoFrameSize(VideoEncControls *encCtrl, Int *maxVideoFrameSize)
 {
     VideoEncData	*encData;
 
@@ -2273,7 +2381,7 @@
 /*																			*/
 /* ======================================================================== */
 
-Bool PVGetVBVSize(VideoEncControls *encCtrl, Int *VBVSize)
+OSCL_EXPORT_REF Bool PVGetVBVSize(VideoEncControls *encCtrl, Int *VBVSize)
 {
     VideoEncData	*encData;
 
@@ -2516,15 +2624,6 @@
     video->nextEncIVop--;  /* number of Vops in highest layer resolution. */
     video->numVopsInGOP++;
 
-    /* map modTime to frame no. from modTimeRef*/
-    if (modTime < modTimeRef) /* modTime wrapped around */
-    {
-        video->wrapModTime += ((ULong)(-1) - modTimeRef) + 1;
-        video->modTimeRef = modTimeRef = 0;
-    }
-
-    modTime += video->wrapModTime; /* wrapModTime is non zero after wrap-around */
-    /* modify modTime with wrapModTime */
     /* from this point frameModTime and nextFrmModTime are internal */
 
     frameNum[i] = (UInt)((modTime - modTimeRef) * LayerFrameRate[i] + 500) / 1000;
@@ -2541,11 +2640,6 @@
     frameModTime = (ULong)(((frameNum[i] * 1000) / LayerFrameRate[i]) + modTimeRef + 0.5); /* rec. time */
     nextFrmModTime = (ULong)((((frameNum[i] + 1) * 1000) / LayerFrameRate[i]) + modTimeRef + 0.5); /* rec. time */
 
-#ifdef _PRINT_STAT
-    printf("TS: %u ", frameModTime - video->wrapModTime);
-#endif
-
-
     srcFrameInterval = 1000 / video->FrameRate;
 
     video->nextModTime = nextFrmModTime - (ULong)(srcFrameInterval / 2.) - 1; /* between current and next frame */
@@ -2558,7 +2652,6 @@
         video->nextModTime += ((delta - video->nextModTime + modTime)); /* empirical formula  */
     }
 #endif
-    video->nextModTime -= video->wrapModTime; /* make it external */
     /****************************************************/
 
     /* map frame no.to tick from modTimeRef */
@@ -2719,7 +2812,7 @@
         {
             if (video->nextEncIVop <= 0 || video->currVop->predictionType == I_VOP)
             {
-                video->nextEncIVop = encParams->IntraPeriod * encParams->LayerFrameRate[encParams->nLayers-1];
+                video->nextEncIVop = encParams->IntraPeriod;
                 video->currVop->predictionType = I_VOP;
                 video->numVopsInGOP = 0;
             }
@@ -2891,6 +2984,7 @@
     float upper_bound_ratio;
     Int bFound = 0;
     Int k = 0, width16, height16, index;
+    Int lowest_level;
 
 #define MIN_BUFF	16000 /* 16k minimum buffer size */
 #define BUFF_CONST  2.0    /* 2000ms */
@@ -3047,7 +3141,17 @@
         }
 
         /* Search the appropriate profile@level index */
-        for (i = 0; i <= index; i++)
+        if (!video->encParams->H263_Enabled &&
+                (video->encParams->IntraDCVlcThr != 0 || video->encParams->SearchRange > 16))
+        {
+            lowest_level = 1; /* cannot allow SPL0 */
+        }
+        else
+        {
+            lowest_level = 0; /* SPL0 */
+        }
+
+        for (i = lowest_level; i <= index; i++)
         {
             if (i != 4 && /* skip Core Profile@Level1 because the parameters in it are smaller than those in Simple Profile@Level3 */
                     base_bitrate	 <= profile_level_max_bitrate[i]	 &&
@@ -3181,6 +3285,14 @@
 
     } /* end of: if(nLayers == 1) */
 
+
+    if (!video->encParams->H263_Enabled && (video->encParams->ProfileLevel[0] == 0x08)) /* SPL0 restriction*/
+    {
+        /* PV only allow frame-based rate control, no QP change from one MB to another
+        if(video->encParams->ACDCPrediction == TRUE && MB-based rate control)
+         return PV_FALSE */
+    }
+
     return PV_TRUE;
 }
 
diff --git a/codecs_v2/video/m4v_h263/enc/src/mp4enc_lib.h b/codecs_v2/video/m4v_h263/enc/src/mp4enc_lib.h
index 5bb46be..3026746 100644
--- a/codecs_v2/video/m4v_h263/enc/src/mp4enc_lib.h
+++ b/codecs_v2/video/m4v_h263/enc/src/mp4enc_lib.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -156,7 +156,7 @@
     Int SAD_Block_MMX(UChar *ref, UChar *blk, Int dmin, Int lx, void *extra_info);
     Int SAD_Block_SSE(UChar *ref, UChar *blk, Int dmin, Int lx, void *extra_info);
 
-#ifdef HTFM	/* KL, 3/2/1, Hypothesis Testing Fast Matching */
+#ifdef HTFM	/* Hypothesis Testing Fast Matching */
     Int SAD_MB_HP_HTFM_Collectxhyh(UChar *ref, UChar *blk, Int dmin_x, void *extra_info);
     Int SAD_MB_HP_HTFM_Collectyh(UChar *ref, UChar *blk, Int dmin_x, void *extra_info);
     Int SAD_MB_HP_HTFM_Collectxh(UChar *ref, UChar *blk, Int dmin_x, void *extra_info);
@@ -166,7 +166,7 @@
     Int SAD_MB_HTFM_Collect(UChar *ref, UChar *blk, Int dmin_lx, void *extra_info);
     Int SAD_MB_HTFM(UChar *ref, UChar *blk, Int dmin_lx, void *extra_info);
 #endif
-    /* KL 4/16/01 on-the-fly padding */
+    /* on-the-fly padding */
     Int SAD_Blk_PADDING(UChar *ref, UChar *cur, Int dmin, Int lx, void *extra_info);
     Int SAD_MB_PADDING(UChar *ref, UChar *cur, Int dmin, Int lx, void *extra_info);
 #ifdef HTFM
@@ -191,10 +191,10 @@
 
 
     /* defined in vlc_encode.c */
-    void MBVlcEncodeDataPar_I_VOP(VideoEncData *video, Int QP_prev, Int ncoefblck[], void *blkCodePtr);
-    void MBVlcEncodeDataPar_P_VOP(VideoEncData *video, Int QP_prev, Int ncoefblck[], void *blkCodePtr);
-    void MBVlcEncodeCombined_I_VOP(VideoEncData *video, Int QP_prev, Int ncoefblck[], void *blkCodePtr);
-    void MBVlcEncodeCombined_P_VOP(VideoEncData *video, Int QP_prev, Int ncoefblck[], void *blkCodePtr);
+    void MBVlcEncodeDataPar_I_VOP(VideoEncData *video, Int ncoefblck[], void *blkCodePtr);
+    void MBVlcEncodeDataPar_P_VOP(VideoEncData *video, Int ncoefblck[], void *blkCodePtr);
+    void MBVlcEncodeCombined_I_VOP(VideoEncData *video, Int ncoefblck[], void *blkCodePtr);
+    void MBVlcEncodeCombined_P_VOP(VideoEncData *video, Int ncoefblck[], void *blkCodePtr);
     void BlockCodeCoeff_ShortHeader(RunLevelBlock *RLB, BitstreamEncVideo *bs, Int j_start, Int j_stop, UChar Mode);
     void BlockCodeCoeff_RVLC(RunLevelBlock *RLB, BitstreamEncVideo *bs, Int j_start, Int j_stop, UChar Mode);
     void BlockCodeCoeff_Normal(RunLevelBlock *RLB, BitstreamEncVideo *bs, Int j_start, Int j_stop, UChar Mode);
diff --git a/codecs_v2/video/m4v_h263/enc/src/mp4lib_int.h b/codecs_v2/video/m4v_h263/enc/src/mp4lib_int.h
index e1358cd..3011704 100644
--- a/codecs_v2/video/m4v_h263/enc/src/mp4lib_int.h
+++ b/codecs_v2/video/m4v_h263/enc/src/mp4lib_int.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,9 @@
     Int byteCount;	/*how many bytes already encoded*/
     UInt word;		/*hold one word temporarily */
     Int bitLeft;	/*number of bits left in "word" */
+    UChar* overrunBuffer;  /* pointer to overrun buffer */
+    Int oBSize;		/* length of overrun buffer */
+    struct tagVideoEncData *video;
 } BitstreamEncVideo;
 
 typedef struct tagVOP
@@ -76,7 +79,7 @@
     Int     shortVideoHeader;   /* shortVideoHeader mode */
     Int		GOVStart;			/* Insert GOV Header */
     Int		timeIncrementResolution;	/* VOL time increment */
-    Int		nbitsTimeIncRes;	/* number of bits for time increment (CJ) */
+    Int		nbitsTimeIncRes;	/* number of bits for time increment */
     Int		timeIncrement;		/* time increment */
     Int		moduloTimeBase;		/* internal decoder clock */
     Int		prevModuloTimeBase;	/* in case of pre-frameskip */
@@ -116,7 +119,7 @@
     Int		verSamp_m;			/* sampfac = ver_samp_n/ver_samp_m      */
     Int		enhancementType;	/* VOL type of enhancement layer */
 
-    /* I added these variables since they are used a lot.  CJ 04/13/2000 */
+    /* These variables were added since they are used a lot. */
     Int		nMBPerRow, nMBPerCol;	/* number of MBs in each row & column    */
     Int		nTotalMB;
     Int		nBitsForMBID;			/* how many bits required for MB number? */
@@ -217,7 +220,7 @@
     Bool	HalfPel_Enabled;		/* Turn Halfpel ME on or off */
     Bool	MV8x8_Enabled;			/* Enable 8x8 motion vectors */
     Bool	RD_opt_Enabled;			/* Enable operational R-D optimization */
-    Bool	GOB_Header_Enabled;		/* Enable encoding GOB header in H263_WITH_ERR_RES and SHORT_HERDER_WITH_ERR_RES */
+    Int 	GOB_Header_Interval;		/* Enable encoding GOB header in H263_WITH_ERR_RES and SHORT_HERDER_WITH_ERR_RES */
     Int		SearchRange;			/* Search range for 16x16 motion vector */
     Int		MemoryUsage;			/* Amount of memory allocated */
     Int		GetVolHeader[2];		/* Flag to check if Vol Header has been retrieved */
@@ -335,6 +338,9 @@
     BitstreamEncVideo  *bitstream2;	/* and combined modes as	  */
     BitstreamEncVideo  *bitstream3;	/* intermediate storages	  */
 
+    UChar   *overrunBuffer;  /* extra output buffer to prevent current skip due to output buffer overrun*/
+    Int		oBSize;		/* size of allocated overrun buffer */
+
     Int dc_scalar_1;			/*dc scalar for Y block */
     Int dc_scalar_2;			/*dc scalar for U, V block*/
 
@@ -371,6 +377,8 @@
     UInt	bitmapzz[6][2];	/* for zigzag bitmap */
     Int		zeroMV;			/* flag for zero MV */
 
+    Int     usePrevQP;      /* flag for intraDCVlcThreshold switch decision */
+    Int		QP_prev;			/* use for DQUANT calculation */
     Int		*acPredFlag;		/* */
     typeDCStore		*predDC;		/* The DC coeffs for each MB */
     typeDCACStore   *predDCAC_row;
@@ -388,7 +396,6 @@
     float	FrameRate;			/* Src frame Rate */
 
     ULong	nextModTime;		/* expected next frame time */
-    ULong	wrapModTime;		/* residue of wrapping */
     UInt	prevFrameNum[4];	/* previous frame number starting from modTimeRef */
     UInt	modTimeRef;		/* Reference modTime update every I-Vop*/
     UInt	refTick[4];			/* second aligned referenc tick */
diff --git a/codecs_v2/video/m4v_h263/enc/src/pvm4vencoder.cpp b/codecs_v2/video/m4v_h263/enc/src/pvm4vencoder.cpp
index 69bfac7..6d1209d 100644
--- a/codecs_v2/video/m4v_h263/enc/src/pvm4vencoder.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/pvm4vencoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,35 +15,28 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*
-////////////////////////////////////////////////////////////////////////////////
-//																				//
-//	File: pvm4vencoder.cpp                                                      //
-//																				//
-//  Modified: 01/15/03									//
-//			  Note:: Black in RGB is (16,128,128) in YUV						//
-//																				//
-//  Modified: 04/09/03				 					    //
-//			  Note:: Optimized function RGB2YUV420_12bit()						//
-//////////////////////////////////////////////////////////////////////////////////
-*/
-
 #include "pvm4vencoder.h"
 #include "oscl_mem.h"
 
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
-
 /* ///////////////////////////////////////////////////////////////////////// */
 CPVM4VEncoder::CPVM4VEncoder()
 {
-//iEncoderControl
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
+    ccRGBtoYUV = NULL;
+#endif
+    //iEncoderControl
 }
 
 /* ///////////////////////////////////////////////////////////////////////// */
 OSCL_EXPORT_REF CPVM4VEncoder::~CPVM4VEncoder()
 {
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
+    OSCL_DELETE(ccRGBtoYUV);
+#endif
+
     Cancel(); /* CTimer function */
     Terminate();
 }
@@ -132,27 +125,17 @@
             }
             else /* otherwise, we can just use aVidIn->iSource */
             {
-                iVideoIn = aVidIn->iSource;  //  Sept 14, 2005 */
+                iVideoIn = aVidIn->iSource;
             }
         }
 #else
             return ECVEI_FAIL;
 #endif
-        if (iVideoFormat == ECVEI_RGB12)
-#ifdef RGB12_INPUT
+
+        if ((iVideoFormat == ECVEI_RGB12) || (iVideoFormat == ECVEI_RGB24) || (iVideoFormat == ECVEI_YUV420SEMIPLANAR))
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
         {
-            RGB2YUV420_12bit((uint32 *)aVidIn->iSource, iSrcWidth, iSrcHeight,
-            ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
-            iVideoIn = iYUVIn;
-        }
-#else
-            return ECVEI_FAIL;
-#endif
-        if (iVideoFormat == ECVEI_RGB24)
-#ifdef RGB24_INPUT
-        {
-            RGB2YUV420_24bit(aVidIn->iSource, iSrcWidth, iSrcHeight,
-            ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
+            ccRGBtoYUV->Convert(aVidIn->iSource, iYUVIn);
             iVideoIn = iYUVIn;
         }
 #else
@@ -267,11 +250,517 @@
     return ;
 }
 
+TCVEI_RETVAL CPVM4VEncoder::ParseFSI(uint8* aFSIBuff, int FSILength, VideoEncOptions *aEncOption)
+{
+    uint32 codeword;
+    mp4StreamType *psBits;
+    psBits = (mp4StreamType *) oscl_malloc(sizeof(mp4StreamType));
+    psBits->data = aFSIBuff;
+    psBits->numBytes = FSILength;
+    psBits->bitBuf = 0;
+    psBits->bitPos = 32;
+    psBits->bytePos = 0;
+    psBits->dataBitPos = 0;
+
+    //visual_object_sequence_start_code
+    ShowBits(psBits, 32, &codeword);
+
+    if (codeword == VISUAL_OBJECT_SEQUENCE_START_CODE)
+    {
+        psBits->dataBitPos += 32;
+        psBits->bitPos += 32;
+
+        ReadBits(psBits, 8, &codeword); /* profile_and_level_indication */
+
+        switch (codeword)
+        {
+            case 0x08: /* SP_LVL0 */
+            {
+                aEncOption->profile_level =  SIMPLE_PROFILE_LEVEL0;
+                break;
+            }
+            case 0x01: /* SP_LVL1 */
+            {
+                aEncOption->profile_level =  SIMPLE_PROFILE_LEVEL1;
+                break;
+            }
+            case 0x02: /* SP_LVL2 */
+            {
+                aEncOption->profile_level =  SIMPLE_PROFILE_LEVEL2;
+                break;
+            }
+            case 0x03: /* SP_LVL3 */
+            {
+                aEncOption->profile_level =  SIMPLE_PROFILE_LEVEL3;
+                break;
+            }
+            case 0x21: /* CP_LVL1 */
+            {
+                aEncOption->profile_level =  CORE_PROFILE_LEVEL1;
+                break;
+            }
+            case 0x22: /* CP_LVL2 */
+            {
+                aEncOption->profile_level =  CORE_PROFILE_LEVEL2;
+                break;
+            }
+            default:
+            {
+                return ECVEI_FAIL;
+            }
+        }
+
+        ShowBits(psBits, 32, &codeword);
+        if (codeword == USER_DATA_START_CODE)
+        {
+            return ECVEI_FAIL;
+        }
+
+        //visual_object_start_code
+        ReadBits(psBits, 32, &codeword);
+        if (codeword != VISUAL_OBJECT_START_CODE) return ECVEI_FAIL;
+
+        /*  is_visual_object_identifier            */
+        ReadBits(psBits, 1, &codeword);
+        if (codeword) return ECVEI_FAIL;
+
+        /* visual_object_type                                 */
+        ReadBits(psBits, 4, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        /* video_signal_type */
+        ReadBits(psBits, 1, &codeword);
+        if (codeword) return ECVEI_FAIL;
+
+        /* next_start_code() */
+        ByteAlign(psBits);
+
+        ShowBits(psBits, 32, &codeword);
+        if (codeword == USER_DATA_START_CODE)
+        {
+            return ECVEI_FAIL;
+        }
+    }
+
+    ShowBits(psBits, 27, &codeword);
+
+    if (codeword == VO_START_CODE)
+    {
+
+        ReadBits(psBits, 32, &codeword);
+
+        /* video_object_layer_start_code                   */
+        ShowBits(psBits, 28, &codeword);
+        if (codeword != VOL_START_CODE)
+        {
+            ShowBits(psBits, 22, &codeword);
+            if (codeword == SHORT_VIDEO_START_MARKER)
+            {
+                iDecodeShortHeader(psBits, aEncOption);
+                return ECVEI_SUCCESS;
+            }
+            else
+            {
+                return ECVEI_FAIL;
+
+            }
+        }
+        /* video_object_layer_start_code                   */
+        ReadBits(psBits, 28, &codeword);
+
+        /* vol_id (4 bits) */
+        ReadBits(psBits, 4, & codeword);
+
+        // RandomAccessibleVOLFlag
+        ReadBits(psBits, 1, &codeword);
+
+        //Video Object Type Indication
+        ReadBits(psBits, 8, &codeword);
+        if (codeword > 2)
+        {
+            return ECVEI_FAIL;
+        }
+
+        // is_object_layer_identifier
+        ReadBits(psBits, 1, &codeword);
+        if (codeword) return ECVEI_FAIL;
+
+        // aspect ratio
+        ReadBits(psBits, 4, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        //vol_control_parameters
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 0) return ECVEI_FAIL;
+
+        //		video_object_layer_shape
+        ReadBits(psBits, 2, &codeword);
+        if (codeword != 0) return ECVEI_FAIL;
+
+        //Marker bit
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        //	vop_time_increment_resolution
+        ReadBits(psBits, 16, &codeword);
+        aEncOption->timeIncRes = codeword;
+
+        //Marker bit
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 1)
+            return ECVEI_FAIL;
+
+        //		fixed_vop_rate
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 0) return ECVEI_FAIL;
+
+        /* video_object_layer_shape is RECTANGULAR */
+        //Marker bit
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        /* this should be 176 for QCIF */
+        ReadBits(psBits, 13, &codeword);
+        aEncOption->encWidth[0] = codeword;
+
+        //Marker bit
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        /* this should be 144 for QCIF */
+        ReadBits(psBits, 13, &codeword);
+        aEncOption->encHeight[0] = codeword;
+
+        //Marker bit
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        //Interlaced
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 0) return ECVEI_FAIL;
+
+        //obmc_disable
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 1) return ECVEI_FAIL;
+
+        //sprite_enable
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 0) return ECVEI_FAIL;
+
+        //not_8_bit
+        ReadBits(psBits, 1, &codeword);
+        if (codeword != 0) return ECVEI_FAIL;
+
+        /* video_object_layer_shape is not GRAY_SCALE  */
+        //quant_type
+        ReadBits(psBits, 1, &codeword);
+        aEncOption->quantType[0] = codeword;
+        if (codeword != 0) //quant_type = 1
+        {
+            ReadBits(psBits, 1, &codeword); //load_intra_quant_mat
+            if (codeword) return ECVEI_FAIL; // No support for user defined matrix.
+
+            ReadBits(psBits, 1, &codeword); //load_nonintra_quant_mat
+            if (codeword) return ECVEI_FAIL; // No support for user defined matrix.
+
+        }
+
+        //complexity_estimation_disable
+        ReadBits(psBits, 1, &codeword);
+        if (!codeword)
+        {
+            return ECVEI_FAIL;
+        }
+
+        //resync_marker_disable
+        ReadBits(psBits, 1, &codeword);
+        if (codeword)
+        {
+            aEncOption->packetSize = 0;
+        }
+
+        //data_partitioned
+        ReadBits(psBits, 1, &codeword);
+        if (codeword)
+        {
+            aEncOption->encMode = DATA_PARTITIONING_MODE;
+            //reversible_vlc
+            ReadBits(psBits, 1, &codeword);
+            aEncOption->rvlcEnable = (ParamEncMode) codeword;
+
+        }
+        else
+        {
+            // No data_partitioned
+            if (aEncOption->packetSize > 0)
+            {
+                aEncOption->encMode = COMBINE_MODE_WITH_ERR_RES;
+            }
+            else
+            {
+                aEncOption->encMode = COMBINE_MODE_NO_ERR_RES;
+            }
+        }
+
+        //scalability
+        ReadBits(psBits, 1, &codeword);
+        if (codeword) return ECVEI_FAIL;
+
+    }
+    else
+    {
+        /* SHORT_HEADER */
+        ShowBits(psBits, SHORT_VIDEO_START_MARKER_LENGTH, &codeword);
+        if (codeword == SHORT_VIDEO_START_MARKER)
+        {
+            iDecodeShortHeader(psBits, aEncOption);
+        }
+        else
+        {
+            return ECVEI_FAIL;
+
+        }
+    }
+    return ECVEI_SUCCESS;
+}
+
+int16 CPVM4VEncoder::iDecodeShortHeader(mp4StreamType *psBits, VideoEncOptions *aEncOption)
+{
+    uint32 codeword;
+    int *width, *height;
+
+    //Default values
+    aEncOption->quantType[0] =	0;
+    aEncOption->rvlcEnable = PV_OFF;
+    aEncOption->packetSize = 0;		// Since, by default resync_marker_disable = 1;
+    aEncOption->encMode = SHORT_HEADER;		// NO error resilience
+    width = &(aEncOption->encWidth[0]);
+    height = &(aEncOption->encHeight[0]);
+
+    //short_video_start_marker
+    ShowBits(psBits, 22, &codeword);
+    if (codeword !=  0x20)
+    {
+        return ECVEI_FAIL;
+    }
+    FlushBits(psBits, 22);
+
+    //temporal_reference
+    ReadBits(psBits, 8, &codeword);
+
+    //marker_bit
+    ReadBits(psBits, 1, &codeword);
+    if (codeword == 0) return ECVEI_FAIL;
+
+    //zero_bit
+    ReadBits(psBits, 1, &codeword);
+    if (codeword == 1) return ECVEI_FAIL;
+
+    //split_screen_indicator
+    ReadBits(psBits, 1, &codeword);
+    if (codeword == 1) return ECVEI_FAIL;
+
+    //document_camera_indicator
+    ReadBits(psBits, 1, &codeword);
+    if (codeword == 1) return ECVEI_FAIL;
+
+    //full_picture_freeze_release
+    ReadBits(psBits, 1, &codeword);
+    if (codeword == 1) return ECVEI_FAIL;
+
+    /* source format */
+    ReadBits(psBits, 3, &codeword);
+    switch (codeword)
+    {
+        case 1:
+            *width = 128;
+            *height = 96;
+            break;
+
+        case 2:
+            *width = 176;
+            *height = 144;
+            break;
+
+        case 3:
+            *width = 352;
+            *height = 288;
+            break;
+
+        case 4:
+            *width = 704;
+            *height = 576;
+            break;
+
+        case 5:
+            *width = 1408;
+            *height = 1152;
+            break;
+
+        default:
+            return ECVEI_FAIL;
+    }
+
+    return 0;
+}
+
+int16 CPVM4VEncoder::ShowBits(
+    mp4StreamType *pStream,           /* Input Stream */
+    uint8 ucNBits,          /* nr of bits to read */
+    uint32 *pulOutData      /* output target */
+)
+{
+    uint8 *bits;
+    uint32 dataBitPos = pStream->dataBitPos;
+    uint32 bitPos = pStream->bitPos;
+    uint32 dataBytePos;
+
+    uint i;
+
+    if (ucNBits > (32 - bitPos))    /* not enough bits */
+    {
+        dataBytePos = dataBitPos >> 3; /* Byte Aligned Position */
+        bitPos = dataBitPos & 7; /* update bit position */
+        if (dataBytePos > pStream->numBytes - 4)
+        {
+            pStream->bitBuf = 0;
+            for (i = 0;i < pStream->numBytes - dataBytePos;i++)
+            {
+                pStream->bitBuf |= pStream->data[dataBytePos+i];
+                pStream->bitBuf <<= 8;
+            }
+            pStream->bitBuf <<= 8 * (3 - i);
+        }
+        else
+        {
+            bits = &pStream->data[dataBytePos];
+            pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
+        }
+        pStream->bitPos = bitPos;
+    }
+
+    bitPos += ucNBits;
+
+    *pulOutData = (pStream->bitBuf >> (32 - bitPos)) & MASK[(uint16)ucNBits];
+
+
+    return 0;
+}
+
+int16 CPVM4VEncoder::FlushBits(
+    mp4StreamType *pStream,           /* Input Stream */
+    uint8 ucNBits                      /* number of bits to flush */
+)
+{
+    uint8 *bits;
+    uint32 dataBitPos = pStream->dataBitPos;
+    uint32 bitPos = pStream->bitPos;
+    uint32 dataBytePos;
+
+
+    if ((dataBitPos + ucNBits) > (uint32)(pStream->numBytes << 3))
+        return (-2); // Buffer over run
+
+    dataBitPos += ucNBits;
+    bitPos     += ucNBits;
+
+    if (bitPos > 32)
+    {
+        dataBytePos = dataBitPos >> 3;    /* Byte Aligned Position */
+        bitPos = dataBitPos & 7; /* update bit position */
+        bits = &pStream->data[dataBytePos];
+        pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
+    }
+
+    pStream->dataBitPos = dataBitPos;
+    pStream->bitPos     = bitPos;
+
+    return 0;
+}
+
+int16 CPVM4VEncoder::ReadBits(
+    mp4StreamType *pStream,           /* Input Stream */
+    uint8 ucNBits,                     /* nr of bits to read */
+    uint32 *pulOutData                 /* output target */
+)
+{
+    uint8 *bits;
+    uint32 dataBitPos = pStream->dataBitPos;
+    uint32 bitPos = pStream->bitPos;
+    uint32 dataBytePos;
+
+
+    if ((dataBitPos + ucNBits) > (pStream->numBytes << 3))
+    {
+        *pulOutData = 0;
+        return (-2); // Buffer over run
+    }
+
+    //  dataBitPos += ucNBits;
+
+    if (ucNBits > (32 - bitPos))    /* not enough bits */
+    {
+        dataBytePos = dataBitPos >> 3;    /* Byte Aligned Position */
+        bitPos = dataBitPos & 7; /* update bit position */
+        bits = &pStream->data[dataBytePos];
+        pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
+    }
+
+    pStream->dataBitPos += ucNBits;
+    pStream->bitPos      = (unsigned char)(bitPos + ucNBits);
+
+    *pulOutData = (pStream->bitBuf >> (32 - pStream->bitPos)) & MASK[(uint16)ucNBits];
+
+    return 0;
+}
+
+
+
+int16 CPVM4VEncoder::ByteAlign(
+    mp4StreamType *pStream           /* Input Stream */
+)
+{
+    uint8 *bits;
+    uint32 dataBitPos = pStream->dataBitPos;
+    uint32 bitPos = pStream->bitPos;
+    uint32 dataBytePos;
+    uint32 leftBits;
+
+    leftBits =  8 - (dataBitPos & 0x7);
+    if (leftBits == 8)
+    {
+        if ((dataBitPos + 8) > (uint32)(pStream->numBytes << 3))
+            return (-2); // Buffer over run
+        dataBitPos += 8;
+        bitPos += 8;
+    }
+    else
+    {
+        dataBytePos = dataBitPos >> 3;
+        dataBitPos += leftBits;
+        bitPos += leftBits;
+    }
+
+
+    if (bitPos > 32)
+    {
+        dataBytePos = dataBitPos >> 3;    /* Byte Aligned Position */
+        bits = &pStream->data[dataBytePos];
+        pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
+    }
+
+    pStream->dataBitPos = dataBitPos;
+    pStream->bitPos     = bitPos;
+
+    return 0;
+}
+
 /* ///////////////////////////////////////////////////////////////////////// */
 OSCL_EXPORT_REF TCVEI_RETVAL CPVM4VEncoder::Initialize(TPVVideoInputFormat *aVidInFormat, TPVVideoEncodeParam *aEncParam)
 {
 
-    int /*status,*/i;
+    int i;
+    TCVEI_RETVAL status;
     MP4EncodingMode	ENC_Mode ;
     ParamEncMode RvlcMode = PV_OFF; /* default no RVLC */
     Int	quantType[2] = {0, 0};		/* default H.263 quant*/
@@ -280,6 +769,9 @@
     iState = EIdle ; // stop encoding
     iId = aEncParam->iEncodeID;
 
+    iOverrunBuffer = NULL;
+    iOBSize = 0;
+
     if (aEncParam->iContentType == 	ECVEI_STREAMING)
     {
         ENC_Mode = DATA_PARTITIONING_MODE;
@@ -319,20 +811,13 @@
 
     if (iInitialized == true)  /* clean up before re-initialized */
     {
-        /*status = */(int) PVCleanUpVideoEncoder(&iEncoderControl);
+        /*status = */
+        (int) PVCleanUpVideoEncoder(&iEncoderControl);
         if (iYUVIn)
         {
             oscl_free(iYUVIn);
             iYUVIn = NULL;
         }
-        if (iVideoFormat == ECVEI_RGB24 || iVideoFormat == ECVEI_RGB12)
-        {
-#if defined(RGB24_INPUT)||defined(RGB12_INPUT)
-            freeRGB2YUVTables();
-#else
-            return ECVEI_FAIL;
-#endif
-        }
     }
 
     // allocate iYUVIn
@@ -354,61 +839,128 @@
         }
     }
 
-    /* Initialize the color conversion table if needed*/
-    if (iVideoFormat == ECVEI_RGB24 || iVideoFormat == ECVEI_RGB12)
+    if (iVideoFormat == ECVEI_RGB24)
     {
-#if defined(RGB24_INPUT)||defined(RGB12_INPUT)
-        initRGB2YUVTables();
+#ifdef RGB24_INPUT
+        ccRGBtoYUV = CCRGB24toYUV420::New();
+#else
+        return ECVEI_FAIL;
+#endif
+    }
+    if (iVideoFormat == ECVEI_RGB12)
+    {
+#ifdef RGB12_INPUT
+        ccRGBtoYUV = CCRGB12toYUV420::New();
+#else
+        return ECVEI_FAIL;
+#endif
+    }
+    if (iVideoFormat == ECVEI_YUV420SEMIPLANAR)
+    {
+#ifdef YUV420SEMIPLANAR_INPUT
+        ccRGBtoYUV = CCYUV420SEMItoYUV420::New();
 #else
         return ECVEI_FAIL;
 #endif
     }
 
+    if ((iVideoFormat == ECVEI_RGB12) || (iVideoFormat == ECVEI_RGB24) || (iVideoFormat == ECVEI_YUV420SEMIPLANAR))
+    {
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined (YUV420SEMIPLANAR_INPUT)
+        ccRGBtoYUV->Init(iSrcWidth, iSrcHeight, iSrcWidth, iSrcWidth, iSrcHeight, ((iSrcWidth + 15) >> 4) << 4, (iFrameOrientation == 1 ? CCBOTTOM_UP : 0));
+#endif
+    }
+
     PVGetDefaultEncOption(&aEncOption, 0);
 
-    for (i = 0; i < aEncParam->iNumLayer; i++)
+
+    /* iContentType is M4v && FSI Buffer is input parameter */
+    if ((aEncParam->iContentType != ECVEI_H263) && (aEncParam->iFSIBuffLength))
     {
-        aEncOption.encWidth[i] = iEncWidth[i] = aEncParam->iFrameWidth[i];
-        aEncOption.encHeight[i] = iEncHeight[i] = aEncParam->iFrameHeight[i];
-        aEncOption.encFrameRate[i] = iEncFrameRate[i] = aEncParam->iFrameRate[i];
+        aEncOption.encMode = ENC_Mode;
+        aEncOption.packetSize = aEncParam->iPacketSize;
+        aEncOption.numLayers = aEncParam->iNumLayer;
+
+        status = ParseFSI(aEncParam->iFSIBuff, aEncParam->iFSIBuffLength, &aEncOption);
+        if (ECVEI_FAIL == status)
+        {
+            return ECVEI_FAIL;
+        }
+
+        aEncOption.tickPerSrc = (int)(aEncOption.timeIncRes / aVidInFormat->iFrameRate + 0.5);
+
+        for (i = 0; i < aEncParam->iNumLayer; i++)
+        {
+            aEncOption.encFrameRate[i] = iEncFrameRate[i] = aEncParam->iFrameRate[i];
+            aEncOption.bitRate[i] = aEncParam->iBitRate[i];
+            aEncOption.iQuant[i] = aEncParam->iIquant[i];
+            aEncOption.pQuant[i] = aEncParam->iPquant[i];
+        }
+
+        if (aEncParam->iRateControlType == ECONSTANT_Q)
+            aEncOption.rcType = CONSTANT_Q;
+        else if (aEncParam->iRateControlType == ECBR_1)
+            aEncOption.rcType = CBR_1;
+        else if (aEncParam->iRateControlType == EVBR_1)
+            aEncOption.rcType = VBR_1;
+        else
+            return ECVEI_FAIL;
+
     }
+    else	// All default Settings
+    {
+        aEncOption.encMode = ENC_Mode;
+        aEncOption.packetSize = aEncParam->iPacketSize;
 
-    if (aEncParam->iRateControlType == ECONSTANT_Q)
-        aEncOption.rcType = CONSTANT_Q;
-    else if (aEncParam->iRateControlType == ECBR_1)
-        aEncOption.rcType = CBR_1;
-    else if (aEncParam->iRateControlType == EVBR_1)
-        aEncOption.rcType = VBR_1;
-    else
-        return ECVEI_FAIL;
+        Int profile_level = (Int)ECVEI_CORE_LEVEL2;
+        if (aEncParam->iNumLayer > 1) profile_level = (Int)ECVEI_CORE_SCALABLE_LEVEL3;
+        aEncOption.profile_level = (ProfileLevelType)profile_level;
 
-    // Check the bitrate, framerate, image size and buffer delay for 3GGP compliance
+        aEncOption.rvlcEnable = RvlcMode;
+        aEncOption.numLayers = aEncParam->iNumLayer;
+        aEncOption.timeIncRes = 1000;
+        aEncOption.tickPerSrc = (int)(1000 / aVidInFormat->iFrameRate + 0.5);
+
+        for (i = 0; i < aEncParam->iNumLayer; i++)
+        {
+            aEncOption.encWidth[i] = iEncWidth[i] = aEncParam->iFrameWidth[i];
+            aEncOption.encHeight[i] = iEncHeight[i] = aEncParam->iFrameHeight[i];
+            aEncOption.encFrameRate[i] = iEncFrameRate[i] = aEncParam->iFrameRate[i];
+            aEncOption.bitRate[i] = aEncParam->iBitRate[i];
+            aEncOption.iQuant[i] = aEncParam->iIquant[i];
+            aEncOption.pQuant[i] = aEncParam->iPquant[i];
+            aEncOption.quantType[i] = quantType[i]; /* default to H.263 */
+        }
+
+        if (aEncParam->iRateControlType == ECONSTANT_Q)
+            aEncOption.rcType = CONSTANT_Q;
+        else if (aEncParam->iRateControlType == ECBR_1)
+            aEncOption.rcType = CBR_1;
+        else if (aEncParam->iRateControlType == EVBR_1)
+            aEncOption.rcType = VBR_1;
+        else
+            return ECVEI_FAIL;
+
+        // Check the bitrate, framerate, image size and buffer delay for 3GGP compliance
 #ifdef FOR_3GPP_COMPLIANCE
-    Check3GPPCompliance(aEncParam, iEncWidth, iEncHeight);
+        Check3GPPCompliance(aEncParam, iEncWidth, iEncHeight);
 #endif
-
-    Int profile_level = (Int)ECVEI_CORE_LEVEL2;
-    if (aEncParam->iNumLayer > 1) profile_level = (Int)ECVEI_CORE_SCALABLE_LEVEL3;
-
-
-    aEncOption.encMode = ENC_Mode;
-    aEncOption.packetSize = aEncParam->iPacketSize;
-    aEncOption.profile_level = (ProfileLevelType)profile_level;
-    aEncOption.rvlcEnable = RvlcMode;
-    aEncOption.numLayers = aEncParam->iNumLayer;
-    aEncOption.timeIncRes = 1000;
-    aEncOption.tickPerSrc = (int)(1000 / aVidInFormat->iFrameRate + 0.5);
-
-    for (i = 0; i < aEncParam->iNumLayer; i++)
-    {
-        aEncOption.bitRate[i] = aEncParam->iBitRate[i];
-        aEncOption.iQuant[i] = aEncParam->iIquant[i];
-        aEncOption.pQuant[i] = aEncParam->iPquant[i];
-        aEncOption.quantType[i] = quantType[i]; /* default to H.263 */
     }
 
+
     aEncOption.vbvDelay = (float)aEncParam->iBufferDelay;
-    aEncOption.intraPeriod = aEncParam->iIFrameInterval;
+    switch (aEncParam->iIFrameInterval)
+    {
+        case -1:
+            aEncOption.intraPeriod = -1;
+            break;
+        case 0:
+            aEncOption.intraPeriod = 0;
+            break;
+        default:
+            aEncOption.intraPeriod = (int)(aEncParam->iIFrameInterval *  aVidInFormat->iFrameRate);
+            break;
+    }
     aEncOption.numIntraMB = aEncParam->iNumIntraMBRefresh;
     aEncOption.sceneDetect = (aEncParam->iSceneDetection == true) ? PV_ON : PV_OFF;
     aEncOption.noFrameSkipped = (aEncParam->iNoFrameSkip == true) ? PV_ON : PV_OFF;
@@ -475,7 +1027,8 @@
 #endif
 
 /* ///////////////////////////////////////////////////////////////////////// */
-OSCL_EXPORT_REF TCVEI_RETVAL CPVM4VEncoder::EncodeFrame(TPVVideoInputData  *aVidIn, TPVVideoOutputData *aVidOut
+// Value of aRemainingBytes is relevant when overrun buffer is used and return value is ECVEI_MORE_OUTPUT
+OSCL_EXPORT_REF TCVEI_RETVAL CPVM4VEncoder::EncodeFrame(TPVVideoInputData  *aVidIn, TPVVideoOutputData *aVidOut, int *aRemainingBytes
 #ifdef PVAUTHOR_PROFILING
         , void *aParam1
 #endif
@@ -487,6 +1040,34 @@
     Int nLayer = 0;
     ULong modTime;
     VideoEncFrameIO vid_in, vid_out;
+    *aRemainingBytes = 0;
+
+    if (iState == EEncode && iOverrunBuffer) // more output buffer to be copied out.
+    {
+        if (iOBSize > aVidOut->iBitStreamSize)
+        {
+            oscl_memcpy(aVidOut->iBitStream, iOverrunBuffer, aVidOut->iBitStreamSize);
+            iOBSize -= aVidOut->iBitStreamSize;
+            iOverrunBuffer += aVidOut->iBitStreamSize;
+            *aRemainingBytes = iOBSize;
+            return ECVEI_MORE_OUTPUT;
+        }
+        else
+        {
+            oscl_memcpy(aVidOut->iBitStream, iOverrunBuffer, iOBSize);
+            aVidOut->iBitStreamSize = iOBSize;
+            iOverrunBuffer = NULL;
+            iOBSize = 0;
+            iState = EIdle;
+            *aRemainingBytes = 0;
+            return ECVEI_SUCCESS;
+        }
+    }
+
+    if (aVidIn->iSource == NULL)
+    {
+        return ECVEI_FAIL;
+    }
 
     if (aVidIn->iTimeStamp >= iNextModTime) /* time to encode */
     {
@@ -509,28 +1090,16 @@
             }
             else /* otherwise, we can just use aVidIn->iSource */
             {
-                iVideoIn = aVidIn->iSource;  //  Sept 14, 2005 */
+                iVideoIn = aVidIn->iSource;
             }
         }
 #else
             return ECVEI_FAIL;
 #endif
-        else if (iVideoFormat == ECVEI_RGB12)
-#ifdef RGB12_INPUT
+        else if ((iVideoFormat == ECVEI_RGB12) || (iVideoFormat == ECVEI_RGB24) || (iVideoFormat == ECVEI_YUV420SEMIPLANAR))
+#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
         {
-            RGB2YUV420_12bit((uint32 *)aVidIn->iSource, iSrcWidth, iSrcHeight,
-            ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
-            iVideoIn = iYUVIn;
-        }
-#else
-            return ECVEI_FAIL;
-#endif
-
-        else if (iVideoFormat == ECVEI_RGB24)
-#ifdef RGB24_INPUT
-        {
-            RGB2YUV420_24bit(aVidIn->iSource, iSrcWidth, iSrcHeight,
-            ((iSrcWidth + 15) >> 4) << 4, ((iSrcHeight + 15) >> 4) << 4);
+            ccRGBtoYUV->Convert((uint8*)aVidIn->iSource, iYUVIn);
             iVideoIn = iYUVIn;
         }
 #else
@@ -562,9 +1131,7 @@
         if (status == PV_TRUE)
         {
             iNextModTime = modTime;
-
             aVidOut->iLayerNumber = nLayer;
-            aVidOut->iBitStreamSize = Size;
             aVidOut->iFrame = iVideoOut = (uint8*)vid_out.yChan;
             aVidOut->iVideoTimeStamp = vid_out.timestamp;
 
@@ -573,7 +1140,21 @@
 #ifdef PVAUTHOR_PROFILING
             if (aParam1)((CPVAuthorProfile*)aParam1)->Stop(CPVAuthorProfile::EVideoEncode);
 #endif
-            return ECVEI_SUCCESS;
+
+            iOverrunBuffer = PVGetOverrunBuffer(&iEncoderControl);
+            if (iOverrunBuffer != NULL && nLayer != -1)
+            {
+                oscl_memcpy(aVidOut->iBitStream, iOverrunBuffer, aVidOut->iBitStreamSize);
+                iOBSize = Size - aVidOut->iBitStreamSize;
+                iOverrunBuffer += aVidOut->iBitStreamSize;
+                iState = EEncode;
+                return ECVEI_MORE_OUTPUT;
+            }
+            else
+            {
+                aVidOut->iBitStreamSize = Size;
+                return ECVEI_SUCCESS;
+            }
         }
         else
             return ECVEI_FAIL;
@@ -606,16 +1187,12 @@
         PVCleanUpVideoEncoder(&iEncoderControl);
         iInitialized = false;
 
-        if (iYUVIn)
-        {
-            oscl_free(iYUVIn);
-            iYUVIn = NULL;
-        }
+    }
 
-#if defined(RGB12_INPUT)||defined(RGB24_INPUT)
-        if (iVideoFormat == ECVEI_RGB24 || iVideoFormat == ECVEI_RGB12)
-            freeRGB2YUVTables();
-#endif
+    if (iYUVIn)
+    {
+        oscl_free(iYUVIn);
+        iYUVIn = NULL;
     }
     return ECVEI_SUCCESS;
 }
@@ -846,622 +1423,6 @@
 }
 #endif
 
-#if defined(RGB12_INPUT) || defined(RGB24_INPUT)
-/* ///////////////////////////////////////////////////////////////////////// */
-/* The following four functions are for RGB->YUV, convert				   */
-/* RGB input(12bit/24bit) to YUV frame inside M4VEnc lib				   */
-/* ///////////////////////////////////////////////////////////////////////// */
-TCVEI_RETVAL CPVM4VEncoder::initRGB2YUVTables()
-{
-    Int i;
-    uint16 *pTable;
-
-    iY_Table  = NULL;
-    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
-
-    /* memory allocation */
-    if ((iY_Table = (uint8*)oscl_malloc(384)) == NULL)
-        return ECVEI_FAIL;
-
-    if ((iCb_Table = (uint16*)oscl_malloc(768 * 2)) == NULL)
-        return ECVEI_FAIL;
-
-    if ((iCr_Table = (uint16*)oscl_malloc(768 * 2)) == NULL)
-        return ECVEI_FAIL;
-
-#define pv_max(a, b)	((a) >= (b) ? (a) : (b))
-#define pv_min(a, b)	((a) <= (b) ? (a) : (b))
-
-    /* Table generation */
-    for (i = 0; i < 384; i++)
-        iY_Table[i] = (uint8) pv_max(pv_min(255, (Int)(0.7152 * i + 16 + 0.5)), 0);
-
-    pTable = iCb_Table + 384;
-    for (i = -384; i < 384; i++)
-        pTable[i] = (uint16) pv_max(pv_min(255, (Int)(0.386 * i + 128 + 0.5)), 0);
-    ipCb_Table = iCb_Table + 384;
-
-    pTable = iCr_Table + 384;
-    for (i = -384; i < 384; i++)
-        pTable[i] = (uint16) pv_max(pv_min(255, (Int)(0.454 * i + 128 + 0.5)), 0);
-    ipCr_Table = iCr_Table + 384;
-
-    return ECVEI_SUCCESS;
-
-}
-
-void CPVM4VEncoder::freeRGB2YUVTables()
-{
-    if (iY_Table) oscl_free(iY_Table);
-    if (iCb_Table) oscl_free(iCb_Table);
-    if (iCr_Table) oscl_free(iCr_Table);
-
-    iY_Table  = NULL;
-    iCb_Table = iCr_Table = ipCb_Table = ipCr_Table = NULL;
-
-}
-#endif
-#ifdef RGB12_INPUT
-#ifdef VERSION_0
-/* Assume B is in the first 4 bits, G is in the second 4 bits, and R is in the third 4 bits, of a whole 16bit unsigned integer */
-void CPVM4VEncoder::RGB2YUV420_12bit(uint16 *inputRGB, Int width, Int height, Int width_16, Int height_16)
-{
-    Int i, j;
-    uint8 *tempY, *tempU, *tempV;
-    uint16 *inputRGB_prevRow = NULL;
-
-
-    tempY = iYUVIn; /* Normal order */
-    tempU = iYUVIn + height_16 * width_16;
-    tempV = iYUVIn + height_16 * width_16 + (height_16 * width_16 >> 2);
-
-    for (j = 0; j < height; j++)
-    {
-        for (i = 0; i < width; i++)
-        {
-
-            *tempY++ = iY_Table[(6616*(inputRGB[i] << 4 & 0x00f0) + ((inputRGB[i] & 0x00f0) << 16) + 19481 * (inputRGB[i] >> 4 & 0x00f0)) >> 16];
-
-            /* downsampling U, V */
-            if (j % 2 == 1 && i % 2 == 1)
-            {
-
-                *tempU++ = (uint8)(ipCb_Table[(((inputRGB[i] << 4 & 0x00f0) << 16) - ((inputRGB[i] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB[i] << 4 & 0x00f0) - (inputRGB[i] >> 4 & 0x00f0))) >> 16] + /* bottom right(current) */
-
-                                   ipCb_Table[(((inputRGB[i-1] << 4 & 0x00f0) << 16) - ((inputRGB[i-1] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB[i-1] << 4 & 0x00f0) - (inputRGB[i-1] >> 4 & 0x00f0))) >> 16] + /* bottom left */
-
-                                   ipCb_Table[(((inputRGB_prevRow[i] << 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB_prevRow[i] << 4 & 0x00f0) - (inputRGB_prevRow[i] >> 4 & 0x00f0))) >> 16] + /* top right */
-
-                                   ipCb_Table[(((inputRGB_prevRow[i-1] << 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i-1] & 0x00f0) << 16) +
-                                               19525 * ((inputRGB_prevRow[i-1] << 4 & 0x00f0) - (inputRGB_prevRow[i-1] >> 4 & 0x00f0))) >> 16] + /* top left */
-
-                                   2 >> 2);
-
-
-                *tempV++ = (uint8)(ipCr_Table[(((inputRGB[i] >> 4 & 0x00f0) << 16) - ((inputRGB[i] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB[i] >> 4 & 0x00f0) - (inputRGB[i] << 4 & 0x00f0))) >> 16] + /* bottom right(current) */
-
-                                   ipCr_Table[(((inputRGB[i-1] >> 4 & 0x00f0) << 16) - ((inputRGB[i-1] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB[i-1] >> 4 & 0x00f0) - (inputRGB[i-1] << 4 & 0x00f0))) >> 16] + /* bottom left */
-
-                                   ipCr_Table[(((inputRGB_prevRow[i] >> 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB_prevRow[i] >> 4 & 0x00f0) - (inputRGB_prevRow[i] << 4 & 0x00f0))) >> 16] + /* top right */
-
-                                   ipCr_Table[(((inputRGB_prevRow[i-1] >> 4 & 0x00f0) << 16) - ((inputRGB_prevRow[i-1] & 0x00f0) << 16) +
-                                               6640 * ((inputRGB_prevRow[i-1] >> 4 & 0x00f0) - (inputRGB_prevRow[i-1] << 4 & 0x00f0))) >> 16] + /* top left */
-
-                                   2 >> 2);
-            }
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-        if (width < width_16)
-        {
-            oscl_memset(tempY, *(tempY - 1), width_16 - width);
-            tempY += (width_16 - width);
-
-            if (j % 2 == 1)
-            {
-                oscl_memset(tempU, *(tempU - 1), (width_16 - width) >> 1);
-                tempU += (width_16 - width) >> 1;
-                oscl_memset(tempV, *(tempV - 1), (width_16 - width) >> 1);
-                tempV += (width_16 - width) >> 1;
-            }
-        }
-
-        inputRGB_prevRow = inputRGB;
-        inputRGB += width;	/* move to the next row */
-    }
-
-    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
-    if (height < height_16)
-    {
-        tempY = iYUVIn + height * width_16;
-        tempU = tempY - width_16;/* tempU is for temporary use, not meaning U stuff */
-        for (i = height; i < height_16; i++)
-        {
-            oscl_memcpy(tempY, tempU, width_16);
-            tempY += width_16;
-        }
-
-        tempU = iYUVIn + height_16 * width_16 + (height * width_16 >> 2);
-        tempV = tempU - (width_16 >> 1); /* tempV is for temporary use, not meaning V stuff */
-        for (i = height >> 1; i<height_16 >> 1; i++)
-        {
-            oscl_memcpy(tempU, tempV, (width_16 >> 1));
-            tempU += (width_16 >> 1);
-        }
-
-        tempV = iYUVIn + height_16 * width_16 + (height_16 * width_16 >> 2) + (height * width_16 >> 2);
-        tempY = tempV - (width_16 >> 1); /* tempY is for temporary use, not meaning Y stuff */
-        for (i = height >> 1; i<height_16 >> 1; i++)
-        {
-            oscl_memcpy(tempV, tempY, (width_16 >> 1));
-            tempV += (width_16 >> 1);
-        }
-
-    }
-
-}
-#endif
-
-/* Assume width is divisible by 8 */
-void CPVM4VEncoder::RGB2YUV420_12bit(
-    uint32 *inputRGB,
-    Int     width,
-    Int     height,
-    Int     width_16,
-    Int     height_16)
-{
-    Int i;
-    Int j;
-    Int ilimit;
-    Int jlimit;
-    uint32 *tempY;
-    uint32 *tempU;
-    uint32 *tempV;
-    uint32 pixels;
-    uint32 pixels_nextRow;
-    uint32 yuv_value;
-    uint32 yuv_value1;
-    uint32 yuv_value2;
-    Int R_ds; /* "_ds" is the downsample version */
-    Int G_ds; /* "_ds" is the downsample version */
-    Int B_ds; /* "_ds" is the downsample version */
-    Int adjust = (width >> 1);
-    Int size16 = height_16 * width_16;
-    Int tmp;
-    uint32 temp;
-
-    /* do padding at the bottom first */
-    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
-    if (height < height_16 || width < width_16)
-    { /* if padding */
-        Int offset = (height < height_16) ? height : height_16;
-
-        offset = (offset * width_16);
-
-        if (width < width_16)
-        {
-            offset -= (width_16 - width);
-        }
-
-        tempY = (uint32 *)iYUVIn + (offset >> 2);
-        oscl_memset((uint8 *)tempY, 16, size16 - offset); /* pad with zeros */
-
-        tempU = (uint32 *)iYUVIn + (size16 >> 2) + (offset >> 4);
-        oscl_memset((uint8 *)tempU, 128, (size16 - offset) >> 2);
-
-        tempV = (uint32 *)iYUVIn + (size16 >> 2) + (size16 >> 4) + (offset >> 4);
-        oscl_memset((uint8 *)tempV, 128, (size16 - offset) >> 2);
-    }
-
-    /* then do padding on the top */
-    tempY = (uint32 *)iYUVIn; /* Normal order */
-    tempU = tempY + ((size16) >> 2);
-    tempV = tempU + ((size16) >> 4);
-
-    /* To center the output */
-    if (height_16 > height)
-    {
-        if (width_16 >= width)
-        {
-            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-        }
-        else
-        {
-            i = ((height_16 - height) >> 1) * width_16;
-            j = ((height_16 - height) >> 2) * (width_16 >> 1);
-            inputRGB += (width - width_16) >> 2;
-        }
-        oscl_memset((uint8 *)tempY, 16, i);
-        tempY += (i >> 2);
-        oscl_memset((uint8 *)tempU, 128, j);
-        tempU += (j >> 2);
-        oscl_memset((uint8 *)tempV, 128, j);
-        tempV += (j >> 2);
-    }
-    else
-    {
-        if (width_16 >= width)
-        {
-            i = (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-            inputRGB += (((height - height_16) >> 1) * width) >> 1;
-
-            oscl_memset((uint8 *)tempY, 16, i);
-            tempY += (i >> 2);
-            oscl_memset((uint8 *)tempU, 128, j);
-            tempU += (j >> 2);
-            oscl_memset((uint8 *)tempV, 128, j);
-            tempV += (j >> 2);
-
-        }
-        else
-        {
-            i = 0;
-            j = 0;
-            inputRGB += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) >> 1 ;
-        }
-    }
-
-    /* ColorConv RGB12-to-YUV420 with cropping or zero-padding */
-    if (height < height_16)
-    {
-        jlimit = height;
-    }
-    else
-    {
-        jlimit = height_16;
-    }
-
-    if (width < width_16)
-    {
-        ilimit = width >> 1;
-    }
-    else
-    {
-        ilimit = width_16 >> 1;
-    }
-
-    width = width_16 - width;
-
-
-    for (j = 0; j < jlimit; j++)
-    {
-
-        for (i = 0; i < ilimit; i += 4)
-        {
-            pixels =  inputRGB[i];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+1];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-            pixels =  inputRGB[i+2];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+3];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-
-            /* downsampling U, V */
-
-            pixels_nextRow = inputRGB[i+3+adjust/*(width>>1)*/];
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-
-            tmp  = B_ds - R_ds;
-
-            yuv_value1 = ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 24;
-            yuv_value2 = ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 24;
-
-            pixels =  inputRGB[i+2];
-            pixels_nextRow = inputRGB[i+2+adjust/*(width>>1)*/];
-
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-            tmp  = B_ds - R_ds;
-
-            yuv_value1 |= ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 16;
-            yuv_value2 |= ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 16;
-
-            pixels =  inputRGB[i+1];
-            pixels_nextRow = inputRGB[i+1+adjust /*(width>>1)*/];
-
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-            tmp  = B_ds - R_ds;
-
-
-            yuv_value1 |= ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18] << 8;
-            yuv_value2 |= ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18] << 8;
-
-            pixels =  inputRGB[i];
-            pixels_nextRow = inputRGB[i+adjust/*(width>>1)*/];
-
-            G_ds    =  pixels & 0x00F000F0;
-            G_ds   += (pixels_nextRow & 0x00F000F0);
-            G_ds   += (G_ds >> 16);
-
-            G_ds   -= 2; /* equivalent to adding constant 2<<16 = 131072 */
-
-            pixels &= 0x0F0F0F0F;
-            pixels += (pixels_nextRow & 0x0F0F0F0F);
-
-            pixels += (pixels >> 16);
-
-            B_ds = (pixels & 0x0003F) << 4;
-
-            R_ds = (pixels & 0x03F00) >> 4;
-            tmp  = B_ds - R_ds;
-
-            *tempU++ = yuv_value1 | (ipCb_Table[(((B_ds-G_ds)<<16) + 19525*tmp)>>18]);
-            *tempV++ = yuv_value2 | (ipCr_Table[(((R_ds-G_ds)<<16) -  6640*tmp)>>18]);
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-
-        if ((width > 0) && j < jlimit - 1)
-        {
-            oscl_memset((uint8 *)tempY, 16/*(*(tempY-1))>>24*/, width);
-            tempY += width >> 2;
-            oscl_memset((uint8 *)tempU, 128/*(*(tempU-1))>>24*/, width >> 1);
-            tempU += width >> 3;
-            oscl_memset((uint8 *)tempV, 128/*(*(tempV-1))>>24*/, width >> 1);
-            tempV += width >> 3;
-        }
-
-        if (j++ == (jlimit - 1))
-        {
-            break;          /* dealing with a odd height  */
-        }
-
-        inputRGB += adjust; /* (160/2 = 80 ) */ /*(width>>1)*/; /* move to the next row */
-
-        for (i = 0; i < ilimit; i += 4)
-        {
-            pixels =  inputRGB[i];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+1];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-            pixels =  inputRGB[i+2];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            yuv_value = (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]    |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8));
-
-            pixels =  inputRGB[i+3];
-            temp = (827 * (pixels & 0x000F000F) + 2435 * ((pixels & 0x0F000F00) >> 8));
-            *tempY++ = (yuv_value                                                         |
-                        (iY_Table[((temp&0x0FFFF)>> 9) + (pixels & 0x000000F0)]     |
-                         (iY_Table[(temp         >>25) + ((pixels & 0x00F00000)>>16)] << 8)) << 16);
-
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-        if ((width > 0) && j < jlimit - 1)
-        {
-            oscl_memset((uint8 *)tempY, 16/*(*(tempY-1))>>24*/, width);
-            tempY += width >> 2;
-        }
-
-        inputRGB += adjust; /* (160/2 = 80 ) */ /*(width>>1)*/; /* move to the next row */
-
-    } /* for(j=0; j<jlimit; j++)*/
-}
-#endif
-#ifdef RGB24_INPUT
-/* Assume B is in the first byte, G is in the second byte, and R is in the third byte, of a whole 3-octct group */
-void CPVM4VEncoder::RGB2YUV420_24bit(uint8 *inputRGB, Int width, Int height, Int width_16, Int height_16)
-{
-    Int i, j, ilimit, jlimit;
-    uint8 *tempY, *tempU, *tempV;
-    uint8 *inputRGB_prevRow = NULL;
-    int32 size16 = height_16 * width_16;
-    int32 adjust = (width + (width << 1));
-
-    /* do padding at the bottom first */
-    /* do padding if input RGB size(height) is different from the output YUV size(height_16) */
-    if (height < height_16 || width < width_16) /* if padding */
-    {
-        Int offset = (height < height_16) ? height : height_16;
-
-        offset = (offset * width_16);
-
-        if (width < width_16)
-        {
-            offset -= (width_16 - width);
-        }
-        tempY = iYUVIn + offset;
-        oscl_memset((uint8 *)tempY, 16, size16 - offset); /* pad with zeros */
-
-        tempU = iYUVIn + size16 + (offset >> 2);
-        oscl_memset((uint8 *)tempU, 128, (size16 - offset) >> 2);
-
-        tempV = iYUVIn + size16 + (size16 >> 2) + (offset >> 2);
-        oscl_memset((uint8 *)tempV, 128, (size16 - offset) >> 2);
-    }
-
-    /* then do padding on the top */
-    tempY = iYUVIn; /* Normal order */
-    tempU = iYUVIn + size16;
-    tempV = tempU + (size16 >> 2);
-
-    /* To center the output */
-    if (height_16 > height)
-    {
-        if (width_16 >= width)
-        {
-            i = ((height_16 - height) >> 1) * width_16 + (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = ((height_16 - height) >> 2) * (width_16 >> 1) + (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-        }
-        else
-        {
-            i = ((height_16 - height) >> 1) * width_16;
-            j = ((height_16 - height) >> 2) * (width_16 >> 1);
-            inputRGB += ((width - width_16) >> 1) * 3;
-        }
-        oscl_memset((uint8 *)tempY, 16, i);
-        tempY += i;
-        oscl_memset((uint8 *)tempU, 128, j);
-        tempU += j;
-        oscl_memset((uint8 *)tempV, 128, j);
-        tempV += j;
-    }
-    else
-    {
-        if (width_16 >= width)
-        {
-            i = (((width_16 - width) >> 3) << 2);
-            /* make sure that (width_16-width)>>1 is divisible by 4 */
-            j = (((width_16 - width) >> 4) << 2);
-            /* make sure that (width_16-width)>>2 is divisible by 4 */
-            inputRGB += (((height - height_16) >> 1) * width) * 3;
-        }
-        else
-        {
-            i = 0;
-            j = 0;
-            inputRGB += (((height - height_16) >> 1) * width + ((width - width_16) >> 1)) * 3;
-        }
-        oscl_memset((uint8 *)tempY, 16, i);
-        tempY += i;
-        oscl_memset((uint8 *)tempU, 128, j);
-        tempU += j;
-        oscl_memset((uint8 *)tempV, 128, j);
-        tempV += j;
-    }
-
-    /* ColorConv RGB24-to-YUV420 with cropping or zero-padding */
-    if (height < height_16)
-        jlimit = height;
-    else
-        jlimit = height_16;
-
-    if (width < width_16)
-        ilimit = width;
-    else
-        ilimit = width_16;
-
-    if (iFrameOrientation > 0)
-    {
-        inputRGB += (jlimit - 1) * width * 3 ; // move to last row
-        adjust = -adjust;
-    }
-
-
-    for (j = 0; j < jlimit; j++)
-    {
-        for (i = 0; i < ilimit*3; i += 3)
-        {
-
-            *tempY++ = iY_Table[(6616*inputRGB[i] + (inputRGB[i+1] << 16) + 19481 * inputRGB[i+2]) >> 16];
-
-            /* downsampling U, V */
-            if (j % 2 == 1 && i % 2 == 1)
-            {
-
-                *tempU++ = (unsigned char)((ipCb_Table[((inputRGB[i] << 16) - (inputRGB[i+1] << 16) + 19525 * (inputRGB[i] - inputRGB[i+2])) >> 16] + /* bottom right(current) */
-                                            ipCb_Table[((inputRGB[i-3] << 16) - (inputRGB[i-2] << 16) + 19525 * (inputRGB[i-3] - inputRGB[i-1])) >> 16] + /* bottom left */
-                                            ipCb_Table[((inputRGB_prevRow[i] << 16) - (inputRGB_prevRow[i+1] << 16) + 19525 * (inputRGB_prevRow[i] - inputRGB_prevRow[i+2])) >> 16] + /* top right */
-                                            ipCb_Table[((inputRGB_prevRow[i-3] << 16) - (inputRGB_prevRow[i-2] << 16) + 19525 * (inputRGB_prevRow[i-3] - inputRGB_prevRow[i-1])) >> 16]  + /* top left */
-                                            2) >> 2);
-
-
-                *tempV++ = (unsigned char)((ipCr_Table[((inputRGB[i+2] << 16) - (inputRGB[i+1] << 16) + 6640 * (inputRGB[i+2] - inputRGB[i])) >> 16] + /* bottom right(current) */
-                                            ipCr_Table[((inputRGB[i-1] << 16) - (inputRGB[i-2] << 16) + 6640 * (inputRGB[i-1] - inputRGB[i-3])) >> 16] + /* bottom left */
-                                            ipCr_Table[((inputRGB_prevRow[i+2] << 16) - (inputRGB_prevRow[i+1] << 16) + 6640 * (inputRGB_prevRow[i+2] - inputRGB_prevRow[i])) >> 16] + /* top right */
-                                            ipCr_Table[((inputRGB_prevRow[i-1] << 16) - (inputRGB_prevRow[i-2] << 16) + 6640 * (inputRGB_prevRow[i-1] - inputRGB_prevRow[i-3])) >> 16]  + /* top left */
-                                            2) >> 2);
-
-            }
-        }
-
-        /* do padding if input RGB size(width) is different from the output YUV size(width_16) */
-        if (width < width_16 && j < jlimit - 1)
-        {
-            oscl_memset(tempY, 16/* *(tempY-1)*/, width_16 - width);
-            tempY += (width_16 - width);
-
-            if (j % 2 == 1)
-            {
-                oscl_memset(tempU, 128/* *(tempU-1)*/, (width_16 - width) >> 1);
-                tempU += (width_16 - width) >> 1;
-                oscl_memset(tempV, 128/* *(tempV-1)*/, (width_16 - width) >> 1);
-                tempV += (width_16 - width) >> 1;
-            }
-        }
-
-        inputRGB_prevRow = inputRGB;
-        inputRGB += adjust ; /* move to the next row */
-    }
-
-}
-#endif
-
 #ifdef FOR_3GPP_COMPLIANCE
 void CPVM4VEncoder::Check3GPPCompliance(TPVVideoEncodeParam *aEncParam, Int *aEncWidth, Int *aEncHeight)
 {
diff --git a/codecs_v2/video/m4v_h263/enc/src/rate_control.cpp b/codecs_v2/video/m4v_h263/enc/src/rate_control.cpp
index d6559e1..c3e46e1 100644
--- a/codecs_v2/video/m4v_h263/enc/src/rate_control.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/rate_control.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -185,6 +185,9 @@
     Int currLayer = video->currLayer;
     Vol *currVol = video->vol[currLayer];
     Vop *currVop = video->currVop;
+#ifdef TEST_MBBASED_QP
+    int i;
+#endif
 
     rateControl *rc = video->rc[currLayer];
     MultiPass *pMP = video->pMP[currLayer];
@@ -193,9 +196,7 @@
 
     if (video->encParams->RC_Type == CONSTANT_Q)
     {
-
         M4VENC_MEMSET(video->QPMB, currVop->quantizer, sizeof(UChar)*currVol->nTotalMB);
-
         return PV_SUCCESS;
     }
     else
@@ -210,7 +211,16 @@
         {
             calculateQuantizer_Multipass((void*) video);
             currVop->quantizer = video->rc[currLayer]->Qc;
+#ifdef TEST_MBBASED_QP
+            i = currVol->nTotalMB;  /* testing changing QP at MB level */
+            while (i)
+            {
+                i--;
+                video->QPMB[i] = (i & 1) ? currVop->quantizer - 1 : currVop->quantizer + 1;
+            }
+#else
             M4VENC_MEMSET(video->QPMB, currVop->quantizer, sizeof(UChar)*currVol->nTotalMB);
+#endif
         }
 
         video->header_bits = 0;
diff --git a/codecs_v2/video/m4v_h263/enc/src/rate_control.h b/codecs_v2/video/m4v_h263/enc/src/rate_control.h
index b4fd945..0d9f480 100644
--- a/codecs_v2/video/m4v_h263/enc/src/rate_control.h
+++ b/codecs_v2/video/m4v_h263/enc/src/rate_control.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/sad.cpp b/codecs_v2/video/m4v_h263/enc/src/sad.cpp
index e29cde7..92b8190 100644
--- a/codecs_v2/video/m4v_h263/enc/src/sad.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/sad.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -72,8 +72,8 @@
     	To do:		Uniform subsampling will be inserted later!
     				Hypothesis Testing Fast Matching to be used later!
     	Changes:
-    	11/7/00:	 implemented MMX
-    	1/24/01:	 implemented SSE
+    11/7/00:	 implemented MMX
+    1/24/01:	 implemented SSE
     ==================================================================*/
     /********** C ************/
     Int SAD_Macroblock_C(UChar *ref, UChar *blk, Int dmin_lx, void *extra_info)
@@ -308,8 +308,8 @@
     	To do:		Uniform subsampling will be inserted later!
     				Hypothesis Testing Fast Matching to be used later!
     	Changes:
-    	11/7/00:	 implemented MMX
-    	1/24/01:	 implemented SSE
+    11/7/00:	 implemented MMX
+    1/24/01:	 implemented SSE
       ==================================================================*/
     /********** C ************/
     Int SAD_Block_C(UChar *ref, UChar *blk, Int dmin, Int lx, void *)
diff --git a/codecs_v2/video/m4v_h263/enc/src/sad_halfpel.cpp b/codecs_v2/video/m4v_h263/enc/src/sad_halfpel.cpp
index 98ad015..6f0698d 100644
--- a/codecs_v2/video/m4v_h263/enc/src/sad_halfpel.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/sad_halfpel.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -209,7 +209,7 @@
     	Input/Output:	hmem is assumed to be a pointer to the starting
     				point of the search in the 33x33 matrix search region
     	Changes:
-    	11/7/00:	 implemented MMX
+    11/7/00:	 implemented MMX
       ===============================================================*/
     /*==================================================================
     	Function:	SAD_MB_HalfPel_C
diff --git a/codecs_v2/video/m4v_h263/enc/src/sad_halfpel_inline.h b/codecs_v2/video/m4v_h263/enc/src/sad_halfpel_inline.h
index dc28c07..006be59 100644
--- a/codecs_v2/video/m4v_h263/enc/src/sad_halfpel_inline.h
+++ b/codecs_v2/video/m4v_h263/enc/src/sad_halfpel_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
 {
 #endif
 
-#if !defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#if !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) /* ARM GNU COMPILER  */
 
     __inline int32 INTERP1_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
     {
@@ -75,7 +75,7 @@
         return sad;
     }
 
-#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#elif ( defined(PV_ARM_GCC_V5) || defined(PV_ARM_GCC_V4) ) /* ARM GNU COMPILER  */
 
 
     __inline int32 INTERP1_SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
diff --git a/codecs_v2/video/m4v_h263/enc/src/sad_inline.h b/codecs_v2/video/m4v_h263/enc/src/sad_inline.h
index 1fd99b9..83f3315 100644
--- a/codecs_v2/video/m4v_h263/enc/src/sad_inline.h
+++ b/codecs_v2/video/m4v_h263/enc/src/sad_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
 {
 #endif
 
-#if !defined(PV_ARM_GCC)&& defined(__arm__) /* ARM GNU COMPILER  */
+#if !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) /* ARM GNU COMPILER  */
 
     __inline int32 SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
     {
@@ -341,7 +341,7 @@
     }
 
 
-#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#elif ( defined(PV_ARM_GCC_V5) || defined(PV_ARM_GCC_V4) ) /* ARM GNU COMPILER  */
 
     __inline int32 SUB_SAD(int32 sad, int32 tmp, int32 tmp2)
     {
diff --git a/codecs_v2/video/m4v_h263/enc/src/sad_mb_offset.h b/codecs_v2/video/m4v_h263/enc/src/sad_mb_offset.h
index 3ff9161..12d21fb 100644
--- a/codecs_v2/video/m4v_h263/enc/src/sad_mb_offset.h
+++ b/codecs_v2/video/m4v_h263/enc/src/sad_mb_offset.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,13 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+/*********************************************************************************/
 /*  Filename: sad_mb_offset.h														*/
 /*  Description: Implementation for in-line functions used in dct.cpp			*/
 /*  Modified:																	*/
 /*********************************************************************************/
 
-#if !defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#if !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_GCC_V5) /* ARM GNU COMPILER  */
 
 #if (NUMBER==3)
 __inline int32 sad_mb_offset3(UChar *ref, UChar *blk, Int lx, Int dmin)
@@ -216,7 +217,7 @@
     return ((uint32)x10 >> 16);
 }
 
-#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#elif ( defined(PV_ARM_GCC_V5) || defined(PV_ARM_GCC_V4) ) /* ARM GNU COMPILER  */
 
 #if (NUMBER==3)
 __inline int32 sad_mb_offset3(UChar *ref, UChar *blk, Int lx, Int dmin)
diff --git a/codecs_v2/video/m4v_h263/enc/src/vlc_enc_tab.h b/codecs_v2/video/m4v_h263/enc/src/vlc_enc_tab.h
index 30bfa08..d31e6f6 100644
--- a/codecs_v2/video/m4v_h263/enc/src/vlc_enc_tab.h
+++ b/codecs_v2/video/m4v_h263/enc/src/vlc_enc_tab.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/vlc_encode.cpp b/codecs_v2/video/m4v_h263/enc/src/vlc_encode.cpp
index 06e3943..d78135c 100644
--- a/codecs_v2/video/m4v_h263/enc/src/vlc_encode.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/vlc_encode.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -167,10 +167,10 @@
 
     void RunLevel(VideoEncData *video, Int intra, Int intraDC_decision, Int ncoefblck[]);
     Int IntraDC_dpcm(Int val, Int lum, BitstreamEncVideo *bitstream);
-    Void DCACPred(VideoEncData *video, UChar Mode, Int *intraDC_decision);
+    Void DCACPred(VideoEncData *video, UChar Mode, Int *intraDC_decision, Int intraDCVlcQP);
     Void find_pmvs(VideoEncData *video, Int block, Int *mvx, Int *mvy);
     Void  WriteMVcomponent(Int f_code, Int dmv, BitstreamEncVideo *bs);
-    static Bool IntraDCSwitch_Decision(Int Mode, Int intra_dc_vlc_thr, Int Qp);
+    static Bool IntraDCSwitch_Decision(Int Mode, Int intra_dc_vlc_threshold, Int intraDCVlcQP);
 
     Void ScaleMVD(Int  f_code, Int  diff_vector, Int  *residual, Int  *vlc_code_mag);
 
@@ -880,7 +880,6 @@
 
 void MBVlcEncodeDataPar_I_VOP(
     VideoEncData *video,
-    Int	QP_prev,
     Int ncoefblck[],
     void *blkCodePtr)
 {
@@ -900,14 +899,21 @@
     BlockCodeCoeffPtr BlockCodeCoeff =	(BlockCodeCoeffPtr) blkCodePtr;
 
     /* DC and AC Prediction, 5/28/01, compute CBP, intraDC_decision*/
-    DCACPred(video, Mode, &intraDC_decision);
+    DCACPred(video, Mode, &intraDC_decision, video->QP_prev);
 
     /* CBP, Run, Level, and Sign */
     RunLevel(video, 1, intraDC_decision, ncoefblck);
     CBP = video->headerInfo.CBP[mbnum];
 
     /* Compute DQuant */
-    dquant = video->QPMB[mbnum] - QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+    dquant = video->QPMB[mbnum] - video->QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+
+    video->QP_prev = video->QPMB[mbnum];
+
+    if (dquant && Mode == MODE_INTRA)
+    {
+        Mode = MODE_INTRA_Q;
+    }
 
     if (dquant >= 0)
         dquant = (PV_ABS(dquant) + 1);
@@ -950,7 +956,7 @@
     for (i = 0;i < 6;i++)
     {
         if (CBP&(1 << (5 - i)))
-            (*BlockCodeCoeff)(&(RLB[i]), bs3, 1, ncoefblck[i], Mode);/* Code Intra AC*/
+            (*BlockCodeCoeff)(&(RLB[i]), bs3, 1 - intraDC_decision, ncoefblck[i], Mode);/* Code Intra AC*/
     }
 
     return ;
@@ -962,7 +968,6 @@
 
 void MBVlcEncodeDataPar_P_VOP(
     VideoEncData *video,
-    Int QP_prev,
     Int ncoefblck[],
     void *blkCodePtr)
 {
@@ -971,10 +976,11 @@
     BitstreamEncVideo *bs2 = video->bitstream2;
     BitstreamEncVideo *bs3 = video->bitstream3;
     int i;
-    UChar Mode = video->headerInfo.Mode[video->mbnum];
+    Int mbnum = video->mbnum;
+    UChar Mode = video->headerInfo.Mode[mbnum];
+    Int QP_tmp = video->QPMB[mbnum];
     UChar CBP;
 //	MacroBlock *MB=video->outputMB;
-    Int mbnum = video->mbnum;
     Int intra, intraDC_decision, DC;
     Int pmvx, pmvy;
 //	int temp;
@@ -987,7 +993,14 @@
     /* DC and AC Prediction, 5/28/01, compute CBP, intraDC_decision*/
 
     if (intra)
-        DCACPred(video, Mode, &intraDC_decision);
+    {
+        if (video->usePrevQP)
+        {
+            QP_tmp = video->QPMB[mbnum-1];
+        }
+
+        DCACPred(video, Mode, &intraDC_decision, QP_tmp);
+    }
     else
         intraDC_decision = 0; /* used in RunLevel */
 
@@ -996,7 +1009,12 @@
     CBP = video->headerInfo.CBP[mbnum];
 
     /* Compute DQuant */
-    dquant = video->QPMB[mbnum] - QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+    dquant = video->QPMB[mbnum] - video->QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+
+    if (dquant && (Mode == MODE_INTRA || Mode == MODE_INTER))
+    {
+        Mode += 2;  /* make it MODE_INTRA_Q and MODE_INTER_Q */
+    }
 
     if (dquant >= 0)
         dquant = (PV_ABS(dquant) + 1);
@@ -1025,6 +1043,9 @@
     else
         BitstreamPut1Bits(bs1, 0); /* not_coded =0 */
 
+    video->QP_prev = video->QPMB[mbnum];
+    video->usePrevQP = 1;
+
     PutMCBPC_Inter(CBP, Mode, bs1); /* MCBPC */
 
     video->header_bits -= BitstreamGetPos(bs1); /* Header Bits */
@@ -1057,7 +1078,7 @@
 
         if (Mode == MODE_INTRA_Q)
             BitstreamPutBits(bs2, 2, dquant);  /* dquant, 3/15/01*/
-        //intraDC_decision = IntraDCSwitch_Decision(Mode,video->currVop->intraDCVlcThr,video->QPMB[mbnum]);
+
         if (intraDC_decision == 0)
         {
             for (i = 0; i < 6; i++)
@@ -1076,7 +1097,7 @@
         for (i = 0;i < 6;i++)
         {
             if (CBP&(1 << (5 - i)))
-                (*BlockCodeCoeff)(&(RLB[i]), bs3, 1, ncoefblck[i], Mode);/* Code Intra AC*/
+                (*BlockCodeCoeff)(&(RLB[i]), bs3, 1 - intraDC_decision, ncoefblck[i], Mode);/* Code Intra AC*/
         }
     }
     else
@@ -1105,7 +1126,6 @@
 
 void MBVlcEncodeCombined_I_VOP(
     VideoEncData *video,
-    Int QP_prev,
     Int ncoefblck[],
     void *blkCodePtr)
 {
@@ -1130,7 +1150,7 @@
 
 #ifndef H263_ONLY
     if (!shortVideoHeader)
-        DCACPred(video, Mode, &intraDC_decision);
+        DCACPred(video, Mode, &intraDC_decision, video->QP_prev);
     else
 #endif
     {
@@ -1143,7 +1163,14 @@
     CBP = video->headerInfo.CBP[mbnum];
 
     /* Compute DQuant */
-    dquant = video->QPMB[mbnum] - QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+    dquant = video->QPMB[mbnum] - video->QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+
+    video->QP_prev = video->QPMB[mbnum];
+
+    if (dquant && Mode == MODE_INTRA)
+    {
+        Mode = MODE_INTRA_Q;
+    }
 
     if (dquant >= 0)
         dquant = (PV_ABS(dquant) + 1);
@@ -1215,7 +1242,6 @@
 
 void MBVlcEncodeCombined_P_VOP(
     VideoEncData *video,
-    Int QP_prev,
     Int ncoefblck[],
     void *blkCodePtr)
 {
@@ -1224,10 +1250,11 @@
 //	BitstreamEncVideo *bs2 = video->bitstream2;
 //	BitstreamEncVideo *bs3 = video->bitstream3;
     int i;
-    UChar Mode = video->headerInfo.Mode[video->mbnum];
+    Int mbnum = video->mbnum;
+    UChar Mode = video->headerInfo.Mode[mbnum];
+    Int QP_tmp = video->QPMB[mbnum];
     UChar CBP ;
 //	MacroBlock *MB=video->outputMB;
-    Int mbnum = video->mbnum;
     Int intra, intraDC_decision;
     Int pmvx, pmvy;
 //	int temp;
@@ -1242,7 +1269,13 @@
     /* DC and AC Prediction, 5/28/01, compute intraDC_decision*/
 #ifndef H263_ONLY
     if (!shortVideoHeader && intra)
-        DCACPred(video, Mode, &intraDC_decision);
+    {
+        if (video->usePrevQP)
+        {
+            QP_tmp = video->QPMB[mbnum-1];
+        }
+        DCACPred(video, Mode, &intraDC_decision, QP_tmp);
+    }
     else
 #endif
         intraDC_decision = 0;
@@ -1253,7 +1286,11 @@
     CBP = video->headerInfo.CBP[mbnum];
 
     /* Compute DQuant */
-    dquant = video->QPMB[mbnum] - QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+    dquant = video->QPMB[mbnum] - video->QP_prev; /* 3/15/01, QP_prev may not equal QPMB[mbnum-1] if mbnum-1 is skipped*/
+    if (dquant && (Mode == MODE_INTRA || Mode == MODE_INTER))
+    {
+        Mode += 2;  /* make it MODE_INTRA_Q and MODE_INTER_Q */
+    }
 
     if (dquant >= 0)
         dquant = (PV_ABS(dquant) + 1);
@@ -1279,6 +1316,9 @@
     else
         BitstreamPut1Bits(bs1, 0); /* not_coded =0 */
 
+    video->QP_prev = video->QPMB[mbnum];
+    video->usePrevQP = 1;
+
     PutMCBPC_Inter(CBP, Mode, bs1);	/* mcbpc P_VOP */
 
     if (!video->vol[video->currLayer]->shortVideoHeader && intra)
@@ -1883,7 +1923,7 @@
 extern "C"
 {
 #endif
-    static Bool IntraDCSwitch_Decision(Int Mode, Int intra_dc_vlc_thr, Int Qp)
+    static Bool IntraDCSwitch_Decision(Int Mode, Int intra_dc_vlc_thr, Int intraDCVlcQP)
     {
         Bool switched = FALSE;
 
@@ -1891,7 +1931,7 @@
         {
             if (intra_dc_vlc_thr != 0)
             {
-                switched = (intra_dc_vlc_thr == 7 || Qp >= intra_dc_vlc_thr * 2 + 11);
+                switched = (intra_dc_vlc_thr == 7 || intraDCVlcQP >= intra_dc_vlc_thr * 2 + 11);
             }
         }
 
@@ -1958,34 +1998,42 @@
 		UChar			Mode												*/
 /*	Return   :																*/
 /*																			*/
-/*	Modified :	8/13/01,  remove Idir_Enc, use multiply-shift instead
-				of division and check QP and QPtmp							*/
 /* ======================================================================== */
 Int cal_dc_scalerENC(Int QP, Int type) ;
-const static short scaleArrayQP[32] = {0, 16384, 8192, 5462,  /* 15 */
+
+#if 0 // optimize div by QP, doesn't work. 
+const static short scaleArrayQP[32] = {0, 16384, 8192, 5462,  /* 14 */
                                        4096, 3277, 2731, 2341,
-                                       4096, 3641, 3277, 2979,  /* 16 */
+                                       4096, 3641, 3277, 2979,  /* 15 */
                                        2731, 2521, 2341, 2185,
-                                       4096, 3856, 3641, 3450,  /* 17 */
+                                       4096, 3856, 3641, 3450,  /* 16 */
                                        3277, 3121, 2979, 2850,
-                                       5462, 5243, 5042, 4855,  /* 18 */
+                                       5462, 5243, 5042, 4855,  /* 17 */
                                        4682, 4520, 4370, 4229
                                       };
-
-
 #define PREDICT_AC  for (m = 0; m < 7; m++){ \
 						tmp = DCAC[0]*QPtmp;\
-						if(tmp<0)	tmp = (tmp-QP);\
-						else		tmp = (tmp+QP);\
+						if(tmp<0)	tmp = (tmp-(QP/2));\
+						else		tmp = (tmp+(QP/2));\
 						tmp = tmp*scaleQP;\
 						tmp>>=shiftQP;\
 						tmp+=((UInt)tmp>>31);\
+                        pred[m] = tmp;\
+						DCAC++;\
+					}
+#else
+
+#define PREDICT_AC  for (m = 0; m < 7; m++){ \
+						tmp = DCAC[0]*QPtmp;\
+						if(tmp<0)	tmp = (tmp-(QP/2))/QP;\
+						else		tmp = (tmp+(QP/2))/QP;\
 						pred[m] = tmp;\
 						DCAC++;\
 					}
 
+#endif
 
-Void DCACPred(VideoEncData *video, UChar Mode, Int *intraDC_decision)
+Void DCACPred(VideoEncData *video, UChar Mode, Int *intraDC_decision, Int intraDCVlcQP)
 {
     MacroBlock *MB = video->outputMB;
     Int mbnum = video->mbnum;
@@ -2000,10 +2048,13 @@
     Int x_pos = video->outputMB->mb_x; /* 5/28/01 */
     Int y_pos = video->outputMB->mb_y;
     UChar QP = video->QPMB[mbnum];
+#if 0
     Int	  scaleQP = scaleArrayQP[QP];
-    Int	  shiftQP = 15 + (QP >> 3);
+    Int	  shiftQP = 14 + (QP >> 3);
+#endif
     UChar *QPMB = video->QPMB;
     UChar *slice_nb = video->sliceNo;
+    Bool bACPredEnable = video->encParams->ACDCPrediction;
     Int *ACpred_flag = video->acPredFlag;
     Int mid_grey = 128 << 3;
     Int m;
@@ -2054,7 +2105,10 @@
             *DCAC++ = mid_grey;
             *DCAC++ = mid_grey;
             /* set to 0 DCAC_row[x_pos][0..3] */
-            M4VENC_MEMSET(DCAC_row[x_pos][0], 0, sizeof(Short) << 5);
+            if (bACPredEnable == TRUE)
+            {
+                M4VENC_MEMSET(DCAC_row[x_pos][0], 0, sizeof(Short) << 5);
+            }
         }
     }
     if (x_pos > 0)
@@ -2070,10 +2124,16 @@
             *DCAC++ = mid_grey;
             *DCAC++ = mid_grey;
             /* set to 0 DCAC_col[x_pos][0..3] */
-            M4VENC_MEMSET(DCAC_col[0][0], 0, sizeof(Short) << 5);
+            if (bACPredEnable == TRUE)
+            {
+                M4VENC_MEMSET(DCAC_col[0][0], 0, sizeof(Short) << 5);
+            }
         }
     }
 
+    S1 = 0;
+    S2 = 0;
+
     for (comp = 0; comp < 6; comp++)
     {
 
@@ -2167,287 +2227,281 @@
         qcoeff[0] -= (DC_pred + QPtmp / 2) / QPtmp;
 
 
-        /***********************/
-        /* Find AC prediction  */
-        /***********************/
-
-        if ((x_pos == 0) && y_pos == 0) 	/* top left corner */
+        if (bACPredEnable)
         {
-            if (direction[comp] == 0)
+            /***********************/
+            /* Find AC prediction  */
+            /***********************/
+
+            if ((x_pos == 0) && y_pos == 0) 	/* top left corner */
             {
-                if (comp == 1 || comp == 3)
+                if (direction[comp] == 0)
                 {
-                    QPtmp = QPMB[mbnum+x_offset] << 1;
-                    DCAC = DCAC_col[0][b_ytab];
-                    if (QPtmp != QP)
+                    if (comp == 1 || comp == 3)
                     {
-                        predptr = pred;
-                        PREDICT_AC
+                        QPtmp = QPMB[mbnum+x_offset];
+                        DCAC = DCAC_col[0][b_ytab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
                     }
                     else
                     {
-                        predptr = DCAC;
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
                     }
                 }
                 else
                 {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
+                    if (comp == 2 || comp == 3)
+                    {
+                        QPtmp = QPMB[mbnum+ y_offset];
+                        DCAC = DCAC_row[x_pos][b_xtab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
+                    }
+                    else
+                    {
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
+                    }
+                }
+            }
+            else if (x_pos == 0) 	/* left edge */
+            {
+                if (direction[comp] == 0)
+                {
+                    if (comp == 1 || comp == 3)
+                    {
+                        QPtmp = QPMB[mbnum+x_offset];
+                        DCAC = DCAC_col[0][b_ytab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
+                    }
+                    else
+                    {
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
+                    }
+                }
+                else
+                {
+
+                    if ((Pos0[comp] && (slice_nb[mbnum] == slice_nb[mbnum-nMBPerRow]))
+                            || comp == 2 || comp == 3)
+                    {
+                        QPtmp = QPMB[mbnum+y_offset];
+                        DCAC = DCAC_row[x_pos][b_xtab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
+                    }
+                    else
+                    {
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
+                    }
+                }
+            }
+            else if (y_pos == 0)  /* top row */
+            {
+                if (direction[comp] == 0)
+                {
+                    if ((Pos1[comp] && (slice_nb[mbnum] == slice_nb[mbnum-1]))
+                            || comp == 1 || comp == 3)
+                    {
+                        QPtmp = QPMB[mbnum+x_offset];
+                        DCAC = DCAC_col[0][b_ytab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
+                    }
+                    else
+                    {
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
+                    }
+                }
+                else
+                {
+                    if (comp == 2 || comp == 3)
+                    {
+                        QPtmp = QPMB[mbnum+y_offset];
+                        DCAC = DCAC_row[x_pos][b_xtab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
+                    }
+                    else
+                    {
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
+                    }
                 }
             }
             else
             {
-                if (comp == 2 || comp == 3)
+                if (direction[comp] == 0)
                 {
-                    QPtmp = QPMB[mbnum+ y_offset] << 1;
-                    DCAC = DCAC_row[x_pos][b_xtab];
-                    if (QPtmp != QP)
+                    if ((Pos1[comp] && (slice_nb[mbnum] == slice_nb[mbnum-1]))
+                            || comp == 1 || comp == 3)
                     {
-                        predptr = pred;
-                        PREDICT_AC
+                        QPtmp = QPMB[mbnum+x_offset];
+                        DCAC = DCAC_col[0][b_ytab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
                     }
                     else
                     {
-                        predptr = DCAC;
+                        predptr = pred;
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
                     }
                 }
                 else
                 {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
-                }
-            }
-        }
-        else if (x_pos == 0) 	/* left edge */
-        {
-            if (direction[comp] == 0)
-            {
-                if (comp == 1 || comp == 3)
-                {
-                    QPtmp = QPMB[mbnum+x_offset] << 1;
-                    DCAC = DCAC_col[0][b_ytab];
-                    if (QPtmp != QP)
+                    if ((Pos0[comp] && (slice_nb[mbnum] == slice_nb[mbnum-nMBPerRow]))
+                            || comp  == 2 || comp == 3)
                     {
-                        predptr = pred;
-                        PREDICT_AC
+                        QPtmp = QPMB[mbnum+y_offset];
+                        DCAC = DCAC_row[x_pos][b_xtab];
+                        if (QPtmp != QP)
+                        {
+                            predptr = pred;
+                            PREDICT_AC
+                        }
+                        else
+                        {
+                            predptr = DCAC;
+                        }
                     }
                     else
                     {
-                        predptr = DCAC;
-                    }
-                }
-                else
-                {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
-                }
-            }
-            else
-            {
-
-                if ((Pos0[comp] && (slice_nb[mbnum] == slice_nb[mbnum-nMBPerRow]))
-                        || comp == 2 || comp == 3)
-                {
-                    QPtmp = QPMB[mbnum+y_offset] << 1;
-                    DCAC = DCAC_row[x_pos][b_xtab];
-                    if (QPtmp != QP)
-                    {
                         predptr = pred;
-                        PREDICT_AC
+                        pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
                     }
-                    else
-                    {
-                        predptr = DCAC;
-                    }
-                }
-                else
-                {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
                 }
             }
-        }
-        else if (y_pos == 0)  /* top row */
-        {
-            if (direction[comp] == 0)
-            {
-                if ((Pos1[comp] && (slice_nb[mbnum] == slice_nb[mbnum-1]))
-                        || comp == 1 || comp == 3)
-                {
-                    QPtmp = QPMB[mbnum+x_offset] << 1;
-                    DCAC = DCAC_col[0][b_ytab];
-                    if (QPtmp != QP)
-                    {
-                        predptr = pred;
-                        PREDICT_AC
-                    }
-                    else
-                    {
-                        predptr = DCAC;
-                    }
-                }
-                else
-                {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
-                }
-            }
-            else
-            {
-                if (comp == 2 || comp == 3)
-                {
-                    QPtmp = QPMB[mbnum+y_offset] << 1;
-                    DCAC = DCAC_row[x_pos][b_xtab];
-                    if (QPtmp != QP)
-                    {
-                        predptr = pred;
-                        PREDICT_AC
-                    }
-                    else
-                    {
-                        predptr = DCAC;
-                    }
-                }
-                else
-                {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
-                }
-            }
-        }
-        else
-        {
-            if (direction[comp] == 0)
-            {
-                if ((Pos1[comp] && (slice_nb[mbnum] == slice_nb[mbnum-1]))
-                        || comp == 1 || comp == 3)
-                {
-                    QPtmp = QPMB[mbnum+x_offset] << 1;
-                    DCAC = DCAC_col[0][b_ytab];
-                    if (QPtmp != QP)
-                    {
-                        predptr = pred;
-                        PREDICT_AC
-                    }
-                    else
-                    {
-                        predptr = DCAC;
-                    }
-                }
-                else
-                {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
-                }
-            }
-            else
-            {
-                if ((Pos0[comp] && (slice_nb[mbnum] == slice_nb[mbnum-nMBPerRow]))
-                        || comp  == 2 || comp == 3)
-                {
-                    QPtmp = QPMB[mbnum+y_offset] << 1;
-                    DCAC = DCAC_row[x_pos][b_xtab];
-                    if (QPtmp != QP)
-                    {
-                        predptr = pred;
-                        PREDICT_AC
-                    }
-                    else
-                    {
-                        predptr = DCAC;
-                    }
-                }
-                else
-                {
-                    predptr = pred;
-                    pred[0] = pred[1] = pred[2] = pred[3] = pred[4] = pred[5] = pred[6] = 0;
-                }
-            }
-        }
 
-        /****************************/
-        /*  Store DCAC coefficients */
-        /****************************/
-        /* Store coeff values for Intra MB */
-        DCAC = DCAC_row[x_pos][b_xtab];
-        DCAC[0] = qcoeff[1];
-        DCAC[1] = qcoeff[2];
-        DCAC[2] = qcoeff[3];
-        DCAC[3] = qcoeff[4];
-        DCAC[4] = qcoeff[5];
-        DCAC[5] = qcoeff[6];
-        DCAC[6] = qcoeff[7];
+            /************************************/
+            /* Decide and Perform AC prediction */
+            /************************************/
+            newCBP[comp] = 0;
 
-        DCAC = DCAC_col[0][b_ytab];
-        DCAC[0] = qcoeff[8];
-        DCAC[1] = qcoeff[16];
-        DCAC[2] = qcoeff[24];
-        DCAC[3] = qcoeff[32];
-        DCAC[4] = qcoeff[40];
-        DCAC[5] = qcoeff[48];
-        DCAC[6] = qcoeff[56];
-
-        /************************************/
-        /* Decide and Perform AC prediction */
-        /************************************/
-
-        S1 = 0;
-        S2 = 0;
-        newCBP[comp] = 0;
-
-        if (direction[comp] == 0)  	/* Horizontal, left COLUMN of block A */
-        {
-            DCAC = pcoeff + comp * 7;
-            qcoeff += 8;
-            for (m = 0; m < 7; m++)
+            if (direction[comp] == 0)  	/* Horizontal, left COLUMN of block A */
             {
-                QPtmp = qcoeff[m<<3];
-                if (QPtmp > 0)	S1 += QPtmp;
-                else		S1 -= QPtmp;
-                QPtmp -= predptr[m];
-                DCAC[m] = QPtmp;
-                if (QPtmp)	newCBP[comp] = 1;
-                diff = PV_ABS(QPtmp);
-                if (diff > 2047)
+                DCAC = pcoeff + comp * 7; /* re-use DCAC as local var */
+                qcoeff += 8;
+                for (m = 0; m < 7; m++)
                 {
-                    S = -1;
-                    break;
+                    QPtmp = qcoeff[m<<3];
+                    if (QPtmp > 0)	S1 += QPtmp;
+                    else		S1 -= QPtmp;
+                    QPtmp -= predptr[m];
+                    DCAC[m] = QPtmp; /* save prediction residue to pcoeff*/
+                    if (QPtmp)	newCBP[comp] = 1;
+                    diff = PV_ABS(QPtmp);
+                    S2 += diff;
                 }
-                S2 += diff;
             }
-        }
-        else  			/* Vertical, top ROW of block C */
-        {
-            qcoeff++;
-            DCAC = pcoeff + comp * 7;
-            for (m = 0; m < 7; m++)
+            else  			/* Vertical, top ROW of block C */
             {
-                QPtmp = qcoeff[m];
-                if (QPtmp > 0)	S1 += QPtmp;
-                else		S1 -= QPtmp;
-                QPtmp -= predptr[m];
-                DCAC[m] = QPtmp;
-                if (QPtmp)	newCBP[comp] = 1;
-                diff = PV_ABS(QPtmp);
-                if (diff > 2047)
+                qcoeff++;
+                DCAC = pcoeff + comp * 7; /* re-use DCAC as local var */
+                for (m = 0; m < 7; m++)
                 {
-                    S = -1;
-                    break;
+                    QPtmp = qcoeff[m];
+                    if (QPtmp > 0)	S1 += QPtmp;
+                    else		S1 -= QPtmp;
+                    QPtmp -= predptr[m];
+                    DCAC[m] = QPtmp; /* save prediction residue to pcoeff*/
+                    if (QPtmp)	newCBP[comp] = 1;
+                    diff = PV_ABS(QPtmp);
+                    S2 += diff;
                 }
-                S2 += diff;
             }
-        }
 
-        if (diff > 2047)
-            break;
-        S += (S1 - S2);
+            /****************************/
+            /*  Store DCAC coefficients */
+            /****************************/
+            /* Store coeff values for Intra MB */
+            qcoeff = MB->block[comp];
+            DCAC = DCAC_row[x_pos][b_xtab];
+            DCAC[0] = qcoeff[1];
+            DCAC[1] = qcoeff[2];
+            DCAC[2] = qcoeff[3];
+            DCAC[3] = qcoeff[4];
+            DCAC[4] = qcoeff[5];
+            DCAC[5] = qcoeff[6];
+            DCAC[6] = qcoeff[7];
+
+            DCAC = DCAC_col[0][b_ytab];
+            DCAC[0] = qcoeff[8];
+            DCAC[1] = qcoeff[16];
+            DCAC[2] = qcoeff[24];
+            DCAC[3] = qcoeff[32];
+            DCAC[4] = qcoeff[40];
+            DCAC[5] = qcoeff[48];
+            DCAC[6] = qcoeff[56];
+
+
+        } /* bACPredEnable */
+
     } /* END COMP FOR LOOP */
 
+    //if (diff > 2047)
+    //    break;
+    S += (S1 - S2);
 
-    if (S >= 0)
+
+    if (S >= 0 && bACPredEnable == TRUE)
     {
         ACpred_flag[mbnum] = 1;
-        DCAC = pcoeff;
+        DCAC = pcoeff; /* prediction residue */
         qcoeff = MB->block[0];
 
         for (comp = 0; comp < 6; comp++)
@@ -2484,7 +2538,7 @@
         ACpred_flag[mbnum] = 0;
     }
 
-    *intraDC_decision = IntraDCSwitch_Decision(Mode, video->currVop->intraDCVlcThr, QP);
+    *intraDC_decision = IntraDCSwitch_Decision(Mode, video->currVop->intraDCVlcThr, intraDCVlcQP);
     if (*intraDC_decision) /* code DC with AC , 5/28/01*/
     {
         qcoeff = MB->block[0];
diff --git a/codecs_v2/video/m4v_h263/enc/src/vlc_encode.h b/codecs_v2/video/m4v_h263/enc/src/vlc_encode.h
index b2b8102..3721b6b 100644
--- a/codecs_v2/video/m4v_h263/enc/src/vlc_encode.h
+++ b/codecs_v2/video/m4v_h263/enc/src/vlc_encode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h b/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
index 69857f3..0cf8317 100644
--- a/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
+++ b/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 #ifndef _VLC_ENCODE_INLINE_H_
 #define _VLC_ENCODE_INLINE_H_
 
-#if !defined(PV_ARM_GCC)&& defined(__arm__)
+#if !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4)
 
 __inline  Int zero_run_search(UInt *bitmapzz, Short *dataBlock, RunLevelBlock *RLB, Int nc)
 {
@@ -112,6 +112,7 @@
 
 __inline  Int zero_run_search(UInt *bitmapzz, Short *dataBlock, RunLevelBlock *RLB, Int nc)
 {
+    OSCL_UNUSED_ARG(nc);
     Int idx, run, level, j;
     UInt end, match;
     Int  zzorder;
@@ -208,7 +209,7 @@
     return idx;
 }
 
-#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
+#elif ( defined(PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5) ) /* ARM GNU COMPILER  */
 
 __inline Int m4v_enc_clz(UInt temp)
 {
@@ -225,6 +226,7 @@
 
 __inline  Int zero_run_search(UInt *bitmapzz, Short *dataBlock, RunLevelBlock *RLB, Int nc)
 {
+    OSCL_UNUSED_ARG(nc);
     Int idx, run, level = 0, j;
     UInt end = 0, match;
     Int  zzorder;
diff --git a/codecs_v2/video/m4v_h263/enc/src/vop.cpp b/codecs_v2/video/m4v_h263/enc/src/vop.cpp
index 94c8e3f..62de1c8 100644
--- a/codecs_v2/video/m4v_h263/enc/src/vop.cpp
+++ b/codecs_v2/video/m4v_h263/enc/src/vop.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -143,7 +143,7 @@
     else 	/* Short Video Header = 0 */
     {
 
-        if (currVol->GOVStart)
+        if (currVol->GOVStart && currVop->predictionType == I_VOP)
             status = EncodeGOVHeader(stream, time); /* Encode GOV Header */
 
         status = EncodeVOPHeader(stream, currVol, currVop);  /* Encode VOP Header */
@@ -322,7 +322,6 @@
     status = BitstreamPutGT16Bits(stream, 32, VOP_START_CODE); /*Start Code for VOP*/
     status = BitstreamPutBits(stream, 2, P_VOP);/* VOP Coding Type*/
 
-    modTime += video->wrapModTime; /* wrapModTime is non zero after wrap-around */
     frameTick = (Int)(((double)(modTime - video->modTimeRef) * currVol->timeIncrementResolution + 500) / 1000);
     timeInc = frameTick - video->refTick[0];
     while (timeInc >= currVol->timeIncrementResolution)
@@ -498,7 +497,8 @@
 /*	Purpose  : Encode a frame of MPEG4 bitstream in Combined mode.			*/
 /*	In/out   :																*/
 /*	Return   :																*/
-/*	Modified : 04/25/2002 Add bitstream structure as input argument			*/
+/*	Modified : 04/25/2002 								*/
+/*			   Add bitstream structure as input argument					*/
 /*																			*/
 /* ======================================================================== */
 PV_STATUS EncodeVideoPacketHeader(VideoEncData *video, int MB_number,
@@ -545,7 +545,8 @@
     if (0) /* header_extension_code = 1 */
     {
         /* NEED modulo_time_base code here ... default 0x01  belo*/
-        /*status =*/ BitstreamPut1Bits(bs, 1);
+        /*status =*/
+        BitstreamPut1Bits(bs, 1);
         /*status = */
         BitstreamPut1Bits(bs, 0);
 
diff --git a/doc/cpm_developers_guide.pdf b/doc/cpm_developers_guide.pdf
deleted file mode 100755
index 714f45f..0000000
--- a/doc/cpm_developers_guide.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/mio_developers_guide.pdf b/doc/mio_developers_guide.pdf
deleted file mode 100755
index 99e6bb5..0000000
--- a/doc/mio_developers_guide.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/openmax_call_sequences.pdf b/doc/openmax_call_sequences.pdf
deleted file mode 100755
index 6ff57c2..0000000
--- a/doc/openmax_call_sequences.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/pvauthor_developers_guide.pdf b/doc/pvauthor_developers_guide.pdf
deleted file mode 100755
index 96a69d4..0000000
--- a/doc/pvauthor_developers_guide.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/pvlogger_users_guide.pdf b/doc/pvlogger_users_guide.pdf
deleted file mode 100755
index a3d22e0..0000000
--- a/doc/pvlogger_users_guide.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/pvmf_return_codes.pdf b/doc/pvmf_return_codes.pdf
deleted file mode 100755
index 57b6904..0000000
--- a/doc/pvmf_return_codes.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/pvplayer_developers_guide.pdf b/doc/pvplayer_developers_guide.pdf
deleted file mode 100755
index 661f77b..0000000
--- a/doc/pvplayer_developers_guide.pdf
+++ /dev/null
Binary files differ
diff --git a/doc/pvplayer_engine_unit_test_guide.pdf b/doc/pvplayer_engine_unit_test_guide.pdf
deleted file mode 100755
index 2e6ecbb..0000000
--- a/doc/pvplayer_engine_unit_test_guide.pdf
+++ /dev/null
Binary files differ
diff --git a/engines/2way/Android.mk b/engines/2way/Android.mk
new file mode 100644
index 0000000..8d792d7
--- /dev/null
+++ b/engines/2way/Android.mk
@@ -0,0 +1,62 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pv_2way_datapath.cpp \
+ 	src/pv_2way_engine.cpp \
+ 	src/pv_2way_data_channel_datapath.cpp \
+ 	src/pv_2way_cmd_control_datapath.cpp \
+ 	src/pv_2way_dec_data_channel_datapath.cpp \
+ 	src/pv_2way_enc_data_channel_datapath.cpp \
+ 	src/pv_2way_mux_datapath.cpp \
+ 	src/pv_2way_preview_datapath.cpp \
+ 	src/pv_2way_rec_datapath.cpp \
+ 	src/pv_2way_engine_factory.cpp \
+ 	src/pv_2way_proxy_adapter.cpp \
+ 	src/pv_2way_proxy_factory.cpp
+
+
+LOCAL_MODULE := libpv2wayengine
+
+LOCAL_CFLAGS := -DPV_DISABLE_VIDRECNODE -DPV_DISABLE_DEVSOUNDNODES -DPV_DISABLE_DEVVIDEOPLAYNODE -DSIP_VOIP_PROJECT=1 -DPV2WAY_USE_OMX_AMR_DECODER -DPV2WAY_USE_OMX_AMR_ENCODER -DPV2WAY_USE_OMX_H263_DECODER -DPV2WAY_USE_OMX_H263_ENCODER -DPV2WAY_USE_OMX_MPEG4_DECODER -DPV2WAY_USE_OMX_MPEG4_ENCODER $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/engines/2way/src \
+ 	$(PV_TOP)/engines/2way/include \
+ 	$(PV_TOP)/engines/2way/src \
+ 	$(PV_TOP)/engines/2way/include \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_TOP)/common/pvdebug/src \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h324/tsc/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/common/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h245/cmn/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h245/per/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h245/se/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h324/srp/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h324/tsc/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h223/include \
+ 	$(PV_TOP)/protocols/systems/common/include \
+ 	$(PV_TOP)/protocols/systems/tools/general/common/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_TOP)/nodes/pvmediainputnode/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/nodes/pvomxvideodecnode/include \
+ 	$(PV_TOP)/nodes/pvomxbasedecnode/include \
+ 	$(PV_TOP)/nodes/pvomxaudiodecnode/include \
+ 	$(PV_TOP)/nodes/pvomxencnode/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pv_2way_interface.h \
+ 	include/pv_2way_engine_factory.h \
+ 	include/pv_2way_proxy_factory.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/engines/2way/build/make/local.mk b/engines/2way/build/make/local.mk
new file mode 100644
index 0000000..757e7bc
--- /dev/null
+++ b/engines/2way/build/make/local.mk
@@ -0,0 +1,95 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv2wayengine 
+
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+XCPPFLAGS +=  -DPV_DISABLE_VIDRECNODE -DPV_DISABLE_DEVSOUNDNODES -DPV_DISABLE_DEVVIDEOPLAYNODE
+
+ifdef NO2WAYSIP
+XCPPFLAGS += -DNO_2WAY_SIP
+else
+XCPPFLAGS += -DSIP_VOIP_PROJECT=1
+endif
+
+ifdef NO2WAY324
+XCPPFLAGS += -DNO_2WAY_324
+endif
+
+ifeq ($(USING_OMX),1)
+XCPPFLAGS += -DPV2WAY_USE_OMX_AMR_DECODER -DPV2WAY_USE_OMX_AMR_ENCODER \
+-DPV2WAY_USE_OMX_H263_DECODER -DPV2WAY_USE_OMX_H263_ENCODER\
+-DPV2WAY_USE_OMX_MPEG4_DECODER -DPV2WAY_USE_OMX_MPEG4_ENCODER
+else
+XCPPFLAGS += -DPV_USE_AMR_CODECS
+endif 
+
+
+XINCDIRS +=  ../../src  ../../include  ../../../common/include  \
+../../../../common/pvdebug/src \
+ ../../../../protocols/systems/3g-324m_pvterminal/h324/tsc/include \
+ ../../../../protocols/systems/3g-324m_pvterminal/common/include \
+ ../../../../protocols/systems/3g-324m_pvterminal/h245/cmn/include \
+ ../../../../protocols/systems/3g-324m_pvterminal/h245/per/include \
+ ../../../../protocols/systems/3g-324m_pvterminal/h245/se/include \
+ ../../../../protocols/systems/3g-324m_pvterminal/h324/srp/include  \
+../../../../protocols/systems/3g-324m_pvterminal/h324/tsc/include  \
+../../../../protocols/systems/3g-324m_pvterminal/h223/include  \
+../../../../protocols/systems/common/include  \
+../../../../protocols/systems/tools/general/common/include  \
+../../../../nodes/streaming/common/include \
+../../../../nodes/pvmediainputnode/include 
+
+ifeq ($(USING_OMX),1)
+XINCDIRS +=  ../../../../extern_libs_v2/khronos/openmax/include \
+  ../../../../nodes/pvomxvideodecnode/include \
+  ../../../../nodes/pvomxbasedecnode/include \
+  ../../../../nodes/pvomxaudiodecnode/include \
+  ../../../../nodes/pvomxencnode/include
+endif
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_2way_datapath.cpp \
+	pv_2way_engine.cpp \
+	pv_2way_data_channel_datapath.cpp \
+	pv_2way_cmd_control_datapath.cpp \
+	pv_2way_dec_data_channel_datapath.cpp \
+	pv_2way_enc_data_channel_datapath.cpp \
+	pv_2way_mux_datapath.cpp \
+	pv_2way_preview_datapath.cpp \
+	pv_2way_rec_datapath.cpp \
+	pv_2way_engine_factory.cpp \
+	pv_2way_proxy_adapter.cpp \
+	pv_2way_proxy_factory.cpp
+
+HDRS := pv_2way_interface.h \
+	pv_2way_engine_factory.h \
+	pv_2way_proxy_factory.h 
+
+
+
+include $(MK)/library.mk
+
+doc:
+	cp -f $(VOB_BASE_DIR)/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config_interface.h $(VOB_BASE_DIR)/engines/2way/include
+	cp -f $(VOB_BASE_DIR)/nodes/common/include/pvmp4h263encextension.h $(VOB_BASE_DIR)/engines/2way/include
+	perl $(VOB_BASE_DIR)/tools_v2/build/document/bin/doc_build.bat --doctype pv2way_engine --title "PV 2Way Engine" --path "$(VOB_BASE_DIR)/engines/2way/include $(VOB_BASE_DIR)/engines/common/include $(VOB_BASE_DIR)/protocols/systems/common/include" -filetype "mainpage *.h readme.txt" --exclude_pattern "*/test/* */obsolete/* */doxydir/* */cpp/* *symbian* *pv_2way_datapath* *pv_2way_engine_* *pv_2way_interface_* *pv_2way_plugin_interfaces* *pv_2way_sdk_types*" -ver $(PV2WAY_ENGINE_VERSION)
+	rm -f $(VOB_BASE_DIR)/engines/2way/include/tsc_h324m_config_interface.h
+	rm -f $(VOB_BASE_DIR)/engines/2way/include/pvmp4h263encextension.h
+
+
+sdkinfo_target := $(LOCAL_SRCDIR)/pv_2way_engine.cpp
+sdkinfo_header_filename := $(LOCAL_SRCDIR)/pv_2way_sdkinfo.h
+sdkinfo_header_macro := PV_2WAY_SDKINFO
+sdkinfo_label_macro := PV2WAY_ENGINE_SDKINFO_LABEL
+sdkinfo_date_macro := PV2WAY_ENGINE_SDKINFO_DATE
+
+include $(MK)/sdkinfo.mk 
diff --git a/engines/2way/include/pv_2way_engine_factory.h b/engines/2way/include/pv_2way_engine_factory.h
new file mode 100644
index 0000000..896d3f6
--- /dev/null
+++ b/engines/2way/include/pv_2way_engine_factory.h
@@ -0,0 +1,65 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_ENGINE_FACTORY_H_INCLUDED
+#define PV_2WAY_ENGINE_FACTORY_H_INCLUDED
+
+#ifndef PV_2WAY_BASIC_TYPES_H_INCLUDED
+#include "pv_2way_basic_types.h"
+#endif
+
+class PVCommandStatusObserver;
+class PVInformationalEventObserver;
+class PVErrorEventObserver;
+class CPV2WayInterface;
+
+class CPV2WayEngineFactory
+{
+    public:
+        OSCL_IMPORT_REF static void Init();
+
+        OSCL_IMPORT_REF static void Cleanup();
+
+        /**
+         * Creates an instance of a terminal of a particular type.  Initially, this
+         * will support 324m type terminals.
+         *
+         * @param aTerminalType the type of terminal to be created.
+         * @param aCmdStatusObserver     the observer for command status
+         * @param aInfoEventObserver     the observer for unsolicited informational events
+         * @param aErrorEventObserver     the observer for unsolicited error events
+         *
+         * @returns A pointer to a terminal or leaves if the type is invalid or the system is out of resources
+         **/
+        OSCL_IMPORT_REF static CPV2WayInterface *CreateTerminal(PV2WayTerminalType aTerminalType,
+                PVCommandStatusObserver* aCmdStatusObserver,
+                PVInformationalEventObserver *aInfoEventObserver,
+                PVErrorEventObserver *aErrorEventObserver);
+
+        /**
+         * This function allows the application to delete an instance of a terminal
+         * and reclaim all allocated resources.  A terminal should be deleted only in
+         * the EIdle state.  An attempt to delete a terminal in any other state will
+         * result in unpredictable behavior.
+         *
+         * @param terminal the terminal to be deleted.
+         *
+         **/
+        OSCL_IMPORT_REF static void DeleteTerminal(CPV2WayInterface* terminal);
+};
+
+#endif // PV_2WAY_ENGINE_FACTORY_H_INCLUDED
diff --git a/engines/2way/include/pv_2way_interface.h b/engines/2way/include/pv_2way_interface.h
new file mode 100644
index 0000000..e59150f
--- /dev/null
+++ b/engines/2way/include/pv_2way_interface.h
@@ -0,0 +1,471 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+* ==============================================================================
+*  Name        : pv_2way_interface.h
+*  Part of     :
+*  Interface   :
+*  Description : Interface class and supporting definitions for the PV2Way SDK
+*  Version     : (see RELEASE field in copyright header above)
+*
+* ==============================================================================
+*/
+
+#ifndef PV_2WAY_INTERFACE_H_INCLUDED
+#define PV_2WAY_INTERFACE_H_INCLUDED
+
+
+//  INCLUDES
+#ifndef PV_COMMON_TYPES_H_INCLUDED
+#include "pv_common_types.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef PVT_COMMON_H_INCLUDED
+#include "pvt_common.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVLOGGER_ACCESSORIES_H_INCLUDED
+#include "pvlogger_accessories.h"
+#endif
+
+#ifndef PV_ENGINE_TYPES_H_INCLUDED
+#include "pv_engine_types.h"
+#endif
+
+#ifndef PVT_2WAY_BASIC_TYPES_H_INCLUDED
+#include "pv_2way_basic_types.h"
+#endif
+
+#ifndef PV_2WAY_H324M_TYPES_H_INCLUDED
+#include "pv_2way_h324m_types.h"
+#endif
+
+
+// CONSTANTS
+
+// DATA TYPES
+
+// CLASS DECLARATION
+
+/**
+ * CPV2WayInterface Class
+ *
+ * CPV2WayInterface is the interface to the pv2way SDK, which
+ * allows initialization, control, and termination of a two-way (3g-324m, SIP) terminal.
+ * The application is expected to contain and maintain a pointer to the
+ * CPV2WayInterface instance at all times that a call is active.
+ * The CPV2WayFactory factory class is to be used to create and
+ * delete instances of this class
+ **/
+class CPV2WayInterface
+{
+    public:
+        /**
+         * Object destructor function
+         * Releases Resources prior to destruction
+         **/
+        virtual ~CPV2WayInterface() {};
+
+        /**
+         * Returns version information about the SDK
+         *
+         * @param aSDKInfo
+         *         A reference to a PVSDKInfo structure which contains the product label and date
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @leave	This method can leave with one of the following error codes
+         *          PVMFErrNoMemory if the SDK failed to allocate memory during this operation
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId GetSDKInfo(PVSDKInfo &aSDKInfo,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Returns information about all modules currently used by the SDK.
+         *
+         * @param aSDKModuleInfo
+         *         A reference to a PVSDKModuleInfo structure which contains the number of modules currently used by
+         *         pv2way SDK and the PV UID and description string for each module. The PV UID and description string
+         *         for modules will be returned in one string buffer allocated by the client. If the string buffer
+         *         is not large enough to hold the all the module's information, the information will be written
+         *         up to the length of the buffer and truncated.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @leave	This method can leave with one of the following error codes
+         *          PVMFErrNoMemory if the SDK failed to allocate memory during this operation
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo,
+                OsclAny* aContextData = NULL) = 0;
+
+
+        /**
+         * This function is valid only in the EIdle state.  It is a no-op when
+         * invoked in any other state.  It causes the pv2way to transition
+         * to the ESetup state.  The terminal remains in the EInitializing state during
+         * the transition.
+         *
+         * While initializing, the pv2way tries to allocate system resources needed
+         * for a two-way call.  If it fails for some reason,
+         * and the pv2way reverts to the EIdle state.  All the resources are de-allocated.
+         *
+         *
+         * @param aInitInfo
+         *         A reference to a CPV2WayInitInfo structure which contains the capabilities of the applications sinks
+         *          and sources to handle compressed and uncompressed formats.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @leave	This method can leave with one of the following error codes
+         *			PVMFErrArgument if more tx and rx codecs are set than engine can handle, or the mandatory codecs are not in the list.
+         *          PVMFErrNotSupported if the format of the sources/sinks is incomtible with what the SDK can handle
+         *          PVMFErrInvalidState if invoked in the incorrect state
+         *          PVMFErrNoMemory if the SDK failed to allocate memory during this operation
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId Init(PV2WayInitInfo& aInitInfo,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function is valid only in the ESetup and EInitializing state.  It is a
+         * no-op when invoked in the EIdle state and returns PVMFErrInvalidState
+         * if invoked in any other state.
+         *
+         * It causes the pv2way to transition back to the EIdle state.  The
+         * terminal remains in the EResetting state during the transition.
+         *
+         * While resetting, the pv2way de-allocates all resources resources that
+         * had been previously allocated.  When it completes, ResetComplete is called
+         * and the pv2way reverts to the EIdle state.
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @leave	This method can leave with one of the following error codes
+         *          PVMFErrInvalidState if invoked in the incorrect state
+         *          PVMFErrNoMemory if the SDK failed to allocate memory during this operation
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId Reset(OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function allows the user to specify the media source for an outgoing track.
+         * Sources should be added after the PVT_INDICATION_OUTGOING_TRACK is received which specifies the format type
+         * and the unique track id.  The format type is indicated using the PV2WayTrackInfoInterface extension interface in the
+         * PVAsyncInformationalEvent.
+         * Data sources could be of the following types:
+         * a)raw media sources like camera, microphone etc.
+         * b)sources of compressed data like file, combined capture and encode devices.
+         *
+         	 * @param aTrackId
+         *          The outgoing track id
+         * @param aDataSource
+         *          Reference to the data source for this track
+         * @param aContextData
+         *          Optional opaque data that will be passed back to the user with the command response
+         * @leave	This method can leave with one of the following error codes
+         *          PVMFErrNotSupported if the format of the sources/sinks is incomtible with what the SDK can handle
+         *          KPVErrInvalidState if invoked in the incorrect state
+         *          KErrNoMemory if the SDK failed to allocate memory during this operation
+         * @return A unique command id for asynchronous completion
+         */
+        OSCL_IMPORT_REF virtual PVCommandId AddDataSource(PVTrackId aTrackId,
+                PVMFNodeInterface& aDataSource,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function unbinds a previously added source.
+         *
+         * @param aDataSource pointer to the media source node
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId RemoveDataSource(PVMFNodeInterface& aDataSource,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function allows the user to specify the media sink for an incoming track.
+         * AddDataSinkL can be called only for established incoming tracks identified by a unique
+         * track id.
+         * Incoming tracks are initiated by the peer and their establishment is indicated using the
+         * PVT_INDICATION_INCOMING_TRACK notification which provides the media type and a unique track id.
+         * The format type is indicated using the PV2WayTrackInfoInterface extension interface in the
+         * PVAsyncInformationalEvent.
+         * Data sinks could be of the following types:
+         * a)raw media sinks like video display sinks for RGB and YUV formats, audio rendering sinks for PCM.
+         * b)sources of compressed data like file, combined decode and render devices.
+         *
+         *
+         * @param aTrackId
+         *          Indicates the unique track id to be associated with this sink.
+         * @param aDataSink The data sink to be added
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @return A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId AddDataSink(PVTrackId aTrackId,
+                PVMFNodeInterface& aDataSink,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function unbinds a previously added sink.
+         *
+         * @param aDataSink pointer to the media sink node
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId RemoveDataSink(PVMFNodeInterface& aDataSink,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function can be invoked only in the ESetup state.  The terminal starts connecting with the remote
+         * terminal based on the specified options and capabilities.
+         * Incoming tracks may be opened before ConnectL completes and will be indicated via the
+         * PVT_INDICATION_INCOMING_TRACK event.
+         *
+         * @param aOptions
+         *         Optional additional information for call setup.
+         * @param aCommServer
+         *		   An optional pointer to a comm server to provide comm source and sink end-points.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId Connect(const PV2WayConnectOptions& aOptions,
+                PVMFNodeInterface* aCommServer = NULL,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * The Disconnect call is valid only when invoked in the EConnecting, and
+         * EConnected states.  It causes the terminal to transition to the
+         * EDisconnecting state.  All the media tracks both incoming and outgoing
+         * will be closed on invoking Disconnect. On completion, the terminal
+         * goes to the ESetup state. The statistics of the previous call shall
+         * still be available until Connect is invoked again.
+         *
+         * It is a no-op when called in any other state.
+         *
+         * The post disconnect option specifies what this terminal wishes to do
+         * after the data call is terminated, whether it wants to disconnect the line
+         * or continue the call as a voice only call.
+         *
+         * This is an asynchronous request.
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId Disconnect(OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This function returns the current state of the pv2way.
+         * Application may use this info for updating display or determine if the
+         * pv2way is ready for the next request.
+         *
+         * @param aState
+         *         Reflects the state of the PV 2Way engine when the command was received.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns value indicating the current pv2way state
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId GetState(PV2WayState& aState,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * For an incoming track this function  pauses sending media to the sink (output device) and stops the sink.
+         *
+         * For outgoing, it pauses the sending of media from the source and stops the source.
+         *
+         * @param aDirection Specifies the direction of the track - incoming or outgoing
+         * @param aTrackId Specifies which track is to be paused.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId Pause(PV2WayDirection aDirection,
+                PVTrackId aTrackId,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Resume a previously paused incoming or outgoing track.  For incoming,
+         * this function starts resumes playing out the media to the appropriate
+         * sink based on the current settings.  For outgoing it resumes encoding
+         * and sending media from the source.
+         *
+         * @param aDirection Specifies the direction of the track - incoming or outgoing
+         * @param aTrackId Specifies which track is to be paused.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId Resume(PV2WayDirection aDirection,
+                PVTrackId aTrackId,
+                OsclAny* aContextData = NULL) = 0;
+
+
+        /**
+         * Allows a logging appender to be attached at some point in the
+         * logger tag tree.  The location in the tag tree is specified by the
+         * input tag string.  A single appender can be attached multiple times in
+         * the tree, but it may result in duplicate copies of log messages if the
+         * appender is not attached in disjoint portions of the tree.
+         * A logging appender is responsible for actually writing the log message
+         * to its final location (e.g., memory, file, network, etc).
+         * This API can be called anytime after creation of the terminal.
+         *
+         * @param aTag Specifies the logger tree tag where the appender should be attached.
+         * @param aAppender The log appender to attach.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @exception memory_error leaves on memory allocation error.
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId SetLogAppender(const char* aTag,
+                OsclSharedPtr<PVLoggerAppender>& aAppender,
+                OsclAny* aContextData = NULL) = 0;
+
+
+        /**
+         * Allows a logging appender to be removed from the logger tree at the
+         * point specified by the input tag.  The input tag cannot be NULL.
+         *
+         * @param aTag Specifies the logger tree tag where the appender should be removed.
+         * @param aAppender The log appender to remove.  Must be a reference to the same object that was set.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @exception memory_error leaves on memory allocation error.
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId RemoveLogAppender(const char* aTag,
+                OsclSharedPtr<PVLoggerAppender>& aAppender,
+                OsclAny* aContextData = NULL) = 0;
+
+
+        /**
+         * Allows the logging level to be set for the logging node specified by the
+         * tag.  A larger log level will result in more messages being logged.  A message
+         * will only be logged if its level is LESS THAN or equal to the current log level.
+         * The set_subtree flag will allow an entire subtree, with the specified tag as the root,
+         * to be reset to the specified value.
+         *
+         * @param aTag Specifies the logger tree tag where the log level should be set.
+         * @param aLevel Specifies the log level to set.
+         * @param aSetSubtree Specifies whether the entire subtree with aTag as the root should
+         *                      be reset to the log level.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @exception memory_error leaves on memory allocation error.
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId SetLogLevel(const char* aTag,
+                int32 aLevel,
+                bool aSetSubtree = false,
+                OsclAny* aContextData = NULL) = 0;
+
+
+        /**
+         * Allows the logging level to be queried for a particular logging tag.
+         * A larger log level will result in more messages being logged.
+         *
+         * In the asynchronous response, this should return the log level along with an
+         * indication of where the level was inherited (i.e., the ancestor tag).
+         *
+         * @param aTag Specifies the logger tree tag where the log level should be retrieved.
+         * @param aLogInfo an output parameter which will be filled in with the log level information.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @exception memory_error leaves on memory allocation error.
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId GetLogLevel(const char* aTag,
+                int32& aLogInfo,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API is to allow for extensibility of the pv2way interface.
+         * It allows a caller to ask for all UUIDs associated with a particular MIME type.
+         * If interfaces of the requested MIME type are found within the system, they are added
+         * to the UUIDs array.
+         *
+         * Also added to the UUIDs array will be all interfaces which have the requested MIME
+         * type as a base MIME type.  This functionality can be turned off.
+         *
+         * @param aMimeType The MIME type of the desired interfaces
+         * @param aUuids An array to hold the discovered UUIDs
+         * @param aExactUuidsOnly Turns on/off the retrival of UUIDs with aMimeType as a base type
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId QueryUUID(const PvmfMimeString& aMimeType,
+                Oscl_Vector<PVUuid, BasicAlloc>& aUuids,
+                bool aExactUuidsOnly = false,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API is to allow for extensibility of the pv2way interface.
+         * It allows a caller to ask for an instance of a particular interface object to be returned.
+         * The mechanism is analogous to the COM IUnknown method.  The interfaces are identified with
+         * an interface ID that is a UUID as in DCE and a pointer to the interface object is
+         * returned if it is supported.  Otherwise the returned pointer is NULL.
+         * TBD:  Define the UIID, InterfacePtr structures
+         * @param aUuid The UUID of the desired interface
+         * @param aInterfacePtr The output pointer to the desired interface
+         * @exception not_supported
+         *                   leaves if the specified interface id is not supported.
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId QueryInterface(const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                OsclAny* aContext = NULL) = 0;
+
+        /**
+         * This API is to allow the user to cancel all pending requests.  The current request being
+         * processed, if any, will also be aborted.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        OSCL_IMPORT_REF virtual PVCommandId CancelAllCommands(OsclAny* aContextData = NULL) = 0;
+};
+
+
+
+#endif //
+
+
diff --git a/engines/2way/include/pv_2way_proxy_factory.h b/engines/2way/include/pv_2way_proxy_factory.h
new file mode 100644
index 0000000..7cb6c0f
--- /dev/null
+++ b/engines/2way/include/pv_2way_proxy_factory.h
@@ -0,0 +1,68 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_PROXY_FACTORY_H_INCLUDED
+#define PV_2WAY_PROXY_FACTORY_H_INCLUDED
+
+#ifndef PV_COMMON_TYPES_H_INCLUDED
+#include "pv_common_types.h"
+#endif
+
+#ifndef PV_2WAY_INTERFACE_H_INCLUDED
+#include "pv_2way_interface.h"
+#endif
+
+#ifndef PV_ENGINE_OBSERVER_H_INCLUDED
+#include "pv_engine_observer.h"
+#endif
+
+class CPV2WayProxyFactory
+{
+    public:
+        OSCL_IMPORT_REF static void Init();
+
+        OSCL_IMPORT_REF static void Cleanup();
+
+        /**
+         * Creates an instance of a terminal of a particular type.  Initially, this
+         * will support 324m type terminals.
+         *
+         * @param aTerminalType the type of terminal to be created.
+         * @param aCmdStatusObserver     the observer for command status
+         * @param aInfoEventObserver     the observer for unsolicited informational events
+         * @param aErrorEventObserver     the observer for unsolicited error events
+         *
+         * @returns A pointer to a terminal or leaves if the type is invalid or the system is out of resources
+         **/
+        OSCL_IMPORT_REF static CPV2WayInterface *CreateTerminal(TPVTerminalType aTerminalType,
+                PVCommandStatusObserver* aCmdStatusObserver,
+                PVInformationalEventObserver *aInfoEventObserver,
+                PVErrorEventObserver *aErrorEventObserver);
+
+        /**
+         * This function allows the application to delete an instance of a terminal
+         * and reclaim all allocated resources.  A terminal should be deleted only in
+         * the EIdle state.  An attempt to delete a terminal in any other state will
+         * result in unpredictable behavior.
+         *
+         * @param terminal the terminal to be deleted.
+         *
+         **/
+        OSCL_IMPORT_REF static void DeleteTerminal(CPV2WayInterface* terminal);
+};
+
+#endif // PV_2WAY_PROXY_FACTORY_H_INCLUDED
diff --git a/engines/2way/pvlogger/config/pvlogger.ini b/engines/2way/pvlogger/config/pvlogger.ini
new file mode 100644
index 0000000..6123baa
--- /dev/null
+++ b/engines/2way/pvlogger/config/pvlogger.ini
@@ -0,0 +1,2 @@
+1
+8,2wayEngine
diff --git a/engines/2way/pvlogger/src/pv_logger_impl.cpp b/engines/2way/pvlogger/src/pv_logger_impl.cpp
new file mode 100644
index 0000000..826c6e4
--- /dev/null
+++ b/engines/2way/pvlogger/src/pv_logger_impl.cpp
@@ -0,0 +1,222 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PVLOGGER_STDERR_APPENDER_H_INCLUDED
+#include "pvlogger_stderr_appender.h"
+#endif
+
+#ifndef PVLOGGER_TIME_AND_ID_LAYOUT_H_INCLUDED
+#include "pvlogger_time_and_id_layout.h"
+#endif
+
+#ifndef PVLOGGER_FILE_APPENDER_H_INCLUDED
+#include "pvlogger_file_appender.h"
+#endif
+
+#ifndef PV_LOGGER_IMPL_H_INCLUDED
+#include "pv_logger_impl.h"
+#endif
+
+PVLoggerConfigFile::~PVLoggerConfigFile()
+{
+    iFileServer.Close();
+}
+
+bool PVLoggerConfigFile::IsLoggerConfigFilePresent()
+{
+    if (ESuccess == ReadAndParseLoggerConfigFile())
+    {
+        // success
+        return true;
+    }
+    // failure
+    return false;
+}
+void PVLoggerConfigFile::SetConfigFilePath(const oscl_wchar *aConfigFilepath)
+{
+    oscl_strncpy(iLogFileName, aConfigFilepath, FILENAME_LEN);
+    //set log file name
+    oscl_strcat(iLogFileName, CONFIG_FILE_NAME);
+}
+
+//Read and parse the config file
+//retval = -1 if the config file doesnt exist
+int8  PVLoggerConfigFile::ReadAndParseLoggerConfigFile()
+{
+    int8 retval = ESuccess;
+
+    if (ESuccess != iLogFile.Open(iLogFileName, Oscl_File::MODE_READ, iFileServer))
+    {
+        // error occured in opening logger config file
+        retval = EError;
+    }
+    else
+    {
+        // able to open logger config file
+        if (!iLogFileRead)
+        {
+            iLogFile.Read(ibuffer, 1, sizeof(ibuffer));
+            //Parse the buffer for \n chars
+            Oscl_Vector<char*, OsclMemAllocator> LogConfigStrings;
+
+            //Get the logger strings
+#if defined(__linux__) || defined(linux)
+            const char* const lnFd = "\n";
+#endif
+
+            const int8 lnFdLen = oscl_strlen(lnFd);
+            int16 offset = 0;
+            char* lastValidBffrAddr = ibuffer + oscl_strlen(ibuffer);
+            const char* lnFdIndx = oscl_strstr(ibuffer, lnFd);
+            while (lnFdIndx != NULL && lnFdIndx < lastValidBffrAddr)
+            {
+                oscl_memset((char*)lnFdIndx, '\0', lnFdLen);
+                LogConfigStrings.push_back(ibuffer + offset);
+                offset = (lnFdIndx + lnFdLen) - ibuffer;
+                lnFdIndx = OSCL_CONST_CAST(char*, oscl_strstr(ibuffer + offset, lnFd));
+            }
+            if (NULL == lnFdIndx && ((ibuffer + offset) < lastValidBffrAddr)) //If \r\n is skipped after the last logging str in ini file
+            {
+                LogConfigStrings.push_back(ibuffer + offset);
+            }
+
+
+            //Populate the  LoggerConfigElements vector
+            {
+                if (!LogConfigStrings.empty())
+                {
+                    Oscl_Vector<char*, OsclMemAllocator>::iterator it;
+                    it = LogConfigStrings.begin();
+                    uint32 appenderType;
+                    PV_atoi(*it, 'd', oscl_strlen(*it), appenderType);
+                    iAppenderType = appenderType;
+                    if (LogConfigStrings.size() > 1)
+                    {
+                        for (it = LogConfigStrings.begin() + 1; it != LogConfigStrings.end(); it++)
+                        {
+                            char* CommaIndex = OSCL_CONST_CAST(char*, oscl_strstr(*it, ","));
+                            if (CommaIndex != NULL)
+                            {
+                                *CommaIndex = '\0';
+                                LoggerConfigElement obj;
+                                uint32 logLevel;
+                                PV_atoi(*it, 'd', oscl_strlen(*it), logLevel);
+                                obj.iLogLevel = logLevel;
+                                obj.iLoggerString = CommaIndex + 1;
+                                iLoggerConfigElements.push_back(obj);
+                            }
+                        }
+                    }
+                    else
+                    {
+                        //Add the config element for complete logging fo all the modules
+                        LoggerConfigElement obj;
+                        obj.iLoggerString = NULL;
+                        obj.iLogLevel = 8;
+                        iLoggerConfigElements.push_back(obj);
+                    }
+                }
+            }
+            iLogFile.Close();
+            iLogFileRead = true;
+        }
+    }
+    return retval;
+}
+
+void PVLoggerConfigFile::SetAppenderType(int aAppenderType)
+{
+    iAppenderType = aAppenderType;
+}
+
+uint32 PVLoggerConfigFile::SetLoggerSettings(CPV2WayInterface *aTerminal, const oscl_wchar *aLogPath)
+{
+    Oscl_Vector<LoggerConfigElement, OsclMemAllocator>::iterator it;
+    uint32 error = 1;
+
+    PVLoggerAppender *appender = NULL;
+    OsclRefCounter *refCounter = NULL;
+    if (iLoggerConfigElements.empty())
+    {
+        return error;
+    }
+
+    if (EConsoleLog == iAppenderType)
+    {
+        // for console
+        appender = new StdErrAppender<TimeAndIdLayout, 1024>();
+        OsclRefCounterSA<AppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
+            new OsclRefCounterSA<AppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > >(appender);
+        refCounter = appenderRefCounter;
+    }
+    else if (EFileLog == iAppenderType)
+    {
+        //for file
+        OSCL_wHeapString<OsclMemAllocator> logfilename(aLogPath);
+        appender = (PVLoggerAppender*)TextFileAppender<TimeAndIdLayout, 1024>::CreateAppender(logfilename.get_str());
+        OsclRefCounterSA<AppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
+            new OsclRefCounterSA<AppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > >(appender);
+        refCounter = appenderRefCounter;
+    }
+    else
+    {
+        // No Valid Logger Appender
+        return error;
+    }
+
+    OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, refCounter);
+
+    for (it = iLoggerConfigElements.begin(); it != iLoggerConfigElements.end(); it++)
+    {
+        char* loggerString = NULL;
+        if (0 != oscl_strncmp(it->iLoggerString, ENABLE_ALL_LOGS, oscl_strlen(ENABLE_ALL_LOGS)))
+        {
+            loggerString = it->iLoggerString;
+        }
+        if (NULL == aTerminal)
+        {
+            PVLogger *node = NULL;
+
+            node = PVLogger::GetLoggerObject(loggerString);
+            if (NULL == node)
+            {
+                error = 1;
+                return error;
+            }
+            node->AddAppender(appenderPtr);
+            node->SetLogLevel(it->iLogLevel);
+        }
+        else
+        {
+            aTerminal->SetLogLevel("", it->iLogLevel, true);
+            aTerminal->SetLogAppender(loggerString, appenderPtr);
+            error = 0;
+        }
+
+        if (0 != error)
+        {
+            return error;
+        }
+    }
+
+    return error;
+}
+
diff --git a/engines/2way/pvlogger/src/pv_logger_impl.h b/engines/2way/pvlogger/src/pv_logger_impl.h
new file mode 100644
index 0000000..ae3155f
--- /dev/null
+++ b/engines/2way/pvlogger/src/pv_logger_impl.h
@@ -0,0 +1,147 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_INTERFACE_H_INCLUDED
+#include "pv_2way_interface.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_MEM_AUDIT_H_INCLUDED
+#include "oscl_mem_audit.h"
+#endif
+
+#ifndef OSCL_ERROR_H_INCLUDED
+#include "oscl_error.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_H_INCLUDED
+#include "oscl_scheduler.h"
+#endif
+
+#ifndef OSCL_UTF8CONV_H
+#include "oscl_utf8conv.h"
+#endif
+
+#include "oscl_file_io.h"
+
+#ifndef FILENAME_LEN
+#define FILENAME_LEN 255
+#endif
+
+#define MAX_BUFFER_SIZE 1024
+
+// logger config file name
+#ifndef CONFIG_FILE_NAME
+#define CONFIG_FILE_NAME _STRLIT("pvlogger.ini")
+#endif
+
+// logger config file name
+#ifndef ENABLE_ALL_LOGS
+#define ENABLE_ALL_LOGS "ALL"
+#endif
+
+/*
+#ifndef DEFAULTSOURCEFORMATTYPE
+#error // The format type for default source file needs to be defined in config file
+#endif
+*/
+#ifndef OSCL_STRING_UTILS_H_INCLUDED
+#include "oscl_string_utils.h"
+#endif
+
+class PVLoggerConfigFile
+{
+        /*  To change the logging settings without the need to compile the test application
+        	Let us read the logging settings from the file instead of hard coding them over here
+        	The name of the config file is pvlogger.ini
+        	The format of entries in it is like
+        	First entry will decide if the file appender has to be used or error appender will be used.
+        	0 -> ErrAppender will be used
+        	1 -> File Appender will be used
+
+            Entries after this will decide the module whose logging has to be taken.For example, contents of one sample config file could be
+        	1
+        	1,2wayEngine
+            8,3g324m.h245user
+        	(pls note that no space is allowed between loglevel and logger tag)
+        	This means, we intend to have logging of level 1 for the module 2wayEngine
+        	and of level 8 for the 3g324m h245user on file.
+        */
+    public:
+
+        typedef enum
+        {
+            EConsoleLog,
+            EFileLog
+        } LoggingType;
+
+        typedef enum
+        {
+            ESuccess,
+            EError
+        } LoggerResult;
+
+        PVLoggerConfigFile(): iLogFileRead(false)
+        {
+            iFileServer.Connect();
+            iAppenderType = 0;
+        }
+
+        ~PVLoggerConfigFile();
+
+        void SetAppenderType(int aAppenderType);
+        bool IsLoggerConfigFilePresent();
+
+        //Set logger config file path
+        void SetConfigFilePath(const oscl_wchar *aConfigFilepath);
+        //Read and parse the config file
+        //retval = -1 if the config file doesnt exist
+        int8 ReadAndParseLoggerConfigFile();
+        //set logger settings
+        uint32 SetLoggerSettings(CPV2WayInterface *aTerminal, const oscl_wchar * aLogPath);
+    private:
+        class LoggerConfigElement
+        {
+            public:
+                LoggerConfigElement()
+                {
+                    iLoggerString = NULL;
+                    iLogLevel = 8;
+                }
+                char *iLoggerString;
+                int8 iLogLevel;
+        };
+        int8 iAppenderType; //Type of appender to be used for the logging 0-> Err Appender, 1-> File Appender
+        bool iLogFileRead;
+        Oscl_File iLogFile;
+        Oscl_FileServer iFileServer;
+        oscl_wchar iLogFileName[FILENAME_LEN]; // logger config file name
+        char ibuffer[MAX_BUFFER_SIZE];
+        Oscl_Vector<LoggerConfigElement, OsclMemAllocator> iLoggerConfigElements;
+        template<class DestructClass>
+        class AppenderDestructDealloc : public OsclDestructDealloc
+        {
+            public:
+                virtual void destruct_and_dealloc(OsclAny *ptr)
+                {
+                    delete((DestructClass*)ptr);
+                }
+        };
+};
diff --git a/engines/2way/pvlogger/test/src/pvlogger.ini b/engines/2way/pvlogger/test/src/pvlogger.ini
new file mode 100644
index 0000000..8377afc
--- /dev/null
+++ b/engines/2way/pvlogger/test/src/pvlogger.ini
@@ -0,0 +1,4 @@
+0
+8,mod1
+8,mod2
+8,mod3
diff --git a/engines/2way/pvlogger/test/src/test.cpp b/engines/2way/pvlogger/test/src/test.cpp
new file mode 100644
index 0000000..e5fdd26
--- /dev/null
+++ b/engines/2way/pvlogger/test/src/test.cpp
@@ -0,0 +1,100 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "stdio.h"
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "oscl_mem_audit.h"
+#include "oscl_error.h"
+#include "osclconfig.h"
+#include "oscl_string.h"
+#include "oscl_str_ptr_len.h"
+#include "oscl_scheduler.h"
+#include "oscl_utf8conv.h"
+#define OSCL_DISABLE_WARNING_CPLUSPLUS_EXC_HANDLER_USED
+#include "osclconfig_compiler_warnings.h"
+#include "oscl_file_io.h"
+#include "pv_logger_impl.h"
+#include "pvlogger.h"
+
+#define CONFIG_FILE_PATH _STRLIT("")
+
+void CleanUp();
+void Mod1();
+void Mod2();
+void Mod3();
+void DoLogging();
+
+int main()
+{
+    OsclBase::Init();
+    OsclMem::Init();
+    OsclErrorTrap::Init();
+    PVLogger::Init();
+    PVLoggerConfigFile *obj = new PVLoggerConfigFile();
+    obj->SetConfigFilePath(CONFIG_FILE_PATH);
+    if (obj->IsLoggerConfigFilePresent())
+    {
+        obj->SetLoggerSettings(NULL, _STRLIT("pvlog.txt"));
+    }
+    else
+    {
+        delete obj;
+        CleanUp();
+        return 1;
+    }
+
+    DoLogging();
+
+    delete obj;
+    CleanUp();
+    return 0;
+}
+
+void CleanUp()
+{
+    PVLogger::Cleanup();
+    OsclErrorTrap::Cleanup();
+    OsclMem::Cleanup();
+    OsclBase::Cleanup();
+}
+
+void DoLogging()
+{
+    Mod1();
+    Mod2();
+    Mod3();
+}
+
+void Mod1()
+{
+    PVLogger *logger = PVLogger::GetLoggerObject("mod1");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger, PVLOGMSG_ALERT, (1, "Test Logging of module 1"));
+}
+
+void Mod2()
+{
+    PVLogger *logger = PVLogger::GetLoggerObject("mod2");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger, PVLOGMSG_STACK_TRACE, (1, "Test Logging of module 2"));
+}
+
+void Mod3()
+{
+    PVLogger *logger = PVLogger::GetLoggerObject("mod3");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger, PVLOGMSG_DEBUG, (1, "Test Logging of module 3"));
+}
diff --git a/engines/2way/src/pv_2way_cmd_control_datapath.cpp b/engines/2way/src/pv_2way_cmd_control_datapath.cpp
new file mode 100644
index 0000000..3fe3a2f
--- /dev/null
+++ b/engines/2way/src/pv_2way_cmd_control_datapath.cpp
@@ -0,0 +1,64 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_cmd_control_datapath.h"
+
+
+bool CPV2WayCmdControlDatapath::CloseDatapath(TPV2WayCmdInfo *aCmdInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayCmdControlDatapath::CloseDatapath state %d cmd %x\n", iState, aCmdInfo));
+    if (iState == EClosing)
+    {
+        if (iCmdInfo == NULL) iCmdInfo = aCmdInfo;
+        return false;
+    }
+    else
+    {
+        //If command was already in progress when close was initiated.
+        if (iCmdInfo)
+        {
+            if ((aCmdInfo == NULL) && (iState == EOpening))
+            {
+                Close();
+                return false;
+            }
+
+            CommandComplete(PVMFErrCancelled);
+        }
+
+        iCmdInfo = aCmdInfo;
+        Close();
+
+        return true;
+    }
+}
+
+void CPV2WayCmdControlDatapath::CommandComplete(PVMFStatus aStatus)
+{
+    iCmdInfo->status = aStatus;
+    i2Way->Dispatch(iCmdInfo);
+    iCmdInfo = NULL;
+}
+
+
+
+
+
+
+
+
+
diff --git a/engines/2way/src/pv_2way_cmd_control_datapath.h b/engines/2way/src/pv_2way_cmd_control_datapath.h
new file mode 100644
index 0000000..b88433e
--- /dev/null
+++ b/engines/2way/src/pv_2way_cmd_control_datapath.h
@@ -0,0 +1,55 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_CMD_CONTROL_DATAPATH_H_INCLUDED
+#define PV_2WAY_CMD_CONTROL_DATAPATH_H_INCLUDED
+
+#ifndef PV_2WAY_DATAPATH_H_INCLUDED
+#include "pv_2way_datapath.h"
+#endif
+
+class CPV2WayCmdControlDatapath : public CPV2WayDatapath
+{
+    public:
+        CPV2WayCmdControlDatapath(PVLogger *aLogger,
+                                  TPV2WayDatapathType aType,
+                                  PVMFFormatType aFormat,
+                                  CPV324m2Way *a2Way) : CPV2WayDatapath(aLogger, aType, aFormat, a2Way),
+                iCmdInfo(NULL)
+
+        {};
+
+        virtual ~CPV2WayCmdControlDatapath() {};
+
+        TPV2WayCmdInfo *GetCmdInfo()
+        {
+            return iCmdInfo;
+        }
+        virtual bool SetCmd(TPV2WayCmdInfo *aCmdInfo) = 0;
+
+    protected:
+        bool CloseDatapath(TPV2WayCmdInfo *aCmdInfo);
+
+        void CommandComplete(PVMFStatus aStatus);
+
+        TPV2WayCmdInfo *iCmdInfo;
+};
+
+
+#endif //PV_2WAY_CMD_CONTROL_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_data_channel_datapath.cpp b/engines/2way/src/pv_2way_data_channel_datapath.cpp
new file mode 100644
index 0000000..b2a43ea
--- /dev/null
+++ b/engines/2way/src/pv_2way_data_channel_datapath.cpp
@@ -0,0 +1,134 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_data_channel_datapath.h"
+#include "pv_2way_rec_datapath.h"
+
+
+bool CPV2WayDataChannelDatapath::SetCmd(TPV2WayCmdInfo *aCmdInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDataChannelDatapath::SetCmd state %d cmd %x\n", iState, aCmdInfo));
+
+    if (aCmdInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDataChannelDatapath::SetCmd cmd type %d\n", aCmdInfo->type));
+        switch (aCmdInfo->type)
+        {
+            case PVT_COMMAND_ADD_DATA_SOURCE:
+            case PVT_COMMAND_ADD_DATA_SINK:
+                if (iState == EOpening) return false;
+                iCmdInfo = aCmdInfo;
+                Open();
+                break;
+
+            case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            case PVT_COMMAND_REMOVE_DATA_SINK:
+                if (!CloseDatapath(aCmdInfo)) return false;
+                break;
+
+            case PVT_COMMAND_PAUSE:
+                if (iState == EPausing) return false;
+                iCmdInfo = aCmdInfo;
+                Pause();
+                break;
+
+            case PVT_COMMAND_RESUME:
+                if (iState == EUnpausing) return false;
+                iCmdInfo = aCmdInfo;
+                Resume();
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDataChannelDatapath::SetCmd invalid command\n"));
+                break;
+        }
+
+    }
+    // A null pointer indicates a close for some reason
+    else
+    {
+        if (!CloseDatapath(aCmdInfo)) return false;
+    }
+
+    return true;
+}
+
+void CPV2WayDataChannelDatapath::CloseComplete()
+{
+    //If parent was closing, then let it notify the app.
+    if (!IsParentClosing())
+    {
+        if (iStateBeforeClose != EOpening)
+        {
+            //If close command issued
+            if (iCmdInfo)
+            {
+                CommandComplete(PVMFSuccess);
+            }
+            //Else if remote closed channel
+            else if ((i2Way->iState != EResetting) &&
+                     (i2Way->iState != EDisconnecting))
+            {
+                int error;
+                TPV2WayEventInfo* aEvent = NULL;
+                OSCL_TRY(error, aEvent = i2Way->GetEventInfoL());
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDataChannelDatapath::CloseComplete unable to notify app!\n"));
+                                     return);
+
+                aEvent->type = PVT_INDICATION_CLOSE_TRACK;
+                if (iType == EEncodeDatapath)
+                {
+                    aEvent->localBuffer[0] = OUTGOING;
+                }
+                else
+                {
+                    aEvent->localBuffer[0] = INCOMING;
+                }
+                *((TPVChannelId*)(aEvent->localBuffer + 4)) = iChannelId;
+
+                aEvent->localBufferSize = 8;
+                i2Way->Dispatch(aEvent);
+            }
+            //Else remote disconnect
+        }
+        //Else open failed.
+        else
+        {
+            CommandComplete(PVMFFailure);
+        }
+    }
+
+    i2Way->CheckState();
+}
+
+bool CPV2WayDataChannelDatapath::ParentIsClosing()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDataChannelDatapath::ParentIsClosing path state %d\n", iState));
+    return SetCmd(NULL);
+}
+
+void CPV2WayDataChannelDatapath::CommandComplete(PVMFStatus aStatus)
+{
+    iCmdInfo->status = aStatus;
+    i2Way->Dispatch(iCmdInfo);
+    iCmdInfo = NULL;
+}
+
+
+
+
diff --git a/engines/2way/src/pv_2way_data_channel_datapath.h b/engines/2way/src/pv_2way_data_channel_datapath.h
new file mode 100644
index 0000000..b71f780
--- /dev/null
+++ b/engines/2way/src/pv_2way_data_channel_datapath.h
@@ -0,0 +1,96 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_DATA_CHANNEL_DATAPATH_H_INCLUDED
+#define PV_2WAY_DATA_CHANNEL_DATAPATH_H_INCLUDED
+
+#ifndef PV_2WAY_DATAPATH_H_INCLUDED
+#include "pv_2way_datapath.h"
+#endif
+
+#ifndef PV_2WAY_CMD_CONTROL_DATAPATH_H_INCLUDED
+#include "pv_2way_cmd_control_datapath.h"
+#endif
+
+class CPV2WayDataChannelDatapath : public CPV2WayCmdControlDatapath
+{
+    public:
+        CPV2WayDataChannelDatapath(PVLogger *aLogger,
+                                   TPV2WayDatapathType aType,
+                                   PVMFFormatType aFormat,
+                                   CPV324m2Way *a2Way) :
+                CPV2WayCmdControlDatapath(aLogger, aType, aFormat, a2Way),
+                iChannelId(0),
+                iTSCPortTag(0)
+        {};
+
+        virtual ~CPV2WayDataChannelDatapath() {};
+
+        bool SetCmd(TPV2WayCmdInfo *aCmdInfo);
+
+        void SetTSCPortTag(int32 aPortTag)
+        {
+            iTSCPortTag = aPortTag;
+        }
+        int32 GetTSCPortTag()
+        {
+            return iTSCPortTag;
+        }
+
+        virtual void TSCPortClosed() = 0;
+        virtual PVMFPortInterface *GetTSCPort() = 0;
+
+        void SetChannelId(TPVChannelId aChannelId)
+        {
+            iChannelId = aChannelId;
+        }
+        TPVChannelId GetChannelId()
+        {
+            return iChannelId;
+        }
+
+    protected:
+        virtual void OpenComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void PauseComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void ResumeComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void CloseComplete();
+        void DatapathError()
+        {
+            SetCmd(NULL);
+        }
+
+        bool ParentIsClosing();
+        void CommandComplete(PVMFStatus aStatus);
+
+        TPVChannelId iChannelId;
+        int32 iTSCPortTag;
+
+};
+
+
+#endif //PV_2WAY_DATA_CHANNEL_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_datapath.cpp b/engines/2way/src/pv_2way_datapath.cpp
new file mode 100644
index 0000000..de136ac
--- /dev/null
+++ b/engines/2way/src/pv_2way_datapath.cpp
@@ -0,0 +1,1527 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_datapath.h"
+#include "pvmi_config_and_capability.h"
+#include "pv_mime_string_utils.h"
+
+bool CPV2WayPortPair::Connect()
+{
+    if ((iSrcPort.GetStatus() == EHasPort) &&
+            (iDestPort.GetStatus() == EHasPort))
+    {
+        if (iSrcPort.GetPort()->Connect(iDestPort.GetPort()) == PVMFSuccess)
+        {
+            iIsConnected = true;
+            return true;
+        }
+    }
+    return false;
+}
+
+bool CPV2WayPortPair::Disconnect()
+{
+    if ((iSrcPort.GetStatus() == EHasPort) &&
+            (iDestPort.GetStatus() == EHasPort))
+    {
+        if (iSrcPort.GetPort()->Disconnect() == PVMFSuccess)
+        {
+            iIsConnected = false;
+            return true;
+        }
+    }
+    return false;
+}
+
+CPVDatapathPort& CPVDatapathPort::operator=(const CPVDatapathPort & a)
+{
+    iRequestPortState = a.iRequestPortState;
+    iCanCancelPort = a.iCanCancelPort;
+    iPortSetType = a.iPortSetType;
+    iFormatType = a.iFormatType;
+    iDefaultFormatType = a.iDefaultFormatType;
+    iPortTag = a.iPortTag;
+    iPortPair = a.iPortPair;
+    return *this;
+}
+
+CPVDatapathNode& CPVDatapathNode::operator=(const CPVDatapathNode & a)
+{
+    iNode = a.iNode;
+    iConfigure = a.iConfigure;
+    iConfigTime = a.iConfigTime;
+    iCanNodePause = a.iCanNodePause;
+    iLoggoffOnReset = a.iLoggoffOnReset;
+    iOriginalState = a.iOriginalState;
+    iInputPort = a.iInputPort;
+    iOutputPort = a.iOutputPort;
+    iCommandIssued = a.iCommandIssued;
+    return *this;
+}
+
+bool CPV2WayDatapath::IsPortInDatapath(PVMFPortInterface *aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::IsPortInDatapath state %d, num port pairs %d\n", iState, iPortPairList.size()));
+    if (aPort)
+    {
+        for (uint32 i = 0; i < iPortPairList.size(); i++)
+        {
+            if ((iPortPairList[i].iSrcPort.GetPort() == aPort) ||
+                    (iPortPairList[i].iDestPort.GetPort() == aPort))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::IsPortInDatapath port found at idx %d\n", i));
+                return true;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::IsPortInDatapath no node found\n"));
+    return false;
+}
+
+bool CPV2WayDatapath::IsNodeInDatapath(PVMFNodeInterface *aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::IsNodeInDatapath state %d, num nodes %d\n", iState, iNodeList.size()));
+    if (aNode)
+    {
+        for (uint32 i = 0; i < iNodeList.size(); i++)
+        {
+            if ((PVMFNodeInterface *)iNodeList[i].iNode == aNode)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::IsNodeInDatapath node found at idx %d\n", i));
+                return true;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::IsNodeInDatapath no node found\n"));
+    return false;
+}
+
+bool CPV2WayDatapath::ResetDatapath()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::ResetDatapath state %d, num nodes %d\n", iState, iNodeList.size()));
+
+    if (iState == EClosed)
+    {
+        for (uint32 i = 0; i < iNodeList.size(); i++)
+        {
+            if (iNodeList[i].iLoggoffOnReset)
+            {
+                PVLOGGER_LOG_USE_ONLY(PVMFStatus status =)((PVMFNodeInterface *)iNodeList[i].iNode)->ThreadLogoff();
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::ResetDatapath thread logoff status %d\n", status));
+            }
+        }
+
+        iPortPairList.clear();
+        iNodeList.clear();
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+bool CPV2WayDatapath::AddNode(const CPVDatapathNode &aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::AddNode path state %d, num nodes %d\n", iState, iNodeList.size()));
+
+    if ((iState == EClosed) &&
+            (iNodeList.size() < MAX_DATAPATH_NODES))
+    {
+        CPVDatapathNode node(aNode);
+
+        node.iOriginalState = ((PVMFNodeInterface *)(node.iNode))->GetState();
+        node.iInputPort.iPortPair = NULL;
+        node.iOutputPort.iPortPair = NULL;
+
+        if (!iNodeList.empty())
+        {
+            CPV2WayPortPair portPair;
+            iPortPairList.push_back(portPair);
+            iNodeList.back().iOutputPort.iPortPair = &(iPortPairList.back());
+            node.iInputPort.iPortPair = &(iPortPairList.back());
+        }
+
+        iNodeList.push_back(node);
+        return true;
+    }
+    return false;
+}
+
+bool CPV2WayDatapath::Open()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::Open path type %d, state %d, num nodes %d\n", iType, iState, iNodeList.size()));
+    if (SingleNodeOpen() || iNodeList.size() > 1)
+    {
+        switch (iState)
+        {
+            case EClosed:
+                SetState(EOpening);
+                CheckPath();
+                //Fall through to next case.
+
+            case EOpening:
+                return true;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::Open invalid state to open\n"));
+                break;
+        }
+    }
+    return false;
+}
+
+bool CPV2WayDatapath::Close()
+{
+    uint32 i;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::Close path type %d, state %d\n", iType, iState));
+
+    if (iFsi)
+    {
+        OSCL_DEFAULT_FREE(iFsi);
+        iFsi = NULL;
+    }
+    iFsiLen = 0;
+
+    switch (iState)
+    {
+        default:
+            //Disconnect all port connections
+            for (i = 0; i < iPortPairList.size(); i++)
+            {
+                iPortPairList[i].Disconnect();
+            }
+
+            iAllPortsConnected = false;
+
+            iStateBeforeClose = iState;
+            SetState(EClosing);
+
+            //Close dependent paths
+            for (i = 0; i < iDependentPathList.size(); i++)
+            {
+                iDependentPathList[i]->Close();
+            }
+
+            CheckPath();
+            //Fall through to next case.
+
+        case EClosing:
+            return true;
+
+        case EClosed:
+            return false;
+    }
+}
+
+bool CPV2WayDatapath::Pause()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::Pause path type %d, state %d\n", iType, iState));
+    switch (iState)
+    {
+        case EOpened:
+            SetState(EPausing);
+            CheckPath();
+            //Fall through to next case.
+
+        case EPausing:
+            return true;
+
+        default:
+            return false;
+    }
+}
+
+bool CPV2WayDatapath::Resume()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::Resume path type %d, state %d\n", iType, iState));
+    switch (iState)
+    {
+        case EPaused:
+            SetState(EUnpausing);
+            CheckPath();
+            //Fall through to next case.
+
+        case EUnpausing:
+            return true;
+
+        default:
+            return false;
+    }
+}
+
+bool CPV2WayDatapath::AddParentDatapath(CPV2WayDatapath &aDatapath)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::AddParentDatapath path state %d, num paths %d\n", iState, iParentPathList.size()));
+
+    if ((iState == EClosed) &&
+            (iParentPathList.size() < MAX_PARENT_PATHS))
+    {
+        iParentPathList.push_back(&aDatapath);
+        return true;
+    }
+    return false;
+}
+
+bool CPV2WayDatapath::AddDependentDatapath(CPV2WayDatapath &aDatapath)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayDatapath::AddDependentDatapath path state %d, num paths %d\n", iState, iDependentPathList.size()));
+
+    if ((iState == EClosed) &&
+            (iDependentPathList.size() < MAX_PARENT_PATHS))
+    {
+        iDependentPathList.push_back(&aDatapath);
+        return true;
+    }
+    return false;
+}
+
+void CPV2WayDatapath::ConstructL()
+{
+    iNodeList.reserve(MAX_DATAPATH_NODES);
+    iPortPairList.reserve(MAX_DATAPATH_NODES);
+    iParentPathList.reserve(MAX_PARENT_PATHS);
+    iDependentPathList.reserve(MAX_DEPENDENT_PATHS);
+    iFsi = NULL;
+    iFsiLen = 0;
+}
+
+void CPV2WayDatapath::SetState(TPV2WayDatapathState aState)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::SetState cur %d, new %d\n", iState, aState));
+    iState = aState;
+}
+
+bool CPV2WayDatapath::IsDatapathNodeClosed(CPVDatapathNode &aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::IsDatapathNodeClosed\n"));
+    if (aNode.iCommandIssued) return false;
+
+    if (aNode.iInputPort.iPortPair &&
+            (aNode.iInputPort.iPortPair->iDestPort.GetStatus() != ENoPort)) return false;
+
+    if (aNode.iOutputPort.iPortPair &&
+            (aNode.iOutputPort.iPortPair->iSrcPort.GetStatus() != ENoPort)) return false;
+
+    /* Gkl - We check for node states that are less than or equal to the state in which the node was added
+    This is becoz the states are assymetric which sucks*/
+    if (!aNode.iIgnoreNodeState &&
+            (((PVMFNodeInterface *)(aNode.iNode))->GetState() > aNode.iOriginalState)) return false;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::IsDatapathNodeClosed node is closed\n"));
+
+    return true;
+}
+
+bool CPV2WayDatapath::CheckNodePortsL(CPVDatapathNode &aNode)
+{
+    PVMFStatus status;
+    TPV2WayNodeRequestPortParams reqPortParams;
+    CPV2WayPortPair *inPortPair = aNode.iInputPort.iPortPair;
+    CPV2WayPortPair *outPortPair = aNode.iOutputPort.iPortPair;
+    CPVDatapathPort *dataPort;
+    bool requestPort;
+    bool portRequestDone = true;
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts in req port state %d, port %x\n", aNode.iInputPort.iRequestPortState, inPortPair));
+
+    if (((PVMFNodeInterface *)(aNode.iNode))->GetState() == aNode.iInputPort.iRequestPortState)
+    {
+        if (inPortPair)
+        {
+            dataPort = (CPVDatapathPort *) & aNode.iInputPort;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts in port state %d\n", inPortPair->iDestPort.GetStatus()));
+            if (inPortPair->iDestPort.GetStatus() == ENoPort)
+            {
+                requestPort = false;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts in port request set type %d\n", aNode.iInputPort.iPortSetType));
+
+                switch (dataPort->iPortSetType)
+                {
+                    case EUserDefined:
+                        requestPort = true;
+                        break;
+
+                    case EConnectedPortFormat:
+                        if (inPortPair->iSrcPort.GetStatus() == EHasPort)
+                        {
+                            dataPort->iFormatType = GetPortFormatType(*inPortPair->iSrcPort.GetPort(), false, inPortPair->iDestPort.GetPort());
+                            requestPort = true;
+                        }
+                        break;
+
+                    case EUseOtherNodePortFormat:
+                        if (outPortPair->iSrcPort.GetStatus() == EHasPort)
+                        {
+                            dataPort->iFormatType = GetPortFormatType(*outPortPair->iSrcPort.GetPort(), false, outPortPair->iDestPort.GetPort());
+                            requestPort = true;
+                        }
+                        break;
+
+                    case EAppDefined:
+                        requestPort = true;
+                        break;
+
+                    default:
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckNodePorts undefined set type\n"));
+                        break;
+                }
+
+                if (requestPort)
+                {
+                    reqPortParams.portTag = dataPort->iPortTag;
+                    reqPortParams.format = dataPort->iFormatType;
+
+                    status = CheckConfig(EConfigBeforeReqInPort, aNode);
+                    switch (status)
+                    {
+                        case PVMFPending:
+                            break;
+
+                        case PVMFSuccess:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts request input port, format %s, tag %d\n", reqPortParams.format.getMIMEStrPtr(), reqPortParams.portTag));
+                            inPortPair->iDestPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_REQUESTPORT, aNode, &reqPortParams));
+                            inPortPair->iDestPort.SetStatus(ERequestPort);
+                            break;
+
+                        default:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckNodePorts node config failed\n"));
+                            OSCL_LEAVE(status);
+                            return false;
+                    }
+                }
+            }
+
+            if (inPortPair->iDestPort.GetStatus() != EHasPort)
+            {
+                portRequestDone = false;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts out req port state %d, port %x\n", aNode.iOutputPort.iRequestPortState, outPortPair));
+
+    if (((PVMFNodeInterface *)(aNode.iNode))->GetState() == aNode.iOutputPort.iRequestPortState)
+    {
+        if (outPortPair)
+        {
+            dataPort = (CPVDatapathPort *) & aNode.iOutputPort;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts out port state %d\n", outPortPair->iSrcPort.GetStatus()));
+            if (outPortPair->iSrcPort.GetStatus() == ENoPort)
+            {
+                requestPort = false;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts out port request set type %d\n", aNode.iOutputPort.iPortSetType));
+
+                switch (dataPort->iPortSetType)
+                {
+                    case EUserDefined:
+                        requestPort = true;
+                        break;
+
+                    case EConnectedPortFormat:
+                        if (outPortPair->iDestPort.GetStatus() == EHasPort)
+                        {
+                            dataPort->iFormatType = GetPortFormatType(*outPortPair->iDestPort.GetPort(), true, outPortPair->iSrcPort.GetPort());
+                            requestPort = true;
+                        }
+                        break;
+
+                    case EUseOtherNodePortFormat:
+                        if (inPortPair->iDestPort.GetStatus() == EHasPort)
+                        {
+                            dataPort->iFormatType = GetPortFormatType(*inPortPair->iDestPort.GetPort(), true, inPortPair->iSrcPort.GetPort());
+                            OSCL_ASSERT(dataPort->iFormatType != PVMF_MIME_FORMAT_UNKNOWN);
+                            requestPort = true;
+                        }
+                        break;
+
+                    case EAppDefined:
+                        requestPort = true;
+                        break;
+
+                    default:
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckNodePorts undefined set type\n"));
+                        break;
+                }
+
+                if (requestPort)
+                {
+                    reqPortParams.portTag = dataPort->iPortTag;
+                    reqPortParams.format = dataPort->iFormatType;
+
+                    status = CheckConfig(EConfigBeforeReqOutPort, aNode);
+                    switch (status)
+                    {
+                        case PVMFPending:
+                            break;
+
+                        case PVMFSuccess:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckNodePorts request output port, format %s, type %d\n", reqPortParams.format.getMIMEStrPtr(), reqPortParams.portTag));
+                            outPortPair->iSrcPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_REQUESTPORT, aNode, &reqPortParams));
+                            outPortPair->iSrcPort.SetStatus(ERequestPort);
+                            break;
+
+                        default:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckNodePorts node config failed\n"));
+                            OSCL_LEAVE(status);
+                            return false;
+                    }
+                }
+            }
+
+            if (outPortPair->iSrcPort.GetStatus() != EHasPort)
+            {
+                portRequestDone = false;
+            }
+        }
+    }
+
+    return portRequestDone;
+}
+
+PVMFStatus CPV2WayDatapath::PortStatusChange(PVMFNodeInterface *aNode, PVMFCommandId aId, PVMFPortInterface *aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::PortStatusChange id %d, port %x\n", aId, aPort));
+    PVMFStatus status = PVMFFailure;
+    int32 error = 0;
+    CPV2WayPort *port = NULL;
+    OsclAny *configPtr = NULL;
+    PvmiKvp portParams;
+    PvmiKvp *portParamsReturn = NULL;
+    PVMFFormatType format = PVMF_MIME_FORMAT_UNKNOWN;
+    CPV2WayPortPair *portPair = NULL;
+    bool isInputPort = false;
+    bool isAppDefined;
+
+    for (uint32 i = 0; i < iNodeList.size(); i++)
+    {
+        if (((PVMFNodeInterface *)(iNodeList[i].iNode)) == aNode)
+        {
+            CPV2WayPortPair* inPortPair = iNodeList[i].iInputPort.iPortPair;
+            CPV2WayPortPair* outPortPair = iNodeList[i].iOutputPort.iPortPair;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                            (0, "CPV2WayDatapath::PortStatusChange node %d\n", i));
+            if (inPortPair &&
+                    (inPortPair->iDestPort.GetCmdId() == aId))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                (0, "CPV2WayDatapath::PortStatusChange found input port\n"));
+                format = iNodeList[i].iInputPort.iFormatType;
+                port = &inPortPair->iDestPort;
+                portPair = inPortPair;
+                isInputPort = true;
+                isAppDefined = (iNodeList[i].iInputPort.iPortSetType == EAppDefined);
+            }
+            else if (outPortPair &&
+                     (outPortPair->iSrcPort.GetCmdId() == aId))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                (0, "CPV2WayDatapath::PortStatusChange found output port\n"));
+                format = iNodeList[i].iOutputPort.iFormatType;
+                port = &outPortPair->iSrcPort;
+                portPair = outPortPair;
+                isInputPort = false;
+                isAppDefined = (iNodeList[i].iOutputPort.iPortSetType == EAppDefined);
+            }
+            break;
+        }
+    }
+
+    if (port)
+    {
+        if (aPort && !isAppDefined)
+        {
+            aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, configPtr);
+
+            //If config ptr exists, otherwise assume port has been configured.
+            if (configPtr)
+            {
+                if (isInputPort)
+                {
+                    portParams.key = OSCL_CONST_CAST(char*, INPUT_FORMATS_VALTYPE);
+                    portParams.length = oscl_strlen(INPUT_FORMATS_VALTYPE);
+                    portParams.capacity = oscl_strlen(INPUT_FORMATS_VALTYPE);
+                }
+                else
+                {
+                    portParams.key = OSCL_CONST_CAST(char*, OUTPUT_FORMATS_VALTYPE);
+                    portParams.length = oscl_strlen(OUTPUT_FORMATS_VALTYPE);
+                    portParams.capacity = oscl_strlen(OUTPUT_FORMATS_VALTYPE);
+                }
+
+                portParams.value.pChar_value = OSCL_STATIC_CAST(mbchar*, format.getMIMEStrPtr());
+                error = SetParametersSync((PvmiCapabilityAndConfig *)configPtr, &portParams, portParamsReturn);
+
+                if (error || portParamsReturn != NULL)
+                {
+                    portParamsReturn = NULL;
+                    portParams.key = OSCL_CONST_CAST(char*, "x-pvmf/port/formattype;valtype=char*");
+                    portParams.length = oscl_strlen("x-pvmf/port/formattype;valtype=char*");
+                    portParams.capacity = portParams.length;
+                    portParams.value.pChar_value = OSCL_STATIC_CAST(mbchar*, format.getMIMEStrPtr());
+                    error = SetParametersSync((PvmiCapabilityAndConfig *)configPtr,
+                                              &portParams, portParamsReturn);
+                }
+
+                if ((error || portParamsReturn != NULL) && isInputPort)
+                {
+                    // this would be a file MIO component which requires explicit setting of audio and video formats
+                    portParamsReturn = NULL;
+                    if (format.isAudio())
+                        portParams.key = OSCL_CONST_CAST(char*, MOUT_AUDIO_FORMAT_KEY);
+                    else
+                        portParams.key = OSCL_CONST_CAST(char*, MOUT_VIDEO_FORMAT_KEY);
+                    portParams.length = oscl_strlen(portParams.key);
+                    portParams.capacity = portParams.length;
+
+
+                    /* This is for the MIO components having the convention
+                       of returning uint32 for a query and requiring pChar for a setting
+                       we don't know if we are talking to an MIO or a decoder node
+                       (which will want a uint32), so we try both.  Try the pchar
+                       first, because if its expecting pchar and gets uint32, it will
+                       crash.
+                    */
+
+                    portParams.value.pChar_value = OSCL_STATIC_CAST(mbchar*, format.getMIMEStrPtr());
+
+                    error = SetParametersSync((PvmiCapabilityAndConfig *)configPtr, &portParams, portParamsReturn);
+                    if (error)
+                    {
+                        portParams.value.pChar_value = OSCL_STATIC_CAST(mbchar*, format.getMIMEStrPtr());
+                        error = SetParametersSync((PvmiCapabilityAndConfig *)configPtr, &portParams, portParamsReturn);
+                    }
+                    portParamsReturn = NULL;
+                    if (format.isAudio())
+                    {
+                        portParams.key = OSCL_CONST_CAST(char*, MOUT_AUDIO_SAMPLING_RATE_KEY);
+                        portParams.value.uint32_value = 8000;
+                    }
+                    else
+                    {
+                        portParams.key = OSCL_CONST_CAST(char*, MOUT_VIDEO_HEIGHT_KEY);
+                        portParams.value.uint32_value = 176;
+                    }
+                    portParams.length = oscl_strlen(portParams.key);
+                    portParams.capacity = portParams.length;
+                    error = SetParametersSync((PvmiCapabilityAndConfig *)configPtr,
+                                              &portParams, portParamsReturn);
+                    if (error && portParamsReturn != NULL)
+                    {
+                        error = 0;
+                        portParamsReturn = NULL;
+                    }
+                }
+
+                if (error || portParamsReturn != NULL)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::PortStatusChange setParametersSync failed %d at parameter %x!\n", error, portParamsReturn));
+                }
+                else
+                {
+                    status = PVMFSuccess;
+                }
+            }
+            else
+            {
+                status = PVMFSuccess;
+            }
+        }
+        else
+        {
+            status = isAppDefined ? PVMFSuccess : PVMFFailure;
+        }
+
+        SetPort(*port, aPort);
+        if (status != PVMFSuccess)
+        {
+            if (portPair->iDestPort.GetPort() && portPair->iSrcPort.GetPort())
+            {
+                PVMFFormatType format2 = PVMF_MIME_FORMAT_UNKNOWN;
+                // now try with two ports
+                if (isInputPort)
+                {
+                    portParams.key = OSCL_CONST_CAST(char*, INPUT_FORMATS_VALTYPE);
+                    portParams.length = oscl_strlen(INPUT_FORMATS_VALTYPE);
+                    portParams.capacity = oscl_strlen(INPUT_FORMATS_VALTYPE);
+                }
+                else
+                {
+                    portParams.key = OSCL_CONST_CAST(char*, OUTPUT_FORMATS_VALTYPE);
+                    portParams.length = oscl_strlen(OUTPUT_FORMATS_VALTYPE);
+                    portParams.capacity = oscl_strlen(OUTPUT_FORMATS_VALTYPE);
+                }
+                format2 = GetPortFormatType(*portPair->iDestPort.GetPort(),
+                                            true, portPair->iSrcPort.GetPort());
+                portParams.value.pChar_value = OSCL_STATIC_CAST(mbchar*, format2.getMIMEStrPtr());
+                error = SetParametersSync((PvmiCapabilityAndConfig *)configPtr, &portParams, portParamsReturn);
+                if (!error)
+                {
+                    status = PVMFSuccess;
+                }
+            }
+        }
+
+        if (status == PVMFSuccess)
+        {
+            if ((portPair->iSrcPort.GetStatus() == EHasPort) &&
+                    (portPair->iDestPort.GetStatus() == EHasPort))
+            {
+                // we'll want to connect these ports so that
+                // settings get negotiated, but we'll then
+                // suspend them so that data does not flow until
+                // the datpath is opened.
+                if (!portPair->Connect())
+                    return PVMFFailure;
+                portPair->iSrcPort.GetPort()->SuspendInput();
+                portPair->iDestPort.GetPort()->SuspendInput();
+            }
+        }
+
+        return status;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::PortStatusChange no port found!\n"));
+        return status;
+    }
+}
+
+int32 CPV2WayDatapath::SetParametersSync(PvmiCapabilityAndConfig * configPtr,
+        PvmiKvp* portParams,
+        PvmiKvp*& portParamsReturn)
+{
+    int32 error;
+    OSCL_TRY(error, configPtr->setParametersSync(NULL, portParams, 1, portParamsReturn));
+    return error;
+}
+
+void CPV2WayDatapath::CloseNodePorts(CPVDatapathNode &aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CloseNodePorts\n"));
+
+    CPV2WayPortPair *portPair;
+
+    portPair = aNode.iInputPort.iPortPair;
+    if (portPair &&
+            (portPair->iDestPort.GetStatus() == EHasPort))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CloseNodePorts closing input port\n"));
+        portPair->iDestPort.SetPort(NULL);
+    }
+
+    portPair = aNode.iOutputPort.iPortPair;
+    if (portPair &&
+            (portPair->iSrcPort.GetStatus() == EHasPort))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CloseNodePorts closing output port\n"));
+        portPair->iSrcPort.SetPort(NULL);
+    }
+
+    return;
+}
+
+PVMFCommandId CPV2WayDatapath::SendNodeCmdL(PV2WayNodeCmdType aCmd,
+        CPVDatapathNode &aNode,
+        void *aParam)
+{
+    PVMFCommandId id;
+    id = i2Way->SendNodeCmdL(aCmd, &aNode.iNode, this, aParam);
+    aNode.iCommandIssued = true;
+    return id;
+}
+
+PVMFStatus CPV2WayDatapath::CheckConfig(TPVNodeConfigTimeType aConfigTime, CPVDatapathNode &aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckConfig config %x, time %d\n", aNode.iConfigure, aConfigTime));
+    if (aNode.iConfigure &&
+            (aNode.iConfigTime == aConfigTime))
+    {
+        return aNode.iConfigure->ConfigureNode(&aNode);
+    }
+
+    return PVMFSuccess;
+}
+
+void CPV2WayDatapath::CheckOpen()
+{
+    uint32 i;
+    bool checkPort = false;
+    bool nodesStarted = true;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckOpen state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckOpen (0x%x) node %d state %d, cmd issued %d\n", this, i, iNodeList[i].iNode.iNode->GetState(), iNodeList[i].iCommandIssued));
+
+        if (iNodeList[i].iCommandIssued)
+        {
+            nodesStarted = false;
+            continue;
+        }
+
+        switch (iNodeList[i].iNode.iNode->GetState())
+        {
+            case EPVMFNodeIdle:
+                nodesStarted = false;
+                if (!CheckNodePorts(checkPort, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen problem checking ports\n"));
+                    DatapathError();
+                    return;
+                }
+                if (checkPort)
+                {
+                    switch (CheckConfig(EConfigBeforeInit, iNodeList[i]))
+                    {
+                        case PVMFPending:
+                            continue;
+
+                        case PVMFSuccess:
+                            break;
+
+                        default:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen node config failed\n"));
+                            DatapathError();
+                            return;
+                    }
+
+                    if (!SendNodeCmd(PV2WAY_NODE_CMD_INIT, i))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen unable to initialize node\n"));
+                        DatapathError();
+                        return;
+                    }
+                }
+                break;
+
+            case EPVMFNodeInitialized:
+                nodesStarted = false;
+                if (!CheckNodePorts(checkPort, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen problem checking ports\n"));
+                    DatapathError();
+                    return;
+                }
+                if (checkPort)
+                {
+                    switch (CheckConfig(EConfigBeforeStart, iNodeList[i]))
+                    {
+                        case PVMFPending:
+                            continue;
+
+                        case PVMFSuccess:
+                            break;
+
+                        default:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen node config failed\n"));
+                            DatapathError();
+                            return;
+                    }
+
+                    if (!SendNodeCmd(PV2WAY_NODE_CMD_PREPARE, i))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen unable to start node\n"));
+                        DatapathError();
+                        return;
+                    }
+                }
+                break;
+
+            case EPVMFNodePrepared:
+                nodesStarted = false;
+                if (!CheckNodePorts(checkPort, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen problem checking ports\n"));
+                    DatapathError();
+                    return;
+                }
+                if (checkPort)
+                {
+                    //Make sure downstream node is started first.
+                    if ((i == iNodeList.size() - 1) || (iNodeList[i+1].iNode.iNode->GetState() == EPVMFNodeStarted))
+                    {
+                        switch (CheckConfig(EConfigBeforeStart, iNodeList[i]))
+                        {
+                            case PVMFPending:
+                                continue;
+
+                            case PVMFSuccess:
+                                break;
+
+                            default:
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen node config failed\n"));
+                                DatapathError();
+                                return;
+                        }
+
+                        if (!CheckPathSpecificStart())
+                        {
+                            continue;
+                        }
+
+                        if (iAllPortsConnected || SingleNodeOpen())
+                        {
+                            if (!SendNodeCmd(PV2WAY_NODE_CMD_START, i))
+                            {
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen unable to start node\n"));
+                                DatapathError();
+                                return;
+                            }
+                        }
+                    }
+                }
+                break;
+
+            case EPVMFNodeStarted:
+                if (!CheckNodePorts(checkPort, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckOpen problem checking ports\n"));
+                    DatapathError();
+                    return;
+                }
+                break;
+
+            default:
+                nodesStarted = false;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckOpen transitional node state!\n"));
+                break;
+        }
+    }
+
+    //All nodes in path have not been started yet.
+    if (!nodesStarted) return;
+
+    //Check if all ports have been connected.
+    if (!iAllPortsConnected && !SingleNodeOpen()) return;
+
+    //Make path specific check
+    if (!CheckPathSpecificOpen())
+    {
+        return;
+    }
+
+//Connect is done when both ports in a port pair are requested
+//	//If reached this point then all ports have been allocated and datapath is deemed open, connect ports and notify upper layer.
+    for (i = 0; i < iPortPairList.size(); i++)
+    {
+        iPortPairList[i].iDestPort.GetPort()->ResumeInput();
+        iPortPairList[i].iSrcPort.GetPort()->ResumeInput();
+    }
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckOpen open complete\n"));
+
+    SetState(EOpened);
+    OpenComplete();
+    return;
+}
+
+bool CPV2WayDatapath::CheckNodePorts(bool& aCheckPort, int32 i)
+{
+    int32 error;
+    OSCL_TRY(error, aCheckPort = CheckNodePortsL(iNodeList[i]));
+    OSCL_FIRST_CATCH_ANY(error,
+                         return false;);
+    return true;
+}
+
+void CPV2WayDatapath::CheckPause()
+{
+    uint32 i;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause node %d state %d, can pause %d, cmd issued %d\n", i, iNodeList[i].iNode.iNode->GetState(), iNodeList[i].iCanNodePause, iNodeList[i].iCommandIssued));
+
+        if (!iNodeList[i].iCanNodePause) continue;
+        if (iNodeList[i].iCommandIssued) continue;
+
+        switch (iNodeList[i].iNode.iNode->GetState())
+        {
+            case EPVMFNodeStarted:
+                if (!SendNodeCmd(PV2WAY_NODE_CMD_PAUSE, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckPause unable to pause node\n"));
+                    DatapathError();
+                    return;
+                }
+
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause transitional node state!\n"));
+                break;
+        }
+    }
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        //If possible pause node is not paused.
+        if (iNodeList[i].iCanNodePause && (iNodeList[i].iNode.iNode->GetState() != EPVMFNodePaused))
+        {
+            return;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause pause complete\n"));
+
+    //If reached this point then the datapath is deemed paused, notify upper layer.
+    SetState(EPaused);
+    PauseComplete();
+    return;
+}
+
+void CPV2WayDatapath::CheckResume()
+{
+    uint32 i;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume node %d state %d, can pause %d, cmd issued %d\n", i, iNodeList[i].iNode.iNode->GetState(), iNodeList[i].iCanNodePause, iNodeList[i].iCommandIssued));
+
+        if (!iNodeList[i].iCanNodePause) continue;
+        if (iNodeList[i].iCommandIssued) continue;
+
+        switch (iNodeList[i].iNode.iNode->GetState())
+        {
+            case EPVMFNodePaused:
+                if (!SendNodeCmd(PV2WAY_NODE_CMD_START, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckResume unable to pause node\n"));
+                    DatapathError();
+                    return;
+                }
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume transitional node state!\n"));
+                break;
+        }
+    }
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        //If possible pause node is not started.
+        if (iNodeList[i].iCanNodePause && (iNodeList[i].iNode.iNode->GetState() != EPVMFNodeStarted))
+        {
+            return;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume resume complete\n"));
+
+    //If reached this point then the datapath is deemed resumed, notify upper layer.
+    SetState(EOpened);
+    ResumeComplete();
+    return;
+}
+
+bool CPV2WayDatapath::SendNodeCmd(PV2WayNodeCmdType cmd, int32 i)
+{
+    int32 error;
+    OSCL_TRY(error, SendNodeCmdL(cmd, iNodeList[i]));
+    OSCL_FIRST_CATCH_ANY(error,
+                         return false;);
+    return true;
+}
+
+void CPV2WayDatapath::CheckClosed()
+{
+    int32 i;
+    int32 error;
+    PVMFCommandId id;
+    CPV2WayPortPair *inPortPair;
+    CPV2WayPortPair *outPortPair;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckClosed state %d\n", iState));
+
+    if (!HaveAllDependentPathsClosed())
+    {
+        return;
+    }
+
+    if (!PathSpecificClose())
+    {
+        return;
+    }
+
+    // List must be closed one node at a time starting from the destination to the source to make sure all memory fragments are freed up to the correct node.
+    for (i = (int32) iNodeList.size() - 1; i >= 0 ; i--)
+    {
+
+        if (IsDatapathNodeClosed(iNodeList[i])) continue;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckClosed node %d cur state %d, orig state %d, cmd issued %d\n", i, iNodeList[i].iNode.iNode->GetState(), iNodeList[i].iOriginalState, iNodeList[i].iCommandIssued));
+
+        if (iNodeList[i].iCommandIssued) return;
+
+        switch (iNodeList[i].iNode.iNode->GetState())
+        {
+            case EPVMFNodeCreated:
+            case EPVMFNodeIdle:
+                CloseNodePorts(iNodeList[i]);
+                continue;
+
+            case EPVMFNodeInitialized:
+            case EPVMFNodePrepared:
+            case EPVMFNodeError:
+                CloseNodePorts(iNodeList[i]);
+                if (iNodeList[i].CloseableState())
+                    continue;
+
+                if (!SendNodeCmd(PV2WAY_NODE_CMD_RESET, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckClosed unable to reset node\n"));
+                    return;
+                }
+                return;
+
+            case EPVMFNodeStarted:
+            case EPVMFNodePaused:
+            {
+                inPortPair = iNodeList[i].iInputPort.iPortPair;
+                outPortPair = iNodeList[i].iOutputPort.iPortPair;
+
+                //Must at least release ports.
+
+                if (inPortPair)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckClosed release in port, state %d, can cancel %d\n", inPortPair->iDestPort.GetStatus(), iNodeList[i].iInputPort.iCanCancelPort));
+                    if (inPortPair->iDestPort.GetStatus() == EHasPort)
+                    {
+                        OSCL_TRY(error, inPortPair->iDestPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_RELEASEPORT, iNodeList[i], inPortPair->iDestPort.GetPort())));
+                        OSCL_FIRST_CATCH_ANY(error,
+                                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckClosed unable to release input port\n"));
+                                             return;);
+
+                        inPortPair->iDestPort.SetStatus(EReleasePort);
+                        return;
+                    }
+                    else if ((inPortPair->iDestPort.GetStatus() == ERequestPort) &&
+                             iNodeList[i].iInputPort.iCanCancelPort)
+                    {
+                        id = inPortPair->iDestPort.GetCmdId();
+                        OSCL_TRY(error, inPortPair->iDestPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_CANCELCMD, iNodeList[i], &id)));
+                        OSCL_FIRST_CATCH_ANY(error,
+                                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckClosed unable to cancel request input port\n"));
+                                             return;);
+
+                        inPortPair->iDestPort.SetStatus(EReleasePort);
+                        return;
+                    }
+                }
+
+                if (outPortPair)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckClosed release out port, state %d, can cancel %d\n", outPortPair->iSrcPort.GetStatus(), iNodeList[i].iOutputPort.iCanCancelPort));
+                    if (outPortPair->iSrcPort.GetStatus() == EHasPort)
+                    {
+                        OSCL_TRY(error, outPortPair->iSrcPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_RELEASEPORT, iNodeList[i], outPortPair->iSrcPort.GetPort())));
+                        OSCL_FIRST_CATCH_ANY(error,
+                                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckClosed unable to release output port\n"));
+                                             return;);
+
+                        outPortPair->iSrcPort.SetStatus(EReleasePort);
+                        return;
+                    }
+                    else if ((outPortPair->iSrcPort.GetStatus() == EHasPort) &&
+                             iNodeList[i].iOutputPort.iCanCancelPort)
+                    {
+                        id = outPortPair->iSrcPort.GetCmdId();
+                        OSCL_TRY(error, outPortPair->iSrcPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_CANCELCMD, iNodeList[i], &id)));
+                        OSCL_FIRST_CATCH_ANY(error,
+                                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckClosed unable to cancel request output port\n"));
+                                             return;);
+
+                        outPortPair->iSrcPort.SetStatus(EReleasePort);
+                        return;
+                    }
+                }
+
+                if (inPortPair)
+                {
+                    switch (inPortPair->iDestPort.GetStatus())
+                    {
+                        case EHasPort:
+                        case ENoPort:
+                            break;
+
+                        default:
+                            return;
+                    }
+                }
+
+                if (outPortPair)
+                {
+                    switch (outPortPair->iSrcPort.GetStatus())
+                    {
+                        case EHasPort:
+                        case ENoPort:
+                            break;
+
+                        default:
+                            return;
+                    }
+                }
+
+                if (!SendNodeCmd(PV2WAY_NODE_CMD_STOP, i))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckClosed unable to stop node\n"));
+                    return;
+                }
+
+                return;
+            }
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckClosed transitional node state!\n"));
+                return;
+        }
+    }
+
+    for (i = 0; i < (int32) iNodeList.size(); i ++)
+    {
+        //If node is not in its original state when datapath was opened then not closed yet.
+        if (!IsDatapathNodeClosed(iNodeList[i])) return;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckClosed close complete\n"));
+
+    //If reached this point then all ports have been deallocated and datapath is deemed closed, notify upper layer.
+    SetState(EClosed);
+    CloseComplete();
+    NotifyParentPaths();
+
+    return;
+}
+
+void CPV2WayDatapath::CheckPath()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPath path type %d, format %s, state %d\n", iType, iFormat.getMIMEStrPtr(), iState));
+
+    switch (iState)
+    {
+        case EOpening:
+            CheckOpen();
+            break;
+        case EPausing:
+            CheckPause();
+            break;
+        case EUnpausing:
+            CheckResume();
+            break;
+        case EClosing:
+            CheckClosed();
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "CPV2WayDatapath::CheckPath warning: static state\n"));
+            break;
+    }
+}
+
+void CPV2WayDatapath::CommandHandler(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CommandHandler path type %d, state %d, cmd type %d, status %d\n", iType, iState, aType, aResponse.GetCmdStatus()));
+    CPV2WayNodeContextData *data = (CPV2WayNodeContextData *) aResponse.GetContext();
+    uint16 i;
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        if (iNodeList[i].iNode.iNode == data->iNode)
+        {
+            iNodeList[i].iCommandIssued = false;
+            break;
+        }
+    }
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_REQUESTPORT:
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                PortStatusChange(data->iNode, aResponse.GetCmdId(), NULL);
+                DatapathError();
+            }
+            else
+            {
+                if (PortStatusChange(data->iNode, aResponse.GetCmdId(), (PVMFPortInterface *) aResponse.GetEventData()) != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CommandHandler PortStatusChange failed!\n"));
+                    DatapathError();
+                }
+                else
+                {
+
+                    bool isConnected;
+                    //Check if all ports have been allocated.
+                    for (i = 0, isConnected = true; i < iPortPairList.size(); i++)
+                    {
+                        if (!iPortPairList[i].iIsConnected)
+                        {
+                            //If all ports have not been connected yet
+                            isConnected = false;
+                            break;
+                        }
+                        // right here- check for negotiated between the two!
+                    }
+
+                    iAllPortsConnected = isConnected;
+                }
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_RELEASEPORT:
+        case PV2WAY_NODE_CMD_CANCELCMD:
+            PortStatusChange(data->iNode, aResponse.GetCmdId(), NULL);
+            break;
+        case PV2WAY_NODE_CMD_START:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (i2Way->IsSinkNode(data->iNode))
+                {
+                    TPV2WayNode* sink_node = i2Way->GetTPV2WayNode(i2Way->iSinkNodes, data->iNode);
+                    OSCL_ASSERT(sink_node);
+
+                    i2Way->SendNodeCmdL(PV2WAY_NODE_CMD_SKIP_MEDIA_DATA, sink_node, i2Way);
+                }
+            }
+            else
+            {
+                DatapathError();
+            }
+            break;
+        default:
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                DatapathError();
+            }
+            break;
+    }
+
+    CheckPath();
+    return;
+}
+
+void CPV2WayDatapath::DependentPathClosed(CPV2WayDatapath *aDependentPath)
+{
+    OSCL_UNUSED_ARG(aDependentPath);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::DependentPathClosed path state %d\n", iState));
+    if (iState == EClosing)
+    {
+        //Start closing this path.
+        CheckPath();
+    }
+    return;
+}
+
+bool CPV2WayDatapath::HaveAllDependentPathsClosed()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::HaveAllDependentPathsClosed path state %d\n", iState));
+    for (uint32 i = 0; i < iDependentPathList.size(); i ++)
+    {
+        if (iDependentPathList[i]->GetState() != EClosed)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::DependentPathClosed not all dependent paths closed, %d\n", i));
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool CPV2WayDatapath::IsParentClosing()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::IsParentClosing path state %d\n", iState));
+    for (uint32 i = 0; i < iParentPathList.size(); i++)
+    {
+        if (iParentPathList[i]->GetState() == EClosing)
+        {
+            //Parent datapath is closing
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::IsParentClosing parent path closing, %d\n", i));
+            return true;
+        }
+    }
+
+    //No parent datapath is closing
+    return false;
+}
+
+void CPV2WayDatapath::NotifyParentPaths()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::NotifyParentPaths path state %d\n", iState));
+    for (uint32 i = 0; i < iParentPathList.size(); i++)
+    {
+        iParentPathList[i]->DependentPathClosed(this);
+    }
+    return;
+}
+
+bool CPV2WayDatapath::ParentIsClosing()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::ParentIsClosing path state %d\n", iState));
+    return Close();
+}
+
+PVMFStatus CPV2WayDatapath::GetKvp(PVMFPortInterface &aPort,
+                                   bool aInput,
+                                   PvmiKvp*& aKvp,
+                                   int32& aNumKvpElem,
+                                   OsclAny*& aconfigPtr)
+{
+    PVMFStatus status = PVMFFailure;
+    PvmiCapabilityContext context = NULL;
+    PvmiKeyType keyType;
+
+    aPort.QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, aconfigPtr);
+    if (aconfigPtr)
+    {
+        if (aInput)
+        {
+            keyType = OSCL_CONST_CAST(char*, INPUT_FORMATS_CAP_QUERY);
+        }
+        else
+        {
+            keyType = OSCL_CONST_CAST(char*, OUTPUT_FORMATS_CAP_QUERY);
+        }
+
+        status = ((PvmiCapabilityAndConfig *)aconfigPtr)->getParametersSync(NULL,
+                 keyType, aKvp, aNumKvpElem, context);
+
+        if (status != PVMFSuccess && aInput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV2WayDatapath::GetKvp 1st getParametersSync failed %d.  Trying another\n", status));
+
+            keyType = OSCL_CONST_CAST(char*, "x-pvmf/video/decode/input_formats");
+            status = ((PvmiCapabilityAndConfig *)aconfigPtr)->getParametersSync(NULL,
+                     keyType, aKvp, aNumKvpElem, context);
+        }
+
+        if (status != PVMFSuccess && !aInput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV2WayDatapath::GetKvp 2nd getParametersSync failed %d.  Trying another\n", status));
+
+            keyType = OSCL_CONST_CAST(char*, "x-pvmf/audio/decode/output_formats");
+            status = ((PvmiCapabilityAndConfig *)aconfigPtr)->getParametersSync(NULL,
+                     keyType, aKvp, aNumKvpElem, context);
+        }
+    }
+    return status;
+}
+
+PVMFFormatType CPV2WayDatapath::GetPortFormatType(PVMFPortInterface &aPort,
+        bool aInput,
+        PVMFPortInterface *aOtherPort)
+{
+    PVMFStatus status = PVMFFailure;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV2WayDatapath::GetPortFormatType, is input %d\n", aInput));
+    PvmiKvp *kvp = NULL;
+    int32 numkvpElements = 0;
+    PvmiKvp *kvpOther = NULL;
+    int32 numkvpOtherElements = 0;
+    OsclAny *configPtr = NULL;
+    OsclAny *configOtherPtr = NULL;
+    PVMFFormatType format = PVMF_MIME_FORMAT_UNKNOWN;
+
+
+    //If config ptr exists, otherwise assume port has been configured.
+    status = GetKvp(aPort, aInput, kvp, numkvpElements, configPtr);
+    if (status == PVMFSuccess && (aOtherPort != NULL))
+    {
+        status = GetKvp(*aOtherPort, !aInput, kvpOther, numkvpOtherElements, configOtherPtr);
+    }
+
+    if (status == PVMFSuccess)
+    {
+        for (int32 ii = 0; ii < numkvpElements; ++ii)
+        {
+            if ((pv_mime_strcmp(kvp[ii].key, "x-pvmf/port/formattype;valtype=char*") == 0) ||
+                    (aInput && (pv_mime_strcmp(kvp[ii].key, INPUT_FORMATS_VALTYPE) == 0)) ||
+                    (pv_mime_strcmp(kvp[ii].key, OUTPUT_FORMATS_VALTYPE) == 0))
+            {
+                format = kvp[ii].value.pChar_value;
+                // loop through other port, look for a match
+                // if there is a match return it
+                for (int jj = 0; jj < numkvpOtherElements; ++jj)
+                {
+                    if ((format == kvpOther[jj].value.pChar_value) &&
+                            ((pv_mime_strcmp(kvpOther[jj].key, "x-pvmf/port/formattype;valtype=char*") == 0) ||
+                             (pv_mime_strcmp(kvpOther[ii].key, INPUT_FORMATS_VALTYPE) == 0) ||
+                             (pv_mime_strcmp(kvpOther[ii].key, OUTPUT_FORMATS_VALTYPE) == 0)))
+                    {
+                        ((PvmiCapabilityAndConfig *)configPtr)->releaseParameters(NULL,
+                                kvp, numkvpElements);
+                        return format;
+                    }
+                }
+            }
+        }
+        ((PvmiCapabilityAndConfig *)configPtr)->releaseParameters(NULL, kvp, numkvpElements);
+        return format;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::GetPortFormatType 3rd getParametersSync failed %d, using configured format\n", status));
+    }
+
+    return format;
+}
+
+void CPV2WayDatapath::SetFormatSpecificInfo(uint8* fsi, uint16 fsi_len)
+{
+    if (iFsi)
+    {
+        OSCL_DEFAULT_FREE(iFsi);
+        iFsi = NULL;
+        iFsiLen = 0;
+    }
+    iFsi = (uint8*)OSCL_DEFAULT_MALLOC(fsi_len);
+    iFsiLen = fsi_len;
+    oscl_memcpy(iFsi, fsi, iFsiLen);
+}
+
+
+uint8* CPV2WayDatapath::GetFormatSpecificInfo(uint32* len)
+{
+    *len = iFsiLen;
+    return iFsi;
+}
+
+void CPV2WayDatapath::SetSourceSinkFormat(PVMFFormatType aFormatType)
+{
+    iSourceSinkFormat = aFormatType;
+}
+
+PVMFFormatType CPV2WayDatapath::GetSourceSinkFormat() const
+{
+    return iSourceSinkFormat;
+}
+
+
+
diff --git a/engines/2way/src/pv_2way_datapath.h b/engines/2way/src/pv_2way_datapath.h
new file mode 100644
index 0000000..376de27
--- /dev/null
+++ b/engines/2way/src/pv_2way_datapath.h
@@ -0,0 +1,383 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_DATAPATH_H_INCLUDED
+#define PV_2WAY_DATAPATH_H_INCLUDED
+
+#ifndef OSCL_ERROR_H_INCLUDED
+#include "oscl_error.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef PV_2WAY_ENGINE_H_INCLUDED
+#include "pv_2way_engine.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_port_interface.h"
+#endif
+
+#define MAX_DATAPATH_NODES 10
+#define MAX_PARENT_PATHS 2
+#define MAX_DEPENDENT_PATHS 2
+
+/**
+ * TPVNodeConfigTimeType enum
+ *
+ * An enumeration of when to configure the node
+ **/
+typedef enum
+{
+    EConfigBeforeInit = 0, //Configure node before initialization
+    EConfigBeforeReqInPort, //Configure node before requesting input port
+    EConfigBeforeReqOutPort, //Configure node before requesting output port
+    EConfigBeforePrepare, //Configure node before preparing
+    EConfigBeforeStart, //Configure node before starting
+    EMaxConfigTimeTypes
+} TPVNodeConfigTimeType;
+
+/**
+ * TPV2WayDatapathType enum
+ *
+ * An enumeration of types of data paths
+ **/
+typedef enum
+{
+    EUnknownDatapath = 0,
+    EEncodeDatapath,
+    EDecodeDatapath,
+    EMuxDatapath,
+    ERecDatapath,
+    EPreviewDatapath,
+    EInitDatapath,
+    EMaxDatapathType
+} TPV2WayDatapathType;
+
+/**
+ * TPV2WayDatapathState enum
+ *
+ * An enumeration of broad external states of the data path
+ **/
+typedef enum
+{
+    EClosed = 0,
+    EOpening,
+    EOpened,
+    EPausing,
+    EPaused,
+    EUnpausing,
+    EClosing,
+    EMaxDataPathStates
+}TPV2WayDatapathState;
+
+/**
+ * TPVPortFormatSetType enum
+ *
+ * An enumeration of how the format type of the port is determined
+ **/
+typedef enum
+{
+    EUserDefined = 0, //User defines format type for port
+    EConnectedPortFormat, //Format is set to the connecting port's format
+    EUseOtherNodePortFormat, //Format is set to whatever the other node port is set to (nodes in a datapath have only 2 ports)
+    EAppDefined, //Format is pre-set during RequestPort.  Does not need to be set
+    EMaxFormatSetTypes
+} TPVPortFormatSetType;
+
+
+/**
+ * CPV2WayPortPair Class
+ *
+ * Specifies a pair of node ports that describe a data connection and the status of the ports.
+ **/
+class CPV2WayPortPair
+{
+    public:
+        CPV2WayPortPair() : iIsConnected(false) {};
+
+        ~CPV2WayPortPair() {};
+
+        bool Connect();
+        bool Disconnect();
+
+        CPV2WayPort iSrcPort;
+        CPV2WayPort iDestPort;
+        bool iIsConnected;
+};
+
+/**
+ * CPVDatapathPort Class
+ *
+ * Describes how to use a port in a datatpath.
+ **/
+class CPVDatapathPort
+{
+    public:
+        CPVDatapathPort() : iPortTag(0),
+                iRequestPortState(EPVMFNodeIdle),
+                iCanCancelPort(false),
+                iPortSetType(EUserDefined),
+                iFormatType(PVMF_MIME_FORMAT_UNKNOWN),
+                iDefaultFormatType(PVMF_MIME_FORMAT_UNKNOWN),
+                iPortPair(NULL)
+        {
+        };
+
+        CPVDatapathPort(const CPVDatapathPort &aPort) : iPortTag(aPort.iPortTag),
+                iRequestPortState(aPort.iRequestPortState),
+                iRequestPortAnytime(aPort.iRequestPortAnytime),
+                iCanCancelPort(aPort.iCanCancelPort),
+                iPortSetType(aPort.iPortSetType),
+                iFormatType(aPort.iFormatType),
+                iDefaultFormatType(aPort.iDefaultFormatType),
+
+                iPortPair(aPort.iPortPair)
+        {
+        };
+
+        ~CPVDatapathPort() {};
+
+        CPVDatapathPort& operator=(const CPVDatapathPort& a);
+
+        int32 iPortTag; // The port tag
+        TPVMFNodeInterfaceState iRequestPortState; //State of node to request/release port
+        bool iRequestPortAnytime; //Can port be requested in any node state
+        bool iCanCancelPort; // Can the request port command be cancelled for the port
+        TPVPortFormatSetType iPortSetType; // How to determine format type for the port
+        PVMFFormatType iFormatType; // Sets format type for the port
+        PVMFFormatType iDefaultFormatType; // In the case the CapConfig interface is stupid
+        CPV2WayPortPair *iPortPair; // The out port will be the iSrcPort of the port pair
+        // The in port will be the iDestPort of the port pair
+};
+
+/**
+ * CPVDatapathNode Class
+ *
+ * Describes how a node is used in a datatpath.
+ **/
+class CPVDatapathNode
+{
+    public:
+        CPVDatapathNode() : iConfigure(NULL),
+                iConfigTime(EConfigBeforeInit),
+                iCanNodePause(false),
+                iLoggoffOnReset(false),
+                iOriginalState(EPVMFNodeIdle),
+                iDatapathCloseState(EPVMFNodeLastState),
+                iCommandIssued(false)
+        {};
+
+        CPVDatapathNode(const CPVDatapathNode &aNode) : iNode(aNode.iNode),
+                iConfigure(aNode.iConfigure),
+                iConfigTime(aNode.iConfigTime),
+                iCanNodePause(aNode.iCanNodePause),
+                iLoggoffOnReset(aNode.iLoggoffOnReset),
+                iIgnoreNodeState(aNode.iIgnoreNodeState),
+                iOriginalState(aNode.iOriginalState),
+                iDatapathCloseState(aNode.iDatapathCloseState),
+                iInputPort(aNode.iInputPort),
+                iOutputPort(aNode.iOutputPort),
+                iCommandIssued(aNode.iCommandIssued)
+        {};
+
+
+        ~CPVDatapathNode() {};
+
+        CPVDatapathNode& operator=(const CPVDatapathNode& a);
+
+        bool CloseableState()
+        {
+            PVMFNodeInterface * nodeIFace = (PVMFNodeInterface *)iNode;
+            if (iDatapathCloseState != EPVMFNodeLastState &&
+                    nodeIFace->GetState() == iDatapathCloseState)
+                return true;
+            if (iDatapathCloseState == EPVMFNodeLastState &&
+                    nodeIFace->GetState() == iOriginalState)
+                return true;
+            return false;
+        }
+
+        TPV2WayNode iNode; // Actual node
+        CPV2WayNodeConfigurationObserver *iConfigure; // Node configuration observer, called when config time is reached
+        TPVNodeConfigTimeType iConfigTime; // When to configure node
+        bool iCanNodePause; // Is the node capable of pausing
+        bool iLoggoffOnReset; // Does node need to logoff after datapath is reset
+        bool iIgnoreNodeState; // Flag for that specifies whether the datapath changes the state of the node
+        TPVMFNodeInterfaceState iOriginalState; // The state of the node when it is added to the datapath
+        TPVMFNodeInterfaceState iDatapathCloseState; // The state in which the node should be in before the
+        // datapath closes
+        CPVDatapathPort iInputPort;
+        CPVDatapathPort iOutputPort;
+        bool iCommandIssued;
+};
+
+
+class CPV2WayDatapath : public HeapBase, public CPV2WayNodeCommandObserver
+{
+    private:
+        TPV2WayNode* iNode;
+    public:
+        CPV2WayDatapath(PVLogger *aLogger,
+                        TPV2WayDatapathType aType,
+                        PVMFFormatType aFormat,
+                        CPV324m2Way *a2Way) : iType(aType),
+                iState(EClosed),
+                iStateBeforeClose(EClosed),
+                iFormat(aFormat),
+                iSourceSinkFormat(PVMF_MIME_FORMAT_UNKNOWN),
+                i2Way(a2Way),
+                iLogger(aLogger),
+                iAllPortsConnected(false)
+        {};
+
+        virtual ~CPV2WayDatapath() {};
+
+        bool IsPortInDatapath(PVMFPortInterface *aPort);
+        bool IsNodeInDatapath(PVMFNodeInterface *aNode);
+        bool ResetDatapath();
+        bool AddNode(const CPVDatapathNode &aNode);
+        bool Open();
+        bool Close();
+        bool Pause();
+        bool Resume();
+
+        bool AddParentDatapath(CPV2WayDatapath &aDatapath);
+        bool AddDependentDatapath(CPV2WayDatapath &aDatapath);
+
+        TPV2WayDatapathState GetState()
+        {
+            return iState;
+        }
+        void SetFormat(PVMFFormatType aFormatType)
+        {
+            iFormat = aFormatType;
+        }
+        PVMFFormatType GetFormat()
+        {
+            return iFormat;
+        }
+
+        void CommandHandler(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+
+        void CheckPath();
+        void SetFormatSpecificInfo(uint8* fsi, uint16 fsi_len);
+        uint8* GetFormatSpecificInfo(uint32* len);
+        void SetSourceSinkFormat(PVMFFormatType aFormatType);
+        PVMFFormatType GetSourceSinkFormat() const;
+    protected:
+        void ConstructL();
+
+        bool SendNodeCmd(PV2WayNodeCmdType cmd, int i);
+        int SetParametersSync(PvmiCapabilityAndConfig * configPtr,
+                              PvmiKvp* portParams,
+                              PvmiKvp*& portParamsReturn);
+        bool CheckNodePorts(bool& aCheckPort, int i);
+
+        void SetPort(CPV2WayPort &aDatapathPort, PVMFPortInterface *aPort)
+        {
+            aDatapathPort.SetPort(aPort);
+        }
+
+        void SetState(TPV2WayDatapathState aState);
+
+        bool IsDatapathNodeClosed(CPVDatapathNode &aNode);
+        bool CheckNodePortsL(CPVDatapathNode &aNode);
+        PVMFStatus PortStatusChange(PVMFNodeInterface *aNode, PVMFCommandId aId, PVMFPortInterface *aPort);
+        CPV2WayPort *RetrievePort(PVMFNodeInterface *aNode, PVMFCommandId aId);
+        PVMFStatus ReleaseNodePorts(CPVDatapathNode &aNode);
+        void CloseNodePorts(CPVDatapathNode &aNode);
+        PVMFCommandId SendNodeCmdL(PV2WayNodeCmdType aCmd,
+                                   CPVDatapathNode &aNode,
+                                   void *aParam = NULL);
+
+        PVMFStatus CheckConfig(TPVNodeConfigTimeType aConfigTime, CPVDatapathNode &aNode);
+
+        //Can be overriden in derived datapaths
+        virtual void CheckOpen();
+        virtual void CheckPause();
+        virtual void CheckResume();
+        virtual void CheckClosed();
+
+        virtual void OpenComplete() = 0;
+        virtual void PauseComplete() = 0;
+        virtual void ResumeComplete() = 0;
+        virtual void CloseComplete() = 0;
+
+        virtual void DatapathError() = 0;
+
+        virtual bool CheckPathSpecificOpen()
+        {
+            return true;
+        }
+        virtual bool PathSpecificClose()
+        {
+            return true;
+        }
+        virtual bool CheckPathSpecificStart()
+        {
+            return true;
+        }
+
+        virtual void DependentPathClosed(CPV2WayDatapath *aDependentPath);
+        bool HaveAllDependentPathsClosed();
+        bool IsParentClosing();
+        void NotifyParentPaths();
+        virtual bool ParentIsClosing();
+        virtual bool SingleNodeOpen()
+        {
+            return false;
+        }
+
+        PVMFStatus GetKvp(PVMFPortInterface &aPort, bool aInput,
+                          PvmiKvp*& aKvp, int& aNumKvpElem, OsclAny*& aconfigPtr);
+        PVMFFormatType GetPortFormatType(PVMFPortInterface& aPort,
+                                         bool aInput, PVMFPortInterface* aOtherPort);
+
+        TPV2WayDatapathType iType;
+        TPV2WayDatapathState iState;
+        TPV2WayDatapathState iStateBeforeClose;
+        // The codec type associated with this datapath
+        PVMFFormatType iFormat;
+        // The format type of the terminating source/sink
+        PVMFFormatType iSourceSinkFormat;
+
+        CPV324m2Way *i2Way;
+        PVLogger *iLogger;
+        bool iAllPortsConnected;
+
+        Oscl_Vector<CPVDatapathNode, BasicAlloc> iNodeList;
+        Oscl_Vector<CPV2WayPortPair, BasicAlloc> iPortPairList;
+
+        //List of datapaths this datapath depends on
+        Oscl_Vector<CPV2WayDatapath *, BasicAlloc> iParentPathList;
+        //List of datapaths that depend on this datapath
+        Oscl_Vector<CPV2WayDatapath *, BasicAlloc> iDependentPathList;
+        // Format specific info associated with this datapath
+        uint8* iFsi;
+        uint32 iFsiLen;
+};
+
+#endif //PV_2WAY_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_dec_data_channel_datapath.cpp b/engines/2way/src/pv_2way_dec_data_channel_datapath.cpp
new file mode 100644
index 0000000..69d6904
--- /dev/null
+++ b/engines/2way/src/pv_2way_dec_data_channel_datapath.cpp
@@ -0,0 +1,55 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_dec_data_channel_datapath.h"
+
+CPV2WayDecDataChannelDatapath *CPV2WayDecDataChannelDatapath::NewL(PVLogger *aLogger,
+        PVMFFormatType aFormat,
+        CPV324m2Way *a2Way)
+{
+    CPV2WayDecDataChannelDatapath *self = OSCL_NEW(CPV2WayDecDataChannelDatapath, (aLogger, aFormat, a2Way));
+    OsclError::LeaveIfNull(self);
+
+    if (self)
+    {
+        OSCL_TRAPSTACK_PUSH(self);
+        self->ConstructL();
+    }
+
+    OSCL_TRAPSTACK_POP();
+    return self;
+}
+
+void CPV2WayDecDataChannelDatapath::TSCPortClosed()
+{
+    if (iState != EClosed)
+    {
+        iPortPairList.front().Disconnect();
+        iPortPairList.front().iSrcPort.SetPort(NULL);
+        SetCmd(NULL);
+    }
+}
+
+PVMFPortInterface *CPV2WayDecDataChannelDatapath::GetTSCPort()
+{
+    return iPortPairList.empty() ? NULL : iPortPairList.front().iSrcPort.GetPort();
+}
+
+void CPV2WayDecDataChannelDatapath::OpenComplete()
+{
+    CommandComplete(PVMFSuccess);
+}
diff --git a/engines/2way/src/pv_2way_dec_data_channel_datapath.h b/engines/2way/src/pv_2way_dec_data_channel_datapath.h
new file mode 100644
index 0000000..09934d8
--- /dev/null
+++ b/engines/2way/src/pv_2way_dec_data_channel_datapath.h
@@ -0,0 +1,49 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_DEC_DATA_CHANNEL_DATAPATH_H_INCLUDED
+#define PV_2WAY_DEC_DATA_CHANNEL_DATAPATH_H_INCLUDED
+
+#ifndef PV_2WAY_DATA_CHANNEL_DATAPATH_H_INCLUDED
+#include "pv_2way_data_channel_datapath.h"
+#endif
+
+
+class CPV2WayDecDataChannelDatapath : public CPV2WayDataChannelDatapath
+{
+    public:
+        static CPV2WayDecDataChannelDatapath *NewL(PVLogger *aLogger,
+                PVMFFormatType aFormat,
+                CPV324m2Way *a2Way);
+
+        ~CPV2WayDecDataChannelDatapath() {};
+
+        void TSCPortClosed();
+        PVMFPortInterface *GetTSCPort();
+
+    private:
+        CPV2WayDecDataChannelDatapath(PVLogger *aLogger,
+                                      PVMFFormatType aFormat,
+                                      CPV324m2Way *a2Way) : CPV2WayDataChannelDatapath(aLogger, EDecodeDatapath, aFormat, a2Way)
+        {};
+        TPV2WayNode* iNode;
+        void OpenComplete();
+};
+
+#endif //PV_2WAY_DEC_DATA_CHANNEL_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_enc_data_channel_datapath.cpp b/engines/2way/src/pv_2way_enc_data_channel_datapath.cpp
new file mode 100644
index 0000000..3775b13
--- /dev/null
+++ b/engines/2way/src/pv_2way_enc_data_channel_datapath.cpp
@@ -0,0 +1,168 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_enc_data_channel_datapath.h"
+
+CPV2WayEncDataChannelDatapath *CPV2WayEncDataChannelDatapath::NewL(PVLogger *aLogger,
+        PVMFFormatType aFormat,
+        CPV324m2Way *a2Way)
+{
+    CPV2WayEncDataChannelDatapath *self = OSCL_NEW(CPV2WayEncDataChannelDatapath, (aLogger, aFormat, a2Way));
+    OsclError::LeaveIfNull(self);
+
+    if (self)
+    {
+        OSCL_TRAPSTACK_PUSH(self);
+        self->ConstructL();
+    }
+
+    OSCL_TRAPSTACK_POP();
+    return self;
+}
+
+void CPV2WayEncDataChannelDatapath::TSCPortClosed()
+{
+    if (iState != EClosed)
+    {
+        iPortPairList.back().Disconnect();
+        iPortPairList.back().iDestPort.SetPort(NULL);
+        SetCmd(NULL);
+    }
+}
+
+PVMFPortInterface *CPV2WayEncDataChannelDatapath::GetTSCPort()
+{
+    return iPortPairList.empty() ? NULL : iPortPairList.back().iDestPort.GetPort();
+}
+
+
+PVMFPortInterface *CPV2WayEncDataChannelDatapath::GetSrcPort()
+{
+    return iPortPairList.empty() ? NULL : iPortPairList.front().iSrcPort.GetPort();
+}
+
+void CPV2WayEncDataChannelDatapath::SetSourceInputPort(PVMFPortInterface *aPort)
+{
+    iSourceInputPort.SetPort(aPort);
+}
+
+void CPV2WayEncDataChannelDatapath::UseFilePlayPort(bool aUseFilePlayPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen state %d, format %s, use play port %d, file play port %x\n", iState, iFormat.getMIMEStrPtr(), aUseFilePlayPort, iFilePlayPort));
+    if ((iState != EOpened) || (iFilePlayPort == NULL)) return;
+
+    //If audio use mixing port (audio source node input port)
+    if (iFormat.isVideo())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen audio source port status %d\n", iSourceInputPort.GetStatus()));
+        if (iSourceInputPort.GetStatus() == EHasPort)
+        {
+            if (aUseFilePlayPort)
+            {
+                iSourceInputPort.GetPort()->Connect(iFilePlayPort);
+                iFilePlayPort->Connect(iSourceInputPort.GetPort());
+            }
+            else
+            {
+                iFilePlayPort->Disconnect();
+                iSourceInputPort.GetPort()->Disconnect();
+            }
+        }
+    }
+    //Else video, use splitter port
+    else
+    {
+        if (aUseFilePlayPort)
+        {
+            iPortPairList.front().Disconnect();
+            iPortPairList.front().iDestPort.GetPort()->Connect(iFilePlayPort);
+            iFilePlayPort->Connect(iPortPairList.front().iDestPort.GetPort());
+        }
+        else
+        {
+            iFilePlayPort->Disconnect();
+            iPortPairList.front().iDestPort.GetPort()->Disconnect();
+            iPortPairList.front().Connect();
+        }
+    }
+}
+
+void CPV2WayEncDataChannelDatapath::OpenComplete()
+{
+#if 0
+    if (i2Way->iUsePlayFileAsSource)
+    {
+        UseFilePlayPort(true);
+    }
+#endif
+
+    CommandComplete(PVMFSuccess);
+}
+
+bool CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificOpen\n"));
+#if 0
+    if (iFormat == EPV2WayAudio)
+    {
+        i2Way->CheckAudioSourceMixingPort();
+        return true;
+    }
+    else
+#endif
+    {
+        return true;
+    }
+}
+
+bool CPV2WayEncDataChannelDatapath::PathSpecificClose()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::PathSpecificClose file port %x, input src port %d\n", iFilePlayPort, iSourceInputPort.GetStatus()));
+
+    if (iFilePlayPort)
+    {
+        iFilePlayPort->Disconnect();
+    }
+
+    switch (iSourceInputPort.GetStatus())
+    {
+        case EHasPort:
+            iSourceInputPort.GetPort()->Disconnect();
+            //i2Way->CheckAudioSourceMixingPort();
+            return false;
+
+        case ENoPort:
+            //No mixing port, continue closing this datapath
+            return true;
+
+        default:
+            break;
+    }
+
+    return false;
+}
+
+bool CPV2WayEncDataChannelDatapath::CheckPathSpecificStart()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificStart engine state=%d\n", i2Way->iState));
+    if (i2Way->iState == EConnecting || i2Way->iState == EConnected)
+    {
+        return true;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayEncDataChannelDatapath::CheckPathSpecificStart engine not connecting yet."));
+    return false;
+}
diff --git a/engines/2way/src/pv_2way_enc_data_channel_datapath.h b/engines/2way/src/pv_2way_enc_data_channel_datapath.h
new file mode 100644
index 0000000..9b806bf
--- /dev/null
+++ b/engines/2way/src/pv_2way_enc_data_channel_datapath.h
@@ -0,0 +1,71 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_ENC_DATA_CHANNEL_DATAPATH_H_INCLUDED
+#define PV_2WAY_ENC_DATA_CHANNEL_DATAPATH_H_INCLUDED
+
+#ifndef PV_2WAY_DATA_CHANNEL_DATAPATH_H_INCLUDED
+#include "pv_2way_data_channel_datapath.h"
+#endif
+
+class CPV2WayEncDataChannelDatapath : public CPV2WayDataChannelDatapath
+{
+    public:
+        static CPV2WayEncDataChannelDatapath *NewL(PVLogger *aLogger,
+                PVMFFormatType aFormat,
+                CPV324m2Way *a2Way);
+
+        ~CPV2WayEncDataChannelDatapath() {};
+
+        void TSCPortClosed();
+        PVMFPortInterface *GetTSCPort();
+        PVMFPortInterface *GetSrcPort();
+
+        CPV2WayPort *GetSourceInputPort()
+        {
+            return &iSourceInputPort;
+        }
+        void SetSourceInputPort(PVMFPortInterface *aPort);
+
+        void SetFilePlayPort(PVMFPortInterface *aPort)
+        {
+            iFilePlayPort = aPort;
+        }
+        void UseFilePlayPort(bool aUseFilePlayPort);
+
+    private:
+        CPV2WayEncDataChannelDatapath(PVLogger *aLogger,
+                                      PVMFFormatType aFormat,
+                                      CPV324m2Way *a2Way) : CPV2WayDataChannelDatapath(aLogger, EEncodeDatapath, aFormat, a2Way),
+                iFilePlayPort(NULL)
+        {};
+        TPV2WayNode* iNode;
+        void OpenComplete();
+
+        bool CheckPathSpecificOpen();
+        bool PathSpecificClose();
+        bool CheckPathSpecificStart();
+
+        CPV2WayPort iSourceInputPort;
+
+        PVMFPortInterface *iFilePlayPort;
+        friend class CPV324m2Way;
+};
+
+#endif //PV_2WAY_ENC_DATA_CHANNEL_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_engine.cpp b/engines/2way/src/pv_2way_engine.cpp
new file mode 100644
index 0000000..98a6455
--- /dev/null
+++ b/engines/2way/src/pv_2way_engine.cpp
@@ -0,0 +1,8376 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_SDKINFO_H_INCLUDED
+#include "pv_2way_sdkinfo.h"
+#endif
+
+#ifndef PV_2WAY_ENGINE_H_INCLUDED
+#include "pv_2way_engine.h"
+#endif
+
+#include "pv_2way_dec_data_channel_datapath.h"
+#include "pv_2way_enc_data_channel_datapath.h"
+#include "pv_2way_mux_datapath.h"
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+#include "pv_2way_preview_datapath.h"
+#include "playfromfilenode.h"
+#endif
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+#include "pv_2way_rec_datapath.h"
+
+#include "pvmp4ffcn_factory.h"
+#include "pvmp4ffcn_trackconfig.h"
+#include "pvmp4ffcn_clipconfig.h"
+#include "pvmf_composer_size_and_duration.h"
+#endif
+
+#if (defined(PV_RECORD_TO_FILE_SUPPORT) || defined(PV_PLAY_FROM_FILE_SUPPORT))
+#include "pvmf_splitter_node.h"
+#endif
+
+#include "pvmf_videoparser_node.h"
+
+#ifdef PV2WAY_USE_OMX
+#include "omx_core.h"
+#endif
+
+#ifdef PV2WAY_USE_OMX_VIDEO_DECODER
+#include "pvmf_omx_videodec_factory.h"
+#else
+#include "pvmf_videodec_factory.h"
+#endif
+
+#include "pvmf_video.h"
+#include "pvmp4h263encextension.h"
+
+#ifndef PV_ENGINE_OBSERVER_H_INCLUDED
+#include "pv_engine_observer.h"
+#endif
+
+#ifdef PV2WAY_USE_OMX_ENCODER
+#include "pvmf_omx_enc_factory.h"
+#else
+#include "pvmf_videoenc_node_factory.h"
+#endif //PV2WAY_USE_OMX_ENCODER
+
+#ifndef PV_DISABLE_VIDRECNODE
+#include "pvvideoencmdfnode_factory.h"
+#endif
+
+#ifndef PV_DISABLE_DEVSOUNDNODES
+#include "pvdevsound_node_base.h"
+#endif
+
+#include "pvlogger.h"
+
+#include "oscl_dll.h"
+
+#ifndef NO_2WAY_324
+#include "tsc_h324m_config_interface.h"
+#endif
+
+
+#ifdef PV2WAY_USE_OMX_AMR_DECODER
+#include "pvmf_omx_audiodec_factory.h"
+#else
+#include "pvmf_gsmamrdec_factory.h"
+#endif // PV2WAY_USE_OMX_AMR_DECODER
+
+#ifndef PV2WAY_USE_OMX_AMR_ENCODER
+#include "pvmf_amrenc_node_factory.h"
+#endif
+
+#include "pvmfamrencnode_extension.h"
+#include "pvmf_nodes_sync_control.h"
+
+#include "pv_2way_track_info_impl.h"
+
+#include "pvmi_config_and_capability.h"
+
+#ifdef MEM_TRACK
+#include "oscl_mem.h"
+#include "oscl_mem_audit.h"
+#endif
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+//Record defaults
+#define DEFAULT_RECORDED_CALL_FILENAME _STRLIT("c:\\recorded_call.mp4")
+#define DEFAULT_RECORDED_CALL_TIMESCALE 1000
+#define DEFAULT_RECORDED_CALL_TYPE PVMP4FFCN_NO_TEMP_FILE_AUTHORING_MODE
+
+#define NUM_MANDATORY_2WAY_AUDIO_CODECS 1
+#define NUM_MANDATORY_2WAY_VIDEO_CODECS 2
+#define PV_VIDEO_FRAME_RATE_NUMERATOR 10
+#define PV_VIDEO_FRAME_RATE_DENOMINATOR 1
+
+//Default skipMediaData params
+const uint32 resume_timestamp = 0;
+#define STREAMID 0
+#define PBPOSITION_CONTINUOUS false
+//Early and late margins for audio and video frames
+#define SYNC_EARLY_MARGIN 100
+#define SYNC_LATE_MARGIN 100
+
+//Preferred codecs
+#define VIDEO_CODEC_MPEG4 1
+#define VIDEO_CODEC_H263 2
+#define AUDIO_CODEC_GSM 3
+#define AUDIO_CODEC_G723 4
+#define PREFERRED_VIDEO_CODEC VIDEO_CODEC_MPEG4
+#define PREFERRED_AUDIO_CODEC AUDIO_CODEC_GSM
+
+const uint32 KSamplingRate  = 8000;
+const uint32 KBitsPerSample = 16;
+const uint32 KNumChannels   = 1;
+const uint32 KNumPCMFrames  = 2; // 10
+
+//TEMP -RH
+#define PV2WAY_UNKNOWN_PORT -1
+#define PV2WAY_IN_PORT 0
+#define PV2WAY_OUT_PORT 1
+#define PV2WAY_IO_PORT 3
+
+#define INVALID_TRACK_ID 255
+
+#define AUDIO_FIRST 1
+
+#ifndef PV_DISABLE_VIDRECNODE
+#define CREATE_VIDEO_ENC_NODE()  PVVideoEncMDFNodeFactory::Create(this,this,this)
+#define DELETE_VIDEO_ENC_NODE(n) PVVideoEncMDFNodeFactory::Delete(n)
+#else
+#ifndef PV2WAY_USE_OMX_ENCODER // mark here
+#define	CREATE_VIDEO_ENC_NODE()  PVMFVideoEncNodeFactory::CreateVideoEncNode()
+#define DELETE_VIDEO_ENC_NODE(n) PVMFVideoEncNodeFactory::DeleteVideoEncNode(n)
+#endif
+#endif
+
+#ifndef PV_DISABLE_DEVVIDEOPLAYNODE
+#define CREATE_VIDEO_DEC_NODE()  PVDevVideoPlayNode::Create()
+#define DELETE_VIDEO_DEC_NODE(n) OSCL_DELETE(n)
+#else
+#ifdef PV2WAY_USE_OMX_VIDEO_DECODER
+#define	CREATE_OMX_VIDEO_DEC_NODE()  PVMFOMXVideoDecNodeFactory::CreatePVMFOMXVideoDecNode()
+#define DELETE_OMX_VIDEO_DEC_NODE(n) PVMFOMXVideoDecNodeFactory::DeletePVMFOMXVideoDecNode(n)
+#endif // PV2WAY_USE_OMX_VIDEO_DECODER
+#define	CREATE_VIDEO_DEC_NODE()  PVMFVideoDecNodeFactory::CreatePVMFVideoDecNode()
+#define DELETE_VIDEO_DEC_NODE(n) PVMFVideoDecNodeFactory::DeletePVMFVideoDecNode(n)
+#endif
+
+#ifdef PV2WAY_USE_OMX_ENCODER
+#define	CREATE_OMX_ENC_NODE()  PVMFOMXEncNodeFactory::CreatePVMFOMXEncNode()
+#define DELETE_OMX_ENC_NODE(n) PVMFOMXEncNodeFactory::DeletePVMFOMXEncNode(n);
+#endif
+
+#ifndef PV2WAY_USE_OMX_AMR_ENCODER
+#define CREATE_AUDIO_ENC_NODE() PvmfAmrEncNodeFactory::Create()
+#define DELETE_AUDIO_ENC_NODE(n) PvmfAmrEncNodeFactory::Delete(n)
+#endif
+
+
+#ifdef PV2WAY_USE_OMX_AMR_DECODER
+#define CREATE_OMX_AUDIO_DEC_NODE() PVMFOMXAudioDecNodeFactory::CreatePVMFOMXAudioDecNode()
+#define DELETE_OMX_AUDIO_DEC_NODE(n) PVMFOMXAudioDecNodeFactory::DeletePVMFOMXAudioDecNode(n)
+#else
+#define CREATE_AUDIO_DEC_NODE() PVMFGSMAMRDecNodeFactory::CreatePVMFGSMAMRDecNode()
+#define DELETE_AUDIO_DEC_NODE(n) PVMFGSMAMRDecNodeFactory::DeletePVMFGSMAMRDecNode(n)
+#endif // PV2WAY_USE_OMX_AMR_DECODER
+
+
+
+#define FILL_FORMAT_INFO(format_type, format_info)\
+GetSampleSize(format_type,&format_info.min_sample_size,&format_info.max_sample_size);\
+format_info.format = format_type;
+
+OSCL_EXPORT_REF CPV324m2Way *CPV324m2Way::NewL(PVMFNodeInterface* aTsc,
+        TPVTerminalType aTerminalType,
+        PVCommandStatusObserver* aCmdStatusObserver,
+        PVInformationalEventObserver *aInfoEventObserver,
+        PVErrorEventObserver *aErrorEventObserver)
+{
+    CPV324m2Way* aRet = OSCL_NEW(CPV324m2Way, ());
+    if (aRet)
+    {
+        int32 error = Construct(aRet, aTsc, aTerminalType, aCmdStatusObserver,
+                                aInfoEventObserver, aErrorEventObserver);
+        if (error)
+        {
+            OSCL_DELETE(aRet);
+            aRet = NULL;
+            OSCL_LEAVE(error);
+        }
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    return aRet;
+}
+
+int32 CPV324m2Way::Construct(CPV324m2Way* aRet,
+                             PVMFNodeInterface* aTsc,
+                             TPVTerminalType aTerminalType,
+                             PVCommandStatusObserver* aCmdStatusObserver,
+                             PVInformationalEventObserver *aInfoEventObserver,
+                             PVErrorEventObserver *aErrorEventObserver)
+{
+    int32 error = 0;
+    OSCL_TRY(error, aRet->ConstructL(aTsc,
+                                     aTerminalType,
+                                     aCmdStatusObserver,
+                                     aInfoEventObserver,
+                                     aErrorEventObserver));
+    return error;
+}
+
+OSCL_EXPORT_REF void CPV324m2Way::Delete(CPV324m2Way *aTerminal)
+{
+    OSCL_DELETE(aTerminal);
+}
+
+CPV324m2Way::CPV324m2Way() :
+        OsclActiveObject(OsclActiveObject::EPriorityNominal, "PV2WayEngine"),
+        iState(EIdle),
+        iLastState(EIdle),
+        iCmdStatusObserver(NULL),
+        iInfoEventObserver(NULL),
+        iErrorEventObserver(NULL),
+        iCommandId(0),
+        iVideoEncDatapath(NULL),
+        iVideoDecDatapath(NULL),
+        iAudioEncDatapath(NULL),
+        iAudioDecDatapath(NULL),
+        iIsStackConnected(false),
+        iMuxDatapath(NULL),
+        iInitInfo(NULL),
+        iConnectInfo(NULL),
+        iDisconnectInfo(NULL),
+        iResetInfo(NULL),
+        iCancelInfo(NULL),
+        iSessionParamsInfo(NULL),
+        iLogger(NULL),
+        iMinIFrameRequestInterval(DEFAULT_MIN_IFRAME_REQ_INT),
+        iIFrameReqTimer("IFrameReqTimer"),
+        iEndSessionTimer(NULL),
+        iRemoteDisconnectTimer(NULL),
+        isIFrameReqTimerActive(false),
+#ifndef NO_2WAY_324
+        iIncomingAudioTrackTag(INVALID_TRACK_ID),
+        iIncomingVideoTrackTag(INVALID_TRACK_ID),
+        iOutgoingAudioTrackTag(INVALID_TRACK_ID),
+        iOutgoingVideoTrackTag(INVALID_TRACK_ID),
+#endif
+        iVideoEncQueryIntCmdId(-1),
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+        iRecordFileState(File2WayIdle),
+        iInitRecFileInfo(NULL),
+        iResetRecFileInfo(NULL),
+        iFFComposerNode(NULL),
+        iAudioRecDatapath(NULL),
+        iVideoRecDatapath(NULL),
+        iRecFileSizeNotificationInterval(0),
+        iRecFileSizeNotificationTimer("iRecFileSizeNotificationTimer"),
+        isRecFileSizeNotificationTimerActive(false),
+#endif
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+        iAudioPreviewDatapath(NULL),
+        iVideoPreviewDatapath(NULL),
+        iPlayFileState(File2WayIdle),
+        iUsePlayFileAsSource(false),
+        iInitPlayFileInfo(NULL),
+        iResetPlayFileInfo(NULL),
+        iPlayFileCmdInfo(NULL),
+        iPlayFromFileNode(NULL),
+#endif
+        iTSCInterface(NULL),
+        iTSC324mInterface(NULL),
+        iPendingTscReset(-1),
+        iPendingAudioEncReset(-1),
+        iPendingVideoEncReset(-1),
+        iAudioDatapathLatency(0),
+        iVideoDatapathLatency(0),
+        iIncomingVideoCodecType(PV_INVALID_CODEC_TYPE),
+        iOutgoingVideoCodecType(PV_INVALID_CODEC_TYPE)
+{
+    iLogger = PVLogger::GetLoggerObject("2wayEngine");
+    iSyncControlPVUuid = PvmfNodesSyncControlUuid;
+    iVideoEncPVUuid = PVMp4H263EncExtensionUUID;
+    iCapConfigPVUuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
+
+    iAudioEncPVUuid = PVAMREncExtensionUUID;
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    iFFClipConfigPVUuid = KPVMp4FFCNClipConfigUuid;
+    iFFTrackConfigPVUuid = KPVMp4FFCNTrackConfigUuid;
+    iFFSizeAndDurationPVUuid = PvmfComposerSizeAndDurationUuid;
+#endif
+    iAddDataSourceVideoCmd = NULL;
+#ifdef PV2WAY_USE_OMX
+    OMX_Init();
+#endif // PV2WAY_USE_OMX
+
+    //creating timers
+    iEndSessionTimer = OSCL_NEW(OsclTimer<OsclMemAllocator>, (END_SESSION_TIMER, END_SESSION_TIMER_FREQUENCY));
+    iRemoteDisconnectTimer = OSCL_NEW(OsclTimer<OsclMemAllocator>, (REMOTE_DISCONNECT_TIMER, REMOTE_DISCONNECT_TIMER_FREQUENCY));
+}
+
+CPV324m2Way::~CPV324m2Way()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::~CPV324m2Way\n"));
+
+    Cancel();
+    iIncomingChannelParams.clear();
+    iOutgoingChannelParams.clear();
+
+    iIncomingAudioCodecs.clear();
+    iOutgoingAudioCodecs.clear();
+    iIncomingVideoCodecs.clear();
+    iOutgoingVideoCodecs.clear();
+    iFormatCapability.clear();
+    iClock.Stop();
+    iSinkNodeList.clear();
+    ClearVideoEncNode();
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    if (iVideoPreviewDatapath)
+    {
+        OSCL_DELETE(iVideoPreviewDatapath);
+        iVideoPreviewDatapath = NULL;
+    }
+
+    if (iAudioPreviewDatapath)
+    {
+        OSCL_DELETE(iAudioPreviewDatapath);
+        iAudioPreviewDatapath = NULL;
+    }
+#endif
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    if (iVideoRecDatapath)
+    {
+        OSCL_DELETE(iVideoRecDatapath);
+        iVideoRecDatapath = NULL;
+    }
+
+    if (iAudioRecDatapath)
+    {
+        OSCL_DELETE(iAudioRecDatapath);
+        iAudioRecDatapath = NULL;
+    }
+#endif
+
+    if (iVideoEncDatapath)
+    {
+        OSCL_DELETE(iVideoEncDatapath);
+        iVideoEncDatapath = NULL;
+    }
+
+    if (iVideoDecDatapath)
+    {
+        OSCL_DELETE(iVideoDecDatapath);
+        iVideoDecDatapath = NULL;
+    }
+
+    if (iAudioEncDatapath)
+    {
+        OSCL_DELETE(iAudioEncDatapath);
+        iAudioEncDatapath = NULL;
+    }
+
+    if (iAudioDecDatapath)
+    {
+        OSCL_DELETE(iAudioDecDatapath);
+        iAudioDecDatapath = NULL;
+    }
+
+    if (iMuxDatapath)
+    {
+        OSCL_DELETE(iMuxDatapath);
+        iMuxDatapath = NULL;
+    }
+
+    PVMFNodeInterface * nodeIFace = (PVMFNodeInterface *)iTscNode;
+    if (nodeIFace)
+    {
+        OSCL_DELETE(nodeIFace);
+        iTscNode.Clear();
+    }
+
+#ifdef PV2WAY_USE_OMX
+    OMX_Deinit();
+#endif
+
+    if (iEndSessionTimer)
+    {
+        iEndSessionTimer->Clear();
+        OSCL_DELETE(iEndSessionTimer);
+        iEndSessionTimer = NULL;
+    }
+
+    if (iRemoteDisconnectTimer)
+    {
+        iRemoteDisconnectTimer->Clear();
+        OSCL_DELETE(iRemoteDisconnectTimer);
+        iRemoteDisconnectTimer = NULL;
+    }
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::~CPV324m2Way - done\n"));
+}
+
+void CPV324m2Way::ClearVideoEncNode()
+{
+    PVMFNodeInterface * nodeIFace = (PVMFNodeInterface *)iVideoEncNode;
+    if (nodeIFace)
+    {
+        nodeIFace->ThreadLogoff();
+        if (iVideoEncNodeInterface.iInterface) iVideoEncNodeInterface.iInterface->removeRef();
+#ifndef PV_DISABLE_VIDRECNODE
+        PVVideoEncMDFNodeFactory::Delete(nodeIFace);
+#else
+        if (iOutgoingVideoCodecType != PV_INVALID_CODEC_TYPE)
+        {
+#if (defined(PV2WAY_USE_OMX_MPEG4_ENCODER) || defined(PV2WAY_USE_OMX_H263_ENCODER))
+            DELETE_OMX_ENC_NODE(nodeIFace);
+#else // PV2WAY_USE_OMX_ENCODER
+            DELETE_VIDEO_ENC_NODE(nodeIFace);
+#endif
+        }
+#endif
+        iVideoEncNode.Clear() ;
+        iVideoEncNodeInterface.Reset();
+    }
+}
+
+PVCommandId CPV324m2Way::GetSDKInfo(PVSDKInfo &aSDKInfo, OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::GetSDKInfo\n"));
+
+    FillSDKInfo(aSDKInfo);
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    cmd->type = PVT_COMMAND_GET_SDK_INFO;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+    Dispatch(cmd);
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aSDKModuleInfo);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::GetSDKModuleInfo\n"));
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    cmd->type = PVT_COMMAND_GET_SDK_MODULE_INFO;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+    Dispatch(cmd);
+    return iCommandId++;
+}
+
+void CPV324m2Way::PreInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::PreInit\n"));
+
+    PVMFNodeSessionInfo sessionInfo;
+    bool allocSuccessful = true;
+
+    switch (iState)
+    {
+        case EIdle:
+
+            if (iTerminalType == PV_324M)
+            {
+#ifndef NO_2WAY_324
+                iTscNode = TPV2WayNode(new TSC_324m(PV_LOOPBACK_MUX));
+                iTSC324mInterface = (TSC_324m *)iTscNode.iNode;
+                iTSCInterface = (TSC *)iTSC324mInterface;
+                // Create the list of stack supported formats
+                GetStackSupportedFormats();
+#endif
+            }
+
+            if (((PVMFNodeInterface *)iTscNode) == NULL)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::PreInit unable to allocate tsc node\n"));
+                allocSuccessful = false;
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::PreInit created TSC Node(%x)", (PVMFNodeInterface *)iTscNode));
+
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::Init Error - invalid state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+}
+
+PVCommandId CPV324m2Way::Init(PV2WayInitInfo& aInitInfo,
+                              OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::InitL\n"));
+
+    PVMFNodeSessionInfo sessionInfo;
+
+    bool allocSuccessful = true;
+
+    switch (iState)
+    {
+        case EIdle:
+        {
+            if (iInitInfo)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                                (0, "CPV324m2Way::PreInit cmd already sent out"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+
+            ((TSC_324m*)(iTscNode.iNode))->SetTscObserver(this);
+            InitiateSession(iTscNode);
+
+            ((TSC_324m*)(iTscNode.iNode))->SetMultiplexingDelayMs(0);
+            ((TSC_324m*)(iTscNode.iNode))->SetClock(&iClock);
+
+            SetPreferredCodecs(aInitInfo);
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+            OSCL_TRY(error, iVideoDecSplitterNode =
+                         TPV2WayNode(PVMFSplitterNode::Create()););
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::PreInit unable to allocate video splitter node\n"));
+                                 allocSuccessful = false;);
+
+            OSCL_TRY(error, iFFComposerNode =
+                         TPV2WayNode(PVMp4FFComposerNodeFactory::CreateMp4FFComposer(this, this, this));;
+                     iFFComposerNode->SetClock(&iClock););
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::PreInit unable to allocate ff composer node\n"));
+                                 allocSuccessful = false;);
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+            OSCL_TRY(error, iAudioSrcSplitterNode =
+                         TPV2WayNode(PVMFSplitterNode::Create()););
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::PreInit unable to allocate audio src splitter node\n"));
+                                 allocSuccessful = false;);
+
+            OSCL_TRY(error, iVideoSrcSplitterNode =
+                         TPV2WayNode(PVMFSplitterNode::Create()););
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::PreInit unable to allocate video src splitter node\n"));
+                                 allocSuccessful = false;);
+
+
+            OSCL_TRY(error, iPlayFromFileNode =
+                         TPV2WayNode(PlayFromFileNode::NewL());
+                     iPlayFromFileNode->SetClock(&iClock););
+            if (iPlayFromFileNode == NULL) error = PVMFErrNoMemory;
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::PreInit unable to allocate playfromfile node\n"));
+                                 allocSuccessful = false;);
+#endif
+
+            if (!allocSuccessful)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::Init allocation failed\n"));
+            }
+            else
+            {
+
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+                InitiateSession(iVideoDecSplitterNode);
+                InitiateSession(iFFComposerNode);
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+                InitiateSession(iAudioSrcSplitterNode);
+                InitiateSession(iVideoSrcSplitterNode);
+                InitiateSession(iPlayFromFileNode);
+#endif
+                //Set incoming channel capabilities.
+                // TBD: Incoming capabilities need to be queried from the registry and passed to the stack
+                H324ChannelParameters inAudioChannelParams(INCOMING, PVMF_MIME_AMR_IF2, MAX_AUDIO_BITRATE);
+                H324ChannelParameters inVideoChannelParams(INCOMING, PVMF_MIME_H2632000, MAX_VIDEO_BITRATE);
+                H324ChannelParameters inDtmfParams(INCOMING, PVMF_MIME_USERINPUT_BASIC_STRING, 0);
+
+                ConvertMapToVector(iIncomingAudioCodecs, iFormatCapability);
+                inAudioChannelParams.SetCodecs(iFormatCapability);
+
+                ConvertMapToVector(iIncomingVideoCodecs, iFormatCapability);
+                inVideoChannelParams.SetCodecs(iFormatCapability);
+                inDtmfParams.SetCodecs(iIncomingUserInputFormats);
+                iIncomingChannelParams.push_back(inAudioChannelParams);
+                iIncomingChannelParams.push_back(inVideoChannelParams);
+                iIncomingChannelParams.push_back(inDtmfParams);
+
+                //Set outgoing channel capabilities.
+                H324ChannelParameters outAudioChannelParams(OUTGOING,
+                        PVMF_MIME_AMR_IF2, MAX_AUDIO_BITRATE);
+                ConvertMapToVector(iOutgoingAudioCodecs, iFormatCapability);
+                outAudioChannelParams.SetCodecs(iFormatCapability);
+                iOutgoingChannelParams.push_back(outAudioChannelParams);
+
+                H324ChannelParameters outVideoChannelParams(OUTGOING,
+                        PVMF_MIME_H2632000, MAX_VIDEO_BITRATE);
+
+                ConvertMapToVector(iOutgoingVideoCodecs, iFormatCapability);
+                outVideoChannelParams.SetCodecs(iFormatCapability);
+                iOutgoingChannelParams.push_back(outVideoChannelParams);
+            }
+
+            iInitInfo = GetCmdInfoL();
+            iInitInfo->type = PVT_COMMAND_INIT;
+            iInitInfo->contextData = aContextData;
+            iInitInfo->id = iCommandId;
+
+            SetState(EInitializing);
+
+            CheckState();
+#ifdef MEM_TRACK
+            printf("\nMemStats at Engine Init\n");
+            MemStats();
+#endif
+            break;
+        }
+
+        case ESetup:
+            iInitInfo = GetCmdInfoL();
+            iInitInfo->type = PVT_COMMAND_INIT;
+            iInitInfo->id = iCommandId;
+            iInitInfo->contextData = aContextData;
+            iInitInfo->status = PVMFSuccess;
+            Dispatch(iInitInfo);
+            iInitInfo = NULL;
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::Init Error - invalid state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+
+PVCommandId CPV324m2Way::Reset(OsclAny* aContextData)
+{
+    uint32 ii = 0;
+    //checking if any sources or sinks still added.
+    for (ii = 0; ii < iSinkNodes.size(); ii++)
+    {
+        if (iSinkNodes[ii])
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetL SinkNodes not removed before Reset"));
+            OSCL_LEAVE(PVMFFailure);
+        }
+    }
+
+    for (ii = 0; ii < iSourceNodes.size(); ii++)
+    {
+        if (iSourceNodes[ii])
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetL SourceNodes not removed before Reset"));
+            OSCL_LEAVE(PVMFFailure);
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResetL %d\n", iState));
+
+    if (iResetInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ResetL cmd already sent out\n"));
+        OSCL_LEAVE(PVMFErrBusy);
+    }
+
+    switch (iState)
+    {
+        case EIdle:
+            iResetInfo = GetCmdInfoL();
+            iResetInfo->type = PVT_COMMAND_RESET;
+            iResetInfo->id = iCommandId;
+            iResetInfo->contextData = aContextData;
+            iResetInfo->status = PVMFSuccess;
+            Dispatch(iResetInfo);
+            iResetInfo = NULL;
+            break;
+
+        case EInitializing:
+            //Notify application that init command has been cancelled.
+            iInitInfo->status = PVMFErrCancelled;
+            Dispatch(iInitInfo);
+            iInitInfo = NULL;
+            //Fall through to next case.
+
+        case ESetup:
+            iResetInfo = GetCmdInfoL();
+            iResetInfo->type = PVT_COMMAND_RESET;
+            iResetInfo->contextData = aContextData;
+            iResetInfo->id = iCommandId;
+
+            InitiateReset();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetL - invalid state %d\n", iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#ifdef MEM_TRACK
+    printf("\nMemStats After Engine Reset\n");
+    MemStats();
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::AddDataSource(PVTrackId aChannelId,
+                                       PVMFNodeInterface& aDataSource,
+                                       OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::AddDataSourceL aChannelId=%d, (%x, %x, %x)",
+                     aChannelId, &aDataSource, 0, aContextData));
+    if (!((TSC_324m *)(PVMFNodeInterface *)iTscNode.iNode)->IsEstablishedLogicalChannel(OUTGOING,
+            aChannelId))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::AddDataSourceL Not an established logical channel in the stack"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+    TPV2WayNode* srcNode;
+    PVMFNodeInterface *node = &aDataSource;
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::AddDataSourceL - invalid state(%d)", iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+        default:
+            //State check okay.
+            break;
+    }
+
+    //As of v4, we'll need to initialize the node first before
+    //querying its capabilities
+
+    // Add the Data Source to the list of source nodes.
+    srcNode = OSCL_NEW(TPV2WayNode, (node));
+    InitiateSession(*srcNode);
+    iSourceNodes.push_back(srcNode);
+
+    cmd = GetCmdInfoL();
+    cmd->type = PVT_COMMAND_ADD_DATA_SOURCE;
+    cmd->status = PVMFSuccess;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->iPvtCmdData = aChannelId;
+
+    SendNodeCmdL(PV2WAY_NODE_CMD_INIT, srcNode, this, cmd);
+    return iCommandId++;
+}
+
+void CPV324m2Way::DoAddDataSource(TPV2WayNode& aNode,
+                                  const PVMFCmdResp& aResponse)
+{
+    TPV2WayNode* srcNode = &aNode;
+    PVMFNodeInterface *node = srcNode->iNode;
+    PVMFNodeCapability capability;
+    CPVDatapathNode datapathnode;
+    CPV2WayNodeContextData *data = (CPV2WayNodeContextData *) aResponse.GetContext();
+    TPV2WayCmdInfo *cmd = (TPV2WayCmdInfo *)data->iContextData;
+
+    cmd->status = aResponse.GetCmdStatus();
+
+    if (node->GetCapability(capability) != PVMFSuccess || !capability.iOutputFormatCapability.size())
+    {
+        OSCL_DELETE(srcNode);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddDataSourceL - unable to get capability"));
+        OSCL_LEAVE(PVMFFailure);
+    }
+
+    CPV2WayEncDataChannelDatapath* datapath = NULL;
+    PVMFFormatType media_type = capability.iOutputFormatCapability[0];
+    if (media_type.isAudio())
+    {
+        datapath = iAudioEncDatapath;
+    }
+    else if (media_type.isVideo())
+    {
+        datapath = iVideoEncDatapath;
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    bool formatSupported = false;
+    for (uint i = 0; i < capability.iOutputFormatCapability.size(); i++)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "CPV324m2Way::AddDataSourceL - format %s\n", (capability.iOutputFormatCapability[i]).getMIMEStrPtr()));
+        if (datapath->GetSourceSinkFormat() == capability.iOutputFormatCapability[i])
+        {
+            formatSupported = true;
+            break;
+        }
+    }
+    if (!formatSupported)
+    {
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+
+    if (datapath->GetSourceSinkFormat() == PVMF_MIME_YUV420)
+    {
+        // video media type
+        if (datapath->GetState() == EClosed)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::AddDataSource - creating video datapath, channel id =%d\n",
+                             cmd->iPvtCmdData));
+            datapath->SetChannelId(cmd->iPvtCmdData);
+
+            //Add source node to datapath
+            datapathnode.iNode = *srcNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iLoggoffOnReset = true;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iOutputPort.iPortSetType = EConnectedPortFormat;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            datapath->AddNode(datapathnode);
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+            //Add video src splitter node to datapath
+            datapathnode.iNode = iVideoSrcSplitterNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = false;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iInputPort.iPortSetType = EUserDefined;
+            datapathnode.iInputPort.iFormatType = PVMF_MIME_YUV420;
+            datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iOutputPort.iCanCancelPort = false;
+            datapathnode.iOutputPort.iPortSetType = EUserDefined;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_YUV420;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            datapath->AddNode(datapathnode);
+#endif
+            //Add video enc node to datapath
+            datapathnode.iNode = iVideoEncNode;
+            datapathnode.iConfigure = this;
+            datapathnode.iConfigTime = EConfigBeforeInit;
+            datapathnode.iCanNodePause = true;
+            datapathnode.iLoggoffOnReset = false;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iInputPort.iPortSetType = EUserDefined;
+            datapathnode.iInputPort.iFormatType = PVMF_MIME_YUV420;
+            datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iOutputPort.iPortSetType = EConnectedPortFormat;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            datapath->AddNode(datapathnode);
+
+            //Add tsc node to datapath
+            datapathnode.iNode = iTscNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = false;
+            datapathnode.iLoggoffOnReset = false;
+            datapathnode.iIgnoreNodeState = true;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeStarted;
+            datapathnode.iInputPort.iCanCancelPort = true;
+            datapathnode.iInputPort.iPortSetType = EAppDefined;
+            datapathnode.iInputPort.iFormatType = datapath->GetFormat();
+            datapathnode.iInputPort.iPortTag = cmd->iPvtCmdData;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            datapath->AddNode(datapathnode);
+
+            // Check if FSI exists and Extension Interface is queried
+            uint32 fsi_len = 0;
+            if (datapath->GetFormatSpecificInfo(&fsi_len) &&
+                    iVideoEncNodeInterface.iState == PV2WayNodeInterface::NoInterface)
+            {
+                iAddDataSourceVideoCmd = cmd;
+            }
+            else
+            {
+                datapath->SetCmd(cmd);
+            }
+        }
+        else
+        {
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+    }
+
+    else if ((datapath->GetSourceSinkFormat() == PVMF_MIME_H2632000) || (datapath->GetSourceSinkFormat() == PVMF_MIME_H2631998) || (datapath->GetSourceSinkFormat() == PVMF_MIME_M4V))
+    {
+        // video media type
+        if (datapath->GetState() == EClosed)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::AddDataSource - creating video datapath, channel id=%d",
+                             cmd->iPvtCmdData));
+            datapath->SetChannelId(cmd->iPvtCmdData);
+            //Add source node to datapath
+            datapathnode.iNode = *srcNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iLoggoffOnReset = true;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iOutputPort.iPortSetType = EConnectedPortFormat;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+
+            datapath->AddNode(datapathnode);
+            //Add tsc node to datapath
+            datapathnode.iNode = iTscNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = false;
+            datapathnode.iLoggoffOnReset = false;
+            datapathnode.iIgnoreNodeState = true;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeStarted;
+            datapathnode.iInputPort.iCanCancelPort = true;
+            datapathnode.iInputPort.iPortSetType = EAppDefined;
+            datapathnode.iInputPort.iFormatType = datapath->GetFormat();
+            datapathnode.iInputPort.iPortTag = cmd->iPvtCmdData;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            datapath->AddNode(datapathnode);
+
+            datapath->SetCmd(cmd);
+        }
+        else
+        {
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+    }
+
+    else if ((datapath->GetSourceSinkFormat() == PVMF_MIME_AMR_IF2) || (datapath->GetSourceSinkFormat() == PVMF_MIME_AMR_IETF) || (datapath->GetSourceSinkFormat() == PVMF_MIME_PCM16))
+    {
+        if (datapath->GetState() == EClosed)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::AddDataSourceL - creating audio datapath\n"));
+            datapath->SetChannelId(cmd->iPvtCmdData);
+
+            //Add source node to datapath
+            datapathnode.iNode = *srcNode;
+
+#ifndef PV_DISABLE_DEVSOUNDNODES
+            datapathnode.iConfigure = this;
+            datapathnode.iConfigTime = EConfigBeforeInit;
+#else
+            datapathnode.iConfigure = NULL;
+#endif
+            datapathnode.iCanNodePause = true;
+            datapathnode.iLoggoffOnReset = true;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iOutputPort.iPortSetType = EConnectedPortFormat;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            datapath->AddNode(datapathnode);
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+            //Add audio src splitter node to datapath
+            datapathnode.iNode = iAudioSrcSplitterNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = false;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iInputPort.iPortSetType = EUseOtherNodePortFormat;
+            datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iOutputPort.iCanCancelPort = false;
+            datapathnode.iOutputPort.iPortSetType = EConnectedPortFormat;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            datapath->AddNode(datapathnode);
+#endif
+
+            if (datapath->GetSourceSinkFormat() == PVMF_MIME_PCM16)
+            {
+                //Add audio enc node to datapath
+                datapathnode.iNode = iAudioEncNode;
+                datapathnode.iConfigure = this;
+                datapathnode.iConfigTime = EConfigBeforeInit;
+                datapathnode.iCanNodePause = true;
+                datapathnode.iLoggoffOnReset = false;
+                datapathnode.iIgnoreNodeState = false;
+                datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iInputPort.iPortSetType = EUserDefined;
+                datapathnode.iInputPort.iFormatType = PVMF_MIME_PCM16;
+                datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iOutputPort.iPortSetType = EConnectedPortFormat;
+                datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+                datapath->AddNode(datapathnode);
+            }
+
+            //Add tsc node to datapath
+            datapathnode.iNode = iTscNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = false;
+            datapathnode.iLoggoffOnReset = false;
+            datapathnode.iIgnoreNodeState = true;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeStarted;
+            datapathnode.iInputPort.iCanCancelPort = true;
+            datapathnode.iInputPort.iPortSetType = EAppDefined;
+            datapathnode.iInputPort.iPortTag = cmd->iPvtCmdData;
+            datapathnode.iInputPort.iFormatType = datapath->GetFormat();
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            datapath->AddNode(datapathnode);
+
+            datapath->SetCmd(cmd);
+        }
+        else
+        {
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+    }
+
+    return;
+}
+
+PVCommandId CPV324m2Way::DoRemoveDataSourceSink(PVMFNodeInterface& aEndPt,
+        OsclAny* aContextData)
+{
+    CPV2WayDataChannelDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    if ((iVideoEncDatapath) && iVideoEncDatapath->IsNodeInDatapath(&aEndPt))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::RemoveDataSource remove video source, state %d\n",
+                         iVideoEncDatapath->GetState()));
+        datapath = iVideoEncDatapath;
+        cmd->type = PVT_COMMAND_REMOVE_DATA_SOURCE;
+    }
+    else if ((iAudioEncDatapath) && iAudioEncDatapath->IsNodeInDatapath(&aEndPt))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::RemoveDataSource remove audio source, state %d\n",
+                         iAudioEncDatapath->GetState()));
+        datapath = iAudioEncDatapath;
+        cmd->type = PVT_COMMAND_REMOVE_DATA_SOURCE;
+    }
+    else if ((iVideoDecDatapath) && iVideoDecDatapath->IsNodeInDatapath(&aEndPt))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::RemoveDataSink remove video sink, state %d\n",
+                         iVideoDecDatapath->GetState()));
+        datapath = iVideoDecDatapath;
+        cmd->type = PVT_COMMAND_REMOVE_DATA_SINK;
+    }
+    else if ((iAudioDecDatapath) && iAudioDecDatapath->IsNodeInDatapath(&aEndPt))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::RemoveDataSink remove audio sink, state %d\n",
+                         iAudioDecDatapath->GetState()));
+        datapath = iAudioDecDatapath;
+        cmd->type = PVT_COMMAND_REMOVE_DATA_SINK;
+    }
+    else
+    {
+        // Just remove the node from sink and source nodes list if still in the list
+
+        TPV2WayNode* node = 0;
+
+        node = RemoveTPV2WayNode(iSinkNodes, &aEndPt);
+
+        if (!node)
+        {
+            // Not there in sink node list . Check in source nodes
+            node = RemoveTPV2WayNode(iSourceNodes, &aEndPt);
+        }
+
+        if (node)
+        {
+            //Successfully found and removed the node from  sink or source nodes ,so delete it.
+            OSCL_DELETE(node);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::RemoveDataSinkSource unknown sink!\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EClosing:
+            //Close command already in progress
+            if (datapath->GetCmdInfo())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                                (0, "CPV324m2Way::RemoveDataSourceL cmd already sent out"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            //Already closing because of error or remote close
+            else
+            {
+                cmd->id = iCommandId;
+                cmd->contextData = aContextData;
+                datapath->SetCmd(cmd);
+            }
+            break;
+
+        case EOpened:
+        case EOpening:
+        case EPaused:
+        case EPausing:
+        case EUnpausing:
+        {
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+        }
+        break;
+        case EClosed:
+            // Remove the node if exists in sink or source even data path is closed
+            break;
+
+        default:
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::RemoveDataSourceL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    TPV2WayNode* node = 0;
+
+    if (cmd->type == PVT_COMMAND_REMOVE_DATA_SINK)
+    {
+        node = RemoveTPV2WayNode(iSinkNodes, &aEndPt);
+    }
+    else if (cmd->type == PVT_COMMAND_REMOVE_DATA_SOURCE)
+    {
+        node = RemoveTPV2WayNode(iSourceNodes, &aEndPt);
+    }
+    OSCL_DELETE(node);
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::RemoveDataSource(PVMFNodeInterface& aDataSource,
+        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveDataSourceL(%x, %x, %x)",
+                     &aDataSource, 0, aContextData));
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::RemoveDataSourceL - invalid state(%d)",
+                             iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            //State check okay.
+            break;
+    }
+    return DoRemoveDataSourceSink(aDataSource, aContextData);
+}
+
+
+PVCommandId CPV324m2Way::AddDataSink(PVTrackId aChannelId,
+                                     PVMFNodeInterface& aDataSink,
+                                     OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::AddDataSinkL(%x, %d, %x)", &aDataSink, 0,
+                     aContextData));
+    TPV2WayNode* sinkNode;
+    CPVDatapathNode datapathnode;
+    TPV2WayCmdInfo *cmd = 0;
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::AddDataSinkL - invalid state(%d)",
+                             iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            //State check okay.
+            break;
+    }
+
+    //As of v4, we'll need to initialize the node first before
+    //querying its capabilities.
+
+    sinkNode = OSCL_NEW(TPV2WayNode, (&aDataSink));
+    InitiateSession(*sinkNode);
+    iSinkNodes.push_back(sinkNode);
+    SupportedSinkNodeInterfaces(sinkNode);
+    cmd = GetCmdInfoL();
+    cmd->type = PVT_COMMAND_ADD_DATA_SINK;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->iPvtCmdData = aChannelId;
+    SendNodeCmdL(PV2WAY_NODE_CMD_INIT, sinkNode, this, cmd);
+    return iCommandId++;
+}
+
+void CPV324m2Way::DoAddDataSink(TPV2WayNode& aNode,
+                                const PVMFCmdResp& aResponse)
+{
+    TPV2WayNode* sinkNode = &aNode;
+    PVMFNodeCapability capability;
+    PVMFNodeInterface *node = sinkNode->iNode;
+    CPVDatapathNode datapathnode;
+    CPV2WayNodeContextData *data = (CPV2WayNodeContextData *) aResponse.GetContext();
+    TPV2WayCmdInfo *cmd = (TPV2WayCmdInfo *)data->iContextData;
+    cmd->status = aResponse.GetCmdStatus();
+
+    if (node->GetCapability(capability) != PVMFSuccess)
+    {
+        OSCL_DELETE(sinkNode);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddDataSinkL - unable to get capability\n"));
+        OSCL_LEAVE(PVMFFailure);
+    }
+
+    CPV2WayDecDataChannelDatapath* datapath = NULL;
+    PVMFFormatType media_type = capability.iInputFormatCapability[0];
+    if (media_type.isAudio())
+    {
+        datapath = iAudioDecDatapath;
+    }
+    else if (media_type.isVideo())
+    {
+        datapath = iVideoDecDatapath;
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    bool formatSupported = false;
+    for (uint i = 0; i < capability.iInputFormatCapability.size(); i++)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "CPV324m2Way::AddDataSinkL - format %s\n", (capability.iInputFormatCapability[i]).getMIMEStrPtr()));
+        if (datapath->GetSourceSinkFormat() == capability.iInputFormatCapability[i])
+        {
+            formatSupported = true;
+            break;
+        }
+    }
+    if (!formatSupported)
+    {
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+
+    if ((datapath->GetSourceSinkFormat() == PVMF_MIME_H2632000) || (datapath->GetSourceSinkFormat() == PVMF_MIME_M4V))
+    {
+        if (datapath)
+        {
+            if (datapath->GetState() == EClosed)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                                (0, "CPV324m2Way::AddDataSinkL - creating video datapath\n"));
+
+                //Add tsc node to datapath
+                datapathnode.iNode = iTscNode;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = false;
+                datapathnode.iIgnoreNodeState = true;
+                datapathnode.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+                datapathnode.iOutputPort.iCanCancelPort = true;
+                datapathnode.iOutputPort.iPortSetType = EAppDefined;
+                datapathnode.iOutputPort.iFormatType = datapath->GetFormat();
+                datapathnode.iOutputPort.iPortTag = -cmd->iPvtCmdData;
+                datapath->AddNode(datapathnode);
+
+                //Add sink node to datapath
+                datapathnode.iNode.iNode = sinkNode->iNode;
+                datapathnode.iNode.iSessionId = sinkNode->iSessionId;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = false;
+                datapathnode.iLoggoffOnReset = true;
+                datapathnode.iIgnoreNodeState = false;
+                datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+                datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+                datapath->AddNode(datapathnode);
+
+                datapath->SetCmd(cmd);
+                datapath->SetChannelId(cmd->iPvtCmdData);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::AddDataSinkL - invalid video dec datapath state %d\n",
+                                 datapath->GetState()));
+                OSCL_LEAVE(PVMFErrInvalidState);
+            }
+        }
+    }
+
+    else if ((datapath->GetSourceSinkFormat() == PVMF_MIME_YUV420))
+    {
+        if (datapath)
+        {
+            if (datapath->GetState() == EClosed)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                                (0, "CPV324m2Way::AddDataSinkL - creating video datapath\n"));
+
+                //Add tsc node to datapath
+                datapathnode.iNode = iTscNode;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = false;
+                datapathnode.iIgnoreNodeState = true;
+                datapathnode.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+                datapathnode.iOutputPort.iCanCancelPort = true;
+                datapathnode.iOutputPort.iPortSetType = EAppDefined;
+                datapathnode.iOutputPort.iFormatType = datapath->GetFormat();
+                //datapathnode.iOutputPort.iPortTag = GetStackNodePortTag(EPV2WayVideoOut);
+                datapathnode.iOutputPort.iPortTag = -cmd->iPvtCmdData;
+                datapath->AddNode(datapathnode);
+
+                //Add video parser node to datapath
+                datapathnode.iNode = iVideoParserNode;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = false;
+                datapathnode.iIgnoreNodeState = false;
+                datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+                datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iOutputPort.iCanCancelPort = false;
+                datapathnode.iOutputPort.iPortSetType = EUseOtherNodePortFormat;
+                datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+                datapath->AddNode(datapathnode);
+
+                //Add video dec node to datapath
+                datapathnode.iNode = iVideoDecNode;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = true;
+                datapathnode.iIgnoreNodeState = false;
+                datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+                datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                datapathnode.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iOutputPort.iPortSetType = EUserDefined;
+                datapathnode.iOutputPort.iFormatType = PVMF_MIME_YUV420;
+                datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+                datapath->AddNode(datapathnode);
+
+                //Add sink node to datapath
+                datapathnode.iNode.iNode = sinkNode->iNode;
+                datapathnode.iNode.iSessionId = sinkNode->iSessionId;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = false;
+                if (datapath->GetSourceSinkFormat() == PVMF_MIME_PCM16)
+                {
+                    //Add audio dec node to datapath
+                    datapathnode.iNode = iAudioDecNode;
+                    datapathnode.iConfigure = NULL;
+                    datapathnode.iCanNodePause = true;
+                    datapathnode.iIgnoreNodeState = false;
+                    datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                    datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+                    datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                    datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                    // Changed from initialized because decoder node now tries to
+                    // immediately send data downstream during prepare, but the
+                    // downstream port isn't connected at that time.
+                    datapathnode.iOutputPort.iRequestPortState = EPVMFNodeIdle;
+                    datapathnode.iOutputPort.iPortSetType = EUserDefined;
+                    datapathnode.iOutputPort.iFormatType = PVMF_MIME_PCM16;
+                    datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+                    iAudioDecDatapath->AddNode(datapathnode);
+                }
+
+                //Add sink node to datapath
+                datapathnode.iNode = *sinkNode;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = true;
+                datapathnode.iLoggoffOnReset = true;
+                datapathnode.iIgnoreNodeState = false;
+                datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+                datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+                datapath->AddNode(datapathnode);
+
+                datapath->SetChannelId(cmd->iPvtCmdData);
+                datapath->SetCmd(cmd);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::AddDataSinkL - invalid video dec datapath state %d\n",
+                                 iVideoDecDatapath->GetState()));
+                OSCL_LEAVE(PVMFErrInvalidState);
+            }
+        }
+    }
+
+    else if ((datapath->GetSourceSinkFormat() == PVMF_MIME_AMR_IF2) || (datapath->GetSourceSinkFormat() == PVMF_MIME_AMR_IETF) || (datapath->GetSourceSinkFormat() == PVMF_MIME_G723) || (datapath->GetSourceSinkFormat() == PVMF_MIME_PCM16))
+    {
+        if (datapath->GetState() == EClosed)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::AddDataSinkL - adding - audio sink node\n"));
+
+            //Add tsc node to datapath
+            datapathnode.iNode = iTscNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = false;
+            datapathnode.iIgnoreNodeState = true;
+            datapathnode.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+            datapathnode.iOutputPort.iCanCancelPort = true;
+            datapathnode.iOutputPort.iPortSetType = EAppDefined;
+            datapathnode.iOutputPort.iFormatType = datapath->GetFormat();
+            // Need to put in the LC number here
+            //datapathnode.iOutputPort.iPortTag = GetStackNodePortTag(EPV2WayAudioOut);
+            datapathnode.iOutputPort.iPortTag = -cmd->iPvtCmdData;
+            datapath->AddNode(datapathnode);
+
+            if (datapath->GetSourceSinkFormat() == PVMF_MIME_PCM16)
+            {
+                //Add audio dec node to datapath
+                datapathnode.iNode = iAudioDecNode;
+                datapathnode.iConfigure = NULL;
+                datapathnode.iCanNodePause = true;
+                datapathnode.iIgnoreNodeState = false;
+                datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+                datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+                datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+                datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+                // Changed from initialized because decoder node now tries to
+                // immediately send data downstream during prepare, but the
+                // downstream port isn't connected at that time.
+                datapathnode.iOutputPort.iRequestPortState = EPVMFNodeIdle;
+                datapathnode.iOutputPort.iPortSetType = EUserDefined;
+                datapathnode.iOutputPort.iFormatType = PVMF_MIME_PCM16;
+                datapathnode.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+                datapath->AddNode(datapathnode);
+            }
+
+            //Add sink node to datapath
+            datapathnode.iNode = *sinkNode;
+            datapathnode.iConfigure = NULL;
+            datapathnode.iCanNodePause = true;
+            datapathnode.iLoggoffOnReset = true;
+            datapathnode.iIgnoreNodeState = false;
+            datapathnode.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            datapathnode.iInputPort.iPortSetType = EConnectedPortFormat;
+            datapathnode.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            datapathnode.iOutputPort.iCanCancelPort = false;
+            datapathnode.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            datapathnode.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            datapath->AddNode(datapathnode);
+
+            datapath->SetChannelId(cmd->iPvtCmdData);
+
+            datapath->SetCmd(cmd);
+        }
+        else
+        {
+            OSCL_ASSERT(datapath);
+        }
+    }
+
+}
+
+PVCommandId CPV324m2Way::RemoveDataSink(PVMFNodeInterface& aDataSink,
+                                        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveDataSinkL(%x, %x, %x)", 0, 0,
+                     aContextData));
+
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::RemoveDataSinkL - invalid state(%d)",
+                             iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            //State check okay.
+            break;
+    }
+
+    return DoRemoveDataSourceSink(aDataSink, aContextData);
+}
+
+PVCommandId CPV324m2Way::Connect(const PV2WayConnectOptions& aOptions,
+                                 PVMFNodeInterface* aCommServer,
+                                 OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ConnectL()"));
+    CPVDatapathNode node;
+
+    // validate aCommServer
+    if (aCommServer == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ConnectL comm server is null"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    if (iConnectInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConnectL cmd already sent out"));
+        OSCL_LEAVE(PVMFErrBusy);
+    }
+
+    /* set clock to 0 and start */
+    uint32 startTime = 0;
+    bool overflowFlag = false;
+
+    if (!iClock.SetStartTime32(startTime, PVMF_MEDIA_CLOCK_MSEC, overflowFlag))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::Connect: unable to set clock time"));
+        OSCL_LEAVE(PVMFFailure);
+    }
+
+    switch (iState)
+    {
+        case ESetup:
+            iConnectInfo = GetCmdInfoL();
+
+            iLoopbackMode = aOptions.iLoopbackMode;
+            ((TSC_324m *)(PVMFNodeInterface *)iTscNode.iNode)->SetLoopbackMode(iLoopbackMode);
+            ((TSC_324m *)(PVMFNodeInterface *)iTscNode.iNode)->SetEndSessionTimeout(((PV2Way324ConnectOptions *)(&aOptions))->iDisconnectTimeoutInterval);
+
+            // Store reference to comm server
+            iCommNode = TPV2WayNode(aCommServer);
+            InitiateSession(iCommNode);
+
+            //Add tsc node to datapath
+            node.iNode = iTscNode;
+            node.iConfigure = this;
+            node.iIgnoreNodeState = false;
+            node.iConfigTime = EConfigBeforeStart;
+            node.iOutputPort.iRequestPortState = EPVMFNodeInitialized;
+            node.iOutputPort.iPortSetType = EUserDefined;
+            node.iOutputPort.iFormatType = PVMF_MIME_H223;
+            //node.iOutputPort.iPortType = EPVIOPort;
+            node.iOutputPort.iPortTag = PV_MULTIPLEXED;
+            iMuxDatapath->AddNode(node);
+
+            //Add rcomm node to datapath
+            node.iNode = iCommNode;
+            node.iLoggoffOnReset = true;
+            node.iConfigure = NULL;
+            node.iIgnoreNodeState = false;
+            node.iLoggoffOnReset = false;
+            node.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            node.iInputPort.iPortSetType = EUserDefined;
+            node.iInputPort.iFormatType = PVMF_MIME_H223;
+            node.iInputPort.iPortTag = PV2WAY_IO_PORT;
+            //node.iInputPort.iProperty.iPortType = EPVIOPort;
+            node.iOutputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            //node.iOutputPort.iPortType = EPVInvalidPortType;
+            node.iOutputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            iMuxDatapath->AddNode(node);
+
+            iConnectInfo->type = PVT_COMMAND_CONNECT;
+            iConnectInfo->id = iCommandId;
+            iConnectInfo->contextData = aContextData;
+            SetState(EConnecting);
+
+            iMuxDatapath->Open();
+            break;
+
+        case EConnected:
+            iConnectInfo = GetCmdInfoL();
+            iConnectInfo->type = PVT_COMMAND_CONNECT;
+            iConnectInfo->status = PVMFSuccess;
+            iConnectInfo->id = iCommandId;
+            iConnectInfo->contextData = aContextData;
+            Dispatch(iConnectInfo);
+            iConnectInfo = NULL;
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ConnectL - invalid state(%d)", iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    /*
+    	// start enc datapaths that are already created
+    	if (iAudioEncDatapath->GetState() != EClosed)
+    	{
+    		iAudioEncDatapath->CheckOpen();
+    	}
+    	if (iVideoEncDatapath->GetState() != EClosed)
+    	{
+    		iVideoEncDatapath->CheckOpen();
+    	}
+    	*/
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::Disconnect(OsclAny* aContextData)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::Disconnect()"));
+
+    if (iDisconnectInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::Disconnect cmd already sent out"));
+        OSCL_LEAVE(PVMFErrBusy);
+    }
+
+    switch (iState)
+    {
+        case EConnecting:
+            //Connect in progress, notify application that it has been cancelled.
+            iConnectInfo->status = PVMFErrCancelled;
+            Dispatch(iConnectInfo);
+            iConnectInfo = NULL;
+            //Fall through to next case
+
+        case EConnected:
+
+            iTSC324mInterface->EndSessionCommand();
+
+            iEndSessionTimer->SetObserver(this);
+            iEndSessionTimer->Request(END_SESSION_TIMER_ID, END_SESSION_TIMER_ID,
+                                      END_SESSION_TIMER_VALUE, this);
+
+            iDisconnectInfo = GetCmdInfoL();
+
+            iDisconnectInfo->type = PVT_COMMAND_DISCONNECT;
+            iDisconnectInfo->contextData = aContextData;
+            iDisconnectInfo->id = iCommandId;
+
+            //We wait to InitiateDisconnect() till iEndSessionTimer timer expires
+            break;
+
+        case EDisconnecting:
+            //If at this point, then remote disconnect is in progress, just treat as user disconnect.
+            iDisconnectInfo = GetCmdInfoL();
+
+            iDisconnectInfo->type = PVT_COMMAND_DISCONNECT;
+            iDisconnectInfo->contextData = aContextData;
+            iDisconnectInfo->id = iCommandId;
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::Disconnect - invalid state(%d)", iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+void CPV324m2Way::InitiateDisconnect()
+{
+    SetState(EDisconnecting);
+    CheckState();
+}
+
+void CPV324m2Way::InitiateReset()
+{
+    SetState(EResetting);
+
+    if (isIFrameReqTimerActive)
+    {
+        iIFrameReqTimer.Cancel(IFRAME_REQ_TIMERID);
+        isIFrameReqTimerActive = false;
+    }
+
+    if ((iAudioDecDatapath != NULL) && (iAudioDecDatapath->GetState() != EClosed))
+    {
+        iAudioDecDatapath->SetCmd(NULL);
+    }
+
+    if ((iAudioEncDatapath != NULL) && (iAudioEncDatapath->GetState() != EClosed))
+    {
+        iAudioEncDatapath->SetCmd(NULL);
+    }
+
+    if ((iVideoDecDatapath != NULL) && (iVideoDecDatapath->GetState() != EClosed))
+    {
+        iVideoDecDatapath->SetCmd(NULL);
+    }
+
+    if ((iVideoEncDatapath != NULL) && (iVideoEncDatapath->GetState() != EClosed))
+    {
+        iVideoEncDatapath->SetCmd(NULL);
+    }
+
+    CheckState();
+}
+
+void CPV324m2Way::CheckState()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckState state %d\n", iState));
+    switch (iState)
+    {
+        case EInitializing:
+            CheckInit();
+            break;
+
+        case EConnecting:
+            CheckConnect();
+            break;
+
+        case EDisconnecting:
+            CheckDisconnect();
+            break;
+
+        case EResetting:
+            CheckReset();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "CPV324m2Way::CheckState warning: static state!"));
+            break;
+    }
+}
+
+void CPV324m2Way::CheckInit()
+{
+//	PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0,"CPV324m2Way::CheckInit state %d, video enc node state %d, interface state %d\n", iState, ((PVMFNodeInterface *)iVideoEncNode)->GetState(), iVideoEncNodeInterface.iState));
+    int32 error;
+
+    if (((PVMFNodeInterface *)iTscNode)->GetState() == EPVMFNodeIdle)
+    {
+        OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_INIT, &iTscNode, this));
+        OSCL_FIRST_CATCH_ANY(error,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::CheckInit unable to init tsc node!\n"));
+                             SetState(EResetting);
+                             CheckState();
+                             return;);
+    }
+    if (((PVMFNodeInterface *)iTscNode)->GetState() == EPVMFNodeInitialized)
+    {
+
+        SetState(ESetup);
+
+        iInitInfo->status = PVMFSuccess;
+        Dispatch(iInitInfo);
+        iInitInfo = NULL;
+    }
+}
+
+void CPV324m2Way::CheckConnect()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::CheckConnect state %d, comm state %d, tsc state %d\n",
+                     iState, ((PVMFNodeInterface *)iCommNode)->GetState(),
+                     ((PVMFNodeInterface *)iTscNode)->GetState()));
+
+    if ((iMuxDatapath->GetState() == EOpened) && iIsStackConnected)
+    {
+        /* Increase video encoder bitrate if required */
+        //	PVMp4H263EncExtensionInterface *ptr = (PVMp4H263EncExtensionInterface *) iVideoEncNodeInterface.iInterface;
+        //	ptr->SetOutputBitRate(0, VIDEO_ENCODER_BITRATE);
+        SetState(EConnected);
+
+        iConnectInfo->status = PVMFSuccess;
+        Dispatch(iConnectInfo);
+        iConnectInfo = NULL;
+    }
+}
+
+
+void CPV324m2Way::CheckDisconnect()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::CheckDisconnect state %d, mux datapath state %d, stack connected %d\n",
+                     iState, iMuxDatapath->GetState(), iIsStackConnected));
+    if ((iMuxDatapath->GetState() == EClosed) &&
+            !iIsStackConnected)
+    {
+        SetState(ESetup);
+
+        //Connect failed
+        if (iConnectInfo)
+        {
+            iConnectInfo->status = PVMFFailure;
+            Dispatch(iConnectInfo);
+            iConnectInfo = NULL;
+        }
+        //Else command cancelled
+        else if (iCancelInfo)
+        {
+            iCancelInfo->status = PVMFSuccess;
+            Dispatch(iCancelInfo);
+            iCancelInfo = NULL;
+        }
+        //Else local disconnect
+        else if (iDisconnectInfo)
+        {
+            iDisconnectInfo->status = PVMFSuccess;
+            Dispatch(iDisconnectInfo);
+            iDisconnectInfo = NULL;
+        }
+        //Else remote disconnect
+        else
+        {
+            TPV2WayEventInfo* aEvent = NULL;
+            if (!GetEventInfo(aEvent))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::CheckDisconnect unable to notify app!\n"));
+                return;
+            }
+            aEvent->type = PVT_INDICATION_DISCONNECT;
+            Dispatch(aEvent);
+        }
+    }
+    else
+    {
+        iMuxDatapath->Close();
+    }
+}
+
+void CPV324m2Way::CheckReset()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::CheckReset state %d \n", iState));
+    int32 error;
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    switch (iRecordFileState)
+    {
+        case File2WayInitializing:
+        case File2WayInitialized:
+            InitiateResetRecordFile();
+            break;
+
+        case File2WayIdle:
+        case File2WayResetting:
+            break;
+    }
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    switch (iPlayFileState)
+    {
+        case File2WayInitializing:
+        case File2WayInitialized:
+            InitiateResetPlayFile();
+            break;
+
+        case File2WayIdle:
+        case File2WayResetting:
+            break;
+    }
+#endif
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    if (iRecordFileState != File2WayIdle) return;
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    if (iPlayFileState != File2WayIdle) return;
+#endif
+
+
+
+    if ((iAudioEncDatapath != NULL) && (iAudioEncDatapath->GetState() == EClosed) &&
+            (iAudioDecDatapath != NULL) && (iAudioDecDatapath->GetState() == EClosed) &&
+            (iVideoEncDatapath != NULL) && (iVideoEncDatapath->GetState() == EClosed) &&
+            (iVideoDecDatapath != NULL) && (iVideoDecDatapath->GetState() == EClosed))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::CheckReset state %d, AD state %d, VD state %d, AE state %d, VE state %d\n",
+                         iState,
+                         iAudioDecDatapath->GetState(),
+                         iVideoDecDatapath->GetState(),
+                         iAudioEncDatapath->GetState(),
+                         iVideoEncDatapath->GetState()));
+
+        TPVMFNodeInterfaceState vidEncState;
+
+        if (iVideoEncNode != NULL)
+        {
+            vidEncState = ((PVMFNodeInterface *)iVideoEncNode)->GetState() ;
+            if ((vidEncState == EPVMFNodeInitialized) || (vidEncState == EPVMFNodeError))
+            {
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_RESET, &iVideoEncNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckReset unable to reset video encoder node!\n"));
+                                     return;);
+            }
+        }
+
+        if (iAudioEncNode != NULL)
+        {
+            if ((iAudioEncNode.iNode->GetState() == EPVMFNodeInitialized) ||
+                    (iAudioEncNode.iNode->GetState() == EPVMFNodeError))
+            {
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_RESET, &iAudioEncNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckReset unable to reset audio encoder node!\n"));
+                                     return;);
+            }
+        }
+    }
+
+    TPVMFNodeInterfaceState tscState = ((PVMFNodeInterface *)iTscNode)->GetState() ;
+
+    if ((tscState == EPVMFNodeInitialized) ||
+            (tscState == EPVMFNodeError))
+    {
+        OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_RESET, &iTscNode, this));
+        OSCL_FIRST_CATCH_ANY(error,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::CheckReset unable to reset tsc node!\n"));
+                             return;);
+    }
+    bool aFlag = false;
+    if ((tscState == EPVMFNodeIdle) &&
+            (iVideoEncNodeInterface.iState != PV2WayNodeInterface::QueryInterface))
+    {
+        if (iVideoEncNode.iNode != NULL)
+            aFlag = IsNodeReset(*(iVideoEncNode.iNode));
+        else
+            aFlag = true;
+
+    }
+
+    if (aFlag == true)
+    {
+        iIncomingChannelParams.clear();
+        iOutgoingChannelParams.clear();
+
+        SetState(EIdle);
+
+        //Init failed
+        if (iInitInfo)
+        {
+            iInitInfo->status = PVMFFailure;
+            Dispatch(iInitInfo);
+            iInitInfo = NULL;
+        }
+        //Else command cancelled
+        else if (iCancelInfo)
+        {
+            iCancelInfo->status = PVMFSuccess;
+            Dispatch(iCancelInfo);
+            iCancelInfo = NULL;
+        }
+        //Else local reset
+        else
+        {
+            iResetInfo->status = PVMFSuccess;
+            Dispatch(iResetInfo);
+            iResetInfo = NULL;
+        }
+    }
+
+}
+
+
+void CPV324m2Way::RemoveAudioDecPath()
+{
+    if (iAudioDecDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::RemoveAudioDecPath audio dec path state %d\n",
+                         iAudioDecDatapath->GetState()));
+    }
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    RemoveAudioRecPath();
+#endif
+
+    if ((iAudioDecDatapath != NULL) &&
+            (iAudioDecDatapath->GetState() == EClosed))
+    {
+        iAudioDecDatapath->ResetDatapath();
+        iAudioSinkNode.Clear();
+    }
+}
+
+void CPV324m2Way::RemoveAudioEncPath()
+{
+    if (iAudioEncDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::RemoveAudioEncPath audio enc path state %d\n",
+                         iAudioEncDatapath->GetState()));
+    }
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    RemoveAudioPreviewPath();
+#endif
+
+    if ((iAudioEncDatapath != NULL) &&
+            (iAudioEncDatapath->GetState() == EClosed))
+    {
+        iAudioEncDatapath->SetSourceInputPort(NULL);
+        iAudioEncDatapath->ResetDatapath();
+        iAudioSrcNode.Clear();
+    }
+}
+
+void CPV324m2Way::RemoveVideoDecPath()
+{
+    if (iVideoDecDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::RemoveVideoDecPath video dec path state %d\n",
+                         iVideoDecDatapath->GetState()));
+    }
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    RemoveVideoRecPath();
+#endif
+
+    if ((iVideoDecDatapath != NULL) &&
+            (iVideoDecDatapath->GetState() == EClosed))
+    {
+        iVideoDecDatapath->ResetDatapath();
+    }
+}
+
+void CPV324m2Way::RemoveVideoEncPath()
+{
+    if (iVideoEncDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::RemoveVideoEncPath video enc path state %d\n",
+                         iVideoEncDatapath->GetState()));
+    }
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    RemoveVideoPreviewPath();
+#endif
+
+    if ((iVideoEncDatapath != NULL) &&
+            (iVideoEncDatapath->GetState() == EClosed))
+    {
+        //Video encoder will be deleted at reset time.
+
+        iVideoEncDatapath->ResetDatapath();
+    }
+}
+
+void CPV324m2Way::HandleCommNodeCmd(PV2WayNodeCmdType aType,
+                                    const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleCommNodeCmd type %d\n", aType));
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_INIT:
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                SetState(EResetting);
+            }
+
+            CheckState();
+            break;
+
+        case PV2WAY_NODE_CMD_RESET:
+            CheckState();
+            break;
+
+        default:
+            break;
+    }
+}
+
+void CPV324m2Way::HandleTscNodeCmd(PV2WayNodeCmdType aType,
+                                   const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleTscNodeCmd type %d\n", aType));
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                ((TSC_324m *)((PVMFNodeInterface *)iTscNode))->SetIncomingChannelConfig(iIncomingChannelParams);
+                ((TSC_324m *)((PVMFNodeInterface *)iTscNode))->SetOutgoingChannelConfig(iOutgoingChannelParams);
+            }
+            else
+            {
+                SetState(EResetting);
+            }
+
+            CheckState();
+            break;
+
+        case PV2WAY_NODE_CMD_RESET:
+            CheckState();
+            break;
+
+        default:
+            break;
+    }
+}
+
+
+void CPV324m2Way::HandleVideoDecNodeCmd(PV2WayNodeCmdType aType,
+                                        const PVMFCmdResp& aResponse)
+{
+    OSCL_UNUSED_ARG(aType);
+    OSCL_UNUSED_ARG(aResponse);
+#if 0
+    if (iVideoEncDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::HandleVideoDecNodeCmd type %d, video enc path state %d\n",
+                         aType, iVideoEncDatapath->GetState()));
+    }
+    PvmiKvp kvp;
+    int32 numElems;
+    PvmiKvp *retKvp;
+    int32 error;
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_QUERY_INTERFACE:
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                kvp.key = "x-pvmf/video/decoder/dropframe_enable;valtype=bool";
+                kvp.capacity = oscl_strlen("x-pvmf/video/decoder/dropframe_enable;valtype=bool");
+                kvp.length = kvp.capacity;
+                kvp.value.bool_value = true;
+                numElems = 1;
+
+                OSCL_TRY(error, ptr->setParametersSync(NULL, &kvp, numElems, retKvp));
+                OSCL_FIRST_CATCH_ANY(error, SetState(EResetting));
+            }
+            else
+            {
+                iVideoDecNodeInterface.iState = PV2WayNodeInterface::NoInterface;
+                SetState(EResetting);
+            }
+
+            CheckState();
+            break;
+
+        default:
+            break;
+    }
+#endif
+}
+
+void CPV324m2Way::HandleVideoEncNodeCmd(PV2WayNodeCmdType aType,
+                                        const PVMFCmdResp& aResponse)
+{
+    if (iVideoEncDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::HandleVideoEncNodeCmd type %d, video enc path state %d\n",
+                         aType, iVideoEncDatapath->GetState()));
+    }
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_QUERY_INTERFACE:
+
+            if (aResponse.GetCmdId() == iVideoEncQueryIntCmdId)
+            {
+                iVideoEncQueryIntCmdId = -1;
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoEncNodeInterface.iState = PV2WayNodeInterface::HasInterface;
+                    // Set the FormatSpecificInfo if available
+                    uint32 fsi_len = 0;
+                    uint8* fsi = iVideoEncDatapath->GetFormatSpecificInfo(&fsi_len);
+                    if (fsi && fsi_len)
+                    {
+                        OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface *,
+                                         iVideoEncNodeInterface.iInterface)->SetFSIParam(fsi, fsi_len);
+                        if (iAddDataSourceVideoCmd)
+                        {
+                            iVideoEncDatapath->SetCmd(iAddDataSourceVideoCmd);
+                            iAddDataSourceVideoCmd = NULL;
+                        }
+                    }
+                }
+                else
+                {
+                    iVideoEncNodeInterface.iState = PV2WayNodeInterface::NoInterface;
+                    SetState(EResetting);
+                }
+
+            }
+
+            CheckState();
+            break;
+
+        case PV2WAY_NODE_CMD_INIT:
+            CheckState();
+            break;
+
+        case PV2WAY_NODE_CMD_RESET:
+            CheckState();
+            break;
+
+        default:
+            break;
+    }
+}
+
+void CPV324m2Way::HandleSinkNodeCmd(PV2WayNodeCmdType aType,
+                                    const PVMFCmdResp& aResponse,
+                                    TPV2WayNode* aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleSinkNodeCmd type %d\n", aType));
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_INIT:
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                SetState(EResetting);
+                CheckState();
+            }
+            else
+            {
+                DoAddDataSink(*aNode, aResponse);
+            }
+            break;
+        case PV2WAY_NODE_CMD_QUERY_INTERFACE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                for (uint32 ii = 0; ii < iSinkNodeList.size();ii++)
+                {
+                    if ((aNode == iSinkNodeList[ii].iSinkNode) &&
+                            (aResponse.GetCmdId() == iSinkNodeList[ii].iNodeInterface.iId))
+                    {
+                        iSinkNodeList[ii].iNodeInterface.iInterface =
+                            iClockSyncInterface.iInterface;
+                        iClockSyncInterface.Reset();
+                        if (iSinkNodeList[ii].iNodeInterface.iInterface != NULL)
+                        {
+                            iSinkNodeList[ii].iNodeInterface.iState =
+                                PV2WayNodeInterface::HasInterface;
+                            PvmfNodesSyncControlInterface* ptr = NULL;
+                            ptr = OSCL_STATIC_CAST(PvmfNodesSyncControlInterface*,
+                                                   iSinkNodeList[ii].iNodeInterface.iInterface);
+                            ptr->SetClock(&iClock);
+                        }
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                SetState(EResetting);
+                CheckState();
+            }
+            break;
+        case PV2WAY_NODE_CMD_SKIP_MEDIA_DATA:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                            (0, "CPV324m2Way::HandleSinkNodeCmd type %d, SkipComplete for Node %x ",
+                             aType, aNode->iNode));
+            break;
+        default:
+            break;
+    }
+}
+
+void CPV324m2Way::SupportedSinkNodeInterfaces(TPV2WayNode* aNode)
+{
+
+    int32 error;
+
+    //Currently this only checks if the sink node support PvmfSyncNodeControlInterface
+
+    TPV2WayNodeQueryInterfaceParams queryParam;
+    queryParam.iUuid = (PVUuid *) & iSyncControlPVUuid;
+    SinkNodeIFList sinkNode;
+    sinkNode.iSinkNode = aNode;
+    queryParam.iInterfacePtr = &iClockSyncInterface.iInterface;
+    OSCL_TRY(error, sinkNode.iNodeInterface.iId =
+                 SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE, aNode, this, &queryParam));
+
+    iSinkNodeList.push_back(sinkNode);
+
+    OSCL_FIRST_CATCH_ANY(error,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                         (0, "CPV324m2Way::SupportedSinkNodeInterfaces unable to query for MediaOutputNode extension interface!\n"));
+                         SetState(EResetting);
+                         CheckState();
+                         return;);
+}
+
+
+void CPV324m2Way::HandleAudioEncNodeCmd(PV2WayNodeCmdType aType,
+                                        const PVMFCmdResp& aResponse)
+{
+    if (iAudioEncDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::HandleAudioEncNodeCmd type %d, audio enc path state %d\n",
+                         aType, iAudioEncDatapath->GetState()));
+    }
+    OSCL_UNUSED_ARG(aResponse);
+    OSCL_UNUSED_ARG(aType);
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_QUERY_INTERFACE:
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iAudioEncNodeInterface.iState = PV2WayNodeInterface::HasInterface;
+
+#if 0
+                PVAMREncExtensionInterface *ptr =
+                    (PVAMREncExtensionInterface *) iAudioEncNodeInterface.iInterface;
+                ptr->SetOutputFormat(PVMF_MIME_AMR_IF2);
+                ptr->SetInputSamplingRate(KSamplingRate);
+                ptr->SetInputBitsPerSample(KBitsPerSample);
+                ptr->SetInputNumChannels(KNumChannels);
+                ptr->SetOutputBitRate(GSM_AMR_12_2);
+                ptr->SetMaxNumOutputFramesPerBuffer(KNumPCMFrames);
+#endif
+            }
+            else
+            {
+                iAudioEncNodeInterface.iState = PV2WayNodeInterface::NoInterface;
+                SetState(EResetting);
+            }
+
+            CheckState();
+            break;
+
+        case PV2WAY_NODE_CMD_INIT:
+            CheckState();
+            break;
+
+        case PV2WAY_NODE_CMD_RESET:
+            CheckState();
+            break;
+
+        default:
+            break;
+    }
+}
+
+void CPV324m2Way::GenerateIFrame(PVMFPortInterface *aPort)
+{
+    if (iVideoEncDatapath)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::GenerateIFrame, vid enc path state %d\n",
+                         iVideoEncDatapath->GetState()));
+
+        if ((iVideoEncDatapath->IsPortInDatapath(aPort)) &&
+                (iVideoEncDatapath->GetState() == EOpened))
+        {
+            if (!((PVMp4H263EncExtensionInterface *) iVideoEncNodeInterface.iInterface)->RequestIFrame())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::GenerateIFrame - unable to generate iframe"));
+            }
+        }
+    }
+}
+
+void CPV324m2Way::RequestRemoteIFrame(PVMFPortInterface *aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "CPV324m2Way::RequestRemoteIFrame, timer active %d\n", isIFrameReqTimerActive));
+    TSC_324m *nodeIface = (TSC_324m *)((PVMFNodeInterface *)iTscNode);
+    if (nodeIface &&
+            !isIFrameReqTimerActive &&
+            (nodeIface->RequestFrameUpdate(aPort) == EPVT_Success))
+    {
+        //Still need to actually send an iframe request!!!!
+        iIFrameReqTimer.Request(IFRAME_REQ_TIMERID, (int32)this,
+                                iMinIFrameRequestInterval, this);
+        isIFrameReqTimerActive = true;
+    }
+}
+
+PVCommandId CPV324m2Way::GetState(PV2WayState& aState,
+                                  OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::GetPV2WayState %d\n", iState));
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    cmd->type = PVT_COMMAND_GET_PV2WAY_STATE;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+
+    aState = iState;
+
+    Dispatch(cmd);
+
+    return iCommandId++;
+}
+
+
+PVCommandId CPV324m2Way::SetLatencyQualityTradeoff(PVMFNodeInterface& aTrack,
+        int32 aTradeoff,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aTrack);
+    OSCL_UNUSED_ARG(aTradeoff);
+    OSCL_UNUSED_ARG(aContextData);
+#if 0
+    TPV2WayCmdInfo *cmd;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::SetLatencyQualityTradeoffL\n"));
+
+#ifndef NO_2WAY_324
+    if (iTerminalType != PV_324M)
+    {
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+
+    if (iState != EConnected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::SetLatencyQualityTradeoff - invalid state(%d)", iState));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iVideoEncDatapath && iVideoEncDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::SetLatencyQualityTradeoff - Sending VidTempSpatTradeoff Indication for track id %d\n",
+                         iVideoEncDatapath->GetTSCPortTag()));
+        iTSC324mInterface->SendVideoTemporalSpatialTradeoffIndication(iVideoEncDatapath->GetTSCPortTag(),
+                aTradeoff);
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::SetLatencyQualityTradeoff - Sending VidTempSpatTradeoff Command for track id %d\n",
+                         iVideoEncDatapath->GetTSCPortTag()));
+        iTSC324mInterface->SendVideoTemporalSpatialTradeoffCommand(iVideoDecDatapath->GetTSCPortTag(),
+                aTradeoff);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::SetLatencyQualityTradeoff - invalid state(%d)", iState));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    cmd = GetCmdInfoL();
+    cmd->type = PVT_COMMAND_SET_TRADEOFF;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+    Dispatch(cmd);
+
+#else
+    OSCL_LEAVE(PVMFErrNotSupported);
+#endif
+#endif
+    return iCommandId++;
+}
+
+
+PVCommandId CPV324m2Way::Pause(PV2WayDirection aDirection,
+                               PVTrackId aTrackId,
+                               OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV324m2Way::Pause\n"));
+    OSCL_UNUSED_ARG(aDirection);
+    OSCL_UNUSED_ARG(aTrackId);
+    OSCL_UNUSED_ARG(aContextData);
+
+    OSCL_LEAVE(PVMFErrNotSupported);
+#if 0
+    CPV2WayDataChannelDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::Pause - invalid state(%d)", iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            //State check okay.
+            break;
+    }
+
+    if (iVideoEncDatapath && iVideoEncDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PauseL video source, state %d\n",
+                         iVideoEncDatapath->GetState()));
+        datapath = iVideoEncDatapath;
+    }
+    else if (iAudioEncDatapath && iAudioEncDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PauseL audio source, state %d\n",
+                         iAudioEncDatapath->GetState()));
+        datapath = iAudioEncDatapath;
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PauseL video sink, state %d\n",
+                         iVideoDecDatapath->GetState()));
+        datapath = iVideoDecDatapath;
+    }
+    else if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PauseL audio sink, state %d\n",
+                         iAudioDecDatapath->GetState()));
+        datapath = iAudioDecDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PauseL - unknown node!"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EOpened:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_PAUSE;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+            break;
+
+        case EPaused:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_PAUSE;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EPausing:
+            return datapath->GetCmdInfo()->id;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::PauseL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+
+
+PVCommandId CPV324m2Way::Resume(PV2WayDirection aDirection,
+                                PVTrackId aTrackId,
+                                OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::Resume\n"));
+    OSCL_UNUSED_ARG(aDirection);
+    OSCL_UNUSED_ARG(aTrackId);
+    OSCL_UNUSED_ARG(aContextData);
+    OSCL_LEAVE(PVMFErrNotSupported);
+
+#if 0
+    CPV2WayDataChannelDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::Resume - invalid state(%d)", iState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            //State check okay.
+            break;
+    }
+
+    if (iVideoEncDatapath && iVideoEncDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::Resume video source, state %d\n",
+                         iVideoEncDatapath->GetState()));
+        datapath = iVideoEncDatapath;
+    }
+    else if (iAudioEncDatapath && iAudioEncDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::Resume audio source, state %d\n",
+                         iAudioEncDatapath->GetState()));
+        datapath = iAudioEncDatapath;
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::Resume video sink, state %d\n",
+                         iVideoDecDatapath->GetState()));
+        datapath = iVideoDecDatapath;
+    }
+    else if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath(&aTrack))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::Resume audio sink, state %d\n",
+                         iAudioDecDatapath->GetState()));
+        datapath = iAudioDecDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::Resume - unknown node!"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EPaused:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_RESUME;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+            break;
+
+        case EOpened:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_RESUME;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EUnpausing:
+            return datapath->GetCmdInfo()->id;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResumeL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+
+
+PVCommandId CPV324m2Way::SetLogAppender(const char * aTag,
+                                        OsclSharedPtr<PVLoggerAppender>& aAppender,
+                                        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::SetLogAppenderL\n"));
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    PVLogger *logger = PVLogger::GetLoggerObject(aTag);
+    logger->AddAppender(aAppender);
+
+    // print sdk info
+    PVSDKInfo sdkinfo;
+    FillSDKInfo(sdkinfo);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PV RELEASE LABEL = %s", sdkinfo.iLabel.get_cstr()));
+
+    cmd->type = PVT_COMMAND_SET_LOG_APPENDER;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+
+    Dispatch(cmd);
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::RemoveLogAppender(const char * aTag,
+        OsclSharedPtr<PVLoggerAppender>& aAppender,
+        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveLogAppenderL\n"));
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    cmd->type = PVT_COMMAND_REMOVE_LOG_APPENDER;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+
+    PVLogger *logger = PVLogger::GetLoggerObject(aTag);
+    logger->RemoveAppender(aAppender);
+
+    Dispatch(cmd);
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::SetLogLevel(const char * aTag,
+                                     int32 aLevel,
+                                     bool aSetSubtree,
+                                     OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::SetLogLevelL\n"));
+    OSCL_UNUSED_ARG(aSetSubtree);
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    cmd->type = PVT_COMMAND_SET_LOG_LEVEL;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+
+    PVLogger *logger = PVLogger::GetLoggerObject(aTag);
+    logger->SetLogLevel(aLevel);
+
+    Dispatch(cmd);
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::GetLogLevel(const char * aTag,
+                                     int32& aLogInfo,
+                                     OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::GetLogLevelL\n"));
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+
+    cmd->type = PVT_COMMAND_GET_LOG_LEVEL;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFSuccess;
+
+    PVLogger *logger = PVLogger::GetLoggerObject(aTag);
+    aLogInfo = logger->GetLogLevel();
+
+    Dispatch(cmd);
+    return iCommandId++;
+}
+
+#if 0
+PVCommandId CPV324m2Way::SendUserInput(CPVUserInput& user_input,
+                                       OsclAny* aContextData)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::SendUserInputL state %d, type %d\n", iState, user_input.GetType()));
+    TPV2WayCmdInfo *cmd;
+#ifndef NO_2WAY_324
+
+    if (iState != EConnected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::SendUserInputL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    switch (user_input.GetType())
+    {
+        case EAlphanumeric:
+            CPVUserInputAlphanumeric *alpha;
+
+            alpha = (CPVUserInputAlphanumeric *) & user_input;
+
+            if ((alpha->GetInput() == NULL) || (alpha->GetLength() == 0))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::SendUserInputL invalid alphanumeric string, ptr %x, len %d!\n",
+                                 alpha->GetInput(), alpha->GetLength()));
+                OSCL_LEAVE(PVMFErrArgument);
+            }
+
+            cmd = GetCmdInfoL();
+
+            ((TSC_324m *) iTscNode.node)->Tsc_UII_Alphanumeric(alpha->GetInput(),
+                    alpha->GetLength());
+
+            cmd->type = PVT_COMMAND_SEND_USER_INPUT;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EDtmf:
+            CPVUserInputDtmf *dtmf;
+
+            dtmf = (CPVUserInputDtmf *) & user_input;
+
+            cmd = GetCmdInfoL();
+
+            ((TSC_324m *) iTscNode.node)->Tsc_UII_DTMF(dtmf->GetInput(),
+                    dtmf->GetDuration());
+
+            cmd->type = PVT_COMMAND_SEND_USER_INPUT;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::SendUserInputL invalid user input type!\n"));
+            OSCL_LEAVE(PVMFErrArgument);
+            break;
+    }
+#else
+    cmd = GetCmdInfoL();
+    cmd->type = PVT_COMMAND_SEND_USER_INPUT;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFErrNotSupported;
+    Dispatch(cmd);
+#endif
+
+    return iCommandId++;
+}
+
+
+TPVCmnCommandId CPV324m2Way::GetCallStatistics(CPVCmn2WayStatistics& /*aStats*/,
+        OsclAny* /*aContextData*/)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::GetCallStatistics\n"));
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return 0;
+}
+#endif
+
+PVCommandId CPV324m2Way::QueryInterface(const PVUuid& aUuid,
+                                        PVInterface*& aInterfacePtr,
+                                        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::QueryInterface()\n"));
+
+    TPV2WayNodeQueryInterfaceParams queryParam;
+    queryParam.iUuid = (PVUuid*) & aUuid;
+    queryParam.iInterfacePtr = &aInterfacePtr;
+
+    TPV2WayCmdInfo *cmd = GetCmdInfoL();
+    cmd->type = PVT_COMMAND_QUERY_INTERFACE;
+    cmd->id = iCommandId;
+    cmd->contextData = aContextData;
+    cmd->status = PVMFPending;
+    aInterfacePtr = NULL;
+
+    if (aUuid == PVH324MConfigUuid && ((PVMFNodeInterface *)iTscNode))
+    {
+        int32 error = 0;
+        OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE,
+                                     &iTscNode, this, &queryParam, cmd));
+        OSCL_FIRST_CATCH_ANY(error,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::QueryInterface failed!\n"));
+                             cmd->status = PVMFFailure;
+                             Dispatch(cmd););
+        cmd->status = PVMFSuccess; //ks added
+    }
+    else if (aUuid == PVMp4H263EncExtensionUUID &&
+             ((PVMFNodeInterface *)iVideoEncNode))
+    {
+        int32 error = 0;
+        OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE, &iVideoEncNode,
+                                     this, &queryParam, cmd));
+        OSCL_FIRST_CATCH_ANY(error,
+                             cmd->status = PVMFFailure;
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::QueryInterface unable to query for video encoder interface!\n")););
+    }
+    else
+    {
+        aInterfacePtr = NULL;
+        cmd->status = PVMFErrNotSupported;
+    }
+    if (cmd->status != PVMFPending)
+        Dispatch(cmd);
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::QueryUUID(const PvmfMimeString& aMimeType,
+                                   Oscl_Vector<PVUuid, BasicAlloc>& aUuids,
+                                   bool aExactUuidsOnly,
+                                   OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aUuids);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+    OSCL_UNUSED_ARG(aContextData);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::QueryUUID\n"));
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return 0;
+}
+
+PVCommandId CPV324m2Way::CancelAllCommands(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CancelAllCommands state %d\n", iState));
+
+    if (iCancelInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::CancelAllCommands, cancel in progress!\n"));
+        OSCL_LEAVE(PVMFErrBusy);
+    }
+
+    switch (iState)
+    {
+        case EInitializing:
+            iCancelInfo = GetCmdInfoL();
+            iCancelInfo->type = PVT_COMMAND_CANCEL_ALL_COMMANDS;
+            iCancelInfo->id = iCommandId;
+            iCancelInfo->contextData = aContextData;
+            SetState(EResetting);
+
+            if (!iInitInfo)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::CancelAllCommands, no init info!\n"));
+            }
+            else
+            {
+                iInitInfo->status = PVMFErrCancelled;
+                Dispatch(iInitInfo);
+                iInitInfo = NULL;
+            }
+
+            CheckState();
+            break;
+
+        case EConnecting:
+            iCancelInfo = GetCmdInfoL();
+            iCancelInfo->type = PVT_COMMAND_CANCEL_ALL_COMMANDS;
+            iCancelInfo->id = iCommandId;
+            iCancelInfo->contextData = aContextData;
+            SetState(EDisconnecting);
+
+            if (!iConnectInfo)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::CancelAllCommands, no connect info!\n"));
+            }
+            else
+            {
+                iConnectInfo->status = PVMFErrCancelled;
+                Dispatch(iConnectInfo);
+                iConnectInfo = NULL;
+            }
+
+            CheckState();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::CancelAllCommands invalid state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+#if 0
+PVCommandId CPV324m2Way::InitRecordFile(const OSCL_wString& aFileName,
+                                        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::InitRecordFileL state %d, rec state %d\n",
+                     iState, iRecordFileState));
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::InitRecordFileL invalid terminal state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            break;
+    }
+
+    switch (iRecordFileState)
+    {
+        case File2WayIdle:
+            iRecFilename = aFileName;
+
+            iInitRecFileInfo = GetCmdInfoL();
+
+            iInitRecFileInfo->type = PVT_COMMAND_INIT_RECORD_FILE;
+            iInitRecFileInfo->id = iCommandId;
+            iInitRecFileInfo->contextData = aContextData;
+
+            iRecordFileState = File2WayInitializing;
+            CheckRecordFileState();
+            break;
+
+        case File2WayInitializing:
+            if (iInitRecFileInfo)
+            {
+                return iInitRecFileInfo->id;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::InitRecordFileL no init rec info!!\n"));
+                OSCL_LEAVE(PVMFFailure);
+            }
+            break;
+
+        case File2WayInitialized:
+            iInitRecFileInfo = GetCmdInfoL();
+            iInitRecFileInfo->type = PVT_COMMAND_INIT_RECORD_FILE;
+            iInitRecFileInfo->id = iCommandId;
+            iInitRecFileInfo->contextData = aContextData;
+            iInitRecFileInfo->status = PVMFSuccess;
+            Dispatch(iInitRecFileInfo);
+            iInitRecFileInfo = NULL;
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::InitRecordFileL invalid ff composer state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::ResetRecordFile(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResetRecordFileL state %d, rec file state %d, audio rec %d, video rec %d\n",
+                     iState,
+                     iRecordFileState,
+                     iAudioRecDatapath->GetState(),
+                     iVideoRecDatapath->GetState()));
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetRecordFileL invalid terminal state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            break;
+    }
+
+    switch (iRecordFileState)
+    {
+        case File2WayIdle:
+            iResetRecFileInfo = GetCmdInfoL();
+            iResetRecFileInfo->type = PVT_COMMAND_RESET_RECORD_FILE;
+            iResetRecFileInfo->id = iCommandId;
+            iResetRecFileInfo->contextData = aContextData;
+            iResetRecFileInfo->status = PVMFSuccess;
+            Dispatch(iResetRecFileInfo);
+            iResetRecFileInfo = NULL;
+            break;
+
+        case File2WayInitialized:
+            iResetRecFileInfo = GetCmdInfoL();
+            iResetRecFileInfo->type = PVT_COMMAND_RESET_RECORD_FILE;
+            iResetRecFileInfo->id = iCommandId;
+            iResetRecFileInfo->contextData = aContextData;
+
+            InitiateResetRecordFile();
+            break;
+
+        case File2WayResetting:
+            if (iResetRecFileInfo)
+            {
+                return iResetRecFileInfo->id;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::ResetRecordFileL no reset rec info!!\n"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetRecordFileL invalid ff composer state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::StartRecord(PVMFNodeInterface& aSink,
+                                     OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::StartRecordL state %d, rec state %d\n", iState, iRecordFileState));
+    CPVDatapathNode node;
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    if ((iState != EConnected) ||
+            (iRecordFileState != File2WayInitialized))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::StartRecordL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iAudioDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StartRecordL audio sink path not open %d!\n",
+                             iAudioDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        if (iAudioRecDatapath->GetState() == EClosed)
+        {
+            //Set up audio rec datapath
+
+            //Get the codec type
+            iAudioDecDatapath->GetTSCPort()->Query(node.iOutputPort.iProperty);
+
+            if (node.iOutputPort.iFormatType != PVMF_MIME_AMR_IF2)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::StartRecordL audio format is not AMR %d!\n",
+                                 node.iOutputPort.iFormatType));
+                OSCL_LEAVE(PVMFErrNotSupported);
+            }
+
+            cmd = GetCmdInfoL();
+
+            //Add audio sink node
+            node.iNode = iAudioSinkNode;
+            node.iConfigure = NULL;
+            node.iLoggoffOnReset = false;
+            node.iOutputPort.iCanCancelPort = false;
+            node.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+            node.iOutputPort.iPortSetType = EUserDefined;
+            node.iOutputPort.iFormatType = PVMF_MIME_AMR_IF2;
+            node.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            iAudioRecDatapath->AddNode(node);
+
+            //Add ff composer node
+            node.iNode = iFFComposerNode;
+            node.iConfigure = NULL;
+            node.iLoggoffOnReset = false;
+            node.iInputPort.iCanCancelPort = false;
+            node.iInputPort.iRequestPortState = EPVMFNodeStarted;
+            node.iInputPort.iPortSetType = EConnectedPortFormat;
+            node.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            node.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            iAudioRecDatapath->AddNode(node);
+
+
+            cmd->type = PVT_COMMAND_START_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+
+            iAudioRecDatapath->SetCmd(cmd);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StartRecordL, invalid record state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iVideoDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StartRecordL video sink path not open %d!\n",
+                             iVideoDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        if (iVideoRecDatapath->GetState() == EClosed)
+        {
+            cmd = GetCmdInfoL();
+
+            //Request an Iframe
+            iTscNode.node->RequestFrameUpdate(iVideoDecDatapath->GetTSCPort());
+
+            //Set up video rec datapath
+
+            //Get the codec type
+            iVideoDecDatapath->GetTSCPort()->Query(node.iOutputPort.iProperty);
+
+            //Add video splitter node
+            node.iNode = iVideoDecSplitterNode;
+            node.iConfigure = NULL;
+            node.iLoggoffOnReset = false;
+            node.iOutputPort.iCanCancelPort = false;
+            node.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+            node.iOutputPort.iPortSetType = EUserDefined;
+            node.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            iVideoRecDatapath->AddNode(node);
+
+            //Add ff composer node
+            node.iNode = iFFComposerNode;
+            node.iConfigure = NULL;
+            node.iLoggoffOnReset = false;
+            node.iInputPort.iCanCancelPort = false;
+            node.iInputPort.iRequestPortState = EPVMFNodeStarted;
+            node.iInputPort.iPortSetType = EConnectedPortFormat;
+            node.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            node.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            iVideoRecDatapath->AddNode(node);
+
+            cmd->type = PVT_COMMAND_START_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+
+            iVideoRecDatapath->SetCmd(cmd);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StartRecordL, invalid record state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::StartRecordL unknown sink!\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::StopRecord(PVMFNodeInterface& aSink, OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::StopRecordL state %d, rec state %d\n",
+                     iState, iRecordFileState));
+    CPV2WayRecDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    if ((iState != EConnected) ||
+            (iRecordFileState != File2WayInitialized))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::StopRecordL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iAudioDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StopRecordL audio sink path not open %d!\n",
+                             iAudioDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::StopRecordL audio record, state %d\n",
+                         iAudioRecDatapath->GetState()));
+        datapath = iAudioRecDatapath;
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iVideoDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StopRecordL video sink path not open %d!\n",
+                             iVideoDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::StopRecordL video record, state %d\n",
+                         iVideoRecDatapath->GetState()));
+        datapath = iVideoRecDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::StopRecordL unknown sink\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+
+    switch (datapath->GetState())
+    {
+        case EClosing:
+            //Close command already in progress
+            if (datapath->GetCmdInfo())
+            {
+                return datapath->GetCmdInfo()->id;
+            }
+            //Already closing because of error or remote close
+            else
+            {
+                cmd = GetCmdInfoL();
+                cmd->type = PVT_COMMAND_STOP_RECORD;
+                cmd->id = iCommandId;
+                cmd->contextData = aContextData;
+
+                datapath->SetCmd(cmd);
+            }
+            break;
+
+        case EOpened:
+        case EOpening:
+        case EPaused:
+        case EPausing:
+        case EUnpausing:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_STOP_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+
+            datapath->SetCmd(cmd);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV324m2Way::StopRecordL - invalid rec path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::PauseRecord(PVMFNodeInterface& aSink,
+                                     OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::PauseRecordL state %d, rec state %d\n",
+                     iState, iRecordFileState));
+    CPV2WayRecDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    if ((iState != EConnected) ||
+            (iRecordFileState != File2WayInitialized))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PauseRecordL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iAudioDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::PauseRecordL audio sink path not open %d!\n",
+                             iAudioDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PauseRecordL audio rec path, state %d\n",
+                         iAudioRecDatapath->GetState()));
+        datapath = iAudioRecDatapath;
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iVideoDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::PauseRecordL video sink path not open %d!\n",
+                             iVideoDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PauseRecordL video rec path, state %d\n",
+                         iVideoRecDatapath->GetState()));
+        datapath = iVideoRecDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PauseRecordL unknown sink\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EOpened:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_PAUSE_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+            break;
+
+        case EPaused:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_PAUSE_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EPausing:
+            return datapath->GetCmdInfo()->id;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::PauseRecordL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::ResumeRecord(PVMFNodeInterface& aSink,
+                                      OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResumeRecordL state %d, rec state %d\n",
+                     iState, iRecordFileState));
+    CPV2WayRecDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    if ((iState != EConnected) ||
+            (iRecordFileState != File2WayInitialized))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ResumeRecordL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iAudioDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResumeRecordL audio sink path not open %d!\n",
+                             iAudioDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::ResumeRecordL audio rec path, state %d\n",
+                         iAudioRecDatapath->GetState()));
+        datapath = iAudioRecDatapath;
+    }
+    else if (iVideoDecDatapath && iVideoDecDatapath->IsNodeInDatapath(&aSink))
+    {
+        if (iVideoDecDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResumeRecordL video sink path not open %d!\n",
+                             iVideoDecDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::ResumeRecordL video rec path, state %d\n",
+                         iVideoRecDatapath->GetState()));
+        datapath = iVideoRecDatapath;
+
+#ifndef NO_2WAY_324
+        //Request an Iframe
+        if (iTSCInterface != NULL)
+            iTSCInterface->RequestFrameUpdate(*iVideoDecDatapath->GetTSCPort());
+#endif
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ResumeRecordL unknown sink\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EPaused:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_RESUME_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+            break;
+
+        case EOpened:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_RESUME_RECORD;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EUnpausing:
+            return datapath->GetCmdInfo()->id;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResumeRecordL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+
+PVCommandId CPV324m2Way::AddPreviewSink(PVMFNodeInterface& aDataSource,
+                                        PVMFNodeInterface &aPreview,
+                                        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::AddPreviewSinkL state %d\n", iState));
+    PVMFNodeCapability capability, previewCap;
+//	uint32 i, j;
+//	TPV2WayCmdInfo *cmd;
+//	CPVDatapathNode node;
+//	bool previewFormatMatch = false;
+
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    if (iState != EConnected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddPreviewSinkL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (aDataSource.GetCapability(capability) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddPreviewSinkL - unable to get source capability"));
+        OSCL_LEAVE(PVMFFailure);
+    }
+
+    if (aPreview.GetCapability(previewCap) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddPreviewSinkL - unable to get preview capability"));
+        OSCL_LEAVE(PVMFFailure);
+    }
+
+    for (i = 0; i < capability.iOutputFormatCapability.size() && !previewFormatMatch; i++)
+    {
+        for (j = 0; j < previewCap.iInputFormatCapability.size() && !previewFormatMatch; j++)
+        {
+            if (capability.iOutputFormatCapability[i] ==
+                    previewCap.iInputFormatCapability[j])
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "CPV324m2Way::AddPreviewSinkL format match %d\n",
+                                 capability.iOutputFormatCapability[i]));
+                previewFormatMatch = true;
+            }
+        }
+    }
+
+    if (!previewFormatMatch)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddPreviewSinkL - no preview format match"));
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+
+    if (iAudioEncDatapath && iAudioEncDatapath->IsNodeInDatapath(&aDataSource))
+    {
+        if (iAudioEncDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::AddPreviewSinkL audio source path not open %d!\n",
+                             iAudioEncDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        if (iAudioPreviewDatapath->GetState() == EClosed)
+        {
+            //Set up audio preview datapath
+
+            cmd = GetCmdInfoL();
+
+            //Set up video preview datapath
+            //Add preview sink to a datapath
+            aPreview.SetCmdStatusObserver(*this);
+            aPreview.SetInfoEventObserver(*this, (OsclAny*) &aPreview);
+            aPreview.SetErrorEventObserver(*this, (OsclAny*) &aPreview);
+            aPreview.ThreadLogon();
+
+            //Get the codec type
+            iAudioEncDatapath->GetSrcPort()->Query(node.iOutputPort.iProperty);
+
+            //Add audio src splitter node
+            node.iNode = iAudioSrcSplitterNode;
+            node.iConfigure = NULL;
+            node.iLoggoffOnReset = false;
+            node.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            node.iInputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            node.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+            node.iOutputPort.iPortSetType = EUserDefined;
+            node.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            iAudioPreviewDatapath->AddNode(node);
+
+            //Add preview sink node
+            node.iNode = &aPreview;
+            node.iConfigure = NULL;
+            node.iCanNodePause = false;
+            node.iLoggoffOnReset = true;
+            node.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            node.iInputPort.iPortSetType = EConnectedPortFormat;
+            node.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            node.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            iAudioPreviewDatapath->AddNode(node);
+
+            cmd->type = PVT_COMMAND_ADD_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+
+            iAudioPreviewDatapath->SetCmd(cmd);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::AddPreviewSinkL, invalid preview state %d!\n",
+                             iAudioPreviewDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+    }
+    else if (iVideoEncDatapath->IsNodeInDatapath(&aDataSource))
+    {
+        if (iVideoEncDatapath->GetState() != EOpened)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::AddPreviewSinkL video source path not open %d!\n",
+                             iVideoEncDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+
+        if (iVideoPreviewDatapath->GetState() == EClosed)
+        {
+            cmd = GetCmdInfoL();
+
+            //Set up video preview datapath
+            //Add preview sink to a datapath
+            aPreview.SetCmdStatusObserver(*this);
+            aPreview.SetInfoEventObserver(*this, (OsclAny*) &aPreview);
+            aPreview.SetErrorEventObserver(*this, (OsclAny*) &aPreview);
+            aPreview.ThreadLogon();
+
+            //Get the codec type
+            iVideoEncDatapath->GetSrcPort()->Query(node.iOutputPort.iProperty);
+
+            //Add video src splitter node
+            node.iNode = iVideoSrcSplitterNode;
+            node.iConfigure = NULL;
+            node.iLoggoffOnReset = false;
+            node.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            node.iInputPort.iPortTag = PV2WAY_UNKNOWN_PORT;
+            node.iOutputPort.iRequestPortState = EPVMFNodeStarted;
+            node.iOutputPort.iPortSetType = EUserDefined;
+            node.iOutputPort.iPortTag = PV2WAY_OUT_PORT;
+            iVideoPreviewDatapath->AddNode(node);
+
+            //Add preview sink node
+            node.iNode = &aPreview;
+            node.iConfigure = NULL;
+            node.iCanNodePause = false;
+            node.iLoggoffOnReset = true;
+            node.iInputPort.iRequestPortState = EPVMFNodeInitialized;
+            node.iInputPort.iPortSetType = EConnectedPortFormat;
+            node.iInputPort.iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            node.iInputPort.iPortTag = PV2WAY_IN_PORT;
+            iVideoPreviewDatapath->AddNode(node);
+
+            cmd->type = PVT_COMMAND_ADD_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+
+            iVideoPreviewDatapath->SetCmd(cmd);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::AddPreviewSinkL, invalid preview state %d!\n",
+                             iVideoPreviewDatapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::AddPreviewSinkL unknown source!\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::RemovePreviewSink(PVMFNodeInterface &aPreview,
+        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemovePreviewSinkL state %d\n", iState));
+    CPV2WayPreviewDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    if (iState != EConnected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::RemovePreviewSinkL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioPreviewDatapath->IsNodeInDatapath(&aPreview))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::RemovePreviewSinkL audio preview, state %d\n",
+                         iAudioPreviewDatapath->GetState()));
+        datapath = iAudioPreviewDatapath;
+    }
+    else if (iVideoPreviewDatapath->IsNodeInDatapath(&aPreview))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::RemovePreviewSinkL video preview, state %d\n",
+                         iVideoPreviewDatapath->GetState()));
+        datapath = iVideoPreviewDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::RemovePreviewSinkL unknown preview sink\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+
+    switch (datapath->GetState())
+    {
+        case EClosing:
+            //Close command already in progress
+            if (datapath->GetCmdInfo())
+            {
+                return datapath->GetCmdInfo()->id;
+            }
+            //Already closing because of error or remote close
+            else
+            {
+                cmd = GetCmdInfoL();
+                cmd->type = PVT_COMMAND_REMOVE_PREVIEW_SINK;
+                cmd->id = iCommandId;
+                cmd->contextData = aContextData;
+
+                datapath->SetCmd(cmd);
+            }
+            break;
+
+        case EOpened:
+        case EOpening:
+        case EPaused:
+        case EPausing:
+        case EUnpausing:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_REMOVE_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+
+            datapath->SetCmd(cmd);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::RemovePreviewSinkL - invalid preview path state %d\n",
+                             datapath->GetState()));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::PausePreviewSink(PVMFNodeInterface &aPreview,
+        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::PausePreviewSinkL state %d\n", iState));
+    CPV2WayPreviewDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    if (iState != EConnected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PausePreviewSinkL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioPreviewDatapath->IsNodeInDatapath(&aPreview))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PausePreviewSinkL audio preview path, state %d\n",
+                         iAudioPreviewDatapath->GetState()));
+        datapath = iAudioPreviewDatapath;
+    }
+    else if (iVideoPreviewDatapath->IsNodeInDatapath(&aPreview))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::PausePreviewSinkL video preview path, state %d\n",
+                         iVideoPreviewDatapath->GetState()));
+        datapath = iVideoPreviewDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PausePreviewSinkL unknown preview sink\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EOpened:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_PAUSE_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+            break;
+
+        case EPaused:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_PAUSE_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EPausing:
+            return datapath->GetCmdInfo()->id;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::PausePreviewSinkL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::ResumePreviewSink(PVMFNodeInterface &aPreview,
+        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResumePreviewSinkL state %d\n", iState));
+    CPV2WayPreviewDatapath *datapath = NULL;
+    TPV2WayCmdInfo *cmd;
+
+    if (iState != EConnected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ResumePreviewSinkL invalid state!\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iAudioPreviewDatapath->IsNodeInDatapath(&aPreview))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::ResumePreviewSinkL audio preview path, state %d\n",
+                         iAudioPreviewDatapath->GetState()));
+        datapath = iAudioPreviewDatapath;
+    }
+    else if (iVideoPreviewDatapath->IsNodeInDatapath(&aPreview))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::ResumePreviewSinkL video preview path, state %d\n",
+                         iVideoPreviewDatapath->GetState()));
+        datapath = iVideoPreviewDatapath;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ResumePreviewSinkL unknown preview sink\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    switch (datapath->GetState())
+    {
+        case EPaused:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_RESUME_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            datapath->SetCmd(cmd);
+            break;
+
+        case EOpened:
+            cmd = GetCmdInfoL();
+            cmd->type = PVT_COMMAND_RESUME_PREVIEW_SINK;
+            cmd->id = iCommandId;
+            cmd->contextData = aContextData;
+            cmd->status = PVMFSuccess;
+            Dispatch(cmd);
+            break;
+
+        case EUnpausing:
+            return datapath->GetCmdInfo()->id;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResumePreviewSinkL - invalid path state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::InitPlayFile(const OSCL_wString& aFileName,
+                                      OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::InitPlayFileL state %d, pff state %d\n",
+                     iState,
+                     iPlayFileState));
+
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::InitPlayFileL invalid terminal state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            break;
+    }
+
+    switch (iPlayFileState)
+    {
+        case File2WayIdle:
+            iPlayFilename = aFileName;
+            iPlayFromFileNode->SetSourceFile(iPlayFilename, DEFAULT_PLAY_FROM_FILE_TYPE);
+            iPlayFromFileNode->SetAudioSinkFormat(DEFAULT_PLAY_FROM_FILE_AUDIO);
+            iPlayFromFileNode->SetVideoSinkFormat(DEFAULT_PLAY_FROM_FILE_VIDEO);
+
+            iInitPlayFileInfo = GetCmdInfoL();
+
+            iInitPlayFileInfo->type = PVT_COMMAND_INIT_PLAY_FILE;
+            iInitPlayFileInfo->id = iCommandId;
+            iInitPlayFileInfo->contextData = aContextData;
+
+            iPlayFileState = File2WayInitializing;
+            CheckPlayFileState();
+            break;
+
+        case File2WayInitializing:
+            if (iInitPlayFileInfo)
+            {
+                return iInitPlayFileInfo->id;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::InitPlayFileL no init play info!!\n"));
+                OSCL_LEAVE(PVMFFailure);
+            }
+            break;
+
+        case File2WayInitialized:
+            iInitPlayFileInfo = GetCmdInfoL();
+            iInitPlayFileInfo->type = PVT_COMMAND_INIT_PLAY_FILE;
+            iInitPlayFileInfo->id = iCommandId;
+            iInitPlayFileInfo->contextData = aContextData;
+            iInitPlayFileInfo->status = PVMFSuccess;
+            Dispatch(iInitPlayFileInfo);
+            iInitPlayFileInfo = NULL;
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::InitPlayFileL invalid pff state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::ResetPlayFile(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResetPlayFileL state %d, pff state %d\n",
+                     iState,
+                     iPlayFileState));
+
+
+    switch (iState)
+    {
+        case EIdle:
+        case EInitializing:
+        case EResetting:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetPlayFileL invalid terminal state!\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+
+        default:
+            break;
+    }
+
+    switch (iPlayFileState)
+    {
+        case File2WayIdle:
+            iResetPlayFileInfo = GetCmdInfoL();
+            iResetPlayFileInfo->type = PVT_COMMAND_RESET_PLAY_FILE;
+            iResetPlayFileInfo->id = iCommandId;
+            iResetPlayFileInfo->contextData = aContextData;
+            iResetPlayFileInfo->status = PVMFSuccess;
+            Dispatch(iResetPlayFileInfo);
+            iResetPlayFileInfo = NULL;
+            break;
+
+        case File2WayInitialized:
+            iResetPlayFileInfo = GetCmdInfoL();
+            iResetPlayFileInfo->type = PVT_COMMAND_RESET_PLAY_FILE;
+            iResetPlayFileInfo->id = iCommandId;
+            iResetPlayFileInfo->contextData = aContextData;
+
+            InitiateResetPlayFile();
+            break;
+
+        case File2WayResetting:
+            if (iResetPlayFileInfo)
+            {
+                return iResetPlayFileInfo->id;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::ResetPlayFileL no reset play info!!\n"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResetPlayFileL invalid pff state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::UsePlayFileAsSource(bool aUsePlayFile,
+        OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::UsePlayFileAsSourceL state %d, use play file %d\n",
+                     iState, aUsePlayFile));
+
+    TPV2WayCmdInfo *info;
+
+    if (iPlayFileState != File2WayInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::UsePlayFileAsSourceL invalid pff state\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    info = GetCmdInfoL();
+    info->type = PVT_COMMAND_USE_PLAY_FILE;
+    info->id = iCommandId;
+    info->contextData = aContextData;
+
+    //Value already set.
+    if (iUsePlayFileAsSource == aUsePlayFile)
+    {
+        info->status = PVMFSuccess;
+    }
+    else
+    {
+        //Use play file as data source
+        if (iAudioEncDatapath->GetState() == EOpened)
+        {
+            iAudioEncDatapath->UseFilePlayPort(aUsePlayFile);
+        }
+
+        if (iVideoEncDatapath->GetState() == EOpened)
+        {
+            iVideoEncDatapath->UseFilePlayPort(aUsePlayFile);
+        }
+
+        iUsePlayFileAsSource = aUsePlayFile;
+    }
+
+    Dispatch(info);
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::StartPlay(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::StartPlayL state %d, pff state %d, cmd %x\n",
+                     iState, iPlayFileState, iPlayFileCmdInfo));
+
+//	int32 error;
+//	TPV2WayCmdInfo *info;
+
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    if (iPlayFileState != File2WayInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::StartPlayL invalid pff state\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::StartPlayL node state %d\n",
+                     iPlayFromFileNode->GetState()));
+
+    switch (iPlayFromFileNode->GetState())
+    {
+        case EPVMFNodeInitialized:
+        case EPVMFNodeStopped:
+            if (iPlayFileCmdInfo)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::StartPlayL node initialized, but start command issued, type %d, id %d\n", iPlayFileCmdInfo->type, iPlayFileCmdInfo->id));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            else
+            {
+                iPlayFileCmdInfo = GetCmdInfoL();
+                iPlayFileCmdInfo->type = PVT_COMMAND_START_PLAY;
+                iPlayFileCmdInfo->id = iCommandId;
+                iPlayFileCmdInfo->contextData = aContextData;
+
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_START,
+                                             iPlayFromFileNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::StartPlayL unable to start pff node\n"));
+                                     FreeCmdInfo(iPlayFileCmdInfo);
+                                     iPlayFileCmdInfo = NULL;
+                                     OSCL_LEAVE(error));
+            }
+            break;
+
+        case EPVMFNodeStart:
+            if (iPlayFileCmdInfo)
+            {
+                if (iPlayFileCmdInfo->type == PVT_COMMAND_START_PLAY)
+                {
+                    return iPlayFileCmdInfo->id;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::StartPlayL node starting, but start command not issued, type %d, id %d\n", iPlayFileCmdInfo->type, iPlayFileCmdInfo->id));
+                    OSCL_LEAVE(PVMFErrBusy);
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::StartPlayL node starting, no start info\n"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+
+            break;
+
+        case EPVMFNodeStarted:
+            info = GetCmdInfoL();
+            info->type = PVT_COMMAND_START_PLAY;
+            info->id = iCommandId;
+            info->contextData = aContextData;
+            info->status = PVMFSuccess;
+            Dispatch(info);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StartPlayL invalid node state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::StopPlay(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::StopPlayL state %d, pff state %d\n",
+                     iState, iPlayFileState));
+
+//	int32 error;
+//	TPV2WayCmdInfo *info;
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    if (iPlayFileState != File2WayInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::StopPlayL invalid pff state\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::StopPlayL node state %d\n",
+                     iPlayFromFileNode->GetState()));
+
+    switch (iPlayFromFileNode->GetState())
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            if (iPlayFileCmdInfo)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::StopPlayL node initialized, but stop command issued, type %d, id %d\n", iPlayFileCmdInfo->type, iPlayFileCmdInfo->id));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            else
+            {
+                iPlayFileCmdInfo = GetCmdInfoL();
+                iPlayFileCmdInfo->type = PVT_COMMAND_STOP_PLAY;
+                iPlayFileCmdInfo->id = iCommandId;
+                iPlayFileCmdInfo->contextData = aContextData;
+
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_STOP,
+                                             iPlayFromFileNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::StopPlayL unable to stop pff node\n"));
+                                     FreeCmdInfo(iPlayFileCmdInfo);
+                                     iPlayFileCmdInfo = NULL;
+                                     OSCL_LEAVE(error));
+            }
+            break;
+
+        case EPVMFNodeStop:
+            if (iPlayFileCmdInfo)
+            {
+                if (iPlayFileCmdInfo->type == PVT_COMMAND_STOP_PLAY)
+                {
+                    return iPlayFileCmdInfo->id;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::StopPlayL node stopping, but stop command not issued, type %d, id %d\n", iPlayFileCmdInfo->type, iPlayFileCmdInfo->id));
+                    OSCL_LEAVE(PVMFErrBusy);
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::StopPlayL node stopping, no stop info\n"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+
+            break;
+
+        case EPVMFNodeInitialized:
+            info = GetCmdInfoL();
+            info->type = PVT_COMMAND_STOP_PLAY;
+            info->id = iCommandId;
+            info->contextData = aContextData;
+            info->status = PVMFSuccess;
+            Dispatch(info);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::StopPlayL invalid node state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::PausePlay(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::PausePlayL state %d, pff state %d\n", iState, iPlayFileState));
+
+//	int32 error;
+//	TPV2WayCmdInfo *info;
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    if (iPlayFileState != File2WayInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PausePlayL invalid pff state\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iPlayFileCmdInfo && (iPlayFileCmdInfo->type != PVT_COMMAND_PAUSE_PLAY))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::PausePlayL another play command in progress\n"));
+        OSCL_LEAVE(PVMFErrBusy);
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::PausePlayL node state %d\n",
+                     iPlayFromFileNode->GetState()));
+
+    switch (iPlayFromFileNode->GetState())
+    {
+        case EPVMFNodeStarted:
+            iPlayFileCmdInfo = GetCmdInfoL();
+            iPlayFileCmdInfo->type = PVT_COMMAND_PAUSE_PLAY;
+            iPlayFileCmdInfo->id = iCommandId;
+            iPlayFileCmdInfo->contextData = aContextData;
+
+            OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_PAUSE,
+                                         iPlayFromFileNode, this));
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::PausePlayL unable to pause pff node\n"));
+                                 FreeCmdInfo(iPlayFileCmdInfo);
+                                 iPlayFileCmdInfo = NULL;
+                                 OSCL_LEAVE(error));
+            break;
+
+        case EPVMFNodePause:
+            if (iPlayFileCmdInfo)
+            {
+                return iPlayFileCmdInfo->id;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::PausePlayL node pausing, but no command issued!\n"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            break;
+
+        case EPVMFNodePaused:
+            info = GetCmdInfoL();
+            info->type = PVT_COMMAND_PAUSE_PLAY;
+            info->id = iCommandId;
+            info->contextData = aContextData;
+            info->status = PVMFSuccess;
+            Dispatch(info);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::PausePlayL invalid node state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+
+PVCommandId CPV324m2Way::ResumePlay(OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResumePlayL state %d, pff state %d\n", iState, iPlayFileState));
+
+//	int32 error;
+//	TPV2WayCmdInfo *info;
+
+#if 1
+    OSCL_LEAVE(PVMFErrNotSupported);
+#else
+    if (iPlayFileState != File2WayInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ResumePlayL invalid pff state\n"));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    if (iPlayFileCmdInfo && (iPlayFileCmdInfo->type != PVT_COMMAND_RESUME_PLAY))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ResumePlayL another play command in progress\n"));
+        OSCL_LEAVE(PVMFErrBusy);
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ResumePlayL node state %d\n",
+                     iPlayFromFileNode->GetState()));
+
+    switch (iPlayFromFileNode->GetState())
+    {
+        case EPVMFNodePaused:
+            iPlayFileCmdInfo = GetCmdInfoL();
+            iPlayFileCmdInfo->type = PVT_COMMAND_RESUME_PLAY;
+            iPlayFileCmdInfo->id = iCommandId;
+            iPlayFileCmdInfo->contextData = aContextData;
+
+            OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_START,
+                                         iPlayFromFileNode, this));
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::ResumePlayL unable to resume pff node\n"));
+                                 FreeCmdInfo(iPlayFileCmdInfo);
+                                 iPlayFileCmdInfo = NULL;
+                                 OSCL_LEAVE(error));
+            break;
+
+        case EPVMFNodeStart:
+            if (iPlayFileCmdInfo)
+            {
+                return iPlayFileCmdInfo->id;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::ResumePlayL node resuming, but no command issued!\n"));
+                OSCL_LEAVE(PVMFErrBusy);
+            }
+            break;
+
+        case EPVMFNodeStarted:
+            info = GetCmdInfoL();
+            info->type = PVT_COMMAND_RESUME_PLAY;
+            info->id = iCommandId;
+            info->contextData = aContextData;
+            info->status = PVMFSuccess;
+            Dispatch(info);
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ResumePlayL invalid node state\n"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+#endif
+    return iCommandId++;
+}
+#endif
+
+void CPV324m2Way::ConstructL(PVMFNodeInterface* aTsc,
+                             TPVTerminalType aType,
+                             PVCommandStatusObserver* aCmdStatusObserver,
+                             PVInformationalEventObserver *aInfoEventObserver,
+                             PVErrorEventObserver *aErrorEventObserver)
+{
+    OSCL_UNUSED_ARG(aTsc);
+
+    iTerminalType = aType;
+
+    /* Initialize the clock */
+    if (!iClock.SetClockTimebase(iTickCountTimeBase))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ConstructL: unable to initialize clock"));
+        OSCL_LEAVE(PVMFFailure);
+    }
+
+    FormatCapabilityInfo inFormat;
+    inFormat.dir = INCOMING;
+
+    /* Add user input types */
+    inFormat.format = PVMF_MIME_USERINPUT_DTMF;
+    iIncomingUserInputFormats.push_back(inFormat);
+    inFormat.format = PVMF_MIME_USERINPUT_IA5_STRING;
+    iIncomingUserInputFormats.push_back(inFormat);
+    inFormat.format = PVMF_MIME_USERINPUT_BASIC_STRING;
+    iIncomingUserInputFormats.push_back(inFormat);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::ConstructL (%x, %x, %x, %x)",
+                     aTsc, aCmdStatusObserver,
+                     aInfoEventObserver, aErrorEventObserver));
+    iMuxDatapath = CPV2WayMuxDatapath::NewL(iLogger, PVMF_MIME_H223, this);
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    iRecFilename = DEFAULT_RECORDED_CALL_FILENAME;
+
+    iAudioRecDatapath = CPV2WayRecDatapath::NewL(iLogger, PVMF_COMPRESSED_AUDIO_FORMAT,
+                        *iAudioDecDatapath, this);
+    iVideoRecDatapath = CPV2WayRecDatapath::NewL(iLogger, PVMF_COMPRESSED_VIDEO_FORMAT,
+                        *iVideoDecDatapath, this);
+
+    //Set up recording datapath dependencies
+    iAudioDecDatapath->AddDependentDatapath(*iAudioRecDatapath);
+    iVideoDecDatapath->AddDependentDatapath(*iVideoRecDatapath);
+    iAudioRecDatapath->AddParentDatapath(*iAudioDecDatapath);
+    iVideoRecDatapath->AddParentDatapath(*iVideoDecDatapath);
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    iAudioPreviewDatapath = CPV2WayPreviewDatapath::NewL(iLogger,
+                            PVMF_COMPRESSED_AUDIO_FORMAT, this);
+    iVideoPreviewDatapath = CPV2WayPreviewDatapath::NewL(iLogger,
+                            PVMF_COMPRESSED_VIDEO_FORMAT, this);
+
+    //Set up preview sink datapath dependencies
+    iAudioEncDatapath->AddDependentDatapath(*iAudioPreviewDatapath);
+    iVideoEncDatapath->AddDependentDatapath(*iVideoPreviewDatapath);
+    iAudioPreviewDatapath->AddParentDatapath(*iAudioEncDatapath);
+    iVideoPreviewDatapath->AddParentDatapath(*iVideoEncDatapath);
+#endif
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "Full pv_2way_engine\n"));
+#ifdef PV_DISABLE_VIDRECNODE
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "VidRec node disabled\n"));
+#else
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "VidRec node enabled\n"));
+#endif
+
+#ifdef PV_DISABLE_DEVSOUNDNODES
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "DevSound nodes disabled\n"));
+#else
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "DevSound nodes enabled\n"));
+#endif
+
+    SetDefaults();
+    iCmdStatusObserver = aCmdStatusObserver;
+    iInfoEventObserver = aInfoEventObserver;
+    iErrorEventObserver = aErrorEventObserver;
+
+    iPendingNotifications.reserve(MAX_PENDING_2WAY_COMMANDS + MAX_PENDING_2WAY_EVENTS);
+    iPendingNodeCmdInfo.reserve(MAX_PENDING_2WAY_NODE_COMMANDS);
+    iIncomingChannelParams.reserve(MAX_LOGICAL_CHANNEL_PARAMS);
+    iOutgoingChannelParams.reserve(MAX_LOGICAL_CHANNEL_PARAMS);
+
+    int32 i;
+    for (i = 0; i < MAX_PENDING_2WAY_COMMANDS; i++)
+    {
+        iFreeCmdInfo.push_back(&iCmdInfo[i]);
+    }
+
+    for (i = 0; i < MAX_PENDING_2WAY_EVENTS; i++)
+    {
+        iFreeEventInfo.push_back(&iEventInfo[i]);
+    }
+
+    for (i = 0; i < MAX_PENDING_2WAY_NODE_COMMANDS; i++)
+    {
+        iFreeNodeCmdInfo.push_back(&iNodeCmdInfo[i]);
+    }
+
+    iSourceNodes.reserve(3);
+    iSinkNodes.reserve(3);
+
+    AddToScheduler();
+
+    PreInit();
+
+    return;
+}
+
+void CPV324m2Way::SetDefaults()
+{
+    uint32 i;
+    SetState(EIdle);
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    if (iPlayFromFileNode.iNode)
+    {
+        iPlayFromFileNode.iNode->ThreadLogoff();
+        OSCL_DELETE(iPlayFromFileNode.iNode);
+        iPlayFromFileNode.Clear();;
+    }
+
+    if (iVideoSrcSplitterNode.iNode)
+    {
+        iVideoSrcSplitterNode.iNode->ThreadLogoff();
+        OSCL_DELETE(iVideoSrcSplitterNode.iNode);
+        iVideoSrcSplitterNode = NULL;
+    }
+
+    if (iAudioSrcSplitterNode)
+    {
+        iAudioSrcSplitterNode->ThreadLogoff();
+        OSCL_DELETE(iAudioSrcSplitterNode);
+        iAudioSrcSplitterNode = NULL;
+    }
+#endif
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    if (iFFComposerNode)
+    {
+        iFFComposerNode->ThreadLogoff();
+        PVMp4FFComposerNodeFactory::DeleteMp4FFComposer(iFFComposerNode);
+        iFFComposerNode = NULL;
+    }
+
+    if (iVideoDecSplitterNode)
+    {
+        iVideoDecSplitterNode->ThreadLogoff();
+        OSCL_DELETE(iVideoDecSplitterNode);
+        iVideoDecSplitterNode = NULL;
+    }
+#endif
+
+    if (iVideoParserNode.iNode)
+    {
+        iVideoParserNode.iNode->ThreadLogoff();
+        OSCL_DELETE(iVideoParserNode.iNode);
+        iVideoParserNode.Clear();
+    }
+
+    if (iVideoDecNode.iNode)
+    {
+        iVideoDecNode.iNode->ThreadLogoff();
+
+        if (iIncomingVideoCodecType != PV_INVALID_CODEC_TYPE)
+        {
+
+            switch (iIncomingVideoCodecType)
+            {
+                case PV_VID_TYPE_H263:
+#ifdef PV2WAY_USE_OMX_H263_DECODER
+                    DELETE_OMX_VIDEO_DEC_NODE(iVideoDecNode.iNode);
+#else
+                    DELETE_VIDEO_DEC_NODE(iVideoDecNode.iNode);
+#endif // PV2WAY_USE_OMX_H263_DECODER
+                    break;
+                case PV_VID_TYPE_MPEG4:
+#ifdef PV2WAY_USE_OMX_MPEG4_DECODER
+                    DELETE_OMX_VIDEO_DEC_NODE(iVideoDecNode.iNode);
+#else
+                    DELETE_VIDEO_DEC_NODE(iVideoDecNode.iNode);
+#endif // PV2WAY_USE_OMX_MPEG4_DECODER
+                    break;
+                default:
+                    //DELETE_VIDEO_DEC_NODE(iVideoDecNode.iNode);
+                    OSCL_ASSERT(0);
+                    break;
+            }
+
+
+            iIncomingVideoCodecType = PV_INVALID_CODEC_TYPE;
+        }
+
+        iVideoDecNode.Clear();
+    }
+
+    if (iAudioDecNode.iNode)
+    {
+        iAudioDecNode.iNode->ThreadLogoff();
+#ifdef PV2WAY_USE_OMX_AMR_DECODER
+        DELETE_OMX_AUDIO_DEC_NODE(iAudioDecNode.iNode);
+#else
+        DELETE_AUDIO_DEC_NODE(iAudioDecNode.iNode);
+#endif // PV2WAY_USE_OMX_AMR_DECODER
+
+        iAudioDecNode.Clear();
+    }
+
+    if (iTscNode.iNode)
+    {
+        iTscNode.iNode->ThreadLogoff();
+    }
+
+    if (iAudioEncNode.iNode)
+    {
+        iAudioEncNode.iNode->ThreadLogoff();
+        if (iAudioEncNodeInterface.iInterface)
+            iAudioEncNodeInterface.iInterface->removeRef();
+#ifdef PV2WAY_USE_OMX_AMR_ENCODER
+        DELETE_OMX_ENC_NODE(iAudioEncNode.iNode);
+#else
+        DELETE_AUDIO_ENC_NODE(iAudioEncNode.iNode);
+#endif
+        iAudioEncNode.Clear() ;
+        iAudioEncNodeInterface.Reset();
+    }
+
+    ClearVideoEncNode();
+
+    if (iCommNode.iNode)
+    {
+        iCommNode.iNode->ThreadLogoff();
+        iCommNode.Clear();
+    }
+
+    iFormatCapability.clear();
+    iIncomingAudioCodecs.clear();
+    iOutgoingAudioCodecs.clear();
+    iIncomingVideoCodecs.clear();
+    iOutgoingVideoCodecs.clear();
+
+    /* Stop the clock */
+    iClock.Stop();
+
+    /* Delete the list of sink/source nodes */
+    for (i = 0;i < iSourceNodes.size();i++)
+    {
+        TPV2WayNode* lNode = iSourceNodes[i];
+        OSCL_DELETE(lNode);
+        iSourceNodes[i] = 0;
+    }
+    iSourceNodes.clear();
+    iSourceNodes.destroy();
+
+    for (i = 0;i < iSinkNodes.size();i++)
+    {
+        TPV2WayNode* lNode = iSinkNodes[i] ;
+        OSCL_DELETE(lNode);
+        iSinkNodes[i] = 0;
+    }
+    iSinkNodes.clear();
+    iSinkNodes.destroy();
+    iAddDataSourceVideoCmd = NULL;
+    return;
+}
+
+void CPV324m2Way::DoCancel()
+{
+
+}
+
+void CPV324m2Way::Run()
+{
+    int32 error;
+    TPV2WayCmdInfo* cmd = NULL;
+    TPV2WayEventInfo* event = NULL;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::Run state %d, number of notifications pending %d\n",
+                     iState, iPendingNotifications.size()));
+
+    while (!iPendingNotifications.empty())
+    {
+        if (iPendingNotifications[0]->notificationType ==
+                TPV2WayNotificationInfo::EPV2WayCommandType)
+        {
+            cmd = (TPV2WayCmdInfo *) iPendingNotifications[0];
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                            (0, "CPV324m2Way::Run Calling CommandCompleted CmdType %d CmdId %d CmdStatus %d\n",
+                             cmd->type, cmd->id, cmd->status));
+
+            switch (cmd->type)
+            {
+                case PVT_COMMAND_INIT:
+                    if ((cmd->status != PVMFSuccess) &&
+                            (cmd->status != PVMFErrCancelled))
+                    {
+                        SetDefaults();
+                    }
+                    break;
+
+                case PVT_COMMAND_RESET:
+                    RemoveAudioEncPath();
+                    RemoveVideoEncPath();
+                    RemoveAudioDecPath();
+                    RemoveVideoDecPath();
+                    SetDefaults();
+                    break;
+
+                case PVT_COMMAND_CONNECT:
+                    if ((cmd->status != PVMFSuccess) &&
+                            (cmd->status != PVMFErrCancelled))
+                    {
+                        iMuxDatapath->ResetDatapath();
+                        iCommNode.iNode->ThreadLogoff();
+                        iCommNode.Clear();
+                    }
+                    break;
+
+                case PVT_COMMAND_DISCONNECT:
+                    iMuxDatapath->ResetDatapath();
+                    iCommNode.iNode->ThreadLogoff();
+                    iCommNode.Clear();
+                    break;
+
+                case PVT_COMMAND_ADD_DATA_SOURCE:
+                    if (cmd->status == PVMFSuccess)
+                    {
+                        if (iAudioEncDatapath && (iAudioEncDatapath->GetState() == EOpened) &&
+                                iVideoEncDatapath && (iVideoEncDatapath->GetState() == EOpened))
+                        {
+                            TSC_324m *tsc_node = (TSC_324m *)(iTscNode.iNode);
+                            tsc_node->SetSkewReference(iVideoEncDatapath->GetTSCPort(),
+                                                       iAudioEncDatapath->GetTSCPort());
+                        }
+                    }
+                    else
+                    {
+                        if (cmd->status != PVMFErrCancelled)
+                        {
+                            RemoveAudioEncPath();
+                            RemoveVideoEncPath();
+                        }
+                    }
+                    break;
+
+                case PVT_COMMAND_ADD_DATA_SINK:
+                    if ((cmd->status != PVMFSuccess) &&
+                            (cmd->status != PVMFErrCancelled))
+                    {
+                        RemoveAudioDecPath();
+                        RemoveVideoDecPath();
+                    }
+                    break;
+
+                case PVT_COMMAND_REMOVE_DATA_SOURCE:
+                    RemoveAudioEncPath();
+                    RemoveVideoEncPath();
+                    break;
+
+                case PVT_COMMAND_REMOVE_DATA_SINK:
+                    RemoveAudioDecPath();
+                    RemoveVideoDecPath();
+                    break;
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+                case PVT_COMMAND_START_RECORD:
+                    if ((cmd->status != PVMFSuccess) &&
+                            (cmd->status != PVMFErrCancelled))
+                    {
+                        RemoveAudioRecPath();
+                        RemoveVideoRecPath();
+                    }
+                    break;
+
+                case PVT_COMMAND_STOP_RECORD:
+                    RemoveAudioRecPath();
+                    RemoveVideoRecPath();
+                    break;
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+                case PVT_COMMAND_ADD_PREVIEW_SINK:
+                    if ((cmd->status != PVMFSuccess) &&
+                            (cmd->status != PVMFErrCancelled))
+                    {
+                        RemoveAudioPreviewPath();
+                        RemoveVideoPreviewPath();
+                    }
+                    break;
+
+                case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+                    RemoveAudioPreviewPath();
+                    RemoveVideoPreviewPath();
+                    break;
+
+#endif
+                case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+                    //Init cancelled
+                    if (iState == EIdle)
+                    {
+                        SetDefaults();
+                    }
+                    if (iState == ESetup)
+                    {
+                        if (iMuxDatapath->GetState() == EClosed)
+                        {
+                            iMuxDatapath->ResetDatapath();
+                            iCommNode.iNode->ThreadLogoff();
+                            iCommNode.Clear();
+                        }
+                    }
+                    break;
+
+                default:
+                    break;
+            }
+
+            {
+                PVCmdResponse resp(cmd->id, cmd->contextData, cmd->status, NULL, 0);
+                OSCL_TRY(error, iCmdStatusObserver->CommandCompleted(resp));
+                OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                     PVLOGMSG_ERR, (0, "CPV324m2Way::Run CommandCompletedL leave %d\n",
+                                                    error)));
+            }
+
+            iPendingNotifications.erase(iPendingNotifications.begin());
+            FreeCmdInfo(cmd);
+
+        }
+        else if (iPendingNotifications[0]->notificationType ==
+                 TPV2WayNotificationInfo::EPV2WayEventType)
+        {
+            event = (TPV2WayEventInfo *) iPendingNotifications[0];
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                            (0, "CPV324m2Way::Run Calling HandleInformationalEventL EventType %d\n",
+                             event->type));
+
+            switch (event->type)
+            {
+                case PVT_INDICATION_CLOSE_TRACK:
+                {
+                    TPVChannelId* id = (TPVChannelId*)(event->localBuffer + 4);
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                    (0, "CPV324m2Way::Run PVT_INDICATION_CLOSE_TRACK direction %d, channel id=%d",
+                                     event->localBuffer[0], *id));
+                    if (event->localBuffer[0] == INCOMING)
+                    {
+                        if (iAudioDecDatapath && (*id == iAudioDecDatapath->GetChannelId()))
+                        {
+                            RemoveAudioDecPath();
+                        }
+                        else if (iVideoDecDatapath && (*id == iVideoDecDatapath->GetChannelId()))
+                        {
+                            RemoveVideoDecPath();
+                        }
+                    }
+                    else if (event->localBuffer[0] == OUTGOING)
+                    {
+                        if (iAudioEncDatapath && (*id == iAudioEncDatapath->GetChannelId()))
+                        {
+                            RemoveAudioEncPath();
+                        }
+                        else if (iVideoEncDatapath && (*id == iVideoEncDatapath->GetChannelId()))
+                        {
+                            RemoveVideoEncPath();
+                        }
+                    }
+
+                    CheckState();
+                }
+                break;
+
+                case PVT_INDICATION_DISCONNECT:
+                    iMuxDatapath->ResetDatapath();
+                    iCommNode.Clear();
+                    break;
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+                case PVT_INDICATION_RECORDING_ERROR:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                    (0, "CPV324m2Way::Run PVT_INDICATION_RECORD_ERROR media %d\n",
+                                     event->localBuffer[0]));
+                    if (event->localBuffer[0] == PV_AUDIO)
+                    {
+                        RemoveAudioRecPath();
+                    }
+                    else
+                    {
+                        RemoveVideoRecPath();
+                    }
+                    break;
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+
+                case PVT_INDICATION_PREVIEW_ERROR:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                    (0, "CPV324m2Way::Run PVT_INDICATION_PREVIEW_ERROR media %d\n",
+                                     event->localBuffer[0]));
+                    if (event->localBuffer[0] == PV_AUDIO)
+                    {
+                        RemoveAudioPreviewPath();
+                    }
+                    else
+                    {
+                        RemoveVideoPreviewPath();
+                    }
+                    break;
+#endif
+                default:
+                    break;
+            }
+
+            {
+                PVAsyncInformationalEvent aEvent(event->type, event->exclusivePtr,
+                                                 &event->localBuffer[0], event->localBufferSize);
+                OSCL_TRY(error, iInfoEventObserver->HandleInformationalEvent(aEvent));
+                OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                     PVLOGMSG_ERR, (0, "CPV324m2Way::Run HandleInformationalEventL leave %d\n",
+                                                    error)));
+            }
+
+            iPendingNotifications.erase(iPendingNotifications.begin());
+            FreeEventInfo(event);
+        }
+    }
+}
+
+void CPV324m2Way::Dispatch(TPV2WayCmdInfo* aCmdInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::Dispatch Appending command to queue CmdType %d CmdId %d CmdStatus %d\n",
+                     aCmdInfo->type, aCmdInfo->id, aCmdInfo->status));
+    if (aCmdInfo->status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::Dispatch Command failed\n"));
+    }
+    iPendingNotifications.push_back(aCmdInfo);
+    RunIfNotReady();
+}
+
+void CPV324m2Way::Dispatch(TPV2WayEventInfo* aEventInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::Dispatch Appending event to queue event type %d\n",
+                     aEventInfo->type));
+
+    iPendingNotifications.push_back(aEventInfo);
+    RunIfNotReady();
+}
+
+
+bool CPV324m2Way::IsNodeInList(Oscl_Vector<TPV2WayNode*, OsclMemAllocator>& aList,
+                               PVMFNodeInterface* aNode)
+{
+    for (uint32 i = 0;i < aList.size();i++)
+    {
+        TPV2WayNode* lNode = aList[i];
+        if (lNode && lNode->iNode == aNode)
+            return true;
+    }
+    return false;
+}
+
+bool CPV324m2Way::IsSourceNode(PVMFNodeInterface* aNode)
+{
+    return IsNodeInList(iSourceNodes, aNode);
+}
+
+bool CPV324m2Way::IsSinkNode(PVMFNodeInterface* aNode)
+{
+    return IsNodeInList(iSinkNodes, aNode);
+}
+
+TPV2WayNode* CPV324m2Way::GetTPV2WayNode(Oscl_Vector<TPV2WayNode*, OsclMemAllocator>& aList,
+        PVMFNodeInterface* aNode)
+{
+    for (uint32 i = 0;i < aList.size();i++)
+    {
+        TPV2WayNode* lNode = aList[i];
+        if (lNode && lNode->iNode == aNode)
+            return lNode;
+    }
+    return NULL;
+}
+
+TPV2WayNode* CPV324m2Way::RemoveTPV2WayNode(Oscl_Vector<TPV2WayNode*, OsclMemAllocator>& aList,
+        PVMFNodeInterface* aNode)
+{
+    for (uint32 i = 0;i < aList.size();i++)
+    {
+        TPV2WayNode* lNode = aList[i];
+        if (lNode && lNode->iNode == aNode)
+        {
+            aList[i] = 0;
+            return lNode;
+        }
+    }
+    return NULL;
+}
+
+// from PVMFNodeCmdEventObserver
+void CPV324m2Way::NodeCommandCompleted(const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::NodeCommandCompleted status %d, context %x\n",
+                     aResponse.GetCmdStatus(), aResponse.GetContext()));
+
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::NodeCommandCompleted Command failed"));
+    }
+    CPV2WayNodeContextData *data = (CPV2WayNodeContextData *) aResponse.GetContext();
+    TPV2WayNodeCmdInfo *info = FindPendingNodeCmd(data->iNode, aResponse.GetCmdId());
+
+    data->iObserver->CommandHandler(info->type, aResponse);
+
+    // check if node cmd response requires engine cmd response
+    if (info->engineCmdInfo != NULL)
+    {
+        info->engineCmdInfo->status = aResponse.GetCmdStatus();
+        Dispatch(info->engineCmdInfo);
+    }
+
+    //Remove the command from the pending list.
+    RemovePendingNodeCmd(data->iNode, aResponse.GetCmdId());
+}
+
+// from PVMFNodeInfoEventObserver
+void CPV324m2Way::HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleNodeInformationalEvent type %d\n",
+                     aEvent.GetEventType()));
+
+    if (aEvent.GetContext() == iTscNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent tsc node\n"));
+        uint8 *buf = aEvent.GetLocalBuffer();
+        switch (buf[0])
+        {
+            case PV_H324COMPONENT_H223:
+                switch (buf[2])
+                {
+                    case INCOMING:
+                    {
+                        TPVChannelId id = CHANNEL_ID_UNKNOWN;
+                        if (buf[1] == PV_MUX_COMPONENT_LOGICAL_CHANNEL)
+                        {
+                            id = *((TPVChannelId*)(buf + 4));
+
+                            // See if error is in video datapath
+                            if (id == iVideoDecDatapath->GetChannelId())
+                            {
+                                // request for I-frame
+                                RequestRemoteIFrame(iVideoDecDatapath->GetTSCPort());
+                            }
+                        }
+                    }
+                    break;
+
+                    case OUTGOING:
+                        GenerateIFrame(iVideoEncDatapath->GetTSCPort());
+                        break;
+
+                    default:
+                        break;
+                }
+                break;
+
+            default:
+                break;
+        }
+    }
+    else if (aEvent.GetContext() == iCommNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent comm node\n"));
+    }
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    else if (aEvent.GetContext() == iFFComposerNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent ff composer node\n"));
+    }
+#endif
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    else if (aEvent.GetContext() == iPlayFromFileNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent playfromfile node\n"));
+        TPV2WayEventInfo* event = NULL;
+        switch (aEvent.GetEventType())
+        {
+            case PFF_NODE_INFO_EVENT_EOS_INFO_EVENT:
+                if (!GetEventInfo(event))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::HandleNodeInformationalEvent unable to notify app!\n"));
+                    return;
+                }
+                event->type = PVT_INDICATION_PLAY_EOS;
+                event->localBufferSize = 1;
+
+                //Check which port received the EOS.
+                if (iAudioPlayPort.GetPort() == aEvent.GetEventData())
+                {
+                    event->localBuffer[0] = PV_AUDIO;
+                    Dispatch(event);
+                }
+                else if (iVideoPlayPort.GetPort() == aEvent.GetEventData())
+                {
+                    event->localBuffer[0] = PV_VIDEO;
+                    Dispatch(event);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                                    (0, "CPV324m2Way::HandleNodeInformationalEvent unknown pff port for EOS %x\n",
+                                     aEvent.GetEventData()));
+                    FreeEventInfo(event);
+                }
+
+                break;
+
+            default:
+                break;
+        }
+
+    }
+#endif
+    else if (aEvent.GetContext() == iVideoDecNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent video dec node\n"));
+    }
+    else if (aEvent.GetContext() == iVideoParserNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent video parser node\n"));
+    }
+    else if (aEvent.GetContext() == iVideoEncNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent video encoder node\n"));
+    }
+    else if (iAudioEncDatapath && iAudioEncDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext()))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent audio enc datapath\n"));
+    }
+    else if (iAudioDecDatapath && iAudioDecDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext()))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent audio dec datapath\n"));
+        PVMFEventType event = aEvent.GetEventType();
+        if (event == PVMFInfoStartOfData)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::HandleNodeInformationalEvent audio dec datapath PVMFInfoStartOfData received, Clock started\n"));
+        }
+    }
+    else if ((iVideoEncDatapath != NULL) &&
+             (iVideoEncDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext())))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent video enc datapath\n"));
+    }
+    else if ((iVideoDecDatapath != NULL) &&
+             (iVideoDecDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext())))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent video dec datapath\n"));
+        PVMFEventType event = aEvent.GetEventType();
+        if (event == PVMFInfoStartOfData)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::HandleNodeInformationalEvent video dec datapath PVMFInfoStartOfData received, Clock started\n"));
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::HandleNodeInformationalEvent unknown node!"));
+    }
+}
+
+// from PVMFNodeErrorEventObserver
+void CPV324m2Way::HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleNodeErrorEvent type %d\n", aEvent.GetEventType()));
+
+    if (aEvent.GetContext() == iTscNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent tsc node\n"));
+
+        switch (iState)
+        {
+            case EDisconnecting:
+                CheckState();
+                break;
+
+            case EConnecting:
+            case EConnected:
+                //InitiateDisconnect();
+                break;
+
+            default:
+                break;
+        }
+    }
+    else if (aEvent.GetContext() == iCommNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent comm node\n"));
+        switch (iState)
+        {
+            case EDisconnecting:
+                CheckState();
+                break;
+
+            case EConnecting:
+            case EConnected:
+                InitiateDisconnect();
+                break;
+
+            default:
+                break;
+        }
+    }
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    else if (aEvent.GetContext() == iFFComposerNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent ff composer node state %d\n",
+                         iRecordFileState));
+        switch (iRecordFileState)
+        {
+            case File2WayResetting:
+                CheckRecordFileState();
+                break;
+
+            case File2WayInitializing:
+            case File2WayInitialized:
+                InitiateResetRecordFile();
+                break;
+
+            default:
+                break;
+        }
+    }
+#endif
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    else if (aEvent.GetContext() == iPlayFromFileNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent playfromfile node state %d\n",
+                         iPlayFromFileNode->GetState()));
+        switch (iPlayFileState)
+        {
+            case File2WayResetting:
+                CheckPlayFileState();
+                break;
+
+            case File2WayInitializing:
+            case File2WayInitialized:
+                InitiateResetPlayFile();
+                break;
+
+            default:
+                break;
+        }
+    }
+#endif
+    else if (iVideoEncDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext()))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent video enc datapath\n"));
+        iVideoEncDatapath->SetCmd(NULL);
+    }
+    else if (iVideoDecDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext()))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent video dec datapath\n"));
+        iVideoDecDatapath->SetCmd(NULL);
+    }
+    else if (iAudioEncDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext()))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent audio enc datapath\n"));
+
+        iAudioEncDatapath->UseFilePlayPort(false);
+        iAudioEncDatapath->SetSourceInputPort(NULL);
+
+#ifndef PV_DISABLE_DEVSOUNDNODES
+        switch (aEvent.GetEventType())
+        {
+
+            case PVMF_DEVSOUND_ERR_PORT_GETDATA_ERROR:
+            case PVMF_DEVSOUND_ERR_PORT_PUTDATA_ERROR:
+            case PVMF_DEVSOUND_ERR_SOURCE_SINK_EVENT_ERROR:
+            case PVMF_DEVSOUND_ERR_BITSTREAM_ERROR:
+            case PVMF_DEVSOUND_ERR_PORT_FRAME_TRANSFER_ERROR:
+            case PVMF_DEVSOUND_ERR_SOURCE_SINK_FRAME_TRANSFER_ERROR:
+            case PVMF_DEVSOUND_ERR_DATA_PROCESSING_ERROR:
+            case PVMF_DEVSOUND_ERR_RECORD_DATA_LOST:
+            case PVMF_DEVSOUND_ERR_MEMPOOL_ALLOC_ERROR:
+            case PVMF_DEVSOUND_ERR_MEDIADATAALLOC_ALLOC_ERROR:
+                //data dropped, recording will continue
+                break;
+
+            default:
+                iAudioEncDatapath->SetCmd(NULL);
+                break;
+        }
+#else
+        iAudioEncDatapath->SetCmd(NULL);
+#endif
+    }
+    else if (iAudioDecDatapath->IsNodeInDatapath((PVMFNodeInterface *) aEvent.GetContext()))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent audio dec datapath\n"));
+
+#ifndef PV_DISABLE_DEVSOUNDNODES
+        switch (aEvent.GetEventType())
+        {
+            case PVMF_DEVSOUND_ERR_PORT_GETDATA_ERROR:
+            case PVMF_DEVSOUND_ERR_PORT_PUTDATA_ERROR:
+            case PVMF_DEVSOUND_ERR_SOURCE_SINK_EVENT_ERROR:
+            case PVMF_DEVSOUND_ERR_BITSTREAM_ERROR:
+            case PVMF_DEVSOUND_ERR_PORT_FRAME_TRANSFER_ERROR:
+            case PVMF_DEVSOUND_ERR_SOURCE_SINK_FRAME_TRANSFER_ERROR:
+            case PVMF_DEVSOUND_ERR_DATA_PROCESSING_ERROR:
+            case PVMF_DEVSOUND_ERR_MEMPOOL_ALLOC_ERROR:
+            case PVMF_DEVSOUND_ERR_MEDIADATAALLOC_ALLOC_ERROR:
+                //data dropped, playback will continue
+                break;
+
+            default:
+                iAudioDecDatapath->SetCmd(NULL);
+                break;
+        }
+#else
+        iAudioDecDatapath->SetCmd(NULL);
+
+#endif
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::HandleNodeErrorEvent unknown node!"));
+    }
+}
+
+void CPV324m2Way::CommandHandler(PV2WayNodeCmdType aType,
+                                 const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "CPV324m2Way::CommandHandler, state %d, type %d\n", iState, aType));
+
+    CPV2WayNodeContextData *data = (CPV2WayNodeContextData *) aResponse.GetContext();
+
+    if (data->iNode == iCommNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler comm node\n"));
+        HandleCommNodeCmd(aType, aResponse);
+    }
+    else if (data->iNode == iTscNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler TSC node\n"));
+        HandleTscNodeCmd(aType, aResponse);
+    }
+    else if (data->iNode == iVideoDecNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler video decoder node\n"));
+        HandleVideoDecNodeCmd(aType, aResponse);
+    }
+    else if (data->iNode == iVideoEncNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler video encoder node\n"));
+        HandleVideoEncNodeCmd(aType, aResponse);
+    }
+    else if (IsSourceNode(data->iNode))
+    {
+        /* Do Add Data Source Here */
+        TPV2WayNode *source_node = GetTPV2WayNode(iSourceNodes, data->iNode);
+        OSCL_ASSERT(source_node);
+        DoAddDataSource(*source_node, aResponse);
+    }
+    else if (IsSinkNode(data->iNode))
+    {
+        TPV2WayNode *sink_node = GetTPV2WayNode(iSinkNodes, data->iNode);
+        OSCL_ASSERT(sink_node);
+        HandleSinkNodeCmd(aType, aResponse, sink_node);
+    }
+    else if (data->iNode == iAudioEncNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler audio encoder node\n"));
+        HandleAudioEncNodeCmd(aType, aResponse);
+    }
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    else if (data->iNode == iFFComposerNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler ff composer node\n"));
+        HandleFFComposerNodeCmd(aType, aResponse);
+    }
+#endif
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+    else if (data->iNode == iPlayFromFileNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler pff node\n"));
+        HandlePFFNodeCmd(aType, aResponse);
+    }
+    else if (data->iNode == iAudioSrcNode.iNode)
+    {
+        // This will happen only after the node had been added to a datapath succussfully
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CommandHandler audio src node\n"));
+        HandleAudioSrcNodeCmd(aType, aResponse);
+    }
+#endif
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::CommandHandler unknown node!"));
+    }
+}
+
+PVMFStatus CPV324m2Way::ConfigureNode(CPVDatapathNode *aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "CPV324m2Way::ConfigureNode, state %d\n", iState));
+
+    PVMFNodeInterface *node = aNode->iNode.iNode;
+
+    if (node == iTscNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring tsc node\n"));
+        return PVMFSuccess;
+    }
+    else if (node == iCommNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring comm node\n"));
+        return PVMFSuccess;
+    }
+    else if (node == iVideoEncNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "CPV324m2Way::ConfigureNode configuring video enc node\n"));
+
+
+        PVMp4H263EncExtensionInterface *ptr =
+            (PVMp4H263EncExtensionInterface *) iVideoEncNodeInterface.iInterface;
+
+
+        uint32 bitrate_bps_100 = VIDEO_ENCODER_BITRATE / 100;
+        PVMFVideoResolution aVideoResolution(VIDEO_ENCODER_WIDTH,
+                                             VIDEO_ENCODER_HEIGHT);
+        double aFrameRate = VIDEO_ENCODER_FRAME_RATE;
+
+        LogicalChannelInfo* lcn_info = NULL;
+
+        if (aNode->iOutputPort.iPortPair->iDestPort.GetStatus() != EHasPort)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::ConfigureNode waiting for tsc port to determine video codec type.\n"));
+            return PVMFPending;
+        }
+#ifndef NO_2WAY_324
+        if (iTerminalType == PV_324M)
+        {
+            OsclAny * tempInterface = NULL;
+            aNode->iOutputPort.iPortPair->iDestPort.GetPort()->QueryInterface(
+                PVH324MLogicalChannelInfoUuid, tempInterface);
+            lcn_info = OSCL_STATIC_CAST(LogicalChannelInfo*, tempInterface);
+            if (lcn_info == NULL)
+            {
+                return PVMFFailure;
+            }
+            PVMFFormatType aFormatType = lcn_info->GetFormatType();
+
+            if (iTSC324mInterface != NULL)
+            {
+                CPvtTerminalCapability* remote_caps = iTSC324mInterface->GetRemoteCapability();
+
+                if (remote_caps)
+                {
+                    for (uint16 i = 0; i < remote_caps->GetNumCapabilityItems();i++)
+                    {
+                        CPvtMediaCapability * RemoteCapItem =
+                            remote_caps->GetCapabilityItem(i);
+                        if (RemoteCapItem->GetFormatType() == aFormatType)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                                            (0, "CPV324m2Way::ConfigureNode Found codec match for bitrate - capability(%d), default(%d)", remote_caps->GetCapabilityItem(i)->GetBitrate(), bitrate_bps_100));
+                            if (RemoteCapItem->GetBitrate() < bitrate_bps_100)
+                            {
+                                bitrate_bps_100 = RemoteCapItem->GetBitrate();
+                            }
+
+                            PVMFVideoResolution *video_resolution;
+                            uint32 frame_rate;
+                            video_resolution = ((CPvtVideoCapability*)RemoteCapItem)->GetMaxResolution(frame_rate);
+                            if ((video_resolution->width < aVideoResolution.width) &&
+                                    (video_resolution->height <  aVideoResolution.height))
+                            {
+                                aVideoResolution.width = video_resolution->width;
+                                aVideoResolution.height = video_resolution->height;
+
+                            }
+
+                            if (frame_rate < aFrameRate)
+                                aFrameRate = frame_rate;
+
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+#endif
+        ptr->SetNumLayers(1);
+        ptr->SetOutputBitRate(0, bitrate_bps_100*100);
+        ptr->SetOutputFrameSize(0, aVideoResolution.width, aVideoResolution.height);
+        ptr->SetOutputFrameRate(0, (float)aFrameRate);
+
+        ptr->SetSegmentTargetSize(0, VIDEO_ENCODER_SEGMENT_SIZE);
+        ptr->SetRateControlType(0, VIDEO_ENCODER_RATE_CONTROL);
+        ptr->SetDataPartitioning(VIDEO_ENCODER_DATA_PARTITIONING);
+        ptr->SetRVLC(VIDEO_ENCODER_RVLC);
+        ptr->SetIFrameInterval(VIDEO_ENCODER_I_FRAME_INTERVAL);
+        return PVMFSuccess;
+
+    }
+    else if (node == iVideoDecNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring video dec node\n"));
+        return PVMFSuccess;
+    }
+#ifndef PV_DISABLE_DEVSOUNDNODES
+    else if (node == iAudioSrcNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring audio node\n"));
+        PVMFPortProperty prop;
+        if (aNode->iOutputPort.iPortPair->iDestPort.GetStatus() != EHasPort)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::ConfigureNode waiting for tsc port to determine audio codec type.\n"));
+            return PVMFPending;
+        }
+
+        aNode->iOutputPort.iPortPair->iDestPort.GetPort()->Query(prop);
+
+        //Set video encoder parameters
+        if (prop.iFormatType == PVMF_MIME_AMR_IF2)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::ConfigureNode AMR IF2.\n"));
+            //Can't set audio codec type yet
+        }
+        else if (prop.iFormatType == PVMF_MIME_G723)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::ConfigureNode G723.\n"));
+            //Can't set audio codec type yet
+        }
+
+        uint32 bitrate_bps = MAX_AUDIO_BITRATE;
+
+        CPvtTerminalCapability* remote_caps = iTscNode.node->GetRemoteCapability();
+        if (remote_caps)
+        {
+            for (uint16 i = 0; i < remote_caps->GetNumCapabilityItems(); i++)
+            {
+                if ((remote_caps->GetCapabilityItem(i)->GetFormatType() == PVMF_AMR_IF2 ||
+                        remote_caps->GetCapabilityItem(i)->GetFormatType() == PVMF_MIME_G723) &&
+                        remote_caps->GetCapabilityItem(i)->GetBitrate() < bitrate_bps / 100)
+                {
+                    bitrate_bps = remote_caps->GetCapabilityItem(i)->GetBitrate() * 100;
+                }
+            }
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode audio bitrate %d.\n", bitrate_bps));
+
+        // set max bitrate in devsound
+        PVDevSoundOptions options;
+        ((PVDevSoundNodeBase *) iAudioSrcNode)->GetOptions(options);
+        if (bitrate_bps >= 12200)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate122;
+        }
+        else if (bitrate_bps >= 10200)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate102;
+        }
+        else if (bitrate_bps >= 7950)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate795;
+        }
+        else if (bitrate_bps >= 7400)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate74;
+        }
+        else if (bitrate_bps >= 6700)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate67;
+        }
+        else if (bitrate_bps >= 5900)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate59;
+        }
+        else if (bitrate_bps >= 5150)
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate515;
+        }
+        else
+        {
+            options.iRecordAmrBitrate = PVMFAmrEncBitrate475;
+        }
+
+        ((PVDevSoundNodeBase *) iAudioSrcNode)->UpdateOptions(options);
+
+        return PVMFSuccess;
+    }
+#endif
+    else if (node == iAudioEncNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring audio enc node\n"));
+        //PVMFPortProperty prop;
+        PVAMREncExtensionInterface *ptr =
+            (PVAMREncExtensionInterface *) iAudioEncNodeInterface.iInterface;
+
+        if (aNode->iOutputPort.iPortPair->iDestPort.GetStatus() != EHasPort)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "CPV324m2Way::ConfigureNode waiting for tsc port to determine audio codec type.\n"));
+            return PVMFPending;
+        }
+
+        //aNode->iOutputPort.iPortPair->iDestPort.GetPort()->Query(prop);
+
+        //ptr->SetOutputFormat(PVMF_AMR_IF2);
+        //ptr->SetInputSamplingRate(KSamplingRate);
+        //ptr->SetInputBitsPerSample(KBitsPerSample);
+        //ptr->SetInputNumChannels(KNumChannels);
+        ptr->SetOutputBitRate(GSM_AMR_12_2);
+        ptr->SetMaxNumOutputFramesPerBuffer(KNumPCMFrames);
+
+        return PVMFSuccess;
+
+    }
+    else if (node == iAudioDecNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring audio dec node\n"));
+        return PVMFSuccess;
+    }
+    else if (node == iVideoParserNode.iNode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::ConfigureNode configuring video parser node\n"));
+        return PVMFSuccess;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ConfigureNode unknown node\n"));
+        return PVMFFailure;
+    }
+    return PVMFFailure;
+}
+
+// Implementations of TSC Observer virtuals
+void CPV324m2Way::ConnectComplete(PVMFStatus status)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "CPV324m2Way::ConnectComplete, state %d, status %d\n", iState, status));
+    if (status == PVMFSuccess)
+    {
+        iIsStackConnected = true;
+    }
+    else
+    {
+        iIsStackConnected = false;
+        SetState(EDisconnecting);
+    }
+
+    CheckState();
+}
+
+void CPV324m2Way::InternalError()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "CPV324m2Way::InternalError, state %d\n", iState));
+
+    switch (iState)
+    {
+        case EDisconnecting:
+            iAudioDecDatapath->TSCPortClosed();
+            iAudioEncDatapath->TSCPortClosed();
+            iVideoDecDatapath->TSCPortClosed();
+            iVideoEncDatapath->TSCPortClosed();
+
+            CheckState();
+            break;
+
+        case EConnecting:
+        case EConnected:
+            iAudioDecDatapath->TSCPortClosed();
+            iAudioEncDatapath->TSCPortClosed();
+            iVideoDecDatapath->TSCPortClosed();
+            iVideoEncDatapath->TSCPortClosed();
+
+            InitiateDisconnect();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::InternalError invalid state\n"));
+            break;
+    }
+}
+
+void CPV324m2Way::DisconnectRequestReceived()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::DisconnectRequestReceived state %d\n", iState));
+
+    iIsStackConnected = false;
+    if (iDisconnectInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::DisconnectRequestReceived Doing nothing as  disconnect is in progress"));
+    }
+    else
+    {
+
+        switch (iState)
+        {
+            case EDisconnecting:
+                iAudioDecDatapath->TSCPortClosed();
+                iAudioEncDatapath->TSCPortClosed();
+                iVideoDecDatapath->TSCPortClosed();
+                iVideoEncDatapath->TSCPortClosed();
+
+                CheckState();
+                break;
+
+            case EConnecting:
+            case EConnected:
+                iAudioDecDatapath->TSCPortClosed();
+                iAudioEncDatapath->TSCPortClosed();
+                iVideoDecDatapath->TSCPortClosed();
+                iVideoEncDatapath->TSCPortClosed();
+
+
+                iRemoteDisconnectTimer->SetObserver(this);
+                iRemoteDisconnectTimer->Request(REMOTE_DISCONNECT_TIMER_ID, REMOTE_DISCONNECT_TIMER_ID,
+                                                REMOTE_DISCONNECT_TIMER_VALUE, this);
+
+
+                //We do InitiateDisconnect() once above timer expires
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::DisconnectRequestReceived invalid state\n"));
+                break;
+        }
+    }
+}
+
+PVMFStatus CPV324m2Way::EstablishChannel(TPVDirection aDir,
+        TPVChannelId aId,
+        PVCodecType_t aCodec,
+        uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::EstablishChannel aDir=%d, channel id=%d, codec %d\n",
+                     aDir, aId, aCodec));
+
+    PV2WayMediaType media_type = ::GetMediaType(aCodec);
+    OSCL_ASSERT(media_type == PV_AUDIO || media_type == PV_VIDEO);
+    PVMFFormatType aFormatType = PVCodecTypeToPVMFFormatType(aCodec);
+    PVMFFormatType aAppFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+
+    TPV2WayEventInfo* aEvent = NULL;
+    if (!GetEventInfo(aEvent))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::EstablishChannel Memory allocation failed!\n"));
+        return PVMFErrNoMemory;
+    }
+
+    Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class>* codec_list = NULL;
+    Oscl_Map<PVMFFormatType, PVMFFormatType, OsclMemAllocator, pvmf_format_type_key_compare_class>* app_format_for_engine_format = NULL;
+
+    CPV2WayDataChannelDatapath* datapath = NULL;
+
+    if (aDir == INCOMING)
+    {
+        if (media_type == PV_AUDIO)
+        {
+            if (!(iAudioDecDatapath))
+            {
+                iAudioDecDatapath = CPV2WayDecDataChannelDatapath::NewL(iLogger,
+                                    aFormatType, this);
+
+            }
+
+            AddAudioDecoderNode();
+            uint32 audioLatency = LookupMioLatency(PVCodecTypeToPVMFFormatType(aCodec), true);
+            ((TSC_324m*)(iTscNode.iNode))->SetMioLatency((audioLatency + iAudioDatapathLatency), true);
+
+            datapath = iAudioDecDatapath;
+            codec_list = &iIncomingAudioCodecs;
+        }
+        else if (media_type == PV_VIDEO)
+        {
+            if (!(iVideoDecDatapath))
+            {
+                iVideoDecDatapath = CPV2WayDecDataChannelDatapath::NewL(iLogger, aFormatType, this);
+            }
+            iVideoDecDatapath->SetFormatSpecificInfo(aFormatSpecificInfo, (uint16)aFormatSpecificInfoLen);
+
+            AddVideoDecoderNode(aCodec, aFormatSpecificInfo, aFormatSpecificInfoLen);
+            uint32 videoLatency = LookupMioLatency(PVCodecTypeToPVMFFormatType(aCodec), false);
+            ((TSC_324m*)(iTscNode.iNode))->SetMioLatency((videoLatency + iVideoDatapathLatency), false);
+
+            datapath = iVideoDecDatapath;
+            codec_list = &iIncomingVideoCodecs;
+        }
+        app_format_for_engine_format = &iAppFormatForEngineFormatIncoming;
+        iClock.Start();
+    }
+
+    else
+    {
+        if (media_type == PV_AUDIO)
+        {
+            if (!(iAudioEncDatapath))
+            {
+                iAudioEncDatapath = CPV2WayEncDataChannelDatapath::NewL(iLogger,
+                                    aFormatType, this);
+            }
+
+            AddAudioEncoderNode();
+
+            datapath = iAudioEncDatapath;
+            codec_list = &iOutgoingAudioCodecs;
+        }
+        else if (media_type == PV_VIDEO)
+        {
+            if (!(iVideoEncDatapath))
+            {
+                iVideoEncDatapath = CPV2WayEncDataChannelDatapath::NewL(iLogger, aFormatType, this);
+            }
+            iVideoEncDatapath->SetFormatSpecificInfo(aFormatSpecificInfo, (uint16)aFormatSpecificInfoLen);
+
+            AddVideoEncoderNode(aCodec);
+            datapath = iVideoEncDatapath;
+            codec_list = &iOutgoingVideoCodecs;
+        }
+        app_format_for_engine_format = &iAppFormatForEngineFormatOutgoing;
+    }
+    Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class>::iterator it = codec_list->find(aFormatType);
+
+    if (it == codec_list->end())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::EstablishChannel Failed to lookup codec=%d\n", aCodec));
+        return PVMFFailure;
+    }
+
+    if ((*it).second.iPriority == ENG)
+    {
+        // Set the app format to the stored raw format type
+        aAppFormatType = (*app_format_for_engine_format)[aFormatType];
+    }
+    else
+    {
+        // Set the app format to the compressed type
+        aAppFormatType = aFormatType;
+    }
+    datapath->SetFormat(aFormatType);
+    datapath->SetSourceSinkFormat(aAppFormatType);
+
+    // Send the informational event to the app
+    aEvent->localBuffer[0] = (uint8) media_type;
+    // bytes 1,2,3 are unused
+    *((TPVChannelId*)(aEvent->localBuffer + 4)) = aId;
+    aEvent->localBufferSize = 8;
+
+    PVEventType aEventType = (aDir == INCOMING) ? PVT_INDICATION_INCOMING_TRACK : PVT_INDICATION_OUTGOING_TRACK;
+    PVUuid puuid = PV2WayTrackInfoInterfaceUUID;
+    PV2WayTrackInfoInterface* pTrackInfo = OSCL_NEW(PV2WayTrackInfoImpl,
+                                           (aAppFormatType, aFormatSpecificInfo, aFormatSpecificInfoLen, aEventType, puuid));
+    PVAsyncInformationalEvent infoEvent(aEventType, NULL,
+                                        OSCL_STATIC_CAST(PVInterface*, pTrackInfo), NULL,
+                                        aEvent->localBuffer, aEvent->localBufferSize);
+    if (iInfoEventObserver != NULL)
+    {
+        iInfoEventObserver->HandleInformationalEvent(infoEvent);
+    }
+    pTrackInfo->removeRef();
+
+    return EPVT_Success;
+}
+
+void CPV324m2Way::OutgoingChannelEstablished(TPVChannelId aId,
+        PVCodecType_t aCodec,
+        uint8* aFormatSpecificInfo,
+        uint32 aFormatSpecificInfoLen)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::OutgoingChannelEstablished id=%d, codec=%d, fsi=%x, fsi_len=%d",
+                     aId, aCodec, aFormatSpecificInfo, aFormatSpecificInfoLen));
+    EstablishChannel(OUTGOING, aId, aCodec, aFormatSpecificInfo, aFormatSpecificInfoLen);
+}
+
+TPVStatusCode CPV324m2Way::IncomingChannel(TPVChannelId aId,
+        PVCodecType_t aCodec,
+        uint8* aFormatSpecificInfo,
+        uint32 aFormatSpecificInfoLen)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::IncomingChannel channel id=%d, codec %d\n",
+                     aId, aCodec));
+    return EstablishChannel(INCOMING, aId, aCodec, aFormatSpecificInfo, aFormatSpecificInfoLen);
+}
+
+bool CPV324m2Way::GetEventInfo(TPV2WayEventInfo*& event)
+{
+    int32 error = 0;
+    OSCL_TRY(error, event = GetEventInfoL());
+    OSCL_FIRST_CATCH_ANY(error,
+                         return false);
+    return true;
+}
+
+void CPV324m2Way::ChannelClosed(TPVDirection direction,
+                                TPVChannelId id,
+                                PVCodecType_t codec,
+                                PVMFStatus status)
+{
+    OSCL_UNUSED_ARG(status);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::ChannelClosed id %d, codec %d, direction %d\n", id, codec, direction));
+    PV2WayMediaType media_type = ::GetMediaType(codec);
+    TPV2WayEventInfo* event = NULL;
+    bool track_closed = false;
+    // Send the closing track indication
+    if (!GetEventInfo(event))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ChannelClosed unable to allocate memory"));
+        return;
+    }
+
+    event->type = PVT_INDICATION_CLOSING_TRACK;
+    event->localBufferSize = 8;
+    event->localBuffer[0] = (uint8)direction;
+    // bytes 1,2,3 are unused
+    *((TPVChannelId*)(event->localBuffer + 4)) = id;
+    Dispatch(event);
+
+    switch (media_type)
+    {
+        case PV_AUDIO:
+            switch (direction)
+            {
+                case INCOMING:
+                    if (iAudioDecDatapath)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                        (0, "CPV324m2Way::ChannelClosed audio dec path state %d, id %d\n",
+                                         iAudioDecDatapath->GetState(), iAudioDecDatapath->GetChannelId()));
+                        if (iAudioDecDatapath->GetChannelId() == CHANNEL_ID_UNKNOWN)
+                        {
+                            track_closed = true;
+                        }
+                        else if (id == iAudioDecDatapath->GetChannelId())
+                        {
+                            switch (iAudioDecDatapath->GetState())
+                            {
+                                case EClosing:
+                                    break;
+                                case EClosed:
+                                    track_closed = true;
+                                    break;
+                                default:
+                                    iAudioDecDatapath->SetCmd(NULL);
+                                    break;
+                            }
+                        }
+                        else
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                            (0, "CPV324m2Way::ChannelClosed ERROR Channel id mismatch id=%d, datapath id=%d\n",
+                                             id, iAudioDecDatapath->GetChannelId()));
+                        }
+                    }
+                    break;
+
+                case OUTGOING:
+                    if (iAudioEncDatapath)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                        (0, "CPV324m2Way::ChannelClosed audio enc path state %d, id %d\n",
+                                         iAudioEncDatapath->GetState(), iAudioEncDatapath->GetChannelId()));
+                        if (iAudioEncDatapath->GetChannelId() == CHANNEL_ID_UNKNOWN)
+                        {
+                            track_closed = true;
+                        }
+                        else if (id == iAudioEncDatapath->GetChannelId())
+                        {
+                            switch (iAudioEncDatapath->GetState())
+                            {
+                                case EClosing:
+                                    break;
+                                case EClosed:
+                                    track_closed = true;
+                                    break;
+                                default:
+                                    iAudioEncDatapath->SetCmd(NULL);
+                                    break;
+                            }
+                        }
+                        else
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                            (0, "CPV324m2Way::ChannelClosed ERROR Channel id mismatch id=%d, datapath id=%d\n",
+                                             id, iAudioEncDatapath->GetChannelId()));
+                        }
+                    }
+                    break;
+
+                default:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::ChannelClosed unknown audio direction %d\n",
+                                     direction));
+                    break;
+            }
+            break;
+        case PV_VIDEO:
+            switch (direction)
+            {
+                case INCOMING:
+                    if (iVideoDecDatapath)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                        (0, "CPV324m2Way::ChannelClosed video dec path state %d, id %d\n",
+                                         iVideoDecDatapath->GetState(),
+                                         iVideoDecDatapath->GetChannelId()));
+                        if (iVideoDecDatapath->GetChannelId() == CHANNEL_ID_UNKNOWN)
+                        {
+                            track_closed = true;
+                        }
+                        else if (id == iVideoDecDatapath->GetChannelId())
+                        {
+                            switch (iVideoDecDatapath->GetState())
+                            {
+                                case EClosing:
+                                    break;
+                                case EClosed:
+                                    track_closed = true;
+                                    break;
+                                default:
+                                    iVideoDecDatapath->SetCmd(NULL);
+                                    break;
+                            }
+                        }
+                        else
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                            (0, "CPV324m2Way::ChannelClosed ERROR Channel id mismatch id=%d, datapath id=%d\n",
+                                             id, iVideoDecDatapath->GetChannelId()));
+                        }
+                    }
+                    break;
+
+                case OUTGOING:
+                    if (iVideoEncDatapath)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                        (0, "CPV324m2Way::ChannelClosed video enc path state %d, id %d\n",
+                                         iVideoEncDatapath->GetState(),
+                                         iVideoEncDatapath->GetChannelId()));
+                        if (iVideoEncDatapath->GetChannelId() == CHANNEL_ID_UNKNOWN)
+                        {
+                            track_closed = true;
+                        }
+                        else if (id == iVideoEncDatapath->GetChannelId())
+                        {
+                            switch (iVideoEncDatapath->GetState())
+                            {
+                                case EClosing:
+                                    break;
+                                case EClosed:
+                                    track_closed = true;
+                                    break;
+                                default:
+                                    iVideoEncDatapath->SetCmd(NULL);
+                                    break;
+                            }
+                        }
+                        else
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                            (0, "CPV324m2Way::ChannelClosed ERROR Channel id mismatch id=%d, datapath id=%d\n",
+                                             id, iVideoEncDatapath->GetChannelId()));
+                        }
+                    }
+                    break;
+
+                default:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::ChannelClosed unknown video direction %d\n",
+                                     direction));
+                    break;
+            }
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::ChannelClosed unknown media type %d\n",
+                             media_type));
+            break;
+    }
+
+    if (!track_closed)
+        return;
+
+    if (!GetEventInfo(event))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::ChannelClosed unable to allocate memory"));
+        return;
+    }
+    event->type = PVT_INDICATION_CLOSE_TRACK;
+    event->localBufferSize = 8;
+    event->localBuffer[0] = (uint8)direction;
+    // bytes 1,2,3 are unused
+    *((TPVChannelId*)(event->localBuffer + 4)) = id;
+    Dispatch(event);
+}
+
+void CPV324m2Way::RequestFrameUpdate(PVMFPortInterface* aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RequestFrameUpdate\n"));
+    if (iVideoEncDatapath)
+    {
+        GenerateIFrame(aPort);
+    }
+}
+
+#if 0
+void CPV324m2Way::VideoSpatialTemporalTradeoffCommandReceived(TPVChannelId id,
+        uint8 tradeoff)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
+                    (0, "CPV324m2Way::VideoSpatialTemporalTradeoffCommandReceived state %d, id %d, tradeoff %d\n", iState, id, tradeoff));
+    int32 error;
+    TPV2WayEventInfo* aEvent = NULL;
+    OSCL_TRY(error, aEvent = GetEventInfoL());
+    OSCL_FIRST_CATCH_ANY(error,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                         PVLOGMSG_ERR, (0, "CPV324m2Way::VidSpatTempTradeoffCmd -  unable to notify app!\n"));
+                         return;);
+    aEvent->type = PVT_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND;
+    TPVChannelId *buf_id = (TPVChannelId *) & aEvent->localBuffer[0];
+    *buf_id = id;
+    host_to_big_endian((char *)&aEvent->localBuffer[0], 2);
+    aEvent->localBuffer[2] = tradeoff;
+    aEvent->localBufferSize = 3;
+    Dispatch(aEvent);
+
+
+}
+
+void CPV324m2Way::VideoSpatialTemporalTradeoffIndicationReceived(TPVChannelId id,
+        uint8 tradeoff)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
+                    (0, "CPV324m2Way::VideoSpatialTemporalTradeoffIndicationReceived state %d, id %d, tradeoff %d\n", iState, id, tradeoff));
+    int32 error;
+    TPV2WayEventInfo* aEvent = NULL;
+    OSCL_TRY(error, aEvent = GetEventInfoL());
+    OSCL_FIRST_CATCH_ANY(error,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                         PVLOGMSG_ERR, (0, "CPV324m2Way::VidSpatTempTradeoffInd -  unable to notify app!\n"));
+                         return;);
+    aEvent->type = PVT_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION;
+    TPVChannelId *buf_id = (TPVChannelId *) & aEvent->localBuffer[0];
+    *buf_id = id;
+    host_to_big_endian((char *)&aEvent->localBuffer[0], 2);
+    aEvent->localBuffer[2] = tradeoff;
+    aEvent->localBufferSize = 3;
+    Dispatch(aEvent);
+}
+
+
+void CPV324m2Way::UserInputReceived(CPVUserInput* aUI)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::UserInputReceived state %d, type %d\n",
+                     iState, aUI->GetType()));
+
+#if 0
+    int32 error;
+    TPV2WayEventInfo* aEvent = NULL;
+    switch (aUI)
+    {
+        case EAlphanumeric:
+        case EDtmf:
+            OSCL_TRY(error, aEvent = GetEventInfoL());
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::UserInputReceived unable to notify app!\n"));
+                                 return EPVT_Failed);
+
+            aEvent->type = PVT_INDICATION_USER_INPUT;
+            (CPVUserInput *)&aEvent->localBuffer[0] = aUI;
+            aEvent->localBufferSize = 4;
+
+            Dispatch(aEvent);
+            break;
+
+        default:
+            break;
+    }
+#else
+    if (aUI)
+    {
+        OSCL_DELETE(aUI);
+    }
+#endif
+    return;
+}
+
+void CPV324m2Way::IncomingVendorId(TPVH245Vendor* /*vendor*/,
+                                   const uint8* /*pn*/,
+                                   uint16 /*pn_len*/,
+                                   const uint8* /*vn*/,
+                                   uint16 /*vn_len*/)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::IncomingVendorId\n"));
+}
+
+void CPV324m2Way::UserInputCapability(int32 formats)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::UserInputCapability formats %d", formats));
+
+    if (iState == EConnecting)
+    {
+        int32 error;
+        TPV2WayEventInfo* aEvent = NULL;
+        if (!GetEventInfoL(aEvent))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::UserInputCapability unable to notify app!\n"));
+            return;
+        }
+        aEvent->type = PVT_INDICATION_USER_INPUT_CAPABILITY;
+        oscl_memset(aEvent->localBuffer, 0, PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+        aEvent->localBuffer[0] = (uint8)(formats & 0xFF);
+        aEvent->localBufferSize = 1;
+        Dispatch(aEvent);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::UserInputCapability invalid state %d\n", iState));
+    }
+}
+#endif
+
+void  CPV324m2Way::TimeoutOccurred(int32 timerID,
+                                   int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timeoutInfo);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::TimeoutOccurred id %d, info %d\n", timerID, timeoutInfo));
+
+    if (timerID == IFRAME_REQ_TIMERID)
+    {
+        isIFrameReqTimerActive = false;
+    }
+    else if ((timerID == END_SESSION_TIMER_ID) || (timerID == REMOTE_DISCONNECT_TIMER_ID))
+    {
+        // Cancel out both timers if any one expires, as both do InitiateDisconnect()
+        if (iEndSessionTimer)
+        {
+            iEndSessionTimer->Cancel(END_SESSION_TIMER_ID);
+        }
+
+        if (iRemoteDisconnectTimer)
+        {
+            iRemoteDisconnectTimer->Cancel(REMOTE_DISCONNECT_TIMER_ID);
+        }
+
+        InitiateDisconnect();
+    }
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+    if (timerID == RECORDED_FILESIZE_NOTIFICATION_TIMERID)
+    {
+        int32 error;
+        uint32 fileSize;
+        TPV2WayEventInfo* aEvent = NULL;
+        PvmfComposerSizeAndDurationInterface *ptr =
+            (PvmfComposerSizeAndDurationInterface *) iFFSizeAndDuration.iInterface;
+
+        if (!GetEventInfo(aEvent))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::TimeoutOccurred unable to notify app of recorded filesize!\n"));
+            return;
+        }
+        aEvent->type = PVT_INDICATION_RECORDED_FILE_SIZE;
+
+        ptr->GetFileSize(fileSize);
+        *((uint32 *)(aEvent->localBuffer)) = fileSize;
+
+        aEvent->localBufferSize = sizeof(uint32);
+        Dispatch(aEvent);
+    }
+#endif
+}
+
+TPV2WayCmdInfo *CPV324m2Way::GetCmdInfoL()
+{
+    if (iFreeCmdInfo.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::GetFreeCmdInfo unable to allocate cmd info!"));
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    else
+    {
+        TPV2WayCmdInfo *cmd = (TPV2WayCmdInfo *)iFreeCmdInfo[0];
+        iFreeCmdInfo.erase(iFreeCmdInfo.begin());
+        return cmd;
+    }
+
+    return NULL;
+}
+
+void CPV324m2Way::FreeCmdInfo(TPV2WayCmdInfo *info)
+{
+    info->Clear();
+    iFreeCmdInfo.push_back(info);
+}
+
+TPV2WayEventInfo *CPV324m2Way::GetEventInfoL()
+{
+    if (iFreeEventInfo.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::GetFreeEventInfo unable to allocate event info!"));
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    else
+    {
+        TPV2WayEventInfo *cmd = (TPV2WayEventInfo *)iFreeEventInfo[0];
+        iFreeEventInfo.erase(iFreeEventInfo.begin());
+        return cmd;
+    }
+
+    return NULL;
+}
+
+void CPV324m2Way::FreeEventInfo(TPV2WayEventInfo *info)
+{
+    info->Clear();
+    iFreeEventInfo.push_back(info);
+}
+
+PVMFCommandId CPV324m2Way::SendNodeCmdL(PV2WayNodeCmdType aCmd,
+                                        TPV2WayNode *aNode,
+                                        CPV2WayNodeCommandObserver *aObserver,
+                                        void *aParam,
+                                        TPV2WayCmdInfo *a2WayCmdInfo)
+{
+    int32 error = 0;
+    PVMFCommandId id = 0;
+    TPV2WayNodeCmdInfo *info;
+    PVMFNodeInterface * nodeIFace = (PVMFNodeInterface *)aNode->iNode;
+    PvmfNodesSyncControlInterface* ptr = NULL;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::SendNodeCmdL state %d, cmd %d, session %d\n",
+                     iState, aCmd, aNode->iSessionId));
+
+    if (aNode == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::SendNodeCmdL node ptr is null!\n"));
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+
+    if (iFreeNodeCmdInfo.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "CPV324m2Way::SendNodeCmdL unable to allocate node command info!\n"));
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    info = (TPV2WayNodeCmdInfo *)iFreeNodeCmdInfo[0];
+    iFreeNodeCmdInfo.erase(iFreeNodeCmdInfo.begin());
+
+    info->type = aCmd;
+    info->context.iObserver = aObserver;
+    info->context.iNode = nodeIFace;
+    info->engineCmdInfo = a2WayCmdInfo;
+
+    PVMFSessionId sessionId = aNode->GetSessionId();
+
+    switch (aCmd)
+    {
+        case PV2WAY_NODE_CMD_QUERY_UUID:
+            if (aParam != NULL)
+            {
+                TPV2WayNodeQueryUuidParams *queryParam = (TPV2WayNodeQueryUuidParams *) aParam;
+                OSCL_TRY(error, id = nodeIFace->QueryUUID(sessionId,
+                                     queryParam->mimetype, *queryParam->iUuids,
+                                     true, (OsclAny *) & info->context));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::SendNodeCmdL RequestPort param is null!\n"));
+                error = PVMFErrArgument;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_QUERY_INTERFACE:
+            if (aParam != NULL)
+            {
+                TPV2WayNodeQueryInterfaceParams *queryParam =
+                    (TPV2WayNodeQueryInterfaceParams *) aParam;
+                OSCL_TRY(error, id = nodeIFace->QueryInterface(sessionId,
+                                     *queryParam->iUuid, *queryParam->iInterfacePtr,
+                                     (OsclAny *) & info->context));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::SendNodeCmdL RequestPort param is null!\n"));
+                error = PVMFErrArgument;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_INIT:
+            info->context.iContextData = aParam;
+            OSCL_TRY(error, id = nodeIFace->Init(sessionId,
+                                                 (OsclAny *) & info->context));
+            break;
+
+        case PV2WAY_NODE_CMD_REQUESTPORT:
+            if (aParam != NULL)
+            {
+                OSCL_HeapString<OsclMemAllocator> mimeType;
+                TPV2WayNodeRequestPortParams *params = (TPV2WayNodeRequestPortParams *) aParam;
+                mimeType = params->format.getMIMEStrPtr();
+                //Get mime string from format type
+                OSCL_TRY(error, id = nodeIFace->RequestPort(sessionId,
+                                     params->portTag, &mimeType, (OsclAny *) & info->context));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::SendNodeCmdL RequestPort param is null!\n"));
+                error = PVMFErrArgument;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_PREPARE:
+            OSCL_TRY(error, id = nodeIFace->Prepare(sessionId,
+                                                    (OsclAny *) & info->context));
+            break;
+
+        case PV2WAY_NODE_CMD_START:
+            OSCL_TRY(error, id = nodeIFace->Start(sessionId,
+                                                  (OsclAny *) & info->context));
+            break;
+
+        case PV2WAY_NODE_CMD_PAUSE:
+            OSCL_TRY(error, id = nodeIFace->Pause(sessionId,
+                                                  (OsclAny *) & info->context));
+            break;
+
+        case PV2WAY_NODE_CMD_STOP:
+            OSCL_TRY(error, id = nodeIFace->Stop(sessionId,
+                                                 (OsclAny *) & info->context));
+            break;
+
+        case PV2WAY_NODE_CMD_RELEASEPORT:
+            if (aParam != NULL)
+            {
+                OSCL_TRY(error, id = nodeIFace->ReleasePort(sessionId,
+                                     *((PVMFPortInterface *) aParam), (OsclAny *) & info->context));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::SendNodeCmdL ReleasePort param is null!\n"));
+                error = PVMFErrArgument;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_RESET:
+            OSCL_TRY(error, id = nodeIFace->Reset(sessionId,
+                                                  (OsclAny *) & info->context));
+            break;
+
+        case PV2WAY_NODE_CMD_CANCELCMD:
+            if (aParam != NULL)
+            {
+                OSCL_TRY(error, id = nodeIFace->CancelCommand(sessionId,
+                                     *((PVMFCommandId *) aParam), (OsclAny *) & info->context));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::SendNodeCmdL CancelCommand param is null!\n"));
+                error = PVMFErrArgument;
+            }
+
+            //Remove commands on pending list
+            if (!error)
+            {
+                RemovePendingNodeCmd((PVMFNodeInterface *)aNode,
+                                     *((PVMFCommandId *) aParam));
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_CANCELALL:
+            OSCL_TRY(error, id = nodeIFace->CancelAllCommands(sessionId,
+                                 (OsclAny *) & info->context));
+
+            //Remove commands on pending list
+            if (!error)
+            {
+                RemovePendingNodeCmd((PVMFNodeInterface *)aNode, 0, true);
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_SKIP_MEDIA_DATA:
+        {
+            for (uint32 ii = 0;ii < iSinkNodeList.size();ii++)
+            {
+                if ((aNode == iSinkNodeList[ii].iSinkNode)
+                        && (iSinkNodeList[ii].iNodeInterface.iState ==
+                            PV2WayNodeInterface::HasInterface))
+                {
+                    ptr = (PvmfNodesSyncControlInterface*)
+                          iSinkNodeList[ii].iNodeInterface.iInterface;
+                    if (ptr != NULL)
+                    {
+                        //Pause the clock, since this gives a chance to register
+                        // the clock observer notifications
+                        iClock.Pause();
+                        ptr->SetClock(&iClock);
+                        ptr->SetMargins(SYNC_EARLY_MARGIN, SYNC_LATE_MARGIN);
+                        OSCL_TRY(error, id =
+                                     ptr->SkipMediaData(aNode->iSessionId,
+                                                        resume_timestamp, STREAMID, false,
+                                                        (OsclAny *) & info->context));
+                        //Re-start the clock, since by now, the sink node and MIO component
+                        // would've registered itself as the clock observer
+                        iClock.Start();
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "CPV324m2Way::SendNodeCmdL SkipMediaData param is null!\n"));
+                        error = PVMFErrArgument;
+                    }
+                    break;
+                }
+            }
+        }
+        break;
+        case PV2WAY_NODE_CMD_INVALID:
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::SendNodeCmdL invalid command!\n"));
+            OSCL_LEAVE(PVMFErrArgument);
+            break;
+    }
+
+    if (error)
+    {
+        info->Clear();
+        iFreeNodeCmdInfo.push_back(info);
+        OSCL_LEAVE(error);
+    }
+
+    info->id = id;
+
+    iPendingNodeCmdInfo.push_back(info);
+    return id;
+}
+
+TPV2WayNodeCmdInfo *CPV324m2Way::FindPendingNodeCmd(PVMFNodeInterface *aNode,
+        PVMFCommandId aId)
+{
+    for (uint32 i = 0; i < iPendingNodeCmdInfo.size(); i++)
+    {
+        if ((iPendingNodeCmdInfo[i]->context.iNode == aNode) &&
+                (iPendingNodeCmdInfo[i]->id == aId))
+        {
+            return iPendingNodeCmdInfo[i];
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "CPV324m2Way::FindPendingNodeCmd unable to find command, node %x, id %d!\n", aNode, aId));
+    return NULL;
+}
+
+void CPV324m2Way::RemovePendingNodeCmd(PVMFNodeInterface *aNode,
+                                       PVMFCommandId aId,
+                                       bool aAllCmds)
+{
+    TPV2WayNodeCmdInfo **info = NULL;
+
+    info = iPendingNodeCmdInfo.begin();
+    while (info != iPendingNodeCmdInfo.end())
+    {
+        if (((*info)->context.iNode == aNode) &&
+                (aAllCmds || ((*info)->id == aId)))
+        {
+            (*info)->Clear();
+            iFreeNodeCmdInfo.push_back(*info);
+            iPendingNodeCmdInfo.erase(info);
+            info = iPendingNodeCmdInfo.begin();
+            continue;
+        }
+
+        info++;
+    }
+
+    return;
+}
+
+
+void CPV324m2Way::FillSDKInfo(PVSDKInfo &aSDKInfo)
+{
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+    //              (0, "CPV324m2Way::FillSDKInfo"));
+    aSDKInfo.iLabel = PV2WAY_ENGINE_SDKINFO_LABEL;
+    aSDKInfo.iDate = PV2WAY_ENGINE_SDKINFO_DATE;
+}
+
+bool CPV324m2Way::CheckMandatoryCodecs(const PVMFFormatType *aMandatoryList,
+                                       uint32 aMandatorySize,
+                                       Oscl_Vector<PVMFFormatType, OsclMemAllocator> &aCodecList)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckMandatoryCodecs"));
+    uint32 i, j;
+    bool found;
+
+    if (aCodecList.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "CPV324m2Way::CheckMandatoryCodecs empty codecs list, use default"));
+        return true;
+    }
+
+    for (i = 0; i < aMandatorySize; i++)
+    {
+        found = false;
+        for (j = 0; j < aCodecList.size(); j++)
+        {
+            if (aMandatoryList[i] == aCodecList[j])
+            {
+                found = true;
+                break;
+            }
+        }
+
+        if (!found)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::CheckMandatoryCodecs %s not found!",
+                             (aMandatoryList[i]).getMIMEStrPtr()));
+            return false;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "CPV324m2Way::CheckMandatoryCodecs all codecs found"));
+    return true;
+}
+
+void CPV324m2Way::InitiateSession(TPV2WayNode& aNode)
+{
+    PVMFNodeInterface * nodeIFace = (PVMFNodeInterface *)aNode ;
+    PVMFNodeSessionInfo session(this, this, aNode, this, aNode);
+    aNode.iSessionId =  nodeIFace->Connect(session);
+    nodeIFace->ThreadLogon();
+}
+
+bool CPV324m2Way::IsNodeReset(PVMFNodeInterface& aNode)
+{
+    TPVMFNodeInterfaceState node_state = aNode.GetState();
+
+    if (node_state == EPVMFNodeCreated || node_state == EPVMFNodeIdle)
+        return true;
+    return false;
+}
+
+
+void CPV324m2Way::SetPreferredCodecs(TPVDirection aDir,
+                                     Oscl_Vector<const char*, OsclMemAllocator>& aAppAudioFormats,
+                                     Oscl_Vector<const char*, OsclMemAllocator>& aAppVideoFormats)
+{
+    /* Iterate over formats supported by the stack */
+    Oscl_Map<PVMFFormatType, CPvtMediaCapability*, OsclMemAllocator, pvmf_format_type_key_compare_class>::iterator it = iStackSupportedFormats.begin();
+    while (it != iStackSupportedFormats.end())
+    {
+        CPvtMediaCapability* media_capability = (*it++).second;
+        const char* format_str = NULL;
+        // Is format present in application formats ?
+        format_str = FindFormatType(media_capability->GetFormatType(), aAppAudioFormats, aAppVideoFormats);
+        if (format_str)
+        {
+            DoSelectFormat(aDir, media_capability->GetFormatType(), format_str, APP);
+        }
+        else
+        {
+            PV2WayMediaType media_type = ::GetMediaType(PVMFFormatTypeToPVCodecType(media_capability->GetFormatType()));
+            const char* can_convert_format = NULL;
+
+            if (media_type == PV_AUDIO)
+            {
+                can_convert_format = CanConvertFormat(aDir, media_capability->GetFormatType(), aAppAudioFormats);
+            }
+            else if (media_type == PV_VIDEO)
+            {
+                can_convert_format = CanConvertFormat(aDir, media_capability->GetFormatType(), aAppVideoFormats);
+            }
+
+            if (can_convert_format)
+            {
+                // Engine can convert the format using a conversion node
+                DoSelectFormat(aDir, media_capability->GetFormatType(), format_str, ENG, can_convert_format);
+            }
+            else
+            {
+                // Check if it is a mandatory codec
+                if (media_capability->IsMandatory())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "CPV324m2Way::SetPreferredCodecs, ERROR Mandatory codec=%s not supported",
+                                     (media_capability->GetFormatType()).getMIMEStrPtr()));
+                    OSCL_LEAVE(PVMFErrResource);
+                }
+            }
+        }
+    }
+}
+
+void CPV324m2Way::SetPreferredCodecs(PV2WayInitInfo& aInitInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::SetPreferredCodecs"));
+    SetPreferredCodecs(INCOMING, aInitInfo.iIncomingAudioFormats, aInitInfo.iIncomingVideoFormats);
+    SetPreferredCodecs(OUTGOING, aInitInfo.iOutgoingAudioFormats, aInitInfo.iOutgoingVideoFormats);
+}
+
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+void CPV324m2Way::HandleFFComposerNodeCmd(PV2WayNodeCmdType aType,
+        const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleFFComposerNodeCmd type %d, status %d\n",
+                     aType, aResponse.GetCmdStatus()));
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_QUERY_INTERFACE:
+            if (aResponse.GetCmdId() == iFFClipConfig.iId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iFFClipConfig.iState = PV2WayNodeInterface::HasInterface;
+                }
+                else
+                {
+                    iFFClipConfig.iState = PV2WayNodeInterface::NoInterface;
+                    iRecordFileState = File2WayResetting;
+                }
+            }
+            else if (aResponse.GetCmdId() == iFFTrackConfig.iId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iFFTrackConfig.iState = PV2WayNodeInterface::HasInterface;
+                }
+                else
+                {
+                    iFFTrackConfig.iState = PV2WayNodeInterface::NoInterface;
+                    iRecordFileState = File2WayResetting;
+                }
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_INIT:
+        case PV2WAY_NODE_CMD_START:
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                iRecordFileState = File2WayResetting;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_STOP:
+        case PV2WAY_NODE_CMD_RESET:
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::HandleFFComposerNodeCmd unhandled command\n"));
+            break;
+    }
+
+    CheckRecordFileState();
+    return;
+}
+
+void CPV324m2Way::RemoveAudioRecPath()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveAudioRecPath audio rec path state %d\n",
+                     iAudioRecDatapath->GetState()));
+    if (iAudioRecDatapath->GetState() == EClosed)
+    {
+        iAudioRecDatapath->ResetDatapath();
+    }
+}
+
+void CPV324m2Way::RemoveVideoRecPath()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveVideoRecPath video rec path state %d\n",
+                     iVideoRecDatapath->GetState()));
+    if (iVideoRecDatapath->GetState() == EClosed)
+    {
+        iVideoRecDatapath->ResetDatapath();
+    }
+}
+
+void CPV324m2Way::CheckRecordFileState()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckRecordFileState state %d\n",
+                     iRecordFileState));
+
+    switch (iRecordFileState)
+    {
+        case File2WayInitializing:
+            CheckRecordFileInit();
+            break;
+
+        case File2WayResetting:
+            CheckRecordFileReset();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "CPV324m2Way::CheckRecordFileState warning: static state!"));
+            break;
+    }
+}
+
+void CPV324m2Way::CheckRecordFileInit()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckRecordFileInit ff composer node state %d\n",
+                     iFFComposerNode->GetState()));
+
+//	int32 error;
+#if 1
+    return;
+#else
+    switch (iFFComposerNode->GetState())
+    {
+        case EPVMFNodeIdle:
+            if (iFFClipConfig.iState == PV2WayNodeInterface::NoInterface)
+            {
+                TPV2WayNodeQueryInterfaceParams queryParam;
+                queryParam.iInterfacePtr = &iFFClipConfig.iInterface;
+
+                queryParam.iUuid = (PVUuid *) & iFFClipConfigPVUuid;
+
+                OSCL_TRY(error, iFFClipConfig.iId = SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE,
+                                                    iFFComposerNode, this, &queryParam));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckRecordFileInit unable to query for ff composer clip interface!\n"));
+                                     SetState(EResetting);
+                                     CheckState();
+                                     return;);
+
+                iFFClipConfig.iState = PV2WayNodeInterface::QueryInterface;
+            }
+
+            if (iFFTrackConfig.iState == PV2WayNodeInterface::NoInterface)
+            {
+                TPV2WayNodeQueryInterfaceParams queryParam;
+                queryParam.iInterfacePtr = &iFFTrackConfig.iInterface;
+
+                queryParam.iUuid = (PVUuid *) & iFFTrackConfigPVUuid;
+
+                OSCL_TRY(error, iFFTrackConfig.iId = SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE,
+                                                     iFFComposerNode, this, &queryParam));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                                     PVLOGMSG_ERR, (0, "CPV324m2Way::CheckRecordFileInit unable to query for ff composer track interface!\n"));
+                                     SetState(EResetting);
+                                     CheckState();
+                                     return;);
+
+                iFFTrackConfig.iState = PV2WayNodeInterface::QueryInterface;
+            }
+
+            OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_INIT, iFFComposerNode, this));
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                                 PVLOGMSG_ERR, (0, "CPV324m2Way::CheckRecordFileInit unable to init ff composer node!\n"));
+                                 iRecordFileState = File2WayResetting;
+                                 CheckRecordFileState();
+                                 return;);
+            break;
+
+        case EPVMFNodeInitialized:
+            if (iFFTrackConfig.iState == PV2WayNodeInterface::HasInterface)
+            {
+                PVMp4FFCNClipConfigInterface *ptr =
+                    (PVMp4FFCNClipConfigInterface *) iFFClipConfig.iInterface;
+
+                error = ptr->SetRealTimeAuthoring(true);
+                if (error != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::CheckRecordFileInit set real time authoring failed %d\n",
+                                     error));
+                    iRecordFileState = File2WayResetting;
+                    CheckRecordFileState();
+                    return;
+                }
+
+                error = ptr->SetOutputFileName(iRecFilename);
+                if (error != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::CheckRecordFileInit set output file failed %d\n",
+                                     error));
+                    iRecordFileState = File2WayResetting;
+                    CheckRecordFileState();
+                    return;
+                }
+
+                error = ptr->SetAuthoringMode(DEFAULT_RECORDED_CALL_TYPE);
+                if (error != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::CheckRecordFileInit set authoring type %d\n",
+                                     error));
+                    iRecordFileState = File2WayResetting;
+                    CheckRecordFileState();
+                    return;
+                }
+
+                error = ptr->SetPresentationTimescale(DEFAULT_RECORDED_CALL_TIMESCALE);
+                if (error != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "CPV324m2Way::CheckRecordFileInit set timescale %d\n",
+                                     error));
+                    iRecordFileState = File2WayResetting;
+                    CheckRecordFileState();
+                    return;
+                }
+
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_START, iFFComposerNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckRecordFileInit unable to start ff composer node!\n"));
+                                     iRecordFileState = File2WayResetting;
+                                     CheckRecordFileState();
+                                     return;);
+            }
+            break;
+
+        case EPVMFNodeStarted:
+            if ((iFFClipConfig.iState == PV2WayNodeInterface::HasInterface) ||
+                    (iFFTrackConfig.iState == PV2WayNodeInterface::HasInterface))
+            {
+                iRecordFileState = File2WayInitialized;
+
+                iInitRecFileInfo->status = PVMFSuccess;
+                Dispatch(iInitRecFileInfo);
+                iInitRecFileInfo = NULL;
+            }
+            break;
+
+        default:
+            break;
+    }
+#endif
+}
+
+void CPV324m2Way::CheckRecordFileReset()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckRecordFileReset audio rec state %d, video rec state %d\n",
+                     iAudioRecDatapath->GetState(), iVideoRecDatapath->GetState()));
+
+//	int32 error;
+#if 1
+    return;
+#else
+    if ((iAudioRecDatapath->GetState() == EClosed) &&
+            (iVideoRecDatapath->GetState() == EClosed))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPV324m2Way::CheckRecordFileReset ff composer node state %d, reset rec info %x, init rec info %x, reset info %x\n",
+                         iFFComposerNode->GetState(), iResetRecFileInfo, iInitRecFileInfo, iResetInfo));
+
+        switch (iFFComposerNode->GetState())
+        {
+            case EPVMFNodeCreated:
+
+                if (iFFClipConfig.iInterface) iFFClipConfig.iInterface->removeRef();
+                iFFClipConfig.Reset();
+
+                if (iFFTrackConfig.iInterface) iFFTrackConfig.iInterface->removeRef();
+                iFFTrackConfig.Reset();
+
+                iRecordFileState = File2WayIdle;
+
+                //If no command was issued, then dispatch an error event.
+                if ((iResetRecFileInfo == NULL) &&
+                        (iInitRecFileInfo == NULL) &&
+                        (iResetInfo == NULL))
+                {
+                    TPV2WayEventInfo* aEvent = NULL;
+                    if (!GetEventInfoL(aEvent))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "CPV324m2Way::CheckRecordFileReset unable to notify app!\n"));
+                        return;
+                    }
+                    aEvent->type = PVT_INDICATION_RECORDING_ERROR;
+                    Dispatch(aEvent);
+                }
+                // If reset rec in progress
+                else if (iResetRecFileInfo)
+                {
+                    iResetRecFileInfo->status = PVMFSuccess;
+                    Dispatch(iResetRecFileInfo);
+                    iResetRecFileInfo = NULL;
+                }
+                //Else if init failed
+                else if (iInitRecFileInfo)
+                {
+                    iInitRecFileInfo->status = PVMFFailure;
+                    Dispatch(iInitRecFileInfo);
+                    iInitRecFileInfo = NULL;
+                }
+
+                //Check if reset engine was in progress
+                if (iResetInfo)
+                {
+                    CheckState();
+                }
+
+                break;
+
+            case EPVMFNodeError:
+            case EPVMFNodeInitialized:
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_RESET, iFFComposerNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckRecordFileReset unable to reset ff composer node!\n"));
+                                     return;);
+                break;
+
+            case EPVMFNodeStarted:
+                OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_STOP, iFFComposerNode, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckRecordFileReset unable to stop ff composer node!\n"));
+                                     return;);
+                break;
+
+            default:
+                break;
+        }
+    }
+#endif
+}
+
+void CPV324m2Way::InitiateResetRecordFile()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::InitiateResetRecordFile state %d, record state %d\n",
+                     iState, iRecordFileState));
+
+    iRecordFileState = File2WayResetting;
+
+    if (iAudioRecDatapath->GetState() != EClosed)
+    {
+        iAudioRecDatapath->SetCmd(NULL);
+    }
+
+    if (iVideoRecDatapath->GetState() != EClosed)
+    {
+        iVideoRecDatapath->SetCmd(NULL);
+    }
+
+    CheckRecordFileState();
+}
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+void CPV324m2Way::RemoveAudioPreviewPath()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveAudioPreviewPath audio preview path state %d\n",
+                     iAudioPreviewDatapath->GetState()));
+    if (iAudioPreviewDatapath->GetState() == EClosed)
+    {
+        iAudioPreviewDatapath->ResetDatapath();
+    }
+}
+
+void CPV324m2Way::RemoveVideoPreviewPath()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::RemoveVideoPreviewPath video preview path state %d\n",
+                     iVideoPreviewDatapath->GetState()));
+    if (iVideoPreviewDatapath->GetState() == EClosed)
+    {
+        iVideoPreviewDatapath->ResetDatapath();
+    }
+}
+
+void CPV324m2Way::HandlePFFNodeCmd(PV2WayNodeCmdType aType,
+                                   const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandlePFFNodeCmd type %d, status %d\n",
+                     aType, aResponse.GetCmdStatus()));
+
+    CPV2WayPort *port;
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_INIT:
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                iPlayFileState = File2WayResetting;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_REQUESTPORT:
+            if (aResponse.GetCmdId() == iAudioPlayPort.GetCmdId())
+            {
+                port = &iAudioPlayPort;
+            }
+            else if (aResponse.GetCmdId() == iVideoPlayPort.GetCmdId())
+            {
+                port = &iVideoPlayPort;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::HandlePFFNodeCmd unknown req port id %d\n",
+                                 aResponse.GetCmdId()));
+                iPlayFileState = File2WayResetting;
+                break;
+            }
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                port->SetPort((PVMFPortInterface *) aResponse.GetEventData());
+            }
+            else
+            {
+                port->SetPort(NULL);
+                iPlayFileState = File2WayResetting;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_START:
+        case PV2WAY_NODE_CMD_PAUSE:
+        case PV2WAY_NODE_CMD_STOP:
+            if (iPlayFileCmdInfo)
+            {
+                iPlayFileCmdInfo->status = aResponse.GetCmdStatus();
+                Dispatch(iPlayFileCmdInfo);
+                iPlayFileCmdInfo = NULL;
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_RESET:
+            CheckPlayFileState();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::HandlePFFNodeCmd unhandled command\n"));
+            break;
+    }
+
+    CheckPlayFileState();
+    return;
+}
+
+void CPV324m2Way::CheckPlayFileState()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckPlayFileState state %d\n",
+                     iRecordFileState));
+
+    switch (iPlayFileState)
+    {
+        case File2WayInitializing:
+            CheckPlayFileInit();
+            break;
+
+        case File2WayResetting:
+            CheckPlayFileReset();
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "CPV324m2Way::CheckPlayFileState warning: static state!"));
+            break;
+    }
+}
+
+void CPV324m2Way::CheckPlayFileInit()
+{
+#if 1
+    return;
+#else
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckPlayFileInit pff node state %d\n",
+                     iPlayFromFileNode->GetState()));
+
+    int32 error;
+    PVMFPortProperty prop;
+
+    switch (iPlayFromFileNode->GetState())
+    {
+        case EPVMFNodeIdle:
+            OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_INIT, iPlayFromFileNode, this));
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "CPV324m2Way::CheckPlayFileInit unable to init pff node!\n"));
+                                 iPlayFileState = File2WayResetting;
+                                 CheckPlayFileState();
+                                 return;);
+            break;
+
+        case EPVMFNodeInitialized:
+            if (iAudioPlayPort.GetStatus() == ENoPort)
+            {
+                prop.iFormatType = DEFAULT_PLAY_FROM_FILE_AUDIO;
+                prop.iPortType = PV2WAY_OUT_PORT;
+
+                OSCL_TRY(error, iAudioPlayPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_REQUESTPORT,
+                                                        iPlayFromFileNode, this, &prop)));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckPlayFileInit unable to request audio port!\n"));
+                                     iPlayFileState = File2WayResetting;
+                                     CheckPlayFileState();
+                                     return;);
+
+                iAudioPlayPort.SetStatus(ERequestPort);
+            }
+            else if (iVideoPlayPort.GetStatus() == ENoPort)
+            {
+                prop.iFormatType = DEFAULT_PLAY_FROM_FILE_VIDEO;
+                prop.iPortType = PV2WAY_OUT_PORT;
+
+                OSCL_TRY(error, iVideoPlayPort.SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_REQUESTPORT,
+                                                        iPlayFromFileNode, this, &prop)));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckPlayFileInit unable to request video port!\n"));
+                                     iPlayFileState = File2WayResetting;
+                                     CheckPlayFileState();
+                                     return;);
+
+                iVideoPlayPort.SetStatus(ERequestPort);
+            }
+            break;
+
+        default:
+            break;
+    }
+
+    CheckAudioSourceMixingPort();
+
+    if ((iAudioPlayPort.GetStatus() == EHasPort) &&
+            (iVideoPlayPort.GetStatus() == EHasPort))
+    {
+        iAudioEncDatapath->SetFilePlayPort(iAudioPlayPort.GetPort());
+        iVideoEncDatapath->SetFilePlayPort(iVideoPlayPort.GetPort());
+
+        iPlayFileState = File2WayInitialized;
+
+        iInitPlayFileInfo->status = PVMFSuccess;
+        Dispatch(iInitPlayFileInfo);
+        iInitPlayFileInfo = NULL;
+    }
+#endif
+}
+
+void CPV324m2Way::CheckPlayFileReset()
+{
+#if 1
+    return;
+#else
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckPlayFileReset\n"));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckPlayFileReset pff node state %d, reset play info %x, init play info %x, reset info %x\n",
+                     iPlayFromFileNode->GetState(), iResetPlayFileInfo,
+                     iInitPlayFileInfo, iResetInfo));
+
+    int32 error;
+
+    switch (iPlayFromFileNode->GetState())
+    {
+        case EPVMFNodeCreated:
+            break;
+
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_STOP,
+                                         iPlayFromFileNode, this));
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                                 PVLOGMSG_ERR, (0, "CPV324m2Way::CheckPlayFileReset unable to stop pff node %d!\n", error));
+                                 return;);
+            break;
+
+        case EPVMFNodeError:
+        case EPVMFNodeInitialized:
+        case EPVMFNodeStopped:
+            OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_RESET, iPlayFromFileNode, this));
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                                 PVLOGMSG_ERR, (0, "CPV324m2Way::CheckPlayFileReset unable to reset pff node %d!\n", error));
+                                 return;);
+            break;
+
+        default:
+            break;
+    }
+
+    CheckAudioSourceMixingPort();
+
+    if (iPlayFromFileNode->GetState() == EPVMFNodeCreated)
+    {
+        iAudioPlayPort.SetPort(NULL);
+        iVideoPlayPort.SetPort(NULL);
+
+        iAudioEncDatapath->SetFilePlayPort(NULL);
+        iVideoEncDatapath->SetFilePlayPort(NULL);
+
+        iPlayFileState = File2WayIdle;
+
+        //If no command was issued, then dispatch an error event.
+        if ((iResetPlayFileInfo == NULL) &&
+                (iInitPlayFileInfo == NULL) &&
+                (iResetInfo == NULL))
+        {
+            TPV2WayEventInfo* aEvent = NULL;
+            if (!GetEventInfo(aEvent))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::CheckPlayFileReset unable to notify app!\n"));
+                return;
+            }
+            aEvent->type = PVT_INDICATION_PLAY_ERROR;
+            aEvent->localBuffer[0] = (uint8) PV_MEDIA_NONE;
+            aEvent->localBufferSize = 1;
+            Dispatch(aEvent);
+        }
+        // If reset play in progress
+        else if (iResetPlayFileInfo)
+        {
+            iResetPlayFileInfo->status = PVMFSuccess;
+            Dispatch(iResetPlayFileInfo);
+            iResetPlayFileInfo = NULL;
+        }
+        //Else if init failed
+        else if (iInitPlayFileInfo)
+        {
+            iInitPlayFileInfo->status = PVMFFailure;
+            Dispatch(iInitPlayFileInfo);
+            iInitPlayFileInfo = NULL;
+        }
+
+        //Check if reset engine was in progress
+        if (iResetInfo)
+        {
+            CheckState();
+        }
+    }
+#endif
+}
+
+void CPV324m2Way::InitiateResetPlayFile()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::InitiateResetPlayFile state %d, record state %d\n",
+                     iState, iPlayFileState));
+
+    //Use play file as data source
+    if (iAudioEncDatapath->GetState() == EOpened)
+    {
+        iAudioEncDatapath->UseFilePlayPort(false);
+    }
+
+    if (iVideoEncDatapath->GetState() == EOpened)
+    {
+        iVideoEncDatapath->UseFilePlayPort(false);
+    }
+
+    iUsePlayFileAsSource = false;
+
+    iPlayFileState = File2WayResetting;
+
+    CheckPlayFileState();
+}
+
+void CPV324m2Way::CheckAudioSourceMixingPort()
+{
+#if 1
+    return;
+#else
+    PVMFPortProperty prop;
+    int32 error;
+    if (!iAudioEncDatapath)
+        return;
+    CPV2WayPort *audioPort = iAudioEncDatapath->GetSourceInputPort();
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::CheckAudioSourceMixingPort audio enc state %d, mixing port state %d, play file state %d\n",
+                     iAudioEncDatapath->GetState(), audioPort->GetStatus(), iPlayFileState));
+
+    switch (iAudioEncDatapath->GetState())
+    {
+        default:
+            switch (iPlayFileState)
+            {
+                case File2WayInitializing:
+                case File2WayInitialized:
+                    if (audioPort->GetStatus() == ENoPort)
+                    {
+                        prop.iFormatType = DEFAULT_PLAY_FROM_FILE_AUDIO;
+                        prop.iPortType = PV2WAY_IN_PORT;
+
+                        OSCL_TRY(error, audioPort->SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_REQUESTPORT,
+                                                            iAudioSrcNode, this, &prop)));
+                        OSCL_FIRST_CATCH_ANY(error,
+                                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,
+                                                             iLogger, PVLOGMSG_ERR,
+                                                             (0, "CPV324m2Way::CheckPlayFileInit unable to request audio port!\n"));
+                                             return;);
+
+                        audioPort->SetStatus(ERequestPort);
+                    }
+                    break;
+
+                default:
+                    break;
+            }
+            break;
+
+        case EClosing:
+        case EClosed:
+            break;
+    }
+
+    switch (iAudioEncDatapath->GetState())
+    {
+        case EClosing:
+        case EClosed:
+            if (audioPort->GetStatus() == EHasPort)
+            {
+                iAudioEncDatapath->UseFilePlayPort(false);
+
+                OSCL_TRY(error, audioPort->SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_RELEASEPORT,
+                                                    iAudioSrcNode, this, audioPort->GetPort())));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,
+                                                     iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckPlayFileReset unable to release audio port %d!\n", error));
+                                     return;);
+            }
+            break;
+
+        default:
+            break;
+    }
+
+    switch (iPlayFileState)
+    {
+        case File2WayIdle:
+        case File2WayResetting:
+            if (audioPort->GetStatus() == EHasPort)
+            {
+                iAudioEncDatapath->UseFilePlayPort(false);
+
+                OSCL_TRY(error, audioPort->SetCmdId(SendNodeCmdL(PV2WAY_NODE_CMD_RELEASEPORT,
+                                                    iAudioSrcNode, this, audioPort->GetPort())));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,
+                                                     iLogger, PVLOGMSG_ERR,
+                                                     (0, "CPV324m2Way::CheckPlayFileReset unable to release audio port %d!\n", error));
+                                     return;);
+
+                audioPort->SetStatus(EReleasePort);
+            }
+            break;
+
+        default:
+            break;
+    }
+#endif
+}
+
+void CPV324m2Way::HandleAudioSrcNodeCmd(PV2WayNodeCmdType aType,
+                                        const PVMFCmdResp& aResponse)
+{
+    int32 error;
+    TPV2WayEventInfo* aEvent = NULL;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                    (0, "CPV324m2Way::HandleAudioSrcNodeCmd type %d, status %d\n",
+                     aType, aResponse.GetCmdStatus()));
+
+    //The only response this handler is expecting is a request for an audio src node input port
+
+    switch (aType)
+    {
+        case PV2WAY_NODE_CMD_REQUESTPORT:
+            if (aResponse.GetCmdId() ==
+                    iAudioEncDatapath->GetSourceInputPort()->GetCmdId())
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioEncDatapath->SetSourceInputPort((PVMFPortInterface *)
+                                                          aResponse.GetEventData());
+                    iAudioEncDatapath->UseFilePlayPort(iUsePlayFileAsSource);
+                }
+                else
+                {
+                    iAudioEncDatapath->SetSourceInputPort(NULL);
+
+                    if (!GetEventInfo(aEvent))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "CPV324m2Way::HandleAudioSrcNodeCmdn unable to allocate event %d!\n",
+                                         error));
+                        return;
+                    }
+
+                    aEvent->type = PVT_INDICATION_PLAY_ERROR;
+                    aEvent->localBuffer[0] = (uint8) PV_AUDIO;
+                    aEvent->localBufferSize = 1;
+                    Dispatch(aEvent);
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::HandleAudioSrcNodeCmd unknown req port id %d\n",
+                                 aResponse.GetCmdId()));
+            }
+            break;
+
+        case PV2WAY_NODE_CMD_RELEASEPORT:
+            if (aResponse.GetCmdId() == iAudioEncDatapath->GetSourceInputPort()->GetCmdId())
+            {
+                iAudioEncDatapath->SetSourceInputPort(NULL);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "CPV324m2Way::HandleAudioSrcNodeCmd unknown req port id %d\n",
+                                 aResponse.GetCmdId()));
+            }
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "CPV324m2Way::HandleAudioSrcNodeCmd unhandled command\n"));
+            break;
+    }
+
+    CheckAudioSourceMixingPort();
+
+    // Audio encode datapath will wait for stable mixing port before continuing to close.
+    if (iAudioEncDatapath->GetState() == EClosing)
+    {
+        iAudioEncDatapath->CheckPath();
+    }
+
+    return;
+}
+#endif
+
+bool CPV324m2Way::Supports(PVMFNodeCapability &capability,
+                           PVMFFormatType aFormat,
+                           bool isInput/*=true*/)
+{
+    if (isInput)
+    {
+        for (uint16 i = 0; i < capability.iInputFormatCapability.size(); i++)
+        {
+            if (capability.iInputFormatCapability[i] == aFormat)
+                return true;
+        }
+    }
+    else
+    {
+        for (uint16 i = 0; i < capability.iOutputFormatCapability.size(); i++)
+        {
+            if (capability.iOutputFormatCapability[i] == aFormat)
+                return true;
+        }
+    }
+
+    return false;
+}
+
+int32 CPV324m2Way::GetStackNodePortTag(TPV2WayPortTagType tagType)
+{
+    switch (tagType)
+    {
+
+        case EPV2WayVideoIn:
+            if (iTerminalType == PV_324M)
+            {
+                return PV_VIDEO;
+            }
+            else
+            {
+                return -1;
+            }
+            break;
+
+        case EPV2WayAudioIn:
+            if (iTerminalType == PV_324M)
+            {
+                return PV_AUDIO;
+            }
+            else
+            {
+                return -1;
+            }
+            break;
+
+        case EPV2WayVideoOut:
+            if (iTerminalType == PV_324M)
+            {
+                return iVideoDecDatapath->GetTSCPortTag();
+            }
+            else
+            {
+                return -1;
+            }
+            break;
+
+        case EPV2WayAudioOut:
+            if (iTerminalType == PV_324M)
+            {
+                return iAudioDecDatapath->GetTSCPortTag();
+            }
+            else
+            {
+                return -1;
+            }
+            break;
+
+        default:
+            break;
+
+    }
+    return -1;
+}
+
+#ifndef NO_2WAY_324
+
+bool CPV324m2Way::AllChannelsOpened()
+{
+    return ((iIncomingAudioTrackTag != INVALID_TRACK_ID ||
+             !iIncomingAudioCodecs.size()) &&
+            (iIncomingVideoTrackTag != INVALID_TRACK_ID ||
+             !iIncomingVideoCodecs.size()) &&
+            (iOutgoingAudioTrackTag != INVALID_TRACK_ID ||
+             !iOutgoingAudioCodecs.size()) &&
+            (iOutgoingVideoTrackTag != INVALID_TRACK_ID ||
+             !iOutgoingVideoCodecs.size()));
+}
+
+#endif //NO_2WAY_324
+
+void CPV324m2Way::ConvertMapToVector(Oscl_Map < PVMFFormatType,
+                                     FormatCapabilityInfo,
+                                     OsclMemAllocator,
+                                     pvmf_format_type_key_compare_class > & aCodecs,
+                                     Oscl_Vector < FormatCapabilityInfo,
+                                     OsclMemAllocator > & aFormatCapability)
+{
+    iFormatCapability.clear();
+    Oscl_Map < PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator,
+    pvmf_format_type_key_compare_class >::iterator it;
+    it = aCodecs.begin();
+    for (it = aCodecs.begin() ; it != aCodecs.end(); it++)
+    {
+        iFormatCapability.push_back(aCodecs[(*it).first]);
+    }
+
+    aFormatCapability = iFormatCapability;
+
+}
+
+
+void CPV324m2Way::AddVideoEncoderNode(PVCodecType_t aCodec)
+{
+    int32 error;
+
+    if (iVideoEncNode != NULL)
+        return;
+#ifdef PV2WAY_USE_OMX_ENCODER
+    iVideoEncNode = TPV2WayNode(CREATE_OMX_ENC_NODE());
+    iOutgoingVideoCodecType = aCodec;
+#else
+    OSCL_UNUSED_ARG(aCodec);
+    iVideoEncNode = TPV2WayNode(CREATE_VIDEO_ENC_NODE());
+#endif // PV2WAY_USE_OMX_ENCODER
+#if 0 // mark
+    switch (aCodec)
+    {
+        case PV_VID_TYPE_H263:
+        case PV_VID_TYPE_MPEG4:
+#ifdef PV2WAY_USE_OMX_ENCODER
+            iVideoEncNode = TPV2WayNode(CREATE_OMX_ENC_NODE());
+            iOutgoingVideoCodecType = aCodec;
+#else
+            iVideoEncNode = TPV2WayNode(CREATE_VIDEO_ENC_NODE());
+#endif // PV2WAY_USE_OMX_MPEG4_ENCODER
+            break;
+        case PV_INVALID_CODEC_TYPE:
+            //Invalid codec type, do a leave with PVMFErrArgument
+            OSCL_LEAVE(PVMFErrArgument);
+            break;
+        default:
+            //Shouldn't reach this section of the code.
+            OSCL_ASSERT(0);
+            break;
+    }
+#endif // mark
+
+    if (iVideoEncNode.iNode == NULL)
+        OSCL_LEAVE(PVMFErrNoMemory);
+    InitiateSession(iVideoEncNode);
+
+    if (iVideoEncNodeInterface.iState == PV2WayNodeInterface::NoInterface)
+    {
+        TPV2WayNodeQueryInterfaceParams queryParam;
+        queryParam.iInterfacePtr = &iVideoEncNodeInterface.iInterface;
+
+        queryParam.iUuid = (PVUuid *) & iVideoEncPVUuid;
+
+        OSCL_TRY(error, iVideoEncQueryIntCmdId = SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE,
+                 &iVideoEncNode, this, &queryParam));
+        OSCL_FIRST_CATCH_ANY(error,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::CheckInit unable to query for video encoder interface!\n"));
+                             SetState(EResetting);
+                             CheckState();
+                             return;);
+
+        iVideoEncNodeInterface.iState = PV2WayNodeInterface::QueryInterface;
+    }
+
+
+}
+void CPV324m2Way::AddAudioEncoderNode()
+{
+    int32 error;
+
+    if (iAudioEncNode != NULL)
+        return;
+
+
+#ifdef PV2WAY_USE_OMX_AMR_ENCODER
+    OSCL_TRY(error, iAudioEncNode = TPV2WayNode(CREATE_OMX_ENC_NODE()));
+#else
+    OSCL_TRY(error, iAudioEncNode =
+                 TPV2WayNode(CREATE_AUDIO_ENC_NODE()););
+#endif
+    OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,
+                         iLogger, PVLOGMSG_ERR,
+                         (0, "CPV324m2Way::InitL unable to allocate audio encoder node\n")));
+
+    InitiateSession(iAudioEncNode);
+
+    if (iAudioEncNodeInterface.iState == PV2WayNodeInterface::NoInterface)
+    {
+        TPV2WayNodeQueryInterfaceParams queryParam;
+        queryParam.iInterfacePtr = &iAudioEncNodeInterface.iInterface;
+
+        queryParam.iUuid = (PVUuid *) & iAudioEncPVUuid;
+
+        OSCL_TRY(error, iAudioEncNodeInterface.iId =
+                     SendNodeCmdL(PV2WAY_NODE_CMD_QUERY_INTERFACE,
+                                  &iAudioEncNode, this, &queryParam));
+        OSCL_FIRST_CATCH_ANY(error,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,
+                                             iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::CheckInit unable to query for audio encoder interface!\n"));
+                             SetState(EResetting);
+                             CheckState();
+                             return;);
+
+        iAudioEncNodeInterface.iState = PV2WayNodeInterface::QueryInterface;
+    }
+    else if ((iAudioEncNode.iNode)->GetState() == EPVMFNodeError)
+    {
+        OSCL_TRY(error, SendNodeCmdL(PV2WAY_NODE_CMD_RESET, &iAudioEncNode, this));
+        OSCL_FIRST_CATCH_ANY(error,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                             (0, "CPV324m2Way::CheckInit unable to reset audio encoder node after error!\n"));
+                             return;);
+    }
+
+
+    // start enc datapaths that are already created
+    if (iAudioEncDatapath->GetState() != EClosed)
+    {
+        iAudioEncDatapath->CheckOpen();
+    }
+
+}
+void CPV324m2Way::AddVideoDecoderNode(PVCodecType_t aCodec, uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen)
+{
+    int32 error = 0;
+    if (iVideoDecNode != NULL)
+        return;
+
+    switch (aCodec)
+    {
+        case PV_VID_TYPE_H263:
+            iIncomingVideoCodecType = aCodec;
+#ifdef PV2WAY_USE_OMX_H263_DECODER
+            OSCL_TRY(error, iVideoDecNode = TPV2WayNode(CREATE_OMX_VIDEO_DEC_NODE()););
+#else
+            OSCL_TRY(error, iVideoDecNode = TPV2WayNode(CREATE_VIDEO_DEC_NODE()););
+#endif // PV2WAY_USE_OMX_H263_DECODER
+            break;
+        case PV_VID_TYPE_MPEG4:
+            iIncomingVideoCodecType = aCodec;
+#ifdef PV2WAY_USE_OMX_MPEG4_DECODER
+            OSCL_TRY(error, iVideoDecNode = TPV2WayNode(CREATE_OMX_VIDEO_DEC_NODE()););
+#else
+            OSCL_TRY(error, iVideoDecNode = TPV2WayNode(CREATE_VIDEO_DEC_NODE()););
+#endif // PV2WAY_USE_OMX_MPEG4_DECODER
+            break;
+        case PV_INVALID_CODEC_TYPE:
+            //Invalid codec type, do a leave with PVMFErrArgument
+            OSCL_LEAVE(PVMFErrArgument);
+            break;
+        default:
+            //Shouldn't reach this section of code
+            //If it does then it's a bug
+            OSCL_ASSERT(0);
+            break;
+    }
+
+    OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                         PVLOGMSG_ERR, (0, "CPV324m2Way::InitL unable to allocate video decoder node\n")));
+
+    OSCL_TRY(error, iVideoParserNode = TPV2WayNode(PVMFVideoParserNode::Create(aFormatSpecificInfo, aFormatSpecificInfoLen)););
+    OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                         PVLOGMSG_ERR, (0, "CPV324m2Way::InitL unable to allocate video parser node\n")));
+
+    InitiateSession(iVideoDecNode);
+    InitiateSession(iVideoParserNode);
+}
+
+void CPV324m2Way::AddAudioDecoderNode()
+{
+    int32 error;
+
+    if (iAudioDecNode != NULL)
+        return;
+
+
+
+#ifdef PV2WAY_USE_OMX_AMR_DECODER
+    OSCL_TRY(error, iAudioDecNode =
+                 TPV2WayNode(CREATE_OMX_AUDIO_DEC_NODE()););
+#else
+    OSCL_TRY(error, iAudioDecNode =
+                 TPV2WayNode(CREATE_AUDIO_DEC_NODE());
+             /*iAudioDecNode->SetClock(&iClock);*/);
+#endif // PV2WAY_USE_OMX_AMR_DECODER
+
+    OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                         PVLOGMSG_ERR, (0, "CPV324m2Way::InitL unable to allocate audio decoder node\n")));
+
+
+    InitiateSession(iAudioDecNode);
+
+
+}
+
+void CPV324m2Way::RegisterMioLatency(const char* aMimeStr,
+                                     bool aAudio,
+                                     PVMFFormatType aFmtType)
+{
+    uint32 latencyVal = 0;
+    if (aMimeStr != NULL)
+    {
+        const char* latencyStr = oscl_strstr(aMimeStr, "latency");
+        if (latencyStr != NULL)
+        {
+            const char* latVal = oscl_strstr(latencyStr, "=");
+            if (latVal != NULL)
+            {
+                latVal += 1;
+                PV_atoi(latVal, 'd', latencyVal);
+            }
+        }
+    }
+    if (aAudio)
+    {
+        iAudioLatency[(char*)aFmtType.getMIMEStrPtr()] = latencyVal;
+    }
+    else
+    {
+        iVideoLatency[(char*)aFmtType.getMIMEStrPtr()] = latencyVal;
+    }
+}
+
+uint32 CPV324m2Way::LookupMioLatency(PVMFFormatType aFmtType,
+                                     bool aAudio)
+{
+    Oscl_Map<char*, uint32, OsclMemAllocator>::iterator it;
+    if (aAudio)
+    {
+        it = iAudioLatency.find((char*)(aFmtType.getMIMEStrPtr()));
+        if (!(it == iAudioLatency.end()))
+        {
+            return (((*it).second));
+        }
+        else
+        {
+            return 0; //if no latency is specified, then default is 0
+        }
+    }
+    else
+    {
+        it = iVideoLatency.find((char*)aFmtType.getMIMEStrPtr());
+        if (!(it == iVideoLatency.end()))
+        {
+            return (((*it).second));
+        }
+        else
+        {
+            return 0; //if no latency is specified, then default is 0
+        }
+    }
+}
+
+#ifdef MEM_TRACK
+void CPV324m2Way::MemStats()
+{
+#if !(OSCL_BYPASS_MEMMGT)
+
+    OsclAuditCB auditCB;
+    OsclMemInit(auditCB);
+    if (auditCB.pAudit)
+    {
+        MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
+        if (stats)
+        {
+            printf("  numBytes %d\n", stats->numBytes);
+            printf("  peakNumBytes %d\n", stats->peakNumBytes);
+            printf("  numAllocs %d\n", stats->numAllocs);
+            printf("  peakNumAllocs %d\n", stats->peakNumAllocs);
+            printf("  numAllocFails %d\n", stats->numAllocFails);
+            printf("  totalNumAllocs %d\n", stats->totalNumAllocs);
+            printf("  totalNumBytes %d\n", stats->totalNumBytes);
+        }
+
+    }
+#endif
+}
+#endif
+
+/* This should be changed to query the node registry */
+bool CPV324m2Way::IsSupported(const PVMFFormatType& aInputFmtType, const PVMFFormatType& aOutputFmtType)
+{
+    if (aInputFmtType == PVMF_MIME_AMR_IF2)
+    {
+        if ((aOutputFmtType == PVMF_MIME_PCM8) || (aOutputFmtType == PVMF_MIME_PCM16))
+        {
+            return true;
+        }
+        return false;
+    }
+    else if ((aInputFmtType ==  PVMF_MIME_M4V) || (aInputFmtType ==  PVMF_MIME_H2632000))
+    {
+        if (aOutputFmtType == PVMF_MIME_YUV420)
+        {
+            return true;
+        }
+        return false;
+    }
+    else if ((aInputFmtType ==  PVMF_MIME_PCM8) || (aInputFmtType ==  PVMF_MIME_PCM16))
+    {
+        if (aOutputFmtType == PVMF_MIME_AMR_IF2)
+        {
+            return true;
+        }
+        return false;
+    }
+    else if ((aInputFmtType ==  PVMF_MIME_YUV420))
+    {
+        if (aOutputFmtType == PVMF_MIME_M4V || aOutputFmtType == PVMF_MIME_H2632000)
+        {
+            return true;
+        }
+        return false;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV324m2Way::IsSupported() Not supported format\n"));
+        return false;
+    }
+}
+
+/* This should be changed to query the formats from the stack */
+void CPV324m2Way::GetStackSupportedFormats()
+{
+    iStackSupportedFormats[PVMF_MIME_AMR_IF2] = OSCL_NEW(CPvtAudioCapability, (PVMF_MIME_AMR_IF2, MAX_AMR_BITRATE));
+    iStackSupportedFormats[PVMF_MIME_M4V] = OSCL_NEW(CPvtMpeg4Capability, (MAX_VIDEO_BITRATE));
+    iStackSupportedFormats[PVMF_MIME_H2632000] = OSCL_NEW(CPvtH263Capability, (MAX_VIDEO_BITRATE));
+}
+
+const char* CPV324m2Way::FindFormatType(PVMFFormatType aFormatType,
+                                        Oscl_Vector<const char*, OsclMemAllocator>& aAudioFormats,
+                                        Oscl_Vector<const char*, OsclMemAllocator>& aVideoFormats)
+{
+    PVMFFormatType aThatFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+    uint32 i = 0;
+
+    for (i = 0; i < aAudioFormats.size(); i++)
+    {
+        aThatFormatType = aAudioFormats[i];
+        if (aFormatType == aThatFormatType)
+        {
+            return aAudioFormats[i];
+        }
+    }
+
+    for (i = 0; i < aVideoFormats.size(); i++)
+    {
+        aThatFormatType  = aVideoFormats[i];
+        if (aFormatType == aThatFormatType)
+        {
+            return aVideoFormats[i];
+        }
+    }
+    return NULL;
+}
+
+const char* CPV324m2Way::CanConvertFormat(TPVDirection aDir, const PVMFFormatType& aThisFmtType, Oscl_Vector<const char*, OsclMemAllocator>& aThatFormatList)
+{
+    PVMFFormatType aInputFmtType = PVMF_MIME_FORMAT_UNKNOWN;
+    PVMFFormatType aOutputFmtType = PVMF_MIME_FORMAT_UNKNOWN;
+
+    OSCL_ASSERT(aDir == INCOMING || aDir == OUTGOING);
+
+    for (uint32 i = 0; i < aThatFormatList.size(); i++)
+    {
+        PVMFFormatType thatFmtType = aThatFormatList[i];
+        aInputFmtType = (aDir == INCOMING) ? aThisFmtType : thatFmtType;
+        aOutputFmtType = (aDir == INCOMING) ? thatFmtType : aThisFmtType;
+        if (IsSupported(aInputFmtType, aOutputFmtType))
+        {
+            return aThatFormatList[i];
+        }
+    }
+    return NULL;
+}
+
+void CPV324m2Way::DoSelectFormat(TPVDirection aDir, PVMFFormatType aFormatType, const char* aFormatStr, TPVPriority aPriority, PVMFFormatType aFormatTypeApp)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPV324m2Way::DoSelectFormat, aDir=%d, aFormatType=%s, aPriority=%d",
+                     aDir, aFormatType.getMIMEStrPtr(), aPriority));
+
+    FormatCapabilityInfo format_cap_info;
+    PV2WayMediaType media_type = GetMediaType(PVMFFormatTypeToPVCodecType(aFormatType));
+    Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class>* the_engine_map = NULL;
+    Oscl_Map<PVMFFormatType, PVMFFormatType, OsclMemAllocator, pvmf_format_type_key_compare_class>* the_app_map = NULL;
+
+    format_cap_info.dir = aDir;
+    FILL_FORMAT_INFO(aFormatType, format_cap_info);
+    format_cap_info.iPriority = aPriority;
+
+    switch (aDir)
+    {
+        case OUTGOING:
+            the_engine_map = (media_type == PV_AUDIO) ? &iOutgoingAudioCodecs : &iOutgoingVideoCodecs;
+            the_app_map = &iAppFormatForEngineFormatOutgoing;
+            break;
+        case INCOMING:
+            the_engine_map = (media_type == PV_AUDIO) ? &iIncomingAudioCodecs : &iIncomingVideoCodecs;
+            the_app_map = &iAppFormatForEngineFormatIncoming;
+            break;
+        default:
+            return;
+    }
+    (*the_engine_map)[aFormatType] = format_cap_info;
+    (*the_app_map)[aFormatType] = aFormatTypeApp;
+
+    RegisterMioLatency(aFormatStr, true, aFormatType);
+}
+
+// This function returns a priority index for each format type.
+#define PV2WAY_ENGINE_PRIORITY_INDEX_FOR_FORMAT_TYPE_START 0
+#define PV2WAY_ENGINE_PRIORITY_INDEX_FOR_FORMAT_TYPE_END 0xFF
+uint32 GetPriorityIndexForPVMFFormatType(PVMFFormatType aFormatType)
+{
+    if (aFormatType == PVMF_MIME_AMR_IF2)
+        return PV2WAY_ENGINE_PRIORITY_INDEX_FOR_FORMAT_TYPE_START;
+    else if (aFormatType == PVMF_MIME_M4V)
+        return PV2WAY_ENGINE_PRIORITY_INDEX_FOR_FORMAT_TYPE_START + 1;
+    else if (aFormatType == PVMF_MIME_H2632000)
+        return PV2WAY_ENGINE_PRIORITY_INDEX_FOR_FORMAT_TYPE_START + 2;
+    else
+        return PV2WAY_ENGINE_PRIORITY_INDEX_FOR_FORMAT_TYPE_END;
+}
diff --git a/engines/2way/src/pv_2way_engine.h b/engines/2way/src/pv_2way_engine.h
new file mode 100644
index 0000000..b1df0c1
--- /dev/null
+++ b/engines/2way/src/pv_2way_engine.h
@@ -0,0 +1,1206 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_ENGINE_H_INCLUDED
+#define PV_2WAY_ENGINE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef OSCL_TIMER_H_INCLUDED
+#include "oscl_timer.h"
+#endif
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
+
+#ifndef OSCL_BYTE_ORDER_H_INCLUDED
+#include "oscl_byte_order.h"
+#endif
+
+#ifndef PV_2WAY_INTERFACE_H_INCLUDED
+#include "pv_2way_interface.h"
+#endif
+
+#ifndef PV_2WAY_BASIC_INTERFACES_H_INCLUDE
+#include "pv_2way_basic_interfaces.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+#include "pvmp4h263encextension.h"
+#endif
+
+
+#if (defined(PV2WAY_USE_OMX_H263_DECODER) || \
+     defined(PV2WAY_USE_OMX_MPEG4_DECODER) || \
+     defined(PV2WAY_USE_OMX_H263_ENCODER) || \
+     defined(PV2WAY_USE_OMX_MPEG4_ENCODER) || \
+     defined(PV2WAY_USE_OMX_AMR_DECODER))
+#define PV2WAY_USE_OMX
+#endif
+
+#if (defined(PV2WAY_USE_OMX_H263_DECODER) || \
+     defined(PV2WAY_USE_OMX_MPEG4_DECODER))
+#define PV2WAY_USE_OMX_VIDEO_DECODER
+#endif
+
+#if (defined(PV2WAY_USE_OMX_H263_ENCODER) || \
+     defined(PV2WAY_USE_OMX_MPEG4_ENCODER) || \
+     defined(PV2WAY_USE_OMX_AMR_DECODER))
+#define PV2WAY_USE_OMX_ENCODER
+#endif
+
+// COMM and Stack related
+#ifndef NO_2WAY_324
+#ifndef TSCMAIN_H_INCLUDED // Gkl
+#include "tscmain.h"
+#endif
+#endif
+
+#define MAX_TX_AUDIO_CODECS_SUPPORTED 2
+#define MAX_RX_AUDIO_CODECS_SUPPORTED 2
+#define MAX_TX_VIDEO_CODECS_SUPPORTED 3
+#define MAX_RX_VIDEO_CODECS_SUPPORTED 3
+
+#define MAX_LOGICAL_CHANNEL_PARAMS 3
+#define MAX_PENDING_2WAY_COMMANDS 20
+#define MAX_PENDING_2WAY_EVENTS 20 // Gkl
+#define MAX_PENDING_2WAY_ERRORS 20 // Gkl
+#define MAX_PENDING_2WAY_NODE_COMMANDS 20
+#define MAX_2WAY_SOURCESINK 2
+#define MAX_SESSION_CHANNELS 4
+#define MAX_SESSION_MEDIA_CAPS MAX_SESSION_CHANNELS*2
+
+
+#if defined (__WINS__)
+#define AUDIO_INPUT_FILENAME _STRLIT("c:\\audio_in.if2")
+#define AUDIO_OUTPUT_FILENAME _STRLIT("c:\\audio_out.if2")
+#else
+#define AUDIO_INPUT_FILENAME _STRLIT("e:\\audio_in.if2")
+#define AUDIO_OUTPUT_FILENAME _STRLIT("e:\\audio_out.if2")
+#endif
+
+#define MAX_AMR_BITRATE 12200
+#define MIN_AMR_BITRATE 12200
+#define MAX_AUDIO_BITRATE 12200
+
+#define DEFAULT_MIN_IFRAME_REQ_INT 1
+#define IFRAME_REQ_TIMERID 1
+
+
+#define END_SESSION_TIMER_ID 2
+#define END_SESSION_TIMER "end_session_timer"
+#define END_SESSION_TIMER_FREQUENCY 5
+#define END_SESSION_TIMER_VALUE 3
+/* End session interval = END_SESSION_TIMER_VALUE * 1000/END_SESSION_TIMER_FREQUENCY */
+
+#define REMOTE_DISCONNECT_TIMER_ID 3
+#define REMOTE_DISCONNECT_TIMER "remote_disconnect_timer"
+#define REMOTE_DISCONNECT_TIMER_FREQUENCY 5
+#define REMOTE_DISCONNECT_TIMER_VALUE 3
+
+
+
+#define MAX_VIDEO_BITRATE 40000
+
+#define VIDEO_ENCODER_WIDTH 176
+#define VIDEO_ENCODER_HEIGHT 144
+#if defined (__WINS__)
+#define VIDEO_ENCODER_FRAME_RATE 2
+#else
+#define VIDEO_ENCODER_FRAME_RATE 7.5
+#endif
+// TBD ARI: This should be removed when capability exchange between video encoder and video source is implemented
+#define VIDEO_INPUT_FRAME_RATE VIDEO_ENCODER_FRAME_RATE
+#define VIDEO_ENCODER_BITRATE 42000
+#define VIDEO_ENCODER_RVLC 0
+#define VIDEO_ENCODER_DATA_PARTITIONING 1
+#define VIDEO_ENCODER_I_FRAME_INTERVAL 5
+#define VIDEO_ENCODER_RATE_CONTROL PVMFVEN_RATE_CONTROL_CBR
+#define VIDEO_ENCODER_INPUT_FORMAT PVMFVEN_INPUT_YUV420
+#define VIDEO_ENCODER_SEGMENT_SIZE 256
+
+//Play defaults
+#define DEFAULT_PLAY_FROM_FILE_TYPE PVMF_MIME_MPEG4FF
+#define DEFAULT_PLAY_FROM_FILE_AUDIO PVMF_MIME_AMR_IETF
+#define DEFAULT_PLAY_FROM_FILE_VIDEO PVMF_MIME_YUV420
+
+//Gkl
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+#define RECORDED_FILESIZE_NOTIFICATION_TIMERID 2
+#define MIN_RECORDED_FILESIZE_NOTIFICATION_INTERVAL 500
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+//Play defaults
+#define DEFAULT_PLAY_FROM_FILE_TYPE PVMF_MIME_MPEG4FF
+#define DEFAULT_PLAY_FROM_FILE_AUDIO PVMF_MIME_AMR_IETF
+#define DEFAULT_PLAY_FROM_FILE_VIDEO PVMF_MIME_YUV420
+#endif
+
+
+class PvmfNodesSyncControlInterface;
+typedef enum
+{
+    EPV2WayAudio = 0,
+    EPV2WayVideo,
+    EPV2WayMuxData
+} TPV2WayMediaType;
+
+typedef enum
+{
+    EPV2WayAudioIn = 0,
+    EPV2WayAudioOut,
+    EPV2WayVideoIn,
+    EPV2WayVideoOut
+} TPV2WayPortTagType;
+
+/**
+ * TPV2WayCommandType enum
+ *
+ *  Enumeration of types of commands that can be issued to the pv2way(Used internall by engine).
+ *  The comments for each command type specify the possible error codes that can be
+ *  returned with the completion of each command.  For details on each command, pls refer the
+ *  interface definition
+ *
+ **/
+
+enum TPV2WayCommandType
+{
+    /**
+     * Indicates completion of the initialization process.   If successful, the terminal
+     * should be in the ESetup state.  If failed, the pv2way remains in the
+     * Eidle state.  The derived class contains information about which
+     * components failed to initialize.
+     *
+     * The application must wait for this callback after the terminal is instantiated
+     * before calling any of the terminal APIs.
+     *
+     * If it fails, a system-wide error code is returned.
+     *
+     **/
+    PVT_COMMAND_INIT,
+    /**
+     * Indicates completion of a GetSDKInfoL call. If successful, the reference to the
+     * TPVSDKInfo struct passed in will be populated with version information pertaining
+     * to the pv2way SDK
+     * If it fails, a system-wide error code is returned.
+     *
+     **/
+    PVT_COMMAND_GET_SDK_INFO,
+    /**
+     * Indicates completion of a GetSDKModuleInfoL call. If successful, the reference to the
+     * TPVSDKModuleInfo struct passed in will be populated with version information pertaining
+     * to the currently loaded modules
+     * If it fails, a system-wide error code is returned.
+     *
+     **/
+    PVT_COMMAND_GET_SDK_MODULE_INFO,
+    /**
+     * Indicates completion of a GetPV2WayStateL call. If successful, the reference to the
+     * TPV2WayState struct passed in will be populated with current state information.
+     * If it fails, a system-wide error code is returned.
+     *
+     **/
+    PVT_COMMAND_GET_PV2WAY_STATE,
+    /**
+     * Indicates that the terminal has released all resources and is in the EIdle
+     * state.  It is now ok to de-allocate the terminal.
+     * If it fails, a system-wide error code is returned.
+     **/
+    PVT_COMMAND_RESET,
+    /**
+     * This indicates the completion status of a previously issued
+     * AddDataSourceL command.
+     *
+     * If successful, the engine will start the source and either start demuxing (COMM source)
+     * or, sending media data from the source (mic, camera etc).
+     *
+     * On failure, a system-wide error code is returned.
+     * The application may either re-try AddDataSourceL, or disconnect
+     * the call.   The application does not have to call RemoveDataSourceL.
+     *
+     * Information about the track - codec, bitrate etc.  are provided via the derived
+     * class
+     **/
+    PVT_COMMAND_ADD_DATA_SOURCE,
+    /**
+     * This  indicates the completion status of a previously issued RemoveMediaSource command.
+     *
+     * If successful, the track is closed and all resources associated with the track
+     * have been released.
+     *
+     * Once this callback is invoked for a track, the pointer to CPVTrackInfo
+     * for the track will be invalid.
+     *
+     * If it fails, a system-wide error code is returned.
+     *
+     **/
+    PVT_COMMAND_REMOVE_DATA_SOURCE,
+    /**
+     * This indicates the completion status of a previously issued
+     * AddDataSinkL command.  It also provides track information.
+     *
+     * If successful, the engine will start sending media data to the sink.
+     *
+     * If it fails, a system-wide error code is returned.
+     * The application may either re-try AddDataSinkL, or disconnect
+     * the call.   The application does not have to call RemoveMediaSink.
+     *
+     * Information about the track - codec, bitrate etc.  are provided via the derived
+     * class
+     **/
+    PVT_COMMAND_ADD_DATA_SINK,
+    /**
+     * Similar to RemoveMediaSource
+     **/
+    PVT_COMMAND_REMOVE_DATA_SINK,
+    /**
+     * Indicates completion of a pending Connect command.  If successful,
+     * the application can open the media tracks using the AddMediaSource API.
+     *
+     * If Connnect fails, a system-wide error code is returned.
+     * The application can either re-try Connect or de-allocate the terminal.
+     * The Phone application does not have to call Disconnect if ConnectComplete is
+     * called with a status that indicates failure.
+     *
+     **/
+    PVT_COMMAND_CONNECT,
+    /**
+     * Indicates completion of a pending Disconnect command.   The terminal
+     * transitions from EDisconnecting back to the ESetup state.   The Phone
+     * application may now call Connect again or reset and de-allocate the terminal.
+     * If it fails, a system-wide error code is returned.
+     *
+     **/
+    PVT_COMMAND_DISCONNECT,
+
+    /**
+     * Indicates completion of a pending Pause command.
+     *
+     **/
+    PVT_COMMAND_PAUSE,
+    /**
+     * Indicates completion of a pending Resume command.
+     *
+     **/
+    PVT_COMMAND_RESUME,
+    /**
+     * Indicates completion of a pending SetLogAppenderL command.
+     *
+     **/
+    PVT_COMMAND_SET_LOG_APPENDER,
+    /**
+     * Indicates completion of a pending RemoveLogAppenderL command.
+     *
+     **/
+    PVT_COMMAND_REMOVE_LOG_APPENDER,
+    /**
+     * Indicates completion of a pending SetLogLevel command.
+     *
+     **/
+    PVT_COMMAND_SET_LOG_LEVEL,
+    /**
+     * Indicates completion of a pending GetLogLevel command.
+     *
+     **/
+    PVT_COMMAND_GET_LOG_LEVEL,
+    /**
+     * Indicates completion of QueryUUIDL command
+     *
+     **/
+    PVT_COMMAND_QUERY_UUID,
+    /**
+     * Indicates completion of QueryInterfaceL command
+     *
+     **/
+    PVT_COMMAND_QUERY_INTERFACE,
+    /**
+     * Indicates pending Init or Connect commands were cancelled
+     *
+     **/
+    PVT_COMMAND_CANCEL_ALL_COMMANDS,
+
+    PVT_LAST_COMMAND
+};
+
+// This function returns a priority index for each format type.
+uint32 GetPriorityIndexForPVMFFormatType(PVMFFormatType aFormatType);
+
+//Priority to MP4 over H.263
+template<class Alloc> struct PV2WayRegFormatTypeCompare
+{
+    bool operator()(const PVMFFormatType& x, const PVMFFormatType& y) const
+    {
+        uint32 x_val = GetPriorityIndexForPVMFFormatType(x);
+        uint32 y_val = GetPriorityIndexForPVMFFormatType(y);
+
+        return (x_val < y_val) ? true : false;
+    }
+};
+
+class TPV2WayNotificationInfo
+{
+    public:
+        enum TPV2WayNotificationInfoType
+        {
+            EPV2WayCommandType,
+            EPV2WayEventType
+        };
+
+        TPV2WayNotificationInfo(TPV2WayNotificationInfoType aType) : notificationType(aType) {};
+        virtual ~TPV2WayNotificationInfo() {};
+
+        TPV2WayNotificationInfoType notificationType;
+};
+
+class TPV2WayCmdInfo : public TPV2WayNotificationInfo
+{
+    public:
+        TPV2WayCmdInfo() : TPV2WayNotificationInfo(EPV2WayCommandType),
+                type(PVT_COMMAND_INIT),
+                id(0),
+                contextData(NULL),
+                status(PVMFSuccess),
+                responseData(NULL),
+                responseDataSize(0),
+                iPvtCmdData(0)
+        {};
+
+        ~TPV2WayCmdInfo() {};
+
+        void Clear()
+        {
+            type = PVT_COMMAND_INIT;
+            id = 0;
+            contextData = NULL;
+            status = PVMFSuccess;
+            responseData = NULL;
+            responseDataSize = 0;
+            iPvtCmdData = 0;
+        }
+
+        TPV2WayCommandType type;
+        PVCommandId id;
+        void *contextData;
+        TPVCmnCommandStatus status;
+        void* responseData;
+        int32 responseDataSize;
+        int32 iPvtCmdData;
+};
+
+class TPV2WayEventInfo : public TPV2WayNotificationInfo
+{
+    public:
+        TPV2WayEventInfo() : TPV2WayNotificationInfo(EPV2WayEventType),
+                type(PVT_INDICATION_INCOMING_TRACK),
+                exclusivePtr(NULL),
+                localBufferSize(0)
+
+        {
+            oscl_memset(localBuffer, 0, PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+        };
+
+        ~TPV2WayEventInfo() {};
+
+        void Clear()
+        {
+            type = PVT_INDICATION_INCOMING_TRACK;
+            exclusivePtr = NULL;
+            localBufferSize = 0;
+            oscl_memset(localBuffer, 0, PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+        }
+
+        TPVTIndicationType type;
+        TPVCmnExclusivePtr exclusivePtr;
+        uint32 localBufferSize;
+        uint8 localBuffer[PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE];
+};
+
+/**
+ * TPV2WayPortStatus Class
+ *
+ * An enumeration of port status
+ **/
+typedef enum
+{
+    ENoPort = 0,
+    ERequestPort,
+    EHasPort,
+    EReleasePort
+} TPV2WayPortStatus;
+
+class CPV2WayPort
+{
+    public:
+        CPV2WayPort() : iPort(NULL),
+                iPortStatus(ENoPort),
+                iPortCmdId(0)
+        {};
+
+        ~CPV2WayPort() {};
+
+        PVMFPortInterface *GetPort()
+        {
+            return iPort;
+        }
+        TPV2WayPortStatus GetStatus()
+        {
+            return iPortStatus;
+        }
+        PVCommandId GetCmdId()
+        {
+            return iPortCmdId;
+        }
+
+        void SetPort(PVMFPortInterface *aPort)
+        {
+            if (aPort)
+            {
+                iPortStatus = EHasPort;
+            }
+            else
+            {
+                iPortStatus = ENoPort;
+            }
+            iPort = aPort;
+        }
+        void SetStatus(TPV2WayPortStatus aStatus)
+        {
+            iPortStatus = aStatus;
+        }
+        void SetCmdId(PVCommandId aId)
+        {
+            iPortCmdId = aId;
+        }
+
+    private:
+        PVMFPortInterface *iPort;
+        TPV2WayPortStatus iPortStatus;
+        PVCommandId iPortCmdId;
+};
+
+
+typedef enum
+{
+    PV2WAY_NODE_CMD_QUERY_INTERFACE,
+    PV2WAY_NODE_CMD_INIT,
+    PV2WAY_NODE_CMD_REQUESTPORT,
+    PV2WAY_NODE_CMD_PREPARE,
+    PV2WAY_NODE_CMD_START,
+    PV2WAY_NODE_CMD_PAUSE,
+    PV2WAY_NODE_CMD_STOP,
+    PV2WAY_NODE_CMD_RELEASEPORT,
+    PV2WAY_NODE_CMD_RESET,
+    PV2WAY_NODE_CMD_CANCELCMD,
+    PV2WAY_NODE_CMD_CANCELALL,
+    PV2WAY_NODE_CMD_INVALID,
+    PV2WAY_NODE_CMD_QUERY_UUID,
+    PV2WAY_NODE_CMD_SKIP_MEDIA_DATA
+}  PV2WayNodeCmdType;
+
+class TPV2WayNodeQueryInterfaceParams
+{
+    public:
+        PVUuid *iUuid;
+        PVInterface **iInterfacePtr;
+};
+
+class TPV2WayNodeQueryUuidParams
+{
+    public:
+        Oscl_Vector<PVUuid, OsclMemAllocator> *iUuids;
+        OSCL_HeapString<OsclMemAllocator> mimetype;
+};
+
+
+
+class PV2WayNodeInterface
+{
+    public:
+        typedef enum
+        {
+            NoInterface,
+            QueryInterface,
+            HasInterface
+        } InterfaceState;
+
+        PV2WayNodeInterface() : iState(NoInterface),
+                iInterface(NULL),
+                iId(0)
+        {};
+
+        ~PV2WayNodeInterface() {};
+
+        void Reset()
+        {
+            iState = NoInterface;
+            iInterface = NULL;
+            iId = 0;
+        }
+
+        InterfaceState iState;
+        PVInterface *iInterface;
+        PVMFCommandId iId;
+};
+
+class CPV2WayNodeCommandObserver
+{
+    public:
+        virtual void CommandHandler(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse) = 0;
+
+};
+
+class CPV2WayNodeContextData
+{
+    public:
+        CPV2WayNodeContextData() : iObserver(NULL),
+                iNode(NULL),
+                iContextData(NULL)
+        {};
+
+        void Clear()
+        {
+            iObserver = NULL;
+            iNode = NULL;
+            iContextData = NULL;
+        }
+
+        CPV2WayNodeCommandObserver *iObserver;
+        PVMFNodeInterface	*iNode;
+        void *iContextData;
+};
+
+class TPV2WayNodeCmdInfo
+{
+    public:
+        TPV2WayNodeCmdInfo() : type(PV2WAY_NODE_CMD_INIT),
+                id(0),
+                engineCmdInfo(NULL)
+        {};
+
+        ~TPV2WayNodeCmdInfo() {};
+
+        void Clear()
+        {
+            type = PV2WAY_NODE_CMD_INIT;
+            id = 0;
+            context.Clear();
+            engineCmdInfo = NULL;
+        }
+
+        PV2WayNodeCmdType type;
+        PVMFCommandId id;
+        CPV2WayNodeContextData context;
+        TPV2WayCmdInfo *engineCmdInfo;
+};
+
+class TPV2WayNodeRequestPortParams
+{
+    public:
+        TPV2WayNodeRequestPortParams() : portTag(-1),
+                format(PVMF_MIME_FORMAT_UNKNOWN)
+        {};
+
+        int32 portTag;
+        PVMFFormatType format;
+};
+
+class TPV2WayNode
+{
+    public:
+        TPV2WayNode() : iNode(NULL),
+                iSessionId(0)
+        {};
+
+        TPV2WayNode(PVMFNodeInterface *aNode) : iNode(aNode), iSessionId(0)
+        {};
+
+
+        TPV2WayNode(const TPV2WayNode &aNode) : iNode(aNode.iNode),
+                iSessionId(aNode.iSessionId)
+        {};
+
+        TPV2WayNode& operator=(const TPV2WayNode& a)
+        {
+            iNode = a.iNode;
+            iSessionId = a.iSessionId;
+            return *this;
+        }
+
+        void Clear()
+        {
+            iNode = NULL;
+            iSessionId = 0;
+        }
+
+        operator PVMFNodeInterface *()
+        {
+            return iNode;
+        }
+
+        PVMFSessionId GetSessionId()
+        {
+            return iSessionId;
+        }
+
+        PVMFNodeInterface *iNode;
+        PVMFSessionId iSessionId;
+};
+
+class SinkNodeIFList
+{
+    public:
+
+        SinkNodeIFList() : iSinkNode(NULL)
+                , iNodeInterface()
+
+        {};
+
+        ~SinkNodeIFList()
+        {};
+
+        SinkNodeIFList(const SinkNodeIFList& aList)
+        {
+            iSinkNode = aList.iSinkNode;
+            iNodeInterface = aList.iNodeInterface;
+        };
+
+        void Clear()
+        {
+            iSinkNode = NULL;
+            iNodeInterface.Reset();
+        }
+
+        TPV2WayNode* iSinkNode;
+        PV2WayNodeInterface iNodeInterface;
+};
+
+class PlayFromFileNode;
+class CPVDatapathNode;
+class CPV2WayDecDataChannelDatapath;
+class CPV2WayEncDataChannelDatapath;
+class CPV2WayMuxDatapath;
+class CPV2WayPreviewDatapath;
+class CPV2WayRecDatapath;
+class CPV2WayInitDatapath;
+class PVCommandStatusObserver;
+class PVInformationalEventObserver;
+class PVErrorEventObserver;
+
+class CPV2WayNodeConfigurationObserver
+{
+    public:
+        virtual PVMFStatus ConfigureNode(CPVDatapathNode *aNode) = 0;
+};
+
+class CPV324m2Way : OsclActiveObject,
+            public CPV2WayInterface,
+            public PVMFNodeCmdStatusObserver,
+            public PVMFNodeInfoEventObserver,
+            public PVMFNodeErrorEventObserver,
+            public CPV2WayNodeCommandObserver,
+            public CPV2WayNodeConfigurationObserver,
+#ifndef NO_2WAY_324
+            public TSCObserver,
+#endif
+            public OsclTimerObserver
+{
+    public:
+        OSCL_IMPORT_REF static CPV324m2Way *NewL(PVMFNodeInterface* aTsc,
+                TPVTerminalType aTerminalType,
+                PVCommandStatusObserver* aCmdStatusObserver,
+                PVInformationalEventObserver *aInfoEventObserver,
+                PVErrorEventObserver *aErrorEventObserver);
+
+        OSCL_EXPORT_REF static void Delete(CPV324m2Way *aTerminal);
+
+        PVCommandId GetSDKInfo(PVSDKInfo &aSDKInfo, OsclAny* aContextData = NULL);
+        PVCommandId GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, OsclAny* aContextData = NULL);
+        PVCommandId Init(PV2WayInitInfo& aInitInfo, OsclAny* aContextData = NULL);
+        PVCommandId Reset(OsclAny* aContextData = NULL);
+        PVCommandId AddDataSource(PVTrackId aChannelId, PVMFNodeInterface& aDataSource, OsclAny* aContextData = NULL);
+        PVCommandId RemoveDataSource(PVMFNodeInterface& aDataSource, OsclAny* aContextData = NULL);
+        PVCommandId AddDataSink(PVTrackId aChannelId, PVMFNodeInterface& aDataSink, OsclAny* aContextData = NULL);
+        PVCommandId RemoveDataSink(PVMFNodeInterface& aDataSink, OsclAny* aContextData = NULL);
+        PVCommandId Connect(const PV2WayConnectOptions& aOptions, PVMFNodeInterface* aCommServer = NULL, OsclAny* aContextData = NULL);
+        PVCommandId Disconnect(OsclAny* aContextData = NULL);
+        PVCommandId GetState(PV2WayState& aState, OsclAny* aContextData = NULL);
+        PVCommandId SetLatencyQualityTradeoff(PVMFNodeInterface& aTrack, int32 aTradeoff, OsclAny* aContextData = NULL);
+        PVCommandId Pause(PV2WayDirection aDirection, PVTrackId aTrackId, OsclAny* aContextData = NULL);
+        PVCommandId Resume(PV2WayDirection aDirection, PVTrackId aTrackId, OsclAny* aContextData = NULL);
+        PVCommandId SetLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, OsclAny* aContextData = NULL);
+        PVCommandId RemoveLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, OsclAny* aContextData = NULL);
+        PVCommandId SetLogLevel(const char* aTag, int32 aLevel, bool aSetSubtree = false, OsclAny* aContextData = NULL);
+        PVCommandId GetLogLevel(const char* aTag, int32& aLogInfo, OsclAny* aContextData = NULL);
+        //PVCommandId SendUserInput(CPVUserInput& user_input, OsclAny* aContextData = NULL);
+        //PVCommandId GetCallStatistics(CPVCmn2WayStatistics& aStats, OsclAny* aContextData = NULL);
+        PVCommandId QueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, OsclAny* aContext = NULL);
+        PVCommandId QueryUUID(const PvmfMimeString& aMimeType, Oscl_Vector<PVUuid, BasicAlloc>& aUuids,
+                              bool aExactUuidsOnly = false, OsclAny* aContextData = NULL);
+        PVCommandId CancelAllCommands(OsclAny* aContextData = NULL);
+
+        // from PVMFNodeCmdEventObserver
+        void NodeCommandCompleted(const PVMFCmdResp& aResponse);
+
+        // from PVMFNodeInfoEventObserver
+        void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent);
+
+        // from PVMFNodeErrorEventObserver
+        void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
+
+        // from CPV2WayNodeCommandObserver
+        void CommandHandler(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+
+        // from CPV2WayNodeConfigurationObserver
+        PVMFStatus ConfigureNode(CPVDatapathNode *aNode);
+
+        //TSC Observer Virtuals
+        /* Responses to commands */
+        void OutgoingChannelEstablished(TPVChannelId id, PVCodecType_t codec, uint8* fsi, uint32 fsi_len);
+        /* Unsolicited indications */
+        void ConnectComplete(PVMFStatus status);
+        void InternalError();
+        /* Requests engine to stop av codecs.  TSC will clean up logical channels by itself */
+        void DisconnectRequestReceived();
+        TPVStatusCode IncomingChannel(TPVChannelId aId,
+                                      PVCodecType_t aCodec,
+                                      uint8* aFormatSpecificInfo = NULL, uint32 aFormatSpecificInfoLen = 0);
+        void ChannelClosed(TPVDirection direction, TPVChannelId id, PVCodecType_t codec, PVMFStatus status = PVMFSuccess);
+        void RequestFrameUpdate(PVMFPortInterface *port);
+
+        // OsclTimerObserver virtuals
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+#ifndef NO_2WAY_324
+        bool AllChannelsOpened();
+#endif
+        bool Supports(PVMFNodeCapability &capability, PVMFFormatType aFormat, bool isInput = true);
+#ifdef MEM_TRACK
+        void MemStats();
+#endif
+    private:
+        CPV324m2Way();
+        ~CPV324m2Way();
+        void ClearVideoEncNode();
+        void ConstructL(PVMFNodeInterface* aTsc,
+                        TPVTerminalType aType,
+                        PVCommandStatusObserver* aCmdStatusObserver,
+                        PVInformationalEventObserver *aInfoEventObserver,
+                        PVErrorEventObserver *aErrorEventObserver);
+        void SetDefaults();
+
+        void PreInit();
+        // OsclActiveObject virtuals
+        void DoCancel();
+        void Run();
+        void Dispatch(TPV2WayCmdInfo* aCmdInfo);
+        void Dispatch(TPV2WayEventInfo* aEventInfo);
+        void SetState(PV2WayState aState)
+        {
+            iLastState = iState;
+            iState = aState;
+        }
+
+        void InitiateDisconnect();
+        void InitiateReset();
+        void CheckState();
+        void CheckInit();
+        void CheckConnect();
+        void CheckDisconnect();
+        void CheckReset();
+
+        void RemoveAudioDecPath();
+        void RemoveAudioEncPath();
+        void RemoveVideoDecPath();
+        void RemoveVideoEncPath();
+
+        void HandleCommNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void HandleTscNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void HandleVideoDecNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void HandleVideoEncNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void HandleAudioEncNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void HandleSinkNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse, TPV2WayNode* aNode);
+        void GenerateIFrame(PVMFPortInterface *aPort);
+        void RequestRemoteIFrame(PVMFPortInterface *aPort);
+
+        TPV2WayCmdInfo *GetCmdInfoL();
+        void FreeCmdInfo(TPV2WayCmdInfo *info);
+
+        TPV2WayEventInfo *GetEventInfoL();
+        void FreeEventInfo(TPV2WayEventInfo *info);
+
+        PVMFCommandId SendNodeCmdL(PV2WayNodeCmdType aCmd, TPV2WayNode *aNode,
+                                   CPV2WayNodeCommandObserver *aObserver,
+                                   void *aParam = NULL, TPV2WayCmdInfo *a2WayCmdInfo = NULL);
+
+        TPV2WayNodeCmdInfo *FindPendingNodeCmd(PVMFNodeInterface *aNode, PVMFCommandId aId);
+        void RemovePendingNodeCmd(PVMFNodeInterface *aNode, PVMFCommandId aId, bool aAllCmds = false);
+
+        void FillSDKInfo(PVSDKInfo &aSDKInfo);
+
+
+
+        int32 GetStackNodePortTag(TPV2WayPortTagType portType);
+
+        bool CheckMandatoryCodecs(const PVMFFormatType *aMandatoryList, uint32 aMandatorySize, Oscl_Vector<PVMFFormatType, OsclMemAllocator> &aCodecList);
+
+        void InitiateSession(TPV2WayNode& aNode);
+
+        void SetPreferredCodecs(PV2WayInitInfo& aInitInfo);
+
+        void SetPreferredCodecs(TPVDirection aDir,
+                                Oscl_Vector<const char*, OsclMemAllocator>& aAudioFormats,
+                                Oscl_Vector<const char*, OsclMemAllocator>& aVideoFormats);
+
+        const char* FindFormatType(PVMFFormatType aFormatType,
+                                   Oscl_Vector<const char*, OsclMemAllocator>& aAudioFormats,
+                                   Oscl_Vector<const char*, OsclMemAllocator>& aVideoFormats);
+
+        bool IsSupported(const PVMFFormatType& aInputFmtType, const PVMFFormatType& aOutputFmtType);
+
+        const char* CanConvertFormat(TPVDirection aDir, const PVMFFormatType& aThisFmtType, Oscl_Vector<const char*, OsclMemAllocator>& aThatFormatList);
+
+        void DoSelectFormat(TPVDirection aDir, PVMFFormatType aFormatType, const char* aFormatStr, TPVPriority aPriority, PVMFFormatType aFormatApp = PVMF_MIME_FORMAT_UNKNOWN);
+
+        void DoAddDataSource(TPV2WayNode& aNode, const PVMFCmdResp& aResponse);
+
+        void DoAddDataSink(TPV2WayNode& aNode, const PVMFCmdResp& aResponse);
+
+        PVCommandId DoRemoveDataSourceSink(PVMFNodeInterface& aEndPt, OsclAny* aContextData);
+
+        bool IsNodeInList(Oscl_Vector<TPV2WayNode*, OsclMemAllocator>& aList, PVMFNodeInterface* aNode);
+
+        bool IsSourceNode(PVMFNodeInterface* aNode);
+
+        bool IsSinkNode(PVMFNodeInterface* aNode);
+
+
+        TPV2WayNode* GetTPV2WayNode(Oscl_Vector<TPV2WayNode*, OsclMemAllocator>& aList, PVMFNodeInterface* aNode);
+
+        TPV2WayNode* RemoveTPV2WayNode(Oscl_Vector<TPV2WayNode*, OsclMemAllocator>& aList, PVMFNodeInterface* aNode);
+
+        bool IsNodeReset(PVMFNodeInterface& aNode);
+
+        void SupportedSinkNodeInterfaces(TPV2WayNode* aNode);
+        typedef PV2WayRegFormatTypeCompare<OsclMemAllocator> pvmf_format_type_key_compare_class;
+
+
+        void ConvertMapToVector(Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class>& aCodecs, Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& aFormatCapability);
+
+        void AddVideoEncoderNode(PVCodecType_t aCodec);
+        void AddAudioEncoderNode();
+        void AddVideoDecoderNode(PVCodecType_t aCodec, uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen);
+        void AddAudioDecoderNode();
+        void RegisterMioLatency(const char* aMimeStr, bool aAudio, PVMFFormatType aFmtType);
+        uint32 LookupMioLatency(PVMFFormatType aFmtType, bool aAudio);
+
+
+        bool GetEventInfo(TPV2WayEventInfo*& event);
+        static int32 Construct(CPV324m2Way* aRet,
+                               PVMFNodeInterface* aTsc,
+                               TPVTerminalType aTerminalType,
+                               PVCommandStatusObserver* aCmdStatusObserver,
+                               PVInformationalEventObserver *aInfoEventObserver,
+                               PVErrorEventObserver *aErrorEventObserver);
+
+        void GetStackSupportedFormats();
+        PVMFStatus EstablishChannel(TPVDirection aDir,
+                                    TPVChannelId aId,
+                                    PVCodecType_t aCodec,
+                                    uint8* fsi, uint32 fsi_len);
+#ifdef PV_USE_DSP_AMR_CODECS
+        void InitializeDsp();
+        void ReleaseDsp();
+        CPVDsp* iDsp; // owned.
+#endif // PV_USE_DSP_AMR_CODECS
+
+        // Loopback mode
+        TPVLoopbackMode iLoopbackMode;
+
+        // Current state
+        PV2WayState iState;
+        PV2WayState iLastState;
+
+        // Command status observer
+        PVCommandStatusObserver* iCmdStatusObserver;
+
+        // Observer for informational messages
+        PVInformationalEventObserver *iInfoEventObserver;
+
+        // Observer for errors
+        PVErrorEventObserver *iErrorEventObserver;
+
+        /* For milestone 2, we will not use the proxy framework.  This will be replaced for Milestone 3 */
+        Oscl_Vector<TPV2WayNotificationInfo*, BasicAlloc> iPendingNotifications;
+
+        PVCommandId iCommandId;
+
+        PVUuid iCapConfigPVUuid;
+
+        Oscl_Vector<PVUuid, OsclMemAllocator> iSipMgrNodeUuidVec;
+
+        // Video data path
+        CPV2WayEncDataChannelDatapath *iVideoEncDatapath;
+        CPV2WayDecDataChannelDatapath *iVideoDecDatapath;
+
+        // Audio data path
+        CPV2WayEncDataChannelDatapath *iAudioEncDatapath;
+        CPV2WayDecDataChannelDatapath *iAudioDecDatapath;
+
+        // COMM Datapath
+        bool iIsStackConnected;
+        CPV2WayMuxDatapath *iMuxDatapath;
+        TPV2WayNode iTscNode;
+        TSC* iTscNodePtr;
+        TPV2WayNode iCommNode;
+
+        TPV2WayNode iAudioSinkNode;
+        TPV2WayNode iAudioSrcNode;
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+        TPV2WayNode iAudioSrcSplitterNode;
+        TPV2WayNode iVideoSrcSplitterNode;
+#endif
+
+        TPV2WayNode iVideoEncNode;
+        PV2WayNodeInterface iVideoEncNodeInterface;
+
+        TPV2WayNode iVideoDecNode;
+        TPV2WayNode iVideoParserNode;
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+        TPV2WayNode iVideoDecSplitterNode;
+#endif
+
+        TPV2WayNode iAudioEncNode;
+        TPV2WayNode iAudioDecNode;
+        PV2WayNodeInterface iAudioEncNodeInterface;
+
+        PV2WayNodeInterface iClockSyncInterface;
+
+        Oscl_Vector<SinkNodeIFList, OsclMemAllocator> iSinkNodeList;
+
+        Oscl_Vector<TPV2WayNode*, OsclMemAllocator> iSourceNodes;
+        Oscl_Vector<TPV2WayNode*, OsclMemAllocator> iSinkNodes;
+
+        PVUuid iSyncControlPVUuid;
+
+        Oscl_Vector<TPV2WayCmdInfo *, BasicAlloc> iFreeCmdInfo;
+        TPV2WayCmdInfo iCmdInfo[MAX_PENDING_2WAY_COMMANDS];
+
+        Oscl_Vector<TPV2WayEventInfo *, BasicAlloc> iFreeEventInfo;
+        TPV2WayEventInfo iEventInfo[MAX_PENDING_2WAY_EVENTS];
+
+        Oscl_Vector<TPV2WayNodeCmdInfo *, BasicAlloc> iFreeNodeCmdInfo;
+        Oscl_Vector<TPV2WayNodeCmdInfo *, BasicAlloc> iPendingNodeCmdInfo;
+        TPV2WayNodeCmdInfo iNodeCmdInfo[MAX_PENDING_2WAY_NODE_COMMANDS];
+
+        // pending Init info
+        TPV2WayCmdInfo *iInitInfo;
+
+        // pending Connect info
+        TPV2WayCmdInfo *iConnectInfo;
+
+        // Is a disconnect pending ?
+        TPV2WayCmdInfo *iDisconnectInfo;
+
+        // Is a reset pending ?
+        TPV2WayCmdInfo *iResetInfo;
+
+        // Is a cancel pending ?
+        TPV2WayCmdInfo *iCancelInfo;
+
+        // Is a get session params call pending ?
+        TPV2WayCmdInfo *iSessionParamsInfo;
+
+        PVLogger *iLogger;
+
+
+        //Minimum time between making successive I frame requests (sec).
+        uint32 iMinIFrameRequestInterval;
+        OsclTimer<OsclMemAllocator> iIFrameReqTimer;
+        OsclTimer<OsclMemAllocator>* iEndSessionTimer;
+        OsclTimer<OsclMemAllocator>* iRemoteDisconnectTimer;
+        bool isIFrameReqTimerActive;
+
+#ifndef NO_2WAY_324
+        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc> iIncomingChannelParams;
+        Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class> iIncomingAudioCodecs;
+        Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class> iIncomingVideoCodecs;
+        Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class> iOutgoingAudioCodecs;
+        Oscl_Map<PVMFFormatType, FormatCapabilityInfo, OsclMemAllocator, pvmf_format_type_key_compare_class> iOutgoingVideoCodecs;
+
+        Oscl_Map<char*, uint32, OsclMemAllocator> iAudioLatency;
+        Oscl_Map<char*, uint32, OsclMemAllocator> iVideoLatency;
+
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator> iFormatCapability;
+
+        /* A list of formats supported by the stack in a certain order of priority.  This list should ideally come from the stack but
+        for now we can generate it internally in the engine and later we will have an API for the stack to return it.
+        For the current version, the list would look like this:
+        {AMR, Mpeg-4, H.263}
+        */
+        Oscl_Map<PVMFFormatType, CPvtMediaCapability*, OsclMemAllocator, pvmf_format_type_key_compare_class> iStackSupportedFormats;
+        /* App Format is the format of the Node/MIO that the application needs to pass in for an incoming/outgoing datapath.
+           These maps track which application formats are expected by the engine for formats(codecs) supported by the engine
+           for the current call.
+           */
+        Oscl_Map<PVMFFormatType, PVMFFormatType, OsclMemAllocator, pvmf_format_type_key_compare_class> iAppFormatForEngineFormatIncoming;
+        Oscl_Map<PVMFFormatType, PVMFFormatType, OsclMemAllocator, pvmf_format_type_key_compare_class> iAppFormatForEngineFormatOutgoing;
+
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator> iIncomingUserInputFormats;
+        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc> iOutgoingChannelParams;
+        int32 iIncomingAudioTrackTag;
+        int32 iIncomingVideoTrackTag;
+        int32 iOutgoingAudioTrackTag;
+        int32 iOutgoingVideoTrackTag;
+#endif
+        PVUuid iVideoEncPVUuid;
+        PVUuid iAudioEncPVUuid;
+        PVMFCommandId iVideoEncQueryIntCmdId;
+
+        typedef enum
+        {
+            File2WayIdle,
+            File2WayInitializing,
+            File2WayInitialized,
+            File2WayResetting
+        } File2WayState;
+
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+        void HandleFFComposerNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void RemoveAudioRecPath();
+        void RemoveVideoRecPath();
+        void CheckRecordFileState();
+        void CheckRecordFileInit();
+        void CheckRecordFileReset();
+        void InitiateResetRecordFile();
+
+        OSCL_wHeapString<OsclMemAllocator> iRecFilename;
+        File2WayState iRecordFileState;
+
+        // Is a init record file pending ?
+        TPV2WayCmdInfo *iInitRecFileInfo;
+
+        // Is a reset record file pending ?
+        TPV2WayCmdInfo *iResetRecFileInfo;
+
+        TPV2WayNode iFFComposerNode;
+        PV2WayNodeInterface iFFClipConfig;
+        PV2WayNodeInterface iFFTrackConfig;
+        PV2WayNodeInterface iFFSizeAndDuration;
+
+        PVUuid iFFClipConfigPVUuid;
+        PVUuid iFFTrackConfigPVUuid;
+        PVUuid iFFSizeAndDurationPVUuid;
+        CPV2WayRecDatapath *iAudioRecDatapath;
+        CPV2WayRecDatapath *iVideoRecDatapath;
+
+        uint32 iRecFileSizeNotificationInterval; //Interval in msec
+        OsclTimer<OsclMemAllocator> iRecFileSizeNotificationTimer;
+        bool isRecFileSizeNotificationTimerActive;
+#endif
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+        void RemoveAudioPreviewPath();
+        void RemoveVideoPreviewPath();
+
+        CPV2WayPreviewDatapath *iAudioPreviewDatapath;
+        CPV2WayPreviewDatapath *iVideoPreviewDatapath;
+
+        void HandlePFFNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+        void CheckPlayFileState();
+        void CheckPlayFileInit();
+        void CheckPlayFileReset();
+        void InitiateResetPlayFile();
+        void CheckAudioSourceMixingPort();
+        void HandleAudioSrcNodeCmd(PV2WayNodeCmdType aType, const PVMFCmdResp& aResponse);
+
+        OSCL_wHeapString<OsclMemAllocator> iPlayFilename;
+        File2WayState iPlayFileState;
+        bool iUsePlayFileAsSource;
+
+        // Is a init play file pending ?
+        TPV2WayCmdInfo *iInitPlayFileInfo;
+
+        // Is a reset play file pending ?
+        TPV2WayCmdInfo *iResetPlayFileInfo;
+
+        // Play file cmd ?
+        TPV2WayCmdInfo *iPlayFileCmdInfo;
+
+        PlayFromFileNode *iPlayFromFileNode;
+        CPV2WayPort iAudioPlayPort;
+        CPV2WayPort iVideoPlayPort;
+#endif
+
+        /* Common clock to be shared with nodes that support the PvmfNodesSyncControlInterface interface */
+        PVMFMediaClock iClock;
+        PVMFTimebase_Tickcount iTickCountTimeBase;
+
+        friend class CPV2WayCmdControlDatapath;
+        friend class CPV2WayDatapath;
+        friend class CPV2WayDataChannelDatapath;
+        friend class CPV2WayDecDataChannelDatapath;
+        friend class CPV2WayEncDataChannelDatapath;
+        friend class CPV2WayMuxDatapath;
+
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+        friend class CPV2WayPreviewDatapath;
+#endif
+
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+        friend class CPV2WayRecDatapath;
+#endif
+
+        TSC *iTSCInterface;
+        TSC_324m *iTSC324mInterface;
+
+        TPVTerminalType iTerminalType;
+
+        int32 iPendingTscReset;
+        int32 iPendingAudioEncReset;
+        int32 iPendingVideoEncReset;
+        int32 iAudioDatapathLatency;
+        int32 iVideoDatapathLatency;
+
+        /* The AddDataSource command for video will be pending untill the extension interface for the encoder is queried and the
+            encoder is configured */
+        TPV2WayCmdInfo *iAddDataSourceVideoCmd;
+
+        PVCodecType_t iIncomingVideoCodecType;
+        PVCodecType_t iOutgoingVideoCodecType;
+};
+
+#endif
+
diff --git a/engines/2way/src/pv_2way_engine_factory.cpp b/engines/2way/src/pv_2way_engine_factory.cpp
new file mode 100644
index 0000000..63baeb8
--- /dev/null
+++ b/engines/2way/src/pv_2way_engine_factory.cpp
@@ -0,0 +1,63 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_base.h"
+#include "oscl_scheduler.h"
+#include "pv_2way_engine_factory.h"
+#include "pv_2way_engine.h"
+
+OSCL_EXPORT_REF void CPV2WayEngineFactory::Init()
+{
+    // initialize Oscl and PVlogger ASAP in each thread
+    OsclBase::Init();
+    OsclMem::Init();
+    PVLogger::Init();
+}
+
+OSCL_EXPORT_REF void CPV2WayEngineFactory::Cleanup()
+{
+    PVLogger::Cleanup();
+    OsclMem::Cleanup();
+    OsclBase::Cleanup();
+}
+
+OSCL_EXPORT_REF CPV2WayInterface *CPV2WayEngineFactory::CreateTerminal(PV2WayTerminalType aTerminalType,
+        PVCommandStatusObserver* aCmdStatusObserver,
+        PVInformationalEventObserver *aInfoEventObserver,
+        PVErrorEventObserver *aErrorEventObserver)
+{
+
+    if (aTerminalType == PV_324M ||
+            aTerminalType == PV_SIP)
+    {
+        return CPV324m2Way::NewL(NULL,
+                                 aTerminalType,
+                                 aCmdStatusObserver,
+                                 aInfoEventObserver,
+                                 aErrorEventObserver);
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF void CPV2WayEngineFactory::DeleteTerminal(CPV2WayInterface* terminal)
+{
+    CPV324m2Way::Delete((CPV324m2Way*) terminal);
+}
diff --git a/engines/2way/src/pv_2way_generate_version_file_main.cpp b/engines/2way/src/pv_2way_generate_version_file_main.cpp
new file mode 100644
index 0000000..472859d
--- /dev/null
+++ b/engines/2way/src/pv_2way_generate_version_file_main.cpp
@@ -0,0 +1,26 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/* A stub main file added in project generate_version_file.
+ * The project creates the sdkinfo header by running a bat file
+ * in the Custom Build Steps.
+ */
+
+int main(void)
+{
+    return 0;
+}
diff --git a/engines/2way/src/pv_2way_interface_cmd_messages.h b/engines/2way/src/pv_2way_interface_cmd_messages.h
new file mode 100644
index 0000000..6697339
--- /dev/null
+++ b/engines/2way/src/pv_2way_interface_cmd_messages.h
@@ -0,0 +1,323 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PV_2WAY_INTERFACE_CMD_MESSAGES_H_INCLUDED
+#define PV_2WAY_INTERFACE_CMD_MESSAGES_H_INCLUDED
+
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+
+#ifndef PV_INTERFACE_MESSAGE_H_INCLUDED
+#include "pv_interface_cmd_message.h"
+#endif
+
+#ifndef PV_2WAY_INTERFACE_H_INCLUDED
+#include "pv_2way_interface.h"
+#endif
+
+#ifndef PV_2WAY_ENGINE_H_INCLUDED
+#include "pv_2way_engine.h"
+#endif
+
+/*
+#ifndef PV_2WAY_SYMBIAN_INTERFACE_H_INCLUDED
+#include "pv_2way_symbian_interface.h"
+#endif
+
+#ifndef PV_COMMON_SYMBIAN_TYPES_H_INCLUDED
+#include "pv_common_symbian_types.h"
+#endif
+*/
+
+class PV2WayMessageGetSDKInfo : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageGetSDKInfo(PVSDKInfo &aSDKInfo, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_GET_SDK_INFO, aContextData)
+                , iSDKInfo(aSDKInfo)
+        {
+        }
+
+        PVSDKInfo &iSDKInfo;
+};
+
+class PV2WayMessageGetSDKModuleInfo : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageGetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_GET_SDK_MODULE_INFO, aContextData)
+                , iSDKModuleInfo(aSDKModuleInfo)
+        {
+        }
+
+        PVSDKModuleInfo &iSDKModuleInfo;
+};
+
+
+class PV2WayMessageInit : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageInit(PV2WayInitInfo& aInitInfo, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_INIT, aContextData)
+                , iInitInfo(aInitInfo)
+        {
+        }
+
+        PV2WayInitInfo& iInitInfo;
+};
+
+class PV2WayMessageReset : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageReset(OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_RESET, aContextData)
+        {
+        }
+
+};
+
+class PV2WayMessageAddDataSource : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageAddDataSource(PVTrackId aTrackId, PVMFNodeInterface& aDataSource, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_ADD_DATA_SOURCE, aContextData)
+                , iTrackId(aTrackId)
+                , iDataSource(aDataSource)
+        {
+        }
+
+        PVTrackId iTrackId;
+        PVMFNodeInterface& iDataSource;
+};
+
+class PV2WayMessageRemoveDataSource : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageRemoveDataSource(PVMFNodeInterface& aDataSource, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_REMOVE_DATA_SOURCE, aContextData)
+                , iDataSource(aDataSource)
+        {
+        }
+
+        PVMFNodeInterface& iDataSource;
+};
+
+class PV2WayMessageAddDataSink : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageAddDataSink(PVTrackId aTrackId, PVMFNodeInterface& aDataSink, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_ADD_DATA_SINK, aContextData)
+                , iTrackId(aTrackId)
+                , iDataSink(aDataSink)
+        {
+        }
+
+        PVTrackId iTrackId;
+        PVMFNodeInterface& iDataSink;
+};
+
+class PV2WayMessageRemoveDataSink : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageRemoveDataSink(PVMFNodeInterface& aDataSink, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_REMOVE_DATA_SINK, aContextData)
+                , iDataSink(aDataSink)
+        {
+        }
+
+        PVMFNodeInterface& iDataSink;
+};
+
+class PV2WayMessageConnect : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageConnect(const PV2WayConnectOptions& aOptions, PVMFNodeInterface* aCommServer, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_CONNECT, aContextData)
+                , iConnectOptions(aOptions),
+                iCommServer(aCommServer)
+        {
+        }
+
+        const PV2WayConnectOptions& iConnectOptions;
+        PVMFNodeInterface* iCommServer;
+};
+
+
+class PV2WayMessageDisconnect : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageDisconnect(OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_DISCONNECT, aContextData)
+        {
+        }
+
+};
+
+class PV2WayMessageGetPV2WayState : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageGetPV2WayState(PV2WayState& aState, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_GET_PV2WAY_STATE, aContextData)
+                , iState(aState)
+        {
+        }
+
+        PV2WayState& iState;
+};
+
+
+class PV2WayMessagePause : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessagePause(PV2WayDirection aDirection, PVTrackId aTrackId, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_PAUSE, aContextData)
+                , iDirection(aDirection)
+                , iTrackId(aTrackId)
+        {
+        }
+
+        PV2WayDirection iDirection;
+        PVTrackId iTrackId;
+};
+
+
+class PV2WayMessageResume : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageResume(PV2WayDirection aDirection, PVTrackId aTrackId, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_RESUME, aContextData)
+                , iDirection(aDirection)
+                , iTrackId(aTrackId)
+        {
+        }
+
+        PV2WayDirection iDirection;
+        PVTrackId iTrackId;
+};
+
+
+class PV2WayMessageSetLogAppender : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageSetLogAppender(OsclSharedPtr<char> &aTag, OsclSharedPtr<PVLoggerAppender> &aAppender, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_SET_LOG_APPENDER, aContextData)
+                , iTag(aTag)
+                , iAppender(aAppender)
+        {
+        }
+
+        OsclSharedPtr<char> iTag;
+        OsclSharedPtr<PVLoggerAppender> iAppender;
+};
+
+
+class PV2WayMessageRemoveLogAppender : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageRemoveLogAppender(OsclSharedPtr<char> &aTag, OsclSharedPtr<PVLoggerAppender> &aAppender, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_REMOVE_LOG_APPENDER, aContextData)
+                , iTag(aTag)
+                , iAppender(aAppender)
+        {
+        }
+
+        OsclSharedPtr<char> iTag;
+        OsclSharedPtr<PVLoggerAppender> iAppender;
+};
+
+
+class PV2WayMessageSetLogLevel : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageSetLogLevel(OsclSharedPtr<char> &aTag, int32 aLevel, bool aSetSubtree, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_SET_LOG_LEVEL, aContextData)
+                , iTag(aTag)
+                , iSetSubtree(aSetSubtree)
+                , iLevel(aLevel)
+        {
+        }
+
+        OsclSharedPtr<char> iTag;
+        bool iSetSubtree;
+        int32 iLevel;
+};
+
+
+class PV2WayMessageGetLogLevel : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageGetLogLevel(OsclSharedPtr<char> &aTag, int32& aLogLevel, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_GET_LOG_LEVEL, aContextData)
+                , iTag(aTag)
+                , iLogLevel(aLogLevel)
+
+        {
+        }
+
+        OsclSharedPtr<char> iTag;
+        int32& iLogLevel;
+};
+
+class PV2WayMessageQueryUUID : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageQueryUUID(const PvmfMimeString& aMimeType, Oscl_Vector<PVUuid, BasicAlloc> &aUuids, bool aExactUuidsOnly, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_QUERY_UUID, aContextData)
+                , iMimeType(aMimeType)
+                , iUuids(aUuids)
+                , iExactUuidsOnly(aExactUuidsOnly)
+
+        {
+        }
+
+        const PvmfMimeString&  iMimeType;
+        Oscl_Vector<PVUuid, BasicAlloc> &iUuids;
+        bool iExactUuidsOnly;
+};
+
+
+class PV2WayMessageQueryInterface : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageQueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_QUERY_INTERFACE, aContextData)
+                , iUuid(aUuid)
+                , iInterfacePtr(aInterfacePtr)
+        {
+        }
+
+        PVUuid iUuid;
+        PVInterface* &iInterfacePtr;
+};
+
+class PV2WayMessageCancelAllCommands : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PV2WayMessageCancelAllCommands(OsclAny* aContextData)
+                : CPVCmnInterfaceCmdMessage(PVT_COMMAND_CANCEL_ALL_COMMANDS, aContextData)
+        {
+        }
+
+};
+
+#endif
+
+
+
+
diff --git a/engines/2way/src/pv_2way_mux_datapath.cpp b/engines/2way/src/pv_2way_mux_datapath.cpp
new file mode 100644
index 0000000..598fac4
--- /dev/null
+++ b/engines/2way/src/pv_2way_mux_datapath.cpp
@@ -0,0 +1,67 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_mux_datapath.h"
+
+CPV2WayMuxDatapath *CPV2WayMuxDatapath::NewL(PVLogger *aLogger,
+        PVMFFormatType aFormat,
+        CPV324m2Way *a2Way)
+{
+    CPV2WayMuxDatapath *self = OSCL_NEW(CPV2WayMuxDatapath, (aLogger, aFormat, a2Way));
+    OsclError::LeaveIfNull(self);
+
+    if (self)
+    {
+        OSCL_TRAPSTACK_PUSH(self);
+        self->ConstructL();
+    }
+
+    OSCL_TRAPSTACK_POP();
+    return self;
+}
+
+void CPV2WayMuxDatapath::OpenComplete()
+{
+    i2Way->CheckConnect();
+}
+
+void CPV2WayMuxDatapath::PauseComplete()
+{
+    //Mux cannot pause
+}
+
+void CPV2WayMuxDatapath::ResumeComplete()
+{
+    //Mux cannot resume
+}
+
+void CPV2WayMuxDatapath::CloseComplete()
+{
+    i2Way->iIsStackConnected = false;
+    i2Way->CheckDisconnect();
+}
+
+void CPV2WayMuxDatapath::DatapathError()
+{
+    i2Way->SetState(EDisconnecting);
+    Close();
+}
+
+
+
+
+
diff --git a/engines/2way/src/pv_2way_mux_datapath.h b/engines/2way/src/pv_2way_mux_datapath.h
new file mode 100644
index 0000000..489ac20
--- /dev/null
+++ b/engines/2way/src/pv_2way_mux_datapath.h
@@ -0,0 +1,56 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_MUX_DATAPATH_H_INCLUDED
+#define PV_2WAY_MUX_DATAPATH_H_INCLUDED
+
+
+#ifndef PV_2WAY_DATAPATH_H_INCLUDED
+#include "pv_2way_datapath.h"
+#endif
+
+class CPV2WayMuxDatapath : public CPV2WayDatapath
+{
+    public:
+        static CPV2WayMuxDatapath *NewL(PVLogger *aLogger,
+                                        PVMFFormatType aFormat,
+                                        CPV324m2Way *a2Way);
+
+        virtual ~CPV2WayMuxDatapath() {};
+        virtual bool SingleNodeOpen()
+        {
+            return (i2Way->iTerminalType == PV_SIP);
+        };
+
+    private:
+        CPV2WayMuxDatapath(PVLogger *aLogger,
+                           PVMFFormatType aFormat,
+                           CPV324m2Way *a2Way) : CPV2WayDatapath(aLogger, EMuxDatapath, aFormat, a2Way)
+        {};
+
+        void OpenComplete();
+        void PauseComplete();
+        void ResumeComplete();
+        void CloseComplete();
+
+        void DatapathError();
+};
+
+
+#endif //PV_2WAY_MUX_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_preview_datapath.cpp b/engines/2way/src/pv_2way_preview_datapath.cpp
new file mode 100644
index 0000000..c89bbc8
--- /dev/null
+++ b/engines/2way/src/pv_2way_preview_datapath.cpp
@@ -0,0 +1,250 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if defined(PV_PLAY_FROM_FILE_SUPPORT)
+#include "pv_2way_preview_datapath.h"
+
+CPV2WayPreviewDatapath *CPV2WayPreviewDatapath::NewL(PVLogger *aLogger,
+        TPV2WayMediaType aFormat,
+        CPV324m2Way *a2Way)
+{
+    CPV2WayPreviewDatapath *self = OSCL_NEW(CPV2WayPreviewDatapath, (aLogger, aFormat, a2Way));
+    OsclError::LeaveIfNull(self);
+
+    if (self)
+    {
+        OSCL_TRAPSTACK_PUSH(self);
+        self->ConstructL();
+    }
+
+    OSCL_TRAPSTACK_POP();
+    return self;
+}
+
+void CPV2WayPreviewDatapath::CheckPause()
+{
+    uint32 i;
+    int32 error;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        if (!iNodeList[i].iCanNodePause) continue;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause node %d state %d\n", i, iNodeList[i].iNode.iNode->GetState()));
+        switch (iNodeList[i].iNode.iNode->GetState())
+        {
+            case EPVMFNodeStarted:
+                OSCL_TRY(error, i2Way->SendNodeCmdL(PV2WAY_NODE_CMD_PAUSE, &(iNodeList[i].iNode), this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckPause unable to pause node\n"));
+                                     DatapathError();
+                                     return;);
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause transitional node state!\n"));
+                break;
+        }
+    }
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        //If possible pause node is not paused.
+        if (iNodeList[i].iCanNodePause && (iNodeList[i].iNode.iNode->GetState() != EPVMFNodePaused))
+        {
+            return;
+        }
+    }
+
+    //Disconnect ports
+    for (i = 0; i < iPortPairList.size(); i++)
+    {
+        iPortPairList[i].Disconnect();
+    }
+
+    //If reached this point then the datapath is deemed paused, notify upper layer.
+    SetState(EPaused);
+    PauseComplete();
+    return;
+}
+
+void CPV2WayPreviewDatapath::CheckResume()
+{
+    uint32 i;
+    int32 error;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        if (!iNodeList[i].iCanNodePause) continue;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume node %d state %d\n", i, iNodeList[i].iNode.iNode->GetState()));
+        switch (iNodeList[i].iNode.iNode->GetState())
+        {
+            case EPVMFNodePaused:
+                OSCL_TRY(error, i2Way->SendNodeCmdL(PV2WAY_NODE_CMD_START, &(iNodeList[i].iNode), this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckResume unable to pause node\n"));
+                                     DatapathError();
+                                     return;);
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume transitional node state!\n"));
+                break;
+        }
+    }
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        //If possible pause node is not started.
+        if (iNodeList[i].iCanNodePause && (iNodeList[i].iNode.iNode->GetState() != EPVMFNodeStarted))
+        {
+            return;
+        }
+    }
+
+    //Reconnect ports
+    for (i = 0; i < iPortPairList.size(); i++)
+    {
+        iPortPairList[i].Connect();
+    }
+
+    //If reached this point then the datapath is deemed resumed, notify upper layer.
+    SetState(EOpened);
+    ResumeComplete();
+    return;
+}
+
+bool CPV2WayPreviewDatapath::SetCmd(TPV2WayCmdInfo *aCmdInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayPreviewDatapath::SetCmd state %d cmd %x\n", iState, aCmdInfo));
+
+    if (aCmdInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayPreviewDatapath::SetCmd cmd type %d\n", aCmdInfo->type));
+        switch (aCmdInfo->type)
+        {
+#if 0
+            case PVT_COMMAND_ADD_PREVIEW_SINK:
+                if (iState == EOpening) return false;
+                iCmdInfo = aCmdInfo;
+                Open();
+                break;
+
+            case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+                if (!CloseDatapath(aCmdInfo)) return false;
+                break;
+
+            case PVT_COMMAND_PAUSE_PREVIEW_SINK:
+                if (iState == EPausing) return false;
+                iCmdInfo = aCmdInfo;
+                Pause();
+                break;
+
+            case PVT_COMMAND_RESUME_PREVIEW_SINK:
+                if (iState == EUnpausing) return false;
+                iCmdInfo = aCmdInfo;
+                Resume();
+                break;
+#endif
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayPreviewDatapath::SetCmd invalid command\n"));
+                break;
+        }
+
+    }
+    // A null pointer indicates a close for some reason
+    else
+    {
+        if (!CloseDatapath(aCmdInfo)) return false;
+    }
+
+    return true;
+}
+
+void CPV2WayPreviewDatapath::OpenComplete()
+{
+    CommandComplete(PVMFSuccess);
+}
+
+void CPV2WayPreviewDatapath::CloseComplete()
+{
+    //If parent was closing, then let it notify the app.
+    if (!IsParentClosing())
+    {
+        //If a command was issued
+        if (iCmdInfo)
+        {
+            //If remove command was issued
+            if (iCmdInfo->type == PVT_COMMAND_REMOVE_PREVIEW_SINK)
+            {
+                CommandComplete(PVMFSuccess);
+            }
+            //Else other command failed
+            else
+            {
+                CommandComplete(PVMFFailure);
+            }
+        }
+        else
+        {
+            int32 error;
+            TPV2WayEventInfo* aEvent = NULL;
+            OSCL_TRY(error, aEvent = i2Way->GetEventInfoL());
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayPreviewDatapath::CloseComplete unable to notify app!\n"));
+                                 return);
+
+            aEvent->type = PVT_INDICATION_PREVIEW_ERROR;
+            aEvent->localBuffer[2] = 0;
+            switch (iFormat)
+            {
+                case PV2WayAudio:
+                    aEvent->localBuffer[0] = PV_AUDIO;
+                    break;
+                case PV2WayVideo:
+                    aEvent->localBuffer[0] = PV_VIDEO;
+                    break;
+                case PV2WayMuxData:
+                default:
+                    break;
+            }
+
+            aEvent->localBufferSize = 2;
+            i2Way->Dispatch(aEvent);
+        }
+    }
+}
+
+void CPV2WayPreviewDatapath::DatapathError()
+{
+    SetCmd(NULL);
+}
+
+bool CPV2WayPreviewDatapath::ParentIsClosing()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayPreviewDatapath::ParentIsClosing path state %d\n", iState));
+    return SetCmd(NULL);
+}
+
+#endif
+
+
diff --git a/engines/2way/src/pv_2way_preview_datapath.h b/engines/2way/src/pv_2way_preview_datapath.h
new file mode 100644
index 0000000..eab0a0b
--- /dev/null
+++ b/engines/2way/src/pv_2way_preview_datapath.h
@@ -0,0 +1,70 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_PREVIEW_DATAPATH_H_INCLUDED
+#define PV_2WAY_PREVIEW_DATAPATH_H_INCLUDED
+
+
+#ifndef PV_2WAY_DATAPATH_H_INCLUDED
+#include "pv_2way_datapath.h"
+#endif
+
+#ifndef PV_2WAY_CMD_CONTROL_DATAPATH_H_INCLUDED
+#include "pv_2way_cmd_control_datapath.h"
+#endif
+
+class CPV2WayPreviewDatapath : public CPV2WayCmdControlDatapath
+{
+    public:
+        static CPV2WayPreviewDatapath *NewL(PVLogger *aLogger,
+                                            TPV2WayMediaType aFormat,
+                                            CPV324m2Way *a2Way);
+
+        virtual ~CPV2WayPreviewDatapath() {};
+
+        bool SetCmd(TPV2WayCmdInfo *aCmdInfo);
+
+    private:
+        CPV2WayPreviewDatapath(PVLogger *aLogger,
+                               TPV2WayMediaType aFormat,
+                               CPV324m2Way *a2Way) : CPV2WayCmdControlDatapath(aLogger, EPreviewDatapath, aFormat, a2Way)
+        {};
+
+        //Override base virtuals
+        void CheckPause();
+        void CheckResume();
+
+        void OpenComplete();
+        void PauseComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void ResumeComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void CloseComplete();
+
+        void DatapathError();
+
+        bool ParentIsClosing();
+};
+
+
+#endif //PV_2WAY_PREVIEW_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_proxy_adapter.cpp b/engines/2way/src/pv_2way_proxy_adapter.cpp
new file mode 100644
index 0000000..6487b0d
--- /dev/null
+++ b/engines/2way/src/pv_2way_proxy_adapter.cpp
@@ -0,0 +1,1030 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "pv_2way_proxy_adapter.h"
+#include "pvlogger.h"
+#include "pvt_common.h"
+#include "pv_2way_engine_factory.h"
+#include "oscl_error_trapcleanup.h"
+
+#define DEFAULT_2WAY_STACK_SIZE 8192
+
+void PVCmnCmdRespMsg::Set(PVCommandId aId,
+                          void *aContext,
+                          PVMFStatus aStatus,
+                          OsclAny* aEventData,
+                          int32 aEventDataSize)
+{
+    OSCL_UNUSED_ARG(aEventDataSize);
+    iId = aId;
+    iContext = aContext;
+    iStatus = aStatus;
+    iEventData = aEventData;
+    //iEventDataSize = aEventDataSize;
+}
+
+void PVCmnAsyncEventMsg::Set(const PVAsyncInformationalEvent& aEvent, PVEventType aType,
+                             PVExclusivePtr aPtr,
+                             uint8 *aBuffer,
+                             uint32 aBufferSize)
+{
+    iEventType = aType;
+    iEventData = aPtr;
+    iEventExtInterface = aEvent.GetEventExtensionInterface();
+    if (aBuffer)
+    {
+        if (aBufferSize > PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE)
+        {
+            oscl_memcpy(iLocalBuffer, aBuffer, PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+        }
+        else
+        {
+            oscl_memcpy(iLocalBuffer, aBuffer, aBufferSize);
+        }
+    }
+}
+
+void PVCmnAsyncErrorEvent::Set(PVEventType aEventType,
+                               PVExclusivePtr aEventData,
+                               uint8* aLocalBuffer,
+                               int32 aLocalBufferSize)
+{
+    iEventType = aEventType;
+    iEventData = aEventData;
+    if (aLocalBuffer)
+    {
+        if (aLocalBufferSize > PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE)
+        {
+            oscl_memcpy(iLocalBuffer, aLocalBuffer, PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+        }
+        else
+        {
+            oscl_memcpy(iLocalBuffer, aLocalBuffer, aLocalBufferSize);
+        }
+    }
+}
+
+CPV2WayProxyAdapter *CPV2WayProxyAdapter::New(TPVTerminalType aTerminalType,
+        PVCommandStatusObserver* aCmdStatusObserver,
+        PVInformationalEventObserver *aInfoEventObserver,
+        PVErrorEventObserver *aErrorEventObserver)
+//called by the factory to create a new proxied 2way interface.
+{
+    int32 error;
+    CPV2WayProxyAdapter* aRet = OSCL_NEW(CPV2WayProxyAdapter, ());
+    if (aRet)
+    {
+        error = Construct(aRet, aTerminalType, aCmdStatusObserver,
+                          aInfoEventObserver,
+                          aErrorEventObserver);
+        if (error)
+        {
+            OSCL_DELETE(aRet);
+            aRet = NULL;
+            OSCL_LEAVE(error);
+        }
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    return aRet;
+}
+
+int32 CPV2WayProxyAdapter::Construct(CPV2WayProxyAdapter*& aRet,
+                                     TPVTerminalType aTerminalType,
+                                     PVCommandStatusObserver* aCmdStatusObserver,
+                                     PVInformationalEventObserver *aInfoEventObserver,
+                                     PVErrorEventObserver *aErrorEventObserver)
+{
+    int32 error;
+    OSCL_TRY(error, aRet->ConstructL(aTerminalType,
+                                     aCmdStatusObserver,
+                                     aInfoEventObserver,
+                                     aErrorEventObserver));
+    return error;
+}
+
+OsclAny CPV2WayProxyAdapter::ConstructL(TPVTerminalType aTerminalType,
+                                        PVCommandStatusObserver* aCmdStatusObserver,
+                                        PVInformationalEventObserver *aInfoEventObserver,
+                                        PVErrorEventObserver *aErrorEventObserver)
+{
+    OSCL_UNUSED_ARG(aTerminalType);
+    iCmdStatusObserver = aCmdStatusObserver;
+    iInfoEventObserver = aInfoEventObserver;
+    iErrorEventObserver = aErrorEventObserver;
+
+    int32 i;
+    for (i = 0; i < MAX_PENDING_2WAY_COMMANDS; i++)
+    {
+        iFreeCmdMsg.push_back(&iCmdMsg[i]);
+    }
+
+    for (i = 0; i < MAX_PENDING_2WAY_EVENTS; i++)
+    {
+        iFreeEventMsg.push_back(&iEventMsg[i]);
+    }
+
+    for (i = 0; i < MAX_PENDING_2WAY_ERRORS; i++)
+    {
+        iFreeErrorMsg.push_back(&iErrorMsg[i]);
+    }
+
+    //Create proxy
+    iPVProxy = CPVInterfaceProxy::NewL(*this, NULL, 2 * DEFAULT_2WAY_STACK_SIZE);
+    //Register ourself as a proxied interface
+    iProxyId = iPVProxy->RegisterProxiedInterface(*this, *this);
+    //Start the proxy thread.
+    iPVProxy->StartPVThread();
+}
+
+
+CPV2WayProxyAdapter::~CPV2WayProxyAdapter()
+//called by the factory to delete 2way interface.
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayProxyAdapter::~CPV2WayProxyAdapter iterminalEngine(%x)", iterminalEngine));
+    if (iPVProxy)
+    {
+        iPVProxy->StopPVThread();
+        iPVProxy->Delete();
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayProxyAdapter::~CPV2WayProxyAdapter - done"));
+}
+
+//
+// Pure virtuals from Oscl proxy base class.
+//
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::DeleteTerminal(PVLogger *aLogger)
+//called by proxy base class to delete terminal under the PV thread.
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, aLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayProxyAdapter::DeleteTerminal-in"));
+    if (iterminalEngine)
+        CPV2WayEngineFactory::DeleteTerminal(iterminalEngine);
+    iterminalEngine = NULL;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, aLogger, PVLOGMSG_STACK_TRACE, (0, "CPV2WayProxyAdapter::DeleteTerminal-out"));
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::CreateTerminal(PVLogger *aLogger)
+//called by proxy base class to create terminal under the PV thread.
+{
+    OSCL_UNUSED_ARG(aLogger);
+    iterminalEngine =  CPV2WayEngineFactory::CreateTerminal(PV_324M,
+                       this,//observers
+                       this,
+                       this);
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::CreateLoggerAppenders()
+{
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::PVThreadLogon(PVMainProxy &proxy)
+{
+    OSCL_UNUSED_ARG(proxy);
+    CreateTerminal();
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::PVThreadLogoff(PVMainProxy &proxy)
+{
+    OSCL_UNUSED_ARG(proxy);
+    DeleteTerminal();
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::CleanupMessage(CPVCmnInterfaceCmdMessage *cmdMsg, PVLogger *aLogger)
+//Cleanup an un-processed command message that was passed to SendAPI.
+{
+    OSCL_UNUSED_ARG(aLogger);
+    if (cmdMsg)
+        OSCL_DELETE(cmdMsg);
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::CleanupNotification(CPVCmnInterfaceObserverMessage *obsMsg, PVLogger *aLogger)
+//Cleanup an un-processed notifier message that was passed to NotifyCaller
+{
+    OSCL_UNUSED_ARG(aLogger);
+    OSCL_UNUSED_ARG(obsMsg);
+#if 0
+    if (obsMsg)
+    {
+        switch (obsMsg->GetResponseType())
+        {
+            case PVT_COMMAND_INIT:
+            case PVT_COMMAND_GET_SDK_INFO:
+            case PVT_COMMAND_GET_SDK_MODULE_INFO:
+            case PVT_COMMAND_GET_PV2WAY_STATE:
+            case PVT_COMMAND_RESET:
+            case PVT_COMMAND_PAUSE:
+            case PVT_COMMAND_RESUME:
+            case PVT_COMMAND_SET_LOG_APPENDER:
+            case PVT_COMMAND_REMOVE_LOG_APPENDER:
+            case PVT_COMMAND_SET_LOG_LEVEL:
+            case PVT_COMMAND_GET_LOG_LEVEL:
+            case PVT_COMMAND_QUERY_INTERFACE:
+            case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            case PVT_COMMAND_CONNECT:
+            case PVT_COMMAND_DISCONNECT:
+            case PVT_COMMAND_ADD_DATA_SOURCE:
+            case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            case PVT_COMMAND_ADD_DATA_SINK:
+            case PVT_COMMAND_REMOVE_DATA_SINK:
+            case PVT_COMMAND_QUERY_UUID:
+            {
+                CPVCmnCmdResp *resp = (CPVCmnCmdResp*)obsMsg;
+
+                //Get the command message that prompted this
+                //response.  The pointer is in the context data.
+                CPVCmnInterfaceCmdMessage *cmd = (CPVCmnInterfaceCmdMessage*)resp->GetContext();
+
+                if (cmd)
+                {
+                    //discard command message.
+                    OSCL_DELETE(cmd);
+                }
+
+                FreeCmdMsg((CPVCmnCmdRespMsg *) obsMsg);
+            }
+            break;
+
+            case PVT_INDICATION_PAUSE_TRACK:
+            case PVT_INDICATION_RESUME_TRACK:
+            case PVT_INDICATION_USER_INPUT:
+            case PVT_INDICATION_USER_INPUT_CAPABILITY:
+            case PVT_INDICATION_INCOMING_TRACK:
+            case PVT_INDICATION_DISCONNECT:
+            case PVT_INDICATION_CLOSE_TRACK:
+            case PVT_INDICATION_INTERNAL_ERROR:
+            {
+                FreeEventMsg((CPVCmnAsyncEventMsg *) obsMsg);
+            }
+            break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayProxyAdapter::CleanupNotification unknown response (%d)", obsMsg->GetResponseType()));
+                break;
+        }
+
+    }
+#endif
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::ProcessMessage(CPVCmnInterfaceCmdMessage *aMsg, PVLogger *aLogger)
+//called in the PV thread to field a command.
+{
+    OSCL_UNUSED_ARG(aLogger);
+    if (!aMsg)
+        return;
+
+    int32 err = ProcessMessageLTry(aMsg);
+
+    //if ProcessMessage did a leave, create
+    //a response here...
+    if (err)
+    {
+        int32 tmp_err;
+        PVCmnCmdRespMsg *msg = NULL;
+        OSCL_TRY(tmp_err, msg = GetCmdMsgL());
+        if (tmp_err) return;
+
+        msg->Set(aMsg->GetCommandId() , //id
+                 aMsg, //context data
+                 err, //status
+                 NULL, 0); //response data
+
+        iPVProxy->SendNotification(iProxyId, (OsclAny*)msg);
+    }
+}
+
+int CPV2WayProxyAdapter::ProcessMessageLTry(CPVCmnInterfaceCmdMessage* aMsg)
+{
+    // this function exists to get rid of compiler warnings
+    int32 err = 0;
+    OSCL_TRY(err, ProcessMessageL(aMsg););
+    return err;
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::HandleCommand(TPVProxyMsgId aMsgId, OsclAny* aMsg)
+{
+    CPVCmnInterfaceCmdMessage *msg = (CPVCmnInterfaceCmdMessage*)aMsg;
+    msg->SetId(aMsgId);
+    ProcessMessage(msg);
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::CleanupNotification(TPVProxyMsgId aId,
+        OsclAny* aMsg)
+{
+    OSCL_UNUSED_ARG(aId);
+    OSCL_UNUSED_ARG(aMsg);
+    //CleanupMessage((CCPVCmnInterfaceCmdMessage*)aMsg);
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::ProcessNotification(CPVCmnInterfaceObserverMessage *aMsg, PVLogger *aLogger)
+//called in the app thread to notify observer.
+{
+    int32 err = 0;
+    OSCL_TRY(err, ProcessNotificationL(aMsg););
+    if (err)
+    {
+        //not really sure what to do with this...
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, aLogger, PVLOGMSG_NONFATAL_ERROR, (0, "PV2WAYPROXY:Error! ProcessNotificationL %d", err));
+    }
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::HandleNotification(TPVProxyMsgId aId, OsclAny* aMsg)
+{
+    OSCL_UNUSED_ARG(aId);
+    ProcessNotification((CPVCmnInterfaceObserverMessage*)aMsg);
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyAdapter::CleanupCommand(TPVProxyMsgId aId, OsclAny* aMsg)
+{
+    OSCL_UNUSED_ARG(aId);
+    CleanupNotification((CPVCmnInterfaceObserverMessage*)aMsg);
+}
+
+//
+// proxied 2way API implementation.
+//
+
+PVCommandId CPV2WayProxyAdapter::GetSDKInfo(PVSDKInfo &aSDKInfo, OsclAny* aContextData)
+{
+    PV2WayMessageGetSDKInfo *msg = OSCL_NEW(PV2WayMessageGetSDKInfo, (aSDKInfo, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, OsclAny* aContextData)
+{
+    PV2WayMessageGetSDKModuleInfo *msg = OSCL_NEW(PV2WayMessageGetSDKModuleInfo, (aSDKModuleInfo, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::Init(PV2WayInitInfo& aInitInfo, OsclAny* aContextData)
+{
+    PV2WayMessageInit *msg = OSCL_NEW(PV2WayMessageInit, (aInitInfo, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+
+PVCommandId CPV2WayProxyAdapter::Reset(OsclAny* aContextData)
+{
+    PV2WayMessageReset *msg = OSCL_NEW(PV2WayMessageReset, (aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::AddDataSource(PVTrackId aTrackId,
+        PVMFNodeInterface& aDataSource,
+        OsclAny* aContextData)
+{
+    PV2WayMessageAddDataSource *msg = OSCL_NEW(PV2WayMessageAddDataSource, (aTrackId, aDataSource, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::RemoveDataSource(PVMFNodeInterface& aDataSource, OsclAny* aContextData)
+{
+    PV2WayMessageRemoveDataSource *msg = OSCL_NEW(PV2WayMessageRemoveDataSource, (aDataSource, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::AddDataSink(PVTrackId aTrackId,
+        PVMFNodeInterface& aDataSink,
+        OsclAny* aContextData)
+{
+    PV2WayMessageAddDataSink *msg = OSCL_NEW(PV2WayMessageAddDataSink, (aTrackId, aDataSink, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::RemoveDataSink(PVMFNodeInterface& aDataSink, OsclAny* aContextData)
+{
+    PV2WayMessageRemoveDataSink *msg = OSCL_NEW(PV2WayMessageRemoveDataSink, (aDataSink, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::Connect(const PV2WayConnectOptions& aOptions,
+        PVMFNodeInterface* aCommServer,
+        OsclAny* aContextData)
+{
+    PV2WayMessageConnect *msg = OSCL_NEW(PV2WayMessageConnect, (aOptions, aCommServer, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::Disconnect(OsclAny* aContextData)
+{
+    PV2WayMessageDisconnect *msg = OSCL_NEW(PV2WayMessageDisconnect, (aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::GetState(PV2WayState& aState, OsclAny* aContextData)
+{
+    PV2WayMessageGetPV2WayState *msg = OSCL_NEW(PV2WayMessageGetPV2WayState, (aState, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::Pause(PV2WayDirection aDirection,
+                                       PVTrackId aTrackId,
+                                       OsclAny* aContextData)
+{
+    PV2WayMessagePause *msg = OSCL_NEW(PV2WayMessagePause, (aDirection, aTrackId, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::Resume(PV2WayDirection aDirection,
+                                        PVTrackId aTrackId,
+                                        OsclAny* aContextData)
+{
+    PV2WayMessageResume *msg = OSCL_NEW(PV2WayMessageResume, (aDirection, aTrackId, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::SetLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, OsclAny* aContextData)
+{
+    ////// copy tag string //////
+    Oscl_TAlloc<uint8, OsclMemAllocator> myAlloc;
+    typedef OsclRefCounterSA<Oscl_TAlloc<uint8, OsclMemAllocator> > refcount_type;
+
+    uint32 allocSize = sizeof(refcount_type) + (sizeof(char) * (oscl_strlen(aTag) + 1));
+    uint8 * mem = (uint8*)myAlloc.allocate(allocSize);
+    OsclError::PushL(mem);
+
+    char* tag = (char*)(mem + sizeof(refcount_type));
+    oscl_strncpy(tag, aTag, oscl_strlen(aTag) + 1);
+
+    refcount_type *tagRefCounter = OSCL_PLACEMENT_NEW(mem, refcount_type(mem));
+
+    OsclSharedPtr<char> tagPtr(tag, tagRefCounter);
+
+
+    PV2WayMessageSetLogAppender *msg = OSCL_NEW(PV2WayMessageSetLogAppender , (tagPtr, aAppender, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    OsclError::Pop();
+
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::RemoveLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, OsclAny* aContextData)
+{
+    ////// copy tag string //////
+    Oscl_TAlloc<uint8, OsclMemAllocator> myAlloc;
+    typedef OsclRefCounterSA<Oscl_TAlloc<uint8, OsclMemAllocator> > refcount_type;
+
+    uint32 allocSize = sizeof(refcount_type) + (sizeof(char) * (oscl_strlen(aTag) + 1));
+    uint8 * mem = (uint8*)myAlloc.allocate(allocSize);
+    OsclError::PushL(mem);
+
+    char* tag = (char*)(mem + sizeof(refcount_type));
+    oscl_strncpy(tag, aTag, oscl_strlen(aTag) + 1);
+
+    refcount_type *tagRefCounter =  OSCL_PLACEMENT_NEW(mem, refcount_type(mem));
+
+    OsclSharedPtr<char> tagPtr(tag, tagRefCounter);
+
+
+    PV2WayMessageRemoveLogAppender *msg = OSCL_NEW(PV2WayMessageRemoveLogAppender , (tagPtr, aAppender, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    OsclError::Pop();
+
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::SetLogLevel(const char *aTag, int32 aLevel, bool aSetSubtree, OsclAny* aContextData)
+{
+    // set the log level in this thread
+    PVLogger *logger = PVLogger::GetLoggerObject(aTag);
+    logger->SetLogLevel(aLevel);
+
+    ////// copy tag string //////
+    Oscl_TAlloc<uint8, OsclMemAllocator> myAlloc;
+    typedef OsclRefCounterSA<Oscl_TAlloc<uint8, OsclMemAllocator> > refcount_type;
+
+    uint32 allocSize = sizeof(refcount_type) + (sizeof(char) * (oscl_strlen(aTag) + 1));
+    uint8 * mem = (uint8*)myAlloc.allocate(allocSize);
+    OsclError::PushL(mem);
+
+    char* tag = (char*)(mem + sizeof(refcount_type));
+    oscl_strncpy(tag, aTag, oscl_strlen(aTag) + 1);
+
+    refcount_type *tagRefCounter = OSCL_PLACEMENT_NEW(mem, refcount_type(mem));
+
+    OsclSharedPtr<char> tagPtr(tag, tagRefCounter);
+
+
+    PV2WayMessageSetLogLevel *msg = OSCL_NEW(PV2WayMessageSetLogLevel, (tagPtr, aLevel, aSetSubtree, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    OsclError::Pop();
+
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::GetLogLevel(const char *aTag, int32 &aLogLevel, OsclAny* aContextData)
+{
+    ////// copy tag string //////
+    Oscl_TAlloc<uint8, OsclMemAllocator> myAlloc;
+    typedef OsclRefCounterSA<Oscl_TAlloc<uint8, OsclMemAllocator> > refcount_type;
+
+    uint32 allocSize = sizeof(refcount_type) + (sizeof(char) * (oscl_strlen(aTag) + 1));
+    uint8 * mem = (uint8*)myAlloc.allocate(allocSize);
+    OsclError::PushL(mem);
+
+    char* tag = (char*)(mem + sizeof(refcount_type));
+    oscl_strncpy(tag, aTag, oscl_strlen(aTag) + 1);
+
+    refcount_type *tagRefCounter =  OSCL_PLACEMENT_NEW(mem, refcount_type(mem));
+
+    OsclSharedPtr<char> tagPtr(tag, tagRefCounter);
+
+
+    PV2WayMessageGetLogLevel *msg = OSCL_NEW(PV2WayMessageGetLogLevel, (tagPtr, aLogLevel, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    OsclError::Pop();
+
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+
+PVCommandId CPV2WayProxyAdapter::QueryUUID(const PvmfMimeString& aMimeType, Oscl_Vector<PVUuid, BasicAlloc>& aUuids,
+        bool aExactUuidsOnly, OsclAny* aContextData)
+{
+    PV2WayMessageQueryUUID *msg = OSCL_NEW(PV2WayMessageQueryUUID, (aMimeType, aUuids, aExactUuidsOnly, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+PVCommandId CPV2WayProxyAdapter::QueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, OsclAny* aContextData)
+{
+    PV2WayMessageQueryInterface *msg = OSCL_NEW(PV2WayMessageQueryInterface, (aUuid, aInterfacePtr, aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+
+    // proxiedinterface->QueryProxiedInterface(uuid, iface);
+
+}
+
+PVCommandId CPV2WayProxyAdapter::CancelAllCommands(OsclAny* aContextData)
+{
+    PV2WayMessageCancelAllCommands *msg = OSCL_NEW(PV2WayMessageCancelAllCommands, (aContextData));
+    if (msg == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return iPVProxy->SendCommand(iProxyId, (OsclAny*)msg);
+}
+
+//
+// 2way engine observer implementation.
+//
+
+void CPV2WayProxyAdapter::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+{
+    PVCmnAsyncErrorEvent *msg;
+    TPVCmnExclusivePtr aExclusivePtr;
+    aEvent.GetEventData(aExclusivePtr);
+
+    msg = GetErrorMsgL();
+
+    msg->Set(aEvent.GetEventType(),
+             aExclusivePtr,
+             aEvent.GetLocalBuffer(),
+             PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+
+    iPVProxy->SendNotification(iProxyId, (OsclAny*)msg);
+}
+
+void CPV2WayProxyAdapter::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    PVCmnAsyncEventMsg *msg;
+    TPVCmnExclusivePtr aExclusivePtr;
+    aEvent.GetEventData(aExclusivePtr);
+    msg = GetEventMsgL();
+
+    msg->Set(aEvent, aEvent.GetEventType(),
+             aExclusivePtr,
+             aEvent.GetLocalBuffer(),
+             PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
+
+    iPVProxy->SendNotification(iProxyId, (OsclAny*)msg);
+}
+
+void CPV2WayProxyAdapter::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    // if command is query interface, we need to get the proxied interface for the response
+    CPVCmnInterfaceCmdMessage *iface_msg = (CPVCmnInterfaceCmdMessage *)aResponse.GetContext();
+    PVMFStatus status = aResponse.GetCmdStatus();
+
+    if (iface_msg->GetType() == PVT_COMMAND_QUERY_INTERFACE)
+    {
+        status = PVMFFailure;
+        /* Handle query interface*/
+        PVUuid uuid = OSCL_STATIC_CAST(PV2WayMessageQueryInterface*, iface_msg)->iUuid;
+        PVInterface *iface = OSCL_STATIC_CAST(PV2WayMessageQueryInterface*, iface_msg)->iInterfacePtr;
+
+        if (iface != NULL && aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            PVProxiedInterface *proxiedinterface = NULL;
+            PVInterface * tempInterface = NULL;
+
+            bool success = iface->queryInterface(PVUidProxiedInterface, tempInterface);
+            proxiedinterface = OSCL_STATIC_CAST(PVProxiedInterface*, tempInterface) ;
+            iface->removeRef();
+            OSCL_STATIC_CAST(PV2WayMessageQueryInterface*, iface_msg)->iInterfacePtr = iface = NULL;
+
+            if (success && proxiedinterface)
+            {
+                proxiedinterface->SetMainProxy(iPVProxy);
+                proxiedinterface->QueryProxiedInterface(uuid, iface);
+                proxiedinterface->removeRef();
+                OSCL_STATIC_CAST(PV2WayMessageQueryInterface*, iface_msg)->iInterfacePtr = iface;
+                if (iface != NULL)
+                {
+                    status = PVMFSuccess;
+                }
+            }
+        }
+    }
+
+    PVCmnCmdRespMsg *msg;
+    msg = GetCmdMsgL();
+
+    msg->Set(aResponse.GetCmdId(), //id
+             iface_msg, //context
+             status,
+             aResponse.GetResponseData(),
+             aResponse.GetResponseDataSize());//response data
+
+    iPVProxy->SendNotification(iProxyId, (OsclAny*)msg);
+}
+
+//
+// server side processing
+//
+
+void CPV2WayProxyAdapter::ProcessMessageL(CPVCmnInterfaceCmdMessage *aMsg)
+//called in the PV thread to field a command.
+{
+    int32 error = 0;
+    //Call the engine, passing the command message pointer as the context data.
+    //We will need the command message later in the response processing,
+    //so we can restore the original command ID and context data that the
+    //app sees.
+
+    switch (aMsg->GetType())
+    {
+        case PVT_COMMAND_INIT:
+        {
+            OSCL_TRY(error, iterminalEngine->Init(
+                         OSCL_STATIC_CAST(PV2WayMessageInit *, aMsg)->iInitInfo,
+                         aMsg));
+        }
+        break;
+        case PVT_COMMAND_GET_SDK_INFO:
+        {
+            OSCL_TRY(error, iterminalEngine->GetSDKInfo(
+                         OSCL_STATIC_CAST(PV2WayMessageGetSDKInfo *, aMsg)->iSDKInfo,
+                         aMsg));
+        }
+        break;
+
+        case PVT_COMMAND_GET_SDK_MODULE_INFO:
+        {
+            OSCL_TRY(error, iterminalEngine->GetSDKModuleInfo(
+                         OSCL_STATIC_CAST(PV2WayMessageGetSDKModuleInfo* , aMsg)->iSDKModuleInfo,
+                         aMsg));
+        }
+        break;
+
+        case PVT_COMMAND_GET_PV2WAY_STATE:
+        {
+            OSCL_TRY(error, iterminalEngine->GetState(
+                         OSCL_STATIC_CAST(PV2WayMessageGetPV2WayState*, aMsg)->iState,
+                         aMsg));
+        }
+        break;
+
+        case PVT_COMMAND_RESET:
+            OSCL_TRY(error, iterminalEngine->Reset(aMsg));
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            OSCL_TRY(error, iterminalEngine->AddDataSource(
+                         OSCL_STATIC_CAST(PV2WayMessageAddDataSource *, aMsg)->iTrackId,
+                         OSCL_STATIC_CAST(PV2WayMessageAddDataSource *, aMsg)->iDataSource,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            OSCL_TRY(error, iterminalEngine->RemoveDataSource(
+                         OSCL_STATIC_CAST(PV2WayMessageRemoveDataSource*, aMsg)->iDataSource,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            OSCL_TRY(error, iterminalEngine->AddDataSink(
+                         OSCL_STATIC_CAST(PV2WayMessageAddDataSink *, aMsg)->iTrackId,
+                         OSCL_STATIC_CAST(PV2WayMessageAddDataSink *, aMsg)->iDataSink,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            OSCL_TRY(error, iterminalEngine->RemoveDataSink(
+                         OSCL_STATIC_CAST(PV2WayMessageRemoveDataSink* , aMsg)->iDataSink,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            OSCL_TRY(error, iterminalEngine->Connect(
+                         OSCL_STATIC_CAST(PV2WayMessageConnect *, aMsg)->iConnectOptions,
+                         OSCL_STATIC_CAST(PV2WayMessageConnect *, aMsg)->iCommServer,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            OSCL_TRY(error, iterminalEngine->Disconnect(aMsg));
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            OSCL_TRY(error, iterminalEngine->Pause(
+                         OSCL_STATIC_CAST(PV2WayMessagePause* , aMsg)->iDirection,
+                         OSCL_STATIC_CAST(PV2WayMessagePause* , aMsg)->iTrackId,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_RESUME:
+            OSCL_TRY(error, iterminalEngine->Resume(
+                         OSCL_STATIC_CAST(PV2WayMessagePause* , aMsg)->iDirection,
+                         OSCL_STATIC_CAST(PV2WayMessagePause* , aMsg)->iTrackId,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_SET_LOG_APPENDER:
+        {
+            OSCL_TRY(error, iterminalEngine->SetLogAppender(
+                         OSCL_STATIC_CAST(PV2WayMessageSetLogAppender*, aMsg)->iTag,
+                         OSCL_STATIC_CAST(PV2WayMessageSetLogAppender*, aMsg)->iAppender,
+                         aMsg));
+        }
+        break;
+
+        case PVT_COMMAND_REMOVE_LOG_APPENDER:
+        {
+            OSCL_TRY(error, iterminalEngine->RemoveLogAppender(
+                         OSCL_STATIC_CAST(PV2WayMessageRemoveLogAppender*, aMsg)->iTag,
+                         OSCL_STATIC_CAST(PV2WayMessageRemoveLogAppender*, aMsg)->iAppender,
+                         aMsg));
+        }
+        break;
+
+        case PVT_COMMAND_SET_LOG_LEVEL:
+            OSCL_TRY(error, iterminalEngine->SetLogLevel(
+                         OSCL_STATIC_CAST(PV2WayMessageSetLogLevel*, aMsg)->iTag,
+                         OSCL_STATIC_CAST(PV2WayMessageSetLogLevel*, aMsg)->iLevel,
+                         OSCL_STATIC_CAST(PV2WayMessageSetLogLevel*, aMsg)->iSetSubtree,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_GET_LOG_LEVEL:
+            OSCL_TRY(error, iterminalEngine->GetLogLevel(
+                         OSCL_STATIC_CAST(PV2WayMessageGetLogLevel*, aMsg)->iTag,
+                         OSCL_STATIC_CAST(PV2WayMessageGetLogLevel*, aMsg)->iLogLevel,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_QUERY_UUID:
+            OSCL_TRY(error, iterminalEngine->QueryUUID(
+                         OSCL_STATIC_CAST(PV2WayMessageQueryUUID*, aMsg)->iMimeType,
+                         OSCL_STATIC_CAST(PV2WayMessageQueryUUID*, aMsg)->iUuids,
+                         OSCL_STATIC_CAST(PV2WayMessageQueryUUID*, aMsg)->iExactUuidsOnly,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_QUERY_INTERFACE:
+            OSCL_TRY(error, iterminalEngine->QueryInterface(
+                         OSCL_STATIC_CAST(PV2WayMessageQueryInterface*, aMsg)->iUuid,
+                         OSCL_STATIC_CAST(PV2WayMessageQueryInterface*, aMsg)->iInterfacePtr,
+                         aMsg));
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            OSCL_TRY(error, iterminalEngine->CancelAllCommands(
+                         aMsg));
+            break;
+    }
+
+    if (error)
+    {
+        //create response to go across proxy.
+        PVCmnCmdRespMsg *msg = GetCmdMsgL();
+
+        msg->Set(aMsg->GetCommandId(), //id
+                 aMsg, //context
+                 error, //status
+                 NULL, 0); //response data
+
+        iPVProxy->SendNotification(iProxyId, (OsclAny*)msg);
+    }
+}
+
+//
+// client side processing
+//
+
+void CPV2WayProxyAdapter::ProcessNotificationL(CPVCmnInterfaceObserverMessage *aMsg)
+//called in the app thread to notify observer.
+{
+    int32 err = 0;
+
+    if (!aMsg)
+        return;
+
+    switch (aMsg->GetResponseType())
+    {
+        case 0:
+        {
+            PVCmnCmdRespMsg *resp = (PVCmnCmdRespMsg*)aMsg;
+
+            //Get the command message that prompted this
+            //response.  The pointer is in the context data.
+            CPVCmnInterfaceCmdMessage *cmd = (CPVCmnInterfaceCmdMessage*)resp->GetContext();
+
+            //Create a new response with the original command ID and
+            //original context data.
+            resp->SetId(cmd->GetCommandId());
+            resp->SetContextData(cmd->GetContextData());
+            OSCL_TRY(err, iCmdStatusObserver->CommandCompleted(*resp));
+            //ignore any leave from the observer function.
+
+            //discard command message.
+            OSCL_DELETE(cmd);
+
+            FreeCmdMsg(resp);
+        }
+        break;
+
+        case 1:
+        {
+            PVCmnAsyncEventMsg *event = (PVCmnAsyncEventMsg*) aMsg;
+
+            OSCL_TRY(err, iInfoEventObserver->HandleInformationalEvent(*event););
+            //ignore any leave from the observer function.
+
+            FreeEventMsg((PVCmnAsyncEventMsg *) aMsg);
+
+        }
+        break;
+
+        case 2:
+        {
+            PVCmnAsyncErrorEvent *event = (PVCmnAsyncErrorEvent *) aMsg;
+
+            OSCL_TRY(err, iErrorEventObserver->HandleErrorEvent(*event););
+            //ignore any leave from the observer function.
+
+            FreeErrorMsg((PVCmnAsyncErrorEvent *) aMsg);
+        }
+        break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayProxyAdapter::ProcessNotificationL unknown response (%d)", aMsg->GetResponseType()));
+            //Assume command message.
+            FreeCmdMsg((PVCmnCmdRespMsg *) aMsg);
+            break;
+    }
+}
+
+
+PVCmnCmdRespMsg *CPV2WayProxyAdapter::GetCmdMsgL()
+{
+    if (iFreeCmdMsg.empty())
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    else
+    {
+        PVCmnCmdRespMsg *cmd = (PVCmnCmdRespMsg *)iFreeCmdMsg[0];
+        iFreeCmdMsg.erase(iFreeCmdMsg.begin());
+        return cmd;
+    }
+
+    return NULL;
+}
+
+PVCmnAsyncEventMsg *CPV2WayProxyAdapter::GetEventMsgL()
+{
+    if (iFreeEventMsg.empty())
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    else
+    {
+        PVCmnAsyncEventMsg *cmd = (PVCmnAsyncEventMsg *)iFreeEventMsg[0];
+        iFreeEventMsg.erase(iFreeEventMsg.begin());
+        return cmd;
+    }
+
+    return NULL;
+}
+
+PVCmnAsyncErrorEvent* CPV2WayProxyAdapter::GetErrorMsgL()
+{
+    if (iFreeErrorMsg.empty())
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    else
+    {
+        PVCmnAsyncErrorEvent *cmd = (PVCmnAsyncErrorEvent *)iFreeErrorMsg[0];
+        iFreeErrorMsg.erase(iFreeErrorMsg.begin());
+        return cmd;
+    }
+
+    return NULL;
+}
+
diff --git a/engines/2way/src/pv_2way_proxy_adapter.h b/engines/2way/src/pv_2way_proxy_adapter.h
new file mode 100644
index 0000000..a641154
--- /dev/null
+++ b/engines/2way/src/pv_2way_proxy_adapter.h
@@ -0,0 +1,270 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PV_2WAY_PROXY_ADAPTER_H_INCLUDED
+#define PV_2WAY_PROXY_ADAPTER_H_INCLUDED
+
+#ifndef PV_INTERFACE_PROXY_H_INCLUDED
+#include "pv_interface_proxy.h"
+#endif
+
+#ifndef PV_2WAY_INTERFACE_H_INCLUDED
+#include "pv_2way_interface.h"
+#endif
+
+#ifndef PV_2WAY_INTERFACE_CMD_MESSAGES_H_INCLUDED
+#include "pv_2way_interface_cmd_messages.h"
+#endif
+
+#ifndef PV_2WAY_ENGINE_H_INCLUDED
+#include "pv_2way_engine.h"
+#endif
+
+#ifndef OSCL_SHARED_PTR_H_INCLUDED
+#include "oscl_shared_ptr.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#include "pv_engine_observer.h"
+#include "pv_engine_observer_message.h"
+
+class PVLogger;
+class PVMFNodeInterface;
+
+
+class PVCmnCmdRespMsg : public CPVCmnInterfaceObserverMessage,
+            public PVCmdResponse
+{
+    public:
+        PVCmnCmdRespMsg() : CPVCmnInterfaceObserverMessage(0),
+                PVCmdResponse(0, (OsclAny*)NULL, PVMFSuccess, NULL, 0)
+        {};
+
+        ~PVCmnCmdRespMsg() {};
+
+        void Set(PVCommandId aId,
+                 void *aContext,
+                 PVMFStatus aStatus,
+                 OsclAny* aEventData = NULL,
+                 int32 aEventDataSize = 0);
+
+        void SetId(PVCommandId aId)
+        {
+            iId = aId;
+        }
+        void SetContextData(void *aContext)
+        {
+            iContext = aContext;
+        }
+};
+
+class PVCmnAsyncEventMsg : public CPVCmnInterfaceObserverMessage,
+            public PVAsyncInformationalEvent
+{
+    public:
+        PVCmnAsyncEventMsg() : CPVCmnInterfaceObserverMessage(1)
+                , PVAsyncInformationalEvent(PVT_INDICATION_INCOMING_TRACK)
+        {};
+
+        ~PVCmnAsyncEventMsg() {};
+
+        void Set(const PVAsyncInformationalEvent& aEvent, PVEventType aType,
+                 PVExclusivePtr aPtr,
+                 uint8 *aLocalBuffer,
+                 uint32 aLocalBufferSize);
+};
+
+class PVCmnAsyncErrorEvent: public CPVCmnInterfaceObserverMessage,
+            public PVAsyncErrorEvent
+{
+    public:
+        PVCmnAsyncErrorEvent() : CPVCmnInterfaceObserverMessage(2)
+                , PVAsyncErrorEvent(0)
+        {};
+
+        ~PVCmnAsyncErrorEvent() {};
+
+        void Set(PVEventType aEventType,
+                 PVExclusivePtr aEventData,
+                 uint8* aLocalBuffer,
+                 int32 aLocalBufferSize);
+
+};
+
+/**
+ * CPV2WayProxyAdapter Class
+ *
+ * CPV2WayProxyAdapter is the interface to the pv2way SDK, which
+ * allows initialization, control, and termination of a two-way terminal.
+ * The application is expected to contain and maintain a pointer to the
+ * CPV2WayInterface instance at all times that a call is active.
+ * The CPV2WayFactory factory class is to be used to create and
+ * delete instances of this class
+ **/
+class CPV2WayProxyAdapter :
+            public CPV2WayInterface,
+            public PVProxiedEngine,
+            public PVCommandStatusObserver,
+            public PVInformationalEventObserver,
+            public PVErrorEventObserver,
+            public PVProxiedInterfaceClient,
+            public PVProxiedInterfaceServer
+{
+    public:
+        static CPV2WayProxyAdapter* New(TPVTerminalType aTerminalType,
+                                        PVCommandStatusObserver* aCmdStatusObserver,
+                                        PVInformationalEventObserver *aInfoEventObserver,
+                                        PVErrorEventObserver *aErrorEventObserver);
+        ~CPV2WayProxyAdapter();
+
+        // CPV2WayInterface virtuals
+        PVCommandId GetSDKInfo(PVSDKInfo &aSDKInfo, OsclAny* aContextData = NULL);
+        PVCommandId GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, OsclAny* aContextData = NULL);
+        PVCommandId Init(PV2WayInitInfo& aInitInfo, OsclAny* aContextData = NULL);
+        PVCommandId Reset(OsclAny* aContextData = NULL);
+        PVCommandId AddDataSource(PVTrackId aChannelId, PVMFNodeInterface& aDataSource, OsclAny* aContextData = NULL);
+        PVCommandId RemoveDataSource(PVMFNodeInterface& aDataSource, OsclAny* aContextData = NULL);
+        PVCommandId AddDataSink(PVTrackId aChannelId, PVMFNodeInterface& aDataSink, OsclAny* aContextData = NULL);
+        PVCommandId RemoveDataSink(PVMFNodeInterface& aDataSink, OsclAny* aContextData = NULL);
+        PVCommandId Connect(const PV2WayConnectOptions& aOptions, PVMFNodeInterface* aCommServer = NULL, OsclAny* aContextData = NULL);
+        PVCommandId Disconnect(OsclAny* aContextData = NULL);
+        PVCommandId GetState(PV2WayState& aState, OsclAny* aContextData = NULL);
+        PVCommandId SetLatencyQualityTradeoff(PVMFNodeInterface& aTrack, int32 aTradeoff, OsclAny* aContextData = NULL);
+        PVCommandId Pause(PV2WayDirection aDirection, PVTrackId aTrackId, OsclAny* aContextData = NULL);
+        PVCommandId Resume(PV2WayDirection aDirection, PVTrackId aTrackId, OsclAny* aContextData = NULL);
+        PVCommandId SetLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, OsclAny* aContextData = NULL);
+        PVCommandId RemoveLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, OsclAny* aContextData = NULL);
+        PVCommandId SetLogLevel(const char* aTag, int32 aLevel, bool aSetSubtree = false, OsclAny* aContextData = NULL);
+        PVCommandId GetLogLevel(const char* aTag, int32& aLogInfo, OsclAny* aContextData = NULL);
+        //PVCommandId SendUserInput(CPVUserInput& user_input, OsclAny* aContextData = NULL);
+        //PVCommandId GetCallStatistics(CPVCmn2WayStatistics& aStats, OsclAny* aContextData = NULL);
+        PVCommandId QueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, OsclAny* aContext = NULL);
+        PVCommandId QueryUUID(const PvmfMimeString& aMimeType, Oscl_Vector<PVUuid, BasicAlloc>& aUuids,
+                              bool aExactUuidsOnly = false, OsclAny* aContextData = NULL);
+        PVCommandId CancelAllCommands(OsclAny* aContextData = NULL);
+
+
+        OSCL_IMPORT_REF void CreateAppenders(PVLogger *aLogger = NULL)
+        {
+            OSCL_UNUSED_ARG(aLogger);
+        };
+        OSCL_IMPORT_REF void CreateTerminal(PVLogger *aLogger = NULL);
+        OSCL_IMPORT_REF void DeleteTerminal(PVLogger *aLogger = NULL);
+        OSCL_IMPORT_REF void CleanupMessage(CPVCmnInterfaceCmdMessage *cmdMsg, PVLogger *aLogger = NULL);
+        OSCL_IMPORT_REF void CleanupNotification(CPVCmnInterfaceObserverMessage *obsMsg, PVLogger *aLogger = NULL);
+        OSCL_IMPORT_REF void ProcessNotification(CPVCmnInterfaceObserverMessage *aMsg, PVLogger *aLogger = NULL);
+        OSCL_IMPORT_REF void ProcessMessage(CPVCmnInterfaceCmdMessage *aMsg, PVLogger *aLogger = NULL);
+
+        //from PVProxiedEngine
+        OSCL_IMPORT_REF void CreateLoggerAppenders();
+        OSCL_IMPORT_REF void PVThreadLogon(PVMainProxy &proxy);
+        OSCL_IMPORT_REF void PVThreadLogoff(PVMainProxy &proxy);
+
+        //from PVProxiedInterfaceServer
+        OSCL_IMPORT_REF void HandleCommand(TPVProxyMsgId aMsgId, OsclAny* aMsg);
+        OSCL_IMPORT_REF void CleanupNotification(TPVProxyMsgId aId, OsclAny* aMsg);
+
+        //from PVProxiedInterfaceClient
+        OSCL_IMPORT_REF void HandleNotification(TPVProxyMsgId aId, OsclAny* aMsg);
+        OSCL_IMPORT_REF void CleanupCommand(TPVProxyMsgId aId, OsclAny* aMsg);
+
+        //from MPVErrorEventObserver
+        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
+
+        //from MPVInformationalEventObserver
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent) ;
+
+        //from MPVCommandStatusObserver
+        void CommandCompleted(const PVCmdResponse& aResponse) ;
+
+    private:
+        CPV2WayProxyAdapter(): iCmdStatusObserver(NULL),
+                iInfoEventObserver(NULL),
+                iErrorEventObserver(NULL),
+                iterminalType(PV_TERMINAL_TYPE_NONE),
+                iterminalEngine(NULL),
+                iLogger(NULL),
+                iPVProxy(NULL)
+        {};
+
+        OsclAny ConstructL(TPVTerminalType aTerminalType,
+                           PVCommandStatusObserver* aCmdStatusObserver,
+                           PVInformationalEventObserver *aInfoEventObserver,
+                           PVErrorEventObserver *aErrorEventObserver);
+
+        PVCmnCmdRespMsg *GetCmdMsgL();
+        void FreeCmdMsg(PVCmnCmdRespMsg *msg)
+        {
+            iFreeCmdMsg.push_back(msg);
+        }
+
+        PVCmnAsyncEventMsg *GetEventMsgL();
+        void FreeEventMsg(PVCmnAsyncEventMsg *msg)
+        {
+            iFreeEventMsg.push_back(msg);
+        }
+
+        PVCmnAsyncErrorEvent *GetErrorMsgL();
+        void FreeErrorMsg(PVCmnAsyncErrorEvent *msg)
+        {
+            iFreeErrorMsg.push_back(msg);
+        }
+
+        static int Construct(CPV2WayProxyAdapter*& aRet,
+                             TPVTerminalType aTerminalType,
+                             PVCommandStatusObserver* aCmdStatusObserver,
+                             PVInformationalEventObserver *aInfoEventObserver,
+                             PVErrorEventObserver *aErrorEventObserver);
+
+
+        PVCommandStatusObserver *iCmdStatusObserver;
+        PVInformationalEventObserver *iInfoEventObserver;
+        PVErrorEventObserver *iErrorEventObserver;
+
+        TPVTerminalType iterminalType;
+        CPV2WayInterface * iterminalEngine;
+
+        PVLogger *iLogger;
+
+        int ProcessMessageLTry(CPVCmnInterfaceCmdMessage *aMsg);
+        void ProcessMessageL(CPVCmnInterfaceCmdMessage *aMsg);
+        void ProcessNotificationL(CPVCmnInterfaceObserverMessage *aMsg);
+
+        friend class CPV2WayInterfaceProxyHandler;
+        friend class CPV2WayInterfaceProxyNotifier;
+
+        Oscl_Vector<PVCmnCmdRespMsg *, OsclMemAllocator> iFreeCmdMsg;
+        PVCmnCmdRespMsg iCmdMsg[MAX_PENDING_2WAY_COMMANDS];
+
+        Oscl_Vector<PVCmnAsyncEventMsg *, OsclMemAllocator> iFreeEventMsg;
+        PVCmnAsyncEventMsg iEventMsg[MAX_PENDING_2WAY_EVENTS];
+
+        Oscl_Vector<PVCmnAsyncErrorEvent *, OsclMemAllocator> iFreeErrorMsg;
+        PVCmnAsyncErrorEvent iErrorMsg[MAX_PENDING_2WAY_ERRORS];
+
+        CPVInterfaceProxy *iPVProxy;
+        friend class CPV2WayFactory;
+        TPVProxyId iProxyId;
+};
+
+#endif //
+
+
diff --git a/engines/2way/src/pv_2way_proxy_factory.cpp b/engines/2way/src/pv_2way_proxy_factory.cpp
new file mode 100644
index 0000000..e16315c
--- /dev/null
+++ b/engines/2way/src/pv_2way_proxy_factory.cpp
@@ -0,0 +1,54 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_2way_proxy_factory.h"
+#include "pv_2way_engine_factory.h"
+#include "pv_2way_proxy_adapter.h"
+#include "pv_2way_engine.h"
+
+OSCL_EXPORT_REF void CPV2WayProxyFactory::Init()
+{
+    CPV2WayEngineFactory::Init();
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyFactory::Cleanup()
+{
+    CPV2WayEngineFactory::Cleanup();
+}
+
+OSCL_EXPORT_REF CPV2WayInterface *CPV2WayProxyFactory::CreateTerminal(TPVTerminalType aTerminalType,
+        PVCommandStatusObserver* aCmdStatusObserver,
+        PVInformationalEventObserver *aInfoEventObserver,
+        PVErrorEventObserver *aErrorEventObserver)
+{
+    if (aTerminalType == PV_324M)
+    {
+        return CPV2WayProxyAdapter::New(aTerminalType,
+                                        aCmdStatusObserver,
+                                        aInfoEventObserver,
+                                        aErrorEventObserver);
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+OSCL_EXPORT_REF void CPV2WayProxyFactory::DeleteTerminal(CPV2WayInterface* terminal)
+{
+    OSCL_DELETE((CPV2WayProxyAdapter*)terminal);
+}
diff --git a/engines/2way/src/pv_2way_rec_datapath.cpp b/engines/2way/src/pv_2way_rec_datapath.cpp
new file mode 100644
index 0000000..c988e3f
--- /dev/null
+++ b/engines/2way/src/pv_2way_rec_datapath.cpp
@@ -0,0 +1,240 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if defined(PV_RECORD_TO_FILE_SUPPORT)
+#include "pv_2way_rec_datapath.h"
+#include "pv_2way_data_channel_datapath.h"
+//#include "pvmp4ffcn_trackconfig.h"
+
+CPV2WayRecDatapath *CPV2WayRecDatapath::NewL(PVLogger *aLogger,
+        TPV2WayMediaType aFormat,
+        CPV2WayDataChannelDatapath &aDatapath,
+        CPV324m2Way *a2Way)
+{
+    CPV2WayRecDatapath *self = OSCL_NEW(CPV2WayRecDatapath, (aLogger, aFormat, aDatapath, a2Way));
+    OsclError::LeaveIfNull(self);
+
+    if (self)
+    {
+        OSCL_TRAPSTACK_PUSH(self);
+        self->ConstructL();
+    }
+
+    OSCL_TRAPSTACK_POP();
+    return self;
+}
+
+void CPV2WayRecDatapath::CheckPause()
+{
+    uint32 i;
+    int32 error;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        if (!iNodeList[i].iCanNodePause) continue;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause node %d state %d\n", i, iNodeList[i].iNode.node->GetState()));
+        switch (iNodeList[i].iNode.node->GetState())
+        {
+            case EPVMFNodeStarted:
+                OSCL_TRY(error, i2Way->SendNodeCmdL(PV2WAY_NODE_CMD_PAUSE, iNodeList[i].iNode.node, iNodeList[i].iNode.session, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckPause unable to pause node\n"));
+                                     DatapathError();
+                                     return;);
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckPause transitional node state!\n"));
+                break;
+        }
+    }
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        //If possible pause node is not paused.
+        if (iNodeList[i].iCanNodePause && (iNodeList[i].iNode.node->GetState() != EPVMFNodePaused))
+        {
+            return;
+        }
+    }
+
+    //Disconnect ports
+    for (i = 0; i < iPortPairList.size(); i++)
+    {
+        iPortPairList[i].Disconnect();
+    }
+
+    //If reached this point then the datapath is deemed paused, notify upper layer.
+    SetState(EPaused);
+    PauseComplete();
+    return;
+}
+
+void CPV2WayRecDatapath::CheckResume()
+{
+    uint32 i;
+    int32 error;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume state %d\n", iState));
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        if (!iNodeList[i].iCanNodePause) continue;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume node %d state %d\n", i, iNodeList[i].iNode.node->GetState()));
+        switch (iNodeList[i].iNode.node->GetState())
+        {
+            case EPVMFNodePaused:
+                OSCL_TRY(error, i2Way->SendNodeCmdL(PV2WAY_NODE_CMD_START, iNodeList[i].iNode.node, iNodeList[i].iNode.session, this));
+                OSCL_FIRST_CATCH_ANY(error,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayDatapath::CheckResume unable to pause node\n"));
+                                     DatapathError();
+                                     return;);
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayDatapath::CheckResume transitional node state!\n"));
+                break;
+        }
+    }
+
+    for (i = 0; i < iNodeList.size(); i++)
+    {
+        //If possible pause node is not started.
+        if (iNodeList[i].iCanNodePause && (iNodeList[i].iNode.node->GetState() != EPVMFNodeStarted))
+        {
+            return;
+        }
+    }
+
+    //Reconnect ports
+    for (i = 0; i < iPortPairList.size(); i++)
+    {
+        iPortPairList[i].Connect();
+    }
+
+    //If reached this point then the datapath is deemed resumed, notify upper layer.
+    SetState(EOpened);
+    ResumeComplete();
+    return;
+}
+
+bool CPV2WayRecDatapath::SetCmd(TPV2WayCmdInfo *aCmdInfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayRecDatapath::SetCmd state %d cmd %x\n", iState, aCmdInfo));
+
+    if (aCmdInfo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayRecDatapath::SetCmd cmd type %d\n", aCmdInfo->type));
+        switch (aCmdInfo->type)
+        {
+            case PVT_COMMAND_START_RECORD:
+                if (iState == EOpening) return false;
+                iCmdInfo = aCmdInfo;
+                Open();
+                break;
+
+            case PVT_COMMAND_STOP_RECORD:
+                if (!CloseDatapath(aCmdInfo)) return false;
+                break;
+
+            case PVT_COMMAND_PAUSE_RECORD:
+                if (iState == EPausing) return false;
+                iCmdInfo = aCmdInfo;
+                Pause();
+                break;
+
+            case PVT_COMMAND_RESUME_RECORD:
+                if (iState == EUnpausing) return false;
+                iCmdInfo = aCmdInfo;
+                Resume();
+                break;
+
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "CPV2WayRecDatapath::SetCmd invalid command\n"));
+                break;
+        }
+
+    }
+    // A null pointer indicates a close for some reason
+    else
+    {
+        if (!CloseDatapath(aCmdInfo)) return false;
+    }
+
+    return true;
+}
+
+void CPV2WayRecDatapath::OpenComplete()
+{
+#if 0
+    uint8 *config;
+    uint32 len;
+
+    //Get the config info
+    config = i2Way->iTscNode->GetFormatSpecificInfo(iChannelDatapath->GetTSCPort(), &len);
+
+    if (config)
+    {
+        PVMp4FFCNTrackConfigInterface *ptr;
+        ptr = (PVMp4FFCNTrackConfigInterface *) i2Way->iFFTrackConfig.iInterface;
+        ptr->SetCodecSpecificInfo(*iPortPairList.back().iDestPort.GetPort(), config, (int32) len);
+    }
+#endif
+    CommandComplete(PVMFSuccess);
+}
+
+void CPV2WayRecDatapath::CloseComplete()
+{
+    //If parent was closing, then let it notify the app.
+    if (!IsParentClosing())
+    {
+        //If a command was issued
+        if (iCmdInfo)
+        {
+            //If stop command was issued
+            if (iCmdInfo->type == PVT_COMMAND_STOP_RECORD)
+            {
+                CommandComplete(PVMFSuccess);
+            }
+            //Else other command failed
+            else
+            {
+                CommandComplete(PVMFFailure);
+            }
+        }
+    }
+
+    i2Way->CheckRecordFileState();
+}
+
+void CPV2WayRecDatapath::DatapathError()
+{
+    SetCmd(NULL);
+}
+
+
+bool CPV2WayRecDatapath::ParentIsClosing()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "CPV2WayRecDatapath::ParentIsClosing path state %d\n", iState));
+    return SetCmd(NULL);
+}
+#endif
+
diff --git a/engines/2way/src/pv_2way_rec_datapath.h b/engines/2way/src/pv_2way_rec_datapath.h
new file mode 100644
index 0000000..b0179cd
--- /dev/null
+++ b/engines/2way/src/pv_2way_rec_datapath.h
@@ -0,0 +1,78 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_REC_DATAPATH_H_INCLUDED
+#define PV_2WAY_REC_DATAPATH_H_INCLUDED
+
+
+#ifndef PV_2WAY_DATAPATH_H_INCLUDED
+#include "pv_2way_datapath.h"
+#endif
+
+#ifndef PV_2WAY_CMD_CONTROL_DATAPATH_H_INCLUDED
+#include "pv_2way_cmd_control_datapath.h"
+#endif
+
+//Forward declaration
+class CPV2WayDataChannelDatapath;
+
+class CPV2WayRecDatapath : public CPV2WayCmdControlDatapath
+{
+    public:
+        static CPV2WayRecDatapath *NewL(PVLogger *aLogger,
+                                        TPV2WayMediaType aFormat,
+                                        CPV2WayDataChannelDatapath &aDatapath,
+                                        CPV324m2Way *a2Way);
+
+        virtual ~CPV2WayRecDatapath() {};
+
+        bool SetCmd(TPV2WayCmdInfo *aCmdInfo);
+
+    private:
+        CPV2WayRecDatapath(PVLogger *aLogger,
+                           PVMFFormatType aFormat,
+                           CPV2WayDataChannelDatapath &aDatapath,
+                           CPV324m2Way *a2Way) : CPV2WayCmdControlDatapath(aLogger, ERecDatapath, aFormat, a2Way),
+                iChannelDatapath(&aDatapath)
+        {};
+
+        //Override base virtuals
+        void CheckPause();
+        void CheckResume();
+
+        void OpenComplete();
+        void PauseComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void ResumeComplete()
+        {
+            CommandComplete(PVMFSuccess);
+        }
+        void CloseComplete();
+
+        void DatapathError();
+
+        bool ParentIsClosing();
+
+        CPV2WayDataChannelDatapath *iChannelDatapath;
+};
+
+
+#endif //PV_2WAY_REC_DATAPATH_H_INCLUDED
+
+
diff --git a/engines/2way/src/pv_2way_sdkinfo.h b/engines/2way/src/pv_2way_sdkinfo.h
new file mode 100644
index 0000000..1d278e9
--- /dev/null
+++ b/engines/2way/src/pv_2way_sdkinfo.h
@@ -0,0 +1,27 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_SDKINFO_H_INCLUDED
+#define PV_2WAY_SDKINFO_H_INCLUDED
+
+// This header file is automatically generated at build-time
+// *** OFFICIAL RELEASE INFO -- Will not auto update
+
+#define PV2WAY_ENGINE_SDKINFO_LABEL "PVDEV_CORE_RELEASE_6.101.1.1"
+#define PV2WAY_ENGINE_SDKINFO_DATE 0x20090121
+
+#endif //PV_2WAY_SDKINFO_H_INCLUDED
diff --git a/engines/2way/test/Android.mk b/engines/2way/test/Android.mk
new file mode 100644
index 0000000..7fb226a
--- /dev/null
+++ b/engines/2way/test/Android.mk
@@ -0,0 +1,43 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/alloc_dealloc_test.cpp \
+ 	src/av_duplicate_test.cpp \
+ 	src/test_engine.cpp \
+ 	src/init_cancel_test.cpp \
+ 	src/init_test.cpp \
+ 	src/test_base.cpp \
+ 	src/../../pvlogger/src/pv_logger_impl.cpp \
+ 	src/av_test.cpp \
+ 	src/connect_cancel_test.cpp \
+ 	src/connect_test.cpp \
+ 	src/audio_only_test.cpp \
+ 	src/video_only_test.cpp \
+ 	src/user_input_test.cpp
+
+
+LOCAL_MODULE := pv2way_omx_engine_test
+
+LOCAL_CFLAGS := -DPV_USE_AMR_CODECS $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES :=                   libunit_test 
+
+LOCAL_SHARED_LIBRARIES := libopencore_2way                   libopencore_common
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/engines/2way/test/src \
+ 	$(PV_TOP)/engines/2way/test/include \
+ 	$(PV_TOP)/engines/2way/pvlogger/src \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+-include $(PV_TOP)/Android_system_extras.mk
+
+include $(BUILD_EXECUTABLE)
diff --git a/engines/2way/test/build/make/local.mk b/engines/2way/test/build/make/local.mk
new file mode 100644
index 0000000..cd636c5
--- /dev/null
+++ b/engines/2way/test/build/make/local.mk
@@ -0,0 +1,119 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+ifeq ($(USING_MONA),1)
+TARGET := pv2way_mona_engine_test
+else
+ifeq ($(USING_OMX),1)
+TARGET := pv2way_omx_engine_test
+else
+TARGET := pv2way_engine_test
+endif
+endif
+
+
+ifeq ($(USING_MONA),1)
+MONA_FLAGS = -DUSING_MONA
+XCPPFLAGS += -DPV_USE_AMR_CODECS $(SIPCPPFLAGS) $(MONA_FLAGS) $(OMX_FLAGS)
+else
+XCPPFLAGS += -DPV_USE_AMR_CODECS $(SIPCPPFLAGS) $(OMX_FLAGS)
+endif
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+ifeq ($(USING_MONA),1)
+XINCDIRS +=  ../../h223/mona/include  ../../h324/tsc/mona/include 
+endif
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+XINCDIRS +=  ../../../pvlogger/src 
+
+SRCS := alloc_dealloc_test.cpp \
+	av_duplicate_test.cpp \
+	test_engine.cpp \
+	init_cancel_test.cpp \
+	init_test.cpp \
+	test_base.cpp \
+	../../pvlogger/src/pv_logger_impl.cpp
+
+SRCS_324 = av_test.cpp \
+	connect_cancel_test.cpp \
+	connect_test.cpp \
+	audio_only_test.cpp \
+	video_only_test.cpp \
+	user_input_test.cpp
+
+SRCS += $(SRCS_324)
+
+
+
+
+#omx_sharedlibrary \
+#omx_amrdec_sharedlibrary\
+#omx_amrenc_sharedlibrary\
+#omx_m4vdec_sharedlibrary\
+#omx_m4venc_sharedlibrary\
+
+ifeq ($(USING_OMX),1)
+ifeq ($(pv2wayengine_lib),m)
+FULL_LIBS =  opencore_2way \
+pvomxvideodecnode pvomxaudiodecnode pvomxencnode pvomxbasedecnode \
+omx_common_lib omx_m4v_component_lib omx_amr_component_lib \
+omx_amrenc_component_lib omx_m4venc_component_lib \
+omx_baseclass_lib pvomx_proxy_lib omx_queue_lib \
+pvvideoencnode pvvideoparsernode pvmp4decoder pvm4vencoder pvencoder_gsmamr \
+unit_test opencore_common 
+
+else
+FULL_LIBS =  pv2wayengine pv324m \
+pvomxvideodecnode pvomxaudiodecnode pvomxencnode pvomxbasedecnode \
+omx_common_lib omx_m4v_component_lib omx_amr_component_lib \
+omx_amrenc_component_lib omx_m4venc_component_lib \
+omx_baseclass_lib pvomx_proxy_lib omx_queue_lib \
+pvvideoencnode pvvideoparsernode pvmp4decoder pvm4vencoder pvencoder_gsmamr \
+pvdecoder_gsmamr pv_amr_nb_common_lib pvgeneraltools pvcommsionode pvmediaoutputnode pvmediainputnode \
+colorconvert pvfileoutputnode pvmio_comm_loopback pvmiofileinput pvmiofileoutput\
+pvmf pvlatmpayloadparser pvgendatastruct pvmediadatastruct pvthreadmessaging \
+pv_config_parser m4v_config getactualaacconfig pvamrwbdecoder \
+pvmimeutils osclregcli osclregserv osclio osclproc osclutil osclmemory \
+osclerror osclbase unit_test threadsafe_callback_ao \
+
+endif
+
+else
+FULL_LIBS =  pv2wayengine pv324m \
+pvvideodecnode pvamrencnode gsmamrdecnode \
+pvvideoencnode pvvideoparsernode pvamrwbdecoder pvmp4decoder pvm4vencoder \
+pvencoder_gsmamr pvdecoder_gsmamr pv_amr_nb_common_lib \
+pvgeneraltools pvcommsionode pvmediaoutputnode pvmediainputnode \
+pvfileoutputnode pvmio_comm_loopback pvmiofileinput pvmiofileoutput \
+pvmf pvlatmpayloadparser pvgendatastruct pvmediadatastruct \
+colorconvert pvthreadmessaging pvmimeutils \
+osclio osclproc osclutil osclmemory osclerror osclbase unit_test 
+
+endif
+LIBS := $(FULL_LIBS)
+
+ifneq ($(HOST_ARCH),win32)
+SYSLIBS += $(SYS_THREAD_LIB)
+endif
+
+include $(MK)/prog.mk
+
+
+TWOWAY_TEST_DIR = ${BUILD_ROOT}/2way_test
+TWOWAY_TARGET_DIR = $(TWOWAY_TEST_DIR)/build/bin
+TWOWAY_TARGET = pv2way_omx_engine_test
+
+run_2way_test:: $(REALTARGET) default
+	$(quiet) ${RM} -r $(TWOWAY_TEST_DIR)
+	$(quiet) ${MKDIR} -p $(TWOWAY_TARGET_DIR)
+	$(quiet) $(CP) $(SRC_ROOT)/tools_v2/build/package/opencore/pvplayer.cfg $(TWOWAY_TARGET_DIR)
+	$(quiet) $(CP) ${BUILD_ROOT}/bin/${HOST_ARCH}/$(TWOWAY_TARGET) $(TWOWAY_TARGET_DIR)
+	$(quiet) $(CP) -r $(SRC_ROOT)/engines/2way/test/test_data/* $(TWOWAY_TARGET_DIR)
+	$(quiet) export LD_LIBRARY_PATH=${BUILD_ROOT}/installed_lib/${HOST_ARCH}; cd $(TWOWAY_TARGET_DIR) && $(TWOWAY_TARGET_DIR)/$(TWOWAY_TARGET) $(TEST_ARGS) $(SOURCE_ARGS)
diff --git a/engines/2way/test/include/a_only_pause_rec_test.h b/engines/2way/test/include/a_only_pause_rec_test.h
new file mode 100644
index 0000000..cea3308
--- /dev/null
+++ b/engines/2way/test/include/a_only_pause_rec_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef A_ONLY_PAUSE_REC_TEST_H_INCLUDED
+#define A_ONLY_PAUSE_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class a_only_pause_rec_test : public test_base
+{
+    public:
+        a_only_pause_rec_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns) {};
+
+        ~a_only_pause_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/a_only_rec_test.h b/engines/2way/test/include/a_only_rec_test.h
new file mode 100644
index 0000000..91903f9
--- /dev/null
+++ b/engines/2way/test/include/a_only_rec_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef A_ONLY_REC_TEST_H_INCLUDED
+#define A_ONLY_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class a_only_rec_test : public test_base
+{
+    public:
+        a_only_rec_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns) {};
+
+        ~a_only_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/alloc_dealloc_test.h b/engines/2way/test/include/alloc_dealloc_test.h
new file mode 100644
index 0000000..78632ce
--- /dev/null
+++ b/engines/2way/test/include/alloc_dealloc_test.h
@@ -0,0 +1,50 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ALLOC_DEALLOC_TEST_H_INCLUDED
+#define ALLOC_DEALLOC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class alloc_dealloc_test : public test_base
+{
+    public:
+        alloc_dealloc_test(bool aUseProxy, bool isSIP = false) :
+                test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy, isSIP) {  };
+
+        ~alloc_dealloc_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        void CommandCompleted(const PVCmdResponse& aResponse);
+
+    private:
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/audio_only_pause_close_test.h b/engines/2way/test/include/audio_only_pause_close_test.h
new file mode 100644
index 0000000..02bb2c3
--- /dev/null
+++ b/engines/2way/test/include/audio_only_pause_close_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AUDIO_ONLY_PAUSE_CLOSE_TEST_H_INCLUDED
+#define AUDIO_ONLY_PAUSE_CLOSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class audio_only_pause_close_test : public test_base
+{
+    public:
+        audio_only_pause_close_test(bool aUseProxy) : test_base(aUseProxy) {};
+
+        ~audio_only_pause_close_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/audio_only_pause_test.h b/engines/2way/test/include/audio_only_pause_test.h
new file mode 100644
index 0000000..3597d24
--- /dev/null
+++ b/engines/2way/test/include/audio_only_pause_test.h
@@ -0,0 +1,61 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AUDIO_ONLY_PAUSE_TEST_H_INCLUDED
+#define AUDIO_ONLY_PAUSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class audio_only_pause_test : public test_base
+{
+    public:
+        audio_only_pause_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns),
+                iAudioSourceResumed(false),
+                iAudioSinkResumed(false)
+        {};
+
+        ~audio_only_pause_test()
+        {};
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_audio_resumed()
+        {
+            return (iAudioSourceResumed && iAudioSinkResumed);
+        }
+
+        bool iAudioSourceResumed;
+        bool iAudioSinkResumed;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/audio_only_resume_close_test.h b/engines/2way/test/include/audio_only_resume_close_test.h
new file mode 100644
index 0000000..3ca0761
--- /dev/null
+++ b/engines/2way/test/include/audio_only_resume_close_test.h
@@ -0,0 +1,61 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AUDIO_ONLY_RESUME_CLOSE_TEST_H_INCLUDED
+#define AUDIO_ONLY_RESUME_CLOSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class audio_only_resume_close_test : public test_base
+{
+    public:
+        audio_only_resume_close_test(bool aUseProxy) : test_base(aUseProxy),
+                iAudioSourcePaused(false),
+                iAudioSinkPaused(false)
+        {};
+
+        ~audio_only_resume_close_test()
+        {};
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_audio_paused()
+        {
+            return (iAudioSourcePaused && iAudioSinkPaused);
+        }
+
+        bool iAudioSourcePaused;
+        bool iAudioSinkPaused;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/audio_only_test.h b/engines/2way/test/include/audio_only_test.h
new file mode 100644
index 0000000..3b027b8
--- /dev/null
+++ b/engines/2way/test/include/audio_only_test.h
@@ -0,0 +1,59 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AUDIO_ONLY_TEST_H_INCLUDED
+#define AUDIO_ONLY_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+class audio_only_test : public test_base
+{
+    public:
+        audio_only_test(bool aUseProxy,
+                        PVMFFormatType audio_src_format = PVMF_MIME_AMR_IF2,
+                        PVMFFormatType audio_sink_format = PVMF_MIME_AMR_IF2)
+                : test_base(audio_src_format, audio_sink_format, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy)
+        { };
+
+        ~audio_only_test()
+        {
+        }
+
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+
+        void TimerCallback();
+
+
+    private:
+        virtual void ConnectSucceeded();
+        virtual void ConnectFailed();
+        bool start_async_test();
+        bool isFirstSink, isFirstSrc;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_disconnect_reset_rec_test.h b/engines/2way/test/include/av_disconnect_reset_rec_test.h
new file mode 100644
index 0000000..2bba39d
--- /dev/null
+++ b/engines/2way/test/include/av_disconnect_reset_rec_test.h
@@ -0,0 +1,76 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_DISCONNECT_RESET_REC_TEST_H_INCLUDED
+#define AV_DISCONNECT_RESET_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_disconnect_reset_rec_test : public test_base
+{
+    public:
+        av_disconnect_reset_rec_test(bool aUseProxy) : test_base(aUseProxy),
+                iAudioRecStarted(false),
+                iAudioStartRecId(0),
+                iAudioStopRecId(0),
+                iVideoRecStarted(false),
+                iVideoStartRecId(0),
+                iVideoStopRecId(0),
+                iIsDisconnected(true)
+        {};
+
+        ~av_disconnect_reset_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_rec_started()
+        {
+            return (iAudioRecStarted && iVideoRecStarted);
+        }
+        bool check_rec_stopped()
+        {
+            return (!iAudioRecStarted && !iVideoRecStarted);
+        }
+
+        bool iAudioRecStarted;
+        TPVCmnCommandId iAudioStartRecId;
+        TPVCmnCommandId iAudioStopRecId;
+        bool iVideoRecStarted;
+        TPVCmnCommandId iVideoStartRecId;
+        TPVCmnCommandId iVideoStopRecId;
+        bool iIsDisconnected;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_duplicate_test.h b/engines/2way/test/include/av_duplicate_test.h
new file mode 100644
index 0000000..9b0cad1
--- /dev/null
+++ b/engines/2way/test/include/av_duplicate_test.h
@@ -0,0 +1,54 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_DUPLICATE_TEST_H_INCLUDED
+#define AV_DUPLICATE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_duplicate_test : public test_base
+{
+    public:
+        av_duplicate_test(bool aUseProxy, int aMaxRuns) :
+                test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy, aMaxRuns) {};
+
+        ~av_duplicate_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+        void TimerCallback();
+
+    private:
+        void start_duplicates_if_ready();
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_pause_disconnect_test.h b/engines/2way/test/include/av_pause_disconnect_test.h
new file mode 100644
index 0000000..623d4af
--- /dev/null
+++ b/engines/2way/test/include/av_pause_disconnect_test.h
@@ -0,0 +1,70 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_PAUSE_DISCONNECT_TEST_H_INCLUDED
+#define AV_PAUSE_DISCONNECT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_pause_disconnect_test : public test_base
+{
+    public:
+        av_pause_disconnect_test(bool aUseProxy) : test_base(aUseProxy),
+                iAudioSourcePaused(false),
+                iAudioSinkPaused(false),
+                iVideoSourcePaused(false),
+                iVideoSinkPaused(false)
+        {};
+
+        ~av_pause_disconnect_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_audio_paused()
+        {
+            return (iAudioSourcePaused && iAudioSinkPaused);
+        }
+        bool check_video_paused()
+        {
+            return (iVideoSourcePaused && iVideoSinkPaused);
+        }
+
+        bool iAudioSourcePaused;
+        bool iAudioSinkPaused;
+        bool iVideoSourcePaused;
+        bool iVideoSinkPaused;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_pause_rec_disconnect_test.h b/engines/2way/test/include/av_pause_rec_disconnect_test.h
new file mode 100644
index 0000000..7b60acd
--- /dev/null
+++ b/engines/2way/test/include/av_pause_rec_disconnect_test.h
@@ -0,0 +1,70 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_PAUSE_REC_DISCONNECT_TEST_H_INCLUDED
+#define AV_PAUSE_REC_DISCONNECT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_pause_rec_disconnect_test : public test_base
+{
+    public:
+        av_pause_rec_disconnect_test(bool aUseProxy) : test_base(aUseProxy),
+                iAudioRecPaused(false),
+                iAudioStartRecId(0),
+                iAudioPauseRecId(0),
+                iVideoRecPaused(false),
+                iVideoStartRecId(0),
+                iVideoPauseRecId(0)
+        {};
+
+        ~av_pause_rec_disconnect_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_rec_paused()
+        {
+            return (iAudioRecPaused && iVideoRecPaused);
+        }
+
+        bool iAudioRecPaused;
+        TPVCmnCommandId iAudioStartRecId;
+        TPVCmnCommandId iAudioPauseRecId;
+        bool iVideoRecPaused;
+        TPVCmnCommandId iVideoStartRecId;
+        TPVCmnCommandId iVideoPauseRecId;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_rec_test.h b/engines/2way/test/include/av_rec_test.h
new file mode 100644
index 0000000..65e1e81
--- /dev/null
+++ b/engines/2way/test/include/av_rec_test.h
@@ -0,0 +1,74 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_REC_TEST_H_INCLUDED
+#define AV_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_rec_test : public test_base
+{
+    public:
+        av_rec_test(bool aUseProxy) : test_base(aUseProxy),
+                iAudioRecStarted(false),
+                iAudioStartRecId(0),
+                iAudioStopRecId(0),
+                iVideoRecStarted(false),
+                iVideoStartRecId(0),
+                iVideoStopRecId(0)
+        {};
+
+        ~av_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_rec_started()
+        {
+            return (iAudioRecStarted && iVideoRecStarted);
+        }
+        bool check_rec_stopped()
+        {
+            return (!iAudioRecStarted && !iVideoRecStarted);
+        }
+
+        bool iAudioRecStarted;
+        TPVCmnCommandId iAudioStartRecId;
+        TPVCmnCommandId iAudioStopRecId;
+        bool iVideoRecStarted;
+        TPVCmnCommandId iVideoStartRecId;
+        TPVCmnCommandId iVideoStopRecId;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_rec_v_preview_test.h b/engines/2way/test/include/av_rec_v_preview_test.h
new file mode 100644
index 0000000..1078863
--- /dev/null
+++ b/engines/2way/test/include/av_rec_v_preview_test.h
@@ -0,0 +1,79 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_REC_V_PREVIEW_TEST_H_INCLUDED
+#define AV_REC_V_PREVIEW_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_rec_v_preview_test : public test_base
+{
+    public:
+        av_rec_v_preview_test(bool aUseProxy) : test_base(aUseProxy),
+                iAudioRecStarted(false),
+                iAudioStartRecId(0),
+                iAudioStopRecId(0),
+                iVideoRecStarted(false),
+                iVideoStartRecId(0),
+                iVideoStopRecId(0),
+                iVideoPreviewStarted(false),
+                iIsDisconnected(true)
+        {};
+
+        ~av_rec_v_preview_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+        void check_audio_video_started();
+
+        bool check_rec_started()
+        {
+            return (iAudioRecStarted && iVideoRecStarted);
+        }
+        bool check_rec_stopped()
+        {
+            return (!iAudioRecStarted && !iVideoRecStarted);
+        }
+
+        bool iAudioRecStarted;
+        TPVCmnCommandId iAudioStartRecId;
+        TPVCmnCommandId iAudioStopRecId;
+        bool iVideoRecStarted;
+        TPVCmnCommandId iVideoStartRecId;
+        TPVCmnCommandId iVideoStopRecId;
+        bool iVideoPreviewStarted;
+        bool iIsDisconnected;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/av_test.h b/engines/2way/test/include/av_test.h
new file mode 100644
index 0000000..03265c3
--- /dev/null
+++ b/engines/2way/test/include/av_test.h
@@ -0,0 +1,74 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AV_TEST_H_INCLUDED
+#define AV_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class av_test : public test_base
+{
+    public:
+        av_test(PVMFFormatType audio_src_format = PVMF_MIME_AMR_IF2,
+                PVMFFormatType audio_sink_format = PVMF_MIME_AMR_IF2,
+                PVMFFormatType video_src_format = PVMF_MIME_YUV420,
+                PVMFFormatType video_sink_format = PVMF_MIME_YUV420,
+                bool aUseProxy = false)
+                : test_base(audio_src_format, audio_sink_format, video_src_format, video_sink_format, aUseProxy, 1)
+        {}
+
+        ~av_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        void TimerCallback();
+
+    private:
+        virtual void ConnectSucceeded();
+        bool start_async_test();
+        virtual void InitFailed();
+        virtual void ConnectFailed();
+        virtual void AudioAddSinkCompleted();
+        virtual void AudioAddSourceCompleted();
+        virtual void VideoAddSinkFailed();
+        virtual void VideoAddSinkSucceeded();
+        virtual void VideoAddSourceSucceeded();
+        virtual void VideoAddSourceFailed();
+        virtual void RstCmdCompleted();
+
+        virtual void AudioRemoveSourceCompleted();
+        virtual void AudioRemoveSinkCompleted();
+
+        virtual void VideoRemoveSourceCompleted();
+        virtual void VideoRemoveSinkCompleted();
+
+        void CheckForTimeToDisconnect();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/avi_test.h b/engines/2way/test/include/avi_test.h
new file mode 100644
index 0000000..937ee71
--- /dev/null
+++ b/engines/2way/test/include/avi_test.h
@@ -0,0 +1,83 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef AVI_TEST_H_INCLUDED
+#define AVI_TEST_H_INCLUDED
+
+#include "test_engine.h"
+#ifndef PVMI_MIO_AVIFILE_FACTORY_H_INCLUDED
+#include "pvmi_mio_avi_wav_file_factory.h"
+#endif
+
+class avi_test : public engine_test
+{
+    public:
+        avi_test(bool aUseProxy,
+                 PVMFFormatType audio_src_format = PVMF_MIME_PCM16,
+                 PVMFFormatType audio_sink_format = PVMF_MIME_PCM16,
+                 PVMFFormatType video_src_format = PVMF_MIME_YUV420,
+                 PVMFFormatType video_sink_format = PVMF_MIME_YUV420)
+                : engine_test(aUseProxy, 1) ,
+                iAudSrcFormatType(audio_src_format),
+                iAudSinkFormatType(audio_sink_format),
+                iVidSrcFormatType(video_src_format),
+                iVidSinkFormatType(video_sink_format),
+                iPVAviFile(NULL),
+                iFileParser(NULL),
+                iAudioMediaInput(NULL),
+                iVideoMediaInput(NULL)
+        {}
+
+        ~avi_test()
+        {
+            delete iPVAviFile;
+            PVAviFile::DeleteAviFileParser((PVAviFile*)iFileParser);
+            delete iAudioMediaInput;
+            delete iVideoMediaInput;
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        void CommandCompleted(const PVCmdResponse& aResponse);
+
+        void TimerCallback();
+
+        bool HandleAvi();
+
+    private:
+        bool start_async_test();
+        PVMFFormatType iAudSrcFormatType, iAudSinkFormatType;
+        PVMFFormatType iVidSrcFormatType, iVidSinkFormatType;
+        PVAviFile*	iPVAviFile;
+        OsclAny*				 iFileParser;
+        Oscl_FileServer          iFileServer;
+        uint32 iAudioNum;
+        uint32 iVideoNum;
+        PvmiMIOControl* iAudioMediaInput;
+        PvmiMIOControl* iVideoMediaInput;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/comp_audio_in_out_test.h b/engines/2way/test/include/comp_audio_in_out_test.h
new file mode 100644
index 0000000..32554f0
--- /dev/null
+++ b/engines/2way/test/include/comp_audio_in_out_test.h
@@ -0,0 +1,17 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
diff --git a/engines/2way/test/include/comp_video_h263_in_out_test.h b/engines/2way/test/include/comp_video_h263_in_out_test.h
new file mode 100644
index 0000000..32554f0
--- /dev/null
+++ b/engines/2way/test/include/comp_video_h263_in_out_test.h
@@ -0,0 +1,17 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
diff --git a/engines/2way/test/include/connect_cancel_test.h b/engines/2way/test/include/connect_cancel_test.h
new file mode 100644
index 0000000..2d43ec8
--- /dev/null
+++ b/engines/2way/test/include/connect_cancel_test.h
@@ -0,0 +1,55 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CONNECT_CANCEL_TEST_H_INCLUDED
+#define CONNECT_CANCEL_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class connect_cancel_test : public test_base
+{
+    public:
+        connect_cancel_test(bool aUseProxy) : test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy) {};
+
+        ~connect_cancel_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+
+
+    private:
+        virtual void InitSucceeded();
+        virtual void InitFailed();
+        virtual void ConnectCancelled();
+        virtual void DisCmdSucceeded();
+        virtual void DisCmdFailed();
+        virtual void CancelCmdCompleted();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/connect_test.h b/engines/2way/test/include/connect_test.h
new file mode 100644
index 0000000..9b7fc84
--- /dev/null
+++ b/engines/2way/test/include/connect_test.h
@@ -0,0 +1,64 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CONNECT_TEST_H_INCLUDED
+#define CONNECT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class connect_test : public test_base
+{
+    public:
+        connect_test(bool aUseProxy, int aMaxRuns, bool runTimerTest = false) :
+                test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy, aMaxRuns) ,
+                iRunTimerTest(runTimerTest),
+                i324mConfigInterface(NULL),
+                iMP4H263EncoderInterface(NULL) {};
+
+        ~connect_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+
+    private:
+        virtual void InitSucceeded();
+        virtual void InitFailed();
+        virtual void EncoderIFSucceeded();
+        virtual void EncoderIFFailed();
+        virtual void ConnectFailed();
+        virtual void ConnectCancelled();
+        virtual void DisCmdSucceeded();
+        virtual void DisCmdFailed();
+
+        bool iRunTimerTest;
+        PVInterface *i324mConfigInterface;
+        PVInterface *iMP4H263EncoderInterface;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/init_cancel_test.h b/engines/2way/test/include/init_cancel_test.h
new file mode 100644
index 0000000..f2711cc
--- /dev/null
+++ b/engines/2way/test/include/init_cancel_test.h
@@ -0,0 +1,57 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INIT_CANCEL_TEST_H_INCLUDED
+#define INIT_CANCEL_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class init_cancel_test : public test_base
+{
+    public:
+        init_cancel_test(bool aUseProxy, bool isSIP = false) : test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy, isSIP)
+        {
+            iRstCmdId  = iInitCmdId = iCnclCmdId = 0;
+        }
+
+        ~init_cancel_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+
+    private:
+        virtual void InitSucceeded();
+        virtual void InitCancelled();
+        virtual void InitFailed();
+        virtual void QueryInterfaceSucceeded();
+
+        PVCommandId iCnclCmdId;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/init_play_reset_test.h b/engines/2way/test/include/init_play_reset_test.h
new file mode 100644
index 0000000..44246d4
--- /dev/null
+++ b/engines/2way/test/include/init_play_reset_test.h
@@ -0,0 +1,56 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INIT_PLAY_RESET_TEST_H_INCLUDED
+#define INIT_PLAY_RESET_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class init_play_reset_test : public test_base
+{
+    public:
+        init_play_reset_test(bool aUseProxy, const OSCL_wString& aFilename) : test_base(aUseProxy)
+        {
+            iFilename = aFilename;
+        };
+
+        ~init_play_reset_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/init_play_test.h b/engines/2way/test/include/init_play_test.h
new file mode 100644
index 0000000..45ad42a
--- /dev/null
+++ b/engines/2way/test/include/init_play_test.h
@@ -0,0 +1,57 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INIT_PLAY_TEST_H_INCLUDED
+#define INIT_PLAY_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class init_play_test : public test_base
+{
+    public:
+        init_play_test(bool aUseProxy, const OSCL_wString& aFilename, int aMaxRuns) :
+                test_base(aUseProxy, aMaxRuns)
+        {
+            iFilename = aFilename;
+        };
+
+        ~init_play_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/init_rec_reset_test.h b/engines/2way/test/include/init_rec_reset_test.h
new file mode 100644
index 0000000..e0522c8
--- /dev/null
+++ b/engines/2way/test/include/init_rec_reset_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INIT_REC_RESET_TEST_H_INCLUDED
+#define INIT_REC_RESET_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class init_rec_reset_test : public test_base
+{
+    public:
+        init_rec_reset_test(bool aUseProxy) : test_base(aUseProxy) {};
+
+        ~init_rec_reset_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/init_rec_test.h b/engines/2way/test/include/init_rec_test.h
new file mode 100644
index 0000000..ee6b942
--- /dev/null
+++ b/engines/2way/test/include/init_rec_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INIT_REC_TEST_H_INCLUDED
+#define INIT_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class init_rec_test : public test_base
+{
+    public:
+        init_rec_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns) {};
+
+        ~init_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/init_test.h b/engines/2way/test/include/init_test.h
new file mode 100644
index 0000000..c35a2c2
--- /dev/null
+++ b/engines/2way/test/include/init_test.h
@@ -0,0 +1,52 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INIT_TEST_H_INCLUDED
+#define INIT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class init_test : public test_base
+{
+    public:
+        init_test(bool aUseProxy, int aMaxRuns, bool isSIP = false) :
+                test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy, aMaxRuns, isSIP) {  };
+
+        ~init_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+
+    private:
+        virtual void InitSucceeded();
+        virtual void InitFailed();
+        virtual void RstCmdCompleted();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/invalid_command_test.h b/engines/2way/test/include/invalid_command_test.h
new file mode 100644
index 0000000..89d18cb
--- /dev/null
+++ b/engines/2way/test/include/invalid_command_test.h
@@ -0,0 +1,50 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef INVALID_COMMAND_TEST_H_INCLUDED
+#define INVALID_COMMAND_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class invalid_command_test : public test_base
+{
+    public:
+        invalid_command_test() {};
+
+        ~invalid_command_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+    private:
+        bool test_command(TPV2WayCommandType cmd);
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/pff_eos_test.h b/engines/2way/test/include/pff_eos_test.h
new file mode 100644
index 0000000..323ab38
--- /dev/null
+++ b/engines/2way/test/include/pff_eos_test.h
@@ -0,0 +1,74 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PFF_EOS_TEST_H_INCLUDED
+#define PFF_EOS_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class pff_eos_test : public test_base
+{
+    public:
+        pff_eos_test(bool aUseProxy,
+                     const OSCL_wString& aFilename,
+                     bool aWaitForAudioEOS,
+                     bool aWaitForVideoEOS,
+                     int aMaxRuns) : test_base(aUseProxy, aMaxRuns),
+                iWaitForAudioEOS(aWaitForAudioEOS),
+                iWaitForVideoEOS(aWaitForVideoEOS),
+                iAudioEOSRecv(false),
+                iVideoEOSRecv(false),
+                iStopPlayLCalled(false)
+        {
+            iFilename = aFilename;
+        };
+
+        ~pff_eos_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        void check_eos();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+
+        bool iWaitForAudioEOS;
+        bool iWaitForVideoEOS;
+
+        bool iAudioEOSRecv;
+        bool iVideoEOSRecv;
+        bool iStopPlayLCalled;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/pff_pause_disconnect_test.h b/engines/2way/test/include/pff_pause_disconnect_test.h
new file mode 100644
index 0000000..38213b8
--- /dev/null
+++ b/engines/2way/test/include/pff_pause_disconnect_test.h
@@ -0,0 +1,63 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PFF_PAUSE_DISCONNECT_TEST_H_INCLUDED
+#define PFF_PAUSE_DISCONNECT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class pff_pause_disconnect_test : public test_base
+{
+    public:
+        pff_pause_disconnect_test(bool aUseProxy,
+                                  const OSCL_wString& aFilename,
+                                  bool aBeforeAddSource) :
+                test_base(aUseProxy),
+                iUsePlayFileBeforeAddSource(aBeforeAddSource)
+        {
+            iFilename = aFilename;
+        };
+
+        ~pff_pause_disconnect_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        void is_av_started();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+        bool iUsePlayFileBeforeAddSource;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/play_from_file_disconnect_test.h b/engines/2way/test/include/play_from_file_disconnect_test.h
new file mode 100644
index 0000000..31d427d
--- /dev/null
+++ b/engines/2way/test/include/play_from_file_disconnect_test.h
@@ -0,0 +1,63 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PLAY_FROM_FILE_DISCONNECT_TEST_H_INCLUDED
+#define PLAY_FROM_FILE_DISCONNECT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class play_from_file_disconnect_test : public test_base
+{
+    public:
+        play_from_file_disconnect_test(bool aUseProxy,
+                                       const OSCL_wString& aFilename,
+                                       bool aBeforeAddSource) :
+                test_base(aUseProxy),
+                iUsePlayFileBeforeAddSource(aBeforeAddSource)
+        {
+            iFilename = aFilename;
+        };
+
+        ~play_from_file_disconnect_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        void is_av_started();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+        bool iUsePlayFileBeforeAddSource;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/play_from_file_pause_test.h b/engines/2way/test/include/play_from_file_pause_test.h
new file mode 100644
index 0000000..fcac4d0
--- /dev/null
+++ b/engines/2way/test/include/play_from_file_pause_test.h
@@ -0,0 +1,64 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PLAY_FROM_FILE_PAUSE_TEST_H_INCLUDED
+#define PLAY_FROM_FILE_PAUSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class play_from_file_pause_test : public test_base
+{
+    public:
+        play_from_file_pause_test(bool aUseProxy,
+                                  const OSCL_wString& aFilename,
+                                  bool aBeforeAddSource,
+                                  int aMaxRuns) :
+                test_base(aUseProxy, aMaxRuns),
+                iUsePlayFileBeforeAddSource(aBeforeAddSource)
+        {
+            iFilename = aFilename;
+        };
+
+        ~play_from_file_pause_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        void is_av_started();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+        bool iUsePlayFileBeforeAddSource;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/play_from_file_test.h b/engines/2way/test/include/play_from_file_test.h
new file mode 100644
index 0000000..6107d7a
--- /dev/null
+++ b/engines/2way/test/include/play_from_file_test.h
@@ -0,0 +1,58 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PLAY_FROM_FILE_TEST_H_INCLUDED
+#define PLAY_FROM_FILE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class play_from_file_test : public test_base
+{
+    public:
+        play_from_file_test(bool aUseProxy,
+                            const OSCL_wString& aFilename,
+                            int aMaxRuns) : test_base(aUseProxy, aMaxRuns)
+        {
+            iFilename = aFilename;
+        };
+
+        ~play_from_file_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/test_base.h b/engines/2way/test/include/test_base.h
new file mode 100644
index 0000000..8071ee3
--- /dev/null
+++ b/engines/2way/test/include/test_base.h
@@ -0,0 +1,136 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_BASE_H_INCLUDED
+#define TEST_BASE_H_INCLUDED
+
+#include "test_engine.h"
+
+#define TEST_DURATION 10000
+
+class test_base : public engine_test,
+            public H324MConfigObserver
+{
+    public:
+
+        test_base(PVMFFormatType aAudSrcFormatType,
+                  PVMFFormatType aAudSinkFormatType,
+                  PVMFFormatType aVidSrcFormatType,
+                  PVMFFormatType aVidSinkFormatType,
+                  bool aUseProxy = false,
+                  int aMaxRuns = 1,
+                  bool isSIP = false) :
+                engine_test(aUseProxy, aMaxRuns),
+                iH324MConfig(NULL),
+                iEncoderIFCommandId(-1),
+                i324mIFCommandId(-1),
+                iCancelCmdId(-1),
+                iQueryInterfaceCmdId(-1),
+                iStackIFSet(false),
+                iEncoderIFSet(false),
+                iSIP(isSIP),
+                iAudSrcFormatType(aAudSrcFormatType),
+                iAudSinkFormatType(aAudSinkFormatType),
+                iVidSrcFormatType(aVidSrcFormatType),
+                iVidSinkFormatType(aVidSinkFormatType),
+                iTempH324MConfigIterface(NULL)
+        {
+        }
+
+        virtual ~test_base()
+        {
+        }
+
+        template<class DestructClass>
+        class AppenderDestructDealloc : public OsclDestructDealloc
+        {
+            public:
+                virtual void destruct_and_dealloc(OsclAny *ptr)
+                {
+                    delete((DestructClass*)ptr);
+                }
+        };
+
+    protected:
+        void InitializeLogs();
+
+        virtual bool Init();
+        virtual void CommandCompleted(const PVCmdResponse& aResponse);
+
+        void CreateH324Component(bool aCreateH324 = true);
+
+        void H324MConfigCommandCompletedL(PVMFCmdResp& aResponse);
+        void H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification);
+
+        virtual void QueryInterfaceSucceeded();
+
+        //------------------- Functions overridden in test classes for specific behavior------
+        virtual bool start_async_test();
+
+        virtual void InitSucceeded();
+        virtual void InitFailed();
+        virtual void InitCancelled();
+
+        virtual void ConnectSucceeded();
+        virtual void ConnectFailed();
+        virtual void ConnectCancelled();
+
+        virtual void CancelCmdCompleted();
+
+
+        virtual void RstCmdCompleted();
+        virtual void DisCmdSucceeded();
+        virtual void DisCmdFailed();
+
+        virtual void EncoderIFSucceeded();
+        virtual void EncoderIFFailed();
+
+
+        // audio
+        virtual void AudioAddSinkCompleted();
+        virtual void AudioAddSourceCompleted();
+        virtual void AudioRemoveSourceCompleted();
+        virtual void AudioRemoveSinkCompleted();
+
+        // video
+        virtual void VideoAddSinkSucceeded();
+        virtual void VideoAddSinkFailed();
+        virtual void VideoAddSourceSucceeded();
+        virtual void VideoAddSourceFailed();
+        virtual void VideoRemoveSourceCompleted();
+        virtual void VideoRemoveSinkCompleted();
+        //------------------- END Functions overridden in test classes for specific behavior------
+
+        H324MConfigInterface* iH324MConfig;
+        PVCommandId iEncoderIFCommandId;
+        PVCommandId i324mIFCommandId;
+        PVCommandId iCancelCmdId;
+        PVCommandId iQueryInterfaceCmdId;
+
+        bool iStackIFSet;
+        bool iEncoderIFSet;
+        bool iSIP;
+
+        PVMFFormatType iAudSrcFormatType, iAudSinkFormatType;
+        PVMFFormatType iVidSrcFormatType, iVidSinkFormatType;
+        PVInterface* iTempH324MConfigIterface;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/test_engine.h b/engines/2way/test/include/test_engine.h
new file mode 100644
index 0000000..5ed7663
--- /dev/null
+++ b/engines/2way/test/include/test_engine.h
@@ -0,0 +1,424 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_ENGINE_H_INCLUDED
+#define TEST_ENGINE_H_INCLUDED
+
+#include "oscl_error.h"
+#include "oscl_timer.h"
+#include "oscl_mem.h"
+#include "oscl_scheduler.h"
+#include "oscl_utf8conv.h"
+#include "pvlogger.h"
+#include "pvlogger_stderr_appender.h"
+#include "pvlogger_file_appender.h"
+#include "pvlogger_time_and_id_layout.h"
+#include "test_case.h"
+#include "text_test_interpreter.h"
+#include "pv_2way_interface.h"
+#include "pv_2way_engine_factory.h"
+#include "pv_2way_proxy_factory.h"
+#include "pvmf_media_input_node_factory.h"
+#include "pv_media_output_node_factory.h"
+#include "pvmi_media_io_fileoutput.h"
+#include "pvmi_mio_fileinput_factory.h"
+#include "pv_engine_observer.h"
+#include "pv_engine_observer_message.h"
+#include "tsc_h324m_config_interface.h"
+
+#if 0
+#include "pvmf_amrconverter_node.h"
+#endif
+#ifndef NO_2WAY_324
+#include "pv_comms_io_node_factory.h"
+#include "pvmi_mio_comm_loopback_factory.h"
+#endif
+
+
+#define RX_LOGGER_TAG _STRLIT_CHAR("pvcommionode.rx.bin")
+#define TX_LOGGER_TAG _STRLIT_CHAR("pvcommionode.tx.bin")
+#define PVSIP2WAY_PROFILE _STRLIT_CHAR("pvSIP2Way")
+#define PVSIPDEMO_ADDRESS _STRLIT_CHAR("sip:pvSIPDemo@")
+#define PVSIPDEMO2_ADDRESS _STRLIT_CHAR("sip:pvSIPDemo2@")
+#define PVSIP_DEFAULT_REALM _STRLIT_CHAR("pvrealm")
+
+
+#define TEST_RX_LOG_FILENAME _STRLIT("commrx.bin")
+#define TEST_TX_LOG_FILENAME _STRLIT("commtx.bin")
+#define TEST_LOG_FILENAME _STRLIT("test2way.log")
+#define AUDIO_SOURCE_FILENAME _STRLIT("audio_in.if2")
+#define AUDIO_SOURCE3_FILENAME _STRLIT("audio_in.amr")
+#define AUDIO_SOURCE_RAW_FILENAME _STRLIT("pcm16testinput.pcm")
+#define AUDIO_SINK_FILENAME _STRLIT("audio_if2_out.dat")
+#define AUDIO_SINK_RAW_FILENAME _STRLIT("audio_pcm16_out.dat")
+#define AUDIO_SINK2_FILENAME _STRLIT("audio_ietf_out.dat")
+#define VIDEO_SOURCE_YUV_FILENAME _STRLIT("yuv420video.yuv")
+#define VIDEO_SOURCE_H263_FILENAME _STRLIT("h263video.h263")
+#define VIDEO_SOURCE_M4V_FILENAME _STRLIT("m4vvideo.m4v")
+#define VIDEO_SINK_YUV_FILENAME _STRLIT("video_yuv_out.dat")
+#define VIDEO_SINK_H263_FILENAME _STRLIT("video_h263_out.dat")
+#define VIDEO_SINK_M4V_FILENAME _STRLIT("video_m4v_out.dat")
+#define VIDEO_PREVIEW_FILENAME _STRLIT("video_preview_out.dat")
+#define RECORDED_CALL_FILENAME _STRLIT("recorded_call.mp4")
+#define AUDIO_ONLY_PLAY_FILENAME _STRLIT("pv-amr-122_novisual.3gp")
+#define AUDIO_H263_PLAY_FILENAME _STRLIT("pv-amr-122_h263-64.3gp")
+#define AUDIO_MPEG4_PLAY_FILENAME _STRLIT("pv2-amr122_mpeg4-rvlcs-64.3gp")
+#define H263_ONLY_PLAY_FILENAME _STRLIT("pv-noaudio_h263-64.3gp")
+#define MPEG4_ONLY_PLAY_FILENAME _STRLIT("pv2-noaudio_mpeg4-rvlcs-64.3gp")
+#define SQCIF_PLAY_FILENAME _STRLIT("sqcif1.3gp")
+#define QVGA_PLAY_FILENAME _STRLIT("qvga.3gp")
+
+
+
+extern FILE *fileoutput;
+
+
+template<class DestructClass>
+class TwoWayLogAppenderDestructDealloc : public OsclDestructDealloc
+{
+    public:
+        virtual void destruct_and_dealloc(OsclAny *ptr)
+        {
+            delete((DestructClass*)ptr);
+        }
+};
+
+class engine_test_suite : public test_case
+{
+    public:
+        engine_test_suite();
+
+    private:
+        void proxy_tests(const bool aProxy);
+        void play_from_file_tests(const bool aProxy,
+                                  const OSCL_wString& aFilename,
+                                  const bool aHasAudio,
+                                  const bool aHasVideo);
+};
+
+class engine_timer;
+
+//test function oscl_str_is_valid_utf8
+class engine_test : public test_case,
+            public OsclActiveObject,
+            public PVCommandStatusObserver,
+            public PVInformationalEventObserver,
+            public PVErrorEventObserver
+{
+    public:
+        engine_test(bool aUseProxy = false,
+                    int aMaxRuns = 1) : OsclActiveObject(OsclActiveObject::EPriorityNominal, "Test Engine"),
+                iAudioSourceAdded(false),
+                iAudioAddSourceId(0),
+                iAudioRemoveSourceId(0),
+                iAudioPauseSourceId(0),
+                iAudioResumeSourceId(0),
+                iAudioSinkAdded(false),
+                iAudioAddSinkId(0),
+                iAudioAddSink2Id(0),
+                iAudioRemoveSinkId(0),
+                iAudioPauseSinkId(0),
+                iAudioResumeSinkId(0),
+                iVideoSourceAdded(false),
+                iVideoAddSourceId(0),
+                iVideoRemoveSourceId(0),
+                iVideoPauseSourceId(0),
+                iVideoResumeSourceId(0),
+                iVideoSinkAdded(false),
+                iVideoAddSinkId(0),
+                iVideoAddSink2Id(0),
+                iVideoRemoveSinkId(0),
+                iVideoPauseSinkId(0),
+                iVideoResumeSinkId(0),
+                iUseProxy(aUseProxy),
+                iMaxRuns(aMaxRuns),
+                iCurrentRun(0),
+                iCommServer(NULL),
+                iSelAudioSource(NULL),
+                iSelAudioSink(NULL),
+                iSelVideoSource(NULL),
+                iSelVideoSink(NULL),
+#ifndef NO_2WAY_324
+                iCommServerIOControl(NULL),
+#endif
+                iAudioSource(NULL),
+                iAudioSourceRaw(NULL),
+                iAudioSource2(NULL),
+                iAudioSource3(NULL),
+                iAudioSourceIOControl(NULL),
+                iAudioSourceRawIOControl(NULL),
+                iAudioSource2IOControl(NULL),
+                iAudioSource3IOControl(NULL),
+                iGetSessionParamsId(0),
+                iVideoSourceYUV(NULL),
+                iVideoSourceH263(NULL),
+                iVideoSourceM4V(NULL),
+                iAudioSink(NULL),
+                iAudioSinkRaw(NULL),
+                iAudioSink2(NULL),
+                iVideoSinkYUV(NULL),
+                iVideoSinkH263(NULL),
+                iVideoSinkM4V(NULL),
+                iDuplicatesStarted(false),
+                iVideoPreview(NULL),
+                //iVideoPreviewIOControl(NULL),
+                terminal(NULL),
+                scheduler(NULL),
+                timer(NULL),
+                timer_elapsed(false),
+                early_close(false),
+                iTestStatus(true)
+        {
+            iConnectOptions.iLoopbackMode = PV_LOOPBACK_MUX;
+            iRstCmdId = 0;
+            iDisCmdId = 0;
+            iConnectCmdId = 0;
+            iInitCmdId = 0;
+            iCommsAddSourceId = 0;
+        }
+
+        virtual ~engine_test()
+        {
+        }
+
+        virtual void test() = 0;
+
+        virtual void Run() = 0;
+
+        virtual void DoCancel() = 0;
+
+        void HandleErrorEvent(const PVAsyncErrorEvent& /*aEvent*/)
+        {
+        }
+
+        virtual void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent) = 0;
+
+        virtual void CommandCompleted(const PVCmdResponse& aResponse) = 0;
+
+        virtual void TimerCallback() {};
+
+        static char iProfileName[32];
+        static char iPeerAddress[64];
+        static uint32 iMediaPorts[2];
+
+    protected:
+
+
+        PVCommandId iRstCmdId, iDisCmdId, iConnectCmdId, iInitCmdId;
+
+        PVCommandId iCommsAddSourceId;
+
+        bool iAudioSourceAdded;
+        PVCommandId iAudioAddSourceId;
+        PVCommandId iAudioAddSource2Id;
+        PVCommandId iAudioRemoveSourceId;
+        PVCommandId iAudioPauseSourceId;
+        PVCommandId iAudioResumeSourceId;
+
+        bool iAudioSinkAdded;
+        PVCommandId iAudioAddSinkId;
+        PVCommandId iAudioAddSink2Id;
+        PVCommandId iAudioRemoveSinkId;
+        PVCommandId iAudioPauseSinkId;
+        PVCommandId iAudioResumeSinkId;
+
+        bool iVideoSourceAdded;
+        PVCommandId iVideoAddSourceId;
+        PVCommandId iVideoAddSource2Id;
+        PVCommandId iVideoRemoveSourceId;
+        PVCommandId iVideoPauseSourceId;
+        PVCommandId iVideoResumeSourceId;
+
+        bool iVideoSinkAdded;
+        PVCommandId iVideoAddSinkId;
+        PVCommandId iVideoAddSink2Id;
+        PVCommandId iVideoRemoveSinkId;
+        PVCommandId iVideoPauseSinkId;
+        PVCommandId iVideoResumeSinkId;
+
+        virtual void disconnect()
+        {
+            int error = 0;
+            OSCL_TRY(error, iDisCmdId = terminal->Disconnect());
+            if (error)
+            {
+                reset();
+            }
+        }
+
+        virtual void reset()
+        {
+            int error = 0;
+            OSCL_TRY(error, iRstCmdId = terminal->Reset());
+            if (error)
+            {
+                RunIfNotReady();
+            }
+        }
+
+        virtual void connect()
+        {
+            int error = 0;
+            OSCL_TRY(error, iConnectCmdId = terminal->Connect(iConnectOptions, iCommServer));
+            if (error)
+            {
+                reset();
+            }
+        }
+
+        virtual void printFormatString(PVMFFormatType aFormatType)
+        {
+            fprintf(fileoutput, "%s", aFormatType.getMIMEStrPtr());
+        }
+
+        bool check_audio_started()
+        {
+            return (iAudioSourceAdded && iAudioSinkAdded);
+        }
+        bool check_audio_stopped()
+        {
+            return (!iAudioSourceAdded && !iAudioSinkAdded);
+        }
+        bool check_video_started()
+        {
+            return (iVideoSourceAdded && iVideoSinkAdded);
+        }
+        bool check_video_stopped()
+        {
+            return (!iVideoSourceAdded && !iVideoSinkAdded);
+        }
+
+
+        PVMFNodeInterface *get_audio_source(PVMFFormatType format);
+        PVMFNodeInterface *get_audio_sink(PVMFFormatType format);
+        PVMFNodeInterface *get_video_source(PVMFFormatType format);
+        PVMFNodeInterface *get_video_sink(PVMFFormatType format);
+
+        void create_sink_source();
+        void destroy_sink_source();
+
+        void init_mime_strings();
+
+        bool iUseProxy;
+        int iMaxRuns;
+        int iCurrentRun;
+        PVMFNodeInterface* iCommServer;
+        PVMFNodeInterface* iSelAudioSource;
+        PVMFNodeInterface* iSelAudioSink;
+        PVMFNodeInterface* iSelVideoSource;
+        PVMFNodeInterface* iSelVideoSink;
+#ifndef NO_2WAY_324
+        PvmiMIOControl* iCommServerIOControl;
+        PvmiMIOCommLoopbackSettings iCommSettings;
+#endif
+        PV2Way324ConnectOptions iConnectOptions;
+        //CPV2WaySIPConnectInfo iSIPConnectOptions;
+        PV2Way324InitInfo iSdkInitInfo;
+        //CPV2WaySIPInitInfo iSdkSIPInitInfo;
+
+        PvmiMIOFileInputSettings iAudioSourceRawFileSettings;
+        PvmiMIOFileInputSettings iAudioSource2FileSettings;
+        PvmiMIOFileInputSettings iAudioSource3FileSettings;
+        PvmiMIOFileInputSettings iAudioSourceFileSettings;
+        PVMFNodeInterface* iAudioSource;
+        PVMFNodeInterface* iAudioSourceRaw;
+        PVMFNodeInterface* iAudioSource2;
+        PVMFNodeInterface* iAudioSource3;
+        PvmiMIOControl* iAudioSourceIOControl;
+        PvmiMIOControl* iAudioSourceRawIOControl;
+        PvmiMIOControl* iAudioSource2IOControl;
+        PvmiMIOControl* iAudioSource3IOControl;
+
+        PVCommandId iGetSessionParamsId;
+        PvmiMIOFileInputSettings iVideoSourceYUVFileSettings;
+        PvmiMIOFileInputSettings iVideoSourceH263FileSettings;
+        PvmiMIOFileInputSettings iVideoSourceM4VFileSettings;
+        PVMFNodeInterface* iVideoSourceYUV;
+        PVMFNodeInterface* iVideoSourceH263;
+        PVMFNodeInterface* iVideoSourceM4V;
+        PvmiMIOControl* iVideoSourceYUVIOControl;
+        PvmiMIOControl* iVideoSourceH263IOControl;
+        PvmiMIOControl* iVideoSourceM4VIOControl;
+
+
+        OSCL_wHeapString<OsclMemAllocator> iAudioSinkFileName;
+        OSCL_wHeapString<OsclMemAllocator> iAudioSinkRawFileName;
+        OSCL_wHeapString<OsclMemAllocator> iAudioSink2FileName;
+        PVMFNodeInterface* iAudioSink;
+        PVMFNodeInterface* iAudioSinkRaw;
+        PVMFNodeInterface* iAudioSink2;
+        /*    PVRefFileOutput* iAudioSinkIOControl;
+            PVRefFileOutput* iAudioSinkRawIOControl;
+            PVRefFileOutput* iAudioSink2IOControl;*/
+
+        OSCL_wHeapString<OsclMemAllocator> iVideoSinkYUVFileName;
+        OSCL_wHeapString<OsclMemAllocator> iVideoSinkH263FileName;
+        OSCL_wHeapString<OsclMemAllocator> iVideoSinkM4VFileName;
+        PVMFNodeInterface* iVideoSinkYUV;
+        PVMFNodeInterface* iVideoSinkH263;
+        PVMFNodeInterface* iVideoSinkM4V;
+        /*   PVRefFileOutput* iVideoSinkYUVIOControl;
+           PVRefFileOutput* iVideoSinkH263IOControl;
+           PVRefFileOutput* iVideoSinkM4VIOControl;*/
+        bool iDuplicatesStarted;
+        OSCL_wHeapString<OsclMemAllocator> iVideoPreviewFileName;
+        PVMFNodeInterface* iVideoPreview;
+        //PVRefFileOutput* iVideoPreviewIOControl;
+
+        CPV2WayInterface *terminal;
+        OsclExecScheduler *scheduler;
+        engine_timer *timer;
+        bool timer_elapsed;
+        bool early_close;
+
+        CPV2WayH263ConfigInfo iH263ConfigInfo;
+        CPV2WayM4VConfigInfo iM4VConfigInfo;
+
+        bool iTestStatus;
+};
+
+class engine_timer : public OsclTimerObject
+{
+    public:
+        engine_timer(engine_test *aObserver) : OsclTimerObject(OsclActiveObject::EPriorityNominal, "Test Engine Timer"),
+                iObserver(aObserver)
+        {};
+
+        ~engine_timer()
+        {
+            Cancel();
+        }
+
+    protected:
+        void Run()
+        {
+            iObserver->TimerCallback();
+        }
+        void DoCancel()
+        {
+            OsclTimerObject::DoCancel();
+        };
+
+        engine_test *iObserver;
+
+};
+
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/test_everything_test.h b/engines/2way/test/include/test_everything_test.h
new file mode 100644
index 0000000..8a65b74
--- /dev/null
+++ b/engines/2way/test/include/test_everything_test.h
@@ -0,0 +1,89 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_EVERYTHING_TEST_H_INCLUDED
+#define TEST_EVERYTHING_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class test_everything_test : public test_base
+{
+    public:
+        test_everything_test(bool aUseProxy,
+                             const OSCL_wString& aFilename) :
+                test_base(aUseProxy),
+                iAudioRecStarted(false),
+                iAudioStartRecId(0),
+                iAudioStopRecId(0),
+                iVideoRecStarted(false),
+                iVideoStartRecId(0),
+                iVideoStopRecId(0),
+                iPlayStarted(false),
+                iVideoPreviewStarted(false),
+                iRecordFileInitialized(false)
+        {
+            iFilename = aFilename;
+        };
+
+        ~test_everything_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_rec_started()
+        {
+            return (iAudioRecStarted && iVideoRecStarted);
+        }
+        bool check_rec_stopped()
+        {
+            return (!iAudioRecStarted && !iVideoRecStarted);
+        }
+
+        void is_test_done();
+
+        bool iAudioRecStarted;
+        TPVCmnCommandId iAudioStartRecId;
+        TPVCmnCommandId iAudioStopRecId;
+        bool iVideoRecStarted;
+        TPVCmnCommandId iVideoStartRecId;
+        TPVCmnCommandId iVideoStopRecId;
+
+        bool iPlayStarted;
+        bool iVideoPreviewStarted;
+        bool iRecordFileInitialized;
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/use_play_file_test.h b/engines/2way/test/include/use_play_file_test.h
new file mode 100644
index 0000000..dff8459
--- /dev/null
+++ b/engines/2way/test/include/use_play_file_test.h
@@ -0,0 +1,85 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef USE_PLAY_FILE_TEST_H_INCLUDED
+#define USE_PLAY_FILE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class use_play_file_test : public test_base
+{
+    public:
+        use_play_file_test(bool aUseProxy,
+                           const OSCL_wString& aFilename,
+                           bool aBeforeAddSource,
+                           bool aStartPlayBeforeUsePlayFile) : test_base(aUseProxy),
+                iUsePlayFileBeforeAddSource(aBeforeAddSource),
+                iUsePlayDone(false),
+                iStartPlayBeforeUsePlayFile(aStartPlayBeforeUsePlayFile),
+                iPlayStarted(false)
+        {
+            iFilename = aFilename;
+        };
+
+        ~use_play_file_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        void check_av_started();
+
+        void check_test_done();
+
+        void shutdown()
+        {
+            if (iIsConnected)
+            {
+                disconnect();
+            }
+            else
+            {
+                reset();
+            }
+        }
+
+        bool iIsConnected;
+
+        OSCL_wHeapString<OsclMemAllocator> iFilename;
+        bool iUsePlayFileBeforeAddSource;
+        bool iUsePlayDone;
+        bool iStartPlayBeforeUsePlayFile;
+        bool iPlayStarted;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/user_input_test.h b/engines/2way/test/include/user_input_test.h
new file mode 100644
index 0000000..82e2026
--- /dev/null
+++ b/engines/2way/test/include/user_input_test.h
@@ -0,0 +1,67 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef USER_INPUT_TEST_H_INCLUDED
+#define USER_INPUT_TEST_H_INCLUDED
+
+#include "test_base.h"
+#include "tsc_h324m_config_interface.h"
+
+class user_input_test : public test_base//,
+            //public H324MConfigObserver
+{
+    public:
+        user_input_test(bool aUseProxy, bool aIsDTMF) : test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aUseProxy),
+                iIsDTMF(aIsDTMF)
+                //,iUserInput(NULL)
+        {};
+
+        ~user_input_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        void H324MConfigCommandCompletedL(PVMFCmdResp& aResponse);
+
+        void H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification);
+
+
+    private:
+        virtual void RstCmdCompleted();
+        virtual void DisCmdSucceeded();
+        virtual void DisCmdFailed();
+        virtual void ConnectSucceeeded();
+        virtual void InitFailed();
+        bool start_async_test();
+        PVInterface *i324mConfigInterface;
+        bool iIsDTMF;
+        PVCommandId i324mIFCommandId, iUserInputId;
+
+        CPVUserInput *iUserInput;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/v_only_pause_rec_test.h b/engines/2way/test/include/v_only_pause_rec_test.h
new file mode 100644
index 0000000..f5cf47c
--- /dev/null
+++ b/engines/2way/test/include/v_only_pause_rec_test.h
@@ -0,0 +1,52 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef V_ONLY_PAUSE_REC_TEST_H_INCLUDED
+#define V_ONLY_PAUSE_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class v_only_pause_rec_test : public test_base
+{
+    public:
+        v_only_pause_rec_test(bool aUseProxy, int aMaxRuns) :
+                test_base(aUseProxy, aMaxRuns) {};
+
+        ~v_only_pause_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/v_only_rec_test.h b/engines/2way/test/include/v_only_rec_test.h
new file mode 100644
index 0000000..c6fd00f
--- /dev/null
+++ b/engines/2way/test/include/v_only_rec_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef V_ONLY_REC_TEST_H_INCLUDED
+#define V_ONLY_REC_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class v_only_rec_test : public test_base
+{
+    public:
+        v_only_rec_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns) {};
+
+        ~v_only_rec_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_only_pause_close_test.h b/engines/2way/test/include/video_only_pause_close_test.h
new file mode 100644
index 0000000..901fbd8
--- /dev/null
+++ b/engines/2way/test/include/video_only_pause_close_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_ONLY_PAUSE_CLOSE_TEST_H_INCLUDED
+#define VIDEO_ONLY_PAUSE_CLOSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class video_only_pause_close_test : public test_base
+{
+    public:
+        video_only_pause_close_test(bool aUseProxy) : test_base(aUseProxy) {};
+
+        ~video_only_pause_close_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_only_pause_test.h b/engines/2way/test/include/video_only_pause_test.h
new file mode 100644
index 0000000..e46ed16
--- /dev/null
+++ b/engines/2way/test/include/video_only_pause_test.h
@@ -0,0 +1,61 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_ONLY_PAUSE_TEST_H_INCLUDED
+#define VIDEO_ONLY_PAUSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class video_only_pause_test : public test_base
+{
+    public:
+        video_only_pause_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns),
+                iVideoSourceResumed(false),
+                iVideoSinkResumed(false)
+        {};
+
+        ~video_only_pause_test()
+        {};
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_video_resumed()
+        {
+            return (iVideoSourceResumed && iVideoSinkResumed);
+        }
+
+        bool iVideoSourceResumed;
+        bool iVideoSinkResumed;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_only_resume_close_test.h b/engines/2way/test/include/video_only_resume_close_test.h
new file mode 100644
index 0000000..97a5c6e
--- /dev/null
+++ b/engines/2way/test/include/video_only_resume_close_test.h
@@ -0,0 +1,61 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_ONLY_RESUME_CLOSE_TEST_H_INCLUDED
+#define VIDEO_ONLY_RESUME_CLOSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class video_only_resume_close_test : public test_base
+{
+    public:
+        video_only_resume_close_test(bool aUseProxy) : test_base(aUseProxy),
+                iVideoSourcePaused(false),
+                iVideoSinkPaused(false)
+        {};
+
+        ~video_only_resume_close_test()
+        {};
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+
+        bool check_video_paused()
+        {
+            return (iVideoSourcePaused && iVideoSinkPaused);
+        }
+
+        bool iVideoSourcePaused;
+        bool iVideoSinkPaused;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_only_test.h b/engines/2way/test/include/video_only_test.h
new file mode 100644
index 0000000..f82f1bf
--- /dev/null
+++ b/engines/2way/test/include/video_only_test.h
@@ -0,0 +1,76 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_ONLY_TEST_H_INCLUDED
+#define VIDEO_ONLY_TEST_H_INCLUDED
+
+#include "test_base.h"
+#include "tsc_h324m_config_interface.h"
+
+class video_only_test : public test_base//,
+            //public H324MConfigObserver
+{
+    public:
+        video_only_test(PVMFFormatType video_src_format = PVMF_MIME_YUV420, PVMFFormatType video_sink_format = PVMF_MIME_YUV420, bool aUseProxy = false)
+                : test_base(PVMF_MIME_AMR_IF2, PVMF_MIME_AMR_IF2, video_src_format, video_sink_format, aUseProxy),
+                iSpatialTemporalIndsReceived(false)
+        {
+            i324mConfigInterface = 0;
+        }
+
+        ~video_only_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        void TimerCallback();
+
+        void H324MConfigCommandCompletedL(PVMFCmdResp& aResponse);
+
+        void H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification);
+
+    private:
+        void DoStuffWithH324MConfig();
+        virtual void VideoAddSinkSucceeded();
+        virtual void VideoAddSourceSucceeded();
+        virtual void VideoAddSourceFailed();
+        virtual void EncoderIFSucceeded();
+        virtual void EncoderIFFailed();
+        virtual void DisCmdFailed();
+        virtual void DisCmdSucceeded();
+        virtual void InitFailed();
+        virtual void ConnectSucceeded();
+        virtual void ConnectFailed();
+        bool start_async_test();
+        PVInterface *i324mConfigInterface;
+        PVInterface *iVidEncIFace;
+        bool iSpatialTemporalIndsReceived;
+        PVCommandId i324mIFCommandId, iTradeOffCmd, iTradeOffInd, iEncIFCommandId;
+        PVTrackId iIncomingVideo, iOutgoingVideo;
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_preview_disconnect_test.h b/engines/2way/test/include/video_preview_disconnect_test.h
new file mode 100644
index 0000000..f113ded
--- /dev/null
+++ b/engines/2way/test/include/video_preview_disconnect_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_PREVIEW_DISCONNECT_TEST_H_INCLUDED
+#define VIDEO_PREVIEW_DISCONNECT_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class video_preview_disconnect_test : public test_base
+{
+    public:
+        video_preview_disconnect_test(bool aUseProxy) : test_base(aUseProxy) {};
+
+        ~video_preview_disconnect_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_preview_pause_test.h b/engines/2way/test/include/video_preview_pause_test.h
new file mode 100644
index 0000000..163da55
--- /dev/null
+++ b/engines/2way/test/include/video_preview_pause_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_PREVIEW_PAUSE_TEST_H_INCLUDED
+#define VIDEO_PREVIEW_PAUSE_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class video_preview_pause_test : public test_base
+{
+    public:
+        video_preview_pause_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns) {};
+
+        ~video_preview_pause_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/include/video_preview_test.h b/engines/2way/test/include/video_preview_test.h
new file mode 100644
index 0000000..7f28f24
--- /dev/null
+++ b/engines/2way/test/include/video_preview_test.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef VIDEO_PREVIEW_TEST_H_INCLUDED
+#define VIDEO_PREVIEW_TEST_H_INCLUDED
+
+#include "test_base.h"
+
+
+class video_preview_test : public test_base
+{
+    public:
+        video_preview_test(bool aUseProxy, int aMaxRuns) : test_base(aUseProxy, aMaxRuns) {};
+
+        ~video_preview_test()
+        {
+        }
+
+        void test();
+
+        void Run();
+
+        void DoCancel();
+
+        void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent);
+
+        void CommandCompletedL(const CPVCmnCmdResp& aResponse);
+
+
+    private:
+        bool start_async_test();
+};
+
+
+#endif
+
+
diff --git a/engines/2way/test/src/a_only_pause_rec_test.cpp b/engines/2way/test/src/a_only_pause_rec_test.cpp
new file mode 100644
index 0000000..deb0a09
--- /dev/null
+++ b/engines/2way/test/src/a_only_pause_rec_test.cpp
@@ -0,0 +1,421 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "a_only_pause_rec_test.h"
+
+
+
+void a_only_pause_rec_test::test()
+{
+    fprintf(fileoutput, "Start audio only pause rec test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void a_only_pause_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void a_only_pause_rec_test::DoCancel()
+{
+}
+
+
+void a_only_pause_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+
+                if (check_audio_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void a_only_pause_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetRecordFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            reset();
+            break;
+
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->PauseRecordL(*iAudioSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+
+        case PVT_COMMAND_STOP_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSourceL(*iAudioSource));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+
+            OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSinkL(*iAudioSink));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_PAUSE_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResumeRecordL(*iAudioSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->PauseRecordL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->StopRecordL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool a_only_pause_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/a_only_rec_test.cpp b/engines/2way/test/src/a_only_rec_test.cpp
new file mode 100644
index 0000000..90d3b2c
--- /dev/null
+++ b/engines/2way/test/src/a_only_rec_test.cpp
@@ -0,0 +1,391 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "a_only_rec_test.h"
+
+
+
+void a_only_rec_test::test()
+{
+    fprintf(fileoutput, "Start audio only rec test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void a_only_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void a_only_rec_test::DoCancel()
+{
+}
+
+
+void a_only_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+
+                if (check_audio_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void a_only_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetRecordFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            reset();
+            break;
+
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->StopRecordL(*iAudioSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+
+        case PVT_COMMAND_STOP_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iCurrentRun >= (iMaxRuns - 1))
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                iCurrentRun = iMaxRuns;
+                test_is_true(false);
+            }
+
+            iCurrentRun++;
+            if (iCurrentRun < iMaxRuns)
+            {
+                OSCL_TRY(error, terminal->StartRecordL(*iAudioSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSinkL(*iAudioSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+    }
+}
+
+bool a_only_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/alloc_dealloc_test.cpp b/engines/2way/test/src/alloc_dealloc_test.cpp
new file mode 100644
index 0000000..0d56bf0
--- /dev/null
+++ b/engines/2way/test/src/alloc_dealloc_test.cpp
@@ -0,0 +1,134 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_MEM_AUDIT_H_INCLUDED
+#include "oscl_mem_audit.h"
+#endif
+
+#ifndef OSCL_ERROR_H_INCLUDED
+#include "oscl_error.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_H_INCLUDED
+#include "oscl_scheduler.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PVLOGGER_FILE_APPENDER_H_INCLUDED
+#include "pvlogger_file_appender.h"
+#endif
+
+#ifndef __UNIT_TEST_TEST_ARGS__
+#include "unit_test_args.h"
+#endif
+
+#ifndef OSCL_UTF8CONV_H
+#include "oscl_utf8conv.h"
+#endif
+
+#ifndef OSCL_STRING_UTILS_H_INCLUDED
+#include "oscl_string_utils.h"
+#endif
+
+#include "alloc_dealloc_test.h"
+
+void alloc_dealloc_test::test()
+{
+    fprintf(fileoutput, "Start alloc dealloc test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    CPV2WayInterface *temp = NULL;
+
+    if (iUseProxy)
+    {
+
+        OSCL_TRY(error, temp = CPV2WayProxyFactory::CreateTerminal(iSIP ? PV_SIP : PV_324M,
+                               (PVCommandStatusObserver *) this,
+                               (PVInformationalEventObserver *) this,
+                               (PVErrorEventObserver *) this));
+
+    }
+    else
+    {
+        OSCL_TRY(error, temp = CPV2WayEngineFactory::CreateTerminal(iSIP ? PV_SIP : PV_324M,
+                               (PVCommandStatusObserver *) this,
+                               (PVInformationalEventObserver *) this,
+                               (PVErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        this->RemoveFromScheduler();
+        return;
+    }
+
+    test_is_true(true);
+
+    if (iUseProxy)
+    {
+        CPV2WayProxyFactory::DeleteTerminal(temp);
+    }
+    else
+    {
+        CPV2WayEngineFactory::DeleteTerminal(temp);
+    }
+
+    this->RemoveFromScheduler();
+    return;
+}
+
+
+void alloc_dealloc_test::Run()
+{
+}
+
+void alloc_dealloc_test::DoCancel()
+{
+}
+
+void alloc_dealloc_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+void alloc_dealloc_test::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    OSCL_UNUSED_ARG(aResponse);
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/engines/2way/test/src/audio_only_pause_close_test.cpp b/engines/2way/test/src/audio_only_pause_close_test.cpp
new file mode 100644
index 0000000..50872c1
--- /dev/null
+++ b/engines/2way/test/src/audio_only_pause_close_test.cpp
@@ -0,0 +1,368 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "audio_only_pause_close_test.h"
+
+
+
+void audio_only_pause_close_test::test()
+{
+    fprintf(fileoutput, "Start audio only pause close test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void audio_only_pause_close_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void audio_only_pause_close_test::DoCancel()
+{
+}
+
+
+void audio_only_pause_close_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+
+                if (check_audio_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void audio_only_pause_close_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started())
+                    {
+                        OSCL_TRY(error, iAudioPauseSourceId = terminal->PauseL(*iAudioSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSourceL(*iAudioSource));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+
+                        OSCL_TRY(error, iAudioPauseSinkId = terminal->PauseL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSinkL(*iAudioSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started())
+                    {
+                        OSCL_TRY(error, iAudioPauseSourceId = terminal->PauseL(*iAudioSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSourceL(*iAudioSource));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+
+                        OSCL_TRY(error, iAudioPauseSinkId = terminal->PauseL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSinkL(*iAudioSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if ((aResponse.GetCmdStatus() != PVMFErrCancelled) &&
+                    (aResponse.GetCmdStatus() != PVMFSuccess))
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool audio_only_pause_close_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/audio_only_pause_test.cpp b/engines/2way/test/src/audio_only_pause_test.cpp
new file mode 100644
index 0000000..1b9fa22
--- /dev/null
+++ b/engines/2way/test/src/audio_only_pause_test.cpp
@@ -0,0 +1,370 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "audio_only_pause_test.h"
+
+
+
+void audio_only_pause_test::test()
+{
+    fprintf(fileoutput, "Start audio only pause test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void audio_only_pause_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void audio_only_pause_test::DoCancel()
+{
+}
+
+
+void audio_only_pause_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void audio_only_pause_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    OSCL_TRY(error, iAudioPauseSourceId = terminal->PauseL(*iAudioSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    OSCL_TRY(error, iAudioPauseSinkId = terminal->PauseL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iAudioPauseSourceId)
+                {
+                    OSCL_TRY(error, iAudioResumeSourceId = terminal->ResumeL(*iAudioSource));
+                }
+                else if (aResponse.GetCmdId() == iAudioPauseSinkId)
+                {
+                    OSCL_TRY(error, iAudioResumeSinkId = terminal->ResumeL(*iAudioSink));
+                }
+                else
+                {
+                    error = -1;
+                }
+
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iAudioResumeSourceId)
+                {
+                    iAudioSourceResumed = true;
+                }
+                else if (aResponse.GetCmdId() == iAudioResumeSinkId)
+                {
+                    iAudioSinkResumed = true;
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                    break;
+                }
+
+                if (check_audio_resumed())
+                {
+                    iCurrentRun++;
+
+                    if (iCurrentRun < iMaxRuns)
+                    {
+                        OSCL_TRY(error, iAudioPauseSourceId = terminal->PauseL(*iAudioSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iAudioPauseSinkId = terminal->PauseL(*iAudioSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                        iAudioSourceResumed = false;
+                        iAudioSinkResumed = false;
+                    }
+                    else
+                    {
+                        test_is_true(true);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool audio_only_pause_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/audio_only_resume_close_test.cpp b/engines/2way/test/src/audio_only_resume_close_test.cpp
new file mode 100644
index 0000000..6a3fb90
--- /dev/null
+++ b/engines/2way/test/src/audio_only_resume_close_test.cpp
@@ -0,0 +1,372 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "audio_only_resume_close_test.h"
+
+
+
+void audio_only_resume_close_test::test()
+{
+    fprintf(fileoutput, "Start audio only resume close test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void audio_only_resume_close_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void audio_only_resume_close_test::DoCancel()
+{
+}
+
+
+void audio_only_resume_close_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+
+                if (check_audio_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void audio_only_resume_close_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    OSCL_TRY(error, iAudioPauseSourceId = terminal->PauseL(*iAudioSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    OSCL_TRY(error, iAudioPauseSinkId = terminal->PauseL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+
+                if (check_audio_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iAudioPauseSourceId)
+                {
+                    iAudioSourcePaused = true;
+                }
+                else if (aResponse.GetCmdId() == iAudioPauseSinkId)
+                {
+                    iAudioSinkPaused = true;
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                    break;
+                }
+
+                if (check_audio_paused())
+                {
+                    OSCL_TRY(error, iAudioResumeSourceId = terminal->ResumeL(*iAudioSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                    else
+                    {
+                        OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSourceL(*iAudioSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+
+                    OSCL_TRY(error, iAudioResumeSinkId = terminal->ResumeL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                    else
+                    {
+                        OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSinkL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME:
+            if ((aResponse.GetCmdStatus() != PVMFErrCancelled) &&
+                    (aResponse.GetCmdStatus() != PVMFSuccess))
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool audio_only_resume_close_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/audio_only_test.cpp b/engines/2way/test/src/audio_only_test.cpp
new file mode 100644
index 0000000..448edf8
--- /dev/null
+++ b/engines/2way/test/src/audio_only_test.cpp
@@ -0,0 +1,224 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "audio_only_test.h"
+
+
+void audio_only_test::test()
+{
+    fprintf(fileoutput, "Start audio only test, proxy %d,SrcFormat:", iUseProxy);
+
+    printFormatString(iAudSrcFormatType);
+
+    fprintf(fileoutput, " SinkFormat:");
+
+    printFormatString(iAudSinkFormatType);
+
+    fprintf(fileoutput, "\n");
+
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    init_mime_strings();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            test_is_true(false);
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+    test_is_true(iTestStatus);
+}
+
+
+void audio_only_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    if (timer)
+    {
+        delete timer;
+        timer = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void audio_only_test::DoCancel()
+{
+}
+
+
+void audio_only_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    int error = 0;
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_OUTGOING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if (aEvent.GetLocalBuffer()[0] == PV_AUDIO && isFirstSink)
+            {
+                isFirstSink = false;
+                iSelAudioSource = get_audio_source(iAudSrcFormatType);
+                if (iSelAudioSource != NULL)
+                {
+                    OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSource(*channel_id, *iSelAudioSource));
+                    printf("Audio");
+                }
+            }
+            else if (aEvent.GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                printf("Video");
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" outgoing Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_INCOMING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if (aEvent.GetLocalBuffer()[0] == PV_AUDIO && isFirstSrc)
+            {
+                isFirstSrc = false;
+                iSelAudioSink = get_audio_sink(iAudSinkFormatType);
+                if (iSelAudioSink != NULL)
+                {
+                    OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSink(*channel_id, *iSelAudioSink));
+                    printf("Audio");
+                }
+            }
+            else if (aEvent.GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                printf("Video");
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" incoming Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void audio_only_test::ConnectSucceeded()
+{
+}
+
+void audio_only_test::ConnectFailed()
+{
+    reset();
+}
+
+
+void audio_only_test::TimerCallback()
+{
+    int error = 1;
+    timer_elapsed = true;
+#if 1
+    if (iSelAudioSource != NULL)
+    {
+        OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSource(*iSelAudioSource));
+    }
+    if (error)
+    {
+        iTestStatus &= false;
+        disconnect();
+    }
+    else
+    {
+        error = 1;
+        if (iSelAudioSink != NULL)
+        {
+            OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSink(*iSelAudioSink));
+        }
+        if (error)
+        {
+            iTestStatus &= false;
+            disconnect();
+        }
+    }
+#else
+    disconnect();
+#endif
+
+}
+
+
+bool audio_only_test::start_async_test()
+{
+    timer = new engine_timer(this);
+    if (timer == NULL)
+    {
+        iTestStatus &= false;
+        return false;
+    }
+
+    iAudioSourceAdded = false;
+    iAudioSinkAdded = false;
+    isFirstSink = true;
+    isFirstSrc = true;
+
+    timer->AddToScheduler();
+
+
+    return test_base::start_async_test();
+}
+
+
diff --git a/engines/2way/test/src/av_disconnect_reset_rec_test.cpp b/engines/2way/test/src/av_disconnect_reset_rec_test.cpp
new file mode 100644
index 0000000..d3fea11
--- /dev/null
+++ b/engines/2way/test/src/av_disconnect_reset_rec_test.cpp
@@ -0,0 +1,530 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "av_disconnect_reset_rec_test.h"
+
+
+
+void av_disconnect_reset_rec_test::test()
+{
+    //Start a/v recording, then disconnect and reset record file.
+    fprintf(fileoutput, "Start a/v disconnect reset rec test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_disconnect_reset_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_disconnect_reset_rec_test::DoCancel()
+{
+}
+
+void av_disconnect_reset_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void av_disconnect_reset_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iIsDisconnected = false;
+
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            iIsDisconnected = true;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (check_rec_stopped())
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            if (check_rec_stopped())
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            iAudioRecStarted = false;
+            iVideoRecStarted = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iIsDisconnected)
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            if (iIsDisconnected)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdId() == iAudioStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioRecStarted = true;
+
+                    if (check_rec_started())
+                    {
+                        TPVPostDisconnectOption option;
+                        OSCL_TRY(error, terminal->DisconnectL(option));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            reset();
+                        }
+
+                        OSCL_TRY(error, terminal->ResetRecordFileL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioStartRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoRecStarted = true;
+
+                    if (check_rec_started())
+                    {
+                        TPVPostDisconnectOption option;
+                        OSCL_TRY(error, terminal->DisconnectL(option));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            reset();
+                            break;
+                        }
+
+                        OSCL_TRY(error, terminal->ResetRecordFileL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoStartRecId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_STOP_RECORD:
+            test_is_true(false);
+            disconnect();
+            break;
+    }
+}
+
+bool av_disconnect_reset_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/av_duplicate_test.cpp b/engines/2way/test/src/av_duplicate_test.cpp
new file mode 100644
index 0000000..484b0da
--- /dev/null
+++ b/engines/2way/test/src/av_duplicate_test.cpp
@@ -0,0 +1,525 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if 0
+#include "av_duplicate_test.h"
+
+
+
+void av_duplicate_test::test()
+{
+    fprintf(fileoutput, "Start a/v duplicate test, num runs %d, proxy %d; try to add extra sources and sinks.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_duplicate_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            //CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    if (timer)
+    {
+        delete timer;
+        timer = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_duplicate_test::DoCancel()
+{
+}
+
+void av_duplicate_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+    /*
+    	switch (aEvent.GetEventType())
+    	{
+    	case PVT_INDICATION_INCOMING_TRACK:
+    		TPVChannelId id;
+
+    		if(((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO){
+    			OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSinkYUV, id));
+    			if (error)
+    			{
+    				test_is_true(false);
+    				timer->Cancel();
+    				disconnect();
+    			}
+    		}
+
+    		if(((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO){
+    			OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+    			if (error)
+    			{
+    				test_is_true(false);
+    				timer->Cancel();
+    				disconnect();
+    			}
+    		}
+    		break;
+
+    	case PVT_INDICATION_DISCONNECT:
+    		iAudioSourceAdded = false;
+    		iVideoSourceAdded = false;
+    		iAudioSinkAdded = false;
+    		iVideoSinkAdded = false;
+    		break;
+
+    	case PVT_INDICATION_CLOSE_TRACK:
+    		if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+    		{
+    			if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+    			{
+    				iVideoSinkAdded = false;
+    			}
+    			else
+    			{
+    				iVideoSourceAdded = false;
+    			}
+    		}
+    		else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+    		{
+    			if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+    			{
+    				iAudioSinkAdded = false;
+    			}
+    			else
+    			{
+    				iAudioSourceAdded = false;
+    			}
+    		}
+    		break;
+
+    	case PVT_INDICATION_INTERNAL_ERROR:
+    		break;
+
+    	default:
+    		break;
+    	}
+    	*/
+}
+
+void av_duplicate_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    TPVChannelId id;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iCommsAddSourceId = terminal->AddDataSource(*iCommServer));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                timer->Cancel();
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iCommsAddSourceId)
+            {
+                OSCL_TRY(error, terminal->Connect(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    reset();
+                }
+            }
+            else if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+                    start_duplicates_if_ready();
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iAudioAddSource2Id)
+            {
+                if (aResponse.GetCmdStatus() == PVMFErrInvalidState)
+                {
+                    test_is_true(true);
+                    // now try and add a duplicate VideoSource
+                    OSCL_TRY(error, iVideoAddSource2Id = terminal->AddDataSource(*iVideoSourceM4V));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        timer->Cancel();
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+                    start_duplicates_if_ready();
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSource2Id)
+            {
+                if (aResponse.GetCmdStatus() == PVMFErrInvalidState)
+                {
+                    test_is_true(true);
+                    // now add a duplicate audio sink
+                    OSCL_TRY(error, iAudioAddSink2Id = terminal->AddDataSink(*iAudioSink2, id));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        timer->Cancel();
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+                    start_duplicates_if_ready();
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+                    start_duplicates_if_ready();
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iAudioAddSink2Id)
+            {
+                if (aResponse.GetCmdStatus() == PVMFErrInvalidState)
+                {
+                    // now try and add a duplicate video sink
+                    OSCL_TRY(error, iVideoAddSink2Id = terminal->AddDataSink(*iVideoSinkM4V, id));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        timer->Cancel();
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSink2Id)
+            {
+                if (aResponse.GetCmdStatus() == PVMFErrInvalidState)
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+                else
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+            }
+
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                //OSCL_TRY(error, iGetSessionParamsId = terminal->GetSessionParamsL(sessionParams));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                timer->Cancel();
+                reset();
+            }
+            break;
+#if 0
+        case PVT_COMMAND_GET_SESSION_PARAMS:
+            // Don't bother checking supported formats here
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSourceYUV));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSinkYUV, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                timer->Cancel();
+                reset();
+            }
+            break;
+#endif
+        case PVT_COMMAND_DISCONNECT:
+            iCurrentRun++;
+            if (check_audio_started() &&
+                    check_video_started() &&
+                    (iCurrentRun >= iMaxRuns))
+            {
+                test_is_true(true);
+            }
+
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+
+            if (iCurrentRun < iMaxRuns)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    timer->Cancel();
+                    reset();
+                }
+            }
+            else
+            {
+                reset();
+            }
+            break;
+    }
+}
+
+void av_duplicate_test::TimerCallback()
+{
+    disconnect();
+}
+
+bool av_duplicate_test::start_async_test()
+{
+    int error = 0;
+
+    timer = new engine_timer(this);
+    if (timer == NULL)
+    {
+        test_is_true(false);
+        return false;
+    }
+    timer->AddToScheduler();
+
+    if (iUseProxy)
+    {
+        //OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+        //(MPVCmnCmdStatusObserver *) this,
+        //(MPVCmnInfoEventObserver *) this,
+        //(MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (PVCommandStatusObserver *) this,
+                                   (PVInformationalEventObserver *) this,
+                                   (PVErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            //CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+void av_duplicate_test::start_duplicates_if_ready()
+{
+    int error = 0;
+    if (iAudioSinkAdded && iVideoSinkAdded &&
+            iAudioSourceAdded && iVideoSourceAdded &&
+            !iDuplicatesStarted)
+    {
+        iDuplicatesStarted = true;
+        OSCL_TRY(error, iAudioAddSource2Id = terminal->AddDataSource(*iAudioSource2));
+        if (error)
+        {
+            test_is_true(false);
+            timer->Cancel();
+            disconnect();
+        }
+    }
+}
+#endif
+
+
diff --git a/engines/2way/test/src/av_pause_disconnect_test.cpp b/engines/2way/test/src/av_pause_disconnect_test.cpp
new file mode 100644
index 0000000..ce106a7
--- /dev/null
+++ b/engines/2way/test/src/av_pause_disconnect_test.cpp
@@ -0,0 +1,377 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "av_pause_disconnect_test.h"
+
+
+
+void av_pause_disconnect_test::test()
+{
+    fprintf(fileoutput, "Start a/v pause disconnect test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_pause_disconnect_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_pause_disconnect_test::DoCancel()
+{
+}
+
+
+void av_pause_disconnect_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            test_is_true(false);
+            disconnect();
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void av_pause_disconnect_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    OSCL_TRY(error, iVideoPauseSourceId = terminal->PauseL(*iVideoSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    OSCL_TRY(error, iAudioPauseSourceId = terminal->PauseL(*iAudioSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    OSCL_TRY(error, iVideoPauseSinkId = terminal->PauseL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    OSCL_TRY(error, iAudioPauseSinkId = terminal->PauseL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourcePaused = false;
+            iVideoSourcePaused = false;
+            iAudioSinkPaused = false;
+            iVideoSinkPaused = false;
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iAudioPauseSourceId)
+                {
+                    iAudioSourcePaused = true;
+                }
+                else if (aResponse.GetCmdId() == iVideoPauseSourceId)
+                {
+                    iVideoSourcePaused = true;
+                }
+                else if (aResponse.GetCmdId() == iAudioPauseSinkId)
+                {
+                    iAudioSinkPaused = true;
+                }
+                else if (aResponse.GetCmdId() == iVideoPauseSinkId)
+                {
+                    iVideoSinkPaused = true;
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                    break;
+                }
+
+                if (check_audio_paused() && check_video_paused())
+                {
+                    TPVPostDisconnectOption option = EDisconnectLine;
+                    OSCL_TRY(error, terminal->DisconnectL(option));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                    else
+                    {
+                        test_is_true(true);
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool av_pause_disconnect_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/av_pause_rec_disconnect_test.cpp b/engines/2way/test/src/av_pause_rec_disconnect_test.cpp
new file mode 100644
index 0000000..8e6df70
--- /dev/null
+++ b/engines/2way/test/src/av_pause_rec_disconnect_test.cpp
@@ -0,0 +1,506 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "av_pause_rec_disconnect_test.h"
+
+
+
+void av_pause_rec_disconnect_test::test()
+{
+    fprintf(fileoutput, "Start a/v pause rec disconnect test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_pause_rec_disconnect_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_pause_rec_disconnect_test::DoCancel()
+{
+}
+
+void av_pause_rec_disconnect_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void av_pause_rec_disconnect_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            test_is_true(true);
+
+            OSCL_TRY(error, terminal->ResetRecordFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdId() == iAudioStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    OSCL_TRY(error, iAudioPauseRecId = terminal->PauseRecordL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioStartRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    OSCL_TRY(error, iVideoPauseRecId = terminal->PauseRecordL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoStartRecId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_PAUSE_RECORD:
+            if (aResponse.GetCmdId() == iAudioPauseRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioRecPaused = true;
+
+                    if (check_rec_paused())
+                    {
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioPauseRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoPauseRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoRecPaused = true;
+
+                    if (check_rec_paused())
+                    {
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoPauseRecId = 0;
+            }
+            break;
+    }
+}
+
+bool av_pause_rec_disconnect_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/av_rec_test.cpp b/engines/2way/test/src/av_rec_test.cpp
new file mode 100644
index 0000000..e563d73
--- /dev/null
+++ b/engines/2way/test/src/av_rec_test.cpp
@@ -0,0 +1,530 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "av_rec_test.h"
+
+
+
+void av_rec_test::test()
+{
+    fprintf(fileoutput, "Start a/v rec test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_rec_test::DoCancel()
+{
+}
+
+void av_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void av_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetRecordFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdId() == iAudioStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioRecStarted = true;
+
+                    if (check_rec_started())
+                    {
+                        OSCL_TRY(error, iAudioStopRecId = terminal->StopRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStopRecId = terminal->StopRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioStartRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoRecStarted = true;
+
+                    if (check_rec_started())
+                    {
+                        OSCL_TRY(error, iAudioStopRecId = terminal->StopRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        OSCL_TRY(error, iVideoStopRecId = terminal->StopRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoStartRecId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_STOP_RECORD:
+            if (aResponse.GetCmdId() == iAudioStopRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioRecStarted = false;
+
+                    if (check_rec_stopped())
+                    {
+                        test_is_true(true);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioStopRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoStopRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoRecStarted = false;
+
+                    if (check_rec_stopped())
+                    {
+                        test_is_true(true);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoStopRecId = 0;
+            }
+            break;
+    }
+}
+
+bool av_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/av_rec_v_preview_test.cpp b/engines/2way/test/src/av_rec_v_preview_test.cpp
new file mode 100644
index 0000000..aee5f55
--- /dev/null
+++ b/engines/2way/test/src/av_rec_v_preview_test.cpp
@@ -0,0 +1,529 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "av_rec_v_preview_test.h"
+
+
+
+void av_rec_v_preview_test::test()
+{
+    fprintf(fileoutput, "Start a/v rec v preview test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_rec_v_preview_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_rec_v_preview_test::DoCancel()
+{
+}
+
+void av_rec_v_preview_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void av_rec_v_preview_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    check_audio_video_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    check_audio_video_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    check_audio_video_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    check_audio_video_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iIsDisconnected = false;
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            iIsDisconnected = true;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (check_rec_stopped())
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            if (check_rec_stopped())
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            iAudioRecStarted = false;
+            iVideoRecStarted = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iIsDisconnected)
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            if (iIsDisconnected)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdId() == iAudioStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioRecStarted = true;
+
+                    if (check_rec_started() && iVideoPreviewStarted)
+                    {
+                        TPVPostDisconnectOption option;
+                        OSCL_TRY(error, terminal->DisconnectL(option));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            reset();
+                            break;
+                        }
+
+                        OSCL_TRY(error, terminal->ResetRecordFileL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioStartRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoRecStarted = true;
+
+                    if (check_rec_started() && iVideoPreviewStarted)
+                    {
+                        TPVPostDisconnectOption option;
+                        OSCL_TRY(error, terminal->DisconnectL(option));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            reset();
+                            break;
+                        }
+
+                        OSCL_TRY(error, terminal->ResetRecordFileL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoStartRecId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_STOP_RECORD:
+            test_is_true(false);
+            disconnect();
+            break;
+
+        case PVT_COMMAND_ADD_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iVideoPreviewStarted = true;
+
+                if (check_rec_started())
+                {
+                    TPVPostDisconnectOption option;
+                    OSCL_TRY(error, terminal->DisconnectL(option));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                        break;
+                    }
+
+                    OSCL_TRY(error, terminal->ResetRecordFileL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+            test_is_true(false);
+            disconnect();
+            break;
+
+    }
+}
+
+bool av_rec_v_preview_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+    return true;
+}
+
+void av_rec_v_preview_test::check_audio_video_started()
+{
+    int error = 0;
+    if (check_audio_started() && check_video_started())
+    {
+        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+        if (error)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+
+        OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+        if (error)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+
+        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+        if (error)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+    }
+}
+
+
+
diff --git a/engines/2way/test/src/av_test.cpp b/engines/2way/test/src/av_test.cpp
new file mode 100644
index 0000000..a50b5de
--- /dev/null
+++ b/engines/2way/test/src/av_test.cpp
@@ -0,0 +1,335 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "av_test.h"
+
+
+void av_test::test()
+{
+    fprintf(fileoutput, "Start avtest, proxy %d,Audio SrcFormat:", iUseProxy);
+
+    printFormatString(iAudSrcFormatType);
+
+    fprintf(fileoutput, " Audio SinkFormat:");
+
+    printFormatString(iAudSinkFormatType);
+
+    fprintf(fileoutput, " Video SourceFormat:");
+
+    printFormatString(iVidSrcFormatType);
+
+    fprintf(fileoutput, " Video SinkFormat:");
+
+    printFormatString(iVidSinkFormatType);
+
+    fprintf(fileoutput, "\n");
+
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    init_mime_strings();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void av_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    if (timer)
+    {
+        delete timer;
+        timer = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void av_test::DoCancel()
+{
+}
+
+void av_test::ConnectSucceeded()
+{
+}
+
+void av_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    int error = 0;
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_OUTGOING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if ((aEvent.GetLocalBuffer()[0] == PV_AUDIO) && !iSelAudioSource)
+            {
+                iSelAudioSource = get_audio_source(iAudSrcFormatType);
+                if (iSelAudioSource != NULL)
+                {
+                    OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSource(*channel_id, *iSelAudioSource));
+                    printf("Audio");
+                }
+            }
+            else if ((aEvent.GetLocalBuffer()[0] == PV_VIDEO) && !iSelVideoSource)
+            {
+                iSelVideoSource = get_video_source(iVidSrcFormatType);
+                if (iSelVideoSource != NULL)
+                {
+                    OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSource(*channel_id, *iSelVideoSource));
+                    printf("Video");
+                }
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" outgoing Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_INCOMING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if ((aEvent.GetLocalBuffer()[0] == PV_AUDIO) && !iSelAudioSink)
+            {
+                iSelAudioSink = get_audio_sink(iAudSinkFormatType);
+                if (iSelAudioSink != NULL)
+                {
+                    OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSink(*channel_id, *iSelAudioSink));
+                    printf("Audio");
+                }
+            }
+            else if ((aEvent.GetLocalBuffer()[0] == PV_VIDEO) && !iSelVideoSink)
+            {
+                iSelVideoSink = get_video_sink(iVidSinkFormatType);
+                if (iSelVideoSink != NULL)
+                {
+                    OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSink(*channel_id, *iSelVideoSink));
+                    printf("Video");
+                }
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" incoming Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void av_test::InitFailed()
+{
+    test_is_true(false);
+    test_base::InitFailed();
+}
+
+void av_test::ConnectFailed()
+{
+}
+
+void av_test::AudioAddSinkCompleted()
+{
+    iAudioSinkAdded = true;
+    if (iAudioSourceAdded && iVideoSourceAdded && iVideoSinkAdded)
+        timer->RunIfNotReady(TEST_DURATION);
+}
+
+void av_test::AudioAddSourceCompleted()
+{
+    iAudioSourceAdded = true;
+    if (iAudioSinkAdded && iVideoSourceAdded && iVideoSinkAdded)
+        timer->RunIfNotReady(TEST_DURATION);
+}
+
+void av_test::VideoAddSinkFailed()
+{
+    VideoAddSinkSucceeded();
+}
+
+void av_test::VideoAddSinkSucceeded()
+{
+    iVideoSinkAdded = true;
+    if (iVideoSourceAdded && iAudioSourceAdded && iAudioSinkAdded)
+        timer->RunIfNotReady(TEST_DURATION);
+}
+void av_test::VideoAddSourceSucceeded()
+{
+    iVideoSourceAdded = true;
+    if (iVideoSinkAdded && iAudioSourceAdded && iAudioSinkAdded)
+        timer->RunIfNotReady(TEST_DURATION);
+}
+void av_test::VideoAddSourceFailed()
+{
+    VideoAddSourceSucceeded();
+}
+
+void av_test::RstCmdCompleted()
+{
+    test_is_true(true);
+    test_base::RstCmdCompleted();
+}
+
+void av_test::CheckForTimeToDisconnect()
+{
+    if (!iAudioSourceAdded &&
+            !iAudioSinkAdded &&
+            !iVideoSourceAdded &&
+            !iVideoSinkAdded)
+    {
+        disconnect();
+    }
+}
+
+void av_test::AudioRemoveSourceCompleted()
+{
+    iAudioSourceAdded = false;
+    CheckForTimeToDisconnect();
+}
+
+void av_test::AudioRemoveSinkCompleted()
+{
+    iAudioSinkAdded = false;
+    CheckForTimeToDisconnect();
+}
+void av_test::VideoRemoveSourceCompleted()
+{
+    iVideoSourceAdded = false;
+    CheckForTimeToDisconnect();
+}
+void av_test::VideoRemoveSinkCompleted()
+{
+    iVideoSinkAdded = false;
+    CheckForTimeToDisconnect();
+}
+
+
+
+void av_test::TimerCallback()
+{
+    int error = 0;
+
+    if (iSelVideoSource != NULL)
+    {
+        OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSource(*iSelVideoSource));
+    }
+    if (error)
+    {
+        iTestStatus &= false;
+        disconnect();
+    }
+    else
+    {
+        error = 1;
+        if (iSelVideoSink != NULL)
+        {
+            OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSink(*iSelVideoSink));
+        }
+        if (error)
+        {
+            iTestStatus &= false;
+            disconnect();
+        }
+    }
+
+    if (iSelAudioSource != NULL)
+    {
+        OSCL_TRY(error, iAudioRemoveSourceId = terminal->RemoveDataSource(*iSelAudioSource));
+    }
+    if (error)
+    {
+        iTestStatus &= false;
+        disconnect();
+    }
+    else
+    {
+        error = 1;
+        if (iSelAudioSink != NULL)
+        {
+            OSCL_TRY(error, iAudioRemoveSinkId = terminal->RemoveDataSink(*iSelAudioSink));
+        }
+        if (error)
+        {
+            iTestStatus &= false;
+            disconnect();
+        }
+    }
+}
+
+bool av_test::start_async_test()
+{
+    timer = new engine_timer(this);
+    if (timer == NULL)
+    {
+        test_is_true(false);
+        return false;
+    }
+    iAudioSourceAdded = false;
+    iAudioSinkAdded = false;
+
+    timer->AddToScheduler();
+
+
+    return test_base::start_async_test();
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/avi_test.cpp b/engines/2way/test/src/avi_test.cpp
new file mode 100644
index 0000000..19418cd
--- /dev/null
+++ b/engines/2way/test/src/avi_test.cpp
@@ -0,0 +1,351 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "avi_test.h"
+
+#define TEST_DURATION 1000
+#define AVI_FILE_SOURCE _STRLIT("C:\\data\\testoutput_IYUV_8k_16_mono.avi")
+
+void avi_test::test()
+{
+    fprintf(fileoutput, "Start avitest, proxy %d,Audio SrcFormat:", iUseProxy);
+
+    printFormatString(iAudSrcFormatType);
+
+    fprintf(fileoutput, " Audio SinkFormat:");
+
+    printFormatString(iAudSinkFormatType);
+
+    fprintf(fileoutput, " Video SourceFormat:");
+
+    printFormatString(iVidSrcFormatType);
+
+    fprintf(fileoutput, " Video SinkFormat:");
+
+    printFormatString(iVidSinkFormatType);
+
+    fprintf(fileoutput, "\n");
+
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    init_mime_strings();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void avi_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    if (timer)
+    {
+        delete timer;
+        timer = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void avi_test::DoCancel()
+{
+}
+
+void avi_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    int error = 0;
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_OUTGOING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if (aEvent.GetLocalBuffer()[0] == PV_AUDIO && !iSelAudioSource)
+            {
+                iSelAudioSource = PvmfMediaInputNodeFactory::Create(iAudioMediaInput);
+                if (iSelAudioSource != NULL)
+                {
+                    OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSource(*channel_id, *iSelAudioSource));
+                    printf("Audio");
+                }
+            }
+            else if (aEvent.GetLocalBuffer()[0] == PV_VIDEO && !iSelVideoSource)
+            {
+                iSelVideoSource = PvmfMediaInputNodeFactory::Create(iVideoMediaInput);
+                if (iSelVideoSource != NULL)
+                {
+                    OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSource(*channel_id, *iSelVideoSource));
+                    printf("Video");
+                }
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" outgoing Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_INCOMING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if (aEvent.GetLocalBuffer()[0] == PV_AUDIO && !iSelAudioSink)
+            {
+                iSelAudioSink = get_audio_sink(iAudSinkFormatType);
+                if (iSelAudioSink != NULL)
+                {
+                    OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSink(*channel_id, *iSelAudioSink));
+                    printf("Audio");
+                }
+            }
+            else if (aEvent.GetLocalBuffer()[0] == PV_VIDEO && !iSelVideoSink)
+            {
+                iSelVideoSink = get_video_sink(iVidSinkFormatType);
+                if (iSelVideoSink != NULL)
+                {
+                    OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSink(*channel_id, *iSelVideoSink));
+                    printf("Video");
+                }
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" incoming Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void avi_test::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    PVCommandId cmdId = aResponse.GetCmdId();
+
+    if (cmdId == iInitCmdId)
+    {
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            connect();
+        }
+        else
+        {
+            test_is_true(false);
+            timer->Cancel();
+            RunIfNotReady();
+        }
+    }
+    else if (iConnectCmdId == cmdId)
+    {
+    }
+    else if (iAudioAddSinkId == cmdId)
+    {
+        iAudioSinkAdded = true;
+        if (iAudioSourceAdded && iVideoSourceAdded && iVideoSinkAdded)
+            timer->RunIfNotReady(TEST_DURATION);
+
+    }
+    else if (iAudioAddSourceId == cmdId)
+    {
+        iAudioSourceAdded = true;
+        if (iAudioSinkAdded && iVideoSourceAdded && iVideoSinkAdded)
+            timer->RunIfNotReady(TEST_DURATION);
+    }
+    else if (iVideoAddSinkId == cmdId)
+    {
+        iVideoSinkAdded = true;
+        if (iVideoSourceAdded && iAudioSourceAdded && iAudioSinkAdded)
+            timer->RunIfNotReady(TEST_DURATION);
+
+    }
+    else if (iVideoAddSourceId == cmdId)
+    {
+        iVideoSourceAdded = true;
+        if (iVideoSinkAdded && iAudioSourceAdded && iAudioSinkAdded)
+            timer->RunIfNotReady(TEST_DURATION);
+    }
+    else if (iDisCmdId == cmdId)
+    {
+        printf("Finished disconnecting \n");
+        //	destroy_sink_source();
+        reset();
+    }
+    else if (iRstCmdId == cmdId)
+    {
+        test_is_true(true);
+        destroy_sink_source();
+        RunIfNotReady();
+    }
+    else
+    {
+        printf("Unhandled cmd here %d\n", cmdId);
+    }
+}
+
+void avi_test::TimerCallback()
+{
+    timer_elapsed = true;
+    disconnect();
+}
+
+bool avi_test::start_async_test()
+{
+    int error = 0;
+
+    timer = new engine_timer(this);
+    if (timer == NULL)
+    {
+        test_is_true(false);
+        return false;
+    }
+    iAudioSourceAdded = false;
+    iAudioSinkAdded = false;
+
+    timer->AddToScheduler();
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminal(PV_324M,
+                                   (PVCommandStatusObserver *) this,
+                                   (PVInformationalEventObserver *) this,
+                                   (PVErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminal(PV_324M,
+                                   (PVCommandStatusObserver *) this,
+                                   (PVInformationalEventObserver *) this,
+                                   (PVErrorEventObserver *) this));
+    }
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+    HandleAvi();
+    OSCL_TRY(error, iInitCmdId = terminal->Init(iSdkInitInfo));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+    return true;
+}
+
+bool avi_test::HandleAvi()
+{
+    int32 error = 0;
+    iFileServer.Connect();
+    {
+
+        OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(AVI_FILE_SOURCE, error, &iFileServer););
+
+        if (!iFileParser)
+        {
+            return false;
+        }
+
+        uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
+
+        for (uint32 ii = 0; ii < numStreams; ii++)
+        {
+            if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "audio"))
+            {
+                iAudioNum = ii;
+                iPVAviFile = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
+                {
+                    iAudioMediaInput = PvmiMIOAviWavFileFactory::Create(0, false, iAudioNum, (OsclAny*)iPVAviFile, FILE_FORMAT_AVI, error);
+                    if (!iAudioMediaInput)
+                    {
+                        return PVMFFailure;
+                    }
+                }
+
+            }
+
+            if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "video"))
+            {
+                iVideoNum = ii;
+                {
+                    iPVAviFile = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
+                    iVideoMediaInput = PvmiMIOAviWavFileFactory::Create(0, false, iVideoNum, (OsclAny*)iPVAviFile, FILE_FORMAT_AVI, error);
+                    if (!iVideoMediaInput)
+                    {
+                        return PVMFFailure;
+                    }
+
+                }
+
+            }
+
+        }
+    }
+    return PVMFSuccess;
+}
+
+
diff --git a/engines/2way/test/src/comp_audio_in_out_test.cpp b/engines/2way/test/src/comp_audio_in_out_test.cpp
new file mode 100644
index 0000000..32554f0
--- /dev/null
+++ b/engines/2way/test/src/comp_audio_in_out_test.cpp
@@ -0,0 +1,17 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
diff --git a/engines/2way/test/src/comp_video_h263_in_out_test.cpp b/engines/2way/test/src/comp_video_h263_in_out_test.cpp
new file mode 100644
index 0000000..32554f0
--- /dev/null
+++ b/engines/2way/test/src/comp_video_h263_in_out_test.cpp
@@ -0,0 +1,17 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
diff --git a/engines/2way/test/src/connect_cancel_test.cpp b/engines/2way/test/src/connect_cancel_test.cpp
new file mode 100644
index 0000000..910b9c1
--- /dev/null
+++ b/engines/2way/test/src/connect_cancel_test.cpp
@@ -0,0 +1,124 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "connect_cancel_test.h"
+
+
+void connect_cancel_test::test()
+{
+    fprintf(fileoutput, "Start connect cancel test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void connect_cancel_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void connect_cancel_test::DoCancel()
+{
+}
+
+
+void connect_cancel_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+void connect_cancel_test::InitSucceeded()
+{
+    int error;
+    test_base::InitSucceeded();
+    OSCL_TRY(error, iCancelCmdId = terminal->CancelAllCommands());
+    if (error)
+    {
+        test_is_true(false);
+        reset();
+    }
+}
+
+void connect_cancel_test::InitFailed()
+{
+}
+
+void connect_cancel_test::ConnectCancelled()
+{
+}
+void connect_cancel_test::DisCmdSucceeded()
+{
+    test_is_true(true);
+    reset();
+}
+
+void connect_cancel_test::DisCmdFailed()
+{
+    test_is_true(true);
+    reset();
+}
+void connect_cancel_test::CancelCmdCompleted()
+{
+    test_is_true(true);
+    reset();
+}
+
+
+
+
diff --git a/engines/2way/test/src/connect_test.cpp b/engines/2way/test/src/connect_test.cpp
new file mode 100644
index 0000000..1624bec
--- /dev/null
+++ b/engines/2way/test/src/connect_test.cpp
@@ -0,0 +1,190 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "connect_test.h"
+#include "tsc_h324m_config_interface.h"
+#include "pvmp4h263encextension.h"
+
+
+void connect_test::test()
+{
+    fprintf(fileoutput, "Start %s test, num runs %d, proxy %d.\n", iRunTimerTest ? "timer configuration and encoder extension IF" : "connect", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void connect_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void connect_test::DoCancel()
+{
+}
+
+
+void connect_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        case PVT_INDICATION_INCOMING_TRACK:
+            printf("Incoming Indication\n");
+            break;
+
+        default:
+            break;
+    }
+}
+
+void connect_test::InitSucceeded()
+{
+    i324mConfigInterface = iH324MConfig;
+    //OSCL_TRY(error, i324mIFCommandId = terminal->QueryInterface(h324mUuid, i324mConfigInterface,NULL));
+    if (i324mConfigInterface == NULL)
+    {
+        test_is_true(false);
+        reset();
+        return;
+
+    }
+    // set some timers via the interface
+    H324MConfigInterface * i324Interface = (H324MConfigInterface *)i324mConfigInterface;
+    if (iRunTimerTest)
+    {
+        i324Interface->SetTimerCounter(EH324Timer, 1, 1, 10, NULL);
+        i324Interface->SetTimerCounter(EH324Counter, 4, 1, 10, NULL);
+    }
+    i324Interface->removeRef();
+    iStackIFSet = true;
+    int error;
+    PVUuid mp4h263EncUuid = PVMp4H263EncExtensionUUID;
+    OSCL_TRY(error, iEncoderIFCommandId = terminal->QueryInterface(mp4h263EncUuid, iMP4H263EncoderInterface, NULL));
+    if (error)
+    {
+        test_is_true(false);
+        reset();
+    }
+}
+
+void connect_test::InitFailed()
+{
+    test_is_true(false);
+    test_base::InitFailed();
+}
+
+void connect_test::EncoderIFSucceeded()
+{
+    PVUuid mp4h263EncUuid = PVMp4H263EncExtensionUUID;
+    PVMp4H263EncExtensionInterface *ptr = (PVMp4H263EncExtensionInterface *) iMP4H263EncoderInterface;
+    // Default frame rate is 5
+    ptr->SetOutputFrameRate(0, 4);
+    iMP4H263EncoderInterface->removeRef();
+    iEncoderIFSet = true;
+    connect();
+}
+
+void connect_test::EncoderIFFailed()
+{
+//	test_is_true(false);
+    reset();
+}
+
+void connect_test::ConnectFailed()
+{
+    test_base::ConnectFailed();
+    disconnect();
+}
+
+void connect_test::ConnectCancelled()
+{
+    ConnectFailed();
+}
+
+void connect_test::DisCmdSucceeded()
+{
+    if (++iCurrentRun < iMaxRuns)
+    {
+        connect();
+    }
+    else
+    {
+        reset();
+    }
+    destroy_sink_source();
+}
+
+void connect_test::DisCmdFailed()
+{
+    test_is_true(false);
+    reset();
+    // yep- this is how the code was.
+    if (++iCurrentRun < iMaxRuns)
+    {
+        connect();
+    }
+    else
+    {
+        reset();
+    }
+    destroy_sink_source();
+}
+
+
+
+
+
+
diff --git a/engines/2way/test/src/init_cancel_test.cpp b/engines/2way/test/src/init_cancel_test.cpp
new file mode 100644
index 0000000..28b10a6
--- /dev/null
+++ b/engines/2way/test/src/init_cancel_test.cpp
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "init_cancel_test.h"
+
+void init_cancel_test::test()
+{
+    fprintf(fileoutput, "Start init cancel test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void init_cancel_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void init_cancel_test::DoCancel()
+{
+}
+
+
+void init_cancel_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+void init_cancel_test::InitSucceeded()
+{
+    test_is_true(true);
+    reset();
+}
+
+void init_cancel_test::InitCancelled()
+{
+    InitSucceeded();
+}
+
+void init_cancel_test::InitFailed()
+{
+    test_is_true(false);
+    RunIfNotReady();
+}
+
+
+void init_cancel_test::QueryInterfaceSucceeded()
+{
+    test_base::QueryInterfaceSucceeded();
+
+    int error = 0;
+    OSCL_TRY(error, iCnclCmdId = terminal->CancelAllCommands());
+    if (error)
+    {
+        test_is_true(false);
+    }
+
+}
+
+
diff --git a/engines/2way/test/src/init_play_reset_test.cpp b/engines/2way/test/src/init_play_reset_test.cpp
new file mode 100644
index 0000000..391ae16
--- /dev/null
+++ b/engines/2way/test/src/init_play_reset_test.cpp
@@ -0,0 +1,185 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "init_play_reset_test.h"
+
+
+
+void init_play_reset_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start init play reset test, proxy %d, file %s\n", iUseProxy, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void init_play_reset_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void init_play_reset_test::DoCancel()
+{
+}
+
+
+void init_play_reset_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+}
+
+void init_play_reset_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResetL());
+                if (error)
+                {
+                    test_is_true(false);
+                    RunIfNotReady();
+                }
+                else
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+    }
+}
+
+bool init_play_reset_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/init_play_test.cpp b/engines/2way/test/src/init_play_test.cpp
new file mode 100644
index 0000000..25fc1a9
--- /dev/null
+++ b/engines/2way/test/src/init_play_test.cpp
@@ -0,0 +1,217 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "init_play_test.h"
+
+
+
+void init_play_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+    fprintf(fileoutput, "Start init play test, num runs %d, proxy %d, file %s\n", iMaxRuns, iUseProxy, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void init_play_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void init_play_test::DoCancel()
+{
+}
+
+
+void init_play_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+}
+
+void init_play_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResetPlayFileL());
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    test_is_true(true);
+
+                    OSCL_TRY(error, terminal->ResetL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        RunIfNotReady();
+                    }
+                    else
+                    {
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+    }
+}
+
+bool init_play_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/init_rec_reset_test.cpp b/engines/2way/test/src/init_rec_reset_test.cpp
new file mode 100644
index 0000000..23e1dec
--- /dev/null
+++ b/engines/2way/test/src/init_rec_reset_test.cpp
@@ -0,0 +1,177 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "init_rec_reset_test.h"
+
+
+
+void init_rec_reset_test::test()
+{
+    fprintf(fileoutput, "Start init rec reset test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void init_rec_reset_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void init_rec_reset_test::DoCancel()
+{
+}
+
+
+void init_rec_reset_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+}
+
+void init_rec_reset_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResetL());
+                if (error)
+                {
+                    test_is_true(false);
+                    RunIfNotReady();
+                }
+                else
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+    }
+}
+
+bool init_rec_reset_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/init_rec_test.cpp b/engines/2way/test/src/init_rec_test.cpp
new file mode 100644
index 0000000..431dcfe
--- /dev/null
+++ b/engines/2way/test/src/init_rec_test.cpp
@@ -0,0 +1,207 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "init_rec_test.h"
+
+
+
+void init_rec_test::test()
+{
+    fprintf(fileoutput, "Start init rec test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void init_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void init_rec_test::DoCancel()
+{
+}
+
+
+void init_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+}
+
+void init_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResetRecordFileL());
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                    if (iCurrentRun >= (iMaxRuns - 1))
+                    {
+                        test_is_true(true);
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                    OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->ResetL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        RunIfNotReady();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+    }
+}
+
+bool init_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/init_test.cpp b/engines/2way/test/src/init_test.cpp
new file mode 100644
index 0000000..c563d87
--- /dev/null
+++ b/engines/2way/test/src/init_test.cpp
@@ -0,0 +1,115 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "init_test.h"
+
+
+
+void init_test::test()
+{
+    fprintf(fileoutput, "Start init test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void init_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void init_test::DoCancel()
+{
+}
+
+
+void init_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+void init_test::InitSucceeded()
+{
+    iRstCmdId = 0;
+    int error;
+    OSCL_TRY(error, iRstCmdId =  terminal->Reset());
+    if (error)
+    {
+        test_is_true(false);
+        RunIfNotReady();
+    }
+    else
+    {
+        if (iCurrentRun >= (iMaxRuns - 1))
+        {
+            test_is_true(true);
+        }
+    }
+}
+
+void init_test::InitFailed()
+{
+    test_is_true(false);
+    RunIfNotReady();
+}
+
+void init_test::RstCmdCompleted()
+{
+    iCurrentRun++;
+    if (iCurrentRun < iMaxRuns)
+    {
+        //iInitCmdId = 0;
+        Init();
+    }
+    else
+    {
+        destroy_sink_source();
+        RunIfNotReady();
+    }
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/invalid_command_test.cpp b/engines/2way/test/src/invalid_command_test.cpp
new file mode 100644
index 0000000..f2db377
--- /dev/null
+++ b/engines/2way/test/src/invalid_command_test.cpp
@@ -0,0 +1,254 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if 0
+#include "invalid_command_test.h"
+
+
+void invalid_command_test::test()
+{
+    fprintf(fileoutput, "Start invalid command test.\n");
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    for (int i = PVT_COMMAND_INIT; i < PVT_LAST_COMMAND; i++)
+    {
+        test_is_true(test_command((TPV2WayCommandType) i));
+    }
+
+    this->RemoveFromScheduler();
+}
+
+void invalid_command_test::Run()
+{
+}
+
+void invalid_command_test::DoCancel()
+{
+}
+
+
+void invalid_command_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+void invalid_command_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    OSCL_UNUSED_ARG(aResponse);
+}
+
+bool invalid_command_test::test_command(TPV2WayCommandType cmd)
+{
+    CPV2WayInterface *temp = NULL;
+    int error = 0;
+    bool status = true;
+
+    OSCL_TRY(error, temp = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                           (MPVCmnCmdStatusObserver *) this,
+                           (MPVCmnInfoEventObserver *) this,
+                           (MPVCmnErrorEventObserver *) this));
+
+    if (error)
+    {
+        return status;
+    }
+
+    create_sink_source();
+
+    switch (cmd)
+    {
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+        {
+            OSCL_TRY(error, temp->AddDataSourceL(*iVideoSourceYUV));
+        }
+        break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            OSCL_TRY(error, temp->RemoveDataSourceL(*iVideoSourceYUV));
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+        {
+            TPVChannelId id;
+            OSCL_TRY(error, temp->AddDataSinkL(*iVideoSinkYUV, id));
+        }
+        break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            OSCL_TRY(error, temp->RemoveDataSinkL(*iVideoSinkYUV));
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            OSCL_TRY(error, temp->ConnectL(iConnectOptions));
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+        {
+            TPVPostDisconnectOption option = EDisconnectLine;
+            OSCL_TRY(error, temp->DisconnectL(option));
+        }
+        break;
+
+        case PVT_COMMAND_SET_TRADEOFF:
+            OSCL_TRY(error, temp->SetLatencyQualityTradeoffL(*iVideoSourceYUV, 1));
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            OSCL_TRY(error, temp->PauseL(*iVideoSourceYUV));
+            break;
+
+        case PVT_COMMAND_RESUME:
+            OSCL_TRY(error, temp->ResumeL(*iVideoSourceYUV));
+            break;
+
+        case PVT_COMMAND_SEND_USER_INPUT:
+        {
+#ifndef NO_2WAY_324
+            CPVUserInputAlphanumeric uii(NULL, 0);
+            OSCL_TRY(error, temp->SendUserInputL(uii));
+#else
+            error = PVMFErrNotSupported;
+#endif
+        }
+        break;
+
+        case PVT_COMMAND_GET_CALL_STATISTICS:
+            CPVCmn2WayStatistics stats;
+            OSCL_TRY(error, temp->GetCallStatistics(stats));
+            break;
+
+        case PVT_COMMAND_QUERY_UUID:
+        {
+            TPVCmnMIMEType type = NULL;
+            Oscl_Vector<PVUuid, BasicAlloc> uuid;
+            OSCL_TRY(error, temp->QueryUUID(type, uuid));
+        }
+        break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            OSCL_TRY(error, temp->CancelAllCommands());
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+        {
+            OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+            OSCL_TRY(error, temp->InitRecordFileL(filename));
+        }
+        break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            OSCL_TRY(error, temp->ResetRecordFileL());
+            break;
+
+        case PVT_COMMAND_START_RECORD:
+            OSCL_TRY(error, temp->StartRecordL(*iVideoSinkYUV));
+            break;
+
+        case PVT_COMMAND_STOP_RECORD:
+            OSCL_TRY(error, temp->StartRecordL(*iVideoSinkYUV));
+            break;
+
+        case PVT_COMMAND_PAUSE_RECORD:
+            OSCL_TRY(error, temp->StartRecordL(*iVideoSinkYUV));
+            break;
+
+        case PVT_COMMAND_RESUME_RECORD:
+            OSCL_TRY(error, temp->StartRecordL(*iVideoSinkYUV));
+            break;
+
+        case PVT_COMMAND_ADD_PREVIEW_SINK:
+            OSCL_TRY(error, temp->AddPreviewSinkL(*iVideoSourceYUV, *iVideoPreview));
+            break;
+
+        case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+            OSCL_TRY(error, temp->RemovePreviewSinkL(*iVideoPreview));
+            break;
+
+        case PVT_COMMAND_PAUSE_PREVIEW_SINK:
+            OSCL_TRY(error, temp->PausePreviewSinkL(*iVideoPreview));
+            break;
+
+        case PVT_COMMAND_RESUME_PREVIEW_SINK:
+            OSCL_TRY(error, temp->ResumePreviewSinkL(*iVideoPreview));
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+        {
+            OSCL_wHeapString<OsclMemAllocator> filename(AUDIO_H263_PLAY_FILENAME);
+            OSCL_TRY(error, temp->InitPlayFileL(filename));
+        }
+        break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            OSCL_TRY(error, temp->ResetPlayFileL());
+            break;
+
+        case PVT_COMMAND_USE_PLAY_FILE:
+            OSCL_TRY(error, temp->UsePlayFileAsSourceL(true));
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            OSCL_TRY(error, temp->StartPlayL());
+            break;
+
+        case PVT_COMMAND_STOP_PLAY:
+            OSCL_TRY(error, temp->StopPlayL());
+            break;
+
+        case PVT_COMMAND_PAUSE_PLAY:
+            OSCL_TRY(error, temp->PausePlayL());
+            break;
+
+        case PVT_COMMAND_RESUME_PLAY:
+            OSCL_TRY(error, temp->ResumePlayL());
+            break;
+
+        case PVT_COMMAND_INIT:
+        case PVT_COMMAND_GET_SDK_INFO:
+        case PVT_COMMAND_GET_SDK_MODULE_INFO:
+        case PVT_COMMAND_GET_PV2WAY_STATE:
+        case PVT_COMMAND_RESET:
+        case PVT_COMMAND_QUERY_INTERFACE:
+        case PVT_COMMAND_SET_LOG_APPENDER:
+        case PVT_COMMAND_REMOVE_LOG_APPENDER:
+        case PVT_COMMAND_SET_LOG_LEVEL:
+        case PVT_COMMAND_GET_LOG_LEVEL:
+        default:
+            error = -1;
+            break;
+    }
+
+    destroy_sink_source();
+
+    if (!error)
+    {
+        status = false;
+    }
+
+    CPV2WayEngineFactory::DeleteTerminal(temp);
+    return status;
+}
+#endif
+
+
+
+
+
+
diff --git a/engines/2way/test/src/pff_eos_test.cpp b/engines/2way/test/src/pff_eos_test.cpp
new file mode 100644
index 0000000..9e4acca
--- /dev/null
+++ b/engines/2way/test/src/pff_eos_test.cpp
@@ -0,0 +1,486 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pff_eos_test.h"
+
+void pff_eos_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start pff eos test, num runs %d, audio eos %d, vidoe eos %d, proxy %d, file %s\n", iMaxRuns, iWaitForAudioEOS, iWaitForVideoEOS, iUseProxy, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void pff_eos_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void pff_eos_test::DoCancel()
+{
+}
+
+void pff_eos_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_PLAY_EOS:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                iVideoEOSRecv = true;
+                if (iWaitForVideoEOS) check_eos();
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                iAudioEOSRecv = true;
+                if (iWaitForAudioEOS) check_eos();
+            }
+
+            break;
+
+        default:
+            break;
+    }
+}
+
+void pff_eos_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetPlayFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                //Wait for EOS
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_STOP_PLAY:
+            iStopPlayLCalled = false;
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iAudioEOSRecv = false;
+                iVideoEOSRecv = false;
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->StartPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool pff_eos_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+void pff_eos_test::check_eos()
+{
+    int error = 0;
+
+    if (iStopPlayLCalled) return;
+
+    if (iWaitForAudioEOS)
+    {
+        if (!iAudioEOSRecv) return;
+    }
+
+    if (iWaitForVideoEOS)
+    {
+        if (!iVideoEOSRecv) return;
+    }
+
+    OSCL_TRY(error, terminal->StopPlayL());
+    if (error)
+    {
+        test_is_true(false);
+        disconnect();
+    }
+    else
+    {
+        iStopPlayLCalled = true;
+    }
+
+    return;
+}
+
+
+
+
diff --git a/engines/2way/test/src/pff_pause_disconnect_test.cpp b/engines/2way/test/src/pff_pause_disconnect_test.cpp
new file mode 100644
index 0000000..393f082
--- /dev/null
+++ b/engines/2way/test/src/pff_pause_disconnect_test.cpp
@@ -0,0 +1,459 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pff_pause_disconnect_test.h"
+
+void pff_pause_disconnect_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start play from file pause disconnect test, before add source %d, file %s\n", iUsePlayFileBeforeAddSource, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void pff_pause_disconnect_test::Run()
+{
+    if (terminal)
+    {
+        delete terminal;
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void pff_pause_disconnect_test::DoCancel()
+{
+}
+
+void pff_pause_disconnect_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void pff_pause_disconnect_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+            }
+
+            OSCL_TRY(error, terminal->ResetPlayFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_USE_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->StartPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    reset();
+                }
+                else
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->PausePlayL());
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_PAUSE_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                TPVPostDisconnectOption option;
+                OSCL_TRY(error, terminal->DisconnectL(option));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool pff_pause_disconnect_test::start_async_test()
+{
+    int error = 0;
+
+    OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                               (MPVCmnCmdStatusObserver *) this,
+                               (MPVCmnInfoEventObserver *) this,
+                               (MPVCmnErrorEventObserver *) this));
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        CPV2WayEngineFactory::DeleteTerminal(terminal);
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+void pff_pause_disconnect_test::is_av_started()
+{
+    int error = 0;
+    if (check_audio_started() && check_video_started())
+    {
+        if (iUsePlayFileBeforeAddSource)
+        {
+            OSCL_TRY(error, terminal->StartPlayL());
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+        else
+        {
+            OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+    }
+
+    return;
+}
+
+
+
+
diff --git a/engines/2way/test/src/play_from_file_disconnect_test.cpp b/engines/2way/test/src/play_from_file_disconnect_test.cpp
new file mode 100644
index 0000000..83ae343
--- /dev/null
+++ b/engines/2way/test/src/play_from_file_disconnect_test.cpp
@@ -0,0 +1,468 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "play_from_file_disconnect_test.h"
+
+void play_from_file_disconnect_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start play from file disconnect test, proxy %d, before add source %d, file %s\n", iUseProxy, iUsePlayFileBeforeAddSource, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void play_from_file_disconnect_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void play_from_file_disconnect_test::DoCancel()
+{
+}
+
+void play_from_file_disconnect_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void play_from_file_disconnect_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+            }
+
+            OSCL_TRY(error, terminal->ResetPlayFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_USE_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->StartPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    reset();
+                }
+                else
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                TPVPostDisconnectOption option;
+                OSCL_TRY(error, terminal->DisconnectL(option));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool play_from_file_disconnect_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+void play_from_file_disconnect_test::is_av_started()
+{
+    int error = 0;
+    if (check_audio_started() && check_video_started())
+    {
+        if (iUsePlayFileBeforeAddSource)
+        {
+            OSCL_TRY(error, terminal->StartPlayL());
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+        else
+        {
+            OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+    }
+
+    return;
+}
+
+
+
+
diff --git a/engines/2way/test/src/play_from_file_pause_test.cpp b/engines/2way/test/src/play_from_file_pause_test.cpp
new file mode 100644
index 0000000..aba15fa
--- /dev/null
+++ b/engines/2way/test/src/play_from_file_pause_test.cpp
@@ -0,0 +1,529 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "play_from_file_pause_test.h"
+
+void play_from_file_pause_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start pff pause test, num runs %d, proxy %d, before add source %d, file %s\n", iMaxRuns, iUseProxy, iUsePlayFileBeforeAddSource, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void play_from_file_pause_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void play_from_file_pause_test::DoCancel()
+{
+}
+
+void play_from_file_pause_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void play_from_file_pause_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+                    is_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetPlayFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_USE_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->StartPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    reset();
+                }
+                else
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->PausePlayL());
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_STOP_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                TPVPostDisconnectOption option;
+                OSCL_TRY(error, terminal->DisconnectL(option));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_PAUSE_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResumePlayL());
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->PausePlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(true);
+
+                    OSCL_TRY(error, terminal->StopPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool play_from_file_pause_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+void play_from_file_pause_test::is_av_started()
+{
+    int error = 0;
+    if (check_audio_started() && check_video_started())
+    {
+        if (iUsePlayFileBeforeAddSource)
+        {
+            OSCL_TRY(error, terminal->StartPlayL());
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+        else
+        {
+            OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+    }
+
+    return;
+}
+
+
+
+
diff --git a/engines/2way/test/src/play_from_file_test.cpp b/engines/2way/test/src/play_from_file_test.cpp
new file mode 100644
index 0000000..b2c94a7
--- /dev/null
+++ b/engines/2way/test/src/play_from_file_test.cpp
@@ -0,0 +1,448 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "play_from_file_test.h"
+
+void play_from_file_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start pff test, num runs %d, proxy %d, file %s\n", iMaxRuns, iUseProxy, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void play_from_file_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void play_from_file_test::DoCancel()
+{
+}
+
+void play_from_file_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void play_from_file_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_audio_started() && check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetPlayFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->StopPlayL());
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_STOP_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->StartPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool play_from_file_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/test_base.cpp b/engines/2way/test/src/test_base.cpp
new file mode 100644
index 0000000..5a59ea5
--- /dev/null
+++ b/engines/2way/test/src/test_base.cpp
@@ -0,0 +1,439 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_BASE_H_INCLUDED
+#include "test_base.h"
+#endif
+
+#ifndef PV_LOGGER_IMPL_H_INCLUDED
+#include "pv_logger_impl.h"
+#endif
+
+
+#if defined(__linux__) || defined(linux)
+#define CONFIG_FILE_PATH _STRLIT("../../../pvlogger/config/")
+#endif
+
+#define LOG_FILE_NAME _STRLIT("pvlog.txt")
+
+void test_base::H324MConfigCommandCompletedL(PVMFCmdResp& aResponse)
+{
+    OSCL_UNUSED_ARG(aResponse);
+}
+
+void test_base::H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification)
+{
+    OSCL_UNUSED_ARG(aNotification);
+}
+
+void test_base::CreateH324Component(bool aCreateH324)
+{
+    OSCL_UNUSED_ARG(aCreateH324);
+
+
+    // get TSC node
+    iQueryInterfaceCmdId = terminal->QueryInterface(PVH324MConfigUuid, iTempH324MConfigIterface);
+
+}
+
+void test_base::QueryInterfaceSucceeded()
+{
+    if (iH324MConfig)
+    {
+        iH324MConfig->SetObserver(this);
+
+        {
+            PVInterface *componentInterface;
+
+            iH324MConfig->queryInterface(PVUuidH324ComponentInterface, (PVInterface*&)componentInterface);
+        }
+    }
+    // now we have created the component, we can do init.
+    Init();
+}
+
+bool test_base::Init()
+{
+    int32 error = 0;
+    OSCL_FastString aStr;
+
+    // Clear formats from prev call if any
+    iSdkInitInfo.iIncomingAudioFormats.clear();
+    iSdkInitInfo.iOutgoingAudioFormats.clear();
+    iSdkInitInfo.iIncomingVideoFormats.clear();
+    iSdkInitInfo.iOutgoingVideoFormats.clear();
+
+
+    iSdkInitInfo.iIncomingAudioFormats.push_back(iAudSinkFormatType.getMIMEStrPtr());
+
+    iSdkInitInfo.iOutgoingAudioFormats.push_back(iAudSrcFormatType.getMIMEStrPtr());
+
+    iSdkInitInfo.iIncomingVideoFormats.push_back(iVidSinkFormatType.getMIMEStrPtr());
+
+    iSdkInitInfo.iOutgoingVideoFormats.push_back(iVidSrcFormatType.getMIMEStrPtr());
+
+
+    OSCL_TRY(error, iInitCmdId = terminal->Init(iSdkInitInfo));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+    return true;
+}
+
+
+void test_base::InitSucceeded()
+{
+    connect();
+}
+
+void test_base::InitFailed()
+{
+    timer->Cancel();
+    RunIfNotReady();
+}
+void test_base::InitCancelled()
+{
+    InitFailed();
+}
+void test_base::EncoderIFSucceeded()
+{
+}
+
+void test_base::EncoderIFFailed()
+{
+}
+
+void test_base::ConnectSucceeded()
+{
+    disconnect();
+}
+
+void test_base::ConnectFailed()
+{
+    test_is_true(false);
+    reset();
+}
+
+void test_base::ConnectCancelled()
+{
+    ConnectFailed();
+}
+
+void test_base::CancelCmdCompleted()
+{
+    test_is_true(true);
+    RunIfNotReady();
+}
+
+void test_base::RstCmdCompleted()
+{
+    destroy_sink_source();
+    RunIfNotReady();
+}
+
+void test_base::DisCmdSucceeded()
+{
+    reset();
+}
+
+void test_base::DisCmdFailed()
+{
+    reset();
+}
+
+void test_base::AudioAddSinkCompleted()
+{
+    iAudioSinkAdded = true;
+    if (iAudioSourceAdded)
+        timer->RunIfNotReady(TEST_DURATION);
+}
+
+void test_base::AudioAddSourceCompleted()
+{
+    iAudioSourceAdded = true;
+    if (iAudioSinkAdded)
+        timer->RunIfNotReady(TEST_DURATION);
+}
+
+void test_base::AudioRemoveSourceCompleted()
+{
+    iAudioSourceAdded = false;
+    if (!iAudioSinkAdded)
+        disconnect();
+}
+
+void test_base::AudioRemoveSinkCompleted()
+{
+    iAudioSinkAdded = false;
+    if (!iAudioSourceAdded)
+        disconnect();
+}
+
+void test_base::VideoAddSinkSucceeded()
+{
+}
+void test_base::VideoAddSinkFailed()
+{
+    test_is_true(false);
+    disconnect();
+}
+void test_base::VideoAddSourceSucceeded()
+{
+}
+void test_base::VideoAddSourceFailed()
+{
+}
+void test_base::VideoRemoveSourceCompleted()
+{
+    int error = 0;
+    iVideoSourceAdded = false;
+    if (iSelVideoSink != NULL)
+    {
+        OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSink(*iSelVideoSink));
+    }
+    if (error)
+    {
+        test_is_true(false);
+        disconnect();
+    }
+}
+void test_base::VideoRemoveSinkCompleted()
+{
+    iVideoSinkAdded = false;
+    if (!iVideoSourceAdded)
+        disconnect();
+}
+
+
+void test_base::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    PVCommandId cmdId = aResponse.GetCmdId();
+    iTestStatus &= (aResponse.GetCmdStatus() == PVMFSuccess) ? true : false;
+
+    if (iQueryInterfaceCmdId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            if (iTempH324MConfigIterface)
+            {
+                iH324MConfig = OSCL_STATIC_CAST(H324MConfigInterface*, iTempH324MConfigIterface);
+                iTempH324MConfigIterface = NULL;
+                QueryInterfaceSucceeded();
+            }
+
+        }
+    }
+    else if (iInitCmdId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            InitSucceeded();
+        }
+        else if (aResponse.GetCmdStatus() == PVMFErrCancelled)
+        {
+            InitCancelled();
+        }
+        else
+        {
+            InitFailed();
+        }
+    }
+    else if (iEncoderIFCommandId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() != PVMFSuccess)
+        {
+            EncoderIFFailed();
+        }
+        else
+        {
+            EncoderIFSucceeded();
+        }
+    }
+    else if (iConnectCmdId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            ConnectSucceeded();
+        }
+        else if (aResponse.GetCmdStatus() == PVMFErrCancelled)
+        {
+            ConnectCancelled();
+        }
+        else
+        {
+            ConnectFailed();
+        }
+    }
+    else if (iDisCmdId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() != PVMFSuccess)
+        {
+            DisCmdFailed();
+        }
+        else
+        {
+            DisCmdSucceeded();
+        }
+    }
+    else if (iRstCmdId == cmdId)
+    {
+        RstCmdCompleted();
+    }
+    else if (iAudioAddSinkId == cmdId)
+    {
+        AudioAddSinkCompleted();
+    }
+    else if (iAudioAddSourceId == cmdId)
+    {
+        AudioAddSourceCompleted();
+    }
+    else if (iAudioRemoveSourceId == cmdId)
+    {
+        AudioRemoveSourceCompleted();
+    }
+    else if (iAudioRemoveSinkId == cmdId)
+    {
+        AudioRemoveSinkCompleted();
+    }
+    else if (iVideoAddSinkId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            VideoAddSinkSucceeded();
+        }
+        else
+        {
+            VideoAddSinkFailed();
+        }
+    }
+    else if (iVideoAddSourceId == cmdId)
+    {
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            VideoAddSourceSucceeded();
+        }
+        else
+        {
+            VideoAddSourceFailed();
+        }
+    }
+    else if (iVideoRemoveSourceId == cmdId)
+    {
+        VideoRemoveSourceCompleted();
+    }
+    else if (iVideoRemoveSinkId == cmdId)
+    {
+        VideoRemoveSinkCompleted();
+    }
+    else if (iCancelCmdId == cmdId)
+    {
+        CancelCmdCompleted();
+    }
+}
+
+
+void test_base::InitializeLogs()
+{
+    uint32 error = 0;
+    PVLoggerConfigFile obj;
+    obj.SetConfigFilePath(CONFIG_FILE_PATH);
+    error = 0;
+    if (obj.IsLoggerConfigFilePresent())
+    {
+        error = obj.SetLoggerSettings(terminal, LOG_FILE_NAME);
+        if (0 != error)
+        {
+            printf("Error Occured in PVLoggerConfigFile::SetLoggerSettings() \n");
+        }
+        else
+        {
+            //sucess able to set logger settings
+            return;
+        }
+    }
+
+    PVLoggerAppender *lLoggerAppender = 0;
+    OsclRefCounter *refCounter = NULL;
+    bool logfile = true;
+    if (logfile)
+    {
+//File Log
+        const uint32 TEXT_FILE_APPENDER_CACHE_SIZE = 1024;
+        lLoggerAppender = TextFileAppender<TimeAndIdLayout, 1024>::CreateAppender(LOG_FILE_NAME,
+                          TEXT_FILE_APPENDER_CACHE_SIZE);
+        OsclRefCounter *appenderRefCounter = new OsclRefCounterSA<AppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > >(lLoggerAppender);
+        refCounter = appenderRefCounter;
+    }
+    else
+    {
+//Console Log
+        lLoggerAppender = new StdErrAppender<TimeAndIdLayout, 1024>();
+        OsclRefCounter *appenderRefCounter = new OsclRefCounterSA<AppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > >(lLoggerAppender);
+        refCounter = appenderRefCounter;
+    }
+    OsclSharedPtr<PVLoggerAppender> appenderPtr(lLoggerAppender, refCounter);
+    terminal->SetLogLevel("", PVLOGMSG_DEBUG, true);
+    terminal->SetLogAppender("", appenderPtr);
+
+}
+
+bool test_base::start_async_test()
+{
+    int error = 0;
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminal(PV_324M,
+                                   (PVCommandStatusObserver *) this,
+                                   (PVInformationalEventObserver *) this,
+                                   (PVErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminal(iSIP ? PV_SIP : PV_324M,
+                                   (PVCommandStatusObserver *) this,
+                                   (PVInformationalEventObserver *) this,
+                                   (PVErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    InitializeLogs();
+
+    create_sink_source();
+    iInitCmdId = -1;
+    iQueryInterfaceCmdId = -1;
+    CreateH324Component();
+    return true;
+}
+
diff --git a/engines/2way/test/src/test_engine.cpp b/engines/2way/test/src/test_engine.cpp
new file mode 100644
index 0000000..a78aa5d
--- /dev/null
+++ b/engines/2way/test/src/test_engine.cpp
@@ -0,0 +1,952 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "test_engine.h"
+
+#include "alloc_dealloc_test.h"
+#include "init_test.h"
+#include "init_cancel_test.h"
+#ifndef NO_2WAY_324
+#include "video_only_test.h"
+#include "av_test.h"
+#include "user_input_test.h"
+#include "connect_test.h"
+#include "connect_cancel_test.h"
+#include "audio_only_test.h"
+#include "av_duplicate_test.h"
+#include "pvmf_fileoutput_factory.h"
+#endif
+
+#include "oscl_string_utils.h"
+#include "oscl_mem_audit.h"
+
+
+#include "tsc_h324m_config_interface.h"
+
+#define AUDIO_FIRST 0
+#define VIDEO_FIRST 1
+
+#define MAX_SIP_TEST 27
+#define MAX_324_TEST 25
+#define SIP_TEST_OFFSET 200
+#define SIP_TEST_MAP(x) (x+SIP_TEST_OFFSET)
+#define NUM_SIP_ARGS 10
+
+
+int start_test();
+
+FILE* fileoutput;
+cmd_line *global_cmd_line;
+
+//Find test range args:
+//To run a range of tests by enum ID:
+//  -test 17 29
+
+char engine_test::iProfileName[32] = "";
+uint32 engine_test::iMediaPorts[2] = { 0, 0 };
+char engine_test::iPeerAddress[64] = "";
+
+
+void FindTestRange(cmd_line* command_line,
+                   int32& iFirstTest,
+                   int32 &iLastTest,
+                   FILE* aFile)
+{
+    //default is to run all tests.
+    iFirstTest = 0;
+    iLastTest = MAX_324_TEST;
+
+    int iTestArgument = 0;
+    char *iTestArgStr1 = NULL;
+    char *iTestArgStr2 = NULL;
+    bool cmdline_iswchar = command_line->is_wchar();
+
+    int count = command_line->get_count();
+
+    // Search for the "-test" argument
+    char *iSourceFind = NULL;
+    if (cmdline_iswchar)
+    {
+        iSourceFind = new char[256];
+    }
+
+    int iTestSearch = 0;
+    while (iTestSearch < count)
+    {
+        bool iTestFound = false;
+        // Go through each argument
+        for (; iTestSearch < count; iTestSearch++)
+        {
+            // Convert to UTF8 if necessary
+            if (cmdline_iswchar)
+            {
+                OSCL_TCHAR* cmd = NULL;
+                command_line->get_arg(iTestSearch, cmd);
+                oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iSourceFind, 256);
+            }
+            else
+            {
+                iSourceFind = NULL;
+                command_line->get_arg(iTestSearch, iSourceFind);
+            }
+
+            // Do the string compare
+            if (oscl_strcmp(iSourceFind, "-help") == 0)
+            {
+                fprintf(aFile, "Test cases to run option. Default is ALL:\n");
+                fprintf(aFile, "  -test x y\n");
+                fprintf(aFile, "   Specify a range of test cases to run. To run one test case, use the\n");
+                fprintf(aFile, "   same index for x and y.\n");
+
+                fprintf(aFile, "  -test G\n");
+                fprintf(aFile, "   Run 324M test cases only.\n");
+
+                exit(0);
+            }
+            else if (oscl_strcmp(iSourceFind, "-test") == 0)
+            {
+                iTestFound = true;
+                iTestArgument = ++iTestSearch;
+                break;
+            }
+        }
+
+        if (cmdline_iswchar)
+        {
+            delete[] iSourceFind;
+            iSourceFind = NULL;
+        }
+
+        if (iTestFound)
+        {
+            // Convert to UTF8 if necessary
+            if (cmdline_iswchar)
+            {
+                iTestArgStr1 = new char[256];
+                OSCL_TCHAR* cmd;
+                command_line->get_arg(iTestArgument, cmd);
+                if (cmd)
+                {
+                    oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr1, 256);
+                }
+
+                iTestArgStr2 = new char[256];
+                command_line->get_arg(iTestArgument + 1, cmd);
+                if (cmd)
+                {
+                    oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr2, 256);
+                }
+            }
+            else
+            {
+                command_line->get_arg(iTestArgument, iTestArgStr1);
+                command_line->get_arg(iTestArgument + 1, iTestArgStr2);
+            }
+
+            //Pull out 2 integers...
+            if (iTestArgStr1
+                    && '0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9'
+                    && iTestArgStr2
+                    && '0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
+            {
+                int len = oscl_strlen(iTestArgStr1);
+                switch (len)
+                {
+                    case 3:
+                        iFirstTest = 0;
+                        if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
+                        {
+                            iFirstTest = iFirstTest + 100 * (iTestArgStr1[0] - '0');
+                        }
+
+                        if ('0' <= iTestArgStr1[1] && iTestArgStr1[1] <= '9')
+                        {
+                            iFirstTest = iFirstTest + 10 * (iTestArgStr1[1] - '0');
+                        }
+
+                        if ('0' <= iTestArgStr1[2] && iTestArgStr1[2] <= '9')
+                        {
+                            iFirstTest = iFirstTest + 1 * (iTestArgStr1[2] - '0');
+                        }
+                        break;
+
+                    case 2:
+                        iFirstTest = 0;
+                        if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
+                        {
+                            iFirstTest = iFirstTest + 10 * (iTestArgStr1[0] - '0');
+                        }
+
+                        if ('0' <= iTestArgStr1[1] && iTestArgStr1[1] <= '9')
+                        {
+                            iFirstTest = iFirstTest + 1 * (iTestArgStr1[1] - '0');
+                        }
+                        break;
+
+                    case 1:
+                        iFirstTest = 0;
+                        if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
+                        {
+                            iFirstTest = iFirstTest + 1 * (iTestArgStr1[0] - '0');
+                        }
+                        break;
+
+                    default:
+                        break;
+                }
+
+                len = oscl_strlen(iTestArgStr2);
+                switch (len)
+                {
+                    case 3:
+                        iLastTest = 0;
+                        if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
+                        {
+                            iLastTest = iLastTest + 100 * (iTestArgStr2[0] - '0');
+                        }
+
+                        if ('0' <= iTestArgStr2[1] && iTestArgStr2[1] <= '9')
+                        {
+                            iLastTest = iLastTest + 10 * (iTestArgStr2[1] - '0');
+                        }
+
+                        if ('0' <= iTestArgStr2[2] && iTestArgStr2[2] <= '9')
+                        {
+                            iLastTest = iLastTest + 1 * (iTestArgStr2[2] - '0');
+                        }
+                        break;
+
+                    case 2:
+                        iLastTest = 0;
+                        if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
+                        {
+                            iLastTest = iLastTest + 10 * (iTestArgStr2[0] - '0');
+                        }
+
+                        if ('0' <= iTestArgStr2[1] && iTestArgStr2[1] <= '9')
+                        {
+                            iLastTest = iLastTest + 1 * (iTestArgStr2[1] - '0');
+                        }
+                        break;
+
+                    case 1:
+                        iLastTest = 0;
+                        if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
+                        {
+                            iLastTest = iLastTest + 1 * (iTestArgStr2[0] - '0');
+                        }
+                        break;
+
+                    default:
+                        break;
+                }
+            }
+
+#ifndef NO_2WAY_324
+            else if (iTestArgStr1
+                     && iTestArgStr1[0] == 'G')
+            {
+                //download tests
+                iFirstTest = 0;
+                iLastTest = MAX_324_TEST;
+            }
+#endif
+        }
+
+        if (cmdline_iswchar)
+        {
+            if (iTestArgStr1)
+            {
+                delete[] iTestArgStr1;
+                iTestArgStr1 = NULL;
+            }
+
+            if (iTestArgStr2)
+            {
+                delete[] iTestArgStr2;
+                iTestArgStr2 = NULL;
+            }
+
+            if (iSourceFind)
+            {
+                delete[] iSourceFind;
+                iSourceFind = NULL;
+            }
+        }
+        iTestSearch += 2;
+    }
+}
+
+
+engine_test_suite::engine_test_suite() : test_case()
+{
+    // setting iProxy
+    //proxy_tests(false);
+
+    proxy_tests(true);
+}
+
+
+void engine_test_suite::proxy_tests(const bool aProxy)
+{
+    //Basic 2way tests
+    fprintf(fileoutput, "Basic engine tests.\n");
+
+    int32 firstTest = 0;
+    int32 lastTest = MAX_324_TEST;
+    FindTestRange(global_cmd_line, firstTest, lastTest, fileoutput);
+    //adopt_test_case( new av_test(aProxy,PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_YUV420,PVMF_YUV420));
+#ifndef NO_2WAY_324
+    if (firstTest == 0)
+        adopt_test_case(new alloc_dealloc_test(aProxy));
+    if (firstTest <= 2 && lastTest >= 2)
+        adopt_test_case(new init_test(aProxy, 1));
+    //if (firstTest <= 3 && lastTest >= 3 )
+    //	adopt_test_case( new init_test(aProxy, 2) );
+
+    if (firstTest <= 4 && lastTest >= 4)
+        adopt_test_case(new init_cancel_test(aProxy));
+
+    if (firstTest <= 5 && lastTest >= 5)
+        adopt_test_case(new connect_test(aProxy, 1));
+
+    if (firstTest <= 6 && lastTest >= 6)
+        adopt_test_case(new connect_cancel_test(aProxy));
+
+    if (firstTest <= 7 && lastTest >= 7)
+    {
+        //adopt_test_case( new audio_only_test(aProxy,PVMF_AMR_IF2,PVMF_AMR_IF2));
+    }
+    if (firstTest <= 8 && lastTest >= 8)
+    {
+        //adopt_test_case( new audio_only_test(aProxy, PVMF_PCM16,PVMF_AMR_IF2) );
+    }
+    if (firstTest <= 9 && lastTest >= 9)
+    {
+        //adopt_test_case( new audio_only_test(aProxy, PVMF_AMR_IF2,PVMF_PCM16) );
+    }
+
+    if (firstTest <= 10 && lastTest >= 10)
+    {
+        adopt_test_case(new audio_only_test(aProxy, PVMF_MIME_PCM16, PVMF_MIME_PCM16));
+    }
+
+    if (firstTest <= 11 && lastTest >= 11)
+        adopt_test_case(new video_only_test(PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
+    /*	if (firstTest <= 12 && lastTest >= 12)
+    		//adopt_test_case( new video_only_test(aProxy,PVMF_YUV420,PVMF_H263));
+    	if (firstTest <= 13 && lastTest >= 13)
+    		//adopt_test_case( new video_only_test(aProxy,PVMF_H263,PVMF_YUV420));
+    	if (firstTest <= 14 && lastTest >= 14)
+    		//adopt_test_case( new video_only_test(aProxy,PVMF_M4V,PVMF_YUV420));
+    	if (firstTest <= 15 && lastTest >= 15)
+    		//adopt_test_case( new video_only_test(aProxy,PVMF_YUV420,PVMF_M4V));
+
+    	if (firstTest <= 16 && lastTest >= 16)
+    		//adopt_test_case( new av_test(aProxy,PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_YUV420,PVMF_YUV420));
+
+    */
+    if (firstTest <= 17 && lastTest >= 17)
+        adopt_test_case(new av_test(PVMF_MIME_AMR_IF2, PVMF_MIME_PCM16, PVMF_MIME_YUV420, PVMF_MIME_YUV420, aProxy));
+    /*
+    	if (firstTest <= 18 && lastTest >= 18)
+    		//adopt_test_case( new av_test(aProxy, PVMF_PCM16,PVMF_AMR_IF2,PVMF_YUV420,PVMF_YUV420) );
+    	if (firstTest <= 19 && lastTest >= 19)
+    		adopt_test_case( new av_test(aProxy, PVMF_PCM16,PVMF_PCM16,PVMF_YUV420,PVMF_YUV420) );
+    */
+    /*	if (firstTest <= 20 && lastTest >= 20)
+    		//adopt_test_case( new av_test(aProxy, PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_YUV420,PVMF_H263) );
+    	if (firstTest <= 21 && lastTest >= 21)
+    		//adopt_test_case( new av_test(aProxy, PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_H263,PVMF_YUV420) );
+    	if (firstTest <= 22 && lastTest >= 22)
+    		//adopt_test_case( new av_test(aProxy, PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_H263,PVMF_H263) );
+    	if (firstTest <= 23 && lastTest >= 23)
+    		//adopt_test_case( new av_test(aProxy, PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_YUV420,PVMF_M4V) );
+    	if (firstTest <= 24 && lastTest >= 24)
+    		//adopt_test_case( new av_test(aProxy, PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_M4V,PVMF_YUV420) );
+    	if (firstTest <= 25 && lastTest >= 25)
+    		//adopt_test_case( new av_test(aProxy, PVMF_AMR_IF2,PVMF_AMR_IF2,PVMF_M4V,PVMF_M4V));
+
+    	if (firstTest <= 26 && lastTest >= 26)
+            adopt_test_case( new connect_test(aProxy, 1, true) );
+    */
+#if 0
+    if (firstTest <= 27 && lastTest >= 27)
+        adopt_test_case(new user_input_test(aProxy, false));
+#endif
+#endif
+
+#if 0
+    adopt_test_case(new connect_test(aProxy, 2));
+    adopt_test_case(new audio_only_pause_test(aProxy, 1));
+    adopt_test_case(new audio_only_pause_test(aProxy, 2));
+    adopt_test_case(new audio_only_pause_close_test(aProxy));
+    adopt_test_case(new audio_only_resume_close_test(aProxy));
+    adopt_test_case(new video_only_test(aProxy));
+    adopt_test_case(new video_only_pause_test(aProxy, 1));
+    adopt_test_case(new video_only_pause_test(aProxy, 2));
+    adopt_test_case(new video_only_pause_close_test(aProxy));
+    adopt_test_case(new video_only_resume_close_test(aProxy));
+    adopt_test_case(new av_test(aProxy, 2));
+    adopt_test_case(new av_pause_disconnect_test(aProxy));
+
+    //Record to file tests
+    fprintf(fileoutput, "Record to file tests.\n");
+    adopt_test_case(new init_rec_test(aProxy, 1));
+    adopt_test_case(new init_rec_test(aProxy, 2));
+    adopt_test_case(new init_rec_reset_test(aProxy));
+    adopt_test_case(new a_only_rec_test(aProxy, 1));
+    adopt_test_case(new a_only_rec_test(aProxy, 2));
+    adopt_test_case(new v_only_rec_test(aProxy, 1));
+    adopt_test_case(new v_only_rec_test(aProxy, 2));
+    adopt_test_case(new av_rec_test(aProxy));
+    adopt_test_case(new a_only_pause_rec_test(aProxy, 1));
+    adopt_test_case(new a_only_pause_rec_test(aProxy, 2));
+    adopt_test_case(new v_only_pause_rec_test(aProxy, 1));
+    adopt_test_case(new v_only_pause_rec_test(aProxy, 2));
+    adopt_test_case(new av_pause_rec_disconnect_test(aProxy));
+    adopt_test_case(new av_disconnect_reset_rec_test(aProxy));
+
+    //Preview tests
+    fprintf(fileoutput, "Preview output tests.\n");
+    adopt_test_case(new video_preview_test(aProxy, 1));
+    adopt_test_case(new video_preview_test(aProxy, 2));
+    adopt_test_case(new video_preview_disconnect_test(aProxy));
+    adopt_test_case(new video_preview_pause_test(aProxy, 1));
+    adopt_test_case(new video_preview_pause_test(aProxy, 2));
+    adopt_test_case(new av_rec_v_preview_test(aProxy));
+
+    //Play from file tests
+    fprintf(fileoutput, "Play from file tests.\n");
+    OSCL_wHeapString<OsclMemAllocator> file;
+    file = AUDIO_ONLY_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, true, false);
+    file = AUDIO_H263_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, true, true);
+    file = AUDIO_MPEG4_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, true, true);
+    file = H263_ONLY_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, false, true);
+    file = MPEG4_ONLY_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, false, true);
+    file = SQCIF_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, true, true);
+    file = QVGA_PLAY_FILENAME;
+    play_from_file_tests(aProxy, file, true, true);
+#endif
+}
+
+void engine_test_suite::play_from_file_tests(const bool aProxy,
+        const OSCL_wString& aFilename,
+        const bool aHasAudio,
+        const bool aHasVideo)
+{
+    OSCL_UNUSED_ARG(aProxy);
+    OSCL_UNUSED_ARG(aFilename);
+    OSCL_UNUSED_ARG(aHasAudio);
+    OSCL_UNUSED_ARG(aHasVideo);
+#if 0
+    adopt_test_case(new init_play_test(aProxy, aFilename, 1));
+    adopt_test_case(new init_play_test(aProxy, aFilename, 2));
+    adopt_test_case(new init_play_reset_test(aProxy, aFilename));
+    adopt_test_case(new play_from_file_test(aProxy, aFilename, 1));
+    adopt_test_case(new play_from_file_test(aProxy, aFilename, 2));
+
+    adopt_test_case(new use_play_file_test(aProxy, aFilename, false, false));
+    adopt_test_case(new use_play_file_test(aProxy, aFilename, false, true));
+    adopt_test_case(new use_play_file_test(aProxy, aFilename, true, false));
+    adopt_test_case(new use_play_file_test(aProxy, aFilename, true, true));
+
+    adopt_test_case(new play_from_file_disconnect_test(aProxy, aFilename, false));
+    adopt_test_case(new play_from_file_disconnect_test(aProxy, aFilename, true));
+
+    adopt_test_case(new play_from_file_pause_test(aProxy, aFilename, false, 1));
+    adopt_test_case(new play_from_file_pause_test(aProxy, aFilename, true, 1));
+    adopt_test_case(new play_from_file_pause_test(aProxy, aFilename, false, 2));
+    adopt_test_case(new play_from_file_pause_test(aProxy, aFilename, true, 2));
+
+    adopt_test_case(new pff_pause_disconnect_test(aProxy, aFilename, false));
+    adopt_test_case(new pff_pause_disconnect_test(aProxy, aFilename, true));
+
+    //A/V file
+    if (aHasAudio && aHasVideo)
+    {
+        //Wait for both audio and video end of stream indications
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, true, true, 1));
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, true, true, 2));
+        //Wait for audio end of stream indication
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, true, false, 1));
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, true, false, 2));
+        //Wait for video end of stream indication
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, false, true, 1));
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, false, true, 2));
+    }
+    //Audio only file
+    else if (aHasAudio)
+    {
+        //Wait for audio end of stream indication
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, true, false, 1));
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, true, false, 2));
+    }
+    //Video only file
+    else if (aHasVideo)
+    {
+        //Wait for video end of stream indication
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, false, true, 1));
+        adopt_test_case(new pff_eos_test(aProxy, aFilename, false, true, 2));
+    }
+
+    adopt_test_case(new test_everything_test(aProxy, aFilename));
+#endif
+}
+
+void engine_test::create_sink_source()
+{
+#ifndef NO_2WAY_324
+    iCommSettings.iMediaFormat = PVMF_MIME_H223;
+    iCommSettings.iTestObserver = NULL;
+    iCommServerIOControl = PvmiMIOCommLoopbackFactory::Create(iCommSettings);
+    bool enableBitstreamLogging = true;
+    iCommServer = PVCommsIONodeFactory::Create(iCommServerIOControl, enableBitstreamLogging);
+#endif
+
+    // create the audio source
+    iAudioSourceFileSettings.iMediaFormat = PVMF_MIME_AMR_IF2;
+    iAudioSourceFileSettings.iLoopInputFile = true;
+    iAudioSourceFileSettings.iFileName = AUDIO_SOURCE_FILENAME;
+    iAudioSourceFileSettings.iSamplingFrequency = 8000;
+    iAudioSourceFileSettings.iNumChannels = 1;
+    //iAudioSourceFileSettings.iFrameRateSimulation = true;
+    iAudioSourceIOControl = PvmiMIOFileInputFactory::Create(iAudioSourceFileSettings);
+    iAudioSource = PvmfMediaInputNodeFactory::Create(iAudioSourceIOControl);
+
+    iAudioSourceRawFileSettings.iMediaFormat = PVMF_MIME_PCM16;
+    iAudioSourceRawFileSettings.iLoopInputFile = true;
+    iAudioSourceRawFileSettings.iFileName = AUDIO_SOURCE_RAW_FILENAME;
+    iAudioSourceRawFileSettings.iSamplingFrequency = 8000;
+    iAudioSourceRawFileSettings.iNumChannels = 1;
+    //iAudioSourceRawFileSettings.iFrameRateSimulation = true;
+    iAudioSourceRawIOControl = PvmiMIOFileInputFactory::Create(iAudioSourceRawFileSettings);
+    iAudioSourceRaw = PvmfMediaInputNodeFactory::Create(iAudioSourceRawIOControl);
+
+    iAudioSource2FileSettings.iMediaFormat = PVMF_MIME_AMR_IF2;
+    iAudioSource2FileSettings.iLoopInputFile = true;
+    iAudioSource2FileSettings.iFileName = AUDIO_SOURCE_FILENAME;
+    iAudioSource2FileSettings.iSamplingFrequency = 8000;
+    iAudioSource2FileSettings.iNumChannels = 1;
+    //iAudioSource2FileSettings.iFrameRateSimulation = true;
+    iAudioSource2IOControl = PvmiMIOFileInputFactory::Create(iAudioSource2FileSettings);
+    iAudioSource2 = PvmfMediaInputNodeFactory::Create(iAudioSource2IOControl);
+
+    iAudioSource3FileSettings.iMediaFormat = PVMF_MIME_AMR_IETF;
+    iAudioSource3FileSettings.iLoopInputFile = true;
+    iAudioSource3FileSettings.iFileName = AUDIO_SOURCE3_FILENAME;
+    iAudioSource3FileSettings.iSamplingFrequency = 8000;
+    iAudioSource3FileSettings.iNum20msFramesPerChunk = 1;
+    //iAudioSource3FileSettings.iFrameRateSimulation = true;
+    iAudioSource3FileSettings.iNumChannels = 1;
+    iAudioSource3IOControl = PvmiMIOFileInputFactory::Create(iAudioSource3FileSettings);
+    iAudioSource3 = PvmfMediaInputNodeFactory::Create(iAudioSource3IOControl);
+
+    // create the audio sinks
+
+    iAudioSinkFileName = AUDIO_SINK_FILENAME;
+    //iAudioSinkIOControl = new PVRefFileOutput(iAudioSinkFileName, MEDIATYPE_AUDIO, true);
+    //iAudioSink = PVMediaOutputNodeFactory::CreateMediaOutputNode(iAudioSinkIOControl);
+    iAudioSink = PVFileOutputNodeFactory::CreateFileOutput(iAudioSinkFileName, PVMF_MIME_AMR_IF2);
+
+    iAudioSinkRawFileName = AUDIO_SINK_RAW_FILENAME;
+    //iAudioSinkRawIOControl = new PVRefFileOutput(iAudioSinkRawFileName, MEDIATYPE_AUDIO, false);
+    // iAudioSinkRaw = PVMediaOutputNodeFactory::CreateMediaOutputNode(iAudioSinkRawIOControl);
+    iAudioSinkRaw = PVFileOutputNodeFactory::CreateFileOutput(iAudioSinkRawFileName, PVMF_MIME_PCM16);
+
+    iAudioSink2FileName = AUDIO_SINK2_FILENAME;
+    // iAudioSink2IOControl = new PVRefFileOutput(iAudioSink2FileName, MEDIATYPE_AUDIO, true);
+    //iAudioSink2 = PVMediaOutputNodeFactory::CreateMediaOutputNode(iAudioSink2IOControl);
+    iAudioSink2 = PVFileOutputNodeFactory::CreateFileOutput(iAudioSink2FileName, PVMF_MIME_AMR_IF2);
+
+    // create the video sources
+    iVideoSourceYUVFileSettings.iMediaFormat = PVMF_MIME_YUV420;
+    iVideoSourceYUVFileSettings.iLoopInputFile = true;
+    iVideoSourceYUVFileSettings.iFileName = VIDEO_SOURCE_YUV_FILENAME;
+    iVideoSourceYUVFileSettings.iTimescale = 1000;
+    iVideoSourceYUVFileSettings.iFrameHeight = 144;
+    iVideoSourceYUVFileSettings.iFrameWidth = 176;
+    iVideoSourceYUVFileSettings.iFrameRate = 5;
+    //iVideoSourceYUVFileSettings.iFrameRateSimulation = true;
+    iVideoSourceYUVIOControl = PvmiMIOFileInputFactory::Create(iVideoSourceYUVFileSettings);
+    iVideoSourceYUV = PvmfMediaInputNodeFactory::Create(iVideoSourceYUVIOControl);
+
+
+    iVideoSourceH263FileSettings.iMediaFormat = PVMF_MIME_H2632000;
+    iVideoSourceH263FileSettings.iLoopInputFile = true;
+    iVideoSourceH263FileSettings.iFileName = VIDEO_SOURCE_H263_FILENAME;
+    iVideoSourceH263FileSettings.iTimescale = 1000;
+    iVideoSourceH263FileSettings.iFrameHeight = 144;
+    iVideoSourceH263FileSettings.iFrameWidth = 176;
+    iVideoSourceH263FileSettings.iFrameRate = 5;
+    //iVideoSourceH263FileSettings.iFrameRateSimulation = true;
+
+    iVideoSourceH263IOControl = PvmiMIOFileInputFactory::Create(iVideoSourceH263FileSettings);
+    iVideoSourceH263 = PvmfMediaInputNodeFactory::Create(iVideoSourceH263IOControl);
+
+    // create another video source
+    iVideoSourceM4VFileSettings.iMediaFormat = PVMF_MIME_M4V;
+    iVideoSourceM4VFileSettings.iLoopInputFile = true;
+    iVideoSourceM4VFileSettings.iFileName = VIDEO_SOURCE_M4V_FILENAME;
+    iVideoSourceM4VFileSettings.iTimescale = 1000;
+    iVideoSourceM4VFileSettings.iFrameHeight = 144;
+    iVideoSourceM4VFileSettings.iFrameWidth = 176;
+    iVideoSourceM4VFileSettings.iFrameRate = 5;
+    //iVideoSourceM4VFileSettings.iFrameRateSimulation = true;
+
+    iVideoSourceM4VIOControl = PvmiMIOFileInputFactory::Create(iVideoSourceM4VFileSettings);
+    iVideoSourceM4V = PvmfMediaInputNodeFactory::Create(iVideoSourceM4VIOControl);
+
+    // create the video sinks
+    iVideoSinkYUVFileName = VIDEO_SINK_YUV_FILENAME;
+    // iVideoSinkYUVIOControl = new PVRefFileOutput(iVideoSinkYUVFileName, MEDIATYPE_VIDEO, false);
+
+    //iVideoSinkYUV = PVMediaOutputNodeFactory::CreateMediaOutputNode(iVideoSinkYUVIOControl);
+    iVideoSinkYUV = PVFileOutputNodeFactory::CreateFileOutput(iVideoSinkYUVFileName, PVMF_MIME_YUV420);
+
+    iVideoSinkH263FileName = VIDEO_SINK_H263_FILENAME;
+    // iVideoSinkH263IOControl = new PVRefFileOutput(iVideoSinkH263FileName, MEDIATYPE_VIDEO, true);
+
+    // iVideoSinkH263 = PVMediaOutputNodeFactory::CreateMediaOutputNode(iVideoSinkH263IOControl);
+    iVideoSinkH263 = PVFileOutputNodeFactory::CreateFileOutput(iVideoSinkH263FileName, PVMF_MIME_H2632000);
+
+    iVideoSinkM4VFileName = VIDEO_SINK_M4V_FILENAME;
+    //iVideoSinkM4VIOControl = new PVRefFileOutput(iVideoSinkM4VFileName, MEDIATYPE_VIDEO, true);
+
+    // iVideoSinkM4V = PVMediaOutputNodeFactory::CreateMediaOutputNode(iVideoSinkM4VIOControl);
+    iVideoSinkM4V = PVFileOutputNodeFactory::CreateFileOutput(iVideoSinkM4VFileName, PVMF_MIME_M4V);
+
+}
+
+void engine_test::destroy_sink_source()
+{
+#ifndef NO_2WAY_324
+    if (iCommServer)
+    {
+        PVCommsIONodeFactory::Delete(iCommServer);
+        iCommServer = NULL;
+    }
+
+    if (iCommServerIOControl)
+    {
+        PvmiMIOCommLoopbackFactory::Delete(iCommServerIOControl);
+        iCommServerIOControl = NULL;
+    }
+#endif
+    if (iAudioSource)
+    {
+        PvmfMediaInputNodeFactory::Delete(iAudioSource);
+        iAudioSource = NULL;
+    }
+
+    if (iAudioSourceRaw)
+    {
+        PvmfMediaInputNodeFactory::Delete(iAudioSourceRaw);
+        iAudioSourceRaw = NULL;
+    }
+
+    if (iAudioSource2)
+    {
+        PvmfMediaInputNodeFactory::Delete(iAudioSource2);
+        iAudioSource2 = NULL;
+    }
+
+    if (iAudioSource3)
+    {
+        PvmfMediaInputNodeFactory::Delete(iAudioSource3);
+        iAudioSource3 = NULL;
+    }
+
+    if (iAudioSourceIOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iAudioSourceIOControl);
+        iAudioSourceIOControl = NULL;
+    }
+
+    if (iAudioSourceRawIOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iAudioSourceRawIOControl);
+        iAudioSourceRawIOControl = NULL;
+    }
+
+    if (iAudioSource2IOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iAudioSource2IOControl);
+        iAudioSource2IOControl = NULL;
+    }
+
+    if (iAudioSource3IOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iAudioSource3IOControl);
+        iAudioSource3IOControl = NULL;
+    }
+
+    if (iVideoSourceYUV)
+    {
+        PvmfMediaInputNodeFactory::Delete(iVideoSourceYUV);
+        iVideoSourceYUV = NULL;
+    }
+
+    if (iVideoSourceH263)
+    {
+        PvmfMediaInputNodeFactory::Delete(iVideoSourceH263);
+        iVideoSourceH263 = NULL;
+    }
+
+    if (iVideoSourceM4V)
+    {
+        PvmfMediaInputNodeFactory::Delete(iVideoSourceM4V);
+        iVideoSourceM4V = NULL;
+    }
+
+    if (iVideoSourceYUVIOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iVideoSourceYUVIOControl);
+        iVideoSourceYUVIOControl = NULL;
+    }
+
+    if (iVideoSourceM4VIOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iVideoSourceM4VIOControl);
+        iVideoSourceM4VIOControl = NULL;
+    }
+
+    if (iVideoSourceH263IOControl)
+    {
+        PvmiMIOFileInputFactory::Delete(iVideoSourceH263IOControl);
+        iVideoSourceH263IOControl = NULL;
+    }
+
+    if (iAudioSink)
+    {
+        //PVMediaOutputNodeFactory::DeleteMediaOutputNode(iAudioSink);
+        PVFileOutputNodeFactory::DeleteFileOutput(iAudioSink);
+        iAudioSink = NULL;
+    }
+
+    if (iAudioSinkRaw)
+    {
+        //PVMediaOutputNodeFactory::DeleteMediaOutputNode(iAudioSinkRaw);
+        PVFileOutputNodeFactory::DeleteFileOutput(iAudioSinkRaw);
+        iAudioSinkRaw = NULL;
+    }
+
+    if (iAudioSink2)
+    {
+        //PVMediaOutputNodeFactory::DeleteMediaOutputNode(iAudioSink2);
+        PVFileOutputNodeFactory::DeleteFileOutput(iAudioSink2);
+        iAudioSink2 = NULL;
+    }
+
+    if (iVideoSinkYUV)
+    {
+        //PVMediaOutputNodeFactory::DeleteMediaOutputNode(iVideoSinkYUV);
+        PVFileOutputNodeFactory::DeleteFileOutput(iVideoSinkYUV);
+        iVideoSinkYUV = NULL;
+    }
+
+    if (iVideoSinkH263)
+    {
+        //PVMediaOutputNodeFactory::DeleteMediaOutputNode(iVideoSinkH263);
+        PVFileOutputNodeFactory::DeleteFileOutput(iVideoSinkH263);
+        iVideoSinkH263 = NULL;
+    }
+
+    if (iVideoSinkM4V)
+    {
+        //PVMediaOutputNodeFactory::DeleteMediaOutputNode(iVideoSinkM4V);
+        PVFileOutputNodeFactory::DeleteFileOutput(iVideoSinkM4V);
+        iVideoSinkM4V = NULL;
+    }
+
+}
+
+PVMFNodeInterface *engine_test::get_audio_source(PVMFFormatType format)
+{
+    if (format == PVMF_MIME_AMR_IF2)
+        return iAudioSource;
+    else if (format ==  PVMF_MIME_PCM16)
+        return iAudioSourceRaw;
+    else
+        return NULL;
+
+}
+
+PVMFNodeInterface *engine_test::get_audio_sink(PVMFFormatType format)
+{
+    if (format == PVMF_MIME_AMR_IF2)
+        return iAudioSink;
+    if (format == PVMF_MIME_PCM16)
+        return iAudioSinkRaw;
+    else
+        return NULL;
+}
+
+PVMFNodeInterface *engine_test::get_video_source(PVMFFormatType format)
+{
+    if (format ==  PVMF_MIME_YUV420)
+        return iVideoSourceYUV;
+    else if (format ==  PVMF_MIME_M4V)
+        return iVideoSourceM4V;
+    else if (format ==  PVMF_MIME_H2632000)
+        return iVideoSourceH263;
+    else
+        return NULL;
+}
+
+PVMFNodeInterface *engine_test::get_video_sink(PVMFFormatType format)
+{
+    if (format == PVMF_MIME_YUV420)
+        return iVideoSinkYUV;
+    else if (format == PVMF_MIME_M4V)
+        return iVideoSinkM4V;
+    else if (format == PVMF_MIME_H2632000 || format == PVMF_MIME_H2631998)
+        return iVideoSinkH263;
+    else
+        return NULL;
+}
+
+void engine_test::init_mime_strings()
+{
+}
+int test_wrapper()
+{
+    int result;
+
+    OsclErrorTrap::Init();
+    OsclScheduler::Init("PV2WayEngineFactory");
+
+    result = start_test();
+
+    OsclScheduler::Cleanup();
+    OsclErrorTrap::Cleanup();
+
+    return result;
+}
+
+
+int local_main(FILE* filehandle, cmd_line *command_line)
+{
+    OSCL_UNUSED_ARG(command_line);
+    int result;
+    global_cmd_line = command_line;
+
+    fileoutput = filehandle;
+    fprintf(fileoutput, "Test Program for PV Engine class.\n");
+
+    CPV2WayEngineFactory::Init();
+#ifndef OSCL_BYPASS_MEMMGT
+#ifndef NDEBUG
+#ifdef MEM_AUDIT_2WAY
+    OsclAuditCB auditCB;
+    OsclMemInit(auditCB);
+    auditCB.pAudit->MM_SetMode(auditCB.pAudit->MM_GetMode() |
+                               MM_AUDIT_VALIDATE_ON_FREE_FLAG | MM_AUDIT_ALLOC_NODE_ENABLE_FLAG);
+#endif
+#endif
+#endif
+    result = test_wrapper();
+
+    PVLogger::Cleanup();
+#ifndef OSCL_BYPASS_MEMMGT
+#ifndef NDEBUG
+#ifdef MEM_AUDIT_2WAY
+    //Check for memory leaks before cleaning up OsclMem.
+
+    uint32 leaks = 0;
+
+    if (auditCB.pAudit)
+    {
+        MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
+        if (stats)
+        {
+            fprintf(fileoutput, "Memory Stats:\n");
+            fprintf(fileoutput, "  peakNumAllocs %d\n", stats->peakNumAllocs);
+            fprintf(fileoutput, "  peakNumBytes %d\n", stats->peakNumBytes);
+            fprintf(fileoutput, "  numAllocFails %d\n", stats->numAllocFails);
+            if (stats->numAllocs)
+            {
+                fprintf(fileoutput, "  ERROR: Memory Leaks! numAllocs %d, numBytes %d\n", stats->numAllocs, stats->numBytes);
+            }
+        }
+        leaks = auditCB.pAudit->MM_GetNumAllocNodes();
+        if (leaks != 0)
+        {
+            fprintf(fileoutput, "ERROR: %d Memory leaks detected!\n", leaks);
+            MM_AllocQueryInfo*info = auditCB.pAudit->MM_CreateAllocNodeInfo(leaks);
+            uint32 leakinfo = auditCB.pAudit->MM_GetAllocNodeInfo(info, leaks, 0);
+            if (leakinfo != leaks)
+            {
+                fprintf(fileoutput, "ERROR: Leak info is incomplete.\n");
+            }
+            for (uint32 i = 0;i < leakinfo;i++)
+            {
+                fprintf(fileoutput, "Leak Info:\n");
+                fprintf(fileoutput, "  allocNum %d\n", info[i].allocNum);
+                fprintf(fileoutput, "  fileName %s\n", info[i].fileName);
+                fprintf(fileoutput, "  lineNo %d\n", info[i].lineNo);
+                fprintf(fileoutput, "  size %d\n", info[i].size);
+                fprintf(fileoutput, "  pMemBlock 0x%x\n", info[i].pMemBlock);
+                fprintf(fileoutput, "  tag %s\n", info[i].tag);
+            }
+            auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
+        }
+    }
+#endif
+#endif
+#endif
+    PVLogger::Init();
+    CPV2WayEngineFactory::Cleanup();
+
+    return (result);
+}
+
+
+int start_test()
+{
+    int32 leave;
+    engine_test_suite engine_tests;
+
+    OSCL_TRY(leave, engine_tests.run_test());
+
+    if (leave != 0)
+        fprintf(fileoutput, "Leave %d\n", leave);
+
+    text_test_interpreter interp;
+    _STRING rs = interp.interpretation(engine_tests.last_result());
+    fprintf(fileoutput, rs.c_str());
+    const test_result the_result = engine_tests.last_result();
+
+    return(the_result.success_count() != the_result.total_test_count());
+}
+
+#if (LINUX_MAIN==1)
+
+int main(int argc, char *argv[])
+{
+    local_main(stdout, NULL);
+    return 0;
+}
+
+#endif
+
diff --git a/engines/2way/test/src/test_everything_test.cpp b/engines/2way/test/src/test_everything_test.cpp
new file mode 100644
index 0000000..b66fab5
--- /dev/null
+++ b/engines/2way/test/src/test_everything_test.cpp
@@ -0,0 +1,552 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "test_everything_test.h"
+
+void test_everything_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start test everything test, proxy %d, file %s\n", iUseProxy, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void test_everything_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void test_everything_test::DoCancel()
+{
+}
+
+void test_everything_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void test_everything_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                    break;
+                }
+
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                    break;
+                }
+
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+
+                    if (check_audio_started() && iRecordFileInitialized)
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        if (iRecordFileInitialized)
+                        {
+                            OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+
+                    if (check_audio_started() && iRecordFileInitialized)
+                    {
+                        OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+
+                        if (iRecordFileInitialized)
+                        {
+                            OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+            }
+
+            OSCL_TRY(error, terminal->ResetL());
+            if (error)
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iRecordFileInitialized = true;
+
+                if (check_audio_started())
+                {
+                    OSCL_TRY(error, iAudioStartRecId = terminal->StartRecordL(*iAudioSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+
+                if (check_video_started())
+                {
+                    OSCL_TRY(error, iVideoStartRecId = terminal->StartRecordL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdId() == iAudioStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioRecStarted = true;
+                    is_test_done();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioStartRecId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoStartRecId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoRecStarted = true;
+                    is_test_done();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoStartRecId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iVideoPreviewStarted = true;
+                is_test_done();
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+                if (error)
+                {
+                    test_is_true(false);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+            }
+            break;
+
+        case PVT_COMMAND_USE_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->StartPlayL());
+                if (error)
+                {
+                    test_is_true(false);
+                }
+            }
+            else
+            {
+                test_is_true(false);
+            }
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iPlayStarted = true;
+                is_test_done();
+            }
+            else
+            {
+                test_is_true(false);
+            }
+            break;
+    }
+}
+
+bool test_everything_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+void test_everything_test::is_test_done()
+{
+    if (check_rec_started() &&
+            iPlayStarted &&
+            iVideoPreviewStarted)
+    {
+        disconnect();
+    }
+}
+
+
diff --git a/engines/2way/test/src/use_play_file_test.cpp b/engines/2way/test/src/use_play_file_test.cpp
new file mode 100644
index 0000000..b4b88bd
--- /dev/null
+++ b/engines/2way/test/src/use_play_file_test.cpp
@@ -0,0 +1,533 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "use_play_file_test.h"
+
+void use_play_file_test::test()
+{
+    int error = 0;
+    char *filename = new char[iFilename.get_size() + 1];
+    if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0))
+    {
+        OSCL_LEAVE(-1);
+    }
+
+    fprintf(fileoutput, "Start use play file test, proxy %d, before add source %d, start play before use file %d, file %s\n", iUseProxy, iUsePlayFileBeforeAddSource, iStartPlayBeforeUsePlayFile, filename);
+
+    delete filename;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void use_play_file_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void use_play_file_test::DoCancel()
+{
+}
+
+void use_play_file_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                OSCL_TRY(error, iAudioAddSinkId = terminal->AddDataSinkL(*iAudioSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iIsConnected = false;
+            iPlayStarted = false;
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            else if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iAudioSinkAdded = false;
+                }
+                else
+                {
+                    iAudioSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void use_play_file_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->InitPlayFileL(iFilename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSourceAdded = true;
+                    check_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSourceId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+                    check_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iAudioRemoveSourceId)
+            {
+                iAudioRemoveSourceId = 0;
+                iAudioSourceAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iAudioSinkAdded = true;
+                    check_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iAudioAddSinkId = 0;
+            }
+            else if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+                    check_av_started();
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iAudioRemoveSinkId)
+            {
+                iAudioRemoveSinkId = 0;
+                iAudioSinkAdded = false;
+            }
+            else if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iIsConnected = true;
+
+                OSCL_TRY(error, iAudioAddSourceId = terminal->AddDataSourceL(*iAudioSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iIsConnected = false;
+            iPlayStarted = false;
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetPlayFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iUsePlayFileBeforeAddSource)
+                {
+                    if (iStartPlayBeforeUsePlayFile)
+                    {
+                        OSCL_TRY(error, terminal->StartPlayL());
+                    }
+                    else
+                    {
+                        OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+                    }
+
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        reset();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_PLAY_FILE:
+            reset();
+            break;
+
+        case PVT_COMMAND_USE_PLAY_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iUsePlayDone = true;
+
+                if (iStartPlayBeforeUsePlayFile)
+                {
+                    if (iUsePlayFileBeforeAddSource)
+                    {
+                        OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            reset();
+                        }
+                    }
+                    else
+                    {
+                        check_test_done();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->StartPlayL());
+                    if (error)
+                    {
+                        test_is_true(false);
+                        shutdown();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                shutdown();
+            }
+            break;
+
+        case PVT_COMMAND_START_PLAY:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iPlayStarted = true;
+
+                if (iStartPlayBeforeUsePlayFile)
+                {
+                    OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        shutdown();
+                    }
+                }
+                else
+                {
+                    if (iUsePlayFileBeforeAddSource)
+                    {
+                        OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            reset();
+                        }
+                    }
+                    else
+                    {
+                        check_test_done();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                shutdown();
+            }
+            break;
+
+        case PVT_COMMAND_STOP_PLAY:
+            iPlayStarted = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+                disconnect();
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool use_play_file_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+void use_play_file_test::check_av_started()
+{
+    int error = 0;
+    if (check_audio_started() && check_video_started())
+    {
+        if (iUsePlayFileBeforeAddSource)
+        {
+            check_test_done();
+        }
+        else
+        {
+            if (iStartPlayBeforeUsePlayFile)
+            {
+                OSCL_TRY(error, terminal->StartPlayL());
+            }
+            else
+            {
+                OSCL_TRY(error, terminal->UsePlayFileAsSourceL(true));
+            }
+
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+        }
+    }
+
+    return;
+}
+
+void use_play_file_test::check_test_done()
+{
+    int error = 0;
+
+    if (check_audio_started() &&
+            check_video_started() &&
+            iUsePlayDone &&
+            iPlayStarted)
+    {
+        OSCL_TRY(error, terminal->StopPlayL());
+        if (error)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+    }
+}
+
+
diff --git a/engines/2way/test/src/user_input_test.cpp b/engines/2way/test/src/user_input_test.cpp
new file mode 100644
index 0000000..f2fb36d
--- /dev/null
+++ b/engines/2way/test/src/user_input_test.cpp
@@ -0,0 +1,164 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "user_input_test.h"
+
+#define DTMF_TEST_INPUT '1'
+#define DTMF_TEST_UPDATE false
+#define DTMF_TEST_DURATION 20
+
+#define ALPHANUMERIC_STRING_LENGTH 16
+uint8 alphanumericTestString[ALPHANUMERIC_STRING_LENGTH] =
+{
+    '0', '1', '2', '3', '4', '5', '6', '7',
+    '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+};
+
+void user_input_test::test()
+{
+    fprintf(fileoutput, "Start user input test, is dtmf %d, proxy %d.\n", iIsDTMF, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void user_input_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            //CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void user_input_test::DoCancel()
+{
+}
+
+void user_input_test::H324MConfigCommandCompletedL(PVMFCmdResp& aResponse)
+{
+    OSCL_UNUSED_ARG(aResponse);
+}
+
+void user_input_test::H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aEvent)
+{
+    switch (aEvent.GetEventType())
+    {
+        case PV_INDICATION_USER_INPUT:
+            break;
+        case PV_INDICATION_USER_INPUT_CAPABILITY:
+            break;
+    }
+}
+
+void user_input_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+void user_input_test::RstCmdCompleted()
+{
+    RunIfNotReady();
+}
+
+void user_input_test::DisCmdSucceeded()
+{
+    printf("Finished disconnecting \n");
+    if (i324mConfigInterface)
+        i324mConfigInterface->removeRef();
+    reset();
+}
+
+void user_input_test::DisCmdFailed()
+{
+    printf("Finished disconnecting \n");
+    if (i324mConfigInterface)
+        i324mConfigInterface->removeRef();
+    reset();
+}
+
+void user_input_test::ConnectSucceeeded()
+{
+    i324mConfigInterface = iH324MConfig;
+//		OSCL_TRY(error, i324mIFCommandId = terminal->QueryInterface(PVH324MConfigUuid, i324mConfigInterface,NULL));
+    if (i324mConfigInterface == NULL)
+    {
+        test_is_true(false);
+        disconnect();
+    }
+    H324MConfigInterface * i324Interface = (H324MConfigInterface *)i324mConfigInterface;
+    i324Interface->SetObserver(this);
+    iUserInputId = i324Interface->SendUserInput(iUserInput);
+}
+
+void user_input_test::InitFailed()
+{
+    test_is_true(false);
+    RunIfNotReady();
+}
+
+bool user_input_test::start_async_test()
+{
+    if (iIsDTMF)
+    {
+        iUserInput = new CPVUserInputDtmf(DTMF_TEST_INPUT, DTMF_TEST_UPDATE, DTMF_TEST_DURATION);
+    }
+    else
+    {
+        iUserInput = new CPVUserInputAlphanumeric(alphanumericTestString, ALPHANUMERIC_STRING_LENGTH);
+    }
+
+    if (iUserInput == NULL)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+
+    return test_base::start_async_test();;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/v_only_pause_rec_test.cpp b/engines/2way/test/src/v_only_pause_rec_test.cpp
new file mode 100644
index 0000000..bfd6a5f
--- /dev/null
+++ b/engines/2way/test/src/v_only_pause_rec_test.cpp
@@ -0,0 +1,420 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "v_only_pause_rec_test.h"
+
+
+
+void v_only_pause_rec_test::test()
+{
+    fprintf(fileoutput, "Start video only pause rec test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void v_only_pause_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void v_only_pause_rec_test::DoCancel()
+{
+}
+
+
+void v_only_pause_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void v_only_pause_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetRecordFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            reset();
+            break;
+
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->PauseRecordL(*iVideoSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_STOP_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+
+            OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+            if (error)
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_PAUSE_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResumeRecordL(*iVideoSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->PauseRecordL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    OSCL_TRY(error, terminal->StopRecordL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool v_only_pause_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/v_only_rec_test.cpp b/engines/2way/test/src/v_only_rec_test.cpp
new file mode 100644
index 0000000..40bb863
--- /dev/null
+++ b/engines/2way/test/src/v_only_rec_test.cpp
@@ -0,0 +1,391 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "v_only_rec_test.h"
+
+
+
+void v_only_rec_test::test()
+{
+    fprintf(fileoutput, "Start video only rec test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void v_only_rec_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void v_only_rec_test::DoCancel()
+{
+}
+
+
+void v_only_rec_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void v_only_rec_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_wHeapString<OsclMemAllocator> filename(RECORDED_CALL_FILENAME);
+                OSCL_TRY(error, terminal->InitRecordFileL(filename));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->StartRecordL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            OSCL_TRY(error, terminal->ResetRecordFileL());
+            if (error)
+            {
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_INIT_RECORD_FILE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_RESET_RECORD_FILE:
+            reset();
+            break;
+
+
+        case PVT_COMMAND_START_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->StopRecordL(*iVideoSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+
+        case PVT_COMMAND_STOP_RECORD:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iCurrentRun >= (iMaxRuns - 1))
+                {
+                    test_is_true(true);
+                }
+            }
+            else
+            {
+                iCurrentRun = iMaxRuns;
+                test_is_true(false);
+            }
+
+            iCurrentRun++;
+            if (iCurrentRun < iMaxRuns)
+            {
+                OSCL_TRY(error, terminal->StartRecordL(*iVideoSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+    }
+}
+
+bool v_only_rec_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_only_pause_close_test.cpp b/engines/2way/test/src/video_only_pause_close_test.cpp
new file mode 100644
index 0000000..ecc4ffb
--- /dev/null
+++ b/engines/2way/test/src/video_only_pause_close_test.cpp
@@ -0,0 +1,371 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_only_pause_close_test.h"
+
+
+
+void video_only_pause_close_test::test()
+{
+    fprintf(fileoutput, "Start video only pause close test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_only_pause_close_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_only_pause_close_test::DoCancel()
+{
+}
+
+
+void video_only_pause_close_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_only_pause_close_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, iVideoPauseSourceId = terminal->PauseL(*iVideoSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+
+                        OSCL_TRY(error, iVideoPauseSinkId = terminal->PauseL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->PauseL(*iVideoSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+
+                        OSCL_TRY(error, terminal->PauseL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if ((aResponse.GetCmdStatus() != PVMFErrCancelled) &&
+                    (aResponse.GetCmdStatus() != PVMFSuccess))
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool video_only_pause_close_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_only_pause_test.cpp b/engines/2way/test/src/video_only_pause_test.cpp
new file mode 100644
index 0000000..b2a3b55
--- /dev/null
+++ b/engines/2way/test/src/video_only_pause_test.cpp
@@ -0,0 +1,373 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_only_pause_test.h"
+
+
+
+void video_only_pause_test::test()
+{
+    fprintf(fileoutput, "Start video only pause test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_only_pause_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_only_pause_test::DoCancel()
+{
+}
+
+
+void video_only_pause_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_only_pause_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    OSCL_TRY(error, iVideoPauseSourceId = terminal->PauseL(*iVideoSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    OSCL_TRY(error, iVideoPauseSinkId = terminal->PauseL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iVideoPauseSourceId)
+                {
+                    OSCL_TRY(error, iVideoResumeSourceId = terminal->ResumeL(*iVideoSource));
+                }
+                else if (aResponse.GetCmdId() == iVideoPauseSinkId)
+                {
+                    OSCL_TRY(error, iVideoResumeSinkId = terminal->ResumeL(*iVideoSink));
+                }
+                else
+                {
+                    error = -1;
+                }
+
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iVideoResumeSourceId)
+                {
+                    iVideoSourceResumed = true;
+                }
+                else if (aResponse.GetCmdId() == iVideoResumeSinkId)
+                {
+                    iVideoSinkResumed = true;
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                    break;
+                }
+
+                if (check_video_resumed())
+                {
+                    iCurrentRun++;
+
+                    if (iCurrentRun < iMaxRuns)
+                    {
+                        OSCL_TRY(error, iVideoPauseSourceId = terminal->PauseL(*iVideoSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                        else
+                        {
+                            OSCL_TRY(error, iVideoPauseSinkId = terminal->PauseL(*iVideoSink));
+                            if (error)
+                            {
+                                test_is_true(false);
+                                disconnect();
+                            }
+                        }
+                        iVideoSourceResumed = false;
+                        iVideoSinkResumed = false;
+                    }
+                    else
+                    {
+                        test_is_true(true);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool video_only_pause_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_only_resume_close_test.cpp b/engines/2way/test/src/video_only_resume_close_test.cpp
new file mode 100644
index 0000000..38d62a7
--- /dev/null
+++ b/engines/2way/test/src/video_only_resume_close_test.cpp
@@ -0,0 +1,375 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_only_resume_close_test.h"
+
+
+
+void video_only_resume_close_test::test()
+{
+    fprintf(fileoutput, "Start video only resume close test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_only_resume_close_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_only_resume_close_test::DoCancel()
+{
+}
+
+
+void video_only_resume_close_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_only_resume_close_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    OSCL_TRY(error, iVideoPauseSourceId = terminal->PauseL(*iVideoSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    OSCL_TRY(error, iVideoPauseSinkId = terminal->PauseL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId  = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    test_is_true(true);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+        case PVT_COMMAND_PAUSE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (aResponse.GetCmdId() == iVideoPauseSourceId)
+                {
+                    iVideoSourcePaused = true;
+                }
+                else if (aResponse.GetCmdId() == iVideoPauseSinkId)
+                {
+                    iVideoSinkPaused = true;
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                    break;
+                }
+
+                if (check_video_paused())
+                {
+                    OSCL_TRY(error, iVideoResumeSourceId = terminal->ResumeL(*iVideoSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                    else
+                    {
+                        OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+
+                    OSCL_TRY(error, iVideoResumeSinkId = terminal->ResumeL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                    else
+                    {
+                        OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME:
+            if ((aResponse.GetCmdStatus() != PVMFErrCancelled) &&
+                    (aResponse.GetCmdStatus() != PVMFSuccess))
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_CANCEL_ALL_COMMANDS:
+            break;
+    }
+}
+
+bool video_only_resume_close_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_only_test.cpp b/engines/2way/test/src/video_only_test.cpp
new file mode 100644
index 0000000..32332bd
--- /dev/null
+++ b/engines/2way/test/src/video_only_test.cpp
@@ -0,0 +1,309 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_only_test.h"
+
+#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+#include "pvmp4h263encextension.h"
+#endif
+
+#define TRADEOFF_VALUE 5
+#define TRADEOFF_VALUE_2 10
+
+
+void video_only_test::test()
+{
+    fprintf(fileoutput, "Start video only test, proxy %d SrcFormat:", iUseProxy);
+
+    printFormatString(iVidSrcFormatType);
+
+    fprintf(fileoutput, " SinkFormat:");
+
+    printFormatString(iVidSinkFormatType);
+
+    fprintf(fileoutput, "\n");
+
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    init_mime_strings();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_only_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    if (timer)
+    {
+        delete timer;
+        timer = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_only_test::DoCancel()
+{
+}
+
+void video_only_test::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    int error = 0;
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_OUTGOING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if (aEvent.GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                printf("Audio");
+            }
+            else if (aEvent.GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                iOutgoingVideo = *channel_id;
+                iSelVideoSource = get_video_source(iVidSrcFormatType);
+                if (iSelVideoSource != NULL)
+                {
+                    OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSource(*channel_id, *iSelVideoSource));
+                    printf("Video");
+                }
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" outgoing Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_INCOMING_TRACK:
+        {
+            TPVChannelId *channel_id = (TPVChannelId *)(&aEvent.GetLocalBuffer()[4]);
+            printf("Indication with logical channel #%d ", *channel_id);
+            if (aEvent.GetLocalBuffer()[0] == PV_AUDIO)
+            {
+                printf("Audio");
+            }
+            else if (aEvent.GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                iIncomingVideo = *channel_id;
+                iSelVideoSink = get_video_sink(iVidSinkFormatType);
+                if (iSelVideoSink != NULL)
+                {
+                    OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSink(*channel_id, *iSelVideoSink));
+                    printf("Video");
+                }
+            }
+            else
+            {
+                printf("unknown");
+            }
+            printf(" incoming Track\n");
+            break;
+        }
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_only_test::H324MConfigCommandCompletedL(PVMFCmdResp& aResponse)
+{
+    OSCL_UNUSED_ARG(aResponse);
+}
+
+void video_only_test::H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aEvent)
+{
+    switch (aEvent.GetEventType())
+    {
+        case PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND:
+            if (aEvent.GetLocalBuffer()[2] == TRADEOFF_VALUE)
+            {
+                H324MConfigInterface * i324Interface = (H324MConfigInterface *)i324mConfigInterface;
+                iTradeOffInd = i324Interface->SendVideoTemporalSpatialTradeoffIndication(iOutgoingVideo, TRADEOFF_VALUE_2);
+            }
+            break;
+        case PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION:
+            if (aEvent.GetLocalBuffer()[2] == TRADEOFF_VALUE_2)
+            {
+                test_is_true(true);
+                timer->RunIfNotReady(TEST_DURATION);
+            }
+            break;
+    }
+}
+
+void video_only_test::DoStuffWithH324MConfig()
+{
+    H324MConfigInterface * i324Interface = (H324MConfigInterface *)i324mConfigInterface;
+    i324Interface->SetObserver(this);
+    iTradeOffCmd = i324Interface->SendVideoTemporalSpatialTradeoffCommand(iIncomingVideo, TRADEOFF_VALUE);
+    iEncIFCommandId = terminal->QueryInterface(PVMp4H263EncExtensionUUID, iVidEncIFace);
+}
+
+void video_only_test::VideoAddSinkSucceeded()
+{
+    iVideoSinkAdded = true;
+    if (iVideoSourceAdded)
+    {
+        i324mConfigInterface = iH324MConfig;
+//		OSCL_TRY(error, i324mIFCommandId = terminal->QueryInterface(PVH324MConfigUuid, i324mConfigInterface,NULL));
+        if (i324mConfigInterface == NULL)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+        DoStuffWithH324MConfig();
+    }
+}
+void video_only_test::VideoAddSourceSucceeded()
+{
+    iVideoSourceAdded = true;
+    if (iVideoSinkAdded)
+    {
+        i324mConfigInterface = iH324MConfig;
+//			OSCL_TRY(error, i324mIFCommandId = terminal->QueryInterface(PVH324MConfigUuid, i324mConfigInterface,NULL));
+        if (i324mConfigInterface == NULL)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+        DoStuffWithH324MConfig();
+    }
+}
+void video_only_test::VideoAddSourceFailed()
+{
+    if (iVidSrcFormatType == PVMF_MIME_M4V)
+    {
+        test_is_true(true);
+    }
+    else
+    {
+        test_is_true(false);
+    }
+    disconnect();
+}
+
+void video_only_test::EncoderIFSucceeded()
+{
+    PVMp4H263EncExtensionInterface *iface = (PVMp4H263EncExtensionInterface *)iVidEncIFace;
+    iface->RequestIFrame();
+}
+void video_only_test::EncoderIFFailed()
+{
+    EncoderIFSucceeded();
+}
+void video_only_test::DisCmdFailed()
+{
+    DisCmdSucceeded();
+}
+void video_only_test::DisCmdSucceeded()
+{
+    printf("Finished disconnecting \n");
+//	destroy_sink_source();
+    if (i324mConfigInterface)
+        i324mConfigInterface->removeRef();
+    reset();
+}
+
+void video_only_test::InitFailed()
+{
+    test_is_true(false);
+    test_base::InitFailed();
+}
+
+void video_only_test::ConnectSucceeded()
+{
+}
+
+void video_only_test::ConnectFailed()
+{
+}
+
+void video_only_test::TimerCallback()
+{
+    int error = 1;
+
+    if (iSelVideoSource != NULL)
+    {
+        OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSource(*iSelVideoSource));
+        if (error)
+        {
+            test_is_true(false);
+            disconnect();
+        }
+    }
+}
+
+bool video_only_test::start_async_test()
+{
+    timer = new engine_timer(this);
+    if (timer == NULL)
+    {
+        test_is_true(false);
+        return false;
+    }
+    timer->AddToScheduler();
+
+
+    return test_base::start_async_test();
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_preview_disconnect_test.cpp b/engines/2way/test/src/video_preview_disconnect_test.cpp
new file mode 100644
index 0000000..0a807f2
--- /dev/null
+++ b/engines/2way/test/src/video_preview_disconnect_test.cpp
@@ -0,0 +1,341 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_preview_disconnect_test.h"
+
+
+
+void video_preview_disconnect_test::test()
+{
+    fprintf(fileoutput, "Start video preview disconnect test, proxy %d.\n", iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_preview_disconnect_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_preview_disconnect_test::DoCancel()
+{
+}
+
+
+void video_preview_disconnect_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_preview_disconnect_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                test_is_true(true);
+            }
+            else
+            {
+                test_is_true(false);
+            }
+
+            reset();
+            break;
+
+
+        case PVT_COMMAND_ADD_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                TPVPostDisconnectOption option;
+                OSCL_TRY(error, terminal->DisconnectL(option));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+            test_is_true(false);
+            break;
+    }
+}
+
+bool video_preview_disconnect_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_preview_pause_test.cpp b/engines/2way/test/src/video_preview_pause_test.cpp
new file mode 100644
index 0000000..32eebf7
--- /dev/null
+++ b/engines/2way/test/src/video_preview_pause_test.cpp
@@ -0,0 +1,399 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_preview_pause_test.h"
+
+
+
+void video_preview_pause_test::test()
+{
+    fprintf(fileoutput, "Start video preview pause test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_preview_pause_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_preview_pause_test::DoCancel()
+{
+}
+
+
+void video_preview_pause_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_preview_pause_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+
+        case PVT_COMMAND_ADD_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->PausePreviewSinkL(*iVideoPreview));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+
+                OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_PAUSE_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ResumePreviewSinkL(*iVideoPreview));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_RESUME_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->PausePreviewSinkL(*iVideoPreview));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(true);
+
+                    OSCL_TRY(error, terminal->RemovePreviewSinkL(*iVideoPreview));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool video_preview_pause_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/src/video_preview_test.cpp b/engines/2way/test/src/video_preview_test.cpp
new file mode 100644
index 0000000..7ec5adc
--- /dev/null
+++ b/engines/2way/test/src/video_preview_test.cpp
@@ -0,0 +1,365 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "video_preview_test.h"
+
+
+
+void video_preview_test::test()
+{
+    fprintf(fileoutput, "Start video preview test, num runs %d, proxy %d.\n", iMaxRuns, iUseProxy);
+    int error = 0;
+
+    scheduler = OsclExecScheduler::Current();
+
+    this->AddToScheduler();
+
+    if (start_async_test())
+    {
+        OSCL_TRY(error, scheduler->StartScheduler());
+        if (error != 0)
+        {
+            OSCL_LEAVE(error);
+        }
+    }
+
+    destroy_sink_source();
+
+    this->RemoveFromScheduler();
+}
+
+
+void video_preview_test::Run()
+{
+    if (terminal)
+    {
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+        terminal = NULL;
+    }
+
+    scheduler->StopScheduler();
+}
+
+void video_preview_test::DoCancel()
+{
+}
+
+
+void video_preview_test::HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent)
+{
+    int error = 0;
+
+    switch (aEvent.GetEventType())
+    {
+        case PVT_INDICATION_INCOMING_TRACK:
+            TPVChannelId id;
+
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                OSCL_TRY(error, iVideoAddSinkId = terminal->AddDataSinkL(*iVideoSink, id));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            break;
+
+        case PVT_INDICATION_CLOSE_TRACK:
+            if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[0] == PV_VIDEO)
+            {
+                if (((CPVCmnAsyncEvent&)aEvent).GetLocalBuffer()[1] == INCOMING)
+                {
+                    iVideoSinkAdded = false;
+                }
+                else
+                {
+                    iVideoSourceAdded = false;
+                }
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_INDICATION_INTERNAL_ERROR:
+            break;
+
+        default:
+            break;
+    }
+}
+
+void video_preview_test::CommandCompletedL(const CPVCmnCmdResp& aResponse)
+{
+    int error = 0;
+    switch (aResponse.GetCmdType())
+    {
+        case PVT_COMMAND_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->ConnectL(iConnectOptions));
+                if (error)
+                {
+                    test_is_true(false);
+                    reset();
+                }
+                else
+                {
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                RunIfNotReady();
+            }
+            break;
+
+        case PVT_COMMAND_RESET:
+            RunIfNotReady();
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoAddSourceId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSourceAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSourceId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SOURCE:
+            if (aResponse.GetCmdId() == iVideoRemoveSourceId)
+            {
+                iVideoRemoveSourceId = 0;
+                iVideoSourceAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_ADD_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoAddSinkId)
+            {
+                if (aResponse.GetCmdStatus() == PVMFSuccess)
+                {
+                    iVideoSinkAdded = true;
+
+                    if (check_video_started())
+                    {
+                        OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                        if (error)
+                        {
+                            test_is_true(false);
+                            disconnect();
+                        }
+                    }
+                }
+                else
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+                iVideoAddSinkId = 0;
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_DATA_SINK:
+            if (aResponse.GetCmdId() == iVideoRemoveSinkId)
+            {
+                iVideoRemoveSinkId = 0;
+                iVideoSinkAdded = false;
+
+                if (check_video_stopped())
+                {
+                    disconnect();
+                }
+            }
+            break;
+
+        case PVT_COMMAND_CONNECT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, iVideoAddSourceId = terminal->AddDataSourceL(*iVideoSource));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                reset();
+            }
+            break;
+
+        case PVT_COMMAND_DISCONNECT:
+            iAudioSourceAdded = false;
+            iVideoSourceAdded = false;
+            iAudioSinkAdded = false;
+            iVideoSinkAdded = false;
+            reset();
+            break;
+
+
+        case PVT_COMMAND_ADD_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                OSCL_TRY(error, terminal->RemovePreviewSinkL(*iVideoPreview));
+                if (error)
+                {
+                    test_is_true(false);
+                    disconnect();
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+
+        case PVT_COMMAND_REMOVE_PREVIEW_SINK:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iCurrentRun++;
+                if (iCurrentRun < iMaxRuns)
+                {
+                    OSCL_TRY(error, terminal->AddPreviewSinkL(*iVideoSource, *iVideoPreview));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+                else
+                {
+                    test_is_true(true);
+
+                    OSCL_TRY(error, iVideoRemoveSourceId = terminal->RemoveDataSourceL(*iVideoSource));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+
+                    OSCL_TRY(error, iVideoRemoveSinkId = terminal->RemoveDataSinkL(*iVideoSink));
+                    if (error)
+                    {
+                        test_is_true(false);
+                        disconnect();
+                    }
+                }
+            }
+            else
+            {
+                test_is_true(false);
+                disconnect();
+            }
+            break;
+    }
+}
+
+bool video_preview_test::start_async_test()
+{
+    int error = 0;
+
+    if (iUseProxy)
+    {
+        OSCL_TRY(error, terminal = CPV2WayProxyFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+    else
+    {
+        OSCL_TRY(error, terminal = CPV2WayEngineFactory::CreateTerminalL(PV_324M,
+                                   (MPVCmnCmdStatusObserver *) this,
+                                   (MPVCmnInfoEventObserver *) this,
+                                   (MPVCmnErrorEventObserver *) this));
+    }
+
+    if (error)
+    {
+        test_is_true(false);
+        return false;
+    }
+
+    create_sink_source();
+
+    OSCL_TRY(error, terminal->InitL(iSdkInitInfo, iCommServer));
+    if (error)
+    {
+        test_is_true(false);
+
+        if (iUseProxy)
+        {
+            CPV2WayProxyFactory::DeleteTerminal(terminal);
+        }
+        else
+        {
+            CPV2WayEngineFactory::DeleteTerminal(terminal);
+        }
+
+        terminal = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+
+
+
diff --git a/engines/2way/test/test_data/audio_in.amr b/engines/2way/test/test_data/audio_in.amr
new file mode 100644
index 0000000..7888380
--- /dev/null
+++ b/engines/2way/test/test_data/audio_in.amr
Binary files differ
diff --git a/engines/2way/test/test_data/audio_in.if2 b/engines/2way/test/test_data/audio_in.if2
new file mode 100644
index 0000000..7d4134c
--- /dev/null
+++ b/engines/2way/test/test_data/audio_in.if2
Binary files differ
diff --git a/engines/2way/test/test_data/getstats.sh b/engines/2way/test/test_data/getstats.sh
new file mode 100644
index 0000000..8f6d73b
--- /dev/null
+++ b/engines/2way/test/test_data/getstats.sh
@@ -0,0 +1,81 @@
+echo "interval,avg,max,time"
+if [[ "$2" == "" ]]; then 
+  rm -f filein.log filein_sort.log
+  egrep "PVMFSocketNode::PortActivity:.*type=5" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > filein.log ; cat filein.log | sort -n > filein_sort.log
+fi
+echo "file in,"
+perl gt.pl filein_sort.log
+
+if [[ "$2" == "" ]]; then 
+rm -f sockin.log sockin_sort.log
+grep "PVMFSocketNode::ProcessIncomingMsg: aP" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > sockin.log ; cat sockin.log | sort -n > sockin_sort.log
+fi
+echo "socket in,"
+perl gt.pl sockin.log
+
+if [[ "$2" == "" ]]; then 
+rm -f socksend.log socksend_sort.log
+grep "PVMFSocketNode::HandleSocketEvent() In aId=1, aFxn=1" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > socksend.log ; cat socksend.log | sort -n | uniq > socksend_sort.log
+fi
+echo "socket send,"
+perl gt.pl socksend_sort.log
+
+if [[ "$2" == "" ]]; then 
+rm -f sockrecv.log sockrecv_sort.log
+grep "45 bytes" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > sockrecv.log ; cat sockrecv.log | sort -n | uniq > sockrecv_sort.log
+fi
+echo "socket recv,"
+perl gt.pl sockrecv.log
+
+if [[ "$2" == "" ]]; then 
+rm -f sockout.log sockout_sort.log
+grep "PVMFSocketNode::ProcessOutgoingMsg: aP" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > sockout.log ; cat sockout.log | sort -n > sockout_sort.log
+fi
+echo "socket out,"
+perl gt.pl sockout.log
+
+if [[ "$2" == "" ]]; then 
+rm -f jbin.log jbin_sort.log
+grep "PVMFJitterBufferNode::ProcessIncomingMsg: aP" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > jbin.log ; cat jbin.log | sort -n > jbin_sort.log
+fi
+echo "jb in,"
+perl gt.pl jbin.log
+
+if [[ "$2" == "" ]]; then 
+rm -f ap.log  ap_sort.log
+grep "PVMFJitterBufferImpl::addPacket: M" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > ap.log ; cat ap.log | sort -n > ap_sort.log
+fi
+echo "add packet,"
+perl gt.pl ap.log
+
+if [[ "$2" == "" ]]; then 
+rm -f jbout.log jbout_sort.log
+grep "PVMFJitterBufferNode::ProcessOutgoingMsg: aP" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > jbout.log ; cat jbout.log | sort -n > jbout_sort.log
+fi
+echo "jb out,"
+perl gt.pl jbout.log
+
+if [[ "$2" == "" ]]; then 
+rm -f mlin.log mlin_sort.log
+grep "PVMFMediaLayerNode::ProcessIncomingMsg: aP" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > mlin.log ; cat mlin.log | sort -n > mlin_sort.log
+fi
+echo "ml in,"
+perl gt.pl mlin.log
+
+if [[ "$2" == "" ]]; then 
+rm -f mlout.log mlout_sort.log
+grep "PVMFMediaLayerNode::ProcessOutgoingMsg: aP" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > mlout.log ; cat mlout.log | sort -n > mlout_sort.log
+fi
+echo "ml out,"
+perl gt.pl mlout.log
+
+if [[ "$2" == "" ]]; then 
+rm -f fileout.log fileout_sort.log
+egrep "PVMFFileOutputNode::PortActivity:.*type=5" $1 | sed -e "s/.*:Time=//" | sed -e "s/:.*//" > fileout.log ; cat fileout.log | sort -n > fileout_sort.log
+fi
+echo "file out,"
+perl gt.pl fileout.log
+
+
+
+
diff --git a/engines/2way/test/test_data/gt.pl b/engines/2way/test/test_data/gt.pl
new file mode 100644
index 0000000..f8e7ff6
--- /dev/null
+++ b/engines/2way/test/test_data/gt.pl
@@ -0,0 +1,26 @@
+open (INPUT, $ARGV[0]);
+
+my $lasttime=0;
+my $numintervals=0;
+my $total_interval=0;
+my $max_interval=0;
+my $max_interval_timeval;
+
+while (<INPUT>) {
+  chomp;
+  my $timeval = $_;
+  if ($numintervals++ != 0) {
+    $total_interval += ($timeval-$lasttime);
+    if (($timeval-$lasttime) > $max_interval) {
+       $max_interval = $timeval-$lasttime;
+       $max_interval_timeval = $timeval; 
+    }
+  }
+  $lasttime = $timeval;
+}
+
+$avg = $total_interval/$numintervals;
+print "$avg,$max_interval,$max_interval_timeval\n";
+
+close INPUT;
+
diff --git a/engines/2way/test/test_data/h263video.h263 b/engines/2way/test/test_data/h263video.h263
new file mode 100644
index 0000000..214d750
--- /dev/null
+++ b/engines/2way/test/test_data/h263video.h263
Binary files differ
diff --git a/engines/2way/test/test_data/m4vvideo.m4v b/engines/2way/test/test_data/m4vvideo.m4v
new file mode 100644
index 0000000..b8d5d96
--- /dev/null
+++ b/engines/2way/test/test_data/m4vvideo.m4v
Binary files differ
diff --git a/engines/2way/test/test_data/pcm16testinput.pcm b/engines/2way/test/test_data/pcm16testinput.pcm
new file mode 100644
index 0000000..146c6bf
--- /dev/null
+++ b/engines/2way/test/test_data/pcm16testinput.pcm
Binary files differ
diff --git a/engines/2way/test/test_data/profiles.dat b/engines/2way/test/test_data/profiles.dat
new file mode 100644
index 0000000..9975aca
--- /dev/null
+++ b/engines/2way/test/test_data/profiles.dat
Binary files differ
diff --git a/engines/2way/test/test_data/yuv420video.yuv b/engines/2way/test/test_data/yuv420video.yuv
new file mode 100644
index 0000000..2cab7be
--- /dev/null
+++ b/engines/2way/test/test_data/yuv420video.yuv
@@ -0,0 +1,2 @@
+‡‡}º¹ÄÃÄÃÃÄÅ’­Éº–¤—dµ€^ikQ~he‹©vOHGEC7:=CE>a»Â¾˜N>•Ÿ§pQLE?HHD=KLVAŠº·³vWIOh†zÊ­¹²Í̓yW0g›ŒŒž”ƒÏ×ÓØ×ÙØÚÛÝÞÞÝÜÝÝÞßßßÝ¿–’àÕ×ÙÛÜÛÝÜÝÝÝßÝßßßÞÞÞÞÞÞÝßÝÝÜÜÞÞßÞÞÝÜÝÞßÞÞÞßÞÞßßßßßßßßz{\>†ÁºÀÇÄÈÇÇÆÉÈ«Ò¿ ŠAŒ‡nc{Wz`¡¢eXKMDD4>CFK=n½ÄÀ±h-J¤§‹Se;9OQG>IGLC‹¾ÀƋmTWXŽi¥¤¢È¯Ò¾—l?2|‹„t¤°ªàÔÕ×ÚÙÛÜÝÝÝÜÜÜÝÝÞÞÞÝÜ®ÃÛØÚÛÜÝÞÞÝÝÞÞßàÞÞÝÞÞÞÞßÞÞÞßßßÞßßßàßßßßßààßßÞßßààßßÞßßߣf1~¿¶¹¼ÃÉÈÉÉÇÈÇŒ²Á›<-^£\ld^¦žbCNMJ?2AEFG=t·¸¼‚\RL¨Œ˜d[C3\VE8MOQS”ÁÄÍ¡—aQVku„“a¶·°Ëʜ‚M>Ž‘‰¤Ñ™™àʙrËÓÑÕÖØÙÚÚÛÛÜÜÜÝÜȒÌÝÕÙÚÛÜÝÜÝÜÝÝÞÞÞßßßßßÞÞßÞßßßàßàßßÞßÝÞÜÞßÞÞÞÞÞÞÞÞÞÞÞßÜ݊I&=Ž®µ¹¹¾¾ÅÆÈÃÂÉÈÉ´¢E(0:5‡’dm…ZƒcMLMJC2;BINBw½··Ž<@Dm³¦w]N?.JHFBRRaQ”ÃÀ¾Ã¦t@O_‚l€\©®·»ÍƕvVN’†›ÄŸªË…`~ÈÖÓÖÖÙÙÙÚÛÚÛÚÛÜ¿„©ÄÞØÙÞÜÞÝÞÝÞÝÞÝÞÞßÞÞÞÝßÞßÞÞÞÞÞÞßàÞßàÞÞÞßßÞßÞÞÞßÞÞÜÝÞßÝ`>+=†³¬­µ·ºÄÅÉÇÉÅÆÆʧ^‘…<&94_ }jmYONQKH:BCCE;tµ¹±¡_@[…–„^KC/MNB:PPTN¼º»­¾€VQVyvnJM„»ÀºÏƘpH;ƒ‘‰ Ó‘¬¶xšÎÚÖÙÙÚØÙÛÞÜÝÞÝÚ‘ƒÂãÕØÙÚÚÛÛÝÝÝÝÞÝàÞßßßßÜßÞÞÞÞÞßßßßÞßßÝÞÜÞÞÞÞÞÞÝÝÞÞÞÞÞÝÜg9-F‘££¨©«°ÁÂÅÅÇÃÄÅÆÅ´cn’O#34=’¡hv…dUEA@7CFCEA‡¾¿·§dQc«Æ“UbU2-KI@=HHJF•¿¶Ê¶|jY]bTKAN<€´º¹ÎÀZ;QŽ‘‰«¿‰¾±©àÔÖØØØÚÛÚˌ/s»­±ÞÔØÙ×ÙØÙÚÚÛÛÚÝÝÜÜÜÜÝÝÝÝÜÝÛÛÛÝÝÜÛÜÞÞÝÝÜÞÞÞßÝÞÝÜÜÝÝÝÜÜÜÛ=6+D~„Ž‘—›¡®²¸¾¾ÄÄÅÅÄÇÀ˜A„x9.34rŸ|e^V><8HDCEEˆ¼º·­nVg™dŠY4V49LP=;HMMH‘¾½Ã‹°au^HYVA14?†³«¼uV¬†_0?’Šz²¸€ºÐÏÔ×Ù×Ó¥8(EL]bš¢ÏÓ×××××ØØÛÚÜÛÛÛÚÝÜÜÛÛÛÜÝÜÝÛÞÞÝÝÜÜÜÛÝÜÜÝÜÝÜÜÜÛÞÞÞÝÝÜÜÚÛÚÚB1 Nqj{y~‚‰—ž¦®¯´¼»½ÆÆĨTy…0#+-QŸ†Vi`^;,;A?@>¼½¹©fZh¢}SIi?;>PJA=FING•¼¾Ñµ§f{b@TUE68.*kvvk|¹¨‚R2I˜…‡½¡†ÏÓÒÓÕÕÖ¸aPXWSV¢€ÅÔÐÒÖØÖØ×ÙÙÛÚÚÚÚÛÚÚÛÚÚÛÛÛÛÛÜÝÜÜÜÛÜÜÛÛÛÛÜÜÜÛÛÛÜÜÛÝÜÝÛÜÛÜÜK-'Soelrstwtz|ž£¢¢„°¿ÆƼsNW#$/5{–^ZgbG.765=‹»½À¤cTh“h…UFY1AIH=ALJKT¦Ãº·Ç—ZofIVRD<I?;…–yŸ‰ÊĸrE(O–†‹Ã¨¡×ªV+=HHKMJX¯™©ÛÏÒÓÕÕ××ÚÙÚÙÙÚÛÜÜÛÚÜÛÛÛÚÛÛÛÛÛÛÚÛÜÛÛÜÜÝÝÛÜÛÛÜÛÛÛÛÛÚÛÛÛÛÜJ7'Sljoosvvvvtt|ƒˆ“¥ŠªÂÁº›UX/ )+4iŽp`hZB*239…·ÁÀ§fRq®€cg?D=?GH<=KJIK¥Ã½~­dqqDOSI=KE<ˆ¥†‰©¾¹Ê£j;(lŒ„£ÄŽ¤µbAKHFGEDB=98J¢¯ÏÕÑÕÔÖ×Ö××ØÚÙÚÚÙÚÛÚÚÚÛÛÛÚÚÛÛÚÚÜÚÛÛÛÜÛÚÚÚÚÛÛÝÜÛÜÜÛÜÛÜÛÛB*%bpjnnonstutqqptv~½²•”¿Á¸Ày41-$&%6IGHbHD/(/U8F–‘d^r¬“xF:7<APF=@HIFM­Â´”‹¢‡¤tGUWNAMF>†¸¡{»º·ÄÉ¡fJ1|Žƒ¡¼¾ŸU)37/0/2234l¦ ¦·ÑÒÑÔÖÖ×ØØÙÙÙÚÙÛÙÚÚÛÛÜÜÜÜÛÛÛÜÛÜÛÛÛÜÛÛÚÚÚÙÙÛÚÛÜÜÛÚÚÚÛÜ?%,hklklljnottponmtbM”°ª›¦¤§°x)(5,&##'2*"# "NtclV«•ŒUK7DFOF=BIKIS«Á¦]z”JL6CCGHDF98s­jf”w¿¼Â•q=9}‹®­dƒ‹H.+*,/110N“±°­²®µÆ×ÔÔÖ×ØØÙÙÙÚÜÜÜÚÚÚÛÛÜÛÛÚÛÚÛÛÛÛÚÛÛÛÛÛÛÛÛÛÛÛÛÚÚÚÚÛÛÛ:&-kmkmlmkllnqoommjzG[¬°5©‹N:!*#! ""0e^qR_x¨”‘`ˆiGGGF=@KLGQª»—En~8WM<KC9959:q•qL‘ƒŽÇºÅ½œc<6šŒ¤˜‹ž/1A<610,/f—©¾¼¼º²®ÇÕÔÕ××ÙØÚÙÚÚÚÚÚÙÚÛÜÜÛÛÜÛÛÚÛÚÛÛÚÛÚÝÛÛÚÜÜÛÛÛÚÛÛÛÚÚ7$9rflkklkinlokkkmi›…R>‰›KhxŠvL:$!($   5wxamT~ª’k˜wDDFE6?GH?M«¾•N•€asa@LI7FHLH‹‹}_ft¶´¶ÅƌY1Q‰‹„¶Ž½}?(-3752ce‹™žÈÀ½½³­Æ×ÔÖÖØÙÙÙÙÚÙÙÚÚÚÛÙÚÚÛÛÚÙÛÛÚÜÛÛÛÛÚÛÚÜÝÜÜÛÚÛÚÜÚÚ3$DvhjklllkkkkkmmmjhfeoYFE<—s•dA6!#! "k‰hkej›q mJLIC8?GGBR´¾W¥ŒXk^CPL8FHH:¥sQFtw‘³°µÃ»ƒ_18“Š‡Â š½~9<II?C™‡d ~{˜³½µ¹«ÕÚÑÔÕØ×ØØÙØØÙÚÚÛÛÛÚÚÚÛÜÛÛÚÛÛÛÛÚÛÛÛÜÝÛÛÛÛÛÜÜÛÛ0#KoejjikkjkiijllmjjmmqeLGnuc}uG7" !!   JŒo_fan hHJJD9MNND`¶¸o«Ž|Ž`KWL>OOKF°mLG]‚x£ŽÃ®À·T6Y“~¡Á“±¼hP\[]a«”lyš]R{mšª›ÁØÑÓÕÕ××ØØÙÙÚÙÚÚÛÛÚÛÚÛÛÛÛÛÛÛÛÜÛÛÛÛÜÛÜÛÛÜÜÜÜÜÛ-%Vhekjkifgiijjklmig]P_f[3f_TpwUImc@-$ )-.rnJ^Mv™hFJJB>ILKB[¸º‚i©™N5BGVP?OMFE›¬}lEPxj‰f¸®ªÈ·z\9c™{¤Ã„£§_XWJD¢µ…W~’„wal‡u“µÒ×Ó×Õ×ÖØ×ÙØÙÙÙÚÛÛÛÚÙÚÛÛÛÛÛÛÜÜÛÜÛÜÝÜÛÛÝÜÜÜÜÛÛ(%\gbfijigeefgiiij\7!"35oYL4TnVEIW<1&  ".4$O_BMJ|_LLH<6MLM=c·µ€^¢{LA5:IJ?JMLL µœ€HKeysMƒª³ºÆ«}Z4qˆ¦µ€¼a[HG’¶zDUž©¾D4cŽ§ÉÛÔÖ×Ö××ÙÙÙÚÙÚÚÛÜÜÛÛÜÛÛÛÝÝÜÝÛÛÛÛÝÜÜÜÛÜÜÜÛÜÝÜ(%Zcceeeeedeadfgff^C &&"/^dN9.aeO8NA,&"! ##&\D#)"2WUo—ePKIC:KDH<Y¸ºƒR•[J::LH;MMJIœ¾¼£H?PlQBKaµ¾­œ§ŠV,s¹º‰½’J3:ˆ›–aO^—¨‘ERt™“ºØÔÕ×ÖØ×Ù×ÙÙÚÚÛÚÛÚÛÛÛÜÜÛÛÜÜÜÝÜÝÜÝÛÛÜÛÜÛÝÜÝÜÛ(/e]_acdcdcdddbeedz„G+1,%0eYHC#CcZB;4##"#%(3sm`.'!%.Kw˜]JJJ?7MLMAo¿ºyZ¯šC=@<SI?OJDP¤¹®™[DQXL6BAº ^˜¤tK&r‚„³¢Ân@@w¥lE?f¢šnDQa•¢×ÙÔÖ×××ØØØÙÙÙÚÙÚÚÛÛÛÛÛÜÛÜÜÜÝÝÛÛÛÛÛÜÜÜÝÜÜÜÛÜ%3lad``ccebbbbdbca”¤~gj\).5\VUU &RV?**#$#$$(XzwqAjeWernŠ™MDRJC:LLNHs¾¸=‡’cF:<PI<FGDI ¶ª±tQMYL5=9@lcŸ»¦sC6€„¿¤†JER™‹u99=5ˆ¢J<:ˆ•ÂÜÒÕÕÖ××ØØØÚÚÚÛÛÚÛÛÛÜÛÜÛÜÝÝÝÜÜÜÜÜÚÜÜÞÜÛÛÛÜÛ 9j`hfda`dddbbbbc^—§}z$+& 7aL_OF5-B3&" "%#'>Uqz@ShHU}uVKNMC5IIJC{¹¯vo¯JX3>RE>JIEH£À³ˆ]EWP>LD:‚~ˆ½®Å«~L>Š‡¨f7CC‰€@<i@I‹‘M@@‘‘ª×ÔÔÕÖ×××ØØÚÙÚÙÛÚÛÛÛÛÛÛÜÜÜÝÜÜÜÛÜÜÝÝÝÞÝÝÜÜÜÜ!@dageed[^abcb^`a^˜¬}‹|, 6, "EZFCUL,')$!#"$%3qPDV3!:gZDpZNLOH;5IFHE|¿±ny~WZ;4<KC9EC@N¡©Ž„gGSN@KHF‘š¸¶¶Ê¥pDS•…Ž]9D?‡ŠŒN]…H8\‘aJR‘™ÈÙÔÔÖÖ××ÙØÙÚÙÚÛÛÛÜÛÜÛÛÚÛÛÛÜÛÜÜÜÜÛÜÛÝÜÜÛÜÛÛ!E`]cdebddb`^`d__^£ —‘ŠA&CL!#&RLCRQ;31   "#0JotDE+&OsWkkQPC;4GFHE~½³o{RQ\9END8DCAN °›…šh@UQDOLA’œ•”¥½°Å£/?—ˆ;49~œlŠ],orsQ<5k‘­ÜÓÔÕ××××ÙÙÚÚÚÚÛÚÚÛÛÛÛÜÝÝÝÜÜÜÝÜÜÛÛÛÜÜÜÜÜÜÛ$L[Z[]`]`bcc^^`abaª¥™„¨—l9gf4&;]GQP?84%$%%)(H{T`nA0'#7u_NtUD77ECGHŠ»°gtHR\GHTC6GGET¥®Ÿ„;.14=>E><z“vœw¼°±Æ£h3S‘~o>5{‚aU;?Œk:s@0N”™ÑÔÑÕÖÖÖ×××ØÚÚÜÛÜÜÜÝÛÛÛÜÛÝÜÜÝÜÜÜÜÝÝÝÜÜÜÜÝÛ'LSZ\Z\X]_bbbb_]][‘ª“€£‡–iqsD:$JN:A963$#$%'&LumP\4.4 ! 1ZeYZPF0E>==¶ªg}‰UNgMITF@IKGT« }s]QJ88FGFŠ\tr™¶³¾Ê–i)M˜‚g%nz•gJF=r7IŠh3d‰“ÄÚÓÔÖ×××ÙÙÚÛÚÛÛÚÜÛÝÛÜÜÛÜÝÜÜÝÝÝÝÝÝÜÜÜÛÛÛÜÜ*\ZWWYZYZ\_abcb`^\GR€©ˆ‰}|u>I!5O??.97))%%%&S}qwmccG,5-! $BiNJ\C0'/1i·¬d†‹ch[IGL@>NNKZ«¢›£‹\DUEEYYO˜˜lXˆ|žª¼¸¸zI*Y‘zWp¬r>FN@m™j6U”G6d“¬ÞÔÓÖÖ×××ØÙÙÚÜÛÛÛÛÜÛÜÛÜÛÛÝÜÞÝÞÝÞÝÝÞÝÝÝÝÜÜ.]Za^VWYYWYZ`bcc`Wic:v¤ŠŽu‡‡9O5/NBS0:6((%'(([|mrkjhfM53#!IpKJ_L3.5k¡žmŽkt:EG?9OLEZ¦ ²¬udCXKHUSE”˜UJsv‡›»¬º611U7.&"*4^];OwF:2|b:B„’Ð×ÑÔÓ×ÕØØÙÚÚÛÛÜÞÜÜÜÛÜÜÝÞßßÞÞÞßÞÞÞÝÝÞÝÜÝÜ8cZ]]^ZUUUYY\[]][MiUnQ9Vƒ‘‹7R=&GED2>0&+&(&(_ƒoq_Omcbb9."" OH3BNA/f61‰‡o~9ELA7POJk¯£¦­¥_LWMR\]Mœ˜UQgNd´¿»²k4++.#)*8I‰cƒj2A:H”nHŠ‡ÐÖÑÔÕØØÙÚÚÙÙØÚÚÝÜÜÜÜÝÛÜÜÞÝÝÜßÝÝÞÜÝÛÝÛÞÝÞ:YW_]\]\[VYZ^_^ZX='nSz_M:Œ‚'=O#/@60<4+*))*.d~ruvtUIfd`E 5* "*+" #3<€s¤DFJ<:OKFb¯¨™“SJ;ZHIPQM”¤\W_tJP]ž¾“gv3'**),2(N‰z|p)ŒW%`‰Z—–³×ÐÒÒÖ×ØÙÙÚÛÛÚÛÝÞÝßÞÞÝÝÝÛÛÜÜÜßÞßÞÞÞÞÞÞÝÝC^UW\[\\\\ZV``caU4!;iOseD@&9^$'-@7072-%)**/luv5G~f<7@e9,!%#    56(,VŸ€FIL><GHJrµ¨©“^_=_KORRJ˜›k[O\JECq¯†—5+77Tn3q’ŠƒY“3@to“R”˜ÌÚÓÕÖ×ÖØØÚÚÛÚÝÝÞßÞÞÝÜÜÛÞÞÞßßßÝÞÜÞÝÞÝßÝÞF\X[]XZ[[\\\[\_]W5!!!!;VEhA<5j)*+@;0>2+&&&)/cv~xh7|g91DXK:"!  ! C?(*OsALM;8OHEd­¯—I;4ODERQI’œukGVD<C/[k”¬„*+<B>a‡`7`rZ3:_l,siˆ¤ÝÌÏÓÖ×ØØÙÚÛÛÛÛÚÚÚÛÜÜÞÛÞÝÞÝÝÜÛÝÜÝÝÜÝÛÝÝIXWYYZZWXZZ[\[XXP,'%-$DKHV0b6",98/10-)'&'2kosptlQ:>XxIVB;'!! HS,10IJK50LFCjªœš¢??0WDFKLL‘š{}MX@FZJ|™¤q:5CD?lœ]>‰‡YS=LlFZ–­‘¢ÐÒÑÖ×ÙÚÚÚÙÙÛÛÝÝÝÝÝÜÛÛÜÜÝÝÞÞÞÞÞÜÝÜÝÞÞÞÜOYRUWXXZXWW\\\YXI 5?VI3)KEEU-/ 5473('(%'&5ijlibfcX/#loTBWD6*!&0X742EI:4BC@l© ‡˜TD7PIGOHG•¡ƒ€<HEFU:‚¹–wd4>574c§¦byˆ}FPGVhT`•vŽ±×ÓÓÕÖ××ÙÚÛÛÙÛÚÚÚÜÜÞÝÞÝÜßÞßÞÜÜÛÜÛÝÝÞÞÛMSWXXVUUUXVUW[Z[I%JY7"#gOH'QI\>+B7>9)''#&&8j_geijkhALa6ˆpKWT1&!! (3,/! d]KPK;;EIIm¯¦«žB02TAFMLM“y~CSVMU9† tz]=49<;_¡£c‚G:<G†G?7l¤~ÙÖÒÔÕÕÕÖ×ÙÚÚÙÙÚÚÜÞÜÞÜÝÝÝÜÜÜÝÞÜÜÜÜÜÞÝÝMNVVWTRWUVVVXVVUG'Vc2)aIY% &K=\Q4560+*#%&=mgdga$")_hM0UoS?A/&%!$#<T#0!<g{AUV<6RNH|°¦y[YC>PEDKKH–aZDF.8<3X‰NZPE#)//7z£q{’¦q2@dfH•C%Š„‹ÌÚÓÑÔÕÖ×ØØÛÛÛÛÜÜÝÜÞÜÛÜÛÝÝÞÝÝÝÝÝÞÝÝÝÜÝcXSTRSSYZZVWVVVR85Ye+7oL>&"! .B8;54,%$$%#Idal`(#  %Z_L0!dR10!"$A‚sHTpA\XOAE5AMODm¹ ‡R)5>LCKRNO¡ž‡xAP9h]Oƒ£sQF-# &*DlWH„=&60h’jlz<xi¡†ÆÜÒÕÔ××××ØØÙÚÚÚÛÛÛÜÜÝÝÝÝÝÝÝÜÞÞßàÝÞÜÝÝ[S]aUSSUUWZVWUVSE:f\,$;hDoX(:240+'$%$"Fmd`„{Me,!#Y]XT0=/"  .EkT 2nMQrXK7;JK@r³¤}E,;HWHFQNP¢¨Š:PDQQFzœTXC%"/;^XiG 3>D9Š”nG2D•zÀ×ÔÒÕÖØ×Ø×ÙÙÚÚÜÛÜÛÝÜÝÞÜÜÛÜÝÝÞÝÝÝÝÝÝÞÜÜ7OUSX[VUUUWWYUTT>AaY%&:P4ob'"&-;13-($""#!Ml``Š—m…H'%(VQDT5$#"#%&JpFY2$&ZdUsZADONBs¼ Š[m4NWJGNJM¨µ|=ODPPIw›]`L3 #/>mfC2)14BbD…‚[F6‘½ÏÍÏÑÒÕÖ××ØØÙÚÚÚÜÛÜÛÝÝÛÛÚÜÜÜÝÜÜÜÛÛÜÜÝÝÞÜ<;9GXW[\XPTUUVWQCFfS&#7P6qY/'GG#*<02-)%%%%$Ke^]‹™tF3 &7YE]F81!!&?T‚^>*2nfb`=+41M¤}d„K2ECBQEG¤¯rb=FFSWK{›PJR:4;K9jrkB->Aj•e`wFK5}¼ÖÖÓÕÔÕÖØÙÚÙÙÚÛÛÝÜÜÜÛÜÛÜÛÜÜÜÜÜÝÝÜÝÞÞÝÝÝÜ;G=>8E]Y[[IKSSTPHLiQ!<==wW63RU$ 1<,2-+#%%&'W][Vœ’X*V6!#HRKG;3#%'_q?vSOa -|€XfG1'D¡–Šk“AIK:IHB>¢§bC9PFQPHrž_VS>3Me9kqs@5D@]š}„vCAM¢ÐÔÑÕÔÖÖØØ×ØÚÚÚÚÝÜÞÞÞÝÜÜÜÝÜÛÜÝÜÝÞÜÞÝÝÞÜÜ 4E@@?<U[RTQPPODOnN )NK8wLC=UI'&4;.8*()('&%Ra\YŽ›}¬zTk>$5Y6<43 $'(*\su~”©p…E%^}WvuAQ‡N<eˆQQK>FMJM¥­s85LCLLBq¦fSSC5Nf9lvma`\GQqEžRMQƒ{Å×ÐÓÓÖ××ØØØÙÙÛÛÝÝÜÛÜÝÝÜÜÛÝÝÞßÞÝÝÞßÞÝÜÝÜ    'EFAA<KURSOA@OhA$+V_H„NHA_J'.4.5*)'%$#(N][[‡ž~¬{zRF!%@G?49(%')a{jfÆµc(-$1.#!"_kdH@F=AMJG¡¨h5<NETTKgªyV[A2Lh4f{mH6?GNˆx‰37P„ˆÒÕÐÒÓÕÖ×××ØÛÚÛÛÛÜÛÛÜÜÜÛÝÝÝÝÞÝÜÝÝÞÝÜÜÜÜÛ!"!9B@A?GPMH@[pF",\QQ~KLF]J#-4.1,*&%%&)X_[\ZE}¡…}ƒ^F&6F884 ()*,]up—g“êb0&!!#)7ˆjr^>JCS]YV¨«hJ3LBMNEsšTDC95Ne=bxnG,4*W?'CDDx’–×ÒÐÑÕÖ××ÙØÚÚÛÙÚÚÛÛÛÜÛÛÛÛÜÝÞÞÞÞßßßÝÜÜÛÜÜ:$"!! !0;99::@E]d;,_FX~OSRjG)44,2)(%"$#+WWZ[Q\RIp|…JM6-D,=7*+,-2otkŸ¾Œ8ze:,$ !!""DŽk{vI<EOIN¢˜dJ;SFKK>u gFN00O_5_}q>.9/AP#387JE˜‰ÐÓÏÒÒÔÕ××ÙÙÚÚÛÚÜÛÜÜÛÝÜÝÛÞÝÝÜÜÜÜÛÝÝÝÞßÞÝF94)!(7B>@@<ba50[@cvGJO_@(1/./+(%#$",\YXH.RQ`SI[:K7)8/?6+...5nwmd~ŽfŸƒ‚9!   11#=Œy|t@ELKZ©GG8N@MM@ªkDQ76J]7^€tAcpDYS3==M‡Jv¤ÐÔÔÕÔÖÖØØÚÚÚÚÛÚÛÛÚÛÚÛÛÛÛÜÜÜÜÝÝÝÝÝÝÝÞÞÝÜLIFB7+&  #-9A<BA.%4]:mhOMT`4(2.)-)&#""".WVXI#6RakX0AG'5/;0+(''2fqx³“af»›¢–N"!"$TrL!9m|YBJNLT ;->KCII?}§o?N0-DW9^ƒsX™uFdj6>8HŠ~‡§ÑÒÒÔÕÖÖØÙÙÚÚÛÙÛÛÜÜÛÞÝÝÝÝÝÝÝÞÜÝÜÝÝÝÜÝÝÛÜIJKJHC=0'" ! &+761 :[<reTNW]1(/-,*(&$"#"7\QUD!!:S[YEF#)4.<-&&%'7mgw»°t¡‘¨¯š”G'%/zpzxAVXC>LNKZ©‰E3>HAJMB„£UGK0.CV;_‚{]¥‡M`nT]@H|l“»§¶ÏÓÔÕÖ×Ø×ÚÚÛÛÛÚÛÛÜÜÝÜÝÝÞÞÝÞÞÞÞÝÜÝÝÞÝÜÛNNONKJHE@7(" %'%?Z<e]YRba*)1'()'&%%$#;bVUC'  ),?F\I0(8/<.'('%:igng_h¨i‹­šW"&*5‹±u‹iZhS;DJG\©‘zx;I>HK?|ŸWBO1,BU9[ƒ}bšL?Yr?PCF…uf +K”¶ÕÒÑÒÓÕÖ×ØØÚÚÛÛÛÝÝÝÜÝÝÜÜÜÜÜÛÜÝÝÝÜÜÛÛ-=GPOMLJJH@;1&.O;%(EV@m\ZVf`#!).))('$$"!!?`UY@=<'NJ*%=PK@4.>/****<pi`;37b—‘‡TJ4%#&)*u¥o7_wb}U<<=N¡‘|{9H6<C=tœQ5L4,<R:T{_‡J3No-55/a<199J~ÍÕÐÓÔÖÕ××ØØÚÙÛÚÜÜÜÛÜÜÛÛÜÛÛÛÛÜÜÝÝÝÞÝJ7+2GPMOMLMLGB:NX_G$DU=o_[UhY$).*+)&&$#"!=^SRBKN!%MJ0'8?I98+'&&'9nhf€B4+a €`-*0&/50¤Œu6}ome:*/€’~~6GAIMFy Z8I;5998T}zU‰M9Kl<m,T87(cSr‹žÔÐÓÓÖÕ×Ö×ØÚÙÚÚÛÚÛÜÜÝÜÜÜÜÜÝÜÝÝÜÜÝÜÛPPM>305CKLNOONGFKP?+%9FKb\YUfR%*-()(&$"!""A]TTD\J 'XG0$732'%%&'ApbcˆDB(1s†i?3&"'(6‰ ”„}0qˆsvS8‘ž}k1D=MUM£Z:I64545Py}R„_=VlkŠ8La4A6‚€R|ÁÒÎÐÒÔÕÖÕ×ØÙÙÚÚÛÜÜÜÛÜÛÛÜÜÝÜÝÜÝÝÞÞÞÝKLMMNB6&->LPQO=!2CSSEC>@ZdYZkL&))'(%$!! !"GRRVIcE '^I+#+% $532(''&%Iqafœ`R2!<“v;5%%'+@™¨µ«rC<=!$"!JxKM@PPE~›X4D31346QwxQ…f?Vp…§MGsEY9…®¯¥Ò×ÐÔÔÖÖØØÙÙÚÛÛÚÚÚÛÜÝÜÛÛÜÜÜÜÜÝÞÝÝÜÝÝ1@JHIJKI?+*4AF: 4I\VOFAbPUpK!*-,&*$#"!"!"EVOMKbE",P@/0O?+614&%'(&Ht\g®‰aN-1o59,-3>Bœ±®½¤U  "#qxf`<MQIxP8D30024GqtO„lHVr…•<GtCT<…£¿£ÔÖÓÕÔ×ÖØÙÙÙÙÌÇÝÙÚÜÛÜÜÜÝÛÛÛÛÚÜÛÝÝÝÜ6##5EEEGGHA6*%, &@TWOKMUoB)-+&("#!!! #DPQNQmE -UB3:WB#.824"$"$$Kq_iµ´vV2%]g7>%289@»¢“‡x0" !"!Au€tlJJBvR2B30.48OtyLqtCKryw6Dt<7.N•³ˆ¸ÕÐÕÔÖÕÖÖ×»_Cc¼ÓÒÐÖÖ×ØØØØØÙÛÛÛÜÛÛO*(+ )6AADEGD:-1- :QRCBQ3$+)$(&#!!! $NONIQj?",KC@DR?!,90;#"  "KoYh¶®Ž;&DH6@4055Cž²™ž{§‘G!)Z0g†lKL=p¢d>D20.5;PwpPzpDNsw‚5B|909P\x £¤ÝÖÕÕÖ×××̔V`PÍ×ÒÓÖÖÙØØØÙÚÚÛÚÛÚÛJ&=NH8)"+:ABBBAMKG7+"%9><?8,+)''&#"  'TQRIZn;/P:<H_@!-425%#"  Ji[XoˆrL9793<0-13@™·ˆU²Ÿ–:#!Hlqp<RBBG9v¢l>B1+,9@NwtHoo;Bss„BO}D9BocDUˆˆ²¸ÐÕÕÖÖÖÖ­dZbg«ÒÚÓÖ×Ø×ØØØÙÚÚÚÚÛÛÛD*EMOPOB0""/:=ARJNMOA2$+6642,&' !  'QNQE\n42P7=Nf;!-2+2#$###Xo\T_h|f\?B948./22H¡³¡ž‘Í«y3(&\žxˆzf^?@:s§i@G7/-46GrnNp}FDpp‹8HyUcBˆ›v@‡Œ›«¬®ÙÔÓÖÔ·sHWb|ÇØÑÓÕ××ØØÙÚÜÛÛÚÛÚÛ ">JNPPPNB,$#7RMQMOOJI9."1:;62'!"  )TPMBdl73K7@Rf:,1/0#('%#\tbB%D\`]M;4/5,,-/Bž¬YMš|ZoS#$'8‰n=‹Œ{r3"CoBF//,38JxuRud8Eqg‰@MzZ…CŠ™´C€›²¨£¾ßÖÖ×¹~Fnc“»ÜÕÔÖØÙÙÚÚÛÜÜÛÙÛÛÛ4'!*6FNLN<'AC9-,:JOQQOPNHB/"!09=9%  ! :HNIcj80F<AVj;+1++#&%$#Wha@%9H^\WD48*),-@—¤Y+_›‚J)/(10M¡–i"K‰`vGMšƒE5-&&26Dyp\xX.=l^„6<nU}1©ÃÃy<y†©‘¼ØÐÕÓŀM l¤ÑÖÔÔÖÕ×ÖÙÚÚÛÚÛÚÛÜÜJD0-)(;C71IEEMB:-2<NSTQLLJF9*    !%(# ! 6SLEgn+:GAE_e3 ),).%%#""Zg\;8G#?MSC05*+,-@urH1.x‡T/%*..b¦–S(2<21!%`l7"$+.Bw{RuZ.Asbˆ9CjR7{°É³w7Ž‘§žµˆ[TBZU˜dŽrrÏÐÏÓÔÕÖ××ÙØÙÛÛÜEA'6A;4'##/GBBNMPO?0,7HRQQPMFC9)(?KHF" =I?B_b1'*(($$$"'Z^X8BQ# /422(/.,I{WQO!K”`9+-52i²±F!#+<~|l2**1p‰Mq_7@qbˆ8?lS~0~·{¦cR—´¡ˆY\VbYœm„›g´ÐÎÑÒÕÔÖØÙØÙÚÚÜ?H;AJJHFA4'!(3=KMMPPN:((7FKLJG?7+  #;HK&FC>Add'')'&$"  $X\T7LV$ .10%'*+IwvvM47S@50<7q¶Ÿ†p*!%$FŠ€q?-41fŒZ`r1Aqj6BnZ€8ƒ‰Dt«À¨THŸ¤³˜|OT[McSxrŸ{šÙÑÒÒÕÖØ×ÙÙÚÚÚÛ-1EOOHDECC=7YVG9TOPRRQ1#'8HMHB5/&" !:%C9=:bb# )&'&!#" "\^T1PR-C'%-01('(*Hcgc7*j:774;5q«‰bªj(!!@j+<„K7CA9z“]is;:vi†49r]{2r‡9Q²¾»•OqœŸŒLCE8WY‰g£†ŠÛÔÒÒÕÕÙÙÛÚÚÛÙÜ!'+-2=KQLJGE3LVTT9#:RONLIA.',9A:1'&#   >I1 3G+"9D@<eT &,''"""%$'ZUP0!J?9P*'-+('&&E_]­Ž?&8#.-691kªPT³™u.0`~†ˆi*AB7jµ}‚=5ye‰7?s\j6o†J7ƒ¹¾È®Dv¡°­’<5B=IODZ£‡ÏØÓÕÔ××ØÙÙÚÚÛÜ ! $/07@OPL5JTQVWUN)"AFHKGF>+(**('#"!!"#$GWOH/D\QQG<9<eZ$$((*'!##!$^aS0IIB^4))(')()Ld[­‘O080//171l³{‹¿“9<9jŒn²mf?*)Kžš|ŽH8qb‰87q]n9i‘YB^yy™l©Gt£°¥„QbaQ{\‚”›ÅÖÑÔ××Ø×ÚÚÙÛÚÜ "!%#'-25;NRRLSRPTSWQ0+AECFB?5(%%%! !!"$MZUO4 (FRKC;aX"()($$$$$#XTO/PFLZ<"+-'&'')EhY„šrC<1837=5e«o‡§e.+/-EœcqdV5;M¤§••C nh–25_`_:i–R4\}J¢Ê•G§ ¬‰‚]cSvd—½ÔÓÓÖÖ×ÖØÙÚÜÜÜ  !"! !"#,57;PZSJMIMPRRG"&A??>94*%>TO7!;CFD3!'%)%$"! )YUK+#[ENU0%+-)&&%%WtLKezoN&3-;<4l¨fR“d9(.0W¤v?$#!  !mvk:2hiŒC+m[e8j“OJk{7w«ÈƟU­® DXRo€gdÈÔÒÏÕÖØÚÙÙÚÚÛÚ! " " !##/57<NZPJKMMOOK7#(<61.&"! !%G;(2@<3    (=990-%&   !!)]WI$"YKZL)&+-'&$##OnX Ej}<41.0,]œ]%|‡M,2>3g•V!%|~iY R’A?e^n0_ŽUPkqDFgª½Çveœ³»hVR~nƒ{t¥ÏÖÒÔÕ××ØÙÙÚÚÚ  ""!#$.9:=M[SJGLHIF@.!%%$" !  $M_XI/LGH8"!1357,!!!#!,[RF*%WHWK(%))($##!RdK7J&D<.*22.\€N;N}G5.>7dnr"!#%:l8…job­™Q5h\c>e[ShrDCZ]‹‰¨]N¯ eJJaj[t‚n´ÓÒÒÓÔÕÖÖ×ÙØÚ ! $$+69>KXXK@A@?8/#!!!   7TPPOSJNJH;)#&969*">LE%"NF]Q*$+*'$   Jfgvund$1/,00/\„aF'_961A6b”‰¶X&
+&&$WqY/|fsª¦U>ie_L[˜\FTw>4CmW”ǵsy©SIK^iTQ†dopZfhYgr}ÁØ×! #" (4:=Db_H870.&#!!!!*L:%=72?SROKGF:$!!+$1FC/LDZR.")+($!"!9]H!%'/.+,0,On‡f 3+83B.]šŽ±|-**)^­Žnb*muqŽD5RgPRQ•dFY{GPTv6?x¸®XZ¨]CTqXeu{ŸsŸ’”¯Œ¥¥–ÄÆÛ!"$##&)48;Naa@ "!!! 1LKKJWK0/ISMKIC;)"!$?A>DAXU&'(((!"!!&^?<FQ2*3/((+(Os‹R$./.(.'l£•x$!$)+JšÆ¿‹y6P‡fe.(d_KOq=MvLP]tAUƒ“ˆ¨Z~™GCvdcdr›s±ŽŽŸ‡”‹Œ’žÜ "#%##$6=AKZc>  2IIIGKLMK< %9HGBB<-:LFZJ#&(%"#"%'Ls9HI)!+0$$)(Ts~775/+/,l|eo-&,.-h®´°Î¡…_2Šyr`•W7Bk=IsJIcf5Sss­» ZQ0.(bSfwtu^oqkx~‘¤¿ß !!%$'(0<@F`hC7NGG:'3JKNQJ3"(:>9,&"!'+""6QB=ZI'#$$!"!#;B;=XY9+*('('XlKm{_64.2,]ƒLP5%$572d«°º¦Ñ°~?$ˆy}Ÿw9C“pCL{MQaj3DE{¢«^1347KŽŠª‡Ä¡“®Ÿ°Ÿ¶Ã×$"##%&.EDJijZMJKQJ67IKIH@,$.+*'!!!!!4IB.&NEFP="%('""#$GL<EXa1 ),"#%"Mk;%TW71.70_a*60$&765j®¹†¥µ¹Òr2M’ye17nd=N~BALl:K~;]– yC9JlZ¦{©}Á­–±Š™šŒ–™Ð!$$&$%-CGJ\f\LHLMF29A@BA;!  !8ZN6 BU=;)-'&#""#GT<=T[6 +($#"!OeT9#-103-Ym6;0$%77/^¨­¸h·¬Êµ†j/ƒrq:[‡FKxSHQv=BsJEreE>:f_?r‹nkVwgrrƒ•šÏ#%&&*+:GI_kaOKJHB4#4=;61'*C>(&9983""! !LQ:>Q^/)&""#"NaPM+)+,(Zk9+/)'51.WŒt•X/Vµ½Á‘k/k˜g‰¥tJ„CBOp;@rE7nOm@HHfXoHs˜§®„²–½™ª¿Õ##&'))8E>PneLHFC;,',+*%"  9ZD CH7&*=7'  B=BRa. %'" # RbJQ$+))*)Zƒg15+0)Kq`%=r`°ÈºÉ¤v@OŽu·yC„E=Nj9AkLFqJm`BEiTfg‚¬ž‰¯ŸŽ·ž˜Ä#%'((*/4HjjP8?7. 4]TPRQJF?-!%!:2>I`,"*%"!#"H^D`%*%$+%VlN0)%#)*'FylO(B'\xv¡Â¾ÀyL8ŒvwJ}E7Ci:AoJ?rCd[KG„{iXRieYrgezfu‡ƒ¸"#%$')>LMgnO)#%"  !8+).+MFMHG<.  (;[(()'#!! IXO\'()'+%QX1B%%+)&FzqJ<:Et¦u|¶Àšg1z|ksG=@nAHwR@nChsHKop\gfƒž»…¯ªŠÂ ›ÉÌ! "$*7AR]gO9"!%GTGE@+3BIHB3* #6^(#'#  !HWQ]&'&$&$Id- (%#/,'Hzpa78D…ŒI:m ²¹šzEw†rO<=oFAgO6nXcqGJnngŒh‡€˜Å‚«º‡Â«–ÃÄ "$()3>RYi\6"ESNLPNE8//:9/* !A7+?AD,'%   L^P`+%""$#D[.$$%*)&A|mY31!s¨‡<_`‹¼°¾®mJ^ƒ?77l=:[R;q\`p7>aitUon~gnh]vfe‚yš!"$(0;J^f]USK8,4BIMD5+-(#"  #KF2"2>A-$ ! !HYPc)"*$"#!H\7#! &&%@}ra&- [Ÿ|R~2j}w±¯²™>*K13l;8]U0w_\r?Ek}^i{‘y…˜’§«§’»¿ !!##-;JY^dYIG22;HII;("  0B<  /74&"  ?SL`((#!"!Ha<"#" '&&@ym^1*>ira,iyXEiqt'$**-a:7ZT1v]Oj:HmzZdzžx’®„š©‡¬©‹¸½ "%),;<z`HHA1(2:3!"@:3E;( $( $AIW$'#"#%J^;"&##=nfZ5-5nTF0F…‚@Vnua>8U7+SV?qYKd4?`{]nl«xswnyeppkzqƒ"$&%';XGEDFB3"!! AHKTPJ@-#3< "&%"#$GWA% =k`Q/(#8pM73HŽkLX1jZ!'32%LI.VS7h\Rh4;Zxlsk½µs‘wž~Ÿž‹©³!"-ABBD@:/&! %@333<FF@#!0<'&&#  $QZ;$ Bm`S,($@mV1(6nqX;!N^7H7:#$XY7eYJl<:Y†gq„¹Î¹ ‘”ˆ«¯Š«¾3VMPF?484+)#"!(XMOMC(.6+!!@A0=C7*$ !!FU=& !"=n`Q/("@pR0&(XS;$6ua+F&!*9T6k_IxD=R…Xw…Ž»Šuz}hwpwuk !'#"  6bV_=-"#&##" ,TG<8AIG:&  "@G /91  %7IB% =n[O(%";jO2'/[S4'V{_0\-D:7M(qaHr@<KPqy¨t¤ ox…z”y“›!"&%%4aedD/11(%""""*RKPNB28E<( !18AA&#!9B#"!  ;j`R$&3gO6--XX)!Ex]0Y0-<"#Vc;jC=K…>dp¸Á˜´œ·‚—µ…˜µ*I'   (*/-($+M_e@" !! ".ZKOMNOH5%$!EORQH6)*# 8oaS-*5fI6.*^_$$Gp[".R"-J#3Y_yGt;<EvE`c¯Èš…t‹r~†x‚n!')28544GE^A"!"#"! (WK:KIGEA0!875,;8(,11@/ 7f[O+)5iN4++YZ**LoZ&T+ 5W(GS4VtCCDzA_R¡Å«ztg€vw…}}Œ%:63623/EGUD& =1&"!!1YE&DNF9=*$"!"%QSTP2,&  @J#+*(EYQ')4`Q0)%NW--Hw`&O+.Q&#:2$HPTDEAuCZRy°–«†¬Œ²‰·'5899/8>L@!"@9 *!"!+SF'3J4)! ! #LM<:BH9 "6<.!"<>/2#4^R+*)VU+&7tb%I. /O*%MS-cE.4`ATK|`‘‹„‘‹Ÿµy~Š &# '0;L@ G4(!"! *Q@#:J5+# #NRPND7+6TKE, #!HR.)YQ*&*WX# 5sh/3A((J%'F<'G2-.+TDSJ‡ŽŽŠŒŒ‰¡ËŒs} $$#"!"!%3?9$K9)#" (MA"5D+  #HLMLHF5 4;.-(" *H$4 2<XP%#(L_!0YP2*B/(C,"9<1G3.?"#7G?‚‰„ˆŒŠ”­´º!#$$$$%27'$P-(#"  (S@!7E/)1!   $JECX;>3$ "BLDE&$#9/ZH: 0FE="IS+$-K\!B-)G%%@>5F4.@'.(2>v¥ ™ž’…|ª¬‚¡ !#%L+&  ,Q<#;J/29! $NB6K%"!"  !BN<4-"'H3EKD8D2 *EAGT(#1WQ B'*G*%><.=-/I)EL&-Bƒ¥©€‘‰z¢È†cg    1P( &#! (T;?H*5< #IBAU()" #?PLC'"@5=%"@P%+MK()3dW"!C*(E' >=.>2.I$,MZY.O“­‰—‘†¦Ö |Ã!"""""!!   #!!'D''' !'F7$@F,7D!$ <:=S#!!"5LGC("*B$2(I_QN(B?+X[$"<,#?.$8?#75-K',R@5V?_¯¶Œ—p{Â¬}½!!    !""!!! ! !10'! !!#+*%'E.-/"#! *B4%<C.9C$  ">;<M)7(# 4D<2-HI1# $#BG?JI.SS#90!&?+ 8C'96,L%+MB!I`”œŒ–Ë•ix–ik    ""##""! !! !!!"%)&  %98/.O0/,%"!)G5$>F*7># "B92B5F( !4=C3)V<-,%)(>?' 7eUG, %F1>+">1"6=&:7*F&A9 .@ŽŠŽ‹šºœ¥ƒŠp”"!!!!!!"#""!!   !""  !!""!  #5:-5Q%-)#"  *F09=&<@!!  (G37=?E$ ! 8@A/&HF8*III'##"5:5<(%D,%A0 6=(8AJM$G>.#:‰|†ŒŠŽ“¯·“~Ÿ!"!!! !"!"!""#"!!! !"#$""""!     ! #5=.3I ##!!  +@48;!B=" " %=:=E?F$" 4;99.$'=756"'C>/.#'*'@!"<==7 6,!0> .6';#&=A*1U‡†‹‹‰‘“ª±w"""!!"##"! !!!"!!#"#"!     " ! !!  !!%8G::Y %"   /H07;%@>" "938D?E' !3@?9/#$AB2EEE5.3EH;(-3"!%87&&#0>!)*#;#%:I2?QŠ|‚‰†‹Œ«Â¸`! ! !!"!"!""##  """##"###!!"""#"!! " !   "#""! "!!(=HVZUU#$""  2C1<A$>A!$;3;B@I%"6:=?1&E44 3@86&C@=.&'$*$%4? 0-.##7K3=[„„†‰‚Š‰Œ–ͽ…!      "!!!$""!"!!"! !#!"!!!  !  !   ! !!" !!%@B:FYE   2A, =?'??$<4:A=A& 0><>0 '36*84'$668 4(4%,= 5466-?"6##3P/ES‡~–‡ˆˆ‘ÁÁw""    !  !""""#  !""""#"#"  ! !!"!   !""# !!"#=F< %!  7D12:$</! #=1-6BH#8=9=901(68$3;37IB)1K%!*,!*."5.5-1R2>Fvp~œ‰€€ŒŒÀ½p""!   ! ""#!#!"!"!!"""!"!!    !     ! !!      !)EE?)+&$!!0>1/9PE-! !>50<=C#271:5"1/"-(*%%6%,;(/!84 00P18@}qk—Š„…¹¿…!!""""#'*-*(&$!! !!!!!!! ! "    +LNX1#?H>*-+( +=4!-6'-! 32+5@F"4738566+4?(:&2:&%808*!% (74;BhN~ƒƒ{‹‹°¼†CC;1')++/342.-)%"#!""##"! "    !    !       !&'$"!=B8#(''"+61334%!70/@CC145::$-,"06?*"21=': ++ (B>5):uŒz|…ˆ Äy9:987841+--/2342.(%$"$%&*++''%&#!    !  $-0.)"%%3LH>(!,222452-$# 4,0B?,.6+65!'4+%*!2!$%#%**&D%5$"KJ%!Mn<3ai“‚‚˜¹sKJE<:97,)----/68899;<>AIHG=/)'&%##!"'.5?930(*($    #+*(")BC&*5(#381)'%!1267'" 24/>2 -, (-4%"'%&"-#4 7,ENFI(R‹mp‰Áz.,+)*(+'(+,)/2766:974333586:::;=><443+/121.-))()&$"    #6:*06+(5;'#  0135)(!14*44-.:(2 %"#* "3-":H?J6DŒ†šƒ€¿{ID@6511++/121388988512/01646367667.+.0:CCB@7;;<<>A??5()&#  !!07'! -8!"-/!*)24/*"-20%"(*  !;!%!"!',# =:JN<9V‡–©—‘p!!""###$&(,//05>ACKNLJB?=;99575441-.-,065889988876644320+(#" &)#1+23& 013,/5,',22-$ )2+#%!$)9$&((7'$.?#7~rI‰ž£         """""#""""$(,+/0244478;=<6954788:::;987652224=70$   !($61,113 4,,/!(/-%)1?81'#%(#' &#("#"+'#%13wnD X‡œ      ! ! !!!!  ! !   !  !#%)+**(')+-.014<=<?@?BA?=4.$ !"#""#""!!#50()" ++'4*/1#()'+DQH.#,>C8" +%/#!!"##1'$%:1).;(, A#$$$#"#$$##"$$$$"!!         #)*+)&""!  !  $%''$#   "!%( !9.$ .*+!-(-.$')(%'*9H,"$1:7&7W=%)"%!  +&%'I 7ZF0;%*         ! !!#$#$$$$$%$"##$$#$%%%$#"   #%%%!   #%&+.-# =/.-#1!%%((-%*'$(+,92##'&2N1$$%! ! ! *' $41wmmw|rR  !       !     !!!!!!"#$! !!"%#$"!"#$$"" !%#  #"!+)#%( ! &,,2 ""$&!+B9851,KLTSQOORX3"-$'&! # #',$$K')LQ`h|~~ !!        !"!!   $/7/& !"#!!,%"#$(#!!#'!)Y[E0+->-/&,!)/9&$ & "&  *3,+36#.91K^l  ':G>2  ! $ !"!! "#,J""&0\rD/$FQn/',2C>#%( "!GaN5/je`G8/F+41,      #*0953! '"  "$"(#.!%/]n>0&D&*&%@>7>Hq\,"! "# M{‘WCLZl;%6^Am         !##$"!!/54&$  #!! !")DI/("C($/338+( *A9  !"  !!!FiIPAdO"$/-2;I/*    !      !     !    "! (,+!! !&"KXF:CX)2_]`]V6!50 !/O',&32)5<@:F."%  !            $&)*!! !""!  !"#1YK8#$drR<0$2+ ) !#3  -,-*0[CU+ -     !!!!   !      !   !   G˜j  !  7#5TNZHT8!%314O,(!,B#$KX253Q6:4F[       !!#!!!!    "!!!   '*++       !  "!'#" "79P*)680436$!-7& +6*2//%3/1;-ONQQVe\SE_fC-0;5Mxr]   !     !   !  !    ""!    !( * 36,40!"$'%&" !#!!""#&!%('#%/U+#68DIKJ<SVWTSN_caY]bfkkcdnlkijjlhag`b`\ZSQUYWX   !        #*.!"*012500286;<=<*&'58=;<%+(3B?@>=>;C@@:<<<6642&($ $ (-9""H>CFIQX_^accdcc]\YXUUUWWXWPJJHHFDFLOMPWTZZYXW            !+/6#   "%(1@IIIGIKLQSTVVYY[\]^`E6^Y`c3@IDrX[[]]][YWY[ZZZXWVVSQKA80$$&.?SRZiolhfa^YKFJJDFBBBA?@@CJGOHPIHJJPKNOONPR^fb```  !    ! !       +:KQSU]_giookf^UNFKPPMPPPONQOPOPOPI@VSUX3FZ&ZZZ[\^\\[ZYZ[[[[ZYTOFCACIMPMJGB?@<?CBCICA;:99;CKCFMEOMFHEFDFEGCDFILNOSTVWZ`[X`    !!!!! !  ! !""$%(--/12337452*$  %7DEC@:/)&'&())*5EUYZ[Z[Z[YYVVTUTUVVVVVVYX`b__]ZRIECC@==>@?@:@B@AGE>A@@CF@FIKFEDSK@HCAMKBA??>@AA?@??@ABDEGIJKKMM_]OROQMMJ   !!""##$&),17=?ACECHHHIHHHFEDDEED9,%! ! *55654324535567:IZWZYYYUSUWZ\Z[ZZ[\\^\TGA1*%$%')8KYXXUDB/234547866668886444P\ECH=@=>==;:;998889;=>ABDFEFHFGFLNNLGEFFFECFJIHHHIHIJIJJJJIIIIJJJHHIFGBB=5332/00+&#! &==>8'!'196640-*($##$$0>LJLNSSKJ74&%##(/15?HGHHB=>>?>:9<<=64234577:>===<=?P[E;=55399<<==;:9986666::=??@>?BCGFEFbh>BCCBEEFHGHKKLIJLKKJFA??87200/1233210011211124330-%"" !%G\lyr7 !$&($" "  !!##%&&'.3=RMJEC;3.23132333323432221233231122112235801021335476776764488:78469=:>?>:979<?@A@??>=======BFCAABE/2332223423344343311222233433231/-)%"! ! $-NLJ8/ !!!"#$$!! !""  #)-*,1/./0///../,./11323344341200/0/1110321245696546767667:876569:9:999879::<=?Vd@@@?>=<;::<<>?A@@?<?BEFK33322223234544432110,,((&%%%!""#"  '6<9.)*"      !&--000//0/0112221000./.B[edK3/20001312221356543233455556676788799::;<>??>=>=>=>>>=<>=<9::;<>>?<:;<<@??<?34321,*)''&%$$"! !!!!!"""!! ! ! ""# %8<6>30("  ! !   #,-0100----.--/-,+++.././-//023312223232211112333344678:8798::;:855<:=;=<==>?>==>?;:9<=<:388:::;;<=<=L\N!"!! !   !! !!!! !!! "!!! !!!!#!!  ! !#*070)$%#   !!! "&*+*,,,,+*,,,-**,,..---/0111/112333321110001344475878867::;9;Mz’}W5=><>>?@?@==<=;<;;=<;;8;==>>>A>>NN9C?= ! !   !! !!  !   !    !$'),*)($ !!  %**********,+,-.//-,--0011000012222100122221222233556889::;;:97:689<=;:9;;<<<:<=ABB@@=;:97<78=ABC?BBB@@F     !!   !   !  !  "$')),)+**+*+*++,,.,....,--+,,,,+,0////021213001125888999:879:;:98:99885665668=9==:;739973/-CW?;;;9:99<VH;jhbYTQQSVVWX[`ehloqqqqlhca``bfilopmihknnh``^^_^^^dlu}€€€€‚‚~€€‚ƒ€€€€€€€€€€€‚€a[WOG@>?BFPX`a_\]aegihc]VV\adcdfgfb]^aegfaYRQRUTU]dq|€~~~€|xwz~‚€€‚‚€€€‚‚‚‚‚‚ed_TKB@AABITbihea_chkie`ZZ[^begjlic_]^`_][VSTUVXVTXcp{}€€}ywy~€‚€€‚€€€‚ƒ‚€€€€€‚‚jfbZQHCA@?CLZekib]\_dfb\WVXZ\_chifbbdgklifd`\ZYZZYZ_iu{}|zwyy|~€~~~~~€‚€~~nke\VQOMHGFGNYfjjeabgif_XTUZ]aeiifa\[\`cddeec`[XVWVW]fqutpoqsw{~€€€€€€€€€€€€€jgd^XUTSSPLJHMYenqolmnnkf`\\\bgigc_\\_``cdc_[UQORVYXVYdnsvrmecfny~}}~€€€€€ffc\XTTUTRRQRSVZeoy}~~|zqg_]agjjgc_[ZZ`eiie_YQJIJQUUUUXalssl`WPRZhtz~€€€€€€gca\YWUTUUVY\[ZZ\dqz~~{yrh`]_cggfeca_bdghea^ZRKHHLPTUUV\ekkga_ZVUZjw~~~}~~~~€€€€€€jhd]WVWXXY\^^\]]`fow|}|{xske`adeba`]]`bgihd`_][YXWVUTRUX\`cb_^ZZ]`gqz}~~~~~€€€€jfa[WWWX\cjqvtollkmqwzxvuwwsnhffecb`bddggeda`acfea`_^ZSRSYadc^ZY]`gmv{~~~~~~~€€~~~€€okf_[[\^^`elrutroqsvxwtqlhfdeefhgdb_\[\chhea__`egigd_XVY[_baba\Z\`irz}}}~€€€nje^\ZZZZ\`emsxxsssvzzwtqpolheccec`]\]_dfggd`]]_bb`[VTSSX]abghhgeehnw{~~~€€€€€€€~~ljf_\\\[Z[]`ekrvuspqtwtoiimppkgfge`\[^`cedb^[\_ddb^XPKKRX\adgd`\Y\`ekt|~~||}€jgd^]\[\\\_cdglqssssvwskdaflqqnkhfea_befec`^\\_bb_\XTPPQYchllgddglhgkqy{{||~~}}}€€€oje^]^_``bfediryyvrruvqja[\bjrvxwvvvtplkheb]Z[^aa__^[YXW\eorne__cfcdipy||||~€nhc`_^]`gmrpmlortuuvwupkdaachmt{~~}|zvrnkgb]ZZZ_`aaaabbadgjidaddihdchpy}~~~€~~~~~}}~ojea``adipxytpoprtuvxxskdacefinv|€{ytpljgda^]^`bdffgedcba`a`]]`cb_]_hsz|}~~~~~~mfb`_`acjntwtqpqqswxywqjdbcehjmrx}|zwqkhgec`^]_deb_^^_aabfhid\STZ`b`aenv{}}}~€}}}}}jgc___aeimrssvyzxwxxyxsmijopqnnquxuqjeccfedbabdgfc``bdccekpqkc__aehhjkquy|}~€€~~~~~~lfb`aabdilqstuxz{zxxxwpifhnrsnouyzumiijheeeccbdedbadeeddglpqolljheaaemuz}~}}}~€uqnhdbbdhlpsqqtuvxyyyvngbdjprppsvwtlggiggedb_^`egeddddddgklllkhf`\]cls{}~~}}~€€€€zywqmihhkmpqrqqtvxzz{yrib_aflqstuuqg_Z]eloqpnidcdddfjjihikljhfedb``dlsy{}~~}}~~pw|}{vrqppqqqrruuw{|zxslfehouvvvuurjc^`iqwzytjd`abdfihgghjijjkmlkkjnsv{}~~}}~~~~€~~~~~hjouy{yvsrqrqqruwx{|zvromnpruuvvutqkea`dhpttnjhfb_^beffdegihda`beggehnv{}}||}€€€€€€€kijmpvz~}zvrpqtwz||zwsrruxusrtvutqle^Z[`inng_]_abbcddecfmnh`[[_egffghpw{~€~~~kiihghjmpsspoqtx{|||yvqppsxxwtsuusojf`^ehnonha_]^afifeffjnpnkhghlonljimpv|€~~~~~~~ljhhiklloqronnquz{}}zwronpvxyxxxwusrrniefhjgb`chlnnmieabeimppmkgcdhiebcju~€~~~€~~~~~~~stroosux{zyuqpoqux{|zvplkkprssuwxxtolkjlmomf_\amuzvpgaadhlpqojea_adfe`^dly~}ywvy~€€€€~mnqqqqqqpqvxyyxxxz~|wqnoprtvvwyzxtnighknpojbZ[ahooib^`dhkmooke`abbaa^__bkrxuqopu|~}}||}rponnrurmjilrx{{zz{|{wroqttrrsw{zvrmjhhkmppkcYVZbjie_\]cgjmlga]\`feb\ZWUUZcmsrrrv}~~}}~stvuusqpnmjhgjrx||}}|{vsqqrtvxz|{ywtrqopqrrnhb`aglkhhjnrppqphb]_egea[XWUTW^fjmllpv{~~~~~xtpppqnljjjmnmmovz€}{zwvuuvy|~}yutuxyzywspnjgfhgdcipvwqjhiijknmiaZXXVSQQQX_fklmov|}}}}{{ytpnljihjkkloswz~~}{xutrqqtwz}|xvtsstxyxwsrppqple_bgjkgcdfhhggfb^]`b`^WSTVY^`_bhpx|}}|€}}{yuqlhfghikntx}}{wuuvvutvy{~}zupnnqvwurmgabhkkgbbdhifdehlppnifeekliea^YVZ]acdipxz|~~}~€€}{wtpliikptwy{{yvttvyz{yz{{wtpmlmqtxwspmlmnnjfehloqtvyxrlgfhjlkgca^]ZWSUZbfhjpu{~~€€ƒ€~|{xvsqruy~}ztnjijosxz{|{{xtqpsvy{zwtsvwurmiikmljimqrnga_abddbcdcd^Z[\_`acceggkq€€€€}{ywvwxz{xsnljjjlpvy||{yvtrrw{~}{yvtspklnomjknpnga`___aaabdeea\\\^acdhhhijo~€€€€€€€€€~|yxxvtpmkjkmnorv|~~{wvttwz{zxxwwxxtqnklmnoqrrkaVTUY\^adfhhifbcfhjkhffgikp€€~~~€~~~€€|xtqmliiiknrv{{xvtuvxz{{ywutx}}yurstrqnoqplc\VUUVY[]_bdedcacddb_addghl€€€€€€€€€€€€€~|zwtomlmptw{}{xutvyzzzyvtrty{yutuvvsmmrsqlgc^]YWUVY^dhhgfeeimqqlkghm~~~~~~‚€€€€€~~~~|zvsrqtz{yupmlmrw{}|zxwyyxurruxxvuvxwsnmje]YXXWY^cgklje^^cikkjkq€€€€€€€€€€€€€€€€}zxutsqolllnsvyyz{z{||yvssuwyxxyxvrnmljf_\[^chlgddb___bddgjjo€‚€€€€‚€~|zwromlijnsyzyyy{||yvtvwwvuxyywtrqpnjd^]cjlnlgda^\\[]cgkmm€€€€€€€€€€€€€€€€€~}{vqllquxxtqpsy|||{|}|zwx{{ywuuvusolklnrroifcdbcdcfhhjl€€€€‚‚€€€€€~yuoosvyxtonpvz{zyzzyyzz||zvsssttqpooqtvupjfedddbeggij€~~‚€€‚‚‚‚}}€€~|zwsrty||xsolmquyxxz{}}}}}{wutstutqqqstvxvqnkhedeeighko€‚‚€€€€€€€|yvsrru{}|zupmmquxvsruz~~}{yvttuutrrrqrsttvvrokighhhijl€€€€‚‚€€€€€€€€|yurrswz{ywwvwz|yvrqty|~~|xtrqppoooprtsqpqrspgbdfiik€€‚€€€€~~€€€€~}}|yvvxz{yvvx{}|zvrqrtvwwxz{yvvwvvuvvuusrqrvxwurlgeeeff~~~€€‚€€~€€€€€€€€€€~}|{|||zwvuvz{ywwwx{zvvvy}zussuussuwyyxvuuuutpje`begj€‚€€€€€‚€€€€€€€€€€€€€€€€~|{|}}}zzz|}}|zxz||zxwy{~}ywuuuuuuwyyyxvuuusojghhhhhƒ‚‚‚ƒ‚€€€€€€‚€€€€€€€€€~|{zzz{zyxxz~~{yyz{}|yy|~~{yxwvvtrrsux||yyxxvtrmhdbdj‚ƒƒ‚‚‚€‚€€€€€€€€}}}{zxxy{||zyyz}~~|zz{~~{{{|}yutttuw{|{{{zzzz|}zurnifddh‚‚‚ƒ„‚‚€‚‚‚ƒ‚‚‚‚‚‚€€€‚}|zsrwz||{zyy{}{{zyz{zxwy|}{ywuuvwy{}~}|{zzxunhedeh€€‚‚‚€‚ƒƒ‚ƒ‚‚‚‚ƒ‚‚ƒ~|{xw|}}|{zyy|||{xxz{zyxy{}||}}|{{{ywwy|}}|yxwtokgdbcf€€€€€€€‚‚‚‚‚‚‚‚‚‚‚‚‚„ƒƒƒ€€~|zyxy{|{ywwwy|~|{{{|}|{zz|}}||{z{{|{zzz}~~yungaaabc{~€€€€~~€€€€€‚ƒƒƒ‚‚‚€~}|{yyz}~|xvvy|}}|yy{~}}}~~{{{|}~~~~~}|}}}{xuvtpkji~~€€~}}}}|||}}~~~€€€~}}|{{}€}zzz{}}{zyyz{||{|~~|{{||||}}||}}zwttsqmhf~~€~}}~~}~}}~~}}}~~€€~}}}~€~~}}}}~~~}~~}||}~~~~~€~}}{yxwvsljg‚‚ƒ‚‚€~}}~€~~}}~~~€€€€€€€~}}}~€€€€€~}~€~}zzzz{{|}~}}}|}|yuqqp€€€€‚‚‚‚‚‚‚‚€€ƒ‚€€€€€~~}~€~~~~~€}{{{zvvwy{|~~}|}~}|zyvqmj‚‚‚€€‚‚‚‚ƒƒ‚€€~~€€€€€€€€~~€€~~|{{{{{zyz|}~~~~€}|{zyxupo€€‚€€€‚€€€€€‚‚~~€€~~€€}}|{{zzz{{yxx{}~{wqnooqqp‚‚‚‚€€€€€€€€€€€€€€€€€€~~€€€€€€€€€€€€€~}|yy{|}~~~~|yxvwxvu‚‚ƒ€€€€~zxx{‚‚€€€€€€€€€€€€€€€€€€~}zz{{{|~~~}}||zyyyxxvs€€€‚‚ƒ‚€€€€€€€€€€€€€ƒƒ‚€€~||{{zzzyz{|}||||}}}||}}||}||zwvutssrrrpnmllmllmmnn‚‚€€€€€€€€€€€€€€~}}}~~|{zxvrpoopqqsssqqqppppqrqrqrtuwwtrnmmmmnoopqqppqppoooopq„ƒ~~~}}}|{{zyz|~€€€€~{vsstvvtrqpponnmnnorsrrrrrrsrrstsstttussrqrttsstvvttsrqqqqppxxxvuttttuvutstuwy|~€|zz||zyz|||{yvuuuuuvuuuwxxwttwyxyzzyxx{{xwwyyvuvxzvttuwuqsvussssvvvuuuuvwxwwxxy{}€€}yxy{~~~€€€~|{{{{||{zz{{{{|{|{{{{{{{{|{{zyyxvuuuuvvvwxxvvvvutsyz|}€‚}}}}}€€€€€€~}}}}~~}|{{|}~~|{{{|||{zzyyxxzz{zxwwyyyyyyyywwwwu€€€€€€€€€}}}}€…’‹‚€~}}}|}~}~~}~}||~~}}}|z{{yyzyy{}zyzzwvwyy{|zxyywxx™›œ›™™™˜šœš–”‘’•–——–•”••––“‘“•–•“‘‘“•–˜˜™š™–’ŒŠ…‚‚€€ƒ‡‡…ƒ‚‚‚‚ƒƒƒ‚€€€€¡£¢¡ŸžŸ£¤Ÿ™˜˜˜˜™›œŸŸžž  ¡š™›ž˜–—˜œ››Ÿ Ÿš•Š†ƒ€€ƒ„†‰‰…‚€€€€€€€€€€€€€‚€€ ¥¦§¤ Ÿ¡žš˜˜˜™›œœžž £¥£ œ ¡˜””˜šœœœžžœ˜•’‹†~~„‰Š‡‚€€€€€€€€€€€€šž¢¦©©¦¢  Ÿž›—•••—™š›œžœœŸŸššœž žš•’“–˜˜˜•”–˜››™–’ˆƒ‚„…‡‡…‚€‚‚€€€€€€€€˜›¢¤¦¦¦¦¥£ ›˜–““•––——–—˜œš—––šŸž™”‘‘”˜™–““’–™š—”Ž‹‡…†Š‹‰‡„€€€€€€€˜›Ÿ ¢£¤££¥¥¤¡ œ—‘ŒŒŒ‹‹ŠŒ‘—˜—–—›žž™–““–™™˜”’““—˜›™–•’ŽŠˆ‰‹‰„€€€€€~~~ž ¡£¢¢¡¡££¤¤¢Ÿ™’Œ†ƒƒ„‡Œ””“•™Ÿ¡ ž›™–””••—˜š›ššš›š™˜—–”‘Ž’••’ˆƒ‚€~~~~~~™ž ¢££££££¡  ¢¡œ”Œ‡„„„‡Œ‘‘‘’–›žœ™˜––˜šœžžžžžŸžœ™˜—––—™™™ššš˜”Žˆƒ€~~~€€€€~~~~~~~~™œž ¢¡¡ Ÿœœ›œž Ÿš“‡…………‡ŠŒ‘–™žœ››š™š›œž  žœ˜–•——–––——–’‡‚€€€€€€€€€ššž ¡¡ ™“Ž•˜™™•‹Š‹Œ‹’–šžŸ›š™™›››š™˜–––––—š›–•““”“““”–—•Š„€~›œž ¢£¢¢¡ž˜’Ž”——–‘ŒŒŽ“•“‘‘—œ  Ÿžžžœœ››˜–•—˜˜˜˜›œœ›šš™˜—––˜—“‡‚€€€€€€€€€€€€€€€€™›žŸ¡¡¡ ž›—’Ž‘•–“‹‹Ž“•’‘‘•™œžžž›š™š››š™™™šš˜——›œ›˜–•••–••—˜–‘‹†‚€€€€€€€™œž Ÿž›™–’ŽŽ“•–“‘––““—™š›œœš™™šœš–•˜™™š™™™™™—–––—•”•••‘Œ†ƒ€€€€€€~~~~~~~™›žžžœš˜”‘ŽŽŽ’—œœ™“ŽŠŠŽ’”–—™šœžœšš››šš››š™˜—–’‘’•——–“‰„€€€€€€€€€€€€€€~™›ž ¡ ž›—••’‹ŠŒ’“™ ¢ œ—‹‰‰ŠŠ‹Ž’•˜š›š››œœššš™˜––”ŽŽ’˜œš”‘‹†~~€~~~~€™œžŸŸŸœ–“‘’’‘ŽŒŒ‘–™œœ›•Ž‡ƒ‚‚ƒ…Š•™œœœšššš™šš™˜˜———–••–™˜—“‡„€€€€€~~~~˜›žŸ¡ žœ—‘Œ‹““‘‘ŽŽ’—›ž˜”‡‚‚ƒ…‡Œ“˜›œœœ›ššš˜˜—˜˜˜˜˜˜———˜™—‘Šƒ€€€~~~~~€~—›žŸ Ÿš•‘‘’“’“””‘Ž’˜›œ›œ›š˜“Žˆˆˆ‹•™›œ››œœ›š™˜˜–•–——•”“’“–™š™—‘Šƒ€€€€€€€€€—œ  ŸŸ›–’Œ‹‘Ž“–•’‘‘“—˜•Œ‘––—›ž›šš›œœš˜˜—˜™™•‘Ž‹‹Œ‘—š™—’‡ƒ€€€€€€€€€€€€–™œž›™•’ŽŠ‡‡ˆ‹ŽŽ”˜—“Ž‘•–“ŽŒŒ“”“”–šš˜——šžž›™š››š—“’’’‘“””––“Š„€€€€€’—™›œ›™“ŽŽ‹Š‰ŠŽŽ”—–“’‘Ž‘•–“’Ž‘’“–™š™——™™šš™™™™™›œ›—”Žˆ‚€€€€€€€€€€Š‹Ž’–™™—”‘ŽŒŒŒŽŒŒ’——–Ž’™žš“ŽŠ‰ˆ‹‘•š›š™™œœœš˜˜•“““”–—–•“Žˆƒ€€”ŽŠ‰‹‘‘‹Š‹ŽŽ”˜™–‘Ž’“““•™œœ›–‘‹‡‡Š•™™››››œ›š˜——•’”•“Š…€€€€€œ™•ŽŠ‡‡‰‘’Œ‰‰‹ŽŒŒ’•••”’ŽŒŽ’—›ž›”‘•—˜™™™˜™™šš™–””“’’“”–—™–ˆ€€š™–‹‰‰ŠŽŽŒŠŠŠŠ‹ŠŠŽ’“ŽŽ‘•”‘Ž’–˜——––”””—™™™˜——–—˜š™—•”““‘’••’‹†‚€€€€€€~~šššš››˜•ŽŽŽ‹‹‹‹ŠŠŠ’•”’‘’‘’•—™š™—•”–˜™˜•”’’“–™››˜–“’‘‘“””“”””‘Œ‡ƒ€~~‚–™š˜——–•’‹‰‰‰‰ˆˆ‰‘“‘ŽŒŒ‘’’’’””••—˜˜•Ž‰ˆŒ•˜š˜—•’‘‘‘‘“‘‘“•”‰„~~}~~~~~€€”“•——–“‰ˆ‰Œ‹‰‡‡Œ’•’ŒŒŽŽŽ‘‘‘””–™œš”‰Œ–™šš™˜”‘ŽŽ‘‘‘’‘Œˆƒ€€€‚ƒ‚€~~——––•–––•“ŽŠˆˆ‹ŒŠˆˆ‰‘“’ŽŒ‹ŒŒŽ‘’’’’’’”–™™”‘’•˜˜–•••’Ž‘‘””•––“‘Œ†ƒ„†ˆ‡„€€€€••——•’‘“—™š•‹ˆˆ‰ŠŠˆˆŠ‘‘ŽŒ‹‹‹‹ŒŽ‘”–——”““•˜œž›—’’”™™—•““’‘‘’•—™™˜™šš™—’Š…†ˆŠ‰…‚€’”••–—˜˜™˜˜™™—“Œˆ††……‡‹ŽŒŒ‹ŒŒŒ‹‹Œ‘““““““’“–—˜—•““•–’Ž’’•——–”’‘”–—“‹ŠŠŠ†€€€€€Š‘’’’”—™˜——˜–”Ž‰…ƒƒƒ…‰ŒŽŒŠ‰ˆ‰Š‹Œ‹‹ŒŽ‘”•–––•––•‹Š‘““”””””“’‘‘’“–”‘ŽŒ‹Ž‰ƒ€€€‚†ˆ‹Ž‘”˜™™™™˜—”’Ž‹ˆ‡‡ŠŽŽŽŒ‹ŠŠ‹Ž‘’ŽŒŒ‹ŒŽ‘“”””•˜›™–••–•“’’•˜˜—••–•”””•””“’‘Ž‰…‚€€€‚‚„…†‰Š“–š™˜—–•‘ˆ‡ˆ‹ŽŒŒŒŒ‹ŠŠŠ‹‘ŒŒŽ‘•——•“’“”––•“’’‘ŽŽ’—˜—•””•—™™˜ššš™•‹ˆ…‚‚‚‚‚‚‚ƒ‡‹“––•”‰ˆˆŒ’‘Šˆ‰ŠŠ‹‹‹Ž‘‘ŽŒŠŠŠŒŽ‘”•”“”•–—–•”‘ŽŠ‰‰‹Ž’”””•––••’’“”•”‘‘Œˆƒ‚ƒ‚‚ƒƒ‚ƒƒ…†‰‘“‘ˆ‡‰“—š›˜“ŠˆˆˆŠŠŽŒ‰‰‰ŠŒŒ‹‹‹“”••••—–”’’’“‘Ž‘’““•––——šœ›–‘Œ‰‡†††…‚‚ƒƒƒ‚‚‚ƒ…†‰‹Œ‹‰ˆ‰”–™šš˜•Ž‰…„…†‰‹Œ‰‰ˆˆˆˆˆˆ‰ŠŒ“•”””•”’‘‘“˜—–•““•––••–•™š—”Ž‹‰ˆ‡‡…‚‚‚‚‚‚‚‚ƒ……‡‰‰Œ•—˜——–•Œˆ…„…ˆ‰Š‰ˆˆˆ‰ŽŒŒ‘“•“‘’”•˜šœœ™—•–––––—˜˜”’Ž‹‹‹‰†€‚‚ƒƒ„„ƒ‚ƒ‚‚‚ƒƒƒƒ…†ˆ‹’”–˜—–’Žˆ‡ˆ‰ŠŠ‰ˆˆˆ‰ŠŒŒŠŠ‹Ž‘‘‘‘’“’’”•™šš™˜—–——™˜—–”“’“”•”Œ‹ˆ€€€‚‚ƒ„†ˆ‘“““Œ‰ˆ‰‹‘Šˆ‡‡ˆŠŽ‹ŠŠŒŽŽŽ‘”–––––™™—“’’“••””•“Ž‹‰‰‹‰†‚‚‚‚ƒ‚‚‚ƒƒ‚‚‚ƒ‚‚‚„…‡‰Œ‰ˆ‰’”•’Ž‰…„„†ˆ‡ˆˆŠ‹ŒŒŽŽŽ‘“”’’“”““–™™™–––•”““’‹Š‰‚‚‚‚‚‚‚‚€€€€€‚‚‚‚ƒ…†ˆ‰Š‘•—–“Œˆ‡ˆˆ‰‰‰Š‹Ž‹ŠŠŒŒ‹Œ’’Ž’™›œœœ›™˜—˜™—–“‘Ž‹Š‰…€€‚‚‚‚‚‚‚‚‚‚‚‚‚‚€€€‚‚‚‚‚ƒ„ˆ‹”•”‹‡‡ŠŒŠ‰ˆˆˆ‰‰ˆˆˆŠ‹ŠŠ‹ŠŠŽ”•“‘‘•˜™˜—˜—•‘Ž‹Š‰ˆ…€‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚ƒ„Š’”’‰‰Ž’“‘‹†„„†ˆ‰ŠŠ‹Š‡‡‰ŒŽŽ‘”“’‘’–—˜˜•“’“Œ‹‰ˆ€€€€‚‚‚‚‚€€€€‚‚ƒ‚‚‚‚ƒƒ‡‘’ŒŠŠ””’‰ˆˆŠŒŒ‹Šˆ‰‰‰ŠŒŽŽ‘’““Ž‹‹‹Ž‘”“‘ŽŠ††‡ˆ…‚ƒƒƒ‚‚‚‚ƒƒƒ‚‚‚ƒ‚‚‚‚‚„ƒ‚‚‚ƒƒƒ‚‚‚ƒ„„†‰‹ŽŠ‡‡‹”–”‘Œ‹‹‹‹‰………………ˆ‹Ž‘‘‘‘’“”“‘ŒŒ‹Š†€€€€‚€€€€€ƒƒƒƒƒƒƒƒƒƒƒƒ„…‡ŠŒŒŠˆ‡‡Š“•”‘‹Œ‘Œˆ‡‡‡‡‡ˆ‹Ž‘ŽŠˆˆŠŽŽŒ‹‹Œ‹Š€‚‚‚€€€€‚‚‚‚‚‚‚‚„………‡‰Š‰‡‡ˆ‹Ž‘Ž‹ŠŠŽ“”‘ŒŠŠ‹ˆ†…†‰ŒŒŒŒŒŒŠ‰‰‰‰‰‰‰ŠŠ‹ˆ‡‡‡‡€€€‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„„„†‡ˆˆˆ‰‰ŒŒ‰‡‡‰Ž’”‘ŒŒŽ‹‡†‡ŠŒŽŒ‹‹‹ŒŒ‹‰‰‰ˆˆ‡ˆ‡‡‡‡€‚ƒƒƒ‚ƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„„„………†‡‹ŽŠ‰ŠŒ‰‰ŒŽ‹ˆ‡ˆŠŽŽŽŽŽŒ‹Š‹Œ‹Šˆ‡†€€‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚„„ƒ…†ˆ‰‹Œ‹ˆ‡‡‰ŒŠ‰‰ŒŠ‰ˆˆ‰‰Š‹ŽŽŒŒ‹‹‹‹‹Š‹Š‹Ž‹‰‡…€€€€€‚‚‚‚‚‚‚‚ƒ‚‚‚‚‚ƒƒƒ„„…†‡‰‰ŠŠŒŽŒˆˆ‰‹‹‰ˆˆ‰‰‡††ˆ‹Œ‹ŒŒ‹Šˆ†…†‰‰‰‰Š‹Œ‹‹‡€€€€€€€€€€€€€€€€‚‚‚‚‚‚‚‚‚‚„„„†ˆ‡‡‡‡‡Š‹‰ˆˆˆ‰‹‹ˆ‡‡‰‰‡……ˆŒŒ‹‰‡††††‡‡ˆŠ‹‹ŒŒŒˆ€€€€€€€€€€€€€€€‚‚‚‚‚‚‚‚ƒ…ˆŠŠ‡††‡ŠŒ‰†††‡ˆˆ‡‡‡‰Š‡‡‡‡ŠŠŠ‹Ž‹‰ˆ‡‡††‡‰‹‹ŒŒ‹‹‹Œ‹€€€€€€€€€€€€‚‚€€‚ƒ…ˆ‰ˆ†††‡ŠŒŠ‡„„…†ˆˆˆˆˆ‰‰…„„…‡‡‡‡ˆŠŒ‹‰‰ˆ‡††††ˆˆ‰ŠŠŒ‹Œ‹‡€€€€€€€€€‚‚€€€€‚‚„…‡‹Œ‹Šˆ‡ˆŠŒ‹ˆ……†ˆŠŠˆ‡‡‡ˆ…„„„†……„„…‡ˆ‰ˆ‡‡ˆ‡‡‡‡ˆ‹ŒŠŠ‰‰‡€€€€€€€€€€€€€€€€€‚…ˆŠŠ‡……‡ŠŠ‡††‰‹Šˆ‡‡‰Šˆ†…………„„…†††‡‡‡†††………†‡ŠŠŠŠ‹‹‰‚€€‚‚‚€€€€€€€€€ƒ…†…„ƒƒ„‰‹‹‰‡††ˆŠŠˆ‡ˆ‰ˆ…ƒƒ…††…„ƒƒƒƒ…†††‡‡‡ˆˆ‰ŒŽ‹‡‡ˆ‹Š€€‚‚ƒƒ‚‚‚ƒƒ‚‚‚‚‚ƒƒ„…†‡†…„…ˆŠ‰†„„†‡‰ˆ†……ˆ‰‡………‡†„ƒƒƒ„„„„„…†‡‡‡‡‡‰Šˆ††‡Œ€€€€€€€€‚‚‚‚‚‚‚‚‚‚‚„„…††„„„†ˆˆ††……‡ˆ‡………†‡†………‡‡ˆˆˆˆˆˆ‡‡†……††††††‡‡…„„„…€€€‚€€€€€€€€€€€€‚ƒƒ……………†…„ƒ‚ƒƒ…„„……†‡„„„…†‡ˆ‰‰Š‹‰†…„„ƒ‚‚‚ƒƒ……‡ˆˆˆŠ‹‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚€€€€€‚€€‚„……„„ƒƒƒƒƒƒ„„„…„„„……„„„„…„ƒƒ…ˆ‰ˆ†‡‰‰ˆ†…„„„„„…†……ˆŠŠŠŠŠŠ€€€€€€€‚‚‚‚‚‚€€€‚‚‚‚ƒƒƒ‚‚‚‚‚ƒ‚‚‚‚‚ƒƒ‚‚‚ƒ‚ƒ„……†…††‡‡‡ˆˆˆˆ‡…„„„„………‡‹ŒŒŒ‚€‚‚‚€€‚‚‚‚‚‚‚‚ƒƒƒƒƒƒƒƒ‚‚‚‚‚‚‚‚ƒ‚‚ƒ„„…„…†‡‡‡††…„ƒƒ‚‚‚ƒ…………†ˆˆ€€‚‚‚€€‚‚‚‚…ˆˆ†ƒƒƒƒ‚€€€‚‚‚‚‚‚‚‚ƒƒƒƒ‚‚‚ƒ„…‡ˆˆ…ƒ€€‚‚ƒƒ„ƒ‚‚‚…†‚‚€€€€€‚‚€€€€€€€‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒ„„……ƒƒƒƒƒƒƒ„„ƒƒƒ„„…‡†‡‡‡‡ˆ‰‰ŠŠ‰‰‰‰‰ˆˆˆˆ‚€€€€€€‚€€€‚‚ƒ‚‚‚‚‚ƒ…†‡ˆ‰‰‰‰ˆ‡†††††ˆ‰ŠŠŠŠŠ‹‰ˆ‡†††‡‰‰ŠŠ‰ŠŠŠ‹ŠŠŠ‰‰ˆˆˆˆ‰ŠŠŠŠ€€€‚‚‚ƒ„„……„„ƒ‚‚‚‚‚„‰Œ’‘ŽŠ‰‰‰‰ŠŠŠˆˆˆˆ‰Š‹‹‹‹‹‹‹Šˆˆ‰‰‰‰ŠŠŠŠ‰ˆ‡‡‡ˆ‰‰‰‰ˆˆˆˆˆ‰ˆ‰‰††‡‡‰Š‹‹‹ŒŽ‘‘Œ‡…„…††„„…‰Ž‹ˆˆ‡‡ˆ‰Š‰ŠŠŠ‰‰‰‰‰ˆˆˆŠˆ†††‡†††‡‡††‡‡‡‡‡‡†„…ˆˆ‡‡‡ˆ‡‡ˆŠˆ‡‡ˆ””–—˜™˜—–••“’ŽŒŠˆ…„ƒƒ…‡‡…ƒ‚‚‚ƒ……………††…………„„„†††…………………„……………††‡††‡‡‡‡ˆˆ‡‡‡‡‡‡‡‡‡Œ‹‰ˆ‡††…ƒ‚‚€€ƒ…„‚€€‚‚ƒ„„…………„„„„„„„………†‡††………………†††††‡††††‡‡††……††………†‡€‚‚‚€€€€€€€‚„„‚‚€€€€†‰…„†…„……„„……„„„……„„…„…†‡††††……††††‡††††……ˆ†††‡†††……†oˆoˆnµÈÇÄÅÅÄÆÆĐ­Í»•œœW©‰b`wY€ig‰­zULFDD8;>@C>^ºÃ¾švUF•˜£tPIEBHID=HGN?|»½¸tXDHe…nij¸²ÍȘwW+f™ŠŒ™‘|ÉÕÑÖ×ØØÙÚÙÛÛÛÛÛÜÜÝÜÝÛ¾ocÏÙ×ÙÚÜÛÛÛÜÛÛÛÝÝÞÞÞÜÝÝÝÝÝÞÜÝÝÝÞÜÞÝÜÞÜÜÞÞßÝÞÞÝÝÜÜÝÛÝÞÝÝ|‚f4~¾¸¹ÅÇÈÇÈÇÉÉ®ƒÊǧD‹—t]zWvh‰©uZMJBD4@ECI>Y³ÈÁ·z/=“¯†VaB?PUI=HHMEºÃ™sdURˆv—²Ç±ËÍ£oT9f’}|˜¹œÚÙÓ×ÖÙØÙÛÚÜÝÝßÞßÞÞÞÜÝ̖ŸÐãÚÚßÝÝÜÜÝÜÝÞÞßÞÞÞÞÞßÞßÝÞÞÞÞÞàßÞÞÜÝÜÜÞÝÞÞßßÞßÝßÝÞÝÞÜÝ£n-/‚¶³½¾ÁÉÈÈÈÆÇÇĈ¥Ê¨D&'M¤^sh^ i?PNIA7BEEH6g·¹¹PVZ£’fVL2WSG7LSSM}½ÇÏ¥–vRYj{v£h³º±ÒʙtI8~’€™Ï–™ØȦe¿ÖÓÙ×ÙØÚÚÛÛÝÜÞÞÛÖ µÝÚÜÜßÝßßßÞÞßÜÛÛÜÜÞÝßßßàÝÝÝÞÝÝÞÞàÞßÞÞÝÝßÞßÞÝÝÞÞÝÝÝÝÞÞފO9€¹¸»¾Á¿ÅÆÈÃÅÆÉɲ¨>,/:B”ei‚W}dLJLEB0<ABIDuµ´µ‹?>?x·žwVK6,HHGEMPWUÅ¹¾ÀŸkOT`|s|U¯°¶´ÎƛxSLˆ‘†ŸË™°Ð‰bƒÌÕÒÓÖØØØÙÙÚÚÚÛÛ½‡·ÂÔÚÚÜÛÜÛÜÛÛÛÜÝÝÝÞÝÜÞßÞàÞÞÞßÞÞÞÜÜÜÞÝÞÞÝÞÝÜÜÝÝÞÝÞÝÝÝÝÝÞ`>,=’­¨­¶¸½ÇÅÈÃÆÄÅÇÈ¢az8%73cœ|n{d[MJOFE9KGHH<o¾Â­ _Faˆ|šƒPK@,NJA9OOOM‘À·»°¾vKZSysmHL¾¾¸ÌƔoHC‚Ž‰¥Ì·½ˆšÖÙÓ××ÙÚÚÛÛÛÜÛÛÚƙ±ÈßÚÚÞÛÞÜÞÞÞÞÞÞÜÜÜÜÜÜÝÜÝÝÝÞÞÞÞÞÞßßàßÞÞÝßÞßÞÞÝÝÜÝÞÞÝÝÜÜk=/F¢ £¥®°¾ÁÅÁÆÆÆÅÄƺ^d™K/-3;£dmƒdSCA?8BEDGG„¾¼¹¨iKa£À–ScQ82IFB?GGNK»¶È¡¶sX[_XM@M;u²º¹ÑÀ•ZAO†¡·´¯ŸäÓÕ×Ø××ØØ͗9w¿¦y¹×ÑÔÔ××ÙÙÛÛÛÜÜÜÜÛÛÜÜÝÝÝÝÝÞÝÞÛÛÛÜÜÜÝÜÜÜÜÜÜÝÜÜÛÛÚÝÛÝÜÜÞÜ:9-F‚Ž”—Ÿ£²¯·¾½ÀÅÇÆÅÄ¿Lj+*14o¢u]„YU>93BBBFG•½¼·­f\l›_~Z8T;<OQ?=LLKE“½Àć£buXOZS:26A²¥ºm\ª}O9K—‰|´·ŒÇÔÐØÖØÖў9+GOX`›ÔÕÕÖÖ×ÖÙÙØÙÚÜÛÝÜÜÛÚÚÛÛÜÛÜÜÝÜÜÝÜÞÜÜÛÛÜÝÝÛÜÜÜÝÞÝÝÜÜÜÝÝÝÛÛÛ@2)Hrmwy|€„Š–¡¦¬°³¸¹ºÆÇÆ«^|†:"',E“ˆXc_\B/@BCC9Œ¸¿¸§j\c›‚ZGi=?;JK>9EHJB’»ӱ¤w|dASY@-91"as€ht¶¯…M&F‚‡·­‚ÐÐÕÖ×ÖÔÀiLWVSO•‡ÀÜÔÔÔÖÖ××ØÙÚÛÛÚÚÛÚÛÚÛÛÛÜÜÜÜÝÝÝÝÞÞÝÜÚÛÛÛÚÛÛÜÛÝÛÛÛÛÜÛÚÚÛÛÚL-%Ttilsutuuw|‹‘›¢ £‰¹¼ÄÄ»tPŠ`  ,/w‘a\ecE2833<†Äļ¡cWr˜n…U@_7@GH;?MJLO¡Ãº´ÇŸ[mdJPU?9H<6‚—|žË¾²oJ)D–‡†ÈŸ™Ð¤R)<ELLNKQ¢œ©ÝÓÓÕÖ×ØØ××ÙØÙÙÙÙÚÚÜÜÚÜÜÜÜÜÜÛÛÛÛÛÛÛÜÛÜÛÚÚÛÜÛÜÚÜÚÜÜÜÛÚÛÛÛF4%[jinmqtutrtuzƒ‰‘–©…±ÄÂÁµ”LT4 (*5lŒk]gVF+12?ºÆ¿¡cUv§xhg<A<?HJ<?IJIH«Å¶—z®_th>RQC>LD8†¨‡‡¬»³Èn;&p}¨ÈŠ£´a?KFFIFE@977R¢¯ÐÖÑÔÔÕÖ××ØØØÙÙÙÙÚÚÚÚÚÚÛÛÛÛÚÚÚÚÚÚÛÛÛÛÛÛÛÛÚÛÜÛÛÚÛÛÛÜÛÛÛÛC+*aqjlkmnwvsqqpqvy|¼´—•½¾º¼x3!2,%%#:LHE]JD3'3X7G”‘f_p¬‘wG:8?AOI=?HJGH¢Áµ’‰¥ˆ§tDUXNCKGAŠ¹ x¼¹»ÂÊ¢kQ4u€œ¸¸¡Z/,31214012i¦ ¥µÐÓÓÔÖÖ×××ØÙÚÙÙÙÚÚÚÚÚÛÚÛÚÛÛÛÚÚÚÙÚÙÚÚÚÚÙÛÛÛÜÝÛÛÚÛÛÛÛÛÛ@&)ekjkklkmorsmmllqcH±¬›Ÿ¥¨°z,*4-'#$&5. # JxbqYz¬“ŠSM7@DPG<>FJIP°¿¤ap•MJ4DACDBF85l«gi”wÁ´ÀÀ’n>4Š¬°`u[',+-1122F†²¶°²°·Ç×ÓÕÖÖ×ØØÙÚÙÚÙÚÚÙÚÚÛÚÛÛÛÛÚÛÛÛÜÛÚÚÙÙÚÛÚÛÚÚÚÙÚÙÙÚÛÛÛ5"3millkjhlkppnnmni{{9Y®¯‚9­ˆI4!'%"!!!.abqR[|¬”b‰`DHHE>?ILGR®¼–Ar{4h=8L@88979q•iQ“€”ź¾¼–d86’‘©“’›-6?:800+2m™­¼¼»¶±®Ç××Ö×ØÙÙÙÚÚÚÛÙÚÚÚÙÙÙÚÚÚÚÛÚÛÚÛÛÛÛÛÛÚÙÚÚÚÚÚÚÚÚÜÛÜÛ5$>oekmkljhhkmlnlliš„O<Œ—Lvq‰oF<"#(#4sv^qV¦’j™tABDB7AGG>P³»’I†b|UFQE0GHJC‰~YjŽp»·¶ÆÀ…T:T†‹Š´‹Ãt;#,1323jc–•©ÇÀ¾¿¯¯Ê×ÕÖÖ×Ø×ØØÙÙÚÙÚÚÚÚÚÚÚÚÚÚÚÙÚÚÚÚÛÚÚÚÛÚÚÚÚÛÛÚÛÛÜÛ2%@tgkjjjjjjllnolkgcfdrYGG=ƒoŒ–c;1!##" $n‰fienžˆt eINJ@1?GG?X¯»Œd©‹VuRCQL8GGGA–£mPDvp¢¯°´Â¹ƒ^1B†ˆÀœ¦²w7AHF@J q¡y‚{ ±¿´¸¦ÙÚÑÕÓØ×Ø×ØØØÙÚÙÚÚÛÛÚÛÛÛÚÚÛÚÚÛÛÛÜÛÜÛÛÚÚÚÚÚÜÜÜÛ.#OjekkjjkkkkijkmmjjonndO%Ins{a{”wC2 #$!! K‡p`g]o¡iLMIB7JLLDY·»‚d¨}ŒaCTNBLJOG–³nNF[ƒx¤ƒÁ®Ä¹Q5X‹€™½•µÃdLZZZ]«”n{˜bO{o’¥¢ŠÀÛÑÒÔÔÖ×ØØØØØÚÙÛÛÛÚÛÛÛÛÛÛÛÛÚÛÛÛÛÚÛÚÛÛÛÛÛÚÛÛÜÛ.'NidkkljjiijjjjjkkkaV\c^1e`TlvWKie?7& &/0jrQ[QmœjKMJE<JIJ@Z·¼‰jª˜S5AFYQ?LKGC™¬}mIQzh‹f³±«Ã¸|W8`™{¥¿‰§¥aYXJF’²U}‹w_o‡s—³ÑØÓÖÕ×Ö××ÙÙÚÙÚÚÚÚÛÛÚÛÛÜÛÜÜÝÛÝÜÜÛÜÛÜÜÜÜÛÛÚÛÛÛ(%Uiafghhgeghhgigh^9 !12p^K9Kn[DHS=.&!  .1#JdIHP{fNIHA;EHN;Z±·…b£ƒSD58IH?JPLC˜¼¢‚KO`vlS…©µ¸Ã°‚]3i‹†£´‡·_^LE„³…EP˜¡½…N2Z‰¢ÄáØ×Ø×ÙØÙØÚÙÚÚÚÙÚÛÛÛÛÛÜÛÜÞÚÚÛÛÜÛÛÜÛÛÛÛÛÜÜÜÜÛ(&bdaebeffddcdefef]D%$"!/\cK33b^M6J>($" !'YF&,"6ZWt˜`KKHA9KFF:c¸¶ƒ_„\N6:NH<NOKM¡¿¸žI?MkOFJ^±¾«ž¨{P0vŽ|¸½ŽÂ‰B3<‰ŸYLbœ«ˆALtš“ºàÕ×ÕÔÖÖ××ØÙÙÚÚÛÚÚÙÚÛÛÜÜÜÜÛÜÛÛÛÛÜÛÛÛÚÛÛÜÜÝÜÜ&,e\^`adccbcedceedy‰C)3/'  1f[G>,J`Y=::#!"##&.jqd/%' $/Ny~™^IKK;9KIMDo¼·y^£–R>><OH8QKFGŸ½«XBQZK6@@»¤_“¤xG'tƒ‰°¡–ÆvGA{¢rFC[¢qHP_šžÒÙÓÖÖÖ××Ø×ØØÙÙÙÛÛÛÛÛÛÛÛÛÚÛÛÛÛÜÜÝÛÛÚÚÛÚÛÛÜÜÜ$3nbabbcccbbabcccbŽ©}em\*+#7aSSU)&QP>.*&%$#$([wkEscTjrpˆšLCQJC;JJNJv¿·~<‡bF<9NI:HECP§²§°qMNXL4;:BsZ ¼¦v=/ƒ„~¼œHBI’‹s8==6Š¤ŒF8;—ÅÚÒÔÔ×ØØØØÙÙÙÚÚÛÛÛÛÚÚÚÜÜÝÝÜÝÝÜÜÜÝÜÜÛÛÛÛÚÜÛÜ&;d_dfb^`ddd_`aca\¦Œ|„t&,'"6cHaRD8.@5%!#" ")>Tqt;VlFVwwŽQKOK<8KJKBsº®vn®‹OW5=KC;JGDJ¢À±‹‰VFTR<MF?ˆ}’Á°Â«G2Ž‹¦h6BD‹Žy6Gd>KH=D¦ÕÖÔÔÖ××××ÙÚÚÙÚÚÜÜÜÛÛÜÜÝÜÛÜÜÛÝÜÜÜÛÛÜÝÜÛÛÛÜÜ#<baddcca^_cdd`cb`˜®›~v' 8-#FWFFNK-%*%#"#%'8rQ=W-"<iVGoZNLPI;7IDHAz»¯n‚{UW44?MD<DCAL ©’ƒf@RO>LG@Ž³¸²Î¡v>X™ƒŽ\2B=‡„•M`€G6`˜VFO’”ÊØÓÓÖÖ××ØÙÚÚÚÚÛÚÛÛÛÜÛÜÝÜÜÜÝÝÝÝÜÜÜÝÝÝÝÝÝÜÝÜ#G][bccbca_^]_cca] ›¤“˜@%GK"%%RKBPP=00!"  "%4KrrEB*!(Qt[miMQH86AFJD¿²l€~NT\;CJB9HF@N¥­šƒ—^DVQAMICšš’¬¹±Ãœz0H”‡{;;8‡œmZ0mso‹O7;q”´ÝÔÕÕÖÖ××ØÙÙÙÛÛÛÛÚÛÛÜÜÝÜÜÜÛÜÜÜÝÝÞÜÜÛÜÜÜÜÜÜ$P\Z]_b_bbdc`__b`dª¡—„ª’g=ga3$>[IOM>84$#''**LzNZpB2&$BxYTqUD46FEHJŠ¿ªe…wQT[ELRD=JIET©¯Ÿ€:058=<D?;x‘sš„¶¯²Ã¢j5Z‘|q=4~‰c[<=Žp:ˆo@.R”œ××ÓÕÖ×××ÙÚÚÚÙÙÚÚÜÝÞÝÝÜÚÜÜÝÜÛÛÜÜÝÝÝÝÝÜÝÝÛÜ%OT\[[\X]`ccca^]\^“§’…¦‡•atq@:&JI;E;52&%%$''PrhS^-00$!/\b[aPC0E?=B„¾§f}…OOhLEPA@LIHV¦¢†z{^SI6<EGHŠQvl˜¼µºÆ”e3Z~d%w|—cPB=tw=P‰h3a‰‘ÎÚÒÒÕÕÖ×ØÙÙÚÚÚÙÚÚÛÜÛÛÜÜÜÝÝÝÜÛÜÛÜÜÜÛÜÝÞÝÝÜ+^ZWXYZZZ\``bbc__\MQŒ„¬‰‰~{r=J!$6N<A,88%(&'('T}pxleeO.31% #?cTJWF/*10n­«g†‡bfWIHN@ANNK^¬¥Ÿ¢ŽaETJKVYQ“›jY…‡£ª½±µ€H0R’zXn§w=DM<mœg&U‘K<l¦Û×Õ××××ØØÚÙÚÛÙÛÚÛÜÜÛÛÛÜÝÝÝÜÝÝÝÝÜÝÝÝÝÞÝÝÜ1[Y__UXY[\[\`aac`Tnf?y¨‰r‚‰8M..O@R-<7('')**[znsllhfP#65""#FlSOgJ+'2gŸ—s—‡ir@EAB?MG>]¨¢°¡y_IUGISNR˜œMCsyŠž½¨³˜1+%W42!#-[W/Q}L>4€d:>†™ÔÛÑÓÔ××ÙÚÙÚÚÚÙÚÜÛÛÜÜÛÛÛÛÝÝÝÜÜÜÜÚÜÛÞÝÞßÞÝ9_X^__[VWW[\[]^_[EmQqO8[ŠŒŽ0[<(FFC4@5(*''))]pr`Gsjdc<%0    VG1NKA,a@ 4†Šx’€@CMD;QQMv¯¡¯­¨dLXIP[]N–¢TIgwY}»»»²n6*16$))6Fd„h2G=@kFˆŠÏÙÑÕÖÖØØÙÙÙÙÚÙÛÛÜÛÜÜÛÞÝÞÝÞÝÝÞÝÝÛÜÝÞÞÞÝÜß;[]^_[\ZYVY[ba^[YF)fTyXHC}%AR#'3A93D7.+))*.jxtuvxTTidaH1&&#!))  $/?s¡†AIJC@UOEv·ª£™PR?NELQR[¡“WL`rKJ\ªºƒqt),,*+*6/XŠ{o@‘X"gŽ^™¼ÔÑÑÔÖÕÖ×ØØÚÛÛÝÜÞÝÝÛÛÜÜÜÝÞÞÞÞÝÝÞÞÞÝÝÜÞÜÞD_VVZ\[[[\[[^_a_V7#";iNlg;?'>^'&-C20<80*)*+1l€st6P…`D7;d<,'$ !!  6:+(VŸ~GJM86KJIx²£° NV?]KMSRN”šcOS\NIBp¨y‚†9 1?<Tl4z‰Œƒ]’=XrqP“ÐÜÕÖØ×ØØÙÛÛÛÜÛÜÛÝÝÞÝÞÜÞÜÝÜÛÜÞÞßßßßÞßÞÞÞI[YXYVVZ[]\]\\]^T4###":ODa,=4g&(-<9473-*))*0lvvua7um/*F^H:#(# #J6(&`~?NN>9LKBr±§“”G9:O=FOOO’˜skMVI:Bbr”°…&1>D<…W7\†rZ5:`h*‰wdŒ¡ØÏÐÔÖ×ØØÙÚÙÚÚÜÛÛÜÛÝÜÜÞÝÝÞÞßÝßÞÞÞÞÝÞÝÝÚIVYZYZXXWZ\]\[ZVU-&& ! /&RHJ[*_9$,5611/*(&&&1ionmpmK:A_pN\A?& FQ/2/JII70JFBe¬–ž¢=?9OBDIJC–}~TY9F\HyŽš§h8;ED=hŸ€]C’ˆ\QCFxJV•ª‘£ØÔÓ××ØÙÚÚÛÛÛÜÜÜÜÞÛÜÛÛÝÛÞÞÞßÜÜÝÝÞßÝÞÝÝÞOUTVXXWYYX[Z\[YZI"7<  !\M9-O;YM80$;493*('$&%8jjkiccaR(1sqWJc=9  !& 6a5:3JM::EGDp¯ž‚‘Q<<QFHMLN›¥‰;JEIO:Ž²”{[=>151e«œe~ŠoJTD`–eT^–ŽÀÚÔÕÖÖ××ÜÛÛÝÜÜÜÜÛÛÛÝÝÝßÞßÞÞÞÝÜÞÝÝÜÛÜÛÝPRVWWUXWWXXWZ[ZYH&IY/&-cME-T<a<1B5>7.&%$&&Dg`kikkkc?R^D†fGUL/)"! !".02)"%^TNMK79FJJ±¢¹Ÿ929RFKOML—•wsASTLT8ƒšvy_=8@?@l¬ l¡~z>.<M„@A?|ž…¯ØÖÒÕ×ØØÚØÚÚÛÛÜÛÛÚÚÜÜÝÞÞÞÞÞÞÞÝÝÝÝÝÞÞÞÞQOVVUTSURUUVYWXVD.Wa-$0aFW +TC_M793/&'&('Hngcc\ -ccJ&ZmE9@/%!"$CvJ*.)=pqKSU8<MLHwµŸ€Y`<?VGBPNS•`^@?5;@7_‡OWN:!,./7„ qq•¡c6Ca`=‰91›ƒÓØÐÒÕÖ××ÙÙÚÙÛÜÜÝÝÜÜÛÜÜÜÜÜÝÝÞÝÜÞÞßÝÜÜÛaWNRSSRYZVQUVXVVB4_c6"7hTA$! ! /B:;34,$!$%%<ibh\&$!!%[_K3)iS.+# "&ErJJn=RTNFK9BKMGpµŸƒW-5=MDKSOLŸŸxAU8]\P‰›wUE'&*?eYF†6*72f–fsu5‚h¦ˆÄÜÑÕÔ×ÖÖØÚÛÛÛÜÝÜÝÛßÞÝÝÜÞÜÝÜÜÜÜÝÝÝÜÜÝÜXS^^YVTUVWZXWWXT@<a[)$>iElW$ -:571+(%#$%Mpb`}wM`' "%XXVQ8>0$"!!"2JjI4jGQpYH6>MKBs¹¡|E1<HXIMQMT­¢‡uGR<TQF|•X^?*3?eVu?#9AA:ƒ–mD5I›u‚ÆÓÑÓÖÖ××ÙÙÚÚÙÚÚÛÚÚÜÝÛÜÝÜÝÜÝÝÜÛÛÛÜßßßÝÞ?PVTX]YWXWXWXVSQACb[(#;O8kf$'% ,8/0+)&&%'%Hmb`‚sŠG(#)UKCP8"#"%%$DrEU/!&]eLqZ=AKKBu·|Qt/DXLKPOO¥²žƒGVFRTJrœ\fT:)(7?kfL+)45@_Aˆ]E=Ž½ÐÐÐÒÖ×ÖØØØÙÙÙÙÛÛÝÝÝÝÜÛÛÝÞÞÞÞÞÝÜÜÝÞÝÝÜÜÝ>?9KWVZ\TPRTVWUODFgU#%HV5}R*-KH#%0:.2('&%&%)X`[]‘–o“=,!9[A\D7,! $+EY…T: *Axaf^9173]¦˜†oˆ8?ODHOFN¨ªia=MIXVIŠ™QNQ;.:K?psh53>Bv—\`pBB6‡Á×ÖÔÕÖ××ÙØÙÙÙÚÙÚÚÚÛÚÜÝÝÝÝÜÝÝÛÛÜÜÝÝÞÜÜÞÜÝ8D>?<>YZ[[IMUVTNAIeV"'8><r^12SY#&-:,2*''('&&R_[Yˆœ•T,^9(OROF<4!"&(WoEk\S^#-‚…XrB,.K –…g”EFM<CHCG¢¨f;4ODPRFmŸcYT=:Td@kvrIHBCeŸ~ˆsJBHŽ¡ÖØÓÕ×ØÙÙÙÙÙÙÚÛÛÜÝÝÝßÜÝÛÜÜÛÜÝÞÝÝÝÞÞÞÜÞÜÝ 4LBA?@UXUTMNOKCOnK'QK8zLB>ZJ%+5>,1)()'#%)R^]]›w®}Uk>"2V7:47%''+bqu~ ©v‚?(_[ys>RTBk‰QLLAFMJU°²k;3S@LNB}¡bNS@0We7ipr[c_HWoC™‡NKUˆÇÙÏÖÔ×××ØØÙÚÚÛÜÜÝÝÜÝÜÜÜÜÝÛÛÝÝÝÝÞÜÜÜÝÞÞÞ   "+HEB@<LTQQK@@Sh=)ZTH€LHG^H&16/8+*&%$$-Z]]^Ž™~¯q{rI@'BHC9;"('*,bsihœ¼ª_&!&-*"" !$gjgCCH>ONIH¤©h55OFSTJx¬sSX81Ng<l{nG5BCYx…,.;]ƒ‘ÓÔÐÓÔÖÖ×ÙÙÚÚÛÛÝÞÞÞÜÝÜÛÜÜÝÞßÞÞÞÞÝÝÜÜÝÜÞÜ!" !!!">GCB@ALJHBWjH&+ZSO€EMGZJ%-602(&$%$%*Ya\[\:y§ˆz~^T*8O;<9%***.^wn’kŸÁ¦]$-'!$"! /4„hv]ALDUZ\[¬¥iI4H?KMEmšU?E:6Te;f{n>.40_C)@??t’˜ÜÓÑÒÔÖ×ØÚÙÛÜÜÛÛÛÝÛÝÜÜÜÛÛÛÜÝÝÝÝÞÞÞßÞÞÞÝÝ7*%!    2E>=;9CB\b:%.ZF^GMM`D&4715&$$$$#0UUYZR\[Fut†HK@.E5A9,./03kuk˜ÃŠE“d0($%!  """&Aj€sG?HOJH¥ž_DCPFMI<mŸeOQ21Hc;[{x<4:,?L3::;JG–”ÓØÐÓÕ×ÖØ×ÙÙÛÛÚÛÛÚÜÛÜÜÝÝÞÝÝÝÝÝÜÜÛÜÛÜÝÞÞÝE<3&! (8@=@?<_`;#1^=crMMS^>(2103('%%%%0aXXI3OP`SOd6U5+=0=8/.,.6vwl`shŸ~9!    ""0/+I‘tp?IPOX¦ŒLF9RCLMA…§fES75N[7hrBic9RL4>;H€L}¡ÑÓÑÔÔÖÖØØÙÙÙÚÛÜÛÜÜÜÜÝÛÝÝßÞÞÞÝÝÜÜÜÝÜÝÜÝÝMJD@7,%"!   $-7>:AB,&8\8hiMHT\2'20/,(%$"##/XUZH%4P_gV4DI '40:.)(()7jsw³•^o·•¡‘F "&VrK'>xZ@HPN]¢‹6+:GAGJ@~ªkAO*/EY6b~pV’Hbl<@7K‡…¨ÏÔÓÓ×ÖÕ×ØØÛÛÜÜÛÛÜÛÜÝÞÝÞÞÞÝÝÝÝÞÜÞÝÞÝÝÞÞÝKKJHGB<3&#! '+275"9]>sdOLTb4'1,-.)'#"$#6`QSC$#8S[ZAB &2/;.&(''3igpµ¶u «µ››@#'/xrrvDWWE=KONU¦’>8?G@KQCx `@M00CW>`…wb¡MZrOYAF€p—´§¹Ì×ÕÖ×××ØÙÚÛÛÚÛÛÜÜÜÛÛÜÛÜÞÝÝÝÝÝÞÞÞÝÝÝÞÝMNNMKJJEA7'$!    &('@X=m\WQ`]*$)/(+*('%#$$;cWX>&!!..CIZH3(95=,')'(=jhgien°†d‹¶ŸU*%,5Ž¯vk`jW@CMIX©ux;H<GK>yTAQ90EQ6]…|\’P@YrCOHGqd*&B˜¼ÒÑÑÓÔÖÖ×ÙØÚÚÚÜÜÛÝÜÞÜÝÜÝÝÞÝÝÝÝÝÝÞÞßÝ-?ORONLLKF@=0&""2M;#&HZ@o[VSd]%#*/*-+)&$$%%<[VX@A7&RJ&*BNH<40?0*())Brg^637dœ‘€[K/(&&+,zŸl6eugvR:?>J¡Ž|w9I7>H<{™Q4K8/BM6]vb‘>9Sl*53._6.8<S‚ƒÐÖÐÓÓÖÖÖØÙÙÚÚÚÛÛÜÛÛÚÜÛÝÜÝÝÝÝÞÝÝÛÝÝÝH9-:FOMNOMNLJE>QYcD)GRDo\XShW %*,(-*'&$###?]SSBSK!*VE+ +;>D57*)())Aqgf{A5.lž‚Z-*,)155‚£ˆn&>|rnc5&8‹Œ|x6H>HOC}ŸS8F94:;9Z{z\ŠH5Rh?^)6P89+kPq‰¨ÕÒÔÓÕÕ×ÖØØÚÙÚÚÛÛÜÜÜÛÚÛÛÝÝÝÝÜÝÜÜÝÜÜPPNA1,8ENNPQPOGFLP=.&;HKh_YVmR$)+((('%$$$$GYTTI^H#+`K+*956'&('(Gq`aˆAC'6w„j>6%$'):’«˜Šp)$wˆqwO5“£{n7D<NVK¤\>M757:;X}L†X>Wlf”6Ja3A9‡RÆÑÏÑÓÕÖ××ØÙÚÚÛÙÚÚÛÜÛÜÝÝÞÞÞÝÜÝÝÝÝÞÝÜLMNNM?3,-=NSQO>%7FQUCB?>abXXkI&(+'*&$!""#%HSRSIaH%-\F'!, &326*'('&Lp^g¡\U:%C˜l<9%')*?™©²©jE(>;"% &#KwHIBQSD˜O9D02257Vw{X“XCRp§IOkKX>ˆ®¯£Õ×ÓÖÔ×ÖÙØÚÙÛÚÛÛÛÝÛÛÛÝÝÞÞßÝÝÝÞÞÝÝÜÜÝ.AIHIKJI=.'/?G86KWUPDEdTWnH'-)#'$#"""!%KSONKfH!-Q@11PA(119()))'LuYf«…_I*3s=</47>C›´¯¾£X!! !$&mygb<MSH U:G00011LwtOvmFYv‡’9DqAY;†Ÿ»¤ÍØÕ×ÖÖÖ××ØÚÚÏËÞÛÚÛÛÛÛÜÝÝÝÝÜÜÛÜÝÜÝÞ6'*9EGFHIJC5''*! *CUTNMQWm>)-+'*#"!!!!$IOONQiH$.UD8?V>%0811%(%&%Pt^m¹®tT6#`e=?*489H£¾ ‘†{+ !##$@z€tkHK@{›O5A4//37OwzQ}uHPr~y:Kw74-R’Œ˜­ºÖÑÒÔÖ××ØÕ¾\EgÃÒÒÒÔ×××ØÙÙÙÛÛÛÜÜÜÜN1)'+6ECFGHC;*2,$ #;RNA>S0%))'($$"!!!&RQOKRkA0PFAFW?$/;48&#$$#OkZi¶¬Ž~5%CL9A2.57G£³••‡©‰@ !"1Z0#e…hMP?z¡`<D1,.5<QxsJ~kAPyzz<Hx446O[y•¢¡ ÛÕÔÕ×××ÖɐZaQ©ÒÒÓÓÖÖ××ØÙÙÛÚÛÛÛÜÚK*@NG7'!,=EBCBDNKE7)" (8;>=8,+(&)"""!"!)TQRLXi:0M<>Ke@!.936$####RfYWs‰ŒpG7<:3@//33FŸ±…Y®¦B#"Lond:WACH?v£k?D2..:@SysOuwEGsv‹@L}B:@rc@d‡®ºÏÕÖØÙ××­f[fj­Õ×Ô××Ø×ÙÙÚÛÛÛÛÜÜÜÛD(CIMONF1%$,8=>QKOQMA/%  !)4754/)'#!  !)SLNF]m81P;@NcA".424$%&%#Vo^W_dyf_HF807-153L£¶¡}œ‘¨~2)&[¢z’ybX>D9t£kAH50.56GvpLwyB@rm9A|Td?†•zH€’®¥«ÔÕÔÔÔ¶qJVc|Â×ÒÓÕØÙÙÚÛÛÜÝÛÚÚÛÛ$$=LLMNONC"+ $5SPRPNMKG:,  !%29<8.$"! *TNLBal71K:?Qe?,/,4'(''&Xna?"J\]aS9926,/02Hž®^J™~huS# ))AsE…ˆxn2!Co@C/.,37DxrMfu@DsgŒ?Jza…B†¡´ŒG€—²°¥·ßÕÕÖ¾zJqm™¿ßÔÖØÚØÚÙÚÚÚÛÛÚÛÛÜ4' &7IOMMA(CD;.1?JPPPPPOIA0!   #-:@9&##"!!9IJGci06F<BWi6 ,.,,!''%%Xk`D*;I^]VC89-/-0C—¨[%p£‚?.3,53R£’i McuCJ™€L@+*)59EtwPbi+;paƒ:Dq^‡+€¨É½vBzƒ¦‘ÄÝÑ×Ô¾€V¡n°ÕÓÕÓ×Ö×ØÙÙÚÛÛÚÛÜÜÜEE0*+#)<E6/JEFSD9.5ANVWTONKG6)!  %("!   :UJDfo+<G=A]g3*++.$%&$%[h[>6G$=LUB35)./-@ssH31|„X-!(0/b¨“}T&1>20!%"an1$(,/BtzXjc+<oaŠ;DlRƒ6}´Ì´w>•Ž¥ ¸„ZNAW[`tr£ÍÒÐÓÔ××ØØÙÙÚÚÛÛI@"9D=3$#$-C@DQMOO@3*8KSQPNMIB8+   '=NHG !>FACbd. )*'(%%%#$[^X:CQ"!2643+-./H{ZSO!L—^>,-72i³²œM!,=‚|m4*)3r†Kff6Ardƒ>?mU{<|„”´}ªgHŠ”®§‡[ZW`U–r…xg°ÔÍÓÒÖÕÖ×ÙÙÚÚÜÛHPBELLID@6('0>MNNPQK?,)7IONLH@9-!! %=HK$EC>Abf.()(%$$$"%V\S3 GR$& -1/(*,,FtrvM7<€V?50;7o°¢n- !%(HŽƒp>161i‰`ok2Cqc‡?AsU€=y‹L†Ÿ»®V;¦±–{WV[KeXxp¡x˜ØÎÓÓÖÕ×ÖØØÚÛÛÛ24BQQDCCCA?=\YC DTMPNQO,"&=IIHC9-%#!     "3'I>=@d\$#,()$"""!$]ZO,XJ-9 &+/1)))+M`k†Z9'l7754:7w³†d«a/#%G\"AŠJ=IF?w“_lo9@qg….<vi”pˆ:Y±Â½IvŸ§‹•O5B<YU‚u¯†“ßÒÓÕ×ØØØÙØØÙØÛ$*025?ITNJHF1NUTO8'AONNKIC)",<>6,'&%!    "9E/#;M+!6A@AcT#)%'#"#!"*]TO1$IB>V#$+*+%#"$LZd£†85&-*230o©Z[§“m)4iu‡Šd$3ED2n¶zq‡=5umŽ5>z[p7u‹I2†²¹Â±@u›°«‘<4FDQOEZ¡ŒØÚÓØ×ÚØÙÙÚÚÛÛÛ!  !'.23>SVP9KQPXWSN0%EDDHIH:*$),*))  !!&LVOE)GYQQI69=hT%)()&"##"'`^Q,"LIHX0&)*&%''*M\g«J592/(696l¦}‘˜º‘8$;;pˆr¯of9,(S©{‹:1qk1@s\dFw–M9r{‹ˆožW–µŸ„TaaRz^„˜“ÏÚÔÖÖ×ØÙØÚÛÛÛÛ !!#!+125;RZOKONOQOQN))DFEEB>2%%#"  !!$Q[SO6 -MSMCAgK#)'&$#"#!(UQO+"RBIY8,0/&#%)(IiW“¡r>/44.5:7oªp–š\')!.1_”SŽvcP,8Q¬«œF"si21q^b8t“K0\wP —ÄŽ?—¤¥ˆzY^Q{xŒm¡¿×ÔÕ××Ø××ÙØÚÚÛ  " !(0468U\UGKKLQSSH#B?@?85%     &>TT2 :HEG/"((*%""##'^ZN'UKKV2!+/(%&%%OpOK]{qP'60594i¯`J•b3&)+[§v=! k}f<-bp”I0kY[Bj–QGi:q¦ÇA£ª®£J]V‚s~leÎ×ÔÕÖØÙ×ÚØÙÚÛÛ"  !!",77=V^TJLLOLMH:(0944.+" 'G=(5@:/    -A27.*)'$"!#",\RK+ XGUR5&+-%%$#!RqU"Fk„>80.2-aœ[*{…O)0:@v’R!${tiZU‘’AAhWg3c‘UOop8Kr´ÃÃvt¡±¸eOR{p~l’Å×ÔÕÖÖ×ØØØÚÛÛ"" ! &$,57=IWSIGQMJFD1''%#"""")JUW@0NLG7$4657.!#!" )ZTI*"`HTM-'+-%$%""R`K<N%?7/+,/.Z|S;Q~J;1=9gnr!$9i5„grb£˜J-oWc>]Ž[MjrD@cT‚‡§eJ°¡`GK_k]qxXªÑÐÑÐÔÕ×Ö×××Ù ! "!%#-68:PbWH@A@?;/"  "8POOOUJLIG;)#&=87' >QF&#PF\L.(+-$!""!Mdawwoa;2..0-Y‚^A)]13,?4d†±P %'(dŠu_:~gs­Q=ld^C]—^F_v58IgS™Äµhr WMKYgQSŠgpr[hc^mq€¾ËÖ !"!! !"*88;I^X@=83+("!"!!/K6%B1<EOPOMGE7( +!<L@' RF]I&$))("!!!?X:  %#$3/,/1-Sv…Z'3,72A2_—’ºs),+)eªˆl`!ms}–62\eSJ^•]FZu?Rjf%;·®KZ¤^IYqXhw™˜p‰¬ˆ®“ÄÉÝ "##%(7<;SaY7'#"""!,JJHLRG1)2LQMICB=%!'DAAEFZN ('&!!!!'];:FV*+60(&,(So„J/3/.'..x¢•d%"*)T¤Á¹„y.S…h['#nZ9Sp?WvOZdd8L‡…¢G†—INk\h\k”w¬œ†‰‘˜¨Û  "! ##%'7>>K_`:!!"3JIIGMQOM@(#<JGD=;/2KHZR!&&""!!$&Hq8FH-&4/%$))Wsˆ‚561.&/*l€ev2"!*/.`¥µ²Ì¡…[%‚m^Œd;K…c;JtPMWo?Q|c¹Ã˜]Q1-2eV^wtz^hrgv~‚‹ª¼à     !!#%()7@>Gai@5ICH9-;MJLOJ2)-@A:/" '0#"7K?:X@"%$ #$%%;>9@MY-$..'%'&YaJ{{]2314-n„RP-)&24/g°®½ªÔ´€A(‰x} m5H•jFUwGSZp4C|Jq ¡P452<W—‹¨…Ɲ’°ˆ¢«˜ºÂÝ $"%%&'1<=I_fUKHGOD6%>IGGFA.#,,('# ;JC/*QEFK?!&&'&&%$HO2@R[6#*)'&&$ReD!ST61/8/bX':/'&772e¬¾ƒ¥µ¿Îr<RŽz]07qeAIxFFJl?JrFT˜¤y=9IffŸ‚|­y»«±‹˜–Œ‘“Ò!#%%&'-AAIfiXDDLMJ-&;CDBB.#"" !  !=UL0HQ?2&*'$"!!#LQ?JO[(#+**&$"U`R,%3.141eb6;.&'65*f©¥¼€~µ¦Ë¢‡]N’ep:tp>VrLL[k5Cv7Lqh5@;i`s@}‰re_wewys‚–Ò #%&&&&?HI^rbMHJGA,(5<>8-% -C;%$;<54&!"#%IQ<@O`4''""#"VbTE&,+,0'\k710%&20+]ŠrŽW,b‹¶¼Äh0™_y¨nO‚O;Io9DvA8lPo=GHiVl?q›§®ˆµ”–Áœ©ÂÖ!$#%&'':DI_l^EIIE=)!+*'"#!! 9]?$FE;  +63%" !"C<DR_-'&%$&!QcGZ ''%))W†g61(,-)Hv`':udµÈ¼Ê¥n3T‡w±w@JBJq;DsPBuFn]DMlJ}ge&‰ªžŒ®Ÿ’¯ˆ™™Å#%&%((:LI`t^>=@91&#"""" 8^TPQNJF>1"!! >9DMd)",' !"!LbL_"())*(]uV,'&#))'DtpJB*Yz}Ÿ¾Á¼wK,Œp}P€I3C`D>wHDn@d\ND~\eNqf]yigzjsŠƒ·"#&(*1GIXxi8&+$" !7.-6(LIOLB?/!(9])$)(!!" HVPa)!*)&**VR/J($#.-'K~nT:8Jt¦q†•«Ä˜m1‚lrLDDr=OsP?kGlrGGw|cb]…|š¹ˆ¹«†ÀŸ—ÉÎ %'),5>O^ff@&" #&HRIIA.2CKKC6*#  4]*!(&#"#"OVS]#&($''L^)#%#$,,&I{pV=;F‹C:s©¶·—wKz€mN9>jEBmN;kPqiAFkjlˆe… Á‚±±ŒÅ©¡ÊÄ#%)*+2?J`jfH+'ITOMNOD7-0<6/(   #>41D@H'!$&#!!!K\O_)&%#$%I]1($#*)(CyjY33#y§†1X`Œ¸¯¹¯vP_|C65i@;XO?p\Vs<@acoƒVtqhmj[tegv™%()*2<=G^eSOOK728BGLA7+(&$#"!%JF1!5AB+$""!"IRN^*%"!&"GZ:!)" (&%?~m\),ZžuQw;q€n±´°”88G24l@;^S4{\Vp>Esx`lƒq‹˜|“ž}¬¡¸À #(**).?XfjfTJG636GKI8)  /B?$!.:5"! >XO],*% #&La?##"!(('=uo_6,@}ixbe€UDett*(.+0a@7YY5s`Um<Cj}[lx›v‘¯—±‚­«‹¸¾ ""&(8COdlkVC?.+5:2 !?:/I=)"&  #=GU((&""$HZ<#&"&$">oh[.(2qRC2>…F[rsf#;9R<,TX9l_Mi2Bd|\ne®zsqnzjppjzqx !&()5=LeliTC1%#    !=HITRN@*#4@%"&%##"FY?"&!"! ;laZ0, 8kN7.?ŠrLb3i` #/1)GM.RZ>h]Hm88X}guh»·tŽ{†œ€œ¥ˆ«¸!$ (')0=JdmiI'  &;39/:GH>(!.7($$$ "H[>$! =p_P-*#>lQ1-6sqY6L\ 5G78&'TW3dZJp?<U…fv‹Ã㚐ÇŠ¬°Š¬¾5a9%$#$')/9BRuf8 (WPPJ@026)"   @A0>F9*$!"#F[B#!! 7mbT/*#@iS2"%VW5"4qg 'C!-:Q8h`LxG=H‚Uu|‚‘¿‘w{huqwug(3('!#"  %*+)3S[)*TI7<COJ;(!! !AJ!#/90%"!2LC& <oZN.%<nO2*1_S2(V`.R&.A;?N+ndDpE<R‡Pqw­v©¢px‡z…‘}•˜ "!! !!!!!"!!!"'QJRNB3:D:'   23A@(#"8B'$ !  5n^N&'4hK8-.Y[)Jx\ /V+,9#  #XdEk<;JEbg·¿•³œƒ¸€™´ƒž¶&7$%#"!#!"!  'H<(,YLNMONI6*!ERRSG5 **#!8sbO+(6cC5--_a&"DqX!,P'2G 1U`|Fv99Et?]W²É›†w…r~‡vs!""!  %)''#!(\R7&ZJ:NKGFA-"7841;7& --3B/$2f_P*+5gN3.%U^%#Cqa!*R- 4U'EQ8Qs@FAw=XQšË¬~sj‚qrˆ{ "!   "(,2d^80YC+HNE@=(##!!'OOSL3*#! #JA%'*+E\N(+:gI/)(XR/(HrU)R)(4N*>.'MKV8<HwA\\{†°š£…°„–±Ž“·! ! #$"'5( <B2/UB!5H5' "!%OL??EK3 +88) $A<-0;[K(%,WR/ ;u`$H&"1M 'QJ2k7 //`?RQyd‹Š‡Œ’‡¤³x‚Š"")<-')(&# (OC!9M3*% OQMNE5("! 6TLF+""GS/(YS*'+UY(#/tj20>-"(E('CA#B3!*,'OJTJ“~‰ŒŽ‡ŸËr{#.EH-()*(%!(N@"5B3  "JOHJIE247*0(!'E#3 39PL$)%J`%"-UM5/C+&E$">=-I0(A !$3I;~Œ……ˆŒˆ”ž²µ|»!4121*'(NA#5B,&1! !JG@R:=3! DMFD*#<.UG9 4DC>JZ.%+I[ @-'E)">C4E4-A%/(2:o ¤›Ÿ’ˆ}­’¤…£!$#!!!+O>!;G63>"!FD7Q""#! $BO<3-$  $I1GFH>I5"/CGHU% ,XR>2!(F&!<@2A1-M (HK$+G~žªŽ{ŸËdi '- ! 'J>$@I(1A!!!!$FE@Z(+!#?PIC)!  "A7;%!>L'0PG(*+aU";,'H+ :>*844M$+AZR$-J—³„˜…ªÓu !  !     #'#92!<D&<J# =7?U# %:HCB.$  *C%5&%UXPK(!GA%[^$!='&E. 5:&<20Q$,PA;V@`ºÂ’™nz¾ª{¼#"""!"!!"!!!    #'10;A&8C!$B;7H*5& 9@92!.GC2$"HFDLG2SQ!!<'%?/%9?'7:1K&,LB*J]—ŽžŠ–ÍŽhx‘hf""!""!"!!#""#!!!       +6! /3AD*8>$ %A:1C5B$#"6<@0!  *R?0,"%&;8' 8eUC($M-E%!B2!69&<8.F'A8,>†Œ‹œÀ™¦…g™#"#"#!""###!""""""!!!!" !!!!  ,4 !!!11=@(>;# (A77D=C% "6??( (JJ8*IKJ*!"$799A+$D,%@2#:?-;=JC'DA.);Š…ˆŠ‹–¬·”|¦"##"#$#""!#"#"##"!""#"""""###"!%4QD%'' (&".+86(?<"#:3?G=E( #8<88,$>653#%B9(/$!%&>"A<:5"<+"5@#1/*=#(F@(/_€ˆ‰‰‡’‘¸§rˆ"" !!!"!! !"!#!"!"""#!!!!"!!  !    !!&'))$'$4:+98";9<I@B$ !8><<3%<>3!!CHH4)4DD5 /7$"$36**"1;)-#8#&9I/9P‡y……ƒŠ‰ªÌ½f"#"!!"#"#"#!"""#$"##!"!"#$#! !   !  !"   " #(' *8*(%"?E'98"!! #808<GD&!";:;:0!&I1'& 3;42'C@@'"#&' #1>,.!2"7M8Dc~„Š‹žÇ¼†!""!!!"""!""!"#""!!"!#$$##""!!!!!!    "!    "#  /-&"($1:/>C!>9  ';18<@?$!59;:0 %46-66$%5971%5072+30-3>""9H/C\€}€•}…†‰È½‚!!#"""!! ! ""#"#"!!!!""!!!!!!!!   !"  !!"""!    "*-+'&!!$"8A258#@-!"B835DI% !466<5!!33$22("3724FA$0I%)$$//$:15-$3P8=Esq€š„€€‰Œ·ºt!""" """!  "! !!"#""  !!#"" ! !!  ! "  !       "%!"$"1@/18RI,  ?9,8CL"09498!+1"*%%#%3)  (@&'!36 +'R/97qkšˆ}€ˆ„ªÈƒ#).69:9.&""!""!! ! !  !!!!!      !!"!  !$#!!$'!,<4(,2#'! 25):=P!,509; 75-6D&<)!39* 3%"19* "(!#=;77jJz‚‡~‚Š‡©Â‹%'(+..((&"""! !"%(++-+$#!!!!!!!!!!! !    !#"!!  !!!!!"!!  $('# !(%#073476(#"7./:K?38252$,,  %,:?%&8!79+>!$() (A>2,4|‹{€‚ˆ¤»s'(*+/,15>ENOLID=5-,+(&%#"!!"!'-,)$!!!"!""  !           )OB4"162466-,#!!<*3EB*36070 +7)')&8#%##*+&'B-3( "UI*#Ui;F`r„…Ÿ»o''*++(*,1548679;;=EFIMHCEF5//,.30+'%#"""#%&&&&$"!      "!'-,("!&*& /:&'6<1/+% 3065'#563D- /1!).: "&%#"2*3!8-FUFJ-!"[…os‡ŽÀw,++...00323:;<;@??875578:;:852--.047?@<<50/**%%##" "%*--$!! !!!!! "()#""+%!-6+(6=*$!65:82- 37*  =8*.<*0!"-#$,!%!40 EG@O4N€›‰ˆ½{BC@?@?@>>77852../.15543474230.--+,0234669;;>?BCGII:21////,(-...+&!!      "38%25"!!+)01&(! .2.)$+*"! 5" %""&!)"!67IN;"<\Œ“§™•r""#$"#!"#%',3469<;56689:31/-+**0./33488641/12456554/17ACA@?>???@7-$# !      07$"02!4-.4.&/41-'#-1'"&*7! ""#$('%4&%.C!"$:~uE‰–ŽŸ   !   !#'&('(&(**130*,+,.27779;<<:95233426642/.,04689:897887651* *1# 43!6-+3*1.)-<82+%($!$ $!%$"$#/*%'02ujD#]‚˜      !!!  "%('('$#   !  ##$!"%&',2000034567;944045799:665531271*##!  '*!--' 4)-2$))!''BUJ3"&=E8&+$.% " '    .$$56( +7+1!">#$##"""#"#$%&&%#!!!""!!"!       !!  $$)++)&')+,/2:::<??=>0%! !##$# $#..."4(..&$)())+7I.$%/<9+ 7V?'#,  ! $!$+&%'E!5~[B-9)*     !   !!"%&&%$%%%&%!"%$$#"#$$$"! !   "%()'#          #)'$    !$%#"!#%%  +, 1!%!(+(+'+&#&),<.""$'5K/%"'#""  )%#44{jkw{qR !       !  !!"!!  !       !!"###"$$$%%$#"$%##"##"##%#"   !#""  "% $& ( ,0./""#&.C::61-KJTTQLORY.%/ '&!$! ")(&&M"-QS_b}         !"##"  !#$')*)''&"  %+'!   %!& "#"! &#,^WG,*/F'1)3!%.8'"" $'!+' *4--64 $690Ndo   !! &1>2$&#! ""#$%@(9arB+'GSp,&*2C<" "%!IcK,.lh`E62F2:-(        $2B:*  ! "!!-$''/]q@4&C+-(@>1? Jo`(&!!N}|‘[IT\m:%8\Cs !  !!!    !!      !      !!!!         !  !"%'(#  (25+%  # # 'AK1)B(#)178,("1I9!  !!!!GiAVEfS(*3.1=H,)      !!!! !!!!     !             !!   !!"! ! "!!! $&"(0-% NSF<HR'7a]^\Q0 22  ! 6Q#*+850:?@>H/ '!  !       !    !        !  !   !  !  !"!   !".YOB !""    #"!5ZFB&'ijL:,!,*&7$5!1..-3]H[! +!! !! !   !!!!!!             """#"""!!"!" 20.$4#:WS]FY-!//-I/%($0G"#GW963V672GW "!! !!! !!!! !!   !! !!            !  "###"""#" $)1%'(# ")#  "34P'+98/8-6 ,3("-6,970(04692ONRPVd\VF]h9+2:/Jvk^ !"!    !       !!"" ! !    !      ! !"""   "1AF6)2'%"  )"#%2/%##!$$)(#$#$#$$$'!# #&"(1S'$6;AHMM9KUVVRNYc\[^efllcglmljhkmhce]d_\\WVVXWZ!    !   !!    "  !!!       ! !!#""#" "/40##!!'9>:+)*:=:>=(/8%?>BB@><DBA<==;9842,&*("!%!-.:'H>CGJVXabdeeeee^\[ZVVTUWYVPMJEFAEFLQMRXV\[[YY     !      !        !!"!! !       !!"!!!"!!  ")1).5DGGHILMQ\YZ\\\\M(Bg^b<<d+PZZ\[]\[XXXZ[[[ZXVTPOM@80"$&)@VSXjpnhec`\KGPKHFCCC@?>@AFHLKRHGIJSOPPQOQR]dc^`_     !    ! ! !!    !!  ! !!     ! !#$'((+-#!,ETSQNFEGFFEB@DIMNOOJ0:YWX2Ke/O`[\\\\[[Z\Z\[\\\YSMEDCEIKLJIFC???@BBEGC@<;::;FKCHJDOOGHBFDEEEEGHIMMPRSTXZbYWc  !!!!!! !"""!!!!!!""$$$'(*-035446887;;CCEHIIJHGFD>,"!  $-0+! "+3563210/1257EQSTUTTUTUUWVXX\^]_\ZOHDEFB??>B@>?>AEDIE???>DDACJKCEDTI=HEANJBBA@A@>??=?>@ACEFHIJLNNQ_YNRQPNML !!""""""#$')*+.16>CKJJHGHFGHHHHHHIIJIIIIJJIIHDA?;850&#  "-MOK3$*79<=;:773.+/B[\[ZZZY[[\ZRC=62&""'*9LRWXTG=8616466777899886653ZfDEJB@;==>=@<<9::;:;>=@AFGHHFCDHLMMIGFEGHGFFNNMMLMLJKLMNOOMMMLKILKMKKJHGA><93232443332220244612/)%"  #8`rmK%" !""%')&%"#!#""&(*'%#%*./?IHHDB??>?==;=<<23135677:;=?=>>ALVC;;8789:<<><<:9876979;<<<==@?BBEFHGehADECCGGGHHHMLNOOPOQPPOMKGFB?;9632111333222535433433545333332412-*'!  1B9+%!"#"!     "%)46500123333221101112032222432212338641114277965588785777897669;;<<><;98>@BB@@?>>>><<=@DAA@ACE522234333445655634332223343433311101-+'$#$$ $$"#!! ! ".65D8-        $&*,..////10221102.1010/.///233333445444476877766676889:;;;;;:::9<<<?Z]<>>=:<<<<<;<<@A@>><ACHHL44556666676744555553/.,#%&%&""" ! !!!! !!"!###"!!  #.;0''$ !%10112211000/B[liM412010132312245432324466543679799:89<9;<<=?@?B@@=@??===<;<;<=>=?A=<:;<???B@@4655421.*(&&%"$###"!!      ! !! !!!! #!"!!""" #')**)%! !+../,--.,.1/.--../013222300/0//0300112124689:98889899536:;=<;;;==?>><<=99::::749998:;;<=;;PbQ#" " ! !!!   !#!""!!! !   "  " !       !    " "!  "%***+*+---../122200010125100/.--/0234576863666@;:;:Mu“~Z1=?>?>?@??9><:;:=;==::::;99?>A@@LL<A>> !!!!!    !!"!"          !!!! ! !!!"""!!! !!!!! !   ##    #%'(*+++,-0/0...//022/112210////00121/./0122469:8889:;99898::;=<<;;<=;=<>@@B@?<;>::::9<<BCBCAB9;B!!!! !!!!!!!    !!"  '('% %%''(((+*++,---,*+-,+,+*,...++./00222110000134778988888:::8768877566788:;<>=;:959875328RD8;78:;;>US5b^ZVRPONPTY^acddegkloqnjfdefikprpoligdb``]Y]bfgfglsy~~~}|zz}~€~~€€‚ƒ‚‚‚‚‚‚€€€€€_YTKE?>ADFMTYZXWZ]adgfc_\YYXY]afhfa][ZYVQMLNSUXWV]gnw|~~€€~}{{€ƒƒ‚‚‚‚‚‚ge^QHA>>?EOYdhc[WY`fjieaZWVWZ`bfif`[[^bb`ZVSRTUWYZ[cks|}}|{{|}€€€€€€€‚‚‚€€€nhbXOGDCBBFLU\de`]]bghc^WTTTY`ehhd`]\\]``a`]YTSSUVV[eny{zwsquy}€€~~‚€mje^XTQNJFEGMS\elkgdegf_XUVW[_cgfdc_\]^bcddb^YWY]^\[\clruqifhox~€€€€€€€€€€€€€€€kjib\WVVTPMJKPYclrspopqohb^]_fjkiea\Z[^dghfa\VPPSVWWW[fovumhedfmw}€€€€€€~~~~~€€€€lie_YXXXXZ\\[\_cks{~~|wmf``bfiigd_[[bippnihifaWSRSSRRW_ipoi^SNP\iv|~~€€€€€jhe^XVVXVUVX]_`aflw|~}|ztjdaceggfb`][Z[`cdc^[\^]YUTUVWZ_dhea]YSRT]kt|}~~€€€€}}~€€lhc\YYZZZZ\`eea_agouz}~~zwrlgddeda_][ZZ_aa`_^^``^YVWWWUSX__]]^^adjrw|}~€€€€~~~€€€jgc_[YYYZ^iqvuojhhlpuyyxwwwuphffea][XVX_egebaa``^[XVXVVY\`aba_]adgls{~~~~~~~~~~~€€€€€jfb\ZYZ[[^biotvslkmpuwupkhgffddffc_\\^bgihd`]Z]ac`ZWWY\[[]adffgifeflv}€€€€~}}€€€lif_ZYY[[\aiptvrlkmsy|xtqqqmhcabdea^^_afhhfa`_beedb_]ZXY]^`__bcca`bisz}}}}}~~~}~~€nje^\\[[[[\aiosrmjkouwuolossphbaehd_]^`efeca`bdghhfc^XUTTW]`ccedadjov{~€€€~~}}}~olib^\\]^^^]]bkqrqpqsvsldchmstqmligda`aceda]XVZacbaa`\\[Z\\]afhfbbciovz|}~~€€€€€€€€€€oid`____adecbcejqsuvvvqkb\]bjrvxwtrljgdffda]Z[_ba^]_ba__cirvupllkjebhow{~~~€€~kgc_^]]`gmrqmjoxzwttuvpjdbfhjmsz|||zxqjffeb][_dggdeec__^`cinojc__`^`bfrx|~~~~~€€~~~oke```abgowxvsooqstwxvqib`adhimsw|~}{xsomifcaachgeeccbbabbdhhd^\becabgrx|~€€€~~~}}~kgd`^^_bglruwvutsssuwwsmecefgfhovz{zzwsnifda`abfgggffgeedgjljhhiiigfgksz}~~~€€kgc_^_`chmsuvwzzwuuuwwrmknstpllouyyusnkgffebbbehgeefgeb`cgmpqnoonkgfegmuy~~~~~~€€lgeca``biouvvx{~~{yxxvqliluz|wrsvy{ywsnifeeedcbdecbaabddfkoqonmmjgbdkqwz|~~~~~vrngeeefhmrsrstuuwwxxumga_flrtsrtvvrnmlhdaa`^]]`cedeffeefiklkie`__`ckqy}}}~~~~~}~€€yywsoihhlpsusporvxyyxvohb^bjqvwuuurle`dkpsspkfffffffhgebbdhkkjjklnllrvz}~~~~€€~~~€‚€qx|{xtqoopssrstuuuxzyvojdcdgnsttsspf^Z\gqxwsne```bdeeddegjmlkjkmonmhipx|~~}~~~~~~€hlry{|{zwvtrpqsuwyz{zwrpoonnpsvxvrng`VTYbmstrjebbehjigfefikkigdba`^afmw|~|{{|}}}~~~~mkijnty|{yuqlloswz}|zwrpquyussswxvriaYUX^gllic__aacfihgfinomhb\]`adiouy|}~~~}}~~gikjhhhjortrqpsxz|}|zuqnnrwwwvuvvtspmhhghlpnkfcb`^_aegiilqrmihgfhllmkhiqw}~~}}~~~~€mkkkklmnnnnnorvz|}|{yvqlkmruvwxxwtoieilppojc``dloplgdbcejlllkhjihjlieaelu|~}}}€€€€qrronnpuxyxurrtx|~}{vqmmmqtvwyzxurnllmmmkieabhqy{xpeaabfknqplgdcfjkhb^_hu{}{yy|}}~~nnopppoopruxyxwvxz}}zvpmmnprttuwxwrjfflrsrngb[Zaipojcabdfinolhb_`effc_[Y^jtyxsqrv|}~~~oonmnpppnkkmrvxyyyz{{ytpoppqstvyywtomkijlnmjfbbiproi_]`deioqqoihijhc^[Z[]clswyxxy}~€€~sttttqnlkkhgilptx{~~|ytqopstvz|{zywvutrponmjiilnokgdegkkjmoqqniiklgc`_a^Z[^chklmoty{}~~~ussrqqppmkklmmmpux}~~}{zvtsuw{~~|xvsstw|{wslfbekmjebelsupkhhd`]`fhfcbccaZUY`cedbdlt|~~~}}{vronmjgggjortvy|}|zxvvtstwy|~|zupnpuzzxupmmlmmjebbfjlgfefecbbcdbaadb^XUX]aegefkry~~~€}{vqlihjkmpsvy||ywtttvvvwx{}{xtrqpsxzxupjhhkmjgeghjkjhhjjjffhgeedb^ZWXWWY\`cflry|}~~€€~~~|zvrmjijkmquyzxuqpsvyzzyy{{yuponrwyyvrnklnnlhfgkmkjlrvtne^]^bgigda]\[Z[^^\[_dnvy{{€€~~|xsooqtw|}zvpljloruxz{{zxxvtuxxyxwvvwusqokiihfdfkookaZWZ`figbbcfc__bbdbbfhjkmr€~~€€€€}zxvtuxz|yuqollmmpsw||}{xursyz{yuttuwvqmjlnnkggkonh^YVX^digdddee^\]_abcgjkkkn‚€‚€€€~|{zyzyvqnkjjmnprw}~{xwttxzzxusruxwupkhhjkkjjlkcZVWYZ]`beeege`_aeecbdjjhgk€€€€‚€€€€€€}{yvrnkkkkmosvzzyxwvvvwy{xusswzzxursspooqsroh`][]`bbacdghgb`bfedccehiil€€‚€€€€€€€}|yvpommoqty{yvvwxyz{zzvsrv{{yvssttrrtvvrne`[WUUVZ]`cffhhhe`^_ehhgin€~~€€€~~€€€€€{xvsqrtz|{vokkouy||{{{{}}xsooqtssrturojgd^WSRSVY]bcefb^]^acehlmo€€€€€~€€€€€€€€}{zwvvutpmllmswz|zvtuyzxustuxyyzzxuqmkkhc[STW^dfhhgc`__aegjlnp€€€€€€€€€€‚~~€€}{wsplklmqvz|zyzz||ywvwyz{zz|{wqllnqpidbdgjmkgda^]`gjllikl€€~~~~€€€€€€‚€€€~zwurqrtyzwsqsy|~|{z{{ywwz{xtppqpmkkllmppnkiiiebaeghghm€€€€€€‚€€‚€€€€€€€€‚~~}||}|ywuvxvrnlnuz}|zyyzyyy{|zvsrrrpooqtuvvrkgfhhijkhhikp€€€€‚€€‚€€€€~~~~}zwrmkmtx|zxwx{||{z{yvttuusqpooprvvvusrmkijlmkkl€‚€€€€€€€€€~~}zvsokhkqwxvrsv{{{|~~{vrtutrppoprstuvutqmiedfhjlm€€€‚€€€€€€€€€€€€€}|{{ywutsuyyxvtsuyz{z|~~{vssuvuttvwvttutqomjedefhil€‚‚€€€€€€€‚€~}|{{{zxuuvx}~ztooqtwxwx{|zxvtrqqqsvvwwvuuvvrojffimos€€€€€€~~~€€€€~~~}|{xwwx|}{xvvxywvvwzzvssssssvvwy||{{zyywtniiiggf€€€€€€€€€€€€~~~€€€€€€€€€€€~}|{zzz}~|ywwyzyvuvy||{{zyutuwxxyzyyyxvqmjfb_`dj€€‚ƒ‚‚€€€€€€€€}|zxxz|}{{zz{|zzz{}|xwwxwvuvwzzywwxyyvttrmgc_ad‚€€€€€€€‚‚‚‚€€€€€€€€€€€~}|zzz{~~}zyzz{zwuy||zwwvvvxxzzz{||{ywvutspjdaae~€‚‚€€‚‚€‚€€€€€€€€€€€€}|{zxwx{}~~}}}{yvuy|~}||{xutvvx||zyxyyxuqmjgb`ad€€‚‚‚€€€~~~~|zxwwwz||yyyzywwwz}}|||{zywvuvxz{{yyzzuqmkhedfg€~€‚‚€€€€€‚‚‚€~~}|{zzyy{}{zyyz{zxyz|}||}}}}{zyyyyxxy{||yvrpmjhik~~}}}~~~~~€‚‚€€€€€€€‚‚€~}}}}{xwwx|}}{z{|{{zz|~€~~~~}|{|{|{{{|}zwurnkgdc~}}}}~~}|{|||}~~~~~~~~€€€€‚‚€~}|{{{|||{zxwx{{{{{|}}}~~€~|{}~|{wvuuvslea~~}}}}}~~~~~~~~||{{|}}~~}}}~~~~~€€€€€~~}}~€}|{{|~}|{|}~}}~}}}~~||||{zzxwupia€€ƒƒ‚‚€€€€€€€€€€~}}}}€‚€€€~~~~~~~~€~|{zyzz|}~€€~~~~~~~}zz{zyu‚ƒ„‚€‚ƒƒ€‚€€€€€€€€€€‚~~€~~~€€€€€|zyyyyyy{~~~~~€€€€~}|zxtqni~}}~€€€€€€€€€€€€€€€€€€~~€~~~}}~~|{yxwuvxzzz{}~€€€€€~{xwxwvrl€€€€€€€‚€€€€€€€‚€~~~€~~€€~}|}|||{yx{|~€~~|wqkikmmi€‚‚ƒƒ~€€€€€€€€~~~}€€€‚€€~{ywusstv{}~~~{ytrsstts€€€€€€€€€€€€€€€€}||~€€€€€€€€€€€€€‚€~}zxvvx{}~€}|{xxz{||zvr~€€€€€€€€€€€€€€€€€€€~{zz|}€~~}}}}}~}}}||~~€€€}yvvusrpooppononnmonnmm€€€€€€€€€€€}||{ywutsstuvusrppppoopqtvwwwurpooonnnoqrrrrrqqpoopoo‚€}}}~}~|{zzzzzzxwwxz{||||}}ywuuvurqpoooqrsrppqrrrsrstttttutttwwvuvvvvtttsqppooooyyyxwvuuuuusrrrstuuuuuvvvwyz|zxxz~€~}}~}zvuuuwxxxvuvvuux{yvvxxwwwyzyyy{{xvwvvvrsusqqssqssstuuuvvvwxxxxxyzz{}~€€~|||}€ƒƒƒ‚‚€}}{{z{{{{{||||||||{{{zzzzxxxxyz{zxwwvvwxxwvutuuyy||||}}~€€€€€€€€€€€€€‚~~|}|{{{{||~~~||{zzzz{||{xwvvwxzzzzzyyyyzxvvuuu€€€€~~}}}~~~~{y‚‰†€~ƒ€~~~~€~}}|||{|}~}|}zxz{zz}}yyzyxy{{{|zwxyyxxxwwwv›œž›˜–––˜›žš•Ž•š™˜˜—–”““–—–––—™™–••——–––———”‘Š‡ƒ€€€€‚…‰ˆ‡…ƒ€€€€€€€‚‚€€€€€€€¤¦¥£¡Ÿžž›˜—–••˜›žž››žžœœŸŸœ›š›œœœž Ÿ›•ŽŠ„‚€‚ƒƒ…ˆŠˆ„€€€€€€€€€€€€€€œ £¦¥¤ žš˜˜™™šœžœžžœžš–””˜šš™™›žœ˜”’‘‰‚ƒ†‰ˆ„‚‚€€€€€€€€€€€€€€€€€™¡¤§¨¥¢Ÿžœš—““””•—™šœ››ŸŸœ›››œ˜”’”›œ™–”–™š™–’ŽŠ†‚…†††„ƒ‚€€€€€€€€˜œŸ¢¤¦§¨¨¨§§¥¢™•“”–—––—šœ›˜——˜œžš˜–˜œœ™™™š›ž™—”Œˆ‡‰‹‹‹ˆ„‚€€€€€€€€€€šœŸ¢¤¤¤¤¤¤¥£¡œ—’Œ‹‹‹Ž’•˜˜–•–™Ÿžš–””—™›š™ššœ›š˜—”‘ŽŠŠ‰‹‹‹Š†ƒ€€€€€€€€€€€š ¡¢£££¤¦¥¤ žœ˜‘‹†……†Š”˜—•”•šœžž›™—•–——––˜˜™››››š™–“‘Ž‘’’Š†€€€~›ž ¢¢¢¢¢¤¤£¢¢¢£¡›‘ˆƒƒƒ…‹”“”•šžžœœœœžœœœœš˜—••—™™™—“Œˆ†€~~~€€€€€~~~›žŸ¡£¤££¢ œœ ¢¢Ÿ–ˆ……‡‰‹Œ•šŸ Ÿžœœš™™ššš™šššš››œ›˜–•˜šš˜—–™˜–‘Š…‚€€~™šš ¢¡ š–‘•™œ›—“ŒŠŠŽŒ‹‹Ž–šœœŸ ž›˜˜—–—™›š˜——š›™—••“”•”’’‘‹†€~~~~~~~€€€™›Ÿ ¡  ™–‘ŽŽ”˜š˜“ŒŠ‹”——“““—›œžžž›œœš˜˜™™˜••—š›™•Ž”———–•‹„€€€€€€˜›žŸ  Ÿ›˜•‘‹ŠŽ“••’Œ‹Ž“•”‘‘’–™žœœ››œœš˜˜˜™—–—š›š™—–•”—˜™——–“Œ…€€€€€€€€€€€~˜šŸ¡  Ÿœ˜•‘’•”‘Ž’˜œ›•Ž“—™›œ›œ›œžŸž›˜–––———–˜šœ›™™™™š™˜—•”Œ…~~~~~~~~~™œŸ ¡ ŸŸ›—“‘‘’ŽŽ’˜ž›•Œ‘‘”—˜—˜˜›žœšš›œœœœššš™—••–———•”ŽŠ„~~~~˜›Ÿ ¡ ž›™—–•’ŽŽ’•“‘‘•šŸ Ÿœ—‹‰ˆˆˆ‰‹“™›žœœœ››š˜˜•“ŽŽ‘”•“‘Ž‹‰…€€~~~šœžŸ Ÿžœ—“‘“––’ŽŽ“’”˜››™—’ˆƒƒƒ…‡Œ‘—šžž›šš›››œ›˜•“““”—˜™™—•’Š†–šžŸ¡ ž›–‘‘’””“’’“™œ›››š–Žˆƒƒƒ‡Œ•™œ›š›œœ›››œœš™™˜———™  š’Ž‹‡~~€€€~~~~™œŸ ¡ žœ—”‘‘’‘’’’’‘ŽŽ“˜šš™™œž–‰‰ŠŒ”™œœ››››™˜—–—––——–““•˜œžš—“‘Œ‡‚€~~~—œžŸŸŸš•‘ŽŽŽŒŠŠŒ‘“–”‘‘–š›—‘ŒŒŽ’””–™œœœ››œ›š™™šš›œœš—’“—šš—–““”‰ƒ€€~~~€•˜œŸžš•‘ŽŽ‹Š‹ŽŽŽ“–•’ŒŽ”–“ŽŒ‘“‘“˜š™˜™›œœœœœœ››š˜–••••—™šš˜–“‡‚€€€“—™›œ›™”ŽŽŒ‹Œ‘•“‘Ž’•“Ž–šœš–““’”˜œœ›™˜™ššššš˜–•”•—šœ˜•Ž‡‚‚€€€€€ŠŠ’•˜˜—“ŽŽ‹‹‹Œ’–•“’’‘‘”™œ—‘ŒŠŠ‹Ž’–š›šššœ›™–““•——•“‹‡‚€€€€€€”‹‰‹‘’“‘ŽŽŽŽŒŠŠŠ‹ŒŒŽ“˜™–’Š‹‘“”•˜™™—“ŽŠˆ‰Ž‘•™™™––˜˜™˜˜—————••””’‹†‚€€›—”ŽŒ‰‰Š‹ŽŠ‰‰‹ŒŒ‹‹Œ“——•“’‘‘Ž‘”•–˜™™–ŽŽ‘•™šššššš›š—–”’‘”—˜š›˜•‰ƒ€~~~~~››˜’Œ‰‰ŠŽŠ‡‡‡‰ŠŠŠŽ‘”““”’’•—˜š›™•‘‘’•—˜˜———˜˜—–•“‘‘’“”—–”’Žˆƒ€€€›š™›œ›˜•‘Šˆˆˆ‰‰‰ŠŽ“•”‘Ž‘‘’“•——–•”’’“”–”Ž‘•——–““’’’““’‘‘Œ‡‚€€€€€€˜››ššš™—•””“‘Š‰‰ŠŠŠ‹Ž’”“‘ŽŽ‘’‘‘“•˜—•”•—™™’Œ‰Š’•——”’‘““”•••”’ŽŠ„€~~€€€€~~~““•—™—”‹Š‹ŽŽŒ‹Œ‹Š‰‰Œ‘“’ŽŽŽŽŽ’‘‘’’””—™™–Š†ˆŒ’–—–•“’”–––”“’‘‘ˆ‚‚‚€€˜˜—””–—˜”‘Šˆ‰‰‹‹Š‰‰‰Œ‘“Œ‘‘‘””•˜›œš•‘‘’—™˜—––”’‘’•––•”––˜–”ˆ„„„…†ƒ€€–—™™—•••—™™•ŒŠŠ‹‹ŠˆˆŒŽ‹ŠŠ‹ŒŽ’•—˜˜•””•—š›˜•””•–“‘‘““‘Ž’––•““–—š™•‰†…„„ƒ€€€€€€€‘“’’“•–™ššš™™—’Ž‰†„ƒƒ…‰ŒŽŒŒ‹ŠŠŠ‹‘‘‘’”’’“–˜›˜”“”••ŒŒ‹Š‹ŒŽ’“’‘’”•–”‘Œ‹‹‰…‚‚‰Œ‘“”–˜™šš™———•Œ…ƒƒƒ†‰Œ‹‹ŠŠŠŠ’Ž“•–˜˜———–•’ŽŽ“”““”–™˜˜––——•””””“‘Ž‹‰ˆ†‚€„†ˆ‹“–˜™š››™˜–”‹ˆ‡‰ŒŽŒ‰ˆˆˆ‰‰‰Œ‘Ž‘“““”–˜—’‘“””•”””••–˜™—•””””““’ŽŠ†ƒ‚€‚ƒ„„„‡ŠŽ“•˜˜——–•‘‰ˆŠŒŒŒ‹‹‰ˆ‡‡‰‘ŠŠŠ’–˜—•””•—™™—•”’Œ‰‰Š“•––––•”’’•–”””’ˆ‚€€‚‚‚ƒ„…‡ˆ‹“———”‰ˆ‰Ž’“‘Š‰Š‹‹‹‹ŒŽ’’ŽŒ‹‹‹ŒŽ‘“”“’“”–›š˜˜–’Œˆ‡‰Œ‘”•••––•’’”—™—•”“‘‹„~€‚‚‚‚ƒƒ„†ˆ‹Ž’“‘Š‰ŠŽ”™››—‘Š‰‰‰‰‹‹‹Š‹‹ŒŒ’’’’“–™˜”““”˜šš™˜˜˜˜™™™™—–––••˜—’Œ‡……„€€€€‚‚‚‚‚‚‚…†ˆ‹ŒŒ‹Š‹”—˜™™˜•‹†„„…ŠŽŒŠ‰‰ŒŽŽŽ’“”””–——”’’”—˜–”“”–––––”‘‘““’Ž‹ˆ‡††„‚ƒƒƒ‚‚ƒ…†‰ŠŠ‘•———–—–‘‰††‡‰‹‹‹ˆˆˆ‰Š‹ŠŠŠ‹“––””””‘‘’”˜š˜–’““””•”““‘ŽŒŒŠŠ†‚‚‚ƒ€‚‚‚ƒ„…ˆŒ•˜™˜–•‘‰ˆ‰ŠŒŠŠŠ‹ŒŽŽ‹‰‰‹Ž‘‘“““‘“––——™š˜–”–—˜˜˜–——•“Š‰‰‰‰‡‚‚‚‚‚€‚ƒƒ„„‡Š”•”‘ŽŠˆ‰‘Ž‹ˆ‰‰‰ŠŽŒŒŽŽŽ‘‘’””’‘’“•”’””•”•——–——”•’Ž‹‰‡‚‚‚‚‚‚€€€‚‚‚‚ƒƒƒ…ˆ‰ŒŒŠ‰‰Š•˜—“Ž‰………†‡ˆ‰‰‹ŒŽŒŒŒŽ‘‘‘’“•˜šžœœ›™—••••”“’‘ŒŒˆ‚‚‚‚€€‚‚ƒ‚‚‚ƒ„††‡ˆˆ‹”––”‰‰‰‹‹‰‡‡‰‹ŽŽ‹‹‹ŒŒŽ”””—š›™˜––•”–•–•••“Ž‹‰†‚‚‚€‚‚‚ƒƒƒ‚‚‚ƒ…†‰’•–”“Ž‰‰‰‹‹‰†…†ˆˆˆ‡ˆ‰Š‹‹‹‘‘‘‘’”––•”””””•”•””’‘Šˆ†‚ƒƒ‚‚‚‚‚‚ƒƒ‚‚‚‚‚ƒƒƒ‚‚ƒƒ„†‰‹ŽŽ‹‰‰Ž’”‘‡……†ˆˆ‰‰ŠŠ‰‰Š’“••“ŽŽ“••“‹‰„€‚‚‚ƒ‚‚‚ƒƒƒƒƒƒƒ‚‚ƒ„††…††‡‰Š‹Œ“”“Ž‰ˆˆŠŠ‰ˆˆ‰ˆ‡‡‰‘‘‘“•”’Ž’‘ŽŒŠ‰…‚‚‚‚€€‚‚‚‚‚‚‚‚‚‚ƒ……„„„…†‡‹‘–™—’ŒŠŠŒŠ†……†††ˆ‹ŽŽŽ’“““’‘Ž‹ˆˆ‹’‘Ž‹‹‰‰ˆˆ‡€‚‚€€‚‚‚‚ƒƒ‚‚‚‚‚ƒ……†…ƒƒ…†‰‘”•”ŒŒ‹ˆ‡‡ˆ††‡ŠŒ‹‹‹ŒŽŒ‹ŠŠ‹Œ’’Œ‰‡ˆˆˆ…€‚‚‚‚‚‚‚‚‚‚‚ƒƒ„ƒƒ„„„…„„…†‰‘Šˆˆ‹’Š‰‰‰‡„ƒ„ˆŠŽŽŽŽŽŽŽ‹‹ŽŒŠ‹‹Š‰…‚‚‚‚‚‚‚€€€‚‚‚‚‚‚‚ƒƒ„„…†‡‰‹Ž‹‡†‡Œ‘‹‹ŒŽŠˆ‡‡‰‹ŒŽŽŽŒ‹ŽŒŠŠ‹‹ŠŠŠŠŠ€‚ƒ‚€‚‚‚‚‚ƒƒƒƒ„„…‡‹ŽŽ‰ˆ‰ŒŽŽŒŒŒ‰‰ŠŽ‘ŒŒŒŒŒŽŽ‹‹‹‹‹‹€€€€€€€€‚‚‚‚‚ƒ…ˆ‹‹ˆ……‡‰Š‰ˆˆ‰Œ‰‰‰‹ŒŒŒŒ‹‰ˆˆ‰ŠŒŽŽŽŒ‹‹‹‰€€€€€€€€€€‚ƒƒ‚‚‚‚€€€‚‚ƒ„…ˆ‹‹‰ˆ‡ˆ‰‹‰‡†‡‰‰‡††ˆ‹‹‹Šˆ‡‡‰Š‹ŠŠŠŒŒŒŒ‹‹ˆ€€€€€‚‚‚‚‚€€‚ƒ„†ˆŠŒ‹ŠŠŠ‹Œ‹ˆ‡‡‰‹ˆ††‡Š‹ŒŒ‹‹Š‰‡†………‡‰‹ŒŒŽŒ‹ˆ€€€€€€€€€€€€€€€€€‚ƒ‚‚‚‚ƒ…‡ŠŒ‹‰‡‡‡‡‰‰‡††‡ˆ…„„†ˆ‰‰Š‹‹Œ‹‰ˆ‡‡††‡‡ˆ‰‹ŽŽŒ€€€€€€€€€€€€€€€‚€€€€€€‚ƒƒƒƒƒ…‡ŠŒ‹ˆ‡††ˆ‰ˆ‡††‡‡…ƒƒ„‡ˆ‰‰ŠŠ‹‹Š‰‡‡‡ˆˆ‰‰‰ŠŒŒŒŒŒŒ€€€€€€€€€€€€‚‚ƒ„‡‹‹‰‡†††‰Šˆ††‡‡„ƒ„…ˆ‡†……†ˆˆŠ‰‰ˆ‡‡‡ˆˆˆ‰‹ˆˆ‰‰ŠŠ€ƒ‚€€€€€€€€€€€€‚‚€€€‚‚ƒ……‡ˆŒŽŽ‹ˆ‡‡‡‰‡………‡‰†……††……„„…††‡‡ˆˆ‰‰‰ˆ‡††ˆ‡†……‡ˆ€€€€€‚ƒƒ‚‚‚€€€‚‚‚€€€€€‚„ˆŒŽŒŠ‡†‡ˆ‹Šˆ‡‡ˆ‰ˆ††††††††„„ƒƒ„…††‡‡‡ˆ‰‹ŽŒŠŠ‹‚‚‚€€€€€‚„ƒ‚€€€€€€€„†ˆ‰‰‡………†ˆˆ†……‡‰†……†‡‡……„…………………„„„………‡ŠŠŠŠŒŽ€€€€€€€€€€€€€€€€€ƒƒ‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚ƒ†‡‡…„„„…‡†………†…„„„…‡ˆŠŠ‰‡ˆˆ†………………………‡ˆˆ††‡Š‹‚‚‚€€€€€€€€€‚€€‚ƒ…†…„„„„†…ƒ‚‚ƒƒƒ‚‚‚…†ˆˆˆŠ‹Šˆ‡…„„„„„…†……„„„ˆŠŠ‚ƒƒ‚‚‚‚€€€€€€€€€€€€€€€€€‚‚‚‚ƒƒƒƒ‚‚ƒ„„„ƒƒƒƒƒƒƒ‚ƒ„„…‡ˆˆ‰ˆ…………………„„„„„…††‡‰Š‚€€€‚€€€€€€€€€€€€€€€€€€ƒ‚‚‚‚‚‚ƒƒ‚‚‚ƒƒƒƒ„„…†………†ˆˆ‡…„ƒƒƒƒ„„ƒƒƒ†‰‹ŒŒŒ€€€€€€€€€€€€€€€‚ƒƒ€€€‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„„ƒ„…††…„ƒ‚‚‚‚‚„…†‡ˆ††…€€‚‚ƒ€€€€€€‚ƒ„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚………††„ƒ‚ƒƒƒƒƒ„†ˆ€€‚‚‚€€€€€€€€€€‚‚‚‚‚‚ƒ‚‚‚‚‚‚ƒƒ„„„……„……„ƒƒƒƒƒƒ‚‚‚‚‚ƒ……‡‡‡ˆˆˆˆ‡‡ˆ‰‰‰‰‰‰ˆˆˆˆ‰‚€€€€€€€€€€‚€€‚‚ƒ‚‚‚‚ƒ„„†‡‰‰‰‰‰†††‰ŠŠŠŠŠ‰‰‰ˆˆ‰‰ˆˆˆŠŠŠ‹‹‹Œ‹ŠŠŠŠˆˆ‰‰‰ŠŠ‹‹‚‚‚‚‚‚‚‚ƒƒƒƒƒ………†‡†‡ˆˆ‰ˆ‡„ƒƒƒ†……ˆŽ’““‘ŠŠŠŠŠŠ‰‰‰Š‹ŒŒŒŒ‹‹‹‹‹Š‰ˆˆ‡‡‡‡ˆˆˆˆˆ‰‰ŠŠ‰‰‰‰‰ˆˆ‰‰„†ˆˆ‰‰‰ŠŠŒŽ‘““”••””””“‘‰‡‡‡‡………†ˆˆ…„„…†ˆ‰‰‰‰‰ˆˆˆ‰‡‡ˆ‰‰‡‡ˆˆ††‡‡††††………ˆ‡††‡Š‰‡ˆŠ‰‰‰‰Š““”•—˜˜™—–•”“’Ž‹‰‡…………„ƒƒƒ„„„„ƒƒƒ‚‚‚ƒ…‡††…………………………………††…………†††………††††‡‡†††‡‡ˆˆˆˆˆŒ‹Š‰‡†„‚€€€€€€€€€€€‚ƒ„„‚‚‚€€€€€ƒ„„„…††…„„„……„„„……………………†‡‡†……††‡ˆ‡†…„„„„…‡ˆ‡€€€€€€€€€€€€‚‚‚xty~€‚‚‚‚‚ƒƒ„„……………………ƒ„…„„………†‡‡‡ˆ‡††……„„†‡†††……†††‡‡ˆˆƒ¾½ÂÄÆÅÇÈÇ€®Ò·“«x±rXke\~fd—£nULMEE2:?BDAr¿¿½~@F›˜¡`KLF?FH=;HLN@¼»­jZEIw|}Ë«¼´ÔŊtO1™‡˜™ƒÑÖÕÖ×Ø×ÙÚÛÛÛÝÜÝÜÞÞßÞÝÇwr×ÛÕÙÛÜÝÜÜÞÝÞÞÝÝÝßÞßàßßÞÞÞßÞßßßßßÞßßÞÞßàßßßßÞÞàÞÝÛÛÛÝÞvQFÀ»ÁÎÉÊÇÆÇÇÇ£–Ù¿š”€BŸŠf^zTyf© fZNLB>7CCEI@x¾Å¿²c*J©­‡yS]8=XMD:LJMCŽÅÀŊrPP\Œm¹¢¦ÅªÑ»’b@6}Š‡w¬±­ÞÕÙÙÛÙÚÛÝÜÞÞÞÝÞÞßÞÞÞÛ͛¤æÕÕÙÙÜÛÜÜÝÞÜÞÜÛÞßßàßßààßàáàààààßàÞßÞÞßÞÞÞÞÞßàáßàÞÞÞÞ b3‡·¶º½ÃÄÅÇÇÆÉÈϘ9+V›}Vo^f§ž\FPKD@5DFFG>vµ»¹}SRY¡Š”zaXF3RND8NPOO›ÇÀÏ¢–aRWruŠ—g¶·­ÌǔwLB‡Ž‡¤Ê–¯ÝɔtÒ×ÕÖ×ÙÙÛÛÜÜÝÝÞÛÛÖ¤£ÊØÝÚÜÛÝÝÞÝÝÝÞÝÝÝÞÞßÞÞÝÞÝÞÞßàßßÞßÞàßßÞÞÞÞßÞÞÝÝÞÞßßàßà߅B';Žµ´½¹¼¼ÇÇÈÃÆÉÇÈ«‰¡G.3>?‰^q‚Xˆ`KCFI@1:CFJCz¸³°†==Ay²£tVI<2OKGCQQVR˜Ç¼Ã¼£qCO`t|\²¬½³ÐǔsZI‡”¡Í•°Èi…ÎÕÑÔÖØÙÙÙÚÚÛÛÝÜз¸ËáÚÜÛÝÜÞÝÝÛÝÛÝÜÝÝÞÝÝÞÜÝÝÝßÞàßßßßÞÞÝÞÞßÞÞÜÝÞÝÞÞÝÞÞÞÝÞaB,A‰¯¯®ºº¼ÅÇÈÆÆÆÆÇȧ^‹„?(54bœf{hVTNQLH;DDFH=€»½²¡V4X€~š\O=2GHA5KKPL”Áº½¬¼€LVRprpBE‘½½¸ÐŗlAE|†ÄŒ§¹yœÐÚÕØØÚÙÚÚÚÚÛÜÛܺ¬ÎÜØØÚÛÜÜÝÞÜÝÝÛÚÚÛÜÝÞÝÝÞÞÞßÞÞÞÝÜÝÝÛÜÜÜÝÜÞÜÜÞÝÞßÞÝÝÝÝÝÜe<+Hš¤¦©¨­³¿ÀÿÇÅÅÇÇÇ´cg—O 00=’£ipˆhSEAB7@AEGE‚½¾¹¨iNa¡À’OdP74QJA=GHLIÀºÅ£¹yoQWaVG=J:…®¶¶ÒƉa:QŽ‘†®ºˆÉ©¥ÙÐÕÕØØÙÙ×ː2 ¾Ë™‘ÜÐÑÓ××ÚØÚÛÜÝÝÛÜÚÛÛÛÛÜÜÛÛÜÛÝÜÝÝÜÝÜÞÞÞÝÞÞÝÝÝÝÛÜÜÞÝÝÛÜÜÜ@3'I‡…”•–¢­¯·¼¿ÁÄÆÄÅǽ“E’k0058|¥se‡RY<6:EEDFC”½»¶©lUf—_„W:W2AJQ<BJJLH›Ã¼¾…§a‚DJXT943E²¦·di°zR6O‘ˆ‚¶±ƒÈÓÑÖÖ×ÖЙ2'BNYf£ÓÒÐÖ×Ö××ØÙÙÛÜÛÜÝÞÝÝÜÛÛÝÝÞÝÜÜÜÝÛÜÜÜÜÛÜÜÝÞßÞÝÜÝÜÝÜÜÜÚÚÚÛÚÚA.%Ivmwz|†Œš £®°²½»»ËÅĬYqŠ0$)-H—Œ[d`^=/@@ACG”³¾¹©cVp£}TRi<8>LK>;GHMK¼·Í²¨a}_AQT<.<,&htgi‚²¨yK/L}„³¤…ÑÐÓÓÕÕÕº]R[WRU¡€ÂØÒÔÕ×Ö×ÖØØÛÚÚÚÙÙÛÛÛÛÚÛÚÝÝÝÝÝÜÜÜÝÜÜÜÛÛÙÛÛÜÝÜÝÛÜÛÜÜÝÜÛÛÚÛJ/*Yoimpstutx{‹šŸ €±ÀÉƺtG^'&.9ƒ‰^\feG)411=º¼¼£fVn–`€W=V6@GJ<;KIJL«Â±²Á›SqiKRPA:N=9~—~£ÈòtL$S–„Ëž›Ó¡T(<JIKMJQ¦›¤×ÏÐÓÕ×ÖØØØÙÙÙÙÙÚÛÛÛÜÛÛÛÜÛÛÜÛÛÛÜÛÝÜÜÛÜÛÛÜÛÛÛÛÛÜÛÚÛÚÚÚÜÜÜB3)Yojnnotutttsz‰‘”¨Š¬ÄÂÁ´˜PO4%**3pŽj]hRC*/0=Ž·ÂÁ£dTx«zac;B:=HF?<HJKL¥Ã·–¯`miKSOF>LC<ƒ£Žª¼¶Í›n6$lŠ}¥Æ¨µ]GMCDGFFA<=3N¦²ÐÒÐÓÕÔÖÕ×ØÙÙÙÚÚÚÚÙÚÚÚÚÛÛÜÛÛÛÛÛÚÛÛÜÝÜÛÛÜÛÜÛÛÛÜÛÛÚÛÚÛÛÛÚC,'_qlonmmssuuqssuv|¾±”™¼»¸¼~06, %&8JFCYCC.(2Y6E’a]|®‘uD;8>BOK<@JKGK¬¾°“‡£ˆ¢rHZYLCNF;ƒ»™t½³ºÀÇ¢fJ5~£º·˜P+/3.0120/2j«£§ºÔÕÒÔÕÕÖØØØÙÚÚÙÙÚÚÚÚÚÙÚÛÚÜÛÛÛÛÛÛÚÛÚÛÛÛÛÛÛÛÜÜÛÛÛÛÛÛÚÚÚ:(1lkmmjkjonuuqnnmp^Q˜³¨œ £§°t$*7-& ")5*#" #QsfqV}§‘ˆSM3FFPG:?GLIR°¾¤Zu’LL8D@DEEF;6w¦^o•rŶÂÁ’q<:†‰ƒ´°_{ˆP*1/./022M±³°µ°¶ÆÒÔÕ××Ø×ØÙÙÙÙÚÚÚÚÙÚÚÜÚÛÚÚÚÛÛÛÚÛÛÛÛÚÜÛÛÛÛÛÚÚÚÛÚÚÛÛÛ9$4ninmlkilklomnlok€y>j°°{ E§†K3$'# !2gflPZ‚ª”dŠZGHLE=DHLGX±½Axy<jC?J?5446;z–eP—€¡Ä¶Äº–[69‘‘¨Œ›Œ•18@<51209qŸ®½ºº¸²³ÊÕÒÖ××Ø×ØØÙÚÚÚÚÚÚÚÝÛÜÛÛÛÚÚÙÚÚÛÛÛÜÛÛÛÛÛÛÛÛÜÛÛÚÚÚÛ9#>pckjkkkjjjklmllj‚›†L5‡FhvŠtL8""'# 7{w[kU­’jœnCHHB8@GFAV¯¾Q’‚^z^>PH3HGKFŒŠ|]iv´¶¸ÅÀ‰W7QˆŽƒ¶‘Áy=(,3333mbŽŸ”¦ÈÁ¼½°¯ÊÖÖÖ×ØØÙÙÙØÙÙÙÛÚÛÚÚÛÛÚÚÙÚÚÛÛÛÛÜÜÜÛÚÛÚÚÚÜÛÜÜÚÚÛ0$IuhkmmlkjiijlnmlgcgfnTGL<ƒ“s’“`A/!  !rŠehck™‰x›eIIJ?5@CH=X¹¿‹[¤Ša{UFRM7HGFA”£rUHwq—²±¶Á·€^:H–‰ŒÄ›¦´y9=JF>Fœ}g¥}}wž±»³¸¤×ØÑÔÔ××ØØØÙÙÙÙÙÛÛÚÛÚÛÚÛÜÜÜÜÚÚÛÛÜÜÜÛÛÚÛÚÛÛÛÛÛÛ0%TnglkjjjjjjiklmkjkmlldH"Nowybz‘qE2 !!   %M‡n`cdŠrŸ_IJIC5JKLEc·ºv¦}YGTLBOPMKŸ¯jJI`€t¢È°Ã³K/]”€¾“­·gTY\]b¤k{™^L{n‘²—ŒÅÛÑÓ××Ø×Ø×ØØÙÙÚÛÛÜÚÛÜÛÜÜÜÛÛÛÛÝÝÜÜÜÛÛÜÛÜÝÜÜÛÛÛ)Widijjigjmlkkjlmkj]Q[h`4aXSpxXHpbA5! !  '.,rnN_OkšjPLID?HKL=[·»…k¨—S8DIYRCKJF@œ°}mIQzk‰c¶¯®Ë¼zV>k–{¥Á‰¬Ÿ^[YKDŸµ‡Uwfrx´Õ×ÓÖÖ××ØØØÚÚÛÚÜÛÜÜÛÛÛÛÛÛÛÜÛÜÛÝÛÜÛÜÛÜÜÝÝÝÜÝÜÜ('ahbffjghfgfghhik[2! "13p[L6XmYBJU;.#"03'T^ALQz`NLG;6JJN?j¹²|g¦OD6>LG=NNJM¦µžxKOe{jIˆ°¹»Ê¦}S2t‰ˆ¯°…Ä™\YIG•µqAXŸ¦¸tB5jŒªÊÛÔÔ××ØØÚÙÛÚÜÚÜÜÛÜÛÛÛÛÜÝÜÝÜÜÛÛÛÛÝÜÝÛÛÛÜÚÚÛÜÜ%*bdbcdfddcdcfghghZ>!'$! 8gbI88cbM?L='!  "#-`<&) <[W{“YJJIC9KDH<i¼µy`–‹SF7=ND=PLGVª¾³“?;QhLCLg³¾¬›£zJ-zƒ¸¯™¾‚I7?—œ\ImœªƒAM}–˜Â×ÓÔÖÖØÖØØÙÙÚÚÛÚÜÛÚÚÛÚÛÛÛÜÛÛÜÜÜÜÜÜÜÜÜÛÜÛÛÜÛÛ(0cZ_aadabbbccbbfcx†F)0/!2c[H>)Ha\A6;($""$(2ppc-%* &,Ow–]HKI@>OKOAl½´|Y¥—LA;;OF?QLGR£¸©–_CNXL5??›¹¡Y“£wJ)v…‰±¡ÃsD@ŒuŸpF=b mNQ^˜¡ÕÚÓÔÖÖÖ××ÙÙÙÙÚÚÛÝÜÛÛÚÚÚÚÛÛÜÜÝÝÝÜÜÜÜÛÛÜÜÜÜÜÜ$0hagbabbcbbabcbbaŠ¬xbj[,, .[URV#&MV@0+%##%%'Q~yn?miUjqq‚›T=MJ@6KJOHp¾ºƒ<•dI86MI>GGEIŸ´§³rOOTK8;9?j~\¤¶¥vC1…~»ŸzUGJ’’{6<>5† ‘K<8†—ÃÜÓÕÔÖÕ××Ø×ÙÙÚÚÛÛÚÛÛÚÙÚÚÛÛÝÛÛÜÛÜÜÛÛÛÛÜÛÜÜÜÜ :j_dda]^acc`_bbb]—¥Œz†t +$6bHcKA7.>2%"" #!*=Qur?SjHZuu‰RNQM>6HIKCw¹¯ur¯GT4BKD;GGCJ¤Å°‰ŒUHUN7ID=‚|„½³Ë«v?8‹‰§`8AC†{@Bg?J‘JAD‘«ØÕÓÔÕÖ×ØÙØÙÙØÚÚÛÚÚÚÚÚÚÛÜÛÛÛÛÛÛÜÝÜÜÛÛÛÛÛÜÛÜ$Bdcfeec___abb_^a^“«›{’y+ 5+#$FVHGRH,)%$#"!#%7qQAX1!7gZHqZLJMH:7JDGDwįjz{[V37>MB:CAAJ ªŽ”ŠeCUPBJE@‹‘²¹¸Ì¥pEQ•„Ž]7C@ˆL]…G7[—XCM–šÈÚÓÕÖÖ×ÖÙÙÚÚÚÛÛÜÛÛÛÜÛÛÛÝÜÜÚÚÛÛÜÜÜÝÛÛÜÜÜÜÜÜ"F_\addbba^]^^c``_¤›¢•˜~B(DC!$(VKEST75. # !#$5NsmHB)!*XxVqfQRB86IGGJƒÁ®g‚~MV[:DM@8EE@R¦©ˆŸ\AVN>OHC”•™‹³¹±Ãœu,R’†|69;’‚i‘U*vqy‹K88x•´ÛÒÓÕÖØØØØÙÙÙÚÛÜÛÜÜÜÛÜÝÜÜÜÜÜÜÜÜÛÜÜÜÝÝÜÜÝÜÜ&M[Z[_a_abcb___``f§Ÿš…®g8fb,#=ZGMO@63'#'(++O}K]l?/'!<w]TvRA56FFHM‹Á«evRTVEIQD;HGBYª«Ÿ€8048;<C>:|i—ˆ¿°¶ÇŸ]1d‘~p85ˆ‚Š_T;?‰n7‡q90O‘£ØÖÓÔÕ×ÖÖ×ØØÛÚÚÛÚÛÛÛÛÛÜÛÜÜÛÜÛÛÛÚÛÜÛÛÜÚÛÛÜÛ)STZZ[\[]^_aba_^]`“¦†§„•_sk>7&LG<A::1&%$$'&V|xkO^(+2 3_bY]KB2D@>CŒ¶¤e†ˆOSkCBRB@KKFe«ŸˆzxXSI58EFI‹†W|o¡¶¶¿Ãe*^‘~`"x}•fOE;„l;Q`5m†•ÌÙÑÒÕÖ×Ö×Ö×ØÙÙÚÚÛÛÜÝÛÝÝÝÜÜÛÛÜÝÝÜÜÛÛÜÜÜÜÜÜ/`YWSWYZ[[`aaaa^\YLYŽ‚©ˆ‡}n=G:J=?+:6*("$'(\usxkdcF)9-!#%G`JRZB/+/3x¹¥^‰dkZGHM?@MLHi°¤žŒWISFIWVT“^Zƒƒ´¸´°tH/gŠzPw¤n=KK?vœc*aA<u–¼ÞÔÖÖÖ×××ÙÙÙÚÛÛÜÛÛÛÜÛÜÜÜÛÜÜÜÛÝÜÜÛÜÝÜÜÛÜÜÛ0^Z^]PWY[[\]_``b`Slg6{«†vƒ€2O-!4QCR5:6*($&(*_yoqhkgfO3/!"KnGPdC,,3b©h‘‰m|o8BCCAIGAp®ž®¦^LUILUUN›—JE{yˆ™Á¬¸—2.)[45 *-cS7LsM=4~`8>„–×ÙÑÔÕ××ØÙÙØÙÙÛÜÜÝÝÞÜÜÜÜÝÞÝÞÝÜÜÝÜÝÝÝÜÜÛÜÜ=aW]]]\TUW[\]\^^\MmUsO8U„‹Ž0U8$?CC4C5($%()-d{oobKjidd60"""QE.DLA6e="0u{5BJ?4PPLl²¤¨¬¦[DUKQXZUšSIl~Vl³Áº¯q4%21+,4A‰†`j2E9AqWŽ‡Ò×ÐÔÓÕÕ×ØØÚÚÜÜÜÜÛÚÜÚÛÚÚÛÜÝÜÝÝÝÞÜÜÜÜÜÜÞÝÞ;TX[Z[[]ZVXZ\][[Y?$hNt_JA†ƒ!EU.?:/>6,)'')-i{ortwWFid^M/%!(,!.7|v ŒCMLA9PLFi²©™›KK7RDJQPR™™WN`tEH^¡¼“dv+'**(+3+Nˆ}o!V(]ŒW™—¶ÖÐÒÒÕÕÖ×ØÙØÙÙÙÚÝÜÜÛÛÛÜÜÜÜÞÞÝÝÜÜÜÜÛÜÜÞÝÜH]UWY[ZZZ\[Ya_`_T1""=iNre:;%?^#(->74:1+)***/n{vs2W„a86Ih6&#$  67')Z—FIJ75JKH~±¢¯”bX8^FOQQRŸ—bTPZGLBm­{; -75Zk/‡‚dŽ2MrnŽP–šÍÛÔÕÖ××ÙÙÚÛÚÛÚÜÜÜÜÜÜÜÜÝÞÜÝÜÝÜÛÜÛÝÜÝÝÜÝÞK\VYZWXXX[[\\\^ZT.!#  BPJa:=6r$)/>8484.(('(5mt~vd.‚c.-IZF3"&'M9)&_vBKO85LJAr²£˜•D<5J@EQOK—”tjNUE;;li¢©w(5AA;‚€]6j‡p[5?tU#˜jo­ÜÎÐÓÔÔ××ØÙÛÚÛÚÝÜÜÛÜÛÜÜÜÝÞÞÞÞÞÝÜÞÝÝÝÛÝÛL\ZXYXWUZ^\]]\YYN%*$*$NCMY/]5#*;933.)&&$%6lkmmpiNA;^kLXD;#HM,0/GGF73HF@t°Ž¦–=>3QCFHIQ“—}TT;K]AŠ‘ž¡eD9HB>‚›|S<˜|WSBTkF`œ©‡¦ÙÖÒÕÖØØ×ÙÙÚÚÚÚÛÛÝÜÛÜÜÛÝÝÝÜÜÜÛÛÚÛÝÝÞÝÞÞRTTVVXWXWUYZZZYYI4:!WG7&J<PR2-6350''&%$$7kkjgahdT-+foSD]61%$4d,03NM4.KHAu°—|”NA?PFKMGG¥ƒz@LCJM;…²–tc9;3;6d¦œm‚ŽmBQF\–hYnœ|ÀØÖÔÕÖÖØÙÚÚÜÛÛÛÚÛÛÜÜÚÜÜÝÞÜÞÝÞÝÜÝÝÝÞÝÜÝUV\ZYVUVUXXXX\[ZI%KW2!)gJE'W?]:4D2?7,'(&&&Bg_lgnjid@V^=cDWL6$! !"-)4/!'[RNMJ59JIH·£®”@47PEIMLU›wvCQRKW7ŠŸzzV74:;9nªœo¤yuG<8Nw;>=…™¯ÕÒÓÓÔÖÖ×ØÙÚÛÚÛÛÛÚÛÛÛÝÜÞÛÜÜÜÜÝÞÞàÞÞÜÝÜNNSUVTQTUVTVXURX>(X`,#/`KV ,MAbL092.%'&&%LmcadT!0c_G(WjKAA*" ##DvH(+/ArnJSR<AMMH„¶žoHjB=QBIHDX¢•]Z?B/::-kL[L8#+00>Šžv{¤l:GiVHŠ;7–‚•ÕÜÓÓÖÖØ×ÙØÚÚÛÚÛÚÛÝÜÛÜÜÜÝÛÜÛÜÜÝÝÞÛÜÝÞÝa\STSTSVXUUUUVUSA8__.#<jPD"!  2A9831($!#$%Ec`iW&$ &`\L,-hN3,$##"%G}oBJm=UWLBH9EMNEƒ·ƒP*7DODLQHT£˜y?L6b^N‰¡nRI) %/B`VOŠ9 42pa…_1Šg ˆÉÛÒÕÓÖÖØØÙÙÚÚÛÛÚÚÙÙÚÛÛÛÛÛÛÜÜÛÛÛÛÛÝÞÞß[S_cVTVVXWYWUWVUA=e\*7j@qQ&'714-)&%$&$Jn`^yW]+ %YZSN%8B,""#!.KuP3pJTnXJ3:JLDxµŸ@+;IXJJQNQª§wAU8MPF€”S\E)1=cYoF(6=>;–qH6Išy„ÃÕÕÑÔÖØÖØØÙÙÚÚÛÛÜÜÜÜÛÚÛÜÝÜÞÞÝÞÜÞÝÝÝÝÝÝ?LSVZ]VQSTVVXUTO?CgX&"CR6nY#&,618+%#&$%$Nha_“pˆ;"!&VIFJ;!#"$#'EpA\/&`aYrX=CKMC‚µ—ƒWo8PZGGPMR«³¡z<QBOPJ˜V_P5"1>kaG,,31G_J’XH=•ºÐÎÑÔÕ×Ö××ØØÙÙÙÚÚÛÛÜÝÝÜÜÜÜÜÞßÞÝÝÝÝÝÜÞÞÞÝ=<:IVVZ]VPRSUVVPDFfY#@Q2s]2(FD %+:24-*&&%$'Mb]_”’r’=1!#4YASH6) *AW…V8*5uad^:563P£œy`‡D:JEHKFJ£ªfZ?NHTUJt”YUU<.:O?lrq72>>m•_jr@H0ƒÅÑÑÑÔÕÖ×ÙÙÙÙÚØÙÙÛÚÛÛÝÜÞÜÝÝÝÞÜÜÝÞÜÝÞÝÛÛÛÝ8F@><@V\\]IIUUTKBLhN!$5<AyS:8QV%#0;,2,)&&%''Rb\Z‰œ“”X*S6%(JNPE<1##%(]jDrWFb%!/ƒ„UqI)(K£“‡kCIL<EHAJ¥§bA9NENSEo^YW@4S_:gt|G@A@[¡x€rCCHžÖÓÐÔÓÖÖ×ÙÙÚÜÛÜÛÜÛÛÛÛÜÜÜÜÜÝÝÜÜÜÜÜÜÜÚÛÛÜÞ1MCB??UZTTOOPLDMjK#)PH<~K??UK%)3;.7+)'&%$(R`^XŽš~²vViD(4V<=67#&(*apy~—§rzB%bX~s7FŒKHk‡YQG<HKII ®l61R<LL?tžeTR@7Qd8lsq[`^DRsT…POR„€ÇÖÒÕÔØÖ××ØÚÛÛÛÛÛÜÝÞÝÝÝÝÝÞÝÞÝÝÝÝÝÞÞÝÝÝÝÞ ! *LGC;>EQPPLABVh@ *[XI…ECF^D&-4*3+*"##$*SYX_—“¥u}yKB&FH?99#(('+fqhj›Ã°] -%4)" "#`glICE>GJDL¦¥^<7NJMPF{§pWYC2R]7j{q>DCC]ˆsƒ(&8S€›ØÔÑÑÔÔ××ØÙÚÙÛÚÚÛÝÜÜÞÞÝÛÜÜÝÞÞÞÝÝÜÛÝÜÜÜÜÜ"  #=A@B>DQIGEYlC-bLW}GMJ`E$1604*(&$%$-[]Z[[;›y}TN <G<>6")*)0gtvb£Ä¡V0$  " (@…ipUILDX\ZV¯¡aK:ODJNDw”P@C=3T`8gqs5024b;'@DBƒ¡ÝÒÓÕÔÕ×ØÙÙÙÙÚÚÛÜÝÝÝÜÛÝÜÜÝÝÝÝÞÝÞÞÝßÝÝÞÝÝ9&"!  ! 1<;98:@AYd1!.`BZzIMOb>"*65-2*)'%%$1ZWYYQYSEvyFT50F0@6*..04rzl¹„Aƒc9$#""!""#%CmqD9DLHU«˜\FBNBLL=r¢bKM10O]6g{p<7=+FU.8:<FJ™ÐÔÎÒÓÖÖØÚÛÚÚÙÚÜÜÜÜÛÜÜÛÛÜÜÝÞÞÞÝÜÛÜÝÞÝÝÝÜF<2("  *7@>A@>`d92a;bqJMQ_=(10+1*(%#%#/]YYG1RScMIZ;U4+;2=6-0//4n|p`zŠlœŒ€9" " ! 20(Cv‡u@GLKZ¥ŠNL?UBLMA}«hJT84MZ8g}rBmg=XM6A<N…Jx©ÖÒÐÔÕ×Ö××ØÙÚÛÚÜÛÝÜÜÜÜÜÜÝÜÝÝÝÝÜÝÞÞÞßßßßÞKJGB:)%"  !"$-9B<?A-#5];mkNLU`5&0/,-(%##$#0XVZG#8TbjV/HJ(4.=2+)((2ors®•^p¸™£—I !$(VrS!5t~[FKOM[¢Œ3.?HAIJ?§gBN+.HW8f‚n^žsIlc;@5J‰…£ÒÕÑÔ×ÖØØÙØÙÙÛÚÜÜÝÝÜÝÝÝÝÝÝÝÞÞßÞÞÞÝÝÝÝÝÜÜKLKIHA</(!!! !&+760";Z9q]OGW_0'2*/+'$#"##5bSWA  ";Q[WJB(92<-%(&(7jguº«s¡¬­–•F''0}s{xCUXD:LPLX¦Œ>.BEAGME€ŸVDM45GU;h‡xc©‚MalKVFNƒl—º¥¸ÌØÕÕ×ÙÙÙÚÚÚÚÚÛÛÛÜÝÜÜÜÝÝÝÞÞÞÞÜÞÜÝÝÞÞÝÝMONNLJHFA8("  !"&'$A[=kZWOa^'"*0(,*&&#$#"AbWX># ,.<K\I.(63>.(''&@peni^jªŒi®•M+.;”°viYnT=DIH^«Œuq;I@JJ@€›SDN14IT;d†xf›H?Yl?PEJya$,N™¾ÓÎÐÒÔÖÖÖØØÚÚÛÛÜÜÝÛÜÛÜÜÝÝÝÝÜÜÜÝÜÜÜÜÜ-@MNOMLLJGB=/&! 1L7&&HYDt\YUd\#*1+.+'#""#"C[TX??=&QK,'COME7.B1*,**?uh^=17bš’‚WK.%'(-/}¦i4ftb|T:<=P£zx8I6@F<{œL3J6/AP8WxZ‡D8Tp&24.c808<S€Ð×ÐÒÓÕÕ××ØØÚÚÚÚÜÝÜÜÜÜÜÝÝÝÜÜÜÝÞÝÞÞÝÞJ8/7EOMOMKMKHC<QYb?)IREn[XShS %)/))'&$#"#"C_VS?QK +SH1+9>H9:,)'''CsdhB3*n ]-./*292†¥‰m?qoa;+4‡’{5H;INF{U:L617;8[€zXŒI>NhAk0O69*gSˆ¦ÖÑÒÑÖÖØ×ÙØÙÚÛÚÛÛÜÜÝÝÝÝÝÝÜÜÜÛÜÜÜÝÜÜRQN@3-6FNNPNPOJHLO?1&<GPg][WpT&*-(*&%$$##$I\VUF\I$*[G.#! ):44&(((&Fw_fŽF>$0j‰o?2 $)*<¤•ƒy+ v‡twJ6˜ž{k6G<PUN¥W6I75978V‚€Q‡[@Xo\8La4A8‡{V…ÉÕÒÓÕÖÖ××ØÙÙÙÚÚÚÛÜÜÜÜÜÝÜÞÞÞÝÞÝÜÜÞÞÝLLLNM@6)0=LRQP>$6BPTGE=B_`X[nO$()',%%##$"%HTPSJaE (fI(%,# &225+(((&Fobgœ_U4)D›u>9(&).C—£°¥xC)==&( #"LvHIATQ>{œO1B10359TyyQ†eCUn‡ FLkH\@Š®¬¥Ô×ÒÕÖØÖØØÚÙÛÚÚÛÜÛÛÚÚÜÜÜÝÜÝÛÛÜÝÜÝÜÝÜ/>FGJLKK<*)1:D83I\VQCAcPWqL&+*''%$#"!!$ERNMKgB"-S@21N@$*306&&&'&IoZh®‹]J.1o:?0/6<Bš²³Á£W !%qzga?NQIv›P:E0/125CwvO}qH[q‡<JtAP=‡£Œ»¢Õ×ÓÖÖØ×ÙÙÙÙÙÎÉÚ×ØÚÛÜÜÚÜÛÛÛÜÝÞÜÝÜÜÜ4"%6GHGFGI?6'#( (DVSOLMWm@*.+&($#"!" $HNONPnD!.OD4=W?$/;34#&%&&Nn\gµ´vQ0'^e5<(13:F ¼›†v+$!!!Aw€ukFK<u™V;A,-.48LvwOxrETquu0Ao04*O‹–®†¿ÖÏÕÔ×ØØ××¼^@hÃÒÏÑÔÕÖÖÖØØÙÚÚÛÚÛÛÜM.')+5CFFGFF;*3/&!! ;ORB?L2&*)(*"#!!"!%NPNITl> /LF?EY<#-519$##"#LlYm»«•ƒ?.FF7E404:B ²˜™ƒ¦‹B ,[.!l†iHO>qžZ?C-+,9=Nx{N}mDMrzy:It357R\}“¤£ªÛÖÔÔ×Ö××ǐ`dQ¦ÒÐÑÑÕÖÖ××ØÙÙÚÚÚÛÛÛJ(AMH8&!-<CBDDCNJG6+"&6:?<5-+)'+#"! ! (NPQIVk=!0O<=Hc>-524###!!OiZYr‡qJ<:94;,.35MŸµ†W“³ 9#!Riuf=V=@HAz¥j@E(++<@MvuIss>Fwv†AJv?9Ao^B^‹Œ³¹ÒÒÔÕÖÖبc^df¯Ò×ÒÕØ×ØØÙÙÙÛÛÛÛÛÛÚF)HNOQN?0##+<<>MKOPN?,!*5644.((&!   'NKQJ_f52P:?Nc:!0423#&&%#]p[U^axb\FD717.123H¡° |žšÀ§{5($`¦rxc\<D:w§f:C/.'48DkkM}tC?pn‰@GvTc@‚•yD¥©®µ×ÔÒÕÓ²pMVdyÅØÐÒÕÖ×Ø×ÙØÚÙÙÙÚÚÚ&)CJKNONL? *!%:RNRQPOKJ9*! %19:71'!!  /VQMAbe/4F9?Rf4-102')('&dl_6&H`_\L7745*/0.Uª¨SW›zhlK'#H‘gD‘†|n$"T•g9?*/*77OqqNyU=Dws†?O~e…1‡£µƒAˆ—´¦¤ÃßÔÔÕ¯kPmk›ÁÛÔÕ×ÙÙÚÚÚÚÚÚÚÛÛÛÜ4%$,9INNM:,JA:.2?JOOPOOOHA0"&17@8%"!  #;IKGfc/!;A<CYe/ .00)%''%'_fb8->K\]R@89+.//JžžJ#nž}=-1.4/[¨“_#[~it;XŸvB:(*)47IqwNrV,?mr…0As]…5‹©Ë¾m@‚Ž­–ÇÙÓÔÔºsX¡d·ÚÔÓÕ×ÖÙØØÚÚÛÚÛÛÛÛÜFC0.)$+<E23LBFRC:,4?OTSRMMIG8( ))$#  9UKEem.CJ:?`h/ *,,,''($$]fY7:B#>NTA26&-/->xsE.0~T0%)0.`¢˜{W".A,-!&'kj3#&+/GtwPpc8Cld‰7@p_Œ%‚’µÊ±rA”Š­¢·‹]LDXZ™c’ou¥ÌÓÏÓÔÖ×ØØØÙÚÚÜÛSI#5A=4&%#1C=BLLOO>1-9IPOPNLHD:)#  *AIIIAI@D\b-!)*)&$$%#%ZbZ6FO%!#-530*--,LzTPN$X›Z6)/82q±­œA!*>€{j/,*3y‰Ceg:Eod„0@mW€;ƒ€™µ¤bR–˜«ª„U^Y`Z™i€yœg¹ÓÍÑÒÕÕÖÖØØØÚÚÛ4GSQJIGD@1'%*1;JKOPOMA+)8FNNKF?9*$  %;GM'ECAAcc)',(%"$$#%W\S0PT$$!+/.+++*CuuxR9=„U?51<9n³¤‹j+!!&&MŽ€sA,72iŽXgp4AudŠ3=oT~;ˆHƒ§½«U<›¥­œzSX[GaQ~o zœÚÑÒÓÖÕ×ÖØØÙÙÚÚ&)/AYUNAA@?;YTE!?WLOOQN9$'9DJHD71)&$! "5%D7<9ec"$&*'(%%$"%W[P/WP.?'%*0/('*+Kdd‹T?,h;04.43m¸‹g¯d&# 3g&3ˆQEHF>x’hsq<Asc-:vW/qˆAW³ÀÁ˜Zkœ¡‹˜Z9F?[]‡tªŒ‹ÚÖÒÔÖ×ØÙÙÙÙÜÛÛ !$(,3=[THGE;SWUT7&?NPOLIG("+7>9-+&"" !":D5$!4G($9DA@fN"&*))'$$$"(\VO+QA<Q+),.+)'%'G\b«Ž@"3$,'46/l¦QY¤’w(4js†d1AB3n¶€}ƒ:/ok‘7=x`Žj’M=…º½Ã¥E‚—²«œ<0G@QPBR£“ÕÙÑÖÕÙÙÚÚÙÛÚÚÛ %'/3?\^:GNPTUTJ.%?FHIJH:)%)+)(& ""%FNOI1HZQQC6:<`V"(()'&$$&daT/JEFW/(*'$'&'O[bªŒL13-/+372r­t‹–¿7"6>vr®lcA$%Lž—uŒE0uh‰>Bsar8k•QAkp{–sŸJ‰›®¦M`cSt]–™ÒÙÑÕÖØØØÙÚÙÚÙÚ      ! '-/2F`cOPPOQRRP(->HGFDA6%!"##"#"#(UZWO, ,JPMA=bD!)++- #""*YRN+!RGRT3)--'''((Qh[‹›g@=141:;7¥qšš]*)(22[“W„rgO29W¬Ÿ‘=vk6:j\g;wG/ixC¥ Ç†>ª¡¨‹}dcT|u•t ÆØÑÕ××Ø×ÙÚØÚÚÛ   !"$).1FbjOMNNQSSA$(C@@;73& !    %@SS3   CLGC-$&&(#"$"*\VL(YJMW-'/.)('%#UuRLcwsE-7):91m¥ab‹\/'*/]¡o6 !nxh3+bo‹D1nZa:oŽQPzy,‚¨ÑʐZ²«­ž@TNƒiysoÎÕÓÕ××××ØØÚØÙÛ!!  "/15VheQJKMNMK;#-842-( "'G=%-><2*C<90-%&###""'XVF'&[GUK*&+." ""!RmNLq…90004.^›[({…P*.8<u’T"'}lVR‹‘@5o_i4fXQur7Ku¢½Âxe˜¬½dSS~ppbšÊØÑÔÕ××ØÙÚÛÛÛ   ! $08<Ph_PHIHHEB2!"$$""""#,NQRG4LEA3&!078:- ""# /[MC##]DYG"(*,('%#!ZaE<K+B7+-00-`}N4[zE6.:Cx†fj!!$ 9b$H|dgm¨•H1o`i6fVUqs8B^]ˆ§[Y¦œ_LKkkZqzg³ÐÓÓÓÕÕÖÖØÙÙÙ # !!!%'59=L`^P<?A@:*   !  &=OQPQNKJGF>*"#!  +:4?)  ">PB&#\IdF%'**%#""!OdesowXA1.12._€ZA6`15->BuŽˆ´K'()g‡sO=}b{® I=ubj8d–UHgs3<Z`\žÇ¯^‚¦WPJhcP]krtZgg]ku‰„¼Ó×   "!##$)&4>=FhaN980+&  !! 0J4*=/8ITSQMIE9+!*!!"6C@+"KFbK)%),)%###=Y?#%%&72.12.Sr}R$2+:5E:q•·t&'*,b¬Œw^$qot‹:+aaZBa—^E_tCH]m9BŠ»©R[¢]A]k\hyˆ ~™‹­‹±¦—ÈÒÜ $$%$#%1:;H`cK" $#"!"0LNKK[H2!1LROKGD@(!"  &CB>EC\Q "&((#!!#*`5:JV1$2/+(+(Ni€A)622+1+x¤“s"$(*Z¤¾À…y3T‚jc)r[ISi9XwIQdi<UŠ–Š¤Q€–CTk_e_‘w±–¡‚‘Š“ªß  #'%&&3;@HagI"!7KIIGIOON>*';HFD@9+ ?HE`L#&%%$#$&&Op5BE,(0-#(*(Wnz5840(.1x}lz**$,//j±°·ÒšL9{hW“Y=Ec9QsIS^iAX{bº¿[I+/1iYaur~Ymskx|„‘«¼Ý"#$$''0;>FbeH6IBD8&8JKMNK0$*9;8+!" )+ 7JA<\>%(&!$"#%;=8ERY.&,-#&&$]cH~Z11/6-n€QR-$&572mª´¾§Ï¬y9+w~f2O•h@VtGKag<@€Iyª£L342>Z™‰£È••«Œ¢¦˜µ½Ý "$&&'&.@CH^n]KILNF6&>OJJHF-%-,&%"  !!5L@+*QACU@%()&%$%"FP8FQ[-",-%#%$Rk;*YX8/.70c^)92)%565j¬ºŠ·³¶Ò‘r9\s[38o]BMyGBYn<K{AR–¡}I9Ld]©x¨yÁ¨°‹•“–˜Ó #$#%%('@CF^i\LJKMJ.";ABBA3%$$ !!!!:VL3 AO=8*/+'$#"&IT>JXc/",)&#%#RfQ/(31040_e7<*&*641i¯§¿~x¿­Å°„c>‘bn1\‚JV|JHYm9Fq;DweŒ8?7o`rGrƒlh]tdp}p•ŸÕ$%&%(*@EI_naMHJG=.->?;:3$ ,K<* *>995""!&PM;CQ\&")('%&%VaUI')),+*de94/%)52.bŒy’N3i¾Å½Š`0‹—Y‚¡hZ‚@=Sk>Cw>;iMe?PIjSbK¢z³§Šº™À–³ÂÖ!%&(*;DCap_DCDB>(%/.)"!  "AW;$IA2# />5%  &?7HQX' ('%#$"RbNR#)(')+_‚f(1!+0+R„tP"@n_´Ê¿Îm/cˆ„­jSy4>Th4BwDGuK{RCEaUslV'›«šŒµ˜–²ˆ¡–Ñ #%'))7DK_odE@B;2  9]WRRNHF7.!   53AL^&')(#"$#N]JX%!('()(dfL3(&$--)LtjH(D+f‚€«·¿¶rF?otV€/BDc8:pHBwIfTNG|c]Roi_wfgwguˆ… $&'(3IKWqo;)*&   <"43/LFOGE:+ )=Z &&%QUQ](()%%(&ZS:D!$ -+'P|lK?6J~¢i€‘¸ÄZ.‚wrrG@IhBM€FEhDqgIHwvh_c‹u¦·†¸ŸŒÄ›¡ÑÌ#%()+48CZidD(! "%GUGG>.5BLGA6(%!8V$"'$#!""LVT]"")&$#&P_,#(%!+,(M}kUA6J†=;t¨·¸”o?v|hI:Ah?@nK<jFlfFElgqŒaƒƒ©À‚²´‹Ä¡ ÅÁ#%'(+3=E^ggL'$IUPKNOC711;3-) #<2.A?F% '%"""#KUO[%'%$#$LX($#!,*%E{jW/.$€¨„6d]ˆ¹±¼¬lEcuF93kA<XL?pVbk::_aw…Yrpxfsk]scfrŸ!$)+,2;FYifMJML835DJMB4.+*! $KB.#4?>0&$!"HVKZ' %$"$"L_9&! &%&F}oZ#+ hžs[{2g€~°­±“::I36iC:`Q=qV[nCEpubg~u†—}”Ÿ«¡“»Â "(),/=F_imeOMI13<FMH9%!"  1E8%  "-;4&"! @WN]&)%$$$M^9 )"!''&I|n[)( D‚dk\-e{SBgtv"),+0d?6]S9vZ^h<Ihy^fx yš´€›­¯¨¼¼#%*-0>GXltcM>=/-8:3  ";74H?'!'#CJV$!(%##&L[>&!!""$>peY/) 8nPC-G~@^pr`@7Y7-XT=qZRg7?cv[lq§vsnqqinnj{q$(+.0<H[jmcP>5$!!  !!AKKONJ?+#4<!!%%"$$IW?#  !:kaT1,%9mH7-JmE[2jV$10&OI/WU<q`Rb1:Yxhpt½°t‘u‰™|¤ ‰«°""$$%*/376BdkbF("!'=276?EF<%-7#$'%##$O];' Ao_Q1*&DnN2)4rnW6JW"1H78**ZT4lWCk=;X„lr¸Ï´–“Ɖ«®Œ±À!(IF$1#'***2=Jfs_H)*UOQLA21;+!!@>,9B7)%!!#HTC %! # :obN-'$BkO.%*XP4&9qa)I!!);Q8jWKo@;T[}t†‘¾‘{|jxqwvl)9$$!"%*.:IatkMT@::CKJ:*!!! "@H#.;0#!4MF">o[N)%!;gO-+2[P2%Ra1Y-A<9N'o\KsB<E„Wut«s§ rzˆx…—~”—#!  !!#&**3C[mmaN>16C:)#  04CA% # =B''!!! ?l^M$#3cG6--\T(!ItZ!/X/1:#W^ApE6F|Ecp»¾–¶•ƒ¸€—¹„Ÿ¯/1"$"   !!!"$')4?O‹sLH1," !FRUSK3(*!";paR')1_G7-0\[( Ct\#,S&"/K$8Zd{Ry18JuBYU°Åƒ~vˆp{vr!   $$#"! #'(&,CEC@-#!:9/1=6&0.0?0"6f[L+(5nJ/)*VW*%Ju[(S*&4T*KS3\q=DCwA][¡Ä¢wrj}ww†|„Ž%&"#""!!"  (5<9=,! #QVRO2-!!<G#))%DXO%*6dK,'%OU+)DqZ%Q($.M!%<.&IPUBECu>ZTx|²›©†±‹“²Œ„¸& &(##! Fc< %OK;<HI.(8:)$@8.17cJ/'+XS*$7rW (H* 0Q"$MK.eB!&5/e<YS|]‰ŒŒ‘…¤®v{Œ!$#!%2.0)JnI+(! "PQQNB1(! 4SHB.  LT,*ZN+*'TY# 4oe30D)+J&%H?*E. -)'SFVM‘|ŒŠŽŽ…¥Éˆux! ! !  !4>)+?YG!!$JKMNID017./)"+L$8 $0;UK$&&W_!"-VM,*E.!+K&!?78F//; "=H@‡‹ˆƒˆ‹Š•¡³«¼   .H4,)(''-"  "ED?X;>1"!!!?QEF)!8/WI:# 1FD?$JU*('G]?,$J(#@@1D6+D -'3>g¢Ÿš‘Š€°“¦ƒ¥  $.8C4--0+5C"  #LD5N  #  !:N:2+%'K-EHG@F5!-CDKW&"0ZR" A,&F,!;A4?20H(FN+*G€¡©†’Š}¢Ç†jd      4sO*..(8E"!'H@I\(- !'INJB*  #E49!)(AJ#.NG)+.fT$!>+"'B,">>"933G&,K[V 3L”°‰™”¨Øšt¿!!   !      '9'##&+#<G##A8FU   #@JF?0-E9(&S^PI+ JE&WQ-";+%C)"<=(>,2O*U54X7q®¸‡fxÆ¤w¹"#'.5AESTR7) !!!! '/(! !+0" #A<7F-6%"9?:0-EK1&!$$GIDLG/WR"!@,&<(#6<)64/I!)L>%Ia—ŽŸ‹šÍdqec#,5=BDFJLJ>>6'&$$#!    #,&"" !! "  "@;4E;B%  2<?-  ,U:*'$"%)<;$8jSG, L-D#%E2$5;<<%G(<9,CŒ’Š¡¼š©ƒˆh‘.;@CFNNKIJHH>5*'%$####%    ! !   !#  &B;8C>B&! 9>>.  )LJ6)!HIJ*"#%$8:9?.%#E+%C4$7@$9DJM(D@*&9‰‹‹‹‘¬µ”ƒ¤9BJLPQOBCFIIFA6""!! !!##"$!" !!!        !  !%;/GHE@$!!:=93+!'@986"*J5'."'+1< #:38.#8+#37!20+='H:,'e…‰‹ˆˆŽ’”¼¦u}9@AJLKI=;CJJIE>&!#$#%$%##"""!!" !    !   #"!! ""! #:6:J?H$"3B;8,(9>2@JF4(3FD;!+3'<9&( 3?'+(7##<L37Qƒ}„‰€ˆŠ’¬Ê»d39EOQSU[\]]\ULB3&&%&&&$"$""!!"!"!      !!  !  !    !$CF,! "  !"  #91BBEF% "9:;<.&K65!9>93$J?='#() +!%6:$2*#4!&>I;5\|ƒ‡‡‚Š‰›Ò·‹28GNNTU]]^^]VMD6(%%$$#"##""!"!   !!"!!   !!!! !  %'+'&"   "!(- #92;=JA   39:9.'33-78(+8:7*2#4 +< 2(;.)8>%%;F3?Xƒ€„”†‡‹™É»w;=<>>CLU[[]]XRF<'!######$$$#""#""!""""!! !!    !!       ! "$(-7G;+!" !%>*  !>32=DD$>=6:3 03(">6%3=57FA%1I&(&#.-%728-2Q.=Mvuœ…„ƒººsBIJD;99BQXZ[YMF:+$$#$#"""#"#"#""!!   #!""!  !"!!        !! !!   #+16DcmW3.*#$"8F( $C/98D;$ !74283 "52$+(%#&4(!.<)&#!9.)22O-:O€omƒƒ‹†´¹ƒGPTPJE4.6ENRTQF;+&&#$$$##! !""###""!!""###"!!!!"!   !###!!  ! !"!!     "!!!  #%&+*#%(%.1"#A./:GG$" /45>6!<;*=?/@$$9<!*4""43!*($"# *@84GgV{‰‡y‚‰†¹¶‹FORURI=423=IJM>6(##$$$%#"!"!###"! ! !!""##""!! !!!!!"!!!!   !  ""!"  !""#"! !!"&'$%$'%!!<24<J@$3:892!#(+ %-;A#)38;(;!*-!)?=6,=z‰{‡‰²ÀtBMQVTM@6-/3<@A@4'""""#$')-476/"#!!!!!"#!"!"!!! !! !!!"!!!!    !"""!   !"!!  !#$)% #$!+1&!!:05BE* 34-74"",1,&, 7#'(!%(+))E'1)##KF%$Kg;:cc‘†¦¼q>JRUTKC7.,167883'$""##'')*-/0.(%"!!!%'(*($#"           !!!!   !   !!!   ;qdK50)%!"7185$# !765=* +1" ,.:#$*'%"4*7 8+DNEQ(##Y…my‰•ºu=GMPOH?3('),.//,'"!!!"$')*,--07;DEJLLNL@70*(&%'+/0,#!!!!!"!"""!!!!   !    )'%"!#)(  !54<7-*41* 74.38 !'4!$%"#("$6-$BD?N9!\Œ‚œ~‰¼q6=DFF?6,%&'(()&&$#""""#)()**+,/0588988877:9:864..0000*%%&$$%$&##"#$&$" !!   (%! !"#!1-24.,! ,1-%&** !!#3  #!$&&+)# 9:JS; :Pˆ”©—’t/67992+$#"$$$%%#&)29??@@;:7445634202112468EB;:3-.+.43678>?ABJICB1/,/.-+,,+*% #4,18(& 32-,%!'/)  $% ")7#"#%)",%!;*%1?'=„wL‰‘ž$%'')&#  """""""!!$%)++0112447;99:765343142++)*)+,.6376331256689600698655671)$!!   #;--0-.+#*,;63.$''#%"#!$(%$$3+&*19yg>(^€ž!!    !"""! !!"   !  !!  !!""#%'('('+12.,)+.5378:;:7344665620/12568886531.*! *#3&10&,*((JTH1#+>>6% ,"(2 " #% " -'%'65(!04.*"$I"##$$$##"#$#%#$$$#"" !!!%()'" !!       "#%(*+-1344661299<;=<;961/.,$! !#'*% +!.%/.#('('*,9H.$#2=:);V=!%+# ""!!,$#&J ;YD.:&.!   !  !!!!  !#$%%$#$$$#""$$###$%$$#"! !!   "%++'&#! $&*-23443'# "  "#!"+$ *'()')'#!((,9+#"&'2N2  (%$!  *#":8‚inwypR        ! !!!         !!#%$$##$$%""##%$$$%%'%%$!!!!     !$$!!#$%%$%&&.! *-*+  !%.C9942/PNRYTLMTW*$0"' )# ##!**$(P 1OScc}|€     !! !!"!""""!"$$&%%$%%&(('$%(')'### !,-! !"""! !'$+ZUI1,+@14)1!$.=&!!!%#"(+7.,46!#1;3P]o       ""##%$" &3.$ ## ""'5_wG* ETk-+,0A; "$  HaM/+kk^G74G*9/'   !!"!  !!!     +;7! !")$&!(/\u>0(G(,$(?<8<KoZ' # "T~ˆU@Q]k7#8]@s    !    !!   !       ! !!!      ! !#"#!  !"#   !   "&(%"  +20! %"#@M1( B# -026((,F:! !!! GeDRFeS#$2,0=I*.!!                !!    !!!!!      !!!""!#!! #%$ *,"QSE<MP%9j^_aR("2- 2I%));6*5?@=N0'' !       !        !!!  !"!""#"###"!!!! +/$"#     !;[E;%+glN9/**$! '0 .*+,4bDX%+!!          !!!!      ! !!!! !"""###"$$# !! &+#  "69SS]J[2  1-")E((!*&/E!%GN:73P392GV !!      !              !    "!"!"""""$$###"##""!4MD  #%!!31L()6=0506*.0'""1)/6/%+4/:0INSSWf_ZQ_a4(092Jqo^   !!"!!                 ! "##"""""!"###!" !+)  10(""&)& ""#$"#")"&1X$75CIPF1IWYWTRO]a^^bekmdfmkhhikmieg^b_]]WRSXVY     !!!!      !!      !! !!""!!##!"""###!  !%" !.=:/'=#A?BB?>=@BC?==;9754/"&(!!" *+<(K?BEJSYfccdddda^Z[XVUSWUVURNIHIDFGKMLTXVZZ[[[ !     ! !      !!    ! !        ! !!""###$""#"""!! (;BEO]aijhj`T]^C<d0e[_\\^\\ZXZ\\\ZYXUUSPN?;/#$%,BUQXllkdc`_XMMMIFFCBAAAABBHHSIMGHKMRMNMNNQS^fe`aa !!!  "!     !" ! !!           ""#%%'*,.0247779:;<>>;/"+=BA=8.*(''*=VS/TU,\Y[[\\][[Z[[]\\[[ZPLDBBDGJKGGFBA>=?DDEG@==::9;FKBJLJOIHIEEBFEFEFGJMPQSUVW[eZY`     "  !"       !!"#%(),-03469898::>BDEGHHHJHHHHHHHGFFECBA=;:3$ #1A3!/999730+,,.NXVXYZ^_^^[VPHBBB?=9<@>?:=FCCFC>???FC?DGIDCDSD@JDBOJB@@???????>?@ABFFIIKLNNM_\LOMQMNK!!  !  !#%'',/7<=BHHKILJJIHIIJJKKKJLKKKJJIIGIDCA@=82025453332321.-$ $=sfS$++*'&%""!&KZYQA940)$$$&9IZWWVD=7411457775477987558PYBHI9=9;>=>=;<:;;:::=<DCEFFDDCCIKNLIEDDDEDEFPQQPPPQQQRRQONPOOONMMKNOMMFCA@?:61//123322333254557452323444431/-(" %4E7!##""!"#:BFHHF9=<<;:9;;:32334555::=<<<=BQY<>:222568;==::97778889;;?=??@ABDFGFgf8>?>ACDFFDFKLLTUWVUSRNKEA>:4022445443433323345444342323213354220/,)'&$$%$%&# /086*   !  *013100021101244320000132366111333465745556656677675799:<<;<::;?@@@@?@?>=>>?>ACD@=?AD77588777778974343545556544446675652/,)'%%&$%!#!!  "!! !  !$#    )9A !)-01121110000/.-.-001012244667767567789876789;;:8987687;>>?[c6=<??>;<;;<<A@C?>>=DCHIK89788:::89:997375651.*('&&$##"!! !""#""####!"!!!"!  ! !!"##"#"" !+-++(% (,-0B^cbH.0//.0.111212234443233232338889789:9<=:>=??@@@A=<<=>=>===;:;>??@><;<==??????89:67/.-+''&&%"##$"  !!"##"!    !!!!!! !!# !!!!      !!"!   (,---++*-.00223230../1110/01/233879887696689953378::=<=>>@??<><;;;<<<96769978:;?;>OeN""!!! !"!! !  !#"" !    ! ! " !     "  " !" " ! ! !! !%(*-././-/../1121010/0..-.2344558955534;7988Ny’~O%====>>>@>=<::<;<;>=;<:;:97<;?<?GI<E@@    !  !! !!"!!!   !! !   !         "(&#!!#)*)+*+++-0---..../...---.-102230/11223369897889:333337;<::99::;:<;<@@>==<;::9:9:<DIGB>@A=;G! !!    !!! !    )%! ))('&'&()))+-,+++**)))**+**++..//0000...11245999898877767665567656783678:;99636732/-L[;<677798=QK=fc]WQOQTWZZZ_aegjmmmopljfehihjklmmjhilnjgc__`````gow}€ƒƒ~€€€€~~‚ƒƒ‚‚‚ƒ‚_[WNF@?ACGNTYZWVX]cfjid^XWZ\^adefeb_`bgjid]VTTWYZaks{}€~{xxz}€€~€‚‚ƒ‚€€gd]QG@>?AENXdigcaaeijhb]\\``_bdfgd`\]`bb`\XRORSWWXZ^kt~‚‚‚€~}|}‚€€€€€€€lgbXPGDDBBDJU`hgb^`dhie^XWY[_bfhhfb]\_dhhfc_[Z[\YWW[enw{{{zz{z|€€€€€€€€€€€€plh_YRNLJGFGLUbkke_^aee`YXWX^dfhiga][\_dfgfc^WTRRTW[ajuywsqpuxz}€€€€~~~€~~€€hiha[WWWSQOJGKWdosqmmookd_\[_cdeec^ZYVX_bba]VOILQUVUYakqttqleaeny~}}}~~~~€€€€€€€€€ifd_[XVWXWVWWW[bjqx|~}{wnf]\_bdffca][`dhkjhbZPKGKPTWVV`iruqh^WST]hsy}~€€~||}}}~~~€jhd]XXYZXXXYZ\ZY]fs{€~|xpg^]`dfggecbbbejjeca]VPMKOQTUUV[afea][WSR[it}~~}}}}}}}}}~€€mjd]ZYYYZ[^adc^]_eow}~}{wrkb_^`ccca^]^`fgfd`^[ZXWUTTSSUX\bed`[WWZ_irz|}}}}}~~~~}~~€khc\XWWZ]clqsqlklmmqv{{xtuwtmfeeca`^]]`efeb`_`cge`]ZZXUTRX_bc^VWW\cjtx||||}~~~~~~kgc^[ZZZZ\`fnqspmmqtwwvsmjiifedfeb_[XVX\_bb_\[]adfdaZY[Z\]`cda]ZZ_hpz~}}}~~}~~~~lid]YYZZXX[cntxtqqsx}}xrmmolgb`bcc`\\]bghgc][[^ceb\WTSRRVZ`dhiihdcgltz}}}}}}}}~~~~oje_\ZYXWXZ^elrvvtrsxyvpnptvuokhfc`^^`cefdb_]]aeeb[TLKNTW[]_``bdaabdjry~~~~~~~~~€€€nkga]\\]]]_aagmqsuwxxwslcbfkqqmiijidb``cec_\Z]aeea]XUSRT\dfjigfhilhgks|~~~}}~€‚€€~~ojd^[[[]_cgffhlrvvtttupi^XY_gorttuuspjfedca^[[\_a__\YWWX\clqnf`_eihkmr{€~~€€€~€€nid^\]_chmsqnnpsvwxyxwrkc`_afkt{}~}|xsolhc^[]_cc`^_`bcabgklicddghbagox}~}}}~~~~~~ohc^]^^ahqy{yutvyywwxvpha_`bdhnv{~~|zuqnjhd_Z[_deeededcca```^[Y[_^][^fqx{}~€€€lhc^]]_djouutvvsposwzxqkc``acgjquxzywqligea^[Z^deb^]^_a_aeghf`WVZ__]^clty|||}~~~kfb___`bglpqqsuwutuvwvplhinoommruwtqmdaabb`]]]_cc```cedcejnnjc]\ac_]`envz}~~~~~€€€€€kgea``adimqqory||ywxxvohdfmqsqpswxtnkjhgeedbabcfeb_]^`abdhmpnlkljigehnuy|}||}€€~}}}€€€wqlgfdcdinttrqruyyyxvtngacjprqprvxtnjijhfddedbacfgghgfcbbcgjlkkhc`afntz|~~~~~~}}}~zyvqmigginttsstvwxxyyxslddeinqrstsoe^\alrttqlhdbdfgghfcbbcegghjfb_^dltz||||~~~}}€~}}}~~swzzxvrommoprstuvwwxxvplgfiotuvwwsohcackqvyzvkd__`cgjifddfjlllmllkilruz}~~~~~~~~~}}~fjpuxyxwvvttqpswyyyyzxtolkjklortuspkd[Y\cmtuqkhdbabehhgghkljheehkligiow|~}|||~~~~€€€€~kiikovxzzzxusssuxz|{ywtssutpnlmprrohaZWY^jonh_\^__^`bddcfmolgc`aehfccdltz}}}}~~~~~€hjllkjknqrrpnorvxz||{ysqpsvutrrssroid`]`fmpnha^^_`adddefjnnligefjnnkjghmtz}~~~~~~~~~olkkmnnnnopnnquz~€€~{wrpoquwyzyywusqqle_aeiifbdilonlheefhknnjfdbcijigbair|~~~€€€trpnnquy||ytqqsuy|~~|xrmmnsuwwxxwtqlifhosrmc\[`muxslfa_adgmmjf`[]bfge_^fpy||zxxz}€€€ponopqpnnqwz|{xwwz|}{wpmllqsuvxyywrliijmoomhb\Z`imlg`\`ehlnmje_^fjjifc__bkszxrptx}~~~~~~opollorrmjintx{{zz{{{xspqrstuvvwvtpkiffhlnkd[RRZbgd^[Z]cjnonke_]aefc^]]YY_fqusqrw~}}}~ttuusqomlkkjjlpuy|~}|zvsqqrruy||zxtqpnmopssokdafihhigikmoooomifgjjfaYXUTUY]eiklosyy|}}}}ywusrrpomkkjjikouy~~}|zurpqvz|}{zxvtsvyxspmljiijgffhnuvpiccfgggiie_[XTRQTX_bfhfgotz|}~|zvsplihikklmnquy}~|yvutssstwy||zvuuvvzywtqpopqojdaadiifedfhgccghfdbb_\YVUW[abbagpz}~~~€~|zwsnkigfglptx|}|yuttutttwz|zxwtpoquxywpibagkke__djjedeinonkdabfhigfb\YX\aa``fqy~€€€~}yvpljklosw{}|zvuuwyxwwx||ytqpprvxzyupmmoomjgfgihhksy|xnieefgihc`^[YUUW\bfhmrw{|{~€€|xsrqqsv{|zvokijnsvxz{{yxtrruy||zvssuxvrmklnmkjjlpqle`^]]`cccb_[XVU[`cbabdglnr€€€‚‚‚‚€}zxvvvw{|zvplkkklotx}}{yvsstxz{{yyxwwwussromkiilomg`_aa`_bdeecba`^``bcdehkkkn€€€€€€€€~}~}yxwvtqmighknrvy|}|zwuttx{}|wusuxywrmjjmnmorrkbXRRVX\`deeddefebcffddegjjm‚€€‚‚~}~|xsnkjjlmpux|}zwvwxy{{zxussw|{wsqrsqqpqrqle]XVVXY\]acfggcbcggd__bgfgk|~€€~~~€€~€€~}{{xvqnmmotwz{yustuxyy{zywvwzzxtpqsusqqtvtokhc]ZXZ]__adca_^_achgggfho€€~~€€€€€€€~}{xurrsv{}{unllouy|}{{yz}|yvttvwvttxyvrljhf^YVTUVY]`bcbbedgifegkq~€€~~~€€€€€€€€€€€~~|zwuutsokkknswzzwtux{{yvttvwvvxyxuqkige`\WWY]aeghgfea_`behjml€~~~€€€€€€€~}{wtpnllkkotxzxwx{~}{{z{{zywxzywrpponidabhoqrojggfb^_`diklm~~€€€€‚‚‚€€€€}zyvspoqtyytqprwz}|||||{z{zyvsqpqrqpljjkprolgffecabdfggk€€€€€€€‚‚€€~~€€€~|zz{zwuuutqomoty{|zzyz{z|~}zvssttsqonmotwupmkmlhcabdfhm€€€‚ƒ‚€€€€€€€~}}~~~~}zwtpnlmrvyywvwz{}~~|zurrttuttqrtvxupjfghikkkkkmm€€€€€‚‚€‚€~~~~|{yvttuwxvssuy|}~}|zvtuvsrstsqqruwwtqnkljefhknp€€€€€‚‚€€€‚‚€‚‚‚‚‚‚€€€€~~}}}}{ywx{{ysnmrw|}||}}zwtstvvustusqnnopsroiffhihh€€€€€€€€€€€€€€€€€~€€€€~|zxwy||yuqprvxwvxzxusrtwxwuttvy||zvvyzzupmljee€‚€€€€€€€€€€€€€€~~}}~~~~{ywwwx{{zxvvwyyvwy{|wsstuuuuuwwvvvvvvvurlfabfjkƒ€~€‚€€€€€€€€€€‚‚‚‚€€€€~~~~~}||}}|zz{||yutwz{zyyxxwwvvxywwvwxwtrpkhffghi{zwrpsw|~€€€‚‚‚‚ƒ‚‚‚‚€€€‚€~~~~|{zyz}}|{z}~|yyyywuuuuuwxxxxwxuspmhdacizwsnklpw|‚‚‚€‚€€€€€~~~}{ywwxz{yyz||zvuvwxyyz{{||{yyyzxuqkfdbad|yxtqqsx}‚‚ƒ‚‚‚‚‚€€€‚‚€~~~€}zyyz||zyyz~}{zxxxwwwxy{~~}|{{wsojeddde}zxuttux|‚‚‚‚‚‚‚‚‚‚‚€}}}~~}~}}~}~}zzyz{{{zz}~~|{{{zzzzzz||}}|ztqnjfeccdzyzzyxxx|‚‚‚‚‚‚‚€ƒƒƒ€€€€}|yyy{|~~~}{yxy{~|{zz}€€~}}|||{zzzzzz|}}zxqlfcba`{yyy{||}~€€€€‚‚‚‚‚€ƒ‚‚€€€€€€€€~}{{{{|}{{z{{~}{{{|~}}}~~~~~~}}}|||}}|zywvupkjyxy{}~€€€€€~}}~€‚‚‚ƒƒ€€€€~~}}}~~|{yyz||}}}}}{{|}}~~~~}~|xttrplhf}|||~€€€~~~~}|}}}~~€}}}||~~~€€~~€€~}|||||zz{|~}}}~~~~~~~~~€~~~~~{{{zwtnhe€€€€€€€€€€€€~|||}~~~~~~~~€€€~~~€€~~~~|zyyyz{|}}}~€}}}|||zwuto€‚‚‚‚€€€€€€€€€€~~~}}}}}||||}}~}{zyywwx{|}~~~}{xvqnm€‚‚€‚‚‚€€‚‚€€~~~€€€~~~~~~~}|yxwxxwwwxz|}}}~~~}}|{zxwuso€€€€€€€€€‚‚‚‚‚‚‚€€€€€€€€€€€€€€€~|zyyyyyzzyz{|}~{wrppqqqp~~€‚‚€€€€€€€€€‚€€€€€€€€€~{{{|}~~~~€€€}{zyyywt€€€€€‚€€€€€€‚€~~€€~~€€€€€€€€~}}|z{}}|zz{}~~~~|zzyywsq€‚‚‚‚‚ƒƒƒ‚‚‚‚‚ƒƒƒ‚€€€€‚‚‚€€€€€€€~~~~}|}}|}}€€€}|{yxwvsrqppqpoppooponnnn€‚‚ƒ„„ƒ‚€€€€‚‚‚ƒ‚€€€~~~~€€}yxwvutusssrqqqqqqsuvvvutsqnmoooopoooonnoonoommm€€‚€~}}||{{{{{zyxxwvuututtuvz}~|{{{zxwvvtsqqrrpppqqrrrrtutssrrrrrstvvvutttrqqqpoopovvvtsstuvttstttsrrstttttuvwwvvwy|~}||}€€€|yywvvwxvvxzzxwxywwwxxwwwyywwxyxwutusqrssqqrssrsstuvvwwwwxyz|~~}}}~€€€€~}}}~€€~~}|||||}}||||||{yyyzzzyyyyyyxvvvwxxxxxwvvwty{||||}~€€€€€‚‚‚‚€€€€€‚€€€‚‚€~}|||}~~}~~}{yyz||{zyxxxyyzzxxxyzzzzxwvvvu€€€€~€€€€€€€€€€|rnu‚~~~~~~}~~~}|}~~~}{|~}|{{zy{zyz|{zzyxy{zxxxuuuvv›œ›™˜———šœœ˜–”Ž‘•—–––––––”“‘“”——“‘‘‘—˜š™™š˜–”‘‹†‚€€€€€€ƒ‡‡‡„ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚¢¡¢¢¢¡ŸŸ ¢¡˜•–—˜šž¡¡¢¢¢ ŸŸ  Ÿžžž Ÿ›ššœŸ  ¡£¢ œ–Š†…ƒ‚‚‚‚ƒ…Š‹‡‚€€€‚ƒƒ‚‚€€€€€Ÿ¢¥¦¥£ ŸŸ  ž™—•–—šœœ ¡¤¡žœœŸŸœ˜••˜š›ššœž¡žœ˜”‘ˆƒ‚…ˆ‡†€€€€€€€€€€€€š¢¦ªª§¤¡Ÿš˜–”–—™œ››œœ›œžŸž››œžŸœ™––™œ›˜——˜›œ›—•’Žˆ‚ƒ„„‚‚€€€€€€€€€€˜š ¢¥¦¨©¨¥¡œ™–’“•—–•–˜š›œ™™›žžš—••˜šš™–•—˜šš˜•’ŽŠˆˆˆŠ‹‹‰…€€€€€€€€€€€€š›ž¡£¥¥¥¥¤¤¤¡žš—‘Ž‹ŠŠŽ“˜˜——˜œ ¢¡˜’‘‘“˜˜—•”•˜ššš˜•’ŽŠ‡‡ˆŒ†‚‚€€€€€€€€~~~›žŸ¢£££¢££¡ ¡Ÿœ–‘‹†„„„‡Œ”“””—œŸ¡Ÿœ™•“•–—˜™šš™™šœœš—”’ŽŠ‰‹‘’“‘Š…‚‚‚€€€€€€€€~~šœžŸ¢¢¢££¥¥¢¢¢¡ ›•‡„„„†ŠŽ‘–œžžœšš™˜™š›œžœœœš˜•’’“••–———•‘†‚€€€~™šœ ¢¢£¢ žœœž ž›”‡ƒƒ„†ˆŠ‘—›ŸŸŸœœ›šš™šœ›œžœ›››œ˜–––————–•’†ƒ€€€€~~~~˜šœž ¢¡Ÿœ˜‘Œ”—˜˜•Šˆ‰ŒŒŒ‘—šœžžœ››š›œœ›š™™™›š™™˜™˜˜–”’’’‘”“”–—”Œ‡‚€€€~~~~~~™›žž ¢¡¡Ÿœ˜”‘‘’”—™—“ŒŒ‘–˜•’’•›žœœš™˜——™›š—–—šš˜–”’’“——˜—“‘Œ‡‚€€€€€~˜šž  ŸŸš–‘ŒŒ•—•‘ŒŒ•–•“’’•˜šœœ›š™™šš™™˜™œ›—”“•—˜˜–”““”’“’““‰ƒ€€€€€€€~~–—™œžž›š–“Ž‘“•’‘•—–‘ŽŽ‘”—˜›œ››š››œœ›™š™˜˜˜˜™™œœ›™˜—–•“’‘‘Œ‡‚€€€€~~~€€™œž  Ÿžžœš–•“‘’’’™žžš•Œ‹Ž’“•–˜š›œžž›š›œœœœ›œœššš˜”’’”••’Œ‰†ƒ€~~~~€€€€™œžžŸŸž›˜•“Œ’”’‘‘”šŸ  œ˜‘Œ‰ˆ‰‹Ž’–™œœ››œžžœœœ›š™–•™›™–’Œˆ„€€~~—›ž ŸŸœ—“‘‘‘‘ŽŒŒ‘‘–™›œœš˜“‰„‚‚„‡‹–šœ››šššššš™˜˜˜——–•••˜œ›˜”‘Ž‰…‚€€€~~€~~~~˜œžŸŸŸžœ—’Œ‹Ž’••”’‘ŽŽ’˜œœ›š–“Œ†ƒƒƒ†‰Ž”˜œœ››››››œ›˜••–—˜™˜˜—”“‘‘Š„€€€€€—šžŸŸ›—“‘’‘‘‘‘ŽŒŒ’—››™˜˜™—’Œˆˆ‰‹‘–™œ›™™™ššš›š™™—–•””’’‘’•™™—”‘Ž‰ƒ€€~~~€€€˜›žŸŸŸš•’‘‘’‘Œ‘‘””’“—˜”‹‹’•™šš˜˜™›œšš™™™™˜•“Œ“–——•‘Žˆ…‚€€€€~•˜š›œ›š–“‰………‰ŒŽŽ”˜™–’“–”Œ‘“””–—š˜—–•–š›œš˜˜™š˜——”“’’’“”—˜–Š†‚€€€€€€Ž’•—šš™—“‹ŠŠŠŽŽ”˜–“ŽŒ’’Ž“•’ŽŒŒ’–˜˜š›šš˜˜š››™˜˜———˜™™˜™—”†‚€€€€~~~~ˆŠ‘”——–’Ž‹‹ŽŽ“––”’’‘‘”™žœ™”ŒŠŠŒ’–™š™™™š››™—•““””•—–•“‘Œ‡€€€€€€€€€€”ˆˆ‹ŽŽŒŒŽŠ‰‰‹ŒŒ”™›˜”’“’’“™œœ›—’‹††Š“–—™™šššœš™˜—”‘ŽŽ‘“‘Œ‡‚€€€€€€~~~›™•Š‡ˆ‹‘‹ŠŠŠŒŒŒ“–•“’’‘‘”˜›œ››•Œ”ššš™™šš™™››š™–”“”•”–—˜•Žˆ€€€€~~~~š››™–‹ˆˆŠ‹‹‹ŒŒ‹‹’”‘“”’’•——–”“‘‘”—™˜——––—™šš™˜—–•”“‘’“•’ˆ…‚€€~~~~šš›››˜’ŽŽŽŠŠŠ‹Œ‹‹Œ‘”“’Ž‘Ž’•—˜™˜•““”—˜–””””•—™š˜–•”“““””•–——”‹†„€€€€€™œœ›š™—•‘‹Š‰Š‹‹ŠŠŠ’•”’ŽŒŒ‘’”””••–——˜š›—‹‹‘–˜š™—–”””“’“““”–—”‹†‚€€€€€€€€€€––˜šš—“‹‹ŽŽŽŒ‹Š‰Š‘””“’ŽŽ’‘’“•••–˜–’ŒŠŠŽ”—™˜–•‘‘“““””’Œˆ„€€€€€€€€š™˜—–——˜˜”‹‰‰Š‹‹Š‰‰ŠŽ’”‘ŒŒ‹‹ŒŽ‘’’’’‘‘“•—™™–‘‘’•˜™™˜—–“““”•–—˜˜——–”’‰……‡‰‡…‚€€€€€—˜™™˜––—™›™•Šˆ‰‰Š‰ˆˆ‹’ŽŽŒ‹‹ŠŒŽ“•——•”““•–—™—“‘‘’”””“’‘‘’”••”•—™™™˜•Ž‰‡ˆŠ‰„‚€Ž’”–—™™˜˜™™—“Ž‰†‡‡‡ˆŒŒŒ‹ŒŒŽŽ’”““’’“•———•”•—•‘‘“‘Ž‘’’’”—š›˜•“Œˆ†ˆ‰‡…‚€€€€€€‡‹‘’“–˜™˜––––”‰„ƒƒ„…‰ŒŽŽ‹Š‰‰ŠŠ‹’‘ŽŒ‹ŒŽŽ’“““•––•’Ž‹“”•–••”’’’’““’“‘ŽŒ‹‹Œ‹‰‡ƒ€€‚„‡ŠŽ’•˜™ššš™˜•“ŽŠ‡†ˆ‹ŽŽŒŒŠ‰‰‰‹Œ’‘ŒŠŠ‹’“”•••–———––˜™—”““•–––””•••””••“‘Œˆ„€€€€€‚ƒ„ˆ‹Ž’–šš™˜—•‹‡‡‰ŠŠŠŠ‰‰‰‰‹Ž‘‹‹Œ“•–——––––—–•”““‘ŒŽ‘•–•““•—šš˜˜˜˜˜—”Šˆ„‚‚„„…†Š’–—–•‘‰ˆ‰Œ‘’‘Ž‹‰‰‰Š‹‹Œ‘’‹‹ŒŒ’”••””•—˜———•’‹ˆˆŠ’”•”•˜˜˜—”•–˜˜˜–‘ŽŒˆƒ‚‚ƒƒ‚‚‚‚‚‚ƒƒ„…‡‰’ŒˆˆŠ”˜™™–’ŽŠ‰‰ˆ‰‰‹ŽŒ‹ŠŠŠ‹ŒŒŒŽ“–—˜˜—–•”’’•–”““““““””“”–™˜•‘ˆ‡†††…ƒ‚‚ƒƒƒƒƒ‚‚‚‚ƒ„†‰ŠŒŠ‰‰Š”–™š™˜•Ž‰…„„†‰Ž‹ŠŠ‰‰Š‹‹Ž’“”•””••”’“”˜›š˜”’””–•––˜™™•”“‘ŽŠˆˆˆ‡„€€€€‚‚‚€€€€‚ƒ„…†ˆ‰Š•™™˜˜–•‹†„„…‡‰Š‹Š‰ˆˆŠŽŽŽ’”•”“’‘”—™›››˜––––•””“–—–•“’ŒŒ‹Š‡€‚‚‚‚‚‚‚‚ƒƒ…‡‡Š‘”–—˜—•’ŽŠŠŠŒŒŒ‰‰ŠŠŠ‹‘‘’“”“’‘‘”—šž›™˜———•“’“’’‘‘’“”’ŽŒ‹‡€€€€‚‚ƒƒ‚‚‚ƒƒ„…†‰Œ•–•’Ž‰ˆŠŽ’“Œ‰ˆˆˆŠ‹Œ‹ŠŠ‹‘“’‘‘“•˜™˜™š››šššš˜–••–—–”“‘Œ‰†‚‚‚‚ƒƒ‚‚‚‚‚‚‚ƒ†‰ŒŽŽŒ‰ˆ‰•—–“ˆ„„…ˆŠŒŽŒ“”’’’“‘ŽŽ”–—–’’•–——˜˜—••“Š„€€€€€‚‚‚‚‚ƒ‚‚‚‚ƒ„……†‡‡‡ˆŒ”–•“‹‰ˆ‰‹‹‹ŠŠŠŒŽŒŒ‹ŒŽŽ‘•——˜˜——–—˜•’’‘‘Š‰‡†ƒ€‚‚‚‚‚‚‚‚‚„……‡ˆ‰’•—–“ŽŠŠ‹ŒŠ‡‡ˆŠ‹‹‹‹Œ‹‹ŠŠ’•˜—•’’“•—˜™™—”‘Š‰ˆ‡…‚‚€€€‚‚‚‚‚ƒ„„„„ƒƒƒ„†‰ŒŒŠŠŽ’“Œ‡……†‰‰Š‹Œ‹‰‰Œ’‘’”“‘‘’”•””’‘Ž‹ŠŠ‰‡ƒƒ‚‚‚‚‚‚‚‚‚‚ƒƒ…‡ˆ‡‡‡ˆ‰Š‹““‘Œˆˆˆ‰Š‰‰‰‰‰‡‡ŠŽ‘‘’““’‘ŽŽŽ’””‘ŽŒ‰ˆ‡‰Š…‚‚‚‚‚‚ƒ‚‚‚‚ƒ‚‚€€€‚‚‚ƒ„„„……………††‡‰Œ’’ŒŠŠŠŠˆ†…†††‡ˆŒ’’’’‘‘‹ŠˆˆŠˆ„€‚‚‚ƒ‚‚ƒ‚‚‚‚‚€‚ƒƒƒ„„„ƒƒ…………†‰‘ŒŒŽŒˆ‡‡ˆ‡†‡‰ŒŽŽ‘ŽŒ‹‹’‘Œ‹‹‹‹…‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„ƒ„„………‡‰‹ŠŠ‹Ž’”‹Š‹Œ‰†……ˆ‰ŒŽŽŽŽŽŒ‹Š‰‰‰‹ŒŠŠŠŠŠ‹ˆ‚‚ƒƒ‚‚‚€€€‚‚‚€€‚‚‚‚‚ƒƒƒƒ„„ƒƒƒƒ„†‰Š‰‡††‰‘“‹‹‹Œ‰‡††‰‹ŽŒ‹Š‰‰Š‹Œ‹‰‰ŠŠ‰‰ˆˆ†‚€‚€€€€‚€€€€‚ƒƒƒƒƒƒ„„„„ƒƒƒƒ…‡‰‰‰‰ˆ‰ŒŽ‹ŠŠŒŽ‹‰‰ŠŽŽŒŒŽŽŒ‹‹ŒŽ‹‰‰‰ŠŠ‰Š‡€€‚ƒƒ‚ƒƒƒƒ‚‚ƒƒƒ‚‚‚ƒƒƒ‚‚‚‚ƒ‚‚‚‚‚‚ƒ„ƒ‚‚‚ƒ…††‡†††‡ŠŒŒ‹ŠŠŽŠ‡‡‡‰‹Ž‘‹ŠŠ‹ŒŒŽŽŽŒ‹‹ˆ‰‰‹’‰…‚‚‚‚‚‚‚‚‚‚‚ƒ„„ƒƒƒƒ†‰‹Œ‹‹‹ŒŒ‰††ˆ‹ŒŒ‹‹‹ŠŠŠŠŠ‹ŒŽŽ‹ˆŠ•˜–Šƒ€€€€€€€‚‚‚‚‚‚‚‚‚‚ƒ‚‚ƒ‚‚‚ƒƒƒ†ˆ‹‹‰ˆˆ‰‰†……‡ŠŒŽŽ‹‰ˆˆˆˆ‰ˆˆ‰‰ŠŽŽŒ‹„‡‰‰‡†‚€€€€€€€€€€€‚ƒƒƒƒƒ‚‚‚‚‚‚‚‚„„†ˆ‰‰‡‡‡ŠŒŠ‡‡‡ŠŠŠŒ‹ŠŠ‰‡‡ˆ‰‹‹ŒŽŽŒŒŒƒ„†‡†„€€€€€€€€€€€€€€€€€€€€‚‚ƒƒƒ„„„…„„ƒƒƒ‚‚‚ƒ…‡ˆˆ‡††‰‹ˆ††‡ˆˆˆˆˆ‰ŠŠŠ‰ˆ‡……†ˆŠŠŠŠ‹‹ŒŒŒ„„„ƒ‚ƒƒƒ€€€€€€€€€€€€€‚‚‚ƒ…‡ˆˆ‡†††††‡ˆˆ‡‡‡‡‡…„„…‡‡†††‡ˆˆ‰Š‰ˆ‡‡‡‡‡ˆŠ‹‹ŒŒŒ‹‰„„…„‚‚‚‚€~~~€€€€€€€€€€€€€€€‚…‡‡‡†……‡ˆ‰‡‡‡‡‡‡………††…………‡‡††……†††‡‡‡‰ŠŠ‰Š‹Œ‰ƒƒ„„‚€€€~€‚ƒ‚€€€€€€€€€€€€€€€‚‚„„……„„…ˆ‹‹‰††‡‰†„„„……„ƒƒ„……………………†‡ˆ‰ŠŒ‹‰ˆ‰‹‹‚‚‚€€€€€€‚ƒ„ƒƒ‚‚‚€€€€€€€‚ƒƒ…ˆŠ‰‡††ˆ‡…„„…‡‡…„„„„„„„„……‡‡‡†‡‡ˆ‡†‡‹Ž€€€€€€€€€‚‚ƒ€€€‚‚‚ƒƒ„„„ƒ‚‚‚‚‚‚‚‚‚‚ƒƒƒ„„„„†‡…„ƒƒ…†„ƒƒ„‡‡ˆˆˆ‡‡†………………†††††‡ˆ†……‡‡€€€€‚€€€€€€€€€€€€€€‚‚‚‚ƒ……††‡‡…„„„…„‚‚‚…†‡‡ˆ‰ˆ‡‡†„„„„„………†ˆˆˆˆ‰‰Š‚€€€€‚€€€€€€€€€€€‚ƒƒ‚ƒƒƒƒ„„ƒƒƒƒ„„ƒ„†ˆˆ‡‡‡ˆˆ……„„„„„…„„„…†‡ˆˆˆŠŒ€€€€€€€‚‚‚€€€€€€€€€€€€‚ƒ„‚‚ƒƒ„ƒƒ‚‚ƒ„……†‡‡ˆ‰‰ˆˆ‰ŠŠˆ†„ƒƒƒƒƒ„†ˆŠŠŠŠŒŽ‚‚‚€€€€€€€€€€€‚ƒƒ‚‚‚‚‚‚ƒƒ‚‚‚‚ƒƒƒ„††‡‡‡ˆˆ‡„ƒƒƒƒƒ„„„……††……†‚‚‚€€€€€€€€€‚‚ƒƒ‚€‚‚‚€€€€‚„†‡††…„„ƒƒƒƒ„„…ƒƒƒ„„„„…†‚€€€‚€€‚‚ƒ„ƒ‚ƒ„…ƒƒƒƒƒƒƒƒ……ƒƒ‚‚‚‚ƒ„„†‡‡ˆˆ‰ŠŠ‹ŠŠŠŠŠ‰‰‰‰‰‰Š‚‚‚‚‚‚‚‚‚€€€€€€‚‚€‚‚‚‚‚ƒ„„…†‡†‡‡‡ˆˆ‰‰‰‰‰‰ŠŠ‰‰ˆ‡†‡‡ˆ‰‹‹‹ŠŠŠŠ‰‰‰Š‰‰ŠŠ‰‰‰‰‰‰‚‚‚‚‚‚ƒƒƒ‚‚‚„……‡ˆ‰Š‰Š‹‹ŒŒŽŒ‰‡‡†††ˆŒ‘“‘‹‹Š‹‹ŠŠ‰‰‰‰ŠŠŠŠ‰ˆˆˆ‰ŠŠŠˆˆˆˆˆ‡‡‡ˆˆˆˆ‰‰ˆˆ‰‰‰ˆ‰ŠŠ‹ŽŽŽŽ‘’”””“”•––•””’‘Ž‹ˆ‡††…„„„……„ƒƒ„†‡ˆˆ‡†…‡‡†††‡‰ˆ‡‡ˆ‡‡‡‰ˆ††‡‡……†ˆˆ††Š‰ˆˆ‰‰‰šššš›œ›š˜——•“““’ŽŒ‰ˆ‡†…ƒƒ‚‚‚ƒƒƒƒ‚€€€€€ƒ…†††„„ƒ„„„……†‡‡†……„„„……‡‡‡‡‡‡‡†………††‡‡‡ˆˆ‹‰ˆ‡‡‡†…„ƒ€€€€€€€€€€€€€€‚ƒ……„„„……„„„„„…………„ƒ„„„††…„„„„……„…„„„„…††‡‡€‚€€€€€€€‡‰ƒ€ƒ„ƒ‚‚‚‚‚„„……„…„ƒ„……„…†……††………††‡ˆ†……………‡††††………„„‡ˆ‡‰~‰~pºÇÉÅÇÆÇÆƾ‚¨Ì»–ž—Z¬„dkreƒfe•©vNKGEC2;>DF=gÁ¿¼™„KMœ£ nNKG>FHC<KLRDƒ·Â²o`CKj}sòñÏǒxP)i”‡Œš¤’ŠÔØÓÖØÙÙÚÛÛÝÝßÞßßÞÞßÞÞ˃}»à××ÚÛÛÜÝÝÝÝÞÝÞÝÝÞßààáßàßßßÞßÞßßßßßÝßÞàßßÞàßÞÞÞÞßÞÞßÞp|c<‰Á½¿ÇÇÈÈÈÈÈÉ¡ŽÍÁ’Š9‘pb{TyiœhbGKBC5AFFL?t¸ÃÁ°m-L˜­€OeAAURG>KJMEŽÁÃÏnWUYp²£™Ã®É—lO@y‡z«ª§Þ×ÙÙÚÚÜÞßÞßÝÝÜÞÞßàßßÝҘxˆÒÚÔÚÙÛÛßÝÞÞÞßßÞßßßßßßÞàààÞßÞßßààßÞÝÝÞÞßÞààßààáßßÞÞÞÞ¡a"3„¹·¾¼ÂÅÇÈÉÅÊÈƇ¶Ã™=%1\›~^q^[£œaLQKHA6ACFF7n·º¹„KP]§ˆ|d[J2VSD9PRSO“ÄÂТ–hQVs|ƒ˜wº°­ÍÁtKB‚Ž†šÅ‘¤ÞȕoÍÓÒÔ×ÙÙÚÛÚÜÜÜÜÝÜÚ¼œ áÖØÜÚÜÝÝÝÝÝÝÞÞßßßÞßÞßßßààßÞÞÞÞÞÞßÞÞÞßÞßßÞÞÞÞßÞßÞßÞފL):‡ºµ·¹½½ÄÆÇÄÅÊÊɪ—›D,/<H‘bm†Uˆ]THKEB3=EGNCw´¼³†>CCx³¡wXM=0NLIGOQYP”üÁ¾œzJO[~v€i°¦·¸ÓƖvOH…¡Å˜»Åwa„ÐØÑÕÕ×ØÚÚÜÝÝÝÝÝ͉§Í´åÛÚÛÛÜÝÛÞÞÞßÞÞßÞßÞßÞÞÞÞßßÞàßàßßßÞÞÞÝÜÝÞÝÝßÞàÝÞßÝààÞ_7*A‘°ª¯µº¿ÉÅÆÅÇÆÇÉǜ]¡n2)64y™ylz_ZLNRIC6GGFH;„¼À¬œW;]„¡xTN=5II?=NMQM¿Àº«¸rKSXzprFL˜´¾¹ÓÌk<J‰‡²ÄŽÁ±€£ÓÓÓ××ÙÙÙÙÚÜÜÝÜÜÀ°¬ÂàÖÙÛÝÜÝÜÞÜÝÝÞÜÝÝÝÝÝÜßÝÝÞßÞÞÝÞÞÞÞÝÝÜÝÝÝÞÞÞÞÞÜÝÜÝÝÝÞÝÝk?3P¦ ¤§«®¼ÁÅÁÅÅÃÅÃĹXi•G",3@š¤bq…dU?DA7ACEHGŠ¿½¹©dGc¤¾—ZbQ72JH>@GJMI–¾ºÅ¢¸ƒr^]cWE>L;ƒ¹»»Î¾‘]=QŒ„§³„¸©£âÓ××ØÙÚÙÙ˙:‚ÂÔÍ ÅÝÑÔ×ÚÚÛÚÛÛÛÜÝÝÝÝÜÜÜÝÜÝÝÜÜÝÜÝÝÝÝÜÜÛÛÜÝÜÝÜÝÞÞÞÞÝÝÜÜÝÛÚ@7-A…€“–š¤²°»¿¿ÀÁÃÃÆÊ¿™C‚s5269}¡u`ˆYUB;;DDDFEƒÂÀº§o\jœg~^<T69FL:;NMLJ”¿Ãćªa}VOTVE53?‹·«ºpV«{Z=K–Š~º¸…ÀÓÔØÖØÕÑ¡7)?KT_ŒÛÖÑÕÔÖ×ØØØØÙÚÚÚÛÚÚÛÛÚÛÛÚÛÛÛÜÜÝÜÝÞÝÝÜÝÞÜÞÞÞÜÜÜÜÝÝÝÜÜÝÜÝÜÜ<4(Oyozx|‡Œ˜¡¦­³³º¼ºËÆƨ`…6*-M•†TgYY8,==A>@Š¿Àº¬gTg¡|RPc>=>MK<7FHNL ½¾Ð¹¨lwfCRVA172+brpe~±§|J&K—ƒ†³§‚ÎÍÕÔÕ×׿dLXTPN—†ÃØÒÔÔ××ÙØÙÙÚÙÚÚÚÛÚÜÜÝÚÛÛÜÛÜÛÜÜÜÛÜÛÛÜÛÜÛÝÜÜÜÝÜÛÛÚÚÚÚÚÚÛÛÚK'*Rmhntvtwux{Ž”™ ¡¡‚®ÁÄĺ~L‡d"$+5}e_deK0853:†Á¾¼¥\Vg”l†W8Y7?IH:@MLKG Â¸·ÄŸPmjGRSC<LA:“} –Å¿¶zW%H”…ߛϥ](7LJKLJR¥œ§ØÐÐÑÓÕÖ××ØØØÛÚÚØÚÛÜÜÛÛÚÛÚÚÚÚÛÛÛÛÚÛÛÝÞÛÛÜÜÝÛÜÝÜÜÜÛÛÚÚÛÛÜD2(]jkmnqsttttu{‡•§Š¯ÃÁÀµ‹SQ.!(*5oˆj^eW@+0/A‘ºÇ¾_Tv¥{``8B<>IF;?IJGL«Á¶•ªcx_BSPF@ND<‰¢‰Š±»·È–o5%s…«Å£¯ZELCCIGDA;=2N¤±ÐÓÐÔÔÔÖÕÖ××ØØÙÚÚÚÚÚÚÚÚÛÚÛÚÚÛÜÜÜÜÛÛÛÛÚÚÚÛÜÜÛÛÚÙÚÙÚÛÛÛÚÛB-$drjnmmnqrrtopotw}º³–”»¿¹¾~1.*$%%9LEFZGE1)2W7J•’c^x¬yE;8<?MI;?FHGM§À¶“¢…¡wJVZPDKF?ˆº›|»²ºÁȞnO3yŽ„¤¼”º™Z./2...0114e¨¥§ºÏÔÒÔÕÕ××ÙØÙÙÙÙÚÚÚÛÛÛÚÛÚÚÛÜÛÜÜÜÛÛÜÛÚÚÙÚÙÙÙÚÛÚÛÚÛÛÚÛÛÚ?$,fhnlikjnmqqnoooq_I—°ª¤§ª²s-*6/&"!&5-!" !Rseo[}«’‰RP7CFPE9@FJIS¬Ã¨[q’MG3FCDFFG66q¬dd‘zƲ¿¿™r=6~Œƒ±²drR/1.///1/H‘³³¯µ±ºÉ×ÔÔÕ×Ö××ÙØÚÙÚÛÚÚÛÚÛÚÚÛÚÚÚÚÚÛÛÛÛÚÛÚÛÚÚÚÛÛÚÛÜÜÛÚÚÚÚ:%1lhklkihkkmpmmmoj}{>]§¯†E«‹N7"'%  #%.g`mS_€¬’_‰aGCLE<?HKET­½™Foƒ9eD9KB:6489n—kI•‚›Å¸Ã¾›];8’“¨•‰ž07B:721,0j­¾¼¼¸²®Ì×Õ××ÙØØØØØÙÙÙÙÚÚÚÚÙÙÙÚÚÛÛÚÚÛÛÛÛÜÜÜÛÚÚÛÚÛÚÛÙÚÚÚÛ8#=nenmkjjijkmmnmmiš„S7…LsuŠsJ;#"'$  :u\mTƒª‘Žj›sBDEB9@GF@V²¾R—w]{X@QF2DFKDŒ‹{XkŠsº¸¸ÈÁ‰Z4OŽŠŠ…·“Áy9&,3723i_œ™¢Çž¼¯¬Ê×ÔÖ×ØØØÙØÙÙÚÚÚÚÛÛÛÚÚÚÛÚÛÚÜÛÛÛÜÛÛÛÜÜÜÛÛÚÛÛÚÛÚÛ2&IqflklklkjjlmmklhdigoWBO9s—t•a</"""!$k‡gicsœŠržkIKJD7AFJ>Z¶À‹Y¦’V|W?PK8FJGBªkNFwoŸ±®ºÀº…[3D–‹‡Ä£²t:CIFAD¡‚g£}v|•°»µ¸ªÖØÑÔÔ××ÙÙÚØØÙÙÙÛÚÛÛÛÛÜÛÛÛÜÜÜÜÛÛÚÛÛÜÛÛÚÚÚÙÚÛÚÛ/#MlflkkkjjjjjkkllhjmkmdQ%Eot{d{’wC3$!"!Hˆr^eb‡u hJGHC:GLKDX¹½…m¤“dCQL?LKLIš²nLBZ€m¤†É²ÃºT7W€ž¿™ª¾gQZZZU¦›pt[Nup”«‹ÂÛÑÓÕÖ××ØØÙÙÚÚÚÚÚÚÛÛÛÛÛÚÚÙÚÚÚÛÚÜÜÜÜÛÛÙÛÛÛÜÛÛÚ/$Ticihjigiiiiiikklj_SZe\/d^Vps[Mkg@5($ '-,nlRbOjšhMIIB:HJN>Y³¸‹e©™M4CJ[QCIIHGœ®rEQvkb¶¶ªÃº€^:jš~¥Á‹®©eWYPG¤µŠZƒsap„{—·Ú×ÓÖÕÕÖ×ØÙÙÙÙÚÚÚÚÚÛÛÛÛÛÛÛÛÚÚÛÚÜÛÜÛÚÛÛÛÜÜÝÜÜÛ-'[e_cfihgfehgkjii\1 !"$27oVI3VmP?NQ</$" #04'RaDKP{_MLH<8HKO<d·²~Sª‚NA4<NJALMKO¥· €KOj}jL‰­·»Ë¬{P.{ˆ‡©±¼˜\ZKG’²wDX¡ µ|E1c©ÏÛÔÕ××Ø×ØÙØÙÚÚÚÚÚÛÛÜÜÜÜÛÜÛÛÛÛÛÛÜÜÝÜÝÜÜÞÜÜÜÜÛ)(`edecfeeeeefkfff[?!'$! 3bbG18d`K>I;)$"#)WC)0" 8XVt•aMLIB;JGH?eº¶}l–‡[K79OE>OOKL¤¾¹—F?QmJ<Me®º¬§|L+vŽ¶»¿‰D8>Š‘\Nc¨‰BKr›“¹ÞÖÕÖÖ×ØØØØÙÙÚÚÚÚÚÚÛÜÛÝÜÜÛÜÜÜÝÜÜÜÚÛÛÜÛÜÜÜÜÛÛ&.d]`dcdbcddedceec|†G+6/' !0g[H>"IdX@97'#$"#'/noc&$' )/Tx{”WLJJ>;LKMBr½·}\¥L@;:QH>PMGGŸ¼®œbGMZL;@B˜¿¢Y¨wE'wƒ‡³¢•ÅtFBŽz¦lA>e¡lKM`™ Ö×ÔÖÕ×Ö××ØØÙÚÙÚÙÛÜÝÞÝÝÜÝÜÝÜÜÜÜÛÜÜÜÜÝÜÝÜÜÜÜÛ%8jaaba`abaaabccca‘¤ydrW**6`QTO (PQ9.)$&$%&)_yviCsfYnttŒ•NBNIB;LKPHyÁµxBŽ”YA9<NG>LFDN¨¶­¯pMMVI398>qz[ŸÀ¦p@<„~€¿œACM‹s6?;3Ž¡ˆG9:‹•ÈÙÒÔÔÕÖ××ÙÙÙÚÙÙÛÚÛÜÜÛÜÛÛÜÛÚÛÚÛÛÝÜÜÛÜÝÞÜÛÛÛÜ#=j^decaabdcaadcc_”¦Œzƒp'.& 7eJ_NF83@7&##!"$*@Srs?UkHVw|‰KONL@6MKKDxµ¯|m¬ŽMS8>IC;HHCO£¾°Œ‡SJUR:KF@‰x¾¯Â©~L;ŠŠ’¨c7CG‡z=HdAONBC”“«Ö×ÕÕÖØ×ØØÙÙÚÙÚÛÛÛÜÛÛÛÛÜÝÛÛÜÜÝÝÞÝÝÜÝÝÞÜÜÛÛÜ%Ae_bdec_^`edd_dd^œ­™|‘u&7/#&CVEEUH.!)%###%'6oNDV1":fYDp[MKMK<:LIIC|º°k†yRW82>KC9DDCQ¦¥‘‘‰d=SO?LIE’‹¤º·µËsAX˜‡\8C?‹N`†I-a“ZKS‘’žËÙÕÓÖÕ×ØÚÚÛÛÚÚÛÛÜÜÝÛÛÛÚÚÛÛÛÜÜÜÜÜÜÝÝÜÝÛÛÝÝÝ"E_[abbbbc```bf``^¢¡¥–•„A"DE%(WKCSR<2/" !"#2IuwDB( *Sw[phLQF;5BDGCÀ¯f{OTU:FKA:GC@Q «ž†˜bCUPDLID‘˜˜Ž²»°Ç t5G“‰~;8<‹ƒœoŽT/usk‹K;;t•´ÝÓÓÕ×ØØ×ØØÙÚÚÚÜÜÝÜÛÛÛÚÜÛÛÜÛÝÛÜÜÝÜÜÜÝÜÜÝÜÝ'P^[]_a`bcdd__`ba`¯¤—…©–f<aa."@YHNN=82%%&'()MwM]q;0' %Au^UnTE85CDFJ¼ªf‚tMQWDJQF<HHER«°¢ƒ8769>;C?;{v›}»±µÆŸ^1`xn87„ŠŒcU@Bˆm@ˆnA3V“œØÕÑÔÕÖØØ×ØØÚÚÛÛÜÛÜÜÛÛÜÝÜÝÝÜÛÛÝÜÝÜÜÝÜÜÜÜÝÝ'SUZZ[]Y`accda___\•¨‘„¦‹š`srE:+LK>E=:2"%((*'R}shW\.03$#"1\bY[PE4D?=CŠ¸¦e‡ˆPLhIFUE@KKFX©£‡u]UK99DFI“ŽY|s¢ºµ¾Ëf-Y”h$x˜iPF;€k7QŠa7l‡–ÉÙÑÓÕÕØ×ØÙÚÚÚÚÛÛÛÜÛÚÛÚÛÛÜÜÜÜÛÝÝÝÜÛÜÜÜÜÝÞÝ,\YVXZZZZ[_acdda]ZJRŽƒ¨ˆŒ~|tEL!8L=</<6''%%'(Z|pvlggB"31""#DcLKY@-*/1p³¥dŒ‰eiYEHM??KKIe®šž\GSIGUYK–c[†…Ÿ­¸¸´D.^{Uu¡qBHL?xe2`’F9r–¯ØÓÓÕÖ×ØØÙÙÙÚÚÚÚÚÜÜÝÝÞÝÞÝÝÜÝÜÜÝÝÝÜÝÝÜÝÝÞÝ1^Z]ZTUXZXZ\acddaStj:‡©‰t‡…>R'1QAN-<8(($$&*`|ptijgfN!:1 !VpOTbH**1i¦Ÿl˜†j{l:AH?6NJAf¦ž± …^FXHGTSM››LA}~‰žÁ­¾’72$X7?$$(/`R6Qx?87}i<E‡œØÖÒÔÕÖ×ØÙÙÙÙÛÛÜÚÛÜÜÜÜÝÜÜÜÜÜÝÞÝÝÞÞÝÞÜÞÞÞÞ8_X^]_^WXXYZ\^_]\QnYpO4Yƒ‰6R@(FC<8D5'''((+ZmocJjkec@3%$"!HI8MOE&[F#5ƒ…qŽ„;>JC4RQJn±¦¤¯£iFXKL]\N—œWKi{[]µÏÀ¸r: -/&+*3?„—h…i/C;>oHˆyÉÕÑÕÕÕ×ØÙÚÚÙÚÛÜÜÛÜÜÜÞÝÞÝÝÝÝÝÝÞßÞÝÞÜÜÝÝÞÞ;^W\\\]][WXX`a_]YB'lRtZJ=|+@M!#1=51D8+'&')*c~ruvwTKmeaN0(! %, $4>€u£‹?IMA<PLDe­©œOL:QFJTSO™ŸTIZqLM[¡¼•`y-(*))*8,K‘|q']*_‹M‘˜½ÙÒÖÖ×ÖÙÙÛÚÛÜÜÜÝÝÝÛÜÞÞÞÜÞÝÝÜÝÞÞÜÛÜÝÝÞÝÝÜDaUVY][[[\XWcbb]R1#"<iJqk<<':_**0>22=5.,)))0m{st1M‡_A?Bi90'' !!    !;6,-RšHKM<:MJHq³§­•WY=_KRUSK—›fRNXLJDr¯†<#063Ml1‚Œ†b’0Tvq‘O™œÎØÒÔÕÖÖØØÙÚÛÛÛÛÜÛÝÜÜÜÜÝÜÜÝÝÞßßÞÞÝÞÝÞÜÜÞJ_VXZXYZ\^_^^___W-% ! FUK^8@<x*1E959/***)*3mn{v[* |`*.GXG8 &  %M4**XsDMQ;;MJBj´¤”•B:8OFHQPVž—vlPXH><#fp¥¯€*5CB=}€T3m€j`3@pY+pn‡¬ØÎÔÔÖÖ×ÖÙÙÚÚÛÜÞÝßÞÝÝÜÚÜÜÛÜÜÝÞÜÝÝÞÝÞÛÝÜNVWVVYXWYZ[\]][[U."! )'PEIT3e9,298221+$'')2krmmqlP;B[qI^>9'GM-31GIK54KFBc¬’Ÿ 795PCDIIL™œ€~M\?HWH~ŠŸ¢g86FC?l¢~W@~WX>]mFZ›ŸŽ¥ÔÖÒÕÖ×ÙÚÜÛÛÛÚÛÜÜÜÜÜÜÜÜÜÜÝÝÜÝÜÝÜÜÝÛÝÝÜÞNTTTVWWWUUYZ[]\ZF:= [E4&KAUT2/#7562*&$$%'8okjebgbW,1kkTC]>7'  # 1\69/KJ96BF?yª—’YA=QCINJQž¤†~:L@FS9‘±’w\8;540i­e}oGQH`“[Se‘‚ÁØÕÕÖØ×ØØÙÙÚÚÚÚÚÜÜÝÚÜÜÝÜßÞÝÞÞÞÞÞßÞÝÜÜÝSSTVWVSUUVVVZ\X[E%KY2"*fPG%SBb;1G5;4+)(&'&=j`igjjkb>N]@ƒaGVJ3$ !!((00(`WMKJ46CFIx³£¬œF44UGKMLN•xy@WVMU7ƒœvyk<9=?=g¬£c—†wL;;L}DB5s~¨ÚÕÓÕ××ÖØ×ÙÙÚÛÜÝÛÛÛÛÝÝÜÝÜÝÜÝÜÝÜÞÝÝÞßÞàNLSUVVUVRUXXXVVVA*T_.!*fLQ""+P;YM572.&'(('DuedgZ!,deE&ZrG;C(! "#;yF *'@nvBVX:>ONJu´¤‡X^B@PFIOLW¤–h_DA59<4ZˆQ[L=',036„¤uy˜¤m8Fd_G?-™ÖÛÑÓÕÕ××ØÙÚÚÛÛÛÝÝÜÜÜÞÝÞÝÝÝÛÛÝÜßÞßÞÞÞÝ_[TTTSSYZYYXXXVUF6[`1$:lRE! 0G7:33($$$&&?hej^*#!!$TdJ1+eP.*"!!$%IpEHpBTTOFK;BILFo²U/:COGLROK ™xBQ:a[T‹žsUA$&)?iWK<#4/k”`mu1…fŸˆÄÛÒÕÔ×ÖØÖØÙÛÛÛÚÚÚÚÚÛÝÝÞÝÜÛÛÜÜÛÞßßÞßÝÞ^T\]XTTVXXZXXVWR?=]\$:cAiZ$  &5111&%%%%$ImaazQ^/&RXVR#2>1#""!*LnM6rEPqXJ2=JMCq¼£„F/<GWNLONQª¢ŽzER?SRK~ Y^E*.9b\lN,9>=4ƒ—p?4H™{ÊÒÑÒÖÖ×××ØÙÙÚÚÛÚÛÛÛÜÛÝÜßÞÞßÞÝÝÝÞÞßÞÞÞÞ<MVV[]YVUUWXYVPQBBf\( >R9h\ $&/;-3.*(&#%$Hlba‡“t‰C'#%PL>N<"%$%%&&EtHY5$'[eQu_;@ONDy¹œ‡Yz2K[LINLI¦¹š~ARHQRIqœW`P2&$4=niG0)42AbHŠ…`F8Ž¸ÒÑÐÓÒÔÕÖ×ÙÙÚÙÛÜÝÝÝÜÜÝÜÞÝÞÝÝÞÞÞÞÝÜÜÜÞÞÝÛ=;;I[Z\]XSUUUVWSCGfX# ?T6zS1*KF!&,:,1-+%%&))Qa[]’–q‘B"1"3\@ZF:*  'BT‚X9*:sbj\=370X¨›„kŽ4;KDELGO£«o_@KFTUIt—ZRU>0;Q;qwo;4:>j™bcu@H8ŠÈ×ÕÓÖØØØÙÚÚÚÛÛÜÛÜÜÛÛÜÝÜÝÝÝÝÞßÞÝÞÞÝÝÝÝÝÞÞBJ@=:>Y[YZKOWVTQCLkN'7>C{O96UX$'1=.3,((''''Tc]XŠ¡‘”Y-X4"(QOUE:4!%%%)boElUZX#.„…Uj@'%N£“ƒk=GI<IHAIž¤dC<SCNQJp¡^WT97U]AmxxIHFAeŸy‹n@CQŽœÕÔÑÖÖØ×ÙÚÚÛÛÚÛÜÛÝÝÞÝÞÝÞÞÞÞÞÞÝÜÝÝÝÞßÞÞÞÞ! 4K@@?BXXSTPQOLFOoM",ZK=yUI?^K#(3:/9/+$$$#(X`_Y™—|³wSjA#8[.:61!$&(+_xs}¡¥n|F&c‚V{u7SVIlŠNNJ>FOIT«°l<4P?JM@x¢dMTD-Sf5mtt`f\ERt=•ŠOLR‡ÇÖÓÔÔ×ÖÙÙÜÛÜÚÛÚÚÛÜÜÝÝÞÝÞÞÞÞÞÞÝÝÞÞÞÝÞÞßÞ ! )IEA?@NSTUNGAUlF$)ZVE€MGE]F%/4-5.+'%%%(X\\`™€²n{uLC"HF>99$()+dukcšÆ«b&+"%2* !$ikiE;D;HOGJ¢©e:9OJSUGr±tVYC6Kf9gxlH?CDT‰}‡%7[…˜ÙÔÑÒÔÕØÙÚÛÜÛÛÛÜÛÝÛÜÝÝÝÜÝÝÝÝÝÝÝÞÞÞÞÞßÛÝÜ   !!?EAC<DOJHF_gA"-ZPQFKIcG&/6-0((&&#$-Y_\\W9¡ƒ~}VI&;M9<5!((*0fwq•h–½›X-!&!!)=„ht]>KHW\YT­¥kQ5KEJMGq™UDA93Y_5gqpF$37.b;%>C?|’ ÙÐÓÔÖÖ×ÙÙÚÚÚÚÚÛÜÝÝÜÜÝÝÝÝÞÝÞÞÝÞÞÞÞÞÞÞßÞÝ5%!!"! !8A<;;:BE_d6 1bFazALTiA&4736''%%%$0VV\]QZVVyuGN9/C4@5*./02rxmÀ‹G‹e<%%$!!#""%MŽl…lC:FPNV¥aCBQBJJCxŸdPR-3Oe=awp@;@1FL/=9;JG“‘ÒÖÑÔÕÖÖÙØÚÚÛÛÛÚÚÛÝÞßßÝÞÝÝÝÞÝßÞÞÜÝÞÝÞßÞÞG>2*$!! )6@>A@<ba; 1]=arMOSbB%1113+'&%%$/\YWL2NV`OMa9P:*<2:3,/-05nxp^vmŽ„:"" ""0/*C’{…u<FONT£‘RN5RENNCƒ§jHQ71M^:b€r?_j?WK3>:IƒW}—ÏÕÑÔÕ×ÖÙ×ÙÙÚÚÚÛÝÜßÝÞÞÞßÝÞÞßÞÞÝÝÞÞÞÜÞÝÞÜMIFB6-#   "+:A<@@+'6Y8lmOOS_7&0-***(%##"2ZTYD&!7T_iP0EG'41>-,)()3kp{´•[r´“¡–F !%UuG!;r|ZFGPM^¤Ž9$7GCIJ>ƒ©kCM).FY9btU˜Ibl>B7G‡†¢ÒÏÒÔÕ××ØØÙÚÚÚÛÜÝÞÞÜÞÝÝÞÝÝÜÝÝÝÝÞÞÞÞÞÞÝÝÝJLKJF@>1'"!  %+774!:\:pdPLZ_.'/---(&$###7aPSB"!9QWYGA$61<0)''%4jhm´µpœ“ª²•–I%)0}sprCWYF=IMKZ¥A2AG@KNG‚ _DN31CW=_wX™‰OYsN[FJƒj•¸¦µÔÙÕ××ØØØÙÙÜÜÝÝÝÝÝÞÞÞÞÝÝÝÝÞÞßÞÝÞÜÞÞÞÞÞMNNNLJHEB6("!%''BY=lXVPa[' *0)))&&$$$#BfYX<"!(.BKZF/(92?/**)'?kfimap³ˆb’¸™S"'+8¬nlamR=CJHd©Œwp7G=LL;O?O4.ER8^…yd—G>[l?QAFƒxg)(M•¸ÙÔÓÕÕÖÕØ×ØÙÚÛÛÜÝÝÜÝÜÝÜÞÞÞÞÞÞÞÝÝÝÝÝÞ0BJNMNMJIF=</& 0L8$%GYCo]XSdZ&$+/+/'%%%%$%AZUW@E:%SL*)?PKB/.=.***)Bug\938eš–‚YD8(!')-{¨i7]wcvP>??SŸˆ{w;G4?E;€›M5M70AO9a„|a<9Xo)562a=.8=VÐÔÑÓÒÕÖ××ØÙÙÚÛÛÜÜÛÝÛÜÜÝÝÞÝÝÝÝÜÝÞÜÝÝJ8-:DQOONLMOJE<OWeC%GOAj]YRgV$*-*+)'&"###>bSR=JJ*QJ.&:<G74+('((@ofg…E3)nž…`,)/)/50¢‹o%?qne:*/…‘}{8I?IPDyœS8H518:9TƒzY‡L7Ll9`+1R68-fSu‹£ÔÒÔÓÖÖØØØØÙÙÚÚÜÜÝÜÜÚÛÛÛÜÝÝÜÝÜÝÝÞÞÜPQO=./8EKOPPPOEGMR>+%=ILf_ZViS%)*'*(&%####D_UUC[J)[J.!'636,'&(&DscgB>,2wŠj:3$$**<Ž¨‘…v!!o‰ruR9¤zk0D>NTN†ŸY:L77797[‚w[‘Q?Vje“3M_3?6†W~ÂÒÏÒÕÕÖ××ØÙÚÙÚÛÛÚÛÛÜÜÝÝÝÝÝÛÜÝÝÝÜÜÜÜKKJKN>2*.=NRRQ?!9CRTED<?Z^XVmL#(+'+'$"! "#ETRSGbE%)_G*)#(3/5*'&'%Iq^k¡^R9#Kšq<7'(**@˜£³©q?"?>!! MzJKCOOCzP5D00157Ru€VŠ^?Tl¥HLlIZA‰­¬§ÔÔÑÕÔ××ÙÚÚÚÚÛÛÜÜÜÛÚÚÛÜÝÞÞÞÝÝÝÜÝÞÞÞÝ1AKJJJJG</)0?G6 3M]VPGF_UYnI&,*'*'&""! #LSPNLaA#,UA10R=,514&&''&Lp[l¬]H-2r:5,.5;M ®±½žT " "#vxf_:QRG|œU9B1/114KxvQ‹hEWp„‰:HkCQBŽŸ—¾¢ÔÖÔ×Ö×ØØØÙÚÛÎËÜØÙÚÜÜÝÜÞÝÞÝÝÛÛÛÜÜÝÜ5#"7GIGIHHA7&(+"!  ,EZUPLOXjA*-+)*&#"#""%NOQNRjF$-PB4=W@$/;32%&&$&Mn]n¸²rQ6)``9>%/49Ež¸ ‰z(   !#$C}ujGL@|šS6A00/5:PwxPƒoCRpzo4Gr1;,V•‹”¯„¾ØÑÔÓØØÙØÖºW@nÃÔÓÑÓÖ×ØÙÙÚÚÛÛÛÚÜÛÜN.-&*6ABCEFC9'3-"   #=PQBBR3 &,)()%#!   (RQOIVk?#1ND@FX;#.94<'&#""UmZk¶©–~;+DI8C1166H¢±ž“„¨Ž3  /Y."c†mOMDyVAI.-06=TyuVˆ[CTu{y;Lq116Q]}”¡ ¡ÚÔÔÔ×ÙØ×ǐY^U¤ÏÓÒÓÖ×ØÙÙÙÚÛÜÜÛÜÛÜK*DOF3$"-;@@?BCQLG7(!+9;==5,-)''$#"!"!*QRQCWj;4P9=Kb>"/62:%$#""QlZ\vƒ‡iJ;=91?/033D¡±ˆZ•­¤‘>#!Nsqb=X6CH?}§cAG-/*6;NuvNƒmBGu{‰ISv>?DmaGgŠ©Å×ÓÓÓ×ÕÖªc_cj¯ØÚÕ××ØÙÙÚÛÛÛÜÜÜÝÝÝD(FIKNMA1"#*69=MKPNM@,$!+4642,$&#!! (ONNG_m40M;?Og=.103%%&&$Zn]S^hyc\FD;2:-/22K¢´¢~¤’Á¬y4('\ zxfW=E:p¦iBH/+*27HrmS‚j>BprŒ?FyRaA†šxK…‰¤¨®°ÓÓÓÕÔ³qMZa}ÃØÑÒÕ×ØØØÙÚÛÛÛÛÚÛÚ$&CKLOONL@)"6QLOPOOMJ8)!  $37950'   ,VQLAal14H<BRh:#-//2&)%$$^q`:(E_b_P6836+032N¢­ZP˜zpqO %&Gn>‰†yi.%Q”k@F-,+7<MulP{[<@xoŠ9Ev_‡<†ž´…@‰–¸©¢½Ý×Õ׺yIlq¥ÆÙÔÖÙÚÙÙÙÙÚÚÜÛÜÜÛÜ/#!(:GNNM9+FF;..7INQONNLG>0"#06>4$"!   <JJHbf14D=AWk6"+.+*&%$"#[ka?*;J]]TB66'+-/B˜¥W)p£ƒC/0*11Q£“fLƒhtCO™H<-)'49FqlOiW0:ph…8Aq]~:ˆ«Ê¿vCxˆ©ÂÚÑÕÒ¿|M¡n¬ÔÕÔÓ×ÖØÙØÛÚÚÛÚÛÚÜÛJB.,'"(>E51KCFSC7-5AOVUSOOKD4(!  !()"     :UKFdh)AI?Cbd+)**)"%$$%_fZ45C&@PTG17'-.-CwpL3/„U.#+1.jª”|P#1>42#(!df0('*/DtyR}S4?qf‡;FqX~3„”³Îµp>ž‰¥£¶‚WO@X^›\Žtp¬ÐÏÎÑÕÖ×ØØØÙÚÚÚÛSS.5A;4'!"2GAFQNQP>0,9IRPQNNFB:)"! (>LJK&%BJ??ac.*+'''%%#%Z\]1KO"!!.442+/.,M}QNL%W˜]4(2;6q²°C!  $-Bƒyl5)+5x‚Em]9<tdƒ3=qY{?‚„™³ƒ¨_Xœ¯¦„X_Wb[šk„œk»ÍÎÒÓ×Ö××ØØÚÛÜÜ,6HVSLHDA2("&1?KMOPPM<++6DPPHE=6+"" '7HK#H?>@dc))(&$#$#"$Z\T4RU %! +20((*,LtqxN7@„X;53<7q²¤Žl)!$&L‹o<)30jŠYmd.Cqc…7AkS~?{‡K¦»©[Aœ£¯–zSU_IdT}| z˜ÔÐÑÓÕÖÖ×ØØÚÜÛÜ"&,2>b]HEA=<UVA!BUMOPQO5$&7FKDA80+&! !;'B@=:a`( **&&!!!"#UWQ/!UP(H*&+01+(),GjdŠ_4+m6138=9m´‹_«g& 5i'=ˆSBEB?w“gnw;6tj‡2<qXy/eŠ>W»¿½ŽStš¥‰—T4C<\X‡r§ˆŒÙÔÔÔ××ÙØÙÙÚÚÛÛ $(/1FZ[F>7O[UR9%CQNMKKF-&,3=81-+'  !!;A3"8F,!1@D;fU $)++%$""!'bXQ2!F@;X3"*..)%%'OaZ¨C):&.-560nªWUµ•o+/gu„‹e!1?>5o®€z€46sf29wWu.jM5x¼ÃÆ°?t¡«­›A7FANQGXÕÛÒÖÕØ×ØÚÚÚÛÛÛ!! !%)+5GZdSOPWXVR,"DCGHJH;*(+,*)&$"#!"!DWMI2CXNMH7::_^#)())$#""$_^Q.EHC[, &(%#&')A_c¯–L59-.-382h¬u‡“¼4?<o“r²ld/!2*N•‚ŠE4peŠ=?rZl<lŽRBkw{Œj›P„š¯¡ˆQ\_Nw\~“•ÊÚ×Õ×ÖÙÚÚÚÙÚÙÛ    !$)+4EadWMLOPRQ((ECDEC>1&$##"""#"(TYVN5!)HSLB@fL )-&%"##%#*TQL'!NCOM,)++)&&')NjX“›p<7./,7:4v§lš™Y'*!27fOqfL27W®£Ž;‚d’12r^m/r“J*byR –ʼn=›¤¤…yZ^Qvt‘p¥ÐØÕÖ×ØØØÚÚÛÜÛÜ   !#"%*-3Eb_RNNTURD"(@=>?93'"!    &BUR," =GDB1 %'(*"$$##+\VL+"[KWP*'+0*)'&$RoJN^{nM*3,8:4o­R<•a8)-2d¢r;"vx`=/hm?/n^f=l‘NJs€:y«ÊÕL¨¯ª—KYMŒn€lpÏÛ×ÓÖÖ×ØÙÙÚÛÜÞ '-07BgePNNMNJ:!.<72.*#!!"(F9+3==3 !!! ,=580-))##"! 1ZQK'$]IYE),-,)%$$#SpT#Im<7.24-ešW.‡„G.4?C}K!#'}qgXSŒE>t\f6jŒZYqn8NuªÅÄum ¸¹^QQˆu“spªËÝÕÕ×××ØÙÚÚÚÛ    ! %(/3JgbNKKIGC3'&%"! !!)KVUE:IFE6% !!  -268/!!! !0XPF#"XK[K(#+,(%$#"X^?>N&;90*010]yT?S|K53?9vŠmi"! #<c+P}jkižQ4d\aCgŽQIjs@?`d«Ra¤™cKFod\iwa©ËÎÑÔÕÖÖ××ØÙÙ!! ! !!%457Kpj77>?6%""!   !>TRSQPMKIF;+""!"*<7:*!#?L?*+QG_G#)++&#"" ZkexrxQ!<,+1/.g~[=<c165CA{…–­R%'&j„sO9zjx­•XDr`l=e”VIbk5:Z^g¬Ä¨Y†ŸRLGgbTacnoSg]Ymu†ÂÐÝ   !! $%.58Qgg>02+($! ! 1E7)E.5BLNOMGD;( !  ,! ;J@*$OFbH%&*+'#"""<V8!$%42,-/+Sv{N1)63E9k”•Áu)(*(g¬ˆm\4|ry51_dUD^˜YD\u=J_i6?†¹¥UiaE[l[ez£z‹œ¦„°£—ËÍÞ!  %&267Qte7$$##"3KIJJUK1)2HUMLGD=( (@ACGFUS"))' !!"(bA6FW-'21%',(Sm~E)50,(0-sŸ—o$'+)Y¦½º„o*Y„fa!,k`MPŒn<VuJWhj>X‹œƒ§Tv›HWibe\o”}´Ž¡ƒ‘‹§Ü  !#&-69Mtq,&%/FIJGJPNM>!%9JHGA908HCUP!(&&%$%%)Kw9CG/'31&&)(Un‘s1:1,(/'ujs-$ )-3f¬®±ËŸ…a2‡lcžL7Cf8QqLL_i=Pxd¯ÄžTF/7-a[_wrw^huj~ƒŽ§µß ! !!"",<<Vxm43FDF66PKMMK5(,>=;/$%!   &+  :MC>_A%'("$#$%;@=<UV-'.,)'(&ZdIuZ-1-52q„LL0#(575n¥¯½¬Ó¸wG&{} n:Q“lERwMLap4>wM}¥£S143<S ˆ¨ˆÁž˜ª~¬›¹¾Û ""$#&%7AC\pjOAIMH0"<IHHHA+%+,)%! !!"5IC5.NEEQ>"()'"$"%GL8BR]3#*,$"%#YhA'PO:5.6,[`-84' 9:2e¬»„ª³Â˒x@XŒyY-8yWAL}DCSo:NxB[—¤{F@Nf\ †|ª~Á¥—±Š˜–“šÙ"$#"$)5ECUigSDJNE-(=BBBA7!!! ! 5XI-!DU@9'-)'!!!$FPAHY[+#*'%#$#RaP, 10474de59-'(331lª¦¾z¹¨Ë«ƒ_GŠjp-Z€BTzNLRs4Fv?Jrh‰<B>kZqBq‚lg^xgr|s…‘Ñ$$(**+3CJWsjRGKKC+$:>;82"  .H=%!!'9:94&##"%QO8@PZ-%(&$&(%[`RD#)*+-,gd5/-!$01*^ˆtL5d“µÁ½‹X.ˆ`‰ždU}EARk=?s=<jNlAKN^]^\x¡t²¤Ž¸Œ”¼™´¾Ú &'&(+1DH\siNGGF>&&-,+%"! !CV9'GF7" !-@5*!!"(G7FO[%$((%$$"WXKP#',(,*l…Y*2 (.+ZqW$Lkk¼ÄÀɛf&bŒƒ­aX~3=Q^9DvCJtJI?K_Y|rN%œªšŽ¶•š¯ˆŸ˜Õ$'('*/EGVrjI<B<,!" "!##=_TQOKHH<+ !  "=3@K`)'('!##VaHX" (('**]kQ/*'%**(Osm? H"`‚v§ÁÁ·wF<iqF=<<f<@nKK{FmYLE|acYqj`ydgzgsŠ…À!#)().CFQnpL!&'"! :*,61IEMKH<,!*;Y#$'&""##JVQZ0&*(&*$ZW=G)%"*)(QkR<>H|¥r}´Á”^*ŽtjnHAAlJPƒIBlGihDG{qj\h{Ã†»¦‹Æ™™ÎÍ"$()*.7EUdlK-!##%ISHIA.5AIHA4+! !7Z)$&' "#"KTR[%)&%&&N\%!&$$/.$J}kV76F€„H=uª°»•s<vƒqN<AkC@kK8hPmhGFnei‰d‘y Ã}²²„éŸÄÅ $'(*.:F[eiQ.$KRMJNMF6+5<7+%  #?1/A?H%%%#!!!PZSa%&$"#$IZ-'""*)&G{kY21‚¨„;`_»³¾ªtHc|A78o8:ZLDrPcn?Ae`}‰[qmzhqi_sefƒwŸ #'(*/7DWhmTOOI904EJKD8*(%!! !$OF0$5EA/$$"!!KWN\'!("#"#JZ9#*"!''%E€p\*,!cŸqY{6d€{¶²°‘>9K36fC?gO;pZ`kAGr~be~u‰–– ®¥“ºÁ &%'-/;EWfniSNJ22=GLG7!!!.B<$!072)! !CUN[&'#!#$Ob>%# &%&Dzk`1,@iyY*h†TAhvz'&-,/c>7]W7pYUl?Ge{`c‚œzµ›¯‚²©”»¼#(+,.:FSiveRC@/.79.%"! !B85H='"& &@IU"#(%%$"I\;$ ! #>seV3,4pJC0BŒ}D\pq`<6W81WY;u_Ok<?]z\m€©tssquioqm{p… #',./;CWlpdN<2&#"!!!"BKITOL=+!"5?%%'&#%%NV=!(  BmdV3-&@rL70J’lGX6gY#2/"OG1XV?o]Rd58cyhorº°rv†š}¢¢‰¨µG9/*&./1:DUqydB%!! (>487>II<'!0<$#'$!!$LW:(  Bn_M-)&?oL/+:tjY4R[5G:6)'\V/fRNj7:`ƒgr€ÅÕ²˜“ÈŠ¯­Œ°À $C-+0"'-.0:DVou`B#.VNSJA208/   "ED.<B4)" "#JW>$!! ?oaR.*!@fP/#)WN6"8wb(K *<S8hXPrE9S}cwz…¡¼Šx{ƒjyq|vm/=&1  $%,016EUgtjAPI<@DLI;'#!!!!CI#!-;1$##5LD% >q\P*'6hG2(1]V3&W~a1X"/C?9J/lcCsH<OŠMwt­z¬¢ryˆzˆ–y’—*#    ! !&)245:=^sobM519D<( !!2;>;* #!!;A("#!!!<o`P#&4gJ5,/VV*"Hz]1[..8%! $V_Kt:6I}Jbl¾¼•·™Š¸™¶ƒ²! ""  #&&%%)+,=Kbt{cF%'"!"!"FQTRG4') "!8r`Q)(3hF3..a\($BsZ"-R& 1F"2Yf~Gy=;GuI`SµÌšˆ{yŠr~‡vr "!$134!%-19A[nxY5!!:933@7(/03@.$ 4d_P('7lN2(&P])%Fta)V+2V*HR6Vr@HB|D\VŸÈ©ywh{wt‰|ƒ‹!#/0/" !&)(0<QjvG#!MQTR8,  "DD")+  )E]S--7hO.&'WX2)BqY'P.&/P $=3!GLVCECxAXUyƒ®—­‡°‘•¶Š¾ $ !""""  "$(-/>aOLK>BFJ6*98'$D>,1 >cL+&+YT-#;v^#)I+&1O!%TG/g8 13g=UM}d‘Š…Ž‰¥°xŠ$*,# !#"$$!$$&MNMLA5'?OJA+!"IO./^I*+.ZU*1rd/3D+ .J%L<)G3!06,VCXL’‹Ž‰ˆ¤ÌŠs|   (6*"$""#$&%#)J< JJMNJF4" 7810)$ ,I(5 %5;RK%)+S\& /SM01I%)I$%D61I1-7#%:I=‡Œ…ˆ‰•œ¶¯~  !!)3"""!!!-64.*WN'MAGW@@5# !$EKDA( %;0ZG8#3HD9NX%$-H^ !B,"'H&#>;7G5.=#1&7@vžŸš›„‚¯Ž¨‚¥   "#)) #%1?5LM(RB4N!""! $BM:2-$'L/GKG;C02FDGP("2XP >.(G#!?<2B11I+EG),L„ ¥’Œ{¤Ð†dh !     "!%%%D%  !&)OH&!&JB>R)-# !$?MJC-#"D39' ">K(/NE,)+fX"B)'I'#>;&:35L+F\X#'R”´‰—”‡¬Ô™uÁ! !! !   !        $)*%%&'+.3,"%"$=:BW !&@ID?-%+E%6( (OYPI% !I@&UT$"9)&E+ 8:'<2-J&0O@@Z>`·¾‰’eqŽÂªwÀ""$!" !  ! ""!"') ##<kG"#$$D=?M+:'  "6C9/ /FE4"" &%CCBHC#3QP!;)&?*";A%80*N&+L>#Nc—¨…•ÌŠfumo    !"!!!!"""!!#"!! !   +( "(&  $C65:<?'"4??/*[<*-$%'C5&=oRH(#L*F% !A,!7;'?5*J!'D*.M”‰¥¼˜œ}‚`˜027::4-('$$"#"##"!!!!" $""""!       '*  3:.A<D&6>@*  +MK7*!EML0"$%$=<7>-%$C,$=2%<C%9?FH&?B(&;‹ŠŽ‹”“°µ}™79<==<;6,&&'((*'$"!"!!! !)6:AKQE)%$" "9BBE$"#4>=2' $=209#%D=,.$&((9#$;<=98. -5.9(:!(D>&'Y†‚ˆ‹‰Š‘¸§tz;<=>?;:82//0279>?>>=1.%%/7ABHHHE94+##!!!:==D%"#4>@?-&:=2!?FD6)9CB8$/9!22++%-7&*%8&':O.8R†€Š…ƒ‹Š’«Ë½b423368:545668;<????=93.38DGLJGFGD@1##""!"!""!    "  28HE$#=9:=/+I-.$9>94L@?!$&(+!6>#.+!1%$<I86]‚€ˆƒ‹‡ŒœÏ¹Œ1,*(),4777785534479:6/.7@INNJFFHGG@0###$$"!"!!!!!      !!%%%" #'! ' 35GB#"26<;0$45*86%'6:8"4#6,62+5,+8"=#%6I1A]|‚”|ƒƒ‡—ÍÀ}*&%! !""$*2454.'&#"""$,4;EOPQS[\XNE/%$##"##$#"!" !" !!    !  $&*3>C6)%% !(.BH%5;7;6 !!1/# 73"1844C@0F !(&#,+#3-930S2<Itu|š„~ŽŽººl/,-,%'$$$(,18<<:0(%$#$,/5DMOWY[][TH3(#"!#""""#"!! !!!    !!!""!   !%-:@T`W? &&/AA# 343=3"0/$)($"#6&"-9!'$!4/,*2P15@|lnš}‚€‰…¸¼‡**+05663.'+148;=;90(%'1<;<@BNYXYYTL9)#""""!!!###"! !!     !!"!""!#!"!!"""%$$!!    '=Recd]4 "2,06KE"89695#:6(:>!0:!"<9$#760 -$#*;86@cR†zƒ†ƒ¹¹‰**,0344*('&&-1:>;72,((1AKJC64;KUZUL;+#"""#""#"""!    !!!!!!##"""    !"""!"#"!!#&1?A)!  !9019GB!257;6 &-+"$,3C'*22=(7#+($!,D?4+:~}‚‡ˆ°¼v-/0343/)%"" !#(/12/,((3>KOMF8/2>PRL<,"#!!"!#""#!!!!!   !!!!!""!    !!!"###!!! !  "$# !!5+3AC-! 25-93)3* '* 8")% #()* (H(1$ ML))MfD2ci”„‡¦¼u;;:7553443342101/00-((1ALNULD3/6ADC:,$"!!"")-*(#! !!  ""!  """!!!!!!!!!"""#""  !%""!6/98 ! 611@.!.2 &19$#((#$-)4"7( FJIM( #\„kuˆ¸v==:4235666:<<<;<94.(#$0<KPURD71.4::4)$##""&),.,&%""!#''(%#!  ! !     !!!!#"!   #ZsY5!;7882-#13,!92.0: (1!"$#$(#$6,DKAP7 W’ƒŸ‚‡Â873/-,.169;;9;;;51-)#")4ELRMA4,,-./,'#!  $&')*,2=DGFE<4'#!!"#%02-$#!   !!"!!"  ! ""#"" 4(.2((! ,2/'(/-!""=" !"%'"' $! =<GM?  4X”¨˜’s#$$ ! ""!!#%+,-,+($!!!)3?HKH8,$'(+*($!  %&')()/234346779::630-/..*%$$$(('####$#    !#'6&,5*%/60,& +3(#(*6#"$&%%#2'%/=$8‚pL“’¡       """! !  !)7>@?0'$#$$$$#')0242/.,-/0454403567:650-*+3479;<63431)*/,***&%#   &<)*1+-(#+1<43-#%' #'  & "+$#",'"&.2vj="\…!!       !  !  "%'))$"! !!"!"!#')+/20347734230.223.**(**-255.0032651//034531/0-(#"2'.1&*( '(DTI1$&?>6' *%,!  $( !2'$&84( .6'+!D!""##"$%%$$#$####%&$"!!          !!  !!#%&&&%(*'((,.136887776653/-0446643111+!  #2(.0$"#&&&*8B/ #/;8)#6V<""*! # &!)'#%H#8~XD07',!        ! !"$%%&%$#!"##$$$%%%%#!!     #%$"   !!! "!! "$'*-10/2114::::;6+!  $$%!!")'(%)'*'$ *+,;.'"%(/L/$"'$ " #  *%#6:imuzuN!! !!!        #$$$$$$%%$!"$#$###$""!     #%('%# !!!*%!&'$#&**"").(+ #!!%!-C;;622MGTRQMPQ\/"-'( (#!# "*+$&M(-PT`c‚~   !!!"!" !$%&'&(')*(&%$#$$$$',1) !   ""$&(# !#!&$+[TD-+/<-8)0 &09% "' &%!*4..50 %.70Rdo          !""#"#$%%$!! "')+'"%.'!"!#'!!&3a|H0$DTl,.+0F;""%( $ KbN1,ji`I45E(7/&    !!!  !      !         '>6 !$#&$%*`t;2&>(+',A>4@!!FrZ-# # !  J‚…’\FS[l>7[@o !      " !        !!!" ! !  !! !!!"!      !  "&!!,5/&# "?K0" B&,989(+)E: $"""  ! GgBS=fW&&3,/AG-. !  !!!     !!!"           !!!!!!!!! !!""!"!!!!!!!""        !! %0. +,$! OUI;LO$7cY\bU-!20  4L%-*;:,6?>;H-%,      !   ! ! !!         ! !!!  !"##!!! !!####"!!""#"! !  !!!,& !#%    ! !!"  #@\C5"+kqL=,(($0"*').3\FW# +   ! !   !!! " ! !!  !       !   !!!"###"""""""#"#""##%"!! """!" /A.! 49RS]I['#/-"*Y%(*%0H"&KI/8/Q7;4J] "!!!! !    !     ! !! !      !!  !! ! !!"""!""#""#$#""#$#"!!%#""!#?;  !04M%)6937.1(20*"$=)*6.%&00;/PMTSVf\VR]j4,2:3Ptl]!       !        !!!!       !!! !!!!""#""#!"##"""""" !""""!     #%'"!!!"!!!%6Q$'6=@HKI;LWSSSPP[a^_eeklcgnmjhijjidi]eb]YWTUVU[ !             !   !     !!!" !!""!!!""#""""#""""#!#"!"!!  #(/:FEBB@A>;@@B>==;95431&#'" %!(*:&E;CCIPX`dcdccdc]\YYVUVXWYWQMJIFDEFLQMRXT\\\[Z           !      !""!!  !!!"""!""!""###""#"#$$%&(*% $ENR^^YONKPX\[\\\\[VWZ\]ZYVVTRNK>60$$(-AURXlnifc^]ZMIJGFFDAA?@@@AJIOHOIGHJRMNOONNQ]db```         "!   !! !#%()*+/02356889;<<>?BCEFFDDDCC@=6 +0),/,+'++,,?][[[\\[[[[[\\\[ZWSMDACFHMNHHG>?>>ACCCGA==;99:CMAIMEOLEIFEFFDEFFIIMPTTVWXZcYYb!   !    !!!!!"!!#$%&&*+.256779;=<=<=>@EEIIJJJJJIIILKJIIHFEBA@@?>;:775431200.(! "@dU5(01*$#!!%8`^[VNDB@@?=6>B><:?BHEGB<?>=BCCEHKBABXEBGB>LF>A??>>==><=?@BCDEHIJKLLLb\NPOONOM!"""%(*-26DEHLPSRRRTUUTSQQOPPPQPPOOMOMLLNMMKJGDA@@=:653232343233431122322223/)#3EN4!& !! !!$(&$#%2FSYXWF=3223456765456887005N_EEJ==:<<=<=;<::99;<<>BDDGGGGDEGONNIGHFGFEEELMOPPQRRRRRRTTUTVWWWXUUMLJEE>884332333333422223354555443343434422/-&'%&###!!#8:7," !!  !!%;==;<:;:53212677;==;;:<@SW=9;534889;;;9:8877687;;=>?@A@AACFFEhiDFCCCDEEDDHPNOPRSOLFD<8322457888878776679898998877455556664344121,+*(&&##"""#!! ! !!! !"!  $8@*#" #/004253432211234425:531113356756675445678875788:<<>;98:>?B?@>=<=>><<;=ACC@@@F03567555478997788987757888998888740/-+*(%%###"""!! !! ! !"!"""" !      !"  !  !*-.*"&+-/-/.//--1213235666776645446777789:9;:;9;8867:;>@>]Z;><=;<:;;<<=>@B@?>>?@FIJ24666667799988887532)'%#$$$$""""  ""%%  !!!!" !!!!      !"      !   #"! $<B3/...--00101023544332332022689;;<:::999<<<<=?>==<==<<<=:=<;;:==>?><<<=???A>@011-+('%$$%!%""" !  !  ! !!!  !!""    !    ! !  ! !       ""%'--./0/1011211111000///11456686759<88733388:9;;;=<><===<::;:;<936779:9<:<<=F[P  !"""!! !!"       !            !   %%"!&),-././+0/000/..-,-,..012345453545>7888FqS.;<==>??@>>;;99;<<=>;;58<:9@@@?@CH;C?;!!! !    !      "   !   !"!    ! !    !!!!"# "%')(*(+*,,,+....--/.--,.//00/.../101002346578:632279:<:778888;;;<????=:;<:7<86<AC@>@?D?@C  ! ! !" !  #&&%&'''(''%%''))*)'(*+-.-..////./0345565566677564:88775336878:999<:5548541/EV=;<99997=PH:_\XTPNORUXZ]^`cffgimprokeccejmorqljgebbcb]\]afjkkotz€€€€€€€€€€€€€€€€€‚‚a]XME@>?BGNV^aa]Z[aeijeaZXXXZ\`fjgc^[ZYWSPLNRVYY[`fr{€€€€}{{|‚‚€€€‚‚‚„ƒƒƒƒ‚faYOG@==@EMW`da[VX^eihc^YXYX[^bhie_[Z\_ceb\VTRSWXY[dlv|}~€||}}€€€€€€€€okcVNGC@?@DKVahga\^bghc]VUUWX^cgie`][[^aceca]YUVURRYdr|~|zurru{€€~~~~~€€€ige^WQNLHECDIO]hljc_affa[Y[^bfijfc`\XWX\`dfc^WUVY\ZY]gpttpjhjpy~€€€€€€€€€€€ljf^YVVVROJFGLXcnsronppnfa^_afihge`[Y\aeiifda[UVW[ZXW[hpvvplebfnw}~}~~€~~€€€€hiha[VVVWWXYWVZakt|€|wmd^]^`acdb_]\_enpnifea]XVSTUUX]clqojdYNO\jx|~~~~~€€€€€€€hfc]XVVUTTVX\]\^biry}}|xpha^`deddd`]Z[_dfebbcdd_YVUVVVZ`gkid^XXV[bmu}€‚€~~~}~€€€€€€kjha\YXYY[_cca__`fmv|~|zungecceeb_\ZXW[`cccb`^]ZUUVWXUUY[\[ZX\]_dlt|}~~~~~€€€€€khf`[[[[\ajrvtojginsxz{zzyxupjggfd`[XVZ_dfca`__^]YUVYY[YZ^_a^\^bbdjsz~~}~~~~€~~~~~khc]ZYZ\]_djprtqkkmpwzytmhfedbbdda][YZ^dfec]ZY^cd_YUW\^\]^`cddgkhcciuz~~~~kid]ZZ[\\\`gouvropquyzvrmookfa^adea[Y[ahihe`_^`cddca^ZXZ^_aabcefdbdgpx|}~€€€}||~€€khf`[Z[]\Z\afkpqmllotwsmjknqod^`cc_ZX[`ehgea`adhjjhec^VVV\][\`ccdgmrvz}~~~}}}}~€€€okf`^^]]]^`adglqpoprvwrjdchnstsnkjg`\]`cdca\XX[bb`]]][[YZ[Z]ababbddjqx}€€€~~~lgd`\\\^_^aaafntuvuvyxrja]_ciptuutsnkfeeedb^Z[^bba``a`^_dmtvunmkjgcdhpz~€~}}}~~~}}pkfa__^_flonkkmpststvvpjb`djopt{~~|yuojhgeb]Z[_cc__`bcdeiorple^WUX[_emv{~~~~€€nid_^^^agnwwspnoprtuxwqib_behjmuy}}{{xuplieb`begea``bdda_`abeb\Z`aa_bity}€€€€€€€€€okeaaabchntuuutrpqtwxvqkedfhhghouzzyvvtqmhba`bdgfeefedb`_bdgfdbdhjfcdjry|~}}}~€~~~~lhecaaachmrtssuwwuuuwvrnlntutonqvywspnjihfca`bdghgfgigcaaejnpmkkkhb^bfnvz}}}}~€€mjfbbbcdimsvxz||zwwxyvnfbeow{wttw{|xtnjddeeca_`cddeeffdcejprpnnkhc`agpw{}~~~€€€€€tpmifdccgkqssqqsuvwwxvog``gmsttuvusojjlkheda\WX]aa__adghjligghedb`_dkrz}~€€€||ysnjijlostsrrtwyzz{yqia_birxxxwuqicbgnqrrpmjfeedcehhfefijlkjjkmnnnpuz}€€€€€~~€€qwz{ytomlmqqpqruwwxxwupjedehnrtuurne_XYcoxzwpfa_`bcdfghhjmmjghijmmkkpuy~~~~€€€€iosw{}{ywvvutuvvwy|}{wsononnpuyzwtne\RPU_ltwtldaacdfffeehklkhecdefefiow{~~~~~~€€€ihhkoux{{ywuqoorux{}{ytpprtrpprvvtqjd\XZ`jooic`_``acghfdimmmidaa_afjorv{€€€€€€illjjjlnoqqponosvy||zvqmnqwyyuttvwvsppmjlnojgc`abeddggeejnnmjedcdglnmkkrx|}~€~~~~llmoomkllmonmnty{}~}{xtpqsvvwxyzxvrmjijnpqpke_bjqtqkigeehnpnjgb_`ccecbfls{}~~~€~~rrommosxzzwsppsuy{}~|wqopuxwwxzzxvqnlmoqnkhecdgqy{ypfbabglpolf`^aeijgb^^gu|~{xy|}€€€~~lmoqsrqpqswz{xvvx{~~{xspnosuwyyyxvqligjopnkgaZ[cnusnighjnqpmjebceggb\WTU]isyytqtx}€€~~~rpmmnqsrmiilsxyyyy{|zwqnmmptvxyzywtomihknoniebfinpoib_^`eknnliffffeb\XWWZbkuz|zy{~~~~€rrsutqooomjhfjpuy|~~|xsppqssuwz{zvtuvvutsrqnllnrupicadhkloqstsnmljgcbba]YY]eknnposx{~}}~zwsqqrrqlkjjklmpux}€|yurrsu{}~|yvssuxzyuqmighkmgb`dluvqlhhfcadhhea`aa_\Y[`effddkry}~~~~}~zvqmjihhikmqsux|}{yvutstuy|}}|xussrsuxyxtojhjmlgb^biljgfdb_]^`bbacd`[VUY[]_cehmt{}~~~€~{xuplihilnpsvz{zvsssuuvwy{}|xussrrvwxtmgdeijhc_bfjjgefhigbacefeec`ZUUVTUW]afoty|}}~€€€}|zwrnllnqux||zxsstx{zzz{{zwvtssswyzxurpmnoomjhiklmotxxqe^[\^cggfea][YYZ[\\biqvyzz~~€€€~~|yvtrrtw||yvojfhlqvxz{{{yusrrv{}{wutuuvutttrojcelpoi`ZX[aegedeeeb\Y]^abehijikq~|}}€€€}yxxxz||yvqolkklotw|}{yvsrquy{zurrtuuplkklmkghlpnh^WW\begfdddffb`^`ccdgjjijm‚€~€€€€|zxtqnlllooptx}~|wvuuy||xtsswzytnihjorrqqpjbZVX[]`fihfdhhfdbccbcegiiin€€ƒ‚‚€€€~{wsqponnoqtx||zxuuuwxz{zvsqtxzxvsqqqstvwsoha_^`aacehlnlhda`_acgijliim‚‚‚‚‚‚€€€‚€~~}zvqonoqtwzywussvyzzzzyxxz~zursvvutuutplea[UTRUY]`acccfikgdccfghhl~~€€€€€‚‚‚€€€€€~|yurruwz{wrlijntx{}||z{|zxtstvwtrrssqnlkjh_ZUTWZ\_`cegihhhhiknpr€€€€€€€€~~€€€€€€}zvsssspmkknsvz|zwvw{|ytstvzzzz{zvoihiid]SRW[_cdefgfcbbcgkllm€‚€€€€€€€€€€€€~}{xuqmkjikoswy{ywxz{ywutvxzyyyxvsppqpkgb`_beghhhggiiiihhiil€€€€€~~€€€~€€€~}{vrnnruyxtqosy}}zyyzyyz{{wrnnoplheiprsusnifdcddbbehkn€€€€€€€€€€€~~€€~~~€€€~{vsrrrssomnuy{zyyz{zz{|{wsmmpstrrrrtwwriebbfjjihhlor€€‚‚€€€€€€€€€€€€€€€€~|{xuqmkilsy{zwwwz{|}}{ytppopqrssttwzywtpnkklkhhghm€€€€€€€€€€€€€€€‚€€€€~~}|{zwtstvxvrpsy{|}||{xtrtsqqqoopsvvvtqqomkkkkjkl~€€€€€€€€~€‚ƒ‚€€€€€€€€€€€~~}}~|{yxvpmosxyxxy|~{xvtttsssstuwwvtpnmljfabehk€€€€€€€€€€€€€€€‚‚€€€€€€€€|{zz{||{wtpmmquwxyz|~zzxwvuvwwwvusqprsrpkgfgimr€~~€€€€€€€€€€€€€€€€€€€~~}}|}|zwtrrruwzyvuvy{yutuvuvwuvwxxwwwwxwtqlhgggi€‚€€€€€€€€€€~~€€~}{zzzzyyxxywx{}{xvw{~}|{yxttuuvwyzyxyxwtpnid`bho||}~‚‚€€€€€€€€€€€€€€€€€€€€€€~}}}~~}|{}~~}zy{}|wuuuuuustw{|}{yywutturlgdcfpooqtxyxxx|~~zxxy|€€€€€‚€~~~€€‚€~{{{{zxy{}~{ywwvvwyz{}}}|zzyxvtpjeddisssrqrqrssuwvtpnot{~€‚‚€~}}~~~~~~€~|||}|yyy{}zxxyyyxxyy|~~}|{{zurnifdddgwyzywvvwy{}|yuqppu{~€€€‚‚‚‚‚€€€~~}||{{{}€€}||}{zz{|~||}}~|yyxxy{}~~}zywtpkgeegguxyxwwuuuvyzyywuuv{}€€€€€‚‚‚‚‚€~}|{yxutvz~~{{{}~|{z{~~~}}}~}|{||||}}}}{xuutrnigetstwz|{xuuxz{yxxyz}~€‚‚ƒ‚‚ƒƒƒƒ‚‚‚€~}}}}}|yy{}|yxz|~~~~~}}}}|zzzz{||yvsqlifccqqrssrqprtyzyyyz|~€‚‚€€€€€‚€€€‚ƒƒ‚€€€€€}||{yyz|~~}~€~}}~~}|||}||{{{ywvwwtnhb~}||{yxwxz||yyz{~€€€€€~}|{{|}~~~€€€€‚€~|||}}}~~€~~~~~~~}}|||}}|zxxxvnjc‚‚‚‚‚€~~~€€~~}}~~}}}}||||||}~€€}||~}}~€}|{{{z{}€~~~}|{yzyxvs€‚‚‚‚‚‚‚‚‚‚‚‚‚€€~}}}~€€~}~€€€€€€}{yyzyxz{}~€€€~}{xvqnk€€€€€€€€€€€~~~~~~€€€€|xwvxwxzz}€}}~}}|{xwvsl‚€€‚ƒƒ‚‚‚‚€‚‚‚‚‚ƒƒ€€€€~~}~€€€€‚€€~~|zxxyz{{~€€~|{{xrnlkosq‚‚‚ƒƒƒƒƒ‚‚€€€€‚‚‚€€€€€€€€€€€€€€€€€€€€€~|{zyvtux{}~~€€}|{zzzzy€€€€‚‚€€~~~‚€€€€€€€€€€€ƒ‚€€‚ƒƒ‚~|{wtsw{~„ƒ{zyzyxyz{{xƒƒ‚ƒ‚‚ƒ‚‚ƒ‚‚€€‚‚‚€€€€€€€€€~}}€€}|yvtsstsrqppqolllmnnmml‚‚‚ƒƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚}}~}|{zz{|}~}ywwusqqqqqqqqrsuvwvsronnmlmoppppqrrqooonnnm€€}}}}}}}}}|yyyyxwwxwvtssssttttttvxz{{||}|{{{xtpppqpqqrsutrrstttttttuvvuuvurrrpooqrrxutttssrrqrqrrqqrstuutuuuttttuwxyz{}~~~~~~~~~~|vvwwwwxzzwvxyxwwyyxwwyyuttuvtpqtrrrsxvtssstttttuvwwyz{|||~€€€€€€€‚‚‚‚~}{{{|~~~}|{zyxxxyyzyyyywvuvvvwwvutrq~}|}€€€‚‚ƒ‚ƒƒ‚‚€€€€€€€€€‚€€€€€€~}}|||}~~~||}}}}|{ywwxyyzzzzzyyyzzyxwvuu€€€€€‚€‚€€€‚€}}‡Œ…€~ƒ€€~~~}~~~~~~~}}~~|z{zz{}{z|{yy{{{|~|yxwwxš›››™—––—˜™˜“Œ’–šš™–•–––––—–••––•••••—–••—™—•“‰…€„‡Šˆ†‚€€€€€€~€€€¢¤£¢ žœžœš™˜˜šžŸ    Ÿžžœžœ››››ššœ ŸŸ¡Ÿœ–’ˆ„‚€€„ŠŽˆƒ€€€€€€€€€ž ¤¥¥¤ žžžœ˜––—™š›žžžŸžžŸŸžœŸŸ›˜––™šš™˜šžœ˜”’‹†ƒ€€„‹Ž‰„€~~~~~~~~~šž¡¦©©¦£¡¡ Ÿœ˜““’’“”–™›œ›œžš˜˜™Ÿžš”’“˜š™—••™››™–”‘Œ†ƒ…††„ƒ€€€€€€€~}}~€€€€~šœž¡¤¦§¨¨§¦¦£ ›–’‘‘’“”––˜š›š™™˜šŸžš—•–šœ›˜–—šžœ›™–’Œ†…‡Š‹ˆ†„‚€€€€€€€€€€€€€€€€€œ ¢£¥¤¤¤¥¥¥£ ›–Œ‹ŒŒ‹‹•˜™––—›žŸžš•‘’–™šš˜™žŸžœ›™—”‘‰ˆ‡‡Š‹‡„€€€€€€€€€€~~~~}™œž ¢££££¤£¡žž›•ˆ…ƒƒƒ‡’––””—›Ÿžš˜”•—˜–•••˜›žžžœš—”‘Œ‘’’Œ‡ƒ€€~~€€~~~›Ÿ ¢££¤¤¥¥¢¡ ¢¤ ™‰„ƒƒ…ˆŒ‘”™žŸžœœžžžžžžžŸŸžŸŸžœ˜——™™™˜—“‘ˆƒ€€€€€€€€€€€€›œŸ¡¡¡¢¡Ÿšš›Ÿž›•†„„†ˆŠ”—œŸœ™˜——™™š›™™šš››šššš˜–––˜˜™™™š›˜”‡€š›Ÿ   Ÿ™”Ž•šœ™“ˆˆ‹ŠŠ‹—œžžŸžŸžœ›š—–—šœ›˜–—˜˜—–””“–˜˜—”’Š…€€€€€€~š›žŸ¡  Ÿœš–‘Ž”–™—“ŽŒ”–•“’’•›Ÿžœœœ›š˜˜˜™™—“‘”˜™—’Ž‘–˜—•””Ž‰„€€€€€€€~~~˜šŸ  ŸŸž›–“‹Š’•–’‹‰’••’‘’•˜›œžžžŸŸžœœš˜––————˜››œš˜—————––•Šƒ€€€~~—šœŸ   ž›•‘ŽŒŒŒ‘“’“™š”‘”˜™™˜™™™™šš›œš™—–––———™šš˜–”‘‘–—––—”Š„€€€€€~~~~—šžŸŸŸžž™•‘ŽŒ‹‹Ž’“’“™ž ›•’ŽŽ‘“•——šœžžœœ›š››žž›š—•’’•—™˜”‘‡ƒ€€€€€€€€€€€€™›ž ¡¡Ÿžžœš™”‘Œ”“’™Ÿ¡¡›•Ž‰ˆˆˆ‡†Š“—šœ›šššœœ››š™™˜•Ž”——•’Žˆƒ~~~€€€€~~˜›žŸ Ÿ›–’““‘Ž‘“˜œœš˜–’‡ƒ‚…‹–™œœš˜˜™š™˜˜™™–•“”•••––”‘ŽŒ‰…€€€€€€~~~—›ž ¡ ž›–’ŒŒ’“’ŽŽ•™žŸžš”Œ†‚‚ƒ‡Š•—››š™˜˜˜—••˜š›œš™˜—––—™››–‘Œ†€€€€€€~~™ ¡ žœ›•’‘’“‘‘‘“’ŽŽ”˜šœ››œœ™•Š‰ˆˆ‰”™žŸœœ››š—–”•—˜—––”‘’’•—™˜”’Œ†‚€€€€€~~—›žŸžš™”‘Ž‹‹Ž’“ŽŽ’––“’——”‹‹‘’–™žž›˜˜›ž›™˜—™™š—’‘•˜˜˜—••”‘‰ƒ€€~~•˜šœžœ™”ŽŽŒ‹‹ŒŽ‘””‘ŽŒŽ’”‘Œ‹‹‘‘‘”———˜™œžžœœ››››™––”•˜˜—™—•‘†‚€€~~~~Œ‘•˜››š˜“ŽŠ‰‰Š‹ŽŽŽ‘”•’Œ’•”•š›˜“‘‘’•š›š™˜šœ››šš˜—–••—˜™˜•†€€€€~~ˆ‰Œ‘”˜™—“ŽŒŒŽŒ‘•–“ŽŒŽ‘’’’•™œš–‹‰‰Š’–™šš™šœœ›š™™—–••”••”‘Œ‡‚€€€€€€€’Œ‰‰‹‘‘ŽŒ‹Œ‰ˆ‰ŒŽ‹‹Ž“––”‹ŠŒ’’’“—š™—“Ž‰‡‰Ž”—™™—–——™œ›››™––”””••‘‹‡‚€€€€€œ˜”Šˆ‰‹ŒŒŽŠ‰ˆŠ‹‰‰‹”•“““’‘ŽŽ’•—šš›—‘ŒŒŽ“–˜————™››š™–““”–—˜™–’‹†€€€€~~™š›™–‹‡‡Š‘Œˆ‡‡Š‹ŠŠ‹’Ž‘”“’—š›š•“‘‘“•——–••—˜™˜—•”“’’““”““’Š…€€€€€€€€~~~›ššš›œ™•‘ŽŽ‹‰‰‰ŠŠ‰‰’”’Ž‘‘”——˜˜—•”“–˜–•’’˜š˜—•”“’’’”“’’‘Žˆ‚€€€€~}~~~~~——™™™˜—•“““’Šˆˆ‰‰‰ˆˆ’”“‘ŽŒŠŠŒ‘‘‘”–•”•—™—“ŠŠ“–—•’’‘‘’“•–––”Š†ƒ€€€€~~~~••–˜™™”‹‰ŠŒŠ‰‰‰‰ˆ‰Œ‘“’‘Ž‹‹‹Œ‘“”•••——•Šˆ‰Ž”–—–””’‘’””––”’Œ‰†ƒ‚€~€€~~˜——————˜•‘‰ˆˆ‰‹‹Š‰ˆ‰‹’ŽŽŒŒŽ’“’‘’“““–™œœ˜’Ž’—˜™˜˜˜•’’“••”•––”’Š…ƒƒ…†‚€€~~~~—™™šš˜——™š™–ŒŠ‰‰‰‰‰‰’‘ŽŒŒŒŽ‘“•••”’’“–š›˜–”’‘’’’“””ŽŽ‘’“”””–˜š™•Š‡‡‡†„€‘“”–—˜˜™™šš—’ˆ††…†‡‹ŽŽŽŒŒŒ‹‹ŒŒŽ“”“’“•—š—–•——•’ŒŠŠ‰Š“•——•“’”–—•’‹‰‰ˆ†ƒ‚€€€€‡Š’“•—˜šš™˜˜–”‹†ƒƒ„†ˆ‹Ž‹‰‰‰ŠŠ‹‘‘ŽŒŒŽ‘’”–˜˜˜˜˜—’ŒŒ‘“’‘‘“•––•••”””“’Ž‹ˆ†„‚ƒ„‡Š’•—™š™—–”“Œˆ††ŠŽŽŒŠ‰Š‰‰‰‰Œ’‘ŒŒŒ‘‘’”—š–’‘‘’“”””•—™˜–••••””•“’‘ŽŽŒŠ‡ƒ€€‚ƒƒ„†‰Œ“–˜˜—–•‘‰ˆŠŽ’‘Œ‹Š‹‹Š‰‰ŠŒŽŒ‹‹‹ŒŽ“–šš—•””•–•••“‘Ž‹‰ˆ‰Œ’“••–•”“’“””•••”‰‚€€€€€€‚‚ƒƒ…ˆ‘”––•‘‰ˆŠ”–“‹ˆ‰ŠŠŠ‰ŠŠ‰‰ŠŒ’”•••–—™™˜–”’‹ˆˆŠ‘’”•šš™˜–”””•––”’ˆƒ}~‚€€‚„„…ˆ‹Ž‹ˆˆ‰Ž”˜š™•‘ŽŠˆˆ‡‡‰ŒŒŠ‰‰ŠŒŽŽ‘“•—˜˜˜™š˜“‘‘“–—–”’’”•––••”•”““””’Žˆ…„ƒ‚‚‚‚ƒ„„„„…‡‰‰‰ˆˆŠ”——˜™—”Ž‰…„„…ŠŒŒŠŠŠŠŒŒŽ“•–••–˜—•””••–”‘‘”••”“””••–˜—“Œ‰‰ˆˆ„‚‚‚‚‚‚‚‚‚‚ƒ„‡‰Š’–˜˜——–”‹†„„†‰‹‰ˆˆˆ‰ŠŒŒ‹‹‹‘”–—•”””““”–™™˜“‘“•–––•”’’“”“‘ŽŒŠŠ‰†€€€€‚‚‚‚‚‚‚ƒ…†‰Œ“–˜˜—•Œ‡†ˆ‹Ž‹‰‰‰‰ŠŒ‹‹‘’’’“’‘“•˜™šœœ›š™–”’‘‘’“”••–•’Œ‹Š†€€‚ƒ‚‚‚ƒƒƒ‚‚‚ƒ„…‡‰”••’ŽŠ‰Š‘‘Œ‰‡†‡ˆŠŠŠŠŠŠ’’‘‘‘”—˜–“••“““”–—––—˜˜˜™™—“Œ‰‰‡€€€€‚‚‚‚‚ƒƒ‚ƒƒ…‡ŠŒ‹ˆˆŠ•—•’Ž‰…„„†‡‡‰‰‹ŽŽŽ‘‘’’’‘‘“–›žŸš˜˜——˜šš˜•’Ž‹‹‹Š‡‚ƒƒƒ€€‚ƒ‚‚‚‚‚‚‚ƒ„…†‡ˆ‰ŠŽ’•—–”Œ‡†‡‰Š‰ˆˆ‰ŒŽŽŒ‹‹‹‹‹Œ‘“””–˜š˜—–••••——˜˜˜—”Œ‰‰‰‡‚‚‚€€€€€‚ƒƒ‚‚‚‚‚‚‚‚ƒƒƒƒƒ……‡ŠŽ“–––“Šˆ‰‹Œ‰‡‡ˆ‹ŒŒ‹ŠŠ‘Ž‘’’‘‘’’”•––’ŠŠˆ„‚‚ƒƒ€€€‚‚‚‚‚‚‚‚ƒ„……†‡‰Œ‘ŠŠŽ“”’‹†„…†‡ˆˆ‰Š‰‰‰‹‘‘‘“••‘Ž“•–•”‘ŽŒŠŠ†€€€€‚ƒƒ‚‚‚€€€€‚ƒƒ‚‚‚‚ƒƒ……†††‰Š‹‹Œ“”’Žˆ††‡‰ˆˆˆ‰ˆˆ‰‹Ž‘‘’’Ž‹ŠŒ“–•“’“‘Ž‹‰†€€€€€‚‚‚ƒƒƒ‚‚‚‚‚ƒƒƒ„„ƒƒ„††ˆ‰’’‹ŠŠ‹Œ‰†……†‡‡ˆŠŽ’’’‘ŽŠ‰‰’‘ŽŒ‹ŒŒŠˆ„€€€€‚‚ƒ‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒƒ„………†‡‡‡‡‡‰ŠŠ‰Š‘ˆ‡ˆ‰ˆˆˆŠŽ‘‘Ž’‘‘Œ‹Š‰Šˆ†‚‚‚‚ƒ‚‚‚‚‚‚‚‚‚‚€€ƒ‚ƒ„ƒƒƒ„…†…………‡‡ˆ‹“”ŠŠŠŠ‡……†‰ŠŽŽ‘‘‹Š‰‰Š‡‚‚‚‚‚ƒƒƒƒ‚‚‚‚‚‚‚‚‚‚‚‚„……†ˆˆ†……‡‹”“Œ‹ŒŠ‡‡ˆ‹ŒŽŽŽŒ‰‰‰ŠŒŒŠˆ‡‡‰‹Š‰‡‡†€€€€‚€€€€‚‚‚‚‚‚‚‚ƒ‚‚‚ƒƒƒ…†‡†…………ˆŠŒŠ‰‰Ž‰‡†‡‹ŒŒŒŽŽ‹‹‹ŒŒŽŒŠ‰ˆ‰‡€€€‚‚‚‚‚‚‚‚€€€‚‚‚ƒƒƒƒƒƒƒƒ„†ˆ‡………†‰Š‹Šˆˆ‰Ž‹ˆ‡ˆŠ‹‹‹Œ‹ŠŠ‰‰Š‹ŒŒŒŒŒŒŒ‹‹ŠˆŒ‹‹ˆ…‚€€€€€€€‚€€‚‚‚ƒ‚‚‚‚ƒƒ……„„……†ˆ‰ˆ†††ˆˆ‡†‡‰ŒŒŒŽŽ‹‹‰ˆˆŠ‹‹‹‹Š‰ŠŠŠ‹Œ‰¡¢ ›•ŽŽ‰…„„‡‰ˆ…‚€€€€‚‚‚€€€€€€‚‚‚‚‚‚‚ƒ„…‡ˆˆˆˆ‡…„„‡‰ŠŒŒŒŒ‰ˆ‡‡‡ˆ‰Š‹ŒŒŒ‹‹ŒŒ‰œšš™˜šœžŸœ–Ž“–“†‚€€€€‚‚‚‚ƒ‚‚‚‚‚‚ƒ‚‚ƒƒ„†ˆ‡‡ˆˆˆ………†‰ŠŠŒŒ‹‹‰ˆ‡…„„…‡‰‰‰Š‰‰‹‹‹Šˆ’ŒŠŠŒ‘””‹‡††‡‹‹ˆ„€€€€€€€ƒƒƒƒ„ƒ„„ƒ‚‚€€‚„†††‡‡‡…ƒƒ…‡‡‡‡ˆˆ‹‹ŠŠˆ‡††‡‰‰‰‰‰Š‹ŒŒ‰‘‘”—•‰ƒ‚„„ƒ‚€€€€€€ƒƒ„……†…„„„…†‰Š‰‡‡ˆˆ…ƒƒ„…††……†ˆ‰ˆ‡‡‡‡‡‡‡†…†‡ˆ‰‹‹‹†—•”‘Ž’Š…ƒƒ…„ƒƒ‚€€€€€€€€€ƒƒ„……†ˆ‰ˆˆˆˆˆˆ†„„„…„„„„……†‡‡ˆ‡‡‡‡ˆˆˆŠŒŒ‰‡‡ˆŠŸœ››™’‹†………ƒ‚‚€~~€€€€€€€‚ƒ„‡ˆŠ‰‡……†ˆ…ƒƒ„††††‡††††………„……†ˆˆŠŠŠ‰‰ŒŒ‹‹‹‹’““Œ†ƒ‚‚ƒƒ€€‚‚ƒƒƒ‚€€€€€€€„†‰ˆ‡††ˆˆ†„„„†‡††„„…††…………„„„…†ˆ‰ˆˆˆ‰€€€€€€€€€€‚‚‚€€€‚‚ƒƒ‚‚‚‚‚„†ˆ‡†††‡‡…ƒƒƒ†‡Š‹Š‰‰‡††††„‚‚‚„…‡†……†‡ˆ‰‚€€€€€€€€€€€€€€€€‚‚‚‚‚‚‚‚‚‚‚ƒ„„…†††………†‡…„„„†‡ˆ‡‡ˆ‰‹ˆ†„„„„„„„„…ƒƒƒƒ‡ŒŒ‚‚‚‚‚‚‚€€€€€€‚‚€€€€€€€€€€‚‚ƒƒƒ„ƒƒƒ„ƒ‚ƒ‡ˆ††‡‡ˆ‡‡†……„„„„………††‡‡ˆ‰‰€€€€‚€€‚‚€€€€€€‚‚€€€€€€„„ƒƒ‚‚‚ƒ„ƒƒƒ‚ƒ…††‡ˆ‰‹‹‰†……†„„„„„…‡‰‹Ž‹‰ˆ€€€€~~~€€€€€€€€€€€€€€€‚€€€€‚‚‚‚€€‚ƒ„†††‡…ƒ‚‚‚‚‚‚‚‚ƒ„‡‰‡††††€€€€€€€€€‚‚‚€€€€€€€ƒ„„ƒ‚‚‚‚€‚………„„„„„ƒ„ƒƒƒƒƒƒ„„†ˆˆ‰ˆ€€€€€€‚€€€€€€€€€€€€‚‚‚‚‚‚‚‚„„ƒ‚‚‚ƒ‚‚‚ƒƒƒ„„„…………††††‡‡ˆŠŠŠŠŠ‹ŠŠŠ‰€€€€‚€‚‚‚‚‚‚‚ƒ‚‚‚‚„…‡‰Œ‹ŠŠ‰‰‰‰‰‰‰‰ˆˆ‡‡‡‡ˆˆ‰ŠŠŠ‹ŠŠŠŠŠŠŠŠŠŠŠŠŠŠŠŠ€€€ƒƒ‚‚‚‚‚ƒƒ„……†ˆˆˆ‰ŠŠŠ‹‹ŒŒŽŽ‹ˆ‡‡‡‡‰ŒŒ‹ŠŠŠŠŠ‰‰Š‹Šˆˆˆ‰ŠŠ‰‰‰‰‰‰‰ˆˆˆ‡‡‡‡ˆ‰‰‰ŠŠ‰ˆˆˆ‰Š‹ŒŽ’““”••–——˜˜˜˜––••”’‘‘Ž‹‰ˆ‡„„ƒƒ„„ƒƒ‚„†‡ˆ‡††‡ˆˆ‡‡ˆˆ‡‡‡‡†…†‡‡††‰‰ˆ‡‡Š‰ˆˆŠ‰‰‰“˜›œœœ›š™–•”‘ŒŠˆ†……„„„ƒ‚€‚ƒ„ƒ‚‚€€€‚„†………†‡†††††††‡‡†††††††…††‡‡‡ˆˆ‡‡‡ˆ‰‰‹Œ‹Šˆˆ†…ƒƒƒ€‚‚€€€€€ƒ€€€‚ƒƒƒƒ‚‚ƒ‚ƒ„„…†…………†††††…„„„……†‡‡‡††††‡‡†††‡ˆˆ‡‡‡‡ˆ€€€€€€€€€€€€€€‚€|usx€€‚ƒ‚ƒƒ……„„„……†…†…„……„„††††‡ˆ‡†…„„………†‡……ˆ‡‡‡ˆˆˆ‰‰yÀÃÅÇÇÅÅÆÇÀÃȸ“¨™R­__u_ƒbe•£rTMFEC1:>CF=o¼¿¹–|KS™£`SJG<DF@>NNO@…¾Á±n^BIgsǵ¸·ËǖyI0u˜‹¬Ž‰ÑÖÒÖØÙÙØÚÚÛÝÞÝÞÜßÝÝÞÜȇÙÔØÚØÚÚÛÚÛÛÝÜÜÜÝÞàßßßßßßßßÝÝÞÜÝÜÞÞÜÝÞßÞÞÝÞÞÞÞÜÝÜÝÝÝÝt}T:“Ƽ¼ÃÇÈÇÆÆÈÈ¥’Õĝ’‡5’m_yX€j ¡hYDKDE7AFHM;u¾À½°i)Nž´yRe<>TXE>MLNBœÀ¾Ä‹oWYYŽn¯¡ÇªÐ¾–g=C{‰|¸¦£åÔÖÖÚÙÛÛÛÚÚÛÛÛÜÝÞÝßÞÞا„žÕßÙÜÝÞÞßßàààßàßÞßßßàßßàÞÞßÞßßÞÞÝÞÞßÞßßßàßàßÞÞÝÞÝÞßßޟa :Â·¹ÀÃÇÊÉÈÇÇÆÁ‚¯Êš8.W›Ywbc¦ŸZJOKHC1DEEF;|¸¼·…MVi£Š‘|g\@.aVB:MPQO—ÄÅϤ“mWUn‚ˆ”n··±ÈŚ~FBŒ„œÌ™¯ÚNjjÊÕÕÖ×ÚÛÛÛÜÝÝÝÝÛÛدµt›ÛÖØ×ÛÚÜÚÝÜÞßÝÝÝÞßßßÞÞÞßÞßßÞßÞßßßßÞÞÞÞßÝÜÝÞÝßÞßÞÞßÞݏ=#I”°º¹¼¿¿ÆÅÉÃÇÇÉǦœB07:CarU|cMMQID0:DHMI…º¶³†?FDy·£tWH:4OJDDNP[Q–¾ǾnELe„y}Z®°·½ÏƙpZP‘ˆŸÌ–µÈƒc…ÍÕÔÔÖØÚÛÛÛÛÝÝÞÜÖ¦•º™ÛÛÚÛÚÝÛÝÚÝÝÞßÝÞÞÞÞßßßÞßÞßÞÞßßßÝÞÞÞÞÞßÞÞÝÞÞÞßßßÞÞÞÞß_7#E‘³¬°¸»¿ÄÅÇÅÈÃÆÆƝU—z/)56k™vcxe[NPQGE:DCEGB½À¬œY?^‹}œ€SK>3IH?<LLPF’¿º±¼~LTV~niDKŽ¿¾¼ÒÁ•i:D‡Š®Ç‡­±v£×Ý×ØÙØÙÚÚÚÝÜÝÜÝÚضŸÜÕÖÜÛÝÝÝÜÝÝÞÞÞÞÞÞÝÝÝÝÝÝÝÜÝÝÝÞÝÜÝÜÞÜÝÜÝÝÞßÞßÞÝÞÝÝÜÝÞÜg=0F˜¢¡ª¨¬°ÂÂÅÃÆÆÃÆÇŲ\vM!03Bšer€dPCC?:@ADFFˆÁ¿½ŸZMh«½”RfO95PK@@HJMM•»½È ¿|tMU`SH@I@‹´ººÉ¿_9W—‡©¸ˆÃ«®ÝÐÔÕ×ØÙÙØɃ'‹¿ÑÔÑÉ×ÙÛÙØÙÙÚÛÜÜÜÝÝÞÜÝÝÜÝÜÜÜÝÝÞÝÝÝÜÝÝÜÝÞÝÞÞÞÞÛÛÛÜÝÜÝÜÜÞÞÛ>/'Jƒ‚‘’“™¢°²¸½¿ÁÁÄÃÇÆ¿“@ˆq216;x¤tbˆUV99<FEDEG’ÄÁ¸©fYk–`ƒU4V8ALO:=JKLMžÀÀÁ€§_|SN\N>86C·©¼di¬yU5NŠ{¸²|ÇÏÓØÖÙÖЏ3(DKZjŠ§ÕÕÒÓÕÖØØÚÙÝÛÜÛÛÝÜÜÚÜÛÛÝÝÝÜÜÛÛÝÞÝÝÝÜÝÞÝÛÝÜÝÝÝÝÛÛÛÛÜÛÛÚÛÛÛB)&Ptnyy|ƒŠ‹™¡¦®¯´¼¹»ÊÅÇ©W*$-.Q—€Tfb]64?BEAH“½½· bapŸzSDfA?CNL@AJIIHŸÀÁÔ²¤\ZGSS>050*kqud­¡|A.JŽ„¸ž‡ÑÍÔÓÕÕÔ¶[R[VSX …ÊÒÐÒÓÖÕØ×Ø×ÙÚÚÛÚÙÙÚÙÚÚÛÜÜÜÜÜÜÝÛÜÛÝÝÝÞÝÜÛÛÛÚÛÜÜÜÛÛÚÜÛÛÚÚÛL/)Ypknruuvuv{¡¢¢±ÃÄÈ»vE‹`$(.2y^WebJ.816=¼º½ _To•iY?W2CHG<AJKHN¨Ã¶´ÄžSvkOYSEAL?:—{£ÆÁ±vO$KÆ ŸÐ§Q*=GGJLIR¬žªØÏÑÓÔÕÖ×××Ù×ØÙØÚÙÙÚÛÚÛÜÜÜÜÜÜÜÚÜÜÝÜÝÝÜÜÜÛÛÙÚÜÝÞÝÜÜÛÛÛÛÝÛD1(Zlmpprsttttvz‚ˆ•¨ˆ¨¿Å¸”PP0$**6l‰j\`VD)13?Œ¼Æ¾Ÿ]Uv¨zcb:D=?HG<AGHHK§Ä¸˜ˆ³XndDSOE>ME@‹£Œ‰¦½¼Äi4(i‹¢È¯´`CKIEIHFB=;2Q§°ÍÑÑÓÒÓÔÕ×ØÚØÙÙÙÙÙÚÙÙÚÛÛÛÛÛÛÛÚÛÚÜÛÜÜÛÚÚÚÛÜÛÜÜÛÜÛÛÜÛÜÛÚÚB&'ekklmmnrttsppprv¼±–™¿¼¹¿y,!4*$&&5HEBWIE0&6X2E’d^~«’wC=;<@LG:BHJHH§¿³‰¤‡ oN_WMGND;†¼•}¹³½¿ÆgK7‡ƒŸº¼™L/42/123213pªŸ§¸ÓÔÓÕÕÕÖØÙÙØÙÙØÙÙÚÙÚÚÛÛÜÛÛÛÛÛÛÛÚÚÚÛÛÛÚÚÚÛÛÛÛÛÛÛÛÛÛÛÛÛ>%2nilllmkontsnnnos^Jœ³ª”žž£ªp,&3,%##(9)! %XqcoV„­†UO5FHOG<AGJHY°Á¡T|‘FJ/DBEIED:6z©_vŠ|DZ¿½•g97ŠŠ„³¯awˆN//..1120I¸³¯³­¶ÉÖÓÔÕÖ××ØÙÙÚÙÚÚÚÚÚÛÛÚÚÚÚÚÚÚÛÚÚÛÜÚÚÙÛÚÛÜÜÛÛÚÛÛÚÛÛÛÚ7$;sinmmkkkklponnojˆl8e´­xK®ƒF3#)$! $"7gfkU[‡¤’ŒbˆWGFKH?EHJDZ·»ˆ=zu@s2<I@=557<€•_Z™¥¿¸Á²\6>–£Œ‘’‰/<<:43.-<w ´¿¼»¶¯±É×ÕÖ××ØØØØØÙÚÚÚÚÛÙÚÚÚÛÛÜÛÜÚÚÚÚÛÚÚÚÚÙÚÚÛÛÛÛÛÛÚÙÚÚ5$;oellklkijlmnmlmh~›ˆS<„“Jos‹rL9($'#6|u`mX‚¬–Žm•pDDGA9DDF>T²¾Y–}ax\>PH7GEJM‘‡z]ls¿´µÁĆV4R‰ŠŠ‡¸’Âo;*/4421haŽœ— ÅÀ½½°±Ê×Ô×ØØÙÙÚÙÙÙÙÙÙÚÚÛÛÛÛÛÚÚÚÚÛÚÚÛÚÚÛÚÛÚÚÙÚÛÛÛÛÛÙÚ1#FqhjkklkkijjlmnnhbecmXHL;‚”s—e<.#" "jŠjfciš‰s¢lEIJ>6BDD?U®¾“Y¡V}VASL5FHHB‘§uSExtž¶²µ»½Œ`6>Š‰È¡¶~;DIHAG›n£y}“²¿´·¤ÓØÑÔÕ×Ö×ÖØ×ÙÙÚÙÚÚÚÚÛÛÜÝÛÜÛÛÛÜÛÛÚÚÜÜÛÛÚÚÚÚÛÜÚÛ."OngkkhhijjihjklnjlljqeP Eku~g|•vB3$!!!Eˆt_ia‹kžiKOIA4OONF\¶»ˆm¥}ŽaERNALNOE™µpHAZq…įÁµ„Q2Z€œÀ—«¾fOZ[[V©–ovŸWOwp’¯œˆÃÜÑÒÕÕ××ØØØØÚÙÙÚÚÚÚÛÛÝÜÛÛÚÛÙÚÚÛÛÜÜÜÝÛÛÜÜÝÜÝÛÜ-&Xcdiijhfghiikjkkjh^SYc[7g]RlwWNlc=3#!!).+mkQ]Ip™`NNKC9MJK<[¶»ƒsª”N4CHUOBIIFEŸ®}oESzkf´¯«É¹|^8e–£¿‹©¢`]XIBž´ƒV‹wfo…t•¹ÖÔÑÔÔÖ××ØØÙØÙØÚÚÚÛÛÛÛÛÛÛÝÜÛÜÛÜÜÛÜÜÜÛÛÚÛÛÛÛÚÛ)%\gbfhjghfhgghhgh\4!#!#/5oZI7OoWDFV<,$ $/2"O_EIP{`OHG?9GHK<c¸´\¤ƒOB6;HHBOOJHŸ¶žHLexkR{¨¹¸È­{V/q‰‡¥°…º aZLCŒ³{ES›Ÿº‚L7b¦ÆàÕÕÖÖØ×ØØÙØØÙÚÚÛÛÛÛÛÛÜÛÜÛÛÛÛÜÜÜÜÜÜÜÛÜÜÛÛÜÛÜ&(bbbedccddebdedgfZ:#($# 2eaH30`dM<K>*$   "$+\A&,5[Zv“^LHHA:HEG<g»µv]”†`L5:PE=LMJE¼´˜A:PhNENb´À¨¦€M"x‹}¶¸Ž¾ŒA4>“ ’^LeŸ¨ŠJKvšŽ»ÜÔÕÓÔÖÖ××ØØÙØÙÙÚÚÙÚÚÛÚÛÛÛÛÛÛÛÛÛÜÛÜÛÛÜÛÛÛÜÛÜ'/f]`bbccaccedcdec{‡E+3.&!!/eZH;#I`]=:5" !""&/pnb*") %,Mut—\IGE=;LLM?m¹³}`«”J<=<TK<NLEE¡¹¨™aHPZK9B?˜½£\¤{C#k‹„±£‹¾pF=t¡nE>`Ÿ™nKO`“ŸÙØÔÕÖÖ×××ØØØØÙÙÚÚÙÚÚÚÛÛÜÝÜÛÛÚÚÚÛÛÛÛÚÛÜÚÚÜÛÜ"5mcb`bacbabaacba`‰¥yeoX'+0]SUS#$RXA**&&%$&'Z|wn8pjVqvt‰–KBPJ@<LJPGs¾·<Œ“[C9;MH<LGEI¤¶ª¯qPJUH-?;<n|d¢À¨pC3{…‚¼ ƒCGP‡~6:;5’Ÿ‰H7:‹ÅÙÐÔÓ×ÖÙ×ØØØÙÙÚÚÛÚÛÛÛÛÛÚÛÛÚÜÛÛÛÜÛÛÛÛÜÛÛÚÜÛÛ":j_ced^_abb__aab\—¢Œzƒj .%8bG^MG1(>3 !  ""+BQvq;QgKUsvˆKKMNB8HHKDyº±wpªŒKY3;KA:GFAL¦À¬‡‡QFVP:KC;…r¼±È§|C:ˆ†¨`6CEƒ~>FgBHŒICD”“­ÛÕÓÔÕÖ×Ù×ÙÚÚÚÚÚÚÛÚÛÛÛÛÚÜÛÜÜÜÜÚÛÚÚÚÚÛÛÛÚÚÛÛ >h`dcdb^__`bb_`a`š¯›yŽr(9* $DWE@QG*#(#"!!#$7vPAY2!<jWBqXKJNH?8EEIDx¾¯iy|VW7/;JA9ECAO¢£”†d>TNAJFAŽ‹ ·¸¸Í¢mGQ”…Z3CCˆˆN_~C5]–YFN“™ËÙÓÔÕÖÖ××ØØÚÙÙÙÚÛÚÛÚÚÚÛÛÛÛÜÜÜÛÜÛÛÛÛÜÜÜÛÛÛÛ$G_\add``a^^\_dc`^Ÿž¢”—ƒ=!BE%'YLFPP93.!  "#0JnpAD/ &RsVkiQNC91DEHE„¸­ky}OT_7EMC7AB>P¥¯›–bDTQBKGC——°½®Ä y-?”„}>4:„žoŠU*rtuŒM:2g™®ÝÔÓÕÖÖÕÖÖ××ÙÙÚÛÛÛÛÜÛÛÛÛÛÛÜÜÝÜÛÚÚÚÛÜÝÝÝÜÝÜ(UXZ]\_^aacc^^\`_eªž™€ªc3ib2$ <XCNN=71%#&&*(O|Pcj>-&!>v\WpW?37CEFK¹©e}tPRYCLPD:JGA]­¬ž{8257><A:;}Ž}š}»¯¸ÁŸa.f~g6;Š‰‡]R=>e9‡l:,T¡ÔÓÒÓÔÕÕÖ×ØÙÚÙÚÚÚÚÛÚÚÚÛÛÛÜÛÜÛÜÛÜÜÛÜÜÝÜÝÛÜÝ)SS\[\\Z^aabcb_]_]•§ƒ¥ˆ•_skC8)PG:D881&$'&('W|sgR^.-.  6^_XXQB1D>=FŠ¶ `‡€MTkGDQFBLKFh±Ÿ‡zZSH69IIH…W‚r¤¶´½ÃŠ_0Z’~U"ƒ“bJD;‡e8S]1n†—Î×ÓÓÕÕ××ØØÙÙÙÚÛÛÚÛÛÜÛÜÜÝÞÜÝÛÛÛÜÛÚÛÜÝÛÜÛÝÜ0]TVVXZ[[]_``bb__YIPŠ„¥‡ˆ|€q=L"9L;A+76)&$%('\{pxhcbG*4)!#GdIKYB/+/3p¸§a“ƒbgSDEJ?BPOHc® žžZDRDHYXS›’e[…™­¶¶³r@.fvNu¥r>GL={˜d6`IAh’²ÙÖÕÖÖÖÖ×ÙÚÚÛÜÛÜÛÛÝÜÜÛÛÛÜÜÝÜÝÝÜÜÝÜÞÝÜÝÝÜÜ4^Y_\UVZZY\^bbdd_Orj4~¥‰Žp‡8P*"3NA\+?2&($'',dtmoijfgI%5*"#NoOTeD*./o˜i”‰j„r7AED?GHAh«® ~\FVHNQSP”MCxvŒ‘½«µ•2'*Z3.$!(/dS3RtG:/~_5L‰—ÙØÒÓÔÖ××ØÚÙÙÙÚÙÚÛÛÜÚÛÛÚÜÝÝÞÞÞÝÝÝÜÜÝÜÜÝÜÛ:bZ][\[VXYZ][\bb^EmRwL4Y†Œ‰8V;'E@F4B-)'$&),coq_Msfed6#1 ""$JC4MM:1c) 0ˆƒw›|4?MB9SRJ·¢¬«£]JWKQ[Y\¡šQJo|^x»È½°f1$2-)+7Eƒ[„e1G:E‘kX‹†ÒÖÓÕÖÖ××ØØÚÛÚÛÚÛÚÚÛÚÝÝÝÜÝÜÞÝÝÛÛÝÝÝÝÜÜÜÝÛ?Z[_^^\ZZWXYb`_\Y<,gQpcJ8Šx#CO#.>80>5-)'*+/hzpruyUOjd`E3(&" '&#18{s¨ˆ@JL><UMEr±§›•ML;SCLRSUž’TO`s;E\¤¶…rv%'*)),3-Pˆ{ƒj(ŒR*aŒT•Ž»ÖÍÔÔÖ××ÚÚÚÚÛÜÛÜÛÛÛÜÜÝÝÝÝÜÜÛÝÜÝÞÝÝÞÜÝÛÛÛD_VV\[[ZZ[YZ_]a^T/%!?jNrh?C$;^%'1C32;5/))**2rus5R…b@5Df=+$&$# 06-*V›{CJL56FHHw³«²–UZA]HMVST˜–_NQXLF@n¥{‰†G,:7Yo.Ž’‡h—)SsmX¥ÍØÒÔÔÕ×ØÙÙÛÚÛÚÛÚÚÜÜÝÝÝÜÜÛÜÝÝÝÞÞÝÝÜÝÜÞÞÜP[VWVVY]]^``]\[[T("DMKY7<<j%+1@78<2-*('(3op{tb4f7.A]I9&)   'M<*(^qBNN94OLBj­£—™B94N@COMR¡‘ukPVE9;%`r›¬(5@D:}‚]<pŠm_8>qY-•giˆ­ÙÑÑÓÕÖ××ÙØÙÚÚÚÛÛÛÛÜÛÛÛÜÝÝÞßÞÝÞÜÝÝÝÞÝÜÜMUUWXZYXY^]^][XYN#&& )$RIMT5g-%*=5120%#&&(:opompfE@=hdO[A<! EN/23EIJ75KGBs±‘¢›269LBFIJR–†zPQ<NYE…Š¨Ÿ`?;G?:}¤}`D›~XR=`hE`¥¦‰¤ÕÔÐ×ÔÖ×ØÙÙÚÙÝÝÞÝÜÛÛÜÜÞÝÞÝÞÝÝÜÜÜÝÝÝÝÝÜÝSUXXWXVXWW[Z[[YYH9;""^B7)R@WQ42";440*$$#%$;ohjhafdS/2kmNC]<3)!! &   7\586LJ9:CFAw³—T<>WGLNKMŸ¢ƒ|>M;OT6‘´x];9270e¡›g€hCRJ_bVi™†‘ÂÕÔÔÖÖ×ØØÚÛÛÛÜÛÛÛÛÛÝÜßÝÞÞÞÝàßßÝÝÝÛÝÞÝÝNOXYYRSVVXXXXZXWF&LY,(jLE+Q>Z86C6:4-%&$$$Dk^edkllc<U\>‚_=WL1&,*,*  %`TPKK8:FLI‚º£ª•9.8QDKOL]¢pkGWXMQ9Šy}[:7<?<s¬—n¥‚xD5:Tw<C@‡˜€®ØÕÒÓÖ××Ø×ÙÙÛÛÜÛÛÚÛÜÜÜÝÜÝÝßÞÜÜÜÝÜÛÜÛÝÛQOWUWTUUTUWXYVVXB+S]/$-aHQ -O;\L66--#%$$%Godce_ ",^cK(ZmJ@G,#"!%$A{J%4)ArwEUV;=PNH±Ÿ~Qb=AQHJMKRœ’bW=C8<=4\ŠNWL>&-01<†¥pzš¦v8Ec\Fˆ?1Œ‚’ÔØÏÑÓÔÖ×ØÙÚÙÚÚÚÛÛÜÜÜÛÜÜÛÛÝÝÝÚÛÛÝÝßÝÞÝ`_VSTTUUVWVXVVWS=7`],$9lMA! 2A:>72)$#%%#Cg`i['" !#Z_H,+iU,%#  !$E€tFKqATWL@G;@MMHw³ŸŽW#8ERFLSMV¤œƒvCP?d^O…œxPE,&*ChTO„4(41l‘hql2g¥„ÅÜÏÖÔØ×ÚØÚÚÙÚÚÛÛÛÜÜÜÜÛÛÛÜÛÝÝÝÝÜÝÝÝÝÞÝVS^dVSRSUVZYXVTS?;b]+ ;hBlX"  '9131'&%$%#Isc^€}Le/%TWPP 5C1"#"! .HqN1iKMpZJ6?NL?w¸£G*<FYLHONN¬©ˆw@RBRTHuTWA+#/<b\oD$7@@:‚žgD4B’vÅÓÐÑÔÕÖÖ××ÙÙÚÚÚÚÚÚÛÚÜÛÜÝÛÜÝÝÝÝÜÝÜÜÜÝÜÝ=OUT[`XUVVVXXVTQBCcZ%$@S5l`(&'2:/4)(%%$&&Mjaa”q=)%&RK@M5$"##%&MoFV$$%\aWqY9CMN?w¼žYr5QWFKPMS­« vAQCNPE}š[gH6(&4?qbD--32EbO’‚VE7™½ÑÌÏÑÒÕÕÖ×ØÙÙÚÚÛÝÜÜÜÜÜÝÝÝÝÜÝÜÞÜÝÜßÞÝÞÞÝÛ@?9H[Y[]UQUUUWUNCJeP!#BN7xV*(EF%.=22+(&'''%Ve^WŽ“t•6!3#:YE_C/*! ")BTW;'<waeb@470W¦šzeƒ??LDEEANª¨j`<KDQTI|›TNO80:L>nwmA3BAr•]`qEF7‚ÅÙÕÑÓÔÖÖ×ØÙÚÙÚÙÙÛÜÝÝÝÞÜÝÞÞÞÝÝÝÜÜÜÜÜÜÝÜÝÜ<F>@;@SYXZNOUTTOCJfM"&:=C|P34ZQ&$/=/6-%&&&(*Vb]W•’V.U9 &RMOE82"%#%&\oFqRSf0ƒƒZlC-%J¤‘„q>ML;FHCL«¢_A8LCNMBuž[VR:3Rb8lwvC@DBh—zŠy?@PŠ¢×ÕÓÕÕ×Ö×ÙÙÚÚÛÚÚÛÛÛÛÛÜÛÝÛÝÞÞàÞÝÞÞÞßÞÞÝÞÝ! 7M@A=BVVSTMPPIARmF)VMOƒMFB^C#(3:24**%$$&+Z`^^š®oTk9$:T2751$'(/ilr¡›oz1#)h|O|n9P„?GtJNK?HLFU¬©e2=S>MNAw£`TSD2SZ>pypX\W<LqW¥†PQT„{ÎØÎÓÒÖÕØ×ÙÙÛÚÛÛÝÜÜÜÜÜÜÝÜÜÜÛÞÞÞÝÜÞÞÝÜÞÝÜ +IH@>;OQQRNFDWc;$1ePVMLD`>&2507,)$$%#1YY[`—’ˆ¡r{oN<*EH>85"'**/pkeg Ã¤X  ",(   &hdf@DH;JKELªW0:P@TRF…©kWU:2UZ6mruA>FEc|~#.7iz¢ÕÓÓÓÕÕ×Õ××ÙØÚÙÛÛÜÜÜÛÛÛÛÝÝÝÝÝÜÜÝÝÝÜÜÛÜÜÜ!<A?A@CMIGE[e@+^P^}MLJ`C'56-2('&%$$.][ZZV=}x€VL!;H;;8%))*/lqx“eŸÊ¡\+!""#  ,A…fqZAGDX\WYªfS9H<HIBv—N8>?5Q[8fpoD14/h;(GFC‚“¥ÙÒÔÔÖÕ×ÖÙÙÙÙÛÚÚÛÚÛÛÛÝÝÜÝÝÝÝÝÝÞÝÞÜÞÞÞÝÜÞ7'%!!   !.C>=;:AC`f6-`L\|INQjF(53.7*'$$%%1ZWZ]Pa]MqyƒEJ70H4;5-///4oulŸÀˆA…f3+&'!!!!"#%AŒh~yH=DKIK¤›bJ@MEMJ;x gLN21Qd2fup?4=0AR)5;<HF•ŠÐ×ÑÔÕ×ÖØØØÙÚÜÛÜÜÛÜÛÛÜÜÝÜÝÝÝÞÝÞÞßßÞÞÞÞÝÝJ;4'#! !  )6?=@?<cc:"1c@apKNPaA*2/+3)'&%%$-_YXK4QQaQK[>R:+=2>4,//06lwoayc…="    #"30"=Žw…s=HOMU¦ŽHJ:Q@MM@zªiEQ71H_:ewrGgk?ZM2><L‰KyªÖÓÒÕÕ×ÖØ×ÚÚÚÙÚÛÜÜÜÜÜÜÛÜÜÝÝÝÝÜÝÞÞÞÝÞÝßÞßMKEB;+#     "-:?=CA,%8Z9mlNLWa6!(1.,-*%%##"/YVZG"7U]jV/BF &60=-')((4lqv¯™[e¹š£•K  "&RtL":u|]BHPMU¢†/'9IBLKC†©j?K/0GY:apXžrGnf8@8J„£ÏÒÑÓÕ×Ø×ÙÙÚÛÛÛÛÜÜÜÜÜÝÜÝÜÝÞÝÞÝÞÞÞÞÝÝÝÝÝÝKKIJFD;0&  &*6;3"B`=u[PL]`, (2*,-)&#"$#@^QTB!=S\WFA%0,=.&'&'7pivÁ®s¦Ž¬­šC$%0€pzsGWUA?LOKY¦‰C3AIAJM@ˆ¢TEM45IR>eu`§HelMYBS}l™º¤¶ÌÖÕÕ×ØØÙÙÚÚÚÛÛÛÜÜÜÝÛÝÜÞÞÞÞßßÞÝÝÝÝÝÜÝÝPPOMKJIE@6'" &'&BZ@pYVQ_\(&+2&*)'%%#%#?aVW<$!+/?I\G1%61@/)'('?oglm`m¨‡c­™K&*<²y“h\lS>GLG[¨Šrp?K>HL?„žQ?N21FO9dˆx_•GBYm<N>Dƒtf"*KšºÕÑÒÓÕÕÖÖÚØÚÙÚÚÚÚÛÚÛÚÜÜÝÝÝÝÝÜÝÜÝÝÝÜÝ->MONNMLJGA@/&2O9%%K[ArXVQe]$"*1*+)&#####=\UZA@<%UG(&BMJB3,;.)+*)>qg^?77d—’„PI3($(++v¥l8ayfyT:==N ‹xu=K6=H>užN0M50?N9W‚y]ƒH8Pq.74+]<+4;N~€Î×ÏÑÓÕÕ×ØØÙÚÚÛÛÛÜÛÜÛÜÝÝÝÝÜÜÜÜÜÝÜÝÜÜJ6-9GSNPOMMKGC=OWd@ 'GRCm\YRgS$(+),)(%##""C^SQ?PB)TH0 *>>E86,')))Boff€B2*m |X,+.'/47‡¦Žn:‚opg6&4Žut6G>FKD}V:G<68=;XwT‘@9Pp=h$2N6<*jS{†®×ÎÑÑÕÕ×ÖØØÙÙÚÚÛÛÚÚÛÛÝÜÝÜÜÜÜÜÜÜÜÜÝÜOPL?309GLNOQPNHFLP8*'<GTi]YYgN&++(*'&%$#"$O[TTDb@"*`B." +635(''(%Lt_iŽE:$7z}f=1&(*>’§“Šo%"{„ttJ:›ti5E;PWM‡¢N;J75786Y}RS?[htŠ5P\6BAŒwUˆÃÏÍÑÓÔÖ×ØØÚÙÚÚØÙÚÛÜÛÜÜÜÝÝÝÝÜÜÜÜÝÝÝÜKKMMN@4(0AOONM> 8AUUDB=@`aZ[jK&*+&(###"$"%GUTSJfE!*dB%!,$%1/4(''&$Mu^fž_T1"I˜o67$&((@™¦¯¢n;(;< !"%#QtIK@RPC‰—J6G..168X{uX–V<Zl‰CRkJV>“­¯¡ÑÕÏÔÓÖÖÙØÙÙÚÛÚÛÛÛÛÛÛÜÛÝÝÜÜÜÜÝÜÜÜÜÜÜ4@IHHJIH>((1?G64K\VODJeRYnC(-)%(##""""'NQPMOh;$0Q<.1V6"-208'&'&&TsWl¯€YG+8Œh77+36<L§¯°½˜G""'yrj^<OQEˆ—L>B+-/43SszW–TG_l…‚>PiFPE’˜’»§×ÕÔÕ×ØÙÙÙÙÚÚÉËÞØÙÚÚÚÚÛÚÝÛÝÜÜÜÛÜÛÜÝ4#):HIHJIJ>4(%(+EXSOKMYo<(/'%*"!    (OLPLRl> 2QC;AT8#.8.1'(%&%Zr[mº®oN,'hY59#468P¦¹ “ˆo"#!#$J€€raKI<…™K5A1/.5:V{€RŠdAVkwi4Hl.8&X‘Š”©‹ÄÑÏÕÔ××Ù×Õ°VBrÆÑÑÑÓÕÖÖ××ØØÛÚÛÚÛÚÚN),* )2ABDBEA8(3-"!=SMA@Q,$*'&'%#! ! *SMNJSg? /NC?FX:%.919###"#RjWk¹ª–€A)CG9B0/33F¡®›™ˆ«ˆC!! /X+&o‡fLT@€¡WAE,-/7?SxyQ„hDPo{u7Jo.23N\£ŸßÕÕÓÖÕ×ÖȈZdX©ÎÔÑÒÔÕÕÖØØÚÚÛÚÚÚÚÚK*@KF3&!->AA@BAMLF5+!&7<;<7-,(&'$"  *OPOHXi9/P;>IdA 0442"! !!OiYYm‚‡iA3773=-033E °ƒT˜¬> Opri:T;FH>}¢h;B0,.6<PvvPxo;Eqv‡;Ku;C>nc>\ƒƒ²¼ÏÓÒÓÕÕÖ§g_ch¯ÖÛ×ØØÙØÙÙÙÙÙÚÚÛÛÛÚF(CIMPOB/"%.7:?OINOPC."+4944.((#"  +OJNI\k53N:@Nj;#03/3&'%$"Yq\S]hvb^=B:2;-133M¢³¡‚šÇ±y5($d§vŽyd]>C:r¦h=D-,+4:HlmMo}F?rs?JxVaB…y@˜­­¯ÔÖÕÖÔ·uNV_wÀ×ÑÓÕÖØØÙÙÙÙÚÚÚÚÛÛ%&CMNOPOM= +#7NMOOPMKI8-# #0::5/&    .SOLCbh27M7>Se8*2/3&)'&%^sa<#E]`_M:837+-1/S§ªTKœVpL!'(F‘j>…‰zi-"Il@D+-,36IpkFcf9ExrŠ=Nwc?‹ °F‰–·¨£ÂÝÓÔÖ´pOmg¦ÂÙÔÓ×ØØÚÚÚÙÚÚÚÛÚÛÚ1&")9GNMM9(EC6,/<KOPPOOMG?.#   ".7>6# !  =IMGff07E=B\g1*--*$$&$$bia8(;K]]W@56+*-,L›žO"n |D'-*2/W¤‘[Y‚fuCSžv@<$$(46FppAhQ,Cqn:Bw]|<„¦Æ»pA‰­ÆØÓÔÔºk^¡g¸ÒÑÐÓÖÖØØÚÙÚÛÚÛÛÚÚÛH<,.%")<E23JBCP?9-5>MSSSNMIE2* ))#!;WMDii$"AH=B_c-)+-+$$#$&bc[6;B$>LP=23(---FwpB06€T0$(..f¥•zL 4;/.!#&ki/$&++IosNn[0Bohˆ7Drb‰(“¼Ç³n?•ˆª¢´‡YJKZ\š_lm¤ÎÐÐÓÔÖÖ×ØØÙÙÛÛÛJT@?B<2%#"0F?CMLON@529HRQPMKDC8(  -BLKH! BE<A_c))*+&##%#'^^]7KN#!".540&+,,RzVSH'Uœ[7*/95v²®œC"",H„{j)--7y…Dja=Erm€8FnXCˆ€š°„¦aV—™®©€W]\`^—i}šn¸ÓÍÐÒÕÖÖØØÙÙÚÛÜ*/>MVOHC?5)!'3?LMNONM>)+8GMOKG=4,#  (<EH%L?@?fb&'))$ """'[ZQ1UO"'",0.**+*RutwK4C„L>14<7s² ‹h' %&L}p9-53pˆXij5Hng‰.;oX‚6~†K‚©½§P=¢§°“yWU\KeM~n¡{˜×ÐÑÒÖÕ××ÙØÚÚÚÛ"%+.3SZR@>@>STE >SNORQN2*-?FLF>50*'$   ;)J:<>hh#+)(#$$$&_^T,TK->&&,10))(+MefˆV>)j2831>8n±‹j¬d$!">i+<ˆK>HC=€”Zds9Bk_…+3kU‡(oˆ:S´ÃÁ‘Wj•§‹“X:B>WZ‡g©„‡ÛÓÏÕÕÖØÙÙÛÚÚÚÚ !#)+-5JbYL-JSQR; ?UNNMKA)!*4;:0)%#!  !8A2'#6C+%6BD=bR',&'%#$%$)]VO/ HB=R+$+,+''&(Mbc°@+8).*5:6p©Y]¬˜z.3jw†‹e)0CA3iµ~|‚:;lh89z_ˆ!lŠJA‰¹»À¥Cu™µ¦”:-EAQPF\ŒÕ×ÑÕÖÙØÙØÙÛÛÛÜ !$!(*.6Ae_OQUUSM-?FHJIH7))--)'$"   "(NRPJ+GXRRN:9<dY$),-&"$#"(`YR.$IEBV- '))'('+S_e«ŠC3@/1*6<4u«t‰š½Œ28@|Šs§ne7-*U¦rŒC&zf’=E{_x7q”L@twŒŒw˜Gˆš«§~PgbStd›™ÙÙÔ×ÖØ×ÙØÚÚÛÛÜ    "!!!!)+14Dg_PJNQSQ,(EBCEB=2##!"$"#!"'U]VL.$+HTMB>aP',$'%%!#!)XPN,!WDNQ0-/0($())Rg[‹ iC=.2/<?7pªf˜a+*"20W—TŒ~hR4:\°£›ŒIpkˆ:<o[f<m‘I,gzH£œÃŠH• ¤†{]_Luo”h¢¹ÔÔÓØÕØÙÚÛÛÜÜÝ    !!"!&+.6OheNNSSRA*,><>><5&!  (<RO1!!"AGEA' %(')#$##!-ZTN)YHNT)&0.)&&&$YrNFeulE)32:<1j«_M’]/'.5`¢t:$!!$qrg5/mjˆC/tTe@n“RInv8y©ÌÀ”_ª¤³ HVSzjŒfpÅÓÖÓÖ×Ø×ÙÙÛÚÛÜ ! ! ""'/36TcaMMMMM:(-942/(#"#"#-S</B7. .=46/-''""!"!0]UF^HWJ*+--$"&%$XoQ$*Pr€761/0-b—O(Œ…E*1;EŽQ  *…slPXDEk`e7l“VTjo<Ox«ÄÁpi™¶ºeZP†n”sl­ÎÜÑÓÔÖÖØÙÛÜÛÜ #!%106WkaGDDCA2#$$"""!!(JSZD2UME6$ #/2490 !!  +WOG$$WEXF%&*,&$#"!^_D?L(;8.-/0.a}N?VJ5+;?ogr#%#Al@|fm\©•H*o`b8f“YLlqC<]V‡†¢\_§Ÿ^KJoocmnh«Ô×ÔÕÕÖÖÖØØÙÙ !"! "%135^kbC4?5,#! !!$:NQQSQKLJK2( .;69)%:L=%+NEdE$(*+&##" RejslvX</+--)]‚Y8=c'81B<vŠ´S"$#bŒnF8d|ªœM:tdf>i•RIar85V^[¡Ëª]ƒ¨RJJukM[ajqUicZmtˆ‚ÁÓØ  " $$(27;Xo_3#-&&#!!!3L1*=/9CQONKEB8% #*&! =J>&"NF_K,#)*)!!!#D\7#%#%5/).0)WmuF".&64@;w•œ·g'('h­„kV-|p{„6*a\\?`‘U@do@Jh`9=—º¢L^œXEXe_it–x˜…šª„¯£“ËÏÛ  !!"$$.36Xrc2#""!4HKKMWL*(0FOKKFB9' 'BB?ABYL%()& ! !(c6=IR)(50)(*(WpwB%6-,%.-¦”o! $*'\£À¸ƒy&S€fc$/rZAR‹a?`xGRif>W„’Œ¨JŒŽ@D^`bVs”‚°™œ†‡¬Ý #!!!#$28=Wrb1#4IJJFIKKM=!&5EFA?;,! 5KF^K)))&##"$(Ms3DD) +1&&)'RoŒz7>2/'1/z~ms+$-/0i®µ±ÉŸW6‹zk[’R=DŠi:PuNIbg;Uwl³º›VG(+4iZavp{]rziy…’­ÀÛ"!!!#%28;\v`>GAB4&8JLNNI3$,><8,"!(+";OA;Z?&()#"#$#>=7LYQ+"-+&'(&YdJp€Y52)4-k}NO,'(69/f­¯»¥Ö®w?'–s{œg7Jg?SvGJhc)E}L|§¡P024:R“ˆ¡ŠÄš–§ˆ¨§—µ¾Ý!!"""".<@ZvgBENF9!7PIHF>-)+*("!    4DA*(MDFR=&'*(#"""EO9?R\)$,)$$&%Sb7OS9/16.aZ-9.((681h±¹‚£´¶Ï“|7P“|`13s]BL{@:Nm?Lp:^¡zM2Be_§y¦v¼¬Œ®‰“‘Ž“Ñ""%&-<@[uf?FKG/":ACCA5#%$"  !=QI+!"AF<3%-(&#!!%LQ<EWZ.%+(!"#!XbP,&/./2.ha*=*&%32*eª¦¶€…¬¬Æ¬‡hGˆik4t}CJwKGam1Dk:Dl\ˆ9B<j[gEvˆgf_qgr|s€“¢Ö!!""#3@Iax`FDG?/':?=9.$!  +I;)&9881$##%NK;AM_+$%'!"$#VcSH$)),.)[f442&)54.bŒu–L-a¼¾¾]3Š‡\‰¨eD‡G@Pm7Dw>2lJn=KOlUhg{ x³¦†°”¼¯ÂÔ "!!%'5HJezg9=B="%/-)$!  CY>(KD6" /:3&  #J6BHZ%&###%#XYPT%%'((-^`*3#)+)V|nLGim³Å¿Ã p2^…{±gV|5=U_5@|?IrBV>J^PvqY0–©š¹””«‰œ–Ì "$%).BHpc9:80 =]URSLFE7*!?2>Q\$'*%#!"$SZLZ&#*(((*`dI0#"$/-+NvlA'C+d‡z¨ºÁ¹uG9ŽttNz=<J^E?~?G}>iTJF‰padVpeezghzgvÄ #"#%'9FHcy`-"!  "=-//,IGKIE=)!(<X"&&$!!!KUM\%$*(&,*UR<C*&-*(RyhLG5IkžnŒ´Ç”\/~uipSDIkCL€RGnHiiEJ|ueci•v»„¶¤ž¡ÏÍ $&(+7=P_mW= ""'JMFI>+4@GHA4* #9Y#"%#  !!NVW^" (&$*)Oa((&$-,'N}nX=:P‚‡>;w­±¼•m:rjG;=eBCvC9kGhaEFu`vˆ`‡z£À¶®ˆ¿ž ÄÃ"#'(*+8@N_m_7"%KOLIPNC5-/96-( "?43==E%!$$!"!#OWQ\ %""$&HW)$"!+*&HzjQ4+)†¦|9^`’µ°»«f@ev>25h>9\I@nMrc>>h\|ƒUtlzerf\qcl„s¦#&*,-1BPch]TPJ:24BIMB7,((#"  %SB0$3E@-$#"!#HQP['%$#&$KZ9&""((&D|m^'+!cžsYw;j€y°¯°•7/G47n9:\O6vX_oHFmy_dxŽt„—}“¡‚®¢”¸Ã!'++-2BQdrlWLF219IKH8$  4B8! .92%! !ALO[#!(%!"'SY8& &&%HxjZ($D„bpU(fxOFjqo *)12c<9dM8sW]i@@mub`‹›v™¬œª„±¤‘»¿ "'+,-3COhoqYA>1+592! !!"B61G?'"& $>LV$&$ "#G]="%#""?qh]3.5lVC2DŽEVosd=7S:.YX7t\Pl<>\|Zgm§xqpqtiookys~#&+-03?PltlR?5!" ! AGISOL?)#5:!$%% !$OQ8$#  Bl`T/(?rF4/HmGX0gR&//"ME/WW8u[Lg59a|dmn»¯nŒt…™{£ „¤¯+- !#+-.6BQjukG'!!)<173@GG<% 09''$! !%Q\8%CqaR0-%@nQ/)7rmV3J\0I27&)\W5lZJj49]hs¶Î¶š‹‘ʆ®ª‹¯¿"@5#;"+115=McwnQ'.WORNE//5,   !A>.>G:(#!!#JY= )!!"!>laO-(&@iP-#*ZO<"6wb+B"!*AO4nZJq@;[[ww€ž½y}}hvo{uo'7&  #*004AObwoMP@=;CKK>*#   "AJ!#2<3"#8J>'"!!Ao[M-( :gK/'6^R3([yZ!0X-D>?K)nTJnC=Q…]}t§wª£y{ˆv„–}—›+9""!  &*022@MdzueI839F;'  20D@&#! ?B%' "! @p_M'&"7eJ4+4]R*GxV0Y.25 %Y[@qC;Vy=dv¼¶˜¹–‰±´ƒŸ¯"#" $)$#'/35CQkx{bF'*!  "HSURG4 *)#     :p^P)&!9cB5-3aV'#KrW.P !3I%6Zc}Jx<=JrDZd³É—…{wŠp~„t|q !!"(.-(!#-34CKZivS/!!":962?:$10.<0   !6i]O)'2fL5,,UZ%%Hv\)T,#5W-IO9^tCEDwD]X¤Æ§zsovy‰{ƒ%&,-$ %,//0;[uwT4$KRUL0-&#  $CD!(+)B]O(&4`J0%(RX+%EqY(P+%2L"$>/ NNSCAHu?VWx¬—¬ˆ´…“±Œ·"     "  " ',3=ZsrmS4<DH6 )76(%::13 ;fJ.%*ZQ&#BwY*H*#0N"%TF4j>#55f@UT|cŒ‰‹Œ‰¦°x…%4-"! (9"$(++9JbprE4*!!7ZME' "KV.(ZP*+(VW)!4sf/1A(+H&(H>%G."-0-RFZJŽ}Š‹‹†¡Êp~'6$!%""*!"%+-7JiG1  7;/+*#)E#8#1<TM')'V^% -TM.,G-*I%&=6/G3.<#7H?…ˆ†Ž‹“ž±±~¼!'!"!  "$$$"'31$ !%IKDE!$:1XD:!0EC:"LV' -GW#@,!(F'$G>7G4(>'.'8>vž¢—…‡²¥„¥"!"!#   &'*&0L'"!!=O>4+$  (I.EHH;G6$/AJKS&".WS$ @+'O!!BE2>3.G *FH$-H~¤«}‘‰{¤É„di !"%'9H'' "?H*)3a;#!!$;PJH(#":38");O%+LL&)&\Q%!A*%E%>B,?10B (HWP"+P…¬Š–”ƒ£Ñ |¼    !      (9.$!#"##c5)($+#@UN*#""&@LH@/" ,F5$ 'R\PI)HB ZP%!>$%?+!49);-+O *U@;Q@h¦µŠ—h{‰Â¥z»! !   !!!"!!     #42#!"#"##'?A@;-,$!$9>9.!*BF-!! GB>JH!.SQ 8,$=, :?%95)W$+Q?)C]™ˆ™‹•Äjt”lj%$"" ! ##%##"""!!""!"  !).-  !""/79:7./'! "4=@0! /\;.)"(,A:# <iSC&%C,C'$?+8A(<6%G )@41DŽŠŒ‰—Àš¤„Œm“2.+),---*($#""!"!! ! !! !!     """!!"%+'AaX96' %9?>' 1JI3&!IKJ.'!$&764;,  E."(@,"8>.:@LL%K9('@Œ„‰“’¬¸€¢620/03579;::64-('%#$#"#"!""!    ! $-=4#10"!$ #8875'  *A902$*J=-6%"'+<!83?2704>.1&=!&AA-.^‡‹‰‰Œ’¡iy855456789:;::951/2232-+(()#$""!"!!          ! !" !%*,#,.'@><9+ ';9."CCD.'5?L6$!.6#63!+*$26))%9%DD45b†…„„…ˆ–¬È¸f34675568889:88422245654459==8/("#!!  !!"+4A?4$ "!   "#""  (*!68;<."%A42"6@82%B=9+ ''!($# 3>-./#%9K:@_†~ˆ‚Š‰‹Ðˆ7876655788<>:865368:9899>??><6/))+16795''$'-;BGID8)!    %(("!    "!  56!8669-! )37055$(:13!9&7,7 3(D,-4%;#%@B2Ab}‚‚‘‚‰‡ˆ˜È¸‚999776899;;;978666789::::=<=;963226==?>:7/1<BHFBFA<' !!!!   #*19>;-!  !" ! %*"9:8=4!0-# <5#071#8B>"4H"'"#.,";2?."7M4;Pov‚™‡‡„‹Á·j799666899=>>;<;::9:;;;961..1344434678993007GLKF@CBA2!"! !!!!""!!!"      "*>ENUSC   7C)"(764<3!//).)'!(1&!/: )$ ">+$$6R28S~nsœ~€‡³·-./3679678:<====9799<873.%$#!"$,222*$!!"".4=IRQVYVN1)%$""!!!!""#%$"!   ""#"#"""!""!"&6Odsxm@$%# #26052":9&9B,@%#:=!&355#-"$!&695BaP}…Šz†…¨¿ˆ1237788668799:=?==;:865/---,(%$'/4::7*'!#34=MNW][WNA-&$##!!"####$"#! """""""##$$&'(%'((%#$+0;ZnyP. $$$#! !!287<6 !&//  '.;@")-6;&:%*,)F?1,;…z„†®¾u12357876567889;;;::97610/-013/++-06:;6/$#5@>?=GTWWP<1&###""##$###! !!""""#""""#%()*'&#"!  !*=D5#!#  22.:6+0)*+"6%%&$-%,@,3)"KF&(Pl=4_q†‡¨¾n43366763314446<97777872/-.010,%#%'09:6/(&4@KJ:0;LXL<,!#""""$#"!!!   !!!"!"!"#####""#$$%#"!    ''""405@( 35$!!'-8#+$%$.*2"9&FKHL(!#_‡p}”¸s21356742101245:86435577877641-(#"!#'.0/)'1?KOH?/5CJB-"##$$$$####""!  !"""#"$#! !!!!!"##"!!!'' $ 35+:4,2; *6 #"*!"-!%90#ACCQ6]Œš‹¹s)02354410./0256410/047:=<;85436899:972-)(1?LTKA./798.$#""&*12)""!#%&&&$#!###""! !!##"!"!  #GB&  550)#,.,$"#5"&#(&#*' $#>8FM7%=Y†šª—t  !""!   ##%$$#$%)05;<:841/167998984,&"-<HOJ@'(.12'   !#'(+2>ACC>3(%! ")0.&#!!!!!"""!"  !' !" .1/,! '/*%'")3$#" # (!'''2%&/C$<ƒ{L‰‘¢  !   ! !!!! ! !!#&,-,*&&'(-/24564,'##'5ELG='%*)*%! !#&*+/14::::;=<6//..,*##%'&$###(%  "#  ).+%$+<80,$%)$)!!#"&#"%,&%'- 6yg?"]|›#%##""!   !!!!  !!!         #,7>=/###$&%&)-11000224221034864.++2355::874...,*++%!"&((&(ETI1"(@C5% )&.!%!&$ +&%(94&22,, D   !!"##%$&%%$"#####%%##!   "%&&#"!!"  !##'*,/.011000002,+*+-553/.0122//2623314/,(   &(&'*<K1!"/;8&9P<!&("%! +#%(L!;XA09&* !!   !!   !""!  !#$#$$&&$#""""#$$%$!        #'&%# !!##**.0221013342345642.0-*$# &0/*# ,*%#  **-4+$$&' 4H,& )"&  !% #28km~zsT   !  !#$$$#"$$$#"$$$%$$#%&$#  !!!   #()'%$%&--/20&!$$#(/)!! $ +H:73/,KKQRQOOTZ0!+"(!&#"# *("$S!0RP^b}|~   !!!!!""! !!!"$#%%&)**'&"$&'')(*)'%""$""-/68;:%! !)"*`TG-+1;*3$2!%2;+!!# &#$& -5,-44!&192K^m        ! "!!! !"#$#%%$#"$&+,,++-9:-#$-($&" ! !& #*3YxC.#JRq(,./H<"$( #  K`P5-nlaG31E-6/'   !!!       !            !+7/! "#"%$+-ar>3)E+.'1E@5:Kn[*"  ! T}ŒZCQ[j:&8T?m !!  !"! !    !   !!            !! !!!"!!!! !!!!!    !  !     !  !!" !)AV[S)"!#@I/$">##/<94+++G7%!!!KgLRBcM!)4)1=K*.  !!!              !   !""!!" !""#""  !!     "!!  !!     !!'93  !#*9>1'NWI;IM!9f[]]X,!.02J'-&:>,;<B>K(. !    !       ! !!"!!! "!!"""#"""""!  !!!!!         <=*#-%")'&$! 9]F7#(khN<3"('"#, %#'(-.bHV(!.    "!       "!!!!!!!""#"$#$####    """   !!!!" .8)!"%%%%$$ !46MSXHZ+#.+  N((5!2F"&IG245P187H_  !   !!       !   !   !!""!!"#""##$""##!! !!$!!!!""!! "!  *( #%$"! 03K&(3:/413+1+($"5+.;/'/0>3LMTSYjZZRdg5)0;4Syl\             !! !! !"#$%%$#"!!"!#""!!""##""!!!!!!!!    $!$6N&4<CIOM?BYQVROOX`]\ecgj_glmihijkhcf\b`^[TSUWWZ        !    !!"!!  !!!! "!#""##$##!""#""!!!!!! !!!!!!!  &->FEGIJBAB?>==;8573(%#"% )/7 +D<BHLSZeecdbcbc[YXWUSUVVWVMLGEFDEGMQNQUUZ[ZXZ   !    !!!! !!""!"###"#$$#"##"$#%%&''*+-/0133555/%&A?>B?>=>PWVX\ZZYYXTTRNM?80#$&-CSRXnqlhda]YKGNIGDBBB=<??CJHPGOJHJKQKLMNOPR_eb```    !!!!!    ! ###$&')+-/3567789:9;=@ACGHHGHGGFEECCBB@?><<;:61#"':D.!+2/.-,,1T_[[\\[[ZZVPIFCAGKKIIHG>=?>@CBEF@<<<;:9DJ@HJGNKIIBDCCCDDFFIKPSUVWW]f^^]  (5:;;<==?BBDHKMLNONOORRQQQQQPNNKJHHGFEB@??@?;:98743222332212220/*# (>hP)#(# !&=FA?=7:?=::>?DBDC??;<CEBCIGADETHGIB@IG@A@@A@@A@?>>??BDGIJKMLMNd]ONOONLK !!   !'1LQRRSSRQQQSRTSTTTRQNLHFEB?>9753324667668776533232333344310--*'"!  $5<)# #% $AWYXW>83435467778988774445[bEDH<<==@=<;::;<;;;;=>@ADCGHHEFILMNKGEGFFEEF!!!    ! ! ! "$08@>=<5326677875667335576998756566653456540/+*))$#$"""!"" !!"#"" !!'/3)$! %5;44232389<=?:;=?BQU@::77788:;=?==;999898:;<=>@@@ACEEFFe_?EDBBEEGGHILMO! ! #$,/1,*'"   !!!%.43667788878678:8898989763-**+*+))&%$##"""  !! !!!!!!!#$$"!!!! *53.% !-44224322233873/.0334667685454766586868789;?><888<ADBAA@@???>>?@BDCC@BG !##$######"!  !!!$-27887662,-*'%#$%&""!""""""! #$###""""!" ! !!!!  !""!"!!!! !"!!*.1//022333545553545557666776:;;;<788778:;>>?X[8>>?<><;:9::>ACBA?>@ACEL!" !###$##$$"!!       !"  "!!   ! "# !!!!!" ! !"! !! !!!" !          !!  !!)),,1013/32434204334332456889878::<<<?<>??==;<<=?=><=9<:=>@??=:<==;@@AAA  "()8=;;8'$"  !!!  !!! !   """!!!! !!!"!             !    !!  #%! $+,---4.-,-.---...-./003356878677886413;999;;:=<>>><<;::;:<;6459:::8;;;9;Q^J  "#'))()*(&$""    ! !  !!    "!      ! !        ! !$')+,+++,,--.--,,,,,+/023334454424<8997Mx‹vM1:;;=;>;>==<::9::;;;;:99:9:=>B=>IMCB@>   %),031010)%"      ! !!!" !"!"#  !!!! !   ! !!"!       !  %')))***+*++,-,./1100///.101022467779::7435798999898:9989;=@@?=;::96<669<BDBAAC@?F#(*,,,+)&&%%"! !"$$$$%%%''()**+,,,.,,-,-02788444567776544457674455679::;9:426753-)IV99788987=VK5gfcYROOPQSWY^begihjnqqojb_a`bcfkmmmmllkjjc\ZZ]^^]bkv}~}}€€€‚‚ƒ‚‚ƒƒ‚‚‚ƒƒ€c_XNE>;>DJR[ab^\\`cfggc_ZY\\`cfiieb`_abdfe]TRSWXX\dpx{}}€‚|{z{€€‚‚€€€€€€‚‚b_YOE=;<?DOYejjeaaehhgd_[YY[^aejieb]\^`a]WVTSTUVWZ\bju~€€~|yxy|€€€‚‚€€€€€‚‚lgaWOHCA@AEN[cig`[\afgb[UTUX[afihc`^_ceedca_ZWY[[YX\dpyzxwuuz{}~€€€€~~€nkf\VQONIEEEMXejie_^cge`YUVX^adgfc^ZXY\`cdefd]YWXYYY`kuxupnotvz{}~~€€€||~€€€€hgd]YVUTRPMIILUbnppmmpqlc]YZ^aehhc^\[Z^abcc^WNILQUTTW]gnsuqkcaemw|~~~~~~~~~€€€€€€~~hfe_YXWWTSQRTW[`hqz}~}{vme`behjigebbbcbdeggaZPKIPSVW[akrxxrh^UPS^iu{~€€€€€€khd^[YXXWWX[^]Z[_gu|~}{ypg]Y[^cgfeca][\_beeb\VPLMQSVUUW[bhhd_YXVV^kv~}}}€€€€jhe^ZYXWVY^`cca`afqy~}zxvsleb`adca`][]`fjhd`^^^]ZUSRSTUZ^aef_XWX[alt{|}}~€€~}}}~~€€€khc]ZZYY\cmsurmkijotxzzxwxyslecefd`]]]`aefda__aca_[[[ZYTV[`dc`a^[[coy{}}}~~~~~€€€mjd]YY[\]]dktxupllquyzxtnmlheccefc`\YX]eigd`]\^bdfd`\[XXZ]`cfea\Z`kt|}~~~€€€~~~nid^[[ZYYZ^ensuvustvz{wsmlmjfaadec_]]`dfhigb^]`ca]YSPORUW]`begfdddekv{}}}}}~~~~~~~~lhc\ZZZ[[]`aflswwtsswyuplnstrlhhhfb\[_bfgeb]Z\affaYRMJLQX]\\`b_\[Z[_ks{}}}}~~~}}}~mid_\\\[\^_`chottsrsvvqjcbhoutqmlkjdabbbcb_\[^``b_YTQQORZ^dijfdcdffglsy|}}|}~}~~~~~€€oke^[[]_`dggilswtpoqtvqh^Z\biptutuutoheefd`\YZ]__^]]^^[XZblrngbbhiijmu|~~~~~€~~~~ngc__^^`gnqqnlmrvwvwxwrkfddgkpu{~~}{upjeca[XY^deb`_bc`__chida^bghe`blu{}}}~~~~€€okf`]^_chnwzvqnpstuvwwrkcaacfhmty|}}{xtnkgc^[[^dfdca`abcddeeda````]Y]cnw{~~~~~~~}}~€€nid```abhmsvvutrooquxvqib`acghjpv{~|{vqlhc`\ZZ]cdbabdddaeiklib]]afebbfnvz}}}}}}}~~~~jgea```bhmsuuw{{wuuwywqjfhmnpmmquxwtpjfdcdb_^_afea_`cddceimplgccefcabepw{}~~~~€~}}}~lfcbbaaaglrstvvxxwwxywpidgnqqpquyyuppomhebbbcehie`_acddcejmoonmmmjhghnty|~~~~~€€€uqnhbaaekpvxsrssttvwywpgbcjptrqruwtonnpnigggfcbefcaaceeegilnpmjfb_^blrx{}€€€€€‚€‚zwtolihhjmqsuutstvyzzyskc_chnssstsnf`]aiouwtogbcccdfhiifegjnqqnhb]]bjsx{||||}~€€~~qw{{zwsqqqtutuuvvwz|{ysmfdiouxwutrogb_ahpw{ytkdbcdefhiihijjlnppmkkjmov|~~~~€€€~~~~€gjpv{}zwtsrsststvx{|{ytqonnpsuwxvtpid_\^dntrnkgca`aehigghkkgaabcgfeefltz}~€€~~}~€jjjkntx{|{xsrrtwxxzzyuqoosurpoosttqjb[WYaimmh`]^_^\]`adcfknjeb`befddfipuz}~~~~~jjjiiijlprspprsvxz}{yurooquutssuvtqlhb_ehnong^ZY[^adcaaceikjhffehljgeejnu{~~~~~~nmlmlkjkmpolkoswz|~~|vokjkquyz{zxvspplhdgjid_aeilmmlieacfikmkijhedffb^`hs|~}||~~~~~~~}}tsqppqsvyzyvroorwz~}zvpmlmoqrrsvxupifghknnkd^\amtyuoe^]bgjlnmkjhegikf_\clx{zwvvx|}}}~€€jmqssroopqvyywwwwy{|zvqooqpqtuvwvtpjeefhjkjfb]^dkpmf_[_bfiloplgbabfihd^^ajqwupnpv|~ommmosspkhgkrwyzyyzzyuqpqtuuuvwxxvrlgfhlnnnkf\X[bhgb]Z]bgknpqnjgfdcb_^\WV]fqupoqu{}~~~~~wwvtsronlkjhhiouxz{|}|wusssrtwz|{yurpooprsplib_eijjighkmonoomiggjjf`YWUVTUYbikkkpvz~|yvvuurokjkllkkmrw|~~|ywtssuxz||yuqpsw|{vrppolkjgggjpvunhccffedhjgb^]XTQQU^chjgfnv~€}}~€€|xuqnihiijjnrvy|}{ywutsrrtwyzzxussstwxvurpmnooib\]biifbdeec`afffccc`\YTRSX^_^^goy|~~€~zwqmihiklqvz}}{xtuvwustvy}|yupooptwwunhbbhkmhcbfmniffjnnnmhgecdghge]XUX]`aaemx}~~€‚ƒ€}{vqnnqtvx||zxussvzz{z{|{wrponotwyxtpnmmnmighimoorw{|wnjghhjkjhd_\ZXYZ_ehiouz}||‚€€€€~{ywutwz~zupkjjnrwz|||zxtssuwxzyuttuxvplklljhfinrsohb^__`cecb^[XWX]aba`bceims€€€~||{zyz|{xtnjijjlqwz~}|{xwuvyy|}yxwwwwvsqpolijlqroibabb`_cdcb`^^^\_acfgghhijn€€€€€~~€€€€~~||{yupkjjklnruy|}~|ywwz||{yussvxxvrnlllkklnniaXSRUWY^ceggikjiffhigefhjik€‚‚€€€ƒ€€~~|yvrpmllmntz~|xvvvxyzzyursuyzwsrstrpmmpqle[WWWUUWZ^aaccbaadd`]_bghgk€€€‚~€€€€€€€}zwtrpoorw|}{wttuxyyyxvtrrwywtstwwurrttqoljdZSRTY]_bfdccbb`^^_cegjn~€€€€€€€€€€€€~~~€€}zvsssuz{ytokkmsw|}|zyyzzxtppsvutuwvtsqpkeYVUVY[[\]`befb^_ceggim€€€€€€‚€€€€€€€€€€€}{yxxwvqljkouy||zzyy{{zxvxyzyvvyyurnjgd`\[Zadfhggfdb`abbdgijm€€€€€€€€~~~€€€€€€€€€}{wroljikosxyxvvwyzywvwyyyxxxywrnnmjd_^bhnonjfeb`]Z_dfgggi€€€€‚‚~~~~~~~|zwtqnorvyxurpqvy{yyyz{zxxzzwsnlnrtsrqssrqoigfeddhhjjhjl~€€€€€€€€€€€€€€€~~~€~{xussrttqoorxz{zxxxzzz{{zxtqoptutrpoqtwuoicabfhggfgkn€€€‚ƒ€€€‚€€€€€€€€€€€}}}}|zwspnmnruwvvvx|}||}|zvrrsttrrsstwzwqnjfefhgiiknp~€€€€€€€€€€€€€€~}}|{ywtsrstsrqrtxz{|||zussuttrponortuuroomkkjghijm‚‚€€€€€€€€€€€€€€€€~}|||}~|zytonnorwyzz{}|yvttuwwvvttttrrtwywsljikmll€€‚~~~€€€€€€€‚€€€~~}}}}}}{{{ywtstxzyyy{|zwwwwwwvvuttxywvvxwupjhhfgj€€€€€€€€‚‚~~‚‚€€€€€€~}{zzz|{yvvx|~|wtrutssssvyzzxxxywskecdgjm€€€€€€€€€€€€‚‚€€€€}{{}€}zxxz{yvvwz}zyxwvtsrqsuvy{zyyxtqnjgdcdjz}€€€€€‚‚‚‚‚‚€€€€€€€~~€€}{{{~zwwxyzywwz}|yyyxwtrrsvy{zywuuutrmfb`agqsttttuwz}~ƒƒ€€€‚‚€€€€‚‚‚€€€€€}||}~}|yyz{}|yxwwwwx{}}~~~~zz{zuqmgcbberqpqppopqrsssttwz}~}~}zzz{€‚‚ƒƒ„‚‚€€€€€€€~~~}|zz|~€~zyxxvuvxz{}€~|{zywsmgda`bdmoppponnooponnorttttuvvsstz~€‚ƒ€}|{{{}~€€€€€}~~||}~~~~}|{{zzz{}}~}zxtqlgc`adestrpoommmnoqtwyxvuvxzyvsrsx}€‚€€}|zywvuvxz|~~€€€~|zz|~|||||||{{{{{||||~}ytlfd`beuutsrqonmnqsuvxyxwwxz{zwvwz|}}€‚€€~}|zywvwz~}{zz{|~}||}~~~~}~€}}}}}zzyxslfeuutssutsrqrrtttwyyyyzzzzz{}~€€€€€€€€€€~~~~}yy{~~}}}~~~~~}}~€~{wvtqidc~}~}}||{{zxurrrsrrtvyzyz{~€€~}}|}}~~}}}€€€€€~~~}{{{|~~}~~€€€€}}~~}|zxsmicƒƒ‚‚€€€€€€€€€€€~~~}}||||}~|||||}}~~€€€€€~|{|}}{zz{|{{|~€}}}}}{yzzywus€€‚€€€€€€€€€‚‚€€€€€€€~}|}}}||||~~}}}}~~~~}{zzzzyyz}~€€€€€}|zzwrnk€€€‚€€€‚‚ƒ‚‚‚€€€€€€€€€€€~}||}~€€~~}{yxzzzz|~~~€€|ywvwsqo€€€‚€€€€€€€€€€€€€€€€€~€€~€€€}}}~~}~}||}~~}}}}~€}}}}zvolmossn‚€€ƒƒƒ‚€€€€€€‚‚€€€€€€€€€€€€€€€€€~}|||}€€€€}}}{{yyyz{|~~~~~|{zyyzzyy‚€€€€€€~~~‚‚‚€€€€€€€€€~|||}€€€€‚‚}{yy{||}€€~}}}||{zzzwt€€€€€€€‚‚‚‚ƒƒ€€‚‚‚€€~€~}}~€‚€~}|{yvsrpoopqonllklmmnooop‚‚€€€‚‚€€€€~~~~~}}}}}{zyxxy{}}~~~|yvusqppqqrvwwurqpoommnnnnnonoppoponmllƒ‚‚ƒ‚‚€~}{{zzywwvvuuutuusrrrrqrrsttuuvxxxzz{~€}{xsqqrrsrrssssrrrsttutrrstssrqpppooo‚‚‚‚€€{wusrqqqqpprsstuuwwwzz{{{|||~€€~~~€‚‚||zxxxyzxvvxxxxxwvuuwyxxvuutrstssssr€€~}||||}}}}}~€€€€‚€€€€€€€€€~~~|||{{z{{{zzyyxxxwwwvvvvvxxwwwuut}}}}€€€‚‚‚‚€€€€€€€‚‚~~}}||}~}}||||{{{||{||{xxxxyxxxyyxyzzywvu€~|{{|}€€‚‚‚€€€€€~xu}ƒ‚}~€€€€~~~~}}}}~~€~~||}|{}}{zz{yxyyy{|{yxwvwxœœž›™˜˜šœž˜”‘Ž‘”–—————––——•••––”’‘’”–••—™™™–’Œ†…‚€~~€‚„ˆŠŠ‡ƒ€€€€‚€€€€€€€¡¤£¢¡ Ÿ ¡¢ ›”’“•—šžŸŸŸŸŸžžŸ  ››Ÿž›˜—™œ›ššœž ˜“Š†ƒ~~€„‰ŒŒˆ‚€€}}}~~ £¦¨§¤ žžžž›—””•–˜œžŸ  ŸŸœš›œžš•””—š™˜˜™œžœš—”ˆ€€†ŠŠ‡ƒ€€€€€€€€€€™œ¡¥©©¥£¡ Ÿœ™—–•˜™œœœœœœžž›™™™šœœš–•–™›™–““”˜š˜•‘Œ‡‚€‚„„‚€€‚‚€€€€€€—š¡£¦§§¦¥£ œ™–•””••””–˜šŸž™——›žœ˜”’“˜šš˜’‘’”—–”‘‰ˆˆ‰‹‹Šˆ…‚€€€€€€€~~™š ££¢¢££¢¡Ÿœ˜“ŽŒŒŠŠ‹”™™–“”™œ ž˜•““–šœš–”“•˜š™–”’‰‡††ˆŒŽŠ…€€~~~~~€€€~~~~šœœŸ¡¤¤£¡ŸŸžœš˜“ˆ„‚‚‚…‹”••”–›œ™—““”–——™š›œœ™˜•”“Œ‹Œ‘’Œ‡ƒ€~~~~š›žŸ¢¤££££££¢¡¡¡œ–Žˆ„„…†‹“–›œ›ššššœœœ›œœœœ›—•”“”••–˜˜™—“Žˆƒ€€€€~~~~™šŸ¢¢¢¡ Ÿœœœ›™“†ƒƒ„‡Š”™œŸ›››››šš›œœ›››œœš—–––———˜—–’Žˆƒ€€€~~€€šœžž ¢¡ ™“ŽŽ’•—˜–’‹‡‡Š‹‹Œ‘˜œœœ››žžž›™˜—˜™›œš•”•˜™˜–””””––•”“‘‹†€~~~~~€€~~~˜šœŸ ŸŸ›—“’•—•‹Š“——–•–˜›žœžŸŸŸ›š˜—––—–“’“•—˜—––—–––••“‹†‚€€€€€€€€€€~š›Ÿ ¡ŸŸš—’‹ŠŒ‘””ŠŠŽ’”’‘’“—š››œ›œš™š›››˜––˜šš˜•”–˜˜—”””•—˜˜˜–“ŽŠ„€€~~€~~~~~~ššŸ Ÿžœš–’‹Ž“––’‘••“ŒŽ‘”—™œžœššš›œ›˜–––—––—šš™™˜–”““••–•“ŽŠ…€€€—šŸ  Ÿž›˜–‘Ž’“’”š™“ŽŒŒ’“”–—™›œž›š™šœœœš™˜™˜™˜•’‘’•——•“‹†€~~~€~~˜›Ÿ ¡ ž˜–•‘Ž‹ˆ‰’”’”™ ¡˜‘ŒŠŠŠŠ‹Œ‘”—š›š™˜™œ›ššš™˜–“Œ“—šš˜”‘ˆ‚€€€€€€™Ÿ ŸŸžœ–“’’“’‘’˜›ž™”†ƒ‡‰Ž–š››š›œœ›šš›™—–––”“”—™››˜“‹‡ƒ€€€€€€€˜œž   žœ–ŠŠŽ“”””“’ŽŽ“˜œžžžš”Œ†ƒ‚‚„‰Ž”˜›œš˜––—™™™˜™™——˜™˜–••–—™˜–“Š„€€€—œžŸŸŸžœ—’’“’‘‘’–™šš™šš˜’ŒˆˆŠ“—›ž›š™™™™™˜˜™™˜˜™™–’“•™œœ˜”‘Ž‰„‚~~~€€˜›žŸŸŸ›–’ŽŽŒŠŠŽŽ‘””‘”—–”ŒŒ’”–˜›ŸŸœšš››š™™™™š™˜—“‘’“–——–“ŽŠ†ƒ‚€~~•™›œ›™”‹Š‹Šˆ‡‡ŠŒŒ’–”‰‰’“‹‹Œ“‘•——–––™›œœ›œœ›š˜–‘‘’’“•–—–’ŽŠ„ƒ€€€€€€€’–™š›š—’ŽŒŠŠŠŒŽŽ’•–”““Ž––“ŽŽ‘‘”—šš˜˜™™™™™™˜—–—˜šš™˜”‘‹…€€€€€€€€€‰‰Œ”––•‘‹‹ŒŽŽŽ’—˜”Œ‹Œ‘‘”˜œœ˜‘‰‡‡‰”™›™˜˜™™›š—––•”•——–•“‘‹…€€€€~~“Šˆ‰Œ’‘‹‰ˆˆ‰‹Œ‹‹’—˜•’’‘‘‘•™œ™•Š††‰–™™™™šš™™˜—•••”’“•’Œ†€€€€~~~~~~œ™•Ž‰‡ˆŠ‹ˆ††‰‹ŒŒ‹‹‘”•””’‘‘ŽŽ’–˜š™•Ž”—™——˜˜˜™˜˜˜—–”’‘“•—˜™–‰€€€€~~~}™œžš–‹ˆ‡ˆŒŒ‰ˆˆ‰‹ŠŠŠ‘“Œ“”‘ŽŽ‘“”•––”“““–™š™˜–•–—˜™˜—–•”“‘’•–—”‹…€€€€€€™™™™š›˜•Šˆˆ‰‹‹ŠŠ‘”’ŽŽŽŽ’”–——–••–˜™—•’’–˜™˜•”“’‘‘’”“”“’‘Ž‰…~~€€€€€€€–™›™––•”“’’‘ŽŠˆˆ‰‰ˆ‡ˆ‘“’Œ‹‹ŒŽŽ‘‘“–––––—–’Œˆ‡‹•˜—–”“‘’“‘’““‘ŽŠ„€€~€~~”•–——•’Ž‰‰ŠŒŽŒ‹Šˆˆˆˆ’“’‘ŽŽŒŽ’”••–˜™™”ˆ‰Ž“—™™–“’“‘’‘Ž‹†‚€~€™™˜—–––—•’ŽŠˆ‰ŒŒŠ‰‰‰‘““‹‹ŒŒŒ‹ŒŽ‘’‘‘‘“•–˜šš–‘Ž“•––•“‘•–•––—˜–“Œ‡„„…‡…ƒ~~~~~–•––•“’“—™™–‘‰‰‰Š‰ˆˆ‰‘ŽŒ‹‹‹‹ŒŒŽ’”––—•““•˜™™˜”‘–—•”“’‘”———––——–“Œ‡†‡ˆ‡„€Œ‘“”–—˜˜˜™™˜–’ŽŠˆ†……†ŠŽ‹ŠŠ‹‹‹Œ‘“““”””—™šš˜——•”ŒŒŽŽŒ‹‹“”–˜™˜—–•“Šˆ‰ŒŠ…‚€€€€…‡‹Ž‘““–˜š™˜˜˜˜•Š…ƒƒƒ…‰Œ‹‰‡‡ˆˆŠŒŒŽ‘“”–••–˜˜—’‰‹Ž’””“‘’“““”“””’‹‹Š‹Š‰†ƒ€€€€‚ƒ„†‰Ž’–˜šš˜˜˜–”‹‡†‡ŠŽŒ‹‰‰Š‹ŒŽ‘Œ‹‹Ž‘’“““–˜™˜–•””•“‘‘“““““•–•““•”“““’‹‡ƒ€ƒƒƒƒƒƒ…‰‘–˜™™—•‹ˆ‡ˆŒ‹‹‹‹‰‰‰‰Œ’“’ŒŽ’•–—˜–•”••–•”““‘ŽŽ‘’“’‘”•˜™™šš™˜•’Ž‹†…‚€‚‚‚ƒƒƒ„…‡Œ”••”‘ŽŠ‰Š“•’Ž‹Š‹ŒŠŠŠŠ’ŽŒŒ‹‹ŒŽ‘–˜˜–”•–––—–“‹‰‰‹“•—˜——––“““”••“‹‡‚€€€‚‚‚‚ƒ„ƒ‚‚‚ƒ…‡‹‘Œˆ‡Š•˜™™—’ŽŠˆ‰‰‰ŠŒŒŒŒŒ‹‹‹Ž‘“–˜™™™—•“’’“””““““”“’’’”™™–‘Œ‰‡ˆˆ†…„‚‚‚‚ƒƒƒ‚‚‚ƒƒ„†ˆ‰‰ˆˆ‹•—˜šš—”ŽŠ†…†‡ŠŒ‹ŠŠ‰‰‰‰ˆˆ‰‹‘“–—–••”’‘’•–˜™˜”‘’’““’‘’•—˜•”’ŽŠˆ‡†„‚‚‚‚‚‚‚‚‚‚ƒ„†ˆŠŽ“—ššš™˜—“Ž‡……†ˆŠŠŠ‰‰‰ŠŒŽ‹Š‹Ž’•—–••••””–—šœ™––––——˜—–•”’‹‰ˆˆ…€€€€‚‚‚ƒ‚‚‚„…‡‹‘”–˜—–’Ž‰ˆ‰ŒŒ‰ˆˆ‰‰ŠŠŒŽŽŒŠŠŒ’“’’’““‘‘’“–˜™˜——˜™™™˜—–”’’’‘ŽŒ‹‹ŒŠ†€€€€€‚‚ƒ‚‚‚‚ƒ†ˆ‹’•–’Ž‰‰ŠŽ‹‰ˆ‡ˆŠ‹‹‰ˆˆŠŽŽŽ’”‘‘’“•––™šœœ›š™—––•“‘ŒŠˆˆ‡€€‚‚‚€€€€€‚‚‚‚ƒ„…‡‰‹ŒŠˆˆ‰”˜—”‰…„…ˆ‰Š‰‰ŠŒŽŽŽŽ‘’“’’’‘”™™˜—–•••––—˜™˜•‰‡†€€€€‚‚‚€€€‚‚ƒƒƒ„…†‡ˆˆˆŠ”––”‘‰ˆˆŠ‹Šˆˆ‰ŒŽŒ‹‹‹‹‹‹Ž’“’’’”˜››œš™—––——˜–”’‹‰ˆ…€‚‚‚‚‚€€€€€‚‚‚‚ƒƒ…†ˆ‹‘•—•‘Š‰ŠŒ‹Š‰‰‰‹ŒŒŠŠ‹ŒŒŠŠŒŽ’Ž‘—˜–’‘“••““””“‰ˆˆˆ„€€‚‚‚‚‚‚‚‚‚ƒ‚ƒ„ƒƒ‚‚ƒƒ„„……………‡‹ŒŽ‹ŠŠ‘“‘‹†……†ˆŠ‹‹‹‹ŠŠ‹Ž‘‘’‘‘“–—–•““’‘ŽŒ‹Š†‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„……††‡ˆ‰Š‹Œ”•’Š‡‡‰ŒŠŠŠŠŠ‰‰‹Ž‘‘Œ‹Œ“–•’‘‹Š†€‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒ„„„„„„…‡‡‰‹Ž’“’‹‰‰‰‹‰‡†††‡‡‰‹Ž’’‘ŽŽŽŽŽ‘‹Š‰‡„€€‚‚ƒ‚‚ƒ‚‚‚ƒ‚‚‚‚ƒƒ„„„„„††††‡ˆŠŠ‰ŠŒŽŠ†††††‡‰ŒŒŽŽŒŠ‰‡‡ˆŠŒ‹‹‹ŒŠ†‚€€€‚€€€‚‚‚‚‚‚‚‚‚‚‚ƒ„„……†††‡‰‹Ž’“‘ŒŠŠ‰‡†……‰ŠŒŽŽŽŽŒ‹ˆˆˆ‰‹Œ‹‰‰‰ŠŠ€€‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒ„„……………„„……†ˆŠŠ‰‰Š‹‰ˆˆˆ‹ŽŽŽŽŒŒ‹ŠŠŠ‹‰ˆ‡‡‡€€€‚‚‚‚‚‚‚ƒƒƒ‚‚€€€€‚‚ƒ‚€€‚‚ƒ……††„„„„„„…††‡ˆŒˆˆ‰‹Œ‹ŒŒŒ‹ŒŒŒŒŒŠ‹‹‹‹Šˆˆ‡€€€‚‚‚‚‚‚‚€‚‚‚ƒƒƒƒƒ„„…‡‡‡†††††††††‰ŒŠˆˆ‰‹ŒŒŽŒ‹‹ŠŠ‰ˆˆŠ‹ŒŽŽŽŒˆˆ†…ƒƒ€€€€€€€‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒ„„…‡‡…„„„…†ˆˆ‡ˆ‰Š‹ˆ‡ˆ‹ŽŒŒŒŒŒŒŠŠŠŒŒ‹Š‰ŠŒŽŠ›———˜—•‘‰‡†„‚€€‚‚‚‚‚‚‚‚‚‚‚‚‚‚ƒƒƒƒƒƒƒ‚‚ƒ……………†ˆŠ‰‡……‡‹ŒŒŒŠŠŠŠŠŠ‰‰‰‰ŠŽ‹Š‡œœžžœš˜˜™™š™–’Œ‰‡†…„„‡‡„‚‚‚‚‚‚‚‚‚ƒƒ‚‚‚ƒƒƒƒƒ…†‰Š†„……‡‡ˆ‰‹ŒŠˆˆˆ‡‡‡ˆ‰Š‹ŒŽŸŸžž  žžŸž›š™™›˜“‘‘Œ†€€€€‚„„„……„„„ƒƒƒ‚‚‚ƒƒƒƒƒ„…ˆ‰†……†‡†††‡ˆŠ‰ˆˆ‡†…†††ˆ‹Ž‹Š‹ŒŒ››œŸ  ¡¡Ÿ˜“’“Œ‰ˆˆŠ‹ˆ…€€‚ƒ……†‡††…„ƒ‚‚‚‚ƒ…‡ˆ†„„„…„„„……‡‡ˆˆˆˆ†…†„„†ˆŠŒ‹ˆ——™šœžŸ  ž›–’’••Š„ƒƒ„„‚€€€€~~~€‚‚„…††…„„„…‡ˆ…„„„……†……††††…………ˆˆŠ‰ˆˆˆ‰Š‹ŒŠŠšš™˜˜˜™š››š™—•’‘‘ŽŠ…ƒƒ‚‚‚€€€€€€€€€€€€ƒƒƒ„„„„††…„„…††„„„„…†…„„„„…‡‡ˆˆ‹‹‰ˆ‡‰Š…†‡ˆˆ‰Š‹Œ“–™˜—™š›—‘Š…………„ƒ€€€‚‚€€€ƒ„„……‡ˆ†………††…„„„……††…………………†ˆŠˆ††ˆ‹‚‚ƒƒ„…††…ƒ‚‚‚€€€€€€‚‚‚‚ƒƒƒƒ‚‚ƒƒƒ„†††………‡ˆˆ‰‰ˆ‡††‡‡‡††…„„„†‰Š‡……†ˆ‚€€€€€€€€€€€€€€€€‚‚ƒƒƒ„ƒ„ƒƒƒƒ„„„„„…………ƒƒ„†ˆ‰‰ˆ‰‰‹‰‡†„„„„…………†ˆˆ‰‰Š‹‹‚‚‚‚‚‚‚€€€€€‚€€€€€€‚‚‚‚‚‚‚‚ƒ„„ƒƒƒƒ‚‚„‡ˆ‰‹Š‰ˆˆ†…………†„„………†ˆ‰‰ŠŠŠ‹€€€€€€€€€€€€€€€€€€€€‚„ƒƒƒƒƒ„ƒƒƒ„…‡ˆˆˆ‡†‡‡……„„„„……ˆ‹ŒŒ‹ŠŠŠ‚‚‚‚€€€€€€€€€€€‚‚‚‚‚ƒƒƒ‚‚‚‚‚‚‚‚‚„…‡‡‡…„„„……ƒƒ‚ƒƒ…ˆ‰ˆ‡††…‚‚‚‚‚‚€€€€€€€€€€€‚ƒ„ƒ‚‚‚‚‚‚‚„…‡ˆ‡…„„……ƒ‚‚‚‚ƒ„ƒƒƒƒ†ˆ‚‚ƒ‚‚‚‚€€€€€€€‚‚‚‚‚ƒ„„„ƒ‚‚ƒ………‡‡‡‡‡ˆ‡ˆˆ‰‰‰ŠŒ‹ŠŠŠŠŠ‚ƒƒƒƒ‚€€€€€€€€€€‚‚ƒƒƒƒƒ„…†‡†„ƒƒƒƒ…ˆˆŠŠˆˆˆˆˆˆ‰‰‡‡‡‡ˆˆ‰‹‹Š‹‰‰ˆˆˆ‰ŠŠ‰‰‰Š‰‰‰‰‚‚‚ƒƒƒ‚‚ƒƒ„……†‡ˆ‰Š‹‹‹‹ŽŽ‘‘’’’‘Šˆ†††‡ˆˆ‡‡ˆ‰‹‹Šˆ‡ˆˆˆˆˆˆˆ‰‰‰ˆˆ‡‡‡ˆˆˆ‰ˆˆˆ‰ŠŠŠŠŠ€‚ƒƒ‚‚ƒƒ‡‹”—™™™ššš™šš™˜—–”ŽŒŠ‰‡†……„ƒƒ‚ƒƒ„……ƒƒ‚‚…‡‡‡‡ˆ‡†††‡††‡‡‡‡‡‡‡„„‡ˆ‡†‡‰‰ˆ‰‹Š‰‰‰‚‚ƒƒ„…ƒƒ‚‚…ˆŒŽ‹‹‰‡‡†………„„ƒ‚‚‚€€€€€‚‚ƒƒƒƒƒƒƒƒ„„…†††………………†††……………††ˆ‰‰ˆ‡‡‡‡†††‡‡‡‚‚ƒ„ƒƒƒƒ‚€€€€€€€€€‚‚‚€‚‚‚‚‚‚ƒ„„„„„†…„„………††††††‡‡‡†…„„…‡††……††‡ˆ‡‚„„…„ƒ‚€€€€€€‚€€€€‚}urx~€‚€€€€‚ƒƒƒƒ„†…„„ƒƒƒ„„„……†††…„„„„„‡‡‡‡‡†…‡‡……†‡‡‡
\ No newline at end of file
diff --git a/engines/adapters/player/framemetadatautility/Android.mk b/engines/adapters/player/framemetadatautility/Android.mk
index 4de3471..197d3c6 100644
--- a/engines/adapters/player/framemetadatautility/Android.mk
+++ b/engines/adapters/player/framemetadatautility/Android.mk
@@ -3,37 +3,32 @@
 
 LOCAL_SRC_FILES := \
 	src/pv_frame_metadata_utility.cpp \
-	src/pv_frame_metadata_factory.cpp \
-	src/pv_frame_metadata_mio_video.cpp \
-	src/pv_frame_metadata_mio_audio.cpp \
-	src/../config/common/pv_frame_metadata_mio_video_config.cpp
-
+ 	src/pv_frame_metadata_factory.cpp \
+ 	src/pv_frame_metadata_mio_video.cpp \
+ 	src/pv_frame_metadata_mio_audio.cpp \
+ 	src/../config/common/pv_frame_metadata_mio_video_config.cpp
 
 
 LOCAL_MODULE := libpvframemetadatautility
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/include \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/src \
-	$(PV_TOP)/engines/common/include \
-	$(PV_TOP)/engines/player/include \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/config/linux \
-	$(PV_TOP)/nodes/common/include \
-	$(PV_TOP)/pvmi/pvmf/include \
-	$(PV_TOP)/baselibs/pv_mime_utils/src \
-	$(PV_TOP)/nodes/pvmediaoutputnode/include \
-	$(PV_TOP)/codecs_v2/utilities/colorconvert/include \
-	$(PV_TOP)/codecs_v2/utilities/colorconvert/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/engines/adapters/player/framemetadatautility/src \
+ 	$(PV_TOP)/engines/adapters/player/framemetadatautility/include \
+ 	$(PV_TOP)/engines/adapters/player/framemetadatautility/config/linux_nj \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pv_frame_metadata_factory.h \
-	include/pv_frame_metadata_interface.h
+ 	include/pv_frame_metadata_interface.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/engines/adapters/player/framemetadatautility/build/make/local.mk b/engines/adapters/player/framemetadatautility/build/make/local.mk
new file mode 100644
index 0000000..2072747
--- /dev/null
+++ b/engines/adapters/player/framemetadatautility/build/make/local.mk
@@ -0,0 +1,25 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvframemetadatautility
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+XINCDIRS += ../../config/$(BUILD_ARCH)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_frame_metadata_utility.cpp \
+        pv_frame_metadata_factory.cpp \
+        pv_frame_metadata_mio_video.cpp \
+        pv_frame_metadata_mio_audio.cpp \
+        ../config/common/pv_frame_metadata_mio_video_config.cpp
+
+HDRS := pv_frame_metadata_factory.h \
+        pv_frame_metadata_interface.h
+
+include $(MK)/library.mk
diff --git a/engines/adapters/player/framemetadatautility/build/make/makefile b/engines/adapters/player/framemetadatautility/build/make/makefile
deleted file mode 100644
index 96daf7e..0000000
--- a/engines/adapters/player/framemetadatautility/build/make/makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvframemetadatautility
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-XINCDIRS += -I $(VOB_BASE_DIR)/engines/common/include \
-            -I $(VOB_BASE_DIR)/engines/player/include \
-            -I ../../config/linux \
-			-I $(VOB_BASE_DIR)/nodes/common/include \
-			-I $(VOB_BASE_DIR)/pvmi/pvmf/include \
-			-I $(VOB_BASE_DIR)/baselibs/pv_mime_utils/src \
-			-I $(VOB_BASE_DIR)/nodes/pvmediaoutputnode/include \
-			-I $(VOB_BASE_DIR)/codecs_v2/utilities/colorconvert/include \
-			-I $(VOB_BASE_DIR)/codecs_v2/utilities/colorconvert/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pv_frame_metadata_utility.cpp \
-	pv_frame_metadata_factory.cpp \
-	pv_frame_metadata_mio_video.cpp \
-	pv_frame_metadata_mio_audio.cpp \
-	../config/common/pv_frame_metadata_mio_video_config.cpp
-
-HDRS =  pv_frame_metadata_factory.h \
-	pv_frame_metadata_interface.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
-
-
diff --git a/engines/adapters/player/framemetadatautility/config/common/pv_frame_metadata_mio_video_config.cpp b/engines/adapters/player/framemetadatautility/config/common/pv_frame_metadata_mio_video_config.cpp
index 28550b7..7e1b73d 100644
--- a/engines/adapters/player/framemetadatautility/config/common/pv_frame_metadata_mio_video_config.cpp
+++ b/engines/adapters/player/framemetadatautility/config/common/pv_frame_metadata_mio_video_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,28 +31,26 @@
 PVMFStatus PVFMVideoMIO::CreateYUVToRGBColorConverter(ColorConvertBase*& aCC, PVMFFormatType aRGBFormatType)
 {
     int32 leavecode = 0;
-    switch (aRGBFormatType)
+#if 0
+    if (aRGBFormatType == PVMF_MIME_RGB12)
     {
-#if 0
-        case PVMF_RGB12:
-            OSCL_TRY(leavecode, aCC = ColorConvert12::NewL());
-            break;
+        OSCL_TRY(leavecode, aCC = ColorConvert12::NewL());
+    }
 #endif
-
-        case PVMF_RGB16:
-            OSCL_TRY(leavecode, aCC = ColorConvert16::NewL());
-            break;
-
+    if (aRGBFormatType == PVMF_MIME_RGB16)
+    {
+        OSCL_TRY(leavecode, aCC = ColorConvert16::NewL());
+    }
 #if 0
-        case PVMF_RGB24:
-            OSCL_TRY(leavecode, aCC = ColorConvert24::NewL());
-            break;
+    if (aRGBFormatType == PVMF_MIME_RGB24)
+    {
+        OSCL_TRY(leavecode, aCC = ColorConvert24::NewL());
+    }
 #endif
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CreateYUVToRGBColorConverter() Unsupported RGB mode for color converter. Asserting"));
-            OSCL_ASSERT(false);
-            return PVMFErrNotSupported;
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CreateYUVToRGBColorConverter() Unsupported RGB mode for color converter. Asserting"));
+        return PVMFErrNotSupported;
     }
 
     OSCL_FIRST_CATCH_ANY(leavecode,
@@ -68,31 +66,29 @@
 {
     OSCL_ASSERT(aCC != NULL);
 
-    switch (aRGBFormatType)
+#if 0
+    if (aRGBFormatType == PVMF_MIME_RGB12)
     {
-#if 0
-        case PVMF_RGB12:
-            OSCL_DELETE(((ColorConvert12*)aCC));
-            aCC = NULL;
-            break;
+        OSCL_DELETE(((ColorConvert12*)aCC));
+        aCC = NULL;
+    }
 #endif
-
-        case PVMF_RGB16:
-            OSCL_DELETE(((ColorConvert16*)aCC));
-            aCC = NULL;
-            break;
-
+    if (aRGBFormatType == PVMF_MIME_RGB16)
+    {
+        OSCL_DELETE(((ColorConvert16*)aCC));
+        aCC = NULL;
+    }
 #if 0
-        case PVMF_RGB24:
-            OSCL_DELETE(((ColorConvert24*)aCC));
-            aCC = NULL;
-            break;
+    if (aRGBFormatType == PVMF_MIME_RGB24)
+    {
+        OSCL_DELETE(((ColorConvert24*)aCC));
+        aCC = NULL;
+    }
 #endif
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CreateYUVToRGBColorConverter() Unsupported RGB mode for color converter. Asserting"));
-            OSCL_ASSERT(false);
-            return PVMFErrNotSupported;
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CreateYUVToRGBColorConverter() Unsupported RGB mode for color converter. Asserting"));
+        return PVMFErrNotSupported;
     }
 
     return PVMFSuccess;
diff --git a/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_factory.h b/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_factory.h
index a5db767..a40a81d 100644
--- a/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_factory.h
+++ b/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_interface.h b/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_interface.h
index 1c2d057..f5ec16b 100644
--- a/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_interface.h
+++ b/engines/adapters/player/framemetadatautility/include/pv_frame_metadata_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -480,6 +480,19 @@
          * (PVMFSuccess, PVMFFailure, PVMFErrNotSupported, PVMFErrInvalidState, PVMFErrArgument)
          **/
         virtual PVMFStatus SetMode(uint32 aMode) = 0;
+
+        /**
+         * This method allows setting the maximum thumbnail size to be retrieved.
+         * Any video streams with larger dimensions will be scaled down proportionally.
+         * aWidth * aHeight * bpc should not exceed the size of the provided buffer.
+         * @param aWidth
+         * @param aHeight
+         *
+         * @returns A status code on whether the intent was accepted or not
+         * (PVMFSuccess, PVMFFailure, PVMFErrNotSupported, PVMFErrInvalidState, PVMFErrArgument)
+         **/
+        virtual void SetThumbnailDimensions(uint32 aWidth, uint32 aHeight) = 0;
+        virtual void GetThumbnailDimensions(uint32 &aWidth, uint32 &aHeight) = 0;
 };
 
 #endif // PV_FRAME_METADATA_INTERFACE_H_INCLUDED
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_factory.cpp b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_factory.cpp
index a67dc5a..a79143e 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_factory.cpp
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.cpp b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.cpp
index d3f12bc..05bb1a9 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.cpp
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,11 +30,13 @@
 
 void PVFMAudioMIO::InitData()
 {
-    iAudioFormat = PVMF_FORMAT_UNKNOWN;
+    iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iAudioSamplingRateValid = false;
     iAudioNumChannelsValid = false;
+    iIsMIOConfigured = false;
     iAudioSamplingRate = 0;
     iAudioNumChannels = 0;
+    iWriteBusy = false;
 
     iCommandCounter = 0;
     iLogger = NULL;
@@ -54,12 +56,13 @@
     Cleanup();
 
     // Reset all the received media parameters.
-    iAudioFormatString = "";
-    iAudioFormat = PVMF_FORMAT_UNKNOWN;
+    iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iAudioSamplingRateValid = false;
     iAudioNumChannelsValid = false;
     iAudioSamplingRate = 0;
     iAudioNumChannels = 0;
+    iIsMIOConfigured = false;
+    iWriteBusy = false;
 }
 
 
@@ -240,8 +243,14 @@
 
 PVMFCommandId PVFMAudioMIO::Reset(const OsclAny* aContext)
 {
-    OSCL_UNUSED_ARG(aContext);
-    return 0;
+    ResetData();
+
+    PVMFCommandId cmdid = iCommandCounter++;
+    PVMFStatus status = PVMFSuccess;
+
+    CommandResponse resp(status, cmdid, aContext);
+    QueueCommandResponse(resp);
+    return cmdid;
 }
 
 PVMFCommandId PVFMAudioMIO::Start(const OsclAny* aContext)
@@ -258,6 +267,11 @@
         case STATE_PAUSED:
             iState = STATE_STARTED;
             status = PVMFSuccess;
+            if (iPeer && iWriteBusy)
+            {
+                iWriteBusy = false;
+                iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+            }
             break;
 
         default:
@@ -436,8 +450,6 @@
         RemoveFromScheduler();
         iLogger = NULL;
         iState = STATE_IDLE;
-        // Reset all data from this session
-        ResetData();
     }
 }
 
@@ -465,10 +477,21 @@
 PVMFCommandId PVFMAudioMIO::writeAsync(uint8 aFormatType, int32 aFormatIndex, uint8* aData, uint32 aDataLen,
                                        const PvmiMediaXferHeader& data_header_info, OsclAny* aContext)
 {
+    OSCL_UNUSED_ARG(aData);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMAudioMIO::writeAsync() seqnum %d ts %d context %d", data_header_info.seq_num, data_header_info.timestamp, aContext));
 
     PVMFStatus status = PVMFFailure;
 
+    // Do a leave if MIO is not configured except when it is an EOS
+    if (!iIsMIOConfigured &&
+            !((PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == aFormatType) &&
+              (PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM == aFormatIndex)))
+    {
+        iWriteBusy = true;
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
     switch (aFormatType)
     {
         case PVMI_MEDIAXFER_FMT_TYPE_COMMAND :
@@ -501,7 +524,9 @@
                     if (iState < STATE_INITIALIZED)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "PVFMAudioMIO::writeAsync: Error - Invalid state"));
-                        status = PVMFErrInvalidState;
+                        iWriteBusy = true;
+                        OSCL_LEAVE(OsclErrInvalidState);
+                        return -1;
                     }
                     else
                     {
@@ -524,7 +549,9 @@
                     if (iState != STATE_STARTED)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "PVFMAudioMIO::writeAsync: Error - Invalid state"));
-                        status = PVMFErrInvalidState;
+                        iWriteBusy = true;
+                        OSCL_LEAVE(OsclErrInvalidState);
+                        return -1;
                     }
                     else
                     {
@@ -694,17 +721,18 @@
         // This is a query for the list of supported formats.
         // This component supports any audio format
         // Generate a list of all the PVMF audio formats...
-        int32 count = 1 + PVMF_LAST_UNCOMPRESSED_AUDIO - PVMF_FIRST_UNCOMPRESSED_AUDIO;
 
+        uint32 count = PVMF_SUPPORTED_UNCOMPRESSED_AUDIO_FORMATS_COUNT;
         aParameters = (PvmiKvp*)oscl_malloc(count * sizeof(PvmiKvp));
 
         if (aParameters)
         {
-            PVMFFormatType fmt;
-            for (fmt = PVMF_FIRST_UNCOMPRESSED_AUDIO;fmt <= PVMF_LAST_UNCOMPRESSED_AUDIO;fmt++)
-            {
-                aParameters[num_parameter_elements++].value.uint32_value = (uint32)fmt;
-            }
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM8;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM16;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM16_BE;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ULAW;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ALAW;
             return PVMFSuccess;
         }
         return PVMFErrNoMemory;
@@ -784,9 +812,8 @@
         //Check against known audio parameter keys...
         if (pv_mime_strcmp(aParameters[i].key, MOUT_AUDIO_FORMAT_KEY) == 0)
         {
-            iAudioFormatString = aParameters[i].value.pChar_value;
-            iAudioFormat = GetFormatIndex(iAudioFormatString.get_str());
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMAudioMIO::setParametersSync() Audio Format Key, Value %s", iAudioFormatString.get_str()));
+            iAudioFormat = aParameters[i].value.pChar_value;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMAudioMIO::setParametersSync() Audio Format Key, Value %s", iAudioFormat.getMIMEStrPtr()));
         }
         else if (pv_mime_strcmp(aParameters[i].key, MOUT_AUDIO_SAMPLING_RATE_KEY) == 0)
         {
@@ -806,6 +833,20 @@
         }
         else
         {
+            if (iAudioSamplingRateValid && iAudioNumChannelsValid && !iIsMIOConfigured)
+            {
+                if (iObserver)
+                {
+                    iIsMIOConfigured = true;
+                    iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+                    if (iPeer && iWriteBusy)
+                    {
+                        iWriteBusy = false;
+                        iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+                    }
+                }
+            }
+
             // If we get here the key is unrecognized.
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMAudioMIO::setParametersSync() Error, unrecognized key "));
 
@@ -814,6 +855,19 @@
             return;
         }
     }
+    if (iAudioSamplingRateValid && iAudioNumChannelsValid && !iIsMIOConfigured)
+    {
+        if (iObserver)
+        {
+            iIsMIOConfigured = true;
+            iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+            if (iPeer && iWriteBusy)
+            {
+                iWriteBusy = false;
+                iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+            }
+        }
+    }
 }
 
 
@@ -848,10 +902,33 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMAudioMIO::verifyParametersSync() called"));
 
     OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(num_elements);
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVFMAudioMIO::verifyParametersSync() NOT SUPPORTED"));
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media/format-type")) == 0)
+        {
+            //This component supports PCM8 or PCM16 only.
+            if ((pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM8) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM16) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM16) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM16_BE) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ULAW) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ALAW) == 0))
+            {
+                return PVMFSuccess;
+            }
+            else
+            {
+                return PVMFErrNotSupported;
+            }
+        }
+    }
+    // For all other parameters return success.
     return PVMFSuccess;
 }
 
@@ -859,7 +936,7 @@
 //
 // For active timing support
 //
-PVMFStatus PVFMAudioMIOActiveTimingSupport::SetClock(OsclClock *clockVal)
+PVMFStatus PVFMAudioMIOActiveTimingSupport::SetClock(PVMFMediaClock *clockVal)
 {
     iClock = clockVal;
     return PVMFSuccess;
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.h b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.h
index 306f60e..91c499b 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.h
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_audio.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,8 +40,12 @@
 #include "pvmi_media_io_clock_extension.h"
 #endif
 
+// To maintain the count of supported uncompressed audio formats.
+// Should be updated whenever new format is added
+#define PVMF_SUPPORTED_UNCOMPRESSED_AUDIO_FORMATS_COUNT 6
+
 class PVLogger;
-class OsclClock;
+class PVMFMediaClock;
 class ColorConvertBase;
 
 class PVFMAudioMIOGetFrameObserver
@@ -62,7 +66,7 @@
         {}
 
         // From PvmiClockExtensionInterface
-        PVMFStatus SetClock(OsclClock *aClock);
+        PVMFStatus SetClock(PVMFMediaClock *aClock);
 
         // From PVInterface
         void addRef() ;
@@ -71,7 +75,7 @@
 
         void queryUuid(PVUuid& uuid);
 
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
 };
 
 
@@ -213,12 +217,13 @@
         Oscl_Vector<WriteResponse, OsclMemAllocator> iWriteResponseQueue;
 
         // Audio parameters
-        OSCL_HeapString<OsclMemAllocator> iAudioFormatString;
         PVMFFormatType iAudioFormat;
         uint32 iAudioNumChannels;
         bool iAudioNumChannelsValid;
         uint32 iAudioSamplingRate;
         bool iAudioSamplingRateValid;
+        bool iIsMIOConfigured;
+        bool iWriteBusy;
 
         // For logging
         PVLogger* iLogger;
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.cpp b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.cpp
index d07419a..5736de2 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.cpp
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,22 +30,24 @@
 
 void PVFMVideoMIO::InitData()
 {
-    iVideoFormatString = PVMF_MIME_FORMAT_UNKNOWN;
-    iVideoFormat = PVMF_FORMAT_UNKNOWN;
+    iVideoFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iVideoHeightValid = false;
     iVideoWidthValid = false;
     iVideoDisplayHeightValid = false;
     iVideoDisplayWidthValid = false;
+    iIsMIOConfigured = false;
+    iWriteBusy = false;
     iVideoHeight = 0;
     iVideoWidth = 0;
     iVideoDisplayHeight = 0;
     iVideoDisplayWidth = 0;
 
-    iColorConverter = NULL;
-    iCCRGBFormatType = PVMF_FORMAT_UNKNOWN;
+    iThumbnailWidth = 320;
+    iThumbnailHeight = 240;
 
-    // hardware specific information
-    iVideoSubFormat = PVMF_FORMAT_UNKNOWN;
+
+    iColorConverter = NULL;
+    iCCRGBFormatType = PVMF_MIME_FORMAT_UNKNOWN;
 
     iCommandCounter = 0;
     iLogger = NULL;
@@ -72,9 +74,7 @@
     Cleanup();
 
     // Reset all the received media parameters.
-    iVideoFormatString = PVMF_MIME_FORMAT_UNKNOWN;
-    iVideoFormat = PVMF_FORMAT_UNKNOWN;
-    iVideoSubFormat = PVMF_FORMAT_UNKNOWN;
+    iVideoFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iVideoHeightValid = false;
     iVideoWidthValid = false;
     iVideoDisplayHeightValid = false;
@@ -83,6 +83,8 @@
     iVideoWidth = 0;
     iVideoDisplayHeight = 0;
     iVideoDisplayWidth = 0;
+    iIsMIOConfigured = false;
+    iWriteBusy = false;
 }
 
 
@@ -118,6 +120,11 @@
     }
 }
 
+void PVFMVideoMIO::setThumbnailDimensions(uint32 aWidth, uint32 aHeight)
+{
+    iThumbnailWidth = aWidth;
+    iThumbnailHeight = aHeight;
+}
 
 PVMFStatus PVFMVideoMIO::GetFrameByFrameNumber(uint32 aFrameIndex, uint8* aFrameBuffer, uint32& aBufferSize,
         PVMFFormatType aFormatType, PVFMVideoMIOGetFrameObserver& aObserver)
@@ -371,8 +378,14 @@
 
 PVMFCommandId PVFMVideoMIO::Reset(const OsclAny* aContext)
 {
-    OSCL_UNUSED_ARG(aContext);
-    return 0;
+    ResetData();
+
+    PVMFCommandId cmdid = iCommandCounter++;
+    PVMFStatus status = PVMFSuccess;
+
+    CommandResponse resp(status, cmdid, aContext);
+    QueueCommandResponse(resp);
+    return cmdid;
 }
 
 PVMFCommandId PVFMVideoMIO::Start(const OsclAny* aContext)
@@ -389,6 +402,11 @@
         case STATE_PAUSED:
             iState = STATE_STARTED;
             status = PVMFSuccess;
+            if (iPeer && iWriteBusy)
+            {
+                iWriteBusy = false;
+                iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+            }
             break;
 
         default:
@@ -567,8 +585,6 @@
         RemoveFromScheduler();
         iLogger = NULL;
         iState = STATE_IDLE;
-        // Reset all data from this session
-        ResetData();
     }
 }
 
@@ -600,6 +616,16 @@
 
     PVMFStatus status = PVMFFailure;
 
+    // Do a leave if MIO is not configured except when it is an EOS
+    if (!iIsMIOConfigured &&
+            !((PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == aFormatType) &&
+              (PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM == aFormatIndex)))
+    {
+        iWriteBusy = true;
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
     switch (aFormatType)
     {
         case PVMI_MEDIAXFER_FMT_TYPE_COMMAND :
@@ -613,13 +639,13 @@
             switch (aFormatIndex)
             {
                 case PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM:
-                    // If waiting for frame then return failure
+                    // If waiting for frame then return errMaxReached
                     if (iFrameRetrievalInfo.iRetrievalRequested)
                     {
                         iFrameRetrievalInfo.iRetrievalRequested = false;
                         iFrameRetrievalInfo.iUseFrameIndex = false;
                         iFrameRetrievalInfo.iUseTimeOffset = false;
-                        iFrameRetrievalInfo.iGetFrameObserver->HandleFrameReadyEvent(PVMFFailure);
+                        iFrameRetrievalInfo.iGetFrameObserver->HandleFrameReadyEvent(PVMFErrMaxReached);
                     }
                     break;
 
@@ -640,7 +666,9 @@
                     if (iState < STATE_INITIALIZED)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::writeAsync: Error - Invalid state"));
-                        status = PVMFErrInvalidState;
+                        iWriteBusy = true;
+                        OSCL_LEAVE(OsclErrInvalidState);
+                        return -1;
                     }
                     else
                     {
@@ -663,7 +691,9 @@
                     if (iState != STATE_STARTED)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::writeAsync: Error - Invalid state"));
-                        status = PVMFErrInvalidState;
+                        iWriteBusy = true;
+                        OSCL_LEAVE(OsclErrInvalidState);
+                        return -1;
                     }
                     else
                     {
@@ -687,11 +717,21 @@
                             // Check if a frame retrieval was requested
                             if (iFrameRetrievalInfo.iRetrievalRequested)
                             {
+
+                                // scale down output proportionally if smaller thumbnail requested
+                                if (iVideoDisplayWidth > iThumbnailWidth || iVideoDisplayHeight > iThumbnailHeight)
+                                {
+                                    float fScaleWidth = (float)iThumbnailWidth / iVideoDisplayWidth;
+                                    float fScaleHeight = (float)iThumbnailHeight / iVideoDisplayHeight;
+                                    float fScale = (fScaleWidth > fScaleHeight) ? fScaleHeight : fScaleWidth;
+                                    iVideoDisplayWidth = (uint32)(iVideoDisplayWidth * fScale);
+                                    iVideoDisplayHeight = (uint32)(iVideoDisplayHeight * fScale);
+                                }
+
                                 if (iFrameRetrievalInfo.iUseFrameIndex == true &&
                                         iFrameRetrievalInfo.iReceivedFrameCount > iFrameRetrievalInfo.iFrameIndex)
                                 {
                                     PVMFStatus evstatus = PVMFFailure;
-
                                     // Copy the frame data
                                     evstatus = CopyVideoFrameData(aData, aDataLen, iVideoFormat,
                                                                   iFrameRetrievalInfo.iFrameBuffer, *(iFrameRetrievalInfo.iBufferSize), iFrameRetrievalInfo.iFrameFormatType,
@@ -763,8 +803,8 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMVideoMIO::CopyVideoFrameData() In"));
 
-    if (aSrcBuffer == NULL || aSrcSize == 0 || aSrcFormat == PVMF_FORMAT_UNKNOWN ||
-            aDestBuffer == NULL || aDestSize == 0 || aDestFormat == PVMF_FORMAT_UNKNOWN)
+    if (aSrcBuffer == NULL || aSrcSize == 0 || aSrcFormat == PVMF_MIME_FORMAT_UNKNOWN ||
+            aDestBuffer == NULL || aDestSize == 0 || aDestFormat == PVMF_MIME_FORMAT_UNKNOWN)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CopyVideoFrameData() Color converter instantiation did a leave"));
         return PVMFErrArgument;
@@ -778,23 +818,16 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CopyVideoFrameData() Color converter instantiation did a leave"));
             return PVMFErrArgument;
         }
-
-        // check for special hardware format
-        if (iVideoSubFormat == PVMF_YUV420_SEMIPLANAR_YVU) {
-            LOGV("@@@@@ Need special color conversion @@@@@");
-            convertFrame(aSrcBuffer, aDestBuffer, aSrcSize);
-        } else {
-            oscl_memcpy(aDestBuffer, aSrcBuffer, aSrcSize);
-        }
+        oscl_memcpy(aDestBuffer, aSrcBuffer, aSrcSize);
         aDestSize = aSrcSize;
     }
-    else if (aSrcFormat == PVMF_YUV420 &&
-             (aDestFormat == PVMF_RGB12 || aDestFormat == PVMF_RGB16 || aDestFormat == PVMF_RGB24))
+    else if (aSrcFormat == PVMF_MIME_YUV420 &&
+             (aDestFormat == PVMF_MIME_RGB12 || aDestFormat == PVMF_MIME_RGB16 || aDestFormat == PVMF_MIME_RGB24))
     {
         // Source is YUV 4:2:0 and dest is RGB 12, 16, or 24 bit
 
         // Validate the source and dest dimensions
-        if (aSrcWidth == 0 || aSrcHeight == 0 || aDestWidth == 0 || aDestWidth == 0)
+        if (aSrcWidth == 0 || aSrcHeight == 0 || aDestWidth == 0 || aDestHeight == 0)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFMVideoMIO::CopyVideoFrameData() Invalid frame dimensions Src(WxH): %dx%d Dest(WxH): %dx%d",
                             aSrcWidth, aSrcHeight, aDestWidth, aDestHeight));
@@ -820,15 +853,15 @@
             iCCRGBFormatType = aDestFormat;
         }
 
-        // Configure the color converter and check the required RGB buffer size
-        iColorConverter->SetMode(0);
-        if (!(iColorConverter->Init((iVideoDisplayWidth + 1)&(~1), (iVideoDisplayHeight + 1)&(~1), (iVideoWidth + 1)&(~1), aDestWidth, (aDestHeight + 1)&(~1), (aDestWidth + 1)&(~1), CCROTATE_NONE)))
+        if (!(iColorConverter->Init((aSrcWidth + 1)&(~1), (aSrcHeight + 1)&(~1), (aSrcWidth + 1)&(~1), aDestWidth, (aDestHeight + 1)&(~1), (aDestWidth + 1)&(~1), CCROTATE_NONE)))
         {
             iColorConverter = NULL;
             return PVMFFailure;
         }
 
+
         iColorConverter->SetMemHeight((iVideoHeight + 1)&(~1));
+        iColorConverter->SetMode(1); // Do scaling if needed.
 
         uint32 rgbbufsize = (uint32)(iColorConverter->GetOutputBufferSize());
         if (rgbbufsize > aDestSize)
@@ -988,7 +1021,7 @@
     {
         //query for video format string
         aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
-        aParameters->value.pChar_value = (char*)iVideoFormatString.get_cstr();
+        aParameters->value.pChar_value = (char*)iVideoFormat.getMIMEStrPtr();
         //don't bother to set the key string.
         return PVMFSuccess;
     }
@@ -996,19 +1029,20 @@
     else if (pv_mime_strcmp(aIdentifier, INPUT_FORMATS_CAP_QUERY) == 0)
     {
         // This is a query for the list of supported formats.
-        // This component supports any video format
+        // This component supports all uncompressed video format
         // Generate a list of all the PVMF video formats...
-        int32 count = 1 + PVMF_LAST_UNCOMPRESSED_VIDEO - PVMF_FIRST_UNCOMPRESSED_VIDEO;
+        int32 count = PVMF_SUPPORTED_UNCOMPRESSED_VIDEO_FORMATS_COUNT;
 
         aParameters = (PvmiKvp*)oscl_malloc(count * sizeof(PvmiKvp));
 
         if (aParameters)
         {
-            PVMFFormatType fmt;
-            for (fmt = PVMF_FIRST_UNCOMPRESSED_VIDEO;fmt <= PVMF_LAST_UNCOMPRESSED_VIDEO;fmt++)
-            {
-                aParameters[num_parameter_elements++].value.uint32_value = (uint32)fmt;
-            }
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_YUV420;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_YUV422;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB8;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB12;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB16;
+            aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB24;
             return PVMFSuccess;
         }
         return PVMFErrNoMemory;
@@ -1088,9 +1122,8 @@
         //Check against known video parameter keys...
         if (pv_mime_strcmp(aParameters[i].key, MOUT_VIDEO_FORMAT_KEY) == 0)
         {
-            iVideoFormatString = aParameters[i].value.pChar_value;
-            iVideoFormat = GetFormatIndex(iVideoFormatString.get_str());
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMVideoMIO::setParametersSync() Video Format Key, Value %s", iVideoFormatString.get_str()));
+            iVideoFormat = aParameters[i].value.pChar_value;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMVideoMIO::setParametersSync() Video Format Key, Value %s", iVideoFormat.getMIMEStrPtr()));
         }
         else if (pv_mime_strcmp(aParameters[i].key, MOUT_VIDEO_WIDTH_KEY) == 0)
         {
@@ -1120,15 +1153,22 @@
         {
             //	iOutputFile.Write(aParameters[i].value.pChar_value, sizeof(uint8), (int32)aParameters[i].capacity);
         }
-        else if (pv_mime_strcmp(aParameters[i].key, MOUT_VIDEO_SUBFORMAT_KEY) == 0)
-        {
-            iVideoSubFormat = (PVMFFormatType) aParameters[i].value.uint32_value;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0,"AndroidSurfaceOutput::setParametersSync() Video SubFormat Key, Value %d",iVideoSubFormat));
-LOGV("VIDEO SUBFORMAT SET TO %d\n",iVideoSubFormat);
-        }
         else
         {
+            if (iVideoWidthValid && iVideoHeightValid && iVideoDisplayHeightValid && iVideoDisplayHeightValid && !iIsMIOConfigured)
+            {
+                if (iObserver)
+                {
+                    iIsMIOConfigured = true;
+                    iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+                    if (iPeer && iWriteBusy)
+                    {
+                        iWriteBusy = false;
+                        iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+                    }
+                }
+            }
+
             // If we get here the key is unrecognized.
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMVideoMIO::setParametersSync() Error, unrecognized key "));
 
@@ -1137,6 +1177,19 @@
             return;
         }
     }
+    if (iVideoWidthValid && iVideoHeightValid && iVideoDisplayHeightValid && iVideoDisplayHeightValid && !iIsMIOConfigured)
+    {
+        if (iObserver)
+        {
+            iIsMIOConfigured = true;
+            iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+            if (iPeer && iWriteBusy)
+            {
+                iWriteBusy = false;
+                iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+            }
+        }
+    }
 }
 
 
@@ -1171,10 +1224,33 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFMVideoMIO::verifyParametersSync() called"));
 
     OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(num_elements);
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVFMVideoMIO::verifyParametersSync() NOT SUPPORTED"));
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media/format-type")) == 0)
+        {
+            //This component supports only uncompressed formats
+            if ((pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_YUV420) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_YUV422) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB8) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB12) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB16) == 0) ||
+                    (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB24) == 0))
+            {
+                return PVMFSuccess;
+            }
+            else
+            {
+                return PVMFErrNotSupported;
+            }
+        }
+    }
+    // For all other parameters return success.
     return PVMFSuccess;
 }
 
@@ -1182,7 +1258,7 @@
 //
 // For active timing support
 //
-PVMFStatus PVFMVideoMIOActiveTimingSupport::SetClock(OsclClock *clockVal)
+PVMFStatus PVFMVideoMIOActiveTimingSupport::SetClock(PVMFMediaClock *clockVal)
 {
     iClock = clockVal;
     return PVMFSuccess;
@@ -1247,26 +1323,8 @@
     }
 }
 
-static inline void* byteOffset(void* p, size_t offset) { return (void*)((uint8_t*)p + offset); }
 
-// convert a frame in YUV420 semiplanar format with VU ordering to YUV420 planar format
-void PVFMVideoMIO::convertFrame(void* src, void* dst, size_t len)
-{
-    // copy the Y plane
-    size_t y_plane_size = iVideoWidth * iVideoHeight;
-    //LOGV("len=%u, y_plane_size=%u", len, y_plane_size);
-    memcpy(dst, src, y_plane_size + iVideoWidth);
 
-    // re-arrange U's and V's
-    uint32_t* p = (uint32_t*)byteOffset(src, y_plane_size);
-    uint16_t* pu = (uint16_t*)byteOffset(dst, y_plane_size);
-    uint16_t* pv = (uint16_t*)byteOffset(pu, y_plane_size / 4);
 
-    int count = y_plane_size / 8;
-    //LOGV("u = %p, v = %p, p = %p, count = %d", pu, pv, p, count);
-    do {
-        uint32_t uvuv = *p++;
-        *pu++ = (uint16_t) (((uvuv >> 8) & 0xff) | ((uvuv >> 16) & 0xff00));
-        *pv++ = (uint16_t) ((uvuv & 0xff) | ((uvuv >> 8) & 0xff00));
-    } while (--count);
-}
+
+
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.h b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.h
index 4db70a7..a2ff965 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.h
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_mio_video.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,9 +41,13 @@
 #endif
 
 class PVLogger;
-class OsclClock;
+class PVMFMediaClock;
 class ColorConvertBase;
 
+// To maintain the count of supported uncompressed video formats.
+// Should be updated whenever new format is added
+#define PVMF_SUPPORTED_UNCOMPRESSED_VIDEO_FORMATS_COUNT 6
+
 class PVFMVideoMIOGetFrameObserver
 {
     public:
@@ -62,7 +66,7 @@
         {}
 
         // From PvmiClockExtensionInterface
-        PVMFStatus SetClock(OsclClock *aClock);
+        PVMFStatus SetClock(PVMFMediaClock *aClock);
 
         // From PVInterface
         void addRef() ;
@@ -71,7 +75,7 @@
 
         void queryUuid(PVUuid& uuid);
 
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
 };
 
 
@@ -145,6 +149,7 @@
         uint32 getCapabilityMetric(PvmiMIOSession aSession);
         PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
 
+        void setThumbnailDimensions(uint32 aWidth, uint32 aHeight);
     private:
         void InitData();
 
@@ -162,7 +167,6 @@
                                       uint32 iSrcWidth, uint32 iSrcHeight, uint32 iDestWidth, uint32 iDestHeight);
         PVMFStatus CreateYUVToRGBColorConverter(ColorConvertBase*& aCC, PVMFFormatType aRGBFormatType);
         PVMFStatus DestroyYUVToRGBColorConverter(ColorConvertBase*& aCC, PVMFFormatType aRGBFormatType);
-        void convertFrame(void* src, void* dst, size_t len);
 
         PvmiMediaTransfer* iPeer;
 
@@ -214,9 +218,7 @@
         Oscl_Vector<WriteResponse, OsclMemAllocator> iWriteResponseQueue;
 
         // Video parameters
-        OSCL_HeapString<OsclMemAllocator> iVideoFormatString;
         PVMFFormatType iVideoFormat;
-        PVMFFormatType iVideoSubFormat;
         uint32 iVideoHeight;
         bool iVideoHeightValid;
         uint32 iVideoWidth;
@@ -225,6 +227,11 @@
         bool iVideoDisplayHeightValid;
         uint32 iVideoDisplayWidth;
         bool iVideoDisplayWidthValid;
+        bool iIsMIOConfigured;
+        bool iWriteBusy;
+
+        uint32 iThumbnailWidth;
+        uint32 iThumbnailHeight;
 
         // Color converter if YUV to RGB is needed
         ColorConvertBase* iColorConverter;
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.cpp b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.cpp
index 0d96258..35673a3 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.cpp
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,7 +31,9 @@
 
 static const char PVFMUTIL_FRAMERETRIEVAL_TIMEOUT_KEY[] = "x-pvmf/fmu/timeout-frameretrieval-in-seconds;valtype=uint32";
 
-#define PVFMUTIL_VIDEOFRAMEBUFFER_MAXSIZE 320*240*3
+#define PVFMUTIL_VIDEOFRAMEBUFFER_WIDTH 320
+#define PVFMUTIL_VIDEOFRAMEBUFFER_HEIGHT 240
+#define PVFMUTIL_VIDEOFRAMEBUFFER_MAXSIZE PVFMUTIL_VIDEOFRAMEBUFFER_WIDTH * PVFMUTIL_VIDEOFRAMEBUFFER_HEIGHT * 3
 #define PVFMUTIL_VIDEOFRAMEBUFFER_MEMPOOL_BUFFERSIZE PVFMUTIL_VIDEOFRAMEBUFFER_MAXSIZE*2
 
 PVFrameAndMetadataUtility* PVFrameAndMetadataUtility::New(char *aOutputFormatMIMEType, PVCommandStatusObserver *aCmdObserver,
@@ -111,7 +113,7 @@
     // Remove the data source handle
     iDataSource = NULL;
 
-    OSCL_TEMPLATED_DELETE(iTimeoutTimer, OsclTimer<OsclMemAllocator>, OsclTimer);
+    OSCL_DELETE(iTimeoutTimer);
 }
 
 PVMFStatus PVFrameAndMetadataUtility::SetMode(uint32 aMode)
@@ -231,6 +233,8 @@
         char* aQueryKey, const OsclAny* aContextData)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::GetMetadataKeys()"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::GetMetadataKeys called Tick=%d", OsclTickCount::TickCount()));
 
     Oscl_Vector<PVFMUtilityCommandParamUnion, OsclMemAllocator> paramvec;
     paramvec.reserve(4);
@@ -254,6 +258,9 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::GetMetadataValues()"));
 
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::GetMetadataValues called Tick=%d", OsclTickCount::TickCount()));
+
     Oscl_Vector<PVFMUtilityCommandParamUnion, OsclMemAllocator> paramvec;
     paramvec.reserve(5);
     paramvec.clear();
@@ -375,7 +382,7 @@
         iErrorEventObserver(NULL),
         iInfoEventObserver(NULL),
         iPlayer(NULL),
-        iOutputFormatType(PVMF_FORMAT_UNKNOWN),
+        iOutputFormatType(PVMF_MIME_FORMAT_UNKNOWN),
         iDataSource(NULL),
         iVideoNode(NULL),
         iVideoMIO(NULL),
@@ -394,7 +401,9 @@
         iAPICmdErrMsg(NULL),
         iTimeoutTimer(NULL),
         iErrorHandlingWaitTime(PVFMUTIL_ERRORHANDLINGTIMEOUT_VALUE),
-        iFrameReadyWaitTime(PVFMUTIL_FRAMEREADYTIMEOUT_VALUE_DEFAULT)
+        iFrameReadyWaitTime(PVFMUTIL_FRAMEREADYTIMEOUT_VALUE_DEFAULT),
+        iThumbnailWidth(PVFMUTIL_VIDEOFRAMEBUFFER_WIDTH),
+        iThumbnailHeight(PVFMUTIL_VIDEOFRAMEBUFFER_HEIGHT)
 {
     //define this Macro in mmp build file only if mode 1 of FrMU is required.
 #ifdef SUPPORT_PARSER_LEVEL_METADATA_EXTRACTION_ONLY
@@ -402,7 +411,8 @@
 #else
     iMode = PV_FRAME_METADATA_INTERFACE_MODE_ALL;
 #endif
-
+    iPlayerCapConfigIF = NULL;
+    iPlayerCapConfigIFPVI = NULL;
 }
 
 
@@ -411,13 +421,9 @@
 {
     OSCL_ASSERT(aOutputFormatMIMEType != NULL);
 
-    iOutputMIMEType = aOutputFormatMIMEType;
-    iOutputFormatType = GetFormatIndex(iOutputMIMEType.get_str(), PVMF_UNCOMPRESSED_VIDEO_FORMAT);
-    if (iOutputFormatType == PVMF_FORMAT_UNKNOWN)
-        iOutputFormatType = GetFormatIndex(iOutputMIMEType.get_str(), PVMF_UNCOMPRESSED_AUDIO_FORMAT);
-    if (iOutputFormatType == PVMF_FORMAT_UNKNOWN)
-        iOutputFormatType = GetFormatIndex(iOutputMIMEType.get_str(), PVMF_COMPRESSED_AUDIO_FORMAT);
-    if (iOutputFormatType == PVMF_FORMAT_UNKNOWN)
+    iOutputFormatType = aOutputFormatMIMEType;
+
+    if (iOutputFormatType == PVMF_MIME_FORMAT_UNKNOWN)
     {
         OSCL_LEAVE(OsclErrArgument);
         return;
@@ -668,6 +674,7 @@
                 break;
 
             case PVFM_CMD_PlayerQueryInterface:
+            case PVFM_CMD_PlayerQueryCapConfigInterface:
                 HandlePlayerQueryInterface(*context, aResponse);
                 break;
 
@@ -707,6 +714,10 @@
                 HandlePlayerGetMetadataValues(*context, aResponse);
                 break;
 
+            case PVFM_CMD_PlayerSetParametersSync:
+                HandlePlayerSetParametersSync(*context, aResponse);
+                break;
+
             case PVFM_CMD_GFPlayerStopFromPaused:
                 HandleGFPlayerStopFromPaused(*context, aResponse);
                 break;
@@ -781,15 +792,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleErrorEvent() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = (PVMFStatus)(aEvent.GetEventType());
             if (iAPICmdErrMsg)
@@ -1352,9 +1356,7 @@
     OSCL_UNUSED_ARG(aRetKVP);
     OSCL_UNUSED_ARG(aContext);
 
-    OsclError::Leave(OsclErrNotSupported);
-
-    return NULL;
+    return PVMFErrNotSupported;
 }
 
 uint32 PVFrameAndMetadataUtility::getCapabilityMetric(PvmiMIOSession aSession)
@@ -1470,6 +1472,8 @@
             if (iUtilityContext.iCmdType != -1)
             {
                 // Player command needs to be cancelled
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtility::CancelAllCommands Called Tick=%d", OsclTickCount::TickCount()));
                 int32 leavecode = 0;
                 OSCL_TRY(leavecode, iPlayer->CancelAllCommands((const OsclAny*) &iCancelContext));
                 OSCL_FIRST_CATCH_ANY(leavecode,
@@ -1549,6 +1553,8 @@
     iUtilityContext.iCmdType = PVFM_CMD_PlayerQueryUUID;
     int32 leavecode = 0;
     OSCL_ASSERT(iPlayer != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::QueryUUID Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->QueryUUID(aMIMEType, aUUIDVec, aExactMatch, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoPlayerQueryUUID() QueryUUID() on player did a leave!"));
@@ -1594,12 +1600,16 @@
         PvmiCapabilityAndConfig* capconfigiface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
         iface = OSCL_STATIC_CAST(PVInterface*, capconfigiface);
 
-        UtilityCommandCompleted(cmdid, context, PVMFSuccess);
+        // Call QueryInterface() on the player too in case of usage using setParametersSync()
+        PVMFStatus cmdstatus = DoPlayerQueryInterface(cmdid, context, iPlayerQueryIFUUID, iPlayerCapConfigIFPVI);
+
+        if (PVMFSuccess != cmdstatus)
+            status = false;
     }
     else
     {
         // Call QueryInterface() on the player
-        PVMFStatus cmdstatus = DoPlayerQueryInterface(cmdid, context, iPlayerQueryIFUUID, iface);
+        PVMFStatus cmdstatus = DoPlayerQueryInterface(cmdid, context, iPlayerQueryIFUUID, (PVInterface*&)iface);
         if (PVMFSuccess != cmdstatus)
             status = false;
     }
@@ -1614,8 +1624,15 @@
     iUtilityContext.iCmdId = aCmdId;
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_PlayerQueryInterface;
+
+    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        iUtilityContext.iCmdType = PVFM_CMD_PlayerQueryCapConfigInterface;
+    }
     int32 leavecode = 0;
     OSCL_ASSERT(iPlayer != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::QueryInterface Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->QueryInterface(aUuid, aInterfacePtr, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoPlayerQueryInterface() QueryInterface() on player did a leave!"));
@@ -1672,6 +1689,7 @@
     // Initiate the player setup sequence
     PVMFStatus cmdstatus = DoADSPlayerAddDataSource(aCmd.GetCmdId(), aCmd.GetContext());
 
+
     if (cmdstatus == PVMFSuccess)
     {
         SetUtilityState(PVFM_UTILITY_STATE_INITIALIZING);
@@ -1690,6 +1708,10 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerAddDataSource;
     int32 leavecode = 0;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerADS called Tick=%d", OsclTickCount::TickCount()));
+
     OSCL_TRY(leavecode, iPlayer->AddDataSource(*iDataSource, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerAddDataSource() AddDataSource() on player did a leave!"));
@@ -1708,6 +1730,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerInit;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerInit() called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Init((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerInit() Init() on player did a leave!"));
@@ -1730,13 +1754,17 @@
                          return PVMFErrNoMemory;
                         );
     iVideoDataSink.SetDataSinkNode(iVideoNode);
-    iVideoDataSink.SetDataSinkFormatType(PVMF_YUV420);
+    iVideoDataSink.SetDataSinkFormatType(PVMF_MIME_YUV420);
+    iVideoMIO->setThumbnailDimensions(iThumbnailWidth, iThumbnailHeight);
 
     iUtilityContext.iCmdId = aCmdId;
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerAddVideoDataSink;
 
     leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerAddVideoSink Called Tick=%d", OsclTickCount::TickCount()));
+
     OSCL_TRY(leavecode, iPlayer->AddDataSink(iVideoDataSink, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerAddVideoDataSink() AddDataSink() on player did a leave!"));
@@ -1758,13 +1786,15 @@
                          return PVMFErrNoMemory;
                         );
     iAudioDataSink.SetDataSinkNode(iAudioNode);
-    iAudioDataSink.SetDataSinkFormatType(PVMF_PCM16);
+    iAudioDataSink.SetDataSinkFormatType(PVMF_MIME_PCM16);
 
     iUtilityContext.iCmdId = aCmdId;
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerAddAudioDataSink;
 
     leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerAddAudioSink Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->AddDataSink(iAudioDataSink, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerAddAudioDataSink() AddDataSink() on player did a leave!"));
@@ -1782,6 +1812,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerPrepare;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerPrepare Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Prepare((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerPrepare() Prepare() on player did a leave!"));
@@ -1800,6 +1832,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerStart;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerStart Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Start((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerStart() Start() on player did a leave!"));
@@ -1818,6 +1852,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_ADSPlayerPause;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerPause Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Pause((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoADSPlayerPause() Pause() on player did a leave!"));
@@ -1873,6 +1909,8 @@
     iUtilityContext.iCmdType = PVFM_CMD_PlayerGetMetadataKeys;
     int32 leavecode = 0;
     OSCL_ASSERT(iPlayer != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerGetMetaDataKeys Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->GetMetadataKeys(aKeyList, aStartingIndex, aMaxEntries, aQueryKey, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoPlayerGetMetadataKeys() GetMetadataKeys() on player did a leave!"));
@@ -1930,6 +1968,8 @@
     iUtilityContext.iCmdType = PVFM_CMD_PlayerGetMetadataValues;
     int32 leavecode = 0;
     OSCL_ASSERT(iPlayer != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerGetMetaDataValues Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->GetMetadataValues(aKeyList, aStartingValueIndex, aMaxValueEntries, aNumAvailableValueEntries, aValueList, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoPlayerGetMetadataValues() GetMetadataValues() on player did a leave!"));
@@ -2001,9 +2041,11 @@
         }
         else
         {
-            //Return un-supported for now. May pass to the engine in future.
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::DoCapConfigSetParameters() Out - Unsupported parameter"));
-            return PVMFErrNotSupported;
+            PVMFStatus cmdstatus = DoPlayerSetParametersSync(aCmd.GetCmdId(), aCmd.GetContext(), paramkvp, numparam, *retkvp);
+            if (PVMFSuccess != cmdstatus)
+            {
+                return cmdstatus;
+            }
         }
     }
 
@@ -2017,8 +2059,30 @@
     return PVMFSuccess;
 }
 
+PVMFStatus PVFrameAndMetadataUtility::DoPlayerSetParametersSync(PVCommandId aCmdId, OsclAny* aCmdContext, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::DoPlayerSetParameterSync() In"));
+
+    iUtilityContext.iCmdId = aCmdId;
+    iUtilityContext.iCmdContext = aCmdContext;
+    iUtilityContext.iCmdType = PVFM_CMD_PlayerSetParametersSync;
+    int32 leavecode = 0;
+    OSCL_ASSERT(iPlayerCapConfigIF != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::Player setParametersSync Called Tick=%d", OsclTickCount::TickCount()));
+    OSCL_TRY(leavecode, iPlayerCapConfigIF->setParametersSync(NULL, aParameters, aNumElements, aRetKVP));
+    OSCL_FIRST_CATCH_ANY(leavecode,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoPlayerQueryInterface() QueryInterface() on player did a leave!"));
+                         return PVMFFailure;);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::DoPlayerSetParameterSync() Out"));
+    return PVMFSuccess;
+}
+
+
 PVMFStatus PVFrameAndMetadataUtility::DoVerifyAndSetFMUParameter(PvmiKvp& aParameter, bool aSetParam)
 {
+    OSCL_UNUSED_ARG(aSetParam);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::DoVerifyAndSetFMUParameter() In"));
 
     PVMFStatus status = PVMFErrNotSupported;
@@ -2029,7 +2093,7 @@
     // Check if it is key string "timeout"
     if (pv_mime_strcmp(compstr, _STRLIT_CHAR("timeout")) >= 0)
     {
-        if (oscl_strcmp(aParameter.key, PVFMUTIL_FRAMERETRIEVAL_TIMEOUT_KEY) == 0)
+        if (oscl_strncmp(aParameter.key, PVFMUTIL_FRAMERETRIEVAL_TIMEOUT_KEY, oscl_strlen(PVFMUTIL_FRAMERETRIEVAL_TIMEOUT_KEY)) == 0)
         {
             iFrameReadyWaitTime = aParameter.value.uint32_value;
             status = PVMFSuccess;
@@ -2192,6 +2256,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_GFPlayerStopFromPaused;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerStop Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Stop((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoGFPlayerStopFromPaused() Stop() on player did a leave!"));
@@ -2242,6 +2308,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_GFPlayerPrepare;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerPrepare Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Prepare((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoGFPlayerPrepare() Prepare() on player did a leave!"));
@@ -2260,6 +2328,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_GFPlayerStart;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerStart Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Start((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoGFPlayerStart() Start() on player did a leave!"));
@@ -2278,8 +2348,8 @@
     PVMFStatus retval = iPlayer->GetPVPlayerStateSync(playerstate);
     if (retval == PVMFSuccess && playerstate == PVP_STATE_PAUSED)
     {
-        // Player is already in paused state (likely due to EOS)
-        // No need to pause playback
+        // Player is already in paused state (due to EOS?)
+        // so need to pause playback
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::DoGFPlayerPause() Playback already paused"));
         return PVMFErrInvalidState;
     }
@@ -2288,6 +2358,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_GFPlayerPause;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::PlayerPause Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Pause((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoGFPlayerPause() Pause() on player did a leave!"));
@@ -2420,6 +2492,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_RDSPlayerStopFromPaused;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::RDSPlayerStop Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Stop((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoRDSPlayerStop Stop() on player did a leave!"));
@@ -2438,6 +2512,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_RDSPlayerRemoveVideoDataSink;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::RDSPlayerRemoveVideoSink Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->RemoveDataSink(iVideoDataSink, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoRDSPlayerRemoveVideoDataSink() RemoveDataSink() on player did a leave!"));
@@ -2455,6 +2531,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_RDSPlayerRemoveAudioDataSink;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::RDSPlayerRemoveAudioSink Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->RemoveDataSink(iAudioDataSink, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoRDSPlayerRemoveAudioDataSink() RemoveDataSink() on player did a leave!"));
@@ -2472,6 +2550,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_RDSPlayerReset;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::RDSPlayerReset Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->Reset((const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoRDSPlayerReset() Reset() on player did a leave!"));
@@ -2490,6 +2570,8 @@
     iUtilityContext.iCmdContext = aCmdContext;
     iUtilityContext.iCmdType = PVFM_CMD_RDSPlayerRemoveDataSource;
     int32 leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::RDSPlayerRemoveDataSource Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer->RemoveDataSource(*iDataSource, (const OsclAny*)&iUtilityContext));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoRDSPlayerRemoveDataSource() RemoveDataSource() on player did a leave!"));
@@ -2516,6 +2598,8 @@
 
     // Recreate the player instance
     leavecode = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVFrameAndMetadataUtility::CreatePlayer Called Tick=%d", OsclTickCount::TickCount()));
     OSCL_TRY(leavecode, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::DoPlayerShutdownRestart() Player engine could not be instantiated! Asserting"));
@@ -2537,6 +2621,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerQueryUUID completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Report QueryUUID() command as succesfully complete
             UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, PVMFSuccess);
             break;
@@ -2548,15 +2634,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandlePlayerQueryUUID() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, aCmdResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
             if (errmsg)
@@ -2575,11 +2654,13 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::HandlePlayerQueryInterface() In"));
 
-    aUtilContext.iCmdType = -1;
-
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerQueryInterface completed successfully Tick=%d", OsclTickCount::TickCount()));
+            if (aUtilContext.iCmdType == PVFM_CMD_PlayerQueryCapConfigInterface)
+                iPlayerCapConfigIF = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, iPlayerCapConfigIFPVI);
             // Report QueryInterface() command as succesfully complete
             UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, PVMFSuccess);
             break;
@@ -2591,15 +2672,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandlePlayerQueryInterface() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, aCmdResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
             if (errmsg)
@@ -2625,6 +2699,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerADS completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call Init() on player
             cmdstatus = DoADSPlayerInit(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -2650,15 +2726,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
-            PVMFErrorInfoMessageInterface* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerAddDataSource() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            PVMFBasicErrorInfoMessage* errmsg = NULL;
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -2704,6 +2773,8 @@
     {
         case PVMFSuccess:
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerInit completed successfully Tick=%d", OsclTickCount::TickCount()));
             if (iMode == PV_FRAME_METADATA_INTERFACE_MODE_SOURCE_METADATA_ONLY)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVFrameAndMetadataUtility::HandleADSPlayerInit - ADS Complete"));
@@ -2743,15 +2814,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerInit() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -2794,6 +2858,8 @@
     {
         case PVMFSuccess:
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerAddVideoDataSink completed successfully Tick=%d", OsclTickCount::TickCount()));
             if (iMode == PV_FRAME_METADATA_INTERFACE_MODE_SOURCE_METADATA_AND_THUMBNAIL)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVFrameAndMetadataUtility::HandleADSPlayerAddVideoDataSink - ADS Complete"));
@@ -2834,14 +2900,8 @@
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
 
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerAddVideoDataSink() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -2884,6 +2944,8 @@
     {
         case PVMFSuccess:
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerAddAudioDataSink completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call Prepare() on player
             PVMFStatus cmdstatus = DoADSPlayerPrepare(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -2911,14 +2973,8 @@
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
 
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerAddAudioDataSink() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -2963,6 +3019,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerPrepare completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call Start() on player
             cmdstatus = DoADSPlayerStart(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -3001,15 +3059,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerPrepare() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3054,6 +3105,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerStart completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call Pause() on player
             cmdstatus = DoADSPlayerPause(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -3079,15 +3132,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerStart() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3130,6 +3176,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerPause completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Utility's AddDataSource() successfully completed
             SetUtilityState(PVFM_UTILITY_STATE_INITIALIZED);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
@@ -3145,15 +3193,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleADSPlayerPause() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3196,6 +3237,9 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerGetMetadataKeys completed successfully Tick=%d", OsclTickCount::TickCount()));
+
             // Report GetMetadataKeys() command as succesfully complete
             UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, PVMFSuccess);
             break;
@@ -3207,15 +3251,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandlePlayerGetMetadataKeys() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             // Check if player is handling the error
             PVPlayerState playerstate;
@@ -3259,6 +3296,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerGetMetadataValues completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Report GetMetadataValues() command as succesfully complete
             UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, PVMFSuccess);
             break;
@@ -3270,15 +3309,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandlePlayerGetMetadataKeys() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             // Check if player is handling the error
             PVPlayerState playerstate;
@@ -3312,6 +3344,62 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::HandlePlayerGetMetadataValues() Out"));
 }
 
+void PVFrameAndMetadataUtility::HandlePlayerSetParametersSync(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::HandlePlayerSetParametersSync() In"));
+
+    aUtilContext.iCmdType = -1;
+
+    switch (aCmdResp.GetCmdStatus())
+    {
+        case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::PlayerSetParametersSync completed successfully Tick=%d", OsclTickCount::TickCount()));
+            // Report SetParametersSync() command as succesfully complete
+            UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, PVMFSuccess);
+            break;
+
+        default:
+        {
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aCmdResp.GetEventExtensionInterface())
+            {
+                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
+            }
+            PVMFBasicErrorInfoMessage* errmsg = NULL;
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
+
+            // Check if player is handling the error
+            PVPlayerState playerstate;
+            PVMFStatus pretval = iPlayer->GetPVPlayerStateSync(playerstate);
+            if (pretval == PVMFSuccess && playerstate == PVP_STATE_ERROR)
+            {
+                // Yes so wait for error handling to complete
+                iAPICmdStatus = aCmdResp.GetCmdStatus();
+                if (iAPICmdErrMsg)
+                {
+                    iAPICmdErrMsg->removeRef();
+                    iAPICmdErrMsg = NULL;
+                }
+                iAPICmdErrMsg = errmsg;
+                // Start a timer just in case the player does not report error handling complete
+                iTimeoutTimer->Request(PVFMUTIL_TIMERID_PLAYERERRORTIMEOUT, 0, iErrorHandlingWaitTime, this, false);
+            }
+            else
+            {
+                // Report the command as failed
+                UtilityCommandCompleted(aUtilContext.iCmdId, aUtilContext.iCmdContext, aCmdResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
+                if (errmsg)
+                {
+                    errmsg->removeRef();
+                }
+            }
+        }
+        break;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::HandlePlayerSetParametersSync() Out"));
+}
 
 void PVFrameAndMetadataUtility::HandleGFPlayerStopFromPaused(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp)
 {
@@ -3323,6 +3411,8 @@
     {
         case PVMFSuccess:
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::GFPlayerStopFromPaused completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call DoPrepare() on player
             PVMFStatus cmdstatus = DoGFPlayerPrepare(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -3364,21 +3454,13 @@
                 iVideoFrameBufferMemPool->deallocate(iCurrentVideoFrameBuffer);
                 iCurrentVideoFrameBuffer = NULL;
             }
-
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aCmdResp.GetEventExtensionInterface())
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleGFPlayerStopFromPaused() Instantiation of error msg did a leave"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3436,6 +3518,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::GFPlayerPrepare completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call Start() on player
             iPlayerStartCompleted = false;
             cmdstatus = DoGFPlayerStart(aUtilContext.iCmdId, aUtilContext.iCmdContext);
@@ -3474,26 +3558,19 @@
                 iVideoFrameBufferMemPool->deallocate(iCurrentVideoFrameBuffer);
                 iCurrentVideoFrameBuffer = NULL;
             }
+            PVFMErrorEventType errCode = PVFMErrPlayerEngine;
+            if (aCmdResp.GetCmdStatus() == PVMFErrResourceConfiguration)
+            {
+                errCode = PVFMErrNoVideoTrack;
+            }
 
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aCmdResp.GetEventExtensionInterface())
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            int32 specificerrcode = PVFMErrPlayerEngine;
-            if (aCmdResp.GetCmdStatus() == PVMFErrResourceConfiguration)
-            {
-                specificerrcode = PVFMErrNoVideoTrack;
-            }
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (specificerrcode, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleGFPlayerPrepare() Instantiation of error msg did a leave"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg, errCode);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3549,6 +3626,8 @@
     switch (cmdstatus)
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::GFPlayerStart completed successfully Tick=%d", OsclTickCount::TickCount()));
             iPlayerStartCompleted = true;
 
             if (iFrameReceived)
@@ -3625,15 +3704,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleGFPlayerStart() Instantiation of error msg did a leave"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3676,6 +3748,9 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::GFPlayerPause completed successfully Tick=%d", OsclTickCount::TickCount()));
             // GetFrame() command completed
             if (iAPICmdStatus != PVMFSuccess)
             {
@@ -3715,14 +3790,8 @@
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
 
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleGFPlayerPause() Instantiation of error msg did a leave"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             // Check if player is handling the error
             PVPlayerState playerstate;
@@ -3800,6 +3869,8 @@
     {
         case PVMFSuccess:
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::RDSPlayerStopFromPaused completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call RemoveDataSink() on player
             PVMFStatus cmdstatus = DoRDSPlayerRemoveVideoDataSink(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -3826,15 +3897,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleRDSPlayerStopFromPaused() Instantiation of error msg did a leave"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -3891,6 +3955,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::RDSPlayerRemoveVideoDataSink completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Cleanup the data sink
             iVideoDataSink.SetDataSinkNode(NULL);
             if (iVideoNode)
@@ -3944,21 +4010,13 @@
                 OSCL_DELETE(iVideoMIO);
                 iVideoMIO = NULL;
             }
-
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aCmdResp.GetEventExtensionInterface())
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleRDSPlayerRemoveVideoDataSink() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -4021,6 +4079,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::RDSPlayerRemoveAudioDataSink completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Cleanup the data sink
             iAudioDataSink.SetDataSinkNode(NULL);
             if (iAudioNode)
@@ -4066,21 +4126,13 @@
                 OSCL_DELETE(iAudioMIO);
                 iAudioMIO = NULL;
             }
-
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aCmdResp.GetEventExtensionInterface())
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleRDSPlayerRemoveAudioDataSink() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -4144,6 +4196,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::RDSPlayerReset completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Call RemoveDataSource() on player
             cmdstatus = DoRDSPlayerRemoveDataSource(aUtilContext.iCmdId, aUtilContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -4170,15 +4224,8 @@
             {
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
-
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleRDSPlayerReset() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -4240,6 +4287,8 @@
     switch (aCmdResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtility::RDSPlayerRemoveDataSource completed successfully Tick=%d", OsclTickCount::TickCount()));
             // Utility's RemoveDataSource() successfully completed
             SetUtilityState(PVFM_UTILITY_STATE_IDLE);
             iDataSource = NULL;
@@ -4263,14 +4312,8 @@
                 nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
             }
 
-            PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
             PVMFBasicErrorInfoMessage* errmsg = NULL;
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVFMErrPlayerEngine, puuid, nextmsg)));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::HandleRDSPlayerRemoveDataSource() Instantiation of error msg did a leave!"));
-                                 errmsg = NULL;
-                                );
+            errmsg = CreateBasicErrInfoMessage(nextmsg);
 
             iAPICmdStatus = aCmdResp.GetCmdStatus();
             if (iAPICmdErrMsg)
@@ -4303,12 +4346,24 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVFrameAndMetadataUtility::HandleRDSPlayerRemoveDataSource() Out"));
 }
 
+void PVFrameAndMetadataUtility::SetThumbnailDimensions(uint32 aWidth, uint32 aHeight)
+{
+    iThumbnailWidth =  aWidth;
+    iThumbnailHeight = aHeight;
+}
+
+void PVFrameAndMetadataUtility::GetThumbnailDimensions(uint32 &aWidth, uint32 &aHeight)
+{
+    aWidth = iThumbnailWidth;
+    aHeight = iThumbnailHeight;
+}
 
 PVMFErrorInfoMessageInterface* PVFrameAndMetadataUtility::GetErrorInfoMessageInterface(PVInterface& aInterface)
 {
-    PVMFErrorInfoMessageInterface* extiface = NULL;
-    if (aInterface.queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)extiface))
+    PVInterface* temp = NULL;
+    if (aInterface.queryInterface(PVMFErrorInfoMessageInterfaceUUID, temp))
     {
+        PVMFErrorInfoMessageInterface* extiface = OSCL_STATIC_CAST(PVMFErrorInfoMessageInterface*, temp);
         return extiface;
     }
     else
@@ -4317,5 +4372,14 @@
     }
 }
 
-
-
+PVMFBasicErrorInfoMessage* PVFrameAndMetadataUtility::CreateBasicErrInfoMessage(PVMFErrorInfoMessageInterface* nextmsg, PVFMErrorEventType aErrEvent)
+{
+    PVUuid puuid = PVFrameAndMetadataErrorInfoEventTypesUUID;
+    PVMFBasicErrorInfoMessage* errmsg = NULL;
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aErrEvent, puuid, nextmsg)));
+    OSCL_FIRST_CATCH_ANY(leavecode,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVFrameAndMetadataUtility::CreateBasicErrInfoMessage() Instantiation of error msg did a leave!"));
+                         errmsg = NULL;);
+    return errmsg;
+}
diff --git a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.h b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.h
index f771fcf..15338a0 100644
--- a/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.h
+++ b/engines/adapters/player/framemetadatautility/src/pv_frame_metadata_utility.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -429,6 +429,8 @@
         PVCommandId RemoveDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL);
         PVMFStatus  SetMode(uint32 aMode);
 
+        void		SetThumbnailDimensions(uint32 aWidth, uint32 aHeight);
+        void		GetThumbnailDimensions(uint32 &aWidth, uint32 &aHeight);
         // From PvmiCapabilityAndConfig
         void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
         PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
@@ -442,6 +444,8 @@
         PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
 
     private:
+        PVMFBasicErrorInfoMessage* CreateBasicErrInfoMessage(PVMFErrorInfoMessageInterface* nextmsg, PVFMErrorEventType aErrEvent = PVFMErrPlayerEngine);
+
         PVFrameAndMetadataUtility();
         void Construct(char *aOutputFormatMIMEType,
                        PVCommandStatusObserver *aCmdObserver,
@@ -530,6 +534,7 @@
                                              int32& aNumAvailableValueEntries, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList);
         PVMFStatus DoCapConfigSetParameters(PVFMUtilityCommand& aCmd, bool aSyncCmd);
         PVMFStatus DoVerifyAndSetFMUParameter(PvmiKvp& aParameter, bool aSetParam);
+        PVMFStatus DoPlayerSetParametersSync(PVCommandId aCmdId, OsclAny* aCmdContext, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
         bool HasVideo();
         PVMFStatus DoGetFrame(PVFMUtilityCommand& aCmd);
         PVMFStatus DoGFPlayerStopFromPaused(PVCommandId aCmdId, OsclAny* aCmdContext);
@@ -562,6 +567,7 @@
             PVFM_CMD_ADSPlayerPause,
             PVFM_CMD_PlayerGetMetadataKeys,
             PVFM_CMD_PlayerGetMetadataValues,
+            PVFM_CMD_PlayerSetParametersSync,
             PVFM_CMD_GFPlayerStopFromPaused,
             PVFM_CMD_GFPlayerPrepare,
             PVFM_CMD_GFPlayerStart,
@@ -570,7 +576,8 @@
             PVFM_CMD_RDSPlayerRemoveVideoDataSink,
             PVFM_CMD_RDSPlayerRemoveAudioDataSink,
             PVFM_CMD_RDSPlayerReset,
-            PVFM_CMD_RDSPlayerRemoveDataSource
+            PVFM_CMD_RDSPlayerRemoveDataSource,
+            PVFM_CMD_PlayerQueryCapConfigInterface
         };
 
         // Player command completion handling
@@ -585,6 +592,7 @@
         void HandleADSPlayerPause(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
         void HandlePlayerGetMetadataKeys(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
         void HandlePlayerGetMetadataValues(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
+        void HandlePlayerSetParametersSync(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
         void HandleGFPlayerStopFromPaused(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
         void HandleGFPlayerPrepare(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
         void HandleGFPlayerStart(PVFMUtilityContext& aUtilContext, const PVCmdResponse& aCmdResp);
@@ -601,8 +609,10 @@
         // Player engine instance handle
         PVPlayerInterface* iPlayer;
 
-        // Output MIME string
-        OSCL_HeapString<OsclMemAllocator> iOutputMIMEType;
+        PvmiCapabilityAndConfig* iPlayerCapConfigIF;
+        PVInterface* iPlayerCapConfigIFPVI;
+
+        // Output Format Type
         PVMFFormatType iOutputFormatType;
 
         // User specified player data source handle
@@ -653,6 +663,9 @@
         OsclTimer<OsclMemAllocator>* iTimeoutTimer;
         uint32 iErrorHandlingWaitTime;
         uint32 iFrameReadyWaitTime;
+
+        uint32 iThumbnailWidth;
+        uint32 iThumbnailHeight;
 };
 
 #endif // PV_FRAME_METADATA_UTILITY_H_INCLUDED
diff --git a/engines/adapters/player/framemetadatautility/test/Android.mk b/engines/adapters/player/framemetadatautility/test/Android.mk
deleted file mode 100644
index 878c300..0000000
--- a/engines/adapters/player/framemetadatautility/test/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/test_pv_frame_metadata_utility.cpp \
-	src/test_pv_frame_metadata_utility_testset1.cpp
-
-
-LOCAL_STATIC_LIBRARIES := libunit_test
-
-LOCAL_SHARED_LIBRARIES := libc libopencorecommon libopencoreplayer
-
-
-LOCAL_MODULE := pv_fmu_test
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/test/src \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/test/src \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/test/include \
-	$(PV_TOP)//engines/adapters/player/framemetadatautility/test/config/common \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-include $(BUILD_EXECUTABLE)
-
diff --git a/engines/adapters/player/framemetadatautility/test/build/make/makefile b/engines/adapters/player/framemetadatautility/test/build/make/makefile
deleted file mode 100644
index a10c045..0000000
--- a/engines/adapters/player/framemetadatautility/test/build/make/makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = prog
-TARGET = pv_fmu_test
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS +=
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-
-# include the common engine header files in the search path
-XINCDIRS += -I ../../include -I ../../config/common
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-#XLDFLAGS +=
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	test_pv_frame_metadata_utility.cpp \
-        test_pv_frame_metadata_utility_testset1.cpp
-
-LIBS = -lunit_test_mod
-XLDFLAGS += -lpvcommon -lpvplayer
-
-SYSLIBS = -lpthread
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/engines/adapters/player/framemetadatautility/test/config/common/test_pv_frame_metadata_utility_config.h b/engines/adapters/player/framemetadatautility/test/config/common/test_pv_frame_metadata_utility_config.h
index ab68fa1..eedf86e 100644
--- a/engines/adapters/player/framemetadatautility/test/config/common/test_pv_frame_metadata_utility_config.h
+++ b/engines/adapters/player/framemetadatautility/test/config/common/test_pv_frame_metadata_utility_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,16 +30,16 @@
 #define RUN_YUV420_TESTCASES 1
 
 // Set to 1 to enable test cases that output RGB 12bpp, 0 to disable
-#define RUN_RGB12_TESTCASES 1
+#define RUN_RGB12_TESTCASES 0
 
 // Set to 1 to enable test cases that output RGB 16bpp, 0 to disable
 #define RUN_RGB16_TESTCASES 1
 
 // Set to 1 to enable test cases that output RGB 24bpp, 0 to disable
-#define RUN_RGB24_TESTCASES 1
+#define RUN_RGB24_TESTCASES 0
 
 // Set to 1 to enable test cases that uses Janus CPM, 0 to disable
-#define RUN_JANUSCPM_TESTCASES 0
+#define RUN_JANUSCPM_TESTCASES 1
 
 // The source test file without video track
 //#define NOVIDEOSOURCEFILENAME "test_amr.mp4"
diff --git a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.cpp b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.cpp
index 35028d3..2fe3939 100644
--- a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.cpp
+++ b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,15 +26,15 @@
 #include "oscl_mem.h"
 #include "oscl_mem_audit.h"
 #include "oscl_error.h"
-#include "oscl_error_panic.h"
 #include "oscl_scheduler.h"
 #include "pvlogger.h"
 #include "pvlogger_file_appender.h"
+#include "pvlogger_mem_appender.h"
 #include "unit_test_args.h"
 #include "oscl_utf8conv.h"
+#include "oscl_string_utils.h"
 
 #include "omx_core.h"
-#include "pv_omxmastercore.h"
 
 #ifndef DEFAULTSOURCEFILENAME
 #error // The default source file needs to be defined in config file
@@ -46,6 +46,225 @@
 
 FILE* file;
 
+#define MAX_LEN 100
+
+class PVLoggerConfigFile
+{
+        /*  To change the logging settings without the need to compile the test application
+        	Let us read the logging settings from the file instead of hard coding them over here
+        	The name of the config file is pvlogger.ini
+        	The format of entries in it is like
+        	First entry will decide if the file appender has to be used or error appender will be used.
+        	0 -> ErrAppender will be used
+        	1 -> File Appender will be used
+        	2 -> Mem Appender will be used
+        	Entries after this will decide the module whose logging has to be taken.For example, contents of one sample config file could be
+        	1
+        	1,PVPlayerEngine
+        	8,PVSocketNode
+        	(pls note that no space is allowed between loglevel and logger tag)
+        	This means, we intend to have logging of level 1 for the module PVPlayerEngine
+        	and of level 8 for the PVSocketNode on file.
+        */
+    public:
+
+        PVLoggerConfigFile(): iLogFileRead(false)
+        {
+            iFileServer.Connect();
+            // Full path of pvlogger.ini is: SOURCENAME_PREPEND_STRING + pvlogger.ini
+            oscl_strncpy(iLogFileName, SOURCENAME_PREPEND_STRING,
+                         oscl_strlen(SOURCENAME_PREPEND_STRING) + 1);
+            oscl_strcat(iLogFileName, "pvlogger.ini");
+            oscl_memset(ibuffer, 0, sizeof(ibuffer));
+            iAppenderType = 0;
+
+        }
+
+        ~PVLoggerConfigFile()
+        {
+            iFileServer.Close();
+        }
+
+        bool get_next_line(const char *start_ptr, const char * end_ptr,
+                           const char *& line_start,
+                           const char *& line_end)
+        {
+            // Finds the boundaries of the next non-empty line within start
+            // and end ptrs
+
+            // This initializes line_start to the first non-whitespace character
+            line_start = skip_whitespace_and_line_term(start_ptr, end_ptr);
+
+            line_end = skip_to_line_term(line_start, end_ptr);
+
+            return (line_start < end_ptr);
+
+        }
+
+
+        bool IsLoggerConfigFilePresent()
+        {
+            if (-1 != ReadAndParseLoggerConfigFile())
+                return true;
+            return false;
+        }
+
+        //Read and parse the config file
+        //retval = -1 if the config file doesnt exist
+        int8 ReadAndParseLoggerConfigFile()
+        {
+            int8 retval = 1;
+
+            if (0 != iLogFile.Open(iLogFileName, Oscl_File::MODE_READ, iFileServer))
+            {
+                retval = -1;
+            }
+            else
+            {
+                if (!iLogFileRead)
+                {
+                    int32 nCharRead = iLogFile.Read(ibuffer, 1, sizeof(ibuffer));
+                    //Parse the buffer for \n chars
+                    Oscl_Vector<char*, OsclMemAllocator> LogConfigStrings;
+
+                    const char *end_ptr = ibuffer + oscl_strlen(ibuffer) ; // Point just beyond the end
+                    const char *section_start_ptr;
+                    const char *line_start_ptr, *line_end_ptr;
+                    char* end_temp_ptr;
+                    int16 offset = 0;
+
+                    section_start_ptr = skip_whitespace_and_line_term(ibuffer, end_ptr);
+
+                    while (section_start_ptr < end_ptr)
+                    {
+                        if (!get_next_line(section_start_ptr, end_ptr,
+                                           line_start_ptr, line_end_ptr))
+                        {
+                            break;
+                        }
+
+
+                        section_start_ptr = line_end_ptr + 1;
+
+                        end_temp_ptr = (char*)line_end_ptr;
+                        *end_temp_ptr = '\0';
+
+                        LogConfigStrings.push_back((char*)line_start_ptr);
+
+                    }
+
+                    //Populate the  LoggerConfigElements vector
+                    {
+                        if (!LogConfigStrings.empty())
+                        {
+                            Oscl_Vector<char*, OsclMemAllocator>::iterator it;
+                            it = LogConfigStrings.begin();
+                            uint32 appenderType;
+                            PV_atoi(*it, 'd', oscl_strlen(*it), appenderType);
+                            iAppenderType = appenderType;
+                            if (LogConfigStrings.size() > 1)
+                            {
+                                for (it = LogConfigStrings.begin() + 1; it != LogConfigStrings.end(); it++)
+                                {
+                                    char* CommaIndex = (char*)oscl_strstr(*it, ",");
+                                    if (CommaIndex != NULL)
+                                    {
+                                        *CommaIndex = '\0';
+                                        LoggerConfigElement obj;
+                                        uint32 logLevel;
+                                        PV_atoi(*it, 'd', oscl_strlen(*it), logLevel);
+                                        obj.iLogLevel = logLevel;
+                                        obj.iLoggerString = CommaIndex + 1;
+                                        iLoggerConfigElements.push_back(obj);
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                //Add the config element for complete logging fo all the modules
+                                LoggerConfigElement obj;
+                                obj.iLoggerString = "";
+                                obj.iLogLevel = 8;
+                                iLoggerConfigElements.push_back(obj);
+                            }
+                        }
+                    }
+                    iLogFile.Close();
+                    iLogFileRead = true;
+                }
+            }
+            return retval;
+        }
+
+        void SetLoggerSettings()
+        {
+            Oscl_Vector<LoggerConfigElement, OsclMemAllocator>::iterator it;
+
+            PVLoggerAppender *appender = NULL;
+            OsclRefCounter *refCounter = NULL;
+            if (iLoggerConfigElements.empty())
+            {
+                return;
+            }
+
+            if (iAppenderType == 0)
+            {
+                appender = new StdErrAppender<TimeAndIdLayout, 1024>();
+                OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
+                    new OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > >(appender);
+                refCounter = appenderRefCounter;
+            }
+            else if (iAppenderType == 1)
+            {
+                OSCL_wHeapString<OsclMemAllocator> logfilename(OUTPUTNAME_PREPEND_WSTRING);
+                logfilename += _STRLIT_WCHAR("player.log");
+                appender = (PVLoggerAppender*)TextFileAppender<TimeAndIdLayout, 1024>::CreateAppender(logfilename.get_str());
+                OsclRefCounterSA<LogAppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
+                    new OsclRefCounterSA<LogAppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > >(appender);
+                refCounter = appenderRefCounter;
+            }
+            else
+            {
+                OSCL_wHeapString<OsclMemAllocator> logfilename(OUTPUTNAME_PREPEND_WSTRING);
+                logfilename += _STRLIT_WCHAR("player.log");
+                appender = (PVLoggerAppender*)MemAppender<TimeAndIdLayout, 1024>::CreateAppender(logfilename.get_str());
+                OsclRefCounterSA<LogAppenderDestructDealloc<MemAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
+                    new OsclRefCounterSA<LogAppenderDestructDealloc<MemAppender<TimeAndIdLayout, 1024> > >(appender);
+                refCounter = appenderRefCounter;
+            }
+
+            OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, refCounter);
+
+            for (it = iLoggerConfigElements.begin(); it != iLoggerConfigElements.end(); it++)
+            {
+                PVLogger *node = NULL;
+                node = PVLogger::GetLoggerObject(it->iLoggerString);
+                node->AddAppender(appenderPtr);
+                node->SetLogLevel(it->iLogLevel);
+            }
+        }
+
+    private:
+        class LoggerConfigElement
+        {
+            public:
+                LoggerConfigElement()
+                {
+                    iLoggerString = NULL;
+                    iLogLevel = 8;
+                }
+                char *iLoggerString;
+                int8 iLogLevel;
+        };
+        int8 iAppenderType; //Type of appender to be used for the logging 0-> Err Appender, 1-> File Appender
+        bool iLogFileRead;
+        Oscl_File iLogFile;
+        Oscl_FileServer iFileServer;
+        char iLogFileName[255];
+        char ibuffer[1024];
+        Oscl_Vector<LoggerConfigElement, OsclMemAllocator> iLoggerConfigElements;
+};
+
 
 // Pull out source file name from arguments
 //  -source sometestfile.mp4
@@ -521,31 +740,65 @@
     OsclBase::Init();
     OsclErrorTrap::Init();
     OsclMem::Init();
-    PV_MasterOMX_Init();
+    OMX_Init();
+
+    const int numArgs = 10; //change as per the number of args below
+    char *argv[numArgs];
+    char arr[numArgs][MAX_LEN];
+    FILE *InputFile = NULL;
+    int argc = 0;
+
     fprintf(filehandle, "Test Program for pvFrameMetadata utility class.\n");
 
+    InputFile = fopen("input.txt", "r+");
+    if (NULL != InputFile)
+    {
+        int ii = 0;
+        int len = 0;
+        fseek(InputFile , 0 , SEEK_SET);
+        while (!feof(InputFile))
+        {
+            arr[ii][0] = '\0';
+            fgets(arr[ii], 127, InputFile);
+            len = strlen(arr[ii]);
+            if (arr[ii][len-1] == '\n')
+            {
+                arr[ii][len-1] = '\0';
+            }
+            else
+            {
+                arr[ii][len-1] = '\0';
+            }
+            argv[ii] = arr[ii];
+
+            ii++;
+        }
+        fclose(InputFile);
+
+        argc = ii - 1;
+    }
+
+    int n = 0;
+
+    command_line->setup(argc - n, &argv[n]);
+
     bool oPrintDetailedMemLeakInfo = false;
     FindMemMgmtRelatedCmdLineParams(command_line, oPrintDetailedMemLeakInfo, filehandle);
 
     //Run the test under a trap
     int result = 0;
     int32 err = 0;
-    TPVErrorPanic panic;
 
-    OSCL_PANIC_TRAP(err, panic, result = _local_main(filehandle, command_line););
+    OSCL_TRY(err, result = _local_main(filehandle, command_line););
 
     //Show any exception.
     if (err != 0)
     {
         fprintf(file, "Error!  Leave %d\n", err);
     }
-    if (panic.iReason != 0)
-    {
-        fprintf(file, "Error!  Panic %s %d\n", panic.iCategory.Str(), panic.iReason);
-    }
 
     //Cleanup
-
+    OMX_Deinit();
 #if !(OSCL_BYPASS_MEMMGT)
     //Check for memory leaks before cleaning up OsclMem.
     OsclAuditCB auditCB;
@@ -593,7 +846,7 @@
         }
     }
 #endif
-    PV_MasterOMX_Deinit();
+
     OsclMem::Cleanup();
     OsclErrorTrap::Cleanup();
     OsclBase::Cleanup();
@@ -948,6 +1201,10 @@
                 iCurrentTest = new pvframemetadata_async_test_settimeout_getframe(testparam, 2, false);
                 break;
 
+            case SetPlayerKeyTest:
+                iCurrentTest = new pvframemetadata_async_test_set_player_key(testparam);
+                break;
+
             case BeyondLastTest:
             default:
                 iCurrentTestNumber = BeyondLastTest;
@@ -995,56 +1252,11 @@
 {
     // Enable the following code for logging (on Symbian, RDebug)
     PVLogger::Init();
-#if 1
-
-#if 1 // Enable this section to log to debug output
-    PVLoggerAppender *appender = new StdErrAppender<TimeAndIdLayout, 1024>();
-    OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
-        new OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > >(appender);
-#else // Enable this section to log to file
-    PVLoggerAppender *appender = (PVLoggerAppender*)TextFileAppender<TimeAndIdLayout, 1024>::CreateAppender((OSCL_TCHAR*)_STRLIT("framemetadatautil.log"));
-    OsclRefCounterSA<LogAppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
-        new OsclRefCounterSA<LogAppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > >(appender);
-#endif
-
-    OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, appenderRefCounter);
-
+    PVLoggerConfigFile obj;
+    if (obj.IsLoggerConfigFilePresent())
     {
-        PVLogger *node = NULL;
-        //selective logging
-
-        /*
-        node = PVLogger::GetLoggerObject("");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(iLogLevel);
-        */
-
-
-        node = PVLogger::GetLoggerObject("PVFrameAndMetadataUtility");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(iLogLevel);
-
-
-        /*
-        node = PVLogger::GetLoggerObject("PVFMVideoMIO");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(iLogLevel);
-        */
-
-        /*
-        node = PVLogger::GetLoggerObject("PVPlayerEngine");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(iLogLevel);
-        */
-
-        /*
-        node = PVLogger::GetLoggerObject("datapath.sourcenode.mp4parsernode");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(iLogLevel);
-        */
+        obj.SetLoggerSettings();
     }
-#endif //logging
-
     // Construct and install the active scheduler
     OsclScheduler::Init("PVFrameMetadataUtilityTestScheduler");
 }
diff --git a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.h b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.h
index 6677325..18a7f85 100644
--- a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.h
+++ b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -155,15 +155,15 @@
             bool foundlastslash = false;
             while (!foundlastslash)
             {
-                oscl_wchar* tmp1 = oscl_strstr(lastslash, _STRLIT_WCHAR("\\"));
-                oscl_wchar* tmp2 = oscl_strstr(lastslash, _STRLIT_WCHAR("/"));
+                const oscl_wchar* tmp1 = oscl_strstr(lastslash, _STRLIT_WCHAR("\\"));
+                const oscl_wchar* tmp2 = oscl_strstr(lastslash, _STRLIT_WCHAR("/"));
                 if (tmp1 != NULL)
                 {
-                    lastslash = tmp1 + 1;
+                    lastslash = (oscl_wchar*)tmp1 + 1;
                 }
                 else if (tmp2 != NULL)
                 {
-                    lastslash = tmp2 + 1;
+                    lastslash = (oscl_wchar*)tmp2 + 1;
                 }
                 else
                 {
@@ -181,10 +181,10 @@
             bool finishedreplace = false;
             while (!finishedreplace)
             {
-                oscl_wchar* tmp = oscl_strstr(aFilename.get_cstr(), _STRLIT_WCHAR("."));
+                const oscl_wchar* tmp = oscl_strstr(aFilename.get_cstr(), _STRLIT_WCHAR("."));
                 if (tmp != NULL)
                 {
-                    oscl_strncpy(tmp, _STRLIT_WCHAR("_"), 1);
+                    oscl_strncpy((oscl_wchar*)tmp, _STRLIT_WCHAR("_"), 1);
                 }
                 else
                 {
@@ -250,8 +250,9 @@
             ProtectedMetadataTest = NoVideoTrackTest + 1,
 
             SetTimeoutAndGetFrameTest = ProtectedMetadataTest + 1,
+            SetPlayerKeyTest = SetTimeoutAndGetFrameTest + 1,
 
-            LastTest = SetTimeoutAndGetFrameTest + 1,//placeholder
+            LastTest = SetPlayerKeyTest + 1,//placeholder
 
             BeyondLastTest = 999 //placeholder
         };
diff --git a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.cpp b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.cpp
index 964f7b5..eb4a853 100644
--- a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.cpp
+++ b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -83,6 +83,11 @@
 {
     AddToScheduler();
     iState = STATE_CREATE;
+
+    // Retrieve the logger object
+    iLogger = PVLogger::GetLoggerObject("PVFrameAndMetadataUtilityTest");
+    iPerfLogger = PVLogger::GetLoggerObject("fmutestdiagnostics");
+
     RunIfNotReady();
 }
 
@@ -98,6 +103,9 @@
             iFrameMetadataUtil = NULL;
 
             OSCL_TRY(error, iFrameMetadataUtil = PVFrameAndMetadataFactory::CreateFrameAndMetadataUtility(iOutputFrameTypeString.get_str(), this, this, this));
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::Create Called Tick=%d", OsclTickCount::TickCount()));
             if (error)
             {
                 PVFMUATB_TEST_IS_TRUE(false);
@@ -189,6 +197,9 @@
             iDataSource->SetDataSourceURL(wFileName);
             iDataSource->SetDataSourceFormatType(iFileType);
 
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::AddDataSource Issued Tick=%d", OsclTickCount::TickCount()));
+
             OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -199,6 +210,9 @@
         {
             // Retrieve all the available metadata keys
             iMetadataKeyList.clear();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::GetMetadataKeys Issued Tick=%d", OsclTickCount::TickCount()));
+
             OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->GetMetadataKeys(iMetadataKeyList, 0, 50, NULL, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -209,6 +223,9 @@
             // Retrieve the values
             iMetadataValueList.clear();
             iNumValues = 0;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::GetMetadataValues Issued Tick=%d", OsclTickCount::TickCount()));
+
             OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->GetMetadataValues(iMetadataKeyList, 0, 50, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -220,6 +237,10 @@
             iFrameSelector.iSelectionMethod = PVFrameSelector::SPECIFIC_FRAME;
             iFrameSelector.iFrameInfo.iFrameIndex = 0;
             iFrameBufferSize = MAX_VIDEO_FRAME_SIZE;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::GetFrame Issued Tick=%d", OsclTickCount::TickCount()));
+
             OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->GetFrame(iFrameSelector, iFrameBuffer, iFrameBufferSize, iFrameBufferProp, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -227,6 +248,9 @@
 
         case STATE_REMOVEDATASOURCE:
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::RemoveDataSource Issued Tick=%d", OsclTickCount::TickCount()));
+
             OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -243,6 +267,9 @@
             delete iDataSource;
             iDataSource = NULL;
 
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                            (0, "PVFrameAndMetadataUtilityTest::CleanUpAndComplete Called Tick=%d", OsclTickCount::TickCount()));
+
             // Close the output file handles
             iMetadataFile.Close();
             iFrameFile.Close();
@@ -298,6 +325,9 @@
         case STATE_ADDDATASOURCE:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::AddDataSource completed sucessfully Tick=%d", OsclTickCount::TickCount()));
+
                 iState = STATE_GETMETADATAKEYS1;
                 RunIfNotReady();
             }
@@ -305,6 +335,9 @@
             {
                 // AddDataSource failed
                 PVFMUATB_TEST_IS_TRUE(false);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::AddDataSource failed Tick=%d", OsclTickCount::TickCount()));
+
                 iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
             }
@@ -313,12 +346,16 @@
         case STATE_GETMETADATAKEYS1:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::GetMetaDataKeys completed sucessfully Tick=%d", OsclTickCount::TickCount()));
                 iState = STATE_GETMETADATAVALUES1;
                 RunIfNotReady();
             }
             else
             {
                 // GetMetadataKeys failed
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::GetMetadataKeys failed Tick=%d", OsclTickCount::TickCount()));
                 PVFMUATB_TEST_IS_TRUE(false);
                 iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -328,6 +365,8 @@
         case STATE_GETMETADATAVALUES1:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::GetMetaDataValues completed sucessfully Tick=%d", OsclTickCount::TickCount()));
                 oscl_snprintf(iTextOutputBuf, 512, "After AddDataSource():\n");
                 iMetadataFile.Write(iTextOutputBuf, sizeof(char), oscl_strlen(iTextOutputBuf));
                 SaveMetadataInfo();
@@ -344,6 +383,8 @@
             else
             {
                 // GetMetadataValues failed
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::GetMetadataValues failed Tick=%d", OsclTickCount::TickCount()));
                 PVFMUATB_TEST_IS_TRUE(false);
                 iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -353,6 +394,8 @@
         case STATE_GETFRAME:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::GetFrame completed sucessfully Tick=%d", OsclTickCount::TickCount()));
                 SaveVideoFrame();
                 iState = STATE_REMOVEDATASOURCE;
                 RunIfNotReady();
@@ -360,6 +403,8 @@
             else
             {
                 // GetFrame failed
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::GetFrame failed Tick=%d", OsclTickCount::TickCount()));
                 PVFMUATB_TEST_IS_TRUE(false);
                 iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -369,6 +414,8 @@
         case STATE_REMOVEDATASOURCE:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::RemoveDataSource completed sucessfully Tick=%d", OsclTickCount::TickCount()));
                 PVFMUATB_TEST_IS_TRUE(true);
                 iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -376,6 +423,8 @@
             else
             {
                 // RemoveDataSource failed
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iPerfLogger, PVLOGMSG_NOTICE,
+                                (0, "PVFrameAndMetadataUtilityTest::RemoveDataSource failed Tick=%d", OsclTickCount::TickCount()));
                 PVFMUATB_TEST_IS_TRUE(false);
                 iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -4021,6 +4070,13 @@
                 iState = STATE_REMOVEDATASOURCE;
                 RunIfNotReady();
             }
+            else if (aResponse.GetCmdStatus() == PVMFErrMaxReached)
+            {
+                // Test could not be excercised fully since we recvd EOS before timeout error
+                fprintf(iTestMsgOutputFile, "\nTest could not be excercised fully since we recvd EOS before timeout error\n\n");
+                iState = STATE_REMOVEDATASOURCE;
+                RunIfNotReady();
+            }
             else
             {
                 // GetFrame failed
@@ -4083,6 +4139,218 @@
 }
 
 
+//
+// pvframemetadata_async_test_set_player_key section
+//
+void pvframemetadata_async_test_set_player_key::StartTest()
+{
+    AddToScheduler();
+    iState = STATE_CREATE;
+    RunIfNotReady();
+}
+
+
+void pvframemetadata_async_test_set_player_key::Run()
+{
+    int error = 0;
+
+    switch (iState)
+    {
+        case STATE_CREATE:
+        {
+            iFrameMetadataUtil = NULL;
+
+            OSCL_TRY(error, iFrameMetadataUtil = PVFrameAndMetadataFactory::CreateFrameAndMetadataUtility(iOutputFrameTypeString.get_str(), this, this, this));
+            if (error)
+            {
+                PVFMUATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+            }
+            else
+            {
+                uint32 mode = PV_FRAME_METADATA_INTERFACE_MODE_SOURCE_METADATA_ONLY;
+                iFrameMetadataUtil->SetMode(mode);
+
+                iState = STATE_QUERYINTERFACE;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case STATE_QUERYINTERFACE:
+        {
+            PVUuid capconfigifuuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
+            OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->QueryInterface(capconfigifuuid, (PVInterface*&)iFMUCapConfigIF, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASOURCE:
+        {
+            // Create a player data source and add it
+            iDataSource = new PVPlayerDataSourceURL;
+
+            // Convert the source file name to UCS2 and extract the filename part
+            oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTempWCharBuf, 512);
+            wFileName.set(iTempWCharBuf, oscl_strlen(iTempWCharBuf));
+
+            iDataSource->SetDataSourceURL(wFileName);
+            iDataSource->SetDataSourceFormatType(iFileType);
+
+            OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+
+        break;
+
+        case STATE_SETPLAYERKEY:
+        {
+            // Any key understood by the player
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/player/nodecmd_timeout;valtype=uint32");
+            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+            iKVPSetAsync.value.uint32_value = 4421;
+            iErrorKVP = NULL;
+            OSCL_TRY(error, iFMUCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+            OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+
+            iState = STATE_REMOVEDATASOURCE;
+            RunIfNotReady();
+        }
+        break;
+
+        case STATE_REMOVEDATASOURCE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iFrameMetadataUtil->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVFMUATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_CLEANUPANDCOMPLETE:
+        {
+            PVFMUATB_TEST_IS_TRUE(PVFrameAndMetadataFactory::DeleteFrameAndMetadataUtility(iFrameMetadataUtil));
+            iFrameMetadataUtil = NULL;
+
+            delete iDataSource;
+            iDataSource = NULL;
+
+            iObserver->TestCompleted(*iTestCase);
+        }
+        break;
+
+        default:
+            break;
+
+    }
+}
+
+
+void pvframemetadata_async_test_set_player_key::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    if (aResponse.GetCmdId() != iCurrentCmdId)
+    {
+        // Wrong command ID.
+        PVFMUATB_TEST_IS_TRUE(false);
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+        return;
+    }
+
+    if (aResponse.GetContext() != NULL)
+    {
+        if (aResponse.GetContext() == (OsclAny*)&iContextObject)
+        {
+            if (iContextObject != iContextObjectRefValue)
+            {
+                // Context data value was corrupted
+                PVFMUATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+                return;
+            }
+        }
+        else
+        {
+            // Context data pointer was corrupted
+            PVFMUATB_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+            return;
+        }
+    }
+
+    switch (iState)
+    {
+        case STATE_QUERYINTERFACE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASOURCE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // QueryInterface failed
+                PVFMUATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_ADDDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_SETPLAYERKEY;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSource failed
+                PVFMUATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                PVFMUATB_TEST_IS_TRUE(true);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSource failed
+                PVFMUATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        default:
+        {
+            // Testing error if this is reached
+            PVFMUATB_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+    }
+}
+
+
+void pvframemetadata_async_test_set_player_key::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+
+void pvframemetadata_async_test_set_player_key::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+}
+
+
+
 
 
 
diff --git a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.h b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.h
index e4ed7ff..0bbe8ec 100644
--- a/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.h
+++ b/engines/adapters/player/framemetadatautility/test/src/test_pv_frame_metadata_utility_testset1.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -157,6 +157,10 @@
 
         uint32 iMode;
         bool iBestThumbNailMode;
+
+        // Handle to the logger node
+        PVLogger* iLogger;
+        PVLogger* iPerfLogger;
 };
 
 
@@ -940,5 +944,65 @@
         bool iBestThumbNailMode;
 };
 
+
+/*!
+ *  A test case to test the usage of setting a key that will be passed to the player engine
+ *  - Data Source: Passed in parameter
+ *  - Sequence:
+ *             -# CreateFrameAndMetadataUtility()
+ *             -# AddDataSource()
+ *             -# QueryInterface()
+ *             -# SetParametersSync()
+  *             -# RemoveDataSource()
+ *             -# DeleteFrameAndMetadataUtility()
+ *
+ */
+class pvframemetadata_async_test_set_player_key : public pvframemetadata_async_test_base
+{
+    public:
+        pvframemetadata_async_test_set_player_key(PVFrameMetadataAsyncTestParam aTestParam):
+                pvframemetadata_async_test_base(aTestParam)
+                , iFrameMetadataUtil(NULL)
+                , iDataSource(NULL)
+                , iCurrentCmdId(0)
+        {
+            iTestCaseName = _STRLIT_CHAR("Set Player Engine Key");
+        }
+
+        ~pvframemetadata_async_test_set_player_key() {}
+
+        void StartTest();
+        void Run();
+
+        void CommandCompleted(const PVCmdResponse& aResponse);
+        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        enum PVTestState
+        {
+            STATE_CREATE,
+            STATE_ADDDATASOURCE,
+            STATE_QUERYINTERFACE,
+            STATE_SETPLAYERKEY,
+            STATE_REMOVEDATASOURCE,
+            STATE_CLEANUPANDCOMPLETE
+        };
+
+        PVTestState iState;
+
+        PVFrameAndMetadataInterface* iFrameMetadataUtil;
+
+        PvmiCapabilityAndConfig* iFMUCapConfigIF;
+        PvmiKvp* iErrorKVP;
+        PvmiKvp iKVPSetAsync;
+        OSCL_StackString<128> iKeyStringSetAsync;
+
+        PVPlayerDataSourceURL* iDataSource;
+        PVCommandId iCurrentCmdId;
+
+    private:
+        OSCL_wHeapString<OsclMemAllocator> wFileName;
+};
+
 #endif // TEST_PV_FRAME_METADATA_UTILITY_TESTSET1_H_INCLUDED
 
diff --git a/engines/author/Android.mk b/engines/author/Android.mk
old mode 100755
new mode 100644
index 0791a8c..b486d4d
--- a/engines/author/Android.mk
+++ b/engines/author/Android.mk
@@ -3,29 +3,30 @@
 
 LOCAL_SRC_FILES := \
 	src/pvaenodeutility.cpp \
-	src/pvauthorengine.cpp
-
+ 	src/pvauthorengine.cpp
 
 
 LOCAL_MODULE := libpvauthorengine
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/author/include \
-	$(PV_TOP)//engines/author/src \
-	$(PV_TOP)//engines/author/../common/include \
-	$(PV_TOP)//engines/author/src/single_core \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/engines/author/src \
+ 	$(PV_TOP)/engines/author/include \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_TOP)/engines/author/src/single_core \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvauthorenginefactory.h \
-	include/pvauthorengineinterface.h
-
-LOCAL_SHARED_LIBRARIES := libcutils libutils
+ 	include/pvauthorengineinterface.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/engines/author/build/make/local.mk b/engines/author/build/make/local.mk
new file mode 100644
index 0000000..1095665
--- /dev/null
+++ b/engines/author/build/make/local.mk
@@ -0,0 +1,41 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvauthorengine
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+XINCDIRS += ../../../common/include ../../src/single_core
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvaenodeutility.cpp pvauthorengine.cpp
+
+HDRS := pvauthorenginefactory.h pvauthorengineinterface.h
+
+
+include $(MK)/library.mk
+
+doc_target := pvauthor_engine
+doc_title := "PV Author Engine"
+doc_paths := "$(SRC_ROOT)/engines/common/include $(SRC_ROOT)/engines/author/include"
+doc_version := $(PVAUTHOR_ENGINE_VERSION)
+
+include $(MK)/doc.mk
+
+sdkinfo_target := $(LOCAL_SRCDIR)/pvauthorengine.cpp
+sdkinfo_header_filename := $(LOCAL_SRCDIR)/pv_author_sdkinfo.h
+sdkinfo_header_macro := PV_AUTHOR_SDKINFO
+sdkinfo_label_macro := PVAUTHOR_ENGINE_SDKINFO_LABEL
+sdkinfo_date_macro := PVAUTHOR_ENGINE_SDKINFO_DATE
+
+include $(MK)/sdkinfo.mk
diff --git a/engines/author/build/make/makefile b/engines/author/build/make/makefile
deleted file mode 100755
index 2373212..0000000
--- a/engines/author/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvauthorengine
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += -DUSE_PVVIDEODISPLAYNODE 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-XINCDIRS += -I../../../common/include -I../../src/single_core
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvaenodeutility.cpp pvauthorengine.cpp
-
-HDRS =  pvauthorenginefactory.h pvauthorengineinterface.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
-doc: 
-	perl $(VOB_BASE_DIR)/tools_v2/build/document/bin/doc_build.bat --doctype pvauthor_engine --title "PV Author Engine" --path "$(VOB_BASE_DIR)/engines/common/include $(VOB_BASE_DIR)/engines/author/include" --filetype "mainpage *.h readme.txt" --exclude_pattern "*/test/* */obsolete/* */doxydir/*" -ver $(PVAUTHOR_ENGINE_VERSION)
diff --git a/engines/author/build/makefile b/engines/author/build/makefile
deleted file mode 100755
index cef7021..0000000
--- a/engines/author/build/makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-LIBDIRS = ../../../oscl/oscl/osclbase/build/make \
-../../../oscl/oscl/osclerror/build/make \
-../../../oscl/oscl/osclmemory/build/make \
-../../../oscl/oscl/osclutil/build/make \
-../../../oscl/pvlogger/build/make \
-../../../oscl/oscl/osclproc/build/make \
-../../../oscl/oscl/osclio/build/make \
-../../../oscl/unit_test/build/make \
-../../../codecs_v2/video/m4v_h263/enc/build/make \
-../../../codecs_v2/audio/gsm_amr/amr_nb/enc/build/make \
-../../../codecs_v2/audio/gsm_amr/amr_nb/common/build/make \
-../../../codecs_v2/video/avc_h264/enc/build/make \
-../../../codecs_v2/video/avc_h264/common/build/make \
-../../../baselibs/pv_mime_utils/build/make \
-../../../baselibs/media_data_structures/build/make \
-../../../pvmi/pvmf/build/make \
-../../../pvmi/content_policy_manager/plugins/common/build/make\
-../../../nodes/common/build/make \
-../../../fileformats/common/parser/build/make\
-../../../pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor \
-../../../pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make\
-../../../fileformats/mp4/composer/build/make \
-../../../fileformats/avi/parser/build/make\
-../../../fileformats/wav/parser/build/make\
-../../../nodes/common/build/make\
-../../../nodes/pvamrencnode/build/make \
-../../../nodes/pvmediainputnode/build/make_pvauthor \
-../../../nodes/pvfileoutputnode/build/make \
-../../../nodes/pvmp4ffcomposernode/build/make \
-../../../nodes/pvvideoencnode/build/make \
-../../../nodes/pvavcencnode/build/make \
-make
-
-include $(MK)/recursive.mk
diff --git a/engines/author/include/pvauthorenginefactory.h b/engines/author/include/pvauthorenginefactory.h
index a521c9b..62b4cec 100644
--- a/engines/author/include/pvauthorenginefactory.h
+++ b/engines/author/include/pvauthorenginefactory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/author/include/pvauthorengineinterface.h b/engines/author/include/pvauthorengineinterface.h
index 6e6c8c0..ab69e3f 100644
--- a/engines/author/include/pvauthorengineinterface.h
+++ b/engines/author/include/pvauthorengineinterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -169,7 +169,9 @@
          * Closes an authoring session.
          *
          * All resources added and allocated to the authoring session will be released.
-         * Upon completion of this command, pvAuthor Engine will be in PVAE_STATE_IDLE state.
+         *
+         * This command is valid only when pvAuthor engine is in PVAE_STATE_OPENED state and Upon
+         * completion of this command, pvAuthor Engine will be in PVAE_STATE_IDLE state.
          *
          * @param aContextData Optional opaque data to be passed back to user with the command response
          * @return Unique command ID to identify this command in command response
@@ -180,6 +182,7 @@
          * Adds a media source to be used as input to an authoring session.
          *
          * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state.
+         * This command does not change the pvAuthor Engine engine state.
          *
          * @param aDataSource Reference to the data source
          * @param aContextData Optional opaque data to be passed back to user with the command response
@@ -191,6 +194,7 @@
          * Unbinds a previously added data source.
          *
           * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state.
+         * This command does not change the pvAuthor Engine engine state.
          *
          * @param aDataSource Reference to the data source to be removed
          * @param aContextData Optional opaque data to be passed back to user with the command response
@@ -203,7 +207,7 @@
          *
          * pvAuthor engine will use the most suitable output composer of the specified MIME type available
          * in the authoring session. This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED
-         * state.
+         * state. This command does not change the pvAuthor Engine state.
          *
          * Upon completion of this command, opaque data to indentify the selected composer is provided in the
          * callback.  The user needs to use this opaque data to identify the composer when calling AddMediaTrack(),
@@ -227,7 +231,8 @@
          * Selects an output composer by specifying its Uuid.
          *
          * pvAuthor engine the composer of the specified Uuid in the authoring session.
-         * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state.
+         * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state. This command does
+         * not change the pvAuthor Engine state.
          *
          * Upon completion of this command, opaque data to indentify the selected composer is provided in the
          * callback.  The user needs to use this opaque data to identify the composer when calling AddMediaTrack(),
@@ -262,6 +267,7 @@
          *
          * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state. The referenced
          * data source and composer must be already added before this method is called.
+         * This command does not change the pvAuthor Engine engine state.
          *
          * @param aDataSource Data source node to provide input data
          * @param aEncoderType MIME type of encoder to encode the source data
@@ -292,6 +298,7 @@
          *
          * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state. The referenced
          * data source and composer must be already added before this method is called.
+         * This command does not change the pvAuthor Engine engine state.
          *
          * @param aDataSource Data source node to provide input data
          * @param aEncoderUuid Uuid of encoder to encode the source data
@@ -314,6 +321,8 @@
          * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state. The
          * referenced composer must be previously selected.
          *
+         * This command does not change the pvAuthor Engine engine state.
+         *
          * @param aDataSink Reference to the data sink to be used
          * @param aComposer Opaque data identifying the composer to which the data sink will connect to.
          * @param aContextData Optional opaque data to be passed back to user with the command response
@@ -328,6 +337,7 @@
          * Currently this API does not cause any action as it is not relevant.
 
          * This command is valid only when pvAuthor Engine is in PVAE_STATE_OPENED state.
+         * This command does not change the pvAuthor Engine engine state.
          *
          * @param aDataSink Reference to the data sink to be removed
          * @param aContextData Optional opaque data to be passed back to user with the command response
@@ -364,7 +374,8 @@
          * received from SelectComposer() or AddMediaTrack() or QueryInterface() APIs
          * before calling this method.  This method would fail otherwise.
          *
-         * Upon completion of this command, pvAuthor Engine will be in PVAE_STATE_OPENED state.
+         * This method can be called from ANY state but PVAE_STATE_IDLE. Upon completion of this command, pvAuthor
+         * Engine will be in PVAE_STATE_OPENED state.
          *
          * @param aContextData Optional opaque data to be passed back to user with the command response
          * @returns A unique command id for asynchronous completion
@@ -432,7 +443,7 @@
          *
          * @param aState Output parameter to hold state information
          * @param aContextData Optional opaque data to be passed back to user with the command response
-         * @returns A unique command id for asynchronous completion
+         * @returns A unique command id for synchronous completion
          */
         virtual PVAEState GetPVAuthorState() = 0;
 
@@ -473,19 +484,6 @@
                                            const OsclAny* aContextData = NULL) = 0;
 
         /**
-         * Returns version information about the SDK
-          * Currently this API is NOT SUPPORTED.
-        *
-         * @param aSDKInfo A reference to a PVSDKInfo structure which contains product name,
-         * supported h/w platform, supported s/w platform, version, part number, and PV UID.
-         * These fields will contain info for the currently instantiated pvAuthor engine when
-         * this function returns success.
-         * @param aContextData Optional opaque data to be passed back to user with the command response
-         * @returns A unique command id for asynchronous completion
-         */
-        virtual PVCommandId GetSDKInfo(PVSDKInfo& aSDKInfo, const OsclAny* aContextData = NULL) = 0;
-
-        /**
          * Returns information about all modules currently used by the SDK.
          * Currently this API is NOT SUPPORTED.
          *
@@ -509,6 +507,17 @@
          * @returns A unique command id for asynchronous completion
          */
         virtual PVCommandId CancelAllCommands(const OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Returns SDK version information about author engine.
+         *
+         * @param aSDKInfo
+         *         A reference to a PVSDKInfo structure which contains product name, supported hardware platform,
+         *         supported software platform, version, part number, and PV UUID. These fields will contain info
+         *        .for the currently instantiated pvPlayer engine when this function returns success.
+         *
+         **/
+        OSCL_IMPORT_REF static void GetSDKInfo(PVSDKInfo& aSDKInfo);
 };
 
 #endif // PVAUTHORENGINE_H_INCLUDED
diff --git a/engines/author/src/pv_author_sdkinfo.h b/engines/author/src/pv_author_sdkinfo.h
new file mode 100644
index 0000000..614da15
--- /dev/null
+++ b/engines/author/src/pv_author_sdkinfo.h
@@ -0,0 +1,27 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_AUTHOR_SDKINFO_H_INCLUDED
+#define PV_AUTHOR_SDKINFO_H_INCLUDED
+
+// This header file is automatically generated at build-time
+// *** OFFICIAL RELEASE INFO -- Will not auto update
+
+#define PVAUTHOR_ENGINE_SDKINFO_LABEL "PVDEV_CORE_RELEASE_6.101.1.1"
+#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20090121
+
+#endif //PV_AUTHOR_SDKINFO_H_INCLUDED
diff --git a/engines/author/src/pvae_tuneables.h b/engines/author/src/pvae_tuneables.h
index fd9f45e..ed177db 100644
--- a/engines/author/src/pvae_tuneables.h
+++ b/engines/author/src/pvae_tuneables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/author/src/pvaenodeutility.cpp b/engines/author/src/pvaenodeutility.cpp
index a6aab0d..0f4ebd8 100644
--- a/engines/author/src/pvaenodeutility.cpp
+++ b/engines/author/src/pvaenodeutility.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -331,7 +331,7 @@
             status = CompleteStateTransition(cmd, EPVMFNodePrepared);
             break;
         case PVAENU_CMD_RESET:
-            status = CompleteStateTransition(cmd, EPVMFNodeCreated);
+            status = CompleteStateTransition(cmd, EPVMFNodeIdle);
             break;
         default:
             status = PVMFFailure;
@@ -467,20 +467,19 @@
 PVMFStatus PVAuthorEngineNodeUtility::DoConnect(const PVAENodeUtilCmd& aCmd)
 {
     LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::DoConnect"));
-
-    int32 tag1 = 0;
-    int32 tag2 = 0;
-    OSCL_HeapString<OsclMemAllocator> mimeType;
-    PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseConnect(tag1, tag2, mimeType);
-    if (status != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVAuthorEngineNodeUtility::DoConnect: Error - cmd.ParseConnect failed. status=%d", status));
+    int32 err = 0;
+    OSCL_TRY(err,
+             int32 tag1 = 0;
+             int32 tag2 = 0;
+             OSCL_HeapString<OsclMemAllocator> mimeType;
+             PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseConnect(tag1, tag2, mimeType);
+             if (status != PVMFSuccess)
+{
+    LOG_ERR((0, "PVAuthorEngineNodeUtility::DoConnect: Error - cmd.ParseConnect failed. status=%d", status));
         return status;
     }
 
-    int32 err = 0;
-    OSCL_TRY(err,
-             if (mimeType.get_size() > 0)
+    if (mimeType.get_size() > 0)
 {
     // Request a port from the master node
     aCmd.iNodes[0]->iNode->RequestPort(aCmd.iNodes[0]->iSessionId, tag1,
@@ -503,6 +502,26 @@
     return PVMFPending;
 }
 
+
+// This is a work-around function to eliminate the compiler warning on certain platforms:
+// "Variable might be clobbered by 'longjmp' or vfork'
+static int32 requestport(PVMFNodeInterface* n, int32 id, int32 t2, OSCL_String& mt, OsclAny* p)
+{
+    int32 err;
+    OSCL_TRY(err,
+             if (mt.get_size() > 0)
+{
+    n->RequestPort(id, t2, &mt, p);
+    }
+    else
+    {
+        n->RequestPort(id, t2, NULL, p);
+    }
+            );
+    return err;
+}
+
+
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PVAuthorEngineNodeUtility::CompleteConnect(const PVAENodeUtilCmd& aCmd, const PVMFCmdResp& aResponse)
 {
@@ -520,6 +539,7 @@
     int32 tag2 = 0;
     OSCL_HeapString<OsclMemAllocator> mimeType;
     PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseConnect(tag1, tag2, mimeType);
+
     if (status != PVMFSuccess)
     {
         LOG_ERR((0, "PVAuthorEngineNodeUtility::CompleteConnect: Error - cmd.ParseConnect failed. status=%d", status));
@@ -527,12 +547,11 @@
     }
 
     int32 err = 0;
-    OSCL_TRY(err,
-             // Add port to port vector of node container
-             switch (tag1)
-{
-    case PVAE_NODE_INPUT_PORT_TAG:
-        nodeContainer->iInputPorts.push_back(port);
+    // Add port to port vector of node container
+    switch (tag1)
+    {
+        case PVAE_NODE_INPUT_PORT_TAG:
+            nodeContainer->iInputPorts.push_back(port);
             break;
         case PVAE_NODE_OUTPUT_PORT_TAG:
             nodeContainer->iOutputPorts.push_back(port);
@@ -542,27 +561,10 @@
             OSCL_LEAVE(OsclErrNotSupported);
             break;
     }
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVAuthorEngineNodeUtility::CompleteConnect: Error - Failed to add port to port vector"));
-                         return PVMFFailure;
-                        );
 
     if (nodeContainer == aCmd.iNodes[0])
     {
-        OSCL_TRY(err,
-                 if (mimeType.get_size() > 0)
-    {
-        aCmd.iNodes[1]->iNode->RequestPort(aCmd.iNodes[1]->iSessionId, tag2,
-                                               &mimeType, (OsclAny*)aCmd.iNodes[1]);
-        }
-        else
-        {
-            aCmd.iNodes[1]->iNode->RequestPort(aCmd.iNodes[1]->iSessionId, tag2,
-                                               NULL, (OsclAny*)aCmd.iNodes[1]);
-        }
-                );
+        err = requestport(aCmd.iNodes[1]->iNode, aCmd.iNodes[1]->iSessionId, tag2, mimeType, (OsclAny*)aCmd.iNodes[1]);
 
         OSCL_FIRST_CATCH_ANY(err,
                              LOG_ERR((0, "PVAuthorEngineNodeUtility::CompleteConnect: Error - RequestPort failed. node=0x%x",
@@ -635,15 +637,8 @@
         return PVMFSuccess;
     }
 
-    int32 err = 0;
-    OSCL_TRY(err,
-             port->Disconnect();
-             container->iNode->ReleasePort(container->iSessionId, *port, (OsclAny*)container);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVAuthorEngineNodeUtility::DoDisconnect: Error - ReleasePort failed"));
-                         return PVMFFailure;
-                        );
+    if (PVMFFailure == ReleasePort(container, port))
+        return PVMFFailure;
 
     return PVMFPending;
 }
@@ -682,18 +677,18 @@
 {
     LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::DoQueryInterface"));
 
-    PVInterface** interfacePtr = NULL;
-    PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseQueryInterface(interfacePtr);
-    if (status != PVMFSuccess || !interfacePtr)
-    {
-        LOG_ERR((0, "PVAuthorEngineNodeUtility::DoQueryInterface: Error - aCmd.ParseQueryInterface failed"));
+    int32 err = 0;
+    OSCL_TRY(err,
+             PVInterface** interfacePtr = NULL;
+             PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseQueryInterface(interfacePtr);
+             if (status != PVMFSuccess || !interfacePtr)
+{
+    LOG_ERR((0, "PVAuthorEngineNodeUtility::DoQueryInterface: Error - aCmd.ParseQueryInterface failed"));
         return PVMFFailure;
     }
 
-    int32 err = 0;
-    OSCL_TRY(err,
-             aCmd.iNodes[0]->iNode->QueryInterface(aCmd.iNodes[0]->iSessionId, aCmd.iUuid,
-                                                   (PVInterface*&)*interfacePtr, aCmd.iContext);
+    aCmd.iNodes[0]->iNode->QueryInterface(aCmd.iNodes[0]->iSessionId, aCmd.iUuid,
+                                          (PVInterface*&)*interfacePtr, aCmd.iContext);
             );
 
     OSCL_FIRST_CATCH_ANY(err,
@@ -710,19 +705,18 @@
 {
     LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::CompleteQueryInterface"));
 
-    PVInterface** interfacePtr = NULL;
-    PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseQueryInterface(interfacePtr);
-    if (status != PVMFSuccess || !interfacePtr)
-    {
-        LOG_ERR((0, "PVAuthorEngineNodeUtility::CompleteQueryInterface: Error - aCmd.ParseQueryInterface failed"));
-        return PVMFFailure;
-    }
-
     int32 err = 0;
     OSCL_TRY(err,
-             aCmd.iNodes[0]->iExtensionUuids.push_back(aCmd.iUuid);
-             (*interfacePtr)->addRef();
-             aCmd.iNodes[0]->iExtensions.push_back(*interfacePtr);
+             PVInterface** interfacePtr = NULL;
+             PVMFStatus status = ((PVAENodeUtilCmd)aCmd).ParseQueryInterface(interfacePtr);
+             if (status != PVMFSuccess || !interfacePtr)
+{
+    LOG_ERR((0, "PVAuthorEngineNodeUtility::CompleteQueryInterface: Error - aCmd.ParseQueryInterface failed"));
+        return PVMFFailure;
+    }
+    aCmd.iNodes[0]->iExtensionUuids.push_back(aCmd.iUuid);
+    (*interfacePtr)->addRef();
+    aCmd.iNodes[0]->iExtensions.push_back(*interfacePtr);
             );
 
     OSCL_FIRST_CATCH_ANY(err,
@@ -911,23 +905,50 @@
 {
     LOG_STACK_TRACE((0, "PVAuthorEngineNodeUtility::CompleteStateTransition: aState=%d", aState));
 
+    //Handle reset differently since we need to thread logoff here
+    //if a node state is EPVMFNodeIdle (which is what aState would be if aCmd.iType is PVAENU_CMD_RESET)
+    //do threadlogoff and take the node back to created
+    if (aCmd.iType == PVAENU_CMD_RESET)
+    {
+        for (uint32 i = 0; i < aCmd.iNodes.size(); i++)
+        {
+            if (aCmd.iNodes[i]->iNode->GetState() == aState)
+            {
+                // reset completed, perform threadlogoff on the node.
+                PVMFStatus status = aCmd.iNodes[i]->iNode->ThreadLogoff();
+                if (PVMFSuccess != status)
+                {
+                    LOG_ERR((0, "PVAuthorEngineNodeUtility::CompleteStateTransition: Error - Node ThreadLogoff failed for node=0x%x", aCmd.iNodes[i]->iNode));
+                    OSCL_ASSERT(false);
+                }
+            }
+        }
+        //now that we have taken the nodes in idle back to created,
+        //override aState to EPVMFNodeCreated
+        aState = EPVMFNodeCreated;
+    }
     for (uint32 i = 0; i < aCmd.iNodes.size(); i++)
     {
         if (aCmd.iNodes[i]->iNode->GetState() != aState)
         {
-            if ((aCmd.iType == PVAENU_CMD_RESET) && (aCmd.iNodes[i]->iNode->GetState() == EPVMFNodeIdle))
-            {
-                //If the command is RESET and GetState() == EPVMFNodeIdle, be tolerant
-                //do nothing;
-            }
-            else
-            {
-                // Some nodes have not completed this command. Continue to wait
-                return PVMFPending;
-            }
+            // Some nodes have not completed this command. Continue to wait
+            return PVMFPending;
         }
     }
-
     return PVMFSuccess;
 }
 
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVAuthorEngineNodeUtility::ReleasePort(PVAENodeContainer*& aContainer, PVMFPortInterface*& aPort)
+{
+    int32 err = 0;
+    OSCL_TRY(err,
+             aPort->Disconnect();
+             aContainer->iNode->ReleasePort(aContainer->iSessionId, *aPort, (OsclAny*)aContainer);
+            );
+    OSCL_FIRST_CATCH_ANY(err,
+                         LOG_ERR((0, "PVAuthorEngineNodeUtility::DoDisconnect: Error - ReleasePort failed"));
+                         return PVMFFailure;
+                        );
+    return PVMFSuccess;
+}
diff --git a/engines/author/src/pvaenodeutility.h b/engines/author/src/pvaenodeutility.h
index 1a1483d..49b1028 100644
--- a/engines/author/src/pvaenodeutility.h
+++ b/engines/author/src/pvaenodeutility.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@
     Oscl_Vector<PVMFPortInterface*, OsclMemAllocator> iOutputPorts;
     Oscl_Vector<PVInterface*, OsclMemAllocator> iExtensions;
     Oscl_Vector<PVUuid, OsclMemAllocator> iExtensionUuids;
-    PvmiCapabilityAndConfig* iNodeCapConfigIF;
+    PVInterface* iNodeCapConfigIF;
 };
 
 /** A vector of node container structures */
@@ -447,7 +447,7 @@
         PVMFStatus DoFlush(const PVAENodeUtilCmd& aCmd);
         PVMFStatus DoReset(const PVAENodeUtilCmd& aCmd);
         PVMFStatus CompleteStateTransition(const PVAENodeUtilCmd& aCmd, TPVMFNodeInterfaceState aState);
-
+        PVMFStatus ReleasePort(PVAENodeContainer*&, PVMFPortInterface*&);
         // Observer
         PVAENodeUtilObserver* iObserver;
 
diff --git a/engines/author/src/pvauthorengine.cpp b/engines/author/src/pvauthorengine.cpp
index f8bf78e..c163165 100644
--- a/engines/author/src/pvauthorengine.cpp
+++ b/engines/author/src/pvauthorengine.cpp
@@ -1,6 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +53,9 @@
 #define PVAE_NUM_PENDING_CMDS 10
 #define PVAE_NUM_PENDING_EVENTS 10
 
+#include "pv_author_sdkinfo.h"
+
+
 // Define entry point for this DLL
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
@@ -94,11 +96,13 @@
         iCmdStatusObserver(NULL),
         iInfoEventObserver(NULL),
         iErrorEventObserver(NULL),
-        iEncodedVideoFormat(PVMF_FORMAT_UNKNOWN),
+        iEncodedVideoFormat(PVMF_MIME_FORMAT_UNKNOWN),
         iState(PVAE_STATE_IDLE),
-        iDoResetNodeContainers(false)
+        iCfgCapCmdObserver(NULL),
+        iAsyncNumElements(0)
 {
     iLogger = PVLogger::GetLoggerObject("PVAuthorEngine");
+    iDoResetNodeContainers = false;
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -125,8 +129,6 @@
     Cancel();
     iPendingCmds.clear();
     iPendingEvents.clear();
-
-    ResetGraph();
     ResetNodeContainers();
     while (!iDataSourcePool.empty())
     {
@@ -462,19 +464,29 @@
 ////////////////////////////////////////////////////////////////////////////
 void PVAuthorEngine::HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent)
 {
+    OSCL_UNUSED_ARG(aEvent);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                     (0, "PVAuthorEngine::HandleNodeErrorEvent"));
 
     if ((!iPendingCmds.empty()) && (iState != PVAE_STATE_ERROR)) //if there is a pending command
     {
-        SetPVAEState(PVAE_STATE_ERROR);
-        CompleteEngineCommand(iPendingCmds[0], PVMFFailure);
+        PVEngineCommand cmd = iPendingCmds.front();
+        int cmdtype = cmd.GetCmdType();
+
+        if (cmdtype == PVAE_CMD_RESET)
+        {
+            SetPVAEState(PVAE_STATE_ERROR);
+            return;
+        }
+        else
+        {
+            SetPVAEState(PVAE_STATE_ERROR);
+            CompleteEngineCommand(iPendingCmds[0], PVMFFailure);
+        }
     }
-    else if (iState != PVAE_STATE_ERROR) //no pending command
+    else if (iState != PVAE_STATE_ERROR) //no pending command*
     {
         SetPVAEState(PVAE_STATE_ERROR);
-        PVAsyncErrorEvent eventError(aEvent.GetEventType(), NULL);
-        iErrorEventObserver->HandleErrorEvent(eventError);
     }
 }
 
@@ -489,20 +501,20 @@
         case PVMF_COMPOSER_MAXFILESIZE_REACHED:
         {
             PVEngineCommand cmd(PVAE_CMD_STOP_MAX_SIZE, 0, NULL, NULL);
-            Dispatch(cmd);
+            PushCmdInFront(cmd);
         }
         break;
         case PVMF_COMPOSER_MAXDURATION_REACHED:
         {
             PVEngineCommand cmd(PVAE_CMD_STOP_MAX_DURATION, 0, NULL, NULL);
-            Dispatch(cmd);
+            PushCmdInFront(cmd);
         }
         break;
         case PVMF_COMPOSER_EOS_REACHED:
         case PVMFInfoEndOfData:
         {
             PVEngineCommand cmd(PVAE_CMD_STOP_EOS_REACHED, 0, NULL, NULL);
-            Dispatch(cmd);
+            PushCmdInFront(cmd);
         }
         break;
         case PVMF_COMPOSER_FILESIZE_PROGRESS:
@@ -559,6 +571,8 @@
         case PVAE_CMD_ADD_DATA_SOURCE:
             status = PVMFSuccess;
             break;
+        case PVAE_CMD_REMOVE_DATA_SOURCE:
+            break;
         case PVAE_CMD_SELECT_COMPOSER:
             if (iNodeUtil.GetCommandQueueSize() > 0)
             {
@@ -779,6 +793,28 @@
         RunIfNotReady();
 }
 
+void PVAuthorEngine::PushCmdInFront(PVEngineCommand& aCmd)
+{
+    uint32 idx = 0;
+    while (idx < iPendingCmds.size())
+    {
+        PVEngineCommand cmdPenCmd(iPendingCmds[idx++]);
+        if (cmdPenCmd.GetCmdType() == PVAE_CMD_RESET) //dont erase RESET
+        {
+            return;
+        }
+    }
+    //Author engine processes commands in the order recvd.This is true for API commands, since author does
+    //not support cancelall yet.when composer node eventually reports any informational event like PVMF_COMPOSER_MAXFILESIZE_REACHED,
+    //author engine should queue this cmd into iPendingCmds using "push_front"
+    iPendingCmds.push_front(aCmd);
+    // Call RunIfNotReady only if the newly added command is the only one
+    // in the queue.  Otherwise, it will be processed after the current
+    // command is complete
+    if (iPendingCmds.size() == 1)
+        RunIfNotReady();
+}
+
 ////////////////////////////////////////////////////////////////////////////
 void PVAuthorEngine::CompleteEngineCommand(PVEngineCommand& aCmd, PVMFStatus aStatus,
         OsclAny* aResponseData, int32 aResponseDataSize)
@@ -793,7 +829,7 @@
         iPendingCmds.erase(iPendingCmds.begin());
     }
 
-    if (aStatus == PVMFFailure)
+    if (IsPVMFErrCode(aStatus))
     {
         PVCmdResponse response(aCmd.GetCmdId(), aCmd.GetContext(), aStatus, aResponseData, aResponseDataSize);
         iCmdStatusObserver->CommandCompleted(response);
@@ -803,7 +839,7 @@
             PVEngineCommand cmdPenCmd(iPendingCmds[0]);
             if (cmdPenCmd.GetCmdType() != PVAE_CMD_RESET) //dont erase RESET
             {
-                PVCmdResponse response(cmdPenCmd.GetCmdId(), cmdPenCmd.GetContext(), aStatus, NULL, NULL);
+                PVCmdResponse response(cmdPenCmd.GetCmdId(), cmdPenCmd.GetContext(), aStatus, NULL, 0);
                 iCmdStatusObserver->CommandCompleted(response);
                 iPendingCmds.erase(iPendingCmds.begin());
             }
@@ -1253,7 +1289,10 @@
         // call queryInterface of amr/video encoder node
         // retrieve capability class pointer in iEncoderNode
         // capability class pointer fetched from amr/video encoder node in iEncoderNode
-        iEncoderNodes[ii]->iNode->QueryInterface(iEncoderNodes[ii]->iSessionId, iUuid1, (PVInterface*&)iEncoderNodes[ii]->iNodeCapConfigIF, NULL);
+        iEncoderNodes[ii]->iNode->QueryInterface(iEncoderNodes[ii]->iSessionId,
+                iUuid1,
+                iEncoderNodes[ii]->iNodeCapConfigIF,
+                NULL);
     }
 
     for (uint jj = 0; jj < iComposerNodes.size(); jj++)
@@ -1261,7 +1300,10 @@
         // call queryInterface of file-ouput/mp4-composer node
         // retrieve capability class pointer in iComposerNode
         // capability class pointer fetched from file-ouput/mp4-composer node in iComposerNode
-        iComposerNodes[jj]->iNode->QueryInterface(iComposerNodes[jj]->iSessionId, iUuid1, (PVInterface*&)iComposerNodes[jj]->iNodeCapConfigIF, NULL);
+        iComposerNodes[jj]->iNode->QueryInterface(iComposerNodes[jj]->iSessionId,
+                iUuid1,
+                iComposerNodes[jj]->iNodeCapConfigIF,
+                NULL);
     }
 
     for (uint kk = 0; kk < iDataSourceNodes.size(); kk++)
@@ -1269,7 +1311,10 @@
         // call queryInterface of media io node
         // retrieve capability class pointer in iDataSourceNodes
         // capability class pointer fetched from media io node in iDataSourceNodes
-        iDataSourceNodes[kk]->iNode->QueryInterface(iDataSourceNodes[kk]->iSessionId, iUuid1, (PVInterface*&)iDataSourceNodes[kk]->iNodeCapConfigIF, NULL);
+        iDataSourceNodes[kk]->iNode->QueryInterface(iDataSourceNodes[kk]->iSessionId,
+                iUuid1,
+                iDataSourceNodes[kk]->iNodeCapConfigIF,
+                NULL);
     }
     return PVMFPending;
 }
@@ -1281,50 +1326,39 @@
 
     OSCL_UNUSED_ARG(aCmd);
 
-    switch (GetPVAEState())
+    if (GetPVAEState() == PVAE_STATE_IDLE)
     {
-        case PVAE_STATE_ERROR:
-        case PVAE_STATE_RECORDING:
-        case PVAE_STATE_PAUSED:
-            iNodeUtil.Stop(iDataSourceNodes);
-            if (iEncoderNodes.size() > 0)
-                iNodeUtil.Stop(iEncoderNodes);
-            iNodeUtil.Stop(iComposerNodes);
-            // Don't break here. Continue to disconnect and reset the nodes
-
-        case PVAE_STATE_INITIALIZED:
-            ResetGraph();
-            iNodeUtil.Reset(iDataSourceNodes);
-            if (iEncoderNodes.size() > 0)
-                iNodeUtil.Reset(iEncoderNodes);
-            iNodeUtil.Reset(iComposerNodes);
-            break;
-
-        case PVAE_STATE_OPENED:
-            if (iDoResetNodeContainers)
-            {
-                iDoResetNodeContainers = false;
-                // While RESET-ing, the Composer and Encoder nodes are to be
-                // deleted as there no user API to do deallocations for the
-                // allocations done in the api's DoSelectComposer() and AddMediaTrack()
-                ResetNodeContainers();
-                return PVMFSuccess;
-            }
-            ResetGraph();
-            if ((iDataSourceNodes.size() == 0)
-                    && (iEncoderNodes.size() == 0)
-                    && (iComposerNodes.size() == 0))
-            {
-                // If there is no source/encoder/composer node present
-                // there is nothing to reset, return success rightaway.
-                return PVMFSuccess;
-            }
-            break;
-
-        default:
-            return PVMFErrInvalidState;
+        return PVMFErrInvalidState;
     }
 
+    else
+    {
+        if ((iDataSourceNodes.size() == 0)
+                && (iEncoderNodes.size() == 0)
+                && (iComposerNodes.size() == 0))
+        {
+            // If there is no source/encoder/composer node present
+            // there is nothing to reset, return success rightaway.
+            return PVMFSuccess;
+        }
+        //First call reset on all child nodes, source nodes, encoder nodes, composer nodes
+        //Pls note that since reset on child nodes can be called from any state, and since
+        //node reset needs to clean up everything, there is no need to thru an asynchronous
+        //release port sequence
+        //Once all these resets complete delete them all. We use the boolean iDoResetNodeContainers
+        //to get back in the context of author engine AO to delete stuff. We cannot delete stuff in
+        //NodeUtilCommandCompleted
+        if (iDoResetNodeContainers)
+        {
+            iDoResetNodeContainers = false;
+            // While RESET-ing, the Composer and Encoder nodes are to be
+            // deleted as there no user API to do deallocations for the
+            // allocations done in the api's DoSelectComposer() and AddMediaTrack()
+            ResetNodeContainers();
+            return PVMFSuccess;
+        }
+        ResetGraph();
+    }
     return PVMFPending;
 }
 
@@ -1412,6 +1446,10 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVAuthorEngine::ResetNodeContainers"));
+
+    if (iAllNodes.size() > 0)
+        iAllNodes.clear();
+
     uint32 i, j;
     for (i = 0; i < iDataSourceNodes.size(); i++)
     {
@@ -1552,19 +1590,14 @@
         LOG_ERR((0, "PVAuthorEngine::IsCompressedFormatDataSource: Error - GetCapability failed"));
         return PVMFFailure;
     }
-
     aIsCompressedFormat = false;
     for (uint32 i = 0; i < capability.iOutputFormatCapability.size(); i++)
     {
-        switch (GetMediaTypeIndex(capability.iOutputFormatCapability[i]))
+        PVMFFormatType format = (capability.iOutputFormatCapability[i]);
+        if (format.isCompressed() || format.isText())
         {
-            case PVMF_COMPRESSED_VIDEO_FORMAT:
-            case PVMF_COMPRESSED_AUDIO_FORMAT:
-            case PVMF_TEXT_FORMAT:
-                aIsCompressedFormat = true;
-                return PVMFSuccess;
-            default:
-                break;
+            aIsCompressedFormat = true;
+            return PVMFSuccess;
         }
     }
 
@@ -1574,13 +1607,30 @@
 ////////////////////////////////////////////////////////////////////////////
 void PVAuthorEngine::ResetGraph()
 {
-    uint32 i = 0;
-    for (i = 0; i < iDataSourceNodes.size(); i++)
-        iNodeUtil.Disconnect(iDataSourceNodes[i]);
-    for (i = 0; i < iEncoderNodes.size(); i++)
-        iNodeUtil.Disconnect(iEncoderNodes[i]);
-    for (i = 0; i < iComposerNodes.size(); i++)
-        iNodeUtil.Disconnect(iComposerNodes[i]);
+
+    if (iAllNodes.size() != (iEncoderNodes.size() + iDataSourceNodes.size() + iComposerNodes.size()))
+    {
+
+        for (uint ii = 0; ii < iEncoderNodes.size(); ii++)
+        {
+            iAllNodes.push_back(iEncoderNodes[ii]);
+        }
+        for (uint jj = 0; jj < iDataSourceNodes.size(); jj++)
+        {
+            iAllNodes.push_back(iDataSourceNodes[jj]);
+        }
+        for (uint kk = 0; kk < iComposerNodes.size(); kk++)
+        {
+            iAllNodes.push_back(iComposerNodes[kk]);
+        }
+    }
+
+
+    if (iAllNodes.size() > 0)
+    {
+        iNodeUtil.Reset(iAllNodes);
+    }
+
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -1668,8 +1718,10 @@
              // Do thread logon and create a session to the node
              PVMFNodeSessionInfo session((PVMFNodeCmdStatusObserver*)&iNodeUtil, this, nodeContainer,
                                          this, nodeContainer);
+
              aNode->ThreadLogon();
              nodeContainer->iSessionId = aNode->Connect(session);
+
              nodeContainer->iNode = aNode;
             );
 
@@ -1771,19 +1823,18 @@
         else
         {
             // Determine which node's cap-config IF needs to be used
-            Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
+            Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
             PVMFStatus retval = DoQueryNodeCapConfig(paramkvp[paramind].key, nodecapconfigif);
             *retkvp = &paramkvp[paramind];
             if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
             {
                 uint32 nodeind = 0;
                 bool anysuccess = false;
-
                 // Go through each returned node's cap-config until successful
                 while (nodeind < nodecapconfigif.size())
                 {
                     *retkvp = NULL;
-                    nodecapconfigif[nodeind]->setParametersSync(NULL, &paramkvp[paramind], 1, *retkvp);
+                    ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->setParametersSync(NULL, &paramkvp[paramind], 1, *retkvp);
                     ++nodeind;
                     if (*retkvp == NULL && anysuccess == false)
                     {
@@ -1815,7 +1866,7 @@
 }
 
 
-PVMFStatus PVAuthorEngine::DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator>& aNodeCapConfigIF)
+PVMFStatus PVAuthorEngine::DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PVInterface*, OsclMemAllocator>& aNodeCapConfigIF)
 {
     int32 leavecode = 0;
 
@@ -1826,51 +1877,59 @@
         return PVMFErrArgument;
     }
 
-    // check for "video/render" or "audio/render" keyword in MIME string
-    if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/video/render")) >= 0)
-            || (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/audio/render")) >= 0)
-            || (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/avc/encoder")) >= 0))
+    // check for "encoder/video" or "encoder/audio" keyword in MIME string
+    if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/encoder/video")) >= 0) ||
+            (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/encoder/audio")) >= 0))
     {
-        for (uint ii = 0; ii < iEncoderNodes.size(); ii++)
-        {
-            if (iEncoderNodes[ii]->iNodeCapConfigIF)
+        leavecode = 0;
+        // insert capability class pointer of amr/video encoder/avc encoder node in aNodeCapConfigIF
+        OSCL_TRY(leavecode,
+                 for (uint ii = 0; ii < iEncoderNodes.size(); ii++)
+    {
+        if (iEncoderNodes[ii]->iNodeCapConfigIF)
             {
-                leavecode = 0;
-                // insert capability class pointer of amr/video encoder/avc encoder node in aNodeCapConfigIF
-                OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(iEncoderNodes[ii]->iNodeCapConfigIF));
-                OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
+                aNodeCapConfigIF.push_back(iEncoderNodes[ii]->iNodeCapConfigIF);
             }
         }
-    }
+                );
+        OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
 
-    // check for "fileio" or "file/output" keyword in MIME string
-    else if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("fileio")) >= 0) || (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/file/output")) >= 0))
-    {
-        for (uint jj = 0; jj < iComposerNodes.size(); jj++)
-        {
-            if (iComposerNodes[jj]->iNodeCapConfigIF)
-            {
-                leavecode = 0;
-                // insert capability class pointer of mp4-composer/file-output node in aNodeCapConfigIF
-                OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(iComposerNodes[jj]->iNodeCapConfigIF));
-                OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-            }
-        }
     }
-
-    // check for "x-pvmf/media-io" keyword in MIME string
-    else if (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/media-io")) >= 0)
+    // check for "fileio" or "file/output" or "x-pvmf/composer" keyword in MIME string
+    else if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/composer")) >= 0) ||
+             (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("fileio")) >= 0) ||
+             (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/file/output")) >= 0))
     {
-        for (uint k = 0; k < iDataSourceNodes.size(); k++)
-        {
-            if (iDataSourceNodes[k]->iNodeCapConfigIF)
+        leavecode = 0;
+        // insert capability class pointer of mp4-composer/file-output node in aNodeCapConfigIF
+        OSCL_TRY(leavecode,
+                 for (uint jj = 0; jj < iComposerNodes.size(); jj++)
+    {
+        if (iComposerNodes[jj]->iNodeCapConfigIF)
             {
-                leavecode = 0;
-                // insert capability class pointer of media io node in aNodeCapConfigIF
-                OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(iDataSourceNodes[k]->iNodeCapConfigIF));
-                OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
+                aNodeCapConfigIF.push_back(iComposerNodes[jj]->iNodeCapConfigIF);
             }
         }
+                );
+        OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
+
+    }
+    // check for "x-pvmf/media-io" or "x-pvmf/datasource" keyword in MIME string
+    else if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/datasource")) >= 0) ||
+             (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/media-io")) >= 0))
+    {
+        leavecode = 0;
+        // insert capability class pointer of media io node in aNodeCapConfigIF
+        OSCL_TRY(leavecode,
+                 for (uint k = 0; k < iDataSourceNodes.size(); k++)
+    {
+        if (iDataSourceNodes[k]->iNodeCapConfigIF)
+            {
+                aNodeCapConfigIF.push_back(iDataSourceNodes[k]->iNodeCapConfigIF);
+            }
+        }
+                );
+        OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
     }
 
     return PVMFSuccess;
@@ -1892,7 +1951,6 @@
     OSCL_UNUSED_ARG(aSession);
     OSCL_UNUSED_ARG(aContext);
     iAsyncNumElements = aNumElements;
-
     PVEngineCommand cmd(PVAE_CMD_CAPCONFIG_SET_PARAMETERS, 0, NULL, aParameters, (OsclAny*)&iAsyncNumElements, (OsclAny*)&aRetKVP);
     Dispatch(cmd);
     return iCommandId++;
@@ -2004,7 +2062,7 @@
         else
         {
             // Determine which node's cap-config IF needs to be used
-            Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
+            Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
             PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
             if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
             {
@@ -2013,7 +2071,8 @@
                 // Go through each returned node's cap-config until successful
                 while (nodeind < nodecapconfigif.size() && retval != PVMFSuccess)
                 {
-                    retval = nodecapconfigif[nodeind]->verifyParametersSync(NULL, &aParameters[paramind], 1);
+                    retval =
+                        ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->verifyParametersSync(NULL, &aParameters[paramind], 1);
                     ++nodeind;
                 }
 
@@ -2323,7 +2382,7 @@
     else
     {
         // Determine which node's cap-config IF needs to be used
-        Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
+        Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
         PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
         if (PVMFSuccess == retval && !(nodecapconfigif.empty()))
         {
@@ -2331,7 +2390,8 @@
             // Go through each returned node's cap-config until successful
             while (nodeind < nodecapconfigif.size() && 0 == aNumParamElements)
             {
-                retval = nodecapconfigif[nodeind]->getParametersSync(NULL, aIdentifier, aParameters, aNumParamElements, aContext);
+                retval =
+                    ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->getParametersSync(NULL, aIdentifier, aParameters, aNumParamElements, aContext);
                 ++nodeind;
             }
         }
@@ -2414,6 +2474,7 @@
                     aParameters[ii].value.key_specific_value = NULL;
                     oscl_free(rui32);
                 }
+                // @TODO Add more types if engine starts returning more types
             }
         }
 
@@ -2427,7 +2488,7 @@
     else
     {
         // Determine which node's cap-config IF needs to be used
-        Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
+        Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
         PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
         if (PVMFSuccess == retval && !(nodecapconfigif.empty()))
         {
@@ -2436,7 +2497,8 @@
             // Go through each returned node's cap-config until successful
             while (nodeind < nodecapconfigif.size() && PVMFSuccess != retval)
             {
-                retval = nodecapconfigif[nodeind]->releaseParameters(NULL, aParameters, aNumElements);
+                retval =
+                    ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->releaseParameters(NULL, aParameters, aNumElements);
                 ++nodeind;
             }
 
@@ -2782,3 +2844,15 @@
     return PVMFSuccess;
 }
 
+
+OSCL_EXPORT_REF
+void
+PVAuthorEngineInterface::GetSDKInfo
+(
+    PVSDKInfo& aSdkInfo
+)
+{
+    aSdkInfo.iLabel = PVAUTHOR_ENGINE_SDKINFO_LABEL;
+    aSdkInfo.iDate  = PVAUTHOR_ENGINE_SDKINFO_DATE;
+}
+
diff --git a/engines/author/src/pvauthorengine.h b/engines/author/src/pvauthorengine.h
index d276ce1..5cd7272 100644
--- a/engines/author/src/pvauthorengine.h
+++ b/engines/author/src/pvauthorengine.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,7 +52,6 @@
 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
 #include "pvmi_config_and_capability.h"
 #endif
-#define KMp4ComposerMimeType "/x-pvmf/ff-mux/mp4"
 #define K3gpComposerMimeType "/x-pvmf/ff-mux/3gp"
 #define KAmrNbEncMimeType "/x-pvmf/audio/encode/amr-nb"
 #define KH263EncMimeType "/x-pvmf/video/encode/h263"
@@ -220,7 +219,7 @@
         PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
         // functions used by cap-config class virtual functions
         bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        PVMFStatus DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator>& aNodeCapConfigIF);
+        PVMFStatus DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PVInterface*, OsclMemAllocator>& aNodeCapConfigIF);
         void addRef();
         void removeRef();
     private:
@@ -234,6 +233,7 @@
         // Command handling functions
         void Dispatch(PVEngineCommand& aCmd);
         void Dispatch(PVEngineAsyncEvent& aEvent);
+        void PushCmdInFront(PVEngineCommand& aCmd);
         void CompleteEngineCommand(PVEngineCommand& aCmd, PVMFStatus aStatus,
                                    OsclAny* aResponseData = NULL, int32 aResponseDataSize = 0);
         PVMFStatus DoOpen(PVEngineCommand& aCmd);
@@ -366,6 +366,7 @@
         PVAENodeContainerVector iDataSourceNodes;
         PVAENodeContainerVector iEncoderNodes;
         PVAENodeContainerVector iComposerNodes;
+        PVAENodeContainerVector iAllNodes;
 
         PVMFFormatType iEncodedVideoFormat;
         PVAEState iState;
diff --git a/engines/author/src/single_core/pvaenodefactoryutility.h b/engines/author/src/single_core/pvaenodefactoryutility.h
index 1cad7c2..6e7bb4d 100644
--- a/engines/author/src/single_core/pvaenodefactoryutility.h
+++ b/engines/author/src/single_core/pvaenodefactoryutility.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,18 +32,12 @@
 #ifndef PVAUTHORENGINE_H_INCLUDED
 #include "pvauthorengine.h"
 #endif
-#ifndef PVMF_OMX_VIDEOENC_NODE_FACTORY_H_INCLUDED
-#include "pvmf_omx_videoenc_node_factory.h"
-#endif
 #ifndef PVMP4FFCN_FACTORY_H_INCLUDED
 #include "pvmp4ffcn_factory.h"
 #endif
 #ifndef PVMF_FILEOUTPUT_FACTORY_H_INCLUDED
 #include "pvmf_fileoutput_factory.h"
 #endif
-#ifndef PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
-#include "pvmf_amrenc_node_factory.h"
-#endif
 #ifndef PVMP4FFCN_CLIPCONFIG_H_INCLUDED
 #include "pvmp4ffcn_clipconfig.h"
 #endif
@@ -59,9 +53,25 @@
 #ifndef PVMFAMRENCNODE_EXTENSION_H_INCLUDED
 #include "pvmfamrencnode_extension.h"
 #endif
+
+#ifdef USE_OMX_ENC_NODE
+
+#ifndef PVMF_OMX_ENC_FACTORY_H_INCLUDED
+#include "pvmf_omx_enc_factory.h"
+#endif
+
+#else
+
 #ifndef PVMFAVCENCNODE_FACTORY_H_INCLUDED
 #include "pvmf_avcenc_node_factory.h"
 #endif
+#ifndef PVMF_VIDEOENC_NODE_FACTORY_H_INCLUDED
+#include "pvmf_videoenc_node_factory.h"
+#endif
+#ifndef PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
+#include "pvmf_amrenc_node_factory.h"
+#endif
+#endif
 
 class PVAuthorEngineNodeFactoryUtility
 {
@@ -69,9 +79,20 @@
         static PVMFNodeInterface* CreateEncoder(const PVUuid& aUuid)
         {
             PVMFNodeInterface* node = NULL;
-            if (aUuid == PVMFOMXVideoEncNodeUuid)
+#ifdef USE_OMX_ENC_NODE
+            if (aUuid == KPVMFOMXVideoEncNodeUuid)
             {
-                node = PVMFOMXVideoEncNodeFactory::CreateVideoEncNode();
+                node = PVMFOMXEncNodeFactory::CreatePVMFOMXEncNode();
+            }
+            else if (aUuid == KPVMFOMXAudioEncNodeUuid)
+            {
+                node = PVMFOMXEncNodeFactory::CreatePVMFOMXEncNode();
+            }
+#else
+
+            if (aUuid == PVMFVideoEncNodeUuid)
+            {
+                node = PVMFVideoEncNodeFactory::CreateVideoEncNode();
             }
             else if (aUuid == PvmfAmrEncNodeUuid)
             {
@@ -81,6 +102,7 @@
             {
                 node = PVMFAvcEncNodeFactory::CreateAvcEncNode();
             }
+#endif
             return node;
         }
 
@@ -101,19 +123,32 @@
 
         static bool Delete(const PVUuid& aUuid, PVMFNodeInterface* aNode)
         {
-            if(!aNode)
-            {
+            if (!aNode)
                 return false;
-            }
 
-            if (aUuid == PVMFOMXVideoEncNodeUuid)
+#ifdef USE_OMX_ENC_NODE
+            else if (aUuid == KPVMFOMXVideoEncNodeUuid)
             {
-                return PVMFOMXVideoEncNodeFactory::DeleteVideoEncNode(aNode);
+                return PVMFOMXEncNodeFactory::DeletePVMFOMXEncNode(aNode);
+            }
+            else if (aUuid == KPVMFOMXAudioEncNodeUuid)
+            {
+                return PVMFOMXEncNodeFactory::DeletePVMFOMXEncNode(aNode);
+            }
+#else
+            if (aUuid == PVMFVideoEncNodeUuid)
+            {
+                return PVMFVideoEncNodeFactory::DeleteVideoEncNode(aNode);
             }
             else if (aUuid == PVMFAvcEncNodeUuid)
             {
                 return PVMFAvcEncNodeFactory::DeleteAvcEncNode(aNode);
             }
+            else if (aUuid == PvmfAmrEncNodeUuid)
+            {
+                return PvmfAmrEncNodeFactory::Delete(aNode);
+            }
+#endif
             else if (aUuid == KPVMp4FFComposerNodeUuid)
             {
                 return PVMp4FFComposerNodeFactory::DeleteMp4FFComposer(aNode);
@@ -122,33 +157,43 @@
             {
                 return PVFileOutputNodeFactory::DeleteFileOutput(aNode);
             }
-            else if (aUuid == PvmfAmrEncNodeUuid)
-            {
-                return PvmfAmrEncNodeFactory::Delete(aNode);
-            }
-
             return false;
         }
 
         static bool QueryRegistry(const PvmfMimeString& aMimeType, PVUuid& aUuid)
         {
-            if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KMp4ComposerMimeType)) ||
-                CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(K3gpComposerMimeType)))
+            if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(K3gpComposerMimeType)))
             {
                 aUuid = KPVMp4FFComposerNodeUuid;
             }
             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KMp4EncMimeType)) ||
                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KH263EncMimeType)))
             {
-                aUuid = PVMFOMXVideoEncNodeUuid;
+#ifdef USE_OMX_ENC_NODE
+                // replace mp4/h263 encoder node with omx encoder node
+                aUuid = KPVMFOMXVideoEncNodeUuid;
+#else
+                aUuid = PVMFVideoEncNodeUuid;
+#endif
             }
             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KH264EncMimeType)))
             {
+#ifdef USE_OMX_ENC_NODE
+                // replace avc encoder node with omx encoder node
+                aUuid = KPVMFOMXVideoEncNodeUuid;
+#else
                 aUuid = PVMFAvcEncNodeUuid;
+#endif
+
             }
             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAmrNbEncMimeType)))
             {
+#ifdef USE_OMX_ENC_NODE
+                // replace amr encoder node with omx encoder node
+                aUuid = KPVMFOMXAudioEncNodeUuid;
+#else
                 aUuid = PvmfAmrEncNodeUuid;
+#endif
             }
             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAMRNbComposerMimeType)) ||
                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAACADIFComposerMimeType)) ||
@@ -178,7 +223,20 @@
                 aConfigUuid = PvmfFileOutputNodeConfigUuid;
                 status = true;
             }
-            else if ((aNodeUuid == PVMFOMXVideoEncNodeUuid) || (aNodeUuid == PVMFAvcEncNodeUuid))
+#ifdef USE_OMX_ENC_NODE
+            else if (aNodeUuid == KPVMFOMXVideoEncNodeUuid)
+            {
+                aConfigUuid = PVMp4H263EncExtensionUUID;
+                status = true;
+            }
+            else if (aNodeUuid == KPVMFOMXAudioEncNodeUuid)
+            {
+                aConfigUuid = PVAMREncExtensionUUID;
+                status = true;
+            }
+#else
+            else if ((aNodeUuid == PVMFVideoEncNodeUuid) ||
+                     (aNodeUuid == PVMFAvcEncNodeUuid))
             {
                 aConfigUuid = PVMp4H263EncExtensionUUID;
                 status = true;
@@ -188,6 +246,7 @@
                 aConfigUuid = PVAMREncExtensionUUID;
                 status = true;
             }
+#endif
             ////////////////////////////////////////////////////////////////////////////
             // When implementing support for a new file format composer or encoder node,
             // add code to return config uuid of the new node here if necessary
diff --git a/engines/author/test/Android.mk b/engines/author/test/Android.mk
index da04749..8600f87 100644
--- a/engines/author/test/Android.mk
+++ b/engines/author/test/Android.mk
@@ -3,51 +3,43 @@
 
 LOCAL_SRC_FILES := \
 	src/pvaetest.cpp \
-	src/test_pv_author_engine_testset1.cpp \
-	src/test_pv_author_engine_testset2.cpp \
-	src/test_pv_author_engine_testset3.cpp \
-	src/test_pv_author_engine_testset4.cpp \
-	src/./single_core/pvaetestinput.cpp \
-	src/test_pv_author_engine_testset5.cpp \
-	src/test_pv_author_engine_testset6.cpp \
-	src/test_pv_author_engine_testset7.cpp \
-	src/test_pv_mediainput_author_engine.cpp
-
-
-LOCAL_SHARED_LIBRARIES := libopencorecommon libopencoreauthor libopencoreplayer
-
-LOCAL_STATIC_LIBRARIES := libunit_test libpvmiofileinput libpvavifileparser libpvwav libpvmioaviwavfileinput
+ 	src/test_pv_author_engine_testset1.cpp \
+ 	src/test_pv_author_engine_testset4.cpp \
+ 	src/./single_core/pvaetestinput.cpp \
+ 	src/test_pv_author_engine_testset5.cpp \
+ 	src/test_pv_author_engine_testset6.cpp \
+ 	src/test_pv_author_engine_testset7.cpp \
+ 	src/test_pv_mediainput_author_engine.cpp \
+ 	src/test_pv_author_engine_logger.cpp \
+ 	src/test_pv_author_engine_testset8.cpp
 
 
 LOCAL_MODULE := test_pvauthorengine
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS := -D_IMOTION_SPECIFIC_UT_DISABLE $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := libunit_test  
+
+LOCAL_SHARED_LIBRARIES :=  libopencore_author libopencore_common
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/author/test/src \
-	$(PV_TOP)//engines/author/test/src \
-	$(PV_TOP)//engines/author/test/../../common/include \
-	$(PV_TOP)//engines/author/test/config/linux_nj \
-	$(PV_TOP)//engines/author/test/src/single_core \
-	$(PV_TOP)//engines/author/test/../../../pvmi/pvmf/include \
-	$(PV_TOP)//engines/author/test/../../../nodes/common/include \
-	$(PV_TOP)//engines/author/test/../../../pvmi/media_io/pvmi_mio_fileinput/include \
-	$(PV_TOP)//engines/author/test/../../../pvmi/media_io/pvmi_mio_fileinput/src \
-	$(PV_TOP)//engines/author/test/../../../pvmi/media_io/pvmi_mio_avi_wav_fileinput/include \
-	$(PV_TOP)//engines/author/test/../../../fileformats/avi/parser/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/engines/author/test/src \
+ 	$(PV_TOP)/engines/author/test/src \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_TOP)/engines/author/test/src/single_core \
+ 	$(PV_TOP)/engines/author/test/config/linux_nj \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
 
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
+LOCAL_COPY_HEADERS := \
+ 	
+
+-include $(PV_TOP)/Android_system_extras.mk
 
 include $(BUILD_EXECUTABLE)
-
diff --git a/engines/author/test/build/linux_nj/local.mk b/engines/author/test/build/linux_nj/local.mk
new file mode 100644
index 0000000..52563a4
--- /dev/null
+++ b/engines/author/test/build/linux_nj/local.mk
@@ -0,0 +1,43 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := test_pvauthorengine
+
+# Comment this out until all warnings are fixed
+#XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+XCPPFLAGS += -D_IMOTION_SPECIFIC_UT_DISABLE
+
+XINCDIRS +=  ../../../../common/include ../../src/single_core ../../config/linux_nj ../../../../../pvmi/pvmf/include ../../../../../nodes/common/include  ../../../../../extern_libs_v2/khronos/openmax/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvaetest.cpp test_pv_author_engine_testset1.cpp test_pv_author_engine_testset4.cpp ./single_core/pvaetestinput.cpp test_pv_author_engine_testset5.cpp test_pv_author_engine_testset6.cpp test_pv_author_engine_testset7.cpp test_pv_mediainput_author_engine.cpp test_pv_author_engine_logger.cpp test_pv_author_engine_testset8.cpp
+
+
+LIBS := unit_test opencore_author opencore_common
+
+
+
+ifneq ($(ARCHITECTURE),win32)
+  SYSLIBS = -lpthread -ldl
+endif
+
+include $(MK)/prog.mk
+
+AE_TEST_DIR = ${BUILD_ROOT}/ae_test
+AE_TARGET = test_pvauthorengine
+
+run_ae_test:: $(REALTARGET) default
+	$(quiet) ${RM} -r ${AE_TEST_DIR}
+	$(quiet) ${MKDIR} ${AE_TEST_DIR}
+	$(quiet) $(CP) $(SRC_ROOT)/tools_v2/build/package/opencore/pvplayer.cfg $(AE_TEST_DIR)
+	$(quiet) $(CP) $(SRC_ROOT)/engines/author/test/test_input/* $(AE_TEST_DIR)
+	$(quiet) export LD_LIBRARY_PATH=${BUILD_ROOT}/installed_lib/${HOST_ARCH}; cd $(AE_TEST_DIR) && ${BUILD_ROOT}/bin/${HOST_ARCH}/$(AE_TARGET) $(TEST_ARGS) $(SOURCE_ARGS)
+
diff --git a/engines/author/test/build/linux_nj/makefile b/engines/author/test/build/linux_nj/makefile
deleted file mode 100755
index 679c5c1..0000000
--- a/engines/author/test/build/linux_nj/makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = prog
-TARGET = test_pvauthorengine
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# include the common engine header files in the search path
-XINCDIRS += -I ../../../../common/include -I ../../config/linux_nj -I../../src/single_core -I../../../../../pvmi/pvmf/include -I../../../../../nodes/common/include -I../../../../../pvmi/media_io/pvmi_mio_fileinput/include -I../../../../../pvmi/media_io/pvmi_mio_fileinput/src -I../../../../../pvmi/media_io/pvmi_mio_avi_wav_fileinput/include -I../../../../../fileformats/avi/parser/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-#XLDFLAGS +=
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	pvaetest.cpp test_pv_author_engine_testset1.cpp test_pv_author_engine_testset2.cpp test_pv_author_engine_testset3.cpp test_pv_author_engine_testset4.cpp ./single_core/pvaetestinput.cpp test_pv_author_engine_testset5.cpp test_pv_author_engine_testset6.cpp test_pv_author_engine_testset7.cpp test_pv_mediainput_author_engine.cpp
-
-
-#to use the _mod versions because the project is built with the LIBTARGET=module-rel option
-LIBS = \
--lpvcommon \
--lpvauthor \
--lunit_test_mod \
--lpvwav_mod \
--lpvmiofileinput_mod \
--lpvmioaviwavfileinput_mod \
--lpvavifileparser_mod \
--lpvfileparserutils_mod 
-
-
-SYSLIBS = -lpthread -ldl
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/engines/author/test/config/linux_nj/test_pv_author_engine_config.h b/engines/author/test/config/linux_nj/test_pv_author_engine_config.h
index d162679..d2b7754 100644
--- a/engines/author/test/config/linux_nj/test_pv_author_engine_config.h
+++ b/engines/author/test/config/linux_nj/test_pv_author_engine_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,72 +28,81 @@
 // Set to 1 to use the scheduler native to the system instead of PV scheduler
 #define USE_NATIVE_SCHEDULER 0
 
-#define SOURCENAME_AUTHOR_PREPEND_STRING _STRLIT("")
-
 #define KLogFile _STRLIT("pvauthor.log")
+#define KPVAELoggerFile _STRLIT("pvaelogger.txt")
+
 
 // Input files
-#define KYUVTestInput               SOURCENAME_AUTHOR_PREPEND_STRING"yuvtestinput.yuv"
-#define KH263TestInput              SOURCENAME_AUTHOR_PREPEND_STRING"h263testinput.h263"
-#define KM4VTestInput               SOURCENAME_AUTHOR_PREPEND_STRING"m4vtestinput.m4v"
-#define KAMRTestInput               SOURCENAME_AUTHOR_PREPEND_STRING"amrtestinput.amr"
-#define KAACADIFTestInput           SOURCENAME_AUTHOR_PREPEND_STRING"aac_adif.aacadif"
-#define KAACADTSTestInput           SOURCENAME_AUTHOR_PREPEND_STRING"aac_adts.aacadts"
-#define KPCM16TestInput             SOURCENAME_AUTHOR_PREPEND_STRING"pcm16testinput.pcm"
-#define KH264TestInput              SOURCENAME_AUTHOR_PREPEND_STRING"h264testinput.h264"
-#define KTEXTTestInput              SOURCENAME_AUTHOR_PREPEND_STRING"MOL004.txt"
-#define KTEXTLogTestInput           SOURCENAME_AUTHOR_PREPEND_STRING"MOL004_text0.log"
-#define KTEXTTxtFileTestInput       SOURCENAME_AUTHOR_PREPEND_STRING"MOL004_sd_txt1.txt"
+#define KYUVTestInput _STRLIT("yuvtestinput.yuv")
+#define KH263TestInput _STRLIT("h263testinput.h263")
+#define KAMRTestInput _STRLIT("amrtestinput.amr")
+#define KAACADIFTestInput _STRLIT("aac_adif.aacadif")
+#define KAACADTSTestInput _STRLIT("aac_adts.aacadts")
+#define KH264TestInput _STRLIT("h264testinput.h264")
+#define KTEXTTestInput _STRLIT("MOL004.txt")
+#define KTEXTLogTestInput _STRLIT("MOL004_text0.log")
+#define KTEXTTxtFileTestInput _STRLIT("MOL004_sd_txt1.txt")
 
 // Output files
-#define KAMRInputAOnly3gpTestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"amr_in_a_only_test.3gp"
-#define KAMRInputAOnlyMp4TestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"amr_in_a_only_test.mp4"
-#define KYUVInputVOnly3gpTestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"yuv_in_v_only_test.3gp"
-#define KH263InputVOnly3gpTestOutput    SOURCENAME_AUTHOR_PREPEND_STRING"h263_in_v_only_test.3gp"
-#define KYUVInputVOnlyMp4TestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"yuv_in_v_only_test.mp4"
-#define KM4VInputVOnlyMp4TestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"m4v_in_v_only_test.mp4"
-#define KAMRYUVInputAV3gpTestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"amr_yuv_in_av_test.3gp"
-#define KAMRH263InputAV3gpTestOutput    SOURCENAME_AUTHOR_PREPEND_STRING"amr_h263_in_av_test.3gp"
-#define KAMRYUVInputAVMp4TestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"amr_yuv_in_av_test.mp4"
-#define KAMRM4VInputAVMp4TestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"amr_m4v_in_av_test.mp4"
-#define KPauseResumeTestOutput          SOURCENAME_AUTHOR_PREPEND_STRING"pause_resume_test.mp4"
-#define KFOAOnlyAMRTestOutput           SOURCENAME_AUTHOR_PREPEND_STRING"amr_testoutput.amr"
-#define KFOAOnlyAACADIFTestOutput       SOURCENAME_AUTHOR_PREPEND_STRING"aac_adif_output.aac"
-#define KFOAOnlyAACADTSTestOutput       SOURCENAME_AUTHOR_PREPEND_STRING"aac_adts_output.aac"
-#define KPCM16TestOutput                SOURCENAME_AUTHOR_PREPEND_STRING"pcm_testoutput.amr"
-#define KPCM16AOnly3gpTestOutput        SOURCENAME_AUTHOR_PREPEND_STRING"pcm_in_a_only_test.3gp"
-#define KPCM16AOnlyMp4TestOutput        SOURCENAME_AUTHOR_PREPEND_STRING"pcm_in_a_only_test.mp4"
-#define KPCM16YUVInputAV3gpTestOutput   SOURCENAME_AUTHOR_PREPEND_STRING"pcm_in_av_test.3gp"
-#define KPCM16YUVInputAVMp4TestOutput   SOURCENAME_AUTHOR_PREPEND_STRING"pcm_in_av_test.mp4"
-#define KMaxFileSizeTestOutput          SOURCENAME_AUTHOR_PREPEND_STRING"maxfilesize_test.3gp"
-#define KMaxDurationTestOutput          SOURCENAME_AUTHOR_PREPEND_STRING"maxduration_test.3gp"
-#define KFileSizeProgressTestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"filesizeprogress_test.3gp"
-#define KDurationProgressTestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"durationprogress_test.3gp"
-#define KIMotionAuthoringModeTestOutput SOURCENAME_AUTHOR_PREPEND_STRING"IMotionAuthoring_test.3gp"
-#define KFastTrackContentModeTestOutput SOURCENAME_AUTHOR_PREPEND_STRING"FastTrackContentAuthoring_test.3gp"
-#define K3GPPDownloadModeTestOutput     SOURCENAME_AUTHOR_PREPEND_STRING"3GPPDownloadAuthoring_test.3gp"
-#define K3GPPProgressiveDownloadModeTestOutput SOURCENAME_AUTHOR_PREPEND_STRING"3GPPProgressiveDownloadAuthoring_test.3gp"
-#define KIMotionDownloadModeTestOutput  SOURCENAME_AUTHOR_PREPEND_STRING"IMotionDownloadAuthoring_test.3gp"
-#define KH264InputVOnlyMp4TestOutput    SOURCENAME_AUTHOR_PREPEND_STRING"h264_in_v_only_test.mp4"
-#define KH264AMRInputAVMp4TestTestOutput SOURCENAME_AUTHOR_PREPEND_STRING"h264_amr_in_av_test.mp4"
-#define KMovieFragmentModeTestOutput    SOURCENAME_AUTHOR_PREPEND_STRING"movieFragmentFileTest.mp4"
-#define KYUVAMRTEXTInputAVTMp4TestOutput SOURCENAME_AUTHOR_PREPEND_STRING"yuv_amr_text_test.mp4"
-#define KYUVTEXTInputMp4TestOutput       SOURCENAME_AUTHOR_PREPEND_STRING"yuv_text_test.mp4"
-#define KAMRTEXTInputMp4TestOutput       SOURCENAME_AUTHOR_PREPEND_STRING"amr_text_test.mp4"
-#define KTEXTInputMp4TestOutput          SOURCENAME_AUTHOR_PREPEND_STRING"text_test.mp4"
+#define KAMRInputAOnly3gpTestOutput _STRLIT("amr_in_a_only_test.3gp")
+#define KAMRInputAOnlyMp4TestOutput _STRLIT("amr_in_a_only_test.3gp")
+#define KH263InputVOnly3gpTestOutput _STRLIT("h263_in_v_only_test.3gp")
+#define KAMRYUVInputAV3gpTestOutput _STRLIT("amr_yuv_in_av_test.3gp")
+#define KAMRH263InputAV3gpTestOutput _STRLIT("amr_h263_in_av_test.3gp")
+#define KAMRYUVInputAVMp4TestOutput _STRLIT("amr_yuv_in_av_test.3gp")
+#define KAMRM4VInputAVMp4TestOutput _STRLIT("amr_m4v_in_av_test.3gp")
+#define KFOAOnlyAMRTestOutput _STRLIT("amr_testoutput.amr")
+#define KFOAOnlyAACADIFTestOutput _STRLIT("aac_adif_output.aac")
+#define KFOAOnlyAACADTSTestOutput _STRLIT("aac_adts_output.aac")
+#define KH264AMRInputAVMp4TestTestOutput _STRLIT("h264_amr_in_av_test.3gp")
+#define KYUVAMRTEXTInputAVTMp4TestOutput _STRLIT("yuv_amr_text_test.3gp")
+#define KYUVTEXTInputMp4TestOutput _STRLIT("yuv_text_test.3gp")
+#define KAMRTEXTInputMp4TestOutput _STRLIT("amr_text_test.3gp")
+#define KTEXTInputMp4TestOutput _STRLIT("text_test.3gp")
 //Error Handling TestCases
-#define KYUVTestInputWrong					SOURCENAME_AUTHOR_PREPEND_STRING"yuvtestinput_wrong.yuv"
-#define KTEXTTestInputWrong					SOURCENAME_AUTHOR_PREPEND_STRING"texttestinput_wrong.txt"
-//specify wrong path
-#define KAMRYUVInputAV3gpTestOutputWrong	SOURCENAME_AUTHOR_PREPEND_STRING"../../../test_input_wrong/amr_yuv_in_av_test.3gp"
-#define KAMRTestInputWrong					SOURCENAME_AUTHOR_PREPEND_STRING"amrtestinput_wrong.amr"
+#define KTEXTTestInputWrong					_STRLIT("texttestinput_wrong.txt")
 
-#define DEFAULTSOURCEFILENAME				"testinput.avi"
-#define DEFAULTSOURCEFORMATTYPE			  	PVMF_AVIFF
-#define DEFAULTOUTPUTFILENAME				"testoutput.mp4"
+#define DEFAULTSOURCEFILENAME						"testinput.avi"
+#define DEFAULTSOURCEFORMATTYPE							PVMF_MIME_AVIFF
+#define DEFAULTOUTPUTFILENAME						"testoutput.3gp"
+#define DEFAULTOUTPUT_3GP_FILENAME						"testoutput.3gp"
 
-#define FILE_NAME_ERROR_HANDLING			"testinput_rgb16.avi"
-#define WRONGIPFILENAME_ERRORHANDLING		"/wrongdir/testinput.avi"
+//YUV test through AVI file
+#define KYUV_AVI_VIDEO_ONLY							"videoonly.avi"
+#define KPCM_AVI_AUDIO_ONLY							"audioonly.wav"
+#define KPCM_YUV_AVI_FILENAME						"testoutput_IYUV_8k_16_mono.avi"
+#define KMediaInput_Open_RealTimeCompose_Output		"mediainput_open_realtimecompose.3gp"
+//YUV & PCM test output files
+#define KYUV_VOnly_3GPP_Output						"Yuv_VideoOnly_Output.3gp"
+#define KPCM_AOnly_3GPP_Output						"Pcm_AudioOnly_Output.3gp"
+#define KPCM_YUV_AV_3GPP_Output						"Pcm_Yuv_AV_Output.3gp"
+#define KYUV_VOnly_MP4_Output						"Yuv_VideoOnly_Output.3gp"
+#define KH264_VOnly_MP4_Output						"H264_VideoOnly_Output.3gp"
+#define KPCM_AOnly_MP4_Output						"Pcm_AudioOnly_Output.3gp"
+#define KPCM_YUV_AV_MP4_Output						"Pcm_Yuv_AV_Output.3gp"
+#define KPCM16_AMR_TestOutput						"pcm_testoutput.amr"
+
+#define KMaxFileSizeTestOutput						"maxfilesize_test.3gp"
+#define KMaxFileSize_long_Output					"maxfilesize_long_output.3gp"
+
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+#define KIMOTIONAUTHORINGMODE_OUTPUT				"IMotionAuthoring_output.3gp"
+#define KIMOTIONDOWNLOADMODE_OUTPUT					"IMotionDownloadAuthoring_output.3gp"
+#define KIMOTIONAUTHORINGMODE_Long_OUTPUT			"IMotionAuthoring_long_test.3gp"
+#define KIMOTIONDOWNLOADMODE_Long_OUTPUT				"IMotionDownloadAuthoring_long_test.3gp"
+#endif
+
+#define K3GPPDOWNLOADMODE_OUTPUT					"3GPPDownloadAuthoring_output.3gp"
+#define K3GPPPROGRESSIVEDOWNLOADMODE_OUTPUT			"3GPPProgressiveDownloadAuthoring_output.3gp"
+#define KMOVIEFRAGMENTMODE_OUTPUT					"MovieFragment_output.3gp"
+#define KCAPCONFIG_OUTPUT							"CapConfig_TestOutput.3gp"
+#define KAVI_Input_Long_OUTPUT						"Avi_Input_long_output.3gp"
+#define K3GPPDOWNLOADMODE_Long_OUTPUT				"3GPPDownloadAuthoring_long_test.3gp"
+#define K3GPPPROGRESSIVEDOWNLOADMODE_Long_OUTPUT		"3GPPProgressiveDownloadAuthoring_long_test.3gp"
+#define KMOVIEFRAGMENTMODE_Long_OUTPUT				"movieFragmentFileTestlong_.3gp"
+#define FILE_NAME_ERROR_HANDLING					"testinput_rgb16.avi"
+#define WRONGIPFILENAME_ERRORHANDLING				"wrongdir/testinput.avi"
+#define WRONGOPFILENAME_ERRORHANDLING				"pvaetest_wrong/testoutput.3gp"
 #endif // TEST_PV_AUTHOR_ENGINE_CONFIG_H_INCLUDED
 
 
diff --git a/engines/author/test/src/pvaetest.cpp b/engines/author/test/src/pvaetest.cpp
index 213d3a1..69dd173 100644
--- a/engines/author/test/src/pvaetest.cpp
+++ b/engines/author/test/src/pvaetest.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,18 +31,18 @@
 #include "test_pv_author_engine_testset1.h"
 #endif
 
-#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET2_H_INCLUDED
-#include "test_pv_author_engine_testset2.h"
-#endif
-
-#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET3_H_INCLUDED
-#include "test_pv_author_engine_testset3.h"
-#endif
-
 #ifndef TEST_PV_AUTHOR_ENGINE_TESTSET4_H_INCLUDED
 #include "test_pv_author_engine_testset4.h"
 #endif
 
+#ifndef TEST_PV_MEDIAINPUT_AUTHOR_ENGINE_H
+#include "test_pv_mediainput_author_engine.h"
+#endif
+
+#ifdef USE_OMX_ENC_NODE
+#include "omx_core.h"
+#endif
+
 FILE* file;
 
 // Default input settings
@@ -74,20 +74,20 @@
 const uint32 KTestDuration = 10; // for 10 sec
 
 // it's for setting Authoring Time Unit for selecting counter loop
-// this time unit is used as default authoring time for longetivity tests
-const uint32 KAuthoringSessionUnit = 1800; //in seconds
+// this time unit is used as default authoring time for longetivity test
+const uint32 KAuthoringSessionUnit = 60; //in seconds
 const uint32 KPauseDuration = 5000000; // microseconds
 
+#define MAXLINELENGTH 200
+
 ////////////////////////////////////////////////////////////////////////////
 
-PVAuthorEngineTest::PVAuthorEngineTest(FILE* aStdOut, int32 aLogFile, int32 aLogLevel, int32 aLogNode,
-                                       int32 aFirstTest, int32 aLastTest,
+PVAuthorEngineTest::PVAuthorEngineTest(FILE* aStdOut, int32 aFirstTest, int32 aLastTest,
                                        const char* aInputFileNameAudio, const char* aInputFileNameVideo, const char* aInputFileNameText, const char* aOutputFileName, AVTConfig aAVTConfig,
                                        PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,  PVAETestInputType aTextInputType,
                                        const char* aComposerMimeType, const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType,  const char* aTextEncoderMimeType, uint32 aAuthoringTime):
 
         iCurrentTest(NULL),
-        PVLoggerSchedulerSetup(aLogFile, aLogLevel, aLogNode),
         iFirstTest(aFirstTest),
         iLastTest(aLastTest),
         iNextTestCase(aFirstTest),
@@ -128,6 +128,7 @@
     {
         iOutputFileName.set(aOutputFileName, oscl_strlen(aOutputFileName));
     }
+
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -159,16 +160,8 @@
                 MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
                 if (stats)
                 {
-                    uint32 alloclks = stats->numAllocs - iNumAllocs;
                     fprintf(file, "  Mem stats: TotalAllocs(%d), TotalBytes(%d),\n             AllocFailures(%d), AllocLeak(%d)\n",
                             stats->totalNumAllocs - iTotalAlloc, stats->totalNumBytes - iTotalBytes, stats->numAllocFails - iAllocFails, stats->numAllocs - iNumAllocs);
-#if 0 //debug
-                    if (alloclks != 0)
-                    {
-                        alloclks++;
-                        alloclks--;
-                    }
-#endif
                 }
                 else
                 {
@@ -206,26 +199,41 @@
             fprintf(file, "Memory audit not available! Memory statistics result would be invalid.\n");
         }
 #endif
-        //skip the placeholders and empty ranges.
-        if ((iNextTestCase == K3GP_OUTPUT_TestEnd) || (iNextTestCase == MP4_OUTPUT_TestEnd)
-                || (iNextTestCase == AMR_OUTPUT_TestEnd) || (iNextTestCase == AAC_OUTPUT_TestEnd)
-                || (iNextTestCase == GenericTestBegin) || (iNextTestCase == GenericTestEnd)
-                || (iNextTestCase == LongetivityTestBegin) || (iNextTestCase == K3GP_OUTPUT_LongetivityTestEnd)
-                || (iNextTestCase == MP4_OUTPUT_LongetivityTestEnd) || (iNextTestCase == AMR_OUTPUT_LongetivityTestEnd)
-                || (iNextTestCase == AAC_OUTPUT_LongetivityTestEnd) || (NormalTestEnd == iNextTestCase))
-        {
-            iNextTestCase++;//go to next test
-        }
-
-        //stop at last test of selected range.
         if (iNextTestCase > iLastTest)
         {
             iNextTestCase = Invalid_Test;
         }
         else
         {
-            fprintf(file, "\nStarting Test %d: ", iNextTestCase);
-            InitLoggerScheduler();
+            //skip the placeholders and empty ranges.
+            if ((iNextTestCase == K3GP_OUTPUT_TestEnd)
+                    || (iNextTestCase == AMR_OUTPUT_TestEnd) || (iNextTestCase == AAC_OUTPUT_TestEnd)
+                    || (iNextTestCase == CompressedLongetivityTestBegin) || (CompressedNormalTestEnd == iNextTestCase)
+                    || (iNextTestCase == KCompressed_Errorhandling_TestBegin))
+            {
+                fprintf(file, "\nPlace Holder Not actual testcase %d: ", iNextTestCase);
+                iNextTestCase++;//go to next test
+            }
+            if ((iNextTestCase >= CompressedNormalTestEnd && iNextTestCase <= CompressedLongetivityTestBegin) && (iLastTest >= CompressedLongetivityTestBegin))
+            {
+                iNextTestCase = CompressedLongetivityTestBegin;
+                iNextTestCase++;
+            }
+
+            if ((iNextTestCase > CompressedNormalTestEnd) && (iLastTest < CompressedLongetivityTestBegin))
+            {
+                iNextTestCase = Invalid_Test;
+            }//stop at last test of selected range.
+            else if ((Compressed_LongetivityTestEnd == iNextTestCase) || (KCompressed_Errorhandling_TestEnd == iNextTestCase))
+            {
+                fprintf(file, "\nPlace Holder Not actual testcase %d: ", iNextTestCase);
+                iNextTestCase = Invalid_Test;
+            }
+            else
+            {
+                fprintf(file, "\nStarting Test %d: ", iNextTestCase);
+                InitLoggerScheduler();
+            }
         }
 
         RunTestCases();
@@ -235,6 +243,10 @@
             OsclExecScheduler *sched = OsclExecScheduler::Current();
             if (sched)
             {
+                uint32 currticks  = 0;
+                currticks = OsclTickCount::TickCount();
+                uint32 starttime = OsclTickCount::TicksToMsec(currticks);
+
                 iCurrentTest->StartTest();
 #if USE_NATIVE_SCHEDULER
                 // Have PV scheduler use the scheduler native to the system
@@ -243,6 +255,10 @@
                 int32 err;
                 OSCL_TRY(err, sched->StartScheduler(););
 #endif
+                currticks = OsclTickCount::TickCount();
+                uint32 endtime = OsclTickCount::TicksToMsec(currticks);
+                fprintf(file, "  Time taken by the test:  %d\n", (endtime - starttime));
+
             }
             else
             {
@@ -263,7 +279,6 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-
 // Normal test set
 void PVAuthorEngineTest::RunTestCases()
 {
@@ -281,38 +296,14 @@
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
-        case AMR_Input_AOnly_Mp4Test:
-            fprintf(iStdOut, "AMR to A-Only .mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case YUV_Input_VOnly_3gpTest:
-            fprintf(iStdOut, "YUV to V-Only .3gp Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
         case H263_Input_VOnly_3gpTest:
             fprintf(iStdOut, "H263 to V-Only .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
-        case H264_Input_VOnly_Mp4Test:
-            fprintf(iStdOut, "H264 to V-Only .mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case H264_AMR_Input_AV_Mp4Test:
-            fprintf(iStdOut, "H264 & AMR to AV .mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case YUV_Input_VOnly_Mp4Test:
-            fprintf(iStdOut, "YUV to V-Only .mp4 Test\n");
+        case H264_AMR_Input_AV_3gpTest:
+            fprintf(iStdOut, "H264 & AMR to AV .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
@@ -329,8 +320,8 @@
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
-        case AMR_YUV_Input_AV_Mp4Test:
-            fprintf(iStdOut, "AMR & YUV to AV .mp4 Test\n");
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
+            fprintf(iStdOut, "AMR & YUV to AV using M4V Encoder .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
@@ -353,271 +344,57 @@
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
-        case KMaxFileSizeTest:
-
-            fprintf(iStdOut, "Max FileSize test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case KMaxDurationTest:
-            fprintf(iStdOut, "Max Duration test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case KFileSizeProgressTest:
-            fprintf(iStdOut, "FileSizeProgress test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case KDurationProgressTest:
-            fprintf(iStdOut, "DurationProgress test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case PCM16In_AMROut_Test:
-            fprintf(iStdOut, "PCM16 to .amr Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case PCM16_Input_AOnly_3gpTest:
-            fprintf(iStdOut, "PCM16 to A-Only .3gp Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case PCM16_Input_AOnly_Mp4Test:
-            fprintf(iStdOut, "PCM16 to A-Only .mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case PCM16_YUV_Input_AV_3gpTest:
-            fprintf(iStdOut, "PCM16 & YUV to AV .3gp Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case PCM16_YUV_Input_AV_Mp4Test:
-            fprintf(iStdOut, "PCM16 & YUV to AV .mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case KFastTrackContentModeTest:
-            fprintf(iStdOut, "FastTrackContentModeTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case K3GPPDownloadModeTest:
-            fprintf(iStdOut, "K3GPPDownloadModeTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case K3GPPProgressiveDownloadModeTest:
-            fprintf(iStdOut, "3GPPProgressiveDownloadModeTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case Pause_Resume_Test:
-            fprintf(iStdOut, "Pause_Resume_Test");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, true, KTestDuration);
-            break;
-
-        case KMovieFragmentModeTest:
-            fprintf(iStdOut, "Movie Fragment Mode Test \n ");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case ErrorHandling_WrongInputFormatTest:
-            fprintf(iStdOut, "ErrorHandling_WrongInputFormatTest Test\n");
-            iCurrentTest = new pvauthor_async_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case ErrorHandling_WrongVideoInputFileNameTest:
-            fprintf(iStdOut, "ErrorHandling_WrongVideoInputFileNameTest Test\n");
-            iCurrentTest = new pvauthor_async_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
-        case ErrorHandling_WrongAudioInputFileNameTest:
-            fprintf(iStdOut, "ErrorHandling_WrongAudioInputFileNameTest Test\n");
-            iCurrentTest = new pvauthor_async_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
-            break;
         case ErrorHandling_WrongTextInputFileNameTest:
             fprintf(iStdOut, "ErrorHandling_WrongTextInputFileNameTest Test\n");
-            iCurrentTest = new pvauthor_async_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
+            iCurrentTest = new pvauthor_async_compressed_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
+                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration, ERROR_NOSTATE);
             break;
         case ErrorHandling_WrongOutputPathTest:
             fprintf(iStdOut, "ErrorHandling_WrongOutputPathTest Test\n");
-            iCurrentTest = new pvauthor_async_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
+            iCurrentTest = new pvauthor_async_compressed_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
+                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration, ERROR_NOSTATE);
             break;
-        case TEXT_Input_TOnly_Mp4Test:
-            fprintf(iStdOut, "TEXT Only .mp4 Test\n");
+
+        case ErrorHandling_MediaInputNodeStartFailed:
+            fprintf(iStdOut, "ErrorHandling_MediaInputNodeStartFailed Test\n");
+#ifndef _TEST_AE_ERROR_HANDLING
+            fprintf(iStdOut, "test not implemented\n");
+            iCurrentTest = NULL;
+            break;
+#else
+            iCurrentTest = new pvauthor_async_compressed_test_errorhandling(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
+                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
+                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration, ERROR_MEDIAINPUTNODE_ADDDATASOURCE_START);
+            break;
+#endif
+        case TEXT_Input_TOnly_3gpTest:
+            fprintf(iStdOut, "TEXT Only .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
-        case AMR_TEXT_Input_AT_Mp4Test:
-            fprintf(iStdOut, "AMR/TEXT .mp4 Test\n");
+        case AMR_TEXT_Input_AT_3gpTest:
+            fprintf(iStdOut, "AMR/TEXT .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
-        case YUV_TEXT_Input_VT_Mp4Test:
-            fprintf(iStdOut, "YUV/TEXT .mp4 Test\n");
+        case YUV_TEXT_Input_VT_3gpTest:
+            fprintf(iStdOut, "YUV/TEXT .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
-            fprintf(iStdOut, "YUV/AMR/TEXT .mp4 Test\n");
+            fprintf(iStdOut, "YUV/AMR/TEXT .3gp Test\n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
                     (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, KTestDuration);
             break;
 
-        case Generic_Open_Reset_Test:
-            fprintf(iStdOut, "Generic_Open_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_OPEN);
-            break;
-
-        case Generic_AddDataSource_Audio_Reset_Test:
-            fprintf(iStdOut, "Generic_AddDataSource_Audio_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_ADD_DATA_SOURCE_AUDIO);
-            break;
-        case Generic_AddDataSource_Video_Reset_Test:
-            fprintf(iStdOut, "Generic_AddDataSource_Video_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_ADD_DATA_SOURCE_VIDEO);
-            break;
-        case Generic_AddDataSource_Text_Reset_Test:
-            fprintf(iStdOut, "Generic_AddDataSource_Text_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_ADD_DATA_SOURCE_TEXT);
-            break;
-        case Generic_SelectComposer_Reset_Test:
-            fprintf(iStdOut, "Generic_SelectComposer_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_SELECT_COMPOSER);
-            break;
-
-        case Generic_QueryInterface_Reset_Test:
-            fprintf(iStdOut, "Generic_QueryInterface_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_QUERY_INTERFACE);
-            break;
-
-        case Generic_Add_Audio_Media_Track_Reset_Test:
-            fprintf(iStdOut, "Generic_Add_Audio_Media_Track_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_ADD_AUDIO_MEDIA_TRACK);
-            break;
-
-        case Generic_Add_Video_Media_Track_Reset_Test:
-            fprintf(iStdOut, "Generic_Add_Video_Media_Track_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_ADD_VIDEO_MEDIA_TRACK);
-            break;
-
-        case Generic_Add_Text_Media_Track_Reset_Test:
-            fprintf(iStdOut, "Generic_Add_Text_Media_Track_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_ADD_TEXT_MEDIA_TRACK);
-            break;
-
-        case Generic_Init_Reset_Test:
-            fprintf(iStdOut, "Generic_Init_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_INIT);
-            break;
-
-        case Generic_Start_Reset_Test:
-            fprintf(iStdOut, "Generic_Start_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_START);
-            break;
-
-        case Generic_Pause_Reset_Test:
-            fprintf(iStdOut, "Generic_Pause_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, true, PVAE_CMD_PAUSE);
-            break;
-
-
-        case Generic_Resume_Reset_Test:
-            fprintf(iStdOut, "Generic_Resume_Reset_Test test \n");
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, true, PVAE_CMD_RESUME);
-            break;
-
-        case Input_Stream_Looping_Test:
-        {
-            fprintf(iStdOut, "Input_Stream_Looping_Test\n");
-            iAVTConfig.iLoopingEnable = true;
-            iCurrentTest = new pvauthor_async_test_generic_reset(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, PVAE_CMD_NONE);
-        }
-        break;
-        case CapConfigTest:
-            fprintf(iStdOut, "CapConfigTest test \n");
-            iCurrentTest = new pvauthor_async_test_capconfig(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iAVTConfig, true);
-            break;
-
             // longetivity test
-        case AMR_Input_AOnly_3gp_LongetivityTest:
-            fprintf(iStdOut, "AMR_Input_AOnly_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-        case YUV_Input_VOnly_3gp_LongetivityTest:
-            fprintf(iStdOut, "YUV_Input_VOnly_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-        case H263_Input_VOnly_3gp_LongetivityTest:
-            fprintf(iStdOut, "H263_Input_VOnly_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
 
         case TEXT_Input_TOnly_3gp_LongetivityTest:
             fprintf(iStdOut, "TEXT_Input_TOnly_3gp_LongetivityTest test \n");
@@ -626,20 +403,6 @@
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
             break;
 
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-            fprintf(iStdOut, "AMR_YUV_Input_AV_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
-            fprintf(iStdOut, "AMR_H263_Input_AV_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
             fprintf(iStdOut, "AMR_TEXT_Input_AT_3gp_LongetivityTest test \n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
@@ -647,20 +410,6 @@
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
             break;
 
-        case PCM16_Input_AOnly_3gp_LongetivityTest:
-            fprintf(iStdOut, "PCM16_Input_AOnly_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-            fprintf(iStdOut, "PCM16_YUV_Input_AV_3gp_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
         case YUV_TEXT_Input_VT_3gp_LongetivityTest:
             fprintf(iStdOut, "YUV_TEXT_Input_VT_3gp_LongetivityTest test \n");
             iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
@@ -675,137 +424,8 @@
                     iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
             break;
 
-        case KMaxFileSizeLongetivityTest:
-            fprintf(iStdOut, "KMaxFileSizeLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case KMaxDurationLongetivityTest:
-            fprintf(iStdOut, "KMaxDurationLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-
-        case KFileSizeProgressLongetivityTest:
-            fprintf(iStdOut, "KFileSizeProgressLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case KDurationProgressLongetivityTest:
-            fprintf(iStdOut, "KFileSizeProgressLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case KFastTrackContentModeLongetivityTest:
-            fprintf(iStdOut, "KFastTrackContentModeLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case K3GPPDownloadModeLongetivityTest:
-            fprintf(iStdOut, "K3GPPDownloadModeLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case K3GPPProgressiveDownloadModeLongetivityTest:
-            fprintf(iStdOut, "K3GPPProgressiveDownloadModeLongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-            //mp4 output file
-        case H264_Input_VOnly_Mp4_LongetivityTest:
-            fprintf(iStdOut, "H264 to V-Only Longetivity mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
-            fprintf(iStdOut, "H264 & AMR to AV Longetivity .mp4 Test\n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(), iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-        case AMR_Input_AOnly_Mp4_LongetivityTest:
-            fprintf(iStdOut, "AMR_Input_AOnly_Mp4_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case YUV_Input_VOnly_Mp4_LongetivityTest:
-            fprintf(iStdOut, "YUV_Input_VOnly_Mp4_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
-            fprintf(iStdOut, "AMR_YUV_Input_AV_Mp4_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case PCM16_Input_AOnly_Mp4_LongetivityTest:
-            fprintf(iStdOut, "PCM16_Input_AOnly_Mp4_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
-            fprintf(iStdOut, "PCM16_YUV_Input_AV_Mp4_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-            //amr output file
-        case AMR_FOutput_LongetivityTest:
-            fprintf(iStdOut, "AMR_FOutput_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case PCM16In_AMROut_LongetivityTest:
-            fprintf(iStdOut, "PCM16In_AMROut_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-            //aac output file
-        case AACADIF_FOutput_LongetivityTest:
-            fprintf(iStdOut, "AACADIF_FOutput_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
-        case AACADTS_FOutput_LongetivityTest:
-            fprintf(iStdOut, "AACADTS_FOutput_LongetivityTest test \n");
-            iCurrentTest = new pvauthor_async_test_miscellaneous(testparam, (const char*)iInputFileNameAudio.get_cstr(), (const char*)iInputFileNameVideo.get_cstr(), (const char*)iInputFileNameText.get_cstr(),
-                    (const char*)iOutputFileName.get_cstr(), iAudioInputType, iVideoInputType, iTextInputType,
-                    iComposerMimeType.get_cstr(), iAudioEncoderMimeType.get_cstr(), iVideoEncoderMimeType.get_cstr(),  iTextEncoderMimeType.get_cstr(), iAVTConfig, false, iAuthoringTime);
-            break;
-
         default:
             iCurrentTest = NULL;
-            iNextTestCase = Invalid_Test;
             break;
     }
 }
@@ -971,6 +591,75 @@
     return false;
 }
 
+//This functions finds the name of AVIConfigFile from command line specified with switch -aviconfigfile <filename>
+//Returns true if filename found, false otherwise
+bool FindAVIConfigFile(cmd_line* aCommandLine, OSCL_HeapString<OsclMemAllocator>& aFileNameAVIConfig, FILE *aFile)
+{
+    OSCL_UNUSED_ARG(aFile);
+    int	iFileArgument = 0;
+    bool iFileFound = false;
+    bool cmdline_iswchar = aCommandLine->is_wchar();
+
+    int count = aCommandLine->get_count();
+
+    // Search for the "-aviconfigfile" argument
+    // go through the each argument
+
+    for (int iFileSearch = 0; iFileSearch < count; iFileSearch++)
+    {
+        char argstr[128];
+        // Convert to UTF8 if necessary
+        if (cmdline_iswchar)
+        {
+            oscl_wchar* argwstr = NULL;
+            aCommandLine->get_arg(iFileSearch, argwstr);
+            oscl_UnicodeToUTF8(argwstr, oscl_strlen(argwstr), argstr, 128);
+            argstr[127] = '\0';
+        }
+        else
+        {
+            char* tmpstr = NULL;
+            aCommandLine->get_arg(iFileSearch, tmpstr);
+            int32 tmpstrlen = oscl_strlen(tmpstr) + 1;
+            if (tmpstrlen > 128)
+            {
+                tmpstrlen = 128;
+            }
+            oscl_strncpy(argstr, tmpstr, tmpstrlen);
+            argstr[tmpstrlen-1] = '\0';
+        }
+
+        // Do the string compare
+        if (oscl_strcmp(argstr, "-aviconfigfile") == 0)
+        {
+            iFileFound = true;
+            iFileArgument = ++iFileSearch;
+            break;
+        }
+    }
+
+    if (iFileFound)
+    {
+        // Convert to UTF8 if necessary
+        if (cmdline_iswchar)
+        {
+            oscl_wchar* cmd;
+            aCommandLine->get_arg(iFileArgument, cmd);
+            char tmpstr[256];
+            oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), tmpstr, 256);
+            tmpstr[255] = '\0';
+            aFileNameAVIConfig = tmpstr;
+        }
+        else
+        {
+            char* cmdlinefilename = NULL;
+            aCommandLine->get_arg(iFileArgument, cmdlinefilename);
+            aFileNameAVIConfig = cmdlinefilename;
+        }
+        return true;
+    }
+    return false;
+}
 
 //This functions finds the name of audio input file from command line specified with switch -audio <filename>
 //Sets the name of audio input file in reference parameter
@@ -1308,7 +997,7 @@
         // Do the string compare
         if (oscl_strcmp(argstr, "-help") == 0)
         {
-            fprintf(aFile, "Output specification option. Default is testoutput.mp4\n");
+            fprintf(aFile, "Output specification option.\n");
             fprintf(aFile, "  -output outputname\n");
             fprintf(aFile, "   Specify the output filename to use for test cases which\n");
             fprintf(aFile, "   allow user-specified source name. \n\n");
@@ -1349,7 +1038,7 @@
 //Find test range args:
 //To run a range of tests by enum ID:
 //  -test 17 29
-//if -test is not specified in the command line, it assumes running tests from 0 to NormalTestEnd-1
+//if -test is not specified in the command line, it assumes running tests from 0 to CompressedNormalTestEnd-1
 void FindTestRange(cmd_line *aCommandLine,	int32 &iFirstTest, int32 &iLastTest, FILE *aFile)
 {
     //default is to run all tests.
@@ -1534,10 +1223,10 @@
             }
         }
     }
-    else //-test arg not given, assuming run tests from 0 to NormalTestEnd-1
+    else //-test arg not given, assuming run tests from 0 to CompressedNormalTestEnd-1
     {
         iFirstTest = 0;
-        iLastTest = NormalTestEnd - 1;
+        iLastTest = CompressedNormalTestEnd - 1;
     }
 
     if (cmdline_iswchar)
@@ -1562,200 +1251,6 @@
     }
 }
 
-//Find the name of logger nodes from the command line switch Eg, -logall. Please see help below
-//to find all the logger nodes that can be specified.
-void FindLoggerNode(cmd_line* aCommandLine, int32& lognode, FILE* aFile)
-{
-    //default is log player engine.
-    lognode = 0;
-
-    bool cmdline_iswchar = aCommandLine->is_wchar();
-
-    int count = aCommandLine->get_count();
-
-    // Search for the "-logerr"/"-logwarn" argument
-    char *SourceFind = NULL;
-    if (cmdline_iswchar)
-    {
-        SourceFind = new char[256];
-    }
-
-    // Go through each argument
-    for (int iTestSearch = 0; iTestSearch < count; iTestSearch++)
-    {
-        // Convert to UTF8 if necessary
-        if (cmdline_iswchar)
-        {
-            OSCL_TCHAR* cmd = NULL;
-            aCommandLine->get_arg(iTestSearch, cmd);
-            oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), SourceFind, 256);
-        }
-        else
-        {
-            SourceFind = NULL;
-            aCommandLine->get_arg(iTestSearch, SourceFind);
-        }
-
-        // Do the string compare
-        if (oscl_strcmp(SourceFind, "-help") == 0)
-        {
-            fprintf(aFile, "Log node options. Default is player engine only:\n");
-            fprintf(aFile, "  -logall\n");
-            fprintf(aFile, "   Log everything (log appender at root node)\n");
-            fprintf(aFile, "  -logdatapath\n");
-            fprintf(aFile, "   Log datapath only\n");
-            fprintf(aFile, "  -logclock\n");
-            fprintf(aFile, "   Log clock only\n");
-            fprintf(aFile, "  -logoscl\n");
-            fprintf(aFile, "   Log OSCL only\n");
-            fprintf(aFile, "  -logperf\n");
-            fprintf(aFile, "   Log scheduler performance\n");
-            fprintf(aFile, "  -logosclfileio\n");
-            fprintf(aFile, "   Log oscl fileio only\n\n");
-        }
-        else if (oscl_strcmp(SourceFind, "-logall") == 0)
-        {
-            lognode = 1;		//log everything
-        }
-        else if (oscl_strcmp(SourceFind, "-logdatapath") == 0)
-        {
-            lognode = 2;		//datapath only
-        }
-        else if (oscl_strcmp(SourceFind, "-logclock") == 0)
-        {
-            lognode = 3;		//clock only
-        }
-        else if (oscl_strcmp(SourceFind, "-logoscl") == 0)
-        {
-            lognode = 4;		//oscl only
-        }
-        else if (oscl_strcmp(SourceFind, "-logperf") == 0)
-        {
-            lognode = 5;		//scheduler perf logging
-        }
-        else if (oscl_strcmp(SourceFind, "-logosclfileio") == 0)
-        {
-            lognode = 6;		//oscl fileio
-        }
-        else if (oscl_strcmp(SourceFind, "-logdiagnostics") == 0)
-        {
-            lognode = 7;
-        }
-    }
-
-    if (cmdline_iswchar)
-    {
-        delete[] SourceFind;
-        SourceFind = NULL;
-    }
-}
-
-//Find the loglevel for logging. Specify -logerr or -logwarn for setting those loglevels
-void FindLogLevel(cmd_line* aCommandLine, int32& loglevel, FILE* aFile)
-{
-    //default is verbose
-    loglevel = PVLOGMSG_DEBUG;
-
-    bool cmdline_iswchar = aCommandLine->is_wchar();
-
-    int count = aCommandLine->get_count();
-
-    // Search for the "-logerr"/"-logwarn" argument
-    char *SourceFind = NULL;
-    if (cmdline_iswchar)
-    {
-        SourceFind = new char[256];
-    }
-
-    // Go through each argument
-    for (int iTestSearch = 0; iTestSearch < count; iTestSearch++)
-    {
-        // Convert to UTF8 if necessary
-        if (cmdline_iswchar)
-        {
-            OSCL_TCHAR* cmd = NULL;
-            aCommandLine->get_arg(iTestSearch, cmd);
-            oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), SourceFind, 256);
-        }
-        else
-        {
-            SourceFind = NULL;
-            aCommandLine->get_arg(iTestSearch, SourceFind);
-        }
-
-        // Do the string compare
-        if (oscl_strcmp(SourceFind, "-help") == 0)
-        {
-            fprintf(aFile, "Log level options. Default is debug level:\n");
-            fprintf(aFile, "  -logerr\n");
-            fprintf(aFile, "   Log at error level\n");
-            fprintf(aFile, "  -logwarn\n");
-            fprintf(aFile, "   Log at warning level\n\n");
-        }
-        else if (oscl_strcmp(SourceFind, "-logerr") == 0)
-        {
-            loglevel = PVLOGMSG_ERR;
-        }
-        else if (oscl_strcmp(SourceFind, "-logwarn") == 0)
-        {
-            loglevel = PVLOGMSG_WARNING;
-        }
-    }
-
-    if (cmdline_iswchar)
-    {
-        delete[] SourceFind;
-        SourceFind = NULL;
-    }
-}
-
-//Find the command line switch for logging to file. Use -logfile for logging to file, else
-//log to stdout will be used
-void FindLogText(cmd_line* aCommandLine, int32& logtext, FILE* aFile)
-{
-    OSCL_UNUSED_ARG(aFile);
-    logtext = false;
-
-    bool cmdline_iswchar = aCommandLine->is_wchar();
-
-    int count = aCommandLine->get_count();
-
-    char *SourceFind = NULL;
-    if (cmdline_iswchar)
-    {
-        SourceFind = new char[256];
-    }
-
-    // Go through each argument
-    for (int iTestSearch = 0; iTestSearch < count; iTestSearch++)
-    {
-        // Convert to UTF8 if necessary
-        if (cmdline_iswchar)
-        {
-            OSCL_TCHAR* cmd = NULL;
-            aCommandLine->get_arg(iTestSearch, cmd);
-            oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), SourceFind, 256);
-        }
-        else
-        {
-            SourceFind = NULL;
-            aCommandLine->get_arg(iTestSearch, SourceFind);
-        }
-
-        // Do the string compare
-        if (oscl_strcmp(SourceFind, "-logfile") == 0)
-        {
-            logtext = 1;
-        }
-    }
-
-    if (cmdline_iswchar)
-    {
-        delete[] SourceFind;
-        SourceFind = NULL;
-    }
-}
-
 //Look for switch to print mem leaks at the end of test. Use switch -leakinfo for finding memory leaks
 void FindMemMgmtRelatedCmdLineParams(cmd_line* aCommandLine, bool& aPrintDetailedMemLeakInfo, FILE* aFile)
 {
@@ -1930,9 +1425,63 @@
     return true;
 }
 
+//This function is used to read the AVIconfigfile and set the MediaInputTestParam structure
+bool LoadAVIConfiguration(OSCL_HeapString<OsclMemAllocator>& aAVIConfigFileName, PVMediaInputAuthorEngineTestParam& aTestParam, FILE* aFile)
+{
+    OSCL_UNUSED_ARG(aFile);
+    char maxLine[200] = "\0";
+    Oscl_FileServer iFileServer;
+    Oscl_File fileConfig;
+
+    iFileServer.Connect();
+
+    if (fileConfig.Open(aAVIConfigFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, iFileServer) != 0)
+    {
+        return false;
+    }
+
+    while (fgetline(&fileConfig, maxLine, MAXLINELENGTH) != EOF)
+    {
+        // retrieve video bitrate
+        if (oscl_CIstrncmp(maxLine, "videobitrate", oscl_strlen("videobitrate")) == 0)
+        {
+            char* pcPtr = oscl_strchr(maxLine, ':');
+            pcPtr++;
+            PV_atoi(pcPtr, '0', (uint32&)aTestParam.iMediainputParam.iVideoBitrate);
+        }
+        // retrieve Audio bitrate
+        if (oscl_CIstrncmp(maxLine, "audiobitrate", oscl_strlen("audiobitrate")) == 0)
+        {
+            char* pcPtr = oscl_strchr(maxLine, ':');
+            pcPtr++;
+            PV_atoi(pcPtr, '0', (uint32&)aTestParam.iMediainputParam.iAudioBitrate);
+        }
+
+        // retrieve Sampling rate
+        if (oscl_CIstrncmp(maxLine, "samplingrate", oscl_strlen("samplingrate")) == 0)
+        {
+            char* pcPtr = oscl_strchr(maxLine, ':');
+            pcPtr++;
+            PV_atoi(pcPtr, '0', (uint32&)aTestParam.iMediainputParam.iSamplingRate);
+        }
+        // retrieve framerate
+        if (oscl_CIstrncmp(maxLine, "framerate", oscl_strlen("framerate")) == 0)
+        {
+            char* pcPtr = oscl_strchr(maxLine, ':');
+            pcPtr++;
+            PV_atof(pcPtr, (OsclFloat&)aTestParam.iMediainputParam.iFrameRate);
+        }
+
+
+    }
+    fileConfig.Close();
+    iFileServer.Close();
+    return true;
+}
+
 //Depending on the Test Nos, check the validity of input and output files extensions as specified in command line
 //Also set the AVTConfig param by loading the contents of audio and video config files
-//This function is used only for Test No 0 to NormalTestEnd-1
+//This function is used only for Test No 0 to CompressedNormalTestEnd-1
 bool CheckSourceAndOutputFiles(cmd_line* aCommandLine, int32 firsttest, int32 lasttest, OSCL_HeapString<OsclMemAllocator> &aInputAudioFileName, OSCL_HeapString<OsclMemAllocator> &aInputVideoFileName, OSCL_HeapString<OsclMemAllocator> &aInputTextFileName, OSCL_HeapString<OsclMemAllocator> &aOutputFileName, AVTConfig aAVTConfig, OSCL_HeapString<OsclMemAllocator> &audioconfigfilename, OSCL_HeapString<OsclMemAllocator> &videoconfigfilename, FILE* file)
 {
     bool bAudioTest = false;//To track if the test is Audio
@@ -1943,36 +1492,13 @@
     {
         case AMR_FOutput_Test:
         case AMR_Input_AOnly_3gpTest:
-        case AMR_Input_AOnly_Mp4Test:
         case AMR_YUV_Input_AV_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
-        case AMR_YUV_Input_AV_Mp4Test:
-            //case AMR_M4V_Input_AV_Mp4Test:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case H264_AMR_Input_AV_Mp4Test:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
+        case H264_AMR_Input_AV_3gpTest:
             //Longetivity Tests
-        case AMR_FOutput_LongetivityTest:
-        case AMR_Input_AOnly_3gp_LongetivityTest:
-        case AMR_Input_AOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
-            //case AMR_M4V_Input_AV_Mp4_LongetivityTest:
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
             bAudioTest = true;
             if (!(oscl_strstr(aInputAudioFileName.get_cstr(), ".amr") != NULL || oscl_strstr(aInputAudioFileName.get_cstr(), ".AMR") != NULL))
             {
@@ -1981,7 +1507,6 @@
             }
             break;
         case AACADIF_FOutput_Test:
-        case AACADIF_FOutput_LongetivityTest:
             bAudioTest = true;
             if (!(oscl_strstr(aInputAudioFileName.get_cstr(), ".aacadif") != NULL || oscl_strstr(aInputAudioFileName.get_cstr(), ".AACADIF") != NULL))
             {
@@ -1990,7 +1515,6 @@
             }
             break;
         case AACADTS_FOutput_Test:
-        case AACADTS_FOutput_LongetivityTest:
             bAudioTest = true;
             if (!(oscl_strstr(aInputAudioFileName.get_cstr(), ".aacadts") != NULL || oscl_strstr(aInputAudioFileName.get_cstr(), ".AACADTS") != NULL))
             {
@@ -1998,23 +1522,6 @@
                 return false;
             }
             break;
-        case PCM16In_AMROut_Test:
-        case PCM16_Input_AOnly_3gpTest:
-        case PCM16_Input_AOnly_Mp4Test:
-        case PCM16_YUV_Input_AV_3gpTest:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case PCM16In_AMROut_LongetivityTest:
-        case PCM16_Input_AOnly_3gp_LongetivityTest:
-        case PCM16_Input_AOnly_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
-            bAudioTest = true;
-            if (!(oscl_strstr(aInputAudioFileName.get_cstr(), ".pcm") != NULL || oscl_strstr(aInputAudioFileName.get_cstr(), ".PCM") != NULL))
-            {
-                fprintf(file, "  Input Filename incorrect!!! TestNo:%d - %d needs Input File:-audio <xxx>.pcm\n\n", firsttest, lasttest);
-                return false;
-            }
-            break;
             //Used for generic testcases
         default:
             if (!(aInputAudioFileName == NULL))
@@ -2040,34 +1547,10 @@
     }
     switch (firsttest)
     {
-        case YUV_Input_VOnly_3gpTest:
-        case YUV_Input_VOnly_Mp4Test:
         case AMR_YUV_Input_AV_3gpTest:
-        case AMR_YUV_Input_AV_Mp4Test:
-        case PCM16_YUV_Input_AV_3gpTest:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case YUV_Input_VOnly_3gp_LongetivityTest:
-        case YUV_Input_VOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
         case YUV_TEXT_Input_VT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
             bVideoTest = true;
             if (!(oscl_strstr(aInputVideoFileName.get_cstr(), ".yuv") != NULL || oscl_strstr(aInputVideoFileName.get_cstr(), ".YUV") != NULL))
             {
@@ -2077,8 +1560,6 @@
             break;
         case H263_Input_VOnly_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
-        case H263_Input_VOnly_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
             bVideoTest = true;
             if (!(oscl_strstr(aInputVideoFileName.get_cstr(), ".h263") != NULL || oscl_strstr(aInputVideoFileName.get_cstr(), ".H263") != NULL))
             {
@@ -2086,10 +1567,7 @@
                 return false;
             }
             break;
-        case H264_Input_VOnly_Mp4Test:
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_Input_VOnly_Mp4_LongetivityTest:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
+        case H264_AMR_Input_AV_3gpTest:
             bVideoTest = true;
             if (!(oscl_strstr(aInputVideoFileName.get_cstr(), ".h264") != NULL || oscl_strstr(aInputVideoFileName.get_cstr(), ".H264") != NULL))
             {
@@ -2097,7 +1575,6 @@
                 return false;
             }
             break;
-
             //Used for generic testcases
         default:
             if (!(aInputVideoFileName == NULL))
@@ -2123,9 +1600,9 @@
     }
     switch (firsttest)
     {
-        case TEXT_Input_TOnly_Mp4Test:
-        case AMR_TEXT_Input_AT_Mp4Test:
-        case YUV_TEXT_Input_VT_Mp4Test:
+        case TEXT_Input_TOnly_3gpTest:
+        case AMR_TEXT_Input_AT_3gpTest:
+        case YUV_TEXT_Input_VT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
         case TEXT_Input_TOnly_3gp_LongetivityTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
@@ -2134,7 +1611,7 @@
             bTextTest = true;
             if (!(oscl_strstr(aInputTextFileName.get_cstr(), ".txt") != NULL || oscl_strstr(aInputTextFileName.get_cstr(), ".TXT") != NULL))
             {
-                fprintf(file, "  Input Filename incorrect!!! TestNo:%d - %d needs Input File:-text <xxx>.h264\n\n", firsttest, lasttest);
+                fprintf(file, "  Input Filename incorrect!!! TestNo:%d - %d needs Input File:-text <xxx>.txt\n\n", firsttest, lasttest);
                 return false;
             }
             break;
@@ -2154,7 +1631,7 @@
             return false;
         }
     }
-    if ((firsttest >= 0 && lasttest < K3GP_OUTPUT_TestEnd) || (firsttest >= LongetivityTestBegin && lasttest < K3GP_OUTPUT_LongetivityTestEnd))
+    if ((firsttest >= 0 && lasttest < K3GP_OUTPUT_TestEnd) || (firsttest >= CompressedLongetivityTestBegin && lasttest < Compressed_LongetivityTestEnd))
     {
         if (!(oscl_strstr(aOutputFileName.get_cstr(), ".3gp") != NULL || oscl_strstr(aOutputFileName.get_cstr(), ".3GP") != NULL))
         {
@@ -2162,15 +1639,7 @@
             return false;
         }
     }
-    else if ((firsttest > K3GP_OUTPUT_TestEnd && lasttest < MP4_OUTPUT_TestEnd) || (firsttest > K3GP_OUTPUT_LongetivityTestEnd && lasttest < MP4_OUTPUT_LongetivityTestEnd))
-    {
-        if (!(oscl_strstr(aOutputFileName.get_cstr(), ".mp4") != NULL || oscl_strstr(aOutputFileName.get_cstr(), ".MP4") != NULL))
-        {
-            fprintf(file, "Output Filename incorrect!!! Output File:-output <xxx>.mp4\n\n");
-            return false;
-        }
-    }
-    else if ((firsttest > MP4_OUTPUT_TestEnd && lasttest < AMR_OUTPUT_TestEnd) || (firsttest > MP4_OUTPUT_LongetivityTestEnd && lasttest < AMR_OUTPUT_LongetivityTestEnd))
+    else if ((firsttest > K3GP_OUTPUT_TestEnd && lasttest < AMR_OUTPUT_TestEnd))
     {
         if (!(oscl_strstr(aOutputFileName.get_cstr(), ".amr") != NULL || oscl_strstr(aOutputFileName.get_cstr(), ".AMR") != NULL))
         {
@@ -2178,7 +1647,7 @@
             return false;
         }
     }
-    else if ((firsttest == AACADIF_FOutput_Test) || (firsttest == AACADIF_FOutput_LongetivityTest))
+    else if ((firsttest == AACADIF_FOutput_Test))
     {
         if (!(oscl_strstr(aOutputFileName.get_cstr(), ".aacadif") != NULL || oscl_strstr(aOutputFileName.get_cstr(), ".AACADIF") != NULL))
         {
@@ -2186,7 +1655,7 @@
             return false;
         }
     }
-    else if ((firsttest == AACADTS_FOutput_Test) || (firsttest == AACADTS_FOutput_LongetivityTest))
+    else if ((firsttest == AACADTS_FOutput_Test))
     {
         if (!(oscl_strstr(aOutputFileName.get_cstr(), ".aacadts") != NULL || oscl_strstr(aOutputFileName.get_cstr(), ".AACADTS") != NULL))
         {
@@ -2197,133 +1666,6 @@
     return true;
 }
 
-//This function is used by the generic tests
-//Function sets the Audio and Video - "Input Types","EncoderMimeTypes" based on input audio and video files extension
-
-bool SetAudioVideoOutputFormats(OSCL_HeapString<OsclMemAllocator>& aInputFileNameAudio,
-                                OSCL_HeapString<OsclMemAllocator>& aInputFileNameVideo,
-                                OSCL_HeapString<OsclMemAllocator>& aInputFileNameText,
-                                OSCL_HeapString<OsclMemAllocator>& aOutputFileName,
-                                PVAETestInputType& aAudioInputType,
-                                PVAETestInputType& aVideoInputType,
-                                PVAETestInputType& aTextInputType,
-                                OSCL_HeapString<OsclMemAllocator>& aComposerMimeType,
-                                OSCL_HeapString<OsclMemAllocator>& aAudioEncoderMimeType,
-                                OSCL_HeapString<OsclMemAllocator>& aVideoEncoderMimeType,
-                                OSCL_HeapString<OsclMemAllocator>& aTextEncoderMimeType,
-                                FILE* aFile)
-{
-    //Set the AudioInputType and AudioEncoderMimeType based on input file extension
-    if (oscl_strstr((char*)aInputFileNameAudio.get_str(), (".amr")) != NULL || oscl_strstr((char*)aInputFileNameAudio.get_str(), (".AMR")) != NULL)
-    {
-        aAudioInputType = AMR_IETF_FILE;
-        aAudioEncoderMimeType = KAMRNbEncMimeType;
-    }
-    else if (oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".pcm")) != NULL || oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".PCM")) != NULL)
-    {
-        aAudioInputType = PCM16_FILE;
-        aAudioEncoderMimeType = KAMRNbEncMimeType;
-    }
-    else if (oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".aacadif")) != NULL || oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".AACADIF")) != NULL)
-    {
-        if ((oscl_strstr((char*)aOutputFileName.get_cstr(), (".aacadif")) == NULL) && (oscl_strstr((char*)aOutputFileName.get_cstr(), (".AACADIF")) == NULL))
-        {
-            fprintf(aFile, "For AACADIF input files Output files AACADIF must be specified \n"); 	//liz
-            return false;
-        }
-        aAudioInputType = AAC_ADIF_FILE;
-        aAudioEncoderMimeType = KAACADIFEncMimeType;
-    }
-    else if (oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".aacadts")) != NULL || oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".AACADTS")) != NULL)
-    {
-        if ((oscl_strstr((char*)aOutputFileName.get_cstr(), (".aacadts")) == NULL) && (oscl_strstr((char*)aOutputFileName.get_cstr(), (".AACADTS")) == NULL))
-        {
-            fprintf(aFile, "For AACADTS input files Output files AACADTS must be specified \n"); 	//liz
-            return false;
-        }
-        aAudioInputType = AAC_ADTS_FILE;
-        aAudioEncoderMimeType = KAACADTSEncMimeType;
-    }
-    else if (aInputFileNameAudio == NULL)
-    {
-        aAudioInputType = INVALID_INPUT_TYPE;
-        fprintf(aFile, "Audio input Filename not specified\n");
-    }
-
-    //Set the VideoInputType and VideoEncoderMimeType based on input file extension
-    if (oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".yuv")) != NULL || oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".YUV")) != NULL)
-    {
-        aVideoInputType = YUV_FILE;
-    }
-    else if (oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".h263")) != NULL || oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".H263")) != NULL)
-    {
-        aVideoInputType = H263_FILE;
-    }
-    else if (oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".m4v")) != NULL || oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".M4V")) != NULL)
-    {
-        aVideoInputType = M4V_FILE;
-    }
-    else if (oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".h264")) != NULL || oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".H264")) != NULL)
-    {
-        aVideoInputType = H264_FILE;//We just differentiate for extn, actually the file is a yuv file for AVC(h264) encoding
-    }
-    else if (aInputFileNameVideo == NULL)
-    {
-        aVideoInputType = INVALID_INPUT_TYPE;
-        fprintf(aFile, "Video input Filename not specified\n");
-    }
-
-
-    //Set the TextInputType and TextEncoderMimeType based on input file extension
-    if (oscl_strstr((char*)aInputFileNameText.get_cstr(), (".txt")) != NULL || oscl_strstr((char*)aInputFileNameVideo.get_cstr(), (".TXT")) != NULL)
-    {
-        aTextInputType = TEXT_FILE;
-        aTextEncoderMimeType = KTextEncMimeType;
-    }
-    else if (aInputFileNameText == NULL)
-    {
-        aTextInputType = INVALID_INPUT_TYPE;
-        fprintf(aFile, "Text input Filename not specified\n");
-    }
-
-    //Set the ComposerMimeType and VideoEncoderMimeType based on output file extension
-    if (oscl_strstr((char*)aOutputFileName.get_cstr(), (".3gp")) != NULL || oscl_strstr((char*)aOutputFileName.get_cstr(), (".3GP")) != NULL)
-    {
-        aComposerMimeType = K3gpComposerMimeType;
-        aVideoEncoderMimeType = KH263EncMimeType;
-    }
-    else if (oscl_strstr((char*)aOutputFileName.get_cstr(), (".mp4")) != NULL || oscl_strstr((char*)aOutputFileName.get_cstr(), (".MP4")) != NULL)
-    {
-        aComposerMimeType = KMp4ComposerMimeType;
-        if (aVideoInputType == H264_FILE)
-        {
-            aVideoEncoderMimeType = KH264EncMimeType;
-        }
-        else
-        {
-            aVideoEncoderMimeType = KMp4EncMimeType;
-        }
-    }
-    else if (oscl_strstr((char*)aOutputFileName.get_cstr(), (".amr")) != NULL || oscl_strstr((char*)aOutputFileName.get_cstr(), (".AMR")) != NULL)
-    {
-        aComposerMimeType = KAMRNbComposerMimeType;
-    }
-    else if (oscl_strstr((char*)aOutputFileName.get_cstr(), (".aacadif")) != NULL || oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".AACADIF")) != NULL)
-    {
-        aComposerMimeType = KAACADIFComposerMimeType;
-    }
-    else if (oscl_strstr((char*)aOutputFileName.get_cstr(), (".aacadts")) != NULL || oscl_strstr((char*)aInputFileNameAudio.get_cstr(), (".AACADTS")) != NULL)
-    {
-        aComposerMimeType = KAACADTSComposerMimeType;
-    }
-    else
-    {
-        aComposerMimeType = NULL;
-        fprintf(aFile, "Please specify valid output filename\n");
-        return false;
-    }
-    return true;
-}
 
 ////////////////////////////////////////////////////////////////////////////
 int _local_main(FILE *filehandle, cmd_line* command_line);
@@ -2336,6 +1678,17 @@
     OsclErrorTrap::Init();
     OsclMem::Init();
 
+#ifdef USE_OMX_ENC_NODE
+    OMX_Init();
+#endif
+
+    {
+        PVSDKInfo aSdkInfo;
+        PVAuthorEngineInterface::GetSDKInfo(aSdkInfo);
+        fprintf(filehandle, "SDK Labeled: %s built on %x\n\n",               // display SDK info
+                aSdkInfo.iLabel.get_cstr(), aSdkInfo.iDate);
+    }
+
     file = filehandle;
     fprintf(file, "PVAuthorEngine Unit Test\n\n");
 
@@ -2343,22 +1696,18 @@
     FindMemMgmtRelatedCmdLineParams(command_line, oPrintDetailedMemLeakInfo, filehandle);
 
     //Run the test under a trap
-    int result;
     int32 err;
-    TPVErrorPanic panic;
 
-    OSCL_PANIC_TRAP(err, panic, result = _local_main(filehandle, command_line););
+    OSCL_TRY(err, retVal = _local_main(filehandle, command_line););
 
     //Show any exception.
     if (err != 0)
     {
         fprintf(file, "Error!  Leave %d\n", err);
     }
-    if (panic.iReason != 0)
-    {
-        fprintf(file, "Error!  Panic %s %d\n", panic.iCategory.Str(), panic.iReason);
-    }
-
+#ifdef USE_OMX_ENC_NODE
+    OMX_Deinit();
+#endif
     //Cleanup
 #if !(OSCL_BYPASS_MEMMGT)
     {
@@ -2400,7 +1749,7 @@
                         fprintf(file, "  fileName %s\n", info[ii].fileName);
                         fprintf(file, "  lineNo %d\n", info[ii].lineNo);
                         fprintf(file, "  size %d\n", info[ii].size);
-                        fprintf(file, "  pMemBlock 0x%x\n", info[ii].pMemBlock);
+                        fprintf(file, "  pMemBlock 0x%x\n", (uint32)info[ii].pMemBlock);
                         fprintf(file, "  tag %s\n", info[ii].tag);
                     }
                     auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
@@ -2410,11 +1759,11 @@
     }
 
 #endif
+
     OsclMem::Cleanup();
     OsclErrorTrap::Cleanup();
     OsclBase::Cleanup();
 
-
     return retVal;
 }
 
@@ -2479,7 +1828,7 @@
             char tmpstr[256];
             oscl_UnicodeToUTF8(wCharTime, oscl_strlen(wCharTime), tmpstr, 256);
             tmpstr[255] = '\0';
-            PV_atoi(tmpstr, '0', aAuthoringTime);
+            PV_atoi(tmpstr, '0', aAuthoringTime); // ash liz
         }
         else
         {
@@ -2535,7 +1884,7 @@
         // Do the string compare
         if (oscl_strcmp(argstr, "-help") == 0)
         {
-            fprintf(aFile, "Source specification option. Default is 'testinput.avi':\n");
+            fprintf(aFile, "Source specification option.:\n");
             fprintf(aFile, "  -source sourcename\n");
             fprintf(aFile, "   Specify the source filename or URL to use for test cases which\n");
             fprintf(aFile, "   allow user-specified source name. The unit test determines the\n");
@@ -2572,18 +1921,18 @@
         // AVI file
         if (oscl_strstr(aFileNameInfo.get_cstr(), ".avi") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AAC") != NULL)
         {
-            aInputFileFormatType = PVMF_AVIFF;
+            aInputFileFormatType = PVMF_MIME_AVIFF;
         }
         // WAV file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".wav") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP3") != NULL)
         {
-            aInputFileFormatType = PVMF_WAVFF;
+            aInputFileFormatType = PVMF_MIME_WAVFF;
         }
         // Unknown so set to unknown try to have the player engine recognize
         else
         {
             fprintf(file, "Source type unknown so setting to unknown and have the player engine recognize it\n");
-            aInputFileFormatType = PVMF_FORMAT_UNKNOWN;
+            aInputFileFormatType = PVMF_MIME_FORMAT_UNKNOWN;
         }
     }
 }
@@ -2631,7 +1980,7 @@
             fprintf(aFile, "Video Encoder Type option. Default is M4V:\n");
             fprintf(aFile, "  -encV encodertype\n");
             fprintf(aFile, "  specifies the encoder to be used for authoring\n  0:M4V\n  1:H263\n  2:H264\n");
-            fprintf(aFile, "  e.g -encV 0 \n");
+            fprintf(aFile, "  e.g -encV 0 \n\n");
         }
         else if (oscl_strcmp(argstr, "-encV") == 0)
         {
@@ -2681,14 +2030,56 @@
     }
 }
 
+bool FindAuthoringMode(cmd_line* command_line, FILE *aFile)
+{
+    bool iAuthoringMode = false;
+    bool cmdline_iswchar = command_line->is_wchar();
+
+    int count = command_line->get_count();
+
+    // Search for the "-realtime" argument
+    for (int ii = 0; ii < count; ii++)
+    {
+        char argstr[128];
+
+        // Convert to UTF8 if necessary
+        if (cmdline_iswchar)
+        {
+            oscl_wchar* argwstr = NULL;
+            command_line->get_arg(ii, argwstr);
+            oscl_UnicodeToUTF8(argwstr, oscl_strlen(argwstr), argstr, 128);
+            argstr[127] = '\0';
+        }
+        else
+        {
+            char* tmpargstr = NULL;
+            command_line->get_arg(ii, tmpargstr);
+            uint32 len = oscl_strlen(tmpargstr);
+            oscl_strncpy(argstr, tmpargstr, len);
+            argstr[len] = '\0';
+        }
+
+        // Do the string compare
+        if (oscl_strcmp(argstr, "-help") == 0)
+        {
+            fprintf(aFile, "  -realtime \n");
+            fprintf(aFile, "  specifies the authoring of output file will be done in real time mode\n");
+            fprintf(aFile, "  test cases should be run one by one to author a file in realtime mode\n");
+            fprintf(aFile, "  by default file will be authored in ASAP mode\n\n");
+        }
+        else if (0 == oscl_strcmp(argstr, "-realtime"))
+        {
+            iAuthoringMode = true;
+            break;
+        }
+    }
+
+    return iAuthoringMode;
+}
 OSCL_HeapString<OsclMemAllocator> FindComposerType(OSCL_HeapString<OsclMemAllocator> aFileName, FILE* aFile)
 {
     OSCL_HeapString<OsclMemAllocator> compType;
-    if (oscl_strstr(aFileName.get_str(), ".mp4"))
-    {
-        compType = KMp4ComposerMimeType;
-    }
-    else if (oscl_strstr(aFileName.get_str(), ".3gp"))
+    if (oscl_strstr(aFileName.get_str(), ".3gp"))
     {
         compType = K3gpComposerMimeType;
     }
@@ -2698,13 +2089,198 @@
     }
     else
     {
-        fprintf(aFile, "No output file specified\n, Using default MP4 Composer\n");
-        compType = KMp4ComposerMimeType;
+        fprintf(aFile, "\n\nNo output file specified\n, Using default MP4 Composer\n");
+        compType = K3gpComposerMimeType;
     }
 
     return compType;
 }
 //////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+int RunCompressedTest(cmd_line *aCommandLine, int32 &iFirstTest, int32 &iLastTest, FILE *afilehandle)
+{
+    int retVal = 1;
+    file = afilehandle;
+    int32 err;
+
+    OSCL_HeapString<OsclMemAllocator> audiofilenameinfo = NULL;
+    OSCL_HeapString<OsclMemAllocator> videofilenameinfo = NULL;
+    OSCL_HeapString<OsclMemAllocator> textfilenameinfo = NULL;
+    OSCL_HeapString<OsclMemAllocator> outputfilenameinfo = NULL;
+
+    OSCL_HeapString<OsclMemAllocator> audioconfigfilename = NULL;
+    OSCL_HeapString<OsclMemAllocator> videoconfigfilename = NULL;
+    AVTConfig aAVTConfig;
+
+    //Hard Coded Audio/Video values
+    aAVTConfig.iWidth = KVideoFrameWidth;
+    aAVTConfig.iHeight = KVideoFrameHeight;
+    aAVTConfig.iFps = KVideoFrameRate;
+    aAVTConfig.iFrameInterval = KVideoIFrameInterval;
+
+    aAVTConfig.iNumChannels = KAudioNumChannels;
+    aAVTConfig.iSamplingRate = KAudioTimescale;
+    aAVTConfig.iLoopingEnable = false;
+    // Check -audio, -video and -output tag if user wants to use command line given compressed inputs
+    if (iFirstTest == iLastTest)
+    {
+        FindAudioSourceFile(aCommandLine, audiofilenameinfo, file);
+
+        FindVideoSourceFile(aCommandLine, videofilenameinfo, file);
+
+        FindTextSourceFile(aCommandLine, textfilenameinfo, aAVTConfig.iTextLogFile, aAVTConfig.iTextConfigFile,  file);
+
+        FindOutputFile(aCommandLine, outputfilenameinfo, file);
+    }
+
+    PVAETestInputType aAudioInputType = INVALID_INPUT_TYPE;	// param1
+    PVAETestInputType aVideoInputType = INVALID_INPUT_TYPE;	// param2
+    PVAETestInputType aTextInputType = INVALID_INPUT_TYPE;	// param3
+    OSCL_HeapString<OsclMemAllocator> aComposerMimeType = NULL;	// param3
+    OSCL_HeapString<OsclMemAllocator> aAudioEncoderMimeType = NULL;	// param4
+    OSCL_HeapString<OsclMemAllocator> aVideoEncoderMimeType = NULL;	// param5
+    OSCL_HeapString<OsclMemAllocator> aTextEncoderMimeType = NULL;	// param6
+
+    //If -audio , -video, -text and -output tags are not specified, we will assume hard coded input and output filenames(So no need to check validity of args)
+    if (!((audiofilenameinfo == NULL) && (videofilenameinfo == NULL) && (textfilenameinfo == NULL) && (outputfilenameinfo == NULL)))
+    {
+        //This function will be used for only non generic tests
+        if (CheckSourceAndOutputFiles(aCommandLine, iFirstTest, iLastTest, audiofilenameinfo, videofilenameinfo, textfilenameinfo, outputfilenameinfo, aAVTConfig, audioconfigfilename, videoconfigfilename, file) == false)
+        {
+            return 1;
+        }
+    }
+
+
+    uint32 AuthoringTime;
+    if ((iLastTest >= CompressedLongetivityTestBegin) && (iFirstTest <= Compressed_LongetivityTestEnd))
+
+    {
+        FindAuthoringTime(aCommandLine, AuthoringTime, file);
+        aAVTConfig.iLoopingEnable = true;
+    }
+
+    fprintf(file, "  \nInput audio file name:%s\n  Input video filename:%s\n  Output filename:%s \n", audiofilenameinfo.get_cstr(), videofilenameinfo.get_cstr(), outputfilenameinfo.get_cstr());
+    fprintf(file, "  Audio Configfile name:%s\n  Video Configfilename:%s\n", audioconfigfilename.get_cstr(), videoconfigfilename.get_cstr());
+    fprintf(file, "  Test case range %d to %d\n", iFirstTest, iLastTest);
+
+    OSCL_TRY(err,
+
+             PVAuthorEngineTestSuite* testSuite 	= new PVAuthorEngineTestSuite(file, iFirstTest, iLastTest,
+                     audiofilenameinfo.get_cstr(), videofilenameinfo.get_cstr(), textfilenameinfo.get_cstr(),
+                     outputfilenameinfo.get_cstr(),	aAVTConfig,
+                     aAudioInputType, aVideoInputType, aTextInputType,
+                     aComposerMimeType.get_cstr(), aAudioEncoderMimeType.get_cstr(), aVideoEncoderMimeType.get_cstr(), aTextEncoderMimeType.get_cstr(), AuthoringTime);
+
+             testSuite->run_test();
+             //if (runTestErr != OSCL_ERR_NONE)
+             //	fprintf(file, "ERROR: Leave Occurred! Reason %d \n", runTestErr);
+
+             text_test_interpreter interp;
+             _STRING rs = interp.interpretation(testSuite->last_result());
+             fprintf(file, rs.c_str());
+             const test_result the_result = testSuite->last_result();
+             retVal = (int)(the_result.success_count() != the_result.total_test_count());
+
+             delete testSuite;
+             testSuite = NULL;
+            );
+    // end if statement if ((iFirstTest <= CompressedNormalTestEnd))
+    if (err != OSCL_ERR_NONE)
+    {
+        fprintf(file, "ERROR: Leave Occurred! Reason %d \n", err);
+        return 1;
+    }
+    return retVal;
+}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int RunUnCompressedTest(cmd_line *aCommandLine, int32 &aFirstTest, int32 &aLastTest, FILE *afilehandle)
+{
+    int retVal = 1;
+    file = afilehandle;
+    int32 err;
+
+    OSCL_HeapString<OsclMemAllocator> filenameinfo;
+    OSCL_HeapString<OsclMemAllocator> outputfilenameinfo;
+    OSCL_HeapString<OsclMemAllocator> videoencoderinfo;
+    OSCL_HeapString<OsclMemAllocator> configfileinfo;
+    PVMFFormatType inputformattype ;
+    PVMediaInputAuthorEngineTestParam testparam;
+
+
+    FindSourceFile(aCommandLine, filenameinfo, inputformattype, file);
+    FindOutputFile(aCommandLine, outputfilenameinfo, file);
+    FindVideoEncoder(aCommandLine, videoencoderinfo, file);
+
+    testparam.iFirstTest = aFirstTest;
+    testparam.iLastTest = aLastTest;
+    testparam.iMediainputParam.iFile = file;
+    testparam.iMediainputParam.iInputFormat = inputformattype;
+    testparam.iMediainputParam.iIPFileInfo = filenameinfo;
+    testparam.iMediainputParam.iOPFileInfo = outputfilenameinfo;
+    testparam.iMediainputParam.iVideoEncInfo = videoencoderinfo;
+    testparam.iMediainputParam.iAudioEncInfo = KAMRNbEncMimeType;
+    testparam.iMediainputParam.iComposerInfo = FindComposerType(outputfilenameinfo, file);
+
+    //setting the default configuration info
+    testparam.iMediainputParam.iAudioBitrate = 0;
+    testparam.iMediainputParam.iVideoBitrate = 0;
+    testparam.iMediainputParam.iFrameRate = 0.0;
+    testparam.iMediainputParam.iSamplingRate = 0;
+
+    //checks authoring mode (-realtime).By default is ASAP mode
+    testparam.iMediainputParam.iRealTimeAuthoring = FindAuthoringMode(aCommandLine, file);
+
+    // Load video configuration
+    if (FindAVIConfigFile(aCommandLine, configfileinfo, file))
+    {
+        LoadAVIConfiguration(configfileinfo, testparam, file);
+    }
+
+    //iAsap is used when we run testcases in one go i.e running TC 0 to TC 569
+    if (testparam.iMediainputParam.iRealTimeAuthoring)
+    {
+        testparam.iAsap = false;
+    }
+    else
+    {
+        testparam.iAsap = true;
+    }
+
+    FindAuthoringTime(aCommandLine, testparam.iMediainputParam.iLoopTime, file);
+    if ((PVMediaInput_ErrorHandling_Test_WrongFormat != aFirstTest)
+            && (PVMediaInput_ErrorHandling_Test_WrongIPFileName != aFirstTest))
+    {
+        fprintf(file, "Begin test with the following parameters:\
+		\nInput File Name : %s\nOutput File Name: %s,\nVideo Encoder: %s,\nAudio Encoder: %s,\
+		\nComposer: %s\n", testparam.iMediainputParam.iIPFileInfo.get_cstr(), testparam.iMediainputParam.iOPFileInfo.get_cstr(),
+                testparam.iMediainputParam.iVideoEncInfo.get_cstr(), testparam.iMediainputParam.iAudioEncInfo.get_cstr(),
+                testparam.iMediainputParam.iComposerInfo.get_cstr());
+    }
+
+    OSCL_TRY(err,
+             PVMediaInputAuthorEngineTestSuite* test_suite =
+                 new PVMediaInputAuthorEngineTestSuite(testparam);
+             test_suite->run_test();
+             text_test_interpreter interp;
+             _STRING rs = interp.interpretation(test_suite->last_result());
+             fprintf(file, rs.c_str());
+             const test_result the_result = test_suite->last_result();
+             retVal = (int)(the_result.success_count() != the_result.total_test_count());
+
+             delete test_suite;
+             test_suite = NULL;
+            );
+    if (err != OSCL_ERR_NONE)
+    {
+        fprintf(file, "ERROR: Leave Occurred! Reason %d \n", err);
+        return 1;
+    }
+    return retVal;
+}
+
 
 
 int _local_main(FILE *filehandle, cmd_line *command_line)
@@ -2713,215 +2289,89 @@
     file = filehandle;
 
     // Print out the extension for help if no argument
+    int32 firsttest, lasttest;
     if (command_line->get_count() == 0)
     {
-        fprintf(file, "  Specify '-help' first to get help information on options\n\n");
-        return 0;
+        fprintf(file, "****Specify '-help' to get CommandLine arguments information options****\n\n");
+        fprintf(file, "****Running all Author test cases****\n\n");
+        //return 0;
+        firsttest = 0;
+        lasttest = KUnCompressed_Errorhandling_TestEnd;
+    }
+    else
+    {
+        FindTestRange(command_line, firsttest, lasttest, file);
+        fprintf(file, "[test range from: %d to: %d]\n\n", firsttest, lasttest);
     }
 
-    int32 loglevel;
-    FindLogLevel(command_line, loglevel, file);
-
-    int32 lognode;
-    FindLoggerNode(command_line, lognode, file);
-
-    int32 logtext;
-    FindLogText(command_line, logtext, file);
-    int32 firsttest, lasttest;
-    int32 err;
-
-    FindTestRange(command_line, firsttest, lasttest, file);
+    PVMFFormatType formaterr = PVMF_MIME_FORMAT_UNKNOWN;
+    int32 err = 0;
 
     OSCL_HeapString<OsclMemAllocator> filenameinfo;
-    OSCL_HeapString<OsclMemAllocator> outputfilenameinfo;
-    OSCL_HeapString<OsclMemAllocator> videoencoderinfo;
-
 
     if (Invalid_Test == firsttest)
     {
         //functions called to print command line arguments.
-        fprintf(file, "CMD LINE ARGS FOR ENGINE TESTS [test range from: %d to: %d]\n\n", AMR_Input_AOnly_3gpTest, AAC_OUTPUT_LongetivityTestEnd);
+        fprintf(file, "CMD LINE ARGS FOR COMPRESSED TESTS [test range from: %d to: %d]\n\n", AMR_Input_AOnly_3gpTest, Compressed_LongetivityTestEnd);
 
         FindAudioSourceFile(command_line, filenameinfo, file);
         FindVideoSourceFile(command_line, filenameinfo, file);
         FindOutputFile(command_line, filenameinfo, file);
         FindAuthoringTime(command_line, (uint32&)err, file);
 
-        fprintf(file, "CMD LINE ARGS FOR ENGINE TESTS WITH AVI/WAV MIO COMPONENT[test range starting from %d]\n\n", PVMediaInput_Open_Compose_Stop_Test);
+        fprintf(file, "CMD LINE ARGS FOR UNCOMPRESSED TESTS(with AVI/WAV inputs)[test range from %d to %d]\n\n", UnCompressed_NormalTestBegin, UnCompressed_LongetivityTestEnd);
 
-        FindSourceFile(command_line, filenameinfo, (uint32&)err, file);
+        FindSourceFile(command_line, filenameinfo, (PVMFFormatType&)formaterr, file);
         FindOutputFile(command_line, filenameinfo, file);
         FindVideoEncoder(command_line, filenameinfo, file);
+        FindAuthoringTime(command_line, (uint32&)err, file);
+
+        fprintf(file, "NO CMD LINE ARGS WERE REQUIRED TO RUN COMPRESSED ERROR HANDLING TESTS [test range from:%d to %d]\n\n", KCompressed_Errorhandling_TestBegin, KCompressed_Errorhandling_TestEnd);
+        fprintf(file, "NO CMD LINE ARGS WERE REQUIRED TO RUN UNCOMPRESSED ERROR HANDLING TESTS [test range from:%d to %d]\n\n", KUnCompressed_Errorhandling_TestBegin, KUnCompressed_Errorhandling_TestEnd);
 
         return 0;
     }
-    else if ((firsttest >= PVMediaInput_Open_Compose_Stop_Test))
+
+    ///////////////////////Normal Compressed tests//////////////////////
+    if (firsttest <= Compressed_LongetivityTestEnd)
     {
-        PVMFFormatType inputformattype ;
-        FindSourceFile(command_line, filenameinfo, inputformattype, file);
-
-        if (filenameinfo.get_size() <= 0)
-        {
-            filenameinfo = DEFAULTSOURCEFILENAME;
-            inputformattype = DEFAULTSOURCEFORMATTYPE;
-        }
-
-        FindOutputFile(command_line, outputfilenameinfo, file);
-
-        if (outputfilenameinfo.get_size() <= 0)
-        {
-            outputfilenameinfo = DEFAULTOUTPUTFILENAME;
-        }
-
-        FindVideoEncoder(command_line, videoencoderinfo, file);
-
-        PVMediaInputAuthorEngineTestParam testparam;
-
-        testparam.iLogLevel = loglevel;
-        testparam.iLogNode = lognode;
-        testparam.iLogFile = logtext;
-        testparam.iFirstTest = firsttest;
-        testparam.iLastTest = lasttest;
-        testparam.iMediainputParam.iFile = file;
-        testparam.iMediainputParam.iInputFormat = inputformattype;
-        testparam.iMediainputParam.iIPFileInfo = filenameinfo;
-        testparam.iMediainputParam.iOPFileInfo = outputfilenameinfo;
-        testparam.iMediainputParam.iVideoEncInfo = videoencoderinfo;
-        testparam.iMediainputParam.iAudioEncInfo = KAMRNbEncMimeType;
-        testparam.iMediainputParam.iComposerInfo = FindComposerType(outputfilenameinfo, file);
-        testparam.iMediainputParam.iRealTimeAuthoring = false;
-
-        FindAuthoringTime(command_line, testparam.iMediainputParam.iLoopTime, file);
-        if ((PVMediaInput_ErrorHandling_Test_WrongFormat != firsttest)
-                && (PVMediaInput_ErrorHandling_Test_WrongIPFileName != firsttest))
-        {
-            fprintf(file, "Begin test with the following parameters:\
-			\nInput File Name : %s\nOutput File Name: %s,\nVideo Encoder: %s,\nAudio Encoder: %s,\
-			\nComposer: %s\n", testparam.iMediainputParam.iIPFileInfo.get_cstr(), testparam.iMediainputParam.iOPFileInfo.get_cstr(),
-                    testparam.iMediainputParam.iVideoEncInfo.get_cstr(), testparam.iMediainputParam.iAudioEncInfo.get_cstr(),
-                    testparam.iMediainputParam.iComposerInfo.get_cstr());
-        }
-
-        OSCL_TRY(err,
-                 PVMediaInputAuthorEngineTestSuite* test_suite =
-                     new PVMediaInputAuthorEngineTestSuite(testparam);
-                 test_suite->run_test();
-                 text_test_interpreter interp;
-                 _STRING rs = interp.interpretation(test_suite->last_result());
-                 fprintf(file, rs.c_str());
-                 const test_result the_result = test_suite->last_result();
-                 retVal = (int)(the_result.success_count() != the_result.total_test_count());
-
-                 delete test_suite;
-                 test_suite = NULL;
-                );
-
+        retVal = RunCompressedTest(command_line, firsttest, lasttest, file);
     }
-    else if ((firsttest < PVMediaInput_Open_Compose_Stop_Test))
+    ///////End of Normal Compressed tests///////////////////////////////////////
+
+    ///////////////Uncompressed AVI normal and longetivity tests///////////////
+    if (((firsttest >= UnCompressed_NormalTestBegin) && (firsttest <= UnCompressed_LongetivityTestEnd))
+            || ((firsttest <= UnCompressed_NormalTestBegin) && (lasttest > UnCompressed_NormalTestBegin)))
     {
-        OSCL_HeapString<OsclMemAllocator> audiofilenameinfo = NULL;
-        OSCL_HeapString<OsclMemAllocator> videofilenameinfo = NULL;
-        OSCL_HeapString<OsclMemAllocator> textfilenameinfo = NULL;
-        OSCL_HeapString<OsclMemAllocator> outputfilenameinfo = NULL;
+        retVal = RunUnCompressedTest(command_line, firsttest, lasttest, file);
+    }
+    //////////////////End of AVI normal and longetivity tests////////////////////
 
-        OSCL_HeapString<OsclMemAllocator> audioconfigfilename = NULL;
-        OSCL_HeapString<OsclMemAllocator> videoconfigfilename = NULL;
-        AVTConfig aAVTConfig;
-
-        //Hard Coded Audio/Video values
-        aAVTConfig.iWidth = KVideoFrameWidth;
-        aAVTConfig.iHeight = KVideoFrameHeight;
-        aAVTConfig.iFps = KVideoFrameRate;
-        aAVTConfig.iFrameInterval = KVideoIFrameInterval;
-
-        aAVTConfig.iNumChannels = KAudioNumChannels;
-        aAVTConfig.iSamplingRate = KAudioTimescale;
-        aAVTConfig.iLoopingEnable = false;
-
-        // Check -audio, -video and -output tag if user wants to run tests one by one or the generic tests
-        if (firsttest == lasttest || ((firsttest >= GenericTestBegin) && (lasttest <= GenericTestEnd)))
-        {
-            FindAudioSourceFile(command_line, audiofilenameinfo, file);
-
-            FindVideoSourceFile(command_line, videofilenameinfo, file);
-
-            FindTextSourceFile(command_line, textfilenameinfo, aAVTConfig.iTextLogFile, aAVTConfig.iTextConfigFile,  file);
-
-            FindOutputFile(command_line, outputfilenameinfo, file);
-        }
-        PVAETestInputType aAudioInputType = INVALID_INPUT_TYPE;	// param1
-        PVAETestInputType aVideoInputType = INVALID_INPUT_TYPE;	// param2
-        PVAETestInputType aTextInputType = INVALID_INPUT_TYPE;	// param3
-        OSCL_HeapString<OsclMemAllocator> aComposerMimeType = NULL;	// param3
-        OSCL_HeapString<OsclMemAllocator> aAudioEncoderMimeType = NULL;	// param4
-        OSCL_HeapString<OsclMemAllocator> aVideoEncoderMimeType = NULL;	// param5
-        OSCL_HeapString<OsclMemAllocator> aTextEncoderMimeType = NULL;	// param6
-
-        //If -audio , -video, -text and -output tags are not specified, we will assume hard coded input and output filenames(So no need to check validity of args)
-        if (!((audiofilenameinfo == NULL) && (videofilenameinfo == NULL) && (textfilenameinfo == NULL) && (outputfilenameinfo == NULL)))
-        {
-            //This function will be used for only non generic tests
-            if (CheckSourceAndOutputFiles(command_line, firsttest, lasttest, audiofilenameinfo, videofilenameinfo, textfilenameinfo, outputfilenameinfo, aAVTConfig, audioconfigfilename, videoconfigfilename, file) == false)
-            {
-                return 1;
-            }
-        }
-
-        if ((firsttest >= GenericTestBegin) && (lasttest <= GenericTestEnd))
-        {
-            if ((audiofilenameinfo == NULL && videofilenameinfo == NULL && textfilenameinfo == NULL) || (outputfilenameinfo == NULL))
-            {
-                fprintf(file, "Please specify -audio or -video tag depending on audio only, video only, text only, audiovideo and audiovideotext file encoding.Also specify -output filename\n");
-                return 0;
-            }
-            else
-            {
-                //Set the MimeTypes based on input and output files extension
-                if (!SetAudioVideoOutputFormats(audiofilenameinfo, videofilenameinfo, textfilenameinfo, outputfilenameinfo,
-                                                aAudioInputType, aVideoInputType, aTextInputType,
-                                                aComposerMimeType, aAudioEncoderMimeType, aVideoEncoderMimeType, aTextEncoderMimeType, file))
-                {
-                    return 0;
-                }
-            }
-
-        }
-
-        uint32 AuthoringTime;
-        if ((firsttest >= LongetivityTestBegin) && (lasttest <= AAC_OUTPUT_LongetivityTestEnd))
-        {
-            FindAuthoringTime(command_line, AuthoringTime, file);
-            aAVTConfig.iLoopingEnable = true;
-        }
-
-        fprintf(file, "  Input audio file name:%s\n  Input video filename:%s\n  Output filename:%s \n", audiofilenameinfo.get_cstr(), videofilenameinfo.get_cstr(), outputfilenameinfo.get_cstr());
-        fprintf(file, "  Audio Configfile name:%s\n  Video Configfilename:%s\n", audioconfigfilename.get_cstr(), videoconfigfilename.get_cstr());
-        fprintf(file, "  Test case range %d to %d\n", firsttest, lasttest);
-        fprintf(file, "  Log level %d; Log node %d Log Text %d\n\n", loglevel, lognode, logtext);
-
-        OSCL_TRY(err,
-                 PVAuthorEngineTestSuite* testSuite 	= new PVAuthorEngineTestSuite(file, logtext, loglevel, lognode, firsttest, lasttest,
-                         audiofilenameinfo.get_cstr(), videofilenameinfo.get_cstr(), textfilenameinfo.get_cstr(),
-                         outputfilenameinfo.get_cstr(),	aAVTConfig,
-                         aAudioInputType, aVideoInputType, aTextInputType,
-                         aComposerMimeType.get_cstr(), aAudioEncoderMimeType.get_cstr(), aVideoEncoderMimeType.get_cstr(), aTextEncoderMimeType.get_cstr(), AuthoringTime);
-
-                 testSuite->run_test();
-
-                 text_test_interpreter interp;
-                 _STRING rs = interp.interpretation(testSuite->last_result());
-                 fprintf(file, rs.c_str());
-                 const test_result the_result = testSuite->last_result();
-                 retVal = (int)(the_result.success_count() != the_result.total_test_count());
-
-                 delete testSuite;
-                 testSuite = NULL;
-                );
-    } // end else statement if (firsttest >= PVMediaInput_Author_Stop_Test)
-    if (err != OSCL_ERR_NONE)
+    //////////////////Compressed Errorhandling test begin/////////////////////
+    if (((firsttest >= KCompressed_Errorhandling_TestBegin) && (firsttest <= KCompressed_Errorhandling_TestEnd))
+            || ((firsttest <= KCompressed_Errorhandling_TestBegin) && (lasttest > KCompressed_Errorhandling_TestBegin)))
     {
-        fprintf(file, "ERROR: Leave Occurred! Reason %d \n", err);
-        return 1;
+
+        if (firsttest < KCompressed_Errorhandling_TestBegin)
+        {
+            firsttest = KCompressed_Errorhandling_TestBegin;
+        }
+
+        retVal = RunCompressedTest(command_line, firsttest, lasttest, file);
+
+    }//////////////////Compressed Errorhandling test end/////////////////////
+
+    //////////////////UnCompressed Errorhandling test begin/////////////////////
+    if (((lasttest > KUnCompressed_Errorhandling_TestBegin) && (lasttest <= KUnCompressed_Errorhandling_TestEnd))
+            || (((firsttest <= KUnCompressed_Errorhandling_TestBegin) || (firsttest >= KUnCompressed_Errorhandling_TestBegin))
+                && (lasttest > KUnCompressed_Errorhandling_TestEnd)))
+    {
+        if (firsttest < KUnCompressed_Errorhandling_TestBegin)
+        {
+            firsttest = KUnCompressed_Errorhandling_TestBegin;
+        }
+        retVal = RunUnCompressedTest(command_line, firsttest, lasttest, file);
+
     }
     return retVal;
 }
diff --git a/engines/author/test/src/pvaetest.h b/engines/author/test/src/pvaetest.h
index f7786a9..b5f0e68 100644
--- a/engines/author/test/src/pvaetest.h
+++ b/engines/author/test/src/pvaetest.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,7 @@
 
 {
     public:
-        PVAuthorEngineTest(FILE* aStdOut, int32 aLogFile, int32 aLogLevel, int32 aLogNode,
-                           int32 aFirstTest, int32 aLastTest, const char* aInputFileName1,
+        PVAuthorEngineTest(FILE* aStdOut, int32 aFirstTest, int32 aLastTest, const char* aInputFileName1,
                            const char* aInputFileName2, const char* aInputFileName3, const char* aOutputFileName,
                            AVTConfig iAVTConfig, PVAETestInputType aAudioInputType,
                            PVAETestInputType aVideoInputType, PVAETestInputType aTextInputType, const char* aComposerMimeType,
@@ -88,10 +87,9 @@
 class PVAuthorEngineTestSuite : public test_case
 {
     public:
-        PVAuthorEngineTestSuite(FILE* aStdOut, int32 aLogFile, int32 aLogLevel, int32 aLogNode, int32 aFirstTest, int32 aLastTest, const char* iInputFileName1, const char* iInputFileName2, const char* iInputFileName3, const char* iOutputFileName, AVTConfig iAVTConfig, PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,  PVAETestInputType aTextInputType, const char* aComposerMimeType, const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType, const char* aTextEncoderMimeType, uint aAuthoringTime) : test_case()
+        PVAuthorEngineTestSuite(FILE* aStdOut, int32 aFirstTest, int32 aLastTest, const char* iInputFileName1, const char* iInputFileName2, const char* iInputFileName3, const char* iOutputFileName, AVTConfig iAVTConfig, PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,  PVAETestInputType aTextInputType, const char* aComposerMimeType, const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType, const char* aTextEncoderMimeType, uint aAuthoringTime) : test_case()
         {
-            adopt_test_case(new PVAuthorEngineTest(aStdOut, aLogFile, aLogLevel, aLogNode,
-                                                   aFirstTest, aLastTest, iInputFileName1, iInputFileName2, iInputFileName3, iOutputFileName,
+            adopt_test_case(new PVAuthorEngineTest(aStdOut, aFirstTest, aLastTest, iInputFileName1, iInputFileName2, iInputFileName3, iOutputFileName,
                                                    iAVTConfig, aAudioInputType, aVideoInputType, aTextInputType, aComposerMimeType, aAudioEncoderMimeType, aVideoEncoderMimeType, aTextEncoderMimeType, aAuthoringTime));
         }
         ~PVAuthorEngineTestSuite() {};
diff --git a/engines/author/test/src/single_core/pvaetest_node_config.h b/engines/author/test/src/single_core/pvaetest_node_config.h
index c9c11cc..a7fa5d3 100644
--- a/engines/author/test/src/single_core/pvaetest_node_config.h
+++ b/engines/author/test/src/single_core/pvaetest_node_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@
 class PVAETestNodeConfig
 {
     public:
-        static bool ConfigureAudioEncoder(PVInterface* aInterface)
+        static bool ConfigureAudioEncoder(PVInterface* aInterface, uint32 aAudioBitrate = 0)
         {
             if (!aInterface)
                 return true;
@@ -57,7 +57,13 @@
             PVAMREncExtensionInterface* config = OSCL_STATIC_CAST(PVAMREncExtensionInterface*, aInterface);
             config->SetMaxNumOutputFramesPerBuffer(KNum20msFramesPerChunk);
 
-            switch (KAudioBitrate)
+            uint32 audioBitrate = aAudioBitrate;
+
+            if (audioBitrate == 0)
+            {
+                audioBitrate = KAudioBitrate;
+            }
+            switch (audioBitrate)
             {
                 case 4750:
                     config->SetOutputBitRate(GSM_AMR_4_75);
diff --git a/engines/author/test/src/single_core/pvaetestinput.cpp b/engines/author/test/src/single_core/pvaetestinput.cpp
index f677809..656f2d0 100644
--- a/engines/author/test/src/single_core/pvaetestinput.cpp
+++ b/engines/author/test/src/single_core/pvaetestinput.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -173,37 +173,13 @@
     }
     switch (aType)
     {
-        case YUV_FILE:
-            if (aFileName.get_size() == 0)
-            {
-                iSettings.iFileName = KYUVTestInput;
-            }
-            iSettings.iMediaFormat = PVMF_YUV420;//PVMF_RGB16;//PVMF_YUV420;
-            iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
-            iSettings.iTimescale = KVideoTimescale;
-            iSettings.iFrameHeight = iAVTConfig.iHeight; //KVideoFrameHeight;
-            iSettings.iFrameWidth = iAVTConfig.iWidth;//KVideoFrameWidth;
-            iSettings.iFrameRate = iAVTConfig.iFps;//KVideoFrameRate;
-            break;
-
-            /*
-            case M4V_FILE:
-            iSettings.iFileName = KM4VTestInput;
-            iSettings.iMediaFormat = PVMF_M4V;
-            iSettings.iLoopInputFile = true;
-            iSettings.iTimescale = KVideoTimescale;
-            iSettings.iFrameHeight = iAVTConfig.iHeight; //KVideoFrameHeight;
-            iSettings.iFrameWidth = iAVTConfig.iWidth;//KVideoFrameWidth;
-            iSettings.iFrameRate = iAVTConfig.iFps;//KVideoFrameRate;
-            break;
-            */
 
         case H263_FILE:
             if (aFileName.get_size() == 0)
             {
                 iSettings.iFileName = KH263TestInput;
             }
-            iSettings.iMediaFormat = PVMF_H263;
+            iSettings.iMediaFormat = PVMF_MIME_H2631998;
             iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
             iSettings.iTimescale = KVideoTimescale;
             iSettings.iFrameHeight = iAVTConfig.iHeight; //KVideoFrameHeight;
@@ -216,7 +192,7 @@
             {
                 iSettings.iFileName = KH264TestInput;
             }
-            iSettings.iMediaFormat = PVMF_YUV420;
+            iSettings.iMediaFormat = PVMF_MIME_YUV420;
             iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
             iSettings.iTimescale = KVideoTimescale;
             iSettings.iFrameHeight = iAVTConfig.iHeight; //KVideoFrameHeight;
@@ -224,12 +200,25 @@
             iSettings.iFrameRate = iAVTConfig.iFps;//KVideoFrameRate;
             break;
 
+        case YUV_FILE:
+            if (aFileName.get_size() == 0)
+            {
+                iSettings.iFileName = KYUVTestInput;
+            }
+            iSettings.iMediaFormat = PVMF_MIME_YUV420;
+            iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
+            iSettings.iTimescale = KVideoTimescale;
+            iSettings.iFrameHeight = iAVTConfig.iHeight;
+            iSettings.iFrameWidth = iAVTConfig.iWidth;
+            iSettings.iFrameRate = iAVTConfig.iFps;
+            break;
+
         case AMR_IETF_FILE:
             if (aFileName.get_size() == 0)
             {
                 iSettings.iFileName = KAMRTestInput;
             }
-            iSettings.iMediaFormat = PVMF_AMR_IETF;
+            iSettings.iMediaFormat = PVMF_MIME_AMR_IETF;
             iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
             iSettings.iSamplingFrequency = iAVTConfig.iSamplingRate; //KAudioTimescale;
             iSettings.iNumChannels = iAVTConfig.iNumChannels;// KAudioNumChannels;
@@ -241,7 +230,7 @@
             {
                 iSettings.iFileName = KAACADIFTestInput;
             }
-            iSettings.iMediaFormat = PVMF_ADIF;
+            iSettings.iMediaFormat = PVMF_MIME_ADIF;
             iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
             iSettings.iSamplingFrequency = iAVTConfig.iSamplingRate; //KAudioTimescale;
             iSettings.iNumChannels = iAVTConfig.iNumChannels;// KAudioNumChannels;
@@ -252,36 +241,14 @@
             {
                 iSettings.iFileName = KAACADTSTestInput;
             }
-            iSettings.iMediaFormat = PVMF_ADTS;
-            iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
-            iSettings.iSamplingFrequency = iAVTConfig.iSamplingRate; //KAudioTimescale;
-            iSettings.iNumChannels = iAVTConfig.iNumChannels;// KAudioNumChannels;
-            iSettings.iNum20msFramesPerChunk = KNum20msFramesPerChunk;
-            break;
-        case PCM16_FILE:
-            if (aFileName.get_size() == 0)
-            {
-                iSettings.iFileName = KPCM16TestInput;
-            }
-            iSettings.iMediaFormat = PVMF_PCM16;
+            iSettings.iMediaFormat = PVMF_MIME_ADTS;
             iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
             iSettings.iSamplingFrequency = iAVTConfig.iSamplingRate; //KAudioTimescale;
             iSettings.iNumChannels = iAVTConfig.iNumChannels;// KAudioNumChannels;
             iSettings.iNum20msFramesPerChunk = KNum20msFramesPerChunk;
             break;
 
-        case YUV_WRONG_FILE:
-            if (aFileName.get_size() == 0)
-            {
-                iSettings.iFileName = KYUVTestInput;
-            }
-            iSettings.iMediaFormat = PVMF_RGB16;//PVMF_RGB16;//PVMF_YUV420;
-            iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
-            iSettings.iTimescale = KVideoTimescale;
-            iSettings.iFrameHeight = iAVTConfig.iHeight; //KVideoFrameHeight;
-            iSettings.iFrameWidth = iAVTConfig.iWidth;//KVideoFrameWidth;
-            iSettings.iFrameRate = iAVTConfig.iFps;//KVideoFrameRate;
-            break;
+
         case TEXT_FILE:
             if (aFileName.get_size() == 0)
             {
@@ -313,7 +280,7 @@
                     iSettings.iTextFileName.set(output2, oscl_strlen(output2));
                 }
             }
-            iSettings.iMediaFormat = PVMF_3GPP_TIMEDTEXT;
+            iSettings.iMediaFormat = PVMF_MIME_3GPP_TIMEDTEXT;
             iSettings.iLoopInputFile = iAVTConfig.iLoopingEnable;
             iSettings.iSamplingFrequency = 0;
             iSettings.iNumChannels = 0;
diff --git a/engines/author/test/src/single_core/pvaetestinput.h b/engines/author/test/src/single_core/pvaetestinput.h
index 886e204..24a9bf9 100644
--- a/engines/author/test/src/single_core/pvaetestinput.h
+++ b/engines/author/test/src/single_core/pvaetestinput.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/author/test/src/test_pv_author_engine_logger.cpp b/engines/author/test/src/test_pv_author_engine_logger.cpp
new file mode 100644
index 0000000..4f35721
--- /dev/null
+++ b/engines/author/test/src/test_pv_author_engine_logger.cpp
@@ -0,0 +1,352 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+// test_pv_author_engine_logger.cpp: implementation of the PVAELogger class.
+//
+//////////////////////////////////////////////////////////////////////
+#ifndef PVLOGGER_FILE_APPENDER_H_INCLUDED
+#include "pvlogger_file_appender.h"
+#endif
+#ifndef PVLOGGER_STDERR_APPENDER_H_INCLUDED
+#include "pvlogger_stderr_appender.h"
+#endif
+#ifndef PVLOGGER_MEM_APPENDER_H_INCLUDED
+#include "pvlogger_mem_appender.h"
+#endif
+#ifndef PVLOGGER_TIME_AND_ID_LAYOUT_H_INCLUDED
+#include "pvlogger_time_and_id_layout.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+#ifndef TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
+#include "test_pv_author_engine_logger.h"
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// Macro redefinition for typing convenience : define an 8-bit char* or 16-bit wchar
+#define _CSTR(x) _STRLIT_CHAR(x)
+#define _W(x) _STRLIT_WCHAR(x)
+
+#define KLogFile ((OSCL_TCHAR*) _STRLIT("pvauthorlog.txt"))
+
+typedef OSCL_HeapString<OsclMemAllocator> HeapString;
+typedef OSCL_wHeapString<OsclMemAllocator> wHeapString;
+
+// Open pwszConfigFile to read nodes (and levels) to log
+// Returns true on success
+OSCL_EXPORT_REF bool PVAELogger::ParseConfigFile(const oscl_wchar *pwszConfigFile)
+{
+    OSCL_ASSERT(pwszConfigFile);
+    if (!pwszConfigFile)
+        return false;
+
+    int32 iStatus = 0;
+    PVLogger		 *loggernode = NULL;
+
+    bool bFileExists = false;
+    Oscl_FileServer fs;
+    Oscl_File		filehandle;
+
+    // read configuration file pvaelogger.txt in working directory
+    fs.Connect();
+    if (filehandle.Open(pwszConfigFile, Oscl_File::MODE_READ, fs) == 0)
+        bFileExists = true;
+
+    //If the file "pvaelogger.txt" does not exist in the working dir or
+    //is empty, set default: log "AuthorEngine", debug level to StdErr
+    if (!bFileExists || 0 == filehandle.Size())
+    {
+        if (bFileExists)
+            filehandle.Close();
+        fs.Close();
+        return false;
+    }
+
+    int32 MAXLENGTH = filehandle.Size();
+    uint32 lastlineterminator = 0, firstline = 0;
+
+    PVLoggerAppender *appender = NULL;
+    OsclRefCounter	 *refCounter = NULL;
+    OsclSharedPtr<PVLoggerAppender> sharedAppenderPtr;
+
+    bool bEof = false;
+    while (!bEof)
+    {
+        char *buf = (char *)OSCL_MALLOC(MAXLENGTH + 1);
+        filehandle.Seek(lastlineterminator, Oscl_File::SEEKSET);
+        if (filehandle.Read((void *)buf, 1, MAXLENGTH))
+        {
+            //delibrately remove const-ness char* output from oscl_strstr to a modifiable char* for further operation
+            char *ptr = OSCL_CONST_CAST(char*, oscl_strstr(buf, _CSTR("\n")));
+            if (ptr)
+            {
+                if (*(ptr - 1) == '\r')
+                {
+                    *(ptr - 1) = '\0';
+                }
+                else
+                {
+                    *ptr = '\0';
+                }
+
+                lastlineterminator += ptr - buf + 1;
+
+            }
+            else
+            {
+                bEof = true;
+            }
+
+            // Check if this is a commented line
+            if (*buf == '#')
+            {
+                firstline = lastlineterminator;
+                if (buf)
+                {
+                    OSCL_FREE(buf);
+                    buf = NULL;
+                }
+                continue;
+            }
+
+            //If the first uncommented line in the file is NO_LOGGING all logging will be disabled
+            //If the first uncommented line in the file is LOGTOFILE, a file appender shall be created
+            //If the first uncommented line in the file is LOGTOMEM, a memory appender shall be created
+            //otherwise all logs shall be dumped on the cmd wnd
+
+            if (appender == NULL &&
+                    ((lastlineterminator == 0) || (firstline == lastlineterminator - (ptr - buf + 1))))
+
+            {
+                if (oscl_strstr(buf, _CSTR("NO_LOGGING")))
+                {
+                    filehandle.Close();
+                    fs.Close();
+                    if (buf)
+                    {
+                        OSCL_FREE(buf);
+                        buf = NULL;
+                    }
+                    return true;
+                }
+
+                iStatus = PVAELogger::CreateTestAppender(buf, appender, refCounter, sharedAppenderPtr);
+
+                if (iStatus != OsclErrNone)
+                {
+                    OSCL_ASSERT(!_CSTR("Author Engine Unittest: unable to create log appender"));
+                    sharedAppenderPtr.Unbind();
+                    if (refCounter)
+                        delete refCounter;
+                    if (appender)
+                        delete appender;
+                    if (buf)
+                    {
+                        OSCL_FREE(buf);
+                        buf = NULL;
+                    }
+                    return false;
+                }
+            }
+
+            //Extract the node
+            char *node = (char *)OSCL_MALLOC(MAXLENGTH + 1);
+            if (!node)
+            {
+                if (NULL != buf)
+                {
+                    OSCL_FREE(buf);
+                    buf = NULL;
+                }
+                return false;
+            }
+
+            const char *marker = oscl_strstr(buf, _CSTR(";"));
+
+            if (!marker)
+            {
+                OSCL_FREE(node);
+                if (buf)
+                {
+                    OSCL_FREE(buf);
+                    buf = NULL;
+                }
+                continue;
+            }
+
+            uint32 node_size = marker - buf;
+
+            oscl_strncpy(node, buf, node_size);
+            *(node + node_size) = '\0';
+
+            //Extract the log level
+            HeapString *loglevel = OSCL_NEW(HeapString, (oscl_strstr(buf, _CSTR(";")) + 1));
+            if (!loglevel)
+            {
+                OSCL_FREE(node);
+                if (buf)
+                {
+                    OSCL_FREE(buf);
+                    buf = NULL;
+                }
+                return false;
+            }
+
+            char *tmp = loglevel->get_str();
+            bool logallnodes = false;
+
+            //If node = ALLNODES; enable logging for all
+            //ALLNODES should be written in the file before any other logger node
+            if (oscl_strstr(node, _CSTR("ALLNODES")))
+            {
+                loggernode = PVLogger::GetLoggerObject("");
+                logallnodes = true;
+            }
+            else
+            {
+                loggernode = PVLogger::GetLoggerObject(node);
+            }
+
+            loggernode->AddAppender(sharedAppenderPtr);
+
+            //Set log level
+            if (oscl_strstr(tmp, _CSTR("PVLOGMSG_EMERG")))
+                loggernode->SetLogLevel(PVLOGMSG_EMERG);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_ALERT")))
+                loggernode->SetLogLevel(PVLOGMSG_ALERT);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_CRIT")))
+                loggernode->SetLogLevel(PVLOGMSG_CRIT);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_ERR")))
+                loggernode->SetLogLevel(PVLOGMSG_ERR);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_WARNING")))
+                loggernode->SetLogLevel(PVLOGMSG_WARNING);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_NOTICE")))
+                loggernode->SetLogLevel(PVLOGMSG_NOTICE);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_INFO")))
+                loggernode->SetLogLevel(PVLOGMSG_INFO);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_STACK_TRACE")))
+                loggernode->SetLogLevel(PVLOGMSG_STACK_TRACE);
+            else if (oscl_strstr(tmp, _CSTR("PVLOGMSG_DEBUG")))
+                loggernode->SetLogLevel(PVLOGMSG_DEBUG);
+
+            if (logallnodes == true)
+                bEof = true;
+
+            if (node)
+                OSCL_FREE(node);
+            if (loglevel)
+                OSCL_DELETE(loglevel);
+            if (buf)
+            {
+                OSCL_FREE(buf);
+                buf = NULL;
+            }
+
+        }
+        else //file read returns 0
+        {
+            //We have reached the end of the file
+            bEof = true;
+        }
+
+        if (buf)
+        {
+            OSCL_FREE(buf);
+            buf = NULL;
+        }
+
+    }//end of while loop
+
+    filehandle.Close();
+    fs.Close();
+    return true;
+}
+
+// Attach a StdErrAppender to "PVAuthorEngine" at level PVLOGMSG_DEBUG
+// Returns true on success
+
+OSCL_EXPORT_REF bool PVAELogger::MakeStdErrAppender()
+{
+    int32 iStatus;
+    PVLoggerAppender *appender   = NULL;
+    OsclRefCounter	 *refCounter = NULL;
+    PVLogger		 *loggernode = NULL;
+
+    typedef StdErrAppender<TimeAndIdLayout, 1024> typeStdErrAppender;
+    OSCL_TRY(iStatus,
+             appender = new typeStdErrAppender() ;
+             OsclRefCounterSA<LogAppenderDestructDealloc<typeStdErrAppender > > *appenderRefCounter =
+                 new OsclRefCounterSA<LogAppenderDestructDealloc<typeStdErrAppender > >(appender);
+             refCounter = appenderRefCounter;
+            );
+
+    if (iStatus != OsclErrNone)
+    {
+        delete refCounter;
+        delete appender;
+        return false;
+    }
+
+    OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, refCounter);
+    loggernode = PVLogger::GetLoggerObject(_CSTR("PVAuthorEngine"));
+    loggernode->AddAppender(appenderPtr);
+    loggernode->SetLogLevel(PVLOGMSG_DEBUG);
+
+    return true;
+}
+
+OSCL_EXPORT_REF int32 PVAELogger::CreateTestAppender(char* aBuf, PVLoggerAppender*& aAppender, OsclRefCounter*& aRefCounter, OsclSharedPtr<PVLoggerAppender> &aSharedAppenderPtr)
+{
+    int32 err;
+    if (oscl_strstr(aBuf, _CSTR("LOGTOFILE")))
+    {
+        typedef TextFileAppender<TimeAndIdLayout, 1024> typeAppender;
+
+        OSCL_TRY(err,
+                 aAppender = (PVLoggerAppender*)typeAppender::CreateAppender(KLogFile);
+                 aRefCounter = new OsclRefCounterSA<LogAppenderDestructDealloc<typeAppender> >(aAppender);
+                 aSharedAppenderPtr.Bind(aAppender, aRefCounter);
+                );
+
+    }
+
+    else if (oscl_strstr(aBuf, _CSTR("LOGTOMEM")))
+    {
+        typedef MemAppender<TimeAndIdLayout, 1024> typeAppender;
+        OSCL_TRY(err,
+                 aAppender = (PVLoggerAppender*)typeAppender::CreateAppender(KLogFile);
+                 aRefCounter = new OsclRefCounterSA<LogAppenderDestructDealloc<typeAppender> >(aAppender);
+                 aSharedAppenderPtr.Bind(aAppender, aRefCounter);
+                );
+    }
+    else
+    {
+        typedef StdErrAppender<TimeAndIdLayout, 1024> typeAppender;
+        OSCL_TRY(err,
+                 aAppender = new typeAppender() ;
+                 aRefCounter = new OsclRefCounterSA<LogAppenderDestructDealloc<typeAppender> >(aAppender);
+                 aSharedAppenderPtr.Bind(aAppender, aRefCounter);
+                );
+    }
+
+    return err;
+}
diff --git a/engines/author/test/src/test_pv_author_engine_logger.h b/engines/author/test/src/test_pv_author_engine_logger.h
new file mode 100644
index 0000000..226a2ad
--- /dev/null
+++ b/engines/author/test/src/test_pv_author_engine_logger.h
@@ -0,0 +1,94 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
+#define TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
+
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+
+#ifndef OSCL_DEFALLOC_H_INCLUDED
+#include "oscl_defalloc.h"
+#endif
+
+//===================================================================
+//CLASS:       PVAELOGGER
+//===================================================================
+// Initialize logging nodes
+//===================================================================
+// Format of logging configuration file:
+// A hash mark (#) is used to indicate a comment line which will not
+// be parsed.
+// First line can be NO_LOGGING in which case no logs are created
+// and the rest of the file is skipped
+// By default logging output is directed to stderr (non-Windows) or
+// ATL Trace (Win32/WinMobile). If LOGTOFILE is specified on the first
+// line, output is redirected into a new file PVAUTHORLOG.TXT using a
+// text file appender. If LOGTOMEM is specified on the first line,
+// the output is still redirected to the file PVAUTHORLOG.TXT but using
+// a memory appender.
+// All other lines must be of the format NODENAME;LOGLEVEL where
+// nodename is the case-sensitive name of a node such as EngineHandler
+// or PVPlayer. Use ALLNODES if you want all nodes to be logged.
+// LOGLEVEL is one of :
+// PVLOGMSG_EMERG
+// PVLOGMSG_ALERT
+// PVLOGMSG_CRIT
+// PVLOGMSG_ERR
+// PVLOGMSG_WARNING
+// PVLOGMSG_NOTICE
+// PVLOGMSG_INFO
+// PVLOGMSG_STACK_TRACE
+//===================================================================
+// Example:
+//
+// # This is a sample configuration
+// LOGTOFILE
+// PVAuthorEngine;PVLOGMSG_DEBUG
+// PVAuthorEngine;PVLOGMSG_WARNING
+
+class PVAELogger
+{
+    public:
+        // Open pwszConfigFile to read nodes (and levels) to log
+        // Returns true on success
+        OSCL_IMPORT_REF static bool ParseConfigFile(const oscl_wchar *pwszConfigFile);
+
+        // Attach a StdErrAppender to "PVAtuhorEngine" at level PVLOGMSG_DEBUG
+        // Returns true on success
+        OSCL_IMPORT_REF static bool MakeStdErrAppender();
+
+        OSCL_EXPORT_REF static int32 CreateTestAppender(char *aBuf, PVLoggerAppender *&aAppender, OsclRefCounter *&aRefCounter, OsclSharedPtr<PVLoggerAppender> &aSharedAppenderPtr);
+};
+
+//===================================================================
+//CLASS:       LogAppenderDestructDealloc
+//===================================================================
+// For smart ptrs call delete when done (used by LogAppender)
+template<class DestructClass>
+class LogAppenderDestructDealloc : public OsclDestructDealloc
+{
+    public:
+        virtual void destruct_and_dealloc(OsclAny *ptr)
+        {
+            delete((DestructClass*)ptr);
+        }
+};
+
+
+#endif //TEST_PV_AUTHOR_ENGINE_LOGGER_H_INCLUDED
diff --git a/engines/author/test/src/test_pv_author_engine_testset1.cpp b/engines/author/test/src/test_pv_author_engine_testset1.cpp
index 33c3467..90f9120 100644
--- a/engines/author/test/src/test_pv_author_engine_testset1.cpp
+++ b/engines/author/test/src/test_pv_author_engine_testset1.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -113,38 +113,13 @@
     {
         case AMR_FOutput_Test:
         case AMR_Input_AOnly_3gpTest:
-        case AMR_Input_AOnly_Mp4Test:
         case AMR_YUV_Input_AV_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
-        case AMR_YUV_Input_AV_Mp4Test:
-        case Pause_Resume_Test:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case KMovieFragmentModeTest:
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
-        case AMR_FOutput_LongetivityTest:
-        case AMR_Input_AOnly_3gp_LongetivityTest:
-        case AMR_Input_AOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
+        case H264_AMR_Input_AV_3gpTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
-
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
-        case AMR_TEXT_Input_AT_Mp4Test:
+        case AMR_TEXT_Input_AT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateAudioTestInput: AMR input"));
@@ -161,7 +136,6 @@
             break;
 
         case AACADIF_FOutput_Test:
-        case AACADIF_FOutput_LongetivityTest:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateAudioTestInput: AAC-ADIF input"));
             if (testInput.IsTestInputTypeSupported(AAC_ADIF_FILE))
@@ -173,7 +147,6 @@
 
 
         case AACADTS_FOutput_Test:
-        case AACADTS_FOutput_LongetivityTest:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateAudioTestInput: AAC-ADTS input"));
             if (testInput.IsTestInputTypeSupported(AAC_ADTS_FILE))
@@ -182,31 +155,12 @@
                 status = testInput.CreateInputNode(AAC_ADTS_FILE, iInputFileNameAudio, iAVTConfig);
             }
             break;
-
-        case PCM16In_AMROut_Test:
-        case PCM16_Input_AOnly_3gpTest:
-        case PCM16_Input_AOnly_Mp4Test:
-        case PCM16_YUV_Input_AV_3gpTest:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case PCM16In_AMROut_LongetivityTest:
-        case PCM16_Input_AOnly_3gp_LongetivityTest:
-        case PCM16_Input_AOnly_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::CreateAudioTestInput: PCM16 input"));
-            if (testInput.IsTestInputTypeSupported(PCM16_FILE))
-            {
-                iAudioInputType = PCM16_FILE;
-                status = testInput.CreateInputNode(PCM16_FILE, iInputFileNameAudio, iAVTConfig);
-            }
-            break;
-
         default:
+        {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateAudioTestInput: Audio input node not needed for this test case"));
             return -1;
-            break;
+        }
     }
 
     if (!status)
@@ -227,38 +181,12 @@
 
     switch (iTestCaseNum)
     {
-        case YUV_Input_VOnly_3gpTest:
-        case YUV_Input_VOnly_Mp4Test:
         case AMR_YUV_Input_AV_3gpTest:
-        case AMR_YUV_Input_AV_Mp4Test:
-        case PCM16_YUV_Input_AV_3gpTest:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case Pause_Resume_Test:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case KMovieFragmentModeTest:
-        case YUV_Input_VOnly_3gp_LongetivityTest:
-        case YUV_Input_VOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
         case YUV_TEXT_Input_VT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
 
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
-        case YUV_TEXT_Input_VT_Mp4Test:
+        case YUV_TEXT_Input_VT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateVideoTestInput: YUV input"));
@@ -272,8 +200,6 @@
 
         case H263_Input_VOnly_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
-        case H263_Input_VOnly_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateVideoTestInput: H263 input"));
             if (testInput.IsTestInputTypeSupported(H263_FILE))
@@ -283,10 +209,7 @@
                 status = testInput.CreateInputNode(H263_FILE, iInputFileNameVideo, iAVTConfig);
             }
             break;
-        case H264_Input_VOnly_Mp4Test:
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_Input_VOnly_Mp4_LongetivityTest:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
+        case H264_AMR_Input_AV_3gpTest:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateVideoTestInput: YUV input"));
             if (testInput.IsTestInputTypeSupported(H264_FILE))
@@ -298,10 +221,11 @@
             break;
 
         default:
+        {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateVideoTestInput: Video input node not needed for this test case"));
             return -1;
-            break;
+        }
     }
 
     if (!status)
@@ -322,9 +246,9 @@
 
     switch (iTestCaseNum)
     {
-        case TEXT_Input_TOnly_Mp4Test:
-        case AMR_TEXT_Input_AT_Mp4Test:
-        case YUV_TEXT_Input_VT_Mp4Test:
+        case TEXT_Input_TOnly_3gpTest:
+        case AMR_TEXT_Input_AT_3gpTest:
+        case YUV_TEXT_Input_VT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
         case TEXT_Input_TOnly_3gp_LongetivityTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
@@ -341,10 +265,11 @@
             break;
 
         default:
+        {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
                             (0, "pvauthor_async_test_miscellaneous::CreateTextTestInput: Text input node not needed for this test case"));
             return -1;
-            break;
+        }
     }
 
     if (!status)
@@ -388,78 +313,34 @@
     switch (iTestCaseNum)
     {
         case AMR_Input_AOnly_3gpTest:
-        case PCM16_Input_AOnly_3gpTest:
-        case PCM16_YUV_Input_AV_3gpTest:
-        case YUV_Input_VOnly_3gpTest:
         case H263_Input_VOnly_3gpTest:
         case AMR_YUV_Input_AV_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
-        case Pause_Resume_Test:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case KMovieFragmentModeTest:
-        case AMR_Input_AOnly_3gp_LongetivityTest:
-        case PCM16_Input_AOnly_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-        case YUV_Input_VOnly_3gp_LongetivityTest:
-        case H263_Input_VOnly_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
         case TEXT_Input_TOnly_3gp_LongetivityTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
         case YUV_TEXT_Input_VT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
 
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
+
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
+        case H264_Input_VOnly_3gpTest:
+        case H264_AMR_Input_AV_3gpTest:
+        case TEXT_Input_TOnly_3gpTest:
+        case AMR_TEXT_Input_AT_3gpTest:
+        case YUV_TEXT_Input_VT_3gpTest:
+        case AMR_YUV_TEXT_Input_AVT_Mp4Test:
             iComposerMimeType = K3gpComposerMimeType;
             break;
 
-        case AMR_Input_AOnly_Mp4Test:
-        case PCM16_Input_AOnly_Mp4Test:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case YUV_Input_VOnly_Mp4Test:
-        case AMR_YUV_Input_AV_Mp4Test:
-        case AMR_Input_AOnly_Mp4_LongetivityTest:
-        case PCM16_Input_AOnly_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
-        case YUV_Input_VOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
-        case H264_Input_VOnly_Mp4Test:
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_Input_VOnly_Mp4_LongetivityTest:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
-        case TEXT_Input_TOnly_Mp4Test:
-        case AMR_TEXT_Input_AT_Mp4Test:
-        case YUV_TEXT_Input_VT_Mp4Test:
-        case AMR_YUV_TEXT_Input_AVT_Mp4Test:
-            iComposerMimeType = KMp4ComposerMimeType;
-            break;
-
         case AMR_FOutput_Test:
-        case PCM16In_AMROut_Test:
-        case AMR_FOutput_LongetivityTest:
-        case PCM16In_AMROut_LongetivityTest:
             iComposerMimeType = KAMRNbComposerMimeType;
             break;
 
         case AACADIF_FOutput_Test:
-        case AACADIF_FOutput_LongetivityTest:
             iComposerMimeType = KAACADIFComposerMimeType;
             break;
 
         case AACADTS_FOutput_Test:
-        case AACADTS_FOutput_LongetivityTest:
             iComposerMimeType = KAACADTSComposerMimeType;
             break;
 
@@ -502,47 +383,30 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "pvauthor_async_test_miscellaneous::ConfigAmrAacComposer"));
 
-    PVMFFormatType format = PVMF_FORMAT_UNKNOWN;
 
     switch (iTestCaseNum)
     {
         case AMR_FOutput_Test:
-        case AMR_FOutput_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KFOAOnlyAMRTestOutput;
             }
-            format = PVMF_AMR_IETF;
             break;
 
         case AACADIF_FOutput_Test:
-        case AACADIF_FOutput_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KFOAOnlyAACADIFTestOutput;
             }
-            format = PVMF_ADIF;
             break;
 
 
         case AACADTS_FOutput_Test:
-        case AACADTS_FOutput_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KFOAOnlyAACADTSTestOutput;
             }
-            format = PVMF_ADTS;
             break;
-
-        case PCM16In_AMROut_Test:
-        case PCM16In_AMROut_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPCM16TestOutput;
-            }
-            format = PVMF_AMR_IETF;
-            break;
-
         default:
             if (!((iComposerMimeType == KAMRNbComposerMimeType) || (iComposerMimeType == KAACADTSComposerMimeType) || (iComposerMimeType == KAACADIFComposerMimeType)))
             {
@@ -578,183 +442,56 @@
     switch (iTestCaseNum)
     {
         case AMR_Input_AOnly_3gpTest:
-        case AMR_Input_AOnly_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KAMRInputAOnly3gpTestOutput;
             }
             break;
-        case AMR_Input_AOnly_Mp4Test:
-        case AMR_Input_AOnly_Mp4_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KAMRInputAOnlyMp4TestOutput;
-            }
-            break;
-        case YUV_Input_VOnly_3gpTest:
-        case YUV_Input_VOnly_3gp_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KYUVInputVOnly3gpTestOutput;
-            }
-            break;
         case H263_Input_VOnly_3gpTest:
-        case H263_Input_VOnly_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KH263InputVOnly3gpTestOutput;
             }
             break;
-        case YUV_Input_VOnly_Mp4Test:
-        case YUV_Input_VOnly_Mp4_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KYUVInputVOnlyMp4TestOutput;
-            }
-            break;
         case AMR_YUV_Input_AV_3gpTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KAMRYUVInputAV3gpTestOutput;
             }
             break;
         case AMR_H263_Input_AV_3gpTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KAMRH263InputAV3gpTestOutput;
             }
             break;
-        case AMR_YUV_Input_AV_Mp4Test:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KAMRYUVInputAVMp4TestOutput;
             }
             break;
-        case KMaxFileSizeTest:
-        case KMaxFileSizeLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KMaxFileSizeTestOutput;
-            }
-            break;
-        case KMaxDurationTest:
-        case KMaxDurationLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KMaxDurationTestOutput;
-            }
-            break;
-        case KFileSizeProgressTest:
-        case KFileSizeProgressLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KFileSizeProgressTestOutput;
-            }
-            break;
-        case KDurationProgressTest:
-        case KDurationProgressLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KDurationProgressTestOutput;
-            }
-            break;
-        case PCM16_Input_AOnly_3gpTest:
-        case PCM16_Input_AOnly_3gp_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPCM16AOnly3gpTestOutput;
-            }
-            break;
-        case PCM16_Input_AOnly_Mp4Test:
-        case PCM16_Input_AOnly_Mp4_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPCM16AOnlyMp4TestOutput;
-            }
-            break;
-        case PCM16_YUV_Input_AV_3gpTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPCM16YUVInputAV3gpTestOutput;
-            }
-            break;
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPCM16YUVInputAVMp4TestOutput;
-            }
-            break;
-        case Pause_Resume_Test:
-
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPauseResumeTestOutput;
-            }
-            break;
-
-        case KFastTrackContentModeTest:
-        case KFastTrackContentModeLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KFastTrackContentModeTestOutput;
-            }
-            break;
-        case K3GPPDownloadModeTest:
-        case K3GPPDownloadModeLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = K3GPPDownloadModeTestOutput;
-            }
-            break;
-        case K3GPPProgressiveDownloadModeTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = K3GPPProgressiveDownloadModeTestOutput;
-            }
-            break;
-
-        case KMovieFragmentModeTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KMovieFragmentModeTestOutput;
-            }
-            break;
-
-        case H264_Input_VOnly_Mp4Test:
-        case H264_Input_VOnly_Mp4_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KH264InputVOnlyMp4TestOutput;
-            }
-            break;
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
+        case H264_AMR_Input_AV_3gpTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KH264AMRInputAVMp4TestTestOutput;
             }
             break;
-        case TEXT_Input_TOnly_Mp4Test:
+        case TEXT_Input_TOnly_3gpTest:
         case TEXT_Input_TOnly_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KTEXTInputMp4TestOutput;
             }
             break;
-        case AMR_TEXT_Input_AT_Mp4Test:
+        case AMR_TEXT_Input_AT_3gpTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KAMRTEXTInputMp4TestOutput;
             }
             break;
-        case YUV_TEXT_Input_VT_Mp4Test:
+        case YUV_TEXT_Input_VT_3gpTest:
         case YUV_TEXT_Input_VT_3gp_LongetivityTest:
             if (iOutputFileName == NULL)
             {
@@ -796,130 +533,27 @@
     iCopyrightString = _STRLIT("copyright");
     iDescriptionString = _STRLIT("description");
     iRatingString = _STRLIT("rating");
+    iAlbumTitle   = _STRLIT("albumtitle");
+    iRecordingYear = 2008;
+
+    OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
 
     clipConfig->SetOutputFileName(iOutputFileName);
     clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(iVersionString);
-    clipConfig->SetTitle(iTitleString);
-    clipConfig->SetAuthor(iAuthorString);
-    clipConfig->SetCopyright(iCopyrightString);
-    clipConfig->SetDescription(iDescriptionString);
-    clipConfig->SetRating(iRatingString);
-    if (iTestCaseNum == KFastTrackContentModeTest)
-    {
-        clipConfig->SetAuthoringMode(PVMP4FFCN_PV_FAST_TRACK_CONTENT_MODE);
-    }
-    else if (iTestCaseNum == K3GPPDownloadModeTest)
-    {
-        clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_DOWNLOAD_MODE);
-    }
-    else if (iTestCaseNum == K3GPPProgressiveDownloadModeTest)
-    {
-        clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_PROGRESSIVE_DOWNLOAD_MODE);
-    }
-    else if (iTestCaseNum == KMovieFragmentModeTest)
-    {
-        clipConfig->SetAuthoringMode(PVMP4FFCN_MOVIE_FRAGMENT_MODE);
-    }
+    clipConfig->SetVersion(iVersionString, lang_code);
+    clipConfig->SetTitle(iTitleString, lang_code);
+    clipConfig->SetAuthor(iAuthorString, lang_code);
+    clipConfig->SetCopyright(iCopyrightString, lang_code);
+    clipConfig->SetDescription(iDescriptionString, lang_code);
+    clipConfig->SetRating(iRatingString, lang_code);
+    clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
+    clipConfig->SetRecordingYear(iRecordingYear);
 
 
     return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_miscellaneous::ConfigComposerOutput()
-{
-    PvmfComposerSizeAndDurationInterface* config =
-        OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
-    if (!config)
-    {
-        return false;
-    }
-    bool enabled = false;
-    uint32 configData = 0;
-    switch (iTestCaseNum)
-    {
-        case KMaxFileSizeTest:
-        case KMaxFileSizeLongetivityTest:
-            if (config->SetMaxFileSize(true, KMaxFileSize) != PVMFSuccess)
-            {
-                return false;
-            }
-            config->GetMaxFileSizeConfig(enabled, configData);
-            if (!enabled || configData != KMaxFileSize)
-            {
-                return false;
-            }
-            break;
-
-        case KMaxDurationLongetivityTest:
-        case KMaxDurationTest:
-            if (config->SetMaxDuration(true, KMaxDuration) != PVMFSuccess)
-            {
-                return false;
-            }
-            config->GetMaxDurationConfig(enabled, configData);
-            if (!enabled || configData != KMaxDuration)
-            {
-                return false;
-            }
-            break;
-
-        case KFileSizeProgressLongetivityTest:
-        case KFileSizeProgressTest:
-            if (config->SetFileSizeProgressReport(true, KFileSizeProgressFreq) != PVMFSuccess)
-            {
-                return false;
-            }
-            config->GetFileSizeProgressReportConfig(enabled, configData);
-            if (!enabled || configData != KFileSizeProgressFreq)
-            {
-                return false;
-            }
-            break;
-
-        case KDurationProgressTest:
-        case KDurationProgressLongetivityTest:
-            if (config->SetDurationProgressReport(true, KDurationProgressFreq) != PVMFSuccess)
-            {
-                return false;
-            }
-            config->GetDurationProgressReportConfig(enabled, configData);
-            if (!enabled || configData != KDurationProgressFreq)
-            {
-                return false;
-            }
-            break;
-
-        default:
-            break;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_miscellaneous::QueryComposerOutputInterface()
-{
-    switch (iTestCaseNum)
-    {
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case Generic_QueryInterface_Reset_Test:
-            iAuthor->QueryInterface(PvmfComposerSizeAndDurationUuid,
-                                    iOutputSizeAndDurationConfig, (OsclAny*)iAuthor);
-            return true;
-
-        default:
-            return false;
-    }
-}
 
 ////////////////////////////////////////////////////////////////////////////
 bool pvauthor_async_test_miscellaneous::AddAudioMediaTrack()
@@ -930,60 +564,22 @@
     switch (iTestCaseNum)
     {
         case AMR_Input_AOnly_3gpTest:
-        case AMR_Input_AOnly_Mp4Test:
         case AMR_YUV_Input_AV_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
-        case AMR_YUV_Input_AV_Mp4Test:
-        case PCM16In_AMROut_Test:
-        case PCM16_Input_AOnly_3gpTest:
-        case PCM16_Input_AOnly_Mp4Test:
-        case PCM16_YUV_Input_AV_3gpTest:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case Pause_Resume_Test:
-        case AMR_TEXT_Input_AT_Mp4Test:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
+        case AMR_TEXT_Input_AT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
         case AMR_FOutput_Test:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case KMovieFragmentModeTest:
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
-        case AMR_Input_AOnly_3gp_LongetivityTest:
-        case AMR_Input_AOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
+        case H264_AMR_Input_AV_3gpTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
-        case PCM16In_AMROut_LongetivityTest:
-        case PCM16_Input_AOnly_3gp_LongetivityTest:
-        case PCM16_Input_AOnly_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
-
-        case AMR_FOutput_LongetivityTest:
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
             iAudioEncoderMimeType = KAMRNbEncMimeType;
             break;
 
-
         case AACADIF_FOutput_Test:
-        case AACADIF_FOutput_LongetivityTest:
             iAudioEncoderMimeType = KAACADIFEncMimeType;
             break;
         case AACADTS_FOutput_Test:
-        case AACADTS_FOutput_LongetivityTest:
             iAudioEncoderMimeType = KAACADTSEncMimeType;
             break;
 
@@ -1038,56 +634,25 @@
         case H263_Input_VOnly_3gpTest:
         case AMR_H263_Input_AV_3gpTest:
         case PCM16_YUV_Input_AV_3gpTest:
-        case KMaxFileSizeTest:
-        case KMaxDurationTest:
-        case KFileSizeProgressTest:
-        case KDurationProgressTest:
-        case KFastTrackContentModeTest:
-        case K3GPPDownloadModeTest:
-        case K3GPPProgressiveDownloadModeTest:
-        case KMovieFragmentModeTest:
             iVideoEncoderMimeType = KH263EncMimeType;
             break;
-        case YUV_Input_VOnly_3gp_LongetivityTest:
-        case AMR_YUV_Input_AV_3gp_LongetivityTest:
-        case H263_Input_VOnly_3gp_LongetivityTest:
-        case AMR_H263_Input_AV_3gp_LongetivityTest:
-        case PCM16_YUV_Input_AV_3gp_LongetivityTest:
         case YUV_TEXT_Input_VT_3gp_LongetivityTest:
         case AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest:
-        case KMaxFileSizeLongetivityTest:
-        case KMaxDurationLongetivityTest:
-        case KFileSizeProgressLongetivityTest:
-        case KDurationProgressLongetivityTest:
-        case KFastTrackContentModeLongetivityTest:
-        case K3GPPDownloadModeLongetivityTest:
-        case K3GPPProgressiveDownloadModeLongetivityTest:
             iVideoEncoderMimeType = KH263EncMimeType;
             break;
 
-
-        case YUV_Input_VOnly_Mp4Test:
-        case AMR_YUV_Input_AV_Mp4Test:
-        case PCM16_YUV_Input_AV_Mp4Test:
-        case Pause_Resume_Test:
-        case YUV_TEXT_Input_VT_Mp4Test:
+        case AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest:
+        case YUV_TEXT_Input_VT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
-        case YUV_Input_VOnly_Mp4_LongetivityTest:
-        case AMR_YUV_Input_AV_Mp4_LongetivityTest:
-        case PCM16_YUV_Input_AV_Mp4_LongetivityTest:
             iVideoEncoderMimeType = KMp4EncMimeType;
             break;
-        case H264_Input_VOnly_Mp4Test:
-        case H264_AMR_Input_AV_Mp4Test:
-        case H264_Input_VOnly_Mp4_LongetivityTest:
-        case H264_AMR_Input_AV_Mp4_LongetivityTest:
+        case H264_AMR_Input_AV_3gpTest:
             iVideoEncoderMimeType = KH264EncMimeType;
             break;
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                             (0, "pvauthor_async_test_miscellaneous::AddVideoMediaTrack: Video encoder not used in this test case."));
             return false;
-            break;
     }
 
     if (iVideoInputType == INVALID_INPUT_TYPE)
@@ -1130,9 +695,9 @@
 
     switch (iTestCaseNum)
     {
-        case TEXT_Input_TOnly_Mp4Test:
-        case AMR_TEXT_Input_AT_Mp4Test:
-        case YUV_TEXT_Input_VT_Mp4Test:
+        case TEXT_Input_TOnly_3gpTest:
+        case AMR_TEXT_Input_AT_3gpTest:
+        case YUV_TEXT_Input_VT_3gpTest:
         case AMR_YUV_TEXT_Input_AVT_Mp4Test:
         case TEXT_Input_TOnly_3gp_LongetivityTest:
         case AMR_TEXT_Input_AT_3gp_LongetivityTest:
@@ -1195,7 +760,8 @@
     config->SetOutputBitRate(0, KVideoBitrate);
     config->SetOutputFrameSize(0, iAVTConfig.iWidth , iAVTConfig.iHeight);
     config->SetOutputFrameRate(0, iAVTConfig.iFps);
-    config->SetIFrameInterval(iAVTConfig.iFrameInterval);
+    config->SetIFrameInterval(KVideoIFrameInterval);
+    config->SetSceneDetection(true);
 
     return true;
 }
@@ -1259,11 +825,7 @@
     uint32 minDuration = 0;
     uint32 ii = 0;
 
-    if (iTestCaseNum >= LongetivityTestBegin && iTestCaseNum <= AAC_OUTPUT_LongetivityTestEnd)
-    {
-        minDuration = iTestDuration / 1000; //in msec
-    }
-    else if (iTestCaseNum == Input_Stream_Looping_Test)
+    if (iTestCaseNum >= CompressedLongetivityTestBegin && iTestCaseNum <= Compressed_LongetivityTestEnd)
     {
         minDuration = iTestDuration / 1000; //in msec
     }
@@ -1459,14 +1021,6 @@
             SelectComposer();
             break;
 
-        case PVAE_CMD_QUERY_INTERFACE:
-            if (!QueryComposerOutputInterface())
-            {
-                iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            break;
-
         case PVAE_CMD_ADD_AUDIO_MEDIA_TRACK:
             if (!AddAudioMediaTrack())
             {
@@ -1530,7 +1084,10 @@
         case PVAE_CMD_RESET:
         {
             ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
+            if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
+            {
+                iAuthor->Reset((OsclAny*)iAuthor);
+            }
         }
         break;
         case PVAE_CMD_REMOVE_DATA_SOURCE:
@@ -1597,7 +1154,7 @@
     if (aResponse.GetCmdStatus() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_generic_reset::CommandCompleted iState:%d FAILED", iState));
+                        (0, "pvauthor_async_test_miscellaneous::CommandCompleted iState:%d FAILED", iState));
     }
     switch (iState)
     {
@@ -1672,7 +1229,7 @@
                 }
                 else
                 {
-                    iState = PVAE_CMD_QUERY_INTERFACE;
+                    iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
                     RunIfNotReady();
                 }
             }
@@ -1684,21 +1241,6 @@
                 RunIfNotReady();
             }
             break;
-        case PVAE_CMD_QUERY_INTERFACE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                ConfigComposerOutput();
-                iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            else
-            {
-                // QueryInterface failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
         case PVAE_CMD_ADD_AUDIO_MEDIA_TRACK:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1881,6 +1423,7 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
+                OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
                 iObserver->CompleteTest(*iTestCase);
             }
             break;
diff --git a/engines/author/test/src/test_pv_author_engine_testset1.h b/engines/author/test/src/test_pv_author_engine_testset1.h
index fa3d6f0..0973c73 100644
--- a/engines/author/test/src/test_pv_author_engine_testset1.h
+++ b/engines/author/test/src/test_pv_author_engine_testset1.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -166,9 +166,6 @@
         bool ConfigAmrAacComposer();
         bool ConfigMp43gpComposer();
 
-        // Method to configure max filesize/duration interface
-        bool QueryComposerOutputInterface();
-        bool ConfigComposerOutput();
 
         // Methods to add media tracks
         bool AddAudioMediaTrack();
@@ -203,6 +200,8 @@
         OSCL_wHeapString<OsclMemAllocator> iCopyrightString;
         OSCL_wHeapString<OsclMemAllocator> iDescriptionString;
         OSCL_wHeapString<OsclMemAllocator> iRatingString;
+        OSCL_wHeapString<OsclMemAllocator> iAlbumTitle;
+        uint16							   iRecordingYear;
 
         AVTConfig iAVTConfig;
         Oscl_Vector<PVAETestInput, OsclMemAllocator> iTestInputs;
diff --git a/engines/author/test/src/test_pv_author_engine_testset2.cpp b/engines/author/test/src/test_pv_author_engine_testset2.cpp
deleted file mode 100644
index 2e23174..0000000
--- a/engines/author/test/src/test_pv_author_engine_testset2.cpp
+++ /dev/null
@@ -1,1234 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET2_H_INCLUDED
-#include "test_pv_author_engine_testset2.h"
-#endif
-
-#ifndef PVMF_COMPOSER_SIZE_AND_DURATION_H_INCLUDED
-#include "pvmf_composer_size_and_duration.h"
-#endif
-
-#ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
-#include "pvmf_fileoutput_config.h"
-#endif
-
-#ifndef PVMP4FFCN_CLIPCONFIG_H_INCLUDED
-#include "pvmp4ffcn_clipconfig.h"
-#endif
-
-#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-#include "pvmp4h263encextension.h"
-#endif
-
-#ifndef PVAETEST_NODE_CONFIG_H_INCLUDED
-#include "pvaetest_node_config.h"
-#endif
-
-void pvauthor_async_test_generic_reset::StartTest()
-{
-    AddToScheduler();
-    iState = PVAE_CMD_CREATE;
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                    (0, "******pvauthor_async_test_generic_reset::iTestCaseNum:%d******", iTestCaseNum));
-    RunIfNotReady();
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_generic_reset::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
-{
-    OSCL_UNUSED_ARG(aEvent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pvauthor_async_test_generic_reset::HandleErrorEvent"));
-    PVPATB_TEST_IS_TRUE(false);
-    iObserver->CompleteTest(*iTestCase);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_generic_reset::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
-{
-    OSCL_UNUSED_ARG(aEvent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::HandleInformationalEvent"));
-    OsclAny* eventData = NULL;
-    switch (aEvent.GetEventType())
-    {
-        case PVMF_COMPOSER_MAXFILESIZE_REACHED:
-        case PVMF_COMPOSER_MAXDURATION_REACHED:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::HandleNodeInformationalEvent: Max file size reached"));
-            Cancel();
-            PVPATB_TEST_IS_TRUE(true);
-            iObserver->CompleteTest(*iTestCase);
-            break;
-
-        case PVMF_COMPOSER_DURATION_PROGRESS:
-            aEvent.GetEventData(eventData);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::HandleNodeInformationalEvent: Duration progress: %d ms",
-                             (int32)eventData));
-            fprintf(iStdOut, "Duration: %d ms\n", (int32)eventData);
-            break;
-
-        case PVMF_COMPOSER_FILESIZE_PROGRESS:
-            aEvent.GetEventData(eventData);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::HandleNodeInformationalEvent: File size progress: %d bytes",
-                             (int32)eventData));
-            fprintf(iStdOut, "File size: %d bytes\n", (int32)eventData);
-            break;
-
-        case PVMF_COMPOSER_EOS_REACHED:
-            //Engine already stopped at EOS so send reset command.
-            iState = PVAE_CMD_RESET;
-            //cancel recording timeout scheduled for timer object.
-            Cancel();
-            RunIfNotReady();
-            break;
-        default:
-            break;
-    }
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_generic_reset::CreateAudioInput()
-{
-    int status = 0;
-    PVAETestInput testInput;
-
-    if (iAudioInputType == INVALID_INPUT_TYPE)	// check condition when -audio tag is not specified
-    {
-        return -1;
-    }
-    else
-    {
-        status = testInput.CreateInputNode(iAudioInputType, iInputFileNameAudio, iAVTConfig);
-    }
-
-    if (!status)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::CreateAudioTestInput: Error - Create input node failed"));
-        return status;
-    }
-
-    return AddDataSource(testInput);
-}
-
-////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_generic_reset::CreateVideoInput()
-{
-    int status = 0;
-    PVAETestInput testInput;
-
-    if (iVideoInputType == INVALID_INPUT_TYPE)	// check condition when -videoo tag is not specified
-    {
-        return -1;
-    }
-    else
-    {
-        testInput = PVAETestInput();
-        status = testInput.CreateInputNode(iVideoInputType, iInputFileNameVideo, iAVTConfig);
-    }
-
-    if (!status)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::CreateTestInputs: Error - CreateInputNode failed"));
-        return status;
-    }
-
-    return AddDataSource(testInput);
-}
-
-////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_generic_reset::CreateTextInput()
-{
-    int status = 0;
-    PVAETestInput testInput;
-
-    if (iTextInputType == INVALID_INPUT_TYPE)	// check condition when -video tag is not specified
-    {
-        return -1;
-    }
-    else
-    {
-        testInput = PVAETestInput();
-        status = testInput.CreateInputNode(iTextInputType, iInputFileNameText, iAVTConfig);
-    }
-
-    if (!status)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::CreateTestInputs: Error - CreateInputNode failed"));
-        return status;
-    }
-
-    return AddDataSource(testInput);
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::AddDataSource(PVAETestInput& aInput)
-{
-    int32 err = 0;
-
-    OSCL_TRY(err, iTestInputs.push_back(aInput););
-    if (err != OSCL_ERR_NONE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddDataSource: Error - iTestInputs.push_back failed. err=0x%x", err));
-        aInput.DeleteInputNode();
-        return false;
-    }
-
-
-    OSCL_TRY(err, iAuthor->AddDataSource(*(aInput.iNode), (OsclAny*)iAuthor););
-    if (err != OSCL_ERR_NONE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
-        aInput.DeleteInputNode();
-        return false;
-    }
-
-    return true;
-}
-
-void pvauthor_async_test_generic_reset::SelectComposer()
-{
-    iAuthor->SelectComposer(iComposerMimeType, iComposerConfig, (OsclAny*)iAuthor);
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::ConfigComposer()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::ConfigComposer"));
-    if ((iTestCaseNum >= GenericTestBegin) && (iTestCaseNum < GenericTestEnd))
-    {
-        uint32 aLenFileName;
-        aLenFileName = oscl_strlen(iTempOutputFileName) - oscl_strlen(oscl_strchr(iTempOutputFileName, '.'));
-        oscl_wchar temp[ARRAY_SIZE];
-        oscl_memset(temp, 0, ARRAY_SIZE);
-        oscl_strncpy(temp, iTempOutputFileName, aLenFileName);
-        oscl_snprintf(temp + aLenFileName, ARRAY_SIZE, _STRLIT("_GenericReset_TestNum_%d"), iTestCaseNum);
-        oscl_strcat(temp, oscl_strchr(iTempOutputFileName, '.'));
-        iOutputFileName = temp;
-    }
-
-    if (!ConfigAmrAacComposer())
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::ConfigComposer: Error - ConfigAmrAacComposer failed"));
-        return false;
-    }
-
-    //Not needed we pick up the output filename from cmd line
-
-    if (!ConfigMp43gpComposer())
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::ConfigComposer: Error - ConfigMp43gpComposer failed"));
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::ConfigAmrAacComposer()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::ConfigAmrAacComposer"));
-
-
-    if (!((iComposerMimeType == KAMRNbComposerMimeType) || (iComposerMimeType == KAACADTSComposerMimeType) || (iComposerMimeType == KAACADIFComposerMimeType)))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_test_generic_reset::ConfigAmrAacComposer: AMR-AAC Composer not used in this test case"));
-        return true;
-    }
-
-
-    PvmfFileOutputNodeConfigInterface* clipConfig = OSCL_STATIC_CAST(PvmfFileOutputNodeConfigInterface*, iComposerConfig);
-    if (!clipConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::ConfigAmrAacComposer: Error - Invalid iComposerConfig"));
-        return false;
-    }
-
-    if (clipConfig->SetOutputFileName(iOutputFileName) != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::ConfigAmrAacComposer: Error - SetOutputFileName failed"));
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::ConfigMp43gpComposer()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                    (0, "pvauthor_async_test_generic_reset::ConfigMp43gpComposer"));
-
-    if (!(iComposerMimeType == KAMRNbComposerMimeType) && !(iComposerMimeType == KAACADTSComposerMimeType) && !(iComposerMimeType == KAACADIFComposerMimeType))
-    {
-        //break;
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_generic_reset::ConfigMp43gpComposer: Mp4-3GPP composer not used in this test case"));
-        return true;
-    }
-
-    PVMp4FFCNClipConfigInterface* clipConfig;
-    clipConfig = OSCL_STATIC_CAST(PVMp4FFCNClipConfigInterface*, iComposerConfig);
-    if (!clipConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::ConfigMp43gpComposer: Error - iComposerConfig==NULL"));
-        return false;
-    }
-
-    iVersionString = _STRLIT("version");
-    iTitleString = _STRLIT("title");
-    iAuthorString = _STRLIT("author");
-    iCopyrightString = _STRLIT("copyright");
-    iDescriptionString = _STRLIT("description");
-    iRatingString = _STRLIT("rating");
-
-    clipConfig->SetOutputFileName(iOutputFileName);
-    clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(iVersionString);
-    clipConfig->SetTitle(iTitleString);
-    clipConfig->SetAuthor(iAuthorString);
-    clipConfig->SetCopyright(iCopyrightString);
-    clipConfig->SetDescription(iDescriptionString);
-    clipConfig->SetRating(iRatingString);
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::ConfigComposerOutput()
-{
-    PvmfComposerSizeAndDurationInterface* config =
-        OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
-    if (!config)
-        return false;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::QueryComposerOutputInterface()
-{
-    switch (iTestCaseNum)
-    {
-        case Generic_QueryInterface_Reset_Test:
-            iAuthor->QueryInterface(PvmfComposerSizeAndDurationUuid,
-                                    iOutputSizeAndDurationConfig, (OsclAny*)iAuthor);
-            return true;
-
-        default:
-            return false;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::AddAudioMediaTrack()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::AddAudioMediaTrack"));
-
-    if (iAudioInputType == INVALID_INPUT_TYPE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddAudioMediaTrackL: Error - Invalid audio input type"));
-        return false;
-    }
-
-    bool testInputFound = false;
-    PVAETestInput testInput;
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-    {
-        if (iTestInputs[ii].iType == iAudioInputType)
-        {
-            testInputFound = true;
-            testInput = iTestInputs[ii];
-            break;
-        }
-    }
-
-    if (!testInputFound)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddAudioMediaTrack: Error - Test input not found"));
-        return false;
-    }
-
-    iAuthor->AddMediaTrack(*(testInput.iNode), iAudioEncoderMimeType, iComposer,
-                           iAudioEncoderConfig, (OsclAny*)iAuthor);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::AddVideoMediaTrack()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::AddVideoMediaTrack"));
-
-    if (iVideoInputType == INVALID_INPUT_TYPE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddVideoMediaTrack: Error - Invalid input type"));
-        return false;
-    }
-
-    bool testInputFound = false;
-    PVAETestInput testInput;
-
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-    {
-        if (iTestInputs[ii].iType == iVideoInputType)
-        {
-            testInputFound = true;
-            testInput = iTestInputs[ii];
-            break;
-        }
-    }
-
-    if (!testInputFound)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddVideoMediaTrack: Error - Test input not found"));
-        return false;
-    }
-
-    iAuthor->AddMediaTrack(*(testInput.iNode), iVideoEncoderMimeType, iComposer,
-                           iVideoEncoderConfig, (OsclAny*)iAuthor);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::AddTextMediaTrack()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::AddTextMediaTrack"));
-
-    if (iTextInputType == INVALID_INPUT_TYPE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddTextMediaTrack: Error - Invalid input type"));
-        return false;
-    }
-
-    bool testInputFound = false;
-    PVAETestInput testInput;
-
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-    {
-        if (iTestInputs[ii].iType == iTextInputType)
-        {
-            testInputFound = true;
-            testInput = iTestInputs[ii];
-            break;
-        }
-    }
-
-    if (!testInputFound)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_generic_reset::AddTextMediaTrack: Error - Test input not found"));
-        return false;
-    }
-
-    iAuthor->AddMediaTrack(*(testInput.iNode), iTextEncoderMimeType, iComposer,
-                           iTextEncoderConfig, (OsclAny*)iAuthor);
-    return true;
-}
-bool pvauthor_async_test_generic_reset::ConfigureVideoEncoder()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::ConfigureVideoEncoder"));
-
-    PVMp4H263EncExtensionInterface* config;
-    config = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, iVideoEncoderConfig);
-    if (!config)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_generic_reset::ConfigureVideoEncoder: No configuration needed"));
-        return true;
-    }
-
-    config->SetNumLayers(1);
-    config->SetOutputBitRate(0, KVideoBitrate);
-    config->SetOutputFrameSize(0, iAVTConfig.iWidth , iAVTConfig.iHeight);
-    config->SetOutputFrameRate(0, iAVTConfig.iFps);
-    config->SetIFrameInterval(iAVTConfig.iFrameInterval);
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::ConfigureAudioEncoder()
-{
-    // Single core AMR encoder node support
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::ConfigureAudioEncoder"));
-
-    if (!iAudioEncoderConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_generic_reset::ConfigureAudioEncoder: No configuration needed"));
-        return true;
-    }
-
-    return PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig);
-}
-
-bool pvauthor_async_test_generic_reset::ConfigureTextEncoder()
-{
-    // Single core AMR encoder node support
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::ConfigureAudioEncoder"));
-
-    if (!iTextEncoderConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_generic_reset::ConfigureTextEncoder: No configuration needed"));
-        return true;
-    }
-
-    return true;
-}
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_generic_reset::DeleteTestInputs()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::DeleteTestInputs"));
-
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-        iTestInputs[ii].DeleteInputNode();
-
-    iTestInputs.clear();
-    return true;
-}
-
-void pvauthor_async_test_generic_reset::ResetAuthorConfig()
-{
-    if (iComposerConfig)
-    {
-        iComposerConfig->removeRef();
-        iComposerConfig = NULL;
-    }
-    if (iAudioEncoderConfig)
-    {
-        iAudioEncoderConfig->removeRef();
-        iAudioEncoderConfig = NULL;
-    }
-    if (iVideoEncoderConfig)
-    {
-        iVideoEncoderConfig->removeRef();
-        iVideoEncoderConfig = NULL;
-    }
-    if (iTextEncoderConfig)
-    {
-        iTextEncoderConfig->removeRef();
-        iTextEncoderConfig = NULL;
-    }
-}
-
-void pvauthor_async_test_generic_reset::Cleanup()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_test_generic_reset::Cleanup"));
-
-    iComposer = NULL;
-
-    ResetAuthorConfig();
-
-    if (iAuthor)
-    {
-        PVAuthorEngineFactory::DeleteAuthor(iAuthor);
-        iAuthor = NULL;
-    }
-
-    DeleteTestInputs();
-    iOutputFileName = NULL;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_generic_reset::Run()
-{
-    switch (iState)
-    {
-        case PVAE_CMD_CREATE:
-        {
-            iAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this);
-            if (!iAuthor)
-            {
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-
-            }
-            else
-            {
-                iState = PVAE_CMD_OPEN;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_OPEN:
-            iAuthor->Open((OsclAny*)iAuthor);
-            break;
-
-        case PVAE_CMD_ADD_DATA_SOURCE_AUDIO:
-        {
-            int aStatus = -1;
-            // Create audio input
-            aStatus = CreateAudioInput();
-            if (aStatus == 0) //Failed while creating audio input
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_generic_reset::CreateTestInputs: Error - CreateAudioInput() failed"));
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (aStatus == -1) //Failed due to test being audio only or video only
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_VIDEO;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_ADD_DATA_SOURCE_VIDEO:
-        {
-            // Create video input
-            int aStatus = -1;
-            aStatus = CreateVideoInput();
-            if (aStatus == 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_generic_reset::CreateTestInputs: Error - CreateVideoInput() failed"));
-                Cleanup();
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (aStatus == -1) //Failed due to test being audio only or video only
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_TEXT;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_ADD_DATA_SOURCE_TEXT:
-        {
-            // Create text input
-            int aStatus = -1;
-            aStatus = CreateTextInput();
-            if (aStatus == 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_generic_reset::CreateTestInputs: Error - CreateTextInput() failed"));
-                Cleanup();
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (aStatus == -1) //Failed due to test being audio only or video only
-            {
-                iState = PVAE_CMD_SELECT_COMPOSER;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_SELECT_COMPOSER:
-            SelectComposer();
-            break;
-
-        case PVAE_CMD_QUERY_INTERFACE:
-            if (!QueryComposerOutputInterface())
-            {
-                iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_AUDIO_MEDIA_TRACK:
-            if (!AddAudioMediaTrack())
-            {
-                bAudioTrack = false;
-                iState = PVAE_CMD_ADD_VIDEO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_VIDEO_MEDIA_TRACK:
-        {
-            bool bVideoTrack = AddVideoMediaTrack();
-            if (!bVideoTrack && !bAudioTrack) //No tracks have been added
-            {
-                bVideoTrack = false;
-                iState = PVAE_CMD_ADD_TEXT_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            else if (!bVideoTrack) //Audio track added but no video track
-            {
-                iState = PVAE_CMD_ADD_TEXT_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_ADD_TEXT_MEDIA_TRACK:
-        {
-            bool bTextTrack = AddTextMediaTrack();
-            if (!bTextTrack && !bVideoTrack && !bAudioTrack) //No tracks have been added
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_generic_reset::CommandCompleted: Error - No track added"));
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (!bTextTrack) //Audio and video tracks added but no text track
-            {
-                iState = PVAE_CMD_INIT;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_INIT:
-            iAuthor->Init((OsclAny*)iAuthor);
-            break;
-
-        case PVAE_CMD_START:
-            iAuthor->Start();
-            break;
-        case PVAE_CMD_STOP:
-            iAuthor->Stop((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_RESET:
-        {
-            ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
-        }
-        break;
-        case PVAE_CMD_REMOVE_DATA_SOURCE:
-        {
-            for (uint ii = 0; ii < iTestInputs.size(); ii++)
-            {
-                iAuthor->RemoveDataSource(*(iTestInputs[ii].iNode), (OsclAny*)iAuthor);
-            }
-        }
-        break;
-        case PVAE_CMD_CLOSE:
-            iAuthor->Close((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_PAUSE:
-            iAuthor->Pause((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_RESUME:
-            iAuthor->Resume((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_CLEANUPANDCOMPLETE:
-        {
-            Cleanup();
-            iObserver->CompleteTest(*iTestCase);
-        }
-        break;
-
-        case PVAE_CMD_QUERY_INTERFACE2:
-            break;
-        case PVAE_CMD_ADD_DATA_SINK:
-            break;
-        case PVAE_CMD_REMOVE_DATA_SINK:
-            break;
-        default:
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_generic_reset::CommandCompleted(const PVCmdResponse& aResponse)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_generic_reset::CommandCompleted iState:%d", iState));
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_generic_reset::CommandCompleted iState:%d FAILED", iState));
-    }
-    switch (iState)
-    {
-        case PVAE_CMD_OPEN:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_ADD_DATA_SOURCE_AUDIO;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // Open failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_DATA_SOURCE_AUDIO:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_ADD_DATA_SOURCE_VIDEO;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // AddDataSourceAudio failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_DATA_SOURCE_VIDEO:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_ADD_DATA_SOURCE_TEXT;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // AddDataSourceVideo failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_DATA_SOURCE_TEXT:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_SELECT_COMPOSER;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // AddDataSourceText failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_SELECT_COMPOSER:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iComposer = aResponse.GetResponseData();
-                if (!ConfigComposer())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_generic_reset::CommandCompleted: Error - ConfigComposer failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                    return;
-                }
-                else
-                {
-                    if (iState == iStateToReset)
-                    {
-                        iState = PVAE_CMD_RESET;
-                        RunIfNotReady();
-                    }
-                    else
-                    {
-                        iState = PVAE_CMD_QUERY_INTERFACE;
-                        RunIfNotReady();
-                    }
-                }
-            }
-            else
-            {
-                // SelectComposer failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_QUERY_INTERFACE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                ConfigComposerOutput();
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // QueryInterface failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_AUDIO_MEDIA_TRACK:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (!ConfigureAudioEncoder())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_generic_reset::CommandCompleted: Error - ConfigureAudioEncoder failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iState = PVAE_CMD_CLOSE;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    if (iState == iStateToReset)
-                    {
-                        iState = PVAE_CMD_RESET;
-                        RunIfNotReady();
-                    }
-                    else
-                    {
-                        iState = PVAE_CMD_ADD_VIDEO_MEDIA_TRACK;
-                        RunIfNotReady();
-                    }
-                }
-            }
-            else
-            {
-                // AddAudioMediaTrack failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_VIDEO_MEDIA_TRACK:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (!ConfigureVideoEncoder())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_generic_reset::CommandCompleted: Error - ConfigureVideoEncoder failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                }
-                else
-                {
-                    if (iState == iStateToReset)
-                    {
-                        iState = PVAE_CMD_RESET;
-                        RunIfNotReady();
-                    }
-                    else
-                    {
-                        iState = PVAE_CMD_ADD_TEXT_MEDIA_TRACK;
-                        RunIfNotReady();
-                    }
-                }
-            }
-            else
-            {
-                // AddVideoMediaTrack failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_TEXT_MEDIA_TRACK:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (!ConfigureTextEncoder())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_miscellaneous::CommandCompleted: Error - ConfigureTextEncoder failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                }
-                else
-                {
-                    if (iState == iStateToReset)
-                    {
-                        iState = PVAE_CMD_RESET;
-                        RunIfNotReady();
-                    }
-                    else
-                    {
-                        iState = PVAE_CMD_INIT;
-                        RunIfNotReady();
-                    }
-                }
-            }
-            else
-            {
-                // AddTextMediaTrack failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_INIT:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_START;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // Init failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_START:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iPauseResumeEnable)
-                {
-                    if (iState == iStateToReset)
-                    {
-                        iState = PVAE_CMD_RESET;
-                        RunIfNotReady();
-                    }
-                    else
-                    {
-                        iState = PVAE_CMD_PAUSE;
-                        RunIfNotReady(KPauseDuration); //Pause after 5 sec
-                    }
-                }
-                else
-                {
-                    if (iState == iStateToReset)
-                    {
-                        iState = PVAE_CMD_RESET;
-                        RunIfNotReady();
-                    }
-                    else
-                    {
-                        iState = PVAE_CMD_STOP;
-                        RunIfNotReady(KTestDuration*1000*1000); // Run for 10 seconds
-                    }
-                }
-            }
-            else
-            {
-                // Start failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_PAUSE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_RESUME;
-                    /* Stay paused for 10 seconds */
-                    RunIfNotReady(10*1000*1000);
-                }
-            }
-            else
-            {
-                //Pause failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_RESUME:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iState == iStateToReset)
-                {
-                    iState = PVAE_CMD_RESET;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_STOP;
-                    RunIfNotReady(KPauseDuration); //Run for another 5 sec
-                }
-            }
-            else
-            {
-                //Resume failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_STOP:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iOutputFileName = NULL;
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            else
-            {
-                // Stop failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_RESET:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iTestInputs.size() == 0)
-                {
-                    if (aResponse.GetCmdStatus() == PVMFSuccess)
-                    {
-                        PVPATB_TEST_IS_TRUE(true);
-                    }
-                    else
-                    {
-                        PVPATB_TEST_IS_TRUE(false);
-                    }
-                    //Since there are no testInputs, we end here
-                    //No need to call RemoveDataSource
-                    iObserver->CompleteTest(*iTestCase);
-                    break;
-                }
-                iState = PVAE_CMD_REMOVE_DATA_SOURCE;
-                RunIfNotReady();
-            }
-            else
-            {
-                // Reset failed
-                PVPATB_TEST_IS_TRUE(false);
-                iObserver->CompleteTest(*iTestCase);
-            }
-            break;
-
-        case PVAE_CMD_REMOVE_DATA_SOURCE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iRemoveDataSourceDone++;
-                if (iRemoveDataSourceDone < iTestInputs.size())
-                {
-                    return;//We will wait for all RemoveDataSource calls to complete
-                }
-                iOutputFileName = NULL;
-                if (!DeleteTestInputs())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_generic_reset::CommandCompleted: Error - DeleteTestInputs failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                    return;
-                }
-                else
-                {
-                    iState = PVAE_CMD_CLOSE;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // RemoveDataSource failed
-                PVPATB_TEST_IS_TRUE(false);
-                iObserver->CompleteTest(*iTestCase);
-            }
-            break;
-        case PVAE_CMD_CLOSE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                PVPATB_TEST_IS_TRUE(true);
-            }
-            else
-            {
-                PVPATB_TEST_IS_TRUE(false);
-            }
-            iObserver->CompleteTest(*iTestCase);
-            break;
-        default:
-        {
-            // Testing error if this is reached
-            PVPATB_TEST_IS_TRUE(false);
-            iObserver->CompleteTest(*iTestCase);
-        }
-    }
-}
diff --git a/engines/author/test/src/test_pv_author_engine_testset2.h b/engines/author/test/src/test_pv_author_engine_testset2.h
deleted file mode 100644
index 86ccb98..0000000
--- a/engines/author/test/src/test_pv_author_engine_testset2.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET2_H_INCLUDED
-#define TEST_PV_AUTHOR_ENGINE_TESTSET2_H_INCLUDED
-
-#ifndef PVAETEST_H_INCLUDED
-#include "pvaetest.h"
-#endif
-
-#ifndef TEST_PV_AUTHOR_ENGINE_TYPEDEFS_H
-#include "test_pv_author_engine_typedefs.h"
-#endif
-#define PVPATB_TEST_IS_TRUE( condition ) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
-
-class pvauthor_async_test_generic_reset: public pvauthor_async_test_base
-{
-    public:
-        pvauthor_async_test_generic_reset(PVAuthorAsyncTestParam aTestParam, const char* aInputFileNameAudio,
-                                          const char* aInputFileNameVideo, const char* aInputFileNameText,
-                                          const char* aOutputFileName,
-                                          PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,
-                                          PVAETestInputType aTextInputType, const char* aComposerMimeType,
-                                          const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType,
-                                          const char* aTextEncoderMimeType,  AVTConfig aAVTConfig,
-                                          bool aPauseResumeEnable, PVAECmdType aStateToReset)
-
-                : pvauthor_async_test_base(aTestParam)
-
-                , iComposerMimeType(aComposerMimeType)
-                , iAudioEncoderMimeType(aAudioEncoderMimeType)
-                , iVideoEncoderMimeType(aVideoEncoderMimeType)
-                , iTextEncoderMimeType(aTextEncoderMimeType)
-                , iAudioInputType(aAudioInputType)
-                , iVideoInputType(aVideoInputType)
-                , iTextInputType(aTextInputType)
-                , iAuthor(NULL)
-                , iComposer(NULL)
-                , iComposerConfig(NULL)
-                , iAudioEncoderConfig(NULL)
-                , iVideoEncoderConfig(NULL)
-                , iTextEncoderConfig(NULL)
-                , iOutputSizeAndDurationConfig(NULL)
-                , iAVTConfig(aAVTConfig)
-                , bAudioTrack(true)
-                , bVideoTrack(true)
-                , iPauseResumeEnable(aPauseResumeEnable)
-                , iStateToReset(aStateToReset)
-
-        {
-            iLogger = PVLogger::GetLoggerObject("pvauthor_async_test_generic_reset");
-            oscl_UTF8ToUnicode(aOutputFileName, oscl_strlen(aOutputFileName), iTempOutputFileName, ARRAY_SIZE);
-
-            iInputFileNameAudio = NULL;
-            iInputFileNameVideo = NULL;
-            iInputFileNameText = NULL;
-            iOutputFileName = NULL;
-
-            if (oscl_strlen(aInputFileNameAudio) != 0)
-            {
-                oscl_wchar output1[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aInputFileNameAudio, oscl_strlen(aInputFileNameAudio), output1, ARRAY_SIZE);
-                iInputFileNameAudio.set(output1, oscl_strlen(output1));
-            }
-
-            if (oscl_strlen(aInputFileNameVideo) != 0)
-            {
-                oscl_wchar output2[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aInputFileNameVideo, oscl_strlen(aInputFileNameVideo), output2, ARRAY_SIZE);
-                iInputFileNameVideo.set(output2, oscl_strlen(output2));
-            }
-
-            if (oscl_strlen(aInputFileNameText) != 0)
-            {
-                oscl_wchar output3[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aInputFileNameText, oscl_strlen(aInputFileNameText), output3, ARRAY_SIZE);
-                iInputFileNameText.set(output3, oscl_strlen(output3));
-            }
-
-            if (oscl_strlen(aOutputFileName) != 0)
-            {
-                oscl_wchar output4[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aOutputFileName, oscl_strlen(aOutputFileName), output4, ARRAY_SIZE);
-                iOutputFileName.set(output4, oscl_strlen(output4));
-            }
-            iRemoveDataSourceDone = 0;
-        }
-
-
-        ~pvauthor_async_test_generic_reset()
-        {
-            Cleanup();
-        }
-        void Run();
-        void StartTest();
-
-        // Author engine observer functions
-        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
-        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
-        void CommandCompleted(const PVCmdResponse& aResponse);
-
-        PVAECmdType iState;
-        // Test output
-        OSCL_wHeapString<OsclMemAllocator> iOutputFileName;
-        OSCL_wHeapString<OsclMemAllocator> iInputFileNameAudio;
-        OSCL_wHeapString<OsclMemAllocator> iInputFileNameVideo;
-        OSCL_wHeapString<OsclMemAllocator> iInputFileNameText;
-
-
-        OSCL_HeapString<OsclMemAllocator> iComposerMimeType;
-        OSCL_HeapString<OsclMemAllocator> iAudioEncoderMimeType;
-        OSCL_HeapString<OsclMemAllocator> iVideoEncoderMimeType;
-        OSCL_HeapString<OsclMemAllocator> iTextEncoderMimeType;
-        // Test inputs
-        PVAETestInputType iAudioInputType;
-        PVAETestInputType iVideoInputType;
-        PVAETestInputType iTextInputType;
-
-    private:
-        // Methods to create test input nodes and add to author engine
-        //bool CreateTestInputs();
-        int CreateAudioInput();
-        int CreateVideoInput();
-        int CreateTextInput();
-        bool AddDataSource(PVAETestInput& aInput);
-
-        // Methods to configure composers
-        void SelectComposer();
-        bool ConfigComposer();
-        bool ConfigAmrAacComposer();
-        bool ConfigMp43gpComposer();
-
-        // Method to configure max filesize/duration interface
-        bool QueryComposerOutputInterface();
-        bool ConfigComposerOutput();
-
-        // Methods to add media tracks
-        bool AddAudioMediaTrack();
-        bool AddVideoMediaTrack();
-        bool AddTextMediaTrack();
-
-        // Methods to configure encoders
-        bool ConfigureVideoEncoder();
-        bool ConfigureAudioEncoder();
-        bool ConfigureTextEncoder();
-
-
-        bool DeleteTestInputs();
-
-        void ResetAuthorConfig();
-
-        void Cleanup();
-        /////////////////////////////////////////////
-        // Author engine related variables
-        PVAuthorEngineInterface* iAuthor;
-        OsclAny* iComposer;
-        PVInterface* iComposerConfig;
-        PVInterface* iAudioEncoderConfig;
-        PVInterface* iVideoEncoderConfig;
-        PVInterface* iTextEncoderConfig;
-        PVInterface* iOutputSizeAndDurationConfig;
-
-        // Meta data strings
-        OSCL_wHeapString<OsclMemAllocator> iVersionString;
-        OSCL_wHeapString<OsclMemAllocator> iTitleString;
-        OSCL_wHeapString<OsclMemAllocator> iAuthorString;
-        OSCL_wHeapString<OsclMemAllocator> iCopyrightString;
-        OSCL_wHeapString<OsclMemAllocator> iDescriptionString;
-        OSCL_wHeapString<OsclMemAllocator> iRatingString;
-
-        AVTConfig iAVTConfig;
-        Oscl_Vector<PVAETestInput, OsclMemAllocator> iTestInputs;
-        oscl_wchar iTempOutputFileName[ARRAY_SIZE];
-
-        PVLogger* iLogger;
-        bool bAudioTrack; //keep track if audio track has been added
-        bool bVideoTrack;
-        bool iPauseResumeEnable;
-        uint iRemoveDataSourceDone;//to keep track of how many removeDataSource calls done
-        int iStateToReset;
-};
-
-#endif
diff --git a/engines/author/test/src/test_pv_author_engine_testset3.cpp b/engines/author/test/src/test_pv_author_engine_testset3.cpp
deleted file mode 100644
index 0fa38c8..0000000
--- a/engines/author/test/src/test_pv_author_engine_testset3.cpp
+++ /dev/null
@@ -1,1273 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET3_H_INCLUDED
-#include "test_pv_author_engine_testset3.h"
-#endif
-
-#ifndef PVMF_COMPOSER_SIZE_AND_DURATION_H_INCLUDED
-#include "pvmf_composer_size_and_duration.h"
-#endif
-
-#ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
-#include "pvmf_fileoutput_config.h"
-#endif
-
-#ifndef PVMP4FFCN_CLIPCONFIG_H_INCLUDED
-#include "pvmp4ffcn_clipconfig.h"
-#endif
-
-#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-#include "pvmp4h263encextension.h"
-#endif
-
-#ifndef PVAETEST_NODE_CONFIG_H_INCLUDED
-#include "pvaetest_node_config.h"
-#endif
-
-void pvauthor_async_test_capconfig::StartTest()
-{
-    AddToScheduler();
-    iState = PVAE_CMD_CREATE;
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                    (0, "******pvauthor_async_test_capconfig::iTestCaseNum:%d******", iTestCaseNum));
-    RunIfNotReady();
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_capconfig::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
-{
-    OSCL_UNUSED_ARG(aEvent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pvauthor_async_test_capconfig::HandleErrorEvent"));
-    PVPATB_TEST_IS_TRUE(false);
-    iObserver->CompleteTest(*iTestCase);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_capconfig::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
-{
-    OSCL_UNUSED_ARG(aEvent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::HandleInformationalEvent"));
-    OsclAny* eventData = NULL;
-    switch (aEvent.GetEventType())
-    {
-        case PVMF_COMPOSER_MAXFILESIZE_REACHED:
-        case PVMF_COMPOSER_MAXDURATION_REACHED:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::HandleNodeInformationalEvent: Max file size reached"));
-            Cancel();
-            PVPATB_TEST_IS_TRUE(true);
-            iObserver->CompleteTest(*iTestCase);
-            break;
-
-        case PVMF_COMPOSER_DURATION_PROGRESS:
-            aEvent.GetEventData(eventData);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::HandleNodeInformationalEvent: Duration progress: %d ms",
-                             (int32)eventData));
-            fprintf(iStdOut, "Duration: %d ms\n", (int32)eventData);
-            break;
-
-        case PVMF_COMPOSER_FILESIZE_PROGRESS:
-            aEvent.GetEventData(eventData);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_miscellaneous::HandleNodeInformationalEvent: File size progress: %d bytes",
-                             (int32)eventData));
-            fprintf(iStdOut, "File size: %d bytes\n", (int32)eventData);
-            break;
-
-        case PVMF_COMPOSER_EOS_REACHED:
-            //Engine already stopped at EOS so send reset command.
-            iState = PVAE_CMD_RESET;
-            //cancel recording timeout scheduled for timer object.
-            Cancel();
-            RunIfNotReady();
-            break;
-        default:
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_capconfig::CreateAudioInput()
-{
-    int status = 0;
-    PVAETestInput testInput;
-
-    if (iAudioInputType == INVALID_INPUT_TYPE)	// check condition when -audio tag is not specified
-    {
-        return -1;
-    }
-    else
-    {
-        status = testInput.CreateInputNode(iAudioInputType, iInputFileNameAudio, iAVTConfig);
-    }
-
-    if (!status)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::CreateAudioTestInput: Error - Create input node failed"));
-        return status;
-    }
-
-    return AddDataSource(testInput);
-}
-
-////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_capconfig::CreateVideoInput()
-{
-    int status = 0;
-    PVAETestInput testInput;
-
-    if (iVideoInputType == INVALID_INPUT_TYPE)	// check condition when -videoo tag is not specified
-    {
-        return -1;
-    }
-    else
-    {
-        testInput = PVAETestInput();
-        status = testInput.CreateInputNode(iVideoInputType, iInputFileNameVideo, iAVTConfig);
-    }
-
-    if (!status)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::CreateTestInputs: Error - CreateInputNode failed"));
-        return status;
-    }
-
-    return AddDataSource(testInput);
-}
-
-////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_capconfig::CreateTextInput()
-{
-    // Text track support will be developed in future
-    return -1;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::AddDataSource(PVAETestInput& aInput)
-{
-    int32 err = 0;
-
-    OSCL_TRY(err, iTestInputs.push_back(aInput););
-    if (err != OSCL_ERR_NONE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::AddDataSource: Error - iTestInputs.push_back failed. err=0x%x", err));
-        aInput.DeleteInputNode();
-        return false;
-    }
-
-
-    OSCL_TRY(err, iAuthor->AddDataSource(*(aInput.iNode), (OsclAny*)iAuthor););
-    if (err != OSCL_ERR_NONE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
-        aInput.DeleteInputNode();
-        return false;
-    }
-
-    return true;
-}
-
-void pvauthor_async_test_capconfig::SelectComposer()
-{
-    iAuthor->SelectComposer(iComposerMimeType, iComposerConfig, (OsclAny*)iAuthor);
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::ConfigComposer()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::ConfigComposer"));
-    if ((iTestCaseNum >= GenericTestBegin) && (iTestCaseNum < GenericTestEnd))
-    {
-        uint32 aLenFileName;
-        aLenFileName = oscl_strlen(iTempOutputFileName) - oscl_strlen(oscl_strchr(iTempOutputFileName, '.'));
-        oscl_wchar temp[ARRAY_SIZE];
-        oscl_memset(temp, 0, ARRAY_SIZE);
-        oscl_strncpy(temp, iTempOutputFileName, aLenFileName);
-        oscl_snprintf(temp + aLenFileName, ARRAY_SIZE, _STRLIT("_CapConfig_TestNum_%d"), iTestCaseNum);
-        oscl_strcat(temp, oscl_strchr(iTempOutputFileName, '.'));
-        iOutputFileName = temp;
-    }
-
-    if (!ConfigAmrAacComposer())
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::ConfigComposer: Error - ConfigAmrAacComposer failed"));
-        return false;
-    }
-
-    if (!ConfigMp43gpComposer())
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::ConfigComposer: Error - ConfigMp43gpComposer failed"));
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::ConfigAmrAacComposer()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::ConfigAmrAacComposer"));
-
-    if (!((iComposerMimeType == KAMRNbComposerMimeType) || (iComposerMimeType == KAACADTSComposerMimeType) || (iComposerMimeType == KAACADIFComposerMimeType)))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_test_capconfig::ConfigAmrAacComposer: AMR-AAC Composer not used in this test case"));
-        return true;
-    }
-
-
-    PvmfFileOutputNodeConfigInterface* clipConfig = OSCL_STATIC_CAST(PvmfFileOutputNodeConfigInterface*, iComposerConfig);
-    if (!clipConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::ConfigAmrAacComposer: Error - Invalid iComposerConfig"));
-        return false;
-    }
-
-    if (clipConfig->SetOutputFileName(iOutputFileName) != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::ConfigAmrAacComposer: Error - SetOutputFileName failed"));
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::ConfigMp43gpComposer()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                    (0, "pvauthor_async_test_capconfig::ConfigMp43gpComposer"));
-
-    if (!(iComposerMimeType == KAMRNbComposerMimeType) && !(iComposerMimeType == KAACADTSComposerMimeType) && !(iComposerMimeType == KAACADIFComposerMimeType))
-    {
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_capconfig::ConfigMp43gpComposer: Mp4-3GPP composer not used in this test case"));
-        return true;
-    }
-
-    PVMp4FFCNClipConfigInterface* clipConfig;
-    clipConfig = OSCL_STATIC_CAST(PVMp4FFCNClipConfigInterface*, iComposerConfig);
-    if (!clipConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::ConfigMp43gpComposer: Error - iComposerConfig==NULL"));
-        return false;
-    }
-
-    iVersionString = _STRLIT("version");
-    iTitleString = _STRLIT("title");
-    iAuthorString = _STRLIT("author");
-    iCopyrightString = _STRLIT("copyright");
-    iDescriptionString = _STRLIT("description");
-    iRatingString = _STRLIT("rating");
-
-    clipConfig->SetOutputFileName(iOutputFileName);
-    clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(iVersionString);
-    clipConfig->SetTitle(iTitleString);
-    clipConfig->SetAuthor(iAuthorString);
-    clipConfig->SetCopyright(iCopyrightString);
-    clipConfig->SetDescription(iDescriptionString);
-    clipConfig->SetRating(iRatingString);
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::ConfigComposerOutput()
-{
-    PvmfComposerSizeAndDurationInterface* config =
-        OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
-    if (!config)
-    {
-        return false;
-    }
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::QueryComposerOutputInterface()
-{
-    switch (iTestCaseNum)
-    {
-        case Generic_QueryInterface_Reset_Test:
-            iAuthor->QueryInterface(PvmfComposerSizeAndDurationUuid,
-                                    iOutputSizeAndDurationConfig, (OsclAny*)iAuthor);
-            return true;
-
-        default:
-            return false;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::AddAudioMediaTrack()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::AddAudioMediaTrack"));
-
-    if (iAudioInputType == INVALID_INPUT_TYPE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::AddAudioMediaTrackL: Error - Invalid audio input type"));
-        return false;
-    }
-
-    bool testInputFound = false;
-    PVAETestInput testInput;
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-    {
-        if (iTestInputs[ii].iType == iAudioInputType)
-        {
-            testInputFound = true;
-            testInput = iTestInputs[ii];
-            break;
-        }
-    }
-
-    if (!testInputFound)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::AddAudioMediaTrack: Error - Test input not found"));
-        return false;
-    }
-
-    iAuthor->AddMediaTrack(*(testInput.iNode), iAudioEncoderMimeType, iComposer,
-                           iAudioEncoderConfig, (OsclAny*)iAuthor);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::AddVideoMediaTrack()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::AddVideoMediaTrack"));
-
-    if (iVideoInputType == INVALID_INPUT_TYPE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::AddVideoMediaTrack: Error - Invalid input type"));
-        return false;
-    }
-
-    bool testInputFound = false;
-    PVAETestInput testInput;
-
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-    {
-        if (iTestInputs[ii].iType == iVideoInputType)
-        {
-            testInputFound = true;
-            testInput = iTestInputs[ii];
-            break;
-        }
-    }
-
-    if (!testInputFound)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_capconfig::AddVideoMediaTrack: Error - Test input not found"));
-        return false;
-    }
-
-    iAuthor->AddMediaTrack(*(testInput.iNode), iVideoEncoderMimeType, iComposer,
-                           iVideoEncoderConfig, (OsclAny*)iAuthor);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::ConfigureVideoEncoder()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::ConfigureVideoEncoder"));
-
-    PVMp4H263EncExtensionInterface* config;
-    config = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, iVideoEncoderConfig);
-    if (!config)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_capconfig::ConfigureVideoEncoder: No configuration needed"));
-        return true;
-    }
-
-    config->SetNumLayers(1);
-    config->SetOutputBitRate(0, KVideoBitrate);
-    config->SetOutputFrameSize(0, iAVTConfig.iWidth , iAVTConfig.iHeight);
-    config->SetOutputFrameRate(0, iAVTConfig.iFps);
-    config->SetIFrameInterval(iAVTConfig.iFrameInterval);
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::ConfigureAudioEncoder()
-{
-    //Single core AMR encoder node support
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::ConfigureAudioEncoder"));
-
-    if (!iAudioEncoderConfig)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_capconfig::ConfigureAudioEncoder: No configuration needed"));
-        return true;
-    }
-
-    return PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig);
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_capconfig::DeleteTestInputs()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::DeleteTestInputs"));
-
-    for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
-        iTestInputs[ii].DeleteInputNode();
-
-    iTestInputs.clear();
-    return true;
-}
-
-void pvauthor_async_test_capconfig::ResetAuthorConfig()
-{
-    if (iComposerConfig)
-    {
-        iComposerConfig->removeRef();
-        iComposerConfig = NULL;
-    }
-    if (iAudioEncoderConfig)
-    {
-        iAudioEncoderConfig->removeRef();
-        iAudioEncoderConfig = NULL;
-    }
-    if (iVideoEncoderConfig)
-    {
-        iVideoEncoderConfig->removeRef();
-        iVideoEncoderConfig = NULL;
-    }
-}
-
-void pvauthor_async_test_capconfig::Cleanup()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_test_capconfig::Cleanup"));
-
-    iComposer = NULL;
-
-    ResetAuthorConfig();
-
-    if (iAuthor)
-    {
-        PVAuthorEngineFactory::DeleteAuthor(iAuthor);
-        iAuthor = NULL;
-    }
-
-    DeleteTestInputs();
-    iOutputFileName = NULL;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_capconfig::Run()
-{
-    switch (iState)
-    {
-        case PVAE_CMD_CREATE:
-        {
-            iAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this);
-            if (!iAuthor)
-            {
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-
-            }
-            else
-            {
-                iState = PVAE_CMD_OPEN;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_OPEN:
-            iAuthor->Open((OsclAny*)iAuthor);
-            break;
-
-        case PVAE_CMD_ADD_DATA_SOURCE_AUDIO:
-        {
-            int aStatus = -1;
-            // Create audio input
-            aStatus = CreateAudioInput();
-            if (aStatus == 0) //Failed while creating audio input
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_capconfig::CreateTestInputs: Error - CreateAudioInput() failed"));
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (aStatus == -1) //Failed due to test being audio only or video only
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_VIDEO;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_ADD_DATA_SOURCE_VIDEO:
-        {
-            // Create video input
-            int aStatus = -1;
-            aStatus = CreateVideoInput();
-            if (aStatus == 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_capconfig::CreateTestInputs: Error - CreateVideoInput() failed"));
-                Cleanup();
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (aStatus == -1) //Failed due to test being audio only or video only
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_TEXT;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_ADD_DATA_SOURCE_TEXT:
-        {
-            // Create text input
-            int aStatus = -1;
-            aStatus = CreateTextInput();
-            if (aStatus == 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_capconfig::CreateTestInputs: Error - CreateVideoInput() failed"));
-                Cleanup();
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (aStatus == -1) //Failed due to test being audio only or video only
-            {
-                iState = PVAE_CMD_SELECT_COMPOSER;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_SELECT_COMPOSER:
-            SelectComposer();
-            break;
-
-        case PVAE_CMD_QUERY_INTERFACE:
-            if (!QueryComposerOutputInterface())
-            {
-                iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_AUDIO_MEDIA_TRACK:
-            if (!AddAudioMediaTrack())
-            {
-                bAudioTrack = false;
-                iState = PVAE_CMD_ADD_VIDEO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_VIDEO_MEDIA_TRACK:
-        {
-            bool bVideoTrack = AddVideoMediaTrack();
-            if (!bVideoTrack && !bAudioTrack) //No tracks have been added
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_capconfig::CommandCompleted: Error - No track added"));
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else if (!bVideoTrack) //Audio track added but no video track
-            {
-                iState = PVAE_CMD_QUERY_INTERFACE2;
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case PVAE_CMD_INIT:
-            iAuthor->Init((OsclAny*)iAuthor);
-            break;
-
-        case PVAE_CMD_START:
-            iAuthor->Start();
-            break;
-        case PVAE_CMD_STOP:
-            iAuthor->Stop((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_RESET:
-        {
-            ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
-        }
-        break;
-        case PVAE_CMD_REMOVE_DATA_SOURCE:
-        {
-            for (uint ii = 0; ii < iTestInputs.size(); ii++)
-            {
-                iAuthor->RemoveDataSource(*(iTestInputs[ii].iNode), (OsclAny*)iAuthor);
-            }
-        }
-        break;
-        case PVAE_CMD_CLOSE:
-            iAuthor->Close((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_PAUSE:
-            iAuthor->Pause((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_RESUME:
-            iAuthor->Resume((OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_QUERY_INTERFACE2:
-            iAuthor->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (PVInterface*&)iAuthorCapConfigIF, (OsclAny*)iAuthor);
-            break;
-        case PVAE_CMD_CAPCONFIG_ASYNC:
-            if (!CapConfigAsync())
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_capconfig::Run: Error - CapConfigAsync failed"));
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_CAPCONFIG_SYNC:
-            // set configuration MIME strings Synchronously
-            if (!CapConfigSync()) //CapConfig failed
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_capconfig::Run: Error - CapConfigSync failed"));
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-            else
-            {
-                iState = PVAE_CMD_START;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_CLEANUPANDCOMPLETE:
-        {
-            Cleanup();
-            iObserver->CompleteTest(*iTestCase);
-        }
-        break;
-        case PVAE_CMD_ADD_DATA_SINK:
-            break;
-        case PVAE_CMD_REMOVE_DATA_SINK:
-            break;
-        default:
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_capconfig::CommandCompleted(const PVCmdResponse& aResponse)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_capconfig::CommandCompleted iState:%d", iState));
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_capconfig::CommandCompleted iState:%d FAILED", iState));
-    }
-    switch (iState)
-    {
-        case PVAE_CMD_OPEN:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_AUDIO;
-                RunIfNotReady();
-            }
-            else
-            {
-                // Open failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_DATA_SOURCE_AUDIO:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_VIDEO;
-                RunIfNotReady();
-            }
-            else
-            {
-                // AddDataSourceAudio failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_DATA_SOURCE_VIDEO:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_ADD_DATA_SOURCE_TEXT;
-                RunIfNotReady();
-            }
-            else
-            {
-                // AddDataSourceVideo failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_DATA_SOURCE_TEXT:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_SELECT_COMPOSER;
-                RunIfNotReady();
-            }
-            else
-            {
-                // AddDataSourceText failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_SELECT_COMPOSER:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iComposer = aResponse.GetResponseData();
-                if (!ConfigComposer())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_capconfig::CommandCompleted: Error - ConfigComposer failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                    return;
-                }
-                else
-                {
-                    iState = PVAE_CMD_QUERY_INTERFACE;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // SelectComposer failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_QUERY_INTERFACE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                ConfigComposerOutput();
-                iState = PVAE_CMD_ADD_AUDIO_MEDIA_TRACK;
-                RunIfNotReady();
-            }
-            else
-            {
-                // QueryInterface failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_ADD_AUDIO_MEDIA_TRACK:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (!ConfigureAudioEncoder())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_capconfig::CommandCompleted: Error - ConfigureAudioEncoder failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iState = PVAE_CMD_CLOSE;
-                    RunIfNotReady();
-                }
-                else
-                {
-                    iState = PVAE_CMD_ADD_VIDEO_MEDIA_TRACK;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // AddAudioMediaTrack failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_ADD_VIDEO_MEDIA_TRACK:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (!ConfigureVideoEncoder())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_capconfig::CommandCompleted: Error - ConfigureVideoEncoder failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                }
-                else
-                {
-                    iState = PVAE_CMD_QUERY_INTERFACE2;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // AddVideoMediaTrack failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_QUERY_INTERFACE2:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_INIT;
-                RunIfNotReady();
-            }
-            else
-            {
-                // QueryInterface2 failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_INIT:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_CAPCONFIG_ASYNC;
-                RunIfNotReady();
-            }
-            else
-            {
-                // Init failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVAE_CMD_START:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iPauseResumeEnable)
-                {
-                    iState = PVAE_CMD_PAUSE;
-                    RunIfNotReady(KPauseDuration); //Pause after 5 sec
-                }
-                else
-                {
-                    iState = PVAE_CMD_STOP;
-                    RunIfNotReady(KTestDuration*1000*1000); // Run for 10 seconds
-                }
-            }
-            else
-            {
-                // Start failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_PAUSE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_RESUME;
-                /* Stay paused for 10 seconds */
-                RunIfNotReady(10*1000*1000);
-            }
-            else
-            {
-                //Pause failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_RESUME:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iState = PVAE_CMD_STOP;
-                RunIfNotReady(KPauseDuration); //Run for another 5 sec
-            }
-            else
-            {
-                //Resume failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_STOP:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iOutputFileName = NULL;
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            else
-            {
-                // Stop failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_RESET;
-                RunIfNotReady();
-            }
-            break;
-        case PVAE_CMD_RESET:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                if (iTestInputs.size() == 0)
-                {
-                    if (aResponse.GetCmdStatus() == PVMFSuccess)
-                    {
-                        PVPATB_TEST_IS_TRUE(true);
-                    }
-                    else
-                    {
-                        PVPATB_TEST_IS_TRUE(false);
-                    }
-                    //Since there are no testInputs, we end here
-                    //No need to call RemoveDataSource
-                    iObserver->CompleteTest(*iTestCase);
-                    break;
-                }
-                iState = PVAE_CMD_REMOVE_DATA_SOURCE;
-                RunIfNotReady();
-            }
-            else
-            {
-                // Reset failed
-                PVPATB_TEST_IS_TRUE(false);
-                iObserver->CompleteTest(*iTestCase);
-            }
-            break;
-
-        case PVAE_CMD_REMOVE_DATA_SOURCE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                iRemoveDataSourceDone++;
-                if (iRemoveDataSourceDone < iTestInputs.size())
-                {
-                    return;//We will wait for all RemoveDataSource calls to complete
-                }
-                iOutputFileName = NULL;
-                if (!DeleteTestInputs())
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_capconfig::CommandCompleted: Error - DeleteTestInputs failed"));
-                    PVPATB_TEST_IS_TRUE(false);
-                    iObserver->CompleteTest(*iTestCase);
-                    return;
-                }
-                else
-                {
-                    iState = PVAE_CMD_CLOSE;
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                // RemoveDataSource failed
-                PVPATB_TEST_IS_TRUE(false);
-                iObserver->CompleteTest(*iTestCase);
-            }
-
-            break;
-        case PVAE_CMD_CLOSE:
-            if (aResponse.GetCmdStatus() == PVMFSuccess)
-            {
-                PVPATB_TEST_IS_TRUE(true);
-            }
-            else
-            {
-                PVPATB_TEST_IS_TRUE(false);
-            }
-            iObserver->CompleteTest(*iTestCase);
-            break;
-
-        default:
-        {
-            // Testing error if this is reached
-            PVPATB_TEST_IS_TRUE(false);
-            iObserver->CompleteTest(*iTestCase);
-        }
-    }
-
-}
-
-void pvauthor_async_test_capconfig::SignalEvent(int32 aReq_Id)
-{
-    if (aReq_Id == 0) //For PVAE_CMD_CAPCONFIG_SET_PARAMETERS
-    {
-        if (iErrorKVP != NULL)
-        {
-            // There was an error in setParameterAsync()
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_capconfig::SignalEvent: setParametersAsync failed"));
-            PVPATB_TEST_IS_TRUE(false);
-            iObserver->CompleteTest(*iTestCase);
-        }
-        else
-        {
-            iState = PVAE_CMD_CAPCONFIG_SYNC;
-            RunIfNotReady();
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-// function for setting configuration MIME strings Synchronously
-
-bool pvauthor_async_test_capconfig::CapConfigSync()
-{
-    // set the mime strings here
-    // capabilty and configuration feature implemented here
-    // set the config parameters using MIME strings here
-
-    // set the KVP array
-    PvmiKvp paramkvp1;
-    // set cache size for composer node
-    //	PVMI_FILEIO_PV_CACHE_SIZE (MACRO defined in "pvmi_fileio_kvp.h")
-    OSCL_StackString<64> paramkey1(_STRLIT_CHAR(PVMI_FILEIO_PV_CACHE_SIZE));
-    paramkey1 += _STRLIT_CHAR(";valtype=uint32");
-    // set KVP values
-    // for composer node
-    paramkvp1.key = paramkey1.get_str();
-    paramkvp1.value.uint32_value = 1024;
-
-    iErrorKVP = NULL;
-
-    // verifyParametersSync will give Failure for test cases not using MP4 composer("fileio") node so commented
-    // Verify the new settings
-    {
-        // set the parameter
-        iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
-        if (iErrorKVP == NULL)
-        {
-            // Check by calling get
-            PvmiKvp* retparam = NULL;
-            int retnumparam = 0;
-            paramkey1 += _STRLIT_CHAR(";attr=cur");
-            // pass the string
-            // retrieve a MIME string back
-            iAuthorCapConfigIF->getParametersSync(NULL, paramkey1.get_str(), retparam, retnumparam, NULL);
-
-            if ((retparam != NULL) && (retnumparam == 1))
-            {
-                // release the parameters
-                if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
-                {
-                    return false;
-                }
-            }
-        }
-    }
-
-    //MIME for file output node
-    // set here any parameter here
-    OSCL_StackString<64> paramkey2(_STRLIT_CHAR("x-pvmf/file/output/parameter1;valtype=uint32"));
-
-    // for file output node
-    paramkvp1.key = paramkey2.get_str();
-    paramkvp1.value.int32_value = 144;
-
-    // set the value in node using SetParameterSync f(n) here
-    iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
-
-    // MIME for media io node
-    // set parameters here
-    OSCL_StackString<64> paramkey3(_STRLIT_CHAR("x-pvmf/media-io/parameter1;valtype=uint32"));
-
-    // for media io node
-    paramkvp1.key = paramkey3.get_str();
-    paramkvp1.value.int32_value = 144;
-
-    // set the value in node using SetParameterSync f(n) here
-    iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
-
-    if (iErrorKVP == NULL)
-    {
-        // Check by calling get
-        PvmiKvp* retparam = NULL;
-        int retnumparam = 0;
-        paramkey3 += _STRLIT_CHAR(";attr=cur");
-        // pass the string
-        // retrieve a MIME string back
-        iAuthorCapConfigIF->getParametersSync(NULL, paramkey3.get_str(), retparam, retnumparam, NULL);
-        if ((retparam != NULL) && (retnumparam == 1))
-        {
-            // release the parameters
-            if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
-            {
-                return false;
-            }
-        }
-    }
-
-    // MIME for amr encoder
-    // set the parameter here
-
-    // MIME string here "x-pvmf/audio/render/sampling_rate;valtype=uint32"
-    OSCL_StackString<64> paramkey4(_STRLIT_CHAR(MOUT_AUDIO_SAMPLING_RATE_KEY));
-    // MOUT_AUDIO_SAMPLING_RATE_KEY (MACRO defined in "pvmi_kvp.h")
-    // for amr encoder node
-    paramkvp1.key = paramkey4.get_str();
-    paramkvp1.value.int32_value = 8000;
-
-    // set the value in node using SetParameterSync f(n) here
-    iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
-
-    if (iErrorKVP == NULL)
-    {
-        // Check by calling get
-        PvmiKvp* retparam = NULL;
-        int retnumparam = 0;
-        paramkey1 += _STRLIT_CHAR(";attr=cur");
-        // pass the string
-        // retrieve a MIME string back
-        iAuthorCapConfigIF->getParametersSync(NULL, paramkey4.get_str(), retparam, retnumparam, NULL);
-        if ((retparam != NULL) && (retnumparam == 1))
-        {
-            // release the parameters
-            if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
-            {
-                return false;
-            }
-        }
-    }
-
-
-    // MIME for video encoder
-    // set the parameter frame width in the node (use combinations for width n height default is 176 by 144)
-
-    // MIME string here "x-pvmf/video/render/output_width;valtype=uint32"
-    OSCL_StackString<64> paramkey5(_STRLIT_CHAR(MOUT_VIDEO_OUTPUT_WIDTH_KEY));
-    // MACRO "MOUT_VIDEO_OUTPUT_WIDTH_KEY" been defined in "pvmi_kvp.h"
-    // for video encoder node
-    paramkvp1.key = paramkey5.get_str();
-    paramkvp1.value.uint32_value = 176;
-    // set the value in node using SetParameterSync f(n) here
-    iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
-
-    if (iErrorKVP == NULL)
-    {
-        // Check by calling get
-        PvmiKvp* retparam = NULL;
-        int retnumparam = 0;
-        paramkey1 += _STRLIT_CHAR(";attr=cur");
-        // pass the string
-        // retrieve a MIME string back
-        iAuthorCapConfigIF->getParametersSync(NULL, paramkey5.get_str(), retparam, retnumparam, NULL);
-        if ((retparam != NULL) && (retnumparam == 1))
-        {
-            // release the parameters
-            if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
-            {
-                return false;
-            }
-        }
-    }
-
-    // MIME for AVC Encoder
-    // set the parameter encoding mode
-
-    // MIME string here "x-pvmf/avc/encoder/encoding_mode;valtype=uint32"
-    OSCL_StackString<64> paramkey6(_STRLIT_CHAR(PVMF_AVC_ENCODER_ENCODINGMODE_KEY));
-    // MACRO "PVMF_AVC_ENCODER_ENCODINGMODE_KEY" been defined in "pvmi_kvp.h"
-    // for AVC Encoder node
-    paramkvp1.key = paramkey6.get_str();
-    paramkvp1.value.uint32_value = 3;//EAVCEI_ENCMODE_TWOWAY;
-    // set the value in node using SetParameterSync f(n) here
-    iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
-
-    if (iErrorKVP == NULL)
-    {
-        // Check by calling get
-        PvmiKvp* retparam = NULL;
-        int retnumparam = 0;
-        paramkey1 += _STRLIT_CHAR(";attr=cur");
-        // pass the string
-        // retrieve a MIME string back
-        iAuthorCapConfigIF->getParametersSync(NULL, paramkey6.get_str(), retparam, retnumparam, NULL);
-        if ((retparam != NULL) && (retnumparam == 1))
-        {
-            // release the parameters
-            if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
-            {
-                return false;
-            }
-        }
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-// function for setting configuration MIME strings Asynchronously
-
-bool pvauthor_async_test_capconfig::CapConfigAsync()
-{
-    // Set the observer
-    iAuthorCapConfigIF->setObserver(this);
-
-    iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/author/productinfo/dummyprod1;valtype=int32");
-    iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-    iKVPSetAsync.value.int32_value = 2;
-
-    // set the parameter
-    iErrorKVP = NULL;
-    iAuthorCapConfigIF->setParametersAsync(NULL, &iKVPSetAsync, 1, iErrorKVP);
-
-    return true;
-}
-
diff --git a/engines/author/test/src/test_pv_author_engine_testset3.h b/engines/author/test/src/test_pv_author_engine_testset3.h
deleted file mode 100644
index 4ed95ee..0000000
--- a/engines/author/test/src/test_pv_author_engine_testset3.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET3_H_INCLUDED
-#define TEST_PV_AUTHOR_ENGINE_TESTSET3_H_INCLUDED
-
-#ifndef PVAETEST_H_INCLUDED
-#include "pvaetest.h"
-#endif
-
-#ifndef PVMI_CONFIG_AND_CAPABILITY_OBSERVER_H_INCLUDED
-#include "pvmi_config_and_capability_observer.h"
-#endif
-#include "pvmi_fileio_kvp.h"
-
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-
-#ifndef TEST_PV_AUTHOR_ENGINE_TYPEDEFS_H
-#include "test_pv_author_engine_typedefs.h"
-#endif
-
-#define PVPATB_TEST_IS_TRUE( condition ) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
-
-class pvauthor_async_test_capconfig: public pvauthor_async_test_base,
-            public PvmiConfigAndCapabilityCmdObserver
-
-{
-    public:
-        pvauthor_async_test_capconfig(PVAuthorAsyncTestParam aTestParam, const char* aInputFileNameAudio,
-                                      const char* aInputFileNameVideo, const char* aOutputFileName,
-                                      PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,
-                                      const char* aComposerMimeType,
-                                      const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType,
-                                      AVTConfig aAVTConfig, bool aPauseResumeEnable)
-
-                : pvauthor_async_test_base(aTestParam)
-
-                , iComposerMimeType(aComposerMimeType)
-                , iAudioEncoderMimeType(aAudioEncoderMimeType)
-                , iVideoEncoderMimeType(aVideoEncoderMimeType)
-                , iAudioInputType(aAudioInputType)
-                , iVideoInputType(aVideoInputType)
-                , iAuthor(NULL)
-                , iComposer(NULL)
-                , iComposerConfig(NULL)
-                , iAudioEncoderConfig(NULL)
-                , iVideoEncoderConfig(NULL)
-                , iOutputSizeAndDurationConfig(NULL)
-                , iAVTConfig(aAVTConfig)
-                , bAudioTrack(true)
-                , iPauseResumeEnable(aPauseResumeEnable)
-
-        {
-            iLogger = PVLogger::GetLoggerObject("pvauthor_async_test_capconfig");
-            oscl_UTF8ToUnicode(aOutputFileName, oscl_strlen(aOutputFileName), iTempOutputFileName, ARRAY_SIZE);
-
-            iInputFileNameAudio = NULL;
-            iInputFileNameVideo = NULL;
-            iOutputFileName = NULL;
-
-            if (oscl_strlen(aInputFileNameAudio) != 0)
-            {
-                oscl_wchar output1[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aInputFileNameAudio, oscl_strlen(aInputFileNameAudio), output1, ARRAY_SIZE);
-                iInputFileNameAudio.set(output1, oscl_strlen(output1));
-            }
-
-            if (oscl_strlen(aInputFileNameVideo) != 0)
-            {
-                oscl_wchar output2[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aInputFileNameVideo, oscl_strlen(aInputFileNameVideo), output2, ARRAY_SIZE);
-                iInputFileNameVideo.set(output2, oscl_strlen(output2));
-            }
-
-            if (oscl_strlen(aOutputFileName) != 0)
-            {
-                oscl_wchar output3[ARRAY_SIZE];
-                oscl_UTF8ToUnicode(aOutputFileName, oscl_strlen(aOutputFileName), output3, ARRAY_SIZE);
-                iOutputFileName.set(output3, oscl_strlen(output3));
-            }
-            iRemoveDataSourceDone = 0;
-        }
-
-        ~pvauthor_async_test_capconfig()
-        {
-            Cleanup();
-        }
-        void Run();
-        void StartTest();
-
-        // Author engine observer functions
-        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
-        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
-        void CommandCompleted(const PVCmdResponse& aResponse);
-
-        PVAECmdType iState;
-        // Test output
-        OSCL_wHeapString<OsclMemAllocator> iOutputFileName;
-        OSCL_wHeapString<OsclMemAllocator> iInputFileNameAudio;
-        OSCL_wHeapString<OsclMemAllocator> iInputFileNameVideo;
-
-        OSCL_HeapString<OsclMemAllocator> iComposerMimeType;
-        OSCL_HeapString<OsclMemAllocator> iAudioEncoderMimeType;
-        OSCL_HeapString<OsclMemAllocator> iVideoEncoderMimeType;
-        // Test inputs
-        PVAETestInputType iAudioInputType;
-        PVAETestInputType iVideoInputType;
-
-    private:
-        // Methods to create test input nodes and add to author engine
-        //bool CreateTestInputs();
-        int CreateAudioInput();
-        int CreateVideoInput();
-        int CreateTextInput();
-        bool AddDataSource(PVAETestInput& aInput);
-
-        // Methods to configure composers
-        void SelectComposer();
-        bool ConfigComposer();
-        bool ConfigAmrAacComposer();
-        bool ConfigMp43gpComposer();
-
-        // Method to configure max filesize/duration interface
-        bool QueryComposerOutputInterface();
-        bool ConfigComposerOutput();
-
-        // Methods to add media tracks
-        bool AddAudioMediaTrack();
-        bool AddVideoMediaTrack();
-
-        // Methods to configure encoders
-        bool ConfigureVideoEncoder();
-        bool ConfigureAudioEncoder();
-
-        bool DeleteTestInputs();
-
-        void ResetAuthorConfig();
-
-        void Cleanup();
-        //CapConfig
-        bool CapConfigSync();
-        bool CapConfigAsync();
-        // From PvmiConfigAndCapabilityCmdObserver
-        void SignalEvent(int32 req_id);
-        /////////////////////////////////////////////
-        // Author engine related variables
-        PVAuthorEngineInterface* iAuthor;
-        OsclAny* iComposer;
-        PVInterface* iComposerConfig;
-        PVInterface* iAudioEncoderConfig;
-        PVInterface* iVideoEncoderConfig;
-        PVInterface* iOutputSizeAndDurationConfig;
-
-        // Meta data strings
-        OSCL_wHeapString<OsclMemAllocator> iVersionString;
-        OSCL_wHeapString<OsclMemAllocator> iTitleString;
-        OSCL_wHeapString<OsclMemAllocator> iAuthorString;
-        OSCL_wHeapString<OsclMemAllocator> iCopyrightString;
-        OSCL_wHeapString<OsclMemAllocator> iDescriptionString;
-        OSCL_wHeapString<OsclMemAllocator> iRatingString;
-
-        AVTConfig iAVTConfig;
-        Oscl_Vector<PVAETestInput, OsclMemAllocator> iTestInputs;
-        oscl_wchar iTempOutputFileName[ARRAY_SIZE];
-
-        PVLogger* iLogger;
-        bool bAudioTrack; //keep track if audio track has been added
-        bool iPauseResumeEnable;
-        uint iRemoveDataSourceDone;//to keep track of how many removeDataSource calls done
-        //For CapConfig
-        PvmiCapabilityAndConfig* iAuthorCapConfigIF;
-        PvmiKvp iKVPSetAsync;
-        OSCL_StackString<64> iKeyStringSetAsync;
-        PvmiKvp* iErrorKVP;
-};
-
-#endif
diff --git a/engines/author/test/src/test_pv_author_engine_testset4.cpp b/engines/author/test/src/test_pv_author_engine_testset4.cpp
index 4f6abe9..014eb16 100644
--- a/engines/author/test/src/test_pv_author_engine_testset4.cpp
+++ b/engines/author/test/src/test_pv_author_engine_testset4.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@
 #include "pvaetest_node_config.h"
 #endif
 
-void pvauthor_async_test_errorhandling::StartTest()
+void pvauthor_async_compressed_test_errorhandling::StartTest()
 {
     AddToScheduler();
     iState = PVAE_CMD_CREATE;
@@ -49,66 +49,53 @@
 
 
 ////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_errorhandling::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+void pvauthor_async_compressed_test_errorhandling::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
 {
     OSCL_UNUSED_ARG(aEvent);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pvauthor_async_test_errorhandling::HandleErrorEvent"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pvauthor_async_compressed_test_errorhandling::HandleErrorEvent"));
     iState = PVAE_CMD_RESET;
     RunIfNotReady();
 }
 
 ////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_errorhandling::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+void pvauthor_async_compressed_test_errorhandling::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
     OSCL_UNUSED_ARG(aEvent);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::HandleInformationalEvent"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::HandleInformationalEvent"));
 
 }
 
 ////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_errorhandling::CreateAudioInput()
+int pvauthor_async_compressed_test_errorhandling::CreateAudioInput()
 {
     int status = 0;
     PVAETestInput testInput;
 
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongInputFormatTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
         case ErrorHandling_WrongTextInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
+        case ErrorHandling_MediaInputNodeStartFailed:
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateAudioTestInput: AMR input"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::CreateAudioTestInput: AMR input"));
             if (testInput.IsTestInputTypeSupported(AMR_IETF_FILE))
             {
                 iAudioInputType = AMR_IETF_FILE;
                 status = testInput.CreateInputNode(AMR_IETF_FILE, iInputFileNameAudio, iAVTConfig);
             }
             break;
-        case ErrorHandling_WrongAudioInputFileNameTest:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateAudioTestInput: AMR input"));
-            if (testInput.IsTestInputTypeSupported(AMR_IETF_FILE))
-            {
-                iAudioInputType = AMR_IETF_FILE;
-                iInputFileNameAudio = KAMRTestInputWrong;
-                status = testInput.CreateInputNode(AMR_IETF_FILE, iInputFileNameAudio, iAVTConfig);
-            }
-            break;
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateAudioTestInput: Audio input node not needed for this test case"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::CreateAudioTestInput: Audio input node not needed for this test case"));
             return -1;
-            break;
     }
 
     if (!status)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::CreateAudioTestInput: Error - Create input node failed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::CreateAudioTestInput: Error - Create input node failed"));
         return status;
     }
 
@@ -116,58 +103,35 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_errorhandling::CreateVideoInput()
+int pvauthor_async_compressed_test_errorhandling::CreateVideoInput()
 {
     int status = 0;
     PVAETestInput testInput;
 
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongAudioInputFileNameTest:
         case ErrorHandling_WrongTextInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateVideoTestInput: YUV input"));
-            if (testInput.IsTestInputTypeSupported(YUV_FILE))
-            {
-                iVideoInputType = YUV_FILE;
-                testInput = PVAETestInput();
-                status = testInput.CreateInputNode(YUV_FILE, iInputFileNameVideo, iAVTConfig);
-            }
-            break;
-        case ErrorHandling_WrongVideoInputFileNameTest:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateVideoTestInput: YUV input"));
-            if (testInput.IsTestInputTypeSupported(YUV_FILE))
-            {
-                iVideoInputType = YUV_FILE;
-                testInput = PVAETestInput();
-                iInputFileNameVideo = KYUVTestInputWrong;
-                status = testInput.CreateInputNode(YUV_FILE, iInputFileNameVideo, iAVTConfig);
-            }
-            break;
-        case ErrorHandling_WrongInputFormatTest:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateVideoTestInput: Incorrect input YUV input"));
-            if (testInput.IsTestInputTypeSupported(YUV_FILE))
-            {
-                iVideoInputType = YUV_WRONG_FILE;
-                testInput = PVAETestInput();
-                status = testInput.CreateInputNode(YUV_WRONG_FILE, iInputFileNameVideo, iAVTConfig);
-            }
-            break;
+        case ErrorHandling_MediaInputNodeStartFailed:
 
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pvauthor_async_compressed_test_errorhandling::CreateVideoTestInput: YUV input"));
+            if (testInput.IsTestInputTypeSupported(YUV_FILE))
+            {
+                iVideoInputType = YUV_FILE;
+                testInput = PVAETestInput();
+                status = testInput.CreateInputNode(YUV_FILE, iInputFileNameVideo, iAVTConfig);
+            }
+            break;
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateVideoTestInput: Video input node not needed for this test case"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::CreateVideoTestInput: Video input node not needed for this test case"));
             return -1;
-            break;
     }
 
     if (!status)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::CreateTestInputs: Error - CreateInputNode failed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::CreateTestInputs: Error - CreateInputNode failed"));
         return status;
     }
 
@@ -175,28 +139,16 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-int pvauthor_async_test_errorhandling::CreateTextInput()
+int pvauthor_async_compressed_test_errorhandling::CreateTextInput()
 {
     int status = 0;
     PVAETestInput testInput;
 
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongAudioInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
-        case ErrorHandling_WrongInputFormatTest:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateTextTestInput: TEXT input"));
-            if (testInput.IsTestInputTypeSupported(TEXT_FILE))
-            {
-                iTextInputType = TEXT_FILE;
-                status = testInput.CreateInputNode(TEXT_FILE, iInputFileNameText, iAVTConfig);
-            }
-            break;
         case ErrorHandling_WrongTextInputFileNameTest:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateTextTestInput: TEXT input"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::CreateTextTestInput: TEXT input"));
             if (testInput.IsTestInputTypeSupported(TEXT_FILE))
             {
                 iTextInputType = TEXT_FILE;
@@ -208,15 +160,14 @@
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                            (0, "pvauthor_async_test_errorhandling::CreateTextTestInput:  input node not needed for this test case"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::CreateTextTestInput:  input node not needed for this test case"));
             return -1;
-            break;
     }
 
     if (!status)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::CreateTestInputs: Error - CreateInputNode failed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::CreateTestInputs: Error - CreateInputNode failed"));
         return status;
     }
 
@@ -224,7 +175,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::AddDataSource(PVAETestInput& aInput)
+bool pvauthor_async_compressed_test_errorhandling::AddDataSource(PVAETestInput& aInput)
 {
     int32 err = 0;
 
@@ -232,7 +183,7 @@
     if (err != OSCL_ERR_NONE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddDataSource: Error - iTestInputs.push_back failed. err=0x%x", err));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddDataSource: Error - iTestInputs.push_back failed. err=0x%x", err));
         aInput.DeleteInputNode();
         return false;
     }
@@ -241,7 +192,7 @@
     if (err != OSCL_ERR_NONE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
         aInput.DeleteInputNode();
         return false;
     }
@@ -249,21 +200,19 @@
     return true;
 }
 
-void pvauthor_async_test_errorhandling::SelectComposer()
+void pvauthor_async_compressed_test_errorhandling::SelectComposer()
 {
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongInputFormatTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
-        case ErrorHandling_WrongAudioInputFileNameTest:
         case ErrorHandling_WrongTextInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
+        case ErrorHandling_MediaInputNodeStartFailed:
+
             iComposerMimeType = K3gpComposerMimeType;
             break;
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_errorhandling::SelectComposer: Error - No composer type for test case"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::SelectComposer: Error - No composer type for test case"));
             PVPATB_TEST_IS_TRUE(false);
             iObserver->CompleteTest(*iTestCase);
             return;
@@ -273,14 +222,14 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigComposer()
+bool pvauthor_async_compressed_test_errorhandling::ConfigComposer()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::ConfigComposer"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::ConfigComposer"));
     if (!ConfigAmrAacComposer())
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::ConfigComposer: Error - ConfigAmrAacComposer failed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigComposer: Error - ConfigAmrAacComposer failed"));
         return false;
     }
 
@@ -289,7 +238,7 @@
     if (!ConfigMp43gpComposer())
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::ConfigComposer: Error - ConfigMp43gpComposer failed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigComposer: Error - ConfigMp43gpComposer failed"));
         return false;
     }
 
@@ -297,56 +246,40 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigAmrAacComposer()
+bool pvauthor_async_compressed_test_errorhandling::ConfigAmrAacComposer()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::ConfigAmrAacComposer"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::ConfigAmrAacComposer"));
 
-    PVMFFormatType format = PVMF_FORMAT_UNKNOWN;
 
     switch (iTestCaseNum)
     {
         case AMR_FOutput_Test:
-        case AMR_FOutput_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KFOAOnlyAMRTestOutput;
             }
-            format = PVMF_AMR_IETF;
             break;
 
         case AACADIF_FOutput_Test:
-        case AACADIF_FOutput_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KFOAOnlyAACADIFTestOutput;
             }
-            format = PVMF_ADIF;
             break;
 
 
         case AACADTS_FOutput_Test:
-        case AACADTS_FOutput_LongetivityTest:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KFOAOnlyAACADTSTestOutput;
             }
-            format = PVMF_ADTS;
-            break;
-
-        case PCM16In_AMROut_Test:
-        case PCM16In_AMROut_LongetivityTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KPCM16TestOutput;
-            }
-            format = PVMF_AMR_IETF;
             break;
 
         default:
             if (!((iComposerMimeType == KAMRNbComposerMimeType) || (iComposerMimeType == KAACADTSComposerMimeType) || (iComposerMimeType == KAACADIFComposerMimeType)))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_test_errorhandling::ConfigAmrAacComposer: AMR-AAC Composer not used in this test case"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_compressed_test_errorhandling::ConfigAmrAacComposer: AMR-AAC Composer not used in this test case"));
                 return true;
             }
     }
@@ -355,14 +288,14 @@
     if (!clipConfig)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::ConfigAmrAacComposer: Error - Invalid iComposerConfig"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigAmrAacComposer: Error - Invalid iComposerConfig"));
         return false;
     }
 
     if (clipConfig->SetOutputFileName(iOutputFileName) != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::ConfigAmrAacComposer: Error - SetOutputFileName failed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigAmrAacComposer: Error - SetOutputFileName failed"));
         return false;
     }
 
@@ -370,28 +303,20 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigMp43gpComposer()
+bool pvauthor_async_compressed_test_errorhandling::ConfigMp43gpComposer()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                    (0, "pvauthor_async_test_errorhandling::ConfigMp43gpComposer"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::ConfigMp43gpComposer"));
 
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongInputFormatTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
-        case ErrorHandling_WrongAudioInputFileNameTest:
         case ErrorHandling_WrongTextInputFileNameTest:
+        case ErrorHandling_MediaInputNodeStartFailed:
             if (iOutputFileName == NULL)
             {
                 iOutputFileName = KAMRYUVInputAV3gpTestOutput;
             }
             break;
-        case ErrorHandling_WrongOutputPathTest:
-            if (iOutputFileName == NULL)
-            {
-                iOutputFileName = KAMRYUVInputAV3gpTestOutputWrong;
-            }
-            break;
 
         default:
             if (!(iComposerMimeType == KAMRNbComposerMimeType) && !(iComposerMimeType == KAACADTSComposerMimeType) && !(iComposerMimeType == KAACADIFComposerMimeType))
@@ -401,7 +326,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "pvauthor_async_test_errorhandling::ConfigMp43gpComposer: Mp4-3GPP composer not used in this test case"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::ConfigMp43gpComposer: Mp4-3GPP composer not used in this test case"));
                 return true;
             }
     }
@@ -411,7 +336,7 @@
     if (!clipConfig)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::ConfigMp43gpComposer: Error - iComposerConfig==NULL"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigMp43gpComposer: Error - iComposerConfig==NULL"));
         return false;
     }
 
@@ -421,20 +346,23 @@
     iCopyrightString = _STRLIT("copyright");
     iDescriptionString = _STRLIT("description");
     iRatingString = _STRLIT("rating");
+    iAlbumTitle   = _STRLIT("albumtitle");
+    iRecordingYear = 2008;
+
+    OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
 
     clipConfig->SetOutputFileName(iOutputFileName);
     clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(iVersionString);
-    clipConfig->SetTitle(iTitleString);
-    clipConfig->SetAuthor(iAuthorString);
-    clipConfig->SetCopyright(iCopyrightString);
-    clipConfig->SetDescription(iDescriptionString);
-    clipConfig->SetRating(iRatingString);
-    if (iTestCaseNum == KFastTrackContentModeTest)
-    {
-        clipConfig->SetAuthoringMode(PVMP4FFCN_PV_FAST_TRACK_CONTENT_MODE);
-    }
-    else if (iTestCaseNum == K3GPPDownloadModeTest)
+    clipConfig->SetVersion(iVersionString, lang_code);
+    clipConfig->SetTitle(iTitleString, lang_code);
+    clipConfig->SetAuthor(iAuthorString, lang_code);
+    clipConfig->SetCopyright(iCopyrightString, lang_code);
+    clipConfig->SetDescription(iDescriptionString, lang_code);
+    clipConfig->SetRating(iRatingString, lang_code);
+    clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
+    clipConfig->SetRecordingYear(iRecordingYear);
+
+    if (iTestCaseNum == K3GPPDownloadModeTest)
     {
         clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_DOWNLOAD_MODE);
     }
@@ -442,13 +370,23 @@
     {
         clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_PROGRESSIVE_DOWNLOAD_MODE);
     }
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+    else if (iTestCaseNum == KIMotionAuthoringModeTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_IMOTION_PSEUDO_STREAMING_MODE);
+    }
+    else if (iTestCaseNum == KIMotionDownloadModeTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_IMOTION_DOWNLOAD_MODE);
+    }
+#endif
 
 
     return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigComposerOutput()
+bool pvauthor_async_compressed_test_errorhandling::ConfigComposerOutput()
 {
     PvmfComposerSizeAndDurationInterface* config =
         OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
@@ -456,44 +394,39 @@
     {
         return false;
     }
-    bool enabled = false;
-    uint32 configData = 0;
 
     return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::QueryComposerOutputInterface()
+bool pvauthor_async_compressed_test_errorhandling::QueryComposerOutputInterface()
 {
     return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::AddAudioMediaTrack()
+bool pvauthor_async_compressed_test_errorhandling::AddAudioMediaTrack()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::AddAudioMediaTrack"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::AddAudioMediaTrack"));
 
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongInputFormatTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
         case ErrorHandling_WrongTextInputFileNameTest:
-        case ErrorHandling_WrongAudioInputFileNameTest:
+        case ErrorHandling_MediaInputNodeStartFailed:
             iAudioEncoderMimeType = KAMRNbEncMimeType;
             break;
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_errorhandling::AddAudioMediaTrackL: Error - No audio for this current test case"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::AddAudioMediaTrackL: Error - No audio for this current test case"));
             return false;
     }
 
     if (iAudioInputType == INVALID_INPUT_TYPE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddAudioMediaTrackL: Error - Invalid audio input type"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddAudioMediaTrackL: Error - Invalid audio input type"));
         return false;
     }
 
@@ -512,7 +445,7 @@
     if (!testInputFound)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddAudioMediaTrack: Error - Test input not found"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddAudioMediaTrack: Error - Test input not found"));
         return false;
     }
 
@@ -522,33 +455,29 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::AddVideoMediaTrack()
+bool pvauthor_async_compressed_test_errorhandling::AddVideoMediaTrack()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::AddVideoMediaTrack"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::AddVideoMediaTrack"));
 
     // Add video media track
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongInputFormatTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
-        case ErrorHandling_WrongAudioInputFileNameTest:
         case ErrorHandling_WrongTextInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
+        case ErrorHandling_MediaInputNodeStartFailed:
             iVideoEncoderMimeType = KH263EncMimeType;
             break;
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_errorhandling::AddVideoMediaTrack: Video encoder not used in this test case."));
+                            (0, "pvauthor_async_compressed_test_errorhandling::AddVideoMediaTrack: Video encoder not used in this test case."));
             return false;
-            break;
     }
 
     if (iVideoInputType == INVALID_INPUT_TYPE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddVideoMediaTrack: Error - Invalid input type"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddVideoMediaTrack: Error - Invalid input type"));
         return false;
     }
 
@@ -568,7 +497,7 @@
     if (!testInputFound)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddVideoMediaTrack: Error - Test input not found"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddVideoMediaTrack: Error - Test input not found"));
         return false;
     }
 
@@ -578,31 +507,27 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::AddTextMediaTrack()
+bool pvauthor_async_compressed_test_errorhandling::AddTextMediaTrack()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::AddTextMediaTrack"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::AddTextMediaTrack"));
 
     switch (iTestCaseNum)
     {
-        case ErrorHandling_WrongInputFormatTest:
-        case ErrorHandling_WrongVideoInputFileNameTest:
-        case ErrorHandling_WrongOutputPathTest:
-        case ErrorHandling_WrongAudioInputFileNameTest:
         case ErrorHandling_WrongTextInputFileNameTest:
             iTextEncoderMimeType = KTextEncMimeType;
             break;
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_errorhandling::AddTextMediaTrackL: Error - No text for this current test case"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::AddTextMediaTrackL: Error - No text for this current test case"));
             return false;
     }
 
     if (iTextInputType == INVALID_INPUT_TYPE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddTextMediaTrackL: Error - Invalid text input type"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddTextMediaTrackL: Error - Invalid text input type"));
         return false;
     }
 
@@ -621,7 +546,7 @@
     if (!testInputFound)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "pvauthor_async_test_errorhandling::AddTextMediaTrack: Error - Test input not found"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::AddTextMediaTrack: Error - Test input not found"));
         return false;
     }
 
@@ -631,17 +556,17 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigureVideoEncoder()
+bool pvauthor_async_compressed_test_errorhandling::ConfigureVideoEncoder()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::ConfigureVideoEncoder"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::ConfigureVideoEncoder"));
 
     PVMp4H263EncExtensionInterface* config;
     config = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, iVideoEncoderConfig);
     if (!config)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_errorhandling::ConfigureVideoEncoder: No configuration needed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigureVideoEncoder: No configuration needed"));
         return true;
     }
 
@@ -649,22 +574,22 @@
     config->SetOutputBitRate(0, KVideoBitrate);
     config->SetOutputFrameSize(0, iAVTConfig.iWidth , iAVTConfig.iHeight);
     config->SetOutputFrameRate(0, iAVTConfig.iFps);
-    config->SetIFrameInterval(iAVTConfig.iFrameInterval);
-
+    config->SetIFrameInterval(KVideoIFrameInterval);
+    config->SetSceneDetection(true);
     return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigureAudioEncoder()
+bool pvauthor_async_compressed_test_errorhandling::ConfigureAudioEncoder()
 {
     // Single core AMR encoder node support
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::ConfigureAudioEncoder"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::ConfigureAudioEncoder"));
 
     if (!iAudioEncoderConfig)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_errorhandling::ConfigureAudioEncoder: No configuration needed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigureAudioEncoder: No configuration needed"));
         return true;
     }
 
@@ -672,25 +597,25 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-bool pvauthor_async_test_errorhandling::ConfigureTextEncoder()
+bool pvauthor_async_compressed_test_errorhandling::ConfigureTextEncoder()
 {
     // Single core AMR encoder node support
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::ConfigureTextEncoder"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::ConfigureTextEncoder"));
 
     if (!iTextEncoderConfig)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "pvauthor_async_test_errorhandling::ConfigureTextEncoder: No configuration needed"));
+                        (0, "pvauthor_async_compressed_test_errorhandling::ConfigureTextEncoder: No configuration needed"));
         return true;
     }
 
     return true;
 }
-bool pvauthor_async_test_errorhandling::DeleteTestInputs()
+bool pvauthor_async_compressed_test_errorhandling::DeleteTestInputs()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::DeleteTestInputs"));
+                    (0, "pvauthor_async_compressed_test_errorhandling::DeleteTestInputs"));
 
     for (uint32 ii = 0; ii < iTestInputs.size(); ii++)
         iTestInputs[ii].DeleteInputNode();
@@ -699,7 +624,7 @@
     return true;
 }
 
-void pvauthor_async_test_errorhandling::ResetAuthorConfig()
+void pvauthor_async_compressed_test_errorhandling::ResetAuthorConfig()
 {
     if (iComposerConfig)
     {
@@ -723,9 +648,9 @@
     }
 }
 
-void pvauthor_async_test_errorhandling::Cleanup()
+void pvauthor_async_compressed_test_errorhandling::Cleanup()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_test_errorhandling::Cleanup"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pvauthor_async_compressed_test_errorhandling::Cleanup"));
 
     iComposer = NULL;
 
@@ -743,14 +668,14 @@
 
 
 ////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_errorhandling::Run()
+void pvauthor_async_compressed_test_errorhandling::Run()
 {
     switch (iState)
     {
         case PVAE_CMD_CREATE:
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "******pvauthor_async_test_errorhandling::iTestCaseNum:%d******", iTestCaseNum));
+                            (0, "******pvauthor_async_compressed_test_errorhandling::iTestCaseNum:%d******", iTestCaseNum));
             iAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this);
             if (!iAuthor)
             {
@@ -779,7 +704,7 @@
             if (aStatus == 0) //Failed while creating audio input
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_errorhandling::CreateTestInputs: Error - CreateAudioInput() failed"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::CreateTestInputs: Error - CreateAudioInput() failed"));
                 PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -800,7 +725,7 @@
             if (aStatus == 0)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_errorhandling::CreateTestInputs: Error - CreateVideoInput() failed"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::CreateTestInputs: Error - CreateVideoInput() failed"));
                 Cleanup();
                 PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
@@ -822,7 +747,7 @@
             if (aStatus == 0)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_errorhandling::CreateTestInputs: Error - CreateVideoInput() failed"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::CreateTestInputs: Error - CreateVideoInput() failed"));
                 Cleanup();
                 PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
@@ -880,7 +805,7 @@
             if (!bTextTrack && !bAudioTrack && !bVideoTrack) //No tracks have been added
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_errorhandling::Run: Error - No track added"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::Run: Error - No track added"));
                 PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
@@ -902,13 +827,16 @@
             break;
         case PVAE_CMD_STOP:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_errorhandling::Run: Fire Stop"));
+                            (0, "pvauthor_async_compressed_test_errorhandling::Run: Fire Stop"));
             iAuthor->Stop((OsclAny*)iAuthor);
             break;
         case PVAE_CMD_RESET:
         {
             ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
+            if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
+            {
+                iAuthor->Reset((OsclAny*)iAuthor);
+            }
         }
         break;
         case PVAE_CMD_REMOVE_DATA_SOURCE:
@@ -935,8 +863,6 @@
         }
         break;
 
-        case PVAE_CMD_QUERY_INTERFACE2:
-            break;
         case PVAE_CMD_ADD_DATA_SINK:
             break;
         case PVAE_CMD_REMOVE_DATA_SINK:
@@ -967,15 +893,15 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-void pvauthor_async_test_errorhandling::CommandCompleted(const PVCmdResponse& aResponse)
+void pvauthor_async_compressed_test_errorhandling::CommandCompleted(const PVCmdResponse& aResponse)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "pvauthor_async_test_errorhandling::CommandCompleted iState:%d", iState));
+                    (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted iState:%d", iState));
 
     if (aResponse.GetCmdStatus() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_errorhandling::CommandCompleted iState:%d FAILED", iState));
+                        (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted iState:%d FAILED", iState));
     }
     switch (iState)
     {
@@ -1042,7 +968,7 @@
                 if (!ConfigComposer())
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_errorhandling::CommandCompleted: Error - ConfigComposer failed"));
+                                    (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted: Error - ConfigComposer failed"));
                     PVPATB_TEST_IS_TRUE(false);
                     iState = PVAE_CMD_RESET;
                     RunIfNotReady();
@@ -1083,7 +1009,7 @@
                 if (!ConfigureAudioEncoder())
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_errorhandling::CommandCompleted: Error - ConfigureAudioEncoder failed"));
+                                    (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted: Error - ConfigureAudioEncoder failed"));
                     PVPATB_TEST_IS_TRUE(false);
                     iState = PVAE_CMD_CLOSE;
                     RunIfNotReady();
@@ -1109,7 +1035,7 @@
                 if (!ConfigureVideoEncoder())
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_errorhandling::CommandCompleted: Error - ConfigureVideoEncoder failed"));
+                                    (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted: Error - ConfigureVideoEncoder failed"));
                     PVPATB_TEST_IS_TRUE(false);
                     iObserver->CompleteTest(*iTestCase);
                 }
@@ -1121,15 +1047,8 @@
             }
             else
             {
-                if (ErrorHandling_WrongInputFormatTest == iTestCaseNum)
-                {
-                    PVPATB_TEST_IS_TRUE(true);
-                }
-                else
-                {
-                    // AddVideoMediaTrack failed
-                    PVPATB_TEST_IS_TRUE(false);
-                }
+                // AddVideoMediaTrack failed
+                PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
             }
@@ -1141,7 +1060,7 @@
                 if (!ConfigureTextEncoder())
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_errorhandling::CommandCompleted: Error - ConfigureTextEncoder failed"));
+                                    (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted: Error - ConfigureTextEncoder failed"));
                     PVPATB_TEST_IS_TRUE(false);
                     iObserver->CompleteTest(*iTestCase);
                 }
@@ -1171,7 +1090,7 @@
                 // Init failed
                 //Test does not hang, so return true
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_errorhandling::INIT FAILED"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::INIT FAILED"));
                 PVPATB_TEST_IS_TRUE(true);
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
@@ -1197,7 +1116,7 @@
                 // Start failed
                 //Test does not hang, so return true
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "pvauthor_async_test_errorhandling::START FAILED"));
+                                (0, "pvauthor_async_compressed_test_errorhandling::START FAILED"));
                 PVPATB_TEST_IS_TRUE(true);
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
@@ -1272,6 +1191,7 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
+                OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
                 iObserver->CompleteTest(*iTestCase);
             }
             break;
@@ -1288,7 +1208,7 @@
                 if (!DeleteTestInputs())
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                    (0, "pvauthor_async_test_errorhandling::CommandCompleted: Error - DeleteTestInputs failed"));
+                                    (0, "pvauthor_async_compressed_test_errorhandling::CommandCompleted: Error - DeleteTestInputs failed"));
                     PVPATB_TEST_IS_TRUE(false);
                     iObserver->CompleteTest(*iTestCase);
                     return;
@@ -1327,3 +1247,5 @@
         }
     }
 }
+
+
diff --git a/engines/author/test/src/test_pv_author_engine_testset4.h b/engines/author/test/src/test_pv_author_engine_testset4.h
index 89cd4be..5cf67e8 100644
--- a/engines/author/test/src/test_pv_author_engine_testset4.h
+++ b/engines/author/test/src/test_pv_author_engine_testset4.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,18 +25,22 @@
 #ifndef TEST_PV_AUTHOR_ENGINE_TYPEDEFS_H
 #include "test_pv_author_engine_typedefs.h"
 #endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
 #define PVPATB_TEST_IS_TRUE( condition ) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
 
 
-class pvauthor_async_test_errorhandling: public pvauthor_async_test_base
+class pvauthor_async_compressed_test_errorhandling: public pvauthor_async_test_base
 {
     public:
-        pvauthor_async_test_errorhandling(PVAuthorAsyncTestParam aTestParam, const char* aInputFileNameAudio,
-                                          const char* aInputFileNameVideo, const char* aInputFileNameText, const char* aOutputFileName,
-                                          PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,
-                                          PVAETestInputType aTextInputType, const char* aComposerMimeType,
-                                          const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType,
-                                          const char* aTextEncoderMimeType, AVTConfig aAVTConfig, bool aPauseResumeEnable, uint32 aAuthoringTime)
+        pvauthor_async_compressed_test_errorhandling(PVAuthorAsyncTestParam aTestParam, const char* aInputFileNameAudio,
+                const char* aInputFileNameVideo, const char* aInputFileNameText, const char* aOutputFileName,
+                PVAETestInputType aAudioInputType, PVAETestInputType aVideoInputType,
+                PVAETestInputType aTextInputType, const char* aComposerMimeType,
+                const char* aAudioEncoderMimeType, const char* aVideoEncoderMimeType,
+                const char* aTextEncoderMimeType, AVTConfig aAVTConfig, bool aPauseResumeEnable, uint32 aAuthoringTime,
+                FAIL_STATE aFailState)
 
                 : pvauthor_async_test_base(aTestParam)
 
@@ -60,9 +64,10 @@
                 , iPauseResumeEnable(aPauseResumeEnable)
                 , iAuthoringTime(aAuthoringTime)
                 , iAuthoringCounter(0)
+                , iFailureState(aFailState)
 
         {
-            iLogger = PVLogger::GetLoggerObject("pvauthor_async_test_errorhandling");
+            iLogger = PVLogger::GetLoggerObject("pvauthor_async_compressed_test_errorhandling");
 
             if (iAuthoringTime > 0)
             {
@@ -121,7 +126,7 @@
             iRemoveDataSourceDone = 0;
         }
 
-        ~pvauthor_async_test_errorhandling()
+        ~pvauthor_async_compressed_test_errorhandling()
         {
             Cleanup();
         }
@@ -199,6 +204,8 @@
         OSCL_wHeapString<OsclMemAllocator> iCopyrightString;
         OSCL_wHeapString<OsclMemAllocator> iDescriptionString;
         OSCL_wHeapString<OsclMemAllocator> iRatingString;
+        OSCL_wHeapString<OsclMemAllocator> iAlbumTitle;
+        uint16							   iRecordingYear;
 
         AVTConfig iAVTConfig;
         Oscl_Vector<PVAETestInput, OsclMemAllocator> iTestInputs;
@@ -211,6 +218,10 @@
         uint32 iAuthoringTime;
         int iAuthoringCounter;
         uint32 iTestDuration;
+        FAIL_STATE	iFailureState;
+        //For CapConfig
+        PvmiCapabilityAndConfig* iAuthorCapConfigIF;
+        PvmiKvp* iErrorKVP;
 };
 
 #endif
diff --git a/engines/author/test/src/test_pv_author_engine_testset5.cpp b/engines/author/test/src/test_pv_author_engine_testset5.cpp
index 02d887d..d2277b1 100644
--- a/engines/author/test/src/test_pv_author_engine_testset5.cpp
+++ b/engines/author/test/src/test_pv_author_engine_testset5.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,9 @@
 #include "pvaetest_node_config.h"
 #endif
 
+#ifndef PVMI_KVP_H_INCLUDED
+#include "pvmi_kvp.h"
+#endif
 void pv_mediainput_async_test_opencomposestop::StartTest()
 {
     AddToScheduler();
@@ -54,6 +57,7 @@
     OSCL_UNUSED_ARG(aEvent);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pv_mediainput_async_test_opencomposestop::HandleErrorEvent"));
     iState = PVAE_CMD_RESET;
+    Cancel();//added to cancel previous running AO
     RunIfNotReady();
 }
 
@@ -84,6 +88,7 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                             (0, "pv_mediainput_async_test_opencomposestop::HandleNodeInformationalEvent: Duration progress: %d ms",
                              (int32)eventData));
+            fprintf(iStdOut, "Duration: %d ms\n", (int32)eventData);
             break;
 
         case PVMF_COMPOSER_FILESIZE_PROGRESS:
@@ -91,6 +96,7 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                             (0, "pv_mediainput_async_test_opencomposestop::HandleNodeInformationalEvent: File size progress: %d bytes",
                              (int32)eventData));
+            fprintf(iStdOut, "File size: %d bytes\n", (int32)eventData);
             break;
 
         case PVMF_COMPOSER_EOS_REACHED:
@@ -117,9 +123,8 @@
     iFileParser = NULL;
 
     iFileServer.Connect();
-    uint32 numloops = 0;
 
-    if (PVMF_AVIFF == iMediaInputType)
+    if (iMediaInputType == PVMF_MIME_AVIFF)
     {
 
         OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(iInputFileName, error, &iFileServer););
@@ -172,14 +177,14 @@
         }
 
     }
-    else if (PVMF_WAVFF == iMediaInputType)
+    else if (iMediaInputType == PVMF_MIME_WAVFF)
     {
         OSCL_TRY(error, iFileParser = OSCL_NEW(PV_Wav_Parser, ()););
         if (error || (NULL == iFileParser))
         {
             return false;
         }
-        if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, NULL) != PVWAVPARSER_OK)
+        if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, &iFileServer) != PVWAVPARSER_OK)
         {
 
             goto ERROR_CODE;
@@ -240,8 +245,6 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                             (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - CreateMIOInputNode failed"));
 
-            //delete any MIO Comp created.
-            MIOComp.DeleteInputNode();
             goto ERROR_CODE;
 
         }
@@ -264,14 +267,14 @@
 ERROR_CODE:
     {
         //remove file parser
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
             PVAviFile::DeleteAviFileParser(fileparser);
             fileparser = NULL;
             iFileParser = NULL;
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
             delete(fileparser);
@@ -289,23 +292,24 @@
 bool pv_mediainput_async_test_opencomposestop::AddDataSource()
 {
     int32 err = 0;
-    uint32 ii = 0;
     uint32 noOfNodes = iMIOComponent.iMIONode.size();
 
-    for (ii = 0; ii < noOfNodes; ii++)
+    OSCL_TRY(err,
+             for (uint32 ii = 0; ii < noOfNodes; ii++)
+{
+    AddEngineCommand();
+
+        iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
+    }
+            );
+
+    if (err != OSCL_ERR_NONE)
     {
-        AddEngineCommand();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
 
-        OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor););
-
-        if (err != OSCL_ERR_NONE)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
-
-            iMIOComponent.DeleteInputNode();
-            return false;
-        }
+        iMIOComponent.DeleteInputNode();
+        return false;
     }
 
     return true;
@@ -372,22 +376,115 @@
 
         return false;
     }
+    PvmfAssetInfo3GPPLocationStruct aLocation_info;
 
-    OSCL_wHeapString<OsclMemAllocator> versionString = _STRLIT("version");
-    OSCL_wHeapString<OsclMemAllocator> titleString = _STRLIT("title");
-    OSCL_wHeapString<OsclMemAllocator> authorString = _STRLIT("author");
-    OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("copyright");
-    OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("description");
-    OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("rating");
+    OSCL_wHeapString<OsclMemAllocator> versionString = _STRLIT("Latest Version");
+    OSCL_wHeapString<OsclMemAllocator> titleString = _STRLIT("This is the test title");
+    OSCL_wHeapString<OsclMemAllocator> authorString = _STRLIT("Unknown");
+    OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("PV Copyright");
+    OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("New Song");
+    OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("Five");
+    OSCL_wHeapString<OsclMemAllocator> performerString = _STRLIT("Performer");
+    OSCL_wHeapString<OsclMemAllocator> genreString = _STRLIT("Rock");
+    OSCL_wHeapString<OsclMemAllocator> classificationInfoString = _STRLIT("Rock Music");
+    OSCL_wHeapString<OsclMemAllocator> keyWordInfoString1 = _STRLIT("One");
+    OSCL_wHeapString<OsclMemAllocator> keyWordInfoString2 = _STRLIT("Two");
+    OSCL_wHeapString<OsclMemAllocator> keyWordInfoString3 = _STRLIT("Three");
+    OSCL_wHeapString<OsclMemAllocator> location_name = _STRLIT("PV");
+    OSCL_wHeapString<OsclMemAllocator> astronomical_body = _STRLIT("PV");
+    OSCL_wHeapString<OsclMemAllocator> additional_notes = _STRLIT("PV");
+    OSCL_wHeapString<OsclMemAllocator> iAlbumTitle = _STRLIT("albumtitle");
+    uint16 iRecordingYear = 2008;
+
+    OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
+
+    aLocation_info._location_name = NULL;
+    uint32 size = location_name.get_size();
+    aLocation_info._location_name = (oscl_wchar *)oscl_malloc(sizeof(oscl_wchar) * size + 10);
+    oscl_strncpy(aLocation_info._location_name, location_name.get_cstr(), size);
+    aLocation_info._location_name[size+1] = 0;
+
+    size = astronomical_body.get_size();
+    aLocation_info._astronomical_body = NULL;
+    aLocation_info._astronomical_body = (oscl_wchar *)oscl_malloc(sizeof(oscl_wchar) * size + 10);
+    oscl_strncpy(aLocation_info._astronomical_body, astronomical_body.get_cstr(), size);
+    aLocation_info._astronomical_body[size+1] = 0;
+
+
+    size = additional_notes.get_size();
+    aLocation_info._additional_notes = NULL;
+    aLocation_info._additional_notes = (oscl_wchar *)oscl_malloc(sizeof(oscl_wchar) * size + 10);
+    oscl_strncpy(aLocation_info._additional_notes, additional_notes.get_cstr(), size);
+    aLocation_info._additional_notes[size+1] = 0;
+
+    aLocation_info._role = 2;
+    aLocation_info._longitude = 0;
+    aLocation_info._latitude = 0;
+    aLocation_info._altitude = 0;
+    aLocation_info.Lang_code = lang_code;
+
+
+    uint32 classificationEntity = 0;
+    uint16 classificationTable = 0;
 
     clipConfig->SetOutputFileName(iOutputFileName);
     clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(versionString);
-    clipConfig->SetTitle(titleString);
-    clipConfig->SetAuthor(authorString);
-    clipConfig->SetCopyright(copyrightString);
-    clipConfig->SetDescription(descriptionString);
-    clipConfig->SetRating(ratingString);
+    clipConfig->SetVersion(versionString, lang_code);
+    clipConfig->SetTitle(titleString, lang_code);
+    clipConfig->SetAuthor(authorString, lang_code);
+    clipConfig->SetCopyright(copyrightString, lang_code);
+    clipConfig->SetDescription(descriptionString, lang_code);
+    clipConfig->SetRating(ratingString, lang_code);
+    clipConfig->SetPerformer(performerString, lang_code);
+    clipConfig->SetGenre(genreString, lang_code);
+    clipConfig->SetClassification(classificationInfoString, classificationEntity, classificationTable, lang_code);
+    clipConfig->SetKeyWord(keyWordInfoString1, lang_code);
+    clipConfig->SetKeyWord(keyWordInfoString2, lang_code);
+    clipConfig->SetKeyWord(keyWordInfoString3, lang_code);
+
+
+    clipConfig->SetLocationInfo(aLocation_info);
+
+
+    clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
+
+
+    clipConfig->SetRecordingYear(iRecordingYear);
+
+    if (iTestCaseNum == K3GPPDownloadModeTest || iTestCaseNum == K3GPPDownloadModeLongetivityTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_DOWNLOAD_MODE);
+    }
+    else if (iTestCaseNum == K3GPPProgressiveDownloadModeTest || iTestCaseNum == K3GPPProgressiveDownloadModeLongetivityTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_3GPP_PROGRESSIVE_DOWNLOAD_MODE);
+    }
+    else if (iTestCaseNum == KMovieFragmentModeTest || iTestCaseNum == KMovieFragmentModeLongetivityTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_MOVIE_FRAGMENT_MODE);
+    }
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+    else if (iTestCaseNum == KIMotionAuthoringModeTest || iTestCaseNum == KIMotionAuthoringModeLongetivityTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_IMOTION_PSEUDO_STREAMING_MODE);
+    }
+    else if (iTestCaseNum == KIMotionDownloadModeTest || iTestCaseNum == KIMotionDownloadModeLongetivityTest)
+    {
+        clipConfig->SetAuthoringMode(PVMP4FFCN_IMOTION_DOWNLOAD_MODE);
+    }
+#endif
+
+
+
+
+    if (aLocation_info._location_name != NULL)
+        OSCL_FREE(aLocation_info._location_name);
+
+    if (aLocation_info._astronomical_body != NULL)
+        OSCL_FREE(aLocation_info._astronomical_body);
+
+    if (aLocation_info._additional_notes != NULL)
+        OSCL_FREE(aLocation_info._additional_notes);
 
 
     return true;
@@ -400,7 +497,7 @@
 
     if (iAddAudioMediaTrack)
     {
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             Oscl_Vector<uint32, OsclMemAllocator> audioStrNum;
 
@@ -417,7 +514,7 @@
             AddEngineCommand();
 
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             PVWAVFileInfo wavFileInfo;
             (iMIOComponent.iPVWavFile)->RetrieveFileInfo(wavFileInfo);
@@ -431,7 +528,7 @@
 
         }
 
-        if (!PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig))
+        if (!PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig, iAudioBitrate))
         {
             return false;
         }
@@ -439,7 +536,7 @@
 
     if (iAddVideoMediaTrack)
     {
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             Oscl_Vector<uint32, OsclMemAllocator> vidStrNum;
             vidStrNum = (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
@@ -455,7 +552,7 @@
             AddEngineCommand();
 
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             return false;
         }
@@ -481,10 +578,10 @@
 
     uint32 width = 0;
     uint32 height = 0;
-    uint32 frameRate = 0;
+    OsclFloat frameRate = 0.0;
     uint32 frameInterval = 0;
 
-    if (PVMF_AVIFF == iMediaInputType)
+    if (iMediaInputType == PVMF_MIME_AVIFF)
     {
         Oscl_Vector<uint32, OsclMemAllocator> vidStrNum =
             (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
@@ -492,16 +589,27 @@
         width = (iMIOComponent.iPVAviFile)->GetWidth(vidStrNum[0]);
         bool orient = false;
         height = (iMIOComponent.iPVAviFile)->GetHeight(orient, vidStrNum[0]);
-        frameRate = (uint32)(iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
+        frameRate = (iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
         frameInterval = (iMIOComponent.iPVAviFile)->GetFrameDuration();
-
     }
 
-    config->SetNumLayers(KNumLayers);
-    config->SetOutputBitRate(0, KVideoBitrate);
+    //setting the width and height
     config->SetOutputFrameSize(0, width , height);
+
+    //setting video bitrate
+    if (0 == iVideoBitrate)
+    {
+        config->SetOutputBitRate(0, KVideoBitrate);
+    }
+    else
+    {
+        config->SetOutputBitRate(0, iVideoBitrate);//values from config file
+    }
+
     config->SetOutputFrameRate(0, frameRate);
-    config->SetIFrameInterval(frameInterval);
+    config->SetNumLayers(KNumLayers);
+    config->SetIFrameInterval(KVideoIFrameInterval);
+    config->SetSceneDetection(true);
 
     return true;
 }
@@ -534,7 +642,6 @@
     iComposer = NULL;
 
     ResetAuthorConfig();
-
     if (iAuthor)
     {
         PVAuthorEngineFactory::DeleteAuthor(iAuthor);
@@ -544,6 +651,8 @@
 //	iMIOComponent.DeleteInputNode();
     iOutputFileName = NULL;
     iFileServer.Close();
+
+
 }
 
 
@@ -613,6 +722,17 @@
         }
         break;
 
+        case PVAE_CMD_QUERY_INTERFACE:
+
+            fprintf(iFile, "Query Interface\n");
+
+            if (!QueryComposerOutputInterface())
+            {
+                iState = PVAE_CMD_ADD_MEDIA_TRACK;
+                RunIfNotReady();
+            }
+            break;
+
         case PVAE_CMD_ADD_MEDIA_TRACK:
         {
             fprintf(iFile, "Add Media Track\n");
@@ -658,7 +778,10 @@
         case PVAE_CMD_RESET:
         {
             ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
+            if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
+            {
+                iAuthor->Reset((OsclAny*)iAuthor);
+            }
         }
         break;
 
@@ -692,6 +815,39 @@
         }
         break;
 
+        case PVAE_CMD_QUERY_INTERFACE2:
+            fprintf(iFile, "Query Interface2\n");
+            iAuthor->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (PVInterface*&)iAuthorCapConfigIF, (OsclAny*)iAuthor);
+            break;
+        case PVAE_CMD_CAPCONFIG_ASYNC:
+        {
+            fprintf(iFile, "Cap Config ASync\n");
+            CapConfigAsync();
+
+        }
+        break;
+
+        case PVAE_CMD_CAPCONFIG_SYNC:
+            // set configuration MIME strings Synchronously
+        {
+            fprintf(iFile, "Cap Config Sync\n");
+
+            if (!CapConfigSync()) //CapConfig failed
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "pv_mediainput_async_test_opencomposestop::Run: Error - CapConfigSync failed"));
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                iState = PVAE_CMD_START;
+                RunIfNotReady();
+            }
+        }
+        break;
+
         case PVAE_CMD_CLEANUPANDCOMPLETE:
         {
             Cleanup();
@@ -699,7 +855,6 @@
         }
         break;
 
-        case PVAE_CMD_QUERY_INTERFACE2:
         case PVAE_CMD_ADD_DATA_SINK:
         case PVAE_CMD_REMOVE_DATA_SINK:
             break;
@@ -732,10 +887,11 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "pv_mediainput_async_test_opencomposestop::CommandCompleted iState:%d", iState));
 
+
     if (aResponse.GetCmdStatus() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_generic_reset::CommandCompleted iState:%d FAILED", iState));
+                        (0, "pv_mediainput_async_test_opencomposestop::CommandCompleted iState:%d FAILED", iState));
     }
 
     switch (iState)
@@ -795,7 +951,7 @@
                 }
                 else
                 {
-                    iState = PVAE_CMD_ADD_MEDIA_TRACK;
+                    iState = PVAE_CMD_QUERY_INTERFACE;
                     RunIfNotReady();
                 }
             }
@@ -806,9 +962,26 @@
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
             }
+
         }
         break;
-
+        case PVAE_CMD_QUERY_INTERFACE:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                ConfigComposerOutput();
+                iState = PVAE_CMD_ADD_MEDIA_TRACK;
+                RunIfNotReady();
+            }
+            else
+            {
+                // QueryInterface failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
         case PVAE_CMD_ADD_MEDIA_TRACK:
         {
             if (EngineCmdComplete())
@@ -818,7 +991,7 @@
                     ConfigureVideoEncoder();
                 }
 
-                iState = PVAE_CMD_INIT;
+                iState = PVAE_CMD_QUERY_INTERFACE2;
             }
 
             if (aResponse.GetCmdStatus() == PVMFSuccess)
@@ -834,12 +1007,33 @@
             }
         }
         break;
+        case PVAE_CMD_QUERY_INTERFACE2:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = PVAE_CMD_INIT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // QueryInterface2 failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+            break;
 
         case PVAE_CMD_INIT:
         {
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                iState = PVAE_CMD_START;
+                if (iTestCaseNum == CapConfigTest)
+                {
+                    iState = PVAE_CMD_CAPCONFIG_ASYNC;
+                }
+                else
+                {
+                    iState = PVAE_CMD_START;
+                }
                 RunIfNotReady();
             }
             else
@@ -851,6 +1045,25 @@
             }
         }
         break;
+        case PVAE_CMD_CAPCONFIG_ASYNC:
+        {
+
+            if (aResponse.GetCmdStatus() != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "pv_mediainput_async_test_opencomposestop::Run: Error - CapConfigAsync failed"));
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(true);
+                iState = PVAE_CMD_START;
+                RunIfNotReady();
+            }
+        }
+        break;
 
         case PVAE_CMD_START:
         {
@@ -960,6 +1173,7 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
+                OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
                 iObserver->CompleteTest(*iTestCase);
             }
         }
@@ -973,14 +1187,14 @@
                 {
                     iOutputFileName = NULL;
                     iMIOComponent.DeleteInputNode();
-                    if (PVMF_AVIFF == iMediaInputType)
+                    if (iMediaInputType == PVMF_MIME_AVIFF)
                     {
                         PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
                         PVAviFile::DeleteAviFileParser(fileparser);
                         fileparser = NULL;
                         iFileParser = NULL;
                     }
-                    else if (PVMF_WAVFF == iMediaInputType)
+                    else if (iMediaInputType == PVMF_MIME_WAVFF)
                     {
                         PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
                         delete(fileparser);
@@ -1031,3 +1245,328 @@
     }  //end switch
 }
 
+bool pv_mediainput_async_test_opencomposestop::ConfigComposerOutput()
+{
+    PvmfComposerSizeAndDurationInterface* config =
+        OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
+    if (!config)
+    {
+        return false;
+    }
+    bool enabled = false;
+    uint32 configData = 0;
+    switch (iTestCaseNum)
+    {
+        case KMaxFileSizeTest:
+        case KMaxFileSizeLongetivityTest:
+        {
+            if (config->SetMaxFileSize(true, KMaxFileSize) != PVMFSuccess)
+            {
+                return false;
+            }
+            config->GetMaxFileSizeConfig(enabled, configData);
+            if (!enabled || configData != KMaxFileSize)
+            {
+                return false;
+            }
+        }
+        break;
+
+        case PVMediaInput_Open_Compose_Stop_Test:
+        {
+            if (config->SetFileSizeProgressReport(true, KFileSizeProgressFreq) != PVMFSuccess)
+            {
+                return false;
+            }
+            config->GetFileSizeProgressReportConfig(enabled, configData);
+            if (!enabled || configData != KFileSizeProgressFreq)
+            {
+                return false;
+            }
+            if (config->SetDurationProgressReport(true, KDurationProgressFreq) != PVMFSuccess)
+            {
+                return false;
+            }
+            config->GetDurationProgressReportConfig(enabled, configData);
+            if (!enabled || configData != KDurationProgressFreq)
+            {
+                return false;
+            }
+        }
+        break;
+
+        default:
+            break;
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_opencomposestop::QueryComposerOutputInterface()
+{
+    switch (iTestCaseNum)
+    {
+        case PVMediaInput_Open_Compose_Stop_Test:
+        case KMaxFileSizeTest:
+        {
+            //iPendingCmds.push_back(PVAE_CMD_QUERY_INTERFACE);
+            iAuthor->QueryInterface(PvmfComposerSizeAndDurationUuid,
+                                    iOutputSizeAndDurationConfig, (OsclAny*)iAuthor);
+            return true;
+        }
+        break;
+        default:
+            return false;
+    }
+
+    return false;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// function for setting configuration MIME strings Asynchronously
+
+bool pv_mediainput_async_test_opencomposestop::CapConfigAsync()
+{
+    if (iTestCaseNum == CapConfigTest)
+    {
+        // Set the observer
+        iAuthorCapConfigIF->setObserver(this);
+
+        iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/author/productinfo/dummyprod1;valtype=int32");
+        iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+        iKVPSetAsync.value.int32_value = 2;
+
+        // set the parameter
+        iErrorKVP = NULL;
+        iAuthorCapConfigIF->setParametersAsync(NULL, &iKVPSetAsync, 1, iErrorKVP);
+
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+// function for setting configuration MIME strings Synchronously
+
+bool pv_mediainput_async_test_opencomposestop::CapConfigSync()
+{
+    if (iTestCaseNum == CapConfigTest)
+    {
+        // set the mime strings here
+        // capabilty and configuration feature implemented here
+        // set the config parameters using MIME strings here
+
+        // set the KVP array
+        PvmiKvp paramkvp1;
+        // set cache size for composer node
+        //	PVMI_FILEIO_PV_CACHE_SIZE (MACRO defined in "pvmi_fileio_kvp.h")
+        OSCL_StackString<64> paramkey1(_STRLIT_CHAR(PVMI_FILEIO_PV_CACHE_SIZE));
+        paramkey1 += _STRLIT_CHAR(";valtype=uint32");
+        // set KVP values
+        // for composer node
+        paramkvp1.key = paramkey1.get_str();
+        paramkvp1.value.uint32_value = 1024;
+
+        iErrorKVP = NULL;
+
+        // verifyParametersSync will give Failure for test cases not using MP4 composer("fileio") node so commented
+        // Verify the new settings
+        //if (iAuthorCapConfigIF->verifyParametersSync(NULL, &paramkvp1, 1) == PVMFSuccess)
+        {
+            // set the parameter
+            iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
+            if (iErrorKVP == NULL)
+            {
+                // Check by calling get
+                PvmiKvp* retparam = NULL;
+                int retnumparam = 0;
+                paramkey1 += _STRLIT_CHAR(";attr=cur");
+                // pass the string
+                // retrieve a MIME string back
+                iAuthorCapConfigIF->getParametersSync(NULL, paramkey1.get_str(), retparam, retnumparam, NULL);
+
+                if ((retparam != NULL) && (retnumparam == 1))
+                {
+                    // release the parameters
+                    if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
+                    {
+                        return false;
+                    }
+                }
+            }
+        }
+        /*
+        else
+        {
+        	return false;
+        }*/
+
+        //MIME for file output node
+        // set here any parameter here
+        OSCL_StackString<64> paramkey2(_STRLIT_CHAR("x-pvmf/file/output/parameter1;valtype=uint32"));
+
+        // for file output node
+        paramkvp1.key = paramkey2.get_str();
+        paramkvp1.value.int32_value = 144;
+
+        // set the value in node using SetParameterSync f(n) here
+        iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
+
+        // MIME for media io node
+        // set parameters here
+        OSCL_StackString<64> paramkey3(_STRLIT_CHAR("x-pvmf/media-io/parameter1;valtype=uint32"));
+
+        // for media io node
+        paramkvp1.key = paramkey3.get_str();
+        paramkvp1.value.int32_value = 144;
+
+        // set the value in node using SetParameterSync f(n) here
+        iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
+
+        if (iErrorKVP == NULL)
+        {
+            // Check by calling get
+            PvmiKvp* retparam = NULL;
+            int retnumparam = 0;
+            paramkey3 += _STRLIT_CHAR(";attr=cur");
+            // pass the string
+            // retrieve a MIME string back
+            iAuthorCapConfigIF->getParametersSync(NULL, paramkey3.get_str(), retparam, retnumparam, NULL);
+            if ((retparam != NULL) && (retnumparam == 1))
+            {
+                // release the parameters
+                if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
+                {
+                    return false;
+                }
+            }
+        }
+
+        // MIME for amr encoder
+        // set the parameter here
+
+        // MIME string here "x-pvmf/encoder/audio/sampling_rate;valtype=uint32"
+        OSCL_StackString<64> paramkey4(_STRLIT_CHAR(MOUT_AUDIO_SAMPLING_RATE_KEY));
+        // MOUT_AUDIO_SAMPLING_RATE_KEY (MACRO defined in "pvmi_kvp.h")
+        // for amr encoder node
+        paramkvp1.key = paramkey4.get_str();
+        paramkvp1.value.int32_value = 8000;
+
+        // set the value in node using SetParameterSync f(n) here
+        iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
+
+        if (iErrorKVP == NULL)
+        {
+            // Check by calling get
+            PvmiKvp* retparam = NULL;
+            int retnumparam = 0;
+            paramkey1 += _STRLIT_CHAR(";attr=cur");
+            // pass the string
+            // retrieve a MIME string back
+            iAuthorCapConfigIF->getParametersSync(NULL, paramkey4.get_str(), retparam, retnumparam, NULL);
+            if ((retparam != NULL) && (retnumparam == 1))
+            {
+                // release the parameters
+                if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
+                {
+                    return false;
+                }
+            }
+        }
+
+
+        // MIME for video encoder
+        // set the parameter frame width in the node (use combinations for width n height default is 176 by 144)
+
+        // MIME string here "x-pvmf/video/render/output_width;valtype=uint32"
+        OSCL_StackString<64> paramkey5(_STRLIT_CHAR(MOUT_VIDEO_OUTPUT_WIDTH_KEY));
+        // MACRO "MOUT_VIDEO_OUTPUT_WIDTH_KEY" been defined in "pvmi_kvp.h"
+        // for video encoder node
+        paramkvp1.key = paramkey5.get_str();
+        paramkvp1.value.uint32_value = 128;
+        // set the value in node using SetParameterSync f(n) here
+        iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
+
+        if (iErrorKVP == NULL)
+        {
+            // Check by calling get
+            PvmiKvp* retparam = NULL;
+            int retnumparam = 0;
+            paramkey1 += _STRLIT_CHAR(";attr=cur");
+            // pass the string
+            // retrieve a MIME string back
+            iAuthorCapConfigIF->getParametersSync(NULL, paramkey5.get_str(), retparam, retnumparam, NULL);
+            if ((retparam != NULL) && (retnumparam == 1))
+            {
+                // release the parameters
+                if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
+                {
+                    return false;
+                }
+            }
+        }
+
+        // MIME for AVC Encoder
+        // set the parameter encoding mode
+
+        // MIME string here "x-pvmf/avc/encoder/encoding_mode;valtype=uint32"
+        OSCL_StackString<64> paramkey6(_STRLIT_CHAR(PVMF_AVC_ENCODER_ENCODINGMODE_KEY));
+        // MACRO "PVMF_AVC_ENCODER_ENCODINGMODE_KEY" been defined in "pvmi_kvp.h"
+        // for AVC Encoder node
+        paramkvp1.key = paramkey6.get_str();
+        paramkvp1.value.uint32_value = 3;//EAVCEI_ENCMODE_TWOWAY;
+        // set the value in node using SetParameterSync f(n) here
+        iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp1, 1, iErrorKVP);
+
+        if (iErrorKVP == NULL)
+        {
+            // Check by calling get
+            PvmiKvp* retparam = NULL;
+            int retnumparam = 0;
+            paramkey1 += _STRLIT_CHAR(";attr=cur");
+            // pass the string
+            // retrieve a MIME string back
+            iAuthorCapConfigIF->getParametersSync(NULL, paramkey6.get_str(), retparam, retnumparam, NULL);
+            if ((retparam != NULL) && (retnumparam == 1))
+            {
+                // release the parameters
+                if (iAuthorCapConfigIF->releaseParameters(NULL, retparam, retnumparam) != PVMFSuccess)
+                {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+    else
+    {
+        return true;
+    }
+
+}
+
+void pv_mediainput_async_test_opencomposestop::SignalEvent(int32 aReq_Id)
+{
+    if (aReq_Id == 0) //For PVAE_CMD_CAPCONFIG_SET_PARAMETERS
+    {
+        if (iErrorKVP != NULL)
+        {
+            // There was an error in setParameterAsync()
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                            (0, "pv_mediainput_async_test_opencomposestop::SignalEvent: setParametersAsync failed"));
+            PVPATB_TEST_IS_TRUE(false);
+            iObserver->CompleteTest(*iTestCase);
+        }
+        else
+        {
+            iState = PVAE_CMD_CAPCONFIG_SYNC;
+            RunIfNotReady();
+        }
+    }
+}
+
diff --git a/engines/author/test/src/test_pv_author_engine_testset5.h b/engines/author/test/src/test_pv_author_engine_testset5.h
index 06cc124..5b35482 100644
--- a/engines/author/test/src/test_pv_author_engine_testset5.h
+++ b/engines/author/test/src/test_pv_author_engine_testset5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,11 +21,15 @@
 #ifndef TEST_PV_MEDIAINPUT_AUTHOR_ENGINE_H
 #include "test_pv_mediainput_author_engine.h"
 #endif
+#ifndef PVMI_FILEIO_KVP_H_INCLUDED
+#include "pvmi_fileio_kvp.h"
+#endif
 
 #define PVPATB_TEST_IS_TRUE( condition ) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
 
 #define TEST_TIMEOUT_FACTOR 8  //take into account AVC encoder and symbian emulator
-class pv_mediainput_async_test_opencomposestop: public pvauthor_async_test_base
+class pv_mediainput_async_test_opencomposestop: public pvauthor_async_test_base,
+            public PvmiConfigAndCapabilityCmdObserver
 {
     public:
         pv_mediainput_async_test_opencomposestop(PVAuthorAsyncTestParam aTestParam, PVMediaInputTestParam aMediaParam, bool aPauseResumeEnable)
@@ -50,8 +54,15 @@
                 , iAddVideoMediaTrack(false)
                 , iFile(aTestParam.iStdOut)
                 , iRealTimeAuthoring(aMediaParam.iRealTimeAuthoring)
+                , iVideoBitrate(aMediaParam.iVideoBitrate)
+                , iAudioBitrate(aMediaParam.iAudioBitrate)
+                , iFrameRate(aMediaParam.iFrameRate)
+                , iSamplingRate(aMediaParam.iSamplingRate)
 
         {
+            OSCL_UNUSED_ARG(iAudioBitrate);
+            OSCL_UNUSED_ARG(iFrameRate);
+            OSCL_UNUSED_ARG(iSamplingRate);
 
             iLogger = PVLogger::GetLoggerObject("pv_mediainput_async_test_opencomposestop");
 
@@ -109,6 +120,14 @@
         bool ConfigOutputFile();
         bool ConfigMp43gpComposer();
 
+        bool CapConfigSync();
+        bool CapConfigAsync();
+        // From PvmiConfigAndCapabilityCmdObserver
+        void SignalEvent(int32 req_id);
+
+        // Method to configure max filesize/duration interface
+        bool QueryComposerOutputInterface();
+        bool ConfigComposerOutput();
         // Methods to add media tracks
         bool AddMediaTrack();
 
@@ -154,6 +173,7 @@
         PVInterface*			 iComposerConfig;
         PVInterface*			 iAudioEncoderConfig;
         PVInterface*			 iVideoEncoderConfig;
+        PVInterface*			 iOutputSizeAndDurationConfig;
         PVMIOControlComp		 iMIOComponent;
         uint32					 iPendingCmds;
         PVLogger*                iLogger;
@@ -166,6 +186,15 @@
         uint32					 iAuthoringCount;
         FILE*                    iFile;
         bool					 iRealTimeAuthoring;
+        PvmiCapabilityAndConfig* iAuthorCapConfigIF;
+        PvmiKvp					 iKVPSetAsync;
+        OSCL_StackString<64>	 iKeyStringSetAsync;
+        PvmiKvp*				 iErrorKVP;
+        uint32					 iVideoBitrate;
+        uint32					 iAudioBitrate;
+        OsclFloat 				 iFrameRate;
+        uint32					 iSamplingRate;
+
 };
 
 #endif
diff --git a/engines/author/test/src/test_pv_author_engine_testset6.cpp b/engines/author/test/src/test_pv_author_engine_testset6.cpp
index 6c24d61..b737821 100644
--- a/engines/author/test/src/test_pv_author_engine_testset6.cpp
+++ b/engines/author/test/src/test_pv_author_engine_testset6.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@
 #include "pvaetest_node_config.h"
 #endif
 
+#include "pvmf_media_data.h"
+#include "pvmf_media_msg_format_ids.h"
 void pv_mediainput_async_test_errorhandling::StartTest()
 {
     AddToScheduler();
@@ -58,10 +60,25 @@
 ////////////////////////////////////////////////////////////////////////////
 void pv_mediainput_async_test_errorhandling::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    OSCL_UNUSED_ARG(aEvent);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "pv_mediainput_async_test_errorhandling::HandleInformationalEvent"));
 
+    switch (aEvent.GetEventType())
+    {
+        case PVMF_COMPOSER_EOS_REACHED:
+            //Engine already stopped at EOS so send reset command.
+            iState = PVAE_CMD_RESET;
+            Cancel();
+            RunIfNotReady();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "pv_mediainput_async_test_errorhandling::HandleInformationalEvent: EOS reached"));
+
+            break;
+
+        default:
+            break;
+    }
+
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -71,20 +88,20 @@
     int32 error = 0;
     iFileParser = NULL;
     iFileServer.Connect();
-    if (PVMF_AVIFF == iMediaInputType)
+    if (iMediaInputType == PVMF_MIME_AVIFF)
     {
 
         OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(iInputFileName, error, &iFileServer););
 
         if (error || (NULL == iFileParser))
         {
-            if (iWrongFormat)
+            if (PVMediaInput_ErrorHandling_Test_WrongIPFileName == iTestErrorType)
             {
-                PVPATB_TEST_IS_TRUE(false);
+                PVPATB_TEST_IS_TRUE(true);
             }
             else
             {
-                PVPATB_TEST_IS_TRUE(true);
+                PVPATB_TEST_IS_TRUE(false);
 
             }
             if (iFileParser)
@@ -117,14 +134,14 @@
         }
 
     }
-    else if (PVMF_WAVFF == iMediaInputType)
+    else if (iMediaInputType == PVMF_MIME_WAVFF)
     {
         OSCL_TRY(error, iFileParser = OSCL_NEW(PV_Wav_Parser, ()););
         if (error || (NULL == iFileParser))
         {
             return false;
         }
-        if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, NULL) != PVWAVPARSER_OK)
+        if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, &iFileServer) != PVWAVPARSER_OK)
         {
             goto ERROR_CODE;
         }
@@ -143,14 +160,19 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                             (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - CreateMIOInputNode failed"));
 
-            PVPATB_TEST_IS_TRUE(true);
+            if (PVMediaInput_ErrorHandling_Test_WrongFormat == iTestErrorType)
+            {
+                PVPATB_TEST_IS_TRUE(true);
+            }
 
-            //delete any MIO Comp created.
-            MIOComp.DeleteInputNode();
             goto ERROR_CODE;
         }
 
-        PVPATB_TEST_IS_TRUE(false);
+        if (PVMediaInput_ErrorHandling_Test_WrongFormat == iTestErrorType)
+        {
+
+            PVPATB_TEST_IS_TRUE(false);
+        }
 
         iMIOComponent = MIOComp;
         if (!AddDataSource())
@@ -167,14 +189,14 @@
     {
 
         //remove file parser
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
             PVAviFile::DeleteAviFileParser(fileparser);
             fileparser = NULL;
             iFileParser = NULL;
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
             delete(fileparser);
@@ -190,23 +212,25 @@
 bool pv_mediainput_async_test_errorhandling::AddDataSource()
 {
     int32 err = 0;
-    uint32 ii = 0;
     uint32 noOfNodes = iMIOComponent.iMIONode.size();
+    OSCL_TRY(err,
+             for (uint32 ii = 0; ii < noOfNodes; ii++)
+{
+    AddEngineCommand();
 
-    for (ii = 0; ii < noOfNodes; ii++)
+        //OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor););
+        iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
+    }
+            );
+
+
+    if (err != OSCL_ERR_NONE)
     {
-        AddEngineCommand();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
 
-        OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor););
-
-        if (err != OSCL_ERR_NONE)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
-
-            iMIOComponent.DeleteInputNode();
-            return false;
-        }
+        iMIOComponent.DeleteInputNode();
+        return false;
     }
 
     return true;
@@ -281,15 +305,20 @@
     OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("copyright");
     OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("description");
     OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("rating");
+    OSCL_wHeapString<OsclMemAllocator> iAlbumTitle = _STRLIT("albumtitle");
+    uint16 iRecordingYear = 2008;
+    OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
 
     clipConfig->SetOutputFileName(iOutputFileName);
     clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(versionString);
-    clipConfig->SetTitle(titleString);
-    clipConfig->SetAuthor(authorString);
-    clipConfig->SetCopyright(copyrightString);
-    clipConfig->SetDescription(descriptionString);
-    clipConfig->SetRating(ratingString);
+    clipConfig->SetVersion(versionString, lang_code);
+    clipConfig->SetTitle(titleString, lang_code);
+    clipConfig->SetAuthor(authorString, lang_code);
+    clipConfig->SetCopyright(copyrightString, lang_code);
+    clipConfig->SetDescription(descriptionString, lang_code);
+    clipConfig->SetRating(ratingString, lang_code);
+    clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
+    clipConfig->SetRecordingYear(iRecordingYear);
 
 
     return true;
@@ -302,7 +331,7 @@
 
     if (iAddAudioMediaTrack)
     {
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             Oscl_Vector<uint32, OsclMemAllocator> audioStrNum;
 
@@ -319,7 +348,7 @@
             AddEngineCommand();
 
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             PVWAVFileInfo wavFileInfo;
             (iMIOComponent.iPVWavFile)->RetrieveFileInfo(wavFileInfo);
@@ -341,7 +370,7 @@
 
     if (iAddVideoMediaTrack)
     {
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             Oscl_Vector<uint32, OsclMemAllocator> vidStrNum;
             vidStrNum = (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
@@ -357,7 +386,7 @@
             AddEngineCommand();
 
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             return false;
         }
@@ -383,10 +412,10 @@
 
     uint32 width = 0;
     uint32 height = 0;
-    uint32 frameRate = 0;
+    OsclFloat frameRate = 0;
     uint32 frameInterval = 0;
 
-    if (PVMF_AVIFF == iMediaInputType)
+    if (iMediaInputType == PVMF_MIME_AVIFF)
     {
         Oscl_Vector<uint32, OsclMemAllocator> vidStrNum =
             (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
@@ -394,7 +423,7 @@
         width = (iMIOComponent.iPVAviFile)->GetWidth(vidStrNum[0]);
         bool orient = false;
         height = (iMIOComponent.iPVAviFile)->GetHeight(orient, vidStrNum[0]);
-        frameRate = (uint32)(iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
+        frameRate = (iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
         frameInterval = (iMIOComponent.iPVAviFile)->GetFrameDuration();
 
     }
@@ -403,7 +432,8 @@
     config->SetOutputBitRate(0, KVideoBitrate);
     config->SetOutputFrameSize(0, width , height);
     config->SetOutputFrameRate(0, frameRate);
-    config->SetIFrameInterval(frameInterval);
+    config->SetIFrameInterval(KVideoIFrameInterval);
+    config->SetSceneDetection(true);
 
     return true;
 }
@@ -456,7 +486,7 @@
     {
         return;
     }
-
+    iCheckState = iState;
     switch (iState)
     {
         case PVAE_CMD_CREATE:
@@ -497,14 +527,6 @@
                 iState = PVAE_CMD_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
             }
-            else
-            {
-                //Error Handling test. not expected to come here.
-                PVPATB_TEST_IS_TRUE(false);
-                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-            }
-
         }
         break;
 
@@ -534,6 +556,22 @@
         }
         break;
 
+        case PVAE_CMD_QUERY_INTERFACE1:
+            iAuthor->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
+                                    (PVInterface*&)iAuthorCapConfigIF,
+                                    (OsclAny*)iAuthor);
+            break;
+
+        case PVAE_CMD_CAPCONFIG_SYNC1:
+            CapConfigSync1();
+            iState = PVAE_CMD_START;
+            RunIfNotReady();
+            break;
+
+        case PVAE_CMD_QUERY_INTERFACE_COMP:
+            iAuthor->QueryInterface(PvmfComposerSizeAndDurationUuid,
+                                    iOutputSizeAndDurationConfig, (OsclAny*)iAuthor);
+            break;
         case PVAE_CMD_START:
         {
             iAuthor->Start();
@@ -545,14 +583,20 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                             (0, "pv_mediainput_async_test_errorhandling::Run: Command Stop"));
 
+            fprintf(iFile, "Error: Recording timeout, stop engine please wait *******\n");
             iAuthor->Stop((OsclAny*)iAuthor);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                            (0, "pv_mediainput_async_test_errorhandling::Run: Error: Recording timeout, stop engine please wait *******\n"));
         }
         break;
 
         case PVAE_CMD_RESET:
         {
             ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
+            if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
+            {
+                iAuthor->Reset((OsclAny*)iAuthor);
+            }
         }
         break;
 
@@ -591,14 +635,14 @@
         }
         break;
 
-        case PVAE_CMD_QUERY_INTERFACE2:
+
         case PVAE_CMD_ADD_DATA_SINK:
         case PVAE_CMD_REMOVE_DATA_SINK:
             break;
 
         case PVAE_CMD_RECORDING:
         {
-            iState = PVAE_CMD_STOP;
+            iState = PVAE_CMD_RESET;
             RunIfNotReady(iTestDuration);
         }
         break;
@@ -617,9 +661,17 @@
     if (aResponse.GetCmdStatus() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_generic_reset::CommandCompleted iState:%d FAILED", iState));
+                        (0, "pv_mediainput_async_test_errorhandling::CommandCompleted iState:%d FAILED", iState));
     }
 
+    /* This check is done in order to verify that the response from the engine
+       is for the current command or for any other previously issued asynchronous command
+    */
+    if (iCheckState != iState) // Current command and the response state doesn't match
+    {
+//		fprintf(iFile, "ERROR: The current state and the response's state doesn't match *******\n");
+        return;
+    }
     switch (iState)
     {
         case PVAE_CMD_OPEN:
@@ -670,10 +722,9 @@
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                                     (0, "pv_mediainput_async_test_errorhandling::CommandCompleted: Error - ConfigComposer failed"));
 
-                    PVPATB_TEST_IS_TRUE(false);
+                    PVPATB_TEST_IS_TRUE(true);
                     iState = PVAE_CMD_RESET;
                     RunIfNotReady();
-                    return;
                 }
                 else
                 {
@@ -721,12 +772,43 @@
         {
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                iState = PVAE_CMD_START;
+                iState = PVAE_CMD_QUERY_INTERFACE_COMP;
                 RunIfNotReady();
             }
             else
             {
                 // Init failed
+                PVPATB_TEST_IS_TRUE(true);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+        case PVAE_CMD_QUERY_INTERFACE_COMP:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                ConfigMp4Composer();
+                iState = PVAE_CMD_QUERY_INTERFACE1;
+                RunIfNotReady();
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+        case PVAE_CMD_QUERY_INTERFACE1:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = PVAE_CMD_CAPCONFIG_SYNC1;
+                RunIfNotReady();
+            }
+            else
+            {
                 PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
@@ -741,7 +823,7 @@
                 if (iPauseResumeEnable)
                 {
                     iState = PVAE_CMD_PAUSE;
-                    RunIfNotReady(KPauseDuration); //Pause after 5 sec
+                    RunIfNotReady();
                 }
                 else
                 {
@@ -752,7 +834,15 @@
             else
             {
                 // Start failed
-                PVPATB_TEST_IS_TRUE(false);
+                if (ErrorHandling_MediaInputNodeStopFailed != iTestErrorType)
+                {
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                }
+
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
             }
@@ -769,8 +859,21 @@
             }
             else
             {
-                //Pause failed
-                PVPATB_TEST_IS_TRUE(false);
+                // Pause failed
+                if ((ErrorHandling_MediaInputNode_StateFailure_EPause_SendMIORequest == iTestErrorType) ||
+                        (ErrorHandling_MediaInputNode_Node_Cmd_Pause == iTestErrorType)	||
+                        (ErrorHandling_MP4Composer_Node_Cmd_Pause == iTestErrorType) ||
+                        (ErrorHandling_VideoEncodeNode_Node_Cmd_Pause == iTestErrorType) ||
+                        (ErrorHandling_AudioEncodeNode_Node_Cmd_Pause == iTestErrorType) ||
+                        (ErrorHandling_AVCEncodeNode_Node_Cmd_Pause == iTestErrorType))
+                {
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    //Pause failed
+                    PVPATB_TEST_IS_TRUE(false);
+                }
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
             }
@@ -789,6 +892,7 @@
             else
             {
                 //Resume failed
+                Cancel();
                 PVPATB_TEST_IS_TRUE(false);
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
@@ -807,7 +911,16 @@
             else
             {
                 // Stop failed
-                PVPATB_TEST_IS_TRUE(false);
+                if (ErrorHandling_MediaInputNodeStopFailed == iTestErrorType)
+
+                {
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                }
+
                 iState = PVAE_CMD_RESET;
                 RunIfNotReady();
             }
@@ -827,6 +940,7 @@
                     else
                     {
                         PVPATB_TEST_IS_TRUE(false);
+
                     }
                     //Since there are no MIO Components/Nodes, we end here
                     //No need to call RemoveDataSource
@@ -836,12 +950,26 @@
 
                 iState = PVAE_CMD_REMOVE_DATA_SOURCE;
                 RunIfNotReady();
+
             }
             else
             {
-                // Reset failed
-                PVPATB_TEST_IS_TRUE(false);
-                iObserver->CompleteTest(*iTestCase);
+                if ((ErrorHandling_VideoEncodeNode_Node_Cmd_Stop == iTestErrorType) ||
+                        (ErrorHandling_AudioEncodeNode_Node_Cmd_Stop == iTestErrorType) ||
+                        (ErrorHandling_AVCEncodeNode_Node_Cmd_Stop == iTestErrorType) ||
+                        (ErrorHandling_MediaInputNode_Node_Cmd_Stop == iTestErrorType) ||
+                        (ErrorHandling_MediaInputNodeStopFailed == iTestErrorType))
+                {
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    // Reset failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
+                    iState = PVAE_CMD_REMOVE_DATA_SOURCE;
+                    RunIfNotReady();
+                }
             }
         }
         break;
@@ -852,24 +980,7 @@
             {
                 if (EngineCmdComplete())
                 {
-                    iOutputFileName = NULL;
-                    iMIOComponent.DeleteInputNode();
-                    if (PVMF_AVIFF == iMediaInputType)
-                    {
-                        PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
-                        PVAviFile::DeleteAviFileParser(fileparser);
-                        fileparser = NULL;
-                        iFileParser = NULL;
-                    }
-                    else if (PVMF_WAVFF == iMediaInputType)
-                    {
-                        PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
-                        delete(fileparser);
-                        fileparser = NULL;
-                        iFileParser = NULL;
-                    }
-
-                    iFileParser = NULL;
+                    RemoveMIOComp();
                     iState = PVAE_CMD_CLOSE;
                     RunIfNotReady();
 
@@ -883,6 +994,7 @@
             {
                 // RemoveDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
+                RemoveMIOComp();
                 iObserver->CompleteTest(*iTestCase);
             }
         }
@@ -912,3 +1024,441 @@
     }  //end switch
 }
 
+void pv_mediainput_async_test_errorhandling::RemoveMIOComp()
+{
+    iOutputFileName = NULL;
+    iMIOComponent.DeleteInputNode();
+    if (iMediaInputType == PVMF_MIME_AVIFF)
+    {
+        PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
+        PVAviFile::DeleteAviFileParser(fileparser);
+        fileparser = NULL;
+        iFileParser = NULL;
+    }
+    else if (iMediaInputType == PVMF_MIME_WAVFF)
+    {
+        PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
+        delete(fileparser);
+        fileparser = NULL;
+        iFileParser = NULL;
+    }
+
+    iFileParser = NULL;
+}
+
+bool pv_mediainput_async_test_errorhandling::CapConfigSync1()
+{
+    // set the mime strings here
+    // capabilty and configuration feature implemented here
+    // set the config parameters using MIME strings here
+
+    OSCL_StackString<64> paramkey;
+    // KVP array
+    PvmiKvp paramkvp;
+    paramkvp.value.bool_value = true;
+    key_type* key = NULL;
+    key = (key_type*)oscl_malloc(sizeof(key_type));
+    if (ErrorHandling_VideoInitFailed == iTestErrorType) //To fail VideoEncNode Initialize
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error_start_init;valtype=bool");
+    }
+    else if (ErrorHandling_ComposerAddFragFailed == iTestErrorType)  //To fail Mp4ComposerNode on AddMemFragToTrack
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error_start_addmemfrag;valtype=bool");
+    }
+    else if (ErrorHandling_ComposerAddTrackFailed == iTestErrorType)  //To fail Mp4ComposerNode on AddTrack
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error_start_addtrack;valtype=bool");
+    }
+    else if (ErrorHandling_MediaInputNodeStartFailed == iTestErrorType)  //To fail MediaInputNode on Start
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error_adddatasource_start;valtype=bool");
+    }
+    else if (ErrorHandling_MediaInputNodeStopFailed == iTestErrorType)  //To fail MediaInputNode on Stop
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error_adddatasource_stop;valtype=bool");
+    }
+    else if (ErrorHandling_AudioInitFailed == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error_start_init;valtype=bool");
+    }
+    else if ((ErrorHandling_AVCVideoEncodeFailed == iTestErrorType))			          //To fail AVCEncNode on Encode
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-encode;mode=frames;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+
+    }
+    else if (ErrorHandling_VideoEncodeFailed == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-encode;mode=frames;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+
+    }
+    else if (ErrorHandling_AudioEncodeFailed == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-encode;mode=frames;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+
+    }
+    else if ((ErrorHandling_AVCVideoEncode5FramesFailed == iTestErrorType))		//To fail AVCEncNode on Encode 5 frames
+
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-encode;mode=frames;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+    }
+    else if (ErrorHandling_VideoEncode5FramesFailed == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-encode;mode=frames;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+
+    }
+    else if (ErrorHandling_MediaInputNode_NoMemBuffer == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error_no_memorybuffer_avaliable;valtype=bool");
+    }
+    else if (ErrorHandling_MediaInputNode_Out_Queue_busy == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error_out_queue_busy;valtype=bool");
+    }
+    else if (ErrorHandling_MediaInputNode_large_time_stamp == iTestErrorType)
+    {
+
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-time-stamp;valtype=ksv");
+
+        uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
+
+        key->mode = 1;
+        key->duration = 0;
+        key->track_no = numStreams - 1;
+
+        paramkvp.value.key_specific_value = OSCL_DYNAMIC_CAST(void*, key);
+    }
+    else if (ErrorHandling_MediaInputNode_wrong_time_stamp_after_duration == iTestErrorType)
+    {
+
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-time-stamp;valtype=ksv");
+
+        uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
+
+        key->mode = 2;
+        key->duration = 60;
+        key->track_no = numStreams - 1;
+
+        paramkvp.value.key_specific_value = OSCL_DYNAMIC_CAST(void*, key);
+    }
+
+    else if (ErrorHandling_MediaInputNode_zero_time_stamp == iTestErrorType)
+    {
+
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-time-stamp;valtype=ksv");
+
+        uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
+
+        key->mode = 3;
+        key->duration = 0;
+        key->track_no = numStreams - 1;
+
+        paramkvp.value.key_specific_value = OSCL_DYNAMIC_CAST(void*, key);
+    }
+
+    else if (ErrorHandling_MediaInputNode_StateFailure_EPause_SendMIORequest == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-sendmiorequest;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+        iPauseResumeEnable = true;
+    }
+    else if (ErrorHandling_MediaInputNode_StateFailure_CancelMIORequest == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-cancelmiorequest;valtype=bool");
+    }
+    else if (ErrorHandling_MediaInputNode_Corrupt_Video_InputData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-corruptinputdata;index=0;valtype=uint32");
+        paramkvp.value.uint32_value = 100;
+    }
+    else if (ErrorHandling_MediaInputNode_Corrupt_Audio_InputData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-corruptinputdata;index=1;valtype=uint32");
+        paramkvp.value.uint32_value = 100;
+    }
+    else if (ErrorHandling_MediaInputNode_Node_Cmd_Start  == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+    }
+    else if (ErrorHandling_MediaInputNode_Node_Cmd_Stop  == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 3;
+    }
+    else if (ErrorHandling_MediaInputNode_Node_Cmd_Flush  == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 4;
+    }
+    else if (ErrorHandling_MediaInputNode_Node_Cmd_Pause  == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+        iPauseResumeEnable = true;
+    }
+    else if (ErrorHandling_MediaInputNode_Node_Cmd_ReleasePort  == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 7;
+    }
+    else if (ErrorHandling_MediaInputNode_DataPath_Stall == iTestErrorType)
+    {
+        uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
+        paramkey = _STRLIT_CHAR("x-pvmf/datasource/error-data-path-stall;valtype=uint32");
+        if (numStreams > 0)
+        {
+            paramkvp.value.uint32_value = numStreams - 1;
+        }
+        else
+        {
+            paramkvp.value.uint32_value = numStreams;
+        }
+
+    }
+    else if (ErrorHandling_MP4Composer_AddTrack_PVMF_AMR_IETF == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addtrack;valtype=char*");
+        OSCL_HeapString<OsclMemAllocator> mode1 = "PVMF_AMR_IETF";
+        paramkvp.value.pChar_value = mode1.get_str();
+    }
+    else if (ErrorHandling_MP4Composer_AddTrack_PVMF_3GPP_TIMEDTEXT == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addtrack;valtype=char*");
+        OSCL_HeapString<OsclMemAllocator> mode2 = "PVMF_3GPP_TIMEDTEXT";
+        paramkvp.value.pChar_value = mode2.get_str();
+    }
+
+    else if (ErrorHandling_MP4Composer_AddTrack_PVMF_M4V == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addtrack;valtype=char*");
+        OSCL_HeapString<OsclMemAllocator> mode3 = "PVMF_M4V";
+        paramkvp.value.pChar_value = mode3.get_str();
+    }
+
+    else if (ErrorHandling_MP4Composer_AddTrack_PVMF_H263 == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addtrack;valtype=char*");
+        OSCL_HeapString<OsclMemAllocator> mode4 = "PVMF_H263";
+        paramkvp.value.pChar_value = mode4.get_str();
+    }
+    else if (ErrorHandling_MP4Composer_AddTrack_PVMF_H264_MP4 == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addtrack;valtype=char*");
+        OSCL_HeapString<OsclMemAllocator> mode5 = "PVMF_H264_MP4";
+        paramkvp.value.pChar_value = mode5.get_str();
+    }
+    else if (ErrorHandling_MP4Composer_Node_Cmd_Start == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+    }
+    else if (ErrorHandling_MP4Composer_Node_Cmd_Stop == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 3;
+    }
+    else if (ErrorHandling_MP4Composer_Node_Cmd_Flush == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 4;
+    }
+    else if (ErrorHandling_MP4Composer_Node_Cmd_Pause == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+        iPauseResumeEnable = true;
+    }
+    else if (ErrorHandling_MP4Composer_Node_Cmd_ReleasePort == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 7;
+    }
+
+    else if (ErrorHandling_MP4Composer_Create_FileParser == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-create-composer;valtype=bool");
+    }
+    else if (ErrorHandling_MP4Composer_RenderToFile == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-render-to-file;valtype=bool");
+    }
+    else if (ErrorHandling_MP4Composer_FailAfter_FileSize == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addsample;mode=filesize;valtype=uint32"); //shorten the key to fit in buffer
+        paramkvp.value.uint32_value = 5000;
+    }
+    else if (ErrorHandling_MP4Composer_FailAfter_Duration == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/error-addsample;mode=duration;valtype=uint32");
+        paramkvp.value.uint32_value = 500;
+    }
+    else if (ErrorHandling_MP4Composer_DataPathStall == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/composer/mp4/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+    }
+    else if (ErrorHandling_VideoEncodeNode_Node_Cmd_Start == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+    }
+    else if (ErrorHandling_VideoEncodeNode_Node_Cmd_Stop == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 3;
+    }
+    else if (ErrorHandling_VideoEncodeNode_Node_Cmd_Flush == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 4;
+    }
+    else if (ErrorHandling_VideoEncodeNode_Node_Cmd_Pause == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+        iPauseResumeEnable = true;
+    }
+    else if (ErrorHandling_VideoEncodeNode_Node_Cmd_ReleasePort == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32;");
+        paramkvp.value.uint32_value = 7;
+    }
+    else if (ErrorHandling_VideoEncodeNode_ConfigHeader == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-config-header;valtype=bool");
+    }
+    else if (ErrorHandling_VideoEncodeNode_DataPathStall_Before_ProcessingData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+    }
+    else if (ErrorHandling_VideoEncodeNode_DataPathStall_After_ProcessingData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+    }
+    else if (ErrorHandling_VideoEncodeNode_FailEncode_AfterDuration == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-encode;mode=duration;valtype=uint32");
+        paramkvp.value.uint32_value = 300;
+    }
+    else if (ErrorHandling_AudioEncodeNode_Node_Cmd_Start == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+
+    }
+    else if (ErrorHandling_AudioEncodeNode_Node_Cmd_Stop == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 3;
+
+    }
+    else if (ErrorHandling_AudioEncodeNode_Node_Cmd_Flush == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 4;
+
+    }
+    else if (ErrorHandling_AudioEncodeNode_Node_Cmd_Pause == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+        iPauseResumeEnable = true;
+
+    }
+    else if (ErrorHandling_AudioEncodeNode_Node_Cmd_ReleasePort == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 7;
+
+    }
+
+    else if (ErrorHandling_AudioEncodeNode_FailEncode_AfterDuration == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/error-encode;mode=duration;valtype=uint32");
+        paramkvp.value.uint32_value = 700;
+    }
+    else if (ErrorHandling_AudioEncodeNode_DataPathStall_Before_ProcessingData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+    }
+
+    else if (ErrorHandling_AudioEncodeNode_DataPathStall_After_ProcessingData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/audio/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+    }
+    else if (ErrorHandling_AVCEncodeNode_Node_Cmd_Start == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+
+    }
+    else if (ErrorHandling_AVCEncodeNode_Node_Cmd_Stop == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 3;
+
+    }
+    else if (ErrorHandling_AVCEncodeNode_Node_Cmd_Flush == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 4;
+
+    }
+    else if (ErrorHandling_AVCEncodeNode_Node_Cmd_Pause == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 5;
+        iPauseResumeEnable = true;
+
+    }
+    else if (ErrorHandling_AVCEncodeNode_Node_Cmd_ReleasePort == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-node-cmd;index=2;valtype=uint32");
+        paramkvp.value.uint32_value = 7;
+
+    }
+    else if (ErrorHandling_AVCEncodeNode_ConfigHeader == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-config-header;valtype=bool");
+    }
+    else if (ErrorHandling_AVCEncodeNode_DataPathStall_Before_ProcessingData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 1;
+    }
+    else if (ErrorHandling_AVCEncodeNode_DataPathStall_After_ProcessingData == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/data-path-stall;valtype=uint32");
+        paramkvp.value.uint32_value = 2;
+    }
+    else if (ErrorHandling_AVCEncodeNode_FailEncode_AfterDuration == iTestErrorType)
+    {
+        paramkey = _STRLIT_CHAR("x-pvmf/encoder/video/error-encode;mode=duration;valtype=uint32");
+        paramkvp.value.uint32_value = 100;
+    }
+    paramkvp.key = paramkey.get_str();
+
+    // set the value in node using SetParameterSync f(n) here
+    iAuthorCapConfigIF->setParametersSync(NULL, &paramkvp, 1, iErrorKVP);
+    oscl_free(key);
+    return true;
+}
+
+void pv_mediainput_async_test_errorhandling::ConfigMp4Composer()
+{
+    PvmfComposerSizeAndDurationInterface* config =
+        OSCL_REINTERPRET_CAST(PvmfComposerSizeAndDurationInterface*, iOutputSizeAndDurationConfig);
+
+    config->SetFileSizeProgressReport(true, KFileSizeProgressFreq);
+
+}
diff --git a/engines/author/test/src/test_pv_author_engine_testset6.h b/engines/author/test/src/test_pv_author_engine_testset6.h
index 8164f62..649f7bd 100644
--- a/engines/author/test/src/test_pv_author_engine_testset6.h
+++ b/engines/author/test/src/test_pv_author_engine_testset6.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@
 class pv_mediainput_async_test_errorhandling: public pvauthor_async_test_base
 {
     public:
-        pv_mediainput_async_test_errorhandling(PVAuthorAsyncTestParam aTestParam, PVMediaInputTestParam aMediaParam, bool aPauseResumeEnable, bool aWrongFormat)
+        pv_mediainput_async_test_errorhandling(PVAuthorAsyncTestParam aTestParam, PVMediaInputTestParam aMediaParam, bool aPauseResumeEnable, uint32 aTestErrorType)
                 : pvauthor_async_test_base(aTestParam)
                 , iOutputFileName(NULL)
                 , iInputFileName(NULL)
@@ -46,7 +46,7 @@
                 , iRemoveDataSourceDone(0)
                 , iAddAudioMediaTrack(false)
                 , iAddVideoMediaTrack(false)
-                , iWrongFormat(aWrongFormat)
+                , iTestErrorType(aTestErrorType)
 
         {
             iLogger = PVLogger::GetLoggerObject("pv_mediainput_async_test_errorhandling");
@@ -82,7 +82,7 @@
         void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
         void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
         void CommandCompleted(const PVCmdResponse& aResponse);
-
+        void ConfigMp4Composer();
         PVAECmdType iState;
         // Test output
         OSCL_wHeapString<OsclMemAllocator> iOutputFileName;
@@ -95,6 +95,13 @@
         //test input type
         PVMFFormatType  iMediaInputType;
 
+        typedef struct ts_keytype
+        {
+            uint8 mode;
+            uint32 duration;
+            uint32 track_no;
+        }key_type;
+
     private:
         // Methods to create test input nodes and add to author engine
         bool CreateTestInputs();
@@ -114,6 +121,8 @@
         void ResetAuthorConfig();
 
         void Cleanup();
+        void RemoveMIOComp();
+        bool CapConfigSync1();
 
         void AddEngineCommand()
         {
@@ -158,8 +167,15 @@
         uint32                   iTestDuration;
         bool					 iAddAudioMediaTrack;
         bool					 iAddVideoMediaTrack;
-        bool					 iWrongFormat;
         Oscl_FileServer          iFileServer;
+        uint32					 iTestErrorType;
+        PvmiCapabilityAndConfig* iAuthorCapConfigIF;
+        PvmiCapabilityAndConfig* iAuthorCapConfigIF1;
+        PvmiMIOControl*			 iMediaIOControl;
+        PvmiKvp* iErrorKVP;
+        FILE*	                 iFile;
+        PVInterface*             iOutputSizeAndDurationConfig;
+        PVAECmdType				 iCheckState;
 };
 
 #endif
diff --git a/engines/author/test/src/test_pv_author_engine_testset7.cpp b/engines/author/test/src/test_pv_author_engine_testset7.cpp
index a8ce3f2..ab84e17 100644
--- a/engines/author/test/src/test_pv_author_engine_testset7.cpp
+++ b/engines/author/test/src/test_pv_author_engine_testset7.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,9 +58,45 @@
 ////////////////////////////////////////////////////////////////////////////
 void pv_mediainput_async_test_reset::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    OSCL_UNUSED_ARG(aEvent);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "pv_mediainput_async_test_reset::HandleInformationalEvent"));
+    OsclAny* eventData = NULL;
+    switch (aEvent.GetEventType())
+    {
+        case PVMF_COMPOSER_MAXFILESIZE_REACHED:
+        case PVMF_COMPOSER_MAXDURATION_REACHED:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pv_mediainput_async_test_reset::HandleNodeInformationalEvent: Max file size reached"));
+            Cancel();
+            PVPATB_TEST_IS_TRUE(true);
+            iObserver->CompleteTest(*iTestCase);
+            break;
+
+        case PVMF_COMPOSER_DURATION_PROGRESS:
+            aEvent.GetEventData(eventData);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pv_mediainput_async_test_reset::HandleNodeInformationalEvent: Duration progress: %d ms",
+                             (int32)eventData));
+            break;
+
+        case PVMF_COMPOSER_FILESIZE_PROGRESS:
+            aEvent.GetEventData(eventData);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pv_mediainput_async_test_reset::HandleNodeInformationalEvent: File size progress: %d bytes",
+                             (int32)eventData));
+            break;
+
+        case PVMF_COMPOSER_EOS_REACHED:
+            //Engine already stopped at EOS so send reset command.
+            iState = PVAE_CMD_RESET;
+            //cancel recording timeout scheduled for timer object.
+            Cancel();
+            RunIfNotReady();
+            break;
+
+        default:
+            break;
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -71,7 +107,7 @@
     iFileParser = NULL;
     iFileServer.Connect();
 
-    if (PVMF_AVIFF == iMediaInputType)
+    if (iMediaInputType == PVMF_MIME_AVIFF)
     {
         OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(iInputFileName, error, &iFileServer););
 
@@ -107,7 +143,7 @@
         }
 
     }
-    else if (PVMF_WAVFF == iMediaInputType)
+    else if (iMediaInputType == PVMF_MIME_WAVFF)
     {
         OSCL_TRY(error, iFileParser = OSCL_NEW(PV_Wav_Parser, ()););
         if (error || (NULL == iFileParser))
@@ -132,8 +168,6 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                             (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - CreateMIOInputNode failed"));
 
-            //delete any MIO Comp created.
-            MIOComp.DeleteInputNode();
             goto ERROR_CODE;
 
         }
@@ -152,14 +186,14 @@
 ERROR_CODE:
     {
         //remove file parser
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
             PVAviFile::DeleteAviFileParser(fileparser);
             fileparser = NULL;
             iFileParser = NULL;
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
             delete(fileparser);
@@ -175,25 +209,25 @@
 bool pv_mediainput_async_test_reset::AddDataSource()
 {
     int32 err = 0;
-    uint32 ii = 0;
     uint32 noOfNodes = iMIOComponent.iMIONode.size();
 
-    for (ii = 0; ii < noOfNodes; ii++)
-    {
-        AddEngineCommand();
+    OSCL_TRY(err,
+             for (uint32 ii = 0; ii < noOfNodes; ii++)
+{
+    AddEngineCommand();
 
-        OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor););
-
-        if (err != OSCL_ERR_NONE)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
-
-            iMIOComponent.DeleteInputNode();
-            return false;
-        }
+        //OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor););
+        iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
     }
+            );
+    if (err != OSCL_ERR_NONE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
 
+        iMIOComponent.DeleteInputNode();
+        return false;
+    }
     return true;
 }
 
@@ -266,15 +300,20 @@
     OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("copyright");
     OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("description");
     OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("rating");
+    OSCL_wHeapString<OsclMemAllocator> iAlbumTitle = _STRLIT("albumtitle");
+    uint16 iRecordingYear = 2008;
+    OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
 
     clipConfig->SetOutputFileName(iOutputFileName);
     clipConfig->SetPresentationTimescale(1000);
-    clipConfig->SetVersion(versionString);
-    clipConfig->SetTitle(titleString);
-    clipConfig->SetAuthor(authorString);
-    clipConfig->SetCopyright(copyrightString);
-    clipConfig->SetDescription(descriptionString);
-    clipConfig->SetRating(ratingString);
+    clipConfig->SetVersion(versionString, lang_code);
+    clipConfig->SetTitle(titleString, lang_code);
+    clipConfig->SetAuthor(authorString, lang_code);
+    clipConfig->SetCopyright(copyrightString, lang_code);
+    clipConfig->SetDescription(descriptionString, lang_code);
+    clipConfig->SetRating(ratingString, lang_code);
+    clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
+    clipConfig->SetRecordingYear(iRecordingYear);
 
 
     return true;
@@ -287,7 +326,7 @@
 
     if (iAddAudioMediaTrack)
     {
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             Oscl_Vector<uint32, OsclMemAllocator> audioStrNum;
 
@@ -304,7 +343,7 @@
             AddEngineCommand();
 
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             PVWAVFileInfo wavFileInfo;
             (iMIOComponent.iPVWavFile)->RetrieveFileInfo(wavFileInfo);
@@ -326,7 +365,7 @@
 
     if (iAddVideoMediaTrack)
     {
-        if (PVMF_AVIFF == iMediaInputType)
+        if (iMediaInputType == PVMF_MIME_AVIFF)
         {
             Oscl_Vector<uint32, OsclMemAllocator> vidStrNum;
             vidStrNum = (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
@@ -342,7 +381,7 @@
             AddEngineCommand();
 
         }
-        else if (PVMF_WAVFF == iMediaInputType)
+        else if (iMediaInputType == PVMF_MIME_WAVFF)
         {
             return false;
         }
@@ -368,10 +407,10 @@
 
     uint32 width = 0;
     uint32 height = 0;
-    uint32 frameRate = 0;
+    OsclFloat frameRate = 0;
     uint32 frameInterval = 0;
 
-    if (PVMF_AVIFF == iMediaInputType)
+    if (iMediaInputType == PVMF_MIME_AVIFF)
     {
         Oscl_Vector<uint32, OsclMemAllocator> vidStrNum =
             (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
@@ -379,7 +418,7 @@
         width = (iMIOComponent.iPVAviFile)->GetWidth(vidStrNum[0]);
         bool orient = false;
         height = (iMIOComponent.iPVAviFile)->GetHeight(orient, vidStrNum[0]);
-        frameRate = (uint32)(iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
+        frameRate = (iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
         frameInterval = (iMIOComponent.iPVAviFile)->GetFrameDuration();
 
     }
@@ -388,7 +427,8 @@
     config->SetOutputBitRate(0, KVideoBitrate);
     config->SetOutputFrameSize(0, width , height);
     config->SetOutputFrameRate(0, frameRate);
-    config->SetIFrameInterval(frameInterval);
+    config->SetIFrameInterval(KVideoIFrameInterval);
+    config->SetSceneDetection(true);
 
     return true;
 }
@@ -458,8 +498,18 @@
             }
             else
             {
-                iState = PVAE_CMD_OPEN;
-                RunIfNotReady();
+                if (PVAE_CMD_CREATE == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_OPEN;
+                    iState = PVAE_CMD_RESET;
+                    PVPATB_TEST_IS_TRUE(true);
+                    RunIfNotReady();
+                }
+                else
+                {
+                    iState = PVAE_CMD_OPEN;
+                    RunIfNotReady();
+                }
             }
         }
         break;
@@ -532,7 +582,17 @@
         case PVAE_CMD_RESET:
         {
             ResetAuthorConfig();
-            iAuthor->Reset((OsclAny*)iAuthor);
+            if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
+            {
+                iAuthor->Reset((OsclAny*)iAuthor);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "pv_mediainput_async_test_opencomposestop::PVAE_CMD_RESET - State PVAE_STATE_IDLE"));
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
         }
         break;
 
@@ -608,7 +668,7 @@
     if (aResponse.GetCmdStatus() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "pvauthor_async_test_generic_reset::CommandCompleted iState:%d FAILED", iState));
+                        (0, "pv_mediainput_async_test_reset::CommandCompleted iState:%d FAILED", iState));
     }
 
     switch (iState)
@@ -900,8 +960,9 @@
                         PVPATB_TEST_IS_TRUE(false);
                     }
                     //Since there are no MIO Components/Nodes, we end here
-                    //No need to call RemoveDataSource
-                    iObserver->CompleteTest(*iTestCase);
+                    //No need to call RemoveDataSource. Just call cleanup.
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                     break;
                 }
 
@@ -910,9 +971,20 @@
             }
             else
             {
-                // Reset failed
-                PVPATB_TEST_IS_TRUE(false);
-                iObserver->CompleteTest(*iTestCase);
+                if (PVAE_CMD_CREATE == iCurrentResetState)
+                {
+                    //Reset in create state will return error.
+                    PVPATB_TEST_IS_TRUE(true);
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    // Reset failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
+                    iObserver->CompleteTest(*iTestCase);
+                }
             }
         }
         break;
@@ -925,14 +997,14 @@
                 {
                     iOutputFileName = NULL;
                     iMIOComponent.DeleteInputNode();
-                    if (PVMF_AVIFF == iMediaInputType)
+                    if (iMediaInputType == PVMF_MIME_AVIFF)
                     {
                         PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
                         PVAviFile::DeleteAviFileParser(fileparser);
                         fileparser = NULL;
                         iFileParser = NULL;
                     }
-                    else if (PVMF_WAVFF == iMediaInputType)
+                    else if (iMediaInputType == PVMF_MIME_WAVFF)
                     {
                         PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
                         delete(fileparser);
diff --git a/engines/author/test/src/test_pv_author_engine_testset7.h b/engines/author/test/src/test_pv_author_engine_testset7.h
index 2286a49..7420091 100644
--- a/engines/author/test/src/test_pv_author_engine_testset7.h
+++ b/engines/author/test/src/test_pv_author_engine_testset7.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,7 +70,11 @@
             }
 
 
-            if (PVAE_CMD_OPEN == iCurrentResetState)
+            if (PVAE_CMD_CREATE == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_OPEN;
+            }
+            else if (PVAE_CMD_OPEN == iCurrentResetState)
             {
                 iNextResetState = PVAE_CMD_ADD_DATA_SOURCE;
             }
diff --git a/engines/author/test/src/test_pv_author_engine_testset8.cpp b/engines/author/test/src/test_pv_author_engine_testset8.cpp
new file mode 100644
index 0000000..7024608
--- /dev/null
+++ b/engines/author/test/src/test_pv_author_engine_testset8.cpp
@@ -0,0 +1,1072 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET7_H_INCLUDED
+#include "test_pv_author_engine_testset8.h"
+#endif
+
+#ifndef PVMF_COMPOSER_SIZE_AND_DURATION_H_INCLUDED
+#include "pvmf_composer_size_and_duration.h"
+#endif
+
+#ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
+#include "pvmf_fileoutput_config.h"
+#endif
+
+#ifndef PVMP4FFCN_CLIPCONFIG_H_INCLUDED
+#include "pvmp4ffcn_clipconfig.h"
+#endif
+
+#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+#include "pvmp4h263encextension.h"
+#endif
+
+#ifndef PVAETEST_NODE_CONFIG_H_INCLUDED
+#include "pvaetest_node_config.h"
+#endif
+
+void pv_mediainput_async_test_delete::StartTest()
+{
+    AddToScheduler();
+    iState = PVAE_CMD_CREATE;
+    RunIfNotReady();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void pv_mediainput_async_test_delete::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+{
+    OSCL_UNUSED_ARG(aEvent);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "pv_mediainput_async_test_delete::HandleErrorEvent"));
+    iState = PVAE_CMD_RESET;
+    RunIfNotReady();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void pv_mediainput_async_test_delete::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "pv_mediainput_async_test_delete::HandleInformationalEvent"));
+    OsclAny* eventData = NULL;
+    switch (aEvent.GetEventType())
+    {
+        case PVMF_COMPOSER_MAXFILESIZE_REACHED:
+        case PVMF_COMPOSER_MAXDURATION_REACHED:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pv_mediainput_async_test_delete::HandleNodeInformationalEvent: Max file size reached"));
+            Cancel();
+            PVPATB_TEST_IS_TRUE(true);
+            iObserver->CompleteTest(*iTestCase);
+            break;
+
+        case PVMF_COMPOSER_DURATION_PROGRESS:
+            aEvent.GetEventData(eventData);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pv_mediainput_async_test_delete::HandleNodeInformationalEvent: Duration progress: %d ms",
+                             (int32)eventData));
+            break;
+
+        case PVMF_COMPOSER_FILESIZE_PROGRESS:
+            aEvent.GetEventData(eventData);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "pv_mediainput_async_test_delete::HandleNodeInformationalEvent: File size progress: %d bytes",
+                             (int32)eventData));
+            break;
+
+        case PVMF_COMPOSER_EOS_REACHED:
+            //Engine already stopped at EOS so send reset command.
+            iState = PVAE_CMD_RESET;
+            //cancel recording timeout scheduled for timer object.
+            Cancel();
+            RunIfNotReady();
+            break;
+
+        default:
+            break;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::CreateTestInputs()
+{
+    int32 status = 0;
+    int32 error = 0;
+    iFileParser = NULL;
+    iFileServer.Connect();
+
+    if (iMediaInputType == PVMF_MIME_AVIFF)
+    {
+        OSCL_TRY(error, iFileParser = PVAviFile::CreateAviFileParser(iInputFileName, error, &iFileServer););
+
+        if (error || (NULL == iFileParser))
+        {
+            if (iFileParser)
+            {
+                goto ERROR_CODE;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        uint32 numStreams = ((PVAviFile*)iFileParser)->GetNumStreams();
+
+        iAddAudioMediaTrack = false;
+        iAddVideoMediaTrack = false;
+
+        for (uint32 ii = 0; ii < numStreams; ii++)
+        {
+            if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "audio"))
+            {
+                iAddAudioMediaTrack = true;
+            }
+
+            if (oscl_strstr(((PVAviFile*)iFileParser)->GetStreamMimeType(ii).get_cstr(), "video"))
+            {
+                iAddVideoMediaTrack = true;
+            }
+
+        }
+
+    }
+    if (iMediaInputType == PVMF_MIME_WAVFF)
+    {
+        OSCL_TRY(error, iFileParser = OSCL_NEW(PV_Wav_Parser, ()););
+        if (error || (NULL == iFileParser))
+        {
+            return false;
+        }
+        if (((PV_Wav_Parser*)iFileParser)->InitWavParser(iInputFileName, NULL) != PVWAVPARSER_OK)
+        {
+            goto ERROR_CODE;
+        }
+
+        iAddAudioMediaTrack = true;
+        iAddVideoMediaTrack = false;
+    }
+
+    {
+        PVMIOControlComp MIOComp(iMediaInputType, (OsclAny*)iFileParser, 0);
+
+        status = MIOComp.CreateMIOInputNode(false, iMediaInputType, iInputFileName);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                            (0, "pv_mediainput_async_test_opencomposestop::CreateTestInputs: Error - CreateMIOInputNode failed"));
+
+            goto ERROR_CODE;
+
+        }
+
+        iMIOComponent = MIOComp;
+        if (!AddDataSource())
+        {
+            //delete any MIO Comp created.
+            MIOComp.DeleteInputNode();
+            goto ERROR_CODE;
+        }
+
+        return true;
+    }
+
+ERROR_CODE:
+    {
+        //remove file parser
+        if (iMediaInputType == PVMF_MIME_AVIFF)
+        {
+            PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
+            PVAviFile::DeleteAviFileParser(fileparser);
+            fileparser = NULL;
+            iFileParser = NULL;
+        }
+        if (iMediaInputType == PVMF_MIME_WAVFF)
+        {
+            PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
+            delete(fileparser);
+            fileparser = NULL;
+            iFileParser = NULL;
+        }
+
+        return false;
+    }
+
+}
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::AddDataSource()
+{
+    int32 err = 0;
+    uint32 noOfNodes = iMIOComponent.iMIONode.size();
+
+    OSCL_TRY(err,
+             for (uint32 ii = 0; ii < noOfNodes; ii++)
+{
+    AddEngineCommand();
+
+        //OSCL_TRY(err, iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor););
+        iAuthor->AddDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
+    }
+            );
+    if (err != OSCL_ERR_NONE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "pvauthor_async_test_miscellaneous::AddDataSource: Error - iAuthor->AddDataSource failed. err=0x%x", err));
+
+        iMIOComponent.DeleteInputNode();
+        return false;
+    }
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::ConfigComposer()
+{
+    if (!ConfigOutputFile())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "pv_mediainput_async_test_delete::ConfigComposer: Error - ConfigOutputFile failed"));
+
+        return false;
+    }
+
+    if ((oscl_strstr(iComposerMimeType.get_str(), "mp4")) || (oscl_strstr(iComposerMimeType.get_str(), "3gp")))
+    {
+        if (!ConfigMp43gpComposer())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "pv_mediainput_async_test_delete::ConfigComposer: Error - ConfigMp43gpComposer failed"));
+
+            return false;
+        }
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::ConfigOutputFile()
+{
+
+    PvmfFileOutputNodeConfigInterface* clipConfig = OSCL_STATIC_CAST(PvmfFileOutputNodeConfigInterface*, iComposerConfig);
+    if (!clipConfig)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "pv_mediainput_async_test_delete::ConfigOutputFile: Error - Invalid iComposerConfig"));
+
+        return false;
+    }
+
+    if (clipConfig->SetOutputFileName(iOutputFileName) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "pv_mediainput_async_test_delete::ConfigOutputFile: Error - SetOutputFileName failed"));
+
+        return false;
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::ConfigMp43gpComposer()
+{
+
+    PVMp4FFCNClipConfigInterface* clipConfig;
+    clipConfig = OSCL_STATIC_CAST(PVMp4FFCNClipConfigInterface*, iComposerConfig);
+    if (!clipConfig)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "pv_mediainput_async_test_delete::ConfigMp43gpComposer: Error - iComposerConfig==NULL"));
+
+        return false;
+    }
+
+    OSCL_wHeapString<OsclMemAllocator> versionString = _STRLIT("version");
+    OSCL_wHeapString<OsclMemAllocator> titleString = _STRLIT("title");
+    OSCL_wHeapString<OsclMemAllocator> authorString = _STRLIT("author");
+    OSCL_wHeapString<OsclMemAllocator> copyrightString = _STRLIT("copyright");
+    OSCL_wHeapString<OsclMemAllocator> descriptionString = _STRLIT("description");
+    OSCL_wHeapString<OsclMemAllocator> ratingString = _STRLIT("rating");
+    OSCL_wHeapString<OsclMemAllocator> iAlbumTitle = _STRLIT("albumtitle");
+    uint16 iRecordingYear = 2008;
+    OSCL_HeapString<OsclMemAllocator> lang_code = "eng";
+
+    clipConfig->SetOutputFileName(iOutputFileName);
+    clipConfig->SetPresentationTimescale(1000);
+    clipConfig->SetVersion(versionString, lang_code);
+    clipConfig->SetTitle(titleString, lang_code);
+    clipConfig->SetAuthor(authorString, lang_code);
+    clipConfig->SetCopyright(copyrightString, lang_code);
+    clipConfig->SetDescription(descriptionString, lang_code);
+    clipConfig->SetRating(ratingString, lang_code);
+    clipConfig->SetAlbumInfo(iAlbumTitle, lang_code);
+    clipConfig->SetRecordingYear(iRecordingYear);
+
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::AddMediaTrack()
+{
+    PVMIOControlComp MIOComp;
+
+    if (iAddAudioMediaTrack)
+    {
+        if (iMediaInputType == PVMF_MIME_AVIFF)
+        {
+            Oscl_Vector<uint32, OsclMemAllocator> audioStrNum;
+
+            audioStrNum = (iMIOComponent.iPVAviFile)->GetAudioStreamCountList();
+
+            if (audioStrNum.size() == 0)
+            {
+                return false;
+            }
+
+            iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[audioStrNum[0]]), iAudioEncoderMimeType,
+                                   iComposer, iAudioEncoderConfig, (OsclAny*)iAuthor);
+
+            AddEngineCommand();
+
+        }
+        if (iMediaInputType == PVMF_MIME_WAVFF)
+        {
+            PVWAVFileInfo wavFileInfo;
+            (iMIOComponent.iPVWavFile)->RetrieveFileInfo(wavFileInfo);
+
+
+            iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[0]), iAudioEncoderMimeType,
+                                   iComposer, iAudioEncoderConfig, (OsclAny*)iAuthor);
+
+            AddEngineCommand();
+
+
+        }
+
+        if (!PVAETestNodeConfig::ConfigureAudioEncoder(iAudioEncoderConfig))
+        {
+            return false;
+        }
+    }
+
+    if (iAddVideoMediaTrack)
+    {
+        if (iMediaInputType == PVMF_MIME_AVIFF)
+        {
+            Oscl_Vector<uint32, OsclMemAllocator> vidStrNum;
+            vidStrNum = (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
+
+            if (vidStrNum.size() == 0)
+            {
+                return false;
+            }
+
+            iAuthor->AddMediaTrack(*(iMIOComponent.iMIONode[vidStrNum[0]]), iVideoEncoderMimeType,
+                                   iComposer, iVideoEncoderConfig, (OsclAny*)iAuthor);
+
+            AddEngineCommand();
+
+        }
+        if (iMediaInputType == PVMF_MIME_WAVFF)
+        {
+            return false;
+        }
+
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool pv_mediainput_async_test_delete::ConfigureVideoEncoder()
+{
+
+    PVMp4H263EncExtensionInterface* config;
+    config = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, iVideoEncoderConfig);
+    if (!config)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "pv_mediainput_async_test_delete::ConfigureVideoEncoder: No configuration needed"));
+
+        return true;
+    }
+
+    uint32 width = 0;
+    uint32 height = 0;
+    OsclFloat frameRate = 0;
+    uint32 frameInterval = 0;
+
+    if (iMediaInputType == PVMF_MIME_AVIFF)
+    {
+        Oscl_Vector<uint32, OsclMemAllocator> vidStrNum =
+            (iMIOComponent.iPVAviFile)->GetVideoStreamCountList();
+
+        width = (iMIOComponent.iPVAviFile)->GetWidth(vidStrNum[0]);
+        bool orient = false;
+        height = (iMIOComponent.iPVAviFile)->GetHeight(orient, vidStrNum[0]);
+        frameRate = (iMIOComponent.iPVAviFile)->GetFrameRate(vidStrNum[0]);
+        frameInterval = (iMIOComponent.iPVAviFile)->GetFrameDuration();
+
+    }
+
+    config->SetNumLayers(KNumLayers);
+    config->SetOutputBitRate(0, KVideoBitrate);
+    config->SetOutputFrameSize(0, width , height);
+    config->SetOutputFrameRate(0, frameRate);
+    config->SetIFrameInterval(KVideoIFrameInterval);
+    config->SetSceneDetection(true);
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void pv_mediainput_async_test_delete::ResetAuthorConfig()
+{
+    if (iComposerConfig)
+    {
+        iComposerConfig->removeRef();
+        iComposerConfig = NULL;
+    }
+    if (iAudioEncoderConfig)
+    {
+        iAudioEncoderConfig->removeRef();
+        iAudioEncoderConfig = NULL;
+    }
+    if (iVideoEncoderConfig)
+    {
+        iVideoEncoderConfig->removeRef();
+        iVideoEncoderConfig = NULL;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void pv_mediainput_async_test_delete::Cleanup()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "pv_mediainput_async_test_delete::Cleanup"));
+
+    iComposer = NULL;
+
+    ResetAuthorConfig();
+    if (iAuthor)
+    {
+        PVAuthorEngineFactory::DeleteAuthor(iAuthor);
+        iAuthor = NULL;
+    }
+
+    iOutputFileName = NULL;
+    iMIOComponent.DeleteInputNode();
+    if (iMediaInputType == PVMF_MIME_AVIFF)
+    {
+        PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
+        PVAviFile::DeleteAviFileParser(fileparser);
+        fileparser = NULL;
+        iFileParser = NULL;
+    }
+    if (iMediaInputType == PVMF_MIME_WAVFF)
+    {
+        PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
+        delete(fileparser);
+        fileparser = NULL;
+        iFileParser = NULL;
+    }
+    iFileParser = NULL;
+
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void pv_mediainput_async_test_delete::Run()
+{
+    if (IsEngineCmdPending())
+    {
+        return;
+    }
+
+    switch (iState)
+    {
+        case PVAE_CMD_CREATE:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "******pv_mediainput_async_test_delete::iTestCaseNum:%d******", iTestCaseNum));
+
+            iAuthor = PVAuthorEngineFactory::CreateAuthor(this, this, this);
+            if (!iAuthor)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+
+            }
+            else
+            {
+                if (PVAE_CMD_CREATE == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_OPEN;
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    PVPATB_TEST_IS_TRUE(true);
+                    RunIfNotReady();
+                }
+                else
+                {
+                    iState = PVAE_CMD_OPEN;
+                    RunIfNotReady();
+                }
+            }
+        }
+        break;
+
+        case PVAE_CMD_OPEN:
+        {
+            iAuthor->Open((OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_ADD_DATA_SOURCE:
+        {
+            bool aStatus = CreateTestInputs();
+            if (aStatus == 0) //Failed while creating test input
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "pv_mediainput_async_test_delete::CreateTestInputs: Error - failed"));
+
+                PVPATB_TEST_IS_TRUE(true); //expected to come here
+
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+
+                RunIfNotReady();
+            }
+
+        }
+        break;
+
+        case PVAE_CMD_SELECT_COMPOSER:
+        {
+            iAuthor->SelectComposer(iComposerMimeType, iComposerConfig,
+                                    (OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_ADD_MEDIA_TRACK:
+        {
+            if (!AddMediaTrack())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "pv_mediainput_async_test_opencomposestop::AddMediaTrack Error - No track added"));
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_REMOVE_DATA_SOURCE;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_INIT:
+        {
+            iAuthor->Init((OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_START:
+        {
+            iAuthor->Start();
+        }
+        break;
+
+        case PVAE_CMD_STOP:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                            (0, "pv_mediainput_async_test_delete::Run: Command Stop"));
+
+            iAuthor->Stop((OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_RESET:
+        {
+            ResetAuthorConfig();
+            if (iAuthor->GetPVAuthorState() != PVAE_STATE_IDLE)
+            {
+                iAuthor->Reset((OsclAny*)iAuthor);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "pv_mediainput_async_test_opencomposestop::PVAE_CMD_RESET - State PVAE_STATE_IDLE"));
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_REMOVE_DATA_SOURCE:
+        {
+            for (uint32 ii = 0; ii < iMIOComponent.iMIONode.size(); ii++)
+            {
+                iAuthor->RemoveDataSource(*(iMIOComponent.iMIONode[ii]), (OsclAny*)iAuthor);
+                AddEngineCommand();
+            }
+        }
+        break;
+
+        case PVAE_CMD_CLOSE:
+        {
+            iAuthor->Close((OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_PAUSE:
+        {
+            iAuthor->Pause((OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_RESUME:
+        {
+            iAuthor->Resume((OsclAny*)iAuthor);
+        }
+        break;
+
+        case PVAE_CMD_CLEANUPANDCOMPLETE:
+        {
+            Cleanup();
+            iObserver->CompleteTest(*iTestCase);
+        }
+        break;
+
+        case PVAE_CMD_QUERY_INTERFACE2:
+        case PVAE_CMD_ADD_DATA_SINK:
+        case PVAE_CMD_REMOVE_DATA_SINK:
+            break;
+
+        case PVAE_CMD_RECORDING:
+        {
+            if (PVAE_CMD_RECORDING == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_STOP;
+                iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                PVPATB_TEST_IS_TRUE(true);
+                RunIfNotReady();
+            }
+            else
+            {
+                iState = PVAE_CMD_STOP;
+                RunIfNotReady(iTestDuration);
+            }
+
+        }
+        break;
+
+        default:
+            break;
+    } //end switch
+}
+
+////////////////////////////////////////////////////////////////////////////
+void pv_mediainput_async_test_delete::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "pv_mediainput_async_test_delete::CommandCompleted iState:%d", iState));
+
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "pv_mediainput_async_test_delete::CommandCompleted iState:%d FAILED", iState));
+    }
+
+    switch (iState)
+    {
+        case PVAE_CMD_OPEN:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (PVAE_CMD_OPEN == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_ADD_DATA_SOURCE;
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    iState = PVAE_CMD_ADD_DATA_SOURCE;
+                }
+
+                RunIfNotReady();
+            }
+            else
+            {
+                // Open failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_ADD_DATA_SOURCE:
+        {
+            if (EngineCmdComplete())
+            {
+                if (PVAE_CMD_ADD_DATA_SOURCE == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_SELECT_COMPOSER;
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    iState = PVAE_CMD_SELECT_COMPOSER;
+                }
+            }
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSource failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_SELECT_COMPOSER:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iComposer = aResponse.GetResponseData();
+                if (!ConfigComposer())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "pv_mediainput_async_test_delete::CommandCompleted: Error - ConfigComposer failed"));
+
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = PVAE_CMD_RESET;
+                    RunIfNotReady();
+                    return;
+                }
+                else
+                {
+                    if (PVAE_CMD_SELECT_COMPOSER == iCurrentResetState)
+                    {
+                        iNextResetState = PVAE_CMD_ADD_MEDIA_TRACK;
+                        iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                        PVPATB_TEST_IS_TRUE(true);
+                    }
+                    else
+                    {
+                        iState = PVAE_CMD_ADD_MEDIA_TRACK;
+                    }
+
+                    RunIfNotReady();
+                }
+            }
+            else
+            {
+                // SelectComposer failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_ADD_MEDIA_TRACK:
+        {
+            if (EngineCmdComplete())
+            {
+                if (iAddVideoMediaTrack)
+                {
+                    ConfigureVideoEncoder();
+                }
+
+                if (PVAE_CMD_ADD_MEDIA_TRACK == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_INIT;
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    iState = PVAE_CMD_INIT;
+                }
+
+            }
+
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddMediaTrack failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_INIT:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (PVAE_CMD_INIT == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_START;
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    PVPATB_TEST_IS_TRUE(true);
+                }
+                else
+                {
+                    iState = PVAE_CMD_START;
+                }
+
+                RunIfNotReady();
+            }
+            else
+            {
+                // Init failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_START:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iPauseResumeEnable)
+                {
+                    if (PVAE_CMD_START == iCurrentResetState)
+                    {
+                        iNextResetState = PVAE_CMD_PAUSE;
+                        iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                        PVPATB_TEST_IS_TRUE(true);
+                    }
+                    else
+                    {
+                        iState = PVAE_CMD_PAUSE;
+                    }
+
+                    RunIfNotReady(KPauseDuration); //Pause after 5 sec
+                }
+                else
+                {
+                    if (PVAE_CMD_START == iCurrentResetState)
+                    {
+                        iNextResetState = PVAE_CMD_RECORDING;
+                        iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                        PVPATB_TEST_IS_TRUE(true);
+                    }
+                    else
+                    {
+                        iState = PVAE_CMD_RECORDING;
+                    }
+
+                    RunIfNotReady();
+                }
+            }
+            else
+            {
+                // Start failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_PAUSE:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (PVAE_CMD_PAUSE == iCurrentResetState)
+                {
+                    iNextResetState = PVAE_CMD_STOP;
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    PVPATB_TEST_IS_TRUE(true);
+                    RunIfNotReady();
+                }
+                else
+                {
+                    iState = PVAE_CMD_RESUME;
+                    /* Stay paused for 10 seconds */
+                    RunIfNotReady(10*1000*1000);
+                }
+
+            }
+            else
+            {
+                //Pause failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_RESUME:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = PVAE_CMD_STOP;
+                iNextResetState = PVAE_CMD_STOP;
+                //Run for another 10 sec before stopping
+                RunIfNotReady(10*1000*1000);
+            }
+            else
+            {
+                //Resume failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_STOP:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iOutputFileName = NULL;
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Stop failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = PVAE_CMD_RESET;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case PVAE_CMD_RESET:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if ((iMIOComponent.iMediaInput.size() == 0) || (iMIOComponent.iMIONode.size() == 0))
+                {
+                    if (aResponse.GetCmdStatus() == PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(true);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    //Since there are no MIO Components/Nodes, we end here
+                    //No need to call RemoveDataSource. Just call cleanup.
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                    break;
+                }
+
+                iState = PVAE_CMD_REMOVE_DATA_SOURCE;
+                RunIfNotReady();
+            }
+            else
+            {
+                if (PVAE_CMD_CREATE == iCurrentResetState)
+                {
+                    //Reset in create state will return error.
+                    PVPATB_TEST_IS_TRUE(true);
+                    iState = PVAE_CMD_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    // Reset failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    OSCL_ASSERT("ERROR -- Response failure for CMD_RESET");
+                    iObserver->CompleteTest(*iTestCase);
+                }
+            }
+        }
+        break;
+
+        case PVAE_CMD_REMOVE_DATA_SOURCE:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (EngineCmdComplete())
+                {
+                    iOutputFileName = NULL;
+                    iMIOComponent.DeleteInputNode();
+                    if (iMediaInputType == PVMF_MIME_AVIFF)
+                    {
+                        PVAviFile* fileparser = OSCL_STATIC_CAST(PVAviFile*, iFileParser);
+                        PVAviFile::DeleteAviFileParser(fileparser);
+                        fileparser = NULL;
+                        iFileParser = NULL;
+                    }
+                    if (iMediaInputType == PVMF_MIME_WAVFF)
+                    {
+                        PV_Wav_Parser* fileparser = OSCL_STATIC_CAST(PV_Wav_Parser*, iFileParser);
+                        delete(fileparser);
+                        fileparser = NULL;
+                        iFileParser = NULL;
+                    }
+
+                    iFileParser = NULL;
+                    iState = PVAE_CMD_CLOSE;
+                    RunIfNotReady();
+
+                }
+                else
+                {
+                    return; //wait for completion of all RemoveDataSource calls.
+                }
+            }
+            else
+            {
+                // RemoveDataSource failed
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->CompleteTest(*iTestCase);
+            }
+        }
+        break;
+
+        case PVAE_CMD_CLOSE:
+        {
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                PVPATB_TEST_IS_TRUE(true);
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(false);
+            }
+            iObserver->CompleteTest(*iTestCase);
+        }
+        break;
+
+        default:
+        {
+            // Testing error if this is reached
+            PVPATB_TEST_IS_TRUE(false);
+            iObserver->CompleteTest(*iTestCase);
+        }
+        break;
+    }  //end switch
+}
+
diff --git a/engines/author/test/src/test_pv_author_engine_testset8.h b/engines/author/test/src/test_pv_author_engine_testset8.h
new file mode 100644
index 0000000..2307809
--- /dev/null
+++ b/engines/author/test/src/test_pv_author_engine_testset8.h
@@ -0,0 +1,214 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET8_H_INCLUDED
+#define TEST_PV_AUTHOR_ENGINE_TESTSET8_H_INCLUDED
+
+#ifndef TEST_PV_MEDIAINPUT_AUTHOR_ENGINE_H
+#include "test_pv_mediainput_author_engine.h"
+#endif
+
+#define PVPATB_TEST_IS_TRUE( condition ) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
+
+class pv_mediainput_async_test_delete: public pvauthor_async_test_base
+{
+    public:
+        pv_mediainput_async_test_delete(PVAuthorAsyncTestParam aTestParam, PVMediaInputTestParam aMediaParam, bool aPauseResumeEnable, PVAECmdType aResetState)
+                : pvauthor_async_test_base(aTestParam)
+                , iOutputFileName(NULL)
+                , iInputFileName(NULL)
+                , iComposerMimeType(aMediaParam.iComposerInfo)
+                , iAudioEncoderMimeType(aMediaParam.iAudioEncInfo)
+                , iVideoEncoderMimeType(aMediaParam.iVideoEncInfo)
+                , iMediaInputType(aMediaParam.iInputFormat)
+                , iAuthor(NULL)
+                , iComposer(NULL)
+                , iFileParser(NULL)
+                , iComposerConfig(NULL)
+                , iAudioEncoderConfig(NULL)
+                , iVideoEncoderConfig(NULL)
+                , iPendingCmds(0)
+                , iPauseResumeEnable(aPauseResumeEnable)
+                , iRemoveDataSourceDone(0)
+                , iAddAudioMediaTrack(false)
+                , iAddVideoMediaTrack(false)
+                , iCurrentResetState(aResetState)
+
+
+        {
+            iLogger = PVLogger::GetLoggerObject("pv_mediainput_async_test_delete");
+
+            iTestDuration = KTestDuration * 1000 * 1000;
+
+            if (oscl_strlen(aMediaParam.iIPFileInfo.get_cstr()) != 0)
+            {
+                oscl_wchar output2[ARRAY_SIZE];
+                oscl_UTF8ToUnicode(aMediaParam.iIPFileInfo.get_cstr(), oscl_strlen(aMediaParam.iIPFileInfo.get_cstr()), output2, ARRAY_SIZE);
+                iInputFileName.set(output2, oscl_strlen(output2));
+
+            }
+
+            if (oscl_strlen(aMediaParam.iOPFileInfo.get_cstr()) != 0)
+            {
+                oscl_wchar output1[ARRAY_SIZE];
+                oscl_UTF8ToUnicode(aMediaParam.iOPFileInfo.get_cstr(), oscl_strlen(aMediaParam.iOPFileInfo.get_cstr()), output1, ARRAY_SIZE);
+                iOutputFileName.set(output1, oscl_strlen(output1));
+            }
+
+
+            if (PVAE_CMD_CREATE == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_OPEN;
+            }
+            else if (PVAE_CMD_OPEN == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_ADD_DATA_SOURCE;
+            }
+            else if (PVAE_CMD_ADD_DATA_SOURCE == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_SELECT_COMPOSER;
+            }
+            else if (PVAE_CMD_SELECT_COMPOSER == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_ADD_MEDIA_TRACK;
+            }
+            else if (PVAE_CMD_ADD_MEDIA_TRACK == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_INIT;
+            }
+            else if (PVAE_CMD_INIT == iCurrentResetState)
+            {
+                iNextResetState = PVAE_CMD_START;
+            }
+            else if (PVAE_CMD_START == iCurrentResetState)
+            {
+                if (iPauseResumeEnable)
+                {
+                    iNextResetState = PVAE_CMD_PAUSE;
+                }
+                else
+                {
+                    iNextResetState = PVAE_CMD_RECORDING;
+                }
+            }
+            else if ((PVAE_CMD_PAUSE == iCurrentResetState) || (PVAE_CMD_RECORDING == iCurrentResetState))
+            {
+                iNextResetState = PVAE_CMD_STOP;
+            }
+
+
+        }
+
+        ~pv_mediainput_async_test_delete()
+        {
+            Cleanup();
+        }
+
+        void Run();
+        void StartTest();
+
+        // Author engine observer functions
+        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+        void CommandCompleted(const PVCmdResponse& aResponse);
+
+        PVAECmdType iState;
+        // Test output
+        OSCL_wHeapString<OsclMemAllocator> iOutputFileName;
+        OSCL_wHeapString<OsclMemAllocator> iInputFileName;
+
+        OSCL_HeapString<OsclMemAllocator> iComposerMimeType;
+        OSCL_HeapString<OsclMemAllocator> iAudioEncoderMimeType;
+        OSCL_HeapString<OsclMemAllocator> iVideoEncoderMimeType;
+
+        //test input type
+        PVMFFormatType  iMediaInputType;
+
+        PVAECmdType GetNextResetState()
+        {
+            return iNextResetState;
+        }
+
+    private:
+        // Methods to create test input nodes and add to author engine
+        bool CreateTestInputs();
+        bool AddDataSource();
+
+        // Methods to configure composers
+        bool ConfigComposer();
+        bool ConfigOutputFile();
+        bool ConfigMp43gpComposer();
+
+        // Methods to add media tracks
+        bool AddMediaTrack();
+
+        // Methods to configure encoders
+        bool ConfigureVideoEncoder();
+
+        void ResetAuthorConfig();
+
+        void Cleanup();
+
+        void AddEngineCommand()
+        {
+            iPendingCmds++;
+        }
+
+        bool EngineCmdComplete()
+        {
+            if (iPendingCmds > 0)
+            {
+                --iPendingCmds;
+            }
+
+            if (iPendingCmds == 0)
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        bool IsEngineCmdPending()
+        {
+            if (iPendingCmds > 0)
+                return true;
+            else
+                return false;
+        }
+
+        // Author engine related variables
+        PVAuthorEngineInterface* iAuthor;
+        OsclAny*				 iComposer;
+        OsclAny*				 iFileParser;
+        PVInterface*			 iComposerConfig;
+        PVInterface*			 iAudioEncoderConfig;
+        PVInterface*			 iVideoEncoderConfig;
+        PVMIOControlComp		 iMIOComponent;
+        uint32					 iPendingCmds;
+        PVLogger*                iLogger;
+        bool                     iPauseResumeEnable;
+        uint                     iRemoveDataSourceDone;
+        uint32                   iTestDuration;
+        bool					 iAddAudioMediaTrack;
+        bool					 iAddVideoMediaTrack;
+        PVAECmdType				 iNextResetState;
+        PVAECmdType			     iCurrentResetState;
+        Oscl_FileServer          iFileServer;
+};
+
+#endif
diff --git a/engines/author/test/src/test_pv_author_engine_typedefs.h b/engines/author/test/src/test_pv_author_engine_typedefs.h
index b3cdc48..1863051 100644
--- a/engines/author/test/src/test_pv_author_engine_typedefs.h
+++ b/engines/author/test/src/test_pv_author_engine_typedefs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,9 +24,6 @@
 #ifndef OSCL_ERROR_H_INCLUDED
 #include "oscl_error.h"
 #endif
-#ifndef OSCL_ERROR_PANIC_H_INCLUDED
-#include "oscl_error_panic.h"
-#endif
 #ifndef OSCL_ERROR_CODES_H_INCLUDED
 #include "oscl_error_codes.h"
 #endif
@@ -141,8 +138,13 @@
 #include "oscl_utf8conv.h"
 #endif
 
+#ifndef PVAELOGGER_H_INCLUDED
+#include "test_pv_author_engine_logger.h"
+#endif
+
+//#define _W(x) _STRLIT_WCHAR(x)
+
 //composer mime type
-#define KMp4ComposerMimeType "/x-pvmf/ff-mux/mp4"
 #define K3gpComposerMimeType "/x-pvmf/ff-mux/3gp"
 #define KAMRNbComposerMimeType		"/x-pvmf/ff-mux/amr-nb"
 #define KAACADIFComposerMimeType	"/x-pvmf/ff-mux/adif"
@@ -202,144 +204,228 @@
 //enum types for test cases
 typedef enum
 {
+    ERROR_NOSTATE = 0,
+    ERROR_VIDEO_START_INIT,
+    ERROR_VIDEO_START_ENCODE,
+    ERROR_VIDEO_START_ENCODE_5FRAMES,
+    ERROR_COMPOSER_START_ADDMEMFRAG,
+    ERROR_COMPOSER_START_ADDTRACK,
+    ERROR_MEDIAINPUTNODE_ADDDATASOURCE_START,
+    ERROR_MEDIAINPUTNODE_ADDDATASOURCE_STOP,
+    ERROR_AVC_START_ENCODE,
+    ERROR_AVC_START_ENCODE_5FRAMES
+}FAIL_STATE;
+
+
+typedef enum
+{
+
+    /*********** Compressed Tests Begin****************************/
+    // Tests that take compressed inputs
     //3gp output file
-    AMR_Input_AOnly_3gpTest = 0, //.amr
-    YUV_Input_VOnly_3gpTest, //.yuv
-    H263_Input_VOnly_3gpTest, //.h263
-    AMR_YUV_Input_AV_3gpTest, //.amr+.yuv
-    AMR_H263_Input_AV_3gpTest, //.amr+.h263
-    PCM16_Input_AOnly_3gpTest,//5 //.pcm
-    PCM16_YUV_Input_AV_3gpTest, //.pcm+.yuv
-    KMaxFileSizeTest, //.amr+.yuv
-    KMaxDurationTest, //.amr+.yuv
-    KFileSizeProgressTest, //.amr+.yuv
-    KDurationProgressTest, //10 //.amr+.yuv
-    KFastTrackContentModeTest, //.amr+.yuv
-    K3GPPDownloadModeTest, //.amr+.yuv
-    K3GPPProgressiveDownloadModeTest,//.amr+.yuv
-    KMovieFragmentModeTest, // 16 //.amr+.yuv
+    AMR_Input_AOnly_3gpTest = 0,					//.amr
+    H263_Input_VOnly_3gpTest,						//.h263
+    AMR_YUV_Input_AV_3gpTest,						//.amr+.yuv
+    AMR_H263_Input_AV_3gpTest,						//.amr+.h263
 
-    K3GP_OUTPUT_TestEnd, //17 placeholder
-    //mp4 output file
-    //H264 Encoding, no need for 3gp file test, the composerMimeType is mapped to same uuid
-    H264_Input_VOnly_Mp4Test, //18 //.yuv
-    H264_AMR_Input_AV_Mp4Test, //19 //.yuv
-    AMR_Input_AOnly_Mp4Test, //20 //.amr
-    YUV_Input_VOnly_Mp4Test, //.yuv
-    AMR_YUV_Input_AV_Mp4Test, //.amr+.yuv
-
-    TEXT_Input_TOnly_Mp4Test,//23
-    AMR_TEXT_Input_AT_Mp4Test,
-    YUV_TEXT_Input_VT_Mp4Test,
+    H264_AMR_Input_AV_3gpTest,						//4 //.yuv
+    AMR_YUV_Input_AV_M4V_AMR_Output_3gpTest,						//.amr+.yuv
+    TEXT_Input_TOnly_3gpTest,						//6
+    AMR_TEXT_Input_AT_3gpTest,
+    YUV_TEXT_Input_VT_3gpTest,
     AMR_YUV_TEXT_Input_AVT_Mp4Test,
 
-    PCM16_Input_AOnly_Mp4Test, //27 //.pcm
-    PCM16_YUV_Input_AV_Mp4Test, //.pcm+.yuv
-
-    MP4_OUTPUT_TestEnd, //29 placeholder
+    K3GP_OUTPUT_TestEnd,							//10 placeholder
 
     //amr output file
-    AMR_FOutput_Test, //30 //.amr
-    PCM16In_AMROut_Test,  //.pcm
+    AMR_FOutput_Test,								//11 //.amr
 
-    AMR_OUTPUT_TestEnd, //32 // placeholder
+    AMR_OUTPUT_TestEnd,								//12 // placeholder
 
     //aac output file
-    AACADIF_FOutput_Test,  //.aacadif
-    AACADTS_FOutput_Test,  //.aacadts
+    AACADIF_FOutput_Test,							//.aacadif
+    AACADTS_FOutput_Test,							//.aacadts
 
-    AAC_OUTPUT_TestEnd, //35 // placeholder
+    AAC_OUTPUT_TestEnd,								//15 // placeholder
 
-    Pause_Resume_Test, //36
-    //To Test Error Handling scenarios
-    //The incorrect paths are hardcoded in test
-    ErrorHandling_WrongVideoInputFileNameTest, //37 //Incorrect name of Video input file
-    ErrorHandling_WrongAudioInputFileNameTest,//Incorrect name of Audio input file
-    ErrorHandling_WrongTextInputFileNameTest,//Incorrect name of Text input file
-    ErrorHandling_WrongOutputPathTest, //Incorrect path of output file
-    ErrorHandling_WrongInputFormatTest, //Unsupported input format say RGB16
+    //ErrorHandling_WrongTextInputFileNameTest,		//Incorrect name of Text input file
 
-    //m4v type file not supported currently due to non availability of VOL Hdr size
-    //M4V_Input_VOnly_Mp4Test, //.m4v
-    //AMR_M4V_Input_AV_Mp4Test, //.amr+.m4v
-    NormalTestEnd, //placeholder
+    CompressedNormalTestEnd,						//placeholder
 
-    GenericTestBegin = 60,	// generic tests start here
-    Generic_Open_Reset_Test,
-    Generic_AddDataSource_Audio_Reset_Test,
-    Generic_AddDataSource_Video_Reset_Test,
-    Generic_AddDataSource_Text_Reset_Test,
-    Generic_SelectComposer_Reset_Test,//65
-    Generic_QueryInterface_Reset_Test,
-    Generic_Add_Audio_Media_Track_Reset_Test,
-    Generic_Add_Video_Media_Track_Reset_Test,
-    Generic_Add_Text_Media_Track_Reset_Test,
-    Generic_Init_Reset_Test, //70
-    Generic_Start_Reset_Test,
-    Generic_Pause_Reset_Test,
-    Generic_Resume_Reset_Test,
-    Input_Stream_Looping_Test,
-    CapConfigTest,
-    GenericTestEnd, //76 Generic tests end here placeholder
-
-
-    LongetivityTestBegin = 80, // longetivity tests start here //placeholder
+    /*********** Compressed Longetivity Tests *********************/
+    // tests that takes compressed inputs and run for long duration
+    // The duration is configurable through command line argument
+    CompressedLongetivityTestBegin = 100,			//placeholder
     //3gp output file
-    AMR_Input_AOnly_3gp_LongetivityTest,  //.amr
-    YUV_Input_VOnly_3gp_LongetivityTest, //.yuv
-    H263_Input_VOnly_3gp_LongetivityTest, //.h263
-    TEXT_Input_TOnly_3gp_LongetivityTest,  //.txt
-    AMR_YUV_Input_AV_3gp_LongetivityTest, //85 s//.amr+.yuv
-    AMR_H263_Input_AV_3gp_LongetivityTest,  //.amr+.h263
-    AMR_TEXT_Input_AT_3gp_LongetivityTest,  //.amr+.txt
-    PCM16_Input_AOnly_3gp_LongetivityTest, //.pcm
-    PCM16_YUV_Input_AV_3gp_LongetivityTest, //.pcm+.yuv
-    YUV_TEXT_Input_VT_3gp_LongetivityTest, //90 //.txt+.yuv
-    AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest, //.txt+.yuv +.amr
-    KMaxFileSizeLongetivityTest, //.amr+.yuv
-    KMaxDurationLongetivityTest, //.amr+.yuv
-    KFileSizeProgressLongetivityTest,  //.amr+.yuv
-    KDurationProgressLongetivityTest, //95  //.amr+.yuv
-    KFastTrackContentModeLongetivityTest, //.amr+.yuv
-    K3GPPDownloadModeLongetivityTest, //.amr+.yuv
-    K3GPPProgressiveDownloadModeLongetivityTest,  //.amr+.yuv
+    TEXT_Input_TOnly_3gp_LongetivityTest,			//.txt
+    AMR_TEXT_Input_AT_3gp_LongetivityTest,			//.amr+.txt
+    YUV_TEXT_Input_VT_3gp_LongetivityTest,			//103 //.txt+.yuv
+    AMR_YUV_TEXT_Input_AVT_3gp_LongetivityTest,		//.txt+.yuv +.amr
+    Compressed_LongetivityTestEnd,					//105 placeholder
 
-    K3GP_OUTPUT_LongetivityTestEnd, //101 placeholder
+    /*********** Compressed Tests End******************************/
 
-    //mp4 output file
-    //H264 Encoding, no need for 3gp file test, the composerMimeType is mapped to same uuid
-    H264_Input_VOnly_Mp4_LongetivityTest, //102 //.yuv
-    H264_AMR_Input_AV_Mp4_LongetivityTest,  //.yuv
-    AMR_Input_AOnly_Mp4_LongetivityTest,  //.amr
-    YUV_Input_VOnly_Mp4_LongetivityTest, //105 //.yuv
-    AMR_YUV_Input_AV_Mp4_LongetivityTest, //.amr+.yuv
-    PCM16_Input_AOnly_Mp4_LongetivityTest, //.pcm
-    PCM16_YUV_Input_AV_Mp4_LongetivityTest, //.pcm+.yuv
+    /*********** UnCompressed Tests Begin**************************/
+    // Test case that takes Uncompressed input through AVI File begin
 
-    MP4_OUTPUT_LongetivityTestEnd,  //109 placeholder
+    // AVI file must have RGB24, RGB12, YUV420 planar or PCM mono 8KHz data only
+    UnCompressed_NormalTestBegin = 200,				//placeholder
+    PVMediaInput_Open_Compose_Stop_Test  ,			//Use testinput.avi
+    PVMediaInput_Open_RealTimeCompose_Stop_Test,	//Real Time authoring
 
-    //amr output file
-    AMR_FOutput_LongetivityTest, //110 //.amr
-    PCM16In_AMROut_LongetivityTest,  //.pcm
+    YUV_Input_VOnly_3gpTest,						//.yuv
+    PCM16_Input_AOnly_3gpTest,						//204 //.pcm
+    PCM16_YUV_Input_AV_3gpTest,						//205 //.pcm+.yuv
+    H264_Input_VOnly_3gpTest,						//.yuv
+    PCM16In_AMROut_Test,							//.pcm//207
 
-    AMR_OUTPUT_LongetivityTestEnd, // placeholder
+    KMaxFileSizeTest,								//.amr+.yuv
 
-    //aac output file
-    AACADIF_FOutput_LongetivityTest,  //.aacadif
-    AACADTS_FOutput_LongetivityTest,  //.aacadts
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+    KIMotionAuthoringModeTest,						//.amr+.yuv
+#endif
+    K3GPPDownloadModeTest,							//.amr+.yuv
+    K3GPPProgressiveDownloadModeTest,				//.amr+.yuv
 
-    AAC_OUTPUT_LongetivityTestEnd, // longetivity tests end here //placeholder
-    // AVI Test Starts
-    // AVI file must have RGB24, RGB12 or PCM mono 8KHz data only
-    PVMediaInput_Open_Compose_Stop_Test, //116 //Use testinput.avi from vob test_content\avi
-    PVMediaInput_Open_RealTimeCompose_Stop_Test, //Real Time authoring
-    PVMediaInput_Pause_Resume_Test, //avi //Use testinput.avi from vob test_content\avi
-    PVMediaInput_ErrorHandling_Test_WrongFormat, //Use testinput_rgb16.avi from test_content\avi
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+    KIMotionDownloadModeTest,						//.amr+.yuv
+#endif
+    KMovieFragmentModeTest,
+    CapConfigTest,									//218
+
+    PVMediaInput_Pause_Resume_Test,//219
+
+    PVMediaInput_Reset_After_Create_Test,//220
+    PVMediaInput_Reset_After_Open_Test,//221
+    PVMediaInput_Reset_After_AddDataSource_Test,//222
+    PVMediaInput_Reset_After_SelectComposer_Test,//223
+    PVMediaInput_Reset_After_AddMediaTrack_Test,//224
+    PVMediaInput_Reset_After_Init_Test,//225
+    PVMediaInput_Reset_After_Start_Test,//226
+    PVMediaInput_Reset_After_Pause_Test,//227
+    PVMediaInput_Reset_After_Recording_Test,//228
+    PVMediaInput_Reset_After_Stop_Test,//229
+
+    PVMediaInput_Delete_After_Create_Test,//230
+    PVMediaInput_Delete_After_Open_Test,//231
+    PVMediaInput_Delete_After_AddDataSource_Test,//232
+    PVMediaInput_Delete_After_SelectComposer_Test,//233
+    PVMediaInput_Delete_After_AddMediaTrack_Test,//234
+    PVMediaInput_Delete_After_Init_Test,//235
+    PVMediaInput_Delete_After_Start_Test,//236
+    PVMediaInput_Delete_After_Pause_Test,//237
+    PVMediaInput_Delete_After_Recording_Test,//238
+    PVMediaInput_Delete_After_Stop_Test,//239
+
+    UnCompressed_NormalTestEnd,
+
+    /********** Uncompressed Longetivity tests*********************/
+    UnCompressed_LongetivityTestBegin = 300,		//placeholder
+    AVI_Input_Longetivity_Test,						//301
+    KMaxFileSizeLongetivityTest,					//.amr+.yuv/302
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+    KIMotionAuthoringModeLongetivityTest,			//.amr+.yuv
+#endif
+    K3GPPDownloadModeLongetivityTest,				//.amr+.yuv
+    K3GPPProgressiveDownloadModeLongetivityTest,    //.amr+.yuv
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+    KIMotionDownloadModeLongetivityTest,			//307 //.amr+.yuv
+#endif
+    KMovieFragmentModeLongetivityTest,				//308
+    UnCompressed_LongetivityTestEnd,
+
+    /*********** UnCompressed Tests End****************************/
+
+    /*********** Error Handling Tests Begin************************/
+
+    // Error Handling tests. These are to test the error handling capability of Author Engine.
+    // Some of the tests takes unsupported inputs like RGB16 data (PVMediaInput_ErrorHandling_Test_WrongFormat).
+    // Other tests deliberately induces errors at various points in the data path. The error point is send through
+    // KVP keys through the test app.
+
+    // Error handling tests that takes compressed inputs
+    KCompressed_Errorhandling_TestBegin = 400,
+    ErrorHandling_WrongTextInputFileNameTest,
+    ErrorHandling_MediaInputNodeStartFailed,
+    KCompressed_Errorhandling_TestEnd,
+
+    //Error handling tests that takes uncompressed inputs through avi files.
+    KUnCompressed_Errorhandling_TestBegin = 500,
+    PVMediaInput_ErrorHandling_Test_WrongFormat,	//Use testinput_rgb16.avi
     PVMediaInput_ErrorHandling_Test_WrongIPFileName,
-    PVMediaInput_Reset_Test,
-    AVI_Input_Longetivity_Test,
-    //AVI Test Ends
+    ErrorHandling_WrongOutputPathTest,
+    ErrorHandling_VideoInitFailed,							// 504, //Video Encoder Init Failed
+    ErrorHandling_VideoEncodeFailed,						//Video Encoder Encode Failed
+    ErrorHandling_VideoEncode5FramesFailed,					//VideoEncNode Encode5Frames Failed
+    ErrorHandling_ComposerAddFragFailed,					//507, Composer AddMemFrag Failed
+    ErrorHandling_ComposerAddTrackFailed,					//Composer AddMemTrack Failed
+    ErrorHandling_AVCVideoEncodeFailed,						//AVCEncNode Encode Failed
+    ErrorHandling_AVCVideoEncode5FramesFailed,				//AVCEncNode Encode5Frames Failed
+    ErrorHandling_MediaInputNodeStopFailed,
+    ErrorHandling_AudioInitFailed,							//Audio Encoder(AMR) Init Failed
+    ErrorHandling_AudioEncodeFailed,						//513, Audio Encoder(AMR) Encode Failed
+    ErrorHandling_MediaInputNode_NoMemBuffer,				//514
+    ErrorHandling_MediaInputNode_Out_Queue_busy,			//515
+    ErrorHandling_MediaInputNode_large_time_stamp,						//516 MediaInputNode Error in time stamp for large value.
+    ErrorHandling_MediaInputNode_wrong_time_stamp_after_duration,		//517 MediaInputNode Error in time stamp for wrong value after duration of time.
+    ErrorHandling_MediaInputNode_zero_time_stamp,						//518 MediaInputNode Error in time stamp for zero value.
+    ErrorHandling_MediaInputNode_StateFailure_EPause_SendMIORequest,	//MediaInputNode Error in SendMIOioRequest().
+    ErrorHandling_MediaInputNode_StateFailure_CancelMIORequest,			//MediaInputNode Error in CancelMIORequest().
+    ErrorHandling_MediaInputNode_Corrupt_Video_InputData,				//MediaInputNode Corrupt the video input data.
+    ErrorHandling_MediaInputNode_Corrupt_Audio_InputData,				//MediaInputNode Corrupt the audio input data.
+    ErrorHandling_MediaInputNode_DataPath_Stall,						//MediaInputNode Stall the data path.
+    ErrorHandling_MP4Composer_AddTrack_PVMF_AMR_IETF,					//524 MP4ComposerNode Error in AddTrack() for PVMF_AMR_IETF.
+    ErrorHandling_MP4Composer_AddTrack_PVMF_3GPP_TIMEDTEXT,				//MP4ComposerNode Error in AddTrack() for PVMF_3GPP_TIMEDTEXT.
+    ErrorHandling_MP4Composer_AddTrack_PVMF_M4V,						//MP4ComposerNode Error in AddTrack() for PVMF_M4V.
+    ErrorHandling_MP4Composer_AddTrack_PVMF_H263,						//MP4ComposerNode Error in AddTrack() for PVMF_H263.
+    ErrorHandling_MP4Composer_AddTrack_PVMF_H264_MP4,					//MP4ComposerNode Error in AddTrack() for PVMF_H264_MP4.
+    ErrorHandling_MP4Composer_Create_FileParser,						//MP4ComposerNode Error in the creation of mp4 file parser.
+    ErrorHandling_MP4Composer_RenderToFile,								//MP4ComposerNode Error in the RenderToFile().
+    ErrorHandling_MP4Composer_FailAfter_FileSize,						//MP4ComposerNode Error after a particular file size is reached.
+    ErrorHandling_MP4Composer_FailAfter_Duration,						//MP4ComposerNode Error after a duration of some time.
+    ErrorHandling_MP4Composer_DataPathStall,							//MP4ComposerNode Stall the data path.
+    ErrorHandling_VideoEncodeNode_ConfigHeader,							//VideoEncodeNode Error in GetVolHeader().
+    ErrorHandling_VideoEncodeNode_DataPathStall_Before_ProcessingData,	//535 VideoEncodeNode Stall the data path before processing starts.
+    ErrorHandling_VideoEncodeNode_DataPathStall_After_ProcessingData,	//VideoEncodeNode Stall the data path post processing.
+    ErrorHandling_VideoEncodeNode_FailEncode_AfterDuration,				//VideoEncodeNode Error in encode after duration of time.
+    ErrorHandling_AudioEncodeNode_FailEncode_AfterDuration,				//AudioEncodeNode Error in encode operation after duration of time.
+    ErrorHandling_AudioEncodeNode_DataPathStall_Before_ProcessingData,	//AudioEncodeNode Stall data path before processing starts.
+    ErrorHandling_AudioEncodeNode_DataPathStall_After_ProcessingData,	//540 AudioEncodeNode Stall data path post processing.
+    ErrorHandling_AVCEncodeNode_ConfigHeader,							//AVCEncodeNode Error in in getting SPS & PPS Values.
+    ErrorHandling_AVCEncodeNode_DataPathStall_Before_ProcessingData,	//AVCEncodeNode Stall the data path before processing starts.
+    ErrorHandling_AVCEncodeNode_DataPathStall_After_ProcessingData,		//AVCEncodeNode Stall the data path post processing.
+    ErrorHandling_AVCEncodeNode_FailEncode_AfterDuration,				//AVCEncodeNode Error in encode after duration of time.
 
+    /***** Test for Node Commands *****/
+    ErrorHandling_MediaInputNode_Node_Cmd_Start,			//545 MediaInputNode Error in node command DoStart().
+    ErrorHandling_MediaInputNode_Node_Cmd_Stop,				//MediaInputNode Error in node command DoStop().
+    ErrorHandling_MediaInputNode_Node_Cmd_Flush,			//MediaInputNode Error in node command DoFlush().
+    ErrorHandling_MediaInputNode_Node_Cmd_Pause,			//MediaInputNode Error in node command DoPause().
+    ErrorHandling_MediaInputNode_Node_Cmd_ReleasePort,		//MediaInputNode Error in node command DoReleasePort().
+    ErrorHandling_MP4Composer_Node_Cmd_Start,				//MP4ComposerNode Error in the node command DoStart().
+    ErrorHandling_MP4Composer_Node_Cmd_Stop,				//MP4ComposerNode Error in the node command DoStop().
+    ErrorHandling_MP4Composer_Node_Cmd_Flush,				//552 MP4ComposerNode Error in the node command DoFlush().
+    ErrorHandling_MP4Composer_Node_Cmd_Pause,				//MP4ComposerNode Error in the node command DoPause().
+    ErrorHandling_MP4Composer_Node_Cmd_ReleasePort,			//MP4ComposerNode Error in the node command DoReleasePort().
+    ErrorHandling_VideoEncodeNode_Node_Cmd_Start,			//VideoEncodeNode Error in node command DoStart().
+    ErrorHandling_VideoEncodeNode_Node_Cmd_Stop,			//VideoEncodeNode Error in node command DoStop().
+    ErrorHandling_VideoEncodeNode_Node_Cmd_Flush,			//VideoEncodeNode Error in node command DoFlush().
+    ErrorHandling_VideoEncodeNode_Node_Cmd_Pause,			//VideoEncodeNode Error in node command DoPause().
+    ErrorHandling_VideoEncodeNode_Node_Cmd_ReleasePort,		//VideoEncodeNode Error in node command DoReleasePort().
+    ErrorHandling_AudioEncodeNode_Node_Cmd_Start,			//560 AudioEncodeNode Error in node command DoStart().
+    ErrorHandling_AudioEncodeNode_Node_Cmd_Stop,			//AudioEncodeNode Error in node command DoStop().
+    ErrorHandling_AudioEncodeNode_Node_Cmd_Flush,			//AudioEncodeNode Error in node command DoFlush().
+    ErrorHandling_AudioEncodeNode_Node_Cmd_Pause,			//AudioEncodeNode Error in node command DoPause().
+    ErrorHandling_AudioEncodeNode_Node_Cmd_ReleasePort,		//AudioEncodeNode Error in node command DoReleasePort().
+    ErrorHandling_AVCEncodeNode_Node_Cmd_Start,				//AVCEncodeNode Error in node command DoStart().
+    ErrorHandling_AVCEncodeNode_Node_Cmd_Stop,				//AVCEncodeNode Error in node command DoStop().
+    ErrorHandling_AVCEncodeNode_Node_Cmd_Flush,				//AVCEncodeNode Error in node command DoFlush().
+    ErrorHandling_AVCEncodeNode_Node_Cmd_Pause,				//AVCEncodeNode Error in node command DoPause().
+    ErrorHandling_AVCEncodeNode_Node_Cmd_ReleasePort,		//569 AVCEncodeNode Error in node command DoReleasePort().
+
+    KUnCompressed_Errorhandling_TestEnd,
+
+    /*********** Error Handling Tests End**************************/
     LastInteractiveTest = 1000,
     Invalid_Test
 
@@ -397,120 +483,26 @@
     PVAE_CMD_CLEANUPANDCOMPLETE,
     PVAE_CMD_CAPCONFIG_SYNC,
     PVAE_CMD_CAPCONFIG_ASYNC,
-    PVAE_CMD_RECORDING
+    PVAE_CMD_RECORDING,
+    PVAE_CMD_QUERY_INTERFACE1,
+    PVAE_CMD_CAPCONFIG_SYNC1,
+    PVAE_CMD_QUERY_INTERFACE_COMP
 } PVAECmdType;
 
-////////////////////////////////////////////////////////////////////////////
-template<class DestructClass>
-class LogAppenderDestructDealloc : public OsclDestructDealloc
-{
-    public:
-        virtual void destruct_and_dealloc(OsclAny *ptr)
-        {
-            delete((DestructClass*)ptr);
-        }
-};
 
 ////////////////////////////////////////////////////////////////////////////
 class PVLoggerSchedulerSetup
 {
     public:
-        PVLoggerSchedulerSetup(int32 aLogFile, int32 aLogLevel, int32 aLogNode):
-                iLogFile(aLogFile),
-                iLogLevel(aLogLevel),
-                iLogNode(aLogNode)	{}
-
+        PVLoggerSchedulerSetup() {};
         ~PVLoggerSchedulerSetup() {};
 
         void InitLoggerScheduler()
         {
             // Logging by PV Logger
             PVLogger::Init();
-            PVLoggerAppender *appender = NULL;
-            OsclRefCounter *refCounter = NULL;
-
-            if (iLogFile)
-            {
-                appender = (PVLoggerAppender*)TextFileAppender<TimeAndIdLayout, 1024>::CreateAppender((oscl_wchar*)(KLogFile));
-                OsclRefCounterSA<LogAppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
-                    new OsclRefCounterSA<LogAppenderDestructDealloc<TextFileAppender<TimeAndIdLayout, 1024> > >(appender);
-                refCounter = appenderRefCounter;
-            }
-            else
-            {
-                appender = new StdErrAppender<TimeAndIdLayout, 1024>();
-                OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
-                    new OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > >(appender);
-                refCounter = appenderRefCounter;
-
-            }
-
-            OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, refCounter);
-
-            if (iLogNode == 0)
-            {
-                PVLogger *rootnode = PVLogger::GetLoggerObject("PVAuthorEngine");
-                rootnode->AddAppender(appenderPtr);
-                rootnode->SetLogLevel(iLogLevel);
-            }
-            else if (iLogNode == 1)
-            {
-                // Log all
-                PVLogger *rootnode = PVLogger::GetLoggerObject("");
-                rootnode->AddAppender(appenderPtr);
-                rootnode->SetLogLevel(iLogLevel);
-            }
-            else if (iLogNode == 2)
-            {
-                // Log datapath only
-                PVLogger *node = PVLogger::GetLoggerObject("datapath");
-                node->AddAppender(appenderPtr);
-                //info level logs ports & synchronization info.
-                node->SetLogLevel(PVLOGMSG_INFO);
-
-                PVLogger* datapathsrc = PVLogger::GetLoggerObject("datapath.sourcenode");
-                datapathsrc->DisableAppenderInheritance();
-                PVLogger* datapathdec = PVLogger::GetLoggerObject("datapath.decnode");
-                datapathdec->DisableAppenderInheritance();
-            }
-            else if (iLogNode == 3)
-            {
-                // Log clock only
-                PVLogger *clocknode = PVLogger::GetLoggerObject("clock");
-                clocknode->AddAppender(appenderPtr);
-                clocknode->SetLogLevel(PVLOGMSG_DEBUG);
-            }
-            else if (iLogNode == 4)
-            {
-                // Log oscl only
-                PVLogger *clocknode = PVLogger::GetLoggerObject("pvscheduler");
-                clocknode->AddAppender(appenderPtr);
-                clocknode->SetLogLevel(iLogLevel);
-                clocknode = PVLogger::GetLoggerObject("osclsocket");
-                clocknode->AddAppender(appenderPtr);
-                clocknode->SetLogLevel(iLogLevel);
-            }
-            else if (iLogNode == 5)
-            {
-                // Log scheduler perf only.
-                PVLogger *clocknode = PVLogger::GetLoggerObject("pvscheduler");
-                clocknode->AddAppender(appenderPtr);
-                //info level logs scheduler activity including AO calls and idle time.
-                clocknode->SetLogLevel(PVLOGMSG_INFO);
-
-            }
-            else if (iLogNode == 6)
-            {
-                PVLogger *clocknode = PVLogger::GetLoggerObject("Oscl_File");
-                clocknode->AddAppender(appenderPtr);
-                clocknode->SetLogLevel(PVLOGMSG_DEBUG + 1);
-            }
-            else if (iLogNode == 7)
-            {
-                PVLogger *clocknode = PVLogger::GetLoggerObject("pvauthordiagnostics");
-                clocknode->AddAppender(appenderPtr);
-                clocknode->SetLogLevel(PVLOGMSG_DEBUG);
-            }
+            //PVAELogger::ParseConfigFile(_W("uilogger.txt"));
+            PVAELogger::ParseConfigFile(KPVAELoggerFile);
 
             // Construct and install the active scheduler
             OsclScheduler::Init("PVAuthorEngineTestScheduler");
@@ -522,11 +514,6 @@
             PVLogger::Cleanup();
         }
 
-        //For logging
-        int32                     iLogFile;
-        int32                     iLogLevel;
-        int32                     iLogNode;
-
 };
 // Observer class for pvPlayer async test to notify completion of test
 class pvauthor_async_test_observer
diff --git a/engines/author/test/src/test_pv_mediainput_author_engine.cpp b/engines/author/test/src/test_pv_mediainput_author_engine.cpp
index de32a6c..944a14d 100644
--- a/engines/author/test/src/test_pv_mediainput_author_engine.cpp
+++ b/engines/author/test/src/test_pv_mediainput_author_engine.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,14 +31,399 @@
 #include "test_pv_author_engine_testset7.h"
 #endif
 
+#ifndef TEST_PV_AUTHOR_ENGINE_TESTSET8_H_INCLUDED
+#include "test_pv_author_engine_testset8.h"
+#endif
+
+#define DEFAULT_LOOPTIME 60 //secs
+bool PVMediaInputAuthorEngineTest::Set_Default_Params(int32 aTestnum, PVMediaInputTestParam& aMediaInputParam)
+{
+    aMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE;
+
+    if (iAsap)
+    {
+        aMediaInputParam.iRealTimeAuthoring = false;
+    }
+
+    bool retval = true;
+    switch (aTestnum)
+    {
+        case CapConfigTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = KCAPCONFIG_OUTPUT;
+        }
+        break;
+
+        case PVMediaInput_Open_Compose_Stop_Test:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = DEFAULTOUTPUTFILENAME;
+            }
+        }
+        break;
+
+        case ErrorHandling_VideoInitFailed:
+        case ErrorHandling_VideoEncodeFailed:
+        case ErrorHandling_VideoEncode5FramesFailed:
+        case ErrorHandling_ComposerAddFragFailed:
+        case ErrorHandling_ComposerAddTrackFailed:
+        case ErrorHandling_MediaInputNodeStopFailed:
+        case ErrorHandling_AudioInitFailed:
+        case ErrorHandling_AudioEncodeFailed:
+        case ErrorHandling_MediaInputNode_NoMemBuffer:
+        case ErrorHandling_MediaInputNode_large_time_stamp:
+        case ErrorHandling_MediaInputNode_wrong_time_stamp_after_duration:
+        case ErrorHandling_MediaInputNode_zero_time_stamp:
+        case ErrorHandling_MediaInputNode_StateFailure_EPause_SendMIORequest:
+        case ErrorHandling_MediaInputNode_StateFailure_CancelMIORequest:
+        case ErrorHandling_MediaInputNode_Corrupt_Video_InputData:
+        case ErrorHandling_MediaInputNode_Corrupt_Audio_InputData:
+        case ErrorHandling_MediaInputNode_Node_Cmd_Start:
+        case ErrorHandling_MediaInputNode_Node_Cmd_Stop:
+        case ErrorHandling_MediaInputNode_Node_Cmd_Flush:
+        case ErrorHandling_MediaInputNode_Node_Cmd_Pause:
+        case ErrorHandling_MediaInputNode_Node_Cmd_ReleasePort:
+        case ErrorHandling_MediaInputNode_DataPath_Stall:
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_AMR_IETF:
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_3GPP_TIMEDTEXT:
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_M4V:
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_H263:
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_H264_MP4:
+        case ErrorHandling_MP4Composer_Node_Cmd_Start:
+        case ErrorHandling_MP4Composer_Node_Cmd_Stop:
+        case ErrorHandling_MP4Composer_Node_Cmd_Flush:
+        case ErrorHandling_MP4Composer_Node_Cmd_Pause:
+        case ErrorHandling_MP4Composer_Node_Cmd_ReleasePort:
+        case ErrorHandling_MP4Composer_Create_FileParser:
+        case ErrorHandling_MP4Composer_RenderToFile:
+        case ErrorHandling_MP4Composer_FailAfter_FileSize:
+        case ErrorHandling_MP4Composer_FailAfter_Duration:
+        case ErrorHandling_MP4Composer_DataPathStall:
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Start:
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Stop:
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Flush:
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Pause:
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_ReleasePort:
+        case ErrorHandling_VideoEncodeNode_ConfigHeader:
+        case ErrorHandling_VideoEncodeNode_DataPathStall_Before_ProcessingData:
+        case ErrorHandling_VideoEncodeNode_DataPathStall_After_ProcessingData:
+        case ErrorHandling_VideoEncodeNode_FailEncode_AfterDuration:
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Start:
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Stop:
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Flush:
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Pause:
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_ReleasePort:
+        case ErrorHandling_AudioEncodeNode_FailEncode_AfterDuration:
+        case ErrorHandling_AudioEncodeNode_DataPathStall_Before_ProcessingData:
+        case ErrorHandling_AudioEncodeNode_DataPathStall_After_ProcessingData:
+        case ErrorHandling_MediaInputNode_Out_Queue_busy:
+        {
+            aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            aMediaInputParam.iOPFileInfo = DEFAULTOUTPUTFILENAME;
+            aMediaInputParam.iRealTimeAuthoring = false;
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Start:
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Stop:
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Flush:
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Pause:
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_ReleasePort:
+        case ErrorHandling_AVCEncodeNode_ConfigHeader:
+        case ErrorHandling_AVCEncodeNode_DataPathStall_Before_ProcessingData:
+        case ErrorHandling_AVCEncodeNode_DataPathStall_After_ProcessingData:
+        case ErrorHandling_AVCEncodeNode_FailEncode_AfterDuration:
+        case ErrorHandling_AVCVideoEncodeFailed:
+        case ErrorHandling_AVCVideoEncode5FramesFailed:
+        {
+            aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            aMediaInputParam.iOPFileInfo = DEFAULTOUTPUTFILENAME;
+            aMediaInputParam.iVideoEncInfo  = KH264EncMimeType;
+            aMediaInputParam.iRealTimeAuthoring = false;
+
+        }
+        break;
+        case PVMediaInput_Open_RealTimeCompose_Stop_Test:
+        {
+            aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            aMediaInputParam.iRealTimeAuthoring = true;
+            aMediaInputParam.iOPFileInfo = KMediaInput_Open_RealTimeCompose_Output;
+        }
+        break;
+        case PVMediaInput_Pause_Resume_Test:
+        case PVMediaInput_Reset_After_Create_Test:
+        case PVMediaInput_Reset_After_Open_Test:
+        case PVMediaInput_Reset_After_AddDataSource_Test:
+        case PVMediaInput_Reset_After_SelectComposer_Test:
+        case PVMediaInput_Reset_After_AddMediaTrack_Test:
+        case PVMediaInput_Reset_After_Init_Test:
+        case PVMediaInput_Reset_After_Start_Test:
+        case PVMediaInput_Reset_After_Pause_Test:
+        case PVMediaInput_Reset_After_Recording_Test:
+        case PVMediaInput_Reset_After_Stop_Test:
+
+        case PVMediaInput_Delete_After_Create_Test:
+        case PVMediaInput_Delete_After_Open_Test:
+        case PVMediaInput_Delete_After_AddDataSource_Test:
+        case PVMediaInput_Delete_After_SelectComposer_Test:
+        case PVMediaInput_Delete_After_AddMediaTrack_Test:
+        case PVMediaInput_Delete_After_Init_Test:
+        case PVMediaInput_Delete_After_Start_Test:
+        case PVMediaInput_Delete_After_Pause_Test:
+        case PVMediaInput_Delete_After_Recording_Test:
+        case PVMediaInput_Delete_After_Stop_Test:
+
+        {
+            aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            aMediaInputParam.iOPFileInfo = DEFAULTOUTPUTFILENAME;
+        }
+        break;
+        case AVI_Input_Longetivity_Test:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = KAVI_Input_Long_OUTPUT;
+            }
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+        case YUV_Input_VOnly_3gpTest:
+        {
+            aMediaInputParam.iIPFileInfo = KYUV_AVI_VIDEO_ONLY;
+            aMediaInputParam.iOPFileInfo = KYUV_VOnly_3GPP_Output;
+        }
+        break;
+
+        case H264_Input_VOnly_3gpTest:
+        {
+            aMediaInputParam.iIPFileInfo = KYUV_AVI_VIDEO_ONLY;
+            aMediaInputParam.iOPFileInfo = KH264_VOnly_MP4_Output;
+        }
+        break;
+
+        case PCM16_Input_AOnly_3gpTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_AVI_AUDIO_ONLY;
+            aMediaInputParam.iInputFormat = PVMF_MIME_WAVFF;
+            aMediaInputParam.iOPFileInfo = KPCM_AOnly_3GPP_Output;
+        }
+        break;
+
+        case PCM16In_AMROut_Test:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_AVI_AUDIO_ONLY;
+            aMediaInputParam.iOPFileInfo = KPCM16_AMR_TestOutput;
+            aMediaInputParam.iInputFormat = PVMF_MIME_WAVFF;
+        }
+        break;
+
+        case PCM16_YUV_Input_AV_3gpTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = KPCM_YUV_AV_3GPP_Output;
+        }
+        break;
+
+        case KMaxFileSizeTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = KMaxFileSizeTestOutput;
+        }
+        break;
+
+        case KMaxFileSizeLongetivityTest:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = KMaxFileSize_long_Output;
+            }
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+        case KIMotionAuthoringModeTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = KIMOTIONAUTHORINGMODE_OUTPUT;
+        }
+        break;
+
+        case KIMotionAuthoringModeLongetivityTest:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = KIMOTIONAUTHORINGMODE_Long_OUTPUT;
+            }
+
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+        case KIMotionDownloadModeTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = KIMOTIONDOWNLOADMODE_OUTPUT;
+        }
+        break;
+
+        case KIMotionDownloadModeLongetivityTest:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = KIMOTIONDOWNLOADMODE_Long_OUTPUT;
+            }
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+#endif
+
+        case K3GPPDownloadModeTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = K3GPPDOWNLOADMODE_OUTPUT;
+        }
+        break;
+
+        case K3GPPDownloadModeLongetivityTest:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = K3GPPDOWNLOADMODE_Long_OUTPUT;
+            }
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+        case K3GPPProgressiveDownloadModeTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = K3GPPPROGRESSIVEDOWNLOADMODE_OUTPUT;
+        }
+        break;
+
+        case K3GPPProgressiveDownloadModeLongetivityTest:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = K3GPPPROGRESSIVEDOWNLOADMODE_Long_OUTPUT;
+            }
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+        case KMovieFragmentModeTest:
+        {
+            aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            aMediaInputParam.iOPFileInfo = KMOVIEFRAGMENTMODE_OUTPUT;
+        }
+        break;
+
+        case KMovieFragmentModeLongetivityTest:
+        {
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iIPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iIPFileInfo = KPCM_YUV_AVI_FILENAME;
+            }
+            if ((iFirstTest != iLastTest) || (aMediaInputParam.iOPFileInfo.get_size() == 0))
+            {
+                aMediaInputParam.iOPFileInfo = KMOVIEFRAGMENTMODE_Long_OUTPUT;
+            }
+            if (0 == aMediaInputParam.iLoopTime)
+            {
+                aMediaInputParam.iLoopTime = DEFAULT_LOOPTIME;
+            }
+        }
+        break;
+
+        case PVMediaInput_ErrorHandling_Test_WrongFormat:
+        {
+            aMediaInputParam.iIPFileInfo = FILE_NAME_ERROR_HANDLING;
+            aMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE;
+        }
+        break;
+
+        case PVMediaInput_ErrorHandling_Test_WrongIPFileName:
+        {
+            aMediaInputParam.iIPFileInfo = WRONGIPFILENAME_ERRORHANDLING;
+            aMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE;
+        }
+        break;
+
+        case ErrorHandling_WrongOutputPathTest:
+        {
+            aMediaInputParam.iIPFileInfo = DEFAULTSOURCEFILENAME;
+            aMediaInputParam.iOPFileInfo = WRONGOPFILENAME_ERRORHANDLING;
+        }
+        break;
+        default:
+            retval = false;
+            break;
+    }
+    return retval;
+}
 
 void PVMediaInputAuthorEngineTest::test()
 {
     iTotalSuccess = 0;
     iTotalFail = 0;
     iTotalError = 0;
+    PVAECmdType resetState = PVAE_CMD_CREATE;
 
-    PVAECmdType resetState = PVAE_CMD_OPEN;
+    if (iNextTestCase < UnCompressed_NormalTestBegin)
+    {
+        iNextTestCase = UnCompressed_NormalTestBegin;
+    }
+
     while ((iNextTestCase <= iLastTest) || (iNextTestCase < Invalid_Test))
     {
         if (iCurrentTest)
@@ -57,7 +442,6 @@
                 MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
                 if (stats)
                 {
-                    uint32 alloclks = stats->numAllocs - iNumAllocs;
                     fprintf(iFile, "  Mem stats: TotalAllocs(%d), TotalBytes(%d),\n AllocFailures(%d), AllocLeak(%d)\n",
                             stats->totalNumAllocs - iTotalAlloc, stats->totalNumBytes - iTotalBytes, stats->numAllocFails - iAllocFails, stats->numAllocs - iNumAllocs);
                 }
@@ -99,17 +483,39 @@
             fprintf(iFile, "Memory audit not available! Memory statistics result would be invalid.\n");
         }
 #endif
-
-
-        //stop at last test
         if (iNextTestCase > iLastTest)
         {
             iNextTestCase = Invalid_Test;
         }
         else
         {
-            fprintf(iFile, "\nStarting Test %d: ", iNextTestCase);
-            InitLoggerScheduler();
+            if ((iNextTestCase >= UnCompressed_NormalTestEnd && iNextTestCase <= UnCompressed_LongetivityTestBegin) && (iLastTest >= UnCompressed_LongetivityTestBegin))
+            {
+                iNextTestCase = UnCompressed_LongetivityTestBegin;
+                iNextTestCase++;
+            }
+
+            if ((UnCompressed_NormalTestBegin == iNextTestCase) || (UnCompressed_LongetivityTestBegin == iNextTestCase)
+                    || (KUnCompressed_Errorhandling_TestBegin == iNextTestCase)  || (UnCompressed_NormalTestEnd == iNextTestCase))
+            {
+                fprintf(iFile, "\nPlace Holder Not actual testcase %d: ", iNextTestCase);
+                iNextTestCase++;
+            }
+
+            if ((iNextTestCase > UnCompressed_NormalTestEnd) && (iLastTest < UnCompressed_LongetivityTestBegin))
+            {
+                iNextTestCase = Invalid_Test;
+            }//stop at last test
+            else if ((UnCompressed_LongetivityTestEnd == iNextTestCase) || (KUnCompressed_Errorhandling_TestEnd == iNextTestCase))
+            {
+                fprintf(iFile, "\nPlace Holder Not actual testcase %d: ", iNextTestCase);
+                iNextTestCase = Invalid_Test;
+            }
+            else
+            {
+                fprintf(iFile, "\nStarting Test %d: ", iNextTestCase);
+                InitLoggerScheduler();
+            }
         }
 
         PVAuthorAsyncTestParam testparam;
@@ -117,21 +523,38 @@
         testparam.iTestCase = this;
         testparam.iTestCaseNum = iNextTestCase;
         testparam.iStdOut = iFile;
+        if (!Set_Default_Params(iNextTestCase, iMediaInputParam) && (Invalid_Test != iNextTestCase))
+        {
+            fprintf(iFile, "\nNo Default Parameters specified for test case:%d\n", iNextTestCase);
+        }
 
         switch (iNextTestCase)
         {
             case PVMediaInput_Open_Compose_Stop_Test:
-            {
-                fprintf(iFile, "Open Compose Stop test with AVI/WAV MIO Comp:\n");
-                iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, false);
-                // Go to next test
-                ++iNextTestCase;
-            }
-            break;
             case PVMediaInput_Open_RealTimeCompose_Stop_Test:
+            case YUV_Input_VOnly_3gpTest:
+            case H264_Input_VOnly_3gpTest:
+            case PCM16_Input_AOnly_3gpTest:
+            case PCM16_YUV_Input_AV_3gpTest:
+            case PCM16In_AMROut_Test:
+            case KMaxFileSizeTest:
+
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+            case KIMotionAuthoringModeTest:
+            case KIMotionDownloadModeTest:
+            case KIMotionAuthoringModeLongetivityTest:
+            case KIMotionDownloadModeLongetivityTest:
+#endif
+            case K3GPPDownloadModeTest:
+            case K3GPPProgressiveDownloadModeTest:
+            case CapConfigTest:
+            case AVI_Input_Longetivity_Test:
+            case KMaxFileSizeLongetivityTest:
+            case K3GPPDownloadModeLongetivityTest:
+            case K3GPPProgressiveDownloadModeLongetivityTest:
+            case KMovieFragmentModeLongetivityTest:
             {
-                fprintf(iFile, "Open Real Time Compose Stop test with AVI/WAV MIO Comp:\n");
-                iMediaInputParam.iRealTimeAuthoring = true;
+                Print_TestCase_Name(iNextTestCase);
                 iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, false);
                 // Go to next test
                 ++iNextTestCase;
@@ -149,10 +572,7 @@
             case PVMediaInput_ErrorHandling_Test_WrongFormat:
             {
                 fprintf(iFile, "Error Handling Wrong Format test with AVI/WAV MIO Comp\n");
-
-                iMediaInputParam.iIPFileInfo = FILE_NAME_ERROR_HANDLING;
-                iMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE;
-                iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, true);
+                iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, iNextTestCase);
 
                 // Go to next test
                 ++iNextTestCase;
@@ -160,89 +580,294 @@
             break;
 
             case PVMediaInput_ErrorHandling_Test_WrongIPFileName:
+            case ErrorHandling_WrongOutputPathTest:
             {
-                fprintf(iFile, "Error Handling wrong IP File test with AVI/WAV MIO Comp\n");
-
-                iMediaInputParam.iIPFileInfo = WRONGIPFILENAME_ERRORHANDLING;
-                iMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE;
-                iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, false);
+                Print_TestCase_Name(iNextTestCase);
+                iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, iNextTestCase);
 
                 // Go to next test
                 ++iNextTestCase;
             }
             break;
 
-            case PVMediaInput_Reset_Test:
+            case ErrorHandling_AVCVideoEncodeFailed:
+            case ErrorHandling_AVCVideoEncode5FramesFailed:
             {
-                fprintf(iFile, "Reset test with AVI/WAV MIO Comp\n");
-                switch (resetState)
+                iMediaInputParam.iVideoEncInfo  = KH264EncMimeType;
+            }
+            case ErrorHandling_VideoInitFailed:
+            case ErrorHandling_VideoEncodeFailed:
+            case ErrorHandling_VideoEncode5FramesFailed:
+            case ErrorHandling_ComposerAddFragFailed:
+            case ErrorHandling_ComposerAddTrackFailed:
+            case ErrorHandling_MediaInputNodeStopFailed:
+            case ErrorHandling_AudioInitFailed:
+            case ErrorHandling_AudioEncodeFailed:
+            case ErrorHandling_MediaInputNode_NoMemBuffer:
+            case ErrorHandling_MediaInputNode_Out_Queue_busy:
+            case ErrorHandling_MediaInputNode_large_time_stamp:
+            case ErrorHandling_MediaInputNode_wrong_time_stamp_after_duration:
+            case ErrorHandling_MediaInputNode_zero_time_stamp:
+            case ErrorHandling_MediaInputNode_StateFailure_EPause_SendMIORequest:
+            case ErrorHandling_MediaInputNode_StateFailure_CancelMIORequest:
+            case ErrorHandling_MediaInputNode_Corrupt_Video_InputData:
+            case ErrorHandling_MediaInputNode_Corrupt_Audio_InputData:
+            case ErrorHandling_MediaInputNode_Node_Cmd_Start:
+            case ErrorHandling_MediaInputNode_Node_Cmd_Stop:
+            case ErrorHandling_MediaInputNode_Node_Cmd_Flush:
+            case ErrorHandling_MediaInputNode_Node_Cmd_Pause:
+            case ErrorHandling_MediaInputNode_Node_Cmd_ReleasePort:
+            case ErrorHandling_MediaInputNode_DataPath_Stall:
+            case ErrorHandling_MP4Composer_AddTrack_PVMF_AMR_IETF:
+            case ErrorHandling_MP4Composer_AddTrack_PVMF_3GPP_TIMEDTEXT:
+            case ErrorHandling_MP4Composer_AddTrack_PVMF_M4V:
+            case ErrorHandling_MP4Composer_AddTrack_PVMF_H263:
+            case ErrorHandling_MP4Composer_AddTrack_PVMF_H264_MP4:
+            case ErrorHandling_MP4Composer_Node_Cmd_Start:
+            case ErrorHandling_MP4Composer_Node_Cmd_Stop:
+            case ErrorHandling_MP4Composer_Node_Cmd_Flush:
+            case ErrorHandling_MP4Composer_Node_Cmd_Pause:
+            case ErrorHandling_MP4Composer_Node_Cmd_ReleasePort:
+            case ErrorHandling_MP4Composer_Create_FileParser:
+            case ErrorHandling_MP4Composer_RenderToFile:
+            case ErrorHandling_MP4Composer_FailAfter_FileSize:
+            case ErrorHandling_MP4Composer_FailAfter_Duration:
+            case ErrorHandling_MP4Composer_DataPathStall:
+            case ErrorHandling_VideoEncodeNode_Node_Cmd_Start:
+            case ErrorHandling_VideoEncodeNode_Node_Cmd_Stop:
+            case ErrorHandling_VideoEncodeNode_Node_Cmd_Flush:
+            case ErrorHandling_VideoEncodeNode_Node_Cmd_Pause:
+            case ErrorHandling_VideoEncodeNode_Node_Cmd_ReleasePort:
+            case ErrorHandling_VideoEncodeNode_ConfigHeader:
+            case ErrorHandling_VideoEncodeNode_DataPathStall_Before_ProcessingData:
+            case ErrorHandling_VideoEncodeNode_DataPathStall_After_ProcessingData:
+            case ErrorHandling_VideoEncodeNode_FailEncode_AfterDuration:
+            case ErrorHandling_AudioEncodeNode_FailEncode_AfterDuration:
+            case ErrorHandling_AudioEncodeNode_DataPathStall_Before_ProcessingData:
+            case ErrorHandling_AudioEncodeNode_DataPathStall_After_ProcessingData:
+            case ErrorHandling_AVCEncodeNode_Node_Cmd_Start:
+            case ErrorHandling_AVCEncodeNode_Node_Cmd_Stop:
+            case ErrorHandling_AVCEncodeNode_Node_Cmd_Flush:
+            case ErrorHandling_AVCEncodeNode_Node_Cmd_Pause:
+            case ErrorHandling_AVCEncodeNode_Node_Cmd_ReleasePort:
+            case ErrorHandling_AudioEncodeNode_Node_Cmd_Start:
+            case ErrorHandling_AudioEncodeNode_Node_Cmd_Stop:
+            case ErrorHandling_AudioEncodeNode_Node_Cmd_Flush:
+            case ErrorHandling_AudioEncodeNode_Node_Cmd_Pause:
+            case ErrorHandling_AudioEncodeNode_Node_Cmd_ReleasePort:
+            case ErrorHandling_AVCEncodeNode_ConfigHeader:
+            case ErrorHandling_AVCEncodeNode_DataPathStall_Before_ProcessingData:
+            case ErrorHandling_AVCEncodeNode_DataPathStall_After_ProcessingData:
+            case ErrorHandling_AVCEncodeNode_FailEncode_AfterDuration:
+
+#ifndef _TEST_AE_ERROR_HANDLING
+                fprintf(iFile, " AE Error Handling Test Not implemented\n");
+                iCurrentTest = NULL;
+                break;
+#else
                 {
-                    case PVAE_CMD_OPEN:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_OPEN\n");
-                    }
-                    break;
-                    case PVAE_CMD_ADD_DATA_SOURCE:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_ADD_DATA_SOURCE\n");
-                    }
-                    break;
-                    case PVAE_CMD_SELECT_COMPOSER:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_SELECT_COMPOSER\n");
-                    }
-                    break;
-                    case PVAE_CMD_ADD_MEDIA_TRACK:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_ADD_MEDIA_TRACK\n");
-                    }
-                    break;
-                    case PVAE_CMD_INIT:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_INIT\n");
-                    }
-                    break;
-                    case PVAE_CMD_START:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_START\n");
-                    }
-                    break;
-                    case PVAE_CMD_PAUSE:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_PAUSE\n");
-                    }
-                    break;
-                    case PVAE_CMD_RECORDING:
-                    {
-                        fprintf(iFile, "Current reset state: PVAE_CMD_RECORDING\n");
-                    }
-                    break;
 
-                    default:
-                        break;
+                    //fprintf(iFile, "\nCurrently executing test:%d\n\n", iNextTestCase);
+                    fprintf(iFile, "Begin test with the following parameters:\
+				\nInput File Name : %s\nOutput File Name: %s,\nVideo Encoder: %s,\nAudio Encoder: %s,\
+				\nComposer: %s\n", iMediaInputParam.iIPFileInfo.get_cstr(), iMediaInputParam.iOPFileInfo.get_cstr(),
+                    iMediaInputParam.iVideoEncInfo.get_cstr(), iMediaInputParam.iAudioEncInfo.get_cstr(),
+                    iMediaInputParam.iComposerInfo.get_cstr());
 
 
-                }
-                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
-                resetState = ((pv_mediainput_async_test_reset*)iCurrentTest)->GetNextResetState();
-                //run reset test for all states.
-                if (PVAE_CMD_STOP == resetState)
-                {
+                    //fprintf(iFile, "\nCurrently executing test:%d\n\n", iNextTestCase);
+                    Print_TestCase_Name(iNextTestCase);
+
+                    iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, iNextTestCase);
+
                     // Go to next test
                     ++iNextTestCase;
-                }
 
-            }
-            break;
-            case AVI_Input_Longetivity_Test:
+                }
+                break;
+#endif
+            case PVMediaInput_Reset_After_Create_Test:
             {
-                fprintf(iFile, "AVI Input Longetivity test:\n");
-                iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, false);
+                fprintf(iFile, "Reset After Create test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_CREATE;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
                 // Go to next test
                 ++iNextTestCase;
-
             }
             break;
+            case PVMediaInput_Reset_After_Open_Test:
+            {
+                fprintf(iFile, "Reset After Open test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_OPEN;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_AddDataSource_Test:
+            {
+                fprintf(iFile, "Reset After AddDataSource test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_ADD_DATA_SOURCE;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_SelectComposer_Test:
+            {
+                fprintf(iFile, "Reset After SelectComposer test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_SELECT_COMPOSER;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_AddMediaTrack_Test:
+            {
+                fprintf(iFile, "Reset After AddMediaTrack test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_ADD_MEDIA_TRACK;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_Init_Test:
+            {
+                fprintf(iFile, "Reset After Init test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_INIT;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_Start_Test:
+            {
+                fprintf(iFile, "Reset After Start test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_START;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_Pause_Test:
+            {
+                fprintf(iFile, "Reset After Pause test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_PAUSE;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_Recording_Test:
+            {
+                fprintf(iFile, "Reset After Recording test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_RECORDING;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Reset_After_Stop_Test:
+            {
+                fprintf(iFile, "Reset After Stop test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_STOP;
+                iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+
+            case PVMediaInput_Delete_After_Create_Test:
+            {
+                fprintf(iFile, "Delete After Create test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_CREATE;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_Open_Test:
+            {
+                fprintf(iFile, "Delete After Open test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_OPEN;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_AddDataSource_Test:
+            {
+                fprintf(iFile, "Delete After AddDataSource test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_ADD_DATA_SOURCE;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_SelectComposer_Test:
+            {
+                fprintf(iFile, "Delete After SelectComposer test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_SELECT_COMPOSER;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_AddMediaTrack_Test:
+            {
+                fprintf(iFile, "Delete After AddMediaTrack test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_ADD_MEDIA_TRACK;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_Init_Test:
+            {
+                fprintf(iFile, "Delete After Init test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_INIT;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_Start_Test:
+            {
+                fprintf(iFile, "Delete After Start test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_START;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_Pause_Test:
+            {
+                fprintf(iFile, "Delete After Pause test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_PAUSE;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_Recording_Test:
+            {
+                fprintf(iFile, "Delete After Recording test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_RECORDING;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+            case PVMediaInput_Delete_After_Stop_Test:
+            {
+                fprintf(iFile, "Delete After Stop test with AVI/WAV MIO Comp\n");
+                resetState = PVAE_CMD_STOP;
+                iCurrentTest = new pv_mediainput_async_test_delete(testparam, iMediaInputParam, false, resetState);
+                // Go to next test
+                ++iNextTestCase;
+            }
+            break;
+
             default:
             {
                 iCurrentTest = NULL;
@@ -252,19 +877,40 @@
 
         if (iCurrentTest)
         {
+
             // Setup Scheduler
             OsclExecScheduler *sched = OsclExecScheduler::Current();
             if (sched)
             {
+                int32 err;
                 iCurrentTest->StartTest();
 
-#if USE_NATIVE_SCHEDULER
-                // Have PV scheduler use the scheduler native to the system
-                sched->StartNativeScheduler();
+#if(USE_NATIVE_SCHEDULER)
+                OSCL_TRY(err,
+                         uint32 currticks  = 0;
+                         currticks = OsclTickCount::TickCount();
+                         uint32 starttime = OsclTickCount::TicksToMsec(currticks);
+
+                         sched->StartNativeScheduler();
+
+                         currticks = OsclTickCount::TickCount();
+                         uint32 endtime = OsclTickCount::TicksToMsec(currticks);
+                         fprintf(iFile, "  Time taken by the test:  %d\n", (endtime - starttime)););
+
 #else
-                int32 err;
-                OSCL_TRY(err, sched->StartScheduler(););
+                OSCL_TRY(err,
+                         uint32 currticks  = 0;
+                         currticks = OsclTickCount::TickCount();
+                         uint32 starttime = OsclTickCount::TicksToMsec(currticks);
+
+                         sched->StartScheduler();
+
+                         currticks = OsclTickCount::TickCount();
+                         uint32 endtime = OsclTickCount::TicksToMsec(currticks);
+                         fprintf(iFile, "  Time taken by the test:  %d\n", (endtime - starttime));
+                        );
 #endif
+
             }
             else
             {
@@ -306,3 +952,466 @@
     }
 }
 
+void PVMediaInputAuthorEngineTest::Print_TestCase_Name(int32 aTestnum)
+{
+    fprintf(iFile, "\n\nTest:%d: ", aTestnum);
+    switch (aTestnum)
+    {
+        case PVMediaInput_Open_Compose_Stop_Test:
+        {
+            fprintf(iFile, "Open Compose Stop test with AVI/WAV MIO Comp:\n");
+        }
+        break;
+        case PVMediaInput_Open_RealTimeCompose_Stop_Test:
+        {
+            fprintf(iFile, "Open Real Time Compose Stop test with AVI/WAV MIO Comp:\n");
+        }
+        break;
+        case YUV_Input_VOnly_3gpTest:
+        {
+            fprintf(iFile, "YUV to V-Only .3gp Test with AVI/WAV component\n");
+
+        }
+        break;
+        case PCM16_Input_AOnly_3gpTest:
+        {
+            fprintf(iFile, "PCM16 to A-Only .3gp Test\n");
+        }
+        break;
+        case PCM16_YUV_Input_AV_3gpTest:
+        {
+            fprintf(iFile, "PCM16 & YUV to AV .3gp Test\n");
+        }
+        break;
+        case H264_Input_VOnly_3gpTest:
+        {
+            fprintf(iFile, "H264 to V-Only .3gp Test\n");
+        }
+        break;
+        case PCM16In_AMROut_Test:
+        {
+            fprintf(iFile, "PCM16 to ARM Test\n");
+        }
+        break;
+        case KMaxFileSizeTest:
+        {
+            fprintf(iFile, "Max FileSize test \n");
+        }
+        break;
+
+#ifndef _IMOTION_SPECIFIC_UT_DISABLE
+        case KIMotionAuthoringModeTest:
+        {
+            fprintf(iFile, "IMotionAuthoringMode test \n");
+        }
+        break;
+        case KIMotionDownloadModeTest:
+        {
+            fprintf(iFile, "IMotionDownloadMode test \n");
+        }
+        break;
+        case KIMotionAuthoringModeLongetivityTest:
+        {
+            fprintf(iFile, "KIMotionAuthoringMode Longetivity Test:\n");
+        }
+        break;
+        case KIMotionDownloadModeLongetivityTest:
+        {
+            fprintf(iFile, "KIMotionDownloadMode Longetivity Test:\n");
+        }
+        break;
+#endif
+        case K3GPPDownloadModeTest:
+        {
+            fprintf(iFile, "3GPPDownloadMode test \n");
+        }
+        break;
+        case K3GPPProgressiveDownloadModeTest:
+        {
+            fprintf(iFile, "3GPPProgressiveDownloadMode test \n");
+        }
+        break;
+        case KMovieFragmentModeTest:
+        {
+            fprintf(iFile, "Movie Fragment test \n");
+        }
+        break;
+        case CapConfigTest:
+        {
+            fprintf(iFile, "CapConfig test \n");
+        }
+        break;
+        case AVI_Input_Longetivity_Test:
+        {
+            fprintf(iFile, "AVI Input Longetivity test:\n");
+        }
+        break;
+        case KMaxFileSizeLongetivityTest:
+        {
+            fprintf(iFile, "KMaxFileSizeLongetivityTest test \n");
+        }
+        break;
+        case K3GPPDownloadModeLongetivityTest:
+        {
+            fprintf(iFile, "K3GPPDownloadMode Longetivity Test:\n");
+        }
+        break;
+        case K3GPPProgressiveDownloadModeLongetivityTest:
+        {
+            fprintf(iFile, "K3GPPProgressiveDownloadMode Longetivity Test:\n");
+        }
+        break;
+        case KMovieFragmentModeLongetivityTest:
+        {
+            fprintf(iFile, "KMovieFragmentMode Longetivity Test:\n");
+        }
+        break;
+        case PVMediaInput_ErrorHandling_Test_WrongIPFileName:
+        {
+            fprintf(iFile, "Error Handling wrong IP File test with AVI/WAV MIO Comp\n");
+        }
+        break;
+
+        case ErrorHandling_WrongOutputPathTest:
+        {
+            fprintf(iFile, "Error Handling wrong Output path for output File test with AVI/WAV MIO Comp\n");
+        }
+        break;
+        case ErrorHandling_VideoInitFailed:
+        {
+            fprintf(iFile, "Error Handling test for Video Init Failed\n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeFailed:
+        {
+            fprintf(iFile, "Error Handiling test for Video Encode Failed\n");
+        }
+        break;
+        case ErrorHandling_VideoEncode5FramesFailed:
+        {
+            fprintf(iFile, "Error Handling test for Video Encode 5Frames Failed\n");
+        }
+        break;
+        case ErrorHandling_ComposerAddFragFailed:
+        {
+            fprintf(iFile, "Error Handling test for Composer Add Fragment Failed\n");
+        }
+        break;
+        case ErrorHandling_ComposerAddTrackFailed:
+        {
+            fprintf(iFile, "Error Handling test for Composer Add Track Failed\n");
+        }
+        break;
+        case ErrorHandling_AVCVideoEncodeFailed:
+        {
+            fprintf(iFile, "Error Handling test for AVC Video Encoder Failed\n");
+        }
+        break;
+        case ErrorHandling_AVCVideoEncode5FramesFailed:
+        {
+            fprintf(iFile, "Error Handling test for AVC Video Encode 5 Frames Failed\n");
+        }
+        break;
+        case ErrorHandling_MediaInputNodeStopFailed:
+        {
+            fprintf(iFile, "Error Handling test for MediaInputNode Stop Failed\n");
+        }
+        break;
+        case ErrorHandling_AudioInitFailed:
+        {
+            fprintf(iFile, "Error Handiling test for Audio Init Failed \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeFailed:
+        {
+            fprintf(iFile, "Error Handling test for Audio Encode Failed \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_NoMemBuffer:
+        {
+            fprintf(iFile, "Error Handling test for MediaInputNode No Memory Buffer available \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Out_Queue_busy:
+        {
+            fprintf(iFile, "Error Handling test for MediaInputNode Out Queue Busy occur \n");
+        }
+        break;
+        case  ErrorHandling_MediaInputNode_large_time_stamp:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to mess up the time stamp by giving largeer time stamp in begining. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_wrong_time_stamp_after_duration:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to mess up the time stamp by giving wrong timestamp after some duration of time. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_zero_time_stamp:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to mess up the time stamp by assigning timestamp value as zero. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_StateFailure_EPause_SendMIORequest:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail EPause state of SendMIORequest(). \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_StateFailure_CancelMIORequest:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail CancelMIORequest(). \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Corrupt_Video_InputData:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to corrupt the video input data. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Corrupt_Audio_InputData:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to corrupt the audio input data. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Node_Cmd_Start:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail the node command Start state. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Node_Cmd_Stop:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail the node command Stop state. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Node_Cmd_Flush:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail the node command Flush state. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Node_Cmd_Pause:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail the node command Pause state. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_Node_Cmd_ReleasePort:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to fail the node command Release Port state. \n");
+        }
+        break;
+        case ErrorHandling_MediaInputNode_DataPath_Stall:
+        {
+            fprintf(iFile, "ErrorHandling test for MediaInputNode to stall data path. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_AMR_IETF:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail PVMF_AMR_IETF in AddTrack(). \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_3GPP_TIMEDTEXT:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail PVMF_3GPP_TIMEDTEXT in AddTrack(). \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_M4V:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail PVMF_M4V in AddTrack(). \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_H263:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail PVMF_H263 in AddTrack(). \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_AddTrack_PVMF_H264_MP4:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail PVMF_H264_MP4 in AddTrack(). \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_Node_Cmd_Start:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail Node Command Start. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_Node_Cmd_Stop:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail Node Command Stop. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_Node_Cmd_Flush:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail Node Command Flush. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_Node_Cmd_Pause:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail Node Command Pause. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_Node_Cmd_ReleasePort:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail Node Command Release Port. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_Create_FileParser:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail creation of mp4 file parser. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_RenderToFile:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to fail RenderToFile(). \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_FailAfter_FileSize:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode returns error after particular file size if reached.\n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_FailAfter_Duration:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode returns error after some duration of time.\n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Start:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail Node Command Start. \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Stop:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail Node Command Stop. \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Flush:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail Node Command Flush. \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_Pause:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail Node Command Pause. \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_Node_Cmd_ReleasePort:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail Node Command ReleasePort. \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_ConfigHeader:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail GetVolHeader(). \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_DataPathStall_Before_ProcessingData:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to stall the data path before processing starts. \n");
+        }
+        break;
+        case ErrorHandling_VideoEncodeNode_DataPathStall_After_ProcessingData:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to stall the data path after processing is done. \n");
+        }
+        break;
+
+        case ErrorHandling_VideoEncodeNode_FailEncode_AfterDuration:
+        {
+            fprintf(iFile, "ErrorHandling test for VideoEncodeNode to fail encode operation after duration of time. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Start:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to fail Node Command Start. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Stop:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to fail Node Command Stop. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Flush:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to fail Node Command Flush. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_Pause:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to fail Node Command Pause. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_Node_Cmd_ReleasePort:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to fail Node Command Release Port. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_FailEncode_AfterDuration:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to fail encode operation after duration of time. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_DataPathStall_Before_ProcessingData:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to stall the data path before the processing starts. \n");
+        }
+        break;
+        case ErrorHandling_AudioEncodeNode_DataPathStall_After_ProcessingData:
+        {
+            fprintf(iFile, "ErrorHandling test for AudioEncodeNode to stall the data path after the processing is done. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Start:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail Node Command Start. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Stop:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail Node Command Stop. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Flush:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail Node Command Flush. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_Pause:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail Node Command Pause. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_Node_Cmd_ReleasePort:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail Node Command ReleasePort. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_ConfigHeader:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail in getting SPS and PPS value. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_DataPathStall_Before_ProcessingData:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to stall the data path before processing starts. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_DataPathStall_After_ProcessingData:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to stall the data path after processing is done. \n");
+        }
+        break;
+        case ErrorHandling_AVCEncodeNode_FailEncode_AfterDuration:
+        {
+            fprintf(iFile, "ErrorHandling test for AVCEncodeNode to fail encode operation after duration of time. \n");
+        }
+        break;
+        case ErrorHandling_MP4Composer_DataPathStall:
+        {
+            fprintf(iFile, "ErrorHandling test for MP4ComposerNode to stall data path. \n");
+        }
+        break;
+        default:
+            break;
+
+
+    }
+    fprintf(iFile, "\n");
+}
diff --git a/engines/author/test/src/test_pv_mediainput_author_engine.h b/engines/author/test/src/test_pv_mediainput_author_engine.h
index a88dd40..ec9c0a0 100644
--- a/engines/author/test/src/test_pv_mediainput_author_engine.h
+++ b/engines/author/test/src/test_pv_mediainput_author_engine.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,16 +53,17 @@
     OSCL_HeapString<OsclMemAllocator> iComposerInfo;
     uint32 iLoopTime;
     bool iRealTimeAuthoring;
-
+    uint32 iVideoBitrate;
+    uint32 iAudioBitrate;
+    OsclFloat iFrameRate;
+    uint32 iSamplingRate;
 }PVMediaInputTestParam;
 
 typedef struct _PVMediaInputAuthorEngineTestParam
 {
-    int32 iLogLevel;
-    int32 iLogNode;
-    int32 iLogFile;
     int32 iFirstTest;
     int32 iLastTest;
+    bool iAsap;
     PVMediaInputTestParam iMediainputParam;
 
 }PVMediaInputAuthorEngineTestParam;
@@ -74,28 +75,19 @@
         /** constructor */
         PVMIOControlComp(PVMFFormatType aType, OsclAny* aFileParser, uint32 aLoopDuration)
         {
-            switch (aType)
+            if (aType == PVMF_MIME_WAVFF)
             {
-                case PVMF_WAVFF:
-                {
-                    iPVWavFile = OSCL_STATIC_CAST(PV_Wav_Parser*, aFileParser);
-                    iPVAviFile = NULL;
-                    PVWAVFileInfo wavFileInfo;
-                    iPVWavFile->RetrieveFileInfo(wavFileInfo);
-                    iFileDuration = wavFileInfo.NumSamples / wavFileInfo.SampleRate; //in sec
-                }
-                break;
-
-                case PVMF_AVIFF:
-                {
-                    iPVAviFile = OSCL_STATIC_CAST(PVAviFile*, aFileParser);
-                    iPVWavFile = NULL;
-                    iFileDuration = iPVAviFile->GetFileDuration(); //in sec
-                }
-                break;
-
-                default :
-                    break;
+                iPVWavFile = OSCL_STATIC_CAST(PV_Wav_Parser*, aFileParser);
+                iPVAviFile = NULL;
+                PVWAVFileInfo wavFileInfo;
+                iPVWavFile->RetrieveFileInfo(wavFileInfo);
+                iFileDuration = (OsclFloat)wavFileInfo.NumSamples / wavFileInfo.SampleRate; //in sec
+            }
+            else if (aType == PVMF_MIME_AVIFF)
+            {
+                iPVAviFile = OSCL_STATIC_CAST(PVAviFile*, aFileParser);
+                iPVWavFile = NULL;
+                iFileDuration = (OsclFloat)iPVAviFile->GetFileDuration(); //in sec
             }
 
             iLogger = PVLogger::GetLoggerObject("PVMIOControlComp");
@@ -156,16 +148,13 @@
          */
         bool IsTestInputTypeSupported(PVMFFormatType aType)
         {
-            switch (aType)
+            if (aType == PVMF_MIME_WAVFF ||
+                    aType == PVMF_MIME_AVIFF)
             {
-                case PVMF_WAVFF:
-                case PVMF_AVIFF:
-                {
-                    return true;
-                }
-                default:
-                    return false;
+                return true;
             }
+
+            return false;
         }
 
         /**
@@ -180,6 +169,7 @@
         {
             OSCL_UNUSED_ARG(aFileName);
             int32 error = PVMFFailure;
+
             if (!IsTestInputTypeSupported(aType))
             {
                 return error;
@@ -188,13 +178,26 @@
             uint32 loopCount = 0;
             if (iLoopDuration)
             {
-                loopCount = iLoopDuration / iFileDuration;
+                loopCount = iLoopDuration / (uint32)iFileDuration;
             }
-            switch (aType)
+            if (aType == PVMF_MIME_WAVFF)
             {
-                case PVMF_WAVFF:
+                PvmiMIOControl* mediaInput = PvmiMIOAviWavFileFactory::Create(loopCount, aRecMode, 0, (OsclAny*)iPVWavFile, FILE_FORMAT_WAV, error);
+                if (!mediaInput)
                 {
-                    PvmiMIOControl* mediaInput = PvmiMIOAviWavFileFactory::Create(loopCount, aRecMode, 0, (OsclAny*)iPVWavFile, FILE_FORMAT_WAV, error);
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "CreateMIOInputNode::CreateMIOInputNode: Error - PvmiMIOAviWavFileFactory::Create failed"));
+
+                    return PVMFFailure;
+                }
+
+                iMediaInput.push_back(mediaInput);
+            }
+            else if (aType == PVMF_MIME_AVIFF)
+            {
+                for (uint32 ii = 0; ii < iPVAviFile->GetNumStreams(); ii++)
+                {
+                    PvmiMIOControl* mediaInput = PvmiMIOAviWavFileFactory::Create(loopCount, aRecMode, ii, (OsclAny*)iPVAviFile, FILE_FORMAT_AVI, error);
                     if (!mediaInput)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
@@ -203,34 +206,19 @@
                         return PVMFFailure;
                     }
 
-                    iMediaInput.push_back(mediaInput);
-                }
-                break;
-
-                case PVMF_AVIFF:
-                {
-                    for (uint32 ii = 0; ii < iPVAviFile->GetNumStreams(); ii++)
+                    if (error != PVMFSuccess)
                     {
-                        PvmiMIOControl* mediaInput = PvmiMIOAviWavFileFactory::Create(loopCount, aRecMode, ii, (OsclAny*)iPVAviFile, FILE_FORMAT_AVI, error);
-                        if (!mediaInput)
+                        if (mediaInput)
                         {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                            (0, "CreateMIOInputNode::CreateMIOInputNode: Error - PvmiMIOAviWavFileFactory::Create failed"));
-
-                            return PVMFFailure;
+                            PvmiMIOAviWavFileFactory::Delete(mediaInput);
                         }
 
-                        iMediaInput.push_back(mediaInput);
+                        return error;
                     }
-                }
-                break;
-                default :
-                    break;
-            }
 
-            if (error != PVMFSuccess)
-            {
-                return error;
+                    iMediaInput.push_back(mediaInput);
+
+                }
             }
 
             for (uint32 ii = 0; ii < iMediaInput.size(); ii++)
@@ -255,14 +243,22 @@
         void DeleteInputNode()
         {
             uint32 ii = 0;
-            for (ii = 0; ii < iMIONode.size() ; ii++)
+            if (iMIONode.size() > 0)
             {
-                PvmfMediaInputNodeFactory::Delete(iMIONode[ii]);
+                for (ii = 0; ii < iMIONode.size() ; ii++)
+                {
+                    PvmfMediaInputNodeFactory::Delete(iMIONode[ii]);
+                }
+                iMIONode.destroy();
             }
 
-            for (ii = 0; ii < iMediaInput.size(); ii++)
+            if (iMediaInput.size() > 0)
             {
-                PvmiMIOAviWavFileFactory::Delete(iMediaInput[ii]);
+                for (ii = 0; ii < iMediaInput.size(); ii++)
+                {
+                    PvmiMIOAviWavFileFactory::Delete(iMediaInput[ii]);
+                }
+                iMediaInput.destroy();
             }
 
         }
@@ -285,12 +281,13 @@
 {
     public:
         PVMediaInputAuthorEngineTest(PVMediaInputAuthorEngineTestParam aTestParam):
+                PVLoggerSchedulerSetup(),
                 iCurrentTest(NULL),
 
-                PVLoggerSchedulerSetup(aTestParam.iLogFile, aTestParam.iLogLevel, aTestParam.iLogNode),
                 iFirstTest(aTestParam.iFirstTest),
                 iLastTest(aTestParam.iLastTest),
                 iNextTestCase(aTestParam.iFirstTest),
+                iAsap(aTestParam.iAsap),
                 iFile(aTestParam.iMediainputParam.iFile),
                 iMediaInputParam(aTestParam.iMediainputParam)
         {};
@@ -299,12 +296,15 @@
         virtual void test();
         virtual void CompleteTest(test_case& arTC);
         void RunTestCases();
+        bool	 Set_Default_Params(int32 aTestnum, PVMediaInputTestParam& aMediaInputParam);
+        void Print_TestCase_Name(int32 aTestnum);
 
     private:
         pvauthor_async_test_base* iCurrentTest;
         int32                     iFirstTest;
         int32                     iLastTest;
         int32                     iNextTestCase;
+        bool					  iAsap;
         FILE*                     iFile;
         // For test results
         int                       iTotalSuccess;
diff --git a/engines/author/test/test_input/amrtestinput.amr b/engines/author/test/test_input/amrtestinput.amr
old mode 100755
new mode 100644
Binary files differ
diff --git a/engines/author/test/test_input/audioonly.wav b/engines/author/test/test_input/audioonly.wav
new file mode 100644
index 0000000..f900b39
--- /dev/null
+++ b/engines/author/test/test_input/audioonly.wav
Binary files differ
diff --git a/engines/author/test/test_input/h263testinput.m4v b/engines/author/test/test_input/h263testinput.m4v
old mode 100755
new mode 100644
Binary files differ
diff --git a/engines/author/test/test_input/m4vtestinput.m4v b/engines/author/test/test_input/m4vtestinput.m4v
old mode 100755
new mode 100644
Binary files differ
diff --git a/engines/author/test/test_input/pcm16testinput.pcm b/engines/author/test/test_input/pcm16testinput.pcm
old mode 100755
new mode 100644
Binary files differ
diff --git a/engines/author/test/test_input/readme.txt b/engines/author/test/test_input/readme.txt
old mode 100755
new mode 100644
diff --git a/engines/author/test/test_input/testoutput_IYUV_8k_16_mono.avi b/engines/author/test/test_input/testoutput_IYUV_8k_16_mono.avi
new file mode 100644
index 0000000..eee636d
--- /dev/null
+++ b/engines/author/test/test_input/testoutput_IYUV_8k_16_mono.avi
Binary files differ
diff --git a/engines/author/test/test_input/videoonly.avi b/engines/author/test/test_input/videoonly.avi
new file mode 100644
index 0000000..028070f
--- /dev/null
+++ b/engines/author/test/test_input/videoonly.avi
Binary files differ
diff --git a/engines/author/test/test_input/yuvtestinput.yuv b/engines/author/test/test_input/yuvtestinput.yuv
old mode 100755
new mode 100644
Binary files differ
diff --git a/engines/common/Android.mk b/engines/common/Android.mk
index 72cb35c..8958d1d 100644
--- a/engines/common/Android.mk
+++ b/engines/common/Android.mk
@@ -1,26 +1,33 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_SRC_FILES := \
+ 	
 
 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
 
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/common/include \
-	$(PV_TOP)//engines/common/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/engines/common/src \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pv_common_types.h \
-	include/pv_config_interface.h \
-	include/pv_engine_observer.h \
-	include/pv_engine_observer_message.h \
-	include/pv_engine_types.h \
-	include/pv_interface_cmd_message.h
+ 	include/pv_config_interface.h \
+ 	include/pv_engine_observer.h \
+ 	include/pv_engine_observer_message.h \
+ 	include/pv_engine_types.h \
+ 	include/pv_interface_cmd_message.h
 
 include $(BUILD_COPY_HEADERS)
-
diff --git a/engines/common/build/make/local.mk b/engines/common/build/make/local.mk
new file mode 100644
index 0000000..3b60e94
--- /dev/null
+++ b/engines/common/build/make/local.mk
@@ -0,0 +1,28 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := 
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := 
+
+HDRS := \
+	pv_common_types.h \
+	pv_config_interface.h \
+	pv_engine_observer.h \
+	pv_engine_observer_message.h \
+	pv_engine_types.h \
+	pv_interface_cmd_message.h
+
+
+
+include $(MK)/library.mk
+install:: headers-install
+
+ 
diff --git a/engines/common/build/make/makefile b/engines/common/build/make/makefile
deleted file mode 100755
index 92e5f69..0000000
--- a/engines/common/build/make/makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-# Warning: This is just for the header installed in the common directory
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = 
-
-
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =
-
-
-HDRS =  \
-	pv_common_types.h \
-	pv_config_interface.h \
-	pv_engine_observer.h \
-	pv_engine_observer_message.h \
-	pv_engine_types.h \
-	pv_interface_cmd_message.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-install:: headers-install
-
- 
diff --git a/engines/common/include/pv_common_types.h b/engines/common/include/pv_common_types.h
index 9804c07..d3c7d44 100644
--- a/engines/common/include/pv_common_types.h
+++ b/engines/common/include/pv_common_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -219,7 +219,7 @@
         ~CPVCmnAsyncEvent() {}
 
         /**
-         * @return Returns the Event type that has been recieved
+         * @return Returns the Event type that has been received
          */
         TPVCmnEventType GetEventType()const
         {
diff --git a/engines/common/include/pv_config_interface.h b/engines/common/include/pv_config_interface.h
index 53be2d2..dfcb792 100644
--- a/engines/common/include/pv_config_interface.h
+++ b/engines/common/include/pv_config_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/common/include/pv_engine_observer.h b/engines/common/include/pv_engine_observer.h
index e1fe8aa..5a730cb 100644
--- a/engines/common/include/pv_engine_observer.h
+++ b/engines/common/include/pv_engine_observer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/common/include/pv_engine_observer_message.h b/engines/common/include/pv_engine_observer_message.h
index 52ebb42..297fdef 100644
--- a/engines/common/include/pv_engine_observer_message.h
+++ b/engines/common/include/pv_engine_observer_message.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -173,7 +173,7 @@
         }
 
         /**
-         * @return Returns the Event type that has been recieved
+         * @return Returns the Event type that has been received
          */
         PVEventType GetEventType()const
         {
@@ -237,7 +237,7 @@
         }
 
         /**
-         * @return Returns the Event type that has been recieved
+         * @return Returns the Event type that has been received
          */
         PVEventType GetEventType()const
         {
diff --git a/engines/common/include/pv_engine_types.h b/engines/common/include/pv_engine_types.h
index dc7c961..ae96eb9 100644
--- a/engines/common/include/pv_engine_types.h
+++ b/engines/common/include/pv_engine_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/common/include/pv_interface_cmd_message.h b/engines/common/include/pv_interface_cmd_message.h
index 739ac75..64ac94b 100644
--- a/engines/common/include/pv_interface_cmd_message.h
+++ b/engines/common/include/pv_interface_cmd_message.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,10 @@
 #include "pv_common_types.h"
 #endif
 
+#ifndef PV_ENGINE_TYPES_H_INCLUDED
+#include "pv_engine_types.h"
+#endif
+
 /**
  * CPVInterfaceCmdMessage Class
  *
@@ -35,7 +39,7 @@
 class CPVCmnInterfaceCmdMessage
 {
     public:
-        CPVCmnInterfaceCmdMessage(TPVCmnCommandType aType,
+        CPVCmnInterfaceCmdMessage(int aType,
                                   OsclAny* aContextData) : iId(0),
                 iType(aType),
                 iPriority(0),
@@ -45,11 +49,11 @@
 
         virtual ~CPVCmnInterfaceCmdMessage() {};
 
-        TPVCmnCommandId GetCommandId()
+        PVCommandId GetCommandId()
         {
             return iId;
         }
-        TPVCmnCommandType GetType()
+        int GetType()
         {
             return iType;
         }
@@ -78,18 +82,18 @@
 
         friend int32 operator<(const CPVCmnInterfaceCmdMessage& a, const CPVCmnInterfaceCmdMessage& b);
 
-        void SetId(TPVCmnCommandId aId)
+        void SetId(PVCommandId aId)
         {
             iId = aId;
         }
 
     protected:
-        TPVCmnCommandId iId;
-        TPVCmnCommandType iType;
+        PVCommandId iId;
+        int iType;
         int32 iPriority;
         OsclAny* iContextData;
 
-        friend class CPVInterfaceProxy;
+        friend class PVInterfaceProxy;
 };
 
 inline int32 operator<(const CPVCmnInterfaceCmdMessage& a, const CPVCmnInterfaceCmdMessage& b)
@@ -110,7 +114,6 @@
         return false;
     }
 }
-
 #endif
 
 
diff --git a/engines/common/include/pv_plugin_interfaces.h b/engines/common/include/pv_plugin_interfaces.h
index 42666ee..1b5c5e8 100644
--- a/engines/common/include/pv_plugin_interfaces.h
+++ b/engines/common/include/pv_plugin_interfaces.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/Android.mk b/engines/player/Android.mk
index 4f9a450..8033abc 100644
--- a/engines/player/Android.mk
+++ b/engines/player/Android.mk
@@ -3,70 +3,44 @@
 
 LOCAL_SRC_FILES := \
 	src/pv_player_datapath.cpp \
-	src/pv_player_engine.cpp \
-	src/pv_player_factory.cpp
+ 	src/pv_player_engine.cpp \
+ 	src/pv_player_factory.cpp \
+ 	src/pv_player_node_registry.cpp \
+ 	src/../config/core/pv_player_node_registry_populator.cpp
 
 
-ifeq ($(FORMAT),nj)
-    LOCAL_SRC_FILES += src/../config/linux_nj/pv_player_node_registry.cpp
-else
-    LOCAL_SRC_FILES += src/../config/linux_nj/pv_player_node_registry.cpp
-endif
-
 LOCAL_MODULE := libpvplayer_engine
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/player/include \
-	$(PV_TOP)//engines/player/src \
-	$(PV_TOP)//engines/player/../common/include \
-	$(PV_TOP)/baselibs/media_data_structures/src \
-	$(PV_TOP)/nodes/pvaudioplayernode/include \
-	$(PV_TOP)/codecs_v2/audio/aac_mpeg4/AAC_baseline/pv_aac_dec/cpp/include/ \
-	$(PV_TOP)/codecs_v2/audio/aac_mpeg4/AAC_baseline/pv_aac_dec/c/include/ \
-	$(PV_TOP)/codecs_v2/audio/mp3/thompson/include \
-	$(PV_TOP)/nodes/pvmediaoutputnode/src \
-	$(PV_TOP)/nodes/common/include \
-	$(PV_TOP)/pvmi/pvmf/include \
-	$(PV_TOP)/nodes/pvwmadecnode/include \
-	$(PV_TOP)/nodes/pvwmvdecnode/include \
-	$(PV_TOP)/nodes/pvasfffparsernode/include \
-	$(PV_TOP)/codecs_v2/wmv_decoder/include \
-	$(PV_TOP)/codecs_v2/wma_decoder/include \
-	$(PV_TOP)/fileformats/asf/parser/include \
-	$(PV_TOP)/pvmi/recognizer/include \
-	$(PV_TOP)/pvmi/recognizer/plugins/pvasfffrecognizer/include \
-	$(PV_TOP)/pvmi/recognizer/plugins/pvmp4ffrecognizer/include \
-	$(PV_TOP)/pvmi/recognizer/plugins/pvmp3ffrecognizer/include \
-	$(PV_INCLUDES) 
-
-ifeq ($(ARCHITECTURE),linux_nj)
-    LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/config/linux_nj
-else
-	ifeq ($(FORMAT),nj)
-    	LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/config/linux_nj
-	else
-    	LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/config/linux_nj
-	endif
-endif
+	$(PV_TOP)/engines/player/src \
+ 	$(PV_TOP)/engines/player/include \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_TOP)/engines/player/config/core \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pv_player_datasinkfilename.h \
-	include/pv_player_datasource.h \
-	include/pv_player_events.h \
-	include/pv_player_factory.h \
-	include/pv_player_datasink.h \
-	include/pv_player_datasourcepvmfnode.h \
-	include/pv_player_interface.h \
-	include/pv_player_datasinkpvmfnode.h \
-	include/pv_player_datasourceurl.h \
-	include/pv_player_types.h \
-	include/pv_player_license_acquisition_interface.h \
-	include/pv_player_track_selection_interface.h \
-	include/pv_player_registry_interface.h
+ 	include/pv_player_datasource.h \
+ 	include/pv_player_events.h \
+ 	include/pv_player_factory.h \
+ 	include/pv_player_datasink.h \
+ 	include/pv_player_datasourcepvmfnode.h \
+ 	include/pv_player_interface.h \
+ 	include/pv_player_datasinkpvmfnode.h \
+ 	include/pv_player_datasourceurl.h \
+ 	include/pv_player_types.h \
+ 	include/pv_player_license_acquisition_interface.h \
+ 	include/pv_player_track_selection_interface.h \
+ 	include/pv_player_registry_interface.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/engines/player/build/linux_nj/makefile b/engines/player/build/linux_nj/makefile
deleted file mode 100644
index 286d59d..0000000
--- a/engines/player/build/linux_nj/makefile
+++ /dev/null
@@ -1,198 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pv
-
-export FORMAT=nj
-LIBDIRS = \
-    ../../../../oscl/oscl/osclbase/build/make \
-    ../../../../oscl/oscl/osclerror/build/make \
-    ../../../../oscl/oscl/osclmemory/build/make \
-    ../../../../oscl/oscl/osclutil/build/make \
-    ../../../../oscl/pvlogger/build/make \
-    ../../../../oscl/oscl/osclproc/build/make \
-    ../../../../oscl/oscl/osclio/build/make \
-    ../../../../oscl/oscl/osclregcli/build/make \
-    ../../../../oscl/oscl/osclregserv/build/make \
-    ../../../../oscl/unit_test/build/make \
-    ../../../../oscl/oscl/oscllib/build/make \
-    ../../../../codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make \
-    ../../../../codecs_v2/video/avc_h264/dec/build/make \
-    ../../../../codecs_v2/video/avc_h264/common/build/make \
-    ../../../../codecs_v2/audio/aac/dec/build/make \
-    ../../../../codecs_v2/audio/gsm_amr/amr_nb/dec/build/make \
-    ../../../../codecs_v2/audio/gsm_amr/amr_nb/common/build/make \
-    ../../../../codecs_v2/audio/gsm_amr/amr_wb/dec/build/make \
-    ../../../../codecs_v2/audio/gsm_amr/common/dec/build/make \
-    ../../../../codecs_v2/audio/mp3/dec/build/make \
-    ../../../../codecs_v2/audio/wma/dec/build/make \
-    ../../../../codecs_v2/video/m4v_h263/dec/build/make \
-    ../../../../codecs_v2/video/wmv_vc1/dec/build/make \
-    ../../../../codecs_v2/utilities/m4v_config_parser/build/make \
-    ../../../../codecs_v2/utilities/pv_video_config_parser/build/make \
-    ../../../../codecs_v2/utilities/colorconvert/build/make \
-    ../../../../codecs_v2/omx/omx_common/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_queue/build/make \
-    ../../../../codecs_v2/omx/omx_aac/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_amr/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_mp3/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_h264/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_m4v/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_wmv/build/make_multithreaded \
-    ../../../../codecs_v2/omx/omx_proxy/build/make \
-    ../../../../codecs_v2/omx/factories/omx_m4v_factory/build/make \
-    ../../../../codecs_v2/omx/factories/omx_wmv_factory/build/make \
-    ../../../../baselibs/threadsafe_callback_ao/build/make \
-    ../../../../baselibs/media_data_structures/build/make \
-    ../../../../baselibs/gen_data_structures/build/make \
-    ../../../../baselibs/gen_data_structures/bitstreamparser/build/make \
-    ../../../../baselibs/pv_mime_utils/build/make \
-    ../../../../baselibs/pvcrypto/build/make \
-    ../../../../baselibs/csprng/build/make \
-    ../../../../baselibs/entropy_source/oscl/build/make \
-    ../../../../pvmi/pvmf/build/make \
-    ../../../../nodes/common/build/make \
-    ../../../../pvmi/content_policy_manager/build/make \
-    ../../../../pvmi/content_policy_manager/plugins/oma1/passthru/build/make \
-    ../../../../pvmi/content_policy_manager/plugins/common/build/make \
-    ../../../../pvmi/media_io/pvmiofileoutput/build/make \
-    ../../../../protocols/rtp/build/make \
-    ../../../../protocols/rtp_payload_parser/util/build/latmparser/make \
-    ../../../../protocols/sdp/parser/build/make \
-    ../../../../protocols/rtcp/build/make \
-    ../../../../protocols/rtp_payload_parser/build/linux_3gpp \
-    ../../../../protocols/rtsp_parcom/build/make \
-    ../../../../protocols/rtsp_client_engine/build/make_3gpp \
-    ../../../../protocols/http_parcom/build/make \
-    ../../../../fileformats/common/parser/build/make \
-    ../../../../fileformats/id3parcom/build/make \
-    ../../../../fileformats/rawgsmamr/parser/build/make \
-    ../../../../fileformats/mp3/parser/build/make \
-    ../../../../fileformats/mp4/parser/build/make \
-    ../../../../fileformats/rawaac/parser/build/make \
-    ../../../../fileformats/pvx/parser/build/make \
-    ../../../../fileformats/wav/parser/build/make \
-    ../../../../fileformats/asf/parser/build/make \
-    ../../../../nodes/pvaacffparsernode/build/make \
-    ../../../../nodes/pvwmadecnode/build/make \
-    ../../../../nodes/pvmp3ffparsernode/build/make \
-    ../../../../nodes/pvasfffparsernode/build/make \
-    ../../../../nodes/pvamrffparsernode/build/make \
-    ../../../../nodes/pvmp4ffparsernode/build/make \
-    ../../../../nodes/pvsocketnode/build/make \
-    ../../../../nodes/pvdownloadmanagernode/build/make \
-    ../../../../nodes/pvprotocolenginenode/build/make \
-    ../../../../nodes/streaming/jitterbuffernode/build/make \
-    ../../../../nodes/streaming/medialayernode/build/make \
-    ../../../../nodes/streaming/streamingmanager/build/linux_3gpp \
-    ../../../../nodes/pvmediaoutputnode/build/make \
-    ../../../../nodes/pvfileoutputnode/build/make \
-    ../../../../nodes/pvomxaudiodecnode/build/make \
-    ../../../../nodes/pvomxvideodecnode/build/make \
-    ../../../../nodes/pvwavffparsernode/build/make \
-    ../../../../pvmi/recognizer/build/make \
-    ../../../../pvmi/recognizer/plugins/pvamrffrecognizer/build/make \
-    ../../../../pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make \
-    ../../../../pvmi/recognizer/plugins/pvasfffrecognizer/build/make \
-    ../../../../pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make \
-    ../../../../pvmi/recognizer/plugins/pvwavffrecognizer/build/make \
-    ../../../../engines/common/build/make \
-    ../../../../pvmi/recognizer/build/make \
-    ../../../../engines/common/build/make \
-    ../../../../engines/adapters/player/framemetadatautility/build/make \
-    ../make \
-    ../../../../pvmi/database/build/make \
-
-LIBS = \
-    -lpvplayer_engine \
-    -lpvfileoutputnode \
-    -lpvasfffparsernode \
-    -lpvmp3ffparsernode \
-    -lpvwmadecnode \
-    -lpvdownloadmanagernode \
-    -lpvmp4ffparsernode \
-    -lcpm \
-    -lpassthru_oma1 \
-    -lpvaacffparsernode \
-    -lpvmp3ff \
-    -lpvasfff \
-    -lpvmp4ff \
-    -lpvaacparser \
-    -lgetactualaacconfig \
-    -lomx_mp3_component_lib \
-    -lpvmp3 \
-    -lwmadecoder \
-    -lpvwavffparsernode \
-    -lpvwav \
-    -lpvomxaudiodecnode \
-    -lpvomxvideodecnode \
-    -lpv_video_config_parser \
-    -lm4v_config \
-    -lpvlogger \
-    -lpvstreamingmanagernode_3gpp \
-    -lpvjitterbuffernode \
-    -lpvmediaplayernode \
-    -lrtprtcp \
-    -lpvrtsp_cli_eng_node_3gpp \
-    -lprotocolenginenode \
-    -lpv_http_parcom \
-    -lpvsocketnode \
-    -lrtppayloadparser_3gpp \
-    -lpvmf \
-    -lpvsdpparser \
-    -lpv_rtsp_parcom \
-    -lomx_common_lib \
-    -lomx_avc_component_lib \
-    -lpvavcdecoder \
-    -lpv_avc_common_lib \
-    -lomx_m4v_component_lib \
-    -lpvmp4decoder \
-    -lomx_wmv_component_lib \
-    -lwmvdecoder \
-    -lomx_amr_component_lib \
-    -lpvdecoder_gsmamr \
-    -lpv_amr_nb_common_lib \
-    -lpvamrwbdecoder \
-    -lomx_aac_component_lib \
-    -lpv_aac_dec \
-    -lfile_mediaio \
-    -lpvgendatastruct \
-    -lpvmimeutils \
-    -lpvmediaoutputnode \
-    -lpvmediadatastruct \
-    -lpvamrffparsernode \
-    -lpvgsmamrparser \
-    -lpvlatmpayloadparser \
-    -lpvmfrecognizer \
-    -lpvamrffrecognizer \
-    -lpvmp3ffrecognizer \
-    -lpvasfffrecognizer \
-    -lpvmp4ffrecognizer \
-    -lpvwavffrecognizer \
-    -lpvfileparserutils \
-    -lpvid3parcom \
-    -lpvdbmanager \
-    -lcsprng \
-    -lpvcrypto \
-    -lpventropysrc \
-    -losclregcli \
-    -losclregserv \
-    -losclio \
-    -loscllib \
-    -losclproc \
-    -losclutil \
-    -losclmemory \
-    -losclerror \
-    -losclbase \
-    -lpvomx_proxy_lib \
-    -lomx_queue_lib \
-    -lthreadsafe_callback_ao \
-
-
-# use --allow-multiple-definition to get around aac decoder and
-# getactualaacconfig building the same code
-XLDFLAGS += -Wl,--allow-multiple-definition
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/engines/player/build/make/local.mk b/engines/player/build/make/local.mk
new file mode 100644
index 0000000..8b0841e
--- /dev/null
+++ b/engines/player/build/make/local.mk
@@ -0,0 +1,58 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvplayer_engine
+
+XINCDIRS += ../../../common/include
+
+XINCDIRS +=  ../../config/core 
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_player_datapath.cpp \
+	pv_player_engine.cpp \
+	pv_player_factory.cpp \
+        pv_player_node_registry.cpp
+
+ifeq ($(BUILD_ARCH),ms_vc2005)
+  SRCS += ../config/ms_vc2005_all/pv_player_node_registry_populator.cpp
+else
+  SRCS += ../config/core/pv_player_node_registry_populator.cpp
+endif
+
+HDRS := pv_player_datasinkfilename.h \
+	pv_player_datasource.h \
+        pv_player_events.h \
+	pv_player_factory.h \
+	pv_player_datasink.h \
+	pv_player_datasourcepvmfnode.h \
+	pv_player_interface.h \
+	pv_player_datasinkpvmfnode.h \
+	pv_player_datasourceurl.h \
+	pv_player_types.h \
+	pv_player_license_acquisition_interface.h \
+	pv_player_track_selection_interface.h \
+	pv_player_registry_interface.h
+
+include $(MK)/library.mk
+
+doc_target := pvplayer_engine
+doc_title := "PV Player Engine"
+doc_paths := "$(SRC_ROOT)/engines/player/include/pv_player_interface.h"
+doc_version := $(PVPLAYER_ENGINE_VERSION)
+
+include $(MK)/doc.mk
+
+sdkinfo_target := $(LOCAL_SRCDIR)/pv_player_engine.cpp
+sdkinfo_header_filename := $(LOCAL_SRCDIR)/pv_player_sdkinfo.h
+sdkinfo_header_macro := PV_PLAYER_SDKINFO
+sdkinfo_label_macro := PVPLAYER_ENGINE_SDKINFO_LABEL
+sdkinfo_date_macro := PVPLAYER_ENGINE_SDKINFO_DATE
+
+include $(MK)/sdkinfo.mk
+
diff --git a/engines/player/build/make/makefile b/engines/player/build/make/makefile
deleted file mode 100644
index 374884a..0000000
--- a/engines/player/build/make/makefile
+++ /dev/null
@@ -1,94 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvplayer_engine
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-XINCDIRS += -I../../../common/include -I $(VOB_BASE_DIR)/baselibs/media_data_structures/src -I $(VOB_BASE_DIR)/nodes/pvaudioplayernode/include -I $(VOB_BASE_DIR)/codecs_v2/audio/aac_mpeg4/AAC_baseline/pv_aac_dec/cpp/include/ -I $(VOB_BASE_DIR)/codecs_v2/audio/aac_mpeg4/AAC_baseline/pv_aac_dec/c/include/ -I $(VOB_BASE_DIR)/codecs_v2/audio/mp3/thompson/include -I $(VOB_BASE_DIR)/nodes/pvmediaoutputnode/src -I $(VOB_BASE_DIR)/nodes/common/include -I $(VOB_BASE_DIR)/pvmi/pvmf/include -I $(VOB_BASE_DIR)/nodes/pvwmadecnode/include -I $(VOB_BASE_DIR)/nodes/pvwmvdecnode/include -I $(VOB_BASE_DIR)/nodes/pvasfffparsernode/include -I $(VOB_BASE_DIR)/codecs_v2/wmv_decoder/include -I $(VOB_BASE_DIR)/codecs_v2/wma_decoder/include -I $(VOB_BASE_DIR)/fileformats/asf/parser/include -I $(VOB_BASE_DIR)/pvmi/recognizer/include -I $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvasfffrecognizer/include -I $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvmp4ffrecognizer/include -I $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvmp3ffrecognizer/include
-
-ifeq ($(ARCHITECTURE),linux_nj)
-    XINCDIRS += -I ../../config/$(BUILD_ARCH)
-else
-	ifeq ($(FORMAT),nj)
-    	XINCDIRS += -I ../../config/linux_nj
-	else
-    	XINCDIRS += -I ../../config/$(BUILD_ARCH)
-	endif
-endif
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pv_player_datapath.cpp \
-	pv_player_engine.cpp \
-	pv_player_factory.cpp
-#pv_player_datasink_factory.cpp
-
-
-ifeq ($(FORMAT),nj)
-    SRCS += ../config/linux_nj/pv_player_node_registry.cpp
-else
-    SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry.cpp
-endif
-
-HDRS =  pv_player_datasinkfilename.h \
-	pv_player_datasource.h \
-        pv_player_events.h \
-	pv_player_factory.h \
-	pv_player_datasink.h \
-	pv_player_datasourcepvmfnode.h \
-	pv_player_interface.h \
-	pv_player_datasinkpvmfnode.h \
-	pv_player_datasourceurl.h \
-	pv_player_types.h \
-	pv_player_license_acquisition_interface.h \
-	pv_player_track_selection_interface.h \
-	pv_player_registry_interface.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
-doc:
-	 perl $(VOB_BASE_DIR)/tools_v2/build/document/bin/doc_build.bat --doctype pvplayer_engine --title "PV Player Engine" --path "$(VOB_BASE_DIR)/engines/common/include $(VOB_BASE_DIR)/engines/player/include" --filetype "mainpage *.h readme.txt" --exclude_pattern "*/test/* */obsolete/* */doxydir/*" -ver $(PVPLAYER_ENGINE_VERSION)
-
diff --git a/engines/player/build/make/makefile_all b/engines/player/build/make/makefile_all
index b722399..e91b0a9 100644
--- a/engines/player/build/make/makefile_all
+++ b/engines/player/build/make/makefile_all
@@ -32,6 +32,17 @@
 #XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
 
 
+#ifeq ($(ARCHITECTURE),panasonic_arm)
+#XINCDIRS += -I ../../config/$(BUILD_ARCH)
+#else
+#   ifeq ($(ARCHITECTURE),panasonic_pc)
+#      XINCDIRS += -I ../../config/$(BUILD_ARCH)
+#   else
+#      XINCDIRS += -I ../../config/linux
+#   endif
+#endif
+
+
 # Use XLIBDIRS for extra library directories. These should be proceeded 
 # with "-L" just as they would be when passing to the linker. 
 # Used for building executables.
diff --git a/engines/player/build/make/player_config.mk b/engines/player/build/make/player_config.mk
new file mode 100644
index 0000000..7401eae
--- /dev/null
+++ b/engines/player/build/make/player_config.mk
@@ -0,0 +1,107 @@
+# The conditions in this makefile fragment would be removed once
+# the projects are configured using CML2.
+# It is not allowed to add any more conditions in this file.
+
+# Add the include path based on project to pick the right tunable and config header
+#
+ifeq ($(ARCHITECTURE),linux_nj)
+    XINCDIRS += -I ../../config/$(BUILD_ARCH)
+else
+    ifeq ($(FORMAT),3gpp)
+        XINCDIRS += -I ../../config/linux_3gpp
+    else
+        ifeq ($(ARCHITECTURE),panasonic_arm)
+            XINCDIRS += -I ../../config/$(BUILD_ARCH)
+         else
+            ifeq ($(ARCHITECTURE),panasonic_pc)
+                XINCDIRS += -I ../../config/$(BUILD_ARCH)
+            else
+                ifeq ($(ARCHITECTURE),nec_hsdpa_linux)
+                    XINCDIRS += -I ../../config/$(BUILD_ARCH)
+                else
+                    ifeq ($(ARCHITECTURE),nec_hsdpa_arm)
+                        XINCDIRS += -I ../../config/$(BUILD_ARCH)
+                    else
+                        ifeq ($(FORMAT),real)
+                            XINCDIRS += -I ../../config/linux_real
+                        else
+                            ifeq ($(FORMAT),asf)
+                                XINCDIRS += -I ../../config/linux_asf
+                            else
+                                ifeq ($(ARCHITECTURE),necel_arm)
+                                    XINCDIRS += -I ../../config/$(BUILD_ARCH)
+                                else
+                                    ifeq ($(FORMAT),nj)
+                                        XINCDIRS += -I ../../config/linux_nj
+                                    else
+                                        ifeq ($(ARCHITECTURE),farnsworth_arm)
+                                            XINCDIRS += -I ../../config/$(BUILD_ARCH)
+                                        else
+                                            ifeq ($(FORMAT),linux_non_omx)
+                                                XINCDIRS += -I ../../config/linux_non_omx
+                                            else
+                                                XINCDIRS += -I ../../config/linux
+                                            endif
+                                        endif
+                                    endif
+                                endif
+                            endif
+                        endif
+                    endif
+                endif
+            endif
+         endif
+    endif
+endif
+
+# Pick the node registry based on project
+#
+ifeq ($(USE_CML2_CONFIG), 1)
+    SRCS += ../config/core/pv_player_node_registry_populator.cpp
+else
+    ifeq ($(ARCHITECTURE),panasonic_arm)
+        SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry_populator.cpp
+    else
+        ifeq ($(ARCHITECTURE),panasonic_pc)
+    	    SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry_populator.cpp
+		else
+            ifeq ($(ARCHITECTURE),nec_hsdpa_linux)
+	        	SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry_populator.cpp
+	        else
+    	        ifeq ($(ARCHITECTURE),nec_hsdpa_arm)
+        	        SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry_populator.cpp
+            	else
+	                ifeq ($(FORMAT),real)
+    	                SRCS += ../config/linux_real/pv_player_node_registry_populator.cpp
+        	        else
+            	        ifeq ($(FORMAT),asf)
+                	        SRCS += ../config/linux_asf/pv_player_node_registry_populator.cpp
+                    	else
+	                        ifeq ($(ARCHITECTURE),necel_arm)
+    	                        SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry_populator.cpp
+        	                else
+            	                ifeq ($(FORMAT),nj)
+                	                SRCS += ../config/linux_nj/pv_player_node_registry_populator.cpp
+                    	        else
+                        	        ifeq ($(ARCHITECTURE),farnsworth_arm)
+                            	        SRCS += ../config/$(BUILD_ARCH)/pv_player_node_registry_populator.cpp
+                                	else
+	                                    ifeq ($(FORMAT),linux_non_omx)
+    	                                    SRCS += ../config/linux_non_omx/pv_player_node_registry_populator.cpp
+        	                            else
+            	                            ifeq ($(FORMAT),3gpp)
+                	                            SRCS += ../config/linux_3gpp/pv_player_node_registry_populator.cpp
+                    	                    else
+                        	                    SRCS += ../config/linux/pv_player_node_registry_populator.cpp
+                            	            endif
+                                	    endif
+	                                endif
+    	                        endif 
+        	                endif
+            	        endif
+                	endif
+	            endif
+    	    endif
+	    endif
+	endif
+endif
diff --git a/engines/player/build/makefile.conf b/engines/player/build/makefile.conf
deleted file mode 100644
index f495372..0000000
--- a/engines/player/build/makefile.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-include $(CFG_DIR)/custom.mk
-include $(CFG_DIR)/config.out
-
-LIBDIRS   += $(foreach lib, $(subst ", ,$(LIBDIR_y)), $(VOB_BASE_DIR)$(lib))
-LIBDIRS-m += $(foreach lib, $(subst ", ,$(LIBDIR_m)), $(VOB_BASE_DIR)$(lib))
-
-include $(MK)/recursive.mk
diff --git a/engines/player/config/core/pv_player_config.h b/engines/player/config/core/pv_player_config.h
new file mode 100644
index 0000000..030f3e0
--- /dev/null
+++ b/engines/player/config/core/pv_player_config.h
@@ -0,0 +1,95 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_PLAYER_CONFIG_H_INCLUDED
+#define PV_PLAYER_CONFIG_H_INCLUDED
+
+// Configuration flags for pvplayerengine are set in this header file
+
+
+// Playback rate range
+#define PVP_PBRATE_MIN 0
+#define PVP_PBRATE_MAX 500000
+
+// Playback position status event unit
+// Default
+#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSUNIT_DEF PVPPBPOSUNIT_MILLISEC
+#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSUNIT_DEF_STRING "PVPPBPOSUNIT_MILLISEC"
+// Capability
+#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_CAP_STRING "PVPPBPOSUNIT_MILLISEC;PVPPBPOSUNIT_SEC;PVPPBPOSUNIT_MIN"
+
+// Playback position status event interval in milliseconds
+// Default
+#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_DEF 1000
+// Min-Max
+#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_MIN 200
+#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_MAX 5000
+
+// End time check interval in milliseconds
+// Default
+#define PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_DEF 1000
+// Min-Max
+#define PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_MIN 200
+#define PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_MAX 5000
+
+// Seek to sync point when repositioning
+#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINT_DEF true
+
+// Whether to render skipped data or not when repositioning
+#define PVPLAYERENGINE_CONFIG_RENDERSKIPPED_DEF false
+
+// Time window when seeking sync point in milliseconds
+// Default
+#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_DEF 0
+// Min-Max
+#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MIN 0
+#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MAX 300000
+
+// Min-Max
+#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_MIN -10000
+#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_MAX 10000
+
+// Node command timeout value in milliseconds
+// Default
+#define PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_DEF 10000
+// Min-Max
+#define PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_MIN 1000
+#define PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_MAX 300000
+
+// Data sink node data queuing timeout value in milliseconds
+// This will be same as threshold value for difference in sync point and actual
+// reposition point in millisec
+// Default is set to maximum value
+#define PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_DEF 5*60*1000
+// Min-Max
+#define PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_MIN 1000
+#define PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_MAX 300000
+
+// Product name info string
+#define PVPLAYERENGINE_PRODINFO_PRODNAME_STRING "pvPlayer v4.0"
+// Part number info string
+#define PVPLAYERENGINE_PRODINFO_PARTNUM_STRING "000000"
+// HW platform info string
+#define PVPLAYERENGINE_PRODINFO_HWPLATFORM_STRING "Unknown"
+// SW platform info string
+#define PVPLAYERENGINE_PRODINFO_SWPLATFORM_STRING "Unknown"
+// Device info string
+#define PVPLAYERENGINE_PRODINFO_DEVICE_STRING "Unknown"
+
+#endif
+
+
diff --git a/engines/player/config/core/pv_player_engine_tunables.h b/engines/player/config/core/pv_player_engine_tunables.h
new file mode 100644
index 0000000..06a646b
--- /dev/null
+++ b/engines/player/config/core/pv_player_engine_tunables.h
@@ -0,0 +1,35 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
+#define PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
+
+
+// Always start from the requested begin position when repositioning
+#define PVPLAYERENGINE_CONFIG_SKIPTOREQUESTEDPOS_DEF true
+
+// Synchronization margin for media tracks in milliseconds
+// Default
+#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_EARLY_DEF -200
+#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_LATE_DEF 200
+
+// Platforms that need the video decoder node priority to be lower than the
+// rest of the nodes need to set the following to 1
+#define VIDEO_DEC_NODE_LOW_PRIORITY 1
+
+#endif // PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
+
diff --git a/engines/player/config/core/pv_player_node_registry_populator.cpp b/engines/player/config/core/pv_player_node_registry_populator.cpp
new file mode 100644
index 0000000..357bba3
--- /dev/null
+++ b/engines/player/config/core/pv_player_node_registry_populator.cpp
@@ -0,0 +1,570 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_player_node_registry.h"
+
+// For decoder node registry
+#if BUILD_OMX_VIDEO_DEC_NODE
+#include "pvmf_omx_videodec_factory.h"
+#endif
+#if BUILD_OMX_AUDIO_DEC_NODE
+#include "pvmf_omx_audiodec_factory.h"
+#endif
+#if BUILD_VIDEO_DEC_NODE
+#include "pvmf_videodec_factory.h"
+#endif
+#if BUILD_AVC_DEC_NODE
+#include "pvmf_avcdec_factory.h"
+#endif
+#if BUILD_WMV_DEC_NODE
+#include "pvmf_wmvdec_factory.h"
+#endif
+#if BUILD_RV_DEC_NODE
+#include "pvmf_rvdec_factory.h"
+#endif
+#if BUILD_WMA_DEC_NODE
+#include "pvmf_wmadec_factory.h"
+#endif
+#if BUILD_G726_DEC_NODE
+#include "pvmf_g726dec_node_factory.h"
+#endif
+#if BUILD_GSMAMR_DEC_NODE
+#include "pvmf_gsmamrdec_factory.h"
+#endif
+#if BUILD_AAC_DEC_NODE
+#include "pvmf_aacdec_factory.h"
+#endif
+#if BUILD_MP3_DEC_NODE
+#include "pvmf_mp3dec_factory.h"
+#endif
+#if BUILD_RA8_DEC_NODE
+#include "pvmf_ra8dec_factory.h"
+#endif
+
+// For parser node registry
+#if BUILD_MP4_FF_PARSER_NODE
+#include "pvmf_mp4ffparser_factory.h"
+#endif
+#if BUILD_AMR_FF_PARSER_NODE
+#include "pvmf_amrffparser_factory.h"
+#endif
+#if BUILD_AAC_FF_PARSER_NODE
+#include "pvmf_aacffparser_factory.h"
+#endif
+#if BUILD_MP3_FF_PARSER_NODE
+#include "pvmf_mp3ffparser_factory.h"
+#endif
+#if BUILD_WAV_FF_PARSER_NODE
+#include "pvmf_wavffparser_factory.h"
+#endif
+#if BUILD_ASF_FF_PARSER_NODE
+#include "pvmf_asfffparser_factory.h"
+#endif
+#if BUILD_RM_FF_PARSER_NODE
+#include "pvmf_rmffparser_factory.h"
+#endif
+#if BUILD_STREAMING_MANAGER_NODE
+#include "pvmf_sm_node_factory.h"
+#endif
+#if BUILD_DOWNLOAD_MANAGER_NODE
+#include "pvmf_downloadmanager_factory.h"
+#endif
+#if BUILD_STILL_IMAGE_NODE
+#include "pvmf_stillimage_factory.h"
+#endif
+
+// For recognizer registry
+#if BUILD_MP4_FF_REC
+#include "pvmp4ffrec_factory.h"
+#endif
+#if BUILD_ASF_FF_REC
+#include "pvasfffrec_factory.h"
+#endif
+#if BUILD_OMA1_FF_REC
+#include "pvoma1ffrec_factory.h"
+#endif
+#if BUILD_AAC_FF_REC
+#include "pvaacffrec_factory.h"
+#endif
+#if BUILD_RM_FF_REC
+#include "pvrmffrec_factory.h"
+#endif
+#if BUILD_MP3_FF_REC
+#include "pvmp3ffrec_factory.h"
+#endif
+#if BUILD_WAV_FF_REC
+#include "pvwavffrec_factory.h"
+#endif
+#if BUILD_AMR_FF_REC
+#include "pvamrffrec_factory.h"
+#endif
+#ifdef USE_LOADABLE_MODULES
+#include "oscl_shared_library.h"
+
+#include "pvmf_node_shared_lib_interface.h"
+#endif
+
+#include "pvmf_recognizer_registry.h"
+
+#include "pvmi_datastreamsyncinterface_ref_factory.h"
+
+#include "pvmf_recognizer_plugin.h"
+
+//#include "pvsdcffrec_factory.h"
+//#include "pvmf_videodec_node.h"
+//#include "pvmf_mp4ffparser_node.h"
+//#include "pvmf_pvciwmvdec_factory.h"
+//#include "pv_devvideoplay_factory.h"
+//#include "pvmf_gsmamrdec_factory_dpi.h"
+//#include "pvmf_aacdec_factory_dpi.h"
+//#include "pvmf_videodec_factory_dpi.h"
+
+void PVPlayerRegistryPopulator::RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    PVPlayerNodeInfo nodeinfo;
+#if BUILD_OMX_VIDEO_DEC_NODE
+    //For PVMFOMXVideoDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H2631998);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H2632000);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_M4V);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H264_VIDEO);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H264_VIDEO_RAW);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H264_VIDEO_MP4);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_WMV);
+    nodeinfo.iNodeUUID = KPVMFOMXVideoDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_YUV420);
+    nodeinfo.iNodeCreateFunc = PVMFOMXVideoDecNodeFactory::CreatePVMFOMXVideoDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFOMXVideoDecNodeFactory::DeletePVMFOMXVideoDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_OMX_AUDIO_DEC_NODE
+    //For PVMFOMXAudioDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMR_IETF);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMR);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMRWB_IETF);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMRWB);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMR_IF2);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_MPEG4_AUDIO);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_ADIF);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_ADTS);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_LATM);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_WMA);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_MP3);
+    nodeinfo.iNodeUUID = KPVMFOMXAudioDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFOMXAudioDecNodeFactory::CreatePVMFOMXAudioDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFOMXAudioDecNodeFactory::DeletePVMFOMXAudioDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_VIDEO_DEC_NODE
+    //For PVMFVideoDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H2631998);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H2632000);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_M4V);
+    nodeinfo.iNodeUUID = KPVMFVideoDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_YUV420);
+    nodeinfo.iNodeCreateFunc = PVMFVideoDecNodeFactory::CreatePVMFVideoDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFVideoDecNodeFactory::DeletePVMFVideoDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_AVC_DEC_NODE
+    //For PVMFAVCDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H264_VIDEO);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H264_VIDEO_RAW);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_H264_VIDEO_MP4);
+    nodeinfo.iNodeUUID = KPVMFAVCDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_YUV420);
+    nodeinfo.iNodeCreateFunc = PVMFAVCDecNodeFactory::CreatePVMFAVCDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFAVCDecNodeFactory::DeletePVMFAVCDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_WMV_DEC_NODE
+    //For PVMFWmvDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_WMV);
+    nodeinfo.iNodeUUID = KPVMFWmvDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_YUV420);
+    nodeinfo.iNodeCreateFunc = PVMFWmvDecNodeFactory::CreatePVMFWmvDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFWmvDecNodeFactory::DeletePVMFWmvDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_RV_DEC_NODE
+    //For PVMFRVDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_REAL_VIDEO);
+    nodeinfo.iNodeUUID = KPVMFRvDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_YUV420);
+    nodeinfo.iNodeCreateFunc = PVMFRvDecNodeFactory::CreatePVMFRvDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFRvDecNodeFactory::DeletePVMFRvDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_WMA_DEC_NODE
+    //For PVMFWmaDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_WMA);
+    nodeinfo.iNodeUUID = KPVMFWMADecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFWMADecNodeFactory::CreatePVMFWMADecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFWMADecNodeFactory::DeletePVMFWMADecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_G726_DEC_NODE
+    //For PVMFG726DecoderNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_G726);
+    nodeinfo.iNodeUUID = PVMFG726DecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFG726DecNodeFactory::Create;
+    nodeinfo.iNodeReleaseFunc = PVMFG726DecNodeFactory::Delete;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_GSMAMR_DEC_NODE
+    //For PVMFGSMAMRDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMR_IETF);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMR);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMRWB_IETF);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMRWB);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMR_IF2);
+    nodeinfo.iNodeUUID = KPVMFGSMAmrNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFGSMAMRDecNodeFactory::CreatePVMFGSMAMRDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFGSMAMRDecNodeFactory::DeletePVMFGSMAMRDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_AAC_DEC_NODE
+    //For PVMFAACDecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_MPEG4_AUDIO);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_ADIF);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_ADTS);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_LATM);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_ASF_MPEG4_AUDIO);
+    nodeinfo.iNodeUUID = KPVMFAACDecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFAACDecNodeFactory::CreatePVMFAACDecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFAACDecNodeFactory::DeletePVMFAACDecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_MP3_DEC_NODE
+    //For PVMFMP3DecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_MP3);
+    nodeinfo.iNodeUUID = KPVMFMP3DecNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFMP3DecNodeFactory::CreatePVMFMP3DecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFMP3DecNodeFactory::DeletePVMFMP3DecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_RA8_DEC_NODE
+    //For PVMFRA8DecNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_REAL_AUDIO);
+    nodeinfo.iNodeUUID = KPVMFRA8NodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_PCM16);
+    nodeinfo.iNodeCreateFunc = PVMFRA8DecNodeFactory::CreatePVMFRA8DecNode;
+    nodeinfo.iNodeReleaseFunc = PVMFRA8DecNodeFactory::DeletePVMFRA8DecNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_MP4_FF_PARSER_NODE
+    //For PVMFMP4FFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_MPEG4FF);
+    nodeinfo.iNodeUUID = KPVMFMP4FFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFMP4FFParserNodeFactory::CreatePVMFMP4FFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFMP4FFParserNodeFactory::DeletePVMFMP4FFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_AMR_FF_PARSER_NODE
+    //For PVMFAMRFFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AMRFF);
+    nodeinfo.iNodeUUID = KPVMFAmrFFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFAMRFFParserNodeFactory::CreatePVMFAMRFFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFAMRFFParserNodeFactory::DeletePVMFAMRFFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_AAC_FF_PARSER_NODE
+    //For PVMFAACFFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_AACFF);
+    nodeinfo.iNodeUUID = KPVMFAacFFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFAACFFParserNodeFactory::CreatePVMFAACFFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFAACFFParserNodeFactory::DeletePVMFAACFFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_MP3_FF_PARSER_NODE
+    //For PVMFMP3FFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_MP3FF);
+    nodeinfo.iNodeUUID = KPVMFMP3FFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFMP3FFParserNodeFactory::CreatePVMFMP3FFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFMP3FFParserNodeFactory::DeletePVMFMP3FFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_WAV_FF_PARSER_NODE
+    //For PVMFWAVFFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_WAVFF);
+    nodeinfo.iNodeUUID = KPVMFWavFFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFWAVFFParserNodeFactory::CreatePVMFWAVFFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFWAVFFParserNodeFactory::DeletePVMFWAVFFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_ASF_FF_PARSER_NODE
+    //For PVMFASFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_ASFFF);
+    nodeinfo.iNodeUUID = KPVMFASFFFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFASFParserNodeFactory::CreatePVMFASFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFASFParserNodeFactory::DeletePVMFASFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_RM_FF_PARSER_NODE
+    //For PVMFRMFFParserNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_RMFF);
+    nodeinfo.iNodeUUID = KPVMFRMFFParserNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFRMFFParserNodeFactory::CreatePVMFRMFFParserNode;
+    nodeinfo.iNodeReleaseFunc = PVMFRMFFParserNodeFactory::DeletePVMFRMFFParserNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_STREAMING_MANAGER_NODE
+    //For PVMFStreamingManagerNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_RTSP_URL);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_SDP_FILE);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_RTP_PACKET_SOURCE);
+    nodeinfo.iNodeUUID = KPVMFStreamingManagerNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFStreamingManagerNodeFactory::CreateStreamingManagerNode;
+    nodeinfo.iNodeReleaseFunc = PVMFStreamingManagerNodeFactory::DeleteStreamingManagerNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_DOWNLOAD_MANAGER_NODE
+    //For PVMFDownloadManagerNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_HTTP_URL);
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_PVX_FILE);
+    nodeinfo.iNodeUUID = KPVMFDownloadManagerNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFDownloadManagerNodeFactory::CreatePVMFDownloadManagerNode;
+    nodeinfo.iNodeReleaseFunc = PVMFDownloadManagerNodeFactory::DeletePVMFDownloadManagerNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+#if BUILD_STILL_IMAGE_NODE
+    //For PVMFStillImageNode
+    nodeinfo.iInputTypes.clear();
+    nodeinfo.iInputTypes.push_back(PVMF_MIME_M4V_IMAGE);
+    nodeinfo.iNodeUUID = KPVMFStillImageNodeUuid;
+    nodeinfo.iOutputType.clear();
+    nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+    nodeinfo.iNodeCreateFunc = PVMFStillImageNodeFactory::CreateStillImageNode;
+    aRegistry->RegisterNode(nodeinfo);
+#endif
+}
+
+void PVPlayerRegistryPopulator::UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aRegistry);
+    OSCL_UNUSED_ARG(aContext);
+    //nothing needed currently.
+}
+
+
+
+
+// Player engine with recognizers
+void PVPlayerRegistryPopulator::RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
+{
+    //Keep a list of all factories allocated by this populator for later cleanup.
+    typedef Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator> nodelistType;
+    nodelistType* nodeList = OSCL_NEW(nodelistType, ());
+    aContext = nodeList;
+
+    PVMFRecognizerPluginFactory* tmpfac = NULL;
+
+#if BUILD_MP4_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVMP4FFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVMP4FFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_ASF_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVASFFFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVASFFFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_OMA1_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVOMA1FFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVOMA1FFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_AAC_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVAACFFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVAACFFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_RM_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVRMFFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVRMFFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_MP3_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVMP3FFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVMP3FFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_WAV_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVWAVFFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVWAVFFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+#if BUILD_AMR_FF_REC
+    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVAMRFFRecognizerFactory, ()));
+    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
+    {
+        aRegistry->RegisterRecognizer(tmpfac);
+        nodeList->push_back(tmpfac);
+    }
+    else
+    {
+        OSCL_DELETE(((PVAMRFFRecognizerFactory*)tmpfac));
+        tmpfac = NULL;
+        return;
+    }
+#endif
+}
+
+
+void PVPlayerRegistryPopulator::UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aRegistry);
+
+    //find the nodes added by this populator & delete them.
+    Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* nodeList = (Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>*) aContext;
+    if (nodeList)
+    {
+        PVMFRecognizerPluginFactory* tmpfac = NULL;
+        while (nodeList->size())
+        {
+            tmpfac = nodeList->front();;
+            nodeList->erase(nodeList->begin());
+            PVMFRecognizerRegistry::RemovePlugin(*tmpfac);
+            OSCL_DELETE(tmpfac);
+        }
+        OSCL_DELETE(nodeList);
+    }
+}
+
diff --git a/engines/player/config/linux_nj/pv_player_config.h b/engines/player/config/linux_nj/pv_player_config.h
deleted file mode 100644
index b9efa90..0000000
--- a/engines/player/config/linux_nj/pv_player_config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_PLAYER_CONFIG_H_INCLUDED
-#define PV_PLAYER_CONFIG_H_INCLUDED
-
-// Configuration flags for pvplayerengine are set in this header file
-
-
-// Playback rate range
-#define PVP_PBRATE_MIN 0
-#define PVP_PBRATE_MAX 500000
-
-#endif
-
-
diff --git a/engines/player/config/linux_nj/pv_player_engine_tunables.h b/engines/player/config/linux_nj/pv_player_engine_tunables.h
deleted file mode 100644
index 3218472..0000000
--- a/engines/player/config/linux_nj/pv_player_engine_tunables.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
-#define PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
-
-
-// Playback position status event unit
-// Default
-#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSUNIT_DEF PVPPBPOSUNIT_MILLISEC
-#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSUNIT_DEF_STRING "PVPPBPOSUNIT_MILLISEC"
-// Capability
-#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_CAP_STRING "PVPPBPOSUNIT_MILLISEC;PVPPBPOSUNIT_SEC;PVPPBPOSUNIT_MIN"
-
-// Playback position status event interval in milliseconds
-// Default
-#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_DEF 1000
-// Min-Max
-#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_MIN 200
-#define PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_MAX 5000
-
-// End time check interval in milliseconds
-// Default
-#define PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_DEF 1000
-// Min-Max
-#define PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_MIN 200
-#define PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_MAX 5000
-
-// Seek to sync point when repositioning
-#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINT_DEF true
-
-// Always start from the requested begin position when repositioning
-#define PVPLAYERENGINE_CONFIG_SKIPTOREQUESTEDPOS_DEF true
-
-// Whether to render skipped data or not when repositioning
-#define PVPLAYERENGINE_CONFIG_RENDERSKIPPED_DEF false
-
-// Time window when seeking sync point in milliseconds
-// Default
-#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_DEF 0
-// Min-Max
-#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MIN 0
-#define PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MAX 300000
-
-// Synchronization margin for media tracks in milliseconds
-// Default
-#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_EARLY_DEF -200
-#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_LATE_DEF 200
-// Min-Max
-#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_MIN -10000
-#define PVPLAYERENGINE_CONFIG_SYNCMARGIN_MAX 10000
-
-// Node command timeout value in milliseconds
-// Default
-#define PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_DEF 10000
-// Min-Max
-#define PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_MIN 1000
-#define PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_MAX 300000
-
-// Data sink node data queuing timeout value in milliseconds
-// Default
-#define PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_DEF 10000
-// Min-Max
-#define PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_MIN 1000
-#define PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_MAX 300000
-
-// Product name info string
-#define PVPLAYERENGINE_PRODINFO_PRODNAME_STRING "pvPlayer v4.0"
-// Part number info string
-#define PVPLAYERENGINE_PRODINFO_PARTNUM_STRING "000000"
-// HW platform info string
-#define PVPLAYERENGINE_PRODINFO_HWPLATFORM_STRING "Unknown"
-// SW platform info string
-#define PVPLAYERENGINE_PRODINFO_SWPLATFORM_STRING "Unknown"
-// Device info string
-#define PVPLAYERENGINE_PRODINFO_DEVICE_STRING "Unknown"
-
-// threshold value for difference in sync point and actual
-// reposition point in millisec
-#define SYNC_POINT_DIFF_THRESHOLD 5*60*1000
-
-// Location of the node registry config file
-#define PVPLAYERENGINE_NODE_REGISTRY_CONFIG_PATH "/system/etc/pvplayer.conf"
-
-
-#endif // PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
-
diff --git a/engines/player/config/linux_nj/pv_player_node_registry.cpp b/engines/player/config/linux_nj/pv_player_node_registry.cpp
deleted file mode 100644
index 787f731..0000000
--- a/engines/player/config/linux_nj/pv_player_node_registry.cpp
+++ /dev/null
@@ -1,530 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-#include "pvmf_omx_videodec_factory.h"
-
-#include "pvmf_omx_audiodec_factory.h"
-
-#include "pvmf_amrffparser_factory.h"
-
-#include "pvmf_aacffparser_factory.h"
-
-#include "pvmf_wavffparser_factory.h"
-
-#include "pvmf_mp3ffparser_factory.h"
-
-#include "pv_player_node_registry.h"
-
-// For recognizer registry
-#include "pvmf_recognizer_registry.h"
-
-#include "pvmi_datastreamsyncinterface_ref_factory.h"
-#include "pvmf_recognizer_plugin.h"
-
-#include "pvmp3ffrec_factory.h"
-
-#include "pvwavffrec_factory.h"
-
-#include "pvamrffrec_factory.h"
-
-#ifdef HAS_OSCL_LIB_SUPPORT
-#include "oscl_shared_library.h"
-
-#include "pvmf_node_shared_lib_interface.h"
-#endif
-
-PVPlayerNodeRegistry::PVPlayerNodeRegistry()
-{
-    PVPlayerNodeInfo nodeinfo;
-    iType.reserve(20);
-
-    //For PVMFOMXVideoDecNode
-    nodeinfo.iInputTypes.clear();
-    nodeinfo.iInputTypes.push_back(PVMF_H263);
-    nodeinfo.iInputTypes.push_back(PVMF_M4V);
-    nodeinfo.iInputTypes.push_back(PVMF_H264);
-    nodeinfo.iInputTypes.push_back(PVMF_H264_RAW);
-    nodeinfo.iInputTypes.push_back(PVMF_H264_MP4);
-    nodeinfo.iInputTypes.push_back(PVMF_WMV);
-    nodeinfo.iNodeUUID = KPVMFOMXVideoDecNodeUuid;
-    nodeinfo.iOutputType.clear();
-    nodeinfo.iOutputType.push_back(PVMF_YUV420);
-    nodeinfo.iNodeCreateFunc = PVMFOMXVideoDecNodeFactory::CreatePVMFOMXVideoDecNode;
-    nodeinfo.iNodeReleaseFunc = PVMFOMXVideoDecNodeFactory::DeletePVMFOMXVideoDecNode;
-    iType.push_back(nodeinfo);
-
-    nodeinfo.iInputTypes.clear();
-    // AAC FORMATS
-    nodeinfo.iInputTypes.push_back(PVMF_MPEG4_AUDIO);
-    nodeinfo.iInputTypes.push_back(PVMF_ADIF);
-    nodeinfo.iInputTypes.push_back(PVMF_ADTS);
-    nodeinfo.iInputTypes.push_back(PVMF_LATM);
-    nodeinfo.iInputTypes.push_back(PVMF_ASF_MPEG4_AUDIO);
-    // AMR FORMATS
-    nodeinfo.iInputTypes.push_back(PVMF_AMR_IETF);
-    nodeinfo.iInputTypes.push_back(PVMF_AMR_IETF_COMBINED);
-    nodeinfo.iInputTypes.push_back(PVMF_AMRWB_IETF);
-    nodeinfo.iInputTypes.push_back(PVMF_AMRWB_IETF_PAYLOAD);
-    nodeinfo.iInputTypes.push_back(PVMF_AMR_IF2);
-
-    // MP3 FORMAT
-    nodeinfo.iInputTypes.push_back(PVMF_MP3);
-
-    nodeinfo.iNodeUUID = KPVMFOMXAudioDecNodeUuid;;
-    nodeinfo.iOutputType.clear();
-    nodeinfo.iOutputType.push_back(PVMF_PCM16);
-    nodeinfo.iNodeCreateFunc = PVMFOMXAudioDecNodeFactory::CreatePVMFOMXAudioDecNode;
-    nodeinfo.iNodeReleaseFunc = PVMFOMXAudioDecNodeFactory::DeletePVMFOMXAudioDecNode;
-    iType.push_back(nodeinfo);
-
-    //For PVMFMP3FFParserNode
-    nodeinfo.iInputTypes.clear();
-    nodeinfo.iInputTypes.push_back(PVMF_MP3FF);
-    nodeinfo.iNodeUUID = KPVMFMP3FFParserNodeUuid;
-    nodeinfo.iOutputType.clear();
-    nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-    nodeinfo.iNodeCreateFunc = PVMFMP3FFParserNodeFactory::CreatePVMFMP3FFParserNode;
-    nodeinfo.iNodeReleaseFunc = PVMFMP3FFParserNodeFactory::DeletePVMFMP3FFParserNode;
-    iType.push_back(nodeinfo);
-
-    //For PVMFAMRFFParserNode
-    nodeinfo.iInputTypes.clear();
-    nodeinfo.iInputTypes.push_back(PVMF_AMRFF);
-    nodeinfo.iNodeUUID = KPVMFAmrFFParserNodeUuid;
-    nodeinfo.iOutputType.clear();
-    nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-    nodeinfo.iNodeCreateFunc = PVMFAMRFFParserNodeFactory::CreatePVMFAMRFFParserNode;
-    nodeinfo.iNodeReleaseFunc = PVMFAMRFFParserNodeFactory::DeletePVMFAMRFFParserNode;
-    iType.push_back(nodeinfo);
-
-    //For PVMFAACFFParserNode
-    nodeinfo.iInputTypes.clear();
-    nodeinfo.iInputTypes.push_back(PVMF_AACFF);
-    nodeinfo.iNodeUUID = KPVMFAacFFParserNodeUuid;
-    nodeinfo.iOutputType.clear();
-    nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-    nodeinfo.iNodeCreateFunc = PVMFAACFFParserNodeFactory::CreatePVMFAACFFParserNode;
-    nodeinfo.iNodeReleaseFunc = PVMFAACFFParserNodeFactory::DeletePVMFAACFFParserNode;
-    iType.push_back(nodeinfo);
-
-    //For PVMFWAVFFParserNode
-    nodeinfo.iInputTypes.clear();
-    nodeinfo.iInputTypes.push_back(PVMF_WAVFF);
-    nodeinfo.iNodeUUID = KPVMFWavFFParserNodeUuid;
-    nodeinfo.iOutputType.clear();
-    nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-    nodeinfo.iNodeCreateFunc = PVMFWAVFFParserNodeFactory::CreatePVMFWAVFFParserNode;
-    nodeinfo.iNodeReleaseFunc = PVMFWAVFFParserNodeFactory::DeletePVMFWAVFFParserNode;
-    iType.push_back(nodeinfo);
-}
-
-
-PVPlayerNodeRegistry::~PVPlayerNodeRegistry()
-{
-    iType.clear();
-}
-
-
-PVMFStatus PVPlayerNodeRegistry::QueryRegistry(PVMFFormatType& aInputType, PVMFFormatType& aOutputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids)
-{
-    uint32 SearchCount = 0;
-    bool matchfound = false;
-
-    // Find all nodes that support the specified input and ouput format pair
-    while (SearchCount < iType.size())
-    {
-        uint32 inputsearchcount = 0, outputsearchcount = 0;
-        bool iInputFoundFlag = false, iOutputFoundFlag = false;
-
-        while (inputsearchcount < iType[SearchCount].iInputTypes.size())
-        {
-            // Check if the input format matches
-            if (iType[SearchCount].iInputTypes[inputsearchcount] == aInputType)
-            {
-                // Set the the input flag to true since we found the match in the search
-                iInputFoundFlag = true;
-                break;
-            }
-            inputsearchcount++;
-        }
-
-        //Check the flag of input format if it is true check for the output format, if not return failure
-        if (iInputFoundFlag)
-        {
-            while (outputsearchcount < iType[SearchCount].iOutputType.size())
-            {
-                if (iType[SearchCount].iOutputType[outputsearchcount] == aOutputType)
-                {
-                    //set the the output flag to true since we found the match in the search
-                    iOutputFoundFlag = true;
-                    break;
-                }
-
-                outputsearchcount++;
-            }
-
-            if (iOutputFoundFlag)
-            {
-                // There's a match so add this node UUID to the list.
-                aUuids.push_back(iType[SearchCount].iNodeUUID);
-                matchfound = true;
-            }
-        }
-
-        SearchCount++;
-    }
-
-    if (matchfound)
-    {
-        return PVMFSuccess;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-}
-
-
-PVMFNodeInterface* PVPlayerNodeRegistry::CreateNode(PVUuid& aUuid)
-{
-    PVMFNodeInterface* nodeInterface = NULL;
-    bool iFoundFlag = false;
-    uint32 NodeSearchCount = 0;
-
-    while (NodeSearchCount < iType.size())
-    {
-        //Search if the UUID's will match
-        if (iType[NodeSearchCount].iNodeUUID == aUuid)
-        {
-            //Since the UUID's match set the flag to true
-            iFoundFlag = true;
-            break;
-        }
-
-        NodeSearchCount++;
-
-    }
-
-    if (iFoundFlag)
-    {
-        OsclActiveObject::OsclActivePriority priority = OsclActiveObject::EPriorityNominal;
-        PVPlayerNodeInfo* nodeInfo = &iType[NodeSearchCount];
-
-        //Call the appropriate Node creation function & return Node pointer
-        if (KPVMFOMXVideoDecNodeUuid == aUuid)
-        {
-            priority = OsclActiveObject::EPriorityLow;
-        }
-        else
-        {
-            priority = OsclActiveObject::EPriorityNominal;
-        }
-
-#ifdef HAS_OSCL_LIB_SUPPORT
-        // If the node has a corresponding shared library, load that
-        // first.  If not, the node is assumed to be already completely
-        // linked.
-        if (NULL != nodeInfo->iSharedLibrary
-                && (OsclLibSuccess == (nodeInfo->iSharedLibrary)->LoadLib()))
-        {
-            // Need to load the library for the node and query for the
-            // create and release functions. If the library is already
-            // loaded, the system should avoid opening the same library
-            // again on its own.
-            OsclAny* interfacePtr = NULL;
-            (nodeInfo->iSharedLibrary)->QueryInterface(PV_NODE_INTERFACE,
-                    (OsclAny*&)interfacePtr);
-            NodeSharedLibraryInterface* nodeIntPtr =
-                OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
-
-            OsclAny* createFuncTemp =
-                nodeIntPtr->QueryNodeInterface(nodeInfo->iNodeUUID, PV_CREATE_NODE_INTERFACE);
-            OsclAny* releaseFuncTemp =
-                nodeIntPtr->QueryNodeInterface(nodeInfo->iNodeUUID, PV_RELEASE_NODE_INTERFACE);
-
-            nodeInfo->iNodeCreateFunc =
-                OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp);
-            nodeInfo->iNodeReleaseFunc =
-                OSCL_DYNAMIC_CAST(bool (*)(PVMFNodeInterface*), releaseFuncTemp);
-        }
-#endif
-
-        if (NULL != nodeInfo->iNodeCreateFunc)
-        {
-            nodeInterface = (*(iType[NodeSearchCount].iNodeCreateFunc))(priority);
-        }
-    }
-
-    return nodeInterface;
-}
-
-bool PVPlayerNodeRegistry::ReleaseNode(PVUuid& aUuid, PVMFNodeInterface* aNode)
-{
-    bool iFoundFlag = false;
-    uint32 NodeSearchCount = 0;
-
-    while (NodeSearchCount < iType.size())
-    {
-        //Search if the UUID's will match
-        if (iType[NodeSearchCount].iNodeUUID == aUuid)
-        {
-            //Since the UUID's match set the flag to true
-            iFoundFlag = true;
-            break;
-        }
-
-        NodeSearchCount++;
-
-    }
-
-    if (iFoundFlag)
-    {
-        //Call the appropriate Node delete function
-        bool del_stat = (*(iType[NodeSearchCount].iNodeReleaseFunc))(aNode);
-
-#ifdef HAS_OSCL_LIB_SUPPORT
-        // If a library needs to be loaded to use this node, close the library
-        if (NULL != iType[NodeSearchCount].iSharedLibrary)
-        {
-            (iType[NodeSearchCount].iSharedLibrary)->Close();
-        }
-#endif
-
-        return del_stat;
-    }
-    return false;
-}
-
-// Player engine with recognizers for MP3, MP4, WAV, and AMR
-PVPlayerRecognizerRegistry::PVPlayerRecognizerRegistry()
-        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerRecognizerRegistry")
-{
-    AddToScheduler();
-
-    iRecSessionId = 0;
-    iRecognizerResult.reserve(4);
-    iFileDataStreamFactory = NULL;
-    iSourceFormatType = PVMF_FORMAT_UNKNOWN;
-    iObserver = NULL;
-    iCmdContext = NULL;
-    iCancelQuery = false;
-    iCancelCmdContext = NULL;
-
-    if (PVMFRecognizerRegistry::Init() != PVMFSuccess)
-    {
-        OSCL_ASSERT(false);
-        return;
-    }
-
-    PVMFRecognizerPluginFactory* tmpfac = NULL;
-    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVMP3FFRecognizerFactory, ()));
-    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
-    {
-        iRecognizerList.push_back(tmpfac);
-    }
-    else
-    {
-        OSCL_DELETE(((PVMP3FFRecognizerFactory*)tmpfac));
-        tmpfac = NULL;
-        return;
-    }
-
-    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVWAVFFRecognizerFactory, ()));
-    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
-    {
-        iRecognizerList.push_back(tmpfac);
-    }
-    else
-    {
-        OSCL_DELETE(((PVWAVFFRecognizerFactory*)tmpfac));
-        tmpfac = NULL;
-        return;
-    }
-
-    tmpfac = OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVAMRFFRecognizerFactory, ()));
-    if (PVMFRecognizerRegistry::RegisterPlugin(*tmpfac) == PVMFSuccess)
-    {
-        iRecognizerList.push_back(tmpfac);
-    }
-    else
-    {
-        OSCL_DELETE(((PVAMRFFRecognizerFactory*)tmpfac));
-        tmpfac = NULL;
-        return;
-    }
-
-}
-
-
-
-PVPlayerRecognizerRegistry::~PVPlayerRecognizerRegistry()
-{
-    if (iFileDataStreamFactory)
-    {
-        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
-        iFileDataStreamFactory = NULL;
-    }
-    PVMFRecognizerPluginFactory* tmpfac = NULL;
-
-    if (iRecognizerList.empty() == false)
-    {
-        tmpfac = iRecognizerList[0];
-        iRecognizerList.erase(iRecognizerList.begin());
-        PVMFRecognizerRegistry::RemovePlugin(*tmpfac);
-        OSCL_DELETE(((PVMP3FFRecognizerFactory*)tmpfac));
-    }
-
-    if (iRecognizerList.empty() == false)
-    {
-        tmpfac = iRecognizerList[0];
-        iRecognizerList.erase(iRecognizerList.begin());
-        PVMFRecognizerRegistry::RemovePlugin(*tmpfac);
-        OSCL_DELETE(((PVWAVFFRecognizerFactory*)tmpfac));
-    }
-
-    if (iRecognizerList.empty() == false)
-    {
-        tmpfac = iRecognizerList[0];
-        iRecognizerList.erase(iRecognizerList.begin());
-        PVMFRecognizerRegistry::RemovePlugin(*tmpfac);
-        OSCL_DELETE(((PVAMRFFRecognizerFactory*)tmpfac));
-    }
-    PVMFRecognizerRegistry::Cleanup();
-}
-
-
-PVMFStatus PVPlayerRecognizerRegistry::QueryFormatType(OSCL_wString& aSourceURL, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aCmdContext)
-{
-    if (iObserver != NULL)
-    {
-        // Previous query still ongoing
-        return PVMFErrBusy;
-    }
-    iObserver = &aObserver;
-    iCmdContext = aCmdContext;
-
-    // Create a datastream wrapper factory for standard file
-    if (iFileDataStreamFactory)
-    {
-        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
-        iFileDataStreamFactory = NULL;
-    }
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iFileDataStreamFactory = OSCL_STATIC_CAST(PVMFDataStreamFactory*, OSCL_NEW(PVMIDataStreamSyncInterfaceRefFactory, (aSourceURL))));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         return PVMFErrNoMemory;
-                        );
-
-    // Open the session with recognizer
-    PVMFRecognizerRegistry::OpenSession(iRecSessionId, *this);
-
-    // Request file recognition
-    iRecognizerResult.clear();
-    iRecognizeCmdId = PVMFRecognizerRegistry::Recognize(iRecSessionId, *iFileDataStreamFactory, NULL, iRecognizerResult, NULL);
-
-    return PVMFSuccess;
-}
-
-
-void PVPlayerRecognizerRegistry::CancelQuery(OsclAny* aContext)
-{
-    if (iObserver == NULL)
-    {
-        // No pending recognize request
-        OSCL_LEAVE(OsclErrInvalidState);
-        return;
-    }
-
-    iCancelQuery = true;
-    iCancelCmdContext = aContext;
-
-    if (!IsBusy())
-    {
-        // The recognition pending so cancel it
-        PVMFRecognizerRegistry::CancelCommand(iRecSessionId, iRecognizeCmdId);
-    }
-    // Else the recognition already completed so just cancel it in the Run()
-}
-
-
-void PVPlayerRecognizerRegistry::Run()
-{
-    // Close the session with recognizer
-    PVMFRecognizerRegistry::CloseSession(iRecSessionId);
-
-    // Destroy the data stream wrapper factory for standard file
-    if (iFileDataStreamFactory)
-    {
-        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
-        iFileDataStreamFactory = NULL;
-    }
-
-    // Tell the engine the result
-    if (iObserver)
-    {
-        iObserver->RecognizeCompleted(iSourceFormatType, iCmdContext);
-
-        if (iCancelQuery)
-        {
-            iObserver->RecognizeCompleted(iSourceFormatType, iCancelCmdContext);
-            iCancelQuery = false;
-            iCancelCmdContext = NULL;
-        }
-    }
-    iObserver = NULL;
-    iCmdContext = NULL;
-}
-
-void PVPlayerRecognizerRegistry::RecognizerCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    iSourceFormatType = PVMF_FORMAT_UNKNOWN;
-
-    if (aResponse.GetCmdId() == iRecognizeCmdId)
-    {
-        // Recognize() command completed
-        if (aResponse.GetCmdStatus() == PVMFSuccess)
-        {
-            Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>::iterator it;
-            for (it = iRecognizerResult.begin(); it != iRecognizerResult.end(); it++)
-            {
-                if (it->iRecognitionConfidence == PVMFRecognizerConfidenceCertain)
-                {
-                    // Current implementation does not support the case where multiple
-                    // recognizer plugins can recognize the file with certainty
-                    iSourceFormatType = GetFormatIndex(it->iRecognizedFormat.get_str());
-                    break;
-                }
-                if (it->iRecognitionConfidence == PVMFRecognizerConfidencePossible)
-                {
-                    iSourceFormatType = GetFormatIndex(it->iRecognizedFormat.get_str());
-                }
-            }
-        }
-
-        if (aResponse.GetCmdStatus() == PVMFErrCancelled)
-        {
-            // If cancelled, need to wait for the cancel command to complete before
-            // calling Run
-            return;
-        }
-    }
-
-    RunIfNotReady();
-}
-
-
diff --git a/engines/player/include/pv_player_datasink.h b/engines/player/include/pv_player_datasink.h
index bc61863..b11f472 100644
--- a/engines/player/include/pv_player_datasink.h
+++ b/engines/player/include/pv_player_datasink.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_datasinkfilename.h b/engines/player/include/pv_player_datasinkfilename.h
index 4271e00..191d152 100644
--- a/engines/player/include/pv_player_datasinkfilename.h
+++ b/engines/player/include/pv_player_datasinkfilename.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
 class PVPlayerDataSinkFilename : public PVPlayerDataSink
 {
     public:
-        PVPlayerDataSinkFilename() : iFormatType(PVMF_FORMAT_UNKNOWN), iFilename(NULL) {};
+        PVPlayerDataSinkFilename() : iFormatType(PVMF_MIME_FORMAT_UNKNOWN), iFilename(NULL) {};
         ~PVPlayerDataSinkFilename() {};
 
         PVPDataSinkType GetDataSinkType()
diff --git a/engines/player/include/pv_player_datasinkpvmfnode.h b/engines/player/include/pv_player_datasinkpvmfnode.h
index 6083c2a..1d62a1b 100644
--- a/engines/player/include/pv_player_datasinkpvmfnode.h
+++ b/engines/player/include/pv_player_datasinkpvmfnode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
 class PVPlayerDataSinkPVMFNode : public PVPlayerDataSink
 {
     public:
-        PVPlayerDataSinkPVMFNode() : iFormatType(PVMF_FORMAT_UNKNOWN), iNode(NULL), iEmptyString(NULL) {};
+        PVPlayerDataSinkPVMFNode() : iFormatType(PVMF_MIME_FORMAT_UNKNOWN), iNode(NULL), iEmptyString(NULL) {};
         ~PVPlayerDataSinkPVMFNode() {};
 
         PVPDataSinkType GetDataSinkType()
diff --git a/engines/player/include/pv_player_datasource.h b/engines/player/include/pv_player_datasource.h
index 549a74f..6e3fa1e 100644
--- a/engines/player/include/pv_player_datasource.h
+++ b/engines/player/include/pv_player_datasource.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_datasourcepvmfnode.h b/engines/player/include/pv_player_datasourcepvmfnode.h
index 8146832..9678276 100644
--- a/engines/player/include/pv_player_datasourcepvmfnode.h
+++ b/engines/player/include/pv_player_datasourcepvmfnode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_datasourceurl.h b/engines/player/include/pv_player_datasourceurl.h
index 639e8ee..e2b90d0 100644
--- a/engines/player/include/pv_player_datasourceurl.h
+++ b/engines/player/include/pv_player_datasourceurl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@
 class PVPlayerDataSourceURL : public PVPlayerDataSource
 {
     public:
-        PVPlayerDataSourceURL() : iFormatType(PVMF_FORMAT_UNKNOWN), iURL(NULL), iContext(NULL) {};
+        PVPlayerDataSourceURL() : iFormatType(PVMF_MIME_FORMAT_UNKNOWN), iURL(NULL), iContext(NULL) {};
         ~PVPlayerDataSourceURL() {};
 
         PVPDataSourceType GetDataSourceType()
diff --git a/engines/player/include/pv_player_events.h b/engines/player/include/pv_player_events.h
index 48c1d95..3d2597f 100644
--- a/engines/player/include/pv_player_events.h
+++ b/engines/player/include/pv_player_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -225,6 +225,12 @@
     PVPlayerInfoAttemptingSFRAsPartOfSetPlayBackRange,
 
     /**
+     pvPlayer sends this event when engine is changing position and
+     Source node sends NotSupported to Change Position request.
+     **/
+    PVPlayerInfoChangePlaybackPositionNotSupported,
+
+    /**
      Placeholder for the last pvPlayer informational event
      **/
     PVPlayerInfoLast = 10000
diff --git a/engines/player/include/pv_player_factory.h b/engines/player/include/pv_player_factory.h
index f8bea5b..e5790a2 100644
--- a/engines/player/include/pv_player_factory.h
+++ b/engines/player/include/pv_player_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_interface.h b/engines/player/include/pv_player_interface.h
index f899f75..a15a9a6 100644
--- a/engines/player/include/pv_player_interface.h
+++ b/engines/player/include/pv_player_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -79,15 +79,10 @@
 #include "pvmi_kvp.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
-/**
- UUID for pvPlayer error and information event type codes
- **/
-#define PVPlayerErrorInfoEventTypesUUID PVUuid(0x46fca5ac,0x5b57,0x4cc2,0x82,0xc3,0x03,0x10,0x60,0xb7,0xb5,0x98)
-
 
 // CLASS DECLARATION
 /**
@@ -107,23 +102,6 @@
         virtual ~PVPlayerInterface() {};
 
         /**
-         * Returns SDK version information about pvPlayer.
-         * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
-         * callback handler will be called when this command request completes.
-         *
-         * @param aSDKInfo
-         *         A reference to a PVSDKInfo structure which contains product name, supported hardware platform,
-         *         supported software platform, version, part number, and PV UUID. These fields will contain info
-         *        .for the currently instantiated pvPlayer engine when this function returns success.
-         * @param aContextData
-         *         Optional opaque data that will be passed back to the user with the command response
-         * @leave This method can leave with one of the following error codes
-         *         OsclErrNoMemory if the pvPlayer engine failed to allocate memory during this operation
-         * @returns A unique command ID for asynchronous completion
-         **/
-        virtual PVCommandId GetSDKInfo(PVSDKInfo &aSDKInfo, const OsclAny* aContextData = NULL) = 0;
-
-        /**
          * Returns information about all modules currently used by pvPlayer SDK.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
@@ -281,10 +259,8 @@
 
         /**
          * This API is to allow the user to cancel all pending requests in pvPlayer. The current request being
-         * processed, if any, will also be aborted. If a request being processed is cancelled, pvPlayer will reset
-         * everything and go to PVP_STATE_IDLE state.
-         * If this API is called when there is no request being processing (just pending requests or no pending requests),
-         * the engine will not change the state and report this command to complete successfully.
+         * processed, if any, will also be aborted. The user of PV-SDK should get the state of
+         * PVPlayer Engine after the command completes and before issuing any other command.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
@@ -347,6 +323,7 @@
          * the data source is being initialized to obtain metadata and track information of the source media.
          * If initialization fails, pvPlayer will revert to PVP_STATE_IDLE state and the data source
          * will be closed.
+         * The Command should only be called in PVP_STATE_IDLE.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
@@ -409,13 +386,36 @@
          *         Reference to a vector of KVP to place the specified metadata values
          * @param aContextData
          *         Optional opaque data that will be passed back to the user with the command response
+         * @param aMetadataValuesCopiedInCallBack
+         *	       Boolean to let engine know if metadata values are copied by User of SDK in command complete callback.
+         *         By default the SDK assumes this to be the case. If this argument is set to false by the caller,
+         *         then SDK assumes that user will call ReleaseMetaDataValues at a later point.
          * @leave This method can leave with one of the following error codes
          *         OsclErrInvalidState if invoked in the incorrect state
          *         OsclErrNoMemory if the SDK failed to allocate memory during this operation
          * @returns A unique command id for asynchronous completion
          **/
         virtual PVCommandId GetMetadataValues(PVPMetadataList& aKeyList, int32 aStartingValueIndex, int32 aMaxValueEntries, int32& aNumAvailableValueEntries,
-                                              Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL) = 0;
+                                              Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL, bool aMetadataValuesCopiedInCallBack = true) = 0;
+
+        /**
+         * The function makes a request to release the metadata value(s) specified by the passed in metadata value list.
+         * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
+         * callback handler will be called when this command request completes.If a GetMetaDataValues were called in
+         * PVP_STATE_INITIALIZED state, then corresponding ReleaseMetaDataValues must be called before Reset.
+         * If a GetMetaDataValues were called in PVP_STATE_PREPARED, PVP_STATE_STARTED, PVP_STATE_PAUSED states,
+         * then corresponding ReleaseMetaDataValues must be called before Stop.
+         *
+         * @param aValueList
+         *         Reference to a vector of KVP to place the specified metadata values
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @leave This method can leave with one of the following error codes
+         *         OsclErrInvalidState if invoked in the incorrect state
+         *         OsclErrNoMemory if the SDK failed to allocate memory during this operation
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId ReleaseMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL) = 0;
 
         /**
          * This function allows a player data sink to be specified for playback. This function must be called
@@ -442,12 +442,14 @@
          * PVP_STATE_STARTED, or PVP_STATE_PAUSED state. The specified positions must be between beginning of clip and
          * clip duration. The units of position is specified in the passed-in parameter PVPPlaybackPosition.
          * If either of the positions is indeterminate, use the indeterminate flag in PVPPlaybackPosition structure.
-         * The current or queued playback range can be changed and aQueueRange flag is used to choose between the two.
+         * The queued playback range can be done using aQueueRange flag which is Not Supported as of now by PV-SDK.
          * This function will overwrite any previous playback range info. The only exception is the changing of end position
          * for the current playback range during playback.
-         * Indeterminate begin position will be mapped to the beginning of the clip (time 0). Only exception to this behavior
-         * is when changing the end position for the current playback range during playback.
-         * Indeterminate end position will be mapped to the end of the clip (clip duration).
+         * Command if called in player state as PVP_STATE_INITIALISED or PVP_STATE_PAUSED, will complete in one Engine AO run without actually
+         * changing the position. The change in position will come into affect when Prepare or Resume respectively is called on Engine by the app.
+         * If reposition request is not honored by the source node during Prepare or Resume, engine will continue to complete Prepare or Resume
+         * but will send an informational event "PVMFInfoChangePlaybackPositionNotSupported" to the app informing that the SetPlaybackRange request
+         * could not be honored.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
@@ -511,20 +513,25 @@
          * means 4X, 25000 means 0.25X, and -100000 means 1X backward.
          * The playback rate can also be modified by specifying the timebase to use for the playback
          * clock. This is accomplished by  setting the aRate parameter to 0 and passing in a pointer
-         * to an OsclTimebase.
-         * This function can be called when pvPlayer is in
-         * PVP_STATE_PREPARED, PVP_STATE_STARTED, or PVP_STATE_PAUSED state.  Changing to or from an outside
-         * timebase is only allowed in PVP_STATE_PREPARED.
+         * to an PVMFTimebase.
+         * This function can be called when pvPlayer is in PVP_STATE_PREPARED, PVP_STATE_STARTED, or PVP_STATE_PAUSED state.
+         * Changing to or from an outside timebase is only allowed in PVP_STATE_PREPARED.
+         * Command if called in player state PVP_STATE_PAUSED with a direction change, will complete in one Engine AO run without actually
+         * changing the direction. The change in direction will come into affect when Resume is called on Engine by the app. If the request
+         * is not honored by the source node during Resume, engine will continue to complete Resume but will send an informational event
+         * "PVMFInfoChangePlaybackPositionNotSupported" to the app informing that the SetPlaybackRate request could not be honored.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
          * @param aRate
          *         The playback rate specified as millipercent of "real-time".
+         *         A millipercent is 1/1000 of a percent. So 2X = 200% of realtime is
+         *         200,000 millipercent. The motivation is to povide precision with an integer parameter.
          *         Negative rates specify backward playback.
          *         The valid range of absolute value of playback rates will be limited to the
          *         minimum and maximum returned by GetPlaybackMinMaxRate().
          * @param aTimebase
-         *         Reference to an OsclTimebase which will be used to drive the playback clock. aRate must be
+         *         Reference to an PVMFTimebase which will be used to drive the playback clock. aRate must be
          *         set to 0, 1X, or -1X to use the timebase.
          * @param aContextData
          *         Optional opaque data that will be passed back to the user with the command response
@@ -532,13 +539,13 @@
          *         OsclErrArgument if rate or timebase is invalid
          * @returns A unique command id for asynchronous completion
          **/
-        virtual PVCommandId SetPlaybackRate(int32 aRate, OsclTimebase* aTimebase = NULL, const OsclAny* aContextData = NULL) = 0;
+        virtual PVCommandId SetPlaybackRate(int32 aRate, PVMFTimebase* aTimebase = NULL, const OsclAny* aContextData = NULL) = 0;
 
         /**
          * This function retrieves the current playback rate setting. If the playback rate is set as a millipercent of "real-time"
          * playback rate, then aRate will be filled in with the milliperecent value when this command completes
          * successfully. If the playback rate is set by an outside timebase, aRate will be set to 0 and aTimebase pointer
-         * will point to the OsclTimebase being used when the command completes successfully.
+         * will point to the PVMFTimebase being used when the command completes successfully.
          * This function can be called when pvPlayer is in
          * PVP_STATE_PREPARED, PVP_STATE_STARTED, or PVP_STATE_PAUSED state.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
@@ -549,7 +556,7 @@
          *         as millipercent of "real-time" playback rate. If an outside timebase is being used, aRate would
          *         be set to 0.
          * @param aTimebase
-         *         Reference to an OsclTimebase pointer which will be valid if an outside timebase is being used
+         *         Reference to an PVMFTimebase pointer which will be valid if an outside timebase is being used
          *         for the playback clock.
          * @param aContextData
          *         Optional opaque data that will be passed back to the user with the command response
@@ -557,7 +564,7 @@
          *
          * @returns A unique command id for asynchronous completion
          **/
-        virtual PVCommandId GetPlaybackRate(int32& aRate, OsclTimebase*& aTimebase, const OsclAny* aContextData = NULL) = 0;
+        virtual PVCommandId GetPlaybackRate(int32& aRate, PVMFTimebase*& aTimebase, const OsclAny* aContextData = NULL) = 0;
 
         /**
          * This function retrieves the minimum and maximum playback rate expressed as  a millipercent of "real-time"
@@ -598,6 +605,7 @@
          * the data source to queue the media data for playback(e.g. for 3GPP streaming, fills the jitter buffer).
          * pvPlayer also checks to make sure each component needed for
          * playback is ready and capable. When successful, pvPlayer will be in PVP_STATE_PREPARED state,
+         * The command should be called only in PVP_STATE_INITIALISED.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
@@ -613,6 +621,7 @@
         /**
          * This function kicks off the actual playback. Media data are sent out from the data source to the data sink(s).
          * pvPlayer will transition to PVP_STATE_STARTED state after playback starts successfully.
+         * The command should be called only in PVP_STATE_PREPARED.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
@@ -628,9 +637,6 @@
         /**
          * This function pauses the currently ongoing playback. pvPlayer must be in PVP_STATE_STARTED state
          * to call this function. When pause successfully completes, pvPlayer will be in PVP_STATE_PAUSED state.
-         * Even in PVP_STATE_STARTED state, the pause request might fail with invalid state error if pvPlayer is
-         * auto-paused due to source data underflow. One can know if pvPlayer is auto-paused by listening for
-         * PVMFInfoUnderflow informational event from pvPlayer.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
@@ -662,7 +668,7 @@
         /**
          * This function stops the current playback and transitions pvPlayer to the PVP_STATE_INITIALIZED
          * state. During the transition, data transmission from data source to all data sinks are
-         * terminated and any queued data is flushed. Also all connections between data source and data sinks
+         * terminated. Also all connections between data source and data sinks
          * are torn down.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
@@ -696,19 +702,17 @@
         virtual PVCommandId RemoveDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData = NULL) = 0;
 
         /**
-         * This function cleans up resources used for playback to transition pvPlayer from PVP_STATE_INITIALIZED state
-         * to PVP_STATE_IDLE state. While processing this command, pvPlayer is in the PVP_STATE_RESETTING state.
+         * This function cleans up resources used for playback to transition pvPlayer to PVP_STATE_IDLE state.
+         * While processing this command, pvPlayer is in the PVP_STATE_RESETTING state.
          * If any data sinks are still referenced by pvPlayer when this function is called, the data sinks
          * will be closed and removed from pvPlayer during the Reset.
-         * pvPlayer must be in PVP_STATE_INITIALIZED state to call this function. If playback is occurring, Stop must be
-         * called first. If already in PVP_STATE_IDLE state, then nothing will occur.
+         * If already in PVP_STATE_IDLE state, then nothing will occur.
          * This command request is asynchronous. PVCommandStatusObserver's CommandCompleted()
          * callback handler will be called when this command request completes.
          *
          * @param aContextData
          *         Optional opaque data that will be passed back to the user with the command response
          * @leave This method can leave with one of the following error codes
-         *         OsclErrInvalidState if invoked in the incorrect state
          *         OsclErrNoMemory if the SDK failed to allocate memory during this operation
          * @returns A unique command id for asynchronous completion
          **/
@@ -732,10 +736,21 @@
          * @returns A unique command id for asynchronous completion
          **/
         virtual PVCommandId RemoveDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Returns SDK version information about pvPlayer.
+         *
+         * @param aSDKInfo
+         *         A reference to a PVSDKInfo structure which contains product name, supported hardware platform,
+         *         supported software platform, version, part number, and PV UUID. These fields will contain info
+         *        .for the currently instantiated pvPlayer engine when this function returns success.
+         *
+         **/
+        OSCL_IMPORT_REF static void GetSDKInfo(PVSDKInfo& aSDKInfo);
+
 };
 
 
 
+
 #endif // PV_PLAYER_INTERFACE_H_INCLUDED
-
-
diff --git a/engines/player/include/pv_player_license_acquisition_interface.h b/engines/player/include/pv_player_license_acquisition_interface.h
index 207e138..c32678f 100644
--- a/engines/player/include/pv_player_license_acquisition_interface.h
+++ b/engines/player/include/pv_player_license_acquisition_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_registry_interface.h b/engines/player/include/pv_player_registry_interface.h
index 2c4c5cb..483d332 100644
--- a/engines/player/include/pv_player_registry_interface.h
+++ b/engines/player/include/pv_player_registry_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_track_selection_interface.h b/engines/player/include/pv_player_track_selection_interface.h
index 2d30547..34ea607 100644
--- a/engines/player/include/pv_player_track_selection_interface.h
+++ b/engines/player/include/pv_player_track_selection_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/include/pv_player_types.h b/engines/player/include/pv_player_types.h
index 668c1f3..2db81ec 100644
--- a/engines/player/include/pv_player_types.h
+++ b/engines/player/include/pv_player_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
 
     /**
     	pvPlayer enters this state when it encounters an error. This is a transitional state and after pvPlayer performs
-    	error recovery, it should end up in PVP_STATE_INITIALIZED or PVP_STATE_IDLE state.
+    	error recovery, it will end up in PVP_STATE_IDLE state.
     **/
     PVP_STATE_ERROR			= 6
 } PVPlayerState;
diff --git a/engines/player/sample_app/Android.mk b/engines/player/sample_app/Android.mk
deleted file mode 100644
index 4a544a6..0000000
--- a/engines/player/sample_app/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/sample_player_app.cpp \
-	src/pv_player_engine_testset_mio_file.cpp
-
-LOCAL_STATIC_LIBRARIES := libunit_test
-
-LOCAL_SHARED_LIBRARIES := libc libopencorecommon libopencoreplayer
-
-LOCAL_LDLIBS += -lpthread
-
-
-
-LOCAL_MODULE := pv_sample_player
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/player/sample_app/src \
-	$(PV_TOP)//engines/player/sample_app/src \
-	$(PV_TOP)//engines/player/sample_app/src/linux_nj \
-	$(PV_TOP)//engines/player/sample_app/../../common/include \
-	$(PV_TOP)//engines/player/sample_app/../../../pvmi/media_io/pvmiofileoutput/include \
-	$(PV_TOP)//engines/player/sample_app/../../../nodes/pvmediaoutputnode/include \
-	$(PV_TOP)//engines/player/sample_app/../include \
-	$(PV_TOP)//engines/player/sample_app/../../../nodes/common/include \
-	$(PV_INCLUDES) 
-
-ifeq ($(ARCHITECTURE),linux_nj)
-   LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/sample_app/config/linux_nj
-else
-   LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/sample_app/config/linux_3gpp
-endif
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-include $(BUILD_EXECUTABLE)
-
diff --git a/engines/player/sample_app/build/linux_nj/makefile b/engines/player/sample_app/build/linux_nj/makefile
deleted file mode 100755
index c234f0e..0000000
--- a/engines/player/sample_app/build/linux_nj/makefile
+++ /dev/null
@@ -1,137 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = prog
-TARGET = sample_player_app
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# include the common engine header files in the search path
-XINCDIRS += -I ../../src/linux_nj -I ../../../../common/include -I ../../../../../pvmi/media_io/pvmiofileoutput/include -I ../../../../../nodes/pvmediaoutputnode/include -I ../../../include -I ../../../../../nodes/common/include
-
-ifeq ($(ARCHITECTURE),linux_nj)
-   XINCDIRS += -I ../../config/$(BUILD_ARCH)
-else
-   XINCDIRS += -I ../../config/linux_3gpp
-endif
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-#XLDFLAGS +=
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	sample_player_app.cpp pv_player_engine_testset_mio_file.cpp
-
-LIBS = \
-	-lpvplayer_engine \
-	-lpvfileoutputnode \
-	-lpvpvxparser \
-	-lpvmp3ffparsernode \
-	-lpvdownloadmanagernode \
-	-lpvmp4ffparsernode \
-	-lcpm \
-	-lpassthru_oma1 \
-	-lpvaacffparsernode \
-	-lpvmp3ff \
-	-lpvmp4ff \
-	-lpvaacparser \
-	-lgetactualaacconfig \
-	-lpvmp3 \
-        -lm4v_config \
-	-lpvlogger \
-	-lpvvideodecnode \
-	-lpvavcdecnode \
-	-lpvstreamingmanagernode_3gpp \
-	-lpvjitterbuffernode \
-	-lpvmediaplayernode \
-	-lrtprtcp \
-	-lprotocolenginenode \
-	-lpvrtsp_cli_eng_node \
-	-lpvmediadatastruct \
-	-lpv_http_parcom \
-	-lpvsocketnode \
-	-lrtppayloadparser_3gpp \
-	-lpvbitstreamparser \
-	-lpvmf \
-	-lpvsdpparser \
-	-lpv_rtsp_parcom \
-	-lpvcrypto \
-	-lpvmp4decoder \
-	-lpvdecoder_gsmamr \
-	-lpv_amr_nb_common_lib \
-	-lpvamrwbdecoder \
-	-lpvavcdecoder \
-	-lpv_avc_common_lib \
-	-lpv_aac_dec \
-	-lfile_mediaio \
-	-lpvgendatastruct \
-	-lpvmimeutils \
-	-lpvmediaoutputnode \
-	-lpvamrffparsernode \
-	-lpvgsmamrparser \
-	-lpvlatmpayloadparser \
-	-lpvmfrecognizer \
-	-lpvmp3ffrecognizer \
-	-lpvmp4ffrecognizer \
-	-lpvfileparserutils \
-	-lpvid3parcom \
-	-losclregcli \
-	-losclregserv \
-	-losclio \
-	-losclproc \
-	-losclutil \
-	-losclmemory \
-	-losclerror \
-	-losclbase \
-	-lunit_test \
-
-ifeq ($(ARCHITECTURE),linux_nj)
-    SYSLIBS = -lc -ldl -lstdc++
-    PRE_LDFLAGS += \
-        $(ANDROID_BASE)/../crtbegin.o
-    POST_LDFLAGS += \
-        $(ANDROID_BASE)/../toolchain-4.1.1/bin/../lib/gcc/arm-elf/4.1.1/libgcc.a \
-        $(ANDROID_BASE)/../toolchain-4.1.1/bin/../lib/gcc/arm-elf/4.1.1/crtend.o
-else
-    SYSLIBS = -lpthread
-endif
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/engines/player/sample_app/sample_player_app_release.txt b/engines/player/sample_app/sample_player_app_release.txt
deleted file mode 100644
index d8d353e..0000000
--- a/engines/player/sample_app/sample_player_app_release.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-See below for build instructions. The sample player app is a single threaded implementation that exercises the PV player engine in the following manner:
-
-  - plays from a media file specified as argument in command line or from default file "testqvga30fps.mp4"
-    if argument had been omitted.  
-
-  - writes raw PCM16 samples into an output file, the default is "sample_player_app_test_mp4_audio.dat"
-
-  - writes YUV420 frames into another output file, the default is "sample_player_app_test_mp4_video.dat"
-
-  - during the playback, the duration metadata of the media clip is displayed
-
-  - the media time is also displayed at 1 second interval during the playback
-
-  - the application will continue playback until the end of clip has been reached.
-
-  - after playback is stopped due to end of clip reached, all the resources are freed.
-
- 
-BUILD INSTRUCTIONS
-
-   - After building all the libraries necessary for the player engine 
-   (see makefile under pv/engines/player/build/<architecture>), the sample 
-   application can be built from pv/engines/player/sample_app/build/<architecture>
-   by running "make".
-
-   NOTE: The sample app makefile assumes that the "crypto" library in the 
-   original release has been renamed to "pvcrypto" (i.e., the release version
-   of the library would have the full name libpvcrypto.a).  The name change
-   was done to avoid a conflict with the libraries in openssl.
-
-RUNNING THE APP:
-        - Using command line prompt, start application with specific file to pay back:
-        for example, ./sample_player_app play_this_file.mp4
-
-        - If file is not specified, the application will look for the default input file
-        in the same directory as it is executed from, so it may be convenient to run it 
-        from the pv/engines/player/sample_app/data directory where the test.mp4 file 
-        is located.
-
-
diff --git a/engines/player/sample_app/src/linux_3gpp/sample_player_app_config.h b/engines/player/sample_app/src/linux_3gpp/sample_player_app_config.h
deleted file mode 100644
index 09c382a..0000000
--- a/engines/player/sample_app/src/linux_3gpp/sample_player_app_config.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef SAMPLE_PLAYER_APP_CONFIG_H_INCLUDED
-#define SAMPLE_PLAYER_APP_CONFIG_H_INCLUDED
-
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-
-// audio sink output type
-#define AUDIOSINK_FORMAT_TYPE PVMF_AMR_IETF
-// video sink output type
-#define VIDEOSINK_FORMAT_TYPE PVMF_M4V
-
-// The default test file to use
-#define DEFAULTSOURCEFILENAME "test.mp4"
-#define DEFAULTSOURCEFORMATTYPE PVMF_MPEG4FF
-
-
-// Set to 1 to use the scheduler native to the system instead of PV scheduler
-#define USE_NATIVE_SCHEDULER 0
-
-// The string to prepend to source filenames
-#define SOURCENAME_PREPEND_STRING ""
-#define SOURCENAME_PREPEND_WSTRING _STRLIT_WCHAR("")
-
-// The string to prepend to output filenames
-#define OUTPUTNAME_PREPEND_STRING ""
-#define OUTPUTNAME_PREPEND_WSTRING _STRLIT_WCHAR("")
-
-#endif
-
diff --git a/engines/player/sample_app/src/linux_nj/sample_player_app_config.h b/engines/player/sample_app/src/linux_nj/sample_player_app_config.h
deleted file mode 100644
index 09c382a..0000000
--- a/engines/player/sample_app/src/linux_nj/sample_player_app_config.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef SAMPLE_PLAYER_APP_CONFIG_H_INCLUDED
-#define SAMPLE_PLAYER_APP_CONFIG_H_INCLUDED
-
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-
-// audio sink output type
-#define AUDIOSINK_FORMAT_TYPE PVMF_AMR_IETF
-// video sink output type
-#define VIDEOSINK_FORMAT_TYPE PVMF_M4V
-
-// The default test file to use
-#define DEFAULTSOURCEFILENAME "test.mp4"
-#define DEFAULTSOURCEFORMATTYPE PVMF_MPEG4FF
-
-
-// Set to 1 to use the scheduler native to the system instead of PV scheduler
-#define USE_NATIVE_SCHEDULER 0
-
-// The string to prepend to source filenames
-#define SOURCENAME_PREPEND_STRING ""
-#define SOURCENAME_PREPEND_WSTRING _STRLIT_WCHAR("")
-
-// The string to prepend to output filenames
-#define OUTPUTNAME_PREPEND_STRING ""
-#define OUTPUTNAME_PREPEND_WSTRING _STRLIT_WCHAR("")
-
-#endif
-
diff --git a/engines/player/sample_app/src/pv_player_engine_testset_mio_file.cpp b/engines/player/sample_app/src/pv_player_engine_testset_mio_file.cpp
deleted file mode 100644
index 4ea64ef..0000000
--- a/engines/player/sample_app/src/pv_player_engine_testset_mio_file.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// copied in from /engines/player/test/src/test_pv_player_engine_testset_mio_file.cpp
-
-// local version
-#include "pv_player_test_mio_factory.h"
-
-
-//File Output MIO implementation.
-
-#ifndef PVMI_MEDIA_IO_FILEOUTPUT_H_INCLUDED
-#include "pvmi_media_io_fileoutput.h"
-#endif
-
-PvmiMIOControl* PVPlayerTestMioFactory::CreateAudioOutput(OsclAny* aParam)
-{
-    return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr());
-}
-
-PvmiMIOControl* PVPlayerTestMioFactory::CreateAudioOutput(
-    OsclAny* aParam,
-    PVRefFileOutputTestObserver* aObserver,
-    bool aActiveTiming,
-    uint32 aQueueLimit,
-    bool aSimFlowControl,
-    bool logStrings)
-{
-    return new PVRefFileOutput(
-               *(OSCL_wString*)aParam,
-               aObserver,
-               aActiveTiming,
-               aQueueLimit,
-               aSimFlowControl,
-               logStrings);
-}
-
-void PVPlayerTestMioFactory::DestroyAudioOutput(PvmiMIOControl* aMio)
-{
-    PVRefFileOutput* mio = (PVRefFileOutput*)aMio;
-    delete mio;
-}
-
-PvmiMIOControl* PVPlayerTestMioFactory::CreateVideoOutput(OsclAny* aParam)
-{
-    return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr());
-}
-
-PvmiMIOControl* PVPlayerTestMioFactory::CreateVideoOutput(
-    OsclAny* aParam,
-    PVRefFileOutputTestObserver* aObserver,
-    bool aActiveTiming,
-    uint32 aQueueLimit,
-    bool aSimFlowControl,
-    bool logStrings)
-{
-    return new PVRefFileOutput(
-               *(OSCL_wString*)aParam,
-               aObserver,
-               aActiveTiming,
-               aQueueLimit,
-               aSimFlowControl,
-               logStrings);
-}
-
-void PVPlayerTestMioFactory::DestroyVideoOutput(PvmiMIOControl* aMio)
-{
-    PVRefFileOutput* mio = (PVRefFileOutput*)aMio;
-    delete mio;
-}
-
-PvmiMIOControl* PVPlayerTestMioFactory::CreateTextOutput(OsclAny* aParam)
-{
-    return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr());
-}
-
-void PVPlayerTestMioFactory::DestroyTextOutput(PvmiMIOControl* aMio)
-{
-    PVRefFileOutput* mio = (PVRefFileOutput*)aMio;
-    delete mio;
-}
-
-void PVPlayerTestMioFactory::DeviceInit(OsclAny* aParam)
-{
-}
-
-void PVPlayerTestMioFactory::DeviceDeInit(OsclAny* aParam)
-{
-}
-
-
-
-
diff --git a/engines/player/sample_app/src/pv_player_test_mio_factory.h b/engines/player/sample_app/src/pv_player_test_mio_factory.h
deleted file mode 100644
index c3a7ff1..0000000
--- a/engines/player/sample_app/src/pv_player_test_mio_factory.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_PLAYER_TEST_MIO_FACTORY_H_INCLUDED
-# define PV_PLAYER_TEST_MIO_FACTORY_H_INCLUDED
-
-// for PvmiMIOControl:
-#include "pvmi_mio_control.h"
-// for PVRefFileOutputTestObserver:
-#include "pvmi_media_io_fileoutput.h"
-/*!
-** PVPlayerTestMioFactory: MIO Factory functions
-*/
-
-
-class PVPlayerTestMioFactory
-{
-    public:
-        static PvmiMIOControl* CreateAudioOutput(OsclAny* aParam);
-        static PvmiMIOControl* CreateAudioOutput(OsclAny* aParam, PVRefFileOutputTestObserver* aObserver, bool aActiveTiming, uint32 aQueueLimit, bool aSimFlowControl, bool logStrings = true);
-        static void DestroyAudioOutput(PvmiMIOControl* aMio);
-        static PvmiMIOControl* CreateVideoOutput(OsclAny* aParam);
-        static PvmiMIOControl* CreateVideoOutput(OsclAny* aParam, PVRefFileOutputTestObserver* aObserver, bool aActiveTiming, uint32 aQueueLimit, bool aSimFlowControl, bool logStrings = true);
-        static void DestroyVideoOutput(PvmiMIOControl* aMio);
-        static PvmiMIOControl* CreateTextOutput(OsclAny* aParam);
-        static void DestroyTextOutput(PvmiMIOControl* aMio);
-
-        static void DeviceInit(OsclAny* aParam);
-        static void DeviceDeInit(OsclAny* aParam);
-};
-
-#endif  // include guard
-
diff --git a/engines/player/sample_app/src/sample_player_app.cpp b/engines/player/sample_app/src/sample_player_app.cpp
deleted file mode 100644
index 0037790..0000000
--- a/engines/player/sample_app/src/sample_player_app.cpp
+++ /dev/null
@@ -1,944 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef SAMPLE_PLAYER_APP_H_INCLUDED
-#include "sample_player_app.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef OSCL_MEM_AUDIT_H_INCLUDED
-#include "oscl_mem_audit.h"
-#endif
-
-#ifndef OSCL_ERROR_H_INCLUDED
-#include "oscl_error.h"
-#endif
-
-#ifndef OSCL_ERROR_PANIC_H_INCLUDED
-#include "oscl_error_panic.h"
-#endif
-
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PVLOGGER_FILE_APPENDER_H_INCLUDED
-#include "pvlogger_file_appender.h"
-#endif
-
-#ifndef OSCL_UTF8CONV_H
-#include "oscl_utf8conv.h"
-#endif
-
-#ifndef SAMPLE_PLAYER_APP_CONFIG_H_INCLUDED
-#include "sample_player_app_config.h"
-#endif
-
-#ifndef OSCL_STRING_UTILS_H_INCLUDED
-#include "oscl_string_utils.h"
-#endif
-
-#ifndef PV_PLAYER_TEST_MIO_FACTORY_H_INCLUDED
-#include "pv_player_test_mio_factory.h"
-#endif
-
-#ifndef PV_MEDIA_OUTPUT_NODE_FACTORY_H_INCLUDED
-#include "pv_media_output_node_factory.h"
-#endif
-
-#ifndef PV_PLAYER_DATASINKPVMFNODE_H_INCLUDED
-#include "pv_player_datasinkpvmfnode.h"
-#endif
-
-#ifndef DEFAULTSOURCEFILENAME
-#error // The default source file needs to be defined in config file
-#endif
-
-#ifndef DEFAULTSOURCEFORMATTYPE
-#error // The format type for default source file needs to be defined in config file
-#endif
-
-int _local_main();
-
-// printing to console
-FILE* file = stdout;
-
-char* input_file_name = NULL;
-
-/*!
- *  A sample application to demostrate the normal engine sequence of playing a specified source till end of clip
- *  - Data Source: defaults to "testqvga30fps.mp4"
- *  - Data Sink(s): Video[FileOutputNode-sample_player_app_[SRCFILENAME]_video.dat]
- *                  Audio[FileOutputNode-sample_player_app__[SRCFILENAME]_audio.dat]
- *                  Text[FileOutputNode-sample_player_app__[SRCFILENAME]_text.dat]
- *
- *  - Sequence
- *             -# CreatePlayer()
- *             -# AddDataSource()
- *             -# Init()
- *             -# AddDataSink() (video)
- *             -# AddDataSink() (audio)
- *             -# AddDataSink() (text)
- *             -# GetMetadataValues()
- *             -# Prepare()
- *             -# Start()
- *             -# Play till EOS
- *             -# Stop()
- *             -# RemoveDataSink() (video)
- *             -# RemoveDataSink() (audio)
- *             -# RemoveDataSink() (text)
- *             -# Reset()
- *             -# RemoveDataSource()
- *             -# DeletePlayer()
- *
- */
-
-
-// Entry point for sample program
-int main(int argc, char **argv)
-{
-    if (argc > 1)
-    {
-        input_file_name = argv[1];
-    }
-
-    fprintf(file, "Sample application for pvPlayer engine:\n");
-
-    //Init Oscl
-    OsclBase::Init();
-    OsclErrorTrap::Init();
-    OsclMem::Init();
-
-    //Run the test under a trap
-    int result = -1;
-    int32 err;
-    TPVErrorPanic panic;
-
-    OSCL_PANIC_TRAP(err, panic, result = _local_main(););
-
-    //Show any exception.
-    if (err != 0)
-    {
-        fprintf(file, "Error!  Leave %d\n", err);
-    }
-    if (panic.iReason != 0)
-    {
-        fprintf(file, "Error!  Panic %s %d\n", panic.iCategory.Str(), panic.iReason);
-    }
-
-    //Cleanup
-#if !(OSCL_BYPASS_MEMMGT)
-    //Check for memory leaks before cleaning up OsclMem.
-    OsclAuditCB auditCB;
-    OsclMemInit(auditCB);
-    if (auditCB.pAudit)
-    {
-        MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
-        if (stats)
-        {
-            fprintf(file, "\nAfter Playback Memory Stats:\n");
-            fprintf(file, "  peakNumAllocs %d\n", stats->peakNumAllocs);
-            fprintf(file, "  peakNumBytes %d\n", stats->peakNumBytes);
-            fprintf(file, "  totalNumAllocs %d\n", stats->totalNumAllocs);
-            fprintf(file, "  totalNumBytes %d\n", stats->totalNumBytes);
-            fprintf(file, "  numAllocFails %d\n", stats->numAllocFails);
-            if (stats->numAllocs)
-            {
-                fprintf(file, "  ERROR: Memory Leaks! numAllocs %d, numBytes %d\n", stats->numAllocs, stats->numBytes);
-            }
-        }
-        uint32 leaks = auditCB.pAudit->MM_GetNumAllocNodes();
-        if (leaks != 0)
-        {
-            fprintf(file, "ERROR: %d Memory leaks detected!\n", leaks);
-            MM_AllocQueryInfo*info = auditCB.pAudit->MM_CreateAllocNodeInfo(leaks);
-            uint32 leakinfo = auditCB.pAudit->MM_GetAllocNodeInfo(info, leaks, 0);
-            if (leakinfo != leaks)
-            {
-                fprintf(file, "ERROR: Leak info is incomplete.\n");
-            }
-            for (uint32 i = 0;i < leakinfo;i++)
-            {
-                fprintf(file, "Leak Info:\n");
-                fprintf(file, "  allocNum %d\n", info[i].allocNum);
-                fprintf(file, "  fileName %s\n", info[i].fileName);
-                fprintf(file, "  lineNo %d\n", info[i].lineNo);
-                fprintf(file, "  size %d\n", info[i].size);
-                fprintf(file, "  pMemBlock 0x%x\n", info[i].pMemBlock);
-                fprintf(file, "  tag %s\n", info[i].tag);
-            }
-            auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
-        }
-    }
-#endif
-
-    OsclMem::Cleanup();
-    OsclErrorTrap::Cleanup();
-    OsclBase::Cleanup();
-
-    return result;
-}
-
-////////
-
-int _local_main()
-{
-    // default source filename is "test.mp4"
-    OSCL_HeapString<OsclMemAllocator> filenameinfo;
-    filenameinfo = SOURCENAME_PREPEND_STRING;
-
-    if (input_file_name != NULL)
-    {
-        filenameinfo += input_file_name;
-    }
-    else
-    {
-        filenameinfo += DEFAULTSOURCEFILENAME;
-    }
-
-    // default source file format is MP4
-    PVMFFormatType inputformattype = DEFAULTSOURCEFORMATTYPE;
-
-    fprintf(file, "  Input file name '%s'\n", filenameinfo.get_cstr());
-
-    // instantiate a player engine
-    pvplayer_engine_interface *engine_interface = new pvplayer_engine_interface(filenameinfo.get_str(), inputformattype);
-    if (engine_interface)
-    {
-#if !(OSCL_BYPASS_MEMMGT)
-        // Obtain the current mem stats before running the test case
-        OsclAuditCB auditCB;
-        OsclMemInit(auditCB);
-        if (auditCB.pAudit)
-        {
-            MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
-            if (stats)
-            {
-                fprintf(file, "\nBefore Playback Memory Stats:\n");
-                fprintf(file, "  totalNumAllocs %d\n", stats->totalNumAllocs);
-                fprintf(file, "  totalNumBytes %d\n", stats->totalNumBytes);
-                fprintf(file, "  numAllocFails %d\n", stats->numAllocFails);
-                fprintf(file, "  numAllocs %d\n", stats->numAllocs);
-            }
-            else
-            {
-                fprintf(file, "Retrieving memory statistics before running test case failed! Memory statistics result would be invalid.\n");
-            }
-        }
-        else
-        {
-            fprintf(file, "Memory audit not available! Memory statistics result would be invalid.\n");
-        }
-#endif
-
-        fprintf(file, "\nStarting Playback\n ");
-
-        // Enable the following code for logging
-        PVLogger::Init();
-        PVLoggerAppender *appender = NULL;
-        OsclRefCounter *refCounter = NULL;
-
-        // Log all nodes, for errors only, to the stdout
-        appender = new StdErrAppender<TimeAndIdLayout, 1024>();
-        OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > > *appenderRefCounter =
-            new OsclRefCounterSA<LogAppenderDestructDealloc<StdErrAppender<TimeAndIdLayout, 1024> > >(appender);
-        refCounter = appenderRefCounter;
-
-        OsclSharedPtr<PVLoggerAppender> appenderPtr(appender, refCounter);
-
-#if 0
-        // log everything at DEBUG
-        PVLogger *rootnode = PVLogger::GetLoggerObject("");
-        rootnode->AddAppender(appenderPtr);
-        rootnode->SetLogLevel(PVLOGMSG_DEBUG);
-#endif
-#if 0
-        // log specific components
-        PVLogger *node;
-
-        node = PVLogger::GetLoggerObject("PVPlayerEngine");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(PVLOGMSG_DEBUG);
-
-        node = PVLogger::GetLoggerObject("PVMFMP4FFParserNode");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(PVLOGMSG_DEBUG);
-
-        node = PVLogger::GetLoggerObject("PVMFFileOutputNode");
-        node->AddAppender(appenderPtr);
-        node->SetLogLevel(PVLOGMSG_DEBUG);
-
-        // Log datapath only
-        node = PVLogger::GetLoggerObject("datapath");
-        node->AddAppender(appenderPtr);
-        //info level logs ports & synchronization info.
-        node->SetLogLevel(PVLOGMSG_INFO);
-#endif
-
-        // Construct and install the active scheduler
-        OsclScheduler::Init("PVPlayerEngineScheduler");
-
-        OsclExecScheduler *sched = OsclExecScheduler::Current();
-        if (sched)
-        {
-            // Start playback
-            engine_interface->StartPlayback();
-
-            // Start the scheduler
-            // control is transfered to the player engine when StartScheduler() is called
-            // control is regained when StopScheduler() is called
-            fprintf(file, "\nStarting Scheduler\n ");
-#if USE_NATIVE_SCHEDULER
-            // Have PV scheduler use the scheduler native to the system
-            sched->StartNativeScheduler();
-#else
-            // Have PV scheduler use its own implementation of the scheduler
-            sched->StartScheduler();
-#endif
-        }
-        else
-        {
-            fprintf(file, "ERROR! Scheduler is not available. Test case could not run.");
-        }
-
-        // when playback completes, StopScheduler is called
-        // and control is returned to this location
-
-        // Shutdown PVLogger and scheduler before checking mem stats
-        OsclScheduler::Cleanup();
-        PVLogger::Cleanup();
-
-        // done with playback, free resources
-        OSCL_DELETE(engine_interface);
-        engine_interface = NULL;
-
-        return 0;
-    }
-    else
-    {
-        fprintf(file, "ERROR! pvplayer_engine_interface could not be instantiated.\n");
-        return 1;
-    }
-}
-
-
-////////
-
-pvplayer_engine_interface::pvplayer_engine_interface(char *aFileName, PVMFFormatType aFileType) : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerEngine"),
-        iState(STATE_UNKNOWN),
-        iPlayer(NULL),
-        iDataSource(NULL),
-        iDataSinkVideo(NULL),
-        iDataSinkAudio(NULL),
-        iDataSinkText(NULL),
-        iCurrentCmdId(0),
-        iFileName(NULL),
-        iFileType(0),
-        iContextObjectRefValue(0),
-        iContextObject(0),
-        iNumValues(0),
-        iClipDuration(0)
-{
-    iFileName = aFileName;
-    iFileType = aFileType;
-
-    // Initialize the variables with some random number to use for context data testing
-    iContextObject = iContextObjectRefValue = 0x5C7A;
-
-    PVPlayerTestMioFactory::DeviceInit(this);
-}
-
-
-////////
-
-pvplayer_engine_interface::~pvplayer_engine_interface()
-{
-    PVPlayerTestMioFactory::DeviceDeInit(this);
-}
-
-////////
-void pvplayer_engine_interface::StartPlayback()
-{
-    // add this timer object to the scheduler
-    AddToScheduler();
-    // use iState to drive the playback for this simple app
-    // a command queuing mechanism may be desired
-    // where by the end user requests, such as pause playback or
-    // resume playback, are put on the queue in a separate thread
-    // and are dequeued by Run()
-    iState = STATE_CREATE;
-    // schedule this timer object to run immediately
-    RunIfNotReady();
-}
-
-////////
-
-// this is called by the PV scheduler
-void pvplayer_engine_interface::Run()
-{
-    int error = 0;
-
-    // in this simple app, state transition is used to drive the engine
-    // in proper deployment, user requests may be used instead to drive engine
-    // end user requests may be queued by in a separate thread and dequeued here
-    switch (iState)
-    {
-        case STATE_CREATE:
-        {
-            iPlayer = NULL;
-
-            OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
-            if (error)
-            {
-                // clean up
-                fprintf(file, "\nStopping Scheduler\n");
-
-                // Stop the scheduler
-                OsclExecScheduler *sched = OsclExecScheduler::Current();
-                if (sched)
-                {
-                    sched->StopScheduler();
-                }
-            }
-            else
-            {
-                // player created successfully
-                // next step is to add the data source
-                iState = STATE_ADDDATASOURCE;
-                // schedule to run immediately
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case STATE_ADDDATASOURCE:
-        {
-            // create a datasource
-            iDataSource = new PVPlayerDataSourceURL;
-
-            // convert to wchar
-            oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), output, 512);
-            wFileName.set(output, oscl_strlen(output));
-
-            iDataSource->SetDataSourceURL(wFileName);
-            iDataSource->SetDataSourceFormatType(iFileType);
-
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-
-        break;
-
-        case STATE_INIT:
-        {
-            // initialize the player
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_ADDDATASINK_VIDEO:
-        {
-            // create video sink
-            // use a file output sink for now
-            // output format is defined in config
-
-            OSCL_wHeapString<OsclMemAllocator> SinkFileName;
-            SinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            SinkFileName += _STRLIT_WCHAR("sample_player_app_");
-            OSCL_wHeapString<OsclMemAllocator> inputfilename;
-            RetrieveFilename(wFileName.get_str(), inputfilename);
-            SinkFileName += inputfilename;
-            SinkFileName += _STRLIT_WCHAR("_video.dat");
-
-            iMIOFileOutVideo = PVPlayerTestMioFactory::CreateVideoOutput
-                               ((OsclAny*) & SinkFileName,
-                                NULL,  // aObserver
-                                true,  // aActiveTiming
-                                50,    // aQueueLimit
-                                false, // aSimFlowControl
-                                false  // logStrings
-                               );
-            iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
-            iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
-
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(VIDEOSINK_FORMAT_TYPE);
-
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_ADDDATASINK_AUDIO:
-        {
-            // create audio sink
-            // use a file output sink for now
-            // default output format is PCM16
-
-            OSCL_wHeapString<OsclMemAllocator> SinkFileName;
-            SinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            SinkFileName += _STRLIT_WCHAR("sample_player_app_");
-            OSCL_wHeapString<OsclMemAllocator> inputfilename;
-            RetrieveFilename(wFileName.get_str(), inputfilename);
-            SinkFileName += inputfilename;
-            SinkFileName += _STRLIT_WCHAR("_audio.dat");
-
-            iMIOFileOutAudio = PVPlayerTestMioFactory::CreateAudioOutput
-                               ((OsclAny*) & SinkFileName,
-                                NULL,  // aObserver
-                                true,  // aActiveTiming
-                                50,    // aQueueLimit
-                                false, // aSimFlowControl
-                                false  // logStrings
-                               );
-
-            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
-            iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
-
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_ADDDATASINK_TEXT:
-        {
-            // create text sink
-            // use a file output sink for now
-            // default output format is 3GPP timed text
-
-            OSCL_wHeapString<OsclMemAllocator> SinkFileName;
-            SinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            SinkFileName += _STRLIT_WCHAR("sample_player_app_");
-            OSCL_wHeapString<OsclMemAllocator> inputfilename;
-            RetrieveFilename(wFileName.get_str(), inputfilename);
-            SinkFileName += inputfilename;
-            SinkFileName += _STRLIT_WCHAR("_text.dat");
-
-            iMIOFileOutText = PVPlayerTestMioFactory::CreateTextOutput((OsclAny*) & SinkFileName); // simple form
-            iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
-            iDataSinkText = new PVPlayerDataSinkPVMFNode;
-
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
-
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_GETMETADATAVALUES:
-        {
-            // find out the source clip duration
-            // the duration is retrieved from the metadata
-            iMetadataKeyList.push_back(OSCL_HeapString<OsclMemAllocator>("duration"));
-            iMetadataValueList.clear();
-            iNumValues = 0;
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0,  -1, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_PREPARE:
-        {
-            // prepare the player
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_START:
-        {
-            // start playback from the beginning of the clip
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_EOSNOTREACHED:
-        {
-            // stop the playback
-            iState = STATE_STOP;
-            RunIfNotReady();
-        }
-        break;
-
-        case STATE_STOP:
-        {
-            // stop the player
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_REMOVEDATASINK_VIDEO:
-        {
-            // remove the video sink, which is a currently a file output sink
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_REMOVEDATASINK_AUDIO:
-        {
-            // remove the audio sink, which is a currently a file output sink
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_REMOVEDATASINK_TEXT:
-        {
-            // remove the text sink, which is a currently a file output sink
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_RESET:
-        {
-            // reset the player
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_REMOVEDATASOURCE:
-        {
-            // remove the data souce
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-        }
-        break;
-
-        case STATE_CLEANUPANDCOMPLETE:
-        {
-            // free up all resources
-            PVPlayerFactory::DeletePlayer(iPlayer);
-            iPlayer = NULL;
-
-            OSCL_DELETE(iDataSource);
-            iDataSource = NULL;
-
-            OSCL_DELETE(iDataSinkVideo);
-            iDataSinkVideo = NULL;
-
-            OSCL_DELETE(iDataSinkAudio);
-            iDataSinkAudio = NULL;
-
-            OSCL_DELETE(iDataSinkText);
-            iDataSinkText = NULL;
-
-            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
-            iIONodeVideo = NULL;
-
-            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
-            iIONodeAudio = NULL;
-
-            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeText);
-            iIONodeText = NULL;
-
-            PVPlayerTestMioFactory::DestroyVideoOutput(iMIOFileOutVideo);
-            iMIOFileOutVideo = NULL;
-
-            PVPlayerTestMioFactory::DestroyAudioOutput(iMIOFileOutAudio);
-            iMIOFileOutAudio = NULL;
-
-            PVPlayerTestMioFactory::DestroyTextOutput(iMIOFileOutText);
-            iMIOFileOutText = NULL;
-
-            fprintf(file, "\nStopping Scheduler\n");
-
-            // Stop the scheduler
-            OsclExecScheduler *sched = OsclExecScheduler::Current();
-            if (sched)
-            {
-                sched->StopScheduler();
-            }
-        }
-        break;
-
-        default:
-            break;
-
-    }
-}
-
-////////
-
-// callback by PV engine when a request has been completed
-void pvplayer_engine_interface::CommandCompleted(const PVCmdResponse& aResponse)
-{
-    if (aResponse.GetCmdId() != iCurrentCmdId)
-    {
-        // Wrong command ID.
-        fprintf(file, "\nCommandCompleted Mismatched Id\n");
-        iState = STATE_CLEANUPANDCOMPLETE;
-        RunIfNotReady();
-        return;
-    }
-
-    if (aResponse.GetContext() != NULL)
-    {
-        if (aResponse.GetContext() == (OsclAny*)&iContextObject)
-        {
-            if (iContextObject != iContextObjectRefValue)
-            {
-                // Context data value was corrupted
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                return;
-            }
-        }
-        else
-        {
-            // Context data pointer was corrupted
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-            return;
-        }
-    }
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        // Treat as unrecoverable error
-        iState = STATE_CLEANUPANDCOMPLETE;
-        RunIfNotReady();
-        return;
-    }
-
-    bool bWait = false;
-
-    switch (iState)
-    {
-        case STATE_ADDDATASOURCE:
-            // Data source was added
-            // Initialize the player
-            iState = STATE_INIT;
-            break;
-
-        case STATE_INIT:
-            // Player was initialized
-            // Add video sink
-            iState = STATE_ADDDATASINK_VIDEO;
-            break;
-
-        case STATE_ADDDATASINK_VIDEO:
-            // Video sink was added
-            // Add audio sink
-            iState = STATE_ADDDATASINK_AUDIO;
-            break;
-
-        case STATE_ADDDATASINK_AUDIO:
-            // Audio sink was added
-            // Add text sink
-            iState = STATE_ADDDATASINK_TEXT;
-            break;
-
-        case STATE_ADDDATASINK_TEXT:
-            // Text sink was added
-            // Retrieve metadata values (clip duration in particular)
-            iState = STATE_GETMETADATAVALUES;
-            break;
-
-        case STATE_GETMETADATAVALUES:
-            // If duration is available, get it. Default is 10 sec
-            iClipDuration = 10000;
-            if (iMetadataValueList.empty() == false)
-            {
-                for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
-                {
-                    // Search for timescale and duration info
-                    char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
-                    if (substr != NULL)
-                    {
-                        uint32 timescale = 1000;
-                        if (PV_atoi((substr + 34), 'd', timescale) == false)
-                        {
-                            // No timescale info, default to 1000
-                            timescale = 1000;
-                        }
-                        uint32 duration = iMetadataValueList[i].value.uint32_value;
-                        if (duration > 0 && timescale > 0)
-                        {
-                            // Save the clip duration in milliseconds
-                            iClipDuration = ((duration * 1000) / timescale);
-                        }
-                    }
-                }
-            }
-
-            fprintf(file, " clip duration %d\n ", iClipDuration);
-
-            // Prepare for playback
-            iState = STATE_PREPARE;
-            break;
-
-        case STATE_PREPARE:
-            // Prepare succeeded
-            // Start playback
-            iState = STATE_START;
-            break;
-
-        case STATE_START:
-            // Wait until EOS
-            iState = STATE_EOSNOTREACHED;
-            bWait = true;
-            break;
-
-        case STATE_STOP:
-            // Engine stopped
-            // Remove the video sink
-            iState = STATE_REMOVEDATASINK_VIDEO;
-            break;
-
-        case STATE_REMOVEDATASINK_VIDEO:
-            // Video sink removed
-            // Remove audio sink
-            iState = STATE_REMOVEDATASINK_AUDIO;
-            break;
-
-        case STATE_REMOVEDATASINK_AUDIO:
-            // Audio sink removed
-            // Remove text sink
-            iState = STATE_REMOVEDATASINK_TEXT;
-            break;
-
-        case STATE_REMOVEDATASINK_TEXT:
-            // Text sink removed
-            // Reset engine
-            iState = STATE_RESET;
-            break;
-
-        case STATE_RESET:
-            // Engine reset
-            // Remove data source
-            iState = STATE_REMOVEDATASOURCE;
-            break;
-
-        case STATE_REMOVEDATASOURCE:
-            // Data source removed
-            // Free resouces
-            iState = STATE_CLEANUPANDCOMPLETE;
-            break;
-
-        default:
-            // engine error if this is reached
-            fprintf(file, "\nCommandCompleted unknown state %d\n ", iState);
-            iState = STATE_CLEANUPANDCOMPLETE;
-            break;
-    } // end switch
-
-    if (bWait == false)
-    {
-        // schedule this object to run immediately
-        RunIfNotReady();
-    }
-
-}
-
-
-////////
-
-// callback by PV engine when an error is encountered
-void pvplayer_engine_interface::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
-{
-    switch (aEvent.GetEventType())
-    {
-        case PVMFErrResourceConfiguration:
-        case PVMFErrResource:
-        case PVMFErrCorrupt:
-        case PVMFErrProcessing:
-            // Just log the error for now
-            fprintf(file, "\nHandleErrorEvent event type %d\n ", aEvent.GetEventType());
-            break;
-
-        default:
-            // Unknown error and just log the error
-            fprintf(file, "\nHandleErrorEvent unknown event type %d\n ", aEvent.GetEventType());
-            break;
-    }
-}
-
-
-////////
-
-// callback by PV engine when information is available
-void pvplayer_engine_interface::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
-{
-    PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
-
-    // Check for end of clip event and clip position event
-    if ((aEvent.GetEventType() == PVMFInfoEndOfData) || (aEvent.GetEventType() == PVMFInfoPositionStatus))
-    {
-        if (iface == NULL)
-        {
-            return;
-        }
-
-        PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
-        PVMFErrorInfoMessageInterface* infomsgiface = NULL;
-        if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
-        {
-            int32 infocode;
-            PVUuid infouuid;
-            infomsgiface->GetCodeUUID(infocode, infouuid);
-
-            if (infouuid == PVPlayerErrorInfoEventTypesUUID)
-            {
-                if (infocode == PVPlayerInfoEndOfClipReached)
-                {
-                    fprintf(file, "\nEnd of Clip Reached\n ");
-
-                    // Playback has reached end of clip
-                    // Stop the player
-                    iState = STATE_STOP;
-                    Cancel();
-                    RunIfNotReady();
-                }
-                else if (infocode == PVPlayerInfoPlaybackPositionStatus)
-                {
-                    // position update
-                    // retrieve and display the media time
-                    uint32 aPos = 0;
-
-                    uint8* localbuf = aEvent.GetLocalBuffer();
-                    if (aEvent.GetLocalBufferSize() == 8 && localbuf[0] == 1)
-                    {
-                        oscl_memcpy(&aPos, &localbuf[4], sizeof(uint32));
-                    }
-
-                    fprintf(file, " media time %d\r ", aPos);
-                    fflush(file);
-                }
-            }
-        }
-    }
-}
-
-
diff --git a/engines/player/sample_app/src/sample_player_app.h b/engines/player/sample_app/src/sample_player_app.h
deleted file mode 100644
index ef58885..0000000
--- a/engines/player/sample_app/src/sample_player_app.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef SAMPLE_PLAYER_APP_H_INCLUDED
-#define SAMPLE_PLAYER_APP_H_INCLUDED
-
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-#ifndef OSCL_EXCEPTION_H_INCLUDE
-#include "oscl_exception.h"
-#endif
-
-#ifndef PV_PLAYER_FACTORY_H_INCLUDED
-#include "pv_player_factory.h"
-#endif
-
-#ifndef PV_PLAYER_INTERFACE_H_INCLUDE
-#include "pv_player_interface.h"
-#endif
-
-#ifndef PV_ENGINE_OBSERVER_H_INCLUDED
-#include "pv_engine_observer.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PVLOGGER_STDERR_APPENDER_H_INCLUDED
-#include "pvlogger_stderr_appender.h"
-#endif
-
-#ifndef PVLOGGER_TIME_AND_ID_LAYOUT_H_INCLUDED
-#include "pvlogger_time_and_id_layout.h"
-#endif
-
-#ifndef PVMI_MEDIA_IO_FILEOUTPUT_H_INCLUDED
-#include "pvmi_media_io_fileoutput.h"
-#endif
-
-#ifndef PV_PLAYER_DATASOURCEURL_H_INCLUDED
-#include "pv_player_datasourceurl.h"
-#endif
-
-#ifndef PV_PLAYER_DATASINKFILENAME_H_INCLUDED
-#include "pv_player_datasinkfilename.h"
-#endif
-
-#ifndef PVMF_ERRORINFOMESSAGE_EXTENSION_H_INCLUDED
-#include "pvmf_errorinfomessage_extension.h"
-#endif
-
-
-// for PVLogger
-template<class DestructClass>
-class LogAppenderDestructDealloc : public OsclDestructDealloc
-{
-    public:
-        virtual void destruct_and_dealloc(OsclAny *ptr)
-        {
-            delete((DestructClass*)ptr);
-        }
-};
-
-
-class pvplayer_engine_interface : public OsclTimerObject,
-            public PVCommandStatusObserver,
-            public PVInformationalEventObserver,
-            public PVErrorEventObserver
-{
-    public:
-        pvplayer_engine_interface(char *aFileName, PVMFFormatType aFileType);
-        ~pvplayer_engine_interface();
-
-        // needed for OsclTimerObject
-        void Run();
-
-        void CommandCompleted(const PVCmdResponse& aResponse);
-        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
-        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
-
-        enum PVPlayerState
-        {
-            STATE_UNKNOWN,
-            STATE_CREATE,
-            STATE_ADDDATASOURCE,
-            STATE_INIT,
-            STATE_ADDDATASINK_VIDEO,
-            STATE_ADDDATASINK_AUDIO,
-            STATE_ADDDATASINK_TEXT,
-            STATE_GETMETADATAVALUES,
-            STATE_PREPARE,
-            STATE_START,
-            STATE_EOSNOTREACHED,
-            STATE_STOP,
-            STATE_REMOVEDATASINK_VIDEO,
-            STATE_REMOVEDATASINK_AUDIO,
-            STATE_REMOVEDATASINK_TEXT,
-            STATE_RESET,
-            STATE_REMOVEDATASOURCE,
-            STATE_CLEANUPANDCOMPLETE
-        };
-
-        PVPlayerState iState;
-        PVPlayerInterface* iPlayer;
-
-        PVPlayerDataSourceURL* iDataSource;
-        PVPlayerDataSink* iDataSinkVideo;
-        PVPlayerDataSink* iDataSinkAudio;
-        PVPlayerDataSink* iDataSinkText;
-
-        PVMFNodeInterface* iIONodeVideo;
-        PVMFNodeInterface* iIONodeAudio;
-        PVMFNodeInterface* iIONodeText;
-        PvmiMIOControl* iMIOFileOutVideo;
-        PvmiMIOControl* iMIOFileOutAudio;
-        PvmiMIOControl* iMIOFileOutText;
-
-        PVCommandId iCurrentCmdId;
-
-        // Utility function to retrieve the filename from string and replace ',' with '_'
-        void RetrieveFilename(const oscl_wchar* aSource, OSCL_wHeapString<OsclMemAllocator>& aFilename)
-        {
-            if (aSource == NULL)
-            {
-                return;
-            }
-
-            // Find the last '\' or '/' in the string
-            oscl_wchar* lastslash = (oscl_wchar*)aSource;
-            bool foundlastslash = false;
-            while (!foundlastslash)
-            {
-                oscl_wchar* tmp1 = oscl_strstr(lastslash, _STRLIT_WCHAR("\\"));
-                oscl_wchar* tmp2 = oscl_strstr(lastslash, _STRLIT_WCHAR("/"));
-                if (tmp1 != NULL)
-                {
-                    lastslash = tmp1 + 1;
-                }
-                else if (tmp2 != NULL)
-                {
-                    lastslash = tmp2 + 1;
-                }
-                else
-                {
-                    foundlastslash = true;
-                }
-            }
-
-            // Now copy the filename
-            if (lastslash)
-            {
-                aFilename = lastslash;
-            }
-
-            // Replace each '.' in filename with '_'
-            bool finishedreplace = false;
-            while (!finishedreplace)
-            {
-                oscl_wchar* tmp = oscl_strstr(aFilename.get_cstr(), _STRLIT_WCHAR("."));
-                if (tmp != NULL)
-                {
-                    oscl_strncpy(tmp, _STRLIT_WCHAR("_"), 1);
-                }
-                else
-                {
-                    finishedreplace = true;
-                }
-            }
-        }
-
-        void StartPlayback();
-
-
-
-    private:
-        char *iFileName;
-        PVMFFormatType iFileType;
-
-        //for context data testing
-        uint32 iContextObjectRefValue;
-        uint32 iContextObject;
-
-        // for metadata retrieval
-        PVPMetadataList iMetadataKeyList;
-        Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
-        int32 iNumValues;
-        uint32 iClipDuration;
-
-        OSCL_wHeapString<OsclMemAllocator> wFileName;
-        oscl_wchar output[512];
-};
-
-
-#endif
-
-
diff --git a/engines/player/src/pv_player_datapath.cpp b/engines/player/src/pv_player_datapath.cpp
index d05977f..31bd3dc 100644
--- a/engines/player/src/pv_player_datapath.cpp
+++ b/engines/player/src/pv_player_datapath.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 //
 PVPlayerDatapath::PVPlayerDatapath() :
         OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerDatapath"),
+        iState(PVPDP_IDLE),
         iSourceNode(NULL), iSourceSessionId(0),
         iDecNode(NULL), iDecSessionId(0),
         iSinkNode(NULL), iSinkSessionId(0),
@@ -39,11 +40,10 @@
         iErrorObserver(NULL),
         iInfoObserver(NULL),
         iContext(NULL),
-        iSourceDecFormatType(PVMF_FORMAT_UNKNOWN),
-        iDecSinkFormatType(PVMF_FORMAT_UNKNOWN),
-        iSourceSinkFormatType(PVMF_FORMAT_UNKNOWN),
+        iSourceDecFormatType(PVMF_MIME_FORMAT_UNKNOWN),
+        iDecSinkFormatType(PVMF_MIME_FORMAT_UNKNOWN),
+        iSourceSinkFormatType(PVMF_MIME_FORMAT_UNKNOWN),
         iSourceTrackInfo(NULL),
-        iState(PVPDP_IDLE),
         iDatapathConfig(CONFIG_NONE),
         iErrorCondition(false),
         iErrorOccurredDuringErrorCondition(false)
@@ -302,17 +302,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Init() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->Init(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Init on iDecNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathInit(iDecNode, iDecSessionId, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Init on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -320,17 +318,15 @@
             }
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Init() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->Init(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Init on iSinkNode did a leave"));
-                                 iState = PVPDP_ERROR; RunIfNotReady(); break);
-            if (cmdid != -1)
+            leavecode = IssueDatapathInit(iSinkNode, iSinkSessionId, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Init on iSinkNode did a leave"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -345,18 +341,17 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling RequestPort() on source node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSourceNode->RequestPort(iSourceSessionId, iSourceTrackInfo->getPortTag(),
-                                        &(iSourceTrackInfo->getTrackMimeType()), (OsclAny*)iSourceNode));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iSourceNode did a leave"));
-                                 iState = PVPDP_ERROR; RunIfNotReady(); break);
-            if (cmdid != -1)
+            leavecode = IssueDatapathRequestPort(iSourceNode, iSourceSessionId, iSourceTrackInfo->getPortTag(),
+                                                 &(iSourceTrackInfo->getTrackMimeType()),
+                                                 (OsclAny*)iSourceNode, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iSourceNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -365,54 +360,50 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling RequestPort() on dec node(input)"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->RequestPort(iDecSessionId, DEFAULT_INPUT_PORTTAG, &(iSourceTrackInfo->getTrackMimeType()),
-                                            (OsclAny*) iSourceTrackInfo));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iDecNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathRequestPort(iDecNode, iDecSessionId, DEFAULT_INPUT_PORTTAG,
+                                                     &(iSourceTrackInfo->getTrackMimeType()),
+                                                     (OsclAny*)iSourceTrackInfo, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
                 }
 
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling RequestPort() on dec node(output)"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->RequestPort(iDecSessionId, DEFAULT_OUTPUT_PORTTAG, &iDecSinkFormatString,
-                                            (OsclAny*) & iDecSinkFormatString));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iDecNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathRequestPort(iDecNode, iDecSessionId, DEFAULT_OUTPUT_PORTTAG,
+                                                     &iDecSinkFormatString, (OsclAny*) & iDecSinkFormatString, cmdid);
+
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
                 }
 
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling RequestPort() on sink node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iSinkNode->RequestPort(iSinkSessionId, DEFAULT_INPUT_PORTTAG, &iDecSinkFormatString,
-                                            (OsclAny*)iSinkNode));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iSinkNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathRequestPort(iSinkNode, iSinkSessionId, DEFAULT_INPUT_PORTTAG,
+                                                     &iDecSinkFormatString, (OsclAny*)iSinkNode, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iSinkNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -421,18 +412,17 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling RequestPort() on sink node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iSinkNode->RequestPort(iSinkSessionId, DEFAULT_INPUT_PORTTAG, &(iSourceTrackInfo->getTrackMimeType()),
-                                            (OsclAny*)iSinkNode));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iSinkNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathRequestPort(iSinkNode, iSinkSessionId, DEFAULT_INPUT_PORTTAG,
+                                                     &(iSourceTrackInfo->getTrackMimeType()),
+                                                     (OsclAny*)iSinkNode, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() RequestPort on iSinkNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -447,9 +437,9 @@
 
             if (iDatapathConfig == CONFIG_DEC)
             {
-                PvmiCapabilityAndConfig *portconfigif = NULL;
-
-                iSourceOutPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)portconfigif);
+                OsclAny* temp = NULL;
+                iSourceOutPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                PvmiCapabilityAndConfig *portconfigif = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (portconfigif)
                 {
                     pvmiSetPortFormatSync(portconfigif, PORT_CONFIG_INPUT_FORMATS_VALTYPE, iSourceDecFormatType);
@@ -462,8 +452,9 @@
                     break;
                 }
 
-                portconfigif = NULL;
-                iDecInPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)portconfigif);
+                temp = NULL;
+                iDecInPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                portconfigif = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (portconfigif)
                 {
                     pvmiSetPortFormatSync(portconfigif, PORT_CONFIG_INPUT_FORMATS_VALTYPE, iSourceDecFormatType);
@@ -484,8 +475,9 @@
                     break;
                 }
 
-                portconfigif = NULL;
-                iDecOutPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)portconfigif);
+                temp = NULL;
+                iDecOutPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                portconfigif = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (portconfigif)
                 {
                     pvmiSetPortFormatSync(portconfigif, PORT_CONFIG_INPUT_FORMATS_VALTYPE, iDecSinkFormatType);
@@ -498,8 +490,9 @@
                     break;
                 }
 
-                portconfigif = NULL;
-                iSinkInPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)portconfigif);
+                temp = NULL;
+                iSinkInPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                portconfigif = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (portconfigif)
                 {
                     pvmiSetPortFormatSync(portconfigif, PORT_CONFIG_INPUT_FORMATS_VALTYPE, iDecSinkFormatType);
@@ -522,9 +515,9 @@
             }
             else
             {
-                PvmiCapabilityAndConfig *portconfigif;
-
-                iSourceOutPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)portconfigif);
+                OsclAny* temp;
+                iSourceOutPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                PvmiCapabilityAndConfig *portconfigif = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (portconfigif)
                 {
                     pvmiSetPortFormatSync(portconfigif, PORT_CONFIG_INPUT_FORMATS_VALTYPE, iSourceSinkFormatType);
@@ -537,7 +530,9 @@
                     break;
                 }
 
-                iSinkInPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)portconfigif);
+                temp = NULL;
+                iSinkInPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                portconfigif = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (portconfigif)
                 {
                     pvmiSetPortFormatSync(portconfigif, PORT_CONFIG_INPUT_FORMATS_VALTYPE, iSourceSinkFormatType);
@@ -570,30 +565,23 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Prepare() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->Prepare(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Prepare on iSinkNode did a leave"));
-                                 iState = PVPDP_ERROR; RunIfNotReady(); break);
+            leavecode = IssueDatapathPrepare(iSinkNode, iSinkSessionId, cmdid);
 
-            if (cmdid != -1)
+            if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
                 if (iDatapathConfig == CONFIG_DEC)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Prepare() on dec node"));
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, cmdid = iDecNode->Prepare(iDecSessionId));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Prepare on iDecNode did a leave"));
-                                         iState = PVPDP_ERROR; RunIfNotReady(); break);
+                    leavecode = IssueDatapathPrepare(iDecNode, iDecSessionId, cmdid);
 
-                    if (cmdid != -1)
+                    if (cmdid != -1 && leavecode == 0)
                     {
                         ++iPendingCmds;
                     }
                     else
                     {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Prepare on iDecNode did a leave or failed"));
                         iState = PVPDP_ERROR;
                         RunIfNotReady();
                         break;
@@ -602,6 +590,7 @@
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Prepare on iSinkNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -618,17 +607,15 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Start() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->Start(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Start on iSinkNode did a leave"));
-                                 iState = PVPDP_ERROR; RunIfNotReady(); break);
-            if (cmdid != -1)
+            leavecode = IssueDatapathStart(iSinkNode, iSinkSessionId, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Start on iSinkNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -637,17 +624,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Start() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->Start(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Start on iDecNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathStart(iDecNode, iDecSessionId, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Start on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -667,17 +652,15 @@
             if (iSinkPaused == false)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Pause() on sink node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iSinkNode->Pause(iSinkSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Pause on iSinkNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathPause(iSinkNode, iSinkSessionId, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Pause on iSinkNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -692,17 +675,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Pause() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->Pause(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Pause on iDecNode did a leave"));
-                                     iState = PVPDP_ERROR; RunIfNotReady(); break);
-                if (cmdid != -1)
+                leavecode = IssueDatapathPause(iDecNode, iDecSessionId, cmdid);
+
+                if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Pause on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -728,23 +709,15 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Stop() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->Stop(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Stop on iSinkNode did a leave"));
-                                 if (!iErrorCondition)
-        {
-            iState = PVPDP_ERROR;
-            RunIfNotReady();
-                break;
-            }
-                                );
+            leavecode = IssueDatapathStop(iSinkNode, iSinkSessionId, cmdid);
+
             if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else if (!iErrorCondition)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Stop on iSinkNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -757,23 +730,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Stop() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->Stop(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Stop on iDecNode did a leave"));
-                                     if (!iErrorCondition)
-            {
-                iState = PVPDP_ERROR;
-                RunIfNotReady();
-                    break;
-                }
-                                    );
+                leavecode = IssueDatapathStop(iDecNode, iDecSessionId, cmdid);
+
                 if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else if (!iErrorCondition)
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Stop on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -786,7 +751,7 @@
 
             if (iPendingCmds == 0 && iErrorCondition)
             {
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 if (iErrorCondition && iErrorOccurredDuringErrorCondition)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Report Stop() command completed with errors during error condition"));
@@ -814,23 +779,15 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling ReleasePort() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->ReleasePort(iSinkSessionId, *iSinkInPort));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iSinkNode did a leave"));
-                                 if (!iErrorCondition)
-        {
-            iState = PVPDP_ERROR;
-            RunIfNotReady();
-                break;
-            }
-                                );
+            leavecode = IssueDatapathReleasePort(iSinkNode, iSinkSessionId, iSinkInPort, cmdid);
+
             if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else if (!iErrorCondition)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iSinkNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -843,23 +800,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling ReleasePort() on dec node(input)"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->ReleasePort(iDecSessionId, *iDecInPort));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iDecNode did a leave"));
-                                     if (!iErrorCondition)
-            {
-                iState = PVPDP_ERROR;
-                RunIfNotReady();
-                    break;
-                }
-                                    );
+                leavecode = IssueDatapathReleasePort(iDecNode, iDecSessionId, iDecInPort, cmdid);
+
                 if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else if (!iErrorCondition)
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -884,23 +833,15 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling ReleasePort() on source node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSourceNode->ReleasePort(iSourceSessionId, *iSourceOutPort));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iSourceNode did a leave"));
-                                 if (!iErrorCondition)
-        {
-            iState = PVPDP_ERROR;
-            RunIfNotReady();
-                break;
-            }
-                                );
+            leavecode = IssueDatapathReleasePort(iSourceNode, iSourceSessionId, iSourceOutPort, cmdid);
+
             if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else if (!iErrorCondition)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iSourceNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -913,23 +854,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling ReleasePort() on dec node(output)"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->ReleasePort(iDecSessionId, *iDecOutPort));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iDecNode did a leave"));
-                                     if (!iErrorCondition)
-            {
-                iState = PVPDP_ERROR;
-                RunIfNotReady();
-                    break;
-                }
-                                    );
+                leavecode = IssueDatapathReleasePort(iDecNode, iDecSessionId, iDecOutPort, cmdid);
+
                 if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else if (!iErrorCondition)
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() ReleasePort on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -968,23 +901,15 @@
             iPendingCmds = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Reset() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->Reset(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Reset on iSinkNode did a leave"));
-                                 if (!iErrorCondition)
-        {
-            iState = PVPDP_ERROR;
-            RunIfNotReady();
-                break;
-            }
-                                );
+            leavecode = IssueDatapathReset(iSinkNode, iSinkSessionId, cmdid);
+
             if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
             else if (!iErrorCondition)
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Reset on iSinkNode did a leave or failed"));
                 iState = PVPDP_ERROR;
                 RunIfNotReady();
                 break;
@@ -997,23 +922,15 @@
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Reset() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->Reset(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Reset on iDecNode did a leave"));
-                                     if (!iErrorCondition)
-            {
-                iState = PVPDP_ERROR;
-                RunIfNotReady();
-                    break;
-                }
-                                    );
+                leavecode = IssueDatapathReset(iDecNode, iDecSessionId, cmdid);
+
                 if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
                 else if (!iErrorCondition)
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Reset on iDecNode did a leave or failed"));
                     iState = PVPDP_ERROR;
                     RunIfNotReady();
                     break;
@@ -1039,22 +956,29 @@
             PVMFStatus retval;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling Disconnect() on nodes"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, retval = iSourceNode->Disconnect(iSourceSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Disconnect on iSourceNode did a leave")));
 
-            leavecode = 0;
-            OSCL_TRY(leavecode, retval = iSinkNode->Disconnect(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Disconnect on iSinkNode did a leave")));
+            retval = iSourceNode->Disconnect(iSourceSessionId);
+            if (retval != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Disconnect on iSourceNode failed, asserting"));
+                OSCL_ASSERT(false);
+            }
+
+            retval = iSinkNode->Disconnect(iSinkSessionId);
+            if (retval != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Disconnect on iSinkNode failed, asserting"));
+                OSCL_ASSERT(false);
+            }
 
             if (iDatapathConfig == CONFIG_DEC)
             {
-                leavecode = 0;
-                OSCL_TRY(leavecode, retval = iDecNode->Disconnect(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Disconnect on iDecNode did a leave")));
+                retval = iDecNode->Disconnect(iDecSessionId);
+                if (retval != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Disconnect on iDecNode failed, asserting"));
+                    OSCL_ASSERT(false);
+                }
             }
 
             iState = PVPDP_IDLE;
@@ -1078,31 +1002,31 @@
             OSCL_ASSERT(iSourceTrackInfo != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Processing PVPDP_CANCEL case for %s", iSourceTrackInfo->getTrackMimeType().get_cstr()));
 
-            iPendingCmds = 0;
-
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling CancelAllCommands() on sink node"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iSinkNode->CancelAllCommands(iSinkSessionId));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() CancelAllCommands on iSinkNode did a leave"));
-                                );
+            leavecode = IssueDatapathCancel(iSinkNode, iSinkSessionId, cmdid);
+
             if (cmdid != -1 && leavecode == 0)
             {
                 ++iPendingCmds;
             }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() CancelAllCommands on iSinkNode did a leave or failed"));
+            }
 
             if (iDatapathConfig == CONFIG_DEC)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerDatapath::Run() Calling CancelAllCommands() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iDecNode->CancelAllCommands(iDecSessionId));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() CancelAllCommands on iDecNode did a leave"));
-                                    );
+                leavecode = IssueDatapathCancel(iDecNode, iDecSessionId, cmdid);
+
                 if (cmdid != -1 && leavecode == 0)
                 {
                     ++iPendingCmds;
                 }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() CancelAllCommands on iDecNode did a leave or failed"));
+                }
             }
 
             if (iPendingCmds == 0)
@@ -1120,7 +1044,7 @@
 
         case PVPDP_ERROR:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::Run() Report command failed"));
-            iState = PVPDP_IDLE;
+            iState = PVPDP_CANCELLED;
             iObserver->HandlePlayerDatapathEvent(0, PVMFFailure, iContext);
             break;
 
@@ -1150,7 +1074,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in PREPARE_INIT state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1186,7 +1110,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in PREPARE_REQPORT state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1206,7 +1130,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in PREPARE_PREPARE state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1227,7 +1151,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in START_START state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1247,7 +1171,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in PAUSE_PAUSE state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1283,7 +1207,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in STOP_STOP state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1308,7 +1232,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in RESET_RESET state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1334,7 +1258,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in TEARDOWN_RELEASEPORT1 state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1371,7 +1295,7 @@
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerDatapath::NodeCommandCompleted() Node command failed in TEARDOWN_RELEASEPORT2 state"));
-                iState = PVPDP_IDLE;
+                iState = PVPDP_CANCELLED;
                 iObserver->HandlePlayerDatapathEvent(0, aResponse.GetCmdStatus(), iContext, (PVMFCmdResp*)&aResponse);
             }
             break;
@@ -1407,13 +1331,78 @@
     // Ignore node error events since the engine will receive it directly from the nodes
 }
 
-
-void PVPlayerDatapath::GetFormatStringFromType(PVMFFormatType &aType, OSCL_HeapString<OsclMemAllocator>& aString)
+PVMFStatus PVPlayerDatapath::IssueDatapathInit(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
 {
-    GetFormatString(aType, aString);
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->Init(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
 }
 
+PVMFStatus PVPlayerDatapath::IssueDatapathRequestPort(PVMFNodeInterface* aNode, PVMFSessionId aSessionId,
+        int32 aPortTag, PvmfMimeString* aPortConfig,
+        OsclAny* aContext, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->RequestPort(aSessionId, aPortTag, aPortConfig, aContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
 
+PVMFStatus PVPlayerDatapath::IssueDatapathPrepare(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->Prepare(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
 
+PVMFStatus PVPlayerDatapath::IssueDatapathStart(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->Start(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerDatapath::IssueDatapathPause(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->Pause(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerDatapath::IssueDatapathStop(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->Stop(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerDatapath::IssueDatapathReleasePort(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFPortInterface* aPort, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->ReleasePort(aSessionId, *aPort));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerDatapath::IssueDatapathReset(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->Reset(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerDatapath::IssueDatapathCancel(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode;
+    OSCL_TRY(leavecode, aCmdId = aNode->CancelAllCommands(aSessionId));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
 
 
diff --git a/engines/player/src/pv_player_datapath.h b/engines/player/src/pv_player_datapath.h
index 9006383..f71d625 100644
--- a/engines/player/src/pv_player_datapath.h
+++ b/engines/player/src/pv_player_datapath.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,30 @@
         virtual ~PVPlayerDatapathObserver() {}
 };
 
+enum PVPDPState
+{
+    PVPDP_IDLE,
+    PVPDP_ERROR,
+    PREPARE_INIT,
+    PREPARE_REQPORT,
+    PREPARE_PREPARE,
+    PREPARE_CONNECT,
+    PREPARED,
+    START_START,
+    STARTED,
+    PAUSE_PAUSE,
+    PAUSED,
+    STOP_STOP,
+    STOPPED,
+    TEARDOWN_RELEASEPORT1,
+    TEARDOWN_RELEASEPORT2,
+    TEARDOWNED,
+    RESET_RESET,
+    RESETTED,
+    PVPDP_CANCEL,
+    PVPDP_CANCELLED
+};
+
 class PVLogger;
 
 class PVPlayerDatapath : public OsclTimerObject,
@@ -103,19 +127,19 @@
         void SetSourceDecTrackInfo(PVMFTrackInfo& aTrackInfo)
         {
             iSourceTrackInfo = &aTrackInfo;
-            iSourceDecFormatType = GetFormatIndex(aTrackInfo.getTrackMimeType().get_str());
+            iSourceDecFormatType = aTrackInfo.getTrackMimeType().get_str();
         }
 
         void SetDecSinkFormatType(PVMFFormatType& aFormatType)
         {
             iDecSinkFormatType = aFormatType;
-            GetFormatStringFromType(aFormatType, iDecSinkFormatString);
+            iDecSinkFormatString = aFormatType.getMIMEStrPtr();
         }
 
         void SetSourceSinkTrackInfo(PVMFTrackInfo& aTrackInfo)
         {
             iSourceTrackInfo = &aTrackInfo;
-            iSourceSinkFormatType = GetFormatIndex(aTrackInfo.getTrackMimeType().get_str());
+            iSourceSinkFormatType = aTrackInfo.getTrackMimeType().get_str();
         }
 
         PVMFStatus Prepare(OsclAny* aContext);
@@ -134,6 +158,8 @@
 
         void DisconnectNodeSession(void);
 
+        PVPDPState iState;
+
     private:
         // From OsclTimerObject
         void Run();
@@ -147,7 +173,16 @@
         // From PVMFNodeErrorEventObserver
         void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
 
-        void GetFormatStringFromType(PVMFFormatType &aType, OSCL_HeapString<OsclMemAllocator>& aString);
+        PVMFStatus IssueDatapathInit(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathRequestPort(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, int32 aPortTag,
+                                            PvmfMimeString* aPortConfig, OsclAny* aContext, PVMFCommandId &aCmdId);
+        PVMFStatus IssueDatapathPrepare(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathStart(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathPause(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathStop(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathReleasePort(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFPortInterface* aPort, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathReset(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
+        PVMFStatus IssueDatapathCancel(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
 
         PVMFNodeInterface* iSourceNode;
         PVMFSessionId iSourceSessionId;
@@ -172,32 +207,6 @@
         PVMFFormatType iSourceSinkFormatType;
         PVMFTrackInfo* iSourceTrackInfo;
 
-        enum PVPDPState
-        {
-            PVPDP_IDLE,
-            PVPDP_ERROR,
-            PREPARE_INIT,
-            PREPARE_REQPORT,
-            PREPARE_PREPARE,
-            PREPARE_CONNECT,
-            PREPARED,
-            START_START,
-            STARTED,
-            PAUSE_PAUSE,
-            PAUSED,
-            STOP_STOP,
-            STOPPED,
-            TEARDOWN_RELEASEPORT1,
-            TEARDOWN_RELEASEPORT2,
-            TEARDOWNED,
-            RESET_RESET,
-            RESETTED,
-            PVPDP_CANCEL,
-            PVPDP_CANCELLED
-        };
-
-        PVPDPState iState;
-
         // Enum for the datapath configuration
         enum PVPDPConfig
         {
diff --git a/engines/player/src/pv_player_engine.cpp b/engines/player/src/pv_player_engine.cpp
index 43ac44b..35982b0 100644
--- a/engines/player/src/pv_player_engine.cpp
+++ b/engines/player/src/pv_player_engine.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,12 +17,14 @@
  */
 #include "pv_player_engine.h"
 
+#include "pv_player_config.h"
+
+#ifndef USE_CML2_CONFIG
 #include "pv_player_engine_tunables.h"
+#endif
 
 #include "pv_player_sdkinfo.h"
 
-#include "pv_player_config.h"
-
 #include "pvmf_node_interface.h"
 
 #include "pvmf_ffparsernode_extension.h"
@@ -69,11 +71,6 @@
 
 #include "pvmf_source_context_data.h"
 
-
-#ifdef HAS_OSCL_LIB_SUPPORT
-
-#include "pv_player_engine.h"
-
 #include "pv_player_node_registry.h"
 #include "pv_player_registry_interface.h"
 
@@ -84,29 +81,14 @@
 
 #include "pvmf_recognizer_plugin.h"
 
-#include "oscl_shared_library.h"
-#include "oscl_library_list.h"
-
-#include "oscl_shared_lib_interface.h"
-
-#include "pvmf_node_shared_lib_interface.h"
-
-#define PVPLAYERENGINE_DEFAULT_CONFIG_PATH_SIZE 32
-
-#ifndef PVPLAYERENGINE_NODE_REGISTRY_CONFIG_PATH
-#define PVPLAYERENGINE_NODE_REGISTRY_CONFIG_PATH NULL
-#endif
-
-#endif
-
 //
 
 
 #define PVPLAYERENGINE_NUM_COMMANDS 10
 
 #define PVPLAYERENGINE_TIMERID_ENDTIMECHECK 1
-#define PVPLAYERENGINE_TIMERID_PLAY_STATUS 2
 
+#define PVP_MIN_PLAYSTATUS_PERCENT_OVERFLOW_THRESHOLD 1000
 
 
 
@@ -131,6 +113,9 @@
 {
     Cancel();
 
+    // Clear the Track selection List
+    iTrackSelectionList.clear();
+
     // Remove Stored KVP Values
     DeleteKVPValues();
 
@@ -161,7 +146,14 @@
         OSCL_DELETE(iWatchDogTimer);
     }
 
-    OSCL_TEMPLATED_DELETE(iPollingCheckTimer, OsclTimer<OsclMemAllocator>, OsclTimer);
+    OSCL_DELETE(iPollingCheckTimer);
+
+    //Destroy media clock notifications interface
+    if (iClockNotificationsInf != NULL)
+    {
+        iPlaybackClock.DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+        iClockNotificationsInf = NULL;
+    }
 
     // Return all engine contexts to pool
     while (!iCurrentContextList.empty())
@@ -169,12 +161,12 @@
         FreeEngineContext(iCurrentContextList[0]);
     }
 
+    PVPlayerRegistryPopulator::Depopulate(iPlayerNodeRegistry, iPlayerRecognizerRegistry);
+
     iNodeUuids.clear();
 
-#ifdef HAS_OSCL_LIB_SUPPORT
-    DepopulateAllRegistries();
-#endif
-
+    iCommandIdMut.Close();
+    iOOTSyncCommandSem.Close();
 }
 
 
@@ -326,8 +318,15 @@
     PVPlayerEngineCommandParamUnion param;
     param.pOsclAny_value = (OsclAny*) & aState;
     paramvec.push_back(param);
-    PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE, -1, NULL, &paramvec);
-    return DoGetPVPlayerState(cmd, true);
+    if (iThreadSafeQueue.IsInThread())
+    {
+        PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE, -1, NULL, &paramvec);
+        return DoGetPVPlayerState(cmd, true);
+    }
+    else
+    {
+        return DoOOTSyncCommand(PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE_OOTSYNC, &paramvec);
+    }
 }
 
 
@@ -373,11 +372,11 @@
 }
 
 PVCommandId PVPlayerEngine::GetMetadataValues(PVPMetadataList& aKeyList, int32 aStartingValueIndex, int32 aMaxValueEntries, int32& aNumAvailableValueEntries,
-        Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData)
+        Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData, bool aMetadataValuesCopiedInCallBack)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::GetMetadataValues()"));
     Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
-    paramvec.reserve(5);
+    paramvec.reserve(6);
     paramvec.clear();
     PVPlayerEngineCommandParamUnion param;
 
@@ -391,10 +390,25 @@
     paramvec.push_back(param);
     param.pOsclAny_value = (OsclAny*) & aValueList;
     paramvec.push_back(param);
+    param.bool_value = aMetadataValuesCopiedInCallBack;
+    paramvec.push_back(param);
 
     return AddCommandToQueue(PVP_ENGINE_COMMAND_GET_METADATA_VALUE, (OsclAny*)aContextData, &paramvec);
 }
 
+PVCommandId PVPlayerEngine::ReleaseMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::ReleaseMetadataValues()"));
+    Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
+    paramvec.reserve(1);
+    paramvec.clear();
+    PVPlayerEngineCommandParamUnion param;
+
+    param.pOsclAny_value = (OsclAny*) & aValueList;
+    paramvec.push_back(param);
+
+    return AddCommandToQueue(PVP_ENGINE_COMMAND_RELEASE_METADATA_VALUE, (OsclAny*)aContextData, &paramvec);
+}
 
 PVCommandId PVPlayerEngine::AddDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData)
 {
@@ -414,6 +428,35 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::SetPlaybackRange()"));
     PVPPlaybackPosition curpos;
     curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+
+    // Additional checks to ensure a valid mode is
+    // used for the begin position.
+    // Assumes: aBegin.iPosUnit is always valid (when applicable).
+
+    // Check 1 || Check 2
+    // Check 1: Is the begin position indeterminate?
+    // Check 2: Is the position unit something other than playlist?
+    // If so, set mode to NOW.
+    if ((aBeginPos.iIndeterminate) || (aBeginPos.iPosUnit != PVPPBPOSUNIT_PLAYLIST))
+    {
+        aBeginPos.iMode = PVPPBPOS_MODE_NOW;
+    }
+    // Check 3: Is the position unit playlist and the mode something other than the three valid
+    // modes? If so, set mode to NOW.
+    else if (aBeginPos.iPosUnit == PVPPBPOSUNIT_PLAYLIST)
+    {
+        switch (aBeginPos.iMode)
+        {
+            case PVPPBPOS_MODE_NOW:
+            case PVPPBPOS_MODE_END_OF_CURRENT_PLAY_ELEMENT:
+            case PVPPBPOS_MODE_END_OF_CURRENT_PLAY_SESSION:
+                break;
+            case PVPPBPOS_MODE_UNKNOWN:
+            default:
+                aBeginPos.iMode = PVPPBPOS_MODE_NOW;
+                break;
+        }
+    }
     iPlaybackPositionMode = aBeginPos.iMode;
     GetPlaybackClockPosition(curpos);
     Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
@@ -426,7 +469,14 @@
     paramvec.push_back(param);
     param.bool_value = aQueueRange;
     paramvec.push_back(param);
-    return AddCommandToQueue(PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE, (OsclAny*)aContextData, &paramvec);
+    if (!iOverflowFlag)
+    {
+        return AddCommandToQueue(PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE, (OsclAny*)aContextData, &paramvec);
+    }
+    else
+    {
+        return AddCommandToQueue(PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE, (OsclAny*)aContextData, &paramvec, NULL, false);
+    }
 }
 
 
@@ -468,12 +518,19 @@
     PVPlayerEngineCommandParamUnion param;
     param.pPlaybackpos_value = &aPos;
     paramvec.push_back(param);
-    PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_GET_CURRENT_POSITION, -1, NULL, &paramvec);
-    return DoGetCurrentPosition(cmd, true);
+    if (iThreadSafeQueue.IsInThread())
+    {
+        PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_GET_CURRENT_POSITION, -1, NULL, &paramvec);
+        return DoGetCurrentPosition(cmd, true);
+    }
+    else
+    {
+        return DoOOTSyncCommand(PVP_ENGINE_COMMAND_GET_CURRENT_POSITION_OOTSYNC, &paramvec);
+    }
 }
 
 
-PVCommandId PVPlayerEngine::SetPlaybackRate(int32 aRate, OsclTimebase* aTimebase, const OsclAny* aContextData)
+PVCommandId PVPlayerEngine::SetPlaybackRate(int32 aRate, PVMFTimebase* aTimebase, const OsclAny* aContextData)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::SetPlaybackRate()"));
     Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
@@ -488,7 +545,7 @@
 }
 
 
-PVCommandId PVPlayerEngine::GetPlaybackRate(int32& aRate, OsclTimebase*& aTimebase, const OsclAny* aContextData)
+PVCommandId PVPlayerEngine::GetPlaybackRate(int32& aRate, PVMFTimebase*& aTimebase, const OsclAny* aContextData)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::GetPlaybackRate()"));
     Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
@@ -535,13 +592,6 @@
 PVCommandId PVPlayerEngine::Pause(const OsclAny* aContextData)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Pause()"));
-    if (!iSourceDurationAvailable)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Pause() - Pause not supported"));
-        OSCL_LEAVE(PVMFErrNotSupported);
-        return -1;
-    }
-
     return AddCommandToQueue(PVP_ENGINE_COMMAND_PAUSE, (OsclAny*)aContextData);
 }
 
@@ -596,16 +646,73 @@
 void PVPlayerEngine::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::setObserver()"));
-    iCfgCapCmdObserver = aObserver;
+
+    if (iThreadSafeQueue.IsInThread())
+    {
+        iCfgCapCmdObserver = aObserver;
+    }
+    else
+    {
+        Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
+        paramvec.reserve(2);
+        paramvec.clear();
+        PVPlayerEngineCommandParamUnion param;
+        param.pOsclAny_value = aObserver;
+        paramvec.push_back(param);
+        DoOOTSyncCommand(PVP_ENGINE_COMMAND_CAPCONFIG_SET_OBSERVER_OOTSYNC, &paramvec);
+    }
 }
 
+PVMFStatus PVPlayerEngine::DoSetObserverSync(PVPlayerEngineCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetObserverSync() In"));
+
+    iCfgCapCmdObserver = (PvmiConfigAndCapabilityCmdObserver*)(aCmd.GetParam(0).pOsclAny_value);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetObserverSync() Out"));
+    return PVMFSuccess;
+}
 
 PVMFStatus PVPlayerEngine::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::getParametersSync()"));
     OSCL_UNUSED_ARG(aSession);
 
-    return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
+    if (iThreadSafeQueue.IsInThread())
+    {
+        return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
+    }
+    else
+    {
+        Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
+        paramvec.reserve(5);
+        paramvec.clear();
+        PVPlayerEngineCommandParamUnion param;
+        param.pOsclAny_value = &aIdentifier;
+        paramvec.push_back(param);
+        param.pOsclAny_value = &aParameters;
+        paramvec.push_back(param);
+        param.pOsclAny_value = &aNumParamElements;
+        paramvec.push_back(param);
+        param.pOsclAny_value = &aContext;
+        paramvec.push_back(param);
+        return DoOOTSyncCommand(PVP_ENGINE_COMMAND_CAPCONFIG_GET_PARAMETERS_OOTSYNC, &paramvec);
+    }
+}
+
+
+PVMFStatus PVPlayerEngine::DoGetParametersSync(PVPlayerEngineCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetParametersSync() In"));
+
+    PVMFStatus status = DoCapConfigGetParametersSync(
+                            *((PvmiKeyType*)aCmd.GetParam(0).pOsclAny_value)
+                            , *((PvmiKvp**)aCmd.GetParam(1).pOsclAny_value)
+                            , *((int*)aCmd.GetParam(2).pOsclAny_value)
+                            , *((PvmiCapabilityContext*)aCmd.GetParam(3).pOsclAny_value));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetParametersSync() Out"));
+    return status;
 }
 
 
@@ -614,9 +721,35 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::releaseParameters()"));
     OSCL_UNUSED_ARG(aSession);
 
-    return DoCapConfigReleaseParameters(aParameters, aNumElements);
+    if (iThreadSafeQueue.IsInThread())
+    {
+        return DoCapConfigReleaseParameters(aParameters, aNumElements);
+    }
+    else
+    {
+        Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
+        paramvec.reserve(3);
+        paramvec.clear();
+        PVPlayerEngineCommandParamUnion param;
+        param.pOsclAny_value = aParameters;
+        paramvec.push_back(param);
+        param.int32_value = aNumElements;
+        paramvec.push_back(param);
+        return DoOOTSyncCommand(PVP_ENGINE_COMMAND_CAPCONFIG_RELEASE_PARAMETERS_OOTSYNC, &paramvec);
+    }
 }
 
+PVMFStatus PVPlayerEngine::DoReleaseParametersSync(PVPlayerEngineCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoReleaseParametersSync() In"));
+
+    PVMFStatus status = DoCapConfigReleaseParameters(
+                            (PvmiKvp*)aCmd.GetParam(0).pOsclAny_value
+                            , aCmd.GetParam(1).int32_value);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoReleaseParametersSync() Out"));
+    return status;
+}
 
 void PVPlayerEngine::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
 {
@@ -636,7 +769,7 @@
     OSCL_UNUSED_ARG(aNumParamElements);
     // This method is not supported so leave
     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::setContextParameters() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
+    OSCL_LEAVE(OsclErrNotSupported);
 }
 
 
@@ -665,10 +798,17 @@
     paramvec.push_back(param);
     param.pOsclAny_value = (OsclAny*) & aRetKVP;
     paramvec.push_back(param);
-    PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS, -1, NULL, &paramvec);
+    if (iThreadSafeQueue.IsInThread())
+    {
+        PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS, -1, NULL, &paramvec);
 
-    // Complete the request synchronously
-    DoCapConfigSetParameters(cmd, true);
+        // Complete the request synchronously
+        DoCapConfigSetParameters(cmd, true);
+    }
+    else
+    {
+        DoOOTSyncCommand(PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS_OOTSYNC, &paramvec);
+    }
 }
 
 
@@ -708,9 +848,35 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::verifyParametersSync()"));
     OSCL_UNUSED_ARG(aSession);
 
-    return DoCapConfigVerifyParameters(aParameters, aNumElements);
+    if (iThreadSafeQueue.IsInThread())
+    {
+        return DoCapConfigVerifyParameters(aParameters, aNumElements);
+    }
+    else
+    {
+        Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
+        paramvec.reserve(3);
+        paramvec.clear();
+        PVPlayerEngineCommandParamUnion param;
+        param.pOsclAny_value = aParameters;
+        paramvec.push_back(param);
+        param.int32_value = aNumElements;
+        paramvec.push_back(param);
+        return DoOOTSyncCommand(PVP_ENGINE_COMMAND_CAPCONFIG_VERIFY_PARAMETERS_OOTSYNC, &paramvec);
+    }
 }
 
+PVMFStatus PVPlayerEngine::DoVerifyParametersSync(PVPlayerEngineCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoVerifyParametersSync() In"));
+
+    PVMFStatus status = DoCapConfigVerifyParameters(
+                            (PvmiKvp*)aCmd.GetParam(0).pOsclAny_value
+                            , aCmd.GetParam(1).int32_value);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoVerifyParametersSync() Out"));
+    return status;
+}
 
 PVMFCommandId PVPlayerEngine::AcquireLicense(OsclAny* aLicenseData, uint32 aDataSize, oscl_wchar* aContentName, int32 aTimeoutMsec, const OsclAny* aContextData)
 {
@@ -763,13 +929,43 @@
 
 PVMFStatus PVPlayerEngine::GetLicenseStatus(PVMFCPMLicenseStatus& aStatus)
 {
-    if (iSourceNodeCPMLicenseIF)
-        return iSourceNodeCPMLicenseIF->GetLicenseStatus(aStatus);
-    if (iCPMPluginLicenseIF)
-        return iCPMPluginLicenseIF->GetLicenseStatus(aStatus);
-    return PVMFFailure;
+    if (iThreadSafeQueue.IsInThread())
+    {
+        if (iSourceNodeCPMLicenseIF)
+            return iSourceNodeCPMLicenseIF->GetLicenseStatus(aStatus);
+        return PVMFFailure;
+    }
+    else
+    {
+        Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> paramvec;
+        paramvec.reserve(2);
+        paramvec.clear();
+        PVPlayerEngineCommandParamUnion param;
+        param.pOsclAny_value = &aStatus;
+        paramvec.push_back(param);
+        return DoOOTSyncCommand(PVP_ENGINE_COMMAND_GET_LICENSE_STATUS_OOTSYNC, &paramvec);
+    }
 }
 
+PVMFStatus PVPlayerEngine::DoGetLicenseStatusSync(PVPlayerEngineCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetLicenseStatusSync() In"));
+
+    PVMFStatus status;
+    PVMFCPMLicenseStatus* licstatus = (PVMFCPMLicenseStatus*)(aCmd.GetParam(0).pOsclAny_value);
+    if (!licstatus)
+    {
+        return PVMFFailure;
+    }
+
+    if (iSourceNodeCPMLicenseIF)
+        status = iSourceNodeCPMLicenseIF->GetLicenseStatus(*licstatus);
+    else
+        status = PVMFFailure;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetLicenseStatusSync() Out"));
+    return status;
+}
 
 void PVPlayerEngine::addRef()
 {
@@ -824,15 +1020,15 @@
         iInfoEventObserver(NULL),
         iCfgCapCmdObserver(NULL),
         iPollingCheckTimer(NULL),
-        iCommandCompleteInEngineAOPending(false),
-        iCommandCompleteInEngineAOCmdStatus(PVMFSuccess),
-        iCommandCompleteInEngineAOErrMsg(NULL),
+        iCommandCompleteStatusInErrorHandling(PVMFSuccess),
+        iCommandCompleteErrMsgInErrorHandling(NULL),
         iCapConfigContext(0),
         iNumPendingNodeCmd(0),
+        iNumPendingSkipCompleteEvent(0),
         iNumPendingDatapathCmd(0),
+        iNumPVMFInfoStartOfDataPending(0),
         iDataSource(NULL),
-        iDataSourcePS(NULL),
-        iSourceFormatType(PVMF_FORMAT_UNKNOWN),
+        iSourceFormatType(PVMF_MIME_FORMAT_UNKNOWN),
         iSourceNode(NULL),
         iSourceNodeSessionId(0),
         iSourceNodeInitIF(NULL),
@@ -845,44 +1041,51 @@
         iSourceNodeRegInitIF(NULL),
         iSourceNodeCPMLicenseIF(NULL),
         iSourceNodePacketSourceIF(NULL),
-        iCPMPlugin(NULL),
-        iCPMPluginFactory(NULL),
-        iCPMPluginSessionId(0),
-        iCPMPluginLicenseIF(NULL),
-        iCPMPluginCapConfigIf(NULL),
-        iCPMPluginCommand(-1),
+        iSourceNodePVInterfaceInit(NULL),
+        iSourceNodePVInterfaceTrackSel(NULL),
+        iSourceNodePVInterfacePBCtrl(NULL),
+        iSourceNodePVInterfaceDirCtrl(NULL),
+        iSourceNodePVInterfaceTrackLevelInfo(NULL),
+        iSourceNodePVInterfaceMetadataExt(NULL),
+        iSourceNodePVInterfaceCapConfig(NULL),
+        iSourceNodePVInterfaceRegInit(NULL),
+        iSourceNodePVInterfaceCPMLicense(NULL),
+        iSourceNodePVInterfacePacketSource(NULL),
         iCPMGetLicenseCmdId(0),
+        iMetadataValuesCopiedInCallBack(true),
+        iReleaseMetadataValuesPending(false),
         iCurrentContextListMemPool(12),
-        iPendingCancelDueToCancelRequest(0),
-        iPendingStopDueToCancelRequest(0),
-        iPendingResetDueToCancelRequest(0),
-        iPendingCancelDueToErrorRequest(0),
-        iErrorOccurredDuringErrorHandling(false),
+        iNumberCancelCmdPending(0),
         iLogger(NULL),
-        iPerfLogger(NULL),
         iReposLogger(NULL),
+        iPerfLogger(NULL),
+        iClockNotificationsInf(NULL),
+        iPlayStatusCallbackTimerID(0),
+        iPlayStatusCallbackTimerMarginWindow(0),
+        iCurrCallbackTimerLatency(0),
         iPlaybackClockRate(100000),
         iOutsideTimebase(NULL),
         iPlaybackClockRate_New(100000),
         iOutsideTimebase_New(NULL),
-        iActualPlaybackPosition(0),
-        iSeekPointBeforeTargetNPT(0),
-        iSeekPointAfterTargetNPT(0),
-        iActualMediaDataTS(0),
-        iAdjustedMediaDataTS(0),
-        iWatchDogTimerInterval(0),
-        iStartNPT(0),
-        iStartMediaDataTS(0),
-        iForwardReposFlag(false),
-        iBackwardReposFlag(false),
         iPlaybackDirection(1),
         iPlaybackDirection_New(1),
         iChangePlaybackDirectionWhenResuming(false),
         iEndTimeCheckEnabled(false),
         iQueuedRangePresent(false),
         iChangePlaybackPositionWhenResuming(false),
-        iDataReadySent(false),
+        iActualNPT(0),
+        iTargetNPT(0),
+        iActualMediaDataTS(0),
+        iSkipMediaDataTS(0),
+        iStartNPT(0),
+        iStartMediaDataTS(0),
+        iWatchDogTimerInterval(0),
+        iSeekPointBeforeTargetNPT(0),
+        iSeekPointAfterTargetNPT(0),
+        iForwardReposFlag(false),
+        iBackwardReposFlag(false),
         iPlayStatusTimerEnabled(false),
+        iDataReadySent(false),
         iPlaybackPausedDueToEndOfClip(false),
         iSourceDurationAvailable(false),
         iSourceDurationInMS(0),
@@ -892,7 +1095,7 @@
         iEndTimeCheckInterval(PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_DEF),
         iSeekToSyncPoint(PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINT_DEF),
         iSkipToRequestedPosition(PVPLAYERENGINE_CONFIG_SKIPTOREQUESTEDPOS_DEF),
-        iRenderSkipped(PVPLAYERENGINE_CONFIG_RENDERSKIPPED_DEF),
+        iBackwardRepos(false),
         iSyncPointSeekWindow(PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_DEF),
         iNodeCmdTimeout(PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_DEF),
         iNodeDataQueuingTimeout(PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_DEF),
@@ -901,15 +1104,12 @@
         iProdInfoHWPlatform(_STRLIT_CHAR(PVPLAYERENGINE_PRODINFO_HWPLATFORM_STRING)),
         iProdInfoSWPlatform(_STRLIT_CHAR(PVPLAYERENGINE_PRODINFO_SWPLATFORM_STRING)),
         iProdInfoDevice(_STRLIT_CHAR(PVPLAYERENGINE_PRODINFO_DEVICE_STRING)),
-        iRollOverState(RollOverStateIdle),
-        iBackwardRepos(false),
-        iAlternateSrcFormatIndex(0),
         iStreamID(0),
-        iNumPendingSkipCompleteEvent(0),
-        iNumPVMFInfoStartOfDataPending(0),
-        iResumeAfterReposition(false),
+        iAlternateSrcFormatIndex(0),
+        iRollOverState(RollOverStateIdle),
         iTrackSelectionHelper(NULL),
-        iPlaybackPositionMode(PVPPBPOS_MODE_UNKNOWN)
+        iPlaybackPositionMode(PVPPBPOS_MODE_UNKNOWN),
+        iOverflowFlag(false)
 {
     iCurrentBeginPosition.iIndeterminate = true;
     iCurrentEndPosition.iIndeterminate = true;
@@ -933,6 +1133,10 @@
                                PVErrorEventObserver *aErrorEventObserver,
                                PVInformationalEventObserver *aInfoEventObserver)
 {
+    iCommandIdMut.Create();
+    iOOTSyncCommandSem.Create();
+    iThreadSafeQueue.Configure(this);
+
     iCmdStatusObserver = aCmdStatusObserver;
     iInfoEventObserver = aInfoEventObserver;
     iErrorEventObserver = aErrorEventObserver;
@@ -952,8 +1156,11 @@
     iMetadataIFList.reserve(6);
     iMetadataIFList.clear();
 
-    iMetadataReleaseList.reserve(6);
-    iMetadataReleaseList.clear();
+    iMetadataKeyReleaseList.reserve(6);
+    iMetadataKeyReleaseList.clear();
+
+    iMetadataValueReleaseList.reserve(6);
+    iMetadataValueReleaseList.clear();
 
     AddToScheduler();
 
@@ -965,7 +1172,10 @@
     // Initialize the playback clock to use tickcount timebase
     iPlaybackClock.SetClockTimebase(iPlaybackTimebase);
     uint32 starttime = 0;
-    iPlaybackClock.SetStartTime32(starttime, OSCLCLOCK_MSEC);
+    bool overflow = 0;
+    iPlaybackClock.SetStartTime32(starttime, PVMF_MEDIA_CLOCK_MSEC, overflow);
+    iPlaybackClock.ConstructMediaClockNotificationsInterface(iClockNotificationsInf, *this,
+            iCurrCallbackTimerLatency);
 
     // Initialize the OSCL timer for polling checks
     iPollingCheckTimer = OSCL_NEW(OsclTimer<OsclMemAllocator>, ("playerengine_pollingcheck"));
@@ -974,14 +1184,7 @@
 
     iWatchDogTimer = OSCL_NEW(PVPlayerWatchdogTimer, (this));
 
-#ifdef HAS_OSCL_LIB_SUPPORT
-    if (NULL != PVPLAYERENGINE_NODE_REGISTRY_CONFIG_PATH)
-    {
-        OSCL_HeapString<OsclMemAllocator> configFileName =
-            PVPLAYERENGINE_NODE_REGISTRY_CONFIG_PATH;
-        PopulateAllRegistries(configFileName);
-    }
-#endif
+    PVPlayerRegistryPopulator::Populate(iPlayerNodeRegistry, iPlayerRecognizerRegistry);
 
     return;
 }
@@ -992,106 +1195,105 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() In"));
     int32 leavecode = 0;
 
-    if (iRollOverState == RollOverStateStart)
+    /* Engine AO will execute commands in the following sequence
+     * 1) If Engine state is Resetting, which will happen when Engine does ErrorHandling,
+     * processing Reset or CancelAllCommands
+     * issued by the app, engine will not try to execute any other command during this state.
+     * 2) If Engine is not in Resetting state then it will process commands in the following order, which ever is true:
+     *    (i) If Engine needs to do Error handling because of some error from Source Node or Datapath.
+     *    Either start error handling or complete it.
+     *    (ii) If Engine has Reset or CancelAllCommands in CurrentCommandQueue,
+     *    engine will do CommandComplete for the CurrentCommand.
+     *	  (iii) If Engine has Prepare in CurrentCommandQueue, engine will call DoPrepare again
+     *    as a part of track selection logic
+     *    (iv) If Engine has CancelAllCommands or CancelAcquireLicense in Pending CommandQueue,
+     *    engine will start Cancel commands.
+     *    (v) Go for Rollover if in Init State and Roll-over is ongoing.
+     *    (vi) Process which ever command is pushed in Pending queue.
+     * Engine will process any one of the command as listed above in the same order.
+     * Every time engine AO is scheduled, engine will go through
+     * these steps.
+     */
+
+    if (iState == PVP_ENGINE_STATE_RESETTING)
     {
-        if (iPendingCmds.top().GetCmdType() == PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() Source Roll Over In Progress But CancelAllCommands is requied by App"));
-            iRollOverState = RollOverStateIdle;
-        }
-        else if (iPendingCmds.top().GetCmdType() == PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() Source Roll Over In Progress But ResetDueToError is required by Error handling"));
-            iRollOverState = RollOverStateIdle;
-        }
-        else
-        {
-            if (iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_INIT)
-            {
-                iCommandCompleteInEngineAOPending = false;
-
-                //implies that we are doing a source rollover
-                PVMFStatus status =
-                    DoSourceNodeRollOver(iCurrentCmd[0].iCmdId,
-                                         iCurrentCmd[0].iContextData);
-
-                if (status != PVMFPending)
-                {
-                    if (CheckForSourceRollOver())
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RunL() DoSourceNodeRollOver Failed, alternate source node for rollover is available"));
-                        RunIfNotReady();
-                        return;
-                    }
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() DoSourceNodeRollOver Failed"));
-                    iRollOverState = RollOverStateIdle;
-                    EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFFailure);
-                }
-                else
-                {
-                    iRollOverState = RollOverStateInProgress;
-                }
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Source Roll Over In Progress But Incorrect Engine Cmd - Asserting"));
-                OSCL_ASSERT(false);
-            }
-            return;
-        }
-    }
-
-    if (iRollOverState == RollOverStateInProgress)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RunL() Source Roll Over In Progress "));
+        //this means error handling, reset or cancelall is still in progress
+        //pls note that the state will be set to idle
+        //in either HandleSourceNodeReset or HandleDataPathReset
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::Run() Return engine in resetting state, No processing until engine is in Idle state"));
         return;
     }
 
-    // Check if a command that needs to complete in engine's AO is pending
-    if (iCommandCompleteInEngineAOPending)
+    /* Check if ErrorHandling request was made */
+    if (!iPendingCmds.empty())
     {
-        iCommandCompleteInEngineAOPending = false;
-
-        OSCL_ASSERT(iCurrentCmd.empty() == false);
-        switch (iCurrentCmd[0].GetCmdType())
+        switch (iPendingCmds.top().GetCmdType())
         {
-            case PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS:
-                DoCleanupDueToCancel();
-                break;
-
-            case PVP_ENGINE_COMMAND_ADD_DATA_SOURCE:
-                DoAddDataSourceFailureComplete();
-                break;
-
-            case PVP_ENGINE_COMMAND_INIT:
-                DoInitFailureComplete();
-                break;
-            case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR:
-            case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR:
-                DoCPMPluginAcquireLicenseComplete();
-                break;
-
-            case PVP_ENGINE_COMMAND_RESET:
-            case PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR:
-                if (iState != PVP_ENGINE_STATE_IDLE)
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL:
+            {
+                // go in error handling right away
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() Processing Error Handling request"));
+                PVMFStatus retVal = DoErrorHandling();
+                if (retVal == PVMFSuccess)
                 {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Wrong state for completing Reset encountered. Asserting"));
-                    OSCL_ASSERT(false); // we should not be here
-                    EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFErrInvalidState);
-                    return;
+                    iPendingCmds.pop();
+                    RunIfNotReady(); // schedule the engine AO to process other commands in queue if any.
                 }
-                if (iDataSource)
-                    RemoveDataSourceSync(*iDataSource);
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFSuccess);
-                break;
+                return;
+            }
+
             default:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Command type that does not need to complete in engine AO encountered. Asserting"));
-                OSCL_ASSERT(false);
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFFailure);
                 break;
         }
-        return;
+    }
+
+    // if current command being processed is reset or cancelAll and
+    // Player engine state is idle then remove the data source
+    // and do reset/cancelAll command complete
+    // OR
+    // if current command being processed is prepare, need to call
+    // DoPrepare again because of track selection
+    if (!iCurrentCmd.empty())
+    {
+        if ((iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_RESET) ||
+                (iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS))
+        {
+            if (iState != PVP_ENGINE_STATE_IDLE)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Engine not in Idle State, asserting"));
+                OSCL_ASSERT(false);
+            }
+            // First destroy all datapaths.
+            DoRemoveAllSinks();
+            // now remove the source node.
+            if (iDataSource)
+            {
+                RemoveDataSourceSync(*iDataSource);
+            }
+
+            EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFSuccess);
+        }
+        else if (iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_PREPARE)
+        {
+            PVMFStatus cmdstatus = DoPrepare(iCurrentCmd[0]);
+
+            if (cmdstatus != PVMFSuccess && cmdstatus != PVMFPending)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Command failed CmdId %d Status %d",
+                                iCurrentCmd[0].GetCmdId(), cmdstatus));
+                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), cmdstatus);
+            }
+        }
     }
 
     /* Check if CancelAll()/CancelAcquireLicense request was made */
@@ -1117,36 +1319,64 @@
         }
     }
 
+    if (iRollOverState == RollOverStateStart)
+    {
+        if (iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_INIT)
+        {
+            //implies that we are doing a source rollover
+            PVMFStatus status =
+                DoSourceNodeRollOver(iCurrentCmd[0].iCmdId,
+                                     iCurrentCmd[0].iContextData);
+
+            if (status != PVMFPending)
+            {
+                if (CheckForSourceRollOver())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() DoSourceNodeRollOver Failed, alternate source node for rollover is available"));
+                    RunIfNotReady();
+                    return;
+                }
+                // roll over failed
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() DoSourceNodeRollOver Failed, go in error handling"));
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
+                {
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Already EH pending, should never happen"));
+                    return;
+                }
+                // go in error handling
+                iCommandCompleteStatusInErrorHandling = status;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
+                iRollOverState = RollOverStateIdle;
+                return;
+            }
+            else
+            {
+                iRollOverState = RollOverStateInProgress;
+            }
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Source Roll Over In Progress But Incorrect Engine Cmd"));
+            EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFErrInvalidState);
+        }
+        return;
+    }
+
+    if (iRollOverState == RollOverStateInProgress)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RunL() Source Roll Over In Progress "));
+        return;
+    }
+
     // Handle other requests normally
     if (!iPendingCmds.empty() && iCurrentCmd.empty())
     {
         // Retrieve the first pending command from queue
         PVPlayerEngineCommand cmd(iPendingCmds.top());
-
-        // check if Stop cmd injection is necessary during Reset
-        if (iPendingCmds.top().GetCmdType() == PVP_ENGINE_COMMAND_RESET)
-        {
-            switch (GetPVPlayerState())
-            {
-                case PVP_STATE_PREPARED:
-                case PVP_STATE_STARTED:
-                case PVP_STATE_PAUSED:
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() Reset request, injecting Stop first"));
-                    RunIfNotReady(); //reschedule Reset
-                    // execute Stop before doing Reset
-                    cmd = PVPlayerEngineCommand(PVP_ENGINE_COMMAND_STOP, iCommandId++, NULL, NULL, false);
-                    if (iCommandId == 0x7FFFFFFF)
-                        iCommandId = 0;
-                    break;
-                default: //process normally in all other states
-                    iPendingCmds.pop();
-            }
-
-        }
-        else
-        {
-            iPendingCmds.pop();
-        }
+        iPendingCmds.pop();
 
         // Put in on the current command queue
         leavecode = 0;
@@ -1154,11 +1384,11 @@
         OSCL_FIRST_CATCH_ANY(leavecode,
                              PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Command could not be pushed onto iCurrentCmd vector"));
                              EngineCommandCompleted(cmd.GetCmdId(), cmd.GetContext(), PVMFErrNoMemory);
-                             OSCL_ASSERT(false);
                              return;);
 
         // Process the command according to the cmd type
         PVMFStatus cmdstatus = PVMFSuccess;
+        bool ootsync = false;
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() Processing command with type=%d", cmd.GetCmdType()));
         switch (cmd.GetCmdType())
         {
@@ -1199,6 +1429,11 @@
                 cmdstatus = DoGetPVPlayerState(cmd, false);
                 break;
 
+            case PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoGetPVPlayerState(cmd, true);
+                break;
+
             case PVP_ENGINE_COMMAND_ADD_DATA_SOURCE:
                 cmdstatus = DoAddDataSource(cmd);
                 break;
@@ -1215,6 +1450,10 @@
                 cmdstatus = DoGetMetadataValue(cmd);
                 break;
 
+            case PVP_ENGINE_COMMAND_RELEASE_METADATA_VALUE:
+                cmdstatus = DoReleaseMetadataValues(cmd);
+                break;
+
             case PVP_ENGINE_COMMAND_ADD_DATA_SINK:
                 cmdstatus = DoAddDataSink(cmd);
                 break;
@@ -1223,6 +1462,11 @@
                 cmdstatus = DoGetCurrentPosition(cmd, false);
                 break;
 
+            case PVP_ENGINE_COMMAND_GET_CURRENT_POSITION_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoGetCurrentPosition(cmd, true);
+                break;
+
             case PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE:
                 cmdstatus = DoSetPlaybackRange(cmd);
                 break;
@@ -1281,6 +1525,26 @@
                 cmdstatus = DoCapConfigSetParameters(cmd, false);
                 break;
 
+            case PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoCapConfigSetParameters(cmd, true);
+                break;
+
+            case PVP_ENGINE_COMMAND_CAPCONFIG_GET_PARAMETERS_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoGetParametersSync(cmd);
+                break;
+
+            case PVP_ENGINE_COMMAND_CAPCONFIG_RELEASE_PARAMETERS_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoReleaseParametersSync(cmd);
+                break;
+
+            case PVP_ENGINE_COMMAND_CAPCONFIG_VERIFY_PARAMETERS_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoVerifyParametersSync(cmd);
+                break;
+
             case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR:
             case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR:
                 cmdstatus = DoAcquireLicense(cmd);
@@ -1294,38 +1558,37 @@
                 cmdstatus = DoSourceDataReadyAutoResume(cmd);
                 break;
 
-            case PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR:
-                cmdstatus = DoStopDueToError(cmd);
+            case PVP_ENGINE_COMMAND_CAPCONFIG_SET_OBSERVER_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoSetObserverSync(cmd);
                 break;
 
-            case PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR:
-                cmdstatus = DoResetDueToError(cmd);
-                break;
-
-            case PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR:
-                cmdstatus = DoCleanupDueToError(cmd);
-                break;
-
-            case PVP_ENGINE_COMMAND_DATAPATH_DELETE:
-                cmdstatus = DoDatapathDelete(cmd);
-                break;
-
-            case PVP_ENGINE_COMMAND_CANCEL_DUE_TO_ERROR:
-                // Nothing to do since this command would not
-                // be processed from here
+            case PVP_ENGINE_COMMAND_GET_LICENSE_STATUS_OOTSYNC:
+                ootsync = true;
+                cmdstatus = DoGetLicenseStatusSync(cmd);
                 break;
 
             case PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS:
                 // CancelAll() should not be handled here
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() CancelAllCommands should be not handled in here. Asserting."));
-                OSCL_ASSERT(false);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() CancelAllCommands should be not handled in here. Return Failure"));
+                cmdstatus = PVMFFailure;
                 // Just handle as "not supported"
             default:
                 cmdstatus = PVMFErrNotSupported;
                 break;
         }
 
-        if (cmdstatus != PVMFSuccess)
+        if (ootsync)
+        {
+            OOTSyncCommandComplete(cmd, cmdstatus);
+            // Empty out the current cmd vector and set active if there are other pending commands
+            iCurrentCmd.erase(iCurrentCmd.begin());
+            if (!iPendingCmds.empty())
+            {
+                RunIfNotReady();
+            }
+        }
+        else if (cmdstatus != PVMFSuccess && cmdstatus != PVMFPending)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::Run() Command failed CmdId %d Status %d",
                             cmd.GetCmdId(), cmdstatus));
@@ -1336,7 +1599,6 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::Run() Out"));
 }
 
-
 bool PVPlayerEngine::FindNodeTypeByNode(PVMFNodeInterface* aUnknownNode, PVPlayerNodeType& aNodeType, int32& aDatapathListIndex)
 {
     if (aUnknownNode == NULL)
@@ -1372,30 +1634,164 @@
     return false;
 }
 
-
-bool PVPlayerEngine::FindDatapathByMediaType(PVPlayerMediaType aMediaType, int32& aDatapathListIndex)
+bool PVPlayerEngine::FindTrackForDatapathUsingMimeString(bool& aVideoTrack, bool& aAudioTrack, bool& aTextTrack, PVPlayerEngineDatapath* aDatapath)
 {
-    // Current implementaion needs to determine which media types are available
-    // and this logic can be removed if the engine is completely media type agnostic.
-    // This logic assumes there is only one possible datapath with the same media type.
-    if (aMediaType == PVP_MEDIATYPE_UNKNOWN)
+    if (aDatapath->iTrackInfo)
     {
-        // Cannot check with media type being unknown
-        // Might bring up false positives
-        aDatapathListIndex = -1;
-        return false;
-    }
+        char* mimeString = aDatapath->iTrackInfo->getTrackMimeType().get_str();
 
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        if (iDatapathList[i].iMediaType == aMediaType)
+        if ((pv_mime_strcmp(mimeString, PVMF_MIME_YUV420) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_YUV422) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_RGB8) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_RGB12) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_RGB16) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_RGB24) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_M4V) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_H2631998) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_H2632000) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_H264_VIDEO_RAW) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_H264_VIDEO_MP4) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_H264_VIDEO) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_WMV) == 0) ||
+                (pv_mime_strcmp(mimeString, PVMF_MIME_REAL_VIDEO) == 0))
         {
-            aDatapathListIndex = i;
+            aVideoTrack = true;
+            aAudioTrack = false;
+            aTextTrack = false;
             return true;
         }
+        else if (pv_mime_strcmp(mimeString, PVMF_MIME_3GPP_TIMEDTEXT) == 0)
+        {
+            aVideoTrack = false;
+            aAudioTrack = false;
+            aTextTrack = true;
+            return true;
+        }
+        else if ((pv_mime_strcmp(mimeString, PVMF_MIME_PCM) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_PCM8) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_PCM16) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_PCM16_BE) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_ULAW) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_ALAW) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_AMR) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_AMRWB) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_AMR_IETF) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_AMRWB_IETF) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_AMR_IF2) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_EVRC) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_MP3) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_ADIF) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_ADTS) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_LATM) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_MPEG4_AUDIO) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_G723) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_G726) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_WMA) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_ASF_AMR) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_REAL_AUDIO) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_ASF_MPEG4_AUDIO) == 0) ||
+                 (pv_mime_strcmp(mimeString, PVMF_MIME_3640) == 0))
+        {
+            aVideoTrack = false;
+            aAudioTrack = true;
+            aTextTrack = false;
+            return true;
+        }
+        else
+        {
+            aVideoTrack = false;
+            aAudioTrack = false;
+            aTextTrack = false;
+            return false;
+        }
     }
 
-    // Could not determine the types
+    aVideoTrack = false;
+    aAudioTrack = false;
+    aTextTrack = false;
+    return false;
+}
+
+bool PVPlayerEngine::FindDatapathForTrackUsingMimeString(bool aVideoTrack, bool aAudioTrack, bool aTextTrack, int32& aDatapathListIndex)
+{
+    for (uint32 i = 0; i < iDatapathList.size(); i++)
+    {
+        if (iDatapathList[i].iTrackInfo)
+        {
+            char* mimeString = iDatapathList[i].iTrackInfo->getTrackMimeType().get_str();
+            if (aVideoTrack)
+            {
+                // find a datapath using the mime string for Video track
+                if ((pv_mime_strcmp(mimeString, PVMF_MIME_YUV420) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_YUV422) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_RGB8) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_RGB12) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_RGB16) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_RGB24) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_M4V) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_H2631998) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_H2632000) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_H264_VIDEO_RAW) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_H264_VIDEO_MP4) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_H264_VIDEO) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_WMV) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_REAL_VIDEO) == 0))
+                {
+                    aDatapathListIndex = i;
+                    return true;
+                }
+            }
+            else if (aAudioTrack)
+            {
+                // find a datapath using the mime string for Audio track
+                if ((pv_mime_strcmp(mimeString, PVMF_MIME_PCM) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_PCM8) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_PCM16) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_PCM16_BE) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_ULAW) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_ALAW) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_AMR) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_AMRWB) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_AMR_IETF) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_AMRWB_IETF) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_AMR_IF2) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_EVRC) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_MP3) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_ADIF) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_ADTS) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_LATM) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_MPEG4_AUDIO) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_G723) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_G726) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_WMA) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_ASF_AMR) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_REAL_AUDIO) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_ASF_MPEG4_AUDIO) == 0) ||
+                        (pv_mime_strcmp(mimeString, PVMF_MIME_3640) == 0))
+                {
+                    aDatapathListIndex = i;
+                    return true;
+                }
+            }
+            else if (aTextTrack)
+            {
+                // find a datapath using the mime string for Text track
+                if (pv_mime_strcmp(mimeString, PVMF_MIME_3GPP_TIMEDTEXT) == 0)
+                {
+                    aDatapathListIndex = i;
+                    return true;
+                }
+            }
+            else
+            {
+                // Unknown track
+                aDatapathListIndex = -1;
+                return false;
+            }
+        }
+    }
+
+    // Unknown track
     aDatapathListIndex = -1;
     return false;
 }
@@ -1409,73 +1805,65 @@
 
     // Check if a cancel command completed
     uint32* context_uint32 = (uint32*)(aResponse.GetContext());
-    if (context_uint32 == &iPendingCancelDueToCancelRequest)
+    if (context_uint32 == &iNumberCancelCmdPending)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Cancel in node completed for cancel command. Pending %d", iPendingCancelDueToCancelRequest));
-        OSCL_ASSERT(iPendingCancelDueToCancelRequest > 0);
-        --iPendingCancelDueToCancelRequest;
-        if (iPendingCancelDueToCancelRequest == 0)
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Cancel in node completed for cancel command. Pending %d", iNumberCancelCmdPending));
+        --iNumberCancelCmdPending;
+
+        // If cmd to cancel was GetMetadataKeys() or GetMetadataValues() and if these commands return with
+        // success then first release the memory for the node which return with success.
+        if (iCmdToCancel[0].GetCmdType() == PVP_ENGINE_COMMAND_GET_METADATA_KEY &&
+                aResponse.GetCmdStatus() == PVMFSuccess)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Cancelling of all node/datapath commands complete so continue to shutdown"));
-            RemoveDatapathContextFromList(); // empty left over contexts from cancelled datapath commands
-            DoShutdownDueToCancel();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::NodeCommandCompleted() Cancel in node completed for GetMetadataKeys with success, release memory."));
+            // Release the memory allocated for the metadata keys
+            uint32 numkeysadded = iGetMetadataKeysParam.iKeyList->size() - iGetMetadataKeysParam.iNumKeyEntriesInList;
+            uint32 start = iGetMetadataKeysParam.iNumKeyEntriesInList;
+            uint32 end = iGetMetadataKeysParam.iNumKeyEntriesInList + numkeysadded - 1;
+
+            PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iGetMetadataKeysParam.iCurrentInterfaceIndex].iInterface;
+            OSCL_ASSERT(mdif != NULL);
+            mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), start, end);
         }
-        return;
-    }
-    // Check if stop called on node due to cancel shutdown
-    else if (context_uint32 == &iPendingStopDueToCancelRequest)
-    {
-        // Don't care about the response
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Stop in node due to cancel completed. Pending %d", iPendingStopDueToCancelRequest));
-        --iPendingStopDueToCancelRequest;
-        if (iPendingStopDueToCancelRequest == 0)
+        else if (iCmdToCancel[0].GetCmdType() == PVP_ENGINE_COMMAND_GET_METADATA_VALUE &&
+                 aResponse.GetCmdStatus() == PVMFSuccess)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Stopping of all nodes due to cancel has completed so continuing on to reset"));
-            DoResetDueToCancel();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::NodeCommandCompleted() Cancel in node completed for GetMetadataValue with success, release memory."));
+            // Release the memory allocated for the metadata values
+            uint32 numkeysadded = iGetMetadataValuesParam.iKeyList->size() - iGetMetadataValuesParam.iNumValueEntriesInList;
+            uint32 start = iGetMetadataValuesParam.iNumValueEntriesInList;
+            uint32 end = iGetMetadataValuesParam.iNumValueEntriesInList + numkeysadded - 1;
+
+            PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iGetMetadataValuesParam.iCurrentInterfaceIndex].iInterface;
+            OSCL_ASSERT(mdif != NULL);
+            mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), start, end);
+
+            iReleaseMetadataValuesPending = false;
         }
-        return;
-    }
-    // Check if reset called on node due to cancel shutdown
-    else if (context_uint32 == &iPendingResetDueToCancelRequest)
-    {
-        // Don't care about the response
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Reset in node due to cancel completed. Pending %d", iPendingResetDueToCancelRequest));
-        --iPendingResetDueToCancelRequest;
-        if (iPendingResetDueToCancelRequest == 0)
+
+        if (iNumberCancelCmdPending == 0)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Resetting of all nodes due to cancel has completed so continuing on to cleanup"));
-            // Need to cleanup in engine's AO so set the flag.
-            // There shouldn't be any other command pending to complete in engine's AO
-            OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-            iCommandCompleteInEngineAOPending = true;
-            if (IsBusy())
-            {
-                Cancel();
-            }
-            RunIfNotReady();
-        }
-        return;
-    }
-    // Check if cancel called on node due to error
-    else if (context_uint32 == &iPendingCancelDueToErrorRequest)
-    {
-        // Don't care about the response
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Cancel in node due to error completed. Pending %d", iPendingCancelDueToErrorRequest));
-        --iPendingCancelDueToErrorRequest;
-        if (iPendingCancelDueToErrorRequest == 0)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Cancel due to error complete."));
-            // Check that current cmd is the internal cancel-due-to-error command
-            OSCL_ASSERT(iCurrentCmd.empty() == false);
-            OSCL_ASSERT(iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_CANCEL_DUE_TO_ERROR);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Cancelling of all node/datapath commands complete, now reset all nodes"));
+            // Clear the CancelCmd queue as the cmd has been cancelled.
+            iCmdToCancel.clear();
 
             RemoveDatapathContextFromList(); // empty left over contexts from cancelled datapath commands
-            // Call EngineCommandCompleted() so the internal cancel-due-to-error command
-            // would be completed and next engine command in pending queue would be processed
-            EngineCommandCompleted(-1, NULL, PVMFSuccess);
-            // Clear out iCmdToCancel queue
-            OSCL_ASSERT(iCmdToCancel.empty() == false);
-            iCmdToCancel.clear();
+            // Now reset the source node
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
+
+            PVMFCommandId cmdid = -1;
+            int32 leavecode = 0;
+            OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+            OSCL_FIRST_CATCH_ANY(leavecode,
+
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::NodeCommandCompleted() Reset on iSourceNode did a leave!"));
+                                 FreeEngineContext(context);
+                                 OSCL_ASSERT(false);
+                                 return);
+
+            SetEngineState(PVP_ENGINE_STATE_RESETTING);
         }
         return;
     }
@@ -1484,7 +1872,7 @@
     OSCL_ASSERT(nodecontext);
 
     // Ignore other node completion if cancelling
-    if (!iCmdToCancel.empty())
+    if (!iCmdToCancel.empty() || (CheckForPendingErrorHandlingCmd() && aResponse.GetCmdStatus() == PVMFErrCancelled))
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::NodeCommandCompleted() Node command completion ignored due to cancel process, id=%d", aResponse.GetCmdId()));
         // Remove the context from the list
@@ -1493,7 +1881,11 @@
     }
 
     // Process according to cmd type in the engine context data, node type, or engine state
-    if (nodecontext->iCmdType == PVP_CMD_SinkNodeSkipMediaDataDuringPlayback)
+    if (nodecontext->iCmdType == PVP_CMD_SinkNodeSkipMediaData)
+    {
+        HandleSinkNodeSkipMediaData(*nodecontext, aResponse);
+    }
+    else if (nodecontext->iCmdType == PVP_CMD_SinkNodeSkipMediaDataDuringPlayback)
     {
         HandleSinkNodeSkipMediaDataDuringPlayback(*nodecontext, aResponse);
     }
@@ -1505,6 +1897,14 @@
     {
         HandleSinkNodeResume(*nodecontext, aResponse);
     }
+    else if (nodecontext->iCmdType == PVP_CMD_DecNodeReset)
+    {
+        HandleDecNodeReset(*nodecontext, aResponse);
+    }
+    else if (nodecontext->iCmdType == PVP_CMD_SinkNodeReset)
+    {
+        HandleSinkNodeReset(*nodecontext, aResponse);
+    }
     else if (nodecontext->iCmdType == PVP_CMD_GetNodeMetadataKey)
     {
         // Ignore the command status since it does not matter and continue going through the metadata interface list
@@ -1521,7 +1921,7 @@
             releaseentry.iEndIndex = iGetMetadataKeysParam.iNumKeyEntriesInList + numkeysadded - 1;
 
             leavecode = 0;
-            OSCL_TRY(leavecode, iMetadataReleaseList.push_back(releaseentry));
+            OSCL_TRY(leavecode, iMetadataKeyReleaseList.push_back(releaseentry));
             if (leavecode != 0)
             {
                 // An element could not be added to the release list vector
@@ -1534,12 +1934,12 @@
                 mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), releaseentry.iStartIndex, releaseentry.iEndIndex);
 
                 // Release the memory allocated for rest of the metadata keys
-                while (iMetadataReleaseList.empty() == false)
+                while (iMetadataKeyReleaseList.empty() == false)
                 {
-                    mdif = iMetadataIFList[iMetadataReleaseList[0].iMetadataIFListIndex].iInterface;
+                    mdif = iMetadataIFList[iMetadataKeyReleaseList[0].iMetadataIFListIndex].iInterface;
                     OSCL_ASSERT(mdif != NULL);
-                    mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataReleaseList[0].iStartIndex, iMetadataReleaseList[0].iEndIndex);
-                    iMetadataReleaseList.erase(iMetadataReleaseList.begin());
+                    mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataKeyReleaseList[0].iStartIndex, iMetadataKeyReleaseList[0].iEndIndex);
+                    iMetadataKeyReleaseList.erase(iMetadataKeyReleaseList.begin());
                 }
 
                 // Remove the context from the list
@@ -1584,7 +1984,7 @@
                 {
                     int32 leavecode = 0;
                     PVMFCommandId cmdid = -1;
-                    PVPlayerEngineContext* newcontext = AllocateEngineContext(NULL, NULL, NULL, nodecontext->iCmdId, nodecontext->iCmdContext, PVP_CMD_GetNodeMetadataKey);
+                    PVPlayerEngineContext* newcontext = AllocateEngineContext(iMetadataIFList[iGetMetadataKeysParam.iCurrentInterfaceIndex].iEngineDatapath, iMetadataIFList[iGetMetadataKeysParam.iCurrentInterfaceIndex].iNode, NULL, nodecontext->iCmdId, nodecontext->iCmdContext, PVP_CMD_GetNodeMetadataKey);
                     OSCL_TRY(leavecode, cmdid = mdif->GetNodeMetadataKeys(sessionid,
                                                 *(iGetMetadataKeysParam.iKeyList),
                                                 0,
@@ -1607,12 +2007,12 @@
                     EngineCommandCompleted(nodecontext->iCmdId, (OsclAny*)nodecontext->iCmdContext, aResponse.GetCmdStatus());
 
                     // Release the memory allocated for the metadata keys
-                    while (iMetadataReleaseList.empty() == false)
+                    while (iMetadataKeyReleaseList.empty() == false)
                     {
-                        mdif = iMetadataIFList[iMetadataReleaseList[0].iMetadataIFListIndex].iInterface;
+                        mdif = iMetadataIFList[iMetadataKeyReleaseList[0].iMetadataIFListIndex].iInterface;
                         OSCL_ASSERT(mdif != NULL);
-                        mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataReleaseList[0].iStartIndex, iMetadataReleaseList[0].iEndIndex);
-                        iMetadataReleaseList.erase(iMetadataReleaseList.begin());
+                        mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataKeyReleaseList[0].iStartIndex, iMetadataKeyReleaseList[0].iEndIndex);
+                        iMetadataKeyReleaseList.erase(iMetadataKeyReleaseList.begin());
                     }
 
                     // End the loop since finished command
@@ -1625,12 +2025,12 @@
                 EngineCommandCompleted(nodecontext->iCmdId, (OsclAny*)nodecontext->iCmdContext, aResponse.GetCmdStatus());
 
                 // Release the memory allocated for the metadata keys
-                while (iMetadataReleaseList.empty() == false)
+                while (iMetadataKeyReleaseList.empty() == false)
                 {
-                    PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataReleaseList[0].iMetadataIFListIndex].iInterface;
+                    PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataKeyReleaseList[0].iMetadataIFListIndex].iInterface;
                     OSCL_ASSERT(mdif != NULL);
-                    mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataReleaseList[0].iStartIndex, iMetadataReleaseList[0].iEndIndex);
-                    iMetadataReleaseList.erase(iMetadataReleaseList.begin());
+                    mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataKeyReleaseList[0].iStartIndex, iMetadataKeyReleaseList[0].iEndIndex);
+                    iMetadataKeyReleaseList.erase(iMetadataKeyReleaseList.begin());
                 }
 
                 // End the loop since reached the end of the metadata IF list
@@ -1654,7 +2054,7 @@
             releaseentry.iEndIndex = iGetMetadataValuesParam.iNumValueEntriesInList + numvaluesadded - 1;
 
             leavecode = 0;
-            OSCL_TRY(leavecode, iMetadataReleaseList.push_back(releaseentry));
+            OSCL_TRY(leavecode, iMetadataValueReleaseList.push_back(releaseentry));
             if (leavecode != 0)
             {
                 // An element could not be added to the release list vector
@@ -1667,12 +2067,12 @@
                 mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), releaseentry.iStartIndex, releaseentry.iEndIndex);
 
                 // Release the memory allocated for rest of the metadata values
-                while (iMetadataReleaseList.empty() == false)
+                while (iMetadataValueReleaseList.empty() == false)
                 {
-                    mdif = iMetadataIFList[iMetadataReleaseList[0].iMetadataIFListIndex].iInterface;
+                    mdif = iMetadataIFList[iMetadataValueReleaseList[0].iMetadataIFListIndex].iInterface;
                     OSCL_ASSERT(mdif != NULL);
-                    mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataReleaseList[0].iStartIndex, iMetadataReleaseList[0].iEndIndex);
-                    iMetadataReleaseList.erase(iMetadataReleaseList.begin());
+                    mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataValueReleaseList[0].iStartIndex, iMetadataValueReleaseList[0].iEndIndex);
+                    iMetadataValueReleaseList.erase(iMetadataValueReleaseList.begin());
                 }
 
                 // Remove the context from the list
@@ -1722,7 +2122,7 @@
                 {
                     int32 leavecode = 0;
                     PVMFCommandId cmdid = -1;
-                    PVPlayerEngineContext* newcontext = AllocateEngineContext(NULL, NULL, NULL, nodecontext->iCmdId, nodecontext->iCmdContext, PVP_CMD_GetNodeMetadataValue);
+                    PVPlayerEngineContext* newcontext = AllocateEngineContext(iMetadataIFList[iGetMetadataValuesParam.iCurrentInterfaceIndex].iEngineDatapath, iMetadataIFList[iGetMetadataValuesParam.iCurrentInterfaceIndex].iNode, NULL, nodecontext->iCmdId, nodecontext->iCmdContext, PVP_CMD_GetNodeMetadataValue);
                     OSCL_TRY(leavecode, cmdid = mdif->GetNodeMetadataValues(sessionid,
                                                 *(iGetMetadataValuesParam.iKeyList),
                                                 *(iGetMetadataValuesParam.iValueList),
@@ -1744,13 +2144,20 @@
                     // Retrieved requested number of values so notify completion of GetMetadataValue() command
                     EngineCommandCompleted(nodecontext->iCmdId, (OsclAny*)nodecontext->iCmdContext, aResponse.GetCmdStatus());
 
-                    // Release the memory allocated for the metadata values
-                    while (iMetadataReleaseList.empty() == false)
+                    if (iMetadataValuesCopiedInCallBack)
                     {
-                        mdif = iMetadataIFList[iMetadataReleaseList[0].iMetadataIFListIndex].iInterface;
-                        OSCL_ASSERT(mdif != NULL);
-                        mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataReleaseList[0].iStartIndex, iMetadataReleaseList[0].iEndIndex);
-                        iMetadataReleaseList.erase(iMetadataReleaseList.begin());
+                        // Release the memory allocated for the metadata values
+                        while (iMetadataValueReleaseList.empty() == false)
+                        {
+                            mdif = iMetadataIFList[iMetadataValueReleaseList[0].iMetadataIFListIndex].iInterface;
+                            OSCL_ASSERT(mdif != NULL);
+                            mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataValueReleaseList[0].iStartIndex, iMetadataValueReleaseList[0].iEndIndex);
+                            iMetadataValueReleaseList.erase(iMetadataValueReleaseList.begin());
+                        }
+                    }
+                    else
+                    {
+                        iReleaseMetadataValuesPending = true;
                     }
 
                     // End the loop since finished command
@@ -1762,13 +2169,20 @@
                 // No more so notify completion of GetMetadataValue() command
                 EngineCommandCompleted(nodecontext->iCmdId, (OsclAny*)nodecontext->iCmdContext, aResponse.GetCmdStatus());
 
-                // Release the memory allocated for the metadata values
-                while (iMetadataReleaseList.empty() == false)
+                if (iMetadataValuesCopiedInCallBack)
                 {
-                    PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataReleaseList[0].iMetadataIFListIndex].iInterface;
-                    OSCL_ASSERT(mdif != NULL);
-                    mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataReleaseList[0].iStartIndex, iMetadataReleaseList[0].iEndIndex);
-                    iMetadataReleaseList.erase(iMetadataReleaseList.begin());
+                    // Release the memory allocated for the metadata values
+                    while (iMetadataValueReleaseList.empty() == false)
+                    {
+                        PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataValueReleaseList[0].iMetadataIFListIndex].iInterface;
+                        OSCL_ASSERT(mdif != NULL);
+                        mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataValueReleaseList[0].iStartIndex, iMetadataValueReleaseList[0].iEndIndex);
+                        iMetadataValueReleaseList.erase(iMetadataValueReleaseList.begin());
+                    }
+                }
+                else
+                {
+                    iReleaseMetadataValuesPending = true;
                 }
 
                 // End the loop since reached the end of the metadata IF list
@@ -1820,10 +2234,6 @@
                             HandleSourceNodeQueryInterfaceOptional(*nodecontext, aResponse);
                             break;
 
-                        case PVP_CMD_SourceNodeGetDlaData:
-                            HandleSourceNodeGetDlaData(*nodecontext, aResponse);
-                            break;
-
                         case PVP_CMD_SourceNodeGetLicense:
                             HandleSourceNodeGetLicense(*nodecontext, aResponse);
                             break;
@@ -1938,24 +2348,6 @@
                     HandleSourceNodeReset(*nodecontext, aResponse);
                     break;
 
-                case PVP_ENGINE_STATE_HANDLINGERROR:
-                    switch (nodecontext->iCmdType)
-                    {
-                        case PVP_CMD_SourceNodeStop:
-                            HandleSourceNodeStopDueToError(*nodecontext, aResponse);
-                            break;
-
-                        case PVP_CMD_SourceNodeReset:
-                            HandleSourceNodeResetDueToError(*nodecontext, aResponse);
-                            break;
-
-                        default:
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::NodeCommandCompleted() Invalid source node command type in PVP_ENGINE_STATE_HANDLINGERROR. Asserting"));
-                            OSCL_ASSERT(false);
-                            break;
-                    }
-                    break;
-
                 default:
                     break;
             }
@@ -1965,37 +2357,35 @@
     {
         switch (nodecontext->iCmdType)
         {
-            case PVP_CMD_SinkNodeQueryFOConfigIF:
-                HandleSinkNodeQueryFileOutConfigIF(*nodecontext, aResponse);
-                break;
-
-            case PVP_CMD_SinkNodeQuerySyncCtrlIF:
-            case PVP_CMD_SinkNodeQueryMetadataIF:
             case PVP_CMD_SinkNodeQueryCapConfigIF:
-                HandleSinkNodeQueryInterfaceOptional(*nodecontext, aResponse);
+                HandleSinkNodeQueryCapConfigIF(*nodecontext, aResponse);
                 break;
 
-            case PVP_CMD_DecNodeQueryMetadataIF:
+            case PVP_CMD_SinkNodeInit:
+                HandleSinkNodeInit(*nodecontext, aResponse);
+                break;
+
             case PVP_CMD_DecNodeQueryCapConfigIF:
-                HandleDecNodeQueryInterfaceOptional(*nodecontext, aResponse);
+                HandleDecNodeQueryCapConfigIF(*nodecontext, aResponse);
                 break;
 
-            case PVP_CMD_SinkNodeSkipMediaData:
-                HandleSinkNodeSkipMediaData(*nodecontext, aResponse);
-                break;
-
-            case PVP_CMD_SinkNodeDecNodeQueryCapConfigIF:
-                HandleSinkNodeDecNodeQueryCapConfigIF(*nodecontext, aResponse);
-                break;
-
-            case PVP_CMD_SinkNodeDecNodeVerifyParameter:
-                HandleSinkNodeDecNodeVerifyParameter(*nodecontext, aResponse);
+            case PVP_CMD_DecNodeInit:
+                HandleDecNodeInit(*nodecontext, aResponse);
                 break;
 
             case PVP_CMD_SinkNodeDecNodeReset:
                 HandleSinkNodeDecNodeReset(*nodecontext, aResponse);
                 break;
 
+            case PVP_CMD_SinkNodeQuerySyncCtrlIF:
+            case PVP_CMD_SinkNodeQueryMetadataIF:
+                HandleSinkNodeQueryInterfaceOptional(*nodecontext, aResponse);
+                break;
+
+            case PVP_CMD_DecNodeQueryMetadataIF:
+                HandleDecNodeQueryInterfaceOptional(*nodecontext, aResponse);
+                break;
+
             default:
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::NodeCommandCompleted() Invalid node command type in PVP_ENGINE_STATE_PREPARING. Asserting"));
                 OSCL_ASSERT(false);
@@ -2005,7 +2395,7 @@
     else
     {
         // Unknown node command completion. Assert
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::NodeCommandCompleted() Unknown node command completion"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::NodeCommandCompleted() Unknown node command completion"));
         OSCL_ASSERT(false);
     }
 
@@ -2132,39 +2522,31 @@
 
     // Check if a cancel command completed
     uint32* context_uint32 = (uint32*)aContext;
-    if (context_uint32 == &iPendingCancelDueToCancelRequest)
+    if (context_uint32 == &iNumberCancelCmdPending)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Cancel in datapath completed for cancel command. Pending %d", iPendingCancelDueToCancelRequest));
-        OSCL_ASSERT(iPendingCancelDueToCancelRequest > 0);
-        --iPendingCancelDueToCancelRequest;
-        if (iPendingCancelDueToCancelRequest == 0)
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Cancel in datapath completed for cancel command. Pending %d", iNumberCancelCmdPending));
+        --iNumberCancelCmdPending;
+        if (iNumberCancelCmdPending == 0)
         {
-            RemoveDatapathContextFromList(); // empty left over contexts from cancelled datapath commands
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Cancelling of all node/datapath command complete so continuing to shutdown"));
-            DoShutdownDueToCancel();
-        }
-        return;
-    }
-    // Check if cancel called on node due to error
-    else if (context_uint32 == &iPendingCancelDueToErrorRequest)
-    {
-        // Don't care about the response
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Cancel in datapath due to error completed. Pending %d", iPendingCancelDueToErrorRequest));
-        --iPendingCancelDueToErrorRequest;
-        if (iPendingCancelDueToErrorRequest == 0)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Cancel due to error complete."));
-            // Check that current cmd is the internal cancel-due-to-error command
-            OSCL_ASSERT(iCurrentCmd.empty() == false);
-            OSCL_ASSERT(iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_CANCEL_DUE_TO_ERROR);
-            RemoveDatapathContextFromList(); // empty left over contexts from cancelled datapath commands
-            // Call EngineCommandCompleted() so the internal cancel-due-to-error command
-            // would be completed and next engine command in pending queue would be processed
-            EngineCommandCompleted(-1, NULL, PVMFSuccess);
-
-            // Clear out iCmdToCancel queue
-            OSCL_ASSERT(iCmdToCancel.empty() == false);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Cancelling of all node/datapath commands complete, now reset all nodes"));
+            // Clear the CancelCmd queue as the cmd has been cancelled.
             iCmdToCancel.clear();
+
+            RemoveDatapathContextFromList(); // empty left over contexts from cancelled datapath commands
+            // Now reset the source node
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
+
+            PVMFCommandId cmdid = -1;
+            int32 leavecode = 0;
+            OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+            OSCL_FIRST_CATCH_ANY(leavecode,
+
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Reset on iSourceNode did a leave!"));
+                                 FreeEngineContext(context);
+                                 OSCL_ASSERT(false);
+                                 return);
+
+            SetEngineState(PVP_ENGINE_STATE_RESETTING);
         }
         return;
     }
@@ -2173,7 +2555,7 @@
     OSCL_ASSERT(datapathcontext);
 
     // Ignore other datapath event if cancelling
-    if (!iCmdToCancel.empty())
+    if (!iCmdToCancel.empty() || (CheckForPendingErrorHandlingCmd() && (aCmdResp && aCmdResp->GetCmdStatus() == PVMFErrCancelled)))
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Datapath event ignored due to cancel process"));
         // Remove the context from the list
@@ -2195,8 +2577,7 @@
                 break;
 
             default:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid datapath command type in PVP_ENGINE_STATE_PREPARING. Asserting"));
-                OSCL_ASSERT(false);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid datapath command type in PVP_ENGINE_STATE_PREPARING."));
                 break;
         }
     }
@@ -2225,38 +2606,27 @@
                 break;
 
             default:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid datapath command type in PVP_ENGINE_STATE_STOPPING. Asserting"));
-                OSCL_ASSERT(false);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid datapath command type in PVP_ENGINE_STATE_STOPPING."));
                 break;
         }
     }
-    else if (iState == PVP_ENGINE_STATE_HANDLINGERROR)
+    else if (iState == PVP_ENGINE_STATE_RESETTING)
     {
         switch (datapathcontext->iCmdType)
         {
-            case PVP_CMD_DPStop:
-                HandleDatapathStopDueToError(*datapathcontext, aEventStatus, aCmdResp);
-                break;
-
-            case PVP_CMD_DPTeardown:
-                HandleDatapathTeardownDueToError(*datapathcontext, aEventStatus, aCmdResp);
-                break;
-
             case PVP_CMD_DPReset:
-                HandleDatapathResetDueToError(*datapathcontext, aEventStatus, aCmdResp);
+                HandleDatapathReset(*datapathcontext, aEventStatus, aCmdResp);
                 break;
 
             default:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid datapath command type in PVP_ENGINE_STATE_HANDLINGERROR. Asserting"));
-                OSCL_ASSERT(false);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid datapath command type in PVP_ENGINE_STATE_RESETTING"));
                 break;
         }
     }
     else
     {
-        // Unknown datapath. Assert
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid state for datapath command completion. Asserting"));
-        OSCL_ASSERT(false);
+        // Unknown datapath.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Invalid state for datapath command completion."));
     }
 
     // Remove the context from the list
@@ -2265,6 +2635,73 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandlePlayerDatapathEvent() Out"));
 }
 
+void PVPlayerEngine::NotificationsInterfaceDestroyed()
+{
+    iClockNotificationsInf = NULL;
+}
+
+void PVPlayerEngine::ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 aDelta,
+                                     const OsclAny* acontextData, PVMFStatus aStatus)
+{
+    OSCL_UNUSED_ARG(aTimerAccuracy);
+    OSCL_UNUSED_ARG(aDelta);
+    OSCL_UNUSED_ARG(acontextData);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::TimeoutOccurred() Timer for PlayStatus event triggered"));
+
+    if (aCallBackID == iPlayStatusCallbackTimerID)
+    {
+        //Callback timer needs to be restarted if status is success
+        if ((PVMFSuccess == aStatus) && iPlayStatusTimerEnabled)
+        {
+            SendPositionStatusUpdate();
+            iPlayStatusTimerEnabled = false;
+            iPlayStatusCallbackTimerID = 0;
+
+            StartPlaybackStatusTimer();
+        }
+        else
+        {
+            if (aStatus == PVMFErrCallbackClockStopped)
+            {
+                iPlayStatusTimerEnabled = false;
+                iPlayStatusCallbackTimerID = 0;
+            }
+        }
+    }
+}
+void PVPlayerEngine::SendPositionStatusUpdate(void)
+{
+    PVPPlaybackPosition curpos;
+    curpos.iPosUnit = iPBPosStatusUnit;
+    GetPlaybackClockPosition(curpos);
+
+    uint8 poslocalbuffer[8];
+    oscl_memset(poslocalbuffer, 0, 8);
+    poslocalbuffer[0] = 1;
+    switch (iPBPosStatusUnit)
+    {
+        case PVPPBPOSUNIT_SEC:
+            oscl_memcpy(&poslocalbuffer[4], &(curpos.iPosValue.sec_value), sizeof(uint32));
+            break;
+
+        case PVPPBPOSUNIT_MIN:
+            oscl_memcpy(&poslocalbuffer[4], &(curpos.iPosValue.min_value), sizeof(uint32));
+            break;
+
+        case PVPPBPOSUNIT_MILLISEC:
+        default:
+            oscl_memcpy(&poslocalbuffer[4], &(curpos.iPosValue.millisec_value), sizeof(uint32));
+            break;
+    }
+
+    PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+    PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoPlaybackPositionStatus, puuid, NULL));
+    // EventData parameter will be deprecated, and curpos will not be sent through EventData in future.
+    SendInformationalEvent(PVMFInfoPositionStatus, OSCL_STATIC_CAST(PVInterface*, infomsg), (OsclAny*)&curpos, poslocalbuffer, 8);
+    infomsg->removeRef();
+}
+
 
 void PVPlayerEngine::TimeoutOccurred(int32 timerID, int32 /*timeoutInfo*/)
 {
@@ -2299,98 +2736,43 @@
             iPollingCheckTimer->Cancel(PVPLAYERENGINE_TIMERID_ENDTIMECHECK);
         }
     }
-    else if (timerID == PVPLAYERENGINE_TIMERID_PLAY_STATUS)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::TimeoutOccurred() Timer for PlayStatus event triggered"));
-        PVPPlaybackPosition curpos;
-        curpos.iPosUnit = iPBPosStatusUnit;
-        GetPlaybackClockPosition(curpos);
-
-        uint8 poslocalbuffer[8];
-        oscl_memset(poslocalbuffer, 0, 8);
-        poslocalbuffer[0] = 1;
-        switch (iPBPosStatusUnit)
-        {
-            case PVPPBPOSUNIT_SEC:
-                oscl_memcpy(&poslocalbuffer[4], &(curpos.iPosValue.sec_value), sizeof(uint32));
-                break;
-
-            case PVPPBPOSUNIT_MIN:
-                oscl_memcpy(&poslocalbuffer[4], &(curpos.iPosValue.min_value), sizeof(uint32));
-                break;
-
-            case PVPPBPOSUNIT_MILLISEC:
-            default:
-                oscl_memcpy(&poslocalbuffer[4], &(curpos.iPosValue.millisec_value), sizeof(uint32));
-                break;
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoPlaybackPositionStatus, puuid, NULL));
-        // EventData parameter will be deprecated, and curpos will not be sent through
-        // EventData in future.
-        SendInformationalEvent(PVMFInfoPositionStatus, OSCL_STATIC_CAST(PVInterface*, infomsg), (OsclAny*)&curpos, poslocalbuffer, 8);
-        infomsg->removeRef();
-
-        if (!iPlayStatusTimerEnabled)
-        {
-            iPollingCheckTimer->Cancel(PVPLAYERENGINE_TIMERID_PLAY_STATUS);
-        }
-    }
 }
 
-
-void PVPlayerEngine::CPMPluginCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::CPMPluginCommandCompleted() In"));
-
-    OSCL_ASSERT(iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR ||
-                iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR);
-
-    switch (iCPMPluginCommand)
-    {
-        case PVP_CMD_CPMQueryLicenseIF:
-            HandleCPMPluginQueryLicenseIF(aResponse);
-            break;
-
-        case PVP_CMD_CPMQueryCapConfigIF:
-            HandleCPMPluginQueryCapConfigIF(aResponse);
-            break;
-
-        case PVP_CMD_CPMGetLicense:
-            HandleCPMPluginGetLicense(aResponse);
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::CPMPluginCommandCompleted() Unknown CPM plug-in command. Asserting"));
-            OSCL_ASSERT(false);
-            break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::CPMPluginCommandCompleted() Out"));
-}
-
-
 void PVPlayerEngine::RecognizeCompleted(PVMFFormatType aSourceFormatType, OsclAny* aContext)
 {
     // Check if a cancel command completed
     uint32* context_uint32 = (uint32*)(aContext);
-    if (context_uint32 == &iPendingCancelDueToCancelRequest)
+    if (context_uint32 == &iNumberCancelCmdPending)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::RecognizeCompleted() Recognize request cancelled"));
-        OSCL_ASSERT(iPendingCancelDueToCancelRequest > 0);
-        --iPendingCancelDueToCancelRequest;
-        if (iPendingCancelDueToCancelRequest == 0)
+        --iNumberCancelCmdPending;
+        if (iNumberCancelCmdPending == 0)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::RecognizeCompleted() Cancelling of all pending commands complete so continue to shutdown"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::RecognizeCompleted() Cancelling of all node/datapath commands complete, now reset all nodes"));
+            // Clear the CancelCmd queue as the cmd has been cancelled.
+            iCmdToCancel.clear();
+
             RemoveDatapathContextFromList(); // empty left over contexts from cancelled datapath commands
-            DoShutdownDueToCancel();
+            // Now reset the source node
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
+
+            PVMFCommandId cmdid = -1;
+            int32 leavecode = 0;
+            OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+            OSCL_FIRST_CATCH_ANY(leavecode,
+
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RecognizeCompleted() Reset on iSourceNode did a leave!"));
+                                 FreeEngineContext(context);
+                                 OSCL_ASSERT(false);
+                                 return);
+
+            SetEngineState(PVP_ENGINE_STATE_RESETTING);
         }
         return;
     }
 
     // Ignore recognize completion if cancelling
-    if (!iCmdToCancel.empty())
+    if (!iCmdToCancel.empty() || CheckForPendingErrorHandlingCmd())
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::RecognizeCompleted() Recognize completion ignored due to cancel process"));
         // Remove the context from the list
@@ -2413,58 +2795,165 @@
 
     if (retval != PVMFSuccess)
     {
-        // Do cleanup
-        DoSourceNodeCleanup();
-        iDataSource = NULL;
-
-        // Complete the AddDataSource() command with failure
-        EngineCommandCompleted(cmdid, cmdcontext, retval);
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RecognizeCompleted() Already EH pending, should never happen"));
+            return;
+        }
+        else
+        {
+            // Queue up Error Handling
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RecognizeCompleted() DoSetupSourceNode failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = retval;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE, NULL, NULL, NULL, false);
+        }
+        return;
     }
 }
 
+//A callback from the threadsafe queue
+void PVPlayerEngine::ThreadSafeQueueDataAvailable(ThreadSafeQueue* aQueue)
+{
+    OSCL_UNUSED_ARG(aQueue);
+
+    //pull all available data off the thread-safe queue and transfer
+    //it to the internal queue.
+    for (uint32 ndata = 1;ndata;)
+    {
+        ThreadSafeQueueId id;
+        OsclAny* data;
+        ndata = iThreadSafeQueue.DeQueue(id, data);
+        if (ndata)
+        {
+            PVPlayerEngineCommand* cmd = (PVPlayerEngineCommand*)data;
+            AddCommandToQueue(cmd->iCmdType
+                              , cmd->iContextData
+                              , &cmd->iParamVector
+                              , &cmd->iUuid
+                              , true//assume all out-of-thread data is an API command.
+                              , (PVCommandId*)&id);//use the command ID that was returned to the caller.
+            OSCL_DELETE(cmd);
+        }
+    }
+}
+
+PVMFStatus PVPlayerEngine::DoOOTSyncCommand(int32 aCmdType,
+        Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector,
+        const PVUuid* aUuid)
+{
+    //Called from out-of-thread to perform a synchronous command
+
+
+    //Add a PVMFStatus* to the end of the command param vec to hold the result.
+    PVMFStatus status;
+    PVPlayerEngineCommandParamUnion param;
+    param.pOsclAny_value = (OsclAny*) & status;
+    aParamVector->push_back(param);
+
+    //push the command across the thread boundary
+    PVCommandId id = 0;
+    PVPlayerEngineCommand* cmd = OSCL_NEW(PVPlayerEngineCommand, (aCmdType, id, NULL, aParamVector));
+    if (aUuid)
+        cmd->SetUuid(*aUuid);
+    iThreadSafeQueue.AddToQueue(cmd);
+
+    //block and wait for completion by engine thread.
+    iOOTSyncCommandSem.Wait();
+    return status;
+}
+
+void PVPlayerEngine::OOTSyncCommandComplete(PVPlayerEngineCommand& aCmd, PVMFStatus aStatus)
+{
+    //Called in engine thread to complete an out-of-thread synchronous command
+
+    //Put the result status into the last element of the command param vector.
+    PVMFStatus* status = (PVMFStatus*)(aCmd.GetParam(aCmd.iParamVector.size() - 1).pOsclAny_value);
+    OSCL_ASSERT(status);
+    *status = aStatus;
+
+    //Signal the calling thread.
+    iOOTSyncCommandSem.Signal();
+}
 
 PVCommandId PVPlayerEngine::AddCommandToQueue(int32 aCmdType, OsclAny* aContextData,
         Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector,
-        const PVUuid* aUuid, bool aAPICommand)
+        const PVUuid* aUuid, bool aAPICommand, PVCommandId* aId)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::AddCommandToQueue() In CmdType %d, CmdId %d", aCmdType, iCommandId));
 
-    PVPlayerEngineCommand cmd(aCmdType, iCommandId, aContextData, aParamVector, aAPICommand);
+    PVCommandId commandId;
+    if (aId)
+    {
+        //This command is being transferred from the thread-safe queue to the
+        //internal queue, in engine thread context.
+        //The input ID is the one that was returned to the
+        //caller, so use that ID instead of generating a new one.
+        commandId = *aId;
+    }
+    else
+    {
+        //Generate the next command ID, being careful to avoid thread contention
+        //for "iCommandId".
+        iCommandIdMut.Lock();
+        commandId = iCommandId;
+        ++iCommandId;
+        if (iCommandId == 0x7FFFFFFF)
+        {
+            iCommandId = 0;
+        }
+        iCommandIdMut.Unlock();
+
+        //If this is from outside engine thread context, then push the command across the
+        //thread boundary.
+        if (!iThreadSafeQueue.IsInThread())
+        {
+            PVPlayerEngineCommand* cmd = OSCL_NEW(PVPlayerEngineCommand, (aCmdType, commandId, aContextData, aParamVector, aAPICommand));
+            if (aUuid)
+                cmd->SetUuid(*aUuid);
+            iThreadSafeQueue.AddToQueue(cmd, (ThreadSafeQueueId*)&commandId);
+            return commandId;
+        }
+    }
+
+    PVPlayerEngineCommand cmd(aCmdType, commandId, aContextData, aParamVector, aAPICommand);
     if (aUuid)
     {
         cmd.SetUuid(*aUuid);
     }
 
-    /*
-     * If engine is in error or error handling state, then don't add external commands to the queue
-     */
     int32 leavecode = 0;
-    if (aAPICommand == true)   //External Command
-    {
-        if (iState == PVP_ENGINE_STATE_ERROR || iState == PVP_ENGINE_STATE_HANDLINGERROR)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::AddCommandToQueue() Invalid state due to Error Handling : CmdType %d, CmdId %d", aCmdType, iCommandId));
-            OSCL_LEAVE(OsclErrInvalidState);
-            return -1;       // Dummy Cmdid
-        }
-
-    }
-
-
     OSCL_TRY(leavecode, iPendingCmds.push(cmd));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::AddCommandToQueue() Adding command to pending command list did a leave!"));
                          OSCL_ASSERT(false);
                          return -1;);
 
-    RunIfNotReady();
-
-    ++iCommandId;
-    if (iCommandId == 0x7FFFFFFF)
+    // if engine needs to queue any error handling command set the engine state as PVP_ENGINE_STATE_ERROR.
+    switch (aCmdType)
     {
-        iCommandId = 0;
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS:
+        case PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL:
+            SetEngineState(PVP_ENGINE_STATE_ERROR);
+            SendInformationalEvent(PVMFInfoErrorHandlingStart, NULL);
+            break;
+
+        default:
+            break;
     }
 
+    RunIfNotReady();
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_NOTICE,
                     (0, "PVPlayerEngine::AddCommandToQueue() Type=%d ID=%d APIcmd=%d Tick=%d",
                      aCmdType, cmd.GetCmdId(), aAPICommand, OsclTickCount::TickCount()));
@@ -2490,7 +2979,9 @@
 
         case PVP_ENGINE_STATE_INITIALIZED:
         case PVP_ENGINE_STATE_PREPARING:
-        case PVP_ENGINE_STATE_RESETTING:
+        case PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE:
+        case PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE:
+        case PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE:
             return PVP_STATE_INITIALIZED;
 
         case PVP_ENGINE_STATE_PREPARED:
@@ -2509,8 +3000,19 @@
         case PVP_ENGINE_STATE_RESUMING:
             return PVP_STATE_PAUSED;
 
+        case PVP_ENGINE_STATE_RESETTING:
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                return PVP_STATE_ERROR;
+            }
+            else
+            {
+                return PVP_STATE_IDLE;
+            }
+        }
 
-        case PVP_ENGINE_STATE_HANDLINGERROR:
         case PVP_ENGINE_STATE_ERROR:
             return PVP_STATE_ERROR;
 
@@ -2542,7 +3044,7 @@
     else
     {
         // Get current playback clock position
-        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, OSCLCLOCK_MSEC);
+        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
 
         nptcurpos = iStartNPT + iPlaybackDirection * (clockcurpos - iStartMediaDataTS);
     }
@@ -2559,7 +3061,7 @@
 }
 
 
-PVMFStatus PVPlayerEngine::ConvertToMillisec(PVPPlaybackPosition aPBPos, uint32& aTimeMS)
+PVMFStatus PVPlayerEngine::ConvertToMillisec(PVPPlaybackPosition& aPBPos, uint32& aTimeMS)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::ConvertToMillisec() In"));
 
@@ -2637,47 +3139,30 @@
             // Determine which track to use for conversion.
             // Give preference to video track, then text, and finally audio
             PVMFTrackInfo* track = NULL;
-            PVPlayerMediaType selmediatype = PVP_MEDIATYPE_UNKNOWN;
+            int32 datapathIndex = -1;
 
             // Search from the datapath list.
-            for (uint32 i = 0; i < iDatapathList.size(); ++i)
+            // 1) Try for video track
+            bool retVal = FindDatapathForTrackUsingMimeString(true, false, false, datapathIndex);
+            if (retVal == false)
             {
-                if (iDatapathList[i].iTrackActive)
+                // Video track not available, look for text track
+                retVal = FindDatapathForTrackUsingMimeString(false, false, true, datapathIndex);
+                if (retVal == false)
                 {
-                    switch (iDatapathList[i].iMediaType)
+                    // Text track also not avaliable, look for audio track
+                    retVal = FindDatapathForTrackUsingMimeString(false, true, false, datapathIndex);
+                    if (retVal == false)
                     {
-                        case PVP_MEDIATYPE_VIDEO:
-                            track = iDatapathList[i].iTrackInfo;
-                            selmediatype = PVP_MEDIATYPE_VIDEO;
-                            // Video track found so no need to check further
-                            i = iDatapathList.size();
-                            break;
-
-                        case PVP_MEDIATYPE_TEXT:
-                            track = iDatapathList[i].iTrackInfo;
-                            selmediatype = PVP_MEDIATYPE_TEXT;
-                            break;
-
-                        case PVP_MEDIATYPE_AUDIO:
-                            if (selmediatype != PVP_MEDIATYPE_TEXT)
-                            {
-                                track = iDatapathList[i].iTrackInfo;
-                                selmediatype = PVP_MEDIATYPE_TEXT;
-                            }
-                            break;
-
-                        default:
-                            break;
+                        // Track is not available to do the conversion
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::ConvertToMillisec() Track not selected for conversion"));
+                        return PVMFErrArgument;
                     }
                 }
             }
 
-            if (track == NULL)
-            {
-                // Track is not available to do the conversion
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::ConvertToMillisec() Track not selected for conversion"));
-                return PVMFErrArgument;
-            }
+            // Track avalaible.
+            track = iDatapathList[datapathIndex].iTrackInfo;
 
             // Convert the sample number to time in milliseconds
             PVMFTimestamp framets = 0;
@@ -2706,7 +3191,7 @@
             PVMFTimestamp mints = 0xFFFFFFFF;
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     PVMFTimestamp curts = 0;
                     if (iSourceNodeTrackLevelInfoIF->GetTimestampForDataPosition(*(iDatapathList[i].iTrackInfo), aPBPos.iPosValue.datapos_value, curts) != PVMFSuccess)
@@ -2788,6 +3273,19 @@
             // source node handle the request.
         }
     }
+
+    if (aPBPos.iPosUnit == PVPPBPOSUNIT_PLAYLIST)
+    {
+        aPBPos.iPlayListPosValue.millisec_value = aTimeMS;
+        aPBPos.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+    }
+    else
+    {
+        aPBPos.iPosValue.millisec_value = aTimeMS;
+        aPBPos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+    }
+    iTargetNPT = aTimeMS;
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::ConvertToMillisec() Out"));
     return PVMFSuccess;
 }
@@ -2843,8 +3341,15 @@
             }
             else
             {
-                // Calculate percentage of playback
-                aPBPos.iPosValue.percent_value = (aTimeMS * 100) / iSourceDurationInMS;
+                // Calculate percentage of playback, avoiding overflow
+                if (iSourceDurationInMS >= PVP_MIN_PLAYSTATUS_PERCENT_OVERFLOW_THRESHOLD)
+                {
+                    aPBPos.iPosValue.percent_value = aTimeMS / (iSourceDurationInMS / 100);
+                }
+                else
+                {
+                    aPBPos.iPosValue.percent_value = (aTimeMS * 100) / iSourceDurationInMS;
+                }
             }
         }
         break;
@@ -2859,49 +3364,32 @@
             }
 
             // Determine which track to use for conversion.
-            // Give preference to video track
+            // Give preference to video track, then text, and finally audio
             PVMFTrackInfo* track = NULL;
-            PVPlayerMediaType selmediatype = PVP_MEDIATYPE_UNKNOWN;
+            int32 datapathIndex = -1;
 
             // Search from the datapath list.
-            for (uint32 i = 0; i < iDatapathList.size(); ++i)
+            // 1) Try for video track
+            bool retVal = FindDatapathForTrackUsingMimeString(true, false, false, datapathIndex);
+            if (retVal == false)
             {
-                if (iDatapathList[i].iTrackActive)
+                // Video track not available, look for text track
+                retVal = FindDatapathForTrackUsingMimeString(false, false, true, datapathIndex);
+                if (retVal == false)
                 {
-                    switch (iDatapathList[i].iMediaType)
+                    // Text track also not avaliable, look for audio track
+                    retVal = FindDatapathForTrackUsingMimeString(false, true, false, datapathIndex);
+                    if (retVal == false)
                     {
-                        case PVP_MEDIATYPE_VIDEO:
-                            track = iDatapathList[i].iTrackInfo;
-                            selmediatype = PVP_MEDIATYPE_VIDEO;
-                            // Video track found so no need to check further
-                            i = iDatapathList.size();
-                            break;
-
-                        case PVP_MEDIATYPE_TEXT:
-                            track = iDatapathList[i].iTrackInfo;
-                            selmediatype = PVP_MEDIATYPE_TEXT;
-                            break;
-
-                        case PVP_MEDIATYPE_AUDIO:
-                            if (selmediatype != PVP_MEDIATYPE_TEXT)
-                            {
-                                track = iDatapathList[i].iTrackInfo;
-                                selmediatype = PVP_MEDIATYPE_TEXT;
-                            }
-                            break;
-
-                        default:
-                            break;
+                        // Track is not available to do the conversion
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::ConvertToMillisec() Track not selected for conversion"));
+                        return PVMFErrArgument;
                     }
                 }
             }
 
-            if (track == NULL)
-            {
-                // Track is not available to do the conversion
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::ConvertFromMillisec() Track not selected for conversion"));
-                return PVMFErrArgument;
-            }
+            // Track avalaible.
+            track = iDatapathList[datapathIndex].iTrackInfo;
 
             // Convert the time to sample number
             PVMFTimestamp ts = aTimeMS;
@@ -2935,7 +3423,7 @@
             // Go through each active track
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     uint32 curdatapos = 0;
                     // Convert the time to data position
@@ -3020,11 +3508,6 @@
             SendSourceDataReadyInfoEvent(aStatus, aExtInterface);
             break;
 
-        case PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR:
-        case PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR:
-            SendErrorHandlingCompleteEvent(aStatus, aExtInterface);
-            break;
-
         case PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS:
             // Send callback to the specified observer
             if (iCfgCapCmdObserver)
@@ -3093,15 +3576,18 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelAllCommands() In"));
 
+
     // Engine cannot be processing another cancel command
     OSCL_ASSERT(iCmdToCancel.empty() == true);
 
     // While AcquireLicense and CancelAcquireLicense is processing, CancelAllCommands is prohibited.
-    if (!iCmdToDlaCancel.empty() || iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE ||
-            iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR || iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR)
+    if (!iCmdToDlaCancel.empty() ||
+            (!iCurrentCmd.empty() &&
+             (iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE ||
+              iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR ||
+              iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR)))
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelAllCommands() Error due to processing AcquireLicense or CancelAcquireLicense,CmdType=%d", iCurrentCmd[0].GetCmdType()));
-
         PVPlayerEngineCommand currentcmd(iCurrentCmd[0]);
         iCurrentCmd.erase(iCurrentCmd.begin());
         iCurrentCmd.push_front(aCmd);
@@ -3109,6 +3595,11 @@
         iCurrentCmd.push_front(currentcmd);
         return;
     }
+    // set engine state to Resetting, as cancel command completion will take Engine to Idle state, after internal reset.
+    SetEngineState(PVP_ENGINE_STATE_RESETTING);
+    iRollOverState = RollOverStateIdle; //reset roll over state to Idle, as engine is resetting itself
+    // Stop the playback clock
+    iPlaybackClock.Stop();
     // Cancel the current command first
     if (iCurrentCmd.size() == 1)
     {
@@ -3129,7 +3620,7 @@
         // Get the queue from the top
         PVPlayerEngineCommand cmd(iTempPendingCmds.top());
         // Check if it needs to be cancelled
-        if ((aCmd.GetCmdId() > cmd.GetCmdId()) && ((aCmd.GetCmdId() - cmd.GetCmdId()) < 0x80000000))
+        if ((aCmd.GetCmdId() > cmd.GetCmdId()) && !((aCmd.GetCmdId() - cmd.GetCmdId()) > 0x7FFFFFFF))
         {
             // Remove it from the pending commands queue
             iPendingCmds.remove(cmd);
@@ -3141,18 +3632,53 @@
         iTempPendingCmds.pop();
     }
 
+
     // Make the CancelAll() command the current command
     iCurrentCmd.push_front(aCmd);
 
     // Check if there was an ongoing command that needs to be properly cancelled
     if (!iCmdToCancel.empty())
     {
+
         // Properly cancel a command being currently processed
         DoCancelCommandBeingProcessed();
     }
     else
     {
-        // CancelAll() command is completed so send the completion event
+        // Nothing to cancel, move on to resetting Source Nodes and Datapaths
+        if (iSourceNode)
+        {
+            int32 leavecode = 0;
+            // call reset on source node if not in created state
+            if (iSourceNode->GetState() != EPVMFNodeCreated)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::DoCancelAllCommands() Issue reset on Source Node"));
+                // error handling code set engine state to resetting
+                SetEngineState(PVP_ENGINE_STATE_RESETTING);
+
+                PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
+
+                PVMFCommandId cmdid = -1;
+                leavecode = 0;
+                OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+                OSCL_FIRST_CATCH_ANY(leavecode,
+
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "PVPlayerEngine::DoCancelAllCommands() Reset on iSourceNode did a leave!"));
+                                     FreeEngineContext(context);
+                                     OSCL_ASSERT(false););
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelAllCommands() Out"));
+                return;
+            }
+        }
+
+        if (iDataSource)
+        {
+            RemoveDataSourceSync(*iDataSource);
+        }
+        SetEngineState(PVP_ENGINE_STATE_IDLE);
         EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
     }
 
@@ -3167,45 +3693,82 @@
     // There should be a command to cancel
     OSCL_ASSERT(iCmdToCancel.empty() == false);
 
+    // If cmd to cancel is GetMetadataKeys() or GetMetadataValues(), first release the memory for
+    // nodes which have already completed the call and then issue cancel on other nodes.
     switch (iCmdToCancel[0].GetCmdType())
     {
+        case PVP_ENGINE_COMMAND_GET_METADATA_KEY:
+        {
+            // Release the memory allocated for the metadata keys
+            while (iMetadataKeyReleaseList.empty() == false)
+            {
+                PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataKeyReleaseList[0].iMetadataIFListIndex].iInterface;
+                OSCL_ASSERT(mdif != NULL);
+                mdif->ReleaseNodeMetadataKeys(*(iGetMetadataKeysParam.iKeyList), iMetadataKeyReleaseList[0].iStartIndex, iMetadataKeyReleaseList[0].iEndIndex);
+                iMetadataKeyReleaseList.erase(iMetadataKeyReleaseList.begin());
+            }
+            // no need to break from the current switch, as we need to issue Cancel on nodes. Continue.
+        }
+        case PVP_ENGINE_COMMAND_GET_METADATA_VALUE:
+        {
+            // Release the memory allocated for the metadata values
+            while (iMetadataValueReleaseList.empty() == false)
+            {
+                PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataValueReleaseList[0].iMetadataIFListIndex].iInterface;
+                OSCL_ASSERT(mdif != NULL);
+                mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataValueReleaseList[0].iStartIndex, iMetadataValueReleaseList[0].iEndIndex);
+                iMetadataValueReleaseList.erase(iMetadataValueReleaseList.begin());
+            }
+
+            iReleaseMetadataValuesPending = false;
+            // no need to break from the current switch, as we need to issue Cancel on nodes. Continue.
+        }
         case PVP_ENGINE_COMMAND_ADD_DATA_SOURCE:
         case PVP_ENGINE_COMMAND_INIT:
         case PVP_ENGINE_COMMAND_PREPARE:
         case PVP_ENGINE_COMMAND_PAUSE:
         case PVP_ENGINE_COMMAND_RESUME:
         case PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE:
-        case PVP_ENGINE_COMMAND_STOP:
-            if (!iCurrentContextList.empty())
-            {
-                // Since there is a pending node or datapath, cancel it
-                DoCancelPendingNodeDatapathCommand();
-            }
-            else
-            {
-                // No pending command so contine to shutdown
-                DoShutdownDueToCancel();
-            }
-            break;
-
-        case PVP_ENGINE_COMMAND_RESET:
         case PVP_ENGINE_COMMAND_SET_PLAYBACK_RATE:
         case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDTIME_REACHED:
         case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP:
         case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW:
         case PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY:
-        case PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR:
-        case PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR:
-        case PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR:
-        case PVP_ENGINE_COMMAND_GET_METADATA_KEY:
-        case PVP_ENGINE_COMMAND_GET_METADATA_VALUE:
-        case PVP_ENGINE_COMMAND_DATAPATH_DELETE:
-            // Complete the CancelAll() but allow the pending command to complete.
-            // This is necessary until transition cancel is fully implemented.
-            EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFSuccess);
-            iCurrentCmd.push_front(iCmdToCancel[0]);
-            iCmdToCancel.clear();
+        case PVP_ENGINE_COMMAND_STOP:
+        {
+            // go ahead and issue cancel on nodes and datapath if needed.
+            if (!iCurrentContextList.empty())
+            {
+                // Since there is a pending node or datapath, cancel it
+                PVMFStatus status = DoCancelPendingNodeDatapathCommand();
+                if (status == PVMFPending)
+                {
+                    // There are some commands which need to be cancelled so wait for cancel complete
+                    // once cancels complete, we would start the reset sequence from either
+                    // NodeCommandComplete, HandlePlayerDataPathEvent, RecognizeComplete
+                    break;
+                }
+            }
+
+            // No pending command so reset the nodes now
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelCommandBeingProcessed() No command to cancel, now reset all nodes"));
+
+            // reset the source node
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
+
+            PVMFCommandId cmdid = -1;
+            int32 leavecode = 0;
+            OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+            OSCL_FIRST_CATCH_ANY(leavecode,
+
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelCommandBeingProcessed() Reset on iSourceNode did a leave!"));
+                                 FreeEngineContext(context);
+                                 OSCL_ASSERT(false);
+                                 return);
+
+            SetEngineState(PVP_ENGINE_STATE_RESETTING);
             break;
+        }
 
         case PVP_ENGINE_COMMAND_QUERY_UUID:
         case PVP_ENGINE_COMMAND_QUERY_INTERFACE:
@@ -3236,7 +3799,7 @@
 }
 
 
-void PVPlayerEngine::DoCancelPendingNodeDatapathCommand()
+PVMFStatus PVPlayerEngine::DoCancelPendingNodeDatapathCommand()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() In"));
 
@@ -3244,7 +3807,7 @@
 
     // Determine where the pending commands were issued to and then cancel them
     int32 leavecode = 0;
-    iPendingCancelDueToCancelRequest = 0;
+    iNumberCancelCmdPending = 0;
     for (uint32 i = 0; i < iCurrentContextList.size(); ++i)
     {
         if (iCurrentContextList[i]->iNode)
@@ -3252,11 +3815,16 @@
             if (iCurrentContextList[i]->iNode == iSourceNode)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() Calling CancelAllCommands() on source node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, iSourceNode->CancelAllCommands(iSourceNodeSessionId, (OsclAny*)&iPendingCancelDueToCancelRequest));
+                leavecode = IssueNodeCancelCommand(iCurrentContextList[i], iSourceNodeSessionId, (OsclAny*) & iNumberCancelCmdPending);
                 if (leavecode == 0)
                 {
-                    ++iPendingCancelDueToCancelRequest;
+                    ++iNumberCancelCmdPending;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() CancelAllCommands() on source node did a leave"));
+                    FreeEngineContext(iCurrentContextList[i]);
                 }
             }
             else if (iCurrentContextList[i]->iEngineDatapath != NULL)
@@ -3264,21 +3832,31 @@
                 if (iCurrentContextList[i]->iNode == iCurrentContextList[i]->iEngineDatapath->iSinkNode)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() Calling CancelAllCommands() on sink node"));
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, iCurrentContextList[i]->iNode->CancelAllCommands(iCurrentContextList[i]->iEngineDatapath->iSinkNodeSessionId, (OsclAny*)&iPendingCancelDueToCancelRequest));
+                    leavecode = IssueNodeCancelCommand(iCurrentContextList[i], iCurrentContextList[i]->iEngineDatapath->iSinkNodeSessionId, (OsclAny*) & iNumberCancelCmdPending);
                     if (leavecode == 0)
                     {
-                        ++iPendingCancelDueToCancelRequest;
+                        ++iNumberCancelCmdPending;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() CancelAllCommands() on sink node did a leave"));
+                        FreeEngineContext(iCurrentContextList[i]);
                     }
                 }
                 else if (iCurrentContextList[i]->iNode == iCurrentContextList[i]->iEngineDatapath->iDecNode)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() Calling CancelAllCommands() on dec node"));
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, iCurrentContextList[i]->iNode->CancelAllCommands(iCurrentContextList[i]->iEngineDatapath->iDecNodeSessionId, (OsclAny*)&iPendingCancelDueToCancelRequest));
+                    leavecode = IssueNodeCancelCommand(iCurrentContextList[i], iCurrentContextList[i]->iEngineDatapath->iDecNodeSessionId, (OsclAny*) & iNumberCancelCmdPending);
                     if (leavecode == 0)
                     {
-                        ++iPendingCancelDueToCancelRequest;
+                        ++iNumberCancelCmdPending;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() CancelAllCommands() on dec node did a leave"));
+                        FreeEngineContext(iCurrentContextList[i]);
                     }
                 }
                 else
@@ -3298,11 +3876,10 @@
             if (iCurrentContextList[i]->iEngineDatapath != NULL)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() Calling CancelAllCommands() on datapath"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, iCurrentContextList[i]->iDatapath->CancelCommand((OsclAny*)&iPendingCancelDueToCancelRequest));
+                leavecode = IssueDatapathCancelCommand(iCurrentContextList[i], (OsclAny*) & iNumberCancelCmdPending);
                 if (leavecode == 0)
                 {
-                    ++iPendingCancelDueToCancelRequest;
+                    ++iNumberCancelCmdPending;
                 }
             }
             else
@@ -3314,11 +3891,16 @@
         else if (iCurrentContextList[i]->iCmdType == PVP_CMD_QUERYSOURCEFORMATTYPE)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() Calling CancelAllCommands() on recognizer"));
-            leavecode = 0;
-            OSCL_TRY(leavecode, iPlayerRecognizerRegistry.CancelQuery((OsclAny*)&iPendingCancelDueToCancelRequest));
+            leavecode = IssueRecognizerRegistryCancel((OsclAny*) & iNumberCancelCmdPending);
             if (leavecode == 0)
             {
-                ++iPendingCancelDueToCancelRequest;
+                ++iNumberCancelCmdPending;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() CancelAllCommands() on recognizer node did a leave"));
+                FreeEngineContext(iCurrentContextList[i]);
             }
         }
         else
@@ -3329,205 +3911,24 @@
         }
     }
 
-    if (iPendingCancelDueToCancelRequest == 0)
+    if (iNumberCancelCmdPending == 0)
     {
-        // Cancel on the node failed so go to next step
+        // Cancel on the node / datapath failed so go to next step
+        // Note that we do not care about not being able to queue cancel since
+        // we are going to reset the components anyway
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() CancelAllCommands() on the node did a leave"));
         RemoveDatapathContextFromList(); // remove left-over datapath contexts
-        DoShutdownDueToCancel();
+        return PVMFSuccess;
     }
     else
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() %d CancelAllCommands are pending", iPendingCancelDueToCancelRequest));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() %d CancelAllCommands are pending", iNumberCancelCmdPending));
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelPendingNodeDatapathCommand() Out"));
+    return PVMFPending;
 }
 
-
-void PVPlayerEngine::DoShutdownDueToCancel()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoShutdownDueToCancel() In"));
-
-    // There should be a command to cancel
-    OSCL_ASSERT(iCmdToCancel.empty() == false);
-
-    switch (iCmdToCancel[0].GetCmdType())
-    {
-        case PVP_ENGINE_COMMAND_ADD_DATA_SOURCE:
-        case PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE:
-        case PVP_ENGINE_COMMAND_PREPARE:
-        case PVP_ENGINE_COMMAND_PAUSE:
-        case PVP_ENGINE_COMMAND_RESUME:
-        case PVP_ENGINE_COMMAND_STOP:
-            DoStopDueToCancel();
-            break;
-
-        case PVP_ENGINE_COMMAND_INIT:
-            DoResetDueToCancel();
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoShutdownDueToCancel() Unsupported command to cancel. Asserting"));
-            OSCL_ASSERT(false);
-            break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoShutdownDueToCancel() Out"));
-}
-
-
-void PVPlayerEngine::DoStopDueToCancel(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToCancel() In"));
-
-    int32 leavecode = 0;
-    iPendingStopDueToCancelRequest = 0;
-    if (iSourceNode)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToCancel() Calling Stop() on source node"));
-        leavecode = 0;
-        OSCL_TRY(leavecode, iSourceNode->Stop(iSourceNodeSessionId, &iPendingStopDueToCancelRequest));
-        if (!leavecode)
-        {
-            ++iPendingStopDueToCancelRequest;
-        }
-    }
-
-    // Go through each active datapath and stop the decoder and sink nodes
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        if (iDatapathList[i].iTrackActive)
-        {
-            if (iDatapathList[i].iDecNode)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToCancel() Calling Stop() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, iDatapathList[i].iDecNode->Stop(iDatapathList[i].iDecNodeSessionId, &iPendingStopDueToCancelRequest));
-                if (!leavecode)
-                {
-                    ++iPendingStopDueToCancelRequest;
-                }
-            }
-            if (iDatapathList[i].iSinkNode)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToCancel() Calling Stop() on sink node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, iDatapathList[i].iSinkNode->Stop(iDatapathList[i].iSinkNodeSessionId, &iPendingStopDueToCancelRequest));
-                if (!leavecode)
-                {
-                    ++iPendingStopDueToCancelRequest;
-                }
-            }
-        }
-    }
-
-    if (iPendingStopDueToCancelRequest == 0)
-    {
-        // All Stop() on the nodes failed so go to next step
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStopDueToCancel() All Stop() on the nodes did a leave"));
-        DoResetDueToCancel();
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStopDueToCancel() %d Stops are pending", iPendingStopDueToCancelRequest));
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToCancel() Out"));
-}
-
-
-void PVPlayerEngine::DoResetDueToCancel(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToCancel() In"));
-
-    int32 leavecode = 0;
-    iPendingResetDueToCancelRequest = 0;
-    if (iSourceNode)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToCancel() Calling Reset() on source node"));
-        leavecode = 0;
-        OSCL_TRY(leavecode, iSourceNode->Reset(iSourceNodeSessionId, &iPendingResetDueToCancelRequest));
-        if (!leavecode)
-        {
-            ++iPendingResetDueToCancelRequest;
-        }
-    }
-
-    // Go through each active datapath and reset the decoder and sink nodes
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        if (iDatapathList[i].iTrackActive)
-        {
-            if (iDatapathList[i].iDecNode)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToCancel() Calling Reset() on dec node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, iDatapathList[i].iDecNode->Reset(iDatapathList[i].iDecNodeSessionId, &iPendingResetDueToCancelRequest));
-                if (!leavecode)
-                {
-                    ++iPendingResetDueToCancelRequest;
-                }
-            }
-            if (iDatapathList[i].iSinkNode)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToCancel() Calling Reset() on sink node"));
-                leavecode = 0;
-                OSCL_TRY(leavecode, iDatapathList[i].iSinkNode->Reset(iDatapathList[i].iSinkNodeSessionId, &iPendingResetDueToCancelRequest));
-                if (!leavecode)
-                {
-                    ++iPendingResetDueToCancelRequest;
-                }
-            }
-        }
-    }
-
-    if (iPendingResetDueToCancelRequest == 0)
-    {
-        // All Reset() on the nodes failed so go to next step
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoResetDueToCancel() All Reset() on the nodes did a leave"));
-        DoCleanupDueToCancel();
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToCancel() %d Resets are pending", iPendingResetDueToCancelRequest));
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToCancel() Out"));
-}
-
-
-void PVPlayerEngine::DoCleanupDueToCancel(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCleanupDueToCancel() In"));
-
-    // Wipe everything out
-    iPollingCheckTimer->Clear();
-
-    // Clean up the datapaths
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        DoEngineDatapathCleanup(iDatapathList[i]);
-    }
-    iDatapathList.clear();
-
-    // Clean up the source node
-    DoSourceNodeCleanup();
-
-    while (!iCurrentContextList.empty())
-    {
-        FreeEngineContext(iCurrentContextList[0]);
-    }
-
-    SetEngineState(PVP_ENGINE_STATE_IDLE);
-
-    iCmdToCancel.clear();
-    EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), PVMFSuccess);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCleanupDueToCancel() Out"));
-}
-
-
 PVMFStatus PVPlayerEngine::DoGetSDKInfo(PVPlayerEngineCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetSDKInfo() In"));
@@ -3704,26 +4105,26 @@
     }
 
     int32 leavecode = 0;
-    PVMFStatus cmdstatus = PVMFSuccess;
 
     // For now just return all available extension interface UUID
-    // Capability and config interface
-    OSCL_TRY(leavecode,	uuidvec->push_back(PVMI_CAPABILITY_AND_CONFIG_PVUUID));
-    OSCL_FIRST_CATCH_ANY(leavecode, cmdstatus = PVMFErrNoMemory);
-
-    // License acquisition interface
-    OSCL_TRY(leavecode,	uuidvec->push_back(PVPlayerLicenseAcquisitionInterfaceUuid));
-    OSCL_FIRST_CATCH_ANY(leavecode, cmdstatus = PVMFErrNoMemory);
-
-    // Track level info interface from source node
-    if (iSourceNodeTrackLevelInfoIF && leavecode == 0)
-    {
-        leavecode = 0;
-        OSCL_TRY(leavecode, uuidvec->push_back(PVMF_TRACK_LEVEL_INFO_INTERFACE_UUID));
-        OSCL_FIRST_CATCH_ANY(leavecode, cmdstatus = PVMFErrNoMemory);
+    OSCL_TRY(leavecode,
+             // Capability and config interface
+             uuidvec->push_back(PVMI_CAPABILITY_AND_CONFIG_PVUUID);
+             // License acquisition interface
+             uuidvec->push_back(PVPlayerLicenseAcquisitionInterfaceUuid);
+             // Track level info interface from source node
+             if (iSourceNodeTrackLevelInfoIF)
+{
+    uuidvec->push_back(PVMF_TRACK_LEVEL_INFO_INTERFACE_UUID);
     }
+            );
+    OSCL_FIRST_CATCH_ANY(leavecode,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryUUID() Leaved"));
+                         EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFErrNoMemory);
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoQueryUUID() Out"));
+                         return PVMFSuccess;);
 
-    EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), cmdstatus);
+    EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoQueryUUID() Out"));
     return PVMFSuccess;
@@ -3804,7 +4205,7 @@
 
     // Save the data source
     iDataSource = (PVPlayerDataSource*)(aCmd.GetParam(0).pOsclAny_value);
-    iDataSourcePS = (PVPlayerDataSourcePacketSource*)(aCmd.GetParam(0).pOsclAny_value);
+
     // (mg) For rollover reset to first available alternate
     iAlternateSrcFormatIndex = 0;
     iDataReadySent = false;
@@ -3813,13 +4214,13 @@
     PVMFStatus retval = PVMFSuccess;
     iSourceFormatType = iDataSource->GetDataSourceFormatType();
 
-    if (iSourceFormatType == PVMF_FORMAT_UNKNOWN)
+    if (iSourceFormatType == PVMF_MIME_FORMAT_UNKNOWN)
     {
         retval = DoQuerySourceFormatType(aCmd.GetCmdId(), aCmd.GetContext());
     }
     else
     {
-        if (iSourceFormatType == PVMF_DATA_SOURCE_UNKNOWN_URL)
+        if (iSourceFormatType == PVMF_MIME_DATA_SOURCE_UNKNOWN_URL)
         {
             retval = SetupDataSourceForUnknownURLAccess();
             if (retval != PVMFSuccess)
@@ -3834,9 +4235,19 @@
 
         if (retval != PVMFSuccess)
         {
-            // Do cleanup
-            DoSourceNodeCleanup();
-            iDataSource = NULL;
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAddDataSource() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            // Queue up Error Handling
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAddDataSource() DoSetupSourceNode failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = retval;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE, NULL, NULL, NULL, false);
+            return PVMFPending;
         }
     }
 
@@ -3858,11 +4269,40 @@
     PVPlayerEngineContext* context = AllocateEngineContext(NULL, NULL, NULL, aCmdId, aCmdContext, PVP_CMD_QUERYSOURCEFORMATTYPE);
     PVMFStatus retval = PVMFSuccess;
     int32 leavecode = 0;
-    OSCL_TRY(leavecode, retval = iPlayerRecognizerRegistry.QueryFormatType(iDataSource->GetDataSourceURL(), *this, (OsclAny*) context));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         FreeEngineContext(context);
-                         return PVMFErrNotSupported;
-                        );
+
+    OsclAny * opaqueData = iDataSource->GetDataSourceContextData();
+    PVInterface* pvInterface = OSCL_STATIC_CAST(PVInterface*, opaqueData);
+    PVInterface* SourceContextData = NULL;
+    PVUuid SourceContextDataUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
+    PVMFCPMPluginAccessInterfaceFactory * DataStreamDataFactory = NULL;
+
+    if (pvInterface != NULL && pvInterface->queryInterface(SourceContextDataUuid, SourceContextData))
+    {
+        PVMFSourceContextData * aSourceContextData = OSCL_STATIC_CAST(PVMFSourceContextData*, SourceContextData);
+        PVMFSourceContextDataCommon * aSourceContextDataCommon = aSourceContextData->CommonData();
+        if (aSourceContextDataCommon)
+        {
+            DataStreamDataFactory = aSourceContextDataCommon->iRecognizerDataStreamFactory;
+        }
+    }
+
+    if (DataStreamDataFactory)
+    {
+        OSCL_TRY(leavecode, retval = iPlayerRecognizerRegistry.QueryFormatType(DataStreamDataFactory, *this, (OsclAny*) context));
+        OSCL_FIRST_CATCH_ANY(leavecode,
+                             FreeEngineContext(context);
+                             return PVMFErrNotSupported;
+                            );
+    }
+    else
+    {
+        OSCL_TRY(leavecode, retval = iPlayerRecognizerRegistry.QueryFormatType(iDataSource->GetDataSourceURL(), *this, (OsclAny*) context));
+        OSCL_FIRST_CATCH_ANY(leavecode,
+                             FreeEngineContext(context);
+                             return PVMFErrNotSupported;
+                            );
+    }
+
     if (retval != PVMFSuccess)
     {
         FreeEngineContext(context);
@@ -3884,7 +4324,7 @@
 
     if (iSourceNode == NULL)
     {
-        PVMFFormatType outputformattype = PVMF_FORMAT_UNKNOWN ;
+        PVMFFormatType outputformattype = PVMF_MIME_FORMAT_UNKNOWN ;
 
         Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
         // Query the node registry
@@ -3893,7 +4333,8 @@
             if (foundUuids.empty())
             {
                 // No matching node found
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSourceNode() No matching source node found"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::DoSetupSourceNode() Query Regsitry successful, No matching source node found."));
                 return PVMFErrNotSupported;
             }
 
@@ -3922,6 +4363,7 @@
     if (iSourceNode->ThreadLogon() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSourceNode() ThreadLogon() on the source node failed"));
+        OSCL_ASSERT(false);
         return PVMFFailure;
     }
 
@@ -3930,6 +4372,7 @@
     OSCL_TRY(leavecode, iSourceNodeSessionId = iSourceNode->Connect(nodesessioninfo));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSourceNode() Connect on iSourceNode did a leave!"));
+                         OSCL_ASSERT(false);
                          return PVMFFailure);
 
     PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeQueryInitIF);
@@ -3937,8 +4380,10 @@
     PVUuid sourceinituuid = PVMF_DATA_SOURCE_INIT_INTERFACE_UUID;
     leavecode = 0;
     PVMFCommandId cmdid = -1;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, sourceinituuid, (PVInterface*&)iSourceNodeInitIF, (OsclAny*)context));
+    iSourceNodePVInterfaceInit = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, sourceinituuid, iSourceNodePVInterfaceInit, (OsclAny*)context));
     OSCL_FIRST_CATCH_ANY(leavecode,
+                         iSourceNodePVInterfaceInit = NULL;
                          FreeEngineContext(context);
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSourceNode() QueryInterface on iSourceNode did a leave!"));
                          return PVMFFailure);
@@ -3960,13 +4405,13 @@
     if (iDataSource->GetDataSourceType() == PVP_DATASRCTYPE_URL)
     {
         // Setup the source node via the initialization IF
-        OSCL_ASSERT(iSourceFormatType != PVMF_FORMAT_UNKNOWN);
+        OSCL_ASSERT(iSourceFormatType != PVMF_MIME_FORMAT_UNKNOWN);
 
         OSCL_wHeapString<OsclMemAllocator> sourceURL;
         // In case the URL starts with file:// skip it
         OSCL_wStackString<8> fileScheme(_STRLIT_WCHAR("file"));
         OSCL_wStackString<8> schemeDelimiter(_STRLIT_WCHAR("://"));
-        oscl_wchar* actualURL = NULL;
+        const oscl_wchar* actualURL = NULL;
 
         if (oscl_strncmp(fileScheme.get_cstr(), iDataSource->GetDataSourceURL().get_cstr(), 4) == 0)
         {
@@ -3989,14 +4434,14 @@
         if (retval != PVMFSuccess)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryTrackSelIF() SetSourceInitializationData failed"));
-            return retval;
+            return PVMFFailure;
         }
         // Set Playback Clock
         retval = iSourceNodeInitIF->SetClientPlayBackClock(&iPlaybackClock);
         if (retval != PVMFSuccess)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryTrackSelIF() SetClientPlayBackClock failed!"));
-            return retval;
+            return PVMFFailure;
         }
     }
     else
@@ -4012,8 +4457,10 @@
     PVUuid trackseluuid = PVMF_TRACK_SELECTION_INTERFACE_UUID;
     PVMFCommandId cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, trackseluuid, (PVInterface*&)iSourceNodeTrackSelIF, (OsclAny*)context));
+    iSourceNodePVInterfaceTrackSel = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, trackseluuid, iSourceNodePVInterfaceTrackSel, (OsclAny*)context));
     OSCL_FIRST_CATCH_ANY(leavecode,
+                         iSourceNodePVInterfaceTrackSel = NULL;
                          FreeEngineContext(context);
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryTrackSelIF() QueryInterface on iSourceNode did a leave!"));
                          return PVMFFailure);
@@ -4041,9 +4488,11 @@
     PVUuid tracklevelinfouuid = PVMF_TRACK_LEVEL_INFO_INTERFACE_UUID;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, tracklevelinfouuid, (PVInterface*&)iSourceNodeTrackLevelInfoIF, (OsclAny*)context));
+    iSourceNodePVInterfaceTrackLevelInfo = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, tracklevelinfouuid, iSourceNodePVInterfaceTrackLevelInfo, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfaceTrackLevelInfo = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4058,9 +4507,11 @@
     PVUuid pbctrluuid = PvmfDataSourcePlaybackControlUuid;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, pbctrluuid, (PVInterface*&)iSourceNodePBCtrlIF, (OsclAny*)context));
+    iSourceNodePVInterfacePBCtrl = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, pbctrluuid, iSourceNodePVInterfacePBCtrl, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfacePBCtrl = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4075,9 +4526,11 @@
     PVUuid dirctrluuid = PvmfDataSourceDirectionControlUuid;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, dirctrluuid, (PVInterface*&)iSourceNodeDirCtrlIF, (OsclAny*)context));
+    iSourceNodePVInterfaceDirCtrl = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, dirctrluuid, iSourceNodePVInterfaceDirCtrl, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfaceDirCtrl = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4092,9 +4545,11 @@
     PVUuid metadatauuid = KPVMFMetadataExtensionUuid;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, metadatauuid, (PVInterface*&)iSourceNodeMetadataExtIF, (OsclAny*)context));
+    iSourceNodePVInterfaceMetadataExt = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, metadatauuid, iSourceNodePVInterfaceMetadataExt, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfaceMetadataExt = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4109,9 +4564,11 @@
     PVUuid capconfiguuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, capconfiguuid, (PVInterface*&)iSourceNodeCapConfigIF, (OsclAny*)context));
+    iSourceNodePVInterfaceCapConfig = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, capconfiguuid, iSourceNodePVInterfaceCapConfig, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfaceCapConfig = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4126,9 +4583,11 @@
     PVUuid licUuid = PVMFCPMPluginLicenseInterfaceUuid;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, licUuid, (PVInterface*&)iSourceNodeCPMLicenseIF, (OsclAny*)context));
+    iSourceNodePVInterfaceCPMLicense = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, licUuid, iSourceNodePVInterfaceCPMLicense, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfaceCPMLicense = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4143,9 +4602,11 @@
     PVUuid regInitUuid = PVMF_DATA_SOURCE_NODE_REGISRTY_INIT_INTERFACE_UUID;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, regInitUuid, (PVInterface*&)iSourceNodeRegInitIF, (OsclAny*)context));
+    iSourceNodePVInterfaceRegInit = NULL;
+    OSCL_TRY(leavecode, cmdid = iSourceNode->QueryInterface(iSourceNodeSessionId, regInitUuid, iSourceNodePVInterfaceRegInit, (OsclAny*)context));
     if (leavecode)
     {
+        iSourceNodePVInterfaceRegInit = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryInterfaceOptional() QueryInterface on iSourceNode did a leave!"));
     }
@@ -4165,56 +4626,6 @@
     }
 }
 
-
-PVMFStatus PVPlayerEngine::DoAddDataSourceFailureComplete(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoAddDataSourceFailureComplete() In"));
-
-    // Cleanup the source node since AddDataSource failed
-    DoSourceNodeCleanup();
-    iDataSource = NULL;
-
-    // Send the command completion
-    if (iCommandCompleteInEngineAOErrMsg)
-    {
-        EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), iCommandCompleteInEngineAOCmdStatus, OSCL_STATIC_CAST(PVInterface*, iCommandCompleteInEngineAOErrMsg));
-        iCommandCompleteInEngineAOErrMsg->removeRef();
-        iCommandCompleteInEngineAOErrMsg = NULL;
-    }
-    else
-    {
-        EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), iCommandCompleteInEngineAOCmdStatus);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoAddDataSourceFailureComplete() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PVPlayerEngine::DoInitFailureComplete(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoInitFailureComplete() In"));
-
-    // Cleanup the source node since AddDataSource failed
-    DoSourceNodeCleanup();
-    iDataSource = NULL;
-
-    // Send the command completion
-    if (iCommandCompleteInEngineAOErrMsg)
-    {
-        EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), iCommandCompleteInEngineAOCmdStatus, OSCL_STATIC_CAST(PVInterface*, iCommandCompleteInEngineAOErrMsg));
-        iCommandCompleteInEngineAOErrMsg->removeRef();
-        iCommandCompleteInEngineAOErrMsg = NULL;
-    }
-    else
-    {
-        EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), iCommandCompleteInEngineAOCmdStatus);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoInitFailureComplete() Out"));
-    return PVMFSuccess;
-}
-
-
 PVMFStatus PVPlayerEngine::DoGetMetadataKey(PVPlayerEngineCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_NOTICE,
@@ -4275,21 +4686,22 @@
     }
 
     // Retrieve the metadata key from the first node
-    PVPlayerEngineContext* context = AllocateEngineContext(NULL, NULL, NULL, aCmd.GetCmdId(), aCmd.GetContext(), PVP_CMD_GetNodeMetadataKey);
+    PVPlayerEngineContext* context = AllocateEngineContext(iMetadataIFList[i].iEngineDatapath, iMetadataIFList[i].iNode, NULL, aCmd.GetCmdId(), aCmd.GetContext(), PVP_CMD_GetNodeMetadataKey);
     PVMFMetadataExtensionInterface* metadataif = iMetadataIFList[i].iInterface;
     PVMFSessionId sessionid = iMetadataIFList[i].iSessionId;
-    int32 leavecode = 0;
     PVMFCommandId cmdid = -1;
-    OSCL_TRY(leavecode, cmdid = metadataif->GetNodeMetadataKeys(sessionid,
-                                *(iGetMetadataKeysParam.iKeyList),
-                                nodestartindex,
-                                iGetMetadataKeysParam.iMaxKeyEntries,
-                                iGetMetadataKeysParam.iQueryKey,
-                                (OsclAny*)context));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         FreeEngineContext(context);
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetMetadataKey() GetNodeMetadataKeys on a node did a leave!"));
-                         return PVMFFailure);
+    cmdid = metadataif->GetNodeMetadataKeys(sessionid,
+                                            *(iGetMetadataKeysParam.iKeyList),
+                                            nodestartindex,
+                                            iGetMetadataKeysParam.iMaxKeyEntries,
+                                            iGetMetadataKeysParam.iQueryKey,
+                                            (OsclAny*)context);
+    if (cmdid == -1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::DoGetMetadataKey() GetNodeMetadataKeys failed"));
+        return PVMFFailure;
+    }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetMetadataKey() Out"));
 
@@ -4315,11 +4727,21 @@
         return PVMFErrInvalidState;
     }
 
+    if (iReleaseMetadataValuesPending)
+    {
+        // App has called GetMetadataValues without calling ReleaseMetadata values on previous list. Wrong
+        // usage. Failure needs to be returned in this case.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::GetMetadataValues() Wrong usage, called again without releasing earlier metadata list"));
+        return PVMFErrReleaseMetadataValueNotDone;
+    }
+
     iGetMetadataValuesParam.iKeyList = (PVPMetadataList*)(aCmd.GetParam(0).pOsclAny_value);
     iGetMetadataValuesParam.iStartingValueIndex = aCmd.GetParam(1).int32_value;
     iGetMetadataValuesParam.iMaxValueEntries = aCmd.GetParam(2).int32_value;
     iGetMetadataValuesParam.iNumAvailableValues = (int32*)(aCmd.GetParam(3).pOsclAny_value);
     iGetMetadataValuesParam.iValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)(aCmd.GetParam(4).pOsclAny_value);
+    iMetadataValuesCopiedInCallBack = aCmd.GetParam(5).bool_value;
 
     if (iGetMetadataValuesParam.iKeyList == NULL || iGetMetadataValuesParam.iValueList == NULL || iGetMetadataValuesParam.iNumAvailableValues == NULL)
     {
@@ -4365,21 +4787,23 @@
     }
 
     // Retrieve the metadata value from the first node
-    PVPlayerEngineContext* context = AllocateEngineContext(NULL, NULL, NULL, aCmd.GetCmdId(), aCmd.GetContext(), PVP_CMD_GetNodeMetadataValue);
+    PVPlayerEngineContext* context = AllocateEngineContext(iMetadataIFList[i].iEngineDatapath, iMetadataIFList[i].iNode, NULL, aCmd.GetCmdId(), aCmd.GetContext(), PVP_CMD_GetNodeMetadataValue);
     PVMFMetadataExtensionInterface* metadataif = iMetadataIFList[i].iInterface;
     PVMFSessionId sessionid = iMetadataIFList[i].iSessionId;
-    int32 leavecode = 0;
     PVMFCommandId cmdid = -1;
-    OSCL_TRY(leavecode, cmdid = metadataif->GetNodeMetadataValues(sessionid,
-                                *(iGetMetadataValuesParam.iKeyList),
-                                *(iGetMetadataValuesParam.iValueList),
-                                nodestartindex,
-                                iGetMetadataValuesParam.iMaxValueEntries,
-                                (OsclAny*)context));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         FreeEngineContext(context);
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetMetadataValue() GetNodeMetadataValues on a node did a leave!"));
-                         return PVMFFailure);
+    cmdid = metadataif->GetNodeMetadataValues(sessionid,
+            *(iGetMetadataValuesParam.iKeyList),
+            *(iGetMetadataValuesParam.iValueList),
+            nodestartindex,
+            iGetMetadataValuesParam.iMaxValueEntries,
+            (OsclAny*)context);
+
+    if (cmdid == -1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::DoGetMetadataValue() GetNodeMetadataValues failed"));
+        return PVMFFailure;
+    }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetMetadataValue() Out"));
 
@@ -4391,6 +4815,43 @@
     return PVMFSuccess;
 }
 
+PVMFStatus PVPlayerEngine::DoReleaseMetadataValues(PVPlayerEngineCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_NOTICE,
+                    (0, "PVPlayerEngine::DoReleaseMetadataValues() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoReleaseMetadataValues() In"));
+
+    if (GetPVPlayerState() == PVP_STATE_ERROR ||
+            GetPVPlayerState() == PVP_STATE_IDLE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReleaseMetadataValues() Wrong engine state"));
+        return PVMFErrInvalidState;
+    }
+
+    iGetMetadataValuesParam.iValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)(aCmd.GetParam(0).pOsclAny_value);
+
+    if (iGetMetadataValuesParam.iValueList == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReleaseMetadataValues() Passed in parameter invalid."));
+        return PVMFErrArgument;
+    }
+
+    // Release the memory allocated for the metadata values
+    while (iMetadataValueReleaseList.empty() == false)
+    {
+        PVMFMetadataExtensionInterface* mdif = iMetadataIFList[iMetadataValueReleaseList[0].iMetadataIFListIndex].iInterface;
+        OSCL_ASSERT(mdif != NULL);
+        mdif->ReleaseNodeMetadataValues(*(iGetMetadataValuesParam.iValueList), iMetadataValueReleaseList[0].iStartIndex, iMetadataValueReleaseList[0].iEndIndex);
+        iMetadataValueReleaseList.erase(iMetadataValueReleaseList.begin());
+    }
+
+    iReleaseMetadataValuesPending = false;
+
+    EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+
+    return PVMFSuccess;
+}
 
 PVMFStatus PVPlayerEngine::DoInit(PVPlayerEngineCommand& aCmd)
 {
@@ -4399,7 +4860,12 @@
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoInit() In"));
 
-    iRollOverState = RollOverStateIdle;
+    if (GetPVPlayerState() == PVP_STATE_INITIALIZED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoInit() Engine already in Initialized State"));
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+        return PVMFSuccess;
+    }
 
     if ((GetPVPlayerState() != PVP_STATE_IDLE) || (iSourceNode == NULL))
     {
@@ -4407,6 +4873,8 @@
         return PVMFErrInvalidState;
     }
 
+    iRollOverState = RollOverStateIdle;
+
     PVMFStatus retval = DoSourceNodeInit(aCmd.GetCmdId(), aCmd.GetContext());
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoInit() Out"));
@@ -4418,7 +4886,18 @@
     }
     else
     {
-        return retval;
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoInit() Already EH pending, should never happen"));
+            return PVMFPending;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoInit() DoSourceNodeInit failed, Add EH command"));
+        iCommandCompleteStatusInErrorHandling = retval;
+        iCommandCompleteErrMsgInErrorHandling = NULL;
+        AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
+        return PVMFPending;
     }
 }
 
@@ -4511,55 +4990,20 @@
 
             iAlternateSrcFormatIndex++;
             PVMFStatus status = DoSetupSourceNode(aCmdId, aCmdContext);
-            if (status == PVMFSuccess)
+            if (status != PVMFSuccess)
             {
-                //roll over pending
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeRollOver() SourceNodeRollOver In Progress"));
-                return PVMFPending;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeRollOver() SourceNodeRollOver Failed, return status"));
+                return status;
             }
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeRollOver() SourceNodeRollOver Failed"));
-            return status;
+            //roll over pending
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeRollOver() SourceNodeRollOver In Progress"));
+            return PVMFPending;
         }
     }
     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeRollOver() Invalid State"));
     return PVMFErrInvalidState;
 }
 
-PVMFStatus PVPlayerEngine::DoSourceNodeGetDlaData(PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeGetDlaData() In"));
-
-    // Create a key list with just duration key
-    iDlaDataKeyList.clear();
-    OSCL_HeapString<OsclMemAllocator> tmpstr = _STRLIT_CHAR("drm/dla-data");
-    iDlaDataKeyList.push_back(tmpstr);
-    // Clear the value list
-    iDlaDataValueList.clear();
-
-    if (iSourceNodeMetadataExtIF == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    // Call GetNodeMetadataValues on the source node to retrieve duration
-    PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeGetDlaData);
-
-    int32 leavecode = 0;
-    PVMFCommandId cmdid = -1;
-    OSCL_TRY(leavecode, cmdid = iSourceNodeMetadataExtIF->GetNodeMetadataValues(iSourceNodeSessionId,
-                                iDlaDataKeyList,
-                                iDlaDataValueList,
-                                0 /*starting index*/, 1 /*max entries*/, (OsclAny*)context));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         FreeEngineContext(context);
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeGetDlaData() GetNodeMetadataValues on iSourceNode did a leave!"));
-                         return PVMFFailure);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeGetDlaData() Out"));
-    return PVMFSuccess;
-}
-
-
 PVMFStatus PVPlayerEngine::DoAcquireLicense(PVPlayerEngineCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_NOTICE,
@@ -4630,18 +5074,12 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() DoSourceNodeGetLicense failed."));
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoAcquireLicense() Out"));
-        return PVMFSuccess;
+        return status;
     }
 
-    //Before getting license we need to get the dla-data blob from the source node
-    //to pass to the new plugin instance.
-    PVMFStatus status = DoSourceNodeGetDlaData(aCmd.GetCmdId(), aCmd.GetContext());
-    if (status != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() DoSourceNodeGetDlaData failed."));
-    }
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoAcquireLicense() Out"));
-    return status;
+    // if the license interface is not available from the source node, fail the command
+    return PVMFFailure;
 }
 
 void PVPlayerEngine::DoCancelAcquireLicense(PVPlayerEngineCommand& aCmd)
@@ -4729,122 +5167,6 @@
     return;
 }
 
-PVMFStatus PVPlayerEngine::DoGetPluginLicenseIF()
-{
-    //create & use a plug-in instance.
-    // Retrieve the CPM plug-in instance from the registry
-    if (iDataSource->GetDataSourceContextData() != NULL)
-    {
-        PVInterface* pvInterface =
-            OSCL_STATIC_CAST(PVInterface*, iDataSource->GetDataSourceContextData());
-        PVInterface* localDataSrc = NULL;
-        PVUuid localDataSrcUuid(PVMF_LOCAL_DATASOURCE_UUID);
-        if (pvInterface->queryInterface(localDataSrcUuid, localDataSrc))
-        {
-            PVMFLocalDataSource* opaqueData =
-                OSCL_STATIC_CAST(PVMFLocalDataSource*, localDataSrc);
-            if (opaqueData->iUseCPMPluginRegistry == false)
-            {
-                // CPM plug-in registry not available in the local data source
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() CPM plug-in registry in local data source not specified."));
-                return PVMFErrBadHandle;
-            }
-        }
-        else
-        {
-            PVInterface* sourceDataContext = NULL;
-            PVInterface* commonDataContext = NULL;
-            PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
-            PVUuid commonContextUuid(PVMF_SOURCE_CONTEXT_DATA_COMMON_UUID);
-            if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
-            {
-                if (sourceDataContext->queryInterface(commonContextUuid, commonDataContext))
-                {
-                    PVMFSourceContextDataCommon* cContext =
-                        OSCL_STATIC_CAST(PVMFSourceContextDataCommon*, commonDataContext);
-                    if (cContext->iUseCPMPluginRegistry == false)
-                    {
-                        // CPM plug-in registry not available in the local data source
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() CPM plug-in registry in local data source not specified."));
-                        return PVMFErrBadHandle;
-                    }
-                }
-            }
-        }
-    }
-    //Lookup the factory for the janus plugin
-    {
-        //Connect to registry
-        OsclRegistryAccessClient cli;
-        if (cli.Connect() != OsclErrNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() Can't connect to plugin registry."));
-            return PVMFFailure;
-        }
-
-        OSCL_StackString<32> janusmimestr("X-CPM-PLUGIN/PV-WMDRM-JANUS");
-        iCPMPluginFactory = cli.GetFactory(janusmimestr);
-
-        if (iCPMPluginFactory)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoAcquireLicense() Using Janus Plug-in."));
-        }
-        else
-        {
-            OSCL_StackString<34> jupitermimestr("X-CPM-PLUGIN/PV-WMDRM-JUPITER");
-            iCPMPluginFactory = cli.GetFactory(jupitermimestr);
-            if (iCPMPluginFactory)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoAcquireLicense() Using Jupiter Plug-in."));
-            }
-        }
-
-        //Close registry session.
-        cli.Close();
-    }
-
-    if (iCPMPluginFactory == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() Can't find Janus plugin factory."));
-        return PVMFFailure;
-    }
-
-    //Create an instance of the plugin.
-    iCPMPlugin = ((PVMFCPMPluginFactory*)iCPMPluginFactory)->CreateCPMPlugin();
-    if (!iCPMPlugin)
-    {
-        // Specified CPM plug-in is not available in the registry
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() Can't create janus plugin."));
-        return PVMFFailure;
-    }
-
-    int32 leavecode = 0;
-
-    // Create a session to the CPM plug-in
-    OSCL_TRY(leavecode, iCPMPluginSessionId = iCPMPlugin->Connect(*this));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() Connect to the plug-in did a leave!"));
-                         ((PVMFCPMPluginFactory*)iCPMPluginFactory)->DestroyCPMPlugin(iCPMPlugin);
-                         iCPMPlugin = NULL;
-                         iCPMPluginFactory = NULL;
-                         return PVMFErrResource;);
-
-    // Query for the license extension IF
-    leavecode = 0;
-    OSCL_TRY(leavecode, iCPMPlugin->QueryInterface(iCPMPluginSessionId, PVMFCPMPluginLicenseInterfaceUuid, (PVInterface*&)iCPMPluginLicenseIF, NULL));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAcquireLicense() QueryInterface to the plug-in did a leave!"));
-                         iCPMPlugin->Disconnect(iCPMPluginSessionId);
-                         ((PVMFCPMPluginFactory*)iCPMPluginFactory)->DestroyCPMPlugin(iCPMPlugin);
-                         iCPMPlugin = NULL;
-                         iCPMPluginFactory = NULL;
-                         return PVMFErrResource;);
-
-    iCPMPluginCommand = PVP_CMD_CPMQueryLicenseIF;
-
-    return PVMFSuccess;
-}
-
 PVMFStatus PVPlayerEngine::DoSourceNodeGetLicense(PVCommandId aCmdId, OsclAny* aCmdContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
@@ -4915,152 +5237,6 @@
     return PVMFSuccess;
 }
 
-PVMFStatus PVPlayerEngine::DoCPMPluginSetUserAgentHeader(PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    OSCL_UNUSED_ARG(aCmdId);
-    OSCL_UNUSED_ARG(aCmdContext);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCPMPluginSetUserAgentHeader() In"));
-
-    if (iCPMPluginCapConfigIf == NULL)
-    {
-        OSCL_ASSERT(false);
-        return PVMFErrBadHandle;
-    }
-
-    //set the parameter
-    OSCL_StackString<64> userAgentheaderKey(_STRLIT_CHAR("x-pvmf/net/user-agent"));
-
-    PvmiKvp *retKVP;
-
-    /*Search for user-agent key in the vector*/
-    for (uint32 i = 0;i < iPvmiKvpCapNConfig.size();i++)
-    {
-        if (oscl_strstr(iPvmiKvpCapNConfig[i]->key, userAgentheaderKey.get_cstr()))
-        {
-            iCPMPluginCapConfigIf->setParametersSync(NULL, iPvmiKvpCapNConfig[i], 1, retKVP);
-
-            //log if error
-            if (retKVP)
-            {
-                //log error
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCPMPluginSetUserAgentHeader() user-agent parameter could not be set in CPM"));
-            }
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCPMPluginSetUserAgentHeader() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PVPlayerEngine::DoCPMPluginGetLicense(PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
-                    (0, "PVPlayerEngine::DoCPMPluginGetLicense() Tick=%d", OsclTickCount::TickCount()));
-
-    OSCL_UNUSED_ARG(aCmdId);
-    OSCL_UNUSED_ARG(aCmdContext);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCPMPluginGetLicense() In"));
-
-    if (iCPMPluginLicenseIF == NULL)
-    {
-        OSCL_ASSERT(false);
-        return PVMFErrBadHandle;
-    }
-
-    // Get the license
-    int32 leavecode = 0;
-    if (iCPMAcquireLicenseParam.iContentNameChar)
-    {
-        // Use the char version
-        iCPMContentNameStr = iCPMAcquireLicenseParam.iContentNameChar;
-        OSCL_TRY(leavecode, iCPMPluginLicenseIF->GetLicense(iCPMPluginSessionId,
-                 iCPMContentNameStr,
-                 iCPMAcquireLicenseParam.iLicenseData,
-                 iCPMAcquireLicenseParam.iLicenseDataSize,
-                 iCPMAcquireLicenseParam.iTimeoutMsec));
-    }
-    else if (iCPMAcquireLicenseParam.iContentNameWChar)
-    {
-        // Use the wchar version
-        iCPMContentNameWStr = iCPMAcquireLicenseParam.iContentNameWChar;
-        OSCL_TRY(leavecode, iCPMPluginLicenseIF->GetLicense(iCPMPluginSessionId,
-                 iCPMContentNameWStr,
-                 iCPMAcquireLicenseParam.iLicenseData,
-                 iCPMAcquireLicenseParam.iLicenseDataSize,
-                 iCPMAcquireLicenseParam.iTimeoutMsec));
-    }
-    else
-    {
-        // This should not happen
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCPMPluginGetLicense() Content name not specified. Asserting"));
-        OSCL_ASSERT(false);
-        return PVMFErrArgument;
-    }
-
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCPMPluginGetLicense() GetLicense to the plug-in's license interface did a leave!"));
-                         return PVMFErrResource;);
-    iCPMPluginCommand = PVP_CMD_CPMGetLicense;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCPMPluginGetLicense() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVPlayerEngine::DoCPMPluginAcquireLicenseComplete()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
-                    (0, "PVPlayerEngine::DoCPMPluginAcquireLicenseComplete() Tick=%d", OsclTickCount::TickCount()));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCPMPluginAcquireLicenseComplete() In"));
-
-    // Close the CPM plug-in session and reset variables
-    if (iCPMPluginLicenseIF)
-    {
-        iCPMPluginLicenseIF->removeRef();
-        iCPMPluginLicenseIF = NULL;
-    }
-
-    iCPMPluginCapConfigIf = NULL;
-
-    // Destroy the plugin instance that we created.
-    if (iCPMPlugin)
-    {
-        // Trap any leave but no need to handle it other than report it
-        int32 leavecode = 0;
-        OSCL_TRY(leavecode, iCPMPlugin->Disconnect(iCPMPluginSessionId));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCPMPluginAcquireLicenseComplete() Disconnect on CPM plugin did a leave. Asserting."));
-                             OSCL_ASSERT(false);
-                            );
-
-        ((PVMFCPMPluginFactory*)iCPMPluginFactory)->DestroyCPMPlugin(iCPMPlugin);
-    }
-
-    iCPMPlugin = NULL;
-    iCPMPluginFactory = NULL;
-    iCPMPluginSessionId = 0;
-    iCPMPluginCommand = -1;
-
-    // Send the command completion
-    if (iCommandCompleteInEngineAOErrMsg)
-    {
-        EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), iCommandCompleteInEngineAOCmdStatus, OSCL_STATIC_CAST(PVInterface*, iCommandCompleteInEngineAOErrMsg));
-        iCommandCompleteInEngineAOErrMsg->removeRef();
-        iCommandCompleteInEngineAOErrMsg = NULL;
-    }
-    else
-    {
-        EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), iCommandCompleteInEngineAOCmdStatus);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCPMPluginAcquireLicenseComplete() Out"));
-    return PVMFSuccess;
-}
-
-
 PVMFStatus PVPlayerEngine::DoAddDataSink(PVPlayerEngineCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_NOTICE,
@@ -5068,6 +5244,12 @@
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoAddDataSink() In"));
 
+    if (GetPVPlayerState() != PVP_STATE_INITIALIZED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAddDataSink() Wrong engine state"));
+        return PVMFErrInvalidState;
+    }
+
     if (aCmd.GetParam(0).pOsclAny_value == NULL)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAddDataSink() Passed in parameter invalid."));
@@ -5079,34 +5261,8 @@
     PVPlayerEngineDatapath newdatapath;
     newdatapath.iDataSink = datasink;
 
-    // Determine the data sink's media type
-    switch (GetMediaTypeIndex(datasink->GetDataSinkFormatType()))
-    {
-        case PVMF_UNCOMPRESSED_VIDEO_FORMAT:
-        case PVMF_COMPRESSED_VIDEO_FORMAT:
-            newdatapath.iMediaType = PVP_MEDIATYPE_VIDEO;
-            break;
-
-        case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-        case PVMF_COMPRESSED_AUDIO_FORMAT:
-            newdatapath.iMediaType = PVP_MEDIATYPE_AUDIO;
-            break;
-
-        case PVMF_TEXT_FORMAT:
-            newdatapath.iMediaType = PVP_MEDIATYPE_TEXT;
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAddDataSink() Unknown format. Cannot determine sink's media type"));
-            return PVMFErrNotSupported;
-    }
-
     // Add a new engine datapath to the list for the data sink
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iDatapathList.push_front(newdatapath));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoAddDataSink() New datapath could not be added to iDatapathList"));
-                         return PVMFErrNoMemory);
+    iDatapathList.push_back(newdatapath);
 
     EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
 
@@ -5124,17 +5280,6 @@
 
     PVMFStatus retval;
 
-    if (iWatchDogTimer != NULL)
-    {
-        if (iWatchDogTimer->IsBusy())
-        {
-            iWatchDogTimer->Cancel();
-        }
-    }
-    iNumPendingSkipCompleteEvent = 0;
-    iNumPVMFInfoStartOfDataPending = 0;
-    iStreamID++;
-
     if (GetPVPlayerState() == PVP_STATE_ERROR)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetPlaybackRange() Wrong engine state"));
@@ -5149,6 +5294,7 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetPlaybackRange() Queued playback range is not supported yet"));
         return PVMFErrNotSupported;
 #else
+        // @TODO Validation on the queued start/stop positions
         iQueuedRangePresent = true;
         iQueuedStartPosition = aCmd.GetParam(0).playbackpos_value;
         iQueuedStopPosition = aCmd.GetParam(1).playbackpos_value;
@@ -5173,11 +5319,16 @@
         return PVMFSuccess;
     }
 
+    // reset repos related variables except the StreamID.
+    ResetReposVariables(false);
+    iStreamID++;
+
     // Reset the paused-due-to-EOS flag
     iPlaybackPausedDueToEndOfClip = false;
 
     // Change the begin position
     iCurrentBeginPosition = aCmd.GetParam(0).playbackpos_value;
+    iTargetNPT = iCurrentBeginPosition.iPosValue.millisec_value;
     retval = UpdateCurrentBeginPosition(iCurrentBeginPosition, aCmd);
 
     if (retval == PVMFSuccess)
@@ -5269,16 +5420,6 @@
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::UpdateCurrentBeginPosition() Converting to millisec failed"));
                 return retval;
             }
-            if (aBeginPos.iPosUnit == PVPPBPOSUNIT_PLAYLIST)
-            {
-                aBeginPos.iPlayListPosValue.millisec_value = timems;
-                aBeginPos.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
-            }
-            else
-            {
-                aBeginPos.iPosValue.millisec_value = timems;
-                aBeginPos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
-            }
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::UpdateCurrentBeginPosition() Requested begin position is %d ms", timems));
 
@@ -5288,6 +5429,9 @@
 
         case PVP_STATE_PAUSED:
         {
+            // This is for use-case: Pause - SetPlaybackRate - Resume.
+            // In DoResume engine will call SetDataSourceDirection and then from HandleSourceNodeSetDataSourceDirection
+            // will call UpdateCurrentBeginPosition.
             if (iCurrentCmd[0].GetCmdType() == PVP_ENGINE_COMMAND_RESUME)
             {
                 // Reposition occurred during the paused state so need to change the source position first
@@ -5320,8 +5464,6 @@
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::UpdateCurrentBeginPosition() Converting to millisec failed in paused state"));
                     return retval;
                 }
-                aBeginPos.iPosValue.millisec_value = timems;
-                aBeginPos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
 
                 iChangePlaybackPositionWhenResuming = true;
 
@@ -5358,21 +5500,11 @@
 
     if (iSeekToSyncPoint && iSyncPointSeekWindow > 0)
     {
-        PVPPlaybackPosition curpos;
-        curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
-        GetPlaybackClockPosition(curpos);
-        // Need to query the data source on where playback would actually begin from
-        PVMFTimestamp startpos;
-        startpos = iCurrentBeginPosition.iPosValue.millisec_value;
-
         PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeQueryDataSourcePositionDuringPlayback);
 
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoChangePlaybackPosition() Querying source position. Position %d ms, SeekToSyncPt %d", startpos, iSeekToSyncPoint));
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoChangePlaybackPosition() Querying source position. Position %d ms, SeekToSyncPt %d", startpos, iSeekToSyncPoint));
-        iActualPlaybackPosition = curpos.iPosValue.millisec_value;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoChangePlaybackPosition() Querying source position. Position %d ms, SeekToSyncPt %d", iTargetNPT, iSeekToSyncPoint));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoChangePlaybackPosition() Querying source position. Position %d ms, SeekToSyncPt %d", iTargetNPT, iSeekToSyncPoint));
         int32 leavecode = 0;
-        iSeekPointBeforeTargetNPT = 0;
-        iSeekPointAfterTargetNPT = 0;
 
         // As in case of MP4 file we need to call overload function of QueryDataSourcePosition which retruns
         // I frame before and after instead of actaul NPT, format type will be checked here to first find if
@@ -5382,28 +5514,26 @@
         iSourceNode->GetCapability(nodeCapability);
         PVMFFormatType * formatType = nodeCapability.iInputFormatCapability.begin();
         bool mpeg4FormatType = false;
-        if (formatType  != NULL)
+        if (formatType != NULL)
         {
-            switch (*formatType)
+            if ((pv_mime_strcmp((char*)formatType->getMIMEStrPtr(), PVMF_MIME_MPEG4FF)) == 0)
             {
-                case PVMF_MPEG4FF:
-                    mpeg4FormatType = true;
-                    break;
-
-                default:
-                    mpeg4FormatType = false;
-                    break;
+                mpeg4FormatType = true;
+            }
+            else
+            {
+                mpeg4FormatType = false;
             }
         }
 
         if (mpeg4FormatType)
         {
-            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, startpos,
+            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, iTargetNPT,
                                         iSeekPointBeforeTargetNPT, iSeekPointAfterTargetNPT, (OsclAny*)context, iSeekToSyncPoint));
         }
         else
         {
-            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, startpos, iActualPlaybackPosition,
+            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, iTargetNPT, iActualNPT,
                                         iSeekToSyncPoint, (OsclAny*)context));
         }
 
@@ -5423,7 +5553,7 @@
     else
     {
         // Go straight to repositioning the data source
-        PVMFStatus retval = DoSourceNodeSetDataSourcePositionDuringPlayback(iCurrentBeginPosition.iPosValue.millisec_value, iSeekToSyncPoint, aCmdId, aCmdContext);
+        PVMFStatus retval = DoSourceNodeSetDataSourcePositionDuringPlayback(aCmdId, aCmdContext);
         if (retval == PVMFSuccess)
         {
             return PVMFPending;
@@ -5439,7 +5569,7 @@
     return PVMFPending;
 }
 
-PVMFStatus PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback(PVMFTimestamp aTargetNPT, bool aSeekToSyncPoint, PVCommandId aCmdId, OsclAny* aCmdContext)
+PVMFStatus PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback(PVCommandId aCmdId, OsclAny* aCmdContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() In"));
 
@@ -5449,7 +5579,7 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() No source playback control IF"));
         return PVMFFailure;
     }
-    bool clockpausedhere;
+    bool clockpausedhere = false;
     switch (iPlaybackPositionMode)
     {
         case PVPPBPOS_MODE_END_OF_CURRENT_PLAY_ELEMENT:
@@ -5467,15 +5597,11 @@
     // Set the new position on the source node
     PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeSetDataSourcePositionDuringPlayback);
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() Calling SetDataSourcePosition() on source node. TargetNPT %d ms, SeekToSyncPoint %d", aTargetNPT, aSeekToSyncPoint));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() Calling SetDataSourcePosition() on source node. TargetNPT %d ms, SeekToSyncPoint %d", iTargetNPT, iSeekToSyncPoint));
 
     int32 leavecode = 0;
     if (iCurrentBeginPosition.iPosUnit == PVPPBPOSUNIT_PLAYLIST)
     {
-        int32 tempStreamID = 0;
-        tempStreamID = iStreamID;
-
-
         iDataSourcePosParams.iActualMediaDataTS = 0;
         iDataSourcePosParams.iActualNPT = 0;
         if ((iCurrentBeginPosition.iMode == PVPPBPOS_MODE_UNKNOWN) ||
@@ -5492,83 +5618,58 @@
             iDataSourcePosParams.iMode = PVMF_SET_DATA_SOURCE_POSITION_MODE_END_OF_CURRENT_PLAY_SESSION;
         }
         iDataSourcePosParams.iPlayElementIndex = iCurrentBeginPosition.iPlayElementIndex;
-        iDataSourcePosParams.iSeekToSyncPoint = aSeekToSyncPoint;
+        iDataSourcePosParams.iSeekToSyncPoint = iSeekToSyncPoint;
         iDataSourcePosParams.iTargetNPT = iCurrentBeginPosition.iPlayListPosValue.millisec_value;
         iDataSourcePosParams.iStreamID = iStreamID;
         iDataSourcePosParams.iPlaylistUri = iCurrentBeginPosition.iPlayListUri;
 
-        PVMFCommandId cmdid = -1;
-        leavecode = 0;
-        OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->SetDataSourcePosition(iSourceNodeSessionId,
-                                    iDataSourcePosParams,
-                                    (OsclAny*)context));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             FreeEngineContext(context);
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition on iSourceNodePBCtrlIF did a leave!"));
-                             if (clockpausedhere)
-    {
-        // Resume the clock if paused in this function
-        iPlaybackClock.Start();
+        leavecode = IssueSourceSetDataSourcePosition(true, (OsclAny*)context);
+        if (leavecode != 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition on iSourceNodePBCtrlIF did a leave!"));
+            FreeEngineContext(context);
+            if (clockpausedhere)
+            {
+                // Resume the clock if paused in this function
+                StartPlaybackClock();
+            }
 
-            // To get regular play status events
-            StartPlaybackStatusTimer();
+            --iStreamID;
+
+            if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
+            {
+                return leavecode;
+            }
+            else
+            {
+                return PVMFFailure;
+            }
         }
-
-        if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
-    {
-        return leavecode;
     }
     else
     {
-        return PVMFFailure;
-    }
-                        );
-    }
-    else
-    {
-        // we assume that the data is not present in the graph
-        // if present we will reset this flag.
-        int32 tempStreamID = 0;
-        // if reposition points exists in between the actualPlaybackPosition and
-        // the currentPlaybackClock position, then the reposition data exists with
-        // in the graph, so we need to start a new media segment
-        // Check if forward repositioning does not need source repositioning
-        PVPPlaybackPosition curpos;
-        curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
-        GetPlaybackClockPosition(curpos);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition on iSourceNodePBCtrlIF - TargetNPT=%d, SeekToSyncPoint=%d", iTargetNPT, iSeekToSyncPoint));
+        leavecode = IssueSourceSetDataSourcePosition(false, (OsclAny*)context);
 
-        tempStreamID = iStreamID;
-
-
-        iActualMediaDataTS = 0;
-        iAdjustedMediaDataTS = 0;
-        iActualPlaybackPosition = 0;
-        leavecode = 0;
-        PVMFCommandId cmdid = -1;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition on iSourceNodePBCtrlIF - TargetNPT=%d, aSeekToSyncPoint=%d", aTargetNPT, aSeekToSyncPoint));
-        OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->SetDataSourcePosition(iSourceNodeSessionId, aTargetNPT, iActualPlaybackPosition, iActualMediaDataTS, aSeekToSyncPoint, tempStreamID, (OsclAny*)context));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             FreeEngineContext(context);
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition on iSourceNodePBCtrlIF did a leave!"));
-                             if (clockpausedhere)
-    {
-        // Resume the clock if paused in this function
-        iPlaybackClock.Start();
-
-            // To get regular play status events
-            StartPlaybackStatusTimer();
+        if (leavecode != 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition on iSourceNodePBCtrlIF did a leave!"));
+            FreeEngineContext(context);
+            if (clockpausedhere)
+            {
+                // Resume the clock if paused in this function
+                StartPlaybackClock();
+            }
+            --iStreamID;
+            if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
+            {
+                return leavecode;
+            }
+            else
+            {
+                return PVMFFailure;
+            }
         }
-
-        if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
-    {
-        return leavecode;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-                        );
     }
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePositionDuringPlayback() Out"));
 
@@ -5587,36 +5688,31 @@
     // Pause the playback clock
     bool clockpausedhere = iPlaybackClock.Pause();
 
-    // Stop the playback position status timer
-    StopPlaybackStatusTimer();
-
     // Tell the sink nodes to skip the unneeded media data
     iNumPendingNodeCmd = 0;
-    PVMFCommandId cmdid = -1;
     int32 leavecode = 0;
 
     // For all sink node with sync control IF, call SkipMediaData()
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVPlayerEngine::DoSinkNodeSkipMediaDataDuringPlayback() Calling SkipMediaData() on sink nodes. MediadataTS to flush to %d ms, MediadataTS to skip to %d ms, RenderSkipped %d", iActualMediaDataTS, iAdjustedMediaDataTS, iRenderSkipped));
+                        (0, "PVPlayerEngine::DoSinkNodeSkipMediaDataDuringPlayback() Calling SkipMediaData() on sink nodes. MediadataTS to flush to %d ms, MediadataTS to skip to %d ms", iActualMediaDataTS, iSkipMediaDataTS));
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                        (0, "PVPlayerEngine::DoSinkNodeSkipMediaDataDuringPlayback() Calling SkipMediaData() on sink nodes. MediadataTS to flush to %d ms, MediadataTS to skip to %d ms, RenderSkipped %d", iActualMediaDataTS, iAdjustedMediaDataTS, iRenderSkipped));
+                        (0, "PVPlayerEngine::DoSinkNodeSkipMediaDataDuringPlayback() Calling SkipMediaData() on sink nodes. MediadataTS to flush to %d ms, MediadataTS to skip to %d ms", iActualMediaDataTS, iSkipMediaDataTS));
 
-        if (iDatapathList[i].iTrackActive == true &&
+        if (iDatapathList[i].iDatapath &&
                 iDatapathList[i].iEndOfDataReceived == false &&
                 iDatapathList[i].iSinkNodeSyncCtrlIF != NULL)
         {
-            leavecode = 0;
             PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeSkipMediaDataDuringPlayback);
-            OSCL_TRY(leavecode, cmdid = iDatapathList[i].iSinkNodeSyncCtrlIF->SkipMediaData(iDatapathList[i].iSinkNodeSessionId, iActualMediaDataTS, iAdjustedMediaDataTS, iStreamID, iRenderSkipped, aSFR, (OsclAny*) context));
+            leavecode = IssueSinkSkipMediaData(&(iDatapathList[i]), aSFR, (OsclAny*) context);
+
             if (leavecode == 0)
             {
                 ++iNumPendingNodeCmd;
                 ++iNumPendingSkipCompleteEvent;
                 ++iNumPVMFInfoStartOfDataPending;
-
             }
             else
             {
@@ -5635,11 +5731,9 @@
         if (clockpausedhere)
         {
             // Resume the clock if paused in this function
-            iPlaybackClock.Start();
-
-            // To get regular play status events
-            StartPlaybackStatusTimer();
+            StartPlaybackClock();
         }
+
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeSkipMediaDataDuringPlayback() Skip on sink nodes failed"));
         return PVMFFailure;
     }
@@ -5686,6 +5780,12 @@
         else
         {
             retval = ConvertFromMillisec(iCurrentBeginPosition.iPosValue.millisec_value, *(aCmd.GetParam(0).pPlaybackpos_value));
+            if (retval != PVMFSuccess)
+            {
+                // The conversion failed.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlaybackRange() Conversion from millisec failed (1)"));
+                return retval;
+            }
         }
 
         if (iCurrentEndPosition.iIndeterminate)
@@ -5696,13 +5796,12 @@
         else
         {
             retval = ConvertFromMillisec(iCurrentEndPosition.iPosValue.millisec_value, *(aCmd.GetParam(1).pPlaybackpos_value));
-        }
-
-        if (retval != PVMFSuccess)
-        {
-            // The conversion failed.
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlaybackRange() Conversion from millisec failed"));
-            return retval;
+            if (retval != PVMFSuccess)
+            {
+                // The conversion failed.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlaybackRange() Conversion from millisec failed (2)"));
+                return retval;
+            }
         }
     }
 
@@ -5755,7 +5854,7 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetPlaybackRate() In"));
 
     int32 rate = aCmd.GetParam(0).int32_value;
-    OsclTimebase* timebase = (OsclTimebase*)(aCmd.GetParam(1).pOsclAny_value);
+    PVMFTimebase* timebase = (PVMFTimebase*)(aCmd.GetParam(1).pOsclAny_value);
 
     // Split the rate into the absolute value plus the direction 1 or -1.
     int32 direction = 1;
@@ -5854,6 +5953,10 @@
     if (direction != iPlaybackDirection)
     {
         iPlaybackPausedDueToEndOfClip = false;
+        //a direction change also involves an internal repositioning
+        //so reset repos related variables and increment iStreamID
+        ResetReposVariables(false);
+        iStreamID++;
     }
 
     // Save the new values.  They won't be installed until they're verified
@@ -5999,7 +6102,7 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetPlaybackRate() In"));
 
     int32* rate = aCmd.GetParam(0).pInt32_value;
-    OsclTimebase** timebase = (OsclTimebase**)(aCmd.GetParam(1).pOsclAny_value);
+    PVMFTimebase** timebase = (PVMFTimebase**)(aCmd.GetParam(1).pOsclAny_value);
 
     if (rate == NULL || timebase == NULL)
     {
@@ -6057,8 +6160,12 @@
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoPrepare() In"));
 
-    // Reset the paused-due-to-EOS flag
-    iPlaybackPausedDueToEndOfClip = false;
+    if (GetPVPlayerState() == PVP_STATE_PREPARED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Engine already in Prepared State"));
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+        return PVMFSuccess;
+    }
 
     if (GetPVPlayerState() != PVP_STATE_INITIALIZED)
     {
@@ -6066,58 +6173,204 @@
         return PVMFErrInvalidState;
     }
 
-    if (iDatapathList.empty() == true)
+    if (iState == PVP_ENGINE_STATE_PREPARING)
     {
-        // No sink added so fail
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Data sinks not added."));
-        return PVMFErrNotReady;
+        // Engine is already in PREPARING STATE and doing Track selection. DoPrepare will be called everytime
+        // engine completes a stage of track selection and flips the state to _TRACK_SELECTION_1_DONE etc.
+        // If DoPrepare called without flipping the state, that means in _PREPARING state, do nothing here
+        // just return.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::DoPrepare() Engine state PVP_ENGINE_STATE_PREPARING - Do Nothing"));
+        return PVMFSuccess;
     }
 
-    // Query cap-config based on available engine datapaths
-    PVMFStatus cmdstatus = DoSourceNodeTrackQuery(aCmd.GetCmdId(), aCmd.GetContext());
-    if (cmdstatus != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoSourceNodeTrackQuery() failed"));
-        return cmdstatus;
-    }
+    PVMFStatus cmdstatus = PVMFFailure;
 
-    SetEngineState(PVP_ENGINE_STATE_PREPARING);
+    /* Engine will call DoPrepare 4 times
+     * 1) When Engine is in PVP_ENGINE_STATE_INITIALIZED state, here engine will start the Track Selection, which
+     * will start with Sink Nodes.
+     * 2) After Init completes on Sink nodes Engine will be in PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE and Engine will
+     * start creating Dec nodes and call Init on dec nodes, if needed.
+     * 3) Init completion on Dec nodes will take Engine to PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE and Engine will
+     * start populating the Playable List after verifying parameters of different tracks. Engine after selecting
+     * tracks will call Reset on Sink and Dec nodes.
+     * 4) Once Reset completes on Sink and Dec nodes, Engine will be in PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE and then
+     * Engine will delete all the unused dec nodes.
+     */
+    if (iState == PVP_ENGINE_STATE_INITIALIZED)
+    {
+        SetEngineState(PVP_ENGINE_STATE_PREPARING);
+
+        // Reset the paused-due-to-EOS flag
+        iPlaybackPausedDueToEndOfClip = false;
+
+        if (iDatapathList.empty() == true)
+        {
+            // No sink added so fail
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Data sinks not added."));
+            return PVMFErrNotReady;
+        }
+
+        // Query cap-config based on available engine datapaths
+        cmdstatus = DoSinkNodeQueryCapConfigIF(aCmd.GetCmdId(), aCmd.GetContext());
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoSinkNodeQueryCapConfigIF: failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return PVMFPending;
+        }
+    }
+    else if (iState == PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE)
+    {
+        SetEngineState(PVP_ENGINE_STATE_PREPARING);
+
+        // Now check for the tracks which can be played only using the Sink nodes, that means no Decoder node needed.
+        cmdstatus = DoSinkNodeTrackSelection(aCmd.GetCmdId(), aCmd.GetContext());
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoSinkNodeTrackSelection: failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return PVMFPending;
+        }
+
+        // For the tracks which cannot be played by Sink nodes only, we need to instantiate decoder nodes.
+        // Create Decoder nodes and query for the cap and config IF here.
+        cmdstatus = DoDecNodeQueryCapConfigIF(aCmd.GetCmdId(), aCmd.GetContext());
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoDecNodeQueryCapConfigIF: failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return PVMFPending;
+        }
+    }
+    else if (iState == PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE)
+    {
+        SetEngineState(PVP_ENGINE_STATE_PREPARING);
+
+        cmdstatus = DoSourceNodeTrackSelection(aCmd.GetCmdId(), aCmd.GetContext());
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoSourceNodeTrackSelection: failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return PVMFPending;
+        }
+        // Reset all the sink and decoder nodes.
+        cmdstatus = DoSinkNodeDecNodeReset(aCmd.GetCmdId(), aCmd.GetContext());
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoSinkNodeDecNodeReset: failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return PVMFPending;
+        }
+    }
+    else if (iState == PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE)
+    {
+        SetEngineState(PVP_ENGINE_STATE_PREPARING);
+
+        cmdstatus = DoSinkDecCleanupSourcePrepare(aCmd.GetCmdId(), aCmd.GetContext());
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() Already EH pending, should never happen"));
+                return PVMFPending;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPrepare() DoDecNodeCleanup: failed, Add EH command"));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return PVMFPending;
+        }
+    }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoPrepare() Out"));
     return PVMFSuccess;
 }
 
-PVMFStatus PVPlayerEngine::DoSourceNodeTrackQuery(PVCommandId aCmdId, OsclAny* aCmdContext)
+PVMFStatus PVPlayerEngine::DoSinkNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeTrackQuery() In"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() In"));
 
     if (iSourceNodeTrackSelIF == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackQuery() Source node track sel IF not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() Source node track sel IF not available. Asserting"));
         return PVMFFailure;
     }
 
     uint32 i = 0;
     int32 leavecode = 0;
+    uint32 numTracks = 0;
+    PVPlayerEngineContext* context = NULL;
+    PVMFCommandId cmdid = -1;
     iNumPendingNodeCmd = 0;
 
-    bool bMimeType = false;
-    bool bMediaType = false;
-
-    PVMFMediaPresentationInfo sourcepresinfo;
-    PVMFStatus retval = PVMFFailure;
-    OSCL_TRY(leavecode, retval = iSourceNodeTrackSelIF->GetMediaPresentationInfo(sourcepresinfo));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackQuery() GetMediaPresentationInfo on iSourceNodeTrackSelIF did a leave!"));
-                         return PVMFFailure);
-    if (retval != PVMFSuccess)
+    if (iSourceNodeTrackSelIF->GetMediaPresentationInfo(iSourcePresInfoList) != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackQuery() GetMediaPresentationInfo() call on source node failed"));
-        return retval;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() GetMediaPresentationInfo() call on source node failed"));
+        return PVMFFailure;
     }
 
-    // For each engine datapath, assign a track info from the list
+    numTracks = iSourcePresInfoList.getNumTracks();
+    iTrackSelectionList.reserve(numTracks);
+
+    for (i = 0; i < numTracks; i++)
+    {
+        // Create the track selection list, which will store a set of sink and dec node (if needed) for each track.
+        PVPlayerEngineTrackSelection trackSelection;
+
+        PVMFTrackInfo* trackInfo = iSourcePresInfoList.getTrackInfo(i);
+        trackSelection.iTsTrackID = trackInfo->getTrackID();
+
+        iTrackSelectionList.push_back(trackSelection);
+    }
+
     for (i = 0;i < iDatapathList.size(); ++i)
     {
         // Destroy the track info if present
@@ -6127,222 +6380,55 @@
             iDatapathList[i].iTrackInfo = NULL;
         }
 
-        switch (iDatapathList[i].iMediaType)
+        if (iDatapathList[i].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_FILENAME)
         {
-            case PVP_MEDIATYPE_TEXT:
-            {
-                for (uint32 j = 0; j < sourcepresinfo.getNumTracks(); ++j)
-                {
-                    // Go through each track, check codec type, and save the track info
-                    PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(j);
-
-                    switch (GetFormatIndex(curtrack->getTrackMimeType().get_str()))
-                    {
-                        case PVMF_3GPP_TIMEDTEXT:
-                            retval = DoQueryTrackInfo(iDatapathList[i], curtrack, aCmdId, aCmdContext);
-                            if (retval != PVMFSuccess)
-                                return retval;
-                            // Break out of the loop
-                            j = sourcepresinfo.getNumTracks();
-
-                            bMimeType = true;
-                            break;
-
-                        default:
-                            break;
-                    }
-                }
-            }
-
-            bMediaType = true;
-
-            break;
-
-            case PVP_MEDIATYPE_VIDEO:
-            {
-                for (uint32 j = 0; j < sourcepresinfo.getNumTracks(); ++j)
-                {
-                    // Go through each track, check codec type, and save the track info
-                    PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(j);
-
-                    PVMFFormatType srcformat = GetFormatIndex(curtrack->getTrackMimeType().get_str());
-                    PVMFFormatType sinkformat = iDatapathList[i].iDataSink->GetDataSinkFormatType();
-                    Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
-
-                    switch (srcformat)
-                    {
-                        case PVMF_M4V:
-                        case PVMF_H263:
-                        case PVMF_H264_RAW:
-                        case PVMF_H264_MP4:
-                        case PVMF_H264:
-                        case PVMF_WMV:
-                        case PVMF_RV:
-                        {
-                            if (IsDecNodeNeeded(srcformat, sinkformat) == true && iPlayerNodeRegistry.QueryRegistry(srcformat, sinkformat, foundUuids) != PVMFSuccess)
-                            {
-                                break;
-                            }
-                            retval = DoQueryTrackInfo(iDatapathList[i], curtrack, aCmdId, aCmdContext);
-                            if (retval != PVMFSuccess)
-                                return retval;
-                            // Break out of the loop
-                            j = sourcepresinfo.getNumTracks();
-
-                            bMimeType = true;
-                            break;
-                        }
-                        default:
-                            break;
-                    }
-                }
-            }
-
-            bMediaType = true;
-
-            break;
-
-            case PVP_MEDIATYPE_AUDIO:
-            {
-                for (uint32 j = 0; j < sourcepresinfo.getNumTracks(); ++j)
-                {
-                    // Go through each track, check codec type, and save the track info
-                    PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(j);
-
-                    PVMFFormatType srcformat = GetFormatIndex(curtrack->getTrackMimeType().get_str());
-                    PVMFFormatType sinkformat = iDatapathList[i].iDataSink->GetDataSinkFormatType();
-                    Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
-
-                    switch (srcformat)
-                    {
-                        case PVMF_AMR_IETF:
-                        case PVMF_AMR_IETF_COMBINED:
-                        case PVMF_AMRWB_IETF:
-                        case PVMF_AMRWB_IETF_PAYLOAD:
-                        case PVMF_AMR_IF2:
-                        case PVMF_ADIF:
-                        case PVMF_ADTS:
-                        case PVMF_MPEG4_AUDIO:
-                        case PVMF_LATM:
-                        case PVMF_MP3:
-                        case PVMF_G726:
-                        case PVMF_WMA:
-                        case PVMF_REAL_AUDIO:
-                        case PVMF_PCM:
-                        case PVMF_PCM8:
-                        case PVMF_PCM16:
-                        case PVMF_PCM16_BE:
-                        case PVMF_PCM_ULAW:
-                        case PVMF_PCM_ALAW:
-                        case PVMF_ASF_MPEG4_AUDIO:
-                        {
-                            if (IsDecNodeNeeded(srcformat, sinkformat) == true && iPlayerNodeRegistry.QueryRegistry(srcformat, sinkformat, foundUuids) != PVMFSuccess)
-                            {
-                                break;
-                            }
-
-                            retval = DoQueryTrackInfo(iDatapathList[i], curtrack, aCmdId, aCmdContext);
-                            if (retval != PVMFSuccess)
-                                return retval;
-                            // Break out of the loop
-                            j = sourcepresinfo.getNumTracks();
-
-                            bMimeType = true;
-                            break;
-                        }
-                        default:
-                            break;
-                    }
-                }
-            }
-
-            bMediaType = true;
-
-            break;
-
-            default:
-                // For unknown media type, do nothing
-                break;
+            // Create file output node for sink
+            leavecode = 0;
+            OSCL_TRY(leavecode, iDatapathList[i].iSinkNode = PVFileOutputNodeFactory::CreateFileOutput());
+            OSCL_FIRST_CATCH_ANY(leavecode,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() Creation of file output node did a leave!"));
+                                 return PVMFErrNoMemory);
         }
-    }
-
-    if (!bMimeType || !bMediaType)
-        return PVMFFailure;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeTrackQuery() Out"));
-    return retval;
-}
-
-PVMFStatus PVPlayerEngine::DoQueryTrackInfo(PVPlayerEngineDatapath &aDatapath, PVMFTrackInfo* aTrack, PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoQueryTrackInfo() In %s", aTrack->getTrackMimeType().get_cstr()));
-
-    int32 leavecode = 0;
-    PVPlayerEngineContext* context = NULL;
-    PVMFCommandId cmdid = -1;
-
-    PVMFFormatType iSrcFormat = GetFormatIndex(aTrack->getTrackMimeType().get_str());
-    PVMFFormatType iSinkFormat = aDatapath.iDataSink->GetDataSinkFormatType();
-
-    if (IsDecNodeNeeded(iSrcFormat, iSinkFormat) == true)
-    {
-        Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
-        // Query the player node registry for the required decoder node
-        if (iPlayerNodeRegistry.QueryRegistry(iSrcFormat, iSinkFormat, foundUuids) == PVMFSuccess)
+        else if (iDatapathList[i].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_SINKNODE)
         {
-            if (foundUuids.empty())
+            // Use the specified output node for sink node
+            iDatapathList[i].iSinkNode = iDatapathList[i].iDataSink->GetDataSinkNodeInterface();
+            if (iDatapathList[i].iSinkNode == NULL)
             {
-                // No matching node found
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() No matching decoder node found"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() Passed in sink node is NULL"));
                 return PVMFFailure;
             }
-
-            leavecode = 0;
-            OSCL_TRY(leavecode, aDatapath.iDecNode = iPlayerNodeRegistry.CreateNode(foundUuids[0]));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Error in creating DecNode"));
-                                 return PVMFFailure;);
-
-            iNodeUuids.push_back(PVPlayerEngineUuidNodeMapping(foundUuids[0], aDatapath.iDecNode));
-
-            if (aDatapath.iDecNode == NULL)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Dec node creation failed"));
-                return PVMFErrNoMemory;
-            }
-
-
-            if (aDatapath.iDecNode->ThreadLogon() != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() ThreadLogon() on dec node failed"));
-                return PVMFFailure;
-            }
-
-            PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)aDatapath.iDecNode, this, (OsclAny*)aDatapath.iDecNode);
-            leavecode = 0;
-            OSCL_TRY(leavecode, aDatapath.iDecNodeSessionId = aDatapath.iDecNode->Connect(nodesessioninfo));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Connect on dec node did a leave!"));
-                                 return PVMFFailure);
         }
         else
         {
-            // Registry query failed
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Registry query for dec node failed"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() Unsupported player data sink type"));
+            return PVMFErrNotSupported;
+        }
+
+        if (iDatapathList[i].iSinkNode->ThreadLogon() != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() ThreadLogon() on passed-in sink node failed"));
+            OSCL_ASSERT(false);
             return PVMFFailure;
         }
 
-        // Query for Metadata IF
-        context = AllocateEngineContext(&aDatapath, aDatapath.iDecNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeQueryCapConfigIF);
+        PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)iDatapathList[i].iSinkNode, this, (OsclAny*)iDatapathList[i].iSinkNode);
+        iDatapathList[i].iSinkNodeSessionId = iDatapathList[i].iSinkNode->Connect(nodesessioninfo);
+
+        // Query for Cap-Config IF
+        context = AllocateEngineContext(&iDatapathList[i], iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeQueryCapConfigIF);
 
         PVUuid capconfiguuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
         cmdid = -1;
         leavecode = 0;
-        OSCL_TRY(leavecode, cmdid = aDatapath.iDecNode->QueryInterface(aDatapath.iDecNodeSessionId, capconfiguuid, (PVInterface*&)aDatapath.iDecNodeCapConfigIF, (OsclAny*)context));
-        if (leavecode)
+        iDatapathList[i].iSinkNodePVInterfaceCapConfig = NULL;
+        leavecode = IssueQueryInterface(iDatapathList[i].iSinkNode, iDatapathList[i].iSinkNodeSessionId, capconfiguuid, iDatapathList[i].iSinkNodePVInterfaceCapConfig, (OsclAny*)context, cmdid);
+        if (leavecode != 0 || cmdid == -1)
         {
+            iDatapathList[i].iSinkNodePVInterfaceCapConfig = NULL;
             FreeEngineContext(context);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() QueryInterface on dec node for cap-config IF did a leave!"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() QueryInterface on sink node for cap-config IF did a leave!"));
+            return PVMFFailure;
         }
         else
         {
@@ -6350,69 +6436,319 @@
         }
     }
 
-    if (aDatapath.iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_FILENAME)
-    {
-        // Create file output node for sink
-        leavecode = 0;
-        OSCL_TRY(leavecode, aDatapath.iSinkNode = PVFileOutputNodeFactory::CreateFileOutput());
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Creation of file output node did a leave!"));
-                             return PVMFErrNoMemory);
-    }
-    else if (aDatapath.iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_SINKNODE)
-    {
-        // Use the specified output node for sink node
-        aDatapath.iSinkNode = aDatapath.iDataSink->GetDataSinkNodeInterface();
-        if (aDatapath.iSinkNode == NULL)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Passed in sink node is NULL"));
-            return PVMFFailure;
-        }
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Unsupported player data sink type"));
-        return PVMFErrNotSupported;
-    }
-
-
-    if (aDatapath.iSinkNode->ThreadLogon() != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() ThreadLogon() on passed-in sink node failed"));
-        return PVMFFailure;
-    }
-
-    PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)aDatapath.iSinkNode, this, (OsclAny*)aDatapath.iSinkNode);
-    leavecode = 0;
-    OSCL_TRY(leavecode, aDatapath.iSinkNodeSessionId = aDatapath.iSinkNode->Connect(nodesessioninfo));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() Connect() on passed-in sink node did a leave!"));
-                         return PVMFFailure);
-
-    // Query for Cap-Config IF
-    context = AllocateEngineContext(&aDatapath, aDatapath.iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeQueryCapConfigIF);
-
-    PVUuid capconfiguuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
-    cmdid = -1;
-    leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, capconfiguuid, (PVInterface*&)aDatapath.iSinkNodeCapConfigIF, (OsclAny*)context));
-    if (leavecode)
-    {
-        FreeEngineContext(context);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoQueryTrackInfo() QueryInterface on sink node for cap-config IF did a leave!"));
-    }
-    else
-    {
-        ++iNumPendingNodeCmd;
-    }
-
     if (iNumPendingNodeCmd <= 0)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoQueryTrackInfo() Out No pending QueryInterface() on sink node"));
+        // NumPendingNodeCmd less than or equal to zero means that none of the Sink nodes support Cap-Config interface, which means that these
+        // sinks cannot be used for playing the content. Return PVMFErrNotSupported from here which will take engine into Error handling and will fail
+        // Prepare command.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() Out No pending QueryInterface() on sink node"));
         return PVMFErrNotSupported;
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoQueryTrackInfo() Out"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeQueryCapConfigIF() Out"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVPlayerEngine::DoSinkNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
+                    (0, "PVPlayerEngine::DoSinkNodeInit() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeInit() In"));
+
+    iNumPendingNodeCmd = 0;
+    PVMFCommandId cmdid = -1;
+    int32 leavecode = 0;
+
+    for (uint32 i = 0; i < iDatapathList.size(); ++i)
+    {
+        if (iDatapathList[i].iSinkNode != NULL)
+        {
+            // Call Init() on the sink node
+            PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeInit);
+
+            leavecode = IssueSinkNodeInit(&(iDatapathList[i]), (OsclAny*) context, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
+            {
+                ++iNumPendingNodeCmd;
+            }
+            else
+            {
+                FreeEngineContext(context);
+                return PVMFFailure;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeInit() Out"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVPlayerEngine::DoSinkNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext)
+{
+    OSCL_UNUSED_ARG(aCmdId);
+    OSCL_UNUSED_ARG(aCmdContext);
+    // For a track to be playable only by sink node, the Sink node should support the Format Type and Format Specific Info
+    // for the track. If any of the 2 variables are not supported by the sink node, the track needs to have a decoder which
+    // will be created in next stage of track selection. If Sink node supports both the above variables for a particular
+    // track, the track will make to the Playable list without any decoder node.
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeTrackSelection() In"));
+
+    PVMFStatus status = PVMFFailure;
+
+    PvmiKvp kvpFormatType;
+    PvmiKvp kvpFSI;
+
+    OSCL_StackString<64> iKVPFormatType = _STRLIT_CHAR(PVMF_FORMAT_TYPE_VALUE_KEY);
+
+    const char* aFormatValType = PVMF_FORMAT_SPECIFIC_INFO_KEY;
+
+    OsclMemAllocator alloc;
+
+    kvpFormatType.key = NULL;
+    kvpFSI.key = NULL;
+
+    kvpFormatType.key = iKVPFormatType.get_str();
+
+    kvpFSI.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+    kvpFSI.key = (PvmiKeyType)alloc.ALLOCATE(kvpFSI.length);
+    if (kvpFSI.key == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+    oscl_strncpy(kvpFSI.key, aFormatValType, kvpFSI.length);
+
+    for (uint32 i = 0; i < iDatapathList.size(); i++)
+    {
+        if (iDatapathList[i].iSinkNodeCapConfigIF != NULL)
+        {
+            for (uint32 j = 0; j < iSourcePresInfoList.getNumTracks(); j++)
+            {
+                // if any track is already been added to the playlist then no need to check with the next Datapath
+                // go onto the next track
+                if (!iTrackSelectionList[j].iTsTrackValidForPlayableList)
+                {
+                    OsclRefCounterMemFrag aConfig;
+                    PVMFTrackInfo* currTrack = iSourcePresInfoList.getTrackInfo(j);
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeTrackSelection() Check format type for %s", currTrack->getTrackMimeType().get_cstr()));
+
+                    kvpFormatType.value.pChar_value = currTrack->getTrackMimeType().get_str();
+
+                    // Check for the format type of the track first. If Supported move to Format specific info, if not
+                    // move on to the next track.
+
+                    status = iDatapathList[i].iSinkNodeCapConfigIF->verifyParametersSync(NULL, &kvpFormatType, 1);
+
+                    if (status == PVMFSuccess)
+                    {
+                        // go ahead and check for Format specific info
+                        aConfig = currTrack->getTrackConfigInfo();
+                        kvpFSI.value.key_specific_value = (OsclAny*)(aConfig.getMemFragPtr());
+                        kvpFSI.capacity = aConfig.getMemFragSize();
+
+                        status = iDatapathList[i].iSinkNodeCapConfigIF->verifyParametersSync(NULL, &kvpFSI, 1);
+
+                        if (status == PVMFSuccess)
+                        {
+                            // This track can be played just using the Sink nodes we need not have decoders for this track
+                            // Set the boolean iTsTrackValidForPlayableList to true in the TrackSelectionList.
+                            // Check the boolean iTsTrackValidForPlayableList before creating the decoder nodes, if
+                            // already set no need for decoders.
+                            iTrackSelectionList[j].iTsSinkNode = iDatapathList[i].iSinkNode;
+                            iTrackSelectionList[j].iTsSinkNodeCapConfigIF = iDatapathList[i].iSinkNodeCapConfigIF;
+                            iTrackSelectionList[j].iTsTrackValidForPlayableList = true;
+                        }
+                    }
+                }
+                // if any of the above verifyParameterSync returns a failure, just move onto the next track.
+            }
+        }
+    }
+
+    alloc.deallocate((OsclAny*)(kvpFSI.key));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeTrackSelection() Out"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVPlayerEngine::DoDecNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() In"));
+
+    int32 leavecode = 0;
+    PVPlayerEngineContext* context = NULL;
+    PVMFCommandId cmdid = -1;
+
+    PVMFFormatType iSrcFormat = 0;
+    PVMFFormatType iSinkFormat = 0;
+
+    iNumPendingNodeCmd = 0;
+
+    uint32 numTracks = iSourcePresInfoList.getNumTracks();
+
+    for (uint32 i = 0; i < numTracks; i++)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() Check the track"));
+        for (uint32 j = 0; j < iDatapathList.size(); j++)
+        {
+            // Start creating decoder nodes for tracks which cannot be played with Sink nodes alone.
+            // It is also possible that there can be similar tracks with same mime strings but with
+            // different config parameters which share the same decoder node. For these similar tracks
+            // engine should not create decoder nodes again, it should use the same decoder node instance.
+            if (iTrackSelectionList[i].iTsDecNode == NULL && !iTrackSelectionList[i].iTsTrackValidForPlayableList)
+            {
+                PVMFTrackInfo* currTrack = iSourcePresInfoList.getTrackInfo(i);
+                iSrcFormat = currTrack->getTrackMimeType().get_str();
+
+                //Try to get supported formats from the media I/O component.
+                PvmiKvp* kvp = NULL;
+                int numParams = 0;
+                PVMFStatus status = iDatapathList[j].iSinkNodeCapConfigIF->getParametersSync(NULL, (char*)INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+                if (status == PVMFSuccess)
+                {
+                    for (int k = 0; k < numParams; k++)
+                    {
+                        iSinkFormat = kvp[k].value.pChar_value;
+
+                        Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
+                        // Query the player node registry for the required decoder node
+                        if (iPlayerNodeRegistry.QueryRegistry(iSrcFormat, iSinkFormat, foundUuids) == PVMFSuccess)
+                        {
+                            if (!foundUuids.empty())
+                            {
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() Node found for %s, sink %s", currTrack->getTrackMimeType().get_str(), iSinkFormat.getMIMEStrPtr()));
+                                iTrackSelectionList[i].iTsDecNode = iPlayerNodeRegistry.CreateNode(foundUuids[0]);
+
+                                if (iTrackSelectionList[i].iTsDecNode != NULL)
+                                {
+                                    iNodeUuids.push_back(PVPlayerEngineUuidNodeMapping(foundUuids[0], iTrackSelectionList[i].iTsDecNode));
+
+                                    if (iTrackSelectionList[i].iTsDecNode->ThreadLogon() != PVMFSuccess)
+                                    {
+                                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() ThreadLogon() on dec node failed"));
+                                        OSCL_ASSERT(false);
+                                    }
+
+                                    PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)iTrackSelectionList[i].iTsDecNode, this, (OsclAny*)iTrackSelectionList[i].iTsDecNode);
+                                    iTrackSelectionList[i].iTsDecNodeSessionId = iTrackSelectionList[i].iTsDecNode->Connect(nodesessioninfo);
+
+                                    // Query for CapConfig IF
+                                    context = AllocateEngineContext(NULL, iTrackSelectionList[i].iTsDecNode, NULL, aCmdId, aCmdContext, PVP_CMD_DecNodeQueryCapConfigIF);
+
+                                    PVUuid capconfiguuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
+                                    cmdid = -1;
+                                    iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig = NULL;
+                                    leavecode = IssueQueryInterface(iTrackSelectionList[i].iTsDecNode, iTrackSelectionList[i].iTsDecNodeSessionId, capconfiguuid, iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig, (OsclAny*)context, cmdid);
+                                    if (cmdid == -1 || leavecode != 0)
+                                    {
+                                        iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig = NULL;
+                                        FreeEngineContext(context);
+                                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() QueryInterface on dec node for cap-config IF did a leave!"));
+                                    }
+                                    else
+                                    {
+                                        ++iNumPendingNodeCmd;
+                                    }
+
+                                    // A decoder is found in the registry and succesfully created for the particular set of track and datapath.
+                                    // Set the sink nodes and its cap and config IF for the track in trackSelectionList
+                                    iTrackSelectionList[i].iTsSinkNode = iDatapathList[j].iSinkNode;
+                                    iTrackSelectionList[i].iTsSinkNodeCapConfigIF = iDatapathList[j].iSinkNodeCapConfigIF;
+                                    iTrackSelectionList[i].iTsSinkNodeSessionId = iDatapathList[j].iSinkNodeSessionId;
+
+                                    // Set the sink format for the datapath.
+                                    iDatapathList[j].iSinkFormat = iSinkFormat;
+
+                                    // Valid decoder node set in TrackSelectionList. Scan the TrackSelectionList further and if
+                                    // any similar MIME track is there just use the same decoder and the same sink nodes.
+                                    for (uint32 s = i + 1; s < numTracks; s++)
+                                    {
+                                        PVMFTrackInfo* tmpTrack = iSourcePresInfoList.getTrackInfo(s);
+                                        if (!(pv_mime_strcmp(currTrack->getTrackMimeType().get_str(), tmpTrack->getTrackMimeType().get_str())))
+                                        {
+                                            iTrackSelectionList[s].iTsSinkNode = iTrackSelectionList[i].iTsSinkNode;
+                                            iTrackSelectionList[s].iTsSinkNodeCapConfigIF = iTrackSelectionList[i].iTsSinkNodeCapConfigIF;
+                                            iTrackSelectionList[s].iTsSinkNodeSessionId = iTrackSelectionList[i].iTsSinkNodeSessionId;
+
+                                            iTrackSelectionList[s].iTsDecNode = iTrackSelectionList[i].iTsDecNode;
+                                            iTrackSelectionList[s].iTsDecNodeSessionId = iTrackSelectionList[i].iTsDecNodeSessionId;
+                                        }
+                                    }
+
+                                    k = numParams;
+                                }
+                                else
+                                {
+                                    // Create node on decoder failed, check with the next sink format
+                                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() Dec node creation failed"));
+                                }
+                            }
+                            else
+                            {
+                                // No matching node found with the given Sinkformat, check with the next Sink Format
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() No matching decoder node found"));
+                            }
+                        }
+                        else
+                        {
+                            // Registry query failed with the given Sinkformat, check with the next Sink Format.
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() Registry query for dec node failed"));
+                        }
+                    }
+                    iDatapathList[j].iSinkNodeCapConfigIF->releaseParameters(0, kvp, numParams);
+                }
+                else
+                {
+                    // getParamterSync on MIO node to get the supported formats by MIO failed
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() getParamterSync on MIO node to get the supported formats by MIO failed"));
+                }
+            }
+        }
+    }
+
+    if (iNumPendingNodeCmd == 0)
+    {
+        // no decoder nodes are needed, go ahead for track selection logic
+        SetEngineState(PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE);
+        RunIfNotReady();
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeQueryCapConfigIF() Out"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVPlayerEngine::DoDecNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
+                    (0, "PVPlayerEngine::DoDecNodeInit() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeInit() In"));
+
+    iNumPendingNodeCmd = 0;
+    PVMFCommandId cmdid = -1;
+    int32 leavecode = 0;
+
+    for (uint32 i = 0; i < iTrackSelectionList.size(); ++i)
+    {
+        if (iTrackSelectionList[i].iTsDecNode != NULL)
+        {
+            // Call Init() on the dec node
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iTrackSelectionList[i].iTsDecNode, NULL, aCmdId, aCmdContext, PVP_CMD_DecNodeInit);
+
+            leavecode = IssueDecNodeInit(iTrackSelectionList[i].iTsDecNode, iTrackSelectionList[i].iTsDecNodeSessionId, (OsclAny*) context, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
+            {
+                ++iNumPendingNodeCmd;
+            }
+            else
+            {
+                FreeEngineContext(context);
+                return PVMFFailure;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeInit() Out"));
     return PVMFSuccess;
 }
 
@@ -6422,8 +6758,7 @@
 
     if (iSourceNodeTrackSelIF == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackSelection() Source node track sel IF not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackSelection() Source node track sel IF not available."));
         return PVMFFailure;
     }
 
@@ -6473,7 +6808,6 @@
     }
 
     uint32 i = 0;
-    int32 leavecode = 0;
 
     // Create a selected track list
     PVMFMediaPresentationInfo selectedtracks;
@@ -6489,15 +6823,12 @@
     if (selectedtracks.getNumTracks() == 0)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackSelection() No tracks were selected"));
+        // @TODO Provide a more specific error info
         return PVMFErrResourceConfiguration;
     }
 
     // Select in source node
-    leavecode = 0;
-    OSCL_TRY(leavecode, retval = iSourceNodeTrackSelIF->SelectTracks(selectedtracks));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackSelection() SelectTracks on iSourceNodeTrackSelIF did a leave!"));
-                         return PVMFFailure);
+    retval = iSourceNodeTrackSelIF->SelectTracks(selectedtracks);
     if (retval != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeTrackSelection() SelectTracks() on source node failed"));
@@ -6514,33 +6845,23 @@
 
     if (iSourceNodeTrackSelIF == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() Source node track sel IF not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() Source node track sel IF not available."));
         return PVMFFailure;
     }
 
-    uint32 i = 0;
-    int32 leavecode = 0;
-    PVMFStatus retval = PVMFFailure;
-
     PVMFMediaPresentationInfo sourcepresinfo;
     if (oPopulatePlayableListOnly)
     {
+        // use already saved presentation info list from source node
+        sourcepresinfo = iSourcePresInfoList;
+
         iPlayableList.Reset();
-        OSCL_TRY(leavecode, retval = iSourceNodeTrackSelIF->GetMediaPresentationInfo(sourcepresinfo));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() GetMediaPresentationInfo on iSourceNodeTrackSelIF did a leave!"));
-                             return PVMFFailure);
-        if (retval != PVMFSuccess)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() GetMediaPresentationInfo() call on source node failed"));
-            return retval;
-        }
-        iPlayableList.setPresentationType(sourcepresinfo.getPresentationType());
-        iPlayableList.setSeekableFlag(sourcepresinfo.IsSeekable());
-        iPlayableList.SetDurationAvailable(sourcepresinfo.IsDurationAvailable());
-        iPlayableList.setDurationValue(sourcepresinfo.getDurationValue());
-        iPlayableList.setDurationTimeScale(sourcepresinfo.getDurationTimeScale());
+
+        iPlayableList.setPresentationType(iSourcePresInfoList.getPresentationType());
+        iPlayableList.setSeekableFlag(iSourcePresInfoList.IsSeekable());
+        iPlayableList.SetDurationAvailable(iSourcePresInfoList.IsDurationAvailable());
+        iPlayableList.setDurationValue(iSourcePresInfoList.getDurationValue());
+        iPlayableList.setDurationTimeScale(iSourcePresInfoList.getDurationTimeScale());
     }
     else
     {
@@ -6556,214 +6877,186 @@
         }
     }
 
-    // For each engine datapath, assign a track info from the list
-    for (i = 0;i < iDatapathList.size(); ++i)
+    PVMFStatus retVal = PVMFSuccess;
+    uint32 i = 0;
+    uint32 k = 0;
+
+    if (oPopulatePlayableListOnly)
     {
-        PVMFStatus checkcodec = PVMFFailure;
-        int32 trackId = -1;
-        // Destroy the track info if present
-        if (iDatapathList[i].iTrackInfo)
+        for (i = 0; i < iDatapathList.size(); i++)
         {
-            OSCL_DELETE(iDatapathList[i].iTrackInfo);
-            iDatapathList[i].iTrackInfo = NULL;
+            // Destroy the track info if present
+            if (iDatapathList[i].iTrackInfo)
+            {
+                OSCL_DELETE(iDatapathList[i].iTrackInfo);
+                iDatapathList[i].iTrackInfo = NULL;
+            }
         }
 
-        switch (iDatapathList[i].iMediaType)
+        for (i = 0; i < sourcepresinfo.getNumTracks(); i++)
         {
-            case PVP_MEDIATYPE_TEXT:
+            PVMFStatus checkcodec = PVMFFailure;
+            int32 trackId = -1;
+
+            // Go through each track, check codec type, and save the track info
+            PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(i);
+            trackId = curtrack->getTrackID();
+
+            // check if this track can be directly pushed in playable list. This will be the case where decoder node is not needed
+            // and Sink node supports the format and format specific info. OR
+            // The track is a text track.
+
+            if (iTrackSelectionList[i].iTsDecNode == NULL)
             {
-                for (uint32 j = 0; j < sourcepresinfo.getNumTracks(); ++j)
+                // check if it is a valid track or not, decoder node can be NULL only in 2 cases
+                // 1) Track can be played without decoder nodes, here iTsTrackValidForPlayableList should be true OR track is TEXT track
+                // 2) If the track is not valid at all, if this is the case, move onto next track.
+
+                if (iTrackSelectionList[i].iTsTrackValidForPlayableList ||
+                        (pv_mime_strcmp(curtrack->getTrackMimeType().get_str(), PVMF_MIME_3GPP_TIMEDTEXT)) == 0)
                 {
-                    // Go through each track, check codec type, and save the track info
-                    PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(j);
-
-                    switch (GetFormatIndex(curtrack->getTrackMimeType().get_str()))
-                    {
-                        case PVMF_3GPP_TIMEDTEXT:
-                        {
-                            if (oPopulatePlayableListOnly)
-                            {
-                                //add it to playable list
-                                iPlayableList.addTrackInfo(*curtrack);
-                            }
-                            else
-                            {
-                                leavecode = 0;
-                                OSCL_TRY(leavecode, iDatapathList[i].iTrackInfo = OSCL_NEW(PVMFTrackInfo, (*curtrack)));
-                                OSCL_FIRST_CATCH_ANY(leavecode,
-                                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() Could not allocate memory for PVMFTrackInfo"));
-                                                     return PVMFErrNoMemory);
-                                // Break out of the loop
-                                j = sourcepresinfo.getNumTracks();
-                            }
-                        }
-                        break;
-
-                        default:
-                            break;
-                    }
+                    // this can make directly to the Playable list, since it satisfies condition# 1 above.
+                    iPlayableList.addTrackInfo(*curtrack);
+                    iTrackSelectionList[i].iTsTrackValidForPlayableList = false;
+                    checkcodec = PVMFSuccess;
                 }
             }
-            break;
-
-            case PVP_MEDIATYPE_VIDEO:
+            else
             {
-                for (uint32 j = 0; j < sourcepresinfo.getNumTracks(); ++j)
+                // if sink node alone does not support this track verify its parameters.
+                retVal = DoVerifyTrackInfo(iTrackSelectionList[i], curtrack, checkcodec);
+                if (retVal != PVMFSuccess)
+                    return retVal;
+
+                if (checkcodec == PVMFSuccess)
                 {
-                    // Go through each track, check codec type, and save the track info
-                    PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(j);
-
-                    PVMFFormatType srcformat = GetFormatIndex(curtrack->getTrackMimeType().get_str());
-                    PVMFFormatType sinkformat = iDatapathList[i].iDataSink->GetDataSinkFormatType();
-                    Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
-
-                    switch (srcformat)
-                    {
-                        case PVMF_M4V:
-                        case PVMF_H263:
-                        case PVMF_H264_RAW:
-                        case PVMF_H264_MP4:
-                        case PVMF_H264:
-                        case PVMF_WMV:
-                        case PVMF_RV:
-                        {
-                            trackId = curtrack->getTrackID();
-                            if (IsDecNodeNeeded(srcformat, sinkformat) == true &&
-                                    iPlayerNodeRegistry.QueryRegistry(srcformat, sinkformat, foundUuids) != PVMFSuccess)
-                            {
-                                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection: Unsupported codec trackID=%d due to NodeRegistry", trackId));
-                                break;
-                            }
-
-                            retval = DoVerifyTrackInfo(iDatapathList[i], curtrack, checkcodec);
-                            if (retval != PVMFSuccess)
-                                return retval;
-
-                            if (oPopulatePlayableListOnly)
-                            {
-                                if (checkcodec == PVMFSuccess)
-                                {
-                                    //add it to playable list
-                                    iPlayableList.addTrackInfo(*curtrack);
-                                }
-                            }
-                            else
-                            {
-                                // Only select base track in case of temporal scalability
-                                if (curtrack->DoesTrackHaveDependency() == false && checkcodec == PVMFSuccess)
-                                {
-                                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection: selected video trackID=%d", trackId));
-                                    leavecode = 0;
-                                    OSCL_TRY(leavecode, iDatapathList[i].iTrackInfo = OSCL_NEW(PVMFTrackInfo, (*curtrack)));
-                                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() Could not allocate memory for PVMFTrackInfo"));
-                                                         return PVMFErrNoMemory);
-                                    // Break out of the loop
-                                    j = sourcepresinfo.getNumTracks();
-                                }
-                            }
-                        }
-                        break;
-
-                        default:
-                            break;
-                    }
+                    //add it to playable list
+                    iPlayableList.addTrackInfo(*curtrack);
                 }
             }
-            break;
 
-            case PVP_MEDIATYPE_AUDIO:
+            if (checkcodec != PVMFSuccess && trackId >= 0)
             {
-                for (uint32 j = 0; j < sourcepresinfo.getNumTracks(); ++j)
-                {
-                    // Go through each track, check codec type, and save the track info
-                    PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(j);
-
-                    PVMFFormatType srcformat = GetFormatIndex(curtrack->getTrackMimeType().get_str());
-                    PVMFFormatType sinkformat = iDatapathList[i].iDataSink->GetDataSinkFormatType();
-                    Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
-
-                    switch (srcformat)
-                    {
-                        case PVMF_AMR_IETF:
-                        case PVMF_AMR_IETF_COMBINED:
-                        case PVMF_AMR_IF2:
-                        case PVMF_ADIF:
-                        case PVMF_ADTS:
-                        case PVMF_MPEG4_AUDIO:
-                        case PVMF_LATM:
-                        case PVMF_MP3:
-                        case PVMF_G726:
-                        case PVMF_WMA:
-                        case PVMF_REAL_AUDIO:
-                        case PVMF_PCM:
-                        case PVMF_PCM8:
-                        case PVMF_PCM16:
-                        case PVMF_PCM16_BE:
-                        case PVMF_PCM_ULAW:
-                        case PVMF_PCM_ALAW:
-                        case PVMF_AMRWB_IETF:
-                        case PVMF_ASF_MPEG4_AUDIO:
-                        case PVMF_AMRWB_IETF_PAYLOAD:
-                        {
-                            trackId = curtrack->getTrackID();
-                            if (IsDecNodeNeeded(srcformat, sinkformat) == true && iPlayerNodeRegistry.QueryRegistry(srcformat, sinkformat, foundUuids) != PVMFSuccess)
-                            {
-                                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection: Unsupported codec trackID=%d due to NodeRegistry", trackId));
-                                break;
-                            }
-
-                            retval = DoVerifyTrackInfo(iDatapathList[i], curtrack, checkcodec);
-                            if (retval != PVMFSuccess)
-                                return retval;
-                            if (oPopulatePlayableListOnly)
-                            {
-                                if (checkcodec == PVMFSuccess)
-                                {
-                                    //add it to playable list
-                                    iPlayableList.addTrackInfo(*curtrack);
-                                }
-                            }
-                            else
-                            {
-                                if (checkcodec == PVMFSuccess)
-                                {
-                                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection: selected audio trackID=%d", trackId));
-                                    leavecode = 0;
-                                    OSCL_TRY(leavecode, iDatapathList[i].iTrackInfo = OSCL_NEW(PVMFTrackInfo, (*curtrack)));
-                                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoTrackSelection() Could not allocate memory for PVMFTrackInfo"));
-                                                         return PVMFErrNoMemory);
-                                    // Break out of the loop
-                                    j = sourcepresinfo.getNumTracks();
-                                }
-                            }
-                        }
-                        break;
-
-                        default:
-                            break;
-                    }
-                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection() Bad track config for TrackId=%d", trackId));
+                SendInformationalEvent(PVMFInfoTrackDisable, NULL, (OsclAny*)trackId, NULL, 0);
             }
-            break;
-
-            default:
-                // For unknown media type, do nothing
-                break;
-        }
-
-        if (checkcodec != PVMFSuccess && trackId >= 0)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection() Bad track config for TrackId=%d", trackId));
-            SendInformationalEvent(PVMFInfoTrackDisable, NULL, (OsclAny*)trackId, NULL, NULL);
         }
     }
-    return retval;
+    else
+    {
+        for (i = 0; i < sourcepresinfo.getNumTracks(); i++)
+        {
+            PVMFTrackInfo* curtrack = sourcepresinfo.getTrackInfo(i);
+
+            for (k = 0; k < iTrackSelectionList.size(); k++)
+            {
+                // check which track is selected by comparing the TrackId
+                int32 trackId = curtrack->getTrackID();
+                if (trackId == iTrackSelectionList[k].iTsTrackID)
+                {
+                    for (uint32 j = 0; j < iDatapathList.size(); j++)
+                    {
+                        // if a track has already been added to the datapath, move onto the next datapath.
+                        if (!iDatapathList[j].iTrackInfo)
+                        {
+                            // check for the corresponding datapath to the track
+                            if (iDatapathList[j].iSinkNode == iTrackSelectionList[k].iTsSinkNode)
+                            {
+                                if (curtrack->DoesTrackHaveDependency() == true)
+                                {
+                                    // Track has dependency, move onto next track
+                                    j = iDatapathList.size();
+                                    k = iTrackSelectionList.size();
+                                }
+                                else
+                                {
+                                    // The track has been added to the final list, this means that this track is valid
+                                    // and will make to DatapathList and all other video decoders will be destroyed.
+                                    iDatapathList[j].iTrackInfo = OSCL_NEW(PVMFTrackInfo, (*curtrack));
+
+                                    // set the decoder node, its session id and decoder cap&config IF in the Datapath, since the track is the
+                                    // selected one.
+                                    if (iTrackSelectionList[k].iTsDecNode)
+                                    {
+                                        iDatapathList[j].iDecNode = iTrackSelectionList[k].iTsDecNode;
+                                        iDatapathList[j].iDecNodeSessionId = iTrackSelectionList[k].iTsDecNodeSessionId;
+                                        iDatapathList[j].iDecNodeCapConfigIF = iTrackSelectionList[k].iTsDecNodeCapConfigIF;
+                                    }
+
+                                    iTrackSelectionList[k].iTsSinkNode = NULL;
+                                    iTrackSelectionList[k].iTsSinkNodeSessionId = 0;
+                                    iTrackSelectionList[k].iTsSinkNodeCapConfigIF = NULL;
+
+                                    iTrackSelectionList[k].iTsDecNode = NULL;
+                                    iTrackSelectionList[k].iTsDecNodeSessionId = 0;
+                                    iTrackSelectionList[k].iTsDecNodeCapConfigIF = NULL;
+                                    iTrackSelectionList[k].iTsDecNodePVInterfaceCapConfig = NULL;
+
+                                    iTrackSelectionList[k].iTsTrackID = -1;
+                                    iTrackSelectionList[k].iTsTrackValidForPlayableList = false;
+                                }
+                                j = iDatapathList.size();
+                            }
+                            // Datapath sinknode does not match, check the next datapath for the track
+                        }
+                        // a track has already been assigned for the datapath, check next datapath for the track
+                    }
+                    k = iTrackSelectionList.size();
+                }
+                // The trackId of the track does not match with the track in the List, check the next track.
+            }
+        }
+
+        // Go through the track selection list and set similar decoder nodes to NULL. There should be only 1 entry
+        // of a decoder node either in DatapathList (this will be for the final playable track) or in
+        // TrackSelectionList which will be for tracks which will not be used for playback.
+        for (i = 0; i < iTrackSelectionList.size(); i++)
+        {
+            PVMFTrackInfo* currTrack = iSourcePresInfoList.getTrackInfo(i);
+            for (uint32 j = i + 1; j < iTrackSelectionList.size(); j++)
+            {
+                PVMFTrackInfo* tmpTrack = iSourcePresInfoList.getTrackInfo(j);
+                if (!(pv_mime_strcmp(currTrack->getTrackMimeType().get_str(), tmpTrack->getTrackMimeType().get_str())))
+                {
+                    iTrackSelectionList[j].iTsDecNode = NULL;
+                    iTrackSelectionList[j].iTsDecNodeSessionId = 0;
+                    iTrackSelectionList[j].iTsDecNodeCapConfigIF = NULL;
+                }
+            }
+        }
+
+        // now go through whole TrackSelectionList and look for similar sink and decoder nodes
+        // to the track selected i.e. added to datapath, set all sink and decoder nodes to NULL for the track selected
+        for (k = 0; k < iDatapathList.size(); k++)
+        {
+            for (uint32 s = 0; s < iTrackSelectionList.size(); s++)
+            {
+                if ((iDatapathList[k].iSinkNode == iTrackSelectionList[s].iTsSinkNode))
+                {
+                    iTrackSelectionList[s].iTsSinkNode = NULL;
+                    iTrackSelectionList[s].iTsSinkNodeSessionId = 0;
+                    iTrackSelectionList[s].iTsSinkNodeCapConfigIF = NULL;
+                }
+
+                if ((iDatapathList[k].iDecNode != NULL) &&
+                        (iDatapathList[k].iDecNode == iTrackSelectionList[s].iTsDecNode))
+                {
+                    iTrackSelectionList[s].iTsDecNode = NULL;
+                    iTrackSelectionList[s].iTsDecNodeSessionId = 0;
+                    iTrackSelectionList[s].iTsDecNodeCapConfigIF = NULL;
+                    iTrackSelectionList[s].iTsDecNodePVInterfaceCapConfig = NULL;
+                }
+
+                iTrackSelectionList[s].iTsTrackID = -1;
+                iTrackSelectionList[s].iTsTrackValidForPlayableList = false;
+            }
+        }
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoTrackSelection() Out"));
+    return retVal;
 }
 
-
-PVMFStatus PVPlayerEngine::DoVerifyTrackInfo(PVPlayerEngineDatapath &aDatapath, PVMFTrackInfo* aTrack, PVMFStatus& aCheckcodec)
+PVMFStatus PVPlayerEngine::DoVerifyTrackInfo(PVPlayerEngineTrackSelection &aTrackSelection, PVMFTrackInfo* aTrack, PVMFStatus& aCheckcodec)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoVerifyTrackInfo() In %s", aTrack->getTrackMimeType().get_cstr()));
 
@@ -6772,7 +7065,7 @@
     PvmiKvp kvp;
     kvp.key = NULL;
 
-    char* aFormatValType = PVMF_FORMAT_SPECIFIC_INFO_KEY;
+    const char* aFormatValType = PVMF_FORMAT_SPECIFIC_INFO_KEY;
     OsclRefCounterMemFrag aConfig;
 
     kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
@@ -6787,115 +7080,115 @@
     kvp.capacity = aConfig.getMemFragSize();
 
     //Check if we have decoder node cap-config
-    if (aDatapath.iDecNodeCapConfigIF != NULL)
+    if (aTrackSelection.iTsDecNodeCapConfigIF != NULL)
     {
-        PVMFFormatType DecnodeFormatType = GetFormatIndex(aTrack->getTrackMimeType().get_str());
-        switch (DecnodeFormatType)
+        PVMFFormatType DecnodeFormatType = aTrack->getTrackMimeType().get_str();
+
+        PvmiKvp* iErrorKVP = NULL;
+        PvmiKvp iKVPSetFormat;
+        iKVPSetFormat.key = NULL;
+        OSCL_StackString<64> iKeyStringSetFormat;
+        iKVPSetFormat.value.pChar_value = (char*)DecnodeFormatType.getMIMEStrPtr();
+
+        // Query for video decoder first with the track, if no success, then check for audio decoder. Only one query will succeed.
+        // If both fails, check the status.
+        iKeyStringSetFormat = _STRLIT_CHAR(PVMF_VIDEO_DEC_FORMAT_TYPE_VALUE_KEY);
+        iKVPSetFormat.key = iKeyStringSetFormat.get_str();
+
+        aTrackSelection.iTsDecNodeCapConfigIF->setParametersSync(NULL, &iKVPSetFormat, 1, iErrorKVP);
+        if (iErrorKVP == NULL)
         {
-            case PVMF_M4V:
-            case PVMF_H263:
-            case PVMF_H264:
-            case PVMF_H264_MP4:
-            case PVMF_H264_RAW:
-            case PVMF_LATM:
-            case PVMF_MPEG4_AUDIO:
-            case PVMF_ASF_MPEG4_AUDIO:
-            case PVMF_WMV:
+            //verify codec specific info
+            int32 leavecode = 0;
+            OSCL_TRY(leavecode, aCheckcodec = aTrackSelection.iTsDecNodeCapConfigIF->verifyParametersSync(NULL, &kvp, 1));
+            OSCL_FIRST_CATCH_ANY(leavecode,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() unsupported verifyParametersSync did a leave!"));
+                                 alloc.deallocate((OsclAny*)(kvp.key));
+                                 aCheckcodec = PVMFSuccess; // set it success in case track selection info is not yet available;
+                                 return PVMFSuccess;);
+
+            if (aCheckcodec != PVMFSuccess)
             {
-                PvmiKvp* iErrorKVP = NULL;
-                PvmiKvp iKVPSetFormat;
-                iKVPSetFormat.key = NULL;
-                OSCL_StackString<64> iKeyStringSetFormat;
-
-                if ((DecnodeFormatType == PVMF_M4V) ||
-                        (DecnodeFormatType == PVMF_H263) ||
-                        (DecnodeFormatType == PVMF_H264) ||
-                        (DecnodeFormatType == PVMF_H264_MP4) ||
-                        (DecnodeFormatType == PVMF_H264_RAW) ||
-                        (DecnodeFormatType == PVMF_WMV)
-                   )
+                alloc.deallocate((OsclAny*)(kvp.key));
+                //In case of other error code, this is operation error.
+                if (aCheckcodec != PVMFErrNotSupported)
                 {
-                    iKeyStringSetFormat = _STRLIT_CHAR("x-pvmf/video/decoder/format-type;valtype=uint32");
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() verifyParametersSync() on decoder node failed"));
+                    return aCheckcodec;
                 }
-                else
-                {
-                    iKeyStringSetFormat += _STRLIT_CHAR("x-pvmf/audio/decoder/format-type;valtype=uint32");
-                }
-                iKVPSetFormat.key = iKeyStringSetFormat.get_str();
-                iKVPSetFormat.value.uint32_value = DecnodeFormatType;
-
-                aDatapath.iDecNodeCapConfigIF->setParametersSync(NULL, &iKVPSetFormat, 1, iErrorKVP);
+                return status;
             }
-            break;
-            default:
-                break;
+
+            int numKvp = 0;
+            PvmiKvp* kvpPtr;
+            // Query using get
+            OSCL_StackString<64> querykey;
+
+            querykey = _STRLIT_CHAR("x-pvmf/video/render");
+            if (aTrackSelection.iTsDecNodeCapConfigIF->getParametersSync(NULL, querykey.get_str(), kvpPtr, numKvp, NULL) == PVMFSuccess)
+            {
+                //verify width/height
+                if (aTrackSelection.iTsSinkNodeCapConfigIF != NULL)
+                    aCheckcodec = aTrackSelection.iTsSinkNodeCapConfigIF->verifyParametersSync(NULL, kvpPtr, numKvp);
+                status = aTrackSelection.iTsDecNodeCapConfigIF->releaseParameters(NULL, kvpPtr, numKvp);
+            }
         }
-
-        //verify codec specific info
-        int32 leavecode = 0;
-        OSCL_TRY(leavecode, aCheckcodec = aDatapath.iDecNodeCapConfigIF->verifyParametersSync(NULL, &kvp, 1));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() unsupported verifyParametersSync did a leave!"));
-                             alloc.deallocate((OsclAny*)(kvp.key));
-                             aCheckcodec = PVMFSuccess; // set it success in case track selection info is not yet available;
-                             return PVMFSuccess;);
-
-        if (aCheckcodec != PVMFSuccess)
+        else
         {
-            alloc.deallocate((OsclAny*)(kvp.key));
-            //In case of other error code, this is operation error.
-            if (aCheckcodec != PVMFErrNotSupported)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() verifyParametersSync() on decoder node failed"));
-                return aCheckcodec;
-            }
-            return status;
-        }
+            // Query failed for video decoder next try the audio decoder.
+            iErrorKVP = NULL;
+            iKeyStringSetFormat = NULL;
+            iKVPSetFormat.key = NULL;
 
-        int numKvp = 0;
-        PvmiKvp* kvpPtr;
-        // Query using get
-        OSCL_StackString<64> querykey;
+            iKeyStringSetFormat += _STRLIT_CHAR(PVMF_AUDIO_DEC_FORMAT_TYPE_VALUE_KEY);
+            iKVPSetFormat.key = iKeyStringSetFormat.get_str();
 
-        switch (aDatapath.iMediaType)
-        {
-            case PVP_MEDIATYPE_VIDEO:
+            aTrackSelection.iTsDecNodeCapConfigIF->setParametersSync(NULL, &iKVPSetFormat, 1, iErrorKVP);
+
+            if (iErrorKVP == NULL)
             {
-                querykey = _STRLIT_CHAR("x-pvmf/video/render");
-                if (aDatapath.iDecNodeCapConfigIF->getParametersSync(NULL, querykey.get_str(), kvpPtr, numKvp, NULL) == PVMFSuccess)
+                //verify codec specific info
+                int32 leavecodeaudio = 0;
+                OSCL_TRY(leavecodeaudio, aCheckcodec = aTrackSelection.iTsDecNodeCapConfigIF->verifyParametersSync(NULL, &kvp, 1));
+                OSCL_FIRST_CATCH_ANY(leavecodeaudio,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() unsupported verifyParametersSync did a leave!"));
+                                     alloc.deallocate((OsclAny*)(kvp.key));
+                                     aCheckcodec = PVMFSuccess; // set it success in case track selection info is not yet available;
+                                     return PVMFSuccess;);
+
+                if (aCheckcodec != PVMFSuccess)
                 {
-                    //verify width/height
-                    if (aDatapath.iSinkNodeCapConfigIF != NULL)
-                        aCheckcodec = aDatapath.iSinkNodeCapConfigIF->verifyParametersSync(NULL, kvpPtr, numKvp);
-                    status = aDatapath.iDecNodeCapConfigIF->releaseParameters(NULL, kvpPtr, numKvp);
-                    if (status != PVMFSuccess || aCheckcodec != PVMFSuccess)
-                        break;
+                    alloc.deallocate((OsclAny*)(kvp.key));
+                    //In case of other error code, this is operation error.
+                    if (aCheckcodec != PVMFErrNotSupported)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() verifyParametersSync() on decoder node failed"));
+                        return aCheckcodec;
+                    }
+                    return status;
                 }
-            }
-            break;
-            case PVP_MEDIATYPE_AUDIO:
-            {
+
+                int numKvp = 0;
+                PvmiKvp* kvpPtr;
+                // Query using get
+                OSCL_StackString<64> querykey;
+
                 querykey = _STRLIT_CHAR("x-pvmf/audio/render");
-                if (aDatapath.iDecNodeCapConfigIF->getParametersSync(NULL, querykey.get_str(), kvpPtr, numKvp, NULL) == PVMFSuccess)
+                if (aTrackSelection.iTsDecNodeCapConfigIF->getParametersSync(NULL, querykey.get_str(), kvpPtr, numKvp, NULL) == PVMFSuccess)
                 {
                     //verify samplerate and channels
-                    if (aDatapath.iSinkNodeCapConfigIF != NULL)
-                        aCheckcodec = aDatapath.iSinkNodeCapConfigIF->verifyParametersSync(NULL, kvpPtr, numKvp);
-                    status = aDatapath.iDecNodeCapConfigIF->releaseParameters(NULL, kvpPtr, numKvp);
-                    if (status != PVMFSuccess || aCheckcodec != PVMFSuccess)
-                        break;
+                    if (aTrackSelection.iTsSinkNodeCapConfigIF != NULL)
+                        aCheckcodec = aTrackSelection.iTsSinkNodeCapConfigIF->verifyParametersSync(NULL, kvpPtr, numKvp);
+                    status = aTrackSelection.iTsDecNodeCapConfigIF->releaseParameters(NULL, kvpPtr, numKvp);
                 }
             }
-            break;
-            default:
-                break;
         }
     }
     else
     {
-        if (aDatapath.iSinkNodeCapConfigIF != NULL)
+        if (aTrackSelection.iTsSinkNodeCapConfigIF != NULL)
         {
-            aCheckcodec = aDatapath.iSinkNodeCapConfigIF->verifyParametersSync(NULL, &kvp, 1);
+            aCheckcodec = aTrackSelection.iTsSinkNodeCapConfigIF->verifyParametersSync(NULL, &kvp, 1);
         }
     }
 
@@ -6919,8 +7212,8 @@
     iKVPBitRate.key = iKVPStringBitRate.get_str();
     iKVPBitRate.value.uint32_value = aTrack->getTrackBitRate();
 
-    if (aDatapath.iSinkNodeCapConfigIF != NULL)
-        aCheckcodec = aDatapath.iSinkNodeCapConfigIF->verifyParametersSync(NULL, &iKVPBitRate, 1);
+    if (aTrackSelection.iTsSinkNodeCapConfigIF != NULL)
+        aCheckcodec = aTrackSelection.iTsSinkNodeCapConfigIF->verifyParametersSync(NULL, &iKVPBitRate, 1);
     //In case of other error code, this is operation error.
     if (aCheckcodec != PVMFSuccess)
     {
@@ -6933,43 +7226,36 @@
         return status;
     }
 
-    //verify video framerate
-    switch (aDatapath.iMediaType)
+    //verify video framerate, if track is not video, sink will return ErrNotSupported.
+    if (aTrack->getTrackFrameRate() > 0)
     {
-        case PVP_MEDIATYPE_VIDEO:
-            if (aTrack->getTrackFrameRate() > 0)
-            {
-                PvmiKvp iKVPFrameRate;
-                iKVPFrameRate.key = NULL;
+        PvmiKvp iKVPFrameRate;
+        iKVPFrameRate.key = NULL;
 
-                OSCL_StackString<64> iKVPStringFrameRate = _STRLIT_CHAR(PVMF_FRAMERATE_VALUE_KEY);
-                iKVPFrameRate.key = iKVPStringFrameRate.get_str();
-                iKVPFrameRate.value.uint32_value = aTrack->getTrackFrameRate();
+        OSCL_StackString<64> iKVPStringFrameRate = _STRLIT_CHAR(PVMF_FRAMERATE_VALUE_KEY);
+        iKVPFrameRate.key = iKVPStringFrameRate.get_str();
+        iKVPFrameRate.value.uint32_value = aTrack->getTrackFrameRate();
 
-                if (aDatapath.iSinkNodeCapConfigIF != NULL)
-                    aCheckcodec = aDatapath.iSinkNodeCapConfigIF->verifyParametersSync(NULL, &iKVPFrameRate, 1);
-                //In case of other error code, this is operation error.
-                if (aCheckcodec != PVMFErrNotSupported && aCheckcodec != PVMFSuccess)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() verifyParametersSync() on sink node framerate failed"));
-                    return aCheckcodec;
-                }
-            }
-            break;
-        default:
-            break;
+        if (aTrackSelection.iTsSinkNodeCapConfigIF != NULL)
+            aCheckcodec = aTrackSelection.iTsSinkNodeCapConfigIF->verifyParametersSync(NULL, &iKVPFrameRate, 1);
+        //In case of other error code, this is operation error.
+        if (aCheckcodec != PVMFErrNotSupported && aCheckcodec != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyTrackInfo() verifyParametersSync() on sink node framerate failed"));
+            return aCheckcodec;
+        }
     }
+
     return status;
 }
 
-PVMFStatus PVPlayerEngine::DoSinkNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext)
+PVMFStatus PVPlayerEngine::DoSinkNodeDecNodeReset(PVCommandId aCmdId, OsclAny* aCmdContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
-                    (0, "PVPlayerEngine::DoSinkNodeInit() Tick=%d", OsclTickCount::TickCount()));
+                    (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() Tick=%d", OsclTickCount::TickCount()));
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeInit() In"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() In"));
 
-    // For each engine datapath in the list, initiate the setup sequence
     iNumPendingNodeCmd = 0;
     PVMFCommandId cmdid = -1;
     int32 leavecode = 0;
@@ -6978,28 +7264,70 @@
     {
         if (iDatapathList[i].iSinkNode != NULL)
         {
-            // Call Init() on the sink node
-            PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeVerifyParameter);
+            // Call Reset() on the sink node
+            PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeReset);
 
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iDatapathList[i].iSinkNode->Init(iDatapathList[i].iSinkNodeSessionId, (OsclAny*) context));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeInit() Init on iSinkNode did a leave")););
+            leavecode = IssueSinkNodeReset(&(iDatapathList[i]), (OsclAny*) context, cmdid);
+
             if (cmdid != -1 && leavecode == 0)
             {
                 ++iNumPendingNodeCmd;
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() Reset on sink node leaved, asserting"));
                 FreeEngineContext(context);
+                OSCL_ASSERT(false);
+            }
+        }
+
+        if (iDatapathList[i].iDecNode != NULL)
+        {
+            // Call Reset() on the dec node
+            PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iDecNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeReset);
+
+            leavecode = IssueDecNodeReset(iDatapathList[i].iDecNode, iDatapathList[i].iDecNodeSessionId, (OsclAny*) context, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
+            {
+                ++iNumPendingNodeCmd;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() Reset on sink node leaved, asserting"));
+                FreeEngineContext(context);
+                OSCL_ASSERT(false);
             }
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeInit() Out"));
+    // There can be some more decoders in TrackSelectionList on which engine needs to call Reset. call Reset on those decoders now.
+    for (uint32 j = 0; j < iTrackSelectionList.size(); j++)
+    {
+        if (iTrackSelectionList[j].iTsDecNode != NULL)
+        {
+            // Call Reset() on the dec node
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iTrackSelectionList[j].iTsDecNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeReset);
+
+            leavecode = IssueDecNodeReset(iTrackSelectionList[j].iTsDecNode, iTrackSelectionList[j].iTsDecNodeSessionId, (OsclAny*) context, cmdid);
+
+            if (cmdid != -1 && leavecode == 0)
+            {
+                ++iNumPendingNodeCmd;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() Reset on sink node leaved, asserting"));
+                FreeEngineContext(context);
+                OSCL_ASSERT(false);
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() Out"));
     if (iNumPendingNodeCmd == 0)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeInit() No datapath could be prepared!"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeDecNodeReset() No datapath could be prepared!"));
         return PVMFFailure;
     }
     else
@@ -7008,50 +7336,226 @@
     }
 }
 
-PVMFStatus PVPlayerEngine::DoSinkNodeReset(PVCommandId aCmdId, OsclAny* aCmdContext)
+PVMFStatus PVPlayerEngine::DoSinkDecCleanupSourcePrepare(PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
-                    (0, "PVPlayerEngine::DoSinkNodeReset() Tick=%d", OsclTickCount::TickCount()));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Tick=%d", OsclTickCount::TickCount()));
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeReset() In"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() In"));
 
-    // For each engine datapath in the list, initiate the setup sequence
-    iNumPendingNodeCmd = 0;
-    PVMFCommandId cmdid = -1;
-    int32 leavecode = 0;
-
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
+    uint32 i = 0;
+    //Destroy created temporal decoder node and sink node
+    for (i = 0; i < iTrackSelectionList.size(); ++i)
     {
-        if (iDatapathList[i].iSinkNode != NULL)
+        if (iTrackSelectionList[i].iTsDecNode != NULL)
         {
-            // Call Reseet() on the sink node
-            PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeDecNodeReset);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode, cmdid = iDatapathList[i].iSinkNode->Reset(iDatapathList[i].iSinkNodeSessionId, (OsclAny*) context));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeReset() Reseet on iSinkNode did a leave")););
-            if (cmdid != -1 && leavecode == 0)
+            if (iTrackSelectionList[i].iTsDecNodeCapConfigIF)
+                iTrackSelectionList[i].iTsDecNodeCapConfigIF = NULL;
+            PVMFStatus status = PVMFFailure;
+            status = iTrackSelectionList[i].iTsDecNode->Disconnect(iTrackSelectionList[i].iTsDecNodeSessionId);
+            if (status == PVMFFailure)
             {
-                ++iNumPendingNodeCmd;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Disconnect on dec node Failed"));
+                OSCL_ASSERT(false);
+            }
+            status = iTrackSelectionList[i].iTsDecNode->ThreadLogoff();
+            if (status == PVMFFailure)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() ThreadLogoff on dec node Failed"));
+                OSCL_ASSERT(false);
+            }
+            PVPlayerEngineUuidNodeMapping* iter = iNodeUuids.begin();
+            for (; iter != iNodeUuids.end(); ++iter)
+                if (iter->iNode == iTrackSelectionList[i].iTsDecNode)
+                    break;
+
+            if (iter != iNodeUuids.end())
+            {
+                bool release_status = false;
+
+                release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, iTrackSelectionList[i].iTsDecNode);
+                if (release_status == false)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Factory returned false while releasing the decnode"));
+                    OSCL_ASSERT(false);
+                    return PVMFFailure;
+                }
+
+                iNodeUuids.erase(iter);
+                iTrackSelectionList[i].iTsDecNode = NULL;
             }
             else
             {
-                FreeEngineContext(context);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() decnode not found"));
+                return PVMFFailure;
+            }
+        }
+        if (iTrackSelectionList[i].iTsSinkNode != NULL)
+        {
+            for (uint32 j = 0; j < iDatapathList.size(); j++)
+            {
+                if (iDatapathList[j].iSinkNode == iTrackSelectionList[i].iTsSinkNode)
+                {
+                    PVMFStatus status = PVMFFailure;
+                    status = iDatapathList[j].iSinkNode->Disconnect(iDatapathList[j].iSinkNodeSessionId);
+                    if (status == PVMFFailure)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Disconnect on sink node Failed"));
+                        OSCL_ASSERT(false);
+                    }
+                    status = iDatapathList[j].iSinkNode->ThreadLogoff();
+                    if (status == PVMFFailure)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() ThreadLogoff on sink node Failed"));
+                        OSCL_ASSERT(false);
+                    }
+                    if (iDatapathList[j].iSinkNodeCapConfigIF)
+                        iDatapathList[j].iSinkNodeCapConfigIF = NULL;
+                    if (iDatapathList[j].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_FILENAME)
+                    {
+                        PVFileOutputNodeFactory::DeleteFileOutput(iDatapathList[j].iSinkNode);
+                        iDatapathList[j].iSinkNode = NULL;
+                    }
+                    else if (iDatapathList[j].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_SINKNODE)
+                    {
+                        iDatapathList[j].iSinkNode = NULL;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Unsupported player data sink type"));
+                        return PVMFFailure;
+                    }
+                }
             }
         }
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeReset() Out"));
-    if (iNumPendingNodeCmd == 0)
+    // Also go through the datapathList and if for any datapath TrackInfo is not created, delete that datapath
+    for (i = 0; i < iDatapathList.size(); i++)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeReset() No datapath could be prepared!"));
+        if (iDatapathList[i].iTrackInfo == NULL)
+        {
+            // destroy the sinks first.
+            if (iDatapathList[i].iSinkNode != NULL)
+            {
+                PVMFStatus status = PVMFFailure;
+                status = iDatapathList[i].iSinkNode->Disconnect(iDatapathList[i].iSinkNodeSessionId);
+                if (status == PVMFFailure)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Disconnect on sink node Failed"));
+                    OSCL_ASSERT(false);
+                }
+                status = iDatapathList[i].iSinkNode->ThreadLogoff();
+                if (status == PVMFFailure)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() ThreadLogoff on sink node Failed"));
+                    OSCL_ASSERT(false);
+                }
+                if (iDatapathList[i].iSinkNodeCapConfigIF)
+                    iDatapathList[i].iSinkNodeCapConfigIF = NULL;
+                if (iDatapathList[i].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_FILENAME)
+                {
+                    PVFileOutputNodeFactory::DeleteFileOutput(iDatapathList[i].iSinkNode);
+                    iDatapathList[i].iSinkNode = NULL;
+                }
+                else if (iDatapathList[i].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_SINKNODE)
+                {
+                    iDatapathList[i].iSinkNode = NULL;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Unsupported player data sink type"));
+                    return PVMFFailure;
+                }
+            }
+
+            // next delete the decoder nodes
+            if (iDatapathList[i].iDecNode != NULL)
+            {
+                if (iDatapathList[i].iDecNodeCapConfigIF)
+                    iDatapathList[i].iDecNodeCapConfigIF = NULL;
+                PVMFStatus status = PVMFFailure;
+                status = iDatapathList[i].iDecNode->Disconnect(iDatapathList[i].iDecNodeSessionId);
+                if (status == PVMFFailure)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Disconnect on dec node Failed"));
+                    OSCL_ASSERT(false);
+                }
+                status = iDatapathList[i].iDecNode->ThreadLogoff();
+                if (status == PVMFFailure)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() ThreadLogoff on dec node Failed"));
+                    OSCL_ASSERT(false);
+                }
+                PVPlayerEngineUuidNodeMapping* iter = iNodeUuids.begin();
+                for (; iter != iNodeUuids.end(); ++iter)
+                    if (iter->iNode == iDatapathList[i].iDecNode)
+                        break;
+
+                if (iter != iNodeUuids.end())
+                {
+                    bool release_status = false;
+
+                    release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, iDatapathList[i].iDecNode);
+                    if (release_status == false)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Factory returned false while releasing the decnode"));
+                        OSCL_ASSERT(false);
+                        return PVMFFailure;
+                    }
+
+                    iNodeUuids.erase(iter);
+                    iDatapathList[i].iDecNode = NULL;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() decnode not found"));
+                    return PVMFFailure;
+                }
+            }
+        }
+    }
+
+    // Reset the Presentation Info list
+    iSourcePresInfoList.Reset();
+
+    // Clear the Track selection List
+    iTrackSelectionList.clear();
+
+    PVMFStatus cmdstatus = PVMFFailure;
+
+    // Notify the TargetNPT to the source node before calling Prepare.
+    if (iSourceNodePBCtrlIF)
+    {
+        cmdstatus = iSourceNodePBCtrlIF->NotifyTargetPositionSync(iTargetNPT);
+    }
+    if (cmdstatus == PVMFSuccess || cmdstatus == PVMFErrNotSupported)
+    {
+        // Prepare the source node
+        cmdstatus = DoSourceNodePrepare(aCmdId, aCmdContext);
+    }
+    if (cmdstatus != PVMFSuccess)
+    {
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Already EH pending, should never happen"));
+            return PVMFPending;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() DoSourceNodePrepare failed, Add EH command"));
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+        }
         return PVMFFailure;
     }
-    else
-    {
-        return PVMFSuccess;
-    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkDecCleanupSourcePrepare() Out"));
+    return PVMFSuccess;
 }
 
 PVMFStatus PVPlayerEngine::DoSourceNodePrepare(PVCommandId aCmdId, OsclAny* aCmdContext)
@@ -7063,21 +7567,20 @@
 
     if (iSourceNode == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodePrepare() Source node not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodePrepare() Source node not available."));
         return PVMFFailure;
     }
 
     // If source node is already in Prepared state then don't call Prepare()
     if (iSourceNode->GetState() == EPVMFNodePrepared)
     {
-        // For each engine datapath in the list, initiate the setup sequence
+        // Datapaths are already set during intelligent track selection, just query for optional interfaces.
         iNumPendingDatapathCmd = 0;
         for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
             if (iDatapathList[i].iTrackInfo != NULL)
             {
-                PVMFStatus cmdstatus = DoSetupSinkNode(iDatapathList[i], aCmdId, aCmdContext);
+                PVMFStatus cmdstatus = DoSinkNodeQueryInterfaceOptional(iDatapathList[i], aCmdId, aCmdContext);
                 if (cmdstatus == PVMFSuccess)
                 {
                     ++iNumPendingDatapathCmd;
@@ -7112,115 +7615,15 @@
     return PVMFSuccess;
 }
 
-
-PVMFStatus PVPlayerEngine::DoSetupSinkNode(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
-                    (0, "PVPlayerEngine::DoSetupSinkNode() for %s Tick=%d",
-                     aDatapath.iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
-
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetupSinkNode() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
-
-    int32 leavecode = 0;
-
-    // Check if datapath can be setup
-    if (aDatapath.iTrackInfo == NULL || aDatapath.iDataSink == NULL)
-    {
-        // No
-        OSCL_ASSERT(false);
-        return PVMFErrNotSupported;
-    }
-
-    // Determine the sink node based on PVPlayerDataSink
-    if (aDatapath.iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_FILENAME)
-    {
-        // Create file output node for sink
-        leavecode = 0;
-        OSCL_TRY(leavecode, aDatapath.iSinkNode = PVFileOutputNodeFactory::CreateFileOutput());
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() Creation of file output node did a leave!"));
-                             return PVMFErrNoMemory);
-
-        if (aDatapath.iSinkNode->ThreadLogon() != PVMFSuccess)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() ThreadLogon() on file output sink node failed"));
-            return PVMFFailure;
-        }
-
-        PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)(aDatapath.iSinkNode), this, (OsclAny*)(aDatapath.iSinkNode));
-        leavecode = 0;
-        OSCL_TRY(leavecode, aDatapath.iSinkNodeSessionId = aDatapath.iSinkNode->Connect(nodesessioninfo));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() Connect on  file output sink node did a leave!"));
-                             return PVMFFailure);
-
-        // Request the fileoutput node config interface
-        PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, aDatapath.iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeQueryFOConfigIF);
-
-        PVMFCommandId cmdid = -1;
-        leavecode = 0;
-        OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, PvmfFileOutputNodeConfigUuid, (PVInterface*&)aDatapath.iSinkNodeFOConfigIF, (OsclAny*)context));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             FreeEngineContext(context);
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() QueryInterface on file output sink node did a leave!"));
-                             return PVMFFailure);
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetupSinkNode() Out"));
-
-        return PVMFSuccess;
-    }
-    else if (aDatapath.iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_SINKNODE)
-    {
-        // Use the specified output node for sink node
-        aDatapath.iSinkNode = aDatapath.iDataSink->GetDataSinkNodeInterface();
-        if (aDatapath.iSinkNode == NULL)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() Passed in sink node is NULL"));
-            return PVMFFailure;
-        }
-
-        if (aDatapath.iSinkNode->ThreadLogon() != PVMFSuccess)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() ThreadLogon() on passed-in sink node failed"));
-            return PVMFFailure;
-        }
-
-        PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)aDatapath.iSinkNode, this, (OsclAny*)aDatapath.iSinkNode);
-        leavecode = 0;
-        OSCL_TRY(leavecode, aDatapath.iSinkNodeSessionId = aDatapath.iSinkNode->Connect(nodesessioninfo));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() Connect() on passed-in sink node did a leave!"));
-                             return PVMFFailure);
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetupSinkNode() Out"));
-        return DoSinkNodeQueryInterfaceOptional(aDatapath, aCmdId, aCmdContext);
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupSinkNode() Unsupported player data sink type"));
-        return PVMFErrNotSupported;
-    }
-}
-
-
 PVMFStatus PVPlayerEngine::DoSinkNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() Tick=%d", OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
     int32 leavecode = 0;
 
-    if (aDatapath.iSinkNode == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() Sink node not available. Asserting"));
-        OSCL_ASSERT(false);
-        return PVMFFailure;
-    }
-
     // Request optional extension interface from the sink node
     PVPlayerEngineContext* context = NULL;
     PVMFCommandId cmdid = -1;
@@ -7230,9 +7633,11 @@
     context = AllocateEngineContext(&aDatapath, aDatapath.iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeQuerySyncCtrlIF);
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, PvmfNodesSyncControlUuid, (PVInterface*&)aDatapath.iSinkNodeSyncCtrlIF, (OsclAny*)context));
+    aDatapath.iSinkNodePVInterfaceSyncCtrl = NULL;
+    OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, PvmfNodesSyncControlUuid, aDatapath.iSinkNodePVInterfaceSyncCtrl, (OsclAny*)context));
     if (leavecode)
     {
+        aDatapath.iSinkNodePVInterfaceSyncCtrl = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() QueryInterface on sink node for sync control IF did a leave!"));
     }
@@ -7246,9 +7651,11 @@
     PVUuid metadatauuid = KPVMFMetadataExtensionUuid;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, metadatauuid, (PVInterface*&)aDatapath.iSinkNodeMetadataExtIF, (OsclAny*)context));
+    aDatapath.iSinkNodePVInterfaceMetadataExt = NULL;
+    OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, metadatauuid, aDatapath.iSinkNodePVInterfaceMetadataExt, (OsclAny*)context));
     if (leavecode)
     {
+        aDatapath.iSinkNodePVInterfaceMetadataExt = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() QueryInterface on sink node for metadata IF did a leave!"));
     }
@@ -7257,22 +7664,6 @@
         ++aDatapath.iNumPendingCmd;
     }
 
-    // Query for Cap-Config IF
-    context = AllocateEngineContext(&aDatapath, aDatapath.iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeQueryCapConfigIF);
-    PVUuid capconfiguuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
-    cmdid = -1;
-    leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = aDatapath.iSinkNode->QueryInterface(aDatapath.iSinkNodeSessionId, capconfiguuid, (PVInterface*&)aDatapath.iSinkNodeCapConfigIF, (OsclAny*)context));
-    if (leavecode)
-    {
-        FreeEngineContext(context);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() QueryInterface on sink node for cap-config IF did a leave!"));
-    }
-    else
-    {
-        ++aDatapath.iNumPendingCmd;
-    }
-
     if (aDatapath.iNumPendingCmd > 0)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeQueryInterfaceOptional() Out"));
@@ -7285,118 +7676,17 @@
     }
 }
 
-
-PVMFStatus PVPlayerEngine::DoSetupDecNode(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
-                    (0, "PVPlayerEngine::DoSetupDecNode() for %s Tick=%d",
-                     aDatapath.iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
-
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetupDecNode() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
-    int32 leavecode = 0;
-
-    // Create decoder node if necessary
-    aDatapath.iSrcFormat = GetFormatIndex(aDatapath.iTrackInfo->getTrackMimeType().get_str());
-    aDatapath.iSinkFormat = aDatapath.iDataSink->GetDataSinkFormatType();
-    // Determine if decoder node is needed. In future, this will be replaced by querying
-    // the capability of data sink to match with source format type
-    if (IsDecNodeNeeded(aDatapath.iSrcFormat, aDatapath.iSinkFormat) == true)
-    {
-        Oscl_Vector<PVUuid, OsclMemAllocator> foundUuids;
-        // Query the player node registry for the required decoder node
-        if (iPlayerNodeRegistry.QueryRegistry(aDatapath.iSrcFormat, aDatapath.iSinkFormat, foundUuids) == PVMFSuccess)
-        {
-            if (foundUuids.empty())
-            {
-                // No matching node found
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupDecNode() No matching decoder node found"));
-                return PVMFFailure;
-            }
-
-            leavecode = 0;
-            OSCL_TRY(leavecode, aDatapath.iDecNode = iPlayerNodeRegistry.CreateNode(foundUuids[0]));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupDecNode() Error in creating DecNode"));
-                                 return PVMFFailure;);
-
-            iNodeUuids.push_back(PVPlayerEngineUuidNodeMapping(foundUuids[0], aDatapath.iDecNode));
-
-            if (aDatapath.iDecNode == NULL)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupDecNode() Dec node creation failed"));
-                return PVMFErrNoMemory;
-            }
-
-            if (aDatapath.iDecNode->ThreadLogon() != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupDecNode() ThreadLogon() on dec node failed"));
-                return PVMFFailure;
-            }
-
-            PVMFNodeSessionInfo nodesessioninfo(this, this, (OsclAny*)aDatapath.iDecNode, this, (OsclAny*)aDatapath.iDecNode);
-            leavecode = 0;
-            OSCL_TRY(leavecode, aDatapath.iDecNodeSessionId = aDatapath.iDecNode->Connect(nodesessioninfo));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupDecNode() Connect on dec node did a leave!"));
-                                 return PVMFFailure);
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetupDecNode() Out"));
-            return DoDecNodeQueryInterfaceOptional(aDatapath, aCmdId, aCmdContext);
-        }
-        else
-        {
-            // Registry query failed
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSetupDecNode() Registry query for dec node failed"));
-            return PVMFFailure;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSetupDecNode() Decoder node not needed"));
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSetupDecNode() Out"));
-    return PVMFErrNotSupported;
-}
-
-
-bool PVPlayerEngine::IsDecNodeNeeded(PVMFFormatType& aSrcFormat, PVMFFormatType& aSinkFormat)
-{
-    OSCL_ASSERT(aSrcFormat != PVMF_FORMAT_UNKNOWN);
-    OSCL_ASSERT(aSinkFormat != PVMF_FORMAT_UNKNOWN);
-
-    if ((aSinkFormat == PVMF_YUV420) || (aSinkFormat == PVMF_RGB16))
-    {
-        // For uncompressed video, decoder node is always needed
-        return true;
-    }
-    else if ((aSinkFormat >= PVMF_FIRST_UNCOMPRESSED_AUDIO && aSinkFormat <= PVMF_LAST_UNCOMPRESSED_AUDIO) &&
-             (!(aSrcFormat >= PVMF_FIRST_UNCOMPRESSED_AUDIO && aSrcFormat <= PVMF_LAST_UNCOMPRESSED_AUDIO)))
-    {
-        // For uncompressed audio, decoder node is needed if the source type is compressed
-        aSinkFormat = PVMF_PCM16;
-        return true;
-    }
-    else
-    {
-        // Set the sink format to be the same as the source format as default
-        aSinkFormat = aSrcFormat;
-        return false;
-    }
-}
-
-
 PVMFStatus PVPlayerEngine::DoDecNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVPlayerEngine::DoDecNodeQueryInterfaceOptional() Tick=%d", OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeQueryInterfaceOptional() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Check if the dec node is present
     if (aDatapath.iDecNode == NULL)
     {
-        OSCL_ASSERT(false);
-        return PVMFFailure;
+        return PVMFErrNotSupported;
     }
 
     PVPlayerEngineContext* context = NULL;
@@ -7410,9 +7700,11 @@
     PVUuid metadatauuid = KPVMFMetadataExtensionUuid;
     cmdid = -1;
     leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = aDatapath.iDecNode->QueryInterface(aDatapath.iDecNodeSessionId, metadatauuid, (PVInterface*&)aDatapath.iDecNodeMetadataExtIF, (OsclAny*)context));
+    aDatapath.iDecNodePVInterfaceMetadataExt = NULL;
+    OSCL_TRY(leavecode, cmdid = aDatapath.iDecNode->QueryInterface(aDatapath.iDecNodeSessionId, metadatauuid, aDatapath.iDecNodePVInterfaceMetadataExt, (OsclAny*)context));
     if (leavecode)
     {
+        aDatapath.iDecNodePVInterfaceMetadataExt = NULL;
         FreeEngineContext(context);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryInterfaceOptional() QueryInterface on dec node for metadata IF did a leave!"));
     }
@@ -7421,22 +7713,6 @@
         ++aDatapath.iNumPendingCmd;
     }
 
-    // Query for Cap-Config IF
-    context = AllocateEngineContext(&aDatapath, aDatapath.iDecNode, NULL, aCmdId, aCmdContext, PVP_CMD_DecNodeQueryCapConfigIF);
-    PVUuid capconfiguuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
-    cmdid = -1;
-    leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = aDatapath.iDecNode->QueryInterface(aDatapath.iDecNodeSessionId, capconfiguuid, (PVInterface*&)aDatapath.iDecNodeCapConfigIF, (OsclAny*)context));
-    if (leavecode)
-    {
-        FreeEngineContext(context);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDecNodeQueryInterfaceOptional() QueryInterface on dec node for cap-config IF did a leave!"));
-    }
-    else
-    {
-        ++aDatapath.iNumPendingCmd;
-    }
-
     if (aDatapath.iNumPendingCmd > 0)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDecNodeQueryInterfaceOptional() Out"));
@@ -7456,7 +7732,6 @@
                     (0, "PVPlayerEngine::DoDatapathPrepare() for %s Tick=%d",
                      aDatapath.iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathPrepare() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
     int32 leavecode = 0;
 
@@ -7489,7 +7764,6 @@
     // Prepare the datapath
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPPrepare);
 
-    aDatapath.iTrackActive = true;
     PVMFStatus retval = aDatapath.iDatapath->Prepare((OsclAny*)context);
     if (retval != PVMFSuccess)
     {
@@ -7505,19 +7779,6 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition() In"));
 
-    // get the current playback position, which needs to be passed to parsernode in QueryDataSourcePosition
-    // to check whether reposotioning done is forward or backward.
-    PVPPlaybackPosition curpos;
-    curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
-    GetPlaybackClockPosition(curpos);
-
-    // Initialize the playback position and clock variables
-    iActualMediaDataTS = 0;
-    iAdjustedMediaDataTS = 0;
-    iActualPlaybackPosition = 0;
-    iStartNPT = 0;
-    iStartMediaDataTS = 0;
-
     // Check if the source node has position control IF
     if (iSourceNodePBCtrlIF == NULL)
     {
@@ -7525,8 +7786,6 @@
         return PVMFErrNotSupported;
     }
 
-    PVMFCommandId cmdid = -1;
-
     uint32 timems = 0;
     if (iCurrentBeginPosition.iIndeterminate == false)
     {
@@ -7538,22 +7797,15 @@
             return retval;
         }
     }
-    iCurrentBeginPosition.iPosValue.millisec_value = timems;
-    iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+
+    PVMFCommandId cmdid = -1;
 
     if (iSeekToSyncPoint && iSyncPointSeekWindow > 0)
     {
-        // Need to query the data source on where playback would actually begin from
-        PVMFTimestamp startpos = iCurrentBeginPosition.iPosValue.millisec_value;
-
         PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeQueryDataSourcePosition);
 
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition() Calling QueryDataSourcePosition() Starting pos %d ms, SeekToSyncPt %d", startpos, iSeekToSyncPoint));
-
-        iActualPlaybackPosition = curpos.iPosValue.millisec_value;
-        iSeekPointBeforeTargetNPT = 0;
-        iSeekPointAfterTargetNPT = 0;
-
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition() Calling QueryDataSourcePosition() Starting pos %d ms, SeekToSyncPt %d", iTargetNPT, iSeekToSyncPoint));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition() Calling QueryDataSourcePosition() Starting pos %d ms, SeekToSyncPt %d", iTargetNPT, iSeekToSyncPoint));
         // As in case of MP4 file we need to call overload function of QueryDataSourcePosition which retruns
         // I frame before and after instead of actaul NPT, format type will be checked here to first find if
         // format-type is one of the MP4 varient
@@ -7564,26 +7816,24 @@
         bool mpeg4FormatType = false;
         if (formatType != NULL)
         {
-            switch (*formatType)
+            if ((pv_mime_strcmp((char*)formatType->getMIMEStrPtr(), PVMF_MIME_MPEG4FF)) == 0)
             {
-                case PVMF_MPEG4FF:
-                    mpeg4FormatType = true;
-                    break;
-
-                default:
-                    mpeg4FormatType = false;
-                    break;
+                mpeg4FormatType = true;
+            }
+            else
+            {
+                mpeg4FormatType = false;
             }
         }
         int32 leavecode = 0;
         if (mpeg4FormatType)
         {
-            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, startpos,
+            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, iTargetNPT,
                                         iSeekPointBeforeTargetNPT, iSeekPointAfterTargetNPT, (OsclAny*) context, iSeekToSyncPoint));
         }
         else
         {
-            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, startpos, iActualPlaybackPosition,
+            OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->QueryDataSourcePosition(iSourceNodeSessionId, iTargetNPT, iActualNPT,
                                         iSeekToSyncPoint, (OsclAny*)context));
         }
 
@@ -7593,15 +7843,10 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition() QueryDataSourcePosition on iSourceNodePBCtrlIF did a leave!"));
             if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
             {
-                // Since position qquery is not supported, assume the repositioning will
+                // Since position query is not supported, assume the repositioning will
                 // go to the requested position
-                // Determine the SetDataSourcePosition parameter based on  reposition settings
-                PVMFTimestamp requesttime = iCurrentBeginPosition.iPosValue.millisec_value;
-                iActualPlaybackPosition = requesttime;
-                bool seektosyncpt = true;
-
                 // Do the source positioning
-                return DoSourceNodeSetDataSourcePosition(aCmdId, aCmdContext, requesttime, seektosyncpt);
+                return DoSourceNodeSetDataSourcePosition(aCmdId, aCmdContext);
             }
             else
             {
@@ -7612,8 +7857,8 @@
     else
     {
         // Go straight to repositioning the data source
-        PVMFTimestamp startpos = iCurrentBeginPosition.iPosValue.millisec_value;
-        return DoSourceNodeSetDataSourcePosition(aCmdId, aCmdContext, startpos, iSeekToSyncPoint);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition: Straight call SetDataSourcePosition Starting pos %d ms, SeekToSyncPt %d", iTargetNPT, iSeekToSyncPoint));
+        return DoSourceNodeSetDataSourcePosition(aCmdId, aCmdContext);
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeQueryDataSourcePosition() Out"));
@@ -7622,7 +7867,7 @@
 }
 
 
-PVMFStatus PVPlayerEngine::DoSourceNodeSetDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext, PVMFTimestamp aTargetNPT, bool aSeekToSyncPoint)
+PVMFStatus PVPlayerEngine::DoSourceNodeSetDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePosition() In"));
 
@@ -7630,23 +7875,23 @@
     if (iSourceNodePBCtrlIF == NULL)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePosition() Playback control IF on source node not available"));
-
         // Since repositioning IF is not supported by this source node, assume the playback
         // will start from time 0
-        iActualPlaybackPosition = 0;
+        iActualNPT = 0;
         iActualMediaDataTS = 0;
-        iAdjustedMediaDataTS = 0;
+        iSkipMediaDataTS = 0;
         // Then continue to handle like success case
         iStartNPT = 0;
         iStartMediaDataTS = 0;
         // Save the actual starting position for GetPlaybackRange() query
-        iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+        iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
         iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+        iTargetNPT = iActualNPT;
 
         // Repositioning so reset the EOS received flag for each active datapath
         for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive)
+            if (iDatapathList[i].iDatapath)
             {
                 iDatapathList[i].iEndOfDataReceived = false;
             }
@@ -7659,46 +7904,47 @@
     // Set the position of the source node
     PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeSetDataSourcePosition);
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePosition() Calling SetDataSourcePosition() TargetNPT %d ms, SeekToSyncPoint %d", aTargetNPT, aSeekToSyncPoint));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePosition() Calling SetDataSourcePosition() TargetNPT %d ms, SeekToSyncPoint %d", iTargetNPT, iSeekToSyncPoint));
 
-    int32 tempStreamID = 0;
-    // if reposition points exists in between the actualPlaybackPosition and
-    // the currentPlaybackClock position, then the reposition data exists with
-    // in the graph, so we need to start a new media segment
-    PVPPlaybackPosition curpos;
-    curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
-    GetPlaybackClockPosition(curpos);
-
-    tempStreamID = iStreamID;
-
-    iActualMediaDataTS = 0;
-    iAdjustedMediaDataTS = 0;
-    iActualPlaybackPosition = 0;
     int32 leavecode = 0;
     PVMFCommandId cmdid = -1;
 
-    OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->SetDataSourcePosition(iSourceNodeSessionId, aTargetNPT, iActualPlaybackPosition, iActualMediaDataTS, aSeekToSyncPoint, tempStreamID, (OsclAny*)context));
+    OSCL_TRY(leavecode, cmdid = iSourceNodePBCtrlIF->SetDataSourcePosition(iSourceNodeSessionId, iTargetNPT, iActualNPT, iActualMediaDataTS, iSeekToSyncPoint, iStreamID, (OsclAny*)context));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          FreeEngineContext(context);
                          PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeSetDataSourcePosition() SetDataSourcePosition on iSourceNodePBCtrlIF did a leave!"));
                          if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
 {
     // Since this repositioning was not supported, assume the playback
-    // will start from time 0
-    iActualPlaybackPosition = 0;
-    iActualMediaDataTS = 0;
-    iAdjustedMediaDataTS = 0;
-    // Then continue to handle like success case
-    iStartNPT = 0;
-    iStartMediaDataTS = 0;
-    // Save the actual starting position for GetPlaybackRange() query
-    iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
-    iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+    // will start from same location as before reposition request.
+    PVPPlaybackPosition curpos;
+    curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+    GetPlaybackClockPosition(curpos);
+        uint32 clockcurpos = 0;
+        bool tmpbool = false;
+        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
 
-    // Repositioning so reset the EOS received flag for each active datapath
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
+        // since repositioning is not supported continue playing from current position.
+        iWatchDogTimerInterval = 0;
+        iActualNPT = curpos.iPosValue.millisec_value;
+        iActualMediaDataTS = clockcurpos;
+        iSkipMediaDataTS = clockcurpos;
+
+        iStartNPT = iActualNPT;
+        iStartMediaDataTS = iSkipMediaDataTS;
+
+        // also decrement the stream id as no skip will be called on MIO node.
+        --iStreamID;
+
+        // Save the actual starting position for GetPlaybackRange() query
+        iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
+        iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+        iTargetNPT = iActualNPT;
+
+        // Repositioning so reset the EOS received flag for each active datapath
+        for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive)
+            if (iDatapathList[i].iDatapath)
             {
                 iDatapathList[i].iEndOfDataReceived = false;
             }
@@ -7734,20 +7980,21 @@
 
             // Since repositioning IF is not supported by this source node, assume the playback
             // will start from time 0
-            iActualPlaybackPosition = 0;
+            iActualNPT = 0;
             iActualMediaDataTS = 0;
-            iAdjustedMediaDataTS = 0;
+            iSkipMediaDataTS = 0;
             // Then continue to handle like success case
             iStartNPT = 0;
             iStartMediaDataTS = 0;
             // Save the actual starting position for GetPlaybackRange() query
-            iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+            iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
             iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            iTargetNPT = iActualNPT;
 
             // Repositioning so reset the EOS flag for each active datapath
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     iDatapathList[i].iEndOfDataReceived = false;
                 }
@@ -7761,14 +8008,11 @@
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourceDirection() Calling SetDataSourcePosition() "));
 
-        iActualMediaDataTS = 0;
-        iAdjustedMediaDataTS = 0;
-        iActualPlaybackPosition = 0;
         int32 leavecode = 0;
         PVMFCommandId cmdid = -1;
         OSCL_TRY(leavecode, cmdid = iSourceNodeDirCtrlIF->SetDataSourceDirection(iSourceNodeSessionId
                                     , (iPlaybackDirection_New < 0) ? PVMF_DATA_SOURCE_DIRECTION_REVERSE : PVMF_DATA_SOURCE_DIRECTION_FORWARD
-                                    , iActualPlaybackPosition
+                                    , iActualNPT
                                     , iActualMediaDataTS
                                     , iOutsideTimebase
                                     , (OsclAny*)context));
@@ -7778,21 +8022,32 @@
                              if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
     {
         // Since this repositioning was not supported, assume the playback
-        // will start from time 0
-        iActualPlaybackPosition = 0;
-        iActualMediaDataTS = 0;
-        iAdjustedMediaDataTS = 0;
-        // Then continue to handle like success case
-        iStartNPT = 0;
-        iStartMediaDataTS = 0;
-        // Save the actual starting position for GetPlaybackRange() query
-        iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
-        iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+        // will start from same location as before repos request.
+        PVPPlaybackPosition curpos;
+        curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+        GetPlaybackClockPosition(curpos);
+            uint32 clockcurpos = 0;
+            bool tmpbool = false;
+            iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
 
-        // Repositioning so reset the EOS flag for each active datapath
-        for (uint32 i = 0; i < iDatapathList.size(); ++i)
+            // since repositioning is not supported continue playing from current position.
+            iWatchDogTimerInterval = 0;
+            iActualNPT = curpos.iPosValue.millisec_value;
+            iActualMediaDataTS = clockcurpos;
+            iSkipMediaDataTS = clockcurpos;
+
+            iStartNPT = iActualNPT;
+            iStartMediaDataTS = iSkipMediaDataTS;
+
+            // Save the actual starting position for GetPlaybackRange() query
+            iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
+            iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            iTargetNPT = iActualNPT;
+
+            // Repositioning so reset the EOS flag for each active datapath
+            for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     iDatapathList[i].iEndOfDataReceived = false;
                 }
@@ -7826,22 +8081,16 @@
         // Pause the playback clock
         bool clockpausedhere = iPlaybackClock.Pause();
 
-        // Stop the playback position status timer
-        StopPlaybackStatusTimer();
-
         // Set the new direction on the source node
         PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeSetDataSourceDirection);
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeSetDataSourceDirection() Calling SetDataSourceDirection() on source node."));
 
-        iActualPlaybackPosition = 0;
-        iActualMediaDataTS = 0;
-        iAdjustedMediaDataTS = 0;
         int32 leavecode = 0;
         PVMFCommandId cmdid = -1;
         OSCL_TRY(leavecode, cmdid = iSourceNodeDirCtrlIF->SetDataSourceDirection(iSourceNodeSessionId
                                     , (iPlaybackDirection_New < 0) ? PVMF_DATA_SOURCE_DIRECTION_REVERSE : PVMF_DATA_SOURCE_DIRECTION_FORWARD
-                                    , iActualPlaybackPosition
+                                    , iActualNPT
                                     , iActualMediaDataTS
                                     , iOutsideTimebase_New
                                     , (OsclAny*)context));
@@ -7851,9 +8100,7 @@
                              if (clockpausedhere)
     {
         // Resume the clock if paused in this function
-        iPlaybackClock.Start();
-            // To get regular play status events
-            StartPlaybackStatusTimer();
+        StartPlaybackClock();
         }
 
         if (leavecode == PVMFErrNotSupported || leavecode == PVMFErrArgument)
@@ -7882,8 +8129,7 @@
 
     if (iSourceNode == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeStart() Source node not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeStart() Source node not available."));
         return PVMFFailure;
     }
 
@@ -7910,17 +8156,9 @@
                     (0, "PVPlayerEngine::DoDatapathStart() for %s Tick=%d",
                      aDatapath.iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathStart() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
-    if (aDatapath.iTrackActive == false)
-    {
-        OSCL_ASSERT(false);
-        return PVMFErrNotSupported;
-    }
-
     // Start the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPStart);
 
     PVMFStatus retval = aDatapath.iDatapath->Start((OsclAny*)context);
@@ -7943,19 +8181,18 @@
 
     // Tell the sink nodes to skip the unneeded media data
     iNumPendingNodeCmd = 0;
-    PVMFCommandId cmdid = -1;
     int32 leavecode = 0;
 
     // Call SkipMediaData() for each active datapath with sink nodes that have the sync control IF
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive == true &&
+        if (iDatapathList[i].iDatapath &&
                 iDatapathList[i].iEndOfDataReceived == false &&
                 iDatapathList[i].iSinkNodeSyncCtrlIF)
         {
-            leavecode = 0;
             PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeSkipMediaData);
-            OSCL_TRY(leavecode, cmdid = iDatapathList[i].iSinkNodeSyncCtrlIF->SkipMediaData(iDatapathList[i].iSinkNodeSessionId, iActualMediaDataTS, iAdjustedMediaDataTS, iStreamID, iRenderSkipped, false, (OsclAny*) context));
+
+            leavecode = IssueSinkSkipMediaData(&(iDatapathList[i]), false, (OsclAny*) context);
             if (leavecode == 0)
             {
                 ++iNumPendingNodeCmd;
@@ -7989,49 +8226,57 @@
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStart() In, State=%d", iState));
 
+    if (GetPVPlayerState() == PVP_STATE_STARTED)
+    {
+        if (iState == PVP_ENGINE_STATE_AUTO_PAUSED)
+        {
+            // Engine in AUTO-PAUSED state since it recieved an Underflow event
+            // during Prepare. Set the engine state to STARTED and return success
+            // Wait for DataReady event for the playback to start.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::DoStart() Engine in auto-paused state, set it to started"));
+            SetEngineState(PVP_ENGINE_STATE_STARTED);
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStart() Engine already in Started State"));
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+        return PVMFSuccess;
+    }
+
+    if (iPlaybackPausedDueToEndOfClip)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStart() Playback already paused due to End of clip"));
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+        return PVMFSuccess;
+    }
     if (GetPVPlayerState() != PVP_STATE_PREPARED)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStart() Wrong engine state"));
         return PVMFErrInvalidState;
     }
 
-    if (iPlaybackClock.GetState() != OsclClock::RUNNING)
+    if (iNumPVMFInfoStartOfDataPending == 0)
     {
+        // start the clock only if Skip is complete and InfoStartOfData has been received
         // Enable the end time check if specified
         UpdateCurrentEndPosition(iCurrentEndPosition);
-
-        // Start the end time check if enabled
-        if (iEndTimeCheckEnabled)
+        StartPlaybackClock();
+    }
+    else
+    {
+        // Sink nodes have not reported InfoStartOfData yet.
+        // Check if WatchDogTimer has already been set or not,
+        // if Timer has not been set or has expired then set it to a default value timer.
+        if (!(iWatchDogTimer->IsBusy()))
         {
-            // Determine the check cycle based on interval setting in milliseconds
-            // and timer frequency of 100 millisec
-            int32 checkcycle = iEndTimeCheckInterval / 100;
-            if (checkcycle == 0)
-            {
-                ++checkcycle;
-            }
-            iPollingCheckTimer->Request(PVPLAYERENGINE_TIMERID_ENDTIMECHECK, 0, checkcycle, this, true);
-        }
-
-        // Start the playback clock
-        iPlaybackClock.Start();
-
-        // Notify data sinks that clock has started
-        for (uint32 i = 0; i < iDatapathList.size(); ++i)
-        {
-            if (iDatapathList[i].iTrackActive)
-            {
-                if (iDatapathList[i].iSinkNodeSyncCtrlIF)
-                {
-                    iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
-                }
-            }
+            // set a dafault timer
+            iWatchDogTimerInterval = 0;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::DoStart() Setting WatchDogTimer to a dafult value of 1 second"));
+            iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval); // this will set a timer to a default
+            iWatchDogTimer->Start();                                  // value of 1 sec. since iWatchDogTimerInterval is zero.
         }
     }
 
-    // To get regular play status events
-    StartPlaybackStatusTimer();
-
     SetEngineState(PVP_ENGINE_STATE_STARTED);
     EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
 
@@ -8048,16 +8293,32 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoPause() In"));
 
     // Check engine state
-    if (GetPVPlayerState() != PVP_STATE_STARTED)
+    switch (GetPVPlayerState())
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() Wrong engine state"));
-        return PVMFErrInvalidState;
+        case PVP_STATE_PAUSED :
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoPause() Engine already in Paused State"));
+            EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+            return PVMFSuccess;
+
+        case PVP_STATE_STARTED :
+            break;
+
+        case PVP_STATE_PREPARED :
+            if (aCmd.GetCmdType() == PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP)
+            {
+                //It is possible in repositioning to end use-case that
+                //engine receives StartofData and EndofData before Prepare
+                //completes. So we should not fail Pause, just process it.
+                break;
+            }
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() Wrong engine state"));
+            return PVMFErrInvalidState;
     }
 
-    // Send position update to app
-    TimeoutOccurred(PVPLAYERENGINE_TIMERID_PLAY_STATUS, -1);
-    // Stop the playback position status timer
-    StopPlaybackStatusTimer();
+    // Send position update to app.
+    SendPositionStatusUpdate();
 
     // Stop the end time check timer
     iPollingCheckTimer->Cancel(PVPLAYERENGINE_TIMERID_ENDTIMECHECK);
@@ -8075,7 +8336,6 @@
         }
     }
 
-
     // Pause the clock and notify sinks if not auto-paused
     uint32 i;
     if (iState != PVP_ENGINE_STATE_AUTO_PAUSED)
@@ -8085,7 +8345,7 @@
         // Notify data sinks that clock has paused
         for (i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+            if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
             {
                 iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStopped();
             }
@@ -8099,7 +8359,7 @@
 
     for (i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive)
+        if (iDatapathList[i].iDatapath)
         {
             if (iState == PVP_ENGINE_STATE_AUTO_PAUSED)
             {
@@ -8118,7 +8378,18 @@
             }
             else
             {
-                return retval;
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
+                {
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() Already EH pending, should never happen"));
+                    return PVMFPending;
+                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() DoDatapathPause Failed, Add EH command"));
+                iCommandCompleteStatusInErrorHandling = retval;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, NULL, NULL, NULL, false);
+                return PVMFPending;
             }
         }
     }
@@ -8131,13 +8402,25 @@
 
     if (retval != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() Pausing datapath and source node failed"));
-        return retval;
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() Already EH pending, should never happen"));
+            return PVMFPending;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoPause() Pausing datapath and source node failed, Add EH command"));
+        iCommandCompleteStatusInErrorHandling = retval;
+        iCommandCompleteErrMsgInErrorHandling = NULL;
+        AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, NULL, NULL, NULL, false);
+        return PVMFPending;
     }
 
+    // TEMP Until queued playback range is available
     // Reset the flag when doing a pause
     iChangePlaybackPositionWhenResuming = false;
     iChangePlaybackDirectionWhenResuming = false;
+    // END TEMP
 
     SetEngineState(PVP_ENGINE_STATE_PAUSING);
 
@@ -8152,18 +8435,14 @@
                     (0, "PVPlayerEngine::DoDatapathPause() for %s Tick=%d",
                      aDatapath.iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
+    if (aDatapath.iTrackInfo == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDatapathPause() TrackInfo not available, failure"));
+        return PVMFFailure;
+    }
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathPause() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
-    if (aDatapath.iTrackActive == false)
-    {
-        // Only active datapaths should be paused
-        OSCL_ASSERT(false);
-        return PVMFErrNotSupported;
-    }
-
     // Pause the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, -1);
 
     PVMFStatus retval = aDatapath.iDatapath->Pause((OsclAny*)context, aSinkPaused);
@@ -8183,8 +8462,7 @@
 
     if (iSourceNode == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodePause() Source node not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodePause() Source node not available"));
         return PVMFFailure;
     }
 
@@ -8210,7 +8488,12 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResume() In"));
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResume() iNumPendingSkipCompleteEvent: %d", iNumPendingSkipCompleteEvent));
 
-
+    if (GetPVPlayerState() == PVP_STATE_STARTED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoResume() Engine already in Started State"));
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+        return PVMFSuccess;
+    }
 
     // Check engine state
     if (GetPVPlayerState() != PVP_STATE_PAUSED)
@@ -8235,6 +8518,10 @@
         // ignore failure, continue on to Start
         if (retval != PVMFSuccess)
         {
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoChangePlaybackPositionNotSupported, puuid, NULL));
+            SendInformationalEvent(PVMFInfoChangePlaybackPositionNotSupported, OSCL_STATIC_CAST(PVInterface*, infomsg));
+            infomsg->removeRef();
             retval = DoSourceNodeStart(aCmd.GetCmdId(), aCmd.GetContext());
         }
     }
@@ -8245,6 +8532,10 @@
         // ignore failure, continue on to Start
         if (retval != PVMFSuccess)
         {
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoChangePlaybackPositionNotSupported, puuid, NULL));
+            SendInformationalEvent(PVMFInfoChangePlaybackPositionNotSupported, OSCL_STATIC_CAST(PVInterface*, infomsg));
+            infomsg->removeRef();
             retval = DoSourceNodeStart(aCmd.GetCmdId(), aCmd.GetContext());
         }
     }
@@ -8255,8 +8546,18 @@
 
     if (retval != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoResume() Resuming source node or changing position failed"));
-        return retval;
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoResume() Already EH pending, should never happen"));
+            return PVMFPending;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoResume() Resuming source node or changing position failed, Add EH command"));
+        iCommandCompleteStatusInErrorHandling = retval;
+        iCommandCompleteErrMsgInErrorHandling = NULL;
+        AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
+        return PVMFPending;
     }
 
     SetEngineState(PVP_ENGINE_STATE_RESUMING);
@@ -8266,7 +8567,7 @@
 }
 
 
-PVMFStatus PVPlayerEngine::AddToMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId)
+PVMFStatus PVPlayerEngine::AddToMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId, PVPlayerEngineDatapath* aEngineDatapath, PVMFNodeInterface* aNode)
 {
     // Validate the interface ptr
     if (aMetadataIF == NULL)
@@ -8278,6 +8579,8 @@
     PVPlayerEngineMetadataIFInfo mdifinfo;
     mdifinfo.iInterface = aMetadataIF;
     mdifinfo.iSessionId = aSessionId;
+    mdifinfo.iEngineDatapath = aEngineDatapath;
+    mdifinfo.iNode = aNode;
     int32 leavecode = 0;
     OSCL_TRY(leavecode, iMetadataIFList.push_back(mdifinfo));
     OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
@@ -8314,6 +8617,12 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStop() In"));
 
+    if (GetPVPlayerState() == PVP_STATE_INITIALIZED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStop() Engine already in Initialized State"));
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
+        return PVMFSuccess;
+    }
 
     if (GetPVPlayerState() != PVP_STATE_PREPARED &&
             GetPVPlayerState() != PVP_STATE_STARTED &&
@@ -8323,22 +8632,27 @@
         return PVMFErrInvalidState;
     }
 
-    // reset the stream id and repos related variables
-    iStreamID = 0;
-    iNumPVMFInfoStartOfDataPending = 0;
-    iNumPendingSkipCompleteEvent = 0;
-    if (iWatchDogTimer->IsBusy())
+    if (iReleaseMetadataValuesPending)
     {
-        iWatchDogTimer->Cancel();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::DoStop() Wrong engine Usage, Stop called without releasing metadata values"));
+        return PVMFErrReleaseMetadataValueNotDone;
     }
 
+    // reset the dataReady event boolean
+    iDataReadySent = false;
+
+    // reset all repos related variables
+    ResetReposVariables(true);
+
     // Stop the playback position status timer
     StopPlaybackStatusTimer();
 
     // Stop the playback clock
     iPlaybackClock.Stop();
     uint32 starttime = 0;
-    iPlaybackClock.SetStartTime32(starttime, OSCLCLOCK_MSEC);
+    bool overflow = 0;
+    iPlaybackClock.SetStartTime32(starttime, PVMF_MEDIA_CLOCK_MSEC, overflow);
     iPlaybackDirection = 1;
 
     // Reset the begin/end time variables
@@ -8364,7 +8678,7 @@
     iNumPendingDatapathCmd = 0;
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive == true)
+        if (iDatapathList[i].iDatapath)
         {
             PVMFStatus retcode = DoDatapathStop(iDatapathList[i], aCmd.GetCmdId(), aCmd.GetContext());
             if (retcode == PVMFSuccess)
@@ -8388,8 +8702,19 @@
 
     if (retval != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStop() Stopping datapath and source node failed"));
-        return retval;
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStop() Already EH pending, should never happen"));
+            return PVMFPending;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoStop() source node failed, go in Error handling, Add EH command"));
+        iCommandCompleteStatusInErrorHandling = retval;
+        iCommandCompleteErrMsgInErrorHandling = NULL;
+
+        AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
+        return PVMFPending;
     }
 
     SetEngineState(PVP_ENGINE_STATE_STOPPING);
@@ -8401,16 +8726,14 @@
 
 PVMFStatus PVPlayerEngine::DoDatapathStop(PVPlayerEngineDatapath& aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathStop() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
-
-    if (aDatapath.iTrackActive == false)
+    if (aDatapath.iTrackInfo == NULL)
     {
-        return PVMFErrNotSupported;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDatapathStop() TrackInfo not available, failure"));
+        return PVMFFailure;
     }
 
     // Stop the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPStop);
 
     PVMFStatus retval = aDatapath.iDatapath->Stop((OsclAny*)context);
@@ -8430,8 +8753,7 @@
 
     if (iSourceNode == NULL)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeStop() Source node not available. Asserting"));
-        OSCL_ASSERT(false);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeStop() Source node not available."));
         return PVMFFailure;
     }
 
@@ -8454,17 +8776,8 @@
 
 PVMFStatus PVPlayerEngine::DoDatapathTeardown(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathTeardown() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
-    if (aDatapath.iTrackActive == false)
-    {
-        return PVMFErrNotSupported;
-    }
-
-    // Teardown the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
-
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPTeardown);
 
     PVMFStatus retval = aDatapath.iDatapath->Teardown((OsclAny*)context);
@@ -8480,23 +8793,17 @@
 
 PVMFStatus PVPlayerEngine::DoDatapathReset(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathReset() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
-    if (aDatapath.iTrackActive == false)
-    {
-        return PVMFErrNotSupported;
-    }
-
     // Reset the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
-
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPReset);
 
     PVMFStatus retval = aDatapath.iDatapath->Reset((OsclAny*)context);
     if (retval != PVMFSuccess)
     {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoDatapathReset() Reset failed. Asserting"));
         FreeEngineContext(context);
+        OSCL_ASSERT(false);
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathReset() Out"));
@@ -8579,64 +8886,100 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoReset() In"));
 
-    // reset the stream id and repos related variables
-    iStreamID = 0;
-    iNumPVMFInfoStartOfDataPending = 0;
-    iNumPendingSkipCompleteEvent = 0;
-    if (iWatchDogTimer->IsBusy())
+    // set engine state to Resetting
+    SetEngineState(PVP_ENGINE_STATE_RESETTING);
+    iRollOverState = RollOverStateIdle; //reset roll over state to Idle, as engine is resetting itself
+
+    // reset all repos related variables
+    ResetReposVariables(true);
+
+    // Stop the playback position status timer
+    StopPlaybackStatusTimer();
+
+    // Stop the playback clock
+    iPlaybackClock.Stop();
+    uint32 starttime = 0;
+    bool overflow = 0;
+    iPlaybackClock.SetStartTime32(starttime, PVMF_MEDIA_CLOCK_MSEC, overflow);
+    iPlaybackDirection = 1;
+
+    // Reset the begin/end time variables
+    iCurrentBeginPosition.iIndeterminate = true;
+    iCurrentEndPosition.iIndeterminate = true;
+    iQueuedBeginPosition.iIndeterminate = true;
+    iQueuedEndPosition.iIndeterminate = true;
+
+    // Reset the paused-due-to-EOS flag
+    iPlaybackPausedDueToEndOfClip = false;
+
+    // Reset the Presentation Info list
+    iSourcePresInfoList.Reset();
+
+    // Clear the Track selection List
+    iTrackSelectionList.clear();
+
+    // Stop the end time check
+    if (iEndTimeCheckEnabled)
     {
-        iWatchDogTimer->Cancel();
+        iEndTimeCheckEnabled = false;
+        iPollingCheckTimer->Cancel(PVPLAYERENGINE_TIMERID_ENDTIMECHECK);
     }
 
     int32 leavecode = 0;
     PVMFStatus status = PVMFSuccess;
-    switch (GetPVPlayerState())
-    {
-        case PVP_STATE_IDLE: // already in final state
-            DoRemoveAllSinks();
 
+    if (iSourceNode)
+    {
+        if (iSourceNode->GetState() != EPVMFNodeCreated)
+        {
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
+
+            PVMFCommandId cmdid = -1;
+            leavecode = 0;
+            OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+            OSCL_FIRST_CATCH_ANY(leavecode,
+
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReset() Reset on iSourceNode did a leave!"));
+                                 FreeEngineContext(context);
+                                 OSCL_ASSERT(false);
+                                 return PVMFFailure);
+        }
+        else
+        {
+            // It is assumed that if SourceNode is in created state then datapaths if present,
+            // has to be in IDLE State
+            if (!iDatapathList.empty())
+            {
+                for (uint32 i = 0; i < iDatapathList.size(); ++i)
+                {
+                    if (!iDatapathList[i].iDatapath)
+                    {
+                        if (iDatapathList[i].iDatapath->iState != PVPDP_IDLE)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "PVPlayerEngine::DoReset() Source Node already in created state, Datapath not in idle state, asserting"));
+                            OSCL_ASSERT(false);
+                        }
+                    }
+                }
+                DoRemoveAllSinks();
+            }
             if (iDataSource)
             {
                 RemoveDataSourceSync(*iDataSource);
             }
+            SetEngineState(PVP_ENGINE_STATE_IDLE);
             EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
-            break;
-        case PVP_STATE_INITIALIZED:
-            DoRemoveAllSinks();
-            if (iSourceNode)
-            {
-                PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmd.GetCmdId(), aCmd.GetContext(), -1);
-
-                PVMFCommandId cmdid = -1;
-                leavecode = 0;
-                OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReset() Reset on iSourceNode did a leave!"));
-                                     FreeEngineContext(context);
-                                     return PVMFFailure);
-
-                SetEngineState(PVP_ENGINE_STATE_RESETTING);
-            }
-            else
-            {
-                SetEngineState(PVP_ENGINE_STATE_IDLE);
-                EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
-            }
-            break;
-        case PVP_STATE_PREPARED:
-        case PVP_STATE_STARTED:
-        case PVP_STATE_PAUSED:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReset() called in wrong engine state!"));
-            status = PVMFFailure;
-            break;
-        case PVP_STATE_ERROR:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReset() called during error state!"));
-            status = PVMFFailure;
-            break;
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoReset() unknown engine state!"));
-            status = PVMFFailure;
+        }
+    }
+    else
+    {
+        if (iDataSource)
+        {
+            RemoveDataSourceSync(*iDataSource);
+        }
+        SetEngineState(PVP_ENGINE_STATE_IDLE);
+        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoReset() Out"));
@@ -8645,138 +8988,12 @@
 
 PVMFStatus PVPlayerEngine::RemoveDataSourceSync(PVPlayerDataSource &aSrc)
 {
+    OSCL_UNUSED_ARG(aSrc);
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::RemoveDataSourceSync() In"));
 
-    if (GetPVPlayerState() != PVP_STATE_IDLE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RemoveDataSourceSync() Wrong engine state"));
-        // force cleanup
-        DoSourceNodeCleanup();
-        iDataSource = NULL;
-        return PVMFErrInvalidState;
-    }
-
-    // Clean up the trackinfo now because iSourceNode might have memfrags in them
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        // Destroy the track info if present
-        if (iDatapathList[i].iTrackInfo)
-        {
-            OSCL_DELETE(iDatapathList[i].iTrackInfo);
-            iDatapathList[i].iTrackInfo = NULL;
-        }
-        if (iDatapathList[i].iDatapath)
-            iDatapathList[i].iDatapath->SetSourceNode(NULL);
-    }
-
     // Destroy the source node if present
-    if (iSourceNode)
-    {
-        // Remove reference to the parser node init interface if available
-        if (iSourceNodeInitIF)
-        {
-            iSourceNodeInitIF->removeRef();
-            iSourceNodeInitIF = NULL;
-        }
-
-        // Remove reference to the parser node track sel interface if available
-        if (iSourceNodeTrackSelIF)
-        {
-            iPlayableList.Reset();
-            iPreferenceList.Reset();
-            iSourceNodeTrackSelIF->removeRef();
-            iSourceNodeTrackSelIF = NULL;
-            iTrackSelectionHelper = NULL;
-        }
-
-        // Remove reference to the parser node track level info interface if available
-        if (iSourceNodeTrackLevelInfoIF)
-        {
-            iSourceNodeTrackLevelInfoIF->removeRef();
-            iSourceNodeTrackLevelInfoIF = NULL;
-        }
-
-        // Remove reference to the parser node position control interface if available
-        if (iSourceNodePBCtrlIF)
-        {
-            iSourceNodePBCtrlIF->removeRef();
-            iSourceNodePBCtrlIF = NULL;
-        }
-
-        // Remove reference to the parser node direction control interface if available
-        if (iSourceNodeDirCtrlIF)
-        {
-            iSourceNodeDirCtrlIF->removeRef();
-            iSourceNodeDirCtrlIF = NULL;
-        }
-
-        // Remove reference to the parser node metadata interface if available
-        if (iSourceNodeMetadataExtIF)
-        {
-            RemoveFromMetadataInterfaceList(iSourceNodeMetadataExtIF, iSourceNodeSessionId);
-            iSourceNodeMetadataExtIF->removeRef();
-            iSourceNodeMetadataExtIF = NULL;
-        }
-
-        // Reset the duration value retrieved from source
-        iSourceDurationAvailable = false;
-        iSourceDurationInMS = 0;
-
-        // Remove reference to the parser node cap-config interface if available
-        if (iSourceNodeCapConfigIF)
-        {
-            iSourceNodeCapConfigIF->removeRef();
-            iSourceNodeCapConfigIF = NULL;
-        }
-
-        if (iSourceNodeCPMLicenseIF)
-        {
-            iSourceNodeCPMLicenseIF->removeRef();
-            iSourceNodeCPMLicenseIF = NULL;
-        }
-        iSourceNode->Disconnect(iSourceNodeSessionId);
-        iSourceNode->ThreadLogoff();
-
-        // search for matching uuid entry in list of instantiated nodes
-        PVPlayerEngineUuidNodeMapping* iter = iNodeUuids.begin();
-        for (; iter != iNodeUuids.end(); ++iter)
-            if (iter->iNode == iSourceNode)
-                break;
-
-        if (iter != iNodeUuids.end())
-        {
-            bool release_status = false;
-
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, iSourceNode));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 // force cleanup
-                                 DoSourceNodeCleanup();
-                                 iDataSource = NULL;
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RemoveDataSourceSync() Error in releasing SourceNode"));
-                                 return PVMFFailure;);
-
-            if (release_status == false)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RemoveDataSourceSync() Factory returned false while releasing the sourcenode"));
-                // force cleanup
-                DoSourceNodeCleanup();
-                iDataSource = NULL;
-                return PVMFFailure;
-            }
-
-            iNodeUuids.erase(iter);
-            iSourceNode = NULL;
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::RemoveDataSourceSync() unknown node"));
-            // force cleanup
-            DoSourceNodeCleanup();
-            iDataSource = NULL;
-            return PVMFFailure;
-        }
-    }
+    DoSourceNodeCleanup();
 
     // Remove Stored KVP Values
     DeleteKVPValues();
@@ -8798,7 +9015,7 @@
     if (GetPVPlayerState() != PVP_STATE_IDLE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoRemoveDataSource() called when engine is not in the IDLE state"));
-        return PVMFFailure;
+        return PVMFErrInvalidState;
     }
 
     if (iDataSource == NULL) // previously removed, e.g. during errorhandling
@@ -8829,22 +9046,73 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceUnderflowAutoPause() In"));
 
-    // Allow auto-pause only when playing
-    if (iState != PVP_ENGINE_STATE_STARTED)
+    /*
+     * Underflow can happen in the following States
+     * Prepared - Use-cases where-in Source Node reports DataReady and goes into
+     * underflow immediately when it starts to retrieve data.
+     * Started - This will be the most generic use-case where in the source node
+     * is retreiving data and because of low bandwidth conditions runs out of data.
+     * In such case Source Node will send an Underflow event to Engine.
+     * Paused - A rare use-case but can happen. Use-case where Source Node is about
+     * to run out of data and just before Source Node sends an Underflow event to
+     * engine, user presses Pause on Engine. Engine gets Pause from user and Underflow
+     * from Source Node back-to-back.
+     */
+    bool pauseSinkNodes = false;
+
+    switch (iState)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceUnderflowAutoPause() Invalid state so cancel auto-pause request!"));
-        return PVMFErrCancelled;
+        case PVP_ENGINE_STATE_PREPARED:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::DoSourceUnderflowAutoPause() in Prepared state"));
+            SetEngineState(PVP_ENGINE_STATE_AUTO_PAUSED);
+            break;
+
+        case PVP_ENGINE_STATE_STARTED:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::DoSourceUnderflowAutoPause() in Started state"));
+            pauseSinkNodes = true;
+            break;
+
+        case PVP_ENGINE_STATE_PAUSED:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::DoSourceUnderflowAutoPause() in Paused state"));
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::DoSourceUnderflowAutoPause() Invalid state so cancel auto-pause request!"));
+            return PVMFErrCancelled;
+    }
+
+    // Stop the watchdog timer if active. We will Start the timer again in auto-resume.
+    // this should only be done when engine is waiting for StartofData info event
+    // after reposition.
+    if (iNumPVMFInfoStartOfDataPending > 0)
+    {
+        if (iWatchDogTimer->IsBusy())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::DoSourceUnderflowAutoPause - Pause after setplayback, Cancelling Watchdog timer, iNumPVMFInfoStartOfDataPending=%d", iNumPVMFInfoStartOfDataPending));
+            iWatchDogTimer->Cancel();
+        }
+    }
+
+    if (!pauseSinkNodes)
+    {
+        // Sink nodes already in Paused state or have no data to process, so
+        // no need to call Pause on the sink nodes.
+        return PVMFErrNotSupported;
     }
 
     // Pause the playback clock
     iPlaybackClock.Pause();
-    // Stop the playback position status timer
-    StopPlaybackStatusTimer();
+
     uint32 i;
     // Notify data sinks that clock has paused
     for (i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+        if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
         {
             iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStopped();
         }
@@ -8856,7 +9124,7 @@
     iNumPendingDatapathCmd = 0;
     for (i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive == true)
+        if (iDatapathList[i].iDatapath)
         {
             retval = DoSinkNodePause(iDatapathList[i], aCmd.GetCmdId(), aCmd.GetContext());
             if (retval == PVMFSuccess)
@@ -8887,25 +9155,22 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceDataReadyAutoResume() In"));
 
-    //Don't need to worry about transitional states(...ING). Because auto-pause/resume cmds are just regular engine cmds and won't be interrupted by normal ones
-    //Underflow->Pause->Resume->DataReady. Then we start clock in here. Because clock is not started at Resume due to underflow.
-    //Resume starts playback clock. Souce node pauses it again. Engine stays in STARTED state rather than AUTO_PAUSED state.
-    //Underflow->Pause->DataReady->Resume. Then we CANNOT start clock in here. Because clock is paused by app.
-    //After Pause done, the engine is in PAUSED state.
-    if (iPlaybackClock.GetState() == OsclClock::PAUSED && iState == PVP_ENGINE_STATE_STARTED)
+    // Don't need to worry about transitional states(...ING).
+    // Auto-pause/resume cmds are just regular engine cmds and won't be interrupted by normal ones
+    // First check to see if it is Underflow->Pause->Resume->DataReady usecase.
+    // In this usecase, engine starts playback clock in Resume, source nodes are sposed to pause the
+    // clock, since they are the ones in underflow. Once source nodes report dataready, engine would
+    // already be in STARTED state. So if the clock is still paused, then start it here.
+    if (iPlaybackClock.GetState() == PVMFMediaClock::PAUSED && iState == PVP_ENGINE_STATE_STARTED)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Clock Start"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceDataReadyAutoResume: Clock Start from paused state"));
 
-        iPlaybackClock.Start();
-        // To get regular play status events
-        StartPlaybackStatusTimer();
+        StartPlaybackClock();
 
-        // Notify all sink nodes that have sync control IF that clock has started.
-        // This is necessary because engine cannot assume all data sinks implement
-        // the clock state observer.
+        // Notify all sink nodes that have sync control IF that clock has started
         for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+            if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
             {
                 iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
             }
@@ -8914,22 +9179,75 @@
         return PVMFErrNotSupported;
     }
 
-    // Allow auto-resume only when auto-paused
+    // Next check to see if it is Underflow->Pause->DataReady->Resume usecase.
+    // Then we CANNOT start clock in here, because clock is paused by app.
+    // After Pause done, the engine is in PAUSED state. By allowing auto-resume only when
+    // auto-paused we deal with this usecase ok.
     if (iState != PVP_ENGINE_STATE_AUTO_PAUSED)
     {
-        //if in these two states, the engine has NOT started yet. It is very likely the app is waiting for DataReady event to call engine Start()
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceDataReadyAutoResume() Invalid state %d", iState));
         //return PVMFErrNotSupported so the the DataReady can be sent, depending on iDataReadySent flag.
         return PVMFErrNotSupported;
     }
 
+    // Next check to see if it is:
+    // Underflow->Pause->SetPlaybackRange->Resume->DataReady or
+    // Prepare->Underflow->Start->DataReady
+    // or some other usecase, where we are still waiting on PVMFInfoStartOfData.
+    // Here if all PVMFInfoStartofData have not been received yet,
+    // then iNumPVMFInfoStartOfDataPending would be non-zero,
+    // clock would still be in Stopped state
+    // and Engine would be in Started state.
+    // Here just send NotSupported so engine can send DataReady Event to the app.
+    // and set the watchdog timer which was cancelled when underflow was recieved.
+    if (iPlaybackClock.GetState() == PVMFMediaClock::STOPPED &&
+            iState == PVP_ENGINE_STATE_STARTED)
+    {
+        if (iNumPVMFInfoStartOfDataPending > 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVPlayerEngine::DoSourceDataReadyAutoResume: Clock in Stopped state, waiting for StartofData"));
+
+            if (iWatchDogTimerInterval > 0)
+            {
+                if (iWatchDogTimer->IsBusy())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                    (0, "PVPlayerEngine::DoSourceDataReadyAutoResume - Pause after setplayback, Cancelling Watchdog timer, iNumPVMFInfoStartOfDataPending=%d", iNumPVMFInfoStartOfDataPending));
+                    iWatchDogTimer->Cancel();
+                }
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                (0, "PVPlayerEngine::DoSourceDataReadyAutoResume Setting WatchDogTimer for %d ms, iNumPVMFInfoStartOfDataPending=%d",
+                                 iWatchDogTimerInterval, iNumPVMFInfoStartOfDataPending));
+                iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
+                iWatchDogTimer->Start();
+            }
+        }
+        else if (iNumPVMFInfoStartOfDataPending == 0)
+        {
+            StartPlaybackClock();
+
+            // Notify data sinks that clock has started
+            for (uint32 i = 0; i < iDatapathList.size(); ++i)
+            {
+                if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
+                {
+                    iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
+                }
+            }
+        }
+        //return PVMFErrNotSupported so the the DataReady can be sent, depending on iDataReadySent flag.
+        return PVMFErrNotSupported;
+    }
+
     PVMFStatus retval = PVMFErrNotSupported;
 
     // Resume all active sink nodes
     iNumPendingDatapathCmd = 0;
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive == true)
+        if (iDatapathList[i].iDatapath)
         {
             retval = DoSinkNodeResume(iDatapathList[i], aCmd.GetCmdId(), aCmd.GetContext());
             if (retval == PVMFSuccess)
@@ -8958,16 +9276,14 @@
 
 PVMFStatus PVPlayerEngine::DoSinkNodePause(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodePause() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
-    if (aDatapath.iTrackActive == false)
+    if (!(aDatapath.iTrackInfo) || !(aDatapath.iSinkNode))
     {
         return PVMFErrNotSupported;
     }
 
     // Pause the sink node
-    OSCL_ASSERT(aDatapath.iSinkNode != NULL);
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, aDatapath.iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeAutoPause);
 
     PVMFCommandId cmdid = -1;
@@ -8986,16 +9302,14 @@
 
 PVMFStatus PVPlayerEngine::DoSinkNodeResume(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
 {
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSinkNodeResume() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
 
-    if (aDatapath.iTrackActive == false)
+    if (!(aDatapath.iTrackInfo) || !(aDatapath.iSinkNode))
     {
         return PVMFErrNotSupported;
     }
 
     // Start the sink node to resume
-    OSCL_ASSERT(aDatapath.iSinkNode != NULL);
     PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, aDatapath.iSinkNode, NULL, aCmdId, aCmdContext, PVP_CMD_SinkNodeAutoResume);
 
     PVMFCommandId cmdid = -1;
@@ -9011,449 +9325,6 @@
     return PVMFSuccess;
 }
 
-
-PVMFStatus PVPlayerEngine::DoCancelDueToError(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelDueToError() In: iCurrentContextList.size() %d",
-                    iCurrentContextList.size()));
-
-    int32 leavecode = 0;
-    if (iCurrentContextList.empty() == false)
-    {
-        // Issue cancel commands
-        // Determine where the pending commands were issued to and then cancel them
-        iPendingCancelDueToErrorRequest = 0;
-        for (uint32 i = 0; i < iCurrentContextList.size(); ++i)
-        {
-            if (iCurrentContextList[i]->iNode)
-            {
-                if (iCurrentContextList[i]->iNode == iSourceNode)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelDueToError() Calling CancelAllCommands() on source node"));
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, iSourceNode->CancelAllCommands(iSourceNodeSessionId, (OsclAny*)&iPendingCancelDueToErrorRequest));
-                    if (leavecode == 0)
-                    {
-                        ++iPendingCancelDueToErrorRequest;
-                    }
-                }
-                else if (iCurrentContextList[i]->iEngineDatapath != NULL)
-                {
-                    if (iCurrentContextList[i]->iNode == iCurrentContextList[i]->iEngineDatapath->iSinkNode)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelDueToError() Calling CancelAllCommands() on sink node"));
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, iCurrentContextList[i]->iNode->CancelAllCommands(iCurrentContextList[i]->iEngineDatapath->iSinkNodeSessionId, (OsclAny*)&iPendingCancelDueToErrorRequest));
-                        if (leavecode == 0)
-                        {
-                            ++iPendingCancelDueToErrorRequest;
-                        }
-                    }
-                    else if (iCurrentContextList[i]->iNode == iCurrentContextList[i]->iEngineDatapath->iDecNode)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelDueToError() Calling CancelAllCommands() on dec node"));
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, iCurrentContextList[i]->iNode->CancelAllCommands(iCurrentContextList[i]->iEngineDatapath->iDecNodeSessionId, (OsclAny*)&iPendingCancelDueToErrorRequest));
-                        if (leavecode == 0)
-                        {
-                            ++iPendingCancelDueToErrorRequest;
-                        }
-                    }
-                    else
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() Unknown node type. Asserting"));
-                        OSCL_ASSERT(false);
-                    }
-                }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() Unknown node. Asserting"));
-                    OSCL_ASSERT(false);
-                }
-            }
-            else if (iCurrentContextList[i]->iDatapath != NULL)
-            {
-                if (iCurrentContextList[i]->iEngineDatapath != NULL)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelDueToError() Calling CancelCommand() on datapath"));
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, iCurrentContextList[i]->iDatapath->CancelCommand((OsclAny*)&iPendingCancelDueToErrorRequest));
-                    if (leavecode == 0)
-                    {
-                        ++iPendingCancelDueToErrorRequest;
-                    }
-                }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() Unknown datapath. Asserting"));
-                    OSCL_ASSERT(false);
-                }
-            }
-            else
-            {
-                // Either a node or datapath should be pending
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() No pending node or datapath. Asserting"));
-                OSCL_ASSERT(false);
-            }
-        }
-
-        // Reset the pending node/datapath cmd counters
-        iNumPendingNodeCmd = 0;
-        iNumPendingDatapathCmd = 0;
-
-        if (iPendingCancelDueToErrorRequest > 0)
-        {
-            // Deactivate the engine AO if active
-            // to avoid processing the next engine command in queue
-            if (IsBusy())
-            {
-                Cancel();
-            }
-
-            // Put in an internal engine command in the current command queue
-            // to prevent the next command in queue from being processed
-            PVPlayerEngineCommand cmd(PVP_ENGINE_COMMAND_CANCEL_DUE_TO_ERROR, -1, NULL, NULL, false);
-
-            leavecode = 0;
-            OSCL_ASSERT(iCurrentCmd.empty() == true);
-            OSCL_TRY(leavecode, iCurrentCmd.push_front(cmd));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() Cancel-due-to-error command could not be pushed onto iCurrentCmd vector. Asserting"));
-                                 OSCL_ASSERT(false);
-                                 return PVMFErrNoMemory;);
-
-            // Put the same command in the cancel command queue
-            leavecode = 0;
-            OSCL_ASSERT(iCmdToCancel.empty() == true);
-            OSCL_TRY(leavecode, iCmdToCancel.push_front(cmd));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() Cancel-due-to-error command could not be pushed onto iCmdToCancel vector. Asserting"));
-                                 OSCL_ASSERT(false);
-                                 return PVMFErrNoMemory;);
-        }
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCancelDueToError() % pending cancels.", iPendingCancelDueToErrorRequest));
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCancelDueToError() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVPlayerEngine::DoStopDueToError(PVPlayerEngineCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToError() In"));
-
-    SetEngineState(PVP_ENGINE_STATE_HANDLINGERROR);
-    iErrorOccurredDuringErrorHandling = false;
-
-    // Stop the playback position status timer
-    StopPlaybackStatusTimer();
-
-    // Stop the playback clock
-    iPlaybackClock.Stop();
-    uint32 starttime = 0;
-    iPlaybackClock.SetStartTime32(starttime, OSCLCLOCK_MSEC);
-
-    // Reset the begin/end time variables
-    iCurrentBeginPosition.iIndeterminate = true;
-    iCurrentEndPosition.iIndeterminate = true;
-    iQueuedBeginPosition.iIndeterminate = true;
-    iQueuedEndPosition.iIndeterminate = true;
-
-    // Reset the paused-due-to-EOS flag
-    iPlaybackPausedDueToEndOfClip = false;
-
-    // Stop the end time check
-    if (iEndTimeCheckEnabled)
-    {
-        iEndTimeCheckEnabled = false;
-        iPollingCheckTimer->Cancel(PVPLAYERENGINE_TIMERID_ENDTIMECHECK);
-    }
-
-    PVMFStatus retval = PVMFFailure;
-
-    // Start the stopping sequence
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        if (iDatapathList[i].iTrackActive == true)
-        {
-            PVMFStatus retcode = DoDatapathStopDueToError(iDatapathList[i], aCmd.GetCmdId(), aCmd.GetContext());
-            if (retcode == PVMFSuccess)
-            {
-                ++iNumPendingDatapathCmd;
-            }
-        }
-    }
-
-    if (iNumPendingDatapathCmd == 0)
-    {
-        // No datapath to stop so stop the source node
-        retval = DoSourceNodeStopDueToError(aCmd.GetCmdId(), aCmd.GetContext());
-
-        if (retval != PVMFSuccess)
-        {
-            // If stop could not be initiated, complete it and issue a reset command
-            EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFFailure);
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoStopDueToError() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVPlayerEngine::DoDatapathStopDueToError(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathStopDueToError() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
-
-    if (aDatapath.iTrackActive == false)
-    {
-        return PVMFErrNotSupported;
-    }
-
-    // Stop the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
-    PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPStop);
-
-    PVMFStatus retval = aDatapath.iDatapath->Stop((OsclAny*)context, true);
-    if (retval != PVMFSuccess)
-    {
-        FreeEngineContext(context);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathStopDueToError() Out"));
-    return retval;
-}
-
-
-PVMFStatus PVPlayerEngine::DoSourceNodeStopDueToError(PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeStopDueToError() In"));
-
-    if (iSourceNode == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeStopDueToError() Source node not available. Asserting"));
-        OSCL_ASSERT(false);
-        return PVMFFailure;
-    }
-
-    // Stop the source node
-    PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmdId, aCmdContext, PVP_CMD_SourceNodeStop);
-
-    PVMFCommandId cmdid = -1;
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, cmdid = iSourceNode->Stop(iSourceNodeSessionId, (OsclAny*)context));
-    OSCL_FIRST_CATCH_ANY(leavecode,
-                         FreeEngineContext(context);
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeStopDueToError() Stop on iSourceNode did a leave!"));
-                         return PVMFFailure);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoSourceNodeStopDueToError() Out"));
-
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVPlayerEngine::DoDatapathTeardownDueToError(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathTeardownDueToError() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
-
-    if (aDatapath.iTrackActive == false)
-    {
-        return PVMFErrNotSupported;
-    }
-
-    // Teardown the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
-    PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPTeardown);
-
-    PVMFStatus retval = aDatapath.iDatapath->Teardown((OsclAny*)context, true);
-    if (retval != PVMFSuccess)
-    {
-        FreeEngineContext(context);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathTeardownDueToError() Out"));
-    return retval;
-}
-
-
-PVMFStatus PVPlayerEngine::DoDatapathResetDueToError(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext)
-{
-    OSCL_ASSERT(aDatapath.iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathResetDueToError() In %s", aDatapath.iTrackInfo->getTrackMimeType().get_cstr()));
-
-    if (aDatapath.iTrackActive == false)
-    {
-        return PVMFErrNotSupported;
-    }
-
-    // Reset the datapath
-    OSCL_ASSERT(aDatapath.iDatapath != NULL);
-    PVPlayerEngineContext* context = AllocateEngineContext(&aDatapath, NULL, aDatapath.iDatapath, aCmdId, aCmdContext, PVP_CMD_DPReset);
-
-    PVMFStatus retval = aDatapath.iDatapath->Reset((OsclAny*)context, true);
-    if (retval != PVMFSuccess)
-    {
-        FreeEngineContext(context);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathResetDueToError() Out"));
-    return retval;
-}
-
-
-PVMFStatus PVPlayerEngine::DoResetDueToError(PVPlayerEngineCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToError() In"));
-
-    SetEngineState(PVP_ENGINE_STATE_HANDLINGERROR);
-    iErrorOccurredDuringErrorHandling = false;
-
-    int32 leavecode = 0;
-    PVMFCommandId cmdid = -1;
-
-
-    if (iSourceNode)
-    {
-        // Remove reference to the parser node init interface if available
-        if (iSourceNodeInitIF)
-        {
-            iSourceNodeInitIF->removeRef();
-            iSourceNodeInitIF = NULL;
-        }
-
-        // Remove reference to the parser node track sel interface if available
-        if (iSourceNodeTrackSelIF)
-        {
-            iPlayableList.Reset();
-            iPreferenceList.Reset();
-            iSourceNodeTrackSelIF->removeRef();
-            iSourceNodeTrackSelIF = NULL;
-            iTrackSelectionHelper = NULL;
-        }
-
-        // Remove reference to the parser node track level info interface if available
-        if (iSourceNodeTrackLevelInfoIF)
-        {
-            iSourceNodeTrackLevelInfoIF->removeRef();
-            iSourceNodeTrackLevelInfoIF = NULL;
-        }
-
-        // Remove reference to the parser node position control interface if available
-        if (iSourceNodePBCtrlIF)
-        {
-            iSourceNodePBCtrlIF->removeRef();
-            iSourceNodePBCtrlIF = NULL;
-        }
-
-        // Remove reference to the parser node direction control interface if available
-        if (iSourceNodeDirCtrlIF)
-        {
-            iSourceNodeDirCtrlIF->removeRef();
-            iSourceNodeDirCtrlIF = NULL;
-        }
-
-        // Remove reference to the parser node metadata interface if available
-        if (iSourceNodeMetadataExtIF)
-        {
-            RemoveFromMetadataInterfaceList(iSourceNodeMetadataExtIF, iSourceNodeSessionId);
-            iSourceNodeMetadataExtIF->removeRef();
-            iSourceNodeMetadataExtIF = NULL;
-        }
-
-        // Reset the duration value retrieved from source
-        iSourceDurationAvailable = false;
-        iSourceDurationInMS = 0;
-
-        // Remove reference to the parser node cap-config interface if available
-        if (iSourceNodeCapConfigIF)
-        {
-            iSourceNodeCapConfigIF->removeRef();
-            iSourceNodeCapConfigIF = NULL;
-        }
-
-        if (iSourceNodeCPMLicenseIF)
-        {
-            iSourceNodeCPMLicenseIF->removeRef();
-            iSourceNodeCPMLicenseIF = NULL;
-        }
-
-        // Reset the source node
-        PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, aCmd.GetCmdId(), aCmd.GetContext(), PVP_CMD_SourceNodeReset);
-        cmdid = -1;
-        leavecode = 0;
-        OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             FreeEngineContext(context);
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoResetDueToError() Reset on iSourceNode did a leave!"));
-                            );
-
-        if (leavecode != 0)
-        {
-            FreeEngineContext(context);
-            // If reset could not be initiated, complete it and issue a cleanup command
-            EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFFailure);
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-        }
-
-
-    }
-    else
-    {
-        // Ready to be in idle state so complete the reset command
-        SetEngineState(PVP_ENGINE_STATE_IDLE);
-        EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoResetDueToError() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVPlayerEngine::DoCleanupDueToError(PVPlayerEngineCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCleanupDueToError() In"));
-
-    SetEngineState(PVP_ENGINE_STATE_HANDLINGERROR);
-    iErrorOccurredDuringErrorHandling = false;
-
-    // Wipe everything out
-    iPollingCheckTimer->Clear();
-
-    // Clean up the datapaths
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
-    {
-        DoEngineDatapathCleanup(iDatapathList[i]);
-    }
-    iDatapathList.clear();
-
-    // Clean up the source node
-    DoSourceNodeCleanup();
-
-    // Return all the engine context
-    while (!iCurrentContextList.empty())
-    {
-        OSCL_ASSERT(iCurrentContextList[0] != aCmd.GetContext());
-        FreeEngineContext(iCurrentContextList[0]);
-    }
-
-    iMetadataIFList.clear();
-
-    SetEngineState(PVP_ENGINE_STATE_IDLE);
-    EngineCommandCompleted(aCmd.GetCmdId(), aCmd.GetContext(), PVMFSuccess);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCleanupDueToError() Out"));
-    return PVMFSuccess;
-}
-
-
 void PVPlayerEngine::DoEngineDatapathTeardown(PVPlayerEngineDatapath& aDatapath)
 {
     if (aDatapath.iTrackInfo)
@@ -9476,8 +9347,19 @@
 
     if (aDatapath.iSinkNode)
     {
-        aDatapath.iSinkNode->Disconnect(aDatapath.iSinkNodeSessionId);
-        aDatapath.iSinkNode->ThreadLogoff();
+        PVMFStatus status = PVMFFailure;
+        status = aDatapath.iSinkNode->Disconnect(aDatapath.iSinkNodeSessionId);
+        if (status == PVMFFailure)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoEngineDatapathTeardown() Disconnect on Sink Node Failed"));
+            OSCL_ASSERT(false);
+        }
+        status = aDatapath.iSinkNode->ThreadLogoff();
+        if (status == PVMFFailure)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoEngineDatapathTeardown() Threadlogoff on SinkNode Failed"));
+            OSCL_ASSERT(false);
+        }
 
         // Remove sync ctrl IF if available
         if (aDatapath.iSinkNodeSyncCtrlIF)
@@ -9534,9 +9416,19 @@
             aDatapath.iDecNodeCapConfigIF = NULL;
         }
 
-
-        aDatapath.iDecNode->Disconnect(aDatapath.iDecNodeSessionId);
-        aDatapath.iDecNode->ThreadLogoff();
+        PVMFStatus status = PVMFFailure;
+        status = aDatapath.iDecNode->Disconnect(aDatapath.iDecNodeSessionId);
+        if (status == PVMFFailure)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoEngineDatapathTeardown() Disconnect on dec node Failed"));
+            OSCL_ASSERT(false);
+        }
+        status = aDatapath.iDecNode->ThreadLogoff();
+        if (status == PVMFFailure)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoEngineDatapathTeardown() ThreadLogoff on dec node Failed"));
+            OSCL_ASSERT(false);
+        }
 
         // search for matching uuid entry in list of instantiated nodes
         PVPlayerEngineUuidNodeMapping* iter = iNodeUuids.begin();
@@ -9548,11 +9440,7 @@
         {
             bool release_status = false;
 
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, aDatapath.iDecNode));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoEngineDatapathTeardown() Error in releasing DecNode"));
-                                 return;);
+            release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, aDatapath.iDecNode);
 
             if (release_status == false)
             {
@@ -9570,8 +9458,6 @@
         }
     }
 
-    aDatapath.iTrackActive = false;
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoEngineDatapathTeardown() Out"));
 }
 
@@ -9603,8 +9489,6 @@
         aDatapath.iTrackInfo = NULL;
     }
 
-    aDatapath.iTrackActive = false;
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoEngineDatapathCleanup() Out"));
 }
 
@@ -9684,9 +9568,24 @@
             iSourceNodeCPMLicenseIF->removeRef();
             iSourceNodeCPMLicenseIF = NULL;
         }
-        iSourceNode->Disconnect(iSourceNodeSessionId);
+        // Reset the Presentation Info list
+        iSourcePresInfoList.Reset();
+
+        PVMFStatus status = PVMFFailure;
+        status = iSourceNode->Disconnect(iSourceNodeSessionId);
+        if (status == PVMFFailure)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeCleanup() Disconnect Failed"));
+            OSCL_ASSERT(false);
+        }
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeCleanup() - DisConnect Done"));
-        iSourceNode->ThreadLogoff();
+
+        status = iSourceNode->ThreadLogoff();
+        if (status == PVMFFailure)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeCleanup() ThreadLogoff Failed"));
+            OSCL_ASSERT(false);
+        }
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::DoSourceNodeCleanup() - ThreadLogoff Done"));
 
         // search for matching uuid entry in list of instantiated nodes
@@ -9699,11 +9598,7 @@
         {
             bool release_status = false;
 
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode, release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, iSourceNode));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoSourceNodeCleanup() Error in releasing SourceNode"));
-                                 return;);
+            release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, iSourceNode);
 
             if (release_status == false)
             {
@@ -9854,7 +9749,7 @@
                 // Go through each engine component string at 3rd level
                 if (pv_mime_strcmp(compstr, (char*)(PVPlayerConfigBaseKeys[engcomp3ind].iString)) >= 0)
                 {
-                    if (engcomp3ind == 12)
+                    if (engcomp3ind == PRODUCTINFO)
                     {
                         // "x-pvmf/player/productinfo"
                         if (compcount == 3)
@@ -9970,18 +9865,35 @@
     }
     else
     {
-        // Determine which node's cap-config IF needs to be used
-        Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
-        PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
-        if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
+        PVMFStatus retval = PVMFFailure;
+
+        // Go through each datapath's cap-config IF in the datapath list and check for the string.
+        for (uint32 i = 0; i < iDatapathList.size(); i++)
         {
-            uint32 nodeind = 0;
-            // Go through each returned node's cap-config until successful
-            while (nodeind < nodecapconfigif.size() && aNumParamElements == 0)
+            if (iDatapathList[i].iDecNodeCapConfigIF != NULL)
             {
-                retval = nodecapconfigif[nodeind]->getParametersSync(NULL, aIdentifier, aParameters, aNumParamElements, aContext);
-                ++nodeind;
+                retval = iDatapathList[i].iDecNodeCapConfigIF->getParametersSync(NULL, aIdentifier, aParameters, aNumParamElements, aContext);
+                if (retval == PVMFSuccess)
+                {
+                    // Key matched break the loop.
+                    break;
+                }
             }
+
+            if (iDatapathList[i].iSinkNodeCapConfigIF != NULL)
+            {
+                retval = iDatapathList[i].iSinkNodeCapConfigIF->getParametersSync(NULL, aIdentifier, aParameters, aNumParamElements, aContext);
+                if (retval == PVMFSuccess)
+                {
+                    // Key matched break the loop.
+                    break;
+                }
+            }
+        }
+
+        if (retval != PVMFSuccess)
+        {
+            return retval;
         }
     }
 
@@ -10066,6 +9978,7 @@
                     aParameters[i].value.key_specific_value = NULL;
                     oscl_free(rui32);
                 }
+                // @TODO Add more types if engine starts returning more types
             }
         }
 
@@ -10078,29 +9991,35 @@
     }
     else
     {
-        // Determine which node's cap-config IF needs to be used
-        Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
-        PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
-        if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
+        PVMFStatus retval = PVMFFailure;
+
+        // Go through each datapath's cap-config IF in the datapath list and check for the string.
+        for (uint32 i = 0; i < iDatapathList.size(); i++)
         {
-            uint32 nodeind = 0;
-            retval = PVMFErrArgument;
-            // Go through each returned node's cap-config until successful
-            while (nodeind < nodecapconfigif.size() && retval != PVMFSuccess)
+            if (iDatapathList[i].iDecNodeCapConfigIF != NULL)
             {
-                retval = nodecapconfigif[nodeind]->releaseParameters(NULL, aParameters, aNumElements);
-                ++nodeind;
+                retval = iDatapathList[i].iDecNodeCapConfigIF->releaseParameters(NULL, aParameters, aNumElements);
+                if (retval == PVMFSuccess)
+                {
+                    // Key matched break the loop.
+                    break;
+                }
             }
 
-            if (retval != PVMFSuccess)
+            if (iDatapathList[i].iSinkNodeCapConfigIF != NULL)
             {
-                return retval;
+                retval = iDatapathList[i].iSinkNodeCapConfigIF->releaseParameters(NULL, aParameters, aNumElements);
+                if (retval == PVMFSuccess)
+                {
+                    // Key matched break the loop.
+                    break;
+                }
             }
         }
-        else
+
+        if (retval != PVMFSuccess)
         {
-            // Unknown key string
-            return PVMFErrArgument;
+            return retval;
         }
     }
 
@@ -10191,36 +10110,49 @@
         }
         else
         {
-            // Determine which node's cap-config IF needs to be used
-            Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
-            PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
             *retkvp = &paramkvp[paramind];
-            if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
+            bool anysuccess = false;
+
+
+            if (iSourceNodeCapConfigIF != NULL)
             {
-                uint32 nodeind = 0;
-                bool anysuccess = false;
-                // Go through each returned node's cap-config until successful
-                while (nodeind < nodecapconfigif.size())
+                *retkvp = NULL;
+                iSourceNodeCapConfigIF->setParametersSync(NULL, &paramkvp[paramind], 1, *retkvp);
+                if (*retkvp == NULL)
+                {
+                    anysuccess = true;
+                }
+            }
+            // Go through each datapath's cap-config IF in the datapath list and check for the string.
+            for (uint32 i = 0; i < iDatapathList.size(); i++)
+            {
+                if (iDatapathList[i].iDecNodeCapConfigIF != NULL)
                 {
                     *retkvp = NULL;
-                    nodecapconfigif[nodeind]->setParametersSync(NULL, &paramkvp[paramind], 1, *retkvp);
-                    ++nodeind;
-                    if (*retkvp == NULL && anysuccess == false)
+                    iDatapathList[i].iDecNodeCapConfigIF->setParametersSync(NULL, &paramkvp[paramind], 1, *retkvp);
+                    if (*retkvp == NULL)
                     {
                         anysuccess = true;
+                        break;
                     }
                 }
-                if (anysuccess == false)
-                {   // setParametersSync was not accepted by the node(s)
-                    *retkvp = &paramkvp[paramind];
-                    return PVMFErrArgument;
-                }
 
+                if (iDatapathList[i].iSinkNodeCapConfigIF != NULL)
+                {
+                    *retkvp = NULL;
+                    iDatapathList[i].iSinkNodeCapConfigIF->setParametersSync(NULL, &paramkvp[paramind], 1, *retkvp);
+                    if (*retkvp == NULL)
+                    {
+                        anysuccess = true;
+                        break;
+                    }
+                }
             }
-            else
+
+            if (anysuccess == false)
             {
-                // Unknown key string
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCapConfigSetParameters() Unsupported key"));
+                // setParametersSync was not accepted by the node(s)
+                *retkvp = &paramkvp[paramind];
                 return PVMFErrArgument;
             }
         }
@@ -10300,29 +10232,35 @@
         }
         else
         {
-            // Determine which node's cap-config IF needs to be used
-            Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator> nodecapconfigif;
-            PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
-            if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
+            PVMFStatus retval = PVMFFailure;
+
+            // Go through each datapath's cap-config IF in the datapath list and check for the string.
+            for (uint32 i = 0; i < iDatapathList.size(); i++)
             {
-                uint32 nodeind = 0;
-                retval = PVMFErrArgument;
-                // Go through each returned node's cap-config until successful
-                while (nodeind < nodecapconfigif.size() && retval != PVMFSuccess)
+                if (iDatapathList[i].iDecNodeCapConfigIF != NULL)
                 {
-                    retval = nodecapconfigif[nodeind]->verifyParametersSync(NULL, &aParameters[paramind], 1);
-                    ++nodeind;
+                    retval = iDatapathList[i].iDecNodeCapConfigIF->verifyParametersSync(NULL, &aParameters[paramind], 1);
+                    if (retval == PVMFSuccess)
+                    {
+                        // Key matched break the loop.
+                        break;
+                    }
                 }
 
-                if (retval != PVMFSuccess)
+                if (iDatapathList[i].iSinkNodeCapConfigIF != NULL)
                 {
-                    return retval;
+                    retval = iDatapathList[i].iSinkNodeCapConfigIF->verifyParametersSync(NULL, &aParameters[paramind], 1);
+                    if (retval == PVMFSuccess)
+                    {
+                        // Key matched break the loop.
+                        break;
+                    }
                 }
             }
-            else
+
+            if (retval != PVMFSuccess)
             {
-                // Unknown key string
-                return PVMFErrArgument;
+                return retval;
             }
         }
     }
@@ -10331,132 +10269,6 @@
     return PVMFSuccess;
 }
 
-
-PVMFStatus PVPlayerEngine::DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator>& aNodeCapConfigIF)
-{
-    aNodeCapConfigIF.clear();
-
-    if (aKeySubString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    int32 leavecode = 0;
-    if (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("video/decoder")) >= 0)
-    {
-        // Video decoder setting
-
-        // Find the video datapath in the list
-        int32 vdpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_VIDEO, vdpind) == true)
-        {
-            PVPlayerEngineDatapath* pvpedp = &(iDatapathList[vdpind]);
-            if (pvpedp->iTrackActive == true)
-            {
-                if (pvpedp->iDecNodeCapConfigIF)
-                {
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(pvpedp->iDecNodeCapConfigIF));
-                    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-                }
-
-                if (pvpedp->iSinkNodeCapConfigIF)
-                {
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(pvpedp->iSinkNodeCapConfigIF));
-                    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-                }
-            }
-        }
-    }
-    else if (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("audio/decoder")) >= 0)
-    {
-        // Audio decoder setting
-
-        // Find the audio datapath in the list
-        int32 adpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_AUDIO, adpind) == true)
-        {
-            PVPlayerEngineDatapath* pvpedp = &(iDatapathList[adpind]);
-            if (pvpedp->iTrackActive == true)
-            {
-                if (pvpedp->iDecNodeCapConfigIF)
-                {
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(pvpedp->iDecNodeCapConfigIF));
-                    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-                }
-
-                if (pvpedp->iSinkNodeCapConfigIF)
-                {
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(pvpedp->iSinkNodeCapConfigIF));
-                    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-                }
-            }
-        }
-    }
-    else if (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("video/render")) >= 0)
-    {
-        // Video render device setting
-
-        // Find the video datapath in the list
-        int32 vdpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_VIDEO, vdpind) == true)
-        {
-            PVPlayerEngineDatapath* pvpedp = &(iDatapathList[vdpind]);
-            if (pvpedp->iTrackActive == true)
-            {
-                if (pvpedp->iSinkNodeCapConfigIF)
-                {
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(pvpedp->iSinkNodeCapConfigIF));
-                    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-                }
-            }
-        }
-    }
-    else if (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("audio/render")) >= 0)
-    {
-        // Audio render device setting
-
-        // Find the audio datapath in the list
-        int32 adpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_AUDIO, adpind) == true)
-        {
-            PVPlayerEngineDatapath* pvpedp = &(iDatapathList[adpind]);
-            if (pvpedp->iTrackActive == true)
-            {
-                if (pvpedp->iSinkNodeCapConfigIF)
-                {
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(pvpedp->iSinkNodeCapConfigIF));
-                    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-                }
-            }
-        }
-    }
-    else if (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("net")) >= 0 ||
-             pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("parser")) >= 0)
-    {
-        // Source node setting
-        if (iSourceNodeCapConfigIF)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, aNodeCapConfigIF.push_back(iSourceNodeCapConfigIF));
-            OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
-        }
-    }
-    else
-    {
-        // No matching node
-        return PVMFFailure;
-    }
-
-    return PVMFSuccess;
-}
-
-
 PVMFStatus PVPlayerEngine::DoGetPlayerParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetPlayerParameter() In"));
@@ -10522,7 +10334,7 @@
     // Copy the requested info
     switch (aIndex)
     {
-        case 0: // "pbpops_units"
+        case PBPOS_UNITS: // "pbpops_units"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10601,7 +10413,7 @@
             }
             break;
 
-        case 1:	// "pbpos_interval"
+        case PBPOS_INTERVAL:	// "pbpos_interval"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10629,7 +10441,7 @@
             }
             break;
 
-        case 2:	// "endtimecheck_interval"
+        case ENDTIMECHECK_INTERVAL:	// "endtimecheck_interval"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10657,7 +10469,7 @@
             }
             break;
 
-        case 3:	// "seektosyncpoint"
+        case SEEKTOSYNCPOINT:	// "seektosyncpoint"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10675,7 +10487,7 @@
             }
             break;
 
-        case 4:	// "skiptorequestedpos"
+        case SKIPTOREQUESTEDPOSITION:	// "skiptorequestedpos"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10693,25 +10505,7 @@
             }
             break;
 
-        case 5:	// "renderskipped"
-            if (reqattr == PVMI_KVPATTR_CUR)
-            {
-                // Return current value
-                aParameters[0].value.bool_value = iRenderSkipped;
-            }
-            else if (reqattr == PVMI_KVPATTR_DEF)
-            {
-                // Return default
-                aParameters[0].value.bool_value = PVPLAYERENGINE_CONFIG_RENDERSKIPPED_DEF;
-            }
-            else
-            {
-                // Return capability
-                // Bool so no capability
-            }
-            break;
-
-        case 6:	// "syncpointseekwindow"
+        case SYNCPOINTSEEKWINDOW:	// "syncpointseekwindow"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10739,9 +10533,9 @@
             }
             break;
 
-        case 7:	// "syncmargin_video"
-        case 8:	// "syncmargin_audio"
-        case 9:	// "syncmargin_text"
+        case SYNCMARGIN_VIDEO:	// "syncmargin_video"
+        case SYNCMARGIN_AUDIO:	// "syncmargin_audio"
+        case SYNCMARGIN_TEXT:	// "syncmargin_text"
         {
             range_int32* ri32 = (range_int32*)oscl_malloc(sizeof(range_int32));
             if (ri32 == NULL)
@@ -10755,13 +10549,13 @@
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
-                if (aIndex == 7)
+                if (aIndex == SYNCMARGIN_VIDEO)
                 {
                     // Video
                     ri32->min = iSyncMarginVideo.min;
                     ri32->max = iSyncMarginVideo.max;
                 }
-                else if (aIndex == 8)
+                else if (aIndex == SYNCMARGIN_AUDIO)
                 {
                     // Audio
                     ri32->min = iSyncMarginAudio.min;
@@ -10792,7 +10586,7 @@
         }
         break;
 
-        case 10:	// "nodecmd_timeout"
+        case NODECMD_TIMEOUT:	// "nodecmd_timeout"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10820,7 +10614,7 @@
             }
             break;
 
-        case 11:	// "nodedataqueuing_timeout"
+        case NODEDATAQUEIUING_TIMEOUT:	// "nodedataqueuing_timeout"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10848,7 +10642,7 @@
             }
             break;
 
-        case 13:	// "pbpos_enable"
+        case PBPOS_ENABLE:	// "pbpos_enable"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10915,7 +10709,7 @@
     // Copy the requested info
     switch (aIndex)
     {
-        case 0: // "productname"
+        case PRODUCTNAME: // "productname"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -10965,7 +10759,7 @@
             }
             break;
 
-        case 1: // "partnumber"
+        case PARTNUMBER: // "partnumber"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -11015,7 +10809,7 @@
             }
             break;
 
-        case 2: // "hardwareplatform"
+        case HARDWAREPLATFORM: // "hardwareplatform"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -11065,7 +10859,7 @@
             }
             break;
 
-        case 3: // "softwareplatform"
+        case SOFTWAREPLATFORM: // "softwareplatform"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -11115,7 +10909,7 @@
             }
             break;
 
-        case 4: // "device"
+        case DEVICE: // "device"
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
@@ -11206,7 +11000,7 @@
         }
     }
 
-    if (engcomp3ind >= PVPLAYERCONFIG_BASE_NUMKEYS || engcomp3ind == 12)
+    if (engcomp3ind >= PVPLAYERCONFIG_BASE_NUMKEYS || engcomp3ind == PRODUCTINFO)
     {
         // Match couldn't be found or non-leaf node ("productinfo") specified
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyAndSetPlayerParameter() Unsupported key or non-leaf node"));
@@ -11222,7 +11016,7 @@
 
     switch (engcomp3ind)
     {
-        case 0: // "pbpos_units"
+        case PBPOS_UNITS: // "pbpos_units"
         {
             // Validate
             if (aParameter.value.pChar_value == NULL)
@@ -11261,7 +11055,7 @@
         }
         break;
 
-        case 1: // "pbpos_interval"
+        case PBPOS_INTERVAL: // "pbpos_interval"
             // Check if within range
             if (aParameter.value.uint32_value < PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_MIN ||
                     aParameter.value.uint32_value > PVPLAYERENGINE_CONFIG_PBPOSSTATUSINTERVAL_MAX)
@@ -11276,7 +11070,7 @@
             }
             break;
 
-        case 2: // "endtimecheck_interval"
+        case ENDTIMECHECK_INTERVAL: // "endtimecheck_interval"
             // Check if within range
             if (aParameter.value.uint32_value < PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_MIN ||
                     aParameter.value.uint32_value > PVPLAYERENGINE_CONFIG_ENDTIMECHECKINTERVAL_MAX)
@@ -11291,7 +11085,7 @@
             }
             break;
 
-        case 3: // "seektosyncpoint"
+        case SEEKTOSYNCPOINT: // "seektosyncpoint"
             // Nothing to validate since it is boolean
             // Change the config if to set
             if (aSetParam)
@@ -11300,7 +11094,7 @@
             }
             break;
 
-        case 4: // "skiptorequestedpos"
+        case SKIPTOREQUESTEDPOSITION: // "skiptorequestedpos"
             // Nothing to validate since it is boolean
             // Change the config if to set
             if (aSetParam)
@@ -11309,19 +11103,9 @@
             }
             break;
 
-        case 5: // "renderskipped"
-            // Nothing to validate since it is boolean
-            // Change the config if to set
-            if (aSetParam)
-            {
-                iRenderSkipped = aParameter.value.bool_value;
-            }
-            break;
-
-        case 6: // "syncpointseekwindow"
+        case SYNCPOINTSEEKWINDOW: // "syncpointseekwindow"
             // Check if within range
-            if (aParameter.value.uint32_value < PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MIN ||
-                    aParameter.value.uint32_value > PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MAX)
+            if (aParameter.value.uint32_value > PVPLAYERENGINE_CONFIG_SEEKTOSYNCPOINTWINDOW_MAX)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoVerifyAndSetPlayerParameter() Invalid value for syncpointseekwindow"));
                 return PVMFErrArgument;
@@ -11333,9 +11117,9 @@
             }
             break;
 
-        case 7: // "syncmargin_video"
-        case 8: // "syncmargin_audio"
-        case 9: // "syncmargin_text"
+        case SYNCMARGIN_VIDEO: // "syncmargin_video"
+        case SYNCMARGIN_AUDIO: // "syncmargin_audio"
+        case SYNCMARGIN_TEXT: // "syncmargin_text"
         {
             range_int32* ri32 = (range_int32*)aParameter.value.key_specific_value;
             if (ri32 == NULL)
@@ -11362,7 +11146,7 @@
         }
         break;
 
-        case 10: // "nodecmd_timeout"
+        case NODECMD_TIMEOUT: // "nodecmd_timeout"
             // Check if within range
             if (aParameter.value.uint32_value < PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_MIN ||
                     aParameter.value.uint32_value > PVPLAYERENGINE_CONFIG_NODECMDTIMEOUT_MAX)
@@ -11377,7 +11161,7 @@
             }
             break;
 
-        case 11: // "nodedataqueuing_timeout"
+        case NODEDATAQUEIUING_TIMEOUT: // "nodedataqueuing_timeout"
             // Check if within range
             if (aParameter.value.uint32_value < PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_MIN ||
                     aParameter.value.uint32_value > PVPLAYERENGINE_CONFIG_NODEDATAQUEUINGTIMEOUT_MAX)
@@ -11392,7 +11176,7 @@
             }
             break;
 
-        case 13: // "pbpos_enable"
+        case PBPOS_ENABLE: // "pbpos_enable"
             // Nothing to validate since it is boolean
             // Change the config if to set
             if (aSetParam)
@@ -11408,7 +11192,7 @@
                 else if (!prevPBPosEnable && (aParameter.value.bool_value))
                 {
                     // Start playback position reporting only when playback clock is running
-                    if (iPlaybackClock.GetState() == OsclClock::RUNNING)
+                    if (iPlaybackClock.GetState() == PVMFMediaClock::RUNNING)
                     {
                         StartPlaybackStatusTimer();
                     }
@@ -11469,7 +11253,7 @@
 
     switch (engcomp4ind)
     {
-        case 0: // "productname"
+        case PRODUCTNAME: // "productname"
             // Check if within range
             if (aParameter.value.pChar_value == NULL)
             {
@@ -11483,7 +11267,7 @@
             }
             break;
 
-        case 1: // "partnumber"
+        case PARTNUMBER: // "partnumber"
             // Check if within range
             if (aParameter.value.pChar_value == NULL)
             {
@@ -11497,7 +11281,7 @@
             }
             break;
 
-        case 2: // "hardwareplatform"
+        case HARDWAREPLATFORM: // "hardwareplatform"
             // Check if within range
             if (aParameter.value.pChar_value == NULL)
             {
@@ -11511,7 +11295,7 @@
             }
             break;
 
-        case 3: // "softwareplatform"
+        case SOFTWAREPLATFORM: // "softwareplatform"
             // Check if within range
             if (aParameter.value.pChar_value == NULL)
             {
@@ -11525,7 +11309,7 @@
             }
             break;
 
-        case 4: // "device"
+        case DEVICE: // "device"
             // Check if within range
             if (aParameter.value.pChar_value == NULL)
             {
@@ -11561,10 +11345,10 @@
 
         // Find the video datapath in the list
         int32 vdpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_VIDEO, vdpind) == true)
+        if (FindDatapathForTrackUsingMimeString(true, false, false, vdpind) == true)
         {
             PVPlayerEngineDatapath* pvpedp = &(iDatapathList[vdpind]);
-            if (pvpedp->iTrackActive == true)
+            if (pvpedp->iDatapath)
             {
                 if (pvpedp->iSinkNodeSyncCtrlIF)
                 {
@@ -11581,10 +11365,10 @@
 
         // Find the audio datapath in the list
         int32 adpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_AUDIO, adpind) == true)
+        if (FindDatapathForTrackUsingMimeString(false, true, false, adpind) == true)
         {
             PVPlayerEngineDatapath* pvpedp = &(iDatapathList[adpind]);
-            if (pvpedp->iTrackActive == true)
+            if (pvpedp->iDatapath)
             {
                 if (pvpedp->iSinkNodeSyncCtrlIF)
                 {
@@ -11601,10 +11385,10 @@
 
         // Find the text datapath in the list
         int32 tdpind = -1;
-        if (FindDatapathByMediaType(PVP_MEDIATYPE_TEXT, tdpind) == true)
+        if (FindDatapathForTrackUsingMimeString(false, false, true, tdpind) == true)
         {
             PVPlayerEngineDatapath* pvpedp = &(iDatapathList[tdpind]);
-            if (pvpedp->iTrackActive == true)
+            if (pvpedp->iDatapath)
             {
                 if (pvpedp->iSinkNodeSyncCtrlIF)
                 {
@@ -11697,58 +11481,86 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeQueryInitIF() In"));
 
     PVMFStatus cmdstatus;
+    bool rescheduleAO = false;
 
     switch (aNodeResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            if (iSourceNodePVInterfaceInit)
+            {
+                iSourceNodeInitIF = (PVMFDataSourceInitializationExtensionInterface*)iSourceNodePVInterfaceInit;
+                iSourceNodePVInterfaceInit = NULL;
+            }
             // Query for track selection interface
             cmdstatus = DoSourceNodeQueryTrackSelIF(aNodeContext.iCmdId, aNodeContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
             {
-                // There shouldn't be any other command pending to complete in engine's AO
-                OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-                iCommandCompleteInEngineAOPending = true;
                 if ((CheckForSourceRollOver() == true) && (iRollOverState == RollOverStateInProgress))
                 {
                     iRollOverState = RollOverStateStart;
+                    rescheduleAO = true;
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVPlayerEngine::HandleSourceNodeQueryInitIF() DoSourceNodeQueryTrackSelIF failed, Add EH command"));
+                    iCommandCompleteStatusInErrorHandling = cmdstatus;
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                    if (iRollOverState == RollOverStateInProgress)
+                    {
+                        // Init is the current ongoing cmd so queue Init EH cmd
+                        AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
+                    }
+                    else
+                    {
+                        // AddDataSource cmd is Current Command, queue ADS EH cmd
+                        AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE, NULL, NULL, NULL, false);
+                    }
                     iRollOverState = RollOverStateIdle;
                 }
-                iCommandCompleteInEngineAOCmdStatus = cmdstatus;
-                iCommandCompleteInEngineAOErrMsg = NULL;
             }
             break;
 
         default:
         {
-            cmdstatus = aNodeResp.GetCmdStatus();
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aNodeResp.GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
-            }
+            iSourceNodePVInterfaceInit = NULL;
+            iSourceNodeInitIF = NULL;
 
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            iCommandCompleteInEngineAOErrMsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceInit, puuid, nextmsg));
-            // There shouldn't be any other command pending to complete in engine's AO
-            OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-            iCommandCompleteInEngineAOPending = true;
             if ((CheckForSourceRollOver() == true) && (iRollOverState == RollOverStateInProgress))
             {
                 iRollOverState = RollOverStateStart;
+                rescheduleAO = true;
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeQueryInitIF() failed, Add EH command"));
+                cmdstatus = aNodeResp.GetCmdStatus();
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aNodeResp.GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+                }
+
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceInit, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                if (iRollOverState == RollOverStateInProgress)
+                {
+                    // Init is the current ongoing cmd so queue Init EH cmd
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
+                }
+                else
+                {
+                    // AddDataSource cmd is Current Command, queue ADS EH cmd
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE, NULL, NULL, NULL, false);
+                }
                 iRollOverState = RollOverStateIdle;
             }
-            iCommandCompleteInEngineAOCmdStatus = cmdstatus;
         }
         break;
     }
-
-    if (iCommandCompleteInEngineAOPending)
+    if (rescheduleAO)
     {
         if (IsBusy())
         {
@@ -11770,10 +11582,16 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeQueryTrackSelIF() In"));
 
     PVMFStatus cmdstatus;
+    bool rescheduleAO = false;
 
     switch (aNodeResp.GetCmdStatus())
     {
         case PVMFSuccess:
+            if (iSourceNodePVInterfaceTrackSel)
+            {
+                iSourceNodeTrackSelIF = (PVMFTrackSelectionExtensionInterface*)iSourceNodePVInterfaceTrackSel;
+                iSourceNodePVInterfaceTrackSel = NULL;
+            }
             // Query the source node for optional extension IFs
             cmdstatus = DoSourceNodeQueryInterfaceOptional(aNodeContext.iCmdId, aNodeContext.iCmdContext);
             if (cmdstatus != PVMFSuccess)
@@ -11782,11 +11600,11 @@
                 if ((CheckForSourceRollOver() == true) && (iRollOverState == RollOverStateInProgress))
                 {
                     iRollOverState = RollOverStateStart;
+                    rescheduleAO = true;
                 }
                 else
                 {
                     iRollOverState = RollOverStateIdle;
-                    iCommandCompleteInEngineAOPending = false;
                     EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFSuccess);
                 }
             }
@@ -11794,28 +11612,45 @@
 
         default:
         {
-            cmdstatus = aNodeResp.GetCmdStatus();
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aNodeResp.GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
-            }
+            iSourceNodePVInterfaceTrackSel = NULL;
+            iSourceNodeTrackSelIF = NULL;
 
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            iCommandCompleteInEngineAOErrMsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceInit, puuid, nextmsg));
-            // There shouldn't be any other command pending to complete in engine's AO
-            OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-            iCommandCompleteInEngineAOPending = true;
             if ((CheckForSourceRollOver() == true) && (iRollOverState == RollOverStateInProgress))
             {
                 iRollOverState = RollOverStateStart;
+                rescheduleAO = true;
             }
-            iCommandCompleteInEngineAOCmdStatus = cmdstatus;
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeQueryTrackSelIF() failed, Add EH Command"));
+                cmdstatus = aNodeResp.GetCmdStatus();
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aNodeResp.GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+                }
+
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceInit, puuid, nextmsg));
+
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                if (iRollOverState == RollOverStateInProgress)
+                {
+                    // Init is the current ongoing cmd so queue Init EH cmd
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
+                }
+                else
+                {
+                    // AddDataSource cmd is Current Command, queue ADS EH cmd
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE, NULL, NULL, NULL, false);
+                }
+                iRollOverState = RollOverStateIdle;
+            }
         }
         break;
     }
-
-    if (iCommandCompleteInEngineAOPending)
+    if (rescheduleAO)
     {
         if (IsBusy())
         {
@@ -11824,7 +11659,6 @@
 
         RunIfNotReady();
     }
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeQueryTrackSelIF() Out"));
 }
 
@@ -11839,37 +11673,58 @@
     // Determine QueryInterface() for which interface completed
     if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQueryTrackLevelInfoIF)
     {
-        if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfaceTrackLevelInfo)
+        {
+            iSourceNodeTrackLevelInfoIF = (PVMFTrackLevelInfoExtensionInterface*)iSourceNodePVInterfaceTrackLevelInfo;
+            iSourceNodePVInterfaceTrackLevelInfo = NULL;
+        }
+        else
         {
             // Track level info IF is not available in this data source
+            iSourceNodePVInterfaceTrackLevelInfo = NULL;
             iSourceNodeTrackLevelInfoIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() Track level info IF not available"));
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQueryPBCtrlIF)
     {
-        if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfacePBCtrl)
+        {
+            iSourceNodePBCtrlIF = (PvmfDataSourcePlaybackControlInterface*)iSourceNodePVInterfacePBCtrl;
+            iSourceNodePVInterfacePBCtrl = NULL;
+        }
+        else
         {
             // Playback control is not available in this data source
+            iSourceNodePVInterfacePBCtrl = NULL;
             iSourceNodePBCtrlIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() Position control IF not available"));
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQueryDirCtrlIF)
     {
-        if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfaceDirCtrl)
+        {
+            iSourceNodeDirCtrlIF = (PvmfDataSourceDirectionControlInterface*)iSourceNodePVInterfaceDirCtrl;
+            iSourceNodePVInterfaceDirCtrl = NULL;
+        }
+        else
         {
             // Direction control is not available in this data source
+            iSourceNodePVInterfaceDirCtrl = NULL;
             iSourceNodeDirCtrlIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() Direction control IF not available"));
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQueryMetadataIF)
     {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && iSourceNodeMetadataExtIF)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfaceMetadataExt)
         {
+            iSourceNodeMetadataExtIF = (PVMFMetadataExtensionInterface*)iSourceNodePVInterfaceMetadataExt;
+            iSourceNodePVInterfaceMetadataExt = NULL;
+
             // Add the parser node's metadata extension IF to the list
-            if (AddToMetadataInterfaceList(iSourceNodeMetadataExtIF, iSourceNodeSessionId) != PVMFSuccess)
+            if (AddToMetadataInterfaceList(iSourceNodeMetadataExtIF, iSourceNodeSessionId, NULL, iSourceNode) != PVMFSuccess)
             {
                 iSourceNodeMetadataExtIF->removeRef();
                 iSourceNodeMetadataExtIF = NULL;
@@ -11880,38 +11735,55 @@
         else
         {
             // Metadata is not available in this data source
+            iSourceNodePVInterfaceMetadataExt = NULL;
             iSourceNodeMetadataExtIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() Metadata IF not available"));
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQueryCapConfigIF)
     {
-        if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfaceCapConfig)
+        {
+            iSourceNodeCapConfigIF = (PvmiCapabilityAndConfig*)iSourceNodePVInterfaceCapConfig;
+            iSourceNodePVInterfaceCapConfig = NULL;
+        }
+        else
         {
             // Cap-config is not available in this data source
+            iSourceNodePVInterfaceCapConfig = NULL;
             iSourceNodeCapConfigIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() Cap-Config IF not available"));
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQueryCPMLicenseIF)
     {
-        if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfaceCPMLicense)
+        {
+            iSourceNodeCPMLicenseIF = (PVMFCPMPluginLicenseInterface*)iSourceNodePVInterfaceCPMLicense;
+            iSourceNodePVInterfaceCPMLicense = NULL;
+        }
+        else
         {
             //CPM License is not available in this data source
+            iSourceNodePVInterfaceCPMLicense = NULL;
             iSourceNodeCPMLicenseIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() CPM License IF not available"));
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SourceNodeQuerySrcNodeRegInitIF)
     {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && iSourceNodeRegInitIF)
+        if ((aNodeResp.GetCmdStatus() == PVMFSuccess) && iSourceNodePVInterfaceRegInit)
         {
+            iSourceNodeRegInitIF = (PVMFDataSourceNodeRegistryInitInterface*)iSourceNodePVInterfaceRegInit;
+            iSourceNodePVInterfaceRegInit = NULL;
+
             // Set source node regsitry
             iSourceNodeRegInitIF->SetPlayerNodeRegistry(&iPlayerNodeRegistry);
         }
         else
         {
             //Node Registry Init Extension Interface is not available in this data source
+            iSourceNodePVInterfaceRegInit = NULL;
             iSourceNodeRegInitIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() Src Node Registry Init IF not available"));
         }
@@ -11937,11 +11809,16 @@
                 if ((CheckForSourceRollOver() == true) && (iRollOverState == RollOverStateInProgress))
                 {
                     iRollOverState = RollOverStateStart;
+                    RunIfNotReady();
                 }
                 else
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVPlayerEngine::HandleSourceNodeQueryInterfaceOptional() DoSourceNodeInit failed, Add EH Command"));
                     iRollOverState = RollOverStateIdle;
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFFailure);
+                    iCommandCompleteStatusInErrorHandling = retval;
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
                 }
             }
         }
@@ -11967,7 +11844,6 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInit() In"));
 
     iRollOverState = RollOverStateIdle;
-    iCommandCompleteInEngineAOPending = false;
     PVMFStatus cmdstatus;
 
     switch (aNodeResp.GetCmdStatus())
@@ -11999,10 +11875,11 @@
 
         case PVMFErrLicenseRequired:
         case PVMFErrHTTPAuthenticationRequired:
+        case PVMFErrRedirect:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInit() PVMFErrLicenseRequired/PVMFErrHTTPAuthenticationRequired"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInit() PVMFErrLicenseRequired/PVMFErrHTTPAuthenticationRequired/PVMFErrRedirect"));
 
-            HandleErrorBasedOnPlayerState();
+            SetEngineState(PVP_ENGINE_STATE_IDLE);
             cmdstatus = aNodeResp.GetCmdStatus();
 
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
@@ -12019,18 +11896,15 @@
 
         }
         break;
-        ;
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
-            // idle state implies that init sequence, including any rollovers are complete
-            // report command complete
-            if (iState == PVP_ENGINE_STATE_IDLE)
+            if (iState == PVP_ENGINE_STATE_INITIALIZING)
             {
+                SetEngineState(PVP_ENGINE_STATE_IDLE);
                 if (CheckForSourceRollOver() == false)
                 {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeInit() failed, Add EH Command"));
                     cmdstatus = aNodeResp.GetCmdStatus();
 
                     PVMFErrorInfoMessageInterface* nextmsg = NULL;
@@ -12040,9 +11914,9 @@
                     }
 
                     PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-                    PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceInit, puuid, nextmsg));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus, OSCL_STATIC_CAST(PVInterface*, errmsg), aNodeResp.GetEventData());
-                    errmsg->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceInit, puuid, nextmsg));
+                    iCommandCompleteStatusInErrorHandling = cmdstatus;
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, NULL, NULL, NULL, false);
                 }
                 else
                 {
@@ -12059,7 +11933,7 @@
             }
             else
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeInit() - Incorrect State - Asserting"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeInit() - Incorrect State - Asserting"));
                 OSCL_ASSERT(false);
             }
         }
@@ -12115,7 +11989,7 @@
             iSourceDurationInMS = iSourceDurationValueList[0].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char* retsubstr = NULL;
+            const char* retsubstr = NULL;
             uint32 retsubstrlen = 0;
             uint32 tsparamlen = oscl_strlen(_STRLIT_CHAR("timescale="));
             retsubstr = oscl_strstr(iSourceDurationValueList[0].key, _STRLIT_CHAR("timescale="));
@@ -12156,8 +12030,10 @@
     // and then clear it
     if (iSourceDurationValueList.empty() == false)
     {
-        OSCL_ASSERT(iSourceNodeMetadataExtIF != NULL);
-        iSourceNodeMetadataExtIF->ReleaseNodeMetadataValues(iSourceDurationValueList, 0, iSourceDurationValueList.size());
+        if (iSourceNodeMetadataExtIF != NULL)
+        {
+            iSourceNodeMetadataExtIF->ReleaseNodeMetadataValues(iSourceDurationValueList, 0, iSourceDurationValueList.size());
+        }
         iSourceDurationValueList.clear();
     }
 
@@ -12168,101 +12044,6 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeGetDurationValue() Out"));
 }
 
-void PVPlayerEngine::HandleSourceNodeGetDlaData(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Tick=%d", OsclTickCount::TickCount()));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() In"));
-
-    OSCL_UNUSED_ARG(aNodeContext);
-
-    switch (aNodeResp.GetCmdStatus())
-    {
-        case PVMFSuccess:
-        {
-            // Extract the DLA Data and save it
-            // Check that there is one KVP in value list
-            if (iDlaDataValueList.size() != 1)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Value list size is not 1 (size=%d)",
-                                iDlaDataValueList.size()));
-                break;
-            }
-
-            // Check that the key in KVP is not NULL
-            if (iDlaDataValueList[0].key == NULL)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Value list key string is NULL"));
-                break;
-            }
-
-            // Check that value is for DLA Data
-            int retval = pv_mime_strstr(iDlaDataValueList[0].key, (char*)_STRLIT_CHAR("drm/dla-data"));
-            if (retval == -1)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Key string does not contain dla data"));
-                break;
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Key string does contain dla data (size=%d)",
-                                iDlaDataValueList[0].length));
-            }
-
-            // Check that Dla Data value is uint8ptr.
-            PvmiKvpValueType durvaltype = GetValTypeFromKeyString(iDlaDataValueList[0].key);
-            if (durvaltype != PVMI_KVPVALTYPE_UINT8PTR && durvaltype != PVMI_KVPVALTYPE_UNKNOWN)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Value type is not PVMI_KVPVALTYPE_UINT8PTR or unknown"));
-                break;
-            }
-
-            iCPMAcquireLicenseParam.iLicenseData = iDlaDataValueList[0].value.pUint8_value;
-            iCPMAcquireLicenseParam.iLicenseDataSize = iDlaDataValueList[0].length;
-        }
-        break;
-
-        default:
-        {
-            // DLA Data is not available.
-            // Most license license acquire will fail, but continue
-            // anyway.
-            iCPMAcquireLicenseParam.iLicenseData = NULL;
-            iCPMAcquireLicenseParam.iLicenseDataSize = 0;
-
-        }
-        break;
-    }
-
-    //Create the plugin and query for the license IF
-
-    PVMFStatus status = DoGetPluginLicenseIF();
-    if (status != PVMFSuccess)
-    {
-        //Trigger the AO to complete the engine command
-
-        // There shouldn't be any other command pending to complete in engine's AO
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-
-        iCommandCompleteInEngineAOPending = true;
-        iCommandCompleteInEngineAOCmdStatus = status;
-        iCommandCompleteInEngineAOErrMsg = NULL;
-
-        if (iCommandCompleteInEngineAOPending)
-        {
-            if (IsBusy())
-            {
-                Cancel();
-            }
-            RunIfNotReady();
-        }
-    }
-    //else wait on CPMPluginCommandCompleted.
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeGetDlaData() Out"));
-}
-
 void PVPlayerEngine::HandleSourceNodeSetDataSourceRate(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceRate() In"));
@@ -12328,7 +12109,7 @@
 
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+        if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
         {
             cmdstatus = iDatapathList[i].iSinkNodeSyncCtrlIF->ChangeClockRate(iPlaybackClockRate_New);
 
@@ -12375,11 +12156,12 @@
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVPlayerEngine::UpdateDirection() Direction %d New Start NPT %d Start Media Data TS %d, Repos NPT %d"
+                    (0, "PVPlayerEngine::UpdateDirection() Direction %d New Start NPT %d Start Media Data TS %d, Repos NPT %d, Pos Indeterminate %d"
                      , iPlaybackDirection
                      , iStartNPT
                      , iStartMediaDataTS
-                     , (aPos.iIndeterminate) ? -1 : aPos.iPosValue.millisec_value));
+                     , aPos.iPosValue.millisec_value
+                     , aPos.iIndeterminate));
 }
 
 void PVPlayerEngine::UpdateTimebaseAndRate()
@@ -12408,17 +12190,291 @@
     else
     {
         //use the player timebase and set the rate.
-        iPlaybackClock.SetClockTimebase(iPlaybackTimebase);
         iPlaybackTimebase.SetRate(iPlaybackClockRate);
+        iPlaybackClock.SetClockTimebase(iPlaybackTimebase);
     }
 
     // Only restart the clock if the clock was paused in this function
     if (clockpaused)
     {
-        iPlaybackClock.Start();
+        StartPlaybackClock();
     }
 }
 
+void PVPlayerEngine::HandleSinkNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() In"));
+
+    switch (aNodeResp.GetCmdStatus())
+    {
+        case PVMFSuccess:
+        {
+            if (aNodeContext.iEngineDatapath->iSinkNodePVInterfaceCapConfig)
+            {
+                aNodeContext.iEngineDatapath->iSinkNodeCapConfigIF = (PvmiCapabilityAndConfig*)aNodeContext.iEngineDatapath->iSinkNodePVInterfaceCapConfig;
+                aNodeContext.iEngineDatapath->iSinkNodePVInterfaceCapConfig = NULL;
+            }
+        }
+        break;
+
+        default:
+        {
+            if (aNodeContext.iNode == aNodeContext.iEngineDatapath->iSinkNode)
+            {
+                aNodeContext.iEngineDatapath->iSinkNodePVInterfaceCapConfig = NULL;
+                aNodeContext.iEngineDatapath->iSinkNodeCapConfigIF = NULL;
+            }
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() Node dont support Cap-Config Interface, ignoring"));
+        }
+        break;
+    }
+
+    // Decrement the pending counter and go to next step if 0.
+    --iNumPendingNodeCmd;
+    if (iNumPendingNodeCmd == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() All QueryInterface() commands complete"));
+
+        PVMFStatus cmdstatus = DoSinkNodeInit(aNodeContext.iCmdId, aNodeContext.iCmdContext);
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() DoSinkNodeInit failed, Add EH Command"));
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryCapConfigIF() Out"));
+}
+
+void PVPlayerEngine::HandleSinkNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
+{
+    OSCL_UNUSED_ARG(aNodeContext);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVPlayerEngine::HandleSinkNodeInit() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeInit() In"));
+
+    if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+    {
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeInit() Already EH pending, should never happen"));
+            return;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSinkNodeInit() cmd response is failure, Add EH Command"));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aNodeResp.GetEventExtensionInterface())
+            {
+                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            }
+
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkInit, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return;
+        }
+    }
+
+    // Decrement the pending counter and go to next step if 0.
+    --iNumPendingNodeCmd;
+    if (iNumPendingNodeCmd == 0)
+    {
+        // Init on sink nodes is complete, next step in track selection is to check with the sink nodes alone if the track is
+        // playable or not. If track can be played using sink nodes only move to track selection or else go further to
+        // instantiate decoder nodes for the tracks.
+
+        // set the Engine state to Track selection so that engine calls DoPrepare and do further processing in Track selection
+
+        SetEngineState(PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE);
+        RunIfNotReady();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeInit() Out"));
+
+    return;
+}
+
+void PVPlayerEngine::HandleDecNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() In"));
+
+    for (uint32 i = 0; i < iTrackSelectionList.size(); i++)
+    {
+        switch (aNodeResp.GetCmdStatus())
+        {
+            case PVMFSuccess:
+            {
+                if (aNodeContext.iNode == iTrackSelectionList[i].iTsDecNode && iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig)
+                {
+                    iTrackSelectionList[i].iTsDecNodeCapConfigIF = (PvmiCapabilityAndConfig*)iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig;
+                    iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig = NULL;
+
+                    PVMFTrackInfo* currTrack = iSourcePresInfoList.getTrackInfo(i);
+                    // Valid decoder node set in TrackSelectionList. Scan the TrackSelectionList further and if
+                    // any similar MIME track is present just set the decoders to NULL for now.
+                    // This is to avoid multiple Init calls on same decoder nodes for similar tracks.
+                    // Set the decoder nodes and its cap and config I/F once decoder node Inits complete.
+                    for (uint32 j = i + 1; j < iTrackSelectionList.size(); j++)
+                    {
+                        PVMFTrackInfo* tmpTrack = iSourcePresInfoList.getTrackInfo(j);
+                        if (!(pv_mime_strcmp(currTrack->getTrackMimeType().get_str(), tmpTrack->getTrackMimeType().get_str())))
+                        {
+                            // These were earlier set in DoDecNodeQueryCapConfifIF to avoid multiple creation of same
+                            // decoder nodes.
+                            iTrackSelectionList[j].iTsDecNode = NULL;
+                            iTrackSelectionList[j].iTsDecNodeSessionId = 0;
+                            iTrackSelectionList[j].iTsDecNodeCapConfigIF = NULL;
+                        }
+                    }
+                }
+            }
+            break;
+
+            default:
+            {
+                if (aNodeContext.iNode == iTrackSelectionList[i].iTsDecNode)
+                {
+                    iTrackSelectionList[i].iTsDecNodePVInterfaceCapConfig = NULL;
+                    iTrackSelectionList[i].iTsDecNodeCapConfigIF = NULL;
+                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() Node dont support Cap-Config Interface, ignoring"));
+            }
+            break;
+        }
+    }
+
+    // Decrement the pending counter and go to next step if 0.
+    --iNumPendingNodeCmd;
+    if (iNumPendingNodeCmd == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() All QueryInterface() commands complete"));
+
+        PVMFStatus cmdstatus = DoDecNodeInit(aNodeContext.iCmdId, aNodeContext.iCmdContext);
+        if (cmdstatus != PVMFSuccess)
+        {
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() DoDecNodeInit failed, Add EH Command"));
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeQueryCapConfigIF() Out"));
+}
+
+void PVPlayerEngine::HandleDecNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
+{
+    OSCL_UNUSED_ARG(aNodeContext);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVPlayerEngine::HandleDecNodeInit() Tick=%d", OsclTickCount::TickCount()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeInit() In"));
+
+    if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+    {
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeInit() Already EH pending, should never happen"));
+            return;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDecNodeInit() cmd response is failure, Add EH Command"));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aNodeResp.GetEventExtensionInterface())
+            {
+                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            }
+
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapath, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            return;
+        }
+    }
+
+    // Decrement the pending counter and go to next step if 0.
+    --iNumPendingNodeCmd;
+    if (iNumPendingNodeCmd == 0)
+    {
+        // All decoder node Init is complete, now set the decoder node for similar tracks in TrackSelectionList.
+        for (uint32 i = 0; i < iTrackSelectionList.size(); i++)
+        {
+            PVMFTrackInfo* currTrack = iSourcePresInfoList.getTrackInfo(i);
+
+            for (uint32 j = i + 1; j < iTrackSelectionList.size(); j++)
+            {
+                // If the track has the same MIME type and needs to have a decoder node for it to be playabale track
+                // use the already created decoder node for the track.
+                PVMFTrackInfo* tmpTrack = iSourcePresInfoList.getTrackInfo(j);
+
+                if ((iTrackSelectionList[i].iTsDecNode != NULL) &&
+                        !(pv_mime_strcmp(currTrack->getTrackMimeType().get_str(), tmpTrack->getTrackMimeType().get_str())) &&
+                        !(iTrackSelectionList[j].iTsTrackValidForPlayableList))
+                {
+                    // These were earlier set in DoDecNodeQueryCapConfifIF to avoid multiple creation of same
+                    // decoder nodes.
+                    iTrackSelectionList[j].iTsDecNode = iTrackSelectionList[i].iTsDecNode;
+                    iTrackSelectionList[j].iTsDecNodeSessionId = iTrackSelectionList[i].iTsDecNodeSessionId;
+                    iTrackSelectionList[j].iTsDecNodeCapConfigIF = iTrackSelectionList[i].iTsDecNodeCapConfigIF;
+                }
+            }
+        }
+
+        // Now engine has all decoder and sink nodes setup for each valid track. Engine will now do the track selection based
+        // on config paramters of each track
+
+        SetEngineState(PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE);
+        RunIfNotReady();
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeInit() Out"));
+    return;
+}
+
 void PVPlayerEngine::HandleSourceNodePrepare(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
@@ -12432,13 +12488,13 @@
     {
         case PVMFSuccess:
         {
-            // Initiate the setup sequence for each datapath
+            // Datapaths are already set during intelligent track selection, just query for optional interfaces.
             iNumPendingDatapathCmd = 0;
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
                 if (iDatapathList[i].iTrackInfo != NULL)
                 {
-                    PVMFStatus retcode = DoSetupSinkNode(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
+                    PVMFStatus retcode = DoSinkNodeQueryInterfaceOptional(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
                     if (retcode == PVMFSuccess)
                     {
                         ++iNumPendingDatapathCmd;
@@ -12457,14 +12513,21 @@
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePrepare() No datapath could be setup. Asserting"));
                     OSCL_ASSERT(false);
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePrepare() Report command as failed"));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFFailure);
+                }
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
+                {
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePrepare() Already EH pending, should never happen"));
+                    return;
                 }
                 else
                 {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePrepare() Report command as failed"));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVPlayerEngine::HandleSourceNodePrepare() Report command as failed, Add EH Command"));
+                    iCommandCompleteStatusInErrorHandling = cmdstatus;
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                    AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
                 }
             }
         }
@@ -12472,8 +12535,15 @@
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodePrepare() failed, Add EH Command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePrepare() Already EH pending, should never happen"));
+                return;
+            }
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aNodeResp.GetEventExtensionInterface())
             {
@@ -12481,9 +12551,10 @@
             }
 
             PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
         }
         break;
     }
@@ -12491,127 +12562,63 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodePrepare() Out"));
 }
 
-
-void PVPlayerEngine::HandleSinkNodeQueryFileOutConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVPlayerEngine::HandleSinkNodeQueryFileOutConfigIF() Tick=%d", OsclTickCount::TickCount()));
-
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aNodeContext.iEngineDatapath->iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryFileOutConfigIF() In %s", aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
-
-    PVMFStatus cmdstatus = PVMFErrNotSupported;
-
-    switch (aNodeResp.GetCmdStatus())
-    {
-        case PVMFSuccess:
-        {
-            OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-            OSCL_ASSERT(aNodeContext.iEngineDatapath->iDataSink != NULL);
-
-            // Set the filename
-            aNodeContext.iEngineDatapath->iSinkNodeFOConfigIF->SetOutputFileName(aNodeContext.iEngineDatapath->iDataSink->GetDataSinkFilename());
-
-            // Query the sink node for optional ext IFs
-            cmdstatus = DoSinkNodeQueryInterfaceOptional(*(aNodeContext.iEngineDatapath), aNodeContext.iCmdId, aNodeContext.iCmdContext);
-            if (cmdstatus == PVMFErrNotSupported)
-            {
-                // Check if a dec node is needed
-                cmdstatus = DoSetupDecNode(*(aNodeContext.iEngineDatapath), aNodeContext.iCmdId, aNodeContext.iCmdContext);
-                if (cmdstatus == PVMFErrNotSupported)
-                {
-                    // Continue to prepare the datapath
-                    cmdstatus = DoDatapathPrepare(*(aNodeContext.iEngineDatapath), aNodeContext.iCmdId, aNodeContext.iCmdContext);
-                }
-            }
-
-            if (cmdstatus != PVMFSuccess)
-            {
-                HandleErrorBasedOnPlayerState();
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeQueryFileOutConfigIF() Report command as failed"));
-                EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-                --iNumPendingDatapathCmd;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-        }
-        break;
-
-        default:
-        {
-            HandleErrorBasedOnPlayerState();
-
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aNodeResp.GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
-            }
-
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkInit, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
-        }
-        break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryFileOutConfigIF() Out"));
-}
-
-
 void PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Tick=%d", OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aNodeContext.iEngineDatapath->iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() In %s", aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Determine QueryInterface() for which interface completed
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
     if (aNodeContext.iCmdType == PVP_CMD_SinkNodeQuerySyncCtrlIF)
     {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF)
+        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iSinkNodePVInterfaceSyncCtrl)
         {
+            aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF = (PvmfNodesSyncControlInterface*)aNodeContext.iEngineDatapath->iSinkNodePVInterfaceSyncCtrl;
+            aNodeContext.iEngineDatapath->iSinkNodePVInterfaceSyncCtrl = NULL;
+
             // Pass the playback clock to the sync control
             aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetClock(&iPlaybackClock);
-            // Set the sync margin based on media type
-            switch (aNodeContext.iEngineDatapath->iMediaType)
+
+            // Set the sync margin, find corresponding track for the datapath using mime string
+            bool videoTrack = false;
+            bool audioTrack = false;
+            bool textTrack = false;
+            bool retVal = FindTrackForDatapathUsingMimeString(videoTrack, audioTrack, textTrack, aNodeContext.iEngineDatapath);
+            if (textTrack && retVal)
             {
-                case PVP_MEDIATYPE_AUDIO:
-                    aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginAudio.min), iSyncMarginAudio.max);
-                    break;
-
-                case PVP_MEDIATYPE_TEXT:
-                    aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginText.min), iSyncMarginText.max);
-                    break;
-
-                case PVP_MEDIATYPE_VIDEO:
-                default:	// Use video's sync margin for unknown media type
-                    aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginVideo.min), iSyncMarginVideo.max);
-                    break;
+                // Text track
+                aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginText.min), iSyncMarginText.max);
+            }
+            else if (audioTrack && retVal)
+            {
+                // Audio track
+                aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginAudio.min), iSyncMarginAudio.max);
+            }
+            else
+            {
+                // Video track available or an unknown datapath
+                aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginVideo.min), iSyncMarginVideo.max);
             }
         }
         else
         {
-            // Metadata is not available in this sink node
-            aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF = NULL;
+            // sync control interface is not available in this sink node
+            aNodeContext.iEngineDatapath->iSinkNodePVInterfaceSyncCtrl = NULL;
+            aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Metadata IF not available"));
+            OSCL_ASSERT(false);
         }
     }
     else if (aNodeContext.iCmdType == PVP_CMD_SinkNodeQueryMetadataIF)
     {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF)
+        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iSinkNodePVInterfaceMetadataExt)
         {
+            aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF = (PVMFMetadataExtensionInterface*)aNodeContext.iEngineDatapath->iSinkNodePVInterfaceMetadataExt;
+            aNodeContext.iEngineDatapath->iSinkNodePVInterfaceMetadataExt = NULL;
+
             // Add the video sink node's metadata extension IF to the list
-            if (AddToMetadataInterfaceList(aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF, aNodeContext.iEngineDatapath->iSinkNodeSessionId) != PVMFSuccess)
+            if (AddToMetadataInterfaceList(aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF, aNodeContext.iEngineDatapath->iSinkNodeSessionId, aNodeContext.iEngineDatapath, aNodeContext.iEngineDatapath->iSinkNode) != PVMFSuccess)
             {
                 aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF->removeRef();
                 aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF = NULL;
@@ -12621,23 +12628,11 @@
         else
         {
             // Metadata is not available in this video sink node
+            aNodeContext.iEngineDatapath->iSinkNodePVInterfaceMetadataExt = NULL;
             aNodeContext.iEngineDatapath->iSinkNodeMetadataExtIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Metadata IF not available"));
         }
     }
-    else if (aNodeContext.iCmdType == PVP_CMD_SinkNodeQueryCapConfigIF)
-    {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iSinkNodeCapConfigIF)
-        {
-            // Nothing to do here
-        }
-        else
-        {
-            // Cap-config is not available
-            aNodeContext.iEngineDatapath->iSinkNodeCapConfigIF = NULL;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Cap-Config IF not available"));
-        }
-    }
     else
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Unknown cmd type. Asserting"));
@@ -12651,7 +12646,7 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() All QueryInterface() commands complete"));
 
         // Create the decoder node if necessary
-        PVMFStatus cmdstatus = DoSetupDecNode(*(aNodeContext.iEngineDatapath), aNodeContext.iCmdId, aNodeContext.iCmdContext);
+        PVMFStatus cmdstatus = DoDecNodeQueryInterfaceOptional(*(aNodeContext.iEngineDatapath), aNodeContext.iCmdId, aNodeContext.iCmdContext);
         if (cmdstatus == PVMFErrNotSupported)
         {
             cmdstatus = DoDatapathPrepare(*(aNodeContext.iEngineDatapath), aNodeContext.iCmdId, aNodeContext.iCmdContext);
@@ -12659,205 +12654,50 @@
 
         if (cmdstatus != PVMFSuccess)
         {
-            HandleErrorBasedOnPlayerState();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Report command as failed, Add EH Command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            }
         }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeQueryInterfaceOptional() Out"));
 }
 
-void PVPlayerEngine::HandleSinkNodeDecNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVPlayerEngine::HandleSinkNodeDecNodeQueryCapConfigIF() Tick=%d", OsclTickCount::TickCount()));
-
-    OSCL_UNUSED_ARG(aNodeResp);
-
-    if (aNodeContext.iCmdType != PVP_CMD_SinkNodeDecNodeQueryCapConfigIF)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeQueryCapConfigIF() Unknown cmd type. Asserting"));
-        OSCL_ASSERT(false);
-    }
-    // Decrement the pending counter and go to next step if 0.
-    OSCL_ASSERT(iNumPendingNodeCmd > 0);
-    --iNumPendingNodeCmd;
-    if (iNumPendingNodeCmd == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeQueryCapConfigIF() All QueryInterface() commands complete"));
-
-        PVMFStatus cmdstatus = DoSinkNodeInit(aNodeContext.iCmdId, aNodeContext.iCmdContext);
-        if (cmdstatus != PVMFSuccess)
-        {
-            HandleErrorBasedOnPlayerState();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeQueryCapConfigIF() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
-            return;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeQueryCapConfigIF() Out"));
-
-}
-
-void PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter() Tick=%d", OsclTickCount::TickCount()));
-
-    OSCL_UNUSED_ARG(aNodeResp);
-
-    if (aNodeContext.iCmdType != PVP_CMD_SinkNodeDecNodeVerifyParameter)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter() Unknown cmd type. Asserting"));
-        OSCL_ASSERT(false);
-    }
-
-    // Decrement the pending counter and go to next step if 0.
-    OSCL_ASSERT(iNumPendingNodeCmd > 0);
-    --iNumPendingNodeCmd;
-    if (iNumPendingNodeCmd == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter() All Sinknode Init() commands complete"));
-        PVMFStatus cmdstatus = PVMFFailure;
-
-        // Select tracks based on available engine datapaths
-        cmdstatus = DoSourceNodeTrackSelection(aNodeContext.iCmdId, aNodeContext.iCmdContext);
-        if (cmdstatus != PVMFSuccess)
-        {
-            HandleErrorBasedOnPlayerState();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
-            return;
-        }
-
-        // Reset SinkNode and MIO on available engine datapaths
-        cmdstatus = DoSinkNodeReset(aNodeContext.iCmdId, aNodeContext.iCmdContext);
-        if (cmdstatus != PVMFSuccess)
-        {
-            HandleErrorBasedOnPlayerState();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
-            return;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeVerifyParameter() Out"));
-}
-
 void PVPlayerEngine::HandleSinkNodeDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
+    OSCL_UNUSED_ARG(aNodeContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Tick=%d", OsclTickCount::TickCount()));
 
-    OSCL_UNUSED_ARG(aNodeResp);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() In"));
 
-    if (aNodeContext.iCmdType != PVP_CMD_SinkNodeDecNodeReset)
+    if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Unknown cmd type. Asserting"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Reset failed, assert"));
         OSCL_ASSERT(false);
+        return;
     }
 
     // Decrement the pending counter and go to next step if 0.
-    OSCL_ASSERT(iNumPendingNodeCmd > 0);
     --iNumPendingNodeCmd;
     if (iNumPendingNodeCmd == 0)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() All Sinknode Reset() commands complete"));
-
-        //Destroy created temporal decoder node and sink node
-        for (uint32 i = 0; i < iDatapathList.size(); ++i)
-        {
-            if (iDatapathList[i].iDecNode != NULL)
-            {
-                if (iDatapathList[i].iDecNodeCapConfigIF == NULL)
-                    iDatapathList[i].iDecNodeCapConfigIF = NULL;
-                iDatapathList[i].iDecNode->Disconnect(iDatapathList[i].iDecNodeSessionId);
-                iDatapathList[i].iDecNode->ThreadLogoff();
-                PVPlayerEngineUuidNodeMapping* iter = iNodeUuids.begin();
-                for (; iter != iNodeUuids.end(); ++iter)
-                    if (iter->iNode == iDatapathList[i].iDecNode)
-                        break;
-
-                if (iter != iNodeUuids.end())
-                {
-                    bool release_status = false;
-
-                    int32 leavecode = 0;
-                    OSCL_TRY(leavecode, release_status = iPlayerNodeRegistry.ReleaseNode(iter->iUuid, iDatapathList[i].iDecNode));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Error in releasing DecNode"));
-                                         return;);
-
-                    if (release_status == false)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Factory returned false while releasing the decnode"));
-                        return;
-                    }
-
-                    iNodeUuids.erase(iter);
-                    iDatapathList[i].iDecNode = NULL;
-                }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() decnode not found"));
-                    return;
-                }
-            }
-            if (iDatapathList[i].iSinkNode != NULL)
-            {
-                iDatapathList[i].iSinkNode->Disconnect(iDatapathList[i].iSinkNodeSessionId);
-                iDatapathList[i].iSinkNode->ThreadLogoff();
-                if (iDatapathList[i].iSinkNodeCapConfigIF == NULL)
-                    iDatapathList[i].iSinkNodeCapConfigIF = NULL;
-                if (iDatapathList[i].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_FILENAME)
-                {
-                    PVFileOutputNodeFactory::DeleteFileOutput(iDatapathList[i].iSinkNode);
-                    iDatapathList[i].iSinkNode = NULL;
-                }
-                else if (iDatapathList[i].iDataSink->GetDataSinkType() == PVP_DATASINKTYPE_SINKNODE)
-                {
-                    iDatapathList[i].iSinkNode = NULL;
-                }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Unsupported player data sink type"));
-                    OSCL_ASSERT(false);
-                    return;
-                }
-            }
-        }
-
-        // Prepare the source node
-        PVMFStatus cmdstatus = DoSourceNodePrepare(aNodeContext.iCmdId, aNodeContext.iCmdContext);
-        if (cmdstatus != PVMFSuccess)
-        {
-            HandleErrorBasedOnPlayerState();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
-            return;
-        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() All Sinknode and decnode Reset() commands complete"));
+        SetEngineState(PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE);
+        RunIfNotReady();
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeDecNodeReset() Out"));
@@ -12868,18 +12708,18 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Tick=%d", OsclTickCount::TickCount()));
 
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aNodeContext.iEngineDatapath->iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() In %s", aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Determine QueryInterface() for which interface completed
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
     if (aNodeContext.iCmdType == PVP_CMD_DecNodeQueryMetadataIF)
     {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF)
+        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iDecNodePVInterfaceMetadataExt)
         {
+            aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF = (PVMFMetadataExtensionInterface*)aNodeContext.iEngineDatapath->iDecNodePVInterfaceMetadataExt;
+            aNodeContext.iEngineDatapath->iDecNodePVInterfaceMetadataExt = NULL;
+
             // Add the video dec node's metadata extension IF to the list
-            if (AddToMetadataInterfaceList(aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF, aNodeContext.iEngineDatapath->iDecNodeSessionId) != PVMFSuccess)
+            if (AddToMetadataInterfaceList(aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF, aNodeContext.iEngineDatapath->iDecNodeSessionId, aNodeContext.iEngineDatapath, aNodeContext.iEngineDatapath->iDecNode) != PVMFSuccess)
             {
                 aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF->removeRef();
                 aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF = NULL;
@@ -12890,60 +12730,55 @@
         else
         {
             // Metadata is not available in this dec node
+            aNodeContext.iEngineDatapath->iDecNodePVInterfaceMetadataExt = NULL;
             aNodeContext.iEngineDatapath->iDecNodeMetadataExtIF = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Metadata IF not available"));
         }
     }
-    else if (aNodeContext.iCmdType == PVP_CMD_DecNodeQueryCapConfigIF)
-    {
-        if (aNodeResp.GetCmdStatus() == PVMFSuccess && aNodeContext.iEngineDatapath->iDecNodeCapConfigIF)
-        {
-            // Configure the dec node for player use
-            PvmiKvp kvpparam;
-            PvmiKvp* retkvp = NULL;
-            OSCL_StackString<64> kvpparamkey;
-
-            switch (aNodeContext.iEngineDatapath->iMediaType)
-            {
-                case PVP_MEDIATYPE_VIDEO:
-                    // Disable drop frame mode
-                    kvpparamkey = _STRLIT_CHAR("x-pvmf/video/decoder/dropframe_enable;valtype=bool");
-                    kvpparam.value.bool_value = false;
-                    break;
-
-                case PVP_MEDIATYPE_AUDIO:
-                    // Disable silence insertion
-                    kvpparamkey = _STRLIT_CHAR("x-pvmf/audio/decoder/silenceinsertion_enable;valtype=bool");
-                    kvpparam.value.bool_value = false;
-                    break;
-
-                default:
-                    break;
-            }
-
-            if (kvpparamkey.get_size() > 0)
-            {
-                kvpparam.key = kvpparamkey.get_str();
-                aNodeContext.iEngineDatapath->iDecNodeCapConfigIF->setParametersSync(NULL, &kvpparam, 1, retkvp);
-                if (retkvp != NULL)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Configuring dec node for player use via cap-config IF failed"));
-                }
-            }
-        }
-        else
-        {
-            // Cap-config is not available
-            aNodeContext.iEngineDatapath->iDecNodeCapConfigIF = NULL;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Cap-Config IF not available"));
-        }
-    }
     else
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Unknown cmd type. Asserting"));
         OSCL_ASSERT(false);
     }
 
+    if (aNodeContext.iEngineDatapath->iDecNodeCapConfigIF)
+    {
+        // Configure the dec node for player use
+        PvmiKvp kvpparam;
+        PvmiKvp* retkvp = NULL;
+        OSCL_StackString<64> kvpparamkey;
+
+        bool videoTrack = false;
+        bool audioTrack = false;
+        bool textTrack = false;
+        bool retVal = FindTrackForDatapathUsingMimeString(videoTrack, audioTrack, textTrack, aNodeContext.iEngineDatapath);
+        if (videoTrack && retVal)
+        {
+            // Video track
+            // Disable drop frame mode
+            kvpparamkey = _STRLIT_CHAR("x-pvmf/video/decoder/dropframe_enable;valtype=bool");
+            kvpparam.value.bool_value = false;
+        }
+        else if (audioTrack && retVal)
+        {
+            // Audio track
+            // Disable silence insertion
+            kvpparamkey = _STRLIT_CHAR("x-pvmf/audio/decoder/silenceinsertion_enable;valtype=bool");
+            kvpparam.value.bool_value = false;
+            aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->SetMargins((-1*iSyncMarginAudio.min), iSyncMarginAudio.max);
+        }
+
+        if (kvpparamkey.get_size() > 0)
+        {
+            kvpparam.key = kvpparamkey.get_str();
+            aNodeContext.iEngineDatapath->iDecNodeCapConfigIF->setParametersSync(NULL, &kvpparam, 1, retkvp);
+            if (retkvp != NULL)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Configuring dec node for player use via cap-config IF failed"));
+            }
+        }
+    }
+
     // Decrement the pending counter and go to next step if 0.
     OSCL_ASSERT(aNodeContext.iEngineDatapath->iNumPendingCmd > 0);
     --aNodeContext.iEngineDatapath->iNumPendingCmd;
@@ -12956,13 +12791,21 @@
 
         if (cmdstatus != PVMFSuccess)
         {
-            HandleErrorBasedOnPlayerState();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Report command as failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeQueryInterfaceOptional() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            }
         }
     }
 
@@ -12974,16 +12817,23 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() In"));
 
+    PVMFTimestamp requesttime = iTargetNPT;
+
     if (aNodeResp.GetCmdStatus() == PVMFErrNotSupported || aNodeResp.GetCmdStatus() == PVMFErrArgument)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() QueryDataSourcePosition failed. Assume position goes to requested position"));
-        iActualPlaybackPosition = iCurrentBeginPosition.iPosValue.millisec_value;
     }
     else if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
-        // If not unsupported error, then assume fatal error from source node
-        HandleErrorBasedOnPlayerState();
-
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() QueryDataSourcePosition failed, Add EH command"));
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePause() Already EH pending, should never happen"));
+            return;
+        }
         PVMFErrorInfoMessageInterface* nextmsg = NULL;
         if (aNodeResp.GetEventExtensionInterface())
         {
@@ -12991,65 +12841,72 @@
         }
 
         PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
+        iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+        iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+
+        if (iState == PVP_ENGINE_STATE_PREPARING)
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+        else if (iState == PVP_ENGINE_STATE_RESUMING)
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
         return;
     }
     else
     {
-        // Every thing is OK.. Calculate the iActualPlaybackPosition depensing upon nearest before and after syncPoints.
-        //  For MPEG4 files
-
         PVMFNodeCapability nodeCapability;
         iSourceNode->GetCapability(nodeCapability);
         PVMFFormatType * formatType = nodeCapability.iInputFormatCapability.begin();
         bool mpeg4FormatType = false;
         if (formatType != NULL)
         {
-            switch (*formatType)
+            if ((pv_mime_strcmp((char*)formatType->getMIMEStrPtr(), PVMF_MIME_MPEG4FF)) == 0)
             {
-                case PVMF_MPEG4FF:
-                    mpeg4FormatType = true;
-                    break;
-
-                default:
-                    mpeg4FormatType = false;
-                    break;
+                mpeg4FormatType = true;
+            }
+            else
+            {
+                mpeg4FormatType = false;
             }
         }
 
         if (mpeg4FormatType)
         {
+            // Every thing is OK.. Calculate the modified target position depending upon nearest before and after syncPoints.
+            // For MPEG4 files
             CalculateActualPlaybackPosition();
         }
     }
 
     // Determine the SetDataSourcePosition parameter based on query result and reposition settings
-    PVMFTimestamp requesttime = iCurrentBeginPosition.iPosValue.millisec_value;
-    bool seektosyncpt = true;
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,
                     "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition()"
-                    "Requested NPT %d, Actual NPT %d", requesttime, iActualPlaybackPosition));
+                    "Requested NPT %d, Modified Target NPT %d", requesttime, iTargetNPT));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0,
+                    "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition()"
+                    "Requested NPT %d, Modified Target NPT %d", requesttime, iTargetNPT));
 
     uint32 startOfSeekWindow = 0;
-    if (iCurrentBeginPosition.iPosValue.millisec_value > iSyncPointSeekWindow)
+    if (requesttime > iSyncPointSeekWindow)
     {
-        startOfSeekWindow = (iCurrentBeginPosition.iPosValue.millisec_value - iSyncPointSeekWindow);
+        startOfSeekWindow = (requesttime - iSyncPointSeekWindow);
     }
-    uint32 endOfSeekWindow = iCurrentBeginPosition.iPosValue.millisec_value + iSyncPointSeekWindow;
+    uint32 endOfSeekWindow = requesttime + iSyncPointSeekWindow;
 
-    // 1) Check if the actual seek point falls within the window
-    if ((iActualPlaybackPosition >= startOfSeekWindow) &&
-            (iActualPlaybackPosition <= endOfSeekWindow))
+    // 1) Check if the modified target position falls within the window
+    if ((iTargetNPT >= startOfSeekWindow) &&
+            (iTargetNPT <= endOfSeekWindow))
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0,
                         "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() - "
-                        "RequestedNPT(%d) ActualNPT(%d) is in the window (%d, %d), Seeking To %d",
-                        requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow, iActualPlaybackPosition));
+                        "RequestedNPT(%d) ModifiedTargetNPT(%d) is in the window (%d, %d), Seeking To %d",
+                        requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, iTargetNPT));
 
-        requesttime = iActualPlaybackPosition;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0,
+                        "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() - "
+                        "RequestedNPT(%d) ModifiedTargetNPT(%d) is in the window (%d, %d), Seeking To %d",
+                        requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, iTargetNPT));
+
+        requesttime = iTargetNPT;
     }
     else
     {
@@ -13059,35 +12916,55 @@
         // go back to start of the seek window
         // SFR is not really an option here since we are not playing yet, therefore always
         // go to start of the window
-        if ((iActualPlaybackPosition < startOfSeekWindow) ||
-                (iActualPlaybackPosition > endOfSeekWindow))
+        if ((iTargetNPT < startOfSeekWindow) ||
+                (iTargetNPT > endOfSeekWindow))
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0,
                             "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() - "
-                            "RequestedNPT(%d) ActualNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt False",
-                            requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
+                            "RequestedNPT(%d) ModifiedTargetNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt False",
+                            requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0,
+                            "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() - "
+                            "RequestedNPT(%d) ModifiedTargetNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt False",
+                            requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
 
             requesttime = startOfSeekWindow;
-            seektosyncpt = false;
-            iActualPlaybackPosition = requesttime;
+            iTargetNPT = requesttime;
         }
         else
         {
             //error
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,
                             "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() - "
-                            "RequestedNPT(%d) ActualNPT(%d) window (%d, %d), Error Condition Asserting",
-                            requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow));
+                            "RequestedNPT(%d) ModifiedTargetNPT(%d) window (%d, %d), Error Condition Asserting",
+                            requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow));
             OSCL_ASSERT(false);
         }
     }
 
     // Do the source positioning
-    PVMFStatus retval = DoSourceNodeSetDataSourcePosition(aNodeContext.iCmdId, aNodeContext.iCmdContext, requesttime, seektosyncpt);
+    PVMFStatus retval = DoSourceNodeSetDataSourcePosition(aNodeContext.iCmdId, aNodeContext.iCmdContext);
     if (retval != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() Report command as failed"));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, retval);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() Report command as failed, Add EH command"));
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() Already EH pending, should never happen"));
+            return;
+        }
+        else
+        {
+            iCommandCompleteStatusInErrorHandling = retval;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            if (iState == PVP_ENGINE_STATE_PREPARING)
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            else if (iState == PVP_ENGINE_STATE_RESUMING)
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
+        }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePosition() Out"));
@@ -13105,9 +12982,6 @@
         case PVMFErrArgument:
         case PVMFErrNotSupported:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Requested begin position(%d ms) is not supported so start from time 0.",
-                             iCurrentBeginPosition.iPosValue.millisec_value));
             if (iChangePlaybackPositionWhenResuming)
             {
                 PVPPlaybackPosition curpos;
@@ -13115,34 +12989,48 @@
                 GetPlaybackClockPosition(curpos);
                 uint32 clockcurpos = 0;
                 bool tmpbool = false;
-                iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, OSCLCLOCK_MSEC);
+                iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
 
                 // since repositioning is not supported and if the playback position change request was
                 // issued during paused state, then continue from paused position.
+                iChangePlaybackPositionWhenResuming = false;
                 iWatchDogTimerInterval = 0;
-                iActualPlaybackPosition = curpos.iPosValue.millisec_value;
+                iActualNPT = curpos.iPosValue.millisec_value;
                 iActualMediaDataTS = clockcurpos;
-                iAdjustedMediaDataTS = clockcurpos;
+                iSkipMediaDataTS = clockcurpos;
 
-                iStartNPT = iActualPlaybackPosition;
-                iStartMediaDataTS = iAdjustedMediaDataTS;
+                iStartNPT = iActualNPT;
+                iStartMediaDataTS = iSkipMediaDataTS;
+
+                // also decrement the stream id as no skip will be called on MIO node.
+                --iStreamID;
+
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoChangePlaybackPositionNotSupported, puuid, NULL));
+                SendInformationalEvent(PVMFInfoChangePlaybackPositionNotSupported, OSCL_STATIC_CAST(PVInterface*, infomsg));
+                infomsg->removeRef();
             }
             else
             {
+                // This happens when we are in preparing state
                 // Since this repositioning was not supported, assume the playback
                 // will start from time 0
                 iWatchDogTimerInterval = 0;
-                iActualPlaybackPosition = 0;
+                iActualNPT = 0;
                 iActualMediaDataTS = 0;
-                iAdjustedMediaDataTS = 0;
+                iSkipMediaDataTS = 0;
                 // Then continue to handle like success case
                 iStartNPT = 0;
                 iStartMediaDataTS = 0;
             }
 
             // Save the actual starting position for GetPlaybackRange() query
-            iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+            iTargetNPT = iActualNPT;
+            iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
             iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Requested begin position(%d ms) is not supported so start from prev location.",
+                             iTargetNPT));
         }
         break;
 
@@ -13150,63 +13038,86 @@
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() SetDataSourcePosition() successful. StartMediaTS %d ms, ActualNPT %d ms, TargetNPT %d ms",
-                             iActualMediaDataTS, iActualPlaybackPosition, iCurrentBeginPosition.iPosValue.millisec_value));
+                             iActualMediaDataTS, iActualNPT, iTargetNPT));
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
                             (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() SetDataSourcePosition() successful. StartMediaTS %d ms, ActualNPT %d ms, TargetNPT %d ms",
-                             iActualMediaDataTS, iActualPlaybackPosition, iCurrentBeginPosition.iPosValue.millisec_value));
+                             iActualMediaDataTS, iActualNPT, iTargetNPT));
             // Compute the difference between actualNPT and targetNPT before any adjustments
-            if (iCurrentBeginPosition.iPosValue.millisec_value >= iActualPlaybackPosition)
+            if (iTargetNPT >= iActualNPT)
             {
-                iWatchDogTimerInterval = iCurrentBeginPosition.iPosValue.millisec_value - iActualPlaybackPosition;
+                iWatchDogTimerInterval = iTargetNPT - iActualNPT;
             }
 
             // Determine if adjustment needed to skip to requested time
-            if (iSkipToRequestedPosition && (iActualPlaybackPosition < iCurrentBeginPosition.iPosValue.millisec_value))
+            if (iSkipToRequestedPosition && (iActualNPT < iTargetNPT))
             {
-                if (iCurrentBeginPosition.iPosValue.millisec_value - iActualPlaybackPosition > SYNC_POINT_DIFF_THRESHOLD)
+                if (iTargetNPT - iActualNPT > iNodeDataQueuingTimeout)
                 {
                     // Sync point seems to be far away in the stream
                     // Can't adjust the skip time back so use the returned values to skip to
-                    iAdjustedMediaDataTS = iActualMediaDataTS;
-                    iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+                    iSkipMediaDataTS = iActualMediaDataTS;
+                    iTargetNPT = iActualNPT;
                     iWatchDogTimerInterval = 0;
+                    iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
                 }
                 else
                 {
-                    // Adjust the media data time to skip-to to correspond to the requested time
-                    // Add the difference of target NPT with actual playback position in NPT to the actual media data time to get time to skip to.
-                    iAdjustedMediaDataTS = iActualMediaDataTS + (iCurrentBeginPosition.iPosValue.millisec_value - iActualPlaybackPosition);
-                    iActualPlaybackPosition = iCurrentBeginPosition.iPosValue.millisec_value;
+                    //check if source node wants to override
+                    uint32 startNPTFrmSource = iActualNPT;
+                    if (iSourceNodePBCtrlIF->ComputeSkipTimeStamp(iTargetNPT,
+                            iActualNPT,
+                            iActualMediaDataTS,
+                            iSkipMediaDataTS,
+                            startNPTFrmSource) == PVMFSuccess)
+                    {
+                        iWatchDogTimerInterval = startNPTFrmSource - iActualNPT;
+                        iActualNPT = startNPTFrmSource;
+                        iTargetNPT = iActualNPT;
+                        iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
+                    }
+                    else
+                    {
+                        // Adjust the media data time to skip-to to correspond to the requested time
+                        // Add the difference of target NPT with actual playback position in NPT to the actual media data time to get time to skip to.
+                        iSkipMediaDataTS = iActualMediaDataTS + (iTargetNPT - iActualNPT);
+                        iActualNPT = iTargetNPT;
+                    }
                 }
             }
             else
             {
                 // Can't adjust the skip time back so use the returned values to skip to
-                iAdjustedMediaDataTS = iActualMediaDataTS;
-                iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+                iSkipMediaDataTS = iActualMediaDataTS;
+                iTargetNPT = iActualNPT;
+                iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
                 iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
                 iWatchDogTimerInterval = 0;
             }
 
             // Save initial NTP and TS values
-            iStartNPT = iActualPlaybackPosition;
-            iStartMediaDataTS = iAdjustedMediaDataTS;
+            iStartNPT = iActualNPT;
+            iStartMediaDataTS = iSkipMediaDataTS;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() After adjustment StartMediaTS %d ms, AdjustedMediaTS %d ms, ActualPBPos %d ms Start NPT %d Start TS %d",
-                             iActualMediaDataTS, iAdjustedMediaDataTS, iActualPlaybackPosition, iStartNPT, iStartMediaDataTS));
+                             iActualMediaDataTS, iSkipMediaDataTS, iActualNPT, iStartNPT, iStartMediaDataTS));
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
                             (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() After adjustment StartMediaTS %d ms, AdjustedMediaTS %d ms, ActualNPT %d ms StartNPT %d StartTS %d",
-                             iActualMediaDataTS, iAdjustedMediaDataTS, iActualPlaybackPosition, iStartNPT, iStartMediaDataTS));
+                             iActualMediaDataTS, iSkipMediaDataTS, iActualNPT, iStartNPT, iStartMediaDataTS));
         }
         break;
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
-            cmdstatus = aNodeResp.GetCmdStatus();
-
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Already EH pending, should never happen"));
+                return;
+            }
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aNodeResp.GetEventExtensionInterface())
             {
@@ -13214,17 +13125,21 @@
             }
 
             PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+
+            if (iState == PVP_ENGINE_STATE_PREPARING)
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            else if (iState == PVP_ENGINE_STATE_RESUMING)
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
+
             return;
         }
     }
-
     // Repositioning so reset the EOS flag for each active datapath
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive)
+        if (iDatapathList[i].iDatapath)
         {
             iDatapathList[i].iEndOfDataReceived = false;
         }
@@ -13234,8 +13149,23 @@
     cmdstatus = DoSourceNodeStart(aNodeContext.iCmdId, aNodeContext.iCmdContext);
     if (cmdstatus != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Report command as failed"));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Report command as failed, Add EH command"));
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
+        {
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Already EH pending, should never happen"));
+            return;
+        }
+        else
+        {
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            if (iState == PVP_ENGINE_STATE_PREPARING)
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            else if (iState == PVP_ENGINE_STATE_RESUMING)
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
+        }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Out"));
@@ -13259,6 +13189,10 @@
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Requested direction is not supported!"));
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoChangePlaybackPositionNotSupported, puuid, NULL));
+                SendInformationalEvent(PVMFInfoChangePlaybackPositionNotSupported, OSCL_STATIC_CAST(PVInterface*, infomsg));
+                infomsg->removeRef();
             }
             break;
 
@@ -13266,15 +13200,15 @@
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                                 (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() SetDataSourceDirection() successful. StartMediaTS %d ms, ActualPBPos %d ms",
-                                 iActualMediaDataTS, iActualPlaybackPosition));
+                                 iActualMediaDataTS, iActualNPT));
 
                 //there's no adjustment to the media TS here.
-                iAdjustedMediaDataTS = iActualMediaDataTS;
-                iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+                iSkipMediaDataTS = iActualMediaDataTS;
+                iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
                 iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
 
                 //Install the new direction and get the repositioning target.
-                UpdateDirection(iActualPlaybackPosition, iAdjustedMediaDataTS, iChangeDirectionNPT);
+                UpdateDirection(iActualNPT, iSkipMediaDataTS, iChangeDirectionNPT);
 
                 //Reposition the source to the desired playback time
                 if (!iChangeDirectionNPT.iIndeterminate)
@@ -13305,10 +13239,15 @@
 
             default:
             {
-                HandleErrorBasedOnPlayerState();
-
-                cmdstatus = aNodeResp.GetCmdStatus();
-
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() failed, Add EH command"));
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
+                {
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Already EH pending, should never happen"));
+                    return;
+                }
                 PVMFErrorInfoMessageInterface* nextmsg = NULL;
                 if (aNodeResp.GetEventExtensionInterface())
                 {
@@ -13316,9 +13255,9 @@
                 }
 
                 PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-                PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-                EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-                errmsg->removeRef();
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Out"));
                 return;
             }
@@ -13328,7 +13267,7 @@
         // Repositioning so reset the EOS flag for each active datapath
         for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive)
+            if (iDatapathList[i].iDatapath)
             {
                 iDatapathList[i].iEndOfDataReceived = false;
             }
@@ -13338,8 +13277,21 @@
         cmdstatus = DoSourceNodeStart(aNodeContext.iCmdId, aNodeContext.iCmdContext);
         if (cmdstatus != PVMFSuccess)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Report command as failed"));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePosition() Report command as failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
+            }
         }
     }
     else
@@ -13355,14 +13307,32 @@
             if (aNodeResp.GetCmdStatus() == PVMFErrNotSupported || aNodeResp.GetCmdStatus() == PVMFErrArgument)
             {
                 // For non-fatal error, continue playback by resuming the clock
-                iPlaybackClock.Start();
-                // To get regular play status events
-                StartPlaybackStatusTimer();
+                StartPlaybackClock();
             }
             else
             {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() failed, Add EH command"));
                 // Initiate error handling
-                HandleErrorBasedOnPlayerState();
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
+                {
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Already EH pending, should never happen"));
+                    return;
+                }
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aNodeResp.GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+                }
+
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE, NULL, NULL, NULL, false);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Out"));
+                return;
             }
 
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
@@ -13376,9 +13346,6 @@
             // Complete the SetPlaybackRate() command as failed
             EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
 
-            // Report an error event here but do nothing to the playback
-            SendErrorEvent(aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-
             errmsg->removeRef();
             errmsg = NULL;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourceDirection() Out"));
@@ -13386,12 +13353,12 @@
         }
 
         // no adjustement here.
-        iAdjustedMediaDataTS = iActualMediaDataTS;
-        iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+        iSkipMediaDataTS = iActualMediaDataTS;
+        iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
         iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
 
         //Install the new direction and get the repositioning target
-        UpdateDirection(iActualPlaybackPosition, iAdjustedMediaDataTS, iChangeDirectionNPT);
+        UpdateDirection(iActualNPT, iSkipMediaDataTS, iChangeDirectionNPT);
 
         //Launch a repositioning sequence now.
         if (!iChangeDirectionNPT.iIndeterminate)
@@ -13415,7 +13382,7 @@
         // Repositioning so reset the EOS flag for each active datapath
         for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive)
+            if (iDatapathList[i].iDatapath)
             {
                 iDatapathList[i].iEndOfDataReceived = false;
             }
@@ -13437,9 +13404,6 @@
             // Complete the SetPlaybackRate() command as failed
             EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
 
-            // Report an error event
-            SendErrorEvent(retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
-
             errmsg->removeRef();
             errmsg = NULL;
         }
@@ -13461,11 +13425,20 @@
     {
         case PVMFSuccess:
         {
+            // Issue Skip on Sink Node and Start on datapaths back to back. This is done to make sure that
+            // sink node is started only after discarding the data from an earlier stream.
+            cmdstatus = DoSinkNodeSkipMediaData(aNodeContext.iCmdId, aNodeContext.iCmdContext);
+            if (cmdstatus != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStart() Skip of sink node did a leave, asserting"));
+                OSCL_ASSERT(false);
+            }
+
             // Start the available datapaths
             iNumPendingDatapathCmd = 0;
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     PVMFStatus retval = DoDatapathStart(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
                     if (retval == PVMFSuccess)
@@ -13480,32 +13453,35 @@
                     }
                 }
             }
-
             if (iNumPendingDatapathCmd == 0)
             {
-                if (cmdstatus == PVMFErrNotSupported)
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine:HandleSourceNodeStart() DoDatapathStart failed, Add EH command"));
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
                 {
-                    // There are no active datapaths. Assert.
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStart() No datapath exists. Asserting"));
-                    OSCL_ASSERT(false);
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStart() Report command as failed"));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFFailure);
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine:HandleSourceNodeStart() Already EH pending, should never happen"));
+                    return;
                 }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStart() Report command as failed"));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-                }
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
             }
         }
-
         break;
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine:HandleSourceNodeStart() failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine:HandleSourceNodeStart() Already EH pending, should never happen"));
+                return;
+            }
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aNodeResp.GetEventExtensionInterface())
             {
@@ -13513,9 +13489,9 @@
             }
 
             PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
         }
         break;
     }
@@ -13526,6 +13502,7 @@
 
 void PVPlayerEngine::HandleSinkNodeSkipMediaData(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
+    OSCL_UNUSED_ARG(aNodeContext);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() for %s Tick=%d",
                      aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -13534,96 +13511,40 @@
                     (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() for %s, iNumPVMFInfoStartOfDataPending=%d",
                      aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), iNumPVMFInfoStartOfDataPending));
 
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() In"));
 
-    OSCL_ASSERT(iNumPendingNodeCmd > 0);
     --iNumPendingNodeCmd;
 
     if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
         // Sink node report error with SkipMediaData()
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aNodeResp.GetEventExtensionInterface())
-        {
-            nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-        return;
-
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() Sink node report error for SkipMediaData(). Asserting"));
+        OSCL_ASSERT(false);
     }
 
-    OSCL_ASSERT(iNumPendingSkipCompleteEvent > 0);
     --iNumPendingSkipCompleteEvent;
 
-
     if (iNumPendingNodeCmd == 0)
     {
-        PVMFTimestamp targetNPT = iCurrentBeginPosition.iPosValue.millisec_value;
-
-        // Set the clock to the specified begin time
-        iPlaybackClock.Stop();
-        iPlaybackClock.SetStartTime32(iAdjustedMediaDataTS, OSCLCLOCK_MSEC);
-
-        if (!(iWatchDogTimer->IsBusy()))
-        {
-            PVMFTimestamp targetNPT = iCurrentBeginPosition.iPosValue.millisec_value;
-            iWatchDogTimer->Cancel();
-            if (iWatchDogTimerInterval > 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                                (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() Setting WatchDogTimer for %d ms, TargetNPT=%d  ActualNPT=%d",
-                                 iWatchDogTimerInterval, targetNPT, iActualPlaybackPosition));
-                iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
-                iWatchDogTimer->Start();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                                (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() Skipping WatchDogTimer - Starting PlayBackClock"));
-                StartPlaybackClock();
-            }
-        }
-        // Set the actual playback position to the requested time since actual media data TS was adjusted
-        // This is important since the difference between the two is used to calculate the NPT to media data offset
-        // This is not required here as the ActualPlaybackPosition is already adjusted before calling Skip on Sink Node.
-        // iActualPlaybackPosition=iCurrentBeginPosition.iPosValue.millisec_value;
-
-        // Save the start NPT and TS
-        iStartNPT = iActualPlaybackPosition;
-        iStartMediaDataTS = iAdjustedMediaDataTS;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
-                        (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() TargetNPT %d, StartNPT %d StartTS %d",
-                         targetNPT, iStartNPT, iStartMediaDataTS));
+        // We dont start the playback clock here since engine is waiting for Start on Sink nodes to complete
+        // This will also check the order in which Sink Node completes the command. Sinks should complete Skip
+        // first and then Start, therefore iNumPendingDatapathCmd should always be greater than zero when
+        // this happens. If not just assert.
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                        (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() TargetNPT %d, StartNPT %d StartTS %d",
-                         targetNPT, iStartNPT, iStartMediaDataTS));
-
-        SetEngineState(PVP_ENGINE_STATE_PREPARED);
-
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFSuccess);
+                        (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() Skip Complete"));
     }
 
     if ((iNumPendingSkipCompleteEvent == 0) && (iNumPVMFInfoStartOfDataPending == 0))
     {
+        // we have received all the bos event so cancel the watchDogTimer if any.
         if (iWatchDogTimer->IsBusy())
         {
             iWatchDogTimer->Cancel();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData - WatchDogTimer cancelled"));
         }
-        // we have received all the bos event for
-        // playback hasnt started yet
-        StartPlaybackClock();
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() - PlayClock Started"));
     }
 
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaData() Out"));
 }
 
@@ -13632,54 +13553,47 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() In"));
 
+    PVMFTimestamp requesttime = iTargetNPT;
     if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() QueryDataSourcePosition failed. Assume position goes to requested position"));
-        iActualPlaybackPosition = iCurrentBeginPosition.iPosValue.millisec_value;
     }
     else
     {
-        // Every thing is OK.. Calculate the iActualPlaybackPosition depensing upon nearest before and after syncPoints.
-        //  For MPEG4 files
-
         PVMFNodeCapability nodeCapability;
         iSourceNode->GetCapability(nodeCapability);
         PVMFFormatType * formatType = nodeCapability.iInputFormatCapability.begin();
         bool mpeg4FormatType = false;
         if (formatType != NULL)
         {
-            switch (*formatType)
+            if ((pv_mime_strcmp((char*)formatType->getMIMEStrPtr(), PVMF_MIME_MPEG4FF)) == 0)
             {
-                case PVMF_MPEG4FF:
-                    mpeg4FormatType = true;
-                    break;
-
-                default:
-                    mpeg4FormatType = false;
-                    break;
+                mpeg4FormatType = true;
+            }
+            else
+            {
+                mpeg4FormatType = false;
             }
         }
         if (mpeg4FormatType)
         {
+            // Every thing is OK.. Calculate the modified target position depending upon nearest before and after syncPoints.
+            // For MPEG4 files
             CalculateActualPlaybackPosition();
         }
     }
 
-
     // Determine the SetDataSourcePosition parameter based on query result and reposition settings
-    PVMFTimestamp requesttime = iCurrentBeginPosition.iPosValue.millisec_value;
-    bool seektosyncpt = true;
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,
                     "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback()"
-                    "Requested NPT %d, Actual NPT %d", requesttime, iActualPlaybackPosition));
+                    "Requested NPT %d, ModifiedTarget NPT %d", requesttime, iTargetNPT));
 
     uint32 startOfSeekWindow = 0;
-    if (iCurrentBeginPosition.iPosValue.millisec_value > iSyncPointSeekWindow)
+    if (requesttime > iSyncPointSeekWindow)
     {
-        startOfSeekWindow = (iCurrentBeginPosition.iPosValue.millisec_value - iSyncPointSeekWindow);
+        startOfSeekWindow = (requesttime - iSyncPointSeekWindow);
     }
-    uint32 endOfSeekWindow = iCurrentBeginPosition.iPosValue.millisec_value + iSyncPointSeekWindow;
+    uint32 endOfSeekWindow = requesttime + iSyncPointSeekWindow;
 
     PVPPlaybackPosition curpos;
     curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
@@ -13689,42 +13603,42 @@
     //depending on whether it is fwd or rwnd, the window is different
     //if doing a rwnd, the worst case window is (0, currentplaybackposition)
     //if doing a fwd, the worst case window is (currentplaybackposition, endofclip)
-    if (iCurrentBeginPosition.iPosValue.millisec_value <= curpos.iPosValue.millisec_value)
+    if (requesttime <= curpos.iPosValue.millisec_value)
     {
         //requested pos <= currpos => rwnd
         //cap end of seek window to be the current play back pos
         endOfSeekWindow = curpos.iPosValue.millisec_value;
     }
-    if (iCurrentBeginPosition.iPosValue.millisec_value > curpos.iPosValue.millisec_value)
+    if (requesttime > curpos.iPosValue.millisec_value)
     {
         //requested pos > currpos => fwd
         //cap start of seek window to be the current play back pos
         startOfSeekWindow = curpos.iPosValue.millisec_value;
     }
 
-    // 1) Check if the actual seek point falls within the window
-    if ((iActualPlaybackPosition >= startOfSeekWindow) &&
-            (iActualPlaybackPosition <= endOfSeekWindow))
+    // 1) Check if the Modified target position falls within the window
+    if ((iTargetNPT >= startOfSeekWindow) &&
+            (iTargetNPT <= endOfSeekWindow))
     {
         // Check for SFR
         // In case if actual playback position
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0,
                         "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() - "
-                        "RequestedNPT(%d) ActualNPT(%d) is in the window (%d, %d), Seeking To %d",
-                        requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow, iActualPlaybackPosition));
+                        "RequestedNPT(%d) ModifiedTargetNPT(%d) is in the window (%d, %d), Seeking To %d",
+                        requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, iTargetNPT));
 
-        requesttime = iActualPlaybackPosition;
+        requesttime = iTargetNPT;
     }
     else
     {
         // Check for SFR
         // SFR means currplaybackpos < requestedpos
-        if (curpos.iPosValue.millisec_value < iCurrentBeginPosition.iPosValue.millisec_value)
+        if (curpos.iPosValue.millisec_value < requesttime)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0,
                             "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() - "
-                            "CurrNPT(%d) less than RequestedNPT(%d) Ignoring ActualNPT(%d) and the window (%d, %d), Doing SFR",
-                            curpos.iPosValue.millisec_value, requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
+                            "CurrNPT(%d) less than RequestedNPT(%d) Ignoring ModifiedTargetNPT(%d) and the window (%d, %d), Doing SFR",
+                            curpos.iPosValue.millisec_value, requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
 
             oSFR = true;
 
@@ -13745,22 +13659,20 @@
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0,
                                 "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() - "
-                                "RequestedNPT(%d) ActualNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt True",
-                                requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
+                                "RequestedNPT(%d) ModifiedTargetNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt True",
+                                requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
 
-                seektosyncpt = true;
-                iActualPlaybackPosition = requesttime;
+                iTargetNPT = requesttime;
             }
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0,
                                 "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() - "
-                                "RequestedNPT(%d) ActualNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt False",
-                                requesttime, iActualPlaybackPosition, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
+                                "RequestedNPT(%d) ModifiedTargetNPT(%d) is outside the window (%d, %d), Seeking To %d Seek-To-SyncPt False",
+                                requesttime, iTargetNPT, startOfSeekWindow, endOfSeekWindow, startOfSeekWindow));
 
                 requesttime = startOfSeekWindow;
-                seektosyncpt = false;
-                iActualPlaybackPosition = requesttime;
+                iTargetNPT = requesttime;
             }
         }
     }
@@ -13772,7 +13684,12 @@
         // Get current playback clock position in media data time
         uint32 clockcurpos = 0;
         bool tmpbool = false;
-        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, OSCLCLOCK_MSEC);
+        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
+
+        // for SFR since the source node is bypassed, there will be no frames generated with new
+        // Stream ID so, for skip to complete on Sink Node, Stream ID needs to be decremented. As
+        // there will be no new Stream in case of SFR.
+        --iStreamID;
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                         (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() New source reposition before current position so no need to change source position."));
@@ -13782,25 +13699,25 @@
             // Skip to the requested begin position
             // Add the difference of target NPT with current time in NPT to the current clock to get media data time to skip to.
             iActualMediaDataTS = clockcurpos;
-            iAdjustedMediaDataTS = (iCurrentBeginPosition.iPosValue.millisec_value - curpos.iPosValue.millisec_value) + clockcurpos;
-            iActualPlaybackPosition = requesttime;
-            iWatchDogTimerInterval = iCurrentBeginPosition.iPosValue.millisec_value - curpos.iPosValue.millisec_value;
+            iSkipMediaDataTS = (requesttime - curpos.iPosValue.millisec_value) + clockcurpos;
+            iActualNPT = requesttime;
+            iWatchDogTimerInterval = requesttime - curpos.iPosValue.millisec_value;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() Skip-to-requested position SET. ActualNPT=%d, ActualMediaTS=%d, AdjustedMediaTS=%d",
-                             iActualPlaybackPosition, iActualMediaDataTS, iAdjustedMediaDataTS));
+                             iActualNPT, iActualMediaDataTS, iSkipMediaDataTS));
         }
         else
         {
             // Just continue playback from current position
             iActualMediaDataTS = clockcurpos;
-            iAdjustedMediaDataTS = clockcurpos;
-            iActualPlaybackPosition = curpos.iPosValue.millisec_value;
+            iSkipMediaDataTS = clockcurpos;
+            iActualNPT = curpos.iPosValue.millisec_value;
             iWatchDogTimerInterval = 0;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() Skip-to-requested position NOT SET so continue playing. ActualNPT=%d, ActualMediaTS=%d, AdjustedMediaTS=%d",
-                             iActualPlaybackPosition, iActualMediaDataTS, iAdjustedMediaDataTS));
+                             iActualNPT, iActualMediaDataTS, iSkipMediaDataTS));
         }
 
         PVMFStatus retval = DoSinkNodeSkipMediaDataDuringPlayback(aNodeContext.iCmdId, aNodeContext.iCmdContext, true);
@@ -13816,9 +13733,6 @@
             // Complete the SetPlaybackRange() command as failed
             EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
 
-            // Report an error event here but do nothing to the playback
-            SendErrorEvent(retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
-
             errmsg->removeRef();
             errmsg = NULL;
         }
@@ -13827,7 +13741,7 @@
     else
     {
         // Do the source positioning
-        PVMFStatus retval = DoSourceNodeSetDataSourcePositionDuringPlayback(requesttime, seektosyncpt, aNodeContext.iCmdId, aNodeContext.iCmdContext);
+        PVMFStatus retval = DoSourceNodeSetDataSourcePositionDuringPlayback(aNodeContext.iCmdId, aNodeContext.iCmdContext);
         if (retval != PVMFSuccess)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeQueryDataSourcePositionDuringPlayback() SetDataSourcePosition failed. Playback position change has been cancelled"));
@@ -13837,9 +13751,6 @@
             // Complete the SetPlaybackRange() command as failed
             EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
 
-            // Report an error event here but do nothing to the playback
-            SendErrorEvent(aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-
             errmsg->removeRef();
             errmsg = NULL;
         }
@@ -13856,14 +13767,12 @@
     curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
     GetPlaybackClockPosition(curpos);
 
-    PVMFTimestamp targetNPT = iCurrentBeginPosition.iPosValue.millisec_value;
-
     // Following code has been taken from MP4 parser node, all the vars are kept very near to the MP4 parser node.
     // Previously the calculation of before and after sync point was done in MP4 parser node.
 
-    if (curpos.iPosValue.millisec_value > targetNPT)
+    if (curpos.iPosValue.millisec_value > iTargetNPT)
     {
-        // curpos.iPosValue.millisec_value was passed as iActualPlaybackPosition in QueryDataSourcePosition
+        // curpos.iPosValue.millisec_value was passed as iActualNPT in QueryDataSourcePosition
         // which became aActualNPT while collection, and used to decide forward and reverse repos.
         iBackwardReposFlag = true;
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::CalculateActualPlaybackPosition In: Backward Reposition"));
@@ -13877,7 +13786,7 @@
     // pick the closest time to targetNPT
     uint32 delta = 0;
     uint32 diffBetSeekPointBeforeAndTarget = 0;
-    if (IsEarlier(iSeekPointBeforeTargetNPT, targetNPT, delta))
+    if (PVTimeComparisonUtils::IsEarlier(iSeekPointBeforeTargetNPT, iTargetNPT, delta))
     {
         // this should always be true when checking the SeekPointBefore with
         // targetNPT.
@@ -13894,7 +13803,7 @@
     }
 
     uint32 diffBetSeekPointAfterAndTarget = 0;
-    if (IsEarlier(targetNPT, iSeekPointAfterTargetNPT, delta))
+    if (PVTimeComparisonUtils::IsEarlier(iTargetNPT, iSeekPointAfterTargetNPT, delta))
     {
         // this should always be true when checking the SeekPointAfter with
         // targetNPT.
@@ -13908,34 +13817,35 @@
         delta = 0;
     }
 
+    // modify the target NPT and set it to the closest I-frame returned by parser node.
     if (diffBetSeekPointAfterAndTarget < diffBetSeekPointBeforeAndTarget)
     {
-        iActualPlaybackPosition = iSeekPointAfterTargetNPT;
+        iTargetNPT = iSeekPointAfterTargetNPT;
     }
     else
     {
         if (iSeekPointBeforeTargetNPT < curpos.iPosValue.millisec_value && iForwardReposFlag)
         {
-            iActualPlaybackPosition = iSeekPointAfterTargetNPT;
+            iTargetNPT = iSeekPointAfterTargetNPT;
             iForwardReposFlag = false;
         }
         else
         {
-            iActualPlaybackPosition = iSeekPointBeforeTargetNPT;
+            iTargetNPT = iSeekPointBeforeTargetNPT;
             iForwardReposFlag = false;
         }
     }
     if (iBackwardReposFlag) // To avoid backwardlooping :: A flag to remember backward repositioning
     {
-        iActualPlaybackPosition = iSeekPointBeforeTargetNPT;
+        iTargetNPT = iSeekPointBeforeTargetNPT;
         iBackwardReposFlag = false;
     }
 
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,
                     "PVPlayerEngine::CalculateActualPlaybackPosition()"
-                    "targetNPT %d Current NPT %d, Actual NPT %d, SeekPointBeforeTargetNPT %d, SeekPointAfterTargetNPT %d ",
-                    targetNPT, curpos.iPosValue.millisec_value, iActualPlaybackPosition, iSeekPointBeforeTargetNPT, iSeekPointAfterTargetNPT));
+                    "targetNPT %d Current NPT %d, Modified Target NPT %d, SeekPointBeforeTargetNPT %d, SeekPointAfterTargetNPT %d ",
+                    iCurrentBeginPosition.iPosValue.millisec_value, curpos.iPosValue.millisec_value, iTargetNPT, iSeekPointBeforeTargetNPT, iSeekPointAfterTargetNPT));
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::CalculateActualPlaybackPosition Out"));
 }
@@ -13950,85 +13860,124 @@
 
         if (aNodeResp.GetCmdStatus() == PVMFErrNotSupported || aNodeResp.GetCmdStatus() == PVMFErrArgument)
         {
-            // For non-fatal error, continue playback by resuming the clock
-            iPlaybackClock.Start();
+            PVPPlaybackPosition curpos;
+            curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            GetPlaybackClockPosition(curpos);
+            uint32 clockcurpos = 0;
+            bool tmpbool = false;
+            iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
 
-            // To get regular play status events
-            StartPlaybackStatusTimer();
+            // since repositioning is not supported continue playing from current position.
+            iWatchDogTimerInterval = 0;
+            iActualNPT = curpos.iPosValue.millisec_value;
+            iActualMediaDataTS = clockcurpos;
+            iSkipMediaDataTS = clockcurpos;
+
+            iStartNPT = iActualNPT;
+            iStartMediaDataTS = iSkipMediaDataTS;
+
+            // also decrement the stream id as no skip will be called on MIO node.
+            --iStreamID;
+
+            // For non-fatal error, continue playback by resuming the clock
+            StartPlaybackClock();
+            // Complete the SetPlaybackRange() command as notsupported / failed
+            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus());
         }
         else
         {
-            // Initiate error handling
-            HandleErrorBasedOnPlayerState();
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePositionDuringPlayback() failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePositionDuringPlayback() Already EH pending, should never happen"));
+                return;
+            }
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aNodeResp.GetEventExtensionInterface())
+            {
+                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            }
+
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE, NULL, NULL, NULL, false);
         }
-
-        // Complete the SetPlaybackRange() command as notsupported / failed
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus());
-
         return;
     }
 
-
-    if ((iCurrentBeginPosition.iMode != PVPPBPOS_MODE_END_OF_CURRENT_PLAY_ELEMENT) && (iCurrentBeginPosition.iMode != PVPPBPOS_MODE_END_OF_CURRENT_PLAY_SESSION))
+    if ((iCurrentBeginPosition.iMode != PVPPBPOS_MODE_END_OF_CURRENT_PLAY_ELEMENT) &&
+            (iCurrentBeginPosition.iMode != PVPPBPOS_MODE_END_OF_CURRENT_PLAY_SESSION))
     {
-        uint32 targetNPT = iCurrentBeginPosition.iPosValue.millisec_value;
         if (iCurrentBeginPosition.iPosUnit == PVPPBPOSUNIT_PLAYLIST)
         {
             iActualMediaDataTS = iDataSourcePosParams.iActualMediaDataTS;
-            iActualPlaybackPosition = iDataSourcePosParams.iActualNPT;
-            /* Reset */
-            iDataSourcePosParams.iActualMediaDataTS = 0;
-            iDataSourcePosParams.iActualNPT = 0;
-            iDataSourcePosParams.iMode = PVMF_SET_DATA_SOURCE_POSITION_MODE_UNKNOWN;
-            iDataSourcePosParams.iPlayElementIndex = -1;
-            iDataSourcePosParams.iSeekToSyncPoint = true;
-            iDataSourcePosParams.iTargetNPT = 0;
-            targetNPT = iCurrentBeginPosition.iPlayListPosValue.millisec_value;
+            iActualNPT = iDataSourcePosParams.iActualNPT;
         }
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                         (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePositionDuringPlayback() SetDataSourcePosition() successful. StartMediaTS %d ms, ActualPBPos %d ms",
-                         iActualMediaDataTS, iActualPlaybackPosition));
+                         iActualMediaDataTS, iActualNPT));
 
         if (iCurrentBeginPosition.iPosUnit == PVPPBPOSUNIT_PLAYLIST)
         {
-            if (iCurrentBeginPosition.iPlayListPosValue.millisec_value >= iActualPlaybackPosition)
+            if (iTargetNPT >= iActualNPT)
             {
-                iWatchDogTimerInterval = iCurrentBeginPosition.iPlayListPosValue.millisec_value - iActualPlaybackPosition;
+                iWatchDogTimerInterval = iTargetNPT - iActualNPT;
             }
         }
         // Compute the difference between actualNPT and targetNPT before any adjustments
-        else if (iCurrentBeginPosition.iPosValue.millisec_value >= iActualPlaybackPosition)
+        else if (iTargetNPT >= iActualNPT)
         {
-            iWatchDogTimerInterval = iCurrentBeginPosition.iPosValue.millisec_value - iActualPlaybackPosition;
+            iWatchDogTimerInterval = iTargetNPT - iActualNPT;
         }
 
         //iCurrentBeginPosition.iPosUnit has served its purpose, it is ok if it is overwritten
-        if (iSkipToRequestedPosition && (iActualPlaybackPosition < targetNPT))
+        if (iSkipToRequestedPosition && (iActualNPT < iTargetNPT))
         {
-            if (targetNPT - iActualPlaybackPosition >= SYNC_POINT_DIFF_THRESHOLD)
+            if (iTargetNPT - iActualNPT >= iNodeDataQueuingTimeout)
             {
                 // Can't adjust the skip time back so use the returned values to skip to
-                iAdjustedMediaDataTS = iActualMediaDataTS;
-                iActualPlaybackPosition = targetNPT;
+                iSkipMediaDataTS = iActualMediaDataTS;
+                iActualNPT = iTargetNPT;
                 iWatchDogTimerInterval = 0;
             }
             else
             {
-                // Adjust the media data time to skip-to to correspond to the requested time
-                // Add the difference of target NPT with actual playback position in NPT to the actual media data time to get time to skip to.
-                iAdjustedMediaDataTS = iActualMediaDataTS + (targetNPT - iActualPlaybackPosition);
-                // Set the actual playback position to the requested time since actual media data TS was adjusted
-                // This is important since the difference between the two is used to calculate the NPT to media data offset in HandleSinkNodeskipMediaDataDuringPlayback()
-                iActualPlaybackPosition = targetNPT;
+                //check if source node wants to override
+                uint32 startNPTFrmSource = iActualNPT;
+                if (iSourceNodePBCtrlIF->ComputeSkipTimeStamp(iTargetNPT,
+                        iActualNPT,
+                        iActualMediaDataTS,
+                        iSkipMediaDataTS,
+                        startNPTFrmSource) == PVMFSuccess)
+                {
+                    iWatchDogTimerInterval = startNPTFrmSource - iActualNPT;
+                    iActualNPT = startNPTFrmSource;
+                }
+                else
+                {
+                    // Adjust the media data time to skip-to to correspond to the requested time
+                    // Add the difference of target NPT with actual playback position in NPT to the actual media data time to get time to skip to.
+                    iSkipMediaDataTS = iActualMediaDataTS + (iTargetNPT - iActualNPT);
+                    // Set the actual playback position to the requested time since actual media data TS was adjusted
+                    // This is important since the difference between the two is used to calculate the NPT to media data offset in HandleSinkNodeskipMediaDataDuringPlayback()
+                    iActualNPT = iTargetNPT;
+                }
+
             }
             iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
         }
         else
         {
             // Can't adjust the skip time back so just use the returned values to skip to
-            iAdjustedMediaDataTS = iActualMediaDataTS;
-            iCurrentBeginPosition.iPosValue.millisec_value = iActualPlaybackPosition;
+            iSkipMediaDataTS = iActualMediaDataTS;
+            iTargetNPT = iActualNPT;
+            iCurrentBeginPosition.iPosValue.millisec_value = iActualNPT;
             iCurrentBeginPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
             iWatchDogTimerInterval = 0;
         }
@@ -14036,16 +13985,16 @@
         uint32 clockcurpos = 0;
         bool tmpbool;
         // Get current playback clock position
-        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, OSCLCLOCK_MSEC);
+        iPlaybackClock.GetCurrentTime32(clockcurpos, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                         (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePositionDuringPlayback() After adjustment StartMediaTS %d ms, AdjustedMediaTS %d ms, ActualPBPos %d ms Clock %d ms",
-                         iActualMediaDataTS, iAdjustedMediaDataTS, iActualPlaybackPosition, clockcurpos));
+                         iActualMediaDataTS, iSkipMediaDataTS, iActualNPT, clockcurpos));
 
         // Repositioning so reset the EOS flag for each active datapath
         for (uint32 i = 0; i < iDatapathList.size(); ++i)
         {
-            if (iDatapathList[i].iTrackActive)
+            if (iDatapathList[i].iDatapath)
             {
                 iDatapathList[i].iEndOfDataReceived = false;
             }
@@ -14056,7 +14005,6 @@
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeSetDataSourcePositionDuringPlayback() Skipping media data request in sink nodes failed. Repositioning did not complete."));
 
-
             // clear the pending direction change NPT.
             iChangeDirectionNPT.iIndeterminate = true;
 
@@ -14074,7 +14022,7 @@
         PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
         PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSource, puuid, nextmsg));
 
-        // Complete the SetPlaybackRange() command as failed
+        // Complete the SetPlaybackRange() command as Success
         EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
         if (errmsg)
         {
@@ -14095,111 +14043,117 @@
                     (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() for %s, iNumPVMFInfoStartOfDataPending=%d",
                      aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), iNumPVMFInfoStartOfDataPending));
 
-    OSCL_UNUSED_ARG(aNodeResp);
+    if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+    {
+        // Sink node report error with SkipMediaData()
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Sink node report error for SkipMediaData(). Asserting"));
+        OSCL_ASSERT(false);
+    }
 
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aNodeContext.iEngineDatapath->iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() In %s", aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Stop the sink that has reached the skipping end point until other sinks are ready
-    if (aNodeContext.iEngineDatapath->iTrackActive && aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF && (aNodeResp.GetCmdStatus() == PVMFSuccess))
+    if (aNodeContext.iEngineDatapath->iDatapath && aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF)
     {
         aNodeContext.iEngineDatapath->iSinkNodeSyncCtrlIF->ClockStopped();
     }
     else
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aNodeResp.GetEventExtensionInterface())
-        {
-            nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-        return;
-
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Datapath does not exist or sync control IF not available."));
     }
 
-    OSCL_ASSERT(iNumPendingSkipCompleteEvent > 0);
     --iNumPendingSkipCompleteEvent;
 
-
-    OSCL_ASSERT(iNumPendingNodeCmd > 0);
     --iNumPendingNodeCmd;
 
     if (iNumPendingNodeCmd == 0)
     {
-        PVMFTimestamp targetNPT = iCurrentBeginPosition.iPosValue.millisec_value;
-
-        // Stop and set to the specified reposition time
+        // Set the clock to the specified begin time just before Start of playback Clock
         iPlaybackClock.Stop();
-        iPlaybackClock.SetStartTime32(iAdjustedMediaDataTS, OSCLCLOCK_MSEC);
+        bool overflow = 0;
+        iPlaybackClock.SetStartTime32(iSkipMediaDataTS, PVMF_MEDIA_CLOCK_MSEC, overflow);
 
-        if (!(iWatchDogTimer->IsBusy()))
+        if (iOverflowFlag)
         {
-            iWatchDogTimer->Cancel();
-            if (iWatchDogTimerInterval > 0)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                                (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Setting WatchDogTimer for %d ms, TargetNPT=%d  ActualNPT=%d",
-                                 iWatchDogTimerInterval, targetNPT, iActualPlaybackPosition));
-                iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
-                iWatchDogTimer->Start();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                                (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Skipping WatchDogTimer - Starting PlayBackClock"));
-                StartPlaybackClock();
-            }
+            iOverflowFlag = false;
+            iActualNPT = iSkipMediaDataTS;
+        }
+        if ((iNumPVMFInfoStartOfDataPending == 0) &&
+                (iState == PVP_ENGINE_STATE_STARTED))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Skipping WatchDogTimer - Starting PlayBackClock"));
+            StartPlaybackClock();
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Setting WatchDogTimer for %d ms, TargetNPT=%d  ActualNPT=%d, if interval zero set to default 1 second",
+                             iWatchDogTimerInterval, iTargetNPT, iActualNPT));
+            // There can be a case in which WatchDogTimerInterval is zero and iNumPVMFInfoStartOfDataPending is greater than zero.
+            // In this case it is possible InfoStartofData is not sent by Sink Nodes for some time and player hangs. To avoid the player hang
+            // set the watchdog timer Interval to the default value of 1 second. If interval is 0, it will be set to default 1 second.
+            iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
+            iWatchDogTimer->Start();
         }
 
         // Set the actual playback position to the requested time since actual media data TS was adjusted
         // This is important since the difference between the two is used to calculate the NPT to media data offset
         // This is not required here as the ActualPlaybackPosition is already adjusted before calling Skip on Sink Node.
-        // iActualPlaybackPosition=iCurrentBeginPosition.iPosValue.millisec_value;
+        // iActualNPT=iCurrentBeginPosition.iPosValue.millisec_value;
 
         //clear the pending direction change NPT.
         iChangeDirectionNPT.iIndeterminate = true;
         // Save the start NPT and TS
-        iStartNPT = iActualPlaybackPosition;
-        iStartMediaDataTS = iAdjustedMediaDataTS;
+        iStartNPT = iActualNPT;
+        iStartMediaDataTS = iSkipMediaDataTS;
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
                         (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() TargetNPT %d, ActualNPT %d StartTS %d",
-                         targetNPT, iStartNPT, iStartMediaDataTS));
+                         iTargetNPT, iStartNPT, iStartMediaDataTS));
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
                         (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() TargetNPT %d, ActualNPT %d StartTS %d",
-                         targetNPT, iStartNPT, iStartMediaDataTS));
+                         iTargetNPT, iStartNPT, iStartMediaDataTS));
 
-        // reset the ResumeAfterRepos boolean here
-        iResumeAfterReposition = false;
-
-        // Complete the SetPlaybackRange(), SetPlaybackRange(), or Resume() command as success
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFSuccess);
-
-        // Send info event that playback from new position has started
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoPlaybackFromBeginTime, puuid, NULL));
-        SendInformationalEvent(PVMFInfoPositionStatus, OSCL_STATIC_CAST(PVInterface*, infomsg));
-        infomsg->removeRef();
-
-        if ((iNumPendingSkipCompleteEvent == 0) && (iNumPVMFInfoStartOfDataPending == 0))
+        // Send event to the observer indicating start of data
+        if (iDataSourcePosParams.iMode == PVMF_SET_DATA_SOURCE_POSITION_MODE_NOW)
         {
-            if (iWatchDogTimer->IsBusy())
-            {
-                iWatchDogTimer->Cancel();
-            }
-            // we have received all the bos event for
-            // playback hasnt started yet
-            StartPlaybackClock();
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() - PlayClock Started"));
+            /* Reset */
+            iDataSourcePosParams.iActualMediaDataTS = 0;
+            iDataSourcePosParams.iActualNPT = 0;
+            iDataSourcePosParams.iMode = PVMF_SET_DATA_SOURCE_POSITION_MODE_UNKNOWN;
+            iDataSourcePosParams.iPlayElementIndex = -1;
+            iDataSourcePosParams.iSeekToSyncPoint = true;
+            iDataSourcePosParams.iTargetNPT = 0;
+            SendInformationalEvent(PVMFInfoStartOfData);
         }
 
+        // send the actual playback position from where playback will resume after reposition.
+        PVPPlaybackPosition actualPlaybackPosition;
+        actualPlaybackPosition.iPosValue.millisec_value = iStartNPT;
+        actualPlaybackPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+
+        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+        PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoPlaybackFromBeginTime, puuid, NULL));
+        SendInformationalEvent(PVMFInfoActualPlaybackPosition, OSCL_STATIC_CAST(PVInterface*, infomsg), (OsclAny*)&actualPlaybackPosition);
+        infomsg->removeRef();
+
+        // Complete the SetPlaybackRange() or SetPlaybackRate()
+        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFSuccess);
     }
+
+    if ((iNumPendingSkipCompleteEvent == 0) && (iNumPVMFInfoStartOfDataPending == 0))
+    {
+        if (iWatchDogTimer->IsBusy())
+        {
+            iWatchDogTimer->Cancel();
+        }
+        // we have received all the bos event for
+        // playback hasnt started yet
+
+        StartPlaybackClock();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback - PlayClock Started"));
+    }
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeSkipMediaDataDuringPlayback() Out"));
 }
 
@@ -14220,8 +14174,15 @@
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodePause() failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodePause() Already EH pending, should never happen"));
+                return;
+            }
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aNodeResp.GetEventExtensionInterface())
             {
@@ -14229,9 +14190,10 @@
             }
 
             PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, NULL, NULL, NULL, false);
         }
         break;
     }
@@ -14250,11 +14212,22 @@
     {
         case PVMFSuccess:
         {
+            // Issue Skip on Sink Node and Start on datapaths back to back. This is done to make sure that
+            // sink node is started only after discarding the data from an earlier stream.
+            if (iChangePlaybackPositionWhenResuming || iChangePlaybackDirectionWhenResuming)
+            {
+                PVMFStatus cmdstatus = DoSinkNodeSkipMediaData(aNodeContext.iCmdId, aNodeContext.iCmdContext);
+                if (cmdstatus != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() Skip of sink node did a leave, asserting"));
+                    OSCL_ASSERT(false);
+                }
+            }
             // Issue start to all active datapaths
             iNumPendingDatapathCmd = 0;
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     PVMFStatus retval = DoDatapathStart(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
                     if (retval == PVMFSuccess)
@@ -14272,32 +14245,32 @@
 
             if (iNumPendingDatapathCmd == 0)
             {
-                if (cmdstatus == PVMFErrNotSupported)
+                bool ehPending = CheckForPendingErrorHandlingCmd();
+                if (ehPending)
                 {
-                    // No datapath so error out
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() No datapath exists. Asserting"));
-                    OSCL_ASSERT(false);
-
-                    HandleErrorBasedOnPlayerState();
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() Report command as failed"));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFFailure);
+                    // there should be no error handling queued.
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() Already EH pending, should never happen"));
+                    return;
                 }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() Report command as failed"));
-                    EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() Report command as failed, Add EH command"));
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
             }
         }
         break;
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeResume() Already EH pending, should never happen"));
+                return;
+            }
             cmdstatus = aNodeResp.GetCmdStatus();
-
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aNodeResp.GetEventExtensionInterface())
             {
@@ -14305,9 +14278,10 @@
             }
 
             PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
         }
         break;
     }
@@ -14320,7 +14294,7 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeStop() In"));
 
-    PVMFStatus cmdstatus = PVMFErrNotSupported;
+    PVMFStatus cmdstatus = PVMFFailure;
 
     switch (aNodeResp.GetCmdStatus())
     {
@@ -14330,7 +14304,7 @@
             iNumPendingDatapathCmd = 0;
             for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                if (iDatapathList[i].iTrackActive)
+                if (iDatapathList[i].iDatapath)
                 {
                     PVMFStatus retval = DoDatapathTeardown(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
                     if (retval == PVMFSuccess)
@@ -14349,28 +14323,33 @@
 
         if (iNumPendingDatapathCmd == 0)
         {
-            if (cmdstatus == PVMFErrNotSupported)
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                // No active datapath to shutdown so stop is complete but assert
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStop() No datapath exists. Asserting"));
-                OSCL_ASSERT(false);
-                SetEngineState(PVP_ENGINE_STATE_INITIALIZED);
-                EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFSuccess);
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStop() Already EH pending, should never happen"));
+                return;
             }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStop() Report command as failed"));
-                EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus);
-            }
+            // No active datapath to shutdown - not possible in stop
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStop() Datapath Teardown failed, Add EH command"));
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
         }
         break;
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeStop() Source node stop failed, go in error handling, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeStop() Already EH pending, should never happen"));
+                return;
+            }
             cmdstatus = aNodeResp.GetCmdStatus();
-
             PVMFErrorInfoMessageInterface* nextmsg = NULL;
             if (aNodeResp.GetEventExtensionInterface())
             {
@@ -14378,9 +14357,10 @@
             }
 
             PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, cmdstatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = cmdstatus;
+
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
         }
         break;
     }
@@ -14393,29 +14373,136 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeReset() In"));
 
+    PVMFStatus cmdstatus = PVMFErrNotSupported;
+
     if (aNodeResp.GetCmdStatus() == PVMFSuccess)
     {
-        SetEngineState(PVP_ENGINE_STATE_IDLE);
-        // we need to delete src node & cmdComplete from engine Run while CMD_Reset is still pending:
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        RunIfNotReady();
+        if (iSourceNode->GetState() != EPVMFNodeIdle)
+        {
+            // when reset completes on Source node, source node should be in Idle State,
+            // If not then just assert.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeReset() Source Node not in a idle state after reset, Asserting"));
+            OSCL_ASSERT(false);
+        }
+
+        PVMFStatus status = PVMFFailure;
+        status = iSourceNode->ThreadLogoff();
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoEngineDatapathTeardown() Threadlogoff on SourceNode Failed"));
+            OSCL_ASSERT(false);
+        }
+
+        if (iSourceNode->GetState() != EPVMFNodeCreated)
+        {
+            // when reset completes on Source node, source node should be in Idle State,
+            // If not then just assert.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeReset() Source Node not in a created state after threadlogoff, Asserting"));
+            OSCL_ASSERT(false);
+        }
+
+        // Reset active datapaths
+        if (!iDatapathList.empty())
+        {
+            iNumPendingDatapathCmd = 0;
+            PVMFCommandId cmdid = -1;
+            int32 leavecode = 0;
+            for (uint32 i = 0; i < iDatapathList.size(); ++i)
+            {
+                if ((iDatapathList[i].iDatapath != NULL) &&
+                        (iDatapathList[i].iTrackInfo != NULL) &&
+                        (iDatapathList[i].iDatapath->iState != PVPDP_IDLE))
+                {
+                    PVMFStatus retval = DoDatapathReset(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
+                    if (retval == PVMFSuccess)
+                    {
+                        ++iNumPendingDatapathCmd;
+                        cmdstatus = PVMFSuccess;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVPlayerEngine::HandleSourceNodeReset() Reset failed, Asserting"));
+                        OSCL_ASSERT(false);
+                        break;
+                    }
+                }
+                else if (iDatapathList[i].iDecNode != NULL)
+                {
+                    // This happens in case of error during prepare, when datapaths have not yet
+                    // been fully constructed.
+                    // reset the decoder node during inteligent track selection
+                    // Call Reset() on the decoder node
+                    PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iDecNode, NULL, aNodeContext.iCmdId, aNodeContext.iCmdContext, PVP_CMD_DecNodeReset);
+
+                    leavecode = IssueDecNodeReset(iDatapathList[i].iDecNode, iDatapathList[i].iDecNodeSessionId, (OsclAny*) context, cmdid);
+
+                    if (cmdid != -1 && leavecode == 0)
+                    {
+                        ++iNumPendingDatapathCmd;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeReset() Reset on dec node leaved, asserting"));
+                        FreeEngineContext(context);
+                        OSCL_ASSERT(false);
+                    }
+                }
+                else if (iDatapathList[i].iSinkNode != NULL)
+                {
+                    // This happens in case of error during prepare, when datapaths have not yet
+                    // been fully constructed.
+                    // reset the sink node during inteligent track selection
+                    // Call Reset() on the sink node
+                    PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aNodeContext.iCmdId, aNodeContext.iCmdContext, PVP_CMD_SinkNodeReset);
+
+                    leavecode = IssueSinkNodeReset(&(iDatapathList[i]), (OsclAny*) context, cmdid);
+
+                    if (cmdid != -1 && leavecode == 0)
+                    {
+                        ++iNumPendingDatapathCmd;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeReset() Reset on sink node leaved, asserting"));
+                        FreeEngineContext(context);
+                        OSCL_ASSERT(false);
+                    }
+                }
+                else
+                {
+                    // No Sink nodes and no datapaths created yet so just do Enginedatapath Teardown.
+                    DoEngineDatapathTeardown(iDatapathList[i]);
+                }
+            }
+
+            if (iNumPendingDatapathCmd == 0)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeReset() Reset on SourceNode completed and no datapath or sink node to reset."));
+                // Reset on source node is complete and there are no datapaths or sink nodes to reset,
+                // now need to remove the data sinks and sources
+                // so schedule engine AO - we cannnot delete datapaths in callback, hence the reschedule
+                SetEngineState(PVP_ENGINE_STATE_IDLE);
+                RunIfNotReady();
+            }
+        }
+        else
+        {
+            // Reset on source node is complete and there are no datapaths or sink nodes to reset,
+            // now need to remove the data sinks and sources
+            // so schedule engine AO - we cannnot delete datapaths in callback, hence the reschedule
+            SetEngineState(PVP_ENGINE_STATE_IDLE);
+            RunIfNotReady();
+        }
     }
     else
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aNodeResp.GetEventExtensionInterface())
-        {
-            nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceShutdown, puuid, nextmsg));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-        return;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSourceNodeReset() Reset failed on Source Node, Asserting"));
+        OSCL_ASSERT(false);
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeReset() Out"));
@@ -14424,31 +14511,36 @@
 
 void PVPlayerEngine::HandleSinkNodePause(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aNodeContext.iEngineDatapath->iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodePause() In %s", aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aNodeResp.GetEventExtensionInterface())
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodePause() Already EH pending, should never happen"));
+            return;
+        }
+        else
+        {
+            // Cancel any pending node/datapath commands
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodePause() Failed, Add EH command"));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aNodeResp.GetEventExtensionInterface())
+            {
+                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            }
+
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, NULL, NULL, NULL, false);
         }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
         return;
     }
 
@@ -14466,47 +14558,79 @@
 
 void PVPlayerEngine::HandleSinkNodeResume(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
-    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aNodeContext.iEngineDatapath->iTrackInfo != NULL);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeResume() In %s", aNodeContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aNodeResp.GetEventExtensionInterface())
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeResume() Already EH pending, should never happen"));
+            return;
         }
+        else
+        {
+            // Cancel any pending node/datapath commands
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeResume() Failed, Add EH command"));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aNodeResp.GetEventExtensionInterface())
+            {
+                nextmsg = GetErrorInfoMessageInterface(*(aNodeResp.GetEventExtensionInterface()));
+            }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, aNodeResp.GetCmdStatus(), OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aNodeResp.GetCmdStatus();
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, NULL, NULL, NULL, false);
+        }
         return;
     }
 
     if (iNumPendingDatapathCmd == 0)
     {
         // Auto-resume is complete
-        // Resume the playback clock
-        iPlaybackClock.Start();
-        // To get regular play status events
-        StartPlaybackStatusTimer();
-        // Notify data sinks that clock has started
-        for (uint32 i = 0; i < iDatapathList.size(); ++i)
+        // Resume the playback clock only if InfoStartofData has been received for all tracks.
+        // If SetPlaybackRange is called in Auto-Pause state, its possible that engine is waiting for InfoStartofData.
+        // If waiting, restart the watchdog timer which was cancelled in Auto-Pause command.
+        // this should only be done when engine is waiting for StartofData info event
+        // after reposition. If already busy after SetPlaybackRange command complete,
+        // then cancel it and start again. Playback clock will be started in either HandleSinkNodeInfoEvent or
+        // PVPlayerWatchdogTimerEvent
+        if (iNumPVMFInfoStartOfDataPending > 0)
         {
-            if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+            if (iWatchDogTimerInterval > 0)
             {
-                iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
+                if (iWatchDogTimer->IsBusy())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                    (0, "PVPlayerEngine::HandleSinkNodeResume - Pause after setplayback, Cancelling Watchdog timer, iNumPVMFInfoStartOfDataPending=%d", iNumPVMFInfoStartOfDataPending));
+                    iWatchDogTimer->Cancel();
+                }
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                (0, "PVPlayerEngine::HandleSinkNodeResume Setting WatchDogTimer for %d ms, iNumPVMFInfoStartOfDataPending=%d",
+                                 iWatchDogTimerInterval, iNumPVMFInfoStartOfDataPending));
+                iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
+                iWatchDogTimer->Start();
+            }
+        }
+        // Auto-resume is complete & not waiting on PVMFInfoStartOfData, so go ahead and
+        // start the clock
+        if (iNumPVMFInfoStartOfDataPending == 0)
+        {
+            StartPlaybackClock();
+
+            // Notify data sinks that clock has started
+            for (uint32 i = 0; i < iDatapathList.size(); ++i)
+            {
+                if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
+                {
+                    iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
+                }
             }
         }
 
@@ -14518,105 +14642,99 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeResume() Out"));
 }
 
-
-void PVPlayerEngine::HandleSourceNodeStopDueToError(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
+void PVPlayerEngine::HandleSinkNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeStopDueToError() In"));
+    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeReset() In"));
 
-    if (aNodeResp.GetCmdStatus() == PVMFErrInvalidState &&
-            iSourceNode->GetState() == EPVMFNodeInitialized &&
-            iErrorOccurredDuringErrorHandling == false)
+    // Decrement the counter for pending cmds
+    --iNumPendingDatapathCmd;
+
+    if (aNodeResp.GetCmdStatus() != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeStopDueToError() Source node is already stopped"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSinkNodeReset() Reset failed, assert"));
+        OSCL_ASSERT(false);
+        return;
     }
-    else if (aNodeResp.GetCmdStatus() != PVMFSuccess && iErrorOccurredDuringErrorHandling == false)
+    else
     {
-        // Issue a reset command
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeStopDueToError() Stop on source node failed so issue reset command"));
-        iErrorOccurredDuringErrorHandling = true;
+        // Reset for this sink node is complete
+        //a sync call in engine - no async cmds issued here
+        DoEngineDatapathTeardown(*(aNodeContext.iEngineDatapath));
     }
 
-    // Initiate teardown or reset sequence for each active datapath
-    iNumPendingDatapathCmd = 0;
-    for (uint32 i = 0; i < iDatapathList.size(); ++i)
+    if (iNumPendingDatapathCmd == 0)
     {
-        if (iDatapathList[i].iTrackActive == true)
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSinkNodeReset() Reset on SourceNode and Sink nodes completed"));
+        // Reset on source node and sink node is complete, now need to remove the data sinks and sources
+        // so schedule engine AO - we cannnot delete datapaths in callback, hence the reschedule
+        SetEngineState(PVP_ENGINE_STATE_IDLE);
+        RunIfNotReady();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeReset() Out"));
+}
+
+void PVPlayerEngine::HandleDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
+{
+    OSCL_ASSERT(aNodeContext.iEngineDatapath != NULL);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeReset() In"));
+
+    // Decrement the counter for pending cmds
+    --iNumPendingDatapathCmd;
+
+    if (aNodeResp.GetCmdStatus() != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleDecNodeReset() Reset failed, assert"));
+        OSCL_ASSERT(false);
+        return;
+    }
+
+    if (iNumPendingDatapathCmd == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleDecNodeReset() Reset on SourceNode and dec nodes completed, now reset Sink nodes"));
+        // Reset on source node and dec node is complete, now need to reset the sink nodes
+        if (!iDatapathList.empty())
         {
-            PVMFStatus retcode = DoDatapathTeardownDueToError(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
-            if (retcode == PVMFSuccess)
+            iNumPendingDatapathCmd = 0;
+            PVMFCommandId cmdid = -1;
+            int32 leavecode = 0;
+            for (uint32 i = 0; i < iDatapathList.size(); ++i)
             {
-                ++iNumPendingDatapathCmd;
-            }
-            else
-            {
-                retcode = DoDatapathResetDueToError(iDatapathList[i], aNodeContext.iCmdId, aNodeContext.iCmdContext);
-                if (retcode == PVMFSuccess)
+                if (iDatapathList[i].iSinkNode != NULL)
                 {
-                    ++iNumPendingDatapathCmd;
+                    // This happens in case of error during prepare, when datapaths have not yet
+                    // been fully constructed.
+                    // reset the sink node during inteligent track selection
+                    // Call Reset() on the sink node
+                    PVPlayerEngineContext* context = AllocateEngineContext(&(iDatapathList[i]), iDatapathList[i].iSinkNode, NULL, aNodeContext.iCmdId, aNodeContext.iCmdContext, PVP_CMD_SinkNodeReset);
+
+                    leavecode = IssueSinkNodeReset(&(iDatapathList[i]), (OsclAny*) context, cmdid);
+
+                    if (cmdid != -1 && leavecode == 0)
+                    {
+                        ++iNumPendingDatapathCmd;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeReset() Reset on sink node leaved, asserting"));
+                        FreeEngineContext(context);
+                        OSCL_ASSERT(false);
+                    }
                 }
             }
         }
     }
 
-    if (iNumPendingDatapathCmd == 0)
-    {
-        for (uint32 i = 0; i < iDatapathList.size(); ++i)
-        {
-            // make copy of context data and reschedule for deletion
-            PVPlayerEngineContext* newContext = AllocateEngineContext(
-                                                    &(iDatapathList[i]), NULL, NULL, 0, NULL, 0);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_DATAPATH_DELETE, newContext, NULL, NULL, false);
-            iNumPendingDatapathCmd++; // datapathdelete pending
-        }
-
-        if (iNumPendingDatapathCmd == 0)
-        {
-            OSCL_ASSERT(iDatapathList.empty());
-            // reset source node, usually called by datapathDelete but since there are no datapaths..
-            if (iErrorOccurredDuringErrorHandling)
-            {
-                AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            }
-        }
-        // done with STOP_DUE_TO_ERROR, clear current Cmd so that either DatapathDelete or ResetDueToError get run
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext,
-                               iErrorOccurredDuringErrorHandling ? PVMFFailure : PVMFSuccess);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeStopDueToError() Out"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeReset() Out"));
 }
 
-
-void PVPlayerEngine::HandleSourceNodeResetDueToError(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeResetDueToError() In"));
-
-    if (aNodeResp.GetCmdStatus() == PVMFSuccess)
-    {
-        SetEngineState(PVP_ENGINE_STATE_IDLE);
-        // we need to delete src node & cmdComplete from engine Run while CMD_Reset_DUE_TO_ERROR is still pending:
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        RunIfNotReady();
-    }
-    else
-    {
-        // Error occurred for Reset() command but complete it and issue a cleanup command
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeResetDueToError() Reset on source node failed so issue cleanup command"));
-        EngineCommandCompleted(aNodeContext.iCmdId, aNodeContext.iCmdContext, PVMFFailure);
-        SetEngineState(PVP_ENGINE_STATE_ERROR);
-        AddCommandToQueue(PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeResetDueToError() Out"));
-}
-
-
 void PVPlayerEngine::HandleDatapathPrepare(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathPrepare() for %s Tick=%d",
                      aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -14624,29 +14742,36 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathPrepare() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aDatapathStatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp)
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            if (aCmdResp->GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-            }
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPrepare() Already EH pending, should never happen"));
+            return;
         }
+        else
+        {
+            // Cancel any pending node/datapath commands
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathPrepare() In %s Failed, Add EH command", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aCmdResp)
+            {
+                if (aCmdResp->GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
+                }
+            }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathInit, puuid, nextmsg));
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aDatapathStatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+        }
         return;
     }
 
@@ -14662,8 +14787,20 @@
 
         if (cmdstatus != PVMFSuccess)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPrepare() Report command as failed"));
-            EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, cmdstatus);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPrepare() Report command as failed, Add EH command"));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPrepare() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+            }
         }
     }
 
@@ -14673,9 +14810,6 @@
 
 void PVPlayerEngine::HandleDatapathStart(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathStart() for %s Tick=%d",
                      aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -14683,43 +14817,84 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathStart() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aDatapathStatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp)
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            if (aCmdResp->GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-            }
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathStart() Already EH pending, should never happen"));
+            return;
         }
+        else
+        {
+            // Cancel any pending node/datapath commands
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathStart() In %s Failed, Add EH command", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aCmdResp)
+            {
+                if (aCmdResp->GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
+                }
+            }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aDatapathStatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, NULL, NULL, NULL, false);
+        }
         return;
     }
 
     if (iNumPendingDatapathCmd == 0)
     {
-        // Skip some media data in sink node if necessary
-        PVMFStatus cmdstatus = DoSinkNodeSkipMediaData(aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
-        if (cmdstatus != PVMFSuccess)
+        // This should never be happen if Skip on sink node has not completed (i.e. iNumPendingSkipCompleteEvent
+        // is greater than zero). If this happens with iNumPendingSkipCompleteEvent > 0 then just assert.
+        // Set the clock to the specified begin time just before Start of playback Clock
+        iPlaybackClock.Stop();
+        bool overflow = 0;
+        iPlaybackClock.SetStartTime32(iSkipMediaDataTS, PVMF_MEDIA_CLOCK_MSEC, overflow);
+
+        if (!(iWatchDogTimer->IsBusy()))
         {
-            // No skipping so complete the commmand
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathStart() Skip of sink node failed, but report command as completed"));
-            SetEngineState(PVP_ENGINE_STATE_PREPARED);
-            EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFSuccess);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::HandleDatapathStart() Setting WatchDogTimer for %d ms, TargetNPT=%d  ActualNPT=%d, if interval zero set to default 1 second",
+                             iWatchDogTimerInterval, iTargetNPT, iActualNPT));
+            iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
+            iWatchDogTimer->Start();
         }
+        // Set the actual playback position to the requested time since actual media data TS was adjusted
+        // This is important since the difference between the two is used to calculate the NPT to media data offset
+        // This is not required here as the ActualPlaybackPosition is already adjusted before calling Skip on Sink Node.
+        // iActualNPT=iCurrentBeginPosition.iPosValue.millisec_value;
+
+        // Save the start NPT and TS
+        iStartNPT = iActualNPT;
+        iStartMediaDataTS = iSkipMediaDataTS;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "PVPlayerEngine::HandleDatapathStart() TargetNPT %d, StartNPT %d StartTS %d",
+                         iTargetNPT, iStartNPT, iStartMediaDataTS));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                        (0, "PVPlayerEngine::HandleDatapathStart() TargetNPT %d, StartNPT %d StartTS %d",
+                         iTargetNPT, iStartNPT, iStartMediaDataTS));
+
+        SetEngineState(PVP_ENGINE_STATE_PREPARED);
+
+        // send the actual playback position from where playback will resume after reposition.
+        PVPPlaybackPosition actualPlaybackPosition;
+        actualPlaybackPosition.iPosValue.millisec_value = iStartNPT;
+        actualPlaybackPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+
+        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+        PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoPlaybackFromBeginTime, puuid, NULL));
+        SendInformationalEvent(PVMFInfoActualPlaybackPosition, OSCL_STATIC_CAST(PVInterface*, infomsg), (OsclAny*)&actualPlaybackPosition);
+        infomsg->removeRef();
+
+        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFSuccess);
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathStart() Out"));
@@ -14728,9 +14903,6 @@
 
 void PVPlayerEngine::HandleDatapathPause(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathPause() for %s Tick=%d",
                      aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -14738,29 +14910,36 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathPause() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aDatapathStatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp)
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            if (aCmdResp->GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-            }
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPause() Already EH pending, should never happen"));
+            return;
         }
+        else
+        {
+            // Cancel any pending node/datapath commands
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathPause() In %s Failed, Add EH command", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aCmdResp)
+            {
+                if (aCmdResp->GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
+                }
+            }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aDatapathStatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, NULL, NULL, NULL, false);
+        }
         return;
     }
 
@@ -14771,8 +14950,20 @@
 
         if (cmdstatus != PVMFSuccess)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPause() Report command as failed"));
-            EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, cmdstatus);
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPause() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathPause() Report command as failed, Add EH command"));
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, NULL, NULL, NULL, false);
+            }
         }
     }
 
@@ -14782,9 +14973,6 @@
 
 void PVPlayerEngine::HandleDatapathResume(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathResume() for %s Tick=%d",
                      aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -14792,29 +14980,35 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathResume() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aDatapathStatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp)
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            if (aCmdResp->GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-            }
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathResume() Already EH pending, should never happen"));
+            return;
         }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathResume() In %s Failed, Add EH command", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aCmdResp)
+            {
+                if (aCmdResp->GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
+                }
+            }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aDatapathStatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
+        }
         return;
     }
 
@@ -14822,21 +15016,70 @@
     {
         if (iChangePlaybackPositionWhenResuming || iChangePlaybackDirectionWhenResuming)
         {
-            iResumeAfterReposition = true;
-        }
+            // This should never be happen if Skip on sink node has not completed (i.e. iNumPendingSkipCompleteEvent
+            // is greater than zero). If this happens with iNumPendingSkipCompleteEvent > 0 then just assert.
+            // Set the clock to the specified begin time just before Start of playback Clock
+            iPlaybackClock.Stop();
+            bool overflow = 0;
+            iPlaybackClock.SetStartTime32(iSkipMediaDataTS, PVMF_MEDIA_CLOCK_MSEC, overflow);
 
-        if (!iResumeAfterReposition)
+            if (iNumPVMFInfoStartOfDataPending == 0)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                (0, "PVPlayerEngine::HandleDatapathResume() Skipping WatchDogTimer - Starting PlayBackClock"));
+                StartPlaybackClock();
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                (0, "PVPlayerEngine::HandleDatapathResume() Setting WatchDogTimer for %d ms, TargetNPT=%d  ActualNPT=%d",
+                                 iWatchDogTimerInterval, iTargetNPT, iActualNPT));
+
+                // There can be a case in which WatchDogTimerInterval is zero and iNumPVMFInfoStartOfDataPending is greater than zero.
+                // In this case it is possible InfoStartofData is not sent by Sink Nodes for some time and player hangs. To avoid the player hang
+                // set the watchdog timer Interval to the default value of 1 second.
+                iWatchDogTimer->setTimerDuration(iWatchDogTimerInterval);
+                iWatchDogTimer->Start();
+            }
+
+            // Set the actual playback position to the requested time since actual media data TS was adjusted
+            // This is important since the difference between the two is used to calculate the NPT to media data offset
+            // This is not required here as the ActualPlaybackPosition is already adjusted before calling Skip on Sink Node.
+            // iActualNPT=iCurrentBeginPosition.iPosValue.millisec_value;
+
+            //clear the pending direction change NPT.
+            iChangeDirectionNPT.iIndeterminate = true;
+            // Save the start NPT and TS
+            iStartNPT = iActualNPT;
+            iStartMediaDataTS = iSkipMediaDataTS;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::HandleDatapathResume() TargetNPT %d, ActualNPT %d StartTS %d",
+                             iTargetNPT, iStartNPT, iStartMediaDataTS));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                            (0, "PVPlayerEngine::HandleDatapathResume() TargetNPT %d, ActualNPT %d StartTS %d",
+                             iTargetNPT, iStartNPT, iStartMediaDataTS));
+
+            // send the actual playback position from where playback will resume after reposition.
+            PVPPlaybackPosition actualPlaybackPosition;
+            actualPlaybackPosition.iPosValue.millisec_value = iStartNPT;
+            actualPlaybackPosition.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            PVMFBasicErrorInfoMessage* infomsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerInfoPlaybackFromBeginTime, puuid, NULL));
+            SendInformationalEvent(PVMFInfoActualPlaybackPosition, OSCL_STATIC_CAST(PVInterface*, infomsg), (OsclAny*)&actualPlaybackPosition);
+            infomsg->removeRef();
+        }
+        else
         {
             // Resume the playback clock - only if we have come out of any previous auto pause, if any
-            if (iPlaybackClock.GetState() == OsclClock::PAUSED)
+            if (iPlaybackClock.GetState() == PVMFMediaClock::PAUSED)
             {
-                iPlaybackClock.Start();
-                // To get regular play status events
-                StartPlaybackStatusTimer();
+                StartPlaybackClock();
+
                 // Notify all sink nodes that have sync control IF that clock has started
                 for (uint32 i = 0; i < iDatapathList.size(); ++i)
                 {
-                    if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+                    if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
                     {
                         iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
                     }
@@ -14858,7 +15101,6 @@
                 }
             }
 
-
             // Restart the end time check if enabled
             if (iEndTimeCheckEnabled)
             {
@@ -14876,32 +15118,6 @@
 
         SetEngineState(PVP_ENGINE_STATE_STARTED);
 
-        if (iChangePlaybackPositionWhenResuming || iChangePlaybackDirectionWhenResuming)
-        {
-            iChangePlaybackPositionWhenResuming = false;
-            iChangePlaybackDirectionWhenResuming = false;
-            iResumeAfterReposition = true;
-            PVMFStatus retval = DoSinkNodeSkipMediaDataDuringPlayback(aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
-            if (retval != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathResume() Skipping media data request in sink nodes failed. Repositioning did not complete."));
-                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-                PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSink, puuid, NULL));
-
-                //clear the pending direction change NPT.
-                iChangeDirectionNPT.iIndeterminate = true;
-
-                // Complete the Resume() command as failed
-                EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
-
-                // Report an error event
-                SendErrorEvent(retval, OSCL_STATIC_CAST(PVInterface*, errmsg));
-                errmsg->removeRef();
-                errmsg = NULL;
-            }
-            return;
-        }
-
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathResume() Report command as completed"));
         EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFSuccess);
     }
@@ -14912,9 +15128,6 @@
 
 void PVPlayerEngine::HandleDatapathStop(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathStop() for %s Tick=%d",
                      aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -14922,29 +15135,35 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathStop() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aDatapathStatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp)
+        bool ehPending = CheckForPendingErrorHandlingCmd();
+        if (ehPending)
         {
-            if (aCmdResp->GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-            }
+            // there should be no error handling queued.
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathStop() Already EH pending, should never happen"));
+            return;
         }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathStop() In %s Failed, Add EH command", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+            PVMFErrorInfoMessageInterface* nextmsg = NULL;
+            if (aCmdResp)
+            {
+                if (aCmdResp->GetEventExtensionInterface())
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
+                }
+            }
 
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+            iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+            iCommandCompleteStatusInErrorHandling = aDatapathStatus;
+            AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
+        }
         return;
     }
 
@@ -14955,8 +15174,20 @@
 
         if (cmdstatus != PVMFSuccess)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathStop() Report command as failed"));
-            EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, cmdstatus);
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
+            {
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathStop() Already EH pending, should never happen"));
+                return;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathStop() Report command as failed, Add EH command"));
+                iCommandCompleteErrMsgInErrorHandling = NULL;
+                iCommandCompleteStatusInErrorHandling = cmdstatus;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
+            }
         }
     }
 
@@ -14966,9 +15197,6 @@
 
 void PVPlayerEngine::HandleDatapathTeardown(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathTeardown() for %s Tick=%d",
                      aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr(), OsclTickCount::TickCount()));
@@ -14981,43 +15209,45 @@
     {
         case PVMFSuccess:
             // Reset this datapath next
-            OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
             cmdstatus = DoDatapathReset(*(aDatapathContext.iEngineDatapath), aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
             break;
 
         default:
         {
-            HandleErrorBasedOnPlayerState();
-
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aCmdResp)
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                if (aCmdResp->GetEventExtensionInterface())
-                {
-                    nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-                }
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathTeardown() Already EH pending, should never happen"));
+                return;
             }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleDatapathTeardown() In %s Failed, Add EH command", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aCmdResp)
+                {
+                    if (aCmdResp->GetEventExtensionInterface())
+                    {
+                        nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
+                    }
+                }
 
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathShutdown, puuid, nextmsg));
-            EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-            errmsg->removeRef();
-
-            // Cancel any pending node/datapath commands
-            DoCancelDueToError();
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = aDatapathStatus;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, NULL, NULL, NULL, false);
+            }
             return;
         }
     }
 
     if (cmdstatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathTeardown() Report command as failed"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDatapathTeardown() Reset failed, asserting"));
+        OSCL_ASSERT(false);
         EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, cmdstatus);
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleVideoDatapathTeardown() Out"));
@@ -15026,8 +15256,7 @@
 
 void PVPlayerEngine::HandleDatapathReset(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp)
 {
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
+    OSCL_UNUSED_ARG(aCmdResp);
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iPerfLogger, PVLOGMSG_INFO,
                     (0, "PVPlayerEngine::HandleDatapathReset() for %s Tick=%d",
@@ -15036,373 +15265,53 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathReset() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
 
     // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
     --iNumPendingDatapathCmd;
 
     if (aDatapathStatus != PVMFSuccess)
     {
-        HandleErrorBasedOnPlayerState();
-
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp)
-        {
-            if (aCmdResp->GetEventExtensionInterface())
-            {
-                nextmsg = GetErrorInfoMessageInterface(*(aCmdResp->GetEventExtensionInterface()));
-            }
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathShutdown, puuid, nextmsg));
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, aDatapathStatus, OSCL_STATIC_CAST(PVInterface*, errmsg));
-        errmsg->removeRef();
-
-        // Cancel any pending node/datapath commands
-        DoCancelDueToError();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleDatapathReset() In %s Reset failed, assert", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
+        OSCL_ASSERT(false);
         return;
     }
     else
     {
         // Reset for this datapath is complete
-        OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
+        //a sync call in engine - no async cmds issued here
         DoEngineDatapathTeardown(*(aDatapathContext.iEngineDatapath));
     }
 
+    //this means datapath reset and teardown is complete for all datapaths
     if (iNumPendingDatapathCmd == 0)
     {
-        // Stop is complete
-        SetEngineState(PVP_ENGINE_STATE_INITIALIZED);
-        EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFSuccess);
+        if (iState == PVP_ENGINE_STATE_RESETTING)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathReset() Reset on SourceNode and Datapath completed"));
+            // Reset on source node and datapath is complete, now need to remove the data sinks and sources
+            // so schedule engine AO - we cannnot delete datapaths in callback, hence the reschedule
+            SetEngineState(PVP_ENGINE_STATE_IDLE);
+            RunIfNotReady();
+        }
+        else if (iState == PVP_ENGINE_STATE_STOPPING)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathReset() Stop Completed"));
+            // stop has completed
+            SetEngineState(PVP_ENGINE_STATE_INITIALIZED);
+            EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFSuccess);
+        }
+        else
+        {
+            //engine cannot be in any other state
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDatapathReset() Wrong Engine state for Reset to complete, asserting"));
+            OSCL_ASSERT(false);
+        }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathReset() Out"));
 }
 
-
-void PVPlayerEngine::HandleDatapathStopDueToError(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* /*aCmdResp*/)
-{
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathStopDueToError() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
-
-    // Decrement the counter for pending datapath cmds
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
-    --iNumPendingDatapathCmd;
-
-    if (aDatapathStatus != PVMFSuccess && iErrorOccurredDuringErrorHandling == false)
-    {
-        // Issue a reset command
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathStopDueToError() Stop on datapath failed so issue reset command"));
-        iErrorOccurredDuringErrorHandling = true;
-    }
-
-    PVMFStatus cmdstatus = PVMFFailure;
-
-    if (iNumPendingDatapathCmd == 0)
-    {
-        // Trying stopping the source node
-        cmdstatus = DoSourceNodeStopDueToError(aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
-
-        if (cmdstatus != PVMFSuccess)
-        {
-            // Try starting teardown or reset sequence for each active datapath
-            iNumPendingDatapathCmd = 0;
-            for (uint32 i = 0; i < iDatapathList.size(); ++i)
-            {
-                if (iDatapathList[i].iTrackActive == true)
-                {
-                    PVMFStatus retcode = DoDatapathTeardownDueToError(iDatapathList[i], aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
-                    if (retcode == PVMFSuccess)
-                    {
-                        ++iNumPendingDatapathCmd;
-                    }
-                    else
-                    {
-                        retcode = DoDatapathResetDueToError(iDatapathList[i], aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
-                        if (retcode == PVMFSuccess)
-                        {
-                            ++iNumPendingDatapathCmd;
-                        }
-                    }
-                }
-            }
-
-            if (iNumPendingDatapathCmd == 0)
-            {
-                // Nothing initiated so just shutdown
-                SetEngineState(PVP_ENGINE_STATE_INITIALIZED);
-
-                // Clean up the datapaths
-                for (uint32 i = 0; i < iDatapathList.size(); ++i)
-                {
-                    DoEngineDatapathCleanup(iDatapathList[i]);
-                }
-                iDatapathList.clear();
-
-                if (iErrorOccurredDuringErrorHandling)
-                {
-                    EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFFailure);
-                }
-                else
-                {
-                    EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext, PVMFSuccess);
-                }
-            }
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathStopDueToError() Out"));
-}
-
-
-void PVPlayerEngine::HandleDatapathTeardownDueToError(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* /*aCmdResp*/)
-{
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath->iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathTeardownDueToError() In %s", aDatapathContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
-
-    if (aDatapathStatus != PVMFSuccess && iErrorOccurredDuringErrorHandling == false)
-    {
-        // Issue a reset command
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathTeardownDueToError() Teardown on datapath failed so issue reset command"));
-        iErrorOccurredDuringErrorHandling = true;
-    }
-
-    PVMFStatus cmdstatus = PVMFFailure;
-
-    // Try resetting this datapath
-    OSCL_ASSERT(aDatapathContext.iEngineDatapath);
-    cmdstatus = DoDatapathResetDueToError(*(aDatapathContext.iEngineDatapath), aDatapathContext.iCmdId, aDatapathContext.iCmdContext);
-
-    if (cmdstatus != PVMFSuccess)
-    {
-        // Couldn't continue with reset of this datapath so decrement the pending datapath cmd counter
-        --iNumPendingDatapathCmd;
-
-        if (iNumPendingDatapathCmd == 0)
-        {
-            // make copy of context data and reschedule for deletion
-            PVPlayerEngineContext* newContext = AllocateEngineContext(
-                                                    aDatapathContext.iEngineDatapath, NULL, NULL, 0, NULL, 0);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_DATAPATH_DELETE, newContext, NULL, NULL, false);
-            iNumPendingDatapathCmd++; // datapathdelete pending
-
-            // a delete cmd has been added to the queue, but it can only be processed once current cmd is completed:
-            // cmdId is shared by multiple datapath commands. if we have not sent confirmation previously do now
-            if (iCurrentCmd.size() == 1 &&  iCurrentCmd[0].GetCmdId() == aDatapathContext.iCmdId)
-            {
-                EngineCommandCompleted(aDatapathContext.iCmdId, aDatapathContext.iCmdContext,
-                                       iErrorOccurredDuringErrorHandling ? PVMFFailure : PVMFSuccess);
-            }
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathTeardownDueToError() Out"));
-}
-
-
-// schedule async deletion of aDatapathContext.iEngineDatapath
-void PVPlayerEngine::HandleDatapathResetDueToError(PVPlayerEngineContext& aContext, PVMFStatus aDatapathStatus, PVMFCmdResp* /*aCmdResp*/)
-{
-    OSCL_ASSERT(aContext.iEngineDatapath != NULL);
-    OSCL_ASSERT(aContext.iEngineDatapath->iTrackInfo != NULL);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathResetDueToError() In %s", aContext.iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
-
-    // make copy of context data and reschedule for deletion
-    PVPlayerEngineContext* newContext = AllocateEngineContext(
-                                            aContext.iEngineDatapath, NULL, NULL, 0, NULL, 0);
-
-    AddCommandToQueue(PVP_ENGINE_COMMAND_DATAPATH_DELETE, newContext, NULL, NULL, false);
-
-    if (aDatapathStatus != PVMFSuccess && iErrorOccurredDuringErrorHandling == false)
-    {
-        // Issue a reset command if not done so previously
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathResetDueToError() Reset on datapath failed so issue reset command"));
-        iErrorOccurredDuringErrorHandling = true;
-    }
-
-    // a delete cmd has been added to the queue, but it can only be processed once current cmd is completed:
-    // cmdId is shared by multiple datapath commands. if we have not sent confirmation previously do now
-    if (iCurrentCmd.size() == 1 &&  iCurrentCmd[0].GetCmdId() == aContext.iCmdId)
-    {
-        EngineCommandCompleted(aContext.iCmdId, aContext.iCmdContext,
-                               iErrorOccurredDuringErrorHandling ? PVMFFailure : PVMFSuccess);
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDatapathResetDueToError() Out"));
-}
-
-// delete aDatapathContext.iEngineDatapath
-PVMFStatus PVPlayerEngine::DoDatapathDelete(PVPlayerEngineCommand &aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathDelete() In"));
-
-    PVPlayerEngineContext* aDatapathContext = (PVPlayerEngineContext*) aCmd.GetContext();
-
-    OSCL_ASSERT(aDatapathContext != NULL);
-    OSCL_ASSERT(aDatapathContext->iEngineDatapath != NULL);
-    if (aDatapathContext->iEngineDatapath->iTrackActive)
-    {
-        OSCL_ASSERT(aDatapathContext->iEngineDatapath->iTrackInfo != NULL);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathDelete() In %s", aDatapathContext->iEngineDatapath->iTrackInfo->getTrackMimeType().get_cstr()));
-    }
-
-    // Clean up objects associated with the current datapath
-    DoEngineDatapathCleanup(*(aDatapathContext->iEngineDatapath));
-
-    OSCL_ASSERT(iNumPendingDatapathCmd > 0);
-    --iNumPendingDatapathCmd;
-
-    // all datapath resets have been handled
-    if (iNumPendingDatapathCmd == 0)
-    {
-        iDatapathList.clear();
-
-        // reset source node
-        AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-    }
-
-    // delete request handled
-    EngineCommandCompleted(aCmd.GetCmdId(), aDatapathContext, PVMFSuccess);
-    FreeEngineContext(aDatapathContext);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoDatapathDelete() Out"));
-    return PVMFSuccess;
-}
-
-
-void PVPlayerEngine::HandleCPMPluginQueryCapConfigIF(const PVMFCmdResp& aCmdResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleCPMPluginQueryCapConfigIF() In"));
-
-    if (aCmdResp.GetCmdStatus() == PVMFSuccess)
-    {
-        // CapConfig interface available. Proceed to set user-agent
-        DoCPMPluginSetUserAgentHeader(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext());
-    }
-    else
-    {
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp.GetEventExtensionInterface())
-        {
-            nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        iCommandCompleteInEngineAOErrMsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrCPMPlugin, puuid, nextmsg));
-        // There shouldn't be any other command pending to complete in engine's AO
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        iCommandCompleteInEngineAOCmdStatus = aCmdResp.GetCmdStatus();
-    }
-
-    // Proceed to acquire licence
-    // if CapConfig UUID is not supported
-
-    PVMFStatus retval = DoCPMPluginGetLicense(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext());
-    if (retval != PVMFSuccess)
-    {
-        // There shouldn't be any other command pending to complete in engine's AO
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        iCommandCompleteInEngineAOCmdStatus = retval;
-        iCommandCompleteInEngineAOErrMsg = NULL;
-    }
-
-    if (iCommandCompleteInEngineAOPending)
-    {
-        if (IsBusy())
-        {
-            Cancel();
-        }
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleCPMPluginQueryCapConfigIF() Out"));
-}
-void PVPlayerEngine::HandleCPMPluginQueryLicenseIF(const PVMFCmdResp& aCmdResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleCPMPluginQueryLicenseIF() In"));
-
-    if (aCmdResp.GetCmdStatus() == PVMFSuccess)
-    {
-        //
-        // License interface available. Proceed to query for CapConfig interface
-        iCPMPlugin->QueryInterface(iCPMPluginSessionId, PVMI_CAPABILITY_AND_CONFIG_PVUUID, (PVInterface*&)iCPMPluginCapConfigIf, NULL);
-
-        if (NULL == iCPMPluginCapConfigIf)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleCPMPluginQueryLicenseIF queryInterface on CPMPluginCapConfigIf returned error"));
-        }
-        iCPMPluginCommand = PVP_CMD_CPMQueryCapConfigIF;
-    }
-    else
-    {
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp.GetEventExtensionInterface())
-        {
-            nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        iCommandCompleteInEngineAOErrMsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrCPMPlugin, puuid, nextmsg));
-        // There shouldn't be any other command pending to complete in engine's AO
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        iCommandCompleteInEngineAOCmdStatus = aCmdResp.GetCmdStatus();
-    }
-
-    if (iCommandCompleteInEngineAOPending)
-    {
-        if (IsBusy())
-        {
-            Cancel();
-        }
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleCPMPluginQueryLicenseIF() Out"));
-}
-
-
-void PVPlayerEngine::HandleCPMPluginGetLicense(const PVMFCmdResp& aCmdResp)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleCPMPluginGetLicense() In"));
-
-    if (aCmdResp.GetCmdStatus() == PVMFSuccess)
-    {
-        // License acquisition is successful.
-        // There shouldn't be any other command pending to complete in engine's AO
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        iCommandCompleteInEngineAOCmdStatus = PVMFSuccess;
-        iCommandCompleteInEngineAOErrMsg = NULL;
-    }
-    else
-    {
-        PVMFErrorInfoMessageInterface* nextmsg = NULL;
-        if (aCmdResp.GetEventExtensionInterface())
-        {
-            nextmsg = GetErrorInfoMessageInterface(*(aCmdResp.GetEventExtensionInterface()));
-        }
-
-        PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-        iCommandCompleteInEngineAOErrMsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrCPMPlugin, puuid, nextmsg));
-        // There shouldn't be any other command pending to complete in engine's AO
-        OSCL_ASSERT(iCommandCompleteInEngineAOPending == false);
-        iCommandCompleteInEngineAOPending = true;
-        iCommandCompleteInEngineAOCmdStatus = aCmdResp.GetCmdStatus();
-    }
-
-    if (IsBusy())
-    {
-        Cancel();
-    }
-    RunIfNotReady();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleCPMPluginGetLicense() Out"));
-}
-
 void PVPlayerEngine::HandleSourceNodeGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeGetLicense() In"));
@@ -15501,7 +15410,29 @@
 
 void PVPlayerEngine::HandleSourceNodeErrorEvent(const PVMFAsyncEvent& aEvent)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() In"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() In"));
+
+    if (iState == PVP_ENGINE_STATE_RESETTING)
+    {
+        //this means error handling, reset or cancelall is still in progress
+        //no need to look for error event
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Return engine in resetting state no need to process the error event"));
+        return;
+    }
+
+    for (uint32 i = 0; i < iCurrentContextList.size(); ++i)
+    {
+        if (iCurrentContextList[i]->iNode)
+        {
+            if (iCurrentContextList[i]->iNode == iSourceNode)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Cmd Pending on Source node, so src node should not send error events - ignoring err event"));
+                return;
+            }
+        }
+    }
 
     PVMFEventType event = aEvent.GetEventType();
 
@@ -15512,39 +15443,71 @@
         case PVMFErrResource:
         case PVMFErrProcessing:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Sending PVPlayerErrSourceMediaData for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Sending PVPlayerErrSourceMediaData for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceMediaData, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceMediaData, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
         case PVMFErrUnderflow:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Sending PVPlayerErrSourceMediaDataUnavailable for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Sending PVPlayerErrSourceMediaDataUnavailable for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceMediaDataUnavailable, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceMediaDataUnavailable, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
@@ -15553,20 +15516,36 @@
         case PVMFErrTimeout:
         case PVMFErrNoMemory:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Sending PVPlayerErrSourceFatal for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Sending PVPlayerErrSourceFatal for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSourceNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSourceFatal, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
@@ -15582,10 +15561,19 @@
 
 void PVPlayerEngine::HandleDecNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeErrorEvent() In"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeErrorEvent() In"));
 
     OSCL_UNUSED_ARG(aDatapathIndex);
 
+    if (iState == PVP_ENGINE_STATE_RESETTING)
+    {
+        //this means error handling, reset or cancelall is still in progress
+        //no need to look for error event
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Return engine in resetting state no need to process the error event"));
+        return;
+    }
+
     PVMFEventType event = aEvent.GetEventType();
 
     switch (event)
@@ -15595,20 +15583,36 @@
         case PVMFErrUnderflow:
         case PVMFErrProcessing:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Sending PVPlayerErrDatapathMediaData for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Sending PVPlayerErrDatapathMediaData for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathMediaData, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathMediaData, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
@@ -15618,20 +15622,36 @@
         case PVMFErrResource:
         case PVMFErrNoMemory:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Sending PVPlayerErrDatapathFatal for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Sending PVPlayerErrDatapathFatal for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleDecNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrDatapathFatal, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
@@ -15647,10 +15667,19 @@
 
 void PVPlayerEngine::HandleSinkNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() In"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() In"));
 
     OSCL_UNUSED_ARG(aDatapathIndex);
 
+    if (iState == PVP_ENGINE_STATE_RESETTING)
+    {
+        //this means error handling, reset or cancelall is still in progress
+        //no need to look for error event
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Return engine in resetting state no need to process the error event"));
+        return;
+    }
+
     PVMFEventType event = aEvent.GetEventType();
 
     switch (event)
@@ -15660,20 +15689,36 @@
         case PVMFErrUnderflow:
         case PVMFErrProcessing:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Sending PVPlayerErrDatapathMediaData for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Sending PVPlayerErrDatapathMediaData for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkMediaData, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkMediaData, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
@@ -15683,20 +15728,36 @@
         case PVMFErrResource:
         case PVMFErrNoMemory:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Sending PVPlayerErrSinkFatal for error event %d", event));
-            PVMFErrorInfoMessageInterface* nextmsg = NULL;
-            if (aEvent.GetEventExtensionInterface() != NULL)
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Sending PVPlayerErrSinkFatal for error event %d, Add EH command if not present", event));
+            bool ehPending = CheckForPendingErrorHandlingCmd();
+            if (ehPending)
             {
-                nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                // there should be no error handling queued.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Already EH pending, should never happen"));
+                return;
             }
-            PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
-            PVMFBasicErrorInfoMessage* errmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
-            if (HandleAsyncErrorBasedOnPlayerState(event, errmsg) == true)
+            else
             {
-                SendErrorEvent(event, OSCL_STATIC_CAST(PVInterface*, errmsg), aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                PVMFErrorInfoMessageInterface* nextmsg = NULL;
+                if (aEvent.GetEventExtensionInterface() != NULL)
+                {
+                    nextmsg = GetErrorInfoMessageInterface(*(aEvent.GetEventExtensionInterface()));
+                }
+                PVUuid puuid = PVPlayerErrorInfoEventTypesUUID;
+                iCommandCompleteErrMsgInErrorHandling = OSCL_NEW(PVMFBasicErrorInfoMessage, (PVPlayerErrSinkFatal, puuid, nextmsg));
+                iCommandCompleteStatusInErrorHandling = event;
+                AddCommandToQueue(PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL, NULL, NULL, NULL, false);
+                if (iCurrentCmd.empty())
+                {
+                    // this error was received when no cmd was being processed so send the error event from here
+                    SendErrorEvent(iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling),
+                                   aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
+                    iCommandCompleteErrMsgInErrorHandling->removeRef();
+                    iCommandCompleteErrMsgInErrorHandling = NULL;
+                }
             }
-            errmsg->removeRef();
-            errmsg = NULL;
         }
         break;
 
@@ -15709,227 +15770,6 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeErrorEvent() Out"));
 }
 
-
-void PVPlayerEngine::HandleErrorBasedOnPlayerState(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() In"));
-
-    switch (iState)
-    {
-        case PVP_ENGINE_STATE_PREPARED:
-        case PVP_ENGINE_STATE_STARTED:
-        case PVP_ENGINE_STATE_PAUSED:
-        case PVP_ENGINE_STATE_AUTO_PAUSED:
-            // Issue emergency stop command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error while Prepared, Started, or Paused. Issue stop due to error"));
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_INITIALIZED:
-            // Issue emergency reset command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error while Initialized. Issue reset due to error"));
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_INITIALIZING:
-        {
-            // Initialization of source node failed so go to idle state
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error while Initializing. Go back to idle state"));
-            SetEngineState(PVP_ENGINE_STATE_IDLE);
-        }
-        break;
-
-        case PVP_ENGINE_STATE_STARTING:
-        case PVP_ENGINE_STATE_PAUSING:
-        case PVP_ENGINE_STATE_RESUMING:
-        case PVP_ENGINE_STATE_AUTO_PAUSING:
-        case PVP_ENGINE_STATE_AUTO_RESUMING:
-            // Issue emergency stop command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error while Preparing, Starting, Resuming, or Pausing. Issue stop due to error"));
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-            //call RESET when in preparing state
-        case PVP_ENGINE_STATE_PREPARING:
-        case PVP_ENGINE_STATE_STOPPING:
-            // Issue emergency reset command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error while Preparing/Stopping. Issue stop due to error"));
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_RESETTING:
-            // Issue emergency cleanup command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error while resetting. Issue cleanup due to error"));
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            AddCommandToQueue(PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_IDLE:
-            // Should not receive any error events when idle
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error event received while idle. Do nothing"));
-            OSCL_ASSERT(false);
-            break;
-
-        case PVP_ENGINE_STATE_HANDLINGERROR:
-        case PVP_ENGINE_STATE_ERROR:
-            // Do nothing
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error event received while handling error. Do nothing"));
-            break;
-
-        default:
-            // Unknown state
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Error event received while in state %d. Do nothing", iState));
-            OSCL_ASSERT(false);
-            break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleErrorBasedOnPlayerState() Out"));
-}
-
-
-bool PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState(PVMFEventType aErrorCode, PVMFBasicErrorInfoMessage* aErrMsg)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() In"));
-
-    if (PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS  == iCurrentCmd[0].GetCmdType() && iPendingResetDueToCancelRequest > 0)
-    {
-        return false;
-    }
-
-    bool senderrorevent = true;
-
-    switch (iState)
-    {
-        case PVP_ENGINE_STATE_PREPARED:
-        case PVP_ENGINE_STATE_STARTED:
-        case PVP_ENGINE_STATE_PAUSED:
-        case PVP_ENGINE_STATE_AUTO_PAUSED:
-            // Issue emergency stop command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error while Prepared, Started, or Paused. Issue stop due to error"));
-            // Change to error state
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            if (iCurrentCmd.empty() == false)
-            {
-                // Report the error by completing the current command with error
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), aErrorCode, aErrMsg);
-                senderrorevent = false;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-            AddCommandToQueue(PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_INITIALIZED:
-            // Issue emergency reset command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error while Initialized. Issue reset due to error"));
-            // Change to error state
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            if (iCurrentCmd.empty() == false)
-            {
-                // Report the error by completing the current command with error
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), aErrorCode, aErrMsg);
-                senderrorevent = false;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-            AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_INITIALIZING:
-            // Initialization of source node failed so go to idle state
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error while Initializing. Go back to idle state"));
-            // Change to error state
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            if (iCurrentCmd.empty() == false)
-            {
-                // Report the error by completing the current command with error
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), aErrorCode, aErrMsg);
-                senderrorevent = false;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-            AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_PREPARING:
-        case PVP_ENGINE_STATE_STARTING:
-        case PVP_ENGINE_STATE_PAUSING:
-        case PVP_ENGINE_STATE_RESUMING:
-            // Issue emergency stop command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error while Preparing, Starting, Resuming, or Pausing. Issue stop due to error"));
-            // Change to error state
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            if (iCurrentCmd.empty() == false)
-            {
-                // Report the error by completing the current command with error
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), aErrorCode, aErrMsg);
-                senderrorevent = false;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-            AddCommandToQueue(PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_STOPPING:
-            // Issue emergency reset command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error while Stopping. Issue reset due to error"));
-            // Change to error state
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            if (iCurrentCmd.empty() == false)
-            {
-                // Report the error by completing the current command with error
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), aErrorCode, aErrMsg);
-                senderrorevent = false;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-            AddCommandToQueue(PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_RESETTING:
-            // Issue emergency cleanup command
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error while resetting. Issue cleanup due to error"));
-            // Change to error state
-            SetEngineState(PVP_ENGINE_STATE_ERROR);
-            if (iCurrentCmd.empty() == false)
-            {
-                // Report the error by completing the current command with error
-                EngineCommandCompleted(iCurrentCmd[0].GetCmdId(), iCurrentCmd[0].GetContext(), aErrorCode, aErrMsg);
-                senderrorevent = false;
-                // Cancel any pending node/datapath commands
-                DoCancelDueToError();
-            }
-            AddCommandToQueue(PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR, NULL, NULL, NULL, false);
-            break;
-
-        case PVP_ENGINE_STATE_IDLE:
-            // Should not receive any error events when idle
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error event received while idle. Do nothing"));
-            OSCL_ASSERT(false);
-            break;
-
-        case PVP_ENGINE_STATE_HANDLINGERROR:
-        case PVP_ENGINE_STATE_ERROR:
-            // Do nothing
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error event received while handling error. Do nothing"));
-            break;
-
-        default:
-            // Unknown state
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Error event received while in state %d. Do nothing", iState));
-            OSCL_ASSERT(false);
-            break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::HandleAsyncErrorBasedOnPlayerState() Out"));
-
-    return senderrorevent;
-}
-
 //Return val: true means found/deleted cmd(s).
 bool PVPlayerEngine::removeCmdFromQ(Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> &aVec, const PVPlayerEngineCommandType aCmdType, bool aRemove)
 {
@@ -16010,6 +15850,15 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() In"));
 
+    if (iState == PVP_ENGINE_STATE_RESETTING)
+    {
+        //this means error handling, reset or cancelall is still in progress
+        //no need to look for info event
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Return engine in resetting state no need to process the info event %d", aEvent.GetEventType()));
+        return;
+    }
+
     PVMFEventType event = aEvent.GetEventType();
 
     switch (event)
@@ -16035,7 +15884,8 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Received PVMFInfoUnderflow"));
             // remove pending auto-resume if there is any
             if (removeCmdFromQ(iPendingCmds, PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY, true))
-            {//cancelled the pending auto-resume
+            {
+                //cancelled the pending auto-resume
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() PVMFInfoUnderflow got cancelled"));
                 break;
             }
@@ -16055,7 +15905,8 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Received PVMFInfoDataReady"));
             // remove pending auto-pause if there is any
             if (removeCmdFromQ(iPendingCmds, PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW, true))
-            {//cancelled the pending auto-pause
+            {
+                //cancelled the pending auto-pause
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() PVMFInfoDataReady got cancelled"));
                 break;
             }
@@ -16075,6 +15926,7 @@
         case PVMFInfoContentTruncated:
         case PVMFInfoRemoteSourceNotification:
         case PVMFInfoPlayListClipTransition:
+        case PVMFInfoPlayListSwitch:
         {
             PVInterface* intf = NULL;
             PVMFBasicErrorInfoMessage* infomsg = NULL;
@@ -16123,11 +15975,13 @@
             PVUuid infomsguuid = PVMFDurationInfoMessageInterfaceUUID;
             PVMFDurationInfoMessageInterface* eventMsg = NULL;
             PVInterface* infoExtInterface = aEvent.GetEventExtensionInterface();
+            PVInterface* temp = NULL;
             if (infoExtInterface &&
-                    infoExtInterface->queryInterface(infomsguuid, (PVInterface*&)eventMsg))
+                    infoExtInterface->queryInterface(infomsguuid, temp))
             {
                 PVUuid eventuuid;
                 int32 infoCode;
+                eventMsg = OSCL_STATIC_CAST(PVMFDurationInfoMessageInterface*, temp);
                 eventMsg->GetCodeUUID(infoCode, eventuuid);
                 if (eventuuid == infomsguuid)
                 {
@@ -16142,7 +15996,7 @@
 
         case PVMFInfoMetadataAvailable:
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Sending meta data Info %d", event));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Sending Meta data Info available %d", event));
             SendInformationalEvent(event, NULL, aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
         }
         break;
@@ -16152,6 +16006,19 @@
             SendInformationalEvent(event, NULL, aEvent.GetEventData(), aEvent.GetLocalBuffer(), aEvent.GetLocalBufferSize());
         }
         break;
+        case PVMFInfoSourceOverflow:
+        {
+            PVPPlaybackPosition aBeginPos;
+            aBeginPos.iIndeterminate = false;
+            aBeginPos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            aBeginPos.iPosValue.millisec_value = 0;
+            PVPPlaybackPosition aEndPos;
+            aEndPos.iIndeterminate = true;
+            iOverflowFlag = true;
+            SetPlaybackRange(aBeginPos, aEndPos, false);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSourceNodeInfoEvent() Received source overflow event, issue auto-reposition command"));
+        }
+        break;
         case PVMFInfoEndOfData:
         default:
             // Do nothing but log it
@@ -16167,6 +16034,15 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleDecNodeInfoEvent() In"));
 
+    if (iState == PVP_ENGINE_STATE_RESETTING)
+    {
+        //this means error handling, reset or cancelall is still in progress
+        //no need to look for info event
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleDecNodeInfoEvent() Return engine in resetting state no need to process the info event %d", aEvent.GetEventType()));
+        return;
+    }
+
     OSCL_UNUSED_ARG(aDatapathIndex);
 
     PVMFEventType event = aEvent.GetEventType();
@@ -16195,6 +16071,15 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() In"));
 
+    if (iState == PVP_ENGINE_STATE_RESETTING)
+    {
+        //this means error handling, reset or cancelall is still in progress
+        //no need to look for info event
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() Return engine in resetting state no need to process the info event %d", aEvent.GetEventType()));
+        return;
+    }
+
     PVMFEventType event = aEvent.GetEventType();
 
     switch (event)
@@ -16213,7 +16098,7 @@
 
             if (streamID != iStreamID)
             {
-                // recieved StartOfData for previous streamId, ignoring these events
+                // received StartOfData for previous streamId, ignoring these events
                 break;
             }
 
@@ -16228,17 +16113,19 @@
                 {
                     iWatchDogTimer->Cancel();
                 }
-                // we have received all the bos event for
-                // playback hasnt started yet
-                StartPlaybackClock();
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() - PlayClock Started"));
+                //check engine internal state here prior to starting the clock
+                //this is to make sure that we do not start the clock in case engine is still
+                //auto-paused (think usecase: auto-pause, setplaybackrange, auto-resume)
+                if (iState == PVP_ENGINE_STATE_STARTED)
+                {
+                    // start the clock only if engine is in started state
+                    StartPlaybackClock();
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() - PlayClock Started"));
+                }
             }
-
-            //else it could mean duplicate or old PVMFInfoStartOfData, ignore
-            //both
+            //else it could mean duplicate or old PVMFInfoStartOfData, ignore both
         }
         break;
-
         case PVMFInfoEndOfData:
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() PVMFInfoEndOfData event received for %s",
@@ -16249,11 +16136,14 @@
 
             if (streamID != iStreamID)
             {
-                // recieved EndOfData for previous streamId, ignoring these events
+                // received EndOfData for previous streamId, ignoring these events
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::HandleSinkNodeInfoEvent() PVMFInfoEndOfData event received for %s with StreamID=%d, Engine StreamID=%d",
+                                iDatapathList[aDatapathIndex].iTrackInfo->getTrackMimeType().get_cstr(),
+                                streamID, iStreamID));
                 break;
             }
 
-            if (iDatapathList[aDatapathIndex].iTrackActive && iDatapathList[aDatapathIndex].iEndOfDataReceived == false)
+            if (iDatapathList[aDatapathIndex].iDatapath && iDatapathList[aDatapathIndex].iEndOfDataReceived == false)
             {
                 iDatapathList[aDatapathIndex].iEndOfDataReceived = true;
                 // If all datapath received EOS, initiate a pause-due-to-EOS
@@ -16297,7 +16187,7 @@
     // received EOS yet. Else true.
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive == true &&
+        if (iDatapathList[i].iDatapath &&
                 iDatapathList[i].iEndOfDataReceived == false)
         {
             return false;
@@ -16384,7 +16274,10 @@
 
     if (aStatus == PVMFSuccess || aStatus == PVMFErrNotSupported)
     {
-        if (!iDataReadySent)
+        // send DataReady event only if it is not sent earlier and if EOS is not reported.
+        // It is possible that for Streaming repositioning to end use-cases engine receives
+        // EOS before prepare completes, in that case suppress DataReady event.
+        if (!iDataReadySent && !iPlaybackPausedDueToEndOfClip)
         {
             iDataReadySent = true;
             SendInformationalEvent(PVMFInfoDataReady);
@@ -16403,28 +16296,13 @@
 }
 
 
-void PVPlayerEngine::SendErrorHandlingCompleteEvent(PVMFStatus aStatus, PVInterface* /*aExtInterface*/)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::SendErrorHandlingCompleteEvent() In"));
-
-    if (aStatus == PVMFSuccess)
-    {
-        SendInformationalEvent(PVMFInfoErrorHandlingComplete, NULL);
-    }
-    else
-    {
-        // Don't send any event since error handling is still not complete
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::SendErrorHandlingCompleteEvent() Out"));
-}
-
-
 PVMFErrorInfoMessageInterface* PVPlayerEngine::GetErrorInfoMessageInterface(PVInterface& aInterface)
 {
     PVMFErrorInfoMessageInterface* extiface = NULL;
-    if (aInterface.queryInterface(PVMFErrorInfoMessageInterfaceUUID, (PVInterface*&)extiface))
+    PVInterface* temp = NULL;
+    if (aInterface.queryInterface(PVMFErrorInfoMessageInterfaceUUID, temp))
     {
+        extiface = OSCL_STATIC_CAST(PVMFErrorInfoMessageInterface*, temp);
         return extiface;
     }
     else
@@ -16442,26 +16320,22 @@
     // To get regular play status events
     iPlayStatusTimerEnabled = true;
 
-    // Determine the check cycle based on interval setting in milliseconds
-    // and timer frequency of 100 millisec
-    int32 checkcycle = iPBPosStatusInterval / 100;
-    if (checkcycle == 0)
-    {
-        ++checkcycle;
-    }
-    OSCL_ASSERT(iPollingCheckTimer);
-    iPollingCheckTimer->Request(PVPLAYERENGINE_TIMERID_PLAY_STATUS, 0, checkcycle, this, true);
+    iClockNotificationsInf->SetCallbackDeltaTime(iPBPosStatusInterval,
+            iPlayStatusCallbackTimerMarginWindow, (PVMFMediaClockNotificationsObs*)this, false, NULL,
+            iPlayStatusCallbackTimerID);
 }
 
 
 void PVPlayerEngine::StopPlaybackStatusTimer(void)
 {
 
-
     // Stop the playback position status timer
     iPlayStatusTimerEnabled = false;
-    OSCL_ASSERT(iPollingCheckTimer);
-    iPollingCheckTimer->Cancel(PVPLAYERENGINE_TIMERID_PLAY_STATUS);
+    if (iClockNotificationsInf && iPlayStatusCallbackTimerID)
+    {
+        iClockNotificationsInf->CancelCallback(iPlayStatusCallbackTimerID, false);
+        iPlayStatusCallbackTimerID = 0;
+    }
 }
 
 bool PVPlayerEngine::CheckForSourceRollOver()
@@ -16497,18 +16371,18 @@
          *  4) Third alternate source format would be PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL,
          *  implying that we would attempt a MS HTTP streaming session
          */
-        iSourceFormatType = PVMF_DATA_SOURCE_RTSP_URL; ;
-        if (iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL) != true)
+        iSourceFormatType = PVMF_MIME_DATA_SOURCE_RTSP_URL; ;
+        if (iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL) != true)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::SetupDataSourceForUnknownURLAccess() - SetAlternateSourceFormatType Failed"));
             return PVMFFailure;
         }
-        if (iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) != true)
+        if (iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) != true)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::SetupDataSourceForUnknownURLAccess() - SetAlternateSourceFormatType Failed"));
             return PVMFFailure;
         }
-        if (iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL) != true)
+        if (iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL) != true)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::SetupDataSourceForUnknownURLAccess() - SetAlternateSourceFormatType Failed"));
             return PVMFFailure;
@@ -16534,7 +16408,7 @@
     oscl_strncpy(KvpCapNConfig->key, aKvpValue->key, oscl_strlen(aKvpValue->key) + 1);
 
 
-    /// all the values have copied automatically so just need to allocate memory of pointer type.
+    // all the values have copied automatically so just need to allocate memory of pointer type.
 
     if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=wchar*")) != NULL)
     {
@@ -16562,56 +16436,56 @@
         KvpCapNConfig->value.pInt32_value = (int32*)OSCL_MALLOC(sizeof(int32));
         if (! KvpCapNConfig->value.pInt32_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.pInt32_value, aKvpValue->value.pInt32_value, sizeof(int32));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length , currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=uint32*")) != NULL)
     {
         KvpCapNConfig->value.pUint32_value = (uint32*)OSCL_MALLOC(sizeof(uint32));
         if (! KvpCapNConfig->value.pUint32_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.pUint32_value, aKvpValue->value.pUint32_value, sizeof(uint32));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=int64*")) != NULL)
     {
         KvpCapNConfig->value.pInt64_value = (int64*)OSCL_MALLOC(sizeof(int64));
         if (! KvpCapNConfig->value.pInt64_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.pInt64_value, aKvpValue->value.pInt64_value, sizeof(int64));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=uint64*")) != NULL)
     {
         KvpCapNConfig->value.pUint64_value = (uint64*)OSCL_MALLOC(sizeof(uint64));
         if (! KvpCapNConfig->value.pUint64_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.pUint64_value, aKvpValue->value.pUint64_value, sizeof(uint64));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=float*")) != NULL)
     {
         KvpCapNConfig->value.pFloat_value = (float*)OSCL_MALLOC(sizeof(float));
         if (! KvpCapNConfig->value.pFloat_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.pFloat_value, aKvpValue->value.pFloat_value, sizeof(float));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=double*")) != NULL)
     {
         KvpCapNConfig->value.pDouble_value = (double*)OSCL_MALLOC(sizeof(double));
         if (! KvpCapNConfig->value.pDouble_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.pDouble_value, aKvpValue->value.pDouble_value, sizeof(double));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=range_int32")) != NULL)
     {
         KvpCapNConfig->value.key_specific_value = (void*)OSCL_MALLOC(sizeof(range_int32));
         if (! KvpCapNConfig->value.key_specific_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.key_specific_value, aKvpValue->value.key_specific_value, sizeof(range_int32));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
     else if (oscl_strstr(aKvpValue->key, _STRLIT_CHAR("valtype=range_uint32")) != NULL)
     {
         KvpCapNConfig->value.key_specific_value = (void*)OSCL_MALLOC(sizeof(range_uint32));
         if (! KvpCapNConfig->value.key_specific_value)  return PVMFErrNoMemory;
         oscl_memcpy(KvpCapNConfig->value.key_specific_value, aKvpValue->value.key_specific_value, sizeof(range_uint32));
-        // Currently support only one element.  Future support will be based on length.
+        // @TODO: Future support will be based on length, currently support only one element
     }
 
     iPvmiKvpCapNConfig.push_back(KvpCapNConfig);
@@ -16634,6 +16508,7 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::SetRollOverKVPValues() Configuring cap-config failed"));
         }
     }
+
 }
 
 void PVPlayerEngine::DeleteKVPValues()
@@ -16714,23 +16589,28 @@
 
 void PVPlayerEngine::PVPlayerWatchdogTimerEvent()
 {
-    StartPlaybackClock();
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::PVPlayerWatchdogTimerEvent() WatchDog timer expired"));
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::PVPlayerWatchdogTimerEvent() WatchDog timer expired"));
+    //check engine internal state here prior to starting the clock
+    //this is to make sure that we do not start the clock in case engine is still
+    //auto-paused (think usecase: auto-pause, setplaybackrange, auto-resume)
+    if (iState == PVP_ENGINE_STATE_STARTED)
+    {
+        // start the clock only if engine is in started state
+        StartPlaybackClock();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::PVPlayerWatchdogTimerEvent() WatchDog timer expired"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO, (0, "PVPlayerEngine::PVPlayerWatchdogTimerEvent() WatchDog timer expired"));
+    }
 }
 
 void PVPlayerEngine::StartPlaybackClock()
 {
-    iWatchDogTimer->Cancel();
-    if (GetPVPlayerState() != PVP_STATE_STARTED)
+    if (iWatchDogTimer->IsBusy())
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::StartPlaybackClock() wrong engine state"));
-        return;
+        iWatchDogTimer->Cancel();
     }
 
-    if (iPlaybackClock.GetState() == OsclClock::RUNNING)
+    if (iPlaybackClock.GetState() == PVMFMediaClock::RUNNING)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::StartPlaybackClock() clock already started"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "PVPlayerEngine::StartPlaybackClock() clock already started"));
         return;
     }
 
@@ -16738,7 +16618,7 @@
     // Notify all sink nodes that have sync control IF that clock has started
     for (uint32 i = 0; i < iDatapathList.size(); ++i)
     {
-        if (iDatapathList[i].iTrackActive && iDatapathList[i].iSinkNodeSyncCtrlIF)
+        if (iDatapathList[i].iDatapath && iDatapathList[i].iSinkNodeSyncCtrlIF)
         {
             iDatapathList[i].iSinkNodeSyncCtrlIF->ClockStarted();
         }
@@ -16761,7 +16641,6 @@
         iPollingCheckTimer->Request(PVPLAYERENGINE_TIMERID_ENDTIMECHECK, 0, checkcycle, this, true);
     }
 
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::StartPlaybackClock() StartNPT %d StartTS %d", iStartNPT, iStartMediaDataTS));
 }
 
@@ -16874,144 +16753,284 @@
     return PVMFSuccess;
 }
 
-#ifdef HAS_OSCL_LIB_SUPPORT
-void PVPlayerEngine::PopulateNodeRegistry(const OSCL_String& aConfigFilePath)
+void PVPlayerEngine::ResetReposVariables(bool aResetAll)
 {
-    OsclLibraryList libList;
-
-    // Check the current directory for a config file first. This way you can
-    // override the config file set by the tunables.
-    OSCL_StackString<PVPLAYERENGINE_DEFAULT_CONFIG_PATH_SIZE> defaultConfig("./pvplayer.conf");
-    if (OsclLibFail == libList.Populate(PV_NODE_REGISTRY_INTERFACE, defaultConfig))
+    if (aResetAll)
     {
-        libList.Populate(PV_NODE_REGISTRY_INTERFACE, aConfigFilePath);
+        iStreamID = 0;
     }
-
-    for (unsigned int i = 0; i < libList.Size(); i++)
+    if (iWatchDogTimer != NULL)
     {
-        OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
-        if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
+        if (iWatchDogTimer->IsBusy())
         {
-            OsclAny* interfacePtr = NULL;
-            OsclLibStatus result = lib->QueryInterface(PV_NODE_REGISTRY_INTERFACE, (OsclAny*&)interfacePtr);
-            if (result == OsclLibSuccess && interfacePtr != NULL)
+            iWatchDogTimer->Cancel();
+        }
+    }
+    iNumPendingSkipCompleteEvent = 0;
+    iNumPVMFInfoStartOfDataPending = 0;
+    iTargetNPT = 0;
+    iActualNPT = 0;
+    iActualMediaDataTS = 0;
+    iSkipMediaDataTS = 0;
+}
+
+PVMFStatus PVPlayerEngine::DoErrorHandling()
+{
+    //pls note that we come into this method twice, in case of error handling
+    //first time, we come here to start the error handling seq (cancelall if any, followed by reset)
+    //second time, we come here when all resets are complete to cleanup and send command completes
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoErrorHandling() In"));
+    // Stop the playback clock
+    iPlaybackClock.Stop();
+
+    // 1st check if anything needs to be cancelled on Source Node or Datapaths
+    if (!iCurrentContextList.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::DoErrorHandling() Some Command is being processed, cancel it"));
+        for (uint32 i = 0; i < iCurrentContextList.size(); ++i)
+        {
+            if (iCurrentContextList[i]->iNode)
             {
-                struct PVPlayerEngineNodeSharedLibInfo *libInfo = (struct PVPlayerEngineNodeSharedLibInfo *)oscl_malloc(sizeof(struct PVPlayerEngineNodeSharedLibInfo));
-                if (NULL != libInfo)
+                if (iCurrentContextList[i]->iNode == iSourceNode)
                 {
-                    libInfo->iLib = lib;
-
-                    NodeRegistrySharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeRegistrySharedLibraryInterface*, interfacePtr);
-                    libInfo->iNodeLibIfacePtr = nodeIntPtr;
-                    nodeIntPtr->RegisterAllNodes((PVPlayerNodeRegistryInterface *)&iPlayerNodeRegistry,  libInfo->iContext);
-
-                    // save for depopulation later
-                    iNodeLibInfoList.push_front(libInfo);
-                    continue;
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoErrorHandling() Cmd Pending on Source node, should never happend, asserting"));
+                    OSCL_ASSERT(false);
                 }
             }
         }
-        lib->Close();
-        OSCL_DELETE(lib);
-    }
-}
 
-void PVPlayerEngine::PopulateRecognizerRegistry(const OSCL_String& aConfigFilePath)
-{
-    OsclLibraryList libList;
-
-    // Check the current directory for a config file first. This way you can
-    // override the config file set by the tunables.
-    OSCL_StackString<PVPLAYERENGINE_DEFAULT_CONFIG_PATH_SIZE> defaultConfig("./pvplayer.conf");
-    if (OsclLibFail == libList.Populate(PV_RECOGNIZER_INTERFACE, defaultConfig))
-    {
-        libList.Populate(PV_RECOGNIZER_INTERFACE, aConfigFilePath);
-    }
-
-    for (unsigned int i = 0; i < libList.Size(); i++)
-    {
-        OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
-        if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
+        // error handling code set engine state to resetting
+        SetEngineState(PVP_ENGINE_STATE_RESETTING);
+        iRollOverState = RollOverStateIdle; //reset roll over state to Idle, as engine is resetting itself
+        // Since there is a pending node or datapath, cancel it
+        PVMFStatus status = DoCancelPendingNodeDatapathCommand();
+        if (status == PVMFPending)
         {
-            OsclAny* interfacePtr = NULL;
-            OsclLibStatus result = lib->QueryInterface(PV_RECOGNIZER_INTERFACE, (OsclAny*&)interfacePtr);
-            if (result == OsclLibSuccess && interfacePtr != NULL)
-            {
-                struct PVPlayerEngineRecognizerSharedLibInfo *libInfo = (struct PVPlayerEngineRecognizerSharedLibInfo *)oscl_malloc(sizeof(struct PVPlayerEngineRecognizerSharedLibInfo));
-                if (NULL != libInfo)
-                {
-                    libInfo->iLib = lib;
-
-                    RecognizerSharedLibraryInterface* recognizerIntPtr = OSCL_DYNAMIC_CAST(RecognizerSharedLibraryInterface*, interfacePtr);
-
-                    libInfo->iRecognizerLibIfacePtr = recognizerIntPtr;
-
-                    recognizerIntPtr->RegisterAllRecognizers((PVPlayerRecognizerRegistryInterface *)&iPlayerRecognizerRegistry, libInfo->iContext);
-
-                    // save for depopulation later
-                    iRecognizerLibInfoList.push_front(libInfo);
-                    continue;
-                }
-            }
+            // There are some commands which need to be cancelled so wait for cancel complete
+            // once cancels complete, we would start the reset sequence from either
+            // NodeCommandComplete, HandlePlayerDataPathEvent, RecognizeComplete
+            return PVMFPending;
         }
-        lib->Close();
-        OSCL_DELETE(lib);
+        // if there is nothing to cancel move forward to reset.
     }
-}
 
-void PVPlayerEngine::PopulateAllRegistries(const OSCL_String& aConfigFilePath)
-{
-    PopulateNodeRegistry(aConfigFilePath);
-    PopulateRecognizerRegistry(aConfigFilePath);
-}
-
-void PVPlayerEngine::DepopulateNodeRegistry()
-{
-    // remove all dynamic nodes now
-    // unregister node one by one
-    while (!iNodeLibInfoList.empty())
+    // move on to resetting Source Nodes and Datapaths
+    if (iSourceNode)
     {
-        struct PVPlayerEngineNodeSharedLibInfo *libInfo = iNodeLibInfoList.front();
-        iNodeLibInfoList.erase(iNodeLibInfoList.begin());
+        int32 leavecode = 0;
+        // call reset on source node if not in created state
+        if (iSourceNode->GetState() != EPVMFNodeCreated)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVPlayerEngine::DoErrorHandling() Issue reset on Source Node"));
+            // error handling code set engine state to resetting
+            SetEngineState(PVP_ENGINE_STATE_RESETTING);
+            iRollOverState = RollOverStateIdle; //reset roll over state to Idle, as engine is resetting itself
 
-        OsclSharedLibrary* lib = libInfo->iLib;
-        NodeRegistrySharedLibraryInterface* nodeIntPtr = libInfo->iNodeLibIfacePtr;
-        OsclAny* context = libInfo->iContext;
-        oscl_free(libInfo);
+            PVPlayerEngineContext* context = AllocateEngineContext(NULL, iSourceNode, NULL, -1, NULL, -1);
 
-        nodeIntPtr->UnregisterAllNodes((PVPlayerNodeRegistryInterface *)&iPlayerNodeRegistry, context);
+            PVMFCommandId cmdid = -1;
+            leavecode = 0;
+            OSCL_TRY(leavecode, cmdid = iSourceNode->Reset(iSourceNodeSessionId, (OsclAny*)context));
+            OSCL_FIRST_CATCH_ANY(leavecode,
 
-        lib->Close();
-        OSCL_DELETE(lib);
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "PVPlayerEngine::DoErrorHandling() Reset on iSourceNode did a leave!"));
+                                 FreeEngineContext(context);
+                                 OSCL_ASSERT(false);
+                                 return PVMFFailure);
+
+            return PVMFPending;
+        }
     }
-}
 
-void PVPlayerEngine::DepopulateRecognizerRegistry()
-{
-    // remove all the dynamic plugins now
-    // unregister the plugins one by one
-    while (!iRecognizerLibInfoList.empty())
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "PVPlayerEngine::DoErrorHandling() Source node is deleted or in created state, so start removing sinks"));
+
+    // Now delete the datapath.
+    DoRemoveAllSinks();
+
+    // finally do the source node cleanup
+    if (iDataSource)
     {
-        struct PVPlayerEngineRecognizerSharedLibInfo *libInfo = iRecognizerLibInfoList.front();
-        iRecognizerLibInfoList.erase(iRecognizerLibInfoList.begin());
-
-        OsclSharedLibrary* lib = libInfo->iLib;
-        RecognizerSharedLibraryInterface* recognizerIntPtr = libInfo->iRecognizerLibIfacePtr;
-        OsclAny* context = libInfo->iContext;
-        oscl_free(libInfo);
-
-        recognizerIntPtr->UnregisterAllRecognizers((PVPlayerRecognizerRegistryInterface *)&iPlayerRecognizerRegistry, context);
-
-        lib->Close();
-        OSCL_DELETE(lib);
+        RemoveDataSourceSync(*iDataSource);
     }
+
+    SetEngineState(PVP_ENGINE_STATE_IDLE);
+
+    // Send the command completion if there is any command in Current command
+    if (!iCurrentCmd.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVPlayerEngine::DoErrorHandling() Complete the engine command being processed"));
+        if (iCommandCompleteErrMsgInErrorHandling)
+        {
+            EngineCommandCompleted(iCurrentCmd[0].GetCmdId(),
+                                   iCurrentCmd[0].GetContext(),
+                                   iCommandCompleteStatusInErrorHandling,
+                                   OSCL_STATIC_CAST(PVInterface*, iCommandCompleteErrMsgInErrorHandling));
+            iCommandCompleteErrMsgInErrorHandling->removeRef();
+            iCommandCompleteErrMsgInErrorHandling = NULL;
+        }
+        else
+        {
+            EngineCommandCompleted(iCurrentCmd[0].GetCmdId(),
+                                   iCurrentCmd[0].GetContext(),
+                                   iCommandCompleteStatusInErrorHandling);
+        }
+    }
+
+    // just send the error handling complete event
+    SendInformationalEvent(PVMFInfoErrorHandlingComplete, NULL);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,	(0, "PVPlayerEngine::DoErrorHandling() Out"));
+
+    return PVMFSuccess;
 }
 
-void PVPlayerEngine::DepopulateAllRegistries()
+bool PVPlayerEngine::CheckForPendingErrorHandlingCmd()
 {
-    DepopulateNodeRegistry();
-    DepopulateRecognizerRegistry();
+    //if an error handling cmd had been queued previously
+    //it must be in top, since error handling cmds have the
+    //highest priority and pending cmds queue is a priority
+    //queue
+    bool retval = false;
+    if (!iPendingCmds.empty())
+    {
+        switch (iPendingCmds.top().GetCmdType())
+        {
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS:
+            case PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL:
+                retval = true;
+                break;
+
+            default:
+                break;
+        }
+    }
+    return retval;
 }
-#endif
+
+PVMFStatus PVPlayerEngine::IssueNodeCancelCommand(PVPlayerEngineContext* aCurrentListContext, PVMFSessionId aSessionId, OsclAny* aNumberCancelCmdPending)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCurrentListContext->iNode->CancelAllCommands(aSessionId, aNumberCancelCmdPending));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueDatapathCancelCommand(PVPlayerEngineContext* aCurrentListContext, OsclAny* aNumberCancelCmdPending)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCurrentListContext->iDatapath->CancelCommand(aNumberCancelCmdPending));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueRecognizerRegistryCancel(OsclAny* aNumberCancelCmdPending)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, iPlayerRecognizerRegistry.CancelQuery(aNumberCancelCmdPending));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueSinkNodeInit(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCmdId = aDatapath->iSinkNode->Init(aDatapath->iSinkNodeSessionId, aCmdContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueSinkNodeReset(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCmdId = aDatapath->iSinkNode->Reset(aDatapath->iSinkNodeSessionId, aCmdContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueSinkSkipMediaData(PVPlayerEngineDatapath* aDatapath, bool aSFR, OsclAny* aCmdContext)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aDatapath->iSinkNodeSyncCtrlIF->SkipMediaData(aDatapath->iSinkNodeSessionId, iSkipMediaDataTS, iStreamID, aSFR, aCmdContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueSourceSetDataSourcePosition(bool aIsPosUnitPlayList, OsclAny* aCmdContext)
+{
+    PVMFStatus leavecode = 0;
+    if (aIsPosUnitPlayList)
+    {
+        OSCL_TRY(leavecode, iSourceNodePBCtrlIF->SetDataSourcePosition(iSourceNodeSessionId,
+                 iDataSourcePosParams,
+                 aCmdContext));
+
+    }
+    else
+    {
+        OSCL_TRY(leavecode, iSourceNodePBCtrlIF->SetDataSourcePosition(iSourceNodeSessionId,
+                 iTargetNPT, iActualNPT, iActualMediaDataTS, iSeekToSyncPoint, iStreamID, aCmdContext));
+    }
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueDecNodeInit(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCmdId = aNode->Init(aDecNodeSessionId, aCmdContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueDecNodeReset(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCmdId = aNode->Reset(aDecNodeSessionId, aCmdContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+PVMFStatus PVPlayerEngine::IssueQueryInterface(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, const PVUuid aUuid, PVInterface*& aInterfacePtr, OsclAny* aCmdContext, PVMFCommandId& aCmdId)
+{
+    PVMFStatus leavecode = 0;
+    OSCL_TRY(leavecode, aCmdId = aNode->QueryInterface(aSessionId, aUuid, aInterfacePtr, aCmdContext));
+    OSCL_FIRST_CATCH_ANY(leavecode,;);
+    return leavecode;
+}
+
+OSCL_EXPORT_REF void
+PVPlayerInterface::GetSDKInfo
+(
+    PVSDKInfo& aSdkInfo
+)
+{
+    aSdkInfo.iLabel = PVPLAYER_ENGINE_SDKINFO_LABEL;
+    aSdkInfo.iDate  = PVPLAYER_ENGINE_SDKINFO_DATE;
+}
+
+// END FILE
+
+
+
+
+
+
+
+
+
+
 
 
diff --git a/engines/player/src/pv_player_engine.h b/engines/player/src/pv_player_engine.h
index e0f6c72..0036a71 100644
--- a/engines/player/src/pv_player_engine.h
+++ b/engines/player/src/pv_player_engine.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,8 +38,8 @@
 #include "oscl_priqueue.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #ifndef PV_ENGINE_TYPES_H_INCLUDED
@@ -106,14 +106,6 @@
 #include "pv_player_license_acquisition_interface.h"
 #endif
 
-#ifndef PVMF_CPMPLUGIN_INTERFACE_H_INCLUDED
-#include "pvmf_cpmplugin_interface.h"
-#endif
-
-#ifndef CPM_PLUGIN_REGISTRY_H
-#include "cpm_plugin_registry.h"
-#endif
-
 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
 #include "pvmf_data_source_playback_control.h"
 #endif
@@ -123,15 +115,11 @@
 #endif
 
 
-#ifdef HAS_OSCL_LIB_SUPPORT
 #ifndef PV_PLAYER_REGISTRY_INTERFACE_H_INCLUDED
 #include "pv_player_registry_interface.h"
 #endif
 
-#ifndef PVMF_NODE_SHARED_LIB_INTERFACE_H_INCLUDED
-#include "pvmf_node_shared_lib_interface.h"
-#endif
-#endif
+#include "threadsafe_queue.h"
 
 /**
  * PVPlayerEngineState enum
@@ -145,6 +133,9 @@
     PVP_ENGINE_STATE_INITIALIZING,
     PVP_ENGINE_STATE_INITIALIZED,
     PVP_ENGINE_STATE_PREPARING,
+    PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE,
+    PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE,
+    PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE,
     PVP_ENGINE_STATE_PREPARED,
     PVP_ENGINE_STATE_STARTING,
     PVP_ENGINE_STATE_STARTED,
@@ -156,7 +147,6 @@
     PVP_ENGINE_STATE_RESUMING,
     PVP_ENGINE_STATE_STOPPING,
     PVP_ENGINE_STATE_RESETTING,
-    PVP_ENGINE_STATE_HANDLINGERROR,
     PVP_ENGINE_STATE_ERROR
 } PVPlayerEngineState;
 
@@ -365,6 +355,7 @@
     PVP_ENGINE_COMMAND_INIT,
     PVP_ENGINE_COMMAND_GET_METADATA_KEY,
     PVP_ENGINE_COMMAND_GET_METADATA_VALUE,
+    PVP_ENGINE_COMMAND_RELEASE_METADATA_VALUE,
     PVP_ENGINE_COMMAND_ADD_DATA_SINK,
     PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE,
     PVP_ENGINE_COMMAND_GET_PLAYBACK_RANGE,
@@ -384,16 +375,30 @@
     PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR,
     PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR,
     PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE,
+    PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE_OOTSYNC,
+    PVP_ENGINE_COMMAND_GET_CURRENT_POSITION_OOTSYNC,
+    PVP_ENGINE_COMMAND_CAPCONFIG_SET_OBSERVER_OOTSYNC,
+    PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS_OOTSYNC,
+    PVP_ENGINE_COMMAND_GET_LICENSE_STATUS_OOTSYNC,
+    PVP_ENGINE_COMMAND_CAPCONFIG_GET_PARAMETERS_OOTSYNC,
+    PVP_ENGINE_COMMAND_CAPCONFIG_RELEASE_PARAMETERS_OOTSYNC,
+    PVP_ENGINE_COMMAND_CAPCONFIG_VERIFY_PARAMETERS_OOTSYNC,
     // Internal engine commands
     PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDTIME_REACHED,
     PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP,
     PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW,
     PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY,
-    PVP_ENGINE_COMMAND_CANCEL_DUE_TO_ERROR,
-    PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR,
-    PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR,
-    PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR,
-    PVP_ENGINE_COMMAND_DATAPATH_DELETE
+    // Internal Error Handling Commands
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS,
+    PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL
 } PVPlayerEngineCommandType;
 
 
@@ -516,16 +521,15 @@
                 case PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY:
                     return 5;
 
-                case PVP_ENGINE_COMMAND_CANCEL_DUE_TO_ERROR:
-                    return 1;
-
-                case PVP_ENGINE_COMMAND_STOP_DUE_TO_ERROR:
-                    return 2;
-                case PVP_ENGINE_COMMAND_RESET_DUE_TO_ERROR:
-                    return 2;
-                case PVP_ENGINE_COMMAND_CLEANUP_DUE_TO_ERROR:
-                    return 2;
-                case PVP_ENGINE_COMMAND_DATAPATH_DELETE:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP:
+                case PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS:
                     return 1;
                 default:
                     return 0;
@@ -549,7 +553,7 @@
 
 
 // Key string info at the base level ("x-pvmf/player/")
-#define PVPLAYERCONFIG_BASE_NUMKEYS 14
+#define PVPLAYERCONFIG_BASE_NUMKEYS 13
 const PVPlayerKeyStringData PVPlayerConfigBaseKeys[PVPLAYERCONFIG_BASE_NUMKEYS] =
 {
     {"pbpos_units", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
@@ -557,7 +561,6 @@
     {"endtimecheck_interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"seektosyncpoint", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
     {"skiptorequestedpos", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
-    {"renderskipped", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
     {"syncpointseekwindow", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"syncmargin_video", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32},
     {"syncmargin_audio", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32},
@@ -568,6 +571,23 @@
     {"pbpos_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
 };
 
+enum PlayerConfigBaseKeys_IndexMap
+{
+    PBPOS_UNITS = 0,
+    PBPOS_INTERVAL,
+    ENDTIMECHECK_INTERVAL,
+    SEEKTOSYNCPOINT,
+    SKIPTOREQUESTEDPOSITION,
+    SYNCPOINTSEEKWINDOW,
+    SYNCMARGIN_VIDEO,
+    SYNCMARGIN_AUDIO,
+    SYNCMARGIN_TEXT,
+    NODECMD_TIMEOUT,
+    NODEDATAQUEIUING_TIMEOUT,
+    PRODUCTINFO,
+    PBPOS_ENABLE
+};
+
 // Key string info at the productinfo level ("x-pvmf/player/productinfo/")
 #define PVPLAYERCONFIG_PRODINFO_NUMKEYS 5
 const PVPlayerKeyStringData PVPlayerConfigProdInfoKeys[PVPLAYERCONFIG_PRODINFO_NUMKEYS] =
@@ -579,60 +599,74 @@
     {"device", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}
 };
 
+enum ProductInfoKeys_IndexMap
+{
+    PRODUCTNAME = 0,
+    PARTNUMBER,
+    HARDWAREPLATFORM,
+    SOFTWAREPLATFORM,
+    DEVICE
+};
 
 // Player engine's timebase with rate change capability
-class PVPlayerTimebase : public OsclTimebase_Tickcount
+class PVPlayerTimebase : public PVMFTimebase_Tickcount
 {
     public:
         PVPlayerTimebase()
         {
             iRate = 100000;
-            iRateChangeTBTime = 0;
             iRateChangeTCTime = 0;
+            iRateChangeTC = 0;
         }
 
         ~PVPlayerTimebase()
         {
         }
-
-        void GetCurrentTime64(uint64& aTime, OsclClock_TimeUnits aUnits, uint64& aTimebaseTime)
+        void GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow)
         {
-            if (aUnits != OSCLCLOCK_USEC)
+            // Retrieve the tickcount time
+            uint32 tickcount = 0;
+
+            PVMFTimebase_Tickcount::GetCurrentTick32(tickcount, aOverflow);
+
+            if (aOverflow)
             {
-                // This is player engine specific timebase so only microsec is supported
-                aTime = 0;
-                aTimebaseTime = 0;
+                aTimebaseTickCount = 0;
                 return;
             }
 
-            // Retrieve the tickcount time
-            uint64 tickcounttime = 0;
-            OsclTimebase_Tickcount::GetCurrentTime64(tickcounttime, aUnits, aTimebaseTime);
-
             // Calculate the tickcount since last rate change
-            uint64 timesincechange = tickcounttime - iRateChangeTCTime;
+            uint32 ticksSinceChange = 0;
+            PVTimeComparisonUtils::IsEarlier(iRateChangeTC, tickcount, ticksSinceChange);
 
             if (iRate != 100000)
             {
                 // Adjust according to rate
                 // Rate change resolution is 0.1
-                uint64 convnum = (uint32)(iRate / 10000);
-                uint64 convden = 10;
-                aTime = ((timesincechange * convnum) / convden);
+                uint32 convnum = (iRate / 10000);
+                uint32 convden = 10;
+                aTimebaseTickCount = ((ticksSinceChange * convnum) / convden);
             }
             else
             {
-                aTime = timesincechange;
+                aTimebaseTickCount = ticksSinceChange;
             }
 
             // Add the timebase since last rate change
-            aTime = aTime + iRateChangeTBTime;
+            aTimebaseTickCount = aTimebaseTickCount + iRateChangeTCTime;
         }
 
         void SetRate(int32 aRate)
         {
+            bool overflow = 0;
             // Save the tickcount time when the rate changed
-            GetCurrentTime64(iRateChangeTBTime, OSCLCLOCK_USEC, iRateChangeTCTime);
+            uint32 temp = 0;
+            GetCurrentTick32(temp, overflow);
+            iRateChangeTCTime = temp;
+
+            uint32 tickcount = 0;
+            PVMFTimebase_Tickcount::GetCurrentTick32(tickcount, overflow);
+            iRateChangeTC = tickcount;
             // Change the rate
             iRate = aRate;
         }
@@ -644,8 +678,8 @@
 
     private:
         int32 iRate; // In millipercent of "real-time"
-        uint64 iRateChangeTBTime;  // This timebase's time when rate last changed
-        uint64 iRateChangeTCTime;  // The tickcount's time when rate last changed
+        uint32 iRateChangeTCTime;  // The tickcount's time when rate last changed
+        uint32 iRateChangeTC;
 };
 
 
@@ -667,14 +701,6 @@
 
 typedef enum
 {
-    PVP_MEDIATYPE_VIDEO,
-    PVP_MEDIATYPE_AUDIO,
-    PVP_MEDIATYPE_TEXT,
-    PVP_MEDIATYPE_UNKNOWN
-} PVPlayerMediaType;
-
-typedef enum
-{
     PVP_NODETYPE_SOURCE,
     PVP_NODETYPE_SINK,
     PVP_NODETYPE_DECODER,
@@ -686,39 +712,40 @@
     public:
         PVPlayerEngineDatapath()
         {
-            iMediaType = PVP_MEDIATYPE_UNKNOWN;
             iTrackInfo = NULL;
-            iSrcFormat = PVMF_FORMAT_UNKNOWN;
-            iTrackActive = false;
+            iSrcFormat = PVMF_MIME_FORMAT_UNKNOWN;
             iDataSink = NULL;
             iDatapath = NULL;
             iDecNode = NULL;
             iDecNodeSessionId = 0;
             iDecNodeCapConfigIF = NULL;
             iDecNodeMetadataExtIF = NULL;
+            iDecNodePVInterfaceMetadataExt = NULL;
             iSinkNode = NULL;
             iSinkNodeSessionId = 0;
             iSinkNodeFOConfigIF = NULL;
             iSinkNodeSyncCtrlIF = NULL;
             iSinkNodeCapConfigIF = NULL;
             iSinkNodeMetadataExtIF = NULL;
-            iSinkFormat = PVMF_FORMAT_UNKNOWN;
+            iSinkFormat = PVMF_MIME_FORMAT_UNKNOWN;
+            iSinkNodePVInterfaceSyncCtrl = NULL;
+            iSinkNodePVInterfaceCapConfig = NULL;
+            iSinkNodePVInterfaceMetadataExt = NULL;
             iNumPendingCmd = 0;
             iEndOfDataReceived = false;
         };
 
         PVPlayerEngineDatapath(const PVPlayerEngineDatapath& aSrc)
         {
-            iMediaType = aSrc.iMediaType;
             iTrackInfo = aSrc.iTrackInfo;
             iSrcFormat = aSrc.iSrcFormat;
-            iTrackActive = aSrc.iTrackActive;
             iDataSink = aSrc.iDataSink;
             iDatapath = aSrc.iDatapath;
             iDecNode = aSrc.iDecNode;
             iDecNodeSessionId = aSrc.iDecNodeSessionId;
             iDecNodeCapConfigIF = aSrc.iDecNodeCapConfigIF;
             iDecNodeMetadataExtIF = aSrc.iDecNodeMetadataExtIF;
+            iDecNodePVInterfaceMetadataExt = aSrc.iDecNodePVInterfaceMetadataExt;
             iSinkNode = aSrc.iSinkNode;
             iSinkNodeSessionId = aSrc.iSinkNodeSessionId;
             iSinkNodeFOConfigIF = aSrc.iSinkNodeFOConfigIF;
@@ -726,6 +753,9 @@
             iSinkNodeCapConfigIF = aSrc.iSinkNodeCapConfigIF;
             iSinkNodeMetadataExtIF = aSrc.iSinkNodeMetadataExtIF;
             iSinkFormat = aSrc.iSinkFormat;
+            iSinkNodePVInterfaceSyncCtrl = aSrc.iSinkNodePVInterfaceSyncCtrl;
+            iSinkNodePVInterfaceCapConfig = aSrc.iSinkNodePVInterfaceCapConfig;
+            iSinkNodePVInterfaceMetadataExt = aSrc.iSinkNodePVInterfaceMetadataExt;
             iNumPendingCmd = aSrc.iNumPendingCmd;
             iEndOfDataReceived = aSrc.iEndOfDataReceived;
         };
@@ -734,10 +764,8 @@
         {
         };
 
-        PVPlayerMediaType iMediaType;
         PVMFTrackInfo* iTrackInfo;
         PVMFFormatType iSrcFormat;
-        bool iTrackActive;
 
         PVPlayerDataSink* iDataSink;
         PVPlayerDatapath* iDatapath;
@@ -746,6 +774,7 @@
         PVMFSessionId iDecNodeSessionId;
         PvmiCapabilityAndConfig* iDecNodeCapConfigIF;
         PVMFMetadataExtensionInterface* iDecNodeMetadataExtIF;
+        PVInterface* iDecNodePVInterfaceMetadataExt;
 
         PVMFNodeInterface* iSinkNode;
         PVMFSessionId iSinkNodeSessionId;
@@ -754,6 +783,9 @@
         PvmiCapabilityAndConfig* iSinkNodeCapConfigIF;
         PVMFMetadataExtensionInterface* iSinkNodeMetadataExtIF;
         PVMFFormatType iSinkFormat;
+        PVInterface* iSinkNodePVInterfaceSyncCtrl;
+        PVInterface* iSinkNodePVInterfaceCapConfig;
+        PVInterface* iSinkNodePVInterfaceMetadataExt;
 
         uint32 iNumPendingCmd;
         bool iEndOfDataReceived;
@@ -769,6 +801,66 @@
     int32 iCmdType;
 };
 
+class PVPlayerEngineTrackSelection
+{
+    public:
+        PVPlayerEngineTrackSelection()
+        {
+            iTsSinkNode = NULL;
+            iTsSinkNodeSessionId = 0;
+            iTsSinkNodeCapConfigIF = NULL;
+            iTsDecNode = NULL;
+            iTsDecNodeSessionId = 0;
+            iTsDecNodeCapConfigIF = NULL;
+            iTsDecNodePVInterfaceCapConfig = NULL;
+            iTsTrackID = -1;
+            iTsTrackValidForPlayableList = false;
+        };
+
+        PVPlayerEngineTrackSelection(const PVPlayerEngineTrackSelection& aTrackSelection)
+        {
+            iTsSinkNode = aTrackSelection.iTsSinkNode;
+            iTsSinkNodeSessionId = aTrackSelection.iTsSinkNodeSessionId;
+            iTsSinkNodeCapConfigIF = aTrackSelection.iTsSinkNodeCapConfigIF;
+            iTsDecNode = aTrackSelection.iTsDecNode;
+            iTsDecNodeSessionId = aTrackSelection.iTsDecNodeSessionId;
+            iTsDecNodeCapConfigIF = aTrackSelection.iTsDecNodeCapConfigIF;
+            iTsDecNodePVInterfaceCapConfig = aTrackSelection.iTsDecNodePVInterfaceCapConfig;
+            iTsTrackID = aTrackSelection.iTsTrackID;
+            iTsTrackValidForPlayableList = aTrackSelection.iTsTrackValidForPlayableList;
+        };
+
+        PVPlayerEngineTrackSelection& operator=(const PVPlayerEngineTrackSelection& aTrackSelection)
+        {
+            iTsSinkNode = aTrackSelection.iTsSinkNode;
+            iTsSinkNodeSessionId = aTrackSelection.iTsSinkNodeSessionId;
+            iTsSinkNodeCapConfigIF = aTrackSelection.iTsSinkNodeCapConfigIF;
+            iTsDecNode = aTrackSelection.iTsDecNode;
+            iTsDecNodeSessionId = aTrackSelection.iTsDecNodeSessionId;
+            iTsDecNodeCapConfigIF = aTrackSelection.iTsDecNodeCapConfigIF;
+            iTsDecNodePVInterfaceCapConfig = aTrackSelection.iTsDecNodePVInterfaceCapConfig;
+            iTsTrackID = aTrackSelection.iTsTrackID;
+            iTsTrackValidForPlayableList = aTrackSelection.iTsTrackValidForPlayableList;
+            return *this;
+        };
+
+        ~PVPlayerEngineTrackSelection()
+        {
+        };
+
+        PVMFNodeInterface* iTsSinkNode;
+        PVMFSessionId iTsSinkNodeSessionId;
+        PvmiCapabilityAndConfig* iTsSinkNodeCapConfigIF;
+
+        PVMFNodeInterface* iTsDecNode;
+        PVMFSessionId iTsDecNodeSessionId;
+        PvmiCapabilityAndConfig* iTsDecNodeCapConfigIF;
+        PVInterface* iTsDecNodePVInterfaceCapConfig;
+
+        int32 iTsTrackID;
+        bool iTsTrackValidForPlayableList;
+};
+
 
 /**
  * Observer class for the inactivity timer AO
@@ -793,10 +885,11 @@
             public PVPlayerDatapathObserver,
             public OsclTimerObserver,
             public PVPlayerLicenseAcquisitionInterface,
-            public PVMFCPMPluginCmdStatusObserver,
             public PVPlayerRecognizerRegistryObserver,
             public PVPlayerWatchdogTimerObserver,
-            public PVPlayerTrackSelectionInterface
+            public PVPlayerTrackSelectionInterface,
+            public PVMFMediaClockNotificationsObs,
+            public ThreadSafeQueueObserver
 {
     public:
         static PVPlayerEngine* New(PVCommandStatusObserver *aCmdObserver,
@@ -819,14 +912,15 @@
         PVCommandId AddDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL);
         PVCommandId Init(const OsclAny* aContextData = NULL);
         PVCommandId GetMetadataKeys(PVPMetadataList& aKeyList, int32 aStartingIndex = 0, int32 aMaxEntries = -1, char* aQueryKey = NULL, const OsclAny* aContextData = NULL);
-        PVCommandId GetMetadataValues(PVPMetadataList& aKeyList, int32 aStartingValueIndex, int32 aMaxValueEntries, int32& aNumAvailableValueEntries, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL);
+        PVCommandId GetMetadataValues(PVPMetadataList& aKeyList, int32 aStartingValueIndex, int32 aMaxValueEntries, int32& aNumAvailableValueEntries, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL, bool aMetadataValuesCopiedInCallBack = true);
+        PVCommandId ReleaseMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL);
         PVCommandId AddDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData = NULL);
         PVCommandId SetPlaybackRange(PVPPlaybackPosition aBeginPos, PVPPlaybackPosition aEndPos, bool aQueueRange, const OsclAny* aContextData = NULL);
         PVCommandId GetPlaybackRange(PVPPlaybackPosition &aBeginPos, PVPPlaybackPosition &aEndPos, bool aQueued, const OsclAny* aContextData = NULL);
         PVCommandId GetCurrentPosition(PVPPlaybackPosition &aPos, const OsclAny* aContextData = NULL);
         PVMFStatus GetCurrentPositionSync(PVPPlaybackPosition &aPos);
-        PVCommandId SetPlaybackRate(int32 aRate, OsclTimebase* aTimebase = NULL, const OsclAny* aContextData = NULL);
-        PVCommandId GetPlaybackRate(int32& aRate, OsclTimebase*& aTimebase, const OsclAny* aContextData = NULL);
+        PVCommandId SetPlaybackRate(int32 aRate, PVMFTimebase* aTimebase = NULL, const OsclAny* aContextData = NULL);
+        PVCommandId GetPlaybackRate(int32& aRate, PVMFTimebase*& aTimebase, const OsclAny* aContextData = NULL);
         PVCommandId GetPlaybackMinMaxRate(int32& aMinRate, int32& aMaxRate, const OsclAny* aContextData = NULL);
         PVCommandId Prepare(const OsclAny* aContextData = NULL);
         PVCommandId Start(const OsclAny* aContextData = NULL);
@@ -872,20 +966,6 @@
         // From PVPlayerWatchdogTimerObserver
         void PVPlayerWatchdogTimerEvent();
 
-#ifdef HAS_OSCL_LIB_SUPPORT
-        // from PVPlayerRegistryInterface
-        void PopulateNodeRegistry(const OSCL_String& aConfigFilePath);
-        void PopulateRecognizerRegistry(const OSCL_String& aConfigFilePath);
-        void PopulateAllRegistries(const OSCL_String& aConfigFilePath);
-
-        // In future a config file path will be added as a parameter to the
-        // following functions. The original design is to allow the ability
-        // to load and unload multiple configuration files independently.
-        void DepopulateNodeRegistry();
-        void DepopulateRecognizerRegistry();
-        void DepopulateAllRegistries();
-#endif
-
     private:
         PVPlayerEngine();
         void Construct(PVCommandStatusObserver *aCmdObserver,
@@ -898,8 +978,11 @@
         // Utility function to determine the type of node in the player datapath and of the datapath which it belongs to
         bool FindNodeTypeByNode(PVMFNodeInterface* aUnknownNode, PVPlayerNodeType& aNodeType, int32& aDatapathListIndex);
 
-        // Utility function to find the datapath list index based on media type
-        bool FindDatapathByMediaType(PVPlayerMediaType aMediaType, int32& aDatapathListIndex);
+        // Utility function to find the track for given datapath based on mime string
+        bool FindTrackForDatapathUsingMimeString(bool& aVideoTrack, bool& aAudioTrack, bool& aTextTrack, PVPlayerEngineDatapath* aDatapath);
+
+        // Utility function to find the datapath list index based on mime string
+        bool FindDatapathForTrackUsingMimeString(bool aVideoTrack, bool aAudioTrack, bool aTextTrack, int32& aDatapathListIndex);
 
         // From PVMFNodeCmdStatusObserver
         void NodeCommandCompleted(const PVMFCmdResp& aResponse);
@@ -916,8 +999,16 @@
         // From OsclTimerObserver
         void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
 
-        // From PVMFCPMPluginCmdStatusObserver
-        void CPMPluginCommandCompleted(const PVMFCmdResp& aResponse);
+        //From PVMFMediaClockNotificationsObs
+        void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 delta,
+                             const OsclAny* acontextData, PVMFStatus aStatus);
+        void NotificationsInterfaceDestroyed();
+
+        //For sending PVMFInfoPositionStatus
+        void SendPositionStatusUpdate(void);
+
+        // For checking of any pending error handling cmd in the queue
+        bool CheckForPendingErrorHandlingCmd();
 
         // From PVPlayerRecognizerRegistryObserver
         void RecognizeCompleted(PVMFFormatType aSourceFormatType, OsclAny* aContext);
@@ -925,7 +1016,17 @@
         // Command and event queueing related functions
         PVCommandId AddCommandToQueue(int32 aCmdType, OsclAny* aContextData = NULL,
                                       Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector = NULL,
-                                      const PVUuid* aUuid = NULL, bool aAPICommand = true);
+                                      const PVUuid* aUuid = NULL, bool aAPICommand = true, PVCommandId* aId = NULL);
+
+        // Thread-safety mechanisms
+        ThreadSafeQueue iThreadSafeQueue;
+        void ThreadSafeQueueDataAvailable(ThreadSafeQueue*);
+        OsclSemaphore iOOTSyncCommandSem;
+        OsclMutex iCommandIdMut;
+        PVMFStatus DoOOTSyncCommand(int32 aCmdType,
+                                    Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector,
+                                    const PVUuid* aUuid = NULL);
+        void OOTSyncCommandComplete(PVPlayerEngineCommand& aCmd, PVMFStatus aStatus);
 
         // start the playback clock once skip is completed by one of the tracks
         void StartPlaybackClock();
@@ -951,7 +1052,7 @@
         void GetPlaybackClockPosition(PVPPlaybackPosition& aClockPos);
 
         // Utility functions to convert to/from milliseconds to other playback position units
-        PVMFStatus ConvertToMillisec(PVPPlaybackPosition aPBPos, uint32& aTimeMS);
+        PVMFStatus ConvertToMillisec(PVPPlaybackPosition& aPBPos, uint32& aTimeMS);
         PVMFStatus ConvertFromMillisec(uint32 aTimeMS, PVPPlaybackPosition& aPBPos);
 
         // OsclTimer for polling checks
@@ -971,20 +1072,16 @@
         Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCmdToDlaCancel; // Vector of size 1 to hold the command being currently cancelled
         OsclPriorityQueue<PVPlayerEngineCommand, OsclMemAllocator, Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator>, PVPlayerEngineCommandCompareLess> iPendingCmds; // Vector to hold the command that has been requested
 
-        // Variables for completing engine commands in engine's AO
-        bool iCommandCompleteInEngineAOPending;
-        PVMFStatus iCommandCompleteInEngineAOCmdStatus;
-        PVMFBasicErrorInfoMessage* iCommandCompleteInEngineAOErrMsg;
+        // Variables for completing engine commands after error handling
+        PVMFStatus iCommandCompleteStatusInErrorHandling;
+        PVMFBasicErrorInfoMessage* iCommandCompleteErrMsgInErrorHandling;
 
         // Command handling functions
         void DoCancelAllCommands(PVPlayerEngineCommand& aCmd);
         void DoCancelCommandBeingProcessed(void);
-        void DoCancelPendingNodeDatapathCommand(void);
-        void DoShutdownDueToCancel(void);
-        void DoStopDueToCancel(void);
-        void DoResetDueToCancel(void);
-        void DoCleanupDueToCancel(void);
         void DoCancelAcquireLicense(PVPlayerEngineCommand& aCmd);
+        PVMFStatus DoCancelPendingNodeDatapathCommand(void);
+        PVMFStatus DoErrorHandling(void);
         PVMFStatus DoGetSDKInfo(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoSetLogAppender(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoRemoveLogAppender(PVPlayerEngineCommand& aCmd);
@@ -999,27 +1096,22 @@
         PVMFStatus SetupDataSourceForUnknownURLAccess();
         PVMFStatus DoSourceNodeQueryTrackSelIF(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodeQueryInterfaceOptional(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoAddDataSourceFailureComplete(void);
-        PVMFStatus DoInitFailureComplete(void);
         PVMFStatus DoGetMetadataKey(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoGetMetadataValue(PVPlayerEngineCommand& aCmd);
-        PVMFStatus AddToMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId);
+        PVMFStatus DoReleaseMetadataValues(PVPlayerEngineCommand& aCmd);
+        PVMFStatus AddToMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId, PVPlayerEngineDatapath* aEngineDatapath, PVMFNodeInterface* aNode);
         PVMFStatus RemoveFromMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId);
         PVMFStatus DoInit(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoSourceNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodeGetDurationValue(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSourceNodeGetDlaData(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoAcquireLicense(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoSourceNodeGetLicense(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoCPMPluginSetUserAgentHeader(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoCPMPluginGetLicense(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoCPMPluginAcquireLicenseComplete(void);
         PVMFStatus DoAddDataSink(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoSetPlaybackRange(PVPlayerEngineCommand& aCmd);
         PVMFStatus UpdateCurrentEndPosition(PVPPlaybackPosition& aEndPos);
         PVMFStatus UpdateCurrentBeginPosition(PVPPlaybackPosition& aBeginPos, PVPlayerEngineCommand& aCmd);
         PVMFStatus DoChangePlaybackPosition(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSourceNodeSetDataSourcePositionDuringPlayback(PVMFTimestamp aTargetNPT, bool aSeekToSyncPoint, PVCommandId aCmdId, OsclAny* aCmdContext);
+        PVMFStatus DoSourceNodeSetDataSourcePositionDuringPlayback(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSinkNodeSkipMediaDataDuringPlayback(PVCommandId aCmdId,
                 OsclAny* aCmdContext,
                 bool aSFR = false);
@@ -1029,22 +1121,22 @@
         PVMFStatus DoGetPlaybackRate(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoGetPlaybackMinMaxRate(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoPrepare(PVPlayerEngineCommand& aCmd);
+        PVMFStatus DoSinkNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext);
+        PVMFStatus DoSinkNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
+        PVMFStatus DoSinkNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext);
+        PVMFStatus DoDecNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext);
+        PVMFStatus DoDecNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoTrackSelection(bool oPopulatePlayableListOnly, bool oUsePreferenceList);
-        PVMFStatus DoSourceNodeTrackQuery(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSinkNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSinkNodeReset(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoQueryTrackInfo(PVPlayerEngineDatapath &aDatapath, PVMFTrackInfo* aTrack, PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoVerifyTrackInfo(PVPlayerEngineDatapath &aDatapath, PVMFTrackInfo* aTrack, PVMFStatus& aCheckcodec);
+        PVMFStatus DoVerifyTrackInfo(PVPlayerEngineTrackSelection &aTrackSelection, PVMFTrackInfo* aTrack, PVMFStatus& aCheckcodec);
+        PVMFStatus DoSinkNodeDecNodeReset(PVCommandId aCmdId, OsclAny* aCmdContext);
+        PVMFStatus DoSinkDecCleanupSourcePrepare(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodePrepare(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSetupSinkNode(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSinkNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSetupDecNode(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
-        bool IsDecNodeNeeded(PVMFFormatType& aSrcFormat, PVMFFormatType& aSinkFormat);
         PVMFStatus DoDecNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoDatapathPrepare(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodeQueryDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSourceNodeSetDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext, PVMFTimestamp aTargetNPT, bool aSeekToSyncPoint);
+        PVMFStatus DoSourceNodeSetDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodeSetDataSourceDirection(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSourceNodeStart(PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoDatapathStart(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
@@ -1067,25 +1159,20 @@
         PVMFStatus DoSourceDataReadyAutoResume(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoSinkNodePause(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
         PVMFStatus DoSinkNodeResume(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoCancelDueToError(void);
-        PVMFStatus DoStopDueToError(PVPlayerEngineCommand& aCmd);
-        PVMFStatus DoDatapathStopDueToError(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoSourceNodeStopDueToError(PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoDatapathTeardownDueToError(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoDatapathResetDueToError(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
-        PVMFStatus DoResetDueToError(PVPlayerEngineCommand& aCmd);
-        PVMFStatus DoCleanupDueToError(PVPlayerEngineCommand& aCmd);
-        PVMFStatus DoDatapathDelete(PVPlayerEngineCommand &aCmd);
         void DoRemoveAllSinks(void);
         void DoEngineDatapathTeardown(PVPlayerEngineDatapath& aDatapath);
         void DoEngineDatapathCleanup(PVPlayerEngineDatapath& aDatapath);
         void DoSourceNodeCleanup(void);
 
+        PVMFStatus DoSetObserverSync(PVPlayerEngineCommand& aCmd);
+        PVMFStatus DoGetLicenseStatusSync(PVPlayerEngineCommand& aCmd);
+        PVMFStatus DoGetParametersSync(PVPlayerEngineCommand& aCmd);
+        PVMFStatus DoReleaseParametersSync(PVPlayerEngineCommand& aCmd);
+        PVMFStatus DoVerifyParametersSync(PVPlayerEngineCommand& aCmd);
         PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
         PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements);
         PVMFStatus DoCapConfigSetParameters(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false);
         PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
-        PVMFStatus DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PvmiCapabilityAndConfig*, OsclMemAllocator>& aNodeCapConfigIF);
         PVMFStatus DoGetPlayerParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
         PVMFStatus DoGetPlayerProductInfoParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
         PVMFStatus DoVerifyAndSetPlayerParameter(PvmiKvp& aParameter, bool aSetParam);
@@ -1097,14 +1184,13 @@
         Oscl_Vector<PVPlayerEngineDatapath, OsclMemAllocator> iDatapathList;
         uint32 iNumPendingNodeCmd;
         int32 iNumPendingSkipCompleteEvent;
-        bool iResumeAfterReposition;
         PVPlayerWatchdogTimer* iWatchDogTimer;
         uint32 iNumPendingDatapathCmd;
         int32 iNumPVMFInfoStartOfDataPending;
 
         // Data source, data sink, and nodes
         PVPlayerDataSource* iDataSource;
-        PVPlayerDataSourcePacketSource* iDataSourcePS;
+
         PVMFFormatType iSourceFormatType;
         PVMFNodeInterface* iSourceNode;
         PVMFSessionId iSourceNodeSessionId;
@@ -1118,6 +1204,16 @@
         PVMFDataSourceNodeRegistryInitInterface* iSourceNodeRegInitIF;
         PVMFCPMPluginLicenseInterface* iSourceNodeCPMLicenseIF;
         PVMFDataSourcePacketSourceInterface* iSourceNodePacketSourceIF;
+        PVInterface* iSourceNodePVInterfaceInit;
+        PVInterface* iSourceNodePVInterfaceTrackSel;
+        PVInterface* iSourceNodePVInterfacePBCtrl;
+        PVInterface* iSourceNodePVInterfaceDirCtrl;
+        PVInterface* iSourceNodePVInterfaceTrackLevelInfo;
+        PVInterface* iSourceNodePVInterfaceMetadataExt;
+        PVInterface* iSourceNodePVInterfaceCapConfig;
+        PVInterface* iSourceNodePVInterfaceRegInit;
+        PVInterface* iSourceNodePVInterfaceCPMLicense;
+        PVInterface* iSourceNodePVInterfacePacketSource;
 
         // For CPM license acquisition
         struct PVPlayerEngineCPMAcquireLicenseParam
@@ -1131,13 +1227,6 @@
         PVPlayerEngineCPMAcquireLicenseParam iCPMAcquireLicenseParam;
         OSCL_HeapString<OsclMemAllocator> iCPMContentNameStr;
         OSCL_wHeapString<OsclMemAllocator> iCPMContentNameWStr;
-        PVMFCPMPluginInterface* iCPMPlugin;
-        void* iCPMPluginFactory;
-        PVMFSessionId iCPMPluginSessionId;
-        PVMFCPMPluginLicenseInterface* iCPMPluginLicenseIF;
-        PvmiCapabilityAndConfig *iCPMPluginCapConfigIf;
-        int32 iCPMPluginCommand;
-        PVMFStatus DoGetPluginLicenseIF();
         PVMFCommandId iCPMGetLicenseCmdId;
 
         // For metadata handling
@@ -1146,6 +1235,8 @@
         {
             PVMFMetadataExtensionInterface* iInterface;
             PVMFSessionId iSessionId;
+            PVPlayerEngineDatapath* iEngineDatapath;
+            PVMFNodeInterface* iNode;
         };
         Oscl_Vector<PVPlayerEngineMetadataIFInfo, OsclMemAllocator> iMetadataIFList;
 
@@ -1178,6 +1269,12 @@
         };
         PVPlayerEngineGetMetadataValuesParam iGetMetadataValuesParam;
 
+        // Boolean to let engine know if metadata values have been copied by the app
+        bool iMetadataValuesCopiedInCallBack;
+
+        // Boolean to check if Metadata values have been released
+        bool iReleaseMetadataValuesPending;
+
         // Vector hold a list of metadata interfaces with key/value to release memory
         struct PVPlayerEngineMetadataReleaseEntry
         {
@@ -1185,7 +1282,8 @@
             int32 iStartIndex;
             int32 iEndIndex;
         };
-        Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataReleaseList;
+        Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataKeyReleaseList;
+        Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataValueReleaseList;
 
         // Engine context related objects and utility functions
         OsclMemPoolFixedChunkAllocator iCurrentContextListMemPool;
@@ -1195,11 +1293,7 @@
         void RemoveDatapathContextFromList();
 
         // Cancel and error handling related variables
-        uint32 iPendingCancelDueToCancelRequest;
-        uint32 iPendingStopDueToCancelRequest;
-        uint32 iPendingResetDueToCancelRequest;
-        uint32 iPendingCancelDueToErrorRequest;
-        bool iErrorOccurredDuringErrorHandling;
+        uint32 iNumberCancelCmdPending;
 
         enum
         {
@@ -1216,17 +1310,17 @@
             PVP_CMD_SourceNodeQueryPacketSourceIF,
             PVP_CMD_SourceNodeInit,
             PVP_CMD_SourceNodeGetDurationValue,
-            PVP_CMD_SourceNodeGetDlaData,
             PVP_CMD_SourceNodeSetDataSourceRate,
             PVP_CMD_SourceNodePrepare,
             PVP_CMD_SourceNodeGetLicense,
             PVP_CMD_SourceNodeCancelGetLicense,
-            PVP_CMD_SinkNodeQueryFOConfigIF,
             PVP_CMD_SinkNodeQuerySyncCtrlIF,
             PVP_CMD_SinkNodeQueryMetadataIF,
             PVP_CMD_SinkNodeQueryCapConfigIF,
             PVP_CMD_DecNodeQueryMetadataIF,
             PVP_CMD_DecNodeQueryCapConfigIF,
+            PVP_CMD_SinkNodeInit,
+            PVP_CMD_DecNodeInit,
             PVP_CMD_SourceNodeQueryDataSourcePosition,
             PVP_CMD_SourceNodeSetDataSourcePosition,
             PVP_CMD_SourceNodeSetDataSourceDirection,
@@ -1235,9 +1329,9 @@
             PVP_CMD_SourceNodeSetDataSourcePositionDuringPlayback,
             PVP_CMD_SinkNodeSkipMediaDataDuringPlayback,
             PVP_CMD_SinkNodeSkipMediaData,
-            PVP_CMD_SinkNodeDecNodeQueryCapConfigIF,
-            PVP_CMD_SinkNodeDecNodeVerifyParameter,
             PVP_CMD_SinkNodeDecNodeReset,
+            PVP_CMD_SinkNodeReset,
+            PVP_CMD_DecNodeReset,
             PVP_CMD_GetNodeMetadataValue,
             PVP_CMD_GetNodeMetadataKey,
             PVP_CMD_SinkNodeAutoPause,
@@ -1250,10 +1344,6 @@
             PVP_CMD_DPStop,
             PVP_CMD_DPTeardown,
             PVP_CMD_DPReset,
-            // CPM plug-in commands
-            PVP_CMD_CPMQueryCapConfigIF,
-            PVP_CMD_CPMQueryLicenseIF,
-            PVP_CMD_CPMGetLicense,
             // Recognizer command
             PVP_CMD_QUERYSOURCEFORMATTYPE,
             // source roll over
@@ -1266,7 +1356,6 @@
         void HandleSourceNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSourceNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSourceNodeGetDurationValue(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
-        void HandleSourceNodeGetDlaData(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSourceNodeGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSourceNodeCancelGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
 
@@ -1277,7 +1366,6 @@
         void UpdateTimebaseAndRate();
         void UpdateDirection(PVMFTimestamp, PVMFTimestamp, PVPPlaybackPosition&);
         void HandleSourceNodePrepare(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
-        void HandleSinkNodeQueryFileOutConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSinkNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleDecNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSourceNodeQueryDataSourcePosition(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
@@ -1297,11 +1385,14 @@
 
         void HandleSinkNodePause(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
         void HandleSinkNodeResume(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+        void HandleSinkNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+        void HandleDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
 
-        void HandleSourceNodeStopDueToError(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
-        void HandleSourceNodeResetDueToError(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
-        void HandleSinkNodeDecNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
-        void HandleSinkNodeDecNodeVerifyParameter(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+        void HandleSinkNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+        void HandleSinkNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+        void HandleDecNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+        void HandleDecNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
+
         void HandleSinkNodeDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
 
         // Datapath command handling functions
@@ -1313,21 +1404,10 @@
         void HandleDatapathTeardown(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
         void HandleDatapathReset(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
 
-        void HandleDatapathStopDueToError(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
-        void HandleDatapathTeardownDueToError(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
-        void HandleDatapathResetDueToError(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
-
-        // CPM plug-in command handling functions
-        void HandleCPMPluginQueryCapConfigIF(const PVMFCmdResp& aCmdResp);
-        void HandleCPMPluginQueryLicenseIF(const PVMFCmdResp& aCmdResp);
-        void HandleCPMPluginGetLicense(const PVMFCmdResp& aCmdResp);
-
         // Node error event handling functions
         void HandleSourceNodeErrorEvent(const PVMFAsyncEvent& aEvent);
         void HandleDecNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex);
         void HandleSinkNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex);
-        void HandleErrorBasedOnPlayerState(void);
-        bool HandleAsyncErrorBasedOnPlayerState(PVMFEventType aErrorCode, PVMFBasicErrorInfoMessage* aErrMsg = NULL);
 
         // Node informational event handling functions
         void HandleSourceNodeInfoEvent(const PVMFAsyncEvent& aEvent);
@@ -1340,7 +1420,6 @@
         void SendEndTimeReachedInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
         void SendSourceUnderflowInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
         void SendSourceDataReadyInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
-        void SendErrorHandlingCompleteEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
 
         // Utility to retrieve the PVMFErrorInfoMessageInterface from a PVInterface
         PVMFErrorInfoMessageInterface* GetErrorInfoMessageInterface(PVInterface& aInterface);
@@ -1352,11 +1431,25 @@
         // Utility Fucntion to calculate the nearest sync frame
         void CalculateActualPlaybackPosition();
 
-        // Save config values in case of protocol rollover
+        // to save config values in case of protocol rollover
         PVMFStatus VerifyAndSaveKVPValues(PvmiKvp *aKvpValue);
         void SetRollOverKVPValues();
         void DeleteKVPValues();
 
+        // to reset reposition related variables.
+        void ResetReposVariables(bool aResetAll);
+
+        PVMFStatus IssueNodeCancelCommand(PVPlayerEngineContext* aCurrentListContext, PVMFSessionId aSessionId, OsclAny* aNumberCancelCmdPending);
+        PVMFStatus IssueDatapathCancelCommand(PVPlayerEngineContext* aCurrentListContext, OsclAny* aNumberCancelCmdPending);
+        PVMFStatus IssueRecognizerRegistryCancel(OsclAny* aNumberCancelCmdPending);
+        PVMFStatus IssueSinkNodeInit(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
+        PVMFStatus IssueSinkNodeReset(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
+        PVMFStatus IssueSinkSkipMediaData(PVPlayerEngineDatapath* aDatapath, bool aSFR, OsclAny* aCmdContext);
+        PVMFStatus IssueSourceSetDataSourcePosition(bool aIsPosUnitPlayList, OsclAny* aCmdContext);
+        PVMFStatus IssueDecNodeInit(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
+        PVMFStatus IssueDecNodeReset(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
+        PVMFStatus IssueQueryInterface(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, const PVUuid aUuid, PVInterface*& aInterfacePtr, OsclAny* aCmdContext, PVMFCommandId& aCmdId);
+
         // Handle to the logger node
         PVLogger* iLogger;
         PVLogger* iReposLogger;
@@ -1370,25 +1463,17 @@
 
         // Objects for playback clock and playback rate control
         PVPlayerTimebase iPlaybackTimebase;
-        OsclClock iPlaybackClock;
+        PVMFMediaClock iPlaybackClock;
+        PVMFMediaClockNotificationsInterface* iClockNotificationsInf;
+        uint32 iPlayStatusCallbackTimerID;
+        uint32 iPlayStatusCallbackTimerMarginWindow;
+
+
+        uint32 iCurrCallbackTimerLatency;
         int32 iPlaybackClockRate;//always >=0
-        OsclTimebase* iOutsideTimebase;
+        PVMFTimebase* iOutsideTimebase;
         int32 iPlaybackClockRate_New;
-        OsclTimebase* iOutsideTimebase_New;
-        PVMFTimestamp iActualPlaybackPosition;
-
-        PVMFTimestamp iSeekPointBeforeTargetNPT;
-        PVMFTimestamp iSeekPointAfterTargetNPT;
-
-        uint32 iWatchDogTimerInterval;
-
-        PVMFTimestamp iActualMediaDataTS;
-        PVMFTimestamp iAdjustedMediaDataTS;
-        PVMFTimestamp iStartNPT;
-        PVMFTimestamp iStartMediaDataTS;
-        // forward and reverse flags, a single flag can also serve, but kept for MP4 parser alignment.
-        bool iForwardReposFlag;
-        bool iBackwardReposFlag;
+        PVMFTimebase* iOutsideTimebase_New;
 
         PVMFDataSourcePositionParams iDataSourcePosParams;
 
@@ -1407,6 +1492,19 @@
         PVPPlaybackPosition iQueuedEndPosition;
         bool iChangePlaybackPositionWhenResuming;
 
+        PVMFTimestamp iActualNPT;
+        PVMFTimestamp iTargetNPT;
+        PVMFTimestamp iActualMediaDataTS;
+        PVMFTimestamp iSkipMediaDataTS;
+        PVMFTimestamp iStartNPT;
+        PVMFTimestamp iStartMediaDataTS;
+        uint32 iWatchDogTimerInterval;
+        PVMFTimestamp iSeekPointBeforeTargetNPT;
+        PVMFTimestamp iSeekPointAfterTargetNPT;
+        // forward and reverse flags, a single flag can also serve, but kept for MP4 parser alignment.
+        bool iForwardReposFlag;
+        bool iBackwardReposFlag;
+
         // Flag to keep track of whether play status event is enabled or not
         bool iPlayStatusTimerEnabled;
 
@@ -1435,7 +1533,6 @@
         uint32 iEndTimeCheckInterval;
         bool iSeekToSyncPoint;
         bool iSkipToRequestedPosition;
-        bool iRenderSkipped;
         bool iBackwardRepos; /* To avoid backward looping :: Flag to remember if this is a case of backward repositioning */
         uint32 iSyncPointSeekWindow;
         range_int32 iSyncMarginVideo;
@@ -1449,7 +1546,7 @@
         OSCL_HeapString<OsclMemAllocator> iProdInfoSWPlatform;
         OSCL_HeapString<OsclMemAllocator> iProdInfoDevice;
         // stream ID for media streams
-        int32 iStreamID;
+        uint32 iStreamID;
 
         //source roll over related
         PVMFStatus DoSourceNodeRollOver(PVCommandId aCmdId, OsclAny* aCmdContext);
@@ -1476,29 +1573,15 @@
         //Vector to store the Uuids for the nodes created throughout the playback
         Oscl_Vector<PVPlayerEngineUuidNodeMapping, OsclMemAllocator> iNodeUuids;
 
+        // For Track Selection during Prepare
+        Oscl_Vector<PVPlayerEngineTrackSelection, OsclMemAllocator> iTrackSelectionList;
+        PVMFMediaPresentationInfo iSourcePresInfoList;
         PVMFMediaPresentationInfo iPlayableList;
         PVMFMediaPresentationInfo iPreferenceList;
         PVMFTrackSelectionHelper* iTrackSelectionHelper;
 
         PVPPlaybackPositionMode iPlaybackPositionMode;
-#ifdef HAS_OSCL_LIB_SUPPORT
-        struct PVPlayerEngineNodeSharedLibInfo
-        {
-            OsclSharedLibrary* iLib;
-            NodeRegistrySharedLibraryInterface* iNodeLibIfacePtr;
-            OsclAny* iContext;
-        };
-
-        struct PVPlayerEngineRecognizerSharedLibInfo
-        {
-            OsclSharedLibrary* iLib;
-            RecognizerSharedLibraryInterface* iRecognizerLibIfacePtr;
-            OsclAny* iContext;
-        };
-
-        Oscl_Vector<struct PVPlayerEngineNodeSharedLibInfo*, OsclMemAllocator> iNodeLibInfoList;
-        Oscl_Vector<struct PVPlayerEngineRecognizerSharedLibInfo*, OsclMemAllocator> iRecognizerLibInfoList;
-#endif
+        bool iOverflowFlag;
 };
 
 /**
@@ -1506,6 +1589,8 @@
  * on remote inactivity (no UDP traffic from server for a certain time)
  */
 #define DEFAULT_WATCHDOG_TIMERDURATION 10
+#define PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL 1000
+
 class PVPlayerWatchdogTimer : public OsclTimerObject
 {
     public:
@@ -1526,7 +1611,7 @@
         /** Start Timer */
         PVMFStatus Start()
         {
-            if (iTimerDuration >= 0)
+            if (iTimerDuration != 0)
             {
                 RunIfNotReady(iTimerDuration * 1000);
                 iStarted = true;
@@ -1540,7 +1625,15 @@
 
         void setTimerDuration(uint32 aTimerDuration)
         {
-            iTimerDuration = aTimerDuration;
+            Cancel();
+            if (aTimerDuration == 0)
+            {
+                iTimerDuration = PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL;
+            }
+            else
+            {
+                iTimerDuration = aTimerDuration;
+            }
         }
 
         uint32 getTimerDurationInMS()
diff --git a/engines/player/src/pv_player_factory.cpp b/engines/player/src/pv_player_factory.cpp
index 460fd4b..1eb56b7 100644
--- a/engines/player/src/pv_player_factory.cpp
+++ b/engines/player/src/pv_player_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/engines/player/src/pv_player_node_registry.cpp b/engines/player/src/pv_player_node_registry.cpp
new file mode 100644
index 0000000..ee2609a
--- /dev/null
+++ b/engines/player/src/pv_player_node_registry.cpp
@@ -0,0 +1,578 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pv_player_node_registry.h"
+
+#include "pvmi_datastreamsyncinterface_ref_factory.h"
+
+#ifdef USE_LOADABLE_MODULES
+#include "oscl_shared_library.h"
+#include "oscl_library_list.h"
+#include "oscl_configfile_list.h"
+#include "osclconfig_lib.h"
+#include "oscl_shared_lib_interface.h"
+
+#include "pvmf_node_shared_lib_interface.h"
+
+#endif //USE_LOADABLE_MODULES
+
+#include "pvmf_omx_videodec_factory.h"
+
+#if BUILD_VIDEO_DEC_NODE
+#include "pvmf_videodec_factory.h"
+#endif
+
+
+void PVPlayerRegistryPopulator::Populate(PVPlayerNodeRegistry& aNode, PVPlayerRecognizerRegistry& aRec)
+{
+
+#ifdef USE_LOADABLE_MODULES
+    //add loadable modules
+
+    OsclConfigFileList aCfgList;
+    // collects all config files from the project specified directory
+    if (NULL != PV_DYNAMIC_LOADING_CONFIG_FILE_PATH)
+    {
+        OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH;
+        aCfgList.Populate(configFilePath);
+    }
+    // populate libraries from all config files
+    for (uint k = 0; k < aCfgList.Size(); k++)
+    {
+        aNode.AddLoadableModules(aCfgList.GetConfigfileAt(k));
+        aRec.AddLoadableModules(aCfgList.GetConfigfileAt(k));
+    }
+#endif
+
+    //add static modules
+    PVPlayerRegistryPopulator pop;
+    pop.RegisterAllNodes(&aNode, aNode.iStaticPopulatorContext);
+    pop.RegisterAllRecognizers(&aRec, aRec.iStaticPopulatorContext);
+
+}
+
+void PVPlayerRegistryPopulator::Depopulate(PVPlayerNodeRegistry& aNode, PVPlayerRecognizerRegistry& aRec)
+{
+    aNode.RemoveLoadableModules();
+    aRec.RemoveLoadableModules();
+
+    PVPlayerRegistryPopulator pop;
+    pop.UnregisterAllNodes(&aNode, aNode.iStaticPopulatorContext);
+    pop.UnregisterAllRecognizers(&aRec, aRec.iStaticPopulatorContext);
+}
+
+
+PVPlayerNodeRegistry::PVPlayerNodeRegistry()
+{
+    iType.reserve(20);
+    iLogger = PVLogger::GetLoggerObject("pvplayerengine.playernoderegistry");
+}
+
+
+PVPlayerNodeRegistry::~PVPlayerNodeRegistry()
+{
+    iType.clear();
+    iLogger = NULL;
+}
+
+void PVPlayerNodeRegistry::AddLoadableModules(const OSCL_String& aConfigFilePath)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::AddLoadableModules() IN"));
+#ifdef USE_LOADABLE_MODULES
+
+    OsclLibraryList libList;
+    libList.Populate(PV_NODE_REGISTRY_POPULATOR_INTERFACE, aConfigFilePath);
+
+    for (unsigned int i = 0; i < libList.Size(); i++)
+    {
+        OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
+        if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
+        {
+            OsclAny* interfacePtr = NULL;
+            OsclLibStatus result = lib->QueryInterface(PV_NODE_REGISTRY_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr);
+            if (result == OsclLibSuccess && interfacePtr != NULL)
+            {
+                struct PVPlayerEngineNodeSharedLibInfo *libInfo = (struct PVPlayerEngineNodeSharedLibInfo *)oscl_malloc(sizeof(struct PVPlayerEngineNodeSharedLibInfo));
+                if (NULL != libInfo)
+                {
+                    libInfo->iLib = lib;
+
+                    NodeRegistryPopulatorInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeRegistryPopulatorInterface*, interfacePtr);
+                    libInfo->iNodeLibIfacePtr = nodeIntPtr;
+                    nodeIntPtr->RegisterAllNodes(this,  libInfo->iContext);
+
+                    // save for depopulation later
+                    iNodeLibInfoList.push_front(libInfo);
+                    continue;
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerNodeRegistry::AddLoadableModules() QueryInterface() of PV_NODE_POPULATOR_INTERFACE for library %s failed.", libList.GetLibraryPathAt(i).get_cstr()));
+
+            }
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerNodeRegistry::AddLoadableModules() LoadLib() of library %s failed.", libList.GetLibraryPathAt(i).get_cstr()));
+        }
+        lib->Close();
+        OSCL_DELETE(lib);
+    }
+#else
+    OSCL_UNUSED_ARG(aConfigFilePath);
+#endif
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::AddLoadableModules() OUT"));
+}
+
+void PVPlayerNodeRegistry::RemoveLoadableModules()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::RemoveLoadableModules() IN"));
+#ifdef USE_LOADABLE_MODULES
+    // remove all dynamic nodes now
+    // unregister node one by one
+    while (!iNodeLibInfoList.empty())
+    {
+        struct PVPlayerEngineNodeSharedLibInfo *libInfo = iNodeLibInfoList.front();
+        iNodeLibInfoList.erase(iNodeLibInfoList.begin());
+
+        OsclSharedLibrary* lib = libInfo->iLib;
+        NodeRegistryPopulatorInterface* nodeIntPtr = libInfo->iNodeLibIfacePtr;
+        OsclAny* context = libInfo->iContext;
+        oscl_free(libInfo);
+
+        nodeIntPtr->UnregisterAllNodes(this, context);
+
+        lib->Close();
+        OSCL_DELETE(lib);
+    }
+#endif
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::RemoveLoadableModules() OUT"));
+}
+
+
+PVMFStatus PVPlayerNodeRegistry::QueryRegistry(PVMFFormatType& aInputType, PVMFFormatType& aOutputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::QueryRegistry() IN"));
+    uint32 SearchCount = 0;
+    bool matchfound = false;
+
+    // Find all nodes that support the specified input and ouput format pair
+    while (SearchCount < iType.size())
+    {
+        uint32 inputsearchcount = 0, outputsearchcount = 0;
+        bool iInputFoundFlag = false, iOutputFoundFlag = false;
+
+        while (inputsearchcount < iType[SearchCount].iInputTypes.size())
+        {
+            // Check if the input format matches
+            if (iType[SearchCount].iInputTypes[inputsearchcount] == aInputType)
+            {
+                // Set the the input flag to true since we found the match in the search
+                iInputFoundFlag = true;
+                break;
+            }
+            inputsearchcount++;
+        }
+
+        //Check the flag of input format if it is true check for the output format, if not return failure
+        if (iInputFoundFlag)
+        {
+            while (outputsearchcount < iType[SearchCount].iOutputType.size())
+            {
+                if (iType[SearchCount].iOutputType[outputsearchcount] == aOutputType)
+                {
+                    //set the the output flag to true since we found the match in the search
+                    iOutputFoundFlag = true;
+                    break;
+                }
+
+                outputsearchcount++;
+            }
+
+            if (iOutputFoundFlag)
+            {
+                // There's a match so add this node UUID to the list.
+                aUuids.push_back(iType[SearchCount].iNodeUUID);
+                matchfound = true;
+            }
+        }
+
+        SearchCount++;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::QueryRegistry() OUT"));
+    if (matchfound)
+    {
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+
+PVMFNodeInterface* PVPlayerNodeRegistry::CreateNode(PVUuid& aUuid)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::CreateNode() IN"));
+    bool iFoundFlag = false;
+    uint32 NodeSearchCount = 0;
+
+    while (NodeSearchCount < iType.size())
+    {
+        //Search if the UUID's will match
+        if (iType[NodeSearchCount].iNodeUUID == aUuid)
+        {
+            //Since the UUID's match set the flag to true
+            iFoundFlag = true;
+            break;
+        }
+
+        NodeSearchCount++;
+
+    }
+
+    if (iFoundFlag)
+    {
+        OsclActiveObject::OsclActivePriority priority = OsclActiveObject::EPriorityNominal;
+        PVPlayerNodeInfo* nodeInfo = &iType[NodeSearchCount];
+        PVMFNodeInterface* nodeInterface = NULL;
+
+#if VIDEO_DEC_NODE_LOW_PRIORITY
+        //Call the appropriate Node creation function & return Node pointer
+        if (KPVMFOMXVideoDecNodeUuid == aUuid)
+        {
+            priority = OsclActiveObject::EPriorityLow;
+        }
+#endif
+        if (NULL != nodeInfo->iNodeCreateFunc)
+        {
+            nodeInterface = (*(iType[NodeSearchCount].iNodeCreateFunc))(priority);
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::CreateNode() OUT"));
+        return nodeInterface;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::CreateNode() OUT"));
+        return NULL;
+    }
+
+
+}
+
+bool PVPlayerNodeRegistry::ReleaseNode(PVUuid& aUuid, PVMFNodeInterface* aNode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::ReleaseNode() IN"));
+    bool iFoundFlag = false;
+    uint32 NodeSearchCount = 0;
+
+    while (NodeSearchCount < iType.size())
+    {
+        //Search if the UUID's will match
+        if (iType[NodeSearchCount].iNodeUUID == aUuid)
+        {
+            //Since the UUID's match set the flag to true
+            iFoundFlag = true;
+            break;
+        }
+
+        NodeSearchCount++;
+
+    }
+
+    if (iFoundFlag)
+    {
+        //Call the appropriate Node release function
+        bool del_stat = (*(iType[NodeSearchCount].iNodeReleaseFunc))(aNode);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::ReleaseNode() OUT"));
+        return del_stat;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::ReleaseNode() OUT"));
+    return false;
+}
+
+
+PVPlayerRecognizerRegistry::PVPlayerRecognizerRegistry()
+        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerRecognizerRegistry")
+{
+    AddToScheduler();
+
+    iRecSessionId = 0;
+    iRecognizerResult.reserve(4);
+    iFileDataStreamFactory = NULL;
+    iDataStreamFactory = NULL;
+    iSourceFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+    iObserver = NULL;
+    iCmdContext = NULL;
+    iCancelQuery = false;
+    iCancelCmdContext = NULL;
+
+    if (PVMFRecognizerRegistry::Init() != PVMFSuccess)
+    {
+        OSCL_ASSERT(false);
+        return;
+    }
+
+    iLogger = PVLogger::GetLoggerObject("pvplayerengine.playerrecognizerregistry");
+}
+
+
+PVPlayerRecognizerRegistry::~PVPlayerRecognizerRegistry()
+{
+    if (iFileDataStreamFactory)
+    {
+        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
+        iFileDataStreamFactory = NULL;
+    }
+
+    PVMFRecognizerRegistry::Cleanup();
+    iLogger = NULL;
+}
+
+void PVPlayerRecognizerRegistry::AddLoadableModules(const OSCL_String& aConfigFilePath)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::AddLoadableModules() IN"));
+#ifdef USE_LOADABLE_MODULES
+    OsclLibraryList libList;
+    libList.Populate(PV_RECOGNIZER_POPULATOR_INTERFACE, aConfigFilePath);
+
+    for (unsigned int i = 0; i < libList.Size(); i++)
+    {
+        OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
+        if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
+        {
+            OsclAny* interfacePtr = NULL;
+            OsclLibStatus result = lib->QueryInterface(PV_RECOGNIZER_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr);
+            if (result == OsclLibSuccess && interfacePtr != NULL)
+            {
+                struct PVPlayerEngineRecognizerSharedLibInfo *libInfo = (struct PVPlayerEngineRecognizerSharedLibInfo *)oscl_malloc(sizeof(struct PVPlayerEngineRecognizerSharedLibInfo));
+                if (NULL != libInfo)
+                {
+                    libInfo->iLib = lib;
+
+                    RecognizerPopulatorInterface* recognizerIntPtr = OSCL_DYNAMIC_CAST(RecognizerPopulatorInterface*, interfacePtr);
+
+                    libInfo->iRecognizerLibIfacePtr = recognizerIntPtr;
+
+                    recognizerIntPtr->RegisterAllRecognizers(this, libInfo->iContext);
+
+                    // save for depopulation later
+                    iRecognizerLibInfoList.push_front(libInfo);
+                    continue;
+                }
+            }
+        }
+        lib->Close();
+        OSCL_DELETE(lib);
+    }
+#else
+    OSCL_UNUSED_ARG(aConfigFilePath);
+#endif
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::AddLoadableModules() OUT"));
+}
+
+void PVPlayerRecognizerRegistry::RemoveLoadableModules()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RemoveLoadableModules() IN"));
+#ifdef USE_LOADABLE_MODULES
+    // remove all the dynamic plugins now
+    // unregister the plugins one by one
+    while (!iRecognizerLibInfoList.empty())
+    {
+        struct PVPlayerEngineRecognizerSharedLibInfo *libInfo = iRecognizerLibInfoList.front();
+        iRecognizerLibInfoList.erase(iRecognizerLibInfoList.begin());
+
+        OsclSharedLibrary* lib = libInfo->iLib;
+        RecognizerPopulatorInterface* recognizerIntPtr = libInfo->iRecognizerLibIfacePtr;
+        OsclAny* context = libInfo->iContext;
+        oscl_free(libInfo);
+
+        recognizerIntPtr->UnregisterAllRecognizers(this, context);
+
+        lib->Close();
+        OSCL_DELETE(lib);
+    }
+#endif
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RemoveLoadableModules() OUT"));
+}
+
+PVMFStatus PVPlayerRecognizerRegistry::QueryFormatType(OSCL_wString& aSourceURL, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aCmdContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() IN"));
+    if (iObserver != NULL)
+    {
+        // Previous query still ongoing
+        return PVMFErrBusy;
+    }
+    iObserver = &aObserver;
+    iCmdContext = aCmdContext;
+
+    // Create a datastream wrapper factory for standard file
+    if (iFileDataStreamFactory)
+    {
+        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
+        iFileDataStreamFactory = NULL;
+    }
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, iFileDataStreamFactory = OSCL_STATIC_CAST(PVMFDataStreamFactory*, OSCL_NEW(PVMIDataStreamSyncInterfaceRefFactory, (aSourceURL))));
+    OSCL_FIRST_CATCH_ANY(leavecode,
+                         return PVMFErrNoMemory;
+                        );
+
+    // Open the session with recognizer
+    PVMFRecognizerRegistry::OpenSession(iRecSessionId, *this);
+
+    // Request file recognition
+    iRecognizerResult.clear();
+    iRecognizeCmdId = PVMFRecognizerRegistry::Recognize(iRecSessionId, *iFileDataStreamFactory, NULL, iRecognizerResult, NULL);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() OUT"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVPlayerRecognizerRegistry::QueryFormatType(PVMFCPMPluginAccessInterfaceFactory* aDataStreamFactory, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aCmdContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() IN"));
+    if (iObserver != NULL)
+    {
+        // Previous query still ongoing
+        return PVMFErrBusy;
+    }
+
+    if (aDataStreamFactory == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    iObserver = &aObserver;
+    iCmdContext = aCmdContext;
+
+    // delete the previous DataStreamFactory created by PVPlayerRecognizerRegistry
+    if (iFileDataStreamFactory)
+    {
+        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
+        iFileDataStreamFactory = NULL;
+    }
+
+    iDataStreamFactory = aDataStreamFactory;
+
+    // Open the session with recognizer
+    PVMFRecognizerRegistry::OpenSession(iRecSessionId, *this);
+
+    // Request file recognition
+    iRecognizerResult.clear();
+    iRecognizeCmdId = PVMFRecognizerRegistry::Recognize(iRecSessionId, *iDataStreamFactory, NULL, iRecognizerResult, NULL);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() OUT"));
+    return PVMFSuccess;
+}
+
+
+void PVPlayerRecognizerRegistry::CancelQuery(OsclAny* aContext)
+{
+    if (iObserver == NULL)
+    {
+        // No pending recognize request
+        OSCL_LEAVE(OsclErrInvalidState);
+        return;
+    }
+
+    iCancelQuery = true;
+    iCancelCmdContext = aContext;
+
+    if (!IsBusy())
+    {
+        // The recognition pending so cancel it
+        PVMFRecognizerRegistry::CancelCommand(iRecSessionId, iRecognizeCmdId);
+    }
+    // Else the recognition already completed so just cancel it in the Run()
+}
+
+
+void PVPlayerRecognizerRegistry::Run()
+{
+    // Close the session with recognizer
+    PVMFRecognizerRegistry::CloseSession(iRecSessionId);
+
+    // Destroy the data stream wrapper factory for standard file
+    if (iFileDataStreamFactory)
+    {
+        OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
+        iFileDataStreamFactory = NULL;
+    }
+
+    // Tell the engine the result
+    if (iObserver)
+    {
+        iObserver->RecognizeCompleted(iSourceFormatType, iCmdContext);
+
+        if (iCancelQuery)
+        {
+            iObserver->RecognizeCompleted(iSourceFormatType, iCancelCmdContext);
+            iCancelQuery = false;
+            iCancelCmdContext = NULL;
+        }
+    }
+    iObserver = NULL;
+    iCmdContext = NULL;
+}
+
+void PVPlayerRecognizerRegistry::RecognizerCommandCompleted(const PVMFCmdResp& aResponse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizerCommandCompleted() IN"));
+    iSourceFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+
+    if (aResponse.GetCmdId() == iRecognizeCmdId)
+    {
+        // Recognize() command completed
+        if (aResponse.GetCmdStatus() == PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizeCommandCompleted() - Recognize returned Success"));
+            Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>::iterator it;
+            for (it = iRecognizerResult.begin(); it != iRecognizerResult.end(); it++)
+            {
+                if (it->iRecognitionConfidence == PVMFRecognizerConfidenceCertain)
+                {   //@TODO: validate whether there are more than one claims Certain.
+                    iSourceFormatType = it->iRecognizedFormat.get_str();
+                    break;
+                }
+                if (it->iRecognitionConfidence == PVMFRecognizerConfidencePossible)
+                {
+                    iSourceFormatType = it->iRecognizedFormat.get_str();
+                }
+            }
+        }
+        else if (aResponse.GetCmdStatus() == PVMFErrCancelled)
+        {
+            // If cancelled, need to wait for the cancel command to complete before
+            // calling Run
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizerCommandCompleted() - Recognize returned Cancelled - OUT"));
+            return;
+        }
+    }
+
+    RunIfNotReady();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizerCommandCompleted() OUT"));
+}
+
+
+
+
+
diff --git a/engines/player/src/pv_player_node_registry.h b/engines/player/src/pv_player_node_registry.h
index 7370453..fd5c65b 100644
--- a/engines/player/src/pv_player_node_registry.h
+++ b/engines/player/src/pv_player_node_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,12 +58,29 @@
 #include "pv_player_node_registry_interface.h"
 #endif
 
-#ifdef HAS_OSCL_LIB_SUPPORT
 #ifndef PVMF_RECOGNIZER_REGISTRY_H_INCLUDED
 #include "pvmf_recognizer_registry.h"
 #endif
+
+#ifndef PV_PLAYER_CONFIG_H_INCLUDED
+#include "pv_player_config.h"
 #endif
 
+#ifndef PV_LOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef USE_CML2_CONFIG
+#ifndef PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
+#include "pv_player_engine_tunables.h"
+#endif
+#endif
+
+class OsclSharedLibrary;
+class NodeRegistryPopulatorInterface;
+class RecognizerPopulatorInterface;
+
+
 // CLASS DECLARATION
 /**
  * PVPlayerNodeRegistry maintains a list of nodes available which is queryable.
@@ -77,6 +94,9 @@
          **/
         PVPlayerNodeRegistry();
 
+        void AddLoadableModules(const OSCL_String&);
+        void RemoveLoadableModules();
+
         /**
          * The QueryRegistry for PVPlayerNodeRegistry. Used mainly for Seaching of the UUID
          * whether it is available or not & returns Success if it is found else failure.
@@ -111,7 +131,6 @@
          **/
         virtual bool ReleaseNode(PVUuid& aUuid, PVMFNodeInterface *aNode);
 
-#ifdef HAS_OSCL_LIB_SUPPORT
         /**
          * The RegisterNode for PVPlayerNodeRegistry. Used for registering nodes through the NodeInfo object.
          *
@@ -134,32 +153,33 @@
             OSCL_UNUSED_ARG(aNodeInfo);
             // do nothing
         };
-#else
-        /**
-         * The RegisterNode for PVPlayerNodeRegistry. Used for registering nodes through the NodeInfo object.
-         *
-         * @param aNodeInfo NodeInfo object passed to the regisry class. This contains all nodes that need to be registered.
-         *
-         **/
-        virtual void RegisterNode(const PVPlayerNodeInfo& aNodeInfo) {};
-
-        /**
-         * The PopulateRegistry for PVPlayerNodeRegistry. Populates the registry by retrieving all the information for node.
-         * @param aConfigFilePath File path for the Configuration file which stores the mapping
-         *  between OsclUuids and SharedLibrary path names
-         *
-         **/
-        virtual void PopulateRegistry(const OSCL_String& aConfigFilePath) {};
-#endif
 
         /**
          * Object destructor function
          **/
         virtual ~PVPlayerNodeRegistry();
 
+
     private:
+        /*
+        ** The node list.
+        */
         Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> iType;
 
+        OsclAny* iStaticPopulatorContext;
+        friend class PVPlayerRegistryPopulator;
+
+        /*
+        ** Bookkeeping data for dynamically loaded nodes.
+        */
+        struct PVPlayerEngineNodeSharedLibInfo
+        {
+            OsclSharedLibrary* iLib;
+            NodeRegistryPopulatorInterface* iNodeLibIfacePtr;
+            OsclAny* iContext;
+        };
+        Oscl_Vector<struct PVPlayerEngineNodeSharedLibInfo*, OsclMemAllocator> iNodeLibInfoList;
+        PVLogger* iLogger;
 };
 
 
@@ -179,14 +199,15 @@
  **/
 class PVPlayerRecognizerRegistry : public OsclTimerObject,
             public PVMFRecognizerCommmandHandler
-#ifdef HAS_OSCL_LIB_SUPPORT
             , public PVPlayerRecognizerRegistryInterface
-#endif
 {
     public:
         PVPlayerRecognizerRegistry();
         virtual ~PVPlayerRecognizerRegistry();
 
+        void AddLoadableModules(const OSCL_String&);
+        void RemoveLoadableModules();
+
         /**
          * Determines the format type of the specified source file using the PVMF recognizer
          *
@@ -199,6 +220,17 @@
         PVMFStatus QueryFormatType(OSCL_wString& aSourceURL, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aContext = NULL);
 
         /**
+         * Determines the format type of the specified source file using the PVMF recognizer
+         *
+         * @param aDataStreamFactory The factory to create source data stream to determine the format
+         * @param aObserver The callback handler to call when recognize operation completes
+         * @param aContext Optional opaque data that would be returned in callback
+         *
+         * @returns Status of query
+         **/
+        PVMFStatus QueryFormatType(PVMFCPMPluginAccessInterfaceFactory* aDataStreamFactory, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aContext = NULL);
+
+        /**
          * Cancels any pending format type query
          *
          * @param aContext Optional opaque data that would be returned in callback
@@ -206,7 +238,7 @@
          * @returns None
          **/
         void CancelQuery(OsclAny* aContext = NULL);
-#ifdef HAS_OSCL_LIB_SUPPORT
+
         /**
          * The RegisterRecognizer for PVPlayerRecognizerRegistryInterface. Used for registering file format recognizer factory plugins.
          *
@@ -238,9 +270,6 @@
                 }
             }
         }
-#endif
-
-
 
     private:
         // From OsclTimerObject
@@ -249,19 +278,73 @@
         // From PVMFRecognizerCommmandHandler
         void RecognizerCommandCompleted(const PVMFCmdResp& aResponse);
 
+        /*
+        ** The Recognizer list
+        */
         Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator> iRecognizerList;
 
         PVMFSessionId iRecSessionId;
         Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator> iRecognizerResult;
         PVMFCPMPluginAccessInterfaceFactory* iFileDataStreamFactory;
+        PVMFCPMPluginAccessInterfaceFactory* iDataStreamFactory;
+
         PVMFFormatType iSourceFormatType;
         PVPlayerRecognizerRegistryObserver* iObserver;
         OsclAny* iCmdContext;
         PVMFCommandId iRecognizeCmdId;
         bool iCancelQuery;
         OsclAny* iCancelCmdContext;
+
+        OsclAny* iStaticPopulatorContext;
+        friend class PVPlayerRegistryPopulator;
+
+        /*
+        ** Bookkeeping data for dynamically loaded recognizers.
+        */
+        struct PVPlayerEngineRecognizerSharedLibInfo
+        {
+            OsclSharedLibrary* iLib;
+            RecognizerPopulatorInterface* iRecognizerLibIfacePtr;
+            OsclAny* iContext;
+        };
+        Oscl_Vector<struct PVPlayerEngineRecognizerSharedLibInfo*, OsclMemAllocator> iRecognizerLibInfoList;
+        PVLogger* iLogger;
 };
 
+/*
+** PVPlayerRegistryPopulator is used by Player engine to populate & de-populate
+** the registries.
+*/
+class PVPlayerRegistryPopulator: public NodeRegistryPopulatorInterface
+            , public RecognizerPopulatorInterface
+{
+    public:
+        /*
+        ** Populate both registries from static and loadable modules
+        */
+        static void Populate(PVPlayerNodeRegistry&, PVPlayerRecognizerRegistry&);
+
+        /*
+        ** Depopulate both registries.
+        */
+        static void Depopulate(PVPlayerNodeRegistry&, PVPlayerRecognizerRegistry&);
+
+    private:
+        /*
+        ** These routines are implemented in the project-specific player config.
+        ** They would normally populate using statically linked modules.
+        */
+
+        //from NodeRegistryPopulatorInterface
+        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext) ;
+        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext) ;
+
+        //from RecognizerPopulatorInterface
+        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext) ;
+        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext) ;
+};
+
+
 #endif // PV_PLAYER_NODE_REGISTRY_H_INCLUDED
 
 
diff --git a/engines/player/src/pv_player_sdkinfo.h b/engines/player/src/pv_player_sdkinfo.h
index 71f385e..ae60498 100644
--- a/engines/player/src/pv_player_sdkinfo.h
+++ b/engines/player/src/pv_player_sdkinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,10 @@
 #ifndef PV_PLAYER_SDKINFO_H_INCLUDED
 #define PV_PLAYER_SDKINFO_H_INCLUDED
 
-// This header file provides defines for PLAYER's SDK info's release label and release date
+// This header file is automatically generated at build-time
+// *** OFFICIAL RELEASE INFO -- Will not auto update
 
-#define PVPLAYER_ENGINE_SDKINFO_LABEL "PVCore/05.02.00.00 PVPlayer/6.18 (Linux; Android; NJ)"
-#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20080729
+#define PVPLAYER_ENGINE_SDKINFO_LABEL "PVDEV_CORE_RELEASE_6.101.1.1"
+#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20090121
 
-#endif //PV_PLAYER_SDKINFO_H_INCLUDED 
+#endif //PV_PLAYER_SDKINFO_H_INCLUDED
diff --git a/engines/player/test/Android.mk b/engines/player/test/Android.mk
index 6f69a05..1df7041 100644
--- a/engines/player/test/Android.mk
+++ b/engines/player/test/Android.mk
@@ -3,56 +3,47 @@
 
 LOCAL_SRC_FILES := \
 	src/test_pv_player_engine.cpp \
-	src/test_pv_player_engine_testset_mio_file.cpp \
-	src/test_pv_player_engine_testset1.cpp \
-	src/test_pv_player_engine_testset5.cpp \
-	src/test_pv_player_engine_testset6.cpp \
-	src/test_pv_player_engine_testset7.cpp \
-	src/test_pv_player_engine_testset8.cpp \
-	src/test_pv_player_engine_testset9.cpp \
-	src/test_pv_player_engine_testset10.cpp \
-	src/test_pv_player_engine_testset11.cpp \
-	src/test_pv_player_engine_testset12.cpp \
-	src/test_pv_player_engine_testset13.cpp \
-	src/test_pv_player_engine_testset_cpmdlapassthru.cpp
-
-
-LOCAL_SHARED_LIBRARIES := libopencorecommon libopencoreplayer
-
-LOCAL_STATIC_LIBRARIES := libunit_test
+ 	src/test_pv_player_engine_testset_mio_file.cpp \
+ 	src/test_pv_player_engine_testset1.cpp \
+ 	src/test_pv_player_engine_testset5.cpp \
+ 	src/test_pv_player_engine_testset6.cpp \
+ 	src/test_pv_player_engine_testset7.cpp \
+ 	src/test_pv_player_engine_testset8.cpp \
+ 	src/test_pv_player_engine_testset9.cpp \
+ 	src/test_pv_player_engine_testset10.cpp \
+ 	src/test_pv_player_engine_testset11.cpp \
+ 	src/test_pv_player_engine_testset12.cpp \
+ 	src/test_pv_player_engine_testset13.cpp \
+ 	src/test_pv_player_engine_testset_cpmdlapassthru.cpp
 
 
 LOCAL_MODULE := pvplayer_engine_test
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS := -DBUILD_OMX_DEC_NODE $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := libunit_test  
+
+LOCAL_SHARED_LIBRARIES :=  libopencore_player libopencore_common
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//engines/player/test/src \
-	$(PV_TOP)//engines/player/test/src \
-	$(PV_TOP)//engines/player/test/../../common/include \
-	$(PV_TOP)//engines/player/test/../../../pvmi/media_io/pvmiofileoutput/include \
-	$(PV_TOP)//engines/player/test/../../../nodes/pvmediaoutputnode/include \
-	$(PV_TOP)//engines/player/test/../include \
-	$(PV_TOP)//engines/player/test/../../../nodes/common/include \
-	$(PV_TOP)//engines/player/test/../../../extern_libs_v2/khronos/openmax/include \
-	$(PV_INCLUDES) 
-
-ifeq ($(TARGET_ARCH),arm)
-   LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/test/config/linux_nj
-else
-   LOCAL_C_INCLUDES += $(PV_TOP)//engines/player/test/config/linux_nj
-endif
+	$(PV_TOP)/engines/player/test/src \
+ 	$(PV_TOP)/engines/player/test/src \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_TOP)/pvmi/media_io/pvmiofileoutput/include \
+ 	$(PV_TOP)/nodes/pvmediaoutputnode/include \
+ 	$(PV_TOP)/engines/player/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/engines/player/test/config/linux_nj \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
 
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
+LOCAL_COPY_HEADERS := \
+ 	
+
+-include $(PV_TOP)/Android_system_extras.mk
 
 include $(BUILD_EXECUTABLE)
-
diff --git a/engines/player/test/build/linux_nj/local.mk b/engines/player/test/build/linux_nj/local.mk
new file mode 100644
index 0000000..8b752bb
--- /dev/null
+++ b/engines/player/test/build/linux_nj/local.mk
@@ -0,0 +1,59 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvplayer_engine_test
+
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+XCPPFLAGS += -DBUILD_OMX_DEC_NODE 
+
+
+XINCDIRS +=  ../../../../common/include  ../../../../../pvmi/media_io/pvmiofileoutput/include  ../../../../../nodes/pvmediaoutputnode/include  ../../../include  ../../../../../nodes/common/include  ../../../../../extern_libs_v2/khronos/openmax/include
+
+# This makefile is used by opencore config. So, only the linux_nj configuration is required
+XINCDIRS +=  ../../config/linux_nj
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := test_pv_player_engine.cpp \
+        test_pv_player_engine_testset_mio_file.cpp \
+        test_pv_player_engine_testset1.cpp \
+        test_pv_player_engine_testset5.cpp \
+        test_pv_player_engine_testset6.cpp \
+        test_pv_player_engine_testset7.cpp \
+        test_pv_player_engine_testset8.cpp \
+        test_pv_player_engine_testset9.cpp \
+        test_pv_player_engine_testset10.cpp \
+        test_pv_player_engine_testset11.cpp \
+        test_pv_player_engine_testset12.cpp \
+        test_pv_player_engine_testset13.cpp \
+        test_pv_player_engine_testset_cpmdlapassthru.cpp
+
+
+LIBS := unit_test opencore_player opencore_common
+
+ifneq ($(ARCHITECTURE),win32)
+  SYSLIBS = -lpthread -ldl
+endif
+
+include $(MK)/prog.mk
+
+PE_TEST_DIR = ${BUILD_ROOT}/pe_test
+PE_TARGET = pvplayer_engine_test
+
+run_pe_test:: $(REALTARGET) default
+	$(quiet) ${RM} -r ${PE_TEST_DIR}
+	$(quiet) ${MKDIR} ${PE_TEST_DIR}
+	$(quiet) $(CP) $(SRC_ROOT)/tools_v2/build/package/opencore/pvplayer.cfg $(PE_TEST_DIR)
+	$(quiet) $(CP) -r $(SRC_ROOT)/engines/player/test/data/* $(PE_TEST_DIR)
+	$(quiet) export LD_LIBRARY_PATH=${BUILD_ROOT}/installed_lib/${HOST_ARCH}; cd $(PE_TEST_DIR) && ${BUILD_ROOT}/bin/${HOST_ARCH}/$(PE_TARGET) $(TEST_ARGS) $(SOURCE_ARGS)
diff --git a/engines/player/test/build/linux_nj/makefile b/engines/player/test/build/linux_nj/makefile
deleted file mode 100644
index b129ca4..0000000
--- a/engines/player/test/build/linux_nj/makefile
+++ /dev/null
@@ -1,85 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = prog
-TARGET = pvplayer_engine_test
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-XCXXFLAGS += -DBUILD_OMX_DEC_NODE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# include the common engine header files in the search path
-XINCDIRS += -I ../../../../common/include -I ../../../../../pvmi/media_io/pvmiofileoutput/include -I ../../../../../nodes/pvmediaoutputnode/include -I ../../../include -I ../../../../../nodes/common/include -I ../../../../../extern_libs_v2/khronos/openmax/include
-
-ifeq ($(ARCHITECTURE),linux_arm)
-   XINCDIRS += -I ../../config/$(BUILD_ARCH)
-else
-   XINCDIRS += -I ../../config/linux_nj
-endif
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-#XLDFLAGS +=
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =  test_pv_player_engine.cpp \
-    test_pv_player_engine_testset_mio_file.cpp \
-        test_pv_player_engine_testset1.cpp \
-        test_pv_player_engine_testset5.cpp \
-        test_pv_player_engine_testset6.cpp \
-        test_pv_player_engine_testset7.cpp \
-        test_pv_player_engine_testset8.cpp \
-        test_pv_player_engine_testset9.cpp \
-        test_pv_player_engine_testset10.cpp \
-        test_pv_player_engine_testset11.cpp \
-        test_pv_player_engine_testset12.cpp \
-        test_pv_player_engine_testset13.cpp \
-	test_pv_player_engine_testset_cpmdlapassthru.cpp
-
-# Need to use the _mod versions because the project is built with the LIBTARGET=module-rel option
-LIBS = -lunit_test_mod -lpvcommon -lpvplayer
-
-#MODS = -lpvcommon -lpvplayer
-
-#XLDFLAGS += -lpvcommon_debug -lpvplayer_debug
-
-SYSLIBS = -lpthread -ldl
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/engines/player/test/config/linux_nj/test_pv_player_engine_config.h b/engines/player/test/config/linux_nj/test_pv_player_engine_config.h
index 023fe03..d0d13f9 100644
--- a/engines/player/test/config/linux_nj/test_pv_player_engine_config.h
+++ b/engines/player/test/config/linux_nj/test_pv_player_engine_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,86 +21,87 @@
 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED
 #include "pvmf_format_type.h"
 #endif
-#define AUDIOSINK_FORMAT_TYPE PVMF_PCM16
+#define AUDIOSINK_FORMAT_TYPE PVMF_MIME_PCM16
 
 // The default test file to use
 #define DEFAULTSOURCEFILENAME "test.mp4"
-#define DEFAULTSOURCEFORMATTYPE PVMF_MPEG4FF
-
-// The string to prepend to source filenames
-#define SOURCENAME_PREPEND_STRING ""
-#define SOURCENAME_PREPEND_WSTRING _STRLIT_WCHAR("")
+#define DEFAULTSOURCEFORMATTYPE PVMF_MIME_MPEG4FF
 
 // Set to 1 to enable MP4 file test cases, 0 to disable
 #define RUN_MP4FILE_TESTCASES 1
 // MP4 files to test. Needs to be defined if RUN_MP4FILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_MP4_FORMAT_TYPE PVMF_MPEG4FF
-#define LOCAL_TEST_FILE_MP4_M4V_AMR 		"test_m4v_amr.mp4"
-#define LOCAL_TEST_FILE_MP4_H263_AMR 		"test_h263_amr.mp4"
-#define LOCAL_TEST_FILE_MP4_AVC_AMR 		"test_avc_amr.mp4"
-#define LOCAL_TEST_FILE_MP4_AMR 		"test_amr.mp4"
-#define LOCAL_TEST_FILE_MP4_AAC 		"test_aac.mp4"
-#define LOCAL_TEST_FILE_MP4_M4V_AMR_TEXT 	"test_m4v_amr_text.mp4"
+#define LOCAL_TEST_FILE_MP4_FORMAT_TYPE PVMF_MIME_MPEG4FF
+#define LOCAL_TEST_FILE_MP4_M4V_AMR "test_m4v_amr.mp4"
+#define LOCAL_TEST_FILE_MP4_H263_AMR "test_h263_amr.mp4"
+#define LOCAL_TEST_FILE_MP4_AVC_AMR "test_avc_amr.mp4"
+#define LOCAL_TEST_FILE_MP4_AMR "test_amr.mp4"
+#define LOCAL_TEST_FILE_MP4_AAC "test_aac.mp4"
+#define LOCAL_TEST_FILE_MP4_M4V_AMR_TEXT "test_m4v_amr_text.mp4"
 
 // Set to 1 to enable AMR file test cases, 0 to disable
 #define RUN_AMRFILE_TESTCASES 1
 // AMR files to test. Needs to be defined if RUN_AMRFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_AMR_FORMAT_TYPE PVMF_AMRFF
-#define LOCAL_TEST_FILE_AMR_IETF 		"test_amr_ietf.amr"
-#define LOCAL_TEST_FILE_AMR_IF2 		"test_amr_if2.cod"
+#define LOCAL_TEST_FILE_AMR_FORMAT_TYPE PVMF_MIME_AMRFF
+#define LOCAL_TEST_FILE_AMR_IETF "test_amr_ietf.amr"
+#define LOCAL_TEST_FILE_AMR_IF2 "test_amr_if2.cod"
 
 // Set to 1 to enable AAC file test cases, 0 to disable
 #define RUN_AACFILE_TESTCASES 1
 // AAC files to test. Needs to be defined if RUN_AACFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_AAC_FORMAT_TYPE PVMF_AACFF
-#define LOCAL_TEST_FILE_AAC_ADTS 		"test_adts.aac"
-#define LOCAL_TEST_FILE_AAC_ADIF 		"test_adif.aac"
-#define LOCAL_TEST_FILE_AAC_RAW 		"test_raw.aac"
+#define LOCAL_TEST_FILE_AAC_FORMAT_TYPE PVMF_MIME_AACFF
+#define LOCAL_TEST_FILE_AAC_ADTS "test_adts.aac"
+#define LOCAL_TEST_FILE_AAC_ADIF "test_adif.aac"
+#define LOCAL_TEST_FILE_AAC_RAW "test_raw.aac"
 
 // Set to 1 to enable MP3 file test cases, 0 to disable
 #define RUN_MP3FILE_TESTCASES 1
 // MP3 files to test. Needs to be defined if RUN_MP3FILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_MP3_FORMAT_TYPE PVMF_MP3FF
-#define LOCAL_TEST_FILE_MP3_CBR 		"test_cbr.mp3"
-#define LOCAL_TEST_FILE_MP3_VBR 		"test_vbr.mp3"
+#define LOCAL_TEST_FILE_MP3_FORMAT_TYPE PVMF_MIME_MP3FF
+#define LOCAL_TEST_FILE_MP3_CBR "test_cbr.mp3"
+#define LOCAL_TEST_FILE_MP3_VBR "test_vbr.mp3"
 
 // Set to 1 to enable 3GP file test cases, 0 to disable
 #define RUN_3GPFILE_TESTCASES 1
 // 3GP files to test. Needs to be defined if RUN_3GPFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_3GP_FORMAT_TYPE PVMF_MPEG4FF
-#define LOCAL_TEST_FILE_3GP 			"test.3gp"
+#define LOCAL_TEST_FILE_3GP_FORMAT_TYPE PVMF_MIME_MPEG4FF
+#define LOCAL_TEST_FILE_3GP "test.3gp"
 
 // Set to 1 to enable WMA file test cases, 0 to disable
 #define RUN_WMAFILE_TESTCASES 1
 // WMA files to test. Needs to be defined if RUN_WMAFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_WMA_FORMAT_TYPE PVMF_ASFFF
-#define LOCAL_TEST_FILE_WMA 			"00000035.wma"
+#define LOCAL_TEST_FILE_WMA_FORMAT_TYPE PVMF_MIME_ASFFF
+#define LOCAL_TEST_FILE_WMA "00000035.wma"
 
 // Set to 1 to enable WMV file test cases, 0 to disable
 #define RUN_WMVFILE_TESTCASES 1
 // WMV files to test. Needs to be defined if RUN_WMVFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_WMV_FORMAT_TYPE PVMF_ASFFF
-#define LOCAL_TEST_FILE_WMV 			"bad_video_config.wmv"
+#define LOCAL_TEST_FILE_WMV_FORMAT_TYPE PVMF_MIME_ASFFF
+#define LOCAL_TEST_FILE_WMV "bad_video_config.wmv"
 
 // Set to 1 to enable WAV file test cases, 0 to disable
 #define RUN_WAVFILE_TESTCASES 1
 // WAV files to test. Needs to be defined if RUN_WAVFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_WAV_FORMAT_TYPE PVMF_WAVFF
-#define LOCAL_TEST_FILE_WAV 			"test.wav"
+#define LOCAL_TEST_FILE_WAV_FORMAT_TYPE PVMF_MIME_WAVFF
+#define LOCAL_TEST_FILE_WAV "test.wav"
 
 // Set to 1 to enable ASF file test cases, 0 to disable
-#define RUN_ASFFILE_TESTCASES 1
+#define RUN_ASFFILE_TESTCASES 0
 // ASF files to test. Needs to be defined if RUN_ASFFILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_ASF_FORMAT_TYPE PVMF_ASFFF
-#define LOCAL_TEST_FILE_ASF 			"test.asf"
+#define LOCAL_TEST_FILE_ASF_FORMAT_TYPE PVMF_MIME_ASFFF
+#define LOCAL_TEST_FILE_ASF "test.asf"
 
-// Set to 1 to enable rtps cloaking test cases, 0 to disable
+// Set to 1 to enable rtsp cloaking test cases, 0 to disable
 #define RUN_RTSP_CLOAKING_TESTCASES 0
+
 // Set to 1 to enable Real audio file test cases, 0 to disable
 #define RUN_REALAUDIO_FILE_TESTCASES 0
+
 // Real audio files to test. Needs to be defined if RUN_REALAUDIO_FILE_TESTCASES is set to 1
-#define LOCAL_TEST_FILE_REALAUDIO_FORMAT_TYPE PVMF_RMFF
-#define LOCAL_TEST_FILE_REALAUDIO 		"22sec_cook10_stereo.rm"
+#define LOCAL_TEST_FILE_REALAUDIO_FORMAT_TYPE PVMF_MIME_RMFF
+#define LOCAL_TEST_FILE_REALAUDIO "22sec_cook10_stereo.rm"
+
+// Set to 1 to enable FastTrack download test cases, 0 to disable
+#define RUN_FASTTRACK_TESTCASES 0
 
 // Set to 1 to enable HTTP download test cases, 0 to disable
 #define RUN_HTTPDOWNLOAD_TESTCASES 1
@@ -125,10 +126,18 @@
 // Set to 1 to use the scheduler native to the system instead of PV scheduler
 #define USE_NATIVE_SCHEDULER 0
 
+// The string to prepend to source filenames
+#define SOURCENAME_PREPEND_STRING ""
+#define SOURCENAME_PREPEND_WSTRING _STRLIT_WCHAR("")
 
 // The string to prepend to output filenames
+#ifdef ANDROID
+#define OUTPUTNAME_PREPEND_STRING "/sdcard/"
+#define OUTPUTNAME_PREPEND_WSTRING _STRLIT_WCHAR("/sdcard/")
+#else
 #define OUTPUTNAME_PREPEND_STRING ""
 #define OUTPUTNAME_PREPEND_WSTRING _STRLIT_WCHAR("")
+#endif
 
 //Local playback range
 #define FIRST_LOCAL_PLAYBACK 0
diff --git a/engines/player/test/data/pv_amr_mpeg4.sdp b/engines/player/test/data/pv_amr_mpeg4.sdp
new file mode 100644
index 0000000..88a8075
--- /dev/null
+++ b/engines/player/test/data/pv_amr_mpeg4.sdp
@@ -0,0 +1,41 @@
+v=0
+o=- 3440279905 2098834555 IN IP4 63.241.31.174
+s=Untitled
+e=support@localhost
+c=IN IP4 63.241.31.174
+t=0 0
+a=creation_date:20020619T212557.860Z
+a=range:npt=0-37.440
+a=X-wmfversion:1.2
+a=X-allowrecord
+a=control:rtsp://pvserveroha.pv.com:554/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp?ud=pvns_user_defined_string
+a=content_version:3.0
+a=video_only_allowed:true
+a=etag:3560F3940CF94D22B93E1C151B6386DF
+m=video 0 RTP/AVP 96
+b=TIAS:20250
+b=AS:23
+b=RR:575
+b=RS:575
+a=control:rtsp://pvserveroha.pv.com:554/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp/trackID=3?ud=pvns_user_defined_string
+a=maxprate:4.0
+a=rtpmap:96 MP4V-ES/1000
+a=range:npt=0-37.600
+a=fmtp:96 profile-level-id=8;config=000001b008000001b5090000010000000120008440fa282c2090a31f;framesize=176-144;decode_buf=9510
+a=framerate:2.5
+a=I_frame_interval:10
+a=X-allowrecord
+a=content_version:3.0
+m=audio 0 RTP/AVP 97
+b=TIAS:4750
+b=AS:10
+b=RR:250
+b=RS:250
+a=control:rtsp://pvserveroha.pv.com:554/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp/trackID=4?ud=pvns_user_defined_string
+a=maxprate:10.0
+a=rtpmap:97 AMR/8000
+a=range:npt=0-37.440
+a=fmtp:97 mode-set=0;octet-align=1;decode_buf=32
+a=maxptime:200
+a=X-allowrecord
+a=content_version:4.0
diff --git a/engines/player/test/data/test.mp4 b/engines/player/test/data/test.mp4
new file mode 100644
index 0000000..0879b06
--- /dev/null
+++ b/engines/player/test/data/test.mp4
Binary files differ
diff --git a/engines/player/test/data/test.wav b/engines/player/test/data/test.wav
new file mode 100644
index 0000000..db06005
--- /dev/null
+++ b/engines/player/test/data/test.wav
Binary files differ
diff --git a/engines/player/test/data/test_1220amr.mp4 b/engines/player/test/data/test_1220amr.mp4
new file mode 100644
index 0000000..dd7072f
--- /dev/null
+++ b/engines/player/test/data/test_1220amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_12fps.mp4 b/engines/player/test/data/test_12fps.mp4
new file mode 100644
index 0000000..ac1b649
--- /dev/null
+++ b/engines/player/test/data/test_12fps.mp4
Binary files differ
diff --git a/engines/player/test/data/test_24fps.mp4 b/engines/player/test/data/test_24fps.mp4
new file mode 100644
index 0000000..c0f45fe
--- /dev/null
+++ b/engines/player/test/data/test_24fps.mp4
Binary files differ
diff --git a/engines/player/test/data/test_475amr.mp4 b/engines/player/test/data/test_475amr.mp4
new file mode 100644
index 0000000..a314413
--- /dev/null
+++ b/engines/player/test/data/test_475amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_670amr.mp4 b/engines/player/test/data/test_670amr.mp4
new file mode 100644
index 0000000..475c0bf
--- /dev/null
+++ b/engines/player/test/data/test_670amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_6fps.mp4 b/engines/player/test/data/test_6fps.mp4
new file mode 100644
index 0000000..51d25e7
--- /dev/null
+++ b/engines/player/test/data/test_6fps.mp4
Binary files differ
diff --git a/engines/player/test/data/test_8fps.mp4 b/engines/player/test/data/test_8fps.mp4
new file mode 100644
index 0000000..8080256
--- /dev/null
+++ b/engines/player/test/data/test_8fps.mp4
Binary files differ
diff --git a/engines/player/test/data/test_aac.mp4 b/engines/player/test/data/test_aac.mp4
new file mode 100644
index 0000000..f022a81
--- /dev/null
+++ b/engines/player/test/data/test_aac.mp4
Binary files differ
diff --git a/engines/player/test/data/test_adif.aac b/engines/player/test/data/test_adif.aac
new file mode 100644
index 0000000..9bfddb6
--- /dev/null
+++ b/engines/player/test/data/test_adif.aac
Binary files differ
diff --git a/engines/player/test/data/test_adts.aac b/engines/player/test/data/test_adts.aac
new file mode 100644
index 0000000..18a37a2
--- /dev/null
+++ b/engines/player/test/data/test_adts.aac
Binary files differ
diff --git a/engines/player/test/data/test_amr.mp4 b/engines/player/test/data/test_amr.mp4
new file mode 100644
index 0000000..fcdefb7
--- /dev/null
+++ b/engines/player/test/data/test_amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_amr_ietf.amr b/engines/player/test/data/test_amr_ietf.amr
new file mode 100644
index 0000000..540794c
--- /dev/null
+++ b/engines/player/test/data/test_amr_ietf.amr
Binary files differ
diff --git a/engines/player/test/data/test_amr_if2.cod b/engines/player/test/data/test_amr_if2.cod
new file mode 100644
index 0000000..8519872
--- /dev/null
+++ b/engines/player/test/data/test_amr_if2.cod
Binary files differ
diff --git a/engines/player/test/data/test_avc_amr.mp4 b/engines/player/test/data/test_avc_amr.mp4
new file mode 100644
index 0000000..283f13d
--- /dev/null
+++ b/engines/player/test/data/test_avc_amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_cbr.mp3 b/engines/player/test/data/test_cbr.mp3
new file mode 100644
index 0000000..7204d27
--- /dev/null
+++ b/engines/player/test/data/test_cbr.mp3
Binary files differ
diff --git a/engines/player/test/data/test_h263_amr.mp4 b/engines/player/test/data/test_h263_amr.mp4
new file mode 100644
index 0000000..ef30fed
--- /dev/null
+++ b/engines/player/test/data/test_h263_amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_m4v_amr.mp4 b/engines/player/test/data/test_m4v_amr.mp4
new file mode 100644
index 0000000..c0f45fe
--- /dev/null
+++ b/engines/player/test/data/test_m4v_amr.mp4
Binary files differ
diff --git a/engines/player/test/data/test_m4v_amr_text.mp4 b/engines/player/test/data/test_m4v_amr_text.mp4
new file mode 100644
index 0000000..59885b8
--- /dev/null
+++ b/engines/player/test/data/test_m4v_amr_text.mp4
Binary files differ
diff --git a/engines/player/test/data/test_metadata.mp4 b/engines/player/test/data/test_metadata.mp4
new file mode 100644
index 0000000..3f8f111
--- /dev/null
+++ b/engines/player/test/data/test_metadata.mp4
Binary files differ
diff --git a/engines/player/test/data/test_raw.aac b/engines/player/test/data/test_raw.aac
new file mode 100644
index 0000000..f40c15b
--- /dev/null
+++ b/engines/player/test/data/test_raw.aac
Binary files differ
diff --git a/engines/player/test/data/test_reposition.mp4 b/engines/player/test/data/test_reposition.mp4
new file mode 100644
index 0000000..1ecf315
--- /dev/null
+++ b/engines/player/test/data/test_reposition.mp4
Binary files differ
diff --git a/engines/player/test/data/test_vbr.mp3 b/engines/player/test/data/test_vbr.mp3
new file mode 100644
index 0000000..96b82c5
--- /dev/null
+++ b/engines/player/test/data/test_vbr.mp3
Binary files differ
diff --git a/engines/player/test/src/test_pv_player_engine.cpp b/engines/player/test/src/test_pv_player_engine.cpp
index 36bd2cb..2f47256 100644
--- a/engines/player/test/src/test_pv_player_engine.cpp
+++ b/engines/player/test/src/test_pv_player_engine.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,13 +31,18 @@
 #include "test_pv_player_engine_testset8.h"
 #endif
 
-#if RUN_HTTPDOWNLOAD_TESTCASES
+#if (RUN_HTTPDOWNLOAD_TESTCASES || RUN_FASTTRACK_TESTCASES)
 #ifndef TEST_PV_PLAYER_ENGINE_TESTSET5_H_INCLUDED
 #include "test_pv_player_engine_testset5.h"
 #endif
 #endif
 
 #if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+#ifndef TEST_PV_PLAYER_ENGINE_TESTSET3_H_INCLUDED
+#include "test_pv_player_engine_testset3.h"
+#endif
+#endif
 #ifndef TEST_PV_PLAYER_ENGINE_TESTSET6_H_INCLUDED
 #include "test_pv_player_engine_testset6.h"
 #endif
@@ -99,10 +104,6 @@
 #include "oscl_error.h"
 #endif
 
-#ifndef OSCL_ERROR_PANIC_H_INCLUDED
-#include "oscl_error_panic.h"
-#endif
-
 #ifndef OSCL_SCHEDULER_H_INCLUDED
 #include "oscl_scheduler.h"
 #endif
@@ -132,7 +133,6 @@
 #endif
 
 #include "omx_core.h"
-#include "pv_omxmastercore.h"
 
 #ifndef OSCL_UTF8CONV_H
 #include "oscl_utf8conv.h"
@@ -211,7 +211,7 @@
             {
                 if (!iLogFileRead)
                 {
-                    int32 nCharRead = iLogFile.Read(ibuffer, 1, sizeof(ibuffer));
+                    iLogFile.Read(ibuffer, 1, sizeof(ibuffer));
                     //Parse the buffer for \n chars
                     Oscl_Vector<char*, OsclMemAllocator> LogConfigStrings;
 
@@ -220,13 +220,13 @@
                     const int8 lnFdLen = oscl_strlen(lnFd);
                     int16 offset = 0;
                     char* lastValidBffrAddr = ibuffer + oscl_strlen(ibuffer);
-                    char* lnFdIndx = oscl_strstr(ibuffer, lnFd);
+                    const char* lnFdIndx = oscl_strstr(ibuffer, lnFd);
                     while (lnFdIndx != NULL && lnFdIndx < lastValidBffrAddr)
                     {
-                        oscl_memset(lnFdIndx, '\0', lnFdLen);
+                        oscl_memset((char*)lnFdIndx, '\0', lnFdLen);
                         LogConfigStrings.push_back(ibuffer + offset);
                         offset = (lnFdIndx + lnFdLen) - ibuffer;
-                        lnFdIndx = oscl_strstr(ibuffer + offset, lnFd);
+                        lnFdIndx = OSCL_CONST_CAST(char*, oscl_strstr(ibuffer + offset, lnFd));
                     }
                     if (NULL == lnFdIndx && ((ibuffer + offset) < lastValidBffrAddr)) //If \r\n is skipped after the last logging str in ini file
                     {
@@ -247,7 +247,7 @@
                             {
                                 for (it = LogConfigStrings.begin() + 1; it != LogConfigStrings.end(); it++)
                                 {
-                                    char* CommaIndex = oscl_strstr(*it, ",");
+                                    char* CommaIndex = OSCL_CONST_CAST(char*, oscl_strstr(*it, ","));
                                     if (CommaIndex != NULL)
                                     {
                                         *CommaIndex = '\0';
@@ -264,7 +264,7 @@
                             {
                                 //Add the config element for complete logging fo all the modules
                                 LoggerConfigElement obj;
-                                obj.iLoggerString = "";
+                                obj.iLoggerString = NULL;
                                 obj.iLogLevel = 8;
                                 iLoggerConfigElements.push_back(obj);
                             }
@@ -394,7 +394,7 @@
             oscl_wchar* argwstr = NULL;
             command_line->get_arg(formatSearch, argwstr); //getting the value of argument at formatSearch position
             oscl_UnicodeToUTF8(argwstr, oscl_strlen(argwstr), argstr, 128);
-            argstr[127] = NULL;
+            argstr[127] = '\0';
         }
         else
         {
@@ -406,14 +406,14 @@
                 tmpstrlen = 128;
             }
             oscl_strncpy(argstr, tmpstr, tmpstrlen);
-            argstr[tmpstrlen-1] = NULL;
+            argstr[tmpstrlen-1] = '\0';
         }
 
         ConvertToLowerCase(argstr); //Convert the string in lower case
 
 
         // Do the string compare
-        if (oscl_strcmp(argstr, "-help") == NULL)
+        if (oscl_strcmp(argstr, "-help") == 0)
         {
             fprintf(aFile, "Format type specification option. Default is 'mp4':\n");
             fprintf(aFile, "Specify the format type name in upper case/lower case letter for test cases which\n");
@@ -421,7 +421,7 @@
             fprintf(aFile, "e.g. for executing MP4 specific tests: test_pv_player_engine.exe MP4)\n");
             break;
         }
-        else if (oscl_strcmp(argstr, "mp3") == NULL)
+        else if (oscl_strcmp(argstr, "mp3") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_MP3_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_MP3_CBR;
@@ -429,7 +429,7 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "aac") == NULL)
+        else if (oscl_strcmp(argstr, "aac") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_AAC_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_AAC_ADTS;
@@ -437,7 +437,7 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "amr") == NULL)
+        else if (oscl_strcmp(argstr, "amr") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_AMR_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_AMR_IETF;
@@ -445,7 +445,7 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "mp4") == NULL)
+        else if (oscl_strcmp(argstr, "mp4") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_MP4_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_MP4_M4V_AMR;
@@ -453,7 +453,7 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "3gp") == NULL)
+        else if (oscl_strcmp(argstr, "3gp") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_3GP_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_3GP;
@@ -461,7 +461,7 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "asf") == NULL)
+        else if (oscl_strcmp(argstr, "asf") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_ASF_FORMAT_TYPE ;
             aFileNameInfo = LOCAL_TEST_FILE_ASF;
@@ -469,7 +469,7 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "rm") == NULL)
+        else if (oscl_strcmp(argstr, "rm") == 0)
         {
             aInputFileFormatType = LOCAL_TEST_FILE_REALAUDIO_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_REALAUDIO;
@@ -477,21 +477,21 @@
             break;
 
         }
-        else if (oscl_strcmp(argstr, "wav") == NULL)
+        else if (oscl_strcmp(argstr, "wav") == 0)
         {
             aInputFileFormatType =  LOCAL_TEST_FILE_WAV_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_WAV;
             aTemp_Flag = WAV_ENABLED;
             break;
         }
-        else if (oscl_strcmp(argstr, "wmv") == NULL)
+        else if (oscl_strcmp(argstr, "wmv") == 0)
         {
             aInputFileFormatType =  LOCAL_TEST_FILE_WMV_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_WMV;
             aTemp_Flag = WMV_ENABLED;
             break;
         }
-        else if (oscl_strcmp(argstr, "wma") == NULL)
+        else if (oscl_strcmp(argstr, "wma") == 0)
         {
             aInputFileFormatType =  LOCAL_TEST_FILE_WMA_FORMAT_TYPE;
             aFileNameInfo = LOCAL_TEST_FILE_WMA;
@@ -541,7 +541,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(argstr, "-help"))
+        if (oscl_strcmp(argstr, "-help") == 0)
         {
             fprintf(aFile, "Source specification option. Default is 'test.mp4':\n");
             fprintf(aFile, "  -source sourcename\n");
@@ -549,7 +549,7 @@
             fprintf(aFile, "   allow user-specified source name. The unit test determines the\n");
             fprintf(aFile, "   source format type using extension or URL header.\n\n");
         }
-        else if (!oscl_strcmp(argstr, "-source"))
+        else if (oscl_strcmp(argstr, "-source") == 0)
         {
             iFileFound = true;
             iFileArgument = ++iFileSearch;
@@ -580,7 +580,7 @@
         // AAC file
         if (oscl_strstr(aFileNameInfo.get_cstr(), ".aac") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AAC") != NULL)
         {
-            aInputFileFormatType = PVMF_AACFF;
+            aInputFileFormatType = PVMF_MIME_AACFF;
 
 
         }
@@ -588,13 +588,13 @@
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".amr") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AMR") != NULL ||
                   oscl_strstr(aFileNameInfo.get_cstr(), ".cod") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".COD") != NULL)
         {
-            aInputFileFormatType = PVMF_AMRFF;
+            aInputFileFormatType = PVMF_MIME_AMRFF;
         }
         // RTSP URL
         else  if ((!oscl_strncmp("rtsp", aFileNameInfo.get_cstr(), 4)) ||
                   (!oscl_strncmp("RTSP", aFileNameInfo.get_cstr(), 4)))
         {
-            aInputFileFormatType = PVMF_DATA_SOURCE_RTSP_URL;
+            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
         }
         // HTTP URL
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), "http:") != NULL ||
@@ -602,61 +602,64 @@
                   oscl_strstr(aFileNameInfo.get_cstr(), "mms:") != NULL ||
                   oscl_strstr(aFileNameInfo.get_cstr(), "MMS:") != NULL)
         {
-            aInputFileFormatType = PVMF_DATA_SOURCE_HTTP_URL;
+            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
         }
         // MP4/3GP file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".mp4") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP4") != NULL ||
                   oscl_strstr(aFileNameInfo.get_cstr(), ".3gp") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".3GP") != NULL)
         {
-            aInputFileFormatType = PVMF_MPEG4FF;
+            aInputFileFormatType = PVMF_MIME_MPEG4FF;
         }
         // ASF file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".asf") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".ASF") != NULL ||
                   oscl_strstr(aFileNameInfo.get_cstr(), ".wma") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WMA") != NULL ||
                   oscl_strstr(aFileNameInfo.get_cstr(), ".wmv") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WMV") != NULL)
         {
-            aInputFileFormatType = PVMF_ASFFF;
+            aInputFileFormatType = PVMF_MIME_ASFFF;
         }
         // MP3 file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".mp3") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP3") != NULL)
         {
-            aInputFileFormatType = PVMF_MP3FF;
+            aInputFileFormatType = PVMF_MIME_MP3FF;
         }
         // RM file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".rm") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".RM") != NULL)
         {
-            aInputFileFormatType = PVMF_RMFF;
+            aInputFileFormatType = PVMF_MIME_RMFF;
         }
-        // SDP file
-        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".sdp") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".SDP") != NULL)
+        // SDP file. also includes PVR files
+        else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".sdp") != NULL ||
+                  oscl_strstr(aFileNameInfo.get_cstr(), ".SDP") != NULL ||
+                  oscl_strstr(aFileNameInfo.get_cstr(), ".pvr") != NULL ||
+                  oscl_strstr(aFileNameInfo.get_cstr(), ".PVR") != NULL)
         {
-            aInputFileFormatType = PVMF_DATA_SOURCE_SDP_FILE;
+            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
         }
         // PVX file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".pvx") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".PVX") != NULL)
         {
-            aInputFileFormatType = PVMF_DATA_SOURCE_PVX_FILE;
+            aInputFileFormatType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
         }
         // WAV file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".wav") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WAV") != NULL)
         {
-            aInputFileFormatType = PVMF_WAVFF;
+            aInputFileFormatType = PVMF_MIME_WAVFF;
         }
         // MIDI file
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".mid") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MID") != NULL)
         {
-            aInputFileFormatType = PVMF_MIDIFF;
+//            aInputFileFormatType = PVMF_MIME_MIDIFF;
         }
         // unrecognized eny (Jupiter envelope) files go to the still image node
         else  if (oscl_strstr(aFileNameInfo.get_cstr(), ".eny") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".ENY") != NULL)
         {
-            aInputFileFormatType = PVMF_IMAGE_FORMAT;
+            aInputFileFormatType = PVMF_MIME_M4V_IMAGE;
         }
         // Unknown so set to unknown try to have the player engine recognize
         else
         {
             fprintf(file, "Source type unknown so setting to unknown and have the player engine recognize it\n");
-            aInputFileFormatType = PVMF_FORMAT_UNKNOWN;
+            aInputFileFormatType = PVMF_MIME_FORMAT_UNKNOWN;
         }
     }
 }
@@ -708,7 +711,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "Test cases to run option. Default is ALL:\n");
             fprintf(aFile, "  -test x y\n");
@@ -721,7 +724,7 @@
             fprintf(aFile, "  -test S\n");
             fprintf(aFile, "   Run streaming playback test cases only.\n\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-test"))
+        else if (oscl_strcmp(iSourceFind, "-test") == 0)
         {
             iTestFound = true;
             iTestArgument = ++iTestSearch;
@@ -730,11 +733,11 @@
         else
         {
             ConvertToLowerCase(iSourceFind);
-            if (oscl_strcmp(iSourceFind, "aac") == NULL || oscl_strcmp(iSourceFind, "amr") == NULL || //When argument is supplied as test.exe mp3/amr,then local playback range has to be set
-                    oscl_strcmp(iSourceFind, "mp4") == NULL || oscl_strcmp(iSourceFind, "3gp") == NULL ||
-                    oscl_strcmp(iSourceFind, "mp3") == NULL || oscl_strcmp(iSourceFind, "wav") == NULL ||
-                    oscl_strcmp(iSourceFind, "wmv") == NULL || oscl_strcmp(iSourceFind, "wma") == NULL ||
-                    oscl_strcmp(iSourceFind, "asf") == NULL || oscl_strcmp(iSourceFind, "rm") == NULL)
+            if (oscl_strcmp(iSourceFind, "aac") == 0 || oscl_strcmp(iSourceFind, "amr") == 0 || //When argument is supplied as test.exe mp3/amr,then local playback range has to be set
+                    oscl_strcmp(iSourceFind, "mp4") == 0 || oscl_strcmp(iSourceFind, "3gp") == 0 ||
+                    oscl_strcmp(iSourceFind, "mp3") == 0 || oscl_strcmp(iSourceFind, "wav") == 0 ||
+                    oscl_strcmp(iSourceFind, "wmv") == 0 || oscl_strcmp(iSourceFind, "wma") == 0 ||
+                    oscl_strcmp(iSourceFind, "asf") == 0 || oscl_strcmp(iSourceFind, "rm") == 0)
             {
                 iFirstTest = FIRST_LOCAL_PLAYBACK;
                 iLastTest = LAST_LOCAL_PLAYBACK;
@@ -781,7 +784,6 @@
             int len = oscl_strlen(iTestArgStr1);
             switch (len)
             {
-
                 case 4:
                     iFirstTest = 0;
                     if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9')
@@ -851,7 +853,6 @@
             len = oscl_strlen(iTestArgStr2);
             switch (len)
             {
-
                 case 4:
                     iLastTest = 0;
                     if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
@@ -873,9 +874,7 @@
                     {
                         iLastTest = iLastTest + 1 * (iTestArgStr2[3] - '0');
                     }
-
                     break;
-
                 case 3:
                     iLastTest = 0;
                     if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9')
@@ -999,7 +998,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "Compressed video and audio output option. Default is OFF for both:\n");
             fprintf(aFile, "  -compV AND/OR -compA\n");
@@ -1008,11 +1007,11 @@
             fprintf(aFile, "   bitstreams. This also means the player engine would not use a decoder\n");
             fprintf(aFile, "   node to decode the bitstream from the source node.\n\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-compV"))
+        else if (oscl_strcmp(iSourceFind, "-compV") == 0)
         {
             aCompV = true;
         }
-        else if (!oscl_strcmp(iSourceFind, "-compA"))
+        else if (oscl_strcmp(iSourceFind, "-compA") == 0)
         {
             aCompA = true;
         }
@@ -1057,7 +1056,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "Packet Source plug-in option. Default is OFF for both:\n");
             fprintf(aFile, "  -fi\n");
@@ -1065,11 +1064,11 @@
             fprintf(aFile, "  -bcs\n");
             fprintf(aFile, "  For broadcast socket\n\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-fi"))
+        else if (oscl_strcmp(iSourceFind, "-fi") == 0)
         {
             aFileInput = true;
         }
-        else if (!oscl_strcmp(iSourceFind, "-bcs"))
+        else if (oscl_strcmp(iSourceFind, "-bcs") == 0)
         {
             aBCS = true;
         }
@@ -1114,14 +1113,14 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "Printing leak info option. Default is OFF:\n");
             fprintf(aFile, "  -leakinfo\n");
             fprintf(aFile, "   If there is a memory leak, prints out the memory leak information\n");
             fprintf(aFile, "   after all specified test cases have finished running.\n\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-leakinfo"))
+        else if (oscl_strcmp(iSourceFind, "-leakinfo") == 0)
         {
             aPrintDetailedMemLeakInfo = true;
         }
@@ -1167,7 +1166,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "Log node options. Default is player engine only:\n");
             fprintf(aFile, "  -logall\n");
@@ -1187,75 +1186,75 @@
             fprintf(aFile, "  -logdatapathdec\n");
             fprintf(aFile, "   Log decoder node datapath only\n\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-logall"))
+        else if (oscl_strcmp(iSourceFind, "-logall") == 0)
         {
             lognode = 1;		//log everything
         }
-        else if (!oscl_strcmp(iSourceFind, "-logdatapath"))
+        else if (oscl_strcmp(iSourceFind, "-logdatapath") == 0)
         {
             lognode = 2;		//datapath only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logclock"))
+        else if (oscl_strcmp(iSourceFind, "-logclock") == 0)
         {
             lognode = 3;		//clock only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logoscl"))
+        else if (oscl_strcmp(iSourceFind, "-logoscl") == 0)
         {
             lognode = 4;		//oscl only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logperf"))
+        else if (oscl_strcmp(iSourceFind, "-logperf") == 0)
         {
             lognode = 5;		//scheduler perf logging
         }
-        else if (!oscl_strcmp(iSourceFind, "-logdatapathsrc"))
+        else if (oscl_strcmp(iSourceFind, "-logdatapathsrc") == 0)
         {
             lognode = 6;		//source node data path only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logdatapathdec"))
+        else if (oscl_strcmp(iSourceFind, "-logdatapathdec") == 0)
         {
             lognode = 7;		//source node data path only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logsync"))
+        else if (oscl_strcmp(iSourceFind, "-logsync") == 0)
         {
             lognode = 8;		//media output node datapath only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logdiagnostics"))
+        else if (oscl_strcmp(iSourceFind, "-logdiagnostics") == 0)
         {
             lognode = 9;		//diagnostics log only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logosclfileio"))
+        else if (oscl_strcmp(iSourceFind, "-logosclfileio") == 0)
         {
             lognode = 10; 	//hds access log only
         }
-        else if (!oscl_strcmp(iSourceFind, "-loghds"))
+        else if (oscl_strcmp(iSourceFind, "-loghds") == 0)
         {
             lognode = 11; 	//oscl file-io access log only
         }
-        else if (!oscl_strcmp(iSourceFind, "-loghdsandosclfileio"))
+        else if (oscl_strcmp(iSourceFind, "-loghdsandosclfileio") == 0)
         {
             lognode = 12; 	//file-io and hds access log only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logjupiter"))
+        else if (oscl_strcmp(iSourceFind, "-logjupiter") == 0)
         {
             lognode = 13; 	//jupiter DRM only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logjanus"))
+        else if (oscl_strcmp(iSourceFind, "-logjanus") == 0)
         {
             lognode = 14; 	//janus DRM only
         }
-        else if (oscl_strcmp(iSourceFind, "-logperfmin") == NULL)
+        else if (oscl_strcmp(iSourceFind, "-logperfmin") == 0)
         {
             lognode = 15;   //scheduler perf logging
         }
-        else if (oscl_strcmp(iSourceFind, "-logppb") == NULL)
+        else if (oscl_strcmp(iSourceFind, "-logppb") == 0)
         {
             lognode = 16;	//progressive playback log only
         }
-        else if (!oscl_strcmp(iSourceFind, "-logrepos"))
+        else if (oscl_strcmp(iSourceFind, "-logrepos") == 0)
         {
             lognode = 17; 	//repos related
         }
-        else if (oscl_strcmp(iSourceFind, "-logsnode") == NULL)
+        else if (oscl_strcmp(iSourceFind, "-logsnode") == 0)
         {
             lognode = 18; 	//socket node related
         }
@@ -1301,7 +1300,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "Log level options. Default is debug level:\n");
             fprintf(aFile, "  -logerr\n");
@@ -1309,11 +1308,11 @@
             fprintf(aFile, "  -logwarn\n");
             fprintf(aFile, "   Log at warning level\n\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-logerr"))
+        else if (oscl_strcmp(iSourceFind, "-logerr") == 0)
         {
             loglevel = PVLOGMSG_ERR;
         }
-        else if (!oscl_strcmp(iSourceFind, "-logwarn"))
+        else if (oscl_strcmp(iSourceFind, "-logwarn") == 0)
         {
             loglevel = PVLOGMSG_WARNING;
         }
@@ -1328,6 +1327,7 @@
 
 void FindLogText(cmd_line* command_line, int32& logtext, FILE* aFile)
 {
+    OSCL_UNUSED_ARG(aFile);
     logtext = false;
 
     bool cmdline_iswchar = command_line->is_wchar();
@@ -1357,7 +1357,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-logfile"))
+        if (oscl_strcmp(iSourceFind, "-logfile") == 0)
         {
             logtext = 1;
         }
@@ -1372,6 +1372,7 @@
 
 void FindLogMem(cmd_line* command_line, int32& logmem, FILE* aFile)
 {
+    OSCL_UNUSED_ARG(aFile);
     logmem = false;
 
     bool cmdline_iswchar = command_line->is_wchar();
@@ -1401,7 +1402,7 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-logmem"))
+        if (oscl_strcmp(iSourceFind, "-logmem") == 0)
         {
             logmem = 1;
         }
@@ -1448,13 +1449,13 @@
         }
 
         // Do the string compare
-        if (!oscl_strcmp(iSourceFind, "-help"))
+        if (oscl_strcmp(iSourceFind, "-help") == 0)
         {
             fprintf(aFile, "   proxy enabled ON or OFF, default is OFF\n");
             fprintf(aFile, "  -proxy\n");
             fprintf(aFile, "   For test cases where proxy support is reqd\n");
         }
-        else if (!oscl_strcmp(iSourceFind, "-proxy"))
+        else if (oscl_strcmp(iSourceFind, "-proxy") == 0)
         {
             aProxyEnabled = true;
         }
@@ -1476,10 +1477,16 @@
     OsclBase::Init();
     OsclErrorTrap::Init();
     OsclMem::Init();
-    //OMX_Init();
-    PV_MasterOMX_Init();
+    OMX_Init();
 
-    fprintf(filehandle, "Test Program for pvPlayer engine class.\n");
+
+    {
+        PVSDKInfo aSdkInfo;
+        PVPlayerInterface::GetSDKInfo(aSdkInfo);
+        fprintf(filehandle, "SDK Labeled: %s built on %x\n\n",               // display SDK info
+                aSdkInfo.iLabel.get_cstr(), aSdkInfo.iDate);
+        fprintf(filehandle, "Test Program for pvPlayer engine class.\n");
+    }
 
     bool oPrintDetailedMemLeakInfo = false;
     FindMemMgmtRelatedCmdLineParams(command_line, oPrintDetailedMemLeakInfo, filehandle);
@@ -1487,22 +1494,16 @@
     //Run the test under a trap
     int result = 0;
     int32 err = 0;
-    TPVErrorPanic panic;
 
-    OSCL_PANIC_TRAP(err, panic, result = _local_main(filehandle, command_line););
+    OSCL_TRY(err, result = _local_main(filehandle, command_line););
 
     //Show any exception.
     if (err != 0)
     {
         fprintf(file, "Error!  Leave %d\n", err);
     }
-    if (panic.iReason != 0)
-    {
-        fprintf(file, "Error!  Panic %s %d\n", panic.iCategory.Str(), panic.iReason);
-    }
     //Cleanup
-    //OMX_Deinit();
-    PV_MasterOMX_Deinit();
+    OMX_Deinit();
 
 #if !(OSCL_BYPASS_MEMMGT)
     //Check for memory leaks before cleaning up OsclMem.
@@ -1543,7 +1544,8 @@
                     fprintf(file, "  fileName %s\n", info[i].fileName);
                     fprintf(file, "  lineNo %d\n", info[i].lineNo);
                     fprintf(file, "  size %d\n", info[i].size);
-                    fprintf(file, "  pMemBlock 0x%x\n", info[i].pMemBlock);
+                    uint32 ptrAddr = (uint32)info[i].pMemBlock;
+                    fprintf(file, "  pMemBlock 0x%x\n", ptrAddr);
                     fprintf(file, "  tag %s\n", info[i].tag);
                 }
                 auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
@@ -1629,10 +1631,10 @@
 
         //Set the Initial timer
 
-        double starttick = OsclTickCount::TickCount();
+        uint32 starttick = OsclTickCount::TickCount();
         // Run the engine test
         engine_tests->run_test();
-        double endtick = OsclTickCount::TickCount();
+        uint32 endtick = OsclTickCount::TickCount();
 
         double t1 = OsclTickCount::TicksToMsec(starttick);
         double t2 = OsclTickCount::TicksToMsec(endtick);
@@ -1954,16 +1956,8 @@
                 MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
                 if (stats)
                 {
-                    uint32 alloclks = stats->numAllocs - iNumAllocs;
                     fprintf(file, "  Mem stats: TotalAllocs(%d), TotalBytes(%d),\n             AllocFailures(%d), AllocLeak(%d)\n",
                             stats->totalNumAllocs - iTotalAlloc, stats->totalNumBytes - iTotalBytes, stats->numAllocFails - iAllocFails, stats->numAllocs - iNumAllocs);
-#if 0 //debug
-                    if (alloclks != 0)
-                    {
-                        alloclks++;
-                        alloclks--;
-                    }
-#endif
                 }
                 else
                 {
@@ -2076,11 +2070,15 @@
                 iCurrentTest = new pvplayer_async_test_cpmopenplaystopreset(testparam);
                 break;
 
+            case OpenPlayStopResetCPMRecognizeTest:
+                iCurrentTest = new pvplayer_async_test_cpmopenplaystopreset(testparam, true);
+                break;
+
             case CPM_DLA_OMA1PASSTRHU_OpenFailAuthPlayStopResetTest:
 #if RUN_CPMOMA1_DLAPASSTHRU_TESTCASES
                 iCurrentTest = new pvplayer_async_test_cpmdlapassthru(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -2096,8 +2094,8 @@
             case CPM_DLA_OMA1PASSTRHU_OpenPlayStopResetTest:
 #if RUN_CPMOMA1_DLAPASSTHRU_TESTCASES
                 iCurrentTest = new pvplayer_async_test_cpmdlapassthru(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -2113,8 +2111,8 @@
             case CPM_DLA_OMA1PASSTRHU_UnknownContentOpenPlayStopResetTest:
 #if RUN_CPMOMA1_DLAPASSTHRU_TESTCASES
                 iCurrentTest = new pvplayer_async_test_cpmdlapassthru(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -2130,8 +2128,8 @@
             case CPM_DLA_OMA1PASSTRHU_CancelAcquireLicenseTooLate_CancelFails:
 #if RUN_CPMOMA1_DLAPASSTHRU_TESTCASES
                 iCurrentTest = new pvplayer_async_test_cpmdlapassthru(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -2147,8 +2145,8 @@
             case CPM_DLA_OMA1PASSTRHU_CancelAcquireLicense_CancelSucceeds:
 #if RUN_CPMOMA1_DLAPASSTHRU_TESTCASES
                 iCurrentTest = new pvplayer_async_test_cpmdlapassthru(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -2164,8 +2162,8 @@
             case CPM_DLA_OMA1PASSTRHU_ContentNotSupported:
 #if RUN_CPMOMA1_DLAPASSTHRU_TESTCASES
                 iCurrentTest = new pvplayer_async_test_cpmdlapassthru(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -2232,8 +2230,11 @@
                 break;
 
             case SetStartPositionPlayStop:
+            {
                 iCurrentTest = new pvplayer_async_test_setstartpositionplaystop(testparam);
+                ((pvplayer_async_test_setstartpositionplaystop*)iCurrentTest)->setMultipleSeekMode(1);
                 break;
+            }
 
             case SetPlayRangePlay:
                 iCurrentTest = new pvplayer_async_test_setplayrangeplay(testparam);
@@ -2287,6 +2288,20 @@
                 iCurrentTest = new pvplayer_async_test_multireposition(testparam);
                 break;
 
+            case MultiplePauseSeekResumeTest:
+            {
+                iCurrentTest = new pvplayer_async_test_multipauseseekresume(testparam);
+                ((pvplayer_async_test_multipauseseekresume*)iCurrentTest)->setMultiplePauseMode(2);
+                break;
+            }
+
+            case MultipleSetStartPositionPlayStopTest:
+            {
+                iCurrentTest = new pvplayer_async_test_setstartpositionplaystop(testparam);
+                ((pvplayer_async_test_setstartpositionplaystop*)iCurrentTest)->setMultipleSeekMode(2);
+                break;
+            }
+
             case MediaIONodeOpenPlayStopTest:
                 iCurrentTest = new pvplayer_async_test_mediaionode_openplaystop(testparam);
                 break;
@@ -2399,7 +2414,7 @@
 #endif
                 break;
 
-            case MediaIONodBackwardNearEOSForwardNearStartTest:
+            case MediaIONodeBackwardNearEOSForwardNearStartTest:
 #ifndef ONLY_3GPP_STREAMING_FORMAT
                 iCurrentTest = new pvplayer_async_test_mediaionode_backwardneareosforwardnearbos(testparam);
 #else
@@ -2754,7 +2769,7 @@
                 break;
 
             case FTDownloadOpenPlayStopTest:
-#if RUN_HTTPDOWNLOAD_TESTCASES
+#if RUN_FASTTRACK_TESTCASES
 #ifndef ONLY_3GPP_STREAMING_FORMAT
                 iCurrentTest = new pvplayer_async_test_ftdlnormal(testparam);
 #else
@@ -2766,7 +2781,7 @@
                 break;
 
             case FTDownloadPlayStopPlayTest:
-#if RUN_HTTPDOWNLOAD_TESTCASES
+#if RUN_FASTTRACK_TESTCASES
 #ifndef ONLY_3GPP_STREAMING_FORMAT
                 iCurrentTest = new pvplayer_async_test_ftdlnormal(testparam);
                 ((pvplayer_async_test_ftdlnormal*)iCurrentTest)->enablePlayStopPlay();
@@ -2781,7 +2796,7 @@
 
             case ProgDownloadPlayAsapTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal(testparam);
 #else
                 fprintf(file, "Prog download tests not enabled\n");
@@ -2790,7 +2805,7 @@
 
             case ProgDownloadPlayStopPlayTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal(testparam);
                 ((pvplayer_async_test_3gppdlnormal*)iCurrentTest)->enablePlayStopPlay();
 #else
@@ -2800,7 +2815,7 @@
 
             case ProgPlaybackPlayStopPlayTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppbnormal(testparam);
                 ((pvplayer_async_test_ppbnormal*)iCurrentTest)->enablePlayStopPlay();
 #else
@@ -2810,7 +2825,7 @@
 
             case ProgDownloadDownloadThenPlayTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal_dlthenplay(testparam);
 #else
                 fprintf(file, "Prog Download tests not enabled\n");
@@ -2819,7 +2834,7 @@
 
             case ProgDownloadDownloadThenPlayPauseTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal_dlthenplay(testparam);
                 ((pvplayer_async_test_3gppdlnormal_dlthenplay*)iCurrentTest)->enablePauseAfterDownloadComplete();
 #else
@@ -2829,7 +2844,7 @@
 
             case ProgDownloadDownloadThenPlayRepositionTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal_dlthenplay(testparam);
                 ((pvplayer_async_test_3gppdlnormal_dlthenplay*)iCurrentTest)->enableReposAfterDownloadComplete();
 #else
@@ -2839,7 +2854,7 @@
 
             case ProgDownloadDownloadOnlyTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal_dlonly(testparam);
 #else
                 fprintf(file, "Prog Download tests not enabled\n");
@@ -2848,7 +2863,7 @@
 
             case ProgDownloadCancelDuringInitTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlcancelduringinit(testparam);
 #else
                 fprintf(file, "Prog Download tests not enabled\n");
@@ -2857,7 +2872,7 @@
 
             case ProgDownloadCancelDuringInitDelayTest: //114
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlcancelduringinitdelay(testparam);
 #else
                 fprintf(file, "Prog Download tests not enabled\n");
@@ -2865,7 +2880,7 @@
                 break;
             case ProgDownloadPauseResumeAfterUnderflowTest: //115
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_PDLPauseResumeAfterUnderFlow(testparam);
 #else
                 fprintf(file, "Prog Download tests not enabled\n");
@@ -2874,7 +2889,7 @@
 
             case ProgDownloadContentTooLarge:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlcontenttoolarge(testparam);
 #else
                 fprintf(file, "Prog Download tests not enabled\n");
@@ -2884,7 +2899,7 @@
             case ProgDownloadTruncated:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
 #ifndef ONLY_3GPP_STREAMING_FORMAT
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlContentTruncated(testparam);
 #else
                 fprintf(file, "Prog Truncated download tests not enabled\n");
@@ -2895,8 +2910,8 @@
                 break;
 
             case ProgDownloadProtocolRolloverTest:
-#if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES && RUN_MS_HTTP_STREAMING_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+#if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal(testparam);
                 ((pvplayer_async_test_3gppdlnormal*)iCurrentTest)->setProtocolRollOverMode();
 #else
@@ -2906,7 +2921,7 @@
 
             case ProgDownloadSetPlayBackRangeTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal(testparam);
                 ((pvplayer_async_test_3gppdlnormal*)iCurrentTest)->enableReposAfterDownloadComplete();
 #else
@@ -2916,7 +2931,7 @@
 
             case ProgDownloadPlayUtilEOSTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_3gppdlnormal(testparam);
                 ((pvplayer_async_test_3gppdlnormal*)iCurrentTest)->enablePlayUntilEOS();
 #else
@@ -2926,7 +2941,7 @@
 
             case ProgPlaybackMP4UntilEOSTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enablePlayUntilEOS();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->iTestCaseName = _STRLIT_CHAR("MP4 Progressive Playback Until EOS");
@@ -2937,7 +2952,7 @@
 
             case ProgPlaybackMP4ShortTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
 #else
                 fprintf(file, "MP4 progressive playback tests not enabled\n");
@@ -2946,7 +2961,7 @@
 
             case ProgPlaybackMP4ShortPauseResumeTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableShortPauseResume();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->iTestCaseName = _STRLIT_CHAR("MP4 Progressive Playback Short Pause Resume");
@@ -2957,7 +2972,7 @@
 
             case ProgPlaybackMP4LongPauseResumeTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableLongPauseResume();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enablePlayUntilEOS();
@@ -2969,7 +2984,7 @@
 
             case ProgPlaybackMP4StartPauseSeekResumeTwiceTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableShortPauseResume();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekAfterStart();
@@ -2982,7 +2997,7 @@
 
             case ProgPlaybackMP4SeekStartTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekBeforeStart();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enablePlayUntilEOS();
@@ -2994,7 +3009,7 @@
 
             case ProgPlaybackMP4StartPauseSeekResumeLoopTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableShortPauseResume();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekAfterStart();
@@ -3007,7 +3022,7 @@
 
             case ProgPlaybackMP4SeekForwardStepLoopTest:
 #if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
-                testparam.iFileType = PVMF_MPEG4FF;
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
                 iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableShortPauseResume();
                 ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekAfterStart();
@@ -3019,9 +3034,44 @@
 #endif
                 break;
 
+            case ProgPlaybackMP4SeekToBOCAfterDownloadCompleteTest:
+#if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
+                iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekToBOC();
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekAfterDownloadComplete();
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->iTestCaseName = _STRLIT_CHAR("MP4 Progressive Playback Seek To Beginning Of Clip After Download Complete");
+#else
+                fprintf(file, "MP4 progressive playback tests not enabled\n");
+#endif
+                break;
+
+            case ProgPlaybackMP4SeekInCacheAfterDownloadCompleteTest:
+#if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
+                iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekInCache();
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableSeekAfterDownloadComplete();
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->iTestCaseName = _STRLIT_CHAR("MP4 Progressive Playback Seek To Position In Cache After Download Complete");
+#else
+                fprintf(file, "MP4 progressive playback tests not enabled\n");
+#endif
+                break;
+
+            case ProgPlaybackMP4EOSStopPlayAgainTest:
+#if RUN_HTTPDOWNLOAD_TESTCASES && RUN_MP4FILE_TESTCASES
+                testparam.iFileType = PVMF_MIME_MPEG4FF;
+                iCurrentTest = new pvplayer_async_test_ppb_normal(testparam);
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enablePlayUntilEOS();
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->enableEOSStopPlay();
+                ((pvplayer_async_test_ppb_normal*)iCurrentTest)->iTestCaseName = _STRLIT_CHAR("MP4 Progressive Playback To EOS Stop and Play Again");
+#else
+                fprintf(file, "MP4 progressive playback tests not enabled\n");
+#endif
+                break;
 
             case FTDownloadOpenPlayUntilEOSTest:
-#if RUN_HTTPDOWNLOAD_TESTCASES
+#if RUN_FASTTRACK_TESTCASES
 #ifndef ONLY_3GPP_STREAMING_FORMAT
                 iCurrentTest = new pvplayer_async_test_ftdlnormal(testparam);
                 ((pvplayer_async_test_ftdlnormal*)iCurrentTest)->enablePlayUntilEOS();
@@ -3033,14 +3083,26 @@
 #endif
                 break;
 
+            case MultipleInstanceOpenPlayStopTest:
+            {
+                iCurrentTest = new pvplayer_async_test_multiple_instance(testparam);
+            }
+            break;
+
+            case MultipleThreadOpenPlayStopTest:
+            {
+                iCurrentTest = new pvplayer_async_test_multiple_thread(testparam);
+            }
+            break;
+
             case StreamingOpenPlayStopTest:
             {
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingOpenPlayStopTest");
                 iCurrentTest =
                     new pvplayer_async_test_streamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -3060,8 +3122,8 @@
                 fprintf(file, "StreamingOpenPlayPausePlayStopTest");
                 iCurrentTest =
                     new pvplayer_async_test_streamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -3081,8 +3143,8 @@
                 fprintf(file, "StreamingOpenPlaySeekStopTest");
                 iCurrentTest =
                     new pvplayer_async_test_streamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -3102,8 +3164,8 @@
                 fprintf(file, "StreamingCancelDuringPrepareTest");
                 iCurrentTest =
                     new pvplayer_async_test_streamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -3118,7 +3180,7 @@
             break;
 
             case PrintMetadataTest:
-                iCurrentTest = new pvplayer_async_test_printmetadata(testparam);
+                iCurrentTest = new pvplayer_async_test_printmetadata(testparam, false);
                 break;
 
             case PrintMemStatsTest:
@@ -3129,6 +3191,10 @@
                 iCurrentTest = new pvplayer_async_test_playuntileos(testparam);
                 break;
 
+            case ReleaseMetadataTest:
+                iCurrentTest = new pvplayer_async_test_printmetadata(testparam, true);
+                break;
+
             case CleanDrmData_JanusCPMTest:
                 fprintf(file, "Janus CPM tests not enabled\n");
                 break;
@@ -3351,50 +3417,50 @@
 #endif
                 break;
 
-            case DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_ringtone:
+            case DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_ringtone:
 #if RUN_CPMJUPITER_TESTCASES
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_openplaystop(testparam
-                        , EJupContentType_v24_WMA
+                        , EJupContentType_v4_WMA
                         , EJupLicenseType_DLA_With_Ringtone);
 #else
                 fprintf(file, "Jupiter CPM tests not enabled\n");
 #endif
                 break;
 
-            case DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain:
+            case DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain:
 #if RUN_CPMJUPITER_TESTCASES
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_openplaystop(testparam
-                        , EJupContentType_v24_WMA
+                        , EJupContentType_v4_WMA
                         , EJupLicenseType_DLA_With_Domain);
 #else
                 fprintf(file, "Jupiter CPM tests not enabled\n");
 #endif
                 break;
 
-            case DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain_renew:
+            case DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain_renew:
 #if RUN_CPMJUPITER_TESTCASES
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_openplaystop(testparam
-                        , EJupContentType_v24_WMA
+                        , EJupContentType_v4_WMA
                         , EJupLicenseType_DLA_With_DomainRenew);
 #else
                 fprintf(file, "Jupiter CPM tests not enabled\n");
 #endif
                 break;
 
-            case DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain_offline:
+            case DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain_offline:
 #if RUN_CPMJUPITER_TESTCASES
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_openplaystop(testparam
-                        , EJupContentType_v24_WMA
+                        , EJupContentType_v4_WMA
                         , EJupLicenseType_DLA_With_DomainOffline);
 #else
                 fprintf(file, "Jupiter CPM tests not enabled\n");
 #endif
                 break;
 
-            case DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain_history:
+            case DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain_history:
 #if RUN_CPMJUPITER_TESTCASES
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_openplaystop(testparam
-                        , EJupContentType_v24_WMA
+                        , EJupContentType_v4_WMA
                         , EJupLicenseType_DLA_With_DomainHistory);
 #else
                 fprintf(file, "Jupiter CPM tests not enabled\n");
@@ -3418,7 +3484,7 @@
                 break;
 
             case DLA_MeteringByCert_JupiterCPMTest:
-#if RUN_CPMJUPITER_TESTCASES
+#if (RUN_CPMJUPITER_TESTCASES && RUN_CPMJUPITER_METERING_TESTCASES)
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_metering_or_sync(testparam
                         , EPVMeterTestType_byCert
                         , EJupContentType_mixed
@@ -3429,7 +3495,7 @@
                 break;
 
             case DLA_MeteringByMID_JupiterCPMTest:
-#if RUN_CPMJUPITER_TESTCASES
+#if (RUN_CPMJUPITER_TESTCASES && RUN_CPMJUPITER_METERING_TESTCASES)
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_metering_or_sync(testparam
                         , EPVMeterTestType_byMID
                         , EJupContentType_mixed
@@ -3440,7 +3506,7 @@
                 break;
 
             case DLA_MeteringAll_JupiterCPMTest:
-#if RUN_CPMJUPITER_TESTCASES
+#if (RUN_CPMJUPITER_TESTCASES && RUN_CPMJUPITER_METERING_TESTCASES)
                 iCurrentTest = new pvplayer_async_test_jupitercpm_dla_metering_or_sync(testparam
                         , EPVMeterTestType_All
                         , EJupContentType_mixed
@@ -3530,8 +3596,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingOpenPlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3548,8 +3614,8 @@
 #if RUN_RTSP_CLOAKING_TESTCASES
                 fprintf(file, "StreamingCloakingOpenPlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3568,8 +3634,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingOpenPlayPausePlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         true,
                         false,
@@ -3587,8 +3653,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingOpenPlayPausePlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         true,
                         false,
@@ -3612,8 +3678,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingOpenPlaySeekPlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         true,
@@ -3630,8 +3696,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingOpenPlayForwardPlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3648,8 +3714,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingJitterBufferAdjustUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingJBadjust(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3667,8 +3733,8 @@
                         (NULL == (oscl_strstr(testparam.iFileName, ".sdp"))))
                 {
                     iCurrentTest = new pvplayer_async_test_streaming_bitstream_switch(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true);
                 }
@@ -3689,8 +3755,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingMultiplePlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3714,8 +3780,8 @@
 #if RUN_RTSP_CLOAKING_TESTCASES
                 fprintf(file, "StreamingMultipleCloakingPlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3741,8 +3807,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingProtocolRollOverTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3758,13 +3824,32 @@
             }
             break;
 
+            case StreamingOpenPlayUntilEOSTestWithFileHandle:
+#if RUN_STREAMING_TESTCASES
+                fprintf(file, "StreamingOpenPlayUntilEOSTestWithFileHandle");
+                iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber,
+                        false,
+                        false,
+                        true,
+                        false,
+                        false,
+                        false,
+                        true);
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
             case StreamingProtocolRollOverTestWithUnknownURLType:
             {
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingProtocolRollOverTestWithUnknownURLType");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3786,8 +3871,8 @@
 #ifndef ONLY_3GPP_STREAMING_FORMAT
                 fprintf(file, "StreamingPlayListSeekTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         true,
@@ -3811,8 +3896,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingSeekAfterEOSTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -3830,12 +3915,62 @@
             }
             break;
 
+            case StreamingPlayListErrorCodeTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#ifndef ONLY_3GPP_STREAMING_FORMAT
+                fprintf(file, "StreamingPlayListErrorCodeTest");
+                iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber,
+                        false,
+                        true,
+                        true,
+                        false,
+                        false,
+                        false);
+
+                ((pvplayer_async_test_streamingopenplaystop*)iCurrentTest)->setPlayListMode();
+                ((pvplayer_async_test_streamingopenplaystop*)iCurrentTest)->setErrorCodeTest();
+#else
+                fprintf(file, "Streaming: playlist tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case StreamingOpenPlayMultipleSeekToEndOfClipUntilEOSTest:
+            {
+#if RUN_STREAMING_TESTCASES
+                fprintf(file, "StreamingOpenPlayMultipleSeekToEndOfClipUntilEOSTest");
+                iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber,
+                        false,
+                        true,
+                        true,
+                        false,
+                        false,
+                        false,
+                        false,
+                        true);
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+
             case StreamingLongPauseTest:
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "StreamingLongPauseTest");
                 iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         true,
                         false,
@@ -3897,8 +4032,8 @@
                 fprintf(file, "GenericReset_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -3913,8 +4048,8 @@
                 fprintf(file, "GenericReset_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -3929,8 +4064,8 @@
                 fprintf(file, "GenericReset_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -3945,8 +4080,8 @@
                 fprintf(file, "GenericReset_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -3961,8 +4096,8 @@
                 fprintf(file, "GenericReset_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -3977,8 +4112,8 @@
                 fprintf(file, "GenericReset_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -3993,8 +4128,8 @@
                 fprintf(file, "GenericReset_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -4009,8 +4144,8 @@
                 fprintf(file, "GenericReset_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          true,
                                                          false,
@@ -4025,8 +4160,8 @@
                 fprintf(file, "GenericReset_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          false,
                                                          false,
@@ -4042,8 +4177,8 @@
                 fprintf(file, "GenericReset_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericreset(testparam,
-                                                         PVMF_YUV420,
-                                                         PVMF_PCM16,
+                                                         PVMF_MIME_YUV420,
+                                                         PVMF_MIME_PCM16,
                                                          iCurrentTestNumber,
                                                          false,
                                                          true,
@@ -4058,8 +4193,8 @@
                 fprintf(file, "GenericDelete_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4074,8 +4209,8 @@
                 fprintf(file, "GenericDelete_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4090,8 +4225,8 @@
                 fprintf(file, "GenericDelete_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4106,8 +4241,8 @@
                 fprintf(file, "GenericDelete_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4122,8 +4257,8 @@
                 fprintf(file, "GenericDelete_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4138,8 +4273,8 @@
                 fprintf(file, "GenericDelete_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4154,8 +4289,8 @@
                 fprintf(file, "GenericDelete_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4170,8 +4305,8 @@
                 fprintf(file, "GenericDelete_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4186,8 +4321,8 @@
                 fprintf(file, "GenericDelete_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           false,
                                                           false,
@@ -4203,8 +4338,8 @@
                 fprintf(file, "GenericDelete_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           false,
                                                           true,
@@ -4219,8 +4354,8 @@
                 fprintf(file, "GenericDeleteWhileProc_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4235,8 +4370,8 @@
                 fprintf(file, "GenericDeleteWhileProc_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4251,8 +4386,8 @@
                 fprintf(file, "GenericDeleteWhileProc_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4267,8 +4402,8 @@
                 fprintf(file, "GenericDeleteWhileProc_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4283,8 +4418,8 @@
                 fprintf(file, "GenericDeleteWhileProc_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4299,8 +4434,8 @@
                 fprintf(file, "GenericDeleteWhileProc_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4315,8 +4450,8 @@
                 fprintf(file, "GenericDeleteWhileProc_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4331,8 +4466,8 @@
                 fprintf(file, "GenericDeleteWhileProc_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           true,
                                                           false,
@@ -4347,8 +4482,8 @@
                 fprintf(file, "GenericDeleteWhileProc_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           false,
                                                           false,
@@ -4363,8 +4498,8 @@
                 fprintf(file, "GenericDeleteWhileProc_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericdelete(testparam,
-                                                          PVMF_YUV420,
-                                                          PVMF_PCM16,
+                                                          PVMF_MIME_YUV420,
+                                                          PVMF_MIME_PCM16,
                                                           iCurrentTestNumber,
                                                           false,
                                                           true,
@@ -4379,8 +4514,8 @@
                 fprintf(file, "GenericCancelAll_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4395,8 +4530,8 @@
                 fprintf(file, "GenericCancelAll_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4411,8 +4546,8 @@
                 fprintf(file, "GenericCancelAll_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4427,8 +4562,8 @@
                 fprintf(file, "GenericCancelAll_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4444,8 +4579,8 @@
                 fprintf(file, "GenericCancelAll_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4460,8 +4595,8 @@
                 fprintf(file, "GenericCancelAll_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4476,8 +4611,8 @@
                 fprintf(file, "GenericCancelAll_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4492,8 +4627,8 @@
                 fprintf(file, "GenericCancelAll_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4508,8 +4643,8 @@
                 fprintf(file, "GenericCancelAll_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4524,8 +4659,8 @@
                 fprintf(file, "GenericCancelAll_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -4540,8 +4675,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4556,8 +4691,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4572,8 +4707,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4588,8 +4723,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4604,8 +4739,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4620,8 +4755,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4636,8 +4771,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4652,8 +4787,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4668,8 +4803,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4684,8 +4819,8 @@
                 fprintf(file, "GenericCancelAllWhileProc_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelall(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -4701,8 +4836,8 @@
                 fprintf(file, "GenericNetworkDisconnect_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4717,8 +4852,8 @@
                 fprintf(file, "GenericNetworkDisconnect_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4733,8 +4868,8 @@
                 fprintf(file, "GenericNetworkDisconnect_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4749,8 +4884,8 @@
                 fprintf(file, "GenericNetworkDisconnect_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4766,8 +4901,8 @@
                 fprintf(file, "GenericNetworkDisconnect_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4782,8 +4917,8 @@
                 fprintf(file, "GenericNetworkDisconnect_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4798,8 +4933,8 @@
                 fprintf(file, "GenericNetworkDisconnect_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4814,8 +4949,8 @@
                 fprintf(file, "GenericNetworkDisconnect_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4830,8 +4965,8 @@
                 fprintf(file, "GenericNetworkDisconnect_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4847,8 +4982,8 @@
                 fprintf(file, "GenericNetworkDisconnect_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -4863,8 +4998,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4879,8 +5014,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4895,8 +5030,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4911,8 +5046,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4927,8 +5062,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4943,8 +5078,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -4959,8 +5094,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4975,8 +5110,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -4991,8 +5126,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5007,8 +5142,8 @@
                 fprintf(file, "GenericNetworkDisconnectWhileProc_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -5024,8 +5159,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5040,8 +5175,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5056,8 +5191,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5072,8 +5207,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5089,8 +5224,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5105,8 +5240,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5121,8 +5256,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5137,8 +5272,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5153,8 +5288,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5170,8 +5305,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnect_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -5186,8 +5321,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5202,8 +5337,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5218,8 +5353,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5234,8 +5369,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5250,8 +5385,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5266,8 +5401,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5282,8 +5417,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5298,8 +5433,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5314,8 +5449,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5331,8 +5466,8 @@
                 fprintf(file, "GenericNetworkDisconnectReconnectWhileProc_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericnetworkdisconnectreconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -5348,8 +5483,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5364,8 +5499,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5380,8 +5515,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5396,8 +5531,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5413,8 +5548,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5429,8 +5564,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5445,8 +5580,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5461,8 +5596,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5477,8 +5612,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5493,8 +5628,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAll_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -5509,8 +5644,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_AddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5525,8 +5660,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_Init");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5541,8 +5676,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_AddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5557,8 +5692,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_AddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5573,8 +5708,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_Prepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5589,8 +5724,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_Start");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5605,8 +5740,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_Pause");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5621,8 +5756,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_Resume");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5637,8 +5772,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_Stop");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5653,8 +5788,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProc_SetPlaybackRange");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -5670,8 +5805,8 @@
                 fprintf(file, "GenericNetworkDisconnectCancelAllWhileProtocolRollover");
                 iCurrentTest =
                     new pvplayer_async_test_genericcancelallnetworkdisconnect(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5687,8 +5822,8 @@
                 fprintf(file, "GenericOpenPlayMultiplePauseResumeUntilEOSTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5707,8 +5842,8 @@
                 fprintf(file, "GenericOpenPlayMultipleSeekUntilEOSTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             true,
@@ -5727,12 +5862,12 @@
                 fprintf(file, "GenericOpenPlayStop_SleepAddDataSource");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_ADDDATASOURCE,
@@ -5748,12 +5883,12 @@
                 fprintf(file, "GenericOpenPlayStop_SleepInit");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_INIT,
@@ -5769,12 +5904,12 @@
                 fprintf(file, "GenericOpenPlayStop_SleepAddDataSinkVideo");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_ADDDATASINK_VIDEO,
@@ -5790,12 +5925,12 @@
                 fprintf(file, "GenericOpenPlayStop_SleepAddDataSinkAudio");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_ADDDATASINK_AUDIO,
@@ -5811,12 +5946,12 @@
                 fprintf(file, "GenericOpenPlayStop_SleepPrepare");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_PREPARE,
@@ -5832,12 +5967,12 @@
                 fprintf(file, "GenericOpenPlayStop_SleepGetMetaDataValueList");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_GETMETADATAVALUELIST,
@@ -5848,101 +5983,17 @@
             }
             break;
 
-            case GenericOpenPlayStop_SleepStart:
-            {
-                fprintf(file, "GenericOpenPlayStop_SleepStart");
-                iCurrentTest =
-                    new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
-                            iCurrentTestNumber,
-                            false,
-                            false,
-                            true,
-                            false,
-                            false,
-                            STATE_START,
-                            true);
-                pvplayer_async_test_genericopenplaystop* ptr =
-                    (pvplayer_async_test_genericopenplaystop*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
-            }
-            break;
-
-            case GenericOpenPlayStop_SleepPause:
-            {
-                fprintf(file, "GenericOpenPlayStop_SleepPause");
-                iCurrentTest =
-                    new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
-                            iCurrentTestNumber,
-                            true,
-                            false,
-                            true,
-                            false,
-                            false,
-                            STATE_PAUSE,
-                            true);
-                pvplayer_async_test_genericopenplaystop* ptr =
-                    (pvplayer_async_test_genericopenplaystop*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
-            }
-            break;
-
-            case GenericOpenPlayStop_SleepResume:
-            {
-                fprintf(file, "GenericOpenPlayStop_SleepResume");
-                iCurrentTest =
-                    new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
-                            iCurrentTestNumber,
-                            true,
-                            false,
-                            true,
-                            false,
-                            false,
-                            STATE_RESUME,
-                            true);
-                pvplayer_async_test_genericopenplaystop* ptr =
-                    (pvplayer_async_test_genericopenplaystop*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
-            }
-            break;
-
-            case GenericOpenPlayStop_SleepSetPlaybackRange:
-            {
-                fprintf(file, "GenericOpenPlayStop_SleepSetplayBackRange");
-                iCurrentTest =
-                    new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
-                            iCurrentTestNumber,
-                            false,
-                            true,
-                            true,
-                            false,
-                            false,
-                            STATE_SETPLAYBACKRANGE,
-                            true);
-                pvplayer_async_test_genericopenplaystop* ptr =
-                    (pvplayer_async_test_genericopenplaystop*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
-            }
-            break;
-
             case GenericOpenPlayStop_SleepStop:
             {
                 fprintf(file, "GenericOpenPlayStop_SleepStop");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
-                            true,
+                            false,
                             false,
                             false,
                             STATE_STOP,
@@ -5958,8 +6009,8 @@
                 fprintf(file, "GenericOpenPlayPauseResumeSeekStopProfiling");
                 iCurrentTest =
                     new pvplayer_async_test_genericprofiling(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -5975,8 +6026,8 @@
                 fprintf(file, "GenericOpenPlayPauseRepositionResumeUntilEOSTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericplaypauserepositionresumetest(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -5992,8 +6043,8 @@
                 fprintf(file, "GenericOpenPlayPauseRepositionResumeNetworkDisconnectCancelAllTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericplaypauserepositionresumenwdisconnectcancelalltest(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -6009,8 +6060,8 @@
                 fprintf(file, "GenericOpenSetPlaybackRangeStartPlayStopTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericopensetplaybackrangestartplaystoptest(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -6026,8 +6077,8 @@
                 fprintf(file, "GenericOpenPlayRepositionToEndPlayTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplayrepositiontoendtest(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -6043,13 +6094,13 @@
                 fprintf(file, "GenericPVMFErrorCorruptReNotified");
                 iCurrentTest =
                     new pvplayer_async_test_genericpvmferrorcorruptrenotified(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false);
                 pvplayer_async_test_genericpvmferrorcorruptrenotified* ptr =
                     (pvplayer_async_test_genericpvmferrorcorruptrenotified*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
+                OSCL_UNUSED_ARG(ptr);
             }
             break;
 
@@ -6058,14 +6109,15 @@
                 fprintf(file, "GenericOpenPlayPauseGetMetaDataUntilEOSTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericopenplaygetmetadatatest(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false);
                 pvplayer_async_test_genericopenplaygetmetadatatest* ptr =
                     (pvplayer_async_test_genericopenplaygetmetadatatest*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
+                OSCL_UNUSED_ARG(ptr);
+
             }
             break;
 
@@ -6074,14 +6126,14 @@
                 fprintf(file, "GenericOpenGetMetaDataPicTest");
                 iCurrentTest =
                     new pvplayer_async_test_genericopengetmetadatapictest(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false);
                 pvplayer_async_test_genericopengetmetadatapictest* ptr =
                     (pvplayer_async_test_genericopengetmetadatapictest*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
+                OSCL_UNUSED_ARG(ptr);
             }
             break;
 
@@ -6091,8 +6143,8 @@
                 fprintf(file, "DLA_StreamingOpenPlayUntilEOST_JupiterCPMTest");
                 iCurrentTest =
                     new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -6112,8 +6164,8 @@
                 fprintf(file, "DLA_StreamingOpenPlayPausePlayUntilEOS_JupiterCPMTest");
                 iCurrentTest =
                     new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             true,
                             false,
@@ -6132,8 +6184,8 @@
 #if RUN_STREAMING_TESTCASES && RUN_CPMJUPITER_TESTCASES
                 fprintf(file, "DLA_StreamingOpenPlaySeekPlayUntilEOS_JupiterCPMTest");
                 iCurrentTest = new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         true,
@@ -6153,8 +6205,8 @@
                 fprintf(file, "DLA_StreamingMultiplePlayUntilEOS_JupiterCPMTest");
                 iCurrentTest =
                     new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -6178,8 +6230,8 @@
 #if RUN_STREAMING_TESTCASES && RUN_CPMJUPITER_TESTCASES
                 fprintf(file, "DLA_StreamingProtocolRollOverTest_JupiterCPMTest");
                 iCurrentTest = new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -6200,8 +6252,8 @@
 #if RUN_STREAMING_TESTCASES && RUN_CPMJUPITER_TESTCASES
                 fprintf(file, "DLA_StreamingProtocolRollOverTestWithUnknownURLType_JupiterCPMTest");
                 iCurrentTest = new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -6773,30 +6825,6 @@
             }
             break;
 
-            case DLA_StreamingOpenPlayStop_SleepStart:
-            {
-                fprintf(file, "Streaming tests not enabled\n");
-            }
-            break;
-
-            case DLA_StreamingOpenPlayStop_SleepPause:
-            {
-                fprintf(file, "Streaming tests not enabled\n");
-            }
-            break;
-
-            case DLA_StreamingOpenPlayStop_SleepResume:
-            {
-                fprintf(file, "Streaming tests not enabled\n");
-            }
-            break;
-
-            case DLA_StreamingOpenPlayStop_SleepSetPlaybackRange:
-            {
-                fprintf(file, "Streaming tests not enabled\n");
-            }
-            break;
-
             case DLA_StreamingOpenPlayStop_SleepStop:
             {
                 fprintf(file, "Streaming tests not enabled\n");
@@ -6808,8 +6836,8 @@
 #if RUN_STREAMING_TESTCASES && RUN_CPMJUPITER_TESTCASES
                 fprintf(file, "DLA_StreamingCancelAcquireLicense_JupiterCPMTest");
                 iCurrentTest = new pvplayer_async_test_jupitercpm_DLAstreamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -6828,8 +6856,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "DVBH_StreamingOpenPlayStopTest");
                 iCurrentTest = new pvplayer_async_test_dvbh_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -6845,8 +6873,8 @@
 #if RUN_STREAMING_TESTCASES
                 fprintf(file, "DVBH_StreamingOpenPlayUntilEOSTest");
                 iCurrentTest = new pvplayer_async_test_dvbh_streamingopenplaystop(testparam,
-                        PVMF_YUV420,
-                        PVMF_PCM16,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
                         iCurrentTestNumber,
                         false,
                         false,
@@ -6858,23 +6886,594 @@
 #endif
                 break;
 
-            case GenericOpenPlaySeekBeyondClipDurationTest:
+            case PVR_FILEPLAYBACK_OpenPlayUntilEOFTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_FILEPLAYBACK_OpenPlayUntilEOFTest");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_FILEPLAYBACK_OpenPlayRepositionPlayStopTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_FILEPLAYBACK_OpenPlayRepositionPlayStopTes");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_FILEPLAYBACK_OpenPlayPauseRepositionTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_FILEPLAYBACK_OpenPlayPauseRepositionTest");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_FILEPLAYBACK_OpenPlayVerifyDurationTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_FILEPLAYBACK_OpenPlayVerifyDurationTest");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_Recorder_RecordOnStartUp:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_Recorder_RecordOnStartUp");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_Recorder_RecordOnDemand:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_Recorder_RecordOnDemand");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_Recorder_MultiplePause:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_Recorder_MultiplePause");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_Recorder_MultiplePauseJTL:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_Recorder_MultiplePauseJTL");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_Recorder_MultipleRepos:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_Recorder_MultipleRepos");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_Recorder_MultipleRecord:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_Recorder_MultipleRepos");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+
+            case PVR_MLB_StreamingOpenPlayLivePausePlayStopTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_MLB_StreamingOpenPlayLivePausePlayStopTest");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_MLB_StreamingOpenPlayLivePausePlaySeekStopTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_MLB_StreamingOpenPlayLivePausePlaySeekStopTest");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_MLB_StreamingOpenPlayLiveBufferBoundaryCheckTest:
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                fprintf(file, "PVR_MLB_StreamingOpenPlayLiveBufferBoundaryCheckTest");
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
+            case PVR_MLB_StreamingOpenPlayMultipleLivePausePlayTest:
+            case PVR_FSLB_StreamingOpenPlayMultipleLivePausePlayTest:
             {
-                fprintf(file, "GenericOpenPlaySeekBeyondClipDurationTest");
-                iCurrentTest =
-                    new pvplayer_async_test_genericopenplaystop(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
-                            iCurrentTestNumber,
-                            false,
-                            true,
-                            true,
-                            false,
-                            false);
-                pvplayer_async_test_genericopenplaystop* ptr =
-                    (pvplayer_async_test_genericopenplaystop*)iCurrentTest;
-                ptr->setProtocolRollOverMode();
-                ptr->setSeekBeyondClipDurationMode();
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPlayMultipleLivePausePlayTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPlayMultipleLivePausePlayTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPlayMultipleLivePausePlayTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                ptr->setMultiplePauseMode(5);
+
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest:
+            case PVR_FSLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                ptr->setMultiplePauseMode(5);
+                ptr->setRandomPauseDurationRange(10); // Duration range in seconds
+
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPlayLongLivePausePlayTest:
+            case PVR_FSLB_StreamingOpenPlayLongLivePausePlayTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPlayLongLivePausePlayTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPlayLongLivePausePlayTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPlayLongLivePausePlayTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                ptr->setLongPauseDuration(60*1000*1000);
+
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPlayLivePauseStopTest:
+            case PVR_FSLB_StreamingOpenPlayLivePauseStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPlayLivePauseStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPlayLivePauseStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPlayLivePauseStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPauseJumpToLiveStopTest:
+            case PVR_FSLB_StreamingOpenPauseJumpToLiveStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPauseJumpToLiveStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPauseJumpToLiveStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPauseJumpToLiveStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                ptr->setMultiplePauseMode(5);
+                ptr->setRandomPauseDurationRange(10); // Duration range in seconds
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPauseResumeJumpToLiveStopTest:
+            case PVR_FSLB_StreamingOpenPauseResumeJumpToLiveStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPauseResumeJumpToLiveStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPauseResumeJumpToLiveStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPauseResumeJumpToLiveStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                ptr->setMultiplePauseMode(5);
+                ptr->setRandomPauseDurationRange(10); // Duration range in seconds
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPauseResumeStopTest:
+            case PVR_FSLB_StreamingOpenPauseResumeStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingOpenPauseResumeStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPauseResumeStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPauseResumeStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+            case PVR_MLB_StreamingRTSPUrlPauseResumeStopTest:
+            case PVR_FSLB_StreamingRTSPUrlPauseResumeStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingRTSPUrlPauseResumeStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingRTSPUrlPauseResumeStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingRTSPUrlPauseResumeStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                ptr->setRtspUrlInput();
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingPauseResumeRepositionStopTest:
+            case PVR_FSLB_StreamingPauseResumeRepositionStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingPauseResumeRepositionStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingPauseResumeRepositionStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingPauseResumeRepositionStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingPauseRepositionResumeStopTest:
+            case PVR_FSLB_StreamingPauseRepositionResumeStopTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingPauseRepositionResumeStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingPauseRepositionResumeStopTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingPauseRepositionResumeStopTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+
+            case PVR_MLB_StreamingOpenPauseJmpToLiveChannelSwitchTest:
+            case PVR_FSLB_StreamingOpenPauseJmpToLiveChannelSwitchTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_FSLB_StreamingOpenPauseJmpToLiveChannelSwitchTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPauseJmpToLiveChannelSwitchTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPauseJmpToLiveChannelSwitchTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingOpenPlayLivePauseWaitForRTSPEOSResumeTest:
+            case PVR_FSLB_StreamingOpenPlayLivePauseWaitForRTSPEOSResumeTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingPauseRepositionResumeStopTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingOpenPlayLivePauseWaitForRTSPEOSResumeTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_FSLB_StreamingOpenPlayLivePauseWaitForRTSPEOSResumeTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+            }
+            break;
+
+            case PVR_MLB_StreamingBitrateEstimationTest:
+            {
+#if RUN_STREAMING_TESTCASES
+#if PVR_SUPPORT
+                if (PVR_MLB_StreamingBitrateEstimationTest == iCurrentTestNumber)
+                {
+                    fprintf(file, "PVR_MLB_StreamingBitrateEstimationTest");
+                }
+                else
+                {
+                    fprintf(file, "PVR_MLB_StreamingBitrateEstimationTest");
+                }
+                iCurrentTest = new pvplayer_async_test_pvr_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber);
+                pvplayer_async_test_pvr_streamingopenplaystop* ptr =
+                    (pvplayer_async_test_pvr_streamingopenplaystop*)iCurrentTest;
+                OSCL_UNUSED_ARG(ptr);
+#else
+                fprintf(file, "PVR tests not enabled\n");
+#endif
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
             }
             break;
 
@@ -6912,14 +7511,34 @@
                 fprintf(file, "Multi CPM tests not enabled\n");
                 break;
 
+            case StreamingLongPauseSeekTest:
+#if RUN_STREAMING_TESTCASES
+                iCurrentTest = new pvplayer_async_test_streamingopenplaystop(testparam,
+                        PVMF_MIME_YUV420,
+                        PVMF_MIME_PCM16,
+                        iCurrentTestNumber,
+                        true,
+                        false,
+                        false,
+                        false,
+                        false,
+                        false,
+                        false);
+                ((pvplayer_async_test_streamingopenplaystop*)iCurrentTest)->setPauseDurationInMS(2*60*1000);
+                ((pvplayer_async_test_streamingopenplaystop*)iCurrentTest)->setPauseSetPlayBackRangeResumeSequence();
+#else
+                fprintf(file, "Streaming tests not enabled\n");
+#endif
+                break;
+
             case ApplicationInvolvedTrackSelectionTestDefault:
             {
 #if RUN_APP_TRACK_SELECTION_TESTCASES
                 fprintf(file, "ApplicationInvolvedTrackSelectionTest");
                 iCurrentTest =
                     new pvplayer_async_test_apptrackselection(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -6940,8 +7559,8 @@
                 fprintf(file, "ApplicationInvolvedTrackSelectionTestPassthru");
                 iCurrentTest =
                     new pvplayer_async_test_apptrackselection(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -6962,8 +7581,8 @@
                 fprintf(file, "ApplicationInvolvedTrackSelectionTestAudioOnly");
                 iCurrentTest =
                     new pvplayer_async_test_apptrackselection(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -6984,8 +7603,8 @@
                 fprintf(file, "ApplicationInvolvedTrackSelectionTestVideoOnly");
                 iCurrentTest =
                     new pvplayer_async_test_apptrackselection(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -7006,8 +7625,8 @@
                 fprintf(file, "ApplicationInvolvedTrackSelectionTestTextOnly");
                 iCurrentTest =
                     new pvplayer_async_test_apptrackselection(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
@@ -7028,8 +7647,8 @@
                 fprintf(file, "ApplicationInvolvedTrackSelectionTestNoTracks");
                 iCurrentTest =
                     new pvplayer_async_test_apptrackselection(testparam,
-                            PVMF_YUV420,
-                            PVMF_PCM16,
+                            PVMF_MIME_YUV420,
+                            PVMF_MIME_PCM16,
                             iCurrentTestNumber,
                             false,
                             false,
diff --git a/engines/player/test/src/test_pv_player_engine.h b/engines/player/test/src/test_pv_player_engine.h
index f5f16d0..39491e9 100644
--- a/engines/player/test/src/test_pv_player_engine.h
+++ b/engines/player/test/src/test_pv_player_engine.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -96,20 +96,36 @@
 };
 
 
-typedef struct
+class PVPlayerAsyncTestParam
 {
-    pvplayer_async_test_observer* iObserver;
-    test_case* iTestCase;
-    FILE* iTestMsgOutputFile;
-    const char* iFileName;
-    PVMFFormatType iFileType;
-    bool iCompressedVideo;
-    bool iCompressedAudio;
-    bool iFileInput;
-    bool iBCS;
-    int iCurrentTestNumber;
-    bool iProxyEnabled;
-} PVPlayerAsyncTestParam;
+    public:
+        pvplayer_async_test_observer* iObserver;
+        test_case* iTestCase;
+        FILE* iTestMsgOutputFile;
+        const char* iFileName;
+        PVMFFormatType iFileType;
+        bool iCompressedVideo;
+        bool iCompressedAudio;
+        bool iFileInput;
+        bool iBCS;
+        int iCurrentTestNumber;
+        bool iProxyEnabled;
+        //explicit copy constructor
+        void Copy(const PVPlayerAsyncTestParam& aParam)
+        {
+            iObserver = aParam.iObserver;
+            iTestCase = aParam.iTestCase;
+            iTestMsgOutputFile = aParam.iTestMsgOutputFile;
+            iFileName = aParam.iFileName;
+            iFileType = aParam.iFileType;
+            iCompressedVideo = aParam.iCompressedVideo;
+            iCompressedAudio = aParam.iCompressedAudio;
+            iFileInput = aParam.iFileInput;
+            iBCS = aParam.iBCS;
+            iCurrentTestNumber = aParam.iCurrentTestNumber;
+            iProxyEnabled = aParam.iProxyEnabled;
+        }
+} ;
 
 #define PVPATB_TEST_IS_TRUE(condition) (iTestCase->test_is_true_stub( (condition), (#condition), __FILE__, __LINE__ ))
 
@@ -143,9 +159,9 @@
     STATE_REMOVEDATASINK_AUDIO,
     STATE_RESET,
     STATE_REMOVEDATASOURCE,
-    STATE_WAIT_FOR_ERROR_HANDLING,
     STATE_CLEANUPANDCOMPLETE,
-    STATE_PROTOCOLROLLOVER
+    STATE_PROTOCOLROLLOVER,
+    STATE_RECONNECT
 } PVTestState;
 
 /*!
@@ -159,12 +175,32 @@
         virtual ~PVPlayerTestMioFactory() {}
 
         virtual PvmiMIOControl* CreateAudioOutput(OsclAny* aParam) = 0;
+        virtual PvmiMIOControl* CreateAudioOutput(OsclAny* aParam, MediaType aMediaType, bool aCompressedAudio = false)
+        {
+            OSCL_UNUSED_ARG(aParam);
+            OSCL_UNUSED_ARG(aMediaType);
+            OSCL_UNUSED_ARG(aCompressedAudio);
+            return 0;
+        };
         virtual PvmiMIOControl* CreateAudioOutput(OsclAny* aParam, PVRefFileOutputTestObserver* aObserver, bool aActiveTiming, uint32 aQueueLimit, bool aSimFlowControl, bool logStrings = true) = 0;
         virtual void DestroyAudioOutput(PvmiMIOControl* aMio) = 0;
         virtual PvmiMIOControl* CreateVideoOutput(OsclAny* aParam) = 0;
+        virtual PvmiMIOControl* CreateVideoOutput(OsclAny* aParam, MediaType aMediaType, bool aCompressedVideo = false)
+        {
+            OSCL_UNUSED_ARG(aParam);
+            OSCL_UNUSED_ARG(aMediaType);
+            OSCL_UNUSED_ARG(aCompressedVideo);
+            return 0;
+        };
         virtual PvmiMIOControl* CreateVideoOutput(OsclAny* aParam, PVRefFileOutputTestObserver* aObserver, bool aActiveTiming, uint32 aQueueLimit, bool aSimFlowControl, bool logStrings = true) = 0;
         virtual void DestroyVideoOutput(PvmiMIOControl* aMio) = 0;
         virtual PvmiMIOControl* CreateTextOutput(OsclAny* aParam) = 0;
+        virtual PvmiMIOControl* CreateTextOutput(OsclAny* aParam, MediaType aMediaType)
+        {
+            OSCL_UNUSED_ARG(aParam);
+            OSCL_UNUSED_ARG(aMediaType);
+            return 0;
+        };
         virtual void DestroyTextOutput(PvmiMIOControl* aMio) = 0;
 };
 
@@ -229,15 +265,15 @@
             bool foundlastslash = false;
             while (!foundlastslash)
             {
-                oscl_wchar* tmp1 = oscl_strstr(lastslash, _STRLIT_WCHAR("\\"));
-                oscl_wchar* tmp2 = oscl_strstr(lastslash, _STRLIT_WCHAR("/"));
+                const oscl_wchar* tmp1 = oscl_strstr(lastslash, _STRLIT_WCHAR("\\"));
+                const oscl_wchar* tmp2 = oscl_strstr(lastslash, _STRLIT_WCHAR("/"));
                 if (tmp1 != NULL)
                 {
-                    lastslash = tmp1 + 1;
+                    lastslash = (oscl_wchar*)tmp1 + 1;
                 }
                 else if (tmp2 != NULL)
                 {
-                    lastslash = tmp2 + 1;
+                    lastslash = (oscl_wchar*)tmp2 + 1;
                 }
                 else
                 {
@@ -255,7 +291,7 @@
             bool finishedreplace = false;
             while (!finishedreplace)
             {
-                oscl_wchar* tmp = oscl_strstr(aFilename.get_cstr(), _STRLIT_WCHAR("."));
+                oscl_wchar* tmp = OSCL_CONST_CAST(oscl_wchar*, oscl_strstr(aFilename.get_cstr(), _STRLIT_WCHAR(".")));
                 if (tmp != NULL)
                 {
                     oscl_strncpy(tmp, _STRLIT_WCHAR("_"), 1);
@@ -401,7 +437,12 @@
             MediaIONodeBackwardForwardTest = 83,
             MediaIONodePauseNearEOSBackwardResumeTest,
             MediaIONodeMultiplePauseSetPlaybackRateResumeTest,
-            MediaIONodBackwardNearEOSForwardNearStartTest,
+            MediaIONodeBackwardNearEOSForwardNearStartTest,
+
+            MultiplePauseSeekResumeTest = 87,
+            MultipleSetStartPositionPlayStopTest,
+
+            OpenPlayStopResetCPMRecognizeTest = 89, //Start of testing recognizer using DataStream input
 
             LastLocalTest,//placeholder
 
@@ -439,6 +480,9 @@
             ProgPlaybackMP4StartPauseSeekResumeLoopTest, //156
             ProgPlaybackMP4SeekForwardStepLoopTest,	//157
             ProgPlaybackPlayStopPlayTest, //158
+            ProgPlaybackMP4SeekToBOCAfterDownloadCompleteTest, //159
+            ProgPlaybackMP4SeekInCacheAfterDownloadCompleteTest, //160
+            ProgPlaybackMP4EOSStopPlayAgainTest, //161
 
             LastProgressivePlaybackTest, //placeholder
 
@@ -451,6 +495,12 @@
 
             LastStreamingTest, //placeholder
 
+            //Multiple Instance tests.
+            MultipleInstanceOpenPlayStopTest = 300,
+            MultipleThreadOpenPlayStopTest = 301,
+            //this range reserved for future multiple instance tests.
+            LastMultipleInstanceTest = 325,//placeholder
+
             FirstProjTest = 700, // placeholder
             // Project specific unit tests should have numbers 701 to 799
             LastProjTest = 799,
@@ -460,6 +510,7 @@
             PrintMetadataTest = 801,
             PrintMemStatsTest,
             PlayUntilEOSTest,
+            ReleaseMetadataTest,
 
             StreamingOpenPlayUntilEOSTest = 851,//851
             StreamingOpenPlayPausePlayUntilEOSTest,//852
@@ -473,6 +524,13 @@
             StreamingProtocolRollOverTestWithUnknownURLType, //860
             StreamingPlayListSeekTest, //861
             StreamingSeekAfterEOSTest, //862
+            /*
+             * TC 863: This test case checks the engine behavior when the server responds
+             * with any of the following error codes - 404 (URL Not Found), 415 (Media Unsupported),
+             * 457 (Invalid Range). In all cases, the test should not error out, and complete as in TC 861
+             */
+            StreamingPlayListErrorCodeTest, // 863
+            StreamingOpenPlayMultipleSeekToEndOfClipUntilEOSTest, //864
 
 
             StreamingOpenPlayMultiplePausePlayUntilEOSTest = 875, //875
@@ -485,7 +543,8 @@
             CPM_DLA_OMA1PASSTRHU_OpenPlayStopResetTest, //880
             CPM_DLA_OMA1PASSTRHU_UnknownContentOpenPlayStopResetTest, //881
 
-            //882-888 available
+            StreamingOpenPlayUntilEOSTestWithFileHandle,//882
+            //883-888 available
 
             //GetLicense returns commandCompleted before CancelLic could be triggered
             CPM_DLA_OMA1PASSTRHU_CancelAcquireLicenseTooLate_CancelFails = 889, //889
@@ -497,6 +556,7 @@
 
             //Multiple CPM Plugins
             OpenPlayStop_MultiCPMTest, //893
+            StreamingLongPauseSeekTest,	//894
 
             GenericReset_AddDataSource = 900,
             GenericReset_Init,
@@ -643,10 +703,6 @@
             GenericOpenPlayStop_SleepAddDataSinkAudio,
             GenericOpenPlayStop_SleepPrepare,
             GenericOpenPlayStop_SleepGetMetaDataValueList,
-            GenericOpenPlayStop_SleepStart,
-            GenericOpenPlayStop_SleepPause,
-            GenericOpenPlayStop_SleepResume,
-            GenericOpenPlayStop_SleepSetPlaybackRange,
             GenericOpenPlayStop_SleepStop,
 
             GenericOpenPlayPauseResumeSeekStopProfiling = 1125,
@@ -793,10 +849,6 @@
             DLA_StreamingOpenPlayStop_SleepAddDataSinkVideo,
             DLA_StreamingOpenPlayStop_SleepAddDataSinkAudio,
             DLA_StreamingOpenPlayStop_SleepPrepare,
-            DLA_StreamingOpenPlayStop_SleepStart,
-            DLA_StreamingOpenPlayStop_SleepPause,
-            DLA_StreamingOpenPlayStop_SleepResume,
-            DLA_StreamingOpenPlayStop_SleepSetPlaybackRange,
             DLA_StreamingOpenPlayStop_SleepStop = 1301,
             //END JANUS CPM TESTS
 
@@ -812,7 +864,6 @@
             ApplicationInvolvedTrackSelectionTestTextOnly = 1307,
             ApplicationInvolvedTrackSelectionTestNoTracks = 1308,
 
-            //BEGIN Jupiter CPM Tests
             //Metadata Query tests
             DLA_QueryEngine_JupiterCPMTest_v2_WMA = 1400,
             DLA_QueryEngine_JupiterCPMTest_v24_WMA,//1401
@@ -837,11 +888,11 @@
             //Special license protocol sequence tests
             DLA_OpenPlayStop_JupiterCPMTest_redirect,//1418
             DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_fallback,//1419
-            DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_ringtone,//1420
-            DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain,//1421
-            DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain_renew,//1422
-            DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain_offline,//1423
-            DLA_OpenPlayStop_JupiterCPMTest_v24_WMA_domain_history,//1424
+            DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_ringtone,//1420
+            DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain,//1421
+            DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain_renew,//1422
+            DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain_offline,//1423
+            DLA_OpenPlayStop_JupiterCPMTest_v4_WMA_domain_history,//1424
             //Jupiter utility tests
             DLA_JoinDomain_JupiterCPMTest,//1425
             DLA_LeaveDomain_JupiterCPMTest,//1426
@@ -866,11 +917,362 @@
             DLA_StreamingProtocolRollOverTest_JupiterCPMTest,//1443
             DLA_StreamingProtocolRollOverTestWithUnknownURLType_JupiterCPMTest,//1444
             //RESERVED FOR FUTURE JUPITER CPM TESTS.
-            LastJupiterCPMTest = 1600,//placeholder
+            LastJupiterCPMTest = 1599,//placeholder
             //End JUPITER CPM TESTS.
+            /*
+             * Note: Starting PVR tests from 1600 since the number of tests exceed the range
+             * from 895 and 900 (the earlier location of the tests)
+             */
+            /*
+             * =========== Basic PVR tests ===========
+             */
+
+            /*
+             * 1600:        Play->pause->resume->stop test
+             * Description: Self-explanatory
+             */
+
+            /**
+            PVR Memory Live Buffer tests start at 1600
+            */
+
+            PVR_MLB_StreamingOpenPlayLivePausePlayStopTest = 1600,//1600
+            PVR_MLB_StreamingOpenPlayLivePausePlaySeekStopTest,//1601
+            PVR_MLB_StreamingOpenPlayLiveBufferBoundaryCheckTest,//1602
+            /*
+             * 1601:        Reposition after a play pause
+             * Description: See TC 1611
+             */
+
+            /*
+             * 1602:        Check live buffer boundary
+             * Description: To maintain TC numbers, this test case
+             *              does a play followed by a stop.
+             */
+
+            /*
+             * =========== Live pause tests ===========
+             */
+
+            /*
+             * 1603:        Quick successive pause/resume
+             * Description: This test case will call pause/resume in a quick and
+             *              repetitive sequence to test quick successive pause/resume stress condition.
+             * Input:       1. repeat count
+             */
+            PVR_MLB_StreamingOpenPlayMultipleLivePausePlayTest,//1603
+            /*
+             * 1604:        Pause with random duration
+             * Description: This test case will call pause/resume repeatedly.
+             *              Each pause has random duration in a range.
+             * Inputs:      1. repeat count.
+             *              2. pause duration range
+             */
+            PVR_MLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest,//1604
+            /*
+             * 1605:        Long pause
+             * Description: This test case will pause long period of time (> live buffer duration)
+             * Input:       1. pause duration
+             */
+            PVR_MLB_StreamingOpenPlayLongLivePausePlayTest,//1605
+            /*
+             * 1606:        Stop during live pause
+             * Description: This test case stop the session during live pause.
+             *              Then it starts the same session again.
+             */
+            PVR_MLB_StreamingOpenPlayLivePauseStopTest,//1606
+
+            /*
+             * =========== Random position tests ===========
+             */
+
+            /*
+             * 1607:        Jump to live after pause
+             * Description: This test case jumps to live session (not buffer) after a pause.
+             *				The above step is repeated several times, after pausing for a random duration.
+             * Inputs:      1. Repeat count
+             *              2. Pause duration range
+             */
+            PVR_MLB_StreamingOpenPauseJumpToLiveStopTest, //1607
+            /*
+             * 1608:        Jump to live after pause/resume
+             * Description: This test case pauses a live session for a random duration, resumes
+             *              a for random duration that is less than the pause duration, and then
+             *              jumps to live. This is repeated several times.
+             * Inputs:      1. Repeat count
+             *              2. Pause duration range
+             *              3. Resume duration range
+             */
+            PVR_MLB_StreamingOpenPauseResumeJumpToLiveStopTest, //1608
+            /*
+             * 1609:        Stop during playing back from live buffer
+             * Description: This test case pauses a live session for a random duration, resumes
+             *              and then stops the session while playing from the live buffer. The same
+             *              session is started after the stop.
+             */
+            PVR_MLB_StreamingOpenPauseResumeStopTest, //1609
+            /*
+             * 1610:        RTSP URL test
+             * Description: This test case uses an RTSP URL as the input for the streaming session.
+             *              Both live and VOD cases are handled.
+             */
+            PVR_MLB_StreamingRTSPUrlPauseResumeStopTest, //1610
+
+            /*
+             * 1611:        PVR Repositioning test
+             * Description: This test case does a sequence of repositioning requests within the live buffer.
+             *              The followed sequence is: start, pause, resume, repositioning sequence, stop.
+            				The repos. sequence consists of 6 repositioning requests back and forward.
+             */
+            PVR_MLB_StreamingPauseResumeRepositionStopTest, //1611
+
+            /*
+            * 1612:        PVR Repositioning test
+            * Description: This test case does a sequence of repositioning requests within the live buffer.
+            *              The followed sequence is: start, pause, repositioning, resume. This sequence is
+               			done six times, followed by a stop.
+            */
+            PVR_MLB_StreamingPauseRepositionResumeStopTest, //1612
+
+            /*
+             * 1613:        RTSP END_OF_STREAM test for memory live buffer.
+             * Description: This test is design to test the case where and RTSP END_OF_STREAM arrives
+             *              during a live pause. Total playback time must equal the cumulative playlist clip
+             *              duration.
+             * Input:
+             */
+            PVR_MLB_StreamingOpenPlayLivePauseWaitForRTSPEOSResumeTest = 1613,//1613
+
+
+            /*
+            * 1614:        PVR Playlist switch with a full live buffer after JTL
+            * Description: This test case makes a live pause it resumes once the live buffer gets full, and makes
+            *              a JTL followed by a channel switch, the channel switch time is measured.
+
+            */
+            PVR_MLB_StreamingOpenPauseJmpToLiveChannelSwitchTest, //1614
+
+
+
+            /*
+            * 1615       PVR Bitrate estimation test
+            * Description: Test case for mismatch between advertised and real bitrate,
+            *              the root of the problem with higher-than-advertised bitrates is that it
+            *              may cause overwrites in the LiveBuffer, which is then reflected in quality artifacts.
+            *
+            *              PLEASE USE A SDP FILE THAT ANOUNCES A SMALLER BITRATE THAN THE REAL ONE
+
+            */
+            PVR_MLB_StreamingBitrateEstimationTest = 1615,
+
+            /**
+            PVR FileSystem Live Buffer tests start at 1630
+            */
+            PVR_FSLB_StreamingOpenPlayLivePausePlayStopTest = 1630,//1630
+            PVR_FSLB_StreamingOpenPlayLivePausePlaySeekStopTest,//1631
+            PVR_FSLB_StreamingOpenPlayLiveBufferBoundaryCheckTest,//1632
+            /*
+             * =========== Live pause tests ===========
+             */
+
+            /*
+             * 1633:        Quick successive pause/resume
+             * Description: This test case will call pause/resume in a quick and
+             *              repetitive sequence to test quick successive pause/resume stress condition.
+             * Input:       1. repeat count
+             */
+            PVR_FSLB_StreamingOpenPlayMultipleLivePausePlayTest,//1633
+            /*
+             * 1634:        Pause with random duration
+             * Description: This test case will call pause/resume repeatedly.
+             *              Each pause has random duration in a range.
+             * Inputs:      1. repeat count.
+             *              2. pause duration range
+             */
+            PVR_FSLB_StreamingOpenPlayMultipleLivePauseRandomDurationPlayTest,//1634
+            /*
+             * 1635:        Long pause
+             * Description: This test case will pause long period of time (> live buffer duration)
+             * Input:       1. pause duration
+             */
+            PVR_FSLB_StreamingOpenPlayLongLivePausePlayTest,//1635
+            /*
+             * 1636:        Stop during live pause
+             * Description: This test case stop the session during live pause.
+             *              Then it starts the same session again.
+             */
+            PVR_FSLB_StreamingOpenPlayLivePauseStopTest,//1636
+
+            /*
+             * =========== Random position tests ===========
+             */
+
+            /*
+             * 1637:        Jump to live after pause
+             * Description: This test case jumps to live session (not buffer) after a pause.
+             *				The above step is repeated several times, after pausing for a random duration.
+             * Inputs:      1. Repeat count
+             *              2. Pause duration range
+             */
+            PVR_FSLB_StreamingOpenPauseJumpToLiveStopTest, //1637
+            /*
+             * 1638:        Jump to live after pause/resume
+             * Description: This test case pauses a live session for a random duration, resumes
+             *              a for random duration that is less than the pause duration, and then
+             *              jumps to live. This is repeated several times.
+             * Inputs:      1. Repeat count
+             *              2. Pause duration range
+             *              3. Resume duration range
+             */
+            PVR_FSLB_StreamingOpenPauseResumeJumpToLiveStopTest, //1638
+            /*
+             * 1639:        Stop during playing back from live buffer
+             * Description: This test case pauses a live session for a random duration, resumes
+             *              and then stops the session while playing from the live buffer. The same
+             *              session is started after the stop.
+             */
+            PVR_FSLB_StreamingOpenPauseResumeStopTest, //1639
+
+            /*
+             * 1640:        RTSP URL test
+             * Description: This test case uses an RTSP URL as the input for the streaming session.
+             *              Both live and VOD cases are handled.
+             */
+            PVR_FSLB_StreamingRTSPUrlPauseResumeStopTest, //1640
+
+            /*
+             * 1641:        PVR Repositioning test
+             * Description: This test case does a sequence of repositioning requests within the live buffer.
+             *              The followed sequence is: start, pause, resume, repositioning sequence, stop.
+            				The repos. sequence consists of 6 repositioning requests back and forward.
+             */
+            PVR_FSLB_StreamingPauseResumeRepositionStopTest, //1641
+
+            /*
+            * 1642:        PVR Repositioning test
+            * Description: This test case does a sequence of repositioning requests within the live buffer.
+            *              The followed sequence is: start, pause, repositioning, resume. This sequence is
+               			done six times, followed by a stop.
+            */
+            PVR_FSLB_StreamingPauseRepositionResumeStopTest, //1642
+
+            /*
+            * 1643:        RTSP END_OF_STREAM test for file system live buffer.
+            * Description: Same as 1643.
+            * Input:
+            */
+
+            PVR_FSLB_StreamingOpenPlayLivePauseWaitForRTSPEOSResumeTest, //1643
+
+            /*
+            * 1644:        PVR Playlist switch with a full live buffer after JTL
+            * Description: This test case makes a live pause it resumes once the live buffer gets full, and makes
+            *              a JTL followed by a channel switch, the channel switch time is measured.
+
+            */
+            PVR_FSLB_StreamingOpenPauseJmpToLiveChannelSwitchTest, //1644
+
+
+            /**
+            PVR local file playback tests start at 1660
+            */
+
+            PVR_FILEPLAYBACK_OpenPlayUntilEOFTest = 1660,// 1660
+
+            /*
+            * 1661       PVR Local Playback Open-Play-Reposition-Play-Stop
+            * Description: This test case plays a local pvr file for 10 seconds, then
+            *              it repositions to 50, 75, 40, 0, 60 and 95% of the local file
+            *              and then it stops playback.
+            *
+
+            */
+
+            PVR_FILEPLAYBACK_OpenPlayRepositionPlayStopTest,  // 1661
+
+
+            /*
+            * 1662       PVR Local Playback Open-Play-Pause-Reposition
+            * Description: This test case plays a local pvr file for 10 seconds, then pauses playback
+            *              it repositions to 50, 75, 40, 0, 60 and 95% of the local file
+            *              and then it stops playback.
+            *
+
+            */
+
+            PVR_FILEPLAYBACK_OpenPlayPauseRepositionTest,  // 1662
+
+            /*
+            * 1663       PVR Local Playback Retrieved duration is correct
+            * Description: This test case plays a local pvr file for 3 seconds and
+            *              verifies if the retrieved duration is correct
+            *
+
+            */
+
+            PVR_FILEPLAYBACK_OpenPlayVerifyDurationTest,  // 1663
+
+
+
+
+            /*===========================PVR Recorder Test cases============================*/
+
+            /*
+            * 1680       PVR_Recorder_RecordOnStartUp
+            * Description: - Recording will start from NPT zero until playback is stopped.
+            *              - Pass criteria will be: No playback or recording errors.
+            */
+
+            PVR_Recorder_RecordOnStartUp = 1680,
+
+            /*
+            * 1681       PVR_Recorder_RecordOnDemand
+            * Description: - Recording will start from an arbitrary NPT different than zero to a point before playback is stopped.
+            *              - Pass criteria will be: No playback or recording errors.
+            */
+
+            PVR_Recorder_RecordOnDemand,
+
+            /*
+            * 1682       PVR_Recorder_MultiplePause
+            * Description: - Recording will start from NPT zero.
+            *              - Multiple pause/resume resume will be performed
+            *              - Pass criteria will be: No playback or recording errors.
+            */
+
+            PVR_Recorder_MultiplePause,
+
+            /*
+            * 1683       PVR_Recorder_MultiplePauseJTL
+            * Description: - Recording will start from NPT zero.
+            *              - Multiple pause/resume will be performed
+            *              - After last pause JTL
+            *              - Pass criteria will be: No playback or recording errors.
+            */
+
+            PVR_Recorder_MultiplePauseJTL,
+
+            /*
+            * 1684       PVR_Recorder_MultipleRepos
+            * Description: - Recording will start from NPT zero.
+            *              - Multiple Reposition/resume will be performed
+            *              - Pass criteria will be: No playback or recording errors.
+            */
+
+            PVR_Recorder_MultipleRepos,
+
+            /*
+            * 1685       PVR_Recorder_MultipleRecord
+            * Description: - Recording will start from an arbitrary NPT different than zero.
+            *              - Multiple StartRecord/StopRecord will be performed
+            *              - Pass criteria will be: No playback or recording errors
+            */
+
+            PVR_Recorder_MultipleRecord,
 
             LastInteractiveTest = 2000, // placeholder
 
+
             BeyondLastTest = 9999 //placeholder
         };
 
diff --git a/engines/player/test/src/test_pv_player_engine_testset1.cpp b/engines/player/test/src/test_pv_player_engine_testset1.cpp
index c64d7ec..96cefd3 100644
--- a/engines/player/test/src/test_pv_player_engine_testset1.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset1.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -81,7 +81,21 @@
 
 #include "pvmi_media_io_fileoutput.h"
 #include "pv_media_output_node_factory.h"
+
+#ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
+#include "pvmf_source_context_data.h"
+#endif
+
+#ifndef PVMI_DATASTREAMSYNCINTERFACE_REF_FACTORY_H_INCLUDED
+#include "pvmi_datastreamsyncinterface_ref_factory.h"
+#endif
+
 extern FILE* file;
+
+#define MAX_AUDIO_TRACKS 256
+#define MAX_VIDEO_TRACKS 256
+
+
 //
 // pvplayer_async_test_newdelete section
 //
@@ -199,20 +213,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
 
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -228,20 +233,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -257,11 +253,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & SinkFileName, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -324,16 +319,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -426,8 +411,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -441,8 +426,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -456,8 +441,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -471,8 +456,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -486,8 +471,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -501,8 +486,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -516,8 +501,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -531,8 +516,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -546,8 +531,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -561,8 +546,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -576,8 +561,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -591,8 +576,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -656,43 +641,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_openplaystopreset::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        // do nothing
     }
-
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
         PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
@@ -809,10 +771,34 @@
                 break;
             }
 
-            //Create a data source with the CPM usage flag set.
             bool useCPM = true;
-            iLocalDataSource = new PVMFLocalDataSource(useCPM);
-            iDataSource->SetDataSourceContextData((OsclAny*)iLocalDataSource);
+            if (iUsingDataStreamInput)
+            {
+                //Create a data stream factory for recognizer (a)
+                int32 leavecode = 0;
+                OSCL_TRY(leavecode, iDataStreamFactory = OSCL_STATIC_CAST(PVMFDataStreamFactory*, new PVMIDataStreamSyncInterfaceRefFactory(wFileName)));
+                OSCL_FIRST_CATCH_ANY(leavecode,
+                                     PVPATB_TEST_IS_TRUE(false);
+                                     iState = STATE_CLEANUPANDCOMPLETE;
+                                     RunIfNotReady();
+                                     break;
+                                    );
+
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->CommonData()->iUseCPMPluginRegistry    = useCPM;
+                iSourceContextData->CommonData()->iRecognizerDataStreamFactory = iDataStreamFactory;
+
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+            }
+            else
+            {
+                //Create a data source with the CPM usage flag set.
+                iLocalDataSource = new PVMFLocalDataSource(useCPM);
+
+                iDataSource->SetDataSourceContextData((OsclAny*)iLocalDataSource);
+            }
+
 
             //Add the data source
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
@@ -838,18 +824,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -866,19 +845,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -894,11 +865,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & SinkFileName, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -961,16 +932,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -982,6 +943,12 @@
             delete iDataSinkVideo;
             iDataSinkVideo = NULL;
 
+            delete iDataStreamFactory;
+            iDataStreamFactory = NULL;
+
+            delete iSourceContextData;
+            iSourceContextData = NULL;
+
             PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
             iIONodeVideo = NULL;
 
@@ -1076,8 +1043,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1091,8 +1058,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1106,8 +1073,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1121,8 +1088,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1136,8 +1103,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1151,8 +1118,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1166,8 +1133,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1181,8 +1148,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1196,8 +1163,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1211,8 +1178,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1226,8 +1193,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1241,8 +1208,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1306,43 +1273,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_cpmopenplaystopreset::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        // do nothing
     }
-
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
         PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
@@ -1481,7 +1425,6 @@
                         errorbitarray |= 0x1;
                     }
                     break;
-
                 default:
                     // Unknown value type so can't compare
                     errorbitarray |= 0x4;
@@ -1664,13 +1607,6 @@
                     }
                     break;
 
-                case PVMI_KVPVALTYPE_UINT8:
-                    if (aValueList[i].value.uint8_value != METADATA_DURATION_VALUE)
-                    {
-                        errorbitarray |= 0x1;
-                    }
-                    break;
-
                 default:
                     // Unknown value type so can't compare
                     errorbitarray |= 0x4;
@@ -1768,13 +1704,6 @@
                     }
                     break;
 
-                case PVMI_KVPVALTYPE_UINT8:
-                    if (aValueList[i].value.uint8_value != METADATA_TRACKINFODURATION0_VALUE)
-                    {
-                        errorbitarray |= 0x1;
-                    }
-                    break;
-
                 default:
                     // Unknown value type so can't compare
                     errorbitarray |= 0x4;
@@ -1801,13 +1730,6 @@
                     }
                     break;
 
-                case PVMI_KVPVALTYPE_UINT8:
-                    if (aValueList[i].value.uint8_value != METADATA_TRACKINFODURATION1_VALUE)
-                    {
-                        errorbitarray |= 0x1;
-                    }
-                    break;
-
                 default:
                     // Unknown value type so can't compare
                     errorbitarray |= 0x4;
@@ -1834,13 +1756,6 @@
                     }
                     break;
 
-                case PVMI_KVPVALTYPE_UINT8:
-                    if (aValueList[i].value.uint8_value != METADATA_TRACKINFOBITRATE0_VALUE)
-                    {
-                        errorbitarray |= 0x1;
-                    }
-                    break;
-
                 default:
                     // Unknown value type so can't compare
                     errorbitarray |= 0x4;
@@ -1867,13 +1782,6 @@
                     }
                     break;
 
-                case PVMI_KVPVALTYPE_UINT8:
-                    if (aValueList[i].value.uint8_value != METADATA_TRACKINFOBITRATE1_VALUE)
-                    {
-                        errorbitarray |= 0x1;
-                    }
-                    break;
-
                 default:
                     // Unknown value type so can't compare
                     errorbitarray |= 0x4;
@@ -2129,7 +2037,7 @@
             sourcefile += _STRLIT_WCHAR("test_metadata.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -2167,18 +2075,12 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_metadata_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -2189,19 +2091,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_metadata_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -2324,16 +2218,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -2417,8 +2301,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2432,8 +2316,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2447,8 +2331,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2489,8 +2373,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2504,8 +2388,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2519,8 +2403,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2534,8 +2418,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2549,8 +2433,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2590,8 +2474,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2605,8 +2489,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2621,8 +2505,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2646,8 +2530,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2671,8 +2555,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2686,8 +2570,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2701,8 +2585,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2716,8 +2600,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2757,8 +2641,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2772,8 +2656,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2787,8 +2671,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2802,8 +2686,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2867,41 +2751,19 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_metadata::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -2973,18 +2835,12 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_timing_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -2995,19 +2851,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_timing_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -3444,7 +3292,7 @@
             sourcefile += _STRLIT_WCHAR("test.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -3476,18 +3324,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_invalid_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3499,20 +3340,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_invalid_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -3872,14 +3704,16 @@
         case STATE_STARTED_INVALID_RESUME:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                // Invalid call. Should not succeed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_CLEANUPANDCOMPLETE;
+                // Invalid Call, resume should not be called in Started state but engine will return
+                // command success to Resume if its already in a started state.
+                iState = STATE_STARTED_INVALID_PREPARE;
                 RunIfNotReady();
             }
             else
             {
-                iState = STATE_STARTED_INVALID_PREPARE;
+                // Command failed. Resume should not fail if engine is already in started state.
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
                 RunIfNotReady();
             }
             break;
@@ -4112,7 +3946,7 @@
             sourcefile += _STRLIT_WCHAR("test.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -4130,18 +3964,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_preparedstop_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -4153,19 +3980,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_preparedstop_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -4530,7 +4349,7 @@
             sourcefile += _STRLIT_WCHAR("test.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -4548,18 +4367,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_videoonly7s_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -4854,8 +4665,17 @@
 }
 
 
-void pvplayer_async_test_videoonlyplay7seconds::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_videoonlyplay7seconds::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -4920,18 +4740,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playstop2times_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
@@ -4944,20 +4756,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playstop2times_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -5360,8 +5163,17 @@
 }
 
 
-void pvplayer_async_test_play5stopplay10stopreset::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_play5stopplay10stopreset::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -5426,18 +5238,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_pauseresume_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
@@ -5450,20 +5254,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_pauseresume_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -5844,8 +5639,17 @@
 }
 
 
-void pvplayer_async_test_pauseresume::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_pauseresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -5912,18 +5716,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playpausestop_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -5935,20 +5731,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playpausestop_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -6307,8 +6094,17 @@
 }
 
 
-void pvplayer_async_test_playpausestop::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_playpausestop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -6358,7 +6154,7 @@
             sourcefile += _STRLIT_WCHAR("test.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -6377,18 +6173,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_outsidevideosink_video.dat");
 
-            iMOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -6400,18 +6188,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_outsidevideosink_audio.dat");
 
-            iMOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -6750,13 +6530,23 @@
 }
 
 
-void pvplayer_async_test_outsidenodeforvideosink::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_outsidenodeforvideosink::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
 void pvplayer_async_test_outsidenodeforvideosink::NodeCommandCompleted(const PVMFCmdResp &aResponse)
 {
+    OSCL_UNUSED_ARG(aResponse);
 }
 
 
@@ -6803,7 +6593,7 @@
             sourcefile += _STRLIT_WCHAR("test.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -6821,18 +6611,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_getplayerstate_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -6844,20 +6627,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_getplayerstate_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -7381,8 +7155,17 @@
 }
 
 
-void pvplayer_async_test_getplayerstate::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_getplayerstate::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -7447,18 +7230,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_getcurrentposition_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -7470,19 +7245,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_getcurrentposition_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -7881,8 +7648,17 @@
 }
 
 
-void pvplayer_async_test_getcurrentposition::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_getcurrentposition::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -7929,7 +7705,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -7947,18 +7723,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetstopposition_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
@@ -7971,21 +7739,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetstopposition_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -8009,6 +7767,7 @@
         {
             PVPPlaybackPosition start, end;
             start.iIndeterminate = true;
+            start.iMode = PVPPBPOS_MODE_NOW;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_MILLISEC;
             end.iPosValue.millisec_value = 20000;
@@ -8361,6 +8120,15 @@
 
 void pvplayer_async_test_playsetstopposition::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -8430,7 +8198,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -8448,18 +8216,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetstoppositionvidframenum_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8471,20 +8232,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetstoppositionvidframenum_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -8508,6 +8260,7 @@
         {
             PVPPlaybackPosition start, end;
             start.iIndeterminate = true;
+            start.iMode = PVPPBPOS_MODE_NOW;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_SAMPLENUMBER;
             end.iPosValue.samplenum_value = 150;
@@ -8860,6 +8613,15 @@
 
 void pvplayer_async_test_playsetstoppositionvidframenum::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -8925,27 +8687,71 @@
         {
             PVMFFormatType fileType;
             iDataSource = new PVPlayerDataSourceURL;
+            OSCL_HeapString<OsclMemAllocator> filename;
+
             if (oscl_strstr(iFileName, "test.mp4") != NULL)
             {
-                wFileName = SOURCENAME_PREPEND_WSTRING;
-                wFileName += _STRLIT_WCHAR("test_reposition.mp4");
-                iFileType = PVMF_MPEG4FF;
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += _STRLIT_CHAR("test_reposition.mp4");
+                fileType = PVMF_MIME_MPEG4FF;
+                iFileType = PVMF_MIME_MPEG4FF;
             }
             else
             {
-                oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), output, 512);
-                wFileName.set(output, oscl_strlen(output));
-            }
-
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
-            {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-            }
-            else
-            {
+                filename = iFileName;
                 fileType = iFileType;
             }
+            fprintf(iTestMsgOutputFile, "***Source URL=%s\n", filename.get_str());
+            oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
+            wFileName.set(output, oscl_strlen(output));
 
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
+            {
+                fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+
+                    if (iProxyEnabled)
+                    {
+                        streamingContext->iProxyName = _STRLIT_WCHAR("63.215.241.33");
+                        streamingContext->iProxyPort = 7070;
+                    }
+
+                    streamingContext->iUserID = _STRLIT_CHAR("abc");
+                    streamingContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                }
+                iSourceContextData->EnableDownloadHTTPSourceContext();
+                sourceContext = NULL;
+                PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataDownloadHTTP* downloadContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                    if (iProxyEnabled)
+                    {
+                        downloadContext->iProxyName = _STRLIT_CHAR("63.215.241.33");
+                        downloadContext->iProxyPort = 7070;
+                    }
+                    downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                    downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                    downloadContext->iUserID = _STRLIT_CHAR("abc");
+                    downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                    downloadContext->bIsNewSession = true;
+                    downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    downloadContext->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
+                }
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+            }
             iDataSource->SetDataSourceURL(wFileName);
             iDataSource->SetDataSourceFormatType(fileType);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
@@ -8965,18 +8771,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setstartpositionplaystop_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8988,20 +8786,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setstartpositionplaystop_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -9012,6 +8801,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 10000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -9073,6 +8863,9 @@
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
             iPlayer = NULL;
 
+            delete iSourceContextData;
+            iSourceContextData = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -9204,6 +8997,7 @@
         case STATE_SETPLAYBACKRANGE:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                iNumSeek++;
                 iState = STATE_PREPARE;
                 RunIfNotReady();
             }
@@ -9249,8 +9043,16 @@
         case STATE_STOP:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
+                if (iTargetNumSeek != iNumSeek)
+                {
+                    iState = STATE_SETPLAYBACKRANGE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    iState = STATE_REMOVEDATASINK_VIDEO;
+                    RunIfNotReady();
+                }
             }
             else
             {
@@ -9366,8 +9168,68 @@
 }
 
 
-void pvplayer_async_test_setstartpositionplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_setstartpositionplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+    // Check for end of clip event
+    if (aEvent.GetEventType() == PVMFInfoEndOfData)
+    {
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface == NULL)
+        {
+            return;
+        }
+        PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+        PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+        if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+        {
+            int32 infocode;
+            PVUuid infouuid;
+            infomsgiface->GetCodeUUID(infocode, infouuid);
+            if ((infouuid == PVPlayerErrorInfoEventTypesUUID) && (infocode == PVPlayerInfoEndOfClipReached))
+            {
+                iState = STATE_STOP;
+                Cancel();
+                RunIfNotReady();
+            }
+        }
+    }
+    else if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
+    {
+        // source rollover...
+        fprintf(iTestMsgOutputFile, "###PVMFInfoSourceFormatNotSupported...\n");
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface != NULL)
+        {
+            PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+            PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+            if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+            {
+                int32 infocode;
+                PVUuid infouuid;
+                infomsgiface->GetCodeUUID(infocode, infouuid);
+                if ((infouuid == PVPlayerErrorInfoEventTypesUUID) &&
+                        (infocode == PVPlayerInfoAttemptingSourceRollOver))
+                {
+                    uint8* localBuf = aEvent.GetLocalBuffer();
+                    if (localBuf != NULL)
+                    {
+                        uint32 srcFormat = 0;
+                        oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                    }
+                }
+            }
+        }
+    }
 }
 
 
@@ -9414,7 +9276,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -9432,18 +9294,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplayrangeplay_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -9455,19 +9309,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplayrangeplay_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -9478,6 +9324,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 10000;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_MILLISEC;
@@ -9845,6 +9692,15 @@
 
 void pvplayer_async_test_setplayrangeplay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -9914,7 +9770,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -9932,18 +9788,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplayrangevidframenumplay_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -9955,20 +9803,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplayrangevidframenumplay_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -9979,6 +9818,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SAMPLENUMBER;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.samplenum_value = 100;
             end.iIndeterminate = false;
 #if 1
@@ -10352,6 +10192,15 @@
 
 void pvplayer_async_test_setplayrangevidframenumplay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -10421,7 +10270,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -10439,20 +10288,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetplayrangestop_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
 
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -10463,20 +10303,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetplayrangestop_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -10501,6 +10332,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -10842,8 +10674,17 @@
 }
 
 
-void pvplayer_async_test_playsetplayrangestop::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_playsetplayrangestop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -10891,7 +10732,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -10909,19 +10750,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetplayrangevidframenumstop_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10933,20 +10765,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_playsetplayrangevidframenumstop_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -10971,6 +10794,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SAMPLENUMBER;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.samplenum_value = 100;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -11312,8 +11136,17 @@
 }
 
 
-void pvplayer_async_test_playsetplayrangevidframenumstop::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_playsetplayrangevidframenumstop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -11388,19 +11221,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_tracklevelinfo_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -11412,19 +11236,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_tracklevelinfo_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -11463,220 +11279,209 @@
                 break;
             }
 
-            int32 vididx = -1;
-            int32 audidx = -1;
+            uint32 audioTrackID[MAX_AUDIO_TRACKS];
+            uint32 videoTrackID[MAX_VIDEO_TRACKS];
+
+            oscl_memset(audioTrackID, '\0', MAX_AUDIO_TRACKS);
+            oscl_memset(videoTrackID, '\0', MAX_VIDEO_TRACKS);
+
+            uint32 audioTrackCnt = 0;
+            uint32 videoTrackCnt = 0;
+
             for (uint32 i = 0; i < availabletracks.size(); ++i)
             {
-                switch (GetMediaTypeIndex(GetFormatIndex(availabletracks[i].getTrackMimeType().get_str())))
+                PVMFFormatType Format = availabletracks[i].getTrackMimeType().get_str();
+                if (Format.isAudio())
                 {
-                    case PVMF_COMPRESSED_AUDIO_FORMAT:
-                    case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-                        audidx = (int32)i;
-                        break;
-
-                    case PVMF_COMPRESSED_VIDEO_FORMAT:
-                    case PVMF_UNCOMPRESSED_VIDEO_FORMAT:
-                    case PVMF_IMAGE_FORMAT:
-                        vididx = (int32)i;
-                        break;
-
-                    default:
-                        break;
+                    audioTrackID[audioTrackCnt++] = i;
                 }
-            }
-
-            if (vididx == -1 || audidx == -1)
-            {
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
+                else if (Format.isVideo() || Format.isImage())
+                {
+                    videoTrackID[videoTrackCnt++] = i;
+                }
             }
 
             // Check the video track info
+            PVMFTimestamp samplets = 0;
+            uint32 samplenum = 0;
             int32 numsyncsamples = 0;
-            if (iTrackLevelInfoIF->GetNumberOfSyncSamples(availabletracks[vididx], numsyncsamples) != PVMFSuccess)
-            {
-                PVPATB_TEST_IS_TRUE(false);
-            }
-            else
-            {
-                // Check the number of sync samples
-                if (!(oscl_strcmp(iFileName, "test_tracklevelinfo.mp4")))
-                    PVPATB_TEST_IS_TRUE(numsyncsamples == 6);
-            }
-
             PVMFSampleNumTSList syncnumtslist;
-            int32 aTargetTimeInMS = 35000;
-            int32 EndIdx = 2;
-            uint32 howManySamples = 2, startIdx = 3;
-            if (iTrackLevelInfoIF->GetSyncSampleInfo(syncnumtslist, availabletracks[vididx], aTargetTimeInMS, howManySamples) != PVMFSuccess)
-            {
-                PVPATB_TEST_IS_TRUE(false);
-            }
 
-            if (iTrackLevelInfoIF->GetSyncSampleInfo(availabletracks[vididx], syncnumtslist, startIdx, EndIdx) != PVMFSuccess)
+            // There is reason to fail the test case just 'cos a clip doesnt have audio or video.
+            // Below loops of getting audio or video sample info will not be executed anyways if videoTrackCnt or audioTrackCnt are 0.
+
+            for (uint32 j = 0; j < videoTrackCnt; j++)
             {
-                PVPATB_TEST_IS_TRUE(false);
-            }
-            else
-            {
-                // Check the returned info on sync samples
+                uint32 tempID = videoTrackID[j];
+                if (iTrackLevelInfoIF->GetNumberOfSyncSamples(availabletracks[tempID], numsyncsamples) != PVMFSuccess)
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                }
+                else
+                {
+                    // Check the number of sync samples
+                    if (!(oscl_strcmp(iFileName, "test_tracklevelinfo.mp4")))
+                        PVPATB_TEST_IS_TRUE(numsyncsamples == 6);
+                }
+
+                int32 aTargetTimeInMS = 35000;
+                int32 EndIdx = 2;
+                uint32 howManySamples = 2, startIdx = 3;
+                if (iTrackLevelInfoIF->GetSyncSampleInfo(syncnumtslist, availabletracks[tempID], aTargetTimeInMS, howManySamples) != PVMFSuccess)
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                }
+
+                if (iTrackLevelInfoIF->GetSyncSampleInfo(availabletracks[tempID], syncnumtslist, startIdx, EndIdx) != PVMFSuccess)
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                }
+                else
+                {
+                    // Check the returned info on sync samples
+                    if (!(oscl_strcmp(iFileName, "test_tracklevelinfo.mp4")))
+                    {
+                        PVPATB_TEST_IS_TRUE(syncnumtslist[0].iSampleNumber == 256);
+                        PVPATB_TEST_IS_TRUE(syncnumtslist[0].iTimestamp == 22250);
+                        PVPATB_TEST_IS_TRUE(syncnumtslist[1].iSampleNumber == 331);
+                        PVPATB_TEST_IS_TRUE(syncnumtslist[1].iTimestamp == 32333);
+                    }
+                }
+
                 if (!(oscl_strcmp(iFileName, "test_tracklevelinfo.mp4")))
                 {
-                    PVPATB_TEST_IS_TRUE(syncnumtslist[0].iSampleNumber == 257);
-                    PVPATB_TEST_IS_TRUE(syncnumtslist[0].iTimestamp == 22416);
-                    PVPATB_TEST_IS_TRUE(syncnumtslist[1].iSampleNumber == 332);
-                    PVPATB_TEST_IS_TRUE(syncnumtslist[1].iTimestamp == 32500);
+                    PVMFTimestamp samplets = 0;
+                    if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[tempID], 100, samplets) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplets == 8416);
+                    }
+
+                    samplets = 0;
+                    if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[tempID], 361, samplets) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplets == 36166);
+                    }
+
+                    samplets = 0;
+                    if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[tempID], 600, samplets) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(true);
+                    }
+                    else
+                    {
+                        // Beyond the last sample so the call should fail
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+
+                    uint32 samplenum = 0;
+                    if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[tempID], 5700, samplenum) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplenum == 67);
+                    }
+
+                    samplenum = 0;
+                    if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[tempID], 12000, samplenum) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplenum == 143);
+                    }
+
+                    samplenum = 0;
+                    if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[tempID], 45000, samplenum) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        // Beyond the duration of track so sample number should be the (last sample+1)
+                        PVPATB_TEST_IS_TRUE(samplenum == 409);
+                    }
                 }
             }
 
-            if (!(oscl_strcmp(iFileName, "test_tracklevelinfo.mp4")))
+            for (uint32 k = 0; k < audioTrackCnt; k++)
             {
-                PVMFTimestamp samplets = 0;
-                if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[vididx], 100, samplets) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplets == 8416);
-                }
-
-                samplets = 0;
-                if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[vididx], 361, samplets) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplets == 36166);
-                }
-
-                samplets = 0;
-                if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[vididx], 600, samplets) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(true);
-                }
-                else
-                {
-                    // Beyond the last sample so the call should fail
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-
-                uint32 samplenum = 0;
-                if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[vididx], 5700, samplenum) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplenum == 67);
-                }
-
-                samplenum = 0;
-                if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[vididx], 12000, samplenum) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplenum == 143);
-                }
-
-                samplenum = 0;
-                if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[vididx], 45000, samplenum) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    // Beyond the duration of track so sample number should be the (last sample+1)
-                    PVPATB_TEST_IS_TRUE(samplenum == 409);
-                }
-
                 // Check the audio track info
                 numsyncsamples = 0;
-                if (iTrackLevelInfoIF->GetNumberOfSyncSamples(availabletracks[audidx], numsyncsamples) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    // For AMR audio, all samples should be sync samples
-                    PVPATB_TEST_IS_TRUE(numsyncsamples == -1);
-                }
+                uint32 tempID = audioTrackID[k];
 
-                syncnumtslist.clear();
-                if (iTrackLevelInfoIF->GetSyncSampleInfo(availabletracks[audidx], syncnumtslist) != PVMFSuccess)
+                if (!(oscl_strcmp(iFileName, "test_tracklevelinfo.mp4")))
                 {
-                    PVPATB_TEST_IS_TRUE(true);
-                }
-                else
-                {
-                    // All samples are sync samples so the query should fail
-                    PVPATB_TEST_IS_TRUE(false);
-                }
+                    samplets = 0;
+                    if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[tempID], 33, samplets) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplets == 660);
+                    }
 
-                samplets = 0;
-                if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[audidx], 33, samplets) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplets == 660);
-                }
+                    samplets = 0;
+                    if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[tempID], 1483, samplets) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplets == 29660);
+                    }
 
-                samplets = 0;
-                if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[audidx], 1483, samplets) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplets == 29660);
-                }
+                    samplets = 0;
+                    if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[tempID], 2500, samplets) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(true);
+                    }
+                    else
+                    {
+                        // Beyond the last sample so query should fail
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
 
-                samplets = 0;
-                if (iTrackLevelInfoIF->GetTimestampForSampleNumber(availabletracks[audidx], 2500, samplets) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(true);
-                }
-                else
-                {
-                    // Beyond the last sample so query should fail
-                    PVPATB_TEST_IS_TRUE(false);
-                }
+                    samplenum = 0;
+                    if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[tempID], 844, samplenum) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplenum == 42);
+                    }
 
-                samplenum = 0;
-                if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[audidx], 844, samplenum) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplenum == 42);
-                }
+                    samplenum = 0;
+                    if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[tempID], 12100, samplenum) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplenum == 605);
+                    }
 
-                samplenum = 0;
-                if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[audidx], 12100, samplenum) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplenum == 605);
-                }
-
-                samplenum = 0;
-                if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[audidx], 45000, samplenum) != PVMFSuccess)
-                {
-                    PVPATB_TEST_IS_TRUE(false);
-                }
-                else
-                {
-                    PVPATB_TEST_IS_TRUE(samplenum == 2120);
+                    samplenum = 0;
+                    if (iTrackLevelInfoIF->GetSampleNumberForTimestamp(availabletracks[tempID], 45000, samplenum) != PVMFSuccess)
+                    {
+                        PVPATB_TEST_IS_TRUE(false);
+                    }
+                    else
+                    {
+                        PVPATB_TEST_IS_TRUE(samplenum == 2120);
+                    }
                 }
             }
             iTrackLevelInfoIF->removeRef();
@@ -12066,8 +11871,17 @@
 }
 
 
-void pvplayer_async_test_tracklevelinfo::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_tracklevelinfo::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -12115,7 +11929,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -12133,20 +11947,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplaybackrate2x_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
 
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -12157,20 +11962,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplaybackrate2x_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -12530,8 +12326,17 @@
 }
 
 
-void pvplayer_async_test_setplaybackrate2X::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_setplaybackrate2X::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -12578,7 +12383,7 @@
             sourcefile += _STRLIT_WCHAR("test_reposition.mp4");
             iDataSource->SetDataSourceURL(sourcefile);
 
-            iDataSource->SetDataSourceFormatType(PVMF_MPEG4FF);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_MPEG4FF);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -12596,19 +12401,10 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplaybackratefifth_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -12620,20 +12416,11 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
             sinkfile += _STRLIT_WCHAR("test_player_setplaybackratefifth_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -12993,8 +12780,17 @@
 }
 
 
-void pvplayer_async_test_setplaybackratefifth::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_setplaybackratefifth::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -13058,18 +12854,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13082,20 +12870,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
             iCmdIds.push_back(iCurrentCmdId);
@@ -13344,8 +13123,17 @@
 }
 
 
-void pvplayer_async_test_queuedcommands::HandleInformationalEvent(const PVAsyncInformationalEvent& /*aEvent*/)
+void pvplayer_async_test_queuedcommands::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 }
 
 
@@ -13411,21 +13199,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
 
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
             iCmdIds.push_back(iCurrentCmdId);
@@ -13436,20 +13214,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
             iCmdIds.push_back(iCurrentCmdId);
@@ -13460,11 +13229,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & SinkFileName, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13485,6 +13253,7 @@
         {
             PVPPlaybackPosition start, end;
             start.iIndeterminate = true;
+            start.iMode = PVPPBPOS_MODE_NOW;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_MILLISEC;
             end.iPosValue.millisec_value = 10000;
@@ -13508,6 +13277,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_MILLISEC;
@@ -13795,6 +13565,15 @@
 
 void pvplayer_async_test_looping::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -13899,19 +13678,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
-
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13928,21 +13698,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -13958,11 +13718,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & SinkFileName, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -14358,6 +14118,15 @@
 
 void pvplayer_async_test_waitforeos::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -14446,18 +14215,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
@@ -14469,20 +14230,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -14493,11 +14245,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & SinkFileName, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
@@ -14635,16 +14387,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -14743,8 +14485,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14763,8 +14505,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14783,8 +14525,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14803,8 +14545,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14823,8 +14565,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14844,8 +14586,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14893,41 +14635,19 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_multipauseresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -15009,18 +14729,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
@@ -15032,20 +14744,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -15056,11 +14759,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & SinkFileName, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
@@ -15084,6 +14787,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -15103,6 +14807,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 5000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -15122,6 +14827,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 25000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -15141,6 +14847,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 10000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -15160,6 +14867,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -15179,6 +14887,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -15539,6 +15248,15 @@
 
 void pvplayer_async_test_multireposition::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check reposition time here
     if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
@@ -15628,7 +15346,7 @@
             querykey = _STRLIT_CHAR("x-pvmf/player;attr=cap");
             iPlayerCapConfigIF->getParametersSync(NULL, querykey.get_str(), retparam, retnumparam, NULL);
             // Just check the number of returned entries
-            if (retparam != NULL && retnumparam == 14)
+            if (retparam != NULL && retnumparam == 13)
             {
                 PVPATB_TEST_IS_TRUE(true);
 
@@ -15867,18 +15585,10 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -15895,20 +15605,11 @@
             SinkFileName += inputfilename;
             SinkFileName += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & SinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -16077,16 +15778,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -16170,8 +15861,8 @@
             {
                 // QueryInterface failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16185,8 +15876,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16200,8 +15891,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16215,8 +15906,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16230,8 +15921,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16245,8 +15936,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16260,8 +15951,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16275,8 +15966,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16290,8 +15981,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16305,8 +15996,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16320,8 +16011,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16385,41 +16076,19 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_capconfigiftest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -16484,11 +16153,75 @@
 
         case STATE_ADDDATASOURCE:
         {
+            PVMFFormatType fileType;
             iDataSource = new PVPlayerDataSourceURL;
-            oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), output, 512);
+            OSCL_HeapString<OsclMemAllocator> filename;
+
+            if (oscl_strstr(iFileName, "test.mp4") != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += _STRLIT_CHAR("test_reposition.mp4");
+                fileType = PVMF_MIME_MPEG4FF;
+                iFileType = PVMF_MIME_MPEG4FF;
+            }
+            else
+            {
+                filename = iFileName;
+                fileType = iFileType;
+            }
+            fprintf(iTestMsgOutputFile, "***Source URL=%s\n", filename.get_str());
+            oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
             wFileName.set(output, oscl_strlen(output));
+
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
+            {
+                fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+
+                    if (iProxyEnabled)
+                    {
+                        streamingContext->iProxyName = _STRLIT_WCHAR("63.215.241.33");
+                        streamingContext->iProxyPort = 7070;
+                    }
+
+                    streamingContext->iUserID = _STRLIT_CHAR("abc");
+                    streamingContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                }
+                iSourceContextData->EnableDownloadHTTPSourceContext();
+                sourceContext = NULL;
+                PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataDownloadHTTP* downloadContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                    if (iProxyEnabled)
+                    {
+                        downloadContext->iProxyName = _STRLIT_CHAR("63.215.241.33");
+                        downloadContext->iProxyPort = 7070;
+                    }
+                    downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                    downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                    downloadContext->iUserID = _STRLIT_CHAR("abc");
+                    downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                    downloadContext->bIsNewSession = true;
+                    downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    downloadContext->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
+                }
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+            }
             iDataSource->SetDataSourceURL(wFileName);
-            iDataSource->SetDataSourceFormatType(iFileType);
+            iDataSource->SetDataSourceFormatType(fileType);
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -16505,114 +16238,41 @@
 
         case STATE_ADDDATASINK_VIDEO:
         {
-#ifdef USE_REF_FILEOUTPUT_FOR_VIDEO
-
-            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
-            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
-            sinkfilename += _STRLIT_WCHAR("test_player_setplaybackafterprepare_");
-            if (iCompressedVideo)
-            {
-                sinkfilename += _STRLIT_WCHAR("compressed_");
-            }
+            OSCL_wHeapString<OsclMemAllocator> SinkFileName;
+            SinkFileName = OUTPUTNAME_PREPEND_WSTRING;
+            SinkFileName += _STRLIT_WCHAR("test_player_setplaybackafterprepare_");
             OSCL_wHeapString<OsclMemAllocator> inputfilename;
             RetrieveFilename(wFileName.get_str(), inputfilename);
-            sinkfilename += inputfilename;
-            sinkfilename += _STRLIT_WCHAR("_video.dat");
+            SinkFileName += inputfilename;
+            SinkFileName += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = new PVRefFileOutput(sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & SinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
 
-#else
-            iMIOOutVideo = PVMioDevVideoFactory::Create();
-            iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOOutVideo);
-            iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
-
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-
-            printf(" AddDataSink \n");
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-
-#endif
         }
         break;
 
         case STATE_ADDDATASINK_AUDIO:
         {
-#if !USE_DEVAUDIO
-
-            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
-            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
-            sinkfilename += _STRLIT_WCHAR("test_player_setplaybackafterprepare_");
-            if (iCompressedAudio)
-            {
-                sinkfilename += _STRLIT_WCHAR("compressed_");
-            }
+            OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfile += _STRLIT_WCHAR("test_player_setplaybackafterprepare_audio.dat");
             OSCL_wHeapString<OsclMemAllocator> inputfilename;
             RetrieveFilename(wFileName.get_str(), inputfilename);
-            sinkfilename += inputfilename;
-            sinkfilename += _STRLIT_WCHAR("_audio.dat");
+            sinkfile += inputfilename;
+            sinkfile += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOOutAudio = OSCL_STATIC_CAST(PvmiMIOControl*, new PVRefFileOutput(sinkfilename));
-
-            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOOutAudio);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
+            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
 
-            if (iFileType == PVMF_ASFFF)
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_PCM16);
-            else
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-
-
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-#else
-#if USE_AUDIO_EXTN_INTERFACE
-            iMIOOutAudio = PVMioDevSoundFactory::Create();
-            iAudioOutputController = PVMioDevSoundFactory::GetAudioOutputControl(iMIOOutAudio);
-#else
-            iMIOOutAudio = PVMioDevSoundFactory::Create();
-#endif // USE_AUDIO_EXTN_INTERFACE
-            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOOutAudio);
-            iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-
-
-            if (iFileType == PVMF_ASFFF)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_PCM16);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
-            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-
-#endif
-
         }
         break;
 
@@ -16626,11 +16286,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = new PVRefFileOutput(sinkfilename);
+            iMIOFileOutText = new PVRefFileOutput((oscl_wchar*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -16650,6 +16310,7 @@
             start.iIndeterminate = false;
             end.iIndeterminate = true;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 10000;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -16705,65 +16366,42 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
             iPlayer = NULL;
 
+            delete iSourceContextData;
+            iSourceContextData = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
             delete iDataSinkVideo;
             iDataSinkVideo = NULL;
 
-            delete iDataSinkAudio;
-            iDataSinkAudio = NULL;
-
-            delete iDataSinkText;
-            iDataSinkText = NULL;
-
             PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
             iIONodeVideo = NULL;
 
+            iMioFactory->DestroyVideoOutput(iMIOFileOutVideo);
+            iMIOFileOutVideo = NULL;
+
+            delete iDataSinkAudio;
+            iDataSinkAudio = NULL;
+
             PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
             iIONodeAudio = NULL;
 
+            iMioFactory->DestroyAudioOutput(iMIOFileOutAudio);
+            iMIOFileOutAudio = NULL;
+
+            delete iDataSinkText;
+            iDataSinkText = NULL;
+
             PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeText);
             iIONodeText = NULL;
 
-#ifdef USE_REF_FILEOUTPUT_FOR_VIDEO
-
-            delete iMIOFileOutVideo;
-            iMIOFileOutVideo = NULL;
-#else
-
-            PVMioDevVideoFactory::Delete(iMIOOutVideo);
-            iMIOOutVideo = NULL;
-
-#endif
-
-#if USE_DEVAUDIO
-            PVMioDevSoundFactory::Delete(iMIOOutAudio);
-#if USE_AUDIO_EXTN_INTERFACE_2
-            iAudioOutputController = NULL;
-#endif // USE_AUDIO_EXTN_INTERFACE
-#else
-            PVRefFileOutput* mioOut = OSCL_STATIC_CAST(PVRefFileOutput*, iMIOOutAudio);
-            delete mioOut;
-#endif
-            iMIOOutAudio = NULL;
-
-            delete iMIOFileOutText;
+            iMioFactory->DestroyTextOutput(iMIOFileOutText);
             iMIOFileOutText = NULL;
 
             iObserver->TestCompleted(*iTestCase);
@@ -16823,8 +16461,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16839,8 +16477,8 @@
                 // Init failed
 
 
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16854,37 +16492,23 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_ADDDATASINK_AUDIO:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-#if USE_AUDIO_EXTN_INTERFACE_2
-                iAudioOutputController = PVMioDevSoundFactory::GetAudioOutputControl(iMIOOutAudio);
-                TInt iVolume;
-                TInt aLeftPercentage, aRightPercentage;
-                iAudioOutputController->GetMaxVolumeL(iVolume);
-                iAudioOutputController->SetVolumeL(iVolume);
-                //iAudioOutputController->SetVolumeL(0);
-                iAudioOutputController->GetVolumeL(iVolume);
-                iAudioOutputController->GetBalanceL(aLeftPercentage, aRightPercentage);
-                iAudioOutputController->SetBalanceL(aLeftPercentage, aRightPercentage);
-                //iAudioOutputController->SetBalanceL(0,100);
-
-#endif //USE_AUDIO_EXTN_INTERFACE_2
                 iState = STATE_ADDDATASINK_TEXT;
-                //	iState=STATE_PREPARE;
                 RunIfNotReady();
             }
             else
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16898,8 +16522,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16913,8 +16537,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16924,12 +16548,18 @@
                 iState = STATE_START;
                 RunIfNotReady();
             }
+            else if (aResponse.GetCmdStatus() == PVMFErrNotSupported)
+            {
+                fprintf(file, " SetPlaybackRange not supported \n");
+                iState = STATE_START;
+                RunIfNotReady();
+            }
             else
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16943,8 +16573,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16958,8 +16588,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16973,8 +16603,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16989,8 +16619,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -17004,8 +16634,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -17019,8 +16649,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -17086,36 +16716,15 @@
 
 void pvplayer_async_test_setplaybackafterprepare::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        // do nothing
     }
-
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
         PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
@@ -17160,3 +16769,2326 @@
     }
 }
 
+//
+// pvplayer_async_test_multipauseseekresume section
+//
+void pvplayer_async_test_multipauseseekresume::StartTest()
+{
+    AddToScheduler();
+    iState = STATE_CREATE;
+    RunIfNotReady();
+}
+
+
+void pvplayer_async_test_multipauseseekresume::Run()
+{
+    int error = 0;
+
+    switch (iState)
+    {
+        case STATE_CREATE:
+        {
+            iPlayer = NULL;
+
+            OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
+            if (error)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+            }
+            else
+            {
+                iState = STATE_ADDDATASOURCE;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case STATE_ADDDATASOURCE:
+        {
+            PVMFFormatType fileType;
+            iDataSource = new PVPlayerDataSourceURL;
+            OSCL_HeapString<OsclMemAllocator> filename;
+
+            if (oscl_strstr(iFileName, "test.mp4") != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += _STRLIT_CHAR("test_reposition.mp4");
+                fileType = PVMF_MIME_MPEG4FF;
+                iFileType = PVMF_MIME_MPEG4FF;
+            }
+            else
+            {
+                filename = iFileName;
+                fileType = iFileType;
+            }
+            fprintf(iTestMsgOutputFile, "***Source URL=%s\n", filename.get_str());
+            oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
+            wFileName.set(output, oscl_strlen(output));
+
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
+            {
+                fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+
+                    if (iProxyEnabled)
+                    {
+                        streamingContext->iProxyName = _STRLIT_WCHAR("63.215.241.33");
+                        streamingContext->iProxyPort = 7070;
+                    }
+
+                    streamingContext->iUserID = _STRLIT_CHAR("abc");
+                    streamingContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                }
+                iSourceContextData->EnableDownloadHTTPSourceContext();
+                sourceContext = NULL;
+                PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataDownloadHTTP* downloadContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                    if (iProxyEnabled)
+                    {
+                        downloadContext->iProxyName = _STRLIT_CHAR("63.215.241.33");
+                        downloadContext->iProxyPort = 7070;
+                    }
+                    downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                    downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                    downloadContext->iUserID = _STRLIT_CHAR("abc");
+                    downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                    downloadContext->bIsNewSession = true;
+                    downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    downloadContext->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
+                }
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+            }
+            iDataSource->SetDataSourceURL(wFileName);
+            iDataSource->SetDataSourceFormatType(fileType);
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_INIT:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_GETMETADATAKEYLIST:
+        {
+            iMetadataKeyList.clear();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataKeys(iMetadataKeyList, 0, -1, NULL, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_GETMETADATAVALUELIST:
+        {
+            iMetadataValueList.clear();
+            iNumValues = 0;
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, -1, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_VIDEO:
+        {
+            OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfile += _STRLIT_WCHAR("test_player_setstartpositionplaystop_video.dat");
+
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
+            iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
+            iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_AUDIO:
+        {
+            OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfile += _STRLIT_WCHAR("test_player_setstartpositionplaystop_audio.dat");
+
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
+            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
+            iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_PREPARE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_START:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_PAUSE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Pause((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+            iCmdIds.push_back(iCurrentCmdId);
+        }
+        break;
+
+        case STATE_SETPLAYBACKRANGE:
+        {
+            PVPPlaybackPosition start, end;
+            start.iIndeterminate = false;
+            start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
+            start.iPosValue.millisec_value = iSessionDuration / 4;
+            end.iIndeterminate = true;
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RESUME:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Resume((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+            iCmdIds.push_back(iCurrentCmdId);
+        }
+        break;
+
+        case STATE_STOP:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_VIDEO:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_AUDIO:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RESET:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASOURCE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_CLEANUPANDCOMPLETE:
+        {
+            PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
+            iPlayer = NULL;
+
+            delete iSourceContextData;
+            iSourceContextData = NULL;
+
+            delete iDataSource;
+            iDataSource = NULL;
+
+            delete iDataSinkVideo;
+            iDataSinkVideo = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
+            iIONodeVideo = NULL;
+
+            iMioFactory->DestroyVideoOutput(iMIOFileOutVideo);
+            iMIOFileOutVideo = NULL;
+
+            delete iDataSinkAudio;
+            iDataSinkAudio = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
+            iIONodeAudio = NULL;
+
+            iMioFactory->DestroyAudioOutput(iMIOFileOutAudio);
+            iMIOFileOutAudio = NULL;
+
+            iObserver->TestCompleted(*iTestCase);
+        }
+        break;
+
+        default:
+            break;
+
+    }
+}
+
+
+void pvplayer_async_test_multipauseseekresume::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    if (aResponse.GetCmdId() != iCurrentCmdId)
+    {
+        // Wrong command ID.
+        PVPATB_TEST_IS_TRUE(false);
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+        return;
+    }
+
+    if (aResponse.GetContext() != NULL)
+    {
+        if (aResponse.GetContext() == (OsclAny*)&iContextObject)
+        {
+            if (iContextObject != iContextObjectRefValue)
+            {
+                // Context data value was corrupted
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+                return;
+            }
+        }
+        else
+        {
+            // Context data pointer was corrupted
+            PVPATB_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+            return;
+        }
+    }
+
+    switch (iState)
+    {
+        case STATE_ADDDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_INIT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSource failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_GETMETADATAKEYLIST;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Init failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_GETMETADATAKEYLIST:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_GETMETADATAVALUELIST;
+                RunIfNotReady();
+            }
+            else
+            {
+                // GetMetadataKeys failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_GETMETADATAVALUELIST:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
+                {
+                    if ((oscl_strstr(iMetadataValueList[i].key, "duration")) && iSessionDuration == 0)
+                    {
+                        iSessionDuration = iMetadataValueList[i].value.uint32_value;
+
+                        // Check the timescale. If not available, assume millisecond (1000)
+                        const char *retTSstr;
+                        retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
+                        uint32 retTSstrLen = 0;
+                        uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
+                        if (retTSstr != NULL)
+                        {
+                            retTSstrLen = oscl_strlen(retTSstr);
+                            if (retTSstrLen > tsstrlen)
+                            {
+                                uint32 timescale = 0;
+                                PV_atoi((char*)(retTSstr + tsstrlen), 'd', (retTSstrLen - tsstrlen), timescale);
+                                if (timescale > 0 && timescale != 1000)
+                                {
+                                    // Convert to milliseconds
+                                    MediaClockConverter mcc(timescale);
+                                    mcc.update_clock(iSessionDuration);
+                                    iSessionDuration = mcc.get_converted_ts(1000);
+                                }
+                            }
+                        }
+                    }
+                }
+                iState = STATE_ADDDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // GetMetadataValue failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_ADDDATASINK_VIDEO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_AUDIO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_ADDDATASINK_AUDIO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_PREPARE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_PREPARE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_START;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Prepare failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_START:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_PAUSE;
+                uint32 iPauseDurationMS = iSessionDuration / 10;
+                RunIfNotReady(iPauseDurationMS*1000);
+            }
+            else
+            {
+                // Start failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_PAUSE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iNumPause++;
+                iState = STATE_SETPLAYBACKRANGE;
+                RunIfNotReady(1000000);
+            }
+            else
+            {
+                // One of queued commands failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_SETPLAYBACKRANGE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_RESUME;
+                RunIfNotReady(1000000);
+            }
+            else
+            {
+                // SetPlaybackRange failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RESUME:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iTargetNumPause != iNumPause)
+                {
+                    iState = STATE_PAUSE;
+                    uint32 iPauseDurationMS = iSessionDuration / 10;
+                    RunIfNotReady(iPauseDurationMS*1000);
+                }
+            }
+            else
+            {
+                // One of queued commands failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_STOP:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Stop failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_VIDEO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_AUDIO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_AUDIO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_RESET;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RESET:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASOURCE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Reset failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                PVPATB_TEST_IS_TRUE(true);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSource failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        default:
+        {
+            // Testing error if this is reached
+            PVPATB_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+    }
+}
+
+
+void pvplayer_async_test_multipauseseekresume::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+{
+    switch (aEvent.GetEventType())
+    {
+        case PVMFErrResourceConfiguration:
+            // Just log the error
+            PVPATB_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrResource:
+            // Just log the error
+            PVPATB_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrCorrupt:
+            // Just log the error
+            PVPATB_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrProcessing:
+            // Just log the error
+            PVPATB_TEST_IS_TRUE(false);
+            break;
+
+        default:
+            // Unknown error and just log the error
+            PVPATB_TEST_IS_TRUE(false);
+            break;
+    }
+
+    // Wait for engine to handle the error
+    Cancel();
+}
+
+
+void pvplayer_async_test_multipauseseekresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+    // Check for end of clip event
+    if (aEvent.GetEventType() == PVMFInfoEndOfData)
+    {
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface == NULL)
+        {
+            return;
+        }
+        PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+        PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+        if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+        {
+            int32 infocode;
+            PVUuid infouuid;
+            infomsgiface->GetCodeUUID(infocode, infouuid);
+            if ((infouuid == PVPlayerErrorInfoEventTypesUUID) && (infocode == PVPlayerInfoEndOfClipReached))
+            {
+                iState = STATE_STOP;
+                Cancel();
+                RunIfNotReady();
+            }
+        }
+    }
+    else if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
+    {
+        // source rollover...
+        fprintf(iTestMsgOutputFile, "###PVMFInfoSourceFormatNotSupported...\n");
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface != NULL)
+        {
+            PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+            PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+            if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+            {
+                int32 infocode;
+                PVUuid infouuid;
+                infomsgiface->GetCodeUUID(infocode, infouuid);
+                if ((infouuid == PVPlayerErrorInfoEventTypesUUID) &&
+                        (infocode == PVPlayerInfoAttemptingSourceRollOver))
+                {
+                    uint8* localBuf = aEvent.GetLocalBuffer();
+                    if (localBuf != NULL)
+                    {
+                        uint32 srcFormat = 0;
+                        oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                    }
+                }
+            }
+        }
+    }
+}
+
+//
+// pvplayer_async_test_multiple_instance section
+//
+#include "pvmf_local_data_source.h"
+#include "oscl_scheduler.h"
+#include "omx_core.h"
+#include "oscl_mem_audit.h"
+
+//test observer function for the 2nd instance.
+void pvplayer_async_test_multiple_instance::ChildObserver::TestCompleted(test_case &tc)
+{
+    OSCL_UNUSED_ARG(tc);
+    OsclExecScheduler* sched = OsclExecScheduler::Current();
+    if (sched)
+        sched->StopScheduler();
+}
+
+void pvplayer_async_test_multiple_instance::ChildTestIsTrue(bool aCondition)
+//add failures from child to the parent error count.
+{
+    OSCL_ASSERT(iParentInstance);
+    if (!aCondition)
+        iParentInstance->iChildThreadFailures++;
+}
+
+//To avoid thread contention for the test result, only the parent thread can register
+//test failures directly in the test case.  The child thread increments a counter that
+//will get added to test case results after the child thread exits.
+#define MULTI_TEST_IS_TRUE(x) (iParentInstance)?ChildTestIsTrue(x):PVPATB_TEST_IS_TRUE(x);
+
+void pvplayer_async_test_multiple_instance::InThread(pvplayer_async_test_multiple_instance* parent)
+{
+    //Init Oscl
+    OsclMem::Init();
+    OMX_Init();
+    PVLogger::Init();
+    OsclScheduler::Init("pvplayer_async_test_multiple_instance");
+
+    {
+        //create a 2nd test instance.
+        pvplayer_async_test_multiple_instance* test = new pvplayer_async_test_multiple_instance(*parent->iParam);
+
+        //replace the observer with one appropriate for this thread.
+        ChildObserver* obs = new ChildObserver;
+        test->iObserver = obs;
+
+        //replace sink name with a unique name for this thread.
+        test->iSinkName = _STRLIT_WCHAR("pvplayer_async_test_multiple_instance_2nd_");
+
+        //save parent instance pointer
+        test->iParentInstance = parent;
+
+        //add to scheduler and go
+        test->StartTest();
+        OsclExecScheduler* sched = OsclExecScheduler::Current();
+        sched->StartScheduler();
+
+        //cleanup.
+        delete(obs);
+        delete(test);
+    }
+
+    //Cleanup Oscl.
+    OsclScheduler::Cleanup();
+    PVLogger::Cleanup();
+    OMX_Deinit();
+    //note: there's no memory leak check here since
+    //this thread exits before the main thread.
+    OsclMem::Cleanup();
+}
+
+static TOsclThreadFuncRet OSCL_THREAD_DECL pvplayer_async_test_multiple_instance_thread(TOsclThreadFuncArg arg)
+{
+    //parent test is passed in as arg
+    pvplayer_async_test_multiple_instance* parent = (pvplayer_async_test_multiple_instance*)arg;
+
+    //Init Oscl
+    OsclBase::Init();
+    OsclErrorTrap::Init();
+
+    //Run remainder of the thread under a trap.
+    OSCL_TRY(parent->iChildThreadLeave,
+             pvplayer_async_test_multiple_instance::InThread(parent););
+
+    //Cleanup Oscl
+    OsclErrorTrap::Cleanup();
+    OsclBase::Cleanup();
+
+    //parent thread waits on this signal to know this thread exited.
+    parent->iChildThreadExit = true;
+
+    return 0;
+}
+
+void pvplayer_async_test_multiple_instance::StartTest()
+{
+    AddToScheduler();
+    iState = STATE_CREATE;
+    RunIfNotReady();
+}
+
+void pvplayer_async_test_multiple_instance::Run()
+{
+    int error = 0;
+
+    switch (iState)
+    {
+        case STATE_CREATE:
+        {
+            //If this is the original instance, then launch a 2nd thread.
+            if (!iParentInstance)
+            {
+                OsclThread thread;
+                OsclProcStatus::eOsclProcError  result = thread.Create(pvplayer_async_test_multiple_instance_thread, 0, this);
+                if (result != OsclProcStatus::SUCCESS_ERROR)
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                    iObserver->TestCompleted(*iTestCase);
+                    break;
+                }
+            }
+
+            OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
+            if (error)
+            {
+                MULTI_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+            }
+            else
+            {
+                iState = STATE_ADDDATASOURCE;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case STATE_ADDDATASOURCE:
+        {
+            iDataSource = new PVPlayerDataSourceURL;
+
+            OSCL_HeapString<OsclMemAllocator> fname(iFileName);
+            oscl_UTF8ToUnicode(fname.get_cstr(), fname.get_size(), iTmpWCharBuffer, 512);
+            iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
+            iDataSource->SetDataSourceURL(iFileNameWStr);
+            iDataSource->SetDataSourceFormatType(iFileType);
+            iLocalDataSource = new PVMFLocalDataSource(false);
+            iDataSource->SetDataSourceContextData((OsclAny*)iLocalDataSource);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+
+        break;
+
+        case STATE_INIT:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_GETMETADATAKEYLIST:
+        {
+            iMetadataKeyList.clear();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataKeys(iMetadataKeyList, 0, 100, NULL, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_GETMETADATAVALUELIST:
+        {
+            iMetadataValueList.clear();
+            iNumValues = 0;
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 100, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_VIDEO:
+        {
+
+            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
+            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfilename += iSinkName;
+            if (iCompressedVideo)
+            {
+                sinkfilename += _STRLIT_WCHAR("compressed_");
+            }
+            OSCL_wHeapString<OsclMemAllocator> inputfilename;
+            RetrieveFilename(iFileNameWStr.get_str(), inputfilename);
+            sinkfilename += inputfilename;
+            sinkfilename += _STRLIT_WCHAR("_video.dat");
+
+            iMOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
+            iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutVideo);
+            iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_AUDIO:
+        {
+            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
+            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfilename += iSinkName;
+            if (iCompressedAudio)
+            {
+                sinkfilename += _STRLIT_WCHAR("compressed_");
+            }
+            OSCL_wHeapString<OsclMemAllocator> inputfilename;
+            RetrieveFilename(iFileNameWStr.get_str(), inputfilename);
+            sinkfilename += inputfilename;
+            sinkfilename += _STRLIT_WCHAR("_audio.dat");
+
+            iMOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
+
+            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutAudio);
+            iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_TEXT:
+        {
+            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
+            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfilename += iSinkName;
+            OSCL_wHeapString<OsclMemAllocator> inputfilename;
+            RetrieveFilename(iFileNameWStr.get_str(), inputfilename);
+            sinkfilename += inputfilename;
+            sinkfilename += _STRLIT_WCHAR("_text.dat");
+
+            iMOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
+            iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutText);
+            iDataSinkText = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
+
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_PREPARE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_START:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_STOP:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_VIDEO:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_AUDIO:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_TEXT:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RESET:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASOURCE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_CLEANUPANDCOMPLETE:
+        {
+            MULTI_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
+            iPlayer = NULL;
+
+            delete iDataSource;
+            iDataSource = NULL;
+
+            delete iDataSinkVideo;
+            iDataSinkVideo = NULL;
+
+            delete iDataSinkAudio;
+            iDataSinkAudio = NULL;
+
+            delete iDataSinkText;
+            iDataSinkText = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
+            iIONodeVideo = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
+            iIONodeAudio = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeText);
+            iIONodeText = NULL;
+
+            iMioFactory->DestroyVideoOutput(iMOutVideo);
+            iMOutVideo = NULL;
+
+            iMioFactory->DestroyAudioOutput(iMOutAudio);
+            iMOutAudio = NULL;
+
+            iMioFactory->DestroyTextOutput(iMOutText);
+            iMOutText = NULL;
+
+            delete iLocalDataSource;
+            iLocalDataSource = NULL;
+
+            //If this is the original instance, then wait on the 2nd instance to finish
+            //so we can check its error results and add to this test case results.
+            if (!iParentInstance)
+            {
+                if (!iChildThreadExit)
+                {
+                    fprintf(file, "Waiting on 2nd instance to exit...\n");
+                    for (uint32 i = 0;!iChildThreadExit && i < 20;i++)
+                        OsclThread::SleepMillisec(1000);
+                }
+                //make sure child thread exited within the allowed time
+                //and didn't report any test failures, exceptions, or memory leaks.
+                PVPATB_TEST_IS_TRUE(iChildThreadExit);
+                if (iChildThreadFailures > 0)
+                    PVPATB_TEST_IS_TRUE(false);
+                if (iChildThreadLeave != OsclErrNone)
+                    PVPATB_TEST_IS_TRUE(false);
+            }
+
+            iObserver->TestCompleted(*iTestCase);
+        }
+        break;
+
+        default:
+            break;
+
+    }
+}
+
+
+void pvplayer_async_test_multiple_instance::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    if (aResponse.GetCmdId() != iCurrentCmdId)
+    {
+        // Wrong command ID.
+        MULTI_TEST_IS_TRUE(false);
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+        return;
+    }
+
+    if (aResponse.GetContext() != NULL)
+    {
+        if (aResponse.GetContext() == (OsclAny*)&iContextObject)
+        {
+            if (iContextObject != iContextObjectRefValue)
+            {
+                // Context data value was corrupted
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+                return;
+            }
+        }
+        else
+        {
+            // Context data pointer was corrupted
+            MULTI_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+            return;
+        }
+    }
+
+    switch (iState)
+    {
+        case STATE_ADDDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_INIT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSource failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_GETMETADATAKEYLIST;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Init failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_GETMETADATAKEYLIST:
+            if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
+            {
+                iState = STATE_GETMETADATAVALUELIST;
+                RunIfNotReady();
+            }
+            else
+            {
+                // GetMetadataKeys failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_GETMETADATAVALUELIST:
+            if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
+            {
+                //Display the resulting metadata.
+                PrintMetadata();
+                iState = STATE_ADDDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // GetMetadataValue failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_ADDDATASINK_VIDEO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_AUDIO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_ADDDATASINK_AUDIO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_TEXT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_ADDDATASINK_TEXT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_PREPARE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_PREPARE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_START;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Prepare failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_START:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                //stop in 20 seconds.
+                iState = STATE_STOP;
+                RunIfNotReady(20000000);
+            }
+            else
+            {
+                // Start failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_STOP:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Stop failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_VIDEO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_AUDIO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_AUDIO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_TEXT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_TEXT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_RESET;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RESET:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASOURCE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Reset failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_REMOVEDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                MULTI_TEST_IS_TRUE(true);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSource failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        default:
+        {
+            // Testing error if this is reached
+            MULTI_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+    }
+}
+
+
+void pvplayer_async_test_multiple_instance::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+{
+    switch (aEvent.GetEventType())
+    {
+        case PVMFErrResourceConfiguration:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrResource:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrCorrupt:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrProcessing:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        default:
+            // Unknown error and just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+    }
+
+    // Wait for engine to handle the error
+    Cancel();
+}
+
+
+void pvplayer_async_test_multiple_instance::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        // do nothing
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+}
+
+void pvplayer_async_test_multiple_instance::PrintMetadata()
+{
+    //to avoid thread contention for the output file, only print metadata
+    //from the original instance (with NULL parent).
+    if (iParentInstance)
+        return;
+
+    for (uint32 i = 0;i < iMetadataValueList.size();i++)
+    {
+        if (!iMetadataValueList[i].key)
+        {
+            fprintf(file, "  Metadata Key Missing!, value ?\n");
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=char*"))
+        {
+            fprintf(file, "  Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, iMetadataValueList[i].value.pChar_value);
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=wchar*"))
+        {
+            OSCL_HeapString<OsclMemAllocator> ostr;
+            char buf[2];
+            buf[1] = '\0';
+            for (uint32 j = 0;;j++)
+            {
+                if (iMetadataValueList[i].value.pWChar_value[j] == '\0')
+                    break;
+                buf[0] = (char)iMetadataValueList[i].value.pWChar_value[j];
+                ostr += buf;
+            }
+            fprintf(file, "  Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, ostr.get_str());
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint32"))
+        {
+            fprintf(file, "  Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.uint32_value);
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=bool"))
+        {
+            fprintf(file, "  Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.bool_value);
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint8*"))
+        {
+            fprintf(file, "  Metadata Key '%s', len %d\n", iMetadataValueList[i].key, iMetadataValueList[i].length);
+        }
+        else
+        {
+            fprintf(file, "  Metadata Key '%s', value ?\n", iMetadataValueList[i].key);
+        }
+    }
+    fprintf(file, "\n\n");
+}
+
+//
+// pvplayer_async_test_multiple_thread section
+//
+#include "pvmf_local_data_source.h"
+#include "oscl_scheduler.h"
+#include "omx_core.h"
+#include "oscl_mem_audit.h"
+
+
+
+//
+#undef MULTI_TEST_IS_TRUE
+#define MULTI_TEST_IS_TRUE(x) PVPATB_TEST_IS_TRUE(x);
+
+
+void pvplayer_async_test_multiple_thread::StartTest()
+{
+    AddToScheduler();
+    iState = STATE_CREATE;
+    RunIfNotReady();
+}
+
+#include "oscl_init.h"
+#include "oscl_mem.h"
+
+static TOsclThreadFuncRet OSCL_THREAD_DECL pvplayer_async_test_multiple_thread_thread(TOsclThreadFuncArg arg)
+{
+    //parent test is passed in as arg
+    pvplayer_async_test_multiple_thread* parent = (pvplayer_async_test_multiple_thread*)arg;
+
+    //Init Oscl.
+    OsclSelect select;
+    select.iOutputFile = file;//for memory leak output.
+    int32 err;
+    OsclInit::Init(err, &select);
+    if (err)
+    {
+        parent->iThreadErrors++;
+        parent->iThreadReadySem.Signal();
+        return 0;
+    }
+
+    OSCL_TRY(err,
+
+             //get scheduler
+             parent->iThreadScheduler = OsclExecScheduler::Current();
+
+             //create player
+             parent->iPlayer = PVPlayerFactory::CreatePlayer(parent, parent, parent);
+
+             //signal parent thread that player is ready to accept commands.
+             parent->iThreadReadySem.Signal();
+
+             //launch scheduler.  this call blocks.
+             parent->iThreadScheduler->StartScheduler();
+
+             //delete player
+             PVPlayerFactory::DeletePlayer(parent->iPlayer);
+             parent->iPlayer = NULL;
+
+            ); //OSCL_TRY
+    if (err)
+        parent->iThreadErrors++;
+
+    //Cleanup Oscl
+    OsclInit::Cleanup(err, &select);
+    if (err)
+        parent->iThreadErrors++;
+
+    parent->iThreadScheduler = NULL;
+
+    //Signal that this thread is cleaned up.
+    parent->iThreadExitSem.Signal();
+
+    return 0;
+}
+
+void pvplayer_async_test_multiple_thread::Run()
+{
+    int error = 0;
+
+    switch (iState)
+    {
+        case STATE_CREATE:
+        {
+            //Configure the threadsafe queues that are used for engine
+            //thread callbacks.
+            iThreadSafeCommandQueue.Configure(this);
+            iThreadSafeErrorQueue.Configure(this);
+            iThreadSafeInfoQueue.Configure(this);
+
+            //Create engine thread
+            {
+                iThreadReadySem.Create();
+                iThreadExitSem.Create();
+                iThreadErrors = 0;
+                iPlayer = NULL;
+                iThreadScheduler = NULL;
+
+                OsclThread thread;
+                OsclProcStatus::eOsclProcError  result = thread.Create(pvplayer_async_test_multiple_thread_thread, 0, this);
+                if (result != OsclProcStatus::SUCCESS_ERROR)
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                    iObserver->TestCompleted(*iTestCase);
+                    break;
+                }
+                //wait on engine to be ready to use.
+                iThreadReadySem.Wait();
+            }
+
+            //player should have been created in the other thread
+            if (!iPlayer)
+            {
+                MULTI_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+            }
+            else
+            {
+                iState = STATE_ADDDATASOURCE;
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        case STATE_ADDDATASOURCE:
+        {
+            iDataSource = new PVPlayerDataSourceURL;
+
+            OSCL_HeapString<OsclMemAllocator> fname(iFileName);
+            oscl_UTF8ToUnicode(fname.get_cstr(), fname.get_size(), iTmpWCharBuffer, 512);
+            iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
+            iDataSource->SetDataSourceURL(iFileNameWStr);
+            iDataSource->SetDataSourceFormatType(iFileType);
+            iLocalDataSource = new PVMFLocalDataSource(false);
+            iDataSource->SetDataSourceContextData((OsclAny*)iLocalDataSource);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+
+        break;
+
+        case STATE_INIT:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_GETMETADATAKEYLIST:
+        {
+            iMetadataKeyList.clear();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataKeys(iMetadataKeyList, 0, 100, NULL, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_GETMETADATAVALUELIST:
+        {
+            iMetadataValueList.clear();
+            iNumValues = 0;
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 100, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject, false));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RELEASEMETADATAVALUES:
+        {
+            PrintMetadata();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->ReleaseMetadataValues(iMetadataValueList, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_VIDEO:
+        {
+            //Synchronous API test
+            {
+                PVPlayerState state;
+                PVMFStatus status = PVMFFailure;
+                OSCL_TRY(error, status = iPlayer->GetPVPlayerStateSync(state););
+                OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+                MULTI_TEST_IS_TRUE(status == PVMFSuccess && state == PVP_STATE_INITIALIZED);
+            }
+
+            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
+            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfilename += iSinkName;
+            if (iCompressedVideo)
+            {
+                sinkfilename += _STRLIT_WCHAR("compressed_");
+            }
+            OSCL_wHeapString<OsclMemAllocator> inputfilename;
+            RetrieveFilename(iFileNameWStr.get_str(), inputfilename);
+            sinkfilename += inputfilename;
+            sinkfilename += _STRLIT_WCHAR("_video.dat");
+
+            iMOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
+            iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutVideo);
+            iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_AUDIO:
+        {
+            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
+            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfilename += iSinkName;
+            if (iCompressedAudio)
+            {
+                sinkfilename += _STRLIT_WCHAR("compressed_");
+            }
+            OSCL_wHeapString<OsclMemAllocator> inputfilename;
+            RetrieveFilename(iFileNameWStr.get_str(), inputfilename);
+            sinkfilename += inputfilename;
+            sinkfilename += _STRLIT_WCHAR("_audio.dat");
+
+            iMOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
+
+            iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutAudio);
+            iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_ADDDATASINK_TEXT:
+        {
+            OSCL_wHeapString<OsclMemAllocator> sinkfilename;
+            sinkfilename = OUTPUTNAME_PREPEND_WSTRING;
+            sinkfilename += iSinkName;
+            OSCL_wHeapString<OsclMemAllocator> inputfilename;
+            RetrieveFilename(iFileNameWStr.get_str(), inputfilename);
+            sinkfilename += inputfilename;
+            sinkfilename += _STRLIT_WCHAR("_text.dat");
+
+            iMOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
+            iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMOutText);
+            iDataSinkText = new PVPlayerDataSinkPVMFNode;
+            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
+
+
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_PREPARE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_START:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_STOP:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_VIDEO:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_AUDIO:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASINK_TEXT:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RESET:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_REMOVEDATASOURCE:
+        {
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, MULTI_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_WAIT_FOR_ERROR_HANDLING:
+        {
+            // Timed out waiting for error handling to complete
+            MULTI_TEST_IS_TRUE(false);
+            // Forcibly terminate the test
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+
+        case STATE_CLEANUPANDCOMPLETE:
+        {
+            //Engine thread cleanup
+            {
+                if (iPlayer)
+                {
+                    //Stop scheduler
+                    iThreadScheduler->StopScheduler();
+
+                    //Wait on engine cleanup
+                    iThreadExitSem.Wait();
+
+                    //Check for errors.
+                    if (iThreadErrors > 0)
+                        PVPATB_TEST_IS_TRUE(false);
+
+                    iThreadReadySem.Close();
+                    iThreadExitSem.Close();
+                }
+            }
+
+            delete iDataSource;
+            iDataSource = NULL;
+
+            delete iDataSinkVideo;
+            iDataSinkVideo = NULL;
+
+            delete iDataSinkAudio;
+            iDataSinkAudio = NULL;
+
+            delete iDataSinkText;
+            iDataSinkText = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeVideo);
+            iIONodeVideo = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeAudio);
+            iIONodeAudio = NULL;
+
+            PVMediaOutputNodeFactory::DeleteMediaOutputNode(iIONodeText);
+            iIONodeText = NULL;
+
+            iMioFactory->DestroyVideoOutput(iMOutVideo);
+            iMOutVideo = NULL;
+
+            iMioFactory->DestroyAudioOutput(iMOutAudio);
+            iMOutAudio = NULL;
+
+            iMioFactory->DestroyTextOutput(iMOutText);
+            iMOutText = NULL;
+
+            delete iLocalDataSource;
+            iLocalDataSource = NULL;
+
+            iObserver->TestCompleted(*iTestCase);
+        }
+        break;
+
+        default:
+            break;
+
+    }
+}
+
+//data is available on one of the thread-safe queues.
+void pvplayer_async_test_multiple_thread::ThreadSafeQueueDataAvailable(ThreadSafeQueue* aQueue)
+{
+    if (aQueue == &iThreadSafeCommandQueue)
+    {
+        for (uint32 ndata = 1;ndata;)
+        {
+            ThreadSafeQueueId id;
+            OsclAny* data;
+            ndata = iThreadSafeCommandQueue.DeQueue(id, data);
+            if (ndata)
+            {
+                PVCmdResponse* cmd = (PVCmdResponse*)data;
+                CommandCompleted(*cmd);
+                OSCL_DELETE(cmd);
+            }
+        }
+    }
+    if (aQueue == &iThreadSafeErrorQueue)
+    {
+        for (uint32 ndata = 1;ndata;)
+        {
+            ThreadSafeQueueId id;
+            OsclAny* data;
+            ndata = iThreadSafeErrorQueue.DeQueue(id, data);
+            if (ndata)
+            {
+                int32 eventType = (PVMFEventType)data;
+                PVAsyncErrorEvent event(eventType);
+                HandleErrorEvent(event);
+            }
+        }
+    }
+    if (aQueue == &iThreadSafeInfoQueue)
+    {
+        for (uint32 ndata = 1;ndata;)
+        {
+            ThreadSafeQueueId id;
+            OsclAny* data;
+            ndata = iThreadSafeInfoQueue.DeQueue(id, data);
+            if (ndata)
+            {
+                int32 eventType = (PVMFEventType)data;
+                PVAsyncInformationalEvent event(eventType);
+                HandleInformationalEvent(event);
+            }
+        }
+    }
+}
+
+void pvplayer_async_test_multiple_thread::CommandCompleted(const PVCmdResponse& aResponse)
+{
+    //if this callback is from engine thread, then push it across the thread
+    //boundary.
+    if (!iThreadSafeCommandQueue.IsInThread())
+    {
+        PVCmdResponse* cmd = OSCL_NEW(PVCmdResponse, (aResponse));
+        iThreadSafeCommandQueue.AddToQueue(cmd);
+        return;
+    }
+
+    if (aResponse.GetCmdId() != iCurrentCmdId)
+    {
+        // Wrong command ID.
+        MULTI_TEST_IS_TRUE(false);
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+        return;
+    }
+
+    if (aResponse.GetContext() != NULL)
+    {
+        if (aResponse.GetContext() == (OsclAny*)&iContextObject)
+        {
+            if (iContextObject != iContextObjectRefValue)
+            {
+                // Context data value was corrupted
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+                return;
+            }
+        }
+        else
+        {
+            // Context data pointer was corrupted
+            MULTI_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+            return;
+        }
+    }
+
+    switch (iState)
+    {
+        case STATE_ADDDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_INIT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSource failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_INIT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_GETMETADATAKEYLIST;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Init failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_GETMETADATAKEYLIST:
+            if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
+            {
+                iState = STATE_GETMETADATAVALUELIST;
+                RunIfNotReady();
+            }
+            else
+            {
+                // GetMetadataKeys failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_GETMETADATAVALUELIST:
+            if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
+            {
+                iState = STATE_RELEASEMETADATAVALUES;
+                RunIfNotReady();
+            }
+            else
+            {
+                // GetMetadataValue failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_RELEASEMETADATAVALUES:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // ReleaseMetadataValue failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_ADDDATASINK_VIDEO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_AUDIO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_ADDDATASINK_AUDIO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_TEXT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_ADDDATASINK_TEXT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_PREPARE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // AddDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_PREPARE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_START;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Prepare failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_START:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                //stop in 20 seconds.
+                iState = STATE_STOP;
+                RunIfNotReady(20000000);
+            }
+            else
+            {
+                // Start failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_STOP:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Stop failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_VIDEO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_AUDIO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_AUDIO:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_TEXT;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_REMOVEDATASINK_TEXT:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_RESET;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSink failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_RESET:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASOURCE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Reset failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_WAIT_FOR_ERROR_HANDLING;
+                RunIfNotReady(5000000);
+            }
+            break;
+
+        case STATE_REMOVEDATASOURCE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                MULTI_TEST_IS_TRUE(true);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // RemoveDataSource failed
+                MULTI_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        default:
+        {
+            // Testing error if this is reached
+            MULTI_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+    }
+}
+
+
+void pvplayer_async_test_multiple_thread::HandleErrorEvent(const PVAsyncErrorEvent& aEvent)
+{
+    //if this callback is from engine thread, then push it across the thread
+    //boundary.
+    if (!iThreadSafeErrorQueue.IsInThread())
+    {
+        //note: we discard all data except the event type here.
+        //if we need more data, memory has to be copied.
+        iThreadSafeErrorQueue.AddToQueue((OsclAny*)aEvent.GetEventType());
+        return;
+    }
+
+    switch (aEvent.GetEventType())
+    {
+        case PVMFErrResourceConfiguration:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrResource:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrCorrupt:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        case PVMFErrProcessing:
+            // Just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+
+        default:
+            // Unknown error and just log the error
+            MULTI_TEST_IS_TRUE(false);
+            break;
+    }
+
+    // Wait for engine to handle the error
+    Cancel();
+    iState = STATE_WAIT_FOR_ERROR_HANDLING;
+    RunIfNotReady(5000000);
+}
+
+
+void pvplayer_async_test_multiple_thread::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
+{
+    //if this callback is from engine thread, then push it across the thread
+    //boundary.
+    if (!iThreadSafeInfoQueue.IsInThread())
+    {
+        //note: we discard all data except the event type here.
+        //if we need more data, memory has to be copied.
+        iThreadSafeInfoQueue.AddToQueue((OsclAny*)aEvent.GetEventType());
+        return;
+    }
+
+    // Wait for error handling to complete
+    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        PVPlayerState pstate;
+        iPlayer->GetPVPlayerStateSync(pstate);
+        switch (pstate)
+        {
+            case PVP_STATE_INITIALIZED:
+                Cancel();
+                iState = STATE_REMOVEDATASINK_VIDEO;
+                RunIfNotReady();
+                break;
+
+            case PVP_STATE_IDLE:
+                Cancel();
+                iState = STATE_REMOVEDATASOURCE;
+                RunIfNotReady();
+                break;
+
+            default:
+                // Engine should not be in any other state when
+                // error handling completes
+                MULTI_TEST_IS_TRUE(false);
+                Cancel();
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+                break;
+        }
+    }
+}
+
+void pvplayer_async_test_multiple_thread::PrintMetadata()
+{
+    for (uint32 i = 0;i < iMetadataValueList.size();i++)
+    {
+        if (!iMetadataValueList[i].key)
+        {
+            fprintf(file, "  Metadata Key Missing!, value ?\n");
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=char*"))
+        {
+            fprintf(file, "  Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, iMetadataValueList[i].value.pChar_value);
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=wchar*"))
+        {
+            OSCL_HeapString<OsclMemAllocator> ostr;
+            char buf[2];
+            buf[1] = '\0';
+            for (uint32 j = 0;;j++)
+            {
+                if (iMetadataValueList[i].value.pWChar_value[j] == '\0')
+                    break;
+                buf[0] = (char)iMetadataValueList[i].value.pWChar_value[j];
+                ostr += buf;
+            }
+            fprintf(file, "  Metadata Key '%s', value '%s'\n", iMetadataValueList[i].key, ostr.get_str());
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint32"))
+        {
+            fprintf(file, "  Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.uint32_value);
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=bool"))
+        {
+            fprintf(file, "  Metadata Key '%s', value %d\n", iMetadataValueList[i].key, iMetadataValueList[i].value.bool_value);
+        }
+        else if (oscl_strstr(iMetadataValueList[i].key, "valtype=uint8*"))
+        {
+            fprintf(file, "  Metadata Key '%s', len %d\n", iMetadataValueList[i].key, iMetadataValueList[i].length);
+        }
+        else
+        {
+            fprintf(file, "  Metadata Key '%s', value ?\n", iMetadataValueList[i].key);
+        }
+    }
+    fprintf(file, "\n\n");
+}
diff --git a/engines/player/test/src/test_pv_player_engine_testset1.h b/engines/player/test/src/test_pv_player_engine_testset1.h
index 36412d8..d39ad3d 100644
--- a/engines/player/test/src/test_pv_player_engine_testset1.h
+++ b/engines/player/test/src/test_pv_player_engine_testset1.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,17 @@
 #include "pvmf_cpmplugin_factory_registry.h"
 #endif
 
-#define  USE_REF_FILEOUTPUT_FOR_VIDEO
+#ifndef PVMF_STREAMING_DATA_SOURCE_H_INCLUDED
+#include "pvmf_streaming_data_source.h"
+#endif
+
+#ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
+#include "pvmf_source_context_data.h"
+#endif
+
+
+
+#define AMR_MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp"
 
 
 class PVPlayerDataSink;
@@ -166,7 +176,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -193,6 +202,8 @@
 
 class PVMFLocalDataSource;
 class PVMFOma1PassthruPluginFactory;
+class PVMFCPMPluginAccessInterfaceFactory;
+class PVMFSourceContextData;
 
 /*!
  *  A test case to test the normal engine sequence of playing a specified source with pass-through CPM plug-in
@@ -222,7 +233,7 @@
 class pvplayer_async_test_cpmopenplaystopreset : public pvplayer_async_test_base
 {
     public:
-        pvplayer_async_test_cpmopenplaystopreset(PVPlayerAsyncTestParam aTestParam):
+        pvplayer_async_test_cpmopenplaystopreset(PVPlayerAsyncTestParam aTestParam, bool aUsingDataStreamInput = false):
                 pvplayer_async_test_base(aTestParam)
                 , iPlayer(NULL)
                 , iDataSource(NULL)
@@ -236,8 +247,18 @@
                 , iIONodeText(NULL)
                 , iMIOFileOutText(NULL)
                 , iCurrentCmdId(0)
+                , iDataStreamFactory(NULL)
+                , iSourceContextData(NULL)
+                , iUsingDataStreamInput(aUsingDataStreamInput)
         {
-            iTestCaseName = _STRLIT_CHAR("CPM Open-Play-Stop-Reset");
+            if (aUsingDataStreamInput)
+            {
+                iTestCaseName = _STRLIT_CHAR("CPM Open-Play-Stop-Reset Using DataStream Input");
+            }
+            else
+            {
+                iTestCaseName = _STRLIT_CHAR("CPM Open-Play-Stop-Reset");
+            }
             iLocalDataSource = NULL;
             iPluginFactory = NULL;
         }
@@ -267,7 +288,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -290,10 +310,13 @@
         PVMFCPMPluginFactoryRegistryClient iPluginRegistryClient;
         PVMFOma1PassthruPluginFactory* iPluginFactory;
         OSCL_HeapString<OsclMemAllocator> iPluginMimeType;
+        PVMFCPMPluginAccessInterfaceFactory* iDataStreamFactory;
+        PVMFSourceContextData* iSourceContextData;
 
     private:
         OSCL_wHeapString<OsclMemAllocator> wFileName;
         oscl_wchar output[512];
+        bool iUsingDataStreamInput;
 };
 
 
@@ -380,7 +403,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1469,8 +1491,11 @@
                 , iIONodeAudio(NULL)
                 , iMIOFileOutAudio(NULL)
                 , iCurrentCmdId(0)
+                , iSourceContextData(NULL)
         {
             iTestCaseName = _STRLIT_CHAR("Set Begin Position-Play-Stop");
+            iTargetNumSeek = 1;
+            iNumSeek = 0;
         }
 
         ~pvplayer_async_test_setstartpositionplaystop() {}
@@ -1511,9 +1536,19 @@
         PVMFNodeInterface* iIONodeAudio;
         PvmiMIOControl* iMIOFileOutAudio;
         PVCommandId iCurrentCmdId;
+
+        void setMultipleSeekMode(uint32 aNum)
+        {
+            iTargetNumSeek = aNum;
+        }
+
     private:
         OSCL_wHeapString<OsclMemAllocator> wFileName;
         oscl_wchar output[512];
+        uint32 iTargetNumSeek;
+        uint32 iNumSeek;
+
+        PVMFSourceContextData* iSourceContextData;
 };
 
 
@@ -2418,7 +2453,6 @@
             STATE_RESUME,
             STATE_PAUSERESUME2,
             STATE_SHUTDOWN,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2614,7 +2648,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2664,22 +2697,16 @@
                 , iPlayer(NULL)
                 , iDataSource(NULL)
                 , iDataSinkVideo(NULL)
-                , iDataSinkAudio(NULL)
-                , iDataSinkText(NULL)
                 , iIONodeVideo(NULL)
-                , iIONodeAudio(NULL)
-                , iIONodeText(NULL)
-#ifdef USE_REF_FILEOUTPUT_FOR_VIDEO
                 , iMIOFileOutVideo(NULL)
-#else
-                , iMIOOutVideo(NULL)
-#endif
-                , iMIOOutAudio(NULL)
+                , iDataSinkAudio(NULL)
+                , iIONodeAudio(NULL)
+                , iMIOFileOutAudio(NULL)
+                , iDataSinkText(NULL)
+                , iIONodeText(NULL)
                 , iMIOFileOutText(NULL)
-#if USE_AUDIO_EXTN_INTERFACE
-                , iAudioOutputController(NULL)
-#endif // USE_AUDIO_EXTN_INTERFACE
                 , iCurrentCmdId(0)
+                , iSourceContextData(NULL)
         {
             iTestCaseName = _STRLIT_CHAR("SetPlaybackRange After Prepare");
         }
@@ -2710,6 +2737,331 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
+            STATE_CLEANUPANDCOMPLETE
+        };
+
+        PVTestState iState;
+
+        PVPlayerInterface* iPlayer;
+        PVPlayerDataSourceURL* iDataSource;
+        PVPlayerDataSink* iDataSinkVideo;
+        PVMFNodeInterface* iIONodeVideo;
+        PvmiMIOControl* iMIOFileOutVideo;
+        PVPlayerDataSink* iDataSinkAudio;
+        PVMFNodeInterface* iIONodeAudio;
+        PvmiMIOControl* iMIOFileOutAudio;
+        PVPlayerDataSink* iDataSinkText;
+        PVMFNodeInterface* iIONodeText;
+        PvmiMIOControl* iMIOFileOutText;
+        PVCommandId iCurrentCmdId;
+        Oscl_Vector<PVCommandId, OsclMemAllocator> iCmdIds;
+
+        Oscl_FileServer iFS;
+        Oscl_File iTimeLogFile;
+
+    private:
+        OSCL_wHeapString<OsclMemAllocator> wFileName;
+        oscl_wchar output[512];
+        PVMFSourceContextData* iSourceContextData;
+};
+
+/*!
+ *  A test case to test if the player engine can handle multiple pause seek resume during playback
+ *  - Data Source: Specified source
+ *  - Data Sink(s): Video[FileOutputNode-test_player_multireposition_[SRCFILENAME]_video.dat]\n
+ *                  Audio[FileOutputNode-test_player_multireposition_[SRCFILENAME]_audio.dat]\n
+ *                  Text[FileOutputNode-test_player_multireposition_[SRCFILENAME]_text.dat]
+ *  - Sequence:
+ *             -# CreatePlayer()
+ *             -# AddDataSource()/Init()/AddDataSink() (video)/AddDataSink() (audio)/AddDataSink() (text)/Prepare()/Start()
+ *             -# WAIT Duration/10 sec.
+ *             -# Pause()/SetPlaybackRange(Duration/4 sec, indeterminate)/Resume()
+ *             -# WAIT Duration/10 sec.
+ *             -# Pause()/SetPlaybackRange(Duration/4 sec, indeterminate)/Resume()
+ *             -#	:
+ *             -# EOS
+ *             -# Stop()/RemoveDataSink() (video)/RemoveDataSink() (audio)/RemoveDataSink() (text)/Reset()/RemoveDataSource()
+ *             -# DeletePlayer()
+ *
+ */
+class pvplayer_async_test_multipauseseekresume : public pvplayer_async_test_base
+{
+    public:
+        pvplayer_async_test_multipauseseekresume(PVPlayerAsyncTestParam aTestParam):
+                pvplayer_async_test_base(aTestParam)
+                , iPlayer(NULL)
+                , iDataSource(NULL)
+                , iDataSinkVideo(NULL)
+                , iIONodeVideo(NULL)
+                , iMIOFileOutVideo(NULL)
+                , iDataSinkAudio(NULL)
+                , iIONodeAudio(NULL)
+                , iMIOFileOutAudio(NULL)
+                , iDataSinkText(NULL)
+                , iIONodeText(NULL)
+                , iMIOFileOutText(NULL)
+                , iCurrentCmdId(0)
+                , iSessionDuration(0)
+                , iSourceContextData(NULL)
+        {
+            iTestCaseName = _STRLIT_CHAR("Multiple Pause SetPlaybackRange Resume");
+            iTargetNumPause = 1;
+            iNumPause = 0;
+        }
+
+        ~pvplayer_async_test_multipauseseekresume() {}
+
+        void StartTest();
+        void Run();
+
+        void CommandCompleted(const PVCmdResponse& aResponse);
+        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        enum PVTestState
+        {
+            STATE_CREATE,
+            STATE_ADDDATASOURCE,
+            STATE_INIT,
+            STATE_GETMETADATAKEYLIST,
+            STATE_GETMETADATAVALUELIST,
+            STATE_ADDDATASINK_VIDEO,
+            STATE_ADDDATASINK_AUDIO,
+            STATE_ADDDATASINK_TEXT,
+            STATE_PREPARE,
+            STATE_START,
+            STATE_PAUSE,
+            STATE_SETPLAYBACKRANGE,
+            STATE_RESUME,
+            STATE_STOP,
+            STATE_REMOVEDATASINK_VIDEO,
+            STATE_REMOVEDATASINK_AUDIO,
+            STATE_REMOVEDATASINK_TEXT,
+            STATE_RESET,
+            STATE_REMOVEDATASOURCE,
+            STATE_CLEANUPANDCOMPLETE
+        };
+
+        PVTestState iState;
+
+        PVPlayerInterface* iPlayer;
+        PVPlayerDataSourceURL* iDataSource;
+        PVPlayerDataSink* iDataSinkVideo;
+        PVMFNodeInterface* iIONodeVideo;
+        PvmiMIOControl* iMIOFileOutVideo;
+        PVPlayerDataSink* iDataSinkAudio;
+        PVMFNodeInterface* iIONodeAudio;
+        PvmiMIOControl* iMIOFileOutAudio;
+        PVPlayerDataSink* iDataSinkText;
+        PVMFNodeInterface* iIONodeText;
+        PvmiMIOControl* iMIOFileOutText;
+        PVCommandId iCurrentCmdId;
+        Oscl_Vector<PVCommandId, OsclMemAllocator> iCmdIds;
+
+        void setMultiplePauseMode(uint32 aNum)
+        {
+            iTargetNumPause = aNum;
+        }
+
+    private:
+        OSCL_wHeapString<OsclMemAllocator> wFileName;
+        oscl_wchar output[512];
+
+        PVPMetadataList iMetadataKeyList;
+        Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
+        int32 iNumValues;
+
+        uint32 iTargetNumPause;
+        uint32 iNumPause;
+        uint32 iSessionDuration;
+
+        PVMFSourceContextData* iSourceContextData;
+};
+
+/**
+* pvplayer_async_test_multiple_instance is an Open-Play-Stop test case
+* that launches a 2nd engine instance and plays the selected input
+* simultaneously from the two instances.
+*/
+class PVMFLocalDataSource;
+class PvOmapVideo;
+class PVRefOmapAudioOutput;
+
+
+class pvplayer_async_test_multiple_instance : public pvplayer_async_test_base
+{
+    public:
+        pvplayer_async_test_multiple_instance(PVPlayerAsyncTestParam aTestParam):
+                pvplayer_async_test_base(aTestParam)
+                , iPlayer(NULL)
+                , iDataSource(NULL)
+                , iDataSinkVideo(NULL)
+                , iDataSinkAudio(NULL)
+                , iDataSinkText(NULL)
+                , iIONodeVideo(NULL)
+                , iIONodeAudio(NULL)
+                , iIONodeText(NULL)
+                , iMOutVideo(NULL)
+                , iMOutAudio(NULL)
+                , iMOutText(NULL)
+                , iCurrentCmdId(0)
+        {
+            iSinkName = _STRLIT_WCHAR("pvplayer_async_test_multiple_instance_");
+            iTestCaseName = _STRLIT_CHAR("Multiple Instance Open-Play-Stop");
+            iLocalDataSource = NULL;
+
+            iParentInstance = NULL;
+            iChildThreadFailures = 0;
+            iChildThreadLeave = 0;
+            iChildThreadExit = false;
+            //make a persistent copy of the test params.
+            iParam = new PVPlayerAsyncTestParam();
+            iParam->Copy(aTestParam);
+        }
+
+        ~pvplayer_async_test_multiple_instance()
+        {
+            delete iParam;
+        }
+
+        //To support the 2nd instance of the test case.
+        pvplayer_async_test_multiple_instance* iParentInstance;
+        int32 iChildThreadFailures;
+        int32 iChildThreadLeave;
+        bool iChildThreadExit;
+        PVPlayerAsyncTestParam* iParam;
+        void ChildTestIsTrue(bool);
+        static void InThread(pvplayer_async_test_multiple_instance* parent);
+        //An observer class for the 2nd instance of the test case.
+        class ChildObserver: public pvplayer_async_test_observer
+        {
+            public:
+                void TestCompleted(test_case &tc);
+        };
+        //End 2nd instance support.
+
+        void StartTest();
+        void Run();
+
+        void CommandCompleted(const PVCmdResponse& aResponse);
+        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        enum PVTestState
+        {
+            STATE_CREATE,
+            STATE_ADDDATASOURCE,
+            STATE_INIT,
+            STATE_GETMETADATAKEYLIST,
+            STATE_GETMETADATAVALUELIST,
+            STATE_ADDDATASINK_VIDEO,
+            STATE_ADDDATASINK_AUDIO,
+            STATE_ADDDATASINK_TEXT,
+            STATE_PREPARE,
+            STATE_START,
+            STATE_STOP,
+            STATE_REMOVEDATASINK_VIDEO,
+            STATE_REMOVEDATASINK_AUDIO,
+            STATE_REMOVEDATASINK_TEXT,
+            STATE_RESET,
+            STATE_REMOVEDATASOURCE,
+            STATE_CLEANUPANDCOMPLETE
+        };
+
+        PVTestState iState;
+
+        PVPlayerInterface* iPlayer;
+        PVPlayerDataSourceURL* iDataSource;
+        PVPlayerDataSink* iDataSinkVideo;
+        PVPlayerDataSink* iDataSinkAudio;
+        PVPlayerDataSink* iDataSinkText;
+        PVMFNodeInterface* iIONodeVideo;
+        PVMFNodeInterface* iIONodeAudio;
+        PVMFNodeInterface* iIONodeText;
+        PvmiMIOControl* iMOutVideo;
+        PvmiMIOControl* iMOutAudio;
+        PvmiMIOControl* iMOutText;
+        PVCommandId iCurrentCmdId;
+
+        OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
+        oscl_wchar iTmpWCharBuffer[512];
+
+        PVMFLocalDataSource* iLocalDataSource;
+
+        void PrintMetadata();
+        PVPMetadataList iMetadataKeyList;
+        Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
+        int32 iNumValues;
+        OSCL_wHeapString<OsclMemAllocator> iSinkName;
+
+};
+
+/**
+* pvplayer_async_test_multiple_thread is an Open-Play-Stop test case
+* that launches engine instance in a second thread and tests controlling
+* engine from an app thread.
+*/
+class PVMFLocalDataSource;
+class PvOmapVideo;
+class PVRefOmapAudioOutput;
+class OsclExecScheduler;
+
+#include "threadsafe_queue.h"
+
+class pvplayer_async_test_multiple_thread : public pvplayer_async_test_base
+            , public ThreadSafeQueueObserver
+{
+    public:
+        pvplayer_async_test_multiple_thread(PVPlayerAsyncTestParam aTestParam):
+                pvplayer_async_test_base(aTestParam)
+                , iPlayer(NULL)
+                , iDataSource(NULL)
+                , iDataSinkVideo(NULL)
+                , iDataSinkAudio(NULL)
+                , iDataSinkText(NULL)
+                , iIONodeVideo(NULL)
+                , iIONodeAudio(NULL)
+                , iIONodeText(NULL)
+                , iMOutVideo(NULL)
+                , iMOutAudio(NULL)
+                , iMOutText(NULL)
+                , iCurrentCmdId(0)
+        {
+            iSinkName = _STRLIT_WCHAR("pvplayer_async_test_multiple_thread_");
+            iTestCaseName = _STRLIT_CHAR("Multiple Thread Open-Play-Stop");
+            iLocalDataSource = NULL;
+        }
+
+        ~pvplayer_async_test_multiple_thread()
+        {
+        }
+
+        void StartTest();
+        void Run();
+
+        void CommandCompleted(const PVCmdResponse& aResponse);
+        void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
+        void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
+
+        enum PVTestState
+        {
+            STATE_CREATE,
+            STATE_ADDDATASOURCE,
+            STATE_INIT,
+            STATE_GETMETADATAKEYLIST,
+            STATE_GETMETADATAVALUELIST,
+            STATE_RELEASEMETADATAVALUES,
+            STATE_ADDDATASINK_VIDEO,
+            STATE_ADDDATASINK_AUDIO,
+            STATE_ADDDATASINK_TEXT,
+            STATE_PREPARE,
+            STATE_START,
+            STATE_STOP,
+            STATE_REMOVEDATASINK_VIDEO,
+            STATE_REMOVEDATASINK_AUDIO,
+            STATE_REMOVEDATASINK_TEXT,
+            STATE_RESET,
+            STATE_REMOVEDATASOURCE,
             STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
@@ -2721,34 +3073,34 @@
         PVPlayerDataSink* iDataSinkVideo;
         PVPlayerDataSink* iDataSinkAudio;
         PVPlayerDataSink* iDataSinkText;
-
         PVMFNodeInterface* iIONodeVideo;
         PVMFNodeInterface* iIONodeAudio;
         PVMFNodeInterface* iIONodeText;
-#ifdef USE_REF_FILEOUTPUT_FOR_VIDEO
-        PVRefFileOutput* iMIOFileOutVideo;
-#else
-        PvmiMIOControl* iMIOOutVideo;
-#endif
-
-        PvmiMIOControl* iMIOOutAudio;
-
-        PVRefFileOutput* iMIOFileOutText;
-
-#if USE_AUDIO_EXTN_INTERFACE
-        PVMioAudioOutputControl* iAudioOutputController;
-#endif // USE_AUDIO_EXTN_INTERFACE
+        PvmiMIOControl* iMOutVideo;
+        PvmiMIOControl* iMOutAudio;
+        PvmiMIOControl* iMOutText;
         PVCommandId iCurrentCmdId;
-        Oscl_Vector<PVCommandId, OsclMemAllocator> iCmdIds;
 
-        Oscl_FileServer iFS;
-        Oscl_File iTimeLogFile;
+        OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
+        oscl_wchar iTmpWCharBuffer[512];
 
-    private:
-        OSCL_wHeapString<OsclMemAllocator> wFileName;
-        oscl_wchar output[512];
+        PVMFLocalDataSource* iLocalDataSource;
+
+        void PrintMetadata();
+        PVPMetadataList iMetadataKeyList;
+        Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
+        int32 iNumValues;
+        OSCL_wHeapString<OsclMemAllocator> iSinkName;
+
+        ThreadSafeQueue iThreadSafeCommandQueue;
+        ThreadSafeQueue iThreadSafeErrorQueue;
+        ThreadSafeQueue iThreadSafeInfoQueue;
+        void ThreadSafeQueueDataAvailable(ThreadSafeQueue*);
+        OsclSemaphore iThreadReadySem;
+        OsclSemaphore iThreadExitSem;
+        int32 iThreadErrors;
+        OsclExecScheduler* iThreadScheduler;
 };
 
-
 #endif // TEST_PV_PLAYER_ENGINE_TESTSET1_H_INCLUDED
 
diff --git a/engines/player/test/src/test_pv_player_engine_testset10.cpp b/engines/player/test/src/test_pv_player_engine_testset10.cpp
index 4f69740..74e3b82 100644
--- a/engines/player/test/src/test_pv_player_engine_testset10.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset10.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,6 +87,96 @@
 //
 void pvplayer_async_test_genericdelete::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -101,6 +191,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -168,12 +269,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
 
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -193,7 +294,7 @@
 
                         if (iProxyEnabled)
                         {
-                            streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                            streamingContext->iProxyName = _STRLIT_WCHAR("");
                             streamingContext->iProxyPort = 8080;
                         }
                     }
@@ -211,7 +312,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -231,15 +331,22 @@
 
                     if (iProxyEnabled)
                     {
-                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                         iStreamDataSource->iProxyPort = 8080;
                     }
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -254,7 +361,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -264,20 +371,23 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -303,7 +413,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -326,7 +436,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -387,7 +497,7 @@
             OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
 
-            // Unnecessary Header should not display
+            ///Unnecessary Header should not display
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_HeapString<OsclMemAllocator> protocolExtensionHeaderHead(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=HeadHeader;method=HEAD"));
@@ -416,7 +526,7 @@
 
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/keep-alive-interval;valtype=uint32");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-            iKVPSetAsync.value.uint32_value = 4;
+            iKVPSetAsync.value.uint32_value = 4; //0xffffffff;
             iErrorKVP = NULL;
             OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
@@ -459,15 +569,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -480,18 +590,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -507,15 +609,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -528,18 +630,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -629,6 +723,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -736,16 +831,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -758,6 +843,8 @@
             delete iStreamDataSource;
             iStreamDataSource = NULL;
 
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
 
             delete iDataSource;
             iDataSource = NULL;
@@ -869,8 +956,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -882,6 +969,7 @@
         case STATE_INIT:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                //iState=STATE_GETMETADATAKEYLIST;
                 if ((!iDeleteWhileProc) && (iEndState == iState))
                 {
                     iState = STATE_CLEANUPANDCOMPLETE;
@@ -930,8 +1018,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -946,8 +1034,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -955,7 +1043,9 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                //iState=STATE_ADDDATASINK_VIDEO;
+                //RunIfNotReady();
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -981,8 +1071,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1003,8 +1093,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1025,8 +1115,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1047,8 +1137,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1068,7 +1158,7 @@
                     {
                         if (oSeekEnable == true)
                         {
-                            if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                            if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                             {
                                 if (!iSeekDone)
                                 {
@@ -1103,8 +1193,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -1128,7 +1218,7 @@
                 {
                     if (iPlayListURL == true)
                     {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                         {
                             int32 error;
                             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -1152,8 +1242,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1176,8 +1266,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1202,8 +1292,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1224,8 +1314,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1239,8 +1329,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1254,8 +1344,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1269,8 +1359,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1337,8 +1427,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1363,14 +1453,15 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         default:
         {
             // Testing error if this is reached
+            //PVPATB_TEST_IS_TRUE(false);
             iState = STATE_CLEANUPANDCOMPLETE;
             RunIfNotReady();
         }
@@ -1515,8 +1606,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericdelete::HandleSocketNodeErrors(int32 aErr)
@@ -1923,37 +2012,22 @@
 
 void pvplayer_async_test_genericdelete::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
     switch (aEvent.GetEventType())
     {
+        case PVMFInfoErrorHandlingStart:
+        {
+            fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+        }
+        break;
+
+        case PVMFInfoErrorHandlingComplete:
+        {
+            fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+
         case PVMFInfoSourceFormatNotSupported:
         {
             // source rollover...
@@ -1974,9 +2048,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -2001,7 +2075,9 @@
         case PVMFInfoBufferingComplete:
             fprintf(iTestMsgOutputFile, "   PVMFInfoBufferingComplete\n");
             iNumBufferingComplete++;
-            // There should only be one Buffering Complete
+            //we should only get one of these.
+            //if(iNumBufferingComplete==2)
+            //	PVPATB_TEST_IS_TRUE(false);
             if (iNumBufferingComplete == 1)
             {
                 if (iState == STATE_WAIT_FOR_BUFFCOMPLETE)
@@ -2047,7 +2123,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -2061,6 +2137,7 @@
             }
             else
             {
+                //int32 localBufSize = aEvent.GetLocalBufferSize();
                 uint8* localBuf = aEvent.GetLocalBuffer();
                 if (localBuf != NULL)
                 {
@@ -2149,6 +2226,13 @@
             break;
         case PVMFInfoUnderflow:
             fprintf(iTestMsgOutputFile, "   PVMFInfoUnderflow\n");
+            /*
+            iNumUnderflow++;
+            //we should not get underflow before data ready
+            if(iNumUnderflow==1
+            	&& iNumDataReady==0)
+            	PVPATB_TEST_IS_TRUE(false);
+            */
             break;
         case PVMFInfoContentLength:
         {
@@ -2250,7 +2334,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
diff --git a/engines/player/test/src/test_pv_player_engine_testset10.h b/engines/player/test/src/test_pv_player_engine_testset10.h
index b746631..3df191c 100644
--- a/engines/player/test/src/test_pv_player_engine_testset10.h
+++ b/engines/player/test/src/test_pv_player_engine_testset10.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,11 @@
 #include "pvmf_streaming_data_source.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
 #include "pvmf_download_data_source.h"
@@ -46,14 +51,14 @@
 #endif
 
 
-#define AMR_MPEG4_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_RTSP_URL_2 "rtsp://test.mp4"
-#define H263_AMR_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://test.3gp"
-#define AAC_RTSP_URL     "rtsp://test.3gp"
-#define MPEG4_AAC_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_SDP_FILE "test.sdp"
+#define AMR_MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp"
+#define AMR_MPEG4_RTSP_URL_2 "rtsp://pvserveroha.pv.com/public/metadata/pvmetadata.mp4"
+#define H263_AMR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-122_h263-64.3gp"
+#define MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4rdatapartr64.3gp"
+#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4shorthdrr64.3gp"
+#define AAC_RTSP_URL     "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-aac64_novisual.3gp"
+#define MPEG4_AAC_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv2-aac64_mpeg4-rvlcs-64.3gp"
+#define AMR_MPEG4_SDP_FILE "pv_amr_mpeg4.sdp"
 
 class PVPlayerDataSourceURL;
 class PVPlayerDataSink;
@@ -61,6 +66,8 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
+class PVMFDownloadDataSourcePVX;
+
 
 /*!
  *  Test cases to test DeletePlayer() call (right after/while processing) each state while playing an local/PDL/rtsp url
@@ -123,6 +130,7 @@
                 , iPlayListURL(false)
                 , iSourceContextData(NULL)
                 , iStreamDataSource(NULL)
+                , iDownloadContextDataPVX(NULL)
                 , iPlayStarted(false)
                 , iSeekDone(false)
         {
@@ -234,8 +242,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
diff --git a/engines/player/test/src/test_pv_player_engine_testset11.cpp b/engines/player/test/src/test_pv_player_engine_testset11.cpp
index 0937b63..10d657c 100644
--- a/engines/player/test/src/test_pv_player_engine_testset11.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset11.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,6 +87,96 @@
 //
 void pvplayer_async_test_genericcancelall::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -101,6 +191,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -168,12 +269,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
 
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -207,7 +308,7 @@
                         int32 iDownloadProxyPort = 0;
                         if (iProxyEnabled)
                         {
-                            iDownloadProxy = _STRLIT_CHAR("");//172.16.2.42
+                            iDownloadProxy = _STRLIT_CHAR("");
                             iDownloadProxyPort = 7070;
                         }
 
@@ -217,7 +318,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -237,15 +337,21 @@
 
                     if (iProxyEnabled)
                     {
-                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                         iStreamDataSource->iProxyPort = 8080;
                     }
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -260,7 +366,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -270,20 +376,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -309,7 +417,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -332,6 +440,11 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
+            }
+            else
             {
                 userAgent = _STRLIT_WCHAR("NSPlayer/9.0 PVPlayerCoreEngineTestUserAgent");
             }
@@ -460,14 +573,18 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
+            }
             else
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_genericreset_");
@@ -477,18 +594,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -504,14 +613,18 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
+            }
             else
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_genericreset_");
@@ -521,18 +634,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -564,8 +669,12 @@
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
             if ((iCancelAllWhileProc) && (iEndState == iState))
             {
-                iState = STATE_CANCELALL;
-                RunIfNotReady();
+                fprintf(iTestMsgOutputFile, "***CancelAllCommands Player Engine...\n");
+                OSCL_TRY(error, iCancelAllCmdId = iPlayer->CancelAllCommands((OsclAny*) & iContextObject));
+                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+
+                iState = STATE_WAIT_FOR_CANCELALL;
+                RunIfNotReady(15000000);
             }
         }
         break;
@@ -622,6 +731,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -729,16 +839,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -751,6 +851,8 @@
             delete iStreamDataSource;
             iStreamDataSource = NULL;
 
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
 
             delete iDataSource;
             iDataSource = NULL;
@@ -863,8 +965,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -924,8 +1026,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -940,8 +1042,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -949,7 +1051,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -975,8 +1077,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -997,8 +1099,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1019,8 +1121,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1041,8 +1143,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1061,7 +1163,7 @@
                     {
                         if (oSeekEnable == true)
                         {
-                            if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                            if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                             {
                                 if (!iSeekDone)
                                 {
@@ -1097,8 +1199,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -1123,7 +1225,7 @@
                 {
                     if (iPlayListURL == true)
                     {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                         {
                             int32 error;
                             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -1147,8 +1249,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1171,8 +1273,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1197,8 +1299,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1219,8 +1321,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1234,8 +1336,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1249,8 +1351,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1264,8 +1366,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1333,8 +1435,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1359,8 +1461,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1512,8 +1614,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericcancelall::HandleSocketNodeErrors(int32 aErr)
@@ -1922,37 +2022,22 @@
 
 void pvplayer_async_test_genericcancelall::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
     switch (aEvent.GetEventType())
     {
+        case PVMFInfoErrorHandlingStart:
+        {
+            fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+        }
+        break;
+
+        case PVMFInfoErrorHandlingComplete:
+        {
+            fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+        }
+        break;
+
         case PVMFInfoSourceFormatNotSupported:
         {
             // source rollover...
@@ -1973,9 +2058,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -2045,7 +2130,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -2248,7 +2333,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
diff --git a/engines/player/test/src/test_pv_player_engine_testset11.h b/engines/player/test/src/test_pv_player_engine_testset11.h
index 9e2baa8..b79957d 100644
--- a/engines/player/test/src/test_pv_player_engine_testset11.h
+++ b/engines/player/test/src/test_pv_player_engine_testset11.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,11 @@
 #include "pvmf_streaming_data_source.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
 #include "pvmf_download_data_source.h"
@@ -48,14 +53,14 @@
 #ifndef DEFAULT_URLS_DEFINED
 #define DEFAULT_URLS_DEFINED
 
-#define AMR_MPEG4_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_RTSP_URL_2 "rtsp://test.mp4"
-#define H263_AMR_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://test.3gp"
-#define AAC_RTSP_URL     "rtsp://test.3gp"
-#define MPEG4_AAC_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_SDP_FILE "test.sdp"
+#define AMR_MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp"
+#define AMR_MPEG4_RTSP_URL_2 "rtsp://pvserveroha.pv.com/public/metadata/pvmetadata.mp4"
+#define H263_AMR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-122_h263-64.3gp"
+#define MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4rdatapartr64.3gp"
+#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4shorthdrr64.3gp"
+#define AAC_RTSP_URL     "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-aac64_novisual.3gp"
+#define MPEG4_AAC_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv2-aac64_mpeg4-rvlcs-64.3gp"
+#define AMR_MPEG4_SDP_FILE "pv_amr_mpeg4.sdp"
 #endif
 
 class PVPlayerDataSourceURL;
@@ -64,6 +69,8 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
+class PVMFDownloadDataSourcePVX;
+
 
 /*!
  *  Test cases to test CancellAllCommands() call (right after/while processing) each state when playing an local/PDL/rtsp url
@@ -126,6 +133,7 @@
                 , iPlayListURL(false)
                 , iSourceContextData(NULL)
                 , iStreamDataSource(NULL)
+                , iDownloadContextDataPVX(NULL)
                 , iPlayStarted(false)
                 , iSeekDone(false)
         {
@@ -238,8 +246,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
diff --git a/engines/player/test/src/test_pv_player_engine_testset12.cpp b/engines/player/test/src/test_pv_player_engine_testset12.cpp
index 5cc7b44..c6a1a10 100644
--- a/engines/player/test/src/test_pv_player_engine_testset12.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset12.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,6 +87,96 @@
 //
 void pvplayer_async_test_genericopenplaystop::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -101,6 +191,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -167,11 +268,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -203,8 +304,8 @@
                         int32 iDownloadProxyPort = 0;
                         if (iProxyEnabled)
                         {
-                            iDownloadProxy = _STRLIT_CHAR("");//172.16.2.42
-                            iDownloadProxyPort = 7070;//8080
+                            iDownloadProxy = _STRLIT_CHAR("");
+                            iDownloadProxyPort = 7070;
                         }
 
                         iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -213,7 +314,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -239,8 +339,14 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -255,9 +361,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    //streamingContext->iProxyName = _STRLIT_WCHAR("yes");
                     streamingContext->iProxyName = _STRLIT_WCHAR("");
-                    //streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -268,22 +372,24 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    //fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    //iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    //fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    //iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -309,7 +415,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -327,7 +433,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -527,15 +633,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -548,18 +654,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -569,15 +668,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -590,18 +689,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -672,7 +764,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -698,6 +790,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (0 == iNumSeek)
                     {
                         if (iSeekBeyondClipDurationMode)
@@ -809,16 +902,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -830,6 +913,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -928,17 +1014,21 @@
                 if (iSleepInState && (iState == iSleepState))
                 {
                     fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                    iState = STATE_CONFIGPARAMS;
                     RunIfNotReady(55000000);
                 }
-                iState = STATE_CONFIGPARAMS;
-                RunIfNotReady();
+                else
+                {
+                    iState = STATE_CONFIGPARAMS;
+                    RunIfNotReady();
+                }
             }
             else
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -974,10 +1064,14 @@
                     if (iSleepInState && (iState == iSleepState))
                     {
                         fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                        iState = STATE_ADDDATASINK_VIDEO;
                         RunIfNotReady(55000000);
                     }
-                    iState = STATE_ADDDATASINK_VIDEO;
-                    RunIfNotReady();
+                    else
+                    {
+                        iState = STATE_ADDDATASINK_VIDEO;
+                        RunIfNotReady();
+                    }
                 }
             }
             else
@@ -995,8 +1089,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -1011,8 +1105,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1020,18 +1114,22 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if (iSleepInState && (iState == iSleepState))
-                {
-                    fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
-                    RunIfNotReady(55000000);
-                }
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
                     {
-                        iState = STATE_START;
-                        RunIfNotReady();
+                        if (iSleepInState && (iState == iSleepState))
+                        {
+                            fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                            iState = STATE_START;
+                            RunIfNotReady(55000000);
+                        }
+                        else
+                        {
+                            iState = STATE_START;
+                            RunIfNotReady();
+                        }
                     }
                     else
                     {
@@ -1042,16 +1140,26 @@
                 }
                 else
                 {
-                    iState = STATE_START;
-                    RunIfNotReady();
+                    if (iSleepInState && (iState == iSleepState))
+                    {
+                        fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                        iState = STATE_START;
+                        RunIfNotReady(55000000);
+                    }
+                    else
+                    {
+                        iState = STATE_START;
+                        RunIfNotReady();
+                    }
+
                 }
             }
             else
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1061,17 +1169,21 @@
                 if (iSleepInState && (iState == iSleepState))
                 {
                     fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                    iState = STATE_ADDDATASINK_AUDIO;
                     RunIfNotReady(55000000);
                 }
-                iState = STATE_ADDDATASINK_AUDIO;
-                RunIfNotReady();
+                else
+                {
+                    iState = STATE_ADDDATASINK_AUDIO;
+                    RunIfNotReady();
+                }
             }
             else
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1081,17 +1193,21 @@
                 if (iSleepInState && (iState == iSleepState))
                 {
                     fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                    iState = STATE_PREPARE;
                     RunIfNotReady(55000000);
                 }
-                iState = STATE_PREPARE;
-                RunIfNotReady();
+                else
+                {
+                    iState = STATE_PREPARE;
+                    RunIfNotReady();
+                }
             }
             else
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1101,17 +1217,21 @@
                 if (iSleepInState && (iState == iSleepState))
                 {
                     fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                    iState = STATE_GETMETADATAKEYLIST;
                     RunIfNotReady(55000000);
                 }
-                iState = STATE_GETMETADATAKEYLIST;
-                RunIfNotReady();
+                else
+                {
+                    iState = STATE_GETMETADATAKEYLIST;
+                    RunIfNotReady();
+                }
             }
             else
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1119,14 +1239,9 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iPlayStarted = true;
-                if (iSleepInState && (iState == iSleepState))
-                {
-                    fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
-                    RunIfNotReady(55000000);
-                }
                 if (oLiveSession == false)
                 {
-                    if ((iSleepInState) && (oSeekEnable == true) && ((!iRolloverDone) || (iFileType == PVMF_ASFFF)))
+                    if ((iSleepInState) && (oSeekEnable == true) && ((!iRolloverDone) || (iFileType == PVMF_MIME_ASFFF)))
                     {
                         iState = STATE_SETPLAYBACKRANGE;
                         RunIfNotReady(10*1000*1000);
@@ -1136,7 +1251,7 @@
                         iState = STATE_PAUSE;
                         RunIfNotReady(10*1000*1000);
                     }
-                    else if (((oSeekEnable == true) && (!iRolloverDone)) || (((oSeekEnable == true)) && (iFileType == PVMF_ASFFF)))
+                    else if (((oSeekEnable == true) && (!iRolloverDone)) || (((oSeekEnable == true)) && (iFileType == PVMF_MIME_ASFFF)))
                     {
                         if (iNumSeek < 10)
                         {
@@ -1156,8 +1271,8 @@
                     {
                         if (oWaitForEOS == false)
                         {
-                            iState = STATE_EOSNOTREACHED;
-                            RunIfNotReady(180*1000*1000);
+                            iState = STATE_STOP;
+                            RunIfNotReady(30*1000*1000);
                         }
                     }
                 }
@@ -1172,8 +1287,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -1194,11 +1309,6 @@
                 {
                     iNumSeek++;
                     fprintf(iTestMsgOutputFile, "***Repositioning success...\n");
-                    if (iSleepInState && (iState == iSleepState))
-                    {
-                        fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
-                        RunIfNotReady(55000000);
-                    }
                     if (iSeekBeyondClipDurationMode == false)
                     {
                         if ((iNumSeek < 10) && (!iSleepInState))
@@ -1210,7 +1320,7 @@
                 }
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -1224,8 +1334,8 @@
                 }
                 if (oWaitForEOS == false)
                 {
-                    iState = STATE_EOSNOTREACHED;
-                    RunIfNotReady(180000000);
+                    iState = STATE_STOP;
+                    RunIfNotReady(30000000);
                 }
                 else
                 {
@@ -1242,8 +1352,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1251,12 +1361,6 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iNumPause++;
-                /* Sleep */
-                if (iSleepInState && (iState == iSleepState))
-                {
-                    fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
-                    RunIfNotReady(55000000);
-                }
                 iState = STATE_RESUME;
                 RunIfNotReady(PAUSE_RESUME_INTERVAL*1000*1000);
             }
@@ -1264,19 +1368,14 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_RESUME:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                if (iSleepInState && (iState == iSleepState))
-                {
-                    fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
-                    RunIfNotReady(55000000);
-                }
                 if ((oPauseResumeEnable == true) && (!iSleepInState))
                 {
                     if (iTargetNumPause != iNumPause)
@@ -1287,7 +1386,7 @@
                 }
                 if (oWaitForEOS == false)
                 {
-                    iState = STATE_EOSNOTREACHED;
+                    iState = STATE_STOP;
                     RunIfNotReady(180000000);
                 }
             }
@@ -1295,8 +1394,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1306,17 +1405,21 @@
                 if (iSleepInState && (iState == iSleepState))
                 {
                     fprintf(iTestMsgOutputFile, "\n***Delaying 55 seconds\n\n");
+                    iState = STATE_REMOVEDATASINK_AUDIO;
                     RunIfNotReady(55000000);
                 }
-                iState = STATE_REMOVEDATASINK_AUDIO;
-                RunIfNotReady();
+                else
+                {
+                    iState = STATE_REMOVEDATASINK_AUDIO;
+                    RunIfNotReady();
+                }
             }
             else
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1330,8 +1433,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1345,8 +1448,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1360,8 +1463,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1427,8 +1530,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1453,8 +1556,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1611,8 +1714,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericopenplaystop::HandleSocketNodeErrors(int32 aErr)
@@ -2039,34 +2140,15 @@
 
 void pvplayer_async_test_genericopenplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -2089,9 +2171,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                         iRolloverDone = true;
@@ -2176,7 +2258,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -2400,7 +2482,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
diff --git a/engines/player/test/src/test_pv_player_engine_testset12.h b/engines/player/test/src/test_pv_player_engine_testset12.h
index 5c5ba86..cf817b6 100644
--- a/engines/player/test/src/test_pv_player_engine_testset12.h
+++ b/engines/player/test/src/test_pv_player_engine_testset12.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,11 @@
 #include "pvmf_streaming_data_source.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
 #include "pvmf_download_data_source.h"
@@ -49,14 +54,14 @@
 #ifndef DEFAULT_URLS_DEFINED
 #define DEFAULT_URLS_DEFINED
 
-#define AMR_MPEG4_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_RTSP_URL_2 "rtsp://test.mp4"
-#define H263_AMR_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://test.3gp"
-#define AAC_RTSP_URL     "rtsp://test.3gp"
-#define MPEG4_AAC_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_SDP_FILE "test.sdp"
+#define AMR_MPEG4_RTSP_URL ""
+#define AMR_MPEG4_RTSP_URL_2 ""
+#define H263_AMR_RTSP_URL ""
+#define MPEG4_RTSP_URL ""
+#define MPEG4_SHRT_HDR_RTSP_URL ""
+#define AAC_RTSP_URL     ""
+#define MPEG4_AAC_RTSP_URL ""
+#define AMR_MPEG4_SDP_FILE "pv_amr_mpeg4.sdp"
 #endif
 
 #define NUM_PAUSE -1 // No of times 'PAUSE' infinite in case of Multiple Pause
@@ -75,6 +80,8 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
+class PVMFDownloadDataSourcePVX;
+
 
 /*!
  *  Test cases to test Multiple pause resume, multiple seek during playback
@@ -142,6 +149,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -200,7 +208,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -327,8 +334,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
diff --git a/engines/player/test/src/test_pv_player_engine_testset13.cpp b/engines/player/test/src/test_pv_player_engine_testset13.cpp
index db57450..13e27b0 100644
--- a/engines/player/test/src/test_pv_player_engine_testset13.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset13.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -82,14 +82,104 @@
 #define DEFAULT_FASTTRACK_DL_FILE "test.pvx"
 #define USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA	1
 
-//Network Reconnect time after Disconnection
-#define NW_RECONNECT_AFTER_DISCONNECT 5
+//Network Reconnect time after Disconnection milli secs
+#define NW_RECONNECT_AFTER_DISCONNECT 10
 
 //
 // pvplayer_async_test_genericprofiling section
 //
 void pvplayer_async_test_genericprofiling::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -104,6 +194,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -154,7 +255,7 @@
         {
             fprintf(iTestMsgOutputFile, "***Query Interface...\n");
             PVUuid capconfigifuuid = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->QueryInterface(capconfigifuuid, (PVInterface*&)iPlayerCapConfigIF, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -172,14 +273,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -191,11 +292,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -237,7 +338,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -263,8 +363,14 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -279,7 +385,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -289,20 +395,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -328,12 +436,12 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
             iDataSource->SetDataSourceFormatType(fileType);
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
             iNumPlay++;
@@ -347,7 +455,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -521,7 +629,7 @@
         case STATE_INIT:
         {
             fprintf(iTestMsgOutputFile, "***Initializing...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -530,7 +638,7 @@
         case STATE_GETMETADATAKEYLIST:
         {
             iMetadataKeyList.clear();
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataKeys(iMetadataKeyList, 0, -1, NULL, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -540,7 +648,7 @@
         {
             iMetadataValueList.clear();
             iNumValues = 0;
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, -1, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -550,15 +658,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -571,20 +679,12 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -594,15 +694,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -615,20 +715,12 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -637,7 +729,7 @@
         case STATE_PREPARE:
         {
             fprintf(iTestMsgOutputFile, "***Preparing...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -646,7 +738,7 @@
         case STATE_START:
         {
             fprintf(iTestMsgOutputFile, "***Starting...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -701,7 +793,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -720,7 +812,7 @@
                     start.iPlayElementIndex = 4;
                     end.iIndeterminate = true;
                     fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d ...\n", start.iPlayElementIndex);
-                    iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+                    iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
                     OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
                 }
                 else
@@ -728,11 +820,12 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     start.iPosValue.millisec_value = iSessionDuration / 4;
 
                     end.iIndeterminate = true;
                     fprintf(iTestMsgOutputFile, "***Repositioning to %d ms/%d ms...\n", start.iPosValue.millisec_value, iSessionDuration);
-                    iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+                    iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
                     OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
                 }
                 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -747,7 +840,7 @@
         case STATE_PAUSE:
         {
             fprintf(iTestMsgOutputFile, "***Pausing...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Pause((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -756,7 +849,7 @@
         case STATE_RESUME:
         {
             fprintf(iTestMsgOutputFile, "***Resuming...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Resume((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -774,7 +867,7 @@
         case STATE_STOP:
         {
             fprintf(iTestMsgOutputFile, "***Stopping...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -783,7 +876,7 @@
         case STATE_REMOVEDATASINK_VIDEO:
         {
             fprintf(iTestMsgOutputFile, "***Removing Video Data Sink...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -792,7 +885,7 @@
         case STATE_REMOVEDATASINK_AUDIO:
         {
             fprintf(iTestMsgOutputFile, "***Removing Audio Data Sink...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -801,7 +894,7 @@
         case STATE_RESET:
         {
             fprintf(iTestMsgOutputFile, "***Resetting...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Reset((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -810,22 +903,12 @@
         case STATE_REMOVEDATASOURCE:
         {
             fprintf(iTestMsgOutputFile, "***Removing Data Source...\n");
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -837,6 +920,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -864,7 +950,7 @@
 
         case STATE_CANCELALL:
         {
-            iClock.GetCurrentTime32(iPrevtime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iPrevtime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             OSCL_TRY(error, iCancelAllCmdId = iPlayer->CancelAllCommands((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
 
@@ -916,7 +1002,7 @@
     switch (iState)
     {
         case STATE_QUERYINTERFACE:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_QUERYINTERFACE commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -933,7 +1019,7 @@
             break;
 
         case STATE_ADDDATASOURCE:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_ADDDATASOURCE commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -944,8 +1030,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -955,7 +1041,7 @@
             break;
 
         case STATE_INIT:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_INIT commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1000,14 +1086,14 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
 
         case STATE_GETMETADATAKEYLIST:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_GETMETADATAKEYLIST commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1018,18 +1104,18 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_GETMETADATAVALUELIST:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_GETMETADATAVALUELIST commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -1054,13 +1140,13 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_ADDDATASINK_VIDEO:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_ADDDATASINK_VIDEO commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1071,13 +1157,13 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_ADDDATASINK_AUDIO:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_ADDDATASINK_AUDIO commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1088,13 +1174,13 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_PREPARE:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_PREPARE commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1105,13 +1191,13 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_START:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_START commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1131,8 +1217,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -1143,7 +1229,7 @@
 
         case STATE_SETPLAYBACKRANGE:
             iSeekDone = true;
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_SETPLAYBACKRANGE commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if ((aResponse.GetCmdStatus() == PVMFSuccess) ||
                     (aResponse.GetCmdStatus() == PVMFErrNotSupported))
@@ -1159,7 +1245,7 @@
 
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -1191,13 +1277,13 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_PAUSE:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_PAUSE commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1208,18 +1294,18 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_RESUME:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_RESUME commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iPauseResumeDone = true;
-                if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                 {
                     if (!iSeekDone)
                     {
@@ -1232,13 +1318,13 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_STOP:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_STOP commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1249,13 +1335,13 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_REMOVEDATASINK_AUDIO:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_REMOVEDATASINK_AUDIO commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1266,13 +1352,13 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_REMOVEDATASINK_VIDEO:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_REMOVEDATASINK_VIDEO commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1283,13 +1369,13 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_RESET:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_RESET commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1300,13 +1386,13 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_REMOVEDATASOURCE:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_REMOVEDATASOURCE commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1358,7 +1444,7 @@
             break;
 
         case STATE_CANCELALL:
-            iClock.GetCurrentTime32(iCurrenttime, iOverflow, OSCLCLOCK_MSEC);
+            iClock.GetCurrentTime32(iCurrenttime, iOverflow, PVMF_MEDIA_CLOCK_MSEC);
             fprintf(iTestMsgOutputFile, "STATE_CANCELALL commandCompleted took: %d milli secs\n\n", iCurrenttime - iPrevtime);
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -1371,8 +1457,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1397,8 +1483,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1555,8 +1641,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericprofiling::HandleSocketNodeErrors(int32 aErr)
@@ -1983,34 +2067,15 @@
 
 void pvplayer_async_test_genericprofiling::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -2033,9 +2098,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -2200,7 +2265,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -2238,6 +2303,96 @@
 //
 void pvplayer_async_test_genericplaypauserepositionresumetest::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -2252,6 +2407,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -2317,14 +2483,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -2336,11 +2502,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -2384,7 +2550,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -2412,8 +2577,14 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -2428,7 +2599,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -2438,20 +2609,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -2477,7 +2650,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -2495,7 +2668,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -2692,15 +2865,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -2713,18 +2886,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -2734,15 +2900,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -2755,18 +2921,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -2837,7 +2996,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -2863,6 +3022,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     start.iPosValue.millisec_value = iSessionDuration / 4;
 
                     end.iIndeterminate = true;
@@ -2943,16 +3103,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -2964,6 +3114,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -3066,8 +3219,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3119,8 +3272,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -3135,8 +3288,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3144,7 +3297,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -3169,8 +3322,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3184,8 +3337,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3199,8 +3352,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3214,8 +3367,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3243,8 +3396,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -3269,7 +3422,7 @@
 
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -3303,8 +3456,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3312,7 +3465,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iPauseDone = true;
-                if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                 {
                     if (!iSeekDone)
                     {
@@ -3325,8 +3478,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3343,8 +3496,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3358,8 +3511,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3373,8 +3526,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3388,8 +3541,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3403,8 +3556,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3470,8 +3623,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3496,8 +3649,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3654,8 +3807,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericplaypauserepositionresumetest::HandleSocketNodeErrors(int32 aErr)
@@ -4082,34 +4233,15 @@
 
 void pvplayer_async_test_genericplaypauserepositionresumetest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -4132,9 +4264,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -4205,7 +4337,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -4219,6 +4351,7 @@
         }
         else
         {
+            //int32 localBufSize = aEvent.GetLocalBufferSize();
             uint8* localBuf = aEvent.GetLocalBuffer();
             if (localBuf != NULL)
             {
@@ -4365,7 +4498,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -4402,6 +4535,96 @@
 //
 void pvplayer_async_test_genericopensetplaybackrangestartplaystoptest::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -4416,6 +4639,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -4481,14 +4715,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -4500,11 +4734,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -4546,7 +4780,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -4572,8 +4805,14 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -4588,7 +4827,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -4598,20 +4837,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -4637,7 +4878,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -4655,7 +4896,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -4852,15 +5093,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -4873,18 +5114,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -4894,15 +5128,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -4915,18 +5149,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -4939,7 +5166,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -4965,6 +5192,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     start.iPosValue.millisec_value = 5000;
 
                     end.iIndeterminate = true;
@@ -5085,16 +5313,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -5106,6 +5324,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -5208,8 +5429,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5262,8 +5483,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -5278,8 +5499,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5294,8 +5515,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5309,15 +5530,15 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_ADDDATASINK_AUDIO:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -5342,8 +5563,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5363,7 +5584,7 @@
 
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -5384,8 +5605,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5399,8 +5620,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5423,8 +5644,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -5443,8 +5664,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5458,8 +5679,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5473,8 +5694,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5488,8 +5709,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5555,8 +5776,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5581,8 +5802,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5739,8 +5960,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericopensetplaybackrangestartplaystoptest::HandleSocketNodeErrors(int32 aErr)
@@ -6167,34 +6386,15 @@
 
 void pvplayer_async_test_genericopensetplaybackrangestartplaystoptest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -6217,9 +6417,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -6243,7 +6443,9 @@
     {
         fprintf(iTestMsgOutputFile, "   PVMFInfoBufferingComplete\n");
         iNumBufferingComplete++;
-        // Only one buffering complete should be received
+        //we should only get one of these.
+        //if(iNumBufferingComplete==2)
+        //	PVPATB_TEST_IS_TRUE(false);
         if (iNumBufferingComplete == 1)
         {
             if (iState == STATE_WAIT_FOR_BUFFCOMPLETE)
@@ -6291,7 +6493,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -6451,7 +6653,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -6488,6 +6690,96 @@
 //
 void pvplayer_async_test_genericopenplayrepositiontoendtest::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -6502,6 +6794,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -6567,14 +6870,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -6586,11 +6889,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -6632,7 +6935,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -6658,8 +6960,14 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -6674,7 +6982,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -6684,20 +6992,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -6723,7 +7033,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -6741,7 +7051,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -6938,15 +7248,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -6959,18 +7269,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -6980,15 +7283,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -7001,18 +7304,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -7083,7 +7379,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -7109,6 +7405,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     start.iPosValue.millisec_value = iSessionDuration;
 
                     end.iIndeterminate = true;
@@ -7173,16 +7470,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -7194,6 +7481,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -7296,8 +7586,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7350,8 +7640,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -7366,8 +7656,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7375,7 +7665,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -7400,8 +7690,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7415,8 +7705,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7430,8 +7720,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7445,8 +7735,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7456,7 +7746,7 @@
             {
                 if (oLiveSession == false)
                 {
-                    if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                    if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                     {
                         if (!iSeekDone)
                         {
@@ -7476,8 +7766,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -7502,7 +7792,7 @@
 
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -7533,8 +7823,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7548,8 +7838,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7563,8 +7853,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7578,8 +7868,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7593,8 +7883,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7660,8 +7950,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7686,8 +7976,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7844,8 +8134,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericopenplayrepositiontoendtest::HandleSocketNodeErrors(int32 aErr)
@@ -8272,34 +8560,15 @@
 
 void pvplayer_async_test_genericopenplayrepositiontoendtest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -8322,9 +8591,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -8348,7 +8617,9 @@
     {
         fprintf(iTestMsgOutputFile, "   PVMFInfoBufferingComplete\n");
         iNumBufferingComplete++;
-        // Only one Buffering Complete should be received
+        //we should only get one of these.
+        //if(iNumBufferingComplete==2)
+        //	PVPATB_TEST_IS_TRUE(false);
         if (iNumBufferingComplete == 1)
         {
             if (iState == STATE_WAIT_FOR_BUFFCOMPLETE)
@@ -8396,7 +8667,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -8410,6 +8681,7 @@
         }
         else
         {
+            //int32 localBufSize = aEvent.GetLocalBufferSize();
             uint8* localBuf = aEvent.GetLocalBuffer();
             if (localBuf != NULL)
             {
@@ -8556,7 +8828,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -8593,6 +8865,96 @@
 //
 void pvplayer_async_test_genericnetworkdisconnect::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -8607,6 +8969,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -8674,12 +9047,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
 
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -8722,7 +9095,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -8741,34 +9113,84 @@
                     iStreamDataSource->iStreamStatsLoggingURL = wFileName;
                     if (iProxyEnabled)
                     {
-                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                         iStreamDataSource->iProxyPort = 8080;
                     }
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+            {
+#ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+                }
+
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+#endif
+            }
+
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
+#ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
+                    iSourceContextData->EnableDownloadHTTPSourceContext();
+                    PVInterface* sourceContext = NULL;
+                    PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                    if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                    {
+                        PVMFSourceContextDataDownloadHTTP* downloadContext =
+                            OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                        if (iProxyEnabled)
+                        {
+                            downloadContext->iProxyName = _STRLIT_CHAR("");
+                            downloadContext->iProxyPort = 7070;
+                        }
+                        downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                        downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                        downloadContext->iUserID = _STRLIT_CHAR("abc");
+                        downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                        downloadContext->bIsNewSession = true;
+                        downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    }
+#endif
                 }
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -8790,7 +9212,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -8920,15 +9342,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -8941,18 +9363,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8967,15 +9381,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -8988,18 +9402,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -9085,6 +9491,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -9187,16 +9594,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -9208,6 +9605,10 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -9319,8 +9720,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9376,10 +9777,20 @@
                 }
                 else
                 {
-                    // Init failed
-                    PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    if (iDisconnectState == STATE_ADDDATASOURCE || iDisconnectState == STATE_INIT)
+                    {
+                        // Init passed
+                        PVPATB_TEST_IS_TRUE(true);
+                        iState = STATE_CLEANUPANDCOMPLETE;
+                        RunIfNotReady();
+                    }
+                    else
+                    {
+                        // Init failed
+                        PVPATB_TEST_IS_TRUE(false);
+                        iState = STATE_CLEANUPANDCOMPLETE;
+                        RunIfNotReady();
+                    }
                 }
             }
             break;
@@ -9394,8 +9805,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9403,7 +9814,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -9429,8 +9840,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9448,8 +9859,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9467,8 +9878,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9484,10 +9895,21 @@
             }
             else
             {
-                // Prepare failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                if (iDisconnectState == STATE_INIT || iDisconnectState == STATE_ADDDATASINK_VIDEO
+                        || iDisconnectState == STATE_ADDDATASINK_AUDIO || iDisconnectState == STATE_PREPARE)
+                {
+                    // prepare passed
+                    PVPATB_TEST_IS_TRUE(true);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    // prepare failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
             }
             break;
 
@@ -9502,8 +9924,11 @@
                 {
                     if (oSeekEnable == true)
                     {
-                        iState = STATE_SETPLAYBACKRANGE;
-                        RunIfNotReady(10*1000*1000);
+                        if (iNumBufferingComplete)
+                        {
+                            iState = STATE_SETPLAYBACKRANGE;
+                            RunIfNotReady(10*1000*1000);
+                        }
                     }
                     else if (oPauseResumeEnable == true)
                     {
@@ -9530,8 +9955,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -9551,7 +9976,7 @@
                 }
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -9571,10 +9996,20 @@
             }
             else
             {
-                // SetPlaybackRange failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                if (iDisconnectState == STATE_SETPLAYBACKRANGE)
+                {
+                    // SetPlaybackRange  passed
+                    PVPATB_TEST_IS_TRUE(true);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    // SetPlaybackRange failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
             }
             break;
 
@@ -9593,8 +10028,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9613,10 +10048,20 @@
             }
             else
             {
-                // Resume failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                if (iDisconnectState == STATE_RESUME)
+                {
+                    // Resume passed
+                    PVPATB_TEST_IS_TRUE(true);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    // Resume failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
             }
             break;
 
@@ -9632,10 +10077,20 @@
             }
             else
             {
-                // Stop failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                if (iDisconnectState == STATE_STOP)
+                {
+                    // Stop passed
+                    PVPATB_TEST_IS_TRUE(true);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
+                else
+                {
+                    // Stop failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
             }
             break;
 
@@ -9649,8 +10104,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9664,8 +10119,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9679,8 +10134,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9748,8 +10203,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9774,8 +10229,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9855,8 +10310,17 @@
             break;
 
         case PVMFErrResource:
-            // Just log the error
-            PVPATB_TEST_IS_TRUE(false);
+            // Just pass the error
+            if (iDisconnectState == STATE_PREPARE || iDisconnectState == STATE_START
+                    || iDisconnectState == STATE_PAUSE || iDisconnectState == STATE_RESUME
+                    || iDisconnectState  == STATE_SETPLAYBACKRANGE)
+            {
+                PVPATB_TEST_IS_TRUE(true);
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(false);
+            }
             break;
 
         case PVMFErrCorrupt:
@@ -9865,8 +10329,17 @@
             break;
 
         case PVMFErrProcessing:
-            // Just log the error
-            PVPATB_TEST_IS_TRUE(false);
+            // Just pass the error
+            if (iDisconnectState == STATE_PREPARE || iDisconnectState == STATE_START
+                    || iDisconnectState == STATE_RESUME
+                    || iDisconnectState  == STATE_SETPLAYBACKRANGE)
+            {
+                PVPATB_TEST_IS_TRUE(true);
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(false);
+            }
             break;
 
         default:
@@ -9927,8 +10400,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericnetworkdisconnect::HandleSocketNodeErrors(int32 aErr)
@@ -10337,35 +10808,17 @@
 
 void pvplayer_async_test_genericnetworkdisconnect::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     switch (aEvent.GetEventType())
     {
         case PVMFInfoSourceFormatNotSupported:
@@ -10388,9 +10841,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -10418,6 +10871,12 @@
             // Only one buffering complete should be received
             if (iNumBufferingComplete == 1)
             {
+                if (iState == STATE_START && oSeekEnable == true)
+                {
+                    iState = STATE_SETPLAYBACKRANGE;
+                    RunIfNotReady();
+                }
+
                 if (iState == STATE_WAIT_FOR_BUFFCOMPLETE)
                 {
                     Cancel();
@@ -10453,7 +10912,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -10467,6 +10926,7 @@
             }
             else
             {
+                //int32 localBufSize = aEvent.GetLocalBufferSize();
                 uint8* localBuf = aEvent.GetLocalBuffer();
                 if (localBuf != NULL)
                 {
@@ -10656,7 +11116,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -10695,6 +11155,96 @@
 //
 void pvplayer_async_test_genericnetworkdisconnectreconnect::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -10709,6 +11259,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -10776,12 +11337,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
 
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -10824,7 +11385,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -10843,34 +11403,85 @@
                     iStreamDataSource->iStreamStatsLoggingURL = wFileName;
                     if (iProxyEnabled)
                     {
-                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                         iStreamDataSource->iProxyPort = 8080;
                     }
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+            {
+#ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+                }
+
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+#endif
+
+            }
+
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
+#ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
+                    iSourceContextData->EnableDownloadHTTPSourceContext();
+                    PVInterface* sourceContext = NULL;
+                    PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                    if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                    {
+                        PVMFSourceContextDataDownloadHTTP* downloadContext =
+                            OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                        if (iProxyEnabled)
+                        {
+                            downloadContext->iProxyName = _STRLIT_CHAR("");
+                            downloadContext->iProxyPort = 7070;
+                        }
+                        downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                        downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                        downloadContext->iUserID = _STRLIT_CHAR("abc");
+                        downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                        downloadContext->bIsNewSession = true;
+                        downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    }
+#endif
                 }
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -10892,7 +11503,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -10995,6 +11606,11 @@
             if ((iDisconnectWhileProc) && (iDisconnectState == iState))
             {
                 disableNetwork();
+                iState = STATE_RECONNECT;
+                iNextState = STATE_ADDDATASINK_VIDEO;
+                iNextStateActiveTime = 0;
+                RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
+                break;
             }
         }
         break;
@@ -11020,15 +11636,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -11041,18 +11657,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -11067,15 +11675,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -11088,18 +11696,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -11118,6 +11718,11 @@
             if ((iDisconnectWhileProc) && (iDisconnectState == iState))
             {
                 disableNetwork();
+                iState = STATE_RECONNECT;
+                iNextState = STATE_GETMETADATAKEYLIST;
+                iNextStateActiveTime = 0;
+                RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
+                break;
             }
         }
         break;
@@ -11185,6 +11790,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -11197,6 +11803,11 @@
                 if ((iDisconnectWhileProc) && (iDisconnectState == iState))
                 {
                     disableNetwork();
+                    iState = STATE_RECONNECT;
+                    iNextState = STATE_STOP;
+                    iNextStateActiveTime = 10;
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
+                    break;
                 }
             }
             else
@@ -11226,6 +11837,11 @@
             if ((iDisconnectWhileProc) && (iDisconnectState == iState))
             {
                 disableNetwork();
+                iState = STATE_RECONNECT;
+                iNextState = STATE_STOP;
+                iNextStateActiveTime = 10;
+                RunIfNotReady();//NW_RECONNECT_AFTER_DISCONNECT*1000);
+                break;
             }
         }
         break;
@@ -11247,6 +11863,11 @@
             if ((iDisconnectWhileProc) && (iDisconnectState == iState))
             {
                 disableNetwork();
+                iState = STATE_RECONNECT;
+                iNextState = STATE_REMOVEDATASINK_AUDIO;
+                iNextStateActiveTime = 0;
+                RunIfNotReady();
+                break;
             }
         }
         break;
@@ -11287,16 +11908,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -11308,6 +11919,10 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -11359,7 +11974,15 @@
         case STATE_RECONNECT:
         {
             enableNetwork();
-            if (iNextState != STATE_RECONNECT)
+            if (iDisconnectWhileProc && iDisconnectState != STATE_ADDDATASOURCE
+                    && iDisconnectState != STATE_ADDDATASINK_VIDEO
+                    && iDisconnectState != STATE_ADDDATASINK_AUDIO
+                    && iDisconnectState != STATE_START
+                    && iDisconnectState != STATE_PAUSE)
+            {
+                iState = iDisconnectState;
+            }
+            else if (iNextState != STATE_RECONNECT)
             {
                 iState = iNextState;
                 if (iNextStateActiveTime)
@@ -11434,7 +12057,7 @@
                     iState = STATE_RECONNECT;
                     iNextState = STATE_CONFIGPARAMS;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
                 iState = STATE_CONFIGPARAMS;
@@ -11444,8 +12067,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11460,6 +12083,11 @@
                 if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                 {
                     disableNetwork();
+                    iState = STATE_RECONNECT;
+                    iNextState = STATE_ADDDATASINK_VIDEO;
+                    iNextStateActiveTime = 0;
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
+                    break;
                 }
                 if (iDownloadOnly)
                 {
@@ -11482,14 +12110,6 @@
                 }
                 else
                 {
-                    if (iDisconnectState == iState)
-                    {
-                        iState = STATE_RECONNECT;
-                        iNextState = STATE_ADDDATASINK_VIDEO;
-                        iNextStateActiveTime = 0;
-                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
-                        break;
-                    }
                     iState = STATE_ADDDATASINK_VIDEO;
                     RunIfNotReady();
                 }
@@ -11510,8 +12130,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -11526,8 +12146,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11535,7 +12155,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -11561,8 +12181,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11578,7 +12198,7 @@
                     iState = STATE_RECONNECT;
                     iNextState = STATE_ADDDATASINK_AUDIO;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
                 iState = STATE_ADDDATASINK_AUDIO;
@@ -11588,8 +12208,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11605,7 +12225,7 @@
                     iState = STATE_RECONNECT;
                     iNextState = STATE_PREPARE;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
                 iState = STATE_PREPARE;
@@ -11615,8 +12235,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11626,13 +12246,10 @@
                 if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                 {
                     disableNetwork();
-                }
-                if (iDisconnectState == iState)
-                {
                     iState = STATE_RECONNECT;
                     iNextState = STATE_GETMETADATAKEYLIST;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
                 iState = STATE_GETMETADATAKEYLIST;
@@ -11642,8 +12259,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11663,7 +12280,7 @@
                             iState = STATE_RECONNECT;
                             iNextState = STATE_SETPLAYBACKRANGE;
                             iNextStateActiveTime = 10;
-                            RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                            RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                             break;
                         }
                         iState = STATE_SETPLAYBACKRANGE;
@@ -11676,7 +12293,7 @@
                             iState = STATE_RECONNECT;
                             iNextState = STATE_PAUSE;
                             iNextStateActiveTime = 10;
-                            RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                            RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                             break;
                         }
                         iState = STATE_PAUSE;
@@ -11689,7 +12306,7 @@
                             iState = STATE_RECONNECT;
                             iNextState = STATE_STOP;
                             iNextStateActiveTime = 30;
-                            RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                            RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                             break;
                         }
                         if (oWaitForEOS == false)
@@ -11706,7 +12323,7 @@
                         iState = STATE_RECONNECT;
                         iNextState = STATE_STOP;
                         iNextStateActiveTime = 60;
-                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                         break;
                     }
                     //run for 1 mins and stop
@@ -11718,8 +12335,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -11739,7 +12356,7 @@
                 }
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -11753,23 +12370,24 @@
                 }
                 if (oWaitForEOS == false)
                 {
-                    if (iDisconnectState == iState)
+                    if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                     {
                         iState = STATE_RECONNECT;
-                        iNextState = STATE_EOSNOTREACHED;
-                        iNextStateActiveTime = 180;
-                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                        iNextState = STATE_STOP;
+                        iNextStateActiveTime = 10;
+                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                         break;
                     }
-                    iState = STATE_EOSNOTREACHED;
-                    RunIfNotReady(180000000);
+                    iState = STATE_STOP;
+                    RunIfNotReady(10000000);
+                    break;
                 }
-                if (iDisconnectState == iState)
+                if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                 {
                     iState = STATE_RECONNECT;
                     iNextState = STATE_RECONNECT;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
             }
@@ -11777,8 +12395,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11794,7 +12412,7 @@
                     iState = STATE_RECONNECT;
                     iNextState = STATE_RESUME;
                     iNextStateActiveTime = 10;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady();
                     break;
                 }
                 iState = STATE_RESUME;
@@ -11803,10 +12421,46 @@
             }
             else
             {
-                // Pause failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                PVInterface* iface = (PVInterface*)(aResponse.GetEventExtensionInterface());
+                if (iface != NULL)
+                {
+                    PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+                    PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+                    if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+                    {
+                        PVUuid engerruuid;
+                        int32 errCodeEng;
+                        infomsgiface->GetCodeUUID(errCodeEng, engerruuid);
+
+                        if (engerruuid == PVPlayerErrorInfoEventTypesUUID)
+                        {
+                            PVMFErrorInfoMessageInterface* sourceNodeErrorIF =
+                                infomsgiface->GetNextMessage();
+
+                            if (sourceNodeErrorIF != NULL)
+                            {
+                                PVUuid eventuuid;
+                                int32 srcErrCode;
+                                sourceNodeErrorIF->GetCodeUUID(srcErrCode, eventuuid);
+                                if ((eventuuid == PVMFRTSPClientEngineNodeEventTypeUUID) &&
+                                        (srcErrCode == PVMFRTSPClientEngineNodeErrorRTSPSocketConnectError))
+                                {
+                                    PVPATB_TEST_IS_TRUE(true);
+                                    fprintf(iTestMsgOutputFile, "Pause is Fail due to PVMFRTSPClientEngineNodeErrorRTSPSocketConnectError\n");
+                                    iState = STATE_CLEANUPANDCOMPLETE;
+                                    RunIfNotReady();
+                                }
+                                else
+                                {
+                                    // Pause failed
+                                    PVPATB_TEST_IS_TRUE(false);
+                                    iState = STATE_CLEANUPANDCOMPLETE;
+                                    RunIfNotReady();
+                                }
+                            }
+                        }
+                    }
+                }
             }
             break;
 
@@ -11819,23 +12473,23 @@
                 }
                 if (oWaitForEOS == false)
                 {
-                    if (iDisconnectState == iState)
+                    if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                     {
                         iState = STATE_RECONNECT;
-                        iNextState = STATE_EOSNOTREACHED;
-                        iNextStateActiveTime = 180;
-                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                        iNextState = STATE_STOP;
+                        iNextStateActiveTime = 10;
+                        RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                         break;
                     }
-                    iState = STATE_EOSNOTREACHED;
-                    RunIfNotReady(180000000);
+                    iState = STATE_STOP;
+                    RunIfNotReady(10000000);
                 }
-                if (iDisconnectState == iState)
+                if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                 {
                     iState = STATE_RECONNECT;
                     iNextState = STATE_RECONNECT;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
             }
@@ -11843,8 +12497,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11854,13 +12508,10 @@
                 if ((!iDisconnectWhileProc) && (iDisconnectState == iState))
                 {
                     disableNetwork();
-                }
-                if (iDisconnectState == iState)
-                {
                     iState = STATE_RECONNECT;
                     iNextState = STATE_REMOVEDATASINK_AUDIO;
                     iNextStateActiveTime = 0;
-                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000*1000);
+                    RunIfNotReady(NW_RECONNECT_AFTER_DISCONNECT*1000);
                     break;
                 }
                 iState = STATE_REMOVEDATASINK_AUDIO;
@@ -11868,10 +12519,53 @@
             }
             else
             {
-                // Stop failed
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                PVInterface* iface = (PVInterface*)(aResponse.GetEventExtensionInterface());
+                if (iface != NULL)
+                {
+                    PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+                    PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+                    if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+                    {
+                        PVUuid engerruuid;
+                        int32 errCodeEng;
+                        infomsgiface->GetCodeUUID(errCodeEng, engerruuid);
+
+                        if (engerruuid == PVPlayerErrorInfoEventTypesUUID)
+                        {
+                            PVMFErrorInfoMessageInterface* sourceNodeErrorIF =
+                                infomsgiface->GetNextMessage();
+
+                            if (sourceNodeErrorIF != NULL)
+                            {
+                                PVUuid eventuuid;
+                                int32 srcErrCode;
+                                sourceNodeErrorIF->GetCodeUUID(srcErrCode, eventuuid);
+                                if ((eventuuid == PVMFRTSPClientEngineNodeEventTypeUUID) &&
+                                        (srcErrCode == PVMFRTSPClientEngineNodeErrorRTSPSocketConnectError))
+                                {
+                                    PVPATB_TEST_IS_TRUE(true);
+                                    fprintf(iTestMsgOutputFile, "Stop is Fail due to PVMFRTSPClientEngineNodeErrorRTSPSocketConnectError\n");
+                                    iState = STATE_CLEANUPANDCOMPLETE;
+                                    RunIfNotReady();
+                                }
+                                else
+                                {
+                                    // Stop failed
+                                    PVPATB_TEST_IS_TRUE(false);
+                                    iState = STATE_CLEANUPANDCOMPLETE;
+                                    RunIfNotReady(5000000);
+                                }
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    // Stop failed
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
+                }
             }
             break;
 
@@ -11885,23 +12579,23 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_REMOVEDATASINK_VIDEO:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                iState = STATE_CLEANUPANDCOMPLETE;
+                iState = STATE_RESET;
                 RunIfNotReady();
             }
             else
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11915,8 +12609,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11984,8 +12678,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12010,8 +12704,26 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RECONNECT:
+            //Should never come here
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                // iDisconnectState failed
+                fprintf(iTestMsgOutputFile, "State %d failed...\n", iDisconnectState);
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12163,8 +12875,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericnetworkdisconnectreconnect::HandleSocketNodeErrors(int32 aErr)
@@ -12573,35 +13283,17 @@
 
 void pvplayer_async_test_genericnetworkdisconnectreconnect::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     switch (aEvent.GetEventType())
     {
         case PVMFInfoSourceFormatNotSupported:
@@ -12624,9 +13316,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -12689,7 +13381,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -12892,7 +13584,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -12931,6 +13623,96 @@
 //
 void pvplayer_async_test_genericcancelallnetworkdisconnect::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -12945,6 +13727,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -13012,12 +13805,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
 
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -13060,7 +13853,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -13079,34 +13871,84 @@
                     iStreamDataSource->iStreamStatsLoggingURL = wFileName;
                     if (iProxyEnabled)
                     {
-                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                         iStreamDataSource->iProxyPort = 8080;
                     }
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+            {
+#ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+
+                }
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+#endif
+            }
+
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
+#ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
+                    iSourceContextData->EnableDownloadHTTPSourceContext();
+                    PVInterface* sourceContext = NULL;
+                    PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                    if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                    {
+                        PVMFSourceContextDataDownloadHTTP* downloadContext =
+                            OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                        if (iProxyEnabled)
+                        {
+                            downloadContext->iProxyName = _STRLIT_CHAR("");
+                            downloadContext->iProxyPort = 7070;
+                        }
+                        downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                        downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                        downloadContext->iUserID = _STRLIT_CHAR("abc");
+                        downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                        downloadContext->bIsNewSession = true;
+                        downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    }
+#endif
                 }
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -13129,7 +13971,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -13262,15 +14104,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -13283,18 +14125,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13310,15 +14144,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -13331,18 +14165,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13431,6 +14257,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -13538,16 +14365,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -13559,6 +14376,10 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -13674,8 +14495,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13736,8 +14557,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -13752,8 +14573,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13761,7 +14582,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -13787,8 +14608,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13809,8 +14630,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13831,8 +14652,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13853,8 +14674,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13901,8 +14722,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -13925,7 +14746,7 @@
                 {
                     if (iPlayListURL == true)
                     {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                         {
                             int32 error;
                             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -13949,8 +14770,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13973,8 +14794,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13999,8 +14820,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14021,8 +14842,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14036,8 +14857,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14051,8 +14872,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14066,8 +14887,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14135,8 +14956,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14161,8 +14982,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14314,8 +15135,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericcancelallnetworkdisconnect::HandleSocketNodeErrors(int32 aErr)
@@ -14724,35 +15543,17 @@
 
 void pvplayer_async_test_genericcancelallnetworkdisconnect::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     switch (aEvent.GetEventType())
     {
         case PVMFInfoSourceFormatNotSupported:
@@ -14781,9 +15582,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -14846,7 +15647,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -14860,6 +15661,7 @@
             }
             else
             {
+                //int32 localBufSize = aEvent.GetLocalBufferSize();
                 uint8* localBuf = aEvent.GetLocalBuffer();
                 if (localBuf != NULL)
                 {
@@ -15049,7 +15851,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -15088,6 +15890,96 @@
 //
 void pvplayer_async_test_genericplaypauserepositionresumenwdisconnectcancelalltest::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -15102,6 +15994,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -15167,14 +16070,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -15186,11 +16089,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -15223,7 +16126,7 @@
                         if (iProxyEnabled)
                         {
                             iDownloadProxy = _STRLIT_CHAR("");
-                            iDownloadProxyPort = 7070;//8080
+                            iDownloadProxyPort = 7070;
                         }
 
                         iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -15232,7 +16135,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -15258,8 +16160,14 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -15274,7 +16182,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -15284,20 +16192,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -15323,7 +16233,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -15341,7 +16251,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -15538,15 +16448,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -15559,18 +16469,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -15580,15 +16483,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -15601,18 +16504,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -15683,7 +16579,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -15709,6 +16605,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     start.iPosValue.millisec_value = iSessionDuration / 4;
 
                     end.iIndeterminate = true;
@@ -15792,16 +16689,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -15813,6 +16700,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -15916,8 +16806,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15970,8 +16860,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -15986,8 +16876,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15997,7 +16887,7 @@
                 PrintMetadataInfo();
                 //iState=STATE_ADDDATASINK_VIDEO;
                 //RunIfNotReady();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -16022,8 +16912,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16037,8 +16927,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16052,8 +16942,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16067,8 +16957,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16096,8 +16986,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -16122,7 +17012,7 @@
 
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -16156,8 +17046,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16165,7 +17055,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iPauseDone = true;
-                if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                 {
                     if (!iSeekDone)
                     {
@@ -16178,8 +17068,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16196,8 +17086,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16211,8 +17101,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16226,8 +17116,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16241,8 +17131,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16256,8 +17146,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16323,8 +17213,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16349,8 +17239,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16507,8 +17397,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericplaypauserepositionresumenwdisconnectcancelalltest::HandleSocketNodeErrors(int32 aErr)
@@ -16935,34 +17823,15 @@
 
 void pvplayer_async_test_genericplaypauserepositionresumenwdisconnectcancelalltest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -16985,9 +17854,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -17059,7 +17928,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -17073,6 +17942,7 @@
         }
         else
         {
+            //int32 localBufSize = aEvent.GetLocalBufferSize();
             uint8* localBuf = aEvent.GetLocalBuffer();
             if (localBuf != NULL)
             {
@@ -17219,7 +18089,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -17256,6 +18126,96 @@
 //
 void pvplayer_async_test_genericpvmferrorcorruptrenotified::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -17270,6 +18230,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -17334,14 +18305,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -17353,11 +18324,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -17390,7 +18361,7 @@
                         if (iProxyEnabled)
                         {
                             iDownloadProxy = _STRLIT_CHAR("");
-                            iDownloadProxyPort = 7070;//8080
+                            iDownloadProxyPort = 7070;
                         }
 
                         iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -17399,7 +18370,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -17425,27 +18395,36 @@
 #endif
                 }
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
                 }
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -17463,7 +18442,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -17647,16 +18626,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -17668,6 +18637,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -17770,8 +18742,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -17804,8 +18776,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                     break;
                 }
             }
@@ -17875,8 +18847,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -17901,8 +18873,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -18060,8 +19032,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericpvmferrorcorruptrenotified::HandleSocketNodeErrors(int32 aErr)
@@ -18488,34 +19458,15 @@
 
 void pvplayer_async_test_genericpvmferrorcorruptrenotified::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -18538,9 +19489,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -18667,7 +19618,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -18704,6 +19655,96 @@
 //
 void pvplayer_async_test_genericopenplaygetmetadatatest::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -18718,6 +19759,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -18783,14 +19835,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -18802,11 +19854,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -18841,7 +19894,7 @@
                         if (iProxyEnabled)
                         {
                             iDownloadProxy = _STRLIT_CHAR("");
-                            iDownloadProxyPort = 7070;//8080
+                            iDownloadProxyPort = 7070;
                         }
 
                         iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -18850,7 +19903,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -18878,27 +19930,11 @@
 #endif
                 }
             }
-            if (iProtocolRollOver)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
-                {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
-                }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
-                {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
-                }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
-                {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
-                }
-            }
-            else if (iProtocolRollOverWithUnknownURLType)
-            {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -18916,7 +19952,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -19113,15 +20149,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -19134,18 +20170,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -19155,15 +20184,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -19176,18 +20205,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -19335,16 +20357,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -19356,6 +20368,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -19458,8 +20473,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19512,8 +20527,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -19528,8 +20543,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19537,7 +20552,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -19562,8 +20577,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19577,8 +20592,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19592,8 +20607,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19607,8 +20622,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19631,8 +20646,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19646,8 +20661,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19661,8 +20676,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19677,8 +20692,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19695,8 +20710,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19716,8 +20731,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19731,8 +20746,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19746,8 +20761,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19761,8 +20776,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19828,8 +20843,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -19854,8 +20869,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -20012,8 +21027,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericopenplaygetmetadatatest::HandleSocketNodeErrors(int32 aErr)
@@ -20440,34 +21453,15 @@
 
 void pvplayer_async_test_genericopenplaygetmetadatatest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -20490,9 +21484,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -20547,7 +21541,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -20561,6 +21555,7 @@
         }
         else
         {
+            //int32 localBufSize = aEvent.GetLocalBufferSize();
             uint8* localBuf = aEvent.GetLocalBuffer();
             if (localBuf != NULL)
             {
@@ -20771,7 +21766,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -20810,6 +21805,96 @@
 //
 void pvplayer_async_test_genericopengetmetadatapictest::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -20824,6 +21909,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -20889,14 +21985,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -20908,11 +22004,12 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -20956,7 +22053,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -20984,28 +22080,13 @@
 #endif
                 }
             }
-            if (iProtocolRollOver)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
-                {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
-                }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
-                {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
-                }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
-                {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
-                }
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
             }
-            else if (iProtocolRollOverWithUnknownURLType)
-            {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
-            }
+
 
             iDataSource->SetDataSourceURL(wFileName);
             iDataSource->SetDataSourceFormatType(fileType);
@@ -21022,7 +22103,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -21219,15 +22300,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
             }
@@ -21240,18 +22321,11 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -21261,15 +22335,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
             }
@@ -21282,18 +22356,11 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -21408,16 +22475,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -21429,6 +22486,9 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -21531,8 +22591,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21585,8 +22645,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -21601,8 +22661,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21610,7 +22670,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -21635,8 +22695,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21650,8 +22710,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21665,8 +22725,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21680,8 +22740,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21704,8 +22764,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21725,8 +22785,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21740,8 +22800,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21755,8 +22815,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21770,8 +22830,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21837,8 +22897,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -21863,8 +22923,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -22021,8 +23081,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericopengetmetadatapictest::HandleSocketNodeErrors(int32 aErr)
@@ -22449,34 +23507,15 @@
 
 void pvplayer_async_test_genericopengetmetadatapictest::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -22499,9 +23538,9 @@
                     uint8* localBuf = aEvent.GetLocalBuffer();
                     if (localBuf != NULL)
                     {
-                        uint32 srcFormat = 0;
+                        PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                         oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                         //The clip type needs a rollover, store the actual clip type
                         iFileType = srcFormat;
                     }
@@ -22556,7 +23595,7 @@
 
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
-        if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+        if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
         {
             if (aEvent.GetLocalBuffer()[0] == 0
                     || aEvent.GetLocalBuffer()[0] == 100)
@@ -22570,6 +23609,7 @@
         }
         else
         {
+            //int32 localBufSize = aEvent.GetLocalBufferSize();
             uint8* localBuf = aEvent.GetLocalBuffer();
             if (localBuf != NULL)
             {
@@ -22798,7 +23838,7 @@
                     Oscl_FileServer fs;
                     fs.Connect();
                     Oscl_File sinkfile;
-                    int32 result = sinkfile.Open(sinkfilename.get_cstr(), Oscl_File::MODE_READWRITE, fs);
+                    uint32 result = sinkfile.Open(sinkfilename.get_cstr(), Oscl_File::MODE_READWRITE, fs);
                     if (result == 0)
                     {
                         result = sinkfile.Write(buf, 1, size);
@@ -22830,7 +23870,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
diff --git a/engines/player/test/src/test_pv_player_engine_testset13.h b/engines/player/test/src/test_pv_player_engine_testset13.h
index e343811..dd8ca92 100644
--- a/engines/player/test/src/test_pv_player_engine_testset13.h
+++ b/engines/player/test/src/test_pv_player_engine_testset13.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,11 @@
 #include "pvmf_streaming_data_source.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
 #include "pvmf_download_data_source.h"
@@ -48,17 +53,17 @@
 
 #ifndef DEFAULT_URLS_DEFINED
 #define DEFAULT_URLS_DEFINED
-#define AMR_MPEG4_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_RTSP_URL_2 "rtsp://test.mp4"
-#define H263_AMR_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://test.3gp"
-#define AAC_RTSP_URL     "rtsp://test.3gp"
-#define MPEG4_AAC_RTSP_URL "rtsp://test.3gp"
+#define AMR_MPEG4_RTSP_URL ""
+#define AMR_MPEG4_RTSP_URL_2 ""
+#define H263_AMR_RTSP_URL ""
+#define MPEG4_RTSP_URL ""
+#define MPEG4_SHRT_HDR_RTSP_URL ""
+#define AAC_RTSP_URL     ""
+#define MPEG4_AAC_RTSP_URL ""
 #define AMR_MPEG4_SDP_FILE "pv_amr_mpeg4.sdp"
 #endif
 
-#define DEFAULT_GATEWAY "127.0.0.1"
+#define DEFAULT_GATEWAY "10.112.43.1"
 
 class PVPlayerDataSourceURL;
 class PVPlayerDataSink;
@@ -66,6 +71,8 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
+class PVMFDownloadDataSourcePVX;
+
 
 /*!
  *  A test case to count time taken in each command completion when playing an local/PDL/rtsp url
@@ -124,6 +131,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -174,7 +182,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -254,8 +261,8 @@
         bool iProtocolRollOverWithUnknownURLType;
         bool iPlayListURL;
 
-        OsclTimebase_Tickcount tb;
-        OsclClock iClock;
+        PVMFTimebase_Tickcount tb;
+        PVMFMediaClock iClock;
         //For clock usage
         uint32 iCurrenttime;
         uint32 iPrevtime;
@@ -272,8 +279,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -341,6 +353,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -388,7 +401,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -480,8 +492,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -544,6 +561,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -591,7 +609,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -682,8 +699,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -747,6 +769,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -794,7 +817,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -885,8 +907,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -897,7 +924,8 @@
 };
 
 /*!
- *  Test cases to test Network disconnection call (right after/while processing) each state when playing an local/PDL/rtsp url
+ *  Test cases to test engine behavior when network is disconnected DURING/RIGHT AFTER various engine command's
+ *  execution when playing an PDL/streaming url
  *  - Data Source: Specified by user of test case
  *  - Data Sink(s): Video[FileOutputNode-test_player_genericnetworkdisconnect_video.dat]\n
  *                  Audio[FileOutputNode-test_player_genericnetworkdisconnect_audio.dat]
@@ -956,6 +984,7 @@
                 , iPlayListURL(false)
                 , iSourceContextData(NULL)
                 , iStreamDataSource(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -1099,8 +1128,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -1111,8 +1145,9 @@
 };
 
 /*!
- *  Test cases to test Network disconnection then reconnection after some time,
- *  (right after/while processing) each state when playing an local/PDL/rtsp url
+ *  Test cases to test engine behavior when network is disconnected and then reconnected after
+ *  NW_RECONNECT_AFTER_DISCONNECT milli secs, DURING/RIGHT AFTER various engine command's
+ *  execution, when playing an PDL/streaming url
  *  - Data Source: Specified by user of test case
  *  - Data Sink(s): Video[FileOutputNode-test_player_genericnetworkdisconnectreconnect_video.dat]\n
  *                  Audio[FileOutputNode-test_player_genericnetworkdisconnectreconnect_audio.dat]
@@ -1171,6 +1206,7 @@
                 , iPlayListURL(false)
                 , iSourceContextData(NULL)
                 , iStreamDataSource(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -1199,37 +1235,6 @@
         void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
         void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
 
-        enum PVTestState
-        {
-            STATE_CREATE,
-            STATE_QUERYINTERFACE,
-            STATE_ADDDATASOURCE,
-            STATE_CONFIGPARAMS,
-            STATE_INIT,
-            STATE_GETMETADATAKEYLIST,
-            STATE_GETMETADATAVALUELIST,
-            STATE_ADDDATASINK_VIDEO,
-            STATE_ADDDATASINK_AUDIO,
-            STATE_PREPARE,
-            STATE_WAIT_FOR_DATAREADY,
-            STATE_WAIT_FOR_BUFFCOMPLETE,
-            STATE_CANCELALL,
-            STATE_WAIT_FOR_CANCELALL,
-            STATE_START,
-            STATE_SETPLAYBACKRANGE,
-            STATE_PAUSE,
-            STATE_RESUME,
-            STATE_EOSNOTREACHED,
-            STATE_STOP,
-            STATE_REMOVEDATASINK_VIDEO,
-            STATE_REMOVEDATASINK_AUDIO,
-            STATE_RESET,
-            STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
-            STATE_CLEANUPANDCOMPLETE,
-            STATE_RECONNECT
-        };
-
         PVTestState iState;
         PVTestState iDisconnectState;
         bool iDisconnectWhileProc;
@@ -1353,8 +1358,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -1365,8 +1375,8 @@
 };
 
 /*!
- *  Test cases to test Network Disconnection during CancellAllCommands() call (right after/while processing)
- *  each state when playing an local/PDL/rtsp url
+ *  Test cases to test engine behavior when network is disconnected, followed by cancelAllCommands() immediately,
+ *  DURING/RIGHT AFTER various engine commands processing
  *  - Data Source: Specified by user of test case
  *  - Data Sink(s): Video[FileOutputNode-test_player_genericcancelall_video.dat]\n
  *                  Audio[FileOutputNode-test_player_genericcancelall_audio.dat]
@@ -1426,6 +1436,7 @@
                 , iPlayListURL(false)
                 , iSourceContextData(NULL)
                 , iStreamDataSource(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -1440,6 +1451,7 @@
             iDownloadOnly = iDownloadThenPlay = false;
             iEndState = (PVTestState)lastState;
             iCancelAllWhileProc = aCancelAllWhileProc;
+            iNetworkIsDisabled = false;
         }
 
         ~pvplayer_async_test_genericcancelallnetworkdisconnect() {}
@@ -1455,6 +1467,7 @@
         PVTestState iState;
         PVTestState iEndState;
         bool iCancelAllWhileProc;
+        bool iNetworkIsDisabled;
 
         PVPlayerInterface* iPlayer;
         PVPlayerDataSourceURL* iDataSource;
@@ -1501,25 +1514,29 @@
             fprintf(iTestMsgOutputFile, "***Disconnecting Network...\n");
             system("ipconfig /release");
 #endif
+            iNetworkIsDisabled = true;
 
         }
 
         void enableNetwork()
         {
-            char cmd_str[48] = "/sbin/route add default gw ";
-            oscl_strcat(cmd_str, DEFAULT_GATEWAY);
+            if (iNetworkIsDisabled)
+            {
+                char cmd_str[48] = "/sbin/route add default gw ";
+                oscl_strcat(cmd_str, DEFAULT_GATEWAY);
 
 #if	PVPLAYER_TEST_LINUX_DISABLE_NETWORK
-            fprintf(iTestMsgOutputFile, "***Reconnecting Network...\n");
-            system("/sbin/ifconfig eth0 up");
-            system(cmd_str);
+                fprintf(iTestMsgOutputFile, "***Reconnecting Network...\n");
+                system("/sbin/ifconfig eth0 up");
+                system(cmd_str);
 #endif
 
 #if	PVPLAYER_TEST_WIN32_DISABLE_NETWORK
-            fprintf(iTestMsgOutputFile, "***Reconnecting Network...\n");
-            system("ipconfig /renew");
+                fprintf(iTestMsgOutputFile, "***Reconnecting Network...\n");
+                system("ipconfig /renew");
 #endif
-
+                iNetworkIsDisabled = false;
+            }
         }
 
     private:
@@ -1569,8 +1586,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -1638,6 +1660,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -1687,7 +1710,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -1811,8 +1833,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -1867,6 +1894,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -1911,7 +1939,6 @@
         	STATE_REMOVEDATASINK_AUDIO,
         	STATE_RESET,
         	STATE_REMOVEDATASOURCE,
-        	STATE_WAIT_FOR_ERROR_HANDLING,
         	STATE_CLEANUPANDCOMPLETE
         };*/
 
@@ -1993,9 +2020,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
-
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -2052,11 +2083,11 @@
                 , iSessionDuration(0)
                 , bcloaking(aCloaking)
                 , oLiveSession(false)
-                , iProtocolRollOver(false)
                 , iProtocolRollOverWithUnknownURLType(false)
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -2103,7 +2134,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE,
             STATE_GETMETADATAKEYLIST1,
             STATE_GETMETADATAVALUELIST1
@@ -2128,11 +2158,6 @@
             iTargetNumPlay = aNum;
         }
 
-        void setProtocolRollOverMode()
-        {
-            iProtocolRollOver = true;
-        }
-
         void setProtocolRollOverModeWithUnknownURL()
         {
             iProtocolRollOverWithUnknownURLType = true;
@@ -2187,8 +2212,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
@@ -2243,11 +2273,11 @@
                 , iSessionDuration(0)
                 , bcloaking(aCloaking)
                 , oLiveSession(false)
-                , iProtocolRollOver(false)
                 , iProtocolRollOverWithUnknownURLType(false)
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -2294,7 +2324,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE,
             STATE_GETMETADATAKEYLIST1,
             STATE_GETMETADATAVALUELIST1
@@ -2319,16 +2348,6 @@
             iTargetNumPlay = aNum;
         }
 
-        void setProtocolRollOverMode()
-        {
-            iProtocolRollOver = true;
-        }
-
-        void setProtocolRollOverModeWithUnknownURL()
-        {
-            iProtocolRollOverWithUnknownURLType = true;
-        }
-
         void setPlayListMode()
         {
             iPlayListURL = true;
@@ -2378,8 +2397,13 @@
 
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
diff --git a/engines/player/test/src/test_pv_player_engine_testset5.cpp b/engines/player/test/src/test_pv_player_engine_testset5.cpp
index 1bf2cd5..e0eb3d1 100644
--- a/engines/player/test/src/test_pv_player_engine_testset5.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset5.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#include "oscl_base.h"
+
 #ifndef TEST_PV_PLAYER_ENGINE_TESTSET5_H_INCLUDED
 #include "test_pv_player_engine_testset5.h"
 #endif
@@ -60,6 +62,10 @@
 #include "pvmf_cpmplugin_passthru_oma1_types.h"
 #endif
 
+#ifndef PVMF_DURATIONINFOMESSAGE_EXTENSION_H_INCLUDED
+#include "pvmf_durationinfomessage_extension.h"
+#endif
+
 #ifndef PVMF_ERRORINFOMESSAGE_EXTENSION_H_INCLUDED
 #include "pvmf_errorinfomessage_extension.h"
 #endif
@@ -104,29 +110,30 @@
 //Default 3gpp download URL, in both single and wide-char versions.
 #if(RUN_MP4FILE_TESTCASES)
 #undef DEFAULT_3GPPDL_URL
-#define DEFAULT_3GPPDL_URL "http://test.mp4"
+#define DEFAULT_3GPPDL_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/MP4/prog_dl/mpeg4+aac_metadata_qt.mp4"
+//#define DEFAULT_3GPPDL_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/MP4/prog_dl/ec36-av-clon-100-10-h176x144p-uc-g7a24;16s-rvdqmt.mp4"
 #elif(RUN_ASFFILE_TESTCASES)
 #undef DEFAULT_3GPPDL_URL
-#define DEFAULT_3GPPDL_URL "http://test.wmv"
+#define DEFAULT_3GPPDL_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/UserUploads/av5.wmv"
 #endif
 
 #if(RUN_ASFFILE_TESTCASES)
 //For slow download use this one
-#define DEFAULT_3GPPDL_URL_SLOW "http://test.wmv"
+#define DEFAULT_3GPPDL_URL_SLOW "http://reallinux.pv.com:1415/av5.wmv?bitrate=100000"
 #elif (RUN_MP4FILE_TESTCASES)
-#define DEFAULT_3GPPDL_URL_SLOW "http://test.3gp"
+#define DEFAULT_3GPPDL_URL_SLOW "http://reallinux.pv.com:1415/at_vh264qc128_1_amr_12.2_of.3gp?bitrate=100000"
 #endif
 
 //Default Bad URL for the error-case test
-#define DEFAULT_BADURL "http://test.wmv"
+#define DEFAULT_BADURL "http://reallinux.pv.com:1415/xxxxx_320x240_15fps_200kbps_wmv7.wmv"
 
-#define DEFAULT_TRUNCATED_TEST_URL "http://test.wmv"
+#define DEFAULT_TRUNCATED_TEST_URL "http://reallinux.pv.com:1415/av5.wmv?no_content_length=true"
 
-#define DEFAULT_CANCEL_DURING_INIT_TEST_URL "http://test.wmv"
+#define DEFAULT_CANCEL_DURING_INIT_TEST_URL "http://reallinux.pv.com:1415/av5.wmv?bitrate=1000"
 
-#define DEFAULT_CANCEL_DURING_INIT_DELAY_TEST_URL "http://test.mp4"
+#define DEFAULT_CANCEL_DURING_INIT_DELAY_TEST_URL "http://reallinux.pv.com:1415/blz4-110302-aac-h263.mp4?bitrate=1000000"
 
-#define DEFAULT_3GPP_PPB_URL "http://test.3gp"
+#define DEFAULT_3GPP_PPB_URL "http://pvwmsoha.pv.com:7070/MediaDownloadContent/UserUploads/youtube_singer.3gp"
 
 extern FILE* file;
 
@@ -190,7 +197,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -268,9 +275,10 @@
 
             //set user-agent, make sure to set as "PVPLAYER VersionNumber" to satisfy Fast Track PV server for Fast Track test
 
-            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=download");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
 
+//			OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18akljfaljfa"));
             OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18.07.00.02"));
             iKVPSetAsync.value.pWChar_value = userAgent.get_str();
             iErrorKVP = NULL;
@@ -344,7 +352,12 @@
             // set extension header
             // set arbitrary extension headers all together
             PvmiKvp kvpheader[3];
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download"));
             OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download;purge-on-redirect"));
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;purge-on-redirect"));
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*"));
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=streaming"));
+
 
             kvpheader[0].key = paramkey.get_str();
             OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader1(_STRLIT_CHAR("key=X1;value=Y1;method=GET,HEAD"));
@@ -562,6 +575,7 @@
                 PVPPlaybackPosition start, end;
                 start.iIndeterminate = false;
                 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                start.iMode = PVPPBPOS_MODE_NOW;
                 start.iPosValue.millisec_value = iSessionDuration / 4;
                 end.iIndeterminate = true;
                 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -615,16 +629,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(file, "Events:\n");
@@ -757,8 +761,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -815,8 +819,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -831,8 +835,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -846,8 +850,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -861,8 +865,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -876,8 +880,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -897,8 +901,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -929,8 +933,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -994,8 +998,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1011,8 +1015,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1030,8 +1034,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1056,8 +1060,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1074,8 +1078,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning Failed...\n");
                 // Repos failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1094,8 +1098,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1108,8 +1112,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1123,8 +1127,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1138,8 +1142,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1153,8 +1157,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1361,41 +1365,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_downloadbase::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(file, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     // Check for EOS event
@@ -1665,6 +1648,155 @@
     }
 }
 
+#if RUN_FASTTRACK_TESTCASES
+//
+// pvplayer_async_test_ftdlnormal section
+//
+pvplayer_async_test_ftdlnormal::~pvplayer_async_test_ftdlnormal()
+{
+}
+
+void pvplayer_async_test_ftdlnormal::CreateDataSource()
+{
+    //fasttrack download using PVX.
+
+    //read the pvx file into a memory fragment.
+    OsclMemoryFragment pvxmemfrag;
+    {
+        Oscl_FileServer fs;
+        fs.Connect();
+        Oscl_File file;
+        OSCL_StackString<64> filename;
+
+        if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+        {
+            filename = SOURCENAME_PREPEND_STRING;
+            filename += DEFAULT_FASTTRACK_DL_FILE;
+        }
+        else
+        {
+            filename = iFileName;
+        }
+
+        if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+        {
+            PVPATB_TEST_IS_TRUE(false);
+            iObserver->TestCompleted(*iTestCase);
+            return;
+        }
+
+        int32 size = file.Read(iPVXFileBuf, 1, 4096);
+        pvxmemfrag.len = size;
+        pvxmemfrag.ptr = iPVXFileBuf;
+        file.Close();
+        fs.Close();
+    }
+
+    //Parse, extracting iDownloadPvxInfo and url8.
+    OSCL_HeapString<OsclMemAllocator> url8;
+    {
+        CPVXParser* parser = NULL;
+        parser = new CPVXParser;
+        if (parser == NULL)
+        {
+            PVPATB_TEST_IS_TRUE(false);
+            iObserver->TestCompleted(*iTestCase);
+            return;
+        }
+        CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+        delete parser;
+        if (status != CPVXParser::CPVXParser_Success)
+        {
+            PVPATB_TEST_IS_TRUE(false);
+            iObserver->TestCompleted(*iTestCase);
+            return;
+        }
+        //set the playback mode in the test case base class to match
+        //the PVX setting.
+        switch (iDownloadPvxInfo.iPlaybackControl)
+        {
+            case CPVXInfo::ENoPlayback:
+                iDownloadOnly = true;
+                break;
+            case CPVXInfo::EAfterDownload:
+                iDownloadThenPlay = true;
+                break;
+            case CPVXInfo::EAsap:
+                break;
+            default:
+                break;
+        }
+    }
+
+    //convert the url8 to unicode iDownloadURL
+    {
+        oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+        if (wtemp == NULL)
+        {
+            // Memory allocation failure
+            PVPATB_TEST_IS_TRUE(false);
+            iObserver->TestCompleted(*iTestCase);
+            return;
+        }
+        int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+        iDownloadURL.set(wtemp, wtemplen);
+        delete [] wtemp;
+    }
+
+    //create the opaque data
+    iDownloadProxy = _STRLIT_CHAR("");
+    int32 iDownloadProxyPort = 0;
+
+    iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
+    iDownloadConfigFilename += _STRLIT_WCHAR("mydlconfig");
+
+    iDownloadMaxfilesize = 0x7FFFFFFF;
+
+    iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
+    iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.loc");
+
+    iContentTooLarge = false;
+
+    //bool aIsNewSession = false;
+    bool aIsNewSession = true;
+
+    iDownloadContextData = new PVMFSourceContextData();
+    iDownloadContextData->EnableCommonSourceContext();
+    iDownloadContextData->EnableDownloadPVXSourceContext();
+    iDownloadContextData->DownloadPVXData()->bIsNewSession = aIsNewSession;
+    iDownloadContextData->DownloadPVXData()->iConfigFileName = iDownloadConfigFilename;
+    iDownloadContextData->DownloadPVXData()->iDownloadFileName = iDownloadFilename;
+    iDownloadContextData->DownloadPVXData()->iMaxFileSize = iDownloadMaxfilesize;
+    iDownloadContextData->DownloadPVXData()->iProxyName = iDownloadProxy;
+    iDownloadContextData->DownloadPVXData()->iProxyPort = iDownloadProxyPort;
+    iDownloadContextData->DownloadPVXData()->iPvxInfo = &iDownloadPvxInfo;
+
+    iDataSource = new PVPlayerDataSourceURL;
+    iDataSource->SetDataSourceURL(iDownloadURL);
+    iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_PVX_FILE);
+    iDataSource->SetDataSourceContextData(iDownloadContextData);
+
+}
+void pvplayer_async_test_ftdlnormal::CreateDataSinkVideo()
+{
+    OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
+    sinkfile += _STRLIT_WCHAR("test_player_ftdlnormal_video.dat");
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
+    iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
+    iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
+    ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
+}
+void pvplayer_async_test_ftdlnormal::CreateDataSinkAudio()
+{
+    OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
+    sinkfile += _STRLIT_WCHAR("test_player_ftdlnormal_audio.dat");
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
+    iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
+    iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
+    ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
+}
+#endif
+
 //
 // pvplayer_async_test_3gppdlnormal section
 //
@@ -1703,12 +1835,12 @@
 
     if (iProtocolRollOver == true)
     {
-        iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-        iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+        iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+        iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
     }
     else
     {
-        iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+        iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
     }
 
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -1748,6 +1880,8 @@
     iDataSource->SetDataSourceContextData(iDownloadContextData);
 }
 
+#if !(JANUS_IS_LOADABLE_MODULE)
+#endif
 
 void pvplayer_async_test_3gppdlnormal::CleanupData()
 {
@@ -1757,35 +1891,19 @@
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_video.dat");
-    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
     iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
     iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-    if (iCompressedVideo)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-    }
 }
 void pvplayer_async_test_3gppdlnormal::CreateDataSinkAudio()
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_audio.dat");
-    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
     iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
     iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-    if (iCompressedAudio)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-    }
 }
 
 //
@@ -1819,12 +1937,12 @@
 
     if (iProtocolRollOver == true)
     {
-        iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-        iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+        iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+        iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
     }
     else
     {
-        iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+        iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
     }
 
     iDownloadFilename = NULL;
@@ -1866,35 +1984,19 @@
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_video.dat");
-    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
     iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
     iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-    if (iCompressedVideo)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-    }
 }
 void pvplayer_async_test_ppbnormal::CreateDataSinkAudio()
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_audio.dat");
-    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
     iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
     iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-    if (iCompressedAudio)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-    }
 }
 
 // pvplayer_async_test_3gppdlnormal_dlthenplay section
@@ -1922,7 +2024,7 @@
     }
     iDataSource = new PVPlayerDataSourceURL;
     iDataSource->SetDataSourceURL(iDownloadURL);
-    iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+    iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
 
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
     iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload_dlthenplay.loc");
@@ -1964,35 +2066,19 @@
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_dlthenplay_video.dat");
-    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
     iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
     iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-    if (iCompressedVideo)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-    }
 }
 void pvplayer_async_test_3gppdlnormal_dlthenplay::CreateDataSinkAudio()
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_dlthenplay_audio.dat");
-    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
     iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
     iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-    if (iCompressedAudio)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-    }
 }
 //
 // pvplayer_async_test_3gppdlnormal_dlonly section
@@ -2021,7 +2107,7 @@
     }
     iDataSource = new PVPlayerDataSourceURL;
     iDataSource->SetDataSourceURL(iDownloadURL);
-    iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+    iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
 
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
     iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload_dlonly.loc");
@@ -2146,7 +2232,7 @@
 
             iDataSource = new PVPlayerDataSourceURL;
             iDataSource->SetDataSourceURL(iDownloadURL);
-            iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
             iDataSource->SetDataSourceContextData(iDownloadHttpContextData);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2159,6 +2245,8 @@
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
 
             iState = STATE_CANCELALL;
+            //if this is commmented out. The BufferingStart(change below) could do RunIfInactiv()
+            //RunIfNotReady(10*1000*1000);
         }
         break;
 
@@ -2200,16 +2288,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -2270,8 +2348,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2290,8 +2368,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2325,8 +2403,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2340,8 +2418,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2404,37 +2482,23 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_3gppdlcancelduringinit::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(file, "PVMFInfoErrorHandlingStart...\n");
     }
-    else if (iState == STATE_CANCELALL && aEvent.GetEventType() == PVMFInfoBufferingStart)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
+    if (iState == STATE_CANCELALL && aEvent.GetEventType() == PVMFInfoBufferingStart)
     {
         RunIfNotReady(10*1000);
     }
@@ -2614,7 +2678,7 @@
 
             iDataSource = new PVPlayerDataSourceURL;
             iDataSource->SetDataSourceURL(iDownloadURL);
-            iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+            iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
             iDataSource->SetDataSourceContextData(iDownloadHttpContextData);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2674,16 +2738,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -2744,8 +2798,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2764,8 +2818,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2798,8 +2852,8 @@
                 fprintf(file, "\n Previous command was not cancelled or cancel failed ...\n");
 
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2813,8 +2867,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2877,35 +2931,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_3gppdlcancelduringinitdelay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(file, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     switch (aEvent.GetEventType())
@@ -3037,7 +3076,7 @@
     }
     iDataSource = new PVPlayerDataSourceURL;
     iDataSource->SetDataSourceURL(iDownloadURL);
-    iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+    iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
 
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
     iDownloadFilename += _STRLIT_WCHAR("test_3gppcontenttoolarge.loc");
@@ -3114,7 +3153,7 @@
     }
     iDataSource = new PVPlayerDataSourceURL;
     iDataSource->SetDataSourceURL(iDownloadURL);
-    iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+    iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
 
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
     iDownloadFilename += _STRLIT_WCHAR("test_3gppdownload_truncated.loc");
@@ -3151,35 +3190,19 @@
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdl_truncated_video.dat");
-    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
     iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
     iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-    if (iCompressedVideo)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-    }
 }
 void pvplayer_async_test_3gppdlContentTruncated::CreateDataSinkAudio()
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdl_truncated_audio.dat");
-    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
     iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
     iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-    if (iCompressedAudio)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-    }
 }
 
 
@@ -3235,7 +3258,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -3313,9 +3336,10 @@
 
             //set user-agent, make sure to set as "PVPLAYER VersionNumber" to satisfy Fast Track PV server for Fast Track test
 
-            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=download");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
 
+//                      OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18akljfaljfa"));
             OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("PVPLAYER 18.07.00.02"));
             iKVPSetAsync.value.pWChar_value = userAgent.get_str();
             iErrorKVP = NULL;
@@ -3389,7 +3413,12 @@
             // set extension header
             // set arbitrary extension headers all together
             PvmiKvp kvpheader[3];
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download"));
             OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=download;purge-on-redirect"));
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;purge-on-redirect"));
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*"));
+            //OSCL_StackString<128> paramkey(_STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*;mode=streaming"));
+
 
             kvpheader[0].key = paramkey.get_str();
             OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader1(_STRLIT_CHAR("key=X1;value=Y1;method=GET,HEAD"));
@@ -3497,6 +3526,7 @@
         break;
 
         case STATE_PREPARE:
+        case STATE_PREPARE_AFTERSTOP:
         {
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3539,6 +3569,7 @@
         break;
 
         case STATE_START:
+        case STATE_START_AFTERSTOP:
         {
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Start((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3553,6 +3584,7 @@
                 PVPPlaybackPosition start, end;
                 start.iIndeterminate = false;
                 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                start.iMode = PVPPBPOS_MODE_NOW;
                 start.iPosValue.millisec_value = iSessionDuration / 4;
                 end.iIndeterminate = true;
                 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -3573,6 +3605,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             if (iForwardStep)
             {
                 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", iForwardSeekTime);
@@ -3605,6 +3638,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 120000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -3619,6 +3653,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             if (iForwardStep)
             {
                 fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms\n", iForwardSeekTime);
@@ -3643,8 +3678,35 @@
         }
         break;
 
+        case STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE:
+        {
+            PVPPlaybackPosition start, end, current;
+            start.iIndeterminate = false;
+            start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
+            end.iIndeterminate = true;
+            if (iSeekToBOC)
+            {
+                // download has completed, rewind back to 0 sec
+                fprintf(iTestMsgOutputFile, "\n***Repositioning to 0 ms\n");
+                start.iPosValue.millisec_value = 0;
+            }
+            else if (iSeekInCache)
+            {
+                current.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                iPlayer->GetCurrentPositionSync(current);
+                // download has completed, seek to a position in cache (the rest of the clip should be there)
+                fprintf(iTestMsgOutputFile, "\n***Repositioning to %d ms", current.iPosValue.millisec_value + 5000);
+                start.iPosValue.millisec_value = current.iPosValue.millisec_value + 5000;
+            }
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
         case STATE_PAUSE:
         case STATE_PAUSE_TWICE:
+        case STATE_PAUSE_AFTERDOWNLOADCOMPLETE:
         {
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Pause((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3653,6 +3715,7 @@
 
         case STATE_RESUME:
         case STATE_RESUME_TWICE:
+        case STATE_RESUME_AFTERDOWNLOADCOMPLETE:
         {
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Resume((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3660,7 +3723,15 @@
         break;
 
         case STATE_STOP:
+        case STATE_STOP_TWICE:
         {
+            if (iState == STATE_STOP)
+            {
+                if (iSessionDuration == 0)
+                    fprintf(file, "   DURATION Not Received\n");
+                else
+                    fprintf(file, "   GOT Duration %d \n\n", iSessionDuration);
+            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -3694,16 +3765,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(file, "Events:\n");
@@ -3822,8 +3883,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3854,8 +3915,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -3870,8 +3931,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3892,8 +3953,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3906,8 +3967,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
 
             break;
@@ -3923,8 +3984,23 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_PREPARE_AFTERSTOP:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_START_AFTERSTOP;
+                RunIfNotReady();
+            }
+            else
+            {
+                // Prepare failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3944,8 +4020,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3975,8 +4051,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3991,18 +4067,20 @@
                         //just play for 20 seconds then stop
                         RunIfNotReady(20*1000*1000);
                     }
-                    else
+                    else if (iSeekAfterDownloadComplete && 0 == iNumBufferingComplete)
+                    {
+                        iState = STATE_PAUSE_AFTERDOWNLOADCOMPLETE;
+                    }
+                    else if (!iPlayUntilEOS)
                     {
                         iState = STATE_STOP;
-                        if (!iPlayUntilEOS)
-                        {
-                            //just play for 20 seconds then stop
-                            RunIfNotReady(20*1000*1000);
-                        }
-                        else
-                        {
-                            // wait for EOS
-                        }
+                        //just play for 20 seconds then stop
+                        RunIfNotReady(20*1000*1000);
+                    }
+                    else
+                    {
+                        // wait for EOS
+                        iState = STATE_STOP;
                     }
                 }
                 else
@@ -4025,8 +4103,29 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_START_AFTERSTOP:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                if (iNumDataReady)
+                {
+                    if (iEOSStopPlay)
+                    {
+                        iState = STATE_STOP_TWICE;
+                        RunIfNotReady(3*1000*1000);	// Play for 3 seconds
+                    }
+                }
+            }
+            else
+            {
+                // Start failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4043,8 +4142,8 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning Failed...\n");
                 // Repos failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4077,12 +4176,27 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_PAUSE_AFTERDOWNLOADCOMPLETE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE;
+                RunIfNotReady();
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_SETPLAYBACKRANGE_AFTERSTART:
+        case STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iState = STATE_RESUME;
@@ -4091,8 +4205,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
 
             break;
@@ -4131,8 +4245,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4164,8 +4278,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4178,8 +4292,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
 
             break;
@@ -4218,22 +4332,39 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_STOP:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                if (iEOSStopPlay)
+                    iState = STATE_PREPARE_AFTERSTOP;
+                else
+                    iState = STATE_REMOVEDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_STOP_TWICE:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
                 iState = STATE_REMOVEDATASINK_VIDEO;
                 RunIfNotReady();
             }
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4247,8 +4378,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4262,8 +4393,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4277,8 +4408,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4475,42 +4606,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_ppb_base::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(file, "PVMFInfoErrorHandlingStart...\n");
     }
-
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(file, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
     // Check for EOS event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -4565,13 +4674,20 @@
             {
                 fprintf(file, ".%d.", *percent);
             }
+
+            // get buffer fullness
+            PVExclusivePtr eventData;
+            aEvent.GetEventData(eventData);
+            uint32 aBufferFullness = (uint32)(eventData);
+            fprintf(file, ".(%d%%).", aBufferFullness);
+
         }
         break;
         case PVMFInfoBufferingStart:
             fprintf(file, "   PVMFInfoBufferingStart\n");
             iNumBufferingStart++;
             //we should only get one of these.
-            if (iNumBufferingStart == 2)
+            if (iNumBufferingStart == 2 && !iEOSStopPlay)
                 PVPATB_TEST_IS_TRUE(false);
             break;
 
@@ -4580,14 +4696,16 @@
             PVExclusivePtr eventData;
             aEvent.GetEventData(eventData);
             uint32 contentSize = (uint32)(eventData);
-            fprintf(file, "   PVMFInfoBufferingComplete (contentSize=%d)\n", contentSize);
             iNumBufferingComplete++;
+            fprintf(file, "   PVMFInfoBufferingComplete (contentSize=%d), iNumBufferingComplete=%d\n", contentSize, iNumBufferingComplete);
             //we should only get one of these.
-            if (iNumBufferingComplete == 2)
+            if (iNumBufferingComplete == 2 && !iEOSStopPlay && iLoopReq == 0)
                 PVPATB_TEST_IS_TRUE(false);
+
             if (iNumBufferingComplete == 1)
             {
-                if (iState == STATE_WAIT_FOR_BUFFCOMPLETE)
+                // if seek after download complete or waiting for download complete
+                if ((iState == STATE_PAUSE_AFTERDOWNLOADCOMPLETE) || (iState == STATE_WAIT_FOR_BUFFCOMPLETE))
                 {
                     Cancel();
                     RunIfNotReady();
@@ -4727,6 +4845,24 @@
             }
         }
         break;
+        case PVMFInfoDurationAvailable:
+        {
+            PVMFDurationInfoMessageInterface* eventMsg = NULL;
+            PVInterface* infoExtInterface = aEvent.GetEventExtensionInterface();
+
+            if (infoExtInterface &&
+                    infoExtInterface->queryInterface(PVMFDurationInfoMessageInterfaceUUID, (PVInterface*&)eventMsg))
+            {
+                PVUuid eventuuid;
+                int32 infoCode;
+                eventMsg->GetCodeUUID(infoCode, eventuuid);
+                if (eventuuid == PVMFDurationInfoMessageInterfaceUUID)
+                {
+                    iSessionDuration = eventMsg->GetDuration();
+                }
+            }
+        }
+        break;
         default:
             break;
     }
@@ -4760,7 +4896,7 @@
     }
     iDataSource = new PVPlayerDataSourceURL;
     iDataSource->SetDataSourceURL(iDownloadURL);
-    iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+    iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
 
     iDownloadFilename = NULL;
 
@@ -4832,18 +4968,10 @@
         sinkfile += _STRLIT_WCHAR("nml_video.dat");
     }
 
-    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
     iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
     iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-    if (iCompressedVideo)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-    }
 }
 
 void pvplayer_async_test_ppb_normal::CreateDataSinkAudio()
@@ -4887,18 +5015,10 @@
         sinkfile += _STRLIT_WCHAR("nml_audio.dat");
     }
 
-    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
     iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
     iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-    if (iCompressedAudio)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-    }
 }
 
 
@@ -4932,12 +5052,12 @@
 
     if (iProtocolRollOver == true)
     {
-        iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-        iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+        iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+        iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
     }
     else
     {
-        iDataSource->SetDataSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+        iDataSource->SetDataSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
     }
 
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -4980,35 +5100,19 @@
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_video.dat");
-    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile);
+    iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfile, MEDIATYPE_VIDEO, iCompressedVideo);
     iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
     iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-    if (iCompressedVideo)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-    }
 }
 void pvplayer_async_test_PDLPauseResumeAfterUnderFlow::CreateDataSinkAudio()
 {
     OSCL_wHeapString<OsclMemAllocator> sinkfile = OUTPUTNAME_PREPEND_WSTRING;
     sinkfile += _STRLIT_WCHAR("test_player_3gppdlnormal_audio.dat");
-    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile);
+    iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfile, MEDIATYPE_AUDIO, iCompressedAudio);
     iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
     iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
     ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-    if (iCompressedAudio)
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-    }
-    else
-    {
-        ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-    }
 }
 void pvplayer_async_test_PDLPauseResumeAfterUnderFlow::CleanupData()
 {
diff --git a/engines/player/test/src/test_pv_player_engine_testset5.h b/engines/player/test/src/test_pv_player_engine_testset5.h
index 262315b..2371707 100644
--- a/engines/player/test/src/test_pv_player_engine_testset5.h
+++ b/engines/player/test/src/test_pv_player_engine_testset5.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,14 +33,22 @@
 #include "test_pv_player_engine_config.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
+#if !(JANUS_IS_LOADABLE_MODULE)
 #ifndef PVMF_CPMPLUGIN_FACTORY_REGISTRY_H_INCLUDED
 #include "pvmf_cpmplugin_factory_registry.h"
 #endif
+#endif
 
 class PVPlayerDataSourceURL;
 class PVPlayerDataSinkFilename;
 class PVLogger;
+class PVMFDownloadDataSourcePVX;
 class PVMFDownloadDataSourceHTTP;
 class PVMFSourceContextData;
 class PvmiCapabilityAndConfig;
@@ -113,7 +121,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE,
             STATE_PREPARE2,
             STATE_START2,
@@ -206,10 +213,56 @@
         OSCL_StackString<256> iKeyStringSetAsync;
 };
 
+#if RUN_FASTTRACK_TESTCASES
+/*!
+ *  A test case to test the normal FastTrack download and playback from a PVX file
+ *  - Data Source: test.pvx
+ *  - Data Sink(s): Video[FileOutputNode-test_player_ftdlnormal_video.dat]\n
+ *                  Audio[FileOutputNode-test_player_ftdlnormal_audio.dat]
+ *  - Sequence:
+ *             -# CreatePlayer()
+ *             -# AddDataSource()
+ *             -# Init()
+ *             -# AddDataSink() (video)
+ *             -# AddDataSink() (audio)
+ *             -# Prepare()
+ *             -# Wait for Data Ready event
+ *             -# Start()
+ *             -# Play until either EOS is reached or 10 seconds after download
+ *					finishes.
+ *             -# Stop()
+ *             -# RemoveDataSink() (video)
+ *             -# RemoveDataSink() (audio)
+ *             -# Reset()
+ *             -# RemoveDataSource()
+ *             -# DeletePlayer()
+ *
+ */
+class pvplayer_async_test_ftdlnormal : public pvplayer_async_test_downloadbase
+{
+    public:
+        pvplayer_async_test_ftdlnormal(PVPlayerAsyncTestParam aTestParam)
+                : pvplayer_async_test_downloadbase(aTestParam)
+        {
+            iLogger = PVLogger::GetLoggerObject("pvplayer_async_test_ftdlnormal");
+            iTestCaseName = _STRLIT_CHAR("FastTrack Download Normal");
+        }
+
+        ~pvplayer_async_test_ftdlnormal();
+
+        void CreateDataSource();
+        void CreateDataSinkVideo();
+        void CreateDataSinkAudio();
+
+        uint8 iPVXFileBuf[4096];
+        int32 iDownloadMaxfilesize;
+        CPVXInfo iDownloadPvxInfo;
+};
+#endif
 
 /*!
  *  A test case to test the normal 3GPP download and playback from an HTTP URL.
- *  - Data Source: http://172.16.6.54/JaniePorche_176.3gp
+ *  - Data Source: http://0.0.0.0/test.3gp
  *  - Data Sink(s): Video[FileOutputNode-test_player_3gppdlnormal_video.dat]\n
  *                  Audio[FileOutputNode-test_player_3gppdlnormal_audio.dat]
  *  - Sequence:
@@ -239,7 +292,9 @@
         {
             iLogger = PVLogger::GetLoggerObject("pvplayer_async_test_3gppdlnormal");
             iTestCaseName = _STRLIT_CHAR("3GPP Download Play ASAP");
+#if !(JANUS_IS_LOADABLE_MODULE)
             iPluginFactory = NULL;
+#endif
             iUseCpmForPlayback = false;
             iDrmDeviceInfoFactory = NULL;
             iDrmSystemClockFactory = NULL;
@@ -252,10 +307,14 @@
         void CreateDataSinkAudio();
 
         //for janus DRM
+#if !(JANUS_IS_LOADABLE_MODULE)
         PVMFCPMPluginFactoryRegistryClient iPluginRegistryClient;
         PVMFJanusPluginFactory* iPluginFactory;
         OSCL_HeapString<OsclMemAllocator> iPluginMimeType;
+#endif
         bool iUseCpmForPlayback;
+#if !(JANUS_IS_LOADABLE_MODULE)
+#endif
         WmDrmDeviceInfoFactory* iDrmDeviceInfoFactory;
         PVWmdrmDeviceSystemClockFactory* iDrmSystemClockFactory;
         void CleanupData();
@@ -263,7 +322,7 @@
 
 /*!
  *  A test case to test the normal PPB from an HTTP URL.
- *  - Data Source: http://172.16.6.54/JaniePorche_176.3gp
+ *  - Data Source: http://0.0.0.0/test.3gp
  *  - Data Sink(s): Video[FileOutputNode-test_player_3gppdlnormal_video.dat]\n
  *                  Audio[FileOutputNode-test_player_3gppdlnormal_audio.dat]
  *  - Sequence:
@@ -423,7 +482,6 @@
             STATE_WAIT_FOR_CANCELALL,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -489,7 +547,6 @@
             STATE_WAIT_FOR_CANCELALL,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -512,7 +569,7 @@
  *  A test case to test the return of PVMFErrContentTooLarge from Init()
  *         when the iMaxFileSize is set to a lower number than the size of
  *         the downloading file.
- *  - Data Source: "http://wms.pv.com:7070/MediaDownloadContent/UserUploads/av5.wmv"
+ *  - Data Source: "http://pvwmsoha.pv.com:7070/MediaDownloadContent/UserUploads/av5.wmv"
  *  - Data Sink(s): N/A
  *  - Sequence:
  *             -# CreatePlayer()
@@ -619,6 +676,10 @@
                 , iBackwardStep(false)
                 , iBackwardSeekStep(0)
                 , iBackwardSeekTime(0)
+                , iSeekAfterDownloadComplete(false)
+                , iSeekToBOC(false)
+                , iSeekInCache(false)
+                , iEOSStopPlay(false)
                 , iSessionDuration(0)
         {
             iNumBufferingStart = iNumBufferingComplete = iNumUnderflow = iNumDataReady = iNumEOS = 0;
@@ -644,11 +705,13 @@
             STATE_ADDDATASINK_AUDIO,
             STATE_SETPLAYBACKRANGE_BEFORESTART,
             STATE_PREPARE,
+            STATE_PREPARE_AFTERSTOP,
             STATE_GETMETADATAKEYLIST,
             STATE_GETMETADATAVALUELIST,
             STATE_WAIT_FOR_DATAREADY,
             STATE_WAIT_FOR_BUFFCOMPLETE,
             STATE_START,
+            STATE_START_AFTERSTOP,
             STATE_SETPLAYBACKRANGE,
             STATE_PAUSE,
             STATE_SETPLAYBACKRANGE_AFTERSTART,
@@ -656,12 +719,15 @@
             STATE_PAUSE_TWICE,
             STATE_SETPLAYBACKRANGE_AFTERSTART_TWICE,
             STATE_RESUME_TWICE,
+            STATE_PAUSE_AFTERDOWNLOADCOMPLETE,
+            STATE_SETPLAYBACKRANGE_AFTERDOWNLOADCOMPLETE,
+            STATE_RESUME_AFTERDOWNLOADCOMPLETE,
             STATE_STOP,
+            STATE_STOP_TWICE,
             STATE_REMOVEDATASINK_VIDEO,
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -772,6 +838,30 @@
         int32 iBackwardSeekStep;
         int32 iBackwardSeekTime;
 
+        void enableSeekAfterDownloadComplete()
+        {
+            iSeekAfterDownloadComplete = true;
+        }
+        bool iSeekAfterDownloadComplete;
+
+        void enableSeekToBOC()
+        {
+            iSeekToBOC = true;
+        }
+        bool iSeekToBOC;
+
+        void enableSeekInCache()
+        {
+            iSeekInCache = true;
+        }
+        bool iSeekInCache;
+
+        void enableEOSStopPlay()
+        {
+            iEOSStopPlay = true;
+        }
+        bool iEOSStopPlay;
+
         //for janus drm.
         void PrintJanusError(const PVCmdResponse& aResponse);
 
@@ -808,7 +898,7 @@
 
 /*!
  *  A test case to test the normal PDL Pause Resume After UnderFlow and playback from an HTTP URL.
- *  - Data Source: http://172.16.6.54/JaniePorche_176.3gp
+ *  - Data Source: http://0.0.0.0/test.3gp
  *  - Data Sink(s): Video[FileOutputNode-test_player_3gppdlnormal_video.dat]\n
  *                  Audio[FileOutputNode-test_player_3gppdlnormal_audio.dat]
  *  - Sequence:
diff --git a/engines/player/test/src/test_pv_player_engine_testset6.cpp b/engines/player/test/src/test_pv_player_engine_testset6.cpp
index 4107522..24f9828 100644
--- a/engines/player/test/src/test_pv_player_engine_testset6.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset6.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -76,6 +76,18 @@
 #include "pvmf_protocol_engine_node_events.h"
 #endif
 
+#ifdef USE_CML2_CONFIG
+#include "pv_config.h"
+#endif
+
+
+
+
+#if PVR_SUPPORT
+#ifndef PVMF_PVR_CONTROL_INCLUDED
+#include "pvmf_pvr_control.h"
+#endif
+#endif
 
 #define USE_NEW_PVMF_SOURCE_CONTEXT_DATA
 #define DVBH_TEST_DURATION 45 // DVBH tests are run for 45 seconds
@@ -89,7 +101,6 @@
     RunIfNotReady();
 }
 
-
 void pvplayer_async_test_streamingopenplaystop::Run()
 {
     int error = 0;
@@ -135,14 +146,22 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
+#if PVR_SUPPORT
+                else if (iPlayListURL)
+                {
+                    filename = DEFAULT_PV_PLAYLIST_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                }
+#endif
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -155,11 +174,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 if (iProtocolRollOverWithUnknownURLType == false)
                 {
 #ifdef USE_NEW_PVMF_SOURCE_CONTEXT_DATA
@@ -199,14 +218,30 @@
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_SOURCE_CONTEXT_DATA
+                if (iUseFileHandle)
+                {
+                }
+
                 iSourceContextData = new PVMFSourceContextData();
                 iSourceContextData->EnableCommonSourceContext();
                 iSourceContextData->EnableStreamingSourceContext();
-
+                if (iUseFileHandle)
+                {
+                    iSourceContextData->CommonData()->iFileHandle = ifilehandle;
+                }
+#if PVR_SUPPORT
+                if (iPlayListURL)
+                {
+                    iSourceContextData->EnablePVRSourceContext();
+                    PVMFSourceContextDataPVR* pvrData = iSourceContextData->PVRData();
+                    m_PVRControl = OSCL_NEW(PVMFPVRControl, ());
+                    pvrData->SetPVRControl(m_PVRControl);
+                }
+#endif
                 PVInterface* sourceContext = NULL;
                 PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
                 if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
@@ -215,7 +250,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -225,10 +260,10 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
 #ifdef USE_NEW_PVMF_SOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -254,17 +289,17 @@
                     }
 #endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
 #if RUN_RTSP_CLOAKING_TESTCASES
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
 #endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_SOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -292,12 +327,9 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
-            // Remove in final for dedicated test
-            // fileType = PVMF_DATA_SOURCE_RTP_PACKET_SOURCE;
-
             iDataSource->SetDataSourceURL(wFileName);
             iDataSource->SetDataSourceFormatType(fileType);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
@@ -310,7 +342,7 @@
         {
             fprintf(iTestMsgOutputFile, "***Configuring Params...\n");
 
-            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=streaming");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("NSPlayer/9.0 PVPlayerCoreEngineTestUserAgent"));
             iKVPSetAsync.value.pWChar_value = userAgent.get_str();
@@ -329,6 +361,20 @@
                 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
             }
 
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/jitterbuffer-inactivity-duration;valtype=uint32");
+            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+            iKVPSetAsync.value.uint32_value = 70000;
+            iErrorKVP = NULL;
+            OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/rtsp-timeout;valtype=uint32");
+            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+            iKVPSetAsync.value.uint32_value = 20;
+            iErrorKVP = NULL;
+            OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/protocol-extension-header;valtype=char*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_HeapString<OsclMemAllocator> protocolExtensionHeader(_STRLIT_CHAR("key=PVPlayerCoreEngineTest;value=Test;method=GET,POST"));
@@ -516,7 +562,8 @@
         {
             iMetadataValueList.clear();
             iNumValues = 0;
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, -1, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
+            //Lets try retrieving the values in blocks.
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, iStartingIndex, iBlockSize, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
         break;
@@ -525,15 +572,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_SDP_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_streamingopenplaystop_");
                 OSCL_wHeapString<OsclMemAllocator> inputfilename;
@@ -542,18 +589,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -564,15 +603,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_SDP_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_streamingopenplaystop_");
                 OSCL_wHeapString<OsclMemAllocator> inputfilename;
@@ -581,18 +620,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -621,88 +652,190 @@
             {
                 if (iPlayListURL == true)
                 {
-                    if (iPlayListSwitchMode == 0)
+                    if (!iErrorCodeTest)
                     {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        if (iPlayListSwitchMode == 0)
                         {
-                            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
-                            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-                            iKVPSetAsync.value.uint32_value = 2000;
-                            iErrorKVP = NULL;
-                            fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
-                            OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
-                            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 2000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            }
+                            PVPPlaybackPosition start, end;
+                            start.iIndeterminate = false;
+                            start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
+                            start.iMode = PVPPBPOS_MODE_NOW;
+                            start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+                            start.iPlayListPosValue.millisec_value = 0;
+                            start.iPlayElementIndex = 2;
+                            start.iPlayListUri = NULL;
+                            end.iIndeterminate = true;
+                            fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d ...\n", start.iPlayElementIndex);
+                            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
                         }
-                        PVPPlaybackPosition start, end;
-                        start.iIndeterminate = false;
-                        start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
-                        start.iMode = PVPPBPOS_MODE_NOW;
-                        start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
-                        start.iPlayListPosValue.millisec_value = 0;
-                        start.iPlayElementIndex = 4;
-                        start.iPlayListUri = NULL;
-                        end.iIndeterminate = true;
-                        fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d ...\n", start.iPlayElementIndex);
-                        OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
-                    }
-                    else if (iPlayListSwitchMode == 1)
-                    {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        else if (iPlayListSwitchMode == 1)
                         {
-                            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
-                            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-                            iKVPSetAsync.value.uint32_value = 2000;
-                            iErrorKVP = NULL;
-                            fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
-                            OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
-                            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 2000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            }
+                            PVPPlaybackPosition start, end;
+                            start.iIndeterminate = false;
+                            start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
+                            start.iMode = PVPPBPOS_MODE_END_OF_CURRENT_PLAY_ELEMENT;
+                            start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+                            start.iPlayListPosValue.millisec_value = 0;
+                            start.iPlayElementIndex = 0;
+                            start.iPlayListUri = NULL;
+                            end.iIndeterminate = true;
+                            fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d at the end of current clip...\n", start.iPlayElementIndex);
+                            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
                         }
-                        PVPPlaybackPosition start, end;
-                        start.iIndeterminate = false;
-                        start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
-                        start.iMode = PVPPBPOS_MODE_END_OF_CURRENT_PLAY_ELEMENT;
-                        start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
-                        start.iPlayListPosValue.millisec_value = 0;
-                        start.iPlayElementIndex = 0;
-                        start.iPlayListUri = NULL;
-                        end.iIndeterminate = true;
-                        fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d at the end of current clip...\n", start.iPlayElementIndex);
-                        OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
-                    }
-                    else if (iPlayListSwitchMode == 2)
-                    {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        else if (iPlayListSwitchMode == 2)
                         {
-                            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
-                            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-                            iKVPSetAsync.value.uint32_value = 2000;
-                            iErrorKVP = NULL;
-                            fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
-                            OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
-                            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 2000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            }
+                            PVPPlaybackPosition start, end;
+                            start.iIndeterminate = false;
+                            start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
+                            start.iMode = PVPPBPOS_MODE_END_OF_CURRENT_PLAY_SESSION;
+                            start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+                            start.iPlayListPosValue.millisec_value = 0;
+                            start.iPlayElementIndex = 2;
+                            start.iPlayListUri = NULL;
+                            end.iIndeterminate = true;
+                            fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d at the end of current playlist...\n", start.iPlayElementIndex);
+                            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
                         }
-                        PVPPlaybackPosition start, end;
-                        start.iIndeterminate = false;
-                        start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
-                        start.iMode = PVPPBPOS_MODE_END_OF_CURRENT_PLAY_SESSION;
-                        start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
-                        start.iPlayListPosValue.millisec_value = 0;
-                        start.iPlayElementIndex = 2;
-                        start.iPlayListUri = NULL;
-                        end.iIndeterminate = true;
-                        fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d at the end of current playlist...\n", start.iPlayElementIndex);
-                        OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
-                    }
 
+                    }
+                    else
+                    {
+                        // Test for error code 404
+                        if (iErrorCode == 404)
+                        {
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 2000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            }
+                            PVPPlaybackPosition start, end;
+                            start.iIndeterminate = false;
+                            start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
+                            start.iMode = PVPPBPOS_MODE_NOW;
+                            start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+                            start.iPlayListPosValue.millisec_value = 0;
+                            start.iPlayElementIndex = 0;
+                            // The uri is set to a non-existent clip in order to elicit a 404 response from the server.
+                            iURLToTest404 = _STRLIT_CHAR("/public/playlist/va_playlists/test_error_404.ply");
+                            start.iPlayListUri = iURLToTest404.get_str();
+                            end.iIndeterminate = true;
+                            fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d ... of clip %s\n", start.iPlayElementIndex, start.iPlayListUri);
+                            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
+                        }
+                        // Test for error code 415
+                        else if (iErrorCode == 415)
+                        {
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 2000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            }
+                            PVPPlaybackPosition start, end;
+                            start.iIndeterminate = false;
+                            start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
+                            start.iMode = PVPPBPOS_MODE_NOW;
+                            start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+                            start.iPlayListPosValue.millisec_value = 0;
+                            start.iPlayElementIndex = 0;
+                            // The uri is set to a clip containing different media type in order to elicit a 415 response from the server.
+                            iURLToTest415 = _STRLIT_CHAR("/public/playlist/va_playlists/ply_av_02_h264_aac_plus_v1.ply");
+                            start.iPlayListUri = iURLToTest415.get_str();
+                            end.iIndeterminate = true;
+                            fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d ... of clip %s\n", start.iPlayElementIndex, start.iPlayListUri);
+                            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
+                        }
+                        // Test for error code 457
+                        else if (iErrorCode == 457)
+                        {
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 2000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Setting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            }
+                            PVPPlaybackPosition start, end;
+                            start.iIndeterminate = false;
+                            start.iPosUnit = PVPPBPOSUNIT_PLAYLIST;
+                            start.iMode = PVPPBPOS_MODE_NOW;
+                            start.iPlayListPosUnit = PVPPBPOSUNIT_MILLISEC;
+                            start.iPlayListPosValue.millisec_value = 0;
+                            // The clip index is set to a really large value (and to one that doesn't exist) in order
+                            // to elicit a 457 response from the server.
+                            start.iPlayElementIndex = 20000;
+                            start.iPlayListUri = NULL;
+                            end.iIndeterminate = true;
+                            fprintf(iTestMsgOutputFile, "***Repositioning to playlistelem %d ...\n", start.iPlayElementIndex);
+                            OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
+                        }
+                    }
                 }
                 else
                 {
+
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
-                    start.iPosValue.millisec_value = iSessionDuration / 4;
+                    start.iMode = PVPPBPOS_MODE_NOW;
+                    // If multiple see enabled and clip length is > 20 sec we need to issue two set playback range
+                    // requests back to back
+                    if (true == oMultipleSeekToEndOfClipEnable && iSessionDuration > 20*1000)
+                    {
+                        // Let's reposition to 3 sec before End of clip
+                        start.iPosValue.millisec_value = (iSessionDuration - 3 * 1000);
+                        iState = STATE_SETPLAYBACKRANGE_2;
+                        RunIfNotReady();
+                    }
+                    else
+                    {
+                        start.iPosValue.millisec_value = iSessionDuration / 4;
+                    }
                     end.iIndeterminate = true;
-                    fprintf(iTestMsgOutputFile, "***Repositioning to %d ms...\n", iSessionDuration / 4);
+                    fprintf(iTestMsgOutputFile, "***Repositioning to %d ms...\n", start.iPosValue.millisec_value);
+
                     OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
                 }
                 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -714,6 +847,29 @@
         }
         break;
 
+        case STATE_SETPLAYBACKRANGE_2:
+        {
+            // Let's do a seek in backword direction to 1/4 of clip duration.
+            if (true == oMultipleSeekToEndOfClipEnable && iSessionDuration > 20*1000)
+            {
+
+                PVPPlaybackPosition start, end;
+                start.iIndeterminate = false;
+                start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                start.iMode = PVPPBPOS_MODE_NOW;
+                start.iPosValue.millisec_value = iSessionDuration / 4;
+                end.iIndeterminate = true;
+                fprintf(iTestMsgOutputFile, "***Repositioning to %d ms...\n", start.iPosValue.millisec_value);
+                OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
+                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+            }
+            else
+            {
+                fprintf(iTestMsgOutputFile, "***Setting PlayBack Range multiple times not Supported for this test...\n");
+            }
+        }
+        break;
+
         case STATE_PAUSE:
         {
             fprintf(iTestMsgOutputFile, "***Pausing...\n");
@@ -782,26 +938,28 @@
         case STATE_REMOVEDATASOURCE:
         {
             fprintf(iTestMsgOutputFile, "***Removing Data Source...\n");
+            if (iUseFileHandle)
+            {
+                if (ifilehandle)
+                    OSCL_DELETE(ifilehandle);
+            }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->RemoveDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
             iPlayer = NULL;
+#if PVR_SUPPORT
+            if (m_PVRControl)
+            {
+                delete m_PVRControl;
+                m_PVRControl = NULL;
+            }
+#endif
 
             delete iSourceContextData;
             iSourceContextData = NULL;
@@ -912,8 +1070,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -925,6 +1083,18 @@
         case STATE_INIT:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+#if PVR_SUPPORT
+                if (iPlayListURL)
+                {
+                    PVRConfig pvrConfig;
+                    pvrConfig.SetLiveBufferEnabled(true);
+                    pvrConfig.SetRecordingEnabled(false);
+                    pvrConfig.SetLiveBufferStorage(iLiveBufferStorage);
+                    pvrConfig.SetLiveBufferSizeInSeconds(iLiveBufferDurationInSec);
+                    if (m_PVRControl)
+                        m_PVRControl->SetConfiguration(pvrConfig);
+                }
+#endif
                 iState = STATE_GETMETADATAKEYLIST;
                 RunIfNotReady();
             }
@@ -932,8 +1102,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -947,8 +1117,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -956,15 +1126,26 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                iState = STATE_ADDDATASINK_VIDEO;
+
+                iTotalValuesRetrieved += iBlockSize;
+
+                if (iNumValues > OSCL_STATIC_CAST(int32, iTotalValuesRetrieved))
+                {
+                    iStartingIndex = iTotalValuesRetrieved;
+                    iState = STATE_GETMETADATAVALUELIST;
+                }
+                else
+                {
+                    iState = STATE_ADDDATASINK_VIDEO;
+                }
                 RunIfNotReady();
             }
             else
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -978,8 +1159,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -993,8 +1174,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1008,15 +1189,15 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_START:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                if (oLiveSession == false)
+                if ((false == iPauseDenied) || (false == oLiveSession))
                 {
                     if (oForwardEnable == true)
                     {
@@ -1058,8 +1239,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1077,36 +1258,108 @@
                 }
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (!iErrorCodeTest)
                     {
-                        int32 error;
-                        iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
-                        iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-                        iKVPSetAsync.value.uint32_value = 4000;
-                        iErrorKVP = NULL;
-                        fprintf(iTestMsgOutputFile, "***Resetting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
-                        OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
-                        OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
-                        // New test case for testing switching at the end of current clip
-                        iPlayListSwitchMode++;
-                        if (iPlayListSwitchMode == 1)
+                        if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                         {
-                            // Switch at end of clip
-                            RunIfNotReady(5*1000*1000);
+                            int32 error;
+                            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                            iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                            iKVPSetAsync.value.uint32_value = 4000;
+                            iErrorKVP = NULL;
+                            fprintf(iTestMsgOutputFile, "***Resetting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                            OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                            // New test case for testing switching at the end of current clip
+                            iPlayListSwitchMode++;
+                            if (iPlayListSwitchMode == 1)
+                            {
+                                // Switch at end of clip
+                                RunIfNotReady(5*1000*1000);
+                            }
+                            else if (iPlayListSwitchMode == 2)
+                            {
+                                // Switch at end of playlist
+                                RunIfNotReady(120*1000*1000);
+                            }
+                            else
+                            {
+                                //run for 15 seconds and stop
+                                iState = STATE_STOP;
+                                RunIfNotReady(15*1000*1000);
+                            }
                         }
-                        else if (iPlayListSwitchMode == 2)
+                    }
+                    else
+                    {
+                        if (iErrorCode == 404)
                         {
-                            // Switch at end of playlist
-                            RunIfNotReady(120*1000*1000);
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                int32 error;
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 4000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Resetting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                                iErrorCode = 415;
+                                RunIfNotReady();
+                            }
+                        }
+                        else if (iErrorCode == 415)
+                        {
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                int32 error;
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 4000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Resetting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                                iErrorCode = 457;
+                                RunIfNotReady();
+                            }
+                        }
+                        else if (iErrorCode == 457)
+                        {
+                            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
+                            {
+                                int32 error;
+                                iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
+                                iKVPSetAsync.key = iKeyStringSetAsync.get_str();
+                                iKVPSetAsync.value.uint32_value = 4000;
+                                iErrorKVP = NULL;
+                                fprintf(iTestMsgOutputFile, "***Resetting Jitter Buffer Duration to = %d ms\n", iKVPSetAsync.value.uint32_value);
+                                OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
+                                OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
+                                iErrorCode = 404;
+                                iErrorCodeTest = false;
+                                //run for 15 seconds and stop
+                                iState = STATE_STOP;
+                                RunIfNotReady(15*1000*1000);
+                            }
                         }
                     }
                 }
+
+
                 if (oWaitForEOS == false)
                 {
-                    //run for 15 seconds and stop
-                    iState = STATE_STOP;
-                    RunIfNotReady(15*1000*1000);
-
+                    if (iSeekAfterPause)
+                    {
+                        iState = STATE_RESUME;
+                        RunIfNotReady();
+                    }
+                    else
+                    {
+                        //run for 15 seconds and stop
+                        iState = STATE_STOP;
+                        RunIfNotReady(15*1000*1000);
+                    }
                 }
                 else
                 {
@@ -1123,24 +1376,58 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_SETPLAYBACKRANGE_2:
+            if ((aResponse.GetCmdStatus() == PVMFSuccess) ||
+                    (aResponse.GetCmdStatus() == PVMFErrNotSupported))
+            {
+                // Clip will be played till EOS
+                if (aResponse.GetCmdStatus() == PVMFErrNotSupported)
+                {
+                    fprintf(iTestMsgOutputFile, "***Repositioning not supported...\n");
+                }
+                else
+                {
+                    fprintf(iTestMsgOutputFile, "***Repositioning success...\n");
+                }
+
+            }
+            else
+            {
+                fprintf(iTestMsgOutputFile, "***Repositioning failed...\n");
+                // SetPlaybackRange failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_PAUSE:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
-                iNumPause++;
-                iState = STATE_RESUME;
-                RunIfNotReady(iPauseDurationInMS*1000);
+                if (iSeekAfterPause)
+                {
+                    iNumPause++;
+                    iState = STATE_SETPLAYBACKRANGE;
+                    RunIfNotReady(iPauseDurationInMS*1000);
+                }
+                else
+                {
+                    iNumPause++;
+                    iState = STATE_RESUME;
+                    RunIfNotReady(iPauseDurationInMS*1000);
+                }
             }
             else
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1167,8 +1454,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1210,8 +1497,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1225,8 +1512,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1240,8 +1527,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1255,8 +1542,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1322,14 +1609,15 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_WAIT_FOR_CANCELALL:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
+                fprintf(iTestMsgOutputFile, "Cancel Cmd Complete...\n");
                 // Cancel succeeded so test passed
                 PVPATB_TEST_IS_TRUE(true);
                 iState = STATE_CLEANUPANDCOMPLETE;
@@ -1346,10 +1634,11 @@
             }
             else
             {
+                fprintf(iTestMsgOutputFile, "Cancel Cmd Failed...\n");
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1508,8 +1797,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_streamingopenplaystop::HandleSocketNodeErrors(int32 aErr)
@@ -1944,34 +2231,53 @@
 
 void pvplayer_async_test_streamingopenplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
+    if (aEvent.GetEventType() == PVMFInfoRemoteSourceNotification)
+    {
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface != NULL)
         {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
+            PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+            PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+            if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+            {
+                PVUuid engerruuid;
+                int32 errCodeEng;
+                infomsgiface->GetCodeUUID(errCodeEng, engerruuid);
+                if (engerruuid == PVPlayerErrorInfoEventTypesUUID)
+                {
+                    PVMFErrorInfoMessageInterface* sourceNodeErrorIF =
+                        infomsgiface->GetNextMessage();
+                    if (sourceNodeErrorIF != NULL)
+                    {
+                        PVUuid eventuuid;
+                        int32 srcInfoCode;
+                        sourceNodeErrorIF->GetCodeUUID(srcInfoCode, eventuuid);
+                        if (eventuuid == PVMFStreamingManagerNodeEventTypeUUID)
+                        {
+                            if (srcInfoCode == PVMFStreamingManagerNodeInfoLaunchURL)
+                            {
+                                PVExclusivePtr url; ;
+                                aEvent.GetEventData(url);
+                                fprintf(iTestMsgOutputFile, "PVMFInfoRemoteSourceNotification:Launching URL:%s\n", (char*)url);
+                            }
+                        }
+                    }
+                }
+            }
         }
+
+
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -2066,15 +2372,21 @@
     {
         PVExclusivePtr aPtr;
         aEvent.GetEventData(aPtr);
-        PVMFRTSPClientEngineNodePlaylistInfoType *myType = (PVMFRTSPClientEngineNodePlaylistInfoType*)(aPtr);
-        fprintf(iTestMsgOutputFile, "###PVMFInfoPlayListClipTransition:\n<%s, %d, %d.%03d>;npt=%d.%03d;mediaName=%s;userData=%s\n", myType->iPlaylistUrlPtr
-                , myType->iPlaylistIndex
-                , myType->iPlaylistOffsetSec
-                , myType->iPlaylistOffsetMillsec
-                , myType->iPlaylistNPTSec
-                , myType->iPlaylistNPTMillsec
-                , myType->iPlaylistMediaNamePtr
-                , myType->iPlaylistUserDataPtr);
+        // With the addition of TC 863, there are cases where a PLAYLIST_PLAY response is not always successful.
+        // In such a case, aPtr will be NULL and needs to be checked for.
+        if (NULL != aPtr)
+        {
+
+            PVMFRTSPClientEngineNodePlaylistInfoType *myType = (PVMFRTSPClientEngineNodePlaylistInfoType*)(aPtr);
+            fprintf(iTestMsgOutputFile, "###PVMFInfoPlayListClipTransition:\n<%s, %d, %d.%03d>;npt=%d.%03d;mediaName=%s;userData=%s\n", myType->iPlaylistUrlPtr
+                    , myType->iPlaylistIndex
+                    , myType->iPlaylistOffsetSec
+                    , myType->iPlaylistOffsetMillsec
+                    , myType->iPlaylistNPTSec
+                    , myType->iPlaylistNPTMillsec
+                    , myType->iPlaylistMediaNamePtr
+                    , myType->iPlaylistUserDataPtr);
+        }
     }
     // Check and print out playback position status
     else if (aEvent.GetEventType() == PVMFInfoPositionStatus)
@@ -2136,6 +2448,17 @@
             fprintf(iTestMsgOutputFile, "###PVMFInfoTrackDisable - DisableTrack=%d\n", iDisableTrack);
         }
     }
+    if (aEvent.GetEventType() == PVMFInfoActualPlaybackPosition)
+    {
+        PVExclusivePtr aPtr;
+        aEvent.GetEventData(aPtr);
+        PVPPlaybackPosition* actualpos = (PVPPlaybackPosition*)aPtr;
+        if (actualpos != NULL)
+        {
+            fprintf(iTestMsgOutputFile, "###PVMFInfoActualPlaybackPosition (in ms) = %d\n",
+                    actualpos->iPosValue.millisec_value);
+        }
+    }
 }
 
 void pvplayer_async_test_streamingopenplaystop::PrintMetadataInfo()
@@ -2213,7 +2536,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -2242,6 +2565,17 @@
                 oLiveSession = true;
             }
         }
+
+
+        //Check to see if pause-denied metadat is available?
+        if (oscl_strstr(iMetadataValueList[i].key, "pause-denied"))
+        {
+            if (iMetadataValueList[i].value.bool_value)
+            {
+                iPauseDenied = true;
+            }
+        }
+
     }
 
     fprintf(iTestMsgOutputFile, "\n\n");
@@ -2305,16 +2639,16 @@
             if (oscl_strstr(iFileName, "test.mp4") != NULL)
             {
                 filename = AMR_MPEG4_SDP_FILE;
-                fileType = PVMF_DATA_SOURCE_SDP_FILE;
+                fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
             }
             else
             {
                 filename = iFileName;
             }
 
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
             }
             fprintf(iTestMsgOutputFile, "***Source URL=%s\n", filename.get_str());
             oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
@@ -2328,7 +2662,7 @@
 
         case STATE_CONFIGPARAMS:
         {
-            if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                 iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -2372,11 +2706,11 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
@@ -2389,18 +2723,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2411,11 +2737,11 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
@@ -2428,18 +2754,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2451,7 +2769,7 @@
             fprintf(iTestMsgOutputFile, "***Preparing...\n");
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
-            if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 iState = STATE_RECONFIGJITTERBUFFER;
                 RunIfNotReady(10000000);
@@ -2489,6 +2807,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 21603;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -2561,16 +2880,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -2675,7 +2984,7 @@
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
                 iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady(5000000);
+                RunIfNotReady();
             }
             break;
 
@@ -2693,8 +3002,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2708,8 +3017,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2723,8 +3032,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2738,8 +3047,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2753,14 +3062,14 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
         case STATE_PREPARE:
         {
-            if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 // shouldn't ever get here for non-http urls
                 OSCL_ASSERT(0);
@@ -2774,7 +3083,16 @@
         }
         break;
 
+        //it is possible that in case of some clips
+        //prepare completes before we get a chance
+        //to reconfigure JB
+        case STATE_RECONFIGJITTERBUFFER:
+        {
+            fprintf(iTestMsgOutputFile, "Prepare Completed before we could do JB Adjust\n");
+        }
+        //intentional fall thru
         case STATE_PREPARING:
+        {
             RunIfNotReady();
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
@@ -2785,10 +3103,11 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
-            break;
+        }
+        break;
 
         case STATE_START:
             if (aResponse.GetCmdStatus() == PVMFSuccess)
@@ -2818,8 +3137,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2839,8 +3158,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2854,8 +3173,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2874,8 +3193,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2889,8 +3208,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2904,8 +3223,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2919,8 +3238,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3079,8 +3398,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_streamingJBadjust::HandleSocketNodeErrors(int32 aErr)
@@ -3461,34 +3778,15 @@
 
 void pvplayer_async_test_streamingJBadjust::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoBufferingComplete)
@@ -3591,6 +3889,17 @@
             fprintf(iTestMsgOutputFile, "###PVMFInfoTrackDisable - DisableTrack=%d\n", iDisableTrack);
         }
     }
+    if (aEvent.GetEventType() == PVMFInfoActualPlaybackPosition)
+    {
+        PVExclusivePtr aPtr;
+        aEvent.GetEventData(aPtr);
+        PVPPlaybackPosition* actualpos = (PVPPlaybackPosition*)aPtr;
+        if (actualpos != NULL)
+        {
+            fprintf(iTestMsgOutputFile, "###PVMFInfoActualPlaybackPosition (in ms) = %d\n",
+                    actualpos->iPosValue.millisec_value);
+        }
+    }
 }
 
 
@@ -3647,17 +3956,17 @@
 
             if (oscl_strstr(iFileName, "test.mp4") != NULL)
             {
-                filename = AMR_MPEG4_SDP_FILE;
-                fileType = PVMF_DATA_SOURCE_SDP_FILE;
+                filename = WM_BSS_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
             }
             else
             {
                 filename = iFileName;
             }
 
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
             }
             fprintf(iTestMsgOutputFile, "***Source URL=%s\n", filename.get_str());
             oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
@@ -3716,11 +4025,11 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
@@ -3733,18 +4042,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3755,11 +4056,11 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
@@ -3772,18 +4073,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3842,6 +4135,7 @@
                 PVPPlaybackPosition start, end;
                 start.iIndeterminate = false;
                 start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                start.iMode = PVPPBPOS_MODE_NOW;
                 start.iPosValue.millisec_value = iSessionDuration / 4;
                 end.iIndeterminate = true;
                 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -3919,16 +4213,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -4032,8 +4316,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4047,8 +4331,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4062,8 +4346,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4078,8 +4362,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4093,8 +4377,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4108,8 +4392,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4123,8 +4407,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4141,8 +4425,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4161,8 +4445,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4176,8 +4460,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4195,8 +4479,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4210,8 +4494,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4225,8 +4509,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4240,8 +4524,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4400,8 +4684,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_streaming_bitstream_switch::HandleSocketNodeErrors(int32 aErr)
@@ -4816,40 +5098,57 @@
 
 void pvplayer_async_test_streaming_bitstream_switch::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
+    if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
+    {
+        // source rollover...
+        fprintf(iTestMsgOutputFile, "###PVMFInfoSourceFormatNotSupported...\n");
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface != NULL)
         {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
+            PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+            PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+            if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+            {
+                int32 infocode;
+                PVUuid infouuid;
+                infomsgiface->GetCodeUUID(infocode, infouuid);
+                if ((infouuid == PVPlayerErrorInfoEventTypesUUID) &&
+                        (infocode == PVPlayerInfoAttemptingSourceRollOver))
+                {
+                    uint8* localBuf = aEvent.GetLocalBuffer();
+                    if (localBuf != NULL)
+                    {
+                        uint32 srcFormat = 0;
+                        oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                    }
+                }
+            }
         }
     }
 
+    if (aEvent.GetEventType() == PVMFInfoBufferingStart)
+    {
+        // Preroll buffer has started filling.
+        fprintf(iTestMsgOutputFile, "###PVMFInfoBufferingStart...\n");
+    }
+
     if (aEvent.GetEventType() == PVMFInfoBufferingComplete)
     {
         // Preroll buffer has been filled.
         // Do nothing
+        fprintf(iTestMsgOutputFile, "###PVMFInfoBufferingComplete...\n");
     }
 
     // Check for stop time reached event
@@ -4875,6 +5174,7 @@
             }
         }
     }
+
     if (aEvent.GetEventType() == PVMFInfoBufferingStatus)
     {
         uint8* localBuf = aEvent.GetLocalBuffer();
@@ -4899,6 +5199,77 @@
                 , myType->iPlaylistMediaNamePtr
                 , myType->iPlaylistUserDataPtr);
     }
+    // Check and print out playback position status
+    else if (aEvent.GetEventType() == PVMFInfoPositionStatus)
+    {
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface == NULL)
+        {
+            return;
+        }
+        PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+        PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+        if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+        {
+            int32 infocode;
+            PVUuid infouuid;
+            infomsgiface->GetCodeUUID(infocode, infouuid);
+            if ((infouuid == PVPlayerErrorInfoEventTypesUUID) && (infocode == PVPlayerInfoPlaybackPositionStatus))
+            {
+                uint8* localbuf = aEvent.GetLocalBuffer();
+                uint32 pbpos = 0;
+                oscl_memcpy(&pbpos, &(localbuf[4]), 4);
+                fprintf(iTestMsgOutputFile, "Playback status(time) %d ms\n", pbpos);
+            }
+        }
+
+        PVPPlaybackPosition curpos;
+
+        curpos.iPosValue.percent_value = 0;
+        curpos.iPosUnit = PVPPBPOSUNIT_PERCENT;
+        if (iPlayer->GetCurrentPositionSync(curpos) == PVMFSuccess)
+        {
+            fprintf(iTestMsgOutputFile, "Playback status(percentage) %d%%\n", curpos.iPosValue.percent_value);
+        }
+
+
+        curpos.iPosValue.samplenum_value = 0;
+        curpos.iPosUnit = PVPPBPOSUNIT_SAMPLENUMBER;
+        if (iPlayer->GetCurrentPositionSync(curpos) == PVMFSuccess)
+        {
+            fprintf(iTestMsgOutputFile, "Playback status(sample number) %d\n", curpos.iPosValue.samplenum_value);
+        }
+
+        curpos.iPosValue.datapos_value = 0;
+        curpos.iPosUnit = PVPPBPOSUNIT_DATAPOSITION;
+        if (iPlayer->GetCurrentPositionSync(curpos) == PVMFSuccess)
+        {
+            fprintf(iTestMsgOutputFile, "Playback status(data position) %d bytes\n", curpos.iPosValue.datapos_value);
+        }
+
+        fprintf(iTestMsgOutputFile, "------------------------------\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoTrackDisable)
+    {
+        PVExclusivePtr aPtr;
+        aEvent.GetEventData(aPtr);
+        int32 iDisableTrack = (int32)aPtr;
+        if (iDisableTrack != 0)
+        {
+            fprintf(iTestMsgOutputFile, "###PVMFInfoTrackDisable - DisableTrack=%d\n", iDisableTrack);
+        }
+    }
+    if (aEvent.GetEventType() == PVMFInfoActualPlaybackPosition)
+    {
+        PVExclusivePtr aPtr;
+        aEvent.GetEventData(aPtr);
+        PVPPlaybackPosition* actualpos = (PVPPlaybackPosition*)aPtr;
+        if (actualpos != NULL)
+        {
+            fprintf(iTestMsgOutputFile, "###PVMFInfoActualPlaybackPosition (in ms) = %d\n",
+                    actualpos->iPosValue.millisec_value);
+        }
+    }
 }
 
 void pvplayer_async_test_streaming_bitstream_switch::PrintMetadataInfo()
@@ -4976,7 +5347,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -5009,6 +5380,7 @@
 
 void pvplayer_async_test_dvbh_streamingopenplaystop::StartTest(void)
 {
+
     AddToScheduler();
     iState = STATE_CREATE;
     RunIfNotReady();
@@ -5016,7 +5388,7 @@
 
 void pvplayer_async_test_dvbh_streamingopenplaystop::Run(void)
 {
-    int error = 0;
+    int error = 1;
 
     switch (iState)
     {
@@ -5024,6 +5396,7 @@
         {
             iPlayer = NULL;
             fprintf(iTestMsgOutputFile, "***Creating Player Engine...\n");
+
             OSCL_TRY(error, iPlayer = PVPlayerFactory::CreatePlayer(this, this, this));
             if (error)
             {
@@ -5035,6 +5408,7 @@
                 iState = STATE_QUERYINTERFACE;
                 RunIfNotReady();
             }
+
         }
         break;
 
@@ -5056,8 +5430,8 @@
             if (oscl_strstr(iFileName, "test.mp4") != NULL)
             {
                 filename = AMR_MPEG4_SDP_FILE;
-                fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
             }
             else
             {
@@ -5067,8 +5441,19 @@
             oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
             wFileName.set(output, oscl_strlen(output));
 
+            m_sourceContext.DisableStreamingSourceContext() ;
+            m_sourceContext.DisableeDownloadHTTPSourceContext() ;
+            m_sourceContext.DisableDownloadPVXSourceContext() ;
+            m_sourceContext.DisablePVRSourceContext() ;
+            m_sourceContext.DisablePacketSourceSourceContext();
+            m_sourceContext.DisablePVRLocalPlaySourceContext();
+            m_sourceContext.DisableCommonSourceContext();
+
+
             // Remove in final for dedicated test
-            fileType = PVMF_DATA_SOURCE_RTP_PACKET_SOURCE;
+            fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+
+
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
             iNumPlay++;
         }
@@ -5078,7 +5463,7 @@
         {
             fprintf(iTestMsgOutputFile, "***Configuring Params...\n");
 
-            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=streaming");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("NSPlayer/9.0 PVPlayerCoreEngineTestUserAgent"));
             iKVPSetAsync.value.pWChar_value = userAgent.get_str();
@@ -5163,7 +5548,7 @@
 
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/keep-alive-interval;valtype=uint32");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-            iKVPSetAsync.value.uint32_value = 4; //0xffffffff;
+            iKVPSetAsync.value.uint32_value = 4;
             iErrorKVP = NULL;
             OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
@@ -5178,6 +5563,13 @@
             fprintf(iTestMsgOutputFile, "***Initializing...\n");
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+#if PVR_SUPPORT
+            PVRConfig pvrConfig;
+            pvrConfig.SetLiveBufferEnabled(true);
+            pvrConfig.SetLiveBufferSizeInSeconds(300);
+            pvrConfig.SetLiveBufferStorage(PVRConfig::EMemory);
+            m_PVRControl->SetConfiguration(pvrConfig);
+#endif
         }
         break;
 
@@ -5202,15 +5594,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_SDP_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_streamingopenplaystop_");
                 OSCL_wHeapString<OsclMemAllocator> inputfilename;
@@ -5219,18 +5611,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -5241,15 +5625,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_SDP_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_streamingopenplaystop_");
                 OSCL_wHeapString<OsclMemAllocator> inputfilename;
@@ -5258,18 +5642,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -5279,6 +5655,7 @@
         case STATE_PREPARE:
         {
             fprintf(iTestMsgOutputFile, "***Preparing...\n");
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Prepare((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -5299,7 +5676,7 @@
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
                         iKVPSetAsync.key = iKeyStringSetAsync.get_str();
@@ -5324,6 +5701,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     start.iPosValue.millisec_value = iSessionDuration / 4;
                     end.iIndeterminate = true;
                     OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5401,16 +5779,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -5422,6 +5790,7 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+
             delete iDataSinkVideo;
             iDataSinkVideo = NULL;
 
@@ -5440,6 +5809,14 @@
             iMioFactory->DestroyAudioOutput(iMIOFileOutAudio);
             iMIOFileOutAudio = NULL;
 
+#if PVR_SUPPORT
+            if (m_PVRControl)
+            {
+                OSCL_DELETE(m_PVRControl);
+                m_PVRControl = NULL;
+            }
+#endif
+
             iObserver->TestCompleted(*iTestCase);
         }
         break;
@@ -5522,8 +5899,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5542,8 +5919,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5557,8 +5934,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5573,8 +5950,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5588,8 +5965,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5603,8 +5980,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5618,8 +5995,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5659,8 +6036,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5670,7 +6047,7 @@
             {
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -5694,8 +6071,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5709,8 +6086,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5728,8 +6105,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5743,8 +6120,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5758,8 +6135,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5773,8 +6150,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5788,8 +6165,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5848,8 +6225,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5874,8 +6251,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6026,40 +6403,19 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_dvbh_streamingopenplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -6640,7 +6996,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -6664,7 +7020,6 @@
         if (oscl_strcmp((char*)(iMetadataValueList[i].key),
                         _STRLIT_CHAR("duration;valtype=char*")) == 0)
         {
-            // disabled because of the sdp file being used has no range
         }
     }
 
@@ -6727,14 +7082,14 @@
                 if (iProtocolRollOverWithUnknownURLType)
                 {
                     filename = AMR_MPEG4_RTSP_URL;
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iFileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+                    iFileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
                 }
                 else
                 {
                     filename = AMR_MPEG4_SDP_FILE;
-                    fileType = PVMF_DATA_SOURCE_SDP_FILE;
-                    iFileType = PVMF_DATA_SOURCE_SDP_FILE;
+                    fileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
+                    iFileType = PVMF_MIME_DATA_SOURCE_SDP_FILE;
                 }
             }
             else
@@ -6746,11 +7101,11 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 if (iProtocolRollOverWithUnknownURLType == false)
                 {
 #ifdef USE_NEW_PVMF_SOURCE_CONTEXT_DATA
@@ -6791,27 +7146,27 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
 #if RUN_RTSP_CLOAKING_TESTCASES
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
 #endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
                 }
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -6825,7 +7180,7 @@
         {
             fprintf(iTestMsgOutputFile, "***Configuring Params...\n");
 
-            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
+            iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*;mode=streaming");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent(_STRLIT_WCHAR("NSPlayer/9.0 PVPlayerCoreEngineTestUserAgent"));
             iKVPSetAsync.value.pWChar_value = userAgent.get_str();
@@ -6912,7 +7267,7 @@
 
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/keep-alive-interval;valtype=uint32");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
-            iKVPSetAsync.value.uint32_value = 4; //0xffffffff;
+            iKVPSetAsync.value.uint32_value = 4;
             iErrorKVP = NULL;
             OSCL_TRY(error, iPlayerCapConfigIF->setParametersSync(NULL, &iKVPSetAsync, 1, iErrorKVP));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); return);
@@ -7015,15 +7370,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_SDP_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_streamingopenplaystopprepareplaystop_");
                 OSCL_wHeapString<OsclMemAllocator> inputfilename;
@@ -7032,18 +7387,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -7054,15 +7401,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_SDP_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_streamingopenplaystopprepareplaystop_");
                 OSCL_wHeapString<OsclMemAllocator> inputfilename;
@@ -7071,18 +7418,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -7178,16 +7517,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -7303,8 +7632,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7323,8 +7652,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7338,8 +7667,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7354,8 +7683,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7369,8 +7698,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7384,8 +7713,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7399,8 +7728,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7426,8 +7755,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7441,8 +7770,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7456,8 +7785,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7483,8 +7812,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7498,8 +7827,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7513,8 +7842,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7528,8 +7857,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7543,8 +7872,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7576,8 +7905,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7602,8 +7931,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7760,8 +8089,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_streamingopenplaystoppreparelaystop::HandleSocketNodeErrors(int32 aErr)
@@ -8188,34 +8515,15 @@
 
 void pvplayer_async_test_streamingopenplaystoppreparelaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 
     if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
@@ -8368,6 +8676,17 @@
             fprintf(iTestMsgOutputFile, "###PVMFInfoTrackDisable - DisableTrack=%d\n", iDisableTrack);
         }
     }
+    if (aEvent.GetEventType() == PVMFInfoActualPlaybackPosition)
+    {
+        PVExclusivePtr aPtr;
+        aEvent.GetEventData(aPtr);
+        PVPPlaybackPosition* actualpos = (PVPPlaybackPosition*)aPtr;
+        if (actualpos != NULL)
+        {
+            fprintf(iTestMsgOutputFile, "###PVMFInfoActualPlaybackPosition (in ms) = %d\n",
+                    actualpos->iPosValue.millisec_value);
+        }
+    }
 }
 
 void pvplayer_async_test_streamingopenplaystoppreparelaystop::PrintMetadataInfo()
@@ -8445,7 +8764,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
@@ -8478,3 +8797,5 @@
 
     fprintf(iTestMsgOutputFile, "\n\n");
 }
+
+
diff --git a/engines/player/test/src/test_pv_player_engine_testset6.h b/engines/player/test/src/test_pv_player_engine_testset6.h
index af0bc68..16ebde5 100644
--- a/engines/player/test/src/test_pv_player_engine_testset6.h
+++ b/engines/player/test/src/test_pv_player_engine_testset6.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,15 +41,28 @@
 #include "pvmf_source_context_data.h"
 #endif
 
+#if PVR_SUPPORT
+#ifndef PVMF_PVR_CONTROL_INTERFACE_H_INCLUDED
+#include "pvmf_pvr_control_interface.h"
+#endif
+#ifndef PVPVRFFPARSER_H_INCLUDED
+#include "pvpvrffparser.h"
+#endif
+#endif
 
-#define AMR_MPEG4_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_RTSP_URL_2 "rtsp://test.mp4"
-#define H263_AMR_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://test.3gp"
-#define AAC_RTSP_URL     "rtsp://test.3gp"
-#define MPEG4_AAC_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_SDP_FILE "test.sdp"
+
+#define AMR_MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp"
+#define AMR_MPEG4_RTSP_URL_2 "rtsp://pvserveroha.pv.com/public/metadata/pvmetadata.mp4"
+#define H263_AMR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-122_h263-64.3gp"
+#define MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4rdatapartr64.3gp"
+#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4shorthdrr64.3gp"
+#define AAC_RTSP_URL     "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-aac64_novisual.3gp"
+#define MPEG4_AAC_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv2-aac64_mpeg4-rvlcs-64.3gp"
+#define AMR_MPEG4_SDP_FILE "pv_amr_mpeg4.sdp"
+#define WM_BSS_URL "http://pvwmsoha.pv.com:8020/WMContent/MBR/mbr_8tracks.wmv"
+#if PVR_SUPPORT
+#define DEFAULT_PV_PLAYLIST_URL "rtsp://pvserver6.pv.com:554/public/playlist/va_playlists/ply_av_01_mp4_aac.ply"
+#endif
 
 class PVPlayerDataSourceURL;
 class PVPlayerDataSink;
@@ -57,8 +70,8 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
-class PVPlayerDataSourcePacketSource;
 
+#define DEFAULT_LIVE_BUFFER_DURATION 20
 /*!
  *  A test case to test the normal engine sequence of playing an rtsp url
  *  - Data Source: RTSP URL
@@ -93,7 +106,9 @@
                 bool aWaitForEOS,
                 bool aCloaking,
                 bool aCancelDuringPrepare,
-                bool aForwardEnable)
+                bool aForwardEnable,
+                bool aUseFileHandle = false,
+                bool aMultipleSeekToEndOfClipEnable = false)
                 : pvplayer_async_test_base(aTestParam)
                 , iPlayer(NULL)
                 , iDataSource(NULL)
@@ -115,14 +130,30 @@
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
                 , iPlayListSwitchMode(0)
+                , iErrorCodeTest(false)
+                , iErrorCode(0)
+                , iUseFileHandle(false)
+                , iPauseDenied(false)
+                , iTotalValuesRetrieved(0)
+                , iStartingIndex(0)
+                , iBlockSize(5)
+#if PVR_SUPPORT
+                , m_PVRControl(NULL)
+                , iLiveBufferDurationInSec(DEFAULT_LIVE_BUFFER_DURATION)
+                , iLiveBufferStorage(PVRConfig::EMemory)
+#endif
         {
+            iSeekAfterPause  = false;
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
             oPauseResumeEnable = aPauseResumeEnable;
             oSeekEnable = aSeekEnable;
             oWaitForEOS = aWaitForEOS;
+            iUseFileHandle = aUseFileHandle;
+            ifilehandle = NULL;
             oCancelDuringPrepare = aCancelDuringPrepare;
             oForwardEnable = aForwardEnable;
+            oMultipleSeekToEndOfClipEnable = aMultipleSeekToEndOfClipEnable;
             iTestID = aTestID;
             iNumPlay = 0;
             iTargetNumPlay = 1;
@@ -164,9 +195,9 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE,
-            STATE_SETFORWARD
+            STATE_SETFORWARD,
+            STATE_SETPLAYBACKRANGE_2
         };
 
         PVTestState iState;
@@ -219,6 +250,17 @@
             iPauseDurationInMS = aDuration;
         }
 
+        void setPauseSetPlayBackRangeResumeSequence()
+        {
+            iSeekAfterPause = true;
+        }
+
+        void setErrorCodeTest()
+        {
+            iErrorCodeTest = true;
+            iErrorCode = 404;
+        }
+
     private:
         void HandleSocketNodeErrors(int32 aErr);
         void HandleRTSPNodeErrors(int32 aErr);
@@ -241,6 +283,7 @@
         uint32 iTestID;
         bool iSeekAfterEOSEnable;
         bool oForwardEnable;
+        bool oMultipleSeekToEndOfClipEnable;
 
         PVPMetadataList iMetadataKeyList;
         Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
@@ -262,19 +305,34 @@
         bool iProtocolRollOver;
         bool iProtocolRollOverWithUnknownURLType;
         bool iPlayListURL;
+
+        PVMFStreamingDataSource* iStreamDataSource;
+        PVMFSourceContextData* iSourceContextData;
         int32 iPlayListSwitchMode;
+        bool iErrorCodeTest;
+        uint32 iErrorCode;
+        bool iUseFileHandle;
 
         PvmiCapabilityAndConfig* iPlayerCapConfigIF;
         PvmiKvp* iErrorKVP;
         PvmiKvp iKVPSetAsync;
         OSCL_StackString<128> iKeyStringSetAsync;
+        OSCL_StackString<128> iURLToTest404;
+        OSCL_StackString<128> iURLToTest415;
+        bool	iPauseDenied;	//governed by the pause-denied metadata
+        uint32 iTotalValuesRetrieved;
+        uint32 iStartingIndex;
+        const uint32 iBlockSize;
+        bool iSeekAfterPause;
+#if PVR_SUPPORT
+        PVMFPVRControl* m_PVRControl;
+        uint32 iLiveBufferDurationInSec;
+        PVRConfig::TLiveBufferStorage iLiveBufferStorage;
+#endif
 
-        PVMFStreamingDataSource* iStreamDataSource;
-
-        PVMFSourceContextData* iSourceContextData;
+        OsclFileHandle* ifilehandle;
 };
 
-
 /*!
  *  A test case to test the normal engine sequence of playing an rtsp url
  *  - Data Source: RTSP URL
@@ -360,7 +418,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -489,7 +546,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -647,7 +703,6 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE,
             STATE_SETFORWARD,
             STATE_PREPARE1,
@@ -808,6 +863,8 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , m_PVRControl(NULL)
+                , ps(NULL)
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -853,14 +910,15 @@
             STATE_REMOVEDATASINK_AUDIO,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
         PVTestState iState;
 
         PVPlayerInterface* iPlayer;
-        PVPlayerDataSourcePacketSource* iDataSource;
+        PVPlayerDataSourceURL* iDataSource;
+
+
         PVPlayerDataSink* iDataSinkVideo;
         PVPlayerDataSink* iDataSinkAudio;
         PVMFNodeInterface* iIONodeVideo;
@@ -936,9 +994,16 @@
         PVMFStreamingDataSource* iStreamDataSource;
 
         PVMFSourceContextData* iSourceContextData;
+        PVMFSourceContextData m_sourceContext;
+
+        PVMFPVRControl* m_PVRControl;
+
+        PVMFPacketSource* ps;
 };
 
 
 
 #endif // TEST_PV_PLAYER_ENGINE_TESTSET6_H_INCLUDED
 
+
+
diff --git a/engines/player/test/src/test_pv_player_engine_testset7.cpp b/engines/player/test/src/test_pv_player_engine_testset7.cpp
index 5c8e5c8..63c59c3 100644
--- a/engines/player/test/src/test_pv_player_engine_testset7.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset7.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -143,18 +143,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -175,18 +167,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -203,11 +187,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -270,16 +254,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -372,8 +346,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -387,8 +361,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -402,8 +376,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -417,8 +391,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -432,8 +406,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -447,8 +421,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -462,8 +436,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -477,8 +451,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -492,8 +466,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -507,8 +481,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -522,8 +496,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -537,8 +511,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -552,8 +526,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -567,8 +541,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -632,41 +606,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_openplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -740,18 +693,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -772,18 +717,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -800,11 +737,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -888,16 +825,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -990,8 +917,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1005,8 +932,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1020,8 +947,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1035,8 +962,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1050,8 +977,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1065,8 +992,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1080,8 +1007,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1095,8 +1022,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1110,8 +1037,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1125,8 +1052,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1140,8 +1067,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1155,8 +1082,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1170,8 +1097,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1185,8 +1112,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1200,8 +1127,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1265,41 +1192,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_playstopplay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -1374,18 +1280,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1406,18 +1304,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1434,11 +1324,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1515,16 +1405,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -1617,8 +1497,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1632,8 +1512,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1647,8 +1527,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1662,8 +1542,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1677,8 +1557,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1692,8 +1572,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1707,8 +1587,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1722,8 +1602,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1737,8 +1617,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1752,8 +1632,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1767,8 +1647,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1782,8 +1662,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1797,8 +1677,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1812,8 +1692,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1877,41 +1757,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_pauseresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -1986,18 +1845,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2018,18 +1869,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2046,11 +1889,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2076,6 +1919,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 6;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlaybackRange, Pos=%d\n", start.iPosValue.sec_value);
@@ -2126,16 +1970,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -2228,8 +2062,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2243,8 +2077,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2258,8 +2092,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2273,8 +2107,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2288,8 +2122,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2303,8 +2137,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2318,8 +2152,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2341,8 +2175,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -2357,8 +2191,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2372,8 +2206,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2387,8 +2221,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2402,8 +2236,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2417,8 +2251,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2488,41 +2322,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_playsetplaybackrange::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -2597,18 +2410,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2629,18 +2434,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2657,11 +2454,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -2731,16 +2528,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -2833,8 +2620,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2848,8 +2635,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2863,8 +2650,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2878,8 +2665,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2893,8 +2680,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2908,8 +2695,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2938,8 +2725,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2953,8 +2740,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2968,8 +2755,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2983,8 +2770,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2998,8 +2785,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3013,8 +2800,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3078,41 +2865,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_3Xplayrate::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -3186,18 +2952,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3218,18 +2976,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3246,11 +2996,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3320,16 +3070,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -3422,8 +3162,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3437,8 +3177,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3452,8 +3192,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3467,8 +3207,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3482,8 +3222,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3497,8 +3237,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3527,8 +3267,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3542,8 +3282,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3557,8 +3297,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3572,8 +3312,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3587,8 +3327,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3602,8 +3342,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -3667,41 +3407,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_halfplayrate::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -3775,18 +3494,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3807,18 +3518,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3835,11 +3538,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3866,6 +3569,7 @@
             start.iIndeterminate = true;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             end.iPosValue.millisec_value = 10000;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -3886,6 +3590,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = false;
             end.iPosUnit = PVPPBPOSUNIT_MILLISEC;
@@ -3953,16 +3658,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -4055,8 +3750,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4070,8 +3765,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4085,8 +3780,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4100,8 +3795,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4115,8 +3810,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4130,8 +3825,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4145,8 +3840,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4168,8 +3863,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -4192,8 +3887,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -4208,8 +3903,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4223,8 +3918,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4238,8 +3933,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4253,8 +3948,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4268,8 +3963,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4283,8 +3978,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4354,13 +4049,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_looping::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -4416,34 +4120,6 @@
             }
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 
@@ -4516,18 +4192,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -4548,18 +4216,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -4576,11 +4236,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -4659,16 +4319,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -4761,8 +4411,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4776,8 +4426,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4791,8 +4441,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4806,8 +4456,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4821,8 +4471,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4836,8 +4486,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4851,8 +4501,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4879,8 +4529,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4894,8 +4544,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4909,8 +4559,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4924,8 +4574,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -4939,8 +4589,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5004,13 +4654,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_waitforeos::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -5034,34 +4693,6 @@
             }
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 
@@ -5105,16 +4736,74 @@
             OSCL_wHeapString<OsclMemAllocator> sinkfilename;
             OSCL_wHeapString<OsclMemAllocator> inputfilename;
 
-            // Add the data source
             iDataSource = new PVPlayerDataSourceURL;
+
             oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), output, 512);
             wFileName.set(output, oscl_strlen(output));
+
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
+            {
+
+                //iFileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+
+                    if (iProxyEnabled)
+                    {
+                        streamingContext->iProxyName = _STRLIT_WCHAR("63.215.241.33");
+                        streamingContext->iProxyPort = 7070;
+                    }
+
+                    streamingContext->iUserID = _STRLIT_CHAR("abc");
+                    streamingContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                }
+
+
+                iSourceContextData->EnableDownloadHTTPSourceContext();
+                sourceContext = NULL;
+                PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataDownloadHTTP* downloadContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                    if (iProxyEnabled)
+                    {
+                        downloadContext->iProxyName = _STRLIT_CHAR("63.215.241.33");
+                        downloadContext->iProxyPort = 7070;
+                    }
+                    downloadContext->iDownloadFileName = OUTPUTNAME_PREPEND_WSTRING;
+                    downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                    downloadContext->iConfigFileName = OUTPUTNAME_PREPEND_WSTRING;
+                    downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                    downloadContext->iUserID = _STRLIT_CHAR("abc");
+                    downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                    downloadContext->bIsNewSession = true;
+                    downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    downloadContext->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
+                }
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+
+            }
+
             RetrieveFilename(wFileName.get_str(), inputfilename);
+
+            // Add Data Source
             iDataSource->SetDataSourceURL(wFileName);
             iDataSource->SetDataSourceFormatType(iFileType);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
+
             // Initialize
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Init((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
@@ -5130,18 +4819,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -5156,18 +4838,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -5178,11 +4853,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -5320,21 +4995,14 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
             iPlayer = NULL;
 
+            delete iSourceContextData;
+            iSourceContextData = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -5428,8 +5096,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5448,8 +5116,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5468,8 +5136,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5488,8 +5156,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5508,8 +5176,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5529,8 +5197,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -5578,40 +5246,48 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_multipauseresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
+    if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
+    {
+        // source rollover...
+        fprintf(iTestMsgOutputFile, "###PVMFInfoSourceFormatNotSupported...\n");
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface != NULL)
         {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_SHUTDOWN;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
+            PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+            PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+            if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+            {
+                int32 infocode;
+                PVUuid infouuid;
+                infomsgiface->GetCodeUUID(infocode, infouuid);
+                if ((infouuid == PVPlayerErrorInfoEventTypesUUID) &&
+                        (infocode == PVPlayerInfoAttemptingSourceRollOver))
+                {
+                    uint8* localBuf = aEvent.GetLocalBuffer();
+                    if (localBuf != NULL)
+                    {
+                        uint32 srcFormat = 0;
+                        oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                    }
+                }
+            }
         }
     }
 }
@@ -5698,18 +5374,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -5724,18 +5393,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -5746,11 +5408,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady(); break);
             iCmdIds.push_back(iCurrentCmdId);
@@ -5773,6 +5435,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5792,6 +5455,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 5000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5811,6 +5475,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 25000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5830,6 +5495,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 10000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5849,6 +5515,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20000;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5868,6 +5535,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -5913,16 +5581,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -6021,8 +5679,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6046,8 +5704,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6071,8 +5729,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6096,8 +5754,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6121,8 +5779,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6146,8 +5804,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6171,8 +5829,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6192,8 +5850,8 @@
             {
                 // One of queued commands failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6241,13 +5899,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_multireposition::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check reposition time here
     if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
@@ -6272,34 +5939,6 @@
             }
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_SHUTDOWN;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 
@@ -6386,18 +6025,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -6419,18 +6050,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -6448,11 +6071,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -6474,6 +6097,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 10;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_1 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6503,6 +6127,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 20;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_2 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6526,6 +6151,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 20;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_3 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6549,6 +6175,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 20;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_4 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6572,6 +6199,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 20;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_5 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6595,6 +6223,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 20;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_6 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6618,6 +6247,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.sec_value = 30;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***Set PlayBackRange_7 - TargetNPT=%d secs\n", start.iPosValue.sec_value);
@@ -6674,17 +6304,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            fprintf(iTestMsgOutputFile, "***Waiting for Error Handling...\n");
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Cleanup And Complete...\n");
@@ -6781,8 +6400,8 @@
             {
                 // QueryInterface() failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6797,8 +6416,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6813,8 +6432,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6829,8 +6448,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6845,8 +6464,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6861,8 +6480,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6877,8 +6496,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6893,8 +6512,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6909,8 +6528,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6925,8 +6544,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6941,8 +6560,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6957,8 +6576,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6973,8 +6592,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -6989,8 +6608,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7005,8 +6624,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7021,8 +6640,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7037,8 +6656,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7053,8 +6672,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7069,8 +6688,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7085,8 +6704,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7151,41 +6770,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_repositionconfig::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -7262,18 +6860,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -7295,18 +6885,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -7324,11 +6906,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -7366,6 +6948,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***SetPlayBackRange_1 - TargetNPT=%d\n",
@@ -7398,6 +6981,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = true;
             fprintf(iTestMsgOutputFile, "***SetPlayBackRange_2 - TargetNPT=%d\n",
@@ -7473,17 +7057,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            fprintf(iTestMsgOutputFile, "***ErrorHandlingTimeOutExpired...\n");
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***CleanUpAndComplete...\n");
@@ -7578,8 +7151,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7594,8 +7167,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7610,8 +7183,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7626,8 +7199,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7642,8 +7215,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7658,8 +7231,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7674,8 +7247,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7698,8 +7271,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -7715,8 +7288,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7739,8 +7312,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -7756,8 +7329,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7772,8 +7345,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7788,8 +7361,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7804,8 +7377,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7820,8 +7393,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7836,8 +7409,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -7908,13 +7481,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_eoslooping::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -7955,34 +7537,6 @@
             }
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
     // Check and print out playback position status
     else if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
@@ -8105,18 +7659,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8137,18 +7683,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8165,11 +7703,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8188,6 +7726,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -8244,16 +7783,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -8346,8 +7875,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8361,8 +7890,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8376,8 +7905,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8391,8 +7920,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8406,8 +7935,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8421,8 +7950,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8444,8 +7973,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -8460,8 +7989,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8475,8 +8004,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8490,8 +8019,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8505,8 +8034,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8520,8 +8049,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8535,8 +8064,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8606,40 +8135,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_repositionduringprepared::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -8713,18 +8222,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8745,18 +8246,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8773,11 +8266,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -8803,6 +8296,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 20;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -8873,16 +8367,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -8975,8 +8459,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -8990,8 +8474,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9005,8 +8489,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9020,8 +8504,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9035,8 +8519,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9050,8 +8534,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9065,8 +8549,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9088,8 +8572,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -9104,8 +8588,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9119,8 +8603,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9134,8 +8618,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9149,8 +8633,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9164,8 +8648,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9179,8 +8663,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9194,8 +8678,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9209,8 +8693,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9280,40 +8764,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_playsetplaybackrangestopplay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -9387,18 +8851,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -9419,18 +8875,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -9447,11 +8895,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -9484,6 +8932,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_SEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 30;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -9561,16 +9010,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -9663,8 +9102,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9678,8 +9117,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9693,8 +9132,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9708,8 +9147,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9723,8 +9162,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9738,8 +9177,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9753,8 +9192,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9768,8 +9207,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9791,8 +9230,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -9807,8 +9246,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9836,8 +9275,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9851,8 +9290,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9866,8 +9305,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9881,8 +9320,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9896,8 +9335,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9911,8 +9350,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -9982,40 +9421,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_playstopsetplaybackrangeplaystop::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -10057,11 +9476,75 @@
 
         case STATE_ADDDATASOURCE:
         {
+            PVMFFormatType fileType;
             iDataSource = new PVPlayerDataSourceURL;
-            oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTmpWCharBuffer, 512);
-            iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
-            iDataSource->SetDataSourceURL(iFileNameWStr);
-            iDataSource->SetDataSourceFormatType(iFileType);
+            OSCL_HeapString<OsclMemAllocator> filename;
+
+            if (oscl_strstr(iFileName, "test.mp4") != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += _STRLIT_CHAR("test_reposition.mp4");
+                fileType = PVMF_MIME_MPEG4FF;
+                iFileType = PVMF_MIME_MPEG4FF;
+            }
+            else
+            {
+                filename = iFileName;
+                fileType = iFileType;
+            }
+            fprintf(iTestMsgOutputFile, "***Source URL=%s\n", filename.get_str());
+            oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
+            wFileName.set(output, oscl_strlen(output));
+
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
+            {
+                fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                iSourceContextData = new PVMFSourceContextData();
+                iSourceContextData->EnableCommonSourceContext();
+                iSourceContextData->EnableStreamingSourceContext();
+
+                PVInterface* sourceContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+                if (iSourceContextData->queryInterface(streamingContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataStreaming* streamingContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
+                    streamingContext->iStreamStatsLoggingURL = wFileName;
+
+                    if (iProxyEnabled)
+                    {
+                        streamingContext->iProxyName = _STRLIT_WCHAR("63.215.241.33");
+                        streamingContext->iProxyPort = 7070;
+                    }
+
+                    streamingContext->iUserID = _STRLIT_CHAR("abc");
+                    streamingContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                }
+                iSourceContextData->EnableDownloadHTTPSourceContext();
+                sourceContext = NULL;
+                PVUuid downloadContextUuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+                if (iSourceContextData->queryInterface(downloadContextUuid, sourceContext))
+                {
+                    PVMFSourceContextDataDownloadHTTP* downloadContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, sourceContext);
+                    if (iProxyEnabled)
+                    {
+                        downloadContext->iProxyName = _STRLIT_CHAR("63.215.241.33");
+                        downloadContext->iProxyPort = 7070;
+                    }
+                    downloadContext->iDownloadFileName += _STRLIT_WCHAR("test_ftdownload.loc");
+                    downloadContext->iConfigFileName += _STRLIT_WCHAR("mydlconfig");
+                    downloadContext->iUserID = _STRLIT_CHAR("abc");
+                    downloadContext->iUserPasswd = _STRLIT_CHAR("xyz");
+                    downloadContext->bIsNewSession = true;
+                    downloadContext->iMaxFileSize = 0x7FFFFFFF;
+                    downloadContext->iPlaybackControl = PVMFSourceContextDataDownloadHTTP::EAsap;
+                }
+                iDataSource->SetDataSourceContextData((OsclAny*)iSourceContextData);
+            }
+            iDataSource->SetDataSourceURL(wFileName);
+            iDataSource->SetDataSourceFormatType(fileType);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -10089,18 +9572,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10121,18 +9596,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10149,11 +9616,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10183,6 +9650,7 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = iStartPosition;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -10249,21 +9717,14 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
             iPlayer = NULL;
 
+            delete iSourceContextData;
+            iSourceContextData = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -10351,8 +9812,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10366,8 +9827,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10381,8 +9842,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10396,8 +9857,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10411,8 +9872,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10430,7 +9891,7 @@
                     for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
                     {
                         // Search for the duration
-                        char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
+                        const char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
                         if (substr != NULL)
                         {
                             uint32 timescale = 1000;
@@ -10454,8 +9915,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10469,8 +9930,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10492,8 +9953,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -10508,8 +9969,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10523,8 +9984,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10538,8 +9999,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10553,8 +10014,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10568,8 +10029,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10583,8 +10044,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -10654,13 +10115,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_setplaybackrangenearendplay::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for end of clip event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -10684,32 +10154,32 @@
             }
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    else if (aEvent.GetEventType() == PVMFInfoSourceFormatNotSupported)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
+        // source rollover...
+        fprintf(iTestMsgOutputFile, "###PVMFInfoSourceFormatNotSupported...\n");
+        PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
+        if (iface != NULL)
         {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
+            PVUuid infomsguuid = PVMFErrorInfoMessageInterfaceUUID;
+            PVMFErrorInfoMessageInterface* infomsgiface = NULL;
+            if (iface->queryInterface(infomsguuid, (PVInterface*&)infomsgiface) == true)
+            {
+                int32 infocode;
+                PVUuid infouuid;
+                infomsgiface->GetCodeUUID(infocode, infouuid);
+                if ((infouuid == PVPlayerErrorInfoEventTypesUUID) &&
+                        (infocode == PVPlayerInfoAttemptingSourceRollOver))
+                {
+                    uint8* localBuf = aEvent.GetLocalBuffer();
+                    if (localBuf != NULL)
+                    {
+                        uint32 srcFormat = 0;
+                        oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
+                        fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                    }
+                }
+            }
         }
     }
 }
@@ -10784,18 +10254,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10816,18 +10278,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10844,11 +10298,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -10884,10 +10338,12 @@
             PVPPlaybackPosition start, end;
             start.iIndeterminate = false;
             start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+            start.iMode = PVPPBPOS_MODE_NOW;
             start.iPosValue.millisec_value = 0;
             end.iIndeterminate = true;
             OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+            iSetPlayBackRangeIssued = true;
         }
         break;
 
@@ -10934,16 +10390,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -11036,8 +10482,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11052,8 +10498,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11068,8 +10514,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11083,8 +10529,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11098,8 +10544,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11116,7 +10562,7 @@
                     for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
                     {
                         // Search for the duration
-                        char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
+                        const char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
                         if (substr != NULL)
                         {
                             uint32 timescale = 1000;
@@ -11140,8 +10586,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11155,8 +10601,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11171,8 +10617,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11194,8 +10640,8 @@
                 }
                 else
                 {
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -11210,8 +10656,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11225,8 +10671,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11240,8 +10686,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11255,8 +10701,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11270,8 +10716,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11341,13 +10787,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_playrepositionnearendofclip::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for end of clip event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -11366,41 +10821,25 @@
             if ((infouuid == PVPlayerErrorInfoEventTypesUUID) && (infocode == PVPlayerInfoEndOfClipReached))
             {
                 // Should not receive EOS event since repositioning before the end
-                PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_STOP;
-                Cancel();
-                RunIfNotReady();
+                if ((iState == STATE_SETPLAYBACKRANGE) && (iSetPlayBackRangeIssued == false))
+                {
+                    fprintf(file, "EOS received before we could do SET_PLAYBACKRANGE\n");
+                    RunIfNotReady();
+                }
+                else if ((iState == STATE_SETPLAYBACKRANGE) && (iSetPlayBackRangeIssued == true))
+                {
+                    PVPATB_TEST_IS_TRUE(false);
+                    iState = STATE_STOP;
+                    Cancel();
+                    RunIfNotReady();
+                }
+                else if (iState == STATE_STOP)
+                {
+                    RunIfNotReady();
+                }
             }
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 
@@ -11481,18 +10920,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -11528,20 +10959,12 @@
             }
             else
             {//create passive MIO
-                iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+                iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             }
 
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -11561,11 +10984,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -11626,15 +11049,15 @@
         {
             //step frame-by-frame for 25 frames, waiting 1/2 second between
             //each frame.
-            int64 count;
-            iSteppingTimebase.GetCount(count);
-            if (Oscl_Int64_Utils::get_int64_lower32(count) == 25)
+            iCount = 0;
+            iSteppingTimebase.GetCount(iCount);
+            if (iCount == 25)
             {
                 iState = STATE_STOPSTEPPING;
                 RunIfNotReady();
             }
             //on 10th step, reposition.
-            else if (!iReposComplete && Oscl_Int64_Utils::get_int64_lower32(count) == 10)
+            else if (!iReposComplete && Oscl_Int64_Utils::get_int64_lower32(iCount) == 10)
             {
                 iReposComplete = true;//to avoid multiple repos...
 #if(DO_FPRINTF)
@@ -11643,6 +11066,7 @@
                 PVPPlaybackPosition start, end;
                 start.iIndeterminate = false;
                 start.iPosUnit = PVPPBPOSUNIT_SEC;
+                start.iMode = PVPPBPOS_MODE_NOW;
                 start.iPosValue.sec_value = 20;
                 end.iIndeterminate = true;
                 OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
@@ -11650,10 +11074,10 @@
             }
             else
             {
-                OSCL_TRY(error, iSteppingTimebase.SetCount(++count););
+                OSCL_TRY(error, iSteppingTimebase.SetCount(++iCount););
                 OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
 #if(DO_FPRINTF)
-                fprintf(file, "Step - %d\n", Oscl_Int64_Utils::get_int64_lower32(count));
+                fprintf(file, "Step - %d\n", Oscl_Int64_Utils::get_int64_lower32(iCount));
 #endif
                 RunIfNotReady(500*1000);
             }
@@ -11690,9 +11114,9 @@
         case STATE_STOP:
         {
             //check the count to make sure we actually did the stepping mode.
-            int64 count;
+            int32 count;
             iSteppingTimebase.GetCount(count);
-            PVPATB_TEST_IS_TRUE(Oscl_Int64_Utils::get_int64_lower32(count) == 25);
+            PVPATB_TEST_IS_TRUE((count == 25) || iEOSReached);
             OSCL_TRY(error, iCurrentCmdId = iPlayer->Stop((OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
@@ -11733,16 +11157,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -11835,8 +11249,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11850,8 +11264,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11865,8 +11279,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11880,8 +11294,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11895,8 +11309,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11910,8 +11324,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11926,8 +11340,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11941,8 +11355,8 @@
             {
                 // pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11956,8 +11370,8 @@
             {
                 // set playback rate failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11971,8 +11385,8 @@
             {
                 // start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -11988,8 +11402,8 @@
             {
                 //set playback range failed.
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12003,8 +11417,8 @@
             {
                 // pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12018,8 +11432,8 @@
             {
                 // set playback rate failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12034,8 +11448,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12049,8 +11463,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12064,8 +11478,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12079,8 +11493,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12094,8 +11508,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12109,8 +11523,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12174,74 +11588,56 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_forwardstep::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
-    else
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
     {
-        switch (aEvent.GetEventType())
-        {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 
-            case PVMFInfoEndOfData:
-                //if we get end-of-data at any point, then stop playback.
-                iState = STATE_STOP;
-                RunIfNotReady();
-                break;
+    switch (aEvent.GetEventType())
+    {
 
-            case PVMFInfoPositionStatus:
+        case PVMFInfoEndOfData:
+            //if we get end-of-data at any point, then stop playback.
+            if (iCount < 25)
             {
-                uint8* pos = (uint8*)aEvent.GetLocalBuffer();
-                //look for 1 in first byte as a clue that this message has the position status
-                //in the local buffer.
-                if ((*pos) == 1)
-                {
-                    pos += 4;
-                    uint32* vpos = (uint32*)pos;
-                    if ((int32)*vpos < 0)
-                        PVPATB_TEST_IS_TRUE(false);
-#if(DO_FPRINTF)
-                    fprintf(file, "Position Status %d\n", *vpos);
-#endif
-                }
+                iEOSReached = true;
+                fprintf(file, "EOS reached on Step - %d only, So can't Step to till 25\n", Oscl_Int64_Utils::get_int64_lower32(iCount));
             }
+            iState = STATE_STOP;
+            RunIfNotReady();
             break;
 
-            default:
-                break;//ignore
+        case PVMFInfoPositionStatus:
+        {
+            uint8* pos = (uint8*)aEvent.GetLocalBuffer();
+            //look for 1 in first byte as a clue that this message has the position status
+            //in the local buffer.
+            if ((*pos) == 1)
+            {
+                pos += 4;
+                uint32* vpos = (uint32*)pos;
+                if ((int32)*vpos < 0)
+                    PVPATB_TEST_IS_TRUE(false);
+#if(DO_FPRINTF)
+                fprintf(file, "Position Status %d\n", *vpos);
+#endif
+            }
         }
+        break;
+
+        default:
+            break;//ignore
     }
 }
 
@@ -12317,18 +11713,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -12349,18 +11737,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -12377,11 +11757,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -12423,10 +11803,10 @@
         {
             //step frame-by-frame, waiting 1/2 second between
             //each frame.
-            int64 count;
+            int32 count;
             iSteppingTimebase.GetCount(count);
 #if(DO_FPRINTF)
-            fprintf(file, "Step - %d\n", Oscl_Int64_Utils::get_int64_lower32(count));
+            fprintf(file, "Step - %d\n", count);
 #endif
             OSCL_TRY(error, iSteppingTimebase.SetCount(++count););
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -12437,9 +11817,9 @@
         case STATE_STOP:
         {
             //check the count to make sure we actually did the stepping mode.
-            int64 count;
+            int32 count;
             iSteppingTimebase.GetCount(count);
-            PVPATB_TEST_IS_TRUE(Oscl_Int64_Utils::get_int64_lower32(count) > 0);
+            PVPATB_TEST_IS_TRUE(count > 0);
 #if(DO_FPRINTF)
             fprintf(file, "Finished %d steps\n", (int32)count);
 #endif
@@ -12483,16 +11863,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -12585,8 +11955,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12600,8 +11970,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12615,8 +11985,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12630,8 +12000,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12645,8 +12015,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12660,8 +12030,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12691,8 +12061,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12710,8 +12080,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12725,8 +12095,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12740,8 +12110,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12755,8 +12125,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12770,8 +12140,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -12835,74 +12205,51 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_forwardsteptoeos::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
-    else
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
     {
-        switch (aEvent.GetEventType())
-        {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 
-            case PVMFInfoEndOfData:
-                //if we get end-of-data at any point, then stop playback.
-                iState = STATE_STOP;
-                RunIfNotReady();
-                break;
+    switch (aEvent.GetEventType())
+    {
 
-            case PVMFInfoPositionStatus:
-            {
-                uint8* pos = (uint8*)aEvent.GetLocalBuffer();
-                //look for 1 in first byte as a clue that this message has the position status
-                //in the local buffer.
-                if ((*pos) == 1)
-                {
-                    pos += 4;
-                    uint32* vpos = (uint32*)pos;
-                    if ((int32)*vpos < 0)
-                        PVPATB_TEST_IS_TRUE(false);
-#if(DO_FPRINTF)
-                    //fprintf(file,"Position Status %d\n",*vpos);
-#endif
-                }
-            }
+        case PVMFInfoEndOfData:
+            //if we get end-of-data at any point, then stop playback.
+            iState = STATE_STOP;
+            RunIfNotReady();
             break;
 
-            default:
-                break;//ignore
+        case PVMFInfoPositionStatus:
+        {
+            uint8* pos = (uint8*)aEvent.GetLocalBuffer();
+            //look for 1 in first byte as a clue that this message has the position status
+            //in the local buffer.
+            if ((*pos) == 1)
+            {
+                pos += 4;
+                uint32* vpos = (uint32*)pos;
+                if ((int32)*vpos < 0)
+                    PVPATB_TEST_IS_TRUE(false);
+#if(DO_FPRINTF)
+                //fprintf(file,"Position Status %d\n",*vpos);
+#endif
+            }
         }
+        break;
+
+        default:
+            break;//ignore
     }
 }
 
@@ -12944,7 +12291,7 @@
         case STATE_ADDDATASOURCE:
         {
             iDataSource = new PVPlayerDataSourceURL;
-            if (iFileType == PVMF_ASFFF)
+            if (iFileType == PVMF_MIME_ASFFF)
             {
                 oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTmpWCharBuffer, 512);
                 iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
@@ -12954,7 +12301,7 @@
                 // If not ASF file, use the sample ASF file.
                 iFileNameWStr = SOURCENAME_PREPEND_WSTRING;
                 iFileNameWStr += _STRLIT_WCHAR("test.asf");
-                iFileType = PVMF_ASFFF;
+                iFileType = PVMF_MIME_ASFFF;
             }
 
             iDataSource->SetDataSourceURL(iFileNameWStr);
@@ -12987,18 +12334,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13019,18 +12358,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13047,11 +12378,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13125,11 +12456,11 @@
         {
             //step frame-by-frame, waiting 1/2 second between
             //each frame.
-            int64 count;
+            int32 count;
             iSteppingTimebase.GetCount(count);
-            iSteppingTimebase.SetCount(Oscl_Int64_Utils::get_int64_lower32(count) + 1);
+            iSteppingTimebase.SetCount(count + 1);
 #if(DO_FPRINTF)
-            fprintf(file, "Step - %d\n", Oscl_Int64_Utils::get_int64_lower32(count));
+            fprintf(file, "Step - %d\n", count);
 #endif
             RunIfNotReady(500*1000);
         }
@@ -13177,16 +12508,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -13279,8 +12600,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13294,8 +12615,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13309,8 +12630,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13324,8 +12645,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13339,8 +12660,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13354,8 +12675,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13370,8 +12691,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13385,8 +12706,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13400,8 +12721,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13415,8 +12736,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13430,8 +12751,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13445,8 +12766,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13464,8 +12785,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13479,8 +12800,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13494,8 +12815,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13509,8 +12830,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13524,8 +12845,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -13589,77 +12910,54 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_backwardplayback::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
-    else
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
     {
-        switch (aEvent.GetEventType())
-        {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 
-            case PVMFInfoEndOfData:
-                //if we get end-of-data at any point, then stop playback.
-                iState = STATE_STOP;
-                RunIfNotReady();
-#if(DO_FPRINTF)
-                fprintf(file, "End of Data!");
-#endif
-                break;
+    switch (aEvent.GetEventType())
+    {
 
-            case PVMFInfoPositionStatus:
-            {
-                uint8* pos = (uint8*)aEvent.GetLocalBuffer();
-                //look for 1 in first byte as a clue that this message has the position status
-                //in the local buffer.
-                if ((*pos) == 1)
-                {
-                    pos += 4;
-                    uint32* vpos = (uint32*)pos;
-                    if ((int32)*vpos < 0)
-                        PVPATB_TEST_IS_TRUE(false);
+        case PVMFInfoEndOfData:
+            //if we get end-of-data at any point, then stop playback.
+            iState = STATE_STOP;
+            RunIfNotReady();
 #if(DO_FPRINTF)
-                    fprintf(file, "Position Status %d\n", *vpos);
+            fprintf(file, "End of Data!");
 #endif
-                }
-            }
             break;
 
-            default:
-                break;//ignore
+        case PVMFInfoPositionStatus:
+        {
+            uint8* pos = (uint8*)aEvent.GetLocalBuffer();
+            //look for 1 in first byte as a clue that this message has the position status
+            //in the local buffer.
+            if ((*pos) == 1)
+            {
+                pos += 4;
+                uint32* vpos = (uint32*)pos;
+                if ((int32)*vpos < 0)
+                    PVPATB_TEST_IS_TRUE(false);
+#if(DO_FPRINTF)
+                fprintf(file, "Position Status %d\n", *vpos);
+#endif
+            }
         }
+        break;
+
+        default:
+            break;//ignore
     }
 }
 
@@ -13702,7 +13000,7 @@
         case STATE_ADDDATASOURCE:
         {
             iDataSource = new PVPlayerDataSourceURL;
-            if (iFileType == PVMF_ASFFF)
+            if (iFileType == PVMF_MIME_ASFFF)
             {
                 oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTmpWCharBuffer, 512);
                 iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
@@ -13712,7 +13010,7 @@
                 // If not ASF file, use the sample ASF file.
                 iFileNameWStr = SOURCENAME_PREPEND_WSTRING;
                 iFileNameWStr += _STRLIT_WCHAR("test.asf");
-                iFileType = PVMF_ASFFF;
+                iFileType = PVMF_MIME_ASFFF;
             }
             iDataSource->SetDataSourceURL(iFileNameWStr);
             iDataSource->SetDataSourceFormatType(iFileType);
@@ -13744,18 +13042,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13776,18 +13066,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13804,11 +13086,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -13901,16 +13183,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -14003,8 +13275,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14018,8 +13290,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14033,8 +13305,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14048,8 +13320,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14063,8 +13335,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14078,8 +13350,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14094,8 +13366,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14109,8 +13381,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14124,8 +13396,8 @@
             else
             {
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14140,8 +13412,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14155,8 +13427,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14170,8 +13442,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14185,8 +13457,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14200,8 +13472,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14215,8 +13487,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14280,77 +13552,54 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_backwardforwardplayback::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
-    else
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
     {
-        switch (aEvent.GetEventType())
-        {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
 
-            case PVMFInfoEndOfData:
-                //if we get end-of-data at any point, then stop playback.
-                iState = STATE_STOP;
-                RunIfNotReady();
-#if(DO_FPRINTF)
-                fprintf(file, "End of Data!");
-#endif
-                break;
+    switch (aEvent.GetEventType())
+    {
 
-            case PVMFInfoPositionStatus:
-            {
-                uint8* pos = (uint8*)aEvent.GetLocalBuffer();
-                //look for 1 in first byte as a clue that this message has the position status
-                //in the local buffer.
-                if ((*pos) == 1)
-                {
-                    pos += 4;
-                    uint32* vpos = (uint32*)pos;
-                    if ((int32)*vpos < 0)
-                        PVPATB_TEST_IS_TRUE(false);
+        case PVMFInfoEndOfData:
+            //if we get end-of-data at any point, then stop playback.
+            iState = STATE_STOP;
+            RunIfNotReady();
 #if(DO_FPRINTF)
-                    fprintf(file, "Position Status %d\n", *vpos);
+            fprintf(file, "End of Data!");
 #endif
-                }
-            }
             break;
 
-            default:
-                break;//ignore
+        case PVMFInfoPositionStatus:
+        {
+            uint8* pos = (uint8*)aEvent.GetLocalBuffer();
+            //look for 1 in first byte as a clue that this message has the position status
+            //in the local buffer.
+            if ((*pos) == 1)
+            {
+                pos += 4;
+                uint32* vpos = (uint32*)pos;
+                if ((int32)*vpos < 0)
+                    PVPATB_TEST_IS_TRUE(false);
+#if(DO_FPRINTF)
+                fprintf(file, "Position Status %d\n", *vpos);
+#endif
+            }
         }
+        break;
+
+        default:
+            break;//ignore
     }
 }
 
@@ -14392,7 +13641,7 @@
         case STATE_ADDDATASOURCE:
         {
             iDataSource = new PVPlayerDataSourceURL;
-            if (iFileType == PVMF_ASFFF)
+            if (iFileType == PVMF_MIME_ASFFF)
             {
                 oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTmpWCharBuffer, 512);
                 iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
@@ -14402,7 +13651,7 @@
                 // If not ASF file, use the sample ASF file.
                 iFileNameWStr = SOURCENAME_PREPEND_WSTRING;
                 iFileNameWStr += _STRLIT_WCHAR("test.asf");
-                iFileType = PVMF_ASFFF;
+                iFileType = PVMF_MIME_ASFFF;
             }
             iDataSource->SetDataSourceURL(iFileNameWStr);
             iDataSource->SetDataSourceFormatType(iFileType);
@@ -14434,18 +13683,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -14466,18 +13707,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -14494,11 +13727,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -14613,16 +13846,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -14715,8 +13938,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14730,8 +13953,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14745,8 +13968,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14760,8 +13983,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14775,8 +13998,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14794,7 +14017,7 @@
                     for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
                     {
                         // Search for the duration
-                        char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
+                        const char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
                         if (substr != NULL)
                         {
                             uint32 timescale = 1000;
@@ -14818,8 +14041,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14833,8 +14056,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14848,8 +14071,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14863,8 +14086,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14893,8 +14116,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14909,8 +14132,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14924,8 +14147,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14939,8 +14162,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14954,8 +14177,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14969,8 +14192,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -14984,8 +14207,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15055,13 +14278,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_pauseneareosbackwardresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for end of clip event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -15104,34 +14336,6 @@
 #endif
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 //
@@ -15170,7 +14374,7 @@
         case STATE_ADDDATASOURCE:
         {
             iDataSource = new PVPlayerDataSourceURL;
-            if (iFileType == PVMF_ASFFF)
+            if (iFileType == PVMF_MIME_ASFFF)
             {
                 oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTmpWCharBuffer, 512);
                 iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
@@ -15180,7 +14384,7 @@
                 // If not ASF file, use the sample ASF file.
                 iFileNameWStr = SOURCENAME_PREPEND_WSTRING;
                 iFileNameWStr += _STRLIT_WCHAR("test.asf");
-                iFileType = PVMF_ASFFF;
+                iFileType = PVMF_MIME_ASFFF;
             }
             iDataSource->SetDataSourceURL(iFileNameWStr);
             iDataSource->SetDataSourceFormatType(iFileType);
@@ -15212,18 +14416,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -15244,18 +14440,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -15272,11 +14460,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -15415,16 +14603,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -15516,8 +14694,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15531,8 +14709,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15546,8 +14724,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15561,8 +14739,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15576,8 +14754,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15595,7 +14773,7 @@
                     for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
                     {
                         // Search for the duration
-                        char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
+                        const char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
                         if (substr != NULL)
                         {
                             uint32 timescale = 1000;
@@ -15619,8 +14797,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15634,8 +14812,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15649,8 +14827,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15664,8 +14842,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15700,8 +14878,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15716,8 +14894,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15731,8 +14909,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15746,8 +14924,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15761,8 +14939,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15776,8 +14954,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15791,8 +14969,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -15861,13 +15039,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_multiplepausesetplaybackrateresume::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for end of clip event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -15910,34 +15097,6 @@
 #endif
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 //
@@ -15977,7 +15136,7 @@
         case STATE_ADDDATASOURCE:
         {
             iDataSource = new PVPlayerDataSourceURL;
-            if (iFileType == PVMF_ASFFF)
+            if (iFileType == PVMF_MIME_ASFFF)
             {
                 oscl_UTF8ToUnicode(iFileName, oscl_strlen(iFileName), iTmpWCharBuffer, 512);
                 iFileNameWStr.set(iTmpWCharBuffer, oscl_strlen(iTmpWCharBuffer));
@@ -15987,7 +15146,7 @@
                 // If not ASF file, use the sample ASF file.
                 iFileNameWStr = SOURCENAME_PREPEND_WSTRING;
                 iFileNameWStr += _STRLIT_WCHAR("test.asf");
-                iFileType = PVMF_ASFFF;
+                iFileType = PVMF_MIME_ASFFF;
             }
             iDataSource->SetDataSourceURL(iFileNameWStr);
             iDataSource->SetDataSourceFormatType(iFileType);
@@ -16019,18 +15178,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -16051,18 +15202,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.wav");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -16079,11 +15222,11 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
+
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -16198,16 +15341,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -16300,8 +15433,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16315,8 +15448,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16330,8 +15463,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16345,8 +15478,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16360,8 +15493,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16379,7 +15512,7 @@
                     for (uint32 i = 0; i < iMetadataValueList.size(); ++i)
                     {
                         // Search for the duration
-                        char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
+                        const char* substr = oscl_strstr(iMetadataValueList[i].key, _STRLIT_CHAR("duration;valtype=uint32;timescale="));
                         if (substr != NULL)
                         {
                             uint32 timescale = 1000;
@@ -16403,8 +15536,8 @@
             {
                 // GetMetadataValues failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16418,8 +15551,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16433,8 +15566,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16448,8 +15581,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16478,8 +15611,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16494,8 +15627,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16514,8 +15647,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16529,8 +15662,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16544,8 +15677,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16559,8 +15692,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16574,8 +15707,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -16645,13 +15778,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_mediaionode_backwardneareosforwardnearbos::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for end of clip event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -16694,32 +15836,6 @@
 #endif
         }
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
+
+
diff --git a/engines/player/test/src/test_pv_player_engine_testset7.h b/engines/player/test/src/test_pv_player_engine_testset7.h
index a21fd63..be031da 100644
--- a/engines/player/test/src/test_pv_player_engine_testset7.h
+++ b/engines/player/test/src/test_pv_player_engine_testset7.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,6 +53,14 @@
 #include "pvmi_config_and_capability_observer.h"
 #endif
 
+#ifndef PVMF_STREAMING_DATA_SOURCE_H_INCLUDED
+#include "pvmf_streaming_data_source.h"
+#endif
+
+#ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
+#include "pvmf_source_context_data.h"
+#endif
+
 class PVPlayerDataSink;
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
@@ -138,7 +146,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -245,7 +252,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -346,7 +352,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -444,7 +449,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -541,7 +545,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -638,7 +641,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -742,7 +744,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -840,7 +841,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -903,6 +903,7 @@
                 , iMIOFileOutAudio(NULL)
                 , iMIOFileOutText(NULL)
                 , iCurrentCmdId(0)
+                , iSourceContextData(NULL)
         {
             iTestCaseName = _STRLIT_CHAR("MIONode Multiple Pause-Resume");
         }
@@ -925,7 +926,6 @@
             STATE_RESUME,
             STATE_PAUSERESUME2,
             STATE_SHUTDOWN,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -949,6 +949,7 @@
     private:
         OSCL_wHeapString<OsclMemAllocator> wFileName;
         oscl_wchar output[512];
+        PVMFSourceContextData* iSourceContextData;
 };
 
 
@@ -1018,7 +1019,6 @@
             STATE_SETPLAYBACKRANGE5,
             STATE_SETPLAYBACKRANGE6,
             STATE_SHUTDOWN,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1146,7 +1146,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1255,7 +1254,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1352,7 +1350,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1457,7 +1454,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1561,7 +1557,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1628,6 +1623,7 @@
                 , iMIOFileOutAudio(NULL)
                 , iMIOFileOutText(NULL)
                 , iCurrentCmdId(0)
+                , iSourceContextData(NULL)
         {
             iTestCaseName = _STRLIT_CHAR("MIONode SetPlaybackRange Near End-Play");
         }
@@ -1660,7 +1656,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1686,6 +1681,12 @@
         Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
         int32 iNumValues;
         uint32 iStartPosition;
+
+    private:
+        OSCL_wHeapString<OsclMemAllocator> wFileName;
+        oscl_wchar output[512];
+
+        PVMFSourceContextData* iSourceContextData;
 };
 
 
@@ -1734,6 +1735,7 @@
                 , iMIOFileOutAudio(NULL)
                 , iMIOFileOutText(NULL)
                 , iCurrentCmdId(0)
+                , iSetPlayBackRangeIssued(false)
         {
             iTestCaseName = _STRLIT_CHAR("MIONode Play-Reposition Near End Of Clip");
         }
@@ -1765,7 +1767,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1791,6 +1792,7 @@
         Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataValueList;
         int32 iNumValues;
         uint32 iClipDuration;
+        bool iSetPlayBackRangeIssued;
 };
 
 /*!
@@ -1846,6 +1848,7 @@
                 , iMIOFileOutText(NULL)
                 , iCurrentCmdId(0)
                 , iActiveAudio(aActiveAudio)
+                , iEOSReached(false)
         {
             if (iActiveAudio)
                 iTestCaseName = _STRLIT_CHAR("MIONode Forward Step Active Audio");
@@ -1886,7 +1889,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -1908,9 +1910,11 @@
         OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
         oscl_wchar iTmpWCharBuffer[512];
 
-        OsclTimebase_Count iSteppingTimebase;
+        PVMFTimebase_Count iSteppingTimebase;
         bool iReposComplete;
         bool iActiveAudio;
+        int32 iCount;
+        bool iEOSReached;
 };
 
 /*!
@@ -1987,7 +1991,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2009,7 +2012,7 @@
         OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
         oscl_wchar iTmpWCharBuffer[512];
 
-        OsclTimebase_Count iSteppingTimebase;
+        PVMFTimebase_Count iSteppingTimebase;
 
 };
 
@@ -2098,7 +2101,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2116,7 +2118,7 @@
         PvmiMIOControl* iMIOFileOutAudio;
         PvmiMIOControl* iMIOFileOutText;
         PVCommandId iCurrentCmdId;
-        OsclTimebase_Count iSteppingTimebase;
+        PVMFTimebase_Count iSteppingTimebase;
 
         OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
         oscl_wchar iTmpWCharBuffer[512];
@@ -2204,7 +2206,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2222,7 +2223,7 @@
         PvmiMIOControl* iMIOFileOutAudio;
         PvmiMIOControl* iMIOFileOutText;
         PVCommandId iCurrentCmdId;
-        OsclTimebase_Count iSteppingTimebase;
+        PVMFTimebase_Count iSteppingTimebase;
 
         OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
         oscl_wchar iTmpWCharBuffer[512];
@@ -2311,7 +2312,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2421,7 +2421,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -2535,7 +2534,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
diff --git a/engines/player/test/src/test_pv_player_engine_testset8.cpp b/engines/player/test/src/test_pv_player_engine_testset8.cpp
index e70ac55..a05bd9d 100644
--- a/engines/player/test/src/test_pv_player_engine_testset8.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,6 +67,7 @@
 #include "oscl_mem_audit.h"
 #endif
 
+
 //
 // pvplayer_async_test_printmetadata section
 //
@@ -115,9 +116,9 @@
              * In case of HTTP URLs always attempt rollover,
              * since we donot know if it is a download or a streaming url
              */
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
             }
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSource(*iDataSource, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -144,7 +145,15 @@
         {
             iMetadataValueList.clear();
             iNumValues = 0;
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, -1, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, -1, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject, !iReleaseMetadataByApp));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RELEASEMETADATAVALUES1:
+        {
+            PrintMetadataInfo();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->ReleaseMetadataValues(iMetadataValueList, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
         break;
@@ -154,18 +163,10 @@
             OSCL_wHeapString<OsclMemAllocator> videosinkfilename = OUTPUTNAME_PREPEND_WSTRING;
             videosinkfilename += _STRLIT_WCHAR("test_player_printmetadata_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videosinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videosinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -177,18 +178,10 @@
             OSCL_wHeapString<OsclMemAllocator> audiosinkfilename = OUTPUTNAME_PREPEND_WSTRING;
             audiosinkfilename += _STRLIT_WCHAR("test_player_printmetadata_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audiosinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audiosinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -200,11 +193,10 @@
             OSCL_wHeapString<OsclMemAllocator> textsinkfilename = OUTPUTNAME_PREPEND_WSTRING;
             textsinkfilename += _STRLIT_WCHAR("test_player_printmetadata_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & textsinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & textsinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -237,7 +229,15 @@
         {
             iMetadataValueList.clear();
             iNumValues = 0;
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 50, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 50, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject, !iReleaseMetadataByApp));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RELEASEMETADATAVALUES2:
+        {
+            PrintMetadataInfo();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->ReleaseMetadataValues(iMetadataValueList, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
         break;
@@ -261,7 +261,15 @@
         {
             iMetadataValueList.clear();
             iNumValues = 0;
-            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 50, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject));
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->GetMetadataValues(iMetadataKeyList, 0, 50, iNumValues, iMetadataValueList, (OsclAny*) & iContextObject, !iReleaseMetadataByApp));
+            OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
+        }
+        break;
+
+        case STATE_RELEASEMETADATAVALUES3:
+        {
+            PrintMetadataInfo();
+            OSCL_TRY(error, iCurrentCmdId = iPlayer->ReleaseMetadataValues(iMetadataValueList, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
         }
         break;
@@ -301,16 +309,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -403,8 +401,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -420,8 +418,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -435,8 +433,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -444,16 +442,38 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
             {
                 fprintf(iTestMsgOutputFile, "After Init()\n");
-                PrintMetadataInfo();
-                iState = STATE_ADDDATASINK_VIDEO;
+                if (iReleaseMetadataByApp)
+                {
+                    iState = STATE_RELEASEMETADATAVALUES1;
+                }
+                else
+                {
+                    PrintMetadataInfo();
+                    iState = STATE_ADDDATASINK_VIDEO;
+                }
                 RunIfNotReady();
             }
             else
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RELEASEMETADATAVALUES1:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_ADDDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // ReleaseMetadataValues failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -467,8 +487,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -482,8 +502,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -497,8 +517,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -512,8 +532,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -529,8 +549,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -544,8 +564,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -553,16 +573,38 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
             {
                 fprintf(iTestMsgOutputFile, "After Start()\n");
-                PrintMetadataInfo();
-                iState = STATE_STOP;
+                if (iReleaseMetadataByApp)
+                {
+                    iState = STATE_RELEASEMETADATAVALUES2;
+                }
+                else
+                {
+                    PrintMetadataInfo();
+                    iState = STATE_STOP;
+                }
                 RunIfNotReady();
             }
             else
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RELEASEMETADATAVALUES2:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_STOP;
+                RunIfNotReady();
+            }
+            else
+            {
+                // ReleaseMetadataValues failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -578,8 +620,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -593,8 +635,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -602,16 +644,38 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess || aResponse.GetCmdStatus() == PVMFErrArgument)
             {
                 fprintf(iTestMsgOutputFile, "After Stop()\n");
-                PrintMetadataInfo();
-                iState = STATE_REMOVEDATASINK_VIDEO;
+                if (iReleaseMetadataByApp)
+                {
+                    iState = STATE_RELEASEMETADATAVALUES3;
+                }
+                else
+                {
+                    PrintMetadataInfo();
+                    iState = STATE_REMOVEDATASINK_VIDEO;
+                }
                 RunIfNotReady();
             }
             else
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
+            }
+            break;
+
+        case STATE_RELEASEMETADATAVALUES3:
+            if (aResponse.GetCmdStatus() == PVMFSuccess)
+            {
+                iState = STATE_REMOVEDATASINK_VIDEO;
+                RunIfNotReady();
+            }
+            else
+            {
+                // ReleaseMetadataValues failed
+                PVPATB_TEST_IS_TRUE(false);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -625,8 +689,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -640,8 +704,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -655,8 +719,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -670,8 +734,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -735,48 +799,240 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_printmetadata::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
+/* PrintCodecSpecificInfo() prints the codec specific information for
+   the respective AUDIO TYPE stream and VIDEO TYPE stream.
+
+   Please note that the usage of numerical constants for transversing
+   the bytes should not be treated as hard coded values usage, because
+   the starting offset of each filed in codec specific info is fixed and
+   these locations are not tunable. That is why these constants are not
+   defined under #define.
+
+*/
+void pvplayer_async_test_printmetadata::PrintCodecSpecificInfo(char* aData, uint32 aIndex)
+{
+
+    if (INDEX_CODEC_SPECIFIC_INFO_AUDIO == aIndex)
+    {
+        uint16 CodecId = ((*(aData + 0))		 & 0x000000FF)
+                         + (((*(aData + 1)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	CodecId:%d \n", CodecId);
+
+        uint16 NumChannels = ((*(aData + 2))		 & 0x000000FF)
+                             + (((*(aData + 3)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	NumChannels:%d \n", NumChannels);
+
+        uint32 SamplesPerSecond = ((*(aData + 4))		  & 0x000000FF)
+                                  + (((*(aData + 5)) << 8)  & 0x0000FF00)
+                                  + (((*(aData + 6)) << 16) & 0x00FF0000)
+                                  + (((*(aData + 7)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	SamplesPerSecond:%d \n", SamplesPerSecond);
+
+        uint32 AvgNumBytesPerSecond = ((*(aData + 8))		   & 0x000000FF)
+                                      + (((*(aData + 9)) << 8)   & 0x0000FF00)
+                                      + (((*(aData + 10)) << 16) & 0x00FF0000)
+                                      + (((*(aData + 11)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	AvgNumBytesPerSecond:%d \n", AvgNumBytesPerSecond);
+
+        uint16 BlockAlignment = ((*(aData + 12))		 & 0x000000FF)
+                                + (((*(aData + 13)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	BlockAlignment:%d \n", BlockAlignment);
+
+        uint16 BitsPerSample = ((*(aData + 14))		    & 0x000000FF)
+                               + (((*(aData + 15)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	BitsPerSample:%d \n", BitsPerSample);
+
+        uint16 CodecSpecificDataSize = ((*(aData + 16))		    & 0x000000FF)
+                                       + (((*(aData + 17)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	CodecSpecificDataSize:%d \n", CodecSpecificDataSize);
+
+        fprintf(iTestMsgOutputFile, "	CodecSpecifcData: \n");
+        fprintf(iTestMsgOutputFile, "\t");
+        for (uint16 ii = 0; ii < CodecSpecificDataSize; ii++)
+        {
+            fprintf(iTestMsgOutputFile, "0x%02x ", (*(aData + 18 + ii) & 0xff));
+
+        }
+        fprintf(iTestMsgOutputFile, "\n");
+
+
+    }
+    else if (INDEX_CODEC_SPECIFIC_INFO_VIDEO == aIndex)
+    {
+        uint32 ImageWidth = ((*(aData + 0))		    & 0x000000FF)
+                            + (((*(aData + 1)) << 8)  & 0x0000FF00)
+                            + (((*(aData + 2)) << 16) & 0x00FF0000)
+                            + (((*(aData + 3)) << 24) & 0xFF000000);
+        fprintf(iTestMsgOutputFile, "	ImageWidth:%d \n", ImageWidth);
+
+        uint32 Imageheight = ((*(aData + 4))		 & 0x000000FF)
+                             + (((*(aData + 5)) << 8)  & 0x0000FF00)
+                             + (((*(aData + 6)) << 16) & 0x00FF0000)
+                             + (((*(aData + 7)) << 24) & 0xFF000000);
+        fprintf(iTestMsgOutputFile, "	Imageheight:%d \n", Imageheight);
+
+        uint8 ReservedFlags = ((*(aData + 8)) & 0x000000FF);
+        fprintf(iTestMsgOutputFile, "	ReservedFlags:%d \n", ReservedFlags);
+
+        uint16 FormatDataSize = ((*(aData + 9))		     & 0x000000FF)
+                                + (((*(aData + 10)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataSize:%d \n", FormatDataSize);
+
+        uint32 FormatDataFormatDataSize = ((*(aData + 11))		   & 0x000000FF)
+                                          + (((*(aData + 12)) << 8)  & 0x0000FF00)
+                                          + (((*(aData + 13)) << 16) & 0x00FF0000)
+                                          + (((*(aData + 14)) << 24) & 0xFF000000);
+        fprintf(iTestMsgOutputFile, "	FormatDataFormatDataSize:%d \n", FormatDataFormatDataSize);
+
+        uint32 FormatDataImageWidth = ((*(aData + 15))		   & 0x000000FF)
+                                      + (((*(aData + 16)) << 8)  & 0x0000FF00)
+                                      + (((*(aData + 17)) << 16) & 0x00FF0000)
+                                      + (((*(aData + 18)) << 24) & 0xFF000000);
+        fprintf(iTestMsgOutputFile, "	FormatDataImageWidth:%d \n", FormatDataImageWidth);
+
+        uint32 FormatDataImageHeight = ((*(aData + 19))			& 0x000000FF)
+                                       + (((*(aData + 20)) << 8)  & 0x0000FF00)
+                                       + (((*(aData + 21)) << 16) & 0x00FF0000)
+                                       + (((*(aData + 22)) << 24) & 0xFF000000);
+        fprintf(iTestMsgOutputFile, "	FormatDataImageHeight:%d \n", FormatDataImageHeight);
+
+        uint16 FormatDataReserved = ((*(aData + 23))		 & 0x000000FF)
+                                    + (((*(aData + 24)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataReserved:%d \n", FormatDataReserved);
+
+        uint16 FormatDataBitsPerPixelCount = ((*(aData + 25))		  & 0x000000FF)
+                                             + (((*(aData + 26)) << 8)  & 0x0000FF00);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataBitsPerPixelCount:%d \n", FormatDataBitsPerPixelCount);
+
+        uint32 FormatDataCompressionId = ((*(aData + 27))		  & 0x000000FF)
+                                         + (((*(aData + 28)) << 8)  & 0x0000FF00)
+                                         + (((*(aData + 29)) << 16) & 0x00FF0000)
+                                         + (((*(aData + 30)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataCompressionId:%d \n", FormatDataCompressionId);
+
+        uint32 FormatDataImageSize = ((*(aData + 31))		  & 0x000000FF)
+                                     + (((*(aData + 32)) << 8)  & 0x0000FF00)
+                                     + (((*(aData + 33)) << 16) & 0x00FF0000)
+                                     + (((*(aData + 34)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataImageSize:%d \n", FormatDataImageSize);
+
+        uint32 FormatDataHorizontalPixelsPerMeter = ((*(aData + 35))		 & 0x000000FF)
+                + (((*(aData + 36)) << 8)  & 0x0000FF00)
+                + (((*(aData + 37)) << 16) & 0x00FF0000)
+                + (((*(aData + 38)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataHorizontalPixelsPerMeter:%d \n", FormatDataHorizontalPixelsPerMeter);
+
+        uint32 FormatDataVerticalPixelsPerMeter = ((*(aData + 39))		   & 0x000000FF)
+                + (((*(aData + 40)) << 8)  & 0x0000FF00)
+                + (((*(aData + 41)) << 16) & 0x00FF0000)
+                + (((*(aData + 42)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataVerticalPixelsPerMeter:%d \n", FormatDataVerticalPixelsPerMeter);
+
+        uint32 FormatDataColorsUsedCount = ((*(aData + 43))		    & 0x000000FF)
+                                           + (((*(aData + 44)) << 8)  & 0x0000FF00)
+                                           + (((*(aData + 45)) << 16) & 0x00FF0000)
+                                           + (((*(aData + 46)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataColorsUsedCount:%d \n", FormatDataColorsUsedCount);
+
+        uint32 FormatDataImportantColorsCount = ((*(aData + 47))		 & 0x000000FF)
+                                                + (((*(aData + 48)) << 8)  & 0x0000FF00)
+                                                + (((*(aData + 49)) << 16) & 0x00FF0000)
+                                                + (((*(aData + 50)) << 24) & 0xFF000000);
+
+        fprintf(iTestMsgOutputFile, "	FormatDataImportantColorsCount:%d \n", FormatDataImportantColorsCount);
+
+        fprintf(iTestMsgOutputFile, "	CodecSpecifcData: \n");
+        fprintf(iTestMsgOutputFile, "\t");
+        for (uint16 ii = 0; ii < (FormatDataSize - SIZE_FORMATDATA_VIDEO); ii++)
+        {
+            fprintf(iTestMsgOutputFile, "0x%02x ", (*(aData + 51 + ii) & 0xff));
+
+        }
+        fprintf(iTestMsgOutputFile, "\n");
+    }
+    else
+    {
+        fprintf(iTestMsgOutputFile, "Codec Specific Info with index %d not supported\n", aIndex);
+
+    }
+
+}
+
+PVMFStatus pvplayer_async_test_printmetadata::GetIndexParamValues(const char* aString,
+        uint32& aStartIndex,
+        uint32& aEndIndex)
+{
+    /*
+     * This parses a string of the form "index=N1...N2" and extracts the integers N1 and N2.
+     * If string is of the format "index=N1" then N2=N1
+     */
+    if (NULL == aString)
+    {
+        return PVMFErrArgument;
+    }
+
+    /* Go to end of "index=" */
+    char* pN1string = (char*)aString + 6;
+    const char ch = 'd';
+    PV_atoi(pN1string, ch, (int32)oscl_strlen(pN1string), (uint32&)aStartIndex);
+    const char* pN2string = oscl_strstr(aString, _STRLIT_CHAR("..."));
+    if (NULL == pN2string)
+    {
+        aEndIndex = aStartIndex;
+    }
+    else
+    {
+        /* Go to end of "index=N1..." */
+        pN2string += 3;
+        PV_atoi(pN2string, ch, (int32)oscl_strlen(pN2string), (uint32&)aEndIndex);
+    }
+    return PVMFSuccess;
+}
 
 void pvplayer_async_test_printmetadata::PrintMetadataInfo()
 {
-    uint32 i = 0;
+    uint32 i = 0, StartIndex = 0, EndIndex = 0, nCnt = 0, jj = 0;
+    iCodecSpecificInfoAudioIndex = INDEX_CODEC_SPECIFIC_INFO_UNDEFINED;
+    iCodecSpecificInfoVideoIndex = INDEX_CODEC_SPECIFIC_INFO_UNDEFINED;
+    CodecSpecificInfo  sCSI[MAX_CODEC_SPECIFIC_INFO_SUPPORTED];
+    for (jj = 0; jj < MAX_CODEC_SPECIFIC_INFO_SUPPORTED; jj++)
+    {
+        sCSI[jj].CodecSpecificInfoIndex		= -1;
+        sCSI[jj].MetadataKeyIndex			= -1;
+        sCSI[jj].ValueIndex					= -1;
+    }
 
     fprintf(iTestMsgOutputFile, "Metadata key list (count=%d):\n", iMetadataKeyList.size());
     for (i = 0; i < iMetadataKeyList.size(); ++i)
@@ -787,14 +1043,99 @@
     fprintf(iTestMsgOutputFile, "\nMetadata value list (count=%d):\n", iMetadataValueList.size());
     for (i = 0; i < iMetadataValueList.size(); ++i)
     {
+
+        // Skip the logging of metadata if it is track-info/codec-specific-info, it will require track-info to be extracted first
+        // And as the track-info matches, the startindex is extracted and compared to
+        // iCodecSpecificInfoAudioIndex/ iCodecSpecificInfoVideoIndex to print the respective codec-specific-info.
+
+        if ((oscl_strncmp(iMetadataValueList[i].key, PVMF_ASF_PARSER_NODE_TRACKINFO_CODEC_DATA_KEY, oscl_strlen(PVMF_ASF_PARSER_NODE_TRACKINFO_CODEC_DATA_KEY)) == 0))
+        {
+            char *pIndexPtr = (char*)oscl_strstr(iMetadataValueList[i].key, "track-info/codec-specific-info;valtype=uint8*;");
+            if (NULL != pIndexPtr)
+            {
+                pIndexPtr = (char *)oscl_strstr(pIndexPtr, "index=");
+                GetIndexParamValues(pIndexPtr, StartIndex, EndIndex);
+                sCSI[nCnt].CodecSpecificInfoIndex = StartIndex;
+                sCSI[nCnt].MetadataKeyIndex = i;
+                sCSI[nCnt].ValueIndex = (i + 1);
+                nCnt++;
+
+                if ((int32)StartIndex == iCodecSpecificInfoAudioIndex)
+                {
+                    fprintf(iTestMsgOutputFile, "Value %d:\n", (i + 1));
+                    fprintf(iTestMsgOutputFile, "   Key string: %s\n", iMetadataValueList[sCSI[jj].MetadataKeyIndex].key);
+                    PrintCodecSpecificInfo(iMetadataValueList[i].value.pChar_value, INDEX_CODEC_SPECIFIC_INFO_AUDIO);
+                }
+                else if ((int32)StartIndex == iCodecSpecificInfoVideoIndex)
+                {
+                    fprintf(iTestMsgOutputFile, "Value %d:\n", (i + 1));
+                    fprintf(iTestMsgOutputFile, "   Key string: %s\n", iMetadataValueList[sCSI[jj].MetadataKeyIndex].key);
+                    PrintCodecSpecificInfo(iMetadataValueList[i].value.pChar_value, INDEX_CODEC_SPECIFIC_INFO_VIDEO);
+                }
+            }
+            continue;
+        }
+
+
         fprintf(iTestMsgOutputFile, "Value %d:\n", (i + 1));
         fprintf(iTestMsgOutputFile, "   Key string: %s\n", iMetadataValueList[i].key);
 
         switch (GetValTypeFromKeyString(iMetadataValueList[i].key))
         {
             case PVMI_KVPVALTYPE_CHARPTR:
+
+            {
                 fprintf(iTestMsgOutputFile, "   Value:%s\n", iMetadataValueList[i].value.pChar_value);
-                break;
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
+
+                // Checks whether the iMetadataValueList[i].key matches the track-info/type.
+                // If matches, then it checks for the index value, extracts the index and stores it in startindex.
+                // Then it verifies for WMA/WMV and accordingly prints the codec-specific-info.
+                // And if it does not match then it continues till it matches.
+
+                char *pIndexPtr = (char *)oscl_strstr(iMetadataValueList[i].key, "track-info/type;valtype=char*;");
+                if (NULL != pIndexPtr)
+                {
+                    pIndexPtr = (char *)oscl_strstr(iMetadataValueList[i].key, "index=");
+                    GetIndexParamValues(pIndexPtr, StartIndex, EndIndex);
+                    if ((oscl_strncmp(iMetadataValueList[i].value.pChar_value, "audio/x-ms-wma", oscl_strlen("audio/x-ms-wma")) == 0))
+                    {
+                        iCodecSpecificInfoAudioIndex = (int32)StartIndex;
+                        for (uint32 jj = 0; jj <= nCnt; jj++)
+                        {
+                            if ((uint32)sCSI[jj].CodecSpecificInfoIndex == StartIndex)
+                            {
+                                fprintf(iTestMsgOutputFile, "Value %d:\n", sCSI[jj].ValueIndex);
+                                fprintf(iTestMsgOutputFile, "   Key string: %s\n", iMetadataValueList[sCSI[jj].MetadataKeyIndex].key);
+                                fprintf(iTestMsgOutputFile, "   Value: UNKNOWN VALUE TYPE\n");
+                                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[sCSI[jj].MetadataKeyIndex].length, iMetadataValueList[sCSI[jj].MetadataKeyIndex].capacity);
+                                PrintCodecSpecificInfo(iMetadataValueList[sCSI[jj].MetadataKeyIndex].value.pChar_value, INDEX_CODEC_SPECIFIC_INFO_AUDIO);
+                                break;
+                            }
+                        }
+                    }
+
+                    else if ((oscl_strncmp(iMetadataValueList[i].value.pChar_value, "video/x-ms-wmv", oscl_strlen("video/x-ms-wmv")) == 0))
+                    {
+                        iCodecSpecificInfoVideoIndex = StartIndex;
+                        for (uint jj = 0; jj <= nCnt; jj++)
+                        {
+                            if ((uint32)sCSI[jj].CodecSpecificInfoIndex == StartIndex)
+                            {
+                                fprintf(iTestMsgOutputFile, "Value %d:\n", sCSI[jj].ValueIndex);
+                                fprintf(iTestMsgOutputFile, "   Key string: %s\n", iMetadataValueList[sCSI[jj].MetadataKeyIndex].key);
+                                fprintf(iTestMsgOutputFile, "   Value: UNKNOWN VALUE TYPE\n");
+                                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[sCSI[jj].MetadataKeyIndex].length, iMetadataValueList[sCSI[jj].MetadataKeyIndex].capacity);
+                                PrintCodecSpecificInfo(iMetadataValueList[sCSI[jj].MetadataKeyIndex].value.pChar_value, INDEX_CODEC_SPECIFIC_INFO_VIDEO);
+                                break;
+                            }
+                        }
+                    }
+
+                }
+
+            }
+            break;
 
             case PVMI_KVPVALTYPE_WCHARPTR:
             {
@@ -805,26 +1146,32 @@
                 tmpstr[64] = '\0';
                 fprintf(iTestMsgOutputFile, "   Value(in UTF-8, first 64 chars):%s\n", tmpstr);
             }
+            fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
             break;
 
             case PVMI_KVPVALTYPE_UINT32:
                 fprintf(iTestMsgOutputFile, "   Value:%d\n", iMetadataValueList[i].value.uint32_value);
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
 
             case PVMI_KVPVALTYPE_INT32:
                 fprintf(iTestMsgOutputFile, "   Value:%d\n", iMetadataValueList[i].value.int32_value);
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
 
             case PVMI_KVPVALTYPE_UINT8:
                 fprintf(iTestMsgOutputFile, "   Value:%d\n", iMetadataValueList[i].value.uint8_value);
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
 
             case PVMI_KVPVALTYPE_FLOAT:
                 fprintf(iTestMsgOutputFile, "   Value:%f\n", iMetadataValueList[i].value.float_value);
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
 
             case PVMI_KVPVALTYPE_DOUBLE:
                 fprintf(iTestMsgOutputFile, "   Value:%f\n", iMetadataValueList[i].value.double_value);
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
 
             case PVMI_KVPVALTYPE_BOOL:
@@ -836,14 +1183,16 @@
                 {
                     fprintf(iTestMsgOutputFile, "   Value:false(0)\n");
                 }
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
 
             default:
                 fprintf(iTestMsgOutputFile, "   Value: UNKNOWN VALUE TYPE\n");
+                fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
                 break;
         }
 
-        fprintf(iTestMsgOutputFile, "   Length:%d  Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity);
+
     }
 
     fprintf(iTestMsgOutputFile, "\n\n");
@@ -957,18 +1306,10 @@
             OSCL_wHeapString<OsclMemAllocator> videosinkfilename = OUTPUTNAME_PREPEND_WSTRING;
             videosinkfilename += _STRLIT_WCHAR("test_player_printmemstats_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videosinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videosinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -980,18 +1321,10 @@
             OSCL_wHeapString<OsclMemAllocator> audiosinkfilename = OUTPUTNAME_PREPEND_WSTRING;
             audiosinkfilename += _STRLIT_WCHAR("test_player_printmemstats_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audiosinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audiosinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1015,9 +1348,10 @@
         case STATE_PRINTMEMSTATS:
         {
             PVPPlaybackPosition curpos;
+            curpos.iPosValue.millisec_value = 0;
             curpos.iPosUnit = PVPPBPOSUNIT_MILLISEC;
             iPlayer->GetCurrentPositionSync(curpos);
-            fprintf(iTestMsgOutputFile, "After playing %d ms: ", curpos.iPosValue);
+            fprintf(iTestMsgOutputFile, "After playing %d ms: ", curpos.iPosValue.millisec_value);
             PrintMemStats();
 
             ++iPlayTimeCtr;
@@ -1069,16 +1403,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -1171,8 +1495,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1189,8 +1513,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1207,8 +1531,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1225,8 +1549,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1243,8 +1567,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1261,8 +1585,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1279,8 +1603,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1297,8 +1621,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1315,8 +1639,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1333,8 +1657,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1351,8 +1675,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1369,8 +1693,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1437,41 +1761,20 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_printmemstats::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Wait for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
     }
 }
 
@@ -1573,18 +1876,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_video.dat");
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & sinkfilename, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1605,18 +1900,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_audio.dat");
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & sinkfilename, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1633,11 +1920,10 @@
             sinkfilename += inputfilename;
             sinkfilename += _STRLIT_WCHAR("_text.dat");
 
-            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename);
+            iMIOFileOutText = iMioFactory->CreateTextOutput((OsclAny*) & sinkfilename, MEDIATYPE_TEXT);
             iIONodeText = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutText);
             iDataSinkText = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkNode(iIONodeText);
-            ((PVPlayerDataSinkPVMFNode*)iDataSinkText)->SetDataSinkFormatType(PVMF_3GPP_TIMEDTEXT);
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkText, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -1700,16 +1986,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             PVPATB_TEST_IS_TRUE(PVPlayerFactory::DeletePlayer(iPlayer));
@@ -1802,8 +2078,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1817,8 +2093,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1832,8 +2108,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1847,8 +2123,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1862,8 +2138,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1871,14 +2147,16 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 iState = STATE_START;
-                RunIfNotReady();
+                // The delay is added between Prepare and Start to test that player
+                // does not start the clock and send playstatus events prior to start.
+                RunIfNotReady(PVPLAYER_ASYNC_TEST_PLAYUNTILEOS_DELAY_AFTER_PREPARE);
             }
             else
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1892,8 +2170,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1907,8 +2185,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1922,8 +2200,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1937,8 +2215,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1952,8 +2230,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1967,8 +2245,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -2032,13 +2310,22 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 
 void pvplayer_async_test_playuntileos::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
+    }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     // Check for stop time reached event
     if (aEvent.GetEventType() == PVMFInfoEndOfData)
     {
@@ -2066,6 +2353,17 @@
     // Check and print out playback position status
     else if (aEvent.GetEventType() == PVMFInfoPositionStatus)
     {
+        PVPlayerState pstate;
+        iPlayer->GetPVPlayerStateSync(pstate);
+        if (pstate != PVP_STATE_STARTED)
+        {
+            fprintf(iTestMsgOutputFile, "Playback status recived in Wrong Engine State\n");
+            PVPATB_TEST_IS_TRUE(false);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
+            return;
+        }
+
         PVInterface* iface = (PVInterface*)(aEvent.GetEventExtensionInterface());
         if (iface == NULL)
         {
@@ -2113,34 +2411,6 @@
 
         fprintf(iTestMsgOutputFile, "------------------------------\n");
     }
-    else if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
-    {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
-    }
 }
 
 
diff --git a/engines/player/test/src/test_pv_player_engine_testset8.h b/engines/player/test/src/test_pv_player_engine_testset8.h
index b99032b..5e7e526 100644
--- a/engines/player/test/src/test_pv_player_engine_testset8.h
+++ b/engines/player/test/src/test_pv_player_engine_testset8.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,16 +49,40 @@
 #include "oscl_file_io.h"
 #endif
 
+#ifndef OSCL_STRING_UTILS_H_INCLUDED
+#include "oscl_string_utils.h"
+#endif
+
 #ifndef PVMI_CONFIG_AND_CAPABILITY_OBSERVER_H_INCLUDED
 #include "pvmi_config_and_capability_observer.h"
 #endif
 
+#define INDEX_CODEC_SPECIFIC_INFO_UNDEFINED -1
+#define INDEX_CODEC_SPECIFIC_INFO_AUDIO 1
+#define INDEX_CODEC_SPECIFIC_INFO_VIDEO 2
+#define MAX_CODEC_SPECIFIC_INFO_SUPPORTED 5
+#define PVPLAYER_ASYNC_TEST_PLAYUNTILEOS_DELAY_AFTER_PREPARE 5*1000*1000 // microseconds
+
+/* Specifically added for ASF file format where we need to get the codec-specific-info which
+   is defined in pvmf_asfffparser_defs.h
+   However, this file can be included but as these are common engine test cases	and some
+   other parsernode\parser library may use these test cases and in that case it will give
+   the error "asfparserdefs.h cannot be opened" as it is not in that parsernode\parserlibrary
+   code.
+*/
+
+static const char PVMF_ASF_PARSER_NODE_TRACKINFO_CODEC_DATA_KEY[] = "track-info/codec-specific-info";
+
+/* For VIDEO MEDIA TYPE Stream the fixed size of Format Data fields
+   listed in a structure is 40 Bytes.*/
+
+#define SIZE_FORMATDATA_VIDEO 40
+
 class PVPlayerDataSink;
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
 
-
 /*!
  *  A test case to query and print out metadata from specified source file using the player engine
  *  - Data Source: Specified by user of test case
@@ -72,6 +96,7 @@
  *             -# GetMetadataKeys()
  *             -# GetMetadataValues()
  *             -# Print out the metadata list
+ *			   -# ReleaseMetadataValues()
  *             -# AddDataSink() (video)
  *             -# AddDataSink() (audio)
  *             -# AddDataSink() (text)
@@ -81,10 +106,12 @@
  *             -# GetMetadataKeys()
  *             -# GetMetadataValues()
  *             -# Print out the metadata list
+ *			   -# ReleaseMetadataValues()
  *             -# Stop()
  *             -# GetMetadataKeys()
  *             -# GetMetadataValues()
  *             -# Print out the metadata list
+ *			   -# ReleaseMetadataValues()
  *             -# RemoveDataSink() (video)
  *             -# RemoveDataSink() (audio)
  *             -# RemoveDataSink() (text)
@@ -96,7 +123,7 @@
 class pvplayer_async_test_printmetadata : public pvplayer_async_test_base
 {
     public:
-        pvplayer_async_test_printmetadata(PVPlayerAsyncTestParam aTestParam):
+        pvplayer_async_test_printmetadata(PVPlayerAsyncTestParam aTestParam, bool aReleaseMetadataByApp):
                 pvplayer_async_test_base(aTestParam)
                 , iPlayer(NULL)
                 , iDataSource(NULL)
@@ -110,8 +137,16 @@
                 , iMIOFileOutAudio(NULL)
                 , iMIOFileOutText(NULL)
                 , iCurrentCmdId(0)
+                , iReleaseMetadataByApp(aReleaseMetadataByApp)
         {
-            iTestCaseName = _STRLIT_CHAR("Print Metadata");
+            if (iReleaseMetadataByApp)
+            {
+                iTestCaseName = _STRLIT_CHAR("Release Metadata");
+            }
+            else
+            {
+                iTestCaseName = _STRLIT_CHAR("Print Metadata");
+            }
         }
 
         ~pvplayer_async_test_printmetadata() {}
@@ -123,7 +158,11 @@
         void HandleErrorEvent(const PVAsyncErrorEvent& aEvent);
         void HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent);
 
+        int32 iCodecSpecificInfoAudioIndex, iCodecSpecificInfoVideoIndex;
         void PrintMetadataInfo();
+        void PrintCodecSpecificInfo(char* aData, uint32 aIndex);
+        PVMFStatus GetIndexParamValues(const char* aString, uint32& aStartIndex, uint32& aEndIndex);
+
 
         enum PVTestState
         {
@@ -132,6 +171,7 @@
             STATE_INIT,
             STATE_GETMETADATAKEYLIST1,
             STATE_GETMETADATAVALUELIST1,
+            STATE_RELEASEMETADATAVALUES1,
             STATE_ADDDATASINK_VIDEO,
             STATE_ADDDATASINK_AUDIO,
             STATE_ADDDATASINK_TEXT,
@@ -139,15 +179,16 @@
             STATE_START,
             STATE_GETMETADATAKEYLIST2,
             STATE_GETMETADATAVALUELIST2,
+            STATE_RELEASEMETADATAVALUES2,
             STATE_STOP,
             STATE_GETMETADATAKEYLIST3,
             STATE_GETMETADATAVALUELIST3,
+            STATE_RELEASEMETADATAVALUES3,
             STATE_REMOVEDATASINK_VIDEO,
             STATE_REMOVEDATASINK_AUDIO,
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -165,6 +206,7 @@
         PvmiMIOControl* iMIOFileOutAudio;
         PvmiMIOControl* iMIOFileOutText;
         PVCommandId iCurrentCmdId;
+        bool iReleaseMetadataByApp;
 
         OSCL_wHeapString<OsclMemAllocator> iFileNameWStr;
         oscl_wchar iTmpWCharBuffer[512];
@@ -256,7 +298,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -362,7 +403,6 @@
             STATE_REMOVEDATASINK_TEXT,
             STATE_RESET,
             STATE_REMOVEDATASOURCE,
-            STATE_WAIT_FOR_ERROR_HANDLING,
             STATE_CLEANUPANDCOMPLETE
         };
 
@@ -385,6 +425,16 @@
         oscl_wchar iTmpWCharBuffer[512];
 };
 
+// Structure CodecSpecificInfo stores the codecSpecificInfoIndex,
+// metadatakeyIndex and the valueIndex and then the information is printed
+// when track-info/type matches with codec-specific-info.
+struct CodecSpecificInfo
+{
+    int32 CodecSpecificInfoIndex;
+    int32 MetadataKeyIndex;
+    int32 ValueIndex;
+};
+
 #endif
 
 
diff --git a/engines/player/test/src/test_pv_player_engine_testset9.cpp b/engines/player/test/src/test_pv_player_engine_testset9.cpp
index ff7b1b4..c79da10 100644
--- a/engines/player/test/src/test_pv_player_engine_testset9.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset9.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,6 +87,96 @@
 //
 void pvplayer_async_test_genericreset::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
     int32 iDownloadProxyPort = 0;
@@ -101,6 +191,17 @@
     iContentTooLarge = false;
     bool aIsNewSession = true;
 
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+    else
+#endif
     {
         bool aUseCpmForPlayback = false;
 
@@ -168,12 +269,14 @@
 
             if (bcloaking)
             {
-                fileType = PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
             }
 
-            else if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                //We will change the iFileType if we need to do ProtocolRollover
+                //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
                 {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
@@ -191,7 +294,7 @@
 
                         if (iProxyEnabled)
                         {
-                            streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                            streamingContext->iProxyName = _STRLIT_WCHAR("");
                             streamingContext->iProxyPort = 8080;
                         }
                     }
@@ -205,7 +308,7 @@
                         int32 iDownloadProxyPort = 0;
                         if (iProxyEnabled)
                         {
-                            iDownloadProxy = _STRLIT_CHAR("172.16.2.42");
+                            iDownloadProxy = _STRLIT_CHAR("");
                             iDownloadProxyPort = 8080;
                         }
                         iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
@@ -214,7 +317,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = false;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -235,15 +337,21 @@
 
                     if (iProxyEnabled)
                     {
-                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                         iStreamDataSource->iProxyPort = 8080;
                     }
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -258,7 +366,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -268,20 +376,22 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_HTTP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_HTTP_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
 #ifdef USE_NEW_PVMF_COMMONSOURCE_CONTEXT_DATA
                     iSourceContextData->EnableDownloadHTTPSourceContext();
                     PVInterface* sourceContext = NULL;
@@ -307,7 +417,7 @@
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             iDataSource->SetDataSourceURL(wFileName);
@@ -325,6 +435,11 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
+            }
+            else
             {
                 userAgent = _STRLIT_WCHAR("NSPlayer/9.0 PVPlayerCoreEngineTestUserAgent");
             }
@@ -448,14 +563,18 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_video.dat");
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_video.dat");
+            }
             else
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_genericreset_");
@@ -465,18 +584,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -487,14 +598,18 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_audio.dat");
             }
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_audio.dat");
+            }
             else
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_genericreset_");
@@ -504,18 +619,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -590,6 +697,7 @@
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -672,16 +780,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -693,6 +791,10 @@
 
             delete iStreamDataSource;
             iStreamDataSource = NULL;
+
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -803,8 +905,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -864,8 +966,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -880,8 +982,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -889,7 +991,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -915,8 +1017,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -937,8 +1039,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -959,8 +1061,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -981,8 +1083,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1001,7 +1103,7 @@
                     {
                         if (oSeekEnable == true)
                         {
-                            if (iNumBufferingComplete || (iFileType == PVMF_ASFFF))
+                            if (iNumBufferingComplete || (iFileType == PVMF_MIME_ASFFF))
                             {
                                 if (!iSeekDone)
                                 {
@@ -1037,8 +1139,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -1061,7 +1163,7 @@
                 {
                     if (iPlayListURL == true)
                     {
-                        if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                        if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                         {
                             int32 error;
                             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -1085,8 +1187,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1109,8 +1211,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1135,8 +1237,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1157,8 +1259,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1172,8 +1274,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1187,8 +1289,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1202,8 +1304,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1269,8 +1371,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1295,8 +1397,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1447,8 +1549,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_genericreset::HandleSocketNodeErrors(int32 aErr)
@@ -1855,35 +1955,17 @@
 
 void pvplayer_async_test_genericreset::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_VIDEO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     switch (aEvent.GetEventType())
     {
         case PVMFInfoSourceFormatNotSupported:
@@ -1906,9 +1988,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -1976,7 +2058,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -2180,7 +2262,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
diff --git a/engines/player/test/src/test_pv_player_engine_testset9.h b/engines/player/test/src/test_pv_player_engine_testset9.h
index dc07501..2a7591e 100644
--- a/engines/player/test/src/test_pv_player_engine_testset9.h
+++ b/engines/player/test/src/test_pv_player_engine_testset9.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,11 @@
 #include "pvmf_streaming_data_source.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
 #include "pvmf_download_data_source.h"
@@ -46,14 +51,14 @@
 #include "pvmf_source_context_data.h"
 #endif
 
-#define AMR_MPEG4_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_RTSP_URL_2 "rtsp://test.mp4"
-#define H263_AMR_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_RTSP_URL "rtsp://test.3gp"
-#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://test.3gp"
-#define AAC_RTSP_URL     "rtsp://test.3gp"
-#define MPEG4_AAC_RTSP_URL "rtsp://test.3gp"
-#define AMR_MPEG4_SDP_FILE "test.sdp"
+#define AMR_MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-475_mpeg4-20.3gp"
+#define AMR_MPEG4_RTSP_URL_2 "rtsp://pvserveroha.pv.com/public/metadata/pvmetadata.mp4"
+#define H263_AMR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-amr-122_h263-64.3gp"
+#define MPEG4_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4rdatapartr64.3gp"
+#define MPEG4_SHRT_HDR_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-mpeg4shorthdrr64.3gp"
+#define AAC_RTSP_URL     "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv-aac64_novisual.3gp"
+#define MPEG4_AAC_RTSP_URL "rtsp://pvserveroha.pv.com/public/Interop/3GPP/pv2/pv2-aac64_mpeg4-rvlcs-64.3gp"
+#define AMR_MPEG4_SDP_FILE "pv_amr_mpeg4.sdp"
 
 class PVPlayerDataSourceURL;
 class PVPlayerDataSink;
@@ -61,6 +66,8 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
+class PVMFDownloadDataSourcePVX;
+
 
 /*!
  *  Test cases to test Reset() call (right after/while processing) each state while playing an local/PDL/rtsp url
@@ -122,6 +129,7 @@
                 , iPlayListURL(false)
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
+                , iDownloadContextDataPVX(NULL)
                 , iPlayStarted(false)
                 , iSeekDone(false)
         {
@@ -231,8 +239,13 @@
         char iClipType[100];
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
diff --git a/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.cpp b/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.cpp
index 5fd22d5..df62fbb 100644
--- a/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -108,9 +108,98 @@
 //
 void pvplayer_async_test_cpmdlapassthru::CreateDownloadDataSource()
 {
+#if RUN_FASTTRACK_TESTCASES
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        //fasttrack download using PVX.
+        //read the pvx file into a memory fragment.
+        OsclMemoryFragment pvxmemfrag;
+        {
+            Oscl_FileServer fs;
+            fs.Connect();
+            Oscl_File file;
+            OSCL_StackString<64> filename;
+
+            if (oscl_strstr(iFileName, DEFAULTSOURCEFILENAME) != NULL)
+            {
+                filename = SOURCENAME_PREPEND_STRING;
+                filename += DEFAULT_FASTTRACK_DL_FILE;
+            }
+            else
+            {
+                filename = iFileName;
+            }
+
+            if (file.Open(filename.get_str(), Oscl_File::MODE_READ | Oscl_File::MODE_TEXT, fs))
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+
+            int32 size = file.Read(iPVXFileBuf, 1, 4096);
+            pvxmemfrag.len = size;
+            pvxmemfrag.ptr = iPVXFileBuf;
+            file.Close();
+            fs.Close();
+        }
+
+        //Parse, extracting iDownloadPvxInfo and url8.
+        OSCL_HeapString<OsclMemAllocator> url8;
+        {
+            CPVXParser* parser = NULL;
+            parser = new CPVXParser;
+            if (parser == NULL)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            CPVXParser::CPVXParserStatus status = parser->ParsePVX(pvxmemfrag, url8, iDownloadPvxInfo);
+            delete parser;
+            if (status != CPVXParser::CPVXParser_Success)
+            {
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            //set the playback mode in the test case base class to match
+            //the PVX setting.
+            switch (iDownloadPvxInfo.iPlaybackControl)
+            {
+                case CPVXInfo::ENoPlayback:
+                    iDownloadOnly = true;
+                    break;
+                case CPVXInfo::EAfterDownload:
+                    iDownloadThenPlay = true;
+                    break;
+                case CPVXInfo::EAsap:
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        //convert the url8 to unicode iDownloadURL
+        {
+            oscl_wchar* wtemp = new oscl_wchar[url8.get_size()+1];
+            if (wtemp == NULL)
+            {
+                // Memory allocation failure
+                PVPATB_TEST_IS_TRUE(false);
+                iObserver->TestCompleted(*iTestCase);
+                return;
+            }
+            int32 wtemplen = oscl_UTF8ToUnicode(url8.get_cstr(), url8.get_size(), wtemp, url8.get_size() + 1);
+            //iDownloadURL.set(wtemp, wtemplen);
+            wFileName.set(wtemp, wtemplen);
+            delete [] wtemp;
+        }
+    }
+#endif
+
     //create the opaque data
     iDownloadProxy = _STRLIT_CHAR("");
-    int32 iDownloadProxyPort = 0;
 
     iDownloadConfigFilename = OUTPUTNAME_PREPEND_WSTRING;
     iDownloadConfigFilename += _STRLIT_WCHAR("mydlconfig");
@@ -120,7 +209,20 @@
     iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
     iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
     iContentTooLarge = false;
+
+#if RUN_FASTTRACK_TESTCASES
+    int32 iDownloadProxyPort = 0;
     bool aIsNewSession = true;
+
+    if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        iDownloadContextDataPVX = new PVMFDownloadDataSourcePVX(aIsNewSession, iDownloadConfigFilename, iDownloadFilename, \
+                iDownloadMaxfilesize,
+                iDownloadProxy,
+                iDownloadProxyPort,
+                iDownloadPvxInfo);
+    }
+#endif
 }
 
 void pvplayer_async_test_cpmdlapassthru::StartTest()
@@ -176,9 +278,9 @@
             oscl_UTF8ToUnicode(filename.get_str(), filename.get_size(), output, 256);
             wFileName.set(output, oscl_strlen(output));
 
-            if (iFileType == PVMF_DATA_SOURCE_HTTP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL)
             {
-                fileType = PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
                 //We will change the iFileType if we need to do ProtocolRollover
                 //iFileType = fileType;
                 if (iProtocolRollOverWithUnknownURLType == false)
@@ -205,7 +307,7 @@
                             OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContextStream);
                         streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0
-                        streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                        streamingContext->iProxyName = _STRLIT_WCHAR("");
                         streamingContext->iProxyPort = 8080;
 #endif
                     }
@@ -224,7 +326,6 @@
                         iDownloadFilename = OUTPUTNAME_PREPEND_WSTRING;
                         iDownloadFilename += _STRLIT_WCHAR("test_ftdownload.dl");
                         bool aIsNewSession = true;
-                        bool aUseCpmForDownload = false;
                         bool iUseCpmForPlayback = true;
 
                         iSourceContextData->DownloadHTTPData()->bIsNewSession = aIsNewSession;
@@ -243,15 +344,21 @@
                     iStreamDataSource = new PVMFStreamingDataSource();
                     iStreamDataSource->iStreamStatsLoggingURL = wFileName;
 #if 0
-                    iStreamDataSource->iProxyName = _STRLIT_WCHAR("172.16.2.42");
+                    iStreamDataSource->iProxyName = _STRLIT_WCHAR("");
                     iStreamDataSource->iProxyPort = 8080;
 #endif
                     iDataSource->SetDataSourceContextData((OsclAny*)iStreamDataSource);
 #endif
                 }
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_RTSP_URL)
-                     || (iFileType == PVMF_DATA_SOURCE_SDP_FILE))
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+            {
+                CreateDownloadDataSource();
+                fileType = PVMF_MIME_DATA_SOURCE_PVX_FILE;
+                iDataSource->SetDataSourceContextData((OsclAny*)iDownloadContextDataPVX);
+            }
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+                     || (iFileType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
             {
 #ifdef USE_NEW_PVMF_SOURCE_CONTEXT_DATA
                 iSourceContextData = new PVMFSourceContextData();
@@ -265,7 +372,7 @@
                         OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, sourceContext);
                     streamingContext->iStreamStatsLoggingURL = wFileName;
 #if 0	//RTSP_PROXY_TEST	
-                    streamingContext->iProxyName = _STRLIT_WCHAR("172.16.2.31");
+                    streamingContext->iProxyName = _STRLIT_WCHAR("");
                     streamingContext->iProxyPort = 80;
 #endif
                 }
@@ -282,25 +389,27 @@
 
             if (iProtocolRollOver)
             {
-                if (fileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+                if (fileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL);
                 }
-                else if (fileType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_RTSP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_RTSP_URL;
+#if RUN_RTSP_CLOAKING_TESTCASES
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL);
+#endif
                 }
-                else if (fileType == PVMF_DATA_SOURCE_RTSP_URL)
+                else if (fileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
                 {
-                    fileType = PVMF_DATA_SOURCE_HTTP_URL;
-                    iDataSource->SetAlternateSourceFormatType(PVMF_DATA_SOURCE_RTSP_URL);
+                    fileType = PVMF_MIME_DATA_SOURCE_HTTP_URL;
+                    iDataSource->SetAlternateSourceFormatType(PVMF_MIME_DATA_SOURCE_RTSP_URL);
                 }
             }
             else if (iProtocolRollOverWithUnknownURLType)
             {
-                fileType = PVMF_DATA_SOURCE_UNKNOWN_URL;
+                fileType = PVMF_MIME_DATA_SOURCE_UNKNOWN_URL;
             }
 
             //This illustrates the use of CPM with a file source.
@@ -402,7 +511,7 @@
             iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/user-agent;valtype=wchar*");
             iKVPSetAsync.key = iKeyStringSetAsync.get_str();
             OSCL_wHeapString<OsclMemAllocator> userAgent;
-            if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 userAgent = _STRLIT_WCHAR("PVPLAYER 18.07.00.02");
             }
@@ -571,15 +680,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Video Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> videoSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_cpmdlapassthru_video.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_httpurl_cpmdlapassthru_video.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 videoSinkFileName += _STRLIT_WCHAR("test_player_pvx_cpmdlapassthru_video.dat");
             }
@@ -592,18 +701,10 @@
                 videoSinkFileName += _STRLIT_WCHAR("_video.dat");
             }
 
-            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName);
+            iMIOFileOutVideo = iMioFactory->CreateVideoOutput((OsclAny*) & videoSinkFileName, MEDIATYPE_VIDEO, iCompressedVideo);
             iIONodeVideo = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutVideo);
             iDataSinkVideo = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkNode(iIONodeVideo);
-            if (iCompressedVideo)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_M4V);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkVideo)->SetDataSinkFormatType(PVMF_YUV420);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkVideo, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -614,15 +715,15 @@
         {
             fprintf(iTestMsgOutputFile, "***Adding Audio Data Sink...\n");
             OSCL_wHeapString<OsclMemAllocator> audioSinkFileName = OUTPUTNAME_PREPEND_WSTRING;
-            if (iFileType == PVMF_DATA_SOURCE_RTSP_URL)
+            if (iFileType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_rtspurl_cpmdlapassthru_audio.dat");
             }
-            else if ((iFileType == PVMF_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL))
+            else if ((iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL) || (iFileType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL))
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_httpurl_cpmdlapassthru_audio.dat");
             }
-            else if (iFileType == PVMF_DATA_SOURCE_PVX_FILE)
+            else if (iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
             {
                 audioSinkFileName += _STRLIT_WCHAR("test_player_pvx_cpmdlapassthru_audio.dat");
             }
@@ -635,18 +736,10 @@
                 audioSinkFileName += _STRLIT_WCHAR("_audio.dat");
             }
 
-            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName);
+            iMIOFileOutAudio = iMioFactory->CreateAudioOutput((OsclAny*) & audioSinkFileName, MEDIATYPE_AUDIO, iCompressedAudio);
             iIONodeAudio = PVMediaOutputNodeFactory::CreateMediaOutputNode(iMIOFileOutAudio);
             iDataSinkAudio = new PVPlayerDataSinkPVMFNode;
             ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkNode(iIONodeAudio);
-            if (iCompressedAudio)
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(PVMF_MPEG4_AUDIO);
-            }
-            else
-            {
-                ((PVPlayerDataSinkPVMFNode*)iDataSinkAudio)->SetDataSinkFormatType(AUDIOSINK_FORMAT_TYPE);
-            }
 
             OSCL_TRY(error, iCurrentCmdId = iPlayer->AddDataSink(*iDataSinkAudio, (OsclAny*) & iContextObject));
             OSCL_FIRST_CATCH_ANY(error, PVPATB_TEST_IS_TRUE(false); iState = STATE_CLEANUPANDCOMPLETE; RunIfNotReady());
@@ -717,22 +810,11 @@
             if (oLiveSession == false)
             {
                 fprintf(iTestMsgOutputFile, "***Repositioning...\n");
-#if 0
-                if (iPlayListURL == true)
-                {
-                    PVPPlaybackPosition start, end;
-                    start.iIndeterminate = false;
-                    start.iPosUnit = PVPPBPOSUNIT_SEC;
-                    start.iPosValue.sec_value = 6;
-                    end.iIndeterminate = true;
-                    OSCL_TRY(error, iCurrentCmdId = iPlayer->SetPlaybackRange(start, end, false, (OsclAny*) & iContextObject));
-                }
-                else
-#endif
                 {
                     PVPPlaybackPosition start, end;
                     start.iIndeterminate = false;
                     start.iPosUnit = PVPPBPOSUNIT_MILLISEC;
+                    start.iMode = PVPPBPOS_MODE_NOW;
                     if (iSessionDuration)
                         start.iPosValue.millisec_value = iSessionDuration / 4;
                     else
@@ -815,16 +897,6 @@
         }
         break;
 
-        case STATE_WAIT_FOR_ERROR_HANDLING:
-        {
-            // Timed out waiting for error handling to complete
-            PVPATB_TEST_IS_TRUE(false);
-            // Forcibly terminate the test
-            iState = STATE_CLEANUPANDCOMPLETE;
-            RunIfNotReady();
-        }
-        break;
-
         case STATE_CLEANUPANDCOMPLETE:
         {
             fprintf(iTestMsgOutputFile, "***Deleting Player Engine...\n");
@@ -837,6 +909,9 @@
             delete iStreamDataSource;
             iStreamDataSource = NULL;
 
+            delete iDownloadContextDataPVX;
+            iDownloadContextDataPVX = NULL;
+
             delete iDataSource;
             iDataSource = NULL;
 
@@ -968,8 +1043,8 @@
             // AcquireLicense failed
             fprintf(iTestMsgOutputFile, "\nAcquire License...Failed!\n");
             PVPATB_TEST_IS_TRUE(false);
-            iState = STATE_WAIT_FOR_ERROR_HANDLING;
-            RunIfNotReady(5000000);
+            iState = STATE_CLEANUPANDCOMPLETE;
+            RunIfNotReady();
         }
         return;
     }
@@ -1001,8 +1076,8 @@
             {
                 // AddDataSource failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1061,8 +1136,8 @@
                 {
                     // Init failed
                     PVPATB_TEST_IS_TRUE(false);
-                    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                    RunIfNotReady(5000000);
+                    iState = STATE_CLEANUPANDCOMPLETE;
+                    RunIfNotReady();
                 }
             }
             break;
@@ -1076,8 +1151,8 @@
             {
                 // QueryInterface failed.
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1126,8 +1201,8 @@
             {
                 // Init2 failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1142,8 +1217,8 @@
             {
                 // GetMetadataKeys failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1151,7 +1226,7 @@
             if (aResponse.GetCmdStatus() == PVMFSuccess)
             {
                 PrintMetadataInfo();
-                if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+                if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
                 {
                     //wait for data ready, unless we already got it.
                     if (iNumDataReady > 0)
@@ -1177,8 +1252,8 @@
             {
                 // GetMetadataValue failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1192,8 +1267,8 @@
             {
                 // Init failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1207,8 +1282,8 @@
             {
                 // AddDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1222,8 +1297,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1263,8 +1338,8 @@
             {
                 // Start failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
         case STATE_WAIT_FOR_DATAREADY:
@@ -1279,7 +1354,7 @@
             {
                 if (iPlayListURL == true)
                 {
-                    if (iFileType != PVMF_DATA_SOURCE_HTTP_URL)
+                    if (iFileType != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                     {
                         int32 error;
                         iKeyStringSetAsync = _STRLIT_CHAR("x-pvmf/net/delay;valtype=uint32");
@@ -1302,8 +1377,8 @@
             {
                 // SetPlaybackRange failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1318,8 +1393,8 @@
             {
                 // Pause failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1336,8 +1411,8 @@
             {
                 // Resume failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1351,8 +1426,8 @@
             {
                 // Stop failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1366,8 +1441,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1381,8 +1456,8 @@
             {
                 // RemoveDataSink failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1396,8 +1471,8 @@
             {
                 // Reset failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1463,8 +1538,8 @@
             {
                 // Prepare failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1489,8 +1564,8 @@
             {
                 // Cancel failed
                 PVPATB_TEST_IS_TRUE(false);
-                iState = STATE_WAIT_FOR_ERROR_HANDLING;
-                RunIfNotReady(5000000);
+                iState = STATE_CLEANUPANDCOMPLETE;
+                RunIfNotReady();
             }
             break;
 
@@ -1642,8 +1717,6 @@
 
     // Wait for engine to handle the error
     Cancel();
-    iState = STATE_WAIT_FOR_ERROR_HANDLING;
-    RunIfNotReady(5000000);
 }
 
 void pvplayer_async_test_cpmdlapassthru::HandleSocketNodeErrors(int32 aErr)
@@ -2050,35 +2123,17 @@
 
 void pvplayer_async_test_cpmdlapassthru::HandleInformationalEvent(const PVAsyncInformationalEvent& aEvent)
 {
-    // Waiting for error handling to complete
-    if (iState == STATE_WAIT_FOR_ERROR_HANDLING && aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingStart)
     {
-        PVPlayerState pstate;
-        iPlayer->GetPVPlayerStateSync(pstate);
-        switch (pstate)
-        {
-            case PVP_STATE_INITIALIZED:
-                Cancel();
-                iState = STATE_REMOVEDATASINK_AUDIO;
-                RunIfNotReady();
-                break;
-
-            case PVP_STATE_IDLE:
-                Cancel();
-                iState = STATE_REMOVEDATASOURCE;
-                RunIfNotReady();
-                break;
-
-            default:
-                // Engine should not be in any other state when
-                // error handling completes
-                PVPATB_TEST_IS_TRUE(false);
-                Cancel();
-                iState = STATE_CLEANUPANDCOMPLETE;
-                RunIfNotReady();
-                break;
-        }
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingStart...\n");
     }
+    if (aEvent.GetEventType() == PVMFInfoErrorHandlingComplete)
+    {
+        fprintf(iTestMsgOutputFile, "PVMFInfoErrorHandlingComplete...\n");
+        iState = STATE_CLEANUPANDCOMPLETE;
+        RunIfNotReady();
+    }
+
     switch (aEvent.GetEventType())
     {
         case PVMFInfoSourceFormatNotSupported:
@@ -2101,9 +2156,9 @@
                         uint8* localBuf = aEvent.GetLocalBuffer();
                         if (localBuf != NULL)
                         {
-                            uint32 srcFormat = 0;
+                            PVMFFormatType srcFormat = PVMF_MIME_FORMAT_UNKNOWN;
                             oscl_memcpy(&srcFormat, &localBuf[4], sizeof(uint32));
-                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%d\n", srcFormat);
+                            fprintf(iTestMsgOutputFile, "###Attempting Source RollOver - NewSrcFormat=%s\n", srcFormat.getMIMEStrPtr());
                             //The clip type needs a rollover, store the actual clip type
                             iFileType = srcFormat;
                         }
@@ -2161,7 +2216,7 @@
 
         case PVMFInfoBufferingStatus:
         {
-            if ((iFileType == PVMF_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_DATA_SOURCE_HTTP_URL))
+            if ((iFileType == PVMF_MIME_DATA_SOURCE_PVX_FILE) || (iFileType == PVMF_MIME_DATA_SOURCE_HTTP_URL))
             {
                 if (aEvent.GetLocalBuffer()[0] == 0
                         || aEvent.GetLocalBuffer()[0] == 100)
@@ -2316,7 +2371,7 @@
                 char tmpstr[65];
                 oscl_UnicodeToUTF8(iMetadataValueList[i].value.pWChar_value,
                                    oscl_strlen(iMetadataValueList[i].value.pWChar_value), tmpstr, 65);
-                tmpstr[64] = NULL;
+                tmpstr[64] = '\0';
                 fprintf(iTestMsgOutputFile, "   Value(in UTF-8, first 64 chars):%s\n", tmpstr);
             }
             break;
@@ -2364,7 +2419,7 @@
             iSessionDuration = iMetadataValueList[i].value.uint32_value;
 
             // Check the timescale. If not available, assume millisecond (1000)
-            char *retTSstr;
+            const char *retTSstr;
             retTSstr = oscl_strstr(iMetadataValueList[i].key, "timescale=");
             uint32 retTSstrLen = 0;
             uint32 tsstrlen = oscl_strlen(_STRLIT_CHAR("timescale="));
diff --git a/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.h b/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.h
index 2e364a0..ca3bf86 100644
--- a/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.h
+++ b/engines/player/test/src/test_pv_player_engine_testset_cpmdlapassthru.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,11 @@
 #include "pvmf_streaming_data_source.h"
 #endif
 
+#if RUN_FASTTRACK_TESTCASES
+#ifndef PVPVXPARSER_H_INCLUDED
+#include "pvpvxparser.h"
+#endif
+#endif
 
 #ifndef PVMF_DOWNLOAD_DATA_SOURCE_H_INCLUDED
 #include "pvmf_download_data_source.h"
@@ -57,6 +62,7 @@
 class PVPlayerDataSinkFilename;
 class PvmfFileOutputNodeConfigInterface;
 class PvmiCapabilityAndConfig;
+class PVMFDownloadDataSourcePVX;
 
 enum OMA1_DLA_TESTMODE
 {
@@ -127,6 +133,8 @@
                 , iStreamDataSource(NULL)
                 , iSourceContextData(NULL)
                 , iLocalDataSource(NULL)
+                , iDownloadContextDataPVX(NULL)
+
         {
             iVideoSinkFormatType = aVideoSinkFormat;
             iAudioSinkFormatType = aAudioSinkFormat;
@@ -237,8 +245,13 @@
         char iClipType[100];
         //FTDL
         void CreateDownloadDataSource();
+        uint8 iPVXFileBuf[4096];
+        PVMFDownloadDataSourcePVX* iDownloadContextDataPVX;
         PVMFDownloadDataSourceHTTP* iDownloadContextDataHTTP;
         int32 iDownloadMaxfilesize;
+#if RUN_FASTTRACK_TESTCASES
+        CPVXInfo iDownloadPvxInfo;
+#endif
         OSCL_wHeapString<OsclMemAllocator> iDownloadURL;
         OSCL_wHeapString<OsclMemAllocator> iDownloadFilename;
         OSCL_HeapString<OsclMemAllocator> iDownloadProxy;
diff --git a/engines/player/test/src/test_pv_player_engine_testset_mio_file.cpp b/engines/player/test/src/test_pv_player_engine_testset_mio_file.cpp
index 27d24f0..16e4067 100644
--- a/engines/player/test/src/test_pv_player_engine_testset_mio_file.cpp
+++ b/engines/player/test/src/test_pv_player_engine_testset_mio_file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,14 @@
 
 PvmiMIOControl* PVPlayerTestFileOutputMioFactory::CreateAudioOutput(
     OsclAny* aParam,
+    MediaType aMediaType,
+    bool aCompressedAudio)
+{
+    return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr(), aMediaType, aCompressedAudio);
+}
+
+PvmiMIOControl* PVPlayerTestFileOutputMioFactory::CreateAudioOutput(
+    OsclAny* aParam,
     PVRefFileOutputTestObserver* aObserver,
     bool aActiveTiming,
     uint32 aQueueLimit,
@@ -59,6 +67,14 @@
 
 PvmiMIOControl* PVPlayerTestFileOutputMioFactory::CreateVideoOutput(
     OsclAny* aParam,
+    MediaType aMediaType,
+    bool aCompressedVideo)
+{
+    return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr(), aMediaType, aCompressedVideo);
+}
+
+PvmiMIOControl* PVPlayerTestFileOutputMioFactory::CreateVideoOutput(
+    OsclAny* aParam,
     PVRefFileOutputTestObserver* aObserver,
     bool aActiveTiming,
     uint32 aQueueLimit,
@@ -85,6 +101,11 @@
     return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr());
 }
 
+PvmiMIOControl* PVPlayerTestFileOutputMioFactory::CreateTextOutput(OsclAny* aParam, MediaType aMediaType)
+{
+    return new PVRefFileOutput(((OSCL_wString*)aParam)->get_cstr(), aMediaType);
+}
+
 void PVPlayerTestFileOutputMioFactory::DestroyTextOutput(PvmiMIOControl* aMio)
 {
     PVRefFileOutput* mio = (PVRefFileOutput*)aMio;
diff --git a/engines/player/test/src/test_pv_player_engine_testset_mio_file.h b/engines/player/test/src/test_pv_player_engine_testset_mio_file.h
index da1402d..c14260c 100644
--- a/engines/player/test/src/test_pv_player_engine_testset_mio_file.h
+++ b/engines/player/test/src/test_pv_player_engine_testset_mio_file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,12 +32,15 @@
         ~PVPlayerTestFileOutputMioFactory() {}
 
         PvmiMIOControl* CreateAudioOutput(OsclAny* aParam);
+        PvmiMIOControl* CreateAudioOutput(OsclAny* aParam, MediaType aMediaType, bool aCompressedAudio = false);
         PvmiMIOControl* CreateAudioOutput(OsclAny* aParam, PVRefFileOutputTestObserver* aObserver, bool aActiveTiming, uint32 aQueueLimit, bool aSimFlowControl, bool logStrings = true);
         void DestroyAudioOutput(PvmiMIOControl* aMio);
         PvmiMIOControl* CreateVideoOutput(OsclAny* aParam);
+        PvmiMIOControl* CreateVideoOutput(OsclAny* aParam, MediaType aMediaType, bool aCompressedVideo = false);
         PvmiMIOControl* CreateVideoOutput(OsclAny* aParam, PVRefFileOutputTestObserver* aObserver, bool aActiveTiming, uint32 aQueueLimit, bool aSimFlowControl, bool logStrings = true);
         void DestroyVideoOutput(PvmiMIOControl* aMio);
         PvmiMIOControl* CreateTextOutput(OsclAny* aParam);
+        PvmiMIOControl* CreateTextOutput(OsclAny* aParam, MediaType aMediaType);
         void DestroyTextOutput(PvmiMIOControl* aMio);
 };
 
diff --git a/extern_libs_v2/khronos/openmax/include/omx_audio.h b/extern_libs_v2/khronos/openmax/include/omx_audio.h
index e4dab02..e615ed0 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_audio.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_audio.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** @file OMX_Audio.h - OpenMax IL version 1.1
+/** @file omx_audio.h - OpenMax IL version 1.1.2
  *  The structures needed by Audio components to exchange
  *  parameters and configuration data with the componenmilts.
  */
@@ -55,7 +55,7 @@
  *  header to compile without errors.  The includes below are required
  *  for this header file to compile successfully 
  */
-#include <omx_types.h>
+
 #include <omx_core.h>
 
 /** @defgroup midi MIDI
@@ -106,6 +106,8 @@
     OMX_AUDIO_CodingWMA,         /**< Any variant of WMA encoded data */
     OMX_AUDIO_CodingRA,          /**< Any variant of RA encoded data */
     OMX_AUDIO_CodingMIDI,        /**< Any variant of MIDI encoded data */
+    OMX_AUDIO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_CodingMax = 0x7FFFFFFF
 } OMX_AUDIO_CODINGTYPE;
 
@@ -114,7 +116,7 @@
  *  necessary for the compliant component to setup an input or an output audio 
  *  path.  If additional information is needed to define the parameters of the
  *  port (such as frequency), additional structures must be sent such as the
- *  OMX_AUDIO_PCMTYPE structure to supply the extra parameters for the port.
+ *  OMX_AUDIO_PARAM_PCMMODETYPE structure to supply the extra parameters for the port.
  */
 typedef struct OMX_AUDIO_PORTDEFINITIONTYPE {
     OMX_STRING cMIMEType;            /**< MIME type of data for the port */
@@ -145,6 +147,8 @@
     OMX_AUDIO_PCMModeLinear = 0,  /**< Linear PCM encoded data */ 
     OMX_AUDIO_PCMModeALaw,        /**< A law PCM encoded data (G.711) */ 
     OMX_AUDIO_PCMModeMULaw,       /**< Mu law PCM encoded data (G.711)  */ 
+    OMX_AUDIO_PCMModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_PCMModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_PCMModeMax = 0x7FFFFFFF 
 } OMX_AUDIO_PCMMODETYPE; 
 
@@ -160,6 +164,8 @@
     OMX_AUDIO_ChannelCS   = 0x7,    /**< Back surround */
     OMX_AUDIO_ChannelLR   = 0x8,    /**< Left rear. */
     OMX_AUDIO_ChannelRR   = 0x9,    /**< Right rear. */
+    OMX_AUDIO_ChannelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_ChannelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_ChannelMax  = 0x7FFFFFFF 
 } OMX_AUDIO_CHANNELTYPE;
 
@@ -196,6 +202,8 @@
     OMX_AUDIO_ChannelModeDual,        /**< 2 mono-channels, each channel is encoded with half 
                                            the bitrate of the overall bitrate */
     OMX_AUDIO_ChannelModeMono,        /**< Mono channel mode */
+    OMX_AUDIO_ChannelModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_ChannelModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_ChannelModeMax = 0x7FFFFFFF
 } OMX_AUDIO_CHANNELMODETYPE;
 
@@ -204,6 +212,8 @@
     OMX_AUDIO_MP3StreamFormatMP1Layer3 = 0, /**< MP3 Audio MPEG 1 Layer 3 Stream format */
     OMX_AUDIO_MP3StreamFormatMP2Layer3,     /**< MP3 Audio MPEG 2 Layer 3 Stream format */
     OMX_AUDIO_MP3StreamFormatMP2_5Layer3,   /**< MP3 Audio MPEG2.5 Layer 3 Stream format */
+    OMX_AUDIO_MP3StreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_MP3StreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_MP3StreamFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_MP3STREAMFORMATTYPE;
 
@@ -232,6 +242,8 @@
     OMX_AUDIO_AACStreamFormatADIF,        /**< AAC Audio Data Interchange Format */
     OMX_AUDIO_AACStreamFormatMP4FF,       /**< AAC inside MPEG-4/ISO File Format */
     OMX_AUDIO_AACStreamFormatRAW,         /**< AAC Raw Format */
+    OMX_AUDIO_AACStreamFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AACStreamFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_AACStreamFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_AACSTREAMFORMATTYPE;
 
@@ -249,6 +261,8 @@
   OMX_AUDIO_AACObjectERLC = 17,     /**< ER AAC Low Complexity object (Error Resilient AAC-LC) */
   OMX_AUDIO_AACObjectLD = 23,       /**< AAC Low Delay object (Error Resilient) */
   OMX_AUDIO_AACObjectHE_PS = 29,    /**< AAC High Efficiency with Parametric Stereo coding (HE-AAC v2, object type PS) */
+  OMX_AUDIO_AACObjectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_AACObjectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_AACObjectMax = 0x7FFFFFFF
 } OMX_AUDIO_AACPROFILETYPE;
 
@@ -331,22 +345,56 @@
   OMX_AUDIO_WMAFormat7,          /**< Windows Media Audio format 7 */
   OMX_AUDIO_WMAFormat8,          /**< Windows Media Audio format 8 */
   OMX_AUDIO_WMAFormat9,          /**< Windows Media Audio format 9 */
+  OMX_AUDIO_WMAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_WMAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_WMAFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_WMAFORMATTYPE;
 
 
+/** WMA Profile */
+typedef enum OMX_AUDIO_WMAPROFILETYPE {
+  OMX_AUDIO_WMAProfileUnused = 0,  /**< profile unused or unknown */
+  OMX_AUDIO_WMAProfileL1,          /**< Windows Media audio version 9 profile L1 */
+  OMX_AUDIO_WMAProfileL2,          /**< Windows Media audio version 9 profile L2 */
+  OMX_AUDIO_WMAProfileL3,          /**< Windows Media audio version 9 profile L3 */
+  OMX_AUDIO_WMAProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_WMAProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+  OMX_AUDIO_WMAProfileMax = 0x7FFFFFFF
+} OMX_AUDIO_WMAPROFILETYPE;
+
+
 /** WMA params */
 typedef struct OMX_AUDIO_PARAM_WMATYPE {
     OMX_U32 nSize;            /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
     OMX_U32 nPortIndex;       /**< port that this structure applies to */
-    OMX_U32 nChannels;        /**< Number of channels */
+    OMX_U16 nChannels;        /**< Number of channels */
     OMX_U32 nBitRate;         /**< Bit rate of the input data.  Use 0 for variable
                                    rate or unknown bit rates */
     OMX_AUDIO_WMAFORMATTYPE eFormat; /**< Version of WMA stream / data */
-    OMX_U32 nSamplingRate;
+	OMX_AUDIO_WMAPROFILETYPE eProfile;  /**< Profile of WMA stream / data */
+    OMX_U32 nSamplingRate;    /**< Sampling rate of the source data */
+    OMX_U16 nBlockAlign;      /**< is the block alignment, or block size, in bytes of the audio codec */
+    OMX_U16 nEncodeOptions;   /**< WMA Type-specific data */
+    OMX_U32 nSuperBlockAlign; /**< WMA Type-specific data */
 } OMX_AUDIO_PARAM_WMATYPE;
 
+/** 
+ * RealAudio format
+ */
+typedef enum OMX_AUDIO_RAFORMATTYPE {
+    OMX_AUDIO_RAFormatUnused = 0, /**< Format unused or unknown */
+    OMX_AUDIO_RA8,                /**< RealAudio 8 codec */
+    OMX_AUDIO_RA9,                /**< RealAudio 9 codec */
+    OMX_AUDIO_RA10_AAC,           /**< MPEG-4 AAC codec for bitrates of more than 128kbps */
+    OMX_AUDIO_RA10_CODEC,         /**< RealAudio codec for bitrates less than 128 kbps */
+    OMX_AUDIO_RA10_LOSSLESS,      /**< RealAudio Lossless */
+    OMX_AUDIO_RA10_MULTICHANNEL,  /**< RealAudio Multichannel */
+    OMX_AUDIO_RA10_VOICE,         /**< RealAudio Voice for bitrates below 15 kbps */
+    OMX_AUDIO_RAFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_RAFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_VIDEO_RAFormatMax = 0x7FFFFFFF
+} OMX_AUDIO_RAFORMATTYPE;
 
 /** RA (Real Audio) params */ 
 typedef struct OMX_AUDIO_PARAM_RATYPE { 
@@ -354,13 +402,13 @@
     OMX_VERSIONTYPE nVersion;   /**< OMX specification version information */ 
     OMX_U32 nPortIndex;         /**< Port that this structure applies to */ 
     OMX_U32 nChannels;          /**< Number of channels */ 
-    OMX_U32 nSamplingRate;      /**< Values allowed for samplerate are 
-                                     8000, 11025, 22050 and 44100 Hz  */ 
-    OMX_U32 nBitsPerFrame;      /**< Values allowed for bitsPerFrame are from 46 to 12288 */ 
-    OMX_U32 nSamplePerFrame;    /**< Values allowed for samplesPerFrame are 256, 512 and 1024*/ 
-    OMX_U32 nCouplingQuantBits; /**< Values allowed for couplingQuantBits are from 2 to 6*/ 
-    OMX_U32 nCouplingStartRegion;   /**< Values allowed for couplingStartRegion are from 1 to 51 */ 
-    OMX_U32 nNumRegions;        /**< Values allowed for numRegions are from 12 to 51 */ 
+    OMX_U32 nSamplingRate;      /**< is the sampling rate of the source data */ 
+    OMX_U32 nBitsPerFrame;      /**< is the value for bits per frame  */ 
+    OMX_U32 nSamplePerFrame;    /**< is the value for samples per frame */ 
+    OMX_U32 nCouplingQuantBits; /**< is the number of coupling quantization bits in the stream */ 
+    OMX_U32 nCouplingStartRegion;   /**< is the coupling start region in the stream  */ 
+    OMX_U32 nNumRegions;        /**< is the number of regions value */ 
+    OMX_AUDIO_RAFORMATTYPE eFormat; /**< is the RealAudio audio format */
 } OMX_AUDIO_PARAM_RATYPE; 
 
 
@@ -368,6 +416,8 @@
 typedef enum OMX_AUDIO_SBCALLOCMETHODTYPE {
   OMX_AUDIO_SBCAllocMethodLoudness, /**< Loudness allocation method */
   OMX_AUDIO_SBCAllocMethodSNR,      /**< SNR allocation method */
+  OMX_AUDIO_SBCAllocMethodKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_SBCAllocMethodVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_SBCAllocMethodMax = 0x7FFFFFFF
 } OMX_AUDIO_SBCALLOCMETHODTYPE;
 
@@ -410,6 +460,8 @@
     OMX_AUDIO_G723ModeUnused = 0,  /**< AMRNB Mode unused / unknown */
     OMX_AUDIO_G723ModeLow,         /**< 5300 bps */
     OMX_AUDIO_G723ModeHigh,        /**< 6300 bps */
+    OMX_AUDIO_G723ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_G723ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_G723ModeMax = 0x7FFFFFFF
 } OMX_AUDIO_G723RATE;
 
@@ -436,6 +488,8 @@
     OMX_AUDIO_G726Mode24,          /**< 24 kbps */
     OMX_AUDIO_G726Mode32,          /**< 32 kbps, most common rate, also G721 */
     OMX_AUDIO_G726Mode40,          /**< 40 kbps */
+    OMX_AUDIO_G726ModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_G726ModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_G726ModeMax = 0x7FFFFFFF
 } OMX_AUDIO_G726MODE;
 
@@ -458,6 +512,8 @@
     OMX_AUDIO_G729A,              /**< ITU G.729 annex A  encoded data */
     OMX_AUDIO_G729B,              /**< ITU G.729 with annex B encoded data */
     OMX_AUDIO_G729AB,             /**< ITU G.729 annexes A and B encoded data */
+    OMX_AUDIO_G729KhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_G729VendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_G729Max = 0x7FFFFFFF
 } OMX_AUDIO_G729TYPE;
 
@@ -488,6 +544,8 @@
     OMX_AUDIO_AMRFrameFormatRTPPayload,       /**< Frame Format is AMR Real-Time 
                                                    Transport Protocol Payload Format */ 
     OMX_AUDIO_AMRFrameFormatITU,              /**< Frame Format is ITU Format (added at Motorola request) */ 
+    OMX_AUDIO_AMRFrameFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AMRFrameFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_AMRFrameFormatMax = 0x7FFFFFFF 
 } OMX_AUDIO_AMRFRAMEFORMATTYPE; 
 
@@ -512,6 +570,8 @@
     OMX_AUDIO_AMRBandModeWB6,                 /**< AMRWB Mode 6 = 19850 bps */
     OMX_AUDIO_AMRBandModeWB7,                 /**< AMRWB Mode 7 = 23050 bps */
     OMX_AUDIO_AMRBandModeWB8,                 /**< AMRWB Mode 8 = 23850 bps */      
+    OMX_AUDIO_AMRBandModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AMRBandModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_AMRBandModeMax = 0x7FFFFFFF
 } OMX_AUDIO_AMRBANDMODETYPE;
      
@@ -528,6 +588,8 @@
 
     OMX_AUDIO_AMRDTXasEFR,             /**< DTX as EFR instead of AMR standard (3GPP 26.101, frame type =8,9,10) */
 
+    OMX_AUDIO_AMRDTXModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_AMRDTXModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_AMRDTXModeMax = 0x7FFFFFFF 
 } OMX_AUDIO_AMRDTXMODETYPE; 
  
@@ -540,8 +602,6 @@
     OMX_U32 nChannels;                      /**< Number of channels */
     OMX_U32 nBitRate;                       /**< Bit rate read only field */
     OMX_AUDIO_AMRBANDMODETYPE eAMRBandMode; /**< AMR Band Mode enumeration */ 
-    OMX_U32 nBitPerSample;                  /**< Bit per sample.  If nBitPerSample = 0, 
-                                                 use the value from eAMRBandMode */
     OMX_AUDIO_AMRDTXMODETYPE  eAMRDTXMode;  /**< AMR DTX Mode enumeration */
     OMX_AUDIO_AMRFRAMEFORMATTYPE eAMRFrameFormat; /**< AMR frame format enumeration */
 } OMX_AUDIO_PARAM_AMRTYPE;
@@ -649,6 +709,8 @@
     OMX_AUDIO_CDMARateQuarter,            /**< CDMA encoded frame in quarter rate */
     OMX_AUDIO_CDMARateEighth,             /**< CDMA encoded frame in eighth rate (DTX)*/
     OMX_AUDIO_CDMARateErasure,            /**< CDMA erasure frame */
+    OMX_AUDIO_CDMARateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_CDMARateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_CDMARateMax = 0x7FFFFFFF
 } OMX_AUDIO_CDMARATETYPE;
 
@@ -732,6 +794,8 @@
     OMX_AUDIO_MIDIFormatXMF0,        /**< eXtensible Music Format type 0 */
     OMX_AUDIO_MIDIFormatXMF1,        /**< eXtensible Music Format type 1 */
     OMX_AUDIO_MIDIFormatMobileXMF,   /**< Mobile XMF (eXtensible Music Format type 2) */
+    OMX_AUDIO_MIDIFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_MIDIFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_MIDIFormatMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDIFORMATTYPE;
 
@@ -765,6 +829,8 @@
     OMX_AUDIO_MIDISoundBankDLS2,                 /**< DLS version 2 */
     OMX_AUDIO_MIDISoundBankMobileDLSBase,        /**< Mobile DLS, using the base functionality */
     OMX_AUDIO_MIDISoundBankMobileDLSPlusOptions, /**< Mobile DLS, using the specification-defined optional feature set */
+    OMX_AUDIO_MIDISoundBankKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_MIDISoundBankVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_MIDISoundBankMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDISOUNDBANKTYPE;
 
@@ -777,6 +843,8 @@
    OMX_AUDIO_MIDISoundBankLayoutGM,           /**< GS layout (based on bank MSB 0x00) */
    OMX_AUDIO_MIDISoundBankLayoutGM2,          /**< General MIDI 2 layout (using MSB 0x78/0x79, LSB 0x00) */
    OMX_AUDIO_MIDISoundBankLayoutUser,         /**< Does not conform to any bank numbering standards */
+   OMX_AUDIO_MIDISoundBankLayoutKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_AUDIO_MIDISoundBankLayoutVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
    OMX_AUDIO_MIDISoundBankLayoutMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDISOUNDBANKLAYOUTTYPE;
 
@@ -885,6 +953,8 @@
                                                     no audible MIDI content during playback
                                                     currently. The situation may change if
                                                     resources are freed later.*/
+  OMX_AUDIO_MIDIPlayBackStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_AUDIO_MIDIPlayBackStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
   OMX_AUDIO_MIDIPlayBackStateMax = 0x7FFFFFFF
 } OMX_AUDIO_MIDIPLAYBACKSTATETYPE;
 
@@ -1123,6 +1193,8 @@
 typedef enum OMX_AUDIO_STEREOWIDENINGTYPE {
     OMX_AUDIO_StereoWideningHeadphones,    /**< Stereo widening for loudspeakers */
     OMX_AUDIO_StereoWideningLoudspeakers,  /**< Stereo widening for closely spaced loudspeakers */
+    OMX_AUDIO_StereoWideningKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_AUDIO_StereoWideningVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_AUDIO_StereoWideningMax = 0x7FFFFFFF
 } OMX_AUDIO_STEREOWIDENINGTYPE;
 
@@ -1216,6 +1288,8 @@
                                      Hands Free operation */
    OMX_AUDIO_EchoCanCarKit,    /**< Echo Cancellation optimized for 
                                      Car Kit (longer echo) */
+   OMX_AUDIO_EchoCanKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_AUDIO_EchoCanVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
    OMX_AUDIO_EchoCanMax = 0x7FFFFFFF
 } OMX_AUDIO_ECHOCANTYPE;
 
diff --git a/extern_libs_v2/khronos/openmax/include/omx_component.h b/extern_libs_v2/khronos/openmax/include/omx_component.h
index 46241ed..0401c20 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_component.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_component.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** OMX_Component.h - OpenMax IL version 1.1
+/** omx_component.h - OpenMax IL version 1.1.2
  *  The OMX_Component header file contains the definitions used to define
  *  the public interface of a component.  This header file is intended to
  *  be used by both the application and the component.
@@ -57,8 +57,7 @@
  *  header to compile without errors.  The includes below are required
  *  for this header file to compile successfully 
  */
-#include <omx_types.h>
-#include <omx_core.h>
+
 #include <omx_audio.h>
 #include <omx_video.h>
 #include <omx_image.h>
@@ -70,6 +69,8 @@
     OMX_PortDomainVideo, 
     OMX_PortDomainImage, 
     OMX_PortDomainOther,
+    OMX_PortDomainKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_PortDomainVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_PortDomainMax = 0x7ffffff
 } OMX_PORTDOMAINTYPE;
 
@@ -97,6 +98,8 @@
         OMX_IMAGE_PORTDEFINITIONTYPE image;
         OMX_OTHER_PORTDEFINITIONTYPE other;
     } format;
+    OMX_BOOL bBuffersContiguous;
+    OMX_U32 nBufferAlignment;
 } OMX_PARAM_PORTDEFINITIONTYPE;
 
 /** @ingroup comp */
@@ -111,6 +114,8 @@
 typedef enum OMX_SUSPENSIONPOLICYTYPE {
     OMX_SuspensionDisabled, /**< No suspension; v1.0 behavior */
     OMX_SuspensionEnabled,  /**< Suspension allowed */   
+    OMX_SuspensionPolicyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_SuspensionPolicyStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_SuspensionPolicyMax = 0x7fffffff
 } OMX_SUSPENSIONPOLICYTYPE;
 
@@ -125,6 +130,8 @@
 typedef enum OMX_SUSPENSIONTYPE {
     OMX_NotSuspended, /**< component is not suspended */
     OMX_Suspended,    /**< component is suspended */
+    OMX_SuspensionKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_SuspensionVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_SuspendMax = 0x7FFFFFFF
 } OMX_SUSPENSIONTYPE;
 
@@ -141,15 +148,14 @@
     OMX_BOOL bEnabled;    
 } OMX_CONFIG_BOOLEANTYPE;
 
-#define MAX_URI_LENGTH 256
-
 /* Parameter specifying the content uri to use. */
 /** @ingroup cp */
 typedef struct OMX_PARAM_CONTENTURITYPE
 {
-    OMX_U32 nSize;                      /**< size of the structure in bytes */
+    OMX_U32 nSize;                      /**< size of the structure in bytes, including
+                                             actual URI name */
     OMX_VERSIONTYPE nVersion;           /**< OMX specification version information */
-    OMX_U8 contentURI[MAX_URI_LENGTH];    /**< The URI name */
+    OMX_U8 contentURI[1];               /**< The URI name */
 } OMX_PARAM_CONTENTURITYPE;
 
 /* Parameter specifying the pipe to use. */
@@ -208,6 +214,8 @@
     OMX_MetadataCharsetISO2022JP1,
     OMX_MetadataCharsetISOEUCJP,
     OMX_MetadataCharsetSMS7Bit,
+    OMX_MetadataCharsetKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MetadataCharsetVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_MetadataCharsetTypeMax= 0x7FFFFFFF
 } OMX_METADATACHARSETTYPE;
 
@@ -218,10 +226,22 @@
     OMX_MetadataScopeTopLevel,
     OMX_MetadataScopePortLevel,
     OMX_MetadataScopeNodeLevel,
+    OMX_MetadataScopeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MetadataScopeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_MetadataScopeTypeMax = 0x7fffffff
 } OMX_METADATASCOPETYPE;
 
 /** @ingroup metadata */
+typedef enum OMX_METADATASEARCHMODETYPE
+{
+    OMX_MetadataSearchValueSizeByIndex,
+    OMX_MetadataSearchItemByIndex,
+    OMX_MetadataSearchNextItemByKey,
+    OMX_MetadataSearchKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MetadataSearchVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_MetadataSearchTypeMax = 0x7fffffff
+} OMX_METADATASEARCHMODETYPE;
+/** @ingroup metadata */
 typedef struct OMX_CONFIG_METADATAITEMCOUNTTYPE
 {
     OMX_U32 nSize;
@@ -239,6 +259,7 @@
     OMX_METADATASCOPETYPE eScopeMode;
     OMX_U32 nScopeSpecifier;
     OMX_U32 nMetadataItemIndex;  
+    OMX_METADATASEARCHMODETYPE eSearchMode;
     OMX_METADATACHARSETTYPE eKeyCharset;
     OMX_U8 nKeySizeUsed;
     OMX_U8 nKey[128];
@@ -254,6 +275,7 @@
 {
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bAllKeys;
     OMX_U32 nParentNodeID;
     OMX_U32 nNumNodes;
 } OMX_CONFIG_CONTAINERNODECOUNTTYPE;
@@ -263,6 +285,7 @@
 {
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
+    OMX_BOOL bAllKeys;
     OMX_U32 nParentNodeID;
     OMX_U32 nNodeIndex; 
     OMX_U32 nNodeID; 
@@ -280,6 +303,8 @@
     OMX_METADATACHARSETTYPE eKeyCharset;
     OMX_U32 nKeySizeUsed; 
     OMX_U8   nKey [128]; 
+    OMX_U32 nLanguageCountrySizeUsed;
+    OMX_U8 nLanguageCountry[128];
     OMX_BOOL bEnabled;	/* if true then key is part of filter (e.g. 
                          * retained for query later). If false then
                          * key is not part of filter */
@@ -323,7 +348,7 @@
         returned to the IL Client by OMX in all callbacks */
     OMX_PTR pApplicationPrivate;
 
-    /** refer to OMX_GetComponentVersion in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetComponentVersion in omx_core.h or the OMX IL 
         specification for details on the GetComponentVersion method.
      */
     OMX_ERRORTYPE (*GetComponentVersion)(
@@ -333,7 +358,7 @@
             OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
             OMX_OUT OMX_UUIDTYPE* pComponentUUID);
 
-    /** refer to OMX_SendCommand in OMX_core.h or the OMX IL 
+    /** refer to OMX_SendCommand in omx_core.h or the OMX IL 
         specification for details on the SendCommand method.
      */
     OMX_ERRORTYPE (*SendCommand)(
@@ -342,7 +367,7 @@
             OMX_IN  OMX_U32 nParam1,
             OMX_IN  OMX_PTR pCmdData);
 
-    /** refer to OMX_GetParameter in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetParameter in omx_core.h or the OMX IL 
         specification for details on the GetParameter method.
      */
     OMX_ERRORTYPE (*GetParameter)(
@@ -351,7 +376,7 @@
             OMX_INOUT OMX_PTR pComponentParameterStructure);
 
 
-    /** refer to OMX_SetParameter in OMX_core.h or the OMX IL 
+    /** refer to OMX_SetParameter in omx_core.h or the OMX IL 
         specification for details on the SetParameter method.
      */
     OMX_ERRORTYPE (*SetParameter)(
@@ -360,7 +385,7 @@
             OMX_IN  OMX_PTR pComponentParameterStructure);
 
 
-    /** refer to OMX_GetConfig in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetConfig in omx_core.h or the OMX IL 
         specification for details on the GetConfig method.
      */
     OMX_ERRORTYPE (*GetConfig)(
@@ -369,7 +394,7 @@
             OMX_INOUT OMX_PTR pComponentConfigStructure);
 
 
-    /** refer to OMX_SetConfig in OMX_core.h or the OMX IL 
+    /** refer to OMX_SetConfig in omx_core.h or the OMX IL 
         specification for details on the SetConfig method.
      */
     OMX_ERRORTYPE (*SetConfig)(
@@ -378,7 +403,7 @@
             OMX_IN  OMX_PTR pComponentConfigStructure);
 
 
-    /** refer to OMX_GetExtensionIndex in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetExtensionIndex in omx_core.h or the OMX IL 
         specification for details on the GetExtensionIndex method.
      */
     OMX_ERRORTYPE (*GetExtensionIndex)(
@@ -387,7 +412,7 @@
             OMX_OUT OMX_INDEXTYPE* pIndexType);
 
 
-    /** refer to OMX_GetState in OMX_core.h or the OMX IL 
+    /** refer to OMX_GetState in omx_core.h or the OMX IL 
         specification for details on the GetState method.
      */
     OMX_ERRORTYPE (*GetState)(
@@ -452,7 +477,7 @@
             provided by the component with the output port.
         @return OMX_ERRORTYPE
             If the command successfully executes, the return code will be
-            OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
         @ingroup tun
     */
 
@@ -463,7 +488,7 @@
         OMX_IN  OMX_U32 nTunneledPort,
         OMX_INOUT  OMX_TUNNELSETUPTYPE* pTunnelSetup); 
 
-    /** refer to OMX_UseBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_UseBuffer in omx_core.h or the OMX IL 
         specification for details on the UseBuffer method.
         @ingroup buf
      */
@@ -475,7 +500,7 @@
             OMX_IN OMX_U32 nSizeBytes,
             OMX_IN OMX_U8* pBuffer);
 
-    /** refer to OMX_AllocateBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_AllocateBuffer in omx_core.h or the OMX IL 
         specification for details on the AllocateBuffer method.
         @ingroup buf
      */
@@ -486,7 +511,7 @@
             OMX_IN OMX_PTR pAppPrivate,
             OMX_IN OMX_U32 nSizeBytes);
 
-    /** refer to OMX_FreeBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_FreeBuffer in omx_core.h or the OMX IL 
         specification for details on the FreeBuffer method.
         @ingroup buf
      */
@@ -495,7 +520,7 @@
             OMX_IN  OMX_U32 nPortIndex,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-    /** refer to OMX_EmptyThisBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_EmptyThisBuffer in omx_core.h or the OMX IL 
         specification for details on the EmptyThisBuffer method.
         @ingroup buf
      */
@@ -503,7 +528,7 @@
             OMX_IN  OMX_HANDLETYPE hComponent,
             OMX_IN  OMX_BUFFERHEADERTYPE* pBuffer);
 
-    /** refer to OMX_FillThisBuffer in OMX_core.h or the OMX IL 
+    /** refer to OMX_FillThisBuffer in omx_core.h or the OMX IL 
         specification for details on the FillThisBuffer method.
         @ingroup buf
      */
@@ -527,7 +552,7 @@
             to determine the context of the call
         @return OMX_ERRORTYPE
             If the command successfully executes, the return code will be
-            OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
      */
     OMX_ERRORTYPE (*SetCallbacks)(
             OMX_IN  OMX_HANDLETYPE hComponent,
@@ -543,7 +568,7 @@
             handle returned by the call to the GetHandle function.
         @return OMX_ERRORTYPE
             If the command successfully executes, the return code will be
-            OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+            OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
      */
     OMX_ERRORTYPE (*ComponentDeInit)(
             OMX_IN  OMX_HANDLETYPE hComponent);
diff --git a/extern_libs_v2/khronos/openmax/include/omx_contentpipe.h b/extern_libs_v2/khronos/openmax/include/omx_contentpipe.h
index 98e3a58..73f95cc 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_contentpipe.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_contentpipe.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2006 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** OMX_ContentPipe.h - OpenMax IL version 1.1
+/** omx_contentpipe.h - OpenMax IL version 1.1.2
  *  The OMX_ContentPipe header file contains the definitions used to define
  *  the public interface for content piples.  This header file is intended to
  *  be used by the component.
@@ -47,6 +47,38 @@
 #ifndef OMX_CONTENTPIPE_H
 #define OMX_CONTENTPIPE_H
 
+#ifndef KD_EACCES
+/* OpenKODE error codes. CPResult values may be zero (indicating success
+   or one of the following values) */
+#define KD_EACCES (1)
+#define KD_EADDRINUSE (2)
+#define KD_EAGAIN (5)
+#define KD_EBADF (7)
+#define KD_EBUSY (8)
+#define KD_ECONNREFUSED (9)
+#define KD_ECONNRESET (10)
+#define KD_EDEADLK (11)
+#define KD_EDESTADDRREQ (12)
+#define KD_ERANGE (35)
+#define KD_EEXIST (13)
+#define KD_EFBIG (14)
+#define KD_EHOSTUNREACH (15)
+#define KD_EINVAL (17)
+#define KD_EIO (18)
+#define KD_EISCONN (20)
+#define KD_EISDIR (21)
+#define KD_EMFILE (22)
+#define KD_ENAMETOOLONG (23)
+#define KD_ENOENT (24)
+#define KD_ENOMEM (25)
+#define KD_ENOSPC (26)
+#define KD_ENOSYS (27)
+#define KD_ENOTCONN (28)
+#define KD_EPERM (33)
+#define KD_ETIMEDOUT (36)
+#define KD_EILSEQ (19)
+#endif
+
 /** Map types from OMX standard types only here so interface is as generic as possible. */
 typedef OMX_U32    CPresult;
 typedef char *     CPstring;  
@@ -63,6 +95,8 @@
     CP_OriginBegin,      
     CP_OriginCur,      
     CP_OriginEnd,      
+    CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_OriginMax = 0X7FFFFFFF
 } CP_ORIGINTYPE;
 
@@ -73,6 +107,8 @@
     CP_AccessRead,      
     CP_AccessWrite,  
     CP_AccessReadWrite ,  
+    CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_AccessMax = 0X7FFFFFFF
 } CP_ACCESSTYPE;
 
@@ -93,6 +129,8 @@
     CP_CheckBytesAtEndOfStream,         /**< The pipe has reached the end of stream
                                               and no more bytes are available. */
     CP_CheckBytesOutOfBuffers,          /**< All read/write buffers are currently in use. */
+    CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_CheckBytesMax = 0X7FFFFFFF
 } CP_CHECKBYTESRESULTTYPE;
 
@@ -103,6 +141,8 @@
     CP_BytesAvailable,      	    /** bytes requested in a CheckAvailableBytes call are now available*/
     CP_Overflow,  		           /** enumeration of content pipe events sent to the client callback*/
     CP_PipeDisconnected  ,  		    /** enumeration of content pipe events sent to the client callback*/
+    CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     CP_EventMax = 0X7FFFFFFF
 } CP_EVENTTYPE;
 
diff --git a/extern_libs_v2/khronos/openmax/include/omx_core.h b/extern_libs_v2/khronos/openmax/include/omx_core.h
index ae60e62..8e0c8a4 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_core.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_core.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** OMX_Core.h - OpenMax IL version 1.1
+/** omx_core.h - OpenMax IL version 1.1.2
  *  The OMX_Core header file contains the definitions used by both the
  *  application and the component to access common items.
  */
@@ -55,7 +55,7 @@
  *  header to compile without errors.  The includes below are required
  *  for this header file to compile successfully 
  */
-#include <omx_types.h>
+
 #include <omx_index.h>
 
 
@@ -70,6 +70,8 @@
     OMX_CommandPortDisable, /**< Disable a port on a component. */
     OMX_CommandPortEnable,  /**< Enable a port on a component. */
     OMX_CommandMarkBuffer,  /**< Mark a component/buffer for observation */
+    OMX_CommandKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_CommandVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_CommandMax = 0X7FFFFFFF
 } OMX_COMMANDTYPE;
 
@@ -123,6 +125,8 @@
     OMX_StateWaitForResources, /**< component is waiting for resources, either after 
                                 preemption or before it gets the resources requested.
                                 See specification for complete details. */
+    OMX_StateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_StateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_StateMax = 0X7FFFFFFF
 } OMX_STATETYPE;
 
@@ -141,130 +145,132 @@
   OMX_ErrorNone = 0,
 
   /** There were insufficient resources to perform the requested operation */
-  OMX_ErrorInsufficientResources = 0x80001000,
+  OMX_ErrorInsufficientResources = (OMX_S32) 0x80001000,
 
   /** There was an error, but the cause of the error could not be determined */
-  OMX_ErrorUndefined = 0x80001001,
+  OMX_ErrorUndefined = (OMX_S32) 0x80001001,
 
   /** The component name string was not valid */
-  OMX_ErrorInvalidComponentName = 0x80001002,
+  OMX_ErrorInvalidComponentName = (OMX_S32) 0x80001002,
 
   /** No component with the specified name string was found */
-  OMX_ErrorComponentNotFound = 0x80001003,
+  OMX_ErrorComponentNotFound = (OMX_S32) 0x80001003,
 
   /** The component specified did not have a "OMX_ComponentInit" or
       "OMX_ComponentDeInit entry point */
-  OMX_ErrorInvalidComponent = 0x80001004,
+  OMX_ErrorInvalidComponent = (OMX_S32) 0x80001004,
 
   /** One or more parameters were not valid */
-  OMX_ErrorBadParameter = 0x80001005,
+  OMX_ErrorBadParameter = (OMX_S32) 0x80001005,
 
   /** The requested function is not implemented */
-  OMX_ErrorNotImplemented = 0x80001006,
+  OMX_ErrorNotImplemented = (OMX_S32) 0x80001006,
 
   /** The buffer was emptied before the next buffer was ready */
-  OMX_ErrorUnderflow = 0x80001007,
+  OMX_ErrorUnderflow = (OMX_S32) 0x80001007,
 
   /** The buffer was not available when it was needed */
-  OMX_ErrorOverflow = 0x80001008,
+  OMX_ErrorOverflow = (OMX_S32) 0x80001008,
 
   /** The hardware failed to respond as expected */
-  OMX_ErrorHardware = 0x80001009,
+  OMX_ErrorHardware = (OMX_S32) 0x80001009,
 
   /** The component is in the state OMX_StateInvalid */
-  OMX_ErrorInvalidState = 0x8000100A,
+  OMX_ErrorInvalidState = (OMX_S32) 0x8000100A,
 
   /** Stream is found to be corrupt */
-  OMX_ErrorStreamCorrupt = 0x8000100B,
+  OMX_ErrorStreamCorrupt = (OMX_S32) 0x8000100B,
 
   /** Ports being connected are not compatible */
-  OMX_ErrorPortsNotCompatible = 0x8000100C,
+  OMX_ErrorPortsNotCompatible = (OMX_S32) 0x8000100C,
 
   /** Resources allocated to an idle component have been
       lost resulting in the component returning to the loaded state */
-  OMX_ErrorResourcesLost = 0x8000100D,
+  OMX_ErrorResourcesLost = (OMX_S32) 0x8000100D,
 
   /** No more indicies can be enumerated */
-  OMX_ErrorNoMore = 0x8000100E,
+  OMX_ErrorNoMore = (OMX_S32) 0x8000100E,
 
   /** The component detected a version mismatch */
-  OMX_ErrorVersionMismatch = 0x8000100F,
+  OMX_ErrorVersionMismatch = (OMX_S32) 0x8000100F,
 
   /** The component is not ready to return data at this time */
-  OMX_ErrorNotReady = 0x80001010,
+  OMX_ErrorNotReady = (OMX_S32) 0x80001010,
 
   /** There was a timeout that occurred */
-  OMX_ErrorTimeout = 0x80001011,
+  OMX_ErrorTimeout = (OMX_S32) 0x80001011,
 
   /** This error occurs when trying to transition into the state you are already in */
-  OMX_ErrorSameState = 0x80001012,
+  OMX_ErrorSameState = (OMX_S32) 0x80001012,
 
   /** Resources allocated to an executing or paused component have been 
       preempted, causing the component to return to the idle state */
-  OMX_ErrorResourcesPreempted = 0x80001013, 
+  OMX_ErrorResourcesPreempted = (OMX_S32) 0x80001013, 
 
   /** A non-supplier port sends this error to the IL client (via the EventHandler callback) 
       during the allocation of buffers (on a transition from the LOADED to the IDLE state or
       on a port restart) when it deems that it has waited an unusually long time for the supplier 
       to send it an allocated buffer via a UseBuffer call. */
-  OMX_ErrorPortUnresponsiveDuringAllocation = 0x80001014,
+  OMX_ErrorPortUnresponsiveDuringAllocation = (OMX_S32) 0x80001014,
 
   /** A non-supplier port sends this error to the IL client (via the EventHandler callback) 
       during the deallocation of buffers (on a transition from the IDLE to LOADED state or 
       on a port stop) when it deems that it has waited an unusually long time for the supplier 
       to request the deallocation of a buffer header via a FreeBuffer call. */
-  OMX_ErrorPortUnresponsiveDuringDeallocation = 0x80001015,
+  OMX_ErrorPortUnresponsiveDuringDeallocation = (OMX_S32) 0x80001015,
 
   /** A supplier port sends this error to the IL client (via the EventHandler callback) 
       during the stopping of a port (either on a transition from the IDLE to LOADED 
       state or a port stop) when it deems that it has waited an unusually long time for 
       the non-supplier to return a buffer via an EmptyThisBuffer or FillThisBuffer call. */
-  OMX_ErrorPortUnresponsiveDuringStop = 0x80001016,
+  OMX_ErrorPortUnresponsiveDuringStop = (OMX_S32) 0x80001016,
 
   /** Attempting a state transtion that is not allowed */
-  OMX_ErrorIncorrectStateTransition = 0x80001017,
+  OMX_ErrorIncorrectStateTransition = (OMX_S32) 0x80001017,
 
   /* Attempting a command that is not allowed during the present state. */
-  OMX_ErrorIncorrectStateOperation = 0x80001018, 
+  OMX_ErrorIncorrectStateOperation = (OMX_S32) 0x80001018, 
 
   /** The values encapsulated in the parameter or config structure are not supported. */
-  OMX_ErrorUnsupportedSetting = 0x80001019,
+  OMX_ErrorUnsupportedSetting = (OMX_S32) 0x80001019,
 
   /** The parameter or config indicated by the given index is not supported. */
-  OMX_ErrorUnsupportedIndex = 0x8000101A,
+  OMX_ErrorUnsupportedIndex = (OMX_S32) 0x8000101A,
 
   /** The port index supplied is incorrect. */
-  OMX_ErrorBadPortIndex = 0x8000101B,
+  OMX_ErrorBadPortIndex = (OMX_S32) 0x8000101B,
 
   /** The port has lost one or more of its buffers and it thus unpopulated. */
-  OMX_ErrorPortUnpopulated = 0x8000101C,
+  OMX_ErrorPortUnpopulated = (OMX_S32) 0x8000101C,
 
   /** Component suspended due to temporary loss of resources */
-  OMX_ErrorComponentSuspended = 0x8000101D,
+  OMX_ErrorComponentSuspended = (OMX_S32) 0x8000101D,
 
   /** Component suspended due to an inability to acquire dynamic resources */
-  OMX_ErrorDynamicResourcesUnavailable = 0x8000101E,
+  OMX_ErrorDynamicResourcesUnavailable = (OMX_S32) 0x8000101E,
 
   /** When the macroblock error reporting is enabled the component returns new error 
   for every frame that has errors */
-  OMX_ErrorMbErrorsInFrame = 0x8000101F,
+  OMX_ErrorMbErrorsInFrame = (OMX_S32) 0x8000101F,
 
   /** A component reports this error when it cannot parse or determine the format of an input stream. */
-  OMX_ErrorFormatNotDetected = 0x80001020, 
+  OMX_ErrorFormatNotDetected = (OMX_S32) 0x80001020, 
 
   /** The content open operation failed. */
-  OMX_ErrorContentPipeOpenFailed = 0x80001021,
+  OMX_ErrorContentPipeOpenFailed = (OMX_S32) 0x80001021,
 
   /** The content creation operation failed. */
-  OMX_ErrorContentPipeCreationFailed = 0x80001022,
+  OMX_ErrorContentPipeCreationFailed = (OMX_S32) 0x80001022,
 
   /** Separate table information is being used */
-  OMX_ErrorSeperateTablesUsed = 0x80001023,
+  OMX_ErrorSeperateTablesUsed = (OMX_S32) 0x80001023,
 
   /** Tunneling is unsupported by the component*/
-  OMX_ErrorTunnelingUnsupported = 0x80001024,
+  OMX_ErrorTunnelingUnsupported = (OMX_S32) 0x80001024,
 
-  OMX_ErrorMax = 0x7FFFFFFF,
+  OMX_ErrorKhronosExtensions = (OMX_S32)0x8F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+  OMX_ErrorVendorStartUnused = (OMX_S32)0x90000000, /**< Reserved region for introducing Vendor Extensions */
+  OMX_ErrorMax = 0x7FFFFFFF
 } OMX_ERRORTYPE;
 
 /** @ingroup core */
@@ -385,6 +391,26 @@
  */
 #define OMX_BUFFERFLAG_EXTRADATA 0x00000040
 
+/** Codec Config Buffer Flag: 
+* OMX_BUFFERFLAG_CODECCONFIG is an optional flag that is set by an
+* output port when all bytes in the buffer form part or all of a set of
+* codec specific configuration data.  Examples include SPS/PPS nal units
+* for OMX_VIDEO_CodingAVC or AudioSpecificConfig data for
+* OMX_AUDIO_CodingAAC.  Any component that for a given stream sets 
+* OMX_BUFFERFLAG_CODECCONFIG shall not mix codec configuration bytes
+* with frame data in the same buffer, and shall send all buffers
+* containing codec configuration bytes before any buffers containing
+* frame data that those configurations bytes describe.
+* If the stream format for a particular codec has a frame specific
+* header at the start of each frame, for example OMX_AUDIO_CodingMP3 or
+* OMX_AUDIO_CodingAAC in ADTS mode, then these shall be presented as
+* normal without setting OMX_BUFFERFLAG_CODECCONFIG.
+ * @ingroup buf
+ */
+#define OMX_BUFFERFLAG_CODECCONFIG 0x00000080
+
+
+
 /** @ingroup buf */
 typedef struct OMX_BUFFERHEADERTYPE
 {
@@ -433,18 +459,29 @@
                                      this buffer */
 } OMX_BUFFERHEADERTYPE;
 
-/* Extra Data flags */
+/** The OMX_EXTRADATATYPE enumeration is used to define the 
+ * possible extra data payload types.
+ * NB: this enum is binary backwards compatible with the previous
+ * OMX_EXTRADATA_QUANT define.  This should be replaced with
+ * OMX_ExtraDataQuantization.
+ */
+typedef enum OMX_EXTRADATATYPE
+{
+   OMX_ExtraDataNone = 0,                       /**< Indicates that no more extra data sections follow */        
+   OMX_ExtraDataQuantization,                   /**< The data payload contains quantization data */
+   OMX_ExtraDataKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_ExtraDataVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+   OMX_ExtraDataMax = 0x7FFFFFFF
+} OMX_EXTRADATATYPE;
 
-/* Quant Data Flag: This flag is set when the extra data is appended to the buffer containing quantization information */
-#define OMX_EXTRADATAFLAG_QUANT 0x00000001
 
 typedef struct OMX_OTHER_EXTRADATATYPE  {
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;               
     OMX_U32 nPortIndex;
-    OMX_U32 nFlags;       // Extra Data flags
-    OMX_U32 nDataSize;   // Size of the supporting data to follow
-    OMX_U8  data[1];     // Supporting data hint  
+    OMX_EXTRADATATYPE eType;       /* Extra Data type */
+    OMX_U32 nDataSize;   /* Size of the supporting data to follow */
+    OMX_U8  data[1];     /* Supporting data hint  */
 } OMX_OTHER_EXTRADATATYPE;
 
 /** @ingroup comp */
@@ -469,6 +506,8 @@
    OMX_EventComponentResumed,     /**< Component resumed due to reacquisition of resources */
    OMX_EventDynamicResourcesAvailable, /**< Component has acquired previously unavailable dynamic resources */
    OMX_EventPortFormatDetected,      /**< Component has detected a supported format. */
+   OMX_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+   OMX_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
    OMX_EventMax = 0x7FFFFFFF
 } OMX_EVENTTYPE;
 
@@ -499,7 +538,7 @@
             an OMX_COMMANDTYPE for a command complete event and OMX_INDEXTYPE for a OMX_PortSettingsChanged event.
          @param nData2
             nData2 will hold further information related to the event. Can be OMX_STATETYPE for
-            a OMX_StateChange command or port index for a OMX_PortSettingsCHanged event.
+            a OMX_CommandStateSet command or port index for a OMX_PortSettingsChanged event.
             Default value is 0 if not used. )
         @param pEventData
             Pointer to additional event-specific data (see spec for meaning).
@@ -581,6 +620,8 @@
                                               or don't care */
     OMX_BufferSupplyInput,             /**< input port supplies the buffers */
     OMX_BufferSupplyOutput,            /**< output port supplies the buffers */
+    OMX_BufferSupplyKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_BufferSupplyVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_BufferSupplyMax = 0x7FFFFFFF
 } OMX_BUFFERSUPPLIERTYPE;
 
@@ -618,7 +659,7 @@
    macros for functions into the component for OMX release 1.0.  
    Developers should not access any structures or data from within
    the component header directly */
-#include <omx_component.h>
+/* TO BE REMOVED - #include <omx_component.h> */
 
 /** GetComponentVersion will return information about the component.  
     This is a blocking call.  This macro will go directly from the
@@ -654,7 +695,7 @@
         the component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_GetComponentVersion(                            \
@@ -703,8 +744,8 @@
         Command for the component to execute
     @param [in] nParam
         Parameter for the command to be executed.  When Cmd has the value 
-        OMX_SetStateCmd, value is a member of OMX_StateType.  When Cmd has 
-        the value OMX_FlushCmd, value of nParam indicates which port(s) 
+        OMX_CommandStateSet, value is a member of OMX_STATETYPE.  When Cmd has 
+        the value OMX_CommandFlush, value of nParam indicates which port(s) 
         to flush. -1 is used to flush all ports a single port index will 
         only flush that port.  When Cmd has the value "OMX_CommandPortDisable"
         or "OMX_CommandPortEnable", the component's port is given by 
@@ -715,7 +756,7 @@
         "OMX_CommandMarkBuffer".     
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_SendCommand(                                    \
@@ -732,7 +773,7 @@
 
 /** The OMX_GetParameter macro will get one of the current parameter 
     settings from the component.  This macro cannot only be invoked when 
-    the component is in the OMX_IndalidState state.  The nParamIndex
+    the component is in the OMX_StateInvalid state.  The nParamIndex
     parameter is used to indicate which structure is being requested from
     the component.  The application shall allocate the correct structure 
     and shall fill in the structure size and version information before 
@@ -756,7 +797,7 @@
         component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_GetParameter(                                   \
@@ -772,7 +813,7 @@
 /** The OMX_SetParameter macro will send an initialization parameter
     structure to a component.  Each structure shall be sent one at a time,
     in a separate invocation of the macro.  This macro can only be
-    invoked when the component is in the OMX_LoadedState state, or the
+    invoked when the component is in the OMX_StateLoaded state, or the
     port is disabled (when the parameter applies to a port). The 
     nParamIndex parameter is used to indicate which structure is being
     passed to the component.  The application shall allocate the 
@@ -795,7 +836,7 @@
         initialization by the component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_SetParameter(                                   \
@@ -831,7 +872,7 @@
         component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
 */        
 #define OMX_GetConfig(                                      \
@@ -867,7 +908,7 @@
         initialization by the component.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_SetConfig(                                      \
@@ -901,7 +942,7 @@
         a pointer to a OMX_INDEXTYPE to receive the index value.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_GetExtensionIndex(                              \
@@ -928,7 +969,7 @@
         is one of the OMX_STATETYPE members 
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp
  */
 #define OMX_GetState(                                       \
@@ -954,7 +995,7 @@
         pointer to the buffer header
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
  */
 
@@ -998,7 +1039,7 @@
         size of the buffer to allocate.  Used when bAllocateNew is true.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
  */    
 #define OMX_AllocateBuffer(                                 \
@@ -1034,7 +1075,7 @@
         or AllocateBuffer.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
  */
 #define OMX_FreeBuffer(                                     \
@@ -1053,7 +1094,7 @@
     This is a non-blocking call in that the component will record the buffer
     and return immediately and then empty the buffer, later, at the proper 
     time.  As expected, this macro may be invoked only while the component 
-    is in the OMX_ExecutingState.  If nPortIndex does not specify an input
+    is in the OMX_StateExecuting.  If nPortIndex does not specify an input
     port, the component shall return an error.  
     
     The component should return from this call within 5 msec.
@@ -1066,7 +1107,7 @@
         or AllocateBuffer.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
  */
 #define OMX_EmptyThisBuffer(                                \
@@ -1096,7 +1137,7 @@
         or AllocateBuffer.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
  */
 #define OMX_FillThisBuffer(                                 \
@@ -1135,7 +1176,7 @@
         can use the EGLImage as a buffer.          
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup comp buf
  */
 #define OMX_UseEGLImage(                                    \
@@ -1144,7 +1185,7 @@
            nPortIndex,                                      \
            pAppPrivate,                                     \
            eglImage)                                        \
-    ((OMX_COMPONENTTYPE*)hComponent)->UseBuffer(            \
+    ((OMX_COMPONENTTYPE*)hComponent)->UseEGLImage(          \
            hComponent,                                      \
            ppBufferHdr,                                     \
            nPortIndex,                                      \
@@ -1159,7 +1200,7 @@
 
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup core
  */
 OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Init(void);
@@ -1174,7 +1215,7 @@
     
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup core
  */
 OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_Deinit(void);
@@ -1212,7 +1253,7 @@
         in the system.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  When the value of nIndex exceeds the number of 
+        OMX_ErrorNone.  When the value of nIndex exceeds the number of 
         components in the system minus 1, OMX_ErrorNoMore will be
         returned. Otherwise the appropriate OMX error will be returned.
     @ingroup core
@@ -1247,7 +1288,7 @@
         component to initialize it with.  
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup core
  */
 OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(
@@ -1269,7 +1310,7 @@
         handle returned by the call to the GetHandle function.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
     @ingroup core
  */
 OMX_API OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(
@@ -1317,7 +1358,7 @@
         used in the tunnel.
     @return OMX_ERRORTYPE
         If the command successfully executes, the return code will be
-        OMX_NoError.  Otherwise the appropriate OMX error will be returned.
+        OMX_ErrorNone.  Otherwise the appropriate OMX error will be returned.
         When OMX_ErrorNotImplemented is returned, one or both components is 
         a non-interop component and does not support tunneling.
         
diff --git a/extern_libs_v2/khronos/openmax/include/omx_image.h b/extern_libs_v2/khronos/openmax/include/omx_image.h
index 5e8cb21..ec4d495 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_image.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_image.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /**
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  */
 
 /** 
- * @file OMX_Image.h - OpenMax IL version 1.1
+ * @file omx_image.h - OpenMax IL version 1.1.2
  * The structures needed by Image components to exchange parameters and 
  * configuration data with the components.
  */
@@ -55,8 +55,7 @@
  * header to compile without errors.  The includes below are required  
  * for this header file to compile successfully 
  */
-#include <omx_types.h>
-#include <omx_core.h>
+
 #include <omx_ivcommon.h>
 
 /** @defgroup imaging OpenMAX IL Imaging Domain
@@ -79,6 +78,8 @@
     OMX_IMAGE_CodingPNG,         /**< PNG image format */
     OMX_IMAGE_CodingLZW,         /**< LZW image format */
     OMX_IMAGE_CodingBMP,         /**< Windows Bitmap format */
+    OMX_IMAGE_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_CodingMax = 0x7FFFFFFF
 } OMX_IMAGE_CODINGTYPE;
 
@@ -176,6 +177,8 @@
     OMX_IMAGE_FlashControlRedEyeReduction,
     OMX_IMAGE_FlashControlFillin,
     OMX_IMAGE_FlashControlTorch,
+    OMX_IMAGE_FlashControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_FlashControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_FlashControlMax = 0x7FFFFFFF
 } OMX_IMAGE_FLASHCONTROLTYPE;
 
@@ -205,6 +208,8 @@
     OMX_IMAGE_FocusControlOff,
     OMX_IMAGE_FocusControlAuto,
     OMX_IMAGE_FocusControlAutoLock,
+    OMX_IMAGE_FocusControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_FocusControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_FocusControlMax = 0x7FFFFFFF
 } OMX_IMAGE_FOCUSCONTROLTYPE;
 
@@ -262,6 +267,8 @@
     OMX_IMAGE_QuantizationTableChroma,
     OMX_IMAGE_QuantizationTableChromaCb,
     OMX_IMAGE_QuantizationTableChromaCr,
+    OMX_IMAGE_QuantizationTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_QuantizationTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_QuantizationTableMax = 0x7FFFFFFF
 } OMX_IMAGE_QUANTIZATIONTABLETYPE;
 
@@ -302,6 +309,8 @@
     OMX_IMAGE_HuffmanTableACChroma,
     OMX_IMAGE_HuffmanTableDCLuma,
     OMX_IMAGE_HuffmanTableDCChroma,
+    OMX_IMAGE_HuffmanTableKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_IMAGE_HuffmanTableVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_IMAGE_HuffmanTableMax = 0x7FFFFFFF
 } OMX_IMAGE_HUFFMANTABLETYPE;
 
diff --git a/extern_libs_v2/khronos/openmax/include/omx_index.h b/extern_libs_v2/khronos/openmax/include/omx_index.h
index f823a59..a1e5fb4 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_index.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_index.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** @file OMX_Index.h - OpenMax IL version 1.1
+/** @file omx_index.h - OpenMax IL version 1.1.2
  *  The OMX_Index header file contains the definitions for both applications
  *  and components .
  */
@@ -66,7 +66,7 @@
  *  are used, the second parameter will always be an entry from this enumeration
  *  and the third entry will be the structure shown in the comments for the entry.
  *  For example, if the application is initializing a cropping function, the 
- *  OMX_SetConfig command would have OMX_ConfigInputCrop as the second parameter 
+ *  OMX_SetConfig command would have OMX_IndexConfigCommonInputCrop as the second parameter 
  *  and would send a pointer to an initialized OMX_RECTTYPE structure as the 
  *  third parameter.
  *  
@@ -77,188 +77,189 @@
 typedef enum OMX_INDEXTYPE {
 
     OMX_IndexComponentStartUnused = 0x01000000,
-    OMX_IndexParamPriorityMgmt, /**< reference: OMX_PRIORITYMGMTTYPE */
-    OMX_IndexParamAudioInit, /**< reference: OMX_PORT_PARAM_TYPE  */
-    OMX_IndexParamImageInit, /**< reference: OMX_PORT_PARAM_TYPE  */
-    OMX_IndexParamVideoInit, /**< reference: OMX_PORT_PARAM_TYPE  */
-    OMX_IndexParamOtherInit, /**< reference: OMX_PORT_PARAM_TYPE  */
-    OMX_IndexParamNumAvailableStreams, /**< reference: OMX_PARAM_U32TYPE */
-    OMX_IndexParamActiveStream,        /**< reference: OMX_PARAM_U32TYPE */
-    OMX_IndexParamSuspensionPolicy,    /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */
-    OMX_IndexParamComponentSuspended,  /**< reference: OMX_PARAM_SUSPENSIONTYPE */
-    OMX_IndexConfigCapturing, /**< reference: OMX_CONFIG_BOOLEANTYPE */ 
-    OMX_IndexConfigCaptureMode, /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ 
-    OMX_IndexAutoPauseAfterCapture, /**< reference: OMX_CONFIG_BOOLEANTYPE */ 
-    OMX_IndexParamContentURI,  /**< reference: OMX_PARAM_CONTENTURITYPE */
-    OMX_IndexParamCustomContentPipe, /**< reference: OMX_PARAM_CONTENTPIPETYPE */ 
+    OMX_IndexParamPriorityMgmt,             /**< reference: OMX_PRIORITYMGMTTYPE */
+    OMX_IndexParamAudioInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamImageInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamVideoInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamOtherInit,                /**< reference: OMX_PORT_PARAM_TYPE */
+    OMX_IndexParamNumAvailableStreams,      /**< reference: OMX_PARAM_U32TYPE */
+    OMX_IndexParamActiveStream,             /**< reference: OMX_PARAM_U32TYPE */
+    OMX_IndexParamSuspensionPolicy,         /**< reference: OMX_PARAM_SUSPENSIONPOLICYTYPE */
+    OMX_IndexParamComponentSuspended,       /**< reference: OMX_PARAM_SUSPENSIONTYPE */
+    OMX_IndexConfigCapturing,               /**< reference: OMX_CONFIG_BOOLEANTYPE */ 
+    OMX_IndexConfigCaptureMode,             /**< reference: OMX_CONFIG_CAPTUREMODETYPE */ 
+    OMX_IndexAutoPauseAfterCapture,         /**< reference: OMX_CONFIG_BOOLEANTYPE */ 
+    OMX_IndexParamContentURI,               /**< reference: OMX_PARAM_CONTENTURITYPE */
+    OMX_IndexParamCustomContentPipe,        /**< reference: OMX_PARAM_CONTENTPIPETYPE */ 
     OMX_IndexParamDisableResourceConcealment, /**< reference: OMX_RESOURCECONCEALMENTTYPE */
-    OMX_IndexConfigMetaDataItemCount,        /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */
-    OMX_IndexConfigMetaDataSize,             /**< reference: OMX_CONFIG_METADATAITEMTYPE */
-    OMX_IndexConfigMetaDataAtIndex,          /**< reference: OMX_CONFIG_METADATAITEMTYPE */
-    OMX_IndexConfigMetaDataAtKey,            /**< reference: OMX_CONFIG_METADATAITEMTYPE */
-    OMX_IndexConfigMetaDataNodeCount,        /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */
-    OMX_IndexConfigMetaDataNode,             /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */
-    OMX_IndexParamMetadataKeyFilter,         /**< reference: OMX_PARAM_METADATAFILTERTYPE */
-    OMX_IndexConfigPriorityMgmt,             /**< reference: OMX_PRIORITYMGMTTYPE */
-    OMX_IndexParamStandardComponentRole,     /**< reference: OMX_PARAM_COMPONENTROLETYPE */
+    OMX_IndexConfigMetadataItemCount,       /**< reference: OMX_CONFIG_METADATAITEMCOUNTTYPE */
+    OMX_IndexConfigContainerNodeCount,      /**< reference: OMX_CONFIG_CONTAINERNODECOUNTTYPE */
+    OMX_IndexConfigMetadataItem,            /**< reference: OMX_CONFIG_METADATAITEMTYPE */
+    OMX_IndexConfigCounterNodeID,           /**< reference: OMX_CONFIG_CONTAINERNODEIDTYPE */
+    OMX_IndexParamMetadataFilterType,       /**< reference: OMX_PARAM_METADATAFILTERTYPE */
+    OMX_IndexParamMetadataKeyFilter,        /**< reference: OMX_PARAM_METADATAFILTERTYPE */
+    OMX_IndexConfigPriorityMgmt,            /**< reference: OMX_PRIORITYMGMTTYPE */
+    OMX_IndexParamStandardComponentRole,    /**< reference: OMX_PARAM_COMPONENTROLETYPE */
 
     OMX_IndexPortStartUnused = 0x02000000,
-    OMX_IndexParamPortDefinition, /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */
-    OMX_IndexParamCompBufferSupplier, /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE (*/ 
+    OMX_IndexParamPortDefinition,           /**< reference: OMX_PARAM_PORTDEFINITIONTYPE */
+    OMX_IndexParamCompBufferSupplier,       /**< reference: OMX_PARAM_BUFFERSUPPLIERTYPE */ 
     OMX_IndexReservedStartUnused = 0x03000000,
 
     /* Audio parameters and configurations */
     OMX_IndexAudioStartUnused = 0x04000000,
-    OMX_IndexParamAudioPortFormat, /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */
-    OMX_IndexParamAudioPcm,    /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */
-    OMX_IndexParamAudioAac,    /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */
-    OMX_IndexParamAudioRa,     /**< reference: OMX_AUDIO_PARAM_RATYPE */
-    OMX_IndexParamAudioMp3,    /**< reference: OMX_AUDIO_PARAM_MP3TYPE */
-    OMX_IndexParamAudioAdpcm,  /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */
-    OMX_IndexParamAudioG723,   /**< reference: OMX_AUDIO_PARAM_G723TYPE */
-    OMX_IndexParamAudioG729,   /**< reference: OMX_AUDIO_PARAM_G729TYPE */
-    OMX_IndexParamAudioAmr,    /**< reference: OMX_AUDIO_PARAM_AMRTYPE */
-    OMX_IndexParamAudioWma,    /**< reference: OMX_AUDIO_PARAM_WMATYPE */
-    OMX_IndexParamAudioSbc,    /**< reference: OMX_AUDIO_PARAM_SBCTYPE */
-    OMX_IndexParamAudioMidi,   /**< reference: OMX_AUDIO_PARAM_MIDITYPE */
-    OMX_IndexParamAudioGsm_FR, /**< reference: OMX_AUDIO_PARAM__GSMFRTYPE */
-    OMX_IndexParamAudioMidiLoadUserSound, /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */
-    OMX_IndexParamAudioG726,     /**< reference: OMX_AUDIO_PARAM_G726TYPE */
-    OMX_IndexParamAudioGsm_EFR,  /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */
-    OMX_IndexParamAudioGsm_HR,   /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */
-    OMX_IndexParamAudioPdc_FR,   /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */
-    OMX_IndexParamAudioPdc_EFR,  /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */
-    OMX_IndexParamAudioPdc_HR,   /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */
-    OMX_IndexParamAudioTdma_FR,  /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */
-    OMX_IndexParamAudioTdma_EFR, /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */
-    OMX_IndexParamAudioQcelp8,   /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */
-    OMX_IndexParamAudioQcelp13,  /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */
-    OMX_IndexParamAudioEvrc,     /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */
-    OMX_IndexParamAudioSmv,      /**< reference: OMX_AUDIO_PARAM_SMVTYPE */
-    OMX_IndexParamAudioVorbis,   /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */
+    OMX_IndexParamAudioPortFormat,          /**< reference: OMX_AUDIO_PARAM_PORTFORMATTYPE */
+    OMX_IndexParamAudioPcm,                 /**< reference: OMX_AUDIO_PARAM_PCMMODETYPE */
+    OMX_IndexParamAudioAac,                 /**< reference: OMX_AUDIO_PARAM_AACPROFILETYPE */
+    OMX_IndexParamAudioRa,                  /**< reference: OMX_AUDIO_PARAM_RATYPE */
+    OMX_IndexParamAudioMp3,                 /**< reference: OMX_AUDIO_PARAM_MP3TYPE */
+    OMX_IndexParamAudioAdpcm,               /**< reference: OMX_AUDIO_PARAM_ADPCMTYPE */
+    OMX_IndexParamAudioG723,                /**< reference: OMX_AUDIO_PARAM_G723TYPE */
+    OMX_IndexParamAudioG729,                /**< reference: OMX_AUDIO_PARAM_G729TYPE */
+    OMX_IndexParamAudioAmr,                 /**< reference: OMX_AUDIO_PARAM_AMRTYPE */
+    OMX_IndexParamAudioWma,                 /**< reference: OMX_AUDIO_PARAM_WMATYPE */
+    OMX_IndexParamAudioSbc,                 /**< reference: OMX_AUDIO_PARAM_SBCTYPE */
+    OMX_IndexParamAudioMidi,                /**< reference: OMX_AUDIO_PARAM_MIDITYPE */
+    OMX_IndexParamAudioGsm_FR,              /**< reference: OMX_AUDIO_PARAM_GSMFRTYPE */
+    OMX_IndexParamAudioMidiLoadUserSound,   /**< reference: OMX_AUDIO_PARAM_MIDILOADUSERSOUNDTYPE */
+    OMX_IndexParamAudioG726,                /**< reference: OMX_AUDIO_PARAM_G726TYPE */
+    OMX_IndexParamAudioGsm_EFR,             /**< reference: OMX_AUDIO_PARAM_GSMEFRTYPE */
+    OMX_IndexParamAudioGsm_HR,              /**< reference: OMX_AUDIO_PARAM_GSMHRTYPE */
+    OMX_IndexParamAudioPdc_FR,              /**< reference: OMX_AUDIO_PARAM_PDCFRTYPE */
+    OMX_IndexParamAudioPdc_EFR,             /**< reference: OMX_AUDIO_PARAM_PDCEFRTYPE */
+    OMX_IndexParamAudioPdc_HR,              /**< reference: OMX_AUDIO_PARAM_PDCHRTYPE */
+    OMX_IndexParamAudioTdma_FR,             /**< reference: OMX_AUDIO_PARAM_TDMAFRTYPE */
+    OMX_IndexParamAudioTdma_EFR,            /**< reference: OMX_AUDIO_PARAM_TDMAEFRTYPE */
+    OMX_IndexParamAudioQcelp8,              /**< reference: OMX_AUDIO_PARAM_QCELP8TYPE */
+    OMX_IndexParamAudioQcelp13,             /**< reference: OMX_AUDIO_PARAM_QCELP13TYPE */
+    OMX_IndexParamAudioEvrc,                /**< reference: OMX_AUDIO_PARAM_EVRCTYPE */
+    OMX_IndexParamAudioSmv,                 /**< reference: OMX_AUDIO_PARAM_SMVTYPE */
+    OMX_IndexParamAudioVorbis,              /**< reference: OMX_AUDIO_PARAM_VORBISTYPE */
 
-    OMX_IndexConfigAudioMidiImmediateEvent, /**< OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */
-    OMX_IndexConfigAudioMidiControl, /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */
+    OMX_IndexConfigAudioMidiImmediateEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIIMMEDIATEEVENTTYPE */
+    OMX_IndexConfigAudioMidiControl,        /**< reference: OMX_AUDIO_CONFIG_MIDICONTROLTYPE */
     OMX_IndexConfigAudioMidiSoundBankProgram, /**< reference: OMX_AUDIO_CONFIG_MIDISOUNDBANKPROGRAMTYPE */
-    OMX_IndexConfigAudioMidiStatus,  /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */
-    OMX_IndexConfigAudioMidiMetaEvent, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */
-    OMX_IndexConfigAudioMidiMetaEventData, /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */
-    OMX_IndexConfigAudioVolume,      /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */
-    OMX_IndexConfigAudioBalance,     /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */
-    OMX_IndexConfigAudioChannelMute, /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */
-    OMX_IndexConfigAudioMute,        /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */
-    OMX_IndexConfigAudioLoudness,    /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */
-    OMX_IndexConfigAudioEchoCancelation, /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */
-    OMX_IndexConfigAudioNoiseReduction,  /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */
-    OMX_IndexConfigAudioBass,        /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */
-    OMX_IndexConfigAudioTreble,      /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */
-    OMX_IndexConfigAudioStereoWidening, /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */
-    OMX_IndexConfigAudioChorus,      /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */
-    OMX_IndexConfigAudioEqualizer,   /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */
-    OMX_IndexConfigAudioReverberation, /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */
-    OMX_IndexConfigAudioChannelVolume, /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */
+    OMX_IndexConfigAudioMidiStatus,         /**< reference: OMX_AUDIO_CONFIG_MIDISTATUSTYPE */
+    OMX_IndexConfigAudioMidiMetaEvent,      /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTTYPE */
+    OMX_IndexConfigAudioMidiMetaEventData,  /**< reference: OMX_AUDIO_CONFIG_MIDIMETAEVENTDATATYPE */
+    OMX_IndexConfigAudioVolume,             /**< reference: OMX_AUDIO_CONFIG_VOLUMETYPE */
+    OMX_IndexConfigAudioBalance,            /**< reference: OMX_AUDIO_CONFIG_BALANCETYPE */
+    OMX_IndexConfigAudioChannelMute,        /**< reference: OMX_AUDIO_CONFIG_CHANNELMUTETYPE */
+    OMX_IndexConfigAudioMute,               /**< reference: OMX_AUDIO_CONFIG_MUTETYPE */
+    OMX_IndexConfigAudioLoudness,           /**< reference: OMX_AUDIO_CONFIG_LOUDNESSTYPE */
+    OMX_IndexConfigAudioEchoCancelation,    /**< reference: OMX_AUDIO_CONFIG_ECHOCANCELATIONTYPE */
+    OMX_IndexConfigAudioNoiseReduction,     /**< reference: OMX_AUDIO_CONFIG_NOISEREDUCTIONTYPE */
+    OMX_IndexConfigAudioBass,               /**< reference: OMX_AUDIO_CONFIG_BASSTYPE */
+    OMX_IndexConfigAudioTreble,             /**< reference: OMX_AUDIO_CONFIG_TREBLETYPE */
+    OMX_IndexConfigAudioStereoWidening,     /**< reference: OMX_AUDIO_CONFIG_STEREOWIDENINGTYPE */
+    OMX_IndexConfigAudioChorus,             /**< reference: OMX_AUDIO_CONFIG_CHORUSTYPE */
+    OMX_IndexConfigAudioEqualizer,          /**< reference: OMX_AUDIO_CONFIG_EQUALIZERTYPE */
+    OMX_IndexConfigAudioReverberation,      /**< reference: OMX_AUDIO_CONFIG_REVERBERATIONTYPE */
+    OMX_IndexConfigAudioChannelVolume,      /**< reference: OMX_AUDIO_CONFIG_CHANNELVOLUMETYPE */
 
     /* Image specific parameters and configurations */
     OMX_IndexImageStartUnused = 0x05000000,
-    OMX_IndexParamImagePortFormat,   /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */
-    OMX_IndexParamFlashControl,      /**< refer to OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
-    OMX_IndexConfigFocusControl,     /**< refer to OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */
-    OMX_IndexParamQFactor,           /**< refer to OMX_IMAGE_PARAM_QFACTORTYPE */
-    OMX_IndexParamQuantizationTable, /**< refer to OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */
-    OMX_IndexParamHuffmanTable,      /**< For jpeg, refer to OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */
-    OMX_IndexConfigFlashControl,      /**< refer to OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
+    OMX_IndexParamImagePortFormat,          /**< reference: OMX_IMAGE_PARAM_PORTFORMATTYPE */
+    OMX_IndexParamFlashControl,             /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
+    OMX_IndexConfigFocusControl,            /**< reference: OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE */
+    OMX_IndexParamQFactor,                  /**< reference: OMX_IMAGE_PARAM_QFACTORTYPE */
+    OMX_IndexParamQuantizationTable,        /**< reference: OMX_IMAGE_PARAM_QUANTIZATIONTABLETYPE */
+    OMX_IndexParamHuffmanTable,             /**< reference: OMX_IMAGE_PARAM_HUFFMANTTABLETYPE */
+    OMX_IndexConfigFlashControl,            /**< reference: OMX_IMAGE_PARAM_FLASHCONTROLTYPE */
 
     /* Video specific parameters and configurations */
     OMX_IndexVideoStartUnused = 0x06000000,
-    OMX_IndexParamVideoPortFormat,   /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */
-    OMX_IndexParamVideoQuantization, /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONPARAMTYPE */
-    OMX_IndexParamVideoFastUpdate,   /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */
-    OMX_IndexParamVideoBitrate,      /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */
-    OMX_IndexParamVideoMotionVector,    /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */
-    OMX_IndexParamVideoIntraRefresh,    /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */
-    OMX_IndexParamVideoErrorCorrection, /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */
-    OMX_IndexParamVideoVBSMC, /**< reference:OMX_VIDEO_PARAM_VBSMCTYPE */
-    OMX_IndexParamVideoMpeg2, /**< reference:OMX_VIDEO_PARAM_MPEG2TYPE */
-    OMX_IndexParamVideoMpeg4, /**< reference: OMX_VIDEO_CONFIG_MPEG4TYPE */
-    OMX_IndexParamVideoWmv,   /**< reference:OMX_VIDEO_PARAM_WMVTYPE */
-    OMX_IndexParamVideoRv,    /**< reference:OMX_VIDEO_PARAM_RVTYPE */
-    OMX_IndexParamVideoAvc,   /**< reference:OMX_VIDEO_PARAM_AVCTYPE */
-    OMX_IndexParamVideoH263,  /**< reference:OMX_VIDEO_PARAM_H263TYPE */
-    OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference:OMX_VIDEO_PARAM_PROFILELEVEL */
-    OMX_IndexParamVideoProfileLevelCurrent, /**< reference:OMX_VIDEO_PARAM_PROFILELEVEL */
-    OMX_IndexConfigVideoBitrate, /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */
-    OMX_IndexConfigVideoFramerate, /**< reference:OMX_VIDEO_CONFIG_FRAMERATETYPE */
-    OMX_IndexConfigVideoIntraVOPRefresh, /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */
-    OMX_IndexConfigVideoIntraMBRefresh, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
-    OMX_IndexConfigVideoMBErrorReporting, /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */
+    OMX_IndexParamVideoPortFormat,          /**< reference: OMX_VIDEO_PARAM_PORTFORMATTYPE */
+    OMX_IndexParamVideoQuantization,        /**< reference: OMX_VIDEO_PARAM_QUANTIZATIONTYPE */
+    OMX_IndexParamVideoFastUpdate,          /**< reference: OMX_VIDEO_PARAM_VIDEOFASTUPDATETYPE */
+    OMX_IndexParamVideoBitrate,             /**< reference: OMX_VIDEO_PARAM_BITRATETYPE */
+    OMX_IndexParamVideoMotionVector,        /**< reference: OMX_VIDEO_PARAM_MOTIONVECTORTYPE */
+    OMX_IndexParamVideoIntraRefresh,        /**< reference: OMX_VIDEO_PARAM_INTRAREFRESHTYPE */
+    OMX_IndexParamVideoErrorCorrection,     /**< reference: OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE */
+    OMX_IndexParamVideoVBSMC,               /**< reference: OMX_VIDEO_PARAM_VBSMCTYPE */
+    OMX_IndexParamVideoMpeg2,               /**< reference: OMX_VIDEO_PARAM_MPEG2TYPE */
+    OMX_IndexParamVideoMpeg4,               /**< reference: OMX_VIDEO_PARAM_MPEG4TYPE */
+    OMX_IndexParamVideoWmv,                 /**< reference: OMX_VIDEO_PARAM_WMVTYPE */
+    OMX_IndexParamVideoRv,                  /**< reference: OMX_VIDEO_PARAM_RVTYPE */
+    OMX_IndexParamVideoAvc,                 /**< reference: OMX_VIDEO_PARAM_AVCTYPE */
+    OMX_IndexParamVideoH263,                /**< reference: OMX_VIDEO_PARAM_H263TYPE */
+    OMX_IndexParamVideoProfileLevelQuerySupported, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */
+    OMX_IndexParamVideoProfileLevelCurrent, /**< reference: OMX_VIDEO_PARAM_PROFILELEVELTYPE */
+    OMX_IndexConfigVideoBitrate,            /**< reference: OMX_VIDEO_CONFIG_BITRATETYPE */
+    OMX_IndexConfigVideoFramerate,          /**< reference: OMX_CONFIG_FRAMERATETYPE */
+    OMX_IndexConfigVideoIntraVOPRefresh,    /**< reference: OMX_CONFIG_INTRAREFRESHVOPTYPE */
+    OMX_IndexConfigVideoIntraMBRefresh,     /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
+    OMX_IndexConfigVideoMBErrorReporting,   /**< reference: OMX_CONFIG_MBERRORREPORTINGTYPE */
     OMX_IndexParamVideoMacroblocksPerFrame, /**< reference: OMX_PARAM_MACROBLOCKSTYPE */
     OMX_IndexConfigVideoMacroBlockErrorMap, /**< reference: OMX_CONFIG_MACROBLOCKERRORMAPTYPE */
-    OMX_IndexParamVideoSliceFMO, /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */
-    OMX_IndexConfigVideoAVCIntraPeriod, /** reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */
-    OMX_IndexConfigVideoNalSize, /** reference: OMX_VIDEO_CONFIG_NALSIZE */
+    OMX_IndexParamVideoSliceFMO,            /**< reference: OMX_VIDEO_PARAM_AVCSLICEFMO */
+    OMX_IndexConfigVideoAVCIntraPeriod,     /**< reference: OMX_VIDEO_CONFIG_AVCINTRAPERIOD */
+    OMX_IndexConfigVideoNalSize,            /**< reference: OMX_VIDEO_CONFIG_NALSIZE */
 
     /* Image & Video common Configurations */
     OMX_IndexCommonStartUnused = 0x07000000,
-    OMX_IndexParamCommonDeblocking, /**< reference: OMX_PARAM_DEBLOCKINGTYPE */
-    OMX_IndexParamCommonSensorMode, /**< reference: OMX_PARAM_SENSORMODETYPE */
-    OMX_IndexParamCommonInterleave, /** reference: OMX_PARAM_INTERLEAVETYPE */
-    OMX_IndexConfigCommonColorFormatConversion,   /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */
-    OMX_IndexConfigCommonScale,  /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
-    OMX_IndexConfigCommonImageFilter, /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */
-    OMX_IndexConfigCommonColorEnhancement, /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */
-    OMX_IndexConfigCommonColorKey, /**< reference: OMX_CONFIG_COLORKEYTYPE */
-    OMX_IndexConfigCommonColorBlend, /**< reference: OMX_CONFIG_COLORBLENDTYPE */
-    OMX_IndexConfigCommonFrameStabilisation, /**< reference: OMX_CONFIG_FRAMESTABTYPE */
-    OMX_IndexConfigCommonRotate, /**< reference: OMX_CONFIG_ROTATIONTYPE */
-    OMX_IndexConfigCommonMirror, /**< reference: OMX_CONFIG_MIRRORTYPE */
-    OMX_IndexConfigCommonOutputPosition, /**< reference: OMX_CONFIG_POINTTYPE */
-    OMX_IndexConfigCommonInputCrop, /**< reference: OMX_CONFIG_RECTTYPE */
-    OMX_IndexConfigCommonOutputCrop, /**< reference: OMX_CONFIG_RECTTYPE */
-    OMX_IndexConfigCommonDigitalZoom,  /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
-    OMX_IndexConfigCommonOpticalZoom, /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/
-    OMX_IndexConfigCommonWhiteBalance, /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */
-    OMX_IndexConfigCommonExposure, /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */
-    OMX_IndexConfigCommonContrast, /**< reference to OMX_CONFIG_CONTRASTTYPE */
-    OMX_IndexConfigCommonBrightness, /**< reference to OMX_CONFIG_BRIGHTNESSTYPE */
-    OMX_IndexConfigCommonBacklight, /**< reference to OMX_CONFIG_BACKLIGHTTYPE */
-    OMX_IndexConfigCommonGamma, /**< reference to OMX_CONFIG_GAMMATYPE */
-    OMX_IndexConfigCommonSaturation, /**< reference to OMX_CONFIG_SATURATIONTYPE */
-    OMX_IndexConfigCommonLightness, /**< reference to OMX_CONFIG_LIGHTNESSTYPE */
-    OMX_IndexConfigCommonExclusionRect, /** reference: OMX_CONFIG_RECTTYPE */
-    OMX_IndexConfigCommonDithering, /**< reference: OMX_TIME_CONFIG_DITHERTYPE */
-    OMX_IndexConfigCommonPlaneBlend, /** reference: OMX_CONFIG_PLANEBLENDTYPE */
-    OMX_IndexConfigCommonExposureValue,  /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */
-    OMX_IndexConfigCommonOutputSize, /**< reference: OMX_FRAMESIZETYPE */
-    OMX_IndexParamCommonExtraQuantData, /**< reference: OMX_OTHER_EXTRADATATYPE */
-    OMX_IndexConfigCommonFocusRegion,      /**< refer to OMX_PARAM_FOCUSREGIONTYPE */
-    OMX_IndexConfigCommonFocusStatus,      /**< refer to OMX_IMAGE_CONFIG_FOCUSSTATUSTYPE */
+    OMX_IndexParamCommonDeblocking,         /**< reference: OMX_PARAM_DEBLOCKINGTYPE */
+    OMX_IndexParamCommonSensorMode,         /**< reference: OMX_PARAM_SENSORMODETYPE */
+    OMX_IndexParamCommonInterleave,         /**< reference: OMX_PARAM_INTERLEAVETYPE */
+    OMX_IndexConfigCommonColorFormatConversion, /**< reference: OMX_CONFIG_COLORCONVERSIONTYPE */
+    OMX_IndexConfigCommonScale,             /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
+    OMX_IndexConfigCommonImageFilter,       /**< reference: OMX_CONFIG_IMAGEFILTERTYPE */
+    OMX_IndexConfigCommonColorEnhancement,  /**< reference: OMX_CONFIG_COLORENHANCEMENTTYPE */
+    OMX_IndexConfigCommonColorKey,          /**< reference: OMX_CONFIG_COLORKEYTYPE */
+    OMX_IndexConfigCommonColorBlend,        /**< reference: OMX_CONFIG_COLORBLENDTYPE */
+    OMX_IndexConfigCommonFrameStabilisation,/**< reference: OMX_CONFIG_FRAMESTABTYPE */
+    OMX_IndexConfigCommonRotate,            /**< reference: OMX_CONFIG_ROTATIONTYPE */
+    OMX_IndexConfigCommonMirror,            /**< reference: OMX_CONFIG_MIRRORTYPE */
+    OMX_IndexConfigCommonOutputPosition,    /**< reference: OMX_CONFIG_POINTTYPE */
+    OMX_IndexConfigCommonInputCrop,         /**< reference: OMX_CONFIG_RECTTYPE */
+    OMX_IndexConfigCommonOutputCrop,        /**< reference: OMX_CONFIG_RECTTYPE */
+    OMX_IndexConfigCommonDigitalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE */
+    OMX_IndexConfigCommonOpticalZoom,       /**< reference: OMX_CONFIG_SCALEFACTORTYPE*/
+    OMX_IndexConfigCommonWhiteBalance,      /**< reference: OMX_CONFIG_WHITEBALCONTROLTYPE */
+    OMX_IndexConfigCommonExposure,          /**< reference: OMX_CONFIG_EXPOSURECONTROLTYPE */
+    OMX_IndexConfigCommonContrast,          /**< reference: OMX_CONFIG_CONTRASTTYPE */
+    OMX_IndexConfigCommonBrightness,        /**< reference: OMX_CONFIG_BRIGHTNESSTYPE */
+    OMX_IndexConfigCommonBacklight,         /**< reference: OMX_CONFIG_BACKLIGHTTYPE */
+    OMX_IndexConfigCommonGamma,             /**< reference: OMX_CONFIG_GAMMATYPE */
+    OMX_IndexConfigCommonSaturation,        /**< reference: OMX_CONFIG_SATURATIONTYPE */
+    OMX_IndexConfigCommonLightness,         /**< reference: OMX_CONFIG_LIGHTNESSTYPE */
+    OMX_IndexConfigCommonExclusionRect,     /**< reference: OMX_CONFIG_RECTTYPE */
+    OMX_IndexConfigCommonDithering,         /**< reference: OMX_CONFIG_DITHERTYPE */
+    OMX_IndexConfigCommonPlaneBlend,        /**< reference: OMX_CONFIG_PLANEBLENDTYPE */
+    OMX_IndexConfigCommonExposureValue,     /**< reference: OMX_CONFIG_EXPOSUREVALUETYPE */
+    OMX_IndexConfigCommonOutputSize,        /**< reference: OMX_FRAMESIZETYPE */
+    OMX_IndexParamCommonExtraQuantData,     /**< reference: OMX_OTHER_EXTRADATATYPE */
+    OMX_IndexConfigCommonFocusRegion,       /**< reference: OMX_CONFIG_FOCUSREGIONTYPE */
+    OMX_IndexConfigCommonFocusStatus,       /**< reference: OMX_PARAM_FOCUSSTATUSTYPE */
+    OMX_IndexConfigCommonTransitionEffect,  /**< reference: OMX_CONFIG_TRANSITIONEFFECTTYPE */
 
     /* Reserved Configuration range */
     OMX_IndexOtherStartUnused = 0x08000000,
-    OMX_IndexParamOtherPortFormat, /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */
-    OMX_IndexConfigOtherPower, /**< reference: OMX_OTHER_CONFIG_POWERTYPE */
-    OMX_IndexConfigOtherStats, /**< reference: OMX_OTHER_CONFIG_STATSTYPE */
+    OMX_IndexParamOtherPortFormat,          /**< reference: OMX_OTHER_PARAM_PORTFORMATTYPE */
+    OMX_IndexConfigOtherPower,              /**< reference: OMX_OTHER_CONFIG_POWERTYPE */
+    OMX_IndexConfigOtherStats,              /**< reference: OMX_OTHER_CONFIG_STATSTYPE */
 
 
     /* Reserved Time range */
     OMX_IndexTimeStartUnused = 0x09000000,
-    OMX_IndexConfigTimeScale, /**< reference: OMX_TIME_CONFIG_SCALETYPE */
-    OMX_IndexConfigTimeClockState,  /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */
-    OMX_IndexConfigTimeActiveRefClock, /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */
-    OMX_IndexConfigTimeCurrentMediaTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only)*/
-    OMX_IndexConfigTimeCurrentWallTime, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only)*/
+    OMX_IndexConfigTimeScale,               /**< reference: OMX_TIME_CONFIG_SCALETYPE */
+    OMX_IndexConfigTimeClockState,          /**< reference: OMX_TIME_CONFIG_CLOCKSTATETYPE */
+    OMX_IndexConfigTimeActiveRefClock,      /**< reference: OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE */
+    OMX_IndexConfigTimeCurrentMediaTime,    /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */
+    OMX_IndexConfigTimeCurrentWallTime,     /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (read only) */
     OMX_IndexConfigTimeCurrentAudioReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
     OMX_IndexConfigTimeCurrentVideoReference, /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
-    OMX_IndexConfigTimeMediaTimeRequest, /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */
-    OMX_IndexConfigTimeClientStartTime,  /**<reference:  OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
-    OMX_IndexConfigTimePosition,  /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */
-    OMX_IndexConfigTimeSeekMode,  /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */
+    OMX_IndexConfigTimeMediaTimeRequest,    /**< reference: OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE (write only) */
+    OMX_IndexConfigTimeClientStartTime,     /**<reference:  OMX_TIME_CONFIG_TIMESTAMPTYPE (write only) */
+    OMX_IndexConfigTimePosition,            /**< reference: OMX_TIME_CONFIG_TIMESTAMPTYPE */
+    OMX_IndexConfigTimeSeekMode,            /**< reference: OMX_TIME_CONFIG_SEEKMODETYPE */
 
 
+    OMX_IndexKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
     /* Vendor specific area */
-    OMX_IndexIndexVendorStartUnused = 0xFF000000,
-    /* Vendor specific structures should be in the range of 0xFF000000 
-       to 0xFFFFFFFF.  This range is not broken out by vendor, so
+    OMX_IndexVendorStartUnused = 0x7F000000,
+    /* Vendor specific structures should be in the range of 0x7F000000 
+       to 0x7FFFFFFE.  This range is not broken out by vendor, so
        private indexes are not guaranteed unique and therefore should
        only be sent to the appropriate component. */
 
diff --git a/extern_libs_v2/khronos/openmax/include/omx_ivcommon.h b/extern_libs_v2/khronos/openmax/include/omx_ivcommon.h
index de3af81..9b35c26 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_ivcommon.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_ivcommon.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /**
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -39,7 +39,7 @@
  */
 
 /** 
- * @file OMX_IVCommon.h - OpenMax IL version 1.1
+ * @file omx_ivcommon.h - OpenMax IL version 1.1.2
  *  The structures needed by Video and Image components to exchange
  *  parameters and configuration data with the components.
  */
@@ -55,7 +55,7 @@
  * to compile without errors.  The includes below are required for this header
  * file to compile successfully 
  */
-#include <omx_types.h>
+
 #include <omx_core.h>
 
 /** @defgroup iv OpenMAX IL Imaging and Video Domain
@@ -147,6 +147,8 @@
     OMX_COLOR_Format18BitBGR666,
     OMX_COLOR_Format24BitARGB6666,
     OMX_COLOR_Format24BitABGR6666,
+    OMX_COLOR_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_COLOR_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_COLOR_FormatMax = 0x7FFFFFFF
 } OMX_COLOR_FORMATTYPE;
 
@@ -194,6 +196,8 @@
     OMX_ImageFilterAntialias, 
     OMX_ImageFilterDeRing,       
     OMX_ImageFilterSolarize,
+    OMX_ImageFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_ImageFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_ImageFilterMax = 0x7FFFFFFF
 } OMX_IMAGEFILTERTYPE;
 
@@ -278,6 +282,8 @@
     OMX_ColorBlendAnd,
     OMX_ColorBlendOr,
     OMX_ColorBlendInvert,
+    OMX_ColorBlendKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_ColorBlendVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_ColorBlendMax = 0x7FFFFFFF
 } OMX_COLORBLENDTYPE;
 
@@ -351,6 +357,8 @@
     OMX_MirrorVertical,
     OMX_MirrorHorizontal,
     OMX_MirrorBoth, 
+    OMX_MirrorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MirrorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_MirrorMax = 0x7FFFFFFF   
 } OMX_MIRRORTYPE;
 
@@ -466,6 +474,8 @@
     OMX_WhiteBalControlIncandescent,
     OMX_WhiteBalControlFlash,
     OMX_WhiteBalControlHorizon,
+    OMX_WhiteBalControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_WhiteBalControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_WhiteBalControlMax = 0x7FFFFFFF
 } OMX_WHITEBALCONTROLTYPE;
 
@@ -501,6 +511,8 @@
     OMX_ExposureControlBeach,
     OMX_ExposureControlLargeAperture,
     OMX_ExposureControlSmallApperture,
+    OMX_ExposureControlKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_ExposureControlVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_ExposureControlMax = 0x7FFFFFFF
 } OMX_EXPOSURECONTROLTYPE;
 
@@ -705,6 +717,8 @@
     OMX_EffectDissolve,
     OMX_EffectWipe,
     OMX_EffectUnspecifiedMixOfTwoScenes,
+    OMX_EffectKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_EffectVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_EffectMax = 0x7FFFFFFF
 } OMX_TRANSITIONEFFECTTYPE;
 
@@ -736,6 +750,8 @@
     OMX_DataUnitVideoSegment,
     OMX_DataUnitSeveralSegments,
     OMX_DataUnitArbitraryStreamSection,
+    OMX_DataUnitKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_DataUnitVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_DataUnitMax = 0x7FFFFFFF
 } OMX_DATAUNITTYPE;
 
@@ -749,6 +765,8 @@
     OMX_DataEncapsulationElementaryStream,
     OMX_DataEncapsulationGenericPayload,
     OMX_DataEncapsulationRtpPayload,
+    OMX_DataEncapsulationKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_DataEncapsulationVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_DataEncapsulationMax = 0x7FFFFFFF
 } OMX_DATAUNITENCAPSULATIONTYPE;
 
@@ -773,6 +791,8 @@
     OMX_DitherOrdered,
     OMX_DitherErrorDiffusion,
     OMX_DitherOther,
+    OMX_DitherKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_DitherVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_DitherMax = 0x7FFFFFFF
 } OMX_DITHERTYPE;
 
@@ -808,7 +828,9 @@
     OMX_MeteringModeSpot,  	      /**< Spot (partial) metering. */
     OMX_MeteringModeMatrix,      /**< Matrix or evaluative metering. */
  
-    OMX_EVModeMax = 0x7ffffff
+    OMX_MeteringKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_MeteringVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
+    OMX_EVModeMax = 0x7fffffff
 } OMX_METERINGTYPE;
  
 typedef struct OMX_CONFIG_EXPOSUREVALUETYPE {
@@ -866,6 +888,8 @@
     OMX_FocusStatusReached,
     OMX_FocusStatusUnableToReach,
     OMX_FocusStatusLost,
+    OMX_FocusStatusKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_FocusStatusVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_FocusStatusMax = 0x7FFFFFFF
 } OMX_FOCUSSTATUSTYPE;
 
diff --git a/extern_libs_v2/khronos/openmax/include/omx_other.h b/extern_libs_v2/khronos/openmax/include/omx_other.h
index 1cfab20..07bec3d 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_other.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_other.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** @file OMX_Other.h - OpenMax IL version 1.1
+/** @file omx_other.h - OpenMax IL version 1.1.2
  *  The structures needed by Other components to exchange
  *  parameters and configuration data with the components.
  */
@@ -55,7 +55,7 @@
  *  header to compile without errors.  The includes below are required
  *  for this header file to compile successfully 
  */
-#include <omx_types.h>
+
 #include <omx_core.h>
 
 
@@ -75,6 +75,8 @@
     OMX_OTHER_FormatVendorReserved = 1000, /**< Starting value for vendor specific 
                                                 formats */
 
+    OMX_OTHER_FormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_OTHER_FormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_OTHER_FormatMax = 0x7FFFFFFF
 } OMX_OTHER_FORMATTYPE;
 
@@ -90,6 +92,8 @@
                                 * position over an approximation
                                 * of the requested seek position even
                                 * if it results in a slower seek. */
+    OMX_TIME_SeekModeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_TIME_SeekModeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_TIME_SeekModeMax = 0x7FFFFFFF
 } OMX_TIME_SEEKMODETYPE;
 
@@ -107,8 +111,8 @@
  *     time
  * OMX_IndexConfigTimeCurrentMediaTime: query of the CC’s current media
  *     time
- * OMX_IndexConfigTimeAudioReferenceTime and  
- * OMX_IndexConfigTimeVideoReferenceTime: audio/video reference 
+ * OMX_IndexConfigTimeCurrentAudioReference and  
+ * OMX_IndexConfigTimeCurrentVideoReference: audio/video reference 
  *     clock sending SC its reference time
  * OMX_IndexConfigTimeClientStartTime: a Clock Component client sends 
  *     this structure to the Clock Component via a SetConfig on its 
@@ -135,6 +139,8 @@
       OMX_TIME_UpdateRequestFulfillment,    /**< Update is the fulfillment of a media time request. */
       OMX_TIME_UpdateScaleChanged,	        /**< Update was generated because the scale chagned. */
       OMX_TIME_UpdateClockStateChanged,     /**< Update was generated because the clock state changed. */
+      OMX_TIME_UpdateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+      OMX_TIME_UpdateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
       OMX_TIME_UpdateMax = 0x7FFFFFFF
 } OMX_TIME_UPDATETYPE;
 
@@ -143,6 +149,8 @@
       OMX_TIME_RefClockNone,    /**< Use no references. */
       OMX_TIME_RefClockAudio,	/**< Use references sent through OMX_IndexConfigTimeCurrentAudioReference */
       OMX_TIME_RefClockVideo,   /**< Use references sent through OMX_IndexConfigTimeCurrentVideoReference */
+      OMX_TIME_RefClockKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+      OMX_TIME_RefClockVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
       OMX_TIME_RefClockMax = 0x7FFFFFFF
 } OMX_TIME_REFCLOCKTYPE;
 
@@ -153,6 +161,8 @@
                                                *   prescribed clients emit their
                                                *   start time. */
       OMX_TIME_ClockStateStopped,             /**< Clock stopped. */
+      OMX_TIME_ClockStateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+      OMX_TIME_ClockStateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
       OMX_TIME_ClockStateMax = 0x7FFFFFFF
 } OMX_TIME_CLOCKSTATE;
 
@@ -254,7 +264,7 @@
                                      * scaling the media time */
 } OMX_TIME_CONFIG_SCALETYPE;
  
-/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG’s nWaitMask field */
+/** Bits used to identify a clock port. Used in OMX_TIME_CONFIG_CLOCKSTATETYPE’s nWaitMask field */
 #define OMX_CLOCKPORT0 0x00000001
 #define OMX_CLOCKPORT1 0x00000002
 #define OMX_CLOCKPORT2 0x00000004
@@ -298,7 +308,8 @@
     OMX_TIME_REFCLOCKTYPE eClock;   /**< Reference clock used to compute media time */                        
 } OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE;
 
-/** Descriptor for setting specifics of power type. */
+/** Descriptor for setting specifics of power type.
+ *  Note: this structure is listed for backwards compatibility. */
 typedef struct OMX_OTHER_CONFIG_POWERTYPE {
     OMX_U32 nSize;            /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
@@ -306,7 +317,8 @@
 } OMX_OTHER_CONFIG_POWERTYPE;
 
 
-/** Descriptor for setting specifics of stats type. */
+/** Descriptor for setting specifics of stats type.
+ *  Note: this structure is listed for backwards compatibility. */
 typedef struct OMX_OTHER_CONFIG_STATSTYPE {
     OMX_U32 nSize;            /**< size of the structure in bytes */
     OMX_VERSIONTYPE nVersion; /**< OMX specification version information */
diff --git a/extern_libs_v2/khronos/openmax/include/omx_types.h b/extern_libs_v2/khronos/openmax/include/omx_types.h
index 28a9768..355434b 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_types.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /*
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -38,7 +38,7 @@
  *
  */
 
-/** OMX_Types.h - OpenMax IL version 1.1
+/** omx_types.h - OpenMax IL version 1.1.2
  *  The OMX_Types header file contains the primitive type definitions used by 
  *  the core, the application and the component.  This file may need to be
  *  modified to be used on systems that do not have "char" set to 8 bits, 
@@ -55,62 +55,59 @@
 /** The OMX_API and OMX_APIENTRY are platform specific definitions used
  *  to declare OMX function prototypes.  They are modified to meet the
  *  requirements for a particular platform */
-#ifdef _WIN32
+#ifdef __SYMBIAN32__   
 #   ifdef __OMX_EXPORTS
 #       define OMX_API __declspec(dllexport)
 #   else
-//#       define OMX_API __declspec(dllimport)
-#define OMX_API 
+#       ifdef _WIN32
+#           define OMX_API __declspec(dllexport) 
+#       else
+#           define OMX_API __declspec(dllimport)
+#       endif
 #   endif
 #else
-#   ifdef __OMX_EXPORTS
-#       define OMX_API
+#   ifdef _WIN32
+#      ifdef __OMX_EXPORTS
+#          define OMX_API __declspec(dllexport)
+#      else
+//#          define OMX_API __declspec(dllimport)
+#define OMX_API
+#      endif
 #   else
-#       define OMX_API extern
+#      ifdef __OMX_EXPORTS
+#          define OMX_API
+#      else
+#          define OMX_API extern
+#      endif
 #   endif
 #endif
 
-#ifdef __SYMBIAN32__
-#   ifdef __OMX_EXPORTS
-#       define OMX_API EXPORT_C
-#   else
-#       define OMX_API IMPORT_C
-#   endif
-#elif defined(_WIN32)
-#   ifdef __OMX_EXPORTS
-#       define OMX_API __declspec(dllexport)
-#   else
-//#       define OMX_API __declspec(dllimport)
-#define OMX_API 
-#   endif
-#else
-#   ifdef __OMX_EXPORTS
-#       define OMX_API
-#   else
-#       define OMX_API extern
-#   endif
-#endif
-
-
+#ifndef OMX_APIENTRY
 #define OMX_APIENTRY 
-
+#endif 
 
 /** OMX_IN is used to identify inputs to an OMX function.  This designation 
     will also be used in the case of a pointer that points to a parameter 
     that is used as an output. */
+#ifndef OMX_IN
 #define OMX_IN
+#endif
 
 /** OMX_OUT is used to identify outputs from an OMX function.  This 
     designation will also be used in the case of a pointer that points 
     to a parameter that is used as an input. */
+#ifndef OMX_OUT
 #define OMX_OUT
+#endif
 
 
 /** OMX_INOUT is used to identify parameters that may be either inputs or
     outputs from an OMX function at the same time.  This designation will 
     also be used in the case of a pointer that  points to a parameter that 
     is used both as an input and an output. */
+#ifndef OMX_INOUT
 #define OMX_INOUT
+#endif
 
 /** OMX_ALL is used to as a wildcard to select all entities of the same type
  *  when specifying the index, or referring to a object by an index.  (i.e.
diff --git a/extern_libs_v2/khronos/openmax/include/omx_video.h b/extern_libs_v2/khronos/openmax/include/omx_video.h
index 8c634f9..1c090b4 100644
--- a/extern_libs_v2/khronos/openmax/include/omx_video.h
+++ b/extern_libs_v2/khronos/openmax/include/omx_video.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 /**
- * Copyright (c) 2005 The Khronos Group Inc. 
+ * Copyright (c) 2008 The Khronos Group Inc. 
  * 
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -39,7 +39,7 @@
  */
 
 /** 
- *  @file OMX_Video.h - OpenMax IL version 1.1
+ *  @file omx_video.h - OpenMax IL version 1.1.2
  *  The structures is needed by Video components to exchange parameters 
  *  and configuration data with OMX components.
  */
@@ -62,8 +62,7 @@
  * header to compile without errors.  The includes below are required
  * for this header file to compile successfully 
  */
-#include <omx_types.h>
-#include <omx_core.h>
+
 #include <omx_ivcommon.h>
 
 
@@ -86,6 +85,8 @@
     OMX_VIDEO_CodingRV,         /**< all versions of Real Video */
     OMX_VIDEO_CodingAVC,        /**< H.264/AVC */
     OMX_VIDEO_CodingMJPEG,      /**< Motion JPEG */
+    OMX_VIDEO_CodingKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_CodingVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_CodingMax = 0x7FFFFFFF
 } OMX_VIDEO_CODINGTYPE;
 
@@ -235,6 +236,8 @@
     OMX_Video_ControlRateConstant,
     OMX_Video_ControlRateVariableSkipFrames,
     OMX_Video_ControlRateConstantSkipFrames,
+    OMX_Video_ControlRateKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_Video_ControlRateVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_Video_ControlRateMax = 0x7FFFFFFF
 } OMX_VIDEO_CONTROLRATETYPE;
 
@@ -266,6 +269,8 @@
     OMX_Video_MotionVectorHalfPel,
     OMX_Video_MotionVectorQuarterPel,
     OMX_Video_MotionVectorEighthPel,
+    OMX_Video_MotionVectorKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_Video_MotionVectorVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_Video_MotionVectorMax = 0x7FFFFFFF
 } OMX_VIDEO_MOTIONVECTORTYPE;
 
@@ -303,6 +308,8 @@
     OMX_VIDEO_IntraRefreshCyclic,
     OMX_VIDEO_IntraRefreshAdaptive,
     OMX_VIDEO_IntraRefreshBoth,
+    OMX_VIDEO_IntraRefreshKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_IntraRefreshVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_IntraRefreshMax = 0x7FFFFFFF
 } OMX_VIDEO_INTRAREFRESHTYPE;
 
@@ -424,6 +431,8 @@
     OMX_VIDEO_H263ProfileInternet            = 0x40,            
     OMX_VIDEO_H263ProfileInterlace           = 0x80,           
     OMX_VIDEO_H263ProfileHighLatency         = 0x100,         
+    OMX_VIDEO_H263ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_H263ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_H263ProfileMax                 = 0x7FFFFFFF  
 } OMX_VIDEO_H263PROFILETYPE;
 
@@ -441,6 +450,8 @@
     OMX_VIDEO_H263Level50  = 0x20,      
     OMX_VIDEO_H263Level60  = 0x40,      
     OMX_VIDEO_H263Level70  = 0x80, 
+    OMX_VIDEO_H263LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_H263LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_H263LevelMax = 0x7FFFFFFF  
 } OMX_VIDEO_H263LEVELTYPE;
 
@@ -464,6 +475,8 @@
     OMX_VIDEO_PictureTypeEI  = 0x11,
     OMX_VIDEO_PictureTypeEP  = 0x12,
     OMX_VIDEO_PictureTypeS   = 0x14,
+    OMX_VIDEO_PictureTypeKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_PictureTypeVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_PictureTypeMax = 0x7FFFFFFF
 } OMX_VIDEO_PICTURETYPE;
 
@@ -521,6 +534,8 @@
     OMX_VIDEO_MPEG2ProfileSNR,         /**< SNR Profile */
     OMX_VIDEO_MPEG2ProfileSpatial,     /**< Spatial Profile */
     OMX_VIDEO_MPEG2ProfileHigh,        /**< High Profile */
+    OMX_VIDEO_MPEG2ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG2ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_MPEG2ProfileMax = 0x7FFFFFFF  
 } OMX_VIDEO_MPEG2PROFILETYPE;
 
@@ -534,6 +549,8 @@
     OMX_VIDEO_MPEG2LevelML,      /**< Main Level */ 
     OMX_VIDEO_MPEG2LevelH14,     /**< High 1440 */ 
     OMX_VIDEO_MPEG2LevelHL,      /**< High Level */   
+    OMX_VIDEO_MPEG2LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG2LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_MPEG2LevelMax = 0x7FFFFFFF  
 } OMX_VIDEO_MPEG2LEVELTYPE;
 
@@ -597,7 +614,10 @@
     OMX_VIDEO_MPEG4ProfileCoreScalable     = 0x800,      
     OMX_VIDEO_MPEG4ProfileAdvancedCoding   = 0x1000,    
     OMX_VIDEO_MPEG4ProfileAdvancedCore     = 0x2000,      
-    OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000,  
+    OMX_VIDEO_MPEG4ProfileAdvancedScalable = 0x4000,
+    OMX_VIDEO_MPEG4ProfileAdvancedSimple   = 0x8000,
+    OMX_VIDEO_MPEG4ProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG4ProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_MPEG4ProfileMax              = 0x7FFFFFFF  
 } OMX_VIDEO_MPEG4PROFILETYPE;
 
@@ -615,6 +635,8 @@
     OMX_VIDEO_MPEG4Level4  = 0x20,   /**< Level 4 */  
     OMX_VIDEO_MPEG4Level4a = 0x40,   /**< Level 4a */  
     OMX_VIDEO_MPEG4Level5  = 0x80,   /**< Level 5 */  
+    OMX_VIDEO_MPEG4LevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_MPEG4LevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_MPEG4LevelMax = 0x7FFFFFFF  
 } OMX_VIDEO_MPEG4LEVELTYPE;
 
@@ -676,6 +698,8 @@
     OMX_VIDEO_WMVFormat7      = 0x02,   /**< Windows Media Video format 7 */
     OMX_VIDEO_WMVFormat8      = 0x04,   /**< Windows Media Video format 8 */
     OMX_VIDEO_WMVFormat9      = 0x08,   /**< Windows Media Video format 9 */
+    OMX_VIDEO_WMFFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_WMFFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_WMVFormatMax    = 0x7FFFFFFF
 } OMX_VIDEO_WMVFORMATTYPE;
 
@@ -705,6 +729,8 @@
     OMX_VIDEO_RVFormat8,          /**< Real Video format 8 */
     OMX_VIDEO_RVFormat9,          /**< Real Video format 9 */
     OMX_VIDEO_RVFormatG2,         /**< Real Video Format G2 */
+    OMX_VIDEO_RVFormatKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_RVFormatVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_RVFormatMax = 0x7FFFFFFF
 } OMX_VIDEO_RVFORMATTYPE;
 
@@ -762,6 +788,8 @@
     OMX_VIDEO_AVCProfileHigh10   = 0x10,   /**< High 10 profile */
     OMX_VIDEO_AVCProfileHigh422  = 0x20,   /**< High 4:2:2 profile */
     OMX_VIDEO_AVCProfileHigh444  = 0x40,   /**< High 4:4:4 profile */
+    OMX_VIDEO_AVCProfileKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_AVCProfileVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_AVCProfileMax      = 0x7FFFFFFF  
 } OMX_VIDEO_AVCPROFILETYPE;
 
@@ -787,6 +815,8 @@
     OMX_VIDEO_AVCLevel42  = 0x2000,   /**< Level 4.2 */
     OMX_VIDEO_AVCLevel5   = 0x4000,   /**< Level 5 */
     OMX_VIDEO_AVCLevel51  = 0x8000,   /**< Level 5.1 */
+    OMX_VIDEO_AVCLevelKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_AVCLevelVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_AVCLevelMax = 0x7FFFFFFF  
 } OMX_VIDEO_AVCLEVELTYPE;
 
@@ -802,6 +832,8 @@
     OMX_VIDEO_AVCLoopFilterEnable = 0,
     OMX_VIDEO_AVCLoopFilterDisable,
     OMX_VIDEO_AVCLoopFilterDisableSliceBoundary,
+    OMX_VIDEO_AVCLoopFilterKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_AVCLoopFilterVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_AVCLoopFilterMax = 0x7FFFFFFF
 } OMX_VIDEO_AVCLOOPFILTERTYPE;
 
@@ -847,7 +879,7 @@
  *                              be applied to P and SP slices
  *  nWeightedBipredicitonMode : Default weighted prediction is applied to B 
  *                              slices 
- *  bConstIpred               : Enable/disable intra prediction
+ *  bconstIpred               : Enable/disable intra prediction
  *  bDirect8x8Inference       : Specifies the method used in the derivation 
  *                              process for luma motion vectors for B_Skip, 
  *                              B_Direct_16x16 and B_Direct_8x8 as specified 
@@ -932,7 +964,7 @@
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
-    OMX_U32 xEncodeFramerate; // Q16 format
+    OMX_U32 xEncodeFramerate; /* Q16 format */
 } OMX_CONFIG_FRAMERATETYPE;
 
 typedef struct OMX_CONFIG_INTRAREFRESHVOPTYPE {
@@ -946,8 +978,8 @@
     OMX_U32 nSize;
     OMX_VERSIONTYPE nVersion;
     OMX_U32 nPortIndex;
-    OMX_U32 nErrMapSize;           // Size of the Error Map in bytes
-    OMX_U8  ErrMap[1];             // Error map hint   
+    OMX_U32 nErrMapSize;           /* Size of the Error Map in bytes */
+    OMX_U8  ErrMap[1];             /* Error map hint */
 } OMX_CONFIG_MACROBLOCKERRORMAPTYPE;
 
 typedef struct OMX_CONFIG_MBERRORREPORTINGTYPE {
@@ -975,6 +1007,8 @@
     OMX_VIDEO_SLICEMODE_AVCDefault = 0,
     OMX_VIDEO_SLICEMODE_AVCMBSlice,
     OMX_VIDEO_SLICEMODE_AVCByteSlice,
+    OMX_VIDEO_SLICEMODE_AVCKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ 
+    OMX_VIDEO_SLICEMODE_AVCVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */
     OMX_VIDEO_SLICEMODE_AVCLevelMax = 0x7FFFFFFF
 } OMX_VIDEO_AVCSLICEMODETYPE;
 
diff --git a/extern_tools_v2/bin/linux/make b/extern_tools_v2/bin/linux/make
new file mode 100755
index 0000000..93ee320
--- /dev/null
+++ b/extern_tools_v2/bin/linux/make
Binary files differ
diff --git a/extern_tools_v2/bin/linux/tar b/extern_tools_v2/bin/linux/tar
new file mode 100755
index 0000000..31fe9e8
--- /dev/null
+++ b/extern_tools_v2/bin/linux/tar
Binary files differ
diff --git a/fileformats/avi/parser/Android.mk b/fileformats/avi/parser/Android.mk
index 16d6255..4474bc5 100644
--- a/fileformats/avi/parser/Android.mk
+++ b/fileformats/avi/parser/Android.mk
@@ -2,31 +2,34 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pv_avifile.cpp\
-	src/pv_avifile_header.cpp\
-	src/pv_avifile_indx.cpp\
-	src/pv_avifile_parser.cpp\
-	src/pv_avifile_parser_utils.cpp\
-	src/pv_avifile_streamlist.cpp\
-
+	src/pv_avifile.cpp \
+ 	src/pv_avifile_header.cpp \
+ 	src/pv_avifile_indx.cpp \
+ 	src/pv_avifile_parser.cpp \
+ 	src/pv_avifile_parser_utils.cpp \
+ 	src/pv_avifile_streamlist.cpp
 
 
 LOCAL_MODULE := libpvavifileparser
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/avi/parser/include \
-	$(PV_TOP)//fileformats/avi/parser/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/avi/parser/src \
+ 	$(PV_TOP)/fileformats/avi/parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pv_avifile.h\
-	include/pv_avifile_typedefs.h\
-	include/pv_avifile_status.h\
+	include/pv_avifile.h \
+ 	include/pv_avifile_typedefs.h \
+ 	include/pv_avifile_status.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/avi/parser/build/make/local.mk b/fileformats/avi/parser/build/make/local.mk
new file mode 100644
index 0000000..e52953c
--- /dev/null
+++ b/fileformats/avi/parser/build/make/local.mk
@@ -0,0 +1,32 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvavifileparser
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_avifile.cpp\
+	pv_avifile_header.cpp\
+	pv_avifile_indx.cpp\
+	pv_avifile_parser.cpp\
+	pv_avifile_parser_utils.cpp\
+	pv_avifile_streamlist.cpp\
+
+HDRS := pv_avifile.h\
+	pv_avifile_typedefs.h\
+	pv_avifile_status.h\
+
+
+include $(MK)/library.mk
diff --git a/fileformats/avi/parser/build/make/makefile b/fileformats/avi/parser/build/make/makefile
deleted file mode 100644
index aa160f8..0000000
--- a/fileformats/avi/parser/build/make/makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvavifileparser
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-#XINCDIRS += 
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = pv_avifile.cpp\
-	pv_avifile_header.cpp\
-	pv_avifile_indx.cpp\
-	pv_avifile_parser.cpp\
-	pv_avifile_parser_utils.cpp\
-	pv_avifile_streamlist.cpp\
-
-HDRS = pv_avifile.h\
-	pv_avifile_typedefs.h\
-	pv_avifile_status.h\
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/fileformats/avi/parser/include/pv_avifile.h b/fileformats/avi/parser/include/pv_avifile.h
index cccfe6a..88af94e 100644
--- a/fileformats/avi/parser/include/pv_avifile.h
+++ b/fileformats/avi/parser/include/pv_avifile.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/include/pv_avifile_header.h b/fileformats/avi/parser/include/pv_avifile_header.h
index f3c082c..ce742d5 100644
--- a/fileformats/avi/parser/include/pv_avifile_header.h
+++ b/fileformats/avi/parser/include/pv_avifile_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/include/pv_avifile_indx.h b/fileformats/avi/parser/include/pv_avifile_indx.h
index 03cd970..bd389e0 100644
--- a/fileformats/avi/parser/include/pv_avifile_indx.h
+++ b/fileformats/avi/parser/include/pv_avifile_indx.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/include/pv_avifile_parser.h b/fileformats/avi/parser/include/pv_avifile_parser.h
index 0719008..4f2948b 100644
--- a/fileformats/avi/parser/include/pv_avifile_parser.h
+++ b/fileformats/avi/parser/include/pv_avifile_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/include/pv_avifile_parser_utils.h b/fileformats/avi/parser/include/pv_avifile_parser_utils.h
index abe6881..e2d227b 100644
--- a/fileformats/avi/parser/include/pv_avifile_parser_utils.h
+++ b/fileformats/avi/parser/include/pv_avifile_parser_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,6 @@
         read16(PVFile* aFp, uint16& aBuff, bool aBigEndian = false);
 
         static int32 GetStreamNumber(uint32 aData);
-        bool IsYUVFormat(uint32 aFcc);
 
 
 };
diff --git a/fileformats/avi/parser/include/pv_avifile_status.h b/fileformats/avi/parser/include/pv_avifile_status.h
index d8cb51a..9bce8ce 100644
--- a/fileformats/avi/parser/include/pv_avifile_status.h
+++ b/fileformats/avi/parser/include/pv_avifile_status.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,10 +27,10 @@
 
 typedef enum
 {
-    PV_AVI_FILE_PARSER_ERROR_UNKNOWN		     = -1,
-    PV_AVI_FILE_PARSER_SUCCESS			         = 0,
+    PV_AVI_FILE_PARSER_ERROR_UNKNOWN             = -1,
+    PV_AVI_FILE_PARSER_SUCCESS                   = 0,
     PV_AVI_FILE_PARSER_FILE_OPEN_ERROR           = 1,
-    PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY	     = 2,
+    PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY       = 2,
     PV_AVI_FILE_PARSER_WRONG_CHUNK               = 3,
     PV_AVI_FILE_PARSER_WRONG_CHUNK_SIZE          = 4,
     PV_AVI_FILE_PARSER_WRONG_FILE                = 5,
@@ -38,16 +38,17 @@
     PV_AVI_FILE_PARSER_READ_ERROR                = 7,
     PV_AVI_FILE_PARSER_ERROR_NUM_STREAM          = 8,
     PV_AVI_FILE_PARSER_ERROR_STREAM_TYPE_UNKNOWN = 9,
-    PV_AVI_FILE_PARSER_NO_INDEX_CHUNK		     = 10,
-    PV_AVI_FILE_PARSER_EOF_REACHED			     = 11,  //End of file
-    PV_AVI_FILE_PARSER_EOS_REACHED			     = 12,  //End of stream
+    PV_AVI_FILE_PARSER_NO_INDEX_CHUNK            = 10,
+    PV_AVI_FILE_PARSER_EOF_REACHED               = 11,  //End of file
+    PV_AVI_FILE_PARSER_EOS_REACHED               = 12,  //End of stream
     PV_AVI_FILE_PARSER_USE_INDX_TBL              = 13,
     PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR          = 14,
     PV_AVI_FILE_PARSER_UNSUPPORTED_CHUNK         = 15,
     PV_AVI_FILE_PARSER_ERROR_WRONG_STREAM_NUM    = 16,
     PV_AVI_FILE_PARSER_WRONG_OFFSET              = 17,
-    PV_AVI_FILE_PARSER_NO_OFFSET_FOUND			 = 18,
-    PV_AVI_FILE_PARSER_WRONG_BIT_COUNT			 = 19
+    PV_AVI_FILE_PARSER_NO_OFFSET_FOUND           = 18,
+    PV_AVI_FILE_PARSER_WRONG_BIT_COUNT           = 19,
+    PV_AVI_FILE_PARSER_SEEK_ERROR                = 20
 
 }PV_AVI_FILE_PARSER_ERROR_TYPE;
 
diff --git a/fileformats/avi/parser/include/pv_avifile_streamlist.h b/fileformats/avi/parser/include/pv_avifile_streamlist.h
index 60205d6..8239e15 100644
--- a/fileformats/avi/parser/include/pv_avifile_streamlist.h
+++ b/fileformats/avi/parser/include/pv_avifile_streamlist.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/include/pv_avifile_typedefs.h b/fileformats/avi/parser/include/pv_avifile_typedefs.h
index 7fe5d49..aee0e13 100644
--- a/fileformats/avi/parser/include/pv_avifile_typedefs.h
+++ b/fileformats/avi/parser/include/pv_avifile_typedefs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,7 +75,6 @@
 const uint32   CHUNK_SIZE				= 4;
 const uint32   RES_BYTES_SZ				= 4;
 const uint32   MAX_STRN_SZ				= 100;
-const uint32   NUM_YUV_FMT				= 32;
 const uint32   OFFSET_FROM_MOVI_LST		= 4;
 const uint32   MAX_COLOR_TABLE_SIZE		= 256;
 const uint32   BIT_COUNT1				= 1;
@@ -108,40 +107,6 @@
 const uint32	MOVI    MAKE_FOURCC('m', 'o', 'v', 'i');
 const uint32	JUNK	MAKE_FOURCC('J', 'U', 'N', 'K');
 
-const uint32    YUV_FMT[] =
-{
-    MAKE_FOURCC('A', 'Y', 'U', 'V'),
-    MAKE_FOURCC('C', 'L', 'J', 'R'),
-    MAKE_FOURCC('c', 'y', 'u', 'v'),
-    MAKE_FOURCC('G', 'R', 'E', 'Y'),
-    MAKE_FOURCC('I', 'R', 'A', 'W'),
-    MAKE_FOURCC('I', 'U', 'Y', 'V'),
-    MAKE_FOURCC('I', 'Y', '4', '1'),
-    MAKE_FOURCC('I', 'Y', 'U', '1'),
-    MAKE_FOURCC('I', 'Y', 'U', '2'),
-    MAKE_FOURCC('H', 'D', 'Y', 'C'),
-    MAKE_FOURCC('U', 'Y', 'N', 'V'),
-    MAKE_FOURCC('U', 'Y', 'V', 'P'),
-    MAKE_FOURCC('U', 'Y', 'V', 'Y'),
-    MAKE_FOURCC('V', '2', '1', '0'),
-    MAKE_FOURCC('V', '4', '2', '2'),
-    MAKE_FOURCC('V', '6', '5', '5'),
-    MAKE_FOURCC('V', 'Y', 'U', 'Y'),
-    MAKE_FOURCC('Y', '4', '2', '2'),
-    MAKE_FOURCC('Y', 'U', 'Y', '2'),
-    MAKE_FOURCC('Y', 'U', 'Y', 'V'),
-    MAKE_FOURCC('Y', 'U', 'N', 'V'),
-    MAKE_FOURCC('Y', 'V', 'Y', 'U'),
-    MAKE_FOURCC('Y', '4', '1', 'P'),
-    MAKE_FOURCC('Y', '4', '1', '1'),
-    MAKE_FOURCC('Y', '2', '1', '1'),
-    MAKE_FOURCC('Y', '4', '1', 'T'),
-    MAKE_FOURCC('Y', '4', '2', 'T'),
-    MAKE_FOURCC('Y', 'U', 'V', 'P'),
-    MAKE_FOURCC('Y', '8', '0', '0'),
-    MAKE_FOURCC('Y', '8', ' ', ' '),
-    MAKE_FOURCC('Y', '1', '6', ' '),
-};
 
 #define WAVE_FORMAT_UNKNOWN             (0x0000)
 
@@ -187,8 +152,8 @@
 
 typedef enum
 {
-    AUDIO,
-    VIDEO,
+    PV_2_AUDIO,
+    PV_2_VIDEO,
     MIDI,
     TEXT,
     UNKNOWN
diff --git a/fileformats/avi/parser/src/pv_avifile.cpp b/fileformats/avi/parser/src/pv_avifile.cpp
index 7c5cb0a..1e583cc 100644
--- a/fileformats/avi/parser/src/pv_avifile.cpp
+++ b/fileformats/avi/parser/src/pv_avifile.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/src/pv_avifile_header.cpp b/fileformats/avi/parser/src/pv_avifile_header.cpp
index 6e2ad6d..e086457 100644
--- a/fileformats/avi/parser/src/pv_avifile_header.cpp
+++ b/fileformats/avi/parser/src/pv_avifile_header.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -335,7 +335,7 @@
 
     for (ii = 0; ii < strnum; ii++)
     {
-        if ((iStreamList[ii].GetStreamType() == AUDIO) && (aStreamNo == ii))
+        if ((iStreamList[ii].GetStreamType() == PV_2_AUDIO) && (aStreamNo == ii))
         {
             retType = iStreamList[ii].GetAudioFormat();
         }
@@ -353,7 +353,7 @@
 
     for (ii = 0; ii < strnum; ii++)
     {
-        if ((iStreamList[ii].GetStreamType() == AUDIO) && (ii == aStreamNo))
+        if ((iStreamList[ii].GetStreamType() == PV_2_AUDIO) && (ii == aStreamNo))
         {
             retType = iStreamList[ii].GetNumAudioChannels();
         }
diff --git a/fileformats/avi/parser/src/pv_avifile_indx.cpp b/fileformats/avi/parser/src/pv_avifile_indx.cpp
index 364718d..5fb511e 100644
--- a/fileformats/avi/parser/src/pv_avifile_indx.cpp
+++ b/fileformats/avi/parser/src/pv_avifile_indx.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/avi/parser/src/pv_avifile_parser.cpp b/fileformats/avi/parser/src/pv_avifile_parser.cpp
index 79def12..abb8fa5 100644
--- a/fileformats/avi/parser/src/pv_avifile_parser.cpp
+++ b/fileformats/avi/parser/src/pv_avifile_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +54,18 @@
 {
     iError = PV_AVI_FILE_PARSER_SUCCESS;
     ipFilePtr->Seek(0, Oscl_File::SEEKSET);
+
+    // Seek to the end to find the file size
+    uint32 filesize = 0;
+    if (ipFilePtr->Seek(0, Oscl_File::SEEKEND))
+    {
+        iError = PV_AVI_FILE_PARSER_SEEK_ERROR;
+        return iError;
+    }
+    filesize = ipFilePtr->Tell();
+
+    // Seek back to the beginning
+    ipFilePtr->Seek(0, Oscl_File::SEEKSET);
     uint32 chunkType = 0;
 
     if ((iError = PVAviFileParserUtils::ReadNextChunkType(ipFilePtr, chunkType)) != PV_AVI_FILE_PARSER_SUCCESS)
@@ -76,7 +88,7 @@
         return iError;
     }
 
-    if (iFileSize <= 0)
+    if ((iFileSize <= 0) || (iFileSize > filesize))
     {
         iError = PV_AVI_FILE_PARSER_WRONG_SIZE;
         return iError;
@@ -375,9 +387,14 @@
         uint32 sampleSize = GetBitsPerSample(arStreamNo);
         sampleSize = sampleSize / BIT_COUNT8; //in bytes
         OsclFloat  samplingRate = GetFrameRate(arStreamNo);
-        OsclFloat  sampleCount = arSize / sampleSize;
-        iTimeStampAudio += (uint32)((sampleCount * 1000) / samplingRate);
-
+        if (sampleSize > 0)
+        {
+            OsclFloat  sampleCount = (OsclFloat)arSize / sampleSize;
+            if (samplingRate > 0)
+            {
+                iTimeStampAudio += (uint32)((sampleCount * 1000) / samplingRate);
+            }
+        }
     }
     else
     {
@@ -465,9 +482,14 @@
         uint32 sampleSize = GetBitsPerSample(aStreamNo);
         sampleSize = sampleSize / BIT_COUNT8; //in bytes
         OsclFloat samplingRate = GetFrameRate(aStreamNo);
-        OsclFloat sampleCount = arSize / sampleSize;
-        iTimeStampAudio += (uint32)((sampleCount * 1000) / samplingRate);
-
+        if (sampleSize > 0)
+        {
+            OsclFloat sampleCount = (OsclFloat)arSize / sampleSize;
+            if (samplingRate > 0)
+            {
+                iTimeStampAudio += (uint32)((sampleCount * 1000) / samplingRate);
+            }
+        }
     }
     else
     {
diff --git a/fileformats/avi/parser/src/pv_avifile_parser_utils.cpp b/fileformats/avi/parser/src/pv_avifile_parser_utils.cpp
index 601a10f..9f0e3a9 100644
--- a/fileformats/avi/parser/src/pv_avifile_parser_utils.cpp
+++ b/fileformats/avi/parser/src/pv_avifile_parser_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -151,17 +151,4 @@
     }
 }
 
-bool PVAviFileParserUtils::IsYUVFormat(uint32 aFcc)
-{
-    uint32  ii;
-    bool pattern_found = false;
-    for (ii = 0 ; ii < NUM_YUV_FMT; ii++)
-    {
-        if (YUV_FMT[ii] == aFcc)
-        {
-            pattern_found = true;
-        }
-    }
-    return pattern_found;
-}
 
diff --git a/fileformats/avi/parser/src/pv_avifile_streamlist.cpp b/fileformats/avi/parser/src/pv_avifile_streamlist.cpp
index ac17e90..d72a716 100644
--- a/fileformats/avi/parser/src/pv_avifile_streamlist.cpp
+++ b/fileformats/avi/parser/src/pv_avifile_streamlist.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -168,7 +168,14 @@
                 break;
             }
 
+            ipCodecSpecificHdrData = NULL;
             ipCodecSpecificHdrData = (uint8*)oscl_malloc(iCodecSpecificHdrDataSize);
+            if (!ipCodecSpecificHdrData)
+            {
+                PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unable to allocate memory."));
+                iError = PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY;
+                break;
+            }
             if (0 == PVAviFileParserUtils::read8(aFp, ipCodecSpecificHdrData, iCodecSpecificHdrDataSize))
             {
                 PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
@@ -199,6 +206,12 @@
             if (strnSz >= MAX_STRN_SZ)
             {
                 uint8* strn = (uint8*)oscl_malloc(strnSz);
+                if (!strn)
+                {
+                    PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: Unable to allocate memory."));
+                    iError = PV_AVI_FILE_PARSER_INSUFFICIENT_MEMORY;
+                    break;
+                }
                 if (PVAviFileParserUtils::read8(aFp, strn, strnSz) == 0)
                 {
                     PVAVIFILE_LOGERROR((0, "PVAviFileStreamlist::PVAviFileStreamlist: File Read Error"));
@@ -206,7 +219,8 @@
                     break;
                 }
 
-                oscl_strncpy(iStreamName, (char*)strn, MAX_STRN_SZ);
+                oscl_strncpy(iStreamName, (char*)strn, (MAX_STRN_SZ - 1));
+                iStreamName[MAX_STRN_SZ - 1] = '\0';
                 oscl_free(strn);
             }
             else
@@ -437,7 +451,7 @@
         return PV_AVI_FILE_PARSER_BYTE_COUNT_ERROR;
     }
 
-    iStreamHdr.iSamplingRate = iStreamHdr.iRate / iStreamHdr.iScale;
+    iStreamHdr.iSamplingRate = (OsclFloat)iStreamHdr.iRate / iStreamHdr.iScale;
 
     return  PV_AVI_FILE_PARSER_SUCCESS;
 }
@@ -451,12 +465,12 @@
     {
         case AUDS:
         {
-            iStreamFmt.iType = AUDIO;
+            iStreamFmt.iType = PV_2_AUDIO;
         }
         break;
         case VIDS:
         {
-            iStreamFmt.iType = VIDEO;
+            iStreamFmt.iType = PV_2_VIDEO;
         }
         break;
         case MIDI:
@@ -477,8 +491,14 @@
     }
     ; //end switch
 
-    if (iStreamFmt.iType == AUDIO)
+    if (iStreamFmt.iType == PV_2_AUDIO)
     {
+        iStreamFmt.iAudWaveFormatEx.FormatTag = 0;
+        iStreamFmt.iAudWaveFormatEx.Channels = 0;
+        iStreamFmt.iAudWaveFormatEx.SamplesPerSec = 0;
+        iStreamFmt.iAudWaveFormatEx.AvgBytesPerSec = 0;
+        iStreamFmt.iAudWaveFormatEx.BlockAlign = 0;
+        iStreamFmt.iAudWaveFormatEx.BitsPerSample = 0;
         if (PV_AVI_FILE_PARSER_SUCCESS != (PVAviFileParserUtils::read16(aFp, iStreamFmt.iAudWaveFormatEx.FormatTag, true)))
         {
             return PV_AVI_FILE_PARSER_READ_ERROR;
@@ -529,8 +549,19 @@
         }
 
     }
-    else if (iStreamFmt.iType == VIDEO)
+    else if (iStreamFmt.iType == PV_2_VIDEO)
     {
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiSize = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiHeight = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiPlanes = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiBitCount = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiSizeImage = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiXPelsPerMeter = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiYPelsPerMeter = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiClrUsed = 0;
+        iStreamFmt.iVidBitMapInfo.BmiHeader.BiClrImportant = 0;
+        iStreamFmt.iVidBitMapInfo.BmiColorsCount = 0;
         if (PV_AVI_FILE_PARSER_SUCCESS != (PVAviFileParserUtils::read32(aFp, iStreamFmt.iVidBitMapInfo.BmiHeader.BiSize, true)))
         {
             return PV_AVI_FILE_PARSER_READ_ERROR;
@@ -599,84 +630,95 @@
 
         //get the color table size
         uint32 colorTblSize = iStreamFmt.iVidBitMapInfo.BmiHeader.BiClrUsed;
-
-        if (colorTblSize == 0)
+        if (colorTblSize > MAX_COLOR_TABLE_SIZE)
         {
-            switch (iStreamFmt.iVidBitMapInfo.BmiHeader.BiBitCount)
+            return PV_AVI_FILE_PARSER_WRONG_SIZE;
+        }
+        if (bytesRead == aHdrSize)
+        {
+            return PV_AVI_FILE_PARSER_SUCCESS;
+        }
+        else
+        {
+            if (colorTblSize == 0)
             {
-                case BIT_COUNT1:
+                switch (iStreamFmt.iVidBitMapInfo.BmiHeader.BiBitCount)
                 {
-                    colorTblSize = 2;
-                }
-                break;
-                case BIT_COUNT2:
-                {
-                    colorTblSize = 4;
-                }
-                break;
-                case BIT_COUNT4:
-                {
-                    colorTblSize = 16;
-                }
-                break;
-                case BIT_COUNT8:
-                {
-                    colorTblSize = 256;
-                }
-                break;
-                case BIT_COUNT16:
-                case BIT_COUNT32:
-                {
-                    if (BI_BITFIELDS == iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression)
+                    case BIT_COUNT1:
                     {
-                        colorTblSize = 3;
+                        colorTblSize = 2;
                     }
-                    else if (BI_ALPHABITFIELDS == iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression)
+                    break;
+                    case BIT_COUNT2:
                     {
                         colorTblSize = 4;
                     }
-                    else if (BI_RGB == iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression)
+                    break;
+                    case BIT_COUNT4:
+                    {
+                        colorTblSize = 16;
+                    }
+                    break;
+                    case BIT_COUNT8:
+                    {
+                        colorTblSize = 256;
+                    }
+                    break;
+                    case BIT_COUNT16:
+                    case BIT_COUNT32:
+                    {
+                        if (BI_BITFIELDS == iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression)
+                        {
+                            colorTblSize = 3;
+                        }
+                        else if (BI_ALPHABITFIELDS == iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression)
+                        {
+                            colorTblSize = 4;
+                        }
+                        else if (BI_RGB == iStreamFmt.iVidBitMapInfo.BmiHeader.BiCompression)
+                        {
+                            colorTblSize = 0;
+                        }
+
+                    }
+                    break;
+                    case BIT_COUNT24:
                     {
                         colorTblSize = 0;
                     }
+                    break;
+                    default:
+                        return PV_AVI_FILE_PARSER_WRONG_BIT_COUNT;
+                        break;
 
-                }
-                break;
-                case BIT_COUNT24:
+                } //switch
+            }
+
+            iStreamFmt.iVidBitMapInfo.BmiColorsCount = colorTblSize;
+
+            uint32 length = 1;
+            //get color table entries
+            for (uint32 ii = 0; ii < colorTblSize; ii++)
+            {
+                if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Blue), length))
                 {
-                    colorTblSize = 0;
+                    return PV_AVI_FILE_PARSER_READ_ERROR;
                 }
-                break;
-                default:
-                    return PV_AVI_FILE_PARSER_WRONG_BIT_COUNT;
+                if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Green), length))
+                {
+                    return PV_AVI_FILE_PARSER_READ_ERROR;
+                }
+                if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Red), length))
+                {
+                    return PV_AVI_FILE_PARSER_READ_ERROR;
+                }
+                if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Reserved), length))
+                {
+                    return PV_AVI_FILE_PARSER_READ_ERROR;
+                }
 
-            } //switch
-        }
-
-        iStreamFmt.iVidBitMapInfo.BmiColorsCount = colorTblSize;
-
-        uint32 length = 1;
-        //get color table entries
-        for (uint32 ii = 0; ii < colorTblSize; ii++)
-        {
-            if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Blue), length))
-            {
-                return PV_AVI_FILE_PARSER_READ_ERROR;
             }
-            if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Green), length))
-            {
-                return PV_AVI_FILE_PARSER_READ_ERROR;
-            }
-            if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Red), length))
-            {
-                return PV_AVI_FILE_PARSER_READ_ERROR;
-            }
-            if (length != PVAviFileParserUtils::read8(aFp, &(iStreamFmt.iVidBitMapInfo.BmiColors[ii].Reserved), length))
-            {
-                return PV_AVI_FILE_PARSER_READ_ERROR;
-            }
-
-        }
+        } //else
         bytesRead += colorTblSize * sizeof(RGBQuad);
 
 
@@ -712,7 +754,7 @@
     }
     else
     {
-        return 0;
+        mime_str = "unknown";
     }
 
     return mime_str;
@@ -732,11 +774,11 @@
 
 uint32 PVAviFileStreamlist::GetBitsPerSample()
 {
-    if (AUDIO == iStreamFmt.iType)
+    if (PV_2_AUDIO == iStreamFmt.iType)
     {
         return (iStreamFmt.iAudWaveFormatEx).BitsPerSample;
     }
-    else if (VIDEO == iStreamFmt.iType)
+    else if (PV_2_VIDEO == iStreamFmt.iType)
 
     {
         return (iStreamFmt.iVidBitMapInfo).BmiHeader.BiBitCount;
@@ -749,7 +791,7 @@
 
 uint32 PVAviFileStreamlist::GetAudioFormat()
 {
-    if (AUDIO == iStreamFmt.iType)
+    if (PV_2_AUDIO == iStreamFmt.iType)
     {
         return (iStreamFmt.iAudWaveFormatEx).FormatTag;
     }
@@ -761,7 +803,7 @@
 
 uint32 PVAviFileStreamlist::GetNumAudioChannels()
 {
-    if (AUDIO == iStreamFmt.iType)
+    if (PV_2_AUDIO == iStreamFmt.iType)
     {
         return (iStreamFmt.iAudWaveFormatEx).Channels;
     }
@@ -774,7 +816,7 @@
 
 uint32 PVAviFileStreamlist::GetVideoWidth()
 {
-    if (VIDEO == iStreamFmt.iType)
+    if (PV_2_VIDEO == iStreamFmt.iType)
     {
         return (iStreamFmt.iVidBitMapInfo).BmiHeader.BiWidth;
     }
@@ -786,7 +828,7 @@
 
 uint32 PVAviFileStreamlist::GetVideoHeight(bool& rBottomUp)
 {
-    if (VIDEO == iStreamFmt.iType)
+    if (PV_2_VIDEO == iStreamFmt.iType)
     {
         int32 height = (iStreamFmt.iVidBitMapInfo).BmiHeader.BiHeight;
         if (height < 0) //negative height
@@ -809,12 +851,12 @@
 
 bool PVAviFileStreamlist::GetFormatSpecificInfo(uint8*& aBuff, uint32& aSize)
 {
-    if (AUDIO == iStreamFmt.iType)
+    if (PV_2_AUDIO == iStreamFmt.iType)
     {
         aSize = sizeof(WaveFormatExStruct);
         aBuff = OSCL_STATIC_CAST(uint8*, &(iStreamFmt.iAudWaveFormatEx));
     }
-    else if (VIDEO == iStreamFmt.iType)
+    else if (PV_2_VIDEO == iStreamFmt.iType)
     {
         aSize = sizeof(BitmapInfoHhr) + (sizeof(RGBQuad) * iStreamFmt.iVidBitMapInfo.BmiColorsCount);
         aBuff = OSCL_STATIC_CAST(uint8*, &(iStreamFmt.iVidBitMapInfo));
diff --git a/fileformats/common/parser/Android.mk b/fileformats/common/parser/Android.mk
index d585afa..04d6575 100644
--- a/fileformats/common/parser/Android.mk
+++ b/fileformats/common/parser/Android.mk
@@ -2,31 +2,31 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/audiogetid3info.cpp \
 	src/pvfile.cpp \
-	src/pvmi_datastreamsyncinterface_ref_factory.cpp \
-	src/pvmi_datastreamsyncinterface_ref_impl.cpp
-
+ 	src/pvmi_datastreamsyncinterface_ref_factory.cpp \
+ 	src/pvmi_datastreamsyncinterface_ref_impl.cpp
 
 
 LOCAL_MODULE := libpvfileparserutils
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/common/parser/include \
-	$(PV_TOP)//fileformats/common/parser/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/common/parser/src \
+ 	$(PV_TOP)/fileformats/common/parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvfile.h \
-	include/audiometadata.h \
-	include/audiogetid3info.h \
-	include/pvmi_datastreamsyncinterface_ref_factory.h \
-	include/virtual_buffer.h
+ 	include/pvmi_datastreamsyncinterface_ref_factory.h \
+ 	include/virtual_buffer.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/common/parser/build/make/local.mk b/fileformats/common/parser/build/make/local.mk
new file mode 100644
index 0000000..1cde50a
--- /dev/null
+++ b/fileformats/common/parser/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvfileparserutils
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvfile.cpp \
+	pvmi_datastreamsyncinterface_ref_factory.cpp \
+	pvmi_datastreamsyncinterface_ref_impl.cpp
+
+
+HDRS := pvfile.h \
+	pvmi_datastreamsyncinterface_ref_factory.h \
+	virtual_buffer.h 
+
+ 
+include $(MK)/library.mk
+install:: headers-install
+
+ 
diff --git a/fileformats/common/parser/build/make/makefile b/fileformats/common/parser/build/make/makefile
deleted file mode 100644
index 507aa25..0000000
--- a/fileformats/common/parser/build/make/makefile
+++ /dev/null
@@ -1,68 +0,0 @@
-# Warning: This is just for the header installed in the common directory
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvfileparserutils
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = audiogetid3info.cpp \
-	pvfile.cpp \
-	pvmi_datastreamsyncinterface_ref_factory.cpp \
-	pvmi_datastreamsyncinterface_ref_impl.cpp
-
-
-HDRS =  pvfile.h \
-	audiometadata.h \
-	audiogetid3info.h \
-	pvmi_datastreamsyncinterface_ref_factory.h \
-	virtual_buffer.h 
-
- 
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-install:: headers-install
-
- 
diff --git a/fileformats/common/parser/include/audiogetid3info.h b/fileformats/common/parser/include/audiogetid3info.h
deleted file mode 100644
index ad507c4..0000000
--- a/fileformats/common/parser/include/audiogetid3info.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//           A U D I O   G E T    I D 3    I N F O
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-
-/**
- *  @file audiogetid3info.h
- *  @brief This include file contains the definitions and classes needed
- *  to use and understand the ID3 library correctly.
- */
-
-
-#ifndef AUDIOGETID3INFO_H_INCLUDED
-#define AUDIOGETID3INFO_H_INCLUDED
-
-//----------------------------------------------------------------------------
-// INCLUDES
-//----------------------------------------------------------------------------
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_FILE_IO_H_INCLUDED
-#include "oscl_file_io.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef PVFILE_H_INCLUDED
-#include "pvfile.h"
-#endif
-
-#ifndef AUDIOMETADATA_H_INCLUDED
-#include "audiometadata.h"
-#endif
-
-//----------------------------------------------------------------------------
-// FORWARD CLASS DECLARATIONS
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// MACROS
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// CONSTANTS
-//----------------------------------------------------------------------------
-
-// Error codes returned
-#define PVID3PARSER_EVERYTHING_FINE                        0
-#define PVID3PARSER_FILE_OPEN_FAILED                      -1
-#define PVID3PARSER_FILE_OPERATION_FAILED				  -2
-
-#define ID3V1_TAG_NUM_BYTES_HEADER             3
-#define ID3V1_MAX_NUM_BYTES_TITLE             30
-#define ID3V1_MAX_NUM_BYTES_ARTIST            30
-#define ID3V1_MAX_NUM_BYTES_ALBUM             30
-#define ID3V1_MAX_NUM_BYTES_YEAR               4
-#define ID3V1_MAX_NUM_BYTES_COMMENT           30
-#define ID3V1_MAX_NUM_BYTES_GENRE              1
-#define ID3V1_MAX_NUM_BYTES_TOTAL            128
-#define ID3V1_MAX_NUM_BYTES_FIELD_SIZE        30
-
-#define ID3V2_TAG_NUM_BYTES_HEADER            10
-#define ID3V2_TAG_NUM_BYTES_FOOTER            10
-#define ID3V2_TAG_NUM_BYTES_ID                 3
-#define ID3V2_TAG_NUM_BYTES_VERSION            2
-#define ID3V2_TAG_NUM_BYTES_FLAG               1
-#define ID3V2_TAG_NUM_BYTES_SIZE               4
-
-#define ID3V2_FRAME_NUM_BYTES_HEADER          10
-#define ID3V2_FRAME_NUM_BYTES_ID               4
-#define ID3V2_FRAME_NUM_BYTES_SIZE             4
-#define ID3V2_FRAME_NUM_BYTES_FLAG             2
-
-#define ID3V2_TAG_EXTENDED_HEADER_TOTAL_SIZE   6
-#define ID3V2_TAG_EXTENDED_HEADER_SIZE         4
-#define ID3V2_TAG_EXTENDED_HEADER_NUM          1
-#define ID3V2_TAG_EXTENDED_HEADER_FLAG         1
-
-#define UNICODE_LITTLE_ENDIAN                  1
-#define UNICODE_BIG_ENDIAN                     0
-
-#define FLAGMASK                              64 // 0x40
-#define FOOTERMASK                            16 // Bit 4
-#define MASK127                              127 // 0111 1111
-
-#define VALID_BITS_IN_SYNC_SAFE_BYTE           7
-#define UNICODE_LITTLE_ENDIAN_INDICATOR      255 // 0xff
-#define UNICODE_BIG_ENDIAN_INDICATOR         254 // 0xfe
-
-//for the ID3 Version 2.2
-#define ID3V22_FRAME_NUM_BYTES_ID               3
-#define ID3V22_HEADER_SIZE                      3
-#define ID3V22_FRAME_NUM_BYTES_HEADER           6
-
-enum TTextType
-{
-    EISO88591,
-    EUTF16,
-    EUTF16BE,
-    EUTF8,
-    ENoType
-};
-
-// Frame Header ID Types for ID3v2 frames
-enum TID3V2FrameType
-{
-    ETIT2, // Title
-    ETPE1, // Artist
-    ETALB, // Album
-    ETCOP, // Copyright
-    ETCON, // Content Type
-    ETRCK, // Track Number on Album
-    ETLEN, // Length of the audiofile in milliseconds
-    ETDAT, // Recording Time
-    ETYER, // Year
-    ETPOS, // Part Of Set
-    ECOMT, // Comment
-    EEND,  // Frame ID was 0's
-    EFrameNotSupported
-};
-
-
-static const uint8 KTAGLIT[] = {"TAG"};
-static const uint8 KID3LIT[] = {"ID3"};
-
-//for the Version 2.3 and 2.4
-static const uint8 KTIT2[]   = {"TIT2"}; // Title
-static const uint8 KTPE1[]   = {"TPE1"}; // Artist
-static const uint8 KTALB[]   = {"TALB"}; // Album
-static const uint8 KTCOP[]   = {"TCOP"}; // Copyright
-static const uint8 KTCON[]   = {"TCON"}; // Content Type
-static const uint8 KTRCK[]   = {"TRCK"}; // Track Number on Album
-static const uint8 KTLEN[]   = {"TLEN"}; // Length of the audiofile in milliseconds
-static const uint8 KTYER[]   = {"TYER"}; // Year (version 2.3)
-static const uint8 KTPOS[]   = {"TPOS"}; // Part Of Set
-static const uint8 KTDRC[]   = {"TDRC"}; // Year (version 2.4)
-static const uint8 KTDAT[]   = {"TDAT"}; // Recording Time
-static const uint8 KCOMM[]   = {"COMM"}; // Comment
-
-
-//for the Version 2.2
-static const uint8 KTT2[]   = {"TT2"}; // Title
-static const uint8 KTP1[]   = {"TP1"}; // Artist
-static const uint8 KTAL[]   = {"TAL"}; // Album
-static const uint8 KTCR[]   = {"TCR"}; // Copyright
-static const uint8 KTCO[]   = {"TCO"}; // Content Type
-static const uint8 KTRK[]   = {"TRK"}; // Track Number on Album
-static const uint8 KTLE[]   = {"TLE"}; // Length of the audiofile in milliseconds
-static const uint8 KTDA[]   = {"TDA"}; // Recording Time
-static const uint8 KTYE[]   = {"TYE"}; // Year
-static const uint8 KCOM[]   = {"COM"}; // Comment
-static const uint8 KTPA[]   = {"TPA"}; // Part Of Set
-
-//id3v1 Genre Lookup table
-
-static const uint8 ID3V1_GENRE[150][64]   = {	  "Blues", "Classic Rock", "Country", "Dance", "Disco",
-        "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age",
-        "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock",
-        "Techno", "Industrial", "Alternative", "Ska", "Death Metal",
-        "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
-        "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical",
-        "Instrumental", "Acid", "House", "Game", "Sound Clip",
-        "Gospel", "Noise", "Alternative Rock", "Bass", "Punk",
-        "Space", "Meditative", "Instrumental Pop", "Instrumental Rock",
-        "Ethnic", "Gothic", "Darkwave", "Techno-Industrial",
-        "Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock",
-        "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap",
-        "Pop/Funk", "Jungle", "Native US", "Cabaret", "New Wave", "Psychadelic",
-        "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk",
-        "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll",
-        "Hard Rock", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion",
-        "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde",
-        "Gothic Rock", "Progressive Rock", "Psychedelic Rock",
-        "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening",
-        "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music",
-        "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire",
-        "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad",
-        "Rhytmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "Acapella",
-        "Euro-House", "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore",
-        "Terror", "Indie", "BritPop", "Negerpunk", "Polsk Punk", "Beat",
-        "Christian Gangsta", "Heavy Metal", "Black Metal", "Crossover", "Contemporary C",
-        "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", "SynthPop"
-
-                                            }; //ID3V1 Genre
-
-//----------------------------------------------------------------------------
-// EXTERNAL VARIABLES REFERENCES
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// CLASS DEFINITIONS
-//----------------------------------------------------------------------------
-
-/**
- *  @brief The TID3TagInfo class acts as temporary storage for information
- *  extracted from the different types of ID3 tags to a given file. This
- *  class is created to keep track of certain qualities of an ID3 tag that
- *  the caller of the ID3 library would not need to know.
- */
-class TID3TagInfo
-{
-    public:
-        uint32      iPositionInFile;
-        TTextType   iTextType;
-
-        uint32    iID3V2FrameSize;
-        uint8     iID3V2TagFlagsV2;
-        uint32    iID3V2ExtendedHeader;
-        uint32    iID3V2TagSize;
-        uint8     iID3V2FrameID[ID3V2_FRAME_NUM_BYTES_ID];
-        uint8     iID3V2FrameFlag[ID3V2_FRAME_NUM_BYTES_FLAG];
-};
-
-
-/**
- *  @brief The CID3TagParser class extracts the ID3 tag information from a
- *  given file. The class reads frame information from a file, determined if
- *  it is a supported tag and frame type, and extracts the frame information
- *  and fills in T-class that stores the ID3 file information.
- */
-class CID3TagParser
-{
-    public:
-        CID3TagParser();
-        OSCL_IMPORT_REF ~CID3TagParser();
-
-    public:
-
-        /**
-        * @brief Checks for the existence of an ID3V1 or ID3V2 tag
-        * associated with the soecified file. Retrieves the information from the tag
-        * to populate aID3MetaData.
-        *
-        * @param aFile Pointer to file to parse
-        * @param aID3MetaData Reference to a pre-allocated TAudioMetaData structure
-        * @returns Result of operation: PVID3PARSER_EVERYTHING_FINE, etc.
-        */
-        OSCL_IMPORT_REF int32 ParseID3TagInfo(PVFile *aFile, TAudioMetaData& aID3MetaData);
-
-        /**
-        * @brief Constructor. This constructor is called if no file server session
-        * exists
-        *
-        * @param None
-        * @returns None
-        */
-        OSCL_IMPORT_REF static CID3TagParser* NewL();
-
-        /**
-        * @brief Destructor for use with NewL.
-        * exists
-        *
-        * @param None
-        * @returns None
-        */
-        OSCL_IMPORT_REF static void Delete(CID3TagParser*);
-
-    private:
-        /**
-        * @brief Constructor.
-        *
-        * @param None
-        * @returns None
-        */
-        void ConstructL();
-
-        /**
-
-        * @brief Checks the file for the presence of ID3V1 Tag.
-        *
-        * @param aID3MetaData Reference to a pre-allocated TAudioMetaData structure
-        * @returns True if Id3V1 tag present otherwise False
-        */
-        bool CheckForTagID3V1(TAudioMetaData& aID3MetaData);
-
-        /**
-        * @brief Checks the file for the presence of ID3V2 Tag attached to
-        * the beginning of the file.
-        *
-        * @param aID3MetaData Reference to a pre-allocated TAudioMetaData structure
-        * @returns True if Id3V2 tag present otherwise False
-        */
-        bool CheckForTagID3V2(TAudioMetaData& aID3MetaData);
-
-        /**
-        * @brief Parses the file and populates the aID3MetaData structure when
-        * an ID3V1 tag is found and no ID3V2 tag was found.
-        *
-        * @param aID3MetaData Reference to a pre-allocated TAudioMetaData structure
-        * @param aTitleOnlyFlag Indicates whether to read title only or read
-        * other metadata information.
-        * @returns None
-        */
-        void ReadID3V1Tag(TAudioMetaData& aID3MetaData, bool aTitleOnlyFlag);
-
-        /**
-        * @brief Parses the ID3 tag frames from the file and populates the
-        * aID3MetaData structure when an ID3V2 tag is found
-        *
-        * @param aID3MetaData Reference to a pre-allocated TAudioMetaData structure
-        * @returns None
-        */
-        void ReadHeaderID3V2(TAudioMetaData& aID3MetaData);
-
-        /**
-        * @brief Parses the frame and populates the iID3TagInfo structure
-        * when an ID3V22 tag is found.
-        *
-        * @param aPos Position of frame in file
-        * @returns None
-        */
-        void ReadFrameHeaderID3V22(uint32 aPos);
-
-        /**
-        * @brief Parses the frame and populates the iID3TagInfo structure
-        * when an ID3V2 tag is found.
-        *
-        * @param aPos Position of frame in file
-        * @returns None
-        */
-        void ReadFrameHeaderID3V2(uint32 aPos);
-
-        /**
-        * @brief Receives a ID3V2 frame and handles it accordingly. All of the frames
-        * sent to this function have ASCII strings in them.
-        *
-        * @param aFrameType Enumerated TFrameTypeID3V2 type; used to determine if
-        * Frame is supported
-        * @param aPos Position in file where frame data begins
-        * @param aSize Size of the frame data
-        * @param aID3MetaData Reference to repository for parsed data
-        * @returns None
-        */
-        void HandleID3V2FrameDataASCII(TID3V2FrameType      aframeType,
-                                       uint32               aPos,
-                                       uint32               aSize,
-                                       TAudioMetaData&      aID3MetaData);
-
-        /**
-        * @brief Receives a ID3V2 frame and handles it accordingly. All of the frames
-        * sent to this function have unicode strings in them.
-        *
-        * @param aFrameType Enumerated TFrameTypeID3V2 type; used to determine if
-        * Frame is supported
-        * @param aPos Position in file where frame data begins
-        * @param aSize Size of the frame data
-        * @param aEndianType Flag indicator regarding the text endian type
-        * @param aID3MetaData Reference to repository for parsed data
-        * @returns None
-        */
-        void HandleID3V2FrameDataUnicode16(TID3V2FrameType      aframeType,
-                                           uint32               aPos,
-                                           uint32               aSize,
-                                           uint32               aEndianType,
-                                           TAudioMetaData&      aID3MetaData);
-
-        /**
-        * @brief Receives a ID3V2 frame and handles it accordingly. All of the frames
-        * sent to this function have unicode strings in them.
-        *
-        * @param aFrameType Enumerated TFrameTypeID3V2 type; used to determine if
-        * Frame is supported
-        * @param aPos Position in file where frame data begins
-        * @param aSize Size of the frame data
-        * @param aTextType Flag indicator regarding the text type
-        * @param aID3MetaData Reference to repository for parsed data
-        * @returns None
-        */
-        void HandleID3V2FrameDataUTF16(TID3V2FrameType      aFrameType,
-                                       uint32               aPos,
-                                       uint32               aSize,
-                                       TTextType            aTextType,
-                                       TAudioMetaData&      aID3MetaData);
-
-        /**
-        * @brief Receives a ID3V2 frame and handles it accordingly. All of the frames
-        * sent to this function have UTF8 strings in them.
-        *
-        * @param aFrameType Enumerated TFrameTypeID3V2 type; used to determine if
-        * Frame is supported
-        * @param aPos Position in file where frame data begins
-        * @param aSize Size of the frame data
-        * @param aID3MetaData Pointer to repository for parsed data
-        * @returns None
-        */
-        void HandleID3V2FrameDataUTF8(TID3V2FrameType      aframeType,
-                                      uint32               aPos,
-                                      uint32               aSize,
-                                      TAudioMetaData&      aID3MetaData);
-
-        /**
-        * @brief Detects the ID3V2FrameType and returns the enum value that
-        * corresponds to the current frame.
-        *
-        * @param None
-        * @returns Value that describes the current frame of type TID3V2FrameType
-        */
-        TID3V2FrameType FrameSupportedID3V2(void);
-
-        /**
-        * @brief Detects the ID3V2FrameType and returns the enum value that
-        * corresponds to the current frame.
-        *
-        * @param None
-        * @returns Value that describes the current frame of type TID3V2FrameType
-        */
-        TID3V2FrameType FrameSupportedID3V22(void);
-
-
-        /**
-        * @brief Converts the data in the uint8* buffer and puts the data into the
-        * oscl_wchar* buffer
-        *
-        * @param aPtrFrameData Pointer to intput string format of either big
-        * or little endian.
-        * @param aSize Number of character elements in aPtrFrameData
-        * @param aEndianType Indicates if the encoded Unicode text in the
-        * aPtrFrameData buffer is in big or little endian.
-        * @param aPtrFrameData16 Pointer to the output string in unicode format.
-        * @returns None
-        */
-        void EightBitToWideCharBufferTransfer(
-            const uint8 *   aPtrFrameData,
-            uint32         aSize,
-            uint32         aEndianType,
-            oscl_wchar *      aPtrFrameData16);
-
-
-    private:
-        bool iTitleFoundFlag;
-        TID3TagInfo iID3TagInfo;
-        PVFile* iFilePtr;
-};
-
-#endif  // AUDIOMP3GETID3INFO_H_INCLUDED
-
diff --git a/fileformats/common/parser/include/audiometadata.h b/fileformats/common/parser/include/audiometadata.h
deleted file mode 100644
index 19c9856..0000000
--- a/fileformats/common/parser/include/audiometadata.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//                  A U D I O   M E T A   D A T A
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-
-/**
- *  @file audiometadata.h
- *  @brief This include file contains the class definition that handles
- *  the storage of meta data for an audio file.
- */
-
-
-#ifndef AUDIOMETADATA_H_INCLUDED
-#define AUDIOMETADATA_H_INCLUDED
-
-//----------------------------------------------------------------------------
-// INCLUDES
-//----------------------------------------------------------------------------
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-const uint32 KMaxFileNameMp3 = 0x100;
-
-//----------------------------------------------------------------------------
-// FORWARD CLASS DECLARATIONS
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// MACROS
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// CONSTANTS
-//----------------------------------------------------------------------------
-#define MAX_UNICODE_BUF_LEN_TITLE     KMaxFileNameMp3
-#define MAX_UNICODE_BUF_LEN_ARTIST       256
-#define MAX_UNICODE_BUF_LEN_ALBUM        256
-#define MAX_UNICODE_BUF_LEN_SET           32
-#define MAX_UNICODE_BUF_LEN_YEAR          32
-#define MAX_UNICODE_BUF_LEN_COMMENT      256
-#define MAX_UNICODE_BUF_LEN_COPYRIGHT    256
-#define MAX_UNICODE_BUF_LEN_GENRE        256
-#define MAX_UNICODE_BUF_LEN_TRACK_NUMBER   4
-#define MAX_UNICODE_BUF_LEN_TRACK_LENGTH   8
-#define MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE 4
-#define MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION 256
-
-
-// ID3 Version Types for MP3 files
-enum TTagType
-{
-    ENoTag,
-    EID3V1,
-    EID3V2,
-};
-
-//----------------------------------------------------------------------------
-// EXTERNAL VARIABLES REFERENCES
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// CLASS DEFINITIONS
-//----------------------------------------------------------------------------
-
-/**
- *  @brief The TAudioMetaData class encapsulates information about any audio
- *  clip found embedded in the file. The information is meta data to the audio
- *  file in that it is not part of the audio frames, but is extra information
- *  such as: artist, title, album, etc...
- */
-class TAudioMetaData
-{
-    public:
-
-        enum FormatType
-        {
-            EISO88591_CHAR,
-            EUTF16_WCHAR,
-            EUTF16BE_WCHAR,
-            EUTF8_CHAR,
-            EBYTEVALUE_UINT8,
-            FORMAT_INVALID
-        };
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_TITLE];
-                char pChar[MAX_UNICODE_BUF_LEN_TITLE];
-            };
-            FormatType iFormat;
-        } iTitle;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_ARTIST];
-                char pChar[MAX_UNICODE_BUF_LEN_ARTIST];
-            };
-            FormatType iFormat;
-        } iArtist;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_ALBUM];
-                char pChar[MAX_UNICODE_BUF_LEN_ALBUM];
-            };
-            FormatType iFormat;
-        } iAlbum;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_SET];
-                char pChar[MAX_UNICODE_BUF_LEN_SET];
-            };
-            FormatType iFormat;
-        } iSet;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_YEAR];
-                char pChar[MAX_UNICODE_BUF_LEN_YEAR];
-            };
-            FormatType iFormat;
-        } iYear;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_COMMENT];
-                char pChar[MAX_UNICODE_BUF_LEN_COMMENT];
-            };
-            FormatType iFormat;
-
-            union
-            {
-                oscl_wchar langcode_pWChar[MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE];
-                char langcode_pChar[MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE];
-            };
-            union
-            {
-                oscl_wchar description_pWChar[MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION];
-                char description_pChar[MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION];
-            };
-        } iComment;
-
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_COPYRIGHT];
-                char pChar[MAX_UNICODE_BUF_LEN_COPYRIGHT];
-            };
-            FormatType iFormat;
-        } iCopyright;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_GENRE];
-                char pChar[MAX_UNICODE_BUF_LEN_GENRE];
-                uint8 uint8_value;
-            };
-            FormatType iFormat;
-        } iGenre;
-
-        struct
-        {
-            union
-            {
-                oscl_wchar pWChar[MAX_UNICODE_BUF_LEN_TRACK_NUMBER];
-                char pChar[MAX_UNICODE_BUF_LEN_TRACK_NUMBER];
-                uint8 uint8_value;
-            };
-            FormatType iFormat;
-        } iTrackNumber;
-
-
-        TTagType iID3VersionType;
-        uint32   iMajorVersion;
-        uint32   iMinorVersion;
-        int64    iTrackLength;
-        uint32   iFileSizeInBytes;
-        uint32   iByteOffsetToStartOfAudioFrames;
-};
-
-#endif  // AUDIOMETADATA_H_INCLUDED
diff --git a/fileformats/common/parser/include/pvfile.h b/fileformats/common/parser/include/pvfile.h
index 8810652..9466880 100644
--- a/fileformats/common/parser/include/pvfile.h
+++ b/fileformats/common/parser/include/pvfile.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,10 +48,59 @@
 */
 
 class PVMFCPMPluginAccessInterfaceFactory;
-class PVMFCPMPluginLocalSyncAccessInterface;
 class PVMIDataStreamSyncInterface;
 class PvmiDataStreamObserver;
 
+#define PVFILE_DEFAULT_CACHE_SIZE 4*1024
+#define PVFILE_DEFAULT_ASYNC_READ_BUFFER_SIZE 0
+#define PVFILE_DEFAULT_NATIVE_ACCESS_MODE 0
+
+class PVFileCacheParams
+{
+    public:
+        PVFileCacheParams()
+        {
+            iCacheSize = PVFILE_DEFAULT_CACHE_SIZE;
+            iAsyncReadBuffSize = PVFILE_DEFAULT_ASYNC_READ_BUFFER_SIZE;
+            iNativeAccessMode = PVFILE_DEFAULT_NATIVE_ACCESS_MODE;
+            iPVLoggerEnableFlag = false;
+            iPVLoggerStateEnableFlag = false;
+        }
+
+        PVFileCacheParams(const PVFileCacheParams& a)
+        {
+            MyCopy(a);
+        }
+
+        /**
+         * The assignment operator
+         */
+        PVFileCacheParams& operator=(const PVFileCacheParams& a)
+        {
+            if (&a != this)
+            {
+                MyCopy(a);
+            }
+            return *this;
+        }
+
+        uint32 iCacheSize;
+        uint32 iAsyncReadBuffSize;
+        bool iPVLoggerEnableFlag;
+        bool iPVLoggerStateEnableFlag;
+        uint32 iNativeAccessMode;
+
+    private:
+        void MyCopy(const PVFileCacheParams& a)
+        {
+            iCacheSize = a.iCacheSize;
+            iAsyncReadBuffSize = a.iAsyncReadBuffSize;
+            iPVLoggerEnableFlag = a.iPVLoggerEnableFlag;
+            iPVLoggerStateEnableFlag = a.iPVLoggerStateEnableFlag;
+            iNativeAccessMode = a.iNativeAccessMode;
+        }
+};
+
 class PVFile
 {
     public:
@@ -61,7 +110,6 @@
             iFile = NULL;
             iFileHandle = NULL;
             iCPMAccessFactory = NULL;
-            iCPMAccess = NULL;
             iFilePtr = NULL;
             iDataStreamAccess = NULL;
             iFileSize = 0;
@@ -76,12 +124,12 @@
             iFilePtr = a.iFilePtr;
             iFileHandle = a.iFileHandle;
             iCPMAccessFactory = a.iCPMAccessFactory;
-            iCPMAccess = a.iCPMAccess;
             iDataStreamAccess = a.iDataStreamAccess;
             iFileSize = a.iFileSize;
             iFileSizeAvailable = a.iFileSizeAvailable;
             iDataStreamSession = a.iDataStreamSession;
             iRequestReadCapacityNotificationID = a.iRequestReadCapacityNotificationID;
+            iOsclFileCacheParams = a.iOsclFileCacheParams;
         }
 
         //copy constructor.
@@ -138,7 +186,6 @@
         {
             if ((iFilePtr != NULL) ||
                     (iFile != NULL) ||
-                    (iCPMAccess != NULL) ||
                     (iDataStreamAccess != NULL))
             {
                 return true;
@@ -146,6 +193,16 @@
             return false;
         }
 
+        //Only valid in case Oscl_File class is being used
+        //internally for file access. In case of datastream
+        //access or in case of Oscl_File ptr provided for outside
+        //via SetFilePtr API, it is assumed that implementor of datastream
+        //has picked appropriate caching mechanism.
+        void SetFileCacheParams(PVFileCacheParams aParams)
+        {
+            iOsclFileCacheParams = aParams;
+        }
+
         //Access APIs, same functionality as Oscl File I/O.
         OSCL_IMPORT_REF int32 Seek(int32 offset, Oscl_File::seek_type origin);
         OSCL_IMPORT_REF int32 Tell();
@@ -190,7 +247,6 @@
 
         //Internal implementation.
         Oscl_File* iFile;
-        PVMFCPMPluginLocalSyncAccessInterface *iCPMAccess;
         PVMIDataStreamSyncInterface* iDataStreamAccess;
         int32 iDataStreamSession;
 
@@ -199,6 +255,7 @@
         uint32 iFileSize;
         bool iFileSizeAvailable;
         uint32 iRequestReadCapacityNotificationID;
+        PVFileCacheParams iOsclFileCacheParams;
 };
 
 
diff --git a/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_factory.h b/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_factory.h
index 0fd3107..8db1fa8 100644
--- a/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_factory.h
+++ b/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_impl.h b/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_impl.h
index 6c697e4..8cf1905 100644
--- a/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_impl.h
+++ b/fileformats/common/parser/include/pvmi_datastreamsyncinterface_ref_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/common/parser/include/virtual_buffer.h b/fileformats/common/parser/include/virtual_buffer.h
index 83a9bf8..f2a25e7 100644
--- a/fileformats/common/parser/include/virtual_buffer.h
+++ b/fileformats/common/parser/include/virtual_buffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -71,7 +71,10 @@
         // operators
         TBufferAccess& operator*();                         // indirection
         VirtualBuffer& operator=(const VirtualBuffer&);     // assignment
-        operator TBufferAccess*();                          // cast
+        operator TBufferAccess*()
+        {
+            return pCurrFragPos;
+        }; 	// cast
         VirtualBuffer& operator++();                        // prefix increment
         VirtualBuffer operator++(int);                      // postfix increment
         VirtualBuffer& operator+=(const int increment);     // addition
@@ -191,12 +194,6 @@
 }
 
 template<class TBufferAccess>
-VirtualBuffer<TBufferAccess>::operator TBufferAccess*()
-{
-    return pCurrFragPos;
-}
-
-template<class TBufferAccess>
 VirtualBuffer<TBufferAccess>& VirtualBuffer<TBufferAccess>::operator++()
 {
     advance();
diff --git a/fileformats/common/parser/src/audiogetid3info.cpp b/fileformats/common/parser/src/audiogetid3info.cpp
deleted file mode 100644
index 39bf356..0000000
--- a/fileformats/common/parser/src/audiogetid3info.cpp
+++ /dev/null
@@ -1,2522 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//           A U D I O    M P 3   G E T    I D 3    I N F O
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-
-/**
- * @file audiogetid3info.cpp
- * @brief This include file contains the methods to obtain the required
- * ID3V1 or ID3V2 information from a specified file. The various tasks it does
- * to get the ID3 data are reading from the file, determining the ID3
- * version, checking for a valid ID3 frame type, and extracting the ID3
- * frame information.
- */
-
-//----------------------------------------------------------------------------
-// INCLUDES
-//----------------------------------------------------------------------------
-
-#include "audiogetid3info.h"
-
-#include "oscl_mem.h"
-#include "oscl_stdstring.h"
-#include "oscl_utf8conv.h"
-
-//----------------------------------------------------------------------------
-// MACROS
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// CONSTANTS
-//----------------------------------------------------------------------------
-static const uint8 ID3Tag[] = "ID3";
-static const uint8 TAGTag[] = "TAG";
-
-static uint32 SafeSynchIntToInt32(uint32 SafeSynchInteger)
-{
-    uint8 * pBuf = (uint8 *) & (SafeSynchInteger);
-    uint8 tmpByte = 0;
-    int32 i = 0;
-    uint32 Integer = 0;
-
-    // This loop will calculate the correct size from the bytes designated for size
-    // It is stored as a SynchSafe Integer. This means the 8th bit is reserved in
-    // each byte and not used for integer precision.. The number is effectively 28
-    // bits in length/precision.
-    // Assumes: sizeof(uint32) = 4 Bytes
-    for (i = 0; i < 4; i++)
-    {
-#if (OSCL_BYTE_ORDER_LITTLE_ENDIAN)
-        tmpByte = (uint8)(pBuf[i] & MASK127);
-#elif (OSCL_BYTE_ORDER_BIG_ENDIAN)
-        tmpByte = pBuf[4-i-1] & MASK127;
-#else
-#error "Must Specify ENDIANNESS"
-#endif
-        // now shift the data to it's correct place
-        Integer += tmpByte << VALID_BITS_IN_SYNC_SAFE_BYTE * i;
-    }
-
-    return Integer;
-}
-
-// Read in byte data and take most significant byte first
-static bool readByteData(PVFile *fp, uint32 length, uint8 *data)
-{
-    uint32 bytesRead;
-    bytesRead = fp->Read(data, 1, length);
-
-    if (bytesRead < (uint32)length) // read byte data failed
-    {
-        return false;
-    }
-
-    return true;
-}
-
-// Read in the 32 bits byte by byte and take most significant byte first
-static bool read32(PVFile *fp, uint32 &data)
-{
-    const int32 N = 4;
-    uint8 bytes[N];
-    data = 0;
-
-    int32 retVal = (int32)(fp->Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-    {
-        return false;
-    }
-
-    for (int32 i = 0; i < N; i++)
-    {
-        data = (data << 8) | bytes[i];
-    }
-
-    return true;
-}
-
-
-// Read in the 32 bits byte by byte and take most significant byte first
-static bool read24(PVFile *fp, uint32 &data)
-{
-    const int32 N = 3;
-    uint8 bytes[N];
-    data = 0;
-
-    int32 retVal = (int32)(fp->Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-    {
-        return false;
-    }
-
-    for (int32 i = 0; i < N; i++)
-    {
-        data = (data << 8) | bytes[i];
-    }
-
-    return true;
-}
-
-// Read in the 8 bit byte
-static bool read8(PVFile *fp, uint8 &data)
-{
-    data = 0;
-
-    int32 retVal = (int32)(fp->Read((void*) & data, 1, 1));
-
-    if (retVal < 1)
-    {
-        return false;
-    }
-
-    return true;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::CID3TagParser()
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: None
-//
-//  Outputs: None
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function is the constructor for the CID3TagParser class.
-//
-//------------------------------------------------------------------------------
-
-CID3TagParser::CID3TagParser()
-{
-    iTitleFoundFlag = false;
-    oscl_memset(&iID3TagInfo, 0, sizeof(iID3TagInfo));
-    iFilePtr = NULL;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::~CID3TagParser
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: None
-//
-//  Outputs: None
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function is the destructor for the CID3TagParser class.
-//
-//------------------------------------------------------------------------------
-OSCL_EXPORT_REF CID3TagParser::~CID3TagParser()
-{
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::NewL()
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: None
-//
-//  Outputs: None
-//
-//  Returns: Returns a pointer to an instance of this class
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function is the 2nd phase constructor for this object.It also
-// is to be available to application programs and other DLLs.
-//
-//------------------------------------------------------------------------------
-OSCL_EXPORT_REF CID3TagParser* CID3TagParser::NewL()
-{
-    OsclAuditCB myCB;
-    OsclMemInit(myCB);
-    CID3TagParser* self = OSCL_AUDIT_NEW(myCB, CID3TagParser, ());
-    self->ConstructL();
-    return self;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::Delete()
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: Pointer to an instance of this class
-//
-//  Outputs: None
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// Destructor for use with NewL
-//
-//------------------------------------------------------------------------------
-OSCL_EXPORT_REF  void CID3TagParser::Delete(CID3TagParser* aObject)
-{
-    OSCL_DELETE(aObject);
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::ParseTagInfo(
-//                                            TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aID3MetaData - Reference to a pre-allocated TAudioMetaData structure
-//
-//  Outputs:
-//     aID3MetaData - Reference to a pre-allocated TAudioMetaData structure
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function causes the checks for the existance of an ID3V1 or ID3V2 tag
-// associated with the file under investigation. It then makes a function
-// call to get the information from the tag to populate aID3MetaData.
-//
-//------------------------------------------------------------------------------
-// CAUTION
-// Leaves the File Pointer a the start of the first audio frame
-//------------------------------------------------------------------------------
-OSCL_EXPORT_REF int32 CID3TagParser::ParseID3TagInfo(PVFile * aFile,
-        TAudioMetaData& aID3MetaData)
-{
-    iTitleFoundFlag = false;
-    int32 iCurrentFilePosn = 0;
-
-    // Initialize the ID3 elements to be unknown
-    aID3MetaData.iTitle.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iArtist.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iAlbum.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iSet.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iYear.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iComment.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iCopyright.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iGenre.iFormat = TAudioMetaData::FORMAT_INVALID;
-    aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::FORMAT_INVALID;
-
-    if (aFile != NULL)
-    {
-        iFilePtr = aFile;
-        // SEEK TO THE END OF THE FILE AND GET FILE SIZE
-        iCurrentFilePosn = iFilePtr->Tell();
-        if (iCurrentFilePosn == -1)
-        {
-            return PVID3PARSER_FILE_OPERATION_FAILED;
-        }
-
-        if (iFilePtr->Seek(0, Oscl_File::SEEKEND) == -1)
-        {
-            return PVID3PARSER_FILE_OPERATION_FAILED;
-        }
-
-        aID3MetaData.iFileSizeInBytes = iFilePtr->Tell();
-        if (aID3MetaData.iFileSizeInBytes == (uint32) - 1)
-        {
-            return PVID3PARSER_FILE_OPERATION_FAILED;
-        }
-        if (iFilePtr->Seek(iCurrentFilePosn, Oscl_File::SEEKSET) == -1)
-        {
-            return PVID3PARSER_FILE_OPERATION_FAILED;
-        }
-
-        // Initialize the ID3 tag
-        aID3MetaData.iID3VersionType = ENoTag;
-
-        if (CheckForTagID3V2(aID3MetaData))
-        {
-            aID3MetaData.iID3VersionType = EID3V2;
-            iCurrentFilePosn = iFilePtr->Tell();
-            if (iCurrentFilePosn == -1)
-            {
-                return PVID3PARSER_FILE_OPERATION_FAILED;
-            }
-
-            ReadHeaderID3V2(aID3MetaData);
-
-            if (!iTitleFoundFlag)
-            {
-                if (CheckForTagID3V1(aID3MetaData))
-                {
-                    ReadID3V1Tag(aID3MetaData, true);
-                }
-            }
-
-            if (iFilePtr->Seek(iCurrentFilePosn, Oscl_File::SEEKSET) == -1)
-            {
-                return PVID3PARSER_FILE_OPERATION_FAILED;
-            }
-        }
-        else
-        {
-            if (CheckForTagID3V1(aID3MetaData))
-            {
-                aID3MetaData.iID3VersionType = EID3V1;
-                ReadID3V1Tag(aID3MetaData, false);
-
-                aID3MetaData.iByteOffsetToStartOfAudioFrames = 0;
-            }
-            else // No ID3 tag was found.
-            {
-                aID3MetaData.iID3VersionType = ENoTag;
-                aID3MetaData.iByteOffsetToStartOfAudioFrames = 0;
-            }
-
-            if (iFilePtr->Seek(iCurrentFilePosn, Oscl_File::SEEKSET) == -1)
-            {
-                return PVID3PARSER_FILE_OPERATION_FAILED;
-            }
-        }
-
-        return PVID3PARSER_EVERYTHING_FINE;
-    }
-    else
-    {
-        return PVID3PARSER_FILE_OPEN_FAILED;
-    }
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::ConstructL()
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: None
-//
-//  Outputs: None
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function is the constructor for the CID3TagParser class.
-//
-//------------------------------------------------------------------------------
-void CID3TagParser::ConstructL()
-{
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::CheckForTagID3V2(TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aID3MetaData - reference to a TAudioMetaData structure
-//
-//  Outputs: None
-//
-//  Returns:
-//     bool - true if Id3V2 tag present otherwise false.
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function checks the file for the presence of ID3V2 Tag attached to
-//  the beginning of the file. This tag is  denoted by the string "ID3"
-//  at the very beginning of the file.
-//------------------------------------------------------------------------------
-
-bool CID3TagParser::CheckForTagID3V2(TAudioMetaData& aID3MetaData)
-{
-    uint8 id3Header[ID3V2_TAG_NUM_BYTES_HEADER+1] = {0};
-
-    // Make sure file is big enough to contain a tag
-    if (aID3MetaData.iFileSizeInBytes >= ID3V2_TAG_NUM_BYTES_HEADER)
-    {
-        if (!readByteData(iFilePtr, ID3V2_TAG_NUM_BYTES_HEADER, id3Header))
-        {
-            return false;
-        }
-
-        // Read in ID3 Tags at the front of the file.
-        if (oscl_memcmp(ID3Tag, id3Header, 3) == 0)
-        {
-            return true;
-        }
-    }
-    return false;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::CheckForTagID3V1(TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aID3MetaData - reference to a TAudioMetaData structure
-//
-//  Outputs: None
-//
-//  Returns:
-//     bool - true if Id3V1 tag present otherwise false
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function checks the file for the presence of ID3V1 Tag. This tag is
-// denoted by the string "TAG" starting 128 bytes in from the end-of-file.
-//
-//------------------------------------------------------------------------------
-bool CID3TagParser::CheckForTagID3V1(TAudioMetaData& aID3MetaData)
-{
-    uint8 tagHeader[ID3V1_TAG_NUM_BYTES_HEADER+1] = {0};
-
-    // Make sure file is big enough to contain a tag
-    if (aID3MetaData.iFileSizeInBytes >= ID3V1_MAX_NUM_BYTES_TOTAL)
-    {
-        uint32 nBytes = 0;
-        // Read the value at the tag position
-
-        nBytes = aID3MetaData.iFileSizeInBytes - ID3V1_MAX_NUM_BYTES_TOTAL;
-        if (iFilePtr->Seek(nBytes, Oscl_File::SEEKSET) == -1)
-        {
-            return false;
-        }
-
-        if (!readByteData(iFilePtr, ID3V1_TAG_NUM_BYTES_HEADER, tagHeader))
-        {
-            return false;
-        }
-
-        // Read in ID3 Tags at the front of the file.
-        if (oscl_memcmp(TAGTag, tagHeader, 3) == 0)
-        {
-            aID3MetaData.iMajorVersion = 1;
-            aID3MetaData.iMinorVersion = 0;
-            return true;
-        }
-    }
-    return false;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::ReadID3V1Tag(TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aID3MetaData - reference to a TAudioMetaData structure
-//
-//  Outputs:
-//     aID3MetaData - reference to a TAudioMetaData structure
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-// This function parses the file and populates the aID3MetaData structure when
-// an ID3V1 tag is found to be attached to the file and no ID3V2 tag was
-// found. The data in the ID3V1 tag can only be ASCII, so the ConvertToUnicode
-// must be called for all fields read from the ID3V1 tag.
-//
-//----------------------------------------------------------------------------
-// REQUIREMENTS
-//
-//  The track must be declared in an ASCII character and not a numeric string.
-//------------------------------------------------------------------------------
-
-void CID3TagParser::ReadID3V1Tag(TAudioMetaData& aID3MetaData,
-                                 bool           aTitleOnlyFlag)
-{
-    char Buf[ID3V1_MAX_NUM_BYTES_FIELD_SIZE+1] = {0};
-
-    // Read and convert title
-    oscl_memset(Buf, 0, ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1);
-    if (readByteData(iFilePtr, ID3V1_MAX_NUM_BYTES_TITLE, (uint8 *)Buf) == false)
-    {
-        return;
-    }
-    Buf[ID3V1_MAX_NUM_BYTES_FIELD_SIZE] = 0;
-
-    oscl_strncpy(aID3MetaData.iTitle.pChar, Buf, oscl_strlen(Buf));
-    aID3MetaData.iTitle.pChar[oscl_strlen(Buf)] = 0;
-
-    if ((aID3MetaData.iID3VersionType == EID3V2) && (aTitleOnlyFlag == true))
-    {
-        aID3MetaData.iTitle.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        iTitleFoundFlag = true;
-        return;
-    }
-
-    iTitleFoundFlag = true;
-
-    if (!aTitleOnlyFlag)
-    {
-        // Set the format for title
-        aID3MetaData.iTitle.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        // Read and convert artist
-        oscl_memset(Buf, 0, ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1);
-        if (readByteData(iFilePtr, ID3V1_MAX_NUM_BYTES_ARTIST, (uint8*)Buf) == false)
-        {
-            return;
-        }
-        Buf[ID3V1_MAX_NUM_BYTES_ARTIST] = 0;
-
-        oscl_strncpy(aID3MetaData.iArtist.pChar, Buf, oscl_strlen(Buf));
-        aID3MetaData.iArtist.pChar[oscl_strlen(Buf)] = 0;
-        aID3MetaData.iArtist.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        // Read and convert album
-        oscl_memset(Buf, 0, ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1);
-        if (readByteData(iFilePtr, ID3V1_MAX_NUM_BYTES_ALBUM, (uint8*)Buf) == false)
-        {
-            return;
-        }
-        Buf[ID3V1_MAX_NUM_BYTES_ALBUM] = 0;
-
-        oscl_strncpy(aID3MetaData.iAlbum.pChar, Buf, oscl_strlen(Buf));
-        aID3MetaData.iAlbum.pChar[oscl_strlen(Buf)] = 0;
-        aID3MetaData.iAlbum.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        // Read and convert year
-        oscl_memset(Buf, 0, ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1);
-        if (readByteData(iFilePtr, ID3V1_MAX_NUM_BYTES_YEAR, (uint8*)Buf) == false)
-        {
-            return;
-        }
-        Buf[ID3V1_MAX_NUM_BYTES_YEAR] = 0;
-
-        oscl_strncpy(aID3MetaData.iYear.pChar, Buf, oscl_strlen(Buf));
-        aID3MetaData.iYear.pChar[oscl_strlen(Buf)] = 0;
-        aID3MetaData.iYear.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        // Read and convert comment & possibly track number
-        oscl_memset(Buf, 0, ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1);
-        if (readByteData(iFilePtr, ID3V1_MAX_NUM_BYTES_COMMENT, (uint8*)Buf) == false)
-        {
-            return;
-        }
-        if ((Buf[ID3V1_MAX_NUM_BYTES_COMMENT-2] == 0)
-                && (Buf[ID3V1_MAX_NUM_BYTES_COMMENT-1] != 0))
-        {
-            // This would mean its an ID3v1.1 tag and hence has the
-            // the track number also, so extract it
-            aID3MetaData.iTrackNumber.uint8_value = (uint8)Buf[ID3V1_MAX_NUM_BYTES_COMMENT-1];
-            aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EBYTEVALUE_UINT8;
-            aID3MetaData.iMinorVersion = 1;
-        }
-        else
-        {
-            // Track number is not available
-            aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::FORMAT_INVALID;
-        }
-        Buf[ID3V1_MAX_NUM_BYTES_COMMENT] = 0;
-
-        oscl_strncpy(aID3MetaData.iComment.pChar, Buf, oscl_strlen(Buf));
-        aID3MetaData.iComment.pChar[oscl_strlen(Buf)] = 0;
-        aID3MetaData.iComment.iFormat = TAudioMetaData::EISO88591_CHAR;
-        // Comment language code and comment not available in ID3v1
-        oscl_memset(aID3MetaData.iComment.description_pChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-        oscl_memset(aID3MetaData.iComment.langcode_pChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-
-        // Read the genre value
-        oscl_memset(Buf, 0, ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1);
-        if (readByteData(iFilePtr, ID3V1_MAX_NUM_BYTES_GENRE, (uint8*)Buf) == false)
-        {
-            return;
-        }
-        aID3MetaData.iGenre.uint8_value = (uint8)Buf[0];
-        aID3MetaData.iGenre.iFormat = TAudioMetaData::EBYTEVALUE_UINT8;
-    }
-}
-
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::ReadHeaderID3V2(TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Outputs:
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function parses the ID3 tag frames from the file and populates the
-//  aID3MetaData structure when an ID3V2 tag is found attached to the start
-//  of a file.
-//
-//------------------------------------------------------------------------------
-
-void CID3TagParser::ReadHeaderID3V2(TAudioMetaData& aID3MetaData)
-{
-    if (iFilePtr->Seek(0, Oscl_File::SEEKSET) == -1)
-    {
-        return;
-    }
-
-    // Read "ID3" tag at start of file.
-    uint8 identifierBuf[ID3V2_TAG_NUM_BYTES_ID];
-    if (readByteData(iFilePtr, ID3V2_TAG_NUM_BYTES_ID, identifierBuf) == false)
-    {
-        return;
-    }
-
-    // Read and convert tag versions, Major and Minor
-    uint8 ID3V2MajorVer, ID3V2MinorVer;
-    if (read8(iFilePtr, ID3V2MajorVer) == false)
-    {
-        return;
-    }
-    if (read8(iFilePtr, ID3V2MinorVer) == false)
-    {
-        return;
-    }
-    aID3MetaData.iMajorVersion = ID3V2MajorVer;
-    aID3MetaData.iMinorVersion = ID3V2MinorVer;
-
-    // Read and convert tag flags
-    if (read8(iFilePtr, iID3TagInfo.iID3V2TagFlagsV2) == false)
-    {
-        return;
-    }
-
-    // Read and convert tag size
-    if (read32(iFilePtr, iID3TagInfo.iID3V2TagSize) == false)
-    {
-        return;
-    }
-
-    // Now check if an extended header exists
-    bool extHeaderFlag = false;
-    if (iID3TagInfo.iID3V2TagFlagsV2 & FLAGMASK)
-    {
-        extHeaderFlag = true;
-        uint8 extHeader[ID3V2_TAG_EXTENDED_HEADER_TOTAL_SIZE];
-        if (readByteData(iFilePtr, ID3V2_TAG_EXTENDED_HEADER_TOTAL_SIZE, extHeader) == false)
-        {
-            return;
-        }
-    }
-
-    // tagSize will store the file's Id3v2 tag size
-    uint32 tagSize = 0;
-    uint32 i;
-
-    tagSize = SafeSynchIntToInt32(iID3TagInfo.iID3V2TagSize);
-
-    // set iByteOffsetToStartOfAudioFrames and it must account for the frame header
-    aID3MetaData.iByteOffsetToStartOfAudioFrames =
-        tagSize + ID3V2_TAG_NUM_BYTES_HEADER;
-
-    // Add Footer Header Size if present
-    if (iID3TagInfo.iID3V2TagFlagsV2 & FOOTERMASK)
-    {
-        aID3MetaData.iByteOffsetToStartOfAudioFrames += ID3V2_TAG_NUM_BYTES_FOOTER;
-    }
-
-    uint32  tagExtHeaderSize = 0;
-    // Calculate the length of the extended header.
-    if (extHeaderFlag)
-    {
-        tagExtHeaderSize = SafeSynchIntToInt32(iID3TagInfo.iID3V2ExtendedHeader);
-        aID3MetaData.iByteOffsetToStartOfAudioFrames +=
-            tagExtHeaderSize + ID3V2_TAG_EXTENDED_HEADER_TOTAL_SIZE;
-    }
-
-    TID3V2FrameType frameType;
-    uint32 currFrameLength;
-    uint32 aIDV2FrameNumBytesHeader;
-
-    i = ID3V2_TAG_NUM_BYTES_HEADER; // must account for the tag header
-    if (extHeaderFlag)
-    {
-        i += tagExtHeaderSize + ID3V2_TAG_EXTENDED_HEADER_TOTAL_SIZE;
-    }
-
-    if (ID3V2MajorVer == 0x02)
-        aIDV2FrameNumBytesHeader = ID3V22_FRAME_NUM_BYTES_HEADER;
-    else
-        aIDV2FrameNumBytesHeader = ID3V2_FRAME_NUM_BYTES_HEADER;
-
-    while (i <= tagSize)
-    {
-        // Read the frame header
-        if (iFilePtr->Seek(i, Oscl_File::SEEKSET) == -1)
-        {
-            return;
-        }
-
-        if (ID3V2MajorVer == 0x02)
-            ReadFrameHeaderID3V22(i);
-        else
-            ReadFrameHeaderID3V2(i);
-
-        if (ID3V2MajorVer == 0x04)
-            iID3TagInfo.iID3V2FrameSize = SafeSynchIntToInt32(iID3TagInfo.iID3V2FrameSize);
-
-
-        currFrameLength = 0;
-        currFrameLength = iID3TagInfo.iID3V2FrameSize;
-        if (currFrameLength > tagSize)
-        {
-            break;
-        }
-        // handle the frame header
-        if (ID3V2MajorVer == 0x02)
-            frameType = FrameSupportedID3V22();
-        else
-            frameType = FrameSupportedID3V2();
-
-        /*
-         * Check the byte after the frame header for indication of unicode.
-         * If the frame is type TLEN then it has a numeric string and do not
-         * make a check for unicode type.
-         */
-        if ((frameType != ETLEN) &&
-                ((currFrameLength > 1) && (frameType != EFrameNotSupported)))
-        {
-            uint8 unicodeCheck;
-
-            if (read8(iFilePtr, unicodeCheck) == false)
-            {
-                return;
-            }
-
-            if (unicodeCheck == EISO88591)
-            {
-                // This frame contains normal ASCII text strings. (ISO-8859-1)
-                iID3TagInfo.iTextType = EISO88591;
-                HandleID3V2FrameDataASCII(frameType,
-                                          i + aIDV2FrameNumBytesHeader + 1,
-                                          currFrameLength - 1,
-                                          aID3MetaData);
-            }
-            else if (unicodeCheck == EUTF16)
-            {
-                uint8 endianCheck;
-
-                // Special case for comments. The first 3 bytes are the have
-                // language code, which does not have any BOM
-                if (frameType == ECOMT)
-                {
-                    uint8 endianData[4];
-
-                    if (readByteData(iFilePtr, 4, endianData) == false)
-                    {
-                        return;
-                    }
-                    endianCheck = endianData[3];
-                }
-                else
-                {
-                    if (read8(iFilePtr, endianCheck) == false)
-                    {
-                        return;
-                    }
-                }
-
-                // This frame's text strings are Unicode and the frame
-                // does include a BOM value. (UTF-16)
-                iID3TagInfo.iTextType = EUTF16;
-
-                if ((endianCheck != UNICODE_LITTLE_ENDIAN_INDICATOR) &&
-                        (endianCheck != UNICODE_BIG_ENDIAN_INDICATOR))
-                {
-                    frameType = EFrameNotSupported;
-                    break;
-                }
-                HandleID3V2FrameDataUTF16(frameType,
-                                          i + aIDV2FrameNumBytesHeader + 1,
-                                          currFrameLength - 1,
-                                          EUTF16,
-                                          aID3MetaData);
-            }
-            else if (unicodeCheck == EUTF16BE)
-            {
-                // This frame's text strings are Unicode but the frame
-                // does not contain a BOM(byte order mark) (UTF-16BE)
-
-                iID3TagInfo.iTextType = EUTF16BE;
-
-                // Big Endian is assumed since the frame did not specify the endian type.
-                HandleID3V2FrameDataUTF16(frameType,
-                                          i + aIDV2FrameNumBytesHeader + 1,
-                                          currFrameLength - 1,
-                                          EUTF16BE,
-                                          aID3MetaData);
-            }
-            else if (unicodeCheck == EUTF8)
-            {
-                // This frame's text strings are Unicode (UTF-8)
-                iID3TagInfo.iTextType = EUTF8;
-                HandleID3V2FrameDataUTF8(frameType,
-                                         i + aIDV2FrameNumBytesHeader + 1,
-                                         currFrameLength - 1,
-                                         aID3MetaData);
-            }
-            else
-            {
-                iID3TagInfo.iTextType = ENoType;
-
-                // This case is when no text type is defined in the frame.
-                HandleID3V2FrameDataASCII(frameType,
-                                          i + aIDV2FrameNumBytesHeader,
-                                          currFrameLength,
-                                          aID3MetaData);
-            }
-        }
-        else
-        {
-            if (frameType == EEND)
-            {
-                i = tagSize + 1;
-            }
-            else
-            {
-                iID3TagInfo.iTextType = ENoType;
-                HandleID3V2FrameDataASCII(frameType,
-                                          i + aIDV2FrameNumBytesHeader,
-                                          currFrameLength,
-                                          aID3MetaData);
-            }
-        }
-        i += currFrameLength + aIDV2FrameNumBytesHeader;
-    }
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::ReadFrameHeaderID3V2(uint32 aPos)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aPos - position in file where frame
-//
-//  Outputs: None
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function parses the frame and populates the iID3TagInfo structure
-//  when an ID3V2 tag is found to be attached to the file.
-//
-//------------------------------------------------------------------------------
-
-void CID3TagParser::ReadFrameHeaderID3V2(uint32 aPos)
-{
-    if (readByteData(iFilePtr, ID3V2_FRAME_NUM_BYTES_ID, iID3TagInfo.iID3V2FrameID) == false)
-    {
-        return;
-    }
-    if (read32(iFilePtr, iID3TagInfo.iID3V2FrameSize) == false)
-    {
-        return;
-    }
-    if (readByteData(iFilePtr, ID3V2_FRAME_NUM_BYTES_FLAG, iID3TagInfo.iID3V2FrameFlag) == false)
-    {
-        return;
-    }
-
-    iID3TagInfo.iPositionInFile = aPos;
-
-    return;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::ReadFrameHeaderID3V22(uint32 aPos)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aPos - position in file where frame
-//
-//  Outputs: None
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function parses the frame and populates the iID3TagInfo structure
-//  when an ID3V2 tag is found to be attached to the file.
-//
-//------------------------------------------------------------------------------
-
-void CID3TagParser::ReadFrameHeaderID3V22(uint32 aPos)
-{
-    if (readByteData(iFilePtr, ID3V22_FRAME_NUM_BYTES_ID, iID3TagInfo.iID3V2FrameID) == false)
-    {
-        return;
-    }
-    if (read24(iFilePtr, iID3TagInfo.iID3V2FrameSize) == false)
-    {
-        return;
-    }
-
-    iID3TagInfo.iPositionInFile = aPos;
-
-    return;
-}
-
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::HandleID3V2FrameDataASCII(
-//                                               TFrameTypeID3V2 aFrameType,
-//                                               uint32            aPos,
-//                                               uint32            aSize,
-//                                               TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aFrameType   - enumerated TFrameTypeID3V2 type - used to determine if
-//                    Frame is supported
-//     aPos         - position in file where frame data begins
-//     aSize        - size of the frame data
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Outputs:
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function receives a ID3V2 frame and handles it accordingly. Each
-//  frame header is composed of 10 bytes - 4 bytes for FrameID, 4 bytes for
-//  FrameSize, and 2 bytes for FrameFlags, respectively. Once we have a
-//  frame's unique FrameID, we can handle the frame accordingly. (eg. The
-//  frame with FrameID = "TIT2" contains data describing the title.
-//  Clearly, the data in that frame should be copied to it respective
-//  location in aID3MetaData. The location for the data with FrameID = "TIT2"
-//  goes in the aID3MetaData.iTitle buffer. This line of code accomplishes our
-//  objective: aID3MetaData.iTitle.Copy(ptrFrameData16);
-//
-//------------------------------------------------------------------------------
-
-void CID3TagParser::HandleID3V2FrameDataASCII(TID3V2FrameType      aFrameType,
-        uint32               aPos,
-        uint32               aSize,
-        TAudioMetaData&      aID3MetaData)
-{
-    if (iFilePtr->Seek(aPos, Oscl_File::SEEKSET) == -1)
-    {
-        return;
-    }
-
-    // create buffers to store frame data
-    uint8* frameData = OSCL_ARRAY_NEW(uint8, aSize + 1);
-    if (frameData == NULL)
-    {
-        return;
-    }
-
-    uint8* ptrFrameData = frameData;
-    oscl_memset(frameData,  0, aSize + 1);
-
-    switch (aFrameType)
-    {
-        case ETIT2:
-        {
-            // Handle TIT2 frame
-            // The TIT2 frame contains data referring to the title.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iTitle.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_TITLE);
-            aID3MetaData.iTitle.pChar[MAX_UNICODE_BUF_LEN_TITLE-1] = 0;
-            aID3MetaData.iTitle.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-            iTitleFoundFlag = true;
-        }
-        break;
-
-        case ETPE1:
-        {
-            // Handle TPE1 frame
-            // The TPE1 frame contains data referring to the artist.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iArtist.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_ARTIST);
-            aID3MetaData.iArtist.pChar[MAX_UNICODE_BUF_LEN_ARTIST-1] = 0;
-            aID3MetaData.iArtist.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-
-        }
-        break;
-
-        case ETPOS:
-        {
-            // Handle TPOS/TPA frame
-            // The TPOS frame contains data defining if this is part of
-            // a multi disc set.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iSet.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_SET);
-            aID3MetaData.iSet.pChar[MAX_UNICODE_BUF_LEN_SET-1] = 0;
-            aID3MetaData.iSet.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        }
-        break;
-
-        case ETALB:
-        {
-            // Handle TALB frame
-            // The TALB frame contains data referring to the album.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iAlbum.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_ALBUM);
-            aID3MetaData.iAlbum.pChar[MAX_UNICODE_BUF_LEN_ALBUM-1] = 0;
-            aID3MetaData.iAlbum.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        }
-        break;
-
-        case ETCOP:
-        {
-            // Handle TCOP frame
-            // The TCOP frame contains data referring to the copyright.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iCopyright.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_COPYRIGHT);
-            aID3MetaData.iCopyright.pChar[MAX_UNICODE_BUF_LEN_COPYRIGHT-1] = 0;
-            aID3MetaData.iCopyright.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        }
-        break;
-
-        case ETCON:
-        {
-            // Handle TCON frame
-            // The TCON frame contains data referring to the genre.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iGenre.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_GENRE);
-            aID3MetaData.iGenre.pChar[MAX_UNICODE_BUF_LEN_GENRE-1] = 0;
-            aID3MetaData.iGenre.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-
-        }
-        break;
-
-        case ETRCK:
-        {
-            // Handle TRCK frame
-            // The TRCK frame contains data referring to the track number.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iTrackNumber.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_TRACK_NUMBER);
-            aID3MetaData.iTrackNumber.pChar[MAX_UNICODE_BUF_LEN_TRACK_NUMBER-1] = 0;
-            aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EISO88591_CHAR;
-
-        }
-        break;
-
-        case ETLEN:
-        {
-            // Handle TLEN frame
-            // The TLEN frame contains data referring to the recording time.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            // The ID3 Track Length is a numeric string in milliseconds.
-            uint32 temp32Low  = 0;
-            uint32 temp32High = 0;
-            int32 numericStringLen = oscl_strlen((const char*)ptrFrameData);
-            int32 i;
-            if (numericStringLen > 4)
-            {
-                for (i = 0; i < 4; i++)
-                {
-                    temp32Low  |= ptrFrameData[numericStringLen-4+i] << (24 - (i * 8));
-                }
-                for (i = 0; i < (numericStringLen - 4); i++)
-                {
-                    temp32High |= ptrFrameData[i] << (((numericStringLen - 5) * 8) - (i * 8));
-                }
-            }
-            else
-            {
-                for (i = 0; i < numericStringLen; i++)
-                {
-                    temp32Low  |= ptrFrameData[i] <<
-                                  (((numericStringLen - 1) * 8) - (i * 8));
-                }
-            }
-
-            // The next 3 lines is equivalent to: aID3MetaData.iTrackLength = (temp32High << 32) | temp32Low;
-            // It is written thus because the behavior of "temp32High << 32" (where temp32High has a width <= 32)
-            // is undefined in some processors.
-            aID3MetaData.iTrackLength = temp32High;
-            aID3MetaData.iTrackLength <<= 32;
-            aID3MetaData.iTrackLength += temp32Low;
-            // Go from milliseconds to microseconds.
-            aID3MetaData.iTrackLength *= 1000;
-        }
-        break;
-
-        case ETYER:
-        {
-            // Handle TYER frame
-            // The TYER frame contains data referring to the year.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iYear.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_YEAR);
-            aID3MetaData.iYear.pChar[MAX_UNICODE_BUF_LEN_YEAR-1] = 0;
-            aID3MetaData.iYear.iFormat = TAudioMetaData::EISO88591_CHAR;
-        }
-        break;
-
-        case ECOMT:
-        {
-            // Handle COMM frame
-            // The COMM frame contains data referring to comments
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(ptrFrameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            char* strptr = (char*)ptrFrameData;
-            oscl_memset(aID3MetaData.iComment.langcode_pChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            oscl_memset(aID3MetaData.iComment.description_pChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-
-            // Copy language code
-            oscl_strncpy(aID3MetaData.iComment.langcode_pChar, strptr, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            aID3MetaData.iComment.langcode_pChar[MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE-1] = 0;
-
-            // Move the string pointer past the language code
-            strptr += 3;
-
-            // Copy comment description string
-            uint32 commentstrlen = oscl_strlen(strptr);
-            if (commentstrlen < (aSize - 5))
-            {
-                oscl_strncpy(aID3MetaData.iComment.description_pChar, strptr, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-                aID3MetaData.iComment.description_pChar[MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION-1] = 0;
-                strptr += (commentstrlen + 1);
-            }
-
-            // Finally copy the comment string
-            oscl_strncpy(aID3MetaData.iComment.pChar, strptr, MAX_UNICODE_BUF_LEN_COMMENT);
-            aID3MetaData.iComment.pChar[MAX_UNICODE_BUF_LEN_COMMENT-1] = 0;
-
-            aID3MetaData.iComment.iFormat = TAudioMetaData::EISO88591_CHAR;
-        }
-        break;
-
-        default:
-        {
-            // Frame is not yet supported
-            break;
-        }
-    }
-
-    OSCL_ARRAY_DELETE(ptrFrameData);
-    ptrFrameData = NULL;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::HandleID3V2FrameDataUnicode16(
-//                                               TFrameTypeID3V2 aFrameType,
-//                                               uint32            aPos,
-//                                               uint32            aSize,
-//                                               uint32            aEndianType,
-//                                               TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aFrameType   - enumerated TFrameTypeID3V2 type - used to determine if
-//                    Frame is supported
-//     aPos         - position in file where frame data begins
-//     aSize        - size of the frame data
-//     aEndianType  - flag indicator regarding the text endian type
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Outputs:
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function receives a ID3V2 frame and handles it accordingly. Each
-//  frame header is composed of 10 bytes - 4 bytes for FrameID, 4 bytes for
-//  FrameSize, and 2 bytes for FrameFlags, respectively. Once we have a
-//  frame's unique FrameID, we can handle the frame accordingly. (eg. The
-//  frame with FrameID = "TIT2" contains data describing the title.
-//  Clearly, the data in that frame should be copied to it respective
-//  location in aID3MetaData. The location for the data with FrameID = "TIT2"
-//  goes in the aID3MetaData.iTitle buffer. This line of code accomplishes our
-//  objective: aID3MetaData.iTitle.Copy(ptrFrameData16); All of the frames
-//  sent to this function have unicode strings in them that will need to be
-//  read different than the ASCII strings.
-//
-//------------------------------------------------------------------------------
-void CID3TagParser::HandleID3V2FrameDataUnicode16(TID3V2FrameType      aFrameType,
-        uint32                 aPos,
-        uint32                 aSize,
-        uint32                 aEndianType,
-        TAudioMetaData&      aID3MetaData)
-{
-    // seek to the beginning of the current frame data
-    if (iFilePtr->Seek(aPos, Oscl_File::SEEKSET) == -1)
-    {
-        return;
-    }
-
-    // create buffers to store frame data
-    uint8* frameData = OSCL_ARRAY_NEW(uint8, aSize + 2);
-    if (frameData == NULL)
-    {
-        return;
-    }
-    oscl_wchar* frameDataWC = OSCL_ARRAY_NEW(oscl_wchar, aSize + 2);
-    if (frameDataWC == NULL)
-    {
-        OSCL_ARRAY_DELETE(frameData);
-        return;
-    }
-    uint8* ptrFrameData  = frameData;
-    oscl_wchar* ptrFrameDataWC = frameDataWC;
-
-    oscl_memset(frameData,  0, aSize + 2);
-    oscl_memset(frameDataWC, 0, sizeof(oscl_wchar)*(aSize + 1));
-
-    switch (aFrameType)
-    {
-        case ETIT2:
-        {   // Handle TIT2 frame
-            // The TIT2 frame contains data referring to the title.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-
-            oscl_strncpy(aID3MetaData.iTitle.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_TITLE);
-            aID3MetaData.iTitle.pWChar[MAX_UNICODE_BUF_LEN_TITLE-1] = NULL_TERM_CHAR;
-
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iTitle.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iTitle.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-            iTitleFoundFlag = true;
-        }
-        break;
-
-        case ETPE1:
-        {
-            // Handle TPE1 frame
-            // The TPE1 frame contains data referring to the artist.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iArtist.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_ARTIST);
-            aID3MetaData.iArtist.pWChar[MAX_UNICODE_BUF_LEN_ARTIST-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iArtist.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iArtist.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETPOS:
-        {
-            // Handle TPOS/TPA frame
-            // The TPOS frame contains data defining if this is part of
-            // a multi disc set.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iSet.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_SET);
-            aID3MetaData.iSet.pWChar[MAX_UNICODE_BUF_LEN_SET-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iSet.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iSet.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETALB:
-        {
-            // Handle TALB frame
-            // The TALB frame contains data referring to the album.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iAlbum.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_ALBUM);
-            aID3MetaData.iAlbum.pWChar[MAX_UNICODE_BUF_LEN_ALBUM-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iAlbum.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iAlbum.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETCOP:
-        {
-            // Handle TCOP frame
-            // The TCOP frame contains data referring to the copyright.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iCopyright.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_COPYRIGHT);
-            aID3MetaData.iCopyright.pWChar[MAX_UNICODE_BUF_LEN_COPYRIGHT-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iCopyright.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iCopyright.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETCON:
-        {
-            // Handle TCON frame
-            // The TCON frame contains data referring to the genre.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iGenre.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_GENRE);
-            aID3MetaData.iGenre.pWChar[MAX_UNICODE_BUF_LEN_GENRE-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iGenre.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iGenre.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETRCK:
-        {
-            // Handle TRCK frame
-            // The TRCK frame contains data referring to the track number.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iTrackNumber.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_TRACK_NUMBER);
-            aID3MetaData.iTrackNumber.pWChar[MAX_UNICODE_BUF_LEN_TRACK_NUMBER-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETYER:
-        {
-            // Handle TYER frame
-            // The TYER frame contains data referring to the year.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-            oscl_strncpy(aID3MetaData.iYear.pWChar, ptrFrameDataWC, MAX_UNICODE_BUF_LEN_YEAR);
-            aID3MetaData.iYear.pWChar[MAX_UNICODE_BUF_LEN_YEAR-1] = NULL_TERM_CHAR;
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iYear.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iYear.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-        case ECOMT:
-        {
-            // Handle COMM frame
-            // The COMM frame contains data referring to comments
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                OSCL_ARRAY_DELETE(frameDataWC);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            EightBitToWideCharBufferTransfer(ptrFrameData,
-                                             aSize,
-                                             aEndianType,
-                                             ptrFrameDataWC);
-
-            oscl_wchar* wstrptr = ptrFrameDataWC;
-            oscl_memset(aID3MetaData.iComment.langcode_pWChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            oscl_memset(aID3MetaData.iComment.description_pWChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-
-            // Check for language code
-            oscl_strncpy(aID3MetaData.iComment.langcode_pWChar, wstrptr, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            aID3MetaData.iComment.langcode_pWChar[MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE-1] = 0;
-
-            // Move the string pointer past the language code
-            wstrptr += 3;
-
-            // Check for comment description string
-            uint32 commentstrlen = oscl_strlen(wstrptr);
-            if (commentstrlen < (aSize - 5))
-            {
-                oscl_strncpy(aID3MetaData.iComment.description_pWChar, wstrptr, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-                aID3MetaData.iComment.description_pWChar[MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION-1] = 0;
-                wstrptr += (commentstrlen + 1);
-            }
-
-            // Finally copy the comment string
-            oscl_strncpy(aID3MetaData.iComment.pWChar, wstrptr, MAX_UNICODE_BUF_LEN_COMMENT);
-            aID3MetaData.iComment.pWChar[MAX_UNICODE_BUF_LEN_COMMENT-1] = NULL_TERM_CHAR;
-
-            if (aEndianType == UNICODE_BIG_ENDIAN)
-            {
-                aID3MetaData.iComment.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iComment.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-        default:
-        {
-            // Frame is not yet supported
-            break;
-        }
-    }
-
-    OSCL_ARRAY_DELETE(ptrFrameData);
-    ptrFrameData = NULL;
-
-    OSCL_ARRAY_DELETE(ptrFrameDataWC);
-    ptrFrameDataWC = NULL;
-}
-
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::HandleID3V2FrameDataUTF16(
-//                                               TFrameTypeID3V2 aFrameType,
-//                                               uint32            aPos,
-//                                               uint32            aSize,
-//                                               uint32            aEndianType,
-//                                               TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aFrameType   - enumerated TFrameTypeID3V2 type - used to determine if
-//                    Frame is supported
-//     aPos         - position in file where frame data begins
-//     aSize        - size of the frame data
-//     aTextType    - flag indicator regarding the text type
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Outputs:
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function receives a ID3V2 frame and handles it accordingly. Each
-//  frame header is composed of 10 bytes - 4 bytes for FrameID, 4 bytes for
-//  FrameSize, and 2 bytes for FrameFlags, respectively. Once we have a
-//  frame's unique FrameID, we can handle the frame accordingly. (eg. The
-//  frame with FrameID = "TIT2" contains data describing the title.
-//  Clearly, the data in that frame should be copied to it respective
-//  location in aID3MetaData. The location for the data with FrameID = "TIT2"
-//  goes in the aID3MetaData.iTitle buffer. This line of code accomplishes our
-//  objective: aID3MetaData.iTitle.Copy(ptrFrameData16); All of the frames
-//  sent to this function have unicode strings in them that will need to be
-//  read different than the ASCII strings.
-//
-//------------------------------------------------------------------------------
-void CID3TagParser::HandleID3V2FrameDataUTF16(TID3V2FrameType      aFrameType,
-        uint32                 aPos,
-        uint32                 aSize,
-        TTextType              aTextType,
-        TAudioMetaData&      aID3MetaData)
-{
-    // seek to the beginning of the current frame data
-    if (iFilePtr->Seek(aPos, Oscl_File::SEEKSET) == -1)
-    {
-        return;
-    }
-
-    // create buffers to store frame data
-    uint8* frameData = OSCL_ARRAY_NEW(uint8, aSize + 2);
-    if (frameData == NULL)
-    {
-        return;
-    }
-
-    uint8* ptrFrameData  = frameData;
-
-    oscl_memset(frameData,  0, aSize + 2);
-
-    switch (aFrameType)
-    {
-        case ETIT2:
-        {   // Handle TIT2 frame
-            // The TIT2 frame contains data referring to the title.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iTitle.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_TITLE);
-            aID3MetaData.iTitle.pWChar[MAX_UNICODE_BUF_LEN_TITLE-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iTitle.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iTitle.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-            iTitleFoundFlag = true;
-        }
-        break;
-
-        case ETPE1:
-        {
-            // Handle TPE1 frame
-            // The TPE1 frame contains data referring to the artist.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iArtist.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_ARTIST);
-            aID3MetaData.iArtist.pWChar[MAX_UNICODE_BUF_LEN_ARTIST-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iArtist.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iArtist.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETPOS:
-        {
-            // Handle TPOS/TPA frame
-            // The TPOS frame contains data defining if this is part of
-            // a multi disc set.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iSet.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_SET);
-            aID3MetaData.iSet.pWChar[MAX_UNICODE_BUF_LEN_SET-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iSet.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iSet.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETALB:
-        {
-            // Handle TALB frame
-            // The TALB frame contains data referring to the album.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iAlbum.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_ALBUM);
-            aID3MetaData.iAlbum.pWChar[MAX_UNICODE_BUF_LEN_ALBUM-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iAlbum.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iAlbum.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETCOP:
-        {
-            // Handle TCOP frame
-            // The TCOP frame contains data referring to the copyright.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iCopyright.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_COPYRIGHT);
-            aID3MetaData.iCopyright.pWChar[MAX_UNICODE_BUF_LEN_COPYRIGHT-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iCopyright.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iCopyright.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETCON:
-        {
-            // Handle TCON frame
-            // The TCON frame contains data referring to the genre.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iGenre.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_GENRE);
-            aID3MetaData.iGenre.pWChar[MAX_UNICODE_BUF_LEN_GENRE-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iGenre.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iGenre.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETRCK:
-        {
-            // Handle TRCK frame
-            // The TRCK frame contains data referring to the track number.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iTrackNumber.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_TRACK_NUMBER);
-            aID3MetaData.iTrackNumber.pWChar[MAX_UNICODE_BUF_LEN_TRACK_NUMBER-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-
-        case ETYER:
-        {
-            // Handle TYER frame
-            // The TYER frame contains data referring to the year.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-            ptrFrameData[aSize+1] = 0;
-
-            oscl_strncpy(aID3MetaData.iYear.pWChar, (oscl_wchar*)ptrFrameData, MAX_UNICODE_BUF_LEN_YEAR);
-            aID3MetaData.iYear.pWChar[MAX_UNICODE_BUF_LEN_YEAR-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iYear.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iYear.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-        case ECOMT:
-        {
-            // Handle COMM frame
-            // The COMM frame contains data referring to comments
-
-            // Since data in ptrFrameData has to be aligned one cannot read the
-            // whole comments frame at once, since the language code is 3 byte
-            // long and accessing the remaining part after that as a wide char
-            // will cause misalignment. So the reading is split into two part.
-
-            // Read Language Code (3 bytes)
-            if (readByteData(iFilePtr, 3, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[3] = 0;
-
-            oscl_wchar* wstrptr = (oscl_wchar*)ptrFrameData;
-            oscl_memset(aID3MetaData.iComment.langcode_pWChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            oscl_memset(aID3MetaData.iComment.description_pWChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-
-            // Check for language code
-            // NOTE: language code is NEVER wide char - and it is always 3 bytes long
-            oscl_strncpy(aID3MetaData.iComment.langcode_pWChar, wstrptr, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            aID3MetaData.iComment.langcode_pWChar[MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE-1] = 0;
-
-            // Reset the part of ptrFrameData to zero, which was used for language code
-            oscl_memset(ptrFrameData,  0, 3);
-
-            // Read the remaning part of the comments frame
-            if (readByteData(iFilePtr, aSize - 3, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-
-            ptrFrameData[aSize-3] = 0;
-            ptrFrameData[aSize-2] = 0; // aSize-3+1
-
-            // Move the pointer to the beginning of the short content description
-            wstrptr = (oscl_wchar*)ptrFrameData;
-
-            // Check for short content description string
-            uint32 commentstrlen = oscl_strlen(wstrptr);
-            if (commentstrlen < (aSize - 5))
-            {
-                oscl_strncpy(aID3MetaData.iComment.description_pWChar, wstrptr, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-                aID3MetaData.iComment.description_pWChar[MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION-1] = 0;
-
-                // Move the pointer to the beginning of the actual comment text
-                wstrptr += (commentstrlen + 1);
-            }
-
-            // Finally copy the comment string
-            oscl_strncpy(aID3MetaData.iComment.pWChar, wstrptr, MAX_UNICODE_BUF_LEN_COMMENT);
-            aID3MetaData.iComment.pWChar[MAX_UNICODE_BUF_LEN_COMMENT-1] = NULL_TERM_CHAR;
-
-            if (aTextType == EUTF16BE)
-            {
-                aID3MetaData.iComment.iFormat = TAudioMetaData::EUTF16BE_WCHAR;
-            }
-            else
-            {
-                aID3MetaData.iComment.iFormat = TAudioMetaData::EUTF16_WCHAR;
-            }
-        }
-        break;
-        default:
-        {
-            // Frame is not yet supported
-            break;
-        }
-    }
-
-    OSCL_ARRAY_DELETE(ptrFrameData);
-    ptrFrameData = NULL;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::HandleID3V2FrameDataUTF8(
-//                                               TFrameTypeID3V2 aFrameType,
-//                                               uint32            aPos,
-//                                               uint32            aSize,
-//                                               TAudioMetaData& aID3MetaData)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//     aFrameType   - enumerated TFrameTypeID3V2 type - used to determine if
-//                    Frame is supported
-//     aPos         - position in file where frame data begins
-//     aSize        - size of the frame data
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Outputs:
-//     aID3MetaData - pointer to repository for parsed data
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function receives a ID3V2 frame and handles it accordingly. Each
-//  frame header is composed of 10 bytes - 4 bytes for FrameID, 4 bytes for
-//  FrameSize, and 2 bytes for FrameFlags, respectively. Once we have a
-//  frame's unique FrameID, we can handle the frame accordingly. (eg. The
-//  frame with FrameID = "TIT2" contains data describing the title.
-//  Clearly, the data in that frame should be copied to it respective
-//  location in aID3MetaData. The location for the data with FrameID = "TIT2"
-//  goes in the aID3MetaData.iTitle buffer. This line of code accomplishes our
-//  objective: aID3MetaData.iTitle.Copy(ptrFrameData16); All of the frames
-//  sent to this function have UTF8 strings in them that will need to be
-//  read different than the ASCII strings.
-//
-//------------------------------------------------------------------------------
-void CID3TagParser::HandleID3V2FrameDataUTF8(TID3V2FrameType      aFrameType,
-        uint32               aPos,
-        uint32               aSize,
-        TAudioMetaData&      aID3MetaData)
-{
-    // seek to the beginning of the current frame data
-    if (iFilePtr->Seek(aPos, Oscl_File::SEEKSET) == -1)
-    {
-        return;
-    }
-
-    // create buffers to store frame data
-    uint8* frameData = OSCL_ARRAY_NEW(uint8, aSize + 1);
-    if (frameData == NULL)
-    {
-        return;
-    }
-    uint8* ptrFrameData = frameData;
-    oscl_memset(frameData,  0, aSize + 1);
-
-    switch (aFrameType)
-    {
-        case ETIT2:
-        {
-            // Handle TIT2 frame
-            // The TIT2 frame contains data referring to the title.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iTitle.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_TITLE);
-            aID3MetaData.iTitle.pChar[MAX_UNICODE_BUF_LEN_TITLE-1] = 0;
-            aID3MetaData.iTitle.iFormat = TAudioMetaData::EUTF8_CHAR;
-
-            iTitleFoundFlag = true;
-        }
-        break;
-
-        case ETPE1:
-        {
-            // Handle TPE1 frame
-            // The TPE1 frame contains data referring to the artist.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iArtist.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_ARTIST);
-            aID3MetaData.iArtist.pChar[MAX_UNICODE_BUF_LEN_ARTIST-1] = 0;
-            aID3MetaData.iArtist.iFormat = TAudioMetaData::EUTF8_CHAR;
-        }
-        break;
-
-        case ETPOS:
-        {
-            // Handle TPOS/TPA frame
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iSet.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_SET);
-            aID3MetaData.iSet.pChar[MAX_UNICODE_BUF_LEN_ALBUM-1] = 0;
-            aID3MetaData.iSet.iFormat = TAudioMetaData::EUTF8_CHAR;
-        }
-        break;
-
-        case ETALB:
-        {
-            // Handle TALB frame
-            // The TALB frame contains data referring to the album.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iAlbum.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_ALBUM);
-            aID3MetaData.iAlbum.pChar[MAX_UNICODE_BUF_LEN_ALBUM-1] = 0;
-            aID3MetaData.iAlbum.iFormat = TAudioMetaData::EUTF8_CHAR;
-        }
-        break;
-
-        case ETCOP:
-        {
-            // Handle TCOP frame
-            // The TCOP frame contains data referring to the copyright.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iCopyright.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_COPYRIGHT);
-            aID3MetaData.iCopyright.pChar[MAX_UNICODE_BUF_LEN_COPYRIGHT-1] = 0;
-            aID3MetaData.iCopyright.iFormat = TAudioMetaData::EUTF8_CHAR;
-
-        }
-        break;
-
-        case ETCON:
-        {
-            // Handle TCON frame
-            // The TCON frame contains data referring to the genre.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iGenre.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_GENRE);
-            aID3MetaData.iGenre.pChar[MAX_UNICODE_BUF_LEN_GENRE-1] = 0;
-            aID3MetaData.iGenre.iFormat = TAudioMetaData::EUTF8_CHAR;
-
-        }
-        break;
-
-        case ETRCK:
-        {
-            // Handle TRCK frame
-            // The TRCK frame contains data referring to the track number.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iTrackNumber.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_TRACK_NUMBER);
-            aID3MetaData.iTrackNumber.pChar[MAX_UNICODE_BUF_LEN_TRACK_NUMBER-1] = 0;
-            aID3MetaData.iTrackNumber.iFormat = TAudioMetaData::EUTF8_CHAR;
-        }
-        break;
-
-        case ETYER:
-        {
-            // Handle TYER frame
-            // The TYER frame contains data referring to the year.
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            oscl_strncpy(aID3MetaData.iYear.pChar, (char*)ptrFrameData, MAX_UNICODE_BUF_LEN_YEAR);
-            aID3MetaData.iYear.pChar[MAX_UNICODE_BUF_LEN_YEAR-1] = 0;
-            aID3MetaData.iYear.iFormat = TAudioMetaData::EUTF8_CHAR;
-        }
-        break;
-
-        case ECOMT:
-        {
-            // Handle COMM frame
-            // The COMM frame contains data referring to comments
-            if (readByteData(iFilePtr, aSize, ptrFrameData) == false)
-            {
-                OSCL_ARRAY_DELETE(frameData);
-                return;
-            }
-            ptrFrameData[aSize] = 0;
-
-            char* strptr = (char*)ptrFrameData;
-            oscl_memset(aID3MetaData.iComment.langcode_pChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            oscl_memset(aID3MetaData.iComment.description_pChar, 0, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-
-            // Copy the language code
-            oscl_strncpy(aID3MetaData.iComment.langcode_pChar, strptr, MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE);
-            aID3MetaData.iComment.langcode_pChar[MAX_UNICODE_BUF_LEN_COMMENT_LANGCODE-1] = 0;
-
-            // Move the string pointer past the language code
-            strptr += 3;
-
-            // Check for comment description string
-            uint32 commentstrlen = oscl_strlen(strptr);
-            if (commentstrlen < (aSize - 5))
-            {
-                oscl_strncpy(aID3MetaData.iComment.description_pChar, strptr, MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION);
-                aID3MetaData.iComment.description_pChar[MAX_UNICODE_BUF_LEN_COMMENT_DESCRIPTION-1] = 0;
-                strptr += (commentstrlen + 1);
-            }
-
-            // Finally copy the comment string
-            oscl_strncpy(aID3MetaData.iComment.pChar, strptr, MAX_UNICODE_BUF_LEN_COMMENT);
-            aID3MetaData.iComment.pChar[MAX_UNICODE_BUF_LEN_COMMENT-1] = 0;
-
-            aID3MetaData.iComment.iFormat = TAudioMetaData::EUTF8_CHAR;
-        }
-        break;
-
-        default:
-        {
-            // Frame is not yet supported
-            break;
-        }
-    }
-
-    OSCL_ARRAY_DELETE(ptrFrameData);
-    ptrFrameData = NULL;
-}
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::FrameSupportedID3V2(void)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: None
-//
-//  Outputs: None
-//
-//  Returns:
-//    ID3V2FrameTypeReturnValue - The value that describes the current frame.
-//                                of type enum TID3V2FrameType
-//
-//  Global Variables Used:
-//    TID3V2FrameType - The enum table containing the supported frame types
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function detects the ID3V2FrameType and returns the enum value that
-//  corresponds to the current frame.
-//
-//------------------------------------------------------------------------------
-
-TID3V2FrameType CID3TagParser::FrameSupportedID3V2(void)
-{
-    uint8 endTestBuf[ID3V2_FRAME_NUM_BYTES_ID] = {0};
-    TID3V2FrameType ID3V2FrameTypeReturnValue;
-
-    if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTIT2, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETIT2;
-        iTitleFoundFlag           = true;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTPE1, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETPE1;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTALB, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETALB;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTCOP, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETCOP;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTCON, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETCON;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTRCK, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETRCK;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTDAT, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETDAT;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTLEN, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETLEN;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KCOMM, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ECOMT;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTYER, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETYER;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTDRC, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETYER;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, endTestBuf, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = EEND;
-    }
-    else
-    {
-        ID3V2FrameTypeReturnValue = EFrameNotSupported;
-    }
-
-    return ID3V2FrameTypeReturnValue;
-}
-
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::FrameSupportedID3V22(void)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs: None
-//
-//  Outputs: None
-//
-//  Returns:
-//    ID3V2FrameTypeReturnValue - The value that describes the current frame.
-//                                of type enum TID3V2FrameType
-//
-//  Global Variables Used:
-//    TID3V2FrameType - The enum table containing the supported frame types
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function detects the ID3V2FrameType and returns the enum value that
-//  corresponds to the current frame.
-//
-//------------------------------------------------------------------------------
-
-TID3V2FrameType CID3TagParser::FrameSupportedID3V22(void)
-{
-    uint8 endTestBuf[ID3V22_FRAME_NUM_BYTES_ID] = {0};
-    TID3V2FrameType ID3V2FrameTypeReturnValue;
-
-    if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTT2, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETIT2;
-        iTitleFoundFlag           = true;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTP1, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETPE1;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTAL, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETALB;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTCR, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETCOP;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTCO, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETCON;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTRK, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETRCK;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KCOM, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ECOMT;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTYE, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETYER;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTDA, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETDAT;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, KTLE, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = ETLEN;
-    }
-    else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, endTestBuf, ID3V22_FRAME_NUM_BYTES_ID) == 0)
-    {
-        ID3V2FrameTypeReturnValue = EEND;
-    }
-    else
-    {
-        ID3V2FrameTypeReturnValue = EFrameNotSupported;
-    }
-
-    return ID3V2FrameTypeReturnValue;
-}
-
-
-//----------------------------------------------------------------------------
-// FUNCTION NAME: CID3TagParser::EightBitToWideCharBufferTransfer(
-//                                               const uint8* aPtrFrameData8,
-//                                               uint32         aSize,
-//                                               uint32         aEndianType,
-//                                               oscl_wchar*    aPtrFrameData16)
-//----------------------------------------------------------------------------
-// INPUT AND OUTPUT DEFINITIONS
-//
-//  Inputs:
-//    aPtrFrameData8  - pointer to input string format of either big
-//                      or little endian.
-//    aSize           - number of character elements in aPtrFrameData8
-//    aEndianType     - This describes if the encoded Unicode text in the
-//                      aPtrFrameData8 buffer is in big or little endian.
-//    aPtrFrameData16 - pointer to the output string in unicode format.
-//
-//  Outputs:
-//    aPtrFrameData16 - pointer to the output string in unicode format.
-//
-//  Returns: None
-//
-//  Global Variables Used: None
-//
-//----------------------------------------------------------------------------
-// FUNCTION DESCRIPTION
-//
-//  This function takes in two buffers. One is of type uint8* and the other is
-//  of type oscl_wchar*. This function converts the data in the uint8* buffer and
-//  puts the data into the oscl_wchar* buffer. The endian is taken care of by this
-//  function as well.
-//
-//------------------------------------------------------------------------------
-void CID3TagParser::EightBitToWideCharBufferTransfer(const uint8 * aPtrFrameData8,
-        uint32        aSize,
-        uint32        aEndianType,
-        oscl_wchar  * aPtrFrameDataWCBase)
-{
-    if (aPtrFrameData8 == NULL || aPtrFrameDataWCBase == NULL)
-    {
-        return;
-    }
-    oscl_wchar * aPtrFrameDataWC = aPtrFrameDataWCBase;
-    uint16 tempFrameData16;
-    oscl_wchar tempFrameDataWC = 0;
-
-    if (aEndianType != 0)
-        // Indication check of big-endian vs. little endian
-    {
-        uint32 z = 0;
-        for (uint32 x = 0; x < (aSize >> 1); x++)
-        {
-            z = x << 1;
-            uint8 tempByteOne = aPtrFrameData8[z];
-            uint8 tempByteTwo = aPtrFrameData8[z + 1];
-            if ((tempByteOne == 0) && (tempByteTwo == 0))
-            {
-                x++;
-                // End of string here and skip to start of next string.
-                *aPtrFrameDataWC++ = ((oscl_wchar) ' ');
-            }
-            else
-            {
-                tempFrameData16 = ((((uint16)(tempByteTwo << 8)) | tempByteOne));
-                tempFrameDataWC = tempFrameData16;
-                *aPtrFrameDataWC++ = tempFrameDataWC;
-            }
-        }
-    }
-    else
-    {
-        uint32 z = 0;
-        for (uint32 x = 0; x < (aSize >> 1); x++)
-        {
-            z = x << 1;
-            uint8 tempByteOne = aPtrFrameData8[z];
-            uint8 tempByteTwo = aPtrFrameData8[z + 1];
-            if ((tempByteTwo == 0) && (tempByteOne == 0))
-            {
-                x++;
-                // End of string here and skip to start of next string.
-                *aPtrFrameDataWC++ = ((oscl_wchar) ' ');
-            }
-            else
-            {
-                tempFrameData16 = ((((uint16)(tempByteOne << 8)) | tempByteTwo));
-                tempFrameDataWC = tempFrameData16;
-                *aPtrFrameDataWC++ = tempFrameDataWC;
-            }
-        }
-    }
-    return;
-}
-
diff --git a/fileformats/common/parser/src/pvfile.cpp b/fileformats/common/parser/src/pvfile.cpp
index efcdb27..16d8f66 100644
--- a/fileformats/common/parser/src/pvfile.cpp
+++ b/fileformats/common/parser/src/pvfile.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@
  */
 
 #include "pvfile.h"
-#include "pvmf_cpmplugin_access_interface.h"
 #include "pvmf_cpmplugin_access_interface_factory.h"
 #include "pvmi_data_stream_interface.h"
 
@@ -38,8 +37,6 @@
 {
     if (iFile)
         return iFile->Seek(offset, origin);
-    else if (iCPMAccess)
-        return iCPMAccess->SeekContent(offset, origin);
     else if (iFilePtr)
         return iFilePtr->Seek(offset, origin);
     else if (iDataStreamAccess)
@@ -70,8 +67,6 @@
 {
     if (iFile)
         return iFile->Tell();
-    else if (iCPMAccess)
-        return iCPMAccess->GetCurrentContentPosition();
     else if (iFilePtr)
         return iFilePtr->Tell();
     else if (iDataStreamAccess)
@@ -85,8 +80,6 @@
 {
     if (iFile)
         return iFile->Read(buffer, size, numelements);
-    else if (iCPMAccess)
-        return iCPMAccess->ReadAndUnlockContent(buffer, size, numelements);
     else if (iFilePtr)
         return iFilePtr->Read(buffer, size, numelements);
     else if (iDataStreamAccess)
@@ -104,9 +97,7 @@
 
 OSCL_EXPORT_REF int32 PVFile::Flush()
 {
-    if (iCPMAccess)
-        return iCPMAccess->Flush();
-    else if (iFile)
+    if (iFile)
         return iFile->Flush();
     else if (iFilePtr)
         return iFilePtr->Flush();
@@ -127,17 +118,6 @@
     {
         return -1;//Close should not be called for filePtr access.
     }
-    else if (iCPMAccess)
-    {
-        int32 result = iCPMAccess->CloseContent();
-
-        //delete the CPM access interface.
-        iCPMAccess->Reset();
-        PVUuid uuid = PVMFCPMPluginLocalSyncAccessInterfaceUuid;
-        iCPMAccessFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iCPMAccess);
-        iCPMAccess = NULL;
-        return result;
-    }
     else if (iDataStreamAccess)
     {
         iDataStreamAccess->CloseSession(iDataStreamSession);
@@ -175,31 +155,15 @@
     }
     else if (iCPMAccessFactory)
     {
-        if (iCPMAccess)
+        if (iDataStreamAccess)
             return (-1);//already open!
 
         //Create an access interface.
-        //Try the data stream first, if not available use CPM local sync access
         PVUuid uuid = PVMIDataStreamSyncInterfaceUuid;
         iDataStreamAccess = (PVMIDataStreamSyncInterface*)iCPMAccessFactory->CreatePVMFCPMPluginAccessInterface(uuid);
         if (iDataStreamAccess == NULL)
         {
-            PVUuid uuid = PVMFCPMPluginLocalSyncAccessInterfaceUuid;
-            iCPMAccess = (PVMFCPMPluginLocalSyncAccessInterface*)iCPMAccessFactory->CreatePVMFCPMPluginAccessInterface(uuid);
-            if (!iCPMAccess)
-                return (-1);//error, no access.
-
-            iCPMAccess->Init();
-            int32 result;
-            result = iCPMAccess->OpenContent();
-
-            //If open failed, cleanup the CPM access interface.
-            if (result != 0)
-            {
-                iCPMAccessFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iCPMAccess);
-                iCPMAccess = NULL;
-            }
-            return result;
+            return (-1);//error, no access.
         }
         else
         {
@@ -248,12 +212,12 @@
         //Create an Oscl_File object for accessing the file, using
         //the optional external file handle.
 
-        iFile = OSCL_NEW(Oscl_File, (4096, iFileHandle));
+        iFile = OSCL_NEW(Oscl_File, (iOsclFileCacheParams.iCacheSize, iFileHandle));
         if (!iFile)
             return (-1);//nonzero indicates error.
 
         // If a filehandle is provided, assume the file is already opened
-        // (but still call Oscl_File::Open() with a bogus filename, since
+        // (but still call Oscl_File::Open() with an arbitrary filename, since
         // otherwise it won't be initialized correctly. This filename will
         // be ignored and the handle will be used instead),
         // Otherwise, open it using its filename.
@@ -262,7 +226,14 @@
         if (iFileHandle)
             result =  iFile->Open("", mode, fileserv);
         else
+        {
+            iFile->SetAsyncReadBufferSize(iOsclFileCacheParams.iAsyncReadBuffSize);
+            iFile->SetLoggingEnable(iOsclFileCacheParams.iPVLoggerEnableFlag);
+            iFile->SetNativeAccessMode(iOsclFileCacheParams.iNativeAccessMode);
+            iFile->SetPVCacheSize(iOsclFileCacheParams.iCacheSize);
+            iFile->SetSummaryStatsLoggingEnable(iOsclFileCacheParams.iPVLoggerStateEnableFlag);
             result = iFile->Open(filename, mode, fileserv);
+        }
 
         //If open failed, cleanup the file object
         if (result != 0)
@@ -293,32 +264,14 @@
             return true;
         }
     }
-    else if (iCPMAccess)
-    {
-        uint32 currPos = (uint32)(iCPMAccess->GetCurrentContentPosition());
-
-        if (iFileSizeAvailable == false)
-        {
-            iCPMAccess->SeekContent(0, Oscl_File::SEEKEND);
-            iFileSize = (uint32)(iCPMAccess->GetCurrentContentPosition());
-            iCPMAccess->SeekContent((int32)currPos, Oscl_File::SEEKSET);
-            iFileSizeAvailable = true;
-        }
-        if (currPos <= iFileSize)
-        {
-            aNumBytes = (iFileSize - currPos);
-            return true;
-        }
-    }
     else if (iFilePtr)
     {
         uint32 currPos = (uint32)(iFilePtr->Tell());
 
         if (iFileSizeAvailable == false)
         {
-            iFilePtr->Seek(0, Oscl_File::SEEKEND);
-            iFileSize = (uint32)(iFilePtr->Tell());
             iFilePtr->Seek(currPos, Oscl_File::SEEKSET);
+            iFileSize = (uint32)(iFilePtr->Size());
             iFileSizeAvailable = true;
         }
         if (currPos <= iFileSize)
diff --git a/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_factory.cpp b/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_factory.cpp
index 8bebe17..523e7c7 100644
--- a/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_factory.cpp
+++ b/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_impl.cpp b/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_impl.cpp
index 8e564ef..a1f8015 100644
--- a/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_impl.cpp
+++ b/fileformats/common/parser/src/pvmi_datastreamsyncinterface_ref_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -310,9 +310,14 @@
         LOGDEBUG((0, "PVMIDataStreamSyncInterfaceRefImpl::Flush returning %d", -1));
         return PVDS_FAILURE;
     }
-    int32 result = iFileObject->Flush();
+    int32 result;
+    result = iFileObject->Flush();
     LOGDEBUG((0, "PVMIDataStreamSyncInterfaceRefImpl::Flush returning %d", result));
-    return PVDS_SUCCESS;
+    if (result == 0) //Flush will return 0 when successful
+        return PVDS_SUCCESS;
+    else
+        return PVDS_FAILURE;
+
 }
 
 
diff --git a/fileformats/id3parcom/Android.mk b/fileformats/id3parcom/Android.mk
index 6bc1785..01e4352 100644
--- a/fileformats/id3parcom/Android.mk
+++ b/fileformats/id3parcom/Android.mk
@@ -2,26 +2,29 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pv_id3_parcom.cpp
-
+ 	src/pv_id3_parcom.cpp
 
 
 LOCAL_MODULE := libpvid3parcom
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/id3parcom/include \
-	$(PV_TOP)//fileformats/id3parcom/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/id3parcom/src \
+ 	$(PV_TOP)/fileformats/id3parcom/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pv_id3_parcom.h \
-	include/pv_id3_parcom_types.h \
-	include/pv_id3_parcom_constants.h
+ 	include/pv_id3_parcom_types.h \
+ 	include/pv_id3_parcom_constants.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/id3parcom/build/make/local.mk b/fileformats/id3parcom/build/make/local.mk
new file mode 100644
index 0000000..f56b4e4
--- /dev/null
+++ b/fileformats/id3parcom/build/make/local.mk
@@ -0,0 +1,27 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvid3parcom
+
+
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pv_id3_parcom.cpp
+
+HDRS := pv_id3_parcom.h \
+       pv_id3_parcom_types.h \
+       pv_id3_parcom_constants.h
+
+
+include $(MK)/library.mk
diff --git a/fileformats/id3parcom/build/make/makefile b/fileformats/id3parcom/build/make/makefile
deleted file mode 100644
index 9072ebd..0000000
--- a/fileformats/id3parcom/build/make/makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvid3parcom
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = pv_id3_parcom.cpp
-
-HDRS = pv_id3_parcom.h \
-       pv_id3_parcom_types.h \
-       pv_id3_parcom_constants.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/fileformats/id3parcom/include/pv_id3_parcom.h b/fileformats/id3parcom/include/pv_id3_parcom.h
index 87ab6cf..7a310df 100644
--- a/fileformats/id3parcom/include/pv_id3_parcom.h
+++ b/fileformats/id3parcom/include/pv_id3_parcom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -304,7 +304,10 @@
         /** Enumerated list of ID3 Frame Types */
         typedef enum
         {
-            PV_ID3_FRAME_UNSUPPORTED = -1,
+            PV_ID3_FRAME_INVALID = -3,
+            PV_ID3_FRAME_CANDIDATE,		/**< Frame ID doesn't match with known frame IDs.
+										 The frame ID made out of the characters capital A-Z and 0-9.*/
+            PV_ID3_FRAME_UNRECOGNIZED,	/** Valid frame ID, but ID3 parcom doesn't support. */
             PV_ID3_FRAME_TITLE,         /**< Title. Supported by all ID3 versions. Maximum 30 characters for
 										 ID3v1.x. There is no maximum length limit for ID3v2.x. */
             PV_ID3_FRAME_ARTIST,        /**< Artist. Supported by all ID3 versions. Maximum 30 characters for
@@ -357,7 +360,7 @@
             uint8     iID3V2TagFlagsV2;
             uint32    iID3V2ExtendedHeaderSize;
             uint32    iID3V2TagSize;
-            uint8     iID3V2FrameID[5	];
+            uint8     iID3V2FrameID[5];
             uint8     iID3V2FrameFlag[2];
             bool	  iFooterPresent;
             uint8	  iID3V2LanguageID[4];
@@ -365,6 +368,29 @@
         };
 
         /**
+         * @brief Checks the ID3 Tag v2.4 frame size whether it is syncsafe or not.
+         *
+         * This function validates next ID3 frame to check whether frame size is
+         * syncsafe.
+         *
+         * @returns Validated frame size
+         */
+        uint32 ValidateFrameLengthV2_4(uint32 aFrameSize);
+
+        /**
+         * @brief Checks the ID3 Tag v2.4 frame is valid or not.
+         *
+         * This function validates ID3 frame type and then, frame size and flags
+         *
+         * @params
+         * [IN] bUseSyncSafeFrameSize - validate syncsafe/non-syncsafe frame size
+         * [OUT] frameType - frame type for frame currently validated
+         *
+         * @returns validation status
+         */
+        bool ValidateFrameV2_4(PVID3FrameType& frameType, bool bUseSyncSafeFrameSize = true);
+
+        /**
          * @brief Checks the file for the presence of ID3V1 Tag.
          *
          * This function checks the file for the presence of ID3V1 Tag. This tag is
@@ -395,16 +421,15 @@
          * found. The data in the ID3V1 tag can only be ASCII, so the ConvertToUnicode
          * must be called for all fields read from the ID3V1 tag.
          *
-         * @param aTitleOnlyFlag Indicates whether to read title only or read
-         * other metadata information.
+         * @param None
          * @returns None
          */
-        void ReadID3V1Tag(bool aTitleOnlyFlag);
+        void ReadID3V1Tag();
 
         /**
          * @brief reads id3 V2 tag header.
          * @param aReadTags, read the id3 frames when true, else just reads the header
-         * @returns true if tags were read successfully
+         * @@returns true if tags were read successfully
          */
         bool ReadHeaderID3V2(bool aReadTags = true);
 
@@ -412,7 +437,7 @@
          * @brief Parses the ID3V2 tag frames from the file and populates the
          * frame vector when an ID3V2 tag is found
          * @param version ID3 V2 sub version number (v2.2, v2.3 or v2.4)
-         * @returns number of tags successfully parsed
+         * * @returns number of tags successfully parsed
          */
         int ReadTagID3V2(PVID3Version version);
 
@@ -537,7 +562,16 @@
          * @param None
          * @returns Value that describes the current frame of type PVID3FrameType
          */
-        PVID3FrameType FrameSupportedID3V2(PVID3Version version);
+        PVID3FrameType FrameSupportedID3V2(PVID3Version version, uint8* aframeid = NULL);
+
+        /**
+         * @brief Detects the ID3V2FrameType and fine whether it us unsupported or
+         * invalid frame type.
+         *
+         * @param None
+         * @returns Value that describes the current frame of type PVID3FrameType
+         */
+        PVID3FrameType FrameValidatedID3V2_4(uint8* aFrameID);
 
         /**
          * @brief Detects the ID3V 2.2 FrameType and returns the enum value that
@@ -662,14 +696,15 @@
         /**
          * @brief reads frame of type track length
          * @param aValueSize size of the frame
+         * @param aCharSet text encoding
          * @return completion status
          */
-        PVMFStatus ReadTrackLengthFrame(uint32 aValueSize);
+        PVMFStatus ReadTrackLengthFrame(uint32 aValueSize, PVID3CharacterSet aCharSet);
 
         /**
          * @brief reads ID3 frames
          * @param aFrameType frame type
-          * @param aValueSize size of the frame data
+         * @param aValueSize size of the frame data
          * @return Completion status
          */
 
@@ -821,12 +856,43 @@
          */
         PVMFStatus ComposeID3v2Tag(OsclRefCounterMemFrag& aTag);
 
+        /**
+         * @brief push frame to supplied frame vector
+         * @param aFrame Frame to be pushed
+         * @param aFrameVector vector in which frame is to be pushed
+         * @return Completion Status
+         */
+        PVMFStatus PushFrameToFrameVector(PvmiKvpSharedPtr& aFrame, PvmiKvpSharedPtrVector& aFrameVector);
+        /**
+         * @brief Allocate array of specified size and type of elements
+         * @param aValueType, type of array elements
+         * @param aNumElements, size of required array
+         * @return aLeaveCode, err code
+         * @return buffer, pointer to allocated buffer
+         */
+        OsclAny* AllocateValueArray(int32& aLeaveCode, PvmiKvpValueType aValueType, int32 aNumElements, OsclMemAllocator* aMemAllocator = NULL);
+
+        /**
+         * @brief Allocate kvp and handle leave
+         * @param aValueType, type of array elements
+         * @param aValueSize, value size of required kvp
+         * @return aStatus, err code
+         * @return truncate, returns false if specified memory is not allocated, else true
+         */
+        PvmiKvpSharedPtr HandleErrorForKVPAllocation(OSCL_String& aKey, PvmiKvpValueType aValueType, uint32 aValueSize, bool &truncate, PVMFStatus &aStatus);
+
     private:
 
         // Variables for parsing
         PVFile* iInputFile;
         TID3TagInfo iID3TagInfo;
         bool iTitleFoundFlag;
+        bool iArtistFoundFlag;
+        bool iAlbumFoundFlag;
+        bool iYearFoundFlag;
+        bool iCommentFoundFlag;
+        bool iTrackNumberFoundFlag;
+        bool iGenereFoundFlag;
         int32 iFileSizeInBytes;
         uint32 iByteOffsetToStartOfAudioFrames;
 
diff --git a/fileformats/id3parcom/include/pv_id3_parcom_constants.h b/fileformats/id3parcom/include/pv_id3_parcom_constants.h
index 7467a64..6839a12 100644
--- a/fileformats/id3parcom/include/pv_id3_parcom_constants.h
+++ b/fileformats/id3parcom/include/pv_id3_parcom_constants.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,6 +78,19 @@
 //Max length for null terminated strings in text frames
 #define ID3_MAX_STRING_FRAME_LEN				256
 
+#define MAX_SYNCSAFE_LEN						127
+#define ID3V2_4_MASK_FRAME_FLAG_VERIFICATION	31
+
+#define ID3V2_4_DATA_LENGTH_INDICATOR_SIZE		4
+
+//The frame ID made out of the characters capital A-Z and 0-9.
+#define IS_VALID_FRAME_ID_CHAR(ch) ((ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))
+#define IS_POTENTIAL_FRAME_ID(id) IS_VALID_FRAME_ID_CHAR(id[0]) && \
+										IS_VALID_FRAME_ID_CHAR(id[1]) && \
+										IS_VALID_FRAME_ID_CHAR(id[2]) && \
+										IS_VALID_FRAME_ID_CHAR(id[3])
+
+
 #define	ID3V2_FLAGS							0x00
 #define EXT_FLAGMASK                         64 // 0x40
 #define FTR_FLAGMASK                         16 // 0x10
@@ -85,6 +98,7 @@
 #define EXTHDR_UPDMASK						 64 // 0x40
 #define ENCR_COMP_3_FLAGMASK					192//0xC0
 #define ENCR_COMP_4_FLAGMASK                    12 //0x0C
+#define FRAME_LENGTH_INDICATOR_FLAGMASK      1 //0x01
 
 #define VALID_BITS_IN_SYNC_SAFE_BYTE           7
 #define UNICODE_LITTLE_ENDIAN_INDICATOR       255 // 0xff
@@ -154,6 +168,84 @@
 #define ID3_FRAME_ID_DESCRIPTION	"TIT3"
 #define ID3_FRAME_ID_VERSION		"TENC"
 
+/*		     - List of unsupported frames -	           */
+#define ID3_FRAME_ID_ENCRYPTION						"AENC"
+#define ID3_FRAME_ID_AUDIO_SEEK_POINT_INDEX			"ASPI"
+#define ID3_FRAME_ID_COMMERCIAL_FRAME				"COMR"
+#define ID3_FRAME_ID_ENCRYPTION_REGISTRATION		"ENCR"
+#define ID3_FRAME_ID_EQUALIZATION2					"EQU2"
+#define ID3_FRAME_ID_EVENT_TIMING_CODES				"ETCO"
+#define ID3_FRAME_ID_GENERAL_ENCAPSULATED_OBJECT	"GEOB"
+#define ID3_FRAME_ID_GROUP_IDENTITY_REGISTRATION	"GRID"
+#define ID3_FRAME_ID_LINKED_INFORMATION				"LINK"
+#define ID3_FRAME_ID_MUSIC_CD_IDENTIFIER			"MCDI"
+#define ID3_FRAME_ID_MPEG_LOCATION_LOOKUP_TABLE		"MLLT"
+#define ID3_FRAME_ID_OWNERSHIP_FRAME				"OWNE"
+#define ID3_FRAME_ID_PRIVATE_FRAME					"PRIV"
+#define ID3_FRAME_ID_PLAY_COUNTER					"PCNT"
+#define ID3_FRAME_ID_POPULARIMETER					"POPM"
+#define ID3_FRAME_ID_POSITION_SYNCH_FRAME			"POSS"
+#define ID3_FRAME_ID_RECOMMENDED_BUFFER_SIZE		"RBUF"
+#define ID3_FRAME_ID_RELATIVE_VOLUME_ADJUSTMENT2	"RVA2"
+#define ID3_FRAME_ID_REVERB							"RVRB"
+#define ID3_FRAME_ID_SYNCHRONIZED_LYRICS_TEXT		"SYLT"
+#define ID3_FRAME_ID_SYNCHRONIZED_TEMPO_CODES		"SYTC"
+#define ID3_FRAME_ID_BPM							"TBPM"
+#define ID3_FRAME_ID_PLAYLIST_DELAY					"TDLY"
+#define ID3_FRAME_ID_FILE_TYPE						"TFLT"
+#define ID3_FRAME_ID_CONTENT_GROUP_DESC				"TIT1"
+#define ID3_FRAME_ID_INITIAL_KEY					"TKEY"
+#define ID3_FRAME_ID_LANGUAGE						"TLAN"
+#define ID3_FRAME_ID_MEDIA_TYPE						"TMED"
+#define ID3_FRAME_ID_ORIGINAL_ALBUM					"TOAL"
+#define ID3_FRAME_ID_ORIGINAL_FILENAME				"TOFN"
+#define ID3_FRAME_ID_ORIGINAL_LYRICIST				"TOLY"
+#define ID3_FRAME_ID_ORIGINAL_ARTIST				"TOPE"
+#define ID3_FRAME_ID_FILE_LICENSEE					"TOWN"
+#define ID3_FRAME_ID_BAND							"TPE2"
+#define ID3_FRAME_ID_CONDUCTOR						"TPE3"
+#define ID3_FRAME_ID_MODIFIER						"TPE4"
+#define ID3_FRAME_ID_PART_OF_SET					"TPOS"
+#define ID3_FRAME_ID_PUBLISHER						"TPUB"
+#define ID3_FRAME_ID_INTERNET_RADIO_STATION_NAME	"TRSN"
+#define ID3_FRAME_ID_INTERNET_RADIO_STATION_OWNER	"TRSO"
+#define ID3_FRAME_ID_RECORDING_CODE					"TSRC"
+#define ID3_FRAME_ID_SOFTWARE_SETTING_ENCODE		"TSSE"
+#define ID3_FRAME_ID_UNIQUE_FILE_IDENTIFIER			"UFID"
+#define ID3_FRAME_ID_TERMS_OF_USE					"USER"
+#define ID3_FRAME_ID_COMMERCIAL_INFO				"WCOM"
+#define ID3_FRAME_ID_LEGAL_INFO						"WCOP"
+#define ID3_FRAME_ID_OFFICIAL_AUDIO_FILE_WEBPAGE	"WOAF"
+#define ID3_FRAME_ID_OFFICIAL_ARTIST_WEBPAGE		"WOAR"
+#define ID3_FRAME_ID_OFFICIAL_AUDIO__SOURCE_WEBPAGE	"WOAS"
+#define ID3_FRAME_ID_OFFICIAL_RADIO_STATION_WEBPAGE	"WORS"
+#define ID3_FRAME_ID_PAYMENT						"WPAY"
+#define ID3_FRAME_ID_PUBLISHER_OFFICIAL_WEBPAGE		"WPUB"
+#define ID3_FRAME_ID_SIGNATURE_FRAME				"SIGN"
+#define ID3_FRAME_ID_ENCODING_TIME					"TDEN"
+#define ID3_FRAME_ID_ORIGINAL_RELEASE_TIME			"TDOR"
+#define ID3_FRAME_ID_RELEASE_TIME					"TDRL"
+#define ID3_FRAME_ID_TAGGING_TIME					"TDTG"
+#define ID3_FRAME_ID_INVOLVED_PEOPLE_LIST			"TIPL"
+#define ID3_FRAME_ID_MUSICIAN_CREDITS_LIST			"TMCL"
+#define ID3_FRAME_ID_MOOD							"TMOO"
+#define ID3_FRAME_ID_PRODUCED_NOTICE				"TPRO"
+#define ID3_FRAME_ID_ALBUM_SORT_ORDER				"TSOA"
+#define ID3_FRAME_ID_PERFORMER_SORT_ORDER			"TSOP"
+#define ID3_FRAME_ID_TITLE_SORT_ORDER				"TSOT"
+#define ID3_FRAME_ID_SET_SUBTITLE					"TSST"
+#define ID3_FRAME_ID_USER_DEFINED_URL_LINK_FRAME	"WXXX"
+#define ID3_FRAME_ID_USER_DEFINED_TEXT_INFO			"TXXX"
+/* deprecated frames in v2.4 */
+//#define ID3_FRAME_ID_EQUALIZATION					"EQUA"
+//#define ID3_FRAME_ID_INVOLVED PEOPLE_LIST			"IPLS"
+//#define ID3_FRAME_ID_RELATIVE_VOLUME_ADJUSTMENT	"RVAD"
+//#define ID3_FRAME_ID_TIME							"TIME"
+//#define ID3_FRAME_ID_ORIGINAL_RELEASE_YEAR		"TORY"
+//#define ID3_FRAME_ID_RECORDING_DATES				"TRDA"
+//#define ID3_FRAME_ID_SIZE							"TSIZ"
+/*		- List of unsupported frames - end here -		*/
+
 
 #define ID3_V1_IDENTIFIER			"TAG"
 #define ID3_V2_IDENTIFIER			"ID3"
diff --git a/fileformats/id3parcom/include/pv_id3_parcom_types.h b/fileformats/id3parcom/include/pv_id3_parcom_types.h
index 56097dd..5a33d54 100644
--- a/fileformats/id3parcom/include/pv_id3_parcom_types.h
+++ b/fileformats/id3parcom/include/pv_id3_parcom_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/id3parcom/src/pv_id3_parcom.cpp b/fileformats/id3parcom/src/pv_id3_parcom.cpp
index 7f21c11..abd14ef 100644
--- a/fileformats/id3parcom/src/pv_id3_parcom.cpp
+++ b/fileformats/id3parcom/src/pv_id3_parcom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,7 @@
 #ifndef NULL_TERM_CHAR
 #define NULL_TERM_CHAR '\0'
 #endif
+
 // DLL entry point
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
@@ -74,11 +75,17 @@
 OSCL_EXPORT_REF PVID3ParCom::PVID3ParCom()
         : iInputFile(NULL),
         iTitleFoundFlag(false),
+        iArtistFoundFlag(false),
+        iAlbumFoundFlag(false),
+        iYearFoundFlag(false),
+        iCommentFoundFlag(false),
+        iTrackNumberFoundFlag(false),
+        iGenereFoundFlag(false),
         iFileSizeInBytes(0),
         iByteOffsetToStartOfAudioFrames(0),
-        iVersion(PV_ID3_INVALID_VERSION),
         iID3V1Present(false),
         iID3V2Present(false),
+        iVersion(PV_ID3_INVALID_VERSION),
         iUseMaxTagSize(false),
         iMaxTagSize(0),
         iUsePadding(false),
@@ -91,6 +98,9 @@
     iID3TagInfo.iID3V2TagFlagsV2 = 0;
     iID3TagInfo.iID3V2TagSize = 0 ;
     iID3TagInfo.iFooterPresent = false;
+
+    oscl_memset(&iID3TagInfo.iID3V2FrameFlag, 0, sizeof(iID3TagInfo.iID3V2FrameFlag));
+
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -285,11 +295,8 @@
         //check for ID3 Version 1
         if (CheckForTagID3V1())
         {
-            if (!iTitleFoundFlag)
-            {
-                //Read the header
-                ReadID3V1Tag(true);
-            }
+            iVersion = PV_ID3_V1;
+            ReadID3V1Tag();
         }
         if (iInputFile->Seek(currentFilePosn, Oscl_File::SEEKSET) == -1)
         {
@@ -297,12 +304,12 @@
             return PVMFFailure;
         }
     }
-    if (!readTags && CheckForTagID3V1())
+    else if (!readTags && CheckForTagID3V1())
     {
         //check for ID3 Version 1
         iVersion = PV_ID3_V1;
         //Read the header
-        ReadID3V1Tag(false);
+        ReadID3V1Tag();
 
         iByteOffsetToStartOfAudioFrames = 0;
         if (iInputFile->Seek(currentFilePosn, Oscl_File::SEEKSET) == -1)
@@ -311,9 +318,8 @@
             return PVMFFailure;
         }
     }
-    else if (!readTags)
+    else
     {
-        //Neither ID3V1 nor ID3V2 are present
         return PVMFFailure;
     }
 
@@ -347,19 +353,14 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVID3ParCom::GetID3Frame(const OSCL_String& aFrameType, PvmiKvpSharedPtrVector& aFrame)
+OSCL_EXPORT_REF PVMFStatus PVID3ParCom::GetID3Frame(const OSCL_String& aFrameType, PvmiKvpSharedPtrVector& aFrameVector)
 {
     uint32 i;
-    int32 err = 0;
     for (i = 0; i < iFrames.size(); i++)
     {
         if (pv_mime_strcmp(iFrames[i]->key, aFrameType.get_str()) == 0)
         {
-            OSCL_TRY(err, aFrame.push_back(iFrames[i]););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 LOG_ERR((0, "PVID3ParCom::GetID3Frame: Error - aFrame.push_back failed"));
-                                 return PVMFErrNoMemory;
-                                );
+            return PushFrameToFrameVector(iFrames[i], aFrameVector);
         }
     }
 
@@ -444,16 +445,15 @@
             return PVMFErrNotSupported;
     }
 
-    int32 err = 0;
+    status = PVMFSuccess;
     PvmiKvpSharedPtr kvp;
     bool truncate = false;
-    OSCL_TRY(err, kvp = AllocateKvp(key, kvpValueType, valueSize, truncate););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::SetID3Frame: Error - AllocateKvp failed"));
-                         return PVMFErrNoMemory;
-                        );
-    if (truncate)
+    kvp = HandleErrorForKVPAllocation(key, kvpValueType, valueSize, truncate, status);
+
+    if (truncate || (PVMFSuccess != status) || !kvp)
+    {
         return PVMFErrNoMemory;
+    }
 
     switch (kvpValueType)
     {
@@ -465,22 +465,20 @@
             oscl_strncpy(kvp->value.pWChar_value, aFrame.value.pWChar_value, valueStrLen);
             kvp->value.pWChar_value[valueStrLen] = NULL_TERM_CHAR;
             break;
-        case PVMI_KVPVALTYPE_KSV:
-            // Comment field
-            break;
         case PVMI_KVPVALTYPE_UINT32:
             kvp->value.uint32_value = aFrame.value.uint32_value;
             break;
+        case PVMI_KVPVALTYPE_KSV:
+            // comment field
         default:
             return PVMFErrNotSupported;
     }
 
-    OSCL_TRY(err, iFrames.push_back(kvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::SetID3Frame: Error - iFrames.push_back() failed"));
-                         return PVMFErrNoMemory;
-                        );
 
+    if (PVMFSuccess != PushFrameToFrameVector(kvp, iFrames))
+    {
+        return PVMFErrNoMemory;
+    }
     return PVMFSuccess;
 }
 
@@ -578,7 +576,6 @@
 OSCL_EXPORT_REF bool PVID3ParCom::IsID3V2Present(PVFile* aFile, uint32& aTagSize)
 {
     iInputFile = aFile;
-
     if (iID3V2Present)
     {
         // if id3 tag has already been discovered, just return the tag size
@@ -622,7 +619,7 @@
 
     tag_size = SafeSynchIntToInt32(size);
 
-    if (iInputFile->Seek(-(int32)(tag_size + 1 + ID3V2_TAG_NUM_BYTES_HEADER + (ID3V2_TAG_NUM_BYTES_HEADER - ID3V2_TAG_NUM_BYTES_ID)),
+    if (iInputFile->Seek(-(int32)(tag_size + ID3V2_TAG_NUM_BYTES_HEADER + (ID3V2_TAG_NUM_BYTES_HEADER - ID3V2_TAG_NUM_BYTES_ID)),
                          Oscl_File::SEEKCUR) == -1)
     {
         return PVMFFailure;
@@ -714,165 +711,261 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-void PVID3ParCom::ReadID3V1Tag(bool aTitleOnlyFlag)
+void PVID3ParCom::ReadID3V1Tag(void)
 {
+
     PVMFStatus status = PVMFSuccess;
     bool truncate = false;
-    status = ReadStringValueFrame(PV_ID3_FRAME_TITLE, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_TITLE);
-    if (status != PVMFSuccess)
+
+    if (!iTitleFoundFlag)
     {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for title"));
-        OSCL_LEAVE(OsclErrGeneral);
+        //Title
+        status = ReadStringValueFrame(PV_ID3_FRAME_TITLE, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_TITLE);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for title"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+        iTitleFoundFlag = true;
+    }
+    else
+    {
+
+        if (iInputFile->Seek(ID3V1_MAX_NUM_BYTES_TITLE, Oscl_File::SEEKCUR) == -1)
+        {
+            return;
+        }
+
+    }
+    if (!iArtistFoundFlag)
+    {
+        //Artist
+        status = ReadStringValueFrame(PV_ID3_FRAME_ARTIST, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_ARTIST);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for artist"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+        iArtistFoundFlag = true;
+    }
+    else
+    {
+        if (iInputFile->Seek(ID3V1_MAX_NUM_BYTES_ARTIST, Oscl_File::SEEKCUR) == -1)
+        {
+            return;
+        }
     }
 
-    iTitleFoundFlag = true;
-    if (aTitleOnlyFlag)
+    if (!iAlbumFoundFlag)
     {
-        return;
+        // Album
+        status = ReadStringValueFrame(PV_ID3_FRAME_ALBUM, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_ALBUM);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for album"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+        iAlbumFoundFlag = true;
+    }
+    else
+    {
+        if (iInputFile->Seek(ID3V1_MAX_NUM_BYTES_ALBUM, Oscl_File::SEEKCUR) == -1)
+        {
+            return;
+        }
     }
 
-    status = ReadStringValueFrame(PV_ID3_FRAME_ARTIST, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_ARTIST);
-    if (status != PVMFSuccess)
+    if (!iYearFoundFlag)
     {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for artist"));
-        OSCL_LEAVE(OsclErrGeneral);
+        //Year
+        status = ReadStringValueFrame(PV_ID3_FRAME_YEAR, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_YEAR);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for year"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+        iYearFoundFlag = true;
     }
-
-    status = ReadStringValueFrame(PV_ID3_FRAME_ALBUM, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_ALBUM);
-    if (status != PVMFSuccess)
+    else
     {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for album"));
-        OSCL_LEAVE(OsclErrGeneral);
+        if (iInputFile->Seek(ID3V1_MAX_NUM_BYTES_YEAR, Oscl_File::SEEKCUR) == -1)
+        {
+            return;
+        }
     }
-
-    status = ReadStringValueFrame(PV_ID3_FRAME_YEAR, PV_ID3_CHARSET_ISO88591, ID3V1_MAX_NUM_BYTES_YEAR);
-    if (status != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error = ReadStringValueFrame failed for year"));
-        OSCL_LEAVE(OsclErrGeneral);
-    }
-
-    // Read and convert comment & track number
-    uint8* frameData = NULL;
-    uint32 frameDataSize = ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1;
-    int32 err = 0;
-    OSCL_TRY(err, frameData = (uint8*)iAlloc.ALLOCATE(frameDataSize););
-    if (err != OsclErrNone || !frameData)
-    {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - Out of memory"));
-        OSCL_LEAVE(OsclErrNoMemory);
-    }
-    oscl_memset(frameData, 0, frameDataSize);
-
-    if (readByteData(iInputFile, ID3V1_MAX_NUM_BYTES_COMMENT, frameData) == false)
-    {
-        iAlloc.deallocate(frameData);
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - readByteData failed"));
-        OSCL_LEAVE(OsclErrGeneral);
-    }
-
     OSCL_StackString<128> keyStr;
     PvmiKvpSharedPtr kvpPtr;
-    if (frameData[ID3V1_MAX_NUM_BYTES_COMMENT-2] == 0 &&
-            frameData[ID3V1_MAX_NUM_BYTES_COMMENT-1] != 0)
-    {
-        // This would mean its an ID3v1.1 tag and hence has the
-        // the track number also, so extract it
-        iVersion = PV_ID3_V1_1;
+    uint8* frameData = NULL;
 
-        if (ConstructKvpKey(keyStr, PV_ID3_FRAME_TRACK_NUMBER, PV_ID3_CHARSET_INVALID) != PVMFSuccess)
+    if (!iCommentFoundFlag   || !iTrackNumberFoundFlag)
+    {
+        frameData = NULL;
+        //Comment or Track Number
+        // Read and convert comment & track number
+        uint32 frameDataSize = ID3V1_MAX_NUM_BYTES_FIELD_SIZE + 1;
+        int32 err = OsclErrNone;
+        frameData = (uint8*) AllocateValueArray(err, PVMI_KVPVALTYPE_UINT8PTR, frameDataSize, &iAlloc);
+        if (OsclErrNone != err || !frameData)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - Out of memory"));
+            OSCL_LEAVE(OsclErrNoMemory);
+        }
+        oscl_memset(frameData, 0, frameDataSize);
+
+        if (readByteData(iInputFile, ID3V1_MAX_NUM_BYTES_COMMENT, frameData) == false)
         {
             iAlloc.deallocate(frameData);
-            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - ConstructKvpKey failed for tracknumber"));
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - readByteData failed"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+
+
+        if (frameData[ID3V1_MAX_NUM_BYTES_COMMENT-2] == 0 &&
+                frameData[ID3V1_MAX_NUM_BYTES_COMMENT-1] != 0)
+        {
+            if (!iTrackNumberFoundFlag)
+            {
+                // This would mean its an ID3v1.1 tag and hence has the
+                // the track number also, so extract it
+                iVersion = PV_ID3_V1_1;
+
+                if (ConstructKvpKey(keyStr, PV_ID3_FRAME_TRACK_NUMBER, PV_ID3_CHARSET_INVALID) != PVMFSuccess)
+                {
+                    iAlloc.deallocate(frameData);
+                    LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - ConstructKvpKey failed for tracknumber"));
+                    OSCL_LEAVE(OsclErrNotSupported);
+                }
+
+                // Allocate key-value pair
+                OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_UINT32, 1, truncate););
+                if (OsclErrNone != err || !kvpPtr)
+                {
+                    LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - AllocateKvp failed. err=%d", err));
+                    iAlloc.deallocate(frameData);
+                    OSCL_LEAVE(OsclErrNoMemory);
+                    return;
+                }
+
+                if (!truncate)
+                {
+                    kvpPtr->value.uint32_value = (uint32)frameData[ID3V1_MAX_NUM_BYTES_COMMENT - 1];
+                }
+                OSCL_TRY(err, iFrames.push_back(kvpPtr););
+                OSCL_FIRST_CATCH_ANY(err,
+                                     LOG_ERR((0, "PVID3ParCom::ReadTrackLengthFrame: Error - iFrame.push_back failed"));
+                                     iAlloc.deallocate(frameData);
+                                     OSCL_LEAVE(OsclErrNoMemory);
+                                     return;
+                                    );
+                iTrackNumberFoundFlag = true;
+            }
+        }
+        if (!iCommentFoundFlag)
+        {
+
+            // Comment frame
+            frameData[ID3V1_MAX_NUM_BYTES_COMMENT] = 0;
+            if (ConstructKvpKey(keyStr, PV_ID3_FRAME_COMMENT, PV_ID3_CHARSET_ISO88591) != PVMFSuccess)
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - ConstructKvpKey failed for tracknumber"));
+                iAlloc.deallocate(frameData);
+                OSCL_LEAVE(OsclErrNotSupported);
+            }
+
+            uint32 dataSize = ID3V1_MAX_NUM_BYTES_COMMENT + 1;
+            // Allocate key-value pair
+            OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_CHARPTR, dataSize, truncate););
+            if (OsclErrNone != err || !kvpPtr)
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - AllocateKvp failed. err=%d", err));
+                iAlloc.deallocate(frameData);
+                OSCL_LEAVE(OsclErrNoMemory);
+                return;
+            }
+
+            if (!truncate)
+            {
+                uint32 comment_size = oscl_strlen((char*) frameData);
+                oscl_strncpy(kvpPtr->value.pChar_value, (char *)frameData, dataSize);
+                kvpPtr->value.pChar_value[comment_size] = 0;
+                kvpPtr->length = comment_size + 1;
+            }
+
+            if (PVMFSuccess != PushFrameToFrameVector(kvpPtr, iFrames))
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - iFrame.push_back failed"));
+                iAlloc.deallocate(frameData);
+                return ;
+            }
+            iCommentFoundFlag = true;
+
+        }
+        iAlloc.deallocate(frameData);
+    }
+    else
+    {
+        if (iInputFile->Seek(ID3V1_MAX_NUM_BYTES_FIELD_SIZE, Oscl_File::SEEKCUR) == -1)
+        {
+            return;
+        }
+    }
+    if (!iGenereFoundFlag)
+    {
+        // Genre frame
+        uint32 frameDataSize = ID3V1_MAX_NUM_BYTES_GENRE + 1;
+        int32 err = 0;
+        frameData = (uint8*) AllocateValueArray(err, PVMI_KVPVALTYPE_UINT8PTR, frameDataSize, &iAlloc);
+        if (OsclErrNone != err || !frameData)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - Out of memory"));
+            OSCL_LEAVE(OsclErrNoMemory);
+        }
+        oscl_memset(frameData, 0, frameDataSize);
+
+        if (readByteData(iInputFile, ID3V1_MAX_NUM_BYTES_GENRE, frameData) == false)
+        {
+            iAlloc.deallocate(frameData);
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - readByteData failed"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+
+        if (ConstructKvpKey(keyStr, PV_ID3_FRAME_GENRE, PV_ID3_CHARSET_INVALID) != PVMFSuccess)
+        {
+            iAlloc.deallocate(frameData);
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - ConstructKvpKey failed for genre"));
             OSCL_LEAVE(OsclErrNotSupported);
         }
 
-        // Allocate key-value pair
-        OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_UINT32, 0, truncate););
-
-        OSCL_FIRST_CATCH_ANY(err,
-                             LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - AllocateKvp failed. err=%d", err));
-                             iAlloc.deallocate(frameData);
-                             OSCL_LEAVE(OsclErrNoMemory);
-                             return;
-                            );
+        OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_UINT32, 1, truncate););
+        if (OsclErrNone != err || !kvpPtr)
+        {
+            iAlloc.deallocate(frameData);
+            LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - AllocateKvp failed. err=%d", err));
+            OSCL_LEAVE(OsclErrNoMemory);
+            return;
+        }
 
         if (!truncate)
-            kvpPtr->value.uint32_value = (uint32)frameData[ID3V1_MAX_NUM_BYTES_COMMENT - 1];
-
+        {
+            kvpPtr->value.uint32_value = (uint32)(frameData[ID3V1_MAX_NUM_BYTES_GENRE - 1]);
+        }
         OSCL_TRY(err, iFrames.push_back(kvpPtr););
         OSCL_FIRST_CATCH_ANY(err,
-                             LOG_ERR((0, "PVID3ParCom::ReadTrackLengthFrame: Error - iFrame.push_back failed"));
                              iAlloc.deallocate(frameData);
+                             LOG_ERR((0, "PVID3ParCom::ReadTrackLengthFrame: Error - iFrame.push_back failed"));
                              OSCL_LEAVE(OsclErrNoMemory);
                              return;
                             );
-    }
-
-    // Comment frame
-    frameData[ID3V1_MAX_NUM_BYTES_COMMENT] = 0;
-    if (ConstructKvpKey(keyStr, PV_ID3_FRAME_COMMENT, PV_ID3_CHARSET_ISO88591) != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - ConstructKvpKey failed for tracknumber"));
         iAlloc.deallocate(frameData);
-        OSCL_LEAVE(OsclErrNotSupported);
+        iGenereFoundFlag = true;
     }
-
-    uint32 dataSize = ID3V1_MAX_NUM_BYTES_COMMENT + 1;
-    // Allocate key-value pair
-    OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_CHARPTR, dataSize, truncate););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - AllocateKvp failed. err=%d", err));
-                         iAlloc.deallocate(frameData);
-                         OSCL_LEAVE(OsclErrNoMemory);
-                         return;
-                        );
-
-    if (!truncate)
-        oscl_strncpy(kvpPtr->value.pChar_value, (char *)frameData, dataSize) ;
-
-    OSCL_TRY(err, iFrames.push_back(kvpPtr););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - iFrame.push_back failed"));
-                         iAlloc.deallocate(frameData);
-                         return ;
-                        );
-
-    // Genre frame
-    oscl_memset(frameData, 0, frameDataSize);
-    if (readByteData(iInputFile, ID3V1_MAX_NUM_BYTES_GENRE, frameData) == false)
+    else
     {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - readByteData failed"));
-        iAlloc.deallocate(frameData);
-        OSCL_LEAVE(OsclErrGeneral);
+        if (iInputFile->Seek(ID3V1_MAX_NUM_BYTES_GENRE, Oscl_File::SEEKCUR) == -1)
+        {
+            return;
+        }
     }
-
-    if (ConstructKvpKey(keyStr, PV_ID3_FRAME_GENRE, PV_ID3_CHARSET_INVALID) != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - ConstructKvpKey failed for genre"));
-        iAlloc.deallocate(frameData);
-        OSCL_LEAVE(OsclErrNotSupported);
-    }
-
-    OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_UINT32, 0, truncate););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadID3V1Tag: Error - AllocateKvp failed. err=%d", err));
-                         iAlloc.deallocate(frameData);
-                         OSCL_LEAVE(OsclErrNoMemory);
-                         return;
-                        );
-
-    if (!truncate)
-        kvpPtr->value.uint32_value = (uint32)(frameData[ID3V1_MAX_NUM_BYTES_GENRE - 1]);
-
-    OSCL_TRY(err, iFrames.push_back(kvpPtr););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadTrackLengthFrame: Error - iFrame.push_back failed"));
-                         iAlloc.deallocate(frameData);
-                         OSCL_LEAVE(OsclErrNoMemory);
-                         return;
-                        );
-    iAlloc.deallocate(frameData);
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -1069,10 +1162,11 @@
 /////////////////////////////////////////////////////////////////////////////////
 int PVID3ParCom::ReadTagID3V2(PVID3Version aVersion)
 {
-    PVID3FrameType frameType;
+    PVID3FrameType frameType = PV_ID3_FRAME_EEND;
     uint32 i = 0;
-    uint32 currFrameLength;
+    uint32 currFrameLength = 0;
     uint32 current_file_pos = iInputFile->Tell();
+    uint32 data_len_indicator_size = 0;
     uint32 count = 0;
 
     if (iID3TagInfo.iID3V2ExtendedHeaderSize > 0)
@@ -1088,7 +1182,6 @@
 
         ReadFrameHeaderID3V2(aVersion);
 
-        currFrameLength = 0;
         currFrameLength = iID3TagInfo.iID3V2FrameSize;
         frameType = FrameSupportedID3V2(aVersion);
 
@@ -1113,14 +1206,12 @@
         if (aVersion == PV_ID3_V2_3)
         {
             if (iID3TagInfo.iID3V2FrameFlag[1] & ENCR_COMP_3_FLAGMASK)
-                frameType = PV_ID3_FRAME_UNSUPPORTED;
-
-
+                frameType = PV_ID3_FRAME_UNRECOGNIZED;
         }
         else if (aVersion == PV_ID3_V2_4)
         {
             if (iID3TagInfo.iID3V2FrameFlag[1] & ENCR_COMP_4_FLAGMASK)
-                frameType = PV_ID3_FRAME_UNSUPPORTED;
+                frameType = PV_ID3_FRAME_UNRECOGNIZED;
         }
 
         if (frameType == PV_ID3_FRAME_SEEK)
@@ -1130,7 +1221,25 @@
             return count;
         }
 
-        if (((currFrameLength > 1) && (frameType != PV_ID3_FRAME_UNSUPPORTED)))
+        // Check if data length indicator is present
+        if (aVersion == PV_ID3_V2_4 && (iID3TagInfo.iID3V2FrameFlag[1] & FRAME_LENGTH_INDICATOR_FLAGMASK))
+        {
+            uint32 temp = 0;
+            // Read data length indicator
+            if (read32(iInputFile, temp) == false)
+            {
+                return count;
+            }
+            // stored as syncsafe integer
+            currFrameLength = SafeSynchIntToInt32(temp);
+
+            data_len_indicator_size = ID3V2_4_DATA_LENGTH_INDICATOR_SIZE;
+        }
+
+        if (((currFrameLength > 1) && (frameType != PV_ID3_FRAME_UNRECOGNIZED
+                                       && frameType != PV_ID3_FRAME_INVALID
+                                       && frameType != PV_ID3_FRAME_EEND
+                                       && frameType != PV_ID3_FRAME_CANDIDATE)))
         {
             uint8 unicodeCheck;
 
@@ -1152,13 +1261,12 @@
 
                     return count;
                 }
-
             }
             else if (unicodeCheck < PV_ID3_CHARSET_END)
             {
 
                 if (!ReadFrameData(unicodeCheck, frameType,
-                                   current_file_pos + i + frame_header_size + 1 ,
+                                   current_file_pos + i + frame_header_size + data_len_indicator_size + 1,
                                    currFrameLength))
                 {
                     return count;
@@ -1167,42 +1275,193 @@
             else
             {
                 // This case is when no text type is defined in the frame.
-                HandleID3V2FrameDataASCII(frameType, i + frame_header_size,
-                                          currFrameLength);
-
+                HandleID3V2FrameDataASCII(frameType, i + frame_header_size + data_len_indicator_size, currFrameLength);
             }
             count++;
         }
         else
         {
-            if (frameType == PV_ID3_FRAME_EEND)
+            if (frameType == PV_ID3_FRAME_EEND ||
+                    frameType == PV_ID3_FRAME_INVALID)
             {
                 i = iID3TagInfo.iID3V2TagSize + 1;
             }
-            else if (frameType == PV_ID3_FRAME_UNSUPPORTED)
+            else if (frameType == PV_ID3_FRAME_UNRECOGNIZED ||
+                     frameType == PV_ID3_FRAME_CANDIDATE) // handle candidate frames as we do unsupported
             {
                 if (i < iID3TagInfo.iID3V2TagSize)
                 {
                     HandleID3V2FrameUnsupported(frameType,
                                                 current_file_pos + i,
-                                                currFrameLength + frame_header_size);
+                                                currFrameLength + frame_header_size + data_len_indicator_size);
                 }
-
-
-
             }
         }
 
-        i += currFrameLength + frame_header_size;
+        i += iID3TagInfo.iID3V2FrameSize + frame_header_size;
+    }
+    return count;
+}
+
+bool PVID3ParCom::ValidateFrameV2_4(PVID3FrameType& frameType, bool bUseSyncSafeFrameSize)
+{
+    // Initialize OUT param
+    frameType = PV_ID3_FRAME_INVALID;
+
+    uint8 frameid[ID3V2_FRAME_NUM_BYTES_ID + 1] = {0};
+    // read frame id for next frame
+    if (readByteData(iInputFile, ID3V2_FRAME_NUM_BYTES_ID, frameid) == false)
+    {
+        return false;
+    }
+    frameid[ID3V2_FRAME_NUM_BYTES_ID] = 0;
+
+    // Get frame type from frame ID
+    frameType = FrameSupportedID3V2(PV_ID3_V2_4, frameid);
+    if (PV_ID3_FRAME_INVALID == frameType ||
+            PV_ID3_FRAME_EEND == frameType)
+    {
+        return false;
+    }
+    else
+    {
+        uint32 frameSize = 0;
+        uint8 frameflags[ID3V2_FRAME_NUM_BYTES_FLAG] = {0};
+
+        // Validate frame size and flags
+
+        if (read32(iInputFile, frameSize) == false)
+        {
+            return false;
+        }
+        if (bUseSyncSafeFrameSize)
+        {
+            frameSize = SafeSynchIntToInt32(frameSize);
+        }
+
+        if (readByteData(iInputFile, ID3V2_FRAME_NUM_BYTES_FLAG, frameflags) == false)
+        {
+            return false;
+        }
+
+        if ((0 == frameSize ||
+                (frameSize + ID3V2_FRAME_NUM_BYTES_HEADER) > iID3TagInfo.iID3V2TagSize) ||
+                ((frameflags[0] & ID3V2_4_MASK_FRAME_FLAG_VERIFICATION) ||
+                 (frameflags[1] & ID3V2_4_MASK_FRAME_FLAG_VERIFICATION)))
+        {
+            // validation for frame size or flags failed
+            return false;
+        }
+        else
+        {
+            return true;
+        }
+    }
+}
+
+uint32 PVID3ParCom::ValidateFrameLengthV2_4(uint32 aFrameSize)
+{
+    int32 currFilePos = iInputFile->Tell();
+    int32 errCode = -1;
+    int32 actualFrameLen = 0;
+
+    // we have already read the complete current frame header
+
+    do
+    {
+        // Assuming syncsafe frame size
+        actualFrameLen = SafeSynchIntToInt32(aFrameSize);
+
+        //
+        /* validate frame using syncsafe size */
+        //
+
+        // Seek to next frame boundary with syncsafe size
+        errCode = iInputFile->Seek(actualFrameLen, Oscl_File::SEEKCUR);
+        if (-1 == errCode)
+        {
+            // proceed with default syncsafe handling
+            break;
+        }
+
+        bool bIsSyncSafeFrameValid = false;
+        PVID3FrameType frameTypeUsingSyncSafeSize = PV_ID3_FRAME_INVALID;
+        // Get the validation status and frame type
+        bIsSyncSafeFrameValid = ValidateFrameV2_4(frameTypeUsingSyncSafeSize);
+
+        //
+        /* validate frame using non-syncsafe size */
+        //
+
+        // FrameSize is not even stored as non-syncsafe
+        if ((aFrameSize + ID3V2_FRAME_NUM_BYTES_HEADER) > iID3TagInfo.iID3V2TagSize)
+        {
+            // proceed with syncsafe, as non-syncsafe length not valid
+            break;
+        }
+
+        // Seek back
+        errCode = iInputFile->Seek(currFilePos, Oscl_File::SEEKSET);
+        if (-1 == errCode)
+        {
+            LOG_ERR((0, "PVID3ParCom::ValidateFrameLengthV2_4: Error - iInputFile->Seek failed"));
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+        // Seek to next frame boundary with non-syncsafe size
+        errCode = iInputFile->Seek(aFrameSize, Oscl_File::SEEKCUR);
+        if (-1 == errCode)
+        {
+            // proceed with default syncsafe handling
+            break;
+        }
+
+        bool bIsNonSyncSafeFrameValid = false;
+        PVID3FrameType frameTypeUsingNonSyncSafeSize = PV_ID3_FRAME_INVALID;
+        // Get the validation status and frame type
+        bIsNonSyncSafeFrameValid = ValidateFrameV2_4(frameTypeUsingNonSyncSafeSize, false);
+
+        // - Give more priority to non-syncsafe VALID frame ID,
+        //		than syncsafe candidate frame ID (frame validation is true for both)
+        // - In case, we have frame validation true for both syncsafe and non-syncsafe size,
+        //		we will use default syncsafe representation
+        // - In case, we have frame validation false for both syncsafe and non-syncsafe size,
+        //		we will use default syncsafe representation
+        if (bIsSyncSafeFrameValid && frameTypeUsingSyncSafeSize != PV_ID3_FRAME_CANDIDATE)
+        {
+            // syncsafe representation
+        }
+        else if (bIsNonSyncSafeFrameValid && frameTypeUsingNonSyncSafeSize != PV_ID3_FRAME_CANDIDATE)
+        {
+            // non-syncsafe representation
+            actualFrameLen = aFrameSize;
+        }
+        else if (!bIsSyncSafeFrameValid && bIsNonSyncSafeFrameValid)
+        {
+            // non-syncsafe representation
+            actualFrameLen = aFrameSize;
+        }
+        else
+        {
+            // consider rest all syncsafe representation
+        }
+
+    }
+    while (false);
+
+    // Seek back
+    errCode = iInputFile->Seek(currFilePos, Oscl_File::SEEKSET);
+    if (-1 == errCode)
+    {
+        LOG_ERR((0, "PVID3ParCom::ValidateFrameLengthV2_4: Error - iInputFile->Seek failed"));
+        OSCL_LEAVE(OsclErrGeneral);
     }
 
-    return count;
+    return actualFrameLen;
 }
 
 //////////////////////////////////////////////////////////////////////////
 bool  PVID3ParCom::ReadFrameData(uint8 unicodeCheck, PVID3FrameType frameType, uint32 pos, uint32 currFrameLength)
 {
-
     if (unicodeCheck == PV_ID3_CHARSET_ISO88591)
     {
         // This frame contains normal ASCII text strings. (ISO-8859-1)
@@ -1254,8 +1513,6 @@
         iID3TagInfo.iTextType = PV_ID3_CHARSET_UTF8;
         HandleID3V2FrameDataUTF8(frameType,	pos, currFrameLength - 1);
     }
-
-
     return true;
 }
 
@@ -1268,23 +1525,31 @@
     }
     else
     {
+        // Read frame ID
         if (readByteData(iInputFile, ID3V2_FRAME_NUM_BYTES_ID, iID3TagInfo.iID3V2FrameID) == false)
         {
             return;
         }
         iID3TagInfo.iID3V2FrameID[ID3V2_FRAME_NUM_BYTES_ID] = 0;
+        // Read frame size
         if (read32(iInputFile, iID3TagInfo.iID3V2FrameSize) == false)
         {
             return;
         }
-        if (aVersion == PV_ID3_V2_4)
-        {
-            iID3TagInfo.iID3V2FrameSize = SafeSynchIntToInt32(iID3TagInfo.iID3V2FrameSize);
-        }
+        // Read frame flag
         if (readByteData(iInputFile, ID3V2_FRAME_NUM_BYTES_FLAG, iID3TagInfo.iID3V2FrameFlag) == false)
         {
             return;
         }
+
+        if (PV_ID3_V2_4 == aVersion)
+        {
+            if (iID3TagInfo.iID3V2FrameSize > MAX_SYNCSAFE_LEN)
+            {
+                // Verify whether frame length is SyncSafe or Non-SyncSafe
+                iID3TagInfo.iID3V2FrameSize = ValidateFrameLengthV2_4(iID3TagInfo.iID3V2FrameSize);
+            }
+        }
     }
     return;
 }
@@ -1322,7 +1587,7 @@
     switch (aFrameType)
     {
         case PV_ID3_FRAME_TRACK_LENGTH:
-            status = ReadTrackLengthFrame(aSize);
+            status = ReadTrackLengthFrame(aSize, PV_ID3_CHARSET_ISO88591);
             if (status != PVMFSuccess)
             {
                 LOG_ERR((0, "PVID3ParCom::HandleID3V2FrameDataASCII: Error - ReadTrackLengthFrame failed. status=%d", status));
@@ -1353,6 +1618,17 @@
             }
             if (aFrameType == PV_ID3_FRAME_TITLE)
                 iTitleFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_ARTIST)
+                iArtistFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_ALBUM)
+                iAlbumFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_YEAR)
+                iYearFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_TRACK_NUMBER)
+                iTrackNumberFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_GENRE)
+                iGenereFoundFlag = true;
+
             break;
 
         default:
@@ -1408,7 +1684,7 @@
 
         case PV_ID3_FRAME_TRACK_LENGTH:
             //is a numeric string and does not depend on text encoding.
-            status = ReadTrackLengthFrame(aSize);
+            status = ReadTrackLengthFrame(aSize, charSet);
             if (status != PVMFSuccess)
             {
                 LOG_ERR((0, "PVID3ParCom::HandleID3V2FrameDataUnicode16: Error - ReadTrackLengthFrame failed. status=%d", status));
@@ -1441,6 +1717,17 @@
             }
             if (aFrameType == PV_ID3_FRAME_TITLE)
                 iTitleFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_ARTIST)
+                iArtistFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_ALBUM)
+                iAlbumFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_YEAR)
+                iYearFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_TRACK_NUMBER)
+                iTrackNumberFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_GENRE)
+                iGenereFoundFlag = true;
+
             break;
 
         default:
@@ -1464,7 +1751,7 @@
     {
 
         case PV_ID3_FRAME_TRACK_LENGTH:
-            status = ReadTrackLengthFrame(aSize);
+            status = ReadTrackLengthFrame(aSize, PV_ID3_CHARSET_UTF8);
             if (status != PVMFSuccess)
             {
                 LOG_ERR((0, "PVID3ParCom::HandleID3V2FrameDataUTF8: Error - ReadTrackLengthFrame failed. status=%d", status));
@@ -1496,6 +1783,17 @@
             }
             if (aFrameType == PV_ID3_FRAME_TITLE)
                 iTitleFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_ARTIST)
+                iArtistFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_ALBUM)
+                iAlbumFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_YEAR)
+                iYearFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_TRACK_NUMBER)
+                iTrackNumberFoundFlag = true;
+            if (aFrameType == PV_ID3_FRAME_GENRE)
+                iGenereFoundFlag = true;
+
             break;
 
         default:
@@ -1527,11 +1825,12 @@
 //
 //------------------------------------------------------------------------------
 
-PVID3ParCom::PVID3FrameType PVID3ParCom::FrameSupportedID3V2(PVID3Version aVersion)
+PVID3ParCom::PVID3FrameType PVID3ParCom::FrameSupportedID3V2(PVID3Version aVersion, uint8* aframeid)
 {
     PVID3FrameType ID3V2FrameTypeReturnValue;
+    uint8* pFrameID = (aframeid) ? aframeid : iID3TagInfo.iID3V2FrameID;
 
-    if ((iID3TagInfo.iID3V2FrameID[0] == 0xff))
+    if (0xff == pFrameID[0])
     {
         //possibly start of mp3 frame. Stop further parsing.
         return PV_ID3_FRAME_EEND;
@@ -1543,101 +1842,108 @@
     }
     else	//for v2.3 & v2.4
     {
-
         uint8 endTestBuf[ID3V2_FRAME_NUM_BYTES_ID] = {0};
 
-        if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_TITLE, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        if (oscl_memcmp(pFrameID, ID3_FRAME_ID_TITLE, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_TITLE;
             iTitleFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_ARTIST, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_ARTIST, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_ARTIST;
+            iArtistFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_PART_OF_SET, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_PART_OF_SET, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_PART_OF_SET;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_ALBUM, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_ALBUM, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_ALBUM;
+            iAlbumFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_COPYRIGHT, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_COPYRIGHT, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_COPYRIGHT;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_GENRE, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_GENRE, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_GENRE;
+            iGenereFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_TRACK_NUMBER, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_TRACK_NUMBER, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_TRACK_NUMBER;
+            iTrackNumberFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_TRACK_LENGTH, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_TRACK_LENGTH, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_TRACK_LENGTH;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_COMMENT, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_COMMENT, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_COMMENT;
+            iCommentFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_YEAR, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_YEAR, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_YEAR;
+            iYearFoundFlag = true;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_DATE, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_RECORDING_TIME, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        {
+            ID3V2FrameTypeReturnValue = PV_ID3_FRAME_RECORDING_TIME;
+            iYearFoundFlag = true;
+        }
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_DATE, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_DATE;
         }
 
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_ALBUMART, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_ALBUMART, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_APIC;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_LYRICIST, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_LYRICIST, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_LYRICS;
         }
 
         // For the seek frame.
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_SEEK, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_SEEK, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_SEEK;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_RECORDING_TIME, ID3V2_FRAME_NUM_BYTES_ID) == 0)
-        {
-            ID3V2FrameTypeReturnValue = PV_ID3_FRAME_RECORDING_TIME;
-        }
-//new frames support
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_AUTHOR, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        //new frames support
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_AUTHOR, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_AUTHOR;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_COMPOSER, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_COMPOSER, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_COMPOSER;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_DESCRIPTION, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_DESCRIPTION, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_DESCRIPTION;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3_FRAME_ID_VERSION, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, ID3_FRAME_ID_VERSION, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_VERSION;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, endTestBuf, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, endTestBuf, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_EEND;
         }
-        else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, endTestBuf, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+        else if (oscl_memcmp(pFrameID, endTestBuf, ID3V2_FRAME_NUM_BYTES_ID) == 0)
         {
             ID3V2FrameTypeReturnValue = PV_ID3_FRAME_EEND;
         }
         else
         {
-            ID3V2FrameTypeReturnValue = PV_ID3_FRAME_UNSUPPORTED;
+            // Find whether frame is invalid or unsupported
+            ID3V2FrameTypeReturnValue = FrameValidatedID3V2_4(pFrameID);
         }
     }
     return ID3V2FrameTypeReturnValue;
@@ -1680,6 +1986,7 @@
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_ARTIST, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
         ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_ARTIST;
+        iArtistFoundFlag = true;
     }
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_PART_OF_SET, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
@@ -1688,6 +1995,7 @@
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_ALBUM, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
         ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_ALBUM;
+        iAlbumFoundFlag = true;
     }
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_COPYRIGHT, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
@@ -1696,10 +2004,12 @@
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_GENRE, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
         ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_GENRE;
+        iGenereFoundFlag = true;
     }
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_TRACK_NUMBER, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
         ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_TRACK_NUMBER;
+        iTrackNumberFoundFlag = true;
     }
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_TRACK_LENGTH, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
@@ -1708,10 +2018,12 @@
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_COMMENT, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
         ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_COMMENT;
+        iCommentFoundFlag = true;
     }
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_YEAR, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
         ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_YEAR;
+        iYearFoundFlag = true;
     }
     else if (oscl_memcmp(iID3TagInfo.iID3V2FrameID, ID3V2_2_FRAME_ID_DATE, ID3V2_2_FRAME_NUM_BYTES_ID) == 0)
     {
@@ -1750,7 +2062,7 @@
 
     else
     {
-        ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_UNSUPPORTED;
+        ID3V2_2FrameTypeReturnValue = PV_ID3_FRAME_UNRECOGNIZED;
     }
 
     return ID3V2_2FrameTypeReturnValue;
@@ -1991,13 +2303,14 @@
                         aligned_kvp_size + key_size + aValueSize;
 
     int32 error = 0;
-    OSCL_TRY(error, myPtr = (uint8*)iAlloc.ALLOCATE(total_size););
+    myPtr = (uint8*) AllocateValueArray(error, PVMI_KVPVALTYPE_UINT8PTR, total_size, &iAlloc);
     if ((error != OsclErrNone) || (!myPtr) || (total_size < aValueSize))
     {
         if (myPtr)
         {
             iAlloc.deallocate(myPtr);
         }
+
         char str_data_len[MAX_RANGE_INT_SIZE + 1] = {0};
         oscl_snprintf(str_data_len, MAX_RANGE_INT_SIZE + 1, "%d", aValueSize);
         aKey += SEMI_COLON;
@@ -2006,8 +2319,12 @@
         uint32 new_key_size = oscl_mem_aligned_size(aKey.get_size() + 1);
         error = OsclErrNone;
         total_size = aligned_refcnt_size + aligned_cleanup_size + aligned_kvp_size + new_key_size;
-        myPtr = (uint8*)iAlloc.ALLOCATE(total_size);
+        myPtr = (uint8*) AllocateValueArray(error, PVMI_KVPVALTYPE_UINT8PTR, total_size, &iAlloc);
         truncate = true;
+        if (OsclErrNone != error)
+        {
+            OSCL_LEAVE(OsclErrNoMemory);
+        }
     }
     oscl_memset(myPtr, 0, total_size);
 
@@ -2018,11 +2335,11 @@
     PvmiKvp* kvp = OSCL_STATIC_CAST(PvmiKvp *, myPtr) ;
     myPtr += aligned_kvp_size;
 
+    kvp->key = OSCL_STATIC_CAST(char* , myPtr);
+    myPtr += key_size;
+    oscl_strncpy(kvp->key, aKey.get_cstr(), key_size);
     if (!truncate)
     {
-        kvp->key = OSCL_STATIC_CAST(char* , myPtr);
-        myPtr += key_size;
-        oscl_strncpy(kvp->key, aKey.get_cstr(), key_size);
         switch (aValueType)
         {
             case PVMI_KVPVALTYPE_WCHARPTR:
@@ -2161,7 +2478,8 @@
             aKey += SEMI_COLON;
             aKey += KVP_VALTYPE_LYRICS;
             break;
-        case PV_ID3_FRAME_UNSUPPORTED:
+        case PV_ID3_FRAME_UNRECOGNIZED:
+        case PV_ID3_FRAME_CANDIDATE:
             aKey += _STRLIT_CHAR(KVP_ID3V2_VALUE);
             aKey += FORWARD_SLASH;
             aKey += _STRLIT_CHAR((char *)iID3TagInfo.iID3V2FrameID);
@@ -2222,7 +2540,7 @@
     }
 
     // Allocate key-value pair
-    int32 err = 0;
+    int32 err = OsclErrNone;
     PvmiKvpSharedPtr kvpPtr;
     bool truncate = false;
     switch (aCharSet)
@@ -2230,10 +2548,11 @@
         case PV_ID3_CHARSET_ISO88591:
         case PV_ID3_CHARSET_UTF8:
             OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_CHARPTR, aValueSize + 1, truncate););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - AllocateKvp failed. err=%d", err));
-                                 return PVMFErrNoMemory;
-                                );
+            if (OsclErrNone != err || !kvpPtr)
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - AllocateKvp failed. err=%d", err));
+                return PVMFErrNoMemory;
+            }
 
             if (truncate)
             {
@@ -2247,8 +2566,12 @@
                     LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - readByteData failed"));
                     return PVMFFailure;
                 }
-                kvpPtr->value.pChar_value[aValueSize] = NULL_TERM_CHAR;
-                kvpPtr->length = aValueSize;
+
+                int32 valueLen = aValueSize;
+                valueLen = oscl_strlen((char*)kvpPtr->value.pChar_value);
+
+                kvpPtr->value.pChar_value[valueLen] = NULL_TERM_CHAR;
+                kvpPtr->length = valueLen + 1;
             }
             // Add to frame vector
             OSCL_TRY(err, iFrames.push_back(kvpPtr););
@@ -2263,8 +2586,8 @@
         {
             // create buffers to store frame data
             uint8* ptrFrameData = NULL;
-            OSCL_TRY(err, ptrFrameData = (uint8*)iAlloc.allocate(aValueSize + 2););
-            if (err != OsclErrNone || !ptrFrameData)
+            ptrFrameData = (uint8*) AllocateValueArray(err, PVMI_KVPVALTYPE_UINT8PTR, aValueSize + 2, &iAlloc);
+            if (OsclErrNone != err || !ptrFrameData)
             {
                 LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - frameData allocation failed"));
                 return PVMFErrNoMemory;
@@ -2273,10 +2596,11 @@
             uint32 wchar_size = sizeof(oscl_wchar);	//for platforms where wchar is 4 bytes.
             // Allocate key-value pair
             OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_WCHARPTR, (wchar_size / 2) * (aValueSize + 2), truncate););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - AllocateKvp failed. err=%d", err));
-                                 return PVMFErrNoMemory;
-                                );
+            if (OsclErrNone != err || !kvpPtr)
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - AllocateKvp failed. err=%d", err));
+                return PVMFErrNoMemory;
+            }
 
             if (truncate)
             {
@@ -2297,17 +2621,19 @@
 
                 uint32 endianType = UNICODE_LITTLE_ENDIAN;
                 if (aCharSet == PV_ID3_CHARSET_UTF16BE)
+                {
                     endianType = UNICODE_BIG_ENDIAN;
+                }
 
                 uint32 wcSize = EightBitToWideCharBufferTransfer(ptrFrameData, aValueSize, endianType, kvpPtr->value.pWChar_value);
-
                 kvpPtr->value.pWChar_value[wcSize] = NULL_TERM_CHAR;
                 iAlloc.deallocate(ptrFrameData);
-                kvpPtr->length = aValueSize;
+                kvpPtr->length = wcSize;
             }
             OSCL_TRY(err, iFrames.push_back(kvpPtr););
             OSCL_FIRST_CATCH_ANY(err,
                                  LOG_ERR((0, "PVID3ParCom::ReadStringValueFrame: Error - iFrame.push_back failed"));
+                                 iAlloc.deallocate((OsclAny*)ptrFrameData);
                                  return PVMFErrNoMemory;
                                 );
         }
@@ -2333,14 +2659,16 @@
     }
 
     // Allocate key-value pair
-    int32 err = 0;
+    int32 err = OsclErrNone;
     PvmiKvpSharedPtr kvpPtr;
     bool truncate = false;
     OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_CHARPTR, aValueSize + 1 + VERSION_SIZE, truncate););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadFrame: Error - AllocateKvp failed. err=%d", err));
-                         return PVMFErrNoMemory;
-                        );
+    if (OsclErrNone != err || !kvpPtr)
+    {
+        LOG_ERR((0, "PVID3ParCom::ReadFrame: Error - AllocateKvp failed. err=%d", err));
+        return PVMFErrNoMemory;
+    }
+
     if (truncate)
     {
         iInputFile->Seek(aValueSize, Oscl_File::SEEKCUR);
@@ -2348,7 +2676,6 @@
     }
     else
     {
-
         kvpPtr->value.pUint8_value[0] = (uint8)iVersion;
         kvpPtr->value.pUint8_value[1] = 0;
 
@@ -2359,7 +2686,6 @@
         }
         kvpPtr->value.pUint8_value[aValueSize+VERSION_SIZE] = 0;
         kvpPtr->length = aValueSize + VERSION_SIZE;
-
     }
     // Add to frame vector
     OSCL_TRY(err, iFrames.push_back(kvpPtr););
@@ -2382,10 +2708,8 @@
     uint8 buff[ID3_MAX_STRING_FRAME_LEN];
     uint32 index = 0;
     uint16 endianCheck;
-
     if (read16(aInputFile, endianCheck) == false)
     {
-
         return PVMFFailure;
     }
 
@@ -2395,7 +2719,6 @@
     //some id3 tools does not add BOM with null strings.
     if (endianCheck != 0)
     {
-
         bomSz = UNICODE_BOM_SIZE;
         // This frame's text strings are Unicode and the frame
         // does include a BOM value. (UTF-16)
@@ -2407,10 +2730,9 @@
         {
             endianType = UNICODE_BIG_ENDIAN;
         }
-
         //read frame data from file
         bool more = true;
-        while (more && index < ID3_MAX_STRING_FRAME_LEN)
+        while (more && (index < ID3_MAX_STRING_FRAME_LEN))
         {
             if (read8(iInputFile, buff[index]) == false)
                 return PVMFFailure;
@@ -2438,10 +2760,10 @@
         index = 2;
     }
 
-    int32 err = 0;
-    oscl_wchar *tmpData = 0;
-    OSCL_TRY(err, tmpData = OSCL_ARRAY_NEW(oscl_wchar, index););
-    if (err != OsclErrNone || !tmpData)
+    int32 err = OsclErrNone;
+    oscl_wchar *tmpData = NULL;
+    tmpData = (oscl_wchar*) AllocateValueArray(err, PVMI_KVPVALTYPE_WCHARPTR, index);
+    if (OsclErrNone != err || !tmpData)
     {
         LOG_ERR((0, "PVID3ParCom::readNullTerminatedUnicodeString: Error - allocation failed"));
         return PVMFErrNoMemory;
@@ -2451,7 +2773,6 @@
     tmpData[wcSize] = 0;
     aData = tmpData;
     OSCL_ARRAY_DELETE(tmpData);
-
     return PVMFSuccess;
 }
 
@@ -2489,7 +2810,7 @@
     OSCL_HeapString<OsclMemAllocator> ImageFormat;
     bool pic_as_url = false;
     bool truncate = false;
-    int32 err = 0;
+    int32 err = OsclErrNone;
     PvmiKvpSharedPtr kvpPtr;
     OSCL_StackString<128> keyStr;
 
@@ -2499,7 +2820,6 @@
         return PVMFErrNotSupported;
     }
 
-
     switch (unicode)
     {
         case PV_ID3_CHARSET_ISO88591:
@@ -2527,16 +2847,18 @@
 
             // Allocate key-value pair
             OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_KSV, total_size, truncate););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 LOG_ERR((0, "PVID3ParCom::ReadAlbumArtFrame: Error - AllocateKvp failed. err=%d", err));
-                                 return PVMFFailure;
-                                );
+            if (OsclErrNone != err || !kvpPtr)
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadAlbumArtFrame: Error - AllocateKvp failed. err=%d", err));
+                return PVMFFailure;
+            }
 
             if (truncate)
             {
                 iInputFile->Seek(dataLen, Oscl_File::SEEKCUR);
                 kvpPtr->capacity = 0;
                 kvpPtr->length = 0;
+
                 OSCL_TRY(err, iFrames.push_back(kvpPtr););
                 OSCL_FIRST_CATCH_ANY(err,
                                      LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - iFrame.push_back failed"));
@@ -2575,22 +2897,24 @@
             keyStr += KVP_VALTYPE_ALBUMART;
 
             //image format is stored as wchar.
-            uint32 rfs = aFrameSize - (ImageFormat.get_size() - (2 * oscl_strlen(description.get_str())));
+            uint32 rfs = aFrameSize - (ImageFormat.get_size() + (2 * oscl_strlen(description.get_str())));
             uint32 wchar_size = sizeof(oscl_wchar); //for platforms that store wchar as 4 bytes.
             uint32 total_size = sizeof(PvmfApicStruct) + rfs + (wchar_size * (ImageFormat.get_size() + description.get_size())) + (2 * wchar_size);
 
             // Allocate key-value pair
             OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_KSV, total_size, truncate););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 LOG_ERR((0, "PVID3ParCom::ReadAlbumArtFrame: Error - AllocateKvp failed. err=%d", err));
-                                 return PVMFFailure;
-                                );
+            if (OsclErrNone != err || !kvpPtr)
+            {
+                LOG_ERR((0, "PVID3ParCom::ReadAlbumArtFrame: Error - AllocateKvp failed. err=%d", err));
+                return PVMFFailure;
+            }
 
             if (truncate)
             {
                 iInputFile->Seek(dataLen, Oscl_File::SEEKCUR);
                 kvpPtr->capacity = 0;
                 kvpPtr->length = 0;
+
                 OSCL_TRY(err, iFrames.push_back(kvpPtr););
                 OSCL_FIRST_CATCH_ANY(err,
                                      LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - iFrame.push_back failed"));
@@ -2606,8 +2930,7 @@
             //convert raw data to struct
             PVMFStatus status;
             status = ConvertUnicodeDataToApic(ImageFormat.get_str(), description.get_str(), picType,
-                                              dataLen , kvpPtr->value.key_specific_value, total_size) ;
-
+                                              dataLen , kvpPtr->value.key_specific_value, total_size);
         }
         break;
         default:
@@ -2622,15 +2945,17 @@
         bool truncate = false;
         // Allocate key-value pair
         OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_CHARPTR, dataLen, truncate););
-        OSCL_FIRST_CATCH_ANY(err,
-                             LOG_ERR((0, "PVID3ParCom::ReadAlbumArtFrame: Error - AllocateKvp failed. err=%d", err));
-                             return PVMFFailure;
-                            );
+        if (OsclErrNone != err || !kvpPtr)
+        {
+            LOG_ERR((0, "PVID3ParCom::ReadAlbumArtFrame: Error - AllocateKvp failed. err=%d", err));
+            return PVMFFailure;
+        }
 
         if (truncate)
         {
             iInputFile->Seek(dataLen, Oscl_File::SEEKCUR);
             kvpPtr->length = 0;
+
             OSCL_TRY(err, iFrames.push_back(kvpPtr););
             OSCL_FIRST_CATCH_ANY(err,
                                  LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - iFrame.push_back failed"));
@@ -2643,8 +2968,8 @@
         {
             if (readByteData(iInputFile, dataLen, (uint8 *)kvpPtr->value.pChar_value) == false)
                 return PVMFFailure;
-            kvpPtr->length = dataLen;
             kvpPtr->value.pChar_value[dataLen] = NULL_TERM_CHAR;
+            kvpPtr->length = dataLen;
         }
     }
     else
@@ -2652,7 +2977,6 @@
         aApicStruct = OSCL_STATIC_CAST(PvmfApicStruct *, kvpPtr->value.key_specific_value);
         if (readByteData(iInputFile, dataLen, aApicStruct->iGraphicData) == false)
             return PVMFFailure;
-        aApicStruct->iGraphicData[dataLen] = NULL_TERM_CHAR;
     }
 
 
@@ -2675,7 +2999,7 @@
         return PVMFFailure;
     }
 
-    iID3TagInfo.iID3V2LanguageID[3] = 0;
+    iID3TagInfo.iID3V2LanguageID[ID3V2_LANGUAGE_SIZE] = 0;
 
     //subtract 3 bytes of language from the frame size.
     framesize = aFramesize - ID3V2_LANGUAGE_SIZE ;
@@ -2691,25 +3015,26 @@
         return PVMFErrNotSupported;
     }
 
-    int32 err = 0;
+    int32 err = OsclErrNone;
     PvmiKvpSharedPtr kvpPtr;
     uint32 wchar_size = sizeof(oscl_wchar); //for platforms where wchar is 4 bytes.
     uint32 total_size = (wchar_size * framesize) + sizeof(PvmfLyricsCommStruct) + (2 * wchar_size) ;
     uint32 used_size = 0;
     // Allocate key-value pair
     OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_KSV, total_size , truncate););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - AllocateKvp failed. err=%d", err));
-                         return PVMFFailure;
-                        );
+    if (OsclErrNone != err || !kvpPtr)
+    {
+        LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - AllocateKvp failed. err=%d", err));
+        return PVMFFailure;
+    }
 
     if (truncate)
     {
         iInputFile->Seek(framesize, Oscl_File::SEEKCUR);
         kvpPtr->capacity = 0;
         kvpPtr->length = 0;
-        OSCL_TRY(err, iFrames.push_back(kvpPtr););
 
+        OSCL_TRY(err, iFrames.push_back(kvpPtr););
         OSCL_FIRST_CATCH_ANY(err,
                              LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - iFrame.push_back failed"));
                              return PVMFErrNoMemory;);
@@ -2718,8 +3043,15 @@
 
     }
 
-    PvmfLyricsCommStruct *lcStruct = OSCL_STATIC_CAST(PvmfLyricsCommStruct *, kvpPtr->value.key_specific_value);
-    uint8 *ptr = (uint8 *)kvpPtr->value.key_specific_value;
+    PvmfLyricsCommStruct *lcStruct = NULL;
+    uint8 *ptr = NULL;
+    lcStruct = OSCL_STATIC_CAST(PvmfLyricsCommStruct *, kvpPtr->value.key_specific_value);
+    ptr = (uint8 *)kvpPtr->value.key_specific_value;
+    if (!ptr)
+    {
+        return PVMFFailure;
+    }
+
     ptr += sizeof(PvmfLyricsCommStruct);
     used_size += sizeof(PvmfLyricsCommStruct);
 
@@ -2767,7 +3099,7 @@
             uint32 datasz = framesize + 1;
             OSCL_TRY(err, data = (uint8*)iAlloc.allocate(datasz););
 
-            if (err != OsclErrNone || !(data))
+            if (OsclErrNone != err || !(data))
             {
                 LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - allocation failed"));
                 iInputFile->Seek(framesize, Oscl_File::SEEKCUR);
@@ -2785,6 +3117,7 @@
 
                 lcStruct->iData = OSCL_STATIC_CAST(oscl_wchar *, ptr);
                 used_size += datasz;
+
                 if (used_size > total_size)
                     return PVMFErrOverflow;
                 oscl_UTF8ToUnicode((const char *)data, framesize, lcStruct->iData,  datasz);
@@ -2819,6 +3152,7 @@
 
             lcStruct->iDescription = OSCL_STATIC_CAST(oscl_wchar *, ptr);
             ptr += wchar_size * (desc_len + 1); //1 for null char
+
             used_size += wchar_size * (desc_len + 1);
             if (used_size > total_size)
                 return PVMFErrOverflow;
@@ -2866,9 +3200,9 @@
 
             uint8 *data = NULL;
             uint32 datasz = framesize + 2;
-            int32 err = 0;
+            int32 err = OsclErrNone;
             OSCL_TRY(err, data = (uint8*)iAlloc.allocate(datasz););
-            if (err != OsclErrNone || !(data))
+            if (OsclErrNone != err || !(data))
             {
                 LOG_ERR((0, "PVID3ParCom::ReadLyricsCommFrame: Error - allocation failed"));
                 truncate = true;
@@ -2877,17 +3211,17 @@
             {
 
                 oscl_memset(data, 0, datasz);
-
                 if ((readByteData(iInputFile, framesize, data) == false))
                 {
                     iAlloc.deallocate(data);
                     return PVMFFailure;
                 }
-
                 lcStruct->iData = OSCL_STATIC_CAST(oscl_wchar *, ptr);
+
                 used_size += wchar_size * (framesize / 2);  //UCS-2 unicode
                 if (used_size > total_size)
                     return PVMFErrOverflow;
+
                 uint32 sz = EightBitToWideCharBufferTransfer(data, framesize, endianType , lcStruct->iData);
                 lcStruct->iData[sz] = 0;
 
@@ -3174,7 +3508,7 @@
 
 
 ////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVID3ParCom::ReadTrackLengthFrame(uint32 aValueSize)
+PVMFStatus PVID3ParCom::ReadTrackLengthFrame(uint32 aValueSize, PVID3CharacterSet aCharSet)
 {
     OSCL_StackString<128> keyStr;
     if (ConstructKvpKey(keyStr, PV_ID3_FRAME_TRACK_LENGTH, PV_ID3_CHARSET_INVALID) != PVMFSuccess)
@@ -3183,10 +3517,10 @@
         return PVMFErrNotSupported;
     }
 
-    int32 err = 0;
+    int32 err = OsclErrNone;
     uint8* ptrFrameData = NULL;
-    OSCL_TRY(err, ptrFrameData = (uint8*)iAlloc.ALLOCATE(aValueSize + 1););
-    if (err != OsclErrNone || !ptrFrameData)
+    ptrFrameData = (uint8*) AllocateValueArray(err, PVMI_KVPVALTYPE_UINT8PTR, aValueSize + 2, &iAlloc);
+    if (OsclErrNone != err || !ptrFrameData)
     {
         LOG_ERR((0, "PVID3ParCom::ReadTrackLengthFrame: Error - ptrFrameData allocation failed"));
         return PVMFErrNoMemory;
@@ -3199,12 +3533,34 @@
         return PVMFFailure;
     }
     ptrFrameData[aValueSize] = 0;
+    ptrFrameData[aValueSize+1] = 0;
+
+    switch (aCharSet)
+    {
+        case PV_ID3_CHARSET_UTF16:
+        case PV_ID3_CHARSET_UTF16BE:
+        {
+            char* tmpData = NULL;
+            tmpData = (char*) AllocateValueArray(err, PVMI_KVPVALTYPE_CHARPTR, aValueSize / sizeof(oscl_wchar) + 1, &iAlloc);
+
+            oscl_UnicodeToUTF8((oscl_wchar*)ptrFrameData, aValueSize / sizeof(oscl_wchar), tmpData, aValueSize);
+            // copy the UTF8 string back to ptrFrameData
+            oscl_strncpy((char*)ptrFrameData, tmpData, oscl_strlen((const oscl_wchar*)ptrFrameData) + 1);
+
+            iAlloc.deallocate((OsclAny*)tmpData);
+        }
+        break;
+        case PV_ID3_CHARSET_ISO88591:
+        case PV_ID3_CHARSET_UTF8:
+            break;
+        default:
+            return PVMFFailure;
+    }
 
     // The ID3 Track Length is a numeric string in milliseconds.
     uint32 duration = 0;
     int32 numericStringLen = oscl_strlen((const char*)ptrFrameData);
 
-    uint8* ptr = ptrFrameData;
     if (!PV_atoi((const char *)ptrFrameData, 'd', numericStringLen, duration))
     {
         uint8* ptr = ptrFrameData;
@@ -3213,10 +3569,10 @@
         {
             // if the charater read is a digit or decimal point
             // then truncate it to integer value
-            if (!((*ptr >= ZERO_CHARACTER_ASCII_VALUE) &&
+            if (!(((*ptr >= ZERO_CHARACTER_ASCII_VALUE) &&
                     (*ptr <= NINE_CHARACTER_ASCII_VALUE)) ||
                     (*ptr == PERIOD_CHARACTER_ASCII_VALUE) ||
-                    (*ptr == COMMA_CHARACTER_ASCII_VALUE))
+                    (*ptr == COMMA_CHARACTER_ASCII_VALUE)))
             {
                 invalid_frame = true;
                 break;
@@ -3241,19 +3597,17 @@
             return PVMFSuccess;
         }
     }
-    else
-    {
-        numericStringLen = aValueSize;
-    }
 
     // Allocate key-value pair
     bool truncate = false;
     PvmiKvpSharedPtr kvpPtr;
-    OSCL_TRY(err, kvpPtr = AllocateKvp(keyStr, PVMI_KVPVALTYPE_UINT32, 0, truncate););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVID3ParCom::ReadTrackLengthFrame: Error - AllocateKvp failed. err=%d", err));
-                         return PVMFFailure;
-                        );
+    PVMFStatus status = PVMFSuccess;
+    kvpPtr = HandleErrorForKVPAllocation(keyStr, PVMI_KVPVALTYPE_UINT32, 1, truncate, status);
+    if (PVMFSuccess != status || !kvpPtr)
+    {
+        iAlloc.deallocate((OsclAny*)ptrFrameData);
+        return PVMFErrNoMemory;
+    }
 
     kvpPtr->value.uint32_value = duration; // Track length in milliseconds
     kvpPtr->length = numericStringLen;
@@ -3282,12 +3636,12 @@
     {
         case PVMI_KVPVALTYPE_CHARPTR:
             aCharSet = PV_ID3_CHARSET_ISO88591;
-            if (pv_mime_string_parse_param(aKvp->key, KVP_PARAM_CHAR_ENCODING_UTF8, param) > 0)
+            if (pv_mime_string_parse_param(aKvp->key, (char*) KVP_PARAM_CHAR_ENCODING_UTF8, param) > 0)
                 aCharSet = PV_ID3_CHARSET_UTF8;
             break;
         case PVMI_KVPVALTYPE_WCHARPTR:
             aCharSet = PV_ID3_CHARSET_UTF16;
-            if (pv_mime_string_parse_param(aKvp->key, KVP_PARAM_CHAR_ENCODING_UTF16BE, param) > 0)
+            if (pv_mime_string_parse_param(aKvp->key, (char*) KVP_PARAM_CHAR_ENCODING_UTF16BE, param) > 0)
                 aCharSet = PV_ID3_CHARSET_UTF16BE;
             break;
         case PVMI_KVPVALTYPE_KSV:
@@ -3791,3 +4145,165 @@
     return PVMFSuccess;
 }
 
+////////////////////////////////////////////////////////////////////////////
+PVID3ParCom::PVID3FrameType PVID3ParCom::FrameValidatedID3V2_4(uint8* aFrameID)
+{
+    PVID3FrameType ID3V2FrameTypeReturnValue;
+
+    if ((oscl_memcmp(aFrameID, ID3_FRAME_ID_ENCRYPTION, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_AUDIO_SEEK_POINT_INDEX, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_COMMERCIAL_FRAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ENCRYPTION_REGISTRATION, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_EQUALIZATION2, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_EVENT_TIMING_CODES, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_GENERAL_ENCAPSULATED_OBJECT, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_GROUP_IDENTITY_REGISTRATION, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_LINKED_INFORMATION, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_MUSIC_CD_IDENTIFIER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_MPEG_LOCATION_LOOKUP_TABLE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_OWNERSHIP_FRAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PRIVATE_FRAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PLAY_COUNTER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_POPULARIMETER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_POSITION_SYNCH_FRAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_RECOMMENDED_BUFFER_SIZE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_RELATIVE_VOLUME_ADJUSTMENT2, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_REVERB, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_SYNCHRONIZED_LYRICS_TEXT, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_SYNCHRONIZED_TEMPO_CODES, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_BPM, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PLAYLIST_DELAY, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_FILE_TYPE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_CONTENT_GROUP_DESC, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_INITIAL_KEY, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_LANGUAGE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_MEDIA_TYPE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ORIGINAL_ALBUM, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ORIGINAL_FILENAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ORIGINAL_LYRICIST, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ORIGINAL_ARTIST, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_FILE_LICENSEE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_BAND, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_CONDUCTOR, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_MODIFIER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PART_OF_SET, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PUBLISHER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_INTERNET_RADIO_STATION_NAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_INTERNET_RADIO_STATION_OWNER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_RECORDING_CODE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_SOFTWARE_SETTING_ENCODE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_UNIQUE_FILE_IDENTIFIER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_TERMS_OF_USE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_COMMERCIAL_INFO, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_LEGAL_INFO, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_OFFICIAL_AUDIO_FILE_WEBPAGE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_OFFICIAL_ARTIST_WEBPAGE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_OFFICIAL_AUDIO__SOURCE_WEBPAGE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_OFFICIAL_RADIO_STATION_WEBPAGE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PAYMENT, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PUBLISHER_OFFICIAL_WEBPAGE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_USER_DEFINED_URL_LINK_FRAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_SIGNATURE_FRAME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ENCODING_TIME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ORIGINAL_RELEASE_TIME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_RELEASE_TIME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_TAGGING_TIME, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_INVOLVED_PEOPLE_LIST, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_MUSICIAN_CREDITS_LIST, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_MOOD, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PRODUCED_NOTICE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_ALBUM_SORT_ORDER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_PERFORMER_SORT_ORDER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_TITLE_SORT_ORDER, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_SET_SUBTITLE, ID3V2_FRAME_NUM_BYTES_ID) == 0) ||
+            (oscl_memcmp(aFrameID, ID3_FRAME_ID_USER_DEFINED_TEXT_INFO, ID3V2_FRAME_NUM_BYTES_ID) == 0)
+       )
+    {
+        ID3V2FrameTypeReturnValue = PV_ID3_FRAME_UNRECOGNIZED;
+    }
+    // The frame ID made out of the characters capital A-Z and 0-9.
+    else if (IS_POTENTIAL_FRAME_ID(aFrameID))
+    {
+        ID3V2FrameTypeReturnValue = PV_ID3_FRAME_CANDIDATE;
+    }
+    else
+    {
+        // Frame ID doesn't match with defined/possible frame Ids
+        ID3V2FrameTypeReturnValue = PV_ID3_FRAME_INVALID;
+    }
+    return ID3V2FrameTypeReturnValue;
+}
+
+PVMFStatus PVID3ParCom::PushFrameToFrameVector(PvmiKvpSharedPtr& aFrame, PvmiKvpSharedPtrVector& aFrameVector)
+{
+    int32 err = OsclErrNone;
+    OSCL_TRY(err, aFrameVector.push_back(aFrame););
+    OSCL_FIRST_CATCH_ANY(err,
+                         LOG_ERR((0, "PVID3ParCom::GetID3Frame: Error - aFrame.push_back failed"));
+                         return PVMFErrNoMemory;);
+    return PVMFSuccess;
+}
+
+OsclAny* PVID3ParCom::AllocateValueArray(int32& aLeaveCode, PvmiKvpValueType aValueType, int32 aNumElements, OsclMemAllocator* aMemAllocator)
+{
+    int32 leaveCode = OsclErrNone;
+    OsclAny* buffer = NULL;
+    switch (aValueType)
+    {
+        case PVMI_KVPVALTYPE_WCHARPTR:
+            if (aMemAllocator)
+            {
+                OSCL_TRY(leaveCode,
+                         buffer = (oscl_wchar*) aMemAllocator->ALLOCATE(aNumElements););
+            }
+            else
+            {
+                OSCL_TRY(leaveCode,
+                         buffer = (oscl_wchar*) OSCL_ARRAY_NEW(oscl_wchar, aNumElements););
+            }
+            break;
+
+        case PVMI_KVPVALTYPE_CHARPTR:
+            if (aMemAllocator)
+            {
+                OSCL_TRY(leaveCode,
+                         buffer = (char*) aMemAllocator->ALLOCATE(aNumElements););
+            }
+            else
+            {
+                OSCL_TRY(leaveCode,
+                         buffer = (char*) OSCL_ARRAY_NEW(char, aNumElements););
+            }
+            break;
+        case PVMI_KVPVALTYPE_UINT8PTR:
+            if (aMemAllocator)
+            {
+                OSCL_TRY(leaveCode,
+                         buffer = (uint8*) aMemAllocator->ALLOCATE(aNumElements););
+            }
+            else
+            {
+                OSCL_TRY(leaveCode,
+                         buffer = (uint8*) OSCL_ARRAY_NEW(char, aNumElements););
+            }
+            break;
+        default:
+            break;
+    }
+    aLeaveCode = leaveCode;
+    return buffer;
+}
+
+PvmiKvpSharedPtr PVID3ParCom::HandleErrorForKVPAllocation(OSCL_String& aKey, PvmiKvpValueType aValueType, uint32 aValueSize, bool &truncate, PVMFStatus &aStatus)
+{
+    PvmiKvpSharedPtr kvp;
+    int32 err = OsclErrNone;
+    aStatus = PVMFSuccess;
+    OSCL_TRY(err, kvp = AllocateKvp(aKey, aValueType, aValueSize, truncate););
+    if (OsclErrNone != err)
+    {
+        LOG_ERR((0, "PVID3ParCom::SetID3Frame: Error - AllocateKvp failed"));
+        aStatus = PVMFErrNoMemory;
+    }
+    return kvp;
+}
diff --git a/fileformats/mp3/parser/Android.mk b/fileformats/mp3/parser/Android.mk
index 0e33b41..58ebe7e 100644
--- a/fileformats/mp3/parser/Android.mk
+++ b/fileformats/mp3/parser/Android.mk
@@ -2,31 +2,33 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/\
 	src/imp3ff.cpp \
-	src/mp3fileio.cpp \
-	src/mp3parser.cpp \
-	src/mp3utils.cpp
-
+ 	src/mp3fileio.cpp \
+ 	src/mp3parser.cpp \
+ 	src/mp3utils.cpp
 
 
 LOCAL_MODULE := libpvmp3ff
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/mp3/parser/include \
-	$(PV_TOP)//fileformats/mp3/parser/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/mp3/parser/src \
+ 	$(PV_TOP)/fileformats/mp3/parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/imp3ff.h \
-	include/mp3fileio.h \
-	include/mp3parser.h \
-	include/mp3utils.h
+ 	include/mp3fileio.h \
+ 	include/mp3parser.h \
+ 	include/mp3utils.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/mp3/parser/build/make/local.mk b/fileformats/mp3/parser/build/make/local.mk
new file mode 100644
index 0000000..5a3567e
--- /dev/null
+++ b/fileformats/mp3/parser/build/make/local.mk
@@ -0,0 +1,33 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp3ff
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := \
+	imp3ff.cpp \
+	mp3fileio.cpp \
+	mp3parser.cpp \
+	mp3utils.cpp 
+
+HDRS := \
+	imp3ff.h \
+	mp3fileio.h \
+	mp3parser.h \
+	mp3utils.h
+
+
+include $(MK)/library.mk
diff --git a/fileformats/mp3/parser/build/make/makefile b/fileformats/mp3/parser/build/make/makefile
deleted file mode 100755
index 1077f62..0000000
--- a/fileformats/mp3/parser/build/make/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp3ff
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	\
-	imp3ff.cpp \
-	mp3fileio.cpp \
-	mp3parser.cpp \
-	mp3utils.cpp 
-
-HDRS =	\
-	imp3ff.h \
-	mp3fileio.h \
-	mp3parser.h \
-	mp3utils.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/fileformats/mp3/parser/include/imp3ff.h b/fileformats/mp3/parser/include/imp3ff.h
index 71b14b8..8034b76 100644
--- a/fileformats/mp3/parser/include/imp3ff.h
+++ b/fileformats/mp3/parser/include/imp3ff.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,9 +78,6 @@
 #ifndef PVMF_META_DATA_H_INCLUDED
 #include "pvmf_meta_data_types.h"
 #endif
-#ifndef AUDIOMETADATA_H_INCLUDED
-#include "audiometadata.h"
-#endif
 #ifndef PVMI_KVP_INCLUDED
 #include "pvmi_kvp.h"
 #endif
@@ -100,10 +97,19 @@
     uint32 FrameSize;
     uint32 FileSizeInBytes;
     uint32 FrameSizeUnComp;
+    uint32 ChannelMode;  //0: Stereo 1: Joint Ch. Stereo 2: Dual  Ch. Stereo 3: Mono
 } MP3ContentFormatType;
 
 typedef enum
 {
+    MP3_CHANNEL_MODE_STEREO = 0,
+    MP3_CHANNEL_MODE_JOINT_CHANNEL_STEREO = 1,
+    MP3_CHANNEL_MODE_DUAL_CHANNEL_STEREO = 2,
+    MP3_CHANNEL_MODE_MONO = 3
+}MP3ChannelMode;
+
+typedef enum
+{
     MP3_ERROR_UNKNOWN = 0,
     MP3_SUCCESS,
     MP3_END_OF_FILE,
@@ -113,6 +119,7 @@
     MP3_FILE_HDR_DECODE_ERR,
     MP3_FILE_XING_HDR_ERR,
     MP3_FILE_VBRI_HDR_ERR,
+    MP3_ERR_NO_MEMORY,
     MP3_NO_SYNC_FOUND,
     MP3_FILE_OPEN_ERR,
     /* PD related Error values*/
@@ -285,6 +292,14 @@
         OSCL_IMPORT_REF uint32 GetDuration() const;
 
         /**
+        * @brief Returns the approximate duration of downloaded data.
+        *
+        * @param aFileSize, aNPTInMS
+        * @returns aNPTInMS
+        */
+        OSCL_IMPORT_REF int32 ConvertSizeToTime(uint32 aFileSize, uint32& aNPTInMS) const;
+
+        /**
         * @brief Returns the number of frames in the clip.
         *
         * @param None
@@ -385,7 +400,7 @@
         * @param reference to metadatasize
         * @returns error type.
         */
-        OSCL_IMPORT_REF MP3ErrorType GetMetadataSize(int32& aMetaDataSize);
+        OSCL_IMPORT_REF MP3ErrorType GetMetadataSize(uint32& aMetaDataSize);
 
         /**
         * @brief Retrieves minimum bytes required for getting the config info
@@ -393,7 +408,7 @@
         * @param
         * @returns byte size of firstframe and id3 tags.
         */
-        OSCL_IMPORT_REF uint32 GetMinBytesRequired();
+        OSCL_IMPORT_REF uint32 GetMinBytesRequired(bool aNextBytes = false);
 
         /**
         * @brief Sets the file size to the parser
@@ -417,6 +432,11 @@
         OSCL_EXPORT_REF MP3ErrorType ScanMP3File(uint32 aFramesToScan);
 
     private:
+        OsclAny* AllocateKVPKeyArray(int32& leavecode, PvmiKvpValueType aValueType, int32 aNumElements);
+        int32 PushKVPValue(PvmiKvp aKVP, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList);
+        int32 PushKVPKey(const char* aString, PVMFMetadataList& aKeyList);
+        int32 PushKVPKey(OSCL_HeapString<OsclMemAllocator>& aString, Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator>& aKeyList);
+
         MP3Parser* pMP3Parser;
         PVFile iMP3File;
         bool iEnableCrcCalc;
diff --git a/fileformats/mp3/parser/include/mp3fileio.h b/fileformats/mp3/parser/include/mp3fileio.h
index 270c97e..6a5723d 100644
--- a/fileformats/mp3/parser/include/mp3fileio.h
+++ b/fileformats/mp3/parser/include/mp3fileio.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp3/parser/include/mp3parser.h b/fileformats/mp3/parser/include/mp3parser.h
index 1b71d60..cbf5737 100644
--- a/fileformats/mp3/parser/include/mp3parser.h
+++ b/fileformats/mp3/parser/include/mp3parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -64,7 +64,9 @@
 #ifndef __MEDIA_CLOCK_CONVERTER_H
 #include "media_clock_converter.h"
 #endif
-
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
 
 //----------------------------------------------------------------------
 // Global Type Declarations
@@ -97,7 +99,7 @@
 #define DEFAULT_NUM_FRAMES_TO_SCAN 20
 #define ID3_V1_TAG_SIZE 128
 
-
+#define MAX_TOC_ENTRY_COUNT 200
 
 typedef struct mp3Header_tag
 {
@@ -296,7 +298,16 @@
         * @param pMP3COnfig Data structure that will contain the header
         * @returns True if successful; False otherwise
         */
-        bool    GetMP3FileHeader(MP3ConfigInfoType * pMP3COnfig);
+        bool GetMP3FileHeader(MP3ConfigInfoType * pMP3COnfig);
+
+        /**
+        * @brief Retreives and returns channel mode for the current
+        * of mp3 file
+        *
+        * @param
+        * @returns
+        */
+        uint32 GetChannelMode() const;
 
         /**
         * @brief Returns the content of decoder specific info.
@@ -347,12 +358,20 @@
         uint32  GetDuration(bool aMetadataDuration = false);
 
         /**
+        * @brief Returns the approximate duration of downloaded data.
+        *
+        * @param aFileSize, aNPTInMS
+        * @returns aNPTInMS
+        */
+        int32 ConvertSizeToTime(uint32 aFileSize, uint32& aNPTInMS);
+
+        /**
         * @brief outputs the size of id3v2 tags
         *
         * @param aSize, carries the tag size
         * @returns success if meta data is parsed, failure otherwise
         */
-        MP3ErrorType GetMetadataSize(int32 &aSize);
+        MP3ErrorType GetMetadataSize(uint32 &aSize);
 
         /**
         * @brief Retrieves minimum bytes required for getting the config info
@@ -360,7 +379,7 @@
         * @param
         * @returns byte size of firstframe and id3 tags.
         */
-        uint32 GetMinBytesRequired();
+        uint32 GetMinBytesRequired(bool aNextBytes = false);
 
         /**
         * @brief Copies the metadata to the structure specified.
@@ -396,6 +415,8 @@
 
         uint32 GetDurationFromMetadata();
 
+        void FillTOCTable(uint32 aFilePos, uint32 aTimeStampToFrame);
+
         //duration related values
         uint32 iClipDurationInMsec;
         uint32 iClipDurationFromEstimation;
@@ -405,53 +426,48 @@
         uint32 iClipDurationFromMetadata;
         bool iDurationScanComplete;
         uint32 iTimestamp;
-        uint32 iAvgBitrateInbpsFromRandomScan;
-        uint32 iAvgBitrateInbps;
-        uint32 iAvgBitrateInbpsFromCompleteScan;
-
+        int32 iAvgBitrateInbpsFromRandomScan;
+        int32 iAvgBitrateInbps;
+        int32 iAvgBitrateInbpsFromCompleteScan;
 
 
     protected:
-        int32 iLocalFileSize;
-        int32 iFileSizeFromExternalSource;
+        uint32 iLocalFileSize;
+        uint32 iFileSizeFromExternalSource;
+        uint32 iInitSearchFileSize;
         bool iLocalFileSizeSet;
-        int32 iInitSearchFileSize;
         PVFile * fp;
         MediaClockConverter iClockConverter;
         bool iFirstScan;
         uint32 iLastScanPosition;
         bool iScanEnable;
-    public:
-        /*scan file related */
-        int32 currentFilePosn; // current file position
-        uint32 firstHeader;
-        uint8 pFrameHeader[4];
-        int32 startOffset;
-        uint32 seekOffset;
-        MP3HeaderType mp3HeaderInfo;
-        MP3ConfigInfoType mp3ConfigInfo;
-        uint32 frameCount;
-
-#ifdef PROFILING_ENABLED
-        uint32 starttick;
-        uint32 endtick;
-        uint32 totaltick;
-        FILE* outFile;
-#endif
 
     private:
         MP3ErrorType IsValidFrame(uint8 * pBuffer, uint32 offset, uint32 seekPoint, PVFile* aFile = NULL);
         MP3ErrorType IsValidFrameHeader(uint8 * mp3FrameHeader, bool &bCRCPresent, uint32 offset, uint32 seekPoint, PVFile* aFile = NULL);
         bool  IsValidFrameCRC(uint8 *pFrame, int32 size, uint32 crcValue);
 
-        bool  GetMP3Header(uint32 &fh, MP3HeaderType &hi);
+        bool GetMP3Header(uint32 &fh, MP3HeaderType &hi);
         bool DecodeMP3Header(MP3HeaderType &aHeaderInfoType, MP3ConfigInfoType &aConfigInfoType, bool aComputeAvgBitrate);
         bool DecodeXINGHeader(uint8 *XingBuffer, XINGHeaderType &mp3XingHI, MP3HeaderType &hi);
-        bool  DecodeVBRIHeader(uint8 * VbriBuffer, VBRIHeaderType &vbriHDI, MP3HeaderType &hi);
+        bool DecodeVBRIHeader(uint8 * VbriBuffer, VBRIHeaderType &vbriHDI, MP3HeaderType &hi);
         MP3ErrorType mp3FindSync(uint32 seekPoint, uint32 &syncOffset, PVFile* aFile = NULL);
         uint16 CalcCRC16(uint8* pBuffer, uint32 dwBitSize);
         MP3ErrorType mp3VerifyCRC(MP3HeaderType mp3HdrInfo, MP3ConfigInfoType mp3CI);
 
+
+        /* scan file related */
+        uint32 iScannedFrameCount;
+        /* toc related */
+        int32* iTOC;
+        uint32 iTOCFilledCount;
+        uint32 iTimestampPrev;
+        uint32 iScanTimestamp;
+        uint32 iBinWidth;
+
+        uint32 iSamplingRate;
+        uint32 iSamplesPerFrame;
+
         int32 CalculateBufferSizeForHeader(uint8 *VbriHead);
         int32 iCurrFrameNumber;
         int32 iNumberOfFrames;
@@ -463,7 +479,6 @@
         uint8 * pSyncBuffer;
         uint32 iMaxSyncBufferSize;
 
-
         MP3ConfigInfoType  iMP3ConfigInfo;
         MP3HeaderType      iMP3HeaderInfo;
         XINGHeaderType     iXingHeader;
diff --git a/fileformats/mp3/parser/include/mp3utils.h b/fileformats/mp3/parser/include/mp3utils.h
index a4aa2cb..df9c7cc 100644
--- a/fileformats/mp3/parser/include/mp3utils.h
+++ b/fileformats/mp3/parser/include/mp3utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp3/parser/src/imp3ff.cpp b/fileformats/mp3/parser/src/imp3ff.cpp
index 7ac8df8..9859f93 100644
--- a/fileformats/mp3/parser/src/imp3ff.cpp
+++ b/fileformats/mp3/parser/src/imp3ff.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,10 +59,13 @@
 static const char PVMP3METADATA_TRACKINFO_SAMPLERATE_KEY[] = "track-info/sample-rate";
 static const char PVMP3METADATA_TRACKINFO_AUDIO_FORMAT_KEY[] = "track-info/audio/format";
 static const char PVMP3METADATA_TRACKINFO_AUDIO_CHANNELS_KEY[] = "track-info/audio/channels";
+static const char PVMP3METADATA_TRACKINFO_AUDIO_CHANNEL_MODE_KEY[] = "track-info/audio/channel-mode";
 static const char PVMP3METADATA_BITRATE_KEY[] = "bit-rate";
 static const char PVMP3METADATA_SAMPLERATE_KEY[] = "sample-rate";
 static const char PVMP3METADATA_FORMAT_KEY[] = "format";
 static const char PVMP3METADATA_CHANNELS_KEY[] = "channels";
+static const char PVMP3METADATA_CHANNEL_MODE_KEY[] = "channel-mode";
+static const char PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY[] = "random-access-denied";
 static const char PVMP3METADATA_SEMICOLON[] = ";";
 static const char PVMP3METADATA_CHARENCUTF8[] = "char-encoding=UTF8";
 static const char PVMP3METADATA_CHARENCUTF16BE[] = "char-encoding=UTF16BE";
@@ -73,7 +76,6 @@
 static const char PVMP3METADATA_UNKNOWN[] = "unknown";
 static const char PVMP3METADATA_COMPUTE[] = "compute=true";
 
-
 // Use default DLL entry point for Symbian
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
@@ -129,9 +131,9 @@
         }
     }
 
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     OSCL_TRY(leavecode, pMP3Parser = OSCL_NEW(MP3Parser, (&iMP3File)););
-    if (pMP3Parser && leavecode == 0)
+    if (pMP3Parser && OsclErrNone == leavecode)
         bSuccess = MP3_SUCCESS;
     else
         bSuccess = MP3_ERROR_UNKNOWN;
@@ -139,9 +141,9 @@
 
 OSCL_EXPORT_REF IMpeg3File::IMpeg3File(MP3ErrorType &bSuccess): pMP3Parser(NULL)
 {
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     OSCL_TRY(leavecode, pMP3Parser = OSCL_NEW(MP3Parser, ()););
-    if (pMP3Parser && leavecode == 0)
+    if (pMP3Parser && OsclErrNone == leavecode)
         bSuccess = MP3_SUCCESS;
     else
         bSuccess = MP3_ERROR_UNKNOWN;
@@ -194,49 +196,97 @@
         pMP3Parser->GetMetaData(id3Frames);
 
         // Populate metadata key list vector
-        int32 leavecode = 0;
+        int32 leavecode = OsclErrNone;
         for (uint32 p = 0;p < id3Frames.size();p++)
         {
             OSCL_HeapString<OsclMemAllocator> keystr((const char *)((*id3Frames[p]).key), oscl_strlen((const char *)((*id3Frames[p]).key)));
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(keystr));
+            leavecode = PushKVPKey(keystr, iAvailableMetadataKeys);
+            if (OsclErrNone != leavecode)
+            {
+                return MP3_ERR_NO_MEMORY;
+            }
+
         }
 
         bool metadataDuration = true;
         if (pMP3Parser->GetDuration(metadataDuration) > 0)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_DURATION_FROM_METADATA_KEY));
+            leavecode = OsclErrNone;
+            leavecode = PushKVPKey(PVMP3METADATA_DURATION_FROM_METADATA_KEY, iAvailableMetadataKeys);
+            if (OsclErrNone != leavecode)
+            {
+                return MP3_ERR_NO_MEMORY;
+            }
         }
 
         // Following keys are available when the MP3 file has been parsed
-        if (pMP3Parser->GetDuration() >= 0)
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVMP3METADATA_DURATION_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_DURATION_KEY));
+            return MP3_ERR_NO_MEMORY;
         }
 
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_NUMTRACKS_KEY));
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_TRACKINFO_AUDIO_FORMAT_KEY));
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
+        {
+            return MP3_ERR_NO_MEMORY;
+        }
+
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVMP3METADATA_NUMTRACKS_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
+        {
+            return MP3_ERR_NO_MEMORY;
+        }
+
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVMP3METADATA_TRACKINFO_AUDIO_FORMAT_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
+        {
+            return MP3_ERR_NO_MEMORY;
+        }
 
         MP3ContentFormatType mp3info;
         if (GetConfigDetails(mp3info) == MP3_SUCCESS)
         {
             if (mp3info.Bitrate > 0)
             {
-                leavecode = 0;
-                OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_TRACKINFO_BITRATE_KEY));
+                leavecode = OsclErrNone;
+                leavecode = PushKVPKey(PVMP3METADATA_TRACKINFO_BITRATE_KEY, iAvailableMetadataKeys);
+                if (OsclErrNone != leavecode)
+                {
+                    return MP3_ERR_NO_MEMORY;
+                }
             }
             if (mp3info.SamplingRate > 0)
             {
-                leavecode = 0;
-                OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_TRACKINFO_SAMPLERATE_KEY));
+                leavecode = OsclErrNone;
+                leavecode = PushKVPKey(PVMP3METADATA_TRACKINFO_SAMPLERATE_KEY, iAvailableMetadataKeys);
+                if (OsclErrNone != leavecode)
+                {
+                    return MP3_ERR_NO_MEMORY;
+                }
             }
             if (mp3info.NumberOfChannels > 0)
             {
+                leavecode = OsclErrNone;
+                leavecode = PushKVPKey(PVMP3METADATA_TRACKINFO_AUDIO_CHANNELS_KEY, iAvailableMetadataKeys);
+                if (OsclErrNone != leavecode)
+                {
+                    return MP3_ERR_NO_MEMORY;
+                }
+            }
+            // valid channel mode is present
+            if (mp3info.ChannelMode <= MP3_CHANNEL_MODE_MONO)
+            {
                 leavecode = 0;
-                OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMP3METADATA_TRACKINFO_AUDIO_CHANNELS_KEY));
+                leavecode = PushKVPKey(PVMP3METADATA_CHANNEL_MODE_KEY, iAvailableMetadataKeys);
+                if (OsclErrNone != leavecode)
+                {
+                    return MP3_ERR_NO_MEMORY;
+                }
             }
         }
     }
@@ -256,6 +306,7 @@
             mp3Config.SamplingRate     = mp3ConfigHdr.SamplingRate;
             mp3Config.FrameSizeUnComp  = mp3ConfigHdr.FrameSizeUnComp;
             mp3Config.FileSizeInBytes  = pMP3Parser->GetFileSize();
+            mp3Config.ChannelMode      = pMP3Parser->GetChannelMode();
             return MP3_SUCCESS;
         }
     }
@@ -327,7 +378,18 @@
     }
 }
 
-OSCL_EXPORT_REF MP3ErrorType IMpeg3File::GetMetadataSize(int32 &aSize)
+OSCL_EXPORT_REF int32 IMpeg3File::ConvertSizeToTime(uint32 aFileSize, uint32& aNPTInMS) const
+{
+    if (pMP3Parser != NULL)
+    {
+        return pMP3Parser->ConvertSizeToTime(aFileSize, aNPTInMS);
+    }
+    else
+    {
+        return -1;
+    }
+}
+OSCL_EXPORT_REF MP3ErrorType IMpeg3File::GetMetadataSize(uint32 &aSize)
 {
     if (pMP3Parser != NULL)
     {
@@ -336,11 +398,11 @@
     return MP3_ERROR_UNKNOWN;
 }
 
-OSCL_EXPORT_REF uint32 IMpeg3File::GetMinBytesRequired()
+OSCL_EXPORT_REF uint32 IMpeg3File::GetMinBytesRequired(bool aNextBytes)
 {
     if (pMP3Parser != NULL)
     {
-        return pMP3Parser->GetMinBytesRequired();
+        return pMP3Parser->GetMinBytesRequired(aNextBytes);
     }
     return 0;
 }
@@ -513,6 +575,14 @@
                 ++numvalentries;
             }
         }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY) == 0)
+        {
+            if (pMP3Parser)
+            {
+                // Increment the counter for the number of values found so far
+                ++numvalentries;
+            }
+        }
         else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP3METADATA_NUMTRACKS_KEY) == 0)
         {
             // Number of tracks
@@ -562,6 +632,17 @@
                 ++numvalentries;
             }
         }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP3METADATA_CHANNEL_MODE_KEY) == 0 ||
+                 oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP3METADATA_TRACKINFO_AUDIO_CHANNEL_MODE_KEY) == 0)
+        {
+            // Channel mode
+            MP3ContentFormatType mp3info;
+            if (GetConfigDetails(mp3info) == MP3_SUCCESS)
+            {
+                // Increment the counter for the number of values found so far
+                ++numvalentries;
+            }
+        }
     }  // End of for loop
     return numvalentries;
 }
@@ -578,7 +659,7 @@
     // Copy the requested keys
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     for (uint32 lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
     {
         if (aQueryKeyString == NULL)
@@ -588,10 +669,12 @@
             if (num_entries > aStartingKeyIndex)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, aKeyList.push_back(iAvailableMetadataKeys[lcv].get_cstr()));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     return PVMFErrNoMemory);
+                leavecode = OsclErrNone;
+                leavecode = PushKVPKey(iAvailableMetadataKeys[lcv].get_cstr(), aKeyList);
+                if (OsclErrNone != leavecode)
+                {
+                    return PVMFErrNoMemory;
+                }
                 num_added++;
             }
         }
@@ -605,10 +688,12 @@
                 if (num_entries > aStartingKeyIndex)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, aKeyList.push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         return PVMFErrNoMemory);
+                    leavecode = OsclErrNone;
+                    leavecode = PushKVPKey(iAvailableMetadataKeys[lcv].get_cstr(), aKeyList);
+                    if (OsclErrNone != leavecode)
+                    {
+                        return PVMFErrNoMemory;
+                    }
                     num_added++;
                 }
             }
@@ -672,10 +757,14 @@
 
             ++numvalentries;
 
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode,
-                     KeyVal.key = OSCL_ARRAY_NEW(char, oscl_strlen(key) + 1);
-                    );
+            int32 leavecode = OsclErrNone;
+            KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, oscl_strlen(key) + 1);
+
+            if (OsclErrNone != leavecode)
+            {
+                // allocation failed
+                return PVMFErrNoMemory;
+            }
 
             oscl_strncpy(KeyVal.key , key, oscl_strlen(key) + 1);
             KeyVal.length = len;
@@ -684,42 +773,24 @@
             if (KeyVal.length > 0)
             {
                 PvmiKvpValueType ValueType = GetValTypeFromKeyString(key);
-
+                leavecode = OsclErrNone;
                 switch (ValueType)
                 {
 
                     case PVMI_KVPVALTYPE_WCHARPTR:
-                        leavecode = 0;
-
-                        OSCL_TRY(leavecode,
-                                 KeyVal.value.pWChar_value = OSCL_ARRAY_NEW(oscl_wchar, len + 1);
-                                );
-
+                        KeyVal.value.pWChar_value = (oscl_wchar*) AllocateKVPKeyArray(leavecode, ValueType, len);
                         oscl_strncpy(KeyVal.value.pWChar_value , (*(iFrame.back())).value.pWChar_value, len);
                         KeyVal.value.pWChar_value[len] = 0;
                         break;
-
                     case PVMI_KVPVALTYPE_CHARPTR:
-                        leavecode = 0;
-
-                        OSCL_TRY(leavecode,
-                                 KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, len + 1);
-                                );
-
+                        KeyVal.value.pChar_value = (char*) AllocateKVPKeyArray(leavecode, ValueType, len);
                         oscl_strncpy(KeyVal.value.pChar_value , (*(iFrame.back())).value.pChar_value, len);
                         KeyVal.value.pChar_value[len] = 0;
                         break;
-
                     case PVMI_KVPVALTYPE_UINT8PTR:
-                        leavecode = 0;
-
-                        OSCL_TRY(leavecode,
-                                 KeyVal.value.pUint8_value = OSCL_ARRAY_NEW(uint8, len);
-                                );
+                        KeyVal.value.pUint8_value = (uint8*) AllocateKVPKeyArray(leavecode, ValueType, len);
                         oscl_memcpy(KeyVal.value.pUint8_value, (uint8*)(*(iFrame.back())).value.pUint8_value, len);
                         break;
-
-
                     case PVMI_KVPVALTYPE_UINT32:
                         KeyVal.value.uint32_value = (*(iFrame.back())).value.uint32_value;
                         break;
@@ -729,10 +800,20 @@
                     default:
                         break;
                 }
-                leavecode = 0;
-                OSCL_TRY(leavecode, aValueList.push_back(KeyVal));
-                OSCL_FIRST_CATCH_ANY(leavecode, ReleaseMetadataValue(KeyVal);
-                                     break;);
+
+                if (OsclErrNone != leavecode)
+                {
+                    // allocation failed
+                    return PVMFErrNoMemory;
+                }
+
+                leavecode = OsclErrNone;
+                leavecode = PushKVPValue(KeyVal, aValueList);
+                if (OsclErrNone != leavecode)
+                {
+                    // push kvp failed
+                    return PVMFErrNoMemory;
+                }
                 ++numentriesadded;
             }
             iFrame.pop_back();
@@ -742,7 +823,7 @@
     for (lcv = 0; lcv < numKeys; lcv++)
     {
 
-        int32 leavecode = 0;
+        int32 leavecode = OsclErrNone;
         PvmiKvp KeyVal;
         KeyVal.key = NULL;
         uint32 KeyLen = 0;
@@ -772,11 +853,9 @@
                         KeyLen += oscl_strlen(PVMP3METADATA_TIMESCALE1000) + 1; // for "timescale=1000" and NULL terminator
 
                         // Allocate memory for the string
-                        leavecode = 0;
-                        OSCL_TRY(leavecode,
-                                 KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                                );
-                        if (leavecode == 0)
+                        leavecode = OsclErrNone;
+                        KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                        if (OsclErrNone == leavecode)
                         {
                             // Copy the key string
                             oscl_strncpy(KeyVal.key, PVMP3METADATA_DURATION_KEY, oscl_strlen(PVMP3METADATA_DURATION_KEY) + 1);
@@ -806,13 +885,10 @@
                         KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*;"
 
                         // Allocate memory for the string
-                        leavecode = 0;
-                        OSCL_TRY(leavecode,
-                                 KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                                );
+                        leavecode = OsclErrNone;
+                        KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-
-                        if (leavecode == 0)
+                        if (OsclErrNone == leavecode)
                         {
                             oscl_strncpy(KeyVal.key, PVMP3METADATA_DURATION_KEY, oscl_strlen(PVMP3METADATA_DURATION_KEY) + 1);
                             oscl_strncat(KeyVal.key, PVMP3METADATA_SEMICOLON, oscl_strlen(PVMP3METADATA_SEMICOLON));
@@ -830,12 +906,10 @@
                         }
 
                         uint32 valuelen = oscl_strlen(_STRLIT_CHAR(PVMP3METADATA_UNKNOWN)) + 1; // Add value string plus one for NULL terminator
-                        leavecode = 0;
-                        OSCL_TRY(leavecode,
-                                 KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                                );
+                        leavecode = OsclErrNone;
+                        KeyVal.value.pChar_value = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, valuelen);
 
-                        if (leavecode == 0)
+                        if (OsclErrNone == leavecode)
                         {
                             // Copy the value
                             oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMP3METADATA_UNKNOWN), valuelen);
@@ -854,6 +928,47 @@
                 }
             }
         }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY))
+        {
+            // Duration
+            if (pMP3Parser)
+            {
+                // Increment the counter for the number of values found so far
+                ++numvalentries;
+
+                // Create a value entry if past the starting index
+                if (numvalentries > aStartingValueIndex)
+                {
+                    KeyLen = oscl_strlen(PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY) + 1; // for "random-access-denied;"
+                    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR) + 1; // for "bool;"
+
+                    // Allocate memory for the string
+                    leavecode = OsclErrNone;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                    if (OsclErrNone == leavecode)
+                    {
+                        // Copy the key string
+                        oscl_strncpy(KeyVal.key, PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY, oscl_strlen(PVMP3METADATA_RANDOM_ACCESS_DENIED_KEY) + 1);
+                        oscl_strncat(KeyVal.key, PVMP3METADATA_SEMICOLON, oscl_strlen(PVMP3METADATA_SEMICOLON));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                        KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                        // Copy the value
+                        KeyVal.value.bool_value = pMP3Parser->GetDuration() > 0 ? false : true;
+                        // Set the length and capacity
+                        KeyVal.length = 1;
+                        KeyVal.capacity = 1;
+                    }
+                    else
+                    {
+                        // Memory allocation failed
+                        KeyVal.key = NULL;
+                        break;
+                    }
+                }
+            }
+        }
         else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMP3METADATA_DURATION_FROM_METADATA_KEY))
         {
             // Duration
@@ -880,11 +995,9 @@
                         KeyLen += oscl_strlen(PVMP3METADATA_TIMESCALE1000) + 1; // for "timescale=1000" and NULL terminator
 
                         // Allocate memory for the string
-                        leavecode = 0;
-                        OSCL_TRY(leavecode,
-                                 KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                                );
-                        if (leavecode == 0)
+                        leavecode = OsclErrNone;
+                        KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                        if (OsclErrNone == leavecode)
                         {
                             // Copy the key string
                             oscl_strncpy(KeyVal.key, PVMP3METADATA_DURATION_FROM_METADATA_KEY, oscl_strlen(PVMP3METADATA_DURATION_KEY) + 1);
@@ -914,13 +1027,11 @@
                         KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*;"
 
                         // Allocate memory for the string
-                        leavecode = 0;
-                        OSCL_TRY(leavecode,
-                                 KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                                );
+                        leavecode = OsclErrNone;
+                        KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
 
-                        if (leavecode == 0)
+                        if (OsclErrNone == leavecode)
                         {
                             oscl_strncpy(KeyVal.key, PVMP3METADATA_DURATION_FROM_METADATA_KEY, oscl_strlen(PVMP3METADATA_DURATION_KEY) + 1);
                             oscl_strncat(KeyVal.key, PVMP3METADATA_SEMICOLON, oscl_strlen(PVMP3METADATA_SEMICOLON));
@@ -928,7 +1039,6 @@
                             oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
 
                             KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
-
                         }
                         else
                         {
@@ -938,12 +1048,10 @@
                         }
 
                         uint32 valuelen = oscl_strlen(_STRLIT_CHAR(PVMP3METADATA_UNKNOWN)) + 1; // Add value string plus one for NULL terminator
-                        leavecode = 0;
-                        OSCL_TRY(leavecode,
-                                 KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                                );
+                        leavecode = OsclErrNone;
+                        KeyVal.value.pChar_value = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, valuelen);
 
-                        if (leavecode == 0)
+                        if (OsclErrNone == leavecode)
                         {
                             // Copy the value
                             oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMP3METADATA_UNKNOWN), valuelen);
@@ -978,12 +1086,10 @@
                     KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                     // Allocate memory for the string
-                    leavecode = 0;
-                    OSCL_TRY(leavecode,
-                             KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                            );
+                    leavecode = OsclErrNone;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                    if (leavecode == 0)
+                    if (OsclErrNone == leavecode)
                     {
                         // Copy the key string
                         oscl_strncpy(KeyVal.key, PVMP3METADATA_NUMTRACKS_KEY, oscl_strlen(PVMP3METADATA_NUMTRACKS_KEY) + 1);
@@ -1025,12 +1131,10 @@
                     KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                     // Allocate memory for the string
-                    leavecode = 0;
-                    OSCL_TRY(leavecode,
-                             KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                            );
+                    leavecode = OsclErrNone;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                    if (leavecode == 0)
+                    if (OsclErrNone == leavecode)
                     {
                         // Copy the key string
                         oscl_strncpy(KeyVal.key, PVMP3METADATA_TRACKINFO_BITRATE_KEY, oscl_strlen(PVMP3METADATA_TRACKINFO_BITRATE_KEY) + 1);
@@ -1075,11 +1179,9 @@
 
                     // Allocate memory for the string
                     leavecode = 0;
-                    OSCL_TRY(leavecode,
-                             KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                            );
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                    if (leavecode == 0)
+                    if (OsclErrNone == leavecode)
                     {
                         // Copy the key string
                         oscl_strncpy(KeyVal.key, PVMP3METADATA_TRACKINFO_SAMPLERATE_KEY, oscl_strlen(PVMP3METADATA_TRACKINFO_SAMPLERATE_KEY) + 1);
@@ -1121,13 +1223,15 @@
 
                 uint32 valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_MP3)) + 1; // Add value string plus one for NULL terminator
                 // Allocate memory for the strings
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                         KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                        );
+                int32 leavecode1 = OsclErrNone;
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                if (OsclErrNone == leavecode)
+                {
+                    KeyVal.value.pChar_value = (char*) AllocateKVPKeyArray(leavecode1, PVMI_KVPVALTYPE_CHARPTR, valuelen);
+                }
 
-                if (leavecode == 0)
+                if (OsclErrNone == leavecode && OsclErrNone == leavecode1)
                 {
                     // Copy the key string
                     oscl_strncpy(KeyVal.key, PVMP3METADATA_TRACKINFO_AUDIO_FORMAT_KEY, oscl_strlen(PVMP3METADATA_TRACKINFO_AUDIO_FORMAT_KEY) + 1);
@@ -1179,12 +1283,10 @@
                     KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                     // Allocate memory for the string
-                    leavecode = 0;
-                    OSCL_TRY(leavecode,
-                             KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                            );
+                    leavecode = OsclErrNone;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                    if (leavecode == 0)
+                    if (OsclErrNone == leavecode)
                     {
                         // Copy the key string
                         oscl_strncpy(KeyVal.key, PVMP3METADATA_TRACKINFO_AUDIO_CHANNELS_KEY, oscl_strlen(PVMP3METADATA_TRACKINFO_AUDIO_CHANNELS_KEY) + 1);
@@ -1209,15 +1311,64 @@
                 }
             }
         }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP3METADATA_CHANNEL_MODE_KEY) == 0 ||
+                 oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP3METADATA_TRACKINFO_AUDIO_CHANNEL_MODE_KEY) == 0)
+        {
+            // Channel mode
+            MP3ContentFormatType mp3info;
+            if (GetConfigDetails(mp3info) == MP3_SUCCESS)
+            {
+                // Increment the counter for the number of values found so far
+                ++numvalentries;
+
+                // Create a value entry if past the starting index
+                if (numvalentries > aStartingValueIndex)
+                {
+                    KeyLen = oscl_strlen(PVMP3METADATA_TRACKINFO_AUDIO_CHANNEL_MODE_KEY) + 1; // for "track-info/audio/channel-mode;"
+                    KeyLen += oscl_strlen(PVMP3METADATA_INDEX0) + 1; // for "index=0;"
+                    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
+
+                    // Allocate memory for the string
+                    leavecode = 0;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+
+                    if (leavecode == 0)
+                    {
+                        // Copy the key string
+                        oscl_strncpy(KeyVal.key, PVMP3METADATA_TRACKINFO_AUDIO_CHANNEL_MODE_KEY, oscl_strlen(PVMP3METADATA_TRACKINFO_AUDIO_CHANNEL_MODE_KEY) + 1);
+                        oscl_strncat(KeyVal.key, PVMP3METADATA_SEMICOLON, oscl_strlen(PVMP3METADATA_SEMICOLON));
+                        oscl_strncat(KeyVal.key, PVMP3METADATA_INDEX0, oscl_strlen(PVMP3METADATA_INDEX0));
+                        oscl_strncat(KeyVal.key, PVMP3METADATA_SEMICOLON, oscl_strlen(PVMP3METADATA_SEMICOLON));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                        KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                        // Copy the value
+                        KeyVal.value.uint32_value = mp3info.ChannelMode;
+                        // Set the length and capacity
+                        KeyVal.length = 1;
+                        KeyVal.capacity = 1;
+                    }
+                    else
+                    {
+                        // Memory allocation failed
+                        KeyVal.key = NULL;
+                        break;
+                    }
+                }
+            }
+        }
 
         // Add the KVP to the list if the key string was created
         if (KeyVal.key != NULL)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, aValueList.push_back(KeyVal));
-            OSCL_FIRST_CATCH_ANY(leavecode,
-                                 ReleaseMetadataValue(KeyVal);
-                                 break;);
+            leavecode = OsclErrNone;
+            leavecode = PushKVPValue(KeyVal, aValueList);
+            if (OsclErrNone != leavecode)
+            {
+                // push kvp failed
+                return PVMFErrNoMemory;
+            }
 
             // Increment the counter for number of value entries added to the list
             ++numentriesadded;
@@ -1334,7 +1485,6 @@
 {
     uint32 capacity = 0;
     uint32 currFilePosn = MP3Utils::getCurrentFilePosition(&iMP3File);
-    uint32 currFileSize = 0;
     if (aFileOffset > currFilePosn)
     {
         capacity = (aFileOffset - currFilePosn);
@@ -1355,3 +1505,57 @@
     return MP3_ERROR_UNKNOWN;
 }
 
+OsclAny* IMpeg3File::AllocateKVPKeyArray(int32& aLeaveCode, PvmiKvpValueType aValueType, int32 aNumElements)
+{
+    int32 leaveCode = OsclErrNone;
+    OsclAny* aBuffer = NULL;
+    switch (aValueType)
+    {
+        case PVMI_KVPVALTYPE_WCHARPTR:
+            OSCL_TRY(leaveCode,
+                     aBuffer = (oscl_wchar*) OSCL_ARRAY_NEW(oscl_wchar, aNumElements + 1);
+                    );
+            break;
+
+        case PVMI_KVPVALTYPE_CHARPTR:
+            OSCL_TRY(leaveCode,
+                     aBuffer = (char*) OSCL_ARRAY_NEW(char, aNumElements + 1);
+                    );
+            break;
+        case PVMI_KVPVALTYPE_UINT8PTR:
+            OSCL_TRY(leaveCode,
+                     aBuffer = (uint8*) OSCL_ARRAY_NEW(uint8, aNumElements);
+                    );
+            break;
+        default:
+            break;
+    }
+    aLeaveCode = leaveCode;
+    return aBuffer;
+}
+
+
+int32 IMpeg3File::PushKVPValue(PvmiKvp aKVP, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList)
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, aValueList.push_back(aKVP));
+    if (OsclErrNone != leavecode)
+    {
+        ReleaseMetadataValue(aKVP);
+    }
+    return leavecode;
+}
+
+int32 IMpeg3File::PushKVPKey(const char* aString, PVMFMetadataList& aKeyList)
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, aKeyList.push_back(aString));
+    return leavecode;
+}
+
+int32 IMpeg3File::PushKVPKey(OSCL_HeapString<OsclMemAllocator>& aString, Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator>& aKeyList)
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, aKeyList.push_back(aString));
+    return leavecode;
+}
diff --git a/fileformats/mp3/parser/src/mp3fileio.cpp b/fileformats/mp3/parser/src/mp3fileio.cpp
index f4feee7..be2b674 100644
--- a/fileformats/mp3/parser/src/mp3fileio.cpp
+++ b/fileformats/mp3/parser/src/mp3fileio.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,11 +29,47 @@
  *  IO utility functions.
  */
 
+//----------------------------------------------------------------------
+// Defines
+//----------------------------------------------------------------------
 #define IMPLEMENT_MP3FileIO
 
+//----------------------------------------------------------------------
+// Include Files
+//----------------------------------------------------------------------
 #include "mp3fileio.h"
 #include "oscl_utf8conv.h"
 
+
+//----------------------------------------------------------------------
+// Type Declarations
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// Global Constant Definitions
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// Global Data Definitions
+//----------------------------------------------------------------------
+
+//----------------------------------------------------------------------
+// Static Variable Definitions
+//----------------------------------------------------------------------
+
+/*======================================================================
+FUNCTION:     **** FILE POINTER READING METHODS
+
+DESCRIPTION:
+
+INPUT/OUTPUT PARAMETERS:
+
+RETURN VALUE:
+
+SIDE EFFECTS:
+
+======================================================================*/
+
 // Read in the 64 bits byte by byte and take most significant byte first
 bool MP3FileIO::read64(PVFile *fp, uint64 &data)
 {
diff --git a/fileformats/mp3/parser/src/mp3parser.cpp b/fileformats/mp3/parser/src/mp3parser.cpp
index 36ce85d..4ffeaf7 100644
--- a/fileformats/mp3/parser/src/mp3parser.cpp
+++ b/fileformats/mp3/parser/src/mp3parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,11 +28,9 @@
  *  @brief This file contains the implementation of the actual MP3
  *  file parser.
  */
-
 /***********************************************************************
  * Include Files
  ***********************************************************************/
-#include "oscl_tickcount.h"
 #include "mp3parser.h"
 #include "mp3fileio.h"
 
@@ -221,6 +219,9 @@
  * FUNCTION:    SwapFileToHostByteOrderInt32
  * DESCRIPTION: Swaps the bytes in an integer to the correct host
  *				byte order
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 static uint32 SwapFileToHostByteOrderInt32(uint8 * pBuf2)
 {
@@ -245,6 +246,9 @@
 /***********************************************************************
  * FUNCTION:    ReadBuffer
  * DESCRIPTION: Read data from buffer
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 static uint32 ReadBuffer(uint8 * pBuf2, int32 length, int32 &pos)
 {
@@ -269,6 +273,9 @@
 /***********************************************************************
  * FUNCTION:    SwapFileToHostByteOrderInt16
  * DESCRIPTION: Swaps the bytes in an integer to the correct host byte order
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 static uint16 SwapFileToHostByteOrderInt16(uint8 * pBuf2)
 {
@@ -290,6 +297,10 @@
 
 /***********************************************************************
  * FUNCTION:    Constructor
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3Parser::MP3Parser(PVFile* aFileHandle)
 {
@@ -310,6 +321,7 @@
     iAvgBitrateInbps = 0;
     iAvgBitrateInbpsFromRandomScan = 0;
     iAvgBitrateInbpsFromCompleteScan = 0;
+    iScannedFrameCount = 0;
     // scan completion flag
     iDurationScanComplete = false;
     // duration values from various sources
@@ -320,9 +332,18 @@
     iClipDurationFromRandomScan = 0;
     iClipDurationFromMetadata = 0;
 
+    iSamplesPerFrame = 0;
+    iSamplingRate = 0;
+
     iTimestamp = 0;
     iFirstScan = true;
 
+    iTOC = NULL;
+    iTOCFilledCount = 0;
+    iTimestampPrev = 0;
+    iScanTimestamp = 0;
+    iBinWidth = 0;
+
     iVbriHeader.TOC = NULL;
     oscl_memset(&iMP3ConfigInfo, 0, sizeof(iMP3ConfigInfo));
     oscl_memset(&iMP3HeaderInfo, 0, sizeof(iMP3HeaderInfo));
@@ -335,6 +356,10 @@
 
 /***********************************************************************
  * FUNCTION:    Destructor
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3Parser::~MP3Parser()
 {
@@ -359,6 +384,12 @@
     }
     iMaxSyncBufferSize = 0;
 
+    if (iTOC)
+    {
+        OSCL_ARRAY_DELETE(iTOC);
+        iTOC = NULL;
+    }
+
     oscl_memset(&iMP3ConfigInfo, 0, sizeof(iMP3ConfigInfo));
     oscl_memset(&iMP3HeaderInfo, 0, sizeof(iMP3HeaderInfo));
     oscl_memset(&iXingHeader, 0, sizeof(iXingHeader));
@@ -371,6 +402,9 @@
  * DESCRIPTION: This function MUST be called after the Constructor and before
  *				any other public function is called. Otherwise the object's
  *				member data will be uninitialized.
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3ErrorType MP3Parser::ParseMP3File(PVFile * fpUsed, bool aEnableCRC)
 {
@@ -414,15 +448,21 @@
                 return MP3_END_OF_FILE;
             }
         }
-        else
-        {
-            iLocalFileSize = 0;
-            return MP3_ERROR_UNKNOWN;
-        }
     }
 
-    // set the length of initial search to the min between default and filesize
-    iInitSearchFileSize = OSCL_MIN(iInitSearchFileSize, iLocalFileSize);
+    if (iLocalFileSizeSet)
+    {
+        // set the length of initial search to the min between default and filesize
+        iInitSearchFileSize = OSCL_MIN(iInitSearchFileSize, iLocalFileSize);
+    }
+    else
+    {
+        uint32 remBytes = 0;
+        if (fp->GetRemainingBytes(remBytes))
+        {
+            iInitSearchFileSize = OSCL_MIN(iInitSearchFileSize, remBytes);
+        }
+    }
 
     MP3ErrorType err = MP3Utils::SeektoOffset(fp, 0);
     if (MP3_SUCCESS != err)
@@ -481,7 +521,7 @@
     if (!GetMP3Header(firstHeader, iMP3HeaderInfo))
     {
         uint32 seekOffset = 0;
-        MP3ErrorType err = mp3FindSync(StartOffset, seekOffset);
+        MP3ErrorType err = mp3FindSync(StartOffset, seekOffset, fp);
         if (err == MP3_SUCCESS)
         {
             StartOffset += seekOffset;
@@ -502,13 +542,17 @@
                 return MP3_FILE_HDR_READ_ERR;
             }
         }
-        else if (err == MP3_INSUFFICIENT_DATA)
+        else if (err == MP3_INSUFFICIENT_DATA ||
+                 err == MP3_END_OF_FILE)
         {
+            // in eof scenario parser reports eof error to the user
+            // eof will be reported in case when no valid sync
+            // word is find in the maximum specified search limit
             return err;
         }
     }
 
-    if (! DecodeMP3Header(iMP3HeaderInfo, iMP3ConfigInfo, false))
+    if (!DecodeMP3Header(iMP3HeaderInfo, iMP3ConfigInfo, false))
     {
         return MP3_FILE_HDR_DECODE_ERR;
     }
@@ -536,7 +580,6 @@
         int32 actualBufferSize = bufferSize + VBRI_HEADER_OFFSET + VBR_HEADER_SIZE;
         uint8* tempBuf = OSCL_ARRAY_NEW(uint8, actualBufferSize);
 
-        uint32 currFileSize = 0;
         MP3ErrorType err = MP3Utils::SeektoOffset(fp, StartOffset);
         if (MP3_SUCCESS != err)
         {
@@ -627,6 +670,37 @@
             else
                 mp3Type = EXINGType;
         }
+        // Check for INFO Header, same as XING Header
+        if ((oscl_memcmp(pBuf, STR_INFO_HEADER_IDENTIFIER, VBR_HEADER_SIZE) == 0))
+        {
+            MP3ErrorType err = MP3Utils::SeektoOffset(fp, StartOffset + offset);
+            if (MP3_SUCCESS != err)
+            {
+                return err;
+            }
+
+            if (!MP3FileIO::readByteData(fp, 128, pFirstFrame))
+            {
+                return MP3_INSUFFICIENT_DATA;
+            }
+
+            if (!DecodeXINGHeader(pFirstFrame, iXingHeader, iMP3HeaderInfo))
+                return MP3_FILE_XING_HDR_ERR;
+            else
+                mp3Type = EXINGType;
+        }
+    }
+
+    // Calculate the sampling rate and samples per frame.
+    iSamplesPerFrame = spfIndexTable[iMP3HeaderInfo.frameVer][iMP3HeaderInfo.layerID];
+    iSamplingRate = srIndexTable[((iMP3HeaderInfo.frameVer)*4) + iMP3HeaderInfo.srIndex];
+
+    if (mp3Type != EXINGType && mp3Type != EVBRIType)
+    {
+        // if XING or VBRI Headers are not present then we need to build our own TOC for
+        // repositioning.
+        iTOC = OSCL_ARRAY_NEW(int32, MAX_TOC_ENTRY_COUNT + 1);
+        oscl_memset(iTOC, 0, sizeof(iTOC));
     }
 
     iAvgBitrateInbps = iMP3ConfigInfo.BitRate;
@@ -648,27 +722,39 @@
  *  Input	 : fpUsed
  *  Output	 : iClipDurationComputed
  *	Return   : error code
+ *	Modified :
  ***********************************************************************/
 MP3ErrorType MP3Parser::ScanMP3File(PVFile * fpUsed, uint32 aFramesToScan)
 {
-    if (iClipDurationFromVBRIHeader || iClipDurationFromMetadata)
+    int32 currentFilePosn = 0;
+    uint32 firstHeader = 0;
+    uint8 pFrameHeader[4];
+    int32 startOffset = 0;
+    uint32 seekOffset = 0;
+    MP3HeaderType mp3HeaderInfo;
+    MP3ConfigInfoType mp3ConfigInfo;
+
+    if (iClipDurationFromMetadata || (iClipDurationFromVBRIHeader &&
+                                      ((iVbriHeader.entriesTOC >= 0) ||
+                                       (iXingHeader.flags & TOC_FLAG)))
+       )
     {
         // if Duration can be obtained from either VBRI/XING Headers or from metadata,
         // we will not scan the file for duration
         return MP3_DURATION_PRESENT;
     }
+
+    if (iTOCFilledCount == MAX_TOC_ENTRY_COUNT)
+    {
+        FillTOCTable(0, 0);
+        return MP3_SUCCESS;
+    }
+
     if (iFirstScan)
     {
-        currentFilePosn = 0; // current file position
-        firstHeader = 0;
-        startOffset = 0;
-        seekOffset = 0;
-        frameCount = 0;
-
         if (iTagSize > 0)
         {
             startOffset = iTagSize;
-            //fpUsed->Seek(startOffset, Oscl_File::SEEKSET);
             MP3ErrorType err = MP3Utils::SeektoOffset(fpUsed, startOffset);
             if (MP3_SUCCESS != err)
             {
@@ -687,7 +773,6 @@
     if (iFirstScan)
     {
         iFirstScan = false;
-
         currentFilePosn = startOffset;
 
         MP3ErrorType err = mp3FindSync(startOffset, seekOffset, fpUsed);
@@ -710,12 +795,13 @@
         }
     }
     currentFilePosn = MP3Utils::getCurrentFilePosition(fpUsed);
-    int32 numFrames = 0;
+    uint32 numFrames = 0;
     int32 bitrate = 0;
+    uint32 frameDur = 0;
 
     while (numFrames < aFramesToScan)
     {
-        firstHeader = NULL;
+        firstHeader = 0;
         oscl_memset(&pFrameHeader, 0, sizeof(pFrameHeader));
 
         if (fpUsed->Read(pFrameHeader, 1, MP3_FRAME_HEADER_SIZE) != MP3_FRAME_HEADER_SIZE)
@@ -724,18 +810,18 @@
             {
                 iDurationScanComplete = true;
             }
+            FillTOCTable(startOffset, 0);
             return MP3_INSUFFICIENT_DATA;
         }
-
         firstHeader = SwapFileToHostByteOrderInt32(pFrameHeader);
+        uint32 offset = MP3Utils::getCurrentFilePosition(fpUsed);
         if (!GetMP3Header(firstHeader, mp3HeaderInfo))
         {
-            MP3ErrorType err = mp3FindSync(startOffset, seekOffset, fpUsed);
+            MP3ErrorType err = mp3FindSync(offset, seekOffset, fpUsed);
             if (err == MP3_SUCCESS)
             {
-                startOffset += seekOffset;
-                //fpUsed->Seek(startOffset, Oscl_File::SEEKSET);
-                err = MP3Utils::SeektoOffset(fpUsed, startOffset);
+                offset += seekOffset;
+                err = MP3Utils::SeektoOffset(fpUsed, offset);
                 if (MP3_SUCCESS != err)
                 {
                     return err;
@@ -744,6 +830,7 @@
                 if (!MP3FileIO::readByteData(fpUsed, 4, pFrameHeader))
                 {
                     iDurationScanComplete = true;
+                    FillTOCTable(offset, iScanTimestamp);
                     return MP3_INSUFFICIENT_DATA;
                 }
 
@@ -751,12 +838,14 @@
                 if (! GetMP3Header(firstHeader, mp3HeaderInfo))
                 {
                     iDurationScanComplete = true;
+                    FillTOCTable(offset, iScanTimestamp);
                     return MP3_FILE_HDR_READ_ERR;
                 }
             }
             else
             {
                 iDurationScanComplete = true;
+                FillTOCTable(offset, iScanTimestamp);
                 return err;
             }
         }
@@ -764,35 +853,47 @@
         if (!DecodeMP3Header(mp3HeaderInfo, mp3ConfigInfo, false))
         {
             iDurationScanComplete = true;
+            FillTOCTable(offset, iScanTimestamp);
             return MP3_FILE_HDR_DECODE_ERR;
         }
 
         fpUsed->Seek(mp3ConfigInfo.FrameLengthInBytes - 4, Oscl_File::SEEKCUR);
         bitrate = mp3ConfigInfo.BitRate;
+        frameDur = frameDur + (uint32)((OsclFloat) mp3ConfigInfo.FrameLengthInBytes * 8000.00f / mp3ConfigInfo.BitRate);
         iLastScanPosition = fpUsed->Tell();
         numFrames++;
-        frameCount++;
+        iScannedFrameCount++;
 
-        if (frameCount > 1)
+        if (iScannedFrameCount > 1)
         {
             if (bitrate != iAvgBitrateInbpsFromCompleteScan)
             {
-                iAvgBitrateInbpsFromCompleteScan += (int32)((int32)bitrate - (int32)iAvgBitrateInbpsFromCompleteScan) / (int32)frameCount;
+                iAvgBitrateInbpsFromCompleteScan += (int32)((int32)bitrate - (int32)iAvgBitrateInbpsFromCompleteScan) / (int32)iScannedFrameCount;
             }
         }
         else
         {
             iAvgBitrateInbpsFromCompleteScan = bitrate;
+            mp3Type = ECBRType;
         }
     }
+
+    // After scan of frames we need to fill the TOC table
+    FillTOCTable(startOffset, iScanTimestamp);
+    iScanTimestamp = iScanTimestamp + frameDur;
+
     return MP3_SUCCESS;
 }
 
 
+
 /***********************************************************************
  * FUNCTION:    GetMP3Header
  * DESCRIPTION: Parse Header Bit fields into a structure (Pass in 4 bytes)
  *	            Validate ranges and reserved fields.
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 bool MP3Parser::GetMP3Header(uint32 &aFrameHeader, MP3HeaderType &aMP3HeaderInfo)
 {
@@ -830,6 +931,9 @@
  * FUNCTION:    DecodeMP3Header
  * DESCRIPTION: Decode the MP3 Header struct and place the derived values
  *              into the supplied MP3 Config data structure.
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 bool MP3Parser::DecodeMP3Header(MP3HeaderType &aMP3HeaderInfo, MP3ConfigInfoType &aMP3ConfigInfo, bool aComputeAvgBitrate)
 {
@@ -927,7 +1031,7 @@
                 if (iId3TagParser.IsID3V1Present())
                 {
                     // The TAG in an ID3V1.x MP3 File is 128 bytes long
-                    audioDataSize -= ID3_V1_TAG_SIZE;
+                    audioDataSize -= 128;
                 }
                 iNumberOfFrames = audioDataSize / (aMP3ConfigInfo.FrameLengthInBytes);
 
@@ -956,6 +1060,9 @@
  * FUNCTION:    DecodeVBRIHeader
  * DESCRIPTION:	Decode VBRI Header and store TOC entries used for
 				repositioning
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 bool MP3Parser::DecodeVBRIHeader(uint8 *VbriBuffer, VBRIHeaderType &vbriHDType,
                                  MP3HeaderType &aMP3HeaderInfo)
@@ -995,6 +1102,10 @@
 
 /***********************************************************************
  * FUNCTION:    DecodeXINGHeader
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 bool  MP3Parser::DecodeXINGHeader(uint8 *XingBuffer,
                                   XINGHeaderType &mp3XingHD,
@@ -1045,6 +1156,9 @@
 /***********************************************************************
  * FUNCTION:    GetMP3FileHeader
  * DESCRIPTION: Returns information necessary to configure the audio device
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 bool MP3Parser::GetMP3FileHeader(MP3ConfigInfoType * pMP3Config)
 {
@@ -1117,11 +1231,25 @@
 }
 
 /***********************************************************************
+ *	Function : GetChannelMode
+ *	Purpose  : Fetch Channel mode for the clip
+ *  Input	 : None
+ *  Output	 :
+ *	Return   : ChannelMode
+ *	Modified :
+ ***********************************************************************/
+uint32 MP3Parser::GetChannelMode() const
+{
+    return iMP3HeaderInfo.chMode;
+}
+
+/***********************************************************************
  *	Function : GetDurationFromMetadata
  *	Purpose  : Fetch duration value from id3 frame (TLEN - track length)
  *  Input	 : None
  *  Output	 : iClipDurationFromMetadata
  *	Return   : clip duration
+ *	Modified :
  ***********************************************************************/
 uint32 MP3Parser::GetDurationFromMetadata()
 {
@@ -1140,6 +1268,45 @@
 }
 
 /***********************************************************************
+ *	Function : ConvertSizeToTime
+ *	Purpose  : Fetches duration of the clip playing
+ *			   Duration is returned, by different
+ *			   means by the pre-defined priorities
+ *  Input	 : aMetadataDuration, true if duration from metadata is needed
+ *  Output	 : None
+ *	Return   : Clip duration
+ *	Modified :
+ **********************************************************************/
+int32 MP3Parser::ConvertSizeToTime(uint32 aFileSize, uint32& aNPTInMS)
+{
+    uint32 duration = 0;
+    uint32 fileSize = aFileSize;
+
+    if (iId3TagParser.IsID3V2Present())
+    {
+        if (iTagSize > fileSize)
+        {
+            return -1;
+        }
+        fileSize -= iTagSize;
+    }
+    if (iId3TagParser.IsID3V1Present())
+    {
+        // id3v1.x tags are 128 bytes long
+        fileSize -= ID3_V1_TAG_SIZE;
+    }
+
+    if (iAvgBitrateInbps > 0)
+    {
+        duration = (uint32)((OsclFloat)(fileSize * 8000.00f / iAvgBitrateInbps));
+        aNPTInMS = duration;
+        return 0;
+    }
+
+    return -1;
+}
+
+/***********************************************************************
  *	Function : GetDuration
  *	Purpose  : Fetches duration of the clip playing
  *			   Duration is returned, by different
@@ -1147,6 +1314,7 @@
  *  Input	 : aMetadataDuration, true if duration from metadata is needed
  *  Output	 : None
  *	Return   : Clip duration
+ *	Modified :
  **********************************************************************/
 uint32 MP3Parser::GetDuration(bool aMetadataDuration)
 {
@@ -1176,18 +1344,20 @@
             if (clipDuration == 0 && GetDurationFromMetadata() > 0)
             {
                 clipDuration = iClipDurationFromMetadata;
-            }
-            if (clipDuration == 0)
-            {
-                if (MP3_SUCCESS != GetDurationFromRandomScan(clipDuration))
-                {
-                    clipDuration = 0;
-                }
-            }
-            if ((iAvgBitrateInbpsFromRandomScan == 0) && (clipDuration != 0))
-            {
                 // random scan will not be performed,
                 // estimate bitrate from filesize and duration
+            }
+            else if (clipDuration == 0)
+            {
+                if (MP3_SUCCESS == GetDurationFromRandomScan(clipDuration))
+                {
+                    iClipDurationInMsec = clipDuration;
+                    return clipDuration;
+                }
+            }
+            // if control gets here, that means avg bit rate from random scan is not calculated.
+            if (iAvgBitrateInbpsFromRandomScan <= 0)
+            {
                 uint32 fileSize = iLocalFileSize;
                 if (iId3TagParser.IsID3V2Present())
                 {
@@ -1198,7 +1368,7 @@
                     // id3v1.x tags are 128 bytes long
                     fileSize -= ID3_V1_TAG_SIZE;
                 }
-                iAvgBitrateInbpsFromRandomScan = fileSize * 8000.00f / clipDuration;
+                iAvgBitrateInbpsFromRandomScan = (int32)((OsclFloat)(fileSize * 8000.00f) / clipDuration);
             }
         }
         else
@@ -1234,8 +1404,9 @@
  *  Input	 : None
  *  Output	 : aSize, size of metadata
  *	Return   : error code
+ *	Modified :
  ***********************************************************************/
-MP3ErrorType MP3Parser::GetMetadataSize(int32 &aMetadataSize)
+MP3ErrorType MP3Parser::GetMetadataSize(uint32 &aMetadataSize)
 {
     if (fp)
     {
@@ -1245,7 +1416,7 @@
             return MP3_SUCCESS;
         }
     }
-    aMetadataSize = -1;
+    aMetadataSize = 0;
     return MP3_METADATA_NOTPARSED;
 }
 
@@ -1255,14 +1426,26 @@
  *  Input	 : None
  *  Output	 : None
  *	Return   : aSize, size of max mp3 frame
+ *	Modified :
  ***********************************************************************/
-uint32 MP3Parser::GetMinBytesRequired()
+uint32 MP3Parser::GetMinBytesRequired(bool aNextBytes)
 {
-    return KMAX_MP3FRAME_LENGTH_IN_BYTES;
+    uint32 minBytes = KMAX_MP3FRAME_LENGTH_IN_BYTES;
+    if (aNextBytes && fp)
+    {
+        // case where parse file has failed due to lack of data
+        // in that case request next n bytes.
+        minBytes += fp->Tell();
+    }
+    return minBytes;
 }
 
 /***********************************************************************
  * FUNCTION: GetNextBundledAccessUnits
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 int32 MP3Parser::GetNextBundledAccessUnits(uint32 *n, GAU *pgau, MP3ErrorType &error)
 {
@@ -1279,7 +1462,6 @@
 
     uint8 * pOutputBuffer = (uint8 *)pgau->buf.fragments[0].ptr;
     int32 iLength = pgau->buf.fragments[0].len;
-
     for (i = 0; (i < (int32)*n) && (iLength > 0); i++)
     {
         pgau->numMediaSamples = i;
@@ -1307,9 +1489,12 @@
     *n = i;
     return nBytesReadTotal;
 }
-
 /***********************************************************************
  * FUNCTION: PeekNextBundledAccessUnits
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 int32  MP3Parser::PeekNextBundledAccessUnits(uint32 *n, MediaMetaInfo *mInfo)
 {
@@ -1327,6 +1512,7 @@
         }
 
         mInfo->ts = GetTimestampForSample(iCurrFrameNumber + i);
+        // Don't care
         mInfo->layer = 0;
         // Maximum Frame Length
         mInfo->len   = (iMP3ConfigInfo.FrameLengthInBytes + MP3_FRAME_HEADER_SIZE);
@@ -1341,6 +1527,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetNextMediaSample
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3ErrorType MP3Parser::GetNextMediaSample(uint8 *buffer, uint32 size, uint32& framesize, uint32& timestamp)
 {
@@ -1356,15 +1546,15 @@
 
     framesize = 0;
     timestamp = 0;
-    uint32 remBytes = 0;
     // Read and Decode the MP3 Frame Header to obtain the
     // correct number of bytes in this frame.
     currentFilePosn = MP3Utils::getCurrentFilePosition(fp);
 
+    // If content length is known (non-0), avoid reading beyond EOF
     uint32 contentLength = MP3FileIO::getContentLength(fp);
     if (0 != contentLength)
     {
-        // if content length is known, check for reading beyond EOF
+        // check for reading beyond EOF
         if ((currentFilePosn + MP3_FRAME_HEADER_SIZE) >= contentLength)
         {
             return MP3_END_OF_FILE;
@@ -1387,7 +1577,7 @@
         // ////////////////////////////////////////////////////////////////////////////
         // If we don't find a valid MP3 Marker point we will attempt recovery.
         uint32 seekOffset = 0;
-        MP3ErrorType err = mp3FindSync(currentFilePosn, seekOffset);
+        MP3ErrorType err = mp3FindSync(currentFilePosn, seekOffset, fp);
 
         if (err == MP3_SUCCESS)
         {
@@ -1460,7 +1650,7 @@
         }
 
         uint32 seekOffset = 0;
-        MP3ErrorType err = mp3FindSync(currentFilePosn, seekOffset);
+        MP3ErrorType err = mp3FindSync(currentFilePosn, seekOffset, fp);
         if (err == MP3_SUCCESS)
         {
             currentFilePosn += seekOffset;
@@ -1469,7 +1659,6 @@
             {
                 return err;
             }
-
             goto BEGIN;
         }
         else
@@ -1503,7 +1692,7 @@
         timestamp = GetTimestampForCurrentSample();
         if (mp3CDInfo.BitRate > 0)
         {
-            iTimestamp = timestamp + (OsclFloat) mp3CDInfo.FrameLengthInBytes * 8000.00f / mp3CDInfo.BitRate;
+            iTimestamp = uint32(timestamp + (OsclFloat) mp3CDInfo.FrameLengthInBytes * 8000.00f / mp3CDInfo.BitRate);
         }
         if (0 != contentLength)
         {
@@ -1530,7 +1719,7 @@
     // calculate frameDuration
     if (mp3CDInfo.BitRate > 0)
     {
-        iTimestamp = timestamp + (OsclFloat) mp3CDInfo.FrameLengthInBytes * 8000.00f / mp3CDInfo.BitRate;
+        iTimestamp = uint32(timestamp + (OsclFloat) mp3CDInfo.FrameLengthInBytes * 8000.00f / mp3CDInfo.BitRate);
     }
 
     // Take into account the header (4 Bytes) already read up front
@@ -1544,7 +1733,6 @@
         }
     }
 
-
     // Take into account the header (4 Bytes) already read up front
     // to obtain the correct Frame Size in Bytes
     bool res = MP3FileIO::readByteData(fp, mp3FrameSizeInBytes - MP3_FRAME_HEADER_SIZE, buf);
@@ -1559,6 +1747,10 @@
 
 /***********************************************************************
  * FUNCTION:    SeekToTimestamp
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32  MP3Parser::SeekToTimestamp(uint32 timestampInMsec)
 {
@@ -1580,12 +1772,25 @@
 
 /***********************************************************************
  * FUNCTION:    SeekPointFromTimestamp
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32 MP3Parser::SeekPointFromTimestamp(uint32 &timestamp)
 {
     uint32 seekPoint = 0;
     uint32 seekOffset = 0;
     OsclFloat percent = 0;
+    uint32 binNo = 0;
+
+    bool bUseTOCForRepos = false;
+
+    uint32 maxTSInTOC = iTOCFilledCount * iBinWidth;
+    if (iTOCFilledCount > 1 && (timestamp < maxTSInTOC || iDurationScanComplete))
+    {
+        bUseTOCForRepos = true;
+    }
 
     // XING - Use VBR TOC Header
     if ((mp3Type == EXINGType) && (iXingHeader.flags & TOC_FLAG))
@@ -1665,13 +1870,29 @@
         seekPoint -= (int)((OsclFloat)iVbriHeader.TOC[i-1] * (OsclFloat)(fraction)
                            / (OsclFloat)iVbriHeader.fTableEntry);
     }
+    else if (bUseTOCForRepos)
+    {
+        // Use TOC for calculating seek point.
+        OsclFloat fpc = (OsclFloat)timestamp / (OsclFloat)iClipDurationInMsec;
+        binNo = (uint32)(fpc * iTOCFilledCount);
+        uint32 TScurr = binNo * iBinWidth;
+        while (TScurr > timestamp)
+        {
+            binNo--;
+            TScurr = binNo * iBinWidth;
+        }
+
+        uint32 offsetDiff = iTOC[binNo+1] - iTOC[binNo];
+        uint32 tsDiff = timestamp - TScurr;
+        seekPoint = iTOC[binNo] + tsDiff * (offsetDiff / iBinWidth);
+    }
     else
     {
         /**
          * vbri and xing headers are not present. seek offset will be
          * calculated on the basis of average bit rate
          **/
-        uint32 avgBR = 0;
+        int32 avgBR = 0;
         if (fp->GetCPM())
         {
             avgBR = iAvgBitrateInbps;
@@ -1687,7 +1908,7 @@
                 avgBR = iAvgBitrateInbpsFromRandomScan;
             }
         }
-        seekPoint = (OsclFloat)(avgBR * (OsclFloat)timestamp) / 8000.0f;
+        seekPoint = (uint32)((OsclFloat)(avgBR * (OsclFloat)timestamp) / 8000.0f);
     }
 
     /**
@@ -1698,10 +1919,17 @@
     **/
     if (seekPoint > 0 && !fp->GetCPM())
     {
-        uint32 retVal = mp3FindSync(StartOffset + seekPoint, seekOffset);
+        uint32 retVal = mp3FindSync(seekPoint + StartOffset, seekOffset);
         if (retVal == MP3_SUCCESS)
         {
             seekPoint += seekOffset;
+            MP3Utils::SeektoOffset(fp, seekPoint);
+
+            if (iDurationScanComplete)
+            {
+                uint32 offsetDiff = iTOC[binNo+1] - iTOC[binNo];
+                timestamp = (binNo * iBinWidth) + (iBinWidth * (seekPoint - iTOC[binNo]) / offsetDiff);
+            }
         }
         else if (retVal == MP3_INSUFFICIENT_DATA || retVal == MP3_END_OF_FILE)
         {
@@ -1725,7 +1953,7 @@
     {
         if (iMP3ConfigInfo.FrameSizeUnComp > 0  && iMP3ConfigInfo.SamplingRate > 0)
         {
-            iCurrFrameNumber = timestamp * (iMP3ConfigInfo.SamplingRate / iMP3ConfigInfo.FrameSizeUnComp) / 1000.00f;
+            iCurrFrameNumber = (int32)(timestamp * (iMP3ConfigInfo.SamplingRate / iMP3ConfigInfo.FrameSizeUnComp) / 1000.00f);
         }
     }
     else
@@ -1743,23 +1971,19 @@
  * DESCRIPTION: This function reads the whole file searching for a sync
  *				word. Once it finds one, it check for 4 continuous sync
  *				words to avoid a false synchronization
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3ErrorType MP3Parser::mp3FindSync(uint32 seekPoint, uint32 &syncOffset, PVFile* aFile)
 {
-    PVFile* fpused = fp;
-    if (aFile)
-    {
-        fpused = aFile;
-    }
     iMaxSyncBufferSize = 627;   /* default for 192 kbps, 44.1 kHz */
 
     if (!aFile)
     {
-        if (fpused->GetCPM() != NULL)
+        if (fp->GetCPM() != NULL)
         {
-            uint32 temp = 0;
-            iLocalFileSizeSet = (int32)MP3Utils::getCurrentFileSize(fpused, temp);
-            iLocalFileSize = (int32)temp;
+            iLocalFileSizeSet = (int32)MP3Utils::getCurrentFileSize(fp, iLocalFileSize);
         }
 
         uint32 contentLength = MP3FileIO::getContentLength(fp);
@@ -1791,13 +2015,26 @@
         return MP3_ERROR_UNKNOWN;  /* buffer couldn't be allocated */
     }
 
+    PVFile* fpused = (aFile) ? aFile : fp;
     uint32 i = 0;
     uint32 j = 0;
     uint32 BufferSize = 0;
     pSyncBuffer[0] = 0;
     bool syncFound = false;
     MP3ErrorType mp3Err = MP3_SUCCESS;
-    uint32 b = OSCL_MIN(iInitSearchFileSize, iLocalFileSize - seekPoint);
+    uint32 b = 0;
+    if (iLocalFileSizeSet)
+    {
+        b = OSCL_MIN(iInitSearchFileSize, iLocalFileSize - seekPoint);
+    }
+    else
+    {
+        uint32 remBytes = 0;
+        if (fp->GetRemainingBytes(remBytes))
+        {
+            b = OSCL_MAX(iInitSearchFileSize, fpused->Tell() + remBytes - seekPoint);
+        }
+    }
 
     for (j = 0; j < b; j += iMaxSyncBufferSize)
     {
@@ -1805,13 +2042,21 @@
         MP3ErrorType err = MP3Utils::SeektoOffset(fpused, seekPoint + j);
         if (MP3_SUCCESS != err)
         {
+            if (pSyncBuffer)
+            {
+                OSCL_ARRAY_DELETE(pSyncBuffer);
+                pSyncBuffer = NULL;
+            }
             return err;
         }
 
         if (!MP3FileIO::readByteData(fpused, iMaxSyncBufferSize, &pSyncBuffer[1], &BufferSize))
         {
-            OSCL_ARRAY_DELETE(pSyncBuffer);
-            pSyncBuffer = NULL;
+            if (pSyncBuffer)
+            {
+                OSCL_ARRAY_DELETE(pSyncBuffer);
+                pSyncBuffer = NULL;
+            }
             return MP3_ERROR_UNKNOWN_OBJECT;
         }
         // Find the first Sync Marker by doing a byte by byte search.
@@ -1825,20 +2070,24 @@
             {
                 if (pSyncBuffer[i] == 0xFF)
                 {
-                    uint32 currPos = MP3Utils::getCurrentFilePosition(fpused);
                     // MPEG 1, 2
                     if ((pSyncBuffer[i+1] & 0xF0) == 0xF0)
                     {
                         // if partial match is found verify that 4 consecutives sync word are valid
+                        int32 currPos = fpused->Tell();
                         mp3Err = IsValidFrame(&(pSyncBuffer[i]), j + i - 1, seekPoint, fpused);
+                        fpused->Seek(currPos, Oscl_File::SEEKSET);
                         if (mp3Err == MP3_SUCCESS)
                         {
                             break;
                         }
                         else if (mp3Err == MP3_INSUFFICIENT_DATA)
                         {
-                            OSCL_ARRAY_DELETE(pSyncBuffer);
-                            pSyncBuffer = NULL;
+                            if (pSyncBuffer)
+                            {
+                                OSCL_ARRAY_DELETE(pSyncBuffer);
+                                pSyncBuffer = NULL;
+                            }
                             return mp3Err;
                         }
                         else
@@ -1850,15 +2099,21 @@
                     else if ((pSyncBuffer[i+1] & 0xF0) == 0xE0)
                     {
                         // if partial match is found verify that 4 consecutives sync word are valid
+                        int32 currPos = fpused->Tell();
                         mp3Err = IsValidFrame(&(pSyncBuffer[i]), j + i - 1, seekPoint, fpused);
+                        fpused->Seek(currPos, Oscl_File::SEEKSET);
+
                         if (mp3Err == MP3_SUCCESS)
                         {
                             break;
                         }
                         else if (mp3Err == MP3_INSUFFICIENT_DATA)
                         {
-                            OSCL_ARRAY_DELETE(pSyncBuffer);
-                            pSyncBuffer = NULL;
+                            if (pSyncBuffer)
+                            {
+                                OSCL_ARRAY_DELETE(pSyncBuffer);
+                                pSyncBuffer = NULL;
+                            }
                             return mp3Err;
                         }
                         else
@@ -1892,8 +2147,20 @@
         return MP3_END_OF_FILE;  /* File does not have any valid sync word */
     }
 
-    /* One valid frame was found -> reset initial size to file size */
-    iInitSearchFileSize = iLocalFileSize;
+    if (iLocalFileSizeSet)
+    {
+        /* One valid frame was found -> reset initial size to file size */
+        iInitSearchFileSize = iLocalFileSize;
+    }
+    else
+    {
+        uint32 remBytes = 0;
+        if (fp->GetRemainingBytes(remBytes))
+        {
+            /* One valid frame was found -> reset initial size remaining file size*/
+            iInitSearchFileSize = OSCL_MIN(iInitSearchFileSize, remBytes);
+        }
+    }
 
     syncOffset = j + i - 1;  /*  set offset */
     return MP3_SUCCESS;
@@ -1902,6 +2169,10 @@
 
 /***********************************************************************
  * FUNCTION:   IsValidFrame
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3ErrorType MP3Parser::IsValidFrame(uint8 * pBuffer,
                                      uint32 offset,
@@ -1922,6 +2193,9 @@
  *				of the following 3 headers. Then, if the sampling frequencies
  *				and number of channels match for all headers, the frame header
  *				is considered valid
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3ErrorType MP3Parser::IsValidFrameHeader(uint8 *mp3Frame,
         bool &bCRCPresent,
@@ -1940,6 +2214,7 @@
     MP3ConfigInfoType mp3CDInfo3 = {0, 0, 0, 0, 0};
     MP3ConfigInfoType mp3CDInfo4 = {0, 0, 0, 0, 0};
     int32 offset, flength;
+    bool status;
 
     uint32 mp3Header = SwapFileToHostByteOrderInt32(mp3Frame);
 
@@ -1964,7 +2239,6 @@
      *  really latch on a valid sync word
      */
     offset = mp3CDInfo.FrameLengthInBytes;
-    uint32 currFileSize = 0;
     MP3ErrorType err = MP3Utils::SeektoOffset(fpUsed, seekPoint + firstSyncOffset + offset);
     if (MP3_SUCCESS != err)
     {
@@ -1978,15 +2252,8 @@
 
     mp3Header = SwapFileToHostByteOrderInt32((uint8 *) & mp3Header);
 
-    if (!GetMP3Header(mp3Header, mp3HeaderInfo))
-    {
-        return MP3_FILE_HDR_READ_ERR;
-    }
-
-    if (!DecodeMP3Header(mp3HeaderInfo, mp3CDInfo2, false))
-    {
-        return MP3_FILE_HDR_READ_ERR;
-    }
+    status = GetMP3Header(mp3Header, mp3HeaderInfo);
+    status = DecodeMP3Header(mp3HeaderInfo, mp3CDInfo2, false);
 
     flength = mp3CDInfo2.FrameLengthInBytes;
     offset += flength;
@@ -2005,15 +2272,8 @@
 
     mp3Header = SwapFileToHostByteOrderInt32((uint8 *) & mp3Header);
 
-    if (!GetMP3Header(mp3Header, mp3HeaderInfo))
-    {
-        return MP3_FILE_HDR_READ_ERR;
-    }
-
-    if (!DecodeMP3Header(mp3HeaderInfo, mp3CDInfo3, false))
-    {
-        return MP3_FILE_HDR_READ_ERR;
-    }
+    status = GetMP3Header(mp3Header, mp3HeaderInfo);
+    status = DecodeMP3Header(mp3HeaderInfo, mp3CDInfo3, false);
 
     offset += mp3CDInfo3.FrameLengthInBytes;
 
@@ -2031,15 +2291,8 @@
 
     mp3Header = SwapFileToHostByteOrderInt32((uint8 *) & mp3Header);
 
-    if (!GetMP3Header(mp3Header, mp3HeaderInfo))
-    {
-        return MP3_FILE_HDR_READ_ERR;
-    }
-
-    if (!DecodeMP3Header(mp3HeaderInfo, mp3CDInfo4, false))
-    {
-        return MP3_FILE_HDR_READ_ERR;
-    }
+    status = GetMP3Header(mp3Header, mp3HeaderInfo);
+    status = DecodeMP3Header(mp3HeaderInfo, mp3CDInfo4, false);
 
 
     /*
@@ -2065,8 +2318,11 @@
 
 /***********************************************************************
  * FUNCTION:   mp3VerifyCRC
+ * DESCRIPTION:
  * INPUT/OUTPUT PARAMETERS: verifies the crc if crc check is enabled and
  *							crc flag is present
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 MP3ErrorType MP3Parser::mp3VerifyCRC(MP3HeaderType mp3HdrInfo, MP3ConfigInfoType mp3CI)
 {
@@ -2092,6 +2348,7 @@
         case MPEG_LAYER_II:
             // no check for Layer II
             return MP3_SUCCESS;
+
         case MPEG_LAYER_III:
             numberOfBits = (mp3HdrInfo.frameVer == FRAME_VESION_MPEG_1) ?
                            (mp3HdrInfo.chMode == CHANNEL_MODE_MONO ? 17 * 8 : 32 * 8) :
@@ -2190,6 +2447,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetSampleCountInFile
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32 MP3Parser::GetSampleCountInFile()
 {
@@ -2198,6 +2459,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetMaximumDecodeBufferSize
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32 MP3Parser::GetMaximumDecodeBufferSize()
 {
@@ -2234,6 +2499,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetFileSize
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32 MP3Parser::GetFileSize()
 {
@@ -2242,6 +2511,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetTimestampForCurrentSample
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32 MP3Parser::GetTimestampForCurrentSample() const
 {
@@ -2259,6 +2532,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetDecoderSpecificInfoSize
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint32  MP3Parser::GetDecoderSpecificInfoSize()
 {
@@ -2267,6 +2544,10 @@
 
 /***********************************************************************
  * FUNCTION:    GetDecoderSpecificInfoContent
+ * DESCRIPTION:
+ * INPUT/OUTPUT PARAMETERS:
+ * RETURN VALUE:
+ * SIDE EFFECTS:
  ***********************************************************************/
 uint8 const * MP3Parser::GetDecoderSpecificInfoContent() const
 {
@@ -2300,13 +2581,13 @@
  * 			   aInitSearchFileSize, amount of data to use for verification
  *  Output	 : None
  *	Return   : error code
+ *	Modified :
  ***********************************************************************/
 MP3ErrorType MP3Parser::IsMp3File(MP3_FF_FILE* aFile, uint32 aInitSearchFileSize)
 {
     MP3ErrorType errCode = MP3_SUCCESS;
     uint8 pFrameHeader[MP3_FRAME_HEADER_SIZE];
     uint32 firstHeader = 0;
-    iLocalFileSizeSet = true;
 
     // get the file pointer
     fp = &(aFile->_pvfile);
@@ -2315,6 +2596,7 @@
     int32 err = fp->Seek(0, Oscl_File::SEEKEND);
     if (err == 0)
     {
+        iLocalFileSizeSet = true;
         iLocalFileSize =  MP3Utils::getCurrentFilePosition(fp);
         if (iLocalFileSize == 0)
         {
@@ -2326,7 +2608,18 @@
         iLocalFileSize = 0;
     }
     //set the initial file search size
-    iInitSearchFileSize = OSCL_MIN(aInitSearchFileSize, iLocalFileSize);
+    if (iLocalFileSizeSet)
+    {
+        iInitSearchFileSize = OSCL_MIN(aInitSearchFileSize, iLocalFileSize);
+    }
+    else
+    {
+        uint32 remBytes = 0;
+        if (fp->GetRemainingBytes(remBytes))
+        {
+            iInitSearchFileSize = OSCL_MIN(iInitSearchFileSize, remBytes);
+        }
+    }
 
     // seek to the begining position in the file
     fp->Seek(0, Oscl_File::SEEKSET);
@@ -2431,6 +2724,7 @@
  *	Return   : error code
  *  Input	 : aFileSize
  *  Output	 : None
+ *	Modified :
  ***********************************************************************/
 MP3ErrorType MP3Parser::SetFileSize(const uint32 aFileSize)
 {
@@ -2445,6 +2739,7 @@
  *	Return   : error code
  *	Input	 : None
  *	Output	 : Clip duration
+ *	Modified :
  **/
 MP3ErrorType MP3Parser::EstimateDurationFromExternalFileSize(uint32 &aClipDuration)
 {
@@ -2477,7 +2772,7 @@
         return MP3_SUCCESS;
     }
 
-    iClipDurationFromEstimation = (OsclFloat)(fileSize * 8000.00f / iAvgBitrateInbps);
+    iClipDurationFromEstimation = (uint32)((OsclFloat)(fileSize * 8000.00f / iAvgBitrateInbps));
     aClipDuration = iClipDurationFromEstimation;
     return MP3_SUCCESS;
 }
@@ -2488,6 +2783,7 @@
  *	Return   : error code
  *	Input	 : None
  *	Output	 : Clip duration
+ *	Modified :
  ***********************************************************************/
 MP3ErrorType MP3Parser::GetDurationFromVBRIHeader(uint32 &aClipDuration)
 {
@@ -2514,10 +2810,7 @@
         return MP3_ERROR_UNKNOWN;
     }
 
-    int32 samplesPerFrame = spfIndexTable[iMP3HeaderInfo.frameVer][iMP3HeaderInfo.layerID];
-    int32 samplingRate = srIndexTable[((iMP3HeaderInfo.frameVer)*4) + iMP3HeaderInfo.srIndex];
-
-    iClipDurationFromVBRIHeader = iNumberOfFrames * samplesPerFrame / samplingRate * 1000;
+    iClipDurationFromVBRIHeader = iNumberOfFrames * iSamplesPerFrame / iSamplingRate * 1000;
     aClipDuration = iClipDurationFromVBRIHeader;
     return MP3_SUCCESS;
 }
@@ -2530,6 +2823,7 @@
  *	Return   : error code
  *	Input	 : None
  *	Output	 : Clip duration
+ *	Modified :
  ***********************************************************************/
 MP3ErrorType MP3Parser::GetDurationFromRandomScan(uint32 &aClipDuration)
 {
@@ -2544,7 +2838,7 @@
     if (MP3_ERROR_UNKNOWN != ComputeDurationFromNRandomFrames(fp))
     {
         uint32 fileSz = iLocalFileSize - iTagSize;
-        iClipDurationFromRandomScan =  fileSz * 8000.00f / iAvgBitrateInbpsFromRandomScan;
+        iClipDurationFromRandomScan = (uint32)(fileSz * 8000.00f / iAvgBitrateInbpsFromRandomScan);
         aClipDuration = iClipDurationFromRandomScan;
         MP3ErrorType status = MP3Utils::SeektoOffset(fp, currFilePos);
         return status;
@@ -2560,17 +2854,17 @@
  *	Return   : error code
  *	Input	 : numFrames
  *	Output	 : iAvgBitrateInbpsFromRandomScan
+ *	Modified :
  ***********************************************************************/
 MP3ErrorType MP3Parser::ComputeDurationFromNRandomFrames(PVFile * fpUsed, int32 aNumFrames, int32 aNumRandomLoc)
 {
     uint32 firstHeader = 0;
     uint8 pFrameHeader[MP3_FRAME_HEADER_SIZE];
-    int32 startOffset = 0;
+    uint32 startOffset = 0;
     int32 totBR = 0;
-    int32 avgBR = 0;
     int32 avgBitRate = 0;
     int32 framecount = 0;
-    int32 randomByteOffset = 0;
+    uint32 randomByteOffset = 0;
     int32 audioDataSize = 0;
     MP3HeaderType mp3HeaderInfo;
     MP3ConfigInfoType mp3ConfigInfo;
@@ -2656,21 +2950,10 @@
                 avgBitRate += (mp3ConfigInfo.BitRate - avgBitRate) / framecount;
             }
         }
-
         totBR += avgBitRate;
-        if (avgBR <= 0)
-        {
-            avgBR = avgBitRate;
-        }
-
-        if (avgBR != avgBitRate)
-        {
-            avgBR = (avgBR + avgBitRate) / 2;
-            mp3Type = EVBRType;
-        }
-
         numSearchLoc++;
     }
+    // calculate average bitrate
     iAvgBitrateInbpsFromRandomScan = totBR / numSearchLoc;
     if (!iAvgBitrateInbpsFromRandomScan)
     {
@@ -2686,13 +2969,55 @@
         aClipDuration = iClipDurationComputed;
         return;
     }
+    uint32 samplesPerFrame = spfIndexTable[iMP3HeaderInfo.frameVer][iMP3HeaderInfo.layerID];
+    uint32 samplingRate = srIndexTable[((iMP3HeaderInfo.frameVer)*4) + iMP3HeaderInfo.srIndex];
+    OsclFloat samplingRateinKHz = (OsclFloat)samplingRate / 1000;
 
-    uint32 audioDataSz = iLocalFileSize - iTagSize;
-    if (iId3TagParser.IsID3V1Present())
-    {
-        // The TAG in an ID3V1.x MP3 File is 128 bytes long
-        audioDataSz -= 128;
-    }
-    iClipDurationComputed = (int32)((OsclFloat)(audioDataSz * 8000.0f) / iAvgBitrateInbpsFromCompleteScan);
+    iClipDurationComputed = (uint32)(iScannedFrameCount * (OsclFloat)(samplesPerFrame / samplingRateinKHz));
     aClipDuration = iClipDurationComputed;
 }
+
+void MP3Parser::FillTOCTable(uint32 aFilePos, uint32 aTimeStampToFrame)
+{
+    if (iDurationScanComplete)
+    {
+        iTOC[iTOCFilledCount] = aFilePos;
+        iTOCFilledCount++;
+        if (0 == iTimestampPrev)
+        {
+            GetDurationFromCompleteScan(iBinWidth);
+        }
+        return;
+    }
+
+    if ((iTOCFilledCount < MAX_TOC_ENTRY_COUNT) && ((aTimeStampToFrame - iTimestampPrev) >= iBinWidth))
+    {
+        if (iTimestampPrev != aTimeStampToFrame)
+        {
+            if ((aTimeStampToFrame - iTimestampPrev) > iBinWidth)
+            {
+                iBinWidth = aTimeStampToFrame - iTimestampPrev;
+            }
+        }
+        // push the file offset into TOC table
+        iTOC[iTOCFilledCount] = aFilePos - StartOffset;
+        iTOCFilledCount++;
+        iTimestampPrev = aTimeStampToFrame;
+    }
+    else if (iTOCFilledCount == MAX_TOC_ENTRY_COUNT)
+    {
+        // run the compaction algorithm to compress the TOC table
+        for (uint32 i = 0; i < (MAX_TOC_ENTRY_COUNT / 2); i++)
+        {
+            iTOC[i] = iTOC[2*i];
+        }
+        iTimestampPrev = iTimestampPrev - iBinWidth;
+        iBinWidth = 2 * iBinWidth;
+        iTOCFilledCount = MAX_TOC_ENTRY_COUNT / 2;
+        return;
+    }
+}
+
+
+
+
diff --git a/fileformats/mp3/parser/src/mp3utils.cpp b/fileformats/mp3/parser/src/mp3utils.cpp
index c2c30e2..39423b4 100644
--- a/fileformats/mp3/parser/src/mp3utils.cpp
+++ b/fileformats/mp3/parser/src/mp3utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,9 +19,7 @@
 /*
     This MP3Utils Class contains sime useful methods for operating FILE
 */
-
-
-//#define IMPLEMENT_MP3Utils
+/*********************************************************************************/
 
 #include "mp3utils.h"
 #include "oscl_base.h"
@@ -78,21 +76,20 @@
         {
             uint32 currPos = (uint32)(fp->Tell());
             aCurrentSize = currPos + aRemBytes;
-
             return true;
         }
     }
     return false;
 }
 
-MP3ErrorType MP3Utils::SeektoOffset(PVFile *fp, int32 offset)
+MP3ErrorType MP3Utils::SeektoOffset(PVFile *aFP, int32 aOffset)
 {
     uint32 currFileSize = 0;
-    if (MP3Utils::getCurrentFileSize(fp, currFileSize))
+    if (MP3Utils::getCurrentFileSize(aFP, currFileSize))
     {
-        if (currFileSize >= offset)
+        if (currFileSize >= (uint32)aOffset)
         {
-            if (fp->Seek(offset, Oscl_File::SEEKSET) != 0)
+            if (aFP->Seek(aOffset, Oscl_File::SEEKSET) != 0)
             {
                 return MP3_FILE_READ_ERR;
             }
diff --git a/fileformats/mp4/composer/Android.mk b/fileformats/mp4/composer/Android.mk
index b31d1b1..45cba0f 100644
--- a/fileformats/mp4/composer/Android.mk
+++ b/fileformats/mp4/composer/Android.mk
@@ -3,106 +3,104 @@
 
 LOCAL_SRC_FILES := \
 	src/amrdecoderspecificinfo.cpp \
-	src/amrdecoderspecificinfo3gpp.cpp \
-	src/amrsampleentry.cpp \
-	src/assetinfoatoms.cpp \
-	src/atom.cpp \
-	src/atomutils.cpp \
-	src/audiosampleentry.cpp \
-	src/avcconfiguration.cpp \
-	src/avcsampleentry.cpp \
-	src/basecommand.cpp \
-	src/basedescriptor.cpp \
-	src/chunkoffsetatom.cpp \
-	src/dataentryatom.cpp \
-	src/dataentryurlatom.cpp \
-	src/datainformationatom.cpp \
-	src/datareferenceatom.cpp \
-	src/decoderconfigdescriptor.cpp \
-	src/decoderspecificinfo.cpp \
-	src/editatom.cpp \
-	src/editlistatom.cpp \
-	src/esdatom.cpp \
-	src/esdescriptor.cpp \
-	src/es_id_inc.cpp \
-	src/es_id_ref.cpp \
-	src/expandablebaseclass.cpp \
-	src/filetypeatom.cpp \
-	src/fullatom.cpp \
-	src/h263decoderspecificinfo.cpp \
-	src/h263decoderspecificinfo3gpp.cpp \
-	src/h263sampleentry.cpp \
-	src/handleratom.cpp \
-	src/hintmediaheaderatom.cpp \
-	src/impeg4file.cpp \
-	src/initialobjectdescriptor.cpp \
-	src/mediaatom.cpp \
-	src/mediadataatom.cpp \
-	src/mediaheaderatom.cpp \
-	src/mediainformationatom.cpp \
-	src/mediainformationheaderatom.cpp \
-	src/movieatom.cpp \
-	src/movieheaderatom.cpp \
-	src/mpeg4file.cpp \
-	src/mpeg4mediaheaderatom.cpp \
-	src/mpegsampleentry.cpp \
-	src/objectdescriptor.cpp \
-	src/objectdescriptoratom.cpp \
-	src/objectdescriptorupdate.cpp \
-	src/sampledescriptionatom.cpp \
-	src/sampleentry.cpp \
-	src/samplesizeatom.cpp \
-	src/sampletableatom.cpp \
-	src/sampletochunkatom.cpp \
-	src/slconfigdescriptor.cpp \
-	src/soundmediaheaderatom.cpp \
-	src/syncsampleatom.cpp \
-	src/timetosampleatom.cpp \
-	src/trackatom.cpp \
-	src/trackheaderatom.cpp \
-	src/trackreferenceatom.cpp \
-	src/trackreferencetypeatom.cpp \
-	src/userdataatom.cpp \
-	src/videomediaheaderatom.cpp \
-	src/visualsampleentry.cpp \
-	src/textsampleentry.cpp \
-	src/boxrecord.cpp \
-	src/fontrecord.cpp \
-	src/fonttableatom.cpp \
-	src/stylerecord.cpp \
-	src/interleavebuffer.cpp \
-	src/movieextendsatom.cpp \
-	src/movieextendsheaderatom.cpp \
-	src/moviefragmentatom.cpp \
-	src/moviefragmentheaderatom.cpp \
-	src/moviefragmentrandomaccessatom.cpp \
-	src/moviefragmentrandomaccessoffsetatom.cpp \
-	src/trackextendsatom.cpp \
-	src/trackfragmentatom.cpp \
-	src/trackfragmentheaderatom.cpp \
-	src/trackfragmentrandomaccessatom.cpp \
-	src/trackfragmentrunatom.cpp
-
+ 	src/amrdecoderspecificinfo3gpp.cpp \
+ 	src/amrsampleentry.cpp \
+ 	src/assetinfoatoms.cpp \
+ 	src/atom.cpp \
+ 	src/atomutils.cpp \
+ 	src/audiosampleentry.cpp \
+ 	src/avcconfiguration.cpp \
+ 	src/avcsampleentry.cpp \
+ 	src/basedescriptor.cpp \
+ 	src/chunkoffsetatom.cpp \
+ 	src/dataentryatom.cpp \
+ 	src/dataentryurlatom.cpp \
+ 	src/datainformationatom.cpp \
+ 	src/datareferenceatom.cpp \
+ 	src/decoderconfigdescriptor.cpp \
+ 	src/decoderspecificinfo.cpp \
+ 	src/editatom.cpp \
+ 	src/editlistatom.cpp \
+ 	src/esdatom.cpp \
+ 	src/esdescriptor.cpp \
+ 	src/es_id_inc.cpp \
+ 	src/es_id_ref.cpp \
+ 	src/expandablebaseclass.cpp \
+ 	src/filetypeatom.cpp \
+ 	src/fullatom.cpp \
+ 	src/h263decoderspecificinfo.cpp \
+ 	src/h263decoderspecificinfo3gpp.cpp \
+ 	src/h263sampleentry.cpp \
+ 	src/handleratom.cpp \
+ 	src/hintmediaheaderatom.cpp \
+ 	src/impeg4file.cpp \
+ 	src/mediaatom.cpp \
+ 	src/mediadataatom.cpp \
+ 	src/mediaheaderatom.cpp \
+ 	src/mediainformationatom.cpp \
+ 	src/mediainformationheaderatom.cpp \
+ 	src/movieatom.cpp \
+ 	src/movieheaderatom.cpp \
+ 	src/mpeg4file.cpp \
+ 	src/mpeg4mediaheaderatom.cpp \
+ 	src/mpegsampleentry.cpp \
+ 	src/sampledescriptionatom.cpp \
+ 	src/sampleentry.cpp \
+ 	src/samplesizeatom.cpp \
+ 	src/sampletableatom.cpp \
+ 	src/sampletochunkatom.cpp \
+ 	src/slconfigdescriptor.cpp \
+ 	src/soundmediaheaderatom.cpp \
+ 	src/syncsampleatom.cpp \
+ 	src/timetosampleatom.cpp \
+ 	src/trackatom.cpp \
+ 	src/trackheaderatom.cpp \
+ 	src/trackreferenceatom.cpp \
+ 	src/trackreferencetypeatom.cpp \
+ 	src/userdataatom.cpp \
+ 	src/videomediaheaderatom.cpp \
+ 	src/visualsampleentry.cpp \
+ 	src/textsampleentry.cpp \
+ 	src/boxrecord.cpp \
+ 	src/fontrecord.cpp \
+ 	src/fonttableatom.cpp \
+ 	src/stylerecord.cpp \
+ 	src/interleavebuffer.cpp \
+ 	src/movieextendsatom.cpp \
+ 	src/movieextendsheaderatom.cpp \
+ 	src/moviefragmentatom.cpp \
+ 	src/moviefragmentheaderatom.cpp \
+ 	src/moviefragmentrandomaccessatom.cpp \
+ 	src/moviefragmentrandomaccessoffsetatom.cpp \
+ 	src/trackextendsatom.cpp \
+ 	src/trackfragmentatom.cpp \
+ 	src/trackfragmentheaderatom.cpp \
+ 	src/trackfragmentrandomaccessatom.cpp \
+ 	src/trackfragmentrunatom.cpp
 
 
 LOCAL_MODULE := libpvmp4ffcomposer
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/mp4/composer/include \
-	$(PV_TOP)//fileformats/mp4/composer/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/mp4/composer/src \
+ 	$(PV_TOP)/fileformats/mp4/composer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/a_impeg4file.h \
-	include/a_isucceedfail.h \
-	include/a_atomdefs.h \
-	include/textsampledescinfo.h \
-	include/../config/opencore/pv_mp4ffcomposer_config.h
+ 	include/a_isucceedfail.h \
+ 	include/a_atomdefs.h \
+ 	include/textsampledescinfo.h \
+ 	include/../config/opencore/pv_mp4ffcomposer_config.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/mp4/composer/build_opencore/make/local.mk b/fileformats/mp4/composer/build_opencore/make/local.mk
new file mode 100644
index 0000000..8cfa85c
--- /dev/null
+++ b/fileformats/mp4/composer/build_opencore/make/local.mk
@@ -0,0 +1,103 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4ffcomposer
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := amrdecoderspecificinfo.cpp \
+	amrdecoderspecificinfo3gpp.cpp \
+	amrsampleentry.cpp \
+    assetinfoatoms.cpp \
+	atom.cpp \
+	atomutils.cpp \
+	audiosampleentry.cpp \
+	avcconfiguration.cpp \
+	avcsampleentry.cpp \
+	basedescriptor.cpp \
+	chunkoffsetatom.cpp \
+	dataentryatom.cpp \
+	dataentryurlatom.cpp \
+	datainformationatom.cpp \
+	datareferenceatom.cpp \
+	decoderconfigdescriptor.cpp \
+	decoderspecificinfo.cpp \
+	editatom.cpp \
+	editlistatom.cpp \
+	esdatom.cpp \
+	esdescriptor.cpp \
+	es_id_inc.cpp \
+	es_id_ref.cpp \
+	expandablebaseclass.cpp \
+	filetypeatom.cpp \
+	fullatom.cpp \
+	h263decoderspecificinfo.cpp \
+	h263decoderspecificinfo3gpp.cpp \
+	h263sampleentry.cpp \
+	handleratom.cpp \
+	hintmediaheaderatom.cpp \
+	impeg4file.cpp \
+	mediaatom.cpp \
+	mediadataatom.cpp \
+	mediaheaderatom.cpp \
+	mediainformationatom.cpp \
+	mediainformationheaderatom.cpp \
+	movieatom.cpp \
+	movieheaderatom.cpp \
+	mpeg4file.cpp \
+	mpeg4mediaheaderatom.cpp \
+	mpegsampleentry.cpp \
+	sampledescriptionatom.cpp \
+	sampleentry.cpp \
+	samplesizeatom.cpp \
+	sampletableatom.cpp \
+	sampletochunkatom.cpp \
+	slconfigdescriptor.cpp \
+	soundmediaheaderatom.cpp \
+	syncsampleatom.cpp \
+	timetosampleatom.cpp \
+	trackatom.cpp \
+	trackheaderatom.cpp \
+	trackreferenceatom.cpp \
+	trackreferencetypeatom.cpp \
+	userdataatom.cpp \
+	videomediaheaderatom.cpp \
+	visualsampleentry.cpp \
+	textsampleentry.cpp \
+	boxrecord.cpp \
+	fontrecord.cpp \
+	fonttableatom.cpp \
+	stylerecord.cpp \
+	interleavebuffer.cpp \
+	movieextendsatom.cpp \
+	movieextendsheaderatom.cpp \
+	moviefragmentatom.cpp \
+	moviefragmentheaderatom.cpp \
+	moviefragmentrandomaccessatom.cpp \
+	moviefragmentrandomaccessoffsetatom.cpp \
+	trackextendsatom.cpp \
+	trackfragmentatom.cpp \
+	trackfragmentheaderatom.cpp \
+	trackfragmentrandomaccessatom.cpp \
+	trackfragmentrunatom.cpp
+	
+HDRS := a_impeg4file.h \
+       a_isucceedfail.h \
+       a_atomdefs.h \
+       textsampledescinfo.h \
+       ../config/opencore/pv_mp4ffcomposer_config.h
+
+
+include $(MK)/library.mk
diff --git a/fileformats/mp4/composer/build_opencore/make/makefile b/fileformats/mp4/composer/build_opencore/make/makefile
deleted file mode 100644
index 6b61aa7..0000000
--- a/fileformats/mp4/composer/build_opencore/make/makefile
+++ /dev/null
@@ -1,138 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4ffcomposer
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-#XINCDIRS += 
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  amrdecoderspecificinfo.cpp \
-	amrdecoderspecificinfo3gpp.cpp \
-	amrsampleentry.cpp \
-    assetinfoatoms.cpp \
-	atom.cpp \
-	atomutils.cpp \
-	audiosampleentry.cpp \
-	avcconfiguration.cpp \
-	avcsampleentry.cpp \
-	basecommand.cpp \
-	basedescriptor.cpp \
-	chunkoffsetatom.cpp \
-	dataentryatom.cpp \
-	dataentryurlatom.cpp \
-	datainformationatom.cpp \
-	datareferenceatom.cpp \
-	decoderconfigdescriptor.cpp \
-	decoderspecificinfo.cpp \
-	editatom.cpp \
-	editlistatom.cpp \
-	esdatom.cpp \
-	esdescriptor.cpp \
-	es_id_inc.cpp \
-	es_id_ref.cpp \
-	expandablebaseclass.cpp \
-	filetypeatom.cpp \
-	fullatom.cpp \
-	h263decoderspecificinfo.cpp \
-	h263decoderspecificinfo3gpp.cpp \
-	h263sampleentry.cpp \
-	handleratom.cpp \
-	hintmediaheaderatom.cpp \
-	impeg4file.cpp \
-	initialobjectdescriptor.cpp \
-	mediaatom.cpp \
-	mediadataatom.cpp \
-	mediaheaderatom.cpp \
-	mediainformationatom.cpp \
-	mediainformationheaderatom.cpp \
-	movieatom.cpp \
-	movieheaderatom.cpp \
-	mpeg4file.cpp \
-	mpeg4mediaheaderatom.cpp \
-	mpegsampleentry.cpp \
-	objectdescriptor.cpp \
-	objectdescriptoratom.cpp \
-	objectdescriptorupdate.cpp \
-	sampledescriptionatom.cpp \
-	sampleentry.cpp \
-	samplesizeatom.cpp \
-	sampletableatom.cpp \
-	sampletochunkatom.cpp \
-	slconfigdescriptor.cpp \
-	soundmediaheaderatom.cpp \
-	syncsampleatom.cpp \
-	timetosampleatom.cpp \
-	trackatom.cpp \
-	trackheaderatom.cpp \
-	trackreferenceatom.cpp \
-	trackreferencetypeatom.cpp \
-	userdataatom.cpp \
-	videomediaheaderatom.cpp \
-	visualsampleentry.cpp \
-	textsampleentry.cpp \
-	boxrecord.cpp \
-	fontrecord.cpp \
-	fonttableatom.cpp \
-	stylerecord.cpp \
-	interleavebuffer.cpp \
-	movieextendsatom.cpp \
-	movieextendsheaderatom.cpp \
-	moviefragmentatom.cpp \
-	moviefragmentheaderatom.cpp \
-	moviefragmentrandomaccessatom.cpp \
-	moviefragmentrandomaccessoffsetatom.cpp \
-	trackextendsatom.cpp \
-	trackfragmentatom.cpp \
-	trackfragmentheaderatom.cpp \
-	trackfragmentrandomaccessatom.cpp \
-	trackfragmentrunatom.cpp
-	
-HDRS = a_impeg4file.h \
-       a_isucceedfail.h \
-       a_atomdefs.h \
-       textsampledescinfo.h \
-       ../config/opencore/pv_mp4ffcomposer_config.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/fileformats/mp4/composer/config/opencore/pv_mp4ffcomposer_config.h b/fileformats/mp4/composer/config/opencore/pv_mp4ffcomposer_config.h
index 0f0ab4d..54c132d 100644
--- a/fileformats/mp4/composer/config/opencore/pv_mp4ffcomposer_config.h
+++ b/fileformats/mp4/composer/config/opencore/pv_mp4ffcomposer_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/a_atomdefs.h b/fileformats/mp4/composer/include/a_atomdefs.h
index 2a98d20..32d562f 100644
--- a/fileformats/mp4/composer/include/a_atomdefs.h
+++ b/fileformats/mp4/composer/include/a_atomdefs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,6 +84,7 @@
 // *** Note that only HINT_PROTOCOL_TEMPORAL_SCALABILITY and HINT_PROTOCOL_BASE_LAYER_ONLY video protocols are supported in version 1.0 ***
 // 'pvau' - Audio encoding with simple hint track
 
+
 static const int32 OBJ_DESCR_TAG			= 0x1;
 static const int32 INITIAL_OBJ_DESCR_TAG	= 0x2;
 static const int32 ES_DESCR_TAG			= 0x3;
@@ -152,15 +153,6 @@
 const uint32    MEDIA_TYPE_VISUAL = FourCharConstToUint32('v', 'i', 'd', 'e');
 const uint32	MEDIA_TYPE_TEXT = FourCharConstToUint32('t', 'e', 'x', 't');
 
-const uint32    MEDIA_TYPE_OBJECT_DESCRIPTOR = FourCharConstToUint32('o', 'd', 's', 'm');
-const uint32    MEDIA_TYPE_CLOCK_REFERENCE = FourCharConstToUint32('c', 'r', 's', 'm');
-const uint32    MEDIA_TYPE_SCENE_DESCRIPTION = FourCharConstToUint32('s', 'd', 's', 'm');
-const uint32    MEDIA_TYPE_MPEG7 = FourCharConstToUint32('m', '7', 's', 'm');
-const uint32    MEDIA_TYPE_OBJECT_CONTENT_INFO = FourCharConstToUint32('o', 'c', 's', 'm');
-const uint32    MEDIA_TYPE_IPMP = FourCharConstToUint32('i', 'p', 's', 'm');
-const uint32    MEDIA_TYPE_MPEG_J = FourCharConstToUint32('m', 'j', 's', 'm');
-const uint32    MEDIA_TYPE_SCALABILITY = FourCharConstToUint32('p', 'v', 's', 'c');
-
 const uint32    MPEG_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 's');
 const uint32    AUDIO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'a');
 const uint32    VIDEO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'v');
@@ -196,6 +188,8 @@
 const uint32    ASSET_INFO_KEYWORD_ATOM = FourCharConstToUint32('k', 'y', 'w', 'd');
 const uint32    ASSET_INFO_LOCINFO_ATOM = FourCharConstToUint32('l', 'o', 'c', 'i');
 const uint32	ASSET_INFO_CPRT_ATOM =  FourCharConstToUint32('c', 'p', 'r', 't');
+const uint32	ASSET_INFO_ALBUM_TITLE_ATOM =  FourCharConstToUint32('a', 'l', 'b', 'm');
+const uint32	ASSET_INFO_RECORDING_YEAR_ATOM =  FourCharConstToUint32('y', 'r', 'r', 'c');
 
 // Movie fragment atoms
 const uint32    MOVIE_EXTENDS_ATOM = FourCharConstToUint32('m', 'v', 'e', 'x');
@@ -210,10 +204,6 @@
 const uint32    TRACK_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('t', 'f', 'r', 'a');
 const uint32    MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM = FourCharConstToUint32('m', 'f', 'r', 'o');
 
-// Allowable values of the hint type byte
-static const int32 HINT_SAMPLE_AUDIO = 0;
-static const int32 HINT_SAMPLE_VIDEO = 1;
-static const int32 HINT_SAMPLE_STILL_IMAGE = 2;
 // MORE TBA - add specific protocols into type value
 
 #define PVMM_VERSION  0x00010000
@@ -252,7 +242,7 @@
 #define MPEG4_SSP_L1   0x11
 #define MPEG4_SSP_L2   0x12
 
-#define MIN_NUM_MEDIA_TRACKS 2 // BIFS + OD
+#define MIN_NUM_MEDIA_TRACKS 0
 
 #define AMR_INTERLEAVE_BUFFER_SIZE    2048
 #define AAC_INTERLEAVE_BUFFER_SIZE   12000  // Calc with 96 Kbps as max
diff --git a/fileformats/mp4/composer/include/a_impeg4file.h b/fileformats/mp4/composer/include/a_impeg4file.h
index 17e9366..5f7db7b 100644
--- a/fileformats/mp4/composer/include/a_impeg4file.h
+++ b/fileformats/mp4/composer/include/a_impeg4file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,9 @@
 #include "textsampledescinfo.h"
 #endif
 
-
+#ifndef PVMI_KVP_H_INCLUDED
+#include "pvmi_kvp.h"
+#endif
 
 typedef OSCL_HeapString<OsclMemAllocator> PVA_FF_UTF8_HEAP_STRING;
 typedef const OSCL_wString& PVA_FF_UNICODE_STRING_PARAM;
@@ -259,10 +261,9 @@
 
         virtual void setKeyWord(uint8 keyWordSize, PVA_FF_UNICODE_HEAP_STRING keyWordInfo, uint16 langCode = LANGUAGE_CODE_UNKNOWN) = 0;
 
-        virtual void setLocationInfo(PVA_FF_UNICODE_STRING_PARAM locationName, PVA_FF_UNICODE_STRING_PARAM locationInfoAstrBody, PVA_FF_UNICODE_STRING_PARAM locationInfoAddNotes,
-                                     uint8 locationInfoRole, uint32 locationInfoLongitude, uint32 locationInfoLatitude,
-                                     uint32 locationInfoAltitude, uint16 langCode = LANGUAGE_CODE_UNKNOWN) = 0;
-
+        virtual void setLocationInfo(PvmfAssetInfo3GPPLocationStruct*) = 0;
+        virtual void setAlbumInfo(PVA_FF_UNICODE_STRING_PARAM albumInfo, uint16 langCode = LANGUAGE_CODE_UNKNOWN) = 0;
+        virtual void setRecordingYear(uint16 recordingYear) = 0;
 
         virtual void setCreationDate(PVA_FF_UNICODE_STRING_PARAM creationDate) = 0;
 
@@ -289,7 +290,7 @@
         ///////////////////////
 
         // Method to render the MP4 file to disk
-        virtual bool renderToFile(PVA_FF_UNICODE_STRING_PARAM filename) = 0;
+        virtual bool renderToFile(PVA_FF_UNICODE_STRING_PARAM filename/*=PVA_FF_EMPTY_STRING*/) = 0;
 
         // Access function to set the postfix string for PVA_FF_MediaDataAtom objects
         virtual void SetTempFilePostFix(PVA_FF_UNICODE_STRING_PARAM postFix) = 0;
diff --git a/fileformats/mp4/composer/include/a_isucceedfail.h b/fileformats/mp4/composer/include/a_isucceedfail.h
index 9e61239..386dda8 100644
--- a/fileformats/mp4/composer/include/a_isucceedfail.h
+++ b/fileformats/mp4/composer/include/a_isucceedfail.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/amrdecoderspecificinfo.h b/fileformats/mp4/composer/include/amrdecoderspecificinfo.h
index 947286c..61ac075 100644
--- a/fileformats/mp4/composer/include/amrdecoderspecificinfo.h
+++ b/fileformats/mp4/composer/include/amrdecoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/include/amrdecoderspecificinfo3gpp.h b/fileformats/mp4/composer/include/amrdecoderspecificinfo3gpp.h
index ea3b8a9..550e7b1 100644
--- a/fileformats/mp4/composer/include/amrdecoderspecificinfo3gpp.h
+++ b/fileformats/mp4/composer/include/amrdecoderspecificinfo3gpp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/include/amrsampleentry.h b/fileformats/mp4/composer/include/amrsampleentry.h
index 7c3ddef..239457d 100644
--- a/fileformats/mp4/composer/include/amrsampleentry.h
+++ b/fileformats/mp4/composer/include/amrsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_AudioSampleEntry Class is used for visual streams.
 */
diff --git a/fileformats/mp4/composer/include/assetinfoatoms.h b/fileformats/mp4/composer/include/assetinfoatoms.h
index f3c35cd..f8745a1 100644
--- a/fileformats/mp4/composer/include/assetinfoatoms.h
+++ b/fileformats/mp4/composer/include/assetinfoatoms.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -360,5 +360,46 @@
 
 };
 
+class PVA_FF_AssetInfoAlbumAtom : public PVA_FF_FullAtom
+{
+    public:
+        PVA_FF_AssetInfoAlbumAtom();
+        virtual ~PVA_FF_AssetInfoAlbumAtom() {};
+        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
+
+        // Member gets
+        void setAlbumLangCode(uint16  aLangCode)
+        {
+            _langCode = aLangCode;
+        }
+        void setAlbumInfo(PVA_FF_UNICODE_HEAP_STRING aAlbumTitle)
+        {
+            _albumTitle = aAlbumTitle;
+            recomputeSize();
+        }
+        virtual	void recomputeSize();
+    private:
+        uint16 _langCode;
+        uint16  _byteOrderMask;
+        PVA_FF_UNICODE_HEAP_STRING _albumTitle;
+};
+
+class PVA_FF_AssetInfoRecordingYearAtom : public PVA_FF_FullAtom
+{
+    public:
+        PVA_FF_AssetInfoRecordingYearAtom();
+        virtual ~PVA_FF_AssetInfoRecordingYearAtom() {};
+        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
+
+        // Member gets
+        void setRecordingYear(uint16 aRecordingYear)
+        {
+            _recordingYear = aRecordingYear;
+            recomputeSize();
+        }
+        virtual	void recomputeSize();
+    private:
+        uint16 _recordingYear;
+};
 
 #endif  // ASSETINFOATOMS_H_INCLUDED
diff --git a/fileformats/mp4/composer/include/atom.h b/fileformats/mp4/composer/include/atom.h
index 1b7cce7..9fb3d70 100644
--- a/fileformats/mp4/composer/include/atom.h
+++ b/fileformats/mp4/composer/include/atom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_Atom Class is the base class for all other Atoms in the MPEG-4 File
     Format.
diff --git a/fileformats/mp4/composer/include/atomutils.h b/fileformats/mp4/composer/include/atomutils.h
index 6fac3e1..5752d7a 100644
--- a/fileformats/mp4/composer/include/atomutils.h
+++ b/fileformats/mp4/composer/include/atomutils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@
 
 #define PV_MP4_FF_TEMPLATED_DELETE(auditCB,T,Tsimple,ptr)\
 {\
-OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
+OSCL_DELETE(ptr);\
 }
 
 
diff --git a/fileformats/mp4/composer/include/audiosampleentry.h b/fileformats/mp4/composer/include/audiosampleentry.h
index c1097fb..b705c70 100644
--- a/fileformats/mp4/composer/include/audiosampleentry.h
+++ b/fileformats/mp4/composer/include/audiosampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_AudioSampleEntry Class is used for visual streams.
 */
@@ -90,6 +89,11 @@
             _pes->setESID(esid);
         }
 
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+        {
+            _pes->writeMaxSampleSize(_afp);
+        }
+
     private:
         virtual void recomputeSize();
         void init();
diff --git a/fileformats/mp4/composer/include/avcconfigurationatom.h b/fileformats/mp4/composer/include/avcconfigurationatom.h
index 33226aa..088d20a 100644
--- a/fileformats/mp4/composer/include/avcconfigurationatom.h
+++ b/fileformats/mp4/composer/include/avcconfigurationatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
 #ifndef __AVCConfigurationAtom_H__
 #define __AVCConfigurationAtom_H__
 
diff --git a/fileformats/mp4/composer/include/avcsampleentry.h b/fileformats/mp4/composer/include/avcsampleentry.h
index ddec4f4..3cd4543 100644
--- a/fileformats/mp4/composer/include/avcsampleentry.h
+++ b/fileformats/mp4/composer/include/avcsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
 
 #ifndef __PVA_FF_AVCSampleEntry_H__
 #define __PVA_FF_AVCSampleEntry_H__
@@ -24,7 +22,6 @@
 #include "atom.h"
 #include "oscl_file_io.h"
 #include "avcconfigurationatom.h"
-//#include "mpeg4sampleentryextensions.h"
 #include "decoderspecificinfo.h"
 #include"sampleentry.h"
 
@@ -77,8 +74,6 @@
         int16  _predefined4;
 
         PVA_FF_AVCConfigurationAtom          *_pAVCConfigurationAtom;
-        // MPEG4BitRateBox              *_pMPEG4BitRateBox;
-
 };
 
 
diff --git a/fileformats/mp4/composer/include/basecommand.h b/fileformats/mp4/composer/include/basecommand.h
index f72bd92..78c37f4 100644
--- a/fileformats/mp4/composer/include/basecommand.h
+++ b/fileformats/mp4/composer/include/basecommand.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_BaseCommand Class is the base class for all PVA_FF_ObjectDescriptor streams
     that are represented as PVA_FF_ObjectDescriptor commands - the AccessUnits for all
diff --git a/fileformats/mp4/composer/include/basedescriptor.h b/fileformats/mp4/composer/include/basedescriptor.h
index 8877a0f..297e399 100644
--- a/fileformats/mp4/composer/include/basedescriptor.h
+++ b/fileformats/mp4/composer/include/basedescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_BaseDescriptor Class
 */
diff --git a/fileformats/mp4/composer/include/bifs.h b/fileformats/mp4/composer/include/bifs.h
deleted file mode 100644
index 4813971..0000000
--- a/fileformats/mp4/composer/include/bifs.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_Atom Class is the base class for all other Atoms in the MPEG-4 File
-    Format.
-*/
-
-
-#ifndef __BIFS_H__
-#define __BIFS_H__
-
-#define NEW_BIFS
-
-#ifdef NEW_BIFS
-
-static const int32 VIDEO_BIFS_SCENE_SIZE = 11;
-static const uint8 VIDEO_BIFS_SCENE[] = {0xC0, 0x10, 0x12, 0x61,
-                                        0x04, 0x88, 0x50, 0x45,
-                                        0x00, 0xBF, 0x00
-                                        };
-
-static const int32 AUDIO_BIFS_SCENE_SIZE = 8;
-static const uint8 AUDIO_BIFS_SCENE[] = {0xC0, 0x10, 0x12, 0x81,
-                                        0x30, 0x2A, 0x01, 0x7C
-                                        };
-
-static const int32 AUDIO_VIDEO_BIFS_SCENE_SIZE = 16;
-
-static const uint8 AUDIO_VIDEO_BIFS_SCENE[] = {0xC0, 0x10, 0x12, 0x81,
-        0x30, 0x2A, 0x01, 0x72,
-        0x61, 0x04, 0x88, 0x50,
-        0x45, 0x00, 0xFF, 0x00
-                                              };
-#else
-
-static const int32 VIDEO_BIFS_SCENE_SIZE = 26;
-static const uint8 VIDEO_BIFS_SCENE[] = { 0x0,  0x0,  0x0,  0x0,
-                                        0x0,  0x0,  0x0,  0x12,
-                                        0xc0, 0x4,  0x24, 0xc0,
-                                        0x85, 0x4,  0x50, 0xa,
-                                        0x57, 0xfe, 0x0,  0x0,
-                                        0x0,  0x0,  0x0,  0x0,
-                                        0x1f, 0x00
-                                        };
-
-static const int32 AUDIO_BIFS_SCENE_SIZE = 25;
-static const uint8 AUDIO_BIFS_SCENE[] = { 0x0,  0x0,  0x0,  0x0,
-                                        0x0,  0x0,  0x0,  0x11,
-                                        0xc0, 0x4,  0x25, 0x2,
-                                        0x60, 0x54, 0x2,  0xa5,
-                                        0xff, 0x80, 0x0,  0x0,
-                                        0x0,  0x0,  0x0,  0x7,
-                                        0x80
-                                        };
-
-static const int32 AUDIO_VIDEO_BIFS_SCENE_SIZE = 39;
-static const uint8 AUDIO_VIDEO_BIFS_SCENE[] = { 0x0,  0x0,  0x0,  0x0,
-        0x0,  0x0,  0x0,  0x1f,
-        0xc0, 0x4,  0x25, 0x2,
-        0x60, 0x54, 0x2,  0xa5,
-        0xff, 0x80, 0x0,  0x0,
-        0x0,  0x0,  0x0,  0x6,
-        0x4c, 0x8,  0x50, 0x45,
-        0x0,  0xe5, 0x7f, 0xe0,
-        0x0,  0x0,  0x0,  0x0,
-        0x0,  0x1,  0xf0
-                                              };
-#endif
-
-static const int32 BIFS_DECODER_INFO_SIZE = 2;
-static const uint8 BIFS_DECODER_INFO[] = { 0x20, 0x20 };
-
-
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/boxrecord.h b/fileformats/mp4/composer/include/boxrecord.h
index 0316bce..fa1a079 100644
--- a/fileformats/mp4/composer/include/boxrecord.h
+++ b/fileformats/mp4/composer/include/boxrecord.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/chunklargeoffsetatom.h b/fileformats/mp4/composer/include/chunklargeoffsetatom.h
index fc6c9ef..0e670b0 100644
--- a/fileformats/mp4/composer/include/chunklargeoffsetatom.h
+++ b/fileformats/mp4/composer/include/chunklargeoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ChunkLargeOffsetAtom Class gives the index of each chunk into the
     containing file.
diff --git a/fileformats/mp4/composer/include/chunkoffsetatom.h b/fileformats/mp4/composer/include/chunkoffsetatom.h
index 7b2cb74..a730b48 100644
--- a/fileformats/mp4/composer/include/chunkoffsetatom.h
+++ b/fileformats/mp4/composer/include/chunkoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ChunkOffsetAtom Class gives the index of each chunk into the
     containing file.
diff --git a/fileformats/mp4/composer/include/compositionoffsetatom.h b/fileformats/mp4/composer/include/compositionoffsetatom.h
index d971b17..cca1407 100644
--- a/fileformats/mp4/composer/include/compositionoffsetatom.h
+++ b/fileformats/mp4/composer/include/compositionoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This CompositionTimeToSampleAtom Class provides the offset between decoding
     time and composition time.
diff --git a/fileformats/mp4/composer/include/copyrightatom.h b/fileformats/mp4/composer/include/copyrightatom.h
index 7a87e80..5d0936b 100644
--- a/fileformats/mp4/composer/include/copyrightatom.h
+++ b/fileformats/mp4/composer/include/copyrightatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_CopyrightAtom Class contains the user-defined copyright notice.
 */
diff --git a/fileformats/mp4/composer/include/dataentryatom.h b/fileformats/mp4/composer/include/dataentryatom.h
index 3275d51..39be510 100644
--- a/fileformats/mp4/composer/include/dataentryatom.h
+++ b/fileformats/mp4/composer/include/dataentryatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataEntryAtom Class is the base class for the PVA_FF_DataEntryUrlAtom and
     PVA_FF_DataEntryUrnAtom classes.
diff --git a/fileformats/mp4/composer/include/dataentryurlatom.h b/fileformats/mp4/composer/include/dataentryurlatom.h
index 2a01504..1934efd 100644
--- a/fileformats/mp4/composer/include/dataentryurlatom.h
+++ b/fileformats/mp4/composer/include/dataentryurlatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataEntryUrlAtom Class contains a table of data references which declare
     the location of the media data used within the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/include/dataentryurnatom.h b/fileformats/mp4/composer/include/dataentryurnatom.h
index 81c2abb..50b75a9 100644
--- a/fileformats/mp4/composer/include/dataentryurnatom.h
+++ b/fileformats/mp4/composer/include/dataentryurnatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataEntryUrnAtom Class contains a table of data references which declare
     the location of the media data used within the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/include/datainformationatom.h b/fileformats/mp4/composer/include/datainformationatom.h
index e054074..ad73820 100644
--- a/fileformats/mp4/composer/include/datainformationatom.h
+++ b/fileformats/mp4/composer/include/datainformationatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataInformationAtom Class contains objects that declare the location
     of the media information within the stream.
diff --git a/fileformats/mp4/composer/include/datareferenceatom.h b/fileformats/mp4/composer/include/datareferenceatom.h
index 94016fd..62ee66d 100644
--- a/fileformats/mp4/composer/include/datareferenceatom.h
+++ b/fileformats/mp4/composer/include/datareferenceatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataReferenceAtom Class contains a table of data references which declare
     the location of the media data used within the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/include/decoderconfigdescriptor.h b/fileformats/mp4/composer/include/decoderconfigdescriptor.h
index 3e790c3..e3f3ec1 100644
--- a/fileformats/mp4/composer/include/decoderconfigdescriptor.h
+++ b/fileformats/mp4/composer/include/decoderconfigdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderConfigDescriptor Class
 */
@@ -119,7 +118,7 @@
         }
 
         virtual void recomputeSize();
-
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
     private:
         uint8 _objectTypeIndication; // (8)
         uint8 _streamType; // (6) 0x04 for VisualStream, 0x05 for AudioStream
@@ -129,6 +128,7 @@
         uint32 _maxBitrate; // (32)
         uint32 _avgBitrate; // (32)
         int32 _codecType;
+        uint32 iCurrFilePos;
 
         Oscl_Vector<PVA_FF_DecoderSpecificInfo*, OsclMemAllocator> *_pdecSpecificInfoVec;
 };
diff --git a/fileformats/mp4/composer/include/decoderspecificinfo.h b/fileformats/mp4/composer/include/decoderspecificinfo.h
index 6ce0e7b..cd3087d 100644
--- a/fileformats/mp4/composer/include/decoderspecificinfo.h
+++ b/fileformats/mp4/composer/include/decoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/include/degradationpriorityatom.h b/fileformats/mp4/composer/include/degradationpriorityatom.h
index ed895fb..ad90314 100644
--- a/fileformats/mp4/composer/include/degradationpriorityatom.h
+++ b/fileformats/mp4/composer/include/degradationpriorityatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DegradationPriorityAtom Class provides a compact marking of the random access
     points within the stream.
diff --git a/fileformats/mp4/composer/include/editatom.h b/fileformats/mp4/composer/include/editatom.h
index a5b6c7d..c6e26ad 100644
--- a/fileformats/mp4/composer/include/editatom.h
+++ b/fileformats/mp4/composer/include/editatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     The contents of the PVA_FF_FreeSpaceAtom Class may be ignored, or the contents deleted
     without affecting the presentation.
diff --git a/fileformats/mp4/composer/include/editlistatom.h b/fileformats/mp4/composer/include/editlistatom.h
index 08d7989..b6746d0 100644
--- a/fileformats/mp4/composer/include/editlistatom.h
+++ b/fileformats/mp4/composer/include/editlistatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_EditListAtom Class contains an explicit timeline map.
 */
diff --git a/fileformats/mp4/composer/include/es_id_inc.h b/fileformats/mp4/composer/include/es_id_inc.h
index 72c08e9..72f9c12 100644
--- a/fileformats/mp4/composer/include/es_id_inc.h
+++ b/fileformats/mp4/composer/include/es_id_inc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ESDescriptor Class contains information on the Elementary Stream
 */
@@ -31,7 +30,6 @@
 
     public:
         PVA_FF_ES_ID_Inc(uint32 trackid); // Alternate constructor
-
         virtual ~PVA_FF_ES_ID_Inc(); // Destructor
 
         // Member gets and sets
diff --git a/fileformats/mp4/composer/include/es_id_ref.h b/fileformats/mp4/composer/include/es_id_ref.h
index 7ff13c1..67f2f5e 100644
--- a/fileformats/mp4/composer/include/es_id_ref.h
+++ b/fileformats/mp4/composer/include/es_id_ref.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ESDescriptor Class contains information on the Elementary Stream
 */
@@ -31,7 +30,6 @@
 
     public:
         PVA_FF_ES_ID_Ref(uint32 trackindex); // Alternate constructor
-
         virtual ~PVA_FF_ES_ID_Ref(); // Destructor
 
         // Member gets and sets
diff --git a/fileformats/mp4/composer/include/esdatom.h b/fileformats/mp4/composer/include/esdatom.h
index 735b96d..4ad379b 100644
--- a/fileformats/mp4/composer/include/esdatom.h
+++ b/fileformats/mp4/composer/include/esdatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ESDAtom Class provides the offset between decoding
     time and composition time.
@@ -69,6 +68,10 @@
 
         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+        {
+            _pdescriptor->writeMaxSampleSize(_afp);
+        }
 
     private:
         void init();
diff --git a/fileformats/mp4/composer/include/esdescriptor.h b/fileformats/mp4/composer/include/esdescriptor.h
index d1de38b..3546dcb 100644
--- a/fileformats/mp4/composer/include/esdescriptor.h
+++ b/fileformats/mp4/composer/include/esdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ESDescriptor Class contains information on the Elementary Stream
 */
@@ -145,6 +144,11 @@
 
         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+        {
+            _pdcd->writeMaxSampleSize(_afp);
+        }
+
 
     private:
         uint16 _ESID; // (16)
diff --git a/fileformats/mp4/composer/include/evrcdecoderspecificinfo.h b/fileformats/mp4/composer/include/evrcdecoderspecificinfo.h
deleted file mode 100644
index 15e0c9e..0000000
--- a/fileformats/mp4/composer/include/evrcdecoderspecificinfo.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
-	video stream
-*/
-
-#ifndef __EVRCDecoderSpecificInfo_H__
-#define __EVRCDecoderSpecificInfo_H__
-
-#include "a_atomdefs.h"
-#include "decoderspecificinfo.h"
-
-//using namespace std;
-
-class PVA_FF_EVRCDecoderSpecificInfo : public PVA_FF_DecoderSpecificInfo
-{
-
-    public:
-        PVA_FF_EVRCDecoderSpecificInfo(); // Default constructor
-        virtual ~PVA_FF_EVRCDecoderSpecificInfo() {} // Destructor
-
-        void setVendorcode(int32 VendorCode = PACKETVIDEO_FOURCC)
-        {
-            _VendorCode = VendorCode;
-        }
-        void setEncoderVersion(uint8 encoder_version = 0)
-        {
-            _encoder_version = encoder_version;
-        }
-        void setFrameType(uint8 frame_type)
-        {
-            _frame_type = frame_type;
-        }
-
-        uint8 getFrameType()
-        {
-            return _frame_type;
-        }
-
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
-
-    private:
-        int32            _VendorCode;
-        uint8            _encoder_version;
-        uint8            _frame_type;
-};
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/expandablebaseclass.h b/fileformats/mp4/composer/include/expandablebaseclass.h
index 71483b9..29079c1 100644
--- a/fileformats/mp4/composer/include/expandablebaseclass.h
+++ b/fileformats/mp4/composer/include/expandablebaseclass.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ExpandableBaseClass Class is the base class for all Descriptors that
     allows the encoding the size of the class in bytes with a VARIABLE NUMBER OF BYTES
diff --git a/fileformats/mp4/composer/include/filetypeatom.h b/fileformats/mp4/composer/include/filetypeatom.h
index 465ab7e..f8f1013 100644
--- a/fileformats/mp4/composer/include/filetypeatom.h
+++ b/fileformats/mp4/composer/include/filetypeatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
 	This PVA_FF_SampleEntry Class is the base class for the HinstSampleEntry,
 	PVA_FF_VisualSampleEntry, PVA_FF_AudioSampleEntry. and PVA_FF_MpegSampleEntry classes.
@@ -39,7 +38,6 @@
         {
             if (_pCompatibleBrandVec != NULL)
             {
-                //OSCL_DELETE((_pCompatibleBrandVec));
                 PV_MP4_FF_TEMPLATED_DELETE(NULL, uint32VecType, Oscl_Vector, _pCompatibleBrandVec);
             }
         }
@@ -66,6 +64,4 @@
         Oscl_Vector<uint32, OsclMemAllocator>* _pCompatibleBrandVec;
 };
 
-
 #endif
-
diff --git a/fileformats/mp4/composer/include/fontrecord.h b/fileformats/mp4/composer/include/fontrecord.h
index 6ef5d4e..a931dbd 100644
--- a/fileformats/mp4/composer/include/fontrecord.h
+++ b/fileformats/mp4/composer/include/fontrecord.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/fonttableatom.h b/fileformats/mp4/composer/include/fonttableatom.h
index e5b86ee..2e8c879 100644
--- a/fileformats/mp4/composer/include/fonttableatom.h
+++ b/fileformats/mp4/composer/include/fonttableatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,7 +46,6 @@
         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
         virtual void recomputeSize();
         virtual uint32 getSize();
-        //PVA_FF_FontRecord *setFontRecord(uint16 FontListID,uint16 FontId,int8 FontLength,uint8* FontName);
         void setFontRecord(uint16 FontListID, uint16 FontId, int8 FontLength, uint8* FontName);
 
         PVA_FF_FontRecord * getFontRecordAt(uint16 index)
diff --git a/fileformats/mp4/composer/include/freespaceatom.h b/fileformats/mp4/composer/include/freespaceatom.h
index 5e81ce4..9cb0af1 100644
--- a/fileformats/mp4/composer/include/freespaceatom.h
+++ b/fileformats/mp4/composer/include/freespaceatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     The contents of the PVA_FF_FreeSpaceAtom Class may be ignored, or the contents deleted
     without affecting the presentation.
diff --git a/fileformats/mp4/composer/include/fullatom.h b/fileformats/mp4/composer/include/fullatom.h
index df40ce4..a5422d1 100644
--- a/fileformats/mp4/composer/include/fullatom.h
+++ b/fileformats/mp4/composer/include/fullatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_FullAtom Class is the base class for some Atoms in the MPEG-4 File
     Format.
diff --git a/fileformats/mp4/composer/include/h263decoderspecificinfo.h b/fileformats/mp4/composer/include/h263decoderspecificinfo.h
index 1925c99..82bc49f 100644
--- a/fileformats/mp4/composer/include/h263decoderspecificinfo.h
+++ b/fileformats/mp4/composer/include/h263decoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/include/h263decoderspecificinfo3gpp.h b/fileformats/mp4/composer/include/h263decoderspecificinfo3gpp.h
index b9a076d..43b6240 100644
--- a/fileformats/mp4/composer/include/h263decoderspecificinfo3gpp.h
+++ b/fileformats/mp4/composer/include/h263decoderspecificinfo3gpp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/include/h263sampleentry.h b/fileformats/mp4/composer/include/h263sampleentry.h
index d12f17b..d952c91 100644
--- a/fileformats/mp4/composer/include/h263sampleentry.h
+++ b/fileformats/mp4/composer/include/h263sampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_VisualSampleEntry Class is used for visual streams.
 */
diff --git a/fileformats/mp4/composer/include/handleratom.h b/fileformats/mp4/composer/include/handleratom.h
index 93a70c6..1305c54 100644
--- a/fileformats/mp4/composer/include/handleratom.h
+++ b/fileformats/mp4/composer/include/handleratom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_HandlerAtom Class declares the nature of the media in the stream.
 */
diff --git a/fileformats/mp4/composer/include/hintmediaheaderatom.h b/fileformats/mp4/composer/include/hintmediaheaderatom.h
index 9e32ac3..53fb8c1 100644
--- a/fileformats/mp4/composer/include/hintmediaheaderatom.h
+++ b/fileformats/mp4/composer/include/hintmediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_HintMediaHeaderAtom Class contains general information,
     independent of protocol, for the hint tracks within the stream.
diff --git a/fileformats/mp4/composer/include/hintsample.h b/fileformats/mp4/composer/include/hintsample.h
deleted file mode 100644
index f08ebb5..0000000
--- a/fileformats/mp4/composer/include/hintsample.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_HintSample Class is the simple structure that hold all the data of
-    individual HintTrack entries.  This class alsp provides access methods to
-    directly access the HintTrack entry fields - this class takes care of parsing
-    the packed bytes of the hint entry
-*/
-
-#ifndef __HintSample_H__
-#define __HintSample_H__
-
-#include "atomutils.h"
-#include "a_atomdefs.h"
-
-class PVA_FF_HintSample
-{
-
-    public:
-        PVA_FF_HintSample(uint8 type)
-        {
-            _type = type;    // Constructor
-        }
-        virtual ~PVA_FF_HintSample() {} // Destructor
-
-        virtual int32 renderToBuffer(void *mem) = 0;
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp) = 0;
-        virtual uint32 getSize() const = 0; // Size of hint sample in bytes
-
-        uint8 getType() const
-        {
-            return _type;
-        }
-
-        void SetMediaOffset(uint32 offset)
-        {
-            _Offset = offset;
-        }
-
-    protected:
-        bool renderBaseMembersToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp) const
-        {
-            if (!PVA_FF_AtomUtils::render8(fp, _type))
-            {
-                return false;
-            }
-
-            return true;
-        }
-        uint32 _Offset;
-        uint8  _Flag_Type;
-
-    private:
-        uint8 _type;
-
-};
-
-#endif
diff --git a/fileformats/mp4/composer/include/hintsampleentry.h b/fileformats/mp4/composer/include/hintsampleentry.h
deleted file mode 100644
index 70a026b..0000000
--- a/fileformats/mp4/composer/include/hintsampleentry.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_HintSampleEntry is used for hint tracks.
-*/
-
-
-#ifndef __HintSampleEntry_H__
-#define __HintSampleEntry_H__
-
-#include "sampleentry.h"
-#include "hintsample.h"
-
-class PVA_FF_HintSampleEntry : public PVA_FF_SampleEntry
-{
-
-    public:
-        PVA_FF_HintSampleEntry(uint32 protocol); // Constructor
-
-        virtual ~PVA_FF_HintSampleEntry();
-
-        // Member gets and sets
-        uint32 getEntryCount() const
-        {
-            return _entryCount;
-        }
-
-        //void nextHintSample(uint8 *psample, uint32 size, uint32 ts, BOOLEAN isIFrame, BOOLEAN isBaseLayer);
-        void nextHintSample(uint8 *psample, uint32 size, uint32 ts, uint8 flags); // For video hint samples
-        void nextHintSample(uint8 *psample, uint32 size, uint32 ts); // For audio hint samples
-        void nextHintSample(uint8 *psample, uint32 size, uint32 ts, uint32 duration); // For still image hint samples
-
-        PVA_FF_HintSample* getSampleAt(int32 index) const;
-
-        Oscl_Vector<PVA_FF_HintSample*, OsclMemAllocator>& getSampleVec() const
-        {
-            return *_psampleVec;
-        }
-
-        int32 seek(int32 baseLayerSampleNum) const; // Seeks to the base-layer sample in the hint track
-
-        // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
-
-        virtual uint32 getHintOffset()
-        {
-            return (_HintOffset);
-        }
-
-
-    private:
-        void addHintSample(PVA_FF_HintSample *sample);
-        void insertHintEntry(int32 index, PVA_FF_HintSample *sample);
-        void replaceHintEntry(int32 index, PVA_FF_HintSample *sample);
-
-        void init();
-        virtual void recomputeSize();
-
-        uint32 _entryCount;
-        Oscl_Vector<PVA_FF_HintSample*, OsclMemAllocator>*_psampleVec;
-        uint32  _mediaOffset;
-        uint32 _HintOffset;
-
-};
-
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/imediabuffer.h b/fileformats/mp4/composer/include/imediabuffer.h
deleted file mode 100644
index 2ca6510..0000000
--- a/fileformats/mp4/composer/include/imediabuffer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-	This PVA_FF_IMediaBuffer Class is the interface that consumers of MediaBuffers will
-	use.  This includes PVPlayer and PVServer.  It is mainly used when retrieving
-	Mpeg-4 data from file and returning a data buffer to either PVPlayer or
-	PVServer.
-*/
-
-#ifndef __IMediaBuffer_H__
-#define __IMediaBuffer_H__
-
-#include "oscl_types.h"
-
-class PVA_FF_IMediaBuffer
-{
-
-    public:
-        virtual ~PVA_FF_IMediaBuffer() {}; // So destructor of PVA_FF_MediaBuffer gets called
-
-        // Member get methods
-
-        // Returns the size of the data in the buffer
-        virtual uint32 getSize() const = 0;
-
-        // Returns a pointer to the data in the buffer
-        virtual uint8 *getDataPtr() = 0;
-        // Returns a read-only pointer to the data in the buffer - USE THIS METHOD
-        virtual uint8 *getReadOnlyDataPtr() const = 0;
-
-        // This method MUST be called when you are done with the buffer.  This allows
-        // the underlying buffer manager to handle memory management by reusing the
-        // buffer when you are done.
-        virtual int32 freeBuf() = 0;
-
-};
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/initialobjectdescriptor.h b/fileformats/mp4/composer/include/initialobjectdescriptor.h
index b5e6a54..2e1bc3b 100644
--- a/fileformats/mp4/composer/include/initialobjectdescriptor.h
+++ b/fileformats/mp4/composer/include/initialobjectdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_InitialObjectDescriptor Class
 */
@@ -117,18 +116,8 @@
         uint8 _graphicsProfileLevelIndication; // (8)
 
         Oscl_Vector<PVA_FF_ES_ID_Inc*, OsclMemAllocator> *_pES_ID_Inc_Vec; // PVA_FF_ESDescriptor[1 to 30]
-        // The PVA_FF_ObjectDescriptor has actual ES_ID_Refs while the
-        // PVA_FF_InitialObjectDescriptor has ES_ID_Incs.
-
-        // OCIDescriptor _ODID[]; // [0 to 255]
-        // IPMPDescriptorPointer _IPMPDP[]; // [0 to 255]
-
-        // ExtensionDescriptor _ExtD[]; // [0 to 255]
-
-
 };
 
 
 
 #endif
-
diff --git a/fileformats/mp4/composer/include/interleavebuffer.h b/fileformats/mp4/composer/include/interleavebuffer.h
index 058d060..e1502af 100644
--- a/fileformats/mp4/composer/include/interleavebuffer.h
+++ b/fileformats/mp4/composer/include/interleavebuffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/mediaatom.h b/fileformats/mp4/composer/include/mediaatom.h
index d121dd6..070d1e3 100644
--- a/fileformats/mp4/composer/include/mediaatom.h
+++ b/fileformats/mp4/composer/include/mediaatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaAtom Class contains all the objects that declare information
     about the media data within the stream.
@@ -149,11 +148,6 @@
             _pmediaInformation->setH263ProfileLevel(profile, level);
         }
 
-        void setBIFSODSampleDuration(int32 duration)
-        {
-            _pmediaInformation->setBIFSODSampleDuration(duration);
-        }
-
         void setDuration(uint32 duration)
         {
             _pmediaHeader->setDuration(duration);
@@ -169,6 +163,14 @@
             _pmediaInformation->setESID(esid);
         }
 
+        void SetMaxSampleSize(uint32);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
+
+        uint32 getSampleCount() const
+        {
+            return _pmediaInformation->getSampleCount();
+        }
+
     private:
         virtual void recomputeSize();
 
diff --git a/fileformats/mp4/composer/include/mediadataatom.h b/fileformats/mp4/composer/include/mediadataatom.h
index 6c0e397..9570c82 100644
--- a/fileformats/mp4/composer/include/mediadataatom.h
+++ b/fileformats/mp4/composer/include/mediadataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaDataAtom Class contains the media data.
 */
@@ -37,6 +36,10 @@
 {
 
     public:
+        // 03/21/01 Pass the postfixed string to the obejct
+        // PVA_FF_MediaDataAtom(int32 type = MEDIA_DATA_IN_MEMORY); // Constructor
+        // 03/21/01 Generate the temporary files into the output path
+        // PVA_FF_MediaDataAtom(OSCL_wString postfixString, int32 type = MEDIA_DATA_IN_MEMORY); // Constructor
         PVA_FF_MediaDataAtom(PVA_FF_UNICODE_STRING_PARAM outputPathString,
                              PVA_FF_UNICODE_STRING_PARAM postfixString,
                              int32 tempFileIndex,
@@ -122,7 +125,6 @@
         {
             return _type;
         }
-
     private:
         virtual void recomputeSize();
         void prepareTempFile(uint32 aCache = 0);
@@ -140,6 +142,8 @@
 
         int32 _tempFileIndex;
 
+        // 03/21/01 Add postfix string to handle multiple instances of the output filter,
+        // the temporary file names will be different for every instances
         PVA_FF_UNICODE_HEAP_STRING _tempFilePostfix;
 
         Oscl_Vector<PVA_FF_Renderable*, OsclMemAllocator> *_prenderables;
@@ -150,6 +154,7 @@
         void*  _osclFileServerSession;
         uint32 _targetFileMediaStartOffset;
         uint32  _totalDataRenderedToTargetFile;
+        bool _oIsFileOpen;
 };
 
 
diff --git a/fileformats/mp4/composer/include/mediaheaderatom.h b/fileformats/mp4/composer/include/mediaheaderatom.h
index 6885a7e..5a51c75 100644
--- a/fileformats/mp4/composer/include/mediaheaderatom.h
+++ b/fileformats/mp4/composer/include/mediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaHeaderAtom Class contains all the objects that declare information
     about the media data within the stream.
@@ -98,7 +97,6 @@
         uint32 _modificationTime; // 4/8 (32/64bits) -- Will templatize later - using 32bits for now
         uint32 _timeScale; // 4 (32bits)
         uint32 _duration; // 4/8 (32/64bits) -- Will templatize later - using 32bits for now
-        //int _pad; // Need to pad a single bit = 0 when rendering
         uint16 _language; // Actually 3 5-bit objects representing the packed ISO-639-2/T language code
         // Rendered as 15 bits with the leading pad bit from above.
 
diff --git a/fileformats/mp4/composer/include/mediainformationatom.h b/fileformats/mp4/composer/include/mediainformationatom.h
index 5bb0656..5316b6c 100644
--- a/fileformats/mp4/composer/include/mediainformationatom.h
+++ b/fileformats/mp4/composer/include/mediainformationatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaInformationAtom Class contains all the objects that declare
     characteristic information about the media data within the stream.
@@ -137,15 +136,17 @@
             _psampleTableAtom->setH263ProfileLevel(profile, level);
         }
 
-        void setBIFSODSampleDuration(int32 duration)
-        {
-            _psampleTableAtom->setBIFSODSampleDuration(duration);
-        }
-
         void setESID(uint16 esid)
         {
             _psampleTableAtom->setESID(esid);
         }
+        void SetMaxSampleSize(uint32);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
+
+        uint32 getSampleCount() const
+        {
+            return _psampleTableAtom->getSampleCount();
+        }
 
     private:
         void recomputeSize();
diff --git a/fileformats/mp4/composer/include/mediainformationheaderatom.h b/fileformats/mp4/composer/include/mediainformationheaderatom.h
index ef0d1dd..64523e3 100644
--- a/fileformats/mp4/composer/include/mediainformationheaderatom.h
+++ b/fileformats/mp4/composer/include/mediainformationheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
 	This PVA_FF_MediaInformationHeaderAtom Class is an abstract base class for the
 	atoms VideoMediaHeaderAton, AudioMediaHeaderAtom, PVA_FF_HintMediaHeaderAtom,
diff --git a/fileformats/mp4/composer/include/movieatom.h b/fileformats/mp4/composer/include/movieatom.h
index 93523ac..acd6a72 100644
--- a/fileformats/mp4/composer/include/movieatom.h
+++ b/fileformats/mp4/composer/include/movieatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MovieAtom Class is the main atom class in the MPEG-4 File that stores
     all the meta data about the MPEG-4 presentation.
@@ -45,6 +44,9 @@
 #include "movieextendsatom.h"
 #include "moviefragmentatom.h"
 #include "moviefragmentrandomaccessatom.h"
+#ifndef PVMI_KVP_H_INCLUDED
+#include "pvmi_kvp.h"
+#endif
 
 
 class PVA_FF_MovieAtom : public PVA_FF_Atom, public PVA_FF_ISucceedFail
@@ -84,25 +86,12 @@
             _pmovieHeaderAtom = header;
         }
 
-        const PVA_FF_ObjectDescriptorAtom &getObjectDescriptorAtom()
-        {
-            return *_pobjectDescriptorAtom;
-        }
-        PVA_FF_ObjectDescriptorAtom &getMutableObjectDescriptorAtom()
-        {
-            return *_pobjectDescriptorAtom;
-        }
-        void setObjectDescriptorAtom(PVA_FF_ObjectDescriptorAtom *od)
-        {
-            _pobjectDescriptorAtom = od;
-        }
-
         // Track gets and adds
         void addTrackAtom(PVA_FF_TrackAtom *a); // Adds to appropriate vector
 
         const Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator>& getMpeg4TrackVec()
         {
-            return *_pmpeg4TrackVec;    // Contains OD and BIFS tracks
+            return *_pmpeg4TrackVec;
         }
         PVA_FF_TrackAtom *getMpeg4Track(int32 index);
 
@@ -125,12 +114,6 @@
         // Getting and setting the Mpeg4 VOL header for timed text
         void addTextDecoderSpecificInfo(PVA_FF_TextSampleDescInfo *pinfo, int32 trackID);
 
-        // Gets and sets for BIFS binary encoded scene
-        void setBIFSDecoderInfo(PVA_FF_DecoderSpecificInfo *info)
-        {
-            _pBIFSTrack->addDecoderSpecificInfo(info);
-        }
-
         PVA_FF_TrackAtom *getMediaTrack(uint32 trackID);
         void addSampleToTrack(uint32 trackID, uint8 *psample,
                               uint32 size, uint32 ts, uint8 flags,
@@ -306,26 +289,32 @@
             return false;
         }
 
-        bool setLocationInfo(PVA_FF_UNICODE_STRING_PARAM locationName,
-                             PVA_FF_UNICODE_STRING_PARAM locationInfoAstrBody,
-                             PVA_FF_UNICODE_STRING_PARAM locationInfoAddNotes,
-                             uint8 locationInfoRole,
-                             uint32 locationInfoLongitude,
-                             uint32 locationInfoLatitude,
-                             uint32 locationInfoAltitude,
-                             uint16 langCode)
+        bool setLocationInfo(PvmfAssetInfo3GPPLocationStruct *ptr_loc_struct)
         {
             if (_pAssetInfoLocationInfoAtom != NULL)
             {
-                _pAssetInfoLocationInfoAtom->setLocationInfoLangCode(langCode);
-                _pAssetInfoLocationInfoAtom->setLocationInfoRole(locationInfoRole);
-                _pAssetInfoLocationInfoAtom->setLocationInfoLongitude(locationInfoLongitude);
-                _pAssetInfoLocationInfoAtom->setLocationInfoLatitude(locationInfoLatitude);
-                _pAssetInfoLocationInfoAtom->setLocationInfoAltitude(locationInfoAltitude);
+                _pAssetInfoLocationInfoAtom->setLocationInfoLangCode(ptr_loc_struct->_langCode);
+                _pAssetInfoLocationInfoAtom->setLocationInfoRole(ptr_loc_struct->_role);
+                _pAssetInfoLocationInfoAtom->setLocationInfoLongitude(ptr_loc_struct->_longitude);
+                _pAssetInfoLocationInfoAtom->setLocationInfoLatitude(ptr_loc_struct->_latitude);
+                _pAssetInfoLocationInfoAtom->setLocationInfoAltitude(ptr_loc_struct->_altitude);
 
-                _pAssetInfoLocationInfoAtom->setLocationInfoName(locationName);
-                _pAssetInfoLocationInfoAtom->setLocationInfoAstrBody(locationInfoAstrBody);
-                _pAssetInfoLocationInfoAtom->setLocationInfoAddNotes(locationInfoAddNotes);
+                _pAssetInfoLocationInfoAtom->setLocationInfoName(ptr_loc_struct->_location_name);
+                _pAssetInfoLocationInfoAtom->setLocationInfoAstrBody(ptr_loc_struct->_astronomical_body);
+                _pAssetInfoLocationInfoAtom->setLocationInfoAddNotes(ptr_loc_struct->_additional_notes);
+                setLanguage(ptr_loc_struct->_langCode);
+                return true;
+            }
+
+            return false;
+        }
+
+        bool setAlbumInfo(PVA_FF_UNICODE_STRING_PARAM albumtitle, uint16 langCode)
+        {
+            if (_pAssetInfoKeyAlbumAtom != NULL)
+            {
+                _pAssetInfoKeyAlbumAtom->setAlbumLangCode(langCode);
+                _pAssetInfoKeyAlbumAtom->setAlbumInfo(albumtitle);
                 setLanguage(langCode);
                 return true;
             }
@@ -333,21 +322,30 @@
             return false;
         }
 
+        bool setRecordingYearInfo(uint16 recordingYear)
+        {
+            if (_pAssetInfoKeyRecordingYearAtom != NULL)
+            {
+                _pAssetInfoKeyRecordingYearAtom->setRecordingYear(recordingYear);
+                return true;
+            }
+
+            return false;
+        }
+
         // Movie Fragment : add movie extend atom usage APIs
         void	setMovieFragmentDuration();
         void	updateMovieFragmentDuration(uint32 trackID, uint32 ts);
         void	writeMovieFragmentDuration(MP4_AUTHOR_FF_FILE_IO_WRAP* fp);
         void	setVideoWidthHeight(uint32 trackID, int16 width, int16 height);
-
+        void    SetMaxSampleSize(uint32, uint32);
+        void	writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
     private:
         virtual void recomputeSize();
 
         PVA_FF_MovieHeaderAtom *_pmovieHeaderAtom;
-        PVA_FF_ObjectDescriptorAtom *_pobjectDescriptorAtom;
 
-        Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator> *_pmpeg4TrackVec; // Vector of misc tracks (OD and BIFS)
-        PVA_FF_TrackAtom *_pBIFSTrack;
-        PVA_FF_TrackAtom *_pODTrack;
+        Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator> *_pmpeg4TrackVec;
 
         PVA_FF_UserDataAtom *_puserDataAtom;
         Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator> *_pMediaTrackVec; // Vector of tracks
@@ -365,6 +363,8 @@
         PVA_FF_AssetInfoClassificationAtom	*_pAssetInfoClassificationAtom;
         PVA_FF_AssetInfoKeyWordsAtom		*_pAssetInfoKeyWordsAtom;
         PVA_FF_AssetInfoLocationInfoAtom	*_pAssetInfoLocationInfoAtom;
+        PVA_FF_AssetInfoAlbumAtom			*_pAssetInfoKeyAlbumAtom;
+        PVA_FF_AssetInfoRecordingYearAtom	*_pAssetInfoKeyRecordingYearAtom;
 
         // Movie Fragment : Atoms needed in movie fragment mode
         PVA_FF_MovieExtendsAtom				*_pMovieExtendsAtom;
diff --git a/fileformats/mp4/composer/include/movieextendsatom.h b/fileformats/mp4/composer/include/movieextendsatom.h
index 6fa2afd..a859a98 100644
--- a/fileformats/mp4/composer/include/movieextendsatom.h
+++ b/fileformats/mp4/composer/include/movieextendsatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/movieextendsheaderatom.h b/fileformats/mp4/composer/include/movieextendsheaderatom.h
index 5b2463e..74e276d 100644
--- a/fileformats/mp4/composer/include/movieextendsheaderatom.h
+++ b/fileformats/mp4/composer/include/movieextendsheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/moviefragmentatom.h b/fileformats/mp4/composer/include/moviefragmentatom.h
index 7f248f2..98248a6 100644
--- a/fileformats/mp4/composer/include/moviefragmentatom.h
+++ b/fileformats/mp4/composer/include/moviefragmentatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/moviefragmentheaderatom.h b/fileformats/mp4/composer/include/moviefragmentheaderatom.h
index 61ddb95..a61ad7a 100644
--- a/fileformats/mp4/composer/include/moviefragmentheaderatom.h
+++ b/fileformats/mp4/composer/include/moviefragmentheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/moviefragmentrandomaccessatom.h b/fileformats/mp4/composer/include/moviefragmentrandomaccessatom.h
index 9cd0ceb..b69a0b5 100644
--- a/fileformats/mp4/composer/include/moviefragmentrandomaccessatom.h
+++ b/fileformats/mp4/composer/include/moviefragmentrandomaccessatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/moviefragmentrandomaccessoffsetatom.h b/fileformats/mp4/composer/include/moviefragmentrandomaccessoffsetatom.h
index 970e4d1..875a5a0 100644
--- a/fileformats/mp4/composer/include/moviefragmentrandomaccessoffsetatom.h
+++ b/fileformats/mp4/composer/include/moviefragmentrandomaccessoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/movieheaderatom.h b/fileformats/mp4/composer/include/movieheaderatom.h
index c98e4dc..c2e5f46 100644
--- a/fileformats/mp4/composer/include/movieheaderatom.h
+++ b/fileformats/mp4/composer/include/movieheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MovieHeaderAtom Class defines the overall media-independent information
     relevant to the MPEG-4 presentation as a whole.
diff --git a/fileformats/mp4/composer/include/mpeg4file.h b/fileformats/mp4/composer/include/mpeg4file.h
index 0f029ac..32a316c 100644
--- a/fileformats/mp4/composer/include/mpeg4file.h
+++ b/fileformats/mp4/composer/include/mpeg4file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     The PVA_FF_Mpeg4File Class is the class that will construct and maintain all the
     mecessary data structures to be able to render a valid MP4 file to disk.
@@ -60,10 +59,12 @@
 
         virtual ~PVA_FF_Mpeg4File();
 
+        // 03/21/01 Multiple instances support, commented out moved FROM private
         bool init(int32 mediaType,
                   void* osclFileServerSession = NULL,
                   uint32 fileAuthoringFlags = PVMP4FF_3GPP_DOWNLOAD_MODE);
 
+        // Member get methods
         PVA_FF_MovieAtom &getMutableMovieAtom()
         {
             return *_pmovieAtom;
@@ -117,14 +118,12 @@
                                 PVA_FF_UNICODE_HEAP_STRING keyWordInfo,
                                 uint16 langCode = LANGUAGE_CODE_UNKNOWN);
 
-        virtual void setLocationInfo(PVA_FF_UNICODE_STRING_PARAM locationName,
-                                     PVA_FF_UNICODE_STRING_PARAM locationInfoAstrBody,
-                                     PVA_FF_UNICODE_STRING_PARAM locationInfoAddNotes,
-                                     uint8 locationInfoRole,
-                                     uint32 locationInfoLongitude,
-                                     uint32 locationInfoLatitude,
-                                     uint32 locationInfoAltitude,
-                                     uint16 langCode = LANGUAGE_CODE_UNKNOWN);
+        virtual void setLocationInfo(PvmfAssetInfo3GPPLocationStruct*);
+
+        virtual void setAlbumInfo(PVA_FF_UNICODE_STRING_PARAM albumInfo,
+                                  uint16 langCode = LANGUAGE_CODE_UNKNOWN);
+
+        virtual void setRecordingYear(uint16 recordingYear);
 
 
         virtual void setCreationDate(PVA_FF_UNICODE_STRING_PARAM creationDate);
@@ -143,8 +142,6 @@
 
         // MPEG4 header retrieval methods for timed text
         virtual void setTextDecoderSpecificInfo(PVA_FF_TextSampleDescInfo *header, int32 trackID);
-        // Gets and sets for BIFS binary encoded scene
-        void setBIFSDecoderInfo(uint8 * header, int32 size);
 
         // Render to file with filename
         virtual bool renderToFile(PVA_FF_UNICODE_STRING_PARAM filename);
@@ -323,6 +320,13 @@
         uint32 _locationInfoAltitude;
         bool         _oSetLocationInfoDone;
 
+        PVA_FF_UNICODE_HEAP_STRING _albumInfo;
+        bool         _oSetAlbumDone;
+
+        uint16	_recordingYear;
+        bool	_oSetRecordingYearDone;
+
+
         PVA_FF_UNICODE_HEAP_STRING _creationDate;
         bool         _oSetCreationDateDone;
 
@@ -333,9 +337,6 @@
         PVA_FF_FileTypeAtom       *_pFileTypeAtom;
         PVA_FF_MovieAtom          *_pmovieAtom;
 
-        //A_FF_ZArray<PVA_FF_MediaDataAtom*> *_pmediaDataAtomVec; // PVA_FF_MediaDataAtom vector to hold media data
-        // This vector also holds the mdat atoms for the OD track
-        // as well as for the BIFS track
         Oscl_Vector<PVA_FF_MediaDataAtom*, OsclMemAllocator> *_pmediaDataAtomVec;
 
         // In movie fragment mode these parameters hold
@@ -375,15 +376,8 @@
         // the temporary file names will be different for every instances
         PVA_FF_UNICODE_HEAP_STRING _tempFilePostfix;
 
-        PVA_FF_ObjectDescriptor *_odAudio;
-        PVA_FF_ObjectDescriptor *_odVideo;
-        PVA_FF_TrackAtom        *_ODTrack;
-
         bool             _downLoadOnly;
 
-        PVA_FF_MediaDataAtom          *_od;
-        PVA_FF_ObjectDescriptorUpdate *_odu;
-
         int32 _codecType;
 
         // an output path for generated temporary files (.mdat)
@@ -433,6 +427,7 @@
 
         bool        _oFirstSampleEditMode;
         uint32      iCacheSize;
+        bool		_oIsFileOpen;
 };
 
 
diff --git a/fileformats/mp4/composer/include/mpeg4mediaheaderatom.h b/fileformats/mp4/composer/include/mpeg4mediaheaderatom.h
index 9538caf..6c5beb5 100644
--- a/fileformats/mp4/composer/include/mpeg4mediaheaderatom.h
+++ b/fileformats/mp4/composer/include/mpeg4mediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_Mpeg4MediaHeaderAtom Class is for streams other than visual and audio.
 */
diff --git a/fileformats/mp4/composer/include/mpegsampleentry.h b/fileformats/mp4/composer/include/mpegsampleentry.h
index e66ed19..15f0b29 100644
--- a/fileformats/mp4/composer/include/mpegsampleentry.h
+++ b/fileformats/mp4/composer/include/mpegsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MpegSampleEntry is used for hint tracks.
 */
@@ -75,6 +74,11 @@
             _pes->setESID(esid);
         }
 
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+        {
+            _pes->writeMaxSampleSize(_afp);
+        }
+
     private:
         void init();
         virtual void recomputeSize();
diff --git a/fileformats/mp4/composer/include/objectdescriptor.h b/fileformats/mp4/composer/include/objectdescriptor.h
index c2ee02f..be9dd78 100644
--- a/fileformats/mp4/composer/include/objectdescriptor.h
+++ b/fileformats/mp4/composer/include/objectdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ObjectDescriptor Class
 */
diff --git a/fileformats/mp4/composer/include/objectdescriptoratom.h b/fileformats/mp4/composer/include/objectdescriptoratom.h
index 11253e2..277ef43 100644
--- a/fileformats/mp4/composer/include/objectdescriptoratom.h
+++ b/fileformats/mp4/composer/include/objectdescriptoratom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ObjectDescriptorAtom Class contains an PVA_FF_ObjectDescriptor or an
     PVA_FF_InitialObjectDescriptor.
diff --git a/fileformats/mp4/composer/include/objectdescriptorupdate.h b/fileformats/mp4/composer/include/objectdescriptorupdate.h
index 9c32c05..60d4339 100644
--- a/fileformats/mp4/composer/include/objectdescriptorupdate.h
+++ b/fileformats/mp4/composer/include/objectdescriptorupdate.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ObjectDescriptorUpdate Class conveys a new list of ObjectDescriptors
     OD streams
diff --git a/fileformats/mp4/composer/include/out_content.h b/fileformats/mp4/composer/include/out_content.h
deleted file mode 100644
index 562a638..0000000
--- a/fileformats/mp4/composer/include/out_content.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-// A custom interface to allow the applet to adjust parameters
-
-#ifndef __ICONTENTINFO__
-#define __ICONTENTINFO__
-
-#include "pvcommon.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*typedef struct _CONTENTINFO
-    {
-    	WCHAR Title[256];
-    	WCHAR Author[256];
-    	WCHAR Copyright[256];
-    	WCHAR Description[256];
-    	WCHAR Rating[256];
-    } CONTENTINFO, *LPCONTENTINFO;
-    */
-    // {38BEEDC0-1242-11d4-9F78-0050DACFB6C8}
-    DEFINE_GUID(IID_IContentInfo,
-                0x38beedc0, 0x1242, 0x11d4, 0x9f, 0x78, 0x0, 0x50, 0xda, 0xcf, 0xb6, 0xc8);
-
-    DECLARE_INTERFACE_(IContentInfo, IUnknown)
-    {
-
-        STDMETHOD(SetContentInfo)(THIS_ LPCONTENTINFO lpContentInfo) PURE;
-        STDMETHOD(GetContentInfo)(THIS_ LPCONTENTINFO lpContentInfo) PURE;
-
-        STDMETHOD(SetVersion)(THIS_ BSTR version1, BSTR version2) PURE;
-        STDMETHOD(GetVersion)(THIS_ BSTR version1, BSTR version2) PURE;
-    };
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __ICONTENTINFO__
-
diff --git a/fileformats/mp4/composer/include/parentable.h b/fileformats/mp4/composer/include/parentable.h
index 907dbe0..81f4690 100644
--- a/fileformats/mp4/composer/include/parentable.h
+++ b/fileformats/mp4/composer/include/parentable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
 	This PVA_FF_Parentable Class is the base class for all other classes here - including
 	both Atoms and Descriptors.  This allows the maintenance of the tree structure
diff --git a/fileformats/mp4/composer/include/pv_standard.h b/fileformats/mp4/composer/include/pv_standard.h
deleted file mode 100644
index a5f5d05..0000000
--- a/fileformats/mp4/composer/include/pv_standard.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-#ifndef PV_STANDARD_H
-#define PV_STANDARD_H
-
-
-/* Type definitions */
-
-#ifndef int8
-typedef char int8;
-#endif
-
-#ifndef uint8
-typedef unsigned char uint8;
-#endif
-
-#ifndef int16
-typedef short int16;
-#endif
-
-#ifndef uint16
-typedef unsigned short uint16;
-#endif
-
-#ifndef int32
-typedef long int32;
-#endif
-
-#ifndef uint32
-typedef unsigned long uint32;
-#endif
-
-/* Architecture definitions */
-/*
-    Compiler information:
-    PV_COMPILER_VISUAL_CPLUSPLUS_PC Visual C++ compiler for PC platform
-*/
-
-
-#if defined(PV_PROCESSOR_PENTIUM)
-#define BYTE_ORDER_LITTLE_ENDIAN
-#elif defined(PV_PROCESSOR_PENTIUM_2)
-#define BYTE_ORDER_LITTLE_ENDIAN
-#elif defined(PV_PROCESSOR_PENTIUM_3)
-#define BYTE_ORDER_LITTLE_ENDIAN
-#elif defined(PV_PROCESSOR_INTEL_80386)
-#define BYTE_ORDER_LITTLE_ENDIAN
-#elif defined(PV_PROCESSOR_INTEL_80486)
-#define BYTE_ORDER_LITTLE_ENDIAN
-
-#elif defined(PV_PROCESSOR_INTEL_STRONGARM)
-/* CPU supports both little endian and big endian. Words must be aligned to word boundaries */
-#define INTEGERS_WORD_ALIGNED
-#elif defined(PV_PROCESSOR_MIPS_R4000)
-/* CPU supports both little endian and big endian. Words must be aligned to word boundaries */
-#define INTEGERS_WORD_ALIGNED
-#elif defined(PV_PROCESSOR_HITACHI_SH3)
-/* CPU supports both little endian and big endian. Words must be aligned to word boundaries */
-#define INTEGERS_WORD_ALIGNED
-#else
-#error need to specify the target processor
-#endif
-
-#if defined(PV_OS_WINDOWS_95)
-#define PV_OS_WIN32
-#elif defined(PV_OS_WINDOWS_98)
-#define PV_OS_WIN32
-#elif defined(PV_OS_WINDOWS_2000)
-#define PV_OS_WIN32
-#elif defined(PV_OS_WINDOWS_NT)
-#define PV_OS_WIN32
-#else
-#define PV_OS_WIN32
-#endif
-
-/* Use PV_OS_VERSION to specify the OS version */
-
-#if !defined(BYTE_ORDER_LITTLE_ENDIAN) && !defined(BYTE_ORDER_BIG_ENDIAN)
-#error must define either BYTE_ORDER_LITTLE_ENDIAN or BYTE_ORDER_BIG_ENDIAN
-#endif
-
-
-#endif
diff --git a/fileformats/mp4/composer/include/pvbase.h b/fileformats/mp4/composer/include/pvbase.h
deleted file mode 100644
index 9ad96cb..0000000
--- a/fileformats/mp4/composer/include/pvbase.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-
-
-
-// When compiling in WIN32, include necessary windows header files
-//#ifdef PV_OS_WIN32
-//#include <windows.h>
-//#else
-// #include "pv_standard.h"
-//#endif
-
diff --git a/fileformats/mp4/composer/include/pvfstream.h b/fileformats/mp4/composer/include/pvfstream.h
deleted file mode 100644
index 09bb8a2..0000000
--- a/fileformats/mp4/composer/include/pvfstream.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-
-#include <fstream>
-
-#include "oscl_file_io.h"
-
-
diff --git a/fileformats/mp4/composer/include/pviostream.h b/fileformats/mp4/composer/include/pviostream.h
deleted file mode 100644
index 05d4122..0000000
--- a/fileformats/mp4/composer/include/pviostream.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-
-#ifndef __PVIOSTREAM_H__
-#define __PVIOSTREAM_H__
-
-#endif
diff --git a/fileformats/mp4/composer/include/pvstring.h b/fileformats/mp4/composer/include/pvstring.h
deleted file mode 100644
index e5b0029..0000000
--- a/fileformats/mp4/composer/include/pvstring.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-
-
-#include "oscl_string.h"
-
-typedef OSCL_wString pvunicodestring;
-typedef OSCL_cString pvstdstring;
-
diff --git a/fileformats/mp4/composer/include/pvuserdataatom.h b/fileformats/mp4/composer/include/pvuserdataatom.h
deleted file mode 100644
index 3cf8d21..0000000
--- a/fileformats/mp4/composer/include/pvuserdataatom.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_UserDataAtom Class is a container atom for informative user-data.
-*/
-
-
-#ifndef __PVUserDataAtom_H__
-#define __PVUserDataAtom_H__
-
-#include "atom.h"
-#include "a_isucceedfail.h"
-#include "atomutils.h"
-
-class PVA_FF_PVUserDataAtom : public PVA_FF_Atom, public PVA_FF_ISucceedFail
-{
-
-    public:
-        PVA_FF_PVUserDataAtom(); // Constructor
-        virtual ~PVA_FF_PVUserDataAtom();
-
-        // Member sets
-        void setVersion(PVA_FF_UNICODE_STRING_PARAM version);
-        void setTitle(PVA_FF_UNICODE_STRING_PARAM title);
-        void setAuthor(PVA_FF_UNICODE_STRING_PARAM author);
-        void setCopyright(PVA_FF_UNICODE_STRING_PARAM copyright);
-        void setDescription(PVA_FF_UNICODE_STRING_PARAM description);
-        void setRating(PVA_FF_UNICODE_STRING_PARAM ratingInfo);
-        void setCreationDate(PVA_FF_UNICODE_STRING_PARAM creationdate);
-
-        // Member gets
-        uint32 getFourCC() const
-        {
-            return _fourCC;    // Special member get
-        }
-        virtual void recomputeSize();
-
-        // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
-
-        uint32          _fourCC;
-        PVA_FF_UNICODE_HEAP_STRING _version; // Static for the version of the file format code
-        PVA_FF_UNICODE_HEAP_STRING _title;
-        PVA_FF_UNICODE_HEAP_STRING _author;
-        PVA_FF_UNICODE_HEAP_STRING _copyright;
-        PVA_FF_UNICODE_HEAP_STRING _description;
-        PVA_FF_UNICODE_HEAP_STRING _rating;
-        PVA_FF_UNICODE_HEAP_STRING _creationDate;
-};
-
-class PVA_FF_PVEntityTagAtom : public PVA_FF_Atom, public PVA_FF_ISucceedFail
-{
-
-    public:
-        PVA_FF_PVEntityTagAtom(); // Constructor
-        virtual ~PVA_FF_PVEntityTagAtom() {};
-
-        // Member sets
-        void setEntityTag(PVA_FF_UNICODE_STRING_PARAM etag);
-
-        virtual void recomputeSize();
-
-        // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
-
-        PVA_FF_UNICODE_HEAP_STRING _etag;
-};
-
-class PVA_FF_PVContentTypeAtom : public PVA_FF_Atom
-{
-    public:
-        PVA_FF_PVContentTypeAtom();
-        virtual ~PVA_FF_PVContentTypeAtom() {};
-
-        void setContentType(uint32 typeFlags);
-
-        virtual void recomputeSize();
-
-        // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
-
-    private:
-        uint32 _contentType;
-};
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/pvvector.h b/fileformats/mp4/composer/include/pvvector.h
deleted file mode 100644
index b26cd97..0000000
--- a/fileformats/mp4/composer/include/pvvector.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-
-//#include <vector>
-
diff --git a/fileformats/mp4/composer/include/randomaccessatom.h b/fileformats/mp4/composer/include/randomaccessatom.h
deleted file mode 100644
index 9ec58cc..0000000
--- a/fileformats/mp4/composer/include/randomaccessatom.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*     -------------------------------------------------------------------       */
-/*                            MPEG-4 PVA_FF_RandomAccessAtom Class                      */
-/*     -------------------------------------------------------------------       */
-/*********************************************************************************/
-
-#ifndef __RandomAccessAtom_H__
-#define __RandomAccessAtom_H__
-
-#include "fullatom.h"
-
-class PVA_FF_RandomAccessAtom : public PVA_FF_FullAtom
-{
-
-    public:
-        //Methods
-        PVA_FF_RandomAccessAtom(); 			// Constructor
-        virtual ~PVA_FF_RandomAccessAtom() {};	// Destructor
-        void setRandomAccessDenied(bool denied)
-        {
-            random_access_denied = denied;    // sets the random access flag
-        }
-
-        virtual void recomputeSize();
-
-        // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
-        virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
-
-        uint8		random_access_denied;
-};
-
-
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/renderable.h b/fileformats/mp4/composer/include/renderable.h
index 8418b27..3d99f75 100644
--- a/fileformats/mp4/composer/include/renderable.h
+++ b/fileformats/mp4/composer/include/renderable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_Renderable Class is the base class for ALL other components of the MP4
     file format - including Atoms, Descriptors, and Commands.  This class provides
diff --git a/fileformats/mp4/composer/include/sampledescriptionatom.h b/fileformats/mp4/composer/include/sampledescriptionatom.h
index 0372d64..d13cb83 100644
--- a/fileformats/mp4/composer/include/sampledescriptionatom.h
+++ b/fileformats/mp4/composer/include/sampledescriptionatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleDescriptionAtom Class gives detailed information about the codeing
     type used, and any initialization information needed for coding.
@@ -103,6 +102,9 @@
             }
         }
 
+        void SetMaxSampleSize(uint32);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
+
     protected:
         virtual void recomputeSize();
 
diff --git a/fileformats/mp4/composer/include/sampleentry.h b/fileformats/mp4/composer/include/sampleentry.h
index 7afadf4..9a56fb3 100644
--- a/fileformats/mp4/composer/include/sampleentry.h
+++ b/fileformats/mp4/composer/include/sampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
 	This PVA_FF_SampleEntry Class is the base class for the HinstSampleEntry,
 	PVA_FF_VisualSampleEntry, PVA_FF_AudioSampleEntry. and PVA_FF_MpegSampleEntry classes.
diff --git a/fileformats/mp4/composer/include/samplesizeatom.h b/fileformats/mp4/composer/include/samplesizeatom.h
index 03c8e4d..9f1a6b7 100644
--- a/fileformats/mp4/composer/include/samplesizeatom.h
+++ b/fileformats/mp4/composer/include/samplesizeatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleSizeAtom Class contains the sample count and a table giving the
     size of each sample.
diff --git a/fileformats/mp4/composer/include/sampletableatom.h b/fileformats/mp4/composer/include/sampletableatom.h
index aa21d19..effe657 100644
--- a/fileformats/mp4/composer/include/sampletableatom.h
+++ b/fileformats/mp4/composer/include/sampletableatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleTableAtom Class contains all the time and data indexing of the
     media samples in a track.
@@ -117,11 +116,6 @@
         {
             _psyncSampleAtom = ssa;
         }
-        /*
-        const PVA_FF_CompositionOffsetAtom *getCompositionOffset(); // No inline for optional atoms - may have null value
-        const PVA_FF_ShadowSyncSampleAtom *getShadowSynchAtom(); // No inline for optional atoms - may have null value
-        const PVA_FF_DegradationPriorityAtom *getDegradationPriorityAtom(); // No inline for optional atoms - may have null value
-        */
         // Creation methods for optional member atoms
         void createCompositionOffsetAtom() {};
         void createSyncSampleAtom() {};
@@ -163,16 +157,18 @@
             _psampleDescriptionAtom->setH263ProfileLevel(profile, level);
         }
 
-        void setBIFSODSampleDuration(int32 duration)
-        {
-            _ptimeToSampleAtom->setBIFSODSampleDuration(duration);
-        }
-
         void setESID(uint16 esid)
         {
             _psampleDescriptionAtom->setESID(esid);
         }
+        void SetMaxSampleSize(uint32);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
 
+
+        uint32 getSampleCount() const
+        {
+            return _psampleSizeAtom->getSampleCount();
+        }
     private:
         virtual void recomputeSize();
 
diff --git a/fileformats/mp4/composer/include/sampletochunkatom.h b/fileformats/mp4/composer/include/sampletochunkatom.h
index 5233be8..6c38362 100644
--- a/fileformats/mp4/composer/include/sampletochunkatom.h
+++ b/fileformats/mp4/composer/include/sampletochunkatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleSizeAtom Class contains the sample count and a table giving the
     size of each sample.
diff --git a/fileformats/mp4/composer/include/shadowsyncsampleatom.h b/fileformats/mp4/composer/include/shadowsyncsampleatom.h
index d1c95d9..ed90b89 100644
--- a/fileformats/mp4/composer/include/shadowsyncsampleatom.h
+++ b/fileformats/mp4/composer/include/shadowsyncsampleatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ShadowSyncSampleAtom Class provides an optional set of synch samples
     when seeking or for similar purposes.
diff --git a/fileformats/mp4/composer/include/slconfigdescriptor.h b/fileformats/mp4/composer/include/slconfigdescriptor.h
index ec2b5f4..4d3856c 100644
--- a/fileformats/mp4/composer/include/slconfigdescriptor.h
+++ b/fileformats/mp4/composer/include/slconfigdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SLConfigDescriptor (SyncLayerDescriptor) Class
 */
diff --git a/fileformats/mp4/composer/include/soundmediaheaderatom.h b/fileformats/mp4/composer/include/soundmediaheaderatom.h
index 6c42b9a..5717840 100644
--- a/fileformats/mp4/composer/include/soundmediaheaderatom.h
+++ b/fileformats/mp4/composer/include/soundmediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SoundMediaHeaderAtom Class contains general presentation information,
     independent of coding, about the audio media within the stream.
diff --git a/fileformats/mp4/composer/include/stylerecord.h b/fileformats/mp4/composer/include/stylerecord.h
index b64bce5..8cbb746 100644
--- a/fileformats/mp4/composer/include/stylerecord.h
+++ b/fileformats/mp4/composer/include/stylerecord.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/syncsampleatom.h b/fileformats/mp4/composer/include/syncsampleatom.h
index f11d1b5..b47abbb 100644
--- a/fileformats/mp4/composer/include/syncsampleatom.h
+++ b/fileformats/mp4/composer/include/syncsampleatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SyncSampleAtom Class provides a compact marking of the random access
     points within the stream.
diff --git a/fileformats/mp4/composer/include/textsampledescinfo.h b/fileformats/mp4/composer/include/textsampledescinfo.h
index d4aa8ab..f873e3e 100644
--- a/fileformats/mp4/composer/include/textsampledescinfo.h
+++ b/fileformats/mp4/composer/include/textsampledescinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/textsampleentry.h b/fileformats/mp4/composer/include/textsampleentry.h
index 3664550..3ea4dcd 100644
--- a/fileformats/mp4/composer/include/textsampleentry.h
+++ b/fileformats/mp4/composer/include/textsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,7 +53,6 @@
         OSCL_IMPORT_REF void setfontSize(uint8 fontsize);
         OSCL_IMPORT_REF void setTextColourRGBA(uint8* RGBA);
         OSCL_IMPORT_REF void setFontListSize(uint16 fontlistsize);
-        //OSCL_IMPORT_REF PVA_FF_FontRecord   *setFontRecord(uint16 fontlistID,uint16 fontID,int8 fontLength,uint8* fontName);
         OSCL_IMPORT_REF void   *setFontRecord(uint16 fontlistID, uint16 fontID, int8 fontLength, uint8* fontName);
 
         void setSample(void* sample, uint32 size);
diff --git a/fileformats/mp4/composer/include/textsamplemodifiers.h b/fileformats/mp4/composer/include/textsamplemodifiers.h
index 7d23d1d..16a2c60 100644
--- a/fileformats/mp4/composer/include/textsamplemodifiers.h
+++ b/fileformats/mp4/composer/include/textsamplemodifiers.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 
 #include "oscl_file_io.h"
 #include "atom.h"
-
 #include "atomutils.h"
 #include "a_atomdefs.h"
 #include "boxrecord.h"
@@ -243,11 +242,4 @@
         uint16  _pendCharOffset;
 };
 
-/*class TextSampleModifiers :PVA_FF_ISucceedFail
-{
-
-};*/
-
-
-
 #endif
diff --git a/fileformats/mp4/composer/include/timetosampleatom.h b/fileformats/mp4/composer/include/timetosampleatom.h
index b4f2b34..c166b1b 100644
--- a/fileformats/mp4/composer/include/timetosampleatom.h
+++ b/fileformats/mp4/composer/include/timetosampleatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TimeToSampleAtom Class contains a compact version of a table that allows
     indexing from decoding to sample number.
@@ -48,8 +47,6 @@
         // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp);
 
-        void setBIFSODSampleDuration(int32 duration);
-
     private:
         void addDelta(int32 delta);
         void addEntry(uint32 count, int32 delta);
diff --git a/fileformats/mp4/composer/include/trackatom.h b/fileformats/mp4/composer/include/trackatom.h
index cabdf29..f9b521d 100644
--- a/fileformats/mp4/composer/include/trackatom.h
+++ b/fileformats/mp4/composer/include/trackatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackAtom Class is the container for a single track in the MPEG-4
     presentation.
@@ -92,7 +91,6 @@
         {
             return _ptrackReference;
         }
-        //const PVA_FF_EditAtom &getEditAtom(); // No inline for optional atoms - may have null value
 
         // Add a reference to another track - return index of reference in table (1-based)
         int32 addTrackReference(uint32 ref);
@@ -245,11 +243,6 @@
             _pmediaAtom->setH263ProfileLevel(profile, level);
         }
 
-        void setBIFSODSampleDuration(int32 duration)
-        {
-            _pmediaAtom->setBIFSODSampleDuration(duration);
-        }
-
         bool Is3GPPTrack()
         {
             return _o3GPPCompliant;
@@ -266,6 +259,10 @@
             return _setDecoderSpecificInfoDone;
         }
 
+        uint32 getSampleCount() const
+        {
+            return _pmediaAtom->getSampleCount();
+        }
 
         bool IsFirstSample()
         {
@@ -273,6 +270,8 @@
         }
         void updateLastTSEntry(uint32 ts);
         void setVideoWidthHeight(int16 width, int16 height);
+        void SetMaxSampleSize(uint32);
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP*);
 
     private:
         virtual void recomputeSize();
diff --git a/fileformats/mp4/composer/include/trackextendsatom.h b/fileformats/mp4/composer/include/trackextendsatom.h
index 6db8fa0..d8fed4a 100644
--- a/fileformats/mp4/composer/include/trackextendsatom.h
+++ b/fileformats/mp4/composer/include/trackextendsatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/trackfragmentatom.h b/fileformats/mp4/composer/include/trackfragmentatom.h
index 421ec3e..f3d6014 100644
--- a/fileformats/mp4/composer/include/trackfragmentatom.h
+++ b/fileformats/mp4/composer/include/trackfragmentatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,15 @@
 
         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP* fp);
 
+        uint32 getSampleCount() const
+        {
+            uint32 lSampleCount = 0;
+            for (uint32 ii = 0; ii < _pTrunList->size(); ii++)
+            {
+                lSampleCount +=	((*_pTrunList)[ii])->getSampleCount();
+            }
+            return lSampleCount;
+        }
 
     private:
 
diff --git a/fileformats/mp4/composer/include/trackfragmentheaderatom.h b/fileformats/mp4/composer/include/trackfragmentheaderatom.h
index 6dd555f..eea1129 100644
--- a/fileformats/mp4/composer/include/trackfragmentheaderatom.h
+++ b/fileformats/mp4/composer/include/trackfragmentheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/trackfragmentrandomaccessatom.h b/fileformats/mp4/composer/include/trackfragmentrandomaccessatom.h
index 805f55b..379cb35 100644
--- a/fileformats/mp4/composer/include/trackfragmentrandomaccessatom.h
+++ b/fileformats/mp4/composer/include/trackfragmentrandomaccessatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/include/trackfragmentrunatom.h b/fileformats/mp4/composer/include/trackfragmentrunatom.h
index ccf2282..46d8c8a 100644
--- a/fileformats/mp4/composer/include/trackfragmentrunatom.h
+++ b/fileformats/mp4/composer/include/trackfragmentrunatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,7 +49,10 @@
         void	updateLastTSEntry(uint32 ts);
 
         virtual bool renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP* fp);
-
+        uint32 getSampleCount() const
+        {
+            return _sampleCount;
+        }
     private:
 
         uint32		_currentTimestamp;
diff --git a/fileformats/mp4/composer/include/trackheaderatom.h b/fileformats/mp4/composer/include/trackheaderatom.h
index 124c2c1..50cd97a 100644
--- a/fileformats/mp4/composer/include/trackheaderatom.h
+++ b/fileformats/mp4/composer/include/trackheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackHeaderAtom Class specifies the characteristics of a single MPEG-4
     track.
diff --git a/fileformats/mp4/composer/include/trackreferenceatom.h b/fileformats/mp4/composer/include/trackreferenceatom.h
index 93d3960..4eb7af5 100644
--- a/fileformats/mp4/composer/include/trackreferenceatom.h
+++ b/fileformats/mp4/composer/include/trackreferenceatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackReferenceAtom Class provides a reference from the containing stream
     to another stream in the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/include/trackreferencetypeatom.h b/fileformats/mp4/composer/include/trackreferencetypeatom.h
index 8b6b992..dcfc1c2 100644
--- a/fileformats/mp4/composer/include/trackreferencetypeatom.h
+++ b/fileformats/mp4/composer/include/trackreferencetypeatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackReferenceTypeAtom Class provides a reference from the containing stream
     to another stream in the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/include/userdataatom.h b/fileformats/mp4/composer/include/userdataatom.h
index 699cad9..5229355 100644
--- a/fileformats/mp4/composer/include/userdataatom.h
+++ b/fileformats/mp4/composer/include/userdataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_UserDataAtom Class is a container atom for informative user-data.
 */
diff --git a/fileformats/mp4/composer/include/videomediaheaderatom.h b/fileformats/mp4/composer/include/videomediaheaderatom.h
index 5bafec6..f41e73b 100644
--- a/fileformats/mp4/composer/include/videomediaheaderatom.h
+++ b/fileformats/mp4/composer/include/videomediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_VideoMediaHeaderAtom Class contains general presentation information,
     independent of coding, about the visual media within the stream.
diff --git a/fileformats/mp4/composer/include/videoutils.h b/fileformats/mp4/composer/include/videoutils.h
deleted file mode 100644
index c779723..0000000
--- a/fileformats/mp4/composer/include/videoutils.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-	This PVA_FF_VideoUtils Class contains sime useful methods for operating on
-	Video frames represented as IMediaSamples.
-*/
-
-#ifndef __VideoUtils_H__
-#define __VideoUtils_H__
-
-#include "oscl_types.h"
-#include "oscl_base.h"
-
-class PVA_FF_VideoUtils
-{
-
-    public:
-        static uint8 getFrameModuloTimeBase(uint8 *psample);
-        static uint16 getFrameVOPTimeIncrement(uint8 *psample);
-        static uint32 getNumberBits(uint8 *psample, uint32 size);
-
-};
-
-
-
-#endif
-
diff --git a/fileformats/mp4/composer/include/visualsampleentry.h b/fileformats/mp4/composer/include/visualsampleentry.h
index 7884702..4326608 100644
--- a/fileformats/mp4/composer/include/visualsampleentry.h
+++ b/fileformats/mp4/composer/include/visualsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_VisualSampleEntry Class is used for visual streams.
 */
@@ -86,6 +85,10 @@
         {
             _pes->setESID(esid);
         }
+        void writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+        {
+            _pes->writeMaxSampleSize(_afp);
+        }
 
     private:
         void init();
diff --git a/fileformats/mp4/composer/src/amrdecoderspecificinfo.cpp b/fileformats/mp4/composer/src/amrdecoderspecificinfo.cpp
index 0607473..3e47dff 100644
--- a/fileformats/mp4/composer/src/amrdecoderspecificinfo.cpp
+++ b/fileformats/mp4/composer/src/amrdecoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/src/amrdecoderspecificinfo3gpp.cpp b/fileformats/mp4/composer/src/amrdecoderspecificinfo3gpp.cpp
index 634691a..960b2c3 100644
--- a/fileformats/mp4/composer/src/amrdecoderspecificinfo3gpp.cpp
+++ b/fileformats/mp4/composer/src/amrdecoderspecificinfo3gpp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/src/amrsampleentry.cpp b/fileformats/mp4/composer/src/amrsampleentry.cpp
index 61acada..cbef66f 100644
--- a/fileformats/mp4/composer/src/amrsampleentry.cpp
+++ b/fileformats/mp4/composer/src/amrsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_AudioSampleEntry Class is used for visual streams.
 */
@@ -47,13 +46,13 @@
     _reserved1[0] = 0;
     _reserved1[1] = 0;
 
-    _reserved2 = 2; // = 2;
-    _reserved3 = 16; // = 16;
-    _reserved4 = 0; // = 0;
+    _reserved2 = 2;
+    _reserved3 = 16;
+    _reserved4 = 0;
 
-    _timeScale = 0; // Get it from the track
+    _timeScale = 0;
 
-    _reserved5 = 0; // = 0;
+    _reserved5 = 0;
 
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_AMRSpecificAtom, (), pAMRSpecificAtom);
 
@@ -153,6 +152,3 @@
     }
 }
 
-
-
-
diff --git a/fileformats/mp4/composer/src/assetinfoatoms.cpp b/fileformats/mp4/composer/src/assetinfoatoms.cpp
index 353c955..60a8aa9 100644
--- a/fileformats/mp4/composer/src/assetinfoatoms.cpp
+++ b/fileformats/mp4/composer/src/assetinfoatoms.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-//#define __IMPLEMENT_AssetInfoAtoms__
-
-
 #include "a_atomdefs.h"
 #include "assetinfoatoms.h"
 
@@ -111,6 +108,22 @@
 
 }
 
+PVA_FF_AssetInfoAlbumAtom::PVA_FF_AssetInfoAlbumAtom()
+        : PVA_FF_FullAtom(ASSET_INFO_ALBUM_TITLE_ATOM, 0, 0)
+{
+    _albumTitle = (_STRLIT(""));
+    _langCode = LANGUAGE_CODE_UNKNOWN;
+    _byteOrderMask = BYTE_ORDER_MASK;
+    recomputeSize();
+}
+
+PVA_FF_AssetInfoRecordingYearAtom::PVA_FF_AssetInfoRecordingYearAtom()
+        : PVA_FF_FullAtom(ASSET_INFO_RECORDING_YEAR_ATOM, 0, 0)
+{
+    _recordingYear = 0;
+    recomputeSize();
+}
+
 PVA_FF_AssetInfoKeyWordsAtom::~PVA_FF_AssetInfoKeyWordsAtom()
 {
     if (_pKeyWordVect != NULL)
@@ -133,9 +146,10 @@
     PVA_FF_UNICODE_HEAP_STRING aKeyWordInfo)
 
 {
+    OSCL_UNUSED_ARG(aKeyWordBinarySize);
     _byteOrderMask = BYTE_ORDER_MASK;
-    _keyWordSize	= aKeyWordBinarySize;
     _keyWordInfo	= aKeyWordInfo;
+    _keyWordSize = ((_keyWordInfo.get_size() + 1) * 2) + sizeof(_byteOrderMask);;// 1 for the NULL entry
 
 }
 
@@ -170,7 +184,6 @@
 bool
 PVA_FF_AssetInfoTitleAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
 {
-    //recomputeSize();
     int32 rendered = 0; // Keep track of number of bytes rendered
 
     // Render PVA_FF_Atom type and size
@@ -197,7 +210,6 @@
         return false;
     }
     rendered += _title.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 
 }
@@ -246,7 +258,6 @@
         return false;
     }
     rendered += _description.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -293,7 +304,6 @@
         return false;
     }
     rendered += _cprt.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -340,7 +350,6 @@
         return false;
     }
     rendered += _performer.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -387,7 +396,6 @@
         return false;
     }
     rendered += _author.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -434,7 +442,6 @@
         return false;
     }
     rendered += _genre.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -497,7 +504,6 @@
         return false;
     }
     rendered += _ratingInfo.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -559,7 +565,6 @@
         return false;
     }
     rendered += _classificationInfo.get_size() + 1; // 1 for the NULL entry
-    //recomputeSize();
     return true;
 }
 
@@ -657,6 +662,10 @@
         return false;
     }
     rendered += 1;
+    if (_pKeyWordVect->size() < _keyWordCnt)
+    {
+        return false;
+    }
 
     // calculate size of each object in the structure
     for (int i = 0; i < _keyWordCnt; i++)
@@ -773,3 +782,85 @@
     rendered += _locationInfoAddNotes.get_size() + 1; // 1 for the NULL entry
     return true;
 }
+
+
+void PVA_FF_AssetInfoAlbumAtom::recomputeSize()
+{
+    _size = getDefaultSize();
+    _size += sizeof(_langCode);
+    _size += sizeof(_byteOrderMask);
+    _size += 2 * (_albumTitle.get_size() + 1);
+    // Update the size of the parent atom since this child atom may have changed
+    if (_pparent != NULL)
+    {
+        _pparent->recomputeSize();
+    }
+}
+
+bool
+PVA_FF_AssetInfoAlbumAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
+{
+    //recomputeSize();
+    int32 rendered = 0; // Keep track of number of bytes rendered
+
+    // Render PVA_FF_Atom type and size
+    if (!renderAtomBaseMembers(fp))
+    {
+        return false;
+    }
+    rendered += getDefaultSize();
+
+    if (!PVA_FF_AtomUtils::render16(fp, _langCode))
+    {
+        return false;
+    }
+    rendered += 2;
+
+    if (!PVA_FF_AtomUtils::render16(fp, _byteOrderMask))
+    {
+        return false;
+    }
+    rendered += 2;
+
+    if (!PVA_FF_AtomUtils::renderNullTerminatedUnicodeString(fp, _albumTitle))
+    {
+        return false;
+    }
+    rendered += _albumTitle.get_size() + 1; // 1 for the NULL entry
+    //recomputeSize();
+    return true;
+
+}
+
+void PVA_FF_AssetInfoRecordingYearAtom::recomputeSize()
+{
+    _size = getDefaultSize();
+    _size += sizeof(_recordingYear);
+    if (_pparent != NULL)
+    {
+        _pparent->recomputeSize();
+    }
+}
+
+bool
+PVA_FF_AssetInfoRecordingYearAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
+{
+    //recomputeSize();
+    int32 rendered = 0; // Keep track of number of bytes rendered
+
+    // Render PVA_FF_Atom type and size
+    if (!renderAtomBaseMembers(fp))
+    {
+        return false;
+    }
+    rendered += getDefaultSize();
+
+    if (!PVA_FF_AtomUtils::render16(fp, _recordingYear))
+    {
+        return false;
+    }
+    rendered += 2;
+    return true;
+
+}
+
diff --git a/fileformats/mp4/composer/src/atom.cpp b/fileformats/mp4/composer/src/atom.cpp
index dd5d5fc..d8098aa 100644
--- a/fileformats/mp4/composer/src/atom.cpp
+++ b/fileformats/mp4/composer/src/atom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_Atom Class is the base class for all other Atoms in the MPEG-4 File
     Format.
diff --git a/fileformats/mp4/composer/src/atomutils.cpp b/fileformats/mp4/composer/src/atomutils.cpp
index abe21b2..5c3e055 100644
--- a/fileformats/mp4/composer/src/atomutils.cpp
+++ b/fileformats/mp4/composer/src/atomutils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/audiosampleentry.cpp b/fileformats/mp4/composer/src/audiosampleentry.cpp
index 2505596..f4505ee 100644
--- a/fileformats/mp4/composer/src/audiosampleentry.cpp
+++ b/fileformats/mp4/composer/src/audiosampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_AudioSampleEntry Class is used for visual streams.
 */
@@ -26,7 +25,6 @@
 #include "atomutils.h"
 #include "a_atomdefs.h"
 
-//extern pvostream& operator<<(pvostream& fp, const PVA_FF_ESDAtom &a);
 
 // Constructor
 PVA_FF_AudioSampleEntry::PVA_FF_AudioSampleEntry(int32 codecType)
@@ -53,15 +51,13 @@
     _reserved1[0] = 0;
     _reserved1[1] = 0;
 
-    _reserved2 = 2; // = 2;
-    _reserved3 = 16; // = 16;
-    _reserved4 = 0; // = 0;
+    _reserved2 = 2;
+    _reserved3 = 16;
+    _reserved4 = 0;
 
-    _timeScale = 0; // Get it from the track
+    _timeScale = 0;
 
-    _reserved5 = 0; // = 0;
-
-
+    _reserved5 = 0;
 }
 
 // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
@@ -155,7 +151,3 @@
         _pparent->recomputeSize();
     }
 }
-
-
-
-
diff --git a/fileformats/mp4/composer/src/avcconfiguration.cpp b/fileformats/mp4/composer/src/avcconfiguration.cpp
index 15ce0aa..6b9f5b2 100644
--- a/fileformats/mp4/composer/src/avcconfiguration.cpp
+++ b/fileformats/mp4/composer/src/avcconfiguration.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -284,6 +284,10 @@
         return false;
     }
     rendered += 1;
+    if (_pictureParameterSetVec->size() < _numPictureParameterSets)
+    {
+        return false;
+    }
     for (int j = 0;j < _numPictureParameterSets;j++)
     {
 
@@ -317,25 +321,29 @@
 
     size += 7; // wrote six one byte data
 
-    for (int i = 0;i < _numSequenceParameterSets;i++)
+    if (_sequenceParameterSetVec->size() >= _numSequenceParameterSets)
     {
-        PVA_FF_ParameterSet *pSet = (*_sequenceParameterSetVec)[i];
+        for (int i = 0;i < _numSequenceParameterSets;i++)
+        {
+            PVA_FF_ParameterSet *pSet = (*_sequenceParameterSetVec)[i];
 
-        uint16	length = pSet->getParameterSetLength();
-        size += 2;
-        size += length;
+            uint16	length = pSet->getParameterSetLength();
+            size += 2;
+            size += length;
+        }
     }
-    for (int j = 0;j < _numPictureParameterSets;j++)
+    if (_pictureParameterSetVec->size() >= _numPictureParameterSets)
     {
-        PVA_FF_ParameterSet *pSet = (*_pictureParameterSetVec)[j];
+        for (int j = 0;j < _numPictureParameterSets;j++)
+        {
+            PVA_FF_ParameterSet *pSet = (*_pictureParameterSetVec)[j];
 
-        uint16	length = pSet->getParameterSetLength();
-        size += 2;
-        size += length;
+            uint16	length = pSet->getParameterSetLength();
+            size += 2;
+            size += length;
+        }
     }
 
-
-
     _size = size;
 
     // Update size of parent
diff --git a/fileformats/mp4/composer/src/avcsampleentry.cpp b/fileformats/mp4/composer/src/avcsampleentry.cpp
index b93a108..0d81351 100644
--- a/fileformats/mp4/composer/src/avcsampleentry.cpp
+++ b/fileformats/mp4/composer/src/avcsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/basecommand.cpp b/fileformats/mp4/composer/src/basecommand.cpp
deleted file mode 100644
index 852aff5..0000000
--- a/fileformats/mp4/composer/src/basecommand.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_BaseCommand Class
-*/
-
-#define IMPLEMENT_BaseCommand
-
-#include "basecommand.h"
-#include "atomutils.h"
-#include "a_atomdefs.h"
-
-
-// Constructor
-PVA_FF_BaseCommand::PVA_FF_BaseCommand(uint8 tag)
-{
-    _sizeOfClass = 0;
-    _sizeOfSizeField = DEFAULT_COMMAND_SIZE; // 1
-    _tag = tag;
-}
-
-// Destructor
-PVA_FF_BaseCommand::~PVA_FF_BaseCommand()
-{
-    // Empty
-}
-
-
-// Rendering the PVA_FF_BaseCommand members in proper format (bitlengths, etc.)
-// to an ostream
-int
-PVA_FF_BaseCommand::renderBaseCommandMembers(MP4_AUTHOR_FF_FILE_IO_WRAP *fp) const
-{
-    if (!PVA_FF_AtomUtils::render8(fp, getTag()))
-    {
-        return 0;
-    }
-    int numBytesRendered = 1;
-
-    // Render attributes of the PVA_FF_BaseCommand class
-    int32 numBytes = renderSizeOfClassToFileStream(fp);
-
-    if (numBytes > 0)
-    {
-        numBytesRendered += numBytes;
-    }
-    else
-    {
-        numBytesRendered = 0;
-    }
-
-    return numBytesRendered;
-}
diff --git a/fileformats/mp4/composer/src/basedescriptor.cpp b/fileformats/mp4/composer/src/basedescriptor.cpp
index 4f3f90d..6d0a3da 100644
--- a/fileformats/mp4/composer/src/basedescriptor.cpp
+++ b/fileformats/mp4/composer/src/basedescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_BaseDescriptor Class
 */
diff --git a/fileformats/mp4/composer/src/boxrecord.cpp b/fileformats/mp4/composer/src/boxrecord.cpp
index ff0ffd8..41692a1 100644
--- a/fileformats/mp4/composer/src/boxrecord.cpp
+++ b/fileformats/mp4/composer/src/boxrecord.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/chunkoffsetatom.cpp b/fileformats/mp4/composer/src/chunkoffsetatom.cpp
index 690c1a2..c92c9af 100644
--- a/fileformats/mp4/composer/src/chunkoffsetatom.cpp
+++ b/fileformats/mp4/composer/src/chunkoffsetatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ChunkOffsetAtom Class gives the index of each chunk into the
     containing FILE.
@@ -80,21 +79,10 @@
         case MEDIA_TYPE_TEXT: //for timed text track
         case MEDIA_TYPE_AUDIO:
         case MEDIA_TYPE_VISUAL:
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        case MEDIA_TYPE_IPMP:
         {
             _currentDataOffset += size;
         }
         break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-            break;
-        case MEDIA_TYPE_MPEG7:
-            break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-            break;
-        case MEDIA_TYPE_MPEG_J:
-            break;
         case MEDIA_TYPE_UNKNOWN:
         default:
             break;
@@ -147,6 +135,10 @@
     }
     rendered += 4;
 
+    if (_pchunkOffsets->size() < getEntryCount())
+    {
+        return false;
+    }
     for (uint32 i = 0; i < getEntryCount(); i++)
     {
         if (!PVA_FF_AtomUtils::render32(fp, (*_pchunkOffsets)[i]))
diff --git a/fileformats/mp4/composer/src/dataentryatom.cpp b/fileformats/mp4/composer/src/dataentryatom.cpp
index 26fa3d3..9833622 100644
--- a/fileformats/mp4/composer/src/dataentryatom.cpp
+++ b/fileformats/mp4/composer/src/dataentryatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataEntryAtom Class is the base class for the PVA_FF_DataEntryUrlAtom and
     PVA_FF_DataEntryUrnAtom classes.
diff --git a/fileformats/mp4/composer/src/dataentryurlatom.cpp b/fileformats/mp4/composer/src/dataentryurlatom.cpp
index 33ecedb..e4a05a9 100644
--- a/fileformats/mp4/composer/src/dataentryurlatom.cpp
+++ b/fileformats/mp4/composer/src/dataentryurlatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataEntryUrlAtom Class contains a table of data references which declare
     the location of the media data used within the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/src/datainformationatom.cpp b/fileformats/mp4/composer/src/datainformationatom.cpp
index ea9f65b..6086a9e 100644
--- a/fileformats/mp4/composer/src/datainformationatom.cpp
+++ b/fileformats/mp4/composer/src/datainformationatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataInformationAtom Class contains objects that declare the location
     of the media information within the stream.
@@ -28,8 +27,6 @@
 #include "a_atomdefs.h"
 #include "atomutils.h"
 
-//extern pvostream& operator<<(pvostream& fp, const PVA_FF_DataReferenceAtom &a);
-//extern pvostream& operator<<(pvostream& fp, PVA_FF_DataReferenceAtom &a);
 
 // Constructor
 PVA_FF_DataInformationAtom::PVA_FF_DataInformationAtom()
@@ -88,4 +85,3 @@
 }
 
 
-
diff --git a/fileformats/mp4/composer/src/datareferenceatom.cpp b/fileformats/mp4/composer/src/datareferenceatom.cpp
index 0c5c4ba..bfd1b08 100644
--- a/fileformats/mp4/composer/src/datareferenceatom.cpp
+++ b/fileformats/mp4/composer/src/datareferenceatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DataReferenceAtom Class contains a table of data references which declare
     the location of the media data used within the MPEG-4 presentation.
@@ -31,7 +30,6 @@
 
 typedef Oscl_Vector<PVA_FF_DataEntryAtom*, OsclMemAllocator> PVA_FF_DataEntryAtomVecType;
 
-//extern pvostream& operator<<(pvostream& fp, PVA_FF_DataEntryUrlAtom &a);
 // Constructor
 PVA_FF_DataReferenceAtom::PVA_FF_DataReferenceAtom()
         : PVA_FF_FullAtom(DATA_REFERENCE_ATOM, (uint8)0, (uint32)0)
@@ -129,5 +127,3 @@
         _pparent->recomputeSize();
     }
 }
-
-
diff --git a/fileformats/mp4/composer/src/decoderconfigdescriptor.cpp b/fileformats/mp4/composer/src/decoderconfigdescriptor.cpp
index c7bddd1..18bb291 100644
--- a/fileformats/mp4/composer/src/decoderconfigdescriptor.cpp
+++ b/fileformats/mp4/composer/src/decoderconfigdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderConfigDescriptor Class
 */
@@ -33,7 +32,7 @@
         : PVA_FF_BaseDescriptor(0x04)
 {
     _codecType = codecType;
-
+    iCurrFilePos = 0;
     init(streamType);
     recomputeSize();
 }
@@ -96,44 +95,6 @@
             PV_MP4_FF_NEW(fp->auditCB, PVA_FF_DecoderSpecificInfoVecType, (), _pdecSpecificInfoVec);
         }
         break;
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        {
-            _objectTypeIndication = 0x01; // No profile specified
-            _streamType = 0x01; // 0x01 for ObjectDescriptorStream,
-        }
-        break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-        {
-            _objectTypeIndication = 0xFF; // No profile specified
-            _streamType = 0x02; // 0x02 for ClockReferenceStream,
-        }
-        break;
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        {
-            _objectTypeIndication = 0x01; // No profile specified
-            _streamType = 0x03; // 0x03 for SceneDescriptionStream,
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_DecoderSpecificInfoVecType, (), _pdecSpecificInfoVec);
-        }
-        break;
-        case MEDIA_TYPE_MPEG7:
-        {
-            _objectTypeIndication = 0xFF; // No profile specified
-            _streamType = 0x06; // 0x06 for Mpeg7Stream,
-        }
-        break;
-        case MEDIA_TYPE_IPMP:
-        {
-            _objectTypeIndication = 0xFF; // No profile specified
-            _streamType = 0x07; // 0x07 for IPMPStream,
-        }
-        break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-        {
-            _objectTypeIndication = 0xFF; // No profile specified
-            _streamType = 0x08; // 0x08 for ObjectContentInfoStream,
-        }
-        break;
-        case MEDIA_TYPE_MPEG_J:
         default:
         {
             _objectTypeIndication = 0xFF; // No profile specified
@@ -216,6 +177,7 @@
     }
     rendered += 1;
 
+    iCurrFilePos = PVA_FF_AtomUtils::getCurrentFilePosition(fp);
     if (!PVA_FF_AtomUtils::render24(fp, _bufferSizeDB))
     {
         return false;
@@ -279,3 +241,14 @@
     }
 
 }
+
+void
+PVA_FF_DecoderConfigDescriptor::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    if (NULL != _afp->_filePtr)
+    {
+        PVA_FF_AtomUtils::seekFromStart(_afp, iCurrFilePos);
+        PVA_FF_AtomUtils::render24(_afp, _bufferSizeDB);
+    }
+}
+
diff --git a/fileformats/mp4/composer/src/decoderspecificinfo.cpp b/fileformats/mp4/composer/src/decoderspecificinfo.cpp
index 914d211..3c71131 100644
--- a/fileformats/mp4/composer/src/decoderspecificinfo.cpp
+++ b/fileformats/mp4/composer/src/decoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/src/editatom.cpp b/fileformats/mp4/composer/src/editatom.cpp
index c468b7e..503a090 100644
--- a/fileformats/mp4/composer/src/editatom.cpp
+++ b/fileformats/mp4/composer/src/editatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/editlistatom.cpp b/fileformats/mp4/composer/src/editlistatom.cpp
index d970da0..51036f6 100644
--- a/fileformats/mp4/composer/src/editlistatom.cpp
+++ b/fileformats/mp4/composer/src/editlistatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,29 +33,6 @@
     _entryCount = 0;
 
     _size = getDefaultSize();
-
-    /* This fp ony for player
-    uint32 entry_Count;
-    int i, reserverd;
-
-    PVA_FF_AtomUtils::read32(fp, &entry_Count);
-    for ( i = 0; i<entry_Count; i++)
-    {
-    	if ( version == 1)
-    	{
-    		PVA_FF_AtomUtils::read64(fp, &_psegmentDurations);
-    		PVA_FF_AtomUtils::read64(fp, &_pmediaTimes);
-    	}else
-    	{
-    		PVA_FF_AtomUtils::read32(fp, &_psegmentDurations);
-    		PVA_FF_AtomUtils::read32(fp, &_pmediaTimes);
-    	}
-
-    	PVA_FF_AtomUtils::read16(fp, &_pmediaRates);
-    	PVA_FF_AtomUtils::read16(fp, &reserverd);
-    }
-    */
-
     PV_MP4_FF_NEW(fp->auditCB, uint32VecType, (), _psegmentDurations);
     PV_MP4_FF_NEW(fp->auditCB, int32VecType, (), _pmediaTimes);
     PV_MP4_FF_NEW(fp->auditCB, uint16VecType, (), _pmediaRates);
diff --git a/fileformats/mp4/composer/src/es_id_inc.cpp b/fileformats/mp4/composer/src/es_id_inc.cpp
index 67e10e2..6359be3 100644
--- a/fileformats/mp4/composer/src/es_id_inc.cpp
+++ b/fileformats/mp4/composer/src/es_id_inc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This ESID_Inc Class contains information on the Elementary Stream that will
 	be replaced when streaming to a client.  The file format replaces the actual
@@ -28,6 +27,7 @@
 #include "atomutils.h"
 #include "a_atomdefs.h"
 
+
 // Alternate constructor
 PVA_FF_ES_ID_Inc::PVA_FF_ES_ID_Inc(uint32 trackid)
         : PVA_FF_BaseDescriptor(ES_ID_INC_DESCR_TAG),
diff --git a/fileformats/mp4/composer/src/es_id_ref.cpp b/fileformats/mp4/composer/src/es_id_ref.cpp
index 073293c..473c279 100644
--- a/fileformats/mp4/composer/src/es_id_ref.cpp
+++ b/fileformats/mp4/composer/src/es_id_ref.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This ESID_Ref Class contains information on the Elementary Stream that will
 	be replaced when streaming to a client.  The file format replaces the actual
@@ -49,8 +48,6 @@
 {
     _sizeOfClass = 2;
     _sizeOfSizeField = 1;
-    // | (8) | (8)  |    (16)    |
-    // | tag | size | trackindex |
 }
 
 // Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
diff --git a/fileformats/mp4/composer/src/esdatom.cpp b/fileformats/mp4/composer/src/esdatom.cpp
index cca9929..111fbc9 100644
--- a/fileformats/mp4/composer/src/esdatom.cpp
+++ b/fileformats/mp4/composer/src/esdatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ESDAtom Class provides the offset between decoding
     time and composition time.
@@ -28,8 +27,6 @@
 #include "a_atomdefs.h"
 #include "atomutils.h"
 
-//extern pvostream& operator<<(pvostream& fp, const PVA_FF_ESDescriptor &a);
-
 // Constructor
 PVA_FF_ESDAtom::PVA_FF_ESDAtom(int32 streamType, int32 codecType)
         : PVA_FF_FullAtom(ESD_ATOM, (uint8)0, (uint32)0)
diff --git a/fileformats/mp4/composer/src/esdescriptor.cpp b/fileformats/mp4/composer/src/esdescriptor.cpp
index 493013e..71c9e9c 100644
--- a/fileformats/mp4/composer/src/esdescriptor.cpp
+++ b/fileformats/mp4/composer/src/esdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ESDescriptor Class contains information on the Elementary Stream
 */
@@ -60,7 +59,6 @@
     _streamPriority = 0;
     _dependsOnESID = 0;
     _urlLength = 0;
-    //_urlString = "";
 }
 
 void
diff --git a/fileformats/mp4/composer/src/expandablebaseclass.cpp b/fileformats/mp4/composer/src/expandablebaseclass.cpp
index 7f94745..9bad973 100644
--- a/fileformats/mp4/composer/src/expandablebaseclass.cpp
+++ b/fileformats/mp4/composer/src/expandablebaseclass.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_ExpandableBaseClass Class fp the base class for all Descriptors that
     allows the encoding the size of the class in bytes with a VARIABLE NUMBER OF BITS
diff --git a/fileformats/mp4/composer/src/filetypeatom.cpp b/fileformats/mp4/composer/src/filetypeatom.cpp
index a9c1f7c..d91d19b 100644
--- a/fileformats/mp4/composer/src/filetypeatom.cpp
+++ b/fileformats/mp4/composer/src/filetypeatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MovieAtom Class is the main atom class in the MPEG-4 File that stores
     all the meta data about the MPEG-4 presentation.
diff --git a/fileformats/mp4/composer/src/fontrecord.cpp b/fileformats/mp4/composer/src/fontrecord.cpp
index 6ae9f8c..a8e3841 100644
--- a/fileformats/mp4/composer/src/fontrecord.cpp
+++ b/fileformats/mp4/composer/src/fontrecord.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/fonttableatom.cpp b/fileformats/mp4/composer/src/fonttableatom.cpp
index c83e64d..d580872 100644
--- a/fileformats/mp4/composer/src/fonttableatom.cpp
+++ b/fileformats/mp4/composer/src/fonttableatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,6 @@
 
 }
 
-//PVA_FF_FontRecord* PVA_FF_FontTableAtom::setFontRecord(uint16 FontListID,uint16 FontId,int8 FontLength,uint8* FontName)
 void PVA_FF_FontTableAtom::setFontRecord(uint16 FontListID, uint16 FontId, int8 FontLength, uint8* FontName)
 {
 
diff --git a/fileformats/mp4/composer/src/fullatom.cpp b/fileformats/mp4/composer/src/fullatom.cpp
index 9f753ef..e3a0c6d 100644
--- a/fileformats/mp4/composer/src/fullatom.cpp
+++ b/fileformats/mp4/composer/src/fullatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_FullAtom Class fp the base class for some Atoms in the MPEG-4 File
     Format.
diff --git a/fileformats/mp4/composer/src/h263decoderspecificinfo.cpp b/fileformats/mp4/composer/src/h263decoderspecificinfo.cpp
index 5f47ef8..f571c54 100644
--- a/fileformats/mp4/composer/src/h263decoderspecificinfo.cpp
+++ b/fileformats/mp4/composer/src/h263decoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/src/h263decoderspecificinfo3gpp.cpp b/fileformats/mp4/composer/src/h263decoderspecificinfo3gpp.cpp
index 507c42b..02c0409 100644
--- a/fileformats/mp4/composer/src/h263decoderspecificinfo3gpp.cpp
+++ b/fileformats/mp4/composer/src/h263decoderspecificinfo3gpp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_DecoderSpecificInfo Class that holds the Mpeg4 VOL header for the
 	video stream
diff --git a/fileformats/mp4/composer/src/h263sampleentry.cpp b/fileformats/mp4/composer/src/h263sampleentry.cpp
index 724d0b5..477ea0f 100644
--- a/fileformats/mp4/composer/src/h263sampleentry.cpp
+++ b/fileformats/mp4/composer/src/h263sampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_VisualSampleEntry Class is used for visual streams.
 */
diff --git a/fileformats/mp4/composer/src/handleratom.cpp b/fileformats/mp4/composer/src/handleratom.cpp
index c65d189..477f8c4 100644
--- a/fileformats/mp4/composer/src/handleratom.cpp
+++ b/fileformats/mp4/composer/src/handleratom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_HandlerAtom Class declares the nature of the media in the stream.
 */
@@ -57,34 +56,6 @@
             _handlerType = MEDIA_TYPE_VISUAL;
             _name = "VideoHandler";
             break;
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-            _handlerType = MEDIA_TYPE_OBJECT_DESCRIPTOR;
-            _name = "ODHandler";
-            break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-            _handlerType = MEDIA_TYPE_CLOCK_REFERENCE;
-            _name = "ClockRefHandler";
-            break;
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-            _handlerType = MEDIA_TYPE_SCENE_DESCRIPTION;
-            _name = "SceneDescHandler";
-            break;
-        case MEDIA_TYPE_MPEG7:
-            _handlerType = MEDIA_TYPE_MPEG7;
-            _name = "Mpeg7Handler";
-            break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-            _handlerType = MEDIA_TYPE_OBJECT_CONTENT_INFO;
-            _name = "ObjContentHandler";
-            break;
-        case MEDIA_TYPE_IPMP:
-            _handlerType = MEDIA_TYPE_IPMP;
-            _name = "IPHandler";
-            break;
-        case MEDIA_TYPE_MPEG_J:
-            _handlerType = MEDIA_TYPE_MPEG_J;
-            _name = "Mpeg-JHandler";
-            break;
         default:
             _handlerType = UNKNOWN_HANDLER; // Error condition!
             _name = "UNKNOWNHandler";
diff --git a/fileformats/mp4/composer/src/hintmediaheaderatom.cpp b/fileformats/mp4/composer/src/hintmediaheaderatom.cpp
index 67ecd16..fc79264 100644
--- a/fileformats/mp4/composer/src/hintmediaheaderatom.cpp
+++ b/fileformats/mp4/composer/src/hintmediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_HintMediaHeaderAtom Class contains general presentation information,
     independent of coding, about the audio media within the stream.
diff --git a/fileformats/mp4/composer/src/impeg4file.cpp b/fileformats/mp4/composer/src/impeg4file.cpp
index 561edd8..b5a93c5 100644
--- a/fileformats/mp4/composer/src/impeg4file.cpp
+++ b/fileformats/mp4/composer/src/impeg4file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     The PVA_FF_IMpeg4File Class is INTERFACE that exsposes only those necessary
     methods of the underlying PVA_FF_Mpeg4File class.
@@ -27,7 +26,6 @@
 #include "oscl_base.h"
 #include "a_impeg4file.h"
 #include "mpeg4file.h"
-//#include "pviostream.h"
 #include "atomutils.h"
 #ifndef OSCL_DLL_H_INCLUDED
 #include "oscl_dll.h"
@@ -36,7 +34,6 @@
 // Define entry point for this DLL
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
-//extern pvostream& operator<<(pvostream& os, PVA_FF_Mpeg4File &mp4);
 OSCL_EXPORT_REF
 // Static method to create the MP4 file and return the PVA_FF_IMpeg4File interface
 PVA_FF_IMpeg4File*
diff --git a/fileformats/mp4/composer/src/initialobjectdescriptor.cpp b/fileformats/mp4/composer/src/initialobjectdescriptor.cpp
deleted file mode 100644
index 7de8835..0000000
--- a/fileformats/mp4/composer/src/initialobjectdescriptor.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_InitialObjectDescriptor Class
-*/
-
-
-#define IMPLEMENT_InitialObjectDescriptor
-
-#include "initialobjectdescriptor.h"
-#include "atomutils.h"
-#include "a_atomdefs.h"
-
-typedef Oscl_Vector<PVA_FF_ES_ID_Inc*, OsclMemAllocator> PVA_FF_ES_ID_IncVecType;
-// Constructor
-PVA_FF_InitialObjectDescriptor::PVA_FF_InitialObjectDescriptor()
-        : PVA_FF_ObjectDescriptor(1, MP4_IOD_TAG)
-{
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ES_ID_IncVecType, (), _pES_ID_Inc_Vec);
-    init();
-    recomputeSize();
-}
-
-// Initializations
-void
-PVA_FF_InitialObjectDescriptor::init()
-{
-    _urlLength = 0;
-    _urlFlag = false;
-    _reserved = 0x0f; // Now only (4)
-    _includeInlineProfilesFlag = false;
-
-    setODProfileLevelIndication(0xFE);
-    setSceneProfileLevelIndication(0xFE);
-    setAudioProfileLevelIndication(0xFE);
-    setVisualProfileLevelIndication(0xFE);
-    setGraphicsProfileLevelIndication(0xFE);
-
-}
-
-// Destructor
-PVA_FF_InitialObjectDescriptor::~PVA_FF_InitialObjectDescriptor()
-{
-    if (_pES_ID_Inc_Vec != NULL)
-    {
-        for (uint32 i = 0; i < _pES_ID_Inc_Vec->size(); i++)
-        {
-            PV_MP4_FF_DELETE(NULL, PVA_FF_ES_ID_Inc, (*_pES_ID_Inc_Vec)[i]);
-        }
-        PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_ES_ID_IncVecType, Oscl_Vector, _pES_ID_Inc_Vec);
-    }
-
-    return;
-
-}
-
-
-void
-PVA_FF_InitialObjectDescriptor::addESIDInclude(PVA_FF_ES_ID_Inc *inc)
-{
-    _pES_ID_Inc_Vec->push_back(inc);
-    recomputeSize();
-}
-
-PVA_FF_ES_ID_Inc*
-PVA_FF_InitialObjectDescriptor::getESIDIncludeAt(int32 index)
-{
-    if (_pES_ID_Inc_Vec != NULL)
-    {
-        if (index < (int32)_pES_ID_Inc_Vec->size())
-        {
-            return (*_pES_ID_Inc_Vec)[index];
-        }
-        else
-        {
-            return NULL;
-        }
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-
-void
-PVA_FF_InitialObjectDescriptor::recomputeSize()
-{
-    int32 contents = 2; // (2 bytes = 16 bits) Packed ODID, URLFlag, InlineProfFlag, and Reserved
-
-    if (_urlFlag)
-    {
-        contents += 1; // 1 byte for URL Length variable
-        contents += _urlLength; // length of URL string
-    }
-    else
-    {
-        contents += 5;  // ODProfileLevelIndication
-        // sceneProfileLevelIndication
-        // audioProfileLevelIndication
-        // visualProfileLevelIndication
-        // graphicsProfileLevelIndication
-
-        // IOD renders ONLy the ESIDs (referencing the tracks) and not the actual ESDescr
-        if (_pES_ID_Inc_Vec != NULL)
-        {
-            // Renders the ESID instead of the actual PVA_FF_ESDescriptor
-            int32 SIZE_OF_ES_ID_INC_OBJECT = 6;
-            contents += _pES_ID_Inc_Vec->size() * SIZE_OF_ES_ID_INC_OBJECT;
-        }
-    }
-
-    _sizeOfClass = contents;
-    _sizeOfSizeField = PVA_FF_AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(contents);
-
-    // Have the parent descriptor recompute its size based on this update
-    if (_pparent != NULL)
-    {
-        _pparent->recomputeSize();
-    }
-}
-
-// Rendering the Descriptor in proper format (bitlengths, etc.) to an ostream
-bool
-PVA_FF_InitialObjectDescriptor::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
-{
-    int32 rendered = 0; // Keep track of number of bytes rendered
-
-    // Render the base class members
-    int32 numBytes = renderBaseDescriptorMembers(fp);
-
-    if (numBytes == 0)
-    {
-        return false;
-    }
-    rendered += numBytes;
-
-    // Pack and render ODID, urlFlag, and
-    uint16 data = (uint16)((_objectDescriptorID && 0x03ff) << 6); // (10 bits)
-
-    if (getUrlFlag())
-    {
-        data |= 0x20; // Set urlFlag bit
-    }
-    if (getIncludeInlineProfilesFlag())
-    {
-        data |= 0x10; // Set includeInlineProfilesFlag bit
-    }
-    data |= (_reserved & 0x000f); // (4 bits)
-
-    if (!PVA_FF_AtomUtils::render16(fp, data))
-    {
-        return false;
-    }
-    rendered += 2;
-
-    if (getUrlFlag())
-    {
-        // Render _urlLength
-        if (!PVA_FF_AtomUtils::render8(fp, _urlLength))
-        {
-            return false;
-        }
-        rendered += 1;
-
-        // Render url string
-        if (_urlLength > 0)
-        {
-            if (!PVA_FF_AtomUtils::renderString(fp, _urlString))
-            {
-                return false;
-            }
-        }
-        rendered += _urlLength;
-    }
-    else
-    {
-        if (!PVA_FF_AtomUtils::render8(fp, _ODProfileLevelIndication))
-        {
-            return false;
-        }
-        if (!PVA_FF_AtomUtils::render8(fp, _sceneProfileLevelIndication))
-        {
-            return false;
-        }
-        if (!PVA_FF_AtomUtils::render8(fp, _audioProfileLevelIndication))
-        {
-            return false;
-        }
-        if (!PVA_FF_AtomUtils::render8(fp, _visualProfileLevelIndication))
-        {
-            return false;
-        }
-        if (!PVA_FF_AtomUtils::render8(fp, _graphicsProfileLevelIndication))
-        {
-            return false;
-        }
-        rendered += 5;
-
-        // Render the vector of ESDescriptors (ES_ID_Incs)
-        if (_pES_ID_Inc_Vec != NULL)
-        {
-            for (uint32 i = 0; i < _pES_ID_Inc_Vec->size(); i++)
-            {
-                PVA_FF_ES_ID_Inc *inc = (*_pES_ID_Inc_Vec)[i];
-                if (!inc->renderToFileStream(fp))
-                {
-                    return false;
-                }
-                rendered += inc->getSizeOfDescriptorObject();
-            }
-        }
-    }
-
-    return true;
-}
-
diff --git a/fileformats/mp4/composer/src/interleavebuffer.cpp b/fileformats/mp4/composer/src/interleavebuffer.cpp
index 6084309..4068b02 100644
--- a/fileformats/mp4/composer/src/interleavebuffer.cpp
+++ b/fileformats/mp4/composer/src/interleavebuffer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -259,8 +259,16 @@
 PVA_FF_InterLeaveBuffer::setLastChunkEndTime(uint32 time)
 {
     _lastChunkEndTime = time;
+    if (_pTimeStampVec->size() > 0)
+    {
+        _lastSampleTS  = _pTimeStampVec->back();
+    }
+    else
+    {
+        _lastSampleTS = 0;
+    }
 
-    _lastSampleTS	= _pTimeStampVec->back();
+
 }
 
 
diff --git a/fileformats/mp4/composer/src/makefile b/fileformats/mp4/composer/src/makefile
deleted file mode 100755
index e0caac1..0000000
--- a/fileformats/mp4/composer/src/makefile
+++ /dev/null
@@ -1,243 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = mpeg4filelib
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# we have the define by default
-XCXXFLAGS += -DUNICODE -D_UNICODE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS += -I../include -I$(OSCL_TOP)/installed_include -I../../../oscl/osclBase/src -I../../../oscl/osclIO/src -I../../../oscl/osclMemory/src -I../../../oscl/osclUtil/src
-XINCDIRS = -I../include \
--I $(VOB_BASE_DIR)/oscl/oscl/pvscheduler/base/inc \
--I $(VOB_BASE_DIR)/oscl/oscl/osclmemory/src \
--I $(VOB_BASE_DIR)/oscl/oscl/osclbase/src \
--I $(VOB_BASE_DIR)/oscl/oscl/osclutil/src \
--I $(VOB_BASE_DIR)/oscl/oscl/osclio/src \
--I $(VOB_BASE_DIR)/baselibs/media_data_structures/src \
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-
-SRCS = amrdecoderspecificinfo.cpp \
-amrdecoderspecificinfo3gpp.cpp \
-amrsampleentry.cpp \
-atom.cpp \
-atomutils.cpp \
-audiohintsample.cpp \
-audiosampleentry.cpp \
-audiotrackinfo.cpp \
-basecommand.cpp \
-basedescriptor.cpp \
-chunkoffsetatom.cpp \
-contentversionatom.cpp \
-dataentryatom.cpp \
-dataentryurlatom.cpp \
-datainformationatom.cpp \
-datareferenceatom.cpp \
-decoderconfigdescriptor.cpp \
-decoderspecificinfo.cpp \
-downloadatom.cpp \
-editatom.cpp \
-editlistatom.cpp \
-esdatom.cpp \
-esdescriptor.cpp \
-es_id_inc.cpp \
-es_id_ref.cpp \
-evrcdecoderspecificinfo.cpp \
-expandablebaseclass.cpp \
-filetypeatom.cpp \
-fullatom.cpp \
-h263sampleentry.cpp \
-h263decoderspecificinfo.cpp \
-h263decoderspecificinfo3gpp.cpp \
-handleratom.cpp \
-hintmediaheaderatom.cpp \
-hintsample.cpp \
-hintsampleentry.cpp \
-impeg4file.cpp \
-initialobjectdescriptor.cpp \
-mediaatom.cpp \
-mediabuffer.cpp \
-mediabuffermanager.cpp \
-mediadataatom.cpp \
-mediaheaderatom.cpp \
-mediainformationatom.cpp \
-mediainformationheaderatom.cpp \
-movieatom.cpp \
-movieheaderatom.cpp \
-mpeg4file.cpp \
-mpeg4mediaheaderatom.cpp \
-mpegsampleentry.cpp \
-objectdescriptoratom.cpp \
-objectdescriptor.cpp \
-objectdescriptorupdate.cpp \
-pvuserdataatom.cpp \
-randomaccessatom.cpp \
-requirementsatom.cpp \
-sampledescriptionatom.cpp \
-sampleentry.cpp \
-samplesizeatom.cpp \
-sampletableatom.cpp \
-sampletochunkatom.cpp \
-slconfigdescriptor.cpp \
-soundmediaheaderatom.cpp \
-stillimagehintsample.cpp \
-syncsampleatom.cpp \
-timetosampleatom.cpp \
-trackatom.cpp \
-trackreferencetypeatom.cpp \
-trackheaderatom.cpp \
-trackreferenceatom.cpp \
-trackinfo.cpp \
-trackinfoatom.cpp \
-userdataatom.cpp \
-videohintsample.cpp \
-videoinfoatom.cpp \
-videomediaheaderatom.cpp \
-videoutils.cpp \
-visualsampleentry.cpp \
-videotrackinfo.cpp \
-wmfsetmediaatom.cpp \
-wmfsetsessionatom.cpp \
-ztl.cpp
-
-INCSRCDIR = ../include
-
-HDRS = a_impeg4file.h \
-amrdecoderspecificinfo.h  \
-amrdecoderspecificinfo3gpp.h  \
-amrsampleentry.h \
-atomdefs.h \
-atom.h \
-atomutils.h \
-audiohintsample.h \
-audiosampleentry.h \
-audiotrackinfo.h \
-basecommand.h \
-bifs.h \
-basedescriptor.h \
-chunklargeoffsetatom.h \
-chunkoffsetatom.h \
-compositionoffsetatom.h \
-contentversionatom.h \
-copyrightatom.h \
-dataentryatom.h \
-dataentryurlatom.h \
-dataentryurnatom.h \
-datainformationatom.h \
-datareferenceatom.h \
-decoderconfigdescriptor.h \
-decoderspecificinfo.h \
-degradationpriorityatom.h \
-downloadatom.h \
-editatom.h \
-editlistatom.h \
-esdatom.h \
-esdescriptor.h \
-es_id_inc.h \
-es_id_ref.h \
-evrcdecoderspecificinfo.h \
-expandablebaseclass.h \
-filetypeatom.h \
-freespaceatom.h \
-fullatom.h \
-h263sampleentry.h \
-h263decoderspecificinfo.h \
-h263decoderspecificinfo3gpp.h \
-handleratom.h \
-hintmediaheaderatom.h \
-hintsampleentry.h \
-hintsample.h \
-imediabuffer.h \
-initialobjectdescriptor.h \
-isucceedfail.h \
-mediaatom.h \
-mediabuffer.h \
-mediabuffermanager.h \
-mediadataatom.h \
-mediaheaderatom.h \
-mediainformationatom.h \
-mediainformationheaderatom.h \
-movieatom.h \
-movieheaderatom.h \
-mpeg4file.h \
-mpeg4mediaheaderatom.h \
-mpegsampleentry.h \
-objectdescriptoratom.h \
-objectdescriptor.h \
-objectdescriptorupdate.h \
-parentable.h \
-pvuserdataatom.h \
-pvstring.h \
-randomaccessatom.h \
-renderable.h \
-requirementsatom.h \
-sampledescriptionatom.h \
-sampleentry.h \
-samplesizeatom.h \
-sampletableatom.h \
-sampletochunkatom.h \
-scalabilityhintsample.h \
-shadowsyncsampleatom.h \
-slconfigdescriptor.h \
-soundmediaheaderatom.h \
-stillimagehintsample.h \
-syncsampleatom.h \
-timetosampleatom.h \
-trackatom.h \
-trackheaderatom.h \
-trackinfo.h \
-trackinfoatom.h \
-trackreferenceatom.h \
-trackreferencetypeatom.h \
-userdataatom.h \
-videohintsample.h \
-videoinfoatom.h \
-videotrackinfo.h \
-videomediaheaderatom.h \
-videoutils.h \
-visualsampleentry.h \
-wmfsetmediaatom.h \
-wmfsetsessionatom.h \
-ztl.h
- 
-  
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-                      
-include $(MK)/gnumake.template
diff --git a/fileformats/mp4/composer/src/mediaatom.cpp b/fileformats/mp4/composer/src/mediaatom.cpp
index b7e24b4..3e5ee81 100644
--- a/fileformats/mp4/composer/src/mediaatom.cpp
+++ b/fileformats/mp4/composer/src/mediaatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaAtom Class contains all the objects that declare information
     about the media data within the stream.
@@ -199,3 +198,14 @@
     return true;
 }
 
+void
+PVA_FF_MediaAtom::SetMaxSampleSize(uint32 aSize)
+{
+    _pmediaInformation->SetMaxSampleSize(aSize);
+}
+
+void
+PVA_FF_MediaAtom::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    _pmediaInformation->writeMaxSampleSize(_afp);
+}
diff --git a/fileformats/mp4/composer/src/mediadataatom.cpp b/fileformats/mp4/composer/src/mediadataatom.cpp
index 273b822..310867f 100644
--- a/fileformats/mp4/composer/src/mediadataatom.cpp
+++ b/fileformats/mp4/composer/src/mediadataatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaDataAtom Class contains the media data.  This class can operate in
     either one of two ways - 1. it can store all it's data in memory (such as
@@ -61,6 +60,7 @@
     _fileWriteError = false;
     _targetFileWriteError = false;
     _directRender = false;
+    _oIsFileOpen = false;
 
     _fileSize = 0;
     _fileOffsetForChunkStart = 0;
@@ -98,9 +98,6 @@
     _totalDataRenderedToTargetFile = 0;
     _prenderables = NULL;
     _success = true;
-    //_ptrackReferencePtrVec = new Oscl_Vector<PVA_FF_TrackAtom*,OsclMemAllocator>();
-    //_prenderables = new Oscl_Vector<PVA_FF_Renderable*,OsclMemAllocator>();
-
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_RenderableVecType, (), _prenderables);
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TrackAtomVecType, (), _ptrackReferencePtrVec);
 
@@ -108,7 +105,6 @@
     // ADDED TO CHECK FOR ANY FILE WRITE FAILURES
     _fileWriteError = false;
     _targetFileWriteError = false;
-
     _fileSize = 0;
     _fileOffsetForChunkStart = 0;
     _fileOffsetForAtomStart = 0;
@@ -124,6 +120,7 @@
 
 
     int retVal = PVA_FF_AtomUtils::openFile(&_pofstream, targetFileName, Oscl_File::MODE_READWRITE | Oscl_File::MODE_BINARY, aCacheSize);
+    _oIsFileOpen = true;
 
     if (_pofstream._filePtr == NULL)
     {
@@ -168,7 +165,7 @@
     _fileSize = 0;
     _fileOffsetForChunkStart = 0;
     _fileOffsetForAtomStart = 0;
-
+    _oIsFileOpen = false;
     _directRender = true;
 
     _ptrackReferencePtr = NULL;
@@ -186,13 +183,10 @@
 // Destructor
 PVA_FF_MediaDataAtom::~PVA_FF_MediaDataAtom()
 {
-    if (!_directRender)
+    if (_pofstream._filePtr != NULL && true == _oIsFileOpen)
     {
-        if (_pofstream._filePtr != NULL)
-        {
-            PVA_FF_AtomUtils::closeFile(&_pofstream);
-            _pofstream._filePtr = NULL;
-        }
+        PVA_FF_AtomUtils::closeFile(&_pofstream);
+        _pofstream._filePtr = NULL;
     }
 
     // PVA_FF_TrackAtom *_ptrackReferencePtr - is taken care of by the movie atom
@@ -229,10 +223,17 @@
 {
     if (_pofstream._filePtr == NULL && !_fileWriteError)
     {
+        // 05/31/01 Generate temporary files into output path (the actual mp4 location)
+        // _tempFilename already contains the output path ("drive:\\...\\...\\")
+        //
         _tempFilename += _STRLIT("temp");
+        // Assign the rest of the temp filename - index plus suffix
         _tempFilename += (uint16)(_tempFileIndex++);
+
+        // 03/21/01 Multiple instances support
         _tempFilename += _STRLIT("_");
         _tempFilename += _tempFilePostfix;
+        //
 
         _tempFilename += _STRLIT(".mdat");
 
@@ -244,6 +245,10 @@
         {
             _fileWriteError = true;
         }
+        else
+        {
+            _oIsFileOpen = true;
+        }
 
         // Render the atoms base members to the media data atom file
         renderAtomBaseMembers(&_pofstream);
@@ -514,7 +519,6 @@
 PVA_FF_MediaDataAtom::reserveBuffer(int32 size)
 {
     OSCL_UNUSED_ARG(size);
-    //_data = malloc // Reserve space for
 }
 
 void
@@ -588,7 +592,6 @@
         // and NOT just offsets from the first chunk (i.e. zero) and we don't really
         // know this offset until now.
         PVA_FF_MediaDataAtom *This = const_cast<PVA_FF_MediaDataAtom*>(this);
-        //This->setFileOffsetForChunkStart(fp.tellp());
         This->setFileOffsetForChunkStart(PVA_FF_AtomUtils::getCurrentFilePosition(fp));
 
         for (uint32 i = 0; i < _prenderables->size(); i++)
@@ -602,6 +605,9 @@
     }
     else
     {
+        // MEDIA_DATA_ON_DISK
+        // 05/30/01 CPU problem when the file fp big.
+        // We update the size at the end not for every sample.
         // Need to update the atoms size field on disk
         int32 currentPos = PVA_FF_AtomUtils::getCurrentFilePosition(&_pofstream);    // Get current position of put pointer
         PVA_FF_AtomUtils::seekFromStart(&_pofstream, 0);          // Go to the beginning of the file
@@ -646,7 +652,6 @@
 
         // Read in atom from separate file and copy byte-by-byte to new ofstream
         // (including the mediaDataAtom header - 4 byte size ad 4 byte type)
-        // uint32 count = 0;
 
         uint32 readBlockSize = 0;
         uint32 tempFileSize  = getSize();
@@ -691,5 +696,3 @@
     return true;
 }
 
-
-
diff --git a/fileformats/mp4/composer/src/mediaheaderatom.cpp b/fileformats/mp4/composer/src/mediaheaderatom.cpp
index 6822069..27be016 100644
--- a/fileformats/mp4/composer/src/mediaheaderatom.cpp
+++ b/fileformats/mp4/composer/src/mediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaHeaderAtom Class contains all the objects that declare information
     about the media data within the stream.
@@ -67,8 +66,6 @@
 void
 PVA_FF_MediaHeaderAtom::addSample(uint32 ts)
 {
-    //uint32 d = getDuration();
-    //d+=1; // duration in terms of the media timescale just maintains a sample count
     _deltaTS = ts - _prevTS;
 
     setDuration(ts);
diff --git a/fileformats/mp4/composer/src/mediainformationatom.cpp b/fileformats/mp4/composer/src/mediainformationatom.cpp
index bd47da5..5e85bb2 100644
--- a/fileformats/mp4/composer/src/mediainformationatom.cpp
+++ b/fileformats/mp4/composer/src/mediainformationatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaInformationHeaderAtom Class fp the base class of the other
     MediaInformationHeaderAtoms, PVA_FF_VideoMediaHeaderAtom VIDEO_MEDIA_HEADER_ATOM, PVA_FF_SoundMediaHeaderAtom
@@ -246,6 +245,16 @@
 
     return true;
 }
+void
+PVA_FF_MediaInformationAtom::SetMaxSampleSize(uint32 aSize)
+{
+    _psampleTableAtom->SetMaxSampleSize(aSize);
+}
 
+void
+PVA_FF_MediaInformationAtom::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    _psampleTableAtom->writeMaxSampleSize(_afp);
+}
 
 
diff --git a/fileformats/mp4/composer/src/mediainformationheaderatom.cpp b/fileformats/mp4/composer/src/mediainformationheaderatom.cpp
index ab7d536..bdf8bb9 100644
--- a/fileformats/mp4/composer/src/mediainformationheaderatom.cpp
+++ b/fileformats/mp4/composer/src/mediainformationheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MediaInformationHeaderAtom Class is an abstract base class for the
     atoms VideoMediaHeaderAton, AudioMediaHeaderAtom, PVA_FF_HintMediaHeaderAtom,
diff --git a/fileformats/mp4/composer/src/movieatom.cpp b/fileformats/mp4/composer/src/movieatom.cpp
index 1a2e758..f954789 100644
--- a/fileformats/mp4/composer/src/movieatom.cpp
+++ b/fileformats/mp4/composer/src/movieatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MovieAtom Class fp the main atom class in the MPEG-4 File that stores
     all the meta data about the MPEG-4 presentation.
@@ -42,8 +41,6 @@
     _fileType = 0;
 
     // Initializations
-    _pBIFSTrack = NULL;
-    _pODTrack = NULL;
 
     _pAssetInfoCopyRightAtom		= NULL;
     _pAssetInfoAuthorAtom			= NULL;
@@ -55,6 +52,8 @@
     _pAssetInfoClassificationAtom	= NULL;
     _pAssetInfoKeyWordsAtom			= NULL;
     _pAssetInfoLocationInfoAtom		= NULL;
+    _pAssetInfoKeyAlbumAtom			= NULL;
+    _pAssetInfoKeyRecordingYearAtom = NULL;
 
     _oMovieFragmentEnabled = false;
     //Movie Fragment : Enable movie fragment mode and create movie extends atom
@@ -67,8 +66,6 @@
 
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MovieHeaderAtom, ((uint8)0, (uint32)0, fileAuthoringFlags), _pmovieHeaderAtom);
 
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ObjectDescriptorAtom, ((uint8)0, (uint32)0), _pobjectDescriptorAtom);
-
 
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TrackAtomVecType, (), _pMediaTrackVec);
     PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TrackAtomVecType, (), _pmpeg4TrackVec);
@@ -82,7 +79,6 @@
     recomputeSize();
 
     _pmovieHeaderAtom->setParent(this);
-    _pobjectDescriptorAtom->setParent(this);
 }
 
 // Destructor - delete the vector(s) of TrackAtoms from the heap
@@ -92,8 +88,6 @@
 
     PV_MP4_FF_DELETE(NULL, PVA_FF_MovieHeaderAtom, _pmovieHeaderAtom);
 
-    PV_MP4_FF_DELETE(NULL, PVA_FF_ObjectDescriptorAtom, _pobjectDescriptorAtom);
-
     // Delete mpeg4 general tracks
     for (i = 0; i < _pmpeg4TrackVec->size(); i++)
     {
@@ -101,12 +95,6 @@
     }
     PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_TrackAtomVecType, Oscl_Vector, _pmpeg4TrackVec);
 
-    if (_pBIFSTrack != NULL)
-        PV_MP4_FF_DELETE(NULL, PVA_FF_TrackAtom, _pBIFSTrack);
-
-    if (_pODTrack != NULL)
-        PV_MP4_FF_DELETE(NULL, PVA_FF_TrackAtom, _pODTrack);
-
     // Delete media tracks
     for (i = 0; i < _pMediaTrackVec->size(); i++)
     {
@@ -173,18 +161,6 @@
             }
         }
         break;
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        {
-            _pBIFSTrack = a;
-            a->setParent(this);
-            break;
-        }
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        {
-            _pODTrack = a;
-            a->setParent(this);
-            break;
-        }
         default:
             PV_MP4_FF_DELETE(NULL, PVA_FF_TrackAtom, a);
             break;
@@ -238,14 +214,6 @@
     // Set timescale in movieheader atom
     _pmovieHeaderAtom->setTimeScale(ts);
 
-    if (_pBIFSTrack != NULL)
-    {
-        _pBIFSTrack->setTimeScale(ts);
-    }
-    if (_pODTrack != NULL)
-    {
-        _pODTrack->setTimeScale(ts);
-    }
 }
 
 
@@ -264,8 +232,6 @@
 
     size += _pmovieHeaderAtom->getSize();
 
-    size += _pobjectDescriptorAtom->getSize();
-
     if (_puserDataAtom != NULL)
     {
         if (_puserDataAtom->getUserDataAtomVecSize() > 0)
@@ -278,15 +244,13 @@
     {
         for (uint32 i = 0; i < _pMediaTrackVec->size(); i++)
         {
-            size += (*_pMediaTrackVec)[i]->getSize();
+            if ((*_pMediaTrackVec)[i]->getSampleCount() > 0)
+            {
+                size += (*_pMediaTrackVec)[i]->getSize();
+            }
         }
     }
-    {
-        if (_pBIFSTrack != NULL)
-            size += _pBIFSTrack->getSize();
-        if (_pODTrack != NULL)
-            size += _pODTrack->getSize();
-    }
+
     // in movie fragment mode add size of mvex
     if (_oMovieFragmentEnabled == true)
     {
@@ -341,36 +305,6 @@
         }
     }
 
-    if (_pBIFSTrack != NULL)
-    {
-        /* Set the duration of the BIFS/OD sample to that of the clip duration */
-        _pBIFSTrack->setBIFSODSampleDuration(maxTrackDuration);
-        _pBIFSTrack->setDuration(maxTrackDuration);
-
-        PVA_FF_TrackHeaderAtom *tkhdPtr = _pBIFSTrack->getTrackHeaderAtomPtr();
-
-        if (tkhdPtr != NULL)
-        {
-            tkhdPtr->setCreationTime(creationTime);
-            tkhdPtr->setModificationTime(modTime);
-        }
-    }
-
-    if (_pODTrack != NULL)
-    {
-        /* Set the duration of the BIFS/OD sample to that of the clip duration */
-        _pODTrack->setBIFSODSampleDuration(maxTrackDuration);
-        _pODTrack->setDuration(maxTrackDuration);
-
-        PVA_FF_TrackHeaderAtom *tkhdPtr = _pODTrack->getTrackHeaderAtomPtr();
-
-        if (tkhdPtr != NULL)
-        {
-            tkhdPtr->setCreationTime(creationTime);
-            tkhdPtr->setModificationTime(modTime);
-        }
-    }
-
     recomputeSize();
 
     return;
@@ -410,41 +344,18 @@
         }
     }
     // Render the object descriptor
-    {
-        if (!_pobjectDescriptorAtom->renderToFileStream(fp))
-        {
-            return false;
-        }
-        rendered += _pobjectDescriptorAtom->getSize();
-    }
     if (_pMediaTrackVec != NULL)
     {
         for (uint32 i = 0; i < _pMediaTrackVec->size(); i++)
         {
-            if (!((*_pMediaTrackVec)[i]->renderToFileStream(fp)))
+            if ((*_pMediaTrackVec)[i]->getSampleCount() > 0)
             {
-                return false;
+                if (!((*_pMediaTrackVec)[i]->renderToFileStream(fp)))
+                {
+                    return false;
+                }
+                rendered += (*_pMediaTrackVec)[i]->getSize();
             }
-            rendered += (*_pMediaTrackVec)[i]->getSize();
-        }
-    }
-    {
-        if (_pBIFSTrack != NULL)
-        {
-            if (!_pBIFSTrack->renderToFileStream(fp))
-            {
-                return false;
-            }
-            rendered += _pBIFSTrack->getSize();
-        }
-
-        if (_pODTrack != NULL)
-        {
-            if (!_pODTrack->renderToFileStream(fp))
-            {
-                return false;
-            }
-            rendered += _pODTrack->getSize();
         }
     }
     // render MVEX atom in movie fragment mode
@@ -569,10 +480,7 @@
             _pmovieHeaderAtom->addSample(ts_in_milliseconds);
         }
     }
-    else
-    {
-        //cerr << "ERROR: MediaTrack" << trackID << "not found" << endl;
-    }
+
 
     if (mediaType == MEDIA_TYPE_VISUAL)
     {
@@ -638,10 +546,7 @@
             _pmovieHeaderAtom->addSample(ts_in_milliseconds);
         }
     }
-    else
-    {
-        //cerr << "ERROR: MediaTrack" << trackID << "not found" << endl;
-    }
+
 
     if (mediaType == MEDIA_TYPE_TEXT)
     {
@@ -684,10 +589,6 @@
             _pmovieHeaderAtom->addSample(ts_in_milliseconds);
         }
     }
-    else
-    {
-        //cerr << "ERROR: MediaTrack" << trackID << "not found" << endl;
-    }
 
     if (mediaType == MEDIA_TYPE_VISUAL)
     {
@@ -755,10 +656,6 @@
             _pmovieHeaderAtom->addSample(ts_in_milliseconds);
         }
     }
-    else
-    {
-        //cerr << "ERROR: MediaTrack" << trackID << "not found" << endl;
-    }
 
     if (mediaType == MEDIA_TYPE_TEXT)//added for the support of timed text track
     {
@@ -890,6 +787,24 @@
         }
     }
 
+    if (_pAssetInfoKeyAlbumAtom == NULL)
+    {
+        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_AssetInfoAlbumAtom, (), _pAssetInfoKeyAlbumAtom);
+        if (_puserDataAtom != NULL)
+        {
+            _puserDataAtom->addAtom(_pAssetInfoKeyAlbumAtom);
+        }
+    }
+
+    if (_pAssetInfoKeyRecordingYearAtom == NULL)
+    {
+        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_AssetInfoRecordingYearAtom, (), _pAssetInfoKeyRecordingYearAtom);
+        if (_puserDataAtom != NULL)
+        {
+            _puserDataAtom->addAtom(_pAssetInfoKeyRecordingYearAtom);
+        }
+    }
+
 }
 
 // functions to set and update fragment duration in MVEX atom
@@ -921,3 +836,30 @@
 {
     _pMovieExtendsAtom->writeMovieFragmentDuration(fp);
 }
+
+void
+PVA_FF_MovieAtom::SetMaxSampleSize(uint32 aTrackID, uint32 aSize)
+{
+    PVA_FF_TrackAtom *mediaTrack = NULL;
+    mediaTrack = getMediaTrack(aTrackID);
+    if (NULL != mediaTrack)
+        mediaTrack->SetMaxSampleSize(aSize);
+}
+
+void
+PVA_FF_MovieAtom::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    for (uint32 i = 0; i < _pMediaTrackVec->size(); i++)
+    {
+        PVA_FF_TrackHeaderAtom *ptkhdr = NULL;
+        ptkhdr = (*_pMediaTrackVec)[i]->getTrackHeaderAtomPtr();
+        if (NULL != ptkhdr)
+        {
+            uint32 trackID = ptkhdr->getTrackID();
+            PVA_FF_TrackAtom *mediaTrack = NULL;
+            mediaTrack = getMediaTrack(trackID);
+            if (NULL != mediaTrack)
+                mediaTrack->writeMaxSampleSize(_afp);
+        }
+    }
+}
diff --git a/fileformats/mp4/composer/src/movieextendsatom.cpp b/fileformats/mp4/composer/src/movieextendsatom.cpp
index cb5e502..fd543cd 100644
--- a/fileformats/mp4/composer/src/movieextendsatom.cpp
+++ b/fileformats/mp4/composer/src/movieextendsatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/movieextendsheaderatom.cpp b/fileformats/mp4/composer/src/movieextendsheaderatom.cpp
index ac644c2..0031ae2 100644
--- a/fileformats/mp4/composer/src/movieextendsheaderatom.cpp
+++ b/fileformats/mp4/composer/src/movieextendsheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/moviefragmentatom.cpp b/fileformats/mp4/composer/src/moviefragmentatom.cpp
index ee0df59..4714852 100644
--- a/fileformats/mp4/composer/src/moviefragmentatom.cpp
+++ b/fileformats/mp4/composer/src/moviefragmentatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -210,7 +210,10 @@
     {
         for (uint32 ii = 0; ii < _pTrafList->size(); ii++)
         {
-            size += ((*_pTrafList)[ii])->getSize();
+            if (((*_pTrafList)[ii])->getSampleCount() > 0)
+            {
+                size += ((*_pTrafList)[ii])->getSize();
+            }
         }
     }
 
@@ -250,11 +253,14 @@
     {
         for (uint32 ii = 0; ii < _pTrafList->size(); ii++)
         {
-            if (!((*_pTrafList)[ii])->renderToFileStream(fp))
+            if (((*_pTrafList)[ii])->getSampleCount() > 0)
             {
-                return false;
+                if (!((*_pTrafList)[ii])->renderToFileStream(fp))
+                {
+                    return false;
+                }
+                rendered += ((*_pTrafList)[ii])->getSize();
             }
-            rendered += ((*_pTrafList)[ii])->getSize();
         }
     }
 
diff --git a/fileformats/mp4/composer/src/moviefragmentheaderatom.cpp b/fileformats/mp4/composer/src/moviefragmentheaderatom.cpp
index f2192aa..0646189 100644
--- a/fileformats/mp4/composer/src/moviefragmentheaderatom.cpp
+++ b/fileformats/mp4/composer/src/moviefragmentheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/moviefragmentrandomaccessatom.cpp b/fileformats/mp4/composer/src/moviefragmentrandomaccessatom.cpp
index f34bc4f..bed572e 100644
--- a/fileformats/mp4/composer/src/moviefragmentrandomaccessatom.cpp
+++ b/fileformats/mp4/composer/src/moviefragmentrandomaccessatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/moviefragmentrandomaccessoffsetatom.cpp b/fileformats/mp4/composer/src/moviefragmentrandomaccessoffsetatom.cpp
index 988eac7..e4fa471 100644
--- a/fileformats/mp4/composer/src/moviefragmentrandomaccessoffsetatom.cpp
+++ b/fileformats/mp4/composer/src/moviefragmentrandomaccessoffsetatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/movieheaderatom.cpp b/fileformats/mp4/composer/src/movieheaderatom.cpp
index 12b77c8..f4853be 100644
--- a/fileformats/mp4/composer/src/movieheaderatom.cpp
+++ b/fileformats/mp4/composer/src/movieheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MovieHeaderAtom Class defines the overall media-independent information
     relevant to the MPEG-4 presentation as a whole.
@@ -33,6 +32,8 @@
 PVA_FF_MovieHeaderAtom::PVA_FF_MovieHeaderAtom(uint8 version, uint32 flags, uint32 fileAuthoringFlags)
         : PVA_FF_FullAtom(MOVIE_HEADER_ATOM, version, flags)
 {
+    OSCL_UNUSED_ARG(fileAuthoringFlags);
+
     PVA_FF_AtomUtils::setTime(_creationTime); // Setting creating time (since 1/1/1904)
     PVA_FF_AtomUtils::setTime(_modificationTime); // Setting modification time
     _timeScale = DEFAULT_PRESENTATION_TIMESCALE;
diff --git a/fileformats/mp4/composer/src/mpeg4file.cpp b/fileformats/mp4/composer/src/mpeg4file.cpp
index 485d88d..556b907 100644
--- a/fileformats/mp4/composer/src/mpeg4file.cpp
+++ b/fileformats/mp4/composer/src/mpeg4file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     The PVA_FF_Mpeg4File Class fp the class that will construct and maintain all the
     mecessary data structures to be able to render a valid MP4 file to disk.
@@ -32,7 +31,6 @@
 #include "mpeg4file.h"
 #include "a_atomdefs.h"
 #include "atomutils.h"
-#include "bifs.h"
 
 #include "objectdescriptorupdate.h"
 
@@ -72,10 +70,6 @@
 
     _tempOutputPath = _STRLIT("");
 
-    _odAudio = NULL;
-    _odVideo = NULL;
-    _od = NULL;
-    _ODTrack = NULL;
     _oUserDataPopulated = true;
     _pmovieAtom = NULL;
     _pmediaDataAtomVec = NULL;
@@ -84,55 +78,15 @@
     _pCurrentMoofAtom = NULL;
     _pCurrentMediaDataAtom = NULL;
     iCacheSize = 0;
+    _oIsFileOpen = false;
+    _pInterLeaveBufferVec = NULL;
+    _oInterLeaveEnabled = false;
+    _aFs = NULL;
 }
 
 // Destructor
 PVA_FF_Mpeg4File::~PVA_FF_Mpeg4File()
 {
-    if (_oFileRenderCalled == false)
-    {
-        // Render to file was not called, hence
-        // these atoms would not be deleted, so
-        // add them to corresponding parents, so
-        // that they get deleted
-
-        if (_odAudio != NULL)
-        {
-            if (_odu != NULL)
-            {
-                _odu->addObjectDescriptor(_odAudio);
-            }
-            else
-            {
-                PV_MP4_FF_DELETE(NULL, PVA_FF_ObjectDescriptor, _odAudio);
-            }
-        }
-
-        if (_odVideo != NULL)
-        {
-            if (_odu != NULL)
-            {
-                _odu->addObjectDescriptor(_odVideo);
-            }
-            else
-            {
-                PV_MP4_FF_DELETE(NULL, PVA_FF_ObjectDescriptor, _odVideo);
-            }
-        }
-
-        // Add the PVA_FF_ObjectDescriptorUpdate to the media data atom
-        if (_od != NULL)
-        {
-            _od->addRenderableSample(_odu);
-        }
-        if (_ODTrack != NULL)
-        {
-            // Add the ODCommand "PVA_FF_ObjectDescriptorUpdate" to the OD track
-            _ODTrack->nextSample(MEDIA_TYPE_OBJECT_DESCRIPTOR,
-                                 (void*)_odu,
-                                 _odu->getSizeOfDescriptorObject());
-        }
-    }
 
     {
         if (_oUserDataPopulated == false)
@@ -163,7 +117,7 @@
     }
 
 
-    if (_oInterLeaveEnabled)
+    if ((_oInterLeaveEnabled) && (NULL != _pInterLeaveBufferVec))
     {
         // delete all interleave buffers
         int32 size = _pInterLeaveBufferVec->size();
@@ -195,8 +149,10 @@
     {
         PV_MP4_FF_DELETE(NULL, PVA_FF_FileTypeAtom, _pFileTypeAtom);
     }
-
-    PVA_FF_AtomUtils::closeFileSession(OSCL_STATIC_CAST(Oscl_FileServer*, _aFs));
+    if (_aFs)
+    {
+        PVA_FF_AtomUtils::closeFileSession(OSCL_STATIC_CAST(Oscl_FileServer*, _aFs));
+    }
 }
 
 void PVA_FF_Mpeg4File::SetCacheSize(uint32 aCacheSize)
@@ -208,6 +164,7 @@
                        void *osclFileServerSession,
                        uint32 fileAuthoringFlags)
 {
+    OSCL_UNUSED_ARG(mediaType);
     _modifiable = true; // Allow addition of media samples
     _firstFrameInLayer0 = true;
     _firstFrameInLayer1 = true;
@@ -245,11 +202,6 @@
     _tempFileIndex = 'a';
 
     _pmediaDataAtomVec  = NULL;
-    _odAudio            = NULL;
-    _odVideo            = NULL;
-    _ODTrack            = NULL;
-    _od                 = NULL;
-    _odu                = NULL;
     _pmovieAtom         = NULL;
 
     _puserDataAtom      = NULL;
@@ -258,7 +210,6 @@
     _initialUserDataSize     = 0;
     _oDirectRenderEnabled    = false;
 
-
     _oSetTitleDone			= false;
     _oSetAuthorDone			= false;
     _oSetCopyrightDone		= false;
@@ -270,11 +221,13 @@
     _oSetGenreDone			= false;
     _oSetClassificationDone	= false;
     _oSetLocationInfoDone	= false;
+    _oSetAlbumDone			= false;
+    _oSetRecordingYearDone	= false;
 
 
     _totalTempFileRemoval = false;
     _oUserDataUpFront     = true;
-
+    _oIsFileOpen		  = false;
     _oFirstSampleEditMode = false;
 
     _fileAuthoringFlags = fileAuthoringFlags;
@@ -346,63 +299,6 @@
 
     _pparent = NULL;
 
-    // BIFS Track
-    PVA_FF_TrackAtom *BIFSTrack = NULL;
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TrackAtom, (MEDIA_TYPE_SCENE_DESCRIPTION,
-                  _pmovieAtom->getMutableMovieHeaderAtom().findNextTrackID(),
-                  _fileAuthoringFlags), BIFSTrack);
-    // Object Descriptor Track
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TrackAtom, (MEDIA_TYPE_OBJECT_DESCRIPTOR,
-                  _pmovieAtom->getMutableMovieHeaderAtom().findNextTrackID(),
-                  _fileAuthoringFlags), _ODTrack);
-
-    // Add the BIFS and OD tracks to the movie atom
-    _pmovieAtom->addTrackAtom(BIFSTrack);
-    _pmovieAtom->addTrackAtom(_ODTrack);
-
-    //CURRENTLY DEFAULTED TO 1000 - MAY NEED TO CHANGE LATER ON WHEN IPMP SUPPORT
-    BIFSTrack->setMediaTimeScale(DEFAULT_PRESENTATION_TIMESCALE);
-    _ODTrack->setMediaTimeScale(DEFAULT_PRESENTATION_TIMESCALE);
-
-    // Still need to add the componnets to the MEDIA_DATA_ATOM atom
-
-    // MODIFIED to fit new PVA_FF_ES_ID_Inc classes
-    // Add BIFS and OD track ESDescriptors to the ODAtom (i.e. the InitialObectDescriptor)
-    // Create new PVA_FF_ES_ID_Inc for the Bifs track and add it to the IOD
-    PVA_FF_ES_ID_Inc* inc = NULL;
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ES_ID_Inc, (BIFSTrack->getTrackID()), inc);
-
-    _pmovieAtom->getMutableObjectDescriptorAtom().getMutableInitialObjectDescriptor().addESIDInclude(inc);
-    // Create new PVA_FF_ES_ID_Inc for the OD track and add it to the IOD
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ES_ID_Inc, (_ODTrack->getTrackID()), inc);
-
-    _pmovieAtom->getMutableObjectDescriptorAtom().getMutableInitialObjectDescriptor().addESIDInclude(inc);
-
-    // Create the ODCommand "PVA_FF_ObjectDescriptorUpdate" and add the ODs with refs to the media and hint tracks
-    _odu = OSCL_NEW(PVA_FF_ObjectDescriptorUpdate, ());
-
-    // Create MEDIA_DATA_ATOM atoms to comtain the BIFS and OD stream data
-    PVA_FF_MediaDataAtom *bif = NULL;
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MediaDataAtom, (_tempOutputPath,
-                  _tempFilePostfix,
-                  _tempFileIndex,
-                  MEDIA_DATA_IN_MEMORY,
-                  _aFs,
-                  iCacheSize), bif);
-    _tempFileIndex++;
-    bif->setTrackReferencePtr(BIFSTrack);
-    addMediaDataAtom(bif);
-
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MediaDataAtom, (_tempOutputPath,
-                  _tempFilePostfix,
-                  _tempFileIndex,
-                  MEDIA_DATA_IN_MEMORY,
-                  _aFs,
-                  iCacheSize), _od);
-    _tempFileIndex++;
-    _od->setTrackReferencePtr(_ODTrack);
-    addMediaDataAtom(_od);
-
     /*
      * In interleave mode, create only ONE media atom, to store
      * all the media samples.
@@ -448,94 +344,6 @@
     {
         _pmovieAtom->createAssetInfoAtoms();
     }
-    // Pointer to the bifs data
-    uint8 * pbifs = NULL;
-    int32 bifsSize = 0;
-
-    // Check the media type(s) of the desired mpeg4 file and create
-    // the appropriate MediaDataAtoms (MEDIA_DATA_ATOM) to store the media content
-    switch (mediaType)
-    {
-        case FILE_TYPE_AUDIO_TEXT:
-        case FILE_TYPE_AUDIO:
-        {
-            // Create the OD for the audio stream
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ObjectDescriptor, (_nextAvailableODID), _odAudio);
-
-            _nextAvailableODID++;
-
-            bifsSize = AUDIO_BIFS_SCENE_SIZE;
-            pbifs = (uint8 *)oscl_malloc(AUDIO_BIFS_SCENE_SIZE);
-            oscl_memcpy(pbifs, AUDIO_BIFS_SCENE, AUDIO_BIFS_SCENE_SIZE);
-        }
-        break;
-        case FILE_TYPE_TIMED_TEXT:
-        case FILE_TYPE_VIDEO_TEXT:
-        case FILE_TYPE_VIDEO:
-        case FILE_TYPE_STILL_IMAGE:
-        {
-            // Create the OD for the base-layer video stream
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ObjectDescriptor, (_nextAvailableODID), _odVideo);
-
-            _nextAvailableODID++;
-
-            bifsSize = VIDEO_BIFS_SCENE_SIZE;
-            pbifs = (uint8 *)oscl_malloc(VIDEO_BIFS_SCENE_SIZE);
-            oscl_memcpy(pbifs, VIDEO_BIFS_SCENE, VIDEO_BIFS_SCENE_SIZE);
-        }
-        break;
-
-        case FILE_TYPE_AUDIO_VIDEO_TEXT:
-        case FILE_TYPE_AUDIO_VIDEO:
-        case FILE_TYPE_STILL_IMAGE_AUDIO:
-        {
-            // Create the OD for the audio stream
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ObjectDescriptor, (_nextAvailableODID), _odAudio);
-
-            _nextAvailableODID++;
-
-            // Create the OD for the base-layer video stream
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ObjectDescriptor, (_nextAvailableODID), _odVideo);
-
-            _nextAvailableODID++;
-
-            bifsSize = AUDIO_VIDEO_BIFS_SCENE_SIZE;
-            pbifs = (uint8 *)oscl_malloc(AUDIO_VIDEO_BIFS_SCENE_SIZE);
-            oscl_memcpy(pbifs, AUDIO_VIDEO_BIFS_SCENE, AUDIO_VIDEO_BIFS_SCENE_SIZE);
-        }
-        break;
-
-        default:
-            pbifs = NULL;
-            break;
-    }
-    if (bif != NULL)
-    {
-        // Add the BIFS binary encoded scene to the media data atom
-        PVA_FF_BufferHolder *bufHolder = NULL;
-
-        //PV_MP4_FF_NEW(fp->auditCB, PVA_FF_BufferHolder, (pbifs, bifsSize),bufHolder);
-        bufHolder = OSCL_NEW(PVA_FF_BufferHolder, (pbifs, bifsSize));
-
-        bif->addRenderableSample(bufHolder);
-
-        // Add the BIFS Command "ReplaceScene" to the BIFS track
-        BIFSTrack->nextSample(MEDIA_TYPE_SCENE_DESCRIPTION, (void*)pbifs, bifsSize);
-
-        if (pbifs)
-        {
-            oscl_free(pbifs);
-        }
-
-        //Add the decoder-specific info for the BIFS track
-        int32 bifsDecoderSize = BIFS_DECODER_INFO_SIZE;
-        uint8 * pbifsDecoder = (uint8 *)oscl_malloc(BIFS_DECODER_INFO_SIZE);
-        oscl_memcpy(pbifsDecoder, BIFS_DECODER_INFO, bifsDecoderSize);
-        setBIFSDecoderInfo(pbifsDecoder, bifsDecoderSize);
-        oscl_free(pbifsDecoder);
-    }
-
-
     recomputeSize();
 
     return true;
@@ -677,7 +485,6 @@
 
             _tempFileIndex++;
         }
-
         addMediaDataAtom(mda);
     }
     else
@@ -695,7 +502,8 @@
                       o3GPPCompliant, 1, profile, profileComp, level),
                       pmediatrack);
 
-        mda->setTrackReferencePtr(pmediatrack);
+        if (mda)
+            mda->setTrackReferencePtr(pmediatrack);
         _pmovieAtom->addTrackAtom(pmediatrack);
 
         // add audio interleave buffer for track
@@ -711,13 +519,6 @@
 
         // Returns the index of the reference in the table to which this was
         // just added (with a 1-based index NOT a zero-based index)
-        int32 index = _ODTrack->addTrackReference(pmediatrack->getTrackID());
-
-        // Create the PVA_FF_ES_ID_Ref to add to the OD
-        PVA_FF_ES_ID_Ref *ref = NULL;
-        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ES_ID_Ref, (index), ref);
-
-        _odAudio->addESIDReference(ref);
 
         TrackID = pmediatrack->getTrackID();
 
@@ -778,19 +579,12 @@
             addInterLeaveBuffer(pInterLeaveBuffer);
         }
 
-        mda->setTrackReferencePtr(pmediatrack);
+        if (mda)
+            mda->setTrackReferencePtr(pmediatrack);
         _pmovieAtom->addTrackAtom(pmediatrack);
 
         // Returns the index of the reference in the table to which this was
         // just added (with a 1-based index NOT a zero-based index)
-        int32 index = _ODTrack->addTrackReference(pmediatrack->getTrackID());
-
-        // Create the PVA_FF_ES_ID_Ref to add to the OD
-        PVA_FF_ES_ID_Ref *ref = NULL;
-        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ES_ID_Ref, (index), ref);
-
-        _odVideo->addESIDReference(ref);
-
         TrackID = pmediatrack->getTrackID();
     }
 
@@ -831,7 +625,6 @@
 
         // Returns the index of the reference in the table to which this was
         // just added (with a 1-based index NOT a zero-based index)
-        _ODTrack->addTrackReference(pmediatrack->getTrackID());
 
         TrackID = pmediatrack->getTrackID();
 
@@ -881,8 +674,6 @@
     mediaType  = mediaTrack->getMediaType();
     codecType = _pmovieAtom->getCodecType(trackID);
 
-    uint32 timescale = mediaTrack->getMediaTimeScale();
-
     // Create media sample buffer and size field
     uint32 size = 0;
     // temporary variables
@@ -976,8 +767,6 @@
     mediaType  = mediaTrack->getMediaType();
     codecType = _pmovieAtom->getCodecType(trackID);
 
-    uint32 timescale = mediaTrack->getMediaTimeScale();
-
     // Create media sample buffer and size field
     uint32 size = 0;
     // temporary variables
@@ -1380,34 +1169,59 @@
 }
 
 void
-PVA_FF_Mpeg4File::setLocationInfo(PVA_FF_UNICODE_STRING_PARAM locationName, PVA_FF_UNICODE_STRING_PARAM locationInfoAstrBody, PVA_FF_UNICODE_STRING_PARAM locationInfoAddNotes,
-                                  uint8 locationInfoRole, uint32 locationInfoLongitude, uint32 locationInfoLatitude,
-                                  uint32 locationInfoAltitude, uint16 langCode)
+PVA_FF_Mpeg4File::setLocationInfo(PvmfAssetInfo3GPPLocationStruct *ptr_loc_struct)
 {
-    OSCL_UNUSED_ARG(langCode);
-
     if (!_oSetLocationInfoDone)
     {
         _oSetLocationInfoDone		= true;
-        _locationName			= locationName;
-        _locationInfoAstrBody	= locationInfoAstrBody;
-        _locationInfoAddNotes	= locationInfoAddNotes;
-        _locationInfoRole		= locationInfoRole;
-        _locationInfoLongitude	= locationInfoLongitude;
-        _locationInfoAltitude	= locationInfoAltitude;
-        _locationInfoLatitude	= locationInfoLatitude;
+        _locationName			= ptr_loc_struct->_location_name;
+        _locationInfoAstrBody	= ptr_loc_struct->_astronomical_body;
+        _locationInfoAddNotes	= ptr_loc_struct->_additional_notes;
+        _locationInfoRole		= ptr_loc_struct->_role;
+        _locationInfoLongitude	= ptr_loc_struct->_longitude;
+        _locationInfoAltitude	= ptr_loc_struct->_altitude;
+        _locationInfoLatitude	= ptr_loc_struct->_latitude;
 
         if (_pmovieAtom != NULL)
         {
-            _pmovieAtom->setLocationInfo(locationName, locationInfoAstrBody,
-                                         locationInfoAddNotes, locationInfoRole,
-                                         locationInfoLongitude, locationInfoLatitude,
-                                         locationInfoAltitude, langCode);
+            _pmovieAtom->setLocationInfo(ptr_loc_struct);
         }
     }
 }
 
 void
+PVA_FF_Mpeg4File::setAlbumInfo(PVA_FF_UNICODE_STRING_PARAM albumInfo, uint16 langCode)
+{
+    if (!_oSetAlbumDone)
+    {
+        _oSetAlbumDone = true;
+        _albumInfo = albumInfo;
+
+        if (_pmovieAtom != NULL)
+        {
+            _pmovieAtom->setAlbumInfo(albumInfo, langCode);
+        }
+
+    }
+}
+
+void
+PVA_FF_Mpeg4File::setRecordingYear(uint16 recordingYear)
+{
+    if (!_oSetRecordingYearDone)
+    {
+        _oSetRecordingYearDone = true;
+        _recordingYear = recordingYear;
+
+        if (_pmovieAtom != NULL)
+        {
+            _pmovieAtom->setRecordingYearInfo(recordingYear);
+        }
+
+    }
+}
+
+void
 PVA_FF_Mpeg4File::setCreationDate(PVA_FF_UNICODE_STRING_PARAM creationDate)
 {
     if (!_oSetCreationDateDone)
@@ -1458,10 +1272,6 @@
     {
         _pmediaDataAtomVec->push_back(atom);
     }
-    else
-    {
-        //cerr << "ERROR: Not allowed to modify file" << endl;
-    }
 }
 
 //for timed text only
@@ -1484,13 +1294,6 @@
     PVA_FF_TrackAtom *track = _pmovieAtom->getMediaTrack(trackID);
     if (track->getMediaType() == MEDIA_TYPE_VISUAL)
     {
-        if (track->getCodecType() == CODEC_TYPE_MPEG4_VIDEO)
-        {
-            // The fifth byte in the VOL header fp the profile level value
-            uint8 profileLevelValue = *(header + 4);
-            _pmovieAtom->getMutableObjectDescriptorAtom().
-            getMutableInitialObjectDescriptor().setVisualProfileLevelIndication(profileLevelValue);
-        }
         if (track->getCodecType() == CODEC_TYPE_AVC_VIDEO)
         {
             PV_MP4_FF_DELETE(NULL, PVA_FF_DecoderSpecificInfo, pinfo);
@@ -1499,15 +1302,6 @@
 }
 
 void
-PVA_FF_Mpeg4File::setBIFSDecoderInfo(uint8 * header, int32 size)
-{
-    PVA_FF_DecoderSpecificInfo *pinfo = NULL;
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_DecoderSpecificInfo, (header, (uint32)size), pinfo);
-    _pmovieAtom->setBIFSDecoderInfo(pinfo);
-}
-
-
-void
 PVA_FF_Mpeg4File::recomputeSize()
 {
     uint32 i;
@@ -1525,26 +1319,6 @@
 PVA_FF_Mpeg4File::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
 {
     uint32 metaDataSize = 0;
-
-    if (_odAudio != NULL)
-    {
-        _odu->addObjectDescriptor(_odAudio);
-    }
-
-    if (_odVideo != NULL)
-    {
-        _odu->addObjectDescriptor(_odVideo);
-    }
-
-    // Add the PVA_FF_ObjectDescriptorUpdate to the media data atom
-    _od->addRenderableSample(_odu);
-
-    // Add the ODCommand "PVA_FF_ObjectDescriptorUpdate" to the OD track
-    _ODTrack->nextSample(MEDIA_TYPE_OBJECT_DESCRIPTOR,
-                         (void*)_odu,
-                         _odu->getSizeOfDescriptorObject());
-
-
     /*
      * Setting the major brand in ftyp atom
      */
@@ -1797,7 +1571,6 @@
                         trefVecIndex++)
                 {
                     PVA_FF_TrackAtom* pTrack = (*trefVec)[trefVecIndex];
-                    uint32 mediaType  = pTrack->getMediaType();
                     uint32 trackID = pTrack->getTrackID();
 
                     if (_oInterLeaveEnabled)
@@ -1840,7 +1613,6 @@
 
                         fp._filePtr = ((*_pmediaDataAtomVec)[k]->getTargetFilePtr());
                         fp._osclFileServerSession = OSCL_STATIC_CAST(Oscl_FileServer*, _aFs);
-
                         _directRenderFileOffset =
                             ((*_pmediaDataAtomVec)[k]->getTotalDataRenderedToTargetFileInDirectRenderMode());
                     }
@@ -1851,6 +1623,7 @@
         {
             fp._osclFileServerSession = OSCL_STATIC_CAST(Oscl_FileServer*, _aFs);
             PVA_FF_AtomUtils::openFile(&fp, filename, Oscl_File::MODE_READWRITE | Oscl_File::MODE_BINARY);
+            _oIsFileOpen = true;
         }
 
         if (fp._filePtr == NULL)
@@ -1863,7 +1636,11 @@
             return false;
         }
 
-        PVA_FF_AtomUtils::closeFile(&fp);
+        if (_oIsFileOpen)
+        {
+            PVA_FF_AtomUtils::closeFile(&fp);
+            _oIsFileOpen = false;
+        }
 
         if (_fileWriteFailed)
         {
@@ -1877,7 +1654,6 @@
         {
             if ((*_pmediaDataAtomVec)[k]->IsTargetRender())
             {
-
                 Oscl_Vector<PVA_FF_TrackAtom*, OsclMemAllocator> *trefVec =
                     (*_pmediaDataAtomVec)[k]->getTrackReferencePtrVec();
 
@@ -1914,8 +1690,12 @@
         fp._filePtr = _targetFileHandle;
         fp._osclFileServerSession = OSCL_STATIC_CAST(Oscl_FileServer*, _aFs);
         _pMfraAtom->renderToFileStream(&fp);
-
-        PVA_FF_AtomUtils::closeFile(&fp);
+        _pmovieAtom->writeMaxSampleSize(&fp);
+        if (_oIsFileOpen)
+        {
+            PVA_FF_AtomUtils::closeFile(&fp);
+            _oIsFileOpen = false;
+        }
     }
 
 
@@ -1924,6 +1704,9 @@
 }
 
 
+// Access function to set the postfix string for PVA_FF_MediaDataAtom objects
+// Set the post fix string for the temporary file in order to support multiple instances,
+// the goal fp to create temporary files with different names
 void
 PVA_FF_Mpeg4File::SetTempFilePostFix(PVA_FF_UNICODE_STRING_PARAM postFix)
 {
@@ -1931,6 +1714,9 @@
     _tempFilePostfix += postFix;
 }
 
+// Access function to set the output path string for PVA_FF_MediaDataAtom objects
+// Set the output path string for the temporary files in order to generate them at the same location
+// as the final mp4 file.
 void
 PVA_FF_Mpeg4File::SetTempOutputPath(PVA_FF_UNICODE_STRING_PARAM outputPath)
 {
@@ -1943,8 +1729,6 @@
 {
     if (_oInterLeaveEnabled)
     {
-        // If interleave is enabled, them there is only media track
-        // for all, except BIFS and OD of course
         if (_pmediaDataAtomVec != NULL)
         {
             if (_pmediaDataAtomVec->size() > MIN_NUM_MEDIA_TRACKS)
@@ -1993,7 +1777,6 @@
         return false;
     }
 
-    uint32 timescale = mediaTrack->getMediaTimeScale();
     if (mediaType == MEDIA_TYPE_AUDIO)
     {
         if (_modifiable)
@@ -2155,22 +1938,6 @@
     {
         return false;
     }
-
-    if (_odAudio != NULL)
-    {
-        _odu->addObjectDescriptor(_odAudio);
-    }
-
-    if (_odVideo != NULL)
-    {
-        _odu->addObjectDescriptor(_odVideo);
-    }
-
-    // Add the PVA_FF_ObjectDescriptorUpdate to the media data atom
-    _od->addRenderableSample(_odu);
-    // Add the ODCommand "PVA_FF_ObjectDescriptorUpdate" to the OD track
-    _ODTrack->nextSample(MEDIA_TYPE_OBJECT_DESCRIPTOR, (void*)_odu, _odu->getSizeOfDescriptorObject());
-
     /*
      * Setting the major brand in ftyp atom
      */
@@ -2636,10 +2403,13 @@
         // make entry for last sample same as duration of second to last sample
         else
         {
-            uint32 delta = (*tsVec)[ii -1] - (*tsVec)[ii -2];
-            uint32 ts = (*tsVec)[ii -1];
-            pCurrentTrackFragment->updateLastTSEntry(ts + delta);
-            _pmovieAtom->updateMovieFragmentDuration(trackID, ts + delta);
+            if (tsVec->size() > 1)
+            {
+                uint32 delta = (*tsVec)[ii -1] - (*tsVec)[ii -2];
+                uint32 ts = (*tsVec)[ii -1];
+                pCurrentTrackFragment->updateLastTSEntry(ts + delta);
+                _pmovieAtom->updateMovieFragmentDuration(trackID, ts + delta);
+            }
         }
 
 
@@ -2870,6 +2640,8 @@
     int32 codecType = _pmovieAtom->getCodecType(trackID);
     uint32 mediaType = mediaTrack->getMediaType();
     int32 index = 0;
+    if (true == _oComposeMoofAtom)
+        _pmovieAtom->SetMaxSampleSize(trackID, size);
     if (_oFirstSampleEditMode)
     {
         _oChunkStart = true;
@@ -3589,7 +3361,8 @@
     fp._filePtr = NULL;
     fp._osclFileServerSession = NULL;
 
-    //make sure to flush the interleave buffers, be it to temp files or to target files
+    //make sure to flush the interleave buffers, be it to temp files
+    //or to target files
     uint32 kk = 0;
 
     for (kk = 0; kk < _pmediaDataAtomVec->size(); kk++)
@@ -3626,7 +3399,8 @@
             {
                 if (targetRender)
                 {
-                    //Only one track is allowed to be rendered directly onto the target file
+                    //Only one track is allowed to be rendered directly onto the target
+                    //file
                     return false;
                 }
                 else
diff --git a/fileformats/mp4/composer/src/mpeg4mediaheaderatom.cpp b/fileformats/mp4/composer/src/mpeg4mediaheaderatom.cpp
index 909d274..39488f1 100644
--- a/fileformats/mp4/composer/src/mpeg4mediaheaderatom.cpp
+++ b/fileformats/mp4/composer/src/mpeg4mediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_Mpeg4MediaHeaderAtom Class fp for streams other than visual and audio.
 */
diff --git a/fileformats/mp4/composer/src/mpegsampleentry.cpp b/fileformats/mp4/composer/src/mpegsampleentry.cpp
index 0e9f476..60c2a16 100644
--- a/fileformats/mp4/composer/src/mpegsampleentry.cpp
+++ b/fileformats/mp4/composer/src/mpegsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_MpegSampleEntry fp used for hint tracks.
 */
@@ -27,8 +26,6 @@
 #include "a_atomdefs.h"
 #include "atomutils.h"
 
-//extern pvostream& operator<<(pvostream& fp, const PVA_FF_ESDAtom &a);
-
 
 // Constructor
 PVA_FF_MpegSampleEntry::PVA_FF_MpegSampleEntry(int32 mediaType)
@@ -111,4 +108,3 @@
         _pparent->recomputeSize();
     }
 }
-
diff --git a/fileformats/mp4/composer/src/objectdescriptor.cpp b/fileformats/mp4/composer/src/objectdescriptor.cpp
deleted file mode 100644
index 17da8a0..0000000
--- a/fileformats/mp4/composer/src/objectdescriptor.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_ObjectDescriptor Class
-*/
-
-#define IMPLEMENT_ObjectDescriptor
-
-#include "objectdescriptor.h"
-#include "atomutils.h"
-#include "a_atomdefs.h"
-
-typedef Oscl_Vector<PVA_FF_ES_ID_Ref*, OsclMemAllocator> PVA_FF_ES_ID_RefVecType;
-
-// Default Constructor
-PVA_FF_ObjectDescriptor::PVA_FF_ObjectDescriptor(uint16 nextAvailableODID, uint8 tag)
-        : PVA_FF_BaseDescriptor(tag)
-{
-    init(nextAvailableODID);
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ES_ID_RefVecType, (), _pES_ID_Ref_Vec);
-
-    recomputeSize();
-}
-
-// Destructor
-PVA_FF_ObjectDescriptor::~PVA_FF_ObjectDescriptor()
-{
-    // Cleanup vector of ES_ID_Refs
-    if (_pES_ID_Ref_Vec != NULL)
-    {
-        for (uint32 i = 0; i < _pES_ID_Ref_Vec->size(); i++)
-        {
-            PVA_FF_ES_ID_Ref* ref = (*_pES_ID_Ref_Vec)[i];
-            PV_MP4_FF_DELETE(NULL, PVA_FF_ES_ID_Ref, ref);
-        }
-        PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_ES_ID_RefVecType, Oscl_Vector, _pES_ID_Ref_Vec);
-    }
-}
-
-void
-PVA_FF_ObjectDescriptor::init(uint16 nextAvailableODID)
-{
-    _objectDescriptorID = nextAvailableODID;
-
-    _urlFlag = false;
-    _urlLength = 0;
-    _reserved = 0x1f;
-}
-
-// Rendering the Descriptor in proper format (bitlengths, etc.) to an ostream
-bool
-PVA_FF_ObjectDescriptor::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
-{
-    int32 rendered = 0; // Keep track of number of bytes rendered
-
-    // Render the base class members
-    int32 numBytes = renderBaseDescriptorMembers(fp);
-
-    if (numBytes == 0)
-    {
-        return false;
-    }
-    rendered += numBytes;
-
-    // Pack and render ODID, urlFlag, and reserved
-    uint16 data = (uint16)((getObjectDescriptorID() & 0x0fffff) << 6); // (10 bits)
-
-    if (getUrlFlag())
-    {
-        data |= 0x20; // Set urlFlag bit
-    }
-
-    data |= _reserved; // (5 bits) reserved 0b11111
-    if (!PVA_FF_AtomUtils::render16(fp, data))
-    {
-        return false;
-    }
-    rendered += 2;
-
-    if (getUrlFlag())
-    {
-        // Render _urlLength
-        if (!PVA_FF_AtomUtils::render8(fp, getUrlLength()))
-        {
-            return false;
-        }
-        rendered += 1;
-
-        // Render url string
-        if (getUrlLength() > 0)
-        {
-            if (!PVA_FF_AtomUtils::renderString(fp, getUrlString()))
-            {
-                return false;
-            }
-        }
-        rendered += getUrlLength();
-
-    }
-    else
-    {
-        // Render the vector of ESDescriptors - actually render their ESIDs
-        if (_pES_ID_Ref_Vec != NULL)
-        {
-            for (uint32 i = 0; i < _pES_ID_Ref_Vec->size(); i++)
-            {
-                PVA_FF_ES_ID_Ref* ref = (*_pES_ID_Ref_Vec)[i];
-                if (!ref->renderToFileStream(fp))
-                {
-                    return false;
-                }
-                rendered += ref->getSizeOfDescriptorObject();
-            }
-        }
-    }
-
-    return true;
-}
-
-
-// Adding an PVA_FF_ES_ID_Ref to the vector of ES_ID_References
-// Then recomputing the size of the descriptor with the newly added PVA_FF_ES_ID_Ref
-void
-PVA_FF_ObjectDescriptor::addESIDReference(PVA_FF_ES_ID_Ref *ref)
-{
-    _pES_ID_Ref_Vec->push_back(ref);
-    recomputeSize();
-}
-
-
-// Returning an PVA_FF_ES_ID_Ref pointer at location index in the array - if
-// the array fp that big
-PVA_FF_ES_ID_Ref*
-PVA_FF_ObjectDescriptor::getESIDReferenceAt(int32 index)
-{
-    if (_pES_ID_Ref_Vec != NULL)
-    {
-        if (index < (int32)_pES_ID_Ref_Vec->size())
-        {
-            return (*_pES_ID_Ref_Vec)[index];
-        }
-        else
-        {
-            return NULL;
-        }
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-
-void
-PVA_FF_ObjectDescriptor::recomputeSize()
-{
-    int32 contents = 0;
-    contents += 2; // (2 bytes = 16 bits) Packed ODID, URLFlag, and Reserved
-
-    if (getUrlFlag())
-    {
-        contents += 1; // 1 byte for URL Length variable
-        contents += _urlLength; // length of URL string
-    }
-    else
-    {
-
-        if (_pES_ID_Ref_Vec != NULL)
-        {
-            // Renders the PVA_FF_ES_ID_Ref instead of the actual PVA_FF_ESDescriptor
-            int32 SIZE_OF_ES_ID_REF_OBJECT = 4;
-            contents += _pES_ID_Ref_Vec->size() * SIZE_OF_ES_ID_REF_OBJECT;
-        }
-    }
-
-    _sizeOfClass = contents;
-    _sizeOfSizeField = PVA_FF_AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(contents);
-
-    if (_pparent != NULL)
-    {
-        _pparent->recomputeSize();
-    }
-}
-
diff --git a/fileformats/mp4/composer/src/objectdescriptoratom.cpp b/fileformats/mp4/composer/src/objectdescriptoratom.cpp
deleted file mode 100644
index a71acde..0000000
--- a/fileformats/mp4/composer/src/objectdescriptoratom.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_ObjectDescriptorAtom Class contains an PVA_FF_ObjectDescriptor or an
-    PVA_FF_InitialObjectDescriptor.
-*/
-
-
-#define IMPLEMENT_ObjectDescriptorAtom
-
-#include "objectdescriptoratom.h"
-#include "atomutils.h"
-#include "a_atomdefs.h"
-
-//extern pvostream& operator<<(pvostream& fp, PVA_FF_InitialObjectDescriptor &iod);
-//extern pvostream& operator<<(pvostream& fp, const PVA_FF_InitialObjectDescriptor &iod);
-
-// Constructor
-PVA_FF_ObjectDescriptorAtom::PVA_FF_ObjectDescriptorAtom(uint8 version, uint32 flags)
-        : PVA_FF_FullAtom(OBJECT_DESCRIPTOR_ATOM, version, flags)
-{
-    _success = true;
-
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_InitialObjectDescriptor, (), _pOD);
-
-    _pOD->setParent(this);
-    recomputeSize();
-}
-
-// Destructor
-PVA_FF_ObjectDescriptorAtom::~PVA_FF_ObjectDescriptorAtom()
-{
-    // Cleanup PVA_FF_InitialObjectDescriptor
-    PV_MP4_FF_DELETE(NULL, PVA_FF_InitialObjectDescriptor, _pOD);
-}
-
-void
-PVA_FF_ObjectDescriptorAtom::recomputeSize()
-{
-    _size = getDefaultSize() + _pOD->getSizeOfDescriptorObject();
-
-    // Update size of parent item (continue up the tree to root)
-    if (getParent() != NULL)
-    {
-        _pparent->recomputeSize();
-    }
-}
-
-
-// Rendering the PVA_FF_Atom in proper format (bitlengths, etc.) to an ostream
-bool
-PVA_FF_ObjectDescriptorAtom::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
-{
-    int32 rendered = 0; // Keep track of number of bytes rendered
-
-    // Render PVA_FF_Atom type and size
-    if (!renderAtomBaseMembers(fp))
-    {
-        return false;
-    }
-    rendered += getDefaultSize();
-
-    // Render the OD
-    if (!_pOD->renderToFileStream(fp))
-    {
-        return false;
-    }
-    rendered += _pOD->getSizeOfDescriptorObject();
-
-    return true;
-}
diff --git a/fileformats/mp4/composer/src/objectdescriptorupdate.cpp b/fileformats/mp4/composer/src/objectdescriptorupdate.cpp
deleted file mode 100644
index c8beeb2..0000000
--- a/fileformats/mp4/composer/src/objectdescriptorupdate.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*
-    This PVA_FF_ObjectDescriptorUpdate Class conveys a new list of ObjectDescriptors
-    OD streams
-*/
-
-
-#define IMPLEMENT_BaseCommand
-
-#include "objectdescriptorupdate.h"
-#include "atomutils.h"
-
-typedef Oscl_Vector<PVA_FF_ObjectDescriptor*, OsclMemAllocator> PVA_FF_ObjectDescriptorVecType;
-
-// Constructor
-PVA_FF_ObjectDescriptorUpdate::PVA_FF_ObjectDescriptorUpdate()
-        : PVA_FF_BaseCommand(0x01)
-{
-    _entryCount = 0;
-    PV_MP4_FF_NEW(fp->auditCB, PVA_FF_ObjectDescriptorVecType, (), _pobjDescrVec);
-
-    recomputeSize();
-}
-
-// Desctructor
-PVA_FF_ObjectDescriptorUpdate::~PVA_FF_ObjectDescriptorUpdate()
-{
-    for (uint32 i = 0; i < _pobjDescrVec->size(); i++)
-    {
-        PV_MP4_FF_DELETE(NULL, PVA_FF_ObjectDescriptor, (*_pobjDescrVec)[i]);
-    }
-    PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_ObjectDescriptorVecType, Oscl_Vector, _pobjDescrVec);
-}
-
-void
-PVA_FF_ObjectDescriptorUpdate::addObjectDescriptor(PVA_FF_ObjectDescriptor *pdescr)
-{
-    _entryCount += 1;
-    _pobjDescrVec->push_back(pdescr);
-    recomputeSize();
-}
-
-const PVA_FF_ObjectDescriptor *
-PVA_FF_ObjectDescriptorUpdate::getObjectDescriptorAt(int32 index) const
-{
-    if (index < (int32)_entryCount)
-    {
-        return (*_pobjDescrVec)[index];
-    }
-    else
-    {
-        return NULL;
-    }
-}
-
-
-// Rendering the Descriptor in proper format (bitlengths, etc.) to an ostream
-bool
-PVA_FF_ObjectDescriptorUpdate::renderToFileStream(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
-{
-    int32 rendered = renderBaseCommandMembers(fp);
-
-    if (rendered > 0)
-    {
-        if (_pobjDescrVec != NULL)
-        {
-            for (int32 i = 0; i < (int32)_entryCount; i++)
-            {
-                if (!((*_pobjDescrVec)[i]->renderToFileStream(fp)))
-                {
-                    return false;
-                }
-                rendered += (*_pobjDescrVec)[i]->getSizeOfDescriptorObject();
-            }
-        }
-    }
-
-    return true;
-}
-
-
-MP4_AUTHOR_FF_FILE_IO_WRAP *
-PVA_FF_ObjectDescriptorUpdate::dump(MP4_AUTHOR_FF_FILE_IO_WRAP *fp)
-{
-    //return fp << *this << endl;
-    return fp;
-}
-
-void
-PVA_FF_ObjectDescriptorUpdate::recomputeSize()
-{
-    int32 contents = 0;
-
-    for (int32 i = 0; i < (int32)_entryCount; i++)   // Get sizes of all contained ODs
-    {
-        contents += (*_pobjDescrVec)[i]->getSizeOfDescriptorObject();
-    }
-    _sizeOfClass = contents;
-    _sizeOfSizeField = PVA_FF_AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(contents);
-
-
-    if (_pparent != NULL)
-    {
-        _pparent->recomputeSize();
-    }
-}
diff --git a/fileformats/mp4/composer/src/sampledescriptionatom.cpp b/fileformats/mp4/composer/src/sampledescriptionatom.cpp
index 304fd64..fd46a1e 100644
--- a/fileformats/mp4/composer/src/sampledescriptionatom.cpp
+++ b/fileformats/mp4/composer/src/sampledescriptionatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleDescriptionAtom Class gives detailed information about the codeing
     type used, and any initialization information needed for coding.
@@ -24,14 +23,10 @@
 
 #define IMPLEMENT_SampleDescriptionAtom
 
-//#define AMR_3GPP_CONTENT
-//#define H263_3GPP_CONTENT
-
 #include "sampledescriptionatom.h"
 
 #include "visualsampleentry.h"
 #include "audiosampleentry.h"
-#include "hintsampleentry.h"
 #include "mpegsampleentry.h"
 
 #include "objectdescriptorupdate.h"
@@ -41,7 +36,6 @@
 #include "objectdescriptor.h"
 #include "decoderspecificinfo.h"
 #include "amrdecoderspecificinfo.h"
-#include "evrcdecoderspecificinfo.h"
 #include "h263decoderspecificinfo.h"
 
 #include "amrsampleentry.h"
@@ -177,55 +171,6 @@
             }
         }
         break;
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        {
-            _handlerType = MEDIA_TYPE_OBJECT_DESCRIPTOR;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_OBJECT_DESCRIPTOR), entry);
-            addSampleEntry(entry);
-        }
-        break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-        {
-            _handlerType = MEDIA_TYPE_CLOCK_REFERENCE;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_CLOCK_REFERENCE), entry);
-            addSampleEntry(entry);
-        }
-        break;
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        {
-            _handlerType = MEDIA_TYPE_SCENE_DESCRIPTION;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_SCENE_DESCRIPTION), entry);
-            addSampleEntry(entry);
-        }
-        break;
-        case MEDIA_TYPE_MPEG7:
-        {
-            _handlerType = MEDIA_TYPE_MPEG7;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_OBJECT_CONTENT_INFO), entry);
-            addSampleEntry(entry);
-        }
-        break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-        {
-            _handlerType = MEDIA_TYPE_OBJECT_CONTENT_INFO;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_OBJECT_CONTENT_INFO), entry);
-            addSampleEntry(entry);
-        }
-        break;
-        case MEDIA_TYPE_IPMP:
-        {
-            _handlerType = MEDIA_TYPE_IPMP;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_IPMP), entry);
-            addSampleEntry(entry);
-        }
-        break;
-        case MEDIA_TYPE_MPEG_J:
-        {
-            _handlerType = MEDIA_TYPE_MPEG_J;
-            PV_MP4_FF_NEW(fp->auditCB, PVA_FF_MpegSampleEntry, (MEDIA_TYPE_MPEG_J), entry);
-            addSampleEntry(entry);
-        }
-        break;
         case MEDIA_TYPE_UNKNOWN:
         default:
         {
@@ -235,6 +180,7 @@
         }
         break;
     }
+    OSCL_UNUSED_ARG(protocol);
 }
 
 
@@ -405,12 +351,6 @@
         }
         break;
 
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        {
-            getMutableSampleEntryAt(0)->addDecoderSpecificInfo(pinfo);
-        }
-        break;
-
         default:
             return; // This fp actually an undefined situation
     }
@@ -484,16 +424,8 @@
         {
             if (_codecType == CODEC_TYPE_AVC_VIDEO)
             {
-                //	PVA_FF_AVCSampleEntry *entry = (PVA_FF_AVCSampleEntry*) getSampleEntryAt(0);
-
-                //	entry->setSample(psample,size);
-
-                //		entry->recomputeSize();
-                //		recomputeSize();
-
-
+                //nothing
             }
-
             else if (!_o3GPPCompliant)
             {
                 PVA_FF_VisualSampleEntry *entry = (PVA_FF_VisualSampleEntry*) getSampleEntryAt(0);
@@ -621,33 +553,10 @@
         // Check whether or not this sample meets the criteria
         // of the existing PVA_FF_SampleEntry(s) ESDAtoms.  If it does, return.
         // Otherwise, add new entry according to this sample
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        {
-            // Actual sample fp an PVA_FF_ObjectDescriptorUpdate command
-            // PVA_FF_ObjectDescriptorUpdate *pupdate = (PVA_FF_ObjectDescriptorUpdate*)psample;
-            // TBA
-            // Check whether or not this sample meets the criteria
-            // of the existing PVA_FF_SampleEntry(s) ESDAtoms.  If it does, return.
-            // Otherwise, add new entry according to this sample
-            // ASSUMING ATLEAST ONE MPEG SAMPLE ENTRY WILL BE ADDED TO THE
-            // OD TRACK
-            PVA_FF_MpegSampleEntry *entry = (PVA_FF_MpegSampleEntry*) getSampleEntryAt(0);
-            entry->nextSampleSize(size);
-            nReturn = 1;
-        }
         break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        case MEDIA_TYPE_MPEG7:
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-        case MEDIA_TYPE_IPMP:
-        case MEDIA_TYPE_MPEG_J:
         case MEDIA_TYPE_UNKNOWN:
         default:
         {
-            // ASSUMING ATLEAST ONE MPEG SAMPLE ENTRY WILL BE ADDED TO THE
-            // BIFS OR OTHER TRACKS
-
             PVA_FF_MpegSampleEntry *entry = (PVA_FF_MpegSampleEntry*) getSampleEntryAt(0);
             entry->nextSampleSize(size);
             nReturn = 1;
@@ -679,9 +588,6 @@
         break;
         default:
         {
-            // ASSUMING ATLEAST ONE MPEG SAMPLE ENTRY WILL BE ADDED TO THE
-            // BIFS OR OTHER TRACKS
-
             PVA_FF_MpegSampleEntry *entry = (PVA_FF_MpegSampleEntry*) getSampleEntryAt(0);
             entry->nextSampleSize(size);
             nReturn = 1;
@@ -741,24 +647,6 @@
             }
             else
             {
-//          cerr << "ERROR: Trying to add PVA_FF_SampleEntry of wrong type!" << endl;
-                return;
-            }
-            break;
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        case MEDIA_TYPE_MPEG7:
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-        case MEDIA_TYPE_IPMP:
-        case MEDIA_TYPE_MPEG_J:
-            if (entry->getType() == MPEG_SAMPLE_ENTRY)
-            {
-                _psampleEntryVec->push_back(entry);
-            }
-            else
-            {
-//          cerr << "ERROR: Trying to add PVA_FF_SampleEntry of wrong type!" << endl;
                 return;
             }
             break;
@@ -787,7 +675,6 @@
                 }
                 else
                 {
-//              cerr << "ERROR: Trying to add PVA_FF_SampleEntry of wrong type!" << endl;
                     return;
                 }
                 break;
@@ -798,7 +685,6 @@
                 }
                 else
                 {
-//              cerr << "ERROR: Trying to add PVA_FF_SampleEntry of wrong type!" << endl;
                     return;
                 }
                 break;
@@ -826,30 +712,25 @@
             case MEDIA_TYPE_AUDIO:
                 if (entry->getType() == AUDIO_SAMPLE_ENTRY)
                 {
-                    //_psampleEntryVec->erase(index); /SKK
                     (*_psampleEntryVec)[index] = entry;
                 }
                 else
                 {
-//              cerr << "ERROR: Trying to add PVA_FF_SampleEntry of wrong type!" << endl;
                     return;
                 }
                 break;
             case MEDIA_TYPE_VISUAL:
                 if (entry->getType() == VIDEO_SAMPLE_ENTRY)
                 {
-                    //_psampleEntryVec->erase(index); //SKK
                     (*_psampleEntryVec)[index] = entry;
                 }
                 else
                 {
-//              cerr << "ERROR: Trying to add PVA_FF_SampleEntry of wrong type!" << endl;
                     return;
                 }
                 break;
             default:
             {
-                //_psampleEntryVec->erase(index); //SKK
                 (*_psampleEntryVec)[index] = entry;
             }
             break;
@@ -901,6 +782,10 @@
     }
     rendered += 4;
 
+    if (_psampleEntryVec->size() < getEntryCount())
+    {
+        return false;
+    }
     for (int32 i = 0; i < (int32)(getEntryCount()); i++)
     {
         if ((uint32) _mediaType == MEDIA_TYPE_AUDIO)
@@ -972,9 +857,12 @@
     int32 size = getDefaultSize();
     size += 4; // For _entryCount
 
-    for (int32 i = 0; i < (int32)(getEntryCount()); i++)
+    if (_psampleEntryVec->size() >= getEntryCount())
     {
-        size += (*_psampleEntryVec)[i]->getSize();
+        for (int32 i = 0; i < (int32)(getEntryCount()); i++)
+        {
+            size += (*_psampleEntryVec)[i]->getSize();
+        }
     }
 
     _size = size;
@@ -986,3 +874,68 @@
     }
 }
 
+void
+PVA_FF_SampleDescriptionAtom::SetMaxSampleSize(uint32 aSize)
+{
+    switch (_mediaType)
+    {
+        case MEDIA_TYPE_VISUAL:
+        {
+            if (!_o3GPPCompliant)
+            {
+                PVA_FF_VisualSampleEntry *entry = (PVA_FF_VisualSampleEntry*) getSampleEntryAt(0);
+                entry->nextSampleSize(aSize);
+            }
+            break;
+        }
+        case MEDIA_TYPE_AUDIO:
+        {
+            if (_codecType == CODEC_TYPE_AAC_AUDIO)
+            {
+                PVA_FF_AudioSampleEntry *entry = (PVA_FF_AudioSampleEntry*) getSampleEntryAt(0);
+                entry->nextSampleSize(aSize);
+            }
+            break;
+        }
+        case MEDIA_TYPE_UNKNOWN:
+        default:
+        {
+            PVA_FF_MpegSampleEntry *entry = (PVA_FF_MpegSampleEntry*) getSampleEntryAt(0);
+            entry->nextSampleSize(aSize);
+            break;
+        }
+    }
+}
+
+void
+PVA_FF_SampleDescriptionAtom::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    switch (_mediaType)
+    {
+        case MEDIA_TYPE_VISUAL:
+        {
+            if (!_o3GPPCompliant)
+            {
+                PVA_FF_VisualSampleEntry *entry = (PVA_FF_VisualSampleEntry*) getSampleEntryAt(0);
+                entry->writeMaxSampleSize(_afp);
+            }
+            break;
+        }
+        case MEDIA_TYPE_AUDIO:
+        {
+            if (_codecType == CODEC_TYPE_AAC_AUDIO)
+            {
+                PVA_FF_AudioSampleEntry *entry = (PVA_FF_AudioSampleEntry*) getSampleEntryAt(0);
+                entry->writeMaxSampleSize(_afp);
+            }
+            break;
+        }
+        case MEDIA_TYPE_UNKNOWN:
+        default:
+        {
+            PVA_FF_MpegSampleEntry *entry = (PVA_FF_MpegSampleEntry*) getSampleEntryAt(0);
+            entry->writeMaxSampleSize(_afp);
+            break;
+        }
+    }
+}
diff --git a/fileformats/mp4/composer/src/sampleentry.cpp b/fileformats/mp4/composer/src/sampleentry.cpp
index 2b01c25..a9c1b7b 100644
--- a/fileformats/mp4/composer/src/sampleentry.cpp
+++ b/fileformats/mp4/composer/src/sampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleEntry Class is the base class for the HinstSampleEntry,
     PVA_FF_VisualSampleEntry, PVA_FF_AudioSampleEntry. and PVA_FF_MpegSampleEntry classes.
@@ -46,4 +45,3 @@
 {
     // Empty
 }
-
diff --git a/fileformats/mp4/composer/src/samplesizeatom.cpp b/fileformats/mp4/composer/src/samplesizeatom.cpp
index ade953c..457160b 100644
--- a/fileformats/mp4/composer/src/samplesizeatom.cpp
+++ b/fileformats/mp4/composer/src/samplesizeatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleSizeAtom Class contains the sample count and a table giving the
     size of each sample.
@@ -59,19 +58,8 @@
         case MEDIA_TYPE_TEXT://added for timed text support
         case MEDIA_TYPE_AUDIO:
         case MEDIA_TYPE_VISUAL:
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-        case MEDIA_TYPE_IPMP:
             addNextSampleSize(size);
             break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-            break;
-        case MEDIA_TYPE_MPEG7:
-            break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-            break;
-        case MEDIA_TYPE_MPEG_J:
-            break;
         case MEDIA_TYPE_UNKNOWN:
         default:
             break;
@@ -142,6 +130,10 @@
 
     if (getDefaultSampleSize() == 0)
     {
+        if (_psampleSizeVec->size() < getSampleCount())
+        {
+            return false;
+        }
         for (int32 i = 0; i < (int32)(getSampleCount()); i++)
         {
             if (!PVA_FF_AtomUtils::render32(fp, (*_psampleSizeVec)[i]))
@@ -167,7 +159,6 @@
     size += 4; // For sampleCount
     if (_sampleSize == 0)
     {
-        //size += (4*_psampleSizeVec->size()); // For all elements in vec
         size += 4 * _sampleCount; // For all elements in vec
     }
 
@@ -206,4 +197,3 @@
     }
     return true;
 }
-
diff --git a/fileformats/mp4/composer/src/sampletableatom.cpp b/fileformats/mp4/composer/src/sampletableatom.cpp
index 8e08c11..1e190a7 100644
--- a/fileformats/mp4/composer/src/sampletableatom.cpp
+++ b/fileformats/mp4/composer/src/sampletableatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleTableAtom Class contains all the time and data indexing of the
     media samples in a track.
@@ -127,6 +126,8 @@
     {
         _psyncSampleAtom->nextSample(flags);
     }
+    OSCL_UNUSED_ARG(mediaType);
+    OSCL_UNUSED_ARG(psample);
 }
 
 void
@@ -216,6 +217,9 @@
     {
         _psyncSampleAtom->nextSample(flags);
     }
+
+    OSCL_UNUSED_ARG(mediaType);
+    OSCL_UNUSED_ARG(fragmentList);
 }
 
 void
@@ -364,4 +368,14 @@
     return true;
 }
 
+void
+PVA_FF_SampleTableAtom::SetMaxSampleSize(uint32 aSize)
+{
+    _psampleDescriptionAtom->SetMaxSampleSize(aSize);
+}
 
+void
+PVA_FF_SampleTableAtom::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    _psampleDescriptionAtom->writeMaxSampleSize(_afp);
+}
diff --git a/fileformats/mp4/composer/src/sampletochunkatom.cpp b/fileformats/mp4/composer/src/sampletochunkatom.cpp
index 5da6d05..d5d8035 100644
--- a/fileformats/mp4/composer/src/sampletochunkatom.cpp
+++ b/fileformats/mp4/composer/src/sampletochunkatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SampleSizeAtom Class contains the sample count and a table giving the
     size of each sample.
@@ -196,7 +195,6 @@
     {
         case MEDIA_TYPE_TEXT://added for timed text support
         case MEDIA_TYPE_AUDIO:
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR:
         case MEDIA_TYPE_VISUAL:
         {
             // Checking actual data size - if current chunk size plus this sample
@@ -216,20 +214,7 @@
             }
         }
         break;
-        case MEDIA_TYPE_CLOCK_REFERENCE: // TBA
-            break;
-        case MEDIA_TYPE_SCENE_DESCRIPTION:
-            // Sample fp an BIFS SceneDescriptor (or a BIFS Command)
-            break;
-        case MEDIA_TYPE_MPEG7: // TBA
-            break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO: // TBA
-            break;
-        case MEDIA_TYPE_IPMP: // TBA
-            break;
-        case MEDIA_TYPE_MPEG_J: // TBA
-            break;
-        case MEDIA_TYPE_UNKNOWN: // TBA
+        case MEDIA_TYPE_UNKNOWN:
         default:
             break;
     }
@@ -263,8 +248,6 @@
     _pfirstChunkVec->push_back(chunk);
     _psamplesPerChunkVec->push_back(samples);
     _psampleDescriptionIndexVec->push_back(index);
-
-    //recomputeSize();
 }
 
 
@@ -303,6 +286,12 @@
 
     // Need to render in a 1-based index vector instead of a 0-based index array
     int32 ARRAY_OFFSET_1_BASE = 1;
+    if ((_pfirstChunkVec->size() < _entryCount) ||
+            (_psamplesPerChunkVec->size() < _entryCount) ||
+            (_psampleDescriptionIndexVec->size() < _entryCount))
+    {
+        return false;
+    }
     for (uint32 i = 0; i < _entryCount; i++)
     {
         if (!PVA_FF_AtomUtils::render32(fp, (*_pfirstChunkVec)[i] + ARRAY_OFFSET_1_BASE))
@@ -323,9 +312,6 @@
     return true;
 }
 
-
-
-
 void
 PVA_FF_SampleToChunkAtom::recomputeSize()
 {
@@ -342,4 +328,3 @@
         _pparent->recomputeSize();
     }
 }
-
diff --git a/fileformats/mp4/composer/src/slconfigdescriptor.cpp b/fileformats/mp4/composer/src/slconfigdescriptor.cpp
index b2fe2c8..d347ab2 100644
--- a/fileformats/mp4/composer/src/slconfigdescriptor.cpp
+++ b/fileformats/mp4/composer/src/slconfigdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SLConfigDescriptor Class
 */
@@ -115,7 +114,6 @@
         contents += 4; // (32 bits for start Dec TS)
         contents += 4; // (32 bits for start Comp TS)
     }
-
     _sizeOfClass = contents;
     _sizeOfSizeField = PVA_FF_AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(contents);
 
diff --git a/fileformats/mp4/composer/src/soundmediaheaderatom.cpp b/fileformats/mp4/composer/src/soundmediaheaderatom.cpp
index 71d8281..85dd812 100644
--- a/fileformats/mp4/composer/src/soundmediaheaderatom.cpp
+++ b/fileformats/mp4/composer/src/soundmediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SoundMediaHeaderAtom Class contains general presentation information,
     independent of coding, about the audio media within the stream.
diff --git a/fileformats/mp4/composer/src/stylerecord.cpp b/fileformats/mp4/composer/src/stylerecord.cpp
index af43203..1f120b7 100644
--- a/fileformats/mp4/composer/src/stylerecord.cpp
+++ b/fileformats/mp4/composer/src/stylerecord.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/syncsampleatom.cpp b/fileformats/mp4/composer/src/syncsampleatom.cpp
index c9b90d9..c36a8f2 100644
--- a/fileformats/mp4/composer/src/syncsampleatom.cpp
+++ b/fileformats/mp4/composer/src/syncsampleatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_SyncSampleAtom Class provides a compact marking of the random access
     points within the stream.
@@ -99,6 +98,10 @@
     int32 ARRAY_OFFSET_1_BASE = 1;
     if (_psampleNumbers != NULL)
     {
+        if (_psampleNumbers->size() < _entryCount)
+        {
+            return false;
+        }
         for (uint32 i = 0; i < _entryCount; i++)
         {
             if (!PVA_FF_AtomUtils::render32(fp, (*_psampleNumbers)[i] + ARRAY_OFFSET_1_BASE))
diff --git a/fileformats/mp4/composer/src/textsampleentry.cpp b/fileformats/mp4/composer/src/textsampleentry.cpp
index 23a693b..fa6c61b 100644
--- a/fileformats/mp4/composer/src/textsampleentry.cpp
+++ b/fileformats/mp4/composer/src/textsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/timetosampleatom.cpp b/fileformats/mp4/composer/src/timetosampleatom.cpp
index 2e29798..2bf71bd 100644
--- a/fileformats/mp4/composer/src/timetosampleatom.cpp
+++ b/fileformats/mp4/composer/src/timetosampleatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TimeToSampleAtom Class contains a compact version of a table that allows
     indexing from decoding to sample number.
@@ -26,7 +25,6 @@
 
 #include "timetosampleatom.h"
 #include "atomutils.h"
-#include "videoutils.h"
 #include "a_atomdefs.h"
 #include "objectdescriptorupdate.h"
 
@@ -64,7 +62,6 @@
         case MEDIA_TYPE_AUDIO: // sample fp an IMediaSample
         case MEDIA_TYPE_VISUAL: // sample fp an IMediaSample
         case MEDIA_TYPE_TEXT:	// sample fp an IMediatextSample for timed text
-        case MEDIA_TYPE_IPMP: // Sample fp an IPMP Message
         {
             if (_firstEntry)
             {
@@ -83,17 +80,6 @@
         }
         break;
 
-        case MEDIA_TYPE_OBJECT_DESCRIPTOR: // Sample fp an PVA_FF_ObjectDescriptor Command
-        case MEDIA_TYPE_SCENE_DESCRIPTION: // Sample fp an BIFS Command
-            break;
-        case MEDIA_TYPE_CLOCK_REFERENCE:
-            break;
-        case MEDIA_TYPE_MPEG7:
-            break;
-        case MEDIA_TYPE_OBJECT_CONTENT_INFO:
-            break;
-        case MEDIA_TYPE_MPEG_J:
-            break;
         case MEDIA_TYPE_UNKNOWN:
         default:
             break;
@@ -106,8 +92,7 @@
 PVA_FF_TimeToSampleAtom::updateLastTSEntry(uint32 ts)
 {
     if (((uint32) _mediaType == MEDIA_TYPE_AUDIO) ||
-            ((uint32) _mediaType == MEDIA_TYPE_VISUAL) ||
-            ((uint32) _mediaType == MEDIA_TYPE_IPMP))
+            ((uint32) _mediaType == MEDIA_TYPE_VISUAL))
     {
         int32 delta = ts - _currentTimestamp;
         addDelta(delta);
@@ -116,16 +101,6 @@
     _lastTSUpdated = true;
 }
 
-void
-PVA_FF_TimeToSampleAtom::setBIFSODSampleDuration(int32 duration)
-{
-    if (((uint32) _mediaType == MEDIA_TYPE_OBJECT_DESCRIPTOR) ||
-            ((uint32) _mediaType == MEDIA_TYPE_SCENE_DESCRIPTION))
-    {
-        addDelta(duration);
-    }
-}
-
 // Add delta to the table - logic contained within if shoudl just update table entries
 // or if should add new entries
 void
@@ -162,10 +137,6 @@
 {
     _psampleDeltaVec->push_back(delta);
     _psampleCountVec->push_back(count);
-
-    //(*_psampleDeltaVec) += (delta);
-    //(*_psampleCountVec) += (count);
-
     _entryCount++;
     recomputeSize();
 }
@@ -186,8 +157,7 @@
     // This is required to comply with w3850 Sec 13.2.3.16
     // "Note that the time to sample atoms must give durations for all
     // samples including the last one"
-    if (((uint32) _mediaType != MEDIA_TYPE_OBJECT_DESCRIPTOR) &&
-            ((uint32) _mediaType != MEDIA_TYPE_SCENE_DESCRIPTION) && (_lastTSUpdated == false))
+    if (_lastTSUpdated == false)
     {
         if (_entryCount > 0)
         {
@@ -202,6 +172,11 @@
     rendered += 4;
 
     // Render the vectors of counts and deltas
+    if ((_psampleCountVec->size() < _entryCount) ||
+            (_psampleDeltaVec->size() < _entryCount))
+    {
+        return false;
+    }
     for (uint32 i = 0; i < _entryCount; i++)
     {
         if (!PVA_FF_AtomUtils::render32(fp, (*_psampleCountVec)[i]))
@@ -241,5 +216,3 @@
         _pparent->recomputeSize();
     }
 }
-
-
diff --git a/fileformats/mp4/composer/src/trackatom.cpp b/fileformats/mp4/composer/src/trackatom.cpp
index 7bc9020..0ad74ba 100644
--- a/fileformats/mp4/composer/src/trackatom.cpp
+++ b/fileformats/mp4/composer/src/trackatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackAtom Class fp the container for a single track in the MPEG-4
     presentation.
@@ -83,16 +82,7 @@
                   profileComp, level),
                   _pmediaAtom);
 
-    if ((uint32) type == MEDIA_TYPE_OBJECT_DESCRIPTOR)  // Mandatory to have tref atom for hint tracks
-    {
-        PV_MP4_FF_NEW(fp->auditCB, PVA_FF_TrackReferenceAtom, (TREF_TYPE_OD), _ptrackReference);
-        _ptrackReference->setParent(this);
-    }
-    else
-    {
-        _ptrackReference = NULL;
-    }
-
+    _ptrackReference = NULL;
     recomputeSize();
 
     _ptrackHeader->setParent(this);
@@ -331,21 +321,6 @@
     return 0;
 }
 
-/*
-// Get the track reference atom if it exists
-const PVA_FF_TrackReferenceAtom&
-PVA_FF_TrackAtom::getTrackReferenceAtom()
-{
-    return NULL;
-}
-
-const PVA_FF_EditAtom&
-PVA_FF_TrackAtom::getEditAtom()
-{
-    return NULL;
-}
-*/
-
 // Create methods for the optional member atoms
 void
 PVA_FF_TrackAtom::createTrackReferenceAtom()
@@ -518,3 +493,15 @@
     _pmediaAtom->updateLastTSEntry(ts);
 
 }
+
+void
+PVA_FF_TrackAtom::SetMaxSampleSize(uint32 aSize)
+{
+    _pmediaAtom->SetMaxSampleSize(aSize);
+}
+
+void
+PVA_FF_TrackAtom::writeMaxSampleSize(MP4_AUTHOR_FF_FILE_IO_WRAP *_afp)
+{
+    _pmediaAtom->writeMaxSampleSize(_afp);
+}
diff --git a/fileformats/mp4/composer/src/trackextendsatom.cpp b/fileformats/mp4/composer/src/trackextendsatom.cpp
index e53377d..f27c4c5 100644
--- a/fileformats/mp4/composer/src/trackextendsatom.cpp
+++ b/fileformats/mp4/composer/src/trackextendsatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/trackfragmentatom.cpp b/fileformats/mp4/composer/src/trackfragmentatom.cpp
index ce6b3ec..905eb14 100644
--- a/fileformats/mp4/composer/src/trackfragmentatom.cpp
+++ b/fileformats/mp4/composer/src/trackfragmentatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/trackfragmentheaderatom.cpp b/fileformats/mp4/composer/src/trackfragmentheaderatom.cpp
index ef8800e..f5aeed8 100644
--- a/fileformats/mp4/composer/src/trackfragmentheaderatom.cpp
+++ b/fileformats/mp4/composer/src/trackfragmentheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/composer/src/trackfragmentrandomaccessatom.cpp b/fileformats/mp4/composer/src/trackfragmentrandomaccessatom.cpp
index 9caea8f..20f8c01 100644
--- a/fileformats/mp4/composer/src/trackfragmentrandomaccessatom.cpp
+++ b/fileformats/mp4/composer/src/trackfragmentrandomaccessatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,14 +78,16 @@
 void
 PVA_FF_TfraAtom::updateMoofOffset(uint32 offset)
 {
-    if (_moofUpdateSample <= _entryCount)
+    if (_pSampleEntries->size() >= _entryCount)
     {
-        for (uint32 ii = _moofUpdateSample; ii <= _entryCount; ii++)
+        if (_moofUpdateSample <= _entryCount)
         {
-            ((*_pSampleEntries)[ii-1].moofOffset) += offset;
+            for (uint32 ii = _moofUpdateSample; ii <= _entryCount; ii++)
+            {
+                ((*_pSampleEntries)[ii-1].moofOffset) += offset;
+            }
+            _moofUpdateSample = _entryCount + 1;
         }
-        _moofUpdateSample = _entryCount + 1;
-
     }
 }
 
diff --git a/fileformats/mp4/composer/src/trackfragmentrunatom.cpp b/fileformats/mp4/composer/src/trackfragmentrunatom.cpp
index 4204cae..d78a276 100644
--- a/fileformats/mp4/composer/src/trackfragmentrunatom.cpp
+++ b/fileformats/mp4/composer/src/trackfragmentrunatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -184,6 +184,10 @@
         (*_psampleEntriesVec)[ _sampleCount - 1].sampleDuration = temp;
     }
 
+    if (_psampleEntriesVec->size() < _sampleCount)
+    {
+        return false;
+    }
     for (uint32 ii = 0; ii < _sampleCount; ii++)
     {
 
diff --git a/fileformats/mp4/composer/src/trackheaderatom.cpp b/fileformats/mp4/composer/src/trackheaderatom.cpp
index ea26e7e..bd1831a 100644
--- a/fileformats/mp4/composer/src/trackheaderatom.cpp
+++ b/fileformats/mp4/composer/src/trackheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackHeaderAtom Class specifies the characteristics of a single MPEG-4
     track.
@@ -34,6 +33,7 @@
 PVA_FF_TrackHeaderAtom::PVA_FF_TrackHeaderAtom(int32 type, uint32 trackID, uint8 version, uint32 flags, uint32 fileAuthoringFlags)
         : PVA_FF_FullAtom(TRACK_HEADER_ATOM, version, flags)
 {
+    OSCL_UNUSED_ARG(fileAuthoringFlags);
 
     _trackID = trackID;
     _mediaType = type;
@@ -203,7 +203,7 @@
      * To ensure that the total track duration includes the duration of the
      * last sample as well, which in our case is same as the last but one.
      */
-    //uint32 totalDuration = getDuration() + _deltaTS;
+
     uint32 totalDuration = getDuration();
     if (!PVA_FF_AtomUtils::render32(fp, totalDuration))
     {
diff --git a/fileformats/mp4/composer/src/trackreferenceatom.cpp b/fileformats/mp4/composer/src/trackreferenceatom.cpp
index f6c06a5..2807764 100644
--- a/fileformats/mp4/composer/src/trackreferenceatom.cpp
+++ b/fileformats/mp4/composer/src/trackreferenceatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackReferenceAtom Class provides a reference from the containing stream
     to another stream in the MPEG-4 presentation.
@@ -27,10 +26,6 @@
 #include "trackreferenceatom.h"
 #include "atomutils.h"
 #include "a_atomdefs.h"
-//#include "pviostream.h"
-
-//extern pvostream & operator<<(pvostream & fp, const PVA_FF_TrackReferenceTypeAtom &a);
-
 
 // Constructor
 PVA_FF_TrackReferenceAtom::PVA_FF_TrackReferenceAtom(uint32 refType)
@@ -84,4 +79,3 @@
         _pparent->recomputeSize();
     }
 }
-
diff --git a/fileformats/mp4/composer/src/trackreferencetypeatom.cpp b/fileformats/mp4/composer/src/trackreferencetypeatom.cpp
index 74ad669..fc7da3c 100644
--- a/fileformats/mp4/composer/src/trackreferencetypeatom.cpp
+++ b/fileformats/mp4/composer/src/trackreferencetypeatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_TrackReferenceTypeAtom Class provides a reference from the containing stream
     to another stream in the MPEG-4 presentation.
@@ -61,7 +60,6 @@
     {
         return (*_trackIDs)[index];
     }
-//  cerr << "ERROR: invalid track reference index" << endl;
     return 0; // ERROR condition
 }
 
diff --git a/fileformats/mp4/composer/src/userdataatom.cpp b/fileformats/mp4/composer/src/userdataatom.cpp
index c31ad2a..b8c1e77 100644
--- a/fileformats/mp4/composer/src/userdataatom.cpp
+++ b/fileformats/mp4/composer/src/userdataatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_UserDataAtom Class fp a container atom for informative user-data.
 */
@@ -94,6 +93,16 @@
             PVA_FF_AssetInfoCopyRightAtom * ptr = (PVA_FF_AssetInfoCopyRightAtom*)(*_pUserDataAtomVec)[i];
             PV_MP4_FF_DELETE(NULL, PVA_FF_AssetInfoCopyRightAtom , ptr);
         }
+        else if (atomPtr->getType() == ASSET_INFO_ALBUM_TITLE_ATOM)
+        {
+            PVA_FF_AssetInfoAlbumAtom * ptr = (PVA_FF_AssetInfoAlbumAtom*)(*_pUserDataAtomVec)[i];
+            PV_MP4_FF_DELETE(NULL, PVA_FF_AssetInfoAlbumAtom , ptr);
+        }
+        else if (atomPtr->getType() == ASSET_INFO_RECORDING_YEAR_ATOM)
+        {
+            PVA_FF_AssetInfoRecordingYearAtom * ptr = (PVA_FF_AssetInfoRecordingYearAtom*)(*_pUserDataAtomVec)[i];
+            PV_MP4_FF_DELETE(NULL, PVA_FF_AssetInfoRecordingYearAtom , ptr);
+        }
 
     }
 
@@ -104,7 +113,6 @@
 void PVA_FF_UserDataAtom::addAtom(PVA_FF_Atom* atom)
 {
     // Adds a new vector to the array of user data atom pointers
-    //_pUserDataAtomVec->push_back(atom);
     _pUserDataAtomVec->push_back(atom);
     atom->setParent(this);
     recomputeSize();
diff --git a/fileformats/mp4/composer/src/videomediaheaderatom.cpp b/fileformats/mp4/composer/src/videomediaheaderatom.cpp
index 96e9868..fdf22b7 100644
--- a/fileformats/mp4/composer/src/videomediaheaderatom.cpp
+++ b/fileformats/mp4/composer/src/videomediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_VideoMediaHeaderAtom Class contains general presentation information,
     independent of coding, about the visual media within the stream.
diff --git a/fileformats/mp4/composer/src/visualsampleentry.cpp b/fileformats/mp4/composer/src/visualsampleentry.cpp
index faf2434..630e1fc 100644
--- a/fileformats/mp4/composer/src/visualsampleentry.cpp
+++ b/fileformats/mp4/composer/src/visualsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
 /*
     This PVA_FF_VisualSampleEntry Class fp used for visual streams.
 */
@@ -27,8 +26,6 @@
 #include "atomutils.h"
 #include "a_atomdefs.h"
 
-//extern pvostream& operator<<(pvostream& fp, const PVA_FF_ESDAtom &a);
-
 
 // Constructor
 PVA_FF_VisualSampleEntry::PVA_FF_VisualSampleEntry(int32 codecType)
@@ -189,4 +186,3 @@
         _pparent->recomputeSize();
     }
 }
-
diff --git a/fileformats/mp4/parser/Android.mk b/fileformats/mp4/parser/Android.mk
index f5d881b..7455752 100644
--- a/fileformats/mp4/parser/Android.mk
+++ b/fileformats/mp4/parser/Android.mk
@@ -3,130 +3,130 @@
 
 LOCAL_SRC_FILES := \
 	src/3gpp_amrdecoderspecificinfo.cpp \
-	src/3gpp_h263decoderspecificinfo.cpp \
-	src/amrdecoderspecificinfo.cpp \
-	src/amrsampleentry.cpp \
-	src/assetinfoatoms.cpp \
-	src/atom.cpp \
-	src/atomutils.cpp \
-	src/audiosampleentry.cpp \
-	src/avcconfigurationbox.cpp \
-	src/avcsampleentry.cpp \
-	src/avcsampledependencytype.cpp \
-	src/avcsampledependency.cpp \
-	src/avcsampletogroupbox.cpp \
-	src/avclayerdescriptionentry.cpp \
-	src/avcsubseqdescriptionentry.cpp \
-	src/basedescriptor.cpp \
-	src/boxrecord.cpp \
-	src/chunkoffsetatom.cpp \
-	src/compositionoffsetatom.cpp \
-	src/copyrightatom.cpp \
-	src/dataentryatom.cpp \
-	src/dataentryurlatom.cpp \
-	src/datainformationatom.cpp \
-	src/datareferenceatom.cpp \
-	src/decoderconfigdescriptor.cpp \
-	src/decoderspecificinfo.cpp \
-	src/editatom.cpp \
-	src/editlistatom.cpp \
-	src/esdatom.cpp \
-	src/esdescriptor.cpp \
-	src/es_id_inc.cpp \
-	src/es_id_ref.cpp \
-	src/expandablebaseclass.cpp \
-	src/filetypeatom.cpp \
-	src/fontrecord.cpp \
-	src/fonttableatom.cpp \
-	src/fullatom.cpp \
-	src/h263decoderspecificinfo.cpp \
-	src/h263sampleentry.cpp \
-	src/handleratom.cpp \
-	src/hintmediaheaderatom.cpp \
-	src/impeg4file.cpp \
-	src/initialobjectdescriptor.cpp \
-	src/itunesilstatom.cpp \
-	src/mediaatom.cpp \
-	src/mediabuffer.cpp \
-	src/mediabuffermanager.cpp \
-	src/mediadataatom.cpp \
-	src/mediaheaderatom.cpp \
-	src/mediainformationatom.cpp \
-	src/mediainformationheaderatom.cpp \
-	src/metadataatom.cpp \
-	src/movieatom.cpp \
-	src/movieheaderatom.cpp \
-	src/mpeg4file.cpp \
-	src/mpeg4mediaheaderatom.cpp \
-	src/mpeg4sampleentryextensions.cpp \
-	src/mpegsampleentry.cpp \
-	src/moviefragmentheaderatom.cpp \
-	src/moviefragmentatom.cpp \
-	src/movieextendsheaderatom.cpp \
-	src/movieextendsatom.cpp \
-	src/mfraoffsetatom.cpp \
-	src/moviefragmentrandomaccess.cpp \
-	src/objectdescriptor.cpp \
-	src/objectdescriptoratom.cpp \
-	src/oma2boxes.cpp \
-	src/pvuserdataatom.cpp \
-	src/sampledescriptionatom.cpp \
-	src/sampleentry.cpp \
-	src/samplesizeatom.cpp \
-	src/sampletableatom.cpp \
-	src/sampletochunkatom.cpp \
-	src/slconfigdescriptor.cpp \
-	src/soundmediaheaderatom.cpp \
-	src/stylerecord.cpp \
-	src/syncsampleatom.cpp \
-	src/textsampleentry.cpp \
-	src/textsamplemodifiers.cpp \
-	src/timetosampleatom.cpp \
-	src/trackatom.cpp \
-	src/trackheaderatom.cpp \
-	src/trackreferenceatom.cpp \
-	src/trackreferencetypeatom.cpp \
-	src/trackfragmentrunatom.cpp \
-	src/trackfragmentheaderatom.cpp \
-	src/trackfragmentatom.cpp \
-	src/trackextendsatom.cpp \
-	src/trackfragmentrandomaccess.cpp \
-	src/userdataatom.cpp \
-	src/videomediaheaderatom.cpp \
-	src/visualsampleentry.cpp \
-	src/paspatom.cpp \
-
+ 	src/3gpp_h263decoderspecificinfo.cpp \
+ 	src/amrdecoderspecificinfo.cpp \
+ 	src/amrsampleentry.cpp \
+ 	src/assetinfoatoms.cpp \
+ 	src/atom.cpp \
+ 	src/audiosampleentry.cpp \
+ 	src/avcconfigurationbox.cpp \
+ 	src/avcsampleentry.cpp \
+ 	src/avcsampledependencytype.cpp \
+ 	src/avcsampledependency.cpp \
+ 	src/avcsampletogroupbox.cpp \
+ 	src/avclayerdescriptionentry.cpp \
+ 	src/avcsubseqdescriptionentry.cpp \
+ 	src/basedescriptor.cpp \
+ 	src/boxrecord.cpp \
+ 	src/chunkoffsetatom.cpp \
+ 	src/compositionoffsetatom.cpp \
+ 	src/copyrightatom.cpp \
+ 	src/dataentryatom.cpp \
+ 	src/dataentryurlatom.cpp \
+ 	src/datainformationatom.cpp \
+ 	src/datareferenceatom.cpp \
+ 	src/decoderconfigdescriptor.cpp \
+ 	src/decoderspecificinfo.cpp \
+ 	src/editatom.cpp \
+ 	src/editlistatom.cpp \
+ 	src/esdatom.cpp \
+ 	src/esdescriptor.cpp \
+ 	src/es_id_inc.cpp \
+ 	src/es_id_ref.cpp \
+ 	src/expandablebaseclass.cpp \
+ 	src/filetypeatom.cpp \
+ 	src/fontrecord.cpp \
+ 	src/fonttableatom.cpp \
+ 	src/fullatom.cpp \
+ 	src/h263decoderspecificinfo.cpp \
+ 	src/h263sampleentry.cpp \
+ 	src/handleratom.cpp \
+ 	src/hintmediaheaderatom.cpp \
+ 	src/impeg4file.cpp \
+ 	src/initialobjectdescriptor.cpp \
+ 	src/itunesilstatom.cpp \
+ 	src/mediaatom.cpp \
+ 	src/mediabuffer.cpp \
+ 	src/mediabuffermanager.cpp \
+ 	src/mediadataatom.cpp \
+ 	src/mediaheaderatom.cpp \
+ 	src/mediainformationatom.cpp \
+ 	src/mediainformationheaderatom.cpp \
+ 	src/metadataatom.cpp \
+ 	src/movieatom.cpp \
+ 	src/movieheaderatom.cpp \
+ 	src/mpeg4file.cpp \
+ 	src/mpeg4mediaheaderatom.cpp \
+ 	src/mpeg4sampleentryextensions.cpp \
+ 	src/mpegsampleentry.cpp \
+ 	src/moviefragmentheaderatom.cpp \
+ 	src/moviefragmentatom.cpp \
+ 	src/movieextendsheaderatom.cpp \
+ 	src/movieextendsatom.cpp \
+ 	src/mfraoffsetatom.cpp \
+ 	src/moviefragmentrandomaccess.cpp \
+ 	src/objectdescriptor.cpp \
+ 	src/objectdescriptoratom.cpp \
+ 	src/oma2boxes.cpp \
+ 	src/pvuserdataatom.cpp \
+ 	src/sampledescriptionatom.cpp \
+ 	src/sampleentry.cpp \
+ 	src/samplesizeatom.cpp \
+ 	src/sampletableatom.cpp \
+ 	src/sampletochunkatom.cpp \
+ 	src/slconfigdescriptor.cpp \
+ 	src/soundmediaheaderatom.cpp \
+ 	src/stylerecord.cpp \
+ 	src/syncsampleatom.cpp \
+ 	src/textsampleentry.cpp \
+ 	src/textsamplemodifiers.cpp \
+ 	src/timetosampleatom.cpp \
+ 	src/trackatom.cpp \
+ 	src/trackheaderatom.cpp \
+ 	src/trackreferenceatom.cpp \
+ 	src/trackreferencetypeatom.cpp \
+ 	src/trackfragmentrunatom.cpp \
+ 	src/trackfragmentheaderatom.cpp \
+ 	src/trackfragmentatom.cpp \
+ 	src/trackextendsatom.cpp \
+ 	src/trackfragmentrandomaccess.cpp \
+ 	src/userdataatom.cpp \
+ 	src/videomediaheaderatom.cpp \
+ 	src/visualsampleentry.cpp \
+ 	src/paspatom.cpp
 
 
 LOCAL_MODULE := libpvmp4ff
 
-LOCAL_CFLAGS := -DOPEN_FILE_ONCE_PER_TRACK  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DOPEN_FILE_ONCE_PER_TRACK $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/mp4/parser/include \
-	$(PV_TOP)//fileformats/mp4/parser/src \
-	$(PV_TOP)//fileformats/mp4/parser/config/opencore \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/mp4/parser/src \
+ 	$(PV_TOP)/fileformats/mp4/parser/include \
+ 	$(PV_TOP)/fileformats/mp4/parser/utils/mp4recognizer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/impeg4file.h \
-	include/isucceedfail.h \
-	include/textsampleentry.h \
-	include/sampleentry.h \
-	include/atom.h \
-	include/atomutils.h \
-	include/parentable.h \
-	include/renderable.h \
-	include/fontrecord.h \
-	include/atomdefs.h \
-	include/decoderspecificinfo.h \
-	include/avcconfigurationbox.h \
-	include/mpeg4sampleentryextensions.h \
-	include/basedescriptor.h \
-	include/expandablebaseclass.h
+ 	include/isucceedfail.h \
+ 	include/textsampleentry.h \
+ 	include/sampleentry.h \
+ 	include/atom.h \
+ 	include/parentable.h \
+ 	include/renderable.h \
+ 	include/fontrecord.h \
+ 	include/h263decoderspecificinfo.h \
+ 	include/decoderspecificinfo.h \
+ 	include/basedescriptor.h \
+ 	include/expandablebaseclass.h \
+ 	include/../config/opencore/pv_mp4ffparser_config.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/mp4/parser/build_opencore/make/local.mk b/fileformats/mp4/parser/build_opencore/make/local.mk
new file mode 100644
index 0000000..6ab0fd7
--- /dev/null
+++ b/fileformats/mp4/parser/build_opencore/make/local.mk
@@ -0,0 +1,130 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4ff
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+XCPPFLAGS += -DOPEN_FILE_ONCE_PER_TRACK  
+
+
+XINCDIRS := ../../utils/mp4recognizer/include
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := 3gpp_amrdecoderspecificinfo.cpp \
+	3gpp_h263decoderspecificinfo.cpp \
+	amrdecoderspecificinfo.cpp \
+	amrsampleentry.cpp \
+	assetinfoatoms.cpp \
+	atom.cpp \
+	audiosampleentry.cpp \
+	avcconfigurationbox.cpp \
+        avcsampleentry.cpp \
+	avcsampledependencytype.cpp \
+	avcsampledependency.cpp \
+	avcsampletogroupbox.cpp \
+	avclayerdescriptionentry.cpp \
+	avcsubseqdescriptionentry.cpp \
+	basedescriptor.cpp \
+	boxrecord.cpp \
+	chunkoffsetatom.cpp \
+	compositionoffsetatom.cpp \
+	copyrightatom.cpp \
+	dataentryatom.cpp \
+	dataentryurlatom.cpp \
+	datainformationatom.cpp \
+	datareferenceatom.cpp \
+	decoderconfigdescriptor.cpp \
+	decoderspecificinfo.cpp \
+	editatom.cpp \
+	editlistatom.cpp \
+	esdatom.cpp \
+	esdescriptor.cpp \
+	es_id_inc.cpp \
+	es_id_ref.cpp \
+	expandablebaseclass.cpp \
+	filetypeatom.cpp \
+	fontrecord.cpp \
+	fonttableatom.cpp \
+	fullatom.cpp \
+	h263decoderspecificinfo.cpp \
+	h263sampleentry.cpp \
+	handleratom.cpp \
+	hintmediaheaderatom.cpp \
+	impeg4file.cpp \
+	initialobjectdescriptor.cpp \
+	itunesilstatom.cpp \
+	mediaatom.cpp \
+	mediabuffer.cpp \
+	mediabuffermanager.cpp \
+	mediadataatom.cpp \
+	mediaheaderatom.cpp \
+	mediainformationatom.cpp \
+	mediainformationheaderatom.cpp \
+	metadataatom.cpp \
+	movieatom.cpp \
+	movieheaderatom.cpp \
+	mpeg4file.cpp \
+	mpeg4mediaheaderatom.cpp \
+	mpeg4sampleentryextensions.cpp \
+	mpegsampleentry.cpp \
+	moviefragmentheaderatom.cpp \
+	moviefragmentatom.cpp \
+	movieextendsheaderatom.cpp \
+	movieextendsatom.cpp \
+	mfraoffsetatom.cpp \
+	moviefragmentrandomaccess.cpp \
+	objectdescriptor.cpp \
+	objectdescriptoratom.cpp \
+	oma2boxes.cpp \
+	pvuserdataatom.cpp \
+	sampledescriptionatom.cpp \
+	sampleentry.cpp \
+	samplesizeatom.cpp \
+	sampletableatom.cpp \
+	sampletochunkatom.cpp \
+	slconfigdescriptor.cpp \
+	soundmediaheaderatom.cpp \
+	stylerecord.cpp \
+	syncsampleatom.cpp \
+	textsampleentry.cpp \
+	textsamplemodifiers.cpp \
+	timetosampleatom.cpp \
+	trackatom.cpp \
+	trackheaderatom.cpp \
+	trackreferenceatom.cpp \
+	trackreferencetypeatom.cpp \
+	trackfragmentrunatom.cpp \
+	trackfragmentheaderatom.cpp \
+	trackfragmentatom.cpp \
+	trackextendsatom.cpp \
+	trackfragmentrandomaccess.cpp \
+	userdataatom.cpp \
+	videomediaheaderatom.cpp \
+	visualsampleentry.cpp \
+	paspatom.cpp \
+
+HDRS := impeg4file.h \
+	isucceedfail.h \
+        textsampleentry.h \
+        sampleentry.h \
+        atom.h \
+        parentable.h \
+        renderable.h \
+        fontrecord.h \
+        h263decoderspecificinfo.h \
+        decoderspecificinfo.h \
+        basedescriptor.h \
+        expandablebaseclass.h \
+        ../config/opencore/pv_mp4ffparser_config.h
+
+
+
+include $(MK)/library.mk
diff --git a/fileformats/mp4/parser/build_opencore/make/makefile b/fileformats/mp4/parser/build_opencore/make/makefile
deleted file mode 100644
index fb48742..0000000
--- a/fileformats/mp4/parser/build_opencore/make/makefile
+++ /dev/null
@@ -1,162 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4ff
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-XCPPFLAGS += -DOPEN_FILE_ONCE_PER_TRACK  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-XINCDIRS = -I ../../config/opencore
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS =  3gpp_amrdecoderspecificinfo.cpp \
-	3gpp_h263decoderspecificinfo.cpp \
-	amrdecoderspecificinfo.cpp \
-	amrsampleentry.cpp \
-	assetinfoatoms.cpp \
-	atom.cpp \
-	atomutils.cpp \
-	audiosampleentry.cpp \
-	avcconfigurationbox.cpp \
-        avcsampleentry.cpp \
-	avcsampledependencytype.cpp \
-	avcsampledependency.cpp \
-	avcsampletogroupbox.cpp \
-	avclayerdescriptionentry.cpp \
-	avcsubseqdescriptionentry.cpp \
-	basedescriptor.cpp \
-	boxrecord.cpp \
-	chunkoffsetatom.cpp \
-	compositionoffsetatom.cpp \
-	copyrightatom.cpp \
-	dataentryatom.cpp \
-	dataentryurlatom.cpp \
-	datainformationatom.cpp \
-	datareferenceatom.cpp \
-	decoderconfigdescriptor.cpp \
-	decoderspecificinfo.cpp \
-	editatom.cpp \
-	editlistatom.cpp \
-	esdatom.cpp \
-	esdescriptor.cpp \
-	es_id_inc.cpp \
-	es_id_ref.cpp \
-	expandablebaseclass.cpp \
-	filetypeatom.cpp \
-	fontrecord.cpp \
-	fonttableatom.cpp \
-	fullatom.cpp \
-	h263decoderspecificinfo.cpp \
-	h263sampleentry.cpp \
-	handleratom.cpp \
-	hintmediaheaderatom.cpp \
-	impeg4file.cpp \
-	initialobjectdescriptor.cpp \
-	itunesilstatom.cpp \
-	mediaatom.cpp \
-	mediabuffer.cpp \
-	mediabuffermanager.cpp \
-	mediadataatom.cpp \
-	mediaheaderatom.cpp \
-	mediainformationatom.cpp \
-	mediainformationheaderatom.cpp \
-	metadataatom.cpp \
-	movieatom.cpp \
-	movieheaderatom.cpp \
-	mpeg4file.cpp \
-	mpeg4mediaheaderatom.cpp \
-	mpeg4sampleentryextensions.cpp \
-	mpegsampleentry.cpp \
-	moviefragmentheaderatom.cpp \
-	moviefragmentatom.cpp \
-	movieextendsheaderatom.cpp \
-	movieextendsatom.cpp \
-	mfraoffsetatom.cpp \
-	moviefragmentrandomaccess.cpp \
-	objectdescriptor.cpp \
-	objectdescriptoratom.cpp \
-	oma2boxes.cpp \
-	pvuserdataatom.cpp \
-	sampledescriptionatom.cpp \
-	sampleentry.cpp \
-	samplesizeatom.cpp \
-	sampletableatom.cpp \
-	sampletochunkatom.cpp \
-	slconfigdescriptor.cpp \
-	soundmediaheaderatom.cpp \
-	stylerecord.cpp \
-	syncsampleatom.cpp \
-	textsampleentry.cpp \
-	textsamplemodifiers.cpp \
-	timetosampleatom.cpp \
-	trackatom.cpp \
-	trackheaderatom.cpp \
-	trackreferenceatom.cpp \
-	trackreferencetypeatom.cpp \
-	trackfragmentrunatom.cpp \
-	trackfragmentheaderatom.cpp \
-	trackfragmentatom.cpp \
-	trackextendsatom.cpp \
-	trackfragmentrandomaccess.cpp \
-	userdataatom.cpp \
-	videomediaheaderatom.cpp \
-	visualsampleentry.cpp \
-	paspatom.cpp \
-
-HDRS =  impeg4file.h \
-	isucceedfail.h \
-        textsampleentry.h \
-        sampleentry.h \
-        atom.h \
-        atomutils.h \
-        parentable.h \
-        renderable.h \
-        fontrecord.h \
-        atomdefs.h \
-        decoderspecificinfo.h \
-        avcconfigurationbox.h \
-        mpeg4sampleentryextensions.h \
-        basedescriptor.h \
-        expandablebaseclass.h   
-	
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/fileformats/mp4/parser/config/opencore/pv_mp4ffparser_config.h b/fileformats/mp4/parser/config/opencore/pv_mp4ffparser_config.h
index bdc6dd3..e5dfa5f 100644
--- a/fileformats/mp4/parser/config/opencore/pv_mp4ffparser_config.h
+++ b/fileformats/mp4/parser/config/opencore/pv_mp4ffparser_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,12 +24,33 @@
 #ifndef PV_MP4FFPARSER_CONFIG_H_INCLUDED
 #define PV_MP4FFPARSER_CONFIG_H_INCLUDED
 
+#ifndef PVMF_MP4_FF_PARSER_HAS_IMOTION_SUPPORT
+#define PVMF_MP4_FF_PARSER_HAS_IMOTION_SUPPORT 0
+#endif
 
+#ifndef PVMF_MP4_FF_PARSER_HAS_IMOTION_SUPPORT
+#define PVMF_MP4_FF_PARSER_HAS_ITUNE_SUPPORT 0
+#endif
 
+#ifndef PVMF_MP4_FF_HAS_OMA2_DRM_SUPPORT
+#define PVMF_MP4_FF_HAS_OMA2_DRM_SUPPORT 0
+#endif
 
+#ifndef PVMF_MP4_FF_PARSER_HAS_TIMED_TEXT_SUPPORT
+#define PVMF_MP4_FF_PARSER_HAS_TIMED_TEXT_SUPPORT 0
+#endif
 
+#ifndef PVMF_MP4_FF_PARSER_HAS_MOOF_SUPPORT
+#define PVMF_MP4_FF_PARSER_HAS_MOOF_SUPPORT 0
+#endif
 
+#ifndef PVMF_MP4_FF_PARSER_HAS_BFRAME_SUPPORT
+#define PVMF_MP4_FF_PARSER_HAS_BFRAME_SUPPORT 0
+#endif
 
-
+#ifndef PV_MP4_FF_PARSER_HAS_PPACK_SUPPORT
+#define PV_MP4_FF_PARSER_HAS_PPACK_SUPPORT 0
+#endif
 
 #endif // PV_MP4FFPARSER_CONFIG_H_INCLUDED
+
diff --git a/fileformats/mp4/parser/include/3gpp_amrdecoderspecificinfo.h b/fileformats/mp4/parser/include/3gpp_amrdecoderspecificinfo.h
index 55287a8..c7343f2 100644
--- a/fileformats/mp4/parser/include/3gpp_amrdecoderspecificinfo.h
+++ b/fileformats/mp4/parser/include/3gpp_amrdecoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/3gpp_h263decoderspecificinfo.h b/fileformats/mp4/parser/include/3gpp_h263decoderspecificinfo.h
index 0f687db..0ac8a40 100644
--- a/fileformats/mp4/parser/include/3gpp_h263decoderspecificinfo.h
+++ b/fileformats/mp4/parser/include/3gpp_h263decoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/amrdecoderspecificinfo.h b/fileformats/mp4/parser/include/amrdecoderspecificinfo.h
index dcf591b..3b8ad20 100644
--- a/fileformats/mp4/parser/include/amrdecoderspecificinfo.h
+++ b/fileformats/mp4/parser/include/amrdecoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/amrsampleentry.h b/fileformats/mp4/parser/include/amrsampleentry.h
index 865b8c1..3ef5647 100644
--- a/fileformats/mp4/parser/include/amrsampleentry.h
+++ b/fileformats/mp4/parser/include/amrsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/assetinfoatoms.h b/fileformats/mp4/parser/include/assetinfoatoms.h
index e7571be..44a5301 100644
--- a/fileformats/mp4/parser/include/assetinfoatoms.h
+++ b/fileformats/mp4/parser/include/assetinfoatoms.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,17 +37,14 @@
 #include "atomdefs.h"
 #endif
 
-
-#define BYTE_ORDER_MASK 0xFEFF
-
-class AssetInfoBaseParser
+class AssestInfoBaseParser
 {
     public:
-        AssetInfoBaseParser(MP4_FF_FILE *fp,
-                            uint32 size,
-                            uint32 sizeofDataFieldBeforeString = 2);
+        AssestInfoBaseParser(MP4_FF_FILE *fp,
+                             uint32 size,
+                             uint32 sizeofDataFieldBeforeString = 2);
 
-        virtual ~AssetInfoBaseParser() {};
+        virtual ~AssestInfoBaseParser() {};
 
         uint16 getLangCode() const
         {
@@ -101,10 +98,10 @@
 
     private:
         OSCL_wHeapString<OsclMemAllocator> _defaultTitle;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
-typedef Oscl_Vector<AssetInfoBaseParser*, OsclMemAllocator> assetInfoBaseParserVecType;
+typedef Oscl_Vector<AssestInfoBaseParser*, OsclMemAllocator> assestInfoBaseParserVecType;
 
 class AssetInfoDescAtom : public FullAtom
 {
@@ -133,7 +130,7 @@
 
     private:
         OSCL_wHeapString<OsclMemAllocator> _defaultDesc;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
 class AssetInfoPerformerAtom : public FullAtom
@@ -162,7 +159,7 @@
 
     private:
         OSCL_wHeapString<OsclMemAllocator> _defaultPerf;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
 class AssetInfoAuthorAtom : public FullAtom
@@ -191,7 +188,7 @@
 
     private:
         OSCL_wHeapString<OsclMemAllocator> _defaultAuthor;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
 class AssetInfoGenreAtom : public FullAtom
@@ -220,7 +217,7 @@
 
     private:
         OSCL_wHeapString<OsclMemAllocator> _defaultGenre;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
 class AssetInfoRatingAtom : public FullAtom
@@ -261,7 +258,7 @@
         OSCL_wHeapString<OsclMemAllocator> _defaultRating;
         uint32				  _ratingEntity;
         uint32				  _ratingCriteria;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
 class AssetInfoClassificationAtom : public FullAtom
@@ -300,13 +297,13 @@
         OSCL_wHeapString<OsclMemAllocator> _defaultClassification;
         uint32				  _classificationEntity;
         uint16				  _classificationTable;
-        AssetInfoBaseParser* _pAssetInfoBaseParser;
+        AssestInfoBaseParser* _pAssetInfoBaseParser;
 };
 
-class AssetInfoKeyWord
+class AssestInfoKeyWord
 {
     public:
-        AssetInfoKeyWord(MP4_FF_FILE *fp);
+        AssestInfoKeyWord(MP4_FF_FILE *fp);
         OSCL_wHeapString<OsclMemAllocator> _defaultKeyWord;
         MP4FFParserOriginalCharEnc _charType;
         uint32 count;
@@ -342,7 +339,7 @@
     private:
         uint16				          _langCode;
         uint8						  _keyWordCount;
-        Oscl_Vector<AssetInfoKeyWord *, OsclMemAllocator> *_pAssetInfoKeyWordVec;
+        Oscl_Vector<AssestInfoKeyWord *, OsclMemAllocator> *_pAssetInfoKeyWordVec;
         OSCL_wHeapString<OsclMemAllocator> _defaultKeyWord;
 };
 
diff --git a/fileformats/mp4/parser/include/atom.h b/fileformats/mp4/parser/include/atom.h
index cbac0f1..dfcf00a 100644
--- a/fileformats/mp4/parser/include/atom.h
+++ b/fileformats/mp4/parser/include/atom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/atomdefs.h b/fileformats/mp4/parser/include/atomdefs.h
deleted file mode 100644
index 6e28a45..0000000
--- a/fileformats/mp4/parser/include/atomdefs.h
+++ /dev/null
@@ -1,408 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef ATOMDEFS_H_INCLUDED
-#define ATOMDEFS_H_INCLUDED
-
-#ifndef PV_MP4FFPARSER_CONFIG_H_INCLUDED
-#include "pv_mp4ffparser_config.h"
-#endif
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef OSCL_FILE_IO_H_INCLUDED
-#include "oscl_file_io.h"
-#endif
-
-#ifndef OSCL_MEM__H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
-#include "oscl_string_containers.h"
-#endif
-
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-
-#ifndef OSCL_INT64_UTILS_H_INCLUDED
-#include "oscl_int64_utils.h"
-#endif
-static const int32 MEDIA_DATA_IN_MEMORY = 0;
-static const int32 MEDIA_DATA_ON_DISK = 1;
-
-static const uint32 DEFAULT_PRESENTATION_TIMESCALE = 1000; // For milliseconds
-static const uint32 INITIAL_TRACK_ID = 1; // Initial track ID for first track added to this movie
-
-static const int32 MEDIA_TYPE_UNKNOWN = 10;
-
-// MediaInformationHeaderAtom types
-static const int32 MEDIA_INFORMATION_HEADER_TYPE_AUDIO = 0;
-static const int32 MEDIA_INFORMATION_HEADER_TYPE_VISUAL = 1;
-static const int32 MEDIA_INFORMATION_HEADER_TYPE_HINT = 2;
-static const int32 MEDIA_INFORMATION_HEADER_TYPE_MPEG4 = 3;
-
-static const uint32 UNKNOWN_ATOM = 0;
-static const int32 UNKNOWN_DESCRIPTOR = 1;
-static const int32 UNKNOWN_HANDLER = 2;
-
-static const int32 CODING_TYPE_I = 0;
-static const int32 CODING_TYPE_P = 1;
-static const int32 CODING_TYPE_B = 2;
-static const int32 CODING_TYPE_SPRITE = 3;
-
-// Mpeg-4 file types
-static const int32 FILE_TYPE_AUDIO = 1;
-static const int32 FILE_TYPE_VIDEO = 2;
-static const int32 FILE_TYPE_AUDIO_VIDEO = 3; // Logical ORing of the two
-static const int32 FILE_TYPE_STILL_IMAGE = 4;
-static const int32 FILE_TYPE_STILL_IMAGE_AUDIO = 5; // Logical ORing of the two
-static const int32 FILE_TYPE_TEXT = 8;
-static const int32 FILE_TYPE_TEXT_AUDIO = 9;
-static const int32 FILE_TYPE_TEXT_VIDEO = 10;
-static const int32 FILE_TYPE_TEXT_AUDIO_VIDEO = 11; // Logical ORing
-
-
-// Scalability settings on the Mpeg4 file
-static const int32 STREAM_SCALABILITY_NONE = 0;
-static const int32 STREAM_SCALABILITY_TEMPORAL = 1;
-static const int32 STREAM_SCALABILITY_SPATIAL = 2;
-static const int32 STREAM_SCALABILITY_BOTH = 3; // Logical ORing of the two
-
-#define FourCharConstToUint32(a, b, c, d) ( (uint32(a) << 24) | (uint32(b) << 16) | (uint32(c) << 8) | uint32(d) )
-
-const uint32 PACKETVIDEO_FOURCC = FourCharConstToUint32('p', 'v', 'm', 'm');
-const uint32 PVUSER_DATA_ATOM = FourCharConstToUint32('p', 'v', 'm', 'm');
-
-const uint32    FILE_TYPE_ATOM = FourCharConstToUint32('f', 't', 'y', 'p');
-
-const uint32    UUID_ATOM = FourCharConstToUint32('u', 'u', 'i', 'd');
-
-const uint32    MOVIE_ATOM = FourCharConstToUint32('m', 'o', 'o', 'v');
-const uint32    MOVIE_HEADER_ATOM = FourCharConstToUint32('m', 'v', 'h', 'd');
-const uint32    TRACK_ATOM = FourCharConstToUint32('t', 'r', 'a', 'k');
-const uint32    ESD_ATOM = FourCharConstToUint32('e', 's', 'd', 's');
-const uint32    TRACK_HEADER_ATOM = FourCharConstToUint32('t', 'k', 'h', 'd');
-const uint32    TRACK_REFERENCE_ATOM = FourCharConstToUint32('t', 'r', 'e', 'f');
-
-//movie fragments
-const uint32    MOVIE_FRAGMENT_ATOM = FourCharConstToUint32('m', 'o', 'o', 'f');
-const uint32	MOVIE_EXTENDS_ATOM = FourCharConstToUint32('m', 'v', 'e', 'x');
-const uint32	MOVIE_EXTENDS_HEADER_ATOM = FourCharConstToUint32('m', 'e', 'h', 'd');
-const uint32	TRACK_EXTENDS_ATOM = FourCharConstToUint32('t', 'r', 'e', 'x');
-const uint32	MOVIE_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('m', 'f', 'h', 'd');
-const uint32	TRACK_FRAGMENT_ATOM = FourCharConstToUint32('t', 'r', 'a', 'f');
-const uint32	TRACK_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('t', 'f', 'h', 'd');
-const uint32	TRACK_FRAGMENT_RUN_ATOM = FourCharConstToUint32('t', 'r', 'u', 'n');
-const uint32	MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('m', 'f', 'r', 'a');
-const uint32	MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM = FourCharConstToUint32('m', 'f', 'r', 'o');
-const uint32	TRACK_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('t', 'f', 'r', 'a');
-
-const uint32    HINT_TRACK_REFERENCE_TYPE = FourCharConstToUint32('h', 'i', 'n', 't');
-const uint32    DPND_TRACK_REFERENCE_TYPE = FourCharConstToUint32('d', 'p', 'n', 'd');
-const uint32    IPIR_TRACK_REFERENCE_TYPE = FourCharConstToUint32('i', 'p', 'i', 'r');
-const uint32    MPOD_TRACK_REFERENCE_TYPE = FourCharConstToUint32('m', 'p', 'o', 'd');
-const uint32    SYNC_TRACK_REFERENCE_TYPE = FourCharConstToUint32('s', 'y', 'n', 'c');
-
-const uint32    MEDIA_ATOM = FourCharConstToUint32('m', 'd', 'i', 'a');
-const uint32    EDIT_ATOM = FourCharConstToUint32('e', 'd', 't', 's');
-const uint32    EDIT_LIST_ATOM = FourCharConstToUint32('e', 'l', 's', 't');
-const uint32    MEDIA_HEADER_ATOM = FourCharConstToUint32('m', 'd', 'h', 'd');
-const uint32    HANDLER_ATOM = FourCharConstToUint32('h', 'd', 'l', 'r');
-const uint32    MEDIA_INFORMATION_ATOM = FourCharConstToUint32('m', 'i', 'n', 'f');
-const uint32    VIDEO_MEDIA_HEADER_ATOM = FourCharConstToUint32('v', 'm', 'h', 'd');
-const uint32    SOUND_MEDIA_HEADER_ATOM = FourCharConstToUint32('s', 'm', 'h', 'd');
-const uint32    HINT_MEDIA_HEADER_ATOM = FourCharConstToUint32('h', 'm', 'h', 'd');
-const uint32    MPEG4_MEDIA_HEADER_ATOM = FourCharConstToUint32('n', 'm', 'h', 'd');
-const uint32    DATA_INFORMATION_ATOM = FourCharConstToUint32('d', 'i', 'n', 'f');
-const uint32    DATA_REFERENCE_ATOM = FourCharConstToUint32('d', 'r', 'e', 'f');
-const uint32    DATA_ENTRY_URL_ATOM = FourCharConstToUint32('u', 'r', 'l', ' ');
-const uint32    DATA_ENTRY_URN_ATOM = FourCharConstToUint32('u', 'r', 'n', ' ');
-const uint32    SAMPLE_TABLE_ATOM = FourCharConstToUint32('s', 't', 'b', 'l');
-const uint32    TIME_TO_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 't', 's');
-const uint32    COMPOSITION_OFFSET_ATOM = FourCharConstToUint32('c', 't', 't', 's');
-const uint32    SAMPLE_DESCRIPTION_ATOM = FourCharConstToUint32('s', 't', 's', 'd');
-const uint32    SAMPLE_SIZE_ATOM = FourCharConstToUint32('s', 't', 's', 'z');
-const uint32    SAMPLE_TO_CHUNK_ATOM = FourCharConstToUint32('s', 't', 's', 'c');
-const uint32    CHUNK_OFFSET_ATOM = FourCharConstToUint32('s', 't', 'c', 'o');
-const uint32    SYNC_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 's', 's');
-const uint32    SHADOW_SYNC_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 's', 'h');
-const uint32    DEGRADATION_PRIORITY_ATOM = FourCharConstToUint32('s', 't', 'd', 'p');
-const uint32    OBJECT_DESCRIPTOR_ATOM = FourCharConstToUint32('i', 'o', 'd', 's');
-const uint32    MEDIA_DATA_ATOM = FourCharConstToUint32('m', 'd', 'a', 't');
-const uint32    FREE_SPACE_ATOM = FourCharConstToUint32('f', 'r', 'e', 'e');
-const uint32    SKIP_ATOM = FourCharConstToUint32('s', 'k', 'i', 'p');
-const uint32    USER_DATA_ATOM = FourCharConstToUint32('u', 'd', 't', 'a');
-const uint32    MEDIA_TYPE_AUDIO = FourCharConstToUint32('s', 'o', 'u', 'n');
-const uint32    MEDIA_TYPE_VISUAL = FourCharConstToUint32('v', 'i', 'd', 'e');
-const uint32    MEDIA_TYPE_HINT = FourCharConstToUint32('h', 'i', 'n', 't');
-const uint32    MEDIA_TYPE_OBJECT_DESCRIPTOR = FourCharConstToUint32('o', 'd', 's', 'm');
-const uint32    MEDIA_TYPE_CLOCK_REFERENCE = FourCharConstToUint32('c', 'r', 's', 'm');
-const uint32    MEDIA_TYPE_SCENE_DESCRIPTION = FourCharConstToUint32('s', 'd', 's', 'm');
-const uint32    MEDIA_TYPE_MPEG7 = FourCharConstToUint32('m', '7', 's', 'm');
-const uint32    MEDIA_TYPE_OBJECT_CONTENT_INFO = FourCharConstToUint32('o', 'c', 's', 'm');
-const uint32    MEDIA_TYPE_IPMP = FourCharConstToUint32('i', 'p', 's', 'm');
-const uint32    MEDIA_TYPE_MPEG_J = FourCharConstToUint32('m', 'j', 's', 'm');
-const uint32    MEDIA_TYPE_SCALABILITY = FourCharConstToUint32('p', 'v', 's', 'c');
-const uint32    MEDIA_TYPE_TEXT = FourCharConstToUint32('t', 'e', 'x', 't');
-
-const uint32    MPEG_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 's');
-const uint32    AUDIO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'a');
-const uint32    VIDEO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'v');
-
-const uint32    AMR_SAMPLE_ENTRY_ATOM = FourCharConstToUint32('s', 'a', 'm', 'r');
-const uint32    AMRWB_SAMPLE_ENTRY_ATOM = FourCharConstToUint32('s', 'a', 'w', 'b');
-const uint32    H263_SAMPLE_ENTRY_ATOM = FourCharConstToUint32('s', '2', '6', '3');
-
-const uint32    AMR_SPECIFIC_ATOM = FourCharConstToUint32('d', 'a', 'm', 'r');
-const uint32    H263_SPECIFIC_ATOM = FourCharConstToUint32('d', '2', '6', '3');
-const uint32    H263_BITRATE_ATOM = FourCharConstToUint32('b', 'i', 't', 'r');
-
-
-const uint32    COPYRIGHT_ATOM = FourCharConstToUint32('c', 'p', 'r', 't');
-
-const uint32    NULL_MEDIA_HEADER_ATOM = FourCharConstToUint32('n', 'm', 'h', 'd');
-const uint32    FONT_TABLE_ATOM = FourCharConstToUint32('f', 't', 'a', 'b');
-const uint32    TEXT_SAMPLE_ENTRY = FourCharConstToUint32('t', 'x', '3', 'g');
-
-// Part of udta at file level
-const uint32    PV_CONTENT_TYPE_ATOM = FourCharConstToUint32('p', 'v', 'c', 't');
-
-const uint32    ASSET_INFO_TITLE_ATOM = FourCharConstToUint32('t', 'i', 't', 'l');
-const uint32    ASSET_INFO_DESCP_ATOM = FourCharConstToUint32('d', 's', 'c', 'p');
-const uint32    ASSET_INFO_PERF_ATOM = FourCharConstToUint32('p', 'e', 'r', 'f');
-const uint32    ASSET_INFO_AUTHOR_ATOM = FourCharConstToUint32('a', 'u', 't', 'h');
-const uint32    ASSET_INFO_GENRE_ATOM = FourCharConstToUint32('g', 'n', 'r', 'e');
-const uint32    ASSET_INFO_RATING_ATOM = FourCharConstToUint32('r', 't', 'n', 'g');
-const uint32    ASSET_INFO_CLSF_ATOM = FourCharConstToUint32('c', 'l', 's', 'f');
-const uint32    ASSET_INFO_KEYWORD_ATOM = FourCharConstToUint32('k', 'y', 'w', 'd');
-const uint32    ASSET_INFO_LOCATION_ATOM = FourCharConstToUint32('l', 'o', 'c', 'i');
-const uint32    ASSET_INFO_ALBUM_ATOM = FourCharConstToUint32('a', 'l', 'b', 'm');
-const uint32    ASSET_INFO_YRRC_ATOM = FourCharConstToUint32('y', 'r', 'r', 'c');
-
-//AVC related atoms
-const uint32    AVC_SAMPLE_ENTRY = FourCharConstToUint32('a', 'v', 'c', '1');
-const uint32    AVC_CONFIGURATION_BOX = FourCharConstToUint32('a', 'v', 'c', 'C');
-const uint32    AVC_SAMPLE_DEPENDENCY_TYPE_BOX = FourCharConstToUint32('s', 'd', 't', 'p');
-const uint32    AVC_SAMPLE_TO_GROUP_BOX = FourCharConstToUint32('s', 'b', 'g', 'p');
-const uint32    AVC_SAMPLE_GROUP_DESCRIPTION_BOX = FourCharConstToUint32('s', 'g', 'p', 'd');
-const uint32    AVC_SUBSEQUENCE_DESCRIPTION_BOX = FourCharConstToUint32('a', 'v', 's', 's');
-const uint32    AVC_LAYER_DESCRIPTION_BOX = FourCharConstToUint32('a', 'v', 'l', 'l');
-const uint32    AVC_SAMPLE_DEPENDENCY_BOX = FourCharConstToUint32('s', 'd', 'e', 'p');
-
-const uint32    MPEG4_BITRATE_BOX = FourCharConstToUint32('b', 't', 'r', 't');
-const uint32    MPEG4_EXTENSION_DESCRIPTORS_BOX = FourCharConstToUint32('m', '4', 'd', 's');
-
-//Pixel Aspect Ratio
-const uint32  PIXELASPECTRATIO_BOX = FourCharConstToUint32('p', 'a', 's', 'p');
-
-
-const uint32    WMF_BRAND = FourCharConstToUint32('w', 'm', 'f', ' ');
-const uint32    BRAND_3GPP4 = FourCharConstToUint32('3', 'g', 'p', '4');
-const uint32    MOBILE_MP4 = FourCharConstToUint32('m', 'm', 'p', '4');
-const uint32    BRAND_3GPP5 = FourCharConstToUint32('3', 'g', 'p', '5');
-const uint32    BRAND_3GP6 = FourCharConstToUint32('3', 'g', 'p', '6');
-const uint32    BRAND_3GR6 = FourCharConstToUint32('3', 'g', 'r', '6');
-const uint32    BRAND_MP41 = FourCharConstToUint32('m', 'p', '4', '1');
-const uint32    BRAND_MP42 = FourCharConstToUint32('m', 'p', '4', '2');
-const uint32    BRAND_ISOM = FourCharConstToUint32('i', 's', 'o', 'm');
-
-
-/* OMA2 DRM Atoms */
-const uint32    ENCRYPTED_AUDIO_SAMPLE_ENTRY = FourCharConstToUint32('e', 'n', 'c', 'a');
-const uint32    ENCRYPTED_VIDEO_SAMPLE_ENTRY = FourCharConstToUint32('e', 'n', 'c', 'v');
-const uint32    ENCRYPTED_TEXT_SAMPLE_ENTRY = FourCharConstToUint32('e', 'n', 'c', 't');
-
-const uint32    PROTECTION_SCHEME_INFO_BOX = FourCharConstToUint32('s', 'i', 'n', 'f');
-const uint32    ORIGINAL_FORMAT_BOX = FourCharConstToUint32('f', 'r', 'm', 'a');
-const uint32    SCHEME_TYPE_BOX = FourCharConstToUint32('s', 'c', 'h', 'm');
-const uint32    SCHEME_INFORMATION_BOX = FourCharConstToUint32('s', 'c', 'h', 'i');
-const uint32    MUTABLE_DRM_INFORMATION = FourCharConstToUint32('m', 'd', 'r', 'i');
-const uint32    OMADRM_TRANSACTION_TRACKING_BOX = FourCharConstToUint32('o', 'd', 't', 't');
-const uint32    OMADRM_RIGHTS_OBJECT_BOX = FourCharConstToUint32('o', 'd', 'r', 'b');
-const uint32    OMADRM_KMS_BOX = FourCharConstToUint32('o', 'd', 'k', 'm');
-// Text Sample Modifier Atoms
-const uint32    TEXT_STYLE_BOX = FourCharConstToUint32('s', 't', 'y', 'l');
-const uint32    TEXT_HIGHLIGHT_BOX = FourCharConstToUint32('h', 'l', 'i', 't');
-const uint32    TEXT_HILIGHT_COLOR_BOX = FourCharConstToUint32('h', 'c', 'l', 'r');
-const uint32    TEXT_KARAOKE_BOX = FourCharConstToUint32('k', 'r', 'o', 'k');
-const uint32    TEXT_SCROLL_DELAY_BOX = FourCharConstToUint32('d', 'l', 'a', 'y');
-const uint32    TEXT_HYPER_TEXT_BOX = FourCharConstToUint32('h', 'r', 'e', 'f');
-const uint32    TEXT_OVER_RIDE_BOX = FourCharConstToUint32('t', 'b', 'o', 'x');
-const uint32    TEXT_BLINK_BOX = FourCharConstToUint32('b', 'l', 'n', 'k');
-
-
-
-//itunes metadata atoms - parsing support yet to be added
-const uint32	ITUNES_ALBUM_ATOM  = FourCharConstToUint32('©', 'a', 'l', 'b');
-const uint32	ITUNES_ARTIST_ATOM = FourCharConstToUint32('©', 'a', 'r', 't');
-const uint32	ITUNES_ALBUM_ARTIST_ATOM = FourCharConstToUint32('©', 'A', 'R', 'T');
-const uint32	ITUNES_COMMENT_ATOM = FourCharConstToUint32('©', 'c', 'm', 't');
-const uint32	ITUNES_YEAR_ATOM = FourCharConstToUint32('©', 'd', 'a', 'y');
-const uint32	ITUNES_TITLE_ATOM = FourCharConstToUint32('©', 'n', 'a', 'm');
-const uint32	ITUNES_GENRE1_ATOM = FourCharConstToUint32('©', 'g', 'e', 'n');
-const uint32	ITUNES_GENRE2_ATOM = FourCharConstToUint32('g', 'n', 'r', 'e');
-const uint32	ITUNES_TRACK_NUMBER_ATOM = FourCharConstToUint32('t', 'r', 'k', 'n');
-const uint32	ITUNES_DISK_NUMBER_ATOM = FourCharConstToUint32('d', 'i', 's', 'k');
-const uint32	ITUNES_COMPOSER_ATOM = FourCharConstToUint32('©', 'w', 'r', 't');
-const uint32	ITUNES_ENCODER_ATOM = FourCharConstToUint32('©', 't', 'o', 'o');
-const uint32	ITUNES_BPM_ATOM = FourCharConstToUint32('t', 'm', 'p', 'o');
-const uint32	ITUNES_COMPILATION_ATOM = FourCharConstToUint32('c', 'p', 'i', 'l');
-const uint32	ITUNES_ART_WORK_ATOM = FourCharConstToUint32('c', 'o', 'v', 'r');
-const uint32	ITUNES_GROUPING_ATOM = FourCharConstToUint32('©', 'g', 'r', 'p');
-const uint32	ITUNES_STIK_ATOM = FourCharConstToUint32('s', 't', 'i', 'k');
-const uint32	ITUNES_PODCAST_ATOM = FourCharConstToUint32('p', 'c', 's', 't');
-const uint32	ITUNES_CATEGORY_ATOM = FourCharConstToUint32('c', 'a', 't', 'g');
-const uint32	ITUNES_KEYWORD_ATOM = FourCharConstToUint32('k', 'e', 'y', 'w');
-const uint32	ITUNES_PODCAST_URL_ATOM = FourCharConstToUint32('p', 'u', 'r', 'l');
-const uint32	ITUNES_EPISODE_GLOBAL_UNIQUE_ID_ATOM = FourCharConstToUint32('e', 'g', 'i', 'd');
-const uint32	ITUNES_LYRICS_ATOM = FourCharConstToUint32('©', 'l', 'y', 'r');
-const uint32	ITUNES_TV_NETWORK_NAME_ATOM = FourCharConstToUint32('t', 'v', 'n', 'n');
-const uint32	ITUNES_TV_SHOW_NAME_ATOM = FourCharConstToUint32('t', 'v', 's', 'h');
-const uint32	ITUNES_TV_EPISODE_NUMBER_ATOM = FourCharConstToUint32('t', 'v', 'e', 'n');
-const uint32	ITUNES_TV_SEASON_ATOM = FourCharConstToUint32('t', 'v', 's', 'n');
-const uint32	ITUNES_TV_EPISODE_ATOM = FourCharConstToUint32('t', 'v', 'e', 's');
-const uint32	ITUNES_PURCHASE_DATE_ATOM = FourCharConstToUint32('p', 'u', 'r', 'd');
-const uint32	ITUNES_COPYRIGHT_ATOM = FourCharConstToUint32('c', 'p', 'r', 't');
-const uint32	ITUNES_DESCRIPTION_ATOM = FourCharConstToUint32('d', 'e', 's', 'c');
-
-const uint32	META_DATA_ATOM = FourCharConstToUint32('m', 'e', 't', 'a');
-const uint32	ITUNES_FREE_FORM_DATA_NAME_ATOM = FourCharConstToUint32('n', 'a', 'm', 'e');
-const uint32	ITUNES_FREE_FORM_DATA_ATOM_TYPE_PART1 = FourCharConstToUint32('i', 'T', 'u', 'n');
-const uint32	ITUNES_FREE_FORM_DATA_ATOM_TYPE_PART2 = FourCharConstToUint32('N', 'O', 'R', 'M');
-const uint32	ITUNES_FREE_FORM_DATA_ATOM_TYPE_TOOL = FourCharConstToUint32('t', 'o', 'o', 'l');
-const uint32	ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB = FourCharConstToUint32('e', 's', '_', 'C');
-const uint32	ITUNES_MDIRAPPL_HDLR_PART1 = FourCharConstToUint32('m', 'd', 'i', 'r');
-const uint32	ITUNES_MDIRAPPL_HDLR_PART2 = FourCharConstToUint32('a', 'p', 'p', 'l');
-const uint32    ITUNES_ILST_ATOM = FourCharConstToUint32('i', 'l', 's', 't');
-const uint32	ITUNES_ILST_DATA_ATOM = FourCharConstToUint32('d', 'a', 't', 'a');
-const uint32	ITUENES_MEAN_ATOM = FourCharConstToUint32('m', 'e', 'a', 'n');
-const uint32	ITUNES_FREE_FORM_ATOM = FourCharConstToUint32('-', '-', '-', '-');
-
-
-
-// VARIOUS DESCRIPTOR TAGS CURRENTLY IN USE
-
-#define ES_DESCRIPTOR_TAG             0x03
-#define ES_ID_INC_TAG                 0x0E
-#define ES_ID_REF_TAG                 0x0F
-#define DECODER_CONFIG_DESCRIPTOR_TAG 0x04
-#define DECODER_SPECIFIC_INFO_TAG     0x05
-#define SL_CONFIG_DESCRIPTOR          0x06
-
-#define STREAM_TYPE_AUDIO      0x05
-#define STREAM_TYPE_VISUAL     0x04
-
-#define DEFAULT_AUTHORING_MODE 0x00000000
-
-typedef enum
-{
-    ENoFileType	  = 0x0000,
-    E3GP4		  = 0x0001,
-    E3GP5		  = 0x0002,
-    EISOM		  = 0x0010,
-    EMP41		  = 0x0020,
-    EMP42		  = 0x0040,
-    EMMP4		  = 0x0100,
-    EWMF		  = 0x0200,
-    EUNKNOWN_TYPE = 0x8000
-} FILE_TYPE_MASKS;
-
-typedef enum
-{
-    CODEC_TYPE_AMR_AUDIO = 1,
-    CODEC_TYPE_AAC_AUDIO
-
-} AUDIO_CODEC_TYPES;
-
-typedef enum
-{
-    CODEC_TYPE_MPEG4_VIDEO = 1,
-    CODEC_TYPE_BASELINE_H263_VIDEO,
-    CODEC_TYPE_MPEG4_IMAGE
-
-} VIDEO_CODEC_TYPES;
-
-typedef enum
-{
-    AMR_AUDIO   = 0xd0,
-    QCELP_MP4	= 0xE1,
-    MPEG4_AUDIO = 0x40,
-    MPEG2_AUDIO_LC = 0x67,
-    MPEG4_VIDEO = 0x20,
-    H263_VIDEO  = 0xc0,
-    AMRWB_AUDIO_3GPP = 0xFA,
-    AVC_VIDEO   = 0xFB,
-    AMR_AUDIO_3GPP = 0xFC,
-    TIMED_TEXT  = 0xFD,
-    MPEG4_SYS_OD = 0x01,
-    MPEG4_SYS_BIFS = 0x01,
-    TYPE_UNKNOWN = 0
-
-} OTI_VALUES;
-
-typedef enum
-{
-    STRING_GENRE = 0,
-    INTEGER_GENRE
-}GnreVersion;
-
-typedef struct
-{
-    OSCL_wHeapString<OsclMemAllocator> title;
-    OSCL_wHeapString<OsclMemAllocator> author;
-    OSCL_wHeapString<OsclMemAllocator> description;
-    OSCL_wHeapString<OsclMemAllocator> rating;
-    OSCL_wHeapString<OsclMemAllocator> copyRight;
-    OSCL_wHeapString<OsclMemAllocator> version;
-    OSCL_wHeapString<OsclMemAllocator> creationDate;
-} ClipInfo;
-
-typedef enum
-{
-
-    ORIGINAL_CHAR_TYPE_UNKNOWN,
-    ORIGINAL_CHAR_TYPE_UTF8,
-    ORIGINAL_CHAR_TYPE_UTF16
-
-} MP4FFParserOriginalCharEnc;
-
-
-#define JPEG	0x0000
-#define GIF		0x0001
-#define MP4_MIN_BYTES_FOR_GETTING_MOVIE_HDR_SIZE 1024
-
-#define DISABLE_REPOS_ON_CLIPS_HAVING_UNEQUAL_TFRA_ENTRY_COUNT 0
-
-#define COUNT_OF_TRUNS_PARSED_THRESHOLD 3000
-
-// when playing from a file
-#define MAX_CACHED_TABLE_ENTRIES_FILE		4096
-#define TABLE_ENTRIES_THRESHOLD_FILE            1024
-
-// when playing from a memory buffer data stream
-#define MAX_CACHED_TABLE_ENTRIES_MBDS		16384
-#define TABLE_ENTRIES_THRESHOLD_MBDS		4096
-
-#endif //ATOMDEFS_H_INCLUDED
diff --git a/fileformats/mp4/parser/include/atomutils.h b/fileformats/mp4/parser/include/atomutils.h
deleted file mode 100644
index 18202d6..0000000
--- a/fileformats/mp4/parser/include/atomutils.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*     -------------------------------------------------------------------       */
-/*                            MPEG-4 AtomUtils Class                             */
-/*     -------------------------------------------------------------------       */
-/*********************************************************************************/
-/*
-    This AtomUtils Class contains sime useful methods for operating on Atoms
-*/
-
-
-#ifndef ATOMUTILS_H_INCLUDED
-#define ATOMUTILS_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDE
-#include "oscl_base.h"
-#endif
-
-#ifndef OSCL_FILE_IO_H_INCLUDED
-#include "oscl_file_io.h"
-#endif
-
-#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
-#include "oscl_string_containers.h"
-#endif
-
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef OSCL_MEM_BASIC_FUNCTIONS_H
-#include "oscl_mem_basic_functions.h"
-#endif
-
-/* CPM Related Header Files */
-#ifndef CPM_H_INCLUDED
-#include "cpm.h"
-#endif
-#ifndef PVFILE_H_INCLUDED
-#include "pvfile.h"
-#endif
-
-typedef Oscl_File* MP4_FF_FILE_REFERENCE;
-
-#define PVMF_MP4FFPARSER_LOGDIAGNOSTICS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iDiagnosticsLogger,PVLOGMSG_INFO,m);
-#define PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iStateVarLogger,PVLOGMSG_INFO,m);
-#define PVMF_MP4FFPARSER_LOGPARSEDINFO(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iParsedDataLogger,PVLOGMSG_INFO,m);
-#define PVMF_MP4FFPARSER_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-#define PV_MP4_FF_NEW(auditCB,T,params,ptr)\
-{\
-ptr = OSCL_NEW(T,params);\
-}
-
-
-#define PV_MP4_FF_DELETE(auditCB,T,ptr)\
-{\
-OSCL_DELETE(ptr);\
-}
-
-#define PV_MP4_FF_TEMPLATED_DELETE(auditCB,T,Tsimple,ptr)\
-{\
-OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
-}
-
-
-#define PV_MP4_FF_ARRAY_MALLOC(auditCB,T,count,ptr)\
-{\
-	ptr = (T*)OSCL_MALLOC(count);\
-}
-
-
-#define PV_MP4_ARRAY_FREE(auditCB,ptr)\
-{\
-	OSCL_FREE(ptr);\
-}
-
-#define PV_MP4_FF_ARRAY_NEW(auditCB, T, count, ptr)\
-{\
-	ptr = OSCL_ARRAY_NEW(T, count);\
-}
-
-#define PV_MP4_ARRAY_DELETE(auditCB, ptr)\
-{\
-	OSCL_ARRAY_DELETE(ptr);\
-}
-
-
-class MP4_FF_FILE
-{
-    public:
-        MP4_FF_FILE()
-                : _fileSize(0)
-                , _fileServSession(NULL)
-        {
-        }
-        MP4_FF_FILE(const MP4_FF_FILE& a)
-                : _fileSize(a._fileSize)
-                , _fileServSession(a._fileServSession)
-                , _pvfile(a._pvfile)
-        {
-        }
-        bool IsOpen()
-        {
-            return _pvfile.IsOpen();
-        }
-
-        int32                 _fileSize;
-        Oscl_FileServer*      _fileServSession;
-        PVFile                _pvfile;
-};
-
-class AtomUtils
-{
-
-    public:
-        // Methods for reading in data from a file stream
-        static bool read64(MP4_FF_FILE *fp, uint64 &data);
-        static bool read32(MP4_FF_FILE *fp, uint32 &data);
-        static bool read32read32(MP4_FF_FILE *fp, uint32 &data1, uint32 &data2);
-        static bool read24(MP4_FF_FILE *fp, uint32 &data);
-        static bool read16(MP4_FF_FILE *fp, uint16 &data);
-        static bool read16read16(MP4_FF_FILE *fp, uint16 &data1, uint16 &data2);
-        static bool read8(MP4_FF_FILE *fp, uint8 &data);
-        static bool read8read8(MP4_FF_FILE *fp, uint8 &data1, uint8 &data2);
-        static bool readNullTerminatedString(MP4_FF_FILE *fp, OSCL_wString& data);
-
-        static bool readNullTerminatedUnicodeString(MP4_FF_FILE *fp, OSCL_wString& data);
-        static bool readNullTerminatedAsciiString(MP4_FF_FILE *fp, OSCL_wString& data);
-
-        static bool readByteData(MP4_FF_FILE *fp, uint32 length, uint8 *data);
-
-        // Method to set time value in seconds since 1904
-        static void setTime(uint32& ulTime);
-
-        // This method is used to calculate the number of bytes needed to store the
-        // overall size of the class - the value contentSize is the size of the class
-        // NOT including the actual _sizeOfClass field (since this is a variable-length
-        // field).  This is used when determining the actual _sizeOfClass value for
-        // all the Descriptor and Command classes.
-        static uint32 getNumberOfBytesUsedToStoreSizeOfClass(uint32 contentSize);
-
-        // Returns the atom type from parsing the input stream
-        OSCL_IMPORT_REF static void getNextAtomType(MP4_FF_FILE *fp, uint32 &size, uint32 &type);
-        static int32 getNextAtomSize(MP4_FF_FILE *fp);
-        static uint32 getMediaTypeFromHandlerType(uint32 handlerType);
-        static uint32 getNumberOfBytesUsedToStoreContent(uint32 sizeOfClass);
-
-        // Peeks and returns the next Nth byte from the file
-        static uint32 peekNextNthBytes(MP4_FF_FILE *fp, int32 n);
-        static uint8  peekNextByte(MP4_FF_FILE *fp);
-        OSCL_IMPORT_REF static void   seekFromCurrPos(MP4_FF_FILE *fp, uint32 n);
-        OSCL_IMPORT_REF static void   seekFromStart(MP4_FF_FILE *fp, uint32 n);
-        OSCL_IMPORT_REF static void   seekToEnd(MP4_FF_FILE *fp);
-        static void   rewindFilePointerByN(MP4_FF_FILE *fp, uint32 n);
-        OSCL_IMPORT_REF static int32  getCurrentFilePosition(MP4_FF_FILE *fp);
-        OSCL_IMPORT_REF static int32  OpenMP4File(OSCL_wString& filename, uint32 mode, MP4_FF_FILE *fp);
-        OSCL_IMPORT_REF static int32  CloseMP4File(MP4_FF_FILE *fp);
-        OSCL_IMPORT_REF static int32  Flush(MP4_FF_FILE *fp);
-        OSCL_IMPORT_REF static bool   getCurrentFileSize(MP4_FF_FILE *fp, uint32& aCurrentSize);
-
-        static bool read32(uint8 *&buf, uint32 &data);
-        static bool read32read32(uint8 *&buf, uint32 &data1, uint32 &data2);
-        static bool read16(uint8 *&buf, uint16 &data);
-        static bool read8(uint8 *&buf, uint8 &data);
-        static bool readByteData(uint8 *&buf, uint32 length, uint8 *data);
-        static uint32 getNextAtomType(uint8 *buf);
-        static int32 getNextAtomSize(uint8 *buf);
-
-        // returns content length
-        static uint32 getContentLength(MP4_FF_FILE *fp);
-        // returns the data stream cache size
-        static uint32 getFileBufferingCapacity(MP4_FF_FILE *fp);
-        // peek to a new offset (MBDS only), read pointer does not change
-        // this is used to trigger a http request
-        static void skipFromStart(MP4_FF_FILE *fp, uint32 n);
-        // for progressive playback seeking
-        // returns the range of available bytes in MBDS
-        // first + last byte offset inclusive
-        static void getCurrentByteRange(MP4_FF_FILE *fp, uint32& aCurrentFirstByteOffset, uint32& aCurrentLastByteOffset);
-
-
-};
-
-#endif // ATOMUTILS_H_INCLUDED
-
-
diff --git a/fileformats/mp4/parser/include/audiosampleentry.h b/fileformats/mp4/parser/include/audiosampleentry.h
index db5eb4e..d1a0b8e 100644
--- a/fileformats/mp4/parser/include/audiosampleentry.h
+++ b/fileformats/mp4/parser/include/audiosampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,6 +56,16 @@
             return _timeScale;
         }
 
+        uint16 getSampleRate()
+        {
+            return _sampleRateHi;
+        }
+
+        uint16 getChannelCount()
+        {
+            return _channelCount;
+        }
+
         virtual uint32 getESID() const
         {
             if (_pes != NULL)
@@ -87,7 +97,7 @@
             }
         }
 
-        virtual    uint8 getObjectTypeIndication() const
+        virtual uint8 getObjectTypeIndication() const
         {
             if (_pes != NULL)
             {
@@ -111,7 +121,7 @@
             }
         }
 
-        uint32 getAverageBitrate() const
+        virtual uint32 getAverageBitrate() const
         {
             if (_pes != NULL)
             {
@@ -123,7 +133,7 @@
             }
         }
 
-        uint32 getMaxBitrate() const
+        virtual uint32 getMaxBitrate() const
         {
             if (_pes != NULL)
             {
@@ -152,11 +162,13 @@
     private:
         // Reserved constants
         uint32 _reserved1[2];
-        uint16 _reserved2;
-        uint16 _reserved3;
-        uint32 _reserved4;
-        uint16 _reserved5;
-        uint16 _timeScale;
+        uint16 _channelCount;
+        uint16 _sampleSize;
+        uint16 _preDefined;
+        uint16 _reserved;
+        uint16 _sampleRateLo;
+        uint16 _timeScale;      //sampleRateHi = TimeScale of track
+        uint16 _sampleRateHi;   //Either sampleRateHi or TimeScale will be read from the file
 
         ESDAtom *_pes;
 };
diff --git a/fileformats/mp4/parser/include/avcconfigurationbox.h b/fileformats/mp4/parser/include/avcconfigurationbox.h
index e137126..8551734 100644
--- a/fileformats/mp4/parser/include/avcconfigurationbox.h
+++ b/fileformats/mp4/parser/include/avcconfigurationbox.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
 #ifndef __AVCConfigurationBox_H__
 #define __AVCConfigurationBox_H__
 
diff --git a/fileformats/mp4/parser/include/avclayerentry.h b/fileformats/mp4/parser/include/avclayerentry.h
index 9bfd46d..a03b03b 100644
--- a/fileformats/mp4/parser/include/avclayerentry.h
+++ b/fileformats/mp4/parser/include/avclayerentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-
 #ifndef __AVCLayerDescEntry_H__
 #define __AVCLayerDescEntry_H__
 
@@ -24,6 +23,7 @@
 #include "oscl_file_io.h"
 #include "visualsampleentry.h"
 
+
 class AVCLayerDescEntry : public VisualSampleEntry
 {
 
diff --git a/fileformats/mp4/parser/include/avcsampledependency.h b/fileformats/mp4/parser/include/avcsampledependency.h
index 675a3ab..5c31f60 100644
--- a/fileformats/mp4/parser/include/avcsampledependency.h
+++ b/fileformats/mp4/parser/include/avcsampledependency.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-
 #ifndef __AVCSampleDependency_H__
 #define __AVCSampleDependency_H__
 
@@ -24,6 +23,7 @@
 #include "oscl_file_io.h"
 #include "fullatom.h"
 
+
 class AVCSampleDependency : public FullAtom
 {
 
diff --git a/fileformats/mp4/parser/include/avcsampledependencytype.h b/fileformats/mp4/parser/include/avcsampledependencytype.h
index 015f1ee..c2ca906 100644
--- a/fileformats/mp4/parser/include/avcsampledependencytype.h
+++ b/fileformats/mp4/parser/include/avcsampledependencytype.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-
 #ifndef __AVCSampleDependencyType_H__
 #define __AVCSampleDependencyType_H__
 
@@ -24,6 +23,7 @@
 #include "oscl_file_io.h"
 #include "fullatom.h"
 
+
 class AVCSampleDependencyType: public FullAtom
 {
     public:
diff --git a/fileformats/mp4/parser/include/avcsampleentry.h b/fileformats/mp4/parser/include/avcsampleentry.h
index 60e1440..d46961c 100644
--- a/fileformats/mp4/parser/include/avcsampleentry.h
+++ b/fileformats/mp4/parser/include/avcsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #ifndef __AVCSampleEntry_H__
 #define __AVCSampleEntry_H__
 
diff --git a/fileformats/mp4/parser/include/avcsampletogroupbox.h b/fileformats/mp4/parser/include/avcsampletogroupbox.h
index f41ea76..627d19a 100644
--- a/fileformats/mp4/parser/include/avcsampletogroupbox.h
+++ b/fileformats/mp4/parser/include/avcsampletogroupbox.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
 #ifndef __AVCSampleToGroup_H__
 #define __AVCSampleToGroup_H__
 
diff --git a/fileformats/mp4/parser/include/avcsubseqdescriptionentry.h b/fileformats/mp4/parser/include/avcsubseqdescriptionentry.h
index 2b538ed..6d00f8f 100644
--- a/fileformats/mp4/parser/include/avcsubseqdescriptionentry.h
+++ b/fileformats/mp4/parser/include/avcsubseqdescriptionentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,10 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*     -------------------------------------------------------------------       */
-/*                        AVC Sub Sequence Description Entry Class               */
-/*     -------------------------------------------------------------------       */
-
 #ifndef __AVCSubSeqDescriptionEntry_H__
 #define __AVCSubSeqDescriptionEntry_H__
 
@@ -26,6 +22,7 @@
 #include "atomutils.h"
 #include "oscl_file_io.h"
 
+
 class DependencyInfo
 {
 
diff --git a/fileformats/mp4/parser/include/basedescriptor.h b/fileformats/mp4/parser/include/basedescriptor.h
index 5d62aea..c84ba8c 100644
--- a/fileformats/mp4/parser/include/basedescriptor.h
+++ b/fileformats/mp4/parser/include/basedescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/boxrecord.h b/fileformats/mp4/parser/include/boxrecord.h
index 2dc1377..f22e51c 100644
--- a/fileformats/mp4/parser/include/boxrecord.h
+++ b/fileformats/mp4/parser/include/boxrecord.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/chunklargeoffsetatom.h b/fileformats/mp4/parser/include/chunklargeoffsetatom.h
index 1073211..edb26bc 100644
--- a/fileformats/mp4/parser/include/chunklargeoffsetatom.h
+++ b/fileformats/mp4/parser/include/chunklargeoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/chunkoffsetatom.h b/fileformats/mp4/parser/include/chunkoffsetatom.h
index b69015d..abee31c 100644
--- a/fileformats/mp4/parser/include/chunkoffsetatom.h
+++ b/fileformats/mp4/parser/include/chunkoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/compositionoffsetatom.h b/fileformats/mp4/parser/include/compositionoffsetatom.h
index 8a98726..269ab34 100644
--- a/fileformats/mp4/parser/include/compositionoffsetatom.h
+++ b/fileformats/mp4/parser/include/compositionoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,9 +40,16 @@
 #include "fullatom.h"
 #endif
 
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#include "oscl_scheduler.h"
+
 #define PV_ERROR -1
 
-class CompositionOffsetAtom : public FullAtom
+class CompositionOffsetAtom : public FullAtom,
+            public OsclTimerObject
 {
 
     public:
@@ -65,6 +72,7 @@
         int32 getTimeOffsetForSampleNumberPeek(uint32 sampleNum);
         int32 getTimeOffsetForSampleNumber(uint32 num);
         int32 getTimeOffsetForSampleNumberGet(uint32 num);
+        void setSamplesCount(uint32 SamplesCount);
 
         int32 resetStateVariables();
         int32 resetStateVariables(uint32 sampleNum);
@@ -75,14 +83,35 @@
             return _currPeekSampleCount;
         }
 
+        //Marker Table Related Functions
+        int32 getTimeOffsetFromMT(uint32 samplenum, uint32 currEC, uint32 currSampleCount);
+        int32 createMarkerTable();
+        uint32 populateMarkerTable();
+        void deleteMarkerTable();
+
     private:
         bool ParseEntryUnit(uint32 entry_cnt);
         void CheckAndParseEntry(uint32 i);
+        // from OsclTimerObject
+        void Run();
         uint32 _entryCount;
 
         uint32 *_psampleCountVec;
         uint32 *_psampleOffsetVec;
 
+        //marker table related
+        uint32 *MT_SampleCount;
+        uint32 *MT_EntryCount;
+        uint32 _iTotalNumSamplesInTrack;
+        uint32 MT_Counter;
+        uint32 addSampleCount;
+        uint32 prevSampleCount;
+        uint32 entrycountTraversed;
+        uint32 MT_Table_Size;
+        bool iMarkerTableCreation;
+        uint32 refSample;
+        uint32 MT_j;
+
         uint32 _mediaType;
 
         // For visual samples
diff --git a/fileformats/mp4/parser/include/copyrightatom.h b/fileformats/mp4/parser/include/copyrightatom.h
index 77f1fe0..c341436 100644
--- a/fileformats/mp4/parser/include/copyrightatom.h
+++ b/fileformats/mp4/parser/include/copyrightatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/dataentryatom.h b/fileformats/mp4/parser/include/dataentryatom.h
index c7a508c..759ad9d 100644
--- a/fileformats/mp4/parser/include/dataentryatom.h
+++ b/fileformats/mp4/parser/include/dataentryatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/dataentryurlatom.h b/fileformats/mp4/parser/include/dataentryurlatom.h
index 4504fd3..77911e2 100644
--- a/fileformats/mp4/parser/include/dataentryurlatom.h
+++ b/fileformats/mp4/parser/include/dataentryurlatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/dataentryurnatom.h b/fileformats/mp4/parser/include/dataentryurnatom.h
index 693f3b9..794da07 100644
--- a/fileformats/mp4/parser/include/dataentryurnatom.h
+++ b/fileformats/mp4/parser/include/dataentryurnatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/datainformationatom.h b/fileformats/mp4/parser/include/datainformationatom.h
index 6e455b9..1c501b5 100644
--- a/fileformats/mp4/parser/include/datainformationatom.h
+++ b/fileformats/mp4/parser/include/datainformationatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/datareferenceatom.h b/fileformats/mp4/parser/include/datareferenceatom.h
index ed51efc..c0c3b43 100644
--- a/fileformats/mp4/parser/include/datareferenceatom.h
+++ b/fileformats/mp4/parser/include/datareferenceatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/decoderconfigdescriptor.h b/fileformats/mp4/parser/include/decoderconfigdescriptor.h
index c6609c0..59f11d1 100644
--- a/fileformats/mp4/parser/include/decoderconfigdescriptor.h
+++ b/fileformats/mp4/parser/include/decoderconfigdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/decoderspecificinfo.h b/fileformats/mp4/parser/include/decoderspecificinfo.h
index ab3aecd..3f1fb4e 100644
--- a/fileformats/mp4/parser/include/decoderspecificinfo.h
+++ b/fileformats/mp4/parser/include/decoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/degradationpriorityatom.h b/fileformats/mp4/parser/include/degradationpriorityatom.h
index 576390e..ee8c809 100644
--- a/fileformats/mp4/parser/include/degradationpriorityatom.h
+++ b/fileformats/mp4/parser/include/degradationpriorityatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/editatom.h b/fileformats/mp4/parser/include/editatom.h
index 9897598..b544033 100644
--- a/fileformats/mp4/parser/include/editatom.h
+++ b/fileformats/mp4/parser/include/editatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/editlistatom.h b/fileformats/mp4/parser/include/editlistatom.h
index 209a043..778c4dd 100644
--- a/fileformats/mp4/parser/include/editlistatom.h
+++ b/fileformats/mp4/parser/include/editlistatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
 #include "fullatom.h"
 #endif
 
+
 #ifndef OSCL_VECTOR_H_INCLUDED
 #include "oscl_vector.h"
 #endif
diff --git a/fileformats/mp4/parser/include/es_id_inc.h b/fileformats/mp4/parser/include/es_id_inc.h
index 4990088..20cf08a 100644
--- a/fileformats/mp4/parser/include/es_id_inc.h
+++ b/fileformats/mp4/parser/include/es_id_inc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/es_id_ref.h b/fileformats/mp4/parser/include/es_id_ref.h
index f25bcbe..7ca1262 100644
--- a/fileformats/mp4/parser/include/es_id_ref.h
+++ b/fileformats/mp4/parser/include/es_id_ref.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/esdatom.h b/fileformats/mp4/parser/include/esdatom.h
index d33e425..f2561f9 100644
--- a/fileformats/mp4/parser/include/esdatom.h
+++ b/fileformats/mp4/parser/include/esdatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/esdescriptor.h b/fileformats/mp4/parser/include/esdescriptor.h
index f403170..312234c 100644
--- a/fileformats/mp4/parser/include/esdescriptor.h
+++ b/fileformats/mp4/parser/include/esdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -94,6 +94,7 @@
         // Retuns a UNICODE string given the null-terminated byte array
         OSCL_wString& getUrlString();
 
+
         const DecoderConfigDescriptor &getDecoderConfigDescriptor()
         {
             return *_pdcd;
diff --git a/fileformats/mp4/parser/include/expandablebaseclass.h b/fileformats/mp4/parser/include/expandablebaseclass.h
index dfcd6cd..a8a91dd 100644
--- a/fileformats/mp4/parser/include/expandablebaseclass.h
+++ b/fileformats/mp4/parser/include/expandablebaseclass.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/filetypeatom.h b/fileformats/mp4/parser/include/filetypeatom.h
index c20dfce..a97d40f 100644
--- a/fileformats/mp4/parser/include/filetypeatom.h
+++ b/fileformats/mp4/parser/include/filetypeatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/fontrecord.h b/fileformats/mp4/parser/include/fontrecord.h
index 271371f..037f2cf 100644
--- a/fileformats/mp4/parser/include/fontrecord.h
+++ b/fileformats/mp4/parser/include/fontrecord.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/fonttableatom.h b/fileformats/mp4/parser/include/fonttableatom.h
index b060b5e..d47d10c 100644
--- a/fileformats/mp4/parser/include/fonttableatom.h
+++ b/fileformats/mp4/parser/include/fonttableatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/freespaceatom.h b/fileformats/mp4/parser/include/freespaceatom.h
index 2bd781a..eed2825 100644
--- a/fileformats/mp4/parser/include/freespaceatom.h
+++ b/fileformats/mp4/parser/include/freespaceatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/fullatom.h b/fileformats/mp4/parser/include/fullatom.h
index 0354d52..22c7676 100644
--- a/fileformats/mp4/parser/include/fullatom.h
+++ b/fileformats/mp4/parser/include/fullatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/h263decoderspecificinfo.h b/fileformats/mp4/parser/include/h263decoderspecificinfo.h
index ecf60da..d0d37d6 100644
--- a/fileformats/mp4/parser/include/h263decoderspecificinfo.h
+++ b/fileformats/mp4/parser/include/h263decoderspecificinfo.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/h263sampleentry.h b/fileformats/mp4/parser/include/h263sampleentry.h
index aaadc2a..0dc817a 100644
--- a/fileformats/mp4/parser/include/h263sampleentry.h
+++ b/fileformats/mp4/parser/include/h263sampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/handleratom.h b/fileformats/mp4/parser/include/handleratom.h
index c601acc..86056f1 100644
--- a/fileformats/mp4/parser/include/handleratom.h
+++ b/fileformats/mp4/parser/include/handleratom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/hintmediaheaderatom.h b/fileformats/mp4/parser/include/hintmediaheaderatom.h
index f094ab0..7f8690f 100644
--- a/fileformats/mp4/parser/include/hintmediaheaderatom.h
+++ b/fileformats/mp4/parser/include/hintmediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/imediabuffer.h b/fileformats/mp4/parser/include/imediabuffer.h
index d9fd7a1..508dc9f 100644
--- a/fileformats/mp4/parser/include/imediabuffer.h
+++ b/fileformats/mp4/parser/include/imediabuffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/impeg4file.h b/fileformats/mp4/parser/include/impeg4file.h
index 29ba728..d724ff1 100644
--- a/fileformats/mp4/parser/include/impeg4file.h
+++ b/fileformats/mp4/parser/include/impeg4file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,7 +68,6 @@
 #ifndef CPM_H_INCLUDED
 #include "cpm.h"
 #endif
-
 #include "pv_id3_parcom_types.h"
 
 class OsclFileHandle;
@@ -138,6 +137,7 @@
         virtual uint64 getMovieDuration() const = 0;
         virtual uint32 getMovieTimescale() const = 0;
 
+
         // From TrackHeader
         virtual uint64 getTrackDuration(uint32 id) = 0; // in movie timescale
 
@@ -148,6 +148,7 @@
         // From MediaHeader
         virtual uint64 getTrackMediaDuration(uint32 id) = 0;
         virtual uint32 getTrackMediaTimescale(uint32 id) = 0;
+        virtual uint16 getTrackLangCode(uint32 id) = 0;
 
         // From Handler
         // Returns the 4CC of the track media type (i.e. 'vide' for video)
@@ -158,8 +159,7 @@
         virtual int32 getTrackNumSampleEntries(uint32 id) = 0;
 
         // From DecoderConfigDescriptor
-        virtual OSCL_wHeapString<OsclMemAllocator>  getTrackMIMEType(uint32 id) = 0; // Based on OTI and string tables
-        virtual uint8  getTrackOTIType(uint32 id) = 0;// Based on OTI value
+        virtual void getTrackMIMEType(uint32 id, OSCL_String& aMimeType) = 0; // Based on OTI and string tables
 
         virtual int32  getTrackMaxBufferSizeDB(uint32 id) = 0;
         virtual int32  getTrackAverageBitrate(uint32 id) = 0;
@@ -187,12 +187,6 @@
                 uint32 howManyKeySamples = 1) = 0;
 
         // Static method to read in an MP4 file from disk and return the IMpeg4File interface
-        OSCL_IMPORT_REF static IMpeg4File *readMP4File(OSCL_wString& filename,
-                uint32 parsingMode = 0,
-                Oscl_FileServer* fileServSession = NULL);
-
-        OSCL_IMPORT_REF static IMpeg4File *readMP4File(Oscl_File* fileRef, uint32 parsingMode = 0);
-
         OSCL_IMPORT_REF static IMpeg4File *readMP4File(OSCL_wString& aFilename,
                 PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
                 OsclFileHandle* aHandle = NULL,
@@ -200,6 +194,14 @@
                 Oscl_FileServer* aFileServSession = NULL);
 
         OSCL_IMPORT_REF static void DestroyMP4FileObject(IMpeg4File* aMP4FileObject);
+
+        virtual bool CreateDataStreamSessionForExternalDownload(OSCL_wString& aFilename,
+                PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
+                OsclFileHandle* aHandle = NULL,
+                Oscl_FileServer* aFileServSession = NULL) = 0;
+
+        virtual void DestroyDataStreamForExternalDownload() = 0;
+
         virtual void resetPlayback() = 0;
         virtual uint32 resetPlayback(uint32 time, uint16 numTracks, uint32 *trackList, bool bResetToIFrame = true) = 0;
         virtual int32 queryRepositionTime(uint32 time,
@@ -243,6 +245,10 @@
 
         virtual int16 getLayer(uint32 trackid) = 0;
         virtual uint16 getAlternateGroup(uint32 trackid) = 0;
+
+        virtual int32 getVideoFrameHeight(uint32 trackid) = 0;
+        virtual int32 getVideoFrameWidth(uint32 trackid) = 0;
+
         virtual int32 getTextTrackWidth(uint32 trackid) = 0;
         virtual int32 getTextTrackHeight(uint32 trackid) = 0;
         virtual int32 getTextTrackXOffset(uint32 trackid) = 0;
@@ -276,14 +282,6 @@
 
         virtual	uint32 getAVCNALLengthSize(uint32 trackID, uint32 index = 0) = 0;
 
-        OSCL_IMPORT_REF static bool IsMP4File(OSCL_wString& filename,
-                                              Oscl_FileServer* fileServSession = NULL);
-
-        OSCL_IMPORT_REF static bool IsMP4File(Oscl_File* filePtr);
-
-        OSCL_IMPORT_REF static bool IsMP4File(PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
-                                              Oscl_FileServer* aFileServSession = NULL,
-                                              OsclFileHandle* aHandle = NULL);
         /*
          * @param Oscl_File* filePtr - File pointer to the MP4/3GP
          * file. Please note that the file open and close are handled by the
@@ -424,23 +422,30 @@
         // ITunes Specific functions
 
         virtual OSCL_wHeapString<OsclMemAllocator> getITunesTool() const = 0;
+        virtual OSCL_wHeapString<OsclMemAllocator> getITunesEncodedBy() const = 0;
         virtual OSCL_wHeapString<OsclMemAllocator> getITunesWriter() const = 0;
         virtual OSCL_wHeapString<OsclMemAllocator> getITunesGroupData() const = 0;
         virtual uint16 getITunesThisTrackNo() const = 0;
         virtual PvmfApicStruct* getITunesImageData() const = 0;
         virtual uint16 getITunesTotalTracks() const = 0;
         virtual bool IsITunesCompilationPart() const = 0;
+        virtual bool IsITunesContentRating() const = 0;
         virtual uint16 getITunesBeatsPerMinute() const = 0;
         virtual uint16 getITunesThisDiskNo() const = 0;
         virtual uint16 getITunesTotalDisks() const = 0;
         virtual OSCL_wHeapString<OsclMemAllocator> getITunesNormalizationData() const = 0;
         virtual OSCL_wHeapString<OsclMemAllocator> getITunesCDIdentifierData(uint8 aCDdatanumIndex) = 0;
+        virtual OSCL_wHeapString<OsclMemAllocator> getITunesCDTrackNumberData() const = 0;
+        virtual OSCL_wHeapString<OsclMemAllocator> getITunesCDDB1Data() const = 0;
         virtual OSCL_wHeapString<OsclMemAllocator> getITunesLyrics() const = 0;
         virtual	uint8 getITunesTotalCDIdentifierData() const = 0;
         virtual bool IsMovieFragmentsPresent() const = 0;
+        //Returns the Subtitle of individual track
+        virtual OSCL_wHeapString<OsclMemAllocator> getITunesTrackSubTitle() const = 0;
 
         // Reposition Related Video Track present API
         virtual void ResetVideoTrackPresentFlag() = 0;
+
         //APIs to return the no. of titles and their metadata values respectively.
         virtual uint32 getNumTitle() = 0;
         virtual PVMFStatus getTitle(uint32 index, OSCL_wString& aVal, uint16& aLangCode, MP4FFParserOriginalCharEnc& aCharEncType) = 0;
diff --git a/fileformats/mp4/parser/include/initialobjectdescriptor.h b/fileformats/mp4/parser/include/initialobjectdescriptor.h
index d737742..6714e19 100644
--- a/fileformats/mp4/parser/include/initialobjectdescriptor.h
+++ b/fileformats/mp4/parser/include/initialobjectdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 /*     -------------------------------------------------------------------       */
 /*********************************************************************************/
 
+
 #ifndef INITIALOBJECTDESCRIPTOR_H_INCLUDED
 #define INITIALOBJECTDESCRIPTOR_H_INCLUDED
 
diff --git a/fileformats/mp4/parser/include/isucceedfail.h b/fileformats/mp4/parser/include/isucceedfail.h
index bee565c..7c842ad 100644
--- a/fileformats/mp4/parser/include/isucceedfail.h
+++ b/fileformats/mp4/parser/include/isucceedfail.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -192,8 +192,9 @@
                 LAST_SAMPLE_IN_MOOV = 148,
                 READ_UDTA_LOC_FAILED = 149,
                 NOT_PROGRESSIVE_STREAMABLE = 150,
-                READ_PIXELASPECTRATIO_BOX_FAILED = 151
+                READ_PIXELASPECTRATIO_BOX_FAILED = 151,
 
+                EXCEED_MAX_LIMIT_SUPPORTED_FOR_TOTAL_TRACKS
 
              } MP4_ERROR_CODE;
 
diff --git a/fileformats/mp4/parser/include/itunesilstatom.h b/fileformats/mp4/parser/include/itunesilstatom.h
index 5660819..659675e 100644
--- a/fileformats/mp4/parser/include/itunesilstatom.h
+++ b/fileformats/mp4/parser/include/itunesilstatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,22 +15,58 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-	This ITunesILSTAtom Class is used for Parsing, and Storing the tags from Meta data
-	of ITune M4A file.
-*/
-
 #ifndef ITUNESILSTATOM_H_INCLUDED
 #define ITUNESILSTATOM_H_INCLUDED
 
 #include "atom.h"
+#include "fullatom.h"
 #include "pvmi_kvp.h"
 #include "atomdefs.h"
 
 #define MAX_CD_IDENTIFIER_FREE_DATA_ATOM 16
 #define ITUNES_MAX_COVER_IMAGE_SIZE (1024*1024) //1 meg
+#define PREFIX_SIZE 16
 
+//************************************MeaningAtom Class Starts  **********************************
+class ItunesMeaningAtom : public FullAtom
+{
+    public:
+        ItunesMeaningAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
+        virtual ~ItunesMeaningAtom();
+        //API to retrieve the Meaning String
+        OSCL_wHeapString<OsclMemAllocator> getMeaningString() const
+        {
+            return _meaningString;
+        }
+
+    private:
+
+        OSCL_wHeapString<OsclMemAllocator> _meaningString;
+
+
+};
+
+//************************************NameAtom Class Starts  **********************************
+
+class ItunesNameAtom : public FullAtom
+{
+    public:
+        ItunesNameAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
+        virtual ~ItunesNameAtom();
+        //API to retrieve the Name String
+        OSCL_wHeapString<OsclMemAllocator> getNameString() const
+        {
+            return _nameString;
+        }
+
+    private:
+
+        OSCL_wHeapString<OsclMemAllocator> _nameString;
+
+
+};
+
+//************************************BaseTypes for the MetaData **********************************
 class ITunesMetaDataAtom: public Atom
 {
     public:
@@ -48,8 +84,7 @@
 };
 
 
-
-// Title / Name
+//************************************Title(Name) Class Starts  **********************************
 class ITunesTitleAtom: public ITunesMetaDataAtom
 {
     public:
@@ -66,6 +101,24 @@
         OSCL_wHeapString<OsclMemAllocator> _name;
 };
 
+//************************************ Track's Subtitle Class Starts  **********************************
+
+class ITunesTrackSubTitleAtom: public ITunesMetaDataAtom
+{
+    public:
+        ITunesTrackSubTitleAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
+        ~ITunesTrackSubTitleAtom();
+
+        OSCL_wHeapString<OsclMemAllocator> getTrackSubTitle() const
+        {
+            return _trackTitle;
+        }
+
+    private:
+//SubTitle of the track
+        OSCL_wHeapString<OsclMemAllocator> _trackTitle;
+};
+
 
 //************************************ Artist / Performer Class Starts  **********************************
 class ITunesArtistAtom: public ITunesMetaDataAtom
@@ -84,6 +137,23 @@
         OSCL_wHeapString<OsclMemAllocator> _artist;
 };
 
+//************************************AlbumArtist Class Starts  **********************************
+class ITunesAlbumArtistAtom: public ITunesMetaDataAtom
+{
+    public:
+        ITunesAlbumArtistAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
+        ~ITunesAlbumArtistAtom();
+
+        OSCL_wHeapString<OsclMemAllocator> getAlbumArtist() const
+        {
+            return _albumArtist;
+        }
+
+    private:
+// AlbumArtist
+        OSCL_wHeapString<OsclMemAllocator> _albumArtist;
+};
+
 //************************************ Album Class Starts  **********************************
 class ITunesAlbumAtom: public ITunesMetaDataAtom
 {
@@ -108,12 +178,6 @@
         ITunesGenreAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
         ~ITunesGenreAtom();
 
-        /*	typedef enum
-        	{
-        		STRING_GENRE = 0,
-        		INTEGER_GENRE
-        	}GnreVersion;
-        */
         uint16 getGnreID() const
         {
             return _gnreID;
@@ -172,6 +236,24 @@
         OSCL_wHeapString<OsclMemAllocator> _tool;
 };
 
+//************************************EncodedBy(Company/Person) Class Starts  **********************************
+class ITunesEncodedByAtom: public ITunesMetaDataAtom
+{
+    public:
+        ITunesEncodedByAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
+        ~ITunesEncodedByAtom();
+
+        OSCL_wHeapString<OsclMemAllocator> getEncodedBy() const
+        {
+            return _encodedBy;
+        }
+
+    private:
+        // Person or company that encoded the recording
+        OSCL_wHeapString<OsclMemAllocator> _encodedBy;
+};
+
+
 //************************************ Writer Class Starts  **********************************
 class ITunesWriterAtom: public ITunesMetaDataAtom
 {
@@ -263,6 +345,23 @@
         bool _compilationPart;
 };
 
+//********************************* Content Rating Class Starts  ********************************
+class ITunesContentRatingAtom: public ITunesMetaDataAtom
+{
+    public:
+        ITunesContentRatingAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
+        ~ITunesContentRatingAtom();
+
+        bool IsContentRating() const
+        {
+            return _contentRating;
+        }
+
+    private:
+        // Does song have explicit content?
+        bool _contentRating;
+};
+
 //************************************ Tempo Class Starts  **********************************
 class ITunesTempoAtom: public ITunesMetaDataAtom
 {
@@ -313,6 +412,7 @@
         OSCL_wHeapString<OsclMemAllocator> _desc;
 };
 
+
 //************************************ Disk Data Class Starts  **********************************
 class ITunesDiskDatatAtom: public ITunesMetaDataAtom
 {
@@ -404,6 +504,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getTrackSubTitle() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesTrackSubTitleAtom)
+                return _pITunesTrackSubTitleAtom->getTrackSubTitle();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getArtist() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -413,6 +522,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getAlbumArtist() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesAlbumArtistAtom)
+                return _pITunesAlbumArtistAtom->getAlbumArtist();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getAlbum() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -491,6 +609,17 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getEncodedBy() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesEncodedByAtom)
+            {
+                return _pITunesEncodedByAtom->getEncodedBy();
+            }
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getWriter() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -542,6 +671,14 @@
                 return false;
         }
 
+        bool IsContentRating() const
+        {
+            if (_pITunesContentRatingAtom)
+                return _pITunesContentRatingAtom->IsContentRating();
+            else
+                return false;
+        }
+
         uint16 getBeatsPerMinute() const
         {
             if (_pITunesTempoAtom)
@@ -569,11 +706,6 @@
         }
 
 
-        /*	PvmfApicStruct getPNGImageData() const
-        	{
-        		return _PNGimageData;
-        	}*/
-
         PvmfApicStruct* getImageData() const
         {
             if (_pITunesCoverImageAtom)
@@ -629,6 +761,24 @@
 
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getCDTrackNumberData() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesCDTrackNumberFreeFormDataAtom)
+                return _pITunesCDTrackNumberFreeFormDataAtom->getString();
+            else
+                return temp;
+        }
+
+        OSCL_wHeapString<OsclMemAllocator> getCDDB1Data() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesCDDB1FreeFormDataAtom)
+                return _pITunesCDDB1FreeFormDataAtom->getString();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getLyrics() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -638,15 +788,26 @@
                 return temp;
         }
 
-
     private:
 
+        //Meaning String
+        ItunesMeaningAtom  *_pITunesMeaningAtom;
+        Oscl_Vector<ItunesMeaningAtom*, OsclMemAllocator> *_pMeaningAtomVec;
+        //Name String
+        ItunesNameAtom     *_pITunesNameAtom;
+        Oscl_Vector<ItunesNameAtom*, OsclMemAllocator> *_pNameAtomVec;
         // Title/Name Atom
         ITunesTitleAtom		*_pITunesTitleAtom;
 
+        //Track's subtitle
+        ITunesTrackSubTitleAtom *_pITunesTrackSubTitleAtom;
+
         // Artist/Performer of the Song
         ITunesArtistAtom		*_pITunesArtistAtom;
 
+        //Artist for the whole album (if different than the individual tracks)
+        ITunesAlbumArtistAtom		*_pITunesAlbumArtistAtom;
+
         // Album of Song
         ITunesAlbumAtom			*_pITunesAlbumAtom;
 
@@ -659,6 +820,9 @@
         // Tool/Encoder used for creation of this file.
         ITunesToolAtom			*_pITunesToolAtom;
 
+        //Person or company that encoded the recording
+        ITunesEncodedByAtom     *_pITunesEncodedByAtom;
+
         // Writer of the Song
         ITunesWriterAtom		*_pITunesWriterAtom;
 
@@ -674,6 +838,9 @@
         // Whether this file is the Part of Compilation or not.
         ITunesCompileAtom		*_pITunesCompileAtom;
 
+        // Does song have explicit content?
+        ITunesContentRatingAtom *_pITunesContentRatingAtom;
+
         // Number of Beats per Minute
         ITunesTempoAtom			*_pITunesTempoAtom;
 
@@ -681,6 +848,7 @@
 
         ITunesDescriptionAtom	*_pITunesDescriptionAtom;
 
+
         // Album Art Data- PNG Image data
         //PvmfApicStruct _PNGimageData;
         ITunesCoverImageAtom	*_pITunesCoverImageAtom;
@@ -698,8 +866,15 @@
         uint8 _iITunesCDIdentifierFreeFormDataAtomNum;
         ITunesFreeFormDataAtom	*_pITunesCDIdentifierFreeFormDataAtom[MAX_CD_IDENTIFIER_FREE_DATA_ATOM];
 
+        //CD Track Number Free Form Data
+        ITunesFreeFormDataAtom *_pITunesCDTrackNumberFreeFormDataAtom;
+
+        // CD Identifier Free Form Data
+        ITunesFreeFormDataAtom *_pITunesCDDB1FreeFormDataAtom;
+
         // Lyrics of the Song
         ITunesLyricsAtom		*_pITunesLyricsAtom;
+
         PVLogger *iLogger;
 };
 
diff --git a/fileformats/mp4/parser/include/itunesilstmetadataatom.h b/fileformats/mp4/parser/include/itunesilstmetadataatom.h
index 5ddfe96..5b50558 100644
--- a/fileformats/mp4/parser/include/itunesilstmetadataatom.h
+++ b/fileformats/mp4/parser/include/itunesilstmetadataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-	This ITunesILstMetaDataAtom Class is used for Parsing, and Storing the tags from Meta data
-	of ITune M4A file.
-*/
-
 #ifndef ITUNESILSTMETADATAATOM_H_INCLUDED
 #define ITUNESILSTMETADATAATOM_H_INCLUDED
 
diff --git a/fileformats/mp4/parser/include/itunesmetadataatom.h b/fileformats/mp4/parser/include/itunesmetadataatom.h
index 95a9dac..4fbcad1 100644
--- a/fileformats/mp4/parser/include/itunesmetadataatom.h
+++ b/fileformats/mp4/parser/include/itunesmetadataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-	This ITunesMetaDataAtom Class is used for Parsing, and Storing the tags from Meta data
-	of ITune M4A file.
-*/
-
 #ifndef ITUNESMETADATAATOM_H_INCLUDED
 #define ITUNESMETADATAATOM_H_INCLUDED
 
diff --git a/fileformats/mp4/parser/include/mediaatom.h b/fileformats/mp4/parser/include/mediaatom.h
index 3bce958..7c779cf 100644
--- a/fileformats/mp4/parser/include/mediaatom.h
+++ b/fileformats/mp4/parser/include/mediaatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -377,6 +377,20 @@
             }
         }
 
+        uint16 getLanguageCode()
+        {
+            if (_pmediaHeader != NULL)
+            {
+                return _pmediaHeader->getLanguage();
+            }
+            else
+            {
+                return (0xFFFF);
+            }
+
+        }
+
+
         // From Handler
         uint32 getTrackStreamType()
         {
@@ -429,16 +443,11 @@
             }
         }
 
-        OSCL_wHeapString<OsclMemAllocator> getMIMEType()
+        void getMIMEType(OSCL_String& aMimeType)
         {
             if (_pmediaInformation != NULL)
             {
-                return _pmediaInformation->getMIMEType();
-            }
-            else
-            {
-                OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("UNKNOWN"));
-                return temp;
+                _pmediaInformation->getMIMEType(aMimeType);
             }
         }
 
diff --git a/fileformats/mp4/parser/include/mediabuffer.h b/fileformats/mp4/parser/include/mediabuffer.h
index 9d33598..4dda4b5 100644
--- a/fileformats/mp4/parser/include/mediabuffer.h
+++ b/fileformats/mp4/parser/include/mediabuffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/mediabuffermanager.h b/fileformats/mp4/parser/include/mediabuffermanager.h
index 9ad7dfa..3f2cf82 100644
--- a/fileformats/mp4/parser/include/mediabuffermanager.h
+++ b/fileformats/mp4/parser/include/mediabuffermanager.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/mediadataatom.h b/fileformats/mp4/parser/include/mediadataatom.h
index d7067cd..058a8d5 100644
--- a/fileformats/mp4/parser/include/mediadataatom.h
+++ b/fileformats/mp4/parser/include/mediadataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/mediaheaderatom.h b/fileformats/mp4/parser/include/mediaheaderatom.h
index 36a0e51..0a41126 100644
--- a/fileformats/mp4/parser/include/mediaheaderatom.h
+++ b/fileformats/mp4/parser/include/mediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/mediainformationatom.h b/fileformats/mp4/parser/include/mediainformationatom.h
index 04e8a59..a5dc5b2 100644
--- a/fileformats/mp4/parser/include/mediainformationatom.h
+++ b/fileformats/mp4/parser/include/mediainformationatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -410,16 +410,11 @@
             }
         }
 
-        OSCL_wHeapString<OsclMemAllocator> getMIMEType()
+        void getMIMEType(OSCL_String& aMimeType)
         {
             if (_psampleTableAtom != NULL)
             {
-                return _psampleTableAtom->getMIMEType();
-            }
-            else
-            {
-                OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("UNKNOWN"));
-                return temp;
+                _psampleTableAtom->getMIMEType(aMimeType);
             }
         }
 
diff --git a/fileformats/mp4/parser/include/mediainformationheaderatom.h b/fileformats/mp4/parser/include/mediainformationheaderatom.h
index 1a0bbd9..27a711a 100644
--- a/fileformats/mp4/parser/include/mediainformationheaderatom.h
+++ b/fileformats/mp4/parser/include/mediainformationheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/metadataatom.h b/fileformats/mp4/parser/include/metadataatom.h
index 842a81b..3b6afa7 100644
--- a/fileformats/mp4/parser/include/metadataatom.h
+++ b/fileformats/mp4/parser/include/metadataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-	This MetaDataAtom Class is used for Parsing, and Storing the tags from Meta data
-	of ITune M4A file.
-*/
-
 #ifndef METADATAATOM_H_INCLUDED
 #define METADATAATOM_H_INCLUDED
 
@@ -50,6 +44,16 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesTrackSubTitle() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesILSTAtom)
+                return _pITunesILSTAtom->getTrackSubTitle();
+            else
+                return temp;
+        }
+
+
         OSCL_wHeapString<OsclMemAllocator> getITunesArtist() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -59,6 +63,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesAlbumArtist() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesILSTAtom)
+                return _pITunesILSTAtom->getAlbumArtist();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesAlbum() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -137,6 +150,17 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesEncodedBy() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesILSTAtom)
+            {
+                return _pITunesILSTAtom->getEncodedBy();
+            }
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesWriter() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -182,6 +206,7 @@
                 return temp;
         }
 
+
         uint16 getITunesThisTrackNo() const
         {
             if (_pITunesILSTAtom)
@@ -206,6 +231,14 @@
                 return false;
         }
 
+        bool IsITunesContentRating() const
+        {
+            if (_pITunesILSTAtom)
+                return _pITunesILSTAtom->IsContentRating();
+            else
+                return false;
+        }
+
         uint16 getITunesBeatsPerMinute() const
         {
             if (_pITunesILSTAtom)
@@ -214,6 +247,7 @@
                 return 0;
         }
 
+
         PvmfApicStruct* getITunesImageData() const
         {
             if (_pITunesILSTAtom)
@@ -266,6 +300,25 @@
                 return 0;
         }
 
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDTrackNumberData() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesILSTAtom)
+                return _pITunesILSTAtom->getCDTrackNumberData();
+            else
+                return temp;
+        }
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDDB1Data() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pITunesILSTAtom)
+                return _pITunesILSTAtom->getCDDB1Data();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesLyrics() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -278,10 +331,7 @@
 
     private:
 
-
-
         HandlerAtom	*_pHdlrAtom;
-
         // User ilst Data
         ITunesILSTAtom* _pITunesILSTAtom;
         PVLogger *iLogger;
diff --git a/fileformats/mp4/parser/include/mfraoffsetatom.h b/fileformats/mp4/parser/include/mfraoffsetatom.h
index 327f1e8..27248ea 100644
--- a/fileformats/mp4/parser/include/mfraoffsetatom.h
+++ b/fileformats/mp4/parser/include/mfraoffsetatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/movieatom.h b/fileformats/mp4/parser/include/movieatom.h
index 7e14c82..679fcd8 100644
--- a/fileformats/mp4/parser/include/movieatom.h
+++ b/fileformats/mp4/parser/include/movieatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,6 +77,7 @@
 #include "movieextendsatom.h"
 #endif
 
+
 class AVCSampleEntry;
 /*
 Class Movie Atom
@@ -231,7 +232,7 @@
 
         DecoderSpecificInfo *getTrackDecoderSpecificInfoAtSDI(uint32 trackID, uint32 index);
 
-        OSCL_wHeapString<OsclMemAllocator> getTrackMIMEType(uint32 id);
+        void getTrackMIMEType(uint32 id, OSCL_String& aMimeType);
 
         int32 getTrackMaxBufferSizeDB(uint32 id);
 
@@ -299,6 +300,16 @@
                 return 0;
             }
         }
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesDescription() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pUserDataAtom)
+                return _pUserDataAtom->getITunesDescription();
+            else
+                return temp;
+        }
+
         int32 getNumAssetInfoPerformerAtoms()
         {
             if (_pUserDataAtom != NULL)
@@ -489,6 +500,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesTrackSubTitle() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pUserDataAtom)
+                return _pUserDataAtom->getITunesTrackSubTitle();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesArtist() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -498,6 +518,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesAlbumArtist() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pUserDataAtom)
+                return _pUserDataAtom->getITunesAlbumArtist();
+            else
+                return temp;
+        }
+
 
         OSCL_wHeapString<OsclMemAllocator> getITunesAlbum() const
         {
@@ -577,6 +606,17 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesEncodedBy() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pUserDataAtom)
+            {
+                return _pUserDataAtom->getITunesEncodedBy();
+            }
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesWriter() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -613,14 +653,6 @@
                 return temp;
         }
 
-        OSCL_wHeapString<OsclMemAllocator> getITunesDescription() const
-        {
-            OSCL_wHeapString<OsclMemAllocator> temp;
-            if (_pUserDataAtom)
-                return _pUserDataAtom->getITunesDescription();
-            else
-                return temp;
-        }
 
         uint16 getITunesThisTrackNo() const
         {
@@ -646,6 +678,14 @@
                 return false;
         }
 
+        bool IsITunesContentRating() const
+        {
+            if (_pUserDataAtom)
+                return _pUserDataAtom->IsITunesContentRating();
+            else
+                return false;
+        }
+
         uint16 getITunesBeatsPerMinute() const
         {
             if (_pUserDataAtom)
@@ -654,6 +694,7 @@
                 return 0;
         }
 
+
         PvmfApicStruct* getITunesImageData() const
         {
             if (_pUserDataAtom)
@@ -708,6 +749,25 @@
                 return 0;
         }
 
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDTrackNumberData() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pUserDataAtom)
+                return _pUserDataAtom->getITunesCDTrackNumberData();
+            else
+                return temp;
+        }
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDDB1Data() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pUserDataAtom)
+                return _pUserDataAtom->getITunesCDDB1Data();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesLyrics() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -717,8 +777,6 @@
                 return temp;
         }
 
-
-
     private:
         void addTrackAtom(TrackAtom *a);
 
@@ -738,6 +796,8 @@
         bool _oVideoTrackPresent;
 
         OSCL_wHeapString<OsclMemAllocator> _emptyString;
+
+
 };
 
 #endif // MOVIEATOM_H_INCLUDED
diff --git a/fileformats/mp4/parser/include/movieextendsatom.h b/fileformats/mp4/parser/include/movieextendsatom.h
index 69845b9..b9a7538 100644
--- a/fileformats/mp4/parser/include/movieextendsatom.h
+++ b/fileformats/mp4/parser/include/movieextendsatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/movieextendsheaderatom.h b/fileformats/mp4/parser/include/movieextendsheaderatom.h
index 634cc11..eba92f5 100644
--- a/fileformats/mp4/parser/include/movieextendsheaderatom.h
+++ b/fileformats/mp4/parser/include/movieextendsheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/moviefragmentatom.h b/fileformats/mp4/parser/include/moviefragmentatom.h
index eb91cb1..9bf41a2 100644
--- a/fileformats/mp4/parser/include/moviefragmentatom.h
+++ b/fileformats/mp4/parser/include/moviefragmentatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/moviefragmentheaderatom.h b/fileformats/mp4/parser/include/moviefragmentheaderatom.h
index 44834ea..3c8049a 100644
--- a/fileformats/mp4/parser/include/moviefragmentheaderatom.h
+++ b/fileformats/mp4/parser/include/moviefragmentheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/moviefragmentrandomaccess.h b/fileformats/mp4/parser/include/moviefragmentrandomaccess.h
index 3b125a2..8c40fff 100644
--- a/fileformats/mp4/parser/include/moviefragmentrandomaccess.h
+++ b/fileformats/mp4/parser/include/moviefragmentrandomaccess.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/movieheaderatom.h b/fileformats/mp4/parser/include/movieheaderatom.h
index a89eadf..e4a92d4 100644
--- a/fileformats/mp4/parser/include/movieheaderatom.h
+++ b/fileformats/mp4/parser/include/movieheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/mpeg4file.h b/fileformats/mp4/parser/include/mpeg4file.h
index 99c55ce..f111206 100644
--- a/fileformats/mp4/parser/include/mpeg4file.h
+++ b/fileformats/mp4/parser/include/mpeg4file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,6 +92,8 @@
 #include "pv_id3_parcom.h"
 #endif
 
+#define ID3V1_STR_MAX_SIZE 64
+
 class AVCSampleEntry;
 
 class Mpeg4File : public IMpeg4File, public Parentable
@@ -330,6 +332,7 @@
         // From MediaHeader
         uint64 getTrackMediaDuration(uint32 id);
         uint32 getTrackMediaTimescale(uint32 id);
+        uint16 getTrackLangCode(uint32 id);
 
         // From Handler
         uint32 getTrackMediaType(uint32 id);
@@ -337,8 +340,7 @@
         // From SampleDescription
         int32 getTrackNumSampleEntries(uint32 id);
 
-        OSCL_wHeapString<OsclMemAllocator> getTrackMIMEType(uint32 id); // Based on OTI value
-        uint8  getTrackOTIType(uint32 id); // Based on OTI value
+        void getTrackMIMEType(uint32 id, OSCL_String& aMimeType); // Based on OTI value
 
         int32 getTrackMaxBufferSizeDB(uint32 id);
         int32 getTrackAverageBitrate(uint32 id);
@@ -378,6 +380,16 @@
         {
             return _pmovieAtom->getAlternateGroup(trackid);
         }
+        int32 getVideoFrameHeight(uint32 trackid)
+        {
+            return _pmovieAtom->getTrackHeight(trackid);
+        }
+
+        int32 getVideoFrameWidth(uint32 trackid)
+        {
+            return _pmovieAtom->getTrackWidth(trackid);
+        }
+
         int32 getTextTrackWidth(uint32 trackid)
         {
             return _pmovieAtom->getTextTrackWidth(trackid);
@@ -867,6 +879,18 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesAlbumArtist() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
+            if (_pmovieAtom != NULL)
+            {
+                return _pmovieAtom->getITunesAlbumArtist();
+
+            }
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesTitle() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
@@ -880,6 +904,19 @@
 
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesTrackSubTitle() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
+            if (_pmovieAtom != NULL)
+            {
+                return _pmovieAtom->getITunesTrackSubTitle();
+
+            }
+            else
+                return temp;
+
+        }
+
 
         OSCL_wHeapString<OsclMemAllocator> getITunesAlbum() const
         {
@@ -971,6 +1008,19 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesEncodedBy() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
+
+            if (_pmovieAtom != NULL)
+            {
+
+                return _pmovieAtom->getITunesEncodedBy();
+            }
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesWriter() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
@@ -1069,6 +1119,17 @@
                 return false;
         }
 
+        bool IsITunesContentRating() const
+        {
+            if (_pmovieAtom != NULL)
+            {
+
+                return _pmovieAtom->IsITunesContentRating();
+            }
+            else
+                return false;
+        }
+
         uint16 getITunesBeatsPerMinute() const
         {
             if (_pmovieAtom != NULL)
@@ -1080,6 +1141,7 @@
                 return 0;
         }
 
+
         PvmfApicStruct* getITunesImageData() const
         {
             if (_pmovieAtom)
@@ -1150,6 +1212,34 @@
         }
 
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDTrackNumberData() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
+
+            if (_pmovieAtom != NULL)
+            {
+                return _pmovieAtom->getITunesCDTrackNumberData();
+
+            }
+            else
+                return temp;
+
+        }
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDDB1Data() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
+
+            if (_pmovieAtom != NULL)
+            {
+                return _pmovieAtom->getITunesCDDB1Data();
+
+            }
+            else
+                return temp;
+
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesLyrics() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT(""));
@@ -1163,7 +1253,7 @@
                 return temp;
         }
 
-
+        // For DRM Atom.
         bool IsTFRAPresentForTrack(uint32 TrackId, bool oVideoAudioTextTrack);
 
         /*
@@ -1185,8 +1275,16 @@
         void parseID3Header(MP4_FF_FILE * aFile);
 
         uint32 getContentType();
+        bool CreateDataStreamSessionForExternalDownload(OSCL_wString& aFilename,
+                PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
+                OsclFileHandle* aHandle,
+                Oscl_FileServer* aFileServSession);
+        void DestroyDataStreamForExternalDownload();
+
 
     private:
+        void ReserveMemoryForLangCodeVector(Oscl_Vector<uint16, OsclMemAllocator> &iLangCode, int32 capacity, int32 &leavecode);
+        void ReserveMemoryForValuesVector(Oscl_Vector<OSCL_wHeapString<OsclMemAllocator>, OsclMemAllocator> &iValues, int32 capacity, int32 &leavecode);
         OSCL_wHeapString<OsclMemAllocator> _emptyString;
         UserDataAtom *_puserDataAtom;
         FileTypeAtom *_pFileTypeAtom;
@@ -1237,6 +1335,7 @@
         uint32 _peekMovieFragmentSeqIdx[256];
         bool isResetPlayBackCalled;
         uint32 countOfTrunsParsed;
+
         //Master Title List
         Oscl_Vector<OSCL_wHeapString<OsclMemAllocator>, OsclMemAllocator> titleValues;
         Oscl_Vector<uint16, OsclMemAllocator> iTitleLangCode;
@@ -1285,6 +1384,12 @@
         Oscl_Vector<uint16, OsclMemAllocator> iRatingLangCode;
         Oscl_Vector<MP4FFParserOriginalCharEnc, OsclMemAllocator> iRatingCharType;
 
+        oscl_wchar _id3v1Title[ID3V1_STR_MAX_SIZE];
+        oscl_wchar _id3v1Album[ID3V1_STR_MAX_SIZE];
+        oscl_wchar _id3v1Artist[ID3V1_STR_MAX_SIZE];
+        oscl_wchar _id3v1Comment[ID3V1_STR_MAX_SIZE];
+        uint32 _id3v1Year;
+        uint32 _fileSize;
 
 };
 
diff --git a/fileformats/mp4/parser/include/mpeg4mediaheaderatom.h b/fileformats/mp4/parser/include/mpeg4mediaheaderatom.h
index 6790225..9fce79a 100644
--- a/fileformats/mp4/parser/include/mpeg4mediaheaderatom.h
+++ b/fileformats/mp4/parser/include/mpeg4mediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/mpeg4sampleentryextensions.h b/fileformats/mp4/parser/include/mpeg4sampleentryextensions.h
index 54875af..6c63914 100644
--- a/fileformats/mp4/parser/include/mpeg4sampleentryextensions.h
+++ b/fileformats/mp4/parser/include/mpeg4sampleentryextensions.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
 #ifndef __MPEG4SampleEntryExtensions_H__
 #define __MPEG4SampleEntryExtensions_H__
 
diff --git a/fileformats/mp4/parser/include/mpegsampleentry.h b/fileformats/mp4/parser/include/mpegsampleentry.h
index accef23..486de6d 100644
--- a/fileformats/mp4/parser/include/mpegsampleentry.h
+++ b/fileformats/mp4/parser/include/mpegsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/objectdescriptor.h b/fileformats/mp4/parser/include/objectdescriptor.h
index c97bb3e..d37c90c 100644
--- a/fileformats/mp4/parser/include/objectdescriptor.h
+++ b/fileformats/mp4/parser/include/objectdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/objectdescriptoratom.h b/fileformats/mp4/parser/include/objectdescriptoratom.h
index cf3ba29..9036aff 100644
--- a/fileformats/mp4/parser/include/objectdescriptoratom.h
+++ b/fileformats/mp4/parser/include/objectdescriptoratom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/oma2boxes.h b/fileformats/mp4/parser/include/oma2boxes.h
index 0c14bfb..66efa92 100644
--- a/fileformats/mp4/parser/include/oma2boxes.h
+++ b/fileformats/mp4/parser/include/oma2boxes.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/parentable.h b/fileformats/mp4/parser/include/parentable.h
index 8c60219..8c03318 100644
--- a/fileformats/mp4/parser/include/parentable.h
+++ b/fileformats/mp4/parser/include/parentable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/paspatom.h b/fileformats/mp4/parser/include/paspatom.h
index f713283..4a05221 100644
--- a/fileformats/mp4/parser/include/paspatom.h
+++ b/fileformats/mp4/parser/include/paspatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/pvuserdataatom.h b/fileformats/mp4/parser/include/pvuserdataatom.h
index e3a3a61..b84472e 100644
--- a/fileformats/mp4/parser/include/pvuserdataatom.h
+++ b/fileformats/mp4/parser/include/pvuserdataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/renderable.h b/fileformats/mp4/parser/include/renderable.h
index d792d15..ec44eec 100644
--- a/fileformats/mp4/parser/include/renderable.h
+++ b/fileformats/mp4/parser/include/renderable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/sampledescriptionatom.h b/fileformats/mp4/parser/include/sampledescriptionatom.h
index ad84b09..418c265 100644
--- a/fileformats/mp4/parser/include/sampledescriptionatom.h
+++ b/fileformats/mp4/parser/include/sampledescriptionatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -111,7 +111,7 @@
         // Getting and setting the Mpeg4 VOL header
         DecoderSpecificInfo *getDecoderSpecificInfo(uint32 index);
 
-        OSCL_wHeapString<OsclMemAllocator> getMIMEType();//Move to SampleDescription.cpp
+        void getMIMEType(OSCL_String& aMimeType);//Move to SampleDescription.cpp
 
         uint8  getObjectTypeIndication();
 
diff --git a/fileformats/mp4/parser/include/sampleentry.h b/fileformats/mp4/parser/include/sampleentry.h
index 1e5c1de..59e2e01 100644
--- a/fileformats/mp4/parser/include/sampleentry.h
+++ b/fileformats/mp4/parser/include/sampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/samplesizeatom.h b/fileformats/mp4/parser/include/samplesizeatom.h
index f37b70f..4d3d487 100644
--- a/fileformats/mp4/parser/include/samplesizeatom.h
+++ b/fileformats/mp4/parser/include/samplesizeatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@
             return _maxSampleSize;
         }
 
-        bool _firstSampleOnBkwdRepos;
+        bool _SkipOldEntry;
 
     private:
         bool ParseEntryUnit(uint32 sample_cnt);
diff --git a/fileformats/mp4/parser/include/sampletableatom.h b/fileformats/mp4/parser/include/sampletableatom.h
index 499de6f..8038227 100644
--- a/fileformats/mp4/parser/include/sampletableatom.h
+++ b/fileformats/mp4/parser/include/sampletableatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -263,15 +263,11 @@
             }
         }
 
-        OSCL_wHeapString<OsclMemAllocator> getMIMEType()
+        void getMIMEType(OSCL_String& aMimeType)
         {
             if (_psampleDescriptionAtom != NULL)
             {
-                return _psampleDescriptionAtom->getMIMEType();
-            }
-            else
-            {
-                return _defaultMimeType;
+                _psampleDescriptionAtom->getMIMEType(aMimeType);
             }
         }
 
@@ -585,6 +581,7 @@
         int32  _amrFrameTimeStamp;
         int32  _amrSampleSize;
 
+        uint32 SamplesCount;
         MP4_FF_FILE *_commonFilePtr;
 
         bool _oPVContentDownloadable;
diff --git a/fileformats/mp4/parser/include/sampletochunkatom.h b/fileformats/mp4/parser/include/sampletochunkatom.h
index 7182055..98799ec 100644
--- a/fileformats/mp4/parser/include/sampletochunkatom.h
+++ b/fileformats/mp4/parser/include/sampletochunkatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -121,6 +121,7 @@
         int32 _maxChunkDataSize;
 
         uint32 _Index;
+
         int32 _numChunksInRun;
         int32 _majorGetIndex;
         int32 _currGetChunk;
diff --git a/fileformats/mp4/parser/include/shadowsyncsampleatom.h b/fileformats/mp4/parser/include/shadowsyncsampleatom.h
index 1435c69..6f9fa6e 100644
--- a/fileformats/mp4/parser/include/shadowsyncsampleatom.h
+++ b/fileformats/mp4/parser/include/shadowsyncsampleatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/slconfigdescriptor.h b/fileformats/mp4/parser/include/slconfigdescriptor.h
index a43d440..b321ecf 100644
--- a/fileformats/mp4/parser/include/slconfigdescriptor.h
+++ b/fileformats/mp4/parser/include/slconfigdescriptor.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,6 +44,7 @@
         virtual ~SLConfigDescriptor();
 
         // ALL the member gets and sets
+
         bool getUseAccessUnitStartFlag() const
         {
             return _useAccessUnitStartFlag;
@@ -178,6 +179,7 @@
         uint64 _startDecodingTimeStamp; // (_timeStampLength)
         uint64 _startCompositionTimeStamp; // (_timeStampLength)
 
+
         // Combine into a single byte when rendering to a stream
         bool _OCRStreamFlag; // (1)
         uint8 _reserved2; // = 0b1111111; // (7)
diff --git a/fileformats/mp4/parser/include/soundmediaheaderatom.h b/fileformats/mp4/parser/include/soundmediaheaderatom.h
index b6a8f60..1d9af2c 100644
--- a/fileformats/mp4/parser/include/soundmediaheaderatom.h
+++ b/fileformats/mp4/parser/include/soundmediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/stylerecord.h b/fileformats/mp4/parser/include/stylerecord.h
index 6a27ab9..61d9c7b 100644
--- a/fileformats/mp4/parser/include/stylerecord.h
+++ b/fileformats/mp4/parser/include/stylerecord.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/syncsampleatom.h b/fileformats/mp4/parser/include/syncsampleatom.h
index 1f7854f..0b234cd 100644
--- a/fileformats/mp4/parser/include/syncsampleatom.h
+++ b/fileformats/mp4/parser/include/syncsampleatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/textsampleentry.h b/fileformats/mp4/parser/include/textsampleentry.h
index 5a2fdfa..2ebcfd7 100644
--- a/fileformats/mp4/parser/include/textsampleentry.h
+++ b/fileformats/mp4/parser/include/textsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/textsamplemodifiers.h b/fileformats/mp4/parser/include/textsamplemodifiers.h
index 470bfd6..68725a0 100644
--- a/fileformats/mp4/parser/include/textsamplemodifiers.h
+++ b/fileformats/mp4/parser/include/textsamplemodifiers.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,16 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*     -------------------------------------------------------------------       */
-/*                        MPEG-4 TextSampleEntry Class                           */
-/*     -------------------------------------------------------------------       */
-/*********************************************************************************/
-/*
-    This TextSampleEntry Class is used for text streams.
-*/
-
-
 #ifndef __TextSampleModifiers_H__
 #define __TextSampleModifiers_H__
 
diff --git a/fileformats/mp4/parser/include/timetosampleatom.h b/fileformats/mp4/parser/include/timetosampleatom.h
index ee2c71c..b2515eb 100644
--- a/fileformats/mp4/parser/include/timetosampleatom.h
+++ b/fileformats/mp4/parser/include/timetosampleatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -101,6 +101,7 @@
         uint32 _next_buff_number;
 
         uint32	_parsed_entry_cnt;
+
         uint32 _currGetSampleCount;
         int32 _currGetIndex;
         int32 _currGetTimeDelta;
diff --git a/fileformats/mp4/parser/include/trackatom.h b/fileformats/mp4/parser/include/trackatom.h
index d3bae47..4ffcfc1 100644
--- a/fileformats/mp4/parser/include/trackatom.h
+++ b/fileformats/mp4/parser/include/trackatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -292,6 +292,7 @@
             }
         }
 
+
         // Returns the timestamp  from the last video sample
         // This is mainly to be used when seeking in the bitstream - you request a video frame at timestamp
         // X, but the actual frame you get is Y, this method returns the timestamp for Y so you know which
@@ -417,6 +418,21 @@
             }
         }
 
+        uint16 getLanguageCode()
+        {
+            if (_pmediaAtom != NULL)
+            {
+                return _pmediaAtom->getLanguageCode();
+            }
+            else
+            {
+                //RETURN SOME UNDEFINED VALUE
+                return (0xFFFF);
+            }
+
+        }
+
+
         // From mediaAtom -> Handler
         uint32 getTrackStreamType()
         {
@@ -443,16 +459,11 @@
             }
         }
 
-        OSCL_wHeapString<OsclMemAllocator> getMIMEType()
+        void getMIMEType(OSCL_String& aMimeType)
         {
             if (_pmediaAtom != NULL)
             {
-                return _pmediaAtom->getMIMEType();
-            }
-            else
-            {
-                OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("UNKNOWN"));
-                return temp;
+                _pmediaAtom->getMIMEType(aMimeType);
             }
         } // Based on OTI value
 
diff --git a/fileformats/mp4/parser/include/trackextendsatom.h b/fileformats/mp4/parser/include/trackextendsatom.h
index a7fb7e4..d1d108c 100644
--- a/fileformats/mp4/parser/include/trackextendsatom.h
+++ b/fileformats/mp4/parser/include/trackextendsatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackfragmentatom.h b/fileformats/mp4/parser/include/trackfragmentatom.h
index e8deee1..f6f978c 100644
--- a/fileformats/mp4/parser/include/trackfragmentatom.h
+++ b/fileformats/mp4/parser/include/trackfragmentatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackfragmentheaderatom.h b/fileformats/mp4/parser/include/trackfragmentheaderatom.h
index 6bc62ee..c31b8c6 100644
--- a/fileformats/mp4/parser/include/trackfragmentheaderatom.h
+++ b/fileformats/mp4/parser/include/trackfragmentheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackfragmentrandomaccess.h b/fileformats/mp4/parser/include/trackfragmentrandomaccess.h
index 2294b66..1211bb0 100644
--- a/fileformats/mp4/parser/include/trackfragmentrandomaccess.h
+++ b/fileformats/mp4/parser/include/trackfragmentrandomaccess.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackfragmentrunatom.h b/fileformats/mp4/parser/include/trackfragmentrunatom.h
index 3c2485c..4c8d142 100644
--- a/fileformats/mp4/parser/include/trackfragmentrunatom.h
+++ b/fileformats/mp4/parser/include/trackfragmentrunatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackheaderatom.h b/fileformats/mp4/parser/include/trackheaderatom.h
index a5278f3..0d03a2c 100644
--- a/fileformats/mp4/parser/include/trackheaderatom.h
+++ b/fileformats/mp4/parser/include/trackheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackreferenceatom.h b/fileformats/mp4/parser/include/trackreferenceatom.h
index fe4524a..1b3a086 100644
--- a/fileformats/mp4/parser/include/trackreferenceatom.h
+++ b/fileformats/mp4/parser/include/trackreferenceatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/trackreferencetypeatom.h b/fileformats/mp4/parser/include/trackreferencetypeatom.h
index 88c51df..bb1b5dd 100644
--- a/fileformats/mp4/parser/include/trackreferencetypeatom.h
+++ b/fileformats/mp4/parser/include/trackreferencetypeatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/userdataatom.h b/fileformats/mp4/parser/include/userdataatom.h
index e80aeb4..55a0395 100644
--- a/fileformats/mp4/parser/include/userdataatom.h
+++ b/fileformats/mp4/parser/include/userdataatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -224,6 +224,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesTrackSubTitle() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pMetaDataAtom)
+                return _pMetaDataAtom->getITunesTrackSubTitle();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesArtist() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -233,6 +242,15 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesAlbumArtist() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pMetaDataAtom)
+                return _pMetaDataAtom->getITunesAlbumArtist();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesAlbum() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -311,6 +329,17 @@
                 return temp;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesEncodedBy() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pMetaDataAtom)
+            {
+                return _pMetaDataAtom->getITunesEncodedBy();
+            }
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesWriter() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -380,6 +409,14 @@
                 return false;
         }
 
+        bool IsITunesContentRating() const
+        {
+            if (_pMetaDataAtom)
+                return _pMetaDataAtom->IsITunesContentRating();
+            else
+                return false;
+        }
+
         uint16 getITunesBeatsPerMinute() const
         {
             if (_pMetaDataAtom)
@@ -441,6 +478,24 @@
                 return 0;
         }
 
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDTrackNumberData() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pMetaDataAtom)
+                return _pMetaDataAtom->getITunesCDTrackNumberData();
+            else
+                return temp;
+        }
+
+        OSCL_wHeapString<OsclMemAllocator> getITunesCDDB1Data() const
+        {
+            OSCL_wHeapString<OsclMemAllocator> temp;
+            if (_pMetaDataAtom)
+                return _pMetaDataAtom->getITunesCDDB1Data();
+            else
+                return temp;
+        }
+
         OSCL_wHeapString<OsclMemAllocator> getITunesLyrics() const
         {
             OSCL_wHeapString<OsclMemAllocator> temp;
@@ -451,6 +506,7 @@
         }
 
 
+
         AssetInfoTitleAtom          *getAssetInfoTitleAtomAt(int32 index);
         AssetInfoDescAtom           *getAssetInfoDescAtomAt(int32 index);
         CopyRightAtom	            *getCopyRightAtomAt(int32 index);
diff --git a/fileformats/mp4/parser/include/videomediaheaderatom.h b/fileformats/mp4/parser/include/videomediaheaderatom.h
index 130045f..fff87d7 100644
--- a/fileformats/mp4/parser/include/videomediaheaderatom.h
+++ b/fileformats/mp4/parser/include/videomediaheaderatom.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/include/visualsampleentry.h b/fileformats/mp4/parser/include/visualsampleentry.h
index 2aa3070..5589596 100644
--- a/fileformats/mp4/parser/include/visualsampleentry.h
+++ b/fileformats/mp4/parser/include/visualsampleentry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/3gpp_amrdecoderspecificinfo.cpp b/fileformats/mp4/parser/src/3gpp_amrdecoderspecificinfo.cpp
index a9ecc5e..0b49b78 100644
--- a/fileformats/mp4/parser/src/3gpp_amrdecoderspecificinfo.cpp
+++ b/fileformats/mp4/parser/src/3gpp_amrdecoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/3gpp_h263decoderspecificinfo.cpp b/fileformats/mp4/parser/src/3gpp_h263decoderspecificinfo.cpp
index 2a86e71..7937dad 100644
--- a/fileformats/mp4/parser/src/3gpp_h263decoderspecificinfo.cpp
+++ b/fileformats/mp4/parser/src/3gpp_h263decoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/amrdecoderspecificinfo.cpp b/fileformats/mp4/parser/src/amrdecoderspecificinfo.cpp
index 489544b..e8dc6df 100644
--- a/fileformats/mp4/parser/src/amrdecoderspecificinfo.cpp
+++ b/fileformats/mp4/parser/src/amrdecoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,33 @@
 
     if (o3GPPTrack)
     {
+#if 0
+        AtomUtils::read32(fp, _VendorCode);
 
+        AtomUtils::read8(fp, _codec_version);
+
+        AtomUtils::read16(fp, _mode_set);
+
+        AtomUtils::read8(fp, _3gpp_mode_change_period);
+
+        AtomUtils::read8(fp, _frames_per_sample);
+
+        /*
+         * Currently no mode switching in 3GPP AMR Tracks is supported
+         */
+        const uint16 aModeSet[9] = {0x0001, 0x0002, 0x0004, 0x0008,
+                                    0x0010, 0x0020, 0x0040, 0x0080,
+                                    0x0100
+                                   };
+
+        for (int8 i = 0; i < 9; i++)
+        {
+            if (_mode_set == aModeSet[i])
+            {
+                _frame_type = i;
+            }
+        }
+#endif
     }
     else
     {
diff --git a/fileformats/mp4/parser/src/amrsampleentry.cpp b/fileformats/mp4/parser/src/amrsampleentry.cpp
index 370fa9b..9fcc608 100644
--- a/fileformats/mp4/parser/src/amrsampleentry.cpp
+++ b/fileformats/mp4/parser/src/amrsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/assetinfoatoms.cpp b/fileformats/mp4/parser/src/assetinfoatoms.cpp
index bbb24c6..2d67348 100644
--- a/fileformats/mp4/parser/src/assetinfoatoms.cpp
+++ b/fileformats/mp4/parser/src/assetinfoatoms.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,9 +40,9 @@
 	characters[0] = (num & 0xFF000000)>>24; \
 }
 
-typedef Oscl_Vector<AssetInfoKeyWord*, OsclMemAllocator> assetInfoKeyWordVecType;
+typedef Oscl_Vector<AssestInfoKeyWord*, OsclMemAllocator> assestInfoKeyWordVecType;
 
-AssetInfoBaseParser::AssetInfoBaseParser(MP4_FF_FILE *fp,
+AssestInfoBaseParser::AssestInfoBaseParser(MP4_FF_FILE *fp,
         uint32 size,
         uint32 sizeofDataFieldBeforeString)
 {
@@ -80,156 +80,22 @@
             return;
         }
 
-        uint32 temp = AtomUtils::peekNextNthBytes(fp, 1);
+        uint32 delta = (size - _count);
 
-        uint16 byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
-
-        if (byteOrderMask == BYTE_ORDER_MASK)
+        if (delta > 0)
         {
-            _charType = ORIGINAL_CHAR_TYPE_UTF16;
-            if (!AtomUtils::read16(fp, byteOrderMask))
+            if (!AtomUtils::readString(fp, delta, _charType , _infoNotice))
             {
+                //error
                 _success = false;
                 return;
             }
-
-            _count += 2;
-
-            // Check to see if the string is actually null-terminated
-            uint32 delta = (size - _count);
-
-            int32 filePos = AtomUtils::getCurrentFilePosition(fp);
-
-            AtomUtils::seekFromCurrPos(fp, (delta - 2));
-
-            uint16 strEnd = 0;
-
-            if (!AtomUtils::read16(fp, strEnd))
-            {
-                _success = false;
-                return;
-            }
-
-            if (strEnd == 0)
-            {
-                AtomUtils::seekFromStart(fp, filePos);
-
-                if (!AtomUtils::readNullTerminatedUnicodeString(fp, _infoNotice))
-                {
-                    _success = false;
-                    return;
-                }
-                {
-                    int32 newfilePos = AtomUtils::getCurrentFilePosition(fp);
-                    if (newfilePos != (int32)(filePos + delta))
-                    {
-                        AtomUtils::seekFromStart(fp, filePos + delta);
-                    }
-                }
-            }
-            else
-            {
-                uint32 dataLengthInBytes = delta * 2;
-                uint8* str = (uint8 *)oscl_malloc(dataLengthInBytes);
-                if (!str)
-                {
-                    _success = false;
-                    return;
-                }
-                AtomUtils::seekFromStart(fp, filePos);
-                if (!AtomUtils::readByteData(fp, dataLengthInBytes, (uint8 *)str))
-                {
-                    _success = false;
-                    oscl_free(str);
-                    return;
-                }
-                oscl_wchar *temp = (oscl_wchar *)oscl_malloc(dataLengthInBytes + 2);;
-                if (!temp)
-                {
-                    _success = false;
-                    oscl_free(str);
-                    return;
-                }
-
-                oscl_memcpy(temp, str, dataLengthInBytes);
-
-                OSCL_wHeapString<OsclMemAllocator> NoticeStr(temp);
-                _infoNotice = NoticeStr;
-                oscl_free(str);
-                oscl_free(temp);
-            }
-
             _count += delta;
         }
         else
         {
-            _charType = ORIGINAL_CHAR_TYPE_UTF8;
-            // Check to see if the string is actually null-terminated
-            uint32 delta = (size - _count);
-
-            int32 filePos = AtomUtils::getCurrentFilePosition(fp);
-
-            AtomUtils::seekFromCurrPos(fp, (delta - 1));
-
-            uint8 strEnd = 0;
-
-            if (!AtomUtils::read8(fp, strEnd))
-            {
-                _success = false;
-                return;
-            }
-
-            if (strEnd == 0)
-            {
-                AtomUtils::seekFromStart(fp, filePos);
-
-                if (!AtomUtils::readNullTerminatedString(fp, _infoNotice))
-                {
-                    _success = false;
-                    return;
-                }
-                {
-                    int32 newfilePos = AtomUtils::getCurrentFilePosition(fp);
-                    if (newfilePos != (int32)(filePos + delta))
-                    {
-                        AtomUtils::seekFromStart(fp, filePos + delta);
-                    }
-                }
-            }
-            else
-            {
-                uint32 dataLengthInBytes = delta;
-                uint8* str = (uint8 *)oscl_malloc(dataLengthInBytes);
-                if (!str)
-                {
-                    _success = false;
-                    return;
-                }
-
-                AtomUtils::seekFromStart(fp, filePos);
-                if (!AtomUtils::readByteData(fp, dataLengthInBytes, (uint8 *)str))
-                {
-                    _success = false;
-                    oscl_free(str);
-                    return;
-                }
-                oscl_wchar *temp = (oscl_wchar *)oscl_malloc(2 * (dataLengthInBytes + 1));;
-                if (!temp)
-                {
-                    _success = false;
-                    oscl_free(str);
-                    return;
-                }
-                oscl_UTF8ToUnicode((const char*)str, dataLengthInBytes, temp, 2*dataLengthInBytes);
-
-                OSCL_wHeapString<OsclMemAllocator> NoticeStr(temp);
-                _infoNotice = NoticeStr;
-
-                oscl_free(str);
-                oscl_free(temp);
-            }
-
-            _count += delta;
+            _charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
+            _infoNotice = NULL;
         }
 
         if (_count < size)
@@ -245,7 +111,7 @@
     {
         uint32 count = getDefaultSize();
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
 
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
@@ -267,7 +133,8 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
+
     }
 }
 
@@ -279,7 +146,7 @@
     {
         uint32 count = getDefaultSize();
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
 
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
@@ -301,7 +168,7 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
     }
 }
 
@@ -314,7 +181,7 @@
     {
         uint32 count = getDefaultSize();
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
 
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
@@ -336,7 +203,7 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
     }
 }
 
@@ -349,7 +216,7 @@
     {
         uint32 count = getDefaultSize();
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
 
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
@@ -371,7 +238,7 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
     }
 }
 
@@ -384,7 +251,7 @@
     {
         uint32 count = getDefaultSize();
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
 
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
@@ -406,7 +273,7 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
     }
 }
 
@@ -435,7 +302,7 @@
         }
         count += 4;
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
             _success = false;
@@ -446,6 +313,7 @@
 
         addnlratingInfo += _STRLIT_WCHAR(";rating-criteria=");
         char Criteria[4];
+        oscl_memset(Criteria, 0, 4*sizeof(char));
         UInt32ToFourChar(_ratingCriteria, Criteria);
         oscl_wchar wCriteria[5];
         oscl_UTF8ToUnicode(Criteria, 4, wCriteria, 5);
@@ -453,6 +321,7 @@
 
         addnlratingInfo += _STRLIT_WCHAR(";rating-entity=");
         char Entity[4];
+        oscl_memset(Entity, 0, 4);
         UInt32ToFourChar(_ratingEntity, Entity);
         oscl_wchar wEntity[5];
         oscl_UTF8ToUnicode(Entity, 4, wEntity, 5);
@@ -473,7 +342,7 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
     }
 }
 
@@ -502,7 +371,7 @@
         }
         count += 2;
 
-        PV_MP4_FF_NEW(fp->auditCB, AssetInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
+        PV_MP4_FF_NEW(fp->auditCB, AssestInfoBaseParser, (fp, (_size - count)), _pAssetInfoBaseParser);
 
         if (!(_pAssetInfoBaseParser->GetMP4Success()))
         {
@@ -514,6 +383,7 @@
 
         addnlclassificationInfo += _STRLIT_WCHAR(";classification-table=");
         char Table[4];
+        oscl_memset(Table, 0, 4);
         oscl_snprintf(Table, 4, _STRLIT_CHAR("%d"), _classificationTable);
         oscl_wchar wTable[5];
         oscl_UTF8ToUnicode(Table, 4, wTable, 5);
@@ -521,6 +391,7 @@
 
         addnlclassificationInfo += _STRLIT_WCHAR(";classification-entity=");
         char Entity[4];
+        oscl_memset(Entity, 0, 4);
         UInt32ToFourChar(_classificationEntity, Entity);
         oscl_wchar wEntity[5];
         oscl_UTF8ToUnicode(Entity, 4, wEntity, 5);
@@ -541,12 +412,12 @@
 {
     if (_pAssetInfoBaseParser != NULL)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoBaseParser, _pAssetInfoBaseParser);
+        PV_MP4_FF_DELETE(NULL, AssestInfoBaseParser, _pAssetInfoBaseParser);
     }
 };
 
 
-AssetInfoKeyWord::AssetInfoKeyWord(MP4_FF_FILE *fp)
+AssestInfoKeyWord::AssestInfoKeyWord(MP4_FF_FILE *fp)
 {
     int32 currfilePos = AtomUtils::getCurrentFilePosition(fp);
 
@@ -595,7 +466,7 @@
 {
     _pAssetInfoKeyWordVec = NULL;
 
-    PV_MP4_FF_NEW(fp->auditCB, assetInfoKeyWordVecType, (), _pAssetInfoKeyWordVec);
+    PV_MP4_FF_NEW(fp->auditCB, assestInfoKeyWordVecType, (), _pAssetInfoKeyWordVec);
 
     if (_success)
     {
@@ -619,9 +490,9 @@
 
         for (uint8 i = 0; i < _keyWordCount; i++)
         {
-            AssetInfoKeyWord * pAssetInfoKeyWord = NULL;
+            AssestInfoKeyWord * pAssetInfoKeyWord = NULL;
 
-            PV_MP4_FF_NEW(fp->auditCB, AssetInfoKeyWord, (fp), pAssetInfoKeyWord);
+            PV_MP4_FF_NEW(fp->auditCB, AssestInfoKeyWord, (fp), pAssetInfoKeyWord);
 
             if (pAssetInfoKeyWord == NULL)
             {
@@ -651,10 +522,10 @@
 {
     for (uint32 i = 0; i < _pAssetInfoKeyWordVec->size(); i++)
     {
-        PV_MP4_FF_DELETE(NULL, AssetInfoKeyWord, (*_pAssetInfoKeyWordVec)[i]);
+        PV_MP4_FF_DELETE(NULL, AssestInfoKeyWord, (*_pAssetInfoKeyWordVec)[i]);
         (*_pAssetInfoKeyWordVec)[i] = NULL;
     }
-    PV_MP4_FF_TEMPLATED_DELETE(NULL, assetInfoKeyWordVecType, Oscl_Vector, _pAssetInfoKeyWordVec);
+    PV_MP4_FF_TEMPLATED_DELETE(NULL, assestInfoKeyWordVecType, Oscl_Vector, _pAssetInfoKeyWordVec);
 };
 
 OSCL_wString& AssetInfoKeyWordAtom::getKeyWordAt(int32 index)
@@ -728,7 +599,7 @@
 
         PV_MP4_FF_ARRAY_NEW(NULL, oscl_wchar, _defaultNotice.get_size() + 1, _pLocationStruct->_location_name);
         oscl_strncpy(_pLocationStruct->_location_name, _defaultNotice.get_str(), _defaultNotice.get_size());
-        _pLocationStruct->_location_name[_defaultNotice.get_size()] = NULL;
+        _pLocationStruct->_location_name[_defaultNotice.get_size()] = 0;
 
         if (_defaultNotice.get_size() > size)
         {
@@ -814,7 +685,7 @@
         }
         PV_MP4_FF_ARRAY_NEW(NULL, oscl_wchar, _astronomical_body.get_size() + 1, _pLocationStruct->_astronomical_body);
         oscl_strncpy(_pLocationStruct->_astronomical_body, _astronomical_body.get_str(), _astronomical_body.get_size());
-        _pLocationStruct->_astronomical_body[_astronomical_body.get_size()] = NULL;
+        _pLocationStruct->_astronomical_body[_astronomical_body.get_size()] = 0;
 
         if (_astronomical_body.get_size() > size)
         {
@@ -860,7 +731,7 @@
         }
         PV_MP4_FF_ARRAY_NEW(NULL, oscl_wchar, _additional_notes.get_size() + 1, _pLocationStruct->_additional_notes);
         oscl_strncpy(_pLocationStruct->_additional_notes, _additional_notes.get_str(), _additional_notes.get_size());
-        _pLocationStruct->_additional_notes[_additional_notes.get_size()] = NULL;
+        _pLocationStruct->_additional_notes[_additional_notes.get_size()] = 0;
 
         if (_additional_notes.get_size() > size)
         {
@@ -932,7 +803,7 @@
                 _success = false;
                 return;
             }
-            count -= _defaultNotice.get_size() + 2;
+            count -= (_defaultNotice.get_size() + 1) * 2;
         }
         else
         {
@@ -955,14 +826,16 @@
 
             return;
         }
-
-        if (!AtomUtils::read8(fp, _trackNumber))
+        if (count > 0)
         {
-            _success = false;
-            _mp4ErrorCode = READ_UDTA_LOC_FAILED;
-            return;
+            if (!AtomUtils::read8(fp, _trackNumber))
+            {
+                _success = false;
+                _mp4ErrorCode = READ_UDTA_LOC_FAILED;
+                return;
+            }
+            count -= 1;
         }
-        count -= 1;
     }
     if (count > 0)
         AtomUtils::seekFromCurrPos(fp, count);
@@ -982,3 +855,4 @@
         }
     }
 }
+
diff --git a/fileformats/mp4/parser/src/atom.cpp b/fileformats/mp4/parser/src/atom.cpp
index 8abb86c..feed232 100644
--- a/fileformats/mp4/parser/src/atom.cpp
+++ b/fileformats/mp4/parser/src/atom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/atomutils.cpp b/fileformats/mp4/parser/src/atomutils.cpp
deleted file mode 100644
index b823ded..0000000
--- a/fileformats/mp4/parser/src/atomutils.cpp
+++ /dev/null
@@ -1,848 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*********************************************************************************/
-/*     -------------------------------------------------------------------       */
-/*                            MPEG-4 Atom Utils Class                            */
-/*     -------------------------------------------------------------------       */
-/*********************************************************************************/
-/*
-    This AtomUtils Class contains sime useful methods for operating on Atoms
-*/
-
-
-#define IMPLEMENT_AtomUtils
-#include "oscl_base.h"
-#include "oscl_int64_utils.h"
-#include "atomutils.h"
-#include "atomdefs.h"
-#include "oscl_utf8conv.h"
-
-// Read in the 64 bits byte by byte and take most significant byte first
-bool
-AtomUtils::read64(MP4_FF_FILE *fp, uint64 &data)
-{
-    const int32 N = 8;
-    uint8 bytes[N];
-    data = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32) fp->_pvfile.Read((void*)bytes, 1, N);
-
-    if (retVal < N)
-    {
-        return false;
-    }
-
-    uint32 low  = 0;
-    uint32 high = 0;
-
-    int32 i;
-    for (i = 0; i < N / 2; i++)
-    {
-        high = (high << 8) | bytes[i];
-    }
-    for (i = N / 2; i < N; i++)
-    {
-        low = (low << 8) | bytes[i];
-    }
-    Oscl_Int64_Utils::set_uint64(data, high, low);
-    return true;
-}
-
-
-// Read in the 32 bits byte by byte and take most significant byte first
-bool
-AtomUtils::read32(MP4_FF_FILE *fp, uint32 &data)
-{
-    const int32 N = 4;
-    uint8 bytes[N];
-    data = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-        return false;
-
-    for (int32 i = 0;i < N;i++)
-        data = (data << 8) | bytes[i];
-
-    return true;
-}
-
-// Read in the 32 bits byte by byte and take most significant byte first.
-// This is equivalent to two read32 calls.
-bool
-AtomUtils::read32read32(MP4_FF_FILE *fp, uint32 &data1, uint32 &data2)
-{
-    const int32 N = 8;
-    uint8 bytes[N];
-    data1 = 0;
-    data2 = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-        return false;
-
-    int32 i;
-    for (i = 0;i < 4;i++)
-        data1 = (data1 << 8) | bytes[i];
-
-    for (i = 4;i < 8;i++)
-        data2 = (data2 << 8) | bytes[i];
-
-    return true;
-}
-
-// Read in the 24 bits byte by byte and take most significant byte first
-bool
-AtomUtils::read24(MP4_FF_FILE *fp, uint32 &data)
-{
-    const int32 N = 3;
-    uint8 bytes[N];
-    data = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-        return false;
-
-    for (int32 i = 0;i < N;i++)
-        data = (data << 8) | bytes[i];
-
-    return true;
-}
-
-// Read in the 16 bits byte by byte and take most significant byte first
-bool
-AtomUtils::read16(MP4_FF_FILE *fp, uint16 &data)
-{
-    const int32 N = 2;
-    uint8 bytes[N];
-    data = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-        return false;
-
-    for (int32 i = 0;i < N;i++)
-        data = (uint16)((data << 8) | (uint16) bytes[i]);
-
-    return true;
-}
-
-// Read in the 16 bits byte by byte and take most significant byte first
-// This is equivalent to two read16 calls
-bool
-AtomUtils::read16read16(MP4_FF_FILE *fp, uint16 &data1, uint16 &data2)
-{
-    const int32 N = 4;
-    uint8 bytes[N];
-    data1 = 0;
-    data2 = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-        return false;
-
-    int32 i;
-    for (i = 0;i < 2;i++)
-        data1 = (uint16)((data1 << 8) | (uint16) bytes[i]);
-
-    for (i = 2;i < 4;i++)
-        data2 = (uint16)((data2 << 8) | (uint16) bytes[i]);
-
-    return true;
-}
-
-// Read in the 8 bit byte
-bool
-AtomUtils::read8(MP4_FF_FILE *fp, uint8 &data)
-{
-    data = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*) & data, 1, 1));
-
-    if (retVal < 1)
-        return false;
-
-    return true;
-}
-
-// Read in the 8 bit byte
-// This is equivalent to two read8 calls
-bool
-AtomUtils::read8read8(MP4_FF_FILE *fp, uint8 &data1, uint8 &data2)
-{
-    const int32 N = 2;
-    uint8 bytes[N];
-    data1 = 0;
-    data2 = 0;
-
-    int32 retVal = 0;
-
-    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
-
-    if (retVal < N)
-        return false;
-
-    data1 = bytes[0];
-    data2 = bytes[1];
-
-    return true;
-}
-// Read in a NULL terminated string byte by byte and take most significant byte first
-// and convert to a OSCL_wString
-bool
-AtomUtils::readNullTerminatedString(MP4_FF_FILE *fp, OSCL_wString& data)
-{
-    const int BUFSIZE = 1024;
-    uint8 buf[BUFSIZE];
-    int32 index = 0;
-
-    if (!AtomUtils::read8(fp, buf[index]))
-        return false;
-
-    bool nextChar = (buf[index] == 0) ? false : true;
-
-    while (nextChar && (index < BUFSIZE))
-    {
-        index++;
-
-        if (!AtomUtils::read8(fp, buf[index]))
-            return false;
-
-        nextChar = (buf[index] == 0) ? false : true;
-    }
-    // String buffer filled - now create OSCL_wString
-
-    uint8 outbuf[BUFSIZE*sizeof(OSCL_TCHAR)];
-    oscl_UTF8ToUnicode((const char *)buf, index, (OSCL_TCHAR *)outbuf, BUFSIZE);
-    OSCL_wHeapString<OsclMemAllocator> temp((const OSCL_TCHAR *)outbuf);
-
-    data = temp;
-    return true;
-}
-
-// Read in a NULL terminated UNICODE string byte by byte and take most significant byte first
-// and convert to a OSCL_wString
-bool
-AtomUtils::readNullTerminatedUnicodeString(MP4_FF_FILE *fp, OSCL_wString& data)
-{
-    const int BUFSIZE = 1024;
-    oscl_wchar buf[BUFSIZE];
-    int32 index = 0;
-
-    /*
-     * Offset is used in case in some platforms if the size of wchar is greater
-     * than 2, then we need to check the lower few bytes to see if the null character
-     * has been reached or not.
-     */
-
-    // Need to be careful of the byte-ordering when creating the wchar_t array
-    uint8 firstbyte;
-    uint8 secondbyte;
-
-    if (!AtomUtils::read8read8(fp, firstbyte, secondbyte))
-        return false;
-
-    // Allow the OS to do the bit shifting to get the correct byte ordering
-    // for the CHAR value
-    oscl_wchar *wptr = &buf[index];
-
-    *wptr = (uint16)(firstbyte << 8 | (uint16) secondbyte);
-
-    bool nextChar = (buf[index] == 0) ? false : true;
-    index += 1;
-
-    while (nextChar && (index < (int32)(BUFSIZE)))
-    {
-        if (!AtomUtils::read8read8(fp, firstbyte, secondbyte))
-            return false;
-
-        // Allow the OS to do the bit shifting to get the correct byte ordering
-        // for the CHAR value
-        wptr  = &buf[index];
-        *wptr = (uint16)(firstbyte << 8 | (uint16) secondbyte);
-        nextChar = (buf[index] == 0) ? false : true;
-        index++;
-    }
-
-    // String (wchar_t) buffer filled - now create OSCL_wString
-    // OSCL_wString is a wchar_t string so no conversion needed
-    OSCL_wHeapString<OsclMemAllocator> temp((const OSCL_TCHAR *)buf, index - 1);
-    data = temp;
-
-    return true;
-}
-
-// Read in a NULL terminated ascii (8-bit char) string byte by byte and take most
-// significant byte first and convert to a OSCL_wString
-bool AtomUtils::readNullTerminatedAsciiString(MP4_FF_FILE *fp, OSCL_wString& data)
-{
-    return readNullTerminatedString(fp, data);
-}
-
-// Read in a first N Characters of string byte by byte
-bool
-AtomUtils::readByteData(MP4_FF_FILE *fp, uint32 length, uint8 *data)
-{
-    uint32 bytesRead = 0;
-
-    if (length > 0)
-    {
-        bytesRead = fp->_pvfile.Read(data, 1, length);
-    }
-    if (bytesRead < (uint32)length)
-    {
-        // read byte data failed
-        return false;
-    }
-    return true;
-}
-
-uint32
-AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(uint32 contentSize)
-{
-    // The actual _sizeOfClass value includes the size of the class's contents PLUS
-    // the number of bytes needed to store the _sizeOfClass field. The parameter
-    // contentSize represents the number of bytes needed to store ONLY the members
-    // of the class NOT including the _sizeOfClass field.
-    if (contentSize <= 0x7e) return 1; // _sizeOfClass field can be rendered in 1 byte (7 LS bits)
-    else if (contentSize <= 0x3ffd) return 2; // _sizeOfClass field can be rendered in 2 bytes (7 LS bits each)
-    else if (contentSize <= 0x1ffffc) return 3; // _sizeOfClass field can be rendered in 3 bytes (7 LS bits each)
-    else if (contentSize <= 0xfffffffb) return 4; // _sizeOfClass field can be rendered in 4 bytes (7 LS bits each)
-    else return 0; // ERROR condition
-}
-
-
-// Returns the atom type from parsing the input stream
-OSCL_EXPORT_REF void
-AtomUtils::getNextAtomType(MP4_FF_FILE *fp, uint32 &size, uint32 &type)
-{
-    size = 0;
-    type = UNKNOWN_ATOM;
-
-    int32 filePointer;
-    filePointer = AtomUtils::getCurrentFilePosition(fp);
-
-    if (filePointer > (fp->_fileSize - 8))
-    {
-        return;
-    }
-
-    if (!AtomUtils::read32read32(fp, size, type))
-    {
-        size = 0;
-        type = UNKNOWN_ATOM;
-        return;
-    }
-
-    if (type == MOVIE_ATOM ||
-            type == MOVIE_HEADER_ATOM ||
-            type == TRACK_ATOM ||
-            type == TRACK_HEADER_ATOM ||
-            type == TRACK_REFERENCE_ATOM ||
-            type == MEDIA_ATOM ||
-            type == EDIT_ATOM ||
-            type == EDIT_LIST_ATOM ||
-            type == MEDIA_HEADER_ATOM ||
-            type == HANDLER_ATOM ||
-            type == MEDIA_INFORMATION_ATOM ||
-            type == VIDEO_MEDIA_HEADER_ATOM ||
-            type == SOUND_MEDIA_HEADER_ATOM ||
-            type == HINT_MEDIA_HEADER_ATOM ||
-            type == MPEG4_MEDIA_HEADER_ATOM ||
-            type == NULL_MEDIA_HEADER_ATOM ||
-            type == DATA_INFORMATION_ATOM ||
-            type == DATA_REFERENCE_ATOM ||
-            type == DATA_ENTRY_URL_ATOM ||
-            type == DATA_ENTRY_URN_ATOM ||
-            type == SAMPLE_TABLE_ATOM ||
-            type == TIME_TO_SAMPLE_ATOM ||
-            type == COMPOSITION_OFFSET_ATOM ||
-            type == SAMPLE_DESCRIPTION_ATOM ||
-            type == ESD_ATOM ||
-            type == SAMPLE_SIZE_ATOM ||
-            type == SAMPLE_TO_CHUNK_ATOM ||
-            type == CHUNK_OFFSET_ATOM ||
-            type == SYNC_SAMPLE_ATOM ||
-            type == SHADOW_SYNC_SAMPLE_ATOM ||
-            type == DEGRADATION_PRIORITY_ATOM ||
-            type == OBJECT_DESCRIPTOR_ATOM ||
-            type == MEDIA_DATA_ATOM ||
-            type == FREE_SPACE_ATOM ||
-            type == SKIP_ATOM ||
-            type == USER_DATA_ATOM ||
-            type == FILE_TYPE_ATOM ||
-            type == PVUSER_DATA_ATOM ||
-            type == PV_CONTENT_TYPE_ATOM ||
-            type == AMR_SAMPLE_ENTRY_ATOM ||
-            type == AMRWB_SAMPLE_ENTRY_ATOM ||
-            type == H263_SAMPLE_ENTRY_ATOM ||
-            type == AUDIO_SAMPLE_ENTRY ||
-            type == VIDEO_SAMPLE_ENTRY ||
-            type == MPEG_SAMPLE_ENTRY ||
-            type == UUID_ATOM ||
-            type == AMR_SPECIFIC_ATOM ||
-            type == H263_SPECIFIC_ATOM ||
-
-
-            type == COPYRIGHT_ATOM ||
-            type == FONT_TABLE_ATOM ||
-            type == HINT_TRACK_REFERENCE_TYPE ||
-            type == DPND_TRACK_REFERENCE_TYPE ||
-            type == IPIR_TRACK_REFERENCE_TYPE ||
-            type == MPOD_TRACK_REFERENCE_TYPE ||
-            type == SYNC_TRACK_REFERENCE_TYPE ||
-            type == ASSET_INFO_TITLE_ATOM ||
-            type == ASSET_INFO_DESCP_ATOM ||
-            type == ASSET_INFO_PERF_ATOM ||
-            type == ASSET_INFO_AUTHOR_ATOM ||
-            type == ASSET_INFO_GENRE_ATOM ||
-            type == ASSET_INFO_RATING_ATOM ||
-            type == ASSET_INFO_CLSF_ATOM ||
-            type == ASSET_INFO_KEYWORD_ATOM ||
-            type == ASSET_INFO_LOCATION_ATOM ||
-            type == ASSET_INFO_ALBUM_ATOM ||
-            type == ASSET_INFO_YRRC_ATOM ||
-            type == TEXT_SAMPLE_ENTRY ||
-            type == AVC_SAMPLE_ENTRY ||
-            type == AVC_CONFIGURATION_BOX ||
-            type == MPEG4_BITRATE_BOX ||
-            type == MPEG4_EXTENSION_DESCRIPTORS_BOX ||
-            type == ENCRYPTED_AUDIO_SAMPLE_ENTRY ||
-            type == ENCRYPTED_VIDEO_SAMPLE_ENTRY ||
-            type == PROTECTION_SCHEME_INFO_BOX ||
-            type == ORIGINAL_FORMAT_BOX ||
-            type == SCHEME_TYPE_BOX ||
-            type == SCHEME_INFORMATION_BOX ||
-            type == MUTABLE_DRM_INFORMATION ||
-            type == OMADRM_TRANSACTION_TRACKING_BOX ||
-            type == OMADRM_RIGHTS_OBJECT_BOX ||
-            type == OMADRM_KMS_BOX ||
-
-
-            type == MOVIE_EXTENDS_ATOM ||
-            type == MOVIE_EXTENDS_HEADER_ATOM ||
-            type == TRACK_EXTENDS_ATOM ||
-            type == MOVIE_FRAGMENT_ATOM ||
-            type == MOVIE_FRAGMENT_HEADER_ATOM ||
-            type == TRACK_FRAGMENT_ATOM ||
-            type == TRACK_FRAGMENT_HEADER_ATOM ||
-            type == TRACK_FRAGMENT_RUN_ATOM ||
-            type == MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM ||
-            type == MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM ||
-            type == TRACK_FRAGMENT_RANDOM_ACCESS_ATOM ||
-
-            type == META_DATA_ATOM ||
-            type == ITUNES_ILST_ATOM ||
-            type == ITUNES_ILST_DATA_ATOM ||
-            type == ITUNES_TITLE_ATOM ||
-            type == ITUNES_COMPILATION_ATOM ||
-            type == ITUNES_ENCODER_ATOM ||
-            type == ITUNES_FREE_FORM_ATOM ||
-            type == ITUNES_ALBUM_ARTIST_ATOM ||
-            type == ITUNES_COMPOSER_ATOM ||
-            type == ITUNES_ALBUM_ATOM ||
-            type == ITUNES_GROUPING_ATOM ||
-            type == ITUNES_GENRE1_ATOM ||
-            type == ITUNES_GENRE2_ATOM ||
-            type == ITUNES_TRACK_NUMBER_ATOM ||
-            type == ITUNES_DISK_NUMBER_ATOM ||
-            type == ITUNES_YEAR_ATOM ||
-            type == ITUNES_COMMENT_ATOM ||
-            type == ITUNES_LYRICS_ATOM ||
-            type == ITUNES_ART_WORK_ATOM ||
-            type == ITUNES_BPM_ATOM ||
-            type == ITUENES_MEAN_ATOM ||
-            type == ITUNES_FREE_FORM_DATA_NAME_ATOM ||
-            type == ITUNES_COPYRIGHT_ATOM ||
-            type == ITUNES_DESCRIPTION_ATOM	||
-
-
-
-            type == PIXELASPECTRATIO_BOX)
-    {
-        return;
-    }
-    else
-    {
-        type = UNKNOWN_ATOM;
-    }
-    return;
-}
-
-uint32
-AtomUtils::getMediaTypeFromHandlerType(uint32 handlerType)
-{
-    if (
-        handlerType == MEDIA_TYPE_AUDIO ||
-        handlerType == MEDIA_TYPE_VISUAL ||
-        handlerType == MEDIA_TYPE_HINT ||
-        handlerType == MEDIA_TYPE_OBJECT_DESCRIPTOR ||
-        handlerType == MEDIA_TYPE_CLOCK_REFERENCE ||
-        handlerType == MEDIA_TYPE_SCENE_DESCRIPTION ||
-        handlerType == MEDIA_TYPE_MPEG7 ||
-        handlerType == MEDIA_TYPE_OBJECT_CONTENT_INFO ||
-        handlerType == MEDIA_TYPE_IPMP ||
-        handlerType == MEDIA_TYPE_MPEG_J ||
-        handlerType == MEDIA_TYPE_TEXT
-    )
-    {
-        return handlerType;
-    }
-    else
-    {
-        return MEDIA_TYPE_UNKNOWN;
-    }
-}
-
-uint32
-AtomUtils::getNumberOfBytesUsedToStoreContent(uint32 sizeOfClass)
-{
-    // The content in a descriptor class is stored immediately after the descriptor tag
-    if (sizeOfClass <= 0x7f) return sizeOfClass - 2; // _sizeOfClass field is 1 byte (7 LS bits)
-    else if (sizeOfClass <= 0x3fff) return sizeOfClass - 3; // _sizeOfClass is 2 bytes (7 LS bits each)
-    else if (sizeOfClass <= 0x1fffff) return sizeOfClass - 4; // _sizeOfClass is 3 bytes (7 LS bits each)
-    else if (sizeOfClass <= 0x0fffffff) return sizeOfClass - 5; // _sizeOfClass is 4 bytes (7 LS bits each)
-    else return 0; // ERROR condition
-}
-
-int32 AtomUtils::getNextAtomSize(MP4_FF_FILE *fp)
-{
-    uint32 size;
-    AtomUtils::read32(fp, size);
-
-    AtomUtils::rewindFilePointerByN(fp, 4);
-    return size;
-}
-
-// Peeks and returns the next Nth tag (32 bits) from the file
-uint32 AtomUtils::peekNextNthBytes(MP4_FF_FILE *fp, int32 n)
-{
-    uint32 tag = 0;
-    for (int32 i = 0; i < n; i++)
-    {
-        AtomUtils::read32(fp, tag);
-    }
-    AtomUtils::rewindFilePointerByN(fp, (4*n));
-    return tag;
-}
-
-// Peeks and returns the next Nth bytes (8 bits) from the file
-uint8 AtomUtils::peekNextByte(MP4_FF_FILE *fp)
-{
-    uint8 tag = 0;
-    AtomUtils::read8(fp, tag);
-    AtomUtils::rewindFilePointerByN(fp, 1);
-    return tag;
-}
-
-OSCL_EXPORT_REF void AtomUtils::seekFromCurrPos(MP4_FF_FILE *fp, uint32 n)
-{
-    fp->_pvfile.Seek(n, Oscl_File::SEEKCUR);
-}
-
-OSCL_EXPORT_REF void AtomUtils::seekFromStart(MP4_FF_FILE *fp, uint32 n)
-{
-    fp->_pvfile.Seek(n, Oscl_File::SEEKSET);
-}
-
-OSCL_EXPORT_REF void AtomUtils::seekToEnd(MP4_FF_FILE *fp)
-{
-    fp->_pvfile.Seek(0, Oscl_File::SEEKEND);
-}
-
-void AtomUtils::rewindFilePointerByN(MP4_FF_FILE *fp, uint32 n)
-{
-    fp->_pvfile.Seek((-1 * (int32) n), Oscl_File::SEEKCUR);
-}
-
-OSCL_EXPORT_REF int32 AtomUtils::getCurrentFilePosition(MP4_FF_FILE *fp)
-{
-    return (fp->_pvfile.Tell());
-}
-
-
-OSCL_EXPORT_REF int32 AtomUtils::OpenMP4File(OSCL_wString& filename,
-        uint32 mode,
-        MP4_FF_FILE *fp)
-{
-    OSCL_UNUSED_ARG(mode);
-    if (fp != NULL)
-    {
-        return (fp->_pvfile.Open(filename.get_cstr(),
-                                 Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
-                                 *(fp->_fileServSession)));
-    }
-    return -1;
-}
-
-OSCL_EXPORT_REF int32  AtomUtils::CloseMP4File(MP4_FF_FILE *fp)
-{
-    if (fp != NULL)
-    {
-        return (fp->_pvfile.Close());
-    }
-    return -1;
-}
-
-OSCL_EXPORT_REF int32  AtomUtils::Flush(MP4_FF_FILE *fp)
-{
-    if (fp != NULL)
-    {
-        return (fp->_pvfile.Flush());
-    }
-    return -1;
-}
-
-bool AtomUtils::getCurrentFileSize(MP4_FF_FILE *fp, uint32& aCurrentSize)
-{
-    if (fp != NULL)
-    {
-        aCurrentSize = 0;
-        uint32 aRemBytes = 0;
-        if (fp->_pvfile.GetRemainingBytes(aRemBytes))
-        {
-            uint32 currPos = (uint32)(fp->_pvfile.Tell());
-            aCurrentSize = currPos + aRemBytes;
-            fp->_fileSize = aCurrentSize;
-            return true;
-        }
-    }
-    return false;
-}
-
-bool
-AtomUtils::read32(uint8 *&buf, uint32 &data)
-{
-    const int32 N = 4;
-    data = 0;
-
-    for (int32 i = 0;i < N;i++)
-        data = (data << 8) | buf[i];
-
-    buf += N;
-    return true;
-}
-
-// Read in the 32 bits byte by byte and take most significant byte first.
-// This is equivalent to two read32 calls.
-bool
-AtomUtils::read32read32(uint8 *&buf, uint32 &data1, uint32 &data2)
-{
-    const int32 N = 8;
-    data1 = 0;
-    data2 = 0;
-
-    int32 i;
-    for (i = 0;i < 4;i++)
-        data1 = (data1 << 8) | buf[i];
-
-    for (i = 4;i < 8;i++)
-        data2 = (data2 << 8) | buf[i];
-
-    buf += N;
-    return true;
-}
-
-// Read in the 16 bits byte by byte and take most significant byte first
-bool
-AtomUtils::read16(uint8 *&buf, uint16 &data)
-{
-    const int32 N = 2;
-    data = 0;
-
-    for (int32 i = 0;i < N;i++)
-        data = (uint16)((data << 8) | (uint16) buf[i]);
-
-    buf += N;
-    return true;
-}
-
-// Read in the 8 bit byte
-bool
-AtomUtils::read8(uint8 *&buf, uint8 &data)
-{
-    data = 0;
-    data = *buf;
-    buf++;
-    return true;
-}
-
-// Read in byte data and take most significant byte first
-bool
-AtomUtils::readByteData(uint8 *&buf, uint32 length, uint8 *data)
-{
-    oscl_memcpy(data, buf, length);
-
-    buf += length;
-    return true;
-}
-
-uint32
-AtomUtils::getNextAtomType(uint8 *buf)
-{
-    uint32 size;
-    uint32 type;
-    if (!AtomUtils::read32read32(buf, size, type))
-    {
-        return UNKNOWN_ATOM;
-    }
-
-    // Rewinding the stream back to atom start
-    buf -= 8;
-
-    if (type == MOVIE_ATOM ||
-            type == MOVIE_HEADER_ATOM ||
-            type == TRACK_ATOM ||
-            type == TRACK_HEADER_ATOM ||
-            type == TRACK_REFERENCE_ATOM ||
-            type == MEDIA_ATOM ||
-            type == EDIT_ATOM ||
-            type == EDIT_LIST_ATOM ||
-            type == MEDIA_HEADER_ATOM ||
-            type == HANDLER_ATOM ||
-            type == MEDIA_INFORMATION_ATOM ||
-            type == VIDEO_MEDIA_HEADER_ATOM ||
-            type == SOUND_MEDIA_HEADER_ATOM ||
-            type == HINT_MEDIA_HEADER_ATOM ||
-            type == MPEG4_MEDIA_HEADER_ATOM ||
-            type == NULL_MEDIA_HEADER_ATOM ||
-            type == DATA_INFORMATION_ATOM ||
-            type == DATA_REFERENCE_ATOM ||
-            type == DATA_ENTRY_URL_ATOM ||
-            type == DATA_ENTRY_URN_ATOM ||
-            type == SAMPLE_TABLE_ATOM ||
-            type == TIME_TO_SAMPLE_ATOM ||
-            type == COMPOSITION_OFFSET_ATOM ||
-            type == SAMPLE_DESCRIPTION_ATOM ||
-            type == ESD_ATOM ||
-            type == SAMPLE_SIZE_ATOM ||
-            type == SAMPLE_TO_CHUNK_ATOM ||
-            type == CHUNK_OFFSET_ATOM ||
-            type == SYNC_SAMPLE_ATOM ||
-            type == SHADOW_SYNC_SAMPLE_ATOM ||
-            type == DEGRADATION_PRIORITY_ATOM ||
-            type == OBJECT_DESCRIPTOR_ATOM ||
-            type == MEDIA_DATA_ATOM ||
-            type == FREE_SPACE_ATOM ||
-            type == SKIP_ATOM ||
-            type == USER_DATA_ATOM ||
-            type == FILE_TYPE_ATOM ||
-            type == PVUSER_DATA_ATOM ||
-            type == PVUSER_DATA_ATOM ||
-            type == AMR_SAMPLE_ENTRY_ATOM ||
-            type == AMRWB_SAMPLE_ENTRY_ATOM ||
-            type == H263_SAMPLE_ENTRY_ATOM ||
-            type == AUDIO_SAMPLE_ENTRY ||
-            type == VIDEO_SAMPLE_ENTRY ||
-            type == MPEG_SAMPLE_ENTRY ||
-            type == UUID_ATOM ||
-            type == AMR_SPECIFIC_ATOM ||
-            type == H263_SPECIFIC_ATOM ||
-            type == COPYRIGHT_ATOM ||
-            type == TEXT_SAMPLE_ENTRY ||
-            type == FONT_TABLE_ATOM ||
-            type == TEXT_STYLE_BOX ||
-            type == TEXT_HIGHLIGHT_BOX ||
-            type == TEXT_HILIGHT_COLOR_BOX ||
-            type == TEXT_KARAOKE_BOX ||
-            type == TEXT_SCROLL_DELAY_BOX ||
-            type == TEXT_HYPER_TEXT_BOX ||
-            type == TEXT_OVER_RIDE_BOX ||
-            type == TEXT_BLINK_BOX ||
-            type == HINT_TRACK_REFERENCE_TYPE ||
-            type == DPND_TRACK_REFERENCE_TYPE ||
-            type == IPIR_TRACK_REFERENCE_TYPE ||
-            type == MPOD_TRACK_REFERENCE_TYPE ||
-            type == SYNC_TRACK_REFERENCE_TYPE ||
-            type == ASSET_INFO_TITLE_ATOM ||
-            type == ASSET_INFO_DESCP_ATOM ||
-            type == ASSET_INFO_PERF_ATOM ||
-            type == ASSET_INFO_AUTHOR_ATOM ||
-            type == ASSET_INFO_GENRE_ATOM ||
-            type == ASSET_INFO_RATING_ATOM ||
-            type == ASSET_INFO_CLSF_ATOM ||
-            type == ASSET_INFO_KEYWORD_ATOM ||
-            type == ASSET_INFO_LOCATION_ATOM ||
-            type == ASSET_INFO_ALBUM_ATOM ||
-            type == ASSET_INFO_YRRC_ATOM)
-    {
-        return type;
-    }
-    else
-    {
-        return UNKNOWN_ATOM; // ERROR condition
-    }
-}
-
-int32 AtomUtils::getNextAtomSize(uint8 *buf)
-{
-    uint32 size;
-    AtomUtils::read32(buf, size);
-
-    return size;
-}
-
-
-uint32 AtomUtils::getContentLength(MP4_FF_FILE *fp)
-{
-    // this returns the content length if known
-    return fp->_pvfile.GetContentLength();
-}
-
-
-uint32 AtomUtils::getFileBufferingCapacity(MP4_FF_FILE *fp)
-{
-    // this returns the data stream cache size
-    return fp->_pvfile.GetFileBufferingCapacity();
-}
-
-
-void AtomUtils::skipFromStart(MP4_FF_FILE *fp, uint32 n)
-{
-    fp->_pvfile.Skip(n, Oscl_File::SEEKSET);
-}
-
-
-void AtomUtils::getCurrentByteRange(MP4_FF_FILE *fp, uint32& aCurrentFirstByteOffset, uint32& aCurrentLastByteOffset)
-{
-    // this returns the byte range in the data stream cache
-    // first and last offset inclusive
-    fp->_pvfile.GetCurrentByteRange(aCurrentFirstByteOffset, aCurrentLastByteOffset);
-}
-
-
-
diff --git a/fileformats/mp4/parser/src/audiosampleentry.cpp b/fileformats/mp4/parser/src/audiosampleentry.cpp
index 7dbfefe..7fec72e 100644
--- a/fileformats/mp4/parser/src/audiosampleentry.cpp
+++ b/fileformats/mp4/parser/src/audiosampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,14 +43,17 @@
         // Read reserved values
         if (!AtomUtils::read32read32(fp, _reserved1[0], _reserved1[1]))
             _success = false;
-        if (!AtomUtils::read16read16(fp, _reserved2, _reserved3))
+        if (!AtomUtils::read16read16(fp, _channelCount, _sampleSize))
             _success = false;
-        if (!AtomUtils::read32(fp, _reserved4))
+        if (!AtomUtils::read16read16(fp, _preDefined, _reserved))
             _success = false;
 
-        if (!AtomUtils::read16read16(fp, _timeScale, _reserved5))
+        if (!AtomUtils::read16read16(fp, _timeScale, _sampleRateLo)) //_timeScale and _sampleRateHi are same
             _success = false;
 
+        _sampleRateHi = _timeScale;
+
+
         if (_success)
         {
             uint32 atomType = UNKNOWN_ATOM;
diff --git a/fileformats/mp4/parser/src/avcconfigurationbox.cpp b/fileformats/mp4/parser/src/avcconfigurationbox.cpp
index 3465995..71a3dac 100644
--- a/fileformats/mp4/parser/src/avcconfigurationbox.cpp
+++ b/fileformats/mp4/parser/src/avcconfigurationbox.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_AVCConfigurationBox
 
 #include "avcsampleentry.h"
diff --git a/fileformats/mp4/parser/src/avclayerdescriptionentry.cpp b/fileformats/mp4/parser/src/avclayerdescriptionentry.cpp
index 4d8e3a5..801fea2 100644
--- a/fileformats/mp4/parser/src/avclayerdescriptionentry.cpp
+++ b/fileformats/mp4/parser/src/avclayerdescriptionentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT__AVCLayerDescEntry
 
 #include "avclayerentry.h"
diff --git a/fileformats/mp4/parser/src/avcsampledependency.cpp b/fileformats/mp4/parser/src/avcsampledependency.cpp
index 4ac3a05..407ce19 100644
--- a/fileformats/mp4/parser/src/avcsampledependency.cpp
+++ b/fileformats/mp4/parser/src/avcsampledependency.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_AVCSampleDependency
 
 #include "avcsampledependency.h"
diff --git a/fileformats/mp4/parser/src/avcsampledependencytype.cpp b/fileformats/mp4/parser/src/avcsampledependencytype.cpp
index c69b17a..1243e92 100644
--- a/fileformats/mp4/parser/src/avcsampledependencytype.cpp
+++ b/fileformats/mp4/parser/src/avcsampledependencytype.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_AVCSampleDependency
 
 #include "avcsampledependencytype.h"
diff --git a/fileformats/mp4/parser/src/avcsampleentry.cpp b/fileformats/mp4/parser/src/avcsampleentry.cpp
index c3fae9f..075668c 100644
--- a/fileformats/mp4/parser/src/avcsampleentry.cpp
+++ b/fileformats/mp4/parser/src/avcsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-    This AVCSampleEntry Class is used for AVC streams.
-*/
-
-
 #define IMPLEMENT_AVCSampleEntry
 
 #include "avcsampleentry.h"
diff --git a/fileformats/mp4/parser/src/avcsampletogroupbox.cpp b/fileformats/mp4/parser/src/avcsampletogroupbox.cpp
index 46ed589..55ef870 100644
--- a/fileformats/mp4/parser/src/avcsampletogroupbox.cpp
+++ b/fileformats/mp4/parser/src/avcsampletogroupbox.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
 #define IMPLEMENT_AVCSampleToGroup
 
 #include "avcsampletogroupbox.h"
diff --git a/fileformats/mp4/parser/src/avcsubseqdescriptionentry.cpp b/fileformats/mp4/parser/src/avcsubseqdescriptionentry.cpp
index eb0542e..564a445 100644
--- a/fileformats/mp4/parser/src/avcsubseqdescriptionentry.cpp
+++ b/fileformats/mp4/parser/src/avcsubseqdescriptionentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT__AVCLayerDescEntry
 
 #include "avcsubseqdescriptionentry.h"
diff --git a/fileformats/mp4/parser/src/basedescriptor.cpp b/fileformats/mp4/parser/src/basedescriptor.cpp
index 4516614..a02043e 100644
--- a/fileformats/mp4/parser/src/basedescriptor.cpp
+++ b/fileformats/mp4/parser/src/basedescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/boxrecord.cpp b/fileformats/mp4/parser/src/boxrecord.cpp
index 6cd9be5..314c738 100644
--- a/fileformats/mp4/parser/src/boxrecord.cpp
+++ b/fileformats/mp4/parser/src/boxrecord.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/chunkoffsetatom.cpp b/fileformats/mp4/parser/src/chunkoffsetatom.cpp
index 8f71af6..b2d69b0 100644
--- a/fileformats/mp4/parser/src/chunkoffsetatom.cpp
+++ b/fileformats/mp4/parser/src/chunkoffsetatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -191,6 +191,7 @@
 
 bool ChunkOffsetAtom::ParseEntryUnit(uint32 sample_cnt)
 {
+
     if (_parsingMode)
     {
         const uint32 threshold = 512;
diff --git a/fileformats/mp4/parser/src/compositionoffsetatom.cpp b/fileformats/mp4/parser/src/compositionoffsetatom.cpp
index 0ff8d3b..1a20aff 100644
--- a/fileformats/mp4/parser/src/compositionoffsetatom.cpp
+++ b/fileformats/mp4/parser/src/compositionoffsetatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,17 +36,27 @@
 #include "compositionoffsetatom.h"
 #include "atomutils.h"
 
+#define CTTS_MIN_SAMPLE_TABLE_SIZE 4096
+#define MT_SAMPLECOUNT_INCREMENT 100 //this has to be atleast 3
+#define NUMBER_OF_SAMPLE_POPULATES_PER_RUNL 50
+#define ENABLE_MT_LOGIC_ON_CTTS_ENTRY_COUNT_VALUE 512
+
 // Stream-in ctor
 CompositionOffsetAtom::CompositionOffsetAtom(MP4_FF_FILE *fp,
         uint32 mediaType,
         uint32 size,
         uint32 type,
         OSCL_wString& filename,
-        uint32 parsingMode)
-        : FullAtom(fp, size, type)
+        uint32 parsingMode):
+        FullAtom(fp, size, type),
+        OsclTimerObject(OsclActiveObject::EPriorityNominal, "CompositionOffsetAtom")
 {
     _psampleCountVec = NULL;
     _psampleOffsetVec = NULL;
+    MT_SampleCount  = NULL;
+    MT_EntryCount  = NULL;
+    iMarkerTableCreation = false;
+    MT_Table_Size = 0;
 
     _currGetSampleCount = 0;
     _currGetIndex = -1;
@@ -55,14 +65,21 @@
     _currPeekIndex = -1;
     _currPeekTimeOffset = 0;
 
+    MT_Counter = 1;
+    addSampleCount = 0;
+    prevSampleCount = 0;
+    entrycountTraversed = 0;
+    refSample = MT_SAMPLECOUNT_INCREMENT;
+    MT_j = 1;
+
     _mediaType = mediaType;
-    //_head_offset = 0;
     _parsed_entry_cnt = 0;
     _fileptr = NULL;
     _parsing_mode = 0;
     _parsing_mode = parsingMode;
 
-    _stbl_buff_size = 4096;
+
+    _stbl_buff_size = CTTS_MIN_SAMPLE_TABLE_SIZE;
     _next_buff_number = 0;
     _curr_buff_number = 0;
     _curr_entry_point = 0;
@@ -72,6 +89,16 @@
     iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats");
     iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata");
 
+    iMarkerTableCreation = false;
+
+    /* Add this AO to the scheduler */
+    if (OsclExecScheduler::Current() != NULL)
+    {
+        if (!IsAdded())
+        {
+            AddToScheduler();
+        }
+    }
 
     if (_success)
     {
@@ -96,9 +123,11 @@
             {
                 if (parsingMode == 1)
                 {
-                    if ((_entryCount > 4096)) // cahce size is 4K so that optimization
-                        // should work if entry_count is greater than 4K
+                    // cache size is 4K so that optimization
+                    // should work if entry_count is greater than 4K
+                    if (_entryCount > _stbl_buff_size)
                     {
+
                         uint32 fptrBuffSize = (_entryCount / _stbl_buff_size) + 1;
 
                         PV_MP4_FF_ARRAY_NEW(NULL, uint32, (fptrBuffSize), _stbl_fptr_vec);
@@ -109,6 +138,7 @@
                             return;
                         }
 
+
                         PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleCountVec);
                         if (_psampleCountVec == NULL)
                         {
@@ -117,6 +147,7 @@
                             return;
                         }
 
+
                         PV_MP4_FF_ARRAY_NEW(NULL, uint32, (_stbl_buff_size), _psampleOffsetVec);
                         if (_psampleOffsetVec == NULL)
                         {
@@ -158,6 +189,7 @@
                         int32 _head_offset = AtomUtils::getCurrentFilePosition(fp);
                         AtomUtils::seekFromCurrPos(fp, dataSize);
                         AtomUtils::seekFromStart(_fileptr, _head_offset);
+
                         return;
                     }
                     else
@@ -227,15 +259,32 @@
     }
 }
 
+void CompositionOffsetAtom::setSamplesCount(uint32 SamplesCount)
+{
+    _iTotalNumSamplesInTrack = SamplesCount;
+
+    if (_entryCount > ENABLE_MT_LOGIC_ON_CTTS_ENTRY_COUNT_VALUE)
+    {
+        //Make this AO active so Run() will be called when scheduler is started
+        if (OsclExecScheduler::Current() != NULL)
+        {
+            RunIfNotReady();
+        }
+    }
+}
+
 bool CompositionOffsetAtom::ParseEntryUnit(uint32 entry_cnt)
 {
     const uint32 threshold = 1024;
     entry_cnt += threshold;
 
     if (entry_cnt > _entryCount)
+    {
         entry_cnt = _entryCount;
+    }
 
-    uint32 number, offset;
+    uint32 number = 0;
+    uint32 offset = 0;
     while (_parsed_entry_cnt < entry_cnt)
     {
         _curr_entry_point = _parsed_entry_cnt % _stbl_buff_size;
@@ -282,6 +331,8 @@
     if (_stbl_fptr_vec != NULL)
         PV_MP4_ARRAY_DELETE(NULL, _stbl_fptr_vec);
 
+    deleteMarkerTable();
+
     if (_fileptr != NULL)
     {
         if (_fileptr->IsOpen())
@@ -290,6 +341,12 @@
         }
         oscl_free(_fileptr);
     }
+
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+    }
+
 }
 
 // Return the number of samples  at index
@@ -382,6 +439,7 @@
             return (PV_ERROR);
         }
     }
+
 }
 
 // This is the most widely used API
@@ -428,12 +486,14 @@
             return (PV_ERROR);
         }
     }
+
 }
 
-// Returns the offset (ms) for the  sample given by num.  This is used when
-// randomly accessing a frame and the timestamp has not been accumulated.
 
-int32 CompositionOffsetAtom::getTimeOffsetForSampleNumber(uint32 num)
+
+
+
+int32 CompositionOffsetAtom::getTimeOffsetFromMT(uint32 samplenum, uint32 currEC, uint32 currSampleCount)
 {
     if ((_psampleOffsetVec == NULL) ||
             (_psampleCountVec == NULL) ||
@@ -442,23 +502,32 @@
         return PV_ERROR;
     }
 
-    uint32 sampleCount = 0;
-    int32 offset = 0; // Offset value to return
-
-    for (uint32 i = 0; i < _entryCount; i++)
-    {
+    if (samplenum < currSampleCount)
+    { // Sample num within current entry
         if (_parsing_mode == 1)
-            CheckAndParseEntry(i);
+            CheckAndParseEntry(currEC);
 
-        if (num < (sampleCount + _psampleCountVec[i%_stbl_buff_size]))
-        { // Sample num within current entry
-            int32 count = num - sampleCount;
-            PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "CompositionOffsetAtom::getTimestampForSampleNumber- Time StampOffset = %d", _psampleOffsetVec[i%_stbl_buff_size]));
-            return _psampleOffsetVec[i%_stbl_buff_size];
-        }
-        else
+        PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "CompositionOffsetAtom::getTimestampForSampleNumber- Time StampOffset = %d", _psampleOffsetVec[currEC%_stbl_buff_size]));
+        return _psampleOffsetVec[currEC%_stbl_buff_size];
+    }
+    else
+    {
+
+        for (uint32 i = currEC + 1; i < _entryCount; i++)
         {
-            sampleCount += _psampleCountVec[i%_stbl_buff_size];
+            if (_parsing_mode == 1)
+                CheckAndParseEntry(i);
+
+
+            if (samplenum < (currSampleCount + _psampleCountVec[i%_stbl_buff_size]))
+            {
+                PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "CompositionOffsetAtom::getTimestampForSampleNumber- Time StampOffset = %d", _psampleOffsetVec[i%_stbl_buff_size]));
+                return _psampleOffsetVec[i%_stbl_buff_size];
+            }
+            else
+            {
+                currSampleCount += _psampleCountVec[i%_stbl_buff_size];
+            }
         }
     }
 
@@ -466,6 +535,73 @@
     return PV_ERROR;
 }
 
+int32 CompositionOffsetAtom::getTimeOffsetForSampleNumber(uint32 num)
+{
+    uint32 currSample = 0;
+    uint32 currEC = 0;
+
+    if (iMarkerTableCreation == true)
+    {
+        uint32 MT_EC = num / (MT_SAMPLECOUNT_INCREMENT - 1); //where MT_SAMPLECOUNT_INCREMENT is the granuality of sample separation in Marker Table
+
+        if (MT_EC > ((_iTotalNumSamplesInTrack / MT_SAMPLECOUNT_INCREMENT) - 1))
+        {
+            //boundary check, MT_EC valid value will always be between 0 to (_samples_count/MT_SAMPLECOUNT_INCREMENT)-1
+            MT_EC = (_iTotalNumSamplesInTrack / MT_SAMPLECOUNT_INCREMENT) - 1;
+        }
+        //assign the last marker entry count created till now to look for sample from this location onwards instead of from start
+        if (MT_EC > MT_Counter)
+            MT_EC = MT_Counter;
+
+        while ((num < MT_SampleCount[MT_EC]) && (MT_EC > 0))
+        {
+            //This check was put keeping in mind that it may happen (due to rounding off error),
+            //that we choose a MT_EC greater than desired. So to avoid such a scenario.
+            MT_EC = MT_EC - 1;
+            currSample = MT_SampleCount[MT_EC];
+            currEC = MT_EntryCount[MT_EC];
+        }
+
+        currSample = MT_SampleCount[MT_EC];
+        currEC = MT_EntryCount[MT_EC];
+
+
+
+        return getTimeOffsetFromMT(num, currEC, currSample);
+    }
+    else
+    {
+        if ((_psampleOffsetVec == NULL) ||
+                (_psampleCountVec == NULL) ||
+                (_entryCount == 0))
+        {
+            return PV_ERROR;
+        }
+
+        uint32 sampleCount = 0;
+
+        for (uint32 i = 0; i < _entryCount; i++)
+        {
+            if (_parsing_mode == 1)
+                CheckAndParseEntry(i);
+
+            if (num < (sampleCount + _psampleCountVec[i%_stbl_buff_size]))
+            { // Sample num within current entry
+
+                PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "CompositionOffsetAtom::getTimestampForSampleNumber- Time StampOffset = %d", _psampleOffsetVec[i%_stbl_buff_size]));
+                return _psampleOffsetVec[i%_stbl_buff_size];
+            }
+            else
+            {
+                sampleCount += _psampleCountVec[i%_stbl_buff_size];
+            }
+        }
+
+        // Went past end of list - not a valid sample number
+        return PV_ERROR;
+    }
+}
+
 int32
 CompositionOffsetAtom::resetStateVariables()
 {
@@ -514,6 +650,7 @@
         {
             return (EVERYTHING_FINE);
         }
+
     }
 
     // Went past end of list - not a valid sample number
@@ -546,3 +683,145 @@
     }
 }
 
+void CompositionOffsetAtom::Run()
+{
+    // Create it for the first time
+    if ((MT_SampleCount == NULL) && (MT_EntryCount == NULL))
+    {
+        int32 status = createMarkerTable();
+        if (status == PVMFFailure)
+        {
+            OSCL_LEAVE(OsclErrNoMemory);
+        }
+        iMarkerTableCreation = true;
+    }
+
+    populateMarkerTable();
+
+    // check for entry count being exhausted.. table iterated completely
+    if ((entrycountTraversed < _entryCount) && (refSample < _iTotalNumSamplesInTrack)
+            && (MT_Counter < _iTotalNumSamplesInTrack / MT_SAMPLECOUNT_INCREMENT))
+    {
+        RunIfNotReady();
+    }
+
+    return;
+
+}
+//Populate the Marker Table with SampleCount and EntryCount values
+//for every nth sample starting from n-1, where n=MT_SAMPLECOUNT_INCREMENT.
+
+uint32 CompositionOffsetAtom::populateMarkerTable()
+{
+    uint32 increment = MT_SAMPLECOUNT_INCREMENT;
+    uint32 numPopulated = 0;
+
+
+
+    for (uint32 i = entrycountTraversed; i < _entryCount; i++)
+    {
+
+        if (refSample < _iTotalNumSamplesInTrack)
+        {
+
+            if (i == 0)
+            {
+                if (_parsing_mode == 1)
+                    CheckAndParseEntry(i);
+
+                MT_SampleCount[0] = _psampleCountVec[i%_stbl_buff_size];
+                prevSampleCount = MT_SampleCount[0];
+                addSampleCount = MT_SampleCount[0];
+            }
+            else if (addSampleCount < refSample)
+            {
+                if (_parsing_mode == 1)
+                    CheckAndParseEntry(MT_j);
+
+                prevSampleCount = addSampleCount;
+                addSampleCount += _psampleCountVec[MT_j%_stbl_buff_size];
+                MT_j++;
+            }
+            else
+            {
+                entrycountTraversed = i - 1;
+                i = i - 1;
+                refSample += increment;
+                MT_SampleCount[MT_Counter] = prevSampleCount;
+                //Incase SampleCounts have same value for consecutive MT entries,
+                //even the same EntryCount should be mentioned in the Marker Table.
+                if (MT_SampleCount[MT_Counter] == MT_SampleCount[MT_Counter-1])
+                {
+                    MT_EntryCount[MT_Counter] = MT_EntryCount[MT_Counter-1];
+                }
+                else
+                {
+                    MT_EntryCount[MT_Counter] = MT_j - 2;
+                }
+
+
+                MT_Counter++;
+                numPopulated++;
+                if ((numPopulated == NUMBER_OF_SAMPLE_POPULATES_PER_RUNL) ||
+                        (MT_Counter >= _iTotalNumSamplesInTrack / MT_SAMPLECOUNT_INCREMENT))
+                    break;
+            }
+        }
+        else
+        {
+            break;
+        }
+
+    }
+
+    return numPopulated;
+
+}
+void CompositionOffsetAtom::deleteMarkerTable()
+{
+    if (MT_SampleCount != NULL)
+        PV_MP4_ARRAY_DELETE(NULL, MT_SampleCount);
+
+    if (MT_EntryCount != NULL)
+        PV_MP4_ARRAY_DELETE(NULL, MT_EntryCount);
+}
+// responsible for creation of data sturcture inside the table.
+PVMFStatus CompositionOffsetAtom::createMarkerTable()
+{
+
+    MT_Table_Size = (_iTotalNumSamplesInTrack / MT_SAMPLECOUNT_INCREMENT);
+    PV_MP4_FF_ARRAY_NEW(NULL, uint32, (MT_Table_Size), MT_SampleCount);
+
+    if (MT_SampleCount == NULL)
+    {
+        PV_MP4_ARRAY_DELETE(NULL, MT_SampleCount);
+        MT_SampleCount = NULL;
+        _success = false;
+        _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
+        return PVMFFailure;
+    }
+
+    PV_MP4_FF_ARRAY_NEW(NULL, uint32, (MT_Table_Size), MT_EntryCount);
+
+    if (MT_EntryCount == NULL)
+    {
+        PV_MP4_ARRAY_DELETE(NULL, MT_EntryCount);
+        MT_EntryCount = NULL;
+        PV_MP4_ARRAY_DELETE(NULL, MT_SampleCount);
+        MT_SampleCount = NULL;
+        _success = false;
+        _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
+        return PVMFFailure;
+    }
+
+    for (uint32 idx = 0; idx < MT_Table_Size; idx++)  //initialization
+    {
+
+        MT_EntryCount[idx] = 0;
+        MT_SampleCount[idx] = 0;
+    }
+
+    return PVMFSuccess;
+}
+
+
diff --git a/fileformats/mp4/parser/src/copyrightatom.cpp b/fileformats/mp4/parser/src/copyrightatom.cpp
index 1ca9bc7..acb4254 100644
--- a/fileformats/mp4/parser/src/copyrightatom.cpp
+++ b/fileformats/mp4/parser/src/copyrightatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,6 @@
 #include "atomutils.h"
 #include "atomdefs.h"
 
-#define BYTE_ORDER_MASK 0xFEFF
-
 CopyRightAtom::CopyRightAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
         : FullAtom(fp, size, type)
 {
@@ -36,130 +34,34 @@
 
         count += 2;
 
-        if (count < _size)
+        if (count <= _size)
         {
-            uint32 temp = AtomUtils::peekNextNthBytes(fp, 1);
+            uint32 delta = (_size - count);
+            MP4FFParserOriginalCharEnc CharType;
 
-            uint16 byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
-
-            if (byteOrderMask == BYTE_ORDER_MASK)
+            if (delta > 0)
             {
-                if (!AtomUtils::read16(fp, byteOrderMask))
+                if (!AtomUtils::readString(fp, delta, CharType , _copyRightNotice))
                 {
+                    //error
                     _success = false;
                     _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
                     return;
                 }
-                count += 2;
-
-                if (count < _size)
-                {
-                    // Check to see if the string is actually null-terminated
-                    uint32 delta = (_size - count);
-
-                    int32 filePos = AtomUtils::getCurrentFilePosition(fp);
-
-                    AtomUtils::seekFromCurrPos(fp, (delta - 2));
-
-                    uint16 strEnd = 0;
-
-                    if (!AtomUtils::read16(fp, strEnd))
-                    {
-                        _success = false;
-                        _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
-                        return;
-                    }
-
-                    if (strEnd == 0)
-                    {
-                        AtomUtils::seekFromStart(fp, filePos);
-
-                        if (!AtomUtils::readNullTerminatedUnicodeString(fp, _copyRightNotice))
-                        {
-                            _success = false;
-                            _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
-                            return;
-                        }
-                        {
-                            int32 newfilePos =
-                                AtomUtils::getCurrentFilePosition(fp);
-
-                            if (newfilePos != (int32)(filePos + delta))
-                            {
-                                AtomUtils::seekFromStart(fp, filePos + delta);
-                            }
-                        }
-                    }
-                    count += delta;
-                }
-                else
-                {
-                    _success = false;
-                    _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
-                    return;
-                }
+                count += delta;
             }
             else
             {
-                if (count < _size)
-                {
-                    // Check to see if the string is actually null-terminated
-
-                    uint32 delta = (_size - count);
-
-                    int32 filePos = AtomUtils::getCurrentFilePosition(fp);
-
-                    AtomUtils::seekFromCurrPos(fp, (delta - 1));
-
-                    uint8 strEnd = 0;
-
-                    if (!AtomUtils::read8(fp, strEnd))
-                    {
-                        _success = false;
-                        _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
-                        return;
-                    }
-
-                    if (strEnd == 0)
-                    {
-                        AtomUtils::seekFromStart(fp, filePos);
-
-                        if (!AtomUtils::readNullTerminatedString(fp, _copyRightNotice))
-                        {
-                            _success = false;
-                            _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
-                            return;
-                        }
-                        {
-                            int32 newfilePos =
-                                AtomUtils::getCurrentFilePosition(fp);
-
-                            if (newfilePos != (int32)(filePos + delta))
-                            {
-                                AtomUtils::seekFromStart(fp, filePos + delta);
-                            }
-                        }
-                    }
-                    count += delta;
-                }
-                else
-                {
-                    _success = false;
-                    _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
-                    return;
-                }
+                //error
+                _success = false;
+                _mp4ErrorCode = READ_COPYRIGHT_ATOM_FAILED;
+                return;
             }
 
-            while (count < _size)
+            if (count < _size)
             {
-                uint8 data;
-                if (!AtomUtils::read8(fp, data))
-                {
-                    _success = false;
-                    _mp4ErrorCode = READ_USER_DATA_ATOM_FAILED;
-                    return;
-                }
-                count++;
+                AtomUtils::seekFromCurrPos(fp, (_size - count));
+                count = _size;
             }
         }
         else if (count > _size)
diff --git a/fileformats/mp4/parser/src/dataentryatom.cpp b/fileformats/mp4/parser/src/dataentryatom.cpp
index 6e32fd2..d9dc217 100644
--- a/fileformats/mp4/parser/src/dataentryatom.cpp
+++ b/fileformats/mp4/parser/src/dataentryatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/dataentryurlatom.cpp b/fileformats/mp4/parser/src/dataentryurlatom.cpp
index 4cd2d6c..489e3b5 100644
--- a/fileformats/mp4/parser/src/dataentryurlatom.cpp
+++ b/fileformats/mp4/parser/src/dataentryurlatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,9 @@
                 _mp4ErrorCode = READ_DATA_ENTRY_URL_ATOM_FAILED;
             }
 
+            //We DO NOT SUPPORT NON-SELF CONTAINED files.
+            //So flag ERROR, and return
+
             _success = false;
             _mp4ErrorCode = MEDIA_DATA_NOT_SELF_CONTAINED;
         }
diff --git a/fileformats/mp4/parser/src/datainformationatom.cpp b/fileformats/mp4/parser/src/datainformationatom.cpp
index f2488fc..eddbb7a 100644
--- a/fileformats/mp4/parser/src/datainformationatom.cpp
+++ b/fileformats/mp4/parser/src/datainformationatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/datareferenceatom.cpp b/fileformats/mp4/parser/src/datareferenceatom.cpp
index 552c8f4..6816750 100644
--- a/fileformats/mp4/parser/src/datareferenceatom.cpp
+++ b/fileformats/mp4/parser/src/datareferenceatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/decoderconfigdescriptor.cpp b/fileformats/mp4/parser/src/decoderconfigdescriptor.cpp
index c9ca0bf..609819e 100644
--- a/fileformats/mp4/parser/src/decoderconfigdescriptor.cpp
+++ b/fileformats/mp4/parser/src/decoderconfigdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
 /*     -------------------------------------------------------------------       */
 /*********************************************************************************/
 
+
+
 #define IMPLEMENT_DecoderConfigDescriptor
 
 #include "decoderconfigdescriptor.h"
@@ -63,6 +65,7 @@
         uint32 base = 1 + _sizeOfSizeField;
         uint32 bytesRead = 13 + base;
 
+
         if (_success)
         {
             if (bytesRead < _sizeOfClass)
@@ -190,3 +193,5 @@
 }
 
 
+
+
diff --git a/fileformats/mp4/parser/src/decoderspecificinfo.cpp b/fileformats/mp4/parser/src/decoderspecificinfo.cpp
index 328fdbc..d76c58e 100644
--- a/fileformats/mp4/parser/src/decoderspecificinfo.cpp
+++ b/fileformats/mp4/parser/src/decoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/editatom.cpp b/fileformats/mp4/parser/src/editatom.cpp
index 968e00b..55a1927 100644
--- a/fileformats/mp4/parser/src/editatom.cpp
+++ b/fileformats/mp4/parser/src/editatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,6 +65,7 @@
                 _mp4ErrorCode = READ_UNKNOWN_ATOM;
                 break;
             }
+
         }
     }
 }
diff --git a/fileformats/mp4/parser/src/editlistatom.cpp b/fileformats/mp4/parser/src/editlistatom.cpp
index 7038f14..53e2260 100644
--- a/fileformats/mp4/parser/src/editlistatom.cpp
+++ b/fileformats/mp4/parser/src/editlistatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/es_id_inc.cpp b/fileformats/mp4/parser/src/es_id_inc.cpp
index 8ffd135..41117d3 100644
--- a/fileformats/mp4/parser/src/es_id_inc.cpp
+++ b/fileformats/mp4/parser/src/es_id_inc.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/es_id_ref.cpp b/fileformats/mp4/parser/src/es_id_ref.cpp
index 0606b59..de06c83 100644
--- a/fileformats/mp4/parser/src/es_id_ref.cpp
+++ b/fileformats/mp4/parser/src/es_id_ref.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/esdatom.cpp b/fileformats/mp4/parser/src/esdatom.cpp
index 180f465..e9e5b67 100644
--- a/fileformats/mp4/parser/src/esdatom.cpp
+++ b/fileformats/mp4/parser/src/esdatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/esdescriptor.cpp b/fileformats/mp4/parser/src/esdescriptor.cpp
index a4a7a75..9634a5e 100644
--- a/fileformats/mp4/parser/src/esdescriptor.cpp
+++ b/fileformats/mp4/parser/src/esdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/expandablebaseclass.cpp b/fileformats/mp4/parser/src/expandablebaseclass.cpp
index 51b5134..a49be59 100644
--- a/fileformats/mp4/parser/src/expandablebaseclass.cpp
+++ b/fileformats/mp4/parser/src/expandablebaseclass.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -93,7 +93,6 @@
 
     }
 
-    // Fix to be compatible with 1.0, 2.0, and Philips
     // Size field only size of descriptor data - not including tag and
     // size field itself.  Need to add tag and size field to _sizeOfClass
     // so we can handle the descriptors as we did in 1.0
diff --git a/fileformats/mp4/parser/src/filetypeatom.cpp b/fileformats/mp4/parser/src/filetypeatom.cpp
index d5a566c..25cad21 100644
--- a/fileformats/mp4/parser/src/filetypeatom.cpp
+++ b/fileformats/mp4/parser/src/filetypeatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
     {
         PV_MP4_FF_NEW(fp->auditCB, uint32VecType, (), _pCompatible_brand);
 
+
         // ftype size is only 8. In that case we should not read beyond the atom boundry blindly
         atomSize = getSize();
         int32 count = atomSize;
diff --git a/fileformats/mp4/parser/src/fontrecord.cpp b/fileformats/mp4/parser/src/fontrecord.cpp
index 1afdbd6..32741e6 100644
--- a/fileformats/mp4/parser/src/fontrecord.cpp
+++ b/fileformats/mp4/parser/src/fontrecord.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,7 @@
             _mp4ErrorCode = READ_FONT_RECORD_FAILED;
         }
     }
+
 }
 
 FontRecord::~FontRecord()
diff --git a/fileformats/mp4/parser/src/fonttableatom.cpp b/fileformats/mp4/parser/src/fonttableatom.cpp
index 2dd12b3..260e8ff 100644
--- a/fileformats/mp4/parser/src/fonttableatom.cpp
+++ b/fileformats/mp4/parser/src/fonttableatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/fullatom.cpp b/fileformats/mp4/parser/src/fullatom.cpp
index 4b4d559..a9416e3 100644
--- a/fileformats/mp4/parser/src/fullatom.cpp
+++ b/fileformats/mp4/parser/src/fullatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/h263decoderspecificinfo.cpp b/fileformats/mp4/parser/src/h263decoderspecificinfo.cpp
index 2d55be2..de57081 100644
--- a/fileformats/mp4/parser/src/h263decoderspecificinfo.cpp
+++ b/fileformats/mp4/parser/src/h263decoderspecificinfo.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/h263sampleentry.cpp b/fileformats/mp4/parser/src/h263sampleentry.cpp
index 49f50f1..fb91161 100644
--- a/fileformats/mp4/parser/src/h263sampleentry.cpp
+++ b/fileformats/mp4/parser/src/h263sampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/handleratom.cpp b/fileformats/mp4/parser/src/handleratom.cpp
index 1e0c0a5..f570880 100644
--- a/fileformats/mp4/parser/src/handleratom.cpp
+++ b/fileformats/mp4/parser/src/handleratom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -62,7 +62,6 @@
 
         //Skip rest of the handler atom - it has no info of value to us
         AtomUtils::seekFromCurrPos(fp, count);
-
     }
     else
     {
diff --git a/fileformats/mp4/parser/src/hintmediaheaderatom.cpp b/fileformats/mp4/parser/src/hintmediaheaderatom.cpp
index 823eeb6..20165a0 100644
--- a/fileformats/mp4/parser/src/hintmediaheaderatom.cpp
+++ b/fileformats/mp4/parser/src/hintmediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/impeg4file.cpp b/fileformats/mp4/parser/src/impeg4file.cpp
index f9b1015..4334f99 100644
--- a/fileformats/mp4/parser/src/impeg4file.cpp
+++ b/fileformats/mp4/parser/src/impeg4file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,79 +53,6 @@
 
 
 /* ======================================================================== */
-// Static method to read in an MP4 file from disk and return the IMpeg4File interface
-OSCL_EXPORT_REF IMpeg4File* IMpeg4File::readMP4File(OSCL_wString& filename,
-        uint32 parsingMode,
-        Oscl_FileServer* fileServSession)
-{
-    //optimized mode is not supported if multiple file ptrs are not allowed
-    if (parsingMode == 1)
-    {
-#ifndef OPEN_FILE_ONCE_PER_TRACK
-        parsingMode = 0;
-#endif
-    }
-
-    MP4_FF_FILE fileStruct;
-    MP4_FF_FILE *fp = &fileStruct;
-    fp->_fileServSession = fileServSession;
-    if (AtomUtils::OpenMP4File(filename,
-                               Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
-                               fp) != 0)
-    {
-        return NULL;
-    }
-
-    int32 fileSize = 0;
-    int32 filePointer = 0;
-    filePointer = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekToEnd(fp);
-    fileSize = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekFromStart(fp, filePointer);
-
-    fp->_fileSize = fileSize;
-
-    Mpeg4File *mp4 = NULL;
-    PV_MP4_FF_NEW(fp->auditCB, Mpeg4File, (fp, filename, parsingMode), mp4);
-
-    return mp4;
-}
-
-OSCL_EXPORT_REF IMpeg4File* IMpeg4File::readMP4File(MP4_FF_FILE_REFERENCE fileRef,
-        uint32 parsingMode)
-{
-    //optimized mode is not supported if multiple file ptrs are not allowed
-    if (parsingMode == 1)
-    {
-#ifndef OPEN_FILE_ONCE_PER_TRACK
-        parsingMode = 0;
-#endif
-    }
-
-    //Create a dummy string to hold the file name
-    OSCL_wHeapString<OsclMemAllocator> filename(_STRLIT(""));
-
-    MP4_FF_FILE fileStruct;
-    MP4_FF_FILE *fp = &fileStruct;
-
-    fp->_pvfile.SetFilePtr(fileRef);
-
-    int32 fileSize;
-    int32 filePointer;
-    AtomUtils::seekFromStart(fp, 0);
-    filePointer = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekToEnd(fp);
-    fileSize = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekFromStart(fp, filePointer);
-
-    fp->_fileSize = fileSize;
-
-    Mpeg4File *mp4 = NULL;
-
-    PV_MP4_FF_NEW(fp->auditCB, Mpeg4File, (fp, filename, parsingMode), mp4);
-
-    return mp4;
-}
 OSCL_EXPORT_REF  IMpeg4File *IMpeg4File::readMP4File(OSCL_wString& aFilename,
         PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
         OsclFileHandle* aHandle,
@@ -161,10 +88,20 @@
     Mpeg4File *mp4 = NULL;
     PV_MP4_FF_NEW(fp->auditCB, Mpeg4File, (fp, aFilename, aParsingMode), mp4);
 
+#ifdef OPEN_FILE_ONCE_PER_TRACK
+    if (mp4 != NULL)
+    {
+        if (!mp4->IsMovieFragmentsPresent())
+        {
+            if (fp->IsOpen())
+                AtomUtils::CloseMP4File(fp);
+        }
+    }
+#endif
+
     return mp4;
 }
 
-// IMOTION_PSEUDO_STREAMING start
 //IsXXXable	*******************************************
 /*
 oMoovBeforeMdat: as input,
@@ -536,177 +473,8 @@
     AtomUtils::CloseMP4File(fp);
     return (mp4ErrorCode);
 }
-// IMOTION_PSEUDO_STREAMING end
 
 
-OSCL_EXPORT_REF bool IMpeg4File::IsMP4File(OSCL_wString& filename,
-        Oscl_FileServer* fileServSession)
-{
-    bool oReturn = false;
-    MP4_FF_FILE fileStruct;
-    MP4_FF_FILE *fp = &fileStruct;
-
-    fp->_fileServSession = fileServSession;
-
-    if (AtomUtils::OpenMP4File(filename,
-                               Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
-                               fp) != 0)
-    {
-        return (oReturn);
-    }
-
-    int32 fileSize;
-    int32 filePointer;
-    filePointer = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekToEnd(fp);
-    fileSize = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekFromStart(fp, filePointer);
-    fp->_fileSize = fileSize;
-
-    int32 fpos = filePointer;
-
-    while (fpos < fileSize)
-    {
-        uint32 atomType = UNKNOWN_ATOM;
-        uint32 atomSize = 0;
-
-        AtomUtils::getNextAtomType(fp, atomSize, atomType);
-
-        if (atomType != UNKNOWN_ATOM)
-        {
-            oReturn = true;
-            break;
-        }
-        else
-        {
-            if (atomSize < DEFAULT_ATOM_SIZE)
-            {
-                break;
-            }
-            if (fileSize < (int32)atomSize)
-            {
-                break;
-            }
-            atomSize -= DEFAULT_ATOM_SIZE;
-            AtomUtils::seekFromCurrPos(fp, atomSize);
-            fpos = AtomUtils::getCurrentFilePosition(fp);
-        }
-    }
-
-    AtomUtils::CloseMP4File(fp);
-    return (oReturn);
-}
-
-
-OSCL_EXPORT_REF bool IMpeg4File::IsMP4File(MP4_FF_FILE_REFERENCE filePtr)
-{
-    bool oReturn = false;
-    MP4_FF_FILE fileStruct;
-    MP4_FF_FILE *fp = &fileStruct;
-
-    fp->_pvfile.SetFilePtr(filePtr);
-
-    int32 fileSize;
-    int32 filePointer;
-    AtomUtils::seekFromStart(fp, 0);
-    filePointer = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekToEnd(fp);
-    fileSize = AtomUtils::getCurrentFilePosition(fp);
-    AtomUtils::seekFromStart(fp, filePointer);
-    fp->_fileSize = fileSize;
-
-    int32 fpos = filePointer;
-
-    while (fpos < fileSize)
-    {
-        uint32 atomType = UNKNOWN_ATOM;
-        uint32 atomSize = 0;
-
-        AtomUtils::getNextAtomType(fp, atomSize, atomType);
-
-        if (atomType != UNKNOWN_ATOM)
-        {
-            oReturn = true;
-            break;
-        }
-        else
-        {
-            if (atomSize < DEFAULT_ATOM_SIZE)
-            {
-                break;
-            }
-            if (fileSize < (int32)atomSize)
-            {
-                break;
-            }
-            atomSize -= DEFAULT_ATOM_SIZE;
-            AtomUtils::seekFromCurrPos(fp, atomSize);
-            fpos = AtomUtils::getCurrentFilePosition(fp);
-        }
-    }
-
-    return (oReturn);
-}
-
-OSCL_EXPORT_REF bool IMpeg4File::IsMP4File(PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
-        Oscl_FileServer* aFileServSession,
-        OsclFileHandle* aHandle)
-{
-    bool oReturn = false;
-
-    /* use a dummy string for file name */
-    OSCL_wHeapString<OsclMemAllocator> filename;
-
-    MP4_FF_FILE fileStruct;
-    MP4_FF_FILE *fp = &fileStruct;
-    fp->_fileServSession = aFileServSession;
-    fp->_pvfile.SetCPM(aCPMAccessFactory);
-    fp->_pvfile.SetFileHandle(aHandle);
-
-    if (AtomUtils::OpenMP4File(filename,
-                               Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
-                               fp) != 0)
-    {
-        return oReturn;
-    }
-
-    uint32 fileSize;
-    AtomUtils::getCurrentFileSize(fp, fileSize);
-    fp->_fileSize = (int32)fileSize;
-    int32 fpos = AtomUtils::getCurrentFilePosition(fp);
-
-    while (fpos < (int32)fileSize)
-    {
-        uint32 atomType = UNKNOWN_ATOM;
-        uint32 atomSize = 0;
-
-        AtomUtils::getNextAtomType(fp, atomSize, atomType);
-
-        if (atomType != UNKNOWN_ATOM)
-        {
-            oReturn = true;
-            break;
-        }
-        else
-        {
-            if (atomSize < DEFAULT_ATOM_SIZE)
-            {
-                break;
-            }
-            if (fileSize < atomSize)
-            {
-                break;
-            }
-            atomSize -= DEFAULT_ATOM_SIZE;
-            AtomUtils::seekFromCurrPos(fp, atomSize);
-            fpos = AtomUtils::getCurrentFilePosition(fp);
-        }
-    }
-
-    AtomUtils::CloseMP4File(fp);
-    return (oReturn);
-}
-
 OSCL_EXPORT_REF MP4_ERROR_CODE
 IMpeg4File::IsProgressiveDownloadable(MP4_FF_FILE_REFERENCE filePtr,
                                       uint32 fileSize,
@@ -854,6 +622,7 @@
                 (atomType == UNKNOWN_ATOM))
         {
             fpos += atomSize;
+            metaDataSize = fpos;
             if ((uint32)fpos > fileSize)
             {
                 break;
@@ -871,6 +640,7 @@
         {
             fpos += atomSize;
             oMediaDataAtomFound  = true;
+            metaDataSize = fpos;
         }
         else
         {
diff --git a/fileformats/mp4/parser/src/initialobjectdescriptor.cpp b/fileformats/mp4/parser/src/initialobjectdescriptor.cpp
index de18fac..d49d904 100644
--- a/fileformats/mp4/parser/src/initialobjectdescriptor.cpp
+++ b/fileformats/mp4/parser/src/initialobjectdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 /*     -------------------------------------------------------------------       */
 /*********************************************************************************/
 
+
 #define IMPLEMENT_InitialObjectDescriptor
 
 #include "initialobjectdescriptor.h"
diff --git a/fileformats/mp4/parser/src/itunesilstatom.cpp b/fileformats/mp4/parser/src/itunesilstatom.cpp
index a4e85ae..6bdfa99 100644
--- a/fileformats/mp4/parser/src/itunesilstatom.cpp
+++ b/fileformats/mp4/parser/src/itunesilstatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,18 +15,143 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-	This ITunesILSTAtom Class is used for Parsing, and Storing the tags from Meta data
-	of ITune M4A file.
-*/
-
 #include "itunesilstatom.h"
 #include "atomdefs.h"
 #include "atomutils.h"
 #include "oscl_int64_utils.h"
 #include "oscl_utf8conv.h"
 
+typedef Oscl_Vector<ItunesMeaningAtom*, OsclMemAllocator> ItunesMeaningAtomVecType;
+typedef Oscl_Vector<ItunesNameAtom*, OsclMemAllocator> ItunesNameAtomVecType;
+
+//************************************MeaningAtom Class Starts  **********************************
+ItunesMeaningAtom::ItunesMeaningAtom(MP4_FF_FILE *fp,
+                                     uint32 size,
+                                     uint32 type)
+        : FullAtom(fp, size, type)
+{
+    int32 nSize = (int32)(size - DEFAULT_FULL_ATOM_SIZE);
+    if (nSize > 0)
+    {
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
+        {
+            if (!AtomUtils::readByteData(fp, nSize, buf))
+            {
+                _success = false;
+                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+
+
+            }
+            else
+            {
+                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                _meaningString = temp;
+            }
+        }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+
+
+        }
+
+        /*Delete the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
+    }
+    else
+    {
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+
+    }
+
+}
+
+
+ItunesMeaningAtom::~ItunesMeaningAtom()
+{
+
+
+}
+
+//************************************NameAtom Class Starts  **********************************
+ItunesNameAtom::ItunesNameAtom(MP4_FF_FILE *fp,
+                               uint32 size,
+                               uint32 type)
+        : FullAtom(fp, size, type)
+{
+
+    int32 nSize = (int32)(size - DEFAULT_FULL_ATOM_SIZE);
+    if (nSize > 0)
+    {
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
+        {
+            if (!AtomUtils::readByteData(fp, nSize, buf))
+            {
+                _success = false;
+                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+
+            }
+            else
+            {
+                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                _nameString = temp;
+            }
+        }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+
+        }
+
+        /*Delete the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
+    }
+    else
+    {
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+
+    }
+
+}
+
+
+ItunesNameAtom::~ItunesNameAtom()
+{
+}
+
+//************************************BaseTypes for the MetaData **********************************
 ITunesMetaDataAtom::ITunesMetaDataAtom(MP4_FF_FILE *fp, uint32 size, uint32 type): Atom(fp, size, type)
 {
 
@@ -49,42 +174,72 @@
                                  uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTitleAtom::ITunesTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _name = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTitleAtom::ITunesTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _name = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTitleAtom::ITunesTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTitleAtom::ITunesTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTitleAtom::ITunesTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
 }
 
 
@@ -92,6 +247,86 @@
 {
 }
 
+//************************************ Track's Subtitle Class Starts **********************************
+
+ITunesTrackSubTitleAtom::ITunesTrackSubTitleAtom(MP4_FF_FILE *fp,
+        uint32 size,
+        uint32 type)
+        : ITunesMetaDataAtom(fp, size, type)
+{
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
+    AtomUtils::getNextAtomType(fp, atomSize, atomType);
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
+    {
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
+        {
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+            {
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTrackSubTitleAtom::ITunesTrackSubTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _trackTitle = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTrackSubTitleAtom::ITunesTrackSubTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
+
+            }
+        }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTrackSubTitleAtom::ITunesTrackSubTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
+    }
+    else
+    {
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTrackSubTitleAtom::ITunesTrackSubTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+    }
+}
+
+
+ITunesTrackSubTitleAtom::~ITunesTrackSubTitleAtom()
+{
+}
+
 
 //************************************ Artist / Performer Class Starts  **********************************
 ITunesArtistAtom::ITunesArtistAtom(MP4_FF_FILE *fp,
@@ -99,41 +334,70 @@
                                    uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesArtistAtom::ITunesArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _artist = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesArtistAtom::ITunesArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _artist = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesArtistAtom::ITunesArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesArtistAtom::ITunesArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesArtistAtom::ITunesArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
@@ -142,47 +406,155 @@
 {
 }
 
+//************************************AlbumArtist Class Starts  **********************************
+ITunesAlbumArtistAtom::ITunesAlbumArtistAtom(MP4_FF_FILE *fp,
+        uint32 size,
+        uint32 type)
+        : ITunesMetaDataAtom(fp, size, type)
+{
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
+    AtomUtils::getNextAtomType(fp, atomSize, atomType);
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
+    {
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
+        {
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+            {
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumArtistAtom::ITunesAlbumArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _albumArtist = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumArtistAtom::ITunesAlbumArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
+            }
+        }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumArtistAtom::ITunesAlbumArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
+    }
+    else
+    {
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumArtistAtom::ITunesAlbumArtistAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+    }
+}
+
+
+ITunesAlbumArtistAtom::~ITunesAlbumArtistAtom()
+{
+}
+
 //************************************ Album Class Starts  **********************************
 ITunesAlbumAtom::ITunesAlbumAtom(MP4_FF_FILE *fp,
                                  uint32 size,
                                  uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumAtom::ITunesAlbumAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _album = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumAtom::ITunesAlbumAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _album = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumAtom::ITunesAlbumAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
+
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumAtom::ITunesAlbumAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesAlbumAtom::ITunesAlbumAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
@@ -197,54 +569,82 @@
                                  uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
     _gnreString = NULL;
-
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            _gnreVersion = STRING_GENRE;
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _gnreString = temp;
+                _gnreVersion = STRING_GENRE;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _gnreString = temp;
+                    }
+                }
+                else if (_prefix == INTEGER_PREFIX)
+                {
+                    _gnreVersion = INTEGER_GENRE;
+                    if (!AtomUtils::read16(fp, _gnreID))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED  _prefix == INTEGER_PREFIX"));
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string/Integer"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
             }
         }
-        else if (_prefix == INTEGER_PREFIX)
+        else
         {
-            _gnreVersion = INTEGER_GENRE;
-            if (!AtomUtils::read16(fp, _gnreID))
-            {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED  _prefix == INTEGER_PREFIX"));
-            }
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
         }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGenreAtom::ITunesGenreAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
@@ -259,41 +659,69 @@
                                uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesYearAtom::ITunesYearAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _day = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesYearAtom::ITunesYearAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _day = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTitleAtom::ITunesTitleAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesYearAtom::ITunesYearAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesYearAtom::ITunesYearAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
@@ -308,89 +736,223 @@
                                uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesToolAtom::ITunesToolAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _tool = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesToolAtom::ITunesToolAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _tool = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesToolAtom::ITunesToolAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesToolAtom::ITunesToolAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesToolAtom::ITunesToolAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
+
 ITunesToolAtom::~ITunesToolAtom()
 {
 }
 
+//************************************ EncodedBy Class Starts  **********************************
+ITunesEncodedByAtom::ITunesEncodedByAtom(MP4_FF_FILE *fp,
+        uint32 size,
+        uint32 type)
+        : ITunesMetaDataAtom(fp, size, type)
+{
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
+    AtomUtils::getNextAtomType(fp, atomSize, atomType);
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
+    {
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
+        {
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+            {
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesEncodedByAtom::ITunesEncodedByAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _encodedBy = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesEncodedByAtom::ITunesEncodedByAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+            }
+        }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesEncodedByAtom::ITunesEncodedByAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
+    }
+    else
+    {
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesEncodedByAtom::ITunesEncodedByAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+    }
+
+}
+
+ITunesEncodedByAtom::~ITunesEncodedByAtom()
+{
+}
+
 //************************************ Writer Class Starts  **********************************
 ITunesWriterAtom::ITunesWriterAtom(MP4_FF_FILE *fp,
                                    uint32 size,
                                    uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesWriterAtom::ITunesWriterAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _writer = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesWriterAtom::ITunesWriterAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _writer = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesWriterAtom::ITunesWriterAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesWriterAtom::ITunesWriterAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesWriterAtom::ITunesWriterAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
@@ -405,43 +967,71 @@
                                  uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesYearAtom::ITunesYearAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-                return;
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _group = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGroupAtom::ITunesGroupAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _group = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGroupAtom::ITunesGroupAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGroupAtom::ITunesGroupAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesGroupAtom::ITunesGroupAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
 }
 
 
@@ -455,42 +1045,71 @@
                                      uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCommentAtom::ITunesCommentAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _comment = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCommentAtom::ITunesCommentAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _comment = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCommentAtom::ITunesCommentAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCommentAtom::ITunesCommentAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCommentAtom::ITunesCommentAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
 }
 
 
@@ -545,8 +1164,11 @@
             _success = false;
             _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
             PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesTracktAtom::ITunesTracktAtom READ_ITUNES_ILST_META_DATA_FAILED  else "));
-            return;
+
+
         }
+
+
     }
 }
 
@@ -560,10 +1182,8 @@
                                      uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
+    uint32 atomType, atomSize;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-
     if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
     {
         if (_prefix == OTHER_PREFIX)
@@ -586,9 +1206,16 @@
             _success = false;
             _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
             PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCompileAtom::ITunesCompileAtom READ_ITUNES_ILST_META_DATA_FAILED  else"));
-            return;
         }
     }
+    else
+    {
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCompileAtom::ITunesCompileAtom READ_ITUNES_ILST_META_DATA_FAILED  if(_prefix == OTHER_PREFIX)"));
+        return;
+
+    }
 }
 
 
@@ -596,16 +1223,57 @@
 {
 }
 
+//********************************* Content Rating Class Starts  ********************************
+ITunesContentRatingAtom::ITunesContentRatingAtom(MP4_FF_FILE *fp,
+        uint32 size,
+        uint32 type)
+        : ITunesMetaDataAtom(fp, size, type)
+{
+    uint32 atomType, atomSize;
+    AtomUtils::getNextAtomType(fp, atomSize, atomType);
+    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    {
+        if (_prefix == OTHER_PREFIX)
+        {
+            uint8 ratingData;
+            if (!AtomUtils::read8(fp, ratingData))
+            {
+                _success = false;
+                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesContentRatingAtom::ITunesContentRatingAtom READ_ITUNES_ILST_META_DATA_FAILED  if(_prefix == OTHER_PREFIX)"));
+                return;
+            }
+            if (ratingData)
+                _contentRating = true;
+            else
+                _contentRating = false;
+        }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesContentRatingAtom::ITunesContentRatingAtom READ_ITUNES_ILST_META_DATA_FAILED  else"));
+            return;
+        }
+    }
+}
+
+
+ITunesContentRatingAtom::~ITunesContentRatingAtom()
+{
+}
+
+
+
+
 //************************************ Tempo Class Starts  **********************************
 ITunesTempoAtom::ITunesTempoAtom(MP4_FF_FILE *fp,
                                  uint32 size,
                                  uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
+    uint32 atomType, atomSize;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-
     if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
     {
         if (_prefix == OTHER_PREFIX)
@@ -640,42 +1308,71 @@
         uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCopyrightAtom::ITunesCopyrightAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _cprt = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCopyrightAtom::ITunesCopyrightAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _cprt = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCopyrightAtom::ITunesCopyrightAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCopyrightAtom::ITunesCopyrightAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCopyrightAtom::ITunesCopyrightAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
 }
 
 
@@ -683,48 +1380,78 @@
 {
 
 }
+
 //************************************ Description Class Starts  **********************************
 ITunesDescriptionAtom::ITunesDescriptionAtom(MP4_FF_FILE *fp,
         uint32 size,
         uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesDescriptionAtom::ITunesDescriptionAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _desc = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesDescriptionAtom::ITunesDescriptionAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _desc = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesDescriptionAtom::ITunesDescriptionAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
             }
         }
+        else
+        {
+            _success = false;
+            _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesDescriptionAtom::ITunesDescriptionAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
+        }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesDescriptionAtom::ITunesDescriptionAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
 }
 
 
@@ -787,56 +1514,85 @@
         : ITunesMetaDataAtom(fp, size, type)
 {
     uint32 atomType = type;
-    uint32 atomSize = size;
-    uint32 nSize;
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    int32 nSize = 0;
+    nSize = (int32)(size - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormdataAtom::ITunesFreeFormDataAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _StringData = temp;
-            }
-        }
-        else if (_prefix == OTHER_PREFIX)
-        {
-            // reading the data to keep atom alignment
-            uint32 readData;
-            if (!AtomUtils::read32(fp, readData))
-            {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom Read four bytes (%d) in OTHER_PREFIX", readData));
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _StringData = temp;
+                    }
+                }
+                else if (_prefix == OTHER_PREFIX)
+                {
+                    // reading the data to keep atom alignment
+                    uint32 readData;
+                    if (!AtomUtils::read32(fp, readData))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom Read four bytes (%d) in OTHER_PREFIX", readData));
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix  doesnt match.
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
+
+
+
             }
         }
         else
         {
             _success = false;
             _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom READ_ITUNES_ILST_META_DATA_FAILED  else"));
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
         }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesFreeFormDataAtom::ITunesFreeFormDataAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
+
 }
 
 
@@ -845,54 +1601,78 @@
 
 }
 
-
 //************************************ Lyrics Class Starts  **********************************
 ITunesLyricsAtom::ITunesLyricsAtom(MP4_FF_FILE *fp,
                                    uint32 size,
                                    uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM, atomSize = 0;
+    int32 nSize = 0;
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-    nSize = atomSize - 16;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    nSize = (int32)(atomSize - PREFIX_SIZE);
+    if (nSize > 0)
     {
-        if (_prefix == STRING_PREFIX)
+        uint8* buf = NULL;
+        uint8* outbuf = NULL;
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, nSize, buf);
+        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, ((nSize + 1)*sizeof(oscl_wchar)), outbuf);
+        if (buf && outbuf)
         {
-            if (!AtomUtils::readByteData(fp, nSize, buf))
+            if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
             {
-                _success = false;
-                _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesLyricsAtom::ITunesLyricsAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-            }
-            else
-            {
-                oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                _lyrics = temp;
+                if (_prefix == STRING_PREFIX)
+                {
+                    if (!AtomUtils::readByteData(fp, nSize, buf))
+                    {
+                        _success = false;
+                        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesLyricsAtom::ITunesLyricsAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                    }
+                    else
+                    {
+                        oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
+                        OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
+                        _lyrics = temp;
+                    }
+                }
+                else //if atomType is not "DataAtom" and/or _prefix is not "string"
+                {
+
+                    _success = false;
+                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesLyricsAtom::ITunesLyricsAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+                }
+
+
+
             }
         }
         else
         {
             _success = false;
             _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesLyricsAtom::ITunesLyricsAtom READ_ITUNES_ILST_META_DATA_FAILED  else"));
+            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesLyricsAtom::ITunesLyricsAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
+        }
+        /*Deleting the buffers*/
+        if (buf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+            buf = NULL;
+        }
+        if (outbuf)
+        {
+            PV_MP4_ARRAY_FREE(fp->auditCB, outbuf);
+            outbuf = NULL;
         }
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
-    }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
+        _success = false;
+        _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesLyricsAtom::ITunesLyricsAtom READ_ITUNES_ILST_META_DATA_FAILED"));
+
     }
 }
 
@@ -907,48 +1687,40 @@
         uint32 type)
         : ITunesMetaDataAtom(fp, size, type)
 {
-    uint32 atomType;
-    uint32 atomSize;
-    uint32 nSize;
+    uint32 atomType = UNKNOWN_ATOM;
+    uint32 atomSize = 0;
     _ImageData = NULL;
-    nSize = 3;
-    uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-    uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
     AtomUtils::getNextAtomType(fp, atomSize, atomType);
-
-    uint32 count = atomSize;
-
-    count -= DEFAULT_ATOM_SIZE;
-
-    if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
+    int32 count = (int32)(atomSize - DEFAULT_ATOM_SIZE);
+    if (count > 0)
     {
-        count -= 8;
-        if (count < ITUNES_MAX_COVER_IMAGE_SIZE)
+
+        if (atomType == ITUNES_ILST_DATA_ATOM && AtomUtils::read64(fp, _prefix))
         {
-            //treat rest of the atom as image
-            _ImageData = OSCL_NEW(PvmfApicStruct, ());
-            _ImageData->iGraphicData = (uint8*)OSCL_MALLOC(count);
-            AtomUtils::readByteData(fp, count, _ImageData->iGraphicData);
-            _ImageData->iGraphicDataLen = count;
+            count -= 8;
+            if (count < ITUNES_MAX_COVER_IMAGE_SIZE)
+            {
+                //treat rest of the atom as image
+                PV_MP4_FF_NEW(fp->auditCB, PvmfApicStruct, (), _ImageData);
+                PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, uint8, count, _ImageData->iGraphicData);
+                AtomUtils::readByteData(fp, count, _ImageData->iGraphicData);
+                _ImageData->iGraphicDataLen = count;
+            }
+            else
+            {
+                _success = false;
+                PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCoverImageAtom::ITunesCoverImageAtom READ_ITUNES_ILST_META_DATA_FAILED  else[if (_prefix == IMAGE_PREFIX_PNG)]  )"));
+            }
         }
-        else
-        {
-            // skip rest of the atom
-            fp->_pvfile.Seek(count, Oscl_File::SEEKCUR);
-            count = 0;
-            PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCoverImageAtom::ITunesCoverImageAtom READ_ITUNES_ILST_META_DATA_FAILED  else[if (_prefix == IMAGE_PREFIX_PNG)]  )"));
-        }
+
     }
-    if (buf)
+    else
     {
-        OSCL_FREE(buf);
-        buf = NULL;
+        _success = false;
+        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCoverImageAtom::ITunesCoverImageAtom READ_ITUNES_ILST_META_DATA_FAILED  else[if (_prefix == IMAGE_PREFIX_PNG)]  )"));
+
     }
-    if (outbuf)
-    {
-        OSCL_FREE(outbuf);
-        outbuf = NULL;
-    }
+
 }
 
 
@@ -958,9 +1730,10 @@
     {
         if (_ImageData->iGraphicData != NULL)
         {
-            OSCL_FREE(_ImageData->iGraphicData);
+            PV_MP4_ARRAY_FREE(fp->auditCB, _ImageData->iGraphicData);
+
         }
-        OSCL_DELETE(_ImageData);
+        PV_MP4_FF_DELETE(fp->auditCB, PvmfApicStruct, _ImageData);
         _ImageData = NULL;
     }
 }
@@ -969,13 +1742,19 @@
 {
     _success = true;
 
+    _pITunesMeaningAtom = NULL;
+    _pITunesNameAtom    = NULL;
+    _pMeaningAtomVec    = NULL;
+    _pNameAtomVec       = NULL;
     _pITunesTitleAtom = NULL;
+    _pITunesTrackSubTitleAtom = NULL;
     _pITunesCompileAtom = NULL;
+    _pITunesContentRatingAtom = NULL;
     _pITunesTempoAtom =  NULL;
     _pITunesCopyrightAtom =  NULL;
     _pITunesDescriptionAtom =  NULL;
-
     _pITunesToolAtom = NULL;
+    _pITunesEncodedByAtom = NULL;
     _pITunesNormalizationFreeFormDataAtom = NULL;
     _pITunesNormalizationFreeFormDataToolAtom = NULL;
     _iITunesCDIdentifierFreeFormDataAtomNum = 0;
@@ -983,8 +1762,16 @@
     {
         _pITunesCDIdentifierFreeFormDataAtom[i] = NULL;
     }
+    //Create the vectors
+    PV_MP4_FF_NEW(fp->auditCB, ItunesMeaningAtomVecType, (), _pMeaningAtomVec);
+    PV_MP4_FF_NEW(fp->auditCB, ItunesNameAtomVecType, (), _pNameAtomVec);
+
+
+    _pITunesCDTrackNumberFreeFormDataAtom = NULL;
+    _pITunesCDDB1FreeFormDataAtom = NULL;
     _pITunesAlbumAtom = NULL;
     _pITunesArtistAtom = NULL;
+    _pITunesAlbumArtistAtom = NULL;
     _pITunesGenreAtom = NULL;
     _pITunesYearAtom = NULL;
     _pITunesWriterAtom = NULL;
@@ -1013,7 +1800,7 @@
             return;
         }
 
-        if (atomType == ITUNES_TITLE_ATOM)
+        if (atomType == ITUNES_SONG_TITLE_ATOM)
         {
             PV_MP4_FF_NEW(fp->auditCB, ITunesTitleAtom, (fp, atomsize, atomType), _pITunesTitleAtom);
 
@@ -1028,6 +1815,21 @@
             else
                 count -= _pITunesTitleAtom->getSize();
         }
+        else if (atomType == ITUNES_TRACK_SUBTITLE_ATOM)
+        {
+            PV_MP4_FF_NEW(fp->auditCB, ITunesTrackSubTitleAtom, (fp, atomsize, atomType), _pITunesTrackSubTitleAtom);
+
+            if (!_pITunesTrackSubTitleAtom->MP4Success())
+            {
+                AtomUtils::seekFromStart(fp, currPtr);
+                AtomUtils::seekFromCurrPos(fp, atomsize);
+                PV_MP4_FF_DELETE(NULL, ITunesTrackSubTitleAtom, _pITunesTrackSubTitleAtom);
+                _pITunesTrackSubTitleAtom = NULL;
+                count -= atomsize;
+            }
+            else
+                count -= _pITunesTrackSubTitleAtom->getSize();
+        }
         else if (atomType == ITUNES_COMPILATION_ATOM)
         {
             PV_MP4_FF_NEW(fp->auditCB, ITunesCompileAtom, (fp, atomsize, atomType), _pITunesCompileAtom);
@@ -1043,6 +1845,21 @@
             else
                 count -= _pITunesCompileAtom->getSize();
         }
+        else if (atomType == ITUNES_CONTENT_RATING_ATOM)
+        {
+            PV_MP4_FF_NEW(fp->auditCB, ITunesContentRatingAtom, (fp, atomsize, atomType), _pITunesContentRatingAtom);
+
+            if (!_pITunesContentRatingAtom->MP4Success())
+            {
+                AtomUtils::seekFromStart(fp, currPtr);
+                AtomUtils::seekFromCurrPos(fp, atomsize);
+                PV_MP4_FF_DELETE(NULL, ITunesContentRatingAtom, _pITunesContentRatingAtom);
+                _pITunesContentRatingAtom = NULL;
+                count -= atomsize;
+            }
+            else
+                count -= _pITunesContentRatingAtom->getSize();
+        }
         else if (atomType == ITUNES_BPM_ATOM)
         {
             PV_MP4_FF_NEW(fp->auditCB, ITunesTempoAtom, (fp, atomsize, atomType), _pITunesTempoAtom);
@@ -1091,8 +1908,9 @@
             else
                 count -= _pITunesDescriptionAtom->getSize();
         }
-        else if (atomType == ITUNES_ENCODER_ATOM)
+        else if (atomType == ITUNES_ENCODER_TOOL_ATOM)
         {
+            //Software(tool) which encoded the recording.
             PV_MP4_FF_NEW(fp->auditCB, ITunesToolAtom, (fp, atomsize, atomType), _pITunesToolAtom);
 
             if (!_pITunesToolAtom->MP4Success())
@@ -1106,223 +1924,262 @@
             else
                 count -= _pITunesToolAtom->getSize();
         }
-#if 0
-/* Disable this code for now, as there is an off-by-X bug in the free form atom
- * parsing that causes subsequent atoms to be misparsed, which makes us not see
- * metadata for some files purchased from the itunes music store
- */
+        else if (atomType == ITUNES_ENCODEDBY_ATOM)
+        {
+            //Person or company that encoded the recording.
+            PV_MP4_FF_NEW(fp->auditCB, ITunesEncodedByAtom, (fp, atomsize, atomType), _pITunesEncodedByAtom);
+
+            if (!_pITunesEncodedByAtom->MP4Success())
+            {
+                AtomUtils::seekFromStart(fp, currPtr);
+                AtomUtils::seekFromCurrPos(fp, atomsize);
+                PV_MP4_FF_DELETE(NULL, ITunesEncodedByAtom, _pITunesEncodedByAtom);
+                _pITunesEncodedByAtom = NULL;
+                count -= atomsize;
+            }
+            else
+                count -= _pITunesEncodedByAtom->getSize();
+        }
+
         else if (atomType == ITUNES_FREE_FORM_ATOM)
         {
-            uint32 FreeAtomsize = 0;
-            uint32 FreeAtomType = 0;
-            uint32 nSize = 0;
+
+            uint32 FreeFormAtomType = UNKNOWN_ATOM;
+            uint32 FreeFormAtomSize = 0;
             count -= DEFAULT_ATOM_SIZE;
-            AtomUtils::getNextAtomType(fp, FreeAtomsize, FreeAtomType);
-            count -= 8;
+            atomsize -= DEFAULT_ATOM_SIZE;
 
-            nSize = 16;
-            uint8* buf = (uint8*)OSCL_MALLOC(nSize);
-            uint8* outbuf = (uint8*)OSCL_MALLOC((nSize + 1) * sizeof(oscl_wchar));
-
-            if (FreeAtomType == ITUENES_MEAN_ATOM)
+            while (((FreeFormAtomType == ITUNES_MEAN_ATOM) ||
+                    (FreeFormAtomType == ITUNES_FREE_FORM_DATA_NAME_ATOM) ||
+                    (FreeFormAtomType == ITUNES_ILST_DATA_ATOM) ||
+                    (FreeFormAtomType == UNKNOWN_ATOM)) &&
+                    (atomsize > 0))
             {
-                uint32 _data;
-                OSCL_wHeapString<OsclMemAllocator> meanData;
 
-                if (!AtomUtils::read32(fp, _data))
+                uint32 currPos = AtomUtils::getCurrentFilePosition(fp);
+                AtomUtils::getNextAtomType(fp, FreeFormAtomSize, FreeFormAtomType);
+                if (FreeFormAtomType == ITUNES_MEAN_ATOM)
                 {
-                    _success = false;
-                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesILSTAtom::ITunesILSTAtom READ_ITUNES_ILST_META_DATA_FAILED  if(!AtomUtils::read32(fp,_data))  )"));
-                    if (buf)
+                    PV_MP4_FF_NEW(fp->auditCB, ItunesMeaningAtom, (fp, FreeFormAtomSize, FreeFormAtomType), _pITunesMeaningAtom);
+                    if (!_pITunesMeaningAtom->MP4Success())
                     {
-                        OSCL_FREE(buf);
-                        buf = NULL;
-                    }
-                    if (outbuf)
-                    {
-                        OSCL_FREE(outbuf);
-                        outbuf = NULL;
-                    }
-                    return;
-                }
-                count -= 4;
-
-                if (!AtomUtils::readByteData(fp, nSize, buf))
-                {
-                    _success = false;
-                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesCommentAtom::ITunesCommentAtom READ_ITUNES_ILST_META_DATA_FAILED"));
-                    if (buf)
-                    {
-                        OSCL_FREE(buf);
-                        buf = NULL;
-                    }
-                    if (outbuf)
-                    {
-                        OSCL_FREE(outbuf);
-                        outbuf = NULL;
-                    }
-                    return;
-                }
-                else
-                {
-                    oscl_UTF8ToUnicode((const char *)buf, nSize, (oscl_wchar*)outbuf, nSize + 1);
-                    OSCL_wHeapString<OsclMemAllocator> temp((const oscl_wchar *)outbuf);
-                    meanData = temp;
-                }
-                count -= 16;
-            }
-            if (buf)
-            {
-                OSCL_FREE(buf);
-                buf = NULL;
-            }
-            if (outbuf)
-            {
-                OSCL_FREE(outbuf);
-                outbuf = NULL;
-            }
-
-            uint32 FDNAtomsize = 0;
-            uint32 FDNAtomType = 0;
-            uint32 read_count = 0;
-
-            AtomUtils::getNextAtomType(fp, FDNAtomsize, FDNAtomType);
-            count -= 8;
-
-            if (FDNAtomType == ITUNES_FREE_FORM_DATA_NAME_ATOM)
-            {
-                uint32 _data;
-                if (!AtomUtils::read32(fp, _data))
-                {
-                    _success = false;
-                    _mp4ErrorCode = READ_ITUNES_ILST_META_DATA_FAILED;
-                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesILSTAtom::ITunesILSTAtom READ_ITUNES_ILST_META_DATA_FAILED  if(!AtomUtils::read32(fp,_data))  )"));
-                    return;
-                }
-                count -= 4;
-                read_count += 4;
-
-                uint32 FreeFormType_Part1 = 0;
-                uint32 FreeFormType_Part2 = 0;
-
-                if (!AtomUtils::read32(fp, FreeFormType_Part1))
-                {
-                    _success = false;
-                    _mp4ErrorCode = READ_META_DATA_FAILED;
-                    PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesILSTAtom::ITunesILSTAtom READ_ITUNES_ILST_META_DATA_FAILED  if(!AtomUtils::read32(fp,_data))  )"));
-                    return;
-                }
-                count -= 4;
-                read_count += 4;
-
-                if (FreeFormType_Part1 == ITUNES_FREE_FORM_DATA_ATOM_TYPE_TOOL)
-                {
-                    uint32 normDataAtomSize = 0;
-                    uint32 normDataAtomType = 0;
-                    uint32 Currpos = AtomUtils::getCurrentFilePosition(fp);
-                    AtomUtils::getNextAtomType(fp, normDataAtomSize, normDataAtomType);
-                    PV_MP4_FF_NEW(fp->auditCB,
-                                  ITunesFreeFormDataAtom,
-                                  (fp, normDataAtomSize, normDataAtomType),
-                                  _pITunesNormalizationFreeFormDataToolAtom);
-                    if (!_pITunesNormalizationFreeFormDataToolAtom->MP4Success())
-                    {
-                        AtomUtils::seekFromStart(fp, Currpos);
-                        AtomUtils::seekFromCurrPos(fp, atomsize);
-                    }
-                    count -= _pITunesNormalizationFreeFormDataToolAtom->getSize();
-                }
-                else
-                {
-                    if (!AtomUtils::read32(fp, FreeFormType_Part2))
-                    {
-                        _success = false;
-                        _mp4ErrorCode = READ_META_DATA_FAILED;
-                        PVMF_MP4FFPARSER_LOGERROR((0, "ERROR =>ITunesILSTAtom::ITunesILSTAtom READ_ITUNES_ILST_META_DATA_FAILED  if(!AtomUtils::read32(fp,_data))  )"));
-                        return;
-                    }
-                    count -= 4;
-                    read_count += 4;
-
-                    if (FreeFormType_Part1 == ITUNES_FREE_FORM_DATA_ATOM_TYPE_PART1 &&
-                            FreeFormType_Part2 == ITUNES_FREE_FORM_DATA_ATOM_TYPE_PART2)
-                    {
-                        uint32 normDataAtomSize = 0;
-                        uint32 normDataAtomType = 0;
-                        uint32 Currpos = AtomUtils::getCurrentFilePosition(fp);
-                        AtomUtils::getNextAtomType(fp, normDataAtomSize, normDataAtomType);
-                        PV_MP4_FF_NEW(fp->auditCB,
-                                      ITunesFreeFormDataAtom,
-                                      (fp, normDataAtomSize, normDataAtomType),
-                                      _pITunesNormalizationFreeFormDataAtom);
-                        if (!_pITunesNormalizationFreeFormDataAtom->MP4Success())
-                        {
-                            AtomUtils::seekFromStart(fp, Currpos);
-                            AtomUtils::seekFromCurrPos(fp, atomsize);
-                        }
-                        count -= _pITunesNormalizationFreeFormDataAtom->getSize();
-                    }
-                    else if (FreeFormType_Part2 == ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB)
-                    {
-                        //skipping rest of "iTunes_CDDB_Ids"
-                        uint32 temp_size = FDNAtomsize - (read_count + DEFAULT_ATOM_SIZE);
-                        uint8 *temp_bytes;
-                        uint8 index = 0;
-                        temp_bytes = (uint8*)OSCL_MALLOC(temp_size);
-                        if (temp_bytes)	// malloc can fail
-                        {
-                            while (index < temp_size)
-                            {
-                                AtomUtils::read8(fp, temp_bytes[index++]);
-                            }
-                            OSCL_FREE(temp_bytes);
-                            temp_bytes = NULL;
-                        }
-                        count -= temp_size;
-
-                        uint32 cdIDDataAtomSize = 0;
-                        uint32 cdIDDataAtomType = 0;
-                        uint32 Currpos = AtomUtils::getCurrentFilePosition(fp);
-                        AtomUtils::getNextAtomType(fp, cdIDDataAtomSize, cdIDDataAtomType);
-                        PV_MP4_FF_NEW(fp->auditCB,
-                                      ITunesFreeFormDataAtom,
-                                      (fp, cdIDDataAtomSize, cdIDDataAtomType),
-                                      _pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]);
-
-                        if (!_pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]->MP4Success())
-                        {
-                            AtomUtils::seekFromStart(fp, Currpos);
-                            AtomUtils::seekFromCurrPos(fp, atomsize);
-                        }
-                        count -= _pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]->getSize();
-                        _iITunesCDIdentifierFreeFormDataAtomNum++;
+                        AtomUtils::seekFromStart(fp, currPos);
+                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                        PV_MP4_FF_DELETE(NULL, ItunesMeaningAtom, _pITunesMeaningAtom);
+                        _pITunesMeaningAtom = NULL;
+                        count -= FreeFormAtomSize;
                     }
                     else
                     {
-                        uint32 unknownFormAtomSize = 0;
-                        uint32 unknownFormAtomType = 0;
-                        AtomUtils::getNextAtomType(fp, unknownFormAtomSize, unknownFormAtomType);
-                        //skip
-                        if (unknownFormAtomSize > DEFAULT_ATOM_SIZE)
+                        count -= _pITunesMeaningAtom->getSize();
+                    }
+                    atomsize -= FreeFormAtomSize;
+                    (*_pMeaningAtomVec).push_back(_pITunesMeaningAtom);
+
+                }
+                else if (FreeFormAtomType == ITUNES_FREE_FORM_DATA_NAME_ATOM)
+                {
+                    PV_MP4_FF_NEW(fp->auditCB, ItunesNameAtom, (fp, FreeFormAtomSize, FreeFormAtomType), _pITunesNameAtom);
+                    if (!_pITunesNameAtom->MP4Success())
+                    {
+                        AtomUtils::seekFromStart(fp, currPos);
+                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                        PV_MP4_FF_DELETE(NULL, ItunesNameAtom, _pITunesNameAtom);
+                        _pITunesNameAtom = NULL;
+                        count -= FreeFormAtomSize;
+                    }
+                    else
+                    {
+                        count -= _pITunesNameAtom->getSize();
+                    }
+                    atomsize -= FreeFormAtomSize;
+                    (*_pNameAtomVec).push_back(_pITunesNameAtom);
+
+                }
+                else if (FreeFormAtomType == ITUNES_ILST_DATA_ATOM)
+                {
+                    OSCL_wHeapString<OsclMemAllocator> tempNameString = NULL;
+                    if (_pITunesNameAtom)
+                        tempNameString =  _pITunesNameAtom->getNameString();
+                    const oscl_wchar *wStringPtr = tempNameString.get_cstr();
+                    uint32 nameStringLen = tempNameString.get_size();
+                    if (nameStringLen > 0)
+                    {
+                        char* buf = NULL;
+                        PV_MP4_FF_ARRAY_MALLOC(fp->auditCB, char, (nameStringLen + 1), buf);
+                        if (buf)
                         {
-                            count -= unknownFormAtomSize;
-                            unknownFormAtomSize -= DEFAULT_ATOM_SIZE;
-                            fp->_pvfile.Seek(unknownFormAtomSize, Oscl_File::SEEKCUR);
+
+                            oscl_UnicodeToUTF8(wStringPtr, nameStringLen, buf, nameStringLen + 1);
+                            if (!(oscl_strcmp(buf, ITUNES_FREE_FORM_DATA_ATOM_TYPE_NORM)))
+                            {
+                                if (_pITunesNormalizationFreeFormDataAtom == NULL)
+                                {
+                                    PV_MP4_FF_NEW(fp->auditCB,
+                                                  ITunesFreeFormDataAtom,
+                                                  (fp, FreeFormAtomSize, FreeFormAtomType),
+                                                  _pITunesNormalizationFreeFormDataAtom);
+                                    if (!_pITunesNormalizationFreeFormDataAtom->MP4Success())
+                                    {
+                                        AtomUtils::seekFromStart(fp, currPos);
+                                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                                    }
+                                    count -= _pITunesNormalizationFreeFormDataAtom->getSize();
+                                    atomsize -= _pITunesNormalizationFreeFormDataAtom->getSize();
+                                }
+                                else //Duplicate atom
+                                {
+                                    AtomUtils::seekFromStart(fp, currPos);
+                                    AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                                    count -= FreeFormAtomSize;
+                                    atomsize -= FreeFormAtomSize;
+
+                                }
+
+                            }
+                            else if (!(oscl_strcmp(buf, ITUNES_FREE_FORM_DATA_ATOM_TYPE_TOOL)))
+                            {
+                                if (_pITunesNormalizationFreeFormDataToolAtom == NULL)
+                                {
+                                    PV_MP4_FF_NEW(fp->auditCB,
+                                                  ITunesFreeFormDataAtom,
+                                                  (fp, FreeFormAtomSize, FreeFormAtomType),
+                                                  _pITunesNormalizationFreeFormDataToolAtom);
+                                    if (!_pITunesNormalizationFreeFormDataToolAtom->MP4Success())
+                                    {
+                                        AtomUtils::seekFromStart(fp, currPos);
+                                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                                    }
+                                    count -= _pITunesNormalizationFreeFormDataToolAtom->getSize();
+                                    atomsize -= _pITunesNormalizationFreeFormDataToolAtom->getSize();
+                                }
+                                else //Duplicate atom
+                                {
+                                    AtomUtils::seekFromStart(fp, currPos);
+                                    AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                                    count -= FreeFormAtomSize;
+                                    atomsize -= FreeFormAtomSize;
+                                }
+                            }
+                            else if (!(oscl_strcmp(buf, ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB1)))
+                            {
+                                if (_pITunesCDDB1FreeFormDataAtom == NULL)
+                                {
+                                    PV_MP4_FF_NEW(fp->auditCB,
+                                                  ITunesFreeFormDataAtom,
+                                                  (fp, FreeFormAtomSize, FreeFormAtomType),
+                                                  _pITunesCDDB1FreeFormDataAtom);
+                                    if (!_pITunesCDDB1FreeFormDataAtom->MP4Success())
+                                    {
+                                        AtomUtils::seekFromStart(fp, currPos);
+                                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                                    }
+                                    count -= _pITunesCDDB1FreeFormDataAtom->getSize();
+                                    atomsize -= _pITunesCDDB1FreeFormDataAtom->getSize();
+                                }
+                                else //Duplicate atom
+                                {
+                                    AtomUtils::seekFromStart(fp, currPos);
+                                    AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                                    count -= FreeFormAtomSize;
+                                    atomsize -= FreeFormAtomSize;
+
+                                }
+                            }
+                            else if (!(oscl_strcmp(buf, ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB_TRACKNUMBER)))
+                            {
+                                if (_pITunesCDTrackNumberFreeFormDataAtom == NULL)
+                                {
+                                    PV_MP4_FF_NEW(fp->auditCB,
+                                                  ITunesFreeFormDataAtom,
+                                                  (fp, FreeFormAtomSize, FreeFormAtomType),
+                                                  _pITunesCDTrackNumberFreeFormDataAtom);
+                                    if (!_pITunesCDTrackNumberFreeFormDataAtom->MP4Success())
+                                    {
+                                        AtomUtils::seekFromStart(fp, currPos);
+                                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                                    }
+                                    count -= _pITunesCDTrackNumberFreeFormDataAtom->getSize();
+                                    atomsize -=  _pITunesCDTrackNumberFreeFormDataAtom->getSize();
+                                }
+                                else //Duplicate atom
+                                {
+                                    AtomUtils::seekFromStart(fp, currPos);
+                                    AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                                    count -= FreeFormAtomSize;
+                                    atomsize -= FreeFormAtomSize;
+
+                                }
+                            }
+                            else if (!(oscl_strcmp(buf, ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB_IDS)))
+                            {
+
+                                PV_MP4_FF_NEW(fp->auditCB,
+                                              ITunesFreeFormDataAtom,
+                                              (fp, FreeFormAtomSize, FreeFormAtomType),
+                                              _pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]);
+
+                                if (!_pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]->MP4Success())
+                                {
+                                    AtomUtils::seekFromStart(fp, currPos);
+                                    AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                                }
+                                count -= _pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]->getSize();
+                                atomsize -= _pITunesCDIdentifierFreeFormDataAtom[_iITunesCDIdentifierFreeFormDataAtomNum]->getSize();
+                                _iITunesCDIdentifierFreeFormDataAtomNum++;
+
+                            }
+                            else /*Ignore the DataAtom */
+                            {
+                                atomsize -= FreeFormAtomSize;
+                                count -= FreeFormAtomSize;
+                                AtomUtils::seekFromStart(fp, currPos);
+                                AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                            }
                         }
                         else
                         {
-                            // skip rest of the atom
-                            fp->_pvfile.Seek(count, Oscl_File::SEEKCUR);
-                            count = 0;
+                            /*Skip the DataAtom when there is memory error*/
+                            atomsize -= FreeFormAtomSize;
+                            count -= FreeFormAtomSize;
+                            AtomUtils::seekFromStart(fp, currPos);
+                            AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                        }
+                        /*Delete the buffer */
+                        if (buf)
+                        {
+                            PV_MP4_ARRAY_FREE(fp->auditCB, buf);
+                            buf = NULL;
                         }
 
                     }
+                    else
+                    {
+                        /*Skip the DataAtom when there is no NameAtom*/
+                        atomsize -= FreeFormAtomSize;
+                        count -= FreeFormAtomSize;
+                        AtomUtils::seekFromStart(fp, currPos);
+                        AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+
+                    }
                 }
-            }
+                else /*Ignore the unrecognized atom */
+                {
+                    atomsize -= FreeFormAtomSize;
+                    count -= FreeFormAtomSize;
+                    AtomUtils::seekFromStart(fp, currPos);
+                    AtomUtils::seekFromCurrPos(fp, FreeFormAtomSize);
+                }
+
+            } //End of While
+
         }
-#endif
         else if (atomType == ITUNES_ALBUM_ATOM)
         {
             PV_MP4_FF_NEW(fp->auditCB, ITunesAlbumAtom, (fp, atomsize, atomType), _pITunesAlbumAtom);
@@ -1338,20 +2195,45 @@
             else
                 count -= _pITunesAlbumAtom->getSize();
         }
-        else if (atomType == ITUNES_ARTIST_ATOM || atomType == ITUNES_ALBUM_ARTIST_ATOM)
+        else if ((atomType == ITUNES_ARTIST1_ATOM) || (atomType == ITUNES_ARTIST2_ATOM))
         {
-            PV_MP4_FF_NEW(fp->auditCB, ITunesArtistAtom, (fp, atomsize, atomType), _pITunesArtistAtom);
+            if (_pITunesArtistAtom == NULL)
+            {
+                PV_MP4_FF_NEW(fp->auditCB, ITunesArtistAtom, (fp, atomsize, atomType), _pITunesArtistAtom);
 
-            if (!_pITunesArtistAtom->MP4Success())
+                if (!_pITunesArtistAtom->MP4Success())
+                {
+                    AtomUtils::seekFromStart(fp, currPtr);
+                    AtomUtils::seekFromCurrPos(fp, atomsize);
+                    PV_MP4_FF_DELETE(NULL, ITunesArtistAtom, _pITunesArtistAtom);
+                    _pITunesArtistAtom = NULL;
+                    count -= atomsize;
+                }
+                else
+                    count -= _pITunesArtistAtom->getSize();
+            }
+            else //Skip it
+            {
+                count -= atomsize;
+                atomsize -= DEFAULT_ATOM_SIZE;
+                AtomUtils::seekFromCurrPos(fp, atomsize);
+
+            }
+        }
+        else if (atomType == ITUNES_ALBUM_ARTIST_ATOM)
+        {
+            PV_MP4_FF_NEW(fp->auditCB, ITunesAlbumArtistAtom, (fp, atomsize, atomType), _pITunesAlbumArtistAtom);
+
+            if (!_pITunesAlbumArtistAtom->MP4Success())
             {
                 AtomUtils::seekFromStart(fp, currPtr);
                 AtomUtils::seekFromCurrPos(fp, atomsize);
-                PV_MP4_FF_DELETE(NULL, ITunesArtistAtom, _pITunesArtistAtom);
-                _pITunesArtistAtom = NULL;
+                PV_MP4_FF_DELETE(NULL, ITunesAlbumArtistAtom, _pITunesAlbumArtistAtom);
+                _pITunesAlbumArtistAtom = NULL;
                 count -= atomsize;
             }
             else
-                count -= _pITunesArtistAtom->getSize();
+                count -= _pITunesAlbumArtistAtom->getSize();
         }
         else if (atomType == ITUNES_GENRE1_ATOM || atomType == ITUNES_GENRE2_ATOM)
         {
@@ -1373,7 +2255,7 @@
             {
                 count -= atomsize;
                 atomsize -= DEFAULT_ATOM_SIZE;
-                fp->_pvfile.Seek(atomsize, Oscl_File::SEEKCUR);
+                AtomUtils::seekFromCurrPos(fp, atomsize);
             }
         }
         else if (atomType == ITUNES_YEAR_ATOM)
@@ -1406,20 +2288,29 @@
             else
                 count -= _pITunesWriterAtom->getSize();
         }
-        else if (atomType == ITUNES_GROUPING_ATOM)
+        else if ((atomType == ITUNES_GROUPING1_ATOM) || (atomType == ITUNES_GROUPING2_ATOM))
         {
-            PV_MP4_FF_NEW(fp->auditCB, ITunesGroupAtom, (fp, atomsize, atomType), _pITunesGroupAtom);
-
-            if (!_pITunesGroupAtom->MP4Success())
+            if (_pITunesGroupAtom == NULL)
             {
-                AtomUtils::seekFromStart(fp, currPtr);
-                AtomUtils::seekFromCurrPos(fp, atomsize);
-                PV_MP4_FF_DELETE(NULL, ITunesGroupAtom, _pITunesGroupAtom);
-                _pITunesGroupAtom = NULL;
-                count -= atomsize;
+                PV_MP4_FF_NEW(fp->auditCB, ITunesGroupAtom, (fp, atomsize, atomType), _pITunesGroupAtom);
+
+                if (!_pITunesGroupAtom->MP4Success())
+                {
+                    AtomUtils::seekFromStart(fp, currPtr);
+                    AtomUtils::seekFromCurrPos(fp, atomsize);
+                    PV_MP4_FF_DELETE(NULL, ITunesGroupAtom, _pITunesGroupAtom);
+                    _pITunesGroupAtom = NULL;
+                    count -= atomsize;
+                }
+                else
+                    count -= _pITunesGroupAtom->getSize();
             }
             else
-                count -= _pITunesGroupAtom->getSize();
+            {
+                count -= atomsize;
+                atomsize -= DEFAULT_ATOM_SIZE;
+                AtomUtils::seekFromCurrPos(fp, atomsize);
+            }
         }
         else if (atomType == ITUNES_COMMENT_ATOM)
         {
@@ -1502,12 +2393,12 @@
             {
                 count -= atomsize;
                 atomsize -= DEFAULT_ATOM_SIZE;
-                fp->_pvfile.Seek(atomsize, Oscl_File::SEEKCUR);
+                AtomUtils::seekFromCurrPos(fp, atomsize);
             }
             else
             {
                 // skip rest of the atom
-                fp->_pvfile.Seek(count, Oscl_File::SEEKCUR);
+                AtomUtils::seekFromCurrPos(fp, atomsize);
                 count = 0;
             }
         }
@@ -1516,14 +2407,46 @@
 
 ITunesILSTAtom::~ITunesILSTAtom()
 {
+
+    if (_pMeaningAtomVec != NULL)
+    {
+        for (uint32 i = 0; i < _pMeaningAtomVec->size(); i++)
+        {
+            ItunesMeaningAtom *ptr = (ItunesMeaningAtom *)(*_pMeaningAtomVec)[i];
+            PV_MP4_FF_DELETE(NULL, ItunesMeaningAtom, ptr);
+
+        }
+    }
+    if (_pNameAtomVec != NULL)
+    {
+        for (uint32 i = 0; i < _pNameAtomVec->size(); i++)
+        {
+            ItunesNameAtom *ptr = (ItunesNameAtom *)(*_pNameAtomVec)[i];
+            PV_MP4_FF_DELETE(NULL, ItunesNameAtom, ptr);
+
+        }
+    }
+    //Delete the  vectors
+    PV_MP4_FF_TEMPLATED_DELETE(NULL, ItunesNameAtomVecType, Oscl_Vector, _pNameAtomVec);
+    PV_MP4_FF_TEMPLATED_DELETE(NULL, ItunesMeaningAtomVecType, Oscl_Vector, _pMeaningAtomVec);
+
     if (_pITunesTitleAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, ITunesTitleAtom, _pITunesTitleAtom);
     }
+    if (_pITunesTrackSubTitleAtom != NULL)
+    {
+        PV_MP4_FF_DELETE(NULL, ITunesTrackSubTitleAtom, _pITunesTrackSubTitleAtom);
+    }
+
     if (_pITunesCompileAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, ITunesCompileAtom, _pITunesCompileAtom);
     }
+    if (_pITunesContentRatingAtom != NULL)
+    {
+        PV_MP4_FF_DELETE(NULL, ITunesContentRatingAtom, _pITunesContentRatingAtom);
+    }
     if (_pITunesTempoAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, ITunesTempoAtom, _pITunesTempoAtom);
@@ -1540,6 +2463,10 @@
     {
         PV_MP4_FF_DELETE(NULL, ITunesToolAtom, _pITunesToolAtom);
     }
+    if (_pITunesEncodedByAtom != NULL)
+    {
+        PV_MP4_FF_DELETE(NULL, ITunesEncodedByAtom, _pITunesEncodedByAtom);
+    }
     if (_pITunesNormalizationFreeFormDataAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, ITunesFreeFormDataAtom, _pITunesNormalizationFreeFormDataAtom);
@@ -1555,6 +2482,15 @@
             PV_MP4_FF_DELETE(NULL, ITunesFreeFormDataAtom, _pITunesCDIdentifierFreeFormDataAtom[ii]);
         }
     }
+
+    if (_pITunesCDDB1FreeFormDataAtom != NULL)
+    {
+        PV_MP4_FF_DELETE(NULL, ITunesFreeFormDataAtom, _pITunesCDDB1FreeFormDataAtom);
+    }
+    if (_pITunesCDTrackNumberFreeFormDataAtom != NULL)
+    {
+        PV_MP4_FF_DELETE(NULL, ITunesFreeFormDataAtom, _pITunesCDTrackNumberFreeFormDataAtom);
+    }
     if (_pITunesAlbumAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, ITunesAlbumAtom, _pITunesAlbumAtom);
@@ -1563,6 +2499,10 @@
     {
         PV_MP4_FF_DELETE(NULL, ITunesArtistAtom, _pITunesArtistAtom);
     }
+    if (_pITunesAlbumArtistAtom != NULL)
+    {
+        PV_MP4_FF_DELETE(NULL, ITunesAlbumArtistAtom, _pITunesAlbumArtistAtom);
+    }
     if (_pITunesGenreAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, ITunesGenreAtom, _pITunesGenreAtom);
diff --git a/fileformats/mp4/parser/src/mediaatom.cpp b/fileformats/mp4/parser/src/mediaatom.cpp
index 42e24df..8b064fa 100644
--- a/fileformats/mp4/parser/src/mediaatom.cpp
+++ b/fileformats/mp4/parser/src/mediaatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mediabuffer.cpp b/fileformats/mp4/parser/src/mediabuffer.cpp
index e5a6075..7be86f9 100644
--- a/fileformats/mp4/parser/src/mediabuffer.cpp
+++ b/fileformats/mp4/parser/src/mediabuffer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mediabuffermanager.cpp b/fileformats/mp4/parser/src/mediabuffermanager.cpp
index e52d556..3b7fc8d 100644
--- a/fileformats/mp4/parser/src/mediabuffermanager.cpp
+++ b/fileformats/mp4/parser/src/mediabuffermanager.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mediadataatom.cpp b/fileformats/mp4/parser/src/mediadataatom.cpp
index e956fa2..daca645 100644
--- a/fileformats/mp4/parser/src/mediadataatom.cpp
+++ b/fileformats/mp4/parser/src/mediadataatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,5 +70,6 @@
 // Destructor
 MediaDataAtom::~MediaDataAtom()
 {
+
 }
 
diff --git a/fileformats/mp4/parser/src/mediaheaderatom.cpp b/fileformats/mp4/parser/src/mediaheaderatom.cpp
index 1593177..1f0fa41 100644
--- a/fileformats/mp4/parser/src/mediaheaderatom.cpp
+++ b/fileformats/mp4/parser/src/mediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mediainformationatom.cpp b/fileformats/mp4/parser/src/mediainformationatom.cpp
index 3d64199..7f17256 100644
--- a/fileformats/mp4/parser/src/mediainformationatom.cpp
+++ b/fileformats/mp4/parser/src/mediainformationatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mediainformationheaderatom.cpp b/fileformats/mp4/parser/src/mediainformationheaderatom.cpp
index 8d72708..ef5dbfb 100644
--- a/fileformats/mp4/parser/src/mediainformationheaderatom.cpp
+++ b/fileformats/mp4/parser/src/mediainformationheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,5 +48,6 @@
 // Destructor
 MediaInformationHeaderAtom::~MediaInformationHeaderAtom()
 {
+
 }
 
diff --git a/fileformats/mp4/parser/src/metadataatom.cpp b/fileformats/mp4/parser/src/metadataatom.cpp
index 8bd457c..4549aff 100644
--- a/fileformats/mp4/parser/src/metadataatom.cpp
+++ b/fileformats/mp4/parser/src/metadataatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*
-	This MetaDataAtom Class is used for Parsing, and Storing the tags from Meta data
-	of ITune M4A file.
-*/
-
 #include "metadataatom.h"
 #include "atomdefs.h"
 
diff --git a/fileformats/mp4/parser/src/mfraoffsetatom.cpp b/fileformats/mp4/parser/src/mfraoffsetatom.cpp
index 12383ca..7d2fd74 100644
--- a/fileformats/mp4/parser/src/mfraoffsetatom.cpp
+++ b/fileformats/mp4/parser/src/mfraoffsetatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_MovieFragmentRandomAccessOffsetAtom
 
 #include "mfraoffsetatom.h"
diff --git a/fileformats/mp4/parser/src/movieatom.cpp b/fileformats/mp4/parser/src/movieatom.cpp
index b803963..8c4e9f8 100644
--- a/fileformats/mp4/parser/src/movieatom.cpp
+++ b/fileformats/mp4/parser/src/movieatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,7 @@
     _oVideoTrackPresent = false;
 
 
+
     if (_success)
     {
         _scalability = -1;
@@ -111,7 +112,6 @@
                 else
                 {
                     //at most one udat atom allowed
-                    //Skip mulitple Imotion UDATs
                     if (atomSize < DEFAULT_ATOM_SIZE)
                     {
                         _success = false;
@@ -222,12 +222,11 @@
             }
             else if (atomType == TRACK_ATOM)
             {
+                TrackAtom *track = NULL;
                 // trak
                 if (oPVContent)
                 {
                     // Read in and add all the track atoms
-                    TrackAtom *track = NULL;
-
                     PV_MP4_FF_NEW(fp->auditCB,
                                   TrackAtom,
                                   (fp, filename, atomSize,
@@ -257,8 +256,6 @@
                 else
                 {
                     // Read in and add all the track atoms
-                    TrackAtom *track = NULL;
-
                     uint32 currPos = AtomUtils::getCurrentFilePosition(fp);
                     PV_MP4_FF_NEW(fp->auditCB,
                                   TrackAtom,
@@ -287,6 +284,14 @@
                         }
                     }
                 }
+
+                /* max limit- 1024 tracks*/
+                if ((_ptrackArray->size()) > MAX_LIMIT_FOR_NUMBER_OF_TRACKS)
+                {
+                    _success = false;
+                    _mp4ErrorCode = EXCEED_MAX_LIMIT_SUPPORTED_FOR_TOTAL_TRACKS;
+                    return ;
+                }
             }
         }
 
@@ -617,18 +622,13 @@
     }
 }
 
-OSCL_wHeapString<OsclMemAllocator> MovieAtom::getTrackMIMEType(uint32 id)
+void MovieAtom::getTrackMIMEType(uint32 id, OSCL_String& aMimeType)
 {
     TrackAtom *trackAtom = getTrackforID(id);
 
     if (trackAtom != NULL)
     {
-        return trackAtom->getMIMEType();
-    }
-    else
-    {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("UNKNOWN"));
-        return temp;
+        trackAtom->getMIMEType(aMimeType);
     }
 }
 
@@ -914,6 +914,7 @@
                         {
                             modifiedTimeStamp = timestamp;
                         }
+
                     }
 
                     bool oDependsOn = true;
@@ -941,6 +942,7 @@
                     {
                         modifiedTimeStamp = timestamp;
                     }
+
                 }
             }
         }
@@ -993,6 +995,7 @@
         }
     }
 
+
     return modifiedTimeStamp;
 
 }
@@ -1044,6 +1047,7 @@
             }
         }
         return minTS;
+
     }
     for (i = 0; i < numTracks; i++)
     {
@@ -2197,3 +2201,4 @@
     }
 
 }
+
diff --git a/fileformats/mp4/parser/src/movieextendsatom.cpp b/fileformats/mp4/parser/src/movieextendsatom.cpp
index eaa5c2a..2c47ec7 100644
--- a/fileformats/mp4/parser/src/movieextendsatom.cpp
+++ b/fileformats/mp4/parser/src/movieextendsatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/movieextendsheaderatom.cpp b/fileformats/mp4/parser/src/movieextendsheaderatom.cpp
index 4cdf5b8..55850d9 100644
--- a/fileformats/mp4/parser/src/movieextendsheaderatom.cpp
+++ b/fileformats/mp4/parser/src/movieextendsheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_MovieExtendsHeaderAtom
 
 #include "movieextendsheaderatom.h"
diff --git a/fileformats/mp4/parser/src/moviefragmentatom.cpp b/fileformats/mp4/parser/src/moviefragmentatom.cpp
index 39a9f59..01b0d37 100644
--- a/fileformats/mp4/parser/src/moviefragmentatom.cpp
+++ b/fileformats/mp4/parser/src/moviefragmentatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -182,6 +182,7 @@
                                       bool &moofParsingCompleted,
                                       uint32 &countOfTrunsParsed)
 {
+    OSCL_UNUSED_ARG(type);
     uint32 count = size;
 
     if (_success)
@@ -207,7 +208,6 @@
                     }
                     count -= _pTrackFragmentAtom->getSize();
                     size = count;
-                    //	_ptrackFragmentArray->push_back(_pTrackFragmentAtom);
                     _pMovieFragmentCurrentOffset += _pTrackFragmentAtom->_trackFragmentEndOffset;
                 }
                 else
diff --git a/fileformats/mp4/parser/src/moviefragmentheaderatom.cpp b/fileformats/mp4/parser/src/moviefragmentheaderatom.cpp
index 704c66b..0daf03c 100644
--- a/fileformats/mp4/parser/src/moviefragmentheaderatom.cpp
+++ b/fileformats/mp4/parser/src/moviefragmentheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_MovieFragmentHeaderAtom
 
 #include "moviefragmentheaderatom.h"
diff --git a/fileformats/mp4/parser/src/moviefragmentrandomaccess.cpp b/fileformats/mp4/parser/src/moviefragmentrandomaccess.cpp
index c08cd05..7ebdfd6 100644
--- a/fileformats/mp4/parser/src/moviefragmentrandomaccess.cpp
+++ b/fileformats/mp4/parser/src/moviefragmentrandomaccess.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -121,6 +121,7 @@
 
 bool MovieFragmentRandomAccessAtom::IsTFRAPresentForTrack(uint32 trackID, bool oVideoAudioTextTrack)
 {
+
     uint32 num_tfra = 0;
     if (_pTrackFragmentRandomAccessAtomVec != NULL)
     {
@@ -141,6 +142,8 @@
                         return true;
                     }
                     else if (oVideoAudioTextTrackTfraCount == tfraAtom->_entry_count)
+#else
+                    OSCL_UNUSED_ARG(oVideoAudioTextTrack);
 #endif // DISABLE_REPOS_ON_CLIPS_HAVING_UNEQUAL_TFRA_ENTRY_COUNT
                     {
                         return true;
@@ -171,6 +174,9 @@
         if (tfraAtom->getTrackID() == trackID)
         {
             uint32 entries = tfraAtom->_entry_count;
+            if (entries == 0)
+                return -1;
+
             Oscl_Vector<TFRAEntries*, OsclMemAllocator>* tfraEntries = tfraAtom->getTrackFragmentRandomAccessEntries();
             if (!tfraEntries)       // unlikely/error
                 return -1;
@@ -308,7 +314,7 @@
         Oscl_Vector<TFRAEntries*, OsclMemAllocator>* tfraEntries = tfraAtom->getTrackFragmentRandomAccessEntries();
         if (!tfraEntries)       // unlikely/error
             return 0;
-        int32 prevTime = 0;
+
 
         uint32 tmp = entries;
 
diff --git a/fileformats/mp4/parser/src/movieheaderatom.cpp b/fileformats/mp4/parser/src/movieheaderatom.cpp
index 506c975..e5e60d1 100644
--- a/fileformats/mp4/parser/src/movieheaderatom.cpp
+++ b/fileformats/mp4/parser/src/movieheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mpeg4file.cpp b/fileformats/mp4/parser/src/mpeg4file.cpp
index 1649273..28cc19c 100644
--- a/fileformats/mp4/parser/src/mpeg4file.cpp
+++ b/fileformats/mp4/parser/src/mpeg4file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -95,6 +95,7 @@
     PV_MP4_FF_NEW(fp->auditCB, movieFragmentRandomAccessAtomVecType, (), _pMovieFragmentRandomAccessAtomVec);
     PV_MP4_FF_NEW(fp->auditCB, PVID3ParCom, (), _pID3Parser);
 
+
     iLogger = PVLogger::GetLoggerObject("mp4ffparser");
     iStateVarLogger = PVLogger::GetLoggerObject("mp4ffparser_mediasamplestats");
     iParsedDataLogger = PVLogger::GetLoggerObject("mp4ffparser_parseddata");
@@ -111,15 +112,7 @@
     _oPVContent = false;
     _oPVContentDownloadable = false;
     _commonFilePtr = NULL;
-
-    OsclAny*ptr = oscl_malloc(sizeof(MP4_FF_FILE));
-    if (ptr == NULL)
-    {
-        _success = false;
-        _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
-        return;
-    }
-    _commonFilePtr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE(*fp));
+    _fileSize = fsize;
 
     int32 count = fileSize - filePointer;// -DEFAULT_ATOM_SIZE;
 
@@ -216,6 +209,8 @@
                 atomSize -= DEFAULT_ATOM_SIZE;
                 AtomUtils::seekFromCurrPos(fp, atomSize);
             }
+
+
         }
         else if (atomType == FILE_TYPE_ATOM)
         {
@@ -327,9 +322,10 @@
             }
             else
             {
-                //multiple "ftyp" atom not allowed.
-                _mp4ErrorCode = DUPLICATE_FILE_TYPE_ATOMS;
-                break;
+                //multiple "ftyp" atom not allowed.skipping
+                count -= atomSize;
+                atomSize -= DEFAULT_ATOM_SIZE;
+                AtomUtils::seekFromCurrPos(fp, atomSize);
             }
         }
         else if (atomType == MOVIE_ATOM)
@@ -360,6 +356,7 @@
                 _isMovieFragmentsPresent = _pmovieAtom->IsMovieFragmentPresent();
                 populateTrackDurationVec();
                 _pTrackExtendsAtomVec = _pmovieAtom->getTrackExtendsAtomVec();
+
                 if (_isMovieFragmentsPresent)
                 {
                     atomSize -= DEFAULT_ATOM_SIZE;
@@ -394,6 +391,8 @@
                     //we are done parsing the moov atom
                     break;
                 }
+
+
             }
             else
             { //after the change above, we will never hit here.
@@ -459,11 +458,6 @@
         }
         else
         {
-            //Populate the title vector with all the title metadata values.
-            if (!populateMetadataVectors())
-            {
-                PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "Mpeg4File::populateTitleVector() Failed"));
-            }
             // CHECK IF THERE ARE ANY VALID MEDIA TRACKS IN THE FILE
             int32 numMediaTracks = getNumTracks();
             if (numMediaTracks == 0)
@@ -544,6 +538,7 @@
         }
     }
 
+
     // Check for any atoms that may have read past the EOF that were not
     // already caught by any earlier error handling
 
@@ -559,6 +554,12 @@
     {
         parseID3Header(fp);
     }
+    //Populate the title vector with all the title metadata values.
+    if (!populateMetadataVectors())
+    {
+        PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "Mpeg4File::populateTitleVector() Failed"));
+    }
+
 }
 
 
@@ -591,6 +592,20 @@
     {
         numTitle++;
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "title") != 0)
+            {
+                numTitle++;
+                break;
+            }
+        }
+    }
     return numTitle;
 }
 
@@ -599,8 +614,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numTitle = getNumTitle();
-    OSCL_TRY(leavecode, titleValues.reserve(numTitle));
-    OSCL_TRY(leavecode1, iTitleLangCode.reserve(numTitle));
+    ReserveMemoryForValuesVector(titleValues, numTitle, leavecode);
+    ReserveMemoryForLangCodeVector(iTitleLangCode, numTitle, leavecode1);
     OSCL_TRY(leavecode2, iTitleCharType.reserve(numTitle));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -635,6 +650,25 @@
         iTitleLangCode.push_front(0);
         iTitleCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "title") != 0)
+            {
+                uint32 len = oscl_strlen(framevector[i]->value.pChar_value);
+                oscl_memset(_id3v1Title, 0, ID3V1_STR_MAX_SIZE);
+                oscl_UTF8ToUnicode(framevector[i]->value.pChar_value, len, _id3v1Title, len*2 + 2);
+                titleValues.push_front(_id3v1Title);
+                iTitleLangCode.push_front(0);
+                iTitleCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
+                break;
+            }
+        }
+    }
     return PVMFSuccess;
 }
 
@@ -672,8 +706,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numAuthor = getNumAuthor();
-    OSCL_TRY(leavecode, authorValues.reserve(numAuthor));
-    OSCL_TRY(leavecode1, iAuthorLangCode.reserve(numAuthor));
+    ReserveMemoryForValuesVector(authorValues, numAuthor, leavecode);
+    ReserveMemoryForLangCodeVector(iAuthorLangCode, numAuthor, leavecode1);
     OSCL_TRY(leavecode2, iAuthorCharType.reserve(numAuthor));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -720,12 +754,25 @@
 uint32 Mpeg4File::getNumAlbum()
 {
     uint32 numAlbum = 0;
-    MP4FFParserOriginalCharEnc chartype = ORIGINAL_CHAR_TYPE_UNKNOWN;
     numAlbum = getNumAssetInfoAlbumAtoms();
     if (getITunesAlbum().get_size() > 0)
     {
         numAlbum++;
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "album") != 0)
+            {
+                numAlbum++;
+                break;
+            }
+        }
+    }
     return numAlbum;
 }
 
@@ -734,8 +781,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numAlbum = getNumAlbum();
-    OSCL_TRY(leavecode, albumValues.reserve(numAlbum));
-    OSCL_TRY(leavecode1, iAlbumLangCode.reserve(numAlbum));
+    ReserveMemoryForValuesVector(albumValues, numAlbum, leavecode);
+    ReserveMemoryForLangCodeVector(iAlbumLangCode, numAlbum, leavecode1);
     OSCL_TRY(leavecode2, iAlbumCharType.reserve(numAlbum));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -760,6 +807,26 @@
         iAlbumLangCode.push_front(0);
         iAlbumCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "album") != 0)
+            {
+                uint32 len = oscl_strlen(framevector[i]->value.pChar_value);
+                oscl_memset(_id3v1Album, 0, ID3V1_STR_MAX_SIZE);
+                oscl_UTF8ToUnicode(framevector[i]->value.pChar_value, len, _id3v1Album, len*2 + 2);
+                albumValues.push_front(_id3v1Album);
+                iAlbumLangCode.push_front(0);
+                iAlbumCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
+                break;
+            }
+        }
+    }
+
     return PVMFSuccess;
 }
 
@@ -782,12 +849,31 @@
 uint32 Mpeg4File::getNumArtist()
 {
     uint32 numArtist = 0;
-    MP4FFParserOriginalCharEnc chartype = ORIGINAL_CHAR_TYPE_UNKNOWN;
     numArtist = getNumAssetInfoPerformerAtoms();
+
     if (getITunesArtist().get_size() > 0)
     {
         numArtist++;
     }
+    if (getITunesAlbumArtist().get_size() > 0) //AlbumArtist
+    {
+        numArtist++;
+    }
+
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "artist") != 0)
+            {
+                numArtist++;
+                break;
+            }
+        }
+    }
     return numArtist;
 }
 
@@ -797,8 +883,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numArtist = getNumArtist();
-    OSCL_TRY(leavecode, artistValues.reserve(numArtist));
-    OSCL_TRY(leavecode1, iArtistLangCode.reserve(numArtist));
+    ReserveMemoryForValuesVector(artistValues, numArtist, leavecode);
+    ReserveMemoryForLangCodeVector(iArtistLangCode, numArtist, leavecode1);
     OSCL_TRY(leavecode2, iArtistCharType.reserve(numArtist));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -823,6 +909,32 @@
         iArtistLangCode.push_front(0);
         iArtistCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
     }
+    if (getITunesAlbumArtist().get_size() > 0) //AlbumArtist
+    {
+        OSCL_wHeapString<OsclMemAllocator> valuestring = getITunesAlbumArtist();
+        artistValues.push_front(valuestring);
+        iArtistLangCode.push_front(0);
+        iArtistCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
+    }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "artist") != 0)
+            {
+                uint32 len = oscl_strlen(framevector[i]->value.pChar_value);
+                oscl_memset(_id3v1Artist, 0, ID3V1_STR_MAX_SIZE);
+                oscl_UTF8ToUnicode(framevector[i]->value.pChar_value, len, _id3v1Artist, len*2 + 2);
+                artistValues.push_front(_id3v1Artist);
+                iArtistLangCode.push_front(0);
+                iArtistCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
+                break;
+            }
+        }
+    }
     return PVMFSuccess;
 }
 
@@ -845,8 +957,8 @@
 uint32 Mpeg4File::getNumGenre()
 {
     uint32 numGenre = 0;
-    MP4FFParserOriginalCharEnc chartype = ORIGINAL_CHAR_TYPE_UNKNOWN;
     numGenre = getNumAssetInfoGenreAtoms();
+
     if (getITunesGnreString().get_size() > 0)
     {
         numGenre++;
@@ -863,8 +975,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numGenre = getNumGenre();
-    OSCL_TRY(leavecode, genreValues.reserve(numGenre));
-    OSCL_TRY(leavecode1, iGenreLangCode.reserve(numGenre));
+    ReserveMemoryForValuesVector(genreValues, numGenre, leavecode);
+    ReserveMemoryForLangCodeVector(iGenreLangCode, numGenre, leavecode1);
     OSCL_TRY(leavecode2, iGenreCharType.reserve(numGenre));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -931,8 +1043,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numCopyright = getNumCopyright();
-    OSCL_TRY(leavecode, copyrightValues.reserve(numCopyright));
-    OSCL_TRY(leavecode1, iCopyrightLangCode.reserve(numCopyright));
+    ReserveMemoryForValuesVector(copyrightValues, numCopyright, leavecode);
+    ReserveMemoryForLangCodeVector(iCopyrightLangCode, numCopyright, leavecode1);
     OSCL_TRY(leavecode2, iCopyrightCharType.reserve(numCopyright));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -987,13 +1099,27 @@
 uint32 Mpeg4File::getNumComment()
 {
     uint32 numComment = 0;
-    MP4FFParserOriginalCharEnc chartype = ORIGINAL_CHAR_TYPE_UNKNOWN;
 
 
     if (getITunesComment().get_size() > 0)
     {
         numComment++;
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "comment") != 0)
+            {
+                numComment++;
+                break;
+            }
+        }
+    }
+
     return numComment;
 }
 
@@ -1003,10 +1129,9 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numComment = getNumComment();
-    OSCL_TRY(leavecode, commentValues.reserve(numComment));
-    OSCL_TRY(leavecode1, iCommentLangCode.reserve(numComment));
+    ReserveMemoryForValuesVector(commentValues, numComment, leavecode);
+    ReserveMemoryForLangCodeVector(iCommentLangCode, numComment, leavecode1);
     OSCL_TRY(leavecode2, iCommentCharType.reserve(numComment));
-    MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
     {
         return PVMFFailure;
@@ -1019,6 +1144,26 @@
         iCommentLangCode.push_front(0);
         iCommentCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "comment") != 0)
+            {
+                uint32 len = oscl_strlen(framevector[i]->value.pChar_value);
+                oscl_memset(_id3v1Comment, 0, ID3V1_STR_MAX_SIZE);
+                oscl_UTF8ToUnicode(framevector[i]->value.pChar_value, len, _id3v1Comment, len*2 + 2);
+                commentValues.push_front(_id3v1Comment);
+                iCommentLangCode.push_front(0);
+                iCommentCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
+                break;
+            }
+        }
+    }
+
     return PVMFSuccess;
 }
 
@@ -1052,6 +1197,7 @@
     {
         numDescription++;
     }
+
     return numDescription;
 }
 
@@ -1061,8 +1207,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numDescription = getNumDescription();
-    OSCL_TRY(leavecode, descriptionValues.reserve(numDescription));
-    OSCL_TRY(leavecode1, iDescriptionLangCode.reserve(numDescription));
+    ReserveMemoryForValuesVector(descriptionValues, numDescription, leavecode);
+    ReserveMemoryForLangCodeVector(iDescriptionLangCode, numDescription, leavecode1);
     OSCL_TRY(leavecode2, iDescriptionCharType.reserve(numDescription));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -1087,6 +1233,7 @@
         iDescriptionLangCode.push_front(0);
         iDescriptionCharType.push_front(charType);
     }
+
     if (getITunesDescription().get_size() > 0)
     {
         OSCL_wHeapString<OsclMemAllocator> valuestring = getITunesDescription();
@@ -1094,6 +1241,7 @@
         iDescriptionLangCode.push_front(0);
         iDescriptionCharType.push_front(ORIGINAL_CHAR_TYPE_UNKNOWN);
     }
+
     return PVMFSuccess;
 }
 
@@ -1134,8 +1282,8 @@
 {
     int32 leavecode = 0, leavecode1 = 0, leavecode2 = 0;
     int32 numRating = getNumRating();
-    OSCL_TRY(leavecode, ratingValues.reserve(numRating));
-    OSCL_TRY(leavecode1, iRatingLangCode.reserve(numRating));
+    ReserveMemoryForValuesVector(ratingValues, numRating, leavecode);
+    ReserveMemoryForLangCodeVector(iRatingLangCode, numRating, leavecode1);
     OSCL_TRY(leavecode2, iRatingCharType.reserve(numRating));
     MP4FFParserOriginalCharEnc charType = ORIGINAL_CHAR_TYPE_UNKNOWN;
     if (leavecode != 0 || leavecode1 != 0 || leavecode2 != 0)
@@ -1190,6 +1338,21 @@
     {
         numYear++;
     }
+
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "year") != 0)
+            {
+                numYear++;
+                break;
+            }
+        }
+    }
     return numYear;
 }
 
@@ -1223,6 +1386,22 @@
         i = PV_atoi(valuestring, 'd', value);
         yearValues.push_front(value);
     }
+    PvmiKvpSharedPtrVector framevector;
+    GetID3MetaData(framevector);
+    uint32 num_frames = framevector.size();
+    for (uint32 i = 0; i < num_frames; i++)
+    {
+        if (framevector.size() > 0)
+        {
+            if (oscl_strstr(framevector[i]->key, "year") != 0)
+            {
+                PV_atoi(framevector[i]->value.pChar_value, 'd', _id3v1Year);
+                yearValues.push_front(_id3v1Year);
+                break;
+            }
+        }
+    }
+
     return PVMFSuccess;
 }
 
@@ -1231,7 +1410,7 @@
 {
     if (index < yearValues.size())
     {
-        aVal = NULL;
+        aVal = 0;
         aVal = yearValues[index];
 
         return PVMFSuccess;
@@ -1483,6 +1662,8 @@
 
     if (_pMoofOffsetVec != NULL)
         PV_MP4_FF_TEMPLATED_DELETE(NULL, movieFragmentOffsetVecType, Oscl_Vector, _pMoofOffsetVec);
+
+
     if (_pMfraOffsetAtom != NULL)
     {
         PV_MP4_FF_DELETE(NULL, MfraOffsetAtom, _pMfraOffsetAtom);
@@ -1510,16 +1691,12 @@
         PV_MP4_FF_DELETE(NULL, FileTypeAtom, _pFileTypeAtom);
     }
 
-    if (_commonFilePtr != NULL)
-    {
-        if (_commonFilePtr->IsOpen())
-        {
-            AtomUtils::CloseMP4File(_commonFilePtr);
-        }
-        oscl_free(_commonFilePtr);
-    }
     if (_movieFragmentFilePtr != NULL)
     {
+        if (_movieFragmentFilePtr->IsOpen())
+        {
+            AtomUtils::CloseMP4File(_movieFragmentFilePtr);
+        }
         oscl_free(_movieFragmentFilePtr);
     }
     if (_pID3Parser)
@@ -1536,7 +1713,7 @@
     uint32 id = 0;
     if (_isMovieFragmentsPresent)
     {
-        uint64 overallMovieDuration = _pmovieAtom->getMovieFragmentDuration();
+        overallMovieDuration = _pmovieAtom->getMovieFragmentDuration();
         if (Oscl_Int64_Utils::get_uint64_lower32(overallMovieDuration) != 0)
         {
             return overallMovieDuration;
@@ -1699,7 +1876,7 @@
             if (!trackList)
                 return 0;	// malloc failed
             _pmovieAtom->getTrackWholeIDList(trackList);
-            uint64 prevtrackDuration = 0, trackduration = 0;
+            uint64 trackduration = 0;
             for (int32 i = 0; i < numTracks; i++)
             {
                 if (trackList[i] == id)
@@ -1769,7 +1946,7 @@
             if (!trackList)
                 return 0;	// malloc failed
             _pmovieAtom->getTrackWholeIDList(trackList);
-            uint32 prevtrackDuration = 0, trackduration = 0;
+            uint32 trackduration = 0;
             for (int32 i = 0; i < numTracks; i++)
             {
                 if (trackList[i] == id)
@@ -1817,6 +1994,31 @@
     }
 }
 
+uint16 Mpeg4File::getTrackLangCode(uint32 id)
+{
+
+    TrackAtom *trackAtom;
+    if (_pmovieAtom != NULL)
+    {
+        trackAtom = _pmovieAtom->getTrackForID(id);
+    }
+    else
+    {
+        // RETURN UNDEFINED VALUE
+        return (0xFFFF);
+    }
+
+    if (trackAtom != NULL)
+    {
+        return trackAtom->getLanguageCode();
+    }
+    else
+    {
+        // RETURN UNDEFINED VALUE
+        return (0xFFFF);
+    }
+}
+
 // From Handler
 uint32 Mpeg4File::getTrackMediaType(uint32 id)
 {
@@ -1936,53 +2138,18 @@
 }
 
 
-OSCL_wHeapString<OsclMemAllocator> Mpeg4File::getTrackMIMEType(uint32 id) // Based on OTI value
+void Mpeg4File::getTrackMIMEType(uint32 id, OSCL_String& aMimeType) // Based on OTI value
 {
-    TrackAtom *trackAtom;
-
-    OSCL_wHeapString<OsclMemAllocator> unknown_oti(_STRLIT("UNKNOWN"));
+    TrackAtom *trackAtom = NULL;
 
     if (_pmovieAtom != NULL)
     {
         trackAtom =  _pmovieAtom->getTrackForID(id);
     }
-    else
-    {
-        return unknown_oti;
-    }
 
     if (trackAtom != NULL)
     {
-        return (trackAtom->getMIMEType());
-    }
-    else
-    {
-        return unknown_oti;
-    }
-}
-
-uint8  Mpeg4File::getTrackOTIType(uint32 id) // Based on OTI value
-{
-    TrackAtom *trackAtom;
-
-    if (_pmovieAtom != NULL)
-    {
-        trackAtom =  _pmovieAtom->getTrackForID(id);
-    }
-    else
-    {
-        // RETURN SOME UNDEFINED VALUE
-        return (0xFF);
-    }
-
-    if (trackAtom != NULL)
-    {
-        return trackAtom->getObjectTypeIndication();
-    }
-    else
-    {
-        // RETURN SOME UNDEFINED VALUE
-        return (0xFF);
+        trackAtom->getMIMEType(aMimeType);
     }
 }
 
@@ -2101,7 +2268,6 @@
 }
 
 /* ======================================================================== */
-// IMOTION_PSEUDO_STREAMING start
 bool
 Mpeg4File::IsMobileMP4()
 {
@@ -2152,7 +2318,6 @@
 
     return (oMMP4);
 }
-// IMOTION_PSEUDO_STREAMING end
 
 uint8
 Mpeg4File::parseBufferAndGetNumAMRFrames(uint8* buffer, uint32 size)
@@ -2247,24 +2412,28 @@
 {
     PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "Mpeg4File::RequestReadCapacityNotification In Offset %d", aFileOffset));
     uint32 capacity = 0;
-    uint32 currPos = (uint32)(AtomUtils::getCurrentFilePosition(_commonFilePtr));
-    if (aFileOffset > currPos)
+    if (_commonFilePtr != NULL)
     {
-        capacity = (aFileOffset - currPos);
-        bool retVal =
-            _commonFilePtr->_pvfile.RequestReadCapacityNotification(aObserver,
-                    capacity,
-                    aContextData);
-        if (retVal)
+        uint32 currPos = (uint32)(AtomUtils::getCurrentFilePosition(_commonFilePtr));
+        if (aFileOffset > currPos)
         {
-            return EVERYTHING_FINE;
+            capacity = (aFileOffset - currPos);
+            bool retVal =
+                _commonFilePtr->_pvfile.RequestReadCapacityNotification(aObserver,
+                        capacity,
+                        aContextData);
+            if (retVal)
+            {
+                return EVERYTHING_FINE;
+            }
+            else
+            {
+                return DEFAULT_ERROR;
+            }
         }
-        else
-        {
-            return DEFAULT_ERROR;
-        }
+        return SUFFICIENT_DATA_IN_FILE;
     }
-    return SUFFICIENT_DATA_IN_FILE;
+    return DEFAULT_ERROR;
 }
 
 
@@ -2276,6 +2445,11 @@
     {
         return EVERYTHING_FINE;
     }
+    if (_commonFilePtr == NULL && _fileSize != 0)
+    {
+        aFileSize = _fileSize;
+        return EVERYTHING_FINE;
+    }
     return DEFAULT_ERROR;
 }
 
@@ -2320,7 +2494,7 @@
                     MovieFragmentAtom *pMovieFragmentAtom = (*_pMovieFragmentAtomVec)[movieFragmentIdx];
                     if (pMovieFragmentAtom != NULL)
                     {
-                        if (pMovieFragmentAtom->getSequenceNumber() == _movieFragmentSeqIdx[trackID])
+                        if ((uint32)pMovieFragmentAtom->getSequenceNumber() == _movieFragmentSeqIdx[trackID])
                         {
                             TrackFragmentAtom *trackfragment = pMovieFragmentAtom->getTrackFragmentforID(trackID);
                             if (trackfragment != NULL)
@@ -2572,6 +2746,7 @@
                                         atomSize -= DEFAULT_ATOM_SIZE;
                                         AtomUtils::seekFromCurrPos(_movieFragmentFilePtr, atomSize);
                                     }
+
                                 }
                             }
                             if (count <= 0)
@@ -2583,7 +2758,7 @@
                         }
                         else if (!moofParsingCompleted)
                         {
-                            if (currMoofNum != _pMovieFragmentAtom->getSequenceNumber())
+                            if (currMoofNum != (uint32) _pMovieFragmentAtom->getSequenceNumber())
                             {
                                 uint32 size = _pMovieFragmentAtomVec->size();
                                 _pMovieFragmentAtom = (*_pMovieFragmentAtomVec)[size - 1];
@@ -2979,7 +3154,7 @@
                     }
                     else
                     {
-                        if (_pMovieFragmentAtom->getSequenceNumber() == _movieFragmentSeqIdx[id])
+                        if ((uint32)_pMovieFragmentAtom->getSequenceNumber() == _movieFragmentSeqIdx[id])
                         {
                             AtomUtils::seekFromStart(_movieFragmentFilePtr, moofPtrPos);
 
@@ -3499,7 +3674,7 @@
                                         for (uint32 idx = prevMoofSeqNum; idx < currMoofNum - 1;idx++)
                                         {
                                             _pMovieFragmentAtomVec->push_back(NULL);
-                                            _pMoofOffsetVec->push_back(NULL);
+                                            _pMoofOffsetVec->push_back(0);
                                         }
                                         if (currMoofNum > i)
                                         {
@@ -3511,7 +3686,13 @@
                                             (*_pMovieFragmentAtomVec)[currMoofNum-1] = _pMovieFragmentAtom;
                                             (*_pMoofOffsetVec)[currMoofNum-1] = moofStartOffset;
                                         }
+                                        else
+                                        {
+                                            PV_MP4_FF_DELETE(_movieFragmentFilePtr->auditCB, MovieFragmentAtom, _pMovieFragmentAtom);
+                                            _pMovieFragmentAtom = NULL;
+                                            break;
 
+                                        }
                                         _movieFragmentSeqIdx[trackID] = currMoofNum;
                                         _movieFragmentIdx[trackID] = currMoofNum - 1;
                                         _peekMovieFragmentIdx[trackID] = currMoofNum - 1;
@@ -3563,6 +3744,7 @@
                                             atomSize -= DEFAULT_ATOM_SIZE;
                                             AtomUtils::seekFromCurrPos(_movieFragmentFilePtr, atomSize);
                                         }
+
                                     }
                                 }
                             }
@@ -3575,6 +3757,11 @@
                         if (_pMovieFragmentAtom != NULL)
                             returnedTS = _pMovieFragmentAtom->resetPlayback(trackID, convertedTS, traf_number, trun_number, sample_num);
                     }
+                    else
+                    {
+                        // Not a valid tfra entries, cannot reposition.
+                        return 0;
+                    }
                 }
 
             }
@@ -3697,7 +3884,8 @@
                     }
                     else
                     {
-                        oMoofFound = false;
+                        // Not a valid tfra entries, cannot reposition.
+                        return 0;
                     }
                 }
                 if (_parsing_mode == 1 && !oMoofFound)
@@ -3769,7 +3957,7 @@
                                 for (uint32 idx = prevMoofSeqNum; idx < currMoofNum - 1;idx++)
                                 {
                                     _pMovieFragmentAtomVec->push_back(NULL);
-                                    _pMoofOffsetVec->push_back(NULL);
+                                    _pMoofOffsetVec->push_back(0);
                                 }
 
                                 if (currMoofNum > i)
@@ -3782,7 +3970,13 @@
                                     (*_pMovieFragmentAtomVec)[currMoofNum-1] = _pMovieFragmentAtom;
                                     (*_pMoofOffsetVec)[currMoofNum-1] = moofStartOffset;
                                 }
+                                else
+                                {
+                                    PV_MP4_FF_DELETE(_movieFragmentFilePtr->auditCB, MovieFragmentAtom, _pMovieFragmentAtom);
+                                    _pMovieFragmentAtom = NULL;
+                                    break;
 
+                                }
                                 if (oMfraFound)
                                 {
                                     currMoofNum = _pMovieFragmentAtom->getSequenceNumber();
@@ -3855,6 +4049,7 @@
                                     atomSize -= DEFAULT_ATOM_SIZE;
                                     AtomUtils::seekFromCurrPos(_movieFragmentFilePtr, atomSize);
                                 }
+
                             }
                         }
                     }
@@ -3983,6 +4178,7 @@
                     oMfraFound = true;
                     for (uint32 idx = 0; idx < _pMovieFragmentRandomAccessAtomVec->size();idx++)
                     {
+
                         MovieFragmentRandomAccessAtom *pMovieFragmentRandomAccessAtom = (*_pMovieFragmentRandomAccessAtomVec)[idx];
                         returnedTS = pMovieFragmentRandomAccessAtom->queryRepositionTime(trackID, convertedTS, bResetToIFrame,
                                      bBeforeRequestedTime);
@@ -4036,6 +4232,7 @@
 
                 for (uint32 idx = 0; idx < _pMovieFragmentRandomAccessAtomVec->size();idx++)
                 {
+
                     MovieFragmentRandomAccessAtom *pMovieFragmentRandomAccessAtom = (*_pMovieFragmentRandomAccessAtomVec)[idx];
                     returnedTS = pMovieFragmentRandomAccessAtom->queryRepositionTime(trackID, convertedTS, bResetToIFrame,
                                  bBeforeRequestedTime);
@@ -4201,7 +4398,7 @@
                     MovieFragmentAtom *pMovieFragmentAtom = (*_pMovieFragmentAtomVec)[peekMovieFragmentIdx];
                     if (pMovieFragmentAtom != NULL)
                     {
-                        if (pMovieFragmentAtom->getSequenceNumber() == _peekMovieFragmentSeqIdx[trackID])
+                        if ((uint32)pMovieFragmentAtom->getSequenceNumber() == _peekMovieFragmentSeqIdx[trackID])
                         {
                             TrackFragmentAtom *trackfragment = pMovieFragmentAtom->getTrackFragmentforID(trackID);
                             if (trackfragment != NULL)
@@ -4304,6 +4501,7 @@
                                     _pMovieFragmentAtomVec->push_back(_pMovieFragmentAtom);
                                 }
                                 _ptrMoofEnds = AtomUtils::getCurrentFilePosition(_movieFragmentFilePtr);
+
                                 break;
                             }
                             else if (atomType == MEDIA_DATA_ATOM)
@@ -4407,6 +4605,7 @@
                         }
                     }
                     _peekMovieFragmentIdx[trackID]++;
+
                 }
             }
         }
@@ -4455,6 +4654,7 @@
     {
         for (uint32 idx = 0; idx < _pMovieFragmentRandomAccessAtomVec->size();idx++)
         {
+
             MovieFragmentRandomAccessAtom *pMovieFragmentRandomAccessAtom = (*_pMovieFragmentRandomAccessAtomVec)[idx];
             return pMovieFragmentRandomAccessAtom->IsTFRAPresentForTrack(TrackId, oVideoAudioTextTrack);
         }
@@ -4588,6 +4788,10 @@
 
     if (_isMovieFragmentsPresent)
     {
+        if (IsTFRAPresentForTrack(trackID, false) == false)
+        {
+            return 0;
+        }
         if (modifiedTimeStamp >= trackDuration)
         {
             return 1; //repos in moof
@@ -4611,3 +4815,67 @@
         return DEFAULT_ERROR;
     }
 }
+
+bool Mpeg4File::CreateDataStreamSessionForExternalDownload(OSCL_wString& aFilename,
+        PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
+        OsclFileHandle* aHandle,
+        Oscl_FileServer* aFileServSession)
+{
+    OsclAny*ptr = oscl_malloc(sizeof(MP4_FF_FILE));
+    if (ptr == NULL)
+    {
+        _success = false;
+        _mp4ErrorCode = MEMORY_ALLOCATION_FAILED;
+        return false;
+    }
+    _commonFilePtr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE());
+
+    if (_commonFilePtr != NULL)
+    {
+        _commonFilePtr->_fileServSession = aFileServSession;
+        _commonFilePtr->_pvfile.SetCPM(aCPMAccessFactory);
+        _commonFilePtr->_pvfile.SetFileHandle(aHandle);
+
+        if (AtomUtils::OpenMP4File(aFilename,
+                                   Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
+                                   _commonFilePtr) != 0)
+        {
+            return false;
+        }
+
+        uint32 fileSize;
+        AtomUtils::getCurrentFileSize(_commonFilePtr, fileSize);
+        _commonFilePtr->_fileSize = (int32)fileSize;
+    }
+    return true;
+}
+
+void Mpeg4File::DestroyDataStreamForExternalDownload()
+{
+    if (_commonFilePtr != NULL)
+    {
+        if (_commonFilePtr->IsOpen())
+        {
+            AtomUtils::CloseMP4File(_commonFilePtr);
+        }
+        oscl_free(_commonFilePtr);
+        _commonFilePtr = NULL;
+    }
+}
+
+//Below APIs are used to supress Warning
+void Mpeg4File::ReserveMemoryForLangCodeVector(Oscl_Vector<uint16, OsclMemAllocator> &iLangCode, int32 capacity, int32 &leavecode)
+{
+    leavecode = 0;
+    OSCL_TRY(leavecode, iLangCode.reserve(capacity));
+
+}
+
+void Mpeg4File::ReserveMemoryForValuesVector(Oscl_Vector<OSCL_wHeapString<OsclMemAllocator>, OsclMemAllocator> &iValues, int32 capacity, int32 &leavecode)
+{
+    leavecode = 0;
+    OSCL_TRY(leavecode, iValues.reserve(capacity));
+
+}
+
+
diff --git a/fileformats/mp4/parser/src/mpeg4mediaheaderatom.cpp b/fileformats/mp4/parser/src/mpeg4mediaheaderatom.cpp
index adcdb1a..d5f41a2 100644
--- a/fileformats/mp4/parser/src/mpeg4mediaheaderatom.cpp
+++ b/fileformats/mp4/parser/src/mpeg4mediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/mpeg4sampleentryextensions.cpp b/fileformats/mp4/parser/src/mpeg4sampleentryextensions.cpp
index 8c3bed9..19af65c 100644
--- a/fileformats/mp4/parser/src/mpeg4sampleentryextensions.cpp
+++ b/fileformats/mp4/parser/src/mpeg4sampleentryextensions.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_AVCConfigurationBox
 
 #include "avcsampleentry.h"
diff --git a/fileformats/mp4/parser/src/mpegsampleentry.cpp b/fileformats/mp4/parser/src/mpegsampleentry.cpp
index 713b807..2eab0bb 100644
--- a/fileformats/mp4/parser/src/mpegsampleentry.cpp
+++ b/fileformats/mp4/parser/src/mpegsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/objectdescriptor.cpp b/fileformats/mp4/parser/src/objectdescriptor.cpp
index 76295e9..48e58ac 100644
--- a/fileformats/mp4/parser/src/objectdescriptor.cpp
+++ b/fileformats/mp4/parser/src/objectdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 /*     -------------------------------------------------------------------       */
 /*********************************************************************************/
 
+
 #define IMPLEMENT_ObjectDescriptor
 
 #include "objectdescriptor.h"
@@ -134,6 +135,7 @@
 
 OSCL_wHeapString<OsclMemAllocator> ObjectDescriptor::getUrlString() const
 {
+
     // Need to convert from a Multibyte array pointer to a wide character array
 
     // allocate space for wide character buffer
diff --git a/fileformats/mp4/parser/src/objectdescriptoratom.cpp b/fileformats/mp4/parser/src/objectdescriptoratom.cpp
index a68bd36..6c28cfe 100644
--- a/fileformats/mp4/parser/src/objectdescriptoratom.cpp
+++ b/fileformats/mp4/parser/src/objectdescriptoratom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/oma2boxes.cpp b/fileformats/mp4/parser/src/oma2boxes.cpp
index e59d5c0..7e38947 100644
--- a/fileformats/mp4/parser/src/oma2boxes.cpp
+++ b/fileformats/mp4/parser/src/oma2boxes.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -767,6 +767,7 @@
 
     if ((int32)len > 0)
     {
+
         PV_MP4_FF_NEW(fp->auditCB, DecoderSpecificInfo, (fp, true), _decoderSpecificInfo);
 
         uint8* info = (uint8*)(oscl_malloc(sizeof(uint8) * len));
@@ -948,6 +949,7 @@
     uint32 width = _reserved2 & 0xFFFF0000;
     uint32 ret = width >> 16;
     return (uint16)ret;
+
 }
 
 uint16 EcnvBox::getHeight() const
diff --git a/fileformats/mp4/parser/src/paspatom.cpp b/fileformats/mp4/parser/src/paspatom.cpp
index f697b3a..a73ae2b 100644
--- a/fileformats/mp4/parser/src/paspatom.cpp
+++ b/fileformats/mp4/parser/src/paspatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/pvuserdataatom.cpp b/fileformats/mp4/parser/src/pvuserdataatom.cpp
index 5827fa2..436b6dd 100644
--- a/fileformats/mp4/parser/src/pvuserdataatom.cpp
+++ b/fileformats/mp4/parser/src/pvuserdataatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -126,6 +126,7 @@
 // Destructor
 PVUserDataAtom::~PVUserDataAtom()
 {
+
 }
 
 PVContentTypeAtom::PVContentTypeAtom(MP4_FF_FILE *fp, uint32 size, uint32 type)
diff --git a/fileformats/mp4/parser/src/sampledescriptionatom.cpp b/fileformats/mp4/parser/src/sampledescriptionatom.cpp
index 15f5864..4abce06 100644
--- a/fileformats/mp4/parser/src/sampledescriptionatom.cpp
+++ b/fileformats/mp4/parser/src/sampledescriptionatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -379,6 +379,7 @@
             }
 
         } // end if success
+
     }
     else
     {
@@ -443,6 +444,7 @@
                 MpegSampleEntry *ptr = (MpegSampleEntry *)(*_psampleEntryVec)[i];
                 PV_MP4_FF_DELETE(NULL, MpegSampleEntry, ptr);
             }
+
             else
             {
                 SampleEntry *ptr = (SampleEntry *)(*_psampleEntryVec)[i];
@@ -650,7 +652,7 @@
 
 int32 SampleDescriptionAtom::getHeight()
 {
-    uint16 height = 0;
+
     uint32 i = 0;
     if (_o3GPPH263)
     {
@@ -688,6 +690,7 @@
         }
     }
 
+
     if (_psampleEntryVec->size() == 0)
     {
         return 0;
@@ -816,64 +819,56 @@
 }
 
 
-OSCL_wHeapString<OsclMemAllocator> SampleDescriptionAtom::getMIMEType()
+void SampleDescriptionAtom::getMIMEType(OSCL_String& aMimeType)
 {
     uint8 objectType;
     objectType = getObjectTypeIndication();
 
-    if ((objectType == AMR_AUDIO) ||
-            (objectType == AMR_AUDIO_3GPP) ||
-            (objectType == AMRWB_AUDIO_3GPP))
+    OSCL_HeapString<OsclMemAllocator> mimeType;
+
+    mimeType.set(PVMF_MIME_FORMAT_UNKNOWN, oscl_strlen(PVMF_MIME_FORMAT_UNKNOWN));
+
+    if (objectType == AMR_AUDIO)
     {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("AMR"));
-        return temp;
+        mimeType.set(PVMF_MIME_AMR, oscl_strlen(PVMF_MIME_AMR));
+    }
+    else if	(objectType == AMR_AUDIO_3GPP)
+    {
+        mimeType.set(PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF));
+    }
+    else if (objectType == AMRWB_AUDIO_3GPP)
+    {
+        mimeType.set(PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF));
     }
     else if (objectType == MPEG4_AUDIO)
     {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("AAC"));
-        return temp;
+        mimeType.set(PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO));
     }
     else if (objectType == MPEG2_AUDIO_LC)
     {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("AAC"));
-        return temp;
+        mimeType.set(_STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), oscl_strlen(PVMF_MIME_MPEG4_AUDIO));
     }
     else if (objectType == MPEG4_VIDEO)
     {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("MP4V-ES"));
-        return temp;
+        mimeType.set(PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V));
     }
     else if (objectType == H263_VIDEO)
     {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("H263-2000"));
-        return temp;
-
+        mimeType.set(PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000));
     }
     else if (objectType == AVC_VIDEO)
     {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("AVC_VIDEO"));
-        return temp;
-
+        mimeType.set(PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4));
     }
-    else if (objectType == AVC_VIDEO)
-    {
-        OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("X-AVC-VIDEO"));
-        return temp;
-    }
-
     else
     {
         if (_pMediaType == MEDIA_TYPE_TEXT)
         {
-            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("3GPP_TIMED_TEXT"));
-            return temp;
-        }
-        else
-        {
-            OSCL_wHeapString<OsclMemAllocator> temp(_STRLIT("UNKNOWN"));
-            return temp;
+            mimeType.set(PVMF_MIME_3GPP_TIMEDTEXT, oscl_strlen(PVMF_MIME_3GPP_TIMEDTEXT));
         }
     }
+
+    aMimeType = mimeType;
 }
 
 
diff --git a/fileformats/mp4/parser/src/sampleentry.cpp b/fileformats/mp4/parser/src/sampleentry.cpp
index a1dac8b..bad0fa4 100644
--- a/fileformats/mp4/parser/src/sampleentry.cpp
+++ b/fileformats/mp4/parser/src/sampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/samplesizeatom.cpp b/fileformats/mp4/parser/src/samplesizeatom.cpp
index ef6741b..01cd677 100644
--- a/fileformats/mp4/parser/src/samplesizeatom.cpp
+++ b/fileformats/mp4/parser/src/samplesizeatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@
     _curr_entry_point = 0;
     _stbl_fptr_vec = NULL;
     _parsing_mode = parsingMode;
-    _firstSampleOnBkwdRepos = false;
+    _SkipOldEntry = false;
     if (_success)
     {
         if (_size < (DEFAULT_FULL_ATOM_SIZE + 4 + 4))
@@ -195,6 +195,7 @@
 
 bool SampleSizeAtom::ParseEntryUnit(uint32 sample_cnt)
 {
+
     uint32 threshold = 0;
     if (0 != AtomUtils::getFileBufferingCapacity(_fileptr))
     {
@@ -285,7 +286,7 @@
             else
             {
                 uint32 entryLoc = index / _stbl_buff_size;
-                if (!_firstSampleOnBkwdRepos) //Not to use old entries in case of backward Repos.
+                if (!_SkipOldEntry) //Not to use old entries in case of backward Repos.
                 {
                     uint32 actualEntryIndex = _parsed_entry_cnt % _stbl_buff_size;
                     uint32 prevEntriesInBuffer = _stbl_buff_size - actualEntryIndex;
@@ -297,7 +298,7 @@
                             return (_psampleSizeVec[index%_stbl_buff_size]);
                     }
                 }
-                _firstSampleOnBkwdRepos = false;
+                _SkipOldEntry = false;
                 if (_curr_buff_number != entryLoc)
                 {
                     _parsed_entry_cnt = entryLoc * _stbl_buff_size;
diff --git a/fileformats/mp4/parser/src/sampletableatom.cpp b/fileformats/mp4/parser/src/sampletableatom.cpp
index 234b640..1020b6e 100644
--- a/fileformats/mp4/parser/src/sampletableatom.cpp
+++ b/fileformats/mp4/parser/src/sampletableatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,6 +67,8 @@
 
     _SDIndex = 0;
 
+    SamplesCount = 0;
+
     _oMultipleSampleDescription = false;
     _numAMRFramesPerSample = 0;
     _pAMRTempBuffer = NULL;
@@ -102,7 +104,6 @@
             return;
         }
         _pinput = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE());
-
         _pinput->_fileServSession = fp->_fileServSession;
         _pinput->_pvfile.SetCPM(fp->_pvfile.GetCPM());
 
@@ -115,6 +116,7 @@
             return;
         }
         _commonFilePtr = OSCL_PLACEMENT_NEW(ptr, MP4_FF_FILE(*fp));
+
 #endif
 
         _currentPlaybackSampleNumber = 0; // Initializing playback start point
@@ -261,6 +263,7 @@
                                filename, parsingMode),
                               _psampleSizeAtom);
 
+                SamplesCount = _psampleSizeAtom->getSampleCount();
                 // Check for success
                 if (!_psampleSizeAtom->MP4Success())
                 {
@@ -378,9 +381,18 @@
                 count -= atomSize;
                 atomSize -= DEFAULT_ATOM_SIZE;
                 AtomUtils::seekFromCurrPos(fp, atomSize);
+
             }
+
         }
 
+        if (_pcompositionOffsetAtom != NULL)
+        {
+            if (SamplesCount != 0)
+            {
+                _pcompositionOffsetAtom->setSamplesCount(SamplesCount);
+            }
+        }
         /*
          * These 5 atoms are mandatory. In case any of it is absent
          * return ERROR!!!
@@ -1305,6 +1317,7 @@
             {
                 // Reset Time Stamp
                 _currentPlaybackSampleTimestamp -= (tsDelta + getCttsOffsetForSampleNumber(_currentPlaybackSampleNumber));
+
                 return retval;
             }
             _currentPlaybackSampleNumber++;
@@ -1566,9 +1579,9 @@
 
         if (_currentPlaybackSampleNumber > _tempSampleNumber)
         {
-            // In case of Backward Repos,the flag _firstSampleOnBkwdRepos in samplesizeatom.cpp is set to true to prevent
+            // In case of Backward Repos,the flag _SkipOldEntry in samplesizeatom.cpp is set to true to prevent
             // old entries from getting used.
-            getSampleSizeAtom()._firstSampleOnBkwdRepos = true;
+            getSampleSizeAtom()._SkipOldEntry = true;
         }
         _currentPlaybackSampleNumber =
             getTimeToSampleAtom().getSampleNumberFromTimestamp(time - _trackStartTSOffset);
@@ -1599,7 +1612,7 @@
         if (getSampleSizeAtom().getSampleCount() > 0)
         {
             _currentPlaybackSampleNumber =
-                (getSampleSizeAtom().getSampleCount() - 1);
+                (getSampleSizeAtom().getSampleCount());
 
             retValA = _ptimeToSampleAtom->resetStateVariables(_currentPlaybackSampleNumber);
             if (retValA == PV_ERROR)
@@ -1788,9 +1801,6 @@
     PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "SampleTableAtom::resetPlayBackbyTime- _currentPlaybackSampleNumber =%d", _currentPlaybackSampleNumber));
     PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "SampleTableAtom::resetPlayBackbyTime- trueTS =%d", trueTS));
 
-    //this is no longer needed since _currentPlaybackSampleTimestamp is updated
-    // with duration of a sample, after each read
-
     retValA = _ptimeToSampleAtom->resetStateVariables(_currentPlaybackSampleNumber);
     if (retValA == PV_ERROR)
     {
@@ -2013,6 +2023,7 @@
     return	1;	//success
 }
 
+
 int32 SampleTableAtom::getTimestampForRandomAccessPointsBeforeAfter(uint32 ts, uint32 *tsBuf, uint32* numBuf, uint32& numsamplestoget, uint32 howManyKeySamples)
 {
     if (_psyncSampleAtom == NULL)
@@ -2448,9 +2459,11 @@
             SDIndex -= 1;
         }
 
+
         // Find chunk offset to file
         int32 offset = _pchunkOffsetAtom->getChunkOffsetAt(chunk);
 
+
         if (offset == PV_ERROR)
         {
             _mp4ErrorCode =  INVALID_CHUNK_OFFSET;
@@ -2465,6 +2478,7 @@
         int32 tempSize = 0;
 
         uint32 sigmaSampleSize = 0;
+
         for (j = sampleNum;
                 j < (sampleNum + numSamples);
                 j++)
@@ -2566,10 +2580,12 @@
 
             currTSBase += tsDelta;
 
+
             PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "SampleTableAtom::getNextNSamples- pgau->info[%d].sample_info =%d", s, pgau->info[s].sample_info));
             PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "SampleTableAtom::getNextNSamples- pgau->info[%d].ts_delta =%d", s, pgau->info[s].ts_delta));
             PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "SampleTableAtom::getNextNSamples- pgau->info[%d].ts =%d", s, pgau->info[s].ts));
 
+
             s++;
         }
 
@@ -2623,9 +2639,9 @@
             bufEnd++;
         }
 
-        if ((sampleFileOffset < bufStart) || ((sigmaSampleSize + sampleFileOffset) > bufEnd))
+        if (((uint32)sampleFileOffset < bufStart) || ((sigmaSampleSize + sampleFileOffset) > bufEnd))
         {
-            if (_currentPlaybackSampleNumber != startSampleNum)
+            if ((uint32)_currentPlaybackSampleNumber != startSampleNum)
             {
                 _currentPlaybackSampleNumber = startSampleNum;
                 _currentPlaybackSampleTimestamp = startSampleNumTSBase;
@@ -2922,6 +2938,7 @@
                                   MediaMetaInfo    *mInfo)
 {//this API is only called in peekNextBundledAccessUnits(), which already check _psampleSizeAtom is NULL
 
+
     int32 currTSBase = _currentPlaybackSampleTimestamp;
     int32 i = 0;
     uint32 sampleNum = startSampleNum;
@@ -3067,6 +3084,7 @@
 
 int32 SampleTableAtom::getOffsetByTime(uint32 ts, int32* sampleFileOffset)
 {
+
     if ((_psampleSizeAtom    == NULL) ||
             (_psampleToChunkAtom == NULL) ||
             (_ptimeToSampleAtom == NULL) ||
@@ -3130,8 +3148,8 @@
 
     // Find actual file offset to sample
     *sampleFileOffset = offset + sampleSizeOffset;
-
-    if (sampleNum == (numSamples - 1))
+    getSampleSizeAtom()._SkipOldEntry = true;
+    if (sampleNum == (int32)(numSamples - 1))
     {
         return LAST_SAMPLE_IN_MOOV;
     }
@@ -3355,16 +3373,6 @@
 int32 SampleTableAtom::
 getTimestampForCurrentSample()
 {
-    if (_psampleDescriptionAtom->Is3GPPAMR())
-    {
-        int32 ts = _amrFrameTimeStamp;
-
-        _amrFrameTimeStamp += _amrFrameDelta;
-
-        return ts;
-    }
-    else
-    {
-        return _currentPlaybackSampleTimestamp;
-    }
+    return _currentPlaybackSampleTimestamp;
 }
+
diff --git a/fileformats/mp4/parser/src/sampletochunkatom.cpp b/fileformats/mp4/parser/src/sampletochunkatom.cpp
index b357614..80722b8 100644
--- a/fileformats/mp4/parser/src/sampletochunkatom.cpp
+++ b/fileformats/mp4/parser/src/sampletochunkatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -250,8 +250,9 @@
 }
 bool SampleToChunkAtom::ParseEntryUnit(uint32 sample_cnt)
 {
+
     uint32 prevFirstChunk = 0;
-    uint32 j = 0;
+
 
     const uint32 threshold = 512;
     sample_cnt += threshold;
@@ -825,6 +826,7 @@
     return 0; // Should never get here
 }
 
+
 // Returns the chunk number for the given sample number
 uint32
 SampleToChunkAtom::getSDIndexPeek() const
diff --git a/fileformats/mp4/parser/src/slconfigdescriptor.cpp b/fileformats/mp4/parser/src/slconfigdescriptor.cpp
index fa73d95..48c7a98 100644
--- a/fileformats/mp4/parser/src/slconfigdescriptor.cpp
+++ b/fileformats/mp4/parser/src/slconfigdescriptor.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,12 +40,14 @@
         if (!AtomUtils::read8(fp, _predefined))
             _success = false;
 
+
         // Need to add in abilty to handle case where (_predefined == 0).
         // In this situation, there are many other members that need to be rendered
 
 
         if (getSizeOfSizeField() + 2 != getSize())
         {
+
             if (_success && _OCRStreamFlag)
             {
                 if (!AtomUtils::read16(fp, _OCRESID))
diff --git a/fileformats/mp4/parser/src/soundmediaheaderatom.cpp b/fileformats/mp4/parser/src/soundmediaheaderatom.cpp
index ab4010b..3cd4dae 100644
--- a/fileformats/mp4/parser/src/soundmediaheaderatom.cpp
+++ b/fileformats/mp4/parser/src/soundmediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/stylerecord.cpp b/fileformats/mp4/parser/src/stylerecord.cpp
index 2b9dfeb..d436faa 100644
--- a/fileformats/mp4/parser/src/stylerecord.cpp
+++ b/fileformats/mp4/parser/src/stylerecord.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/syncsampleatom.cpp b/fileformats/mp4/parser/src/syncsampleatom.cpp
index 4f4b293..3e48946 100644
--- a/fileformats/mp4/parser/src/syncsampleatom.cpp
+++ b/fileformats/mp4/parser/src/syncsampleatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/textsampleentry.cpp b/fileformats/mp4/parser/src/textsampleentry.cpp
index 02f18fa..fe83cf5 100644
--- a/fileformats/mp4/parser/src/textsampleentry.cpp
+++ b/fileformats/mp4/parser/src/textsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/textsamplemodifiers.cpp b/fileformats/mp4/parser/src/textsamplemodifiers.cpp
index e8d6bf6..a215bb1 100644
--- a/fileformats/mp4/parser/src/textsamplemodifiers.cpp
+++ b/fileformats/mp4/parser/src/textsamplemodifiers.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,15 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-/*     -------------------------------------------------------------------       */
-/*                        MPEG-4 TextSampleModifiers Class                       */
-/*     -------------------------------------------------------------------       */
-/*********************************************************************************/
-/*
-    This TextSampleModifiers Class is used for text streams.
-*/
-
 #define IMPLEMENT_TextSampleModifiers
 
 #include "textsamplemodifiers.h"
@@ -829,4 +820,6 @@
 
 }
 
-#endif // SUPPRESS__NOT_YET_IMPLEMENTED
\ No newline at end of file
+
+#endif // SUPPRESS__NOT_YET_IMPLEMENTED
+
diff --git a/fileformats/mp4/parser/src/timetosampleatom.cpp b/fileformats/mp4/parser/src/timetosampleatom.cpp
index e26b124..3a23c86 100644
--- a/fileformats/mp4/parser/src/timetosampleatom.cpp
+++ b/fileformats/mp4/parser/src/timetosampleatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -414,6 +414,7 @@
         }
     }
 
+
     sampleCount += 1;
     if (ts >= timeCount)
     {
@@ -563,6 +564,8 @@
             return (PV_ERROR);
         }
     }
+
+
 }
 
 // Returns the timestamp delta (ms) for the current sample given by num.  This value
@@ -612,6 +615,8 @@
             return (PV_ERROR);
         }
     }
+
+
 }
 
 int32
@@ -658,6 +663,7 @@
         {
             return (EVERYTHING_FINE);
         }
+
     }
 
     // Went past end of list - not a valid sample number
diff --git a/fileformats/mp4/parser/src/trackatom.cpp b/fileformats/mp4/parser/src/trackatom.cpp
index b0b45ff..c02d178 100644
--- a/fileformats/mp4/parser/src/trackatom.cpp
+++ b/fileformats/mp4/parser/src/trackatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/trackextendsatom.cpp b/fileformats/mp4/parser/src/trackextendsatom.cpp
index 29d70da..e98a98d 100644
--- a/fileformats/mp4/parser/src/trackextendsatom.cpp
+++ b/fileformats/mp4/parser/src/trackextendsatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_TrackExtendsAtom
 
 #include "trackextendsatom.h"
diff --git a/fileformats/mp4/parser/src/trackfragmentatom.cpp b/fileformats/mp4/parser/src/trackfragmentatom.cpp
index 849ec5f..bfd46e1 100644
--- a/fileformats/mp4/parser/src/trackfragmentatom.cpp
+++ b/fileformats/mp4/parser/src/trackfragmentatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -265,6 +265,9 @@
                                       bool &trafParsingCompleted,
                                       uint32 &countOfTrunsParsed)
 {
+    OSCL_UNUSED_ARG(type);
+    OSCL_UNUSED_ARG(movieFragmentCurrentOffset);
+    OSCL_UNUSED_ARG(moofSize);
     uint32 count = size;
     uint32 trun_start = 0;
     uint32 _movieFragmentBaseOffset = movieFragmentBaseOffset - DEFAULT_ATOM_SIZE;
@@ -570,7 +573,8 @@
             return (_mp4ErrorCode);
         }
 
-        int32 tfrunoffset = Oscl_Int64_Utils::get_uint64_lower32(tfRun->getDataOffset());
+        int32 tfrunoffset = 0;
+        tfrunoffset = Oscl_Int64_Utils::get_uint64_lower32(tfRun->getDataOffset());
         int32 sampleSizeOffset = 0;
 
         uint32 sigmaSampleSize = 0, k = 0;
@@ -663,6 +667,7 @@
         }
 
 
+
         Oscl_Int64_Utils::set_uint64(pgau->SampleOffset, 0, (uint32)sampleFileOffset);
 
         AtomUtils::getCurrentFileSize(_pinput, _fileSize);
@@ -713,6 +718,7 @@
                 tempgauPtr->buf.fragments[k].ptr = read_fragment_ptr;
 
                 sigmaSampleSize -= tmpSize;
+
             }
 
             if (sigmaSampleSize == 0)
@@ -979,7 +985,8 @@
             return (_mp4ErrorCode);
         }
 
-        int32 tfrunoffset = Oscl_Int64_Utils::get_uint64_lower32(tfRun->getDataOffset());
+        int32 tfrunoffset = 0;
+        tfrunoffset = Oscl_Int64_Utils::get_uint64_lower32(tfRun->getDataOffset());
         int32 sampleSizeOffset = 0;
 
         uint32 sigmaSampleSize = 0, k = 0;
@@ -1079,12 +1086,12 @@
             break;
         }
 
-        if (_peekPlaybackSampleNumber == (int32)totalnumSamples)
+        if (_peekPlaybackSampleNumber == totalnumSamples)
         {
             break;
         }
 
-        if (_peekPlaybackSampleNumber > (int32)totalnumSamples)
+        if (_peekPlaybackSampleNumber > totalnumSamples)
         {
             _mp4ErrorCode = END_OF_TRACK;
             break;
@@ -1225,9 +1232,7 @@
 int32
 TrackFragmentAtom::getOffsetByTime(uint32 id, uint32 ts, int32* sampleFileOffset)
 {
-
-    PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "TrackFragmentAtom::peekNextNSamples- Track Fragment Run Input TS =%d track ID %d", ts, id));
-    int32 sampleTS = 0, sampleOffset = DEFAULT_ERROR;
+    OSCL_UNUSED_ARG(id);
     uint32 time = ts;
     uint32 prevTime = 0, prevOffset = 0;
     if (_pTrackFragmentRunAtomVec != NULL)
@@ -1251,13 +1256,11 @@
                             if (diffwithbeforeTS > diffwithafterTS)
                             {
                                 *sampleFileOffset = (*_tfRunSampleInfo)[i]->_sample_offset;;
-                                PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "TrackFragmentAtom::peekNextNSamples- Track Fragment Run Offset Time =%d %d", sampleOffset, sampleTS));
                                 return EVERYTHING_FINE;
                             }
                             else
                             {
                                 *sampleFileOffset = prevOffset;
-                                PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES((0, "TrackFragmentAtom::peekNextNSamples- Track Fragment Run Offset Time =%d %d", sampleOffset, sampleTS));
                                 return EVERYTHING_FINE;
                             }
                         }
@@ -1279,7 +1282,7 @@
     {
         for (uint32 i = 0; i < _pTrackdurationInfoVec->size();i++)
         {
-            if ((*_pTrackdurationInfoVec)[i]->trackId == id)
+            if ((int32)((*_pTrackdurationInfoVec)[i]->trackId) == id)
             {
                 (*_pTrackdurationInfoVec)[i]->trackDuration = duration;
             }
diff --git a/fileformats/mp4/parser/src/trackfragmentheaderatom.cpp b/fileformats/mp4/parser/src/trackfragmentheaderatom.cpp
index ae3b3da..94961c5 100644
--- a/fileformats/mp4/parser/src/trackfragmentheaderatom.cpp
+++ b/fileformats/mp4/parser/src/trackfragmentheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_TrackFragmentHeaderAtom
 
 #include "trackfragmentheaderatom.h"
diff --git a/fileformats/mp4/parser/src/trackfragmentrandomaccess.cpp b/fileformats/mp4/parser/src/trackfragmentrandomaccess.cpp
index 081517d..133b483 100644
--- a/fileformats/mp4/parser/src/trackfragmentrandomaccess.cpp
+++ b/fileformats/mp4/parser/src/trackfragmentrandomaccess.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_TrackFragmentRandomAccessAtom
 
 #include "trackfragmentrandomaccess.h"
diff --git a/fileformats/mp4/parser/src/trackfragmentrunatom.cpp b/fileformats/mp4/parser/src/trackfragmentrunatom.cpp
index 1c38d11..f6dc27d 100644
--- a/fileformats/mp4/parser/src/trackfragmentrunatom.cpp
+++ b/fileformats/mp4/parser/src/trackfragmentrunatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*********************************************************************************/
-
-
 #define IMPLEMENT_TrackFragmentRunAtom
 
 #include "trackfragmentrunatom.h"
diff --git a/fileformats/mp4/parser/src/trackheaderatom.cpp b/fileformats/mp4/parser/src/trackheaderatom.cpp
index fd6b6bd..1b9d266 100644
--- a/fileformats/mp4/parser/src/trackheaderatom.cpp
+++ b/fileformats/mp4/parser/src/trackheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -111,6 +111,7 @@
         if (!AtomUtils::read32(fp, _reserved7))
             _success = false;
 
+
         if (_success)
         {
             if (_reserved3 == 0x0100)
diff --git a/fileformats/mp4/parser/src/trackreferenceatom.cpp b/fileformats/mp4/parser/src/trackreferenceatom.cpp
index cc401cc..bf0bcc3 100644
--- a/fileformats/mp4/parser/src/trackreferenceatom.cpp
+++ b/fileformats/mp4/parser/src/trackreferenceatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 /*     -------------------------------------------------------------------       */
 /*********************************************************************************/
 
+
 #define IMPLEMENT_TrackReferenceAtom
 
 #include "trackreferenceatom.h"
diff --git a/fileformats/mp4/parser/src/trackreferencetypeatom.cpp b/fileformats/mp4/parser/src/trackreferencetypeatom.cpp
index a3aa1a8..f3bbe5e 100644
--- a/fileformats/mp4/parser/src/trackreferencetypeatom.cpp
+++ b/fileformats/mp4/parser/src/trackreferencetypeatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/userdataatom.cpp b/fileformats/mp4/parser/src/userdataatom.cpp
index bc8befc..f98d855 100644
--- a/fileformats/mp4/parser/src/userdataatom.cpp
+++ b/fileformats/mp4/parser/src/userdataatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -399,7 +399,6 @@
                 }
             }
 
-
             else
             {
                 // skip unknown atom
@@ -424,6 +423,7 @@
 
 }
 
+
 // Destructor
 UserDataAtom::~UserDataAtom()
 {
@@ -444,7 +444,6 @@
     }
 
 
-
     if (_pCopyRightAtomArray != NULL)
     {
         // CLEAN UP VECTOR!!
@@ -543,7 +542,7 @@
         {
             PV_MP4_FF_DELETE(NULL, AssetInfoAlbumAtom, (*_pAssetInfoAlbumAtomArray)[i]);
         }
-        PV_MP4_FF_TEMPLATED_DELETE(NULL, assetInfoLocationAtomVecType, Oscl_Vector, _pAssetInfoAlbumAtomArray);
+        PV_MP4_FF_TEMPLATED_DELETE(NULL, assetInfoAlbumAtomVecType, Oscl_Vector, _pAssetInfoAlbumAtomArray);
     }
 
     if (_pAssetInfoRecordingYearArray != NULL)
@@ -553,7 +552,7 @@
         {
             PV_MP4_FF_DELETE(NULL, AssetInfoRecordingYearAtom, (*_pAssetInfoRecordingYearArray)[i]);
         }
-        PV_MP4_FF_TEMPLATED_DELETE(NULL, assetInfoLocationAtomVecType, Oscl_Vector, _pAssetInfoRecordingYearArray);
+        PV_MP4_FF_TEMPLATED_DELETE(NULL, assetInfoRecordingYearAtomVecType, Oscl_Vector, _pAssetInfoRecordingYearArray);
     }
 
 
diff --git a/fileformats/mp4/parser/src/videomediaheaderatom.cpp b/fileformats/mp4/parser/src/videomediaheaderatom.cpp
index 9075306..b447c36 100644
--- a/fileformats/mp4/parser/src/videomediaheaderatom.cpp
+++ b/fileformats/mp4/parser/src/videomediaheaderatom.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/mp4/parser/src/visualsampleentry.cpp b/fileformats/mp4/parser/src/visualsampleentry.cpp
index 3cf6530..d5608c6 100644
--- a/fileformats/mp4/parser/src/visualsampleentry.cpp
+++ b/fileformats/mp4/parser/src/visualsampleentry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -164,5 +164,6 @@
     uint32 width = _reserved2 & 0xFFFF0000;
     uint32 ret = width >> 16;
     return (uint16)ret;
+
 }
 
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/Android.mk b/fileformats/mp4/parser/utils/mp4recognizer/Android.mk
new file mode 100644
index 0000000..5dc2c30
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pvmp4ffrec.cpp \
+ 	src/atomutils.cpp
+
+
+LOCAL_MODULE := libmp4recognizer_utility
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/fileformats/mp4/parser/utils/mp4recognizer/src \
+ 	$(PV_TOP)/fileformats/mp4/parser/utils/mp4recognizer/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pvmp4ffrec.h \
+ 	include/atomdefs.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/build/make/local.mk b/fileformats/mp4/parser/utils/mp4recognizer/build/make/local.mk
new file mode 100644
index 0000000..a42b9b9
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/build/make/local.mk
@@ -0,0 +1,23 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := mp4recognizer_utility
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmp4ffrec.cpp \
+	atomutils.cpp
+
+HDRS := pvmp4ffrec.h \
+	atomdefs.h
+
+
+
+include $(MK)/library.mk
+
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/include/atomdefs.h b/fileformats/mp4/parser/utils/mp4recognizer/include/atomdefs.h
new file mode 100644
index 0000000..8631855
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/include/atomdefs.h
@@ -0,0 +1,412 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ATOMDEFS_H_INCLUDED
+#define ATOMDEFS_H_INCLUDED
+
+#ifndef PV_MP4FFPARSER_CONFIG_H_INCLUDED
+#include "pv_mp4ffparser_config.h"
+#endif
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+
+#ifndef OSCL_MEM__H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+
+#ifndef OSCL_INT64_UTILS_H_INCLUDED
+#include "oscl_int64_utils.h"
+#endif
+static const int32 MEDIA_DATA_IN_MEMORY = 0;
+static const int32 MEDIA_DATA_ON_DISK = 1;
+
+static const uint32 DEFAULT_PRESENTATION_TIMESCALE = 1000; // For milliseconds
+static const uint32 INITIAL_TRACK_ID = 1; // Initial track ID for first track added to this movie
+
+static const int32 MEDIA_TYPE_UNKNOWN = 10;
+
+// MediaInformationHeaderAtom types
+static const int32 MEDIA_INFORMATION_HEADER_TYPE_AUDIO = 0;
+static const int32 MEDIA_INFORMATION_HEADER_TYPE_VISUAL = 1;
+static const int32 MEDIA_INFORMATION_HEADER_TYPE_HINT = 2;
+static const int32 MEDIA_INFORMATION_HEADER_TYPE_MPEG4 = 3;
+
+static const uint32 UNKNOWN_ATOM = 0;
+static const int32 UNKNOWN_DESCRIPTOR = 1;
+static const int32 UNKNOWN_HANDLER = 2;
+
+static const int32 CODING_TYPE_I = 0;
+static const int32 CODING_TYPE_P = 1;
+static const int32 CODING_TYPE_B = 2;
+static const int32 CODING_TYPE_SPRITE = 3;
+
+// Mpeg-4 file types
+static const int32 FILE_TYPE_AUDIO = 1;
+static const int32 FILE_TYPE_VIDEO = 2;
+static const int32 FILE_TYPE_AUDIO_VIDEO = 3; // Logical ORing of the two
+static const int32 FILE_TYPE_STILL_IMAGE = 4;
+static const int32 FILE_TYPE_STILL_IMAGE_AUDIO = 5; // Logical ORing of the two
+static const int32 FILE_TYPE_TEXT = 8;
+static const int32 FILE_TYPE_TEXT_AUDIO = 9;
+static const int32 FILE_TYPE_TEXT_VIDEO = 10;
+static const int32 FILE_TYPE_TEXT_AUDIO_VIDEO = 11; // Logical ORing
+
+
+// Scalability settings on the Mpeg4 file
+static const int32 STREAM_SCALABILITY_NONE = 0;
+static const int32 STREAM_SCALABILITY_TEMPORAL = 1;
+static const int32 STREAM_SCALABILITY_SPATIAL = 2;
+static const int32 STREAM_SCALABILITY_BOTH = 3; // Logical ORing of the two
+
+#define FourCharConstToUint32(a, b, c, d) ( (uint32(a) << 24) | (uint32(b) << 16) | (uint32(c) << 8) | uint32(d) )
+
+const uint32 PACKETVIDEO_FOURCC = FourCharConstToUint32('p', 'v', 'm', 'm');
+const uint32 PVUSER_DATA_ATOM = FourCharConstToUint32('p', 'v', 'm', 'm');
+
+const uint32    FILE_TYPE_ATOM = FourCharConstToUint32('f', 't', 'y', 'p');
+
+const uint32    UUID_ATOM = FourCharConstToUint32('u', 'u', 'i', 'd');
+
+const uint32    MOVIE_ATOM = FourCharConstToUint32('m', 'o', 'o', 'v');
+const uint32    MOVIE_HEADER_ATOM = FourCharConstToUint32('m', 'v', 'h', 'd');
+const uint32    TRACK_ATOM = FourCharConstToUint32('t', 'r', 'a', 'k');
+const uint32    ESD_ATOM = FourCharConstToUint32('e', 's', 'd', 's');
+const uint32    TRACK_HEADER_ATOM = FourCharConstToUint32('t', 'k', 'h', 'd');
+const uint32    TRACK_REFERENCE_ATOM = FourCharConstToUint32('t', 'r', 'e', 'f');
+
+//movie fragments
+const uint32    MOVIE_FRAGMENT_ATOM = FourCharConstToUint32('m', 'o', 'o', 'f');
+const uint32	MOVIE_EXTENDS_ATOM = FourCharConstToUint32('m', 'v', 'e', 'x');
+const uint32	MOVIE_EXTENDS_HEADER_ATOM = FourCharConstToUint32('m', 'e', 'h', 'd');
+const uint32	TRACK_EXTENDS_ATOM = FourCharConstToUint32('t', 'r', 'e', 'x');
+const uint32	MOVIE_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('m', 'f', 'h', 'd');
+const uint32	TRACK_FRAGMENT_ATOM = FourCharConstToUint32('t', 'r', 'a', 'f');
+const uint32	TRACK_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('t', 'f', 'h', 'd');
+const uint32	TRACK_FRAGMENT_RUN_ATOM = FourCharConstToUint32('t', 'r', 'u', 'n');
+const uint32	MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('m', 'f', 'r', 'a');
+const uint32	MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM = FourCharConstToUint32('m', 'f', 'r', 'o');
+const uint32	TRACK_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('t', 'f', 'r', 'a');
+
+const uint32    HINT_TRACK_REFERENCE_TYPE = FourCharConstToUint32('h', 'i', 'n', 't');
+const uint32    DPND_TRACK_REFERENCE_TYPE = FourCharConstToUint32('d', 'p', 'n', 'd');
+const uint32    IPIR_TRACK_REFERENCE_TYPE = FourCharConstToUint32('i', 'p', 'i', 'r');
+const uint32    MPOD_TRACK_REFERENCE_TYPE = FourCharConstToUint32('m', 'p', 'o', 'd');
+const uint32    SYNC_TRACK_REFERENCE_TYPE = FourCharConstToUint32('s', 'y', 'n', 'c');
+
+const uint32    MEDIA_ATOM = FourCharConstToUint32('m', 'd', 'i', 'a');
+const uint32    EDIT_ATOM = FourCharConstToUint32('e', 'd', 't', 's');
+const uint32    EDIT_LIST_ATOM = FourCharConstToUint32('e', 'l', 's', 't');
+const uint32    MEDIA_HEADER_ATOM = FourCharConstToUint32('m', 'd', 'h', 'd');
+const uint32    HANDLER_ATOM = FourCharConstToUint32('h', 'd', 'l', 'r');
+const uint32    MEDIA_INFORMATION_ATOM = FourCharConstToUint32('m', 'i', 'n', 'f');
+const uint32    VIDEO_MEDIA_HEADER_ATOM = FourCharConstToUint32('v', 'm', 'h', 'd');
+const uint32    SOUND_MEDIA_HEADER_ATOM = FourCharConstToUint32('s', 'm', 'h', 'd');
+const uint32    HINT_MEDIA_HEADER_ATOM = FourCharConstToUint32('h', 'm', 'h', 'd');
+const uint32    MPEG4_MEDIA_HEADER_ATOM = FourCharConstToUint32('n', 'm', 'h', 'd');
+const uint32    DATA_INFORMATION_ATOM = FourCharConstToUint32('d', 'i', 'n', 'f');
+const uint32    DATA_REFERENCE_ATOM = FourCharConstToUint32('d', 'r', 'e', 'f');
+const uint32    DATA_ENTRY_URL_ATOM = FourCharConstToUint32('u', 'r', 'l', ' ');
+const uint32    DATA_ENTRY_URN_ATOM = FourCharConstToUint32('u', 'r', 'n', ' ');
+const uint32    SAMPLE_TABLE_ATOM = FourCharConstToUint32('s', 't', 'b', 'l');
+const uint32    TIME_TO_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 't', 's');
+const uint32    COMPOSITION_OFFSET_ATOM = FourCharConstToUint32('c', 't', 't', 's');
+const uint32    SAMPLE_DESCRIPTION_ATOM = FourCharConstToUint32('s', 't', 's', 'd');
+const uint32    SAMPLE_SIZE_ATOM = FourCharConstToUint32('s', 't', 's', 'z');
+const uint32    SAMPLE_TO_CHUNK_ATOM = FourCharConstToUint32('s', 't', 's', 'c');
+const uint32    CHUNK_OFFSET_ATOM = FourCharConstToUint32('s', 't', 'c', 'o');
+const uint32    SYNC_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 's', 's');
+const uint32    SHADOW_SYNC_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 's', 'h');
+const uint32    DEGRADATION_PRIORITY_ATOM = FourCharConstToUint32('s', 't', 'd', 'p');
+const uint32    OBJECT_DESCRIPTOR_ATOM = FourCharConstToUint32('i', 'o', 'd', 's');
+const uint32    MEDIA_DATA_ATOM = FourCharConstToUint32('m', 'd', 'a', 't');
+const uint32    FREE_SPACE_ATOM = FourCharConstToUint32('f', 'r', 'e', 'e');
+const uint32    SKIP_ATOM = FourCharConstToUint32('s', 'k', 'i', 'p');
+const uint32    USER_DATA_ATOM = FourCharConstToUint32('u', 'd', 't', 'a');
+const uint32    MEDIA_TYPE_AUDIO = FourCharConstToUint32('s', 'o', 'u', 'n');
+const uint32    MEDIA_TYPE_VISUAL = FourCharConstToUint32('v', 'i', 'd', 'e');
+const uint32    MEDIA_TYPE_HINT = FourCharConstToUint32('h', 'i', 'n', 't');
+const uint32    MEDIA_TYPE_OBJECT_DESCRIPTOR = FourCharConstToUint32('o', 'd', 's', 'm');
+const uint32    MEDIA_TYPE_CLOCK_REFERENCE = FourCharConstToUint32('c', 'r', 's', 'm');
+const uint32    MEDIA_TYPE_SCENE_DESCRIPTION = FourCharConstToUint32('s', 'd', 's', 'm');
+const uint32    MEDIA_TYPE_MPEG7 = FourCharConstToUint32('m', '7', 's', 'm');
+const uint32    MEDIA_TYPE_OBJECT_CONTENT_INFO = FourCharConstToUint32('o', 'c', 's', 'm');
+const uint32    MEDIA_TYPE_IPMP = FourCharConstToUint32('i', 'p', 's', 'm');
+const uint32    MEDIA_TYPE_MPEG_J = FourCharConstToUint32('m', 'j', 's', 'm');
+const uint32    MEDIA_TYPE_SCALABILITY = FourCharConstToUint32('p', 'v', 's', 'c');
+const uint32    MEDIA_TYPE_TEXT = FourCharConstToUint32('t', 'e', 'x', 't');
+
+const uint32    MPEG_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 's');
+const uint32    AUDIO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'a');
+const uint32    VIDEO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'v');
+
+const uint32    AMR_SAMPLE_ENTRY_ATOM = FourCharConstToUint32('s', 'a', 'm', 'r');
+const uint32    AMRWB_SAMPLE_ENTRY_ATOM = FourCharConstToUint32('s', 'a', 'w', 'b');
+const uint32    H263_SAMPLE_ENTRY_ATOM = FourCharConstToUint32('s', '2', '6', '3');
+
+const uint32    AMR_SPECIFIC_ATOM = FourCharConstToUint32('d', 'a', 'm', 'r');
+const uint32    H263_SPECIFIC_ATOM = FourCharConstToUint32('d', '2', '6', '3');
+const uint32    H263_BITRATE_ATOM = FourCharConstToUint32('b', 'i', 't', 'r');
+
+
+const uint32    COPYRIGHT_ATOM = FourCharConstToUint32('c', 'p', 'r', 't');
+
+const uint32    NULL_MEDIA_HEADER_ATOM = FourCharConstToUint32('n', 'm', 'h', 'd');
+const uint32    FONT_TABLE_ATOM = FourCharConstToUint32('f', 't', 'a', 'b');
+const uint32    TEXT_SAMPLE_ENTRY = FourCharConstToUint32('t', 'x', '3', 'g');
+
+// Part of udta at file level
+const uint32    PV_CONTENT_TYPE_ATOM = FourCharConstToUint32('p', 'v', 'c', 't');
+
+const uint32    ASSET_INFO_TITLE_ATOM = FourCharConstToUint32('t', 'i', 't', 'l');
+const uint32    ASSET_INFO_DESCP_ATOM = FourCharConstToUint32('d', 's', 'c', 'p');
+const uint32    ASSET_INFO_PERF_ATOM = FourCharConstToUint32('p', 'e', 'r', 'f');
+const uint32    ASSET_INFO_AUTHOR_ATOM = FourCharConstToUint32('a', 'u', 't', 'h');
+const uint32    ASSET_INFO_GENRE_ATOM = FourCharConstToUint32('g', 'n', 'r', 'e');
+const uint32    ASSET_INFO_RATING_ATOM = FourCharConstToUint32('r', 't', 'n', 'g');
+const uint32    ASSET_INFO_CLSF_ATOM = FourCharConstToUint32('c', 'l', 's', 'f');
+const uint32    ASSET_INFO_KEYWORD_ATOM = FourCharConstToUint32('k', 'y', 'w', 'd');
+const uint32    ASSET_INFO_LOCATION_ATOM = FourCharConstToUint32('l', 'o', 'c', 'i');
+const uint32    ASSET_INFO_ALBUM_ATOM = FourCharConstToUint32('a', 'l', 'b', 'm');
+const uint32    ASSET_INFO_YRRC_ATOM = FourCharConstToUint32('y', 'r', 'r', 'c');
+
+//AVC related atoms
+const uint32    AVC_SAMPLE_ENTRY = FourCharConstToUint32('a', 'v', 'c', '1');
+const uint32    AVC_CONFIGURATION_BOX = FourCharConstToUint32('a', 'v', 'c', 'C');
+const uint32    AVC_SAMPLE_DEPENDENCY_TYPE_BOX = FourCharConstToUint32('s', 'd', 't', 'p');
+const uint32    AVC_SAMPLE_TO_GROUP_BOX = FourCharConstToUint32('s', 'b', 'g', 'p');
+const uint32    AVC_SAMPLE_GROUP_DESCRIPTION_BOX = FourCharConstToUint32('s', 'g', 'p', 'd');
+const uint32    AVC_SUBSEQUENCE_DESCRIPTION_BOX = FourCharConstToUint32('a', 'v', 's', 's');
+const uint32    AVC_LAYER_DESCRIPTION_BOX = FourCharConstToUint32('a', 'v', 'l', 'l');
+const uint32    AVC_SAMPLE_DEPENDENCY_BOX = FourCharConstToUint32('s', 'd', 'e', 'p');
+
+const uint32    MPEG4_BITRATE_BOX = FourCharConstToUint32('b', 't', 'r', 't');
+const uint32    MPEG4_EXTENSION_DESCRIPTORS_BOX = FourCharConstToUint32('m', '4', 'd', 's');
+
+//Pixel Aspect Ratio
+const uint32  PIXELASPECTRATIO_BOX = FourCharConstToUint32('p', 'a', 's', 'p');
+
+
+const uint32    WMF_BRAND = FourCharConstToUint32('w', 'm', 'f', ' ');
+const uint32    BRAND_3GPP4 = FourCharConstToUint32('3', 'g', 'p', '4');
+const uint32    MOBILE_MP4 = FourCharConstToUint32('m', 'm', 'p', '4');
+const uint32    BRAND_3GPP5 = FourCharConstToUint32('3', 'g', 'p', '5');
+const uint32    BRAND_3GP6 = FourCharConstToUint32('3', 'g', 'p', '6');
+const uint32    BRAND_3GR6 = FourCharConstToUint32('3', 'g', 'r', '6');
+const uint32    BRAND_MP41 = FourCharConstToUint32('m', 'p', '4', '1');
+const uint32    BRAND_MP42 = FourCharConstToUint32('m', 'p', '4', '2');
+const uint32    BRAND_ISOM = FourCharConstToUint32('i', 's', 'o', 'm');
+
+
+/* OMA2 DRM Atoms */
+const uint32    ENCRYPTED_AUDIO_SAMPLE_ENTRY = FourCharConstToUint32('e', 'n', 'c', 'a');
+const uint32    ENCRYPTED_VIDEO_SAMPLE_ENTRY = FourCharConstToUint32('e', 'n', 'c', 'v');
+const uint32    ENCRYPTED_TEXT_SAMPLE_ENTRY = FourCharConstToUint32('e', 'n', 'c', 't');
+
+const uint32    PROTECTION_SCHEME_INFO_BOX = FourCharConstToUint32('s', 'i', 'n', 'f');
+const uint32    ORIGINAL_FORMAT_BOX = FourCharConstToUint32('f', 'r', 'm', 'a');
+const uint32    SCHEME_TYPE_BOX = FourCharConstToUint32('s', 'c', 'h', 'm');
+const uint32    SCHEME_INFORMATION_BOX = FourCharConstToUint32('s', 'c', 'h', 'i');
+const uint32    MUTABLE_DRM_INFORMATION = FourCharConstToUint32('m', 'd', 'r', 'i');
+const uint32    OMADRM_TRANSACTION_TRACKING_BOX = FourCharConstToUint32('o', 'd', 't', 't');
+const uint32    OMADRM_RIGHTS_OBJECT_BOX = FourCharConstToUint32('o', 'd', 'r', 'b');
+const uint32    OMADRM_KMS_BOX = FourCharConstToUint32('o', 'd', 'k', 'm');
+// Text Sample Modifier Atoms
+const uint32    TEXT_STYLE_BOX = FourCharConstToUint32('s', 't', 'y', 'l');
+const uint32    TEXT_HIGHLIGHT_BOX = FourCharConstToUint32('h', 'l', 'i', 't');
+const uint32    TEXT_HILIGHT_COLOR_BOX = FourCharConstToUint32('h', 'c', 'l', 'r');
+const uint32    TEXT_KARAOKE_BOX = FourCharConstToUint32('k', 'r', 'o', 'k');
+const uint32    TEXT_SCROLL_DELAY_BOX = FourCharConstToUint32('d', 'l', 'a', 'y');
+const uint32    TEXT_HYPER_TEXT_BOX = FourCharConstToUint32('h', 'r', 'e', 'f');
+const uint32    TEXT_OVER_RIDE_BOX = FourCharConstToUint32('t', 'b', 'o', 'x');
+const uint32    TEXT_BLINK_BOX = FourCharConstToUint32('b', 'l', 'n', 'k');
+
+
+
+
+const uint32	ITUNES_ALBUM_ATOM  = FourCharConstToUint32('©', 'a', 'l', 'b');
+const uint32	ITUNES_ARTIST1_ATOM = FourCharConstToUint32('©', 'a', 'r', 't');
+const uint32	ITUNES_ARTIST2_ATOM = FourCharConstToUint32('©', 'A', 'R', 'T');
+const uint32	ITUNES_ALBUM_ARTIST_ATOM = FourCharConstToUint32('a', 'A', 'R', 'T');
+const uint32	ITUNES_COMMENT_ATOM = FourCharConstToUint32('©', 'c', 'm', 't');
+const uint32	ITUNES_YEAR_ATOM = FourCharConstToUint32('©', 'd', 'a', 'y');
+const uint32	ITUNES_SONG_TITLE_ATOM = FourCharConstToUint32('©', 'n', 'a', 'm');
+const uint32	ITUNES_GENRE1_ATOM = FourCharConstToUint32('©', 'g', 'e', 'n');
+const uint32	ITUNES_GENRE2_ATOM = FourCharConstToUint32('g', 'n', 'r', 'e');
+const uint32	ITUNES_TRACK_NUMBER_ATOM = FourCharConstToUint32('t', 'r', 'k', 'n');
+const uint32	ITUNES_DISK_NUMBER_ATOM = FourCharConstToUint32('d', 'i', 's', 'k');
+const uint32	ITUNES_COMPOSER_ATOM = FourCharConstToUint32('©', 'w', 'r', 't');
+const uint32	ITUNES_ENCODER_TOOL_ATOM = FourCharConstToUint32('©', 't', 'o', 'o');
+const uint32    ITUNES_ENCODEDBY_ATOM = FourCharConstToUint32('@', 'e', 'n', 'c');
+const uint32	ITUNES_BPM_ATOM = FourCharConstToUint32('t', 'm', 'p', 'o');
+const uint32	ITUNES_COMPILATION_ATOM = FourCharConstToUint32('c', 'p', 'i', 'l');
+const uint32	ITUNES_ART_WORK_ATOM = FourCharConstToUint32('c', 'o', 'v', 'r');
+const uint32	ITUNES_GROUPING1_ATOM = FourCharConstToUint32('©', 'g', 'r', 'p');
+const uint32	ITUNES_GROUPING2_ATOM = FourCharConstToUint32('g', 'r', 'u', 'p');
+const uint32	ITUNES_LYRICS_ATOM = FourCharConstToUint32('©', 'l', 'y', 'r');
+const uint32	ITUNES_DESCRIPTION_ATOM = FourCharConstToUint32('d', 'e', 's', 'c');
+const uint32	ITUNES_COPYRIGHT_ATOM = FourCharConstToUint32('c', 'p', 'r', 't');
+const uint32	META_DATA_ATOM = FourCharConstToUint32('m', 'e', 't', 'a');
+const uint32	ITUNES_FREE_FORM_DATA_NAME_ATOM = FourCharConstToUint32('n', 'a', 'm', 'e');
+const uint32	ITUNES_MDIRAPPL_HDLR_PART1 = FourCharConstToUint32('m', 'd', 'i', 'r');
+const uint32	ITUNES_MDIRAPPL_HDLR_PART2 = FourCharConstToUint32('a', 'p', 'p', 'l');
+const uint32    ITUNES_ILST_ATOM = FourCharConstToUint32('i', 'l', 's', 't');
+const uint32	ITUNES_ILST_DATA_ATOM = FourCharConstToUint32('d', 'a', 't', 'a');
+const uint32	ITUNES_MEAN_ATOM = FourCharConstToUint32('m', 'e', 'a', 'n');
+const uint32	ITUNES_FREE_FORM_ATOM = FourCharConstToUint32('-', '-', '-', '-');
+const uint32    ITUNES_TRACK_SUBTITLE_ATOM = FourCharConstToUint32('@', 's', 't', '3');
+const uint32    ITUNES_CONTENT_RATING_ATOM = FourCharConstToUint32('r', 't', 'n', 'g');  // Same tag as ASSET_INFO_RATING_ATOM
+
+
+
+//For iTunes
+#define ITUNES_FREE_FORM_DATA_ATOM_TYPE_NORM "iTunNORM"
+#define ITUNES_FREE_FORM_DATA_ATOM_TYPE_TOOL "tool"
+#define ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB1 "iTunes_CDDB_1"
+#define ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB_TRACKNUMBER "iTunes_CDDB_TrackNumber"
+#define ITUNES_FREE_FORM_DATA_ATOM_TYPE_CDDB_IDS "iTunes_CDDB_IDs"
+
+
+// VARIOUS DESCRIPTOR TAGS CURRENTLY IN USE
+
+#define ES_DESCRIPTOR_TAG             0x03
+#define ES_ID_INC_TAG                 0x0E
+#define ES_ID_REF_TAG                 0x0F
+#define DECODER_CONFIG_DESCRIPTOR_TAG 0x04
+#define DECODER_SPECIFIC_INFO_TAG     0x05
+#define SL_CONFIG_DESCRIPTOR          0x06
+
+#define STREAM_TYPE_AUDIO      0x05
+#define STREAM_TYPE_VISUAL     0x04
+
+#define DEFAULT_AUTHORING_MODE 0x00000000
+
+typedef enum
+{
+    ENoFileType	  = 0x0000,
+    E3GP4		  = 0x0001,
+    E3GP5		  = 0x0002,
+    EISOM		  = 0x0010,
+    EMP41		  = 0x0020,
+    EMP42		  = 0x0040,
+    EMMP4		  = 0x0100,
+    EWMF		  = 0x0200,
+    EUNKNOWN_TYPE = 0x8000
+} FILE_TYPE_MASKS;
+
+typedef enum
+{
+    CODEC_TYPE_AMR_AUDIO = 1,
+    CODEC_TYPE_AAC_AUDIO
+
+} AUDIO_CODEC_TYPES;
+
+typedef enum
+{
+    CODEC_TYPE_MPEG4_VIDEO = 1,
+    CODEC_TYPE_BASELINE_H263_VIDEO,
+    CODEC_TYPE_MPEG4_IMAGE
+
+} VIDEO_CODEC_TYPES;
+
+typedef enum
+{
+    AMR_AUDIO   = 0xd0,
+    QCELP_MP4	= 0xE1,
+    MPEG4_AUDIO = 0x40,
+    MPEG2_AUDIO_LC = 0x67,
+    MPEG4_VIDEO = 0x20,
+    H263_VIDEO  = 0xc0,
+    AMRWB_AUDIO_3GPP = 0xFA,
+    AVC_VIDEO   = 0xFB,
+    AMR_AUDIO_3GPP = 0xFC,
+    TIMED_TEXT  = 0xFD,
+    MPEG4_SYS_OD = 0x01,
+    MPEG4_SYS_BIFS = 0x01,
+    TYPE_UNKNOWN = 0
+
+} OTI_VALUES;
+
+typedef enum
+{
+    STRING_GENRE = 0,
+    INTEGER_GENRE
+}GnreVersion;
+
+typedef struct
+{
+    OSCL_wHeapString<OsclMemAllocator> title;
+    OSCL_wHeapString<OsclMemAllocator> author;
+    OSCL_wHeapString<OsclMemAllocator> description;
+    OSCL_wHeapString<OsclMemAllocator> rating;
+    OSCL_wHeapString<OsclMemAllocator> copyRight;
+    OSCL_wHeapString<OsclMemAllocator> version;
+    OSCL_wHeapString<OsclMemAllocator> creationDate;
+} ClipInfo;
+
+typedef enum
+{
+
+    ORIGINAL_CHAR_TYPE_UNKNOWN,
+    ORIGINAL_CHAR_TYPE_UTF8,
+    ORIGINAL_CHAR_TYPE_UTF16
+
+} MP4FFParserOriginalCharEnc;
+
+
+#define JPEG	0x0000
+#define GIF		0x0001
+#define MP4_MIN_BYTES_FOR_GETTING_MOVIE_HDR_SIZE 1024
+
+#define DISABLE_REPOS_ON_CLIPS_HAVING_UNEQUAL_TFRA_ENTRY_COUNT 0
+
+#define COUNT_OF_TRUNS_PARSED_THRESHOLD 3000
+
+// when playing from a file
+#define MAX_CACHED_TABLE_ENTRIES_FILE		4096
+#define TABLE_ENTRIES_THRESHOLD_FILE            1024
+
+// when playing from a memory buffer data stream
+#define MAX_CACHED_TABLE_ENTRIES_MBDS		16384
+#define TABLE_ENTRIES_THRESHOLD_MBDS		4096
+
+#define BYTE_ORDER_MASK 0xFEFF
+#define BYTE_ORDER_MASK_SIZE 2
+#define MAX_UTF8_REPRESENTATION 4
+
+// Max limit for number of tracks in a file
+
+#define MAX_LIMIT_FOR_NUMBER_OF_TRACKS 1024
+
+#endif //ATOMDEFS_H_INCLUDED
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/include/atomutils.h b/fileformats/mp4/parser/utils/mp4recognizer/include/atomutils.h
new file mode 100644
index 0000000..74a2c49
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/include/atomutils.h
@@ -0,0 +1,218 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*********************************************************************************/
+/*     -------------------------------------------------------------------       */
+/*                            MPEG-4 AtomUtils Class                             */
+/*     -------------------------------------------------------------------       */
+/*********************************************************************************/
+/*
+    This AtomUtils Class contains sime useful methods for operating on Atoms
+*/
+
+
+#ifndef ATOMUTILS_H_INCLUDED
+#define ATOMUTILS_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDE
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef OSCL_MEM_BASIC_FUNCTIONS_H
+#include "oscl_mem_basic_functions.h"
+#endif
+
+#ifndef ATOMDEFS_H_INCLUDED
+#include "atomdefs.h"
+#endif
+
+/* CPM Related Header Files */
+#ifndef CPM_H_INCLUDED
+#include "cpm.h"
+#endif
+#ifndef PVFILE_H_INCLUDED
+#include "pvfile.h"
+#endif
+
+typedef Oscl_File* MP4_FF_FILE_REFERENCE;
+
+#define DEFAULT_ATOM_SIZE 8	//need to change when they use various size field
+#define PVMF_MP4FFPARSER_LOGDIAGNOSTICS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iDiagnosticsLogger,PVLOGMSG_INFO,m);
+#define PVMF_MP4FFPARSER_LOGMEDIASAMPELSTATEVARIABLES(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iStateVarLogger,PVLOGMSG_INFO,m);
+#define PVMF_MP4FFPARSER_LOGPARSEDINFO(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iParsedDataLogger,PVLOGMSG_INFO,m);
+#define PVMF_MP4FFPARSER_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+
+#define PV_MP4_FF_NEW(auditCB,T,params,ptr)\
+{\
+ptr = OSCL_NEW(T,params);\
+}
+
+
+#define PV_MP4_FF_DELETE(auditCB,T,ptr)\
+{\
+OSCL_DELETE(ptr);\
+}
+
+#define PV_MP4_FF_TEMPLATED_DELETE(auditCB,T,Tsimple,ptr)\
+{\
+OSCL_DELETE(ptr);\
+}
+
+
+#define PV_MP4_FF_ARRAY_MALLOC(auditCB,T,count,ptr)\
+{\
+	ptr = (T*)OSCL_MALLOC(count);\
+}
+
+
+#define PV_MP4_ARRAY_FREE(auditCB,ptr)\
+{\
+	OSCL_FREE(ptr);\
+}
+
+#define PV_MP4_FF_ARRAY_NEW(auditCB, T, count, ptr)\
+{\
+	ptr = OSCL_ARRAY_NEW(T, count);\
+}
+
+#define PV_MP4_ARRAY_DELETE(auditCB, ptr)\
+{\
+	OSCL_ARRAY_DELETE(ptr);\
+}
+
+
+class MP4_FF_FILE
+{
+    public:
+        MP4_FF_FILE()
+                : _fileSize(0)
+                , _fileServSession(NULL)
+        {
+        }
+        MP4_FF_FILE(const MP4_FF_FILE& a)
+                : _fileSize(a._fileSize)
+                , _fileServSession(a._fileServSession)
+                , _pvfile(a._pvfile)
+        {
+        }
+        bool IsOpen()
+        {
+            return _pvfile.IsOpen();
+        }
+
+        int32                 _fileSize;
+        Oscl_FileServer*      _fileServSession;
+        PVFile                _pvfile;
+};
+
+class AtomUtils
+{
+
+    public:
+        // Methods for reading in data from a file stream
+        OSCL_IMPORT_REF static bool read64(MP4_FF_FILE *fp, uint64 &data);
+        OSCL_IMPORT_REF static bool read32(MP4_FF_FILE *fp, uint32 &data);
+        OSCL_IMPORT_REF static bool read32read32(MP4_FF_FILE *fp, uint32 &data1, uint32 &data2);
+        OSCL_IMPORT_REF static bool read24(MP4_FF_FILE *fp, uint32 &data);
+        OSCL_IMPORT_REF static bool read16(MP4_FF_FILE *fp, uint16 &data);
+        OSCL_IMPORT_REF static bool read16read16(MP4_FF_FILE *fp, uint16 &data1, uint16 &data2);
+        OSCL_IMPORT_REF static bool read8(MP4_FF_FILE *fp, uint8 &data);
+        OSCL_IMPORT_REF static bool read8read8(MP4_FF_FILE *fp, uint8 &data1, uint8 &data2);
+        OSCL_IMPORT_REF static bool readNullTerminatedString(MP4_FF_FILE *fp, OSCL_wString& data);
+
+        OSCL_IMPORT_REF static bool readNullTerminatedUnicodeString(MP4_FF_FILE *fp, OSCL_wString& data);
+        OSCL_IMPORT_REF static bool readNullTerminatedAsciiString(MP4_FF_FILE *fp, OSCL_wString& data);
+
+        OSCL_IMPORT_REF static bool readString(MP4_FF_FILE *fp, uint32 inLength, MP4FFParserOriginalCharEnc &CharType, OSCL_wString& data);
+        OSCL_IMPORT_REF static bool readUTF8String(MP4_FF_FILE *fp, uint32 inLength, OSCL_wString& data);
+        OSCL_IMPORT_REF static bool readAsciiString(MP4_FF_FILE *fp, uint32 inLength, OSCL_wString& data);
+        OSCL_IMPORT_REF static bool readUnicodeString(MP4_FF_FILE *fp, uint32 inLength, OSCL_wString& data);
+
+        OSCL_IMPORT_REF static bool readByteData(MP4_FF_FILE *fp, uint32 length, uint8 *data);
+        OSCL_IMPORT_REF static bool readUnicodeData(MP4_FF_FILE *fp, uint32 length, uint16 *data);
+
+        // Method to set time value in seconds since 1904
+        OSCL_IMPORT_REF static void setTime(uint32& ulTime);
+
+        // This method is used to calculate the number of bytes needed to store the
+        // overall size of the class - the value contentSize is the size of the class
+        // NOT including the actual _sizeOfClass field (since this is a variable-length
+        // field).  This is used when determining the actual _sizeOfClass value for
+        // all the Descriptor and Command classes.
+        OSCL_IMPORT_REF static uint32 getNumberOfBytesUsedToStoreSizeOfClass(uint32 contentSize);
+
+        // Returns the atom type from parsing the input stream
+        OSCL_IMPORT_REF static void getNextAtomType(MP4_FF_FILE *fp, uint32 &size, uint32 &type);
+        OSCL_IMPORT_REF static int32 getNextAtomSize(MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static uint32 getMediaTypeFromHandlerType(uint32 handlerType);
+        OSCL_IMPORT_REF static uint32 getNumberOfBytesUsedToStoreContent(uint32 sizeOfClass);
+
+        // Peeks and returns the next Nth byte from the file
+        OSCL_IMPORT_REF static uint32 peekNextNthBytes(MP4_FF_FILE *fp, int32 n);
+        OSCL_IMPORT_REF static uint8  peekNextByte(MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static void   seekFromCurrPos(MP4_FF_FILE *fp, uint32 n);
+        OSCL_IMPORT_REF static void   seekFromStart(MP4_FF_FILE *fp, uint32 n);
+        OSCL_IMPORT_REF static void   seekToEnd(MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static void   rewindFilePointerByN(MP4_FF_FILE *fp, uint32 n);
+        OSCL_IMPORT_REF static int32  getCurrentFilePosition(MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static int32  OpenMP4File(OSCL_wString& filename, uint32 mode, MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static int32  CloseMP4File(MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static int32  Flush(MP4_FF_FILE *fp);
+        OSCL_IMPORT_REF static bool   getCurrentFileSize(MP4_FF_FILE *fp, uint32& aCurrentSize);
+
+        OSCL_IMPORT_REF static bool read32(uint8 *&buf, uint32 &data);
+        OSCL_IMPORT_REF static bool read32read32(uint8 *&buf, uint32 &data1, uint32 &data2);
+        OSCL_IMPORT_REF static bool read16(uint8 *&buf, uint16 &data);
+        OSCL_IMPORT_REF static bool read8(uint8 *&buf, uint8 &data);
+        OSCL_IMPORT_REF static bool readByteData(uint8 *&buf, uint32 length, uint8 *data);
+        OSCL_IMPORT_REF static uint32 getNextAtomType(uint8 *buf);
+        OSCL_IMPORT_REF static int32 getNextAtomSize(uint8 *buf);
+
+        // returns content length
+        OSCL_IMPORT_REF static uint32 getContentLength(MP4_FF_FILE *fp);
+        // returns the data stream cache size
+        OSCL_IMPORT_REF static uint32 getFileBufferingCapacity(MP4_FF_FILE *fp);
+        // peek to a new offset (MBDS only), read pointer does not change
+        // this is used to trigger a http request
+        OSCL_IMPORT_REF static void skipFromStart(MP4_FF_FILE *fp, uint32 n);
+        // for progressive playback seeking
+        // returns the range of available bytes in MBDS
+        // first + last byte offset inclusive
+        OSCL_IMPORT_REF static void getCurrentByteRange(MP4_FF_FILE *fp, uint32& aCurrentFirstByteOffset, uint32& aCurrentLastByteOffset);
+
+
+};
+
+#endif // ATOMUTILS_H_INCLUDED
+
+
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/include/pvmp4ffrec.h b/fileformats/mp4/parser/utils/mp4recognizer/include/pvmp4ffrec.h
new file mode 100644
index 0000000..5b09f01
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/include/pvmp4ffrec.h
@@ -0,0 +1,50 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef MP4FFFREC_H_INCLUDED
+#define MP4FFFREC_H_INCLUDED
+
+#ifndef OSCL_FILE_SERVER_H_INCLUDED
+#include "oscl_file_server.h"
+#endif
+
+#ifndef OSCL_FILE_HANDLE_H_INCLUDED
+#include "oscl_file_handle.h"
+#endif
+
+/* CPM Related Header Files */
+#ifndef CPM_H_INCLUDED
+#include "cpm.h"
+#endif
+
+class MP4FileRecognizer
+{
+
+    public:
+
+        OSCL_IMPORT_REF static bool IsMP4File(OSCL_wString& filename,
+                                              Oscl_FileServer* fileServSession = NULL);
+
+        OSCL_IMPORT_REF static bool IsMP4File(Oscl_File* filePtr);
+
+        OSCL_IMPORT_REF static bool IsMP4File(PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
+                                              Oscl_FileServer* aFileServSession = NULL,
+                                              OsclFileHandle* aHandle = NULL);
+
+};
+
+#endif
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/src/atomutils.cpp b/fileformats/mp4/parser/utils/mp4recognizer/src/atomutils.cpp
new file mode 100644
index 0000000..77e5823
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/src/atomutils.cpp
@@ -0,0 +1,1025 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*********************************************************************************/
+/*     -------------------------------------------------------------------       */
+/*                            MPEG-4 Atom Utils Class                            */
+/*     -------------------------------------------------------------------       */
+/*********************************************************************************/
+/*
+    This AtomUtils Class contains sime useful methods for operating on Atoms
+*/
+
+
+#define IMPLEMENT_AtomUtils
+#include "oscl_base.h"
+#include "oscl_int64_utils.h"
+#include "atomutils.h"
+#include "atomdefs.h"
+#include "oscl_utf8conv.h"
+
+// Read in the 64 bits byte by byte and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::read64(MP4_FF_FILE *fp, uint64 &data)
+{
+    const int32 N = 8;
+    uint8 bytes[N];
+    data = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32) fp->_pvfile.Read((void*)bytes, 1, N);
+
+    if (retVal < N)
+    {
+        return false;
+    }
+
+    uint32 low  = 0;
+    uint32 high = 0;
+
+    int32 i;
+    for (i = 0; i < N / 2; i++)
+    {
+        high = (high << 8) | bytes[i];
+    }
+    for (i = N / 2; i < N; i++)
+    {
+        low = (low << 8) | bytes[i];
+    }
+    Oscl_Int64_Utils::set_uint64(data, high, low);
+    return true;
+}
+
+
+// Read in the 32 bits byte by byte and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::read32(MP4_FF_FILE *fp, uint32 &data)
+{
+    const int32 N = 4;
+    uint8 bytes[N];
+    data = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
+
+    if (retVal < N)
+        return false;
+
+    for (int32 i = 0;i < N;i++)
+        data = (data << 8) | bytes[i];
+
+    return true;
+}
+
+// Read in the 32 bits byte by byte and take most significant byte first.
+// This is equivalent to two read32 calls.
+OSCL_EXPORT_REF bool
+AtomUtils::read32read32(MP4_FF_FILE *fp, uint32 &data1, uint32 &data2)
+{
+    const int32 N = 8;
+    uint8 bytes[N];
+    data1 = 0;
+    data2 = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
+
+    if (retVal < N)
+        return false;
+
+    int32 i;
+    for (i = 0;i < 4;i++)
+        data1 = (data1 << 8) | bytes[i];
+
+    for (i = 4;i < 8;i++)
+        data2 = (data2 << 8) | bytes[i];
+
+    return true;
+}
+
+// Read in the 24 bits byte by byte and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::read24(MP4_FF_FILE *fp, uint32 &data)
+{
+    const int32 N = 3;
+    uint8 bytes[N];
+    data = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
+
+    if (retVal < N)
+        return false;
+
+    for (int32 i = 0;i < N;i++)
+        data = (data << 8) | bytes[i];
+
+    return true;
+}
+
+// Read in the 16 bits byte by byte and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::read16(MP4_FF_FILE *fp, uint16 &data)
+{
+    const int32 N = 2;
+    uint8 bytes[N];
+    data = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
+
+    if (retVal < N)
+        return false;
+
+    for (int32 i = 0;i < N;i++)
+        data = (uint16)((data << 8) | (uint16) bytes[i]);
+
+    return true;
+}
+
+// Read in the 16 bits byte by byte and take most significant byte first
+// This is equivalent to two read16 calls
+OSCL_EXPORT_REF bool
+AtomUtils::read16read16(MP4_FF_FILE *fp, uint16 &data1, uint16 &data2)
+{
+    const int32 N = 4;
+    uint8 bytes[N];
+    data1 = 0;
+    data2 = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
+
+    if (retVal < N)
+        return false;
+
+    int32 i;
+    for (i = 0;i < 2;i++)
+        data1 = (uint16)((data1 << 8) | (uint16) bytes[i]);
+
+    for (i = 2;i < 4;i++)
+        data2 = (uint16)((data2 << 8) | (uint16) bytes[i]);
+
+    return true;
+}
+
+// Read in the 8 bit byte
+OSCL_EXPORT_REF bool
+AtomUtils::read8(MP4_FF_FILE *fp, uint8 &data)
+{
+    data = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*) & data, 1, 1));
+
+    if (retVal < 1)
+        return false;
+
+    return true;
+}
+
+// Read in the 8 bit byte
+// This is equivalent to two read8 calls
+OSCL_EXPORT_REF bool
+AtomUtils::read8read8(MP4_FF_FILE *fp, uint8 &data1, uint8 &data2)
+{
+    const int32 N = 2;
+    uint8 bytes[N];
+    data1 = 0;
+    data2 = 0;
+
+    int32 retVal = 0;
+
+    retVal = (int32)(fp->_pvfile.Read((void*)bytes, 1, N));
+
+    if (retVal < N)
+        return false;
+
+    data1 = bytes[0];
+    data2 = bytes[1];
+
+    return true;
+}
+// Read in a NULL terminated string byte by byte and take most significant byte first
+// and convert to a OSCL_wString
+OSCL_EXPORT_REF bool
+AtomUtils::readNullTerminatedString(MP4_FF_FILE *fp, OSCL_wString& data)
+{
+    const int MAX_BUFF_SIZE = 1024;
+    uint8 buf[MAX_BUFF_SIZE];
+    int32 index = 0;
+
+    if (!AtomUtils::read8(fp, buf[index]))
+        return false;
+
+    bool nextChar = (buf[index] == 0) ? false : true;
+
+    while (nextChar && (index < MAX_BUFF_SIZE))
+    {
+        index++;
+
+        if (!AtomUtils::read8(fp, buf[index]))
+            return false;
+
+        nextChar = (buf[index] == 0) ? false : true;
+    }
+    // String buffer filled - now create OSCL_wString
+
+    OSCL_TCHAR outbuf[MAX_BUFF_SIZE];
+    oscl_UTF8ToUnicode((const char *)buf, index, outbuf, MAX_BUFF_SIZE);
+    OSCL_wHeapString<OsclMemAllocator> temp(outbuf);
+
+    data = temp;
+    return true;
+}
+
+// Read in a NULL terminated UNICODE string byte by byte and take most significant byte first
+// and convert to a OSCL_wString
+OSCL_EXPORT_REF bool
+AtomUtils::readNullTerminatedUnicodeString(MP4_FF_FILE *fp, OSCL_wString& data)
+{
+    const int MAX_BUFF_SIZE = 1024;
+    oscl_wchar buf[MAX_BUFF_SIZE];
+    int32 index = 0;
+
+    // Need to be careful of the byte-ordering when creating the oscl_wchar array
+    uint8 firstbyte;
+    uint8 secondbyte;
+
+    if (!AtomUtils::read8read8(fp, firstbyte, secondbyte))
+        return false;
+
+    // Allow the OS to do the bit shifting to get the correct byte ordering
+    // for the CHAR value
+    oscl_wchar *wptr = &buf[index];
+
+    *wptr = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+
+    bool nextChar = (buf[index] == 0) ? false : true;
+    index += 1;
+
+    while (nextChar && (index < (int32)(MAX_BUFF_SIZE)))
+    {
+        if (!AtomUtils::read8read8(fp, firstbyte, secondbyte))
+            return false;
+
+        // Allow the OS to do the bit shifting to get the correct byte ordering
+        // for the CHAR value
+        wptr  = &buf[index];
+        *wptr = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+        nextChar = (buf[index] == 0) ? false : true;
+        index++;
+    }
+
+    // String (oscl_wchar) buffer filled - now create OSCL_STRING
+
+    // OSCL_STRING is a oscl_wchar string so no conversion needed
+    OSCL_wHeapString<OsclMemAllocator> temp((const OSCL_TCHAR *)buf, index - 1);
+    data = temp;
+
+    return true;
+}
+
+// Read in a NULL terminated ascii (8-bit char) string byte by byte and take most
+// significant byte first and convert to a OSCL_wString
+OSCL_EXPORT_REF bool AtomUtils::readNullTerminatedAsciiString(MP4_FF_FILE *fp, OSCL_wString& data)
+{
+    return readNullTerminatedString(fp, data);
+}
+
+// Read in a first N Characters of string byte by byte
+OSCL_EXPORT_REF bool
+AtomUtils::readByteData(MP4_FF_FILE *fp, uint32 length, uint8 *data)
+{
+    uint32 bytesRead = 0;
+
+    if (length > 0)
+    {
+        bytesRead = fp->_pvfile.Read(data, 1, length);
+    }
+    if (bytesRead < (uint32)length)
+    {
+        // read byte data failed
+        return false;
+    }
+    return true;
+}
+
+// Read in byte data and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::readUnicodeData(MP4_FF_FILE *fp, uint32 length, uint16 *data)
+{
+    uint32 wordsRead;
+
+    if (length == 0)
+        return false;
+
+    wordsRead = (int32)(fp->_pvfile.Read((void*)data, 2, length));
+
+    // read byte data failed
+    if (wordsRead < (uint32)length)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+OSCL_EXPORT_REF bool
+AtomUtils::readString(MP4_FF_FILE *fp, uint32 inLength, MP4FFParserOriginalCharEnc &CharType, OSCL_wString& data)
+{
+    uint32 temp = AtomUtils::peekNextNthBytes(fp, 1);
+    uint16 byteOrderMask = (uint16)((temp >> 16) & 0xFFFF);
+
+    if (byteOrderMask == BYTE_ORDER_MASK)
+    {
+        // UTF16
+        CharType = ORIGINAL_CHAR_TYPE_UTF16;
+        if (!AtomUtils::read16(fp, byteOrderMask))
+        {
+            return false;
+        }
+
+        if (inLength < BYTE_ORDER_MASK_SIZE)
+        {
+            return false;
+        }
+
+        uint32 delta = (inLength - BYTE_ORDER_MASK_SIZE);
+
+        int32 filePos = AtomUtils::getCurrentFilePosition(fp);
+
+        if (!AtomUtils::readUnicodeString(fp, delta, data))
+        {
+            return false;
+        }
+        int32 newfilePos = AtomUtils::getCurrentFilePosition(fp);
+        if (newfilePos != (int32)(filePos + delta))
+        {
+            AtomUtils::seekFromStart(fp, filePos + delta);
+        }
+    }
+    else
+    {
+        // UTF8 or Ascii
+        // Check to see if the string is actually null-terminated
+        CharType = ORIGINAL_CHAR_TYPE_UTF8;
+
+        uint32 delta = inLength;
+
+        int32 filePos = AtomUtils::getCurrentFilePosition(fp);
+
+        if (!AtomUtils::readUTF8String(fp, delta, data))
+        {
+            return false;
+        }
+        int32 newfilePos = AtomUtils::getCurrentFilePosition(fp);
+        if (newfilePos != (int32)(filePos + delta))
+        {
+            AtomUtils::seekFromStart(fp, filePos + delta);
+        }
+    }
+    return true;
+}
+
+OSCL_EXPORT_REF bool
+AtomUtils::readUTF8String(MP4_FF_FILE *fp, uint32 inLength, OSCL_wString& data)
+{
+    const int MAX_BUFF_SIZE = 1024;
+    uint8 buf[MAX_BUFF_SIZE];
+
+    uint32 max_length = (uint32)MAX_BUFF_SIZE;
+    if (inLength > max_length)
+    {
+        inLength = max_length;
+    }
+
+    uint32 index = 0;
+    bool nextChar = true;
+
+    while (nextChar && (index < inLength))
+    {
+
+        if (!AtomUtils::read8(fp, buf[index]))
+            return false;
+
+        nextChar = (buf[index] == 0) ? false : true;
+
+        index++;
+
+    }
+    // String buffer filled - now create ZString
+
+    OSCL_TCHAR outbuf[MAX_BUFF_SIZE];
+    oscl_UTF8ToUnicode((const char *)buf, (int32)index, outbuf, MAX_BUFF_SIZE);
+    OSCL_wHeapString<OsclMemAllocator> temp(outbuf);
+
+    data = temp;
+    return true;
+}
+
+OSCL_EXPORT_REF bool
+AtomUtils::readAsciiString(MP4_FF_FILE *fp, uint32 inLength, OSCL_wString& data)
+{
+    return (AtomUtils::readUTF8String(fp, inLength, data));
+}
+
+OSCL_EXPORT_REF bool
+AtomUtils::readUnicodeString(MP4_FF_FILE *fp, uint32 inLength, OSCL_wString& data)
+{
+    // make inLength an even.
+    inLength -= (inLength & 1);
+
+    if (inLength == 0)
+    {
+        data = NULL;
+        return true;
+    }
+
+    const int MAX_BUFF_SIZE = 1024;
+    oscl_wchar buf[MAX_BUFF_SIZE];
+    if (inLength > MAX_BUFF_SIZE * sizeof(oscl_wchar))
+    {
+        inLength = MAX_BUFF_SIZE;
+    }
+
+    uint32 wlength = inLength / 2;
+
+    uint32 index = 0;
+
+    // Need to be careful of the byte-ordering when creating the oscl_wchar array
+    uint8 firstbyte;
+    uint8 secondbyte;
+
+    oscl_wchar *wptr;
+
+    bool nextChar = true;
+
+    while (nextChar && (index < wlength))
+    {
+        if (!AtomUtils::read8read8(fp, firstbyte, secondbyte))
+            return false;
+
+        // Allow the OS to do the bit shifting to get the correct byte ordering
+        // for the CHAR value
+        wptr  = &buf[index];
+        *wptr = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+        nextChar = (buf[index] == 0) ? false : true;
+        index++;
+    }
+
+    // if it is a NULL terminated string, don't count the last NULL as length.
+    if (nextChar == false)
+    {
+        index --;
+    }
+
+    // OSCL_STRING is a oscl_wchar string so no conversion needed
+    OSCL_wHeapString<OsclMemAllocator> temp((const OSCL_TCHAR *)buf, index);
+    data = temp;
+
+    return true;
+}
+
+OSCL_EXPORT_REF uint32
+AtomUtils::getNumberOfBytesUsedToStoreSizeOfClass(uint32 contentSize)
+{
+    // The actual _sizeOfClass value includes the size of the class's contents PLUS
+    // the number of bytes needed to store the _sizeOfClass field. The parameter
+    // contentSize represents the number of bytes needed to store ONLY the members
+    // of the class NOT including the _sizeOfClass field.
+    if (contentSize <= 0x7e) return 1; // _sizeOfClass field can be rendered in 1 byte (7 LS bits)
+    else if (contentSize <= 0x3ffd) return 2; // _sizeOfClass field can be rendered in 2 bytes (7 LS bits each)
+    else if (contentSize <= 0x1ffffc) return 3; // _sizeOfClass field can be rendered in 3 bytes (7 LS bits each)
+    else if (contentSize <= 0xfffffffb) return 4; // _sizeOfClass field can be rendered in 4 bytes (7 LS bits each)
+    else return 0; // ERROR condition
+}
+
+
+// Returns the atom type from parsing the input stream
+OSCL_EXPORT_REF void
+AtomUtils::getNextAtomType(MP4_FF_FILE *fp, uint32 &size, uint32 &type)
+{
+    size = 0;
+    type = UNKNOWN_ATOM;
+
+    int32 filePointer;
+    filePointer = AtomUtils::getCurrentFilePosition(fp);
+
+    if (filePointer > (fp->_fileSize - 8))
+    {
+        return;
+    }
+
+    if (!AtomUtils::read32read32(fp, size, type))
+    {
+        size = 0;
+        type = UNKNOWN_ATOM;
+        return;
+    }
+
+    if (type == MOVIE_ATOM ||
+            type == MOVIE_HEADER_ATOM ||
+            type == TRACK_ATOM ||
+            type == TRACK_HEADER_ATOM ||
+            type == TRACK_REFERENCE_ATOM ||
+            type == MEDIA_ATOM ||
+            type == EDIT_ATOM ||
+            type == EDIT_LIST_ATOM ||
+            type == MEDIA_HEADER_ATOM ||
+            type == HANDLER_ATOM ||
+            type == MEDIA_INFORMATION_ATOM ||
+            type == VIDEO_MEDIA_HEADER_ATOM ||
+            type == SOUND_MEDIA_HEADER_ATOM ||
+            type == HINT_MEDIA_HEADER_ATOM ||
+            type == MPEG4_MEDIA_HEADER_ATOM ||
+            type == NULL_MEDIA_HEADER_ATOM ||
+            type == DATA_INFORMATION_ATOM ||
+            type == DATA_REFERENCE_ATOM ||
+            type == DATA_ENTRY_URL_ATOM ||
+            type == DATA_ENTRY_URN_ATOM ||
+            type == SAMPLE_TABLE_ATOM ||
+            type == TIME_TO_SAMPLE_ATOM ||
+            type == COMPOSITION_OFFSET_ATOM ||
+            type == SAMPLE_DESCRIPTION_ATOM ||
+            type == ESD_ATOM ||
+            type == SAMPLE_SIZE_ATOM ||
+            type == SAMPLE_TO_CHUNK_ATOM ||
+            type == CHUNK_OFFSET_ATOM ||
+            type == SYNC_SAMPLE_ATOM ||
+            type == SHADOW_SYNC_SAMPLE_ATOM ||
+            type == DEGRADATION_PRIORITY_ATOM ||
+            type == OBJECT_DESCRIPTOR_ATOM ||
+            type == MEDIA_DATA_ATOM ||
+            type == FREE_SPACE_ATOM ||
+            type == SKIP_ATOM ||
+            type == USER_DATA_ATOM ||
+            type == FILE_TYPE_ATOM ||
+            type == PVUSER_DATA_ATOM ||
+            type == PV_CONTENT_TYPE_ATOM ||
+            type == AMR_SAMPLE_ENTRY_ATOM ||
+            type == AMRWB_SAMPLE_ENTRY_ATOM ||
+            type == H263_SAMPLE_ENTRY_ATOM ||
+            type == AUDIO_SAMPLE_ENTRY ||
+            type == VIDEO_SAMPLE_ENTRY ||
+            type == MPEG_SAMPLE_ENTRY ||
+            type == UUID_ATOM ||
+            type == AMR_SPECIFIC_ATOM ||
+            type == H263_SPECIFIC_ATOM ||
+
+
+            type == COPYRIGHT_ATOM ||
+            type == FONT_TABLE_ATOM ||
+            type == HINT_TRACK_REFERENCE_TYPE ||
+            type == DPND_TRACK_REFERENCE_TYPE ||
+            type == IPIR_TRACK_REFERENCE_TYPE ||
+            type == MPOD_TRACK_REFERENCE_TYPE ||
+            type == SYNC_TRACK_REFERENCE_TYPE ||
+            type == ASSET_INFO_TITLE_ATOM ||
+            type == ASSET_INFO_DESCP_ATOM ||
+            type == ASSET_INFO_PERF_ATOM ||
+            type == ASSET_INFO_AUTHOR_ATOM ||
+            type == ASSET_INFO_GENRE_ATOM ||
+            type == ASSET_INFO_RATING_ATOM ||
+            type == ASSET_INFO_CLSF_ATOM ||
+            type == ASSET_INFO_KEYWORD_ATOM ||
+            type == ASSET_INFO_LOCATION_ATOM ||
+            type == ASSET_INFO_ALBUM_ATOM ||
+            type == ASSET_INFO_YRRC_ATOM ||
+            type == TEXT_SAMPLE_ENTRY ||
+            type == AVC_SAMPLE_ENTRY ||
+            type == AVC_CONFIGURATION_BOX ||
+            type == MPEG4_BITRATE_BOX ||
+            type == MPEG4_EXTENSION_DESCRIPTORS_BOX ||
+            type == ENCRYPTED_AUDIO_SAMPLE_ENTRY ||
+            type == ENCRYPTED_VIDEO_SAMPLE_ENTRY ||
+            type == PROTECTION_SCHEME_INFO_BOX ||
+            type == ORIGINAL_FORMAT_BOX ||
+            type == SCHEME_TYPE_BOX ||
+            type == SCHEME_INFORMATION_BOX ||
+            type == MUTABLE_DRM_INFORMATION ||
+            type == OMADRM_TRANSACTION_TRACKING_BOX ||
+            type == OMADRM_RIGHTS_OBJECT_BOX ||
+            type == OMADRM_KMS_BOX ||
+
+
+            type == MOVIE_EXTENDS_ATOM ||
+            type == MOVIE_EXTENDS_HEADER_ATOM ||
+            type == TRACK_EXTENDS_ATOM ||
+            type == MOVIE_FRAGMENT_ATOM ||
+            type == MOVIE_FRAGMENT_HEADER_ATOM ||
+            type == TRACK_FRAGMENT_ATOM ||
+            type == TRACK_FRAGMENT_HEADER_ATOM ||
+            type == TRACK_FRAGMENT_RUN_ATOM ||
+            type == MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM ||
+            type == MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM ||
+            type == TRACK_FRAGMENT_RANDOM_ACCESS_ATOM ||
+
+            type == META_DATA_ATOM ||
+            type == ITUNES_ILST_ATOM ||
+            type == ITUNES_ILST_DATA_ATOM ||
+            type == ITUNES_SONG_TITLE_ATOM ||
+            type == ITUNES_TRACK_SUBTITLE_ATOM ||
+            type == ITUNES_COMPILATION_ATOM ||
+            type == ITUNES_ENCODER_TOOL_ATOM ||
+            type == ITUNES_ENCODEDBY_ATOM ||
+            type == ITUNES_FREE_FORM_ATOM ||
+            type == ITUNES_ALBUM_ARTIST_ATOM ||
+            type == ITUNES_COMPOSER_ATOM ||
+            type == ITUNES_ALBUM_ATOM ||
+            type == ITUNES_GROUPING1_ATOM ||
+            type == ITUNES_GROUPING2_ATOM ||
+            type == ITUNES_GENRE1_ATOM ||
+            type == ITUNES_GENRE2_ATOM ||
+            type == ITUNES_TRACK_NUMBER_ATOM ||
+            type == ITUNES_DISK_NUMBER_ATOM ||
+            type == ITUNES_YEAR_ATOM ||
+            type == ITUNES_COMMENT_ATOM ||
+            type == ITUNES_LYRICS_ATOM  ||
+            type == ITUNES_ART_WORK_ATOM ||
+            type == ITUNES_BPM_ATOM ||
+            type == ITUNES_MEAN_ATOM ||
+            type == ITUNES_FREE_FORM_DATA_NAME_ATOM ||
+            type == ITUNES_COPYRIGHT_ATOM ||
+            type == ITUNES_DESCRIPTION_ATOM	||
+            type == ITUNES_CONTENT_RATING_ATOM ||
+            type == ITUNES_ARTIST1_ATOM ||
+            type == ITUNES_ARTIST2_ATOM ||
+
+
+
+            type == PIXELASPECTRATIO_BOX)
+    {
+        return;
+    }
+    else
+    {
+        type = UNKNOWN_ATOM;
+    }
+    return;
+}
+
+OSCL_EXPORT_REF uint32
+AtomUtils::getMediaTypeFromHandlerType(uint32 handlerType)
+{
+    if (
+        handlerType == MEDIA_TYPE_AUDIO ||
+        handlerType == MEDIA_TYPE_VISUAL ||
+        handlerType == MEDIA_TYPE_HINT ||
+        handlerType == MEDIA_TYPE_OBJECT_DESCRIPTOR ||
+        handlerType == MEDIA_TYPE_CLOCK_REFERENCE ||
+        handlerType == MEDIA_TYPE_SCENE_DESCRIPTION ||
+        handlerType == MEDIA_TYPE_MPEG7 ||
+        handlerType == MEDIA_TYPE_OBJECT_CONTENT_INFO ||
+        handlerType == MEDIA_TYPE_IPMP ||
+        handlerType == MEDIA_TYPE_MPEG_J ||
+        handlerType == MEDIA_TYPE_TEXT
+    )
+    {
+        return handlerType;
+    }
+    else
+    {
+        return MEDIA_TYPE_UNKNOWN;
+    }
+}
+
+OSCL_EXPORT_REF uint32
+AtomUtils::getNumberOfBytesUsedToStoreContent(uint32 sizeOfClass)
+{
+    // The content in a descriptor class is stored immediately after the descriptor tag
+    if (sizeOfClass <= 0x7f) return sizeOfClass - 2; // _sizeOfClass field is 1 byte (7 LS bits)
+    else if (sizeOfClass <= 0x3fff) return sizeOfClass - 3; // _sizeOfClass is 2 bytes (7 LS bits each)
+    else if (sizeOfClass <= 0x1fffff) return sizeOfClass - 4; // _sizeOfClass is 3 bytes (7 LS bits each)
+    else if (sizeOfClass <= 0x0fffffff) return sizeOfClass - 5; // _sizeOfClass is 4 bytes (7 LS bits each)
+    else return 0; // ERROR condition
+}
+
+OSCL_EXPORT_REF int32 AtomUtils::getNextAtomSize(MP4_FF_FILE *fp)
+{
+    uint32 size;
+    AtomUtils::read32(fp, size);
+
+    AtomUtils::rewindFilePointerByN(fp, 4);
+    return size;
+}
+
+// Peeks and returns the next Nth tag (32 bits) from the file
+OSCL_EXPORT_REF uint32 AtomUtils::peekNextNthBytes(MP4_FF_FILE *fp, int32 n)
+{
+    uint32 tag = 0;
+    for (int32 i = 0; i < n; i++)
+    {
+        AtomUtils::read32(fp, tag);
+    }
+    AtomUtils::rewindFilePointerByN(fp, (4*n));
+    return tag;
+}
+
+// Peeks and returns the next Nth bytes (8 bits) from the file
+OSCL_EXPORT_REF uint8 AtomUtils::peekNextByte(MP4_FF_FILE *fp)
+{
+    uint8 tag = 0;
+    AtomUtils::read8(fp, tag);
+    AtomUtils::rewindFilePointerByN(fp, 1);
+    return tag;
+}
+
+OSCL_EXPORT_REF void AtomUtils::seekFromCurrPos(MP4_FF_FILE *fp, uint32 n)
+{
+    fp->_pvfile.Seek(n, Oscl_File::SEEKCUR);
+}
+
+OSCL_EXPORT_REF void AtomUtils::seekFromStart(MP4_FF_FILE *fp, uint32 n)
+{
+    fp->_pvfile.Seek(n, Oscl_File::SEEKSET);
+}
+
+OSCL_EXPORT_REF void AtomUtils::seekToEnd(MP4_FF_FILE *fp)
+{
+    fp->_pvfile.Seek(0, Oscl_File::SEEKEND);
+}
+
+OSCL_EXPORT_REF void AtomUtils::rewindFilePointerByN(MP4_FF_FILE *fp, uint32 n)
+{
+    fp->_pvfile.Seek((-1 * (int32) n), Oscl_File::SEEKCUR);
+}
+
+OSCL_EXPORT_REF int32 AtomUtils::getCurrentFilePosition(MP4_FF_FILE *fp)
+{
+    return (fp->_pvfile.Tell());
+}
+
+
+OSCL_EXPORT_REF int32 AtomUtils::OpenMP4File(OSCL_wString& filename,
+        uint32 mode,
+        MP4_FF_FILE *fp)
+{
+    OSCL_UNUSED_ARG(mode);
+    if (fp != NULL)
+    {
+        return (fp->_pvfile.Open(filename.get_cstr(),
+                                 Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
+                                 *(fp->_fileServSession)));
+    }
+    return -1;
+}
+
+OSCL_EXPORT_REF int32  AtomUtils::CloseMP4File(MP4_FF_FILE *fp)
+{
+    if (fp != NULL)
+    {
+        return (fp->_pvfile.Close());
+    }
+    return -1;
+}
+
+OSCL_EXPORT_REF int32  AtomUtils::Flush(MP4_FF_FILE *fp)
+{
+    if (fp != NULL)
+    {
+        return (fp->_pvfile.Flush());
+    }
+    return -1;
+}
+
+OSCL_EXPORT_REF bool AtomUtils::getCurrentFileSize(MP4_FF_FILE *fp, uint32& aCurrentSize)
+{
+    if (fp != NULL)
+    {
+        aCurrentSize = 0;
+        uint32 aRemBytes = 0;
+        if (fp->_pvfile.GetRemainingBytes(aRemBytes))
+        {
+            uint32 currPos = (uint32)(fp->_pvfile.Tell());
+            aCurrentSize = currPos + aRemBytes;
+            fp->_fileSize = aCurrentSize;
+            return true;
+        }
+    }
+    return false;
+}
+
+OSCL_EXPORT_REF bool
+AtomUtils::read32(uint8 *&buf, uint32 &data)
+{
+    const int32 N = 4;
+    data = 0;
+
+    for (int32 i = 0;i < N;i++)
+        data = (data << 8) | buf[i];
+
+    buf += N;
+    return true;
+}
+
+// Read in the 32 bits byte by byte and take most significant byte first.
+// This is equivalent to two read32 calls.
+OSCL_EXPORT_REF bool
+AtomUtils::read32read32(uint8 *&buf, uint32 &data1, uint32 &data2)
+{
+    const int32 N = 8;
+    data1 = 0;
+    data2 = 0;
+
+    int32 i;
+    for (i = 0;i < 4;i++)
+        data1 = (data1 << 8) | buf[i];
+
+    for (i = 4;i < 8;i++)
+        data2 = (data2 << 8) | buf[i];
+
+    buf += N;
+    return true;
+}
+
+// Read in the 16 bits byte by byte and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::read16(uint8 *&buf, uint16 &data)
+{
+    const int32 N = 2;
+    data = 0;
+
+    for (int32 i = 0;i < N;i++)
+        data = (uint16)((data << 8) | (uint16) buf[i]);
+
+    buf += N;
+    return true;
+}
+
+// Read in the 8 bit byte
+OSCL_EXPORT_REF bool
+AtomUtils::read8(uint8 *&buf, uint8 &data)
+{
+    data = 0;
+    data = *buf;
+    buf++;
+    return true;
+}
+
+// Read in byte data and take most significant byte first
+OSCL_EXPORT_REF bool
+AtomUtils::readByteData(uint8 *&buf, uint32 length, uint8 *data)
+{
+    oscl_memcpy(data, buf, length);
+
+    buf += length;
+    return true;
+}
+
+OSCL_EXPORT_REF uint32
+AtomUtils::getNextAtomType(uint8 *buf)
+{
+    uint32 size;
+    uint32 type;
+    if (!AtomUtils::read32read32(buf, size, type))
+    {
+        return UNKNOWN_ATOM;
+    }
+
+    // Rewinding the stream back to atom start
+    buf -= 8;
+
+    if (type == MOVIE_ATOM ||
+            type == MOVIE_HEADER_ATOM ||
+            type == TRACK_ATOM ||
+            type == TRACK_HEADER_ATOM ||
+            type == TRACK_REFERENCE_ATOM ||
+            type == MEDIA_ATOM ||
+            type == EDIT_ATOM ||
+            type == EDIT_LIST_ATOM ||
+            type == MEDIA_HEADER_ATOM ||
+            type == HANDLER_ATOM ||
+            type == MEDIA_INFORMATION_ATOM ||
+            type == VIDEO_MEDIA_HEADER_ATOM ||
+            type == SOUND_MEDIA_HEADER_ATOM ||
+            type == HINT_MEDIA_HEADER_ATOM ||
+            type == MPEG4_MEDIA_HEADER_ATOM ||
+            type == NULL_MEDIA_HEADER_ATOM ||
+            type == DATA_INFORMATION_ATOM ||
+            type == DATA_REFERENCE_ATOM ||
+            type == DATA_ENTRY_URL_ATOM ||
+            type == DATA_ENTRY_URN_ATOM ||
+            type == SAMPLE_TABLE_ATOM ||
+            type == TIME_TO_SAMPLE_ATOM ||
+            type == COMPOSITION_OFFSET_ATOM ||
+            type == SAMPLE_DESCRIPTION_ATOM ||
+            type == ESD_ATOM ||
+            type == SAMPLE_SIZE_ATOM ||
+            type == SAMPLE_TO_CHUNK_ATOM ||
+            type == CHUNK_OFFSET_ATOM ||
+            type == SYNC_SAMPLE_ATOM ||
+            type == SHADOW_SYNC_SAMPLE_ATOM ||
+            type == DEGRADATION_PRIORITY_ATOM ||
+            type == OBJECT_DESCRIPTOR_ATOM ||
+            type == MEDIA_DATA_ATOM ||
+            type == FREE_SPACE_ATOM ||
+            type == SKIP_ATOM ||
+            type == USER_DATA_ATOM ||
+            type == FILE_TYPE_ATOM ||
+            type == PVUSER_DATA_ATOM ||
+            type == PVUSER_DATA_ATOM ||
+            type == AMR_SAMPLE_ENTRY_ATOM ||
+            type == AMRWB_SAMPLE_ENTRY_ATOM ||
+            type == H263_SAMPLE_ENTRY_ATOM ||
+            type == AUDIO_SAMPLE_ENTRY ||
+            type == VIDEO_SAMPLE_ENTRY ||
+            type == MPEG_SAMPLE_ENTRY ||
+            type == UUID_ATOM ||
+            type == AMR_SPECIFIC_ATOM ||
+            type == H263_SPECIFIC_ATOM ||
+            type == COPYRIGHT_ATOM ||
+            type == TEXT_SAMPLE_ENTRY ||
+            type == FONT_TABLE_ATOM ||
+            type == TEXT_STYLE_BOX ||
+            type == TEXT_HIGHLIGHT_BOX ||
+            type == TEXT_HILIGHT_COLOR_BOX ||
+            type == TEXT_KARAOKE_BOX ||
+            type == TEXT_SCROLL_DELAY_BOX ||
+            type == TEXT_HYPER_TEXT_BOX ||
+            type == TEXT_OVER_RIDE_BOX ||
+            type == TEXT_BLINK_BOX ||
+            type == HINT_TRACK_REFERENCE_TYPE ||
+            type == DPND_TRACK_REFERENCE_TYPE ||
+            type == IPIR_TRACK_REFERENCE_TYPE ||
+            type == MPOD_TRACK_REFERENCE_TYPE ||
+            type == SYNC_TRACK_REFERENCE_TYPE ||
+            type == ASSET_INFO_TITLE_ATOM ||
+            type == ASSET_INFO_DESCP_ATOM ||
+            type == ASSET_INFO_PERF_ATOM ||
+            type == ASSET_INFO_AUTHOR_ATOM ||
+            type == ASSET_INFO_GENRE_ATOM ||
+            type == ASSET_INFO_RATING_ATOM ||
+            type == ASSET_INFO_CLSF_ATOM ||
+            type == ASSET_INFO_KEYWORD_ATOM ||
+            type == ASSET_INFO_LOCATION_ATOM ||
+            type == ASSET_INFO_ALBUM_ATOM ||
+            type == ASSET_INFO_YRRC_ATOM)
+    {
+        return type;
+    }
+    else
+    {
+        return UNKNOWN_ATOM; // ERROR condition
+    }
+}
+
+OSCL_EXPORT_REF int32 AtomUtils::getNextAtomSize(uint8 *buf)
+{
+    uint32 size;
+    AtomUtils::read32(buf, size);
+
+    return size;
+}
+
+
+OSCL_EXPORT_REF uint32 AtomUtils::getContentLength(MP4_FF_FILE *fp)
+{
+    // this returns the content length if known
+    return fp->_pvfile.GetContentLength();
+}
+
+
+OSCL_EXPORT_REF uint32 AtomUtils::getFileBufferingCapacity(MP4_FF_FILE *fp)
+{
+    // this returns the data stream cache size
+    return fp->_pvfile.GetFileBufferingCapacity();
+}
+
+
+OSCL_EXPORT_REF void AtomUtils::skipFromStart(MP4_FF_FILE *fp, uint32 n)
+{
+    fp->_pvfile.Skip(n, Oscl_File::SEEKSET);
+}
+
+
+OSCL_EXPORT_REF void AtomUtils::getCurrentByteRange(MP4_FF_FILE *fp, uint32& aCurrentFirstByteOffset, uint32& aCurrentLastByteOffset)
+{
+    // this returns the byte range in the data stream cache
+    // first and last offset inclusive
+    fp->_pvfile.GetCurrentByteRange(aCurrentFirstByteOffset, aCurrentLastByteOffset);
+}
+
+
+
diff --git a/fileformats/mp4/parser/utils/mp4recognizer/src/pvmp4ffrec.cpp b/fileformats/mp4/parser/utils/mp4recognizer/src/pvmp4ffrec.cpp
new file mode 100644
index 0000000..008fcbf
--- /dev/null
+++ b/fileformats/mp4/parser/utils/mp4recognizer/src/pvmp4ffrec.cpp
@@ -0,0 +1,193 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "atomutils.h"
+#include "atomdefs.h"
+
+#include "pvmp4ffrec.h"
+
+// Use default DLL entry point for Symbian
+#include "oscl_dll.h"
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+OSCL_EXPORT_REF bool MP4FileRecognizer::IsMP4File(OSCL_wString& filename,
+        Oscl_FileServer* fileServSession)
+{
+    bool oReturn = false;
+    MP4_FF_FILE fileStruct;
+    MP4_FF_FILE *fp = &fileStruct;
+
+    fp->_fileServSession = fileServSession;
+
+    if (AtomUtils::OpenMP4File(filename,
+                               Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
+                               fp) != 0)
+    {
+        return (oReturn);
+    }
+
+    int32 fileSize;
+    int32 filePointer;
+    filePointer = AtomUtils::getCurrentFilePosition(fp);
+    AtomUtils::seekToEnd(fp);
+    fileSize = AtomUtils::getCurrentFilePosition(fp);
+    AtomUtils::seekFromStart(fp, filePointer);
+    fp->_fileSize = fileSize;
+
+    int32 fpos = filePointer;
+
+    while (fpos < fileSize)
+    {
+        uint32 atomType = UNKNOWN_ATOM;
+        uint32 atomSize = 0;
+
+        AtomUtils::getNextAtomType(fp, atomSize, atomType);
+
+        if (atomType != UNKNOWN_ATOM)
+        {
+            oReturn = true;
+            break;
+        }
+        else
+        {
+            if (atomSize < DEFAULT_ATOM_SIZE)
+            {
+                break;
+            }
+            if (fileSize < (int32)atomSize)
+            {
+                break;
+            }
+            atomSize -= DEFAULT_ATOM_SIZE;
+            AtomUtils::seekFromCurrPos(fp, atomSize);
+            fpos = AtomUtils::getCurrentFilePosition(fp);
+        }
+    }
+
+    AtomUtils::CloseMP4File(fp);
+    return (oReturn);
+}
+
+
+OSCL_EXPORT_REF bool MP4FileRecognizer::IsMP4File(MP4_FF_FILE_REFERENCE filePtr)
+{
+    bool oReturn = false;
+    MP4_FF_FILE fileStruct;
+    MP4_FF_FILE *fp = &fileStruct;
+
+    fp->_pvfile.SetFilePtr(filePtr);
+
+    int32 fileSize;
+    int32 filePointer;
+    AtomUtils::seekFromStart(fp, 0);
+    filePointer = AtomUtils::getCurrentFilePosition(fp);
+    AtomUtils::seekToEnd(fp);
+    fileSize = AtomUtils::getCurrentFilePosition(fp);
+    AtomUtils::seekFromStart(fp, filePointer);
+    fp->_fileSize = fileSize;
+
+    int32 fpos = filePointer;
+
+    while (fpos < fileSize)
+    {
+        uint32 atomType = UNKNOWN_ATOM;
+        uint32 atomSize = 0;
+
+        AtomUtils::getNextAtomType(fp, atomSize, atomType);
+
+        if (atomType != UNKNOWN_ATOM)
+        {
+            oReturn = true;
+            break;
+        }
+        else
+        {
+            if (atomSize < DEFAULT_ATOM_SIZE)
+            {
+                break;
+            }
+            if (fileSize < (int32)atomSize)
+            {
+                break;
+            }
+            atomSize -= DEFAULT_ATOM_SIZE;
+            AtomUtils::seekFromCurrPos(fp, atomSize);
+            fpos = AtomUtils::getCurrentFilePosition(fp);
+        }
+    }
+
+    return (oReturn);
+}
+
+OSCL_EXPORT_REF bool MP4FileRecognizer::IsMP4File(PVMFCPMPluginAccessInterfaceFactory* aCPMAccessFactory,
+        Oscl_FileServer* aFileServSession,
+        OsclFileHandle* aHandle)
+{
+    bool oReturn = false;
+
+    /* use a dummy string for file name */
+    OSCL_wHeapString<OsclMemAllocator> filename;
+
+    MP4_FF_FILE fileStruct;
+    MP4_FF_FILE *fp = &fileStruct;
+    fp->_fileServSession = aFileServSession;
+    fp->_pvfile.SetCPM(aCPMAccessFactory);
+    fp->_pvfile.SetFileHandle(aHandle);
+
+    if (AtomUtils::OpenMP4File(filename,
+                               Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
+                               fp) != 0)
+    {
+        return oReturn;
+    }
+
+    uint32 fileSize;
+    AtomUtils::getCurrentFileSize(fp, fileSize);
+    fp->_fileSize = (int32)fileSize;
+    int32 fpos = AtomUtils::getCurrentFilePosition(fp);
+
+    while (fpos < (int32)fileSize)
+    {
+        uint32 atomType = UNKNOWN_ATOM;
+        uint32 atomSize = 0;
+
+        AtomUtils::getNextAtomType(fp, atomSize, atomType);
+
+        if (atomType != UNKNOWN_ATOM)
+        {
+            oReturn = true;
+            break;
+        }
+        else
+        {
+            if (atomSize < DEFAULT_ATOM_SIZE)
+            {
+                break;
+            }
+            if (fileSize < atomSize)
+            {
+                break;
+            }
+            atomSize -= DEFAULT_ATOM_SIZE;
+            AtomUtils::seekFromCurrPos(fp, atomSize);
+            fpos = AtomUtils::getCurrentFilePosition(fp);
+        }
+    }
+
+    AtomUtils::CloseMP4File(fp);
+    return (oReturn);
+}
diff --git a/fileformats/rawaac/parser/Android.mk b/fileformats/rawaac/parser/Android.mk
index 188a8a4..9b87473 100644
--- a/fileformats/rawaac/parser/Android.mk
+++ b/fileformats/rawaac/parser/Android.mk
@@ -2,26 +2,27 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/aacfileparser.cpp
-
+ 	src/aacfileparser.cpp
 
 
 LOCAL_MODULE := libpvaacparser
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/rawaac/parser/include \
-	$(PV_TOP)//fileformats/rawaac/parser/src \
-	$(PV_TOP)/codecs_v2/audio/aac/dec/util/getactualaacconfig/include \
-	$(PV_TOP)/codecs_v2/audio/aac/dec/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/rawaac/parser/src \
+ 	$(PV_TOP)/fileformats/rawaac/parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/aacfileparser.h
+ 	include/aacfileparser.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/rawaac/parser/build/make/local.mk b/fileformats/rawaac/parser/build/make/local.mk
new file mode 100644
index 0000000..b8876ef
--- /dev/null
+++ b/fileformats/rawaac/parser/build/make/local.mk
@@ -0,0 +1,19 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvaacparser
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := aacfileparser.cpp
+
+HDRS := aacfileparser.h 
+
+include $(MK)/library.mk
diff --git a/fileformats/rawaac/parser/build/make/makefile b/fileformats/rawaac/parser/build/make/makefile
deleted file mode 100644
index 38165e3..0000000
--- a/fileformats/rawaac/parser/build/make/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvaacparser
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-XINCDIRS += -I $(VOB_BASE_DIR)/codecs_v2/audio/aac/dec/util/getactualaacconfig/include -I $(VOB_BASE_DIR)/codecs_v2/audio/aac/dec/include
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	aacfileparser.cpp
-
-HDRS =  aacfileparser.h 
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/fileformats/rawaac/parser/include/aacfileparser.h b/fileformats/rawaac/parser/include/aacfileparser.h
index 380d75f..8ee1066 100644
--- a/fileformats/rawaac/parser/include/aacfileparser.h
+++ b/fileformats/rawaac/parser/include/aacfileparser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,10 +58,6 @@
 #include "pv_gau.h"
 #endif
 
-#ifndef AUDIOMETADATA_H_INCLUDED
-#include "audiometadata.h"
-#endif
-
 #ifndef PVFILE_H_INCLUDED
 #include "pvfile.h"
 #endif
@@ -114,7 +110,7 @@
 
 #define PV_AAC_FF_TEMPLATED_DELETE(auditCB,T,Tsimple,ptr)\
 {\
-OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
+OSCL_DELETE(ptr);\
 }
 
 #define PV_AAC_FF_ARRAY_MALLOC(auditCB,T,count,ptr)\
@@ -138,13 +134,14 @@
     OSCL_ARRAY_DELETE(ptr);\
 }
 
-typedef enum
+enum ParserErrorCode
 {
+    GENERIC_ERROR     = -4,
+    INSUFFICIENT_DATA = -3,
     FILE_OPEN_ERROR = -2,
-    MEMEORY_ERROR   = -1,
-    OK           = 1
-
-} PARSER_ERROR_CODES;
+    MEMORY_ERROR    = -1,
+    OK              = 1
+};
 
 /*
  * AAC format types supported
@@ -226,7 +223,8 @@
             MISC_ERROR = -2,
             READ_ERROR = -1,
             EVERYTHING_OK = 0,
-            END_OF_FILE = 62
+            END_OF_FILE = 62,
+            INSUFFICIENT_DATA = 141
         };
 
         /**
@@ -380,6 +378,13 @@
         */
         int32 find_adts_syncword(uint8 *pBuffer);
 
+        /**
+        * @brief Determines if clip is AAC
+        *
+        * @param PVFile&
+        * @returns Result of operation: EVERYTHING_OK, READ_ERROR etc.
+        */
+        int32 isAACFile();
 
     private:
 
@@ -605,10 +610,17 @@
         */
         OSCL_IMPORT_REF TAACFormat GetAACFormat(void);
 
-        OSCL_IMPORT_REF  uint32 getAACHeaderLen(OSCL_wString& aClip,  bool aInitParsingEnable, Oscl_FileServer* iFileSession, PVMFCPMPluginAccessInterfaceFactory* aCPMAccess, OsclFileHandle*aHandle);
+        OSCL_IMPORT_REF  ParserErrorCode getAACHeaderLen(OSCL_wString& aClip,  bool aInitParsingEnable, Oscl_FileServer* iFileSession, PVMFCPMPluginAccessInterfaceFactory* aCPMAccess, OsclFileHandle*aHandle, uint32* HeaderLen);
 
         OSCL_IMPORT_REF  PVID3Version GetID3Version() const;
 
+        /**
+        * @brief Returns if file is AAC
+        *
+        * @param
+        * @returns status
+        */
+        OSCL_IMPORT_REF ParserErrorCode IsAACFile(OSCL_wString& aClip, Oscl_FileServer* aFileSession, PVMFCPMPluginAccessInterfaceFactory* aCPMAccess, OsclFileHandle* aHandle = NULL);
 
     private:
         PVFile     iAACFile;
diff --git a/fileformats/rawaac/parser/src/aacfileparser.cpp b/fileformats/rawaac/parser/src/aacfileparser.cpp
index e0672bc..e6e7507 100644
--- a/fileformats/rawaac/parser/src/aacfileparser.cpp
+++ b/fileformats/rawaac/parser/src/aacfileparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
 #include "pv_audio_type_defs.h"
 #include "getactualaacconfig.h"
 #include "media_clock_converter.h"
-
+#include "pvmp4audiodecoder_api.h"
 
 // Use default DLL entry point for Symbian
 #include "oscl_dll.h"
@@ -257,6 +257,118 @@
     aFile.Seek(curpos, Oscl_File::SEEKSET);
 }
 
+int32 AACBitstreamObject::isAACFile()
+{
+    if (!ipAACFile || !ipAACFile->IsOpen())
+    {
+        return AACBitstreamObject::READ_ERROR;
+    }
+
+    int32 retVal = AACBitstreamObject::EVERYTHING_OK;
+
+    // save current file pointer location
+    int32 curPos = ipAACFile->Tell();
+    ipAACFile->Seek(0, Oscl_File::SEEKSET);
+
+    // check for ID3v2 tag at the beginning of file
+    uint32 tagSize = 0;
+    if (true == id3Parser->IsID3V2Present(ipAACFile, tagSize))
+    {
+        // skip over ID3v2 tag
+        // move the file read pointer to beginning of audio data
+        // but first make sure the data is there
+        uint32 aCurrentSize = 0;
+        uint32 aRemBytes = 0;
+        if (ipAACFile->GetRemainingBytes(aRemBytes))
+        {
+            uint32 currPos_2 = (uint32)(ipAACFile->Tell());
+            aCurrentSize = currPos_2 + aRemBytes;
+
+            if (aCurrentSize >= tagSize)
+            {
+                if (ipAACFile->Seek(tagSize, Oscl_File::SEEKSET) != 0)
+                {
+                    retVal = AACBitstreamObject::READ_ERROR;
+                }
+            }
+            else
+            {
+                // data has not arrived yet
+                retVal = AACBitstreamObject::INSUFFICIENT_DATA;
+            }
+        }
+        else
+        {
+            retVal = AACBitstreamObject::READ_ERROR;
+        }
+    }
+
+    // file pointer should be at the audio data
+    // can be ADTS, ADIF or raw AAC
+    // - it takes 8192 bytes (max AAC frame size) to determine that is is ADTS
+    // - it takes 4 bytes to determine that it is ADIF
+    // - it takes 1536 bytes to determine that it is raw AAC
+
+    // make sure there are at least 8192 bytes left in the file
+    if (AACBitstreamObject::EVERYTHING_OK == retVal)
+    {
+        uint32 aRemBytes = 0;
+        if (ipAACFile->GetRemainingBytes(aRemBytes))
+        {
+            int32 currPos_2 = ipAACFile->Tell();
+            retVal = reset(currPos_2);
+
+            if (AACBitstreamObject::EVERYTHING_OK == retVal)
+            {
+                uint8 *pBuffer = &iBuffer[iPos];
+
+                // default to not enough data
+                retVal = AACBitstreamObject::INSUFFICIENT_DATA;
+                if (aRemBytes >= MAX_ADTS_PACKET_LENGTH)
+                {
+                    // check for possible ADTS sync word
+                    int32 index = find_adts_syncword(pBuffer);
+                    if (index != -1)
+                    {
+                        // definitely ADTS
+                        retVal = AACBitstreamObject::EVERYTHING_OK;
+                    }
+                }
+
+                if (AACBitstreamObject::INSUFFICIENT_DATA == retVal)
+                {
+                    // not enough data to determine if it is ADTS
+                    // see if it is ADIF
+                    if (aRemBytes >= 4)
+                    {
+                        // check for ADIF header
+                        if (pBuffer[0] == 0x41 &&  // 'A'
+                                pBuffer[1] == 0x44 &&  // 'D'
+                                pBuffer[2] == 0x49 &&  // 'I'
+                                pBuffer[3] == 0x46)    // 'F'
+                        {
+                            // definitely ADIF
+                            retVal = AACBitstreamObject::EVERYTHING_OK;
+                        }
+                        else
+                        {
+                            // non-recognized format,
+                            retVal = AACBitstreamObject::MISC_ERROR;
+                        }
+                    }
+                }
+            }
+        }
+        else
+        {
+            retVal = AACBitstreamObject::READ_ERROR;
+        }
+    }
+
+    // retore file pointer
+    ipAACFile->Seek(curPos, Oscl_File::SEEKSET);
+    return retVal;
+}
 
 
 //! Search for adts synchronization word
@@ -1357,6 +1469,15 @@
 //
 //  Constructor for CAACFileParser class
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF CAACFileParser::CAACFileParser(void)
 {
@@ -1393,6 +1514,15 @@
 //
 //  Destructor for CAACFileParser class
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF CAACFileParser::~CAACFileParser(void)
 {
@@ -1433,6 +1563,15 @@
 //  This function opens the AAC file, checks for AAC format type, calculates
 //  the track duration, and sets the AAC bitrate value.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF bool CAACFileParser::InitAACFile(OSCL_wString& aClip,  bool aInitParsingEnable, Oscl_FileServer* iFileSession, PVMFCPMPluginAccessInterfaceFactory* aCPMAccess, OsclFileHandle*aHandle)
 {
@@ -1581,7 +1720,7 @@
             // get the duration in millisec
             MediaClockConverter mcc;
             mcc.set_timescale(iAACSampleFrequency);
-            mcc.set_clock(iAACDuration*1024, 1);
+            mcc.set_clock(iAACDuration*1024, 0);
             iAACDuration = mcc.get_converted_ts(1000);
 
             if (ipBSO->reset(0))
@@ -1599,7 +1738,7 @@
             // rough duration calculation based on max bitrate for variable rate bitstream
             MediaClockConverter mcc;
             mcc.set_timescale(iAACBitRate);
-            mcc.set_clock(raw_data_bits, 1);
+            mcc.set_clock(raw_data_bits, 0);
             iAACDuration = mcc.get_converted_ts(1000);
 
             if (ipBSO->reset(ipBSO->GetByteOffsetToStartOfAudioFrames() + (iAACHeaderLen >> 3)))
@@ -1651,6 +1790,15 @@
 //  This function opens the AAC file, checks for AAC format type, calculates
 //  the track duration, and sets the AAC bitrate value.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF bool CAACFileParser::RetrieveFileInfo(TPVAacFileInfo& aInfo)
 {
@@ -1693,6 +1841,15 @@
 //
 //  This function retrieves the ID3 data if any was found in the file.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF bool CAACFileParser::RetrieveID3Info(PvmiKvpSharedPtrVector& aID3MetaData)
 {
@@ -1743,11 +1900,21 @@
 //  This function sets the file pointer to the location that aStartTime would
 //  point to in the file.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 
 OSCL_EXPORT_REF int32 CAACFileParser::ResetPlayback(uint32 aStartTime, uint32& aActualStartTime)
 {
     // Check if the file is opened
+    int32 result;
     if (!iAACFile.IsOpen())
     {
         PVMF_AACPARSER_LOGERROR((0, "CAACFileParser::ResetPlayback- Misc error-"));
@@ -1782,11 +1949,11 @@
             }
             newPosition = iRPTable[iTotalNumFramesRead];
         }
-
-        if (newPosition >= 0 && ipBSO->reset(ipBSO->GetByteOffsetToStartOfAudioFrames() + newPosition))
+        result = ipBSO->reset(ipBSO->GetByteOffsetToStartOfAudioFrames() + newPosition);
+        if (newPosition >= 0 && result)
         {
             PVMF_AACPARSER_LOGERROR((0, "CAACFileParser::ResetPlayback- Misc error-"));
-            return AACBitstreamObject::MISC_ERROR;
+            return result;
         }
         iEndOfFileReached = false;
     }
@@ -1823,7 +1990,7 @@
 
     MediaClockConverter mcc;
     mcc.set_timescale(iAACSampleFrequency);
-    mcc.set_clock(iTotalNumFramesRead*1024, 1);
+    mcc.set_clock(iTotalNumFramesRead*1024, 0);
     aActualStartTime = mcc.get_converted_ts(1000);
 
     PVMF_AACPARSER_LOGDIAGNOSTICS((0, "CAACFileParser::resetplayback - aActualStartTime=%d", aActualStartTime));
@@ -1853,6 +2020,15 @@
 //  This function returns the timestamp for an actual position corresponding
 //  to the specified start time
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF uint32 CAACFileParser::SeekPointFromTimestamp(uint32 aStartTime)
 {
@@ -1918,6 +2094,15 @@
 //  aNumSamples. It formats the read data to WMF bit order and stores it in
 //  the GAU structure.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF int32
 CAACFileParser::GetNextBundledAccessUnits(uint32 *aNumSamples,
@@ -2123,12 +2308,21 @@
 //
 //  This function returns the next timestamp without processing any data.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF int32 CAACFileParser::PeekNextTimestamp(uint32& ts)
 {
     MediaClockConverter mcc;
     mcc.set_timescale(iAACSampleFrequency);
-    mcc.set_clock((iTotalNumFramesRead + 1)*1024, 1);
+    mcc.set_clock((iTotalNumFramesRead + 1)*1024, 0);
     ts = mcc.get_converted_ts(1000);
 
     return AACBitstreamObject::EVERYTHING_OK;
@@ -2156,6 +2350,15 @@
 //
 //  This function returns the value defined by AAC_DECODER_SPECIFIC_INFO_SIZE.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF int32 CAACFileParser::GetTrackDecoderSpecificInfoSize(void)
 {
@@ -2197,6 +2400,15 @@
 //  This function populates iAACFrameBuffer with the two byte of decoder
 //  specific info and returns the address to the values.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF uint8* CAACFileParser::GetTrackDecoderSpecificInfoContent(void)
 {
@@ -2229,6 +2441,15 @@
 //
 //  This function returns iAACFormat value.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF TAACFormat CAACFileParser::GetAACFormat(void)
 {
@@ -2240,11 +2461,12 @@
     return ipBSO->GetID3Version();
 }
 
-OSCL_EXPORT_REF uint32 CAACFileParser::getAACHeaderLen(OSCL_wString& aClip,
+OSCL_EXPORT_REF ParserErrorCode CAACFileParser::getAACHeaderLen(OSCL_wString& aClip,
         bool aInitParsingEnable,
         Oscl_FileServer* iFileSession,
         PVMFCPMPluginAccessInterfaceFactory* aCPMAccess,
-        OsclFileHandle* aHandle)
+        OsclFileHandle* aHandle,
+        uint32* HeaderLenValue)
 {
     PVFile iAACFileTemp;
     OSCL_UNUSED_ARG(aInitParsingEnable);
@@ -2268,27 +2490,70 @@
         // release temp storage, file control block..
         iAACFileTemp.Close();
         PV_AAC_FF_DELETE(NULL, AACBitstreamObject, ipBSOTemp);
-        return MEMEORY_ERROR;
+        return MEMORY_ERROR;
     }
 
     uint32 bitRateValueTemp;
-    uint32 HeaderLenValueTemp;
+    uint32 tempHeaderLenValue = 0;
 
     int32 iAACFileSizeTemp;
     uint8 sampleFreqTableValueTemp;
     TAACFormat formatTemp;
-    if (ipBSOTemp->getFileInfo(iAACFileSizeTemp, formatTemp, sampleFreqTableValueTemp, bitRateValueTemp, HeaderLenValueTemp, aClip))
+    if (ipBSOTemp->getFileInfo(iAACFileSizeTemp, formatTemp, sampleFreqTableValueTemp, bitRateValueTemp, tempHeaderLenValue, aClip))
     {
         return FILE_OPEN_ERROR;
     }
     if (formatTemp == EAACADTS)
     {
-        HeaderLenValueTemp = ADTS_HEADER_LENGTH;
+        tempHeaderLenValue = ADTS_HEADER_LENGTH;
     }
     iAACFileTemp.Close();
     PV_AAC_FF_DELETE(NULL, AACBitstreamObject, ipBSOTemp);
     ipBSOTemp = NULL;
-
-    return HeaderLenValueTemp;
-
+    *HeaderLenValue = tempHeaderLenValue;
+    return OK;
 }
+
+OSCL_EXPORT_REF ParserErrorCode CAACFileParser::IsAACFile(OSCL_wString& aClip, Oscl_FileServer* aFileSession, PVMFCPMPluginAccessInterfaceFactory* aCPMAccess, OsclFileHandle* aHandle)
+{
+    PVFile iAACFileTemp;
+    iAACFileTemp.SetCPM(aCPMAccess);
+    iAACFileTemp.SetFileHandle(aHandle);
+
+    // Open the file (aClip)
+    if (iAACFileTemp.Open(aClip.get_cstr(), (Oscl_File::MODE_READ | Oscl_File::MODE_BINARY), *aFileSession) != 0)
+    {
+        PVMF_AACPARSER_LOGERROR((0, "CAACFileParser::IsAACFile- File open error-"));
+        return FILE_OPEN_ERROR;
+    }
+
+    AACBitstreamObject *ipBSOTemp;
+    PV_AAC_FF_NEW(NULL, AACBitstreamObject, (&iAACFileTemp), ipBSOTemp);
+
+    if (!ipBSOTemp || ipBSOTemp->get())
+    {
+        PVMF_AACPARSER_LOGERROR((0, "CAACFileParser::IsAACFile- Memory allocation failed-"));
+        // release temp storage, file control block..
+        iAACFileTemp.Close();
+        PV_AAC_FF_DELETE(NULL, AACBitstreamObject, ipBSOTemp);
+        return MEMORY_ERROR;
+    }
+
+    int32 result = ipBSOTemp->isAACFile();
+
+    // release temp storage, file control block and the file
+    iAACFileTemp.Close();
+    PV_AAC_FF_DELETE(NULL, AACBitstreamObject, ipBSOTemp);
+    ipBSOTemp = NULL;
+
+    if (AACBitstreamObject::EVERYTHING_OK == result)
+    {
+        return OK;
+    }
+    else if (AACBitstreamObject::INSUFFICIENT_DATA == result)
+    {
+        return INSUFFICIENT_DATA;
+    }
+    return GENERIC_ERROR;
+}
+
diff --git a/fileformats/rawgsmamr/parser/Android.mk b/fileformats/rawgsmamr/parser/Android.mk
index 35ffa47..2edae84 100644
--- a/fileformats/rawgsmamr/parser/Android.mk
+++ b/fileformats/rawgsmamr/parser/Android.mk
@@ -2,24 +2,27 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/amrfileparser.cpp
-
+ 	src/amrfileparser.cpp
 
 
 LOCAL_MODULE := libpvgsmamrparser
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/rawgsmamr/parser/include \
-	$(PV_TOP)//fileformats/rawgsmamr/parser/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/rawgsmamr/parser/src \
+ 	$(PV_TOP)/fileformats/rawgsmamr/parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/amrfileparser.h
+ 	include/amrfileparser.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/rawgsmamr/parser/build/make/local.mk b/fileformats/rawgsmamr/parser/build/make/local.mk
new file mode 100644
index 0000000..46287a8
--- /dev/null
+++ b/fileformats/rawgsmamr/parser/build/make/local.mk
@@ -0,0 +1,28 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvgsmamrparser
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := amrfileparser.cpp
+
+HDRS := amrfileparser.h
+
+
+
+include $(MK)/library.mk
diff --git a/fileformats/rawgsmamr/parser/build/make/makefile b/fileformats/rawgsmamr/parser/build/make/makefile
deleted file mode 100644
index 7399fb5..0000000
--- a/fileformats/rawgsmamr/parser/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvgsmamrparser
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I ../../../common/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	amrfileparser.cpp
-
-HDRS =  amrfileparser.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/fileformats/rawgsmamr/parser/include/amrfileparser.h b/fileformats/rawgsmamr/parser/include/amrfileparser.h
index 49df529..00220ee 100644
--- a/fileformats/rawgsmamr/parser/include/amrfileparser.h
+++ b/fileformats/rawgsmamr/parser/include/amrfileparser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/fileformats/rawgsmamr/parser/src/amrfileparser.cpp b/fileformats/rawgsmamr/parser/src/amrfileparser.cpp
index 396b876..e861850 100644
--- a/fileformats/rawgsmamr/parser/src/amrfileparser.cpp
+++ b/fileformats/rawgsmamr/parser/src/amrfileparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
 //----------------------------------------------------------------------------
 #include "amrfileparser.h"
 
+// Use default DLL entry point for Symbian
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
@@ -389,6 +390,15 @@
 // FUNCTION DESCRIPTION
 //
 //  Constructor for CAMRFileParser class
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF CAMRFileParser::CAMRFileParser(void)
 {
@@ -426,6 +436,15 @@
 // FUNCTION DESCRIPTION
 //
 //  Destructor for CAMRFileParser class
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF CAMRFileParser::~CAMRFileParser(void)
 {
@@ -457,6 +476,15 @@
 //  This function opens the AMR file, checks for AMR format type, calculates
 //  the track duration, and sets the AMR bitrate value.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF bool CAMRFileParser::InitAMRFile(OSCL_wString& aClip, bool aInitParsingEnable, Oscl_FileServer* aFileSession, PVMFCPMPluginAccessInterfaceFactory*aCPM, OsclFileHandle*aHandle, uint32 countToClaculateRDATimeInterval)
 {
@@ -606,7 +634,7 @@
 }
 
 //----------------------------------------------------------------------------
-// FUNCTION NAME: CAMRFileParser::RetreiveAMRFileInfo
+// FUNCTION NAME: CAMRFileParser::RetrieveAMRFileInfo
 //----------------------------------------------------------------------------
 // INPUT AND OUTPUT DEFINITIONS
 //
@@ -630,6 +658,15 @@
 //  This function opens the AMR file, checks for AMR format type, calculates
 //  the track duration, and sets the AMR bitrate value.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF bool CAMRFileParser::RetrieveFileInfo(TPVAmrFileInfo& aInfo)
 {
@@ -673,6 +710,15 @@
 //  This function takes in the 3GPP frametype and sets the AMR bitrate value
 //  depending on the AMR frametype.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 void CAMRFileParser::SetBitRate(AMRFF_Frame_Type_3GPP aFrameType3GPP)
 {
@@ -811,10 +857,20 @@
 //  This function sets the file pointer to the location that aStartTime would
 //  point to in the file.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF int32 CAMRFileParser::ResetPlayback(int32 aStartTime)
 {
     // get file size info, //iAMRFile.Size(fileSize)
+    int32 result;
     if (iAMRFileSize <= 0)
     {
         int32 frameTypeIndex;
@@ -861,11 +917,11 @@
             newPosition = iRPTable[tblIdx];
         }
     }
-
-    if (newPosition >= 0 && ipBSO->reset(newPosition))
+    result = ipBSO->reset(newPosition);
+    if (newPosition >= 0 && result)
     {
         PVMF_AMRPARSER_LOGERROR((0, "AMRBitstreamObject::refill- Misc Error"));
-        return bitstreamObject::MISC_ERROR;
+        return result;
     }
     iEndOfFileReached = false;
 
@@ -896,6 +952,15 @@
 //  This function returns the timestamp for an actual position corresponding
 //  to the specified start time
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF uint32 CAMRFileParser::SeekPointFromTimestamp(uint32 aStartTime)
 {
@@ -960,6 +1025,15 @@
 //  aNumSamples. It formats the read data to WMF bit order and stores it in
 //  the GAU structure.
 //
+//----------------------------------------------------------------------------
+// REQUIREMENTS
+//
+//----------------------------------------------------------------------------
+// REFERENCES
+//
+//------------------------------------------------------------------------------
+// CAUTION
+//
 //------------------------------------------------------------------------------
 OSCL_EXPORT_REF int32 CAMRFileParser::GetNextBundledAccessUnits(uint32 *aNumSamples, GAU *aGau)
 {
diff --git a/fileformats/wav/parser/Android.mk b/fileformats/wav/parser/Android.mk
index 18ec345..6146e4d 100644
--- a/fileformats/wav/parser/Android.mk
+++ b/fileformats/wav/parser/Android.mk
@@ -2,24 +2,27 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvwavfileparser.cpp
-
+ 	src/pvwavfileparser.cpp
 
 
 LOCAL_MODULE := libpvwav
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//fileformats/wav/parser/include \
-	$(PV_TOP)//fileformats/wav/parser/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/fileformats/wav/parser/src \
+ 	$(PV_TOP)/fileformats/wav/parser/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvwavfileparser.h
+ 	include/pvwavfileparser.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/fileformats/wav/parser/build/make/local.mk b/fileformats/wav/parser/build/make/local.mk
new file mode 100644
index 0000000..a93876f
--- /dev/null
+++ b/fileformats/wav/parser/build/make/local.mk
@@ -0,0 +1,28 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvwav
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvwavfileparser.cpp
+
+HDRS := pvwavfileparser.h
+
+
+
+include $(MK)/library.mk
diff --git a/fileformats/wav/parser/build/make/makefile b/fileformats/wav/parser/build/make/makefile
deleted file mode 100755
index c02c2a9..0000000
--- a/fileformats/wav/parser/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvwav
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I ../../../common/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvwavfileparser.cpp
-
-HDRS =  pvwavfileparser.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/fileformats/wav/parser/include/pvwavfileparser.h b/fileformats/wav/parser/include/pvwavfileparser.h
index 67876a2..25bfa86 100644
--- a/fileformats/wav/parser/include/pvwavfileparser.h
+++ b/fileformats/wav/parser/include/pvwavfileparser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -120,7 +120,7 @@
         OSCL_IMPORT_REF bool SetOutputToUncompressedPCM(void);
     private:
         PVWavParserReturnCode ReadData(uint8* buff, uint32 size, uint32& bytesread);
-        void CleanupWAVFile(void);
+        OSCL_IMPORT_REF void CleanupWAVFile(void);
 
         //Subchunk 1
         uint16 AudioFormat;
diff --git a/fileformats/wav/parser/src/pvwavfileparser.cpp b/fileformats/wav/parser/src/pvwavfileparser.cpp
index 18c8042..2e8cb29 100644
--- a/fileformats/wav/parser/src/pvwavfileparser.cpp
+++ b/fileformats/wav/parser/src/pvwavfileparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/modules/cml2/rules.cml b/modules/cml2/rules.cml
new file mode 100644
index 0000000..7758c23
--- /dev/null
+++ b/modules/cml2/rules.cml
@@ -0,0 +1,30 @@
+# streaming
+source "symbols.cml"
+
+derive pvrtspinterface_m_mk from rtsp_support==y                          ? "/modules/linux_rtsp/core/build/make" : ""
+derive pvrtspreginterface_m_mk from rtsp_support==y                    ? "/modules/linux_rtsp/node_registry/build/make" : ""
+derive pvasfstreaminginterface_m_mk from asf_streaming_support==y          ? "/modules/linux_asf/asf_streaming/core/build/make" : ""
+derive pvasfstreamingreginterface_m_mk from asf_streaming_support==y    ? "/modules/linux_asf/asf_streaming/node_registry/build/make" : ""
+derive pvdownloadinterface_m_mk from download_support==y                  ? "/modules/linux_download/core/build/make" : ""
+derive pvdownloadreginterface_m_mk from download_support==y            ? "/modules/linux_download/node_registry/build/make" : ""
+derive pvmp4interface_m_mk from mp4local_support==y                       ? "/modules/linux_mp4/core/build/make" : ""
+derive pvmp4reginterface_m_mk from mp4local_support==y                 ? "/modules/linux_mp4/node_registry/build/make" : ""
+derive pvasflocalpbinterface_m_mk from asflocal_support==y                ? "/modules/linux_asf/asf_localpb/core/build/make" : ""
+derive pvasflocalpbreginterface_m_mk from asflocal_support==y          ? "/modules/linux_asf/asf_localpb/node_registry/build/make" : ""
+
+derive pvrtspinterface_m_lib from rtsp_support==y                         ? "-lpvrtspinterface" : ""
+derive pvrtspreginterface_m_lib from rtsp_support==y                   ? "-lpvrtspreginterface" : ""
+derive pvasfstreaminginterface_m_lib from asf_streaming_support==y         ? "-lpvasfstreaminginterface" : ""
+derive pvasfstreamingreginterface_m_lib from asf_streaming_support==y   ? "-lpvasfstreamingreginterface" : ""
+derive pvdownloadinterface_m_lib from download_support==y                 ? "-lpvdownloadinterface" : ""
+derive pvdownloadreginterface_m_lib from download_support==y           ? "-lpvdownloadreginterface" : ""
+derive pvmp4interface_m_lib from mp4local_support==y                      ? "-lpvmp4interface" : ""
+derive pvmp4reginterface_m_lib from mp4local_support==y                ? "-lpvmp4reginterface" : ""
+derive pvasflocalpbinterface_m_lib from asflocal_support==y               ? "-lpvasflocalpbinterface" : ""
+derive pvasflocalpbreginterface_m_lib from asflocal_support==y         ? "-lpvasflocalpbreginterface" : ""
+
+
+derive LIBDIR_tools_v2_shared from pvrtspinterface_m_mk.pvrtspreginterface_m_mk.pvasfstreaminginterface_m_mk.pvasfstreamingreginterface_m_mk.pvdownloadinterface_m_mk.pvdownloadreginterface_m_mk.pvmp4interface_m_mk.pvmp4reginterface_m_mk.pvasflocalpbinterface_m_mk.pvasflocalpbreginterface_m_mk
+
+derive LIBS_tools_v2_shared from pvrtspinterface_m_lib.pvrtspreginterface_m_lib.pvasfstreaminginterface_m_lib.pvasfstreamingreginterface_m_lib.pvdownloadinterface_m_lib.pvdownloadreginterface_m_lib.pvmp4interface_m_lib.pvmp4reginterface_m_lib.pvasflocalpbinterface_m_lib.pvasflocalpbreginterface_m_lib
+
diff --git a/modules/cml2/start.cml b/modules/cml2/start.cml
new file mode 100755
index 0000000..43d7983
--- /dev/null
+++ b/modules/cml2/start.cml
@@ -0,0 +1,2 @@
+start streaming
+source "rules.cml"
diff --git a/modules/cml2/symbols.cml b/modules/cml2/symbols.cml
new file mode 100755
index 0000000..61bf0e6
--- /dev/null
+++ b/modules/cml2/symbols.cml
@@ -0,0 +1,2 @@
+symbols
+
diff --git a/modules/linux_download/core/Android.mk b/modules/linux_download/core/Android.mk
new file mode 100644
index 0000000..2a10b5e
--- /dev/null
+++ b/modules/linux_download/core/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pvmfdownloadnodes.cpp
+
+
+LOCAL_MODULE := libpvdownloadinterface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/modules/linux_download/core/src \
+ 	$(PV_TOP)/modules/linux_download/core/build/make \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/modules/linux_download/core/build/make/local.mk b/modules/linux_download/core/build/make/local.mk
new file mode 100644
index 0000000..e76d811
--- /dev/null
+++ b/modules/linux_download/core/build/make/local.mk
@@ -0,0 +1,14 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvdownloadinterface
+
+SRCDIR := ../../src
+
+SRCS := pvmfdownloadnodes.cpp
+
+include $(MK)/library.mk
+
diff --git a/modules/linux_download/core/src/pvmfdownloadnodes.cpp b/modules/linux_download/core/src/pvmfdownloadnodes.cpp
new file mode 100644
index 0000000..e7d7cbc
--- /dev/null
+++ b/modules/linux_download/core/src/pvmfdownloadnodes.cpp
@@ -0,0 +1,80 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_node_shared_lib_interface.h"
+
+#include "pvmf_downloadmanager_factory.h"
+
+#include "osclconfig.h"
+
+class DownloadNodesInterface: public OsclSharedLibraryInterface,
+            public NodeSharedLibraryInterface
+{
+    public:
+        // From NodeSharedLibraryInterface
+        OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId)
+        {
+            if (KPVMFDownloadManagerNodeUuid == aNodeUuid)
+            {
+                if (PV_CREATE_NODE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(PVMFDownloadManagerNodeFactory::CreatePVMFDownloadManagerNode));
+                }
+                else if (PV_RELEASE_NODE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(PVMFDownloadManagerNodeFactory::DeletePVMFDownloadManagerNode));
+                }
+            }
+
+            return NULL;
+        };
+
+        // From OsclSharedLibraryInterface
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_NODE_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(NodeSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+        static DownloadNodesInterface* Instance()
+        {
+            static DownloadNodesInterface nodeInterface;
+            return &nodeInterface;
+        };
+
+    private:
+
+        DownloadNodesInterface() {};
+
+};
+
+
+extern "C"
+{
+    OsclSharedLibraryInterface* PVGetInterface(void)
+    {
+        return DownloadNodesInterface::Instance();
+    }
+    void PVReleaseInterface(OsclSharedLibraryInterface*)
+    {
+        //nothing needed
+    }
+}
+
diff --git a/modules/linux_download/node_registry/Android.mk b/modules/linux_download/node_registry/Android.mk
new file mode 100644
index 0000000..5d0b375
--- /dev/null
+++ b/modules/linux_download/node_registry/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pvmfdownloadnodereg.cpp
+
+
+LOCAL_MODULE := libpvdownloadreginterface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/modules/linux_download/node_registry/src \
+ 	$(PV_TOP)/modules/linux_download/node_registry/src \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/modules/linux_download/node_registry/build/make/local.mk b/modules/linux_download/node_registry/build/make/local.mk
new file mode 100644
index 0000000..86e19ec
--- /dev/null
+++ b/modules/linux_download/node_registry/build/make/local.mk
@@ -0,0 +1,21 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvdownloadreginterface
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvmfdownloadnodereg.cpp
+
+include $(MK)/library.mk
+
diff --git a/modules/linux_download/node_registry/src/pvmfdownloadnodereg.cpp b/modules/linux_download/node_registry/src/pvmfdownloadnodereg.cpp
new file mode 100644
index 0000000..d47dbfd
--- /dev/null
+++ b/modules/linux_download/node_registry/src/pvmfdownloadnodereg.cpp
@@ -0,0 +1,232 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/* This file defines a PV NodeSharedLibrary interface that populates the
+   registry with the download manager node.
+*/
+#ifndef PVMFDOWNLOADNODEREG_H_INCLUDED
+#include "pvmfdownloadnodereg.h"
+#endif
+
+#ifndef PVMF_NODE_SHARED_LIB_INTERFACE_H_INCLUDED
+#include "pvmf_node_shared_lib_interface.h"
+#endif
+
+#ifndef PVMF_DOWNLOADMANAGER_FACTORY_H_INCLUDED
+#include "pvmf_downloadmanager_factory.h"
+#endif
+
+#ifndef PVMF_RECOGNIZER_REGISTRY_H_INCLUDED
+#include "pvmf_recognizer_registry.h"
+#endif
+
+#ifndef OSCLCONFIG_H_INCLUDED
+#include "osclconfig.h"
+#endif
+
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
+
+#define DOWNLOAD_LIB_NAME "libopencore_download.so"
+
+#define NODE_REGISTRY_LIB_NAME_MAX_LENGTH 64
+
+typedef PVMFNodeInterface*(* LPFN_NODE_CREATE_FUNC)(int32);
+
+typedef bool (* LPFN_NODE_RELEASE_FUNC)(PVMFNodeInterface *);
+
+// init static variables before use
+OsclSharedLibrary* DownloadNodesCoreLibraryLoader::iOsclSharedLibrary = NULL;
+
+// Factory functions
+PVMFNodeInterface* DownloadNodesCoreLibraryLoader::CreateDownloadManagerNode(int32 aPriority)
+{
+    if (NULL == iOsclSharedLibrary)
+    {
+        OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(DOWNLOAD_LIB_NAME);
+
+        // Need to load the library for the node
+        iOsclSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
+
+        OsclLibStatus result = iOsclSharedLibrary->LoadLib();
+        if (OsclLibSuccess != result)
+        {
+            return NULL;
+        }
+    }
+
+    iOsclSharedLibrary->AddRef();
+
+    // Query for create function
+    OsclAny* interfacePtr = NULL;
+
+    iOsclSharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);
+
+    NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
+
+    OsclAny* createFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFDownloadManagerNodeUuid, PV_CREATE_NODE_INTERFACE);
+
+    LPFN_NODE_CREATE_FUNC nodeCreateFunc = OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp);
+
+    if (NULL != nodeCreateFunc)
+    {
+        // call the real node factory function
+        return (*(nodeCreateFunc))(aPriority);
+    }
+    return NULL;
+}
+
+
+bool DownloadNodesCoreLibraryLoader::DeleteDownloadManagerNode(PVMFNodeInterface* aNode)
+{
+    bool bStatus = false;
+
+    if (NULL != iOsclSharedLibrary)
+    {
+        // Query for release function
+        OsclAny* interfacePtr = NULL;
+
+        iOsclSharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);
+
+        NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
+
+        OsclAny* releaseFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFDownloadManagerNodeUuid, PV_RELEASE_NODE_INTERFACE);
+
+        LPFN_NODE_RELEASE_FUNC nodeReleaseFunc = OSCL_DYNAMIC_CAST(bool (*)(PVMFNodeInterface*), releaseFuncTemp);
+
+        if (NULL != nodeReleaseFunc)
+        {
+            bStatus = (*(nodeReleaseFunc))(aNode);
+        }
+
+        iOsclSharedLibrary->RemoveRef();
+
+        if (OsclLibSuccess == iOsclSharedLibrary->Close())
+        {
+            // Close will unload the library if refcount is 0
+            OSCL_DELETE(iOsclSharedLibrary);
+            iOsclSharedLibrary = NULL;
+        }
+    }
+
+    return bStatus;
+}
+
+
+
+class DownloadNodesRegistryInterface: public OsclSharedLibraryInterface,
+            public NodeRegistryPopulatorInterface,
+            public RecognizerPopulatorInterface
+{
+    public:
+
+        // From NodeRegistryPopulatorInterface
+        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
+        {
+            PVPlayerNodeInfo nodeinfo;
+
+            OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(DOWNLOAD_LIB_NAME);
+
+            Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
+
+            //For PVMFDownloadManagerNode
+            nodeinfo.iInputTypes.clear();
+            nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_HTTP_URL);
+            nodeinfo.iNodeUUID = KPVMFDownloadManagerNodeUuid;
+            nodeinfo.iOutputType.clear();
+            nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+            nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
+            nodeinfo.iNodeCreateFunc = (DownloadNodesCoreLibraryLoader::CreateDownloadManagerNode);
+            nodeinfo.iNodeReleaseFunc = (DownloadNodesCoreLibraryLoader::DeleteDownloadManagerNode);
+
+            aRegistry->RegisterNode(nodeinfo);
+
+            nodeList->push_back(nodeinfo);
+
+            aContext = (OsclAny *)nodeList;
+        };
+
+        // From NodeRegistryPopulatorInterface
+        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
+        {
+            if (NULL != aContext)
+            {
+                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;
+
+                while (!nodeList->empty())
+                {
+                    PVPlayerNodeInfo tmpnode = nodeList->front();
+                    OSCL_DELETE(tmpnode.iSharedLibrary);
+                    aRegistry->UnregisterNode(tmpnode);
+                    nodeList->erase(nodeList->begin());
+                }
+
+                delete nodeList;
+            }
+        };
+
+
+        // From RecognizerPopulatorInterface
+        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
+        {
+            OSCL_UNUSED_ARG(aRegistry);
+            OSCL_UNUSED_ARG(aContext);
+        };
+
+
+        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
+        {
+            OSCL_UNUSED_ARG(aRegistry);
+            OSCL_UNUSED_ARG(aContext);
+        };
+
+        // From OsclSharedLibraryInterface
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_NODE_REGISTRY_POPULATOR_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(NodeRegistryPopulatorInterface*, this);
+            }
+            return NULL;
+        };
+
+        static DownloadNodesRegistryInterface* Instance()
+        {
+            static DownloadNodesRegistryInterface nodeInterface;
+            return &nodeInterface;
+        };
+
+    private:
+
+        DownloadNodesRegistryInterface() {};
+
+};
+
+
+extern "C"
+{
+    OsclSharedLibraryInterface* PVGetInterface(void)
+    {
+        return DownloadNodesRegistryInterface::Instance();
+    }
+    void PVReleaseInterface(OsclSharedLibraryInterface*)
+    {
+        //nothing needed
+    }
+}
+
diff --git a/modules/linux_download/node_registry/src/pvmfdownloadnodereg.h b/modules/linux_download/node_registry/src/pvmfdownloadnodereg.h
new file mode 100644
index 0000000..50c9021
--- /dev/null
+++ b/modules/linux_download/node_registry/src/pvmfdownloadnodereg.h
@@ -0,0 +1,39 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMFDOWNLOADNODEREG_H_INCLUDED
+#define PVMFDOWNLOADNODEREG_H_INCLUDED
+
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+class DownloadNodesCoreLibraryLoader
+{
+    public:
+        static PVMFNodeInterface* CreateDownloadManagerNode(int32 aPriority);
+        static bool DeleteDownloadManagerNode(PVMFNodeInterface* aNode);
+    private:
+        static OsclSharedLibrary* iOsclSharedLibrary;
+};
+
+#endif // PVMFDOWNLOADNODEREG_H_INCLUDED
+
diff --git a/modules/linux_mp4/core/Android.mk b/modules/linux_mp4/core/Android.mk
new file mode 100644
index 0000000..164d4ae
--- /dev/null
+++ b/modules/linux_mp4/core/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pvmfmp4nodes.cpp
+
+
+LOCAL_MODULE := libpvmp4interface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/modules/linux_mp4/core/src \
+ 	$(PV_TOP)/modules/linux_mp4/core/build/make \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/modules/linux_mp4/core/build/make/local.mk b/modules/linux_mp4/core/build/make/local.mk
new file mode 100644
index 0000000..f91062a
--- /dev/null
+++ b/modules/linux_mp4/core/build/make/local.mk
@@ -0,0 +1,14 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4interface
+
+SRCDIR := ../../src
+
+SRCS := pvmfmp4nodes.cpp
+
+include $(MK)/library.mk
+
diff --git a/modules/linux_mp4/core/src/pvmfmp4nodes.cpp b/modules/linux_mp4/core/src/pvmfmp4nodes.cpp
new file mode 100644
index 0000000..3d29c89
--- /dev/null
+++ b/modules/linux_mp4/core/src/pvmfmp4nodes.cpp
@@ -0,0 +1,81 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_node_shared_lib_interface.h"
+
+#include "pvmf_mp4ffparser_factory.h"
+
+#include "osclconfig.h"
+
+class Mp4NodesInterface: public OsclSharedLibraryInterface,
+            public NodeSharedLibraryInterface
+{
+    public:
+        // From NodeSharedLibraryInterface
+        OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId)
+        {
+            if (KPVMFMP4FFParserNodeUuid == aNodeUuid)
+            {
+                if (PV_CREATE_NODE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(PVMFMP4FFParserNodeFactory::CreatePVMFMP4FFParserNode));
+                }
+                else if (PV_RELEASE_NODE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(PVMFMP4FFParserNodeFactory::DeletePVMFMP4FFParserNode));
+                }
+            }
+
+            return NULL;
+        };
+
+        // From OsclSharedLibraryInterface
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_NODE_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(NodeSharedLibraryInterface*, this);
+            }
+
+            return NULL;
+        };
+
+        static Mp4NodesInterface* Instance()
+        {
+            static Mp4NodesInterface nodeInterface;
+            return &nodeInterface;
+        };
+
+    private:
+
+        Mp4NodesInterface() {};
+
+};
+
+
+extern "C"
+{
+    OsclSharedLibraryInterface *PVGetInterface(void)
+    {
+        return Mp4NodesInterface::Instance();
+    }
+    void PVReleaseInterface(OsclSharedLibraryInterface*)
+    {
+        //nothing needed
+    }
+}
+
diff --git a/modules/linux_mp4/node_registry/Android.mk b/modules/linux_mp4/node_registry/Android.mk
new file mode 100644
index 0000000..a36d8d8
--- /dev/null
+++ b/modules/linux_mp4/node_registry/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pvmfmp4nodereg.cpp
+
+
+LOCAL_MODULE := libpvmp4reginterface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/modules/linux_mp4/node_registry/src \
+ 	$(PV_TOP)/modules/linux_mp4/node_registry/src \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	src/pvmfmp4nodereg.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/modules/linux_mp4/node_registry/build/make/local.mk b/modules/linux_mp4/node_registry/build/make/local.mk
new file mode 100644
index 0000000..2de8bb6
--- /dev/null
+++ b/modules/linux_mp4/node_registry/build/make/local.mk
@@ -0,0 +1,17 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4reginterface
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvmfmp4nodereg.cpp
+
+HDRS := pvmfmp4nodereg.h
+
+include $(MK)/library.mk
+
diff --git a/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.cpp b/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.cpp
new file mode 100644
index 0000000..6237af0
--- /dev/null
+++ b/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.cpp
@@ -0,0 +1,264 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/* This file defines a PV NodeSharedLibrary interface that populates the
+   registry with the nodes required for mp4 playback.
+*/
+#ifndef PVMF_NODE_SHARED_LIB_INTERFACE_H_INCLUDED
+#include "pvmf_node_shared_lib_interface.h"
+#endif
+
+#ifndef PVMF_MP4FFPARSER_FACTORY_H_INCLUDED
+#include "pvmf_mp4ffparser_factory.h"
+#endif
+
+#ifndef PVMP4FFREC_FACTORY_H_INCLUDED
+#include "pvmp4ffrec_factory.h"
+#endif
+
+#ifndef PVMF_RECOGNIZER_REGISTRY_H_INCLUDED
+#include "pvmf_recognizer_registry.h"
+#endif
+
+#ifndef OSCLCONFIG_H_INCLUDED
+#include "osclconfig.h"
+#endif
+
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
+
+#ifndef PVMFMP4NODEREG_H_INCLUDED
+#include "pvmfmp4nodereg.h"
+#endif
+
+#define MP4_LIB_NAME "libopencore_mp4local.so"
+
+#define NODE_REGISTRY_LIB_NAME_MAX_LENGTH 64
+
+typedef PVMFNodeInterface*(* LPFN_NODE_CREATE_FUNC)(int32);
+
+typedef bool (* LPFN_NODE_RELEASE_FUNC)(PVMFNodeInterface *);
+
+// init static variables before use
+OsclSharedLibrary* Mp4NodesCoreLibraryLoader::iOsclSharedLibrary = NULL;
+
+// Factory functions
+PVMFNodeInterface* Mp4NodesCoreLibraryLoader::CreateMp4ParserNode(int32 aPriority)
+{
+    if (NULL == iOsclSharedLibrary)
+    {
+        OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(MP4_LIB_NAME);
+
+        // Need to load the library for the node
+        iOsclSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
+
+        OsclLibStatus result = iOsclSharedLibrary->LoadLib();
+        if (OsclLibSuccess != result)
+        {
+            return NULL;
+        }
+    }
+
+    iOsclSharedLibrary->AddRef();
+
+    // Query for create function
+    OsclAny* interfacePtr = NULL;
+
+    iOsclSharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);
+
+    NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
+
+    OsclAny* createFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFMP4FFParserNodeUuid, PV_CREATE_NODE_INTERFACE);
+
+    LPFN_NODE_CREATE_FUNC nodeCreateFunc = OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp);
+
+    if (NULL != nodeCreateFunc)
+    {
+        // call the real node factory function
+        return (*(nodeCreateFunc))(aPriority);
+    }
+    return NULL;
+}
+
+
+bool Mp4NodesCoreLibraryLoader::DeleteMp4ParserNode(PVMFNodeInterface* aNode)
+{
+    bool bStatus = false;
+
+    if (NULL != iOsclSharedLibrary)
+    {
+        // Query for release function
+        OsclAny* interfacePtr = NULL;
+
+        iOsclSharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);
+
+        NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
+
+        OsclAny* releaseFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFMP4FFParserNodeUuid, PV_RELEASE_NODE_INTERFACE);
+
+        LPFN_NODE_RELEASE_FUNC nodeReleaseFunc = OSCL_DYNAMIC_CAST(bool (*)(PVMFNodeInterface*), releaseFuncTemp);
+
+        if (NULL != nodeReleaseFunc)
+        {
+            bStatus = (*(nodeReleaseFunc))(aNode);
+        }
+
+        iOsclSharedLibrary->RemoveRef();
+
+        if (OsclLibSuccess == iOsclSharedLibrary->Close())
+        {
+            // Close will unload the library if refcount is 0
+            OSCL_DELETE(iOsclSharedLibrary);
+            iOsclSharedLibrary = NULL;
+        }
+    }
+
+    return bStatus;
+}
+
+class Mp4NodesRegistryInterface: public OsclSharedLibraryInterface,
+            public NodeRegistryPopulatorInterface,
+            public RecognizerPopulatorInterface
+{
+    public:
+
+        // From NodeRegistryPopulatorInterface
+        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
+        {
+            PVPlayerNodeInfo nodeinfo;
+
+            OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname = MP4_LIB_NAME;
+
+            Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
+
+            //For PVMFMP4FFParserNode
+            nodeinfo.iInputTypes.clear();
+            nodeinfo.iInputTypes.push_back(PVMF_MIME_MPEG4FF);
+            nodeinfo.iNodeUUID = KPVMFMP4FFParserNodeUuid;
+            nodeinfo.iOutputType.clear();
+            nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+            nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
+            nodeinfo.iNodeCreateFunc = (Mp4NodesCoreLibraryLoader::CreateMp4ParserNode);
+            nodeinfo.iNodeReleaseFunc = (Mp4NodesCoreLibraryLoader::DeleteMp4ParserNode);
+
+            aRegistry->RegisterNode(nodeinfo);
+
+            nodeList->push_back(nodeinfo);
+
+            aContext = (OsclAny *)nodeList;
+
+        };
+
+        // From NodeRegistryPopulatorInterface
+        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
+        {
+            if (NULL != aContext)
+            {
+                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;
+
+                while (!nodeList->empty())
+                {
+                    PVPlayerNodeInfo tmpnode = nodeList->front();
+                    OSCL_DELETE(tmpnode.iSharedLibrary);
+                    aRegistry->UnregisterNode(tmpnode);
+                    nodeList->erase(nodeList->begin());
+                }
+
+                delete nodeList;
+            }
+        };
+
+
+        // From RecognizerPopulatorInterface
+        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
+        {
+            PVMFRecognizerPluginFactory* tmpfac = NULL;
+
+            Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList =
+                new Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>;
+
+            tmpfac =
+                OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVMP4FFRecognizerFactory, ()));
+            aRegistry->RegisterRecognizer(tmpfac);
+
+            pluginList->push_back(tmpfac);
+
+            aContext = (OsclAny *)pluginList;
+        };
+
+
+        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
+        {
+            if (NULL != aContext)
+            {
+                Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList = (Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>*)aContext;
+
+                while (!pluginList->empty())
+                {
+                    PVMFRecognizerPluginFactory* tmpfac = pluginList->front();
+
+                    aRegistry->UnregisterRecognizer(tmpfac);
+
+                    pluginList->erase(pluginList->begin());
+
+                    OSCL_DELETE(tmpfac);
+                }
+
+                delete pluginList;
+            }
+        };
+
+        // From OsclSharedLibraryInterface
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_NODE_REGISTRY_POPULATOR_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(NodeRegistryPopulatorInterface*, this);
+            }
+            else if (aInterfaceId == PV_RECOGNIZER_POPULATOR_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(RecognizerPopulatorInterface*, this);
+            }
+            return NULL;
+        };
+
+        static Mp4NodesRegistryInterface* Instance()
+        {
+            static Mp4NodesRegistryInterface nodeInterface;
+            return &nodeInterface;
+        };
+
+    private:
+
+        Mp4NodesRegistryInterface() {};
+
+};
+
+
+extern "C"
+{
+    OsclSharedLibraryInterface *PVGetInterface(void)
+    {
+        return Mp4NodesRegistryInterface::Instance();
+    }
+    void PVReleaseInterface(OsclSharedLibraryInterface*)
+    {
+        //nothing needed
+    }
+}
+
diff --git a/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.h b/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.h
new file mode 100644
index 0000000..9810c43
--- /dev/null
+++ b/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.h
@@ -0,0 +1,39 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMFMP4NODEREG_H_INCLUDED
+#define PVMFMP4NODEREG_H_INCLUDED
+
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+class Mp4NodesCoreLibraryLoader
+{
+    public:
+        static PVMFNodeInterface* CreateMp4ParserNode(int32 aPriority);
+        static bool DeleteMp4ParserNode(PVMFNodeInterface* aNode);
+    private:
+        static OsclSharedLibrary* iOsclSharedLibrary;
+};
+
+#endif // PVMFMP4NODEREG_H_INCLUDED
+
diff --git a/modules/linux_rtsp/core/Android.mk b/modules/linux_rtsp/core/Android.mk
new file mode 100644
index 0000000..40b8bea
--- /dev/null
+++ b/modules/linux_rtsp/core/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pvmfrtspnodes.cpp
+
+
+LOCAL_MODULE := libpvrtspinterface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/modules/linux_rtsp/core/src \
+ 	$(PV_TOP)/modules/linux_rtsp/core/build/make \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/modules/linux_rtsp/core/build/make/local.mk b/modules/linux_rtsp/core/build/make/local.mk
new file mode 100644
index 0000000..9cb9bb4
--- /dev/null
+++ b/modules/linux_rtsp/core/build/make/local.mk
@@ -0,0 +1,14 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvrtspinterface
+
+SRCDIR := ../../src
+
+SRCS := pvmfrtspnodes.cpp
+
+include $(MK)/library.mk
+
diff --git a/modules/linux_rtsp/core/src/pvmfrtspnodes.cpp b/modules/linux_rtsp/core/src/pvmfrtspnodes.cpp
new file mode 100644
index 0000000..e0e3f51
--- /dev/null
+++ b/modules/linux_rtsp/core/src/pvmfrtspnodes.cpp
@@ -0,0 +1,83 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_node_shared_lib_interface.h"
+
+#include "pvmfrtspnodereg.h"
+
+#include "pvmf_sm_node_factory.h"
+
+// Need osclconfig.h for the HAS_OSCL_LIB_SUPPORT macro for now
+#include "osclconfig.h"
+
+class StreamingNodesInterface: public OsclSharedLibraryInterface,
+            public NodeSharedLibraryInterface
+{
+    public:
+        // From NodeSharedLibraryInterface
+        OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId)
+        {
+            if (KPVMFRTSPStreamingModuleUuid == aNodeUuid)
+            {
+                if (PV_CREATE_NODE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(PVMFStreamingManagerNodeFactory::CreateStreamingManagerNode));
+                }
+                else if (PV_RELEASE_NODE_INTERFACE == aInterfaceId)
+                {
+                    return ((OsclAny*)(PVMFStreamingManagerNodeFactory::DeleteStreamingManagerNode));
+                }
+            }
+
+            return NULL;
+        };
+
+        // From OsclSharedLibraryInterface
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_NODE_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(NodeSharedLibraryInterface*, this);
+            }
+            return NULL;
+        };
+
+        static StreamingNodesInterface* Instance()
+        {
+            static StreamingNodesInterface nodeInterface;
+            return &nodeInterface;
+        };
+
+    private:
+
+        StreamingNodesInterface() {};
+
+};
+
+
+extern "C"
+{
+    OsclSharedLibraryInterface* PVGetInterface(void)
+    {
+        return StreamingNodesInterface::Instance();
+    }
+    void PVReleaseInterface(OsclSharedLibraryInterface*)
+    {
+        //nothing needed
+    }
+}
+
diff --git a/modules/linux_rtsp/node_registry/Android.mk b/modules/linux_rtsp/node_registry/Android.mk
new file mode 100644
index 0000000..51ee461
--- /dev/null
+++ b/modules/linux_rtsp/node_registry/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	src/pvmfrtspnodereg.cpp
+
+
+LOCAL_MODULE := libpvrtspreginterface
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/modules/linux_rtsp/node_registry/src \
+ 	$(PV_TOP)/modules/linux_rtsp/node_registry/src \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	src/pvmfrtspnodereg.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/modules/linux_rtsp/node_registry/build/make/local.mk b/modules/linux_rtsp/node_registry/build/make/local.mk
new file mode 100644
index 0000000..f0cdde2
--- /dev/null
+++ b/modules/linux_rtsp/node_registry/build/make/local.mk
@@ -0,0 +1,17 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvrtspreginterface
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvmfrtspnodereg.cpp
+
+HDRS := pvmfrtspnodereg.h
+
+include $(MK)/library.mk
+
diff --git a/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.cpp b/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.cpp
new file mode 100644
index 0000000..d5257c3
--- /dev/null
+++ b/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.cpp
@@ -0,0 +1,232 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/* This file defines a PV NodeSharedLibrary interface that populates the
+   registry with the streaming manager node.
+*/
+
+#ifndef PVMFRTSPNODEREG_H_INCLUDED
+#include "pvmfrtspnodereg.h"
+#endif
+
+#ifndef PVMF_NODE_SHARED_LIB_INTERFACE_H_INCLUDED
+#include "pvmf_node_shared_lib_interface.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_RECOGNIZER_REGISTRY_H_INCLUDED
+#include "pvmf_recognizer_registry.h"
+#endif
+
+#ifndef OSCLCONFIG_H_INCLUDED
+#include "osclconfig.h"
+#endif
+
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
+
+#define NODE_REGISTRY_LIB_NAME_MAX_LENGTH 64
+
+#define RTSP_LIB_NAME "libopencore_rtsp.so"
+
+typedef PVMFNodeInterface*(* LPFN_NODE_CREATE_FUNC)(int32);
+
+typedef bool (* LPFN_NODE_RELEASE_FUNC)(PVMFNodeInterface *);
+
+// init static variables before use
+OsclSharedLibrary* StreamingNodesCoreLibraryLoader::iOsclSharedLibrary = NULL;
+
+// Factory functions
+PVMFNodeInterface* StreamingNodesCoreLibraryLoader::CreateStreamingManagerNode(int32 aPriority)
+{
+    if (NULL == iOsclSharedLibrary)
+    {
+        OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(RTSP_LIB_NAME);
+
+        // Need to load the library for the node
+        iOsclSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
+
+        OsclLibStatus result = iOsclSharedLibrary->LoadLib();
+        if (OsclLibSuccess != result)
+        {
+            return NULL;
+        }
+    }
+
+    iOsclSharedLibrary->AddRef();
+
+    // Query for create function
+    OsclAny* interfacePtr = NULL;
+
+    iOsclSharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);
+
+    NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
+
+    OsclAny* createFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFRTSPStreamingModuleUuid, PV_CREATE_NODE_INTERFACE);
+
+    LPFN_NODE_CREATE_FUNC nodeCreateFunc = OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp);
+
+    if (NULL != nodeCreateFunc)
+    {
+        // call the real node factory function
+        return (*(nodeCreateFunc))(aPriority);
+    }
+    return NULL;
+}
+
+bool StreamingNodesCoreLibraryLoader::DeleteStreamingManagerNode(PVMFNodeInterface* aNode)
+{
+    bool bStatus = false;
+
+    if (NULL != iOsclSharedLibrary)
+    {
+        // Query fro release function
+        OsclAny* interfacePtr = NULL;
+
+        iOsclSharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);
+
+        NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);
+
+        OsclAny* releaseFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFRTSPStreamingModuleUuid, PV_RELEASE_NODE_INTERFACE);
+
+        LPFN_NODE_RELEASE_FUNC nodeReleaseFunc = OSCL_DYNAMIC_CAST(bool (*)(PVMFNodeInterface*), releaseFuncTemp);
+
+        if (NULL != nodeReleaseFunc)
+        {
+            bStatus = (*(nodeReleaseFunc))(aNode);
+        }
+
+        iOsclSharedLibrary->RemoveRef();
+
+        if (OsclLibSuccess == iOsclSharedLibrary->Close())
+        {
+            // Close will unload the library if refcount is 0
+            OSCL_DELETE(iOsclSharedLibrary);
+            iOsclSharedLibrary = NULL;
+        }
+    }
+
+    return bStatus;
+}
+
+
+
+class StreamingNodesRegistryInterface: public OsclSharedLibraryInterface,
+            public NodeRegistryPopulatorInterface,
+            public RecognizerPopulatorInterface
+{
+    public:
+
+        // From NodeRegistryPopulatorInterface
+        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
+        {
+            PVPlayerNodeInfo nodeinfo;
+
+            OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(RTSP_LIB_NAME);
+
+            Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
+
+            //For PVMFStreamingManagerNode
+            nodeinfo.iInputTypes.clear();
+            nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_RTSP_URL);
+            nodeinfo.iInputTypes.push_back(PVMF_MIME_DATA_SOURCE_SDP_FILE);
+            nodeinfo.iNodeUUID = KPVMFRTSPStreamingModuleUuid;
+            nodeinfo.iOutputType.clear();
+            nodeinfo.iOutputType.push_back(PVMF_MIME_FORMAT_UNKNOWN);
+            nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
+            nodeinfo.iNodeCreateFunc = (StreamingNodesCoreLibraryLoader::CreateStreamingManagerNode);
+            nodeinfo.iNodeReleaseFunc = (StreamingNodesCoreLibraryLoader::DeleteStreamingManagerNode);
+
+            aRegistry->RegisterNode(nodeinfo);
+
+            nodeList->push_back(nodeinfo);
+
+            aContext = (OsclAny *)nodeList;
+        };
+
+        // From NodeRegistryPopulatorInterface
+        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
+        {
+            if (NULL != aContext)
+            {
+                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;
+
+                while (!nodeList->empty())
+                {
+                    PVPlayerNodeInfo tmpnode = nodeList->front();
+                    OSCL_DELETE(tmpnode.iSharedLibrary);
+                    aRegistry->UnregisterNode(tmpnode);
+                    nodeList->erase(nodeList->begin());
+                }
+
+                delete nodeList;
+            }
+        };
+
+
+        // From RecognizerPopulatorInterface
+        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
+        {
+            OSCL_UNUSED_ARG(aRegistry);
+            OSCL_UNUSED_ARG(aContext);
+        };
+
+
+        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
+        {
+            OSCL_UNUSED_ARG(aRegistry);
+            OSCL_UNUSED_ARG(aContext);
+        };
+
+        // From OsclSharedLibraryInterface
+        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
+        {
+            if (aInterfaceId == PV_NODE_REGISTRY_POPULATOR_INTERFACE)
+            {
+                return OSCL_STATIC_CAST(NodeRegistryPopulatorInterface*, this);
+            }
+            return NULL;
+        };
+
+        static StreamingNodesRegistryInterface* Instance()
+        {
+            static StreamingNodesRegistryInterface nodeInterface;
+            return &nodeInterface;
+        };
+
+    private:
+
+        StreamingNodesRegistryInterface() {};
+};
+
+
+extern "C"
+{
+    OsclSharedLibraryInterface* PVGetInterface(void)
+    {
+        return StreamingNodesRegistryInterface::Instance();
+    }
+    void PVReleaseInterface(OsclSharedLibraryInterface*)
+    {
+        //nothing needed
+    }
+}
+
diff --git a/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.h b/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.h
new file mode 100644
index 0000000..36e6422
--- /dev/null
+++ b/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.h
@@ -0,0 +1,40 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMFRTSPNODEREG_H_INCLUDED
+#define PVMFRTSPNODEREG_H_INCLUDED
+
+#ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
+#include "oscl_shared_library.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#define KPVMFRTSPStreamingModuleUuid PVUuid(0x608aea40,0x9ca0,0x11dd,0xbd,0x92,0x00,0x02,0xa5,0xd5,0xc5,0x1b)
+class StreamingNodesCoreLibraryLoader
+{
+    public:
+        static PVMFNodeInterface* CreateStreamingManagerNode(int32 aPriority);
+        static bool DeleteStreamingManagerNode(PVMFNodeInterface* aNode);
+    private:
+        static OsclSharedLibrary* iOsclSharedLibrary;
+};
+
+#endif // PVMFRTSPNODEREG_H_INCLUDED
+
diff --git a/nodes/common/Android.mk b/nodes/common/Android.mk
index 77fcad2..4ab5656 100644
--- a/nodes/common/Android.mk
+++ b/nodes/common/Android.mk
@@ -1,40 +1,50 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_SRC_FILES := \
+ 	
 
 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
 
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/common/include \
-	$(PV_TOP)//nodes/common/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/common/src \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_common_audio_decnode.h \
-	include/pvmf_composer_size_and_duration.h \
-	include/pvmf_data_source_init_extension.h \
-	include/pvmf_data_source_playback_control.h \
-	include/pvmf_data_source_direction_control.h \
-	include/pvmf_download_data_source.h \
-	include/pvmf_download_progress_interface.h \
-	include/pvmf_ffparsernode_extension.h \
-	include/pvmf_media_presentation_info.h \
-	include/pvmf_meta_data_extension.h \
-	include/pvmf_mp4_progdownload_support_extension.h \
-	include/pvmf_node_shared_lib_interface.h \
-	include/pvmf_node_registry.h \
-	include/pvmf_nodes_sync_control.h \
-	include/pvmf_track_level_info_extension.h \
-	include/pvmf_track_selection_extension.h \
-	include/pvmf_local_data_source.h \
-	include/pvmf_source_context_data.h \
-	include/pv_player_node_registry_interface.h \
-	include/pvmf_streaming_data_source.h
+ 	include/pvmf_composer_size_and_duration.h \
+ 	include/pvmf_data_source_init_extension.h \
+ 	include/pvmf_data_source_playback_control.h \
+ 	include/pvmf_data_source_direction_control.h \
+ 	include/pvmf_download_data_source.h \
+ 	include/pvmf_download_progress_interface.h \
+ 	include/pvmf_ffparsernode_extension.h \
+ 	include/pvmf_media_presentation_info.h \
+ 	include/pvmf_meta_data_extension.h \
+ 	include/pvmf_mp4_progdownload_support_extension.h \
+ 	include/pvmf_node_shared_lib_interface.h \
+ 	include/pvmf_node_registry.h \
+ 	include/pvmf_nodes_sync_control.h \
+ 	include/pvmf_track_level_info_extension.h \
+ 	include/pvmf_track_selection_extension.h \
+ 	include/pvmf_local_data_source.h \
+ 	include/pvmf_source_context_data.h \
+ 	include/pv_player_node_registry_interface.h \
+ 	include/pvmf_streaming_data_source.h \
+ 	include/pvmfamrencnode_extension.h \
+ 	include/pvmp4h263encextension.h \
+ 	include/pvmf_format_progdownload_support_extension.h
 
 include $(BUILD_COPY_HEADERS)
-
diff --git a/nodes/common/build/make/local.mk b/nodes/common/build/make/local.mk
new file mode 100644
index 0000000..6d4e866
--- /dev/null
+++ b/nodes/common/build/make/local.mk
@@ -0,0 +1,40 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := 
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := 
+
+HDRS :=  pvmf_common_audio_decnode.h \
+	pvmf_composer_size_and_duration.h \
+	pvmf_data_source_init_extension.h \
+	pvmf_data_source_playback_control.h \
+	pvmf_data_source_direction_control.h \
+	pvmf_download_data_source.h \
+	pvmf_download_progress_interface.h \
+	pvmf_ffparsernode_extension.h \
+	pvmf_media_presentation_info.h \
+	pvmf_meta_data_extension.h \
+	pvmf_mp4_progdownload_support_extension.h \
+	pvmf_node_shared_lib_interface.h \
+	pvmf_node_registry.h \
+	pvmf_nodes_sync_control.h \
+	pvmf_track_level_info_extension.h \
+	pvmf_track_selection_extension.h \
+	pvmf_local_data_source.h \
+	pvmf_source_context_data.h \
+	pv_player_node_registry_interface.h \
+	pvmf_streaming_data_source.h \
+	pvmfamrencnode_extension.h \
+	pvmp4h263encextension.h \
+        pvmf_format_progdownload_support_extension.h
+
+include $(MK)/library.mk
diff --git a/nodes/common/build/make/makefile b/nodes/common/build/make/makefile
deleted file mode 100644
index 6eaff9c..0000000
--- a/nodes/common/build/make/makefile
+++ /dev/null
@@ -1,80 +0,0 @@
-# Warning: This is just for the header installed in the common directory
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = 
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS +=
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =
-
-
-HDRS =  pvmf_common_audio_decnode.h \
-	pvmf_composer_size_and_duration.h \
-	pvmf_data_source_init_extension.h \
-	pvmf_data_source_playback_control.h \
-	pvmf_data_source_direction_control.h \
-	pvmf_download_data_source.h \
-	pvmf_download_progress_interface.h \
-	pvmf_ffparsernode_extension.h \
-	pvmf_media_presentation_info.h \
-	pvmf_meta_data_extension.h \
-	pvmf_mp4_progdownload_support_extension.h \
-	pvmf_node_shared_lib_interface.h \
-	pvmf_node_registry.h \
-	pvmf_nodes_sync_control.h \
-	pvmf_track_level_info_extension.h \
-	pvmf_track_selection_extension.h \
-	pvmf_local_data_source.h \
-	pvmf_source_context_data.h \
-	pv_player_node_registry_interface.h \
-	pvmf_streaming_data_source.h 
- 
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-install:: headers-install
-
- 
diff --git a/nodes/common/include/pv_player_node_registry_interface.h b/nodes/common/include/pv_player_node_registry_interface.h
index e9d4857..212ddd5 100644
--- a/nodes/common/include/pv_player_node_registry_interface.h
+++ b/nodes/common/include/pv_player_node_registry_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,16 +46,12 @@
 #include "pv_uuid.h"
 #endif
 
-#ifdef HAS_OSCL_LIB_SUPPORT
 #ifndef PVMF_RECOGNIZER_PLUGIN_H_INCLUDED
 #include "pvmf_recognizer_plugin.h"
 #endif
-#endif
 
-// FORWARD DECLARATION
 class OsclSharedLibrary;
 
-
 // CLASS DECLARATION
 /**
  * PVPlayerNodeInfo is a class which will maintain node info
@@ -68,11 +64,9 @@
          **/
         PVPlayerNodeInfo()
         {
-#ifdef HAS_OSCL_LIB_SUPPORT
-            iSharedLibrary = NULL;
             iNodeCreateFunc = NULL;
             iNodeReleaseFunc = NULL;
-#endif
+            iSharedLibrary = NULL;
         }
 
         /**
@@ -149,7 +143,6 @@
          **/
         virtual void RegisterNode(const PVPlayerNodeInfo& aNodeInfo) = 0;
 
-#ifdef HAS_OSCL_LIB_SUPPORT
         /**
          * The UnregisterNode for PVPlayerNodeRegistry. Used for unregistering nodes through the NodeInfo object.
          *
@@ -157,10 +150,8 @@
          *
          **/
         virtual void UnregisterNode(const PVPlayerNodeInfo& aNodeInfo) = 0;
-#endif
 };
 
-#ifdef HAS_OSCL_LIB_SUPPORT
 class PVPlayerRecognizerRegistryInterface
 {
     public:
@@ -181,7 +172,60 @@
         virtual void UnregisterRecognizer(PVMFRecognizerPluginFactory* aRecognizerPluginFactory) = 0;
 
 };
-#endif
+
+/*
+** NodeRegistryPopulatorInterface is an abstract interface that is used to register and
+** unregister nodes in a registry.  A registry uses this interface to allow registry populators
+** to add and remove objects in the registry.
+*/
+#define PV_NODE_REGISTRY_POPULATOR_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
+class NodeRegistryPopulatorInterface
+{
+    public:
+        /*
+        ** RegisterAllNodes will register one or more nodes in the registry
+        ** @param aRegistry: the registry
+        ** @param aContext (out): a returned context value.  The registry must
+        **    include this value in the UnregisterAllNodes call.
+        */
+        virtual void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext) = 0;
+
+        /*
+        ** UnregisterAllNodes will unregister one or more nodes in the registry
+        ** @param aRegistry: the registry
+        ** @param aContext (in): the context value that was returned in the RegisterAllNodes
+        **    call.
+        */
+        virtual void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext) = 0;
+};
+
+/*
+** RecognizerPopulatorInterface is an abstract interface that is used to register and
+** unregister recognizers in a registry.  A registry uses this interface to allow registry populators
+** to add and remove objects in the registry.
+*/
+#define PV_RECOGNIZER_POPULATOR_INTERFACE OsclUuid(0x6d3413a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
+class RecognizerPopulatorInterface
+{
+    public:
+        /*
+        ** RegisterAllRecognizers will register one or more recognizers in the registry
+        ** @param aRegistry: the registry
+        ** @param aContext (out): a returned context value.  The registry must
+        **    include this value in the UnregisterAllRecognizers call.
+        */
+        virtual void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext) = 0;
+
+        /*
+        ** UnregisterAllNodes will unregister one or more recognizers in the registry
+        ** @param aRegistry: the registry
+        ** @param aContext (in): the context value that was returned in the RegisterAllRecognizers
+        **    call.
+        */
+        virtual void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext) = 0;
+};
 
 #endif // PV_PLAYER_NODE_REGISTRY_INTERFACE_H_INCLUDED
 
diff --git a/nodes/common/include/pvmf_common_audio_decnode.h b/nodes/common/include/pvmf_common_audio_decnode.h
index 84c3315..d846d8d 100644
--- a/nodes/common/include/pvmf_common_audio_decnode.h
+++ b/nodes/common/include/pvmf_common_audio_decnode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_composer_size_and_duration.h b/nodes/common/include/pvmf_composer_size_and_duration.h
index 3728cd8..e6cd6c9 100644
--- a/nodes/common/include/pvmf_composer_size_and_duration.h
+++ b/nodes/common/include/pvmf_composer_size_and_duration.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_data_source_direction_control.h b/nodes/common/include/pvmf_data_source_direction_control.h
index ac41c93..76749d5 100644
--- a/nodes/common/include/pvmf_data_source_direction_control.h
+++ b/nodes/common/include/pvmf_data_source_direction_control.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,8 +39,9 @@
 #ifndef PVMF_RETURN_CODES_H_INCLUDED
 #include "pvmf_return_codes.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #define PVMF_DATA_SOURCE_DIRECTION_CONTROL_INTERFACE_MIMETYPE "pvxxx/pvmf/pvmfdatasourcedirectioncontrolinterface"
@@ -80,7 +81,7 @@
                 int32 aDirection,
                 PVMFTimestamp& aActualNPT,
                 PVMFTimestamp& aActualMediaDataTS,
-                OsclTimebase* aTimebase = NULL,
+                PVMFTimebase* aTimebase = NULL,
                 OsclAny* aContext = NULL) = 0;
 
 };
diff --git a/nodes/common/include/pvmf_data_source_init_extension.h b/nodes/common/include/pvmf_data_source_init_extension.h
index ffcd7c5..a4443e0 100644
--- a/nodes/common/include/pvmf_data_source_init_extension.h
+++ b/nodes/common/include/pvmf_data_source_init_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@
 #ifndef OSCL_STRING_H_INCLUDED
 #include "oscl_string.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PV_UUID_H_INCLUDED
 #include "pv_uuid.h"
@@ -67,18 +67,18 @@
         /**
          * Sets the client playback clock for the use of the data source.
          *
-         * @param aClientClock Pointer to OsclClock
+         * @param aClientClock Pointer to PVMFMediaClock
          * @return PVMFSuccess if successfully set. PVMFFailure for all other errors.
          */
-        virtual PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock) = 0;
+        virtual PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock) = 0;
 
         /**
          * Sets the estimated server clock for the use of the data source.
          *
-         * @param aClientClock Pointer to OsclClock
+         * @param aClientClock Pointer to PVMFMediaClock
          * @return PVMFSuccess if successfully set. PVMFFailure for all other errors.
          */
-        virtual PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock) = 0;
+        virtual PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock) = 0;
 
 };
 
diff --git a/nodes/common/include/pvmf_data_source_playback_control.h b/nodes/common/include/pvmf_data_source_playback_control.h
index 12138da..083bfd9 100644
--- a/nodes/common/include/pvmf_data_source_playback_control.h
+++ b/nodes/common/include/pvmf_data_source_playback_control.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,8 +39,10 @@
 #ifndef PVMF_RETURN_CODES_H_INCLUDED
 #include "pvmf_return_codes.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #define PVMF_DATA_SOURCE_PLAYBACK_CONTROL_INTERFACE_MIMETYPE "pvxxx/pvmf/pvmfdatasourceplaybackcontrolinterface"
@@ -249,11 +251,58 @@
          **/
         virtual PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId,
                                                 int32 aRate,
-                                                OsclTimebase* aTimebase = NULL,
+                                                PVMFTimebase* aTimebase = NULL,
                                                 OsclAny* aContext = NULL) = 0;
 
-        PVMFTimestamp iDummy;
+        /**
+         * Synchronous method to compute skip timestamp based on actual and target NPT values
+         * Not all source nodes need implement this. Some source node (viz. 3GPP RTSP Streaming)
+         * are "realtime" sources and are constrained by remote server's datatransfer rate,which
+         * typically is realtime. In those cases it makes sense to start rendering from actualNPT
+         * immaterial how engine's repositioning tunables are configured.
+         *
+         * @param aTargetNPT Target normal-play-time timestamp in milliseconds of the location where the
+         *                   data source will be repositioned to, as provided in a prior SetDataSourcePosition
+         *                   call.
+         * @param aActualNPT The actual normal-play-time timestamp after repositioning as provided by the
+         *                   source node in a prior SetDataSourcePosition call.
+         * @param aActualMediaDataTS The media data timestamp corresponding to the actual NPT time. This
+         *                           will be the timestamp of the first media data after repositioning, as
+         *                           provided by the source node.
+         * @param aSkipTimeStamp Computed by source node based on aTargetNPT, aActualNPT and aActualMediaDataTS.
+         * @param aStartNPT Computed by source node based on aTargetNPT, aActualNPT and aActualMediaDataTS.
+         * @returns PVMFErrNotSupported if the source node does not care about skip timestamps, else one
+         * of PVMF return codes.
+         **/
+        virtual PVMFStatus ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+                                                PVMFTimestamp aActualNPT,
+                                                PVMFTimestamp aActualMediaDataTS,
+                                                PVMFTimestamp& aSkipTimeStamp,
+                                                PVMFTimestamp& aStartNPT)
+        {
+            OSCL_UNUSED_ARG(aTargetNPT);
+            OSCL_UNUSED_ARG(aActualNPT);
+            OSCL_UNUSED_ARG(aActualMediaDataTS);
+            OSCL_UNUSED_ARG(aSkipTimeStamp);
+            OSCL_UNUSED_ARG(aStartNPT);
+            return PVMFErrNotSupported;
+        }
 
+        /**
+         * Synchronous method to notify the Target NPT to the Source Node. Some source node
+         * (viz. 3GPP RTSP Streaming) will need to know the Target NPT before Prepare is
+         * called on the node to support PipeLining feature, in which the Source node
+         * will send a SETUP and PLAY request back to back to the streaming server's supporting
+         * PipeLining mode.
+         *
+         * @param aTargetNPT Target normal-play-time timestamp in milliseconds of the location where the
+         *                   data source will be repositioned to.
+         */
+        virtual PVMFStatus NotifyTargetPositionSync(PVMFTimestamp aTargetNPT)
+        {
+            OSCL_UNUSED_ARG(aTargetNPT);
+            return PVMFErrNotSupported;
+        }
 };
 
 #endif // PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
diff --git a/nodes/common/include/pvmf_download_data_source.h b/nodes/common/include/pvmf_download_data_source.h
index cb2ca44..70fcd1f 100644
--- a/nodes/common/include/pvmf_download_data_source.h
+++ b/nodes/common/include/pvmf_download_data_source.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -107,6 +107,7 @@
 
 class CPVXInfo;
 
+//Source data for Fasttrack download (format type PVMF_DATA_SOURCE_PVX_FILE)
 class PVMFDownloadDataSourcePVX : public PVInterface
 {
     public:
diff --git a/nodes/common/include/pvmf_download_progress_interface.h b/nodes/common/include/pvmf_download_progress_interface.h
index 35e59be..c3e2711 100644
--- a/nodes/common/include/pvmf_download_progress_interface.h
+++ b/nodes/common/include/pvmf_download_progress_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@
 #ifndef OSCL_SHARED_PTR_H_INCLUDED
 #include "oscl_shared_ptr.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PV_UUID_H_INCLUDED
 #include "pv_uuid.h"
@@ -82,9 +82,9 @@
         /**
          * Returns the download progress clock
          *
-         * @return OsclSharedPtr<OsclClock> - the shared pointer to the download progress clock.
+         * @return OsclSharedPtr<PVMFMediaClock> - the shared pointer to the download progress clock.
          */
-        virtual OsclSharedPtr<OsclClock> getDownloadProgressClock() = 0;
+        virtual OsclSharedPtr<PVMFMediaClock> getDownloadProgressClock() = 0;
 
         /**
          * Requests notification when playback can continue uninterrupted based on the
diff --git a/nodes/common/include/pvmf_ffparsernode_extension.h b/nodes/common/include/pvmf_ffparsernode_extension.h
index 3088b40..dbf3e0d 100644
--- a/nodes/common/include/pvmf_ffparsernode_extension.h
+++ b/nodes/common/include/pvmf_ffparsernode_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_format_progdownload_support_extension.h b/nodes/common/include/pvmf_format_progdownload_support_extension.h
index f532e3e..cbdb12f 100644
--- a/nodes/common/include/pvmf_format_progdownload_support_extension.h
+++ b/nodes/common/include/pvmf_format_progdownload_support_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@
 #ifndef OSCL_SHARED_PTR_H_INCLUDED
 #include "oscl_shared_ptr.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PV_UUID_H_INCLUDED
 #include "pv_uuid.h"
diff --git a/nodes/common/include/pvmf_local_data_source.h b/nodes/common/include/pvmf_local_data_source.h
index c072645..2700639 100644
--- a/nodes/common/include/pvmf_local_data_source.h
+++ b/nodes/common/include/pvmf_local_data_source.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_media_presentation_info.h b/nodes/common/include/pvmf_media_presentation_info.h
index 8c7b663..4e13bb7 100644
--- a/nodes/common/include/pvmf_media_presentation_info.h
+++ b/nodes/common/include/pvmf_media_presentation_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_meta_data_extension.h b/nodes/common/include/pvmf_meta_data_extension.h
index 4b3a530..632a7ef 100644
--- a/nodes/common/include/pvmf_meta_data_extension.h
+++ b/nodes/common/include/pvmf_meta_data_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_mp4_progdownload_support_extension.h b/nodes/common/include/pvmf_mp4_progdownload_support_extension.h
index 6f17593..10cc0a1 100644
--- a/nodes/common/include/pvmf_mp4_progdownload_support_extension.h
+++ b/nodes/common/include/pvmf_mp4_progdownload_support_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@
 #ifndef OSCL_SHARED_PTR_H_INCLUDED
 #include "oscl_shared_ptr.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PV_UUID_H_INCLUDED
 #include "pv_uuid.h"
diff --git a/nodes/common/include/pvmf_node_registry.h b/nodes/common/include/pvmf_node_registry.h
index f178b60..9d473b6 100644
--- a/nodes/common/include/pvmf_node_registry.h
+++ b/nodes/common/include/pvmf_node_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_node_shared_lib_interface.h b/nodes/common/include/pvmf_node_shared_lib_interface.h
index 1e33d3b..b77e2d3 100644
--- a/nodes/common/include/pvmf_node_shared_lib_interface.h
+++ b/nodes/common/include/pvmf_node_shared_lib_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,31 +28,10 @@
 #include "pv_player_node_registry_interface.h"
 #endif
 
-#define PV_NODE_REGISTRY_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
-#define PV_RECOGNIZER_INTERFACE OsclUuid(0x6d3413a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
 #define PV_CREATE_NODE_INTERFACE OsclUuid(0xac8703a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
 #define PV_RELEASE_NODE_INTERFACE OsclUuid(0xac8703a1,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
 #define PV_NODE_INTERFACE OsclUuid(0xac8703a2,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66)
 
-class NodeRegistrySharedLibraryInterface
-{
-    public:
-        virtual void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext) = 0;
-
-        virtual void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext) = 0;
-};
-
-// A simple macro that facilitates the packaging of a node plugin
-// The usage would be
-// DECLARE_NODE_SHARED_LIBRARY(new NodeSharedLibraryInterface());
-//
-#define DECLARE_NODE_SHARED_LIBRARY(INTERFACE_OBJECT) \
-    extern "C" {\
-        OsclAny *GetInterface (void) { \
-        printf("\nIN THE SUPPORTED LIBS GET INTERFACE METHOD\n"); \
-        return INTERFACE_OBJECT; \
-        }\
-    }
 
 class NodeSharedLibraryInterface
 {
@@ -68,26 +47,5 @@
         virtual OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId) = 0;
 };
 
-class RecognizerSharedLibraryInterface
-{
-    public:
-        virtual void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext) = 0;
-
-        virtual void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext) = 0;
-};
-
-// A simple macro that facilitates the packaging of a plugin
-// The usage would be
-// DECLARE_SHARED_LIBRARY(new MyCustomSharedLibraryInterface());
-//
-#define DECLARE_SHARED_LIBRARY(INTERFACE_OBJECT) \
-        extern "C" {\
-        OsclAny *GetInterface (void) { \
-                printf("\nIN THE SUPPORTED LIBS GET INTERFACE METHOD\n"); \
-                return INTERFACE_OBJECT; \
-            }\
-    }
-
-
 #endif // PVMF_NODE_SHARED_LIB_INTERFACE_H_INCLUDED
 
diff --git a/nodes/common/include/pvmf_nodes_sync_control.h b/nodes/common/include/pvmf_nodes_sync_control.h
index 7975de1..faf3594 100644
--- a/nodes/common/include/pvmf_nodes_sync_control.h
+++ b/nodes/common/include/pvmf_nodes_sync_control.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@
 #define PvmfNodesSyncControlUuid PVUuid(0xd4d82607,0xbca5,0x43e3,0x88,0x30,0xa3,0x1b,0x36,0x0a,0xb5,0xf2)
 
 // Forward declarations
-class OsclClock;
+class PVMFMediaClock;
 
 /**
  * Configuration interface used by data sink nodes to synchronize rendering of media data
@@ -58,7 +58,7 @@
          * @param aClock Clock object to which media data is synchronized.
          * @return Completion status.
          */
-        virtual PVMFStatus SetClock(OsclClock* aClock) = 0;
+        virtual PVMFStatus SetClock(PVMFMediaClock* aClock) = 0;
 
         /**
          * Notifies the data sink node that clock rate is changing. Also allows
@@ -117,12 +117,8 @@
          * PVMFNodeCmdStatusObserver of the node implementing this interface.
          *
          * @param aSessionId Session ID returned when creating a session with the node
-         * @param aStartingTimestamp Timestamp at which the new media data will start. Media data with timestamps before the starting time
-         *                           is considered to be old data and will be flushed out.
          * @param aResumeTimestamp Timestamp at which normal evaluation of timestamp against the clock will resume. This timestamp
          *                         must be greater than or equal to aStartingTimestamp
-         * @param aRenderSkippedData When set to true, SyncMediaData API will return 0 for all timestamps after the starting time but
-         *        before the resume time.
          * @param aPlayBackPositionContinuous When set to true, this is meant to notify the data sink that
          *        this skip media data call does not relate to a change in source position. Or in
          *        other words source is continuous. Example: Smart Forward Repositioning (SFR). In this case the source node
@@ -131,10 +127,8 @@
          * @returns A unique command id for asynchronous completion.
          */
         virtual PVMFCommandId SkipMediaData(PVMFSessionId aSessionId,
-                                            PVMFTimestamp aStartingTimestamp,
                                             PVMFTimestamp aResumeTimestamp,
                                             uint32 aStreamID = 0,
-                                            bool aRenderSkippedData = false,
                                             bool aPlayBackPositionContinuous = false,
                                             OsclAny* aContext = NULL) = 0;
 };
diff --git a/nodes/common/include/pvmf_source_context_data.h b/nodes/common/include/pvmf_source_context_data.h
index c2a3751..0732779 100644
--- a/nodes/common/include/pvmf_source_context_data.h
+++ b/nodes/common/include/pvmf_source_context_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,10 @@
 #define PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID PVUuid(0x0b8a0087,0xd539,0x4ee0,0x88,0x8d,0x0c,0x1c,0x70,0xf0,0x33,0x59)
 #define PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID PVUuid(0x731e4269,0x849b,0x4123,0x92,0x6f,0xaf,0x27,0xc9,0x8a,0x2e,0xab)
 #define PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_PVX_UUID PVUuid(0x3dbb1b51,0x49ea,0x4933,0xa6,0xec,0x26,0x97,0x43,0x12,0xb6,0xd6)
+#define PVMF_SOURCE_CONTEXT_DATA_PVR_UUID PVUuid(0x442059a2,0x76b6,0x11dc,0x83,0x14,0x08,0x00,0x20,0x0c,0x9a,0x66)
+#define PVMF_SOURCE_CONTEXT_DATA_PACKETSOURCE_UUID PVUuid(0x7f064f8c,0xa90d,0x11dc,0x83,0x14,0x08,0x00,0x20,0x0c,0x9a,0x66)
+#define PVMF_SOURCE_CONTEXT_DATA_PVRLOCALPLAYBACK_UUID PVUuid(0x3f9c615e,0x31e2,0x474c,0x9a,0xdd,0x29,0xc6,0x1d,0xd0,0x7e,0xad)
+//3f9c615e-31e2-474c-9add-29c61dd07ead
 
 class OsclFileHandle;
 class PVMFCPMPluginAccessInterfaceFactory;
@@ -60,6 +64,7 @@
             iPreviewMode = false;
             iIntent = BITMASK_PVMF_SOURCE_INTENT_PLAY;
             iContentAccessFactory = NULL;
+            iRecognizerDataStreamFactory = NULL;
         };
 
         PVMFSourceContextDataCommon(const PVMFSourceContextDataCommon& aSrc) : PVInterface(aSrc)
@@ -117,15 +122,17 @@
         //passed in will be used for play back or just for metadata retrieval
         uint32 iIntent;
 
-        //HTTP proxy name, either ip or dns,
+        //HTTP proxy name, either ip or dns, for DRM License Acquisition purposes
         OSCL_wHeapString<OsclMemAllocator> iDRMLicenseProxyName;
 
-        //HTTP proxy port,
+        //HTTP proxy port, for DRM for DRM License Acquisition purposes
         int32 iDRMLicenseProxyPort;
 
         //external datastream for usecases where the input file is controlled by the app
         PVMFCPMPluginAccessInterfaceFactory* iContentAccessFactory;
 
+        //external datastream for usecases where input file to be recognized is controlled by the app
+        PVMFCPMPluginAccessInterfaceFactory* iRecognizerDataStreamFactory;
 
     private:
         void MyCopy(const PVMFSourceContextDataCommon& aSrc)
@@ -137,6 +144,7 @@
             iDRMLicenseProxyName	= aSrc.iDRMLicenseProxyName;
             iDRMLicenseProxyPort	= aSrc.iDRMLicenseProxyPort;
             iContentAccessFactory	= aSrc.iContentAccessFactory;
+            iRecognizerDataStreamFactory = aSrc.iRecognizerDataStreamFactory;
         };
 };
 
@@ -191,6 +199,7 @@
 
         //Optional logging url.
         //When present, streaming stats will be sent to this URL.
+        //Typically applies to MS HTTP Streaming sessions
         OSCL_wHeapString<OsclMemAllocator> iStreamStatsLoggingURL;
 
         //HTTP proxy name, either ip or dns
@@ -304,6 +313,7 @@
 
 class CPVXInfo;
 
+//Source data for Fasttrack download (format type PVMF_DATA_SOURCE_PVX_FILE)
 class PVMFSourceContextDataDownloadPVX : public PVInterface
 {
     public:
@@ -376,6 +386,252 @@
         };
 };
 
+
+//Source Context Data for PVR
+class PVMFPVRControl;
+
+class PVMFSourceContextDataPVR : public PVInterface
+{
+    public:
+        //default constructor
+        PVMFSourceContextDataPVR()
+        {
+            iRefCounter = 0;
+            iPVMFPVRControl = NULL;
+            iLiveBufferSizeInSeconds = 0;
+        };
+
+        PVMFSourceContextDataPVR(const PVMFSourceContextDataPVR& aSrc) : PVInterface(aSrc)
+        {
+            iRefCounter = 0;
+            iPVMFPVRControl = NULL;
+            iLiveBufferSizeInSeconds = 0;
+            MyCopy(aSrc);
+        };
+
+        PVMFSourceContextDataPVR& operator=(const PVMFSourceContextDataPVR& aSrc)
+        {
+            if (&aSrc != this)
+            {
+                MyCopy(aSrc);
+            }
+            return *this;
+        };
+
+        void SetPVRControl(PVMFPVRControl* aPVMFPVRControl)
+        {
+            iPVMFPVRControl = aPVMFPVRControl;
+        }
+
+        PVMFPVRControl* GetPVRControl()
+        {
+            return iPVMFPVRControl;
+        }
+
+
+//	void SetLiveBufferSizeInSeconds(uint32 aLiveBufferSizeInSeconds)
+//	{
+//		iLiveBufferSizeInSeconds = aLiveBufferSizeInSeconds;
+//	}
+
+//	uint32 LiveBufferSizeInSeconds()
+//	{
+//		return iLiveBufferSizeInSeconds;
+//	}
+
+        /* From PVInterface */
+        void addRef()
+        {
+            iRefCounter++;
+        }
+        void removeRef()
+        {
+            iRefCounter--;
+        }
+
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            if (uuid == PVUuid(PVMF_SOURCE_CONTEXT_DATA_PVR_UUID))
+            {
+                iface = this;
+                return true;
+            }
+            else
+            {
+                iface = NULL;
+                return false;
+            }
+        }
+
+    private:
+        void MyCopy(const PVMFSourceContextDataPVR& aSrc)
+        {
+            // \todo: check this copy constructor
+            iPVMFPVRControl = aSrc.iPVMFPVRControl;
+            iLiveBufferSizeInSeconds = aSrc.iLiveBufferSizeInSeconds;
+        };
+
+        // reference counter
+        int32 iRefCounter;
+
+
+        // This class doesn't own PVMFPVRControl
+        PVMFPVRControl* iPVMFPVRControl;
+
+        // temp buffer size in seconds
+        uint32 iLiveBufferSizeInSeconds;
+};
+
+
+class PVMFPacketSource;
+
+class PVMFSourceContextDataPacketSource : public PVInterface
+{
+    public:
+        //default constructor
+        PVMFSourceContextDataPacketSource()
+        {
+            iRefCounter = 0;
+            iPacketSourcePlugin = NULL;
+        };
+
+        PVMFSourceContextDataPacketSource(const PVMFSourceContextDataPacketSource& aSrc) : PVInterface(aSrc)
+        {
+            iRefCounter = 0;
+            MyCopy(aSrc);
+        };
+
+        PVMFSourceContextDataPacketSource& operator=(const PVMFSourceContextDataPacketSource& aSrc)
+        {
+            if (&aSrc != this)
+            {
+                MyCopy(aSrc);
+            }
+            return *this;
+        };
+
+        void SetPacketSourcePlugin(PVMFPacketSource* aPacketSourcePlugin)
+        {
+            iPacketSourcePlugin = aPacketSourcePlugin;
+        }
+
+        PVMFPacketSource* GetPacketSourcePlugin()
+        {
+            return iPacketSourcePlugin;
+        }
+
+        /* From PVInterface */
+        void addRef()
+        {
+            iRefCounter++;
+        }
+        void removeRef()
+        {
+            iRefCounter--;
+        }
+
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            if (uuid == PVUuid(PVMF_SOURCE_CONTEXT_DATA_PACKETSOURCE_UUID))
+            {
+                iface = this;
+                return true;
+            }
+            else
+            {
+                iface = NULL;
+                return false;
+            }
+        }
+
+    private:
+        void MyCopy(const PVMFSourceContextDataPacketSource& aSrc)
+        {
+            // \todo: check this copy constructor
+            iPacketSourcePlugin = aSrc.iPacketSourcePlugin;
+        };
+
+        // reference counter
+        int32 iRefCounter;
+
+        // This class doesn't own PVMFPVRControl
+        PVMFPacketSource* iPacketSourcePlugin;
+};
+
+// Source context data for local playback of pvr files.
+// This should not be the final approach for pvr local playback. Ideally, the
+// engine should be modified to associate pvr extensions with the SM
+// source node. In that way, pvr files would be treated just like any other
+// local playback format.
+class PVMFSourceContextDataPVRLocalPlay : public PVInterface
+{
+    public:
+        PVMFSourceContextDataPVRLocalPlay()
+        {
+            iRefCounter = 0;
+        }
+
+        PVMFSourceContextDataPVRLocalPlay(const PVMFSourceContextDataPVRLocalPlay& aSrc) : PVInterface(aSrc)
+        {
+            iRefCounter = 0;
+            MyCopy(aSrc);
+        };
+
+        PVMFSourceContextDataPVRLocalPlay& operator=(const PVMFSourceContextDataPVRLocalPlay& aSrc)
+        {
+            if (&aSrc != this)
+            {
+                MyCopy(aSrc);
+            }
+            return *this;
+        };
+
+        void SetFileName(OSCL_wString& aFileName)
+        {
+            iPVRFileName = aFileName;
+        }
+
+        OSCL_wString& GetFileName()
+        {
+            return iPVRFileName;
+        }
+
+        /* From PVInterface */
+        void addRef()
+        {
+            iRefCounter++;
+        }
+        void removeRef()
+        {
+            iRefCounter--;
+        }
+
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            if (uuid == PVUuid(PVMF_SOURCE_CONTEXT_DATA_PVRLOCALPLAYBACK_UUID))
+            {
+                iface = this;
+                return true;
+            }
+            else
+            {
+                iface = NULL;
+                return false;
+            }
+        }
+
+    private:
+        void MyCopy(const PVMFSourceContextDataPVRLocalPlay& aSrc)
+        {
+            iPVRFileName = aSrc.iPVRFileName;
+        };
+
+        // reference counter
+        int32 iRefCounter;
+        // Full file name
+        OSCL_wHeapString<OsclMemAllocator> iPVRFileName;
+};
+
 class PVMFSourceContextData : public PVInterface
 {
     public:
@@ -386,6 +642,9 @@
             iStreamingDataContextValid = false;
             iDownloadHTTPDataContextValid = false;
             iDownloadPVXDataContextValid = false;
+            iPVRDataContextValid = false;
+            iPacketSourceDataContextValid = false;
+            iPVRLocalPlayDataContextValid = false;
         };
 
         PVMFSourceContextData(const PVMFSourceContextData& aSrc) : PVInterface(aSrc)
@@ -451,6 +710,32 @@
                     return true;
                 }
             }
+            else if (uuid == PVUuid(PVMF_SOURCE_CONTEXT_DATA_PVR_UUID))
+            {
+                if (iPVRDataContextValid == true)
+                {
+                    iface = &iPVMFSourceContextDataPVR;
+                    return true;
+                }
+            }
+            else if (uuid == PVUuid(PVMF_SOURCE_CONTEXT_DATA_PACKETSOURCE_UUID))
+            {
+                if (iPacketSourceDataContextValid == true)
+                {
+                    iface = &iPVMFSourceContextDataPacketSource;
+                    return true;
+                }
+            }
+            else if (uuid == PVUuid(PVMF_SOURCE_CONTEXT_DATA_PVRLOCALPLAYBACK_UUID))
+            {
+                if (iPVRLocalPlayDataContextValid == true)
+                {
+                    iface = &iPVMFSourceContextDataPVRLocalPlay;
+                    return true;
+                }
+            }
+
+
             iface = NULL;
             return false;
         }
@@ -471,6 +756,18 @@
         {
             iDownloadPVXDataContextValid = true;
         }
+        void EnablePVRSourceContext()
+        {
+            iPVRDataContextValid = true;
+        }
+        void EnablePacketSourceSourceContext()
+        {
+            iPacketSourceDataContextValid = true;
+        }
+        void EnablePVRLocalPlaySourceContext()
+        {
+            iPVRLocalPlayDataContextValid = true;
+        }
 
         void DisableCommonSourceContext()
         {
@@ -488,6 +785,18 @@
         {
             iDownloadPVXDataContextValid = false;
         }
+        void DisablePVRSourceContext()
+        {
+            iPVRDataContextValid = false;
+        }
+        void DisablePacketSourceSourceContext()
+        {
+            iPacketSourceDataContextValid = false;
+        }
+        void DisablePVRLocalPlaySourceContext()
+        {
+            iPVRLocalPlayDataContextValid = false;
+        }
 
         PVMFSourceContextDataCommon* CommonData()
         {
@@ -505,6 +814,18 @@
         {
             return iDownloadPVXDataContextValid ? &iPVMFSourceContextDataDownloadPVX : NULL;
         }
+        PVMFSourceContextDataPVR* PVRData()
+        {
+            return iPVRDataContextValid ? &iPVMFSourceContextDataPVR : NULL;
+        }
+        PVMFSourceContextDataPacketSource* PacketSourceData()
+        {
+            return iPacketSourceDataContextValid ? &iPVMFSourceContextDataPacketSource : NULL;
+        }
+        PVMFSourceContextDataPVRLocalPlay* PVRLocalPlayData()
+        {
+            return iPVRLocalPlayDataContextValid ? &iPVMFSourceContextDataPVRLocalPlay : NULL;
+        }
 
     private:
         int32 iRefCounter;
@@ -512,11 +833,17 @@
         bool iStreamingDataContextValid;
         bool iDownloadHTTPDataContextValid;
         bool iDownloadPVXDataContextValid;
+        bool iPVRDataContextValid;
+        bool iPacketSourceDataContextValid;
+        bool iPVRLocalPlayDataContextValid;
 
         PVMFSourceContextDataCommon iPVMFSourceContextDataCommon;
         PVMFSourceContextDataStreaming iPVMFSourceContextDataStreaming;
         PVMFSourceContextDataDownloadHTTP iPVMFSourceContextDataDownloadHTTP;
         PVMFSourceContextDataDownloadPVX iPVMFSourceContextDataDownloadPVX;
+        PVMFSourceContextDataPVR iPVMFSourceContextDataPVR;
+        PVMFSourceContextDataPacketSource iPVMFSourceContextDataPacketSource;
+        PVMFSourceContextDataPVRLocalPlay iPVMFSourceContextDataPVRLocalPlay;
 
         void MyCopy(const PVMFSourceContextData& aSrc)
         {
@@ -524,10 +851,17 @@
             iStreamingDataContextValid = aSrc.iStreamingDataContextValid;
             iDownloadHTTPDataContextValid = aSrc.iDownloadHTTPDataContextValid;
             iDownloadPVXDataContextValid = aSrc.iDownloadPVXDataContextValid;
+            iPVRDataContextValid = aSrc.iPVRDataContextValid;
+            iPacketSourceDataContextValid = aSrc.iPacketSourceDataContextValid;
+            iPVRLocalPlayDataContextValid = aSrc.iPVRLocalPlayDataContextValid;
+
             iPVMFSourceContextDataCommon = aSrc.iPVMFSourceContextDataCommon;
             iPVMFSourceContextDataStreaming = aSrc.iPVMFSourceContextDataStreaming;
             iPVMFSourceContextDataDownloadHTTP = aSrc.iPVMFSourceContextDataDownloadHTTP;
             iPVMFSourceContextDataDownloadPVX = aSrc.iPVMFSourceContextDataDownloadPVX;
+            iPVMFSourceContextDataPVR = aSrc.iPVMFSourceContextDataPVR;
+            iPVMFSourceContextDataPacketSource = aSrc.iPVMFSourceContextDataPacketSource;
+            iPVMFSourceContextDataPVRLocalPlay = aSrc.iPVMFSourceContextDataPVRLocalPlay;
         };
 };
 
diff --git a/nodes/common/include/pvmf_streaming_data_source.h b/nodes/common/include/pvmf_streaming_data_source.h
index 656138e..1f5154d 100644
--- a/nodes/common/include/pvmf_streaming_data_source.h
+++ b/nodes/common/include/pvmf_streaming_data_source.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -103,6 +103,7 @@
         OSCL_wHeapString<OsclMemAllocator> iStreamStatsLoggingURL;
         //Optional logging url.
         //When present, streaming stats will be sent to this URL.
+        //Typically applies to MS HTTP Streaming sessions
 
         bool iPreviewMode;
         //Optional field to indicate if the source that is being
diff --git a/nodes/common/include/pvmf_track_level_info_extension.h b/nodes/common/include/pvmf_track_level_info_extension.h
index 30c9dfd..b00631c 100644
--- a/nodes/common/include/pvmf_track_level_info_extension.h
+++ b/nodes/common/include/pvmf_track_level_info_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmf_track_selection_extension.h b/nodes/common/include/pvmf_track_selection_extension.h
index c0be588..412f73a 100644
--- a/nodes/common/include/pvmf_track_selection_extension.h
+++ b/nodes/common/include/pvmf_track_selection_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/common/include/pvmfamrencnode_extension.h b/nodes/common/include/pvmfamrencnode_extension.h
new file mode 100644
index 0000000..b1206df
--- /dev/null
+++ b/nodes/common/include/pvmfamrencnode_extension.h
@@ -0,0 +1,99 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmfamrencnode_extension.h
+ */
+
+#ifndef PVMFAMRENCNODE_EXTENSION_H_INCLUDED
+#define PVMFAMRENCNODE_EXTENSION_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+
+#define PVAMREncExtensionUUID PVUuid(0xd282cc91,0x54a6,0x4f36,0xbc,0x5b,0x2d,0xab,0xb4,0x40,0x69,0x26)
+
+/**
+ * Enumerated list of output bitrate
+ */
+
+typedef enum
+{
+    GSM_AMR_4_75 = 0,
+    GSM_AMR_5_15,
+    GSM_AMR_5_90,
+    GSM_AMR_6_70,
+    GSM_AMR_7_40,
+    GSM_AMR_7_95,
+    GSM_AMR_10_2,
+    GSM_AMR_12_2,
+    GSM_AMR_DTX,
+    GSM_AMR_N_MODES      /* number of (SPC) modes */
+} PVMF_GSMAMR_Rate;
+
+
+////////////////////////////////////////////////////////////////////////////
+class PVAMREncExtensionInterface : public PVInterface
+{
+    public:
+        /** Increment reference counter for this interface. */
+        virtual void addRef() = 0;
+
+        /** Decrement reference counter for this interface. */
+        virtual void removeRef() = 0;
+
+        /**
+         * Query for a pointer to an instance of the interface specified by the UUID.
+         *
+         * @param uuid UUID of the interface to be queried.
+         * @param iface Output parameter where a pointer to an instance of the requested
+         * interface is stored if the interface is supported.
+         * @return true if successful, else false.
+         */
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+
+        /**
+         * Sets the bitrate of encoded output.
+         * @param aBitRate Bitrate in bits per second.
+         * @return PVMFSuccess if successful, else see PVMF return code.
+         */
+        virtual PVMFStatus SetOutputBitRate(PVMF_GSMAMR_Rate aBitRate) = 0;
+
+        /**
+         * Sets the maximum number of output frames per media buffer
+         * @param aNumOutputFrames, maximum number of output frames
+         * @return PVMFSuccess if successful, else see PVMF return code.
+         */
+        virtual PVMFStatus SetMaxNumOutputFramesPerBuffer(uint32 aNumOutputFrames) = 0;
+};
+
+#endif // PVMFAMRENCNODE_EXTENSION_H_INCLUDED
+
+
+
+
+
diff --git a/nodes/common/include/pvmp4h263encextension.h b/nodes/common/include/pvmp4h263encextension.h
new file mode 100644
index 0000000..c61e7dc
--- /dev/null
+++ b/nodes/common/include/pvmp4h263encextension.h
@@ -0,0 +1,211 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmp4h263encextension.h
+ */
+
+#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+#define PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED
+#include "oscl_refcounter_memfrag.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+
+// Forward declaration
+template <class T> class OsclSharedPtr;
+
+#define PVMp4H263EncExtensionUUID PVUuid(0xc4737ade,0xa002,0x4632,0x95,0x1a,0x9c,0xa7,0xd6,0x3a,0xcd,0x2b)
+
+/**
+ * Enumerated list of supported rate control types
+ */
+typedef enum
+{
+    PVMFVEN_RATE_CONTROL_CONSTANT_Q,
+    PVMFVEN_RATE_CONTROL_CBR,
+    PVMFVEN_RATE_CONTROL_VBR
+} PVMFVENRateControlType;
+
+////////////////////////////////////////////////////////////////////////////
+class PVMp4H263EncExtensionInterface : public PVInterface
+{
+    public:
+        /** Increment reference counter for this interface. */
+        virtual void addRef() = 0;
+
+        /** Decrement reference counter for this interface. */
+        virtual void removeRef() = 0;
+
+        /**
+         * Query for a pointer to an instance of the interface specified by the UUID.
+         *
+         * @param uuid UUID of the interface to be queried.
+         * @param iface Output parameter where a pointer to an instance of the requested
+         * interface is stored if the interface is supported.
+         * @return True if successful, else false.
+         */
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+
+        /**
+         * Sets the number of layers in encoded output.
+         * @param aNumLayers Number of layers.
+         * @return True if successful, else false.
+         */
+        virtual bool SetNumLayers(uint32 aNumLayers) = 0;
+
+        /**
+         * Sets the bitrate of encoded output for the specified layer.
+         * @param aLayer Layer ID
+         * @param aBitRate Bitrate for the specified layer in bits per second.
+         * @return True if successful, else false.
+         */
+        virtual bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate) = 0;
+
+        /**
+         * Sets the frame size of encoded output for the specified layer.
+         * @param aLayer Layer ID
+         * @param aWidth Width for the specified layer in pixels.
+         * @param aHeight Height for the specified layer in pixels.
+         * @return True if successful, else false.
+         */
+        virtual bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight) = 0;
+
+        /**
+         * Sets the frame rate of encoded output for the specified layer.
+         * @param aLayer Layer ID
+         * @param aFrameRate Frame rate for the specified layer in frames per second.
+         * @return True if successful, else false.
+         */
+        virtual bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate) = 0;
+
+        /**
+         * Sets the segment size of encoded output for the specified layer
+         * @param aLayer Layer ID
+         * @param aSizeBytes Segment size in bytes.
+         * @return True if successful, else false.
+         */
+        virtual bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes) = 0;
+
+        /**
+         * Sets the rate control type to be used by encoder for the specified layer.
+         * @param aLayer Layer ID
+         * @param aRateControl Type of rate control to be used by encoder.
+         * @return True if successful, else false.
+         */
+        virtual bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl) = 0;
+
+        /**
+         * Enable or disable data partitioning in the encoded MPEG4 output.
+         * This menthod is valid only when the codec type is set to PVMFVEN_CODEC_M4V.
+         *
+         * @param aDataPartitioning Set to true to enable data partitioning, set to false
+         * to disable data partitioning.
+         * @return True if successful, else false
+         */
+        virtual bool SetDataPartitioning(bool aDataPartitioning) = 0;
+
+        /**
+         * Enable or disable reversible VLC in the encoded MPEG4 output.
+         * This menthod is valid only when the codec type is set to PVMFVEN_CODEC_M4V.
+         *
+         * @param aRVLC Set to true to enable RVLC, set to false to disable
+         * @return True if successful, else false
+         */
+        virtual bool SetRVLC(bool aRVLC) = 0;
+
+        /**
+         * Sets the I-Frame refresh rate of the encoded output.
+         *
+         * @param aIFrameInterval I-Frame rate in seconds per I-Frame
+         * @return True if successful, else false
+         */
+        virtual bool SetIFrameInterval(uint32 aIFrameInterval) = 0;
+
+
+        /**
+         * Sets the automatic I-frame mode for scene change detection.
+         *
+         * @param aSCD  Set to true to enable scene detection
+         * @return True is successful, else false.
+         */
+        virtual bool SetSceneDetection(bool aSCD) = 0;
+
+        /**
+         * Retrieves VOL header for the M4V bitstream.
+         *
+         * This method is valid only when codec type is set to PVMFVEN_CODEC_M4V. This method
+         * would retrieve the VOL header for the M4V bitstream using encoder parameters
+         * specified at the time of the method call.  The VOL header is stored in the
+         * memory fragment provided by the caller.
+         *
+         * @param aVolHeader Memory fragment to store the VOL header
+         * @return True if VOL header is successfully retrieved, else false.
+         */
+        virtual bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader) = 0;
+
+        /**
+         * Requests the encoder to encode the next frame as an I-Frame.  This menthod is valid
+         * only when the node is in EPVMFNodeStarted state. If successful, the next encoded
+         * frame will be an I-Frame.
+         *
+         * @return True for success, else false
+         */
+        virtual bool RequestIFrame() = 0;
+
+        /**
+         * Sets the type of encoder use.
+         *
+         * @param aCodec Codec type.
+         * @return True for success, else false
+         */
+        virtual bool SetCodec(PVMFFormatType aCodec)
+        {
+            OSCL_UNUSED_ARG(aCodec);
+            return false;
+        }
+
+        /**
+        * Set FSI buff to encoding param
+        *
+        * @param aFSIBuff			FSI Buffer
+        * @param aFSIBuffLength		Length of FSI Buffer
+        * @return True for success, else false
+        */
+        virtual bool SetFSIParam(uint8* aFSIBuff, int aFSIBuffLength) = 0;
+
+
+
+};
+#endif // PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+
+
+
+
+
diff --git a/nodes/pvaacffparsernode/Android.mk b/nodes/pvaacffparsernode/Android.mk
index 01544f0..606d020 100644
--- a/nodes/pvaacffparsernode/Android.mk
+++ b/nodes/pvaacffparsernode/Android.mk
@@ -3,27 +3,29 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_aacffparser_node.cpp \
-	src/pvmf_aacffparser_factory.cpp \
-	src/pvmf_aacffparser_outport.cpp
-
+ 	src/pvmf_aacffparser_factory.cpp \
+ 	src/pvmf_aacffparser_outport.cpp
 
 
 LOCAL_MODULE := libpvaacffparsernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvaacffparsernode/include \
-	$(PV_TOP)//nodes/pvaacffparsernode/src \
-	$(PV_TOP)//nodes/pvaacffparsernode/../common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvaacffparsernode/src \
+ 	$(PV_TOP)/nodes/pvaacffparsernode/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_aacffparser_factory.h \
-	include/pvmf_aacffparser_defs.h \
+ 	include/pvmf_aacffparser_defs.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvaacffparsernode/build/make/local.mk b/nodes/pvaacffparsernode/build/make/local.mk
new file mode 100644
index 0000000..658c527
--- /dev/null
+++ b/nodes/pvaacffparsernode/build/make/local.mk
@@ -0,0 +1,22 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvaacffparsernode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_aacffparser_node.cpp pvmf_aacffparser_factory.cpp pvmf_aacffparser_outport.cpp
+
+HDRS := pvmf_aacffparser_factory.h \
+        pvmf_aacffparser_defs.h \
+
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvaacffparsernode/build/make/makefile b/nodes/pvaacffparsernode/build/make/makefile
deleted file mode 100644
index 9b39480..0000000
--- a/nodes/pvaacffparsernode/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvaacffparsernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../common/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_aacffparser_node.cpp pvmf_aacffparser_factory.cpp pvmf_aacffparser_outport.cpp
-
-HDRS =  pvmf_aacffparser_factory.h \
-		pvmf_aacffparser_defs.h \
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvaacffparsernode/include/pvmf_aacffparser_defs.h b/nodes/pvaacffparsernode/include/pvmf_aacffparser_defs.h
index 4816669..c8e3300 100644
--- a/nodes/pvaacffparsernode/include/pvmf_aacffparser_defs.h
+++ b/nodes/pvaacffparsernode/include/pvmf_aacffparser_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@
 static const char PVAACMETADATA_CHARENCUTF16BE[] = "char-encoding=UTF16BE";
 static const char PVAACMETADATA_FORMATID3V1[] = "format=id3v1";
 static const char PVAACMETADATA_FORMATID3V11[] = "format=id3v1.1";
-static const char PVAACMETADATA_TIMESCALE1000[] = "timescale=1000";
+static const char PVAACMETADATA_TIMESCALE1000[] = ";timescale=1000";
 static const char PVAACMETADATA_INDEX0[] = "index=0";
 static const char PVAACMETADATA_RANDOM_ACCESS_DENIED_KEY[] = "random-access-denied";
 
diff --git a/nodes/pvaacffparsernode/include/pvmf_aacffparser_factory.h b/nodes/pvaacffparsernode/include/pvmf_aacffparser_factory.h
index f423677..cc793f1 100644
--- a/nodes/pvaacffparsernode/include/pvmf_aacffparser_factory.h
+++ b/nodes/pvaacffparsernode/include/pvmf_aacffparser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvaacffparsernode/src/pvmf_aacffparser_factory.cpp b/nodes/pvaacffparsernode/src/pvmf_aacffparser_factory.cpp
index d565d43..3e02a10 100644
--- a/nodes/pvaacffparsernode/src/pvmf_aacffparser_factory.cpp
+++ b/nodes/pvaacffparsernode/src/pvmf_aacffparser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.cpp b/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.cpp
index 1daf513..c2552de 100644
--- a/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.cpp
+++ b/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,17 +35,10 @@
 #include "oscl_int64_utils.h"
 #include "aacfileparser.h"
 #include "pvmf_source_context_data.h"
+
 #define PVAACFF_MEDIADATA_POOLNUM 8
 #define PVAACFF_MEDIADATA_CHUNKSIZE 128
 
-void PVMFAACFFParserNode::Assert(bool x)
-{
-    if (!x)
-    {
-        PVMF_AACPARSERNODE_LOGINFOLOW((0, "PVMFAACFFParserNode Assertion Failed!"));
-        OSCL_ASSERT(0);
-    }
-}
 
 PVMFAACFFParserNode::PVMFAACFFParserNode(int32 aPriority)
         : OsclTimerObject(aPriority, "PVMFAACFFParserNode")
@@ -100,7 +93,6 @@
     iAutoPaused                = false;
 
     iStreamID				   = 0;
-
     int32 err;
     OSCL_TRY(err, ConstructL());
 
@@ -142,8 +134,8 @@
     iCapability.iCanSupportMultipleOutputPorts = false;
     iCapability.iHasMaxNumberOfPorts = true;
     iCapability.iMaxNumberOfPorts = 2;//no maximum
-    iCapability.iInputFormatCapability.push_back(PVMF_AACFF);
-    iCapability.iOutputFormatCapability.push_back(PVMF_MPEG4_AUDIO);
+    iCapability.iInputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_AACFF));
+    iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_MPEG4_AUDIO));
 
 
 
@@ -214,6 +206,7 @@
 
     if (iDownloadProgressInterface != NULL)
     {
+        iDownloadProgressInterface->cancelResumeNotification();
         iDownloadProgressInterface->removeRef();
     }
 }
@@ -543,7 +536,7 @@
 {
     PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACParserNode::ReleaseNodeMetadataValues called"));
 
-    if (start < 0 || start > end || aValueList.size() == 0)
+    if (start > end || aValueList.size() == 0)
     {
         PVMF_AACPARSERNODE_LOGERROR((0, "PVMFAACFFParserNode::ReleaseNodeMetadataValues() Invalid start/end index"));
         return PVMFErrArgument;
@@ -644,7 +637,7 @@
 // From PvmfDataSourcePlaybackControlInterface
 PVMFCommandId PVMFAACFFParserNode::SetDataSourceRate(PVMFSessionId aSessionId
         , int32 aRate
-        , OsclTimebase* aTimebase
+        , PVMFTimebase* aTimebase
         , OsclAny* aContext)
 {
     PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACParserNode::SetDataSourceRate called"));
@@ -782,29 +775,46 @@
 {
 
     // Create a data buffer from pool
-    int errcode = 0;
+    int errcode = OsclErrNoResources;
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
-    OSCL_TRY(errcode, mediaDataImplOut = aTrackInfoPtr->iResizableSimpleMediaMsgAlloc->allocate(MAXTRACKDATASIZE));
+    mediaDataImplOut = aTrackInfoPtr->iResizableSimpleMediaMsgAlloc->allocate(MAXTRACKDATASIZE);
+
+    if (mediaDataImplOut.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
 
     OsclMemPoolResizableAllocatorObserver* resizableAllocObs =
         OSCL_STATIC_CAST(OsclMemPoolResizableAllocatorObserver*, aTrackInfoPtr);
 
     // Enable flag to receive event when next deallocate() is called on pool
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackInfoPtr->iTrackDataMemoryPool->notifyfreeblockavailable(*resizableAllocObs);
-                         return PVMFErrBusy;);
+    if (errcode != OsclErrNone)
+    {
+        aTrackInfoPtr->iTrackDataMemoryPool->notifyfreeblockavailable(*resizableAllocObs);
+        return PVMFErrBusy;
+    }
 
     // Now create a PVMF media data from pool
-    errcode = 0;
-    OSCL_TRY(errcode,
-             aMediaDataOut = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackInfoPtr->iMediaDataMemPool));
+    errcode = OsclErrNoResources;
+    aMediaDataOut = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackInfoPtr->iMediaDataMemPool);
+
+    if (aMediaDataOut.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
+
     OsclMemPoolFixedChunkAllocatorObserver* fixedChunkObs =
         OSCL_STATIC_CAST(OsclMemPoolFixedChunkAllocatorObserver*, aTrackInfoPtr);
 
     // Enable flag to receive event when next deallocate() is called on pool
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackInfoPtr->iMediaDataMemPool->notifyfreechunkavailable(*fixedChunkObs);
-                         return PVMFErrBusy);
+    if (errcode != OsclErrNone)
+    {
+        aTrackInfoPtr->iMediaDataMemPool->notifyfreechunkavailable(*fixedChunkObs);
+        return PVMFErrBusy;
+    }
+
+
+
     // Retrieve memory fragment to write to
     OsclRefCounterMemFrag refCtrMemFragOut;
     OsclMemoryFragment memFragOut;
@@ -914,30 +924,6 @@
     return PVMFSuccess;
 }
 
-
-
-bool PVMFAACFFParserNode::SendTrackData(PVAACFFNodeTrackPortInfo& aTrackPortInfo)
-{
-    // Set the track specific config info
-    aTrackPortInfo.iMediaData->setFormatSpecificInfo(aTrackPortInfo.iFormatSpecificConfig);
-
-    // Send frame to downstream node via port
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaMsg(mediaMsgOut, aTrackPortInfo.iMediaData);
-    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
-    {
-        PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACFFParserNode::SendTrackData: output queue busy!"));
-        // output queue is busy, so wait for the output queue being ready
-        aTrackPortInfo.iState = PVAACFFNodeTrackPortInfo::TRACKSTATE_DESTFULL;
-        return false;
-    }
-
-    // Don't need the ref to iMediaData so unbind it
-    aTrackPortInfo.iMediaData.Unbind();
-
-    return true;
-}
-
 void PVMFAACFFParserNode::PushToAvailableMetadataKeysList(const char* aKeystr, char* aOptionalParam)
 {
     if (aKeystr == NULL)
@@ -1028,15 +1014,22 @@
         CAACFileParser* iAACParserTemp;
         PVMF_AAC_PARSER_NODE_NEW(NULL, CAACFileParser, (), iAACParserTemp);
 
-        uint32 headerSize32 = iAACParserTemp->getAACHeaderLen(iSourceURL, false, &iFileServer , iDataStreamFactory, iFileHandle);
-
-        if (currCapacity < headerSize32)
+        uint32 headerSize32 = 0;
+        if (OK == iAACParserTemp->getAACHeaderLen(iSourceURL, false, &iFileServer ,
+                iDataStreamFactory, iFileHandle, &headerSize32))
         {
-            iRequestReadCapacityNotificationID =
-                iDataStreamInterface->RequestReadCapacityNotification(iDataStreamSessionID,
-                        *this,
-                        headerSize32);
-            return PVMFPending;
+            if (currCapacity < headerSize32)
+            {
+                iRequestReadCapacityNotificationID =
+                    iDataStreamInterface->RequestReadCapacityNotification(iDataStreamSessionID,
+                            *this,
+                            headerSize32);
+                return PVMFPending;
+            }
+        }
+        else
+        {
+            return PVMFFailure;
         }
 
         PVMF_AAC_PARSER_NODE_DELETE(NULL, CAACFileParser, iAACParserTemp);
@@ -1121,12 +1114,14 @@
 
     if (iID3DataValid)
     {
-        for (uint s = 0; s < iID3Data.size(); s++)
-        {
-            OSCL_HeapString<OsclMemAllocator> keystr((const char *)((*iID3Data[s]).key), oscl_strlen((const char *)((*iID3Data[s]).key)));
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(keystr));
+        leavecode = 0;
+        OSCL_TRY(leavecode,
+                 for (uint s = 0; s < iID3Data.size(); s++)
+    {
+        OSCL_HeapString<OsclMemAllocator> keystr((const char *)((*iID3Data[s]).key), oscl_strlen((const char *)((*iID3Data[s]).key)));
+            iAvailableMetadataKeys.push_back(keystr);
         }
+                );
     }
 
     //set clip duration on download progress interface
@@ -1179,6 +1174,7 @@
 
 void PVMFAACFFParserNode::DoStop(PVMFAACFFParserNodeCommand& aCmd)
 {
+    iStreamID = 0;
     switch (iInterfaceState)
     {
         case EPVMFNodeStarted:
@@ -1237,6 +1233,12 @@
     PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACParserNode::DoReset() Called"));
 
     MoveCmdToCurrentQueue(aCmd);
+
+    if (iDownloadProgressInterface != NULL)
+    {
+        iDownloadProgressInterface->cancelResumeNotification();
+    }
+
     if (iFileHandle != NULL)
     {
         /* Indicates that the init was successfull */
@@ -1268,10 +1270,7 @@
     ReleaseTrack();
     CleanupFileSource();
     SetState(EPVMFNodeIdle);
-    PVMFStatus status = ThreadLogoff();
-    CommandComplete(iCurrentCommand, iCurrentCommand.front(), status);
-
-    return;
+    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
 }
 
 void PVMFAACFFParserNode::DoRequestPort(PVMFAACFFParserNodeCommand& aCmd, PVMFPortInterface*& aPort)
@@ -1312,7 +1311,7 @@
     //validate the requested format
     if (mimetype)
     {
-        PVMFFormatType fmt = GetFormatIndex(mimetype->get_str(), PVMF_COMPRESSED_AUDIO_FORMAT);
+        PVMFFormatType fmt = mimetype->get_str();
         if (!iOutPort->IsFormatSupported(fmt))
         {
             PVMF_AACPARSERNODE_LOGERROR((0, "PVMFAACFFParserNode::DoRequestPort: Error - Invalid Format!"));
@@ -1388,11 +1387,13 @@
             return;
         }
 
+        trackdatamempool->enablenullpointerreturn();
+        mediadatamempool->enablenullpointerreturn();
+
         // Construct iTrack
         iTrack.iTrackId = 0;  // Only support 1 channel so far
         iTrack.iPort = iOutPort;
         iTrack.iClockConverter = clockconv;
-        iTrack.iState = PVAACFFNodeTrackPortInfo::TRACKSTATE_UNINITIALIZED;
         iTrack.iTrackDataMemoryPool = trackdatamempool;
         iTrack.iTrackDataMemoryPoolProxy = trackdatamempoolproxy;
         iTrack.iMediaDataImplAlloc = mediadataimplalloc;
@@ -1425,17 +1426,13 @@
 
 void PVMFAACFFParserNode::ResetAllTracks()
 {
-    iTrack.iState = PVAACFFNodeTrackPortInfo::TRACKSTATE_UNINITIALIZED;
     iTrack.iMediaData.Unbind();
     iTrack.iSeqNum = 0;
     iFirstFrame = false;
-    //------------- CORE408/409 FIX BEGIN ------------------------
     iTrack.oEOSReached = false;
     iTrack.oEOSSent = false;
     iTrack.oProcessOutgoingMessages = true;
     iTrack.oQueueOutgoingMessages = true;
-    //------------- CORE408/409 END ------------------------
-
 }
 
 
@@ -1473,9 +1470,10 @@
         iTrack.iMediaDataImplAlloc = NULL;
     }
 
-    if (iTrack.iMediaDataMemPool)
+    if (iTrack.iMediaDataMemPool != NULL)
     {
-        PVMF_AAC_PARSER_NODE_DELETE(NULL, PVMFMemPoolFixedChunkAllocator, iTrack.iMediaDataMemPool);
+        iTrack.iMediaDataMemPool->CancelFreeChunkAvailableCallback();
+        iTrack.iMediaDataMemPool->removeRef();
         iTrack.iMediaDataMemPool = NULL;
     }
     if (iTrack.iResizableSimpleMediaMsgAlloc)
@@ -1576,42 +1574,130 @@
 
 void PVMFAACFFParserNode::HandlePortActivity(const PVMFPortActivity &aActivity)
 {
+
+    PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACFFParserNode::PortActivity: port=0x%x, type=%d",
+                                      aActivity.iPort, aActivity.iType));
+
+    /*
+     * A port is reporting some activity or state change.  This code
+     * figures out whether we need to queue a processing event
+     * for the AO, and/or report a node event to the observer.
+     */
     switch (aActivity.iType)
     {
-        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-            PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACFFParserNode::PortActivity: Outgoing Msg"));
-            //An outgoing message was queued on this port.
-            RunIfNotReady();
+        case PVMF_PORT_ACTIVITY_CREATED:
+            /*
+             * Report port created info event to the node.
+             */
+            ReportInfoEvent(PVMFInfoPortCreated, (OsclAny*)aActivity.iPort);
             break;
 
-        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-            //not used in this node.
-            break;
+        case PVMF_PORT_ACTIVITY_DELETED:
+        {
+            /*
+             * Report port deleted info event to the node.
+             */
+            ReportInfoEvent(PVMFInfoPortDeleted, (OsclAny*)aActivity.iPort);
+        }
+        break;
 
         case PVMF_PORT_ACTIVITY_CONNECT:
-            //nothing needed.
             break;
 
         case PVMF_PORT_ACTIVITY_DISCONNECT:
-            //nothing needed.
             break;
 
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-            //This message is send by destination port to notify that the earlier Send
-            //call that failed due to its busy status can be resumed now.
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+        {
+            /*
+             * An outgoing message was queued on this port.
+             * Wakeup the node to process the same.
+             */
             RunIfNotReady();
-            break;
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+        {
+            /*
+             * There are no input ports to this node
+             */
+            OSCL_ASSERT(false);
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
+        {
+            /*
+             * This implies that this output port cannot accept any more
+             * msgs on its outgoing queue. This implies that we should stop
+             * retrieving samples from file to queue.
+             */
+            PVAACFFNodeTrackPortInfo* trackInfoPtr = NULL;
+            if (!GetTrackInfo(aActivity.iPort, trackInfoPtr))
+            {
+                ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+                PVMF_AACPARSERNODE_LOGERROR((0, "0x%x PVMFAACFFParserNode::HandlePortActivity: Error - GetTrackInfo failed", this));
+                return;
+            }
+            trackInfoPtr->oQueueOutgoingMessages = false;
+        }
+        break;
 
         case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            //this message is sent by the OutgoingQueue when it recovers from
-            //the queue full status
-            if (iTrack.iState == PVAACFFNodeTrackPortInfo::TRACKSTATE_DESTFULL)
+        {
+            /*
+             * Outgoing queue was previously busy, but is now ready.
+             * We are ready to send new samples from file.
+             */
+            PVAACFFNodeTrackPortInfo* trackInfoPtr = NULL;
+            if (!GetTrackInfo(aActivity.iPort, trackInfoPtr))
             {
-                // Change track state to try sending the data again
-                iTrack.iState = PVAACFFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_SENDDATA;
+                ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+                PVMF_AACPARSERNODE_LOGERROR((0, "0x%x PVMFAACFFParserNode::HandlePortActivity: Error - GetTrackInfo failed", this));
+                return;
             }
+            trackInfoPtr->oQueueOutgoingMessages = true;
             RunIfNotReady();
-            break;
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
+        {
+            /*
+             * The connected port has become busy (its incoming queue is
+             * busy). There is nothing to do but to wait for connected port
+             * ready.
+             */
+            PVAACFFNodeTrackPortInfo* trackInfoPtr = NULL;
+            if (!GetTrackInfo(aActivity.iPort, trackInfoPtr))
+            {
+                ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+                PVMF_AACPARSERNODE_LOGERROR((0, "0x%x PVMFAACFFParserNode::HandlePortActivity: Error - GetTrackInfo failed", this));
+                return;
+            }
+            trackInfoPtr->oProcessOutgoingMessages = false;
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+        {
+            /*
+             * The connected port has transitioned from Busy to Ready.
+             * It's time to start sending messages again.
+             */
+            PVAACFFNodeTrackPortInfo* trackInfoPtr = NULL;
+            if (!GetTrackInfo(aActivity.iPort, trackInfoPtr))
+            {
+                ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+                PVMF_AACPARSERNODE_LOGERROR((0, "0x%x PVMFAACFFParserNode::HandlePortActivity: Error - GetTrackInfo failed", this));
+                return;
+            }
+            trackInfoPtr->oProcessOutgoingMessages = true;
+            RunIfNotReady();
+        }
+        break;
+
 
         default:
             break;
@@ -1668,7 +1754,7 @@
     }
 
     //The newest or highest pri command is in the front of the queue.
-    Assert(!iInputCommands.empty());
+    OSCL_ASSERT(!iInputCommands.empty());
     PVMFAACFFParserNodeCommand& aCmd = iInputCommands.front();
 
     PVMFStatus cmdstatus;
@@ -1956,8 +2042,10 @@
     //This node supports release port from any state
 
     //Find the port in the port vector
-    PVMFAACFFParserOutPort* port;
-    aCmd.PVMFAACFFParserNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* p = NULL;
+    aCmd.PVMFAACFFParserNodeCommandBase::Parse(p);
+
+    PVMFAACFFParserOutPort* port = (PVMFAACFFParserOutPort*)p;
 
     if (iOutPort == port)
     {
@@ -2098,7 +2186,7 @@
 {
     PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACParserNode::SetSourceInitializationData called"));
 
-    if (aSourceFormat == PVMF_AACFF)
+    if (aSourceFormat == PVMF_MIME_AACFF)
     {
         /* Clean up any previous sources */
         CleanupFileSource();
@@ -2188,12 +2276,12 @@
     return PVMFFailure;
 }
 
-PVMFStatus PVMFAACFFParserNode::SetClientPlayBackClock(OsclClock* aClientClock)
+PVMFStatus PVMFAACFFParserNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
 }
-PVMFStatus PVMFAACFFParserNode::SetEstimatedServerClock(OsclClock* aClientClock)
+PVMFStatus PVMFAACFFParserNode::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
@@ -2237,6 +2325,7 @@
         case EAACRaw:
             mime_type = PVMF_MIME_ADIF;
             break;
+
         case EAACADTS:
             mime_type = PVMF_MIME_MPEG4_AUDIO;
             break;
@@ -2247,6 +2336,16 @@
 
     tmpTrackInfo.setTrackMimeType(mime_type);
 
+    OsclRefCounterMemFrag config;
+    PVAACFFNodeTrackPortInfo trackPortInfo;
+    if (!RetrieveTrackConfigInfo(trackPortInfo))
+    {
+        return PVMFFailure;
+    }
+    config = trackPortInfo.iFormatSpecificConfig;
+
+    tmpTrackInfo.setTrackConfigInfo(config);
+
     // add the track
     aInfo.addTrackInfo(tmpTrackInfo);
 
@@ -2271,6 +2370,7 @@
     }
     return (CompleteGetMetadataKeys(aCmd));
 }
+
 PVMFStatus
 PVMFAACFFParserNode::CompleteGetMetadataKeys(PVMFAACFFParserNodeCommand& aCmd)
 {
@@ -2296,7 +2396,7 @@
         return PVMFErrArgument;
     }
 
-    if ((starting_index < 0) || (starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
+    if ((starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
     {
         // Invalid starting index and/or max entries
         return PVMFErrArgument;
@@ -2305,7 +2405,6 @@
     // Copy the requested keys
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
     uint32 lcv = 0;
     for (lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
     {
@@ -2316,11 +2415,11 @@
             if (num_entries > starting_index)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVMF_AACPARSERNODE_LOGERROR((0, "PVMFAACFFParserNode::DoGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushValueToList(iAvailableMetadataKeys, keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -2334,11 +2433,11 @@
                 if (num_entries > starting_index)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVMF_AACPARSERNODE_LOGERROR((0, "PVMFAACFFParserNode::DoGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushValueToList(iAvailableMetadataKeys, keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -2359,11 +2458,11 @@
             if (num_entries > (uint32)starting_index)
             {
                 /* Past the starting index so copy the key */
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAACFFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushValueToList(iCPMMetadataKeys, keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -2377,11 +2476,11 @@
                 if (num_entries > (uint32)starting_index)
                 {
                     /* Past the starting index so copy the key */
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAACFFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushValueToList(iCPMMetadataKeys, keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -2429,6 +2528,7 @@
 
 PVMFStatus PVMFAACFFParserNode::DoGetMetadataValues(PVMFAACFFParserNodeCommand& aCmd)
 {
+    int32 leavecode = 0;
     PVMF_AACPARSERNODE_LOGSTACKTRACE((0, "PVMFAACParserNode::DoGetMetaDataValues Called"));
 
     // File must be parsed
@@ -2452,7 +2552,7 @@
 
     uint32 numkeys = keylistptr->size();
 
-    if (starting_index < 0 || starting_index > (numkeys - 1) || numkeys <= 0 || max_entries == 0)
+    if (starting_index > (numkeys - 1) || numkeys <= 0 || max_entries == 0)
     {
         // Don't do anything
         return PVMFErrArgument;
@@ -2478,11 +2578,7 @@
 
             ++numvalentries;
 
-            int32 leavecode = 0;
-            OSCL_TRY(leavecode,
-                     KeyVal.key = OSCL_ARRAY_NEW(char, oscl_strlen(key) + 1);
-                    );
-
+            leavecode = CreateNewArray(KeyVal.key, key);
             oscl_strncpy(KeyVal.key , key, oscl_strlen(key) + 1);
             KeyVal.length = len;
             KeyVal.capacity = (*(iFrame.back())).capacity;
@@ -2493,21 +2589,12 @@
             {
 
                 case PVMI_KVPVALTYPE_WCHARPTR:
-                    leavecode = 0;
-
-                    OSCL_TRY(leavecode,
-                             KeyVal.value.pWChar_value = OSCL_ARRAY_NEW(oscl_wchar, len);
-                            );
-
+                    leavecode = CreateNewArray(KeyVal.value.pWChar_value, len);
                     oscl_strncpy(KeyVal.value.pWChar_value , (*(iFrame.back())).value.pWChar_value, len);
                     break;
 
                 case PVMI_KVPVALTYPE_CHARPTR:
-                    leavecode = 0;
-
-                    OSCL_TRY(leavecode,
-                             KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, len);
-                            );
+                    leavecode = CreateNewArray(KeyVal.value.pChar_value, len);
 
                     oscl_strncpy(KeyVal.value.pChar_value , (*(iFrame.back())).value.pChar_value, len);
                     break;
@@ -2520,8 +2607,7 @@
                     break;
             }
 
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
+            leavecode = PushBackKeyVal(valuelistptr, KeyVal);
             OSCL_FIRST_CATCH_ANY(leavecode, ReleaseMetadataValue(KeyVal);
                                  break;);
 
@@ -2537,7 +2623,6 @@
         int32 leavecode = 0;
         PvmiKvp KeyVal;
         KeyVal.key = NULL;
-        uint32 KeyLen = 0;
 
         if (!oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVAACMETADATA_DURATION_KEY) &&
                 iAACFileInfo.iDuration > 0)
@@ -2549,40 +2634,20 @@
             // Create a value entry if past the starting index
             if (numvalentries > starting_index)
             {
-                KeyLen = oscl_strlen(PVAACMETADATA_DURATION_KEY) + 1; // for "duration;"
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32;"
-                KeyLen += oscl_strlen(PVAACMETADATA_TIMESCALE1000) + 1; // for "timescale=1000" and NULL terminator
+                uint32 duration = (uint32)iAACFileInfo.iDuration;
+                PVMFStatus retval =
+                    PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                            PVAACMETADATA_DURATION_KEY,
+                            duration,
+                            (char *)PVAACMETADATA_TIMESCALE1000);
 
-                // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
                 {
-                    // Copy the key string
-                    oscl_strncpy(KeyVal.key, PVAACMETADATA_DURATION_KEY, oscl_strlen(PVAACMETADATA_DURATION_KEY) + 1);
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_TIMESCALE1000, oscl_strlen(PVAACMETADATA_TIMESCALE1000));
-                    KeyVal.key[KeyLen-1] = 0;
-                    // Copy the value
-                    KeyVal.value.uint32_value = iAACFileInfo.iDuration;
-                    // Set the length and capacity
-                    KeyVal.length = 1;
-                    KeyVal.capacity = 1;
-                }
-                else
-                {
-                    // Memory allocation failed
-                    KeyVal.key = NULL;
                     break;
                 }
+
             }
+
         }
         else if (!oscl_strcmp((*keylistptr)[lcv].get_cstr(),  PVAACMETADATA_RANDOM_ACCESS_DENIED_KEY))
         {
@@ -2596,8 +2661,6 @@
             if (numvalentries > (uint32)starting_index)
             {
                 bool random_access_denied = false;
-                //Ideally any ASF header that has broadcast flag set to true MUST also have seekable flag set to false.
-                //If either seekable flag is false or broadcast flag is true, then random access denied must be set to true.
                 if (iAACFileInfo.iFormat == EAACADIF || iAACFileInfo.iFormat == EAACRaw)
                 {
                     random_access_denied = true;
@@ -2622,34 +2685,13 @@
             // Create a value entry if past the starting index
             if (numvalentries > starting_index)
             {
-                KeyLen = oscl_strlen(PVAACMETADATA_NUMTRACKS_KEY) + 1; // for "num-tracks;"
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
-
-                // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                uint32 numtracksuint32 = 1;
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                                    PVAACMETADATA_NUMTRACKS_KEY,
+                                    numtracksuint32,
+                                    NULL);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
                 {
-                    // Copy the key string
-                    oscl_strncpy(KeyVal.key, PVAACMETADATA_NUMTRACKS_KEY, oscl_strlen(PVAACMETADATA_NUMTRACKS_KEY) + 1);
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
-                    KeyVal.key[KeyLen-1] = 0;
-                    // Copy the value
-                    KeyVal.value.uint32_value = 1; // Number of tracks supported in PV AAC parser would always be 1
-                    // Set the length and capacity
-                    KeyVal.length = 1;
-                    KeyVal.capacity = 1;
-                }
-                else
-                {
-                    // Memory allocation failed
-                    KeyVal.key = NULL;
                     break;
                 }
             }
@@ -2664,39 +2706,16 @@
             // Create a value entry if past the starting index
             if (numvalentries > starting_index)
             {
-                KeyLen = oscl_strlen(PVAACMETADATA_TRACKINFO_BITRATE_KEY) + 1; // for "track-info/bitrate;"
-                KeyLen += oscl_strlen(PVAACMETADATA_INDEX0) + 1; // for "index=0;"
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
-
-                // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                uint32 bitRate = (uint32)iAACFileInfo.iBitrate;
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                                    PVAACMETADATA_TRACKINFO_BITRATE_KEY,
+                                    bitRate,
+                                    NULL);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
                 {
-                    // Copy the key string
-                    oscl_strncpy(KeyVal.key, PVAACMETADATA_TRACKINFO_BITRATE_KEY, oscl_strlen(PVAACMETADATA_TRACKINFO_BITRATE_KEY) + 1);
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_INDEX0, oscl_strlen(PVAACMETADATA_INDEX0));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
-                    KeyVal.key[KeyLen-1] = 0;
-                    // Copy the value
-                    KeyVal.value.uint32_value = iAACFileInfo.iBitrate;
-                    // Set the length and capacity
-                    KeyVal.length = 1;
-                    KeyVal.capacity = 1;
-                }
-                else
-                {
-                    // Memory allocation failed
-                    KeyVal.key = NULL;
                     break;
                 }
+
             }
         }
         else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVAACMETADATA_TRACKINFO_SAMPLERATE_KEY) == 0) &&
@@ -2709,37 +2728,13 @@
             // Create a value entry if past the starting index
             if (numvalentries > starting_index)
             {
-                KeyLen = oscl_strlen(PVAACMETADATA_TRACKINFO_SAMPLERATE_KEY) + 1; // for "track-info/samplingrate;"
-                KeyLen += oscl_strlen(PVAACMETADATA_INDEX0) + 1; // for "index=0;"
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
-
-                // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                uint32 sampleFreq = (uint32)iAACFileInfo.iSampleFrequency;
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                                    PVAACMETADATA_TRACKINFO_BITRATE_KEY,
+                                    sampleFreq,
+                                    NULL);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
                 {
-                    // Copy the key string
-                    oscl_strncpy(KeyVal.key, PVAACMETADATA_TRACKINFO_SAMPLERATE_KEY, oscl_strlen(PVAACMETADATA_TRACKINFO_SAMPLERATE_KEY) + 1);
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_INDEX0, oscl_strlen(PVAACMETADATA_INDEX0));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
-                    KeyVal.key[KeyLen-1] = 0;
-                    // Copy the value
-                    KeyVal.value.uint32_value = iAACFileInfo.iSampleFrequency;
-                    // Set the length and capacity
-                    KeyVal.length = 1;
-                    KeyVal.capacity = 1;
-                }
-                else
-                {
-                    // Memory allocation failed
-                    KeyVal.key = NULL;
                     break;
                 }
             }
@@ -2754,93 +2749,53 @@
             // Create a value entry if past the starting index
             if (numvalentries > starting_index)
             {
-                KeyLen = oscl_strlen(PVAACMETADATA_TRACKINFO_AUDIO_FORMAT_KEY) + 1; // for "track-info/audio/format;"
-                KeyLen += oscl_strlen(PVAACMETADATA_INDEX0) + 1; // for "index=0;"
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*" and NULL terminator
-
-                uint32 valuelen = 1; // Init to 1 for NULL terminator
-
+                PVMFStatus retval = PVMFSuccess;
                 switch (iAACFileInfo.iFormat)
                 {
                     case EAACADTS:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_ADTS)) + 1;
+                        retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                                 PVAACMETADATA_TRACKINFO_AUDIO_FORMAT_KEY,
+                                 _STRLIT_CHAR(PVMF_MIME_ADTS));
                         break;
 
                     case EAACADIF:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_ADIF)) + 1;
+                        retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                                 PVAACMETADATA_TRACKINFO_AUDIO_FORMAT_KEY,
+                                 _STRLIT_CHAR(PVMF_MIME_ADIF));
+
                         break;
 
                     case EAACRaw:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO)) + 1;
+                        retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                                 PVAACMETADATA_TRACKINFO_AUDIO_FORMAT_KEY,
+                                 _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO));
+
                         break;
 
                     default:
                         break;
                 }
-
-                // Allocate memory for the strings
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                         KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                        );
-
-                if (leavecode == 0)
+            }
+            else
+            {
+                // Memory allocation failed so clean up
+                if (KeyVal.key)
                 {
-                    // Copy the key string
-                    oscl_strncpy(KeyVal.key, PVAACMETADATA_TRACKINFO_AUDIO_FORMAT_KEY, oscl_strlen(PVAACMETADATA_TRACKINFO_AUDIO_FORMAT_KEY) + 1);
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_INDEX0, oscl_strlen(PVAACMETADATA_INDEX0));
-                    oscl_strncat(KeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
-                    KeyVal.key[KeyLen-1] = 0;
-                    // Copy the value
-                    switch (iAACFileInfo.iFormat)
-                    {
-                        case EAACADTS:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_ADTS), valuelen);
-                            break;
-
-                        case EAACADIF:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_ADIF), valuelen);
-                            break;
-
-                        case EAACRaw:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), valuelen);
-                            break;
-
-                        default:
-                            break;
-                    }
-                    KeyVal.value.pChar_value[valuelen-1] = 0;
-                    // Set the length and capacity
-                    KeyVal.length = valuelen;
-                    KeyVal.capacity = valuelen;
+                    OSCL_ARRAY_DELETE(KeyVal.key);
+                    KeyVal.key = NULL;
                 }
-                else
+                if (KeyVal.value.pChar_value)
                 {
-                    // Memory allocation failed so clean up
-                    if (KeyVal.key)
-                    {
-                        OSCL_ARRAY_DELETE(KeyVal.key);
-                        KeyVal.key = NULL;
-                    }
-                    if (KeyVal.value.pChar_value)
-                    {
-                        OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
-                    }
-                    break;
+                    OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
                 }
+                break;
             }
         }
 
         // Add the KVP to the list if the key string was created
         if (KeyVal.key != NULL)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
+            leavecode = PushBackKeyVal(valuelistptr, KeyVal);
             OSCL_FIRST_CATCH_ANY(leavecode, ReleaseMetadataValue(KeyVal);
                                  break;);
 
@@ -2872,154 +2827,6 @@
     return PVMFSuccess;
 }
 
-
-void PVMFAACFFParserNode::CreateKVPForCharStringValue(PvmiKvp& aKeyVal, TAudioMetaData::FormatType aFormatType, const char* aTypeString, char* aValStr, char* aMiscKeyParam)
-{
-    // Check the format type. Only char string ones supported
-    if (aFormatType != TAudioMetaData::EISO88591_CHAR && aFormatType != TAudioMetaData::EUTF8_CHAR)
-    {
-        return;
-    }
-
-    // Validate the string pointers passed in
-    if (aTypeString == NULL || aValStr == NULL)
-    {
-        return;
-    }
-
-    uint32 KeyLen = 0;
-    KeyLen = oscl_strlen(aTypeString) + 1; // for the type string and ';'
-    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*" and NULL terminator
-    if (aFormatType == TAudioMetaData::EUTF8_CHAR)
-    {
-        KeyLen += oscl_strlen(PVAACMETADATA_CHARENCUTF8) + 1; // for ";char-encoding=UTF8"
-    }
-    if (aMiscKeyParam)
-    {
-        KeyLen += oscl_strlen(aMiscKeyParam);
-    }
-
-    uint32 valuelen = oscl_strlen(aValStr) + 1; // Add value string plus one for NULL terminator
-    // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-             aKeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-            );
-
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aTypeString, oscl_strlen(aTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
-        if (aFormatType == TAudioMetaData::EUTF8_CHAR)
-        {
-            oscl_strncat(aKeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-            oscl_strncat(aKeyVal.key, PVAACMETADATA_CHARENCUTF8, oscl_strlen(PVAACMETADATA_CHARENCUTF8));
-        }
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[KeyLen-1] = 0;
-        // Copy the value
-        oscl_strncpy(aKeyVal.value.pChar_value, aValStr, valuelen);
-        // Set the length and capacity
-        aKeyVal.length = valuelen;
-        aKeyVal.capacity = valuelen;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pChar_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pChar_value);
-        }
-    }
-}
-
-void PVMFAACFFParserNode::CreateKVPForWCharStringValue(PvmiKvp& aKeyVal, TAudioMetaData::FormatType aFormatType, const char* aTypeString, oscl_wchar* aValStr, char* aMiscKeyParam)
-{
-    // Check the format type. Only wide string ones supported
-    if (aFormatType != TAudioMetaData::EUTF16_WCHAR && aFormatType != TAudioMetaData::EUTF16BE_WCHAR)
-    {
-        return;
-    }
-
-    // Validate the string pointers passed in
-    if (aTypeString == NULL || aValStr == NULL)
-    {
-        return;
-    }
-
-    uint32 KeyLen = 0;
-    KeyLen = oscl_strlen(aTypeString) + 1; // for the type string and ';'
-    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-    KeyLen += oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR) + 1; // for "wchar*" and NULL terminator
-    if (aFormatType == TAudioMetaData::EUTF16BE_WCHAR)
-    {
-        KeyLen += oscl_strlen(PVAACMETADATA_CHARENCUTF16BE) + 1; // for ";char-encoding=UTF16BE"
-    }
-    if (aMiscKeyParam)
-    {
-        KeyLen += oscl_strlen(aMiscKeyParam);
-    }
-
-    uint32 valuelen = oscl_strlen(aValStr) + 1; // Add value string plus one for NULL terminator
-    // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-             aKeyVal.value.pWChar_value = OSCL_ARRAY_NEW(oscl_wchar, valuelen);
-            );
-
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aTypeString, oscl_strlen(aTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR));
-        if (aFormatType == TAudioMetaData::EUTF16BE_WCHAR)
-        {
-            oscl_strncat(aKeyVal.key, PVAACMETADATA_SEMICOLON, oscl_strlen(PVAACMETADATA_SEMICOLON));
-            oscl_strncat(aKeyVal.key, PVAACMETADATA_CHARENCUTF16BE, oscl_strlen(PVAACMETADATA_CHARENCUTF16BE));
-        }
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[KeyLen-1] = 0;
-        // Copy the value
-        oscl_strncpy(aKeyVal.value.pWChar_value, aValStr, valuelen);
-        // Set the length and capacity
-        aKeyVal.length = valuelen;
-        aKeyVal.capacity = valuelen;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pWChar_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pWChar_value);
-        }
-    }
-}
-
-
 PVMFStatus
 PVMFAACFFParserNode::DoSetDataSourcePosition(PVMFAACFFParserNodeCommand& aCmd)
 {
@@ -3044,35 +2851,24 @@
     iFirstFrame = true;
     aCmd.PVMFAACFFParserNodeCommand::Parse(targetNPT, actualNPT, actualMediaDataTS, jumpToIFrame, streamID);
 
-    //setting up the stream id
-    bool retVal = false;
-    // duplicate bos has been received
-    // dont perform reposition at source node
-    if (iStreamID == streamID) retVal = true;
+    // validate the parameters
+    if (actualNPT == NULL || actualMediaDataTS == NULL)
+    {
+        return PVMFErrArgument;
+    }
 
     //store to send the BOS
     iTrack.iSendBOS = true;
     //save the stream id for next media segment
     iStreamID = streamID;
 
-    if (retVal)
-    {
-        RunIfNotReady();
-        return PVMFSuccess;
-    }
-
-    if (actualNPT == NULL || actualMediaDataTS == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
     *actualNPT = 0;
     *actualMediaDataTS = 0;
 
     int32 result;
 
     // check if passed targetNPT is greater than or equal to clip duration.
-    if ((targetNPT >= iAACFileInfo.iDuration) && (iAACFileInfo.iFormat != EAACRaw))
+    if ((targetNPT >= (uint32)iAACFileInfo.iDuration) && (iAACFileInfo.iFormat != EAACRaw))
     {
         if (iAACFileInfo.iFormat == EAACADIF)
         {
@@ -3090,7 +2886,7 @@
             iTrack.iClockConverter->set_clock(0, 0);
 
             // Set the return parameters
-            *actualNPT = 0;
+            *actualNPT = iAACFileInfo.iDuration;
             *actualMediaDataTS = iTrack.iTimestampOffset;
             iTrack.oEOSReached = true;
         }
@@ -3104,9 +2900,6 @@
                 return PVMFErrResource;
             }
 
-            // Adjust the timestamp to the end of the last sample, i.e. adding the delta to next sample
-            // iTrack.iClockConverter->update_clock(timestamp);
-
             uint32 millisecTS = iTrack.iClockConverter->get_converted_ts(1000);
             *actualMediaDataTS = millisecTS;
 
@@ -3125,7 +2918,7 @@
             {
                 return PVMFErrResource;
             }
-            *actualNPT = newtimestamp;
+            *actualNPT = iAACFileInfo.iDuration;
 
             //Adjust the offset to add to future timestamps.
             iTrack.iTimestampOffset += (timestamp - newtimestamp);
@@ -3206,16 +2999,69 @@
             return PVMFErrResource;
         }
 
+        // Adjust the timestamp to the end of the last sample, i.e. adding the delta to next sample
+        //	iTrack.iClockConverter->update_clock(timestamp);
+
         uint32 millisecTS = iTrack.iClockConverter->get_converted_ts(1000);
         *actualMediaDataTS = millisecTS;
 
+        // Reset the clock to this new starting point.
+        //	iTrack.iClockConverter->set_clock(timestamp,0);
         // Reposition
         // If new position is past the end of clip, AAC FF should set the position to the last frame
         uint32 tmpuint32 = 0;
         result = iAACParser->ResetPlayback(targetNPT, tmpuint32);
         if (result != AACBitstreamObject::EVERYTHING_OK)
         {
-            return PVMFErrResource;
+            if (AACBitstreamObject::END_OF_FILE == result)
+            {
+                uint32 timestamp;
+                result = iAACParser->PeekNextTimestamp(timestamp);
+                if (result != AACBitstreamObject::EVERYTHING_OK)
+                {
+                    return PVMFErrResource;
+                }
+
+                // Adjust the timestamp to the end of the last sample, i.e. adding the delta to next sample
+                // iTrack.iClockConverter->update_clock(timestamp);
+
+                uint32 millisecTS = iTrack.iClockConverter->get_converted_ts(1000);
+                *actualMediaDataTS = millisecTS;
+
+                // Reset the track to begining of clip.
+                uint32 tmpuint32 = 0;
+                result = iAACParser->ResetPlayback(0, tmpuint32);
+                if (result != AACBitstreamObject::EVERYTHING_OK)
+                {
+                    return PVMFErrResource;
+                }
+
+                //Peek new position to get the actual new timestamp
+                uint32 newtimestamp;
+                result = iAACParser->PeekNextTimestamp(newtimestamp);
+                if (result != AACBitstreamObject::EVERYTHING_OK)
+                {
+                    return PVMFErrResource;
+                }
+                *actualNPT = newtimestamp;
+
+                //Adjust the offset to add to future timestamps.
+                iTrack.iTimestampOffset += (timestamp - newtimestamp);
+
+                MediaClockConverter mcc(1000);
+                uint32 delta = PVMF_AAC_PARSER_NODE_TS_DELTA_DURING_REPOS_IN_MS;
+                uint32 wrap_count = 0;
+                mcc.set_clock(delta, wrap_count);
+                uint32 deltaintimescale = mcc.get_converted_ts(iTrack.iClockConverter->get_timescale());
+                iTrack.iTimestampOffset += deltaintimescale;
+
+                iTrack.oEOSReached = true;
+                return PVMFSuccess;
+            }
+            else
+            {
+                return PVMFErrResource;
+            }
         }
 
         //Peek new position to get the actual new timestamp
@@ -3310,10 +3156,11 @@
 
 void PVMFAACFFParserNode::GetCPMLicenseInterface()
 {
+    iCPMLicenseInterfacePVI = NULL;
     iCPMGetLicenseInterfaceCmdId =
         iCPM->QueryInterface(iCPMSessionID,
                              PVMFCPMPluginLicenseInterfaceUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMLicenseInterface));
+                             iCPMLicenseInterfacePVI);
 }
 
 bool PVMFAACFFParserNode::GetCPMContentAccessFactory()
@@ -3329,9 +3176,11 @@
 
 bool PVMFAACFFParserNode::GetCPMMetaDataExtensionInterface()
 {
+    PVInterface* temp = NULL;
     bool retVal =
-        iCPM->queryInterface(KPVMFMetadataExtensionUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMMetaDataExtensionInterface));
+        iCPM->queryInterface(KPVMFMetadataExtensionUuid, temp);
+    iCPMMetaDataExtensionInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, temp);
+
     return retVal;
 }
 
@@ -3590,6 +3439,8 @@
         }
         else if (id == iCPMGetLicenseInterfaceCmdId)
         {
+            iCPMLicenseInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, iCPMLicenseInterfacePVI);
+            iCPMLicenseInterfacePVI = NULL;
             GetCPMMetaDataExtensionInterface();
             iCPMContentType = iCPM->GetCPMContentType(iCPMSessionID);
             if ((iCPMContentType == PVMF_CPM_FORMAT_OMA1) ||
@@ -3968,7 +3819,8 @@
                     {
                         keyFrameBit = 1;
                     }
-                    uint32 nptTS32 = Oscl_Int64_Utils::get_uint64_lower32(aTrackInfoPtr->iPrevSampleTimeStamp);
+                    uint32 nptTS32 = 0;
+                    nptTS32 = Oscl_Int64_Utils::get_uint64_lower32(aTrackInfoPtr->iPrevSampleTimeStamp);
                     PVMF_AACPARSERNODE_LOGDATATRAFFIC((0, "PVMFAACParserNode::QueueMediaSample() TrackID=%d, SeqNum=%d, SampleLen=%d, NptTS=%d, SampleTS=%d, NR=%d, KEY=%d, MimeType=%s",
                                                        aTrackInfoPtr->iTrackId,
                                                        msgOut->getSeqNum(),
@@ -3978,6 +3830,7 @@
                                                        noRender,
                                                        keyFrameBit,
                                                        aTrackInfoPtr->iTrackMimeType.get_cstr()));
+
                     status = aTrackInfoPtr->iPort->QueueOutgoingMsg(msgOut);
                     if (status != PVMFSuccess)
                     {
@@ -4368,3 +4221,43 @@
     CommandComplete(iInputCommands, aCmd, status);
     return;
 }
+
+int32 PVMFAACFFParserNode::CreateNewArray(char*& aPtr, char *aKey)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode,
+             aPtr = OSCL_ARRAY_NEW(char, oscl_strlen(aKey) + 1););
+    return leavecode;
+}
+
+int32 PVMFAACFFParserNode::CreateNewArray(char*& aPtr, int32 aLen)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode,
+             aPtr = OSCL_ARRAY_NEW(char, aLen););
+    return leavecode;
+}
+
+int32 PVMFAACFFParserNode::CreateNewArray(oscl_wchar*& aPtr, int32 aLen)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode,
+             aPtr = OSCL_ARRAY_NEW(oscl_wchar, aLen););
+    return leavecode;
+}
+
+int32 PVMFAACFFParserNode::PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, (*aValueListPtr).push_back(aKeyVal));
+    return leavecode;
+}
+
+PVMFStatus PVMFAACFFParserNode::PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetaDataKeys, PVMFMetadataList *&aKeyListPtr, uint32 aLcv)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aKeyListPtr->push_back(aRefMetaDataKeys[aLcv]));
+    OSCL_FIRST_CATCH_ANY(leavecode, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAACFFParserNode::PushValueToList() Memory allocation failure when copying metadata key"));return PVMFErrNoMemory);
+    return PVMFSuccess;
+}
+
diff --git a/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.h b/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.h
index aa40eb8..25f9408 100644
--- a/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.h
+++ b/nodes/pvaacffparsernode/src/pvmf_aacffparser_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,9 +67,6 @@
 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
 #include "pvmf_data_source_playback_control.h"
 #endif
-#ifndef AUDIOMETADATA_H_INCLUDED
-#include "audiometadata.h"
-#endif
 #ifndef AACFILEPARSER_H_INCLUDED
 #include "aacfileparser.h"
 #endif
@@ -143,7 +140,7 @@
 
 #define PVMF_AAC_PARSER_NODE_TEMPLATED_DELETE(auditCB, T, Tsimple, ptr)\
 {\
-	OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
+	OSCL_DELETE(ptre);\
 }
 
 #define PV_AAC_PARSER_NODE_ARRAY_NEW(auditCB, T, count, ptr)\
@@ -206,19 +203,6 @@
             public OsclMemPoolResizableAllocatorObserver
 {
     public:
-        enum TrackState
-        {
-            TRACKSTATE_UNINITIALIZED,
-            TRACKSTATE_INITIALIZED,
-            TRACKSTATE_TRANSMITTING_GETDATA,
-            TRACKSTATE_TRANSMITTING_SENDDATA,
-            TRACKSTATE_TRACKDATAPOOLEMPTY,
-            TRACKSTATE_MEDIADATAPOOLEMPTY,
-            TRACKSTATE_DESTFULL,
-            TRACKSTATE_SOURCEEMPTY,
-            TRACKSTATE_ENDOFTRACK,
-            TRACKSTATE_ERROR
-        };
 
         PVAACFFNodeTrackPortInfo()
         {
@@ -226,7 +210,6 @@
             iTrackId = -1;
             iPort = NULL;
             iClockConverter = NULL;
-            iState = TRACKSTATE_UNINITIALIZED;
             iTrackDataMemoryPool = NULL;
             iTrackDataMemoryPoolProxy = NULL;
             iMediaDataImplAlloc = NULL;
@@ -238,7 +221,7 @@
             iSendBOS = false;
 
             /////////////////////////////////////////////////////
-            iFormatType                   = PVMF_FORMAT_UNKNOWN;
+            iFormatType                   = PVMF_MIME_FORMAT_UNKNOWN;
             iSeqNum                       = 0;
             oEOSReached                   = false;
             oEOSSent                      = false;
@@ -277,7 +260,6 @@
             iClockConverter = aSrc.iClockConverter;
             iFormatSpecificConfig = aSrc.iFormatSpecificConfig;
             iMediaData = aSrc.iMediaData;
-            iState = aSrc.iState;
             iTrackDataMemoryPool = aSrc.iTrackDataMemoryPool;
             iTrackDataMemoryPoolProxy = aSrc.iTrackDataMemoryPoolProxy;
             iMediaDataImplAlloc = aSrc.iMediaDataImplAlloc;
@@ -381,8 +363,6 @@
 
         // Shared memory pointer holding the currently retrieved track data
         PVMFSharedMediaDataPtr iMediaData;
-        // Current state of this track
-        TrackState iState;
         // Output buffer memory pool
         OsclMemPoolResizableAllocator *iTrackDataMemoryPool;
         // Allocator wrapper for the output buffer memory pool
@@ -578,7 +558,7 @@
         }
 
         // Constructor and parser for SetDataSourceRate
-        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, OsclTimebase* aTimebase, const OsclAny*aContext)
+        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny*aContext)
         {
             PVMFAACFFParserNodeCommandBase::Construct(s, cmd, aContext);
             iParam1 = (OsclAny*)aRate;
@@ -587,10 +567,10 @@
             iParam4 = NULL;
             iParam5 = NULL;
         }
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
         {
             aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
+            aTimebase = (PVMFTimebase*)iParam2;
         }
 
         /* Constructor and parser for GetLicenseW */
@@ -751,8 +731,8 @@
         bool queryInterface(const PVUuid& uuid, PVInterface *& iface);
 
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         //From PVMFTrackSelectionExtensionInterface
         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
@@ -812,7 +792,7 @@
                                                                     , bool aSeekToSyncPoint = true);
         PVMFCommandId SetDataSourceRate(PVMFSessionId aSession
                                         , int32 aRate
-                                        , OsclTimebase* aTimebase = NULL
+                                        , PVMFTimebase* aTimebase = NULL
                                                                     , OsclAny* aContext = NULL);
 
         /* From PVMFCPMPluginLicenseInterface */
@@ -921,8 +901,6 @@
         // For metadata extention interface
         PVMFStatus DoGetMetadataKeys(PVMFAACFFParserNodeCommand& aCmd);
         PVMFStatus DoGetMetadataValues(PVMFAACFFParserNodeCommand& aCmd);
-        void CreateKVPForCharStringValue(PvmiKvp& aKeyVal, TAudioMetaData::FormatType aFormatType, const char* aTypeString, char* aValChar, char* aMiscKeyParam = NULL);
-        void CreateKVPForWCharStringValue(PvmiKvp& aKeyVal, TAudioMetaData::FormatType aFormatType, const char* aTypeString, oscl_wchar* aValWChar, char* aMiscKeyParam = NULL);
 
         void CompleteGetMetaDataValues();
         int32 AddToValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, PvmiKvp& aNewValue);
@@ -941,7 +919,6 @@
         // Track data processing
         bool RetrieveTrackConfigInfo(PVAACFFNodeTrackPortInfo& aTrackPortInfo);
         bool RetrieveTrackData(PVAACFFNodeTrackPortInfo& aTrackPortInfo);
-        bool SendTrackData(PVAACFFNodeTrackPortInfo& aTrackPortInfo);
         bool SendEndOfTrackCommand(PVAACFFNodeTrackPortInfo& aTrackPortInfo);
 
         void ResetAllTracks();
@@ -983,7 +960,7 @@
         PVAACFFNodeTrackPortInfo iTrack;
         bool iFirstFrame;
 
-        OsclClock* iClientClock;
+        PVMFMediaClock* iClientClock;
         void ResetSourceFile();
         bool oSourceIsCurrent;
 
@@ -1026,6 +1003,7 @@
         PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
         PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
         PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
+        PVInterface* iCPMLicenseInterfacePVI;
         PvmiKvp iRequestedUsage;
         PvmiKvp iApprovedUsage;
         PvmiKvp iAuthorizationDataKvp;
@@ -1057,6 +1035,13 @@
         void GetCPMMetaDataKeys();
         void GetCPMMetaDataValues();
         PVMFStatus CheckCPMCommandCompleteStatus(PVMFCommandId, PVMFStatus);
+        int32 CreateNewArray(char*& aPtr, char *aKey);
+        int32 CreateNewArray(char*& aPtr, int32 aLen);
+        int32 CreateNewArray(oscl_wchar*& aPtr, int32 aLen);
+        int32 PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal);
+        PVMFStatus PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetadataKeys,
+                                   PVMFMetadataList *&aKeyListPtr,
+                                   uint32 aLcv);
         PVMFStatus iCPMRequestUsageCommandStatus;
 
         PVMFStatus DoGetLicense(PVMFAACFFParserNodeCommand& aCmd,
@@ -1087,7 +1072,6 @@
         char iLogFileIndex;
         OSCL_HeapString<PVMFAACParserNodeAllocator> portLogPath;
 
-        void Assert(bool);
         PVMFStatus ParseAACFile();
 };
 
diff --git a/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.cpp b/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.cpp
index 4566d6b..4521f00 100644
--- a/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.cpp
+++ b/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,8 +51,13 @@
 
 bool PVMFAACFFParserOutPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return (aFmt == PVMF_MPEG4_AUDIO ||
-            aFmt == PVMF_ADIF);
+    bool formatSupported = false;
+    if (aFmt == PVMF_MIME_MPEG4_AUDIO ||
+            aFmt == PVMF_MIME_ADIF)
+    {
+        formatSupported = true;
+    }
+    return formatSupported;
 }
 
 void PVMFAACFFParserOutPort::FormatUpdated()
@@ -78,10 +83,9 @@
         return PVMFFailure;
     }
 
-    PvmiCapabilityAndConfig *config;
-
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                          (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
     if (config != NULL)
     {
diff --git a/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.h b/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.h
index 694c420..bd478f8 100644
--- a/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.h
+++ b/nodes/pvaacffparsernode/src/pvmf_aacffparser_outport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrencnode/Android.mk b/nodes/pvamrencnode/Android.mk
deleted file mode 100644
index ccb91d0..0000000
--- a/nodes/pvamrencnode/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/pvmf_amrenc_node.cpp \
-	src/pvmf_amrenc_port.cpp \
-	src/pvmf_amrenc_data_processor.cpp \
-	src/pvmf_amrenc_media_buffer.cpp \
-	src/pvmf_amrenc_node_cap_config.cpp
-
-
-
-LOCAL_MODULE := libpvamrencnode
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvamrencnode/include \
-	$(PV_TOP)//nodes/pvamrencnode/src \
-	$(PV_TOP)//nodes/pvamrencnode/src \
-	$(PV_TOP)//nodes/pvamrencnode/../../codecs_v2/audio/gsm_amr/amr_nb/enc/include \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/pvmfamrencnode_extension.h \
-	include/pvmf_amrenc_node_factory.h \
-	include/pvmf_amrenc_node_types.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvamrencnode/build/make/makefile b/nodes/pvamrencnode/build/make/makefile
deleted file mode 100755
index 3bbf808..0000000
--- a/nodes/pvamrencnode/build/make/makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvamrencnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-XCPPFLAGS +=
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-XINCDIRS += -I ../../src -I ../../../../codecs_v2/audio/gsm_amr/amr_nb/enc/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_amrenc_node.cpp \
-		pvmf_amrenc_port.cpp \
-		pvmf_amrenc_data_processor.cpp \
-		pvmf_amrenc_media_buffer.cpp \
-		pvmf_amrenc_node_cap_config.cpp
-
-		
-
-HDRS =	pvmfamrencnode_extension.h \
-		pvmf_amrenc_node_factory.h \
-		pvmf_amrenc_node_types.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvamrencnode/include/pvmf_amrenc_node_factory.h b/nodes/pvamrencnode/include/pvmf_amrenc_node_factory.h
deleted file mode 100644
index 0d265f7..0000000
--- a/nodes/pvamrencnode/include/pvmf_amrenc_node_factory.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
-#define PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-// Forward declarations
-class PVMFNodeInterface;
-
-#define PvmfAmrEncNodeUuid PVUuid(0x8274e1d1, 0xd604, 0x43e6, 0xa8, 0xd4, 0xb9, 0x7a, 0x14, 0x0e, 0x14, 0x4c)
-
-/**
- * Factory class for PvmfAmrEncNode
- */
-class PvmfAmrEncNodeFactory
-{
-    public:
-        /**
-         * Creates an instance of a PV AMR Encoder node
-         *
-         * @param aPriority Priority of active objects of PvmfAmrEncNode
-         * @returns A pointer to an author or NULL if instantiation fails
-         **/
-        OSCL_IMPORT_REF static PVMFNodeInterface* Create(int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        /**
-         * This function allows the application to delete an instance of file input node
-         * and reclaim all allocated resources.  An instance can be deleted only in
-         * the idle state. An attempt to delete in any other state will fail and return false.
-         *
-         * @param aNode The file input node to be deleted.
-         * @returns A status code indicating success or failure.
-         **/
-        OSCL_IMPORT_REF static bool Delete(PVMFNodeInterface* aNode);
-};
-
-#endif // PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvamrencnode/include/pvmf_amrenc_node_types.h b/nodes/pvamrencnode/include/pvmf_amrenc_node_types.h
deleted file mode 100644
index cebf65f..0000000
--- a/nodes/pvamrencnode/include/pvmf_amrenc_node_types.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_NODE_TYPES_H_INCLUDED
-#define PVMF_AMRENC_NODE_TYPES_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-///////////////////////////////////////////////
-// Port tags
-///////////////////////////////////////////////
-
-/** Enumerated list of port tags supported by the node for the port requests.*/
-typedef enum
-{
-    PVMF_AMRENC_NODE_PORT_TYPE_INPUT = 0,
-    PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT
-} PVMFVideoEncNodePortType;
-
-///////////////////////////////////////////////
-// Error Events
-///////////////////////////////////////////////
-
-enum PVMFVideoEncNodeErrorEvent
-{
-    PVMF_AMRENC_NODE_ERROR_ENCODE_ERROR = PVMF_NODE_ERROR_EVENT_LAST
-};
-
-///////////////////////////////////////////////
-// Information Events
-///////////////////////////////////////////////
-
-// Enumerated list of informational event from PVMFVideoEncNode
-enum PVMFVideoEncNodeInfoEvent
-{
-    PVMF_AMRENC_NODE_INFO = PVMF_NODE_INFO_EVENT_LAST
-};
-
-
-#endif // PVMF_AMRENC_NODE_TYPES_H_INCLUDED
diff --git a/nodes/pvamrencnode/include/pvmfamrencnode_extension.h b/nodes/pvamrencnode/include/pvmfamrencnode_extension.h
deleted file mode 100644
index 3c3fea9..0000000
--- a/nodes/pvamrencnode/include/pvmfamrencnode_extension.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- * @file pvmfamrencnode_extension.h
- */
-
-#ifndef PVMFAMRENCNODE_EXTENSION_H_INCLUDED
-#define PVMFAMRENCNODE_EXTENSION_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef PV_UUID_H_INCLUDED
-#include "pv_uuid.h"
-#endif
-#ifndef PV_INTERFACE_H_INCLUDED
-#include "pv_interface.h"
-#endif
-
-#define PVAMREncExtensionUUID PVUuid(0xd282cc91,0x54a6,0x4f36,0xbc,0x5b,0x2d,0xab,0xb4,0x40,0x69,0x26)
-
-/**
- * Enumerated list of output bitrate
- */
-
-typedef enum
-{
-    GSM_AMR_4_75 = 0,
-    GSM_AMR_5_15,
-    GSM_AMR_5_90,
-    GSM_AMR_6_70,
-    GSM_AMR_7_40,
-    GSM_AMR_7_95,
-    GSM_AMR_10_2,
-    GSM_AMR_12_2,
-    GSM_AMR_DTX,
-    GSM_AMR_N_MODES      /* number of (SPC) modes */
-} PVMF_GSMAMR_Rate;
-
-
-////////////////////////////////////////////////////////////////////////////
-class PVAMREncExtensionInterface : public PVInterface
-{
-    public:
-        /** Increment reference counter for this interface. */
-        virtual void addRef() = 0;
-
-        /** Decrement reference counter for this interface. */
-        virtual void removeRef() = 0;
-
-        /**
-         * Query for a pointer to an instance of the interface specified by the UUID.
-         *
-         * @param uuid UUID of the interface to be queried.
-         * @param iface Output parameter where a pointer to an instance of the requested
-         * interface is stored if the interface is supported.
-         * @return true if successful, else false.
-         */
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
-
-        /**
-         * Sets the bitrate of encoded output.
-         * @param aBitRate Bitrate in bits per second.
-         * @return PVMFSuccess if successful, else see PVMF return code.
-         */
-        virtual PVMFStatus SetOutputBitRate(PVMF_GSMAMR_Rate aBitRate) = 0;
-
-        /**
-         * Sets the maximum number of output frames per media buffer
-         * @param aNumOutputFrames, maximum number of output frames
-         * @return PVMFSuccess if successful, else see PVMF return code.
-         */
-        virtual PVMFStatus SetMaxNumOutputFramesPerBuffer(uint32 aNumOutputFrames) = 0;
-};
-
-#endif // PVMFAMRENCNODE_EXTENSION_H_INCLUDED
-
-
-
-
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_data_processor.cpp b/nodes/pvamrencnode/src/pvmf_amrenc_data_processor.cpp
deleted file mode 100644
index 177ddd2..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_data_processor.cpp
+++ /dev/null
@@ -1,686 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- * @file pvmf_amrenc_data_processor.cpp
- * @brief Data processor to encode PCM16 data to AMR-IETF and AMR-IF2 using PV AMR encoder library
- */
-#ifndef PVMF_AMRENC_DATA_PROCESSOR_H_INCLUDED
-#include "pvmf_amrenc_data_processor.h"
-#endif
-#ifndef PVMF_AMRENC_TUNEABLES_INCLUDED
-#include "pvmf_amrenc_tuneables.h"
-#endif
-#ifndef GSMAMR_ENCODER_H_INCLUDED
-#include "gsmamr_encoder_wrapper.h"
-#endif
-
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncDataProcessor::PvmfAmrEncDataProcessor()
-        : iMediaOutMemoryPool(OUTPUT_BITSTREAMBUFFER_POOLNUM),
-        iMediaDataMemPool(OUTPUT_MEDIADATA_POOL_SIZE)
-{
-    int32 err = 0;
-    Construct();
-    OSCL_TRY(err,
-             // Reserve for data queue
-             iIncomingDataQueue.reserve(PVMF_AMRENC_NODE_PORT_ACTIVITY_RESERVE);
-
-             // Create media data allocator
-             iMediaOutAlloc = OSCL_NEW(PvmfAmrEncBufferAlloc, (&iMediaOutMemoryPool));
-             if (!iMediaOutAlloc)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         // If a leave happened, cleanup and re-throw the error
-                         iIncomingDataQueue.clear();
-                         OSCL_LEAVE(err);
-                        );
-
-    iLogger = PVLogger::GetLoggerObject("PvmfAmrEncDataProcessor");
-    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvauthordiagnostics.encnode.amrencnode");
-
-#if PROFILING_ON
-    total_ticks = 0;
-    total_frames = 0;
-    iFinalTimeStamp = 0;
-    iMinEncDuration = 0;
-    iMaxEncDuration = 0;
-    iAverageEncDuration = 0;
-    oDiagnosticsLogged = false;
-#endif
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncDataProcessor::~PvmfAmrEncDataProcessor()
-{
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-    Reset();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncDataProcessor::LogDiagnostics()
-{
-#if PROFILING_ON
-    oDiagnosticsLogged = true;
-    uint32 enctime = OsclTickCount::TicksToMsec(total_ticks);
-    if (total_frames > 0)
-    {
-        iAverageEncDuration = enctime / total_frames;
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFAMREncNode Diagnostics: NumFrames=%d, Final Timestamp=%d, encode time(in ms)[Total:%d, Max:%d, Min:%d, Average:%d]\n",
-                    total_frames, iFinalTimeStamp, OsclTickCount::TicksToMsec(total_ticks), iMaxEncDuration, iMinEncDuration, iAverageEncDuration));
-#endif
-
-}
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::ThreadLogon()
-{
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::ThreadLogoff()
-{
-    iLogger = NULL;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::QueryInterface(const PVUuid& uuid, PVInterface*& aface)
-{
-    if (queryInterface(uuid, aface))
-        return PVMFSuccess;
-    else
-        return PVMFFailure;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::QueryUUID(const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-        bool aExactUuidsOnly)
-{
-    OSCL_UNUSED_ARG(aMimeType);
-    OSCL_UNUSED_ARG(aExactUuidsOnly);
-
-    int32 err = 0;
-    OSCL_TRY(err, aUuids.push_back(PVAMREncExtensionUUID););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncDataProcessor::QueryUUID: Error - aUuid.push_back() failed"));
-                         return PVMFErrNoMemory;
-                        );
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::Initialize()
-{
-    // Create encoder object and encoder settings
-    int32 err = 0;
-    OSCL_TRY(err,
-             iGsmEncoder = OSCL_NEW(CPvGsmAmrEncoder, ());
-             if (!iGsmEncoder)
-             OSCL_LEAVE(OsclErrNoMemory);
-
-             // for encoder properties
-             iEncProps = OSCL_NEW(TEncodeProperties, ());
-             if (!iEncProps)
-                 OSCL_LEAVE(OsclErrNoMemory);
-                );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncDataProcessor::Initialize: Error - Encoder / encoder property creation failed"));
-                         return PVMFErrNoMemory;
-                        );
-
-    iEncProps->iInBitsPerSample  = iInputBitsPerSample;
-    iEncProps->iInSamplingRate   = iInputSamplingRate;
-    iEncProps->iInClockRate      = 1000; //iEncProps->iInSamplingRate;
-    iEncProps->iInNumChannels    = (uint8)iInputNumChannels;
-    iEncProps->iInInterleaveMode = TEncodeProperties::EINTERLEAVE_LR;
-
-    iEncProps->iMode			   = (int32)iOutputBitrate;
-    iEncProps->iBitStreamFormatIf2 = (iOutputFormat == PVMF_AMR_IF2);
-    iEncProps->iAudioObjectType    = 0; // only for AAC encoder
-    iEncProps->iOutSamplingRate    = iInputSamplingRate;
-    iEncProps->iOutNumChannels     = (uint8)iInputNumChannels;
-    iEncProps->iOutClockRate       = iEncProps->iInClockRate ; // set the sampling rate , but not sure at this point
-
-    // initialize the amr encoder, cause memory buffer overflow problem in the encoding
-    LOG_DEBUG((0, "PvmfAmrEncDataProcessor::Initialize: Calling InitializeEncoder()"));
-
-    // initialize the amr encoder, cause memory buffer overflow problem in the encoding
-    // when I set the maximum output buffer size as KGsmBlockSize, so set it as large value
-    iMaxOutputBufferSize = iMaxNumOutputFramesPerBuffer * MAX_AMR_FRAME_SIZE;
-    if (iGsmEncoder->InitializeEncoder(iMaxOutputBufferSize, iEncProps) < 0) // MAX_AMR_FRAME_SIZE = 32
-    {
-        LOG_ERR((0, "PvmfAmrEncDataProcessor::Initialize: Error - InitializeEncoder() failed"));
-        return PVMFFailure;
-    }
-
-    OSCL_TRY(err,
-             iSizeArrayForOutputFrames = (int32*)iAlloc.allocate(sizeof(int32) * iMaxNumOutputFramesPerBuffer);
-             if (!iSizeArrayForOutputFrames)
-             OSCL_LEAVE(OsclErrNoMemory);
-             oscl_memset(iSizeArrayForOutputFrames, 0, iMaxNumOutputFramesPerBuffer*sizeof(int32));
-
-             iOneInputFrameLength = AMR_FRAME_LENGTH_IN_TIMESTAMP * iInputSamplingRate * iInputBitsPerSample / 8000;
-             iMax_input_size = iMaxNumOutputFramesPerBuffer * iOneInputFrameLength;
-             iInternalInputBuffer = (uint8*)iAlloc.allocate(iMax_input_size);
-             if (!iInternalInputBuffer)
-                 OSCL_LEAVE(OsclErrNoMemory);
-                 oscl_memset(iInternalInputBuffer, 0, iMax_input_size);
-                );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncDataProcessor::Initialize: Error - iSizeArrayForOutputFrames or iInternalInputBuffer allocation failed"));
-                         return PVMFErrNoMemory;
-                        );
-
-    iInitialized = true;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::Reset()
-{
-    iInitialized = false;
-    iIncomingDataQueue.clear();
-
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-
-    if (iGsmEncoder)
-    {
-        iGsmEncoder->CleanupEncoder();
-        OSCL_DELETE(iGsmEncoder);
-    }
-
-    if (iEncProps)
-        OSCL_DELETE(iEncProps);
-
-    if (iMediaOutAlloc)
-        OSCL_DELETE(iMediaOutAlloc);
-
-    if (iSizeArrayForOutputFrames)
-        iAlloc.deallocate(iSizeArrayForOutputFrames);
-
-    if (iInternalInputBuffer)
-        iAlloc.deallocate(iInternalInputBuffer);
-
-    Construct();
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::QueueIncomingData(PVMFSharedMediaDataPtr& aMediaDataIn)
-{
-    if (!iInitialized)
-    {
-        LOG_ERR((0, "PvmfAmrEncDataProcessor::Process: Error - Encoder not initialized"));
-        return PVMFErrNotReady;
-    }
-
-    int32 err = 0;
-    OSCL_TRY(err, iIncomingDataQueue.push_back(aMediaDataIn););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncDataProcessor::Process: Error - iIncomingDataQueue.push_back() failed"));
-                         return PVMFErrNoMemory;
-                        );
-
-    if (IsEnoughDataToEncode())
-        Encode();
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncDataProcessor::Encode()
-{
-    PVMFSharedMediaDataPtr mediaDataOut;
-    int32 err = 0;
-
-    BufferInfo bufferInfo;
-    if (!GetNewInputBuffer(bufferInfo))
-    {
-        LOG_DEBUG((0, "PvmfAmrEncDataProcessor::Encode: Not enough data"));
-        return; // Not enough data
-    }
-
-    // 2. create output buffer pointer
-    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
-    OSCL_TRY(err, mediaDataImpl = iMediaOutAlloc->allocate(MAX_AMR_FRAME_SIZE, iMaxNumOutputFramesPerBuffer));
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncDataProcessor::Encode: Error - Memory for mediaDataImpl could not be allocated"));
-                         iObserver->ProcessComplete(ProcessNoOutputMemory, mediaDataOut);
-                         return;
-                        );
-
-    OSCL_TRY(err, mediaDataOut = PVMFMediaData::createMediaData(mediaDataImpl, &iMediaDataMemPool));
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncDataProcessor::Encode: Error - Memory for mediaData could not be allocated"));
-                         iObserver->ProcessComplete(ProcessNoOutputMemory, mediaDataOut);
-                         return;
-                        );
-
-    OsclRefCounterMemFrag memFragOut;
-    mediaDataOut->getMediaFragment(0, memFragOut);
-
-    TOutputAudioStream output;
-    output.iBitStreamBuffer = (uint8*)memFragOut.getMemFragPtr();
-    output.iNumSampleFrames = 0;
-    output.iSampleFrameSize = iSizeArrayForOutputFrames;
-
-    // We already figured out the pointer and buffer size and then do encoding
-    int32 input_frame_num = bufferInfo.ptrLength / iOneInputFrameLength; //mediaDataPtr->getNumFragments();
-
-    TInputAudioStream input;
-    input.iSampleBuffer = bufferInfo.ptr;
-    input.iSampleLength = (int32)bufferInfo.ptrLength;
-    input.iMode			= iEncProps->iMode;
-    input.iStartTime	= (iNextStartTime >= bufferInfo.tsInFirstMediaData  ? iNextStartTime : bufferInfo.tsInFirstMediaData);
-    input.iStopTime		= input.iStartTime + AMR_FRAME_LENGTH_IN_TIMESTAMP * input_frame_num; // 20ms
-    iNextStartTime		= input.iStopTime; // for the next encoding
-
-    // 3. do encoding at one time for multiple frame input
-#if PROFILING_ON
-    uint32 start_ticks = OsclTickCount::TickCount();
-#endif
-    if (iGsmEncoder->Encode(input, output) < 0 || output.iNumSampleFrames != input_frame_num)
-    {
-        LOG_ERR((0, "PvmfAmrEncDataProcessor::Encode: Error - iGsmEncoder->Encode() failed"));
-        iObserver->ProcessComplete(ProcessError, mediaDataOut);
-        return;
-    }
-#if PROFILING_ON
-    uint32 end_ticks = OsclTickCount::TickCount();
-    uint32 enctime = OsclTickCount::TicksToMsec(end_ticks - start_ticks);
-    if ((iMinEncDuration > enctime) || (0 == iMinEncDuration))
-    {
-        iMinEncDuration = enctime;
-    }
-
-    if (iMaxEncDuration < enctime)
-    {
-        iMaxEncDuration = enctime;
-    }
-
-    total_ticks += (end_ticks - start_ticks);
-    total_frames += 1;
-    iFinalTimeStamp = input.iStopTime;
-#endif
-
-    // For IETF, make a conversion from WMF
-    uint8 *tmp_buff = output.iBitStreamBuffer;
-    uint32 i;
-    for (i = 0; i < (uint32)output.iNumSampleFrames; i++)
-    {
-        // for IETF format, we need to make change
-        if (!iEncProps->iBitStreamFormatIf2)  // non-IF2 => IETF format, not WMF format
-        {
-            tmp_buff[0] = (uint8)(((tmp_buff[0] << 3) | 0x4) & 0x7C); // IETF frame header: P(1) + FT(4) + Q(1) + P(2) , Q=1 for good frame, P=padding bit, 0
-            tmp_buff += output.iSampleFrameSize[i];
-        }
-
-        // Set fragment length
-        mediaDataOut->setMediaFragFilledLen(i, output.iSampleFrameSize[i]);
-    }
-
-    // Set timestamp
-    mediaDataOut->setTimestamp(input.iStartTime);
-
-    // Set sequence number
-    mediaDataOut->setSeqNum(iSeqNum++);
-
-    if (bufferInfo.bNeedDequeue)
-    {
-        // Remove from incoming queue
-        iIncomingDataQueue.erase(iIncomingDataQueue.begin());
-    }
-
-    PvmfAmrEncDataProcessResult result;
-    if (bufferInfo.bContinueProcessing)
-        result = ProcessComplete_EnoughDataToContinueProcessing;
-    else
-        result = ProcessComplete_NotEnoughDataInQueue;
-
-    // Send frame back to the node
-    iObserver->ProcessComplete(result, mediaDataOut);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::SetInputSamplingRate(uint32 aSamplingRate)
-{
-    if (aSamplingRate != 8000)
-        return PVMFErrNotSupported;
-    iInputSamplingRate = aSamplingRate;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::SetInputBitsPerSample(uint32 aBitsPerSample)
-{
-    if (aBitsPerSample != 16)
-        return PVMFErrNotSupported;
-    iInputBitsPerSample = aBitsPerSample;
-    return PVMFSuccess;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::SetInputNumChannels(uint32 aNumChannels)
-{
-    if (aNumChannels != 1)
-        return PVMFErrNotSupported;
-    iInputNumChannels = aNumChannels;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncDataProcessor::SetOutputFormat(PVMFFormatType aFormat)
-{
-    if (aFormat != PVMF_AMR_IETF && aFormat != PVMF_AMR_IF2)
-        return PVMFErrNotSupported;
-
-    iOutputFormat = aFormat;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PvmfAmrEncDataProcessor::GetOutputBitRate()
-{
-    switch (iOutputBitrate)
-    {
-        case GSM_AMR_4_75:
-            return 4750;
-        case GSM_AMR_5_15:
-            return 5150;
-        case GSM_AMR_5_90:
-            return 5900;
-        case GSM_AMR_6_70:
-            return 6700;
-        case GSM_AMR_7_40:
-            return 7400;
-        case GSM_AMR_7_95:
-            return 7950;
-        case GSM_AMR_10_2:
-            return 10200;
-        case GSM_AMR_12_2:
-            return 12200;
-        default:
-            return 0;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//         Virtual functions of PVAMREncExtensionInterface
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncDataProcessor::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncDataProcessor::removeRef()
-{
-    if (iExtensionRefCount > 0) --iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PvmfAmrEncDataProcessor::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    if (uuid == PVAMREncExtensionUUID)
-    {
-        PVAMREncExtensionInterface* myInterface = OSCL_STATIC_CAST(PVAMREncExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else
-    {
-        iface = NULL;
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncDataProcessor::SetOutputBitRate(PVMF_GSMAMR_Rate aBitRate)
-{
-    iOutputBitrate = aBitRate;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncDataProcessor::SetMaxNumOutputFramesPerBuffer(uint32 aNumOutputFrames)
-{
-    iMaxNumOutputFramesPerBuffer = aNumOutputFrames;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                           Private methods
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncDataProcessor::Construct()
-{
-    // Codec and encoder setting structure
-    iGsmEncoder = NULL;
-    iEncProps   = NULL;
-
-    // Default values
-    iInputSamplingRate  = 8000;
-    iInputBitsPerSample = 16;
-    iInputNumChannels   = 1;
-    iOutputBitrate		= GSM_AMR_12_2;
-    iOutputFormat	    = PVMF_AMR_IETF;
-    iMaxNumOutputFramesPerBuffer = 25;
-    iInitialized		= false;
-
-    iSizeArrayForOutputFrames	= NULL;
-    iInternalInputBuffer		= NULL;
-    iMax_input_size				= 0;
-    iOneInputFrameLength		= 320;
-    iPosForInputMediaDataBuffer = 0;
-    iNextStartTime				= 0;
-
-    // Other stuff
-    iSeqNum = 0;
-    iExtensionRefCount = 0;
-
-    iMediaOutAlloc      = NULL;
-    iLogger = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PvmfAmrEncDataProcessor::GetTotalAvailableDataSize()
-{
-    uint32 i = 0, total_available_data_size = 0;
-
-    for (i = 0; i < iIncomingDataQueue.size(); i++)
-    {
-        PVMFSharedMediaDataPtr mediaDataPtr = iIncomingDataQueue[i];
-        total_available_data_size += mediaDataPtr->getFilledSize();
-    }
-
-    total_available_data_size -= iPosForInputMediaDataBuffer;
-    return total_available_data_size;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncDataProcessor::IsEnoughDataToEncode()
-{
-    return (GetTotalAvailableDataSize() >= iOneInputFrameLength);
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncDataProcessor::GetNewInputBuffer(BufferInfo &aBufferInfo)
-{
-    // Get the current available data size in the input buffer queue
-    uint32 total_available_data_size = 0;
-    uint8 *ptrIn = NULL;
-    uint32 ptrLength = 0;
-
-    total_available_data_size = GetTotalAvailableDataSize();
-    if (!IsEnoughDataToEncode())
-    {
-        LOG_DEBUG((0, "PvmfAmrEncDataProcessor::GetNewInputBuffer: Not enough data"));
-        return false; // No enough data
-    }
-
-    // total available data size is big enough, at least for one frame encoding
-    bool bNeedDeque = true, bContinueProcessing = false;
-    PVMFSharedMediaDataPtr mediaDataPtr = iIncomingDataQueue[0];
-    ptrLength = mediaDataPtr->getFilledSize() - iPosForInputMediaDataBuffer;
-    uint32 tsInFirstMediaData = mediaDataPtr->getTimestamp();
-
-    if (ptrLength >= iMax_input_size || /* current available media data length is big enough */
-            iIncomingDataQueue.size() == 1)    /* only one media data buffer */
-    {
-        // (1) the first buffer in the queue is big enough, definitely able to fill up the internal buffer
-        // (2) there is only one buffer in the queue (whatever the buffer size is, but the bottom line is
-        //	   the buffer size should be larger than one frame size)
-        // no need to copy to the internal buffer
-        ptrLength = pv_min(ptrLength, iMax_input_size);
-        ptrLength -= (ptrLength % iOneInputFrameLength); // make ptrLength one pcm frame length aligned
-
-        // get the buffer pointer
-        OsclRefCounterMemFrag memFrag;
-        mediaDataPtr->getMediaFragment(0, memFrag);
-        ptrIn = (uint8*)memFrag.getMemFragPtr();
-        ptrIn += iPosForInputMediaDataBuffer;
-
-        // update iPosForInputMediaDataBuffer
-        iPosForInputMediaDataBuffer += ptrLength;
-        if (iPosForInputMediaDataBuffer == mediaDataPtr->getFilledSize())
-        {
-            // this buffer is consumed
-            iPosForInputMediaDataBuffer = 0;
-            bNeedDeque = true;
-        }
-        else   // still has data
-        {
-            bNeedDeque = false;
-        }
-    }
-    else
-    {
-        // buffer queue has multiple buffers, but the first buffer in the queue is not able to
-        // fill up the whole internal buffer
-        // Then we have to make a copy and use internal buffer instead
-
-        // first, we need to calculate the maximum allowable filled size using total_available_data_size calculated above
-        uint32 max_filled_size = pv_min(total_available_data_size, iMax_input_size);
-        max_filled_size -= (max_filled_size % iOneInputFrameLength); // make max_filled_size one frame aligned
-
-        uint32 max_copy_size = max_filled_size;
-        uint8 *ptrForInternalBuffer = iInternalInputBuffer;
-        do
-        {
-            OsclRefCounterMemFrag memFrag;
-            mediaDataPtr->getMediaFragment(0, memFrag);
-            ptrIn = (uint8*)memFrag.getMemFragPtr();
-            ptrIn += iPosForInputMediaDataBuffer;
-            ptrLength = mediaDataPtr->getFilledSize() - iPosForInputMediaDataBuffer;
-            uint32 copy_size = pv_min(ptrLength, max_copy_size);
-            oscl_memcpy(ptrForInternalBuffer, ptrIn, copy_size);
-
-            if (ptrLength >= max_copy_size)
-            {
-                if (ptrLength == max_copy_size)
-                {
-                    // a whole buffer is consumed
-                    iPosForInputMediaDataBuffer = 0;
-
-                    // Remove from incoming queue
-                    iIncomingDataQueue.erase(iIncomingDataQueue.begin());
-                }
-                else
-                {
-                    iPosForInputMediaDataBuffer += copy_size;
-                }
-
-                // finalize the pointer and length for the input of amr encoding
-                ptrIn = iInternalInputBuffer;
-                ptrLength = max_filled_size;
-
-                bNeedDeque = false;
-                break;
-            }
-
-            // the internal buffer isn't full yet, needs to be re-filled with a new media data buffer
-            // Remove from incoming queue
-            iIncomingDataQueue.erase(iIncomingDataQueue.begin());
-
-            // Note that no need to check the buffer queue is empty of not, because the above break point should be reached
-            // get a new media buffer
-            mediaDataPtr = iIncomingDataQueue[0];
-
-            // other updates
-            iPosForInputMediaDataBuffer = 0;
-            max_copy_size -= copy_size;
-            ptrForInternalBuffer += copy_size;
-
-        }
-        while (max_filled_size); // max_filled_size is always larger than zero, infinite loop, remove the warning if putting "while(1)"
-    }
-
-    // for efficiency, check the data after the encoding is enough for the next round of encoding
-    total_available_data_size -= ptrLength;
-    if (total_available_data_size >= iOneInputFrameLength) // data is enough for one frame encoding
-        bContinueProcessing = true;
-    else
-        bContinueProcessing = false;
-
-    // set aBufferInfo
-    aBufferInfo.ptr					= ptrIn;
-    aBufferInfo.ptrLength			= ptrLength;
-    aBufferInfo.bContinueProcessing = bContinueProcessing;
-    aBufferInfo.bNeedDequeue		= bNeedDeque;
-    aBufferInfo.tsInFirstMediaData  = tsInFirstMediaData;
-
-    return true;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_data_processor.h b/nodes/pvamrencnode/src/pvmf_amrenc_data_processor.h
deleted file mode 100644
index bc03b73..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_data_processor.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- *
- * @file pvvideoencmdf_node.h
- * @brief Node for PV Video Encoder MDFs. This node
- * encodes raw video data (YUV/RGB) to MP4 or H263 formats.
- *
- */
-#ifndef PVMF_AMRENC_DATA_PROCESSOR_H_INCLUDED
-#define PVMF_AMRENC_DATA_PROCESSOR_H_INCLUDED
-
-#ifndef PVMF_AMRENC_DATA_PROCESSOR_INTERFACE_H_INCLUDED
-#include "pvmf_amrenc_data_processor_interface.h"
-#endif
-#ifndef PVMF_AMRENC_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_amrenc_media_buffer.h"
-#endif
-#ifndef PVMFAMRENCNODE_EXTENSION_H_INCLUDED
-#include "pvmfamrencnode_extension.h"
-#endif
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef OSCL_TICKCOUNT_H_INCLUDED
-#include "oscl_tickcount.h"
-#endif
-
-#define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
-
-#define pv_min(a, b)  ((a) <= (b) ? (a) : (b));
-typedef OsclMemAllocator PvmfAmrEncDataProcessorAlloc;
-typedef Oscl_Vector<PVMFSharedMediaDataPtr, PvmfAmrEncDataProcessorAlloc> PvmfAmrEncMediaDataVector;
-typedef OsclMemPoolFixedChunkAllocator PvmfAmrEncDataProcessorMemPool;
-
-struct BufferInfo
-{
-    uint8 *ptr;
-    uint32 ptrLength;
-    uint32 tsInFirstMediaData;
-    bool bContinueProcessing;
-    bool bNeedDequeue;
-
-    BufferInfo()
-    {
-        oscl_memset(this, 0, sizeof(struct BufferInfo));
-    }
-};
-
-// Forward declarations
-class CPvGsmAmrEncoder;
-class TEncodeProperties;
-class OsclClock;
-class PvmfAmrEncDataProcessor : public PvmfAmrEncDataProcessorInterface,
-            public PVAMREncExtensionInterface,
-            public OsclMemPoolFixedChunkAllocatorObserver
-{
-    public:
-
-        PvmfAmrEncDataProcessor();
-        ~PvmfAmrEncDataProcessor();
-
-        // Virtual functions of PVNodeDataPrecessor
-        PVMFStatus ThreadLogon();
-        PVMFStatus ThreadLogoff();
-        PVMFStatus QueryUUID(const PvmfMimeString& aMimeType,
-                             Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-                             bool aExactUuidsOnly = false);
-        PVMFStatus QueryInterface(const PVUuid& uuid, PVInterface*& aface);
-        PVMFStatus Initialize();
-        PVMFStatus Reset();
-        PVMFStatus QueueIncomingData(PVMFSharedMediaDataPtr& aMediaDataIn);
-        void Encode();
-        PVMFStatus SetInputSamplingRate(uint32 aSamplingRate);
-        PVMFStatus SetInputBitsPerSample(uint32 aBitsPerSample);
-        PVMFStatus SetInputNumChannels(uint32 aNumChannels);
-        PVMFStatus SetOutputFormat(PVMFFormatType aFormat);
-        uint32 GetOutputBitRate();
-        PVMFFormatType GetOutputFormat()
-        {
-            return iOutputFormat;
-        }
-
-        // Virtual functions of PVAMREncExtensionInterface
-        OSCL_IMPORT_REF void addRef();
-        OSCL_IMPORT_REF void removeRef();
-        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        OSCL_IMPORT_REF PVMFStatus SetOutputBitRate(PVMF_GSMAMR_Rate aBitRate);
-        OSCL_IMPORT_REF PVMFStatus SetMaxNumOutputFramesPerBuffer(uint32 aNumOutputFrames);
-
-    private:
-        void Construct();
-        uint32 GetTotalAvailableDataSize();
-        bool IsEnoughDataToEncode();
-        bool GetNewInputBuffer(BufferInfo &aBufferInfo);
-
-        // virtual functions from OsclMemPoolFixedChunkAllocatorObserver
-        void freechunkavailable(OsclAny *)
-        {
-            if (iObserver) iObserver->OutputMemoryAvailable();
-        }
-
-    private:
-        void LogDiagnostics();
-
-        // Codec and encoder settings
-        CPvGsmAmrEncoder *iGsmEncoder;
-        TEncodeProperties *iEncProps;
-
-        // Encoding Settings
-        uint32	iInputSamplingRate;
-        uint32	iInputBitsPerSample;
-        uint32	iInputNumChannels;
-        PVMF_GSMAMR_Rate iOutputBitrate;
-        PVMFFormatType	iOutputFormat;
-        uint32	iMaxNumOutputFramesPerBuffer;
-        uint32	iMaxOutputBufferSize;
-        int32	*iSizeArrayForOutputFrames;
-        uint8	*iInternalInputBuffer;
-        uint32	iMax_input_size;
-        uint32	iOneInputFrameLength;
-        uint32	iPosForInputMediaDataBuffer;
-        uint32	iNextStartTime;
-        bool	iInitialized;
-
-        // Generic memory allocator
-        PvmfAmrEncDataProcessorAlloc iAlloc;
-
-        // Output media data allocator and memory pool
-        PvmfAmrEncDataProcessorMemPool iMediaOutMemoryPool;
-        PvmfAmrEncBufferAlloc *iMediaOutAlloc;
-
-        // Output media data object memory pool
-        PvmfAmrEncDataProcessorMemPool iMediaDataMemPool;
-
-        // Input data queue
-        PvmfAmrEncMediaDataVector iIncomingDataQueue;
-
-        PVLogger* iLogger;	/** Logger */
-        uint32 iSeqNum;		/** Sequence number */
-        uint32 iExtensionRefCount; /** Reference counter for extension interface */
-
-        PVLogger* iDiagnosticsLogger;
-
-#if PROFILING_ON
-        uint32 total_ticks;
-        uint32 total_frames;
-        uint32 iFinalTimeStamp;
-        uint32 iMinEncDuration;
-        uint32 iMaxEncDuration;
-        uint32 iAverageEncDuration;
-        bool oDiagnosticsLogged;
-#endif
-
-};
-
-#endif // PVMF_AMRENC_DATA_PROCESSOR_H_INCLUDED
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_data_processor_interface.h b/nodes/pvamrencnode/src/pvmf_amrenc_data_processor_interface.h
deleted file mode 100644
index 945c4d6..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_data_processor_interface.h
+++ /dev/null
@@ -1,234 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- * @file pvmf_amrenc_data_processor_interface.h
- * @brief Data processing interface for PvmfAmrEncNode
- */
-#ifndef PVMF_AMRENC_DATA_PROCESSOR_INTERFACE_H_INCLUDED
-#define PVMF_AMRENC_DATA_PROCESSOR_INTERFACE_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_VECTOR_H_INCLUDED
-#include "oscl_vector.h"
-#endif
-#ifndef OSCL_DEFALLOC_H_INCLUDED
-#include "oscl_defalloc.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-#ifndef PVMF_RETURN_CODES_H_INCLUDED
-#include "pvmf_return_codes.h"
-#endif
-
-class PvmfAmrEncCapabilityConfig
-{
-    public:
-        virtual ~PvmfAmrEncCapabilityConfig() {}
-        /**
-         * Sets the sampling rate of the unencoded input data
-         * @param aSamplingRate, sampling rate
-         * @return PVMFSuccess if successful, else see PVMF return code.
-         */
-        virtual PVMFStatus SetInputSamplingRate(uint32 aSamplingRate) = 0;
-
-        /**
-         * Sets the bits per sample of unencoded input data.
-         * @param aBitsPerSample, number of bits per sample
-         * @return PVMFSuccess if successful, else see PVMF return code.
-         */
-        virtual PVMFStatus SetInputBitsPerSample(uint32 aBitsPerSample) = 0;
-
-        /**
-         * Sets the frame size of unencoded input data.
-         * @param aNumChannels, number of channels
-         * @return PVMFSuccess if successful, else see PVMF return code.
-         */
-        virtual PVMFStatus SetInputNumChannels(uint32 aNumChannels) = 0;
-
-        /**
-         * Sets the format (IF2 or IETF) of encoded output.
-         * @param aFormat, IF2 or IETF format, use PVMF format type, PVMF_AMR_IETF or PVMF_AMR_IF2
-         * @return PVMFSuccess if successful, else see PVMF return code.
-         */
-        virtual PVMFStatus SetOutputFormat(PVMFFormatType aFormat) = 0;
-
-        /**
-         * Gets the format of encoded output
-         * @return Format type
-         */
-        virtual PVMFFormatType GetOutputFormat() = 0;
-
-        /**
-         * Gets the bitrate of encoded output.
-         * @return Output bitrate of encoded output.
-         */
-        virtual uint32 GetOutputBitRate() = 0;
-};
-
-/**
- * This enumeration is especially for the result of the following Process() interface
- * It lists a bunch of the return values(cases) for this API.
- */
-typedef enum
-{
-    // output media data can be generated, but the data in the buffer queue is not enough (or even no data) to continue processing
-    ProcessComplete_NotEnoughDataInQueue		   = 0,
-    // output media data can be generated, but the data in the buffer queue is enough to continue processing
-    ProcessComplete_EnoughDataToContinueProcessing = 1,
-
-    // the data in the buffer is not enough to generate one output media data, needs to get more data
-    // Note that the data in the buffer queue is not consumed any more, so the data needs to be held in the queue. The user is not
-    // responsible to remove the data in the buffer queue.
-    ProcessInComplete		 = 2,
-
-    // different errors
-    ProcessError			 = -1,
-    ProcessNotInitialized    = -2, // initialization not done yet
-    ProcessNoOutputMemory    = -3
-}PvmfAmrEncDataProcessResult;
-
-/** PVNodeDataPrecessor observer class is designed to delegate the callback from the memory pool, i.e.,
-**  OsclMemPoolFixedChunkAllocatorObserver::freechunkavailable(). And the memory pool is typically used
-**  inside PVNodeDataPrecessor class for memory allocation for the output (processed) data
-*/
-class PvmfAmrEncDataProcessorObserver
-{
-    public:
-        virtual ~PvmfAmrEncDataProcessorObserver() {}
-        virtual void OutputMemoryAvailable(void) = 0;
-        virtual void ProcessComplete(PvmfAmrEncDataProcessResult aResult, PVMFSharedMediaDataPtr& aMediaDataOut) = 0;
-};
-
-
-/** PVNodeDataPrecessor class is designed to provide a (small) set of interfaces that seperate basic node implementation(
- ** state transition, port, command and event handling etc.) and data processing specific (i.e. codec specific) implementation.
- ** It basically has three interfaces:
- ** (1) virtual function QueryInterface(), this is for node extension interface, for example, some encoder nodes need extension interfaces to get
- **     encoding parameters set before the actual encoding. For other nodes that do not have extension interface, the base class provides the
- **     default implementation (i.e. not supported). That is why this fucntion is set as non-pure virtual function.
- ** (2) pure virtual function Initialize(), this is the initialization function. The derived class has to implement this function.
- ** (3) pure virtual function Process(), this is the actual data processing function, for codec, this is the actual encoding or decoding function
- **     The derived class has to implement it by its own. Note that the memory allocation for the output processed data usually happens inside this
- **     function.
- **
- ** Note that no clean up function is specified, since the destructor needs to take care of resource deallocation
- **
- */
-class PvmfAmrEncDataProcessorInterface : public PvmfAmrEncCapabilityConfig
-{
-    public:
-        PvmfAmrEncDataProcessorInterface() : iObserver(NULL) {}
-        virtual ~PvmfAmrEncDataProcessorInterface() {};
-
-        void SetObserver(PvmfAmrEncDataProcessorObserver* aObserver)
-        {
-            iObserver = aObserver;
-        }
-        virtual PVMFStatus ThreadLogon() = 0;
-        virtual PVMFStatus ThreadLogoff() = 0;
-
-        /**
-         * Retrieve the extension interface if there is, otherwise return PVMFErrNotSupported.
-         * Here provide the default implementation for those derived classes that don't need extension interface
-         *
-         * @param "uuid" "the uuid for the extension interface to be queried"
-         * @param "aface" "the actual interface"
-         * @return PVMFStatus, if the extension interface doesn't exist, return PVMFErrNotSupported
-         */
-        virtual PVMFStatus QueryInterface(const PVUuid& uuid, PVInterface*& aface) = 0;
-
-        /**
-        * It allows a caller to ask for all UUIDs associated with a particular MIME type.
-        * If interfaces of the requested MIME type are found within the system, they are added
-        * to the UUIDs array.
-        *
-        * Also added to the UUIDs array will be all interfaces which have the requested MIME
-        * type as a base MIME type.  This functionality can be turned off.
-        *
-        * @param aMimeType The MIME type of the desired interfaces
-        * @param aUuids A vector to hold the discovered UUIDs
-        * @param aExactUuidsOnly Turns on/off the retrival of UUIDs with aMimeType as a base type
-        * @returns Completion status
-        */
-        virtual PVMFStatus QueryUUID(const PvmfMimeString& aMimeType,
-                                     Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-                                     bool aExactUuidsOnly = false) = 0;
-
-        /**
-         * Initialization function. For codec, this is for codec initialization. Right now
-         * this is synchonized call, and doesn't
-         * support asynchronized call.
-         *
-         * @return PVMFStatus
-         */
-        virtual PVMFStatus Initialize() = 0;
-
-        /**
-         * Resets the encoder
-         * @return Completion status
-         */
-        virtual PVMFStatus Reset() = 0;
-
-        /**
-         * Data processing function. This interface is currently designed as synchronized call for data processing.
-         * Basically, this function will take all the current available input data, do processing and probably generate one media data (
-         * PVMFSharedMediaDataPtr type). The reason for taking all the available input data instead of one input frame is to handle arbitrary
-         * input, and also hide the handling logic for arbitrary input inside this function, which I think makes things easier.
-         *
-         * Therefore, the caller (the node) only needs to pass the current input data queue down to this function, and is not responsible to
-         * remove the input data in the data queue (except the final clean up, the node may need to check if the input data queue has data or
-         * not, and may remove them all). This function will take care of it. In addition, the caller only needs to check the return value to
-         * see if the output medida data is available.
-         *
-         * @param "aIncomingDataQueue" "current input data queue for a node"
-         * @param "aMediaDataOut" "one output media data that contains the processed data"
-         * @return ProcessResult, see the above description
-         */
-
-        virtual PVMFStatus QueueIncomingData(PVMFSharedMediaDataPtr& aMediaDataIn) = 0;
-
-        virtual void Encode() = 0;
-
-        /**
-         * This API will set the observer object for issuing a callback when the output memory becomes available
-         *
-         * @param "aObserver" "reference of PvmfAmrEncDataProcessorObserver object to be passed down to PVNodeDataPrecessor"
-         * @return PVMFStatus
-         */
-        //
-        void NotifyMemoryAvailable(PvmfAmrEncDataProcessorObserver& aObserver)
-        {
-            iObserver = &aObserver;
-        }
-
-    protected:
-        PvmfAmrEncDataProcessorObserver *iObserver;
-};
-
-
-#endif // PVMF_AMRENC_DATA_PROCESSOR_INTERFACE_H_INCLUDED
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_media_buffer.cpp b/nodes/pvamrencnode/src/pvmf_amrenc_media_buffer.cpp
deleted file mode 100644
index 6af8a91..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_media_buffer.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
-*
-* @file Pvmf_amrenc_media_buffer.cpp
-* @brief Media buffer for pv amr encoder node
-*
-*/
-
-
-#ifndef PVVIDEOENCMDF_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_amrenc_media_buffer.h"
-#endif
-
-#ifndef PVMF_MEDIA_FRAG_GROUP_IN_SIMPLE_BUFFER_H_INCLUDED
-#include "pvmf_media_fraggroup_in_simple_buffer.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef PVMF_RETURN_CODES_H_INCLUDED
-#include "pvmf_return_codes.h"
-#endif
-
-// Constants used in this file are defined in the following h file
-#ifndef PVMF_AMRENC_TUNEABLES_INCLUDED
-#include "pvmf_amrenc_tuneables.h"
-#endif
-
-
-template <class Alloc>
-class AMREncBufferCleanupDA : public OsclDestructDealloc
-{
-    public:
-        AMREncBufferCleanupDA(Oscl_DefAlloc* in_gen_alloc) :
-                gen_alloc(in_gen_alloc), mediaFragPtr(NULL) {};
-        virtual ~AMREncBufferCleanupDA() {};
-
-        virtual void destruct_and_dealloc(OsclAny* ptr)
-        {
-            // 1. destruct mediaFragPtr, because the vector used in mediaFragPtr needs to be deleted, otherwise there will be a memory leak
-            if (mediaFragPtr) mediaFragPtr->OSCL_TEMPLATED_DESTRUCTOR_CALL(PVMFMediaFragGroupInSimpleBuffer<Alloc>,  PVMFMediaFragGroupInSimpleBuffer);
-
-            // 2. free the memory. No need to call destructors to free the actual memory because memory pool is used
-            // So real memory deallocation is done in the destructor of the memory pool
-            gen_alloc->deallocate(ptr);
-        }
-
-        // For PvmfAmrEncBufferAlloc::allocate() to call private function setPointer()
-        friend class PvmfAmrEncBufferAlloc;
-
-    private:
-        void setPointer(PVMFMediaFragGroupInSimpleBuffer<Alloc> *ptr)
-        {
-            mediaFragPtr = ptr;
-        }
-
-    private:
-        Oscl_DefAlloc* gen_alloc;
-        PVMFMediaFragGroupInSimpleBuffer<Alloc> *mediaFragPtr;
-};
-
-
-OSCL_EXPORT_REF PvmfAmrEncBufferAlloc::PvmfAmrEncBufferAlloc(Oscl_DefAlloc* opt_gen_alloc) : gen_alloc(opt_gen_alloc)
-{
-    if (!gen_alloc)  // No support for this static allocator(SA)
-    {
-        OSCL_LEAVE(PVMFErrArgument);
-    }
-}
-
-OsclSharedPtr<PVMFMediaDataImpl> PvmfAmrEncBufferAlloc::allocate(uint32 aFragLen, uint32 aNumOfFragments)
-{
-    // Note that gen_alloc shouldn't be zero, because we put leave in constructor
-
-    // Sanity check
-    if (aNumOfFragments == 0) aNumOfFragments = PVMF_AMRENC_MEDIA_BUF_DEFAULT_NUMOFFRAGMENTS;
-    if (aFragLen == 0)		 aFragLen = PVMF_AMRENC_MEDIA_BUF_DEFAULT_FRAGMENT_LENGTH;
-
-    uint aligned_cleanup_size			= oscl_mem_aligned_size(sizeof(AMREncBufferCleanupDA<OsclMemAllocator>));
-    uint aligned_refcnt_size			= oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-    uint aligned_frag_group_class_size  = oscl_mem_aligned_size(sizeof(PVMFMediaFragGroupInSimpleBuffer<OsclMemAllocator>));
-    //uint aligned_frag_group_class_size  = oscl_mem_aligned_size(sizeof(PVMFMediaFragGroupInSimpleBuffer));
-
-    OsclRefCounter* my_refcnt = NULL;
-    uint32 total_size, capacity_frag;
-    uint8* my_ptr = NULL;
-    AMREncBufferCleanupDA<OsclMemAllocator>* cleanup_ptr = NULL;
-
-
-    // 1.calculate the total size and do memory allocation
-    capacity_frag = aFragLen;
-    total_size = aligned_refcnt_size + aligned_cleanup_size + aligned_frag_group_class_size +
-                 aNumOfFragments * capacity_frag;
-    my_ptr = (uint8*) gen_alloc->allocate(total_size);
-
-    // 1.5 create clean up object (for the reference count object). Note that the first pointer should be for reference count object
-    cleanup_ptr = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, AMREncBufferCleanupDA<OsclMemAllocator>(gen_alloc));
-
-    // 2. create the recounter after the cleanup object
-    my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
-    my_ptr += (aligned_refcnt_size + aligned_cleanup_size);
-
-
-    // 3. create PVMFMediaFragGroup object at the beginning (not sure if the memory position would cause problem)
-    void *ptr;
-    ptr = my_ptr + aligned_frag_group_class_size;
-    PVMFMediaFragGroupInSimpleBuffer<OsclMemAllocator>* media_data_ptr = new(my_ptr) PVMFMediaFragGroupInSimpleBuffer<OsclMemAllocator>(
-        ptr, aNumOfFragments*capacity_frag,
-        my_refcnt, aNumOfFragments, capacity_frag);
-
-    // will destruct media_data_ptr in AMREncBufferCleanupDA::destruct_and_dealloc()
-    if (cleanup_ptr) cleanup_ptr->setPointer(media_data_ptr);
-
-    // create OsclSharedPtr<PVMFMediaDataImpl> object
-    OsclSharedPtr<PVMFMediaDataImpl> shared_media_data(media_data_ptr, my_refcnt);
-    return shared_media_data;
-}
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_media_buffer.h b/nodes/pvamrencnode/src/pvmf_amrenc_media_buffer.h
deleted file mode 100644
index 861d021..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_media_buffer.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- *
- * @file pvmf_amrenc_media_buffer.h
- * @brief Media buffer to hold video encoder MDF output
- *
- */
-
-#ifndef PVMF_AMRENC_MEDIA_BUFFER_H_INCLUDED
-#define PVMF_AMRENC_MEDIA_BUFFER_H_INCLUDED
-
-#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
-#include "pvmf_media_data_impl.h"
-#endif
-#ifndef OSCL_SHARED_PTR_H_INCLUDED
-#include "oscl_shared_ptr.h"
-#endif
-
-/*
-  This class is specially for creating PVMFMediaFragGroup object that contains multiple fragments (OsclRefCounterMemFrag),
-  with the specific structure (see code)
-  Note that PVMFSimpleMediaBuffer only contains 1 fragment.
-*/
-class PvmfAmrEncBufferAlloc
-{
-    public:
-
-        //! constructor
-        OSCL_IMPORT_REF PvmfAmrEncBufferAlloc(Oscl_DefAlloc* opt_gen_alloc = 0);
-
-        /**
-         * Create a PVMFMediaFragGroup object that contains multiple fragments
-         * @param aNumOfFragments, the number of fragments within the generated PVMFMediaFragGroup object
-         * @param aFragLen, the length of each fragment (usually the maximum length)
-         * @return the shared pointer of the PVMFMediaFragGroup object
-         */
-        virtual OsclSharedPtr<PVMFMediaDataImpl> allocate(uint32 aFragLen, uint32 aNumOfFragments);
-
-    private:
-        Oscl_DefAlloc* gen_alloc;
-};
-
-#endif // PVMF_AMRENC_MEDIA_BUFFER_H_INCLUDED
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_node.cpp b/nodes/pvamrencnode/src/pvmf_amrenc_node.cpp
deleted file mode 100644
index e103de4..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_node.cpp
+++ /dev/null
@@ -1,1279 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_NODE_H_INCLUDED
-#include "pvmf_amrenc_node.h"
-#endif
-#ifndef OSCL_ERROR_CODES_H_INCLUDED
-#include "oscl_error_codes.h"
-#endif
-#ifndef PVMF_AMRENC_PORT_H_INCLUDED
-#include "pvmf_amrenc_port.h"
-#endif
-#ifndef PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
-#include "pvmf_amrenc_node_factory.h"
-#endif
-#ifndef PVMF_AMRENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_amrenc_node_types.h"
-#endif
-#ifndef PVMF_AMRENC_DATA_PROCESSOR_H_INCLUDED
-#include "pvmf_amrenc_data_processor.h"
-#endif
-#ifndef OSCL_DLL_H_INCLUDED
-#include "oscl_dll.h"
-#endif
-#ifndef PVMF_MEDIA_MSG_FORMAT_IDS_H_INCLUDED
-#include "pvmf_media_msg_format_ids.h"
-#endif
-#ifndef PVMF_MEDIA_CMD_H_INCLUDED
-#include "pvmf_media_cmd.h"
-#endif
-
-// DLL entry point
-OSCL_DLL_ENTRY_POINT_DEFAULT()
-
-////////////////////////////////////////////////////////////////////////////
-//              PvmfAmrEncNodeFactory implementation
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFNodeInterface* PvmfAmrEncNodeFactory::Create(int32 aPriority)
-{
-    int32 err = 0;
-    PvmfAmrEncNode* node = NULL;
-    PvmfAmrEncDataProcessorInterface* dataProcessor = NULL;
-
-    OSCL_TRY(err,
-             dataProcessor = OSCL_NEW(PvmfAmrEncDataProcessor, ());
-             if (!dataProcessor)
-             OSCL_LEAVE(OsclErrNoMemory);
-
-             node = OSCL_NEW(PvmfAmrEncNode, (aPriority, dataProcessor));
-             if (!node)
-                 OSCL_LEAVE(OsclErrNoMemory);
-                );
-    OSCL_FIRST_CATCH_ANY(err, return NULL;);
-
-    return (PVMFNodeInterface*)node;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PvmfAmrEncNodeFactory::Delete(PVMFNodeInterface* aNode)
-{
-    if (!aNode)
-        return false;
-
-    PvmfAmrEncNode* node = (PvmfAmrEncNode*)aNode;
-    PvmfAmrEncDataProcessor* dataProcessor = (PvmfAmrEncDataProcessor*)node->GetDataProcessor();
-    OSCL_DELETE(dataProcessor);
-    OSCL_DELETE(node);
-    aNode = NULL;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//              PvmfAmrEncNode implementation
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncNode::PvmfAmrEncNode(int32 aPriority, PvmfAmrEncDataProcessorInterface* aDataProcessor) :
-        OsclTimerObject(aPriority, "PvmfAmrEncNode"),
-        iDataProcessor(aDataProcessor)
-{
-    iInterfaceState = EPVMFNodeCreated;
-
-    int32 err;
-    OSCL_TRY(err,
-             //Create the input command queue
-             iCmdQueue.Construct(PVMF_AMRENC_NODE_CMD_ID_START, PVMF_AMRENC_NODE_CMD_QUEUE_RESERVE);
-             iCurrentCmd.Construct(0, 1); // There's only 1 current command
-
-             //Create the port vector.
-             iInPort.Construct(PVMF_AMRENC_NODE_PORT_VECTOR_RESERVE);
-             iOutPort.Construct(PVMF_AMRENC_NODE_PORT_VECTOR_RESERVE);
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         // If a leave happened, cleanup and re-throw the error
-                         iCmdQueue.clear();
-                         iInPort.clear();
-                         iOutPort.clear();
-                         OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
-                         OSCL_CLEANUP_BASE_CLASS(OsclTimerObject);
-                         OSCL_LEAVE(err);
-                        );
-
-    iDataProcessor->SetObserver(this);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncNode::~PvmfAmrEncNode()
-{
-    while (!iInPort.empty())
-        iInPort.Erase(&iInPort.front());
-    while (!iOutPort.empty())
-        iOutPort.Erase(&iOutPort.front());
-
-    Cancel();
-    SetState(EPVMFNodeIdle);
-    ThreadLogoff();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncNode::ThreadLogon()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeCreated:
-            if (!IsAdded())
-                AddToScheduler();
-            iLogger = PVLogger::GetLoggerObject("PvmfAmrEncNode");
-            SetState(EPVMFNodeIdle);
-            return PVMFSuccess;
-            // break;	This statement was removed to avoid compiler warning for Unreachable Code
-
-        default:
-            return PVMFErrInvalidState;
-            // break;	This statement was removed to avoid compiler warning for Unreachable Code
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncNode::ThreadLogoff()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            if (IsAdded())
-                RemoveFromScheduler();
-            iLogger = NULL;
-            SetState(EPVMFNodeCreated);
-            return PVMFSuccess;
-            // break;	This statement was removed to avoid compiler warning for Unreachable Code
-
-        default:
-            return PVMFErrInvalidState;
-            // break;	This statement was removed to avoid compiler warning for Unreachable Code
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncNode::GetCapability(PVMFNodeCapability& aNodeCapability)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::GetCapability"));
-
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_PCM16);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_AMR_IETF);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_AMR_IF2);
-    aNodeCapability.iCanSupportMultipleOutputPorts = false;
-    aNodeCapability.iCanSupportMultipleInputPorts = false;
-    aNodeCapability.iHasMaxNumberOfPorts = true;
-    aNodeCapability.iMaxNumberOfPorts = 2;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFPortIter* PvmfAmrEncNode::GetPorts(const PVMFPortFilter* aFilter)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::GetPorts"));
-    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
-
-    int32 err = 0;
-    PvmfAmrEncPortVector* port = NULL;
-    OSCL_TRY(err,
-             port = OSCL_NEW(PvmfAmrEncPortVector, ());
-             if (!port)
-             return NULL;
-
-             uint32 i;
-             for (i = 0; i < iInPort.size(); i++)
-                 port->AddL(iInPort[i]);
-                 for (i = 0; i < iOutPort.size(); i++)
-                     port->AddL(iOutPort[i]);
-                     port->Reset();
-                    );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncNode::GetPorts: Error - Out of memory"));
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::QueryUUID(PVMFSessionId aSession,
-        const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-        bool aExactUuidsOnly,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::QueryUUID"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYUUID,
-                  aMimeType, aUuids, aExactUuidsOnly, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::QueryInterface(PVMFSessionId aSession,
-        const PVUuid& aUuid,
-        PVInterface*& aInterfacePtr,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::QueryInterface"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYINTERFACE,
-                  aUuid, aInterfacePtr, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::RequestPort(PVMFSessionId aSession,
-        int32 aPortTag,
-        const PvmfMimeString* aPortConfig,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::RequestPort: aPortTag=%d", aPortTag));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_REQUESTPORT,
-                  aPortTag, aPortConfig, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::ReleasePort(PVMFSessionId aSession,
-        PVMFPortInterface& aPort,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::ReleasePort"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Init(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Init"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_INIT, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Prepare(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Prepare"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PREPARE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Start(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Start"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_START, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Stop(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Stop"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_STOP, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Flush(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Flush"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_FLUSH, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Pause(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Pause"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PAUSE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::Reset(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Reset"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RESET, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::CancelAllCommands"));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncNode::CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::CancelCommand: aCmdId=%d", aCmdId));
-    PvmfAmrEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::HandlePortActivity(const PVMFPortActivity &aActivity)
-{
-    // Only outgoing queue ready activity are forwarded on to the node
-    // by the output port.  The rest of the events for output port and all events
-    // for input port are handled within the port AO.
-    if (aActivity.iPort->GetPortTag() == PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aActivity.iType)
-        {
-            case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-                // Notifies the node that the output queue is ready, and the node would
-                // resume encoding incoming data
-                uint32 i;
-                for (i = 0; i < iInPort.size(); i++)
-                    ((PvmfAmrEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                break;
-
-            default:
-                break;
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::ProcessComplete(PvmfAmrEncDataProcessResult aResult, PVMFSharedMediaDataPtr& aMediaDataOut)
-{
-    switch (aResult)
-    {
-        case ProcessComplete_NotEnoughDataInQueue:
-        case ProcessComplete_EnoughDataToContinueProcessing:
-        {
-            // Send bitstream data to downstream node
-            PVMFSharedMediaMsgPtr mediaMsgOut;
-            convertToPVMFMediaMsg(mediaMsgOut, aMediaDataOut);
-
-            uint32 i = 0;
-            for (i = 0; i < iOutPort.size(); i++)
-            {
-                PVMFStatus status = iOutPort[i]->QueueOutgoingMsg(mediaMsgOut);
-                switch (status)
-                {
-                    case PVMFSuccess:
-                        break;
-                    case PVMFErrBusy:
-                        LOG_DEBUG((0, "PvmfAmrEncNode::ProcessComplete: Outgoing queue busy. This should not happen."));
-                        break;
-                    default:
-                        ReportErrorEvent(PVMF_AMRENC_NODE_ERROR_ENCODE_ERROR);
-                        break;
-                }
-            }
-
-            if (aResult == ProcessComplete_EnoughDataToContinueProcessing)
-            {
-                LOG_DEBUG((0, "PvmfAmrEncNode::ProcessComplete: More data to encode."));
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        case ProcessInComplete:
-            break;
-
-        case ProcessNoOutputMemory:
-            // set the observer to be notified when output memory becomes available,
-            // and then wait (return PVMFSuccess)
-            iDataProcessor->NotifyMemoryAvailable(*this);
-            break;
-
-        case ProcessError:
-        case ProcessNotInitialized:
-            LOG_ERR((0, "PvmfAmrEncNode::ProcessIncomingMsg: Error - iDataProcessor->Process failed. result=%d", aResult));
-            ReportErrorEvent(PVMF_AMRENC_NODE_ERROR_ENCODE_ERROR);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//               Port activity processing routines
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncNode::IsProcessOutgoingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsConnectedPortBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncNode::IsProcessIncomingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsOutgoingQueueBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::ProcessIncomingMsg: aPort=0x%x", aPort));
-    PVMFStatus status = PVMFFailure;
-
-    switch (aPort->GetPortTag())
-    {
-        case PVMF_AMRENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (!IsProcessIncomingMsgReady())
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::ProcessIncomingMsg: Error - Not ready."));
-                return PVMFErrBusy;
-            }
-
-            PVMFSharedMediaMsgPtr msg;
-            status = aPort->DequeueIncomingMsg(msg);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed. status=%d", status));
-                return status;
-            }
-
-            if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
-            {
-                status = SendEndOfTrackCommand(msg);
-                return status;
-            }
-            PVMFSharedMediaDataPtr mediaDataIn;
-            convertToPVMFMediaData(mediaDataIn, msg);
-            status = iDataProcessor->QueueIncomingData(mediaDataIn);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::ProcessIncomingMsg: Error - iDataProcessor->QueueIncomingData() failed. status=%d", status));
-                return status;
-            }
-        }
-        break;
-
-        case PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT:
-            // Nothing to be done
-            status = PVMFSuccess;
-            break;
-
-        default:
-            LOG_ERR((0, "PvmfAmrEncNode::ProcessIncomingMsg: Error - Invalid port tag"));
-            ReportErrorEvent(PVMF_AMRENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)aPort);
-            status = PVMFFailure;
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                        Private methods
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::Run()
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Run"));
-
-    if (!iCmdQueue.empty())
-    {
-        if (ProcessCommand(iCmdQueue.front()))
-        {
-            // Need to check the state before re-scheduling since the node could have
-            // been reset in the ProcessCommand call
-            if ((iInterfaceState != EPVMFNodeCreated) &&
-                    !iCmdQueue.empty())
-            {
-                RunIfNotReady();
-            }
-        }
-        return;
-    }
-
-    // If it gets to here, there's more queued data to encode in the data processor
-    if (iDataProcessor)
-        iDataProcessor->Encode();
-
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::Run: Out"));
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                   Command processing routines
-////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PvmfAmrEncNode::QueueCommandL(PvmfAmrEncNodeCommand& aCmd)
-{
-    if (iInterfaceState == EPVMFNodeCreated)
-    {
-        OSCL_LEAVE(OsclErrNotReady);
-        // return 0;	This statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVMFCommandId id = iCmdQueue.AddL(aCmd);
-    RunIfNotReady();
-    return id;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncNode::ProcessCommand(PvmfAmrEncNodeCommand& aCmd)
-{
-    // If a command is active, only high priority commands can interrupt
-    // the processing
-    if (!iCurrentCmd.empty() && !aCmd.hipri())
-        return false;
-
-    switch (aCmd.iCmd)
-    {
-        case PVMF_GENERIC_NODE_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELCOMMAND:
-            DoCancelCommand(aCmd);
-            break;
-
-        default://unknown command type
-            LOG_ERR((0, "PvmfAmrEncNode::ProcessCommand: Error - Unknown command type %d", aCmd.iCmd));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            break;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::CommandComplete(PvmfAmrEncNodeCmdQueue& aCmdQueue, PvmfAmrEncNodeCommand& aCmd,
-                                     PVMFStatus aStatus, OsclAny* aData)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::CommandComplete: Id=%d, Type=%d, Status=%d, Context=0x%x, Data0x%x"
-                     , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aData));
-
-    //create response
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aData);
-    PVMFSessionId session = aCmd.iSession;
-
-    //Erase the command from the queue.
-    aCmdQueue.Erase(&aCmd);
-
-    //Report completion to the session observer.
-    ReportCmdCompleteEvent(session, resp);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoQueryUuid(PvmfAmrEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::DoQueryUuid"));
-    OSCL_String* mimetype;
-    Oscl_Vector<PVUuid, OsclMemAllocator>* uuidvec;
-    bool exactMatch;
-    aCmd.Parse(mimetype, uuidvec, exactMatch);
-
-    PVMFStatus status;
-    if (iDataProcessor)
-    {
-        if (!mimetype)
-        {
-            OSCL_StackString<1> tmpMimeType;
-            status = iDataProcessor->QueryUUID(tmpMimeType, *uuidvec, exactMatch);
-        }
-        else
-        {
-            status = iDataProcessor->QueryUUID(*mimetype, *uuidvec, exactMatch);
-        }
-    }
-    else
-    {
-        status = PVMFFailure;
-    }
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoQueryInterface(PvmfAmrEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::DoQueryInterface"));
-    PVUuid* uuid;
-    PVInterface** ptr;
-    aCmd.Parse(uuid, ptr);
-
-    PVMFStatus status;
-    if (iDataProcessor)
-    {
-        status = iDataProcessor->QueryInterface(*uuid, *ptr);
-        if ((status == PVMFFailure) && (PVMI_CAPABILITY_AND_CONFIG_PVUUID == *uuid))
-        {
-            PvmiCapabilityAndConfig* myInterface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
-            *ptr = OSCL_STATIC_CAST(PVInterface*, myInterface);
-            status = true;
-        }
-    }
-    else
-        status = PVMFFailure;
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoRequestPort(PvmfAmrEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::DoRequestPort"));
-    int32 tag;
-    OSCL_String* mimetype;
-    PvmfAmrEncPort* port = NULL;
-    aCmd.Parse(tag, mimetype);
-
-    switch (tag)
-    {
-        case PVMF_AMRENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (iInPort.size() >= PVMF_AMRENC_NODE_MAX_INPUT_PORT)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::DoRequestPort: Error - Max number of input port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVAmrEncIn";
-
-            port = AllocatePort(iInPort, tag, mimetype, portname.get_cstr());
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        break;
-
-        case PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT:
-        {
-            if (iOutPort.size() >= PVMF_AMRENC_NODE_MAX_OUTPUT_PORT)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::DoRequestPort: Error - Max number of output port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-
-            OSCL_StackString<20> portname;
-            portname = "PVAmrEncOut";
-
-            port = AllocatePort(iOutPort, tag, mimetype, portname.get_cstr());
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        break;
-
-        default:
-            LOG_ERR((0, "PvmfAmrEncNode::DoRequestPort: Error - Invalid port tag"));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            return;
-    }
-
-    //Return the port pointer to the caller.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess, (OsclAny*)port);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncPort* PvmfAmrEncNode::AllocatePort(PvmfAmrEncPortVector& aPortVector, int32 aTag,
-        OSCL_String* aMimeType, const char* aName)
-{
-    int32 err = 0;
-    OsclAny* ptr = NULL;
-
-    // Allocate a new port
-    OSCL_TRY(err,
-             ptr = aPortVector.Allocate();
-             if (!ptr)
-             OSCL_LEAVE(PVMFErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncNode::AllocatePort: Error - iPortVector Out of memory"));
-                         return NULL;
-                        );
-    PvmfAmrEncPort* port = OSCL_PLACEMENT_NEW(ptr, PvmfAmrEncPort(aTag, this, iDataProcessor, Priority(), aName));
-
-    // if format was provided in mimestring, set it now.
-    if (aMimeType)
-    {
-        PVMFFormatType format = GetFormatIndex(aMimeType->get_str());
-        if (port->SetFormat(format) != PVMFSuccess ||
-                !iDataProcessor || (aTag == PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT &&
-                                    iDataProcessor->SetOutputFormat(format) != PVMFSuccess))
-        {
-            aPortVector.DestructAndDealloc(port);
-            LOG_ERR((0, "PvmfAmrEncNode::AllocatePort: Error - port->SetFormat or iDataProcessor->SetOutputFormat failed"));
-            return NULL;
-        }
-    }
-
-    OSCL_TRY(err, aPortVector.AddL(port););
-    OSCL_FIRST_CATCH_ANY(err,
-                         aPortVector.DestructAndDealloc(port);
-                         return NULL;
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoReleasePort(PvmfAmrEncNodeCommand& aCmd)
-{
-    //Find the port in the port vector
-    PvmfAmrEncPort* port = NULL;
-    PvmfAmrEncPort** portPtr = NULL;
-    aCmd.Parse((PVMFPortInterface*&)port);
-
-    if (!port)
-    {
-        LOG_ERR((0, "PvmfAmrEncNode::DoReleasePort: Error - Invalid port pointer"));
-        CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-        return;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (port->GetPortTag())
-    {
-        case PVMF_AMRENC_NODE_PORT_TYPE_INPUT:
-            portPtr = iInPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iInPort.Erase(portPtr);
-            }
-            break;
-
-        case PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT:
-            portPtr = iOutPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iOutPort.Erase(portPtr);
-            }
-            break;
-
-        default:
-            LOG_ERR((0, "PvmfAmrEncNode::DoReleasePort: Error - Invalid port tag"));
-            status = PVMFFailure;
-            break;
-    }
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoInit(PvmfAmrEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            SetState(EPVMFNodeInitialized);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeInitialized:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoPrepare(PvmfAmrEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::DoPrepare"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoStart(PvmfAmrEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::DoStart"));
-    PVMFStatus status;
-    switch (iInterfaceState)
-    {
-        case EPVMFNodePrepared:
-            if (!iDataProcessor)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::DoPrepare: Error - iDataProcessor not available"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            status = iDataProcessor->Initialize();
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PvmfAmrEncNode::DoPrepare: Error - iDataProcessor->Initialize() failed"));
-                CommandComplete(iCmdQueue, aCmd, status);
-                return;
-            }
-
-            SetState(EPVMFNodeStarted);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-
-        case EPVMFNodePaused:
-            SetState(EPVMFNodeStarted);
-
-            // Notify input port that the node is ready to process incoming msg again
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                ((PvmfAmrEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeStarted:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoStop(PvmfAmrEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::DoStop"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            // Clear queued messages in ports
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                iInPort[i]->ClearMsgQueues();
-            for (i = 0; i < iOutPort.size(); i++)
-                iOutPort[i]->ClearMsgQueues();
-
-            PVMFStatus status;
-            if (!iDataProcessor)
-            {
-                status = PVMFFailure;
-            }
-            else
-            {
-                status = iDataProcessor->Reset();
-                if (status == PVMFSuccess)
-                {
-                    //transition to Prepared state
-                    SetState(EPVMFNodePrepared);
-                }
-            }
-
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoFlush(PvmfAmrEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            int32 err;
-            uint32 i;
-            bool msgPending;
-            msgPending = false;
-
-            for (i = 0; i < iInPort.size(); i++)
-            {
-                if (iInPort[i]->IncomingMsgQueueSize() > 0)
-                    msgPending = true;
-                iInPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessIncomingMsgReady
-                    // to wake up port AO
-                    ((PvmfAmrEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                }
-            }
-
-            for (i = 0; i < iOutPort.size(); i++)
-            {
-                if (iOutPort[i]->OutgoingMsgQueueSize() > 0)
-                    msgPending = true;
-                iOutPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessOutgoingMsgReady
-                    // to wake up port AO
-                    ((PvmfAmrEncPort*)iOutPort[i])->ProcessOutgoingMsgReady();
-                }
-            }
-
-            //the flush is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until the flush completes.
-            OSCL_TRY(err, iCurrentCmd.StoreL(aCmd););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                                 return;
-                                );
-            iCmdQueue.Erase(&aCmd);
-            if (!msgPending)
-            {
-                FlushComplete();
-                return;
-            }
-            break;
-
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncNode::IsFlushPending()
-{
-    return (iCurrentCmd.size() > 0
-            && iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::FlushComplete()
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::FlushComplete"));
-    uint32 i = 0;
-
-    // Flush is complete only when all queues of all ports are clear.
-    // Other wise, just return from this method and wait for FlushComplete
-    // from the remaining ports.
-    for (i = 0; i < iInPort.size(); i++)
-    {
-        if (iInPort[i]->IncomingMsgQueueSize() > 0 ||
-                iInPort[i]->OutgoingMsgQueueSize() > 0)
-        {
-            return;
-        }
-    }
-
-    for (i = 0; i < iOutPort.size(); i++)
-    {
-        if (iOutPort[i]->IncomingMsgQueueSize() > 0 ||
-                iOutPort[i]->OutgoingMsgQueueSize() > 0)
-        {
-            return;
-        }
-    }
-
-    PVMFStatus status;
-    if (!iDataProcessor)
-    {
-        status = PVMFFailure;
-    }
-    else
-    {
-        status = iDataProcessor->Reset();
-        if (status == PVMFSuccess)
-        {
-            //transition to Prepared state
-            SetState(EPVMFNodePrepared);
-        }
-    }
-
-    //resume port input so the ports can be re-started.
-    for (i = 0; i < iInPort.size(); i++)
-        iInPort[i]->ResumeInput();
-    for (i = 0; i < iOutPort.size(); i++)
-        iOutPort[i]->ResumeInput();
-
-    CommandComplete(iCurrentCmd, iCurrentCmd.front(), status);
-
-    if (!iCmdQueue.empty())
-    {
-        // If command queue is not empty, schedule to process the next command
-        RunIfNotReady();
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoPause(PvmfAmrEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-            SetState(EPVMFNodePaused);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePaused:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoReset(PvmfAmrEncNodeCommand& aCmd)
-{
-    //This example node allows a reset from any idle state.
-    if (IsAdded())
-    {
-        uint32 i;
-        for (i = 0; i < iInPort.size(); i++)
-            iInPort[i]->ClearMsgQueues();
-        for (i = 0; i < iOutPort.size(); i++)
-            iOutPort[i]->ClearMsgQueues();
-
-        while (!iInPort.empty())
-            iInPort.Erase(&iInPort.front());
-        while (!iOutPort.empty())
-            iOutPort.Erase(&iOutPort.front());
-
-        //restore original port vector reserve.
-        iInPort.Reconstruct();
-        iOutPort.Reconstruct();
-
-        PVMFStatus status;
-        if (iDataProcessor)
-        {
-            iDataProcessor->Reset();
-            iDataProcessor->ThreadLogoff();
-        }
-
-        //logoff & go back to Created state.
-        SetState(EPVMFNodeIdle);
-        status = ThreadLogoff();
-
-        CommandComplete(iCmdQueue, aCmd, status);
-    }
-    else
-    {
-        OSCL_LEAVE(OsclErrInvalidState);
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoCancelAllCommands(PvmfAmrEncNodeCommand& aCmd)
-{
-    //first cancel the current command if any
-    {
-        while (!iCurrentCmd.empty())
-            CommandComplete(iCurrentCmd, iCurrentCmd[0], PVMFErrCancelled);
-    }
-
-    //next cancel all queued commands
-    {
-        //start at element 1 since this cancel command is element 0.
-        while (iCmdQueue.size() > 1)
-            CommandComplete(iCmdQueue, iCmdQueue[1], PVMFErrCancelled);
-    }
-
-    //finally, report cancel complete.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::DoCancelCommand(PvmfAmrEncNodeCommand& aCmd)
-{
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.Parse(id);
-
-    //first check "current" command if any
-    {
-        PvmfAmrEncNodeCommand* cmd = iCurrentCmd.FindById(id);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCurrentCmd, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PvmfAmrEncNodeCommand* cmd = iCmdQueue.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCmdQueue, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Event reporting routines.
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::SetState(TPVMFNodeInterfaceState aState)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::SetState %d", aState));
-    PVMFNodeInterface::SetState(aState);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_ERR((0, "PvmfAmrEncNode::ReportErrorEvent: aEventType=%d aEventData=0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncNode::ReportInfoEvent: aEventType=%d, aEventData0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
-}
-
-
-PVMFStatus PvmfAmrEncNode::SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg)
-{
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    sharedMediaCmdPtr->setTimestamp(aMsg->getTimestamp());
-
-    // Set the sequence number
-    sharedMediaCmdPtr->setSeqNum(aMsg->getSeqNum());
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-
-    PVMFStatus status;
-    for (uint32 ii = 0; ii < iOutPort.size(); ii++)
-    {
-        status = iOutPort[ii]->QueueOutgoingMsg(mediaMsgOut);
-
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PvmfAmrEncNode::SendEndOfTrackCommand: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-
-    }
-
-    return status;
-}
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_node.h b/nodes/pvamrencnode/src/pvmf_amrenc_node.h
deleted file mode 100644
index 951f16d..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_node.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_NODE_H_INCLUDED
-#define PVMF_AMRENC_NODE_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-#ifndef PVMFAMRENCNODE_EXTENSION_H_INCLUDED
-#include "pvmfamrencnode_extension.h"
-#endif
-#ifndef PVMF_AMRENC_DATA_PROCESSOR_INTERFACE_H_INCLUDED
-#include "pvmf_amrenc_data_processor_interface.h"
-#endif
-#ifndef PVMF_AMRENC_TUNEABLES_H_INCLUDED
-#include "pvmf_amrenc_tuneables.h"
-#endif
-
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-
-#define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
-
-#if PROFILING_ON
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
-#endif
-#endif
-
-
-// Forward declarations
-class PvmfAmrEncPort;
-
-// Allocators
-typedef OsclMemAllocDestructDealloc<uint8> PvmfAmrEncNodeAllocDestructDealloc;
-typedef OsclMemAllocator PvmfAmrEncNodeAlloc;
-typedef OsclMemPoolFixedChunkAllocator PvmfAmrEncNodeMemPool;
-
-/** Node command type */
-typedef PVMFGenericNodeCommand<PvmfAmrEncNodeAlloc> PvmfAmrEncNodeCommand;
-
-/** Command queue type */
-typedef PVMFNodeCommandQueue<PvmfAmrEncNodeCommand, PvmfAmrEncNodeAlloc> PvmfAmrEncNodeCmdQueue;
-
-/** Port vector type */
-typedef PVMFPortVector<PvmfAmrEncPort, PvmfAmrEncNodeAlloc> PvmfAmrEncPortVector;
-
-////////////////////////////////////////////////////////////////////////////
-class PvmfAmrEncNode : public OsclTimerObject,
-            public PVMFNodeInterface,
-            public PvmfAmrEncDataProcessorObserver,
-            public PvmiCapabilityAndConfig
-{
-    public:
-        PvmfAmrEncNode(int32 aPriority, PvmfAmrEncDataProcessorInterface* aDataProcessor);
-        ~PvmfAmrEncNode();
-
-        // Virtual functions of PVMFNodeInterface
-        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
-        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
-        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
-        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
-        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId aSession,
-                                                const PvmfMimeString& aMimeType,
-                                                Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-                                                bool aExactUuidsOnly = false,
-                                                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSession,
-                const PVUuid& aUuid,
-                PVInterface*& aInterfacePtr,
-                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession, int32 aPortTag,
-                const PvmfMimeString* aPortConfig = NULL,
-                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId aSession, PVMFPortInterface& aPort,
-                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContextData = NULL);
-        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId,
-                const OsclAny* aContextData = NULL);
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-        // Pure virtuals from PvmfAmrEncDataProcessorObserver
-        void OutputMemoryAvailable() {};
-        void ProcessComplete(PvmfAmrEncDataProcessResult aResult, PVMFSharedMediaDataPtr& aMediaDataOut);
-
-        // Port activity processing routines
-        bool IsProcessOutgoingMsgReady();
-        bool IsProcessIncomingMsgReady();
-        PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
-
-        PvmfAmrEncDataProcessorInterface* GetDataProcessor()
-        {
-            return iDataProcessor;
-        }
-
-        /////////////////////////////////////////////////////
-        //     // cap config interface
-        /////////////////////////////////////////////////////
-
-        // implemetation of PvmiCapabilityAndConfig class functions here
-
-        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-
-        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
-                                     PvmiKvp*& aParameters, int& num_parameter_elements,
-                                     PvmiCapabilityContext aContext);
-        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                                  PvmiKvp* aParameters, int num_parameter_elements);
-        void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                               int num_elements, PvmiKvp * & aRet_kvp);
-        PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                                         int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
-        uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-
-        // function used in VerifyParametersSync n SetParametersSync of capability class
-        PVMFStatus VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam);
-
-        // function used in getParametersSync of capability class
-        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
-
-
-    private:
-        // From OsclTimerObject
-        void Run();
-
-        /////////////////////////////////////////////////////
-        //     Command processing routines
-        /////////////////////////////////////////////////////
-        PVMFCommandId QueueCommandL(PvmfAmrEncNodeCommand& aCmd);
-        bool ProcessCommand(PvmfAmrEncNodeCommand& aCmd);
-        void CommandComplete(PvmfAmrEncNodeCmdQueue& aCmdQueue, PvmfAmrEncNodeCommand& aCmd,
-                             PVMFStatus aStatus, OsclAny* aData = NULL);
-        void DoQueryUuid(PvmfAmrEncNodeCommand& aCmd);
-        void DoQueryInterface(PvmfAmrEncNodeCommand& aCmd);
-        void DoRequestPort(PvmfAmrEncNodeCommand& aCmd);
-        PvmfAmrEncPort* AllocatePort(PvmfAmrEncPortVector& aPortVector, int32 aTag, OSCL_String* aMimeType, const char* aName = NULL);
-        void DoReleasePort(PvmfAmrEncNodeCommand& aCmd);
-        void DoInit(PvmfAmrEncNodeCommand& aCmd);
-        void DoPrepare(PvmfAmrEncNodeCommand& aCmd);
-        void DoStart(PvmfAmrEncNodeCommand& aCmd);
-        void DoStop(PvmfAmrEncNodeCommand& aCmd);
-        void DeleteVideoEncoder();
-        void DoFlush(PvmfAmrEncNodeCommand& aCmd);
-        bool IsFlushPending();
-        void FlushComplete();
-        void DoPause(PvmfAmrEncNodeCommand& aCmd);
-        void DoReset(PvmfAmrEncNodeCommand& aCmd);
-        void DoCancelAllCommands(PvmfAmrEncNodeCommand& aCmd);
-        void DoCancelCommand(PvmfAmrEncNodeCommand& aCmd);
-
-        // Event reporting
-        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
-        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
-        void SetState(TPVMFNodeInterfaceState aState);
-        PVMFStatus SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg);
-
-    private:
-
-        // Allocators
-        PvmfAmrEncNodeAllocDestructDealloc iAlloc;
-
-        // Command queue
-        PvmfAmrEncNodeCmdQueue iCmdQueue;
-
-        // A queue is used to hold the current command so it's easy to find out
-        // whether a command is in progress, and allow cancel to interrupt
-        PvmfAmrEncNodeCmdQueue iCurrentCmd;
-
-        // Ports and port activity
-        PvmfAmrEncPortVector iInPort;
-        PvmfAmrEncPortVector iOutPort;
-        friend class PvmfAmrEncPort;
-
-        // Encoder
-        PvmfAmrEncDataProcessorInterface* iDataProcessor;
-
-        // Logger
-        PVLogger* iLogger;
-};
-
-#endif // PVMF_AMRENC_NODE_H_INCLUDED
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_node_cap_config.cpp b/nodes/pvamrencnode/src/pvmf_amrenc_node_cap_config.cpp
deleted file mode 100644
index 9e33153..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_node_cap_config.cpp
+++ /dev/null
@@ -1,560 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_NODE_H_INCLUDED
-#include "pvmf_amrenc_node.h"
-#endif
-
-#ifndef PVMF_AMRENC_PORT_H_INCLUDED
-#include "pvmf_amrenc_port.h"
-#endif
-
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-
-#ifndef PVMI_KVP_UTIL_H_INCLUDED
-#include "pvmi_kvp_util.h"
-#endif
-
-#define AMRENCNODECONFIG_BASE_NUMKEYS 2
-#define AMRENCCONFIG_KEYSTRING_SIZE 128
-
-struct AmrEncNodeKeyStringData
-{
-    char iString[64];
-    PvmiKvpType iType;
-    PvmiKvpValueType iValueType;
-};
-
-static const AmrEncNodeKeyStringData AmrEncNodeConfig_BaseKeys[] =
-{
-    {"sampling_rate", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"channels", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
-};
-
-enum BaseKeys_IndexMapType
-{
-    SAMPLING_RATE = 0,
-    CHANNELS
-};
-
-static const uint AmrEncNodeConfig_NumBaseKeys =
-    (sizeof(AmrEncNodeConfig_BaseKeys) /
-     sizeof(AmrEncNodeKeyStringData));
-
-
-
-////////////////////////////////////////////////////////////////////////////
-//					PvmiCapConfigInterface
-////////////////////////////////////////////////////////////////////////////
-
-void PvmfAmrEncNode::createContext(PvmiMIOSession aSession,
-                                   PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PvmfAmrEncNode::setContextParameters(PvmiMIOSession aSession,
-        PvmiCapabilityContext& aContext,
-        PvmiKvp* aParameters,
-        int aNumParameterElements)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumParameterElements);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PvmfAmrEncNode::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-PVMFCommandId PvmfAmrEncNode::setParametersAsync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int aNumElements,
-        PvmiKvp*& aRet_kvp,
-        OsclAny* aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    OSCL_UNUSED_ARG(aRet_kvp);
-//	PvmfAmrEncNode cmd;
-//	cmd.PVMFMP4FFParserNodeCommand::Construct(NULL, PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS, aSession, aParameters, num_elements, aRet_kvp, context);
-//	LOG_STACK_TRACE((0,"PvmfAmrEncNode::setParametersAsync - Out"));
-//	return QueueCommandL(cmd);
-    return 0;
-}
-
-uint32 PvmfAmrEncNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-    OSCL_UNUSED_ARG(aSession);
-    return 0;
-}
-
-PVMFStatus PvmfAmrEncNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::verifyParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (NULL == aParameters || aNumElements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::verifyParametersSync() Passed in parameter invalid"));
-        return PVMFErrArgument;
-    }
-
-    // Go through each parameter
-    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/audio/render")) < 0) || compcount < 4)
-        {
-            // First 3 components should be "x-pvmf/audio/render" and there must
-            // be at least four components
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::verifyParametersSync() Unsupported key"));
-            return PVMFErrNotSupported;
-        }
-
-        if (compcount == 4)
-        {
-            // Verify and set the passed-in composer node setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], false);
-            if (retval != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::verifyParametersSync() Setting parameter %d failed", paramind));
-                return retval;
-            }
-        }
-        else
-        {
-            // Do not support more than 4 components right now
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::verifyParametersSync() Unsupported key"));
-            return PVMFErrNotSupported;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::verifyParametersSync() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PvmfAmrEncNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::releaseParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (aParameters == NULL || aNumElements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::releaseParameters() KVP list is NULL or number of elements is 0"));
-        return PVMFErrArgument;
-    }
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aParameters[0].key);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/audio/render")) < 0) || compcount < 4)
-    {
-        // First 3 component should be "x-pvmf/audio/render" and there must
-        // be at least three components
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::releaseParameters() Unsupported key"));
-        return PVMFErrNotSupported;
-    }
-
-    // Retrieve the third component from the key string
-    pv_mime_string_extract_type(2, aParameters[0].key, compstr);
-
-    // Go through each KVP and release memory for value if allocated from heap
-    for (int32 ii = 0; ii < aNumElements; ++ii)
-    {
-        // Next check if it is a value type that allocated memory
-        PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
-        if (PVMI_KVPTYPE_VALUE == kvptype || PVMI_KVPTYPE_UNKNOWN == kvptype)
-        {
-            PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
-            if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::releaseParameters() Valtype not specified in key string"));
-                return PVMFErrNotSupported;
-            }
-
-            if (PVMI_KVPVALTYPE_CHARPTR == keyvaltype && NULL != aParameters[ii].value.pChar_value)
-            {
-                oscl_free(aParameters[ii].value.pChar_value);
-                aParameters[ii].value.pChar_value = NULL;
-            }
-            else if (PVMI_KVPVALTYPE_KSV == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
-            {
-                oscl_free(aParameters[ii].value.key_specific_value);
-                aParameters[ii].value.key_specific_value = NULL;
-            }
-            else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
-            {
-                range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
-                aParameters[ii].value.key_specific_value = NULL;
-                oscl_free(rui32);
-            }
-            // TODO Add more types if amr enc node starts returning more types
-        }
-    }
-
-    // amr enc node allocated its key strings in one chunk so just free the first key string ptr
-    oscl_free(aParameters[0].key);
-
-    // Free memory for the parameter list
-    oscl_free(aParameters);
-    aParameters = NULL;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::releaseParameters() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PvmfAmrEncNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::getParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    OSCL_UNUSED_ARG(aContext);
-
-    // Initialize the output parameters
-    aNumParamElements = 0;
-    aParameters = NULL;
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aIdentifier);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aIdentifier, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/audio/render")) < 0) || compcount < 4)
-    {
-        // First 3 components should be "x-pvmf/audio/render" and there must
-        // be at least 3 components
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::getParametersSync() Invalid key string"));
-        return PVMFErrNotSupported;
-    }
-
-    // Retrieve the fourth component from the key string
-    pv_mime_string_extract_type(3, aIdentifier, compstr);
-
-    for (int32 amrenc4ind = 0; amrenc4ind < AMRENCNODECONFIG_BASE_NUMKEYS; ++amrenc4ind)
-    {
-        // Go through each amr enc component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(AmrEncNodeConfig_BaseKeys[amrenc4ind].iString)) >= 0)
-        {
-            if (4 == compcount)
-            {
-                // Determine what is requested
-                PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
-                if (PVMI_KVPATTR_UNKNOWN == reqattr)
-                {
-                    reqattr = PVMI_KVPATTR_CUR;
-                }
-
-                // Return the requested info
-                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, amrenc4ind, reqattr);
-                if (PVMFSuccess != retval)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::getParametersSync() Retrieving amr enc node parameter failed"));
-                    return retval;
-                }
-            }
-            else
-            {
-                // Right now amr enc node doesn't support more than 4 components
-                // for this sub-key string so error out
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::getParametersSync() Unsupported key"));
-                return PVMFErrNotSupported;
-            }
-
-            // Breakout of the for(amrenc4ind) loop
-            break;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::getParametersSync() Out"));
-    if (0 == aNumParamElements)
-    {
-        // If no one could get the parameter, return error
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::getParametersSync() Unsupported key"));
-        return PVMFFailure;
-    }
-    else
-    {
-        return PVMFSuccess;
-    }
-}
-
-void PvmfAmrEncNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::setParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-    // Complete the request synchronously
-
-    if (NULL == aParameters || aNumElements < 1)
-    {
-        if (aParameters)
-        {
-            aRetKVP = aParameters;
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::setParametersSync() Passed in parameter invalid"));
-        return;
-    }
-
-    // Go through each parameter
-    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/audio/render")) < 0) || compcount < 4)
-        {
-            // First 3 components should be "x-pvmf/audio/render" and there must
-            // be at least four components
-            aRetKVP = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::setParametersSync() Unsupported key"));
-            return;
-        }
-
-        if (4 == compcount)
-        {
-            // Verify and set the passed-in media input setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
-            if (PVMFSuccess != retval)
-            {
-                aRetKVP = &aParameters[paramind];
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::setParametersSync() Setting parameter %d failed", paramind));
-                return;
-            }
-        }
-        else
-        {
-            // Do not support more than 5 components right now
-            aRetKVP = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::setParametersSync() Unsupported key"));
-            return;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::setParametersSync() Out"));
-}
-
-
-PVMFStatus PvmfAmrEncNode::VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::VerifyAndSetConfigParameter() In"));
-
-    // Determine the valtype
-    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
-    if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::VerifyAndSetConfigParameter() Valtype in key string unknown"));
-        return PVMFErrNotSupported;
-    }
-    // Retrieve the fourth component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(3, aParameter.key, compstr);
-
-    int32 amrenc4ind;
-    for (amrenc4ind = 0; amrenc4ind < AMRENCNODECONFIG_BASE_NUMKEYS; ++amrenc4ind)
-    {
-        // Go through each component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(AmrEncNodeConfig_BaseKeys[amrenc4ind].iString)) >= 0)
-        {
-            // Break out of the for loop
-            break;
-        }
-    }
-
-    if (AMRENCNODECONFIG_BASE_NUMKEYS <= amrenc4ind)
-    {
-        // Match couldn't be found or non-leaf node specified
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::VerifyAndSetConfigParameter() Unsupported key or non-leaf node"));
-        return PVMFErrNotSupported;
-    }
-
-    // Verify the valtype
-    if (keyvaltype != AmrEncNodeConfig_BaseKeys[amrenc4ind].iValueType)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::VerifyAndSetConfigParameter() Valtype does not match for key"));
-        return PVMFErrNotSupported;
-    }
-
-    switch (amrenc4ind)
-    {
-        case SAMPLING_RATE: // "sampling_rate"
-            // Change the parameter
-            if (aSetParam)
-            {
-                // set the parameter here
-            }
-            break;
-
-        case CHANNELS:  // "channels"
-            // change the parameter
-            if (aSetParam)
-            {
-                // set the parameter here
-            }
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::VerifyAndSetConfigParameter() Invalid index for amr enc node parameter"));
-            return PVMFErrNotSupported;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::VerifyAndSetConfigParameter() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PvmfAmrEncNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::GetConfigParameter() In"));
-
-    aNumParamElements = 0;
-
-    // Allocate memory for the KVP
-    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
-    if (NULL == aParameters)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::GetConfigParameter() Memory allocation for KVP failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
-    // Allocate memory for the key string in KVP
-    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(AMRENCCONFIG_KEYSTRING_SIZE * sizeof(char));
-    if (NULL == memblock)
-    {
-        oscl_free(aParameters);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::GetConfigParameter() Memory allocation for key string failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_strset(memblock, 0, AMRENCCONFIG_KEYSTRING_SIZE * sizeof(char));
-    // Assign the key string buffer to KVP
-    aParameters[0].key = memblock;
-
-    // Copy the key string
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/audio/render/"), 21);
-    oscl_strncat(aParameters[0].key, AmrEncNodeConfig_BaseKeys[aIndex].iString, oscl_strlen(AmrEncNodeConfig_BaseKeys[aIndex].iString));
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
-    switch (AmrEncNodeConfig_BaseKeys[aIndex].iValueType)
-    {
-        case PVMI_KVPVALTYPE_BITARRAY32:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_KSV:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_BOOL:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_INT32:
-            if (PVMI_KVPATTR_CUR == reqattr)
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            break;
-        case PVMI_KVPVALTYPE_UINT32:
-        default:
-            if (PVMI_KVPATTR_CAP == reqattr)
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            else
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
-            }
-            break;
-    }
-    aParameters[0].key[AMRENCCONFIG_KEYSTRING_SIZE-1] = 0;
-
-    // Copy the requested info
-    switch (aIndex)
-    {
-        case SAMPLING_RATE:	// "sampling_rate"
-            if (PVMI_KVPATTR_CUR == reqattr)
-            {
-                // get the parameter here
-            }
-            else if (PVMI_KVPATTR_DEF == reqattr)
-            {
-                // Return default
-            }
-            else
-            {
-                // Return capability
-            }
-            break;
-
-        case CHANNELS:	// "channels"
-
-            if (PVMI_KVPATTR_CUR == reqattr)
-            {
-                // get the parameter here
-            }
-            else if (PVMI_KVPATTR_DEF == reqattr)
-            {
-                // Return default
-            }
-            else
-            {
-                // Return capability
-            }
-            break;
-
-        default:
-            // Invalid index
-            oscl_free(aParameters[0].key);
-            oscl_free(aParameters);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfAmrEncNode::GetConfigParameter() Invalid index to amr enc node parameter"));
-            return PVMFErrNotSupported;
-    }
-
-    aNumParamElements = 1;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PvmfAmrEncNode::GetConfigParameter() Out"));
-    return PVMFSuccess;
-}
-
-void PvmfAmrEncNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    ciObserver = aObserver;
-}
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_port.cpp b/nodes/pvamrencnode/src/pvmf_amrenc_port.cpp
deleted file mode 100644
index d422e9f..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_port.cpp
+++ /dev/null
@@ -1,808 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_PORT_H_INCLUDED
-#include "pvmf_amrenc_port.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-#ifndef PVMF_AMRENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_amrenc_node_types.h"
-#endif
-#ifndef PVMF_AMRENC_NODE_H_INCLUDED
-#include "pvmf_amrenc_node.h"
-#endif
-#ifndef PV_AMR_ENC_EXTENSION_H_INCLUDED
-#include "pvmfamrencnode_extension.h"
-#endif
-
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncPort::PvmfAmrEncPort(int32 aTag, PvmfAmrEncNode* aNode, PvmfAmrEncCapabilityConfig* aConfig, int32 aPriority, const char* aName)
-        :  PvmfPortBaseImpl(aTag, this,
-                            PVMF_AMRENC_PORT_CAPACITY, PVMF_AMRENC_PORT_RESERVE, PVMF_AMRENC_PORT_THRESHOLD,
-                            PVMF_AMRENC_PORT_CAPACITY, PVMF_AMRENC_PORT_RESERVE, PVMF_AMRENC_PORT_THRESHOLD, aName),
-        OsclActiveObject(aPriority, "PvmfAmrEncPort"),
-        iFormat(PVMF_FORMAT_UNKNOWN),
-        iNode(aNode),
-        iEncConfig(aConfig)
-{
-    AddToScheduler();
-    iLogger = PVLogger::GetLoggerObject("PvmfAmrEncPort");
-#if PVMF_PORT_BASE_IMPL_STATS
-    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfAmrEncPort::~PvmfAmrEncPort()
-{
-    Disconnect();
-    ClearMsgQueues();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncPort::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
-{
-    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-        aPtr = (PvmiCapabilityAndConfig*)this;
-    else
-        aPtr = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncPort::Connect(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::Connect: aPort=0x%x", aPort));
-
-    if (!aPort)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::Connect: Error - Connecting to invalid port"));
-        return PVMFErrArgument;
-    }
-
-    if (iConnectedPort)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::Connect: Error - Already connected"));
-        return PVMFFailure;
-    }
-
-    PvmiCapabilityAndConfig* config = NULL;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-    if (!config)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::Connect: Error - Peer port does not support capability interface"));
-        return PVMFFailure;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (iTag)
-    {
-        case PVMF_AMRENC_NODE_PORT_TYPE_INPUT:
-            status = NegotiateInputSettings(config);
-            break;
-        case PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT:
-            status = NegotiateOutputSettings(config);
-            break;
-        default:
-            LOG_ERR((0, "PvmfAmrEncPort::Connect: Error - Invalid port tag"));
-            status = PVMFFailure;
-    }
-
-    if (status != PVMFSuccess)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::Connect: Error - Settings negotiation failed. status=%d", status));
-        return status;
-    }
-
-    //Automatically connect the peer.
-    if (aPort->PeerConnect(this) != PVMFSuccess)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::Connect: Error - Peer Connect failed"));
-        return PVMFFailure;
-    }
-
-    iConnectedPort = aPort;
-
-#if PVMF_PORT_BASE_IMPL_STATS
-    // Reset statistics
-    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-
-    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                  PvmiCapabilityAndConfig
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    // Not supported
-    OSCL_UNUSED_ARG(aObserver);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncPort::getParametersSync(PvmiMIOSession session,
-        PvmiKeyType identifier,
-        PvmiKvp*& parameters,
-        int& num_parameter_elements,
-        PvmiCapabilityContext context)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::getParametersSync"));
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-
-    parameters = NULL;
-    num_parameter_elements = 0;
-    PVMFStatus status = PVMFFailure;
-
-    switch (iTag)
-    {
-        case PVMF_AMRENC_NODE_PORT_TYPE_INPUT:
-            return GetInputParametersSync(identifier, parameters, num_parameter_elements);
-        case PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT:
-            return GetOutputParametersSync(identifier, parameters, num_parameter_elements);
-        default:
-            LOG_ERR((0, "PvmfAmrEncPort::getParametersSync: Error - Invalid port tag"));
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncPort::releaseParameters(PvmiMIOSession session,
-        PvmiKvp* parameters,
-        int num_elements)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(num_elements);
-
-    if (parameters)
-    {
-        iAlloc.deallocate((OsclAny*)parameters);
-        return PVMFSuccess;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncPort::setContextParameters(PvmiMIOSession session,
-        PvmiCapabilityContext& context,
-        PvmiKvp* parameters, int num_parameter_elements)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-    OSCL_UNUSED_ARG(parameters);
-    OSCL_UNUSED_ARG(num_parameter_elements);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PvmfAmrEncPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
-        int num_elements, PvmiKvp*& ret_kvp)
-{
-    OSCL_UNUSED_ARG(session);
-    PVMFStatus status = PVMFSuccess;
-    ret_kvp = NULL;
-
-    for (int32 i = 0; i < num_elements; i++)
-    {
-        status = VerifyAndSetParameter(&(parameters[i]), true);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PvmfAmrEncPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
-            ret_kvp = &(parameters[i]);
-            OSCL_LEAVE(OsclErrArgument);
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PvmfAmrEncPort::setParametersAsync(PvmiMIOSession session,
-        PvmiKvp* parameters,
-        int num_elements,
-        PvmiKvp*& ret_kvp,
-        OsclAny* context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(parameters);
-    OSCL_UNUSED_ARG(num_elements);
-    OSCL_UNUSED_ARG(ret_kvp);
-    OSCL_UNUSED_ARG(context);
-    return -1;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF uint32 PvmfAmrEncPort::getCapabilityMetric(PvmiMIOSession session)
-{
-    OSCL_UNUSED_ARG(session);
-    return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PvmfAmrEncPort::verifyParametersSync(PvmiMIOSession session,
-        PvmiKvp* parameters, int num_elements)
-{
-    OSCL_UNUSED_ARG(session);
-
-    PVMFStatus status = PVMFSuccess;
-    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
-        status = VerifyAndSetParameter(&(parameters[i]));
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::SetFormat(PVMFFormatType aFormat)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::SetFormat: aFormat=%d", aFormat));
-    if (!IsFormatSupported(aFormat))
-        return PVMFFailure;
-
-    iFormat = aFormat;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncPort::ProcessIncomingMsgReady()
-{
-    if (IncomingMsgQueueSize() > 0)
-        RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncPort::ProcessOutgoingMsgReady()
-{
-    if (OutgoingMsgQueueSize() > 0)
-        RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from PVMFPortActivityHandler
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncPort::HandlePortActivity(const PVMFPortActivity& aActivity)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::HandlePortActivity: type=%d", aActivity.iType));
-
-    if (aActivity.iPort != this)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::HandlePortActivity: Error - Activity is not on this port"));
-        return;
-    }
-
-    switch (aActivity.iType)
-    {
-        case PVMF_PORT_ACTIVITY_CREATED:
-            //Report port created info event to the node.
-            iNode->ReportInfoEvent(PVMFInfoPortCreated,
-                                   (OsclAny*)aActivity.iPort);
-            break;
-
-        case PVMF_PORT_ACTIVITY_DELETED:
-            //Report port deleted info event to the node.
-            iNode->ReportInfoEvent(PVMFInfoPortDeleted,
-                                   (OsclAny*)aActivity.iPort);
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-            // Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-            if (OutgoingMsgQueueSize() == 1 &&
-                    !IsConnectedPortBusy())
-            {
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-            //Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-            if (IncomingMsgQueueSize() == 1 &&
-                    iNode->IsProcessIncomingMsgReady())
-            {
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
-            // This is handled in the input port side when IsProcessIncomingMsgReady call failed
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            // Notifies the node that the output queue is ready, and the node would
-            // resume encoding incoming data
-            iNode->HandlePortActivity(aActivity);
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-            if (OutgoingMsgQueueSize() > 0)
-                RunIfNotReady();
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-            // This is handled when iNode->ProcessOutgoingMsg failed with busy
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECT:
-        case PVMF_PORT_ACTIVITY_DISCONNECT:
-        default:
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from OsclActiveObject
-////////////////////////////////////////////////////////////////////////////
-void PvmfAmrEncPort::Run()
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::Run"));
-    PVMFStatus status = PVMFSuccess;
-
-    // Process incoming messages
-    if (iTag == PVMF_AMRENC_NODE_PORT_TYPE_INPUT)
-    {
-        if (IncomingMsgQueueSize() > 0)
-        {
-            //dispatch the incoming data.
-            status = iNode->ProcessIncomingMsg(this);
-            switch (status)
-            {
-                case PVMFSuccess:
-                    // Reschedule if there is more data and the node did not become busy
-                    // after processing the current msg
-                    if (IncomingMsgQueueSize() > 0 && iNode->IsProcessIncomingMsgReady())
-                    {
-                        RunIfNotReady();
-                    }
-                    break;
-
-                case PVMFErrBusy:
-                    // Node busy. Don't schedule next data
-                    break;
-
-                default:
-                    LOG_ERR((0, "PvmfAmrEncPort::Run: Error - ProcessIncomingMsg failed. status=%d", status));
-                    break;
-            }
-        }
-
-        if (iNode->IsFlushPending())
-        {
-            if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                iNode->FlushComplete();
-        }
-    }
-
-    //Process outgoing messages
-    if (iTag == PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        if (OutgoingMsgQueueSize() > 0)
-        {
-            if (iNode->IsProcessOutgoingMsgReady())
-            {
-                //Send data to connected port
-                status = Send();
-                switch (status)
-                {
-                    case PVMFSuccess:
-                        // Reschedule if there's more data to process and connected port did not become busy
-                        // after receiving the last msg
-                        if (OutgoingMsgQueueSize() > 0 && iNode->IsProcessOutgoingMsgReady())
-                        {
-                            RunIfNotReady();
-                        }
-                        break;
-
-                    case PVMFErrBusy:
-                        // Connected port busy. Don't schedule next data
-                        break;
-
-                    default:
-                        LOG_ERR((0, "PvmfAmrEncPort::Run: Error - Send() failed. status=%d", status));
-                        iNode->ReportErrorEvent(PVMF_AMRENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)this);
-                        break;
-                }
-
-                if (iNode->IsFlushPending())
-                {
-                    if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                        iNode->FlushComplete();
-                }
-            }
-        }
-
-        if (iNode->IsFlushPending())
-        {
-            if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                iNode->FlushComplete();
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Capabilities exchange handling routines
-////////////////////////////////////////////////////////////////////////////
-bool PvmfAmrEncPort::IsFormatSupported(PVMFFormatType aFormat)
-{
-    if (iTag == PVMF_AMRENC_NODE_PORT_TYPE_INPUT)
-    {
-        switch (aFormat)
-        {
-            case PVMF_PCM16:
-                return true;
-            default:
-                break;
-        }
-    }
-    else if (iTag == PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aFormat)
-        {
-            case PVMF_AMR_IETF:
-            case PVMF_AMR_IF2:
-                return true;
-            default:
-                break;
-        }
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-        int& num_parameter_elements)
-{
-    if (iTag != PVMF_AMRENC_NODE_PORT_TYPE_INPUT)
-        return PVMFFailure;
-
-    PVMFStatus status = PVMFSuccess;
-
-    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PvmfAmrEncPort::GetInputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-
-        parameters[0].value.uint32_value = PVMF_PCM16;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-        int& num_parameter_elements)
-{
-    if (iTag != PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT)
-        return PVMFFailure;
-
-    PVMFStatus status = PVMFSuccess;
-
-    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0)
-    {
-        num_parameter_elements = 2;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PvmfAmrEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = PVMF_AMR_IETF;
-            parameters[1].value.uint32_value = PVMF_AMR_IF2;
-        }
-    }
-    else if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PvmfAmrEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iEncConfig->GetOutputFormat();
-        }
-    }
-    else if (pv_mime_strcmp(identifier, OUTPUT_BITRATE_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_BITRATE_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PvmfAmrEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iEncConfig->GetOutputBitRate();
-        }
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::AllocateKvp"));
-    uint8* buf = NULL;
-    uint32 keyLen = oscl_strlen(aKey) + 1;
-    int32 err = 0;
-
-    OSCL_TRY(err,
-             buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
-             if (!buf)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncPort::AllocateKvp: Error - kvp allocation failed"));
-                         return PVMFErrNoMemory;
-                        );
-
-    int32 i = 0;
-    PvmiKvp* curKvp = aKvp = new(buf) PvmiKvp;
-    buf += sizeof(PvmiKvp);
-    for (i = 1; i < aNumParams; i++)
-    {
-        curKvp += i;
-        curKvp = new(buf) PvmiKvp;
-        buf += sizeof(PvmiKvp);
-    }
-
-    for (i = 0; i < aNumParams; i++)
-    {
-        aKvp[i].key = (char*)buf;
-        oscl_strncpy(aKvp[i].key, aKey, keyLen);
-        buf += keyLen;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
-
-    if (!aKvp)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
-        return PVMFFailure;
-    }
-
-    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0 &&
-            iTag == PVMF_AMRENC_NODE_PORT_TYPE_INPUT)
-    {
-        switch (aKvp->value.uint32_value)
-        {
-            case PVMF_PCM16:
-                if (aSetParam)
-                {
-                    iFormat = aKvp->value.uint32_value;
-                    iEncConfig->SetInputBitsPerSample(16);
-                }
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PvmfAmrEncPort::VerifyAndSetParameter: Error - Input format %d not supported",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
-        }
-    }
-    else if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0 &&
-             iTag == PVMF_AMRENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aKvp->value.uint32_value)
-        {
-            case PVMF_AMR_IETF:
-            case PVMF_AMR_IF2:
-                if (aSetParam)
-                {
-                    iFormat = aKvp->value.uint32_value;
-                    iEncConfig->SetOutputFormat(iFormat);
-                }
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PvmfAmrEncPort::VerifyAndSetParameter: Error - Output format %d not supported",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
-        }
-    }
-
-    LOG_ERR((0, "PvmfAmrEncPort::VerifyAndSetParameter: Error - Unsupported parameter"));
-    return PVMFFailure;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::NegotiateInputSettings: aConfig=0x%x", aConfig));
-    if (!aConfig)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateInputSettings: Error - Invalid config object"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    int32 err = 0;
-
-    // Get supported output formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams == 0)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateInputSettings: Error - config->getParametersSync(output_formats) failed"));
-        return status;
-    }
-
-    // Using a priority queue, sort the kvp's returned from aConfig->getParametersSync
-    // according to the preference of this port. Formats that are not supported are
-    // not pushed to the priority queue and hence dropped from consideration.
-    PvmiKvp* selectedKvp = NULL;
-    for (int32 i = 0; i < numParams && !selectedKvp; i++)
-    {
-        switch (kvp[i].value.uint32_value)
-        {
-            case PVMF_PCM16:
-                selectedKvp = &kvp[i];
-                break;
-            default:
-                break;
-        }
-    }
-
-    if (!selectedKvp)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateInputSettings: Error - No matching supported input format"));
-        return PVMFFailure;
-    }
-
-    // Set format of this port, peer port and container node
-    PvmiKvp* retKvp = NULL;
-    iFormat = selectedKvp->value.uint32_value;
-    iEncConfig->SetInputBitsPerSample(16);
-    OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncPort::NegotiateInputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-                         return PVMFFailure;
-                        );
-
-    // Release parameters back to peer and reset for the next query
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    status = aConfig->getParametersSync(NULL, AUDIO_OUTPUT_SAMPLING_RATE_CUR_QUERY, kvp, numParams, NULL);
-    uint32 samplingRate = 0;
-    if (status != PVMFSuccess || !kvp || numParams != 1)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateInputSettings: config->getParametersSync(sampling rate) not supported. Use default."));
-        samplingRate = PVMF_AMRENC_DEFAULT_SAMPLING_RATE;
-    }
-    else
-    {
-        samplingRate = kvp[0].value.uint32_value;
-        aConfig->releaseParameters(NULL, kvp, numParams);
-    }
-
-    // Forward settings to encoder
-    iEncConfig->SetInputSamplingRate(samplingRate);
-    kvp = NULL;
-    numParams = 0;
-
-    status = aConfig->getParametersSync(NULL, AUDIO_OUTPUT_NUM_CHANNELS_CUR_QUERY, kvp, numParams, NULL);
-    uint32 numChannels = 0;
-    if (status != PVMFSuccess || !kvp || numParams != 1)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateInputSettings: config->getParametersSync(num channels) not supported. Use default"));
-        numChannels = PVMF_AMRENC_DEFAULT_NUM_CHANNELS;
-    }
-    else
-    {
-        numChannels = kvp[0].value.uint32_value;
-        aConfig->releaseParameters(NULL, kvp, numParams);
-    }
-
-    // Forward settings to encoder
-    iEncConfig->SetInputNumChannels(numChannels);
-    kvp = NULL;
-    numParams = 0;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfAmrEncPort::NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-    LOG_STACK_TRACE((0, "PvmfAmrEncPort::NegotiateOutputSettings: aConfig=0x%x", aConfig));
-    if (!aConfig)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateOutputSettings: Error - Invalid config object"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    int32 i = 0;
-    int32 err = 0;
-
-    // Get supported input formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams == 0)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateOutputSettings: Error - config->getParametersSync(input_formats) failed"));
-        return status;
-    }
-
-    PvmiKvp* selectedKvp = NULL;
-    PvmiKvp* retKvp = NULL;
-    for (i = 0; i < numParams && !selectedKvp; i++)
-    {
-        if (kvp[i].value.uint32_value == iFormat)
-            selectedKvp = &(kvp[i]);
-    }
-
-    if (!selectedKvp)
-    {
-        LOG_ERR((0, "PvmfAmrEncPort::NegotiateOutputSettings: Error - Output format not supported by peer"));
-        return PVMFFailure;
-    }
-
-    OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PvmfAmrEncPort::NegotiateOutputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-                         return PVMFFailure;
-                        );
-
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    return PVMFSuccess;
-}
-
-
-
-
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_port.h b/nodes/pvamrencnode/src/pvmf_amrenc_port.h
deleted file mode 100644
index d632dcf..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_port.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AMRENC_PORT_H_INCLUDED
-#define PVMF_AMRENC_PORT_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
-#include "pvmf_port_base_impl.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
-#include "pvmi_config_and_capability_utils.h"
-#endif
-
-// Forward declaration
-class PvmfAmrEncNode;
-class PvmfAmrEncCapabilityConfig;
-
-class PvmfAmrEncPort : public PvmfPortBaseImpl,
-            public PvmiCapabilityAndConfig,
-            public PVMFPortActivityHandler,
-            public OsclActiveObject
-{
-    public:
-        PvmfAmrEncPort(int32 aTag, PvmfAmrEncNode* aNode, PvmfAmrEncCapabilityConfig* aConfig, int32 aPriority, const char* aName = NULL);
-        ~PvmfAmrEncPort();
-
-        // Overload PvmfPortBaseImpl methods
-        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
-        OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
-
-
-        // Implement pure virtuals from PvmiCapabilityAndConfig interface
-        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
-                PvmiKvp*& aParameters, int& num_parameter_elements,
-                PvmiCapabilityContext aContext);
-        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                PvmiKvp* aParameters, int num_parameter_elements);
-        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                                               int num_elements, PvmiKvp * & aRet_kvp);
-        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
-        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-
-        PVMFStatus SetFormat(PVMFFormatType aFormat);
-
-        // Notification from node to resume processing incoming msg
-        void ProcessIncomingMsgReady();
-        void ProcessOutgoingMsgReady();
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-    private:
-        // Implement pure virtuals from OsclActiveObject
-        void Run();
-
-        /**
-         * Check if a format is supported for a specific port type
-         * @return true if specified format is supported for the specified port type
-         */
-        bool IsFormatSupported(PVMFFormatType aFormat);
-
-        /**
-         * Synchronous query of input port parameters
-         */
-        PVMFStatus GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                          int& num_parameter_elements);
-
-        /**
-         * Synchronous query of output port parameters
-         */
-        PVMFStatus GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                           int& num_parameter_elements);
-        /**
-         * Allocate a specified number of key-value pairs and set the keys
-         *
-         * @param aKvp Output parameter to hold the allocated key-value pairs
-         * @param aKey Key for the allocated key-value pairs
-         * @param aNumParams Number of key-value pairs to be allocated
-         * @return Completion status
-         */
-        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
-
-        /**
-         * Verify one key-value pair parameter against capability of the port and
-         * if the aSetParam flag is set, set the value of the parameter corresponding to
-         * the key.
-         *
-         * @param aKvp Key-value pair parameter to be verified
-         * @param aSetParam If true, set the value of parameter corresponding to the key.
-         * @return PVMFSuccess if parameter is supported, else PVMFFailure
-         */
-        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
-
-        /**
-         * Negotiates input port settings (format, video size and frame rate) and
-         * configures the peer port and the container node with these settings
-         *
-         * @param aConfig Capability and config object for peer port
-         * @return PVMFSuccess if settings are successfully negotiated.
-         */
-        PVMFStatus NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig);
-
-        /**
-         * Negotiates output port settings and configures the peer port using settings
-         * from the container node.
-         *
-         * @param aConfig Capability and config object for peer port
-         * @return PVMFSuccess if settings are successfully negotiated.
-         */
-        PVMFStatus NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig);
-
-        PVMFFormatType iFormat;
-        OsclMemAllocator iAlloc;
-        PvmfAmrEncNode* iNode;
-        PvmfAmrEncCapabilityConfig* iEncConfig;
-};
-
-#endif // PVMF_VIDEOENC_INPORT_H_INCLUDED
diff --git a/nodes/pvamrencnode/src/pvmf_amrenc_tuneables.h b/nodes/pvamrencnode/src/pvmf_amrenc_tuneables.h
deleted file mode 100644
index c30778c..0000000
--- a/nodes/pvamrencnode/src/pvmf_amrenc_tuneables.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- * @file pvvideoencmdf_tuneables.h
- * @brief Tuneable hard coded parameters for using PV video encoder MDF
- */
-
-#ifndef PVMF_AMRENC_TUNEABLES_H_INCLUDED
-#define PVMF_AMRENC_TUNEABLES_H_INCLUDED
-
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-// Constants for pvmf_amrenc_media_buffer.cpp
-const uint32 PVMF_AMRENC_MEDIA_BUF_DEFAULT_NUMOFFRAGMENTS  = 4;
-const uint32 PVMF_AMRENC_MEDIA_BUF_DEFAULT_FRAGMENT_LENGTH = 32;
-
-// Constants for pvmf_amrenc_node.cpp
-const uint32 MAX_AMR_FRAME_SIZE = 32;
-const uint32 AMR_FRAME_LENGTH_IN_TIMESTAMP = 20;
-const uint32 OUTPUT_BITSTREAMBUFFER_POOLNUM = 4;
-const uint32 OUTPUT_MEDIADATA_POOL_SIZE = 10;
-const uint32 OUTPUT_MEDIADATA_CHUNK_SIZE = 128;
-
-// Default port queue reserve size
-#define PVMF_AMRENC_NODE_PORT_VECTOR_RESERVE 2
-#define PVMF_AMRENC_NODE_MAX_INPUT_PORT 1
-#define PVMF_AMRENC_NODE_MAX_OUTPUT_PORT 1
-#define PVMF_AMRENC_NODE_PORT_ACTIVITY_RESERVE 10
-
-// Default command queue reserve size
-#define PVMF_AMRENC_NODE_CMD_QUEUE_RESERVE 10
-
-// Starting value for command IDs
-#define PVMF_AMRENC_NODE_CMD_ID_START 50000
-
-// Port queue settings
-#define PVMF_AMRENC_PORT_CAPACITY 10
-#define PVMF_AMRENC_PORT_RESERVE 10
-#define PVMF_AMRENC_PORT_THRESHOLD 50
-
-#define PVMF_AMRENC_DEFAULT_SAMPLING_RATE 8000
-#define PVMF_AMRENC_DEFAULT_NUM_CHANNELS 1
-
-#endif // PVMF_AMRENC_TUNEABLES_H_INCLUDED
-
diff --git a/nodes/pvamrencnode/src/pvmf_media_fraggroup_in_simple_buffer.h b/nodes/pvamrencnode/src/pvmf_media_fraggroup_in_simple_buffer.h
deleted file mode 100644
index e36d3c6..0000000
--- a/nodes/pvamrencnode/src/pvmf_media_fraggroup_in_simple_buffer.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_MEDIA_FRAG_GROUP_IN_SIMPLE_BUFFER_H_INCLUDED
-#define PVMF_MEDIA_FRAG_GROUP_IN_SIMPLE_BUFFER_H_INCLUDED
-
-#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
-#include "pvmf_media_data_impl.h"
-#endif
-#ifndef OSCL_VECTOR_H_INCLUDED
-#include "oscl_vector.h"
-#endif
-#ifndef OSCL_DEFALLOC_H_INCLUDED
-#include "Oscl_defalloc.h"
-#endif
-#ifndef OSCL_EXCEPTION_H_INCLUDED
-#include "oscl_exception.h"
-#endif
-#ifndef OSCL_ERROR_CODES_H_INCLUDED
-#include "oscl_error_codes.h"
-#endif
-
-/**
- * The PVMFMediaFragGroupInSimpleBuffer class is a MediaDataImpl implementation that
- * stores multiple OsclRefCounterMemFrag in one chunk of memory with one shared reference counter,
- * especially for multiple AMR fremes encoding. It takes an allocator as a templatized parameter to
- * allow the user to determine how memory for storing the fragments internally is allocated.
- * The PVMFMediaFragGroupInSimpleBuffer is created with a fixed capacity that is passed in at
- * construction time.
- */
-template <class Alloc>
-class PVMFMediaFragGroupInSimpleBuffer : public PVMFMediaDataImpl
-{
-
-    public:
-        OSCL_IMPORT_REF virtual uint32 getMarkerInfo();
-        OSCL_IMPORT_REF virtual bool isRandomAccessPoint();
-        OSCL_IMPORT_REF virtual uint32 getErrorsFlag();
-        OSCL_IMPORT_REF virtual uint32 getNumFragments();
-        OSCL_IMPORT_REF virtual bool getMediaFragment(uint32 index, OsclRefCounterMemFrag& memfrag);
-        OSCL_IMPORT_REF virtual bool getMediaFragmentSize(uint32, uint32&);
-        OSCL_IMPORT_REF virtual uint32 getFilledSize();
-        OSCL_IMPORT_REF virtual uint32 getCapacity();
-        OSCL_IMPORT_REF virtual void setCapacity(uint32 aCapacity);
-        OSCL_IMPORT_REF virtual bool setMediaFragFilledLen(uint32 index, uint32 len);
-        OSCL_IMPORT_REF virtual bool setMarkerInfo(uint32 marker);
-        OSCL_IMPORT_REF virtual bool setRandomAccessPoint(bool flag);
-        OSCL_IMPORT_REF virtual bool setErrorsFlag(uint32 flag);
-
-        OSCL_IMPORT_REF virtual bool appendMediaFragment(OsclRefCounterMemFrag& memfrag);
-        OSCL_IMPORT_REF virtual bool clearMediaFragments();
-
-        /* NOTE!!:  The constructor assumes the refcnt has already been incremented
-         * to reflect this class holding a reference to the buffer. Increment it
-         * externally if you aren't simply passing ownership of a reference
-         */
-        OSCL_IMPORT_REF PVMFMediaFragGroupInSimpleBuffer(void * ptr, uint32 buffer_length,
-                OsclRefCounter *my_refcnt,
-                uint32 group_capacity,
-                uint32 frag_capacity_in);
-
-        OSCL_IMPORT_REF virtual ~PVMFMediaFragGroupInSimpleBuffer();
-
-    private:
-        uint32 marker_info;
-        bool random_access_point;
-        uint32 errors_flag;
-        OsclMemoryFragment buffer;
-        Oscl_Vector<uint32, Alloc> iFragLengths;
-        uint32 group_capacity;
-        uint32 frag_capacity;
-        uint32 filled_size;
-        OsclRefCounter* refcnt;
-
-};
-
-
-template<class Alloc>
-OSCL_EXPORT_REF PVMFMediaFragGroupInSimpleBuffer<Alloc>::~PVMFMediaFragGroupInSimpleBuffer()
-{
-    // clear all the fragments
-    iFragLengths.clear();
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF uint32 PVMFMediaFragGroupInSimpleBuffer<Alloc>::getMarkerInfo()
-{
-    return marker_info;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::isRandomAccessPoint()
-{
-    return random_access_point;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF uint32 PVMFMediaFragGroupInSimpleBuffer<Alloc>::getErrorsFlag()
-{
-    return errors_flag;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF uint32 PVMFMediaFragGroupInSimpleBuffer<Alloc>::getNumFragments()
-{
-    return iFragLengths.size();
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF uint32 PVMFMediaFragGroupInSimpleBuffer<Alloc>::getFilledSize()
-{
-    return filled_size;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF uint32 PVMFMediaFragGroupInSimpleBuffer<Alloc>::getCapacity()
-{
-    return group_capacity;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::getMediaFragment(uint32 index, OsclRefCounterMemFrag& memfrag)
-{
-    if (index != 0 && index >= iFragLengths.size())
-    {
-        return false;
-    }
-
-    if (index == 0 && iFragLengths.empty())   // at this time, iFragLengths have no element, then send out buffer to let
-    {
-        OsclMemoryFragment raw_memFrag;			// the user get the buffer pointer
-        uint8 *ptr = (uint8 *)buffer.ptr;
-        raw_memFrag.ptr = (void *)ptr;
-        raw_memFrag.len = frag_capacity;
-        memfrag = OsclRefCounterMemFrag(raw_memFrag, refcnt, iFragLengths[index]);
-    }
-    else    // index < iFragLengths.size()
-    {
-        uint32 i = 0, offset = 0;
-        for (i = 0; i < index; i++) offset += iFragLengths[i];
-
-        OsclMemoryFragment raw_memFrag;
-        uint8 *ptr = (uint8 *)buffer.ptr;
-        raw_memFrag.ptr = (void *)(&ptr[offset]);
-        raw_memFrag.len = iFragLengths[index];
-        memfrag = OsclRefCounterMemFrag(raw_memFrag, refcnt, iFragLengths[index]);
-    }
-
-    // explicitly addref
-    refcnt->addRef();
-
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::getMediaFragmentSize(uint32 index, uint32& size)
-{
-    size = 0;
-    if (index >= iFragLengths.size())
-    {
-        return false;
-    }
-
-    size = iFragLengths[index];
-
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::setMediaFragFilledLen(uint32 index, uint32 len)
-{
-    if (index > iFragLengths.size() || index >= group_capacity)
-    {
-        return false;
-    }
-
-    if (len > frag_capacity)
-    {
-        return false;
-    }
-
-    if (index == iFragLengths.size())
-    {
-        iFragLengths.push_back(len);
-        filled_size += len;
-    }
-    else
-    {
-        filled_size -= iFragLengths[index];
-        iFragLengths[index] = len;
-        filled_size += len;
-    }
-
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::setMarkerInfo(uint32 in_marker)
-{
-    marker_info = in_marker;
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::setRandomAccessPoint(bool flag)
-{
-    random_access_point = flag;
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::setErrorsFlag(uint32 flag)
-{
-    errors_flag = flag;
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF PVMFMediaFragGroupInSimpleBuffer<Alloc>::PVMFMediaFragGroupInSimpleBuffer(void * ptr, uint32 buffer_length,
-        OsclRefCounter *my_refcnt,
-        uint32 group_capacity_in,
-        uint32 frag_capacity_in) :
-        marker_info(0), random_access_point(false), errors_flag(0),
-        group_capacity(group_capacity_in), frag_capacity(frag_capacity_in), filled_size(0), refcnt(my_refcnt)
-{
-    buffer.ptr = ptr;
-    buffer.len = buffer_length;
-    iFragLengths.reserve(group_capacity);
-}
-
-
-// Not supported, because there is one chunck of memory shared for all the fragments
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::appendMediaFragment(OsclRefCounterMemFrag& memfrag)
-{
-    OSCL_UNUSED_ARG(memfrag);
-    return false;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF bool PVMFMediaFragGroupInSimpleBuffer<Alloc>::clearMediaFragments()
-{
-    iFragLengths.clear();
-    group_capacity = 0;
-    frag_capacity  = 0;
-    filled_size = 0;
-    return true;
-}
-
-template<class Alloc>
-OSCL_EXPORT_REF void PVMFMediaFragGroupInSimpleBuffer<Alloc>::setCapacity(uint32 aCapacity)
-{
-    OSCL_UNUSED_ARG(aCapacity);
-    OSCL_LEAVE(OsclErrNotSupported);
-}
-#endif // PVMF_MEDIA_FRAG_GROUP_IN_SIMPLE_BUFFER_H_INCLUDED
-
diff --git a/nodes/pvamrffparsernode/Android.mk b/nodes/pvamrffparsernode/Android.mk
index ee953e2..90e5c1b 100644
--- a/nodes/pvamrffparsernode/Android.mk
+++ b/nodes/pvamrffparsernode/Android.mk
@@ -3,28 +3,30 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_amrffparser_node.cpp \
-	src/pvmf_amrffparser_port.cpp \
-	src/pvmf_amrffparser_factory.cpp
-
+ 	src/pvmf_amrffparser_port.cpp \
+ 	src/pvmf_amrffparser_factory.cpp
 
 
 LOCAL_MODULE := libpvamrffparsernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvamrffparsernode/include \
-	$(PV_TOP)//nodes/pvamrffparsernode/src \
-	$(PV_TOP)//nodes/pvamrffparsernode/../common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvamrffparsernode/src \
+ 	$(PV_TOP)/nodes/pvamrffparsernode/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_amrffparser_factory.h \
-	include/pvmf_amrffparser_registry_factory.h \
-	include/pvmf_amrffparser_defs.h
+ 	include/pvmf_amrffparser_registry_factory.h \
+ 	include/pvmf_amrffparser_events.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvamrffparsernode/build/make/local.mk b/nodes/pvamrffparsernode/build/make/local.mk
new file mode 100644
index 0000000..6e4f6f2
--- /dev/null
+++ b/nodes/pvamrffparsernode/build/make/local.mk
@@ -0,0 +1,29 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvamrffparsernode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_amrffparser_node.cpp pvmf_amrffparser_port.cpp pvmf_amrffparser_factory.cpp
+
+HDRS := pvmf_amrffparser_factory.h \
+	pvmf_amrffparser_registry_factory.h \
+	pvmf_amrffparser_events.h
+
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvamrffparsernode/build/make/makefile b/nodes/pvamrffparsernode/build/make/makefile
deleted file mode 100644
index 733da05..0000000
--- a/nodes/pvamrffparsernode/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvamrffparsernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../common/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_amrffparser_node.cpp pvmf_amrffparser_port.cpp pvmf_amrffparser_factory.cpp
-
-HDRS =  pvmf_amrffparser_factory.h \
-	pvmf_amrffparser_registry_factory.h \
-	pvmf_amrffparser_defs.h 
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvamrffparsernode/include/pvmf_amrffparser_defs.h b/nodes/pvamrffparsernode/include/pvmf_amrffparser_defs.h
index 3fe325a..611da18 100644
--- a/nodes/pvamrffparsernode/include/pvmf_amrffparser_defs.h
+++ b/nodes/pvamrffparsernode/include/pvmf_amrffparser_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrffparsernode/include/pvmf_amrffparser_events.h b/nodes/pvamrffparsernode/include/pvmf_amrffparser_events.h
index e7e9f72..31f5449 100644
--- a/nodes/pvamrffparsernode/include/pvmf_amrffparser_events.h
+++ b/nodes/pvamrffparsernode/include/pvmf_amrffparser_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrffparsernode/include/pvmf_amrffparser_factory.h b/nodes/pvamrffparsernode/include/pvmf_amrffparser_factory.h
index bf59c13..432e010 100644
--- a/nodes/pvamrffparsernode/include/pvmf_amrffparser_factory.h
+++ b/nodes/pvamrffparsernode/include/pvmf_amrffparser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrffparsernode/include/pvmf_amrffparser_registry_factory.h b/nodes/pvamrffparsernode/include/pvmf_amrffparser_registry_factory.h
index e8d2c74..85f7ed1 100644
--- a/nodes/pvamrffparsernode/include/pvmf_amrffparser_registry_factory.h
+++ b/nodes/pvamrffparsernode/include/pvmf_amrffparser_registry_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrffparsernode/src/amr_parsernode_tunables.h b/nodes/pvamrffparsernode/src/amr_parsernode_tunables.h
index 2dace91..4b2c053 100644
--- a/nodes/pvamrffparsernode/src/amr_parsernode_tunables.h
+++ b/nodes/pvamrffparsernode/src/amr_parsernode_tunables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrffparsernode/src/pvmf_amrffparser_factory.cpp b/nodes/pvamrffparsernode/src/pvmf_amrffparser_factory.cpp
index 738fce3..3b1ef7f 100644
--- a/nodes/pvamrffparsernode/src/pvmf_amrffparser_factory.cpp
+++ b/nodes/pvamrffparsernode/src/pvmf_amrffparser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.cpp b/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.cpp
index c90f937..d705d61 100644
--- a/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.cpp
+++ b/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,14 +49,7 @@
 
 #define AMR_SAMPLE_DURATION 20
 
-void PVMFAMRFFParserNode::Assert(bool x)
-{
-    if (!x)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_CRIT, (0, "PVMFAMRFFParserNode Assertion Failed!"));
-        OSCL_ASSERT(0);
-    }
-}
+
 
 PVMFAMRFFParserNode::PVMFAMRFFParserNode(int32 aPriority) :
         OsclTimerObject(aPriority, "PVAMRFFParserNode"),
@@ -65,12 +58,12 @@
         iAMRParser(NULL),
         iExtensionRefCount(0)
 {
-    iFileHandle				   = NULL;
-    iLogger					   = NULL;
-    iDataPathLogger			   = NULL;
-    iClockLogger			   = NULL;
+    iFileHandle                = NULL;
+    iLogger                    = NULL;
+    iDataPathLogger            = NULL;
+    iClockLogger               = NULL;
 
-    iExtensionRefCount		   = 0;
+    iExtensionRefCount         = 0;
     iUseCPMPluginRegistry      = false;
 
     iCPM                       = NULL;
@@ -98,11 +91,11 @@
     iDownloadFileSize          = 0;
     iAMRHeaderSize             = AMR_HEADER_SIZE;
     iDataStreamInterface       = NULL;
-    iDataStreamFactory		   = NULL;
+    iDataStreamFactory         = NULL;
     iDataStreamReadCapacityObserver = NULL;
     iAutoPaused                = false;
 
-    iStreamID				   = 0;
+    iStreamID                  = 0;
 
     oSourceIsCurrent           = false;
     iInterfaceState = EPVMFNodeCreated;
@@ -111,7 +104,6 @@
     iFileHandle = NULL;
 
     iCountToClaculateRDATimeInterval = 1;
-
     int32 err;
     OSCL_TRY(err,
 
@@ -131,9 +123,9 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = true;
              iCapability.iMaxNumberOfPorts = 1;
-             iCapability.iOutputFormatCapability.push_back(PVMF_AMR_IETF);
-             iCapability.iOutputFormatCapability.push_back(PVMF_AMR_IF2);
-             iCapability.iOutputFormatCapability.push_back(PVMF_AMRWB_IETF);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_AMR_IF2);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_AMRWB_IETF);
             );
 
     if (err != OsclErrNone)
@@ -154,7 +146,6 @@
 
 PVMFAMRFFParserNode::~PVMFAMRFFParserNode()
 {
-    ThreadLogoff();
     if (iRequestedUsage.key)
     {
         OSCL_ARRAY_DELETE(iRequestedUsage.key);
@@ -177,6 +168,10 @@
         PVMFCPMFactory::DestroyContentPolicyManager(iCPM);
         iCPM = NULL;
     }
+    if (iDownloadProgressInterface != NULL)
+    {
+        iDownloadProgressInterface->cancelResumeNotification();
+    }
     //Cleanup commands
     //The command queues are self-deleting, but we want to
     //notify the observer of unprocessed commands.
@@ -192,6 +187,10 @@
     {
         CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
     }
+    if (iExtensionRefCount > 0)
+    {
+        OSCL_ASSERT(false);
+    }
     Cancel();
 
     //Cleanup allocated ports
@@ -372,17 +371,19 @@
 {
     if (!iInputCommands.empty())
     {
-        ProcessCommand();
-        /*
-         * note: need to check the state before re-scheduling
-         * since the node could have been reset in the ProcessCommand
-         * call.
-         */
-        if (iInterfaceState != EPVMFNodeCreated)
+        if (ProcessCommand())
         {
-            RunIfNotReady();
+            /*
+             * note: need to check the state before re-scheduling
+             * since the node could have been reset in the ProcessCommand
+             * call.
+             */
+            if (iInterfaceState != EPVMFNodeCreated)
+            {
+                RunIfNotReady();
+            }
+            return;
         }
-        return;
     }
     // Send outgoing messages
     if (iInterfaceState == EPVMFNodeStarted || FlushPending())
@@ -474,7 +475,6 @@
 
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
     uint32 lcv = 0;
     for (lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
     {
@@ -484,11 +484,11 @@
             if (num_entries > starting_index)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAMRFFParserNode::DoGetNodeMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushValueToList(iAvailableMetadataKeys, keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -502,11 +502,11 @@
                 if (num_entries > starting_index)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAMRFFParserNode::DoGetNodeMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushValueToList(iAvailableMetadataKeys, keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -527,11 +527,12 @@
             if (num_entries > (uint32)starting_index)
             {
                 /* Past the starting index so copy the key */
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+
+                PVMFStatus status = PushValueToList(iCPMMetadataKeys, keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -544,11 +545,12 @@
                 if (num_entries > (uint32)starting_index)
                 {
                     /* Past the starting index so copy the key */
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+
+                    PVMFStatus status = PushValueToList(iCPMMetadataKeys, keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -560,6 +562,9 @@
         }
     }
 
+
+
+
     return PVMFSuccess;
 }
 
@@ -767,8 +772,7 @@
         if (KeyVal.key != NULL)
         {
             // Add the entry to the list
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
+            leavecode = PushBackKeyVal(valuelistptr, KeyVal);
             if (leavecode != 0)
             {
                 switch (GetValTypeFromKeyString(KeyVal.key))
@@ -840,13 +844,6 @@
 
     aCmd.PVMFAMRFFNodeCommand::Parse(targetNPT, actualNPT, actualMediaDataTS, seektosyncpoint, streamID);
 
-
-    bool retVal = false;
-    // duplicate bos has been received
-    // dont perform reposition at source node
-    if (iStreamID == streamID)
-        retVal = true;
-
     Oscl_Vector<PVAMRFFNodeTrackPortInfo, PVMFAMRParserNodeAllocator>::iterator it;
     for (it = iSelectedTrackList.begin(); it != iSelectedTrackList.end(); it++)
     {
@@ -856,12 +853,6 @@
     //save the stream id for next media segment
     iStreamID = streamID;
 
-    if (retVal)
-    {
-        RunIfNotReady();
-        return PVMFSuccess;
-    }
-
     *actualNPT = 0;
     *actualMediaDataTS = 0;
 
@@ -894,10 +885,10 @@
         // report EOS for the track.
         for (uint32 i = 0; i < iSelectedTrackList.size(); ++i)
         {
-            iSelectedTrackList[i].iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK;
             iSelectedTrackList[i].iSeqNum = 0;
             iSelectedTrackList[i].oEOSReached = true;
             iSelectedTrackList[i].oQueueOutgoingMessages = true;
+            iSelectedTrackList[i].oEOSSent = false;
         }
         result = iAMRParser->ResetPlayback(0);
         if (result != bitstreamObject::EVERYTHING_OK)
@@ -905,7 +896,7 @@
             return PVMFErrResource;
         }
 
-        *actualNPT = result;
+        *actualNPT = durationms;
         return PVMFSuccess;
     }
 
@@ -915,7 +906,28 @@
     result = iAMRParser->ResetPlayback(targetNPT);
     if (result != bitstreamObject::EVERYTHING_OK)
     {
-        return PVMFErrResource;
+        if (bitstreamObject::END_OF_FILE == result)
+        {
+            for (uint32 i = 0; i < iSelectedTrackList.size(); ++i)
+            {
+                iSelectedTrackList[i].iSeqNum = 0;
+                iSelectedTrackList[i].oEOSReached = true;
+                iSelectedTrackList[i].oQueueOutgoingMessages = true;
+                iSelectedTrackList[i].oEOSSent = false;
+            }
+            result = iAMRParser->ResetPlayback(0);
+            if (result != bitstreamObject::EVERYTHING_OK)
+            {
+                return PVMFErrResource;
+            }
+
+            *actualNPT = result;
+            return PVMFSuccess;
+        }
+        else
+        {
+            return PVMFErrResource;
+        }
     }
 
     //Peek new position to get the actual new timestamp
@@ -967,29 +979,9 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::DoSetDataSourceRate() In"));
     OSCL_UNUSED_ARG(aCmd);
-    CommandComplete(iInputCommands, aCmd, PVMFFailure);
     return PVMFSuccess;
 }
 
-bool PVMFAMRFFParserNode::SendTrackData(PVAMRFFNodeTrackPortInfo& aTrackPortInfo)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::SendTrackData() Seq Num %d Timestamp %d"
-                    , aTrackPortInfo.iMediaData->getSeqNum()
-                    , aTrackPortInfo.iMediaData->getTimestamp()));
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    aTrackPortInfo.iMediaData->setStreamID(iStreamID);
-    convertToPVMFMediaMsg(mediaMsgOut, aTrackPortInfo.iMediaData);
-    if (aTrackPortInfo.iPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::SendTrackData() Failed-- Busy"));
-        return false;
-    }
-    aTrackPortInfo.iMediaData.Unbind();
-    return true;
-}
-
-
 bool PVMFAMRFFParserNode::SendEndOfTrackCommand(PVAMRFFNodeTrackPortInfo& aTrackPortInfo)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::SendEndOfTrackCommand() "));
@@ -1063,18 +1055,18 @@
     }
 }
 
-void PVMFAMRFFParserNode::ProcessCommand()
+bool PVMFAMRFFParserNode::ProcessCommand()
 {
     //This call will process the first node command in the input queue.
     //Can't do anything when an asynchronous cancel is in progress-- just
     //need to wait on completion.
     if (!iCancelCommand.empty())
-        return;
+        return false;
 
     //If a command is in progress, only a hi-pri command can interrupt it.
     if (!iCurrentCommand.empty()  && !iInputCommands.front().hipri() && iInputCommands.front().iCmd != PVMF_AMR_PARSER_NODE_CMD_CANCEL_GET_LICENSE)
     {
-        return;
+        return false;
     }
 
     //The newest or highest pri command is in the front of the queue.
@@ -1223,8 +1215,11 @@
             break;
 
             case PVMF_AMR_PARSER_NODE_SET_DATASOURCE_RATE:
-                DoSetDataSourceRate(aCmd);
-                break;
+            {
+                PVMFStatus status = DoSetDataSourceRate(aCmd);
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+            break;
 
             case PVMF_AMR_PARSER_NODE_GET_LICENSE_W:
             {
@@ -1274,7 +1269,7 @@
                 break;
         }
     }
-
+    return true;
 }
 
 void PVMFAMRFFParserNode::SetState(TPVMFNodeInterfaceState s)
@@ -1290,8 +1285,18 @@
 
     if (aEventUUID && aEventCode)
     {
-        PVMFBasicErrorInfoMessage* eventmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        PVMFAsyncEvent asyncevent(PVMFErrorEvent, aEventType, NULL, eventmsg, aEventData, NULL, 0);
+        PVMFBasicErrorInfoMessage* eventmsg;
+        PVMF_AMR_PARSER_NODE_NEW(NULL,
+                                 PVMFBasicErrorInfoMessage,
+                                 (*aEventCode, *aEventUUID, NULL),
+                                 eventmsg);
+        PVMFAsyncEvent asyncevent(PVMFErrorEvent,
+                                  aEventType,
+                                  NULL,
+                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
+                                  aEventData,
+                                  NULL,
+                                  0);
         PVMFNodeInterface::ReportErrorEvent(asyncevent);
         eventmsg->removeRef();
     }
@@ -1299,6 +1304,8 @@
     {
         PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
     }
+    /* Transition the node to an error state */
+    iInterfaceState = EPVMFNodeError;
 }
 
 void PVMFAMRFFParserNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData, PVUuid* aEventUUID, int32* aEventCode)
@@ -1308,8 +1315,18 @@
 
     if (aEventUUID && aEventCode)
     {
-        PVMFBasicErrorInfoMessage* eventmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        PVMFAsyncEvent asyncevent(PVMFInfoEvent, aEventType, NULL, eventmsg, aEventData, NULL, 0);
+        PVMFBasicErrorInfoMessage* eventmsg;
+        PVMF_AMR_PARSER_NODE_NEW(NULL,
+                                 PVMFBasicErrorInfoMessage,
+                                 (*aEventCode, *aEventUUID, NULL),
+                                 eventmsg);
+        PVMFAsyncEvent asyncevent(PVMFInfoEvent,
+                                  aEventType,
+                                  NULL,
+                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
+                                  aEventData,
+                                  NULL,
+                                  0);
         PVMFNodeInterface::ReportInfoEvent(asyncevent);
         eventmsg->removeRef();
     }
@@ -1375,6 +1392,7 @@
 
 PVMFStatus PVMFAMRFFParserNode::DoInit(PVMFAMRFFNodeCommand& aCmd)
 {
+    OSCL_UNUSED_ARG(aCmd);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::DoInitNode() In"));
 
     if (iInterfaceState != EPVMFNodeIdle)
@@ -1470,76 +1488,63 @@
 
 void PVMFAMRFFParserNode::DoPrepare(PVMFAMRFFNodeCommand& aCmd)
 {
-    switch (iInterfaceState)
+    if (iInterfaceState != EPVMFNodeInitialized)
     {
-        case EPVMFNodeInitialized:
-
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-
-        default:
-
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            return;
-
+        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+        return;
     }
+    SetState(EPVMFNodePrepared);
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    return;
 }
 
-
 void PVMFAMRFFParserNode::DoStart(PVMFAMRFFNodeCommand& aCmd)
 {
-    switch (iInterfaceState)
+    if (iInterfaceState != EPVMFNodePrepared &&
+            iInterfaceState != EPVMFNodePaused)
     {
-        case EPVMFNodePrepared:
-        case EPVMFNodePaused:
-            SetState(EPVMFNodeStarted);
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            return;
+        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+        return;
     }
-
+    SetState(EPVMFNodeStarted);
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    return;
 }
 
 void PVMFAMRFFParserNode::DoStop(PVMFAMRFFNodeCommand& aCmd)
 {
-    switch (iInterfaceState)
+    iStreamID = 0;
+
+    if (iInterfaceState != EPVMFNodeStarted &&
+            iInterfaceState != EPVMFNodePaused)
     {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            if (iDataStreamInterface != NULL)
-            {
-                PVInterface* iFace = OSCL_STATIC_CAST(PVInterface*, iDataStreamInterface);
-                PVUuid uuid = PVMIDataStreamSyncInterfaceUuid;
-                iDataStreamFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iFace);
-                iDataStreamInterface = NULL;
-            }
-            // stop and reset position to beginning
-            ResetAllTracks();
+        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+        return;
+    }
+    if (iDataStreamInterface != NULL)
+    {
+        PVInterface* iFace = OSCL_STATIC_CAST(PVInterface*, iDataStreamInterface);
+        PVUuid uuid = PVMIDataStreamSyncInterfaceUuid;
+        iDataStreamFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iFace);
+        iDataStreamInterface = NULL;
+    }
+    // stop and reset position to beginning
+    ResetAllTracks();
 
-            // Reset the AMR FF to beginning
-            if (iAMRParser)
-            {
-                iAMRParser->ResetPlayback(0);
-            }
-
-            //clear msg queue
-            if (iOutPort)
-            {
-                iOutPort->ClearMsgQueues();
-            }
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            return;
+    // Reset the AMR FF to beginning
+    if (iAMRParser)
+    {
+        iAMRParser->ResetPlayback(0);
     }
 
+    //clear msg queue
+    if (iOutPort)
+    {
+        iOutPort->ClearMsgQueues();
+    }
+    SetState(EPVMFNodePrepared);
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    return;
 }
 
 void PVMFAMRFFParserNode::DoPause(PVMFAMRFFNodeCommand& aCmd)
@@ -1586,6 +1591,10 @@
 
     PVMF_AMRPARSERNODE_LOGSTACKTRACE((0, "PVMFAMRParserNode::DoReset() Called"));
 
+    if (iDownloadProgressInterface != NULL)
+    {
+        iDownloadProgressInterface->cancelResumeNotification();
+    }
     MoveCmdToCurrentQueue(aCmd);
     if (iFileHandle != NULL)
     {
@@ -1689,13 +1698,14 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::DoRequestPort() In"));
     aPort = NULL;
 
-    if (!iAMRParser)
+    if ((iInterfaceState != EPVMFNodePrepared) || (!iAMRParser))
     {
+        PVMF_AMRPARSERNODE_LOGERROR((0, "PVMFASFParserNode::DoRequestPort() - Invalid State"));
         CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
         return;
     }
 
-    int32 tag;
+    int32 tag = 0;
     OSCL_String* mime_string;
     aCmd.PVMFAMRFFNodeCommandBase::Parse(tag, mime_string);
 
@@ -1728,7 +1738,7 @@
         }
         if (mime_string)
         {
-            PVMFFormatType fmt = GetFormatIndex(mime_string->get_str(), PVMF_COMPRESSED_AUDIO_FORMAT);
+            PVMFFormatType fmt = mime_string->get_str();
             if (!iOutPort->IsFormatSupported(fmt))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1782,6 +1792,8 @@
             return;
         }
 
+        mediadatamempool->enablenullpointerreturn();
+
         PVAMRFFNodeTrackPortInfo trackportinfo;
 
         trackportinfo.iTrackId = 0;  // Only support 1 channel so far
@@ -1789,7 +1801,6 @@
         trackportinfo.iPort = iOutPort;
 
         trackportinfo.iClockConverter = clockconv;
-        trackportinfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_UNINITIALIZED;
         trackportinfo.iTrackDataMemoryPool = trackdatamempool;
         trackportinfo.iMediaDataImplAlloc = mediadataimplalloc;
         trackportinfo.iMediaDataMemPool = mediadatamempool;
@@ -1805,7 +1816,7 @@
                                  trackDataResizableMemPool);
 
         PVUuid eventuuid = PVMFAMRParserNodeEventTypesUUID;
-        int32	errcode = PVMFAMRFFParserErrTrackMediaMsgAllocatorCreationFailed;
+        int32   errcode = PVMFAMRFFParserErrTrackMediaMsgAllocatorCreationFailed;
 
         PVMFResizableSimpleMediaMsgAlloc* resizableSimpleMediaDataImplAlloc = NULL;
         OsclExclusivePtr<PVMFResizableSimpleMediaMsgAlloc> resizableSimpleMediaDataImplAllocAutoPtr;
@@ -1826,6 +1837,8 @@
             return;
         }
 
+        trackDataResizableMemPool->enablenullpointerreturn();
+
         trackportinfo.iResizableSimpleMediaMsgAlloc = resizableSimpleMediaDataImplAlloc;
         trackportinfo.iResizableDataMemoryPool = trackDataResizableMemPool;
         trackportinfo.iNode = this;
@@ -1899,10 +1912,25 @@
             OSCL_DELETE(((PVMFAMRFFParserOutPort*)iSelectedTrackList[i].iPort));
             iSelectedTrackList[i].iPort = NULL;
             iOutPort = NULL;
-            OSCL_DELETE(iSelectedTrackList[i].iClockConverter);
-            OSCL_DELETE(iSelectedTrackList[i].iTrackDataMemoryPool);
-            OSCL_DELETE(iSelectedTrackList[i].iMediaDataImplAlloc);
-            OSCL_DELETE(iSelectedTrackList[i].iMediaDataMemPool);
+            if (iSelectedTrackList[i].iClockConverter)
+            {
+                OSCL_DELETE(iSelectedTrackList[i].iClockConverter);
+            }
+            if (iSelectedTrackList[i].iTrackDataMemoryPool)
+            {
+                iSelectedTrackList[i].iTrackDataMemoryPool->removeRef();
+                iSelectedTrackList[i].iTrackDataMemoryPool = NULL;
+            }
+            if (iSelectedTrackList[i].iMediaDataImplAlloc)
+            {
+                OSCL_DELETE(iSelectedTrackList[i].iMediaDataImplAlloc);
+            }
+            if (iSelectedTrackList[i].iMediaDataMemPool)
+            {
+                iSelectedTrackList[i].iMediaDataMemPool->CancelFreeChunkAvailableCallback();
+                iSelectedTrackList[i].iMediaDataMemPool->removeRef();
+                iSelectedTrackList[i].iMediaDataMemPool = NULL;
+            }
 
             if (iSelectedTrackList[i].iResizableSimpleMediaMsgAlloc != NULL)
             {
@@ -1932,7 +1960,6 @@
 {
     for (uint32 i = 0; i < iSelectedTrackList.size(); ++i)
     {
-        iSelectedTrackList[i].iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_UNINITIALIZED;
         iSelectedTrackList[i].iMediaData.Unbind();
         iSelectedTrackList[i].iSeqNum = 0;
         iSelectedTrackList[i].iFirstFrame = true;
@@ -1940,8 +1967,6 @@
         iSelectedTrackList[i].oEOSSent = false;
         iSelectedTrackList[i].oEOSReached = false;
         iSelectedTrackList[i].oQueueOutgoingMessages = true;
-        //iSelectedTrackList[i].oProcessOutgoingMessages = true;
-
     }
 }
 
@@ -1952,11 +1977,27 @@
         iSelectedTrackList[0].iPort->Disconnect();
         iSelectedTrackList[0].iMediaData.Unbind();
         OSCL_DELETE(((PVMFAMRFFParserOutPort*)iSelectedTrackList[0].iPort));
-        OSCL_DELETE(iSelectedTrackList[0].iClockConverter);
+        if (iSelectedTrackList[0].iClockConverter)
+        {
+            OSCL_DELETE(iSelectedTrackList[0].iClockConverter);
+        }
+        if (iSelectedTrackList[0].iTrackDataMemoryPool)
+        {
+            iSelectedTrackList[0].iTrackDataMemoryPool->removeRef();
+            iSelectedTrackList[0].iTrackDataMemoryPool = NULL;
+        }
+        if (iSelectedTrackList[0].iMediaDataImplAlloc)
+        {
+            OSCL_DELETE(iSelectedTrackList[0].iMediaDataImplAlloc);
+        }
+        if (iSelectedTrackList[0].iMediaDataMemPool)
+        {
+            iSelectedTrackList[0].iMediaDataMemPool->CancelFreeChunkAvailableCallback();
+            iSelectedTrackList[0].iMediaDataMemPool->removeRef();
+            iSelectedTrackList[0].iMediaDataMemPool = NULL;
+        }
         iOutPort = NULL;
-        OSCL_DELETE(iSelectedTrackList[0].iTrackDataMemoryPool);
-        OSCL_DELETE(iSelectedTrackList[0].iMediaDataImplAlloc);
-        OSCL_DELETE(iSelectedTrackList[0].iMediaDataMemPool);
+
         if (iSelectedTrackList[0].iResizableSimpleMediaMsgAlloc != NULL)
         {
             PVMF_AMR_PARSER_NODE_DELETE(NULL,
@@ -1971,7 +2012,6 @@
         }
         iSelectedTrackList.erase(iSelectedTrackList.begin());
     }
-
     return true;
 }
 
@@ -2014,53 +2054,25 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFAMRFFParserNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
                     , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
 
-    //do state transitions
-    if (aStatus == PVMFSuccess)
+    PVInterface* extif = NULL;
+    PVMFBasicErrorInfoMessage* errormsg = NULL;
+    if (aExtMsg)
     {
-        switch (aCmd.iCmd)
-        {
-            case PVMF_AMR_PARSER_NODE_INIT:
-                SetState(EPVMFNodeInitialized);
-                break;
-            case PVMF_AMR_PARSER_NODE_PREPARE:
-                SetState(EPVMFNodePrepared);
-                break;
-            case PVMF_AMR_PARSER_NODE_START:
-                SetState(EPVMFNodeStarted);
-                break;
-            case PVMF_AMR_PARSER_NODE_STOP:
-            case PVMF_AMR_PARSER_NODE_FLUSH:
-                SetState(EPVMFNodePrepared);
-                break;
-            case PVMF_AMR_PARSER_NODE_PAUSE:
-                SetState(EPVMFNodePaused);
-                break;
-            case PVMF_AMR_PARSER_NODE_RESET:
-                SetState(EPVMFNodeIdle);
-                ThreadLogoff();
-                break;
-            default:
-                break;
-        }
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFAMRFFParserNode:CommandComplete Failed!"));
+        extif = aExtMsg;
     }
 
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aExtMsg, aEventData);
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
     PVMFSessionId session = aCmd.iSession;
 
-    //Erase the command from the queue.
+    /* Erase the command from the queue. */
     aCmdQ.Erase(&aCmd);
 
-    //Report completion to the session observer.
+    /* Report completion to the session observer.*/
     ReportCmdCompleteEvent(session, resp);
 
-    //Continue processing commands.
-    if (iInputCommands.size() > 0 && IsAdded())
+    if (errormsg)
     {
-        RunIfNotReady();
+        errormsg->removeRef();
     }
 }
 
@@ -2171,8 +2183,6 @@
     {
         return false;
     }
-
-    ++iExtensionRefCount;
     return true;
 }
 
@@ -2180,7 +2190,7 @@
 PVMFStatus PVMFAMRFFParserNode::SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::SetSourceInitializationData() called"));
-    if (aSourceFormat == PVMF_AMRFF)
+    if (aSourceFormat == PVMF_MIME_AMRFF)
     {
         /* Clean up any previous sources */
         CleanupFileSource();
@@ -2269,13 +2279,13 @@
     return PVMFFailure;
 }
 
-PVMFStatus PVMFAMRFFParserNode::SetClientPlayBackClock(OsclClock* aClientClock)
+PVMFStatus PVMFAMRFFParserNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
 }
 
-PVMFStatus PVMFAMRFFParserNode::SetEstimatedServerClock(OsclClock* aClientClock)
+PVMFStatus PVMFAMRFFParserNode::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
@@ -2301,8 +2311,8 @@
     switch (amrinfo.iAmrFormat)
     {
             // Supported formats
-        case EAMRIF2:		// IF2
-        case EAMRIETF_SingleNB:	// IETF
+        case EAMRIF2:       // IF2
+        case EAMRIETF_SingleNB: // IETF
         case EAMRIETF_SingleWB:
             break;
 
@@ -2569,7 +2579,7 @@
 
 PVMFCommandId PVMFAMRFFParserNode::SetDataSourceRate(PVMFSessionId aSessionId
         , int32 aRate
-        , OsclTimebase* aTimebase
+        , PVMFTimebase* aTimebase
         , OsclAny* aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::SetDataSourceRate() called"));
@@ -2812,10 +2822,11 @@
 
 void PVMFAMRFFParserNode::GetCPMLicenseInterface()
 {
+    iCPMLicenseInterfacePVI = NULL;
     iCPMGetLicenseInterfaceCmdId =
         iCPM->QueryInterface(iCPMSessionID,
                              PVMFCPMPluginLicenseInterfaceUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMLicenseInterface));
+                             iCPMLicenseInterfacePVI);
 }
 
 bool PVMFAMRFFParserNode::GetCPMContentAccessFactory()
@@ -2831,9 +2842,10 @@
 
 bool PVMFAMRFFParserNode::GetCPMMetaDataExtensionInterface()
 {
+    PVInterface* temp = NULL;
     bool retVal =
-        iCPM->queryInterface(KPVMFMetadataExtensionUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMMetaDataExtensionInterface));
+        iCPM->queryInterface(KPVMFMetadataExtensionUuid, temp);
+    iCPMMetaDataExtensionInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, temp);
     return retVal;
 }
 
@@ -3006,7 +3018,13 @@
         PVMF_AMRPARSERNODE_LOGINFO((0, "PVMFAMRParserNode::CPMCommandCompleted - Unknown CPM Format - Ignoring CPM"));
         if (CheckForAMRHeaderAvailability() == PVMFSuccess)
         {
-            CompleteInit();
+            if (ParseAMRFile())
+            {
+                /* End of Node Init sequence. */
+                OSCL_ASSERT(!iCurrentCommand.empty());
+                OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_AMR_PARSER_NODE_INIT);
+                CompleteInit();
+            }
         }
         return;
     }
@@ -3045,6 +3063,8 @@
         }
         else if (id == iCPMGetLicenseInterfaceCmdId)
         {
+            iCPMLicenseInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, iCPMLicenseInterfacePVI);
+            iCPMLicenseInterfacePVI = NULL;
             iCPMContentType = iCPM->GetCPMContentType(iCPMSessionID);
 
             if ((iCPMContentType == PVMF_CPM_FORMAT_AUTHORIZE_BEFORE_ACCESS)
@@ -3052,7 +3072,13 @@
             {
                 GetCPMContentAccessFactory();
                 GetCPMMetaDataExtensionInterface();
-                RequestUsage();
+                if (CheckForAMRHeaderAvailability() == PVMFSuccess)
+                {
+                    if (ParseAMRFile())
+                    {
+                        RequestUsage();
+                    }
+                }
             }
             else
             {
@@ -3060,7 +3086,22 @@
                 PVMF_AMRPARSERNODE_LOGINFO((0, "PVMFAMRParserNode::CPMCommandCompleted - Unknown CPM Format - Ignoring CPM"));
                 if (CheckForAMRHeaderAvailability() == PVMFSuccess)
                 {
-                    CompleteInit();
+                    if (ParseAMRFile())
+                    {
+                        OSCL_ASSERT(!iCurrentCommand.empty());
+                        OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_AMR_PARSER_NODE_INIT);
+                        CompleteInit();
+                        /*
+                         * if there was any pending cancel, it was waiting on
+                         * this command to complete-- so the cancel is now done.
+                         */
+                        if (!iCancelCommand.empty())
+                        {
+                            CommandComplete(iCancelCommand,
+                                            iCancelCommand.front(),
+                                            PVMFSuccess);
+                        }
+                    }
                 }
             }
         }
@@ -3071,7 +3112,22 @@
             {
                 if (CheckForAMRHeaderAvailability() == PVMFSuccess)
                 {
-                    CompleteInit();
+                    if (ParseAMRFile())
+                    {
+                        OSCL_ASSERT(!iCurrentCommand.empty());
+                        OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_AMR_PARSER_NODE_INIT);
+                        CompleteInit();
+                        /*
+                         * if there was any pending cancel, it was waiting on
+                         * this command to complete-- so the cancel is now done.
+                         */
+                        if (!iCancelCommand.empty())
+                        {
+                            CommandComplete(iCancelCommand,
+                                            iCancelCommand.front(),
+                                            PVMFSuccess);
+                        }
+                    }
                 }
             }
             else
@@ -3120,6 +3176,7 @@
         }
         else
         {
+            /* Unknown cmd - error */
             CommandComplete(iCurrentCommand,
                             iCurrentCommand.front(),
                             PVMFFailure);
@@ -3183,24 +3240,8 @@
                                 NULL, NULL, NULL);
                 return;
             }
-            else
-            {
-                ParseAMRFile();
-            }
         }
-        else
-        {
-            /* CPM doesnt care about amr files */
-            ParseAMRFile();
-        }
-
     }
-    else
-    {
-        /* CPM doesnt care about AMR files */
-        ParseAMRFile();
-    }
-
     SetState(EPVMFNodeInitialized);
     CommandComplete(iCurrentCommand,
                     iCurrentCommand.front(),
@@ -3323,8 +3364,7 @@
     ReleaseAllPorts();
     CleanupFileSource();
     SetState(EPVMFNodeIdle);
-    PVMFStatus status = ThreadLogoff();
-    CommandComplete(iCurrentCommand, iCurrentCommand.front(), status);
+    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
     return;
 }
 
@@ -3441,30 +3481,43 @@
 {
 
     // Create a data buffer from pool
-    int errcode = 0;
+    int errcode = OsclErrNoResources;
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
-    OSCL_TRY(errcode, mediaDataImplOut = aTrackInfoPtr->iResizableSimpleMediaMsgAlloc->allocate(MAXTRACKDATASIZE));
+    mediaDataImplOut = aTrackInfoPtr->iResizableSimpleMediaMsgAlloc->allocate(MAXTRACKDATASIZE);
+
+    if (mediaDataImplOut.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
 
     OsclMemPoolResizableAllocatorObserver* resizableAllocObs =
         OSCL_STATIC_CAST(OsclMemPoolResizableAllocatorObserver*, aTrackInfoPtr);
 
     // Enable flag to receive event when next deallocate() is called on pool
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackInfoPtr->iResizableDataMemoryPool->notifyfreeblockavailable(*resizableAllocObs);
-                         return PVMFErrBusy;);
+    if (errcode != OsclErrNone)
+    {
+        aTrackInfoPtr->iResizableDataMemoryPool->notifyfreeblockavailable(*resizableAllocObs);
+        return PVMFErrBusy;
+    }
 
     // Now create a PVMF media data from pool
-    errcode = 0;
-    OSCL_TRY(errcode,
-             aMediaDataOut = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackInfoPtr->iMediaDataMemPool));
+    errcode = OsclErrNoResources;
+    aMediaDataOut = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackInfoPtr->iMediaDataMemPool);
+
+    if (aMediaDataOut.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
+
     OsclMemPoolFixedChunkAllocatorObserver* fixedChunkObs =
         OSCL_STATIC_CAST(OsclMemPoolFixedChunkAllocatorObserver*, aTrackInfoPtr);
 
     // Enable flag to receive event when next deallocate() is called on pool
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackInfoPtr->iMediaDataMemPool->notifyfreechunkavailable(*fixedChunkObs);
-
-                         return PVMFErrBusy);
+    if (errcode != OsclErrNone)
+    {
+        aTrackInfoPtr->iMediaDataMemPool->notifyfreechunkavailable(*fixedChunkObs);
+        return PVMFErrBusy;
+    }
 
 
     // Retrieve memory fragment to write to
@@ -3625,44 +3678,49 @@
     int errcode = 0;
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
     OSCL_TRY(errcode, mediaDataImplOut = aTrackPortInfo.iMediaDataImplAlloc->allocate(MAXTRACKDATASIZE));
+
     if (errcode != 0)
     {
         if (errcode == OsclErrNoResources)
         {
-            aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_MEDIADATAPOOLEMPTY;
-            aTrackPortInfo.iTrackDataMemoryPool->notifyfreechunkavailable(aTrackPortInfo);	// Enable flag to receive event when next deallocate() is called on pool
+            aTrackPortInfo.iTrackDataMemoryPool->notifyfreechunkavailable(aTrackPortInfo);  // Enable flag to receive event when next deallocate() is called on pool
             return false;
         }
         else if (errcode == OsclErrNoMemory)
         {
             // Memory allocation for the pool failed
-            aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ERROR;
             ReportErrorEvent(PVMFErrNoMemory, NULL);
             return false;
         }
         else if (errcode == OsclErrArgument)
         {
             // Invalid parameters passed to mempool
-            aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ERROR;
             ReportErrorEvent(PVMFErrArgument, NULL);
             return false;
         }
         else
         {
             // General error
-            aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ERROR;
             ReportErrorEvent(PVMFFailure, NULL);
             return false;
         }
+
     }
 
     // Now create a PVMF media data from pool
-    errcode = 0;
+    errcode = OsclErrNoResources;
     PVMFSharedMediaDataPtr mediadataout;
-    OSCL_TRY(errcode, mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool));
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(aTrackPortInfo);		// Enable flag to receive event when next deallocate() is called on pool
-                         return false);
+    mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool);
+
+    if (mediadataout.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
+    else
+    {
+        aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(aTrackPortInfo);     // Enable flag to receive event when next deallocate() is called on pool
+        return false;
+    }
 
     // Set the random access point flag if first frame
     if (aTrackPortInfo.iFirstFrame == true)
@@ -3727,7 +3785,6 @@
     else if (retval == bitstreamObject::READ_ERROR)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::RetrieveTrackData() AMR Parser READ_ERROR"));
-        aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ERROR;
         PVUuid erruuid = PVMFFileFormatEventTypesUUID;
         int32 errcode = PVMFFFErrFileRead;
         ReportErrorEvent(PVMFErrResource, NULL, &erruuid, &errcode);
@@ -3740,7 +3797,6 @@
         {
             // EOS message sent so change state
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFAMRFFParserNode::RetrieveTrackData() Sending EOS message succeeded"));
-            aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK;
             return false;
         }
         else
@@ -3753,7 +3809,6 @@
     else
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::RetrieveTrackData() AMR Parser Unknown Error!"));
-        aTrackPortInfo.iState = PVAMRFFNodeTrackPortInfo::TRACKSTATE_ERROR;
         PVUuid erruuid = PVMFFileFormatEventTypesUUID;
         int32 errcode = PVMFFFErrInvalidData;
         ReportErrorEvent(PVMFErrCorrupt, NULL, &erruuid, &errcode);
@@ -3782,6 +3837,7 @@
         return status;
     }
     aTrackPortInfoPtr->iSendBOS = false;
+    aTrackPortInfoPtr->oProcessOutgoingMessages = true;
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAMRFFParserNode::SendBeginOfMediaStreamCommand() BOS Sent StreamId %d ", iStreamID));
     return status;
 }
@@ -3939,3 +3995,19 @@
     /* if we get here the command isn't queued so the cancel fails */
     return status;
 }
+
+int32 PVMFAMRFFParserNode::PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, (*aValueListPtr).push_back(aKeyVal));
+    return leavecode;
+}
+
+PVMFStatus PVMFAMRFFParserNode::PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetaDataKeys, PVMFMetadataList *&aKeyListPtr, uint32 aLcv)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aKeyListPtr->push_back(aRefMetaDataKeys[aLcv]));
+    OSCL_FIRST_CATCH_ANY(leavecode, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAMRFFParserNode::PushValueToList() Memory allocation failure when copying metadata key"));return PVMFErrNoMemory);
+    return PVMFSuccess;
+}
+
diff --git a/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.h b/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.h
index 557b757..8d0834c 100644
--- a/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.h
+++ b/nodes/pvamrffparsernode/src/pvmf_amrffparser_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -102,7 +102,7 @@
 
 #define PVMF_AMR_PARSER_NODE_TEMPLATED_DELETE(auditCB, T, Tsimple, ptr)\
 {\
-	OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
+	OSCL_DELETE(ptr);\
 }
 
 #define PV_AMR_PARSER_NODE_ARRAY_NEW(auditCB, T, count, ptr)\
@@ -234,7 +234,7 @@
         }
 
         // Constructor and parser for SetDataSourceRate
-        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, OsclTimebase* aTimebase, const OsclAny*aContext)
+        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny*aContext)
         {
             PVMFAMRFFNodeCommandBase::Construct(s, cmd, aContext);
             iParam1 = (OsclAny*)aRate;
@@ -243,10 +243,10 @@
             iParam4 = NULL;
             iParam5 = NULL;
         }
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
         {
             aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
+            aTimebase = (PVMFTimebase*)iParam2;
         }
 
         /* need to overlaod the base Destroy routine to cleanup metadata key. */
@@ -425,8 +425,8 @@
         bool queryInterface(const PVUuid& uuid, PVInterface *& iface);
         //From PVMFDataSourceInitializationExtensionInterface
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         //From PVMFTrackSelectionExtensionInterface
         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
@@ -466,7 +466,7 @@
 
         PVMFCommandId SetDataSourceRate(PVMFSessionId aSession
                                         , int32 aRate
-                                        , OsclTimebase* aTimebase = NULL
+                                        , PVMFTimebase* aTimebase = NULL
                                                                     , OsclAny* aContext = NULL);
 
         /* From PVMIDatastreamuserInterface */
@@ -539,7 +539,7 @@
 
         void MoveCmdToCurrentQueue(PVMFAMRFFNodeCommand& aCmd);
         void MoveCmdToCancelQueue(PVMFAMRFFNodeCommand& aCmd);
-        void ProcessCommand();
+        bool ProcessCommand();
         void CommandComplete(PVMFAMRFFNodeCmdQ& aCmdQueue,
                              PVMFAMRFFNodeCommand& aCmd,
                              PVMFStatus aStatus,
@@ -605,7 +605,6 @@
 
         bool RetrieveTrackData(PVAMRFFNodeTrackPortInfo& aTrackPortInfo);
         PVMFStatus RetrieveTrackData(PVAMRFFNodeTrackPortInfo& aTrackPortInfo, PVMFSharedMediaDataPtr& aMediaDataOut);
-        bool SendTrackData(PVAMRFFNodeTrackPortInfo& aTrackPortInfo);
         bool SendEndOfTrackCommand(PVAMRFFNodeTrackPortInfo& aTrackPortInfo);
         PVMFStatus SendBeginOfMediaStreamCommand(PVAMRFFNodeTrackPortInfo* aTrackPortInfo);
         bool CheckAvailabilityForSendingNewTrackData(PVAMRFFNodeTrackPortInfo& aTrackPortInfo);
@@ -637,6 +636,10 @@
         PVMFStatus GenerateAndSendEOSCommand(PVAMRFFNodeTrackPortInfo* aTrackInfoPtr);
         bool CheckForPortRescheduling();
         bool CheckForPortActivityQueues();
+        int32 PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal);
+        PVMFStatus PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetadataKeys,
+                                   PVMFMetadataList *&aKeyListPtr,
+                                   uint32 aLcv);
 
         /* Progressive download related */
         PVMFStatus CheckForAMRHeaderAvailability();
@@ -689,6 +692,7 @@
         PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
         PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
         PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
+        PVInterface* iCPMLicenseInterfacePVI;
         PvmiKvp iRequestedUsage;
         PvmiKvp iApprovedUsage;
         PvmiKvp iAuthorizationDataKvp;
@@ -727,7 +731,6 @@
                                 bool aWideCharVersion = false);
         PVMFStatus DoCancelGetLicense(PVMFAMRFFNodeCommand& aCmd);
         void CompleteGetLicense();
-        void Assert(bool);
         PVMFStatus ParseAMRFile();
         uint32 iCountToClaculateRDATimeInterval;
 };
diff --git a/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.cpp b/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.cpp
index 4a730f7..155d34f 100644
--- a/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.cpp
+++ b/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,10 +25,6 @@
 {
     iAMRParserNode = OSCL_STATIC_CAST(PVMFAMRFFParserNode*, aNode);
     Construct();
-    /*	PvmiCapabilityAndConfig::Construct(
-    		PVMF_AMRFFPARSER_PORT_OUTPUT_FORMATS,
-    		PVMF_AMRFFPARSER_PORT_OUTPUT_FORMATS_VALTYPE);
-    		*/
 }
 void PVMFAMRFFParserOutPort::Construct()
 {
@@ -48,7 +44,12 @@
 
 bool PVMFAMRFFParserOutPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return (aFmt == PVMF_AMR_IETF || aFmt == PVMF_AMR_IF2 || PVMF_AMRWB_IETF == aFmt);
+    bool formatSupported = false;
+    if (aFmt == PVMF_MIME_AMR_IETF || aFmt == PVMF_MIME_AMR_IF2 || aFmt == PVMF_MIME_AMRWB_IETF)
+    {
+        formatSupported = true;
+    }
+    return formatSupported;
 }
 
 void PVMFAMRFFParserOutPort::FormatUpdated()
@@ -73,10 +74,9 @@
         return PVMFFailure;
     }
 
-    PvmiCapabilityAndConfig *config;
-
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                          (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
     if (config != NULL)
     {
diff --git a/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.h b/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.h
index bffbc93..8dfdbfb 100644
--- a/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.h
+++ b/nodes/pvamrffparsernode/src/pvmf_amrffparser_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,8 +53,8 @@
 #include "oscl_bin_stream.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #ifndef OSCL_TIMER_H_INCLUDED
@@ -138,32 +138,19 @@
             public OsclMemPoolResizableAllocatorObserver
 {
     public:
-        enum TrackState
-        {
-            TRACKSTATE_UNINITIALIZED,
-            TRACKSTATE_INITIALIZED,
-            TRACKSTATE_TRANSMITTING_GETDATA,
-            TRACKSTATE_TRANSMITTING_SENDDATA,
-            TRACKSTATE_MEDIADATAPOOLEMPTY,
-            TRACKSTATE_DESTFULL,
-            TRACKSTATE_SOURCEEMPTY,
-            TRACKSTATE_ENDOFTRACK,
-            TRACKSTATE_ERROR
-        };
 
         PVAMRFFNodeTrackPortInfo()
         {
             iTrackId = -1;
             iPort = NULL;
             iClockConverter = NULL;
-            iState = TRACKSTATE_UNINITIALIZED;
             iTrackDataMemoryPool = NULL;
             iMediaDataImplAlloc = NULL;
             iMediaDataMemPool = NULL;
             iNode = NULL;
             iSeqNum = 0;
             iTimestampOffset = 0;
-            iFormatType                   = PVMF_FORMAT_UNKNOWN;
+            iFormatType                   = PVMF_MIME_FORMAT_UNKNOWN;
 
             iResizableDataMemoryPool      = NULL;
             iResizableSimpleMediaMsgAlloc = NULL;
@@ -211,7 +198,6 @@
             iTag = aSrc.iTag;
             iClockConverter = aSrc.iClockConverter;
             iMediaData = aSrc.iMediaData;
-            iState = aSrc.iState;
             iTrackDataMemoryPool = aSrc.iTrackDataMemoryPool;
             iMediaDataImplAlloc = aSrc.iMediaDataImplAlloc;
             iMediaDataMemPool = aSrc.iMediaDataMemPool;
@@ -355,8 +341,6 @@
         OSCL_wHeapString<OsclMemAllocator> iCodecName;
         OSCL_wHeapString<OsclMemAllocator> iCodecDescription;
 
-        // Current state of this track
-        TrackState iState;
         // Output buffer memory pool
         OsclMemPoolFixedChunkAllocator *iTrackDataMemoryPool;
         // Allocator for simple media data buffer impl
diff --git a/nodes/pvavcencnode/Android.mk b/nodes/pvavcencnode/Android.mk
deleted file mode 100644
index cae5488..0000000
--- a/nodes/pvavcencnode/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/pvmf_avcenc_node.cpp \
-	src/pvmf_avcenc_port.cpp \
-	src/pvmf_avcenc_node_cap_config.cpp
-
-
-
-LOCAL_MODULE := libpvavcencnode
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvavcencnode/include \
-	$(PV_TOP)//nodes/pvavcencnode/src \
-	$(PV_TOP)/$(SDK_LOCAL)/installed_include \
-	$(PV_TOP)//nodes/pvavcencnode/src \
-	$(PV_TOP)//nodes/pvavcencnode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvavcencnode/include \
-	$(PV_TOP)//nodes/pvavcencnode/../../baselibs/pv_mime_utils/src \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/pvmf_avcenc_node_factory.h \
-	include/pvmf_avcenc_node_types.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvavcencnode/build/make/makefile b/nodes/pvavcencnode/build/make/makefile
deleted file mode 100644
index 0b3112a..0000000
--- a/nodes/pvavcencnode/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvavcencnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I$(SDK_LOCAL)/installed_include -I../../src -I../../../../pvmi/pvmf/include -I ../../include -I ../../../../baselibs/pv_mime_utils/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =  pvmf_avcenc_node.cpp \
-	pvmf_avcenc_port.cpp \
-	pvmf_avcenc_node_cap_config.cpp
-
-
-HDRS =  pvmf_avcenc_node_factory.h \
-	pvmf_avcenc_node_types.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvavcencnode/include/pvmf_avcenc_node_factory.h b/nodes/pvavcencnode/include/pvmf_avcenc_node_factory.h
deleted file mode 100644
index 67dace4..0000000
--- a/nodes/pvavcencnode/include/pvmf_avcenc_node_factory.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMFAVCENCNODE_FACTORY_H_INCLUDED
-#define PVMFAVCENCNODE_FACTORY_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-// Forward declarations
-class PVMFNodeInterface;
-
-/** Uuid of PV Video Encoder Node */
-#define PVMFAvcEncNodeUuid PVUuid(0xfd18217e,0xbac6,0x4012,0x86,0x41,0xd1,0xf1,0xa4,0x8f,0xb4,0xb5)
-
-/**
- * Factory class for PVMFAvcEncNode
- */
-class PVMFAvcEncNodeFactory
-{
-    public:
-        /**
-         * Creates an instance of a PV video encoder node. If the creation fails, this function will leave.
-         *
-         * @param aPriority The active object priority for the node. Default is standard priority if not specified
-         * @returns A pointer to an author or leaves if instantiation fails
-         **/
-        OSCL_IMPORT_REF static PVMFNodeInterface* CreateAvcEncNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        /**
-         * This function allows the application to delete an instance of file input node
-         * and reclaim all allocated resources.  An instance can be deleted only in
-         * the idle state. An attempt to delete in any other state will fail and return false.
-         *
-         * @param aNode The file input node to be deleted.
-         * @returns A status code indicating success or failure.
-         **/
-        OSCL_IMPORT_REF static bool DeleteAvcEncNode(PVMFNodeInterface* aNode);
-};
-
-#endif // PVMFAVCENCNODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvavcencnode/include/pvmf_avcenc_node_types.h b/nodes/pvavcencnode/include/pvmf_avcenc_node_types.h
deleted file mode 100644
index 153d8f5..0000000
--- a/nodes/pvavcencnode/include/pvmf_avcenc_node_types.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMF_AVCENC_NODE_TYPES_H_INCLUDED
-#define PVMF_AVCENC_NODE_TYPES_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-///////////////////////////////////////////////
-// Port tags
-///////////////////////////////////////////////
-
-/** Enumerated list of port tags supported by the node for the port requests.*/
-typedef enum
-{
-    PVMF_AVCENC_NODE_PORT_TYPE_INPUT = 0,
-    PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT
-} PVMFAvcEncNodePortType;
-
-///////////////////////////////////////////////
-// Error Events
-///////////////////////////////////////////////
-
-enum PVMFAvcEncNodeErrorEvent
-{
-    PVMF_AVCENC_NODE_ERROR_ENCODE_ERROR = PVMF_NODE_ERROR_EVENT_LAST
-};
-
-///////////////////////////////////////////////
-// Information Events
-///////////////////////////////////////////////
-
-// Enumerated list of informational event from PVMFAvcEncNode
-enum PVMFAvcEncNodeInfoEvent
-{
-    PVMF_AVCENC_NODE_INFO = PVMF_NODE_INFO_EVENT_LAST
-};
-
-
-#endif // PVMF_AVCENC_NODE_TYPES_H_INCLUDED
diff --git a/nodes/pvavcencnode/src/pvmf_avcenc_node.cpp b/nodes/pvavcencnode/src/pvmf_avcenc_node.cpp
deleted file mode 100644
index c3eeb45..0000000
--- a/nodes/pvavcencnode/src/pvmf_avcenc_node.cpp
+++ /dev/null
@@ -1,2105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#include "oscl_dll.h"
-#include "oscl_error_codes.h"
-#include "pvmf_avcenc_port.h"
-#include "pvmf_avcenc_node_factory.h"
-#include "pvmf_avcenc_node_types.h"
-#include "pvmf_avcenc_node.h"
-#include "pvavcencoderinterface.h"
-#include "pvavcencoder_factory.h"
-
-#ifndef PVMF_MEDIA_MSG_FORMAT_IDS_H_INCLUDED
-#include "pvmf_media_msg_format_ids.h"
-#endif
-#ifndef PVMF_MEDIA_CMD_H_INCLUDED
-#include "pvmf_media_cmd.h"
-#endif
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-// DLL entry point
-OSCL_DLL_ENTRY_POINT_DEFAULT()
-
-const uint32 DEFAULT_PARAMS_SET_LENGTH = 256; // should cover the output from avcencoder
-const uint32 DEFAULT_PACKET_SIZE = 256;
-
-////////////////////////////////////////////////////////////////////////////
-//              PVMFAvcEncNodeFactory implementation
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFNodeInterface* PVMFAvcEncNodeFactory::CreateAvcEncNode(int32 aPriority)
-{
-    int32 err = 0;
-    PVMFAvcEncNode* node = NULL;
-
-    OSCL_TRY(err,
-             node = OSCL_NEW(PVMFAvcEncNode, (aPriority));
-             if (!node)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err, return NULL;);
-
-    return (PVMFNodeInterface*)node;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNodeFactory::DeleteAvcEncNode(PVMFNodeInterface* aNode)
-{
-    if (!aNode)
-        return false;
-
-    PVMFAvcEncNode* node = (PVMFAvcEncNode*)aNode;
-    OSCL_DELETE(node);
-    aNode = NULL;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//              PVMFAvcEncNode implementation
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncNode::PVMFAvcEncNode(int32 aPriority) :
-        OsclTimerObject(aPriority, "PVMFAvcEncNode"),
-//	iMediaBufferMemPool(PVAVCENC_MEDIADATA_POOLNUM, PVAVCENC_MEDIABUFFER_CHUNKSIZE),
-        iMediaDataMemPool(PVAVCENC_MEDIADATA_POOLNUM, PVAVCENC_MEDIADATA_CHUNKSIZE),
-        iCodec(PVMF_H264_RAW),
-        iAvcEncoder(NULL),
-        iSeqNum(0),
-        iReadyForNextFrame(false),
-        iNumSPSs(0),
-        iNumPPSs(0),
-        iExtensionRefCount(0)
-{
-
-#if PROFILING_ON
-    iMinEncDuration = 0;
-    iMaxEncDuration = 0;
-    iAverageEncDuration = 0;
-    iTotalFramesEncoded = 0;
-    iTotalEncTime = 0;
-    iNumFramesSkipped = 0;
-    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvauthordiagnostics.encoder.avc");
-    oDiagnosticsLogged = false;
-
-#endif
-
-    iInterfaceState = EPVMFNodeCreated;
-
-    // Allocate memory for parameters set
-    uint refCounterSize = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-    uint size = refCounterSize + DEFAULT_PARAMS_SET_LENGTH;
-    uint8 *memBuffer = NULL;
-
-    int32 err;
-    OSCL_TRY(err,
-             //Create the input command queue
-             iCmdQueue.Construct(PVMF_AVCENC_NODE_CMD_ID_START, PVMF_AVCENC_NODE_CMD_QUEUE_RESERVE);
-             iCurrentCmd.Construct(0, 1); // There's only 1 current command
-
-             //Create the port vector.
-             iInPort.Construct(PVMF_AVCENC_NODE_PORT_VECTOR_RESERVE);
-             iOutPort.Construct(PVMF_AVCENC_NODE_PORT_VECTOR_RESERVE);
-
-             // Reserve space for port activity queue
-             iPortActivityQueue.reserve(PVMF_AVCENC_NODE_PORT_ACTIVITY_RESERVE);
-
-             // Create media data allocator
-             iMediaBufferMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVAVCENC_MEDIADATA_POOLNUM));
-             if (!iMediaBufferMemPool)
-             OSCL_LEAVE(OsclErrNoMemory);
-
-             iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iMediaBufferMemPool));
-             if (!iMediaDataAlloc)
-                 OSCL_LEAVE(OsclErrNoMemory);
-
-                 // The first allocate call will set the chunk size of the memory pool. Use the max
-                 // frame size calculated earlier to set the chunk size.  The allocated data will be
-                 // deallocated automatically as tmpPtr goes out of scope.
-                 OsclSharedPtr<PVMFMediaDataImpl> tmpPtr = iMediaDataAlloc->allocate(MAX_OUTBUF_SIZE);
-
-                 iMediaDataGroupImplMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVAVCENC_MEDIADATA_POOLNUM));
-                 if (!iMediaDataGroupImplMemPool)
-                     OSCL_LEAVE(OsclErrNoMemory);
-
-                     iMediaDataGroupAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemPoolFixedChunkAllocator>,
-                                                     (10, 2048, iMediaDataGroupImplMemPool));
-                     if (!iMediaDataGroupAlloc)
-            {
-                OSCL_LEAVE(OsclErrNoMemory);
-                }
-                else
-                {
-                    iMediaDataGroupAlloc->create();
-                }
-
-    // original from m4venc
-    memBuffer = (uint8*)iAlloc.allocate(size);
-    if (!memBuffer)
-{
-    OSCL_LEAVE(PVMFErrNoMemory);
-    }
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         // If a leave happened, cleanup and re-throw the error
-                         iCmdQueue.clear();
-                         iInPort.clear();
-                         iOutPort.clear();
-                         OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
-                         OSCL_CLEANUP_BASE_CLASS(OsclTimerObject);
-                         OSCL_LEAVE(err);
-                        );
-
-    // Save default VOL header
-
-    oscl_memset(memBuffer, 0, DEFAULT_PARAMS_SET_LENGTH);
-    OsclMemoryFragment paramSet;
-    OsclRefCounter* refCounter = new(memBuffer) OsclRefCounterDA(memBuffer,
-            (OsclDestructDealloc*)&iAlloc);
-    memBuffer += refCounterSize;
-    paramSet.ptr = memBuffer;
-//	oscl_memcpy(volHeader.ptr, (OsclAny*)DEFAULT_VOL_HEADER, DEFAULT_VOL_HEADER_LENGTH); no default param set
-    paramSet.len = DEFAULT_PARAMS_SET_LENGTH;
-    iParamSet = OsclRefCounterMemFrag(paramSet, refCounter, DEFAULT_PARAMS_SET_LENGTH);
-
-    ConstructEncoderParams();
-
-#if PROFILING_ON
-    oscl_memset(&iStats, 0, sizeof(PVAvcEncNodeStats));
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncNode::~PVMFAvcEncNode()
-{
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-
-    if (iMediaDataGroupAlloc)
-    {
-        iMediaDataGroupAlloc->removeRef();
-    }
-
-    if (iMediaDataGroupImplMemPool)
-    {
-        OSCL_DELETE(iMediaDataGroupImplMemPool);
-        iMediaDataGroupImplMemPool = 0;
-    }
-
-    if (iMediaDataAlloc)
-    {
-        OSCL_DELETE(iMediaDataAlloc);
-        iMediaDataAlloc = NULL;
-    }
-
-    if (iMediaBufferMemPool)
-    {
-        OSCL_DELETE(iMediaBufferMemPool);
-        iMediaBufferMemPool = 0;
-    }
-
-    DeleteAvcEncoder();
-
-    while (!iInPort.empty())		iInPort.Erase(&iInPort.front());
-    while (!iOutPort.empty())	iOutPort.Erase(&iOutPort.front());
-
-    Cancel();
-    SetState(EPVMFNodeIdle);
-    ThreadLogoff();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncNode::ThreadLogon()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeCreated:
-            if (!IsAdded())
-                AddToScheduler();
-            iLogger = PVLogger::GetLoggerObject("PVMFAvcEncNode");
-            SetState(EPVMFNodeIdle);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncNode::ThreadLogoff()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            if (IsAdded())
-                RemoveFromScheduler();
-            iLogger = NULL;
-            SetState(EPVMFNodeCreated);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncNode::GetCapability(PVMFNodeCapability& aNodeCapability)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::GetCapability"));
-
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_YUV420);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_H264_RAW);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_H264_MP4);
-    // not supported yet NodeCapability.iOutputFormatCapability.push_back(PVMF_H264);
-    aNodeCapability.iCanSupportMultipleOutputPorts = false;
-    aNodeCapability.iCanSupportMultipleInputPorts = false;
-    aNodeCapability.iHasMaxNumberOfPorts = true;
-    aNodeCapability.iMaxNumberOfPorts = 2;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFPortIter* PVMFAvcEncNode::GetPorts(const PVMFPortFilter* aFilter)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::GetPorts"));
-    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
-
-    int32 err = 0;
-    PVMFAvcEncPortVector* port = NULL;
-    OSCL_TRY(err,
-             port = OSCL_NEW(PVMFAvcEncPortVector, ());
-             if (!port)
-             return NULL;
-
-             int32 i;
-             for (i = 0; i < (int)iInPort.size(); i++)
-                 port->AddL(iInPort[i]);
-                 for (i = 0; i < (int) iOutPort.size(); i++)
-                     port->AddL(iOutPort[i]);
-                     port->Reset();
-                    );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFAvcEncNode::GetPorts: Error - Out of memory"));
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::QueryUUID(PVMFSessionId aSession,
-        const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-        bool aExactUuidsOnly,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::QueryUUID"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYUUID,
-                  aMimeType, aUuids, aExactUuidsOnly, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::QueryInterface(PVMFSessionId aSession,
-        const PVUuid& aUuid,
-        PVInterface*& aInterfacePtr,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::QueryInterface"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYINTERFACE,
-                  aUuid, aInterfacePtr, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::RequestPort(PVMFSessionId aSession,
-        int32 aPortTag,
-        const PvmfMimeString* aPortConfig,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::RequestPort: aPortTag=%d", aPortTag));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_REQUESTPORT,
-                  aPortTag, aPortConfig, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::ReleasePort(PVMFSessionId aSession,
-        PVMFPortInterface& aPort,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::ReleasePort"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Init(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Init"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_INIT, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Prepare(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Prepare"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PREPARE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Start(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Start"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_START, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Stop(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Stop"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_STOP, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Flush(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Flush"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_FLUSH, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Pause(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Pause"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PAUSE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::Reset(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Reset"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RESET, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::CancelAllCommands"));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncNode::CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::CancelCommand: aCmdId=%d", aCmdId));
-    PVMFAvcEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::HandlePortActivity(const PVMFPortActivity &aActivity)
-{
-    // Only outgoing queue ready activity are forwarded on to the node
-    // by the output port.  The rest of the events for output port and all events
-    // for input port are handled within the port AO.
-    if (aActivity.iPort->GetPortTag() == PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aActivity.iType)
-        {
-            case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-                // Notifies the node that the output queue is ready, and the node would
-                // resume encoding incoming data
-                uint32 i;
-                for (i = 0; i < iInPort.size(); i++)
-                    ((PVMFAvcEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                break;
-
-            default:
-                break;
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncNode::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncNode::removeRef()
-{
-    if (iExtensionRefCount > 0)
-        --iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    if (uuid == PVMp4H263EncExtensionUUID)
-    {
-        PVMp4H263EncExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else if (uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-    {
-        PvmiCapabilityAndConfig* myInterface = 	OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else
-    {
-        iface = NULL;
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetNumLayers(uint32 aNumLayers)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetNumLayers: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if (aNumLayers > MAX_AVC_LAYER) // MAX_AVC_LAYER defined in pvmf_avcenc_tunables.h
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::SetNumLayers: Error Max num layers is %d", MAX_AVC_LAYER));
-        return false;
-    }
-
-    iEncodeParam.iNumLayer = aNumLayers;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetOutputBitRate(uint32 aLayer, uint32 aBitRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetOutputBitRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::SetOutputBitRate: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iBitRate[aLayer] = aBitRate;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetOutputFrameSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::SetOutputFrameSize: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iFrameWidth[aLayer] = aWidth;
-    iEncodeParam.iFrameHeight[aLayer] = aHeight;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetOutputFrameRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::SetOutputFrameRate: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iFrameRate[aLayer] = OSCL_STATIC_CAST(float, aFrameRate);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes)
-{
-    OSCL_UNUSED_ARG(aLayer);
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetSegmentTargetSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    iEncodeParam.iPacketSize = aSizeBytes;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl)
-{
-    OSCL_UNUSED_ARG(aLayer);
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetRateControlType: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    switch (aRateControl)
-    {
-        case PVMFVEN_RATE_CONTROL_CONSTANT_Q:
-            iEncodeParam.iRateControlType = EAVCEI_RC_CONSTANT_Q;
-            break;
-        case PVMFVEN_RATE_CONTROL_CBR:
-            iEncodeParam.iRateControlType = EAVCEI_RC_CBR_1;
-            break;
-        case PVMFVEN_RATE_CONTROL_VBR:
-            iEncodeParam.iRateControlType = EAVCEI_RC_VBR_1;
-            break;
-        default:
-            return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetDataPartitioning(bool aDataPartitioning)
-{
-    OSCL_UNUSED_ARG(aDataPartitioning);
-
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::SetDataPartitioning, do nothing"));
-
-    return true; // do nothing for now.
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetIFrameInterval(uint32 aIFrameInterval)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetIFrameInterval: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    iEncodeParam.iIFrameInterval = aIFrameInterval;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetRVLC(bool aRVLC)
-{
-    OSCL_UNUSED_ARG(aRVLC);
-
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::SetRVLC do nothing"));
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::GetVolHeader(OsclRefCounterMemFrag& aVolHeader)
-{
-    OSCL_UNUSED_ARG(aVolHeader);
-    // this function is utility. It returns vol header to whomever using it.
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::GetVolHeader not supported"));
-
-    return false; // just return false for now
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::RequestIFrame()
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::RequestIFrame"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            break;
-        default:
-            LOG_ERR((0, "PVMFAvcEncNode::RequestIFrame: Error - Wrong state"));
-            return false;
-    }
-
-    if (!iAvcEncoder || iAvcEncoder->IDRRequest() == EAVCEI_FAIL)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::RequestIFrame: Error - IFrameRequest failed"));
-        return false;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFAvcEncNode::SetCodec(PVMFFormatType aCodec)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::SetCodec %d", aCodec));
-
-    if (SetCodecType(aCodec) == PVMFSuccess)
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                        Private methods
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::ConstructEncoderParams()
-{
-    iInputFormat.iVideoFormat = EAVCEI_VDOFMT_YUV420;
-    iInputFormat.iFrameWidth = DEFAULT_FRAME_WIDTH;
-    iInputFormat.iFrameHeight = DEFAULT_FRAME_HEIGHT;
-    iInputFormat.iFrameRate = (float)DEFAULT_FRAME_RATE;
-
-    oscl_memset(&iEncodeParam, 0, sizeof(TAVCEIEncodeParam));
-    iEncodeParam.iEncodeID = 0;
-    iEncodeParam.iNumLayer = 1;
-    iEncodeParam.iFrameWidth[0] = DEFAULT_FRAME_WIDTH;
-    iEncodeParam.iFrameHeight[0] = DEFAULT_FRAME_HEIGHT;
-    iEncodeParam.iBitRate[0] = DEFAULT_BITRATE;
-    iEncodeParam.iFrameRate[0] = (float)DEFAULT_FRAME_RATE;
-    iEncodeParam.iIFrameInterval = 10;
-    iEncodeParam.iBufferDelay = (float)5.0;
-    iEncodeParam.iEncMode = EAVCEI_ENCMODE_RECORDER;
-    iEncodeParam.iRateControlType = EAVCEI_RC_CBR_1;
-    iEncodeParam.iIquant[0] = 0; // to enable automatic init QP selection
-    iEncodeParam.iPquant[0] = 35; // doesn't matter
-    iEncodeParam.iBquant[0] = 35; // doesn't matter
-    iEncodeParam.iPacketSize = DEFAULT_PACKET_SIZE;
-    iEncodeParam.iProfile = EAVCEI_PROFILE_BASELINE;
-    iEncodeParam.iLevel = EAVCEI_LEVEL_11;
-    iEncodeParam.iOutOfBandParamSet = true;
-}
-
-void PVMFAvcEncNode::freechunkavailable(OsclAny* aContextData)
-{
-    OSCL_UNUSED_ARG(aContextData);
-
-    iWaitingOnFreeChunk = false;
-    RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::Run()
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Run"));
-
-    if (!iCmdQueue.empty())
-    {
-        if (ProcessCommand(iCmdQueue.front()))
-        {
-            // Need to check the state before re-scheduling since the node could have
-            // been reset in the ProcessCommand call
-            if (iInterfaceState != EPVMFNodeCreated)
-                RunIfNotReady();
-        }
-    }
-
-
-    if (iInterfaceState == EPVMFNodeStarted && iReadyForNextFrame == false)
-    {
-        /* there are bitstreams to be retrieved. */
-        PVMFAvcEncNodeOutputData outputData;
-        PVMFStatus status = outputData.Allocate(iMediaDataAlloc, &iMediaDataMemPool, iMediaDataGroupAlloc);
-        if (status != PVMFSuccess)
-        {
-            LOG_DEBUG((0, "PVMFAvcEncNode::Run: Error - outputData.Allocate failed"));
-            //register to receive notice when memory is available.
-            iMediaBufferMemPool->notifyfreechunkavailable(*this);
-            iWaitingOnFreeChunk = true;
-
-            return ;
-        }
-
-        int32 max_length = outputData.iEncoderOutput.iBitstreamSize;
-        int32 length = 0;
-        uint8* firstPtr = outputData.iEncoderOutput.iBitstream;
-
-        while (1)
-        {
-            OsclRefCounterMemFrag memFragOut(outputData.iRefCtrMemFragOut);
-
-            /* need to add some code to separate between NALs of the same frame */
-            if (iCodec == PVMF_H264_RAW)
-            {
-                outputData.iEncoderOutput.iBitstream[0] = 0;
-                outputData.iEncoderOutput.iBitstream[1] = 0;
-                outputData.iEncoderOutput.iBitstream[2] = 0;
-                outputData.iEncoderOutput.iBitstream[3] = 1;
-                outputData.iEncoderOutput.iBitstream += 4;
-                outputData.iEncoderOutput.iBitstreamSize -= 4;
-                length += 4;
-            }
-
-            TAVCEI_RETVAL avcStatus = iAvcEncoder->GetOutput(&(outputData.iEncoderOutput));
-
-            if (avcStatus == EAVCEI_FAIL || avcStatus == EAVCEI_INPUT_ERROR)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::Run: Error iAvcEncoder->GetOutput failed"));
-                return ;
-            }
-            else
-            {
-                if (iCodec == PVMF_H264_RAW)
-                {
-                    outputData.iEncoderOutput.iBitstream -= 4;
-                    outputData.iEncoderOutput.iBitstreamSize += 4;
-                }
-
-                memFragOut.getMemFrag().ptr = (OsclAny*)outputData.iEncoderOutput.iBitstream;
-                memFragOut.getMemFrag().len = outputData.iEncoderOutput.iBitstreamSize;
-                outputData.iFragGroupmediaDataImpl->appendMediaFragment(memFragOut);
-
-                outputData.iEncoderOutput.iBitstream += outputData.iEncoderOutput.iBitstreamSize;
-                length += outputData.iEncoderOutput.iBitstreamSize;
-                outputData.iEncoderOutput.iBitstreamSize = max_length - length;
-                if (avcStatus == EAVCEI_SUCCESS) // we get the whole frame
-                {
-                    break;
-                }
-            }
-        }
-
-#if PROFILING_ON
-        ++iStats.iNumFrames;
-        iStats.iDuration = outputData.iEncoderOutput.iTimeStamp;
-#endif
-        outputData.iEncoderOutput.iBitstreamSize = length;
-        outputData.iEncoderOutput.iBitstream = firstPtr;
-
-        iReadyForNextFrame = true;
-
-        // KL added, make sure port is activated after done with current frame.
-        uint32 i;
-        for (i = 0; i < iInPort.size(); i++)
-            ((PVMFAvcEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-
-        status = SendEncodedBitstream(outputData);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncNode::Run: Error - SendEncodeBitstream fail"));
-            return ;
-        }
-
-    }
-
-
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::Run: Out"));
-}
-
-/////////////////////////////////////////////////////
-//     Command processing routines
-/////////////////////////////////////////////////////
-PVMFCommandId PVMFAvcEncNode::QueueCommandL(PVMFAvcEncNodeCommand& aCmd)
-{
-    if (iInterfaceState == EPVMFNodeCreated)
-    {
-        OSCL_LEAVE(OsclErrNotReady);
-        // return 0;	This statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVMFCommandId id = iCmdQueue.AddL(aCmd);
-    RunIfNotReady();
-    return id;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFAvcEncNode::ProcessCommand(PVMFAvcEncNodeCommand& aCmd)
-{
-    // If a command is active, only high priority commands can interrupt
-    // the processing
-    if (!iCurrentCmd.empty() && !aCmd.hipri())
-        return false;
-
-    switch (aCmd.iCmd)
-    {
-        case PVMF_GENERIC_NODE_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELCOMMAND:
-            DoCancelCommand(aCmd);
-            break;
-
-        default://unknown command type
-            LOG_ERR((0, "PVMFAvcEncNode::ProcessCommand: Error - Unknown command type %d", aCmd.iCmd));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            break;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::CommandComplete(PVMFAvcEncNodeCmdQueue& aCmdQueue, PVMFAvcEncNodeCommand& aCmd,
-                                     PVMFStatus aStatus, OsclAny* aData)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::CommandComplete: Id=%d, Type=%d, Status=%d, Context=0x%x, Data0x%x"
-                     , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aData));
-
-    //create response
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aData);
-    PVMFSessionId session = aCmd.iSession;
-
-    //Erase the command from the queue.
-    aCmdQueue.Erase(&aCmd);
-
-    //Report completion to the session observer.
-    ReportCmdCompleteEvent(session, resp);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoQueryUuid(PVMFAvcEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::DoQueryUuid"));
-    OSCL_String* mimetype;
-    Oscl_Vector<PVUuid, OsclMemAllocator>* uuidvec;
-    bool exactMatch;
-    aCmd.Parse(mimetype, uuidvec, exactMatch);
-
-    int32 err = 0;
-    PVMFStatus status = PVMFSuccess;
-    OSCL_TRY(err, uuidvec->push_back(PVMp4H263EncExtensionUUID););
-    OSCL_FIRST_CATCH_ANY(err, status = PVMFErrNoMemory;);
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoQueryInterface(PVMFAvcEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::DoQueryInterface"));
-    PVUuid* uuid;
-    PVInterface** ptr;
-    aCmd.Parse(uuid, ptr);
-
-    PVMFStatus status = PVMFSuccess;
-    if (!queryInterface(*uuid, *ptr))
-        status = PVMFFailure;
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoRequestPort(PVMFAvcEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::DoRequestPort"));
-    int32 tag;
-    OSCL_String* mimetype;
-    PVMFAvcEncPort* port = NULL;
-    aCmd.Parse(tag, mimetype);
-
-    switch (tag)
-    {
-        case PVMF_AVCENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (iInPort.size() >= PVMF_AVCENC_NODE_MAX_INPUT_PORT)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::DoRequestPort: Error - Max number of input port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVAvcEncIn";
-
-            port = AllocatePort(iInPort, tag, mimetype, portname.get_cstr());
-
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        break;
-
-        case PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT:
-        {
-            if (iOutPort.size() >= PVMF_AVCENC_NODE_MAX_OUTPUT_PORT)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::DoRequestPort: Error - Max number of output port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVAvcEncOut";
-
-            port = AllocatePort(iOutPort, tag, mimetype, portname.get_cstr());
-
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        break;
-
-        default:
-            LOG_ERR((0, "PVMFAvcEncNode::DoRequestPort: Error - Invalid port tag"));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            return;
-    }
-
-    //Return the port pointer to the caller.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess, (OsclAny*)port);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncPort* PVMFAvcEncNode::AllocatePort(PVMFAvcEncPortVector& aPortVector, int32 aTag,
-        OSCL_String* aMimeType, const char* aName)
-{
-    int32 err = 0;
-    OsclAny* ptr = NULL;
-
-    // Allocate a new port
-    OSCL_TRY(err,
-             ptr = aPortVector.Allocate();
-             if (!ptr)
-             OSCL_LEAVE(PVMFErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFAvcEncNode::AllocatePort: Error - iPortVector Out of memory"));
-                         return NULL;
-                        );
-    PVMFAvcEncPort* port = new(ptr) PVMFAvcEncPort(aTag, this, Priority(), aName);
-
-    // if format was provided in mimestring, set it now.
-    if (aMimeType)
-    {
-        PVMFFormatType format = GetFormatIndex(aMimeType->get_str());
-        if ((port->SetFormat(format) != PVMFSuccess) ||
-                ((aTag == PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT) && (SetCodecType(format) != PVMFSuccess)))
-        {
-            aPortVector.DestructAndDealloc(port);
-            LOG_ERR((0, "PVMFAvcEncNode::AllocatePort: Error - port->SetFormat or SetCodecType failed"));
-            return NULL;
-        }
-    }
-
-    OSCL_TRY(err, aPortVector.AddL(port););
-    OSCL_FIRST_CATCH_ANY(err,
-                         aPortVector.DestructAndDealloc(port);
-                         return NULL;
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoReleasePort(PVMFAvcEncNodeCommand& aCmd)
-{
-    //Find the port in the port vector
-    PVMFAvcEncPort* port = NULL;
-    PVMFAvcEncPort** portPtr = NULL;
-    aCmd.Parse((PVMFPortInterface*&)port);
-
-    if (!port)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::DoReleasePort: Error - Invalid port pointer"));
-        CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-        return;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (port->GetPortTag())
-    {
-        case PVMF_AVCENC_NODE_PORT_TYPE_INPUT:
-            portPtr = iInPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iInPort.Erase(portPtr);
-            }
-            break;
-
-        case PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT:
-            portPtr = iOutPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iOutPort.Erase(portPtr);
-            }
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFAvcEncNode::DoReleasePort: Error - Invalid port tag"));
-            status = PVMFFailure;
-            break;
-    }
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoInit(PVMFAvcEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            SetState(EPVMFNodeInitialized);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeInitialized:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoPrepare(PVMFAvcEncNodeCommand& aCmd)
-{
-
-    LOG_STACK_TRACE((0, "PVMFVIdeoEncNode::DoPrepare"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-            /* moved from DoStart to here */
-            int32 leavecode;
-            int32 length, new_length;
-            uint8* start_ptr;
-            int nalType;
-
-            leavecode = 0;
-
-            OSCL_TRY(leavecode, iAvcEncoder = PVAVCEncoderFactory::CreatePVAVCEncoder());
-
-            if (iAvcEncoder->Initialize(&iInputFormat, &iEncodeParam) == EAVCEI_FAIL)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::DoPrepare: CommonAvcEncoder::Initialize failed"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-
-            if (iCodec == PVMF_H264_MP4) // if MP4 output, get the SPS and PPS up front.
-            {
-                iNumSPSs = iNumPPSs = 0; // reset here
-
-                start_ptr = (uint8*)iParamSet.getMemFragPtr();
-
-                oscl_memset(start_ptr, 0, DEFAULT_PARAMS_SET_LENGTH); // reset to zero
-
-                length = new_length = DEFAULT_PARAMS_SET_LENGTH;
-
-                while (1 || length < 0)
-                {
-
-                    TAVCEI_RETVAL avcStatus = iAvcEncoder->GetParameterSet(start_ptr, &new_length, &nalType);
-
-                    if (avcStatus == EAVCEI_FAIL)
-                    {
-                        break;
-                    }
-                    else if (avcStatus == EAVCEI_SUCCESS)
-                    {
-                        if (nalType == 7) // SPS
-                        {
-                            iSPSs[iNumSPSs].ptr = start_ptr;
-                            iSPSs[iNumSPSs++].len = new_length;
-                        }
-                        else //if(nalType == 8) // PPS
-                        {
-                            iPPSs[iNumPPSs].ptr = start_ptr;
-                            iPPSs[iNumPPSs++].len = new_length;
-                        }
-
-                        start_ptr += new_length;
-                        length -= new_length;
-                        new_length = length;
-                    }
-                    else
-                    {
-                        LOG_ERR((0, "PVMFAvcEncNode::DoPrepare: Error - PVAVCEncoder::GetParameterSet failed"));
-                        CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                        return;
-                    }
-                }
-                //iParamSet = OsclRefCounterMemFrag(paramSet, refCounter, DEFAULT_PARAMS_SET_LENGTH);
-
-                if (length < 0)
-                {
-                    LOG_ERR((0, "PVMFAvcEncNode::DoPrepare: Error - Not enough memory for parameter sets"));
-                    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                    return;
-                }
-
-                if (iOutPort[0])
-                {
-                    iOutPort[0]->SendSPS_PPS(iSPSs, iNumSPSs, iPPSs, iNumPPSs);
-                }
-                else
-                {
-                    LOG_ERR((0, "PVMFAvcEncNode::DoPrepare: Error - cannot find output port"));
-                    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                    return;
-                }
-            }
-
-            iReadyForNextFrame = true;
-            /************************/
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoStart(PVMFAvcEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::DoStart"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodePrepared:
-            SetState(EPVMFNodeStarted);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-
-        case EPVMFNodePaused:
-            SetState(EPVMFNodeStarted);
-
-            // Notify input port that the node is ready to process incoming msg again
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                ((PVMFAvcEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeStarted:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoStop(PVMFAvcEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::DoStop"));
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            // Clear queued messages in ports
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                iInPort[i]->ClearMsgQueues();
-            for (i = 0; i < iOutPort.size(); i++)
-                iOutPort[i]->ClearMsgQueues();
-
-            // Video encoder is created on Start, so in parallel it's deleted in Stop
-            DeleteAvcEncoder();
-
-            //transition to Prepared state
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DeleteAvcEncoder()
-{
-    if (iAvcEncoder)
-    {
-
-        iAvcEncoder->FlushInput(); /* signal input flush */
-        iAvcEncoder->CleanupEncoder();
-        delete iAvcEncoder;
-        iAvcEncoder = NULL;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoFlush(PVMFAvcEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            int32 err;
-            uint32 i;
-            bool msgPending;
-            msgPending = false;
-
-            for (i = 0; i < iInPort.size(); i++)
-            {
-                if (iInPort[i]->IncomingMsgQueueSize() > 0)
-                    msgPending = true;
-                iInPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessIncomingMsgReady
-                    // to wake up port AO
-                    ((PVMFAvcEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                }
-            }
-
-            for (i = 0; i < iOutPort.size(); i++)
-            {
-                if (iOutPort[i]->OutgoingMsgQueueSize() > 0)
-                    msgPending = true;
-                iOutPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessOutgoingMsgReady
-                    // to wake up port AO
-                    ((PVMFAvcEncPort*)iOutPort[i])->ProcessOutgoingMsgReady();
-                }
-            }
-
-            //the flush is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until the flush completes.
-            OSCL_TRY(err, iCurrentCmd.StoreL(aCmd););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                                 return;
-                                );
-            iCmdQueue.Erase(&aCmd);
-            if (!msgPending)
-            {
-                FlushComplete();
-                return;
-            }
-            break;
-
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFAvcEncNode::IsFlushPending()
-{
-    return (iCurrentCmd.size() > 0
-            && iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::FlushComplete()
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::FlushComplete"));
-    uint32 i = 0;
-
-    // Flush is complete only when all queues of all ports are clear.
-    // Other wise, just return from this method and wait for FlushComplete
-    // from the remaining ports.
-    for (i = 0; i < iInPort.size(); i++)
-    {
-        if (iInPort[i]->IncomingMsgQueueSize() > 0 ||
-                iInPort[i]->OutgoingMsgQueueSize() > 0)
-        {
-            return;
-        }
-    }
-
-    for (i = 0; i < iOutPort.size(); i++)
-    {
-        if (iOutPort[i]->IncomingMsgQueueSize() > 0 ||
-                iOutPort[i]->OutgoingMsgQueueSize() > 0)
-        {
-            return;
-        }
-    }
-
-    // Video encoder is created on Start, so in parallel it's deleted when Flush is completed
-    DeleteAvcEncoder();
-#if PROFILING_ON
-    LOG_DEBUG((0, "PVMFAvcEncNode Stats: NumFrames=%d, NumSkippedFrames=%d, Duration=%d",
-               iStats.iNumFrames, iStats.iNumFramesSkipped, iStats.iDuration));
-    oscl_memset(&iStats, 0, sizeof(PVAvcEncNodeStats));
-#endif
-
-    //resume port input so the ports can be re-started.
-    for (i = 0; i < iInPort.size(); i++)
-        iInPort[i]->ResumeInput();
-    for (i = 0; i < iOutPort.size(); i++)
-        iOutPort[i]->ResumeInput();
-
-    // Flush is complete.  Go to prepared state.
-    SetState(EPVMFNodePrepared);
-    CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-
-    if (!iCmdQueue.empty())
-    {
-        // If command queue is not empty, schedule to process the next command
-        RunIfNotReady();
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoPause(PVMFAvcEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-            SetState(EPVMFNodePaused);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePaused:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoReset(PVMFAvcEncNodeCommand& aCmd)
-{
-    //This example node allows a reset from any idle state.
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-
-    if (IsAdded())
-    {
-        while (!iInPort.empty())
-            iInPort.Erase(&iInPort.front());
-        while (!iOutPort.empty())
-            iOutPort.Erase(&iOutPort.front());
-
-        //restore original port vector reserve.
-        iInPort.Reconstruct();
-        iOutPort.Reconstruct();
-
-        //logoff & go back to Created state.
-        SetState(EPVMFNodeIdle);
-        PVMFStatus status = ThreadLogoff();
-
-        CommandComplete(iCmdQueue, aCmd, status);
-    }
-    else
-    {
-        OSCL_LEAVE(OsclErrInvalidState);
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoCancelAllCommands(PVMFAvcEncNodeCommand& aCmd)
-{
-    //first cancel the current command if any
-    {
-        while (!iCurrentCmd.empty())
-            CommandComplete(iCurrentCmd, iCurrentCmd[0], PVMFErrCancelled);
-    }
-
-    //next cancel all queued commands
-    {
-        //start at element 1 since this cancel command is element 0.
-        while (iCmdQueue.size() > 1)
-            CommandComplete(iCmdQueue, iCmdQueue[1], PVMFErrCancelled);
-    }
-
-    //finally, report cancel complete.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::DoCancelCommand(PVMFAvcEncNodeCommand& aCmd)
-{
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.Parse(id);
-
-    //first check "current" command if any
-    {
-        PVMFAvcEncNodeCommand* cmd = iCurrentCmd.FindById(id);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCurrentCmd, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PVMFAvcEncNodeCommand* cmd = iCmdQueue.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCmdQueue, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//               Port activity processing routines
-////////////////////////////////////////////////////////////////////////////
-bool PVMFAvcEncNode::IsProcessOutgoingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsConnectedPortBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFAvcEncNode::IsProcessIncomingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        if (!iReadyForNextFrame) // still encoding the current frame.
-        {
-            return false;
-        }
-
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsOutgoingQueueBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::ProcessIncomingMsg: aPort=0x%x", aPort));
-    PVMFStatus status = PVMFFailure;
-
-    switch (aPort->GetPortTag())
-    {
-        case PVMF_AVCENC_NODE_PORT_TYPE_INPUT:
-        {
-            PVMFSharedMediaMsgPtr msg;
-            status = aPort->DequeueIncomingMsg(msg);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PVMFAvcEncNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed"));
-                return status;
-            }
-
-            if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
-            {
-                status = SendEndOfTrackCommand(msg);
-                return status;
-            }
-            // Put the data on the data queue
-            PVMFSharedMediaDataPtr mediaData;
-            convertToPVMFMediaData(mediaData, msg);
-            status = AsyncEncode(mediaData); // set it to encode asynchronously
-            switch (status)
-            {
-                case PVMFSuccess:
-                    break;
-                    /*case PVMFErrBusy:  // this is treated as error.
-                    	LOG_DEBUG((0,"PVMFAvcEncNode::ProcessIncomingMsg: Outgoing queue busy. This should not happen."));
-                    	break;*/
-                default:
-                    ReportErrorEvent(PVMF_AVCENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)aPort);
-                    break;
-            }
-        }
-        break;
-
-        case PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT:
-            // Nothing to be done
-            status = PVMFSuccess;
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFAvcEncNode::ProcessIncomingMsg: Error - Invalid port tag"));
-            ReportErrorEvent(PVMF_AVCENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)aPort);
-            status = PVMFFailure;
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::AsyncEncode(PVMFSharedMediaDataPtr& aMediaData)
-{
-    TAVCEI_RETVAL status;
-
-    // Get the next data fragment
-    OsclRefCounterMemFrag frag;
-    aMediaData->getMediaFragment(0, frag);
-
-    TAVCEIInputData inputData;
-    inputData.iSource = (uint8*)frag.getMemFragPtr();
-    inputData.iTimeStamp = aMediaData->getTimestamp();
-
-    LOG_DEBUG((0, "PVMFAvcEncNode::SyncEncodeAndSend(): Encoding frame %d", inputData.iTimeStamp));
-
-#if PROFILING_ON
-    uint32 start = OsclTickCount::TickCount();
-#endif
-
-    status = iAvcEncoder->Encode(&inputData) ;
-#if PROFILING_ON
-
-    uint32 stop = OsclTickCount::TickCount();
-    uint32 enctime = OsclTickCount::TicksToMsec(stop - start);
-    if ((iMinEncDuration > enctime) || (0 == iMinEncDuration))
-    {
-        iMinEncDuration = enctime;
-    }
-
-    if (iMaxEncDuration < enctime)
-    {
-        iMaxEncDuration = enctime;
-    }
-
-    if (status == EAVCEI_SUCCESS)
-    {
-        ++iTotalFramesEncoded;
-    }
-
-    iTotalEncTime += enctime;
-
-#endif
-
-    if (status == EAVCEI_FRAME_DROP)
-    {
-
-#if	 PROFILING_ON
-        ++iStats.iNumFramesSkipped;
-        ++iNumFramesSkipped;
-#endif
-        LOG_DEBUG((0, "PVMFAvcEncNode::SyncEncodeAndSend(): Skipped frame"));
-
-        // KL added, make sure port is activated after the dropped frame
-        uint32 i = 0;
-        for (i = 0; i < iInPort.size(); i++)
-            ((PVMFAvcEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-
-        return PVMFSuccess; // do nothing, move on to the next frame
-    }
-    else if (status != EAVCEI_SUCCESS) // this should not happen
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::ASyncEncode(): Error - EncodeFrame failed"));
-        return PVMFFailure;
-    }
-
-    // else set Run to get output
-    iReadyForNextFrame = false;
-    RunIfNotReady();
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::SendEncodedBitstream(PVMFAvcEncNodeOutputData& aOutputData)
-{
-    PVMFStatus status = PVMFSuccess;
-
-    aOutputData.iMediaData->setTimestamp(aOutputData.iEncoderOutput.iTimeStamp);
-    aOutputData.iMediaData->setSeqNum(iSeqNum++);
-
-    OsclSharedPtr<PVMFMediaDataImpl> media_data_impl;
-    aOutputData.iMediaData->getMediaDataImpl(media_data_impl);
-
-    if (aOutputData.iEncoderOutput.iKeyFrame == true)
-        media_data_impl->setMarkerInfo(1);
-    else
-        media_data_impl->setMarkerInfo(0);
-
-    /*** old code
-    // update the filled length of the fragment
-    //aOutputData.iMediaData->setMediaFragFilledLen(0, aOutputData.iEncoderOutput.iBitstreamSize);
-
-    // Set timestamp
-    //aOutputData.iMediaData->setTimestamp(aOutputData.iEncoderOutput.iTimeStamp);
-
-    // Set sequence number
-    //aOutputData.iMediaData->setSeqNum(iSeqNum++);
-
-    // Send paramSet for avc bitstream // sent via Kvp instead
-    //if(aOutputData.iMediaData->getSeqNum() == 0 && iCodec == PVMF_H264_MP4)
-    	//aOutputData.iMediaData->setFormatSpecificInfo(iParamSet);
-    ****/
-
-    // Send bitstream data to downstream node
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaMsg(mediaMsgOut, aOutputData.iMediaData);
-
-    for (uint32 i = 0; i < iOutPort.size(); i++)
-    {
-        status = iOutPort[i]->QueueOutgoingMsg(mediaMsgOut);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncNode::SendEncodedBitstream: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Encoder settings routines
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::SetCodecType(PVMFFormatType aCodec)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetCodecType: Error iInterfaceState=%d", iInterfaceState));
-            return PVMFErrInvalidState;
-        default:
-            break;
-    }
-
-    iCodec = aCodec;
-
-    switch (iCodec)
-    {
-        case PVMF_H264_RAW:
-            iEncodeParam.iOutOfBandParamSet = false;
-            break;
-        case PVMF_H264_MP4:
-            iEncodeParam.iOutOfBandParamSet = true;
-            break;
-        default:
-            LOG_ERR((0, "PVMFAvcEncNode::SetCodecType: RFC 3984 not supported"));
-            return PVMFErrNotSupported;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::SetInputFormat(PVMFFormatType aFormat)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::SetInputFormat: aFormat=%d", aFormat));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetInputFormat: Error - iInterfaceState=%d", iInterfaceState));
-            return PVMFErrInvalidState;
-        default:
-            break;
-    }
-
-    switch (aFormat)
-    {
-        case PVMF_YUV420:
-            iInputFormat.iVideoFormat = EAVCEI_VDOFMT_YUV420;
-            break;
-        case PVMF_YUV422:
-            iInputFormat.iVideoFormat = EAVCEI_VDOFMT_UYVY;
-            break;
-        case PVMF_RGB24:
-            iInputFormat.iVideoFormat = EAVCEI_VDOFMT_RGB24;
-            break;
-        case PVMF_RGB12:
-            iInputFormat.iVideoFormat = EAVCEI_VDOFMT_RGB12;
-            break;
-        default:
-            return PVMFFailure;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetInputFrameSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-        default:
-            break;
-    }
-
-    iInputFormat.iFrameWidth = aWidth;
-    iInputFormat.iFrameHeight = aHeight;
-    iInputFormat.iFrameOrientation = aFrmOrient;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::SetInputFrameRate(OsclFloat aFrameRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFAvcEncNode::SetInputFrameRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-        default:
-            break;
-    }
-
-    iInputFormat.iFrameRate = aFrameRate;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFFormatType PVMFAvcEncNode::GetCodecType()
-{
-    return iCodec;
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PVMFAvcEncNode::GetOutputBitRate(uint32 aLayer)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::GetOutputBitRate: Error - Invalid layer number"));
-        return 0;
-    }
-
-    return iEncodeParam.iBitRate[aLayer];
-}
-
-////////////////////////////////////////////////////////////////////////////
-OsclFloat PVMFAvcEncNode::GetOutputFrameRate(uint32 aLayer)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::GetOutputFrameRate: Error Invalid layer number"));
-        return 0;
-    }
-
-    return iEncodeParam.iFrameRate[aLayer];
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFAvcEncNode::GetOutputFrameSize: Error Invalid layer number"));
-        return PVMFFailure;
-    }
-
-    aWidth = iEncodeParam.iFrameWidth[aLayer];
-    aHeight = iEncodeParam.iFrameHeight[aLayer];
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PVMFAvcEncNode::GetIFrameInterval()
-{
-    return iEncodeParam.iIFrameInterval;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Event reporting routines.
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::SetState(TPVMFNodeInterfaceState aState)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::SetState %d", aState));
-    PVMFNodeInterface::SetState(aState);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_ERR((0, "PVMFAvcEncNode::ReportErrorEvent: aEventType=%d aEventData=0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncNode::ReportInfoEvent: aEventType=%d, aEventData0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNode::SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg)
-{
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    sharedMediaCmdPtr->setTimestamp(aMsg->getTimestamp());
-
-    // Set the sequence number
-    sharedMediaCmdPtr->setSeqNum(aMsg->getSeqNum());
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-
-    for (uint32 ii = 0; ii < iOutPort.size(); ii++)
-    {
-        PVMFStatus status = iOutPort[ii]->QueueOutgoingMsg(mediaMsgOut);
-
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncNode::SendEndOfTrackCommand: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncNode::LogDiagnostics()
-{
-#if PROFILING_ON
-    oDiagnosticsLogged = true;
-    if (iTotalFramesEncoded > 0)
-    {
-        iAverageEncDuration = iTotalEncTime / iTotalFramesEncoded;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iDiagnosticsLogger, PVLOGMSG_DEBUG,
-                    (0, "PVMFAvcEncNodeEnc Stats: Encode Duration(Min: %d ,Max: %d, Average: %d), Total Enc Time: %d\n", iMinEncDuration, iMaxEncDuration, iAverageEncDuration, iTotalEncTime));
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////
-//            PVMFAvcEncNodeOutputData implementation
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncNodeOutputData::PVMFAvcEncNodeOutputData()
-{
-    oscl_memset(&iEncoderOutput, 0, sizeof(TAVCEIOutputData));
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncNodeOutputData::PVMFAvcEncNodeOutputData(const PVMFAvcEncNodeOutputData& aData)
-{
-    iEncoderOutput.iBitstream = aData.iEncoderOutput.iBitstream;
-    iEncoderOutput.iBitstreamSize = aData.iEncoderOutput.iBitstreamSize;
-    iEncoderOutput.iTimeStamp = aData.iEncoderOutput.iTimeStamp;
-    iEncoderOutput.iFragment = aData.iEncoderOutput.iFragment;
-    iEncoderOutput.iLastFragment = aData.iEncoderOutput.iLastFragment;
-    iEncoderOutput.iKeyFrame = aData.iEncoderOutput.iKeyFrame;
-    iEncoderOutput.iLastNAL = aData.iEncoderOutput.iLastNAL;
-
-    iMediaData = aData.iMediaData;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncNodeOutputData::Allocate(PVMFSimpleMediaBufferCombinedAlloc* aBufferAlloc,
-        PVMFAvcEncNodeMemPool* aMemPool,
-        PVMFMediaFragGroupCombinedAlloc<OsclMemPoolFixedChunkAllocator>* aGroupAlloc)
-{
-    int32 err = 0;
-    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
-
-    OSCL_TRY(err, mediaDataImplOut = aBufferAlloc->allocate(MAX_OUTBUF_SIZE);); // 8192
-    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
-
-    OSCL_TRY(err, iFragGroupmediaDataImpl = aGroupAlloc->allocate(););
-    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
-
-    /* Now create a PVMF media data from pool */
-    OSCL_TRY(err, iMediaData = PVMFMediaData::createMediaData(iFragGroupmediaDataImpl, aMemPool););
-    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
-
-    // Retrieve memory fragment to write to
-    //iMediaData->getMediaFragment(0, refCtrMemFragOut);
-    mediaDataImplOut->getMediaFragment(0, iRefCtrMemFragOut);
-    iEncoderOutput.iBitstream = (uint8*)iRefCtrMemFragOut.getMemFrag().ptr;
-    oscl_memset(iEncoderOutput.iBitstream, 0, MAX_OUTBUF_SIZE);
-    iEncoderOutput.iBitstreamSize = MAX_OUTBUF_SIZE;
-    return PVMFSuccess;
-}
-
diff --git a/nodes/pvavcencnode/src/pvmf_avcenc_node.h b/nodes/pvavcencnode/src/pvmf_avcenc_node.h
deleted file mode 100644
index a2d740c..0000000
--- a/nodes/pvavcencnode/src/pvmf_avcenc_node.h
+++ /dev/null
@@ -1,339 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMF_AVCENC_NODE_H_INCLUDED
-#define PVMF_AVCENC_NODE_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-#ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
-#include "pvmf_media_frag_group.h"
-#endif
-#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-#include "pvmp4h263encextension.h"
-#endif
-#ifndef PVMF_AVCENC_TUNEABLES_H_INCLUDED
-#include "pvmf_avcenc_tuneables.h"
-#endif
-#ifndef PVAVCENCODERINTERFACE_H_INCLUDED
-#include "pvavcencoderinterface.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-
-#define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
-
-#if PROFILING_ON
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
-#endif
-#endif
-
-
-// Forward declarations
-class PVMFAvcEncPort;
-class PVMFAvcEncNodeOutputData;
-
-// Allocators
-typedef OsclMemAllocDestructDealloc<uint8> PVMFAvcEncNodeAllocDestructDealloc;
-typedef OsclMemAllocator PVMFAvcEncNodeAlloc;
-typedef OsclMemPoolFixedChunkAllocator PVMFAvcEncNodeMemPool;
-
-/** Node command type */
-typedef PVMFGenericNodeCommand<PVMFAvcEncNodeAlloc> PVMFAvcEncNodeCommand;
-
-/** Command queue type */
-typedef PVMFNodeCommandQueue<PVMFAvcEncNodeCommand, PVMFAvcEncNodeAlloc> PVMFAvcEncNodeCmdQueue;
-
-/** Port vector type */
-typedef PVMFPortVector<PVMFAvcEncPort, PVMFAvcEncNodeAlloc> PVMFAvcEncPortVector;
-
-////////////////////////////////////////////////////////////////////////////
-class PVMFAvcEncNode : public OsclTimerObject, public PVMFNodeInterface,
-            public PVMp4H263EncExtensionInterface,
-            public OsclMemPoolFixedChunkAllocatorObserver,
-            public PvmiCapabilityAndConfig
-{
-    public:
-        PVMFAvcEncNode(int32 aPriority);
-        virtual ~PVMFAvcEncNode();
-
-        // Virtual functions of PVMFNodeInterface
-        virtual PVMFStatus ThreadLogon();
-        virtual PVMFStatus ThreadLogoff();
-        virtual PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
-        virtual PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
-        virtual PVMFCommandId QueryUUID(PVMFSessionId aSession,
-                                        const PvmfMimeString& aMimeType,
-                                        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-                                        bool aExactUuidsOnly = false,
-                                        const OsclAny* aContext = NULL);
-        virtual PVMFCommandId QueryInterface(PVMFSessionId aSession,
-                                             const PVUuid& aUuid,
-                                             PVInterface*& aInterfacePtr,
-                                             const OsclAny* aContext = NULL);
-        virtual PVMFCommandId RequestPort(PVMFSessionId aSession, int32 aPortTag,
-                                          const PvmfMimeString* aPortConfig = NULL,
-                                          const OsclAny* aContext = NULL);
-        virtual PVMFCommandId ReleasePort(PVMFSessionId aSession, PVMFPortInterface& aPort,
-                                          const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Init(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Prepare(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Start(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Stop(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Flush(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Pause(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId Reset(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        virtual PVMFCommandId CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContextData = NULL);
-        virtual PVMFCommandId CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId,
-                                            const OsclAny* aContextData = NULL);
-
-        // From PVMFPortActivityHandler
-        virtual void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-        // Virtual functions of PVMp4H263EncExtensionInterface
-        virtual void addRef();
-        virtual void removeRef();
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        virtual bool SetNumLayers(uint32 aNumLayers);
-        virtual bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate);
-        virtual bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight);
-        virtual bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate);
-        virtual bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes);
-        virtual bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl);
-        virtual bool SetDataPartitioning(bool aDataPartitioning);
-        virtual bool SetRVLC(bool aRVLC);
-        virtual bool SetIFrameInterval(uint32 aIFrameInterval);
-        virtual bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader);
-        virtual bool RequestIFrame();
-        virtual bool SetCodec(PVMFFormatType aCodec);
-        // implemetation of PvmiCapabilityAndConfig class functions here
-        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-
-        PVMFStatus getParametersSync(PvmiMIOSession aSession,
-                                     PvmiKeyType aIdentifier,
-                                     PvmiKvp*& aParameters,
-                                     int& aNumParamElements,
-                                     PvmiCapabilityContext aContext);
-        PVMFStatus releaseParameters(PvmiMIOSession aSession,
-                                     PvmiKvp* aParameters,
-                                     int num_elements);
-        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                                  PvmiKvp* aParameters, int num_parameter_elements);
-        void DeleteContext(PvmiMIOSession aSession,
-                           PvmiCapabilityContext& aContext);
-        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                               int num_elements, PvmiKvp * & aRet_kvp);
-        PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
-                                         PvmiKvp* aParameters,
-                                         int num_elements,
-                                         PvmiKvp*& aRet_kvp,
-                                         OsclAny* context = NULL);
-        uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
-                                        PvmiKvp* aParameters,
-                                        int num_elements);
-
-        // function used in getParametersSync of capability class
-        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
-                                      int32 aIndex, PvmiKvpAttr reqattr);
-        // function used in VerifyParametersSync n SetParametersSync of capability class
-        PVMFStatus VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam);
-
-
-    private:
-        void ConstructEncoderParams();
-
-        // From OsclTimerObject
-        void Run();
-
-        /////////////////////////////////////////////////////
-        //     Command processing routines
-        /////////////////////////////////////////////////////
-        PVMFCommandId QueueCommandL(PVMFAvcEncNodeCommand& aCmd);
-        bool ProcessCommand(PVMFAvcEncNodeCommand& aCmd);
-        void CommandComplete(PVMFAvcEncNodeCmdQueue& aCmdQueue, PVMFAvcEncNodeCommand& aCmd,
-                             PVMFStatus aStatus, OsclAny* aData = NULL);
-        void DoQueryUuid(PVMFAvcEncNodeCommand& aCmd);
-        void DoQueryInterface(PVMFAvcEncNodeCommand& aCmd);
-        void DoRequestPort(PVMFAvcEncNodeCommand& aCmd);
-        PVMFAvcEncPort* AllocatePort(PVMFAvcEncPortVector& aPortVector, int32 aTag, OSCL_String* aMimeType, const char* aName);
-        void DoReleasePort(PVMFAvcEncNodeCommand& aCmd);
-        void DoInit(PVMFAvcEncNodeCommand& aCmd);
-        void DoPrepare(PVMFAvcEncNodeCommand& aCmd);
-        void DoStart(PVMFAvcEncNodeCommand& aCmd);
-        void DoStop(PVMFAvcEncNodeCommand& aCmd);
-        void DeleteAvcEncoder();
-        void DoFlush(PVMFAvcEncNodeCommand& aCmd);
-        bool IsFlushPending();
-        void FlushComplete();
-        void DoPause(PVMFAvcEncNodeCommand& aCmd);
-        void DoReset(PVMFAvcEncNodeCommand& aCmd);
-        void DoCancelAllCommands(PVMFAvcEncNodeCommand& aCmd);
-        void DoCancelCommand(PVMFAvcEncNodeCommand& aCmd);
-
-        /////////////////////////////////////////////////////
-        //      Port activity processing routines
-        /////////////////////////////////////////////////////
-        bool IsProcessOutgoingMsgReady();
-        bool IsProcessIncomingMsgReady();
-        PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
-        PVMFStatus AsyncEncode(PVMFSharedMediaDataPtr& aMediaData);
-        PVMFStatus SendEncodedBitstream(PVMFAvcEncNodeOutputData& aOutputData);
-
-        /////////////////////////////////////////////////////
-        //      Encoder settings routine
-        /////////////////////////////////////////////////////
-        PVMFStatus SetInputFormat(PVMFFormatType aFormat);
-        PVMFStatus SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient = 0);
-        PVMFStatus SetInputFrameRate(OsclFloat aFrameRate);
-        PVMFStatus SetCodecType(PVMFFormatType aCodec);
-        PVMFFormatType GetCodecType();
-        uint32 GetOutputBitRate(uint32 aLayer);
-        OsclFloat GetOutputFrameRate(uint32 aLayer);
-        PVMFStatus GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight);
-        uint32 GetIFrameInterval();
-
-        // Event reporting
-        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
-        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
-        void SetState(TPVMFNodeInterfaceState aState);
-
-        // OsclMemPoolFixedChunkAllocatorObserver
-        void freechunkavailable(OsclAny* aContextData);
-        PVMFStatus SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg);
-        void LogDiagnostics();
-    private:
-
-        // Allocators
-        PVMFAvcEncNodeAllocDestructDealloc iAlloc;
-        // Allocator for simple media data buffer
-        OsclMemPoolFixedChunkAllocator* iMediaBufferMemPool;
-        PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc;
-
-        // Memory pool for media data buffer impl that holds multiple media fragments
-        OsclMemPoolFixedChunkAllocator* iMediaDataGroupImplMemPool;
-        PVMFMediaFragGroupCombinedAlloc<OsclMemPoolFixedChunkAllocator>* iMediaDataGroupAlloc;
-
-        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
-
-        bool iWaitingOnFreeChunk;
-
-        // Command queue
-        PVMFAvcEncNodeCmdQueue iCmdQueue;
-
-        // A queue is used to hold the current command so it's easy to find out
-        // whether a command is in progress, and allow cancel to interrupt
-        PVMFAvcEncNodeCmdQueue iCurrentCmd;
-
-        // Ports and port activity
-        PVMFAvcEncPortVector iInPort;
-        PVMFAvcEncPortVector iOutPort;
-        Oscl_Vector<PVMFPortActivity, PVMFAvcEncNodeAlloc> iPortActivityQueue;
-        friend class PVMFAvcEncPort;
-
-        // Encoder
-        PVMFFormatType iCodec;
-        PVAVCEncoderInterface* iAvcEncoder;
-        TAVCEIInputFormat iInputFormat;
-        TAVCEIEncodeParam iEncodeParam;
-        OsclRefCounterMemFrag iParamSet; /** Vol header */
-        uint32 iSeqNum; /** Sequence number */
-        bool  iReadyForNextFrame;
-        OsclMemoryFragment iSPSs[PVMF_AVCENC_NODE_SPS_VECTOR_RESERVE];
-        OsclMemoryFragment iPPSs[PVMF_AVCENC_NODE_PPS_VECTOR_RESERVE];
-        int   iNumSPSs;
-        int	  iNumPPSs;
-
-        PVLogger* iLogger;
-        int32 iExtensionRefCount;
-
-#if PROFILING_ON
-        uint32 iMinEncDuration;
-        uint32 iMaxEncDuration;
-        uint32 iAverageEncDuration;
-        uint32 iTotalFramesEncoded;
-        uint32 iTotalEncTime;
-        uint32 iNumFramesSkipped;
-        PVLogger* iDiagnosticsLogger;
-        bool oDiagnosticsLogged;
-
-        // Statistics
-        struct PVAvcEncNodeStats
-        {
-            uint32 iNumFrames;
-            uint32 iNumFramesSkipped;
-            uint32 iDuration;
-        };
-        PVAvcEncNodeStats iStats;
-#endif
-};
-
-////////////////////////////////////////////////////////////////////////////
-class PVMFAvcEncNodeOutputData
-{
-    public:
-        PVMFAvcEncNodeOutputData();
-        PVMFAvcEncNodeOutputData(const PVMFAvcEncNodeOutputData& aData);
-        PVMFStatus Allocate(PVMFSimpleMediaBufferCombinedAlloc* aBufferAlloc, PVMFAvcEncNodeMemPool* aMemPool,
-                            PVMFMediaFragGroupCombinedAlloc<OsclMemPoolFixedChunkAllocator>* aGroupAlloc);
-
-        TAVCEIOutputData iEncoderOutput;
-        PVMFSharedMediaDataPtr iMediaData;
-        OsclSharedPtr<PVMFMediaDataImpl> iFragGroupmediaDataImpl;
-        OsclRefCounterMemFrag iRefCtrMemFragOut;
-
-};
-
-#endif // PVMF_AVCENC_NODE_H_INCLUDED
-
diff --git a/nodes/pvavcencnode/src/pvmf_avcenc_node_cap_config.cpp b/nodes/pvavcencnode/src/pvmf_avcenc_node_cap_config.cpp
deleted file mode 100644
index f6dbff0..0000000
--- a/nodes/pvavcencnode/src/pvmf_avcenc_node_cap_config.cpp
+++ /dev/null
@@ -1,530 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_AVCENC_NODE_H_INCLUDED
-#include "pvmf_avcenc_node.h"
-#endif
-
-#ifndef PVMF_AVCENC_PORT_H_INCLUDED
-#include "pvmf_avcenc_port.h"
-#endif
-
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-
-#ifndef PVMI_KVP_UTIL_H_INCLUDED
-#include "pvmi_kvp_util.h"
-#endif
-
-
-// Structure to hold the key string info for
-// AVCEncnode's capability-and-config
-struct PVAVCEncNodeKeyStringData
-{
-    char iString[64];
-    PvmiKvpType iType;
-    PvmiKvpValueType iValueType;
-};
-
-// The number of characters to allocate for the key string
-#define PVAVCENCNODECONFIG_KEYSTRING_SIZE 128
-
-// Key string info at the base level ("x-pvmf/avc/encoder")
-#define PVAVCENCNODECONFIG_BASE_NUMKEYS 3
-
-const PVAVCEncNodeKeyStringData PVAVCEncNodeConfigBaseKeys[PVAVCENCNODECONFIG_BASE_NUMKEYS] =
-{
-    {"encoding_mode", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-};
-
-enum BaseKeys_IndexMapType
-{
-    ENCODING_MODE = 0
-};
-
-PVMFStatus PVMFAvcEncNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::GetConfigParameter() In"));
-
-    aNumParamElements = 0;
-
-    // Allocate memory for the KVP
-    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
-    if (NULL == aParameters)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::GetConfigParameter() Memory allocation for KVP failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
-    // Allocate memory for the key string in KVP
-    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVAVCENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
-    if (NULL == memblock)
-    {
-        oscl_free(aParameters);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::GetConfigParameter() Memory allocation for key string failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_strset(memblock, 0, PVAVCENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
-    // Assign the key string buffer to KVP
-    aParameters[0].key = memblock;
-
-    // Copy the key string
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/avc/encoder/"), 20);
-    oscl_strncat(aParameters[0].key, PVAVCEncNodeConfigBaseKeys[aIndex].iString, oscl_strlen(PVAVCEncNodeConfigBaseKeys[aIndex].iString));
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
-    switch (PVAVCEncNodeConfigBaseKeys[aIndex].iValueType)
-    {
-        case PVMI_KVPVALTYPE_BITARRAY32:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_KSV:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_BOOL:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_INT32:
-            if (PVMI_KVPATTR_CUR == aReqattr)
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            break;
-        case PVMI_KVPVALTYPE_UINT32:
-        default:
-            if (PVMI_KVPATTR_CAP == aReqattr)
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            else
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
-            }
-            break;
-    }
-    aParameters[0].key[PVAVCENCNODECONFIG_KEYSTRING_SIZE-1] = 0;
-
-    // Copy the requested info
-    switch (aIndex)
-    {
-        case ENCODING_MODE:	// "encoding_mode"
-            if (PVMI_KVPATTR_CUR == aReqattr)
-            {
-                // Return current value
-                aParameters[0].value.uint32_value = iEncodeParam.iEncMode;
-            }
-            else if (PVMI_KVPATTR_DEF == aReqattr)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = EAVCEI_ENCMODE_RECORDER;//default setting
-            }
-            else
-            {
-                // Return capability
-            }
-            break;
-
-        default:
-            // Invalid index
-            oscl_free(aParameters[0].key);
-            oscl_free(aParameters);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::GetConfigParameter() Invalid index to AVC enc node parameter"));
-            return PVMFErrNotSupported;
-    }
-
-    aNumParamElements = 1;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::GetConfigParameter() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFAvcEncNode::VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::VerifyAndSetConfigParameter() In"));
-
-    // Determine the valtype
-    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
-    if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::VerifyAndSetConfigParameter() Valtype in key string unknown"));
-        return PVMFErrNotSupported;
-    }
-    // Retrieve the fourth component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(3, aParameter.key, compstr);
-
-    int32 avcenccomp4ind = 0;
-    for (avcenccomp4ind = 0; avcenccomp4ind < PVAVCENCNODECONFIG_BASE_NUMKEYS; ++avcenccomp4ind)
-    {
-        // Go through each component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(PVAVCEncNodeConfigBaseKeys[avcenccomp4ind].iString)) >= 0)
-        {
-            // Break out of the for loop
-            break;
-        }
-    }
-
-    if (PVAVCENCNODECONFIG_BASE_NUMKEYS <= avcenccomp4ind)
-    {
-        // Match couldn't be found or non-leaf node specified
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::VerifyAndSetConfigParameter() Unsupported key or non-leaf node"));
-        return PVMFErrNotSupported;
-    }
-
-    // Verify the valtype
-    if (keyvaltype != PVAVCEncNodeConfigBaseKeys[avcenccomp4ind].iValueType)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::VerifyAndSetConfigParameter() Valtype does not match for key"));
-        return PVMFErrNotSupported;
-    }
-
-    switch (avcenccomp4ind)
-    {
-        case ENCODING_MODE: // "encoding_mode"
-            // change the parameter
-            if (aSetParam)
-            {
-                iEncodeParam.iEncMode = (TAVCEIEncodingMode)aParameter.value.uint32_value;
-            }
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::VerifyAndSetConfigParameter() Invalid index for AVC enc node parameter"));
-            return PVMFErrNotSupported;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::VerifyAndSetConfigParameter() Out"));
-    return PVMFSuccess;
-}
-
-void PVMFAvcEncNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::setParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (NULL == aParameters || aNumElements < 1)
-    {
-        if (aParameters)
-        {
-            aRetKVP = aParameters;
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::setParametersSync() Passed in parameter invalid"));
-        return;
-    }
-
-    // Go through each parameter
-    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/avc/encoder")) < 0) || compcount < 3)
-        {
-            // First 3 components should be "x-pvmf/avc/encoder" and there must
-            // be at least 3 components
-            aRetKVP = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::setParametersSync() Unsupported key"));
-            return;
-        }
-
-        if (4 == compcount)
-        {
-            // Verify and set the passed-in AVC enc node setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
-            if (PVMFSuccess != retval)
-            {
-                aRetKVP = &aParameters[paramind];
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::setParametersSync() Setting parameter %d failed", paramind));
-                return;
-            }
-        }
-
-        else
-        {
-            // Do not support more than 4 components right now
-            aRetKVP = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::setParametersSync() Unsupported key"));
-            return;
-        }
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::setParametersSync() Out"));
-}
-
-
-PVMFStatus PVMFAvcEncNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::getParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-
-    // Initialize the output parameters
-    aNumParamElements = 0;
-    aParameters = NULL;
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aIdentifier);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aIdentifier, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/avc/encoder")) < 0) || compcount < 4)
-    {
-        // First 3 components should be "x-pvmf/avc/encoder" and there must
-        // be at least 3 components
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::getParametersSync() Invalid key string"));
-        return PVMFErrNotSupported;
-    }
-
-    // Retrieve the fourth component from the key string
-    pv_mime_string_extract_type(3, aIdentifier, compstr);
-
-    for (int32 avcenccomp4ind = 0; avcenccomp4ind < PVAVCENCNODECONFIG_BASE_NUMKEYS; ++avcenccomp4ind)
-    {
-        // Go through each AVC enc component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(PVAVCEncNodeConfigBaseKeys[avcenccomp4ind].iString)) >= 0)
-        {
-            if (4 == compcount)
-            {
-                // Determine what is requested
-                PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
-                if (PVMI_KVPATTR_UNKNOWN == reqattr)
-                {
-                    reqattr = PVMI_KVPATTR_CUR;
-                }
-
-                // Return the requested info
-                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, avcenccomp4ind, reqattr);
-                if (PVMFSuccess != retval)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::getParametersSync() Retrieving AVC enc node parameter failed"));
-                    return retval;
-                }
-            }
-            else
-            {
-                // Right now avcenc node doesn't support more than 4 components
-                // for this sub-key string so error out
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::getParametersSync() Unsupported key"));
-                return PVMFErrNotSupported;
-            }
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::getParametersSync() Out"));
-    if (aNumParamElements == 0)
-    {
-        // If no one could get the parameter, return error
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::getParametersSync() Unsupported key"));
-        return PVMFFailure;
-    }
-    else
-    {
-        return PVMFSuccess;
-    }
-}
-
-PVMFStatus PVMFAvcEncNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::releaseParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (aParameters == NULL || aNumElements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::releaseParameters() KVP list is NULL or number of elements is 0"));
-        return PVMFErrArgument;
-    }
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aParameters[0].key);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/avc/encoder")) < 0) || compcount < 3)
-    {
-        // First 3 component should be "x-pvmf/avc/encoder" and there must
-        // be at least three components
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::releaseParameters() Unsupported key"));
-        return PVMFErrNotSupported;
-    }
-
-    // Retrieve the third component from the key string
-    pv_mime_string_extract_type(2, aParameters[0].key, compstr);
-
-    // Go through each KVP and release memory for value if allocated from heap
-    for (int32 ii = 0; ii < aNumElements; ++ii)
-    {
-        // Next check if it is a value type that allocated memory
-        PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
-        if (PVMI_KVPTYPE_VALUE == kvptype || PVMI_KVPTYPE_UNKNOWN == kvptype)
-        {
-            PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
-            if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::releaseParameters() Valtype not specified in key string"));
-                return PVMFErrNotSupported;
-            }
-
-            if (PVMI_KVPVALTYPE_CHARPTR == keyvaltype && NULL != aParameters[ii].value.pChar_value)
-            {
-                oscl_free(aParameters[ii].value.pChar_value);
-                aParameters[ii].value.pChar_value = NULL;
-            }
-            else if (keyvaltype == PVMI_KVPVALTYPE_KSV && NULL != aParameters[ii].value.key_specific_value)
-            {
-                oscl_free(aParameters[ii].value.key_specific_value);
-                aParameters[ii].value.key_specific_value = NULL;
-            }
-            else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
-            {
-                range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
-                aParameters[ii].value.key_specific_value = NULL;
-                oscl_free(rui32);
-            }
-            // TODO Add more types if AVC enc node starts returning more types
-        }
-    }
-
-    // AVC enc node allocated its key strings in one chunk so just free the first key string ptr
-    oscl_free(aParameters[0].key);
-
-    // Free memory for the parameter list
-    oscl_free(aParameters);
-    aParameters = NULL;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::releaseParameters() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVMFAvcEncNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::verifyParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (NULL == aParameters || aNumElements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::verifyParametersSync() Passed in parameter invalid"));
-        return PVMFErrArgument;
-    }
-
-    // Go through each parameter
-    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/avc/encoder")) < 0) || compcount < 3)
-        {
-            // First 3 components should be "x-pvmf/avc/encoder" and there must
-            // be at least 3 components
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::verifyParametersSync() Unsupported key"));
-            return PVMFErrNotSupported;
-        }
-
-        if (4 == compcount)
-        {
-            // Verify and set the passed-in avc enc node setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], false);
-            if (retval != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::verifyParametersSync() Setting parameter %d failed", paramind));
-                return retval;
-            }
-        }
-        else
-        {
-            // Do not support more than 4 components right now
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAvcEncNode::verifyParametersSync() Unsupported key"));
-            return PVMFErrNotSupported;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFAvcEncNode::verifyParametersSync() Out"));
-    return PVMFSuccess;
-
-}
-
-uint32 PVMFAvcEncNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-    OSCL_UNUSED_ARG(aSession);
-    return 0;
-}
-
-//PvmiCapConfigInterface
-void PVMFAvcEncNode::createContext(PvmiMIOSession aSession,
-                                   PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFAvcEncNode::setContextParameters(PvmiMIOSession aSession,
-        PvmiCapabilityContext& aContext,
-        PvmiKvp* aParameters,
-        int aNumElements)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFAvcEncNode::DeleteContext(PvmiMIOSession aSession,
-                                   PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-PVMFCommandId PVMFAvcEncNode::setParametersAsync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int aNumElements,
-        PvmiKvp*& aRet_kvp,
-        OsclAny* aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    OSCL_UNUSED_ARG(aRet_kvp);
-//	PVMFAVCEncNodeCommand cmd;
-//	cmd.PVMFMP4FFParserNodeCommand::Construct(NULL, PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS, aSession, aParameters, num_elements, aRet_kvp, context);
-//	return QueueCommandL(cmd);
-    return 0;
-}
-
-void PVMFAvcEncNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    ciObserver = aObserver;
-}
-
diff --git a/nodes/pvavcencnode/src/pvmf_avcenc_port.cpp b/nodes/pvavcencnode/src/pvmf_avcenc_port.cpp
deleted file mode 100644
index 8e282c7..0000000
--- a/nodes/pvavcencnode/src/pvmf_avcenc_port.cpp
+++ /dev/null
@@ -1,978 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMF_AVCENC_PORT_H_INCLUDED
-#include "pvmf_avcenc_port.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-#ifndef PVMF_AVCENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_avcenc_node_types.h"
-#endif
-#ifndef PVMF_AVCENC_NODE_H_INCLUDED
-#include "pvmf_avcenc_node.h"
-#endif
-#ifndef PVMI_KVP_H_INCLUDED
-#include "pvmi_kvp.h"
-#endif
-
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncPort::PVMFAvcEncPort(int32 aTag, PVMFAvcEncNode* aNode, int32 aPriority, const char* aName)
-        :  PvmfPortBaseImpl(aTag, this,
-                            PVMF_AVCENC_PORT_CAPACITY, PVMF_AVCENC_PORT_RESERVE, PVMF_AVCENC_PORT_THRESHOLD,
-                            PVMF_AVCENC_PORT_CAPACITY, PVMF_AVCENC_PORT_RESERVE, PVMF_AVCENC_PORT_THRESHOLD, aName),
-        OsclActiveObject(aPriority, "PVMFAvcEncPort"),
-        iFormat(PVMF_FORMAT_UNKNOWN),
-        iNode(aNode)
-{
-    AddToScheduler();
-    iLogger = PVLogger::GetLoggerObject("PVMFAvcEncPort");
-#if PVMF_PORT_BASE_IMPL_STATS
-    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFAvcEncPort::~PVMFAvcEncPort()
-{
-    Disconnect();
-    ClearMsgQueues();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncPort::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
-{
-    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-        aPtr = (PvmiCapabilityAndConfig*)this;
-    else
-        aPtr = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncPort::Connect(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::Connect: aPort=0x%x", aPort));
-
-    if (!aPort)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - Connecting to invalid port"));
-        return PVMFErrArgument;
-    }
-
-    if (iConnectedPort)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - Already connected"));
-        return PVMFFailure;
-    }
-
-    PvmiCapabilityAndConfig* config = NULL;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-    if (!config)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - Peer port does not support capability interface"));
-        return PVMFFailure;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (iTag)
-    {
-        case PVMF_AVCENC_NODE_PORT_TYPE_INPUT:
-            status = NegotiateInputSettings(config);
-            break;
-        case PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT:
-            status = NegotiateOutputSettings(config);
-            iOutConnectedPort = aPort;
-            break;
-        default:
-            LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - Invalid port tag"));
-            status = PVMFFailure;
-    }
-
-    if (status != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - Settings negotiation failed. status=%d", status));
-        return status;
-    }
-
-    //Automatically connect the peer.
-    if (aPort->PeerConnect(this) != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - Peer Connect failed"));
-        return PVMFFailure;
-    }
-
-    iConnectedPort = aPort;
-
-#if PVMF_PORT_BASE_IMPL_STATS
-    // Reset statistics
-    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-
-    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                  PvmiCapabilityAndConfig
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    // Not supported
-    OSCL_UNUSED_ARG(aObserver);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncPort::getParametersSync(PvmiMIOSession session,
-        PvmiKeyType identifier,
-        PvmiKvp*& parameters,
-        int& num_parameter_elements,
-        PvmiCapabilityContext context)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::getParametersSync"));
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-
-    parameters = NULL;
-    num_parameter_elements = 0;
-    PVMFStatus status = PVMFFailure;
-
-    switch (iTag)
-    {
-        case PVMF_AVCENC_NODE_PORT_TYPE_INPUT:
-            return GetInputParametersSync(identifier, parameters, num_parameter_elements);
-        case PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT:
-            return GetOutputParametersSync(identifier, parameters, num_parameter_elements);
-        default:
-            LOG_ERR((0, "PVMFAvcEncPort::getParametersSync: Error - Invalid port tag"));
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncPort::releaseParameters(PvmiMIOSession session,
-        PvmiKvp* parameters,
-        int num_elements)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(num_elements);
-
-    if (parameters)
-    {
-        iAlloc.deallocate((OsclAny*)parameters);
-        return PVMFSuccess;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncPort::setContextParameters(PvmiMIOSession session,
-        PvmiCapabilityContext& context,
-        PvmiKvp* parameters, int num_parameter_elements)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-    OSCL_UNUSED_ARG(parameters);
-    OSCL_UNUSED_ARG(num_parameter_elements);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFAvcEncPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
-        int num_elements, PvmiKvp*& ret_kvp)
-{
-    OSCL_UNUSED_ARG(session);
-    PVMFStatus status = PVMFSuccess;
-    ret_kvp = NULL;
-
-    for (int32 i = 0; i < num_elements; i++)
-    {
-        status = VerifyAndSetParameter(&(parameters[i]), true);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
-            ret_kvp = &(parameters[i]);
-            OSCL_LEAVE(OsclErrArgument);
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFAvcEncPort::setParametersAsync(PvmiMIOSession session,
-        PvmiKvp* parameters,
-        int num_elements,
-        PvmiKvp*& ret_kvp,
-        OsclAny* context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(parameters);
-    OSCL_UNUSED_ARG(num_elements);
-    OSCL_UNUSED_ARG(ret_kvp);
-    OSCL_UNUSED_ARG(context);
-    return -1;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF uint32 PVMFAvcEncPort::getCapabilityMetric(PvmiMIOSession session)
-{
-    OSCL_UNUSED_ARG(session);
-    return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFAvcEncPort::verifyParametersSync(PvmiMIOSession session,
-        PvmiKvp* parameters, int num_elements)
-{
-    OSCL_UNUSED_ARG(session);
-
-    PVMFStatus status = PVMFSuccess;
-    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
-        status = VerifyAndSetParameter(&(parameters[i]));
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::SetFormat(PVMFFormatType aFormat)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::SetFormat: aFormat=%d", aFormat));
-    if (!IsFormatSupported(aFormat))
-        return PVMFFailure;
-
-    iFormat = aFormat;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncPort::ProcessIncomingMsgReady()
-{
-    if (IncomingMsgQueueSize() > 0)
-        RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncPort::ProcessOutgoingMsgReady()
-{
-    if (OutgoingMsgQueueSize() > 0)
-        RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from PVMFPortActivityHandler
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncPort::HandlePortActivity(const PVMFPortActivity& aActivity)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::HandlePortActivity: type=%d", aActivity.iType));
-
-    if (aActivity.iPort != this)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::HandlePortActivity: Error - Activity is not on this port"));
-        return;
-    }
-
-    switch (aActivity.iType)
-    {
-        case PVMF_PORT_ACTIVITY_CREATED:
-            //Report port created info event to the node.
-            iNode->ReportInfoEvent(PVMFInfoPortCreated,
-                                   (OsclAny*)aActivity.iPort);
-            break;
-
-        case PVMF_PORT_ACTIVITY_DELETED:
-            //Report port deleted info event to the node.
-            iNode->ReportInfoEvent(PVMFInfoPortDeleted,
-                                   (OsclAny*)aActivity.iPort);
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-            // Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-            if (OutgoingMsgQueueSize() == 1 &&
-                    !IsConnectedPortBusy())
-            {
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-            //Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-            if (IncomingMsgQueueSize() == 1 &&
-                    iNode->IsProcessIncomingMsgReady())
-            {
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
-            // This is handled in the input port side when IsProcessIncomingMsgReady call failed
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            // Notifies the node that the output queue is ready, and the node would
-            // resume encoding incoming data
-            iNode->HandlePortActivity(aActivity);
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-            if (OutgoingMsgQueueSize() > 0)
-                RunIfNotReady();
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-            // This is handled when iNode->ProcessOutgoingMsg failed with busy
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECT:
-        case PVMF_PORT_ACTIVITY_DISCONNECT:
-        default:
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from OsclActiveObject
-////////////////////////////////////////////////////////////////////////////
-void PVMFAvcEncPort::Run()
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::Run"));
-    PVMFStatus status = PVMFSuccess;
-
-    // Process incoming messages
-    if (iTag == PVMF_AVCENC_NODE_PORT_TYPE_INPUT)
-    {
-        if (IncomingMsgQueueSize() > 0)
-        {
-            //dispatch the incoming data.
-            if (iNode->IsProcessIncomingMsgReady())
-            {
-                status = iNode->ProcessIncomingMsg(this);
-                if (status != PVMFSuccess)
-                {
-                    LOG_ERR((0, "PVMFAvcEncPort::Run: Error - ProcessIncomingMsg failed. status=%d", status));
-                }
-            }
-
-        }
-
-
-        if (iNode->IsFlushPending())
-        {
-            if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-            {
-                iNode->FlushComplete();
-            }
-            else
-            {
-                RunIfNotReady();
-            }
-        }
-    }
-
-    //Process outgoing messages
-    if (iTag == PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        if (OutgoingMsgQueueSize() > 0)
-        {
-            if (iNode->IsProcessOutgoingMsgReady())
-            {
-                //Send data to connected port
-                status = Send();
-                switch (status)
-                {
-                    case PVMFSuccess:
-                        // Reschedule if there's more data to process and connected port did not become busy
-                        // after receiving the last msg
-                        if (OutgoingMsgQueueSize() > 0 && iNode->IsProcessOutgoingMsgReady())
-                        {
-                            RunIfNotReady();
-                        }
-                        break;
-
-                    case PVMFErrBusy:
-                        // Connected port busy. Don't schedule next data
-                        break;
-
-                    default:
-                        LOG_ERR((0, "PVMFAvcEncPort::Run: Error - Send() failed. status=%d", status));
-                        iNode->ReportErrorEvent(PVMF_AVCENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)this);
-                        break;
-                }
-
-                if (iNode->IsFlushPending())
-                {
-                    if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                        iNode->FlushComplete();
-                }
-            }
-        }
-
-        if (iNode->IsFlushPending())
-        {
-            if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                iNode->FlushComplete();
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Capabilities exchange handling routines
-////////////////////////////////////////////////////////////////////////////
-bool PVMFAvcEncPort::IsFormatSupported(PVMFFormatType aFormat)
-{
-    if (iTag == PVMF_AVCENC_NODE_PORT_TYPE_INPUT)
-    {
-        switch (aFormat)
-        {
-            case PVMF_YUV420:
-            case PVMF_YUV422:
-            case PVMF_RGB12:
-            case PVMF_RGB24:
-                return true;
-            default:
-                break;
-        }
-    }
-    else if (iTag == PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aFormat)
-        {
-            case PVMF_H264_RAW:
-            case PVMF_H264_MP4:
-            case PVMF_H264:
-                return true;
-            default:
-                break;
-        }
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-        int& num_parameter_elements)
-{
-    if (iTag != PVMF_AVCENC_NODE_PORT_TYPE_INPUT)
-        return PVMFFailure;
-
-    PVMFStatus status = PVMFSuccess;
-
-    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
-    {
-        num_parameter_elements = 1;//4;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetInputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-
-        parameters[0].value.uint32_value = PVMF_YUV420;
-        parameters[1].value.uint32_value = PVMF_YUV422;
-        parameters[2].value.uint32_value = PVMF_RGB12;
-        parameters[3].value.uint32_value = PVMF_RGB24;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-        int& num_parameter_elements)
-{
-    if (iTag != PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT)
-        return PVMFFailure;
-
-    PVMFStatus status = PVMFSuccess;
-
-    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0)
-    {
-        num_parameter_elements = 2;//3;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = PVMF_H264_RAW;
-            parameters[1].value.uint32_value = PVMF_H264_MP4;
-            //parameters[2].value.uint32_value = PVMF_H264;
-        }
-    }
-    else if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iNode->GetCodecType();
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-
-        uint32 width, height;
-        status = iNode->GetOutputFrameSize(0, width, height);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error -iNode->GetOutputFrameSize failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = width;
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_HEIGHT_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            uint32 width, height;
-            status = iNode->GetOutputFrameSize(0, width, height);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - iNode->GetOutputFrameSize failed. status=%d", status));
-            }
-            else
-            {
-                parameters[0].value.uint32_value = height;
-            }
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.float_value = iNode->GetOutputFrameRate(0);
-        }
-    }
-    else if (pv_mime_strcmp(identifier, OUTPUT_BITRATE_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_BITRATE_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iNode->GetOutputBitRate(0);
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFAvcEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iNode->GetIFrameInterval();
-        }
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::AllocateKvp"));
-    uint8* buf = NULL;
-    uint32 keyLen = oscl_strlen(aKey) + 1;
-    int32 err = 0;
-
-    OSCL_TRY(err,
-             buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
-             if (!buf)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFAvcEncPort::AllocateKvp: Error - kvp allocation failed"));
-                         return PVMFErrNoMemory;
-                        );
-
-    int32 i = 0;
-    PvmiKvp* curKvp = aKvp = new(buf) PvmiKvp;
-    buf += sizeof(PvmiKvp);
-    for (i = 1; i < aNumParams; i++)
-    {
-        curKvp += i;
-        curKvp = new(buf) PvmiKvp;
-        buf += sizeof(PvmiKvp);
-    }
-
-    for (i = 0; i < aNumParams; i++)
-    {
-        aKvp[i].key = (char*)buf;
-        oscl_strncpy(aKvp[i].key, aKey, keyLen);
-        buf += keyLen;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
-
-    if (!aKvp)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
-        return PVMFFailure;
-    }
-
-    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0 &&
-            iTag == PVMF_AVCENC_NODE_PORT_TYPE_INPUT)
-    {
-        switch (aKvp->value.uint32_value)
-        {
-            case PVMF_YUV420:
-            case PVMF_YUV422:
-            case PVMF_RGB12:
-            case PVMF_RGB24:
-                if (aSetParam)
-                {
-                    iFormat = aKvp->value.uint32_value;
-                    iNode->SetInputFormat(iFormat);
-                }
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PVMFAvcEncPort::VerifyAndSetParameter: Error - Input format %d not supported",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
-        }
-    }
-    else if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0 &&
-             iTag == PVMF_AVCENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aKvp->value.uint32_value)
-        {
-            case PVMF_H264_RAW:
-            case PVMF_H264_MP4:
-                //case PVMF_H264:
-                if (aSetParam)
-                {
-                    iFormat = aKvp->value.uint32_value;
-                    iNode->SetCodecType(iFormat);
-                }
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PVMFAvcEncPort::VerifyAndSetParameter: Error - Output format %d not supported",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
-        }
-    }
-
-    LOG_ERR((0, "PVMFAvcEncPort::VerifyAndSetParameter: Error - Unsupported parameter"));
-    return PVMFFailure;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::NegotiateInputSettings: aConfig=0x%x", aConfig));
-    if (!aConfig)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::NegotiateInputSettings: Error - Invalid config object"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    int32 err = 0;
-    uint32 videoFormat;
-
-    // Get supported output formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams == 0)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::NegotiateInputSettings: Error - config->getParametersSync(output_formats) failed"));
-        return status;
-    }
-
-    OsclPriorityQueue < PvmiKvp*, OsclMemAllocator,
-    Oscl_Vector<PvmiKvp*, OsclMemAllocator>,
-    PVMFAvcEncInputFormatCompareLess > sortedKvp;
-
-    // Using a priority queue, sort the kvp's returned from aConfig->getParametersSync
-    // according to the preference of this port. Formats that are not supported are
-    // not pushed to the priority queue and hence dropped from consideration.
-    for (int32 i = 0; i < numParams; i++)
-    {
-        switch (kvp[i].value.uint32_value)
-        {
-            case PVMF_YUV420:
-            case PVMF_YUV422:
-            case PVMF_RGB12:
-            case PVMF_RGB24:
-            {
-                videoFormat = kvp[i].value.uint32_value;
-                OSCL_TRY(err, sortedKvp.push(&(kvp[i])););
-                OSCL_FIRST_CATCH_ANY(err,
-                                     LOG_ERR((0, "PVMFAvcEncPort::NegotiateInputSettings: Error - sortedKvp.push failed"));
-                                     return PVMFErrNoMemory;
-                                    );
-            }
-            break;
-            default:
-                break;
-        }
-    }
-
-    if (sortedKvp.size() == 0)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::NegotiateInputSettings: Error - No matching supported input format"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* selectedKvp = sortedKvp.top();
-    PvmiKvp* retKvp = NULL;
-
-    // Set format of this port, peer port and container node
-    iFormat = selectedKvp->value.uint32_value;
-    iNode->SetInputFormat(iFormat);
-    OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFAvcEncPort::NegotiateInputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-                         return PVMFFailure;
-                        );
-
-    // Release parameters back to peer and reset for the next query
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    // Get size (in pixels) of video data from peer
-    uint32 width = 0;
-    uint32 height = 0;
-    uint8 orientation = 0;
-
-    status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams != 1)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - config->getParametersSync(current width) failed"));
-        return status;
-    }
-    width = kvp[0].value.uint32_value;
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams != 1)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - config->getParametersSync(current height) failed"));
-        return status;
-    }
-    height = kvp[0].value.uint32_value;
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    if ((PVMF_RGB12 == videoFormat) || (PVMF_RGB24 == videoFormat))
-    {
-        status = aConfig->getParametersSync(NULL, VIDEO_FRAME_ORIENTATION_CUR_QUERY, kvp, numParams, NULL);
-        if (status != PVMFSuccess || numParams != 1)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - config->getParametersSync(current height) failed"));
-            return status;
-        }
-
-        orientation = kvp[0].value.uint8_value;
-        aConfig->releaseParameters(NULL, kvp, numParams);
-        kvp = NULL;
-        numParams = 0;
-
-    }
-
-    // Set input frame size of container node
-    iNode->SetInputFrameSize(width, height, orientation);
-
-    // Get video frame rate from peer
-    status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams != 1)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::Connect: Error - config->getParametersSync(current frame rate) failed"));
-        return status;
-    }
-
-    // Set input frame rate of container node
-    iNode->SetInputFrameRate(kvp[0].value.float_value);
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFAvcEncPort::NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-    LOG_STACK_TRACE((0, "PVMFAvcEncPort::NegotiateOutputSettings: aConfig=0x%x", aConfig));
-    if (!aConfig)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::NegotiateOutputSettings: Error - Invalid config object"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    int32 i = 0;
-    int32 err = 0;
-
-    // Get supported input formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams == 0)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::NegotiateOutputSettings: Error - config->getParametersSync(input_formats) failed"));
-        return status;
-    }
-
-    PvmiKvp* selectedKvp = NULL;
-    PvmiKvp* retKvp = NULL;
-    for (i = 0; i < numParams && !selectedKvp; i++)
-    {
-        if (kvp[i].value.uint32_value == iFormat)
-            selectedKvp = &(kvp[i]);
-    }
-
-    if (!selectedKvp)
-    {
-        LOG_ERR((0, "PVMFAvcEncPort::NegotiateOutputSettings: Error - Output format not supported by peer"));
-        return PVMFFailure;
-    }
-
-    OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFAvcEncPort::NegotiateOutputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-                         return PVMFFailure;
-                        );
-
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    return PVMFSuccess;
-}
-
-
-void PVMFAvcEncPort::SendSPS_PPS(OsclMemoryFragment *aSPSs, int aNumSPSs, OsclMemoryFragment *aPPSs, int aNumPPSs)
-{
-    int ii;
-    PvmiCapabilityAndConfig* config = NULL;
-    iOutConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-
-    if (config)
-    {
-        for (ii = 0; ii < aNumSPSs; ii++)
-        {
-            // send SPS
-            PvmiKvp* sps, *ret;
-            AllocateKvp(sps, VIDEO_AVC_OUTPUT_SPS_CUR_VALUE, 1);
-
-            sps->value.key_specific_value = aSPSs[ii].ptr;
-            sps->capacity = aSPSs[ii].len;
-            config->setParametersSync(NULL, sps, 1, ret);
-            if (ret)
-            {
-                LOG_ERR((0, "PVMFAvcEncPort::SendSPS_PPS: Error returned Kvp is not null."));
-            }
-            // Release parameters back to peer and reset for the next query
-            config->releaseParameters(NULL, sps, 1);
-        }
-        for (ii = 0; ii < aNumPPSs; ii++)
-        {
-            // send PPS
-            PvmiKvp* pps, *ret;
-            AllocateKvp(pps, VIDEO_AVC_OUTPUT_PPS_CUR_VALUE, 1);
-
-            pps->value.key_specific_value = aPPSs[ii].ptr;
-            pps->capacity = aPPSs[ii].len;
-            config->setParametersSync(NULL, pps, 1, ret);
-            if (ret)
-            {
-                LOG_ERR((0, "PVMFAvcEncPort::SendSPS_PPS: Error returned Kvp is not null."));
-            }
-            // Release parameters back to peer and reset for the next query
-            config->releaseParameters(NULL, pps, 1);
-        }
-    }
-
-    return ;
-}
-
-
diff --git a/nodes/pvavcencnode/src/pvmf_avcenc_port.h b/nodes/pvavcencnode/src/pvmf_avcenc_port.h
deleted file mode 100644
index 4551d1b..0000000
--- a/nodes/pvavcencnode/src/pvmf_avcenc_port.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMF_AVCENC_PORT_H_INCLUDED
-#define PVMF_AVCENC_PORT_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
-#include "pvmf_port_base_impl.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
-#include "pvmi_config_and_capability_utils.h"
-#endif
-
-// Forward declaration
-class PVMFAvcEncNode;
-
-class PVMFAvcEncPort : public PvmfPortBaseImpl,
-            public PvmiCapabilityAndConfig,
-            public PVMFPortActivityHandler,
-            public OsclActiveObject
-{
-    public:
-        PVMFAvcEncPort(int32 aTag, PVMFAvcEncNode* aNode, int32 aPriority, const char* aName = NULL);
-        ~PVMFAvcEncPort();
-
-        // Overload PvmfPortBaseImpl methods
-        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
-        OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
-
-
-        // Implement pure virtuals from PvmiCapabilityAndConfig interface
-        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
-                PvmiKvp*& aParameters, int& num_parameter_elements,
-                PvmiCapabilityContext aContext);
-        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                PvmiKvp* aParameters, int num_parameter_elements);
-        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                                               int num_elements, PvmiKvp * & aRet_kvp);
-        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
-        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-
-        PVMFStatus SetFormat(PVMFFormatType aFormat);
-
-        // Notification from node to resume processing incoming msg
-        void ProcessIncomingMsgReady();
-        void ProcessOutgoingMsgReady();
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-        // For AVC specific call
-        void SendSPS_PPS(OsclMemoryFragment *aSPSs, int aNumSPSs, OsclMemoryFragment *aPPSs, int aNumPPSs);
-
-    private:
-        // Implement pure virtuals from OsclActiveObject
-        void Run();
-
-        /**
-         * Check if a format is supported for a specific port type
-         * @return true if specified format is supported for the specified port type
-         */
-        bool IsFormatSupported(PVMFFormatType aFormat);
-
-        /**
-         * Synchronous query of input port parameters
-         */
-        PVMFStatus GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                          int& num_parameter_elements);
-
-        /**
-         * Synchronous query of output port parameters
-         */
-        PVMFStatus GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                           int& num_parameter_elements);
-        /**
-         * Allocate a specified number of key-value pairs and set the keys
-         *
-         * @param aKvp Output parameter to hold the allocated key-value pairs
-         * @param aKey Key for the allocated key-value pairs
-         * @param aNumParams Number of key-value pairs to be allocated
-         * @return Completion status
-         */
-        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
-
-        /**
-         * Verify one key-value pair parameter against capability of the port and
-         * if the aSetParam flag is set, set the value of the parameter corresponding to
-         * the key.
-         *
-         * @param aKvp Key-value pair parameter to be verified
-         * @param aSetParam If true, set the value of parameter corresponding to the key.
-         * @return PVMFSuccess if parameter is supported, else PVMFFailure
-         */
-        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
-
-        /**
-         * Negotiates input port settings (format, video size and frame rate) and
-         * configures the peer port and the container node with these settings
-         *
-         * @param aConfig Capability and config object for peer port
-         * @return PVMFSuccess if settings are successfully negotiated.
-         */
-        PVMFStatus NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig);
-
-        /**
-         * Negotiates output port settings and configures the peer port using settings
-         * from the container node.
-         *
-         * @param aConfig Capability and config object for peer port
-         * @return PVMFSuccess if settings are successfully negotiated.
-         */
-        PVMFStatus NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig);
-
-        PVMFFormatType iFormat;
-        OsclMemAllocator iAlloc;
-        PVMFAvcEncNode* iNode;
-        PVMFPortInterface* iOutConnectedPort;
-};
-
-class PVMFAvcEncInputFormatCompareLess
-{
-    public:
-        /**
-         * The algorithm used in OsclPriorityQueue needs a compare function
-         * that returns true when A's priority is less than B's
-         * @return true if A's priority is less than B's, else false
-         */
-        int compare(PvmiKvp*& a, PvmiKvp*& b) const
-        {
-            return (PVMFAvcEncInputFormatCompareLess::GetPriority(a) <
-                    PVMFAvcEncInputFormatCompareLess::GetPriority(b));
-        }
-
-        /**
-         * Returns the priority of each command
-         * @return A 0-based priority number. A lower number indicates lower priority.
-         */
-        static int GetPriority(PvmiKvp*& aKvp)
-        {
-            switch (aKvp->value.uint32_value)
-            {
-                case PVMF_YUV420:
-                    return 3;
-                case PVMF_YUV422:
-                    return 2;
-                case PVMF_RGB12:
-                    return 1;
-                case PVMF_RGB24:
-                    return 0;
-                default:
-                    return 0;
-            }
-        }
-};
-
-#endif // PVMF_AVCENC_INPORT_H_INCLUDED
diff --git a/nodes/pvavcencnode/src/pvmf_avcenc_tuneables.h b/nodes/pvavcencnode/src/pvmf_avcenc_tuneables.h
deleted file mode 100644
index d5817a2..0000000
--- a/nodes/pvavcencnode/src/pvmf_avcenc_tuneables.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//                                                                              //
-//////////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMF_AVCENC_TUNEABLES_H_INCLUDED
-#define PVMF_AVCENC_TUNEABLES_H_INCLUDED
-
-
-// Default port queue reserve size
-#define PVMF_AVCENC_NODE_PORT_VECTOR_RESERVE 2
-#define PVMF_AVCENC_NODE_MAX_INPUT_PORT 1
-#define PVMF_AVCENC_NODE_MAX_OUTPUT_PORT 1
-#define PVMF_AVCENC_NODE_PORT_ACTIVITY_RESERVE 10
-
-// Default command queue reserve size
-#define PVMF_AVCENC_NODE_CMD_QUEUE_RESERVE 10
-
-// Starting value for command IDs
-#define PVMF_AVCENC_NODE_CMD_ID_START 10000
-
-#define DEFAULT_BITRATE 32000
-#define DEFAULT_FRAME_WIDTH 176
-#define DEFAULT_FRAME_HEIGHT 144
-#define DEFAULT_FRAME_RATE 5
-#define MAX_OUTBUF_SIZE 8192
-#define MAX_NUM_INPUTDATA	2
-#define MAX_NUM_OUTPUTDATA	2
-
-#define PVAVCENC_MEDIADATA_POOLNUM 16
-#define PVAVCENC_MEDIADATA_CHUNKSIZE 128
-#define PVAVCENC_MEDIABUFFER_CHUNKSIZE (MAX_OUTBUF_SIZE+128)
-
-// Port queue settings
-#define PVMF_AVCENC_PORT_CAPACITY 10
-#define PVMF_AVCENC_PORT_RESERVE 10
-#define PVMF_AVCENC_PORT_THRESHOLD 50
-
-// Encoder settings
-#define MAX_AVC_LAYER 1
-#define PVMF_AVCENC_NODE_SPS_VECTOR_RESERVE 16  // max allowed by standard
-#define PVMF_AVCENC_NODE_PPS_VECTOR_RESERVE 256 // max allowed by standard
-
-
-#endif // PVMF_AVCENC_TUNEABLES_H_INCLUDED
diff --git a/nodes/pvclientserversocketnode/build/make/local.mk b/nodes/pvclientserversocketnode/build/make/local.mk
new file mode 100644
index 0000000..a283f2e
--- /dev/null
+++ b/nodes/pvclientserversocketnode/build/make/local.mk
@@ -0,0 +1,33 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvclientserversocketnode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += ../../include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_clientserver_socket_factory.cpp \
+	pvmf_clientserver_socket_node.cpp \
+	pvmf_clientserver_socket_port.cpp
+
+HDRS := pvmf_clientserver_socket_factory.h \
+	pvmf_clientserver_socket_node.h \
+	pvmf_clientserver_socket_port.h \
+	pvmf_clientserver_socket_tuneables.h \
+	pvmf_socket_buffer_allocators.h
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_factory.h b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_factory.h
new file mode 100644
index 0000000..05d13ad
--- /dev/null
+++ b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_factory.h
@@ -0,0 +1,69 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CLIENTSERVER_SOCKET_NODE_FACTORY_H_INCLUDED
+#define PVMF_CLIENTSERVER_SOCKET_NODE_FACTORY_H_INCLUDED
+
+#ifndef OSCL_SOCKET_TYPES_H_INCLUDED
+#include "oscl_socket_types.h"
+#endif
+#ifndef OSCL_SOCKET_H_INCLUDED
+#include "oscl_socket.h"
+#endif
+#ifndef PVMF_CLIENTSERVER_SOCKET_NODE_H_INCLUDED
+#include "pvmf_clientserver_socket_node.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+// Forward declaration
+class PVMFNodeInterface;
+
+/**
+ * PVMFClientServerSocketNodeFactory Class
+ *
+ * PVMFClientServerSocketNodeFactory class is a singleton class which instantiates and provides
+ * access to PVMF socket node. It returns a PVMFNodeInterface
+ * reference, the interface class of the PVMFClientServerSocketNode.
+ *
+ * The client is expected to contain and maintain a pointer to the instance created
+ * while the node is active.
+ */
+class PVMFClientServerSocketNodeFactory
+{
+    public:
+        /**
+         * Creates an instance of a PVMFClientServerSocketNode. If the creation fails, this function will leave.
+         *
+         * @param aPriority The active object priority for the node. Default is standard priority if not specified
+         * @returns A pointer to an instance of PVMFClientServerSocketNode as PVMFNodeInterface reference or leaves if instantiation fails
+         **/
+        OSCL_IMPORT_REF static PVMFNodeInterface* CreateClientServerSocketNode(OsclTCPSocket* aSocketHandle, int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        /**
+         * Deletes an instance of PVMFClientServerSocketNode
+         * and reclaims all allocated resources.  An instance can be deleted only in
+         * the idle state. An attempt to delete in any other state will fail and return false.
+         *
+         * @param aNode The PVMFClientServerSocketNode instance to be deleted
+         * @returns A status code indicating success or failure of deletion
+         **/
+        OSCL_IMPORT_REF static bool DeleteClientServerSocketNode(PVMFNodeInterface* aNode);
+};
+
+#endif // PVMF_CLIENTSERVER_SOCKET_NODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_node.h b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_node.h
new file mode 100644
index 0000000..33e7f1e
--- /dev/null
+++ b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_node.h
@@ -0,0 +1,485 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CLIENTSERVER_SOCKET_NODE_H_INCLUDED
+#define PVMF_CLIENTSERVER_SOCKET_NODE_H_INCLUDED
+
+#ifndef OSCL_SOCKET_TYPES_H_INCLUDED
+#include "oscl_socket_types.h"
+#endif
+#ifndef PVMF_CLIENTSERVER_SOCKET_TUNEABLES_H_INCLUDED
+#include "pvmf_clientserver_socket_tuneables.h"
+#endif
+
+#ifndef PVMF_CLIENTSERVER_SOCKET_PORT_H_INCLUDED
+#include "pvmf_clientserver_socket_port.h"
+#endif
+
+//Logger macros
+#define PVMF_SOCKETNODE_LOGSTACKTRACE(m)	PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_STACK_TRACE,m);
+#define PVMF_SOCKETNODE_LOGINFO(m)			PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_INFO,m);
+#define PVMF_SOCKETNODE_LOGERROR(m)			PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+
+//memory allocator type for this node.
+typedef OsclMemAllocator PVMFSocketNodeAllocator;
+
+//Node command type.
+typedef PVMFGenericNodeCommand<PVMFSocketNodeAllocator> PVMFSocketNodeCommandBase;
+class PVMFSocketNodeCommand: public PVMFSocketNodeCommandBase
+{
+    public:
+
+};
+
+//Default vector reserve size
+#define PVMF_SOCKET_NODE_COMMAND_VECTOR_RESERVE 10
+
+//Starting value for command IDs
+#define PVMF_SOCKET_NODE_COMMAND_ID_START 6000
+
+class PVLogger;
+class PVMFClientServerSocketPort;
+
+/**
+ * Mem pool class
+ */
+class PVMFSocketNodeMemPool
+{
+    public:
+        PVMFSocketNodeMemPool(uint32 aMemPoolNumBufs = DEFAULT_SOCKET_NODE_MEDIA_MSGS_NUM);
+
+        virtual ~PVMFSocketNodeMemPool()
+        {
+            if (iMediaDataMemPool != NULL)
+            {
+                iMediaDataMemPool->removeRef();
+                iMediaDataMemPool = NULL;
+            }
+        };
+
+        OsclSharedPtr<PVMFMediaDataImpl> getMediaDataImpl(uint32 size)
+        {
+            return (iSocketAllocSharedPtr->createSharedBuffer(size));
+        }
+
+        void resizeSocketDataBuffer(OsclSharedPtr<PVMFMediaDataImpl>& aSharedBuffer)
+        {
+            if (iSocketAllocSharedPtr.GetRep() != NULL)
+            {
+                iSocketAllocSharedPtr->ResizeMemoryFragment(aSharedBuffer);
+            }
+        }
+
+        void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& aObserver,
+                                      uint32 aSize,
+                                      OsclAny* aContextData = NULL)
+        {
+            if (iSocketAllocSharedPtr.GetRep() != NULL)
+            {
+                iSocketAllocSharedPtr->notifyfreechunkavailable(aObserver, aSize, aContextData);
+            }
+        }
+
+        void CancelFreeChunkAvailableCallback()
+        {
+            if (iSocketAllocSharedPtr.GetRep() != NULL)
+            {
+                iSocketAllocSharedPtr->CancelFreeChunkAvailableCallback();
+            }
+        }
+
+        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> iSocketAllocSharedPtr;
+
+        // Memory pool for media data objects
+        OsclMemPoolFixedChunkAllocator* iMediaDataMemPool;
+
+        int32 iPortTag;
+
+        // Allocator created in this node, for TCP only.
+        PVMFSMSharedBufferAllocWithReSize* iInternalAlloc;
+};
+
+class PVMFClientServerSocketNode;
+
+/*
+** Socket activity class is used to save Oscl socket or DNS results
+*/
+class PVMFSocketActivity
+{
+    public:
+        PVMFSocketActivity(): iValid(false)
+        {
+        }
+        PVMFSocketActivity(PVMFStatus aStatus, int32 aId, int32 aFxn, int32 aEvent, int32 aError)
+        {
+            Set(aStatus, aId, aFxn, aEvent, aError);
+        }
+        void Set(PVMFStatus aStatus, int32 aId, int32 aFxn, int32 aEvent, int32 aError)
+        {
+            iValid = true;
+            iStatus = aStatus;
+            iId = aId;
+            iFxn = aFxn;
+            iEvent = aEvent;
+            iError = aError;
+        }
+        bool iValid;
+        PVMFStatus iStatus;
+        int32 iId;
+        int32 iFxn;
+        int32 iEvent;
+        int32 iError;
+
+    private:
+
+};
+
+//Individual asynchronous operations and wait states that make up a send sequence.
+enum TPVSocketPortSendOperation
+{
+    EPVSocketPortSendOperation_None
+    , EPVSocketPortSendOperation_Send
+    , EPVSocketPortSendOperation_Last
+};
+
+//Individual asynchronous operations and wait states that make up a receive sequence.
+enum TPVSocketPortRecvOperation
+{
+    EPVSocketPortRecvOperation_None
+    , EPVSocketPortRecvOperation_Recv
+    , EPVSocketPortRecvOperation_WaitOnConnectedPort
+    , EPVSocketPortRecvOperation_WaitOnMemory
+    , EPVSocketPortRecvOperation_Last
+};
+
+enum TPVSocketPortSequence
+{
+    EPVSocketPortSequence_None
+    , EPVSocketPortSequence_RequestPort
+    , EPVSocketPortSequence_InputDataMsg
+    , EPVSocketPortSequence_InputDisconnectMsg
+    , EPVSocketPortSequence_SocketCleanup
+    , EPVSocketPortSequence_Last
+};
+
+class SocketPortState
+{
+    public:
+        SocketPortState(): iSequence(EPVSocketPortSequence_None)
+                , iSequenceStatus(PVMFSuccess)
+                , iSendOperation(EPVSocketPortSendOperation_None)
+                , iSendOperationStatus(PVMFSuccess)
+                , iSendOperationCanceled(false)
+                , iRecvOperation(EPVSocketPortRecvOperation_None)
+                , iRecvOperationStatus(PVMFSuccess)
+                , iRecvOperationCanceled(false)
+        {}
+
+        TPVSocketPortSequence iSequence;
+        PVMFStatus iSequenceStatus;
+
+        TPVSocketPortSendOperation iSendOperation;
+        PVMFStatus iSendOperationStatus;
+        bool iSendOperationCanceled;
+
+        TPVSocketPortRecvOperation iRecvOperation;
+        PVMFStatus iRecvOperationStatus;
+        bool iRecvOperationCanceled;
+};
+
+/*
+** SocketPortConfig contains all the information associated with a port including
+** the Oscl socket, memory pool, and status.
+*/
+class SocketPortConfig : public OsclMemPoolFixedChunkAllocatorObserver
+{
+    public:
+        SocketPortConfig()
+        {
+            iPVMFPort = NULL;
+            iSockId = 0;
+            iTCPSocket = NULL;
+            iMemPool	= NULL;
+            iContainer = NULL;
+            iTag = PVMF_CLIENTSERVER_SOCKET_NODE_PORT_TYPE_UNKNOWN;
+        };
+
+        void DoSetSocketPortMemAllocator(PVLogger*, OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc);
+        void CleanupMemPools();
+
+        void freechunkavailable(OsclAny* aContextData);
+
+        SocketPortState iState;
+
+        PVMFClientServerSocketPort *iPVMFPort;
+        uint32	iSockId;
+        OsclTCPSocket* iTCPSocket;
+
+        //socket pending request and state
+        PVMFSharedMediaDataPtr iPendingRecvMediaData, iPendingSendMediaData;
+
+        //Fixed chunk memory pool for media messages
+        PVMFSocketNodeMemPool *iMemPool;
+
+        PVMFClientServerSocketNode* iContainer;
+        int32 iTag;
+
+        PVMFSocketActivity iSocketRecvActivity;
+};
+
+/*
+** Memory pool sizes.
+*/
+#define SIMPLE_MEDIA_BUF_CLASS_SIZE 128 /*oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer) + oscl_mem_aligned_size(sizeof(OsclRefCounterSA<SimpleMediaBufferCombinedCleanupSA>)*/
+#define MEDIA_DATA_CLASS_SIZE 128 /*oscl_mem_aligned_size(sizeof(PVMFMediaData)) + oscl_mem_aligned_size(sizeof(OsclRefCounterDA)) + oscl_mem_aligned_size(sizeof(MediaDataCleanupDA)) + sizeof(PVMFMediaMsgHeader))*/
+
+/*
+** The Socket Node
+*/
+class PVMFClientServerSocketNode  :	public PVMFNodeInterface
+            , public OsclActiveObject
+            , public OsclSocketObserver
+{
+    public:
+
+        OSCL_IMPORT_REF PVMFClientServerSocketNode(OsclTCPSocket* aSocketHandle, int32 aPriority);
+        OSCL_IMPORT_REF ~PVMFClientServerSocketNode();
+
+
+        //**********begin PVMFSocketNodeExtensionInterface
+        OSCL_IMPORT_REF void addRef();
+        OSCL_IMPORT_REF void removeRef();
+        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        OSCL_IMPORT_REF PVMFStatus AllocateConsecutivePorts(PvmfMimeString* aPortConfig,
+                uint32& aLowerPortNum,
+                uint32& aHigherPortNum, uint32& aStartPortNum);
+        OSCL_IMPORT_REF PVMFStatus SetMaxTCPRecvBufferSize(uint32 aBufferSize);
+        OSCL_IMPORT_REF PVMFStatus GetMaxTCPRecvBufferSize(uint32& aSize);
+        OSCL_IMPORT_REF PVMFStatus SetMaxTCPRecvBufferCount(uint32 aBufferSize);
+        OSCL_IMPORT_REF PVMFStatus GetMaxTCPRecvBufferCount(uint32& aSize);
+
+        //**********end PVMFSocketNodeExtensionInterface
+
+        //************ begin OsclSocketObserver
+        OSCL_IMPORT_REF void HandleSocketEvent(int32 aId, TPVSocketFxn aFxn, TPVSocketEvent aEvent, int32 aError);
+        //************ end OsclSocketObserver
+
+        //from PVMFNodeInterface
+        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, PVMFSocketNodeAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession
+                , int32 aPortTag
+                , const PvmfMimeString* aPortConfig = NULL
+                                                      , const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+
+        //from PVMFPortActivityHandler
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        //These are some extra APIs that are used by Streaming Manager and are unique to socket node.
+        OSCL_IMPORT_REF bool GetPortConfig(PVMFPortInterface &aPort, OsclNetworkAddress &aLocalAdd, OsclNetworkAddress &aRemoteAdd);
+        OSCL_IMPORT_REF bool SetPortConfig(PVMFPortInterface &aPort, OsclNetworkAddress aLocalAdd, OsclNetworkAddress aRemoteAdd);
+
+        PVMFStatus CloseSocketConnection();
+        OSCL_IMPORT_REF bool setSocketPortMemAllocator(PVMFPortInterface* aPort,
+                OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc);
+
+
+    private:
+        friend class SocketPortConfig;
+
+        //from OsclActiveObject
+        void Run();
+
+        /*********************************************
+        * Socket extension interface
+        **********************************************/
+
+        // Reference counter for extension
+        uint32 iExtensionRefCount;
+
+        /*********************************************
+        * Command Processing and Event Notification
+        **********************************************/
+
+        //Command queue type
+        typedef PVMFNodeCommandQueue<PVMFSocketNodeCommand, PVMFSocketNodeAllocator> PVMFSocketNodeCmdQ;
+
+        PVMFSocketNodeCmdQ iPendingCmdQueue;
+        PVMFSocketNodeCmdQ iCurrentCmdQueue;
+        PVMFSocketNodeCmdQ iCancelCmdQueue;
+
+        void MoveCmdToCancelQueue(PVMFSocketNodeCommand& aCmd);
+
+        void CommandComplete(PVMFSocketNodeCmdQ&,
+                             PVMFSocketNodeCommand&,
+                             PVMFStatus,
+                             OsclAny* aData = NULL,
+                             PVUuid* aEventUUID = NULL,
+                             int32* aEventCode = NULL);
+
+        void ReportErrorEvent(PVMFEventType aEventType,
+                              OsclAny* aEventData = NULL,
+                              PVUuid* aEventUUID = NULL,
+                              int32* aEventCode = NULL);
+
+        void ReportInfoEvent(PVMFEventType aEventType,
+                             OsclAny* aEventData = NULL,
+                             PVUuid* aEventUUID = NULL,
+                             int32* aEventCode = NULL);
+
+        PVMFCommandId QueueCommandL(PVMFSocketNodeCommand& aCmd);
+
+        bool CanProcessCommand();
+        void ProcessCommand(PVMFSocketNodeCmdQ& aCmdQ, PVMFSocketNodeCommand&);
+
+        //Command handlers.
+        PVMFStatus DoRequestPort(PVMFSocketNodeCommand& aCmd);
+        PVMFStatus DoReset(PVMFSocketNodeCommand&);
+        PVMFStatus DoQueryUuid(PVMFSocketNodeCommand&);
+        PVMFStatus DoQueryInterface(PVMFSocketNodeCommand&);
+        PVMFStatus DoReleasePort(PVMFSocketNodeCommand&);
+        PVMFStatus DoInit(PVMFSocketNodeCommand&);
+        PVMFStatus DoPrepare(PVMFSocketNodeCommand&);
+        PVMFStatus DoStart(PVMFSocketNodeCommand&);
+        PVMFStatus DoStop(PVMFSocketNodeCommand&);
+        PVMFStatus DoFlush(PVMFSocketNodeCommand&);
+        PVMFStatus DoPause(PVMFSocketNodeCommand&);
+        PVMFStatus DoCancelAllCommands(PVMFSocketNodeCommand&);
+        PVMFStatus DoCancelCommand(PVMFSocketNodeCommand&);
+
+        PVMFStatus DoCancelCurrentCommand(PVMFSocketNodeCmdQ& aCmdQ, PVMFSocketNodeCommand& aCmd);
+        PVMFStatus DoStopNodeActivity();
+        //PVMFClientServerSocketPort* iRequestedPort;
+
+        //node state
+        void ChangeExternalState(TPVMFNodeInterfaceState aNewState)
+        {
+            iInterfaceState = aNewState;
+        }
+
+        //for error messages.
+        int32 iCommandErrorCode;
+        int32 iErrorEventErrorCode;
+        void ReportSocketNodeError(PVMFStatus aStatus, PVMFSocketNodeErrorEventType aEvent)
+        {
+            PVUuid eventuuid = PVMFSocketNodeEventTypeUUID;
+            iErrorEventErrorCode = aEvent;
+            ReportErrorEvent(aStatus, NULL, &eventuuid, &iErrorEventErrorCode);
+        }
+
+        //Used to stop all port activity, this var counts down from N to 0, or
+        //has a value of (-1) to indicate it's inactive
+        int32 iNumStopPortActivityPending;
+
+        /*********************************************
+        * Oscl Socket Handling
+        **********************************************/
+
+        void HandleRecvComplete(PVMFStatus, PVMFSocketActivity*, bool);
+
+        OsclSocketServ	*iSockServ;
+
+        const int TIMEOUT_CONNECT;
+        const int TIMEOUT_SEND;
+        const int TIMEOUT_RECV;
+        const int TIMEOUT_SHUTDOWN;
+
+        int32 iMaxTcpRecvBufferSize;
+        int32 iMaxTcpRecvBufferCount;
+
+        /*********************************************
+        * Port Data Handling
+        **********************************************/
+
+        bool CanProcessIncomingMsg();
+
+        void ProcessIncomingMsg();
+
+
+        /*********************************************
+        * Port & Socket Creation
+        **********************************************/
+
+        PVMFStatus AllocatePortMemPool(int32 tag, PVMFSocketNodeMemPool* & aMemPool);
+        PVMFStatus AddPort(int32 tag);
+        void CleanupTCP();
+        void CleanupPorts();
+
+        uint32 iSocketID;
+
+        /*********************************************
+        * Port Data
+        **********************************************/
+
+        PVMFClientServerSocketPort* iPVMFPort;
+
+        /*********************************************
+        * Operation and Sequence Handlers
+        **********************************************/
+
+        PVMFStatus StartSequence(TPVSocketPortSequence, OsclAny* param = NULL);
+        void SequenceComplete(PVMFStatus);
+
+        bool CanReceive();
+
+        PVMFStatus StartRecvOperation();
+        PVMFStatus StartSendOperation(PVMFSharedMediaMsgPtr& aMsg);
+        void StartRecvWaitOnMemory(int32 aSize = 0);
+        void StartRecvWaitOnConnectedPort(PVMFSocketActivity& aSocketActivity);
+
+        PVMFStatus SendOperationComplete(PVMFStatus, PVMFSocketActivity*);
+        PVMFStatus RecvOperationComplete(PVMFStatus, PVMFSocketActivity*);
+
+        PVMFStatus CancelSendOperation();
+        PVMFStatus CancelRecvOperation();
+
+        /*********************************************
+        * Loggers, Error Trap, Allocator
+        **********************************************/
+
+        PVLogger *iLogger;
+        PVLogger *iDataPathLogger;
+        OsclErrorTrapImp* iOsclErrorTrapImp;
+        OsclTCPSocket* iSocketHandle;
+
+        PVMFSocketNodeAllocator iAlloc;
+        SocketPortConfig* iSockConfig;
+};
+
+#endif //PVMF_CLIENTSERVER_SOCKET_NODE_H_INCLUDED
+
diff --git a/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_port.h b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_port.h
new file mode 100644
index 0000000..8db36c0
--- /dev/null
+++ b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_port.h
@@ -0,0 +1,153 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_clientserver_socket_port.h
+ */
+
+#ifndef PVMF_CLIENTSERVER_SOCKET_PORT_H_INCLUDED
+#define PVMF_CLIENTSERVER_SOCKET_PORT_H_INCLUDED
+
+#ifndef OSCL_SOCKET_H_INCLUDED
+#include "oscl_socket.h"
+#endif
+#ifndef PVMF_SOCKET_BUFFER_ALLOCATORS_H_INCLUDED
+#include "pvmf_socket_buffer_allocators.h"
+#endif
+#ifndef PVMI_PORT_CONFIG_KVP_H_INCLUDED
+#include "pvmi_port_config_kvp.h"
+#endif
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+//Default vector reserve size
+#define PVMF_CLIENTSERVER_SOCKET_NODE_PORT_VECTOR_RESERVE 10
+
+
+// Capability mime strings
+#define PVMF_CLIENTSERVER_SOCKET_PORT_SPECIFIC_ALLOCATOR "x-pvmf/pvmfsocket/socketmemallocator"
+#define PVMF_CLIENTSERVER_SOCKET_PORT_SPECIFIC_ALLOCATOR_VALTYPE "x-pvmf/pvmfsocket/socketmemallocator;valtype=ksv"
+
+#define PVMFSocketNodePortTag int32
+
+/** Enumerated list of port tags supported by this port */
+
+typedef enum
+{
+    PVMF_CLIENTSERVER_SOCKET_NODE_PORT_TYPE_UNKNOWN,
+    PVMF_CLIENTSERVER_SOCKET_NODE_PORT_TYPE_SOURCE,
+    PVMF_CLIENTSERVER_SOCKET_NODE_PORT_TYPE_SINK,
+    PVMF_CLIENTSERVER_SOCKET_NODE_PORT_TYPE_PASSTHRU
+} PVMFClientServerSocketNodePortTag;
+
+
+class PVMFClientServerSocketNode;
+class SocketPortConfig;
+
+
+class PVMFClientServerSocketPort :	public PvmfPortBaseImpl,
+            public PvmiCapabilityAndConfigPortFormatImpl
+{
+    public:
+        /**
+         * Default constructor. Default settings will be used for the data queues.
+         * @param aId ID assigned to this port
+         * @param aTag Port tag
+         * @param aNode Container node
+         */
+        PVMFClientServerSocketPort(int32 aTag, PVMFPortActivityHandler* aNode);
+
+        /**
+         * Constructor that allows the node to configure the data queues of this port.
+         * @param aTag Port tag
+         * @param aNode Container node
+         * @param aSize Data queue capacity. The data queue size will not grow beyond this capacity.
+         * @param aReserve Size of data queue for which memory is reserved. This must be
+         * less than or equal to the capacity. If this is less than capacity, memory will be
+         * allocated when the queue grows beyond the reserve size, but will stop growing at
+         * capacity.
+         * @param aThreshold Ready-to-receive threshold, in terms of percentage of the data queue capacity.
+         * This value should be between 0 - 100.
+         */
+        PVMFClientServerSocketPort(int32 aTag
+                                   , PVMFPortActivityHandler* aNode
+                                   , uint32 aInCapacity
+                                   , uint32 aInReserve
+                                   , uint32 aInThreshold
+                                   , uint32 aOutCapacity
+                                   , uint32 aOutReserve
+                                   , uint32 aOutThreshold);
+
+        /** Destructor */
+        ~PVMFClientServerSocketPort();
+
+        // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface
+        bool IsFormatSupported(PVMFFormatType);
+        void FormatUpdated();
+
+        // this port supports config interface
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+                aPtr = (PvmiCapabilityAndConfig*)this;
+            else
+                aPtr = NULL;
+        }
+
+        PVMFStatus getParametersSync(PvmiMIOSession aSession,
+                                     PvmiKeyType aIdentifier,
+                                     PvmiKvp*& aParameters,
+                                     int& num_parameter_elements,
+                                     PvmiCapabilityContext aContext);
+
+
+        void setParametersSync(PvmiMIOSession aSession,
+                               PvmiKvp* aParameters,
+                               int num_elements,
+                               PvmiKvp * & aRet_kvp);
+
+
+        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        PVMFStatus PeekIncomingMsg(PVMFSharedMediaMsgPtr& aMsg);
+
+        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> iAllocSharedPtr;
+
+        SocketPortConfig* iConfig;
+        PVMFSocketNodePortTag iPortTag;
+
+        //overrides from PVMFPortInterface so we can skip the outgoing port queue.
+        PVMFStatus QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg);
+        bool IsOutgoingQueueBusy();
+
+    private:
+        void Construct();
+        bool pvmiGetPortInPlaceDataProcessingInfoSync(const char* aFormatValType, PvmiKvp*& aKvp);
+        PVLogger *iLogger;
+
+        uint32 iNumFramesConsumed; //number of frames consumed & discarded.
+
+        friend class PVMFSocketNode;
+        friend class Oscl_TAlloc<PVMFClientServerSocketPort, OsclMemAllocator>;
+        friend class PVMFSocketNodeCustomInterface1Impl;
+};
+
+#endif //PVMF_CLIENTSERVER_SOCKET_PORT_H_INCLUDED
+
+
+
diff --git a/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_tuneables.h b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_tuneables.h
new file mode 100644
index 0000000..b6d29fd
--- /dev/null
+++ b/nodes/pvclientserversocketnode/include/pvmf_clientserver_socket_tuneables.h
@@ -0,0 +1,92 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_clientserver_socket_tuneables.h
+ */
+
+#ifndef PVMF_CLIENTSERVER_SOCKET_TUNEABLES_H_INCLUDED
+#define PVMF_CLIENTSERVER_SOCKET_TUNEABLES_H_INCLUDED
+
+#ifndef OSCL_SOCKET_H_INCLUDED
+#include "oscl_socket.h"
+#endif
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+
+#define PVMFSocketNodeEventTypeUUID PVUuid(0xbe846567,0xae17,0x44c8,0x9c,0x9a,0x87,0xb8,0x33,0xa0,0xf9,0x1d)
+
+
+#define DEFAULT_SOCKET_NODE_MEDIA_MSGS_NUM 1
+#define PVMF_SOCKET_NODE_PORT_VECTOR_RESERVE 10
+
+const PVUid32 PVMF_MEDIA_CMD_SOCKET_CONNECT_FORMAT_ID    = 0x00000200;
+const PVUid32 PVMF_MEDIA_CMD_SOCKET_DISCONNECT_FORMAT_ID = 0x00000201;
+
+#define SNODE_DEFAULT_SOCKET_TCP_BUFFER_SIZE		(4096)
+#define SNODE_DEFAULT_MAX_TCP_RECV_BUFFER_SIZE		(4*1024)
+
+#define SNODE_DEFAULT_SOCKET_TCP_BUFFER_COUNT		8
+#define SNODE_DEFAULT_NUMBER_MEDIADATA_IN_MEMPOOL	4
+
+#define MAX_SOCKET_BUFFER_SIZE						(16*1024)
+#define DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES		 100
+
+#define DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_FEEDBACK_PORT  32*1024
+#define DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT  \
+                (32*1024 + 2*MAX_SOCKET_BUFFER_SIZE)
+
+#define MIN_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT		0
+#define MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT		128*1024
+
+/**
+ * An enumeration of error codes from PVMFSocketNode
+ **/
+typedef enum
+{
+    PVMFSocketNodeErrorEventStart = 1024,
+    PVMFSocketNodeErrorSocketServerCreateError,
+    PVMFSocketNodeErrorSocketServConnectError,
+    PVMFSocketNodeErrorTCPSocketRecvError,
+    PVMFSocketNodeErrorTCPSocketSendError,
+    PVMFSocketNodeError_TCPSocketConnect,
+    PVMFSocketNodeErrorSocketFailure,
+    PVMFSocketNodeErrorSocketTimeOut,
+    PVMFSocketNodeErrorInvalidPortTag,
+    PVMFSocketNodeErrorInvalidPortConfig,
+    PVMFSocketNodeErrorConnectCancelled,
+    PVMFSocketNodeErrorEventEnd
+} PVMFSocketNodeErrorEventType;
+
+#endif	//PVMF_CLIENTSERVER_SOCKET_TUNEABLES_H_INCLUDED
diff --git a/nodes/pvclientserversocketnode/include/pvmf_socket_buffer_allocators.h b/nodes/pvclientserversocketnode/include/pvmf_socket_buffer_allocators.h
new file mode 100644
index 0000000..cc3460d
--- /dev/null
+++ b/nodes/pvclientserversocketnode/include/pvmf_socket_buffer_allocators.h
@@ -0,0 +1,1649 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SOCKET_BUFFER_ALLOCATORS_H_INCLUDED
+#define PVMF_SOCKET_BUFFER_ALLOCATORS_H_INCLUDED
+
+#ifndef PVMF_CLIENTSERVER_SOCKET_TUNEABLES_H_INCLUDED
+#include "pvmf_clientserver_socket_tuneables.h"
+#endif
+#ifndef OSCL_DEFALLOC_H_INCLUDED
+#include "oscl_defalloc.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#define PVMF_RESIZE_ALLOC_OVERHEAD 8
+#define PVMF_RESIZE_ALLOC_BLK_SIZE_OFFSET 4
+
+// constants
+const uint PVMF_SOCKET_BUF_DEFAULT_SIZE = 200;
+
+#define PVMF_SOCKALLOC_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define PVMF_SOCKALLOC_LOGWARNING(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_WARNING,m);
+#define PVMF_SOCKALLOC_LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
+#define PVMF_SOCKALLOC_LOGINFO(m) PVMF_SOCKALLOC_LOGINFOLOW(m)
+#define PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC(m) PVMF_SOCKALLOC_LOGINFO(m)
+#define PVMF_SOCKALLOC_LOG_SEQNUM_ALLOC_DEALLOC(m) PVMF_SOCKALLOC_LOGINFO(m)
+#define PVMF_SOCKALLOC_LOG_OUT_OF_ORDER_DEALLOC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iOOOLogger,PVLOGMSG_INFO,m);
+#define PVMF_SOCKALLOC_LOG_MEMCALLBACK(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iCallBackLogger,PVLOGMSG_INFO,m);
+#define PVMF_SOCKALLOC_LOG_AVAILABILITY(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSizeLogger,PVLOGMSG_INFO,m);
+
+#define PVMF_SOCKALLOC_FILL_MEMBLK_ON_ALLOC 1
+
+static const char PVMF_SOCKALLOC_FEEDBACK_PORT_NAME[] = "PVMFJitterBufferPortFeedBack";
+
+class PVMFSMSharedBufferAllocWithReSizeAllocDeallocObserver
+{
+    public:
+        virtual void chunkdeallocated(OsclAny* aContextData) = 0;
+};
+
+/*
+ * This allocator is used to allocate socket buffers, for the purpose of
+ * doing a receive.
+ */
+class PVMFSocketBufferAllocator : public Oscl_DefAlloc
+{
+    public:
+        PVMFSocketBufferAllocator(uint32 numChunks, uint32 chunkSize)
+                : alloc(numChunks, chunkSize)
+        {
+            iNumChunks = numChunks;
+            iChunkSize = chunkSize;
+            iNumOutStandingBuffers = 0;
+            IncrementKeepAliveCount();
+        };
+
+        virtual ~PVMFSocketBufferAllocator() {};
+
+        void IncrementKeepAliveCount()
+        {
+            iNumOutStandingBuffers++;
+        }
+
+        void DecrementKeepAliveCount()
+        {
+            iNumOutStandingBuffers--;
+        }
+
+        OsclAny* allocate(const uint32 n)
+        {
+            iNumOutStandingBuffers++;
+            return (alloc.allocate(n));
+        }
+
+        void deallocate(OsclAny* p)
+        {
+            iNumOutStandingBuffers--;
+            alloc.deallocate(p);
+        }
+
+        uint32 getNumOutStandingBuffers()
+        {
+            return iNumOutStandingBuffers;
+        }
+
+        uint32 getAvailableBufferSpace(bool aFirstParentChunkOnly = false)
+        {
+            OSCL_UNUSED_ARG(aFirstParentChunkOnly);
+            if (iNumChunks > iNumOutStandingBuffers)
+            {
+                return ((iNumChunks - iNumOutStandingBuffers)*iChunkSize);
+            }
+            return 0;
+        }
+        void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& aObserver,
+                                      uint32 aSize,
+                                      OsclAny* aContextData = NULL)
+        {
+            OSCL_UNUSED_ARG(aSize);
+            alloc.notifyfreechunkavailable(aObserver, aContextData);
+        }
+
+        void CancelFreeChunkAvailableCallback()
+        {
+            alloc.CancelFreeChunkAvailableCallback();
+        }
+
+    private:
+        uint32 iNumChunks;
+        uint32 iChunkSize;
+        OsclMemPoolFixedChunkAllocator alloc;
+        uint32 iNumOutStandingBuffers;
+};
+
+class PVMFSocketBufferCleanupDA : public OsclDestructDealloc
+{
+    public:
+        PVMFSocketBufferCleanupDA(Oscl_DefAlloc* in_gen_alloc) :
+
+
+                gen_alloc(in_gen_alloc) {};
+
+        virtual ~PVMFSocketBufferCleanupDA() {};
+
+        virtual void destruct_and_dealloc(OsclAny* ptr)
+        {
+            gen_alloc->deallocate(ptr);
+            /*
+             * in case there are no outstanding buffers delete the allocator
+             */
+            PVMFSocketBufferAllocator* socketDataAllocator =
+                reinterpret_cast<PVMFSocketBufferAllocator*>(gen_alloc);
+
+            uint32 numBuffers = socketDataAllocator->getNumOutStandingBuffers();
+
+            if (numBuffers == 0)
+            {
+                OSCL_DELETE((socketDataAllocator));
+            }
+        }
+
+    private:
+        Oscl_DefAlloc* gen_alloc;
+};
+
+class PVMFSMSharedBufferAllocWithReSize : public Oscl_DefAlloc
+{
+    public:
+        PVMFSMSharedBufferAllocWithReSize(uint32 aParentChunkSize, const char name[])
+        {
+            iLogger = NULL;
+            iSizeLogger = NULL;
+            iOOOLogger = NULL;
+            iLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize");
+            iSizeLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize.availability");
+            iCallBackLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize.memcallback");
+            iOOOLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize.ooo");
+            iName = name;
+
+            iNumOutOfOrderDeallocs = 0;
+            iLastDeallocatedSeqNum = 0;
+            iSeqCount = 1;
+            iNumOutStandingBuffers = 0;
+
+            iCallbackPending = false;
+            iCallbackRequestSize = 0;;
+            iObserver = NULL;
+            iNextAvailableContextData = NULL;
+
+            iJJDataSize = 0;
+            iJJDataDbgSize = 0;
+
+            if ((int32)aParentChunkSize <= 0)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize - Invalid Parent Chunk size"));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+
+            // set buffer resizing to default values
+            if (oscl_strcmp(iName.get_cstr(), PVMF_SOCKALLOC_FEEDBACK_PORT_NAME) == 0)
+            {
+                iiRegrowthSize = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_FEEDBACK_PORT;
+            }
+            else
+            {
+                iiRegrowthSize = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+            }
+            iiMaxNumGrows = DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES;
+            iiNumGrows = 0;
+
+            iDeallocObserver = NULL;
+            iDeallocNotificationContextData = NULL;
+
+            CreateParentChunk(aParentChunkSize);
+
+            IncrementKeepAliveCount();
+        }
+
+        PVMFSMSharedBufferAllocWithReSize(uint32 aParentChunkSize, const char name[],
+                                          int aMaxNumGrows, int aGrowSize)
+        {
+            iLogger = NULL;
+            iSizeLogger = NULL;
+            iOOOLogger = NULL;
+            iLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize");
+            iSizeLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize.availability");
+            iCallBackLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize.memcallback");
+            iOOOLogger = PVLogger::GetLoggerObject("PVMFSMSharedBufferAllocWithReSize.ooo");
+            iName = name;
+            iCallbackPending = false;
+            iNumOutOfOrderDeallocs = 0;
+            iLastDeallocatedSeqNum = -1;
+            iSeqCount = 0;
+            iNumOutStandingBuffers = 0;
+
+            iJJDataSize = 0;
+            iJJDataDbgSize = 0;
+            if ((int32)aParentChunkSize <= 0)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize - Invalid Parent Chunk size"));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+
+            // set buffer resizing to specified values
+            iiRegrowthSize = aGrowSize;
+            iiMaxNumGrows = aMaxNumGrows;
+            iiNumGrows = 0;
+
+            iDeallocObserver = NULL;
+            iDeallocNotificationContextData = NULL;
+
+            CreateParentChunk(aParentChunkSize);
+            IncrementKeepAliveCount();
+        }
+
+        void CreateParentChunk(uint32 aSize)
+        {
+            ParentChunkContainer parentChunkContainer;
+
+            parentChunkContainer.id = iParentChunkContainerVec.size();
+            parentChunkContainer.iParentChunkSize = aSize;
+            parentChunkContainer.iParentChunkStart =
+                (uint8*)(alloc.ALLOCATE(aSize));
+            parentChunkContainer.iParentChunkEnd =
+                parentChunkContainer.iParentChunkStart + aSize;
+            parentChunkContainer.iAllocationPtr =
+                parentChunkContainer.iParentChunkStart;
+
+            iParentChunkContainerVec.push_back(parentChunkContainer);
+            PVMF_SOCKALLOC_LOGINFO((0, "PVMFSMSharedBufferAllocWithReSize::CreateParentChunk - Name=%s, Size=%d", iName.get_cstr(), aSize));
+        }
+
+        virtual ~PVMFSMSharedBufferAllocWithReSize()
+        {
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+
+            for (it = iParentChunkContainerVec.begin();
+                    it != iParentChunkContainerVec.end();
+                    it++)
+            {
+                alloc.deallocate(it->iParentChunkStart);
+            }
+
+            if (iNumOutOfOrderDeallocs != 0)
+            {
+                OSCL_ASSERT(false);
+            }
+
+            iParentChunkContainerVec.clear();
+            iLogger = NULL;
+            iJJDataSize = 0;
+            iJJDataDbgSize = 0;
+            iNumOutStandingBuffers = 0;
+            iSeqCount = 0;
+            iLastDeallocatedSeqNum = -1;
+            iNumOutOfOrderDeallocs = 0;
+            iDeallocObserver = NULL;
+        };
+
+        /*
+         * This allocator is used to create shared buffer which could have a lifetime
+         * that is longer than the module that actually created the allocator. Hence
+         * it is implemented in such a way that this allocator would de destroyed when
+         * all the outstanding buffers allocated by this alloacator are deallocated. Or
+         * in other words this allocator would be destroyed if and when iNumOutStandingBuffers
+         * becomes zero. This could cause problems when due to transient nature of data flow
+         * iNumOutStandingBuffers could become zero when the data flow drys up temporarily.
+         * Under such a scenario we would end up deleting the allocator prematurely. Inorder
+         * to avoid this, these keep alive mechanisms are provided. This ensures that the
+         * module that created the allocator can make sure that the allocator is alive atleast
+         * till its lifetime. Therefore allocator's life is the maximum of:
+         * (buffer life times, allocator creator's life time)
+         */
+        void IncrementKeepAliveCount()
+        {
+            iDecKeepAliveCalled = false;
+            iNumOutStandingBuffers++;
+            PVMF_SOCKALLOC_LOGINFO((0, "PVMFSMSharedBufferAllocWithReSize::IncrementKeepAliveCount - Name=%s, iNumOutStandingBuffers=%d", iName.get_cstr(), iNumOutStandingBuffers));
+        }
+
+        void DecrementKeepAliveCount()
+        {
+            iDecKeepAliveCalled = true;
+            iNumOutStandingBuffers--;
+            PVMF_SOCKALLOC_LOGINFO((0, "PVMFSMSharedBufferAllocWithReSize::DecrementKeepAliveCount - Name=%s, iNumOutStandingBuffers=%d", iName.get_cstr(), iNumOutStandingBuffers));
+        }
+
+        struct StatBlock
+        {
+            StatBlock()
+            {
+                size = 0;
+                seqNum = 0;
+            };
+
+            uint32 size;
+            uint32 seqNum;
+        };
+
+        struct OutOfOrderBlockContainer
+        {
+            OutOfOrderBlockContainer()
+            {
+                ptr = NULL;
+                seqNum = 0;
+            };
+            OutOfOrderBlockContainer(const OsclAny* p, uint32 s)
+            {
+                ptr = p;
+                seqNum = s;
+            };
+
+            const OsclAny* ptr;
+            uint32 seqNum;
+        };
+
+        class ReassemblyBlock
+        {
+
+            public:
+                ReassemblyBlock(const OsclAny* ptr, uint32 seqNum, ReassemblyBlock* p = NULL) : pnext(p)
+                {
+                    rangeStart = rangeEnd = seqNum;
+                    blocks.push_back(OutOfOrderBlockContainer(ptr, seqNum));
+                }
+
+                ~ReassemblyBlock() { }
+
+                bool IsInRange(uint32 seq)
+                {
+                    return (seq >= rangeStart - 1) && (seq <= rangeEnd + 1);
+                }
+                bool IsInRange(ReassemblyBlock& block)
+                {
+                    return (block.rangeStart == rangeEnd + 1);
+                }
+                bool IsLess(uint32 seq)
+                {
+                    return seq < rangeStart;
+                }
+                void Merge(ReassemblyBlock& block)
+                {
+                    for (uint i = 0; i < block.blocks.size(); i++)
+                    {
+                        blocks.push_back(block.blocks[i]);
+                        rangeEnd++;
+                    }
+
+                    rangeEnd = block.rangeEnd;
+                }
+                bool Insert(const OsclAny* ptr, uint32 seqNum)
+                {
+                    if (seqNum == rangeEnd + 1)
+                    {
+                        blocks.push_back(OutOfOrderBlockContainer(ptr, seqNum));
+                        rangeEnd++;
+                        return true;
+                    }
+                    else if (seqNum == rangeStart - 1)
+                    {
+                        blocks.push_front(OutOfOrderBlockContainer(ptr, seqNum));
+                        rangeStart--;
+                        return true;
+                    }
+                    else
+                    {
+                        //OSCL_ASSERT(false);
+                        return false;
+                    }
+                }
+
+                Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>* Blocks()
+                {
+                    return &blocks;
+                }
+                ReassemblyBlock* pnext;
+
+            private:
+                uint32 rangeStart;
+                uint32 rangeEnd;
+                Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator> blocks;
+        };
+
+        class ReassemblyBlockList
+        {
+            public:
+                ReassemblyBlockList()
+                {
+                    phead = NULL;
+                }
+                ~ReassemblyBlockList() { }
+
+                bool Insert(const OsclAny* ptr, uint32 seq)
+                {
+                    bool oRet = true;
+                    ReassemblyBlock** pp = &phead;
+                    while (1)
+                    {
+                        if (*pp == NULL)
+                        {
+                            *pp = OSCL_NEW(ReassemblyBlock, (ptr, seq));
+                            break;
+                        }
+                        else if ((*pp)->IsInRange(seq))
+                        {
+                            oRet = (*pp)->Insert(ptr, seq);
+                            break;
+                        }
+                        else if ((*pp)->IsLess(seq))
+                        {
+                            ReassemblyBlock* p = *pp;
+                            *pp = OSCL_NEW(ReassemblyBlock, (ptr, seq, p));
+                            break;
+                        }
+                        else
+                        {
+                            pp = &(*pp)->pnext;
+                        }
+                    }
+                    pp = &phead;
+                    while ((*pp)->pnext != NULL)
+                    {
+                        if ((*pp)->IsInRange(*((*pp)->pnext)))
+                        {
+                            (*pp)->Merge(*((*pp)->pnext));
+                            ReassemblyBlock* p = (*pp)->pnext;
+                            (*pp)->pnext = (*pp)->pnext->pnext;
+                            OSCL_DELETE(p);
+                        }
+                        else
+                        {
+                            pp = &(*pp)->pnext;
+                        }
+                    }
+                    return oRet;
+                }
+
+                Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>* GetDeletables(uint32 seqNum)
+                {
+                    if (phead == NULL)
+                    {
+                        return NULL;
+                    }
+                    else if (phead->IsInRange(seqNum))
+                    {
+                        return phead->Blocks();
+                    }
+                    else
+                    {
+                        return NULL;
+                    }
+                }
+                void Prune()
+                {
+                    OSCL_ASSERT(phead != NULL);
+                    ReassemblyBlock* p = phead;
+                    phead = p->pnext;
+                    OSCL_DELETE(p);
+                }
+/////// START: clean the head
+                Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>* GetHeadDeletables(uint32 headSeqNum)
+                {
+                    ReassemblyBlock *my_ptr = phead;
+
+                    while (my_ptr != NULL)
+                    {
+                        if (my_ptr->IsInRange(headSeqNum))
+                        { //ok, we got a consecutive chunk end with headSeqNum-1
+                            return my_ptr->Blocks();
+                        }
+
+                        my_ptr = my_ptr->pnext;
+                    }
+                    return NULL;
+                }
+                void PruneHead(Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>* ptrBlk)
+                {
+                    OSCL_ASSERT(phead != NULL);
+                    if (phead->Blocks() == ptrBlk)
+                    {
+                        OSCL_DELETE(phead);
+                        phead = NULL;
+                        return;
+                    }
+
+                    ReassemblyBlock *myParent_ptr = phead;
+                    ReassemblyBlock *my_ptr = myParent_ptr->pnext;
+
+                    while (my_ptr != NULL)
+                    {
+                        if (my_ptr->Blocks() == ptrBlk)
+                        {
+                            OSCL_DELETE(my_ptr);
+                            myParent_ptr->pnext = NULL;
+                            return;
+                        }
+
+                        myParent_ptr = my_ptr;
+                        my_ptr = my_ptr->pnext;
+                    }
+                    OSCL_ASSERT(false);
+                }
+/////// END: clean the head
+            private:
+                ReassemblyBlock* phead;
+        };
+
+
+        struct ParentChunkContainer
+        {
+            ParentChunkContainer()
+            {
+                id = 0xFFFFFFFF;
+                iParentChunkStart = NULL;
+                iParentChunkEnd = NULL;
+                iAllocationPtr = NULL;
+                iEndOfLastDeallocatedBlock = NULL;
+                iParentChunkSize = 0;
+            };
+            uint32 id;
+            uint8* iParentChunkStart;
+            uint8* iParentChunkEnd;
+            uint32 iParentChunkSize;
+            uint8* iAllocationPtr;
+            uint8* iEndOfLastDeallocatedBlock;
+        };
+
+        enum PVMF_RESIZE_ALLOC_ERROR_CODE
+        {
+            PVMF_RESIZE_ALLOC_SUCCESS,
+            PVMF_RESIZE_ALLOC_NO_MEMORY,
+            PVMF_RESIZE_ALLOC_MEMORY_CORRUPT,
+            PVMF_RESIZE_OUT_OF_ORDER_BLOCK
+        };
+
+        PVMF_RESIZE_ALLOC_ERROR_CODE
+        AllocateInParentChunk(ParentChunkContainer* aPCContainer,
+                              OsclAny*& aRequestPtr,
+                              const uint32 aReqBlkSize)
+        {
+            uint32 n = aReqBlkSize + PVMF_RESIZE_ALLOC_OVERHEAD;
+            uint32 availSize = FindLargestContiguousFreeBlock(aPCContainer);
+            if (n > availSize)
+            {
+                PVMF_SOCKALLOC_LOGINFO((0, "PVMFSMSharedBufferAllocWithReSize::AllocateInParentChunk - No Memory1 Name=%s, ChunkID=%d, ReqSize=%d, AvailSize=%d", iName.get_cstr(), aPCContainer->id, n, availSize));
+                return (PVMF_RESIZE_ALLOC_NO_MEMORY);
+            }
+            /*
+             * Check and see if the block being allocated would
+             * cause a wrap around of the "iAllocationPtr"
+             */
+            if ((aPCContainer->iAllocationPtr + n) > aPCContainer->iParentChunkEnd)
+            {
+                /*
+                 * This implies that the requested block is larger
+                 * than whats left towards the end of the parent chunk.
+                 * Since we cannot provide memory in fragments, we
+                 * have to ignore this chunk, wrap the allocation ptr
+                 * to start of the parent chunk and check for alloc size.
+                 */
+                aPCContainer->iAllocationPtr = aPCContainer->iParentChunkStart;
+            }
+            /*
+             * Next check if we can accomodate this request in one
+             * contiguous block between the current alloc ptr and
+             * last deallocated ptr. Please note that we make use
+             * of the fact that deallocation happens sequentially.
+             * Or in other words blocks are freed in the order
+             * in which they are allocated
+             *
+             * There are two possibilites:
+             * 1) iAllocationPtr < iEndOfLastDeallocatedBlock - This means
+             * that a wrap around has happenned, and we need to check
+             * if there is a large enough block between the two ptrs.
+             * Please note that we assume that the space between
+             * iAllocationPtr and iEndOfLastDeallocatedBlock is all free.
+             * Reason being that blocks are deallocated in the same
+             * order in which they are allocated.
+             *
+             * 2) iAllocationPtr > iEndOfLastDeallocatedBlock - This means
+             * we are ok. Any discrepancies must have been detected
+             * by earlier checks.
+             */
+            if (aPCContainer->iAllocationPtr < aPCContainer->iEndOfLastDeallocatedBlock)
+            {
+                uint32 diff = (aPCContainer->iEndOfLastDeallocatedBlock -
+                               aPCContainer->iAllocationPtr);
+                if (diff >= n)
+                {
+                    iNumOutStandingBuffers++;
+                }
+                else
+                {
+                    /*
+                     * We do not have a large enough block to
+                     * satisfy this request.
+                     */
+                    PVMF_SOCKALLOC_LOGINFO((0, "PVMFSMSharedBufferAllocWithReSize::AllocateInParentChunk - No Memory2 Name=%s, ChunkID=%d, ReqSize=%d, AvailSize=%d", iName.get_cstr(), aPCContainer->id, n, diff));
+                    return (PVMF_RESIZE_ALLOC_NO_MEMORY);
+                }
+            }
+            else
+            {
+                iNumOutStandingBuffers++;
+            }
+            /* Set sequence number */
+            oscl_memcpy(aPCContainer->iAllocationPtr, &iSeqCount, sizeof(uint32));
+            /* Set size */
+            oscl_memcpy((aPCContainer->iAllocationPtr + PVMF_RESIZE_ALLOC_BLK_SIZE_OFFSET),
+                        &aReqBlkSize,
+                        sizeof(uint32));
+            aRequestPtr = (OsclAny*)(aPCContainer->iAllocationPtr +
+                                     PVMF_RESIZE_ALLOC_OVERHEAD);
+
+#if PVMF_SOCKALLOC_FILL_MEMBLK_ON_ALLOC
+            uint32 value = 0x00;
+            oscl_memset(aRequestPtr, value, aReqBlkSize);
+#endif
+            // need to remove begin and end variables because of compiler warnings
+            PVMF_SOCKALLOC_LOG_SEQNUM_ALLOC_DEALLOC((0, "PVMFSMSharedBufferAllocWithReSize::allocate - Alloc SeqNum=%d", iSeqCount));
+
+#if 0
+            availSize = FindLargestContiguousFreeBlock(aPCContainer);
+            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "PVMFSMSharedBufferAllocWithReSize::allocate - "
+                                                    "Name=%s, ChunkID=%d, SeqNum=%d, PtrS=0x%x, PtrE=0x%x, Begin=%d, End=%d, AllocSize=%d, iAvailableSize=%d, iNumOutStandingBuffers=%d",
+                                                    iName.get_cstr(),
+                                                    aPCContainer->id,
+                                                    iSeqCount,
+                                                    aPCContainer->iAllocationPtr,
+                                                    aPCContainer->iAllocationPtr + n,
+                                                    (aPCContainer->iAllocationPtr - aPCContainer->iParentChunkStart),
+                                                    (aPCContainer->iAllocationPtr - aPCContainer->iParentChunkStart) + n,
+                                                    n,
+                                                    availSize,
+                                                    iNumOutStandingBuffers));
+#else
+            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "PVMFSMReSize::allocate - "
+                                                    "SeqNum=%d, PtrS=0x%x, PtrE=0x%x, Begin=%d, End=%d, AllocSize=%d, LastDeallocPtr=0x%x, Avail=%d",
+                                                    iSeqCount,
+                                                    aPCContainer->iAllocationPtr,
+                                                    aPCContainer->iAllocationPtr + n,
+                                                    (aPCContainer->iAllocationPtr - aPCContainer->iParentChunkStart),
+                                                    (aPCContainer->iAllocationPtr - aPCContainer->iParentChunkStart) + n,
+                                                    n,
+                                                    aPCContainer->iEndOfLastDeallocatedBlock,
+                                                    getTotalAvailableBufferSpace()));
+#endif
+            aPCContainer->iAllocationPtr += n;
+
+            PVMF_SOCKALLOC_LOG_AVAILABILITY((0, "PVMFSMSBAWithReSize::allocate - Name=%s, SN=%d, Alloc=%d, Avail=%d, BufsOS=%d",
+                                             iName.get_cstr(), iSeqCount, n, getTotalAvailableBufferSpace(), iNumOutStandingBuffers));
+
+            iSeqCount++;
+
+            iJJDataSize += aReqBlkSize;
+            iJJDataDbgSize += aReqBlkSize;
+
+            return (PVMF_RESIZE_ALLOC_SUCCESS);
+        }
+
+        OsclAny* allocate(const uint32 n)
+        {
+            OsclAny* requestPtr = NULL;
+            PVMF_RESIZE_ALLOC_ERROR_CODE errCode;
+
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+
+            for (it = iParentChunkContainerVec.begin();
+                    it != iParentChunkContainerVec.end();
+                    it++)
+            {
+                errCode = AllocateInParentChunk(it, requestPtr, n);
+
+                if (errCode == PVMF_RESIZE_ALLOC_MEMORY_CORRUPT)
+                {
+                    PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::allocate - MEMORY CHUNKS CORRUPT!!! Name=%s", iName.get_cstr()));
+                    OSCL_LEAVE(OsclErrCorrupt);
+                }
+                else if (errCode == PVMF_RESIZE_ALLOC_SUCCESS)
+                {
+                    return requestPtr;
+                }
+            }
+            /*
+             * This implies that we cannot accomodate the request in any
+             * of the existing chunks. Allocate a new parent chunk.
+             */
+            if (iiNumGrows == iiMaxNumGrows)
+            {
+                //PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::allocate - Unable to add an another buffer. Limit exceeded.", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrNoMemory);  // not graceful - can I return NULL instead? TBD.
+            }
+            iiNumGrows++;
+            CreateParentChunk(iiRegrowthSize);
+
+            PVMF_SOCKALLOC_LOGINFO((0, "PVMFSMSharedBufferAllocWithReSize::allocate - EXPANDING JITTER BUFFER - Name=%s, Size=%d", iName.get_cstr(), iiRegrowthSize));
+
+            ParentChunkContainer newPCContainer = iParentChunkContainerVec.back();
+
+            errCode = AllocateInParentChunk(&newPCContainer, requestPtr, n);
+            iParentChunkContainerVec[iParentChunkContainerVec.size()-1] = newPCContainer;
+
+            if (errCode == PVMF_RESIZE_ALLOC_MEMORY_CORRUPT)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::allocate - MEMORY CHUNKS CORRUPT!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrCorrupt);
+            }
+            else if (errCode == PVMF_RESIZE_ALLOC_NO_MEMORY)
+            {
+                /* Too big of a request */
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::allocate - TOO BIG A REQUEST Name=%s, ReqSize=%d", iName.get_cstr(), n));
+                OSCL_LEAVE(OsclErrNoMemory);
+            }
+            return requestPtr;
+        }
+
+        ParentChunkContainer* FindParentChunk(const OsclAny* p)
+        {
+            const uint8* deallocPtr = reinterpret_cast<const uint8*>(p);
+
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+
+            for (it = iParentChunkContainerVec.begin();
+                    it != iParentChunkContainerVec.end();
+                    it++)
+            {
+                if ((deallocPtr >= it->iParentChunkStart) &&
+                        (deallocPtr < it->iParentChunkEnd))
+                {
+                    return (it);
+                }
+            }
+            return NULL;
+        }
+
+        PVMF_RESIZE_ALLOC_ERROR_CODE
+        DeallocateFromParentChunk(ParentChunkContainer* aPCContainer,
+                                  const OsclAny* aDeallocPtr,
+                                  bool oEnableOutofOrderCheck = true)
+        {
+            uint32 seqNum = 0;
+            uint32 blkSize = 0;
+            uint8* p = ((uint8*)(aDeallocPtr) - PVMF_RESIZE_ALLOC_OVERHEAD);
+            /* Get the corresponding block size & seqnum from the pointer itself */
+            oscl_memcpy(&seqNum, (OsclAny*)p, sizeof(uint32));
+            oscl_memcpy(&blkSize, (OsclAny*)(p + PVMF_RESIZE_ALLOC_BLK_SIZE_OFFSET), sizeof(uint32));
+            blkSize += PVMF_RESIZE_ALLOC_OVERHEAD;
+            if (oEnableOutofOrderCheck)
+            {
+                iJJDataSize -= (blkSize - PVMF_RESIZE_ALLOC_OVERHEAD);
+                if (seqNum != (uint32)(iLastDeallocatedSeqNum + 1))
+                {
+                    if (seqNum + 1 == iSeqCount)
+                    {//just allocated, now free, so we pretend we didn't allocate this one to increase mem efficiency
+                        if (aPCContainer->iAllocationPtr != p + blkSize)
+                        {
+                            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "SM ATTN seqNum %d blkSize %d iAlloc 0x%x p 0x%x Ln %d"
+                                                                    , seqNum, blkSize, aPCContainer->iAllocationPtr, p, __LINE__));
+                            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "SM ATTN start 0x%x end 0x%x lastD 0x%x Ln %d"
+                                                                    , aPCContainer->iParentChunkStart, aPCContainer->iParentChunkEnd, aPCContainer->iEndOfLastDeallocatedBlock, __LINE__));
+                        }
+
+                        iJJDataDbgSize -= (blkSize - PVMF_RESIZE_ALLOC_OVERHEAD);
+
+                        aPCContainer->iAllocationPtr = p;
+
+                        iNumOutStandingBuffers--;
+                        iSeqCount--;
+                        return (PVMF_RESIZE_ALLOC_SUCCESS);
+                    }
+
+                    bool oRet = iOutOfOrderBlocks.Insert(aDeallocPtr, seqNum);
+                    if (oRet == true)
+                    {
+                        iNumOutOfOrderDeallocs++;
+                    }
+                    PVMF_SOCKALLOC_LOG_OUT_OF_ORDER_DEALLOC((0, "PVMFSMSharedBufferAllocWithReSize::DeallocateFromParentChunk - OOO Dealloc SeqNum=%d, Size=%d, Ptr=0x%x, NumOOODeallocs=%d", seqNum, blkSize, p, iNumOutOfOrderDeallocs));
+                    return (PVMF_RESIZE_OUT_OF_ORDER_BLOCK);
+                }
+
+            }
+
+            iJJDataDbgSize -= (blkSize - PVMF_RESIZE_ALLOC_OVERHEAD);
+
+            iLastDeallocatedSeqNum = (int32)(seqNum);
+            aPCContainer->iEndOfLastDeallocatedBlock = ((uint8*)p + blkSize);
+
+            if (aPCContainer->iEndOfLastDeallocatedBlock == aPCContainer->iAllocationPtr)
+            {
+                aPCContainer->iEndOfLastDeallocatedBlock = NULL;
+                aPCContainer->iAllocationPtr = aPCContainer->iParentChunkStart;
+            }
+            iNumOutStandingBuffers--;
+
+#if PVMF_SOCKALLOC_FILL_MEMBLK_ON_ALLOC
+            uint32 value = 0x00;
+            oscl_memset(p, value, blkSize);
+#endif
+            // need to remove begin and end variables because of compiler warnings
+            PVMF_SOCKALLOC_LOG_SEQNUM_ALLOC_DEALLOC((0, "PVMFSMSharedBufferAllocWithReSize::DeallocateFromParentChunk - Dealloc SeqNum=%d", iLastDeallocatedSeqNum));
+#if 0
+            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "PVMFSMSharedBufferAllocWithReSize::DeallocateFromParentChunk - "
+                                                    "Name=%s, ChunkID=%d, SeqNum=%d, PtrS=0x%x, PtrE=0x%x, Begin=%d, End=%d, BlockSize=%d, iAvailableSize=%d, iNumOutStandingBuffers=%d",
+                                                    iName.get_cstr(),
+                                                    aPCContainer->id,
+                                                    seqNum,
+                                                    p,
+                                                    p + blkSize + PVMF_RESIZE_ALLOC_OVERHEAD,
+                                                    ((uint8*)p - aPCContainer->iParentChunkStart),
+                                                    ((uint8*)p - aPCContainer->iParentChunkStart) + blkSize,
+                                                    blkSize,
+                                                    FindLargestContiguousFreeBlock(aPCContainer),
+                                                    iNumOutStandingBuffers));
+#else
+            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "PVMFSMReSize::Dealloc - "
+                                                    "SeqNum=%d, PtrS=0x%x, PtrE=0x%x, Begin=%d, End=%d, BlockSize=%d, LastDeallocatedPtr=0x%x, Avail=%d",
+                                                    seqNum,
+                                                    p,
+                                                    p + blkSize,
+                                                    ((uint8*)p - aPCContainer->iParentChunkStart),
+                                                    ((uint8*)p - aPCContainer->iParentChunkStart) + blkSize,
+                                                    blkSize,
+                                                    aPCContainer->iEndOfLastDeallocatedBlock,
+                                                    getTotalAvailableBufferSpace()));
+#endif
+            PVMF_SOCKALLOC_LOG_AVAILABILITY((0, "PVMFSMSBAWithReSize::DeallocateFromParentChunk - Name=%s, SN=%d, Dealloc=%d, Avail=%d, BufsOS=%d",
+                                             iName.get_cstr(), seqNum, blkSize, getTotalAvailableBufferSpace(), iNumOutStandingBuffers));
+            return (PVMF_RESIZE_ALLOC_SUCCESS);
+        }
+
+        PVMF_RESIZE_ALLOC_ERROR_CODE
+        SearchAndDeallocateAnyPrevOutofOrderBlocks(uint32 aSeqNum)
+        {
+            Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>* deleteList =
+                iOutOfOrderBlocks.GetDeletables(aSeqNum);
+
+            if (deleteList == NULL)
+            {
+                return (PVMF_RESIZE_ALLOC_SUCCESS);
+            }
+
+            for (uint i = 0; i < (*deleteList).size(); i++)
+            {
+                DeallocateOutofOrderBlock((*deleteList)[i].ptr);
+                iNumOutOfOrderDeallocs--;
+            }
+
+            iOutOfOrderBlocks.Prune();
+            return (PVMF_RESIZE_ALLOC_SUCCESS);
+        }
+
+        void DeallocateOutofOrderBlock(const OsclAny* p)
+        {
+            ParentChunkContainer* parentChunkContainer = FindParentChunk(p);
+
+            if (parentChunkContainer == NULL)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::DeallocateOutofOrderBlock - INVALID PTR!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+            bool oEnableOutofOrderCheck = false;
+            if (DeallocateFromParentChunk(parentChunkContainer, p, oEnableOutofOrderCheck) == PVMF_RESIZE_ALLOC_MEMORY_CORRUPT)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::DeallocateOutofOrderBlock - CORRUPT PTR!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+        }
+
+        void PurgeOutofOrderBlockVec()
+        {
+            if (iOutofOrderBlockVec.size() > 0)
+            {
+                Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>::iterator it;
+                uint32 count = iOutofOrderBlockVec.size();
+                if (count != iNumOutOfOrderDeallocs)
+                {
+                    OSCL_ASSERT(false);
+                }
+                while (iOutofOrderBlockVec.size() > 0)
+                {
+                    it = iOutofOrderBlockVec.begin();
+                    DeallocateOutofOrderBlock(it->ptr);
+                    iOutofOrderBlockVec.erase(it);
+                }
+            }
+        }
+
+        virtual void deallocate(OsclAny* p)
+        {
+            ParentChunkContainer* parentChunkContainer = FindParentChunk(p);
+            if (parentChunkContainer == NULL)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - INVALID PTR!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+            /* Deallocate the current ptr */
+            PVMF_RESIZE_ALLOC_ERROR_CODE errCode = DeallocateFromParentChunk(parentChunkContainer, p);
+
+            if (errCode == PVMF_RESIZE_ALLOC_MEMORY_CORRUPT)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - CORRUPT PTR - 2!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+            else if ((errCode == PVMF_RESIZE_ALLOC_SUCCESS) || (errCode == PVMF_RESIZE_OUT_OF_ORDER_BLOCK))
+            {
+                if (iDeallocObserver != NULL)
+                {
+                    iDeallocObserver->chunkdeallocated(iDeallocNotificationContextData);
+                }
+                /* Deallocate any out of order blocks */
+                if (iNumOutOfOrderDeallocs > 0)
+                {
+                    SearchAndDeallocateAnyPrevOutofOrderBlocks(iLastDeallocatedSeqNum);
+                }
+
+                if (iNumOutOfOrderDeallocs > 0)
+                {//delete from head, maybe?
+                    Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator>* deleteList =
+                        iOutOfOrderBlocks.GetHeadDeletables(iSeqCount);
+
+                    if (NULL != deleteList)
+                    {
+                        for (int32 i = (*deleteList).size() - 1; i >= 0; i--)
+                        {
+                            uint8* p = (uint8*)((*deleteList)[i].ptr);
+                            ParentChunkContainer* parentChunkContainer = FindParentChunk(p);
+
+                            if (parentChunkContainer == NULL)
+                            {
+                                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - INVALID PTR!!! Name=%s Ln %d", iName.get_cstr(), __LINE__));
+                                OSCL_LEAVE(OsclErrArgument);
+                            }
+                            uint32 seqNum = 0;
+                            uint32 blkSize = 0;
+                            p -= PVMF_RESIZE_ALLOC_OVERHEAD;
+                            /* Get the corresponding block size & seqnum from the pointer itself */
+                            oscl_memcpy(&seqNum, (OsclAny*)p, sizeof(uint32));
+                            oscl_memcpy(&blkSize, (OsclAny*)(p + PVMF_RESIZE_ALLOC_BLK_SIZE_OFFSET), sizeof(uint32));
+
+                            if (seqNum + 1 != iSeqCount)
+                            {
+                                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - ERROR seqNum %d iSeqCount %d Name=%s", seqNum, iSeqCount, iName.get_cstr()));
+                                OSCL_LEAVE(OsclErrArgument);
+                            }
+
+                            if (p + blkSize + PVMF_RESIZE_ALLOC_OVERHEAD != parentChunkContainer->iAllocationPtr)
+                            {//just for logging wrap-around
+                                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - p 0x%x iAllocPtr 0x%x seqNum %d iSeqCount %d Name=%s",
+                                                         p, parentChunkContainer->iAllocationPtr, seqNum, iSeqCount, iName.get_cstr()));
+                            }
+                            parentChunkContainer->iAllocationPtr = p;
+
+                            OSCL_ASSERT(parentChunkContainer->iAllocationPtr != parentChunkContainer->iEndOfLastDeallocatedBlock);
+
+                            iNumOutOfOrderDeallocs--;
+                            iNumOutStandingBuffers--;
+                            iSeqCount--;
+                            iJJDataDbgSize -= blkSize;
+                        }
+
+                        iOutOfOrderBlocks.PruneHead(deleteList);
+                    }
+                }
+            }
+            CheckAndNotifyFreeChunkAvailable();
+        }
+
+        PVMF_RESIZE_ALLOC_ERROR_CODE
+        ReSizeFromParentChunk(ParentChunkContainer* aPCContainer,
+                              OsclAny* aPtr,
+                              uint32 aBytesToReclaim)
+        {
+            uint32 seqNum = 0;
+            uint32 blkSize = 0;
+            uint8* p = ((uint8*)(aPtr) - PVMF_RESIZE_ALLOC_OVERHEAD);
+            /* Get the corresponding block size & seqnum from the pointer itself */
+            oscl_memcpy(&seqNum, (OsclAny*)p, sizeof(uint32));
+            oscl_memcpy(&blkSize, (OsclAny*)(p + PVMF_RESIZE_ALLOC_BLK_SIZE_OFFSET), sizeof(uint32));
+            if (aBytesToReclaim > blkSize)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::ReSizeFromParentChunk - Invalid Reclaim Size - Name=%s, ChunkID=%d, SeqNum=%d, Ptr=0x%x, BlockSize=%d, ReclaimSize=%d", iName.get_cstr(), aPCContainer->id, seqNum, p, blkSize, aBytesToReclaim));
+                return (PVMF_RESIZE_ALLOC_MEMORY_CORRUPT);
+            }
+            blkSize -= aBytesToReclaim;
+            aPCContainer->iAllocationPtr -= aBytesToReclaim;
+
+            iJJDataSize -= aBytesToReclaim;
+            iJJDataDbgSize -= aBytesToReclaim;
+            if (iSeqCount > seqNum + 1)
+            {
+                //Resize can ONLY be applied to the buffer just allocated.
+                PVMF_SOCKALLOC_LOGERROR((0, "Resize ERROR seq %d iSeqCount %d iJJDataSize %d", seqNum, iSeqCount, iJJDataSize));
+                return (PVMF_RESIZE_ALLOC_MEMORY_CORRUPT);
+            }
+            /* reset the block size */
+            oscl_memcpy((OsclAny*)(p + PVMF_RESIZE_ALLOC_BLK_SIZE_OFFSET),
+                        &blkSize,
+                        sizeof(uint32));
+            // need to remove begin and end variables because of compiler warnings
+#if 0
+            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "PVMFSMSharedBufferAllocWithReSize::ReSizeFromParentChunk - "
+                                                    "Name=%s, ChunkID=%d, SeqNum=%d, PtrS=0x%x, PtrE=0x%x, AllocPtr=0x%x, Begin=%d, End=%d, NewSize=%d, aBytesToReclaim=%d, iAvailableSize=%d",
+                                                    iName.get_cstr(),
+                                                    aPCContainer->id,
+                                                    seqNum,
+                                                    p,
+                                                    p + blkSize + PVMF_RESIZE_ALLOC_OVERHEAD,
+                                                    aPCContainer->iAllocationPtr,
+                                                    (p - aPCContainer->iParentChunkStart),
+                                                    (p - aPCContainer->iParentChunkStart) + blkSize + PVMF_RESIZE_ALLOC_OVERHEAD,
+                                                    blkSize,
+                                                    aBytesToReclaim,
+                                                    FindLargestContiguousFreeBlock(aPCContainer)));
+#else
+            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "PVMFSMReSize::ReSize - "
+                                                    "SeqNum=%d, PtrS=0x%x, PtrE=0x%x, AllocPtr=0x%x, Begin=%d, End=%d, NewSize=%d, Avail=%d",
+                                                    seqNum,
+                                                    p,
+                                                    p + blkSize + PVMF_RESIZE_ALLOC_OVERHEAD,
+                                                    aPCContainer->iAllocationPtr,
+                                                    (p - aPCContainer->iParentChunkStart),
+                                                    (p - aPCContainer->iParentChunkStart) + blkSize + PVMF_RESIZE_ALLOC_OVERHEAD,
+                                                    blkSize,
+                                                    getTotalAvailableBufferSpace()));
+#endif
+            PVMF_SOCKALLOC_LOG_AVAILABILITY((0, "PVMFSMSBAWithReSize::ReSizeFromParentChunk - Name=%s, SN=%d, Reclaim=%d, Avail=%d",
+                                             iName.get_cstr(), seqNum, aBytesToReclaim, getTotalAvailableBufferSpace()));
+            return (PVMF_RESIZE_ALLOC_SUCCESS);
+        }
+
+        void resize(OsclAny* p, uint32 aBytesToReclaim)
+        {
+            ParentChunkContainer* parentChunkContainer = FindParentChunk(p);
+
+            if (parentChunkContainer == NULL)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::resize - INVALID PTR!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+            if (ReSizeFromParentChunk(parentChunkContainer,
+                                      p,
+                                      aBytesToReclaim) == PVMF_RESIZE_ALLOC_MEMORY_CORRUPT)
+            {
+                PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::resize - INVALID PTR!!! Name=%s", iName.get_cstr()));
+                OSCL_LEAVE(OsclErrArgument);
+            }
+            CheckAndNotifyFreeChunkAvailable();
+        }
+
+        uint32 getNumOutStandingBuffers()
+        {
+            return iNumOutStandingBuffers;
+        }
+
+        uint32 getTotalBufferSize()
+        {
+            uint32 totalsize = 0;
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+            for (it = iParentChunkContainerVec.begin();
+                    it != iParentChunkContainerVec.end();
+                    it++)
+            {
+                totalsize += it->iParentChunkSize;
+            }
+            return (totalsize);
+        }
+
+        uint32 getTotalAvailableBufferSpace()
+        {
+            uint32 freespace = 0;
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+            if ((iNumOutStandingBuffers == 1) &&
+                    (iDecKeepAliveCalled == false))
+            {
+                // all outstanding buffers have been freed
+                freespace = getTotalBufferSize();
+                for (it = iParentChunkContainerVec.begin();
+                        it != iParentChunkContainerVec.end();
+                        it++)
+                {
+                    it->iEndOfLastDeallocatedBlock = NULL;
+                    it->iAllocationPtr = it->iParentChunkStart;
+                }
+            }
+            else
+            {
+                for (it = iParentChunkContainerVec.begin();
+                        it != iParentChunkContainerVec.end();
+                        it++)
+                {
+                    freespace += FindLargestContiguousFreeBlock(it);
+                }
+            }
+            return (freespace);
+        }
+
+        uint32 getActualDataSize()
+        {
+            return iJJDataSize;
+        }
+
+        uint32 getTrueBufferSpace()
+        {
+            uint32 truespace = 0;
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+            if ((iNumOutStandingBuffers == 1) &&
+                    (iDecKeepAliveCalled == false))
+            {
+                // all outstanding buffers have been freed
+                truespace = getTotalBufferSize();
+                for (it = iParentChunkContainerVec.begin();
+                        it != iParentChunkContainerVec.end();
+                        it++)
+                {
+                    it->iEndOfLastDeallocatedBlock = NULL;
+                    it->iAllocationPtr = it->iParentChunkStart;
+                }
+            }
+            else
+            {
+                for (it = iParentChunkContainerVec.begin();
+                        it != iParentChunkContainerVec.end();
+                        it++)
+                {
+                    uint32 maxSize = 0;
+                    if (it != NULL)
+                    {
+                        if (it->iEndOfLastDeallocatedBlock == NULL)
+                        {
+                            /*
+                             * Implies that there is no deallocations have happenned
+                             */
+                            maxSize =
+                                (it->iParentChunkEnd - it->iAllocationPtr);
+                        }
+                        else
+                        {
+                            if (it->iAllocationPtr <= it->iEndOfLastDeallocatedBlock)
+                            {
+                                maxSize =
+                                    (it->iEndOfLastDeallocatedBlock - it->iAllocationPtr);
+                            }
+                            else
+                            {
+                                uint32 free_end =
+                                    (it->iParentChunkEnd - it->iAllocationPtr);
+                                uint32 free_begin =
+                                    (it->iEndOfLastDeallocatedBlock - it->iParentChunkStart);
+                                maxSize = free_end + free_begin;
+                            }
+                        }
+                    }
+                    truespace += maxSize;
+                }
+            }
+            PVMF_SOCKALLOC_LOG_AVAILABILITY((0, "SM alloc space new1 %d new2 %d kspace %d Ln %d", iJJDataSize, iJJDataDbgSize, truespace, __LINE__));
+            return (truespace);
+        }
+
+
+        uint32 FindLargestContiguousFreeBlock(ParentChunkContainer* aPtr)
+        {
+            ParentChunkContainer* it = aPtr;
+            uint32 maxSize = 0;
+            if (it != NULL)
+            {
+                if (it->iEndOfLastDeallocatedBlock == NULL)
+                {
+                    /*
+                     * Implies that there is no deallocations have happenned
+                     */
+                    maxSize =
+                        (it->iParentChunkEnd - it->iAllocationPtr);
+                }
+                else
+                {
+                    /*
+                     * There are two possibilites:
+                     * 1) iAllocationPtr < iEndOfLastDeallocatedBlock - This means
+                     * that a wrap around has happenned, and we need to check
+                     * if there is a large enough block between the two ptrs.
+                     * Please note that we assume that the space between
+                     * iAllocationPtr and iEndOfLastDeallocatedBlock is all free.
+                     * Reason being that blocks are deallocated in the same
+                     * order in which they are allocated.
+                     *
+                     * 2) iAllocationPtr > iEndOfLastDeallocatedBlock - This means
+                     * we are ok.
+                     *
+                     */
+                    if (it->iAllocationPtr <= it->iEndOfLastDeallocatedBlock)
+                    {
+                        maxSize =
+                            (it->iEndOfLastDeallocatedBlock - it->iAllocationPtr);
+                    }
+                    else
+                    {
+                        uint32 free_end =
+                            (it->iParentChunkEnd - it->iAllocationPtr);
+                        uint32 free_begin =
+                            (it->iEndOfLastDeallocatedBlock - it->iParentChunkStart);
+                        if (free_end > free_begin)
+                        {
+                            maxSize = free_end;
+                        }
+                        else
+                        {
+                            maxSize = free_begin;
+                        }
+                    }
+                }
+            }
+            return (maxSize);
+        }
+
+
+        uint32 getAvailableBufferSpace(bool aFirstParentChunkOnly = false)
+        {
+            uint32 freespace = 0;
+            Oscl_Vector<ParentChunkContainer, OsclMemAllocator>::iterator it;
+            if (aFirstParentChunkOnly)
+            {
+                /*
+                 * Since we cannot inform the server about buffer growth, we
+                 * should only send free space from the first allocated chunk.
+                 */
+                it = iParentChunkContainerVec.begin();
+                freespace = FindLargestContiguousFreeBlock(it);
+            }
+            else
+            {
+                for (it = iParentChunkContainerVec.begin();
+                        it != iParentChunkContainerVec.end();
+                        it++)
+                {
+                    uint32 size = FindLargestContiguousFreeBlock(it);
+                    if (size > freespace)
+                    {
+                        freespace = size;
+                    }
+                }
+            }
+            return (freespace);
+        }
+
+        void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& aObserver,
+                                      uint32 aSize,
+                                      OsclAny* aContextData = NULL)
+        {
+            PVMF_SOCKALLOC_LOG_MEMCALLBACK((0, "notifyfreechunkavailable - reqSize=%d", (aSize + PVMF_RESIZE_ALLOC_OVERHEAD)));
+            iCallbackPending = true;
+            iCallbackRequestSize = aSize + PVMF_RESIZE_ALLOC_OVERHEAD;
+            iObserver = &aObserver;
+            iNextAvailableContextData = aContextData;
+        }
+
+        void CancelFreeChunkAvailableCallback()
+        {
+            iCallbackPending = false;
+            iCallbackRequestSize = 0;
+            iObserver = NULL;
+        }
+
+        void CheckAndNotifyFreeChunkAvailable()
+        {
+            if (iCallbackPending == true)
+            {
+                uint32 availSize = getTrueBufferSpace();
+
+                PVMF_SOCKALLOC_LOG_MEMCALLBACK((0, "CheckAndNotifyFreeChunkAvailable() availSize %d", availSize));
+                if (availSize > iCallbackRequestSize)
+                {
+                    PVMF_SOCKALLOC_LOG_MEMCALLBACK((0, "CheckAndNotifyFreeChunkAvailable() availSize(%d) > iCallbackRequestSize(%d)", availSize, iCallbackRequestSize));
+                    if (iObserver == NULL)
+                        return;
+                    OsclMemPoolFixedChunkAllocatorObserver* MyObserver = iObserver;
+                    PVMF_SOCKALLOC_LOG_MEMCALLBACK((0, "CheckAndNotifyFreeChunkAvailable() MyObserver(0x%x) iObserver(0x%x) ", MyObserver, iObserver));
+                    CancelFreeChunkAvailableCallback();
+                    PVMF_SOCKALLOC_LOG_MEMCALLBACK((0, "CheckAndNotifyFreeChunkAvailable MyObserver(0x%x)", MyObserver));
+                    MyObserver->freechunkavailable(iNextAvailableContextData);
+                    PVMF_SOCKALLOC_LOG_MEMCALLBACK((0, "CheckAndNotifyFreeChunkAvailable() iNextAvailableContextData %d out", iNextAvailableContextData));
+                }
+            }
+        }
+
+        void NotifyDeallocations(PVMFSMSharedBufferAllocWithReSizeAllocDeallocObserver& aObserver,
+                                 OsclAny* aContextData = NULL)
+        {
+            iDeallocObserver = &aObserver;
+            iDeallocNotificationContextData = aContextData;
+        }
+
+        void CancelDeallocationNotifications()
+        {
+            iDeallocObserver = NULL;
+            iDeallocNotificationContextData = NULL;
+        }
+
+    private:
+        Oscl_Vector<ParentChunkContainer, OsclMemAllocator> iParentChunkContainerVec;
+
+        OsclMemAllocator alloc;
+
+        uint32 iNumOutOfOrderDeallocs;
+        Oscl_Vector<OutOfOrderBlockContainer, OsclMemAllocator> iOutofOrderBlockVec;
+
+        int32 iLastDeallocatedSeqNum;
+        uint32 iSeqCount;
+        uint32 iNumOutStandingBuffers;
+        PVLogger *iLogger;
+        PVLogger *iSizeLogger;
+        PVLogger *iCallBackLogger;
+        PVLogger *iOOOLogger;
+        uint32 iJJDataSize;
+        uint32 iJJDataDbgSize;
+        OSCL_HeapString<OsclMemAllocator> iName;
+        ReassemblyBlockList iOutOfOrderBlocks;
+
+        // buffer resize parameters
+        uint iiMaxNumGrows;
+        uint iiNumGrows;
+        uint iiRegrowthSize;
+
+        //callback related params
+        bool iCallbackPending;
+        uint32 iCallbackRequestSize;
+        OsclMemPoolFixedChunkAllocatorObserver* iObserver;
+        OsclAny* iNextAvailableContextData;
+
+        bool iDecKeepAliveCalled;
+
+        PVMFSMSharedBufferAllocWithReSizeAllocDeallocObserver* iDeallocObserver;
+        OsclAny* iDeallocNotificationContextData;
+};
+
+class PVMFSMSharedBufferAllocWithReSizeCleanupDA : public OsclDestructDealloc
+{
+    public:
+        PVMFSMSharedBufferAllocWithReSizeCleanupDA(Oscl_DefAlloc* in_gen_alloc) :
+                gen_alloc(in_gen_alloc) {};
+
+        virtual ~PVMFSMSharedBufferAllocWithReSizeCleanupDA() {};
+
+        virtual void destruct_and_dealloc(OsclAny* ptr)
+        {
+            /*
+             * get number of outstanding buffers from the allocator
+             */
+            Oscl_DefAlloc* myalloc = gen_alloc;
+            PVMFSMSharedBufferAllocWithReSize* socketDataAllocator =
+                reinterpret_cast<PVMFSMSharedBufferAllocWithReSize*>(myalloc);
+            gen_alloc->deallocate(ptr);
+
+            uint32 numBuffers = socketDataAllocator->getNumOutStandingBuffers();
+
+            /*
+             * get the number of buffers deallocated, after the pointer has
+             * been deallocated. A single dealloc call can potentially deallocate
+             * multiple buffers (if there are many out of order blocks).
+             */
+            /*
+             * in case there are no outstanding buffers delete the allocator
+             */
+            if (numBuffers == 0)
+            {
+                OSCL_DELETE((socketDataAllocator));
+            }
+        }
+
+    private:
+        Oscl_DefAlloc* gen_alloc;
+};
+
+class PVMFSharedSocketDataBufferAlloc
+{
+    public:
+        PVMFSharedSocketDataBufferAlloc(Oscl_DefAlloc* in_gen_alloc)
+        {
+            iResizeAlloc = false;
+            if (in_gen_alloc)
+            {
+                gen_alloc = in_gen_alloc;
+                iBufferOverhead = 0;
+            }
+            else
+            {
+                OSCL_LEAVE(OsclErrArgument);
+            }
+        }
+
+        PVMFSharedSocketDataBufferAlloc(PVMFSMSharedBufferAllocWithReSize* in_gen_alloc)
+        {
+            iResizeAlloc = false;
+            if (in_gen_alloc)
+            {
+                iResizeAlloc = true;
+                gen_alloc = in_gen_alloc;
+                iBufferOverhead = 0;
+                uint aligned_class_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+                uint aligned_cleanup_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSMSharedBufferAllocWithReSizeCleanupDA));
+                uint aligned_refcnt_size =
+                    oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+                iBufferOverhead = (aligned_refcnt_size +
+                                   aligned_cleanup_size +
+                                   aligned_class_size);
+
+            }
+            else
+            {
+                OSCL_LEAVE(OsclErrArgument);
+            }
+        };
+
+        virtual ~PVMFSharedSocketDataBufferAlloc()
+        {
+        };
+
+        OsclSharedPtr<PVMFMediaDataImpl> createSharedBuffer(uint32 size)
+        {
+            if (size == 0)
+            {
+                size = PVMF_SOCKET_BUF_DEFAULT_SIZE;
+            }
+
+            uint aligned_in_size = oscl_mem_aligned_size(size);
+
+            if (iResizeAlloc)
+            {
+                uint8* my_ptr;
+                OsclRefCounter* my_refcnt;
+
+                uint aligned_class_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+
+                uint aligned_cleanup_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSMSharedBufferAllocWithReSizeCleanupDA));
+
+                uint aligned_refcnt_size =
+                    oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+
+                my_ptr = (uint8*) gen_alloc->allocate(aligned_refcnt_size +
+                                                      aligned_cleanup_size +
+                                                      aligned_class_size +
+                                                      aligned_in_size);
+
+                PVMFSMSharedBufferAllocWithReSizeCleanupDA *my_cleanup =
+                    OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVMFSMSharedBufferAllocWithReSizeCleanupDA(gen_alloc));
+
+                my_refcnt =
+                    OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, my_cleanup));
+
+                my_ptr += aligned_refcnt_size + aligned_cleanup_size;
+
+                void* ptr;
+                ptr = my_ptr + aligned_class_size;
+
+                PVMFMediaDataImpl* media_data_ptr =
+                    new(my_ptr) PVMFSimpleMediaBuffer(ptr,
+                                                      aligned_in_size,
+                                                      my_refcnt);
+
+                OsclSharedPtr<PVMFMediaDataImpl> shared_media_data(media_data_ptr,
+                        my_refcnt);
+                return shared_media_data;
+            }
+            else
+            {
+                uint8* my_ptr;
+                OsclRefCounter* my_refcnt;
+
+                uint aligned_class_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+
+                uint aligned_cleanup_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSocketBufferCleanupDA));
+
+                uint aligned_refcnt_size =
+                    oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+
+                my_ptr = (uint8*) gen_alloc->allocate(aligned_refcnt_size +
+                                                      aligned_cleanup_size +
+                                                      aligned_class_size +
+                                                      aligned_in_size);
+
+                PVMFSocketBufferCleanupDA *my_cleanup =
+                    OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVMFSocketBufferCleanupDA(gen_alloc));
+
+                my_refcnt =
+                    OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, my_cleanup));
+
+                my_ptr += aligned_refcnt_size + aligned_cleanup_size;
+
+                void* ptr;
+                ptr = my_ptr + aligned_class_size;
+
+                PVMFMediaDataImpl* media_data_ptr =
+                    new(my_ptr) PVMFSimpleMediaBuffer(ptr,
+                                                      aligned_in_size,
+                                                      my_refcnt);
+
+                OsclSharedPtr<PVMFMediaDataImpl> shared_media_data(media_data_ptr,
+                        my_refcnt);
+                return shared_media_data;
+            }
+        }
+
+        void ResizeMemoryFragment(OsclSharedPtr<PVMFMediaDataImpl>& aSharedBuffer)
+        {
+            if (iResizeAlloc)
+            {
+                OsclRefCounterMemFrag memFrag;
+                aSharedBuffer->getMediaFragment(0, memFrag);
+                uint32 currCapacity = memFrag.getCapacity();
+                uint32 bytesUsed = memFrag.getMemFragSize();
+
+                //uint32 alignedBytesUsed = bytesUsed;
+                uint32 alignedBytesUsed = oscl_mem_aligned_size(bytesUsed);
+
+                if (alignedBytesUsed < currCapacity)
+                {
+                    uint32 bytesToReclaim = (currCapacity - alignedBytesUsed);
+                    PVMFSMSharedBufferAllocWithReSize* socketDataAllocator =
+                        reinterpret_cast<PVMFSMSharedBufferAllocWithReSize*>(gen_alloc);
+                    /* Account for the overhead */
+                    uint8* memFragPtr = (uint8*)(memFrag.getMemFragPtr());
+                    uint8* ptr = (memFragPtr - iBufferOverhead);
+                    socketDataAllocator->resize((OsclAny*)ptr, bytesToReclaim);
+                    aSharedBuffer->setCapacity(alignedBytesUsed);
+                }
+            }
+        }
+
+        uint32 getAvailableBufferSpace(bool aFirstParentChunkOnly = false)
+        {
+            if (iResizeAlloc)
+            {
+                PVMFSMSharedBufferAllocWithReSize* socketDataAllocator =
+                    reinterpret_cast<PVMFSMSharedBufferAllocWithReSize*>(gen_alloc);
+                return (socketDataAllocator->getAvailableBufferSpace(aFirstParentChunkOnly));
+            }
+            else
+            {
+                PVMFSocketBufferAllocator* socketDataAllocator =
+                    reinterpret_cast<PVMFSocketBufferAllocator*>(gen_alloc);
+                return (socketDataAllocator->getAvailableBufferSpace(aFirstParentChunkOnly));
+            }
+        }
+        void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& aObserver,
+                                      uint32 aSize,
+                                      OsclAny* aContextData = NULL)
+        {
+            if (iResizeAlloc)
+            {
+                PVMFSMSharedBufferAllocWithReSize* socketDataAllocator =
+                    reinterpret_cast<PVMFSMSharedBufferAllocWithReSize*>(gen_alloc);
+                socketDataAllocator->notifyfreechunkavailable(aObserver, (aSize + iBufferOverhead), aContextData);
+            }
+            else
+            {
+                PVMFSocketBufferAllocator* socketDataAllocator =
+                    reinterpret_cast<PVMFSocketBufferAllocator*>(gen_alloc);
+                socketDataAllocator->notifyfreechunkavailable(aObserver, (aSize + iBufferOverhead), aContextData);
+            }
+        }
+
+        void CancelFreeChunkAvailableCallback()
+        {
+            if (iResizeAlloc)
+            {
+                PVMFSMSharedBufferAllocWithReSize* socketDataAllocator =
+                    reinterpret_cast<PVMFSMSharedBufferAllocWithReSize*>(gen_alloc);
+                socketDataAllocator->CancelFreeChunkAvailableCallback();
+            }
+            else
+            {
+                PVMFSocketBufferAllocator* socketDataAllocator =
+                    reinterpret_cast<PVMFSocketBufferAllocator*>(gen_alloc);
+                socketDataAllocator->CancelFreeChunkAvailableCallback();
+            }
+        }
+
+    private:
+        bool iResizeAlloc;
+        uint iBufferOverhead;
+        Oscl_DefAlloc* gen_alloc;
+};
+
+class PVMFSharedSocketDataBufferAllocCleanupSA : public OsclDestructDealloc
+{
+    public:
+        virtual ~PVMFSharedSocketDataBufferAllocCleanupSA() {};
+
+        virtual void destruct_and_dealloc(OsclAny* ptr)
+        {
+            uint8* tmp_ptr = (uint8*) ptr;
+
+            uint aligned_refcnt_size =
+                oscl_mem_aligned_size(sizeof(OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>));
+
+            tmp_ptr += aligned_refcnt_size;
+            PVMFSharedSocketDataBufferAlloc* socketDataBufferAlloc =
+                reinterpret_cast<PVMFSharedSocketDataBufferAlloc*>(tmp_ptr);
+
+            socketDataBufferAlloc->~PVMFSharedSocketDataBufferAlloc();
+            OsclMemAllocator alloc;
+            alloc.deallocate(ptr);
+        }
+};
+
+
+#endif //PVMF_STREAMING_BUFFER_ALLOCATORS_H_INCLUDED
diff --git a/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_factory.cpp b/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_factory.cpp
new file mode 100644
index 0000000..737a6ef
--- /dev/null
+++ b/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_factory.cpp
@@ -0,0 +1,61 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_clientserver_socket_factory.cpp
+ * @brief Singleton factory for PVMFClientServerSocketNode
+ */
+#ifndef PVMF_CLIENTSERVER_SOCKET_NODE_FACTORY_H_INCLUDED
+#include "pvmf_clientserver_socket_factory.h"
+#endif
+#ifndef OSCL_EXCEPTION_H_INCLUDED
+#include "oscl_exception.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+// Use default DLL entry point for Symbian
+#include "oscl_dll.h"
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVMFClientServerSocketNodeFactory::CreateClientServerSocketNode(OsclTCPSocket* aSocketHandle, int32 aPriority)
+{
+    PVMFNodeInterface* node = NULL;
+    node = OSCL_NEW(PVMFClientServerSocketNode, (aSocketHandle, aPriority));
+    if (node == NULL)
+    {
+        OSCL_LEAVE(OsclErrNoMemory);
+    }
+    return node;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFClientServerSocketNodeFactory::DeleteClientServerSocketNode(PVMFNodeInterface* aNode)
+{
+    if (aNode)
+    {
+        OSCL_DELETE(aNode);
+        return true;
+    }
+    return false;
+}
+
diff --git a/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_node.cpp b/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_node.cpp
new file mode 100644
index 0000000..ba0cc64
--- /dev/null
+++ b/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_node.cpp
@@ -0,0 +1,2051 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "pvmf_clientserver_socket_node.h"
+#include "oscl_string_utils.h"
+#include "pvmf_basic_errorinfomessage.h"
+#include "pvmf_errorinfomessage_extension.h"
+#include "oscl_byte_order.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+#include "oscl_tickcount.h"
+#include "oscl_rand.h"
+#include "oscl_time.h"
+#include "oscl_bin_stream.h"
+
+// Use default DLL entry point for Symbian
+#include "oscl_dll.h"
+
+//////////////////////////////////////////////////
+// Standard Node APIs
+//////////////////////////////////////////////////
+
+OSCL_EXPORT_REF PVMFClientServerSocketNode::PVMFClientServerSocketNode(OsclTCPSocket* aSocketHandle, int32 aPriority)
+        : OsclActiveObject(aPriority, "PVMFClientServerSocketNode")
+        , iSockServ(NULL)
+        , TIMEOUT_CONNECT(-1)
+        , TIMEOUT_SEND(-1)
+        , TIMEOUT_RECV(-1)
+        , TIMEOUT_SHUTDOWN(-1)
+        , iSocketHandle(aSocketHandle)
+        , iSockConfig(NULL)
+{
+    iLogger = NULL;
+    iDataPathLogger = NULL;
+    iOsclErrorTrapImp = NULL;
+    iExtensionRefCount = 0;
+    iMaxTcpRecvBufferSize = SNODE_DEFAULT_SOCKET_TCP_BUFFER_SIZE;
+    iMaxTcpRecvBufferCount = SNODE_DEFAULT_SOCKET_TCP_BUFFER_COUNT;
+    iSocketID = 0;
+    iCommandErrorCode = PVMFSocketNodeErrorEventStart;
+    iErrorEventErrorCode = PVMFSocketNodeErrorEventStart;
+
+    iPVMFPort = NULL;
+    iNumStopPortActivityPending = (-1);//inactive.
+
+    int32 err;
+    OSCL_TRY(err,
+
+             iPendingCmdQueue.Construct(PVMF_SOCKET_NODE_COMMAND_ID_START,
+                                        PVMF_SOCKET_NODE_COMMAND_VECTOR_RESERVE);
+
+             //Create the "current command" queue.  It will only contain one
+             //command at a time, so use a reserve of 1.
+             iCurrentCmdQueue.Construct(0, 1);
+             iCancelCmdQueue.Construct(0, 1);
+            );
+
+    if (err != OsclErrNone)
+    {
+        //if a leave happened, cleanup and re-throw the error
+        iPendingCmdQueue.clear();
+        iCurrentCmdQueue.clear();
+        iCancelCmdQueue.clear();
+        if (iPVMFPort)
+        {
+            iPVMFPort->Disconnect();
+            delete iPVMFPort;
+            iPVMFPort = NULL;
+        }
+        OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
+        OSCL_CLEANUP_BASE_CLASS(OsclActiveObject);
+        OSCL_LEAVE(err);
+    }
+}
+
+
+OSCL_EXPORT_REF PVMFClientServerSocketNode::~PVMFClientServerSocketNode()
+{
+    Cancel();
+
+    //thread logoff
+    if (IsAdded())
+        RemoveFromScheduler();
+
+    /* Cleanup allocated ports */
+    CleanupPorts();
+
+    //Cleanup commands
+    while (!iCurrentCmdQueue.empty())
+    {
+        CommandComplete(iCurrentCmdQueue, iCurrentCmdQueue.front(), PVMFFailure);
+    }
+    while (!iPendingCmdQueue.empty())
+    {
+        CommandComplete(iPendingCmdQueue, iPendingCmdQueue.front(), PVMFFailure);
+    }
+    while (!iCancelCmdQueue.empty())
+    {
+        CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFFailure);
+    }
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::ThreadLogon()
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+            if (!IsAdded())
+                AddToScheduler();
+            iLogger = PVLogger::GetLoggerObject("PVMFClientServerSocketNode");
+            iDataPathLogger = PVLogger::GetLoggerObject("datapath.socketnode");
+            iOsclErrorTrapImp = OsclErrorTrap::GetErrorTrapImp();
+            SetState(EPVMFNodeIdle);
+            return PVMFSuccess;
+        default:
+            return PVMFErrInvalidState;
+    }
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::ThreadLogoff()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:ThreadLogoff"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        {
+            if (IsAdded())
+                RemoveFromScheduler();
+            iLogger = NULL;
+            iDataPathLogger = NULL;
+            iOsclErrorTrapImp = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+        }
+        default:
+            return PVMFErrInvalidState;
+    }
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    OSCL_UNUSED_ARG(aNodeCapability);
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFPortIter* PVMFClientServerSocketNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    OSCL_UNUSED_ARG(aFilter);
+    //retrive a port iterator
+    return (PVMFPortIter*)iPVMFPort;
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:RequestPort"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:ReleasePort"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Init"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Init"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Start"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Stop"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Flush"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Pause"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:Reset"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:CancelAllCommands"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
+    return QueueCommandL(cmd);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFClientServerSocketNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:CancelCommand"));
+    PVMFSocketNodeCommand cmd;
+    cmd.PVMFSocketNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
+    return QueueCommandL(cmd);
+}
+
+//Port activity handler
+void PVMFClientServerSocketNode::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVMFClientServerSocketPort* sockPort = NULL;
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_CONNECT:
+        {
+            sockPort = OSCL_STATIC_CAST(PVMFClientServerSocketPort*, aActivity.iPort);
+            OSCL_ASSERT(sockPort && sockPort->iConfig);
+            *iSockConfig = *sockPort->iConfig;
+
+            setSocketPortMemAllocator(aActivity.iPort, sockPort->iAllocSharedPtr);
+
+            //Receives may have been blocked waiting on the port to be connected, so check here.
+            if (CanReceive())
+                StartRecvOperation();
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+        {
+            sockPort = (PVMFClientServerSocketPort*)(aActivity.iPort);
+            OSCL_ASSERT(sockPort && sockPort->iConfig);
+
+            //Try to process this message now.
+            if (CanProcessIncomingMsg())
+                ProcessIncomingMsg();
+            //Otherwise, ignore this event now.  Other code will check
+            //the input queue as needed.
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+        {
+            sockPort = (PVMFClientServerSocketPort*)(aActivity.iPort);
+            OSCL_ASSERT(sockPort && sockPort->iConfig);
+            SocketPortConfig& aSockConfig = *sockPort->iConfig;
+
+            if (aSockConfig.iState.iRecvOperation == EPVSocketPortRecvOperation_WaitOnConnectedPort)
+            {
+                RecvOperationComplete(PVMFSuccess, NULL);
+            }
+
+            //Otherwise ignore this event now.  Other code will check connected
+            //port status as needed.
+        }
+        break;
+
+        default:
+            //all other events can be ignored.
+            break;
+    }
+}
+
+
+OSCL_EXPORT_REF void PVMFClientServerSocketNode::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+OSCL_EXPORT_REF void PVMFClientServerSocketNode::removeRef()
+{
+    --iExtensionRefCount;
+}
+
+OSCL_EXPORT_REF bool PVMFClientServerSocketNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    OSCL_UNUSED_ARG(uuid);
+    OSCL_UNUSED_ARG(iface);
+    return false;
+}
+
+void PVMFClientServerSocketNode::Run()
+{
+    //Process node commands
+    while (CanProcessCommand())
+        ProcessCommand(iPendingCmdQueue, iPendingCmdQueue.front());
+}
+
+
+bool PVMFClientServerSocketNode::CanProcessCommand()
+{
+    return (!iPendingCmdQueue.empty()
+            && (iCurrentCmdQueue.empty()
+                || (iPendingCmdQueue.front().hipri() && iCancelCmdQueue.empty())));
+}
+
+//Process an input command.
+void PVMFClientServerSocketNode::ProcessCommand(PVMFSocketNodeCmdQ& aCmdQ, PVMFSocketNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFSocketNodeCommand::ProcessCommand() in"));
+
+    PVMFStatus status = PVMFFailure;
+    iCommandErrorCode = PVMFSocketNodeErrorEventStart; //no error
+
+    if (aCmd.hipri())
+    {
+        //calling logic should prevent multiple cancels in progress.
+        OSCL_ASSERT(iCancelCmdQueue.empty());
+
+        switch (aCmd.iCmd)
+        {
+            case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+                status = DoCancelAllCommands(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_CANCELCOMMAND:
+                status = DoCancelCommand(aCmd);
+                break;
+
+            default://unknown command type
+                status = PVMFFailure;
+                break;
+        }
+
+        //If the command was not finished in this call, then move it to the
+        //"cancel cmd" queue where it will remain until it is completed.
+        if (status == PVMFPending)
+        {
+            //move the new cmd to the "cancel cmd" queue where it will
+            //remain until complete.
+            int32 err;
+            OSCL_TRY(err, iCancelCmdQueue.StoreL(aCmd););
+
+            //we reserved space in the CancelCmdQueue already, so
+            //it should not be possible to fail here.
+            OSCL_ASSERT(err == OsclErrNone);
+
+            //erase the original command
+            aCmdQ.Erase(&aCmd);
+        }
+        else
+        {
+            CommandComplete(aCmdQ, aCmd, status, NULL);
+        }
+    }
+    else
+    {
+        //calling logic should prevent multiple commands in progress.
+        OSCL_ASSERT(iCurrentCmdQueue.empty());
+
+        OsclAny* eventData = NULL;
+
+        switch (aCmd.iCmd)
+        {
+            case PVMF_GENERIC_NODE_QUERYUUID:
+                status = DoQueryUuid(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_QUERYINTERFACE:
+                status = DoQueryInterface(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_REQUESTPORT:
+            {
+                status = DoRequestPort(aCmd);
+                eventData = iPVMFPort;
+                break;
+            }
+
+            case PVMF_GENERIC_NODE_RELEASEPORT:
+                status = DoReleasePort(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_INIT:
+                status = DoInit(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_PREPARE:
+                status = DoPrepare(aCmd);
+                if (status == PVMFSuccess)
+                {
+                    ChangeExternalState(EPVMFNodePrepared);
+                }
+                break;
+
+            case PVMF_GENERIC_NODE_START:
+                status = DoStart(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_STOP:
+                status = DoStop(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_FLUSH:
+                status = DoFlush(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_PAUSE:
+                status = DoPause(aCmd);
+                break;
+
+            case PVMF_GENERIC_NODE_RESET:
+                status = DoReset(aCmd);
+                break;
+
+            default://unknown command type
+                status = PVMFFailure;
+                break;
+        }
+
+        if (status == PVMFPending)
+        {
+            int32 err;
+            OSCL_TRY(err, iCurrentCmdQueue.StoreL(aCmd););
+            OSCL_ASSERT(err == OsclErrNone);
+
+            //erase the original command
+            aCmdQ.Erase(&aCmd);
+        }
+        else
+        {
+            CommandComplete(aCmdQ, aCmd, status, eventData);
+        }
+    }
+}
+
+//Called to complete a node command.
+void PVMFClientServerSocketNode::CommandComplete(PVMFSocketNodeCmdQ& aCmdQ,
+        PVMFSocketNodeCommand& aCmd,
+        PVMFStatus aStatus,
+        OsclAny* aEventData,
+        PVUuid* aEventUUID,
+        int32* aEventCode)
+
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
+                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    bool canProcess = CanProcessCommand();
+
+    PVMFStatus status = aStatus;
+
+    if (aStatus == PVMFSuccess)
+    {
+        switch (aCmd.iCmd)
+        {
+            case PVMF_GENERIC_NODE_INIT:
+                ChangeExternalState(EPVMFNodeInitialized);
+                break;
+
+            case PVMF_GENERIC_NODE_PREPARE:
+                ChangeExternalState(EPVMFNodePrepared);
+                break;
+
+            case PVMF_GENERIC_NODE_START:
+                ChangeExternalState(EPVMFNodeStarted);
+                break;
+
+            case PVMF_GENERIC_NODE_STOP:
+                ChangeExternalState(EPVMFNodePrepared);
+                break;
+
+            case PVMF_GENERIC_NODE_PAUSE:
+                ChangeExternalState(EPVMFNodePaused);
+                break;
+
+            case PVMF_GENERIC_NODE_RESET:
+                ChangeExternalState(EPVMFNodeCreated);
+
+                //Complete the reset command.
+                {
+                    //cleanup all ports.
+                    CleanupPorts();
+                    SetState(EPVMFNodeIdle);
+                }
+                break;
+
+            case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+                //Complete the reset command.
+            {
+                //Since "cancel all" is effectively used as a Reset,
+                //go ahead and cleanup all ports.
+                CleanupPorts();
+            }
+            break;
+            default:
+                break;
+        }
+    }
+
+    PVInterface* extif = NULL;
+    PVMFBasicErrorInfoMessage* errormsg = NULL;
+    if (aEventUUID && aEventCode)
+    {
+        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
+    }
+    //else if no error input, see if "command error code" was set.
+    else if (iCommandErrorCode != PVMFSocketNodeErrorEventStart)
+    {
+        PVUuid eventuuid = PVMFSocketNodeEventTypeUUID;
+        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (iCommandErrorCode, eventuuid, NULL));
+        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
+    }
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, status, extif, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+
+    if (errormsg)
+    {
+        errormsg->removeRef();
+    }
+    iCommandErrorCode = PVMFSocketNodeErrorEventStart;//reset.
+
+    //See if there was a pending cancel waiting on the current command to
+    //complete.
+    if (!iCancelCmdQueue.empty()
+            && iCancelCmdQueue.front().iCmd == PVMF_GENERIC_NODE_CANCELCOMMAND)
+    {
+        CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
+    }
+
+    //May need to resume command handling if the AO was blocked
+    //waiting on asynchronous command completion, but it's unblocked now.
+    if (!canProcess
+            && CanProcessCommand()
+            && IsAdded())
+    {
+        RunIfNotReady();
+    }
+}
+
+PVMFCommandId PVMFClientServerSocketNode::QueueCommandL(PVMFSocketNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::QueueCommandL()"));
+    PVMFCommandId id;
+
+    id = iPendingCmdQueue.AddL(aCmd);
+
+    //This may be a processing trigger.
+    //Wakeup the AO if needed.
+    if (IsAdded()
+            && CanProcessCommand())
+    {
+        RunIfNotReady();
+    }
+
+    return id;
+}
+
+//This is the callback from Oscl Sockets for socket operation completion.
+OSCL_EXPORT_REF  void PVMFClientServerSocketNode::HandleSocketEvent(int32 aId, TPVSocketFxn aFxn, TPVSocketEvent aEvent, int32 aError)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::HandleSocketEvent() In aId=%d, aFxn=%d, aEvent=%d, aError=%d", aId, aFxn, aEvent, aError));
+
+    if (iSockConfig && aEvent == EPVSocketSuccess)
+    {
+        PVMFSocketActivity activity((aEvent == EPVSocketSuccess) ? PVMFSuccess : PVMFFailure, aId, aFxn, aEvent, aError);
+
+        //Call the appropriate handler
+        switch (aFxn)
+        {
+            case EPVSocketRecv:
+                OSCL_ASSERT(iSockConfig->iState.iRecvOperation == EPVSocketPortRecvOperation_Recv);
+
+                RecvOperationComplete(activity.iStatus, &activity);
+                break;
+
+            case EPVSocketSend:
+                OSCL_ASSERT(iSockConfig->iState.iSendOperation == EPVSocketPortSendOperation_Send);
+
+                SendOperationComplete(activity.iStatus, &activity);
+                break;
+
+            case EPVSocketShutdown:
+                //OSCL_ASSERT(iSockConfig->iState.iConnectOperation==EPVSocketPortConnectOperation_Shutdown);
+                SequenceComplete(PVMFSuccess);
+                //ConnectOperationComplete(activity.iStatus,&activity);
+                break;
+
+            default:
+                OSCL_ASSERT(0);//unexpected
+                break;
+        }
+    }
+    else if (aEvent == EPVSocketCancel)
+    {
+        switch (aFxn)
+        {
+            case EPVSocketRecv:
+                if (iSockConfig->iState.iSendOperation == EPVSocketPortSendOperation_Send
+                        && iSockConfig->iState.iSendOperationCanceled == false)
+                {//if does hv anything to send, cancel it
+                    CancelSendOperation();
+                }
+                else
+                {	//shutdown
+                    CloseSocketConnection();
+                }
+                break;
+
+            case EPVSocketSend:
+                if (iSockConfig->iState.iRecvOperation == EPVSocketPortRecvOperation_Recv
+                        && iSockConfig->iState.iRecvOperationCanceled == false)
+                {
+                    CancelRecvOperation();
+                }
+                else
+                {
+                    //shutdown
+                    CloseSocketConnection();
+                }
+                break;
+
+            case EPVSocketShutdown:
+                //quite difficult to cancel shutdown
+                break;
+
+            default:
+                OSCL_ASSERT(0);//unexpected
+                break;
+        }
+    }
+    else
+    {//failure
+        switch (aFxn)
+        {
+            case EPVSocketRecv:
+                iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_None;
+                iSockConfig->iState.iRecvOperationCanceled = true;
+                break;
+
+            case EPVSocketSend:
+                iSockConfig->iState.iSendOperation = EPVSocketPortSendOperation_None;
+                iSockConfig->iState.iSendOperationCanceled = true;
+                break;
+
+            case EPVSocketShutdown:
+            default:
+                OSCL_ASSERT(0);//unexpected
+                break;
+        }
+    }
+}
+
+
+//Allocate a node port and add it to the port vector.
+PVMFStatus PVMFClientServerSocketNode::AddPort(int32 tag)
+{
+    iPVMFPort = new PVMFClientServerSocketPort((int32)tag,
+            this,
+            DEFAULT_DATA_QUEUE_CAPACITY,
+            DEFAULT_DATA_QUEUE_CAPACITY,
+            DEFAULT_READY_TO_RECEIVE_THRESHOLD_PERCENT,
+            //the output queue is empty because
+            //this node pushes data directly to the
+            //connecte port's input.
+            0, 0, 0);
+
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::AllocatePortMemPool(int32 tag, PVMFSocketNodeMemPool* & aMemPool)
+{
+    aMemPool = NULL;
+    OsclAny *MemPtr = NULL;
+    MemPtr = iAlloc.ALLOCATE(sizeof(PVMFSocketNodeMemPool));
+    if (MemPtr == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    int32 errcode = 0;
+    OSCL_TRY(errcode, aMemPool = OSCL_PLACEMENT_NEW(MemPtr, PVMFSocketNodeMemPool(SNODE_DEFAULT_NUMBER_MEDIADATA_IN_MEMPOOL);));
+    if (errcode != OsclErrNone)
+    {
+        PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::DoRequestPort: PVMFSocketNodeMemPool Construct Failed Ln %d", errcode, __LINE__));
+        iAlloc.deallocate(MemPtr);
+        return PVMFErrNoMemory;
+    }
+
+    aMemPool->iPortTag = tag;
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::CancelSendOperation()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::CancelSendOperation()"));
+
+    PVMFStatus status = PVMFSuccess;
+
+    switch (iSockConfig->iState.iSendOperation)
+    {
+        case EPVSocketPortSendOperation_None:
+            break;
+
+        case EPVSocketPortSendOperation_Send:
+            if (iSockConfig->iTCPSocket)
+            {
+                if (!iSockConfig->iState.iSendOperationCanceled)
+                {
+                    iSockConfig->iState.iSendOperationCanceled = true;
+                    iSockConfig->iTCPSocket->CancelSend();
+                }
+                status = PVMFPending;
+                //wait on send to complete in HandleSocketEvent
+            }
+            break;
+
+        default:
+            OSCL_ASSERT(0);
+            status = PVMFFailure;
+            break;
+    }
+    return status;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoStopNodeActivity()
+{
+    if (iNumStopPortActivityPending > 0)
+        return PVMFPending;
+
+    //Stop socket activity on all ports.
+    uint32 nPortsPending = 0;
+    if (iSockConfig)
+    {
+        // discard any saved socket activity events
+        iSockConfig->iSocketRecvActivity.iValid = false;
+
+        //if a request port is going on, be sure to complete the command,
+        //although we will interrupt the current processing.
+        if (iSockConfig->iState.iSequence == EPVSocketPortSequence_RequestPort
+                && iCurrentCmdQueue.size()
+                && iCurrentCmdQueue.front().iCmd == PVMF_GENERIC_NODE_REQUESTPORT)
+        {
+            CommandComplete(iCurrentCmdQueue, iCurrentCmdQueue.front(), PVMFErrCancelled, NULL);
+        }
+
+        //if a cleanup is already underway, just keep waiting for it to complete,
+        //else start a new sequence
+        if (iSockConfig->iState.iSequence == EPVSocketPortSequence_SocketCleanup)
+        {
+            nPortsPending++;
+        }
+        else if (StartSequence(iSockConfig->iState.iSequence = EPVSocketPortSequence_SocketCleanup) == PVMFPending)
+        {
+            nPortsPending++;
+        }
+    }
+
+    if (nPortsPending > 0)
+        iNumStopPortActivityPending = nPortsPending;
+
+    if (iNumStopPortActivityPending > 0)
+        return PVMFPending; //wait on completion in SequenceComplete.
+
+    return PVMFSuccess;
+}
+
+//Flush is implemented for this node, but hasn't been tested.
+PVMFStatus PVMFClientServerSocketNode::DoFlush(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::DoFlush() In"));
+
+    if ((iInterfaceState != EPVMFNodeStarted) && (iInterfaceState != EPVMFNodePaused))
+    {
+        return PVMFErrInvalidState;
+    }
+
+    PVMFStatus status = PVMFSuccess;
+    {
+        iPVMFPort->SuspendInput();
+        if (status != PVMFPending
+                && iPVMFPort->IncomingMsgQueueSize() > 0)
+        {
+            status = PVMFPending;//Wait on this queue to empty.
+            //Completion is detected in SequenceComplete.
+        }
+    }
+    return status;
+}
+
+//Pause is a do-nothing for this node.
+PVMFStatus PVMFClientServerSocketNode::DoPause(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::DoPause() In"));
+
+    if (iInterfaceState == EPVMFNodePaused)
+    {
+        return PVMFSuccess;
+    }
+
+    if (iInterfaceState != EPVMFNodeStarted)
+    {
+        return PVMFErrInvalidState;
+    }
+
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoReset(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::DoReset()"));
+
+    /* This node allows a reset from any state */
+
+    return DoStopNodeActivity();
+}
+
+PVMFStatus PVMFClientServerSocketNode::DoQueryUuid(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    /*	//This node supports Query UUID from any state
+
+    	OSCL_String* mimetype;
+    	Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
+    	bool exactmatch;
+    	aCmd.PVMFSocketNodeCommandBase::Parse(mimetype,uuidvec,exactmatch);
+
+    	//Try to match the input mimetype against any of
+    	//the custom interfaces for this node
+
+    	//Match against custom interface1...
+    	if (*mimetype==PVMF_SOCKET_NODE_EXTENSION_INTERFACE_MIMETYPE
+    		//also match against base mimetypes for custom interface1,
+    		//unless exactmatch is set.
+    		|| (!exactmatch && *mimetype==PVMF_SOCKET_NODE_MIMETYPE)
+    		|| (!exactmatch && *mimetype==PVMF_SOCKET_NODE_BASEMIMETYPE))
+    	{
+
+    		PVUuid uuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID);
+    		uuidvec->push_back(uuid);
+    	}*/
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoQueryInterface(PVMFSocketNodeCommand&  aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFClientServerSocketNode::DoRequestPort(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    //retrieve port tag.
+    int32 tag;
+    OSCL_String* portconfig;
+    aCmd.PVMFSocketNodeCommandBase::Parse(tag, portconfig);
+
+    PVMFStatus status = AddPort(tag);
+    if (status != PVMFSuccess)
+        return status;
+
+    //create the socket config
+    iSockConfig = OSCL_NEW(SocketPortConfig, ());
+    iPVMFPort->iConfig = iSockConfig;
+    iSockConfig->iPVMFPort = iPVMFPort;
+
+    iSockConfig->iContainer = this;
+    iSockConfig->iSockId = iSocketID++;
+    iSockConfig->iTag = tag;
+    iSockConfig->iTCPSocket = iSocketHandle;
+
+    //create the mem pool
+    PVMFSocketNodeMemPool* memPool;
+    status = AllocatePortMemPool(tag, memPool);
+    if (status == PVMFSuccess)
+        iSockConfig->iMemPool = memPool;
+    return status;
+}
+
+
+//Release ports is a do-nothing for this node.
+PVMFStatus PVMFClientServerSocketNode::DoReleasePort(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoInit(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    if (iInterfaceState != EPVMFNodeIdle)
+    {
+        return PVMFErrInvalidState;
+    }
+    return PVMFSuccess;
+}
+
+
+//Prepare is a do-nothing for this node.
+PVMFStatus PVMFClientServerSocketNode::DoPrepare(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::DoPrepare() In"));
+
+    if (iInterfaceState != EPVMFNodeInitialized)
+    {
+        return PVMFErrInvalidState;
+    }
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoStart(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    if (iInterfaceState == EPVMFNodeStarted)
+    {
+        return PVMFSuccess;//already started.
+    }
+
+    if (iInterfaceState != EPVMFNodePrepared &&
+            iInterfaceState != EPVMFNodePaused)
+    {
+        return PVMFErrInvalidState;
+    }
+
+    TPVMFNodeInterfaceState curState = iInterfaceState;
+    ChangeExternalState(EPVMFNodeStarted);
+
+    PVMFStatus status = PVMFSuccess;
+    if (iSockConfig)
+    {
+        //Start handling incoming messages
+        if (CanProcessIncomingMsg())
+            ProcessIncomingMsg();
+
+        //Start the receives.
+        if (CanReceive())
+        {
+            status = StartRecvOperation();
+            if (status == PVMFPending)
+            {
+                status = PVMFSuccess;
+            }
+            else if (status != PVMFSuccess)
+            {
+                ChangeExternalState(curState);
+            }
+        }
+    }
+    return status;
+}
+
+
+
+PVMFStatus PVMFClientServerSocketNode::DoStop(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::DoStop() In"));
+
+    if ((iInterfaceState != EPVMFNodeStarted) && (iInterfaceState != EPVMFNodePaused))
+    {
+        return PVMFErrInvalidState;
+    }
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoCancelCommand(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::DoCancelCommand() Called"));
+
+    // extract the command ID from the parameters.
+    PVMFCommandId cmdId;
+    aCmd.PVMFSocketNodeCommandBase::Parse(cmdId);
+
+    if (!iCurrentCmdQueue.empty()
+            && iCurrentCmdQueue.front().iId == cmdId)
+    {
+        return DoCancelCurrentCommand(iCurrentCmdQueue, iCurrentCmdQueue.front());
+        //wait on current command to complete.  The cancel command
+        //will ultimately be completed in the "CommandComplete" for the current command.
+    }
+
+    {
+        // start at element 1 since this cancel command is element 0
+        PVMFSocketNodeCommand* cmd = iPendingCmdQueue.FindById(cmdId, 1);
+        if (cmd)
+        {
+            // cancel the queued command.  Note this will complete out-of-order.
+            CommandComplete(iPendingCmdQueue, *cmd, PVMFErrCancelled);
+            // no further action is required.
+            return PVMFSuccess;
+        }
+    }
+
+    //this command fails if the given command is not queued or in progress.
+    return PVMFErrArgument;
+}
+
+PVMFStatus PVMFClientServerSocketNode::DoCancelAllCommands(PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVMFStatus status = DoStopNodeActivity();
+
+    if (!iCurrentCmdQueue.empty())
+        CommandComplete(iCurrentCmdQueue, iCurrentCmdQueue.front(), PVMFErrCancelled);
+
+    //Cancel all other pending commands, except for this one which is
+    //element 0 in the queue
+    for (uint32 i = 1;i < iPendingCmdQueue.size();i++)
+        CommandComplete(iPendingCmdQueue, iPendingCmdQueue[i], PVMFErrCancelled);
+
+    //May need to wait on completion of StopNodeActivity.
+    return status;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::DoCancelCurrentCommand(PVMFSocketNodeCmdQ& aCmdQ, PVMFSocketNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmdQ);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::DoCancelCurrentCommand()"));
+    switch (aCmd.iCmd)
+    {
+
+        case PVMF_GENERIC_NODE_REQUESTPORT:
+            //there may be a connect operation pending-- cancel it.
+        {
+            if (iPVMFPort)
+            {
+                //SocketPortConfig* iSockConfig=iRequestedPort->iConfig;
+                if (iSockConfig)
+                {
+                    //	CancelConnectOperation();
+                    return PVMFPending;//wait on the operation to complete
+                    //in HandleSocketEvent or HandleDNSEvent
+                }
+            }
+            //shouldn't get here...
+            return PVMFFailure;
+        }
+        break;
+
+        case PVMF_GENERIC_NODE_RESET:
+            //it's too complicated to cancel a reset, so just wait on completion
+            return PVMFPending;
+
+        case PVMF_GENERIC_NODE_FLUSH:
+            //to cancel a flush, just discard all remaining port messages
+            //and keep waiting on completion of current message.
+        {
+            iPVMFPort->ClearMsgQueues();
+        }
+        return PVMFPending;//keep waiting on flush completion in SequenceComplete.
+
+        case PVMF_GENERIC_NODE_CANCELCOMMAND:
+        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+            //these have asynchronous completion, but the command handling prevents
+            //processing a cancel during a cancel, so we shouldn't get here.
+            OSCL_ASSERT(0);
+            return PVMFFailure;
+
+        default:
+            //no other node commands have asynchronous completion, so this is unexpected.
+            OSCL_ASSERT(0);
+            return PVMFFailure;
+    }
+}
+
+PVMFStatus PVMFClientServerSocketNode::CancelRecvOperation()
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::CancelRecvOperation() In"));
+
+    PVMFStatus status = PVMFSuccess;
+
+    switch (iSockConfig->iState.iRecvOperation)
+    {
+        case EPVSocketPortRecvOperation_None:
+            break;
+
+        case EPVSocketPortRecvOperation_Recv:
+            if (iSockConfig->iTCPSocket)
+            {
+                if (!iSockConfig->iState.iRecvOperationCanceled)
+                {
+                    iSockConfig->iState.iRecvOperationCanceled = true;
+                    iSockConfig->iTCPSocket->CancelRecv();
+                }
+                status = PVMFPending;
+                //wait on recv to complete in HandleSocketEvent
+            }
+            break;
+
+        case EPVSocketPortRecvOperation_WaitOnConnectedPort:
+            //just clear the state
+            iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_None;
+            //also discard the received data and the associated recv activity
+            if (iSockConfig->iSocketRecvActivity.iValid)
+                iSockConfig->iSocketRecvActivity.iValid = false;
+            if (iSockConfig->iPendingRecvMediaData.GetRep())
+                iSockConfig->iPendingRecvMediaData.Unbind();
+            break;
+
+        case EPVSocketPortRecvOperation_WaitOnMemory:
+            if (iSockConfig->iMemPool != NULL)
+                iSockConfig->iMemPool->CancelFreeChunkAvailableCallback();
+            //clear the state
+            iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_None;
+            break;
+
+        default:
+            OSCL_ASSERT(0);//add code for this case
+            status = PVMFFailure;
+            break;
+    }
+    return status;
+}
+
+//a memory pool callback
+void SocketPortConfig::freechunkavailable(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    //complete the "wait on memory" state
+    if (iState.iRecvOperation == EPVSocketPortRecvOperation_WaitOnMemory)
+    {
+        iContainer->RecvOperationComplete(PVMFSuccess, NULL);	//*this,
+    }
+}
+
+
+void PVMFClientServerSocketNode::CleanupTCP()
+{
+    //cleanup media messages
+    if (iSockConfig->iPendingRecvMediaData.GetRep() != NULL)
+    {
+        iSockConfig->iPendingRecvMediaData.Unbind();
+
+    }
+    if (iSockConfig->iPendingSendMediaData.GetRep() != NULL)
+    {
+        iSockConfig->iPendingSendMediaData.Unbind();
+    }
+}
+
+
+void PVMFClientServerSocketNode::CleanupPorts()
+{
+    if (iPVMFPort)
+    {
+        SocketPortConfig* it = iPVMFPort->iConfig;
+        if (it)
+        {
+            //unlink the PVMFPort so we won't try to send any EOS msg
+            //during the TCP cleanup.
+            it->iPVMFPort = NULL;
+            it->CleanupMemPools();
+            OSCL_DELETE(it);
+            iPVMFPort->iConfig = NULL;
+        }
+
+        iPVMFPort->Disconnect();
+        delete iPVMFPort;
+        iPVMFPort = NULL;
+    }
+}
+
+
+PVMFSocketNodeMemPool::PVMFSocketNodeMemPool(uint32 aMemPoolNumBufs)
+        : iMediaDataMemPool(NULL)
+{
+    iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (aMemPoolNumBufs, MEDIA_DATA_CLASS_SIZE));
+    iInternalAlloc = NULL;
+}
+
+
+void SocketPortConfig::DoSetSocketPortMemAllocator(PVLogger* aLogger, OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc)
+{
+    if (aAlloc.GetRep())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, PVLOGMSG_INFO, (0, "SocketPortConfig::DoSetSocketPortMemAllocator() Using input mem allocator"));
+        /*
+         * Deletion of any previously created allocators is handled as part of
+         * reset / node delete. So just re-assign the shared ptr here.
+         */
+        if (iMemPool->iSocketAllocSharedPtr.GetRep() != NULL)
+        {
+            iMemPool->iSocketAllocSharedPtr.Unbind();
+        }
+        iMemPool->iSocketAllocSharedPtr = aAlloc;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, PVLOGMSG_INFO, (0, "SocketPortConfig::DoSetSocketPortMemAllocator() no mem allocator. Create one"));
+
+        uint aligned_socket_alloc_size = oscl_mem_aligned_size(sizeof(PVMFSMSharedBufferAllocWithReSize));
+
+        uint aligned_refcnt_size = 	oscl_mem_aligned_size(sizeof(OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>));
+
+        OsclMemAllocator my_alloc;
+        uint8 *my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size + aligned_socket_alloc_size);
+        OsclRefCounter *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>(my_ptr));
+        my_ptr += aligned_refcnt_size;
+
+        // allow one resize for a maximum mempool size of TCP_BUFFER_SIZE*TCP_BUFFER_IN_MEMPOOL
+        iMemPool->iInternalAlloc = OSCL_NEW(PVMFSMSharedBufferAllocWithReSize, (
+                                                iContainer->iMaxTcpRecvBufferSize * (iContainer->iMaxTcpRecvBufferCount - 1), "TCPsocketBuffer",
+                                                1, iContainer->iMaxTcpRecvBufferSize));
+
+        PVMFSharedSocketDataBufferAlloc *alloc_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSharedSocketDataBufferAlloc(iMemPool->iInternalAlloc));
+
+        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> shared_alloc(alloc_ptr, my_refcnt);
+        iMemPool->iSocketAllocSharedPtr = shared_alloc;
+    }
+}
+
+void SocketPortConfig::CleanupMemPools()
+{
+    if (iMemPool->iInternalAlloc != NULL)
+    {
+        iMemPool->iInternalAlloc->DecrementKeepAliveCount();
+        uint32 numOutStandingBuffers =
+            iMemPool->iInternalAlloc->getNumOutStandingBuffers();
+        if (numOutStandingBuffers == 0)
+        {
+            OSCL_DELETE((iMemPool->iInternalAlloc));
+            iMemPool->iInternalAlloc = NULL;
+        }
+    }
+    PVMFSocketNodeAllocator alloc;
+    iMemPool->~PVMFSocketNodeMemPool();
+    alloc.deallocate((OsclAny*)(iMemPool));
+    iMemPool = NULL;
+}
+
+
+void PVMFClientServerSocketNode::ReportErrorEvent(PVMFEventType aEventType,
+        OsclAny* aEventData,
+        PVUuid* aEventUUID,
+        int32* aEventCode)
+{
+    if (aEventUUID && aEventCode)
+    {
+        PVMFBasicErrorInfoMessage* eventmsg =
+            OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        PVMFAsyncEvent asyncevent(PVMFErrorEvent,
+                                  aEventType,
+                                  NULL,
+                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
+                                  aEventData,
+                                  NULL,
+                                  0);
+        PVMFNodeInterface::ReportErrorEvent(asyncevent);
+        eventmsg->removeRef();
+    }
+    else
+    {
+        PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
+    }
+}
+
+void PVMFClientServerSocketNode::ReportInfoEvent(PVMFEventType aEventType,
+        OsclAny* aEventData,
+        PVUuid* aEventUUID,
+        int32* aEventCode)
+{
+    if (aEventUUID && aEventCode)
+    {
+        PVMFBasicErrorInfoMessage* eventmsg =
+            OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        PVMFAsyncEvent asyncevent(PVMFInfoEvent,
+                                  aEventType,
+                                  NULL,
+                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
+                                  aEventData,
+                                  NULL,
+                                  0);
+        PVMFNodeInterface::ReportInfoEvent(asyncevent);
+        eventmsg->removeRef();
+    }
+    else
+    {
+        PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
+    }
+}
+
+OSCL_EXPORT_REF bool PVMFClientServerSocketNode::setSocketPortMemAllocator(PVMFPortInterface* aInPort,
+        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc)
+{
+
+    PVMFClientServerSocketPort* aPort = OSCL_STATIC_CAST(PVMFClientServerSocketPort*, aInPort);
+    SocketPortConfig* tmpSockConfig = (aPort) ? aPort->iConfig : NULL;
+    if (NULL != tmpSockConfig)
+    {
+        tmpSockConfig->DoSetSocketPortMemAllocator(iLogger, aAlloc);
+        return true;
+    }
+    return false;
+}
+
+
+bool PVMFClientServerSocketNode::CanProcessIncomingMsg()
+{
+    return
+        //node is started
+        iInterfaceState == EPVMFNodeStarted
+        //port has input messages
+        && iSockConfig->iPVMFPort && iSockConfig->iPVMFPort->IncomingMsgQueueSize() > 0
+        //port is not busy with any sequence
+        && iSockConfig->iState.iSequence == EPVSocketPortSequence_None;
+}
+
+
+void PVMFClientServerSocketNode::ProcessIncomingMsg()
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::ProcessIncomingMsg: aPort=0x%x", iSockConfig->iPVMFPort));
+
+    //Dequeue the incoming message
+    PVMFSharedMediaMsgPtr msg;
+    PVMFStatus status = iSockConfig->iPVMFPort->DequeueIncomingMsg(msg);
+    if (status != PVMFSuccess)
+    {
+        PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::ProcessIncomingDataMsg: Error - DequeueIncomingMsg failed"));
+        ReportErrorEvent(PVMFErrPortProcessing);
+        return ;
+    }
+
+    OSCL_ASSERT(iSockConfig->iState.iSequence == EPVSocketPortSequence_None);
+
+    //Handle 3 types of messages
+    if (msg->getFormatID() == PVMF_MEDIA_CMD_SOCKET_DISCONNECT_FORMAT_ID)
+    {
+        //Disconnect message
+        StartSequence(EPVSocketPortSequence_InputDisconnectMsg);
+    }
+    else if (msg->getFormatID() == PVMF_MEDIA_MSG_DATA_FORMAT_ID)
+    {
+        //Start the sequence
+        StartSequence(EPVSocketPortSequence_InputDataMsg, (OsclAny*)&msg);
+    }
+    else
+    {
+        //unexpected message type
+        ReportErrorEvent(PVMFErrPortProcessing);
+    }
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::StartSendOperation(PVMFSharedMediaMsgPtr& aMsg)
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::StartSendOperation() In"));
+
+    //caller should have verified we can send now.
+    OSCL_ASSERT(iSockConfig->iState.iSendOperation == EPVSocketPortSendOperation_None);
+
+    //caller should provide a media data message as input
+    OSCL_ASSERT(aMsg->getFormatID() == PVMF_MEDIA_MSG_DATA_FORMAT_ID);
+
+    //there should be either a UDP or TCP socket on this port
+    if (!iSockConfig->iTCPSocket)
+    {
+        return PVMFFailure;
+    }
+
+    // Retrieve memory fragment to write to
+    if (iSockConfig->iPendingSendMediaData.GetRep())
+        iSockConfig->iPendingSendMediaData.Unbind();
+
+    convertToPVMFMediaData(iSockConfig->iPendingSendMediaData, aMsg);
+    OsclRefCounterMemFrag refCtrMemFragOut;
+    iSockConfig->iPendingSendMediaData->getMediaFragment(0, refCtrMemFragOut);
+
+    PVMFStatus status = PVMFFailure;
+
+    if (iSockConfig->iTCPSocket)
+    {
+        iSockConfig->iState.iSendOperation = EPVSocketPortSendOperation_Send;
+
+        TPVSocketEvent retVal = iSockConfig->iTCPSocket->Send((uint8*)refCtrMemFragOut.getMemFragPtr(),
+                                refCtrMemFragOut.getMemFragSize(),
+                                TIMEOUT_SEND);
+
+        if (retVal == EPVSocketPending)
+            status = PVMFPending;//wait on HandleSocketEvent callback
+        else
+            status = PVMFFailure;
+
+        if (PVMFPending != status)
+        {
+            PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::StartSendOperation: TCP - Error. status=%d", status));
+        }
+    }
+
+    //Handle synchronous completion or failures
+    if (status != PVMFPending)
+        status = SendOperationComplete(status, NULL);
+
+    return status;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::SendOperationComplete(PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::SendOperationComplete()"));
+
+    OSCL_ASSERT(aStatus != PVMFPending);
+
+    PVMFStatus status = aStatus;
+
+    //Update the send state
+    TPVSocketPortSendOperation curOp = iSockConfig->iState.iSendOperation;
+    iSockConfig->iState.iSendOperation = EPVSocketPortSendOperation_None;
+    iSockConfig->iState.iSendOperationStatus = aStatus;
+    iSockConfig->iState.iSendOperationCanceled = false;
+
+    //Release the media buffer after each send operation, regardless of success/fail.
+    if (iSockConfig->iPendingSendMediaData.GetRep() != NULL)
+        iSockConfig->iPendingSendMediaData.Unbind();
+
+    if (aSocketActivity)
+    {
+        //Datapath logging
+        switch (aSocketActivity->iEvent)
+        {
+            case EPVSocketSuccess:
+                //PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0,"PVMFClientServerSocketNode::SendOperationComplete - Success - SockId=%d, Mime=%s", iSockConfig->iSockId, iSockConfig->iMime.get_str()));
+                break;
+            case EPVSocketTimeout:
+                //PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0,"PVMFClientServerSocketNode::SendOperationComplete - TimeOut - SockId=%d, Mime=%s", iSockConfig->iSockId, iSockConfig->iMime.get_str()));
+                break;
+            case EPVSocketFailure:
+                //PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0,"PVMFClientServerSocketNode::SendOperationComplete - Failed - SockId=%d, Mime=%s", iSockConfig->iSockId, iSockConfig->iMime.get_str()));
+                break;
+            case EPVSocketCancel:
+                //PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0,"PVMFClientServerSocketNode::SendOperationComplete - Cancelled - SockId=%d, Mime=%s", iSockConfig->iSockId, iSockConfig->iMime.get_str()));
+                break;
+            default:
+                OSCL_ASSERT(0);
+                break;
+        }
+    }
+
+    //report TCP errors.
+    if (aStatus != PVMFSuccess
+            && curOp == EPVSocketPortSendOperation_Send)
+    {
+        ReportSocketNodeError(PVMFErrResource, PVMFSocketNodeErrorTCPSocketSendError);
+    }
+
+    //This completes an input data message sequence
+    if (iSockConfig->iState.iSequence == EPVSocketPortSequence_InputDataMsg)
+        SequenceComplete(aStatus);
+    return status;
+}
+
+
+bool PVMFClientServerSocketNode::CanReceive()
+{
+    return
+        //node is started
+        iInterfaceState == EPVMFNodeStarted
+        //port is connected
+        && iSockConfig->iPVMFPort && iSockConfig->iPVMFPort->IsConnected()
+        //socket exists (gets created during request port or connect sequence)
+        && (iSockConfig->iTCPSocket)
+        //port is not busy with any sequence other than sending data
+        && (iSockConfig->iState.iSequence == EPVSocketPortSequence_None
+            || iSockConfig->iState.iSequence == EPVSocketPortSequence_InputDataMsg)
+        //port is not busy with any receive operation.
+        && iSockConfig->iState.iRecvOperation == EPVSocketPortRecvOperation_None
+        //there's no node stop going on.
+        && iNumStopPortActivityPending < 0;
+}
+
+//Enter the "wait on memory" state
+void PVMFClientServerSocketNode::StartRecvWaitOnMemory(int32 aSize)
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::StartRecvWaitOnMemory() In"));
+
+    iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_WaitOnMemory;
+
+    if (aSize)
+    {//wait on data buffer
+        iSockConfig->iMemPool->notifyfreechunkavailable(*iSockConfig, aSize, NULL);
+    }
+    else
+    {//wait on media data wrapper
+        iSockConfig->iMemPool->iMediaDataMemPool->notifyfreechunkavailable(*iSockConfig, NULL);
+    }
+}
+
+//Enter the "wait on connected port" state
+void PVMFClientServerSocketNode::StartRecvWaitOnConnectedPort(PVMFSocketActivity& aSocketActivity)
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::StartRecvWaitOnConnectedPort() In"));
+
+    //outgoing queue is busy-- must queue this event for later processing
+    switch (aSocketActivity.iFxn)
+    {
+        case EPVSocketRecv:
+        case EPVSocketRecvFrom:
+            iSockConfig->iSocketRecvActivity.Set(aSocketActivity.iStatus
+                                                 , aSocketActivity.iId
+                                                 , aSocketActivity.iFxn
+                                                 , aSocketActivity.iEvent
+                                                 , aSocketActivity.iError);
+            break;
+        default:
+            OSCL_ASSERT(false);//invalid input arg.
+            break;
+    }
+
+    //current state shoudl be idle
+    OSCL_ASSERT(iSockConfig->iState.iRecvOperation == EPVSocketPortRecvOperation_None);
+
+    iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_WaitOnConnectedPort;
+}
+
+
+PVMFStatus PVMFClientServerSocketNode::StartRecvOperation()
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::StartRecvOperation() In"));
+
+    //caller should have verified we can receive data right now.
+    OSCL_ASSERT(iSockConfig->iState.iRecvOperation == EPVSocketPortRecvOperation_None);
+
+    //there should be either a UDP or TCP socket on this port and a memory pool.
+    if (!iSockConfig->iTCPSocket)
+    {
+        return PVMFFailure;
+    }
+    if (!iSockConfig->iMemPool)
+    {
+        return PVMFFailure;
+    }
+
+    PVMFStatus status = PVMFFailure;
+
+    if (iSockConfig->iTCPSocket)
+    {
+        iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_Recv;
+
+        //Allocate memory
+        int32 err;
+        OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
+        OSCL_TRY(err,
+                 mediaDataImpl = iSockConfig->iMemPool->getMediaDataImpl(iMaxTcpRecvBufferSize););
+        if (err != OsclErrNone)
+        {
+            StartRecvWaitOnMemory(iMaxTcpRecvBufferSize);
+            status = PVMFPending;
+            //wait on memory pool callback "notifyfreechunkavailable"
+        }
+
+        else
+        {
+            OSCL_TRY(err, iSockConfig->iPendingRecvMediaData = PVMFMediaData::createMediaData(
+                         mediaDataImpl, iSockConfig->iMemPool->iMediaDataMemPool););
+            if (err != OsclErrNone)
+            {
+                StartRecvWaitOnMemory();
+                status = PVMFPending;
+                //wait on memory pool callback "notifyfreechunkavailable"
+            }
+
+            else
+            {
+                // Retrieve memory fragment to write to
+                OsclRefCounterMemFrag refCtrMemFragOut;
+                iSockConfig->iPendingRecvMediaData->getMediaFragment(0, refCtrMemFragOut);
+
+                //Issue the Oscl socket request
+                TPVSocketEvent retVal = iSockConfig->iTCPSocket->Recv((uint8*)refCtrMemFragOut.getMemFragPtr()
+                                        , refCtrMemFragOut.getCapacity()
+                                        , TIMEOUT_RECV);
+                if (EPVSocketPending != retVal)
+                {
+                    status = PVMFFailure;
+                }
+                else
+                {
+                    status = PVMFPending;
+                    //wait on HandleSocketEvent callback.
+                }
+            }
+        }
+    }
+    else	//for (iTCPSocket==NULL)
+    {
+        PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::StartRecvOperation() Unexpected error, no socket"));
+    }
+
+    //Handle synchronous completion or failure.
+    if (status != PVMFPending
+            && status != PVMFFailure)
+    {
+        PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::StartRecvOperation: Error. status=%d", status));
+    }
+
+    if (status != PVMFPending)
+        status = RecvOperationComplete(status, NULL);
+
+    return status;
+}
+
+PVMFStatus PVMFClientServerSocketNode::RecvOperationComplete(PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity)
+{
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::RecvOperationComplete() In"));
+
+    //status should never be pending here
+    OSCL_ASSERT(aStatus != PVMFPending);
+
+    PVMFStatus status = aStatus;
+    bool recvOperationCanceled = iSockConfig->iState.iRecvOperationCanceled;
+
+    //check the condition of reset here
+    if (iSockConfig->iState.iSequence == EPVSocketPortSequence_SocketCleanup
+            || recvOperationCanceled)
+    {
+        return PVMFSuccess;
+    }
+
+    //Update the state
+    TPVSocketPortRecvOperation curOp = iSockConfig->iState.iRecvOperation;
+    iSockConfig->iState.iRecvOperation = EPVSocketPortRecvOperation_None;
+    iSockConfig->iState.iRecvOperationStatus = aStatus;
+    iSockConfig->iState.iRecvOperationCanceled = false;
+
+    switch (curOp)
+    {
+        case EPVSocketPortRecvOperation_WaitOnMemory:
+            //a memory wait is complete.
+            //PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0, "PVMFClientServerSocketNode::RecvOperationComplete WaitOnMemory - SockId=%d, Mime=%s ", iSockConfig->iSockId, iSockConfig->iMime.get_str()));
+            break;
+
+        case EPVSocketPortRecvOperation_WaitOnConnectedPort:
+            //a port wait is complete
+            if (iSockConfig->iSocketRecvActivity.iValid)
+            {
+                iSockConfig->iSocketRecvActivity.iValid = false;
+
+                switch (iSockConfig->iSocketRecvActivity.iFxn)
+                {
+                    case EPVSocketRecv:
+                        HandleRecvComplete(iSockConfig->iSocketRecvActivity.iStatus
+                                           , &iSockConfig->iSocketRecvActivity, recvOperationCanceled);
+                        break;
+                    default:
+                        OSCL_ASSERT(0);//invalid arg
+                        break;
+                }
+            }
+            break;
+
+        case EPVSocketPortRecvOperation_Recv:
+            HandleRecvComplete(aStatus, aSocketActivity, recvOperationCanceled);
+            break;
+
+        default:
+            OSCL_ASSERT(0);//add code for this case
+            break;
+    }
+
+    if (CanReceive())
+        status = StartRecvOperation();
+
+    return status;
+}
+
+
+void PVMFClientServerSocketNode::HandleRecvComplete(PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity, bool aRecvOperationCanceled)
+{
+    OSCL_UNUSED_ARG(aRecvOperationCanceled);
+    PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFClientServerSocketNode::HandleRecvComplete() In"));
+
+    //operation should be complete when this is called.
+    OSCL_ASSERT(aStatus != PVMFPending);
+
+    //If there's no socket activity input, then this must be a failure in initiating
+    //a Recv operation.
+    if (!aSocketActivity || !iSockConfig->iPVMFPort
+            || !iSockConfig->iPVMFPort->IsConnected())
+    {
+        OSCL_ASSERT(aStatus != PVMFSuccess);
+        ReportSocketNodeError(PVMFErrResource, PVMFSocketNodeErrorSocketFailure);
+        //release media data
+        if (iSockConfig->iPendingRecvMediaData.GetRep())
+            iSockConfig->iPendingRecvMediaData.Unbind();
+        return;
+    }
+
+    if (aSocketActivity->iEvent == EPVSocketSuccess)
+    {
+        if (iSockConfig->iPVMFPort->IsOutgoingQueueBusy())
+        {
+            //wait on port so we can send recv data.
+            StartRecvWaitOnConnectedPort(*aSocketActivity);
+            return;
+        }
+    }
+
+    //If we get here then it's time to process the recv result.
+
+    //Release media data on failure
+    if (aStatus != PVMFSuccess)
+    {
+        if (iSockConfig->iPendingRecvMediaData.GetRep())
+            iSockConfig->iPendingRecvMediaData.Unbind();
+    }
+
+    switch (aSocketActivity->iEvent)
+    {
+        case EPVSocketSuccess:
+        {
+            //Get data length and set media buffer size
+            int32 len;
+            iSockConfig->iTCPSocket->GetRecvData(&len);
+            if (len <= 0)
+            {
+                PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::HandleRecvComplete - Sucessful Recv With Zero Length"));
+                OSCL_ASSERT(false);
+            }
+            iSockConfig->iPendingRecvMediaData->setMediaFragFilledLen(0, len);
+
+            // Resize the buffer
+            if (iSockConfig->iMemPool)
+            {
+                OsclSharedPtr<PVMFMediaDataImpl> mediaMsgImpl;
+                iSockConfig->iPendingRecvMediaData->getMediaDataImpl(mediaMsgImpl);
+                iSockConfig->iMemPool->resizeSocketDataBuffer(mediaMsgImpl);
+            }
+            else
+            {
+                PVMF_SOCKETNODE_LOGERROR((0, "PVMFClientServerSocketNode::HandleRecvComplete() ERROR:mempool not found"));
+                OSCL_ASSERT(0);
+                return ;
+            }
+
+            //queue to next port
+            PVMFSharedMediaMsgPtr aMediaMsgPtr;
+            convertToPVMFMediaMsg(aMediaMsgPtr, iSockConfig->iPendingRecvMediaData);
+
+            PVMFStatus status = iSockConfig->iPVMFPort->QueueOutgoingMsg(aMediaMsgPtr);
+            if (status != PVMFSuccess)
+            {
+                ReportErrorEvent(PVMFErrPortProcessing);
+                return ;
+            }
+        }
+        break;
+
+        case EPVSocketTimeout:
+        {
+            ReportSocketNodeError(PVMFErrTimeout, PVMFSocketNodeErrorSocketTimeOut);
+        }
+        break;
+
+        case EPVSocketCancel:
+            break;
+
+        case EPVSocketFailure:
+        {
+            //After a receive failure, we may need to do a TCP shutdown.
+            //Check what else is currently happening on the port.
+            switch (iSockConfig->iState.iSequence)
+            {
+                case EPVSocketPortSequence_RequestPort:
+                case EPVSocketPortSequence_InputDisconnectMsg:
+                case EPVSocketPortSequence_SocketCleanup:
+                    break;
+
+                case EPVSocketPortSequence_None:
+                case EPVSocketPortSequence_InputDataMsg:
+                    //for these cases, start a shutdown sequence
+                    //start the sequence
+                    iSockConfig->iState.iSequence = EPVSocketPortSequence_SocketCleanup;
+                    StartSequence(EPVSocketPortSequence_SocketCleanup);
+                    break;
+
+                default:
+                    //need code to handle this case.
+                    OSCL_ASSERT(0);
+                    break;
+            }
+        }
+        break;
+
+        default:
+            OSCL_ASSERT(0);
+            break;
+    }
+}
+
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::SetMaxTCPRecvBufferSize(uint32 aBufferSize)
+{
+    if ((aBufferSize > 0) && (aBufferSize < SNODE_DEFAULT_MAX_TCP_RECV_BUFFER_SIZE))
+    {
+        iMaxTcpRecvBufferSize = aBufferSize;
+        return PVMFSuccess;
+    }
+    return PVMFErrArgument;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::GetMaxTCPRecvBufferSize(uint32& aSize)
+{
+    aSize = iMaxTcpRecvBufferSize;
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::SetMaxTCPRecvBufferCount(uint32 aBufferSize)
+{
+    iMaxTcpRecvBufferCount = aBufferSize;
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFClientServerSocketNode::GetMaxTCPRecvBufferCount(uint32& aSize)
+{
+    aSize = iMaxTcpRecvBufferCount;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFClientServerSocketNode::StartSequence(TPVSocketPortSequence aSequence, OsclAny* aParam)
+{
+    PVMFStatus status = PVMFFailure;
+    //Set the sequence.
+    iSockConfig->iState.iSequence = aSequence;
+
+    switch (aSequence)
+    {
+        case EPVSocketPortSequence_InputDataMsg:
+        {
+            OSCL_ASSERT(aParam);
+            return StartSendOperation(*((PVMFSharedMediaMsgPtr*)aParam));
+        }
+
+        case EPVSocketPortSequence_InputDisconnectMsg:
+        {
+            status = CloseSocketConnection();
+        }
+        break;
+
+        case EPVSocketPortSequence_SocketCleanup:
+            if (iSockConfig->iTCPSocket)
+            {
+                //CancelRecvOperation();
+                //CancelSendOperation();
+                status = CloseSocketConnection();
+            }
+            break;
+
+        default:
+        {
+            OSCL_ASSERT(0);
+            return PVMFFailure;
+        }
+    }
+
+    if (status != PVMFPending)
+    {
+        //nothing needed.
+        SequenceComplete(PVMFSuccess);
+        return PVMFSuccess;
+    }
+    return status;
+}
+
+
+
+PVMFStatus PVMFClientServerSocketNode::CloseSocketConnection()
+{
+    PVMFStatus status;
+    iSockConfig->iState.iSequence = EPVSocketPortSequence_SocketCleanup;
+    if (!iSockConfig->iTCPSocket)
+    {
+        status = PVMFFailure;//unexpected
+        return status;
+    }
+    //Initiate a socket shutdown.
+    TPVSocketEvent ret = iSockConfig->iTCPSocket->Shutdown(EPVSocketBothShutdown, TIMEOUT_SHUTDOWN);
+    if (ret == EPVSocketPending)
+    {
+        status = PVMFPending;
+        //wait on the socket shutdown to complete in HandleSocketEvent callback
+    }
+    else
+    {
+        status = PVMFFailure;
+    }
+    return status;
+}
+
+
+void PVMFClientServerSocketNode::SequenceComplete(PVMFStatus aStatus)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFClientServerSocketNode::SequenceComplete() Sequence %d Status %d ", iSockConfig->iState.iSequence, aStatus));
+
+    TPVSocketPortSequence curSequence = iSockConfig->iState.iSequence;
+    iSockConfig->iState.iSequence = EPVSocketPortSequence_None;
+    iSockConfig->iState.iSequenceStatus = aStatus;
+
+    switch (curSequence)
+    {
+        case EPVSocketPortSequence_RequestPort:
+            //may need to complete the node command
+            if (iCurrentCmdQueue.size()
+                    && iCurrentCmdQueue.front().iCmd == PVMF_GENERIC_NODE_REQUESTPORT)
+            {
+                CommandComplete(iCurrentCmdQueue, iCurrentCmdQueue.front(), aStatus, iPVMFPort);
+            }
+            break;
+
+        case EPVSocketPortSequence_InputDisconnectMsg:
+        case EPVSocketPortSequence_InputDataMsg:
+            //If we've just completed an input port message, this may complete a node Flush command
+            if (!iCurrentCmdQueue.empty()
+                    && iCurrentCmdQueue.front().iCmd == PVMF_GENERIC_NODE_FLUSH)
+            {
+                //Flush is done when all input ports are empty.
+                if (iPVMFPort->IncomingMsgQueueSize() > 0)
+                    return;//keep waiting
+                CommandComplete(iCurrentCmdQueue, iCurrentCmdQueue.front(), PVMFSuccess);
+            }
+            break;
+
+
+        case EPVSocketPortSequence_SocketCleanup:
+        {
+            iPVMFPort->SuspendInput();
+            iPVMFPort->ClearMsgQueues();
+
+            CleanupPorts();
+            //This port is done-- decrement the counter
+            iNumStopPortActivityPending--;
+
+            //When counter reaches zero, all ports are done and the sequence is complete.
+            if (iNumStopPortActivityPending == 0)
+            {
+                //Reset the counter to the "idle" value.
+                iNumStopPortActivityPending = (-1);
+
+                //There may be a Reset or CancelAll command waiting on
+                //this to complete.
+                if (!iCurrentCmdQueue.empty()
+                        && iCurrentCmdQueue.front().iCmd == PVMF_GENERIC_NODE_RESET)
+                {
+                    CommandComplete(iCurrentCmdQueue, iCurrentCmdQueue.front(), PVMFSuccess);
+                }
+                else if (!iCancelCmdQueue.empty()
+                         && iCancelCmdQueue.front().iCmd == PVMF_GENERIC_NODE_CANCELALLCOMMANDS)
+                {
+                    CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
+                }
+                return;
+            }
+        }
+        break;
+
+        default:
+            break;
+    }
+
+    if (curSequence != EPVSocketPortSequence_InputDataMsg
+            && CanReceive())
+    {
+        StartRecvOperation();
+    }
+
+    if (CanProcessIncomingMsg())
+        ProcessIncomingMsg();
+}
diff --git a/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_port.cpp b/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_port.cpp
new file mode 100644
index 0000000..8669aed
--- /dev/null
+++ b/nodes/pvclientserversocketnode/src/pvmf_clientserver_socket_port.cpp
@@ -0,0 +1,263 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+* "pvmf_clientserver_socket_port.cpp"
+*/
+#ifndef PVMF_CLIENTSERVER_SOCKET_PORT_H_INCLUDED
+#include "pvmf_clientserver_socket_port.h"
+#endif
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+
+////////////////////////////////////////////////////////////////////////////
+PVMFClientServerSocketPort::PVMFClientServerSocketPort(int32 aTag,
+        PVMFPortActivityHandler* aNode)
+        : PvmfPortBaseImpl(aTag, aNode)
+{
+    Construct();
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFClientServerSocketPort::PVMFClientServerSocketPort(int32 aTag
+        , PVMFPortActivityHandler* aNode
+        , uint32 aInCapacity
+        , uint32 aInReserve
+        , uint32 aInThreshold
+        , uint32 aOutCapacity
+        , uint32 aOutReserve
+        , uint32 aOutThreshold)
+        : PvmfPortBaseImpl(aTag, aNode, aInCapacity, aInReserve,
+                           aInThreshold, aOutCapacity, aOutReserve, aOutThreshold)
+{
+    iPortTag = (PVMFSocketNodePortTag)aTag;
+    Construct();
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFClientServerSocketPort::Construct()
+{
+    iConfig = NULL;
+    iLogger = PVLogger::GetLoggerObject("PVMFClientServerSocketPort");
+    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
+    iNumFramesConsumed = 0;
+    PvmiCapabilityAndConfigPortFormatImpl::Construct(PVMF_CLIENTSERVER_SOCKET_PORT_SPECIFIC_ALLOCATOR
+            , PVMF_CLIENTSERVER_SOCKET_PORT_SPECIFIC_ALLOCATOR_VALTYPE);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFClientServerSocketPort::~PVMFClientServerSocketPort()
+{
+    Disconnect();
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFClientServerSocketPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    if (aFmt == PVMF_MIME_INET_TCP)
+        return true;
+    else
+        return false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFClientServerSocketPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFClientServerSocketPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFClientServerSocketPort::PeekIncomingMsg(PVMFSharedMediaMsgPtr& aMsg)
+{
+    if (iIncomingQueue.iQ.empty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFClientServerSocketPort::PeekIncomingMsg: Error - Incoming queue is empty", this));
+        return PVMFFailure;
+    }
+
+    // Save message to output parameter and erase it from queue
+    aMsg = iIncomingQueue.iQ.front();
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFClientServerSocketPort::QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFClientServerSocketPort::QueueOutgoingMsg"));
+
+    //If port is not connected, don't accept data on the
+    //outgoing queue.
+    if (!iConnectedPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFClientServerSocketPort::QueueOutgoingMsg: Error - Port not connected"));
+        return PVMFFailure;
+    }
+
+    PvmfPortBaseImpl* cpPort = OSCL_STATIC_CAST(PvmfPortBaseImpl*, iConnectedPort);
+
+    // Connected Port incoming Queue is in busy / flushing state.  Do not accept more outgoing messages
+    // until the queue is not busy, i.e. queue size drops below specified threshold or FlushComplete
+    // is called.
+    if (cpPort->iIncomingQueue.iBusy)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFClientServerSocketPort::QueueOutgoingMsg: Connected Port Incoming queue in busy / flushing state - Attempting to Q in output port's outgoing msg q"));
+        return (PvmfPortBaseImpl::QueueOutgoingMsg(aMsg));
+    }
+
+    // Add message to outgoing queue and notify the node of the activity
+    // There is no need to trap the push_back, since it cannot leave in this usage
+    // Reason being that we do a reserve in the constructor and we do not let the
+    // port queues grow indefinitely (we either a connected port busy or outgoing Q busy
+    // before we reach the reserved limit
+    PVMFStatus status = cpPort->Receive(aMsg);
+
+    if (status != PVMFSuccess)
+    {
+        return PVMFFailure;
+    }
+
+    // Outgoing queue size is at capacity and goes into busy state. The owner node is
+    // notified of this transition into busy state.
+    if (cpPort->isIncomingFull())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFClientServerSocketPort::QueueOutgoingMsg: Connected Port incoming queue is full. Goes into busy state"));
+        cpPort->iIncomingQueue.iBusy = true;
+        PvmfPortBaseImpl::PortActivity(PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY);
+    }
+
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFClientServerSocketPort::IsOutgoingQueueBusy()
+{
+    if (iConnectedPort != NULL)
+    {
+        PvmfPortBaseImpl* cpPort = OSCL_STATIC_CAST(PvmfPortBaseImpl*, iConnectedPort);
+        return (cpPort->iIncomingQueue.iBusy);
+    }
+    return (PvmfPortBaseImpl::IsOutgoingQueueBusy());;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFClientServerSocketPort::setParametersSync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements,
+        PvmiKvp * & aRet_kvp)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFClientServerSocketPort::setParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d, aRet_kvp=0x%x",
+                    aSession, aParameters, num_elements, aRet_kvp));
+    OSCL_UNUSED_ARG(aSession);
+    if (!aParameters || (num_elements != 1) ||
+            (pv_mime_strcmp(aParameters->key, PVMF_CLIENTSERVER_SOCKET_PORT_SPECIFIC_ALLOCATOR_VALTYPE) != 0))
+    {
+        aRet_kvp = aParameters;
+        OSCL_LEAVE(OsclErrArgument);
+    }
+    if (aParameters->value.key_specific_value == NULL)
+    {
+        aRet_kvp = aParameters;
+        OSCL_LEAVE(OsclErrArgument);
+    }
+    else
+    {
+        aRet_kvp = NULL;
+        iAllocSharedPtr =
+            *((OsclSharedPtr<PVMFSharedSocketDataBufferAlloc>*)(aParameters->value.key_specific_value));
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFClientServerSocketPort::getParametersSync(PvmiMIOSession aSession,
+        PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aSession);
+    if (pv_mime_strcmp(aIdentifier, PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_KEY) != 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFClientServerSocketPort::getParametersSync: Error - Unsupported PvmiKeyType"));
+        return PVMFErrNotSupported;
+    }
+
+    num_parameter_elements = 0;
+    if (!pvmiGetPortInPlaceDataProcessingInfoSync(PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_VALUE, aParameters))
+    {
+        return PVMFFailure;
+    }
+    num_parameter_elements = 1;
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFClientServerSocketPort::releaseParameters(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    if ((num_elements != 1) ||
+            (pv_mime_strcmp(aParameters->key, PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_VALUE) != 0))
+    {
+        return PVMFFailure;
+    }
+    OsclMemAllocator alloc;
+    alloc.deallocate((OsclAny*)(aParameters));
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFClientServerSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync(const char*
+        aFormatValType,
+        PvmiKvp*& aKvp)
+{
+    //Create PvmiKvp for capability settings
+    aKvp = NULL;
+    OsclMemAllocator alloc;
+    uint32 strLen = oscl_strlen(aFormatValType) + 1;
+    uint8* ptr = (uint8*)alloc.allocate(sizeof(PvmiKvp) + strLen);
+
+    if (!ptr)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFClientServerSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync: Error - No memory. Cannot allocate PvmiKvp"));
+        return false;
+    }
+
+    aKvp = new(ptr) PvmiKvp;
+    ptr += sizeof(PvmiKvp);
+    aKvp->key = (PvmiKeyType)ptr;
+    oscl_strncpy(aKvp->key, aFormatValType, strLen);
+    aKvp->length = aKvp->capacity = strLen;
+    aKvp->value.bool_value = true;
+    return true;
+}
diff --git a/nodes/pvcommsionode/Android.mk b/nodes/pvcommsionode/Android.mk
new file mode 100644
index 0000000..4d7b18c
--- /dev/null
+++ b/nodes/pvcommsionode/Android.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pv_comms_io_node_port.cpp \
+ 	src/pv_comms_io_node.cpp
+
+
+LOCAL_MODULE := libpvcommsionode
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/nodes/pvcommsionode/src \
+ 	$(PV_TOP)/nodes/pvcommsionode/src \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/nodes/pvcommsionode/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	src/pv_comms_io_node.h \
+ 	src/../include/pv_comms_io_node_factory.h \
+ 	src/../include/pv_comms_io_node_events.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/nodes/pvcommsionode/build/make/local.mk b/nodes/pvcommsionode/build/make/local.mk
new file mode 100644
index 0000000..295028e
--- /dev/null
+++ b/nodes/pvcommsionode/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvcommsionode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += ../../../../pvmi/pvmf/include ../../../../nodes/common/include ../../include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pv_comms_io_node_port.cpp \
+	pv_comms_io_node.cpp 
+
+HDRS := pv_comms_io_node.h \
+        ../include/pv_comms_io_node_factory.h \
+        ../include/pv_comms_io_node_events.h
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvcommsionode/include/pv_comms_io_node_events.h b/nodes/pvcommsionode/include/pv_comms_io_node_events.h
new file mode 100644
index 0000000..7450f47
--- /dev/null
+++ b/nodes/pvcommsionode/include/pv_comms_io_node_events.h
@@ -0,0 +1,94 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_media_input_node_events.h
+ * @brief
+ */
+
+#ifndef PV_COMMS_IO_NODE_EVENTS_H_INCLUDED
+#define PV_COMMS_IO_NODE_EVENTS_H_INCLUDED
+
+/**
+ UUID for file format error and information event type codes
+ **/
+#define PVCommsIONodeEventTypesUUID PVUuid(0x57598870,0xa620,0x11d9,0x96,0x69,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
+/**
+ Event codes for Media I/O Node events.
+ All the messages are of type PVMFBasicErrorInfoMessage
+**/
+typedef enum
+{
+    //This value is just a placeholder-- the event will not be reported.
+    PVCommsIONodeErr_First = 1024
+
+    //This error code indicates that no ports exist, but ports are
+    //required to complete the command.
+    , PVCommsIONodeErr_NoPorts
+
+    //This error code indicates that a port referenced in a command
+    //does not exist.
+    , PVCommsIONodeErr_PortNotExist
+
+    //This error code indicates that a Cancel command failed
+    //because the indicated command is no longer queueud.
+    , PVCommsIONodeErr_CmdNotQueued
+
+    //This error code indicates that the Media I/O component does not exist
+    , PVCommsIONodeErr_MediaIONotExist
+
+    //This error code indicates that the Media I/O component was in
+    //an unexpected state when the node tried to issue a command.
+    , PVCommsIONodeErr_MediaIOWrongState
+
+    //These error codes indicate that a specific command to the
+    //Media I/O control component failed.
+    , PVCommsIONodeErr_MediaIOConnect
+    , PVCommsIONodeErr_MediaIOQueryCapConfigInterface//query for capability & config interface
+    , PVCommsIONodeErr_MediaIOInit
+    , PVCommsIONodeErr_MediaIOStart
+    , PVCommsIONodeErr_MediaIOPause
+    , PVCommsIONodeErr_MediaIOStop
+    , PVCommsIONodeErr_MediaIOFlush
+    , PVCommsIONodeErr_MediaIOCancelCommand
+
+    //These error codes indicate errors in the data transfer
+    , PVCommsIONodeErr_WriteAsync //unexpeced leave in writeAsync
+    , PVCommsIONodeErr_WriteComplete //unexpected error reported in writeComplete
+
+    //This value is just a placeholder-- the event will not be reported.
+    , PVCommsIONodeErr_Last
+
+    //This value is just a placeholder-- the event will not be reported.
+    , PVCommsIONodeInfo_First
+
+    //Notifications of dropped or skipped frames.
+    , PVCommsIONodeInfo_FramesDropped
+    , PVCommsIONodeInfo_FramesSkipped
+
+    //This value is just a placeholder-- the event will not be reported.
+    , PVCommsIONodeInfo_Last
+
+} PVCommsIONodeErrorInfoEventTypes;
+
+#endif // PV_COMMS_IO_NODE_EVENTS_H_INCLUDED
+
+
+
+
+
diff --git a/nodes/pvcommsionode/include/pv_comms_io_node_factory.h b/nodes/pvcommsionode/include/pv_comms_io_node_factory.h
new file mode 100644
index 0000000..9f6c51e
--- /dev/null
+++ b/nodes/pvcommsionode/include/pv_comms_io_node_factory.h
@@ -0,0 +1,85 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_COMMS_IO_NODE_FACTORY_H_INCLUDED
+#define PV_COMMS_IO_NODE_FACTORY_H_INCLUDED
+
+// Forward declaration
+class PVMFNodeInterface;
+class PvmiMIOControl;
+class PVMFNodeCmdStatusObserver;
+class PVMFNodeInfoEventObserver;
+class PVMFNodeErrorEventObserver;
+
+#define PVCommsIONodeUuid PVUuid(0x860c7c50,0xb76a,0x4672,0x97,0x84,0xba,0x4d,0xce,0xc4,0x3a,0x3e)
+
+/**
+ * PVCommsIONodeFactory Class
+ *
+ * PVCommsIONodeFactory class is a singleton class which instantiates and provides
+ * access to PVCommsIONode node. It returns a PVMFNodeInterface reference, the
+ * interface class of the PVCommsIONode.
+ *
+ * The client is expected to contain and maintain a pointer to the instance created
+ * while the node is active.
+ */
+class PVCommsIONodeFactory
+{
+    public:
+        /**
+         * Creates an instance of a PVCommsIONode from one or more unidirectional
+         * media IO components. If the creation fails, this function will leave.
+         *
+         * @param aMIOInputControl Media input object to be controlled by this node
+         *        this parameter can be NULL of the aMIOOutputControl parameter is
+         *        non-NULL
+         * @param aMIOOutputControl Media output object to be controlled by this node
+         *        this parameter can be NULL of the aMIOInputControl parameter is
+         *        non-NULL
+         * @returns A pointer to an author or leaves if instantiation fails
+         */
+        OSCL_IMPORT_REF static PVMFNodeInterface* Create(PvmiMIOControl* aMIOInputControl, PvmiMIOControl *aMIOOutputControl, bool logBitstreams = false);
+
+        /**
+         * Creates an instance of a PVCommsIONode from a single bidirectional
+         * media IO component. If the creation fails, this function will leave.
+         *
+         * @param aMIOIControl Media input object to be controlled by this node
+         * @returns A pointer to an author or leaves if instantiation fails
+         */
+        OSCL_IMPORT_REF static PVMFNodeInterface* Create(PvmiMIOControl* aMIOControl, bool logBitstreams = false);
+
+        /**
+         * This function allows the application to delete an instance of a PVCommsIONode
+         * and reclaim all allocated resources.  An instance can be deleted only in
+         * the idle state. An attempt to delete in any other state will fail and return false.
+         *
+         * @param aNode The PVCommsIONode to be deleted.
+         */
+        OSCL_IMPORT_REF static void Delete(PVMFNodeInterface* aNode);
+
+        /**
+         * This function allows the application to retrieve the
+         * media I/O control instance contained within the node.
+         *
+         * @param aNode The PVCommsIONode
+         * @returns Pointer to the media I/O component.
+         */
+        OSCL_IMPORT_REF static PvmiMIOControl* GetMediaIOControl(PVMFNodeInterface* aNode);
+};
+
+#endif // PV_COMMS_IO_NODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvcommsionode/src/pv_comms_io_node.cpp b/nodes/pvcommsionode/src/pv_comms_io_node.cpp
new file mode 100644
index 0000000..825b3a8
--- /dev/null
+++ b/nodes/pvcommsionode/src/pv_comms_io_node.cpp
@@ -0,0 +1,1777 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pv_comms_io_node.cpp
+ * @brief
+ */
+
+#include "oscl_base.h"
+#include "pv_comms_io_node_factory.h"
+#include "pv_comms_io_node.h"
+#include "pv_comms_io_node_port.h"
+#include "oscl_dll.h"
+#include "pvmf_basic_errorinfomessage.h"
+#include "pv_comms_io_node_events.h"
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+/**
+//Macros for calling PVLogger
+*/
+#define LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFO(m) LOGINFOMED(m)
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVCommsIONodeFactory::Create(PvmiMIOControl* aMIOInputControl, PvmiMIOControl *aMIOOutputControl, bool logBitstream)
+{
+    return PVCommsIONode::Create(aMIOInputControl, aMIOOutputControl, logBitstream);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVCommsIONodeFactory::Create(PvmiMIOControl *aMIOControl, bool logBitstream)
+{
+    return PVCommsIONode::Create(aMIOControl, logBitstream);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodeFactory::Delete(PVMFNodeInterface* aNode)
+{
+    PVCommsIONode::Release(aNode);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFNodeInterface* PVCommsIONode::Create(PvmiMIOControl* aMIOInputControl, PvmiMIOControl *aMIOOutputControl, bool logBitstream)
+{
+    PVCommsIONode* node = OSCL_NEW(PVCommsIONode, (logBitstream));
+    if (node)
+    {
+        OSCL_TRAPSTACK_PUSH(node);
+        node->ConstructL(aMIOInputControl, aMIOOutputControl);
+        OSCL_TRAPSTACK_POP();
+    }
+    return (PVMFNodeInterface*)node;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFNodeInterface* PVCommsIONode::Create(PvmiMIOControl* aMIOControl, bool logBitstream)
+{
+    PVCommsIONode* node = OSCL_NEW(PVCommsIONode, (logBitstream));
+    if (node)
+    {
+        OSCL_TRAPSTACK_PUSH(node);
+        node->ConstructL(aMIOControl);
+        OSCL_TRAPSTACK_POP();
+    }
+    return (PVMFNodeInterface*)node;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::Release(PVMFNodeInterface* aNode)
+{
+    OSCL_DELETE(((PVCommsIONode*)aNode));
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONode::ThreadLogon()
+{
+    if (iInterfaceState != EPVMFNodeCreated)
+        return PVMFErrInvalidState;
+
+    iLogger = PVLogger::GetLoggerObject("PVCommsIONode");
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::ThreadLogon"));
+
+    if (!IsAdded())
+        AddToScheduler();
+
+    iMediaInputContext.ThreadLogon();
+    if (!(iMediaOutputContext == iMediaInputContext))
+        iMediaOutputContext.ThreadLogon();
+
+    SetState(EPVMFNodeIdle);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONode::ThreadLogoff()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::ThreadLogoff"));
+
+    if (iInterfaceState != EPVMFNodeIdle)
+        return PVMFErrInvalidState;
+
+    if (IsAdded())
+        RemoveFromScheduler();
+
+    iLogger = NULL;
+
+    iMediaInputContext.ThreadLogoff();
+    if (!(iMediaOutputContext == iMediaInputContext))
+        iMediaOutputContext.ThreadLogoff();
+
+    SetState(EPVMFNodeCreated);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    if (iInterfaceState == EPVMFNodeIdle ||
+            iInterfaceState == EPVMFNodeCreated)
+        return PVMFFailure;
+
+    if ((iMediaInputContext.isValid() && !iMediaInputContext.hasConfig()) ||
+            (iMediaOutputContext.isValid() && !iMediaOutputContext.hasConfig()))
+        return PVMFFailure;
+
+    aNodeCapability.iCanSupportMultipleInputPorts = false;
+    aNodeCapability.iCanSupportMultipleOutputPorts = false;
+    aNodeCapability.iHasMaxNumberOfPorts = true;
+    if (iMediaOutputContext.isValid() && iMediaInputContext.isValid())
+        aNodeCapability.iMaxNumberOfPorts = 2;
+    else
+        aNodeCapability.iMaxNumberOfPorts = 1;
+
+    PvmiKvp* kvp ;
+    int numParams ;
+    int32 err ;
+    int32 i ;
+    PVMFStatus status;
+
+    // Get input formats capability from media IO
+    kvp = NULL;
+    numParams = 0;
+
+    PvmiCapabilityAndConfig *inputConfig, *outputConfig;
+
+    inputConfig = iMediaInputContext.iMediaIOConfig;
+    outputConfig = iMediaOutputContext.iMediaIOConfig;
+
+    if (inputConfig)
+    {
+        status = inputConfig->getParametersSync(NULL,
+                                                OSCL_CONST_CAST(char*, INPUT_FORMATS_CAP_QUERY),
+                                                kvp, numParams, NULL);
+        if (status == PVMFSuccess)
+        {
+            OSCL_TRY(err,
+                     for (i = 0; i < numParams; i++)
+                     aNodeCapability.iInputFormatCapability.push_back(kvp[i].value.pChar_value););
+            if (kvp)
+                inputConfig->releaseParameters(0, kvp, numParams);
+        }
+        //else ignore errors.
+    }
+    // Get output formats capability from media IO
+    kvp = NULL;
+    numParams = 0;
+
+    if (outputConfig)
+    {
+        status = outputConfig->getParametersSync(NULL,
+                 OSCL_CONST_CAST(char*, OUTPUT_FORMATS_CAP_QUERY),
+                 kvp, numParams, NULL);
+        if (status == PVMFSuccess)
+        {
+            OSCL_TRY(err,
+                     for (i = 0; i < numParams; i++)
+                     aNodeCapability.iOutputFormatCapability.push_back(kvp[i].value.pChar_value);
+                    );
+            if (kvp)
+                outputConfig->releaseParameters(0, kvp, numParams);
+        }
+        //else ignore errors.
+    }
+
+    if (aNodeCapability.iInputFormatCapability.empty() && aNodeCapability.iOutputFormatCapability.empty())
+        return PVMFFailure;
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFPortIter* PVCommsIONode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
+    iPortVector.Reset();
+    return &iPortVector;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::QueryUUID() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::QueryInterface() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::RequestPort() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::ReleasePort() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Init() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Prepare() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Start() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Stop() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Flush() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Pause() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::Reset() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::CancelAllCommands() called"));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::CancelCommands() called cmdId=%d", aCmdId));
+    PVCommsIONodeCmd cmd;
+    cmd.PVCommsIONodeCmdBase::Construct(s, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONode::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONode::removeRef()
+{
+    if (iExtensionRefCount > 0)
+        --iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVCommsIONode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == PvmfNodesSyncControlUuid)
+    {
+        PvmfNodesSyncControlInterface* myInterface = OSCL_STATIC_CAST(PvmfNodesSyncControlInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+    }
+    else
+    {
+        iface = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONode::RequestCompleted(const PVMFCmdResp& aResponse)
+//callback from the MIO module.
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::RequestCompleted: Cmd ID=%d", aResponse.GetCmdId()));
+
+    //look for cancel completion.
+    if (iMediaIOCancelPending
+            && aResponse.GetCmdId() == iMediaIOCancelCmdId)
+    {
+        iMediaIOCancelPending = false;
+
+        Assert(!iCancelCommand.empty());
+
+        //Current cancel command is now complete.
+        CommandComplete(iCancelCommand, iCancelCommand.front(), PVMFSuccess);
+    }
+    //look for non-cancel completion
+    else if (iMediaIORequest != ENone
+             && aResponse.GetCmdId() == iMediaIOCmdId)
+    {
+        // Kind of tricky here.  For each node request, ie Init()
+        // up to 2 asynchronous MIO requests will be made.  We need
+        // to intercept the first MIO response here and make sure to
+        // send another one if necessary.  The actual node command
+        // completion message won't be sent until we get the 2nd
+        // MIO response.
+        Assert(!iCurrentCommand.empty());
+        PVCommsIONodeCmd& cmd = iCurrentCommand.front();
+
+        switch (iMediaIORequest)
+        {
+            case EQueryCapability:
+                if (aResponse.GetCmdStatus() != PVMFSuccess)
+                {
+                    cmd.iEventCode = PVCommsIONodeErr_MediaIOQueryCapConfigInterface;
+                }
+                else
+                {
+                    if ((cmd.iCmd == PVMF_GENERIC_NODE_INIT) && iTempCapConfigInterface)
+                    {
+                        cmd.iControlContext->iMediaIOConfig = OSCL_STATIC_CAST(PvmiCapabilityAndConfig *, iTempCapConfigInterface);
+                        iTempCapConfigInterface = NULL;
+
+                    }
+                    else
+                    {
+                        LOGERROR((0, "PVCommsIONode:RequestComplete Error:Not setting interface iCmd=%d,iTempCapConfigInterface=%x",
+                                  cmd.iCmd, iTempCapConfigInterface));
+
+
+                    }
+                    if (ReRunCommandForNextMIO(cmd))
+                    {
+                        return;
+                    }
+                    else	if (cmd.iControlContext == &iMediaInputContext &&
+                             iMediaInputContext.iControl == iMediaOutputContext.iControl)
+                    {
+                        // if we have a single object that supports both input and
+                        // output, the context's controls will be identical, and
+                        // we don't need to query the interface again, so we'll just
+                        // copy the session and config interface
+                        // to the output context, since they will be the same
+                        iMediaOutputContext = iMediaInputContext;
+                    }
+                }
+                break;
+
+            case EInit:
+                if (aResponse.GetCmdStatus() != PVMFSuccess)
+                {
+                    cmd.iEventCode = PVCommsIONodeErr_MediaIOInit;
+                }
+                else if (ReRunCommandForNextMIO(cmd))
+                {
+                    return;
+                }
+                else
+                {
+                    iMediaIOState = MIO_STATE_INITIALIZED;
+                }
+                break;
+
+            case EStart:
+                if (aResponse.GetCmdStatus() != PVMFSuccess)
+                {
+                    cmd.iEventCode = PVCommsIONodeErr_MediaIOStart;
+                }
+                else if (ReRunCommandForNextMIO(cmd))
+                {
+                    return;
+                }
+                else
+                {
+                    iMediaIOState = MIO_STATE_STARTED;
+                    //tell all the ports that I/O is started.
+                    {
+                        uint32 i;
+                        for (i = 0; i < iPortVector.size(); i++)
+                            iPortVector[i]->MediaIOStarted();
+                    }
+                }
+                break;
+
+            case EPause:
+                if (aResponse.GetCmdStatus() != PVMFSuccess)
+                {
+                    cmd.iEventCode = PVCommsIONodeErr_MediaIOPause;
+                }
+                else if (ReRunCommandForNextMIO(cmd))
+                {
+                    return;
+                }
+                else
+                {
+                    iMediaIOState = MIO_STATE_PAUSED;
+                }
+                break;
+
+            case EStop:
+                if (aResponse.GetCmdStatus() != PVMFSuccess)
+                {
+                    cmd.iEventCode = PVCommsIONodeErr_MediaIOStop;
+                }
+                else if (ReRunCommandForNextMIO(cmd))
+                {
+                    return;
+                }
+                else
+                {
+                    iMediaIOState = MIO_STATE_INITIALIZED;
+                }
+                break;
+
+            default:
+                Assert(false);
+                break;
+        }
+
+        //current node command is now complete.
+        if (IsFlushPending())
+        {
+            iMediaIORequest = ENone;
+            FlushComplete();
+        }
+        else
+        {
+            CommandComplete(iCurrentCommand, iCurrentCommand.front(), aResponse.GetCmdStatus());
+        }
+    }
+    else
+    {
+        //unexpected response.
+        LOGERROR((0, "PVCommsIONode:RequestComplete Warning! Unexpected command ID %d"
+                  , aResponse.GetCmdId()));
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONode::ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aEventType);
+    OSCL_UNUSED_ARG(aExtMsg);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONode::ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aEventType);
+    OSCL_UNUSED_ARG(aExtMsg);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVCommsIONode::PVCommsIONode(bool logBitstream)
+        : OsclActiveObject(OsclActiveObject::EPriorityNominal, "PVCommsIONode")
+        , iMediaIOState(PVCommsIONode::MIO_STATE_IDLE)
+        , iEventUuid(PVCommsIONodeEventTypesUUID)
+        , iExtensionRefCount(0)
+        , iLogger(NULL)
+        , iLogBitstream(logBitstream)
+        , iTempCapConfigInterface(NULL)
+{
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVCommsIONode::~PVCommsIONode()
+{
+    Cancel();
+    if (IsAdded())
+        RemoveFromScheduler();
+
+    //if any MIO commands are outstanding, there will be
+    //a crash when they callback-- so panic here instead.
+    OSCL_ASSERT(!(!iCancelCommand.empty()
+                  || iMediaIORequest != ENone));
+
+    //Cleanup allocated ports
+    while (!iPortVector.empty())
+        iPortVector.Erase(&iPortVector.front());
+
+    //Cleanup commands
+    //The command queues are self-deleting, but we want to
+    //notify the observer of unprocessed commands.
+    while (!iCurrentCommand.empty())
+    {
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
+        iCurrentCommand.Erase(&iCurrentCommand.front());
+    }
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+        iInputCommands.Erase(&iInputCommands.front());
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::ConstructL(PvmiMIOControl* aMIOInputControl, PvmiMIOControl *aMIOOutputControl)
+{
+    if (((aMIOInputControl == NULL) && (aMIOOutputControl == NULL)) ||
+            aMIOInputControl == aMIOOutputControl)
+        OsclError::Leave(OsclErrArgument);
+    iLogger = NULL;
+    iMediaInputContext.iControl = aMIOInputControl;
+    iMediaOutputContext.iControl = aMIOOutputControl;
+    iPortActivity = 0;
+    iInputCommands.Construct(1, 10);//reserve 10
+    iCurrentCommand.Construct(1, 1);//reserve 1.
+    iCancelCommand.Construct(1, 1);//reserve 1.
+    iPortVector.Construct(0);//reserve zero.
+    iMediaIORequest = ENone;
+    iMediaIOCancelPending = false;
+}
+
+void PVCommsIONode::ConstructL(PvmiMIOControl* aMIOControl)
+{
+    if (aMIOControl == NULL)
+        OsclError::Leave(OsclErrArgument);
+
+    iLogger = NULL;
+    iMediaInputContext.iControl = aMIOControl;
+    iMediaOutputContext.iControl = aMIOControl;
+
+    iPortActivity = 0;
+    iInputCommands.Construct(1, 10);//reserve 10
+    iCurrentCommand.Construct(1, 1);//reserve 1.
+    iCancelCommand.Construct(1, 1);//reserve 1.
+    iPortVector.Construct(0);//reserve zero.
+    iMediaIORequest = ENone;
+    iMediaIOCancelPending = false;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::Run()
+{
+    //Process async node commands.
+    if (!iInputCommands.empty())
+    {
+        ProcessCommand();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVCommsIONode::QueueCommandL(PVCommsIONodeCmd& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iInputCommands.AddL(aCmd);
+
+    //wakeup the AO
+    RunIfNotReady();
+
+    return id;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::ProcessCommand()
+{
+    //Can't do anything when an asynchronous cancel is in progress-- just
+    //need to wait on completion.
+    if (!iCancelCommand.empty())
+        return ; //keep waiting.
+
+    //If a command is in progress, only hi pri cancel commands can interrupt it.
+    if (!iCurrentCommand.empty()
+            && !iInputCommands.front().hipri())
+    {
+        return ; //keep waiting
+    }
+
+    //The newest or highest pri command is in the front of the queue.
+    Assert(!iInputCommands.empty());
+    PVCommsIONodeCmd& aCmd = iInputCommands.front();
+
+    PVMFStatus cmdstatus;
+    OsclAny* aEventData = NULL;
+    if (aCmd.hipri())
+    {
+        //save input command in cancel command
+        int32 err;
+        OSCL_TRY(err, iCancelCommand.StoreL(aCmd););
+        if (err != OsclErrNone)
+        {
+            cmdstatus = PVMFErrNoMemory;
+        }
+        else
+        {
+            //Process the interrupt commands.
+            switch (aCmd.iCmd)
+            {
+                case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+                    cmdstatus = DoCancelAllCommands(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_CANCELCOMMAND:
+                    cmdstatus = DoCancelCommand(aCmd);
+                    break;
+
+                default:
+                    Assert(false);
+                    cmdstatus = PVMFFailure;
+                    break;
+            }
+        }
+
+        //erase the input command.
+        if (cmdstatus != PVMFPending)
+        {
+            //Request already failed-- erase from Cancel Command.
+            //Node command remains in Input Commands.
+            iCancelCommand.Erase(&iCurrentCommand.front());
+        }
+        else
+        {
+            //Node command is now stored in Cancel Command, so erase from Input Commands.
+            iInputCommands.Erase(&aCmd);
+        }
+    }
+    else
+    {
+        //save input command in current command
+        int32 err;
+        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+        if (err != OsclErrNone)
+        {
+            cmdstatus = PVMFErrNoMemory;
+        }
+        else
+        {
+            //Process the normal pri commands.
+            switch (aCmd.iCmd)
+            {
+                case PVMF_GENERIC_NODE_QUERYUUID:
+                    cmdstatus = DoQueryUuid(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_QUERYINTERFACE:
+                    cmdstatus = DoQueryInterface(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_REQUESTPORT:
+                    cmdstatus = DoRequestPort(aCmd, aEventData);
+                    break;
+
+                case PVMF_GENERIC_NODE_RELEASEPORT:
+                    cmdstatus = DoReleasePort(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_INIT:
+                    cmdstatus = DoInit(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_PREPARE:
+                    cmdstatus = DoPrepare(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_START:
+                    cmdstatus = DoStart(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_STOP:
+                    cmdstatus = DoStop(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_FLUSH:
+                    cmdstatus = DoFlush(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_PAUSE:
+                    cmdstatus = DoPause(aCmd);
+                    break;
+
+                case PVMF_GENERIC_NODE_RESET:
+                    cmdstatus = DoReset(aCmd);
+                    break;
+
+                default://unknown command type
+                    Assert(false);
+                    cmdstatus = PVMFFailure;
+                    break;
+            }
+        }
+
+        //erase the input command.
+        if (cmdstatus != PVMFPending)
+        {
+            //Request already failed/succeeded-- erase from Current Command.
+            //Node command remains in Input Commands.
+            iCurrentCommand.Erase(&iCurrentCommand.front());
+        }
+        else
+        {
+            //Node command is now stored in Current Command, so erase from Input Commands.
+            //The DoXXX() routines will modify the command object, so we
+            //need to update the command object in the current command queue
+            iCurrentCommand[iCurrentCommand.size()-1] = aCmd;
+            iInputCommands.Erase(&aCmd);
+        }
+    }
+
+    if (cmdstatus != PVMFPending)
+        CommandComplete(iInputCommands, aCmd, cmdstatus, aEventData);
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::CommandComplete(PVCommsIONodeCmdQ& aCmdQ, PVCommsIONodeCmd& aCmd, PVMFStatus aStatus, OsclAny*aEventData)
+{
+    if (aStatus == PVMFSuccess)
+    {
+        LOGINFO((0, "PVCommsIONode:CommandComplete Id %d Cmd %d Status %d Context %d EVData %d EVCode %d"
+                 , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData, aCmd.iEventCode));
+    }
+    else
+    {
+        LOGERROR((0, "PVCommsIONode:CommandComplete Error! Id %d Cmd %d Status %d Context %d EVData %d EVCode %d"
+                  , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData, aCmd.iEventCode));
+    }
+
+    //do state transitions and any final command completion.
+    if (aStatus == PVMFSuccess)
+    {
+        switch (aCmd.iCmd)
+        {
+            case PVMF_GENERIC_NODE_INIT:
+                SetState(EPVMFNodeInitialized);
+                break;
+            case PVMF_GENERIC_NODE_PREPARE:
+                SetState(EPVMFNodePrepared);
+                break;
+            case PVMF_GENERIC_NODE_START:
+                SetState(EPVMFNodeStarted);
+                break;
+            case PVMF_GENERIC_NODE_PAUSE:
+                SetState(EPVMFNodePaused);
+                break;
+            case PVMF_GENERIC_NODE_STOP:
+                SetState(EPVMFNodePrepared);
+                //clear the message queues of any unprocessed data now.
+                {
+                    uint32 i;
+                    for (i = 0; i < iPortVector.size(); i++)
+                        iPortVector[i]->ClearMsgQueues();
+                }
+                break;
+            case PVMF_GENERIC_NODE_FLUSH:
+                SetState(EPVMFNodePrepared);
+                //Stop the ports
+                {
+                    for (uint32 i = 0; i < iPortVector.size(); i++)
+                        iPortVector[i]->Stop();
+                }
+                break;
+            default:
+                break;
+        }
+    }
+
+    //Reset the media I/O request
+    iMediaIORequest = ENone;
+
+
+    //The "startmio" command originated from port activity,
+    //not from the node controller, so no command complete event
+    //is needed.
+    if (aCmd.iCmd == PVMF_COMMSIONODE_STARTMIO)
+    {
+        //Erase the command from the queue.
+        aCmdQ.Erase(&aCmd);
+    }
+    else
+    {
+        //Extract parameters needed for command response.
+        PVMFCommandId cmdId = aCmd.iId;
+        const OsclAny* cmdContext = aCmd.iContext;
+        PVMFSessionId cmdSess = aCmd.iSession;
+        PVMFStatus eventCode = aCmd.iEventCode;
+
+        //Erase the command from the queue.
+        aCmdQ.Erase(&aCmd);
+
+        if (eventCode != PVCommsIONodeErr_First)
+        {
+            //create extended response.
+
+            PVMFBasicErrorInfoMessage*eventmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (eventCode, iEventUuid, NULL));
+
+            PVMFCmdResp resp(cmdId
+                             , cmdContext
+                             , aStatus
+                             , OSCL_STATIC_CAST(PVInterface*, eventmsg)
+                             , aEventData);
+
+            //report to the session observers.
+            PVMFNodeInterface::ReportCmdCompleteEvent(cmdSess, resp);
+
+            //remove the ref to the extended response
+            if (eventmsg)
+                eventmsg->removeRef();
+        }
+        else
+        {
+            //create basic response
+            PVMFCmdResp resp(cmdId, cmdContext, aStatus, aEventData);
+
+            //report to the session observers.
+            PVMFNodeInterface::ReportCmdCompleteEvent(cmdSess, resp);
+        }
+    }
+    //re-schedule if there are more commands and node isn't logged off
+    if (!iInputCommands.empty()
+            && IsAdded())
+        RunIfNotReady();
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoQueryUuid(PVCommsIONodeCmd& aCmd)
+{
+    //This node supports Query UUID from any state
+
+    OSCL_String* mimetype;
+    Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
+    bool exactmatch;
+    aCmd.PVCommsIONodeCmdBase::Parse(mimetype, uuidvec, exactmatch);
+
+    uuidvec->push_back(PvmfNodesSyncControlUuid);
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoQueryInterface(PVCommsIONodeCmd& aCmd)
+{
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVCommsIONodeCmdBase::Parse(uuid, ptr);
+    if (uuid && ptr)
+    {
+        if (queryInterface(*uuid, *ptr))
+            return PVMFSuccess;
+    }
+    return PVMFFailure;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoRequestPort(PVCommsIONodeCmd& aCmd, OsclAny*&aEventData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::DoRequestPort"));
+    //This node supports port request from any state
+
+    //retrieve port tag & mimetype
+    int32 tag;
+    OSCL_String* mimetype;
+    aCmd.PVCommsIONodeCmdBase::Parse(tag, mimetype);
+
+    switch (tag)
+    {
+
+        case PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG:
+        case PVMF_COMMSIO_NODE_INPUT_PORT_TAG:
+        case PVMF_COMMSIO_NODE_IO_PORT_TAG:
+        {
+            //Allocate a new port
+            OsclAny *ptr = NULL;
+            int32 err;
+            if (!ValidatePortTagRequest(tag))
+                return PVMFErrNotSupported;
+
+            OSCL_TRY(err, ptr = iPortVector.Allocate(););
+            if (err != OsclErrNone || !ptr)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVCommsIONode::DoRequestPort: Error - iPortVector Out of memory"));
+                return PVMFErrNoMemory;
+            }
+            PVCommsIONodePort *port = OSCL_PLACEMENT_NEW(ptr, PVCommsIONodePort(tag, this));
+
+            //set the format from the mimestring.
+            if (mimetype)
+            {
+                PVMFFormatType fmt = mimetype->get_str();
+                if (fmt != PVMF_MIME_FORMAT_UNKNOWN)
+                    port->Configure(fmt);
+            }
+
+            //Add the port to the port vector.
+            OSCL_TRY(err, iPortVector.AddL(port););
+            if (err != OsclErrNone)
+            {
+                iPortVector.DestructAndDealloc(port);
+                return PVMFErrNoMemory;
+            }
+            aEventData = (OsclAny*)port;
+
+            //cast the port to the generic interface before returning.
+            PVMFPortInterface*retval = port;
+            aEventData = (OsclAny*)retval;
+            return PVMFSuccess;
+        }
+        break;
+
+        default:
+        {
+            //bad port tag
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVCommsIONode::DoRequestPort: Error - Invalid port tag"));
+            return PVMFFailure;
+        }
+        break;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoReleasePort(PVCommsIONodeCmd& aCmd)
+{
+    //This node supports release port from any state
+
+    PVMFPortInterface* p;
+    aCmd.PVCommsIONodeCmdBase::Parse(p);
+    //search the output port vector
+    {
+        PVCommsIONodePort* port = (PVCommsIONodePort*)p;
+        PVCommsIONodePort** portPtr = iPortVector.FindByValue(port);
+        if (portPtr)
+        {
+            (*portPtr)->Disconnect();
+            iPortVector.Erase(portPtr);
+            return PVMFSuccess;
+        }
+    }
+    aCmd.iEventCode = PVCommsIONodeErr_PortNotExist;
+    return PVMFFailure;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoInit(PVCommsIONodeCmd& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    bool haveNewContext;
+
+    if (iInterfaceState != EPVMFNodeIdle)
+        return PVMFErrInvalidState;
+
+    if (!(haveNewContext = GetNextContextInSequence(aCmd)) && aCmd.iControlContext == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVCommsIONode::DoInit: Error - All media controls are NULL"));
+        aCmd.iEventCode = PVCommsIONodeErr_MediaIONotExist;
+        return PVMFFailure;
+    }
+    else if (aCmd.iControlContext->iControl->connect(aCmd.iControlContext->iMediaSession, this) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVCommsIONode::DoInit: Error - iMediaIOControl->connect failed"));
+        aCmd.iEventCode = PVCommsIONodeErr_MediaIOConnect;
+        return PVMFFailure;
+    }
+
+    //Query for MIO capability and config interface
+    return SendMioRequest(aCmd, EQueryCapability);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoPrepare(PVCommsIONodeCmd& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::DoPrepare"));
+
+    if (iInterfaceState != EPVMFNodeInitialized)
+        return PVMFErrInvalidState;
+
+    if (aCmd.iControlContext == NULL)
+        GetNextContextInSequence(aCmd);
+    return SendMioRequest(aCmd, EInit);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoStart(PVCommsIONodeCmd& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::DoStart"));
+
+    if (iInterfaceState != EPVMFNodePrepared
+            && iInterfaceState != EPVMFNodePaused)
+        return PVMFErrInvalidState;
+
+    //Start the MIO
+    if (aCmd.iControlContext == NULL)
+        GetNextContextInSequence(aCmd);
+
+    PVMFStatus status = SendMioRequest(aCmd, EStart);
+
+    if (status != PVMFPending)
+        return status;
+
+    // don't start ports until last MIO start has been sent
+    PVCommsIONodeCmd tempCmd = aCmd;
+    if (!GetNextContextInSequence(tempCmd))
+    {
+        uint32 i = 0;
+        for (i = 0; i < iPortVector.size(); i++)
+            iPortVector[i]->Start();
+    }
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoStop(PVCommsIONodeCmd& aCmd)
+{
+    if (iInterfaceState != EPVMFNodeStarted
+            && iInterfaceState != EPVMFNodePaused)
+        return PVMFErrInvalidState;
+
+    //Stop the MIO
+    if (aCmd.iControlContext == NULL)
+        GetNextContextInSequence(aCmd);
+
+    PVMFStatus status = SendMioRequest(aCmd, EStop);
+
+    //Stop the ports
+    for (uint32 i = 0; i < iPortVector.size(); i++)
+        iPortVector[i]->Stop();
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoFlush(PVCommsIONodeCmd& aCmd)
+{
+    if (iInterfaceState != EPVMFNodeStarted
+            && iInterfaceState != EPVMFNodePaused)
+        return PVMFErrInvalidState;
+
+    //Disable the input.
+    if (iPortVector.size() > 0)
+    {
+        //Stop the MIO input
+        if (aCmd.iControlContext == NULL)
+            GetNextContextInSequence(aCmd);
+
+        SendMioRequest(aCmd, EStop);
+        //ignore returned error.
+    }
+    //wait for all data to be consumed
+    return PVMFPending;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVCommsIONode::IsFlushPending()
+{
+    return (iCurrentCommand.size() > 0
+            && iCurrentCommand.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::FlushComplete()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFVideoEncNode::FlushComplete"));
+
+    if (iMediaIORequest != ENone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "PVMFVideoEncNode::FlushComplete: Media IO request is pending"));
+        return;
+    }
+
+    if (!PortQueuesEmpty())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "PVMFVideoEncNode::FlushComplete: Port queues are not empty"));
+        return;
+    }
+
+    //Flush is complete.
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                    (0, "PVMFVideoEncNode::FlushComplete: Done"));
+    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoPause(PVCommsIONodeCmd& aCmd)
+{
+    if (iInterfaceState != EPVMFNodeStarted)
+        return PVMFErrInvalidState;
+
+    if (aCmd.iControlContext == NULL)
+        GetNextContextInSequence(aCmd);
+
+    return SendMioRequest(aCmd, EPause);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoReset(PVCommsIONodeCmd& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+        case EPVMFNodeIdle:
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        {
+            //delete all ports and notify observer.
+            while (!iPortVector.empty())
+                iPortVector.Erase(&iPortVector.front());
+
+            //restore original port vector reserve.
+            iPortVector.Reconstruct();
+
+            //logoff & go back to Created state.
+            SetState(EPVMFNodeIdle);
+
+            return PVMFSuccess;
+        }
+        break;
+
+        default:
+            return PVMFErrInvalidState;
+            break;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoCancelAllCommands(PVCommsIONodeCmd& aCmd)
+{
+    //first cancel any MIO commmand in progress.
+    if (iMediaIORequest != ENone)
+    {
+        return CancelMioRequest(aCmd);
+    }
+
+    //first cancel the current command if any
+    {
+        while (!iCurrentCommand.empty())
+            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
+    }
+
+    //next cancel all queued commands
+    {
+        //start at element 1 since this cancel command is element 0.
+        while (iInputCommands.size() > 1)
+            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
+    }
+
+    //finally, report cancel complete.
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::DoCancelCommand(PVCommsIONodeCmd& aCmd)
+{
+    //tbd, need to cancel the MIO
+
+    //extract the command ID from the parameters.
+    PVMFCommandId id;
+    aCmd.PVCommsIONodeCmdBase::Parse(id);
+
+    //first check "current" command if any
+    {
+        PVCommsIONodeCmd* cmd = iCurrentCommand.FindById(id);
+        if (cmd)
+        {
+            //first cancel any MIO commmand in progress.
+            if (iMediaIORequest != ENone)
+            {
+                return CancelMioRequest(aCmd);
+            }
+            else
+            {
+                //cancel the queued command
+                CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
+                //report cancel success
+                return PVMFSuccess;
+            }
+        }
+    }
+
+    //next check input queue.
+    {
+        //start at element 1 since this cancel command is element 0.
+        PVCommsIONodeCmd* cmd = iInputCommands.FindById(id, 1);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
+            //report cancel success
+            return PVMFSuccess;
+        }
+    }
+    //if we get here the command isn't queued so the cancel fails.
+    aCmd.iEventCode = PVCommsIONodeErr_CmdNotQueued;
+    return PVMFFailure;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::SendMioRequest(PVCommsIONodeCmd& aCmd, EMioRequest aRequest)
+{
+    //Make an asynchronous request to MIO component
+    //and save the request in iMediaIORequest.
+
+
+    //there should not be a MIO command in progress..
+    Assert(iMediaIORequest == ENone);
+
+    //save media io request.
+    iMediaIORequest = aRequest;
+
+    PVMFStatus status;
+
+    //Issue the command to the MIO.
+    switch (aRequest)
+    {
+        case EQueryCapability:
+        {
+            int32 err ;
+
+            OSCL_TRY(err,
+                     iMediaIOCmdId = aCmd.iControlContext->iControl->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
+                                     iTempCapConfigInterface , NULL);
+                    );
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVCommsIONode::DoInit: Error - iMediaIOControl->QueryInterface failed"));
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOQueryCapConfigInterface;
+                status = PVMFFailure;
+            }
+            else
+            {
+                status = PVMFPending;
+            }
+        }
+        break;
+
+        case EInit:
+        {
+            if (iMediaIOState != MIO_STATE_IDLE)
+            {
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOWrongState;
+                status = PVMFFailure;
+                break;
+            }
+
+            int32 err ;
+            OSCL_TRY(err, iMediaIOCmdId = aCmd.iControlContext->iControl->Init(););
+
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVCommsIONode::DoInit: Error - iMediaIOControl->Init failed"));
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOInit;
+                status = PVMFFailure;
+            }
+            else
+            {
+                status = PVMFPending;
+            }
+        }
+        break;
+
+        case EStart:
+        {
+            if (iMediaIOState != MIO_STATE_INITIALIZED
+                    && iMediaIOState != MIO_STATE_PAUSED)
+            {
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOWrongState;
+                status = PVMFFailure;
+                break;
+            }
+
+            int32 err ;
+            OSCL_TRY(err, iMediaIOCmdId = aCmd.iControlContext->iControl->Start(););
+
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVCommsIONode::DoInit: Error - iMediaIOControl->Start failed"));
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOStart;
+                status = PVMFFailure;
+            }
+            else
+            {
+                status = PVMFPending;
+            }
+        }
+        break;
+
+        case EPause:
+        {
+            if (iMediaIOState != MIO_STATE_STARTED)
+            {
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOWrongState;
+                status = PVMFFailure;
+                break;
+            }
+
+            int32 err ;
+            OSCL_TRY(err, iMediaIOCmdId = aCmd.iControlContext->iControl->Pause(););
+
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVCommsIONode::DoInit: Error - iMediaIOControl->Pause failed"));
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOPause;
+                status = PVMFFailure;
+            }
+            else
+            {
+                status = PVMFPending;
+            }
+        }
+        break;
+
+        case EStop:
+        {
+            if (iMediaIOState != MIO_STATE_STARTED
+                    && iMediaIOState != MIO_STATE_PAUSED)
+            {
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOWrongState;
+                status = PVMFFailure;
+                break;
+            }
+
+            int32 err ;
+            OSCL_TRY(err, iMediaIOCmdId = aCmd.iControlContext->iControl->Stop(););
+
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVCommsIONode::DoInit: Error - iMediaIOControl->Stop failed"));
+                aCmd.iEventCode = PVCommsIONodeErr_MediaIOStop;
+                status = PVMFFailure;
+            }
+            else
+            {
+                status = PVMFPending;
+            }
+        }
+        break;
+
+        default:
+            Assert(false);//unrecognized command.
+            status = PVMFFailure;
+            break;
+    }
+
+    if (status == PVMFPending)
+    {
+        LOGINFOHI((0, "PVCommsIONode:SendMIORequest: Command Issued to MIO component, waiting on response..."));
+    }
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVCommsIONode::CancelMioRequest(PVCommsIONodeCmd& aCmd)
+{
+    Assert(iMediaIORequest != ENone);
+
+    Assert(!iMediaIOCancelPending);
+
+    //Issue the cancel to the MIO.
+    iMediaIOCancelPending = true;
+    int32 err;
+    OSCL_TRY(err, iMediaIOCancelCmdId = aCmd.iControlContext->iControl->CancelCommand(iMediaIOCmdId););
+    if (err != OsclErrNone)
+    {
+        aCmd.iEventCode = PVCommsIONodeErr_MediaIOCancelCommand;
+        iMediaIOCancelPending = false;
+        return PVMFFailure;
+    }
+    LOGINFOHI((0, "PVCommsIONode:SendMIORequest: Cancel Command Issued to MIO component, waiting on response..."));
+    return PVMFPending;//wait on request to cancel.
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::MioConfigured(int32 aPortTag)
+//called by the port when the MIO was just configured.
+//only called for ports that need to wait on config before starting
+//the MIO.
+//RH Note: probably not need for Comms right now, and the port
+//does not call this method.
+{
+    OSCL_UNUSED_ARG(aPortTag);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIONode::MioConfigured() called"));
+    if (iInterfaceState == EPVMFNodeStarted)
+    {
+        PVCommsIONodeCmd cmd;
+//		cmd.iControlContext = ContextFromTag(aPortTag);
+        cmd.PVCommsIONodeCmdBase::Construct(0, PVMF_COMMSIONODE_STARTMIO, NULL);
+        QueueCommandL(cmd);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                  Event reporting routines.
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::SetState(TPVMFNodeInterfaceState s)
+{
+    LOGINFO((0, "PVCommsIONode:SetState %d", s));
+    PVMFNodeInterface::SetState(s);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData, PVMFStatus aEventCode)
+{
+    LOGERROR((0, "PVCommsIONode:NodeErrorEvent Type %d EVData %d EVCode %d"
+              , aEventType, aEventData, aEventCode));
+
+    //create the extension message if any.
+    if (aEventCode != PVCommsIONodeErr_First)
+    {
+        PVMFBasicErrorInfoMessage* eventmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, iEventUuid, NULL));
+        PVMFAsyncEvent asyncevent(PVMFErrorEvent, aEventType, NULL, OSCL_STATIC_CAST(PVInterface*, eventmsg), aEventData, NULL, 0);
+        PVMFNodeInterface::ReportErrorEvent(asyncevent);
+        eventmsg->removeRef();
+    }
+    else
+        PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData, PVMFStatus aEventCode)
+{
+    LOGINFO((0, "PVCommsIONode:NodeInfoEvent Type %d EVData %d EVCode %d"
+             , aEventType, aEventData, aEventCode));
+
+    //create the extension message if any.
+    if (aEventCode != PVCommsIONodeErr_First)
+    {
+        PVMFBasicErrorInfoMessage* eventmsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, iEventUuid, NULL));
+        PVMFAsyncEvent asyncevent(PVMFErrorEvent, aEventType, NULL, OSCL_STATIC_CAST(PVInterface*, eventmsg), aEventData, NULL, 0);
+        PVMFNodeInterface::ReportInfoEvent(asyncevent);
+        eventmsg->removeRef();
+    }
+    else
+        PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVCommsIONode::PortQueuesEmpty()
+{
+    uint32 i;
+    for (i = 0;i < iPortVector.size();i++)
+    {
+        if (iPortVector[i]->IncomingMsgQueueSize() > 0
+                || iPortVector[i]->OutgoingMsgQueueSize() > 0)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONode::Assert(bool condition)
+{
+    if (!condition)
+    {
+        LOGERROR((0, "PVCommsIONode::Assert Failed!"));
+        OSCL_ASSERT(0);
+    }
+}
+
+MIOControlContextSet PVCommsIONode::ContextSetFromTag(int32 aTag)
+{
+    MIOControlContextSet contextSet;
+
+    switch (aTag)
+    {
+        case PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG:
+            if (iMediaInputContext.isValid())
+                contextSet.iMediaInputElement = &iMediaInputContext;
+            break;
+        case PVMF_COMMSIO_NODE_INPUT_PORT_TAG:
+            if (iMediaOutputContext.isValid())
+                contextSet.iMediaOutputElement = &iMediaOutputContext;
+            break;
+        case PVMF_COMMSIO_NODE_IO_PORT_TAG:
+            if (iMediaOutputContext.isValid() && iMediaInputContext.isValid())
+            {
+                contextSet.iMediaInputElement = &iMediaInputContext;
+                contextSet.iMediaOutputElement = &iMediaOutputContext;
+            }
+            break;
+        default:
+            break;
+    }
+    return contextSet;
+}
+/*
+PvmiCapabilityAndConfig *PVCommsIONode::GetConfig(int32 aPortTag)
+{
+	MIOControlContextElement *context = ContextSetFromTag(aPortTag);
+	if (context)
+		return context->iMediaIOConfig;
+	return NULL;
+}
+*/
+bool PVCommsIONode::CreateMediaTransfer(int32 aPortTag, PvmiMediaTransfer *&aInputTransfer, PvmiMediaTransfer *&aOutputTransfer)
+{
+    MIOControlContextSet set = ContextSetFromTag(aPortTag);
+
+    if (set.isEmpty())
+        return false;
+
+    if (set.iMediaInputElement)
+    {
+        aInputTransfer = set.iMediaInputElement->iControl->createMediaTransfer(set.iMediaInputElement->iMediaSession);
+        if (!aInputTransfer)
+            return false;
+    }
+    if (set.iMediaOutputElement)
+    {
+        aOutputTransfer = set.iMediaOutputElement->iControl->createMediaTransfer(set.iMediaOutputElement->iMediaSession);
+        if (!aOutputTransfer)
+            return false;
+    }
+
+    return true;
+}
+
+void PVCommsIONode::DeleteMediaTransfer(int32 aPortTag, PvmiMediaTransfer *aInputTransfer, PvmiMediaTransfer *aOutputTransfer)
+{
+    MIOControlContextSet set = ContextSetFromTag(aPortTag);
+
+    if (set.isEmpty())
+        return;
+
+    if (set.iMediaInputElement && aInputTransfer)
+    {
+        set.iMediaInputElement->iControl->deleteMediaTransfer(set.iMediaInputElement->iMediaSession, aInputTransfer);
+    }
+    else if (set.iMediaOutputElement && aOutputTransfer)
+    {
+        set.iMediaOutputElement->iControl->deleteMediaTransfer(set.iMediaOutputElement->iMediaSession, aOutputTransfer);
+    }
+}
+
+bool PVCommsIONode::GetNextContextInSequence(PVCommsIONodeCmd &aCmd)
+{
+    // We need to determine which IO controls to start
+    // the init with
+    if (aCmd.iControlContext == NULL)
+    {
+        if (iMediaInputContext.isValid())
+            aCmd.iControlContext = &iMediaInputContext;
+        else if (iMediaOutputContext.isValid())
+            aCmd.iControlContext = &iMediaOutputContext;
+        else
+            return false;
+    }
+    else if ((aCmd.iControlContext == &iMediaInputContext) &&
+             iMediaOutputContext.isValid() &&
+             (iMediaOutputContext.iControl != iMediaInputContext.iControl))
+    {
+        aCmd.iControlContext = &iMediaOutputContext;
+    }
+    else
+        return false;
+
+    return true;
+}
+
+bool PVCommsIONode::ReRunCommandForNextMIO(PVCommsIONodeCmd &aCmd)
+{
+    // This method should only be called from the
+    // RequestCompleted method, and allows us to re-use
+    // command objects to asynchronously initialize more than
+    // one MIO component under the context of a single node
+    // command id.
+
+    // The force parameter will force the command to be re run for
+    // an output context even if its MIO component is a reference to
+    // the input context component.  This is useful for the query interface
+    // portion of initialization.
+
+    PVCommsIONodeCmd newCmd = aCmd;
+
+    if (GetNextContextInSequence(newCmd))
+    {
+        iCurrentCommand.Erase(&aCmd);
+        // Don't use AddL because that overwrites the iId
+        // which must remain the same.
+        iInputCommands.StoreL(newCmd);
+        RunIfNotReady();
+        iMediaIORequest = ENone;
+        return true;
+    }
+    return false;
+}
+
+bool PVCommsIONode::MIOSupportsPortTag(int32 aTag, MIOControlContextSet &aSet)
+{
+    PvmiKvp* kvp ;
+    int numParams ;
+
+    // Get input formats capability from media IO
+    kvp = NULL;
+    numParams = 0;
+
+    if (aTag & PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG)
+    {
+        if (!aSet.iMediaInputElement->hasConfig() ||
+                aSet.iMediaInputElement->iMediaIOConfig->getParametersSync(NULL,
+                        OSCL_CONST_CAST(char*, OUTPUT_FORMATS_CAP_QUERY),
+                        kvp, numParams, NULL) != PVMFSuccess)
+            return false;
+        aSet.iMediaInputElement->iMediaIOConfig->releaseParameters(0, kvp, numParams);
+        if (numParams == 0)
+            return false;
+    }
+    if (aTag & PVMF_COMMSIO_NODE_INPUT_PORT_TAG)
+    {
+        if (!aSet.iMediaOutputElement->hasConfig() ||
+                aSet.iMediaOutputElement->iMediaIOConfig->getParametersSync(NULL,
+                        OSCL_CONST_CAST(char*, INPUT_FORMATS_CAP_QUERY),
+                        kvp, numParams, NULL) != PVMFSuccess)
+            return false;
+        aSet.iMediaOutputElement->iMediaIOConfig->releaseParameters(0, kvp, numParams);
+        if (numParams == 0)
+            return false;
+    }
+
+    return true;
+}
+
+// Check some stuff to determine if we can hand out
+// a port of this type...
+
+bool PVCommsIONode::ValidatePortTagRequest(int32 aTag)
+{
+    uint32 curPorts = iPortVector.size();
+
+    switch (aTag)
+    {
+        case PVMF_COMMSIO_NODE_IO_PORT_TAG:
+            if (curPorts > 0)
+                return false; // can have only one I/O port
+            break;
+
+        case PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG:
+            if (curPorts > 1 ||
+                    (curPorts == 1 && iPortVector[0]->GetPortTag() != PVMF_COMMSIO_NODE_INPUT_PORT_TAG))
+                return false;
+            break;
+        case PVMF_COMMSIO_NODE_INPUT_PORT_TAG:
+            if (curPorts > 1 ||
+                    (curPorts == 1 && iPortVector[0]->GetPortTag() != PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG))
+                return false;
+            break;
+        default:
+            return false;
+    }
+
+    MIOControlContextSet set = ContextSetFromTag(aTag);
+
+    if (set.isEmpty() || !MIOSupportsPortTag(aTag, set))
+        return false;
+
+    return true;
+}
diff --git a/nodes/pvcommsionode/src/pv_comms_io_node.h b/nodes/pvcommsionode/src/pv_comms_io_node.h
new file mode 100644
index 0000000..eaa9a6a
--- /dev/null
+++ b/nodes/pvcommsionode/src/pv_comms_io_node.h
@@ -0,0 +1,388 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pv_comms_io_node.h
+ * @brief
+ */
+
+#ifndef PV_COMMS_IO_NODE_H_INCLUDED
+#define PV_COMMS_IO_NODE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMF_RETURN_CODES_H_INCLUDED
+#include "pvmf_return_codes.h"
+#endif
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_port_interface.h"
+#endif
+#ifndef PVMI_MIO_CONTROL_H_INCLUDED
+#include "pvmi_mio_control.h"
+#endif
+#ifndef PVMI_MEDIA_IO_OBSERVER_H_INCLUDED
+#include "pvmi_media_io_observer.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
+#ifndef PVMF_NODES_SYNC_CONTROL_H_INCLUDED
+#include "pvmf_nodes_sync_control.h"
+#endif
+#ifndef PV_COMMS_IO_NODE_PORT_H_INCLUDED
+#include "pv_comms_io_node_port.h"
+#endif
+#ifndef PV_COMMS_IO_NODE_EVENTS_H_INCLUDED
+#include "pv_comms_io_node_events.h"
+#endif
+
+/** Port tags.  For now engine must use these directly since
+* port tag query is not yet implemented
+*/
+enum PVCommsIONodePortTags
+{
+    PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG = 0x01,
+    PVMF_COMMSIO_NODE_INPUT_PORT_TAG = 0x02,
+    PVMF_COMMSIO_NODE_IO_PORT_TAG = 0x03, //bitwise OR of previous two tags
+};
+
+const PVMFStatus PVMFInfoEndOfInputPortData = PVMFInfoLast + 1;
+const PVMFStatus PVMFInfoEndOfOutputPortData = PVMFInfoLast + 2;
+
+class MIOControlContextElement
+{
+
+    public:
+        MIOControlContextElement()
+        {
+            iControl = NULL;
+            iMediaSession = 0;
+            iMediaIOConfig = NULL;
+        };
+        bool operator== (const MIOControlContextElement &context)
+        {
+            return (iControl == context.iControl);
+        }
+        MIOControlContextElement &operator= (const MIOControlContextElement &context)
+        {
+            Copy(context);
+            return (*this);
+        }
+        bool isValid()
+        {
+            return iControl ? true : false;
+        };
+        bool hasConfig()
+        {
+            return iMediaIOConfig ? true : false;
+        };
+        void ThreadLogon()
+        {
+            if (iControl)
+                iControl->ThreadLogon();
+        };
+        void ThreadLogoff()
+        {
+            if (iControl)
+            {
+                iControl->ThreadLogoff();
+                iControl->disconnect(iMediaSession);
+            }
+        };
+
+        PvmiMIOControl *iControl;
+        PvmiMIOSession iMediaSession;
+        PvmiCapabilityAndConfig *iMediaIOConfig;
+    private:
+        void Copy(const MIOControlContextElement &aSettings)
+        {
+            iControl = aSettings.iControl;
+            iMediaSession = aSettings.iMediaSession;
+            iMediaIOConfig = aSettings.iMediaIOConfig;
+        }
+};
+
+class MIOControlContextSet
+{
+    public:
+        MIOControlContextSet(): iMediaInputElement(NULL), iMediaOutputElement(NULL) {};
+        bool isUni()
+        {
+            return (iMediaInputElement == NULL || iMediaOutputElement == NULL);
+        };
+        bool isIOProxy()
+        {
+            return (!isUni() && iMediaInputElement == iMediaOutputElement);
+        };
+        bool isEmpty()
+        {
+            return (iMediaInputElement == NULL && iMediaOutputElement == NULL);
+        };
+        MIOControlContextElement *iMediaInputElement;
+        MIOControlContextElement *iMediaOutputElement;
+};
+
+/**
+ * Command queue for internal use in the node
+ */
+
+//command type enums.  This node has one extra async command.
+enum PVCommsIONodeCmdType
+{
+    PVMF_COMMSIONODE_SKIPMEDIADATA = PVMF_GENERIC_NODE_COMMAND_LAST
+    , PVMF_COMMSIONODE_STARTMIO
+    //startmio command is generated internally by the input ports.
+};
+
+//command class
+class PVCommsIONodeCmd: public PVMFGenericNodeCommand<OsclMemAllocator>
+{
+    public:
+
+        //this holds an event code associated with the command status
+        PVMFStatus iEventCode;
+        MIOControlContextElement *iControlContext;
+
+        //need to override base construct routine due to additional parameter.
+        void BaseConstruct(PVMFSessionId s, int32 aCmd, const OsclAny* aContext)
+        {
+            PVMFGenericNodeCommand<OsclMemAllocator>::BaseConstruct(s, aCmd, aContext);
+            iEventCode = PVCommsIONodeErr_First;
+            iControlContext = NULL;
+        }
+        //need to override base copy routine due to additional parameter
+        void Copy(PVCommsIONodeCmd& aCmd)
+        {
+            PVMFGenericNodeCommand<OsclMemAllocator>::Copy(aCmd);
+            iEventCode = aCmd.iEventCode;
+            iControlContext = aCmd.iControlContext;
+        }
+
+
+};
+//define a synonym for the base class.
+//a typedef creates compiler warnings so use #define
+#define PVCommsIONodeCmdBase PVMFGenericNodeCommand<OsclMemAllocator>
+
+//command queue type
+typedef PVMFNodeCommandQueue<PVCommsIONodeCmd, OsclMemAllocator> PVCommsIONodeCmdQ;
+
+
+/**
+ * class PVCommsIONode is a node wrapper around the io interface
+ */
+class PVCommsIONode : public OsclActiveObject,
+            public PVMFNodeInterface,
+            public PvmiMIOObserver
+{
+    public:
+        static PVMFNodeInterface* Create(PvmiMIOControl* aMIOControl, bool logBitstream = false);
+        static PVMFNodeInterface* Create(PvmiMIOControl* aMIOInputControl,
+                                         PvmiMIOControl* aMIOOutputControl, bool logBitstream = false);
+        static void Release(PVMFNodeInterface*);
+
+        // PVMFNodeInterface implementation
+        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId aSession
+                                                , const PvmfMimeString& aMimeType
+                                                , Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids
+                                                , bool aExactUuidsOnly = false
+                                                                         , const OsclAny* aContext = NULL) ;
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSession
+                , const PVUuid& aUuid
+                , PVInterface*& aInterfacePtr
+                , const OsclAny* aContext = NULL) ;
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession
+                , int32 aPortTag
+                , const PvmfMimeString* aPortConfig = NULL
+                                                      , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId aSession
+                , PVMFPortInterface& aPort
+                , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId aSession
+                                           , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId aSession
+                                              , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId aSession
+                                           , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId aSession
+                , const OsclAny* aContextData = NULL) ;
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId aSession
+                , PVMFCommandId aCmdId
+                , const OsclAny* aContextData = NULL) ;
+        void HandlePortActivity(const PVMFPortActivity& aActivity)
+        {
+            OSCL_UNUSED_ARG(aActivity);
+        }
+
+        // Pure virtual from PvInterface
+        OSCL_IMPORT_REF void addRef();
+        OSCL_IMPORT_REF void removeRef();
+        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+        // PvmiMIOObserver implementation
+        OSCL_IMPORT_REF void RequestCompleted(const PVMFCmdResp& aResponse);
+        OSCL_IMPORT_REF void ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL);
+        OSCL_IMPORT_REF void ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL);
+
+        friend class PVCommsIONodePort;
+
+    private:
+        typedef enum
+        {
+            ENone
+            , EQueryCapability
+            , EInit
+            , EStart
+            , EPause
+            , EStop
+        } EMioRequest;
+
+        PVCommsIONode(bool iLogBitstream);
+        ~PVCommsIONode();
+        void ConstructL(PvmiMIOControl* aIOInterfacePtr);
+        void ConstructL(PvmiMIOControl* aMediaInputPtr, PvmiMIOControl* aMediaOutputPtr);
+
+        //from OsclActiveObject
+        void Run();
+
+        //Command processing
+        PVMFCommandId QueueCommandL(PVCommsIONodeCmd&);
+        void ProcessCommand();
+        void CommandComplete(PVCommsIONodeCmdQ& aCmdQ, PVCommsIONodeCmd& aCmd, PVMFStatus aStatus, OsclAny*aEventData = NULL);
+
+        //generic node Command handlers.
+        PVMFStatus DoQueryUuid(PVCommsIONodeCmd&);
+        PVMFStatus DoQueryInterface(PVCommsIONodeCmd&);
+        PVMFStatus DoRequestPort(PVCommsIONodeCmd&, OsclAny*&);
+        PVMFStatus DoReleasePort(PVCommsIONodeCmd&);
+        PVMFStatus DoInit(PVCommsIONodeCmd&);
+        PVMFStatus DoPrepare(PVCommsIONodeCmd&);
+        PVMFStatus DoStart(PVCommsIONodeCmd&);
+        PVMFStatus DoStop(PVCommsIONodeCmd&);
+        PVMFStatus DoFlush(PVCommsIONodeCmd&);
+        bool IsFlushPending();
+        void FlushComplete();
+        PVMFStatus DoPause(PVCommsIONodeCmd&);
+        PVMFStatus DoReset(PVCommsIONodeCmd&);
+        PVMFStatus DoCancelAllCommands(PVCommsIONodeCmd&);
+        PVMFStatus DoCancelCommand(PVCommsIONodeCmd&);
+
+        bool ReRunCommandForNextMIO(PVCommsIONodeCmd&);
+        // Returns contexts according to the initialization
+        // sequence
+        bool GetNextContextInSequence(PVCommsIONodeCmd&);
+        // Returns context associated with given port tag
+        MIOControlContextSet ContextSetFromTag(int32 aTag);
+        //PvmiCapabilityAndConfig *GetConfig(int32 aPortTag);
+        bool CreateMediaTransfer(int32 aPortTag, PvmiMediaTransfer *&aInputTransfer, PvmiMediaTransfer *&aOutputTransfer);
+        void DeleteMediaTransfer(int32 aPortTag, PvmiMediaTransfer *aInputTransfer, PvmiMediaTransfer *aOutputTransfer);
+        bool MIOSupportsPortTag(int32 aTag, MIOControlContextSet &aSet);
+        bool ValidatePortTagRequest(int32 aTag);
+
+
+        // Media IO commands
+        PVMFStatus SendMioRequest(PVCommsIONodeCmd& aCmd, EMioRequest);
+        PVMFStatus CancelMioRequest(PVCommsIONodeCmd& aCmd);
+        void MioConfigured(int32 aPortTag);
+
+        // Event reporting
+        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, PVMFStatus aEventCode = PVCommsIONodeErr_First);
+        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, PVMFStatus aEventCode = PVCommsIONodeErr_First);
+        void SetState(TPVMFNodeInterfaceState);
+
+        bool PortQueuesEmpty();
+        void Assert(bool condition);
+
+        // Node capability.
+        PVMFNodeCapability iCapability;
+
+        // COmmand queues
+        PVCommsIONodeCmdQ iInputCommands;
+        PVCommsIONodeCmdQ iCurrentCommand;
+        PVCommsIONodeCmdQ iCancelCommand;
+
+        // Media IO control
+        MIOControlContextElement iMediaInputContext;
+        MIOControlContextElement iMediaOutputContext;
+
+        enum
+        {
+            MIO_STATE_IDLE
+            , MIO_STATE_INITIALIZED
+            , MIO_STATE_STARTED
+            , MIO_STATE_PAUSED
+        } iMediaIOState;
+
+        EMioRequest iMediaIORequest;
+        PVMFCommandId iMediaIOCmdId;
+        PVMFCommandId iMediaIOCancelCmdId;
+        bool iMediaIOCancelPending;
+
+        // Ports
+        PVMFPortVector<PVCommsIONodePort, OsclMemAllocator> iPortVector;
+        int32 iPortActivity;
+
+        // Events
+        PVUuid iEventUuid;
+
+        // Extension reference counter
+        uint32 iExtensionRefCount;
+
+        // Counter for number of callbacks for skip media data completion
+        uint32 iSkipMediaDataResponse;
+
+        //logger
+        PVLogger* iLogger;
+        bool iLogBitstream;
+        // for removing type-punned warning
+        PVInterface * iTempCapConfigInterface;
+};
+
+#endif // PV_COMMS_IO_NODE_H_INCLUDED
+
+
+
+
+
diff --git a/nodes/pvcommsionode/src/pv_comms_io_node_port.cpp b/nodes/pvcommsionode/src/pv_comms_io_node_port.cpp
new file mode 100644
index 0000000..d4e57b6
--- /dev/null
+++ b/nodes/pvcommsionode/src/pv_comms_io_node_port.cpp
@@ -0,0 +1,1149 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+* @file pv_comms_io_node_port.cpp
+* @brief Port for Comms I/O interfacing; can be unidirectional or bidirectional
+*/
+
+#ifndef PV_COMMS_IO_NODE_OUTPORT_H_INCLUDED
+#include "pv_comms_io_node_port.h"
+#endif
+#ifndef PV_COMMS_IO_NODE_H_INCLUDED
+#include "pv_comms_io_node.h"
+#endif
+#ifndef PVMF_MEDIA_MSG_FORMAT_IDS_H_INCLUDED
+#include "pvmf_media_msg_format_ids.h"
+#endif
+
+#ifndef OSCL_BASE_MACROS_H_INCLUDED
+#include "oscl_base_macros.h"
+#endif
+
+#define PVMIO_MEDIADATA_POOLNUM 9
+#define MIO_PORT_QUEUE_LIMIT 10
+
+#define INPUT_TRANSFER_MODEL_VAL ".../input/transfer_model;valtype=uint32"
+#define OUTPUT_TRANSFER_MODEL_VAL ".../output/transfer_model;valtype=uin32"
+
+// Logging macros
+#define LOGDATAPATH(x)	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iDatapathLogger, PVLOGMSG_INFO, x);
+#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
+#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
+#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+
+#define IS_INPUT_PORT 		(iTag&PVMF_COMMSIO_NODE_INPUT_PORT_TAG)
+
+#define IS_OUTPUT_PORT     	(iTag&PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG)
+
+
+////////////////////////////////////////////////////////////////////////////
+PVCommsIONodePort::PVCommsIONodePort(int32 aPortTag, PVCommsIONode* aNode)
+        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVCommsIONodePort")
+        , PvmfPortBaseImpl(aPortTag
+                           //this port handles its own port activity
+                           , this
+                           // incoming data queue config
+                           , 0
+                           , DEFAULT_DATA_QUEUE_CAPACITY
+                           , DEFAULT_READY_TO_RECEIVE_THRESHOLD_PERCENT
+                           // outgoing data queue config
+                           , 0
+                           , DEFAULT_DATA_QUEUE_CAPACITY
+                           , DEFAULT_READY_TO_RECEIVE_THRESHOLD_PERCENT,
+                           "PVCommsIONodePort")
+        , iNode(aNode)
+        , iMediaOutputTransfer(NULL)
+        , iMediaInputTransfer(NULL)
+        , iMediaDataMemPool(PVMIO_MEDIADATA_POOLNUM)
+        , iState(PVCommsIONodePort::PORT_STATE_BUFFERING)
+        , iWriteState(EWriteOK)
+        , iActiveCommsWrite(true)
+        , iActiveCommsRead(false)
+        , iEndOfInputPortDataReached(false)
+        , iEndOfOutputPortDataReached(false)
+{
+    cmdId = 0;
+    AddToScheduler();
+    iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+    iWriteFailed = false;
+    iPeer = NULL;
+    iCleanupQueue.reserve(1);
+    iWriteAsyncContext = 0;
+    iQueueLimit = MIO_PORT_QUEUE_LIMIT;
+    iTxLogger = iRxLogger = NULL;
+
+    switch (iTag)
+    {
+        case PVMF_COMMSIO_NODE_INPUT_PORT_TAG:
+            // configure default incoming queue size,
+            // and we don't need outgoing queue
+            SetCapacity(EPVOutgoingDataQueue, 0);
+            SetReserve(EPVOutgoingDataQueue, 0);
+            SetThreshold(EPVOutgoingDataQueue, 0);
+            if (iNode->iLogBitstream)
+            {
+                iTxLogger = PVLogger::GetLoggerObject("pvcommionode.tx.bin");
+                iTxLogger->DisableAppenderInheritance();
+            }
+            break;
+        case PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG:
+            // configure default outgoing queue size,
+            // and we don't need icomiing queue
+            SetCapacity(EPVIncomingDataQueue, 0);
+            SetReserve(EPVIncomingDataQueue, 0);
+            SetThreshold(EPVIncomingDataQueue, 0);
+            if (iNode->iLogBitstream)
+            {
+                iRxLogger = PVLogger::GetLoggerObject("pvcommionode.rx.bin");
+                iRxLogger->DisableAppenderInheritance();
+            }
+            break;
+        default:
+            if (iNode->iLogBitstream)
+            {
+                iTxLogger = PVLogger::GetLoggerObject("pvcommionode.tx.bin");
+                iRxLogger = PVLogger::GetLoggerObject("pvcommionode.rx.bin");
+                iTxLogger->DisableAppenderInheritance();
+                iRxLogger->DisableAppenderInheritance();
+            }
+            // defaults are already set for I/O
+            break;
+    }
+
+#ifdef USE_COPY_BUFFER
+    for (int i = 0; i < NUM_COPY_BUFFERS; i++)
+    {
+        oscl_memset(&iCopyBuffer[i][0], 0, COPY_BUFFER_SIZE);
+        iCopyBufferSize[i] = 0;
+    }
+    iCopyBufferIndex = 0;
+    iCopyBufferSent = false;
+#endif
+}
+
+void PVCommsIONodePort::ClearCleanupQueue()
+{//clear the media transfer cleanup queue and log all messages.
+    while (!iCleanupQueue.empty())
+    {
+        PVMFSharedMediaDataPtr mediaData = iCleanupQueue.begin()->iData;
+        PVMFCommandId cmdId = iCleanupQueue.begin()->iCmdId;
+        iCleanupQueue.erase(iCleanupQueue.begin());
+        LogMediaDataInfo("Cleared"
+                         , mediaData
+                         , cmdId
+                         , iCleanupQueue.size()
+                        );
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVCommsIONodePort::~PVCommsIONodePort()
+{
+    PvmfPortBaseImpl::ClearMsgQueues();
+
+    //cancel any pending write operations
+    if (!iCleanupQueue.empty())
+    {
+        int32 err;
+        OSCL_TRY(err, iMediaOutputTransfer->cancelAllCommands(););
+        ClearCleanupQueue();
+    }
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::Start()
+{
+    iState = PVCommsIONodePort::PORT_STATE_STARTED;
+    if (iNode->iMediaIOState == PVCommsIONode::MIO_STATE_STARTED)
+    {
+        RunIfNotReady();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::MediaIOStarted()
+{
+    if (iState == PVCommsIONodePort::PORT_STATE_STARTED)
+        RunIfNotReady();
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::Pause()
+{
+    iState = PVCommsIONodePort::PORT_STATE_BUFFERING;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::Stop()
+{
+    ClearMsgQueues();
+    iState = PVCommsIONodePort::PORT_STATE_BUFFERING;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::Configure(PVMFFormatType aPortProperty)
+{
+    if (iConnectedPort)
+    {
+        // Must disconnect before changing port properties, so return error
+        return PVMFFailure;
+    }
+
+    iFormatType = aPortProperty;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::Connect(PVMFPortInterface* aPort)
+{
+    PVMFStatus status = PvmfPortBaseImpl::Connect(aPort);
+
+    if (status != PVMFSuccess)
+        return status;
+
+    if (!iNode->CreateMediaTransfer(iTag, iMediaInputTransfer, iMediaOutputTransfer))
+        return PVMFFailure;
+
+    if (iMediaInputTransfer)
+        iMediaInputTransfer->setPeer(this);
+    if (iMediaOutputTransfer &&
+            iMediaOutputTransfer != iMediaInputTransfer)
+        iMediaOutputTransfer->setPeer(this);
+
+    iEndOfInputPortDataReached = false;
+    iEndOfOutputPortDataReached = false;
+
+    SetDataTransferModels();
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::PeerConnect(PVMFPortInterface* aPort)
+{
+    PVMFStatus status = PvmfPortBaseImpl::PeerConnect(aPort);
+    if (status != PVMFSuccess)
+        return status;
+
+    if (!iNode->CreateMediaTransfer(iTag, iMediaInputTransfer, iMediaOutputTransfer))
+        return PVMFFailure;
+
+    if (iMediaInputTransfer)
+        iMediaInputTransfer->setPeer(this);
+    if (iMediaOutputTransfer &&
+            iMediaOutputTransfer != iMediaInputTransfer)
+        iMediaOutputTransfer->setPeer(this);
+
+    SetDataTransferModels();
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::Disconnect()
+{
+    PVMFStatus status = PvmfPortBaseImpl::Disconnect();
+    if (status != PVMFSuccess)
+        return status;
+
+    iNode->DeleteMediaTransfer(iTag, iMediaInputTransfer, iMediaOutputTransfer);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::PeerDisconnect()
+{
+    PVMFStatus status = PvmfPortBaseImpl::PeerDisconnect();
+    if (status != PVMFSuccess)
+        return status;
+
+    iNode->DeleteMediaTransfer(iTag, iMediaInputTransfer, iMediaOutputTransfer);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::setPeer(PvmiMediaTransfer *aPeer)
+{
+    iPeer = aPeer;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::useMemoryAllocators(OsclMemAllocator* write_alloc)
+{
+    OSCL_UNUSED_ARG(write_alloc);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVCommsIONodePort::writeAsync(uint8 format_type, int32 format_index, uint8* data, uint32 data_len,
+        const PvmiMediaXferHeader& data_header_info, OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(format_type);
+    OSCL_UNUSED_ARG(format_index);
+
+    // TODO: Handle incoming data here. Create a media data using PvmiMIOSourceDataBufferAlloc::allocate,
+    // save the data there, put the media data to outgoing queue.
+    // If the port is started, schedule to send in Run
+    if (!IS_OUTPUT_PORT || isActiveCommsRead())
+    {
+        // Not configured for input or passive read
+        OsclError::Leave(OsclErrNotSupported);
+    }
+
+    PVLOGGER_LOGBIN(PVLOGMSG_INST_LLDBG, iRxLogger, PVLOGMSG_DEBUG, (0, 1, data_len, data));
+
+    //if the outgoing queue is full, we can't accept data
+    //now.
+    if (IsOutgoingQueueBusy())
+    {
+        iWriteFailed = true;
+        OsclError::Leave(OsclErrGeneral);
+    }
+
+    // Create new media data buffer
+    PVMFSharedMediaDataPtr mediaData;
+    int32 err = 0;
+    if (cmdId == 0x7FFFFFFF)
+        cmdId = 0;
+    OSCL_TRY(err,
+             OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc.allocate(iMediaInputTransfer, data,
+                     data_len, cmdId, aContext);
+             mediaData = PVMFMediaData::createMediaData(mediaDataImpl, &iMediaDataMemPool);
+            );
+
+    // Set timestamp
+    mediaData->setTimestamp(data_header_info.timestamp);
+    mediaData->setSeqNum(data_header_info.seq_num);
+    mediaData->setMediaFragFilledLen(0, data_len);
+
+    // Convert media data to MediaMsg
+    PVMFSharedMediaMsgPtr mediaMsg;
+    convertToPVMFMediaMsg(mediaMsg, mediaData);
+
+
+    if (mediaMsg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+    {
+        iEndOfOutputPortDataReached = true;
+        RunIfNotReady();
+    }
+
+    PVMFStatus status = QueueOutgoingMsg(mediaMsg);
+    if (status != PVMFSuccess)
+        iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)status);
+
+    if (iState == PVCommsIONodePort::PORT_STATE_STARTED)
+        RunIfNotReady();
+    return cmdId++;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+void PVCommsIONodePort::writeComplete(PVMFStatus status, PVMFCommandId aCmdId, OsclAny* aContext)
+//for PvmiMediaTransfer
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "PVCommsIONodePort::writeComplete status %d cmdId %d context 0x%x", status, aCmdId, aContext));
+
+
+
+#ifdef USE_COPY_BUFFER
+    PVLOGGER_LOGBIN(PVLOGMSG_INST_LLDBG, iTxLogger, PVLOGMSG_DEBUG, (0, 1, iCopyBufferSize[(iCopyBufferIndex - 1) % NUM_COPY_BUFFERS], iCopyBuffer[(iCopyBufferIndex -1) % NUM_COPY_BUFFERS]));
+    iCopyBufferSize[(iCopyBufferIndex - 1) % NUM_COPY_BUFFERS] = 0;
+    iCopyBufferSent = false;
+    RunIfNotReady();
+    return;
+#endif
+
+    //we don't expect any error status to be returned here
+    //except possibly cancelled
+    if (status != PVMFSuccess
+            && status != PVMFErrCancelled)
+        iNode->ReportErrorEvent(PVMFErrPortProcessing, NULL, PVCommsIONodeErr_WriteComplete);
+
+    //detect cases where the current call is completing synchronously.
+    if (iWriteState == EWriteBusy
+            && (uint32)aContext == iWriteAsyncContext)
+    {
+        //synchronous completion
+        iWriteState = EWriteOK;
+    }
+    else
+    {
+        //asynchronous completion
+        //do any memory cleanup
+        uint32 i;
+        for (i = 0;i < iCleanupQueue.size();i++)
+        {
+            if (iCleanupQueue[i].iCmdId == aCmdId)
+            {
+                PVMFSharedMediaDataPtr mediaData = iCleanupQueue[i].iData;
+                iCleanupQueue.erase(&iCleanupQueue[i]);
+
+                LogMediaDataInfo("Async Write Complete"
+                                 , mediaData
+                                 , aCmdId
+                                 , iCleanupQueue.size()
+                                );
+                //may need to generate port flow control now
+                PvmfPortBaseImpl::EvaluateIncomingBusy();
+                break;
+            }
+        }
+        //we may be waiting on completion of EOS
+        if (EndOfData(PVMF_COMMSIO_NODE_INPUT_PORT_TAG))
+            RunIfNotReady();
+    }
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVCommsIONodePort::readAsync(uint8* data, uint32 max_data_len, OsclAny* context,
+        int32* formats, uint16 num_formats)
+{
+    OSCL_UNUSED_ARG(data);
+    OSCL_UNUSED_ARG(max_data_len);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(formats);
+    OSCL_UNUSED_ARG(num_formats);
+
+    if (!IS_INPUT_PORT || isActiveCommsWrite())
+    {
+        OsclError::Leave(OsclErrNotSupported);
+    }
+
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::readComplete(PVMFStatus status, PVMFCommandId read_cmd_id,
+                                     int32 format_index, const PvmiMediaXferHeader& data_header_info,
+                                     OsclAny* context)
+{
+    OSCL_UNUSED_ARG(status);
+    OSCL_UNUSED_ARG(read_cmd_id);
+    OSCL_UNUSED_ARG(format_index);
+    OSCL_UNUSED_ARG(data_header_info);
+    OSCL_UNUSED_ARG(context);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::cancelCommand(PVMFCommandId command_id)
+{
+    OSCL_UNUSED_ARG(command_id);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::cancelAllCommands()
+{
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                  PvmiCapabilityAndConfig
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    // Not supported
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    LOG_STACK_TRACE((0, "PVCommsIONodePort::getParametersSync"));
+
+    MIOControlContextSet set;
+
+    if (!iNode)
+    {
+        LOG_ERR((0, "PVCommsIONodePort::getParametersSync: Error - Config object for media IO not available"));
+        return PVMFFailure;
+
+    }
+    set = iNode->ContextSetFromTag(iTag);
+
+    if (set.iMediaInputElement &&
+            set.iMediaInputElement->hasConfig() &&
+            (set.iMediaInputElement->iMediaIOConfig->getParametersSync(session, identifier, parameters, num_parameter_elements, context) == PVMFSuccess))
+        return PVMFSuccess;
+
+    // if this is a proxy port, we don't really have any way of determining
+    // which config we want to query, so if the input query fails, we'll
+    // try on the output config
+    if (set.iMediaOutputElement &&
+            set.iMediaOutputElement->hasConfig() &&
+            (set.iMediaOutputElement->iMediaIOConfig->getParametersSync(session, identifier, parameters, num_parameter_elements, context) == PVMFSuccess))
+        return PVMFSuccess;
+
+    return PVMFFailure;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    LOG_STACK_TRACE((0, "PVCommsIONodePort::releaseParameters"));
+
+    MIOControlContextSet set;
+
+    if (!iNode)
+    {
+        LOG_ERR((0, "PVCommsIONodePort::releaseParameters: Error - Config object for media IO not available"));
+        return PVMFFailure;
+
+    }
+
+    set = iNode->ContextSetFromTag(iTag);
+
+    if (set.iMediaInputElement &&
+            set.iMediaInputElement->hasConfig() &&
+            (set.iMediaInputElement->iMediaIOConfig->releaseParameters(session, parameters, num_elements) == PVMFSuccess))
+        return PVMFSuccess;
+
+    // if this is a proxy port, we don't really have any way of determining
+    // which config we want to query, so if the input query fails, we'll
+    // try on the output config
+    if (set.iMediaOutputElement &&
+            set.iMediaOutputElement->hasConfig() &&
+            (set.iMediaOutputElement->iMediaIOConfig->releaseParameters(session, parameters, num_elements) == PVMFSuccess))
+        return PVMFSuccess;
+
+    return PVMFFailure;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVCommsIONodePort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    LOG_STACK_TRACE((0, "PVCommsIONodePort::setParametersSync"));
+
+    MIOControlContextSet set;
+
+    if (!iNode)
+    {
+        LOG_ERR((0, "PVCommsIONodePort::setParametersSync: Error - Config object for media IO not available"));
+        ret_kvp = parameters;
+        OSCL_LEAVE(OsclErrGeneral);
+    }
+
+    PvmiKvp *ret_kvp1 = NULL;
+    PvmiKvp *ret_kvp2 = NULL;
+
+    set = iNode->ContextSetFromTag(iTag);
+
+    if (set.iMediaInputElement &&
+            set.iMediaInputElement->hasConfig())
+    {
+        set.iMediaInputElement->iMediaIOConfig->setParametersSync(session, parameters, num_elements, ret_kvp1);
+    }
+    // if this is a proxy port, we don't really have any way of determining
+    // which config we want to query, so we'll just try setting both of them
+    if (set.iMediaOutputElement &&
+            set.iMediaOutputElement != set.iMediaInputElement &&
+            set.iMediaOutputElement->hasConfig())
+    {
+        set.iMediaOutputElement->iMediaIOConfig->setParametersSync(session, parameters, num_elements, ret_kvp);
+    }
+    // Since we aren't sure about which IO the request goes to we'll
+    // have to settle for considering 1 successful setParam() a success
+
+    if ((ret_kvp1 == NULL && ret_kvp2 == NULL) ||
+            (set.iMediaInputElement && (ret_kvp1 == NULL)) ||
+            (set.iMediaOutputElement && (ret_kvp2 == NULL)))
+    {
+        ret_kvp = ret_kvp1 ? ret_kvp1 : ret_kvp2;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVCommsIONodePort::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    OsclError::Leave(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 PVCommsIONodePort::getCapabilityMetric(PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVCommsIONodePort::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    LOG_STACK_TRACE((0, "PVCommsIONodePort::verifyParametersSync"));
+
+    MIOControlContextSet set;
+
+    if (!iNode)
+    {
+        LOG_ERR((0, "PVCommsIONodePort::verifyParametersSync: Error - Config object for media IO not available"));
+        return PVMFFailure;
+    }
+
+    set = iNode->ContextSetFromTag(iTag);
+
+    if (set.iMediaInputElement &&
+            set.iMediaInputElement->hasConfig() &&
+            (set.iMediaInputElement->iMediaIOConfig->verifyParametersSync(session, parameters, num_elements) == PVMFSuccess))
+        return PVMFSuccess;
+
+    // if this is a proxy port, we don't really have any way of determining
+    // which config we want to query, so if the input query fails, we'll
+    // try on the output config
+    if (set.iMediaOutputElement &&
+            set.iMediaOutputElement->hasConfig() &&
+            (set.iMediaOutputElement->iMediaIOConfig->verifyParametersSync(session, parameters, num_elements) == PVMFSuccess))
+        return PVMFSuccess;
+
+    return PVMFFailure;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::Run()
+{
+    if (iState == PVCommsIONodePort::PORT_STATE_BUFFERING)
+        return;
+
+#ifdef USE_COPY_BUFFER
+    SendCopyBuffer();
+#endif
+
+    if (iReadAsyncCmds.size() > 0)
+    {
+        PvmiMediaXferHeader data_hdr;
+        data_hdr.seq_num = 0;
+        data_hdr.timestamp = 0;
+        data_hdr.flags = 0;
+        data_hdr.duration = 0;
+        data_hdr.stream_id = 0;
+        //writeAsyncID = iPeer->writeAsync(0, 0, data, bytesToRead, data_hdr);
+
+        iMediaOutputTransfer->readComplete(PVMFSuccess,
+                                           iReadAsyncCmds.begin()->iID,
+                                           0,
+                                           data_hdr,
+                                           iReadAsyncCmds.begin()->iContext);
+        iReadAsyncCmds.erase(iReadAsyncCmds.begin());
+    }
+
+    if (IS_OUTPUT_PORT && OutgoingMsgQueueSize() > 0 && !IsConnectedPortBusy())
+    {
+        //transfer data to connected port.
+        PVMFStatus status = Send();
+        if (status != PVMFSuccess)
+            iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)status);
+    }
+
+    if (CanSendCommsData())
+        SendCommsData();
+
+    if (iNode->IsFlushPending())
+    {
+        if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0
+                && iCleanupQueue.size() == 0)
+            iNode->FlushComplete();
+    }
+
+    // Send EOS event
+    if (EndOfData(PVMF_COMMSIO_NODE_INPUT_PORT_TAG))
+    {
+        iNode->ReportInfoEvent(PVMFInfoEndOfInputPortData, (OsclAny*)NULL);
+        iEndOfInputPortDataReached = false;
+    }
+
+    if (EndOfData(PVMF_COMMSIO_NODE_OUTPUT_PORT_TAG))
+    {
+        iNode->ReportInfoEvent(PVMFInfoEndOfOutputPortData, (OsclAny*)NULL);
+        iEndOfOutputPortDataReached = false;
+    }
+
+    //reschedule if necessary
+    if ((OutgoingMsgQueueSize() > 0 && !IsConnectedPortBusy()) ||
+            CanSendCommsData() ||
+            iReadAsyncCmds.size() > 0)
+    {
+        RunIfNotReady();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVCommsIONodePort::HandlePortActivity(const PVMFPortActivity& aActivity)
+{
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            RunIfNotReady();
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+            //wakeup the AO when the connected port is
+            //ready to accept data again.
+            RunIfNotReady();
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+#ifdef USE_COPY_BUFFER
+            CopyBuffer();
+#else
+            if (CanSendCommsData())
+                RunIfNotReady();
+#endif
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
+            if (iWriteFailed)
+            {
+                iWriteFailed = false;
+                //let the peer know they can try to write again.
+                if (iPeer)
+                    iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+            }
+            break;
+
+        default:
+            break;
+    }
+}
+
+bool PVCommsIONodePort::CanSendCommsData()
+{
+    return !iIncomingQueue.iQ.empty()
+           && iNode->GetState() == EPVMFNodeStarted
+           && iWriteState == EWriteOK
+           && isActiveCommsWrite()
+           && IS_INPUT_PORT;
+}
+
+void PVCommsIONodePort::SendCommsData()
+{
+    if (!CanSendCommsData()) return;
+
+
+    PVMFSharedMediaMsgPtr aMsg;
+    PVMFSharedMediaDataPtr aMediaData;
+    uint32 fragment = 0;
+    uint32 fragindex;
+
+    // get the input message at the front of the queue.
+    aMsg = iIncomingQueue.iQ.front();
+
+    if (aMsg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+    {
+        iEndOfInputPortDataReached = true;
+        // remove the message from the queue
+        iIncomingQueue.iQ.pop();
+        RunIfNotReady();
+        return;
+    }
+
+    convertToPVMFMediaData(aMediaData, aMsg);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVCommsIOPort::SendCommsData Seq %d TS %d Rep 0x%x Count %d"
+                     , aMediaData->getSeqNum()
+                     , aMediaData->getTimestamp()
+                     , aMediaData.GetRep()
+                     , aMediaData.get_count()));
+
+    OSCL_ASSERT(iWriteState == EWriteOK);
+
+    if (iResend
+            && aMediaData->getSeqNum() == iResendSeqNum)
+    {
+        fragment = iResendFragment;
+        iResend = false;
+    }
+
+    for (fragindex = fragment; fragindex < aMediaData->getNumFragments();)
+    {
+        OsclRefCounterMemFrag frag;
+        aMediaData->getMediaFragment(fragindex, frag);
+
+        ++iWriteAsyncContext;
+        iWriteState = EWriteBusy;
+        int32 err;
+        int32 cmdId = 0;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVCommsIONodePort::SendCommsData Calling WriteAsync context 0x%x", iWriteAsyncContext));
+
+        PvmiMediaXferHeader data_hdr;
+        data_hdr.seq_num = aMediaData->getSeqNum();
+        data_hdr.timestamp = aMediaData->getTimestamp();
+        data_hdr.flags = 0;
+        data_hdr.duration = 0;
+        data_hdr.stream_id = 0;
+        //writeAsyncID = iPeer->writeAsync(0, 0, data, bytesToRead, data_hdr);
+
+        err = WriteAsync(cmdId, frag, data_hdr);
+
+        if (err != OsclErrNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVCommsIONodePort::SendData WriteAsync Leave code %d", err));
+
+            LogDatapath("MIO Component Busy!  Waiting on Status Update");
+
+            //if a leave occurs in the writeAsync call, we suspend data
+            //transfer until a statusUpdate call from the MIO component
+            //tells us to resume.
+            //this is not an error-- it's the normal flow control mechanism.
+            iWriteState = EWriteWait;
+
+            //save the data to re-send later.
+            iResend = true;
+            iResendFragment = fragindex;
+            iResendSeqNum = aMediaData->getSeqNum();
+
+            // leave the message on front of the queue and return
+
+            return ;//wait on statusUpdate call from the MIO component.
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVCommsIONodePort::SendData WriteAsync returned cmdId %d", cmdId));
+
+            fragindex++;
+            if (fragindex == aMediaData->getNumFragments())
+            {
+                //all fragments have been sent.  see whether completion
+                //is synchronous or asynchronous.
+                if (iWriteState == EWriteBusy)
+                {
+                    //asynchronous completion.
+                    //push the data onto the cleanup stack so it won't get cleaned
+                    //up until the component consumes it.
+                    iCleanupQueue.push_back(CleanupQueueElement(aMediaData, cmdId));
+
+                    LogMediaDataInfo("Async Write"
+                                     , aMediaData
+                                     , cmdId
+                                     , iCleanupQueue.size()
+                                    );
+
+                }
+                //else the write already completed synchronously.
+                else
+                {
+                    LogMediaDataInfo("Sync Write"
+                                     , aMediaData
+                                    );
+                }
+            }
+            iWriteState = EWriteOK;
+        }
+    }
+
+    // remove the message from the fron of the queue
+    iIncomingQueue.iQ.pop();
+
+}
+
+int32 PVCommsIONodePort::WriteAsync(int32& cmdId,
+                                    OsclRefCounterMemFrag frag,
+                                    PvmiMediaXferHeader data_hdr)
+{
+    int32 err = 0;
+    OSCL_TRY(err,
+             cmdId = iMediaOutputTransfer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA,  /*format_type*/
+                     PVMI_MEDIAXFER_FMT_INDEX_DATA, /*format_index*/
+                     (uint8*)frag.getMemFragPtr(),
+                     frag.getMemFragSize(),
+                     data_hdr,
+                     (OsclAny*)iWriteAsyncContext);
+            );
+    return err;
+}
+
+//for logging media data info
+void PVCommsIONodePort::LogMediaDataInfo(const char*msg, PVMFSharedMediaDataPtr mediaData)
+{
+    OSCL_UNUSED_ARG(msg);
+    OSCL_UNUSED_ARG(mediaData);
+    LOGDATAPATH(
+        (0, "MOUT %s %s MediaData SeqNum %d, SId %d, TS %d"
+         , PortName()
+         , msg
+         , mediaData->getSeqNum()
+         , mediaData->getStreamID()
+         , mediaData->getTimestamp()
+        ));
+}
+//for logging media data info plus write ID and cleanup q depth
+void PVCommsIONodePort::LogMediaDataInfo(const char*msg, PVMFSharedMediaDataPtr mediaData, int32 cmdid, int32 qdepth)
+{
+    OSCL_UNUSED_ARG(msg);
+    OSCL_UNUSED_ARG(mediaData);
+    OSCL_UNUSED_ARG(cmdid);
+    OSCL_UNUSED_ARG(qdepth);
+    LOGDATAPATH(
+        (0, "MOUT %s %s, Write Id %d, MediaData SeqNum %d, SId %d, TS %d, Cleanup Q-depth %d"
+         , PortName()
+         , msg
+         , cmdid
+         , mediaData->getSeqNum()
+         , mediaData->getStreamID()
+         , mediaData->getTimestamp()
+         , qdepth
+        ));
+}
+//for logging media xfer info
+void PVCommsIONodePort::LogDatapath(const char*msg)
+{
+    OSCL_UNUSED_ARG(msg);
+    LOGDATAPATH(
+        (0, "MOUT %s %s"
+         , PortName()
+         , msg
+        ));
+}
+
+void PVCommsIONodePort::statusUpdate(uint32 status_flags)
+//for PvmiMediaTransfer
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "PVCommsIONodePort::statusUpdate flags %d", status_flags));
+
+    if (status_flags & PVMI_MEDIAXFER_STATUS_WRITE)
+    {
+        //recover from a previous async write error.
+        if (iWriteState == EWriteWait)
+        {
+            LogDatapath("Data Transfer re-enabled");
+            iWriteState = EWriteOK;
+            RunIfNotReady();
+        }
+    }
+    else
+    {
+        //disable write
+        iWriteState = EWriteWait;
+    }
+}
+
+OSCL_EXPORT_REF bool PVCommsIONodePort::isIncomingFull()
+// override the PvmfPortBaseImpl routine to impose a
+// limit on the total buffers in this node.
+// Since we are doing this we also need to call EvaluateIncomingBusy
+// when any data is consumed.
+{
+    return (iIncomingQueue.iQ.size()
+            + iCleanupQueue.size()) >= iQueueLimit;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVCommsIONodePort::EndOfData(int32 aPortTag)
+{
+    //this is really just necessary for the unit test,
+    //which uses file I/O.
+    //end of data is reached when we have received the end-of-data
+    //command in the media data and all data is played out.
+    if (aPortTag == PVMF_COMMSIO_NODE_INPUT_PORT_TAG)
+    {
+        return (iEndOfInputPortDataReached
+                && iIncomingQueue.iQ.empty()
+                && iCleanupQueue.empty());
+    }
+    else
+    {
+        return (iEndOfOutputPortDataReached
+                && iOutgoingQueue.iQ.empty());
+    }
+}
+
+void PVCommsIONodePort::SetDataTransferModels()
+{
+    // This will determine how the port writes
+    // and writes data to its mediaDataTransfer
+    // object.  Default is active writing to media
+    // object, and passive reading from media object
+
+    PvmiKvp* parameters = NULL;
+    int num_parameter_elements = 0;
+    PvmiCapabilityContext context = NULL;
+    MIOControlContextSet set;
+
+    set = iNode->ContextSetFromTag(iTag);
+
+    if (set.iMediaInputElement &&
+            set.iMediaInputElement->hasConfig() &&
+            set.iMediaInputElement->iMediaIOConfig->getParametersSync(set.iMediaInputElement->iMediaSession,
+                    OSCL_CONST_CAST(char*, OUTPUT_TRANSFER_MODEL_VAL),
+                    parameters, num_parameter_elements, context) == PVMFSuccess)
+    {
+        if (num_parameter_elements == 1)
+        {
+            // In the future we will be able to handle
+            // both push and pull for input from the
+            // MIO object, but for now we only want to
+            // do push input, meaning the object
+            // calls our writeAsync() method to send data
+            // to us.
+            OSCL_ASSERT(parameters[0].value.uint32_value == 1);
+            iActiveCommsRead = false;
+        }
+        set.iMediaInputElement->iMediaIOConfig->releaseParameters(set.iMediaInputElement->iMediaSession, parameters, num_parameter_elements);
+    }
+    num_parameter_elements = 0;
+    parameters = NULL;
+    if (set.iMediaOutputElement &&
+            set.iMediaOutputElement->hasConfig() &&
+            set.iMediaOutputElement->iMediaIOConfig->getParametersSync(set.iMediaOutputElement->iMediaSession,
+                    OSCL_CONST_CAST(char*, INPUT_TRANSFER_MODEL_VAL),
+                    parameters, num_parameter_elements, context) == PVMFSuccess)
+    {
+        if (num_parameter_elements == 1)
+        {
+            // In the future we will be able to handle
+            // both push and pull for output to the
+            // MIO object, but for now we only want to
+            // do push output, meaning we will call
+            // the object's writeAsync() method to send
+            // data to it.
+            OSCL_ASSERT(parameters[0].value.uint32_value == 1);
+            iActiveCommsWrite = true;
+        }
+        set.iMediaOutputElement->iMediaIOConfig->releaseParameters(set.iMediaOutputElement->iMediaSession, parameters, num_parameter_elements);
+    }
+}
+
+#ifdef USE_COPY_BUFFER
+void PVCommsIONodePort::CopyBuffer()
+{
+    PVMFSharedMediaMsgPtr aMsg;
+    PVMFSharedMediaDataPtr aMediaData;
+
+    while (IncomingMsgQueueSize())
+    {
+        DequeueIncomingMsg(aMsg);
+        convertToPVMFMediaData(aMediaData, aMsg);
+
+        for (uint32 fragindex = 0; fragindex < aMediaData->getNumFragments(); fragindex++)
+        {
+            OsclRefCounterMemFrag frag;
+            aMediaData->getMediaFragment(fragindex, frag);
+
+            //If going to overflow flush data
+            if ((frag.getMemFragSize() + iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS]) > COPY_BUFFER_SIZE)
+            {
+                iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS] = 0;
+            }
+
+            //If frag is too large, drop it
+            if (frag.getMemFragSize() > COPY_BUFFER_SIZE)
+            {
+                continue;
+            }
+
+            oscl_memcpy(&iCopyBuffer[iCopyBufferIndex % NUM_COPY_BUFFERS][iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS]],
+                        frag.getMemFragPtr(),
+                        frag.getMemFragSize());
+
+            iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS] += frag.getMemFragSize();
+        }
+
+        SendCopyBuffer();
+    }
+}
+
+void PVCommsIONodePort::SendCopyBuffer()
+{
+    int32 err;
+    int32 cmdId;
+
+    if (!iCopyBufferSent && (iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS] > 0))
+    {
+        PvmiMediaXferHeader data_hdr;
+        data_hdr.seq_num = iCopyBufferIndex;
+        data_hdr.timestamp = iCopyBufferIndex;
+        data_hdr.flags = 0;
+        data_hdr.duration = 0;
+        data_hdr.stream_id = 0;
+        //writeAsyncID = iPeer->writeAsync(0, 0, data, bytesToRead, data_hdr);
+
+        OSCL_TRY(err,
+                 cmdId = iMediaOutputTransfer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA,  /*format_type*/
+                         PVMI_MEDIAXFER_FMT_INDEX_DATA, /*format_index*/
+                         (uint8*) & iCopyBuffer[iCopyBufferIndex % NUM_COPY_BUFFERS][0],
+                         iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS],
+                         data_hdr,
+                         (OsclAny*)iWriteAsyncContext);
+                );
+
+        if (err)
+        {
+            iCopyBufferSize[iCopyBufferIndex % NUM_COPY_BUFFERS] = 0;
+        }
+        else
+        {
+            iCopyBufferIndex++;
+            iCopyBufferSent = true;
+        }
+    }
+}
+#endif
+
+
+
diff --git a/nodes/pvcommsionode/src/pv_comms_io_node_port.h b/nodes/pvcommsionode/src/pv_comms_io_node_port.h
new file mode 100644
index 0000000..76be4bd
--- /dev/null
+++ b/nodes/pvcommsionode/src/pv_comms_io_node_port.h
@@ -0,0 +1,261 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_media_input_node_outport.h
+ * @brief Output port for media io interface wrapper node
+ *
+ */
+
+#ifndef PV_COMMS_IO_NODE_PORT_H_INCLUDED
+#define PV_COMMS_IO_NODE_PORT_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+#ifndef PVMI_MEDIA_TRANSFER_H_INCLUDED
+#include "pvmi_media_transfer.h"
+#endif
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+#ifndef PVMI_MIO_COMM_DATA_BUFFER_H_INCLUDED
+#include "pvmi_mio_comm_data_buffer.h"
+#endif
+
+// TEMP -RH TSC deletes the allocators while comm node holds buffers
+// so copy them for now to avoid holding onto TSC fragments.
+#define USE_COPY_BUFFER
+#ifdef USE_COPY_BUFFER
+#define NUM_COPY_BUFFERS 2
+#define COPY_BUFFER_SIZE 1024
+#endif
+
+// Forward declaration
+class PVCommsIONode;
+
+class PVCommsIONodePort : public OsclTimerObject,
+            public PvmfPortBaseImpl,
+            public PvmiMediaTransfer,
+            public PVMFPortActivityHandler,
+            public PvmiCapabilityAndConfig
+{
+    public:
+        PVCommsIONodePort(int32 aPortTag, PVCommsIONode* aNode);
+        ~PVCommsIONodePort();
+
+        OSCL_IMPORT_REF void Start();
+        OSCL_IMPORT_REF void MediaIOStarted();
+        OSCL_IMPORT_REF void Pause();
+        OSCL_IMPORT_REF void Stop();
+
+        OSCL_IMPORT_REF PVMFStatus Configure(PVMFFormatType aPortProperty);
+
+        // these override the PvmfPortBaseImpl routines
+        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
+        OSCL_IMPORT_REF PVMFStatus Disconnect();
+        OSCL_IMPORT_REF PVMFStatus PeerConnect(PVMFPortInterface* aPort);
+        OSCL_IMPORT_REF PVMFStatus PeerDisconnect();
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+            {
+                aPtr = (PvmiCapabilityAndConfig*)this;
+            }
+            else
+            {
+                aPtr = NULL;
+            }
+        }
+
+        //from PVMFPortActivityHandler
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        // Pure virtuals from PvmiMediaTransfer
+        void setPeer(PvmiMediaTransfer *aPeer);
+        void useMemoryAllocators(OsclMemAllocator* write_alloc = NULL);
+        PVMFCommandId writeAsync(uint8 format_type, int32 format_index, uint8* data, uint32 data_len,
+                                 const PvmiMediaXferHeader& data_header_info, OsclAny* aContext = NULL);
+        void writeComplete(PVMFStatus aStatus, PVMFCommandId  write_cmd_id, OsclAny* aContext);
+        PVMFCommandId readAsync(uint8* data, uint32 max_data_len, OsclAny* aContext = NULL,
+                                int32* formats = NULL, uint16 num_formats = 0);
+//	void readComplete(PVMFStatus aStatus, PVMFCommandId  read_cmd_id, int32 format_index,
+        //uint32 seq_num, uint32 flags, const PVMFTimestamp& timestamp, OsclAny* aContext);
+        void readComplete(PVMFStatus aStatus, PVMFCommandId  read_cmd_id, int32 format_index,
+                          const PvmiMediaXferHeader& data_header_info, OsclAny* aContext);
+
+        void statusUpdate(uint32 status_flags);
+        void cancelCommand(PVMFCommandId  command_id);
+        void cancelAllCommands();
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        OSCL_IMPORT_REF bool isActiveCommsRead()
+        {
+            return iActiveCommsRead;
+        }
+        OSCL_IMPORT_REF bool isActiveCommsWrite()
+        {
+            return iActiveCommsWrite;
+        }
+
+        OSCL_EXPORT_REF bool isIncomingFull();
+
+    private:
+        int32 WriteAsync(int32& cmdId,
+                         OsclRefCounterMemFrag frag,
+                         PvmiMediaXferHeader data_hdr);
+
+        void Run();
+
+        void QueueData(PVMFSharedMediaDataPtr aData, bool requeue = false, uint32 fragindex = 0);
+        PVMFStatus DequeueData(PVMFSharedMediaDataPtr &aData, bool &aResend, uint32 &aFragment);
+
+        void SetDataTransferModels();
+
+        // Container node
+        PVCommsIONode* iNode;
+
+        // Rx/Tx bitstream loggers;
+        PVLogger *iRxLogger;
+        PVLogger *iTxLogger;
+
+        class AsyncIOCmd
+        {
+            public:
+                AsyncIOCmd(PVMFCommandId id, OsclAny* context = NULL): iID(id), iContext(context) {}
+                PVMFCommandId iID;
+                OsclAny *iContext;
+        };
+        Oscl_Vector<AsyncIOCmd, OsclMemAllocator> iReadAsyncCmds;
+
+        //Format
+        PVMFFormatType iFormatType;
+
+        PvmiMediaTransfer* iMediaOutputTransfer;
+        PvmiMediaTransfer* iMediaInputTransfer;
+        uint32 iRemoteStatus;
+
+        uint32 cmdId;
+
+        //media data re-send queue
+        bool iResend;
+        uint32 iResendSeqNum;
+        uint32 iResendFragment;
+        uint32 iWriteAsyncContext;
+
+        PvmiMIOCommDataBufferAlloc iMediaDataAlloc;
+        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
+
+        enum PortState
+        {
+            PORT_STATE_BUFFERING = 0,
+            PORT_STATE_STARTED,
+        };
+        PortState iState;
+        PVMFFormatType iFormat;
+
+        enum WriteState {EWriteBusy, EWriteWait, EWriteOK};
+        WriteState iWriteState;
+
+        //media data cleanup queue
+        class CleanupQueueElement
+        {
+            public:
+                CleanupQueueElement(PVMFSharedMediaDataPtr d, PVMFCommandId id): iData(d), iCmdId(id) {}
+                PVMFSharedMediaDataPtr iData;
+                PVMFCommandId iCmdId;
+        };
+        Oscl_Vector<CleanupQueueElement, OsclMemAllocator> iCleanupQueue;
+
+        // Receive and Send models for the MediaDataTransfer
+        // interface.  Threading model will likely dictate
+        // how these are set.
+        bool iActiveCommsWrite;
+        bool iActiveCommsRead;
+
+        uint32 iQueueLimit;
+
+        bool iEndOfInputPortDataReached;
+        bool iEndOfOutputPortDataReached;
+
+        //for flow control
+        bool iWriteFailed;
+        PvmiMediaTransfer* iPeer;
+
+        void ClearCleanupQueue();
+        void CleanupMediaTransfer();
+
+        bool CanSendCommsData();
+        void SendCommsData();
+
+        bool EndOfData(int32 aTag);
+
+        //for datapath logging
+        void LogMediaDataInfo(const char*msg, PVMFSharedMediaDataPtr mediaData, int32 p1, int32 p2);
+        void LogMediaDataInfo(const char*msg, PVMFSharedMediaDataPtr mediaData);
+        void LogDatapath(const char*msg);
+
+#ifdef USE_COPY_BUFFER
+        uint8 iCopyBuffer[NUM_COPY_BUFFERS][COPY_BUFFER_SIZE];
+        uint32 iCopyBufferSize[NUM_COPY_BUFFERS];
+        uint32 iCopyBufferIndex;
+        bool iCopyBufferSent;
+
+        void CopyBuffer();
+        void SendCopyBuffer();
+#endif
+};
+
+#endif // PV_COMMS_IO_NODE_PORT_H_INCLUDED
diff --git a/nodes/pvdownloadmanagernode/Android.mk b/nodes/pvdownloadmanagernode/Android.mk
index e1a8b79..2a8311c 100644
--- a/nodes/pvdownloadmanagernode/Android.mk
+++ b/nodes/pvdownloadmanagernode/Android.mk
@@ -2,43 +2,36 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/\
 	src/pvmf_downloadmanager_factory.cpp \
-	src/pvmf_downloadmanager_node.cpp \
-	src/pvmf_filebufferdatastream_factory.cpp \
-	src/pvmf_memorybufferdatastream_factory.cpp
-
+ 	src/pvmf_downloadmanager_node.cpp \
+ 	src/pvmf_filebufferdatastream_factory.cpp \
+ 	src/pvmf_memorybufferdatastream_factory.cpp
 
 
 LOCAL_MODULE := libpvdownloadmanagernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvdownloadmanagernode/include \
-	$(PV_TOP)//nodes/pvdownloadmanagernode/src \
-	$(PV_TOP)//nodes/pvdownloadmanagernode/../common/include \
-	$(PV_TOP)//nodes/pvdownloadmanagernode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvdownloadmanagernode/../streaming/common/include \
-	$(PV_INCLUDES) 
-
-ifeq ($(ARCHITECTURE),linux_nj)
-	LOCAL_C_INCLUDES += $(PV_TOP)//nodes/pvdownloadmanagernode/config/opencore
-else
-	ifeq ($(FORMAT), nj)
-                LOCAL_C_INCLUDES += $(PV_TOP)//nodes/pvdownloadmanagernode/config/opencore
-        else
-                LOCAL_C_INCLUDES += $(PV_TOP)//nodes/pvdownloadmanagernode/config/default
-        endif
-endif
+	$(PV_TOP)/nodes/pvdownloadmanagernode/src \
+ 	$(PV_TOP)/nodes/pvdownloadmanagernode/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_downloadmanager_defs.h \
-	include/pvmf_downloadmanager_factory.h \
-	include/pvmf_filebufferdatastream_factory.h \
-	include/pvmf_memorybufferdatastream_factory.h
+ 	include/pvmf_downloadmanager_factory.h \
+ 	include/pvmf_filebufferdatastream_factory.h \
+ 	include/pvmf_memorybufferdatastream_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvdownloadmanagernode/build/make/local.mk b/nodes/pvdownloadmanagernode/build/make/local.mk
new file mode 100644
index 0000000..ff47aa7
--- /dev/null
+++ b/nodes/pvdownloadmanagernode/build/make/local.mk
@@ -0,0 +1,38 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvdownloadmanagernode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+XINCDIRS += \
+  ../../../common/include \
+  ../../../../pvmi/pvmf/include \
+  ../../../streaming/common/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := \
+	pvmf_downloadmanager_factory.cpp \
+	pvmf_downloadmanager_node.cpp \
+	pvmf_filebufferdatastream_factory.cpp \
+	pvmf_memorybufferdatastream_factory.cpp
+
+HDRS := \
+	pvmf_downloadmanager_defs.h \
+	pvmf_downloadmanager_factory.h \
+	pvmf_filebufferdatastream_factory.h \
+	pvmf_memorybufferdatastream_factory.h
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvdownloadmanagernode/build/make/makefile b/nodes/pvdownloadmanagernode/build/make/makefile
deleted file mode 100755
index 1b48003..0000000
--- a/nodes/pvdownloadmanagernode/build/make/makefile
+++ /dev/null
@@ -1,80 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET =pvdownloadmanagernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this so that correct headers for player get included
-
-XINCDIRS += \
-	-I ../../../common/include \
-	-I ../../../../pvmi/pvmf/include \
-	-I ../../../streaming/common/include
-
-#Select the config based on architecture.
-ifeq ($(ARCHITECTURE),linux_nj)
-	XINCDIRS += -I../../config/opencore
-else
-	ifeq ($(FORMAT), nj)
-                XINCDIRS += -I../../config/opencore
-        else
-                XINCDIRS += -I../../config/default
-        endif
-endif
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = \
-	pvmf_downloadmanager_factory.cpp \
-	pvmf_downloadmanager_node.cpp \
-	pvmf_filebufferdatastream_factory.cpp \
-	pvmf_memorybufferdatastream_factory.cpp
-
-HDRS = \
-	pvmf_downloadmanager_defs.h \
-	pvmf_downloadmanager_factory.h \
-	pvmf_filebufferdatastream_factory.h \
-	pvmf_memorybufferdatastream_factory.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvdownloadmanagernode/config/opencore/pvmf_downloadmanager_config.h b/nodes/pvdownloadmanagernode/config/opencore/pvmf_downloadmanager_config.h
index cda14fb..0404a8a 100644
--- a/nodes/pvdownloadmanagernode/config/opencore/pvmf_downloadmanager_config.h
+++ b/nodes/pvdownloadmanagernode/config/opencore/pvmf_downloadmanager_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,8 +48,7 @@
 ** use for progressive playback.
 */
 #ifndef PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB
-//#define PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB 13
-#define PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB 39
+#define PVMF_DOWNLOADMANAGER_MIN_TCP_BUFFERS_FOR_PPB  8
 #endif
 
 #endif // PVMF_DOWNLOADMANAGER_CONFIG_H_INCLUDED
diff --git a/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_defs.h b/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_defs.h
index ce7886a..96ff53c 100644
--- a/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_defs.h
+++ b/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_factory.h b/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_factory.h
index 69fce1c..6786c8f 100644
--- a/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_factory.h
+++ b/nodes/pvdownloadmanagernode/include/pvmf_downloadmanager_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvdownloadmanagernode/include/pvmf_filebufferdatastream_factory.h b/nodes/pvdownloadmanagernode/include/pvmf_filebufferdatastream_factory.h
index 15056fb..8dc40b6 100644
--- a/nodes/pvdownloadmanagernode/include/pvmf_filebufferdatastream_factory.h
+++ b/nodes/pvdownloadmanagernode/include/pvmf_filebufferdatastream_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h b/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h
index 67bf124..6ea1db3 100644
--- a/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h
+++ b/nodes/pvdownloadmanagernode/include/pvmf_memorybufferdatastream_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,13 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+// only include pvmf_downloadmanager_config.h if CML2 is NOT being used
+#ifndef USE_CML2_CONFIG
 #ifndef PVMF_DOWNLOADMANAGER_CONFIG_H_INCLUDED
 #include "pvmf_downloadmanager_config.h"
 #endif
+#endif
+
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
 
 #ifndef PVMF_MEMORYBUFFERDATASTREAM_FACTORY_H_INCLUDED
@@ -73,10 +77,16 @@
 
 // this is the minimum size of the sliding window
 // the file format parsers used this number to decide if a clip can be played properly in a progressive manner
-// TBD this needs to be tied to the socket memory pool size
-#define READ_BUFFER_SIZE        1680000
+// @TODO this needs to be tied to the socket memory pool size
+#define READ_BUFFER_SIZE    300000
+#define READ_BUFFER_TRIM_THRESHOLD  100 * 1024
+#if (ENABLE_LARGE_MBDS_CACHE_SIZE)
+#undef READ_BUFFER_SIZE
+#define READ_BUFFER_SIZE    1680000
 
-#define READ_BUFFER_TRIM_THRESHOLD      900 * 1024
+#undef READ_BUFFER_TRIM_THRESHOLD
+#define READ_BUFFER_TRIM_THRESHOLD 	900 * 1024
+#endif
 
 // starts trimming if the cache is grown beyond this margin
 #define READ_BUFFER_MARGIN 		4 * 1024
@@ -90,8 +100,8 @@
 #define BYTES_TO_WAIT         4 * 1024
 
 // In forward repositioning, if the data is going to come in soon,
-// which is defined as requested offset minus the download offset
-// is less than this threshold, then don't disconnect and send a new GET request.
+// which is defined as requested offset minus the download offset (aka current write pointer)
+// being less than this threshold, then don't disconnect to send a new GET request.
 #define PV_MBDS_FWD_SEEKING_NO_GET_REQUEST_THRESHOLD 64000
 
 typedef enum
@@ -510,6 +520,7 @@
 
         OSCL_IMPORT_REF PvmiDataStreamStatus SetReadPointerPosition(PvmiDataStreamSession aSessionID, uint32 aFilePosition);
 
+
         OSCL_IMPORT_REF PvmiDataStreamStatus SetReadPointerCacheLocation(PvmiDataStreamSession aSessionID, bool aInTempCache);
 
         OSCL_IMPORT_REF void ManageCache();
@@ -519,6 +530,7 @@
         OSCL_IMPORT_REF void UpdateReadPointersAfterMakePersistent();
 
         OSCL_IMPORT_REF bool GetPermCachePersistence(uint32& aFirstOffset, uint32& aLastOffset);
+
     public:
         bool iDownloadComplete;
 
@@ -641,6 +653,7 @@
 class PVMFMemoryBufferDataStream
 {
     public:
+        // in case we would want to pass the constructor an existing cache
         OSCL_IMPORT_REF PVMFMemoryBufferDataStream();
 
         OSCL_IMPORT_REF ~PVMFMemoryBufferDataStream();
diff --git a/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_factory.cpp b/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_factory.cpp
index 4e4dca1..edbaae3 100644
--- a/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_factory.cpp
+++ b/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.cpp b/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.cpp
index 36b0e43..2e381ec 100644
--- a/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.cpp
+++ b/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,12 @@
 #include "pv_mime_string_utils.h"
 #include "pvmi_kvp_util.h"
 #include "pvmf_source_context_data.h"
-#include "oscl_utf8conv.h"
+
+//Log levels for node commands
+#define CMD_LOG_LEVEL PVLOGMSG_INFO
+//Log levels for subnode commands.
+#define SUB_CMD_LOG_LEVEL PVLOGMSG_INFO
+
 
 ///////////////////////////////////////////////////////////////////////////////
 //
@@ -68,22 +73,7 @@
     BASEKEY_MAX_TCP_RECV_BUFFER_COUNT
 };
 
-void PVMFDownloadManagerNode::Assert(bool x)
-{
-    if (!x)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_CRIT, (0, "PVMFDownloadManagerNode Assertion Failed!"));
-        OSCL_ASSERT(0);
-    }
-}
 
-void PVMFDownloadManagerSubNodeContainerBase::Assert(bool x)
-{
-    if (!x)
-    {
-        iContainer->Assert(x);
-    }
-}
 
 PVMFDownloadManagerNode::PVMFDownloadManagerNode(int32 aPriority)
         : OsclActiveObject(aPriority, "PVMFDownloadManagerNode")
@@ -112,10 +102,11 @@
     iDebugMode = false;
     iLogger = NULL;
     iExtensionRefCount = 0;
-    iSourceFormat = PVMF_FORMAT_UNKNOWN;
+    iSourceFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iMimeType = PVMF_MIME_FORMAT_UNKNOWN;
     iSourceData = NULL;
     iPlayBackClock = NULL;
+    iClockNotificationsInf = NULL;
 
 
     iParserInit = false;
@@ -156,15 +147,17 @@
     iCapability.iCanSupportMultipleOutputPorts = true;
     iCapability.iHasMaxNumberOfPorts = true;
     iCapability.iMaxNumberOfPorts = 6;
-    iCapability.iInputFormatCapability.push_back(PVMF_MPEG4FF);
-    iCapability.iInputFormatCapability.push_back(PVMF_ASFFF);
-    iCapability.iInputFormatCapability.push_back(PVMF_RMFF);
-    iCapability.iOutputFormatCapability.push_back(PVMF_AMR_IETF);
-    iCapability.iOutputFormatCapability.push_back(PVMF_MPEG4_AUDIO);
-    iCapability.iOutputFormatCapability.push_back(PVMF_M4V);
-    iCapability.iOutputFormatCapability.push_back(PVMF_H263);
-    iCapability.iOutputFormatCapability.push_back(PVMF_RV);
-    iCapability.iOutputFormatCapability.push_back(PVMF_WMV);
+    iCapability.iInputFormatCapability.push_back(PVMF_MIME_MPEG4FF);
+    iCapability.iInputFormatCapability.push_back(PVMF_MIME_ASFFF);
+    iCapability.iInputFormatCapability.push_back(PVMF_MIME_RMFF);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_MPEG4_AUDIO);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_M4V);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2631998);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2632000);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_REAL_VIDEO);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_WMV);
+    iCapability.iOutputFormatCapability.push_back(PVMF_MIME_DIVXFF);
 
     iFileBufferDatastreamFactory = NULL;
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
@@ -172,6 +165,7 @@
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_PPB
 
     iDownloadFileName = NULL;
+    iContentTypeMIMEString = NULL;
 
     iProtocolEngineNode.iNode = PVMFProtocolEngineNodeFactory::CreatePVMFProtocolEngineNode(OsclActiveObject::EPriorityNominal);
     OsclError::LeaveIfNull(iProtocolEngineNode.iNode);
@@ -184,10 +178,13 @@
 
 PVMFDownloadManagerNode::~PVMFDownloadManagerNode()
 {
-    //remove the clock observer
     if (iPlayBackClock != NULL)
     {
-        iPlayBackClock->RemoveClockStateObserver(*this);
+        if (iClockNotificationsInf != NULL)
+        {
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iPlayBackClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+        }
     }
 
     Cancel();
@@ -227,14 +224,7 @@
         bool release_status = false;
         int32 leavecode = 0;
         OSCL_TRY(leavecode, release_status = iPlayerNodeRegistry->ReleaseNode(iDNodeUuids[iDNodeUuidCount], iFormatParserNode.iNode));
-        OSCL_FIRST_CATCH_ANY(leavecode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDownloadManagerNode::~PVMFDownloadManagerNode() Error in releasing Download Manager Node")););
-
-        if (release_status == false)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::~PVMFDownloadManagerNode() Factory returned false while releasing the download manager node"));
-        }
-
+        //ignore errors.
         iDNodeUuids.clear();
     }
 
@@ -265,7 +255,6 @@
         CommandComplete(iCancelCommand, iCancelCommand.front(), PVMFFailure, NULL, NULL);
     while (!iInputCommands.empty())
         CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure, NULL, NULL);
-
 }
 
 //Public API From node interface.
@@ -280,7 +269,7 @@
 
     iLogger = PVLogger::GetLoggerObject("pvdownloadmanagernode");
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::ThreadLogon() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::ThreadLogon() called"));
 
     //logon the sub-nodes.
     if (iProtocolEngineNode.iNode)
@@ -297,7 +286,7 @@
 //Public API From node interface.
 PVMFStatus PVMFDownloadManagerNode::ThreadLogoff()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::ThreadLogoff() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::ThreadLogoff() called"));
 
     if (iInterfaceState != EPVMFNodeIdle)
         return PVMFErrInvalidState;
@@ -324,7 +313,7 @@
 //Public API From node interface.
 PVMFStatus PVMFDownloadManagerNode::GetCapability(PVMFNodeCapability& aNodeCapability)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::GetCapability() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::GetCapability() called"));
 
     aNodeCapability = iCapability;
 
@@ -335,7 +324,7 @@
 //Public API From node interface.
 PVMFPortIter* PVMFDownloadManagerNode::GetPorts(const PVMFPortFilter* aFilter)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::GetPorts() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::GetPorts() called"));
 
     if (iFormatParserNode.iNode)
         return iFormatParserNode.iNode->GetPorts(aFilter);
@@ -348,7 +337,7 @@
         Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids, bool aExactUuidsOnly, const OsclAny* aContext)
 {
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::QueryUUID() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::QueryUUID() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
@@ -360,7 +349,7 @@
 PVMFCommandId PVMFDownloadManagerNode::QueryInterface(PVMFSessionId aSessionId, const PVUuid& aUuid,
         PVInterface*& aInterfacePtr, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::QueryInterface() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::QueryInterface() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
@@ -372,7 +361,7 @@
 PVMFCommandId PVMFDownloadManagerNode::RequestPort(PVMFSessionId aSessionId, int32 aPortTag,
         const PvmfMimeString* aPortConfig, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::RequestPort() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::RequestPort() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
@@ -383,7 +372,7 @@
 //Public API From node interface.
 PVMFStatus PVMFDownloadManagerNode::ReleasePort(PVMFSessionId aSessionId, PVMFPortInterface& aPort, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::ReleasePort() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::ReleasePort() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
@@ -394,7 +383,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Init(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Init() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Init() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_INIT, aContext);
@@ -405,7 +394,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Prepare(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Prepare() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Prepare() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_PREPARE, aContext);
@@ -416,7 +405,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Start(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Start() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Start() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_START, aContext);
@@ -427,7 +416,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Stop(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Stop() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Stop() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_STOP, aContext);
@@ -438,7 +427,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Flush(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Flush() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Flush() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_FLUSH, aContext);
@@ -449,7 +438,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Pause(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Pause() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Pause() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_PAUSE, aContext);
@@ -460,7 +449,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::Reset(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::Reset() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::Reset() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_RESET, aContext);
@@ -471,7 +460,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::CancelAllCommands(PVMFSessionId aSessionId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::CancelAllCommands() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::CancelAllCommands() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
@@ -482,7 +471,7 @@
 //Public API From node interface.
 PVMFCommandId PVMFDownloadManagerNode::CancelCommand(PVMFSessionId aSessionId, PVMFCommandId aCmdId, const OsclAny* aContext)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::CancelCommand() called"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::CancelCommand() called"));
 
     PVMFDownloadManagerNodeCommand cmd;
     cmd.PVMFDownloadManagerNodeCommandBase::Construct(aSessionId, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
@@ -564,22 +553,22 @@
         return PVMFErrInvalidState;
 
     //Validate
-    switch (aSourceFormat)
+    if (aSourceFormat == PVMF_MIME_DATA_SOURCE_HTTP_URL)
     {
-        case PVMF_DATA_SOURCE_HTTP_URL:
-            if (!aSourceData)
-                return PVMFErrArgument;
-            break;
-
-        case PVMF_DATA_SOURCE_PVX_FILE:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
-                            "PVMFDownloadManagerNode:SetSourceInitializationData() Unsupported source format."));
-            return PVMFErrArgument; // unsupported format
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
-                            "PVMFDownloadManagerNode:SetSourceInitializationData() Unsupported source format."));
-            return PVMFErrArgument; // unsupported format
+        if (!aSourceData)
+            return PVMFErrArgument;
+    }
+    else if (aSourceFormat == PVMF_MIME_DATA_SOURCE_PVX_FILE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
+                        "PVMFDownloadManagerNode:SetSourceInitializationData() Unsupported source format."));
+        return PVMFErrArgument; // unsupported format
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
+                        "PVMFDownloadManagerNode:SetSourceInitializationData() Unsupported source format."));
+        return PVMFErrArgument; // unsupported format
     }
 
     // Pass the source info directly to the protocol engine node.
@@ -610,35 +599,72 @@
         return PVMFErrProcessing;
     }
 
-    switch (aSourceFormat)
+    if (aSourceFormat == PVMF_MIME_DATA_SOURCE_HTTP_URL)
     {
-        case PVMF_DATA_SOURCE_HTTP_URL:
+        PVInterface* pvinterface = (PVInterface*)aSourceData;
+        PVUuid uuid(PVMF_DOWNLOAD_DATASOURCE_HTTP_UUID);
+        PVInterface* temp = NULL;
+        if (pvinterface->queryInterface(uuid, temp))
         {
-            PVInterface* pvinterface = (PVInterface*)aSourceData;
-            PVUuid uuid(PVMF_DOWNLOAD_DATASOURCE_HTTP_UUID);
-            PVMFDownloadDataSourceHTTP* data = NULL;
-            if (pvinterface->queryInterface(uuid, (PVInterface*&)data))
+            PVMFDownloadDataSourceHTTP* data = OSCL_STATIC_CAST(PVMFDownloadDataSourceHTTP*, temp);
+            //extract the download file name from the opaque data.
+            iDownloadFileName = data->iDownloadFileName;
+
+            //extract CPM options
+            iLocalDataSource.iUseCPMPluginRegistry = data->iUseCPMPluginRegistryForPlayback;
+
+            //extract the playback mode
+            switch (data->iPlaybackControl)
             {
+                case PVMFDownloadDataSourceHTTP::ENoPlayback:
+                    iPlaybackMode = EDownloadOnly;
+                    break;
+                case PVMFDownloadDataSourceHTTP::EAfterDownload:
+                    iPlaybackMode = EDownloadThenPlay;
+                    break;
+                case PVMFDownloadDataSourceHTTP::EAsap:
+                    iPlaybackMode = EPlayAsap;
+                    break;
+
+                case PVMFDownloadDataSourceHTTP::ENoSaveToFile:
+#if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
+                    iPlaybackMode = EPlaybackOnly;
+                    break;
+#else
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
+                                    "PVMFDownloadManagerNode:SetSourceInitializationData() NoSaveToFile is not supported!"));
+                    return PVMFErrArgument;//unsupported mode.
+#endif//PVMF_DOWNLOADMANAGER_SUPPORT_PPB
+
+                default:
+                    iPlaybackMode = EPlayAsap;
+                    break;
+            }
+        }
+        else
+        {
+            PVUuid uuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
+            temp = NULL;
+            if (pvinterface->queryInterface(uuid, temp))
+            {
+                PVMFSourceContextDataDownloadHTTP* data = OSCL_STATIC_CAST(PVMFSourceContextDataDownloadHTTP*, temp);
                 //extract the download file name from the opaque data.
                 iDownloadFileName = data->iDownloadFileName;
 
-                //extract CPM options
-                iLocalDataSource.iUseCPMPluginRegistry = data->iUseCPMPluginRegistryForPlayback;
-
                 //extract the playback mode
                 switch (data->iPlaybackControl)
                 {
-                    case PVMFDownloadDataSourceHTTP::ENoPlayback:
+                    case PVMFSourceContextDataDownloadHTTP::ENoPlayback:
                         iPlaybackMode = EDownloadOnly;
                         break;
-                    case PVMFDownloadDataSourceHTTP::EAfterDownload:
+                    case PVMFSourceContextDataDownloadHTTP::EAfterDownload:
                         iPlaybackMode = EDownloadThenPlay;
                         break;
-                    case PVMFDownloadDataSourceHTTP::EAsap:
+                    case PVMFSourceContextDataDownloadHTTP::EAsap:
                         iPlaybackMode = EPlayAsap;
                         break;
 
-                    case PVMFDownloadDataSourceHTTP::ENoSaveToFile:
+                    case PVMFSourceContextDataDownloadHTTP::ENoSaveToFile:
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
                         iPlaybackMode = EPlaybackOnly;
                         break;
@@ -652,69 +678,31 @@
                         iPlaybackMode = EPlayAsap;
                         break;
                 }
+
+                //extract the cpm usage flag from the common data
+                {
+                    PVUuid uuid(PVMF_SOURCE_CONTEXT_DATA_COMMON_UUID);
+                    temp = NULL;
+                    if (pvinterface->queryInterface(uuid, temp))
+                    {
+                        PVMFSourceContextDataCommon* data = OSCL_STATIC_CAST(PVMFSourceContextDataCommon*, temp);
+                        iLocalDataSource.iUseCPMPluginRegistry = data->iUseCPMPluginRegistry;
+                    }
+                    else
+                    {//invalid source data
+                        return PVMFErrArgument;
+                    }
+                }
             }
             else
-            {
-                PVUuid uuid(PVMF_SOURCE_CONTEXT_DATA_DOWNLOAD_HTTP_UUID);
-                PVMFSourceContextDataDownloadHTTP* data = NULL;
-                if (pvinterface->queryInterface(uuid, (PVInterface*&)data))
-                {
-                    //extract the download file name from the opaque data.
-                    iDownloadFileName = data->iDownloadFileName;
-
-                    //extract the playback mode
-                    switch (data->iPlaybackControl)
-                    {
-                        case PVMFSourceContextDataDownloadHTTP::ENoPlayback:
-                            iPlaybackMode = EDownloadOnly;
-                            break;
-                        case PVMFSourceContextDataDownloadHTTP::EAfterDownload:
-                            iPlaybackMode = EDownloadThenPlay;
-                            break;
-                        case PVMFSourceContextDataDownloadHTTP::EAsap:
-                            iPlaybackMode = EPlayAsap;
-                            break;
-
-                        case PVMFSourceContextDataDownloadHTTP::ENoSaveToFile:
-#if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
-                            iPlaybackMode = EPlaybackOnly;
-                            break;
-#else
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0,
-                                            "PVMFDownloadManagerNode:SetSourceInitializationData() NoSaveToFile is not supported!"));
-                            return PVMFErrArgument;//unsupported mode.
-#endif//PVMF_DOWNLOADMANAGER_SUPPORT_PPB
-
-                        default:
-                            iPlaybackMode = EPlayAsap;
-                            break;
-                    }
-
-                    //extract the cpm usage flag from the common data
-                    {
-                        PVUuid uuid(PVMF_SOURCE_CONTEXT_DATA_COMMON_UUID);
-                        PVMFSourceContextDataCommon* data = NULL;
-                        if (pvinterface->queryInterface(uuid, (PVInterface*&)data))
-                        {
-                            iLocalDataSource.iUseCPMPluginRegistry = data->iUseCPMPluginRegistry;
-                        }
-                        else
-                        {//invalid source data
-                            return PVMFErrArgument;
-                        }
-                    }
-                }
-                else
-                {//invalid source data
-                    return PVMFErrArgument;
-                }
+            {//invalid source data
+                return PVMFErrArgument;
             }
         }
-        break;
-
-        default:
-            Assert(false);
-            break;
+    }
+    else
+    {
+        OSCL_ASSERT(false);
     }
 
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
@@ -727,7 +715,7 @@
         // Use Memory Buffer Data Stream for progressive playback
         iMemoryBufferDatastreamFactory = OSCL_NEW(PVMFMemoryBufferDataStream, ());
 
-        Assert(iMemoryBufferDatastreamFactory != NULL);
+        OSCL_ASSERT(iMemoryBufferDatastreamFactory != NULL);
 
         iReadFactory  = iMemoryBufferDatastreamFactory->GetReadDataStreamFactoryPtr();
         iWriteFactory = iMemoryBufferDatastreamFactory->GetWriteDataStreamFactoryPtr();
@@ -738,7 +726,7 @@
         // Now that we have the download file name, we can instantiate the file buffer data stream object
         // Create the filebuffer data stream factory
         iFileBufferDatastreamFactory = OSCL_NEW(PVMFFileBufferDataStream, (iDownloadFileName));
-        Assert(iFileBufferDatastreamFactory != NULL);
+        OSCL_ASSERT(iFileBufferDatastreamFactory != NULL);
         iReadFactory  = iFileBufferDatastreamFactory->GetReadDataStreamFactoryPtr();
         iWriteFactory = iFileBufferDatastreamFactory->GetWriteDataStreamFactoryPtr();
     }
@@ -752,12 +740,20 @@
 }
 
 //public API from data source initialization interface
-PVMFStatus PVMFDownloadManagerNode::SetClientPlayBackClock(OsclClock* aClientClock)
+PVMFStatus PVMFDownloadManagerNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::SetClientPlayBackClock() called"));
 
     iPlayBackClock = aClientClock;
-    iPlayBackClock->SetClockStateObserver(*this);
+    if (iPlayBackClock)
+    {
+        iPlayBackClock->ConstructMediaClockNotificationsInterface(iClockNotificationsInf, *this);
+    }
+
+    if (iClockNotificationsInf != NULL)
+    {
+        iClockNotificationsInf->SetClockStateObserver(*this);
+    }
 
     //pass the source info directly to the download node.
     if (NULL == iProtocolEngineNode.DataSourceInit())
@@ -769,7 +765,7 @@
 }
 
 //public API from data source initialization interface
-PVMFStatus PVMFDownloadManagerNode::SetEstimatedServerClock(OsclClock*)
+PVMFStatus PVMFDownloadManagerNode::SetEstimatedServerClock(PVMFMediaClock*)
 {
     //not needed for download.
     return PVMFErrNotSupported;
@@ -778,15 +774,14 @@
 PVMFDownloadManagerSubNodeContainer& PVMFDownloadManagerNode::TrackSelectNode()
 {
     //Decide which sub-node is supporting track selection.
-    switch (iSourceFormat)
+    if (iSourceFormat == PVMF_MIME_DATA_SOURCE_HTTP_URL)
     {
-        case PVMF_DATA_SOURCE_HTTP_URL:
-            //for 3gpp, the parser does track selection.
-            return iFormatParserNode;
-
-
-        default:
-            return iFormatParserNode;
+        //for 3gpp, the parser does track selection.
+        return iFormatParserNode;
+    }
+    else
+    {
+        return iFormatParserNode;
     }
 }
 
@@ -909,6 +904,7 @@
         OsclAny* aContextData,
         bool aSeekToSyncPoint)
 {
+    OSCL_UNUSED_ARG(aSeekPointAfterTargetNPT);
     // Implemented to complete interface file definition
     // Not tested on logical plane
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -937,7 +933,7 @@
 }
 
 
-PVMFCommandId PVMFDownloadManagerNode::SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, OsclTimebase* aTimebase, OsclAny* aContext)
+PVMFCommandId PVMFDownloadManagerNode::SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, PVMFTimebase* aTimebase, OsclAny* aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFDownloadManagerNode::SetDataSourceRate: aRate=%d", aRate));
@@ -981,6 +977,8 @@
     // Wakeup the AO
     RunIfNotReady();
 
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::QueueCommandL() returning %d", id));
+
     return id;
 }
 
@@ -1002,7 +1000,7 @@
     }
 
     //The newest or highest pri command is in the front of the queue.
-    Assert(!iInputCommands.empty());
+    OSCL_ASSERT(!iInputCommands.empty());
     PVMFDownloadManagerNodeCommand& aCmd = iInputCommands.front();
 
     PVMFStatus cmdstatus;
@@ -1121,7 +1119,7 @@
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
 
             default:
-                Assert(false);
+                OSCL_ASSERT(false);
                 cmdstatus = PVMFFailure;
                 break;
         }
@@ -1144,12 +1142,12 @@
 {
     //Complete a node command
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::CommandComplete() In Id %d Cmd %d Status %d Context %d Data %d",
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL, (0, "PVMFDownloadManagerNode::CommandComplete() In Id %d Cmd %d Status %d Context %d Data %d",
                     aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
 
     if (aStatus != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, CMD_LOG_LEVEL,
                         (0, "PVMFDownloadManagerNode::CommandComplete() Failure!"));
     }
 
@@ -1184,7 +1182,6 @@
             case PVMF_GENERIC_NODE_RESET:
                 //drive this node back to Created state.
                 ChangeNodeState(EPVMFNodeIdle);
-                ThreadLogoff();
                 break;
         }
     }
@@ -1235,6 +1232,11 @@
     {
         GenerateDataReadyEvent();
     }
+    else if (aEvent.GetEventType() == PVMFInfoContentType)
+    {
+        // copy and save MIME string for recognizer to use as hint
+        iContentTypeMIMEString = (char *)aEvent.GetEventData();
+    }
 }
 
 void PVMFDownloadManagerNode::GenerateDataReadyEvent()
@@ -1274,7 +1276,7 @@
         case PVMFInfoRemoteSourceNotification:
             //we get this event for "not pseudostreamable" for both fast-track
             //and 3gpp.  Only pass it up for 3gpp.
-            if (iSourceFormat != PVMF_DATA_SOURCE_HTTP_URL)
+            if (iSourceFormat != PVMF_MIME_DATA_SOURCE_HTTP_URL)
                 return true;
             break;
         default:
@@ -1304,7 +1306,7 @@
     bool exactmatch;
     aCmd.PVMFDownloadManagerNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
 
-    // TODO Add MIME string matching
+    // @TODO Add MIME string matching
     // For now just return all available extension interface UUID
     uuidvec->push_back(PVMF_TRACK_SELECTION_INTERFACE_UUID);
     uuidvec->push_back(PVMF_DATA_SOURCE_INIT_INTERFACE_UUID);
@@ -1441,16 +1443,17 @@
     //remove the clock observer
     if (iPlayBackClock != NULL)
     {
-        iPlayBackClock->RemoveClockStateObserver(*this);
+        if (iClockNotificationsInf != NULL)
+        {
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iPlayBackClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+            iClockNotificationsInf = NULL;
+        }
     }
 
     //Start executing a node command
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::DoResetNode() In"));
 
-    if (iInterfaceState == EPVMFNodeStarted
-            || iInterfaceState == EPVMFNodePaused)
-        return PVMFErrInvalidState;
-
     //Reset the sub-nodes first.
     return ScheduleSubNodeCommands(aCmd);
 }
@@ -1637,8 +1640,8 @@
     if (!(iMimeType == PVMF_MIME_FORMAT_UNKNOWN))
     {
         PVMFNodeInterface *iSourceNode = NULL;
-        PVMFFormatType outputFormatType = PVMF_FORMAT_UNKNOWN;
-        iFmt = GetFormatIndex(iMimeType.get_str());
+        PVMFFormatType outputFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+        iFmt = iMimeType.get_str();
         PVMFStatus status =
             iPlayerNodeRegistry->QueryRegistry(iFmt, outputFormatType, iDNodeUuids);
         if ((status == PVMFSuccess) && (iDNodeUuids.size() > 0))
@@ -1657,7 +1660,7 @@
 {
     //given the node command ID, create the sub-node command vector, initiate the processing and return the node command status.
 
-    Assert(iSubNodeCmdVec.empty());
+    OSCL_ASSERT(iSubNodeCmdVec.empty());
 
     //Create the vector of all the commands in the sequence.
     switch (aCmd.iCmd)
@@ -1673,7 +1676,7 @@
             PVUuid*aUuid;
             PVInterface**aInterface;
             aCmd.PVMFDownloadManagerNodeCommandBase::Parse(aUuid, aInterface);
-            Assert(aUuid != NULL);
+            OSCL_ASSERT(aUuid != NULL);
 
             if (*aUuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)
             {
@@ -1683,11 +1686,7 @@
                 Push(iProtocolEngineNode, PVMFDownloadManagerSubNodeContainerBase::EQueryDataSourceInit);
                 Push(iProtocolEngineNode, PVMFDownloadManagerSubNodeContainerBase::EQueryDownloadProgress);
             }
-            else
-            {
-                //nothing else needed for any other interface.
-                return PVMFSuccess;
-            }
+            //else nothing else needed for other interfaces.
         }
         break;
 
@@ -1700,6 +1699,7 @@
                 Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EInit);
             }
             else
+
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
             {
                 //reset any prior download/playback event
@@ -1769,48 +1769,52 @@
             break;
 
         case PVMF_GENERIC_NODE_START:
-            //if file isn't parsed (as in download-only), just ignore command
-            if (!iFormatParserNode.iNode)
-                return PVMFSuccess;
-            Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EStart);
+            //Re-start socket node & PE node in case they were stopped by a prior
+            //stop command.
+            if (iSocketNode.iNode->GetState() == EPVMFNodePrepared)
+                Push(iSocketNode, PVMFDownloadManagerSubNodeContainerBase::EStart);
+            if (iProtocolEngineNode.iNode->GetState() == EPVMFNodePrepared)
+                Push(iProtocolEngineNode, PVMFDownloadManagerSubNodeContainerBase::EStart);
+            //Start or re-start parser node (unless download-only)
+            if (iFormatParserNode.iNode)
+                Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EStart);
             break;
 
         case PVMF_GENERIC_NODE_STOP:
-            //just stop parser here.
-            //if I stop socket and protocol engine, then re-start hangs.
-            //tbd, would be nice to be able to stop & re-start the download.
-            //if file isn't parsed (as in download-only), just ignore command
-            if (!iFormatParserNode.iNode)
-                return PVMFSuccess;
-            Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EStop);
+            iDataReady = false;
+            //Stop parser (unless download-only)
+            if (iFormatParserNode.iNode)
+                Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EStop);
+            //Stop PE node & socket node.
+            Push(iProtocolEngineNode, PVMFDownloadManagerSubNodeContainerBase::EStop);
+            Push(iSocketNode, PVMFDownloadManagerSubNodeContainerBase::EStop);
             break;
 
         case PVMF_GENERIC_NODE_FLUSH:
-            //if file isn't parsed (as in download-only), just ignore command
-            if (!iFormatParserNode.iNode)
-                return PVMFSuccess;
-            Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EFlush);
+            if (iFormatParserNode.iNode)
+                Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EFlush);
             break;
 
         case PVMF_GENERIC_NODE_PAUSE:
             //note: pause/resume download is not supported.
-            //if file isn't parsed (as in download-only), just ignore command
-            if (!iFormatParserNode.iNode)
-                return PVMFSuccess;
-            Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EPause);
+            if (iFormatParserNode.iNode)
+                Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EPause);
             break;
 
         case PVMF_GENERIC_NODE_RESET:
+            //Stop socket node if needed.
             if (iSocketNode.iNode->GetState() == EPVMFNodeStarted
                     || iSocketNode.iNode->GetState() == EPVMFNodePaused)
             {
                 Push(iSocketNode, PVMFDownloadManagerSubNodeContainerBase::EStop);
             }
+            //Stop PE node if needed.
             if (iProtocolEngineNode.iNode->GetState() == EPVMFNodeStarted
                     || iProtocolEngineNode.iNode->GetState() == EPVMFNodePaused)
             {
                 Push(iProtocolEngineNode, PVMFDownloadManagerSubNodeContainerBase::EStop);
             }
+            //Reset & cleanup all nodes.
             if (iFormatParserNode.iNode)
                 Push(iFormatParserNode, PVMFDownloadManagerSubNodeContainerBase::EReset);
             Push(iSocketNode, PVMFDownloadManagerSubNodeContainerBase::EReset);
@@ -1849,7 +1853,7 @@
             break;
 
         default:
-            Assert(false);
+            OSCL_ASSERT(false);
             break;
     }
 
@@ -1937,6 +1941,7 @@
 PVMFStatus PVMFDownloadManagerNode::DoGetLicense(PVMFDownloadManagerNodeCommand& aCmd,
         bool aWideCharVersion)
 {
+    OSCL_UNUSED_ARG(aCmd);
     if (iFormatParserNode.LicenseInterface() == NULL)
     {
         return PVMFErrNotSupported;
@@ -1963,6 +1968,7 @@
 
 PVMFStatus PVMFDownloadManagerNode::DoCancelGetLicense(PVMFDownloadManagerNodeCommand& aCmd)
 {
+    OSCL_UNUSED_ARG(aCmd);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerNode::DoCancelGetLicense called"));
     if (iFormatParserNode.LicenseInterface() == NULL)
     {
@@ -2066,31 +2072,21 @@
         iSessionId = iNode->Connect(info);
 }
 
-#define LOGTRACE(x) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE, (0,x))
+#define LOGSUBCMD(x) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, SUB_CMD_LOG_LEVEL, x)
+#define GETNODESTR (iType==EFormatParser)?"Parser":((iType==EProtocolEngine)?"ProtEngine":"SockNode")
 
 PVMFStatus PVMFDownloadManagerSubNodeContainer::IssueCommand(int32 aCmd)
 {
     //Issue a command to the sub-node.
     //Return the sub-node completion status-- either pending, success, or failure.
 
-    if (iType == EFormatParser)
-    {
-        LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand to PARSER () In");
-    }
-    else if (iType == EProtocolEngine)
-    {
-        LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand to PROTOCOLENGINE () In");
-    }
-    else if (iType == ESocket)
-    {
-        LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand to SOCKET () In");
-    }
+    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s () In", GETNODESTR));
 
-    Assert(!CmdPending());
+    OSCL_ASSERT(!CmdPending());
 
     //find the current node command since we may need its parameters.
 
-    Assert(!iContainer->iCurrentCommand.empty());
+    OSCL_ASSERT(!iContainer->iCurrentCommand.empty());
     PVMFDownloadManagerNodeCommand* nodeCmd = &iContainer->iCurrentCommand.front();
 
     //save the sub-node command code
@@ -2099,7 +2095,7 @@
     switch (aCmd)
     {
         case ECleanup:
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Cleanup");
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Cleanup", GETNODESTR));
             Cleanup();
             return PVMFSuccess;
 
@@ -2114,63 +2110,70 @@
             return PVMFErrCorrupt;
 
         case EQueryDataSourceInit:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface(data source init)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(data source init)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PVMF_DATA_SOURCE_INIT_INTERFACE_UUID, iDataSourceInit);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EQueryProtocolEngine:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface(ProtocolEngine)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(ProtocolEngine)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, KPVMFProtocolEngineNodeExtensionUuid, iProtocolEngineExtensionInt);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EQueryDatastreamUser:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface(DatastreamUser)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(DatastreamUser)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PVMIDatastreamuserInterfaceUuid, iDatastreamUser);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EQueryTrackSelection:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface(track selection)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(track selection)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PVMF_TRACK_SELECTION_INTERFACE_UUID, iTrackSelection);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EQueryMetadata:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface (metadata)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(metadata)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, KPVMFMetadataExtensionUuid, iMetadata);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE)
         case ECPMQueryLicenseInterface:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface (metadata)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(License)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PVMFCPMPluginLicenseInterfaceUuid, iLicenseInterface);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
 
         case EQueryDataSourcePlayback:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface (datasourcePB)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface(datasourcePB)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PvmfDataSourcePlaybackControlUuid, iDataSourcePlayback);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EInit:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             if (iType == EFormatParser)
             {
                 // For this command, which gets pushed to the format parser node, we set the source init and also
                 // set the datstream factory
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand issuing SetSourceInitializationData to format parser node.");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling SetSourceInitializationData", GETNODESTR));
 
                 if (!DataSourceInit())
                     return PVMFFailure; //no source init interface?
@@ -2187,7 +2190,7 @@
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
                 {
                     //Pass source data
-                    //for 3gpp, pass the recognized file format to the parser node.
+                        //for 3gpp, pass the recognized file format to the parser node.
                     {
                         (DataSourceInit())->SetSourceInitializationData(iContainer->iDownloadFileName
                                 , iContainer->iFmt
@@ -2198,32 +2201,36 @@
                     (DatastreamUser())->PassDatastreamFactory(*(iContainer->iReadFactory), (int32)0);
                     PVMFFileBufferDataStreamWriteDataStreamFactoryImpl* wdsfactory =
                         OSCL_STATIC_CAST(PVMFFileBufferDataStreamWriteDataStreamFactoryImpl*, iContainer->iWriteFactory);
-                    PVMFDataStreamReadCapacityObserver* obs =
-                        OSCL_STATIC_CAST(PVMFDataStreamReadCapacityObserver*, wdsfactory);
                     int32 leavecode = 0;
-                    OSCL_TRY(leavecode, (DatastreamUser())->PassDatastreamReadCapacityObserver(obs));
+                    OSCL_TRY(leavecode,
+                             PVMFDataStreamReadCapacityObserver* obs =
+                                 OSCL_STATIC_CAST(PVMFDataStreamReadCapacityObserver*, wdsfactory);
+                             (DatastreamUser())->PassDatastreamReadCapacityObserver(obs));
                     OSCL_FIRST_CATCH_ANY(leavecode,
-                                         LOGTRACE("PVMFDownloadManagerNode::IssueCommand() - PassDatastreamReadCapacityObserver Not supported"););
+                                         LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s PassDatastreamReadCapacityObserver not supported", GETNODESTR));
+                                        );
                 }
 
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Init on Format Parser Node");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Init ", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = iNode->Init(iSessionId);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
             else
             {
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Init");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Init ", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = iNode->Init(iSessionId);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
 
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE)
         case ECPMGetLicenseW:
         {
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling ECPMGetLicenseW");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling ECPMGetLicenseW", GETNODESTR));
             iCmdState = EBusy;
             OSCL_wString* contentName = NULL;
             OsclAny* data = NULL;
@@ -2241,12 +2248,13 @@
                                                timeoutMsec);
             iCPMGetLicenseCmdId = iCmdId;
 
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
         }
         case ECPMGetLicense:
         {
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling ECPMGetLicense");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling ECPMGetLicense", GETNODESTR));
             iCmdState = EBusy;
             OSCL_String* contentName = NULL;
             OsclAny* data = NULL;
@@ -2264,115 +2272,125 @@
                                                timeoutMsec);
             iCPMGetLicenseCmdId = iCmdId;
 
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
         }
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
 
         case ERequestPort:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             // The parameters to RequestPort vary depending on which node we're getting a port from, so we switch on it.
             switch (iType)
             {
                 case EProtocolEngine:
-                    LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling RequestPort to Protocol Engine Node");
+                    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling RequestPort ", GETNODESTR));
                     iCmdState = EBusy;
                     // For protocol engine port request, we don't need port tag or config info because it's the only port we ask it for.
                     iCmdId = iNode->RequestPort(iSessionId, (int32)0);
+                    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                     return PVMFPending;
 
                 case ESocket:
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
-                                    "PVMFDownloadManagerSubNodeContainer::IssueCommand Calling RequestPort to socket node with port config %s", iContainer->iServerAddr.get_cstr()));
+                    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling RequestPort with port config %s", GETNODESTR, iContainer->iServerAddr.get_cstr()));
                     iCmdState = EBusy;
                     //append a mimestring to the port for socket node logging
                     iContainer->iServerAddr += ";mime=download";
                     iCmdId = iNode->RequestPort(iSessionId, PVMF_SOCKET_NODE_PORT_TYPE_PASSTHRU, &iContainer->iServerAddr);
+                    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                     return PVMFPending;
 
                 case EFormatParser:
                     //extract params from current Node command.
-                    Assert(nodeCmd->iCmd == PVMF_GENERIC_NODE_REQUESTPORT);
+                    OSCL_ASSERT(nodeCmd->iCmd == PVMF_GENERIC_NODE_REQUESTPORT);
                     {
                         int32 aPortTag;
                         OSCL_String*aMimetype;
                         nodeCmd->PVMFDownloadManagerNodeCommandBase::Parse(aPortTag, aMimetype);
 
-                        LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling RequestPort to Format Parser Node");
+                        LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling RequestPort ", GETNODESTR));
                         iCmdState = EBusy;
                         iCmdId = iNode->RequestPort(iSessionId, aPortTag, aMimetype);
                     }
+                    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                     return PVMFPending;
 
                 default:
-                    Assert(false);
+                    OSCL_ASSERT(false);
                     return PVMFFailure;
             }
 
         case EReleasePort:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             {
                 //extract params from current Node command.
-                Assert(nodeCmd->iCmd == PVMF_GENERIC_NODE_RELEASEPORT);
+                OSCL_ASSERT(nodeCmd->iCmd == PVMF_GENERIC_NODE_RELEASEPORT);
                 PVMFPortInterface *port;
                 nodeCmd->PVMFDownloadManagerNodeCommandBase::Parse(port);
-                Assert(port != NULL);
+                OSCL_ASSERT(port != NULL);
 
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling ReleasePort");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling ReleasePort", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = iNode->ReleasePort(iSessionId, *port);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
 
         case EPrepare:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Prepare");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Prepare", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->Prepare(iSessionId);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EStop:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Stop");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Stop", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->Stop(iSessionId);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EStart:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Start");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Start", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->Start(iSessionId);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EPause:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Pause");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Pause", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->Pause(iSessionId);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EFlush:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Flush");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Flush", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->Flush(iSessionId);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EReset:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling Reset");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling Reset", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->Reset(iSessionId);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EGetMetadataKey:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             {
                 if (!Metadata())
                     return PVMFErrNotSupported;//no interface!
 
                 //extract params from current Node command.
-                Assert(nodeCmd->iCmd == PVDLM_NODE_CMD_GETNODEMETADATAKEY);
+                OSCL_ASSERT(nodeCmd->iCmd == PVDLM_NODE_CMD_GETNODEMETADATAKEY);
 
                 PVMFMetadataList* aKeyList;
                 uint32 starting_index;
@@ -2380,107 +2398,113 @@
                 char* query_key;
 
                 nodeCmd->Parse(aKeyList, starting_index, max_entries, query_key);
-                Assert(aKeyList != NULL);
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling GetMetadataKey");
+                OSCL_ASSERT(aKeyList != NULL);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling GetNodeMetadataKeys", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = (Metadata())->GetNodeMetadataKeys(iSessionId, *aKeyList, starting_index, max_entries, query_key, NULL);
 
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
 
 
         case EGetMetadataValue:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             {
                 if (!Metadata())
                     return PVMFErrNotSupported;//no interface!
 
                 //extract params from current Node command.
-                Assert(nodeCmd->iCmd == PVDLM_NODE_CMD_GETNODEMETADATAVALUE);
+                OSCL_ASSERT(nodeCmd->iCmd == PVDLM_NODE_CMD_GETNODEMETADATAVALUE);
                 PVMFMetadataList* aKeyList;
                 Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList;
                 uint32 starting_index;
                 int32 max_entries;
                 nodeCmd->Parse(aKeyList, aValueList, starting_index, max_entries);
-                Assert(aKeyList != NULL);
-                Assert(aValueList != NULL);
+                OSCL_ASSERT(aKeyList != NULL);
+                OSCL_ASSERT(aValueList != NULL);
 
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling GetMetadataValue");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling GetNodeMetadataValues", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = (Metadata())->GetNodeMetadataValues(iSessionId, *aKeyList, *aValueList, starting_index, max_entries, NULL);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
 
         case EQueryFFProgDownload:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface (format prog dl)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface (format prog dl)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PVMF_FF_PROGDOWNLOAD_SUPPORT_INTERFACE_UUID, iFormatProgDownloadSupport);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case EQueryDownloadProgress:
-            Assert(iNode != NULL);
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryInterface (dl prog)");
+            OSCL_ASSERT(iNode != NULL);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryInterface (dl prog)", GETNODESTR));
             iCmdState = EBusy;
             iCmdId = iNode->QueryInterface(iSessionId, PVMF_DOWNLOAD_PROGRESS_INTERFACE_UUID, iDownloadProgress);
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
             return PVMFPending;
 
         case ESetFFProgDownloadSupport:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
 
             if (!DownloadProgress() || !iContainer->iFormatParserNode.FormatProgDownloadSupport())
                 return PVMFErrNotSupported;//no interface!
 
             //pass parser node format prog download interface to the protocol node.
-            LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling setFormatDownloadSupportInterface");
+            LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling setFormatDownloadSupportInterface", GETNODESTR));
             (DownloadProgress())->setFormatDownloadSupportInterface(iContainer->iFormatParserNode.FormatProgDownloadSupport());
             return PVMFSuccess;
 
         case ESetDataSourcePosition:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             {
                 if (!DataSourcePlayback())
                     return PVMFErrNotSupported;//no interface!
 
                 //extract params from current Node command.
-                Assert(nodeCmd->iCmd == PVDLM_NODE_CMD_SETDATASOURCEPOSITION);
+                OSCL_ASSERT(nodeCmd->iCmd == PVDLM_NODE_CMD_SETDATASOURCEPOSITION);
                 PVMFTimestamp aTargetNPT;
                 PVMFTimestamp* aActualNPT;
                 PVMFTimestamp* aActualMediaDataTS;
                 uint32 streamID = 0;
                 bool aJump;
                 nodeCmd->Parse(aTargetNPT, aActualNPT, aActualMediaDataTS, aJump, streamID);
-                Assert(aActualNPT != NULL);
-                Assert(aActualMediaDataTS != NULL);
+                OSCL_ASSERT(aActualNPT != NULL);
+                OSCL_ASSERT(aActualMediaDataTS != NULL);
 
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling SetDataSourcePosition");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling SetDataSourcePosition", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = (DataSourcePlayback())->SetDataSourcePosition(iSessionId, aTargetNPT, *aActualNPT, *aActualMediaDataTS, aJump, streamID);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
 
         case EQueryDataSourcePosition:
-            Assert(iNode != NULL);
+            OSCL_ASSERT(iNode != NULL);
             {
                 if (!DataSourcePlayback())
                     return PVMFErrNotSupported;//no interface!
 
                 //extract params from current Node command.
-                Assert(nodeCmd->iCmd == PVDLM_NODE_CMD_QUERYDATASOURCEPOSITION);
+                OSCL_ASSERT(nodeCmd->iCmd == PVDLM_NODE_CMD_QUERYDATASOURCEPOSITION);
                 PVMFTimestamp aTargetNPT;
                 PVMFTimestamp* aActualNPT;
                 bool aJump;
                 nodeCmd->Parse(aTargetNPT, aActualNPT, aJump);
-                Assert(aActualNPT != NULL);
+                OSCL_ASSERT(aActualNPT != NULL);
 
-                LOGTRACE("PVMFDownloadManagerSubNodeContainer::IssueCommand Calling QueryDataSourcePosition");
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s Calling QueryDataSourcePosition", GETNODESTR));
                 iCmdState = EBusy;
                 iCmdId = (DataSourcePlayback())->QueryDataSourcePosition(iSessionId, aTargetNPT, *aActualNPT, aJump);
+                LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::IssueCommand %s CmdId %d ", GETNODESTR, iCmdId));
                 return PVMFPending;
             }
 
         default:
-            Assert(false);
+            OSCL_ASSERT(false);
             return PVMFFailure;
     }
 }
@@ -2491,9 +2515,9 @@
     //Issue a command to the Recognizer.
     //Return the completion status-- either pending, success, or failure.
 
-    LOGTRACE("PVMFDownloadManagerRecognizerContainer::IssueCommand In");
+    LOGSUBCMD((0, "PVMFDownloadManagerRecognizerContainer::IssueCommand In"));
 
-    Assert(!CmdPending());
+    OSCL_ASSERT(!CmdPending());
 
     //save the sub-node command code
     iCmd = aCmd;
@@ -2511,7 +2535,7 @@
                          *(iContainer->iReadFactory),
                          NULL,
                          iRecognizerResultVec);
-                LOGTRACE("PVMFDownloadManagerRecognizerContainer::IssueCommand Recognize Pending");
+                LOGSUBCMD((0, "PVMFDownloadManagerRecognizerContainer::IssueCommand Recognize Pending Cmd ID %d", iCmdId));
                 return PVMFPending;
                 //wait on the RecognizerCommandCompleted callback.
             }
@@ -2537,8 +2561,8 @@
         }
 
         default:
-            LOGTRACE("PVMFDownloadManagerRecognizerContainer::IssueCommand Error, Unknown Recognizer Command!");
-            Assert(false);//unknown command type for recognizer.
+            LOGSUBCMD((0, "PVMFDownloadManagerRecognizerContainer::IssueCommand Error, Unknown Recognizer Command!"));
+            OSCL_ASSERT(false);//unknown command type for recognizer.
             return PVMFFailure;
     }
 }
@@ -2553,7 +2577,147 @@
         if (aResponse.GetCmdStatus() == PVMFSuccess
                 && iRecognizerResultVec.size() > 0)
         {
-            iContainer->iMimeType = iRecognizerResultVec[0].iRecognizedFormat;
+            // if there is only 1, use it
+            // if more than 1, check the confidence level
+            if (1 == iRecognizerResultVec.size())
+            {
+                iContainer->iMimeType = iRecognizerResultVec[0].iRecognizedFormat;
+            }
+            else
+            {
+                // if certain, use it
+                // if possible, keep looking
+                bool found = false;
+                for (uint32 i = 0; i < iRecognizerResultVec.size(); i++)
+                {
+                    if (PVMFRecognizerConfidenceCertain == iRecognizerResultVec[i].iRecognitionConfidence)
+                    {
+                        found = true;
+                        iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                        break;
+                    }
+                }
+
+                // if Content-Type may not be known, just use the first result
+                if (!found && (0 != iContainer->iContentTypeMIMEString.get_size()))
+                {
+                    // no certain, all possibles
+                    // compare with the Content-Type hint, which is in IANA MIME string format
+                    // these are file formats, does not include streaming formats
+                    // @TODO: need to add the following to "pvmi/pvmf/include/pvmf_format_type.h"
+                    //
+                    // MP4 + 3GPP = "video/3gpp", "video/mp4", "audio/3gpp", "audio/mp4", "video/3gpp-tt"
+                    // AMR = "audio/amr", "audio/amr-wb"
+                    // AAC = "audio/aac", "audio/x-aac", "audio/aacp"
+                    // MP3 = "audio/mpeg"
+                    // WM + ASF = "video/x-ms-wmv", "video/x-ms-wm", "video/x-ms-asf","audio/x-ms-wma",
+                    // RM = "video/vnd.rn-realvideo", "audio/vnd.rn-realaudio"
+                    // WAV = "audio/wav", "audio/x-wav", "audio/wave"
+                    //
+                    // the recognizer plugins may return PV proprietary format, X-...
+                    // in "pvmi/pvmf/include/pvmf_format_type.h"
+                    // #define PVMF_MIME_MPEG4FF               "video/MP4"
+                    // #define PVMF_MIME_AMRFF                 "X-AMR-FF"
+                    // #define PVMF_MIME_AACFF                 "X-AAC-FF"
+                    // #define PVMF_MIME_MP3FF                 "X-MP3-FF"
+                    // #define PVMF_MIME_WAVFF                 "X-WAV-FF"
+                    // #define PVMF_MIME_ASFFF                 "x-pvmf/mux/asf"
+                    // #define PVMF_MIME_RMFF                  "x-pvmf/mux/rm"
+
+                    // need case insensitive compares
+                    const char* mimeStr = iContainer->iContentTypeMIMEString.get_cstr();
+
+                    for (uint32 i = 0; !found && i < iRecognizerResultVec.size(); i++)
+                    {
+                        const char* recognizedStr = iRecognizerResultVec[i].iRecognizedFormat.get_cstr();
+                        if (0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_MPEG4FF))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "video/3gpp"))    ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "video/mp4"))     ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/3gpp"))    ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/mp4"))     ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "video/3gpp-tt")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else if (0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_MP3FF))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "audio/mpeg")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else if (0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_AACFF))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "audio/aac"))   ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/x-aac")) ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/aacp")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else if (0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_AMRFF))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "audio/amr"))  ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/amr-wb")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else if (0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_ASFFF))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "video/x-ms-wmv"))  ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "video/x-ms-wm"))   ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "video/x-ms-asf"))  ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/x-ms-wma")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else if (0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_RMFF))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "video/vnd.rn-realvideo"))  ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/vnd.rn-realaudio")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else if ((0 == oscl_CIstrcmp(recognizedStr, PVMF_MIME_WAVFF)))
+                        {
+                            if ((0 == oscl_CIstrcmp(mimeStr, "audio/wav"))    ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/wave"))   ||
+                                    (0 == oscl_CIstrcmp(mimeStr, "audio/x-wav")))
+                            {
+                                found = true;
+                                iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                            }
+                        }
+                        else
+                        {
+                            // some new format that this component does not know about
+                            // we'll use it
+                            found = true;
+                            iContainer->iMimeType = iRecognizerResultVec[i].iRecognizedFormat;
+                        }
+                    }
+                }
+
+                // if still no match found
+                // need to wait for more data and run the recognizer again, will implement this later
+                // just use the first one for now
+                if (!found)
+                {
+                    // @TODO - implement the recognizer loop later
+                    iContainer->iMimeType = iRecognizerResultVec[0].iRecognizedFormat;
+                }
+            }
         }
 
         CommandDone(aResponse.GetCmdStatus(), aResponse.GetEventExtensionInterface(), aResponse.GetEventData());
@@ -2568,7 +2732,7 @@
     }
     else
     {
-        Assert(false);//unexpected response.
+        OSCL_ASSERT(false);//unexpected response.
     }
 }
 
@@ -2595,7 +2759,7 @@
                 return; // Suppress socket node error, if the download is already complete.
             break;
         default:
-            Assert(false);
+            OSCL_ASSERT(false);
             break;
     }
 
@@ -2688,20 +2852,20 @@
     switch (iType)
     {
         case EFormatParser:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_ERR, (0,
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
                             "PVMFDownloadManagerSubNodeContainer::HandleNodeInfoEvent Parser Node Info Event %d", aEvent.GetEventType()));
             break;
         case EProtocolEngine:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_ERR, (0,
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
                             "PVMFDownloadManagerSubNodeContainer::HandleNodeInfoEvent ProtocolEngine Node Info Event %d", aEvent.GetEventType()));
             break;
         case ESocket:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_ERR, (0,
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
                             "PVMFDownloadManagerSubNodeContainer::HandleNodeInfoEvent Socket Node Info Event %d", aEvent.GetEventType()));
             break;
 
         default:
-            Assert(false);
+            OSCL_ASSERT(false);
             break;
     }
 }
@@ -2717,8 +2881,9 @@
 
     if (iNode)
     {
-        LOGTRACE("PVMFDownloadManagerSubNodeContainer::CancelPendingCommand Calling Cancel");
+        LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::CancelPendingCommand Calling Cancel"));
         iCancelCmdId = iNode->CancelCommand(iSessionId, iCmdId, NULL);
+        LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::CancelPendingCommand CmdId %d", iCancelCmdId));
     }
 
     return true;//cancel initiated
@@ -2733,8 +2898,9 @@
 
     iCancelCmdState = EBusy;
 
-    LOGTRACE("PVMFDownloadManagerSubNodeContainer::CancelPendingCommand Calling Cancel");
+    LOGSUBCMD((0, "PVMFDownloadManagerRecognizerContainer::CancelPendingCommand Calling Cancel"));
     iCancelCmdId = PVMFRecognizerRegistry::CancelCommand(iRecognizerSessionId, iCmdId, NULL);
+    LOGSUBCMD((0, "PVMFDownloadManagerRecognizerContainer::CancelPendingCommand CmdId %d", iCancelCmdId));
 
     return true;//cancel initiated
 }
@@ -2744,10 +2910,10 @@
 {
     //a sub-node command is done-- process the result.
 
-    Assert(aStatus != PVMFPending);
+    OSCL_ASSERT(aStatus != PVMFPending);
 
     //pop the sub-node command vector.
-    Assert(!iContainer->iSubNodeCmdVec.empty());
+    OSCL_ASSERT(!iContainer->iSubNodeCmdVec.empty());
     iContainer->iSubNodeCmdVec.erase(&iContainer->iSubNodeCmdVec.front());
 
     iCmdState = EIdle;
@@ -2836,7 +3002,7 @@
     else
     {
         //node command is done.
-        Assert(!iContainer->iCurrentCommand.empty());
+        OSCL_ASSERT(!iContainer->iCurrentCommand.empty());
         iContainer->CommandComplete(iContainer->iCurrentCommand, iContainer->iCurrentCommand.front(), status, aExtMsg, aEventData);
     }
 }
@@ -2847,7 +3013,7 @@
     OSCL_UNUSED_ARG(aEventData);
     //a sub-node cancel command is done-- process the result.
 
-    Assert(aStatus != PVMFPending);
+    OSCL_ASSERT(aStatus != PVMFPending);
 
     iCancelCmdState = EIdle;
     //print and ignore any failed sub-node cancel commands.
@@ -2856,25 +3022,25 @@
         switch (iType)
         {
             case EFormatParser:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_ERR, (0,
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
                                 "PVMFDownloadManagerSubNodeContainer::CancelCommandDone Parser Node Cancel failed"));
                 break;
             case EProtocolEngine:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_ERR, (0,
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
                                 "PVMFDownloadManagerSubNodeContainer::CancelCommandDone ProtocolEngine Node Cancel failed"));
                 break;
             case ESocket:
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_ERR, (0,
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0,
                                 "PVMFDownloadManagerSubNodeContainer::CancelCommandDone Socket Node Cancel failed"));
                 break;
             default:
-                Assert(false);
+                OSCL_ASSERT(false);
                 break;
         }
     }
 
     //Node cancel command is now done.
-    Assert(!iContainer->iCancelCommand.empty());
+    OSCL_ASSERT(!iContainer->iCancelCommand.empty());
     iContainer->CommandComplete(iContainer->iCancelCommand, iContainer->iCancelCommand.front(), aStatus, NULL, NULL);
 }
 
@@ -2882,23 +3048,11 @@
 void PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted(const PVMFCmdResp& aResponse)
 {
     //A command to a sub-node is complete
-
-    if (iType == EFormatParser)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted FORMAT PARSER"));
-    }
-    else if (iType == EProtocolEngine)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted PROTOCOL ENGINE"));
-    }
-    else if (iType == ESocket)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted SOCKET"));
-    }
+    LOGSUBCMD((0, "PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted %s () In CmdId %d Status %d", GETNODESTR, aResponse.GetCmdId(), aResponse.GetCmdStatus()));
 
     if (aResponse.GetCmdStatus() != PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted Failure! %d", aResponse.GetCmdStatus()));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_DEBUG, (0, "PVMFDownloadManagerSubNodeContainer::NodeCommandCompleted Failure! %d", aResponse.GetCmdStatus()));
     }
 
     if (aResponse.GetCmdId() == iCmdId
@@ -2923,7 +3077,7 @@
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
     else
     {
-        Assert(false);//unexpected response.
+        OSCL_ASSERT(false);//unexpected response.
     }
 }
 
@@ -3282,10 +3436,13 @@
                 {
                     case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
                     {
-                        OSCL_wHeapString<OsclMemAllocator> userAgent;
-                        userAgent = aParameters[paramind].value.pWChar_value;
-                        (iProtocolEngineNode.ProtocolEngineExtension())->SetUserAgent(userAgent, false);
-
+                        if (IsDownloadExtensionHeaderValid(*aParameters))
+                        {
+                            //setting KVP string for download when mode applied for download or not applied at all.
+                            OSCL_wHeapString<OsclMemAllocator> userAgent;
+                            userAgent = aParameters[paramind].value.pWChar_value;
+                            (iProtocolEngineNode.ProtocolEngineExtension())->SetUserAgent(userAgent, true);
+                        }
                     }
                     break;
                     case BASEKEY_SESSION_CONTROLLER_HTTP_VERSION:
@@ -3338,8 +3495,12 @@
 
                     case BASEKEY_SESSION_CONTROLLER_NUM_REDIRECT_ATTEMPTS:
                     {
-                        uint32 numRedirects = aParameters[paramind].value.uint32_value;
-                        (iProtocolEngineNode.ProtocolEngineExtension())->SetNumRedirectTrials(numRedirects);
+                        if (IsDownloadExtensionHeaderValid(*aParameters))
+                        {
+                            //setting KVP string for download when mode applied for download or not applied at all.
+                            uint32 numRedirects = aParameters[paramind].value.uint32_value;
+                            (iProtocolEngineNode.ProtocolEngineExtension())->SetNumRedirectTrials(numRedirects);
+                        }
                     }
                     break;
 
@@ -3439,7 +3600,7 @@
     // get aPurgeOnRedirect
     aPurgeOnRedirect = false;
     OSCL_StackString<32> purgeOnRedirect(_STRLIT_CHAR("purge-on-redirect"));
-    if (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), purgeOnRedirect.get_cstr()) != NULL)
+    if (oscl_strstr(aParameter.key, purgeOnRedirect.get_cstr()) != NULL)
     {
         aPurgeOnRedirect = true;
     }
@@ -3453,11 +3614,11 @@
     OSCL_StackString<8> keyTag(_STRLIT_CHAR("key="));
 
     OSCL_StackString<8> valueTag(_STRLIT_CHAR("value="));
-    char *keyStart = oscl_strstr(OSCL_CONST_CAST(char*, extensionHeader), keyTag.get_cstr());
+    char *keyStart = OSCL_CONST_CAST(char*, oscl_strstr(extensionHeader, keyTag.get_cstr()));
     if (!keyStart) return false;
 
     keyStart += keyTag.get_size();
-    char *keyEnd = oscl_strstr(OSCL_CONST_CAST(char*, extensionHeader), valueTag.get_cstr());
+    char *keyEnd = OSCL_CONST_CAST(char*, oscl_strstr(extensionHeader, valueTag.get_cstr()));
     if (!keyEnd) return false;
     uint32 keyLen = getItemLen(keyStart, keyEnd);
     if (keyLen == 0) return false;
@@ -3468,13 +3629,13 @@
     valueStart += valueTag.get_size();
 
     OSCL_StackString<8> methodTag(_STRLIT_CHAR("method="));
-    char* valueEnd = oscl_strstr(valueStart, methodTag.get_cstr());
+    char* valueEnd = OSCL_CONST_CAST(char*, oscl_strstr(valueStart, methodTag.get_cstr()));
     if (!valueEnd) valueEnd = extensionHeader + aParameter.capacity;
     uint32 valueLen = getItemLen(valueStart, valueEnd);
     extensionHeaderValue = OSCL_HeapString<OsclMemAllocator> (valueStart, valueLen);
 
     // (3) check for optional method
-    char *methodStart = oscl_strstr(OSCL_CONST_CAST(char*, extensionHeader), methodTag.get_cstr());
+    const char *methodStart = oscl_strstr(extensionHeader, methodTag.get_cstr());
     if (!methodStart)
     {
         httpMethod = HTTP_GET;
@@ -3486,12 +3647,9 @@
     OSCL_StackString<8> methodHttpHead(_STRLIT_CHAR("HEAD"));
     OSCL_StackString<8> methodHttpPost(_STRLIT_CHAR("POST"));
 
-    char* methodGet = NULL;
-    char* methodHead = NULL;
-    char* methodPost = NULL;
-    methodGet = oscl_strstr(methodStart, methodHttpGet.get_cstr());
-    methodHead = oscl_strstr(methodStart, methodHttpHead.get_cstr());
-    methodPost = oscl_strstr(methodStart, methodHttpPost.get_cstr());
+    const char* methodGet = oscl_strstr(methodStart, methodHttpGet.get_cstr());
+    const char* methodHead = oscl_strstr(methodStart, methodHttpHead.get_cstr());
+    const char* methodPost = oscl_strstr(methodStart, methodHttpPost.get_cstr());
 
     httpMethod = HTTP_GET;
     if (methodPost != NULL) httpMethod = HTTP_POST;
@@ -3507,8 +3665,8 @@
     OSCL_StackString<32> downloadMode(_STRLIT_CHAR("mode=download"));
     OSCL_StackString<32> streamingMode(_STRLIT_CHAR("mode=streaming"));
 
-    bool isDownloadMode  = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), downloadMode.get_cstr())  != NULL);
-    bool isStreamingMode = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), streamingMode.get_cstr()) != NULL);
+    bool isDownloadMode  = (oscl_strstr(aParameter.key, downloadMode.get_cstr())  != NULL);
+    bool isStreamingMode = (oscl_strstr(aParameter.key, streamingMode.get_cstr()) != NULL);
 
     // streaming mode only would fail, download mode specified or not specified will be viewed as true
     if (isStreamingMode && !isDownloadMode) return false;
@@ -3571,9 +3729,9 @@
     OSCL_StackString<32> streamingMode(_STRLIT_CHAR("mode=streaming"));
     OSCL_StackString<32> dlaMode(_STRLIT_CHAR("mode=dla"));
 
-    bool isDownloadMode  = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), downloadMode.get_cstr())  != NULL);
-    bool isStreamingMode = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), streamingMode.get_cstr()) != NULL);
-    bool isDlaMode = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), dlaMode.get_cstr()) != NULL);
+    bool isDownloadMode  = (oscl_strstr(aParameter.key, downloadMode.get_cstr())  != NULL);
+    bool isStreamingMode = (oscl_strstr(aParameter.key, streamingMode.get_cstr()) != NULL);
+    bool isDlaMode = (oscl_strstr(aParameter.key, dlaMode.get_cstr()) != NULL);
 
 
     // streaming mode only would fail, download mode specified or not specified will be viewed as true
@@ -3582,10 +3740,12 @@
     // dla mode only would fail, download mode specified or not specified will be viewed as true
     if (isDlaMode && !isDownloadMode) return false;
 
+    return true;
+}
 
-    if (isDownloadMode) return true;
-
-    return false;
+void PVMFDownloadManagerNode::NotificationsInterfaceDestroyed()
+{
+    iClockNotificationsInf = NULL;
 }
 
 void PVMFDownloadManagerNode::ClockStateUpdated()
@@ -3595,7 +3755,7 @@
         // Don't let anyone start the clock while the source node is in underflow
         if (iPlayBackClock != NULL)
         {
-            if (iPlayBackClock->GetState() == OsclClock::RUNNING)
+            if (iPlayBackClock->GetState() == PVMFMediaClock::RUNNING)
             {
                 iPlayBackClock->Pause();
             }
diff --git a/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.h b/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.h
index 4695b1e..c88c4d8 100644
--- a/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.h
+++ b/nodes/pvdownloadmanagernode/src/pvmf_downloadmanager_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -80,9 +80,12 @@
 #include "pvmi_config_and_capability.h"
 #endif
 
+// only include pvmf_downloadmanager_config.h if CML2 is NOT being used
+#ifndef USE_CML2_CONFIG
 #ifndef PVMF_DOWNLOADMANAGER_CONFIG_H_INCLUDED
 #include "pvmf_downloadmanager_config.h"
 #endif
+#endif
 
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_PPB)
 #ifndef  PVMF_MEMORYBUFFERDATASTREAM_FACTORY_H_INCLUDED
@@ -218,7 +221,7 @@
         }
 
         // Constructor and parser for SetDataSourceRate
-        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, OsclTimebase* aTimebase, const OsclAny*aContext)
+        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny*aContext)
         {
             PVMFDownloadManagerNodeCommandBase::Construct(s, cmd, aContext);
             iParam1 = (OsclAny*)aRate;
@@ -227,10 +230,10 @@
             iParam4 = NULL;
             iParam5 = NULL;
         }
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
         {
             aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
+            aTimebase = (PVMFTimebase*)iParam2;
         }
 
         //need to overload the base Destroy routine to cleanup metadata key.
@@ -435,7 +438,6 @@
         CmdState iCancelCmdState;
         void CancelCommandDone(PVMFStatus, PVInterface*, OsclAny*);
 
-        void Assert(bool);
         bool CmdPending()
         {
             return iCmdState != EIdle || iCancelCmdState != EIdle;
@@ -628,7 +630,7 @@
             , public PVMFCPMPluginLicenseInterface
 #endif//PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE
             // For observing the playback clock states
-            , public OsclClockStateObserver
+            , public PVMFMediaClockStateObserver
 {
     public:
         PVMFDownloadManagerNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
@@ -674,8 +676,8 @@
 
         //From PVMFDataSourceInitializationExtensionInterface
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         //From PVMFTrackSelectionExtensionInterface
         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
@@ -701,7 +703,7 @@
                                               PVMFTimestamp& aSeekPointBeforeTargetNPT, PVMFTimestamp& aSeekPointAfterTargetNPT,
                                               OsclAny* aContext = NULL, bool aSeekToSyncPoint = true);
 
-        PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, OsclTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
+        PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, PVMFTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
 
         // From PVMFPortActivityHandler
         void HandlePortActivity(const PVMFPortActivity& aActivity)
@@ -748,8 +750,9 @@
                                                 PvmiKvp* aParameters,
                                                 int num_elements);
 
-        //from OsclClockStateObserver
+        //from PVMFMediaClockStateObserver
         void ClockStateUpdated();
+        void NotificationsInterfaceDestroyed();
 
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE)
         /* From PVMFCPMPluginLicenseInterface */
@@ -882,7 +885,6 @@
 
         PVMFNodeCapability iCapability;
         PVLogger* iLogger;
-        void Assert(bool);
         friend class PVMFDownloadManagerSubNodeContainerBase;
         friend class PVMFDownloadManagerSubNodeContainer;
         friend class PVMFDownloadManagerRecognizerContainer;
@@ -978,7 +980,11 @@
         //Count for Uuids
         uint32 iDNodeUuidCount;
         // playback clock which will be received form the engine.
-        OsclClock *iPlayBackClock;
+        PVMFMediaClock *iPlayBackClock;
+        PVMFMediaClockNotificationsInterface *iClockNotificationsInf;
+
+        // HTTP Content-Type header MIME string hint from the server
+        OSCL_HeapString<OsclMemAllocator> iContentTypeMIMEString;
 
 #if(PVMF_DOWNLOADMANAGER_SUPPORT_CPM_GETLICENSE)
         PVMFStatus DoGetLicense(PVMFDownloadManagerNodeCommand& aCmd,
diff --git a/nodes/pvdownloadmanagernode/src/pvmf_filebufferdatastream_factory.cpp b/nodes/pvdownloadmanagernode/src/pvmf_filebufferdatastream_factory.cpp
index db1150b..5a66042 100644
--- a/nodes/pvdownloadmanagernode/src/pvmf_filebufferdatastream_factory.cpp
+++ b/nodes/pvdownloadmanagernode/src/pvmf_filebufferdatastream_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp b/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp
index 9a1549e..1ed5c4d 100644
--- a/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp
+++ b/nodes/pvdownloadmanagernode/src/pvmf_memorybufferdatastream_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -491,7 +491,7 @@
 
     // for debugging only
     //LOGERROR((0, "PVMFMemoryBufferReadDataStreamImpl::Read session %d offset %d size %d firstTempByteOffset %d lastTempByteOffset %d",
-    //iSessionID, iFilePtrPos, aSize * aNumElements, firstTempByteOffset, lastTempByteOffset));
+    //	iSessionID, iFilePtrPos, aSize * aNumElements, firstTempByteOffset, lastTempByteOffset));
 
     uint32 bytesRead = 0;
     uint32 firstEntry = 0;
@@ -508,7 +508,7 @@
             // Find out if it is on route to the cache, if so, no need to send reposition request
             // But if the cache is full, we need to send reposition request
             if ((firstByteToRead < firstTempByteOffset) || ((firstByteToRead - lastTempByteOffset) > BYTES_TO_WAIT) ||
-                    ((firstByteToRead - lastTempByteOffset) <= BYTES_TO_WAIT) && ((lastTempByteOffset - firstTempByteOffset + 1) >= READ_BUFFER_SIZE))
+                    (((firstByteToRead - lastTempByteOffset) <= BYTES_TO_WAIT) && ((lastTempByteOffset - firstTempByteOffset + 1) >= READ_BUFFER_SIZE)))
             {
                 LOGDEBUG((0, "PVMFMemoryBufferReadDataStreamImpl::Read Reposition first %d last %d session %d offset %d",
                           firstTempByteOffset, lastTempByteOffset, iSessionID, firstByteToRead));
@@ -724,10 +724,10 @@
                 uint32 lastTempByteOffset = 0;
                 iTempCache->GetFileOffsets(firstTempByteOffset, lastTempByteOffset);
 
-                if ((skipTo >= firstTempByteOffset)
-                        && (lastTempByteOffset + PV_MBDS_FWD_SEEKING_NO_GET_REQUEST_THRESHOLD >= skipTo))
+                if ((skipTo >= firstTempByteOffset) &&
+                        (lastTempByteOffset + PV_MBDS_FWD_SEEKING_NO_GET_REQUEST_THRESHOLD >= skipTo))
                 {
-                    // Seeking forward, check to see if the data may be coming shortly before sending request
+                    // Seeking forward,, eed to see if the data may be coming shortly before sending request
                     // If the temp cache is full, send the request right away
                     uint32 capacity = 0;
                     iWriteDataStream->QueryWriteCapacity(0, capacity);
@@ -879,24 +879,24 @@
 
     // MakePersistent should not be called multiple times with different offsets
     uint32 firstPersistentOffset = 0;
-    uint32 lastPersistentOffset = 0;
-    bool bMadePersistent = iWriteDataStream->GetPermCachePersistence(firstPersistentOffset, lastPersistentOffset);
+    uint32 lastPeristentOffset = 0;
+    bool bMadePersistent = iWriteDataStream->GetPermCachePersistence(firstPersistentOffset, lastPeristentOffset);
 
     if (bMadePersistent)
     {
         // has already been called, check the offset + size
         // last byte in perm cache is one byte beyond moov atom
-        if ((0 == aSize && 0 == firstPersistentOffset && 0 == lastPersistentOffset) ||
-                (aOffset == (int32)firstPersistentOffset && (aOffset + aSize) == lastPersistentOffset))
+        if ((0 == aSize && 0 == firstPersistentOffset && 0 == lastPeristentOffset) ||
+                (aOffset == (int32)firstPersistentOffset && (aOffset + aSize) == lastPeristentOffset))
         {
-            // same parameters, it is ok
+            // same paramerters, it is ok
             LOGDEBUG((0, "PVMFMemoryBufferReadDataStreamImpl::MakePersistent has already been called with same offset and size"));
             return PVDS_SUCCESS;
         }
 
         // does not support calling this function again with different parameters
         LOGERROR((0, "PVMFMemoryBufferReadDataStreamImpl::MakePersistent has already been called with first offset %d last offset %d",
-                  firstPersistentOffset, lastPersistentOffset));
+                  firstPersistentOffset, lastPeristentOffset));
         return PVDS_NOT_SUPPORTED;
     }
 
@@ -1143,13 +1143,11 @@
     for (uint32 i = 0; i < PV_MB_MAX_NUMBER_OF_READ_CONNECTIONS; i++)
     {
         iReadNotifications[i].iReadStructValid = false;
-        iReadNotifications[i].iOutstanding = false;
 
         iReadFilePositions[i].iReadPositionStructValid = false;
     }
 
     iRepositionRequest.iOutstanding = false;
-    iRepositionRequest.iRepositionSessionID = -1;
     iWriteNotification.iOutstanding = false;
     iLogger = PVLogger::GetLoggerObject("PVMFMemoryBufferDataStream");
 
@@ -1852,21 +1850,65 @@
             (aSessionID > (PV_MB_MAX_NUMBER_OF_READ_CONNECTIONS + PV_MB_MAX_NUMBER_OF_WRITE_CONNECTIONS)))
     {
         status = PVDS_FAILURE;
+        return status;
     }
     else if (NULL == iRequestObserver)
     {
         // Protocol engine is not listening
         status = PVDS_FAILURE;
+        return status;
     }
-    else if ((aOffset >= iFilePtrPos) &&
-             (iFilePtrPos + PV_MBDS_FWD_SEEKING_NO_GET_REQUEST_THRESHOLD > aOffset) &&
-             ((writeCap != 0) && ((aOffset - iFilePtrPos) < writeCap)) &&
-             (iAVTOffsetDelta < READ_BUFFER_SIZE))
+    else if ((aOffset >= iFilePtrPos)
+             && ((writeCap != 0) && ((writeCap + iFilePtrPos) > aOffset)))
     {
-        // data is on route
+        // data is on route. Now check whether we should send new GET and flush the old data or just wait
         LOGDEBUG((0, "PVMFMemoryBufferWriteDataStreamImpl::Reposition data is en route, GET request not sent"));
+        // Check for read position pointers in temp cache
+        bool found = false;
+        uint32 smallest = 0xFFFFFFFF;
+        {
+            uint32 firstPersistentOffset = 0;
+            uint32 lastPersistentOffset = 0;
+            iPermCache->GetPermOffsets(firstPersistentOffset, lastPersistentOffset);
+            for (int32 i = 0; i < PV_MB_MAX_NUMBER_OF_READ_CONNECTIONS; i++)
+            {
+                if ((iReadFilePositions[i].iReadPositionStructValid == true) && (iReadFilePositions[i].iInTempCache == true))
+                {
+                    if ((0 == i) && (0 == firstPersistentOffset) && (0 == lastPersistentOffset) && (0 == iReadFilePositions[i].iReadFilePtr))
+                    {
+                        // nothing made persistent, ignore session 0 ptr at offset 0
+                        continue;
+                    }
+                    found = true;
+                    //LOGE("Ln %d smalltest %d iReadFilePositions[%d].iReadFilePtr %d ", __LINE__, smallest , i, iReadFilePositions[i].iReadFilePtr );
+                    if (iReadFilePositions[i].iReadFilePtr < smallest)
+                    {
+                        smallest = iReadFilePositions[i].iReadFilePtr;
+                    }
+                }
+            }
+        }
+        //LOGE("Ln %d found %d smalltest %d iFilePtrPos %d aOffset %d", __LINE__, found, smallest , iFilePtrPos, aOffset );
+        //LOGE("Ln %d tmpCache [%d %d] iFilePtrPos %d", __LINE__, firstTempByteOffset, lastTempByteOffset , iFilePtrPos);
+        if (found)
+        {
+            if (smallest < iFilePtrPos)
+            {
+                //LOGE("Ln %d Do nothing. found %d smalltest %d", __LINE__, found, smallest );
+                return status;
+            }
+
+            if ((smallest >= iFilePtrPos) &&
+                    (iFilePtrPos + PV_MBDS_FWD_SEEKING_NO_GET_REQUEST_THRESHOLD > smallest) &&
+                    ((writeCap != 0) && ((smallest - iFilePtrPos) < writeCap)) &&
+                    (iAVTOffsetDelta < READ_BUFFER_SIZE))
+            {
+                //LOGE("Ln %d Do nothing. found %d smalltest %d", __LINE__, found, smallest );
+                return status;
+            }
+        }
     }
-    else
+
     {
         // Only support one outstanding reposition request, do not send another
         // If this is requesting the same offset as the outstanding request, return success, otherwise failure
@@ -2284,7 +2326,7 @@
             bool bSend = false;
             PVMFStatus status = PVMFFailure;
 
-            if ((currFilePosition - iReadNotifications[i].iFilePosition) >=
+            if ((currFilePosition - iReadNotifications[i].iFilePosition) >
                     iReadNotifications[i].iReadCapacity)
             {
                 bSend = true;
@@ -2654,7 +2696,6 @@
     return iMadePersistent;
 }
 
-
 //////////////////////////////////////////////////////////////////////
 // PVMFMemoryBufferDataStream
 //////////////////////////////////////////////////////////////////////
@@ -2858,7 +2899,9 @@
 
         found = true;
 
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
         uint32 offset = entry->fileOffset;
+#endif
         uint32 size = entry->fragSize;
 
         aFrag = entry->frag;
@@ -2884,8 +2927,10 @@
             iTotalBytes = 0;
         }
 
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
         LOGDEBUG((0, "PVMFMemoryBufferDataStreamTempCache::RemoveFirstEntry %x offset %d size %d first %d last %d total %d",
                   entry, offset, size, iFirstByteFileOffset, iLastByteFileOffset, iTotalBytes));
+#endif
 
     }
 
@@ -3418,8 +3463,9 @@
         MBDSPermCacheEntry* entry = iEntries.front();
 
         found = true;
-
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
         uint32 offset = entry->firstFileOffset;
+#endif
         uint32 size = entry->fillSize;
 
         aFragPtr = entry->bufPtr;
@@ -3444,8 +3490,10 @@
             iLastByteFileOffset = 0;
             iTotalBytes = 0;
         }
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
         LOGDEBUG((0, "PVMFMemoryBufferDataStreamTempCache::RemoveFirstEntry %x offset %d size %d first %d last %d total %d",
                   entry, offset, size, iFirstByteFileOffset, iLastByteFileOffset, iTotalBytes));
+#endif
 
     }
 
diff --git a/nodes/pvdummyinputnode/build/make/local.mk b/nodes/pvdummyinputnode/build/make/local.mk
new file mode 100644
index 0000000..bf2cfc0
--- /dev/null
+++ b/nodes/pvdummyinputnode/build/make/local.mk
@@ -0,0 +1,34 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvdummyinputnode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_dummy_fileinput_node.cpp \
+	pvmf_fileinput_port.cpp
+
+
+
+HDRS := pvmf_fileinput_node_extension.h \
+        pvmf_dummy_fileinput_node_factory.h \
+	pvmf_dummy_fileinput_node.h \
+	pvmf_fileinput_node_internal.h \
+	pvmf_fileinput_port.h \
+	pvmf_fileinput_settings.h
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvdummyinputnode/include/pvmf_dummy_fileinput_node.h b/nodes/pvdummyinputnode/include/pvmf_dummy_fileinput_node.h
new file mode 100644
index 0000000..4b6a77e
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_dummy_fileinput_node.h
@@ -0,0 +1,244 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PVMF_DUMMY_FILEINPUT_NODE_H_INCLUDED
+#define PVMF_DUMMY_FILEINPUT_NODE_H_INCLUDED
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef PVMF_FILEINPUT_PORT_H_INCLUDED
+#include "pvmf_fileinput_port.h"
+#endif
+#ifndef PVMF_FILEINPUT_NODE_EXTENSION_H_INCLUDED
+#include "pvmf_fileinput_node_extension.h"
+#endif
+#ifndef PVMF_FILEINPUT_NODE_EVENTS_H_INCLUDED
+#include "pvmf_fileinput_node_events.h"
+#endif
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef PVMF_FILEINPUT_NODE_INTERNAL_H_INCLUDED
+#include "pvmf_fileinput_node_internal.h"
+#endif
+#ifndef PVMF_FILEINPUT_SETTINGS_H_INCLUDED
+#include "pvmf_fileinput_settings.h"
+#endif
+
+// SEE DESCRIPTION IN pvmf_fileinput_node.cpp
+//#define FRAGMENTATION_TEST
+
+///////////////////////////////////////////////
+// Port tags
+///////////////////////////////////////////////
+
+/** Enumerated list of port tags supported by the node,
+** for the port requests.
+*/
+typedef enum
+{
+    // chesterc: Convention for now is for input/sink port to have tag value 0
+    // and output/src port to have tag value 1.  Both author and player engines
+    // relies on this assumption, and should be removed later on when capabilities
+    // exchange is implemented on the node.  The engine would then query the node
+    // for the list of supported tags for a given mime type.
+    PVMF_DUMMY_FILEINPUT_NODE_PORT_TYPE_SOURCE = 1
+} PVMFDummyFileInputNodePortType;
+
+///////////////////////////////////////////////
+// The PVMFDummyFileInputNode Node Implementation Class
+///////////////////////////////////////////////
+
+class PVLogger;
+
+class PVMFDummyFileInputNode : public PVMFNodeInterface,
+            public OsclTimerObject,
+            public PVMFFileInputNodeExtensionInterface
+            , public OsclMemPoolFixedChunkAllocatorObserver
+{
+    public:
+        OSCL_IMPORT_REF PVMFDummyFileInputNode(PVMFFileInputSettings* aSettings, int32 aPriority);
+        OSCL_IMPORT_REF ~PVMFDummyFileInputNode();
+
+        //from PVMFNodeInterface
+        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, PVMFFileInputNodeAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId
+                , int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+
+        //from PVMFPortActivityHandler
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        //from PVMFDummyFileInputNodeCustomInterface1
+        OSCL_IMPORT_REF PVMFStatus GetStats(PVMFPortInterface* aPort, int32& aNumMsgGenerated, int32& aNumMsgConsumed);
+
+        // Virtual functions of PVMFFileInputNodeExtensionInterface
+        OSCL_IMPORT_REF void addRef();
+        OSCL_IMPORT_REF void removeRef();
+        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        OSCL_IMPORT_REF bool GetBitstreamConfig(OsclRefCounterMemFrag& aConfig);
+
+
+    private: // private member functions
+
+        //from OsclActiveObject
+        void Run();
+        void DoCancel();
+
+        //Command processing
+        PVMFCommandId QueueCommandL(PVMFFileInputNodeCommand&);
+        bool ProcessCommand(PVMFFileInputNodeCommand&);
+        void CommandComplete(PVMFFileInputNodeCmdQ&, PVMFFileInputNodeCommand&, PVMFStatus, OsclAny* aData = NULL);
+        bool FlushPending();
+
+        //Command handlers.
+        void DoReset(PVMFFileInputNodeCommand&);
+        void DoQueryUuid(PVMFFileInputNodeCommand&);
+        void DoQueryInterface(PVMFFileInputNodeCommand&);
+        void DoRequestPort(PVMFFileInputNodeCommand&);
+        void DoReleasePort(PVMFFileInputNodeCommand&);
+        void DoInit(PVMFFileInputNodeCommand&);
+        void DoPrepare(PVMFFileInputNodeCommand&);
+        void DoStart(PVMFFileInputNodeCommand&);
+        void DoStop(PVMFFileInputNodeCommand&);
+        void DoFlush(PVMFFileInputNodeCommand&);
+        void DoPause(PVMFFileInputNodeCommand&);
+        void DoCancelAllCommands(PVMFFileInputNodeCommand&);
+        void DoCancelCommand(PVMFFileInputNodeCommand&);
+
+        // Event reporting
+        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
+        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
+        void SetState(TPVMFNodeInterfaceState);
+
+        // Helper functions
+
+        int32 LocateH263FrameHeader(uint8* video_buffer, int32 vop_size);
+
+        int32 GetIF2FrameSize(uint8 aFrameType);
+
+        void  ConstructInputSettings(PVMFFileInputSettings* aSettings);
+        void  CloseInputFile();
+
+        // Initialization function
+        PVMFStatus Initialize();
+
+        // Create and send out media messages
+        PVMFStatus GenerateMediaMessage(PVMFSharedMediaMsgPtr& aMediaMsg);
+#ifdef FRAGMENTATION_TEST
+        // Create and send out media messages
+        PVMFStatus GenerateMediaMessage2(PVMFSharedMediaMsgPtr& aMediaMsg, PVMFSharedMediaMsgPtr& aMediaMsg2);
+#endif
+
+        PVMFStatus SendNewMediaMessage();
+
+    private: // private member variables
+
+        // Vector of ports contained in this node
+        PVMFPortVector<PVMFFileDummyInputPort, PVMFFileInputNodeAllocator> iPortVector;
+        friend class PVMFFileDummyInputPort;
+
+        // commands
+        PVMFFileInputNodeCmdQ iInputCommands;
+        PVMFFileInputNodeCmdQ iCurrentCommand;
+
+        // Allocator
+        OsclMemAllocator iCmdAlloc;
+        OsclMemAllocDestructDealloc<uint8> iAlloc;
+
+        // Allocator for simple media data buffer
+        OsclMemPoolFixedChunkAllocator* iMediaBufferMemPool;
+        PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc;
+        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
+
+        uint8* iAudioData;
+        uint8* iVideoData;
+        PVMFNodeCapability iCapability;
+        PVLogger *iLogger;
+        PVMFFileInputSettings iSettings;
+
+        // Format specific info
+        OsclRefCounterMemFrag iFormatSpecificInfo;
+        int32 iFormatSpecificInfoSize;
+        bool iSetFormatSpecificInfo;
+
+        int32 iFileHeaderSize;
+
+        // Input file
+        Oscl_FileServer iFs;
+        bool iFsOpen;
+        Oscl_File iInputFile;
+        bool iFileOpen;
+
+        // Counter and size info for file read
+        Oscl_Vector<uint32, OsclMemAllocator> iFrameSizeVector;
+        Oscl_Vector<uint32, OsclMemAllocator> iMilliSecFrameDurationVector;
+        int32 iDataEventCounter;
+        int32 iTotalNumFrames;
+
+        // Timing
+        int32 iMicroSecondsPerTick;
+        int32 iMilliSecondsPerDataEvent;
+        int32 iMicroSecondsPerDataEvent;
+        int32 iTSForRunIfInactive;
+        PVMFTimestamp iTimeStamp;
+
+        // Reference counter for extension
+        uint32 iExtensionRefCount;
+
+
+        void IncTimestamp();
+
+        //from OsclMemPoolFixedChunkAllocatorObserver
+        void freechunkavailable(OsclAny* aContextData);
+        bool iWaitingOnFreeChunk;
+        bool iEndOfFileReached;
+};
+
+#endif
+
+
diff --git a/nodes/pvdummyinputnode/include/pvmf_dummy_fileinput_node_factory.h b/nodes/pvdummyinputnode/include/pvmf_dummy_fileinput_node_factory.h
new file mode 100644
index 0000000..a32d05d
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_dummy_fileinput_node_factory.h
@@ -0,0 +1,61 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_DUMMY_FILEINPUT_NODE_FACTORY_H_INCLUDED
+#define PVMF_DUMMY_FILEINPUT_NODE_FACTORY_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PVMF_FILEINPUT_SETTINGS_H_INCLUDED
+#include "pvmf_fileinput_settings.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+// Forward declarations
+class PVMFNodeInterface;
+
+/**
+ * Factory class for PVMFDummyFileInputNode
+ */
+class PVMFDummyFileInputNodeFactory
+{
+    public:
+        /**
+         * Creates an instance of a file input node. If the creation fails, this function will leave.
+         *
+         * @param aPriority The active object priority for the node. Default is standard priority if not specified
+         * @param aSettings Settings for the file input node
+         * @returns A pointer to an author or leaves if instantiation fails
+         **/
+        OSCL_IMPORT_REF static PVMFNodeInterface* CreateDummyFileInputNode(PVMFFileInputSettings* aSettings,
+                int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        /**
+         * This function allows the application to delete an instance of file input node
+         * and reclaim all allocated resources.  An instance can be deleted only in
+         * the idle state. An attempt to delete in any other state will fail and return false.
+         *
+         * @param aNode The file input node to be deleted.
+         * @returns A status code indicating success or failure.
+         **/
+        OSCL_IMPORT_REF static bool DeleteDummyFileInputNode(PVMFNodeInterface*& aNode);
+};
+
+#endif // PVMF_DUMMY_FILEINPUT_NODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvdummyinputnode/include/pvmf_fileinput_node_events.h b/nodes/pvdummyinputnode/include/pvmf_fileinput_node_events.h
new file mode 100644
index 0000000..745f8ea
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_fileinput_node_events.h
@@ -0,0 +1,50 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_FILEINPUT_NODE_EVENTS_H_INCLUDED
+#define PVMF_FILEINPUT_NODE_EVENTS_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+///////////////////////////////////////////////
+// Error Events
+///////////////////////////////////////////////
+
+enum PVMFFileInputNodeErrorEvent
+{
+    PVMF_FILEINPUT_NODE_ERROR_PORT_PROCESSING_ERROR = PVMF_NODE_ERROR_EVENT_LAST
+    , PVMF_FILEINPUT_NODE_ERROR_DATA_GENERATING_ERROR
+};
+
+///////////////////////////////////////////////
+// Information Events
+///////////////////////////////////////////////
+
+// Enumerated list of informational event from PVMFFileInputNode
+enum PVMFFileInputNodeInfoEvent
+{
+    PVMFFIN_EndOfFile = PVMF_NODE_INFO_EVENT_LAST
+};
+
+#endif
+
+
diff --git a/nodes/pvdummyinputnode/include/pvmf_fileinput_node_extension.h b/nodes/pvdummyinputnode/include/pvmf_fileinput_node_extension.h
new file mode 100644
index 0000000..9a46d07
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_fileinput_node_extension.h
@@ -0,0 +1,67 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_fileinputnode_extension.h
+ * @brief Extension interface for PVMFFileInputNode
+ */
+
+#ifndef PVMF_FILEINPUT_NODE_EXTENSION_H_INCLUDED
+#define PVMF_FILEINPUT_NODE_EXTENSION_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PV_INTERFACE_H
+#include "pv_interface.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+
+// The PVUuid cannot by a const or it will create uninitialized data
+//
+#define KPVMFFileInputNodeExtensionUuid PVUuid(0xca27cb64,0x83ed,0x40d6,0x96,0xa3,0xed,0x1d,0x8b,0x60,0x11,0x38)
+
+// Forward declaration
+class OsclRefCounterMemFrag;
+
+/**
+ * PVMFFileInputNodeExtensionInterface allows a client to do exercise extened functions
+ * of a PVMFFileInputNode
+ */
+class PVMFFileInputNodeExtensionInterface : public PVInterface
+{
+    public:
+        virtual void addRef() = 0;
+        virtual void removeRef() = 0;
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+
+        /**
+         * Retrieves bitstream configuration information specific to the file type.
+         * This method is not valid for all files types. For M4V files, this function
+         * would copy the VOL header to the config memory fragment provided. For
+         * other file types, this method would return false, and aConfig is not
+         * modified.
+         *
+         * @param aConfig Memory fragment to hold the config information.
+         * @return true if config info is provided, else false.
+         */
+        virtual bool GetBitstreamConfig(OsclRefCounterMemFrag& aConfig) = 0;
+};
+
+#endif // PVMF_FILEINPUT_NODE_EXTENSION_H_INCLUDED
diff --git a/nodes/pvdummyinputnode/include/pvmf_fileinput_node_internal.h b/nodes/pvdummyinputnode/include/pvmf_fileinput_node_internal.h
new file mode 100644
index 0000000..169ee04
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_fileinput_node_internal.h
@@ -0,0 +1,80 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PVMF_FILEINPUT_NODE_INTERNAL_H_INCLUDED
+#define PVMF_FILEINPUT_NODE_INTERNAL_H_INCLUDED
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+
+//memory allocator type for this node.
+typedef OsclMemAllocator PVMFFileInputNodeAllocator;
+
+
+///////////////////////////////////////////////////////
+// For Command implementation
+///////////////////////////////////////////////////////
+
+//Default vector reserve size
+#define PVMF_FILEINPUT_NODE_COMMAND_VECTOR_RESERVE 10
+
+//Starting value for command IDs
+#define PVMF_FILEINPUT_NODE_COMMAND_ID_START 6000
+
+//Mimetypes for the custom interface
+#define PVMF_FILEINPUT_NODE_EXTENSION_INTERFACE_MIMETYPE "pvxxx/FileInputNode/ExtensionInterface"
+#define PVMF_FILEINPUT_NODE_MIMETYPE "pvxxx/FileInputNode"
+#define PVMF_BASEMIMETYPE "pvxxx"
+
+//Node command type.
+//typedef PVMFGenericNodeCommand<PVMFFileInputNodeAllocator> PVMFFileInputNodeCommandBase;
+#define PVMFFileInputNodeCommandBase PVMFGenericNodeCommand<PVMFFileInputNodeAllocator>  // to remove typedef warning on symbian
+class PVMFFileInputNodeCommand: public PVMFFileInputNodeCommandBase
+{
+    public:
+        //constructor for Custom2 command
+        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
+        {
+            PVMFFileInputNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)arg1;
+            iParam2 = (OsclAny*)arg2;
+            iParam3 = (OsclAny*) & arg3;
+        }
+        void Parse(int32&arg1, int32&arg2, int32*&arg3)
+        {
+            arg1 = (int32)iParam1;
+            arg2 = (int32)iParam2;
+            arg3 = (int32*)iParam3;
+        }
+};
+
+
+//Command queue type
+typedef PVMFNodeCommandQueue<PVMFFileInputNodeCommand, PVMFFileInputNodeAllocator> PVMFFileInputNodeCmdQ;
+
+#endif // PVMF_FILEINPUT_NODE_INTERNAL_H_INCLUDED
+
+
diff --git a/nodes/pvdummyinputnode/include/pvmf_fileinput_port.h b/nodes/pvdummyinputnode/include/pvmf_fileinput_port.h
new file mode 100644
index 0000000..d5a70d4
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_fileinput_port.h
@@ -0,0 +1,165 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_fileinput_port.h
+ */
+
+#ifndef PVMF_FILEINPUT_PORT_H_INCLUDED
+#define PVMF_FILEINPUT_PORT_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
+
+//Default vector reserve size
+#define PVMF_FILEINPUT_NODE_PORT_VECTOR_RESERVE 10
+
+// Capability mime strings
+#define PVMF_FILEINPUT_PORT_INPUT_FORMATS OUTPUT_FORMATS_CUR_QUERY
+#define PVMF_FILEINPUT_PORT_INPUT_FORMATS_VALTYPE OUTPUT_FORMATS_VALTYPE
+#define INPORT_CAPACITY 0
+#define INPORT_RESERVE 0
+#define INPORT_THRESOLD 0
+#define OUTPORT_CAPACITY 10
+#define OUTPORT_RESERVE 0
+#define OUTPORT_THRESOLD 70
+/**
+ * An example of a PVMF port implementation.
+ *
+ * Input (sink) ports have a simple flow control scheme.
+ * Ports report "busy" when their queue is full, then when the
+ * queue goes to half-empty they issue a "get data" to the connected
+ * port.  The media message in the "get data" is empty and is
+ * meant to be discarded.
+ * Output (source) ports assume the connected port uses the
+ * same flow-control scheme.
+ */
+class PVMFFileDummyInputPort : public PvmfPortBaseImpl,
+            public PvmiCapabilityAndConfig
+{
+    public:
+        /**
+         * Default constructor. Default settings will be used for the data queues.
+         * @param aId ID assigned to this port
+         * @param aTag Port tag
+         * @param aNode Container node
+         */
+        PVMFFileDummyInputPort(int32 aTag
+                               , PVMFNodeInterface* aNode);
+
+        /**
+         * Constructor that allows the node to configure the data queues of this port.
+         * @param aTag Port tag
+         * @param aNode Container node
+         * @param aSize Data queue capacity. The data queue size will not grow beyond this capacity.
+         * @param aReserve Size of data queue for which memory is reserved. This must be
+         * less than or equal to the capacity. If this is less than capacity, memory will be
+         * allocated when the queue grows beyond the reserve size, but will stop growing at
+         * capacity.
+         * @param aThreshold Ready-to-receive threshold, in terms of percentage of the data queue capacity.
+         * This value should be between 0 - 100.
+         */
+        PVMFFileDummyInputPort(int32 aTag
+                               , PVMFNodeInterface* aNode
+                               , uint32 aInCapacity
+                               , uint32 aInReserve
+                               , uint32 aInThreshold
+                               , uint32 aOutCapacity
+                               , uint32 aOutReserve
+                               , uint32 aOutThreshold);
+
+        /** Destructor */
+        ~PVMFFileDummyInputPort();
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        // Implement virtuals from PVMFPortBaseImpl
+        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+                aPtr = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
+            else
+                aPtr = NULL;
+        }
+        bool IsFormatSupported(PVMFFormatType aFmt);
+        void FormatUpdated();
+
+    private:
+        void Construct();
+        /**
+         * Allocate a specified number of key-value pairs and set the keys
+         *
+         * @param aKvp Output parameter to hold the allocated key-value pairs
+         * @param aKey Key for the allocated key-value pairs
+         * @param aNumParams Number of key-value pairs to be allocated
+         * @return Completion status
+         */
+        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
+
+        /**
+         * Verify one key-value pair parameter against capability of the port and
+         * if the aSetParam flag is set, set the value of the parameter corresponding to
+         * the key.
+         *
+         * @param aKvp Key-value pair parameter to be verified
+         * @param aSetParam If true, set the value of parameter corresponding to the key.
+         * @return PVMFSuccess if parameter is supported, else PVMFFailure
+         */
+        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
+
+        bool pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType, PvmiKvp*& aKvp);
+        bool pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort, const char* aFormatValType);
+
+        uint32 iNumFramesGenerated; //number of source frames generated.
+        PVMFFormatType iFormat;
+        OsclMemAllocator iAlloc;
+        PVLogger *iLogger;
+        uint32 iTrackConfigSizeFI;
+        uint8* iTrackConfigFI;
+        friend class PVMFDummyFileInputNode;
+};
+
+#endif // PVMF_FILEINPUT_PORT_H_INCLUDED
+
+
+
diff --git a/nodes/pvdummyinputnode/include/pvmf_fileinput_settings.h b/nodes/pvdummyinputnode/include/pvmf_fileinput_settings.h
new file mode 100644
index 0000000..e33e012
--- /dev/null
+++ b/nodes/pvdummyinputnode/include/pvmf_fileinput_settings.h
@@ -0,0 +1,74 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PVMF_FILEINPUT_SETTINGS_H_INCLUDED
+#define PVMF_FILEINPUT_SETTINGS_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+/**
+ * Structure containing configuration info for this node
+ */
+class PVMFFileInputSettings
+{
+    public:
+        PVMFFileInputSettings()
+        {
+            iMediaFormat = PVMF_MIME_FORMAT_UNKNOWN;
+            iLoopInputFile = true;
+            iSamplingFrequency = 8000;
+            iNumChannels = 1;
+            iNum20msFramesPerChunk = 1;
+            iTimescale = 1000;
+            iFrameHeight = 144;
+            iFrameWidth = 176;
+            iFrameRateSimulation = false;
+            iFrameRate = 15;
+            iFirstFrameTimestamp = 0;
+            iBitrate = 0;
+        }
+
+        // General settings
+        PVMFFormatType iMediaFormat;
+        bool iLoopInputFile;
+        OSCL_wHeapString<OsclMemAllocator> iFileName;
+        // Settings for audio files
+        uint32 iSamplingFrequency;
+        uint32 iNumChannels;
+        uint32 iNum20msFramesPerChunk;
+        // Settings for video files
+        uint32 iTimescale;
+        uint32 iFrameHeight;
+        uint32 iFrameWidth;
+        bool iFrameRateSimulation;
+        OsclFloat iFrameRate;
+        uint32 iFirstFrameTimestamp;
+        uint32 iBitrate;
+};
+
+#endif
+
+
diff --git a/nodes/pvdummyinputnode/src/pvmf_dummy_fileinput_node.cpp b/nodes/pvdummyinputnode/src/pvmf_dummy_fileinput_node.cpp
new file mode 100644
index 0000000..9152cf1
--- /dev/null
+++ b/nodes/pvdummyinputnode/src/pvmf_dummy_fileinput_node.cpp
@@ -0,0 +1,1676 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_DUMMY_FILEINPUT_NODE_H_INCLUDED
+#include "pvmf_dummy_fileinput_node.h"
+#endif
+#ifndef PVMF_FILEINPUT_NODE_INTERNAL_H_INCLUDED
+#include "pvmf_fileinput_node_internal.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMF_COMMON_AUDIO_DECNODE_H_INCLUDE
+#include "pvmf_common_audio_decnode.h"
+#endif
+#ifndef PVMF_VIDEO_H_INCLUDED
+#include "pvmf_video.h"
+#endif
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
+#ifndef PVMF_VIDEO_H_INCLUDED
+#include "pvmf_video.h"
+#endif
+#ifndef PVMF_DUMMY_FILEINPUT_NODE_FACTORY_H_INCLUDED
+#include "pvmf_dummy_fileinput_node_factory.h"
+#endif
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+
+// also defined in the pvmf_fileinput_node.h:
+// This test splits each frame into two pieces and sends them in 2 separate messages.
+// the first message has no marker bit set, the 2nd message has marker bit set
+//#define FRAGMENTATION_TEST
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+#define GetUnalignedDword( pb, dw ) \
+            (dw) = ((uint32) *(pb + 3) << 24) + \
+                   ((uint32) *(pb + 2) << 16) + \
+                   ((uint16) *(pb + 1) << 8) + *pb;
+
+#define GetUnalignedDwordEx( pb, dw )   GetUnalignedDword( pb, dw ); (pb) += sizeof(uint32);
+#define LoadDWORD( dw, p )  GetUnalignedDwordEx( p, dw )
+
+/**
+//Macros for calling PVLogger
+*/
+#define LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFO(m) LOGINFOMED(m)
+
+
+#define PVFILEIN_MEDIADATA_POOLNUM 16
+#define PVFILEIN_MEDIADATA_CHUNKSIZE 128
+
+//#define SEND_CONFIGINFO_SEPARATELY
+const uint32 AMR_FRAME_DELAY = 20; // 20ms
+
+
+/** Factory class */
+OSCL_EXPORT_REF PVMFNodeInterface* PVMFDummyFileInputNodeFactory::CreateDummyFileInputNode(PVMFFileInputSettings* aSettings,
+        int32 aPriority)
+{
+    PVMFDummyFileInputNode* node = NULL;
+    int32 err = 0;
+    OSCL_TRY(err, node = OSCL_NEW(PVMFDummyFileInputNode, (aSettings, aPriority)););
+    OSCL_FIRST_CATCH_ANY(err, return NULL;);
+    return node;
+}
+
+OSCL_EXPORT_REF bool PVMFDummyFileInputNodeFactory::DeleteDummyFileInputNode(PVMFNodeInterface*& aNode)
+{
+    if (!aNode)
+        return false;
+    PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)aNode;
+    OSCL_DELETE(node);
+    aNode = NULL;
+    return true;
+}
+
+/**
+//////////////////////////////////////////////////
+// Node Constructor & Destructor
+//////////////////////////////////////////////////
+*/
+
+OSCL_EXPORT_REF PVMFDummyFileInputNode::PVMFDummyFileInputNode(PVMFFileInputSettings* aSettings, int32 aPriority)
+        : OsclTimerObject(aPriority, "PVMFDummyFileInputNode")
+        , iMediaBufferMemPool(NULL)
+        , iMediaDataAlloc(NULL)
+        , iMediaDataMemPool(PVFILEIN_MEDIADATA_POOLNUM, PVFILEIN_MEDIADATA_CHUNKSIZE)
+        , iAudioData(NULL)
+        , iVideoData(NULL)
+        , iLogger(NULL)
+        , iFormatSpecificInfoSize(0)
+        , iSetFormatSpecificInfo(false)
+        , iFileHeaderSize(0)
+        , iFsOpen(false)
+        , iFileOpen(false)
+        , iDataEventCounter(0)
+        , iTotalNumFrames(0)
+        , iMilliSecondsPerDataEvent(0)
+        , iMicroSecondsPerDataEvent(0)
+        , iTSForRunIfInactive(0)
+        , iTimeStamp(0)
+        , iExtensionRefCount(0)
+        , iWaitingOnFreeChunk(false)
+        , iEndOfFileReached(false)
+{
+    int32 err;
+    OSCL_TRY(err,
+
+             //Create the input command queue.  Use a reserve to avoid lots of
+             //dynamic memory allocation.
+             iInputCommands.Construct(PVMF_FILEINPUT_NODE_COMMAND_ID_START, PVMF_FILEINPUT_NODE_COMMAND_VECTOR_RESERVE);
+
+             //Create the "current command" queue.  It will only contain one
+             //command at a time, so use a reserve of 1.
+             iCurrentCommand.Construct(0, 1);
+
+             //Create the port vector.
+             iPortVector.Construct(PVMF_FILEINPUT_NODE_PORT_VECTOR_RESERVE);
+
+             //Set the node capability data.
+             //This node can support an unlimited number of ports.
+             iCapability.iCanSupportMultipleInputPorts = true;
+             iCapability.iCanSupportMultipleOutputPorts = true;
+             iCapability.iHasMaxNumberOfPorts = false;
+             iCapability.iMaxNumberOfPorts = 0;//no maximum
+             // chesterc: The node only supports the format of the input file, not
+             // all formats that the node could parse.
+             iCapability.iOutputFormatCapability.push_back(aSettings->iMediaFormat);
+
+             // construct iSettings
+             ConstructInputSettings(aSettings);
+            );
+
+    if (err != OsclErrNone)
+    {
+        //if a leave happened, cleanup and re-throw the error
+        iInputCommands.clear();
+        iCurrentCommand.clear();
+        iPortVector.clear();
+        iCapability.iInputFormatCapability.clear();
+        iCapability.iOutputFormatCapability.clear();
+        OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
+        OSCL_CLEANUP_BASE_CLASS(OsclTimerObject);
+        OSCL_LEAVE(err);
+    }
+}
+
+OSCL_EXPORT_REF PVMFDummyFileInputNode::~PVMFDummyFileInputNode()
+{
+    //thread logoff
+    if (IsAdded())
+        RemoveFromScheduler();
+
+    //Cleanup allocated interfaces
+
+    //Cleanup allocated ports
+    while (!iPortVector.empty())
+        iPortVector.Erase(&iPortVector.front());
+
+    //Cleanup commands
+    //The command queues are self-deleting, but we want to
+    //notify the observer of unprocessed commands.
+    while (!iCurrentCommand.empty())
+    {
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
+    }
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+    }
+
+    CloseInputFile();
+    iAlloc.deallocate((OsclAny*)iAudioData);
+    iAlloc.deallocate((OsclAny*)iVideoData);
+
+    if (iMediaBufferMemPool)
+    {
+        OSCL_DELETE(iMediaBufferMemPool);
+        iMediaBufferMemPool = NULL;
+    }
+
+    if (iMediaDataAlloc)
+    {
+        OSCL_DELETE(iMediaDataAlloc);
+        iMediaDataAlloc = NULL;
+    }
+}
+
+/**
+//////////////////////////////////////////////////
+// Public Node API implementation
+//////////////////////////////////////////////////
+*/
+
+/**
+//Do thread-specific node creation and go to "Idle" state.
+*/
+OSCL_EXPORT_REF PVMFStatus PVMFDummyFileInputNode::ThreadLogon()
+{
+    LOGINFO((0, "FileInputNode:ThreadLogon"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+            if (!IsAdded())
+                AddToScheduler();
+            iLogger = PVLogger::GetLoggerObject("PVMFDummyFileInputNode");
+            SetState(EPVMFNodeIdle);
+            return PVMFSuccess;
+            break;
+        default:
+            return PVMFErrInvalidState;
+            break;
+    }
+}
+
+/**
+//Do thread-specific node cleanup and go to "Created" state.
+*/
+OSCL_EXPORT_REF PVMFStatus PVMFDummyFileInputNode::ThreadLogoff()
+{
+    LOGINFO((0, "FileInputNode:ThreadLogoff"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            if (IsAdded())
+                RemoveFromScheduler();
+            iLogger = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+            break;
+
+        default:
+            return PVMFErrInvalidState;
+            break;
+    }
+}
+
+/**
+//retrieve node capabilities.
+*/
+OSCL_EXPORT_REF PVMFStatus PVMFDummyFileInputNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    LOGINFO((0, "FileInputNode:GetCapability"));
+    aNodeCapability = iCapability;
+    return PVMFSuccess;
+}
+
+/**
+//retrive a port iterator.
+*/
+OSCL_EXPORT_REF PVMFPortIter* PVMFDummyFileInputNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    LOGINFO((0, "FileInputNode:GetPorts"));
+    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
+    iPortVector.Reset();
+    return &iPortVector;
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:QueryUUID"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:QueryInterface"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aPortConfig);
+    LOGINFO((0, "FileInputNode:RequestPort"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:ReleasePort"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Init"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Prepare"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Start"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Stop"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Flush"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Pause"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:Reset"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:CancelAllCommands"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileInputNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    LOGINFO((0, "FileInputNode:CancelCommand"));
+    PVMFFileInputNodeCommand cmd;
+    cmd.PVMFFileInputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileInputNode::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileInputNode::removeRef()
+{
+    --iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFDummyFileInputNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == KPVMFFileInputNodeExtensionUuid)
+    {
+        PVMFFileInputNodeExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFFileInputNodeExtensionInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+        return true;
+    }
+
+    return false;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFDummyFileInputNode::GetBitstreamConfig(OsclRefCounterMemFrag& aConfig)
+{
+    if (!iFormatSpecificInfo.getMemFragPtr())
+        return false;
+
+    aConfig = iFormatSpecificInfo;
+    return true;
+}
+
+
+/**
+//This routine is called by various command APIs to queue an
+//asynchronous command for processing by the command handler AO.
+//This function may leave if the command can't be queued due to
+//memory allocation failure.
+*/
+PVMFCommandId PVMFDummyFileInputNode::QueueCommandL(PVMFFileInputNodeCommand& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iInputCommands.AddL(aCmd);
+
+    //wakeup the AO
+    RunIfNotReady();
+
+    return id;
+}
+
+/**
+/////////////////////////////////////////////////////
+// Asynchronous Command processing routines.
+// These routines are all called under the AO.
+/////////////////////////////////////////////////////
+*/
+
+/**
+//Called by the command handler AO to process a command from
+//the input queue.
+//Return true if a command was processed, false if the command
+//processor is busy and can't process another command now.
+*/
+bool PVMFDummyFileInputNode::ProcessCommand(PVMFFileInputNodeCommand& aCmd)
+{
+    //normally this node will not start processing one command
+    //until the prior one is finished.  However, a hi priority
+    //command such as Cancel must be able to interrupt a command
+    //in progress.
+    if (!iCurrentCommand.empty() && !aCmd.hipri())
+        return false;
+
+    switch (aCmd.iCmd)
+    {
+        case PVMF_GENERIC_NODE_QUERYUUID:
+            DoQueryUuid(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_INIT:
+            DoInit(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PREPARE:
+            DoPrepare(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_START:
+            DoStart(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_STOP:
+            DoStop(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_FLUSH:
+            DoFlush(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PAUSE:
+            DoPause(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RESET:
+            DoReset(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+            DoCancelAllCommands(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELCOMMAND:
+            DoCancelCommand(aCmd);
+            break;
+
+        default://unknown command type
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            break;
+    }
+
+    return true;
+}
+
+/**
+//The various command handlers call this when a command is complete.
+*/
+void PVMFDummyFileInputNode::CommandComplete(PVMFFileInputNodeCmdQ& aCmdQ, PVMFFileInputNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    LOGINFO((0, "FileInputNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
+             , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+}
+
+/**
+//Called by the command handler AO to do the node Reset.
+*/
+void PVMFDummyFileInputNode::DoReset(PVMFFileInputNodeCommand& aCmd)
+{
+    //This example node allows a reset from any idle state.
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+        case EPVMFNodeIdle:
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        {
+            //delete all ports and notify observer.
+            while (!iPortVector.empty())
+                iPortVector.Erase(&iPortVector.front());
+
+            //restore original port vector reserve.
+            iPortVector.Reconstruct();
+
+            // close the input file
+            CloseInputFile();
+
+            //logoff & go back to Created state.
+            SetState(EPVMFNodeIdle);
+            PVMFStatus status = ThreadLogoff();
+
+            CommandComplete(iInputCommands, aCmd, status);
+        }
+        break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the Query UUID
+*/
+void PVMFDummyFileInputNode::DoQueryUuid(PVMFFileInputNodeCommand& aCmd)
+{
+    //This node supports Query UUID from any state
+
+    OSCL_String* mimetype;
+    Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
+    bool exactmatch;
+    aCmd.PVMFFileInputNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
+
+    //Try to match the input mimetype against any of
+    //the custom interfaces for this node
+
+    //Match against extension interface...
+    if (*mimetype == PVMF_FILEINPUT_NODE_EXTENSION_INTERFACE_MIMETYPE
+            //also match against base mimetypes for custom interface1,
+            //unless exactmatch is set.
+            || (!exactmatch && *mimetype == PVMF_FILEINPUT_NODE_MIMETYPE)
+            || (!exactmatch && *mimetype == PVMF_BASEMIMETYPE))
+    {
+
+        PVUuid uuid(KPVMFFileInputNodeExtensionUuid);
+        uuidvec->push_back(uuid);
+    }
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+/**
+//Called by the command handler AO to do the Query Interface.
+*/
+void PVMFDummyFileInputNode::DoQueryInterface(PVMFFileInputNodeCommand& aCmd)
+{
+    //This node supports Query Interface from any state
+
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVMFFileInputNodeCommandBase::Parse(uuid, ptr);
+
+    if (*uuid == PVUuid(KPVMFFileInputNodeExtensionUuid))
+    {
+        queryInterface(*uuid, *ptr);
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {//not supported
+        *ptr = NULL;
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+}
+
+/**
+//Called by the command handler AO to do the port request
+*/
+void PVMFDummyFileInputNode::DoRequestPort(PVMFFileInputNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileInputNode::DoRequestPort"));
+
+    //This node supports port request from any state
+
+    //this node is limited to one port
+    if (iPortVector.size() > 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::DoRequestPort: Multiple port request!"));
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+
+    //retrieve port tag.
+    int32 tag;
+    OSCL_String* mimetype;
+    aCmd.PVMFFileInputNodeCommandBase::Parse(tag, mimetype);
+
+    //(mimetype is not used on this node)
+
+    //validate the tag...
+    switch (tag)
+    {
+        case PVMF_DUMMY_FILEINPUT_NODE_PORT_TYPE_SOURCE:
+            break;
+        default:
+        {
+            //bad port tag
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFDummyFileInputNode::DoRequestPort: Error - Invalid port tag"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            return;
+        }
+        break;
+    }
+
+    //Allocate a new port
+    OsclAny *ptr = NULL;
+    int32 err;
+    OSCL_TRY(err, ptr = iPortVector.Allocate(););
+    if (err != OsclErrNone || !ptr)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::DoRequestPort: Error - iPortVector Out of memory"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        return;
+    }
+
+    //create base port
+    PVMFFileDummyInputPort*port = NULL;
+    port = new(ptr) PVMFFileDummyInputPort(tag
+                                           , this //the node handles port activity.
+                                           , INPORT_CAPACITY, INPORT_RESERVE, INPORT_THRESOLD //no input queue needed.
+                                           , OUTPORT_CAPACITY, OUTPORT_RESERVE, OUTPORT_THRESOLD);//output queue has a limit of 10 with no reserve
+
+    //if format was provided in mimestring, set it now.
+    if (mimetype)
+    {
+        PVMFFormatType fmt = mimetype->get_str();
+        if (fmt != PVMF_MIME_FORMAT_UNKNOWN
+                && port->IsFormatSupported(fmt))
+        {
+            port->iFormat = fmt;
+            port->FormatUpdated();
+        }
+    }
+
+    //Add the port to the port vector.
+    OSCL_TRY(err, iPortVector.AddL(port););
+    if (err != OsclErrNone)
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        return;
+    }
+
+    //Return the port pointer to the caller.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)port);
+}
+
+/**
+//Called by the command handler AO to do the port release
+*/
+void PVMFDummyFileInputNode::DoReleasePort(PVMFFileInputNodeCommand& aCmd)
+{
+    //This node supports release port from any state
+
+    //Find the port in the port vector
+    PVMFFileDummyInputPort *port;
+    PVMFPortInterface * tempInterface = NULL;
+
+    aCmd.PVMFFileInputNodeCommandBase::Parse(tempInterface);
+    port = OSCL_STATIC_CAST(PVMFFileDummyInputPort*, tempInterface);
+
+    PVMFFileDummyInputPort** portPtr = iPortVector.FindByValue(port);
+    if (portPtr)
+    {
+        //delete the port.
+        iPortVector.Erase(portPtr);
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        //port not found.
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Init
+*/
+void PVMFDummyFileInputNode::DoInit(PVMFFileInputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        {
+            //this node doesn't need to do anything
+            PVMFStatus status = Initialize();
+            if (status == PVMFSuccess)
+                SetState(EPVMFNodeInitialized);
+            //else
+            //	SetState(EPVMFNodeError);
+
+            CommandComplete(iInputCommands, aCmd, status);
+        }
+        break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Prepare
+*/
+void PVMFDummyFileInputNode::DoPrepare(PVMFFileInputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+            //this node doesn't need to do anything to get ready
+            //to start.
+            SetState(EPVMFNodePrepared);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Start
+*/
+void PVMFDummyFileInputNode::DoStart(PVMFFileInputNodeCommand& aCmd)
+{
+    PVMFStatus status = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodePrepared:
+            iTimeStamp = 0;
+            // Don't break here. Continue to process start command
+
+        case EPVMFNodePaused:
+            // If it's a start from stopped or initialized state, iInputFile
+            // object will be NULL and output file will be opened and read
+            // from the beginning.
+            if (!iFileOpen)
+            {
+                if (iFs.Connect() != 0) return;
+                iFsOpen = true;
+
+                if (iInputFile.Open(iSettings.iFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, iFs))
+                    status = PVMFFailure;
+
+                if (status == PVMFSuccess)
+                {
+                    iFileOpen = true;
+                    if (iInputFile.Seek(iFileHeaderSize + iFormatSpecificInfoSize, Oscl_File::SEEKSET))
+                        status = PVMFFailure;
+                }
+            }
+
+            if (status == PVMFSuccess)
+            {
+                //transition to Started
+                SetState(EPVMFNodeStarted);
+            }
+            //else
+            //	SetState(EPVMFNodeError);
+
+            break;
+
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+
+    CommandComplete(iInputCommands, aCmd, status);
+}
+
+/**
+//Called by the command handler AO to do the node Stop
+*/
+void PVMFDummyFileInputNode::DoStop(PVMFFileInputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+
+            // Clear queued messages in ports
+            uint32 i;
+            for (i = 0; i < iPortVector.size(); i++)
+                iPortVector[i]->ClearMsgQueues();
+
+            // Close the input file
+            CloseInputFile();
+            iDataEventCounter = 0;
+
+            //transition to Prepared state
+            SetState(EPVMFNodePrepared);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Flush
+*/
+void PVMFDummyFileInputNode::DoFlush(PVMFFileInputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            //the flush is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until the flush completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            //Notify all ports to suspend their input
+            {
+                for (uint32 i = 0;i < iPortVector.size();i++)
+                    iPortVector[i]->SuspendInput();
+            }
+
+            // Close the input file
+            CloseInputFile();
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//A routine to tell if a flush operation is in progress.
+*/
+bool PVMFDummyFileInputNode::FlushPending()
+{
+    return (iCurrentCommand.size() > 0
+            && iCurrentCommand.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
+}
+
+
+/**
+//Called by the command handler AO to do the node Pause
+*/
+void PVMFDummyFileInputNode::DoPause(PVMFFileInputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+
+            SetState(EPVMFNodePaused);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the Cancel All
+*/
+void PVMFDummyFileInputNode::DoCancelAllCommands(PVMFFileInputNodeCommand& aCmd)
+{
+    //first cancel the current command if any
+    {
+        while (!iCurrentCommand.empty())
+            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
+    }
+
+    //next cancel all queued commands
+    {
+        //start at element 1 since this cancel command is element 0.
+        while (iInputCommands.size() > 1)
+            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
+    }
+
+    //finally, report cancel complete.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+/**
+//Called by the command handler AO to do the Cancel single command
+*/
+void PVMFDummyFileInputNode::DoCancelCommand(PVMFFileInputNodeCommand& aCmd)
+{
+    //extract the command ID from the parameters.
+    PVMFCommandId id;
+    aCmd.PVMFFileInputNodeCommandBase::Parse(id);
+
+    //first check "current" command if any
+    {
+        PVMFFileInputNodeCommand* cmd = iCurrentCommand.FindById(id);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+
+    //next check input queue.
+    {
+        //start at element 1 since this cancel command is element 0.
+        PVMFFileInputNodeCommand* cmd = iInputCommands.FindById(id, 1);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+    //if we get here the command isn't queued so the cancel fails.
+    CommandComplete(iInputCommands, aCmd, PVMFFailure);
+}
+
+/////////////////////////////////////////////////////
+// Event reporting routines.
+/////////////////////////////////////////////////////
+void PVMFDummyFileInputNode::SetState(TPVMFNodeInterfaceState s)
+{
+    LOGINFO((0, "FileInputNode:SetState %d", s));
+    PVMFNodeInterface::SetState(s);
+}
+
+void PVMFDummyFileInputNode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData)
+{
+    LOGINFO((0, "FileInputNode:NodeErrorEvent Type %d Data %d"
+             , aEventType, aEventData));
+
+    PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
+}
+
+void PVMFDummyFileInputNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData)
+{
+    LOGINFO((0, "FileInputNode:NodeInfoEvent Type %d Data %d"
+             , aEventType, aEventData));
+
+    PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
+}
+
+/////////////////////////////////////////////////////
+// Port Processing routines
+/////////////////////////////////////////////////////
+
+void PVMFDummyFileInputNode::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFDummyFileInputNode::PortActivity: port=0x%x, type=%d",
+                     this, aActivity.iPort, aActivity.iType));
+
+    //A port is reporting some activity or state change.  This code
+    //figures out whether we need to queue a processing event
+    //for the AO, and/or report a node event to the observer.
+
+    //int32 err = 0;
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_CREATED:
+            //Report port created info event to the node.
+            PVMFNodeInterface::ReportInfoEvent(PVMFInfoPortCreated
+                                               , (OsclAny*)aActivity.iPort);
+            break;
+
+        case PVMF_PORT_ACTIVITY_DELETED:
+            //Report port deleted info event to the node.
+            PVMFNodeInterface::ReportInfoEvent(PVMFInfoPortDeleted
+                                               , (OsclAny*)aActivity.iPort);
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECT:
+            break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            // chesterc: No RunIfNotReady here. It will be called in Run after SendNewMediaMessage.
+            // Calling RunIfNotReady here would screw up frame rate simulation
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
+            //wakeup to resume queueing outgoing messages.
+            RunIfNotReady();
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+            //wakeup to resume sending outgoing data.
+            RunIfNotReady();
+            break;
+
+        default:
+            break;
+    }
+}
+
+
+/**
+/////////////////////////////////////////////////////
+// Active object implementation
+/////////////////////////////////////////////////////
+*/
+
+/**
+//Example of a single-AO node implementation.  This AO handles
+//both API commands and port activity.
+//
+//The AO will either process one command, send one outgoing message,
+//or create one new outgoing message per call.
+//It will re-schedule itself and run continuously
+//until it runs out of things to do.
+*/
+void PVMFDummyFileInputNode::Run()
+{
+    /*
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+    	(0, "0x%x PVMFDummyFileInputNode::Run: ENTER - iInputCommands.size=%d, iPortActivityQueue.size=%d",
+    	this, iInputCommands.size(), iPortActivityQueue.size()));
+    */
+
+    //Process commands.
+    if (!iInputCommands.empty())
+    {
+        if (ProcessCommand(iInputCommands.front()))
+        {
+            //note:it's possible the node could be reset so
+            //check isAdded here to avoid scheduler panic.
+            if (IsAdded())
+                RunIfNotReady();
+            return;
+        }
+    }
+
+    //Process ports
+    if (iPortVector.size() > 0)
+    {
+        //Send output data.
+        if (iInterfaceState == EPVMFNodeStarted || FlushPending())
+        {
+            if (iPortVector[0]->OutgoingMsgQueueSize() > 0
+                    && !iPortVector[0]->IsConnectedPortBusy())
+            {
+                PVMFStatus status = iPortVector[0]->Send();
+                if (status == PVMFSuccess)
+                {
+                    //increment timestamp and frame counter
+                    IncTimestamp();
+                    ++iDataEventCounter;
+                    RunIfNotReady();
+                    return;
+                }
+                else if (status == PVMFErrBusy)
+                {
+                    return;//wait on port ready callback
+                }
+            }
+            while (iPortVector[0]->IncomingMsgQueueSize() > 0)
+            {
+                // Just purge this data so that we
+                // don't have a memory lockup
+                PVMFSharedMediaMsgPtr aMsg;
+                iPortVector[0]->DequeueIncomingMsg(aMsg);
+            }
+        }
+
+        // Create new data and send to the output queue.
+        // chesterc: In flush state, don't queue new data
+        if (iInterfaceState == EPVMFNodeStarted && !FlushPending())
+        {
+            if (!iPortVector[0]->IsOutgoingQueueBusy())
+            {
+                PVMFStatus status = SendNewMediaMessage();
+                if (status == PVMFSuccess)
+                {
+                    //Re-schedule if not end of file.
+                    RunIfNotReady(iTSForRunIfInactive);
+                    return;
+                }
+            }
+        }
+
+        //Monitor completion of flush command.
+        if (FlushPending())
+        {
+            if (iPortVector[0]->IncomingMsgQueueSize() > 0
+                    || iPortVector[0]->OutgoingMsgQueueSize() > 0)
+            {
+                RunIfNotReady();
+                return;//wait on queues to empty.
+            }
+
+            //Flush is complete.  Go to prepared state.
+            SetState(EPVMFNodePrepared);
+
+            //resume port input so the ports can be re-started.
+            iPortVector[0]->ResumeInput();
+
+            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+            RunIfNotReady();
+        }
+    }
+}
+
+PVMFStatus PVMFDummyFileInputNode::SendNewMediaMessage()
+{
+#ifdef FRAGMENTATION_TEST
+    PVMFSharedMediaMsgPtr mediaMsg;
+    PVMFSharedMediaMsgPtr mediaMsg2;
+    PVMFStatus status = GenerateMediaMessage2(mediaMsg, mediaMsg2);
+#else
+    PVMFSharedMediaMsgPtr mediaMsg;
+    PVMFStatus status = GenerateMediaMessage(mediaMsg);
+#endif
+
+    if (status == PVMFSuccess)
+    {
+        status = iPortVector[0]->QueueOutgoingMsg(mediaMsg);
+
+        if (status == PVMFSuccess)
+        {
+            //keep count of the number of source
+            //frames generated on this port.
+            iPortVector[0]->iNumFramesGenerated++;
+        }
+        else
+        {
+            //just discard the data...
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFDummyFileInputNode::SendNewMediaMessage: Data lost!. "));
+        }
+#ifdef FRAGMENTATION_TEST
+        if (!iEndOfFileReached)
+        {
+            // 2nd message exists unless EOF
+            status = iPortVector[0]->QueueOutgoingMsg(mediaMsg2);
+
+            if (status == PVMFSuccess)
+            {
+                //keep count of the number of source
+                //frames generated on this port.
+                iPortVector[0]->iNumFramesGenerated++;
+            }
+            else
+            {
+                //just discard the data...
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "PVMFDummyFileInputNode::SendNewMediaMessage: Data lost!. "));
+            }
+        }
+#endif
+
+    }
+    else if (iEndOfFileReached)
+    {
+        // end of file
+    }
+    else if (status != PVMFErrNoMemory) // excluding the case that memory pool runs out of memory
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::SendNewMediaMessage: Error - GenerateData failed"));
+        PVMFNodeInterface* node = OSCL_STATIC_CAST(PVMFNodeInterface*, this);
+        ReportErrorEvent(PVMF_FILEINPUT_NODE_ERROR_DATA_GENERATING_ERROR, (OsclAny*)node);
+    }
+
+    return status;
+}
+
+void PVMFDummyFileInputNode::DoCancel()
+{//the base class cancel operation is sufficient.
+    OsclTimerObject::DoCancel();
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileInputNode::ConstructInputSettings(PVMFFileInputSettings* aSettings)
+{
+    iSettings.iFileName = aSettings->iFileName;
+    iSettings.iFrameHeight = aSettings->iFrameHeight;
+    iSettings.iFrameRate = aSettings->iFrameRate;
+    iSettings.iFrameWidth = aSettings->iFrameWidth;
+    iSettings.iLoopInputFile = aSettings->iLoopInputFile;
+    iSettings.iMediaFormat = aSettings->iMediaFormat;
+    iSettings.iNumChannels = aSettings->iNumChannels;
+    iSettings.iSamplingFrequency = aSettings->iSamplingFrequency;
+    iSettings.iTimescale = aSettings->iTimescale;
+    iSettings.iNum20msFramesPerChunk = aSettings->iNum20msFramesPerChunk;
+    iSettings.iFrameRateSimulation = aSettings->iFrameRateSimulation;
+    iSettings.iFirstFrameTimestamp = aSettings->iFirstFrameTimestamp;
+    iSettings.iBitrate = aSettings->iBitrate;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileInputNode::CloseInputFile()
+{
+    if (iFileOpen)
+    {
+        iInputFile.Close();
+        iFileOpen = false;
+    }
+
+    if (iFsOpen)
+    {
+        iFs.Close();
+        iFsOpen = false;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileInputNode::Initialize()
+{
+    if (iFs.Connect() != 0) return 0;
+
+    iFsOpen = true;
+
+    if (0 != iInputFile.Open(iSettings.iFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, iFs))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::HandleCmdInit: Error - iInputFile.Open failed"));
+        return PVMFFailure;
+    }
+
+
+    iFileOpen = true;
+    uint32 maxFrameSize = 0;
+
+    if (iSettings.iMediaFormat == PVMF_MIME_H2632000)
+    {
+        int32 fileStart = iInputFile.Tell();
+        iInputFile.Seek(0, Oscl_File::SEEKEND);
+        int32 fileEnd = iInputFile.Tell();
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+        int32 fileSize = fileEnd - fileStart;
+
+        // Validate settings
+        if (iSettings.iFrameHeight <= 0 || iSettings.iFrameWidth <= 0 ||
+                iSettings.iFrameRate <= 0 || iSettings.iTimescale <= 0)
+        {
+            CloseInputFile();
+            return PVMFErrArgument;
+        }
+
+        fileStart = iInputFile.Tell();
+        iInputFile.Seek(0, Oscl_File::SEEKEND);
+        fileEnd = iInputFile.Tell();
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+        fileSize = fileEnd - fileStart;
+        iVideoData = (uint8*)iAlloc.allocate(fileSize);
+        if (!iVideoData)
+        {
+            CloseInputFile();
+            return PVMFErrNoMemory;
+        }
+
+        // Read the whole file to data buffer then go back to front
+        iInputFile.Read((OsclAny*)iVideoData, sizeof(uint8), fileSize);
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+        iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
+        iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
+
+    }
+
+    else if (iSettings.iMediaFormat == PVMF_MIME_AMR_IF2)
+    {
+        int32 fileStart, fileEnd, fileSize;
+        fileStart = iInputFile.Tell();
+        iInputFile.Seek(0, Oscl_File::SEEKEND);
+        fileEnd = iInputFile.Tell();
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+        fileSize = fileEnd - fileStart;
+        iAudioData = (uint8*)iAlloc.allocate(fileSize);
+        if (!iAudioData)
+        {
+            CloseInputFile();
+            return PVMFErrNoMemory;
+        }
+
+        // Read the whole file to data buffer then go back to front
+        iInputFile.Read((OsclAny*)iAudioData, sizeof(uint8), fileSize);
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+
+    }
+    else
+        CloseInputFile();
+    return PVMFErrArgument;
+
+    iDataEventCounter = 0;
+    CloseInputFile();
+
+    // Create memory pool for the media data, using the maximum frame size found earlier
+    int32 err = 0;
+    OSCL_TRY(err,
+             if (iMediaBufferMemPool)
+{
+    OSCL_DELETE(iMediaBufferMemPool);
+        iMediaBufferMemPool = NULL;
+    }
+    iMediaBufferMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator,
+                                   (PVFILEIN_MEDIADATA_POOLNUM));
+    if (!iMediaBufferMemPool)
+    OSCL_LEAVE(OsclErrNoMemory);
+
+    if (iMediaDataAlloc)
+    {
+        OSCL_DELETE(iMediaDataAlloc);
+            iMediaDataAlloc = NULL;
+        }
+    iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iMediaBufferMemPool));
+    if (!iMediaDataAlloc)
+    OSCL_LEAVE(OsclErrNoMemory);
+
+    // The first allocate call will set the chunk size of the memory pool. Use the max
+    // frame size calculated earlier to set the chunk size.  The allocated data will be
+    // deallocated automatically as tmpPtr goes out of scope.
+    OsclSharedPtr<PVMFMediaDataImpl> tmpPtr = iMediaDataAlloc->allocate(maxFrameSize);
+            );
+    if (err != OsclErrNone)
+        return PVMFFailure;
+
+    return PVMFSuccess;
+}
+
+void PVMFDummyFileInputNode::IncTimestamp()
+{
+    //Increment running timestamp if needed.
+    if (iSettings.iMediaFormat == PVMF_MIME_AMR_IF2)
+    {
+        iTimeStamp += iMilliSecondsPerDataEvent;
+    }
+}
+
+void PVMFDummyFileInputNode::freechunkavailable(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    if (iWaitingOnFreeChunk)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::freechunkavailable: Resuming processing, free chunk available."));
+        iWaitingOnFreeChunk = false;
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+}
+
+
+PVMFStatus PVMFDummyFileInputNode::GenerateMediaMessage(PVMFSharedMediaMsgPtr& aMediaMsg)
+{
+
+    if (iInterfaceState != EPVMFNodeStarted)
+    {
+        return PVMFSuccess;
+    }
+
+    uint32 bytesToRead = 0;
+    uint32 timeStamp = 0;
+
+    //Find the frame...
+    if (!((iSettings.iMediaFormat == PVMF_MIME_H2632000) || (iSettings.iMediaFormat == PVMF_MIME_AMR_IF2)))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::HandleEventPortActivity: Error - Unsupported media format"));
+        return PVMFFailure;
+    }
+
+    if (timeStamp < iSettings.iFirstFrameTimestamp)
+    {
+        // Search for the first frame greater than the specified start time
+        iTSForRunIfInactive = 0;
+        return PVMFSuccess;
+    }
+
+    // Create new media data buffer
+
+    PVMFSharedMediaDataPtr mediaData;
+    int32 err = 0;
+    OSCL_TRY(err,
+             OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(bytesToRead);
+             mediaData = PVMFMediaData::createMediaData(mediaDataImpl, &iMediaDataMemPool);
+            );
+    if (err != OsclErrNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileInputNode::HandleEventPortActivity: Mempool empty-- calling notifyfreechunkavailable"));
+        //register to receive notice when memory is available.
+        iMediaBufferMemPool->notifyfreechunkavailable(*this);
+        iWaitingOnFreeChunk = true;
+        return PVMFErrNoMemory;
+    }
+
+    // Retrieve memory fragment to write to
+
+    OsclRefCounterMemFrag refCtrMemFrag;
+    mediaData->getMediaFragment(0, refCtrMemFrag);
+    if (refCtrMemFrag.getCapacity() < bytesToRead)
+        return PVMFFailure;
+
+
+    // For AAC Latm, read the marker info before reading the data
+
+    // Read the frame from file
+
+    //uint32 len = iInputFile.Read(refCtrMemFrag.getMemFragPtr(), sizeof(uint8), bytesToRead );
+    if (iSettings.iMediaFormat == PVMF_MIME_H2632000)
+    {
+        oscl_memcpy(refCtrMemFrag.getMemFragPtr(), iVideoData, sizeof(iVideoData));
+        // update the filled length of the fragment
+        mediaData->setMediaFragFilledLen(0, sizeof(iVideoData));
+    }
+    else
+    {
+        oscl_memcpy(refCtrMemFrag.getMemFragPtr(), iAudioData, sizeof(iAudioData));
+        // update the filled length of the fragment
+        mediaData->setMediaFragFilledLen(0, sizeof(iAudioData));
+    }
+
+    // Set timestamp
+    mediaData->setTimestamp(timeStamp);
+    // Set sequence number
+    mediaData->setSeqNum(iDataEventCounter);
+
+    if (iSettings.iMediaFormat == PVMF_MIME_H2632000)
+
+    {
+        // For M4V and H263 data always set the marker bit to 1
+        OsclSharedPtr<PVMFMediaDataImpl> media_data_impl;
+        mediaData->getMediaDataImpl(media_data_impl);
+        media_data_impl->setMarkerInfo(1);
+    }
+
+
+    // Set format specific info in media data message
+#ifndef SEND_CONFIGINFO_SEPARATELY
+    mediaData->setFormatSpecificInfo(iFormatSpecificInfo);
+#else
+    if (iSetFormatSpecificInfo)
+    {
+        // Create new media data buffer
+        OsclSharedPtr<PVMFMediaDataImpl> emptyImpl = iMediaDataAlloc.allocate(0);
+        PVMFSharedMediaDataPtr volData;
+        int errcode = 0;
+        OSCL_TRY(errcode, volData = PVMFMediaData::createMediaData(emptyImpl, &iMediaDataMemPool));
+        OSCL_FIRST_CATCH_ANY(errcode, return PVMFErrNoMemory);
+
+        // Set format specific info in media data message
+        volData->setFormatSpecificInfo(iFormatSpecificInfo);
+
+        // Send VOL header to downstream node
+        PVMFSharedMediaMsgPtr volMsg;
+        convertToPVMFMediaMsg(volMsg, volData);
+        iSetFormatSpecificInfo = false;
+
+        ++iDataEventCounter;
+        return PVMFSuccess;
+    }
+#endif
+
+    // Send frame to downstream node
+
+    convertToPVMFMediaMsg(aMediaMsg, mediaData);
+
+    // Queue the next data event
+    if (iSettings.iFrameRateSimulation)
+        iTSForRunIfInactive = iMicroSecondsPerDataEvent;
+    else
+        iTSForRunIfInactive = 0;
+
+    return PVMFSuccess;
+}
+
+
+int32 PVMFDummyFileInputNode::GetIF2FrameSize(uint8 aFrameType)
+{
+    // Last 4 bits of first byte of the package is frame type
+    uint8 frameType = (uint8)(0x0f & aFrameType);
+
+    // Find frame size for each frame type
+    switch (frameType)
+    {
+        case 0: // AMR 4.75 Kbps
+            return 13;
+        case 1: // AMR 5.15 Kbps
+            return 14;
+        case 2: // AMR 5.90 Kbps
+            return 16;
+        case 3: // AMR 6.70 Kbps
+            return 18;
+        case 4: // AMR 7.40 Kbps
+            return 19;
+        case 5: // AMR 7.95 Kbps
+            return 21;
+        case 6: // AMR 10.2 Kbps
+            return 26;
+        case 7: // AMR 12.2 Kbps
+            return 31;
+        case 8: // AMR Frame SID
+        case 9: // AMR Frame GSM EFR SID
+        case 10: // AMR Frame TDMA EFR SID
+        case 11: // AMR Frame PDC EFR SID
+            return 6;
+        case 15: // AMR Frame No Data
+            return 1;
+        default: // Error - For Future Use
+            return -1;
+    }
+}
+
+int32 PVMFDummyFileInputNode::LocateH263FrameHeader(uint8 *video_buffer, int32 vop_size)
+{
+    int32 idx;
+    uint8 *ptr;
+
+    idx = 1;
+    ptr = video_buffer + 1;
+    vop_size -= 4;
+    do
+    {
+        ptr--;
+        idx--;
+        for (;;)
+        {
+            if (ptr[1])
+            {
+                ptr += 2;
+                idx += 2;
+            }
+            else if (ptr[0])
+            {
+                ptr++;
+                idx++;
+            }
+            else
+            {
+                break;
+            }
+            if (idx >= vop_size) return -1;
+        }
+        ptr += 2;
+        idx += 2;
+    }
+    while ((video_buffer[idx] & 0xfc) != 0x80);
+
+    return idx -2;
+}
diff --git a/nodes/pvdummyinputnode/src/pvmf_fileinput_port.cpp b/nodes/pvdummyinputnode/src/pvmf_fileinput_port.cpp
new file mode 100644
index 0000000..36f5f53
--- /dev/null
+++ b/nodes/pvdummyinputnode/src/pvmf_fileinput_port.cpp
@@ -0,0 +1,557 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_sample_port.cpp
+ * @brief Sample PVMF Port implementation
+ */
+
+#ifndef PVMF_FILEINPUT_PORT_H_INCLUDED
+#include "pvmf_fileinput_port.h"
+#endif
+#ifndef OSCL_MEM_BASIC_FUNCTIONS_H
+#include "oscl_mem_basic_functions.h"
+#endif
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+#ifndef PVMF_DUMMY_FILEINPUT_NODE_H_INCLUDED
+#include "pvmf_dummy_fileinput_node.h"
+#endif
+
+#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
+#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
+#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFFileDummyInputPort::PVMFFileDummyInputPort(int32 aTag, PVMFNodeInterface* aNode)
+        : PvmfPortBaseImpl(aTag, aNode)
+{
+    Construct();
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFFileDummyInputPort::PVMFFileDummyInputPort(int32 aTag, PVMFNodeInterface* aNode
+        , uint32 aInCapacity
+        , uint32 aInReserve
+        , uint32 aInThreshold
+        , uint32 aOutCapacity
+        , uint32 aOutReserve
+        , uint32 aOutThreshold)
+        : PvmfPortBaseImpl(aTag, aNode, aInCapacity, aInReserve, aInThreshold, aOutCapacity, aOutReserve, aOutThreshold)
+{
+    Construct();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFFileDummyInputPort::Construct()
+{
+    iLogger = PVLogger::GetLoggerObject("PVMFFileDummyInputPort");
+    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
+    iNumFramesGenerated = 0;
+    iTrackConfigFI = NULL;
+    iTrackConfigSizeFI = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFFileDummyInputPort::~PVMFFileDummyInputPort()
+{
+    Disconnect();
+    ClearMsgQueues();
+
+    if (iTrackConfigFI)
+    {
+        oscl_free(iTrackConfigFI);
+        iTrackConfigFI = NULL;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                  PvmiCapabilityAndConfig
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFFileDummyInputPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    // Not supported
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    LOG_STACK_TRACE((0, "PVMFFileDummyInputPort::getParametersSync"));
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+
+    num_parameter_elements = 0;
+    PVMFStatus status = PVMFFailure;
+    PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)iPortActivityHandler;
+
+
+    if (pv_mime_strcmp(identifier, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0 && (iFormat == PVMF_MIME_WMV || iFormat == PVMF_MIME_WMA))
+    {
+        if (pvmiGetPortFormatSpecificInfoSync(PVMF_FORMAT_SPECIFIC_INFO_KEY, parameters) == 0)
+        {
+            return PVMFFailure;
+        }
+        else
+        {
+            num_parameter_elements = 1;
+            return PVMFSuccess;
+        }
+
+    }
+
+    parameters = NULL;
+    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0 ||
+            pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, OUTPUT_FORMATS_VALTYPE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.pChar_value = (char*)node->iSettings.iMediaFormat.getMIMEStrPtr();
+        }
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, VIDEO_OUTPUT_WIDTH_CUR_VALUE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+
+        parameters[0].value.uint32_value = node->iSettings.iFrameWidth;
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, VIDEO_OUTPUT_HEIGHT_CUR_VALUE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+
+        parameters[0].value.uint32_value = node->iSettings.iFrameHeight;
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+
+        parameters[0].value.float_value = node->iSettings.iFrameRate;
+    }
+    else if (pv_mime_strcmp(identifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, OUTPUT_TIMESCALE_CUR_VALUE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFVideoEncPort::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        else
+        {
+            if ((node->iSettings.iMediaFormat).isAudio())
+            {
+                parameters[0].value.uint32_value = node->iSettings.iSamplingFrequency;
+            }
+            else
+            {
+                parameters[0].value.uint32_value = node->iSettings.iTimescale;
+            }
+        }
+    }
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if (parameters)
+    {
+        iAlloc.deallocate((OsclAny*)parameters->key);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFFileDummyInputPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFFileDummyInputPort::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFFileDummyInputPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFFileDummyInputPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    OSCL_UNUSED_ARG(session);
+    PVMFStatus status = PVMFSuccess;
+    ret_kvp = NULL;
+
+    for (int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
+            ret_kvp = &(parameters[i]);
+            OSCL_LEAVE(OsclErrArgument);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFFileDummyInputPort::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 PVMFFileDummyInputPort::getCapabilityMetric(PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+
+    PVMFStatus status = PVMFSuccess;
+    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
+        status = VerifyAndSetParameter(&(parameters[i]));
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFFileDummyInputPort::Connect(PVMFPortInterface* aPort)
+{
+
+
+    if (!aPort)
+    {
+        LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Connecting to invalid port"));
+        return PVMFErrArgument;
+    }
+
+    if (iConnectedPort)
+    {
+        LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Already connected"));
+        return PVMFFailure;
+    }
+
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig* config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
+    if (config != NULL)
+    {
+        if (!(pvmiSetPortFormatSpecificInfoSync(config, PVMF_FORMAT_SPECIFIC_INFO_KEY)))
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Unable To Send Format Specific Info To Peer"));
+            return PVMFFailure;
+        }
+    }
+
+    /*
+     * Automatically connect the peer.
+     */
+    if (aPort->PeerConnect(this) != PVMFSuccess)
+    {
+        LOG_ERR((0, "PVMFFileDummyInputPort::Connect: Error - Peer Connect failed"));
+        return PVMFFailure;
+    }
+
+    iConnectedPort = aPort;
+
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFFileDummyInputPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    return ((aFmt == PVMF_MIME_YUV420)		        ||
+            (aFmt == PVMF_MIME_RGB16)		        ||
+            (aFmt == PVMF_MIME_M4V)		        ||
+            (aFmt == PVMF_MIME_WMV)				||
+            (aFmt == PVMF_MIME_WMA)				||
+            (aFmt == PVMF_MIME_H2632000)		        ||
+            (aFmt == PVMF_MIME_AMR_IF2)	        ||
+            (aFmt == PVMF_MIME_AMR_IETF)	        ||
+            (aFmt == PVMF_MIME_PCM16)		        ||
+            (aFmt == PVMF_MIME_ADTS)		        ||
+            (aFmt == PVMF_MIME_MPEG4_AUDIO)        ||
+            (aFmt == PVMF_MIME_LATM)		        ||
+            (aFmt == PVMF_MIME_MP3)		        ||
+            (aFmt == PVMF_MIME_ADIF)		        ||
+            (aFmt == PVMF_MIME_AAC_SIZEHDR)		||
+            (aFmt == PVMF_MIME_G726)		        ||
+            (aFmt == PVMF_MIME_YUV420)				||
+            (aFmt == PVMF_MIME_REAL_AUDIO));
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFFileDummyInputPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFFileDummyInputPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFFileDummyInputPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
+{
+    LOG_STACK_TRACE((0, "PVMFFileDummyInputPort::AllocateKvp"));
+    uint8* buf = NULL;
+    uint32 keyLen = oscl_strlen(aKey) + 1;
+    int32 err = 0;
+
+    OSCL_TRY(err,
+             buf = (uint8*)iAlloc.ALLOCATE(aNumParams * (sizeof(PvmiKvp) + keyLen));
+             if (!buf)
+             OSCL_LEAVE(OsclErrNoMemory);
+            );
+    OSCL_FIRST_CATCH_ANY(err,
+                         LOG_ERR((0, "PVMFFileDummyInputPort::AllocateKvp: Error - kvp allocation failed"));
+                         return PVMFErrNoMemory;
+                        );
+
+    int32 i = 0;
+    PvmiKvp* curKvp = aKvp = OSCL_PLACEMENT_NEW(buf, PvmiKvp);
+    buf += sizeof(PvmiKvp);
+    for (i = 1; i < aNumParams; i++)
+    {
+        curKvp += i;
+        curKvp = OSCL_PLACEMENT_NEW(buf, PvmiKvp);
+        buf += sizeof(PvmiKvp);
+    }
+
+    for (i = 0; i < aNumParams; i++)
+    {
+        aKvp[i].key = (char*)buf;
+        oscl_strncpy(aKvp[i].key, aKey, oscl_strlen(aKvp[i].key));
+        buf += oscl_strlen(aKvp[i].key);
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFFileDummyInputPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    LOG_STACK_TRACE((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
+
+    if (!aKvp)
+    {
+        LOG_ERR((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
+        return PVMFFailure;
+    }
+
+    PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)iPortActivityHandler;
+
+    if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
+    {
+        if (aKvp->value.pChar_value == node->iSettings.iMediaFormat.getMIMEStrPtr())
+        {
+            if (aSetParam)
+                iFormat = aKvp->value.pChar_value;
+            return PVMFSuccess;
+        }
+        else
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: Error - Unsupported format %d",
+                     aKvp->value.uint32_value));
+            return PVMFFailure;
+        }
+    }
+
+    LOG_ERR((0, "PVMFFileDummyInputPort::VerifyAndSetParameter: Error - Unsupported parameter"));
+    return PVMFFailure;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+bool PVMFFileDummyInputPort::pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType,
+        PvmiKvp*& aKvp)
+{
+    PVMFDummyFileInputNode* node = (PVMFDummyFileInputNode*)iPortActivityHandler;
+
+    if ((iFormat == PVMF_MIME_WMV) || (iFormat == PVMF_MIME_WMA))
+    {
+        if (node->iFs.Connect() != 0) return false;
+        node->iInputFile.Open(node->iSettings.iFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, node->iFs);
+        node->iInputFile.Read((OsclAny*) &iTrackConfigSizeFI, sizeof(uint8), 4);
+
+        iTrackConfigFI = (uint8*) iAlloc.allocate(iTrackConfigSizeFI);
+        node->iInputFile.Read((OsclAny*) iTrackConfigFI, sizeof(uint8), iTrackConfigSizeFI);
+        node->iInputFile.Close();
+
+        if (iTrackConfigSizeFI > 0)
+        {
+            OsclMemAllocator alloc;
+            aKvp->key = NULL;
+            aKvp->length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+            aKvp->key = (PvmiKeyType)alloc.ALLOCATE(aKvp->length);
+            if (aKvp->key == NULL)
+            {
+                return false;
+            }
+            oscl_strncpy(aKvp->key, aFormatValType, aKvp->length);
+
+            aKvp->value.key_specific_value = (OsclAny*)(iTrackConfigFI);
+            aKvp->capacity = iTrackConfigSizeFI;
+        }
+        return true;
+    }
+
+    else
+        return true;
+
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+bool PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort,
+        const char* aFormatValType)
+{
+    PVMFDummyFileInputNode* node = OSCL_STATIC_CAST(PVMFDummyFileInputNode*, iPortActivityHandler);
+    PvmiKvp* retKvp = NULL; // for return value
+    int32 err = 0;
+    PvmiKvp* kvpPtr = NULL;
+    if (iFormat == PVMF_MIME_WMV)
+    {
+        if (node->iFs.Connect() != 0) return false;
+        node->iInputFile.Open(node->iSettings.iFileName.get_cstr(),
+                              Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, node->iFs);
+        node->iInputFile.Read((OsclAny*) &iTrackConfigSizeFI, sizeof(uint8), 4);
+
+        iTrackConfigFI = (uint8*)oscl_malloc(iTrackConfigSizeFI);
+        node->iInputFile.Read((OsclAny*) iTrackConfigFI, sizeof(uint8), iTrackConfigSizeFI);
+        node->iInputFile.Close();
+
+        if (iTrackConfigSizeFI > 0)
+        {
+            OsclMemAllocator alloc;
+            PvmiKvp kvp;
+            kvp.key = NULL;
+            kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+            kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+            if (kvp.key == NULL)
+            {
+                return false;
+            }
+            oscl_strncpy(kvp.key, aFormatValType, kvp.length);
+
+            kvp.value.key_specific_value = (OsclAny*) iTrackConfigFI;
+            kvp.capacity = iTrackConfigSizeFI;
+            OSCL_TRY(err, aPort->setParametersSync(NULL, &kvp, 1, retKvp););
+            /* ignore the error for now */
+            alloc.deallocate((OsclAny*)(kvp.key));
+        }
+    }
+    else if (iFormat == PVMF_MIME_G726)
+    {
+        // Send a fake G726 format specific info containing number of bits per sample in the
+        // 14th byte of the info buffer.
+        if (AllocateKvp(kvpPtr, OSCL_STATIC_CAST(PvmiKeyType, aFormatValType), 1) != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync: Error - AllocateKvp failed"));
+            return false;
+        }
+
+        kvpPtr->value.key_specific_value = OSCL_MALLOC(32);
+        if (kvpPtr->value.key_specific_value == NULL)
+        {
+            LOG_ERR((0, "PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync: Error - OSCL_MALLOC failed"));
+            return false;
+        }
+        oscl_memset(kvpPtr->value.key_specific_value, 0, 32);
+
+        int16* bitsPerSamplePtr;
+        bitsPerSamplePtr = OSCL_STATIC_CAST(int16*,
+                                            (OSCL_STATIC_CAST(uint8*, kvpPtr->value.key_specific_value) + 14));
+        *bitsPerSamplePtr = (node->iSettings.iBitrate) / (node->iSettings.iSamplingFrequency);
+
+        OSCL_TRY(err, aPort->setParametersSync(NULL, kvpPtr, 1, retKvp););
+        OSCL_FIRST_CATCH_ANY(err,
+                             LOG_ERR((0, "PVMFFileDummyInputPort::pvmiSetPortFormatSpecificInfoSync: Error - setParametersSync failed. err=%d", err));
+                             return false;
+                            );
+
+        OSCL_FREE(kvpPtr->value.key_specific_value);
+        releaseParameters(NULL, kvpPtr, 1);
+    }
+
+    return true;
+}
diff --git a/nodes/pvdummyoutputnode/build/make/local.mk b/nodes/pvdummyoutputnode/build/make/local.mk
new file mode 100644
index 0000000..03eb4ca
--- /dev/null
+++ b/nodes/pvdummyoutputnode/build/make/local.mk
@@ -0,0 +1,32 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvdummyoutputnode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += ../../include ../../../../pvmi/pvmf/include ../../../common/include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_dummy_fileoutput_inport.cpp \
+	pvmf_dummy_fileoutput_node.cpp \
+	pvmf_dummy_fileoutput_factory.cpp \
+	pvmf_dummy_fileoutput_node_cap_config.cpp
+
+HDRS := pvmf_dummy_fileoutput_config.h\
+	pvmf_dummy_fileoutput_factory.h
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvdummyoutputnode/include/pvmf_dummy_fileoutput_config.h b/nodes/pvdummyoutputnode/include/pvmf_dummy_fileoutput_config.h
new file mode 100644
index 0000000..922e381
--- /dev/null
+++ b/nodes/pvdummyoutputnode/include/pvmf_dummy_fileoutput_config.h
@@ -0,0 +1,87 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_fileoutput_config.h
+ * @brief External configuration interface for PVMFDummyFileOutputNode
+ */
+
+#ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
+#define PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+#define PVMF_MIME_FILE_OUTPUT _STRLIT_CHAR("x-pvmf/file/output")
+#define PVMF_MIME_MIN_COMP_CNT 4
+#define PVMF_MIME_MIN_COMP_IDX 3
+#define PVMFDummyFileOutputNodeConfigUuid PVUuid(0x5411cc90,0xe335,0x4b06,0xbe,0xe4,0x7c,0x81,0x40,0x6a,0xf3,0xaa)
+
+/**
+ * PVMFDummyFileOutputNodeConfigInterface allows a external client to configure properties
+ * of PVMFFileOutputNode. The application can specify the file name through this
+ * extension interface.
+ */
+class PVMFDummyFileOutputNodeConfigInterface : public PVInterface
+{
+    public:
+        /**
+         * Register a reference to this interface.
+         */
+        virtual void addRef() = 0;
+
+        /**
+         * Remove a reference to this interface.
+         */
+        virtual void removeRef() = 0;
+
+        /**
+         * Query for an instance of a particular interface.
+         *
+         * @param uuid Uuid of the requested interface
+         * @param iface Output parameter where pointer to an instance of the
+         * requested interface will be stored if it is supported by this object
+         * @return true if the requested interface is supported, else false
+         */
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+
+        /**
+         * This method sets the output file name. This method must be called before
+         * the engine / node is initialized.
+         *
+         * @param aFileName Output file name
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetOutputFileName(const OSCL_wString& aFileName) = 0;
+
+};
+
+#endif // PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
+
+
diff --git a/nodes/pvdummyoutputnode/include/pvmf_dummy_fileoutput_factory.h b/nodes/pvdummyoutputnode/include/pvmf_dummy_fileoutput_factory.h
new file mode 100644
index 0000000..50a92e9
--- /dev/null
+++ b/nodes/pvdummyoutputnode/include/pvmf_dummy_fileoutput_factory.h
@@ -0,0 +1,82 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_DUMMY_FILEOUTPUT_FACTORY_H_INCLUDED
+#define PVMF_DUMMY_FILEOUTPUT_FACTORY_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+// Forward declaration
+class PVMFNodeInterface;
+
+//Port tags for this node.
+typedef enum
+{
+    PVMF_DUMMY_FILE_OUTPUT_NODE_PORT_TYPE_SINK
+} PVMFDummyFileOutputNodePortTag;
+
+#define KPVFileOutputNodeUuid PVUuid(0xa9fb43bb,0xfed4,0x4914,0xa4,0xbf,0x7d,0x04,0x3f,0x45,0x0c,0x24)
+
+/**
+ * PVMFDummyFileOutputNodeFactory Class
+ *
+ * PVMFDummyFileOutputNodeFactory class is a singleton class which instantiates and provides
+ * access to PV FileOutput node. It returns a PVMFNodeInterface
+ * reference, the interface class of the PVMFDummyFileOutputNode.
+ *
+ * The client is expected to contain and maintain a pointer to the instance created
+ * while the node is active.
+ */
+class PVMFDummyFileOutputNodeFactory
+{
+    public:
+        /**
+         * Creates an instance of a FileOutput. If the creation fails, this function will leave.
+         *
+         * @param aPriority The active object priority for the node. Default is standard priority if not specified
+         * @returns A pointer to an author or leaves if instantiation fails
+         **/
+        OSCL_IMPORT_REF static PVMFNodeInterface* CreateDummyFileOutput(int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        /**
+         * Creates an instance of a FileOutput. If the creation fails, this function will leave.
+         *
+         * @param aFileName pathname of file to write to.
+         * @param aFormat media format for file.
+         * @param aPriority The active object priority for the node. Default is standard priority if not specified
+         * @returns A pointer to an author or leaves if instantiation fails
+         **/
+        OSCL_IMPORT_REF static PVMFNodeInterface* CreateDummyFileOutput(OSCL_wString &aFileName, PVMFFormatType aFormat, int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        /**
+         * This function allows the application to delete an instance of a PVMFDummyFileOutputNode
+         * and reclaim all allocated resources.  An instance can be deleted only in
+         * the idle state. An attempt to delete in any other state will fail and return false.
+         *
+         * @param aComposer The file format composer to be deleted.
+         * @returns A status code indicating success or failure.
+         **/
+        OSCL_IMPORT_REF static bool DeleteDummyFileOutput(PVMFNodeInterface*& aNode);
+};
+
+#endif // PVMF_FILEOUTPUT_FACTORY_H_INCLUDED
diff --git a/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_factory.cpp b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_factory.cpp
new file mode 100644
index 0000000..7a3ec4d
--- /dev/null
+++ b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_factory.cpp
@@ -0,0 +1,77 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_fileoutput_factory.cpp
+ * @brief Singleton factory for PVMFDummyFileOutputNode
+ */
+
+#include "oscl_base.h"
+
+#include "pvmf_dummy_fileoutput_node.h"
+
+#include "pvmf_dummy_fileoutput_factory.h"
+
+#include "pvmf_dummy_fileoutput_inport.h"
+
+#include "oscl_error_codes.h"
+
+#include "oscl_exception.h"
+
+#include "oscl_dll.h"
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVMFDummyFileOutputNodeFactory::CreateDummyFileOutput(int32 aPriority)
+{
+    PVMFNodeInterface* node = NULL;
+    node = OSCL_NEW(PVMFDummyFileOutputNode, (aPriority));
+    if (node == NULL)
+    {
+        OSCL_LEAVE(OsclErrNoMemory);
+    }
+    return node;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVMFDummyFileOutputNodeFactory::CreateDummyFileOutput(OSCL_wString &aFileName, PVMFFormatType aFormat, int32 aPriority)
+{
+    PVMFNodeInterface* node = NULL;
+    node = OSCL_NEW(PVMFDummyFileOutputNode, (aPriority));
+    if (node == NULL)
+    {
+        OSCL_LEAVE(OsclErrNoMemory);
+    }
+    ((PVMFDummyFileOutputNode *)node)->iFormat = aFormat;
+    ((PVMFDummyFileOutputNode *)node)->iOutputFileName = aFileName.get_cstr();
+    return node;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFDummyFileOutputNodeFactory::DeleteDummyFileOutput(PVMFNodeInterface*& aNode)
+{
+    if (aNode)
+    {
+        OSCL_DELETE(aNode);
+        return true;
+    }
+
+    return false;
+}
+
diff --git a/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_inport.cpp b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_inport.cpp
new file mode 100644
index 0000000..c6b9872
--- /dev/null
+++ b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_inport.cpp
@@ -0,0 +1,740 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_fileoutput_inport.h
+ * @brief Input port for simple file output node
+ *
+ */
+
+#include "pvmf_dummy_fileoutput_inport.h"
+#include "oscl_error_codes.h"
+#include "pv_mime_string_utils.h"
+#include "pvmf_dummy_fileoutput_node.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+
+#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
+#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
+#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+
+////////////////////////////////////////////////////////////////////////////
+PVMFDummyFileOutputInPort::~PVMFDummyFileOutputInPort()
+{
+    Disconnect();
+    ClearMsgQueues();
+    iDataQueue.Clear();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::Start()
+{
+    iState = PORT_STATE_STARTED;
+    RunIfNotReady();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::Pause()
+{
+    iState = PORT_STATE_BUFFERING;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::Stop()
+{
+    iDataQueue.Clear();
+    iState = PORT_STATE_BUFFERING;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::removeRef()
+{
+    if (iExtensionRefCount > 0)
+    {
+        --iExtensionRefCount;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFDummyFileOutputInPort::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == PvmfNodesSyncControlUuid)
+    {
+        PvmfNodesSyncControlInterface* myInterface = OSCL_STATIC_CAST(PvmfNodesSyncControlInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        addRef();
+    }
+    else
+    {
+        iface = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputInPort::SetClock(PVMFMediaClock* aClock)
+{
+    return iDataQueue.SetClock(aClock);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputInPort::ChangeClockRate(int32 aRate)
+{
+    OSCL_UNUSED_ARG(aRate);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputInPort::SetMargins(int32 aEarlyMargin, int32 aLateMargin)
+{
+    return iSyncUtil.SetMargins(aEarlyMargin, aLateMargin);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputInPort::SkipMediaData(PVMFSessionId aSessionId,
+        PVMFTimestamp aResumeTimestamp,
+        uint32 aStreamID,
+        bool aPlayBackPositionContinuous,
+        OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aStreamID);
+    OSCL_UNUSED_ARG(aPlayBackPositionContinuous);
+
+    // To handle case where media data are in queues but
+    // not processed yet
+    if (iLastDataTimestampSet == false)
+    {
+        // Check if there is data in the incoming queue
+        if (IncomingMsgQueueSize() > 0)
+        {
+            iLastDataTimestamp = iIncomingQueue.iQ.front()->getTimestamp();
+            if (iLastDataTimestamp == PVMF_MAX_CMDID_CNTR)
+            {
+                // TEMP Handle unknown timestamp
+                // Will be removed when unknown timestamp is incorporated in architecture
+                iLastDataTimestamp = 0;
+            }
+            else
+            {
+                PVMFSharedMediaMsgPtr msgPtr = iIncomingQueue.iQ.front();
+                if (msgPtr->getFormatID() == PVMF_MEDIA_MSG_DATA_FORMAT_ID)
+                {
+                    PVMFSharedMediaDataPtr mediaData;
+                    convertToPVMFMediaData(mediaData, msgPtr);
+                    uint32 markerInfo = mediaData->getMarkerInfo();
+                    if (markerInfo & PVMF_MEDIA_DATA_MARKER_INFO_DURATION_AVAILABLE_BIT)
+                    {
+                        iLastDataTimestamp += iIncomingQueue.iQ.front()->getDuration();
+                    }
+                }
+            }
+            iLastDataTimestampSet = true;
+        }
+        // Or the sync util's data queue
+        else if (iDataQueue.DataQueue().size() > 0)
+        {
+            iLastDataTimestamp = iDataQueue.DataQueue()[0]->getTimestamp();
+            if (iLastDataTimestamp == PVMF_MAX_TIME_STAMP)
+            {
+                // TEMP Handle unknown timestamp
+                // Will be removed when unknown timestamp is incorporated in architecture
+                iLastDataTimestamp = 0;
+            }
+            else
+            {
+                PVMFSharedMediaMsgPtr msgPtr = iDataQueue.DataQueue()[0];
+                if (msgPtr->getFormatID() == PVMF_MEDIA_MSG_DATA_FORMAT_ID)
+                {
+                    PVMFSharedMediaDataPtr mediaData;
+                    convertToPVMFMediaData(mediaData, msgPtr);
+                    uint32 markerInfo = mediaData->getMarkerInfo();
+                    if (markerInfo & PVMF_MEDIA_DATA_MARKER_INFO_DURATION_AVAILABLE_BIT)
+                    {
+                        iLastDataTimestamp += iDataQueue.DataQueue()[0]->getDuration();
+                    }
+                }
+            }
+            iLastDataTimestampSet = true;
+        }
+    }
+
+    // Check if the incoming media data is already past the resume point
+    if (iLastDataTimestampSet == true && aResumeTimestamp <= iLastDataTimestamp)
+    {
+        // Skip is already done so send the skip complete in Run
+        iSkipAlreadyComplete = true;
+        RunIfNotReady();
+
+        // Return a command ID
+        iSkipMediaDataContext = aContext;
+        iSkipMediaDataSessionId = aSessionId;
+        iSkipMediaDataCmdId = iNode->iCmdIdCounter;
+        if (++(iNode->iCmdIdCounter) == PVMF_MAX_CMDID_CNTR)
+        {
+            iNode->iCmdIdCounter = 0;
+        }
+        return iSkipMediaDataCmdId;
+    }
+
+    // Wait for data to come in
+    switch (iDataQueue.SkipMediaData(aResumeTimestamp, true))
+    {
+        case PVMFPending:
+            iSkipResumeTimestamp = aResumeTimestamp;
+            iSkipMediaDataPending = true;
+            iSkipMediaDataContext = aContext;
+
+            iSkipMediaDataSessionId = aSessionId;
+            iSkipMediaDataCmdId = iNode->iCmdIdCounter;
+            if (++(iNode->iCmdIdCounter) == PVMF_MAX_CMDID_CNTR)
+            {
+                iNode->iCmdIdCounter = 0;
+            }
+            return iSkipMediaDataCmdId;
+
+        default:
+            OSCL_LEAVE(OsclErrGeneral);
+            return 0;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::ScheduleProcessData(PvmfSyncUtilDataQueue* aDataQueue, uint32 aTimeMilliseconds)
+{
+    OSCL_UNUSED_ARG(aDataQueue);
+//	if(iSkipMediaDataPending || iState == PORT_STATE_STARTED)
+    {
+        RunIfNotReady(aTimeMilliseconds * 1000);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::SkipMediaDataComplete()
+{
+    iSkipResumeTimestamp = 0;
+    //Report completion to the session observer.
+    PVMFCmdResp resp(iSkipMediaDataCmdId, iSkipMediaDataContext, PVMFSuccess);
+    iNode->ReportCmdCompleteEvent(iSkipMediaDataSessionId, resp);
+
+    iSkipMediaDataPending = false;
+    ScheduleProcessData(&iDataQueue, 0);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::CancelSkipMediaData()
+{
+    iSkipResumeTimestamp = 0;
+    iDataQueue.CancelSkipMediaData();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+{
+    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        aPtr = (PvmiCapabilityAndConfig*)this;
+    }
+    else
+    {
+        aPtr = NULL;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFDummyFileOutputInPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    return ((aFmt == PVMF_MIME_AMR_IF2) ||
+            (aFmt == PVMF_MIME_ADTS) ||
+            (aFmt == PVMF_MIME_MPEG4_AUDIO) ||
+            (aFmt == PVMF_MIME_LATM) ||
+            (aFmt == PVMF_MIME_M4V) ||
+            (aFmt == PVMF_MIME_H2632000) ||
+            (aFmt == PVMF_MIME_PCM) ||
+            (aFmt == PVMF_MIME_PCM8) ||
+            (aFmt == PVMF_MIME_PCM16) ||
+            (aFmt == PVMF_MIME_YUV420) ||
+            (aFmt == PVMF_MIME_3GPP_TIMEDTEXT));
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFDummyFileOutputInPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
+    //set port name for datapath logging
+    if (iFormat.isAudio())
+    {
+        SetName("FileOutIn(Audio)");
+        iDataQueue.SetName("FileOutIn(Audio)");
+    }
+    else if (iFormat.isVideo())
+    {
+        SetName("FileOutIn(Video)");
+        iDataQueue.SetName("FileOutIn(Video)");
+    }
+    else if (iFormat.isText())
+    {
+        SetName("FileOutIn(Text)");
+        iDataQueue.SetName("FileOutIn(Text)");
+    }
+    else
+    {
+        SetName("FileOutIn");
+        iDataQueue.SetName("FileOutIn");
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                  PvmiCapabilityAndConfig
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileOutputInPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    // Not supported
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFDummyFileOutputInPort::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    LOG_STACK_TRACE((0, "PVMFDummyFileOutputInPort::getParametersSync"));
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+    parameters = NULL;
+    num_parameter_elements = 0;
+    PVMFStatus status = PVMFFailure;
+
+    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
+    {
+        num_parameter_elements = 15;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, INPUT_FORMATS_VALTYPE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFDummyFileOutputInPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_AMR_IETF);
+            parameters[1].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_ADTS);
+            parameters[2].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_MPEG4_AUDIO);
+            parameters[3].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_LATM);
+            parameters[4].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_M4V);
+            parameters[5].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_H2632000);
+            parameters[6].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_PCM8);
+            parameters[7].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_PCM16);
+            parameters[8].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_YUV420);
+            parameters[9].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_AMR_IF2);
+            parameters[10].value.pChar_value = OSCL_STATIC_CAST(char*, PVMF_MIME_3GPP_TIMEDTEXT);
+        }
+    }
+    else if (pv_mime_strcmp(identifier, INPUT_FORMATS_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, INPUT_FORMATS_VALTYPE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFDummyFileOutputInPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.pChar_value = (char*)iFormat.getMIMEStrPtr();
+        }
+    }
+    else if (pv_mime_strcmp(identifier, PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, OSCL_STATIC_CAST(PvmiKeyType, PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFDummyFileOutputInPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.pChar_value = (char*)iFormat.getMIMEStrPtr();
+        }
+    }
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFDummyFileOutputInPort::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if (parameters)
+    {
+        iAlloc.deallocate((OsclAny*)parameters);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileOutputInPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileOutputInPort::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileOutputInPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFDummyFileOutputInPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    OSCL_UNUSED_ARG(session);
+    PVMFStatus status = PVMFSuccess;
+    ret_kvp = NULL;
+
+    for (int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFDummyFileOutputInPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
+            ret_kvp = &(parameters[i]);
+            OSCL_LEAVE(OsclErrArgument);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFDummyFileOutputInPort::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 PVMFDummyFileOutputInPort::getCapabilityMetric(PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFDummyFileOutputInPort::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+
+    PVMFStatus status = PVMFSuccess;
+    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
+        status = VerifyAndSetParameter(&(parameters[i]));
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFDummyFileOutputInPort::PVMFDummyFileOutputInPort(int32 aTag
+        , PVMFNodeInterface* aNode)
+        : PvmfPortBaseImpl(aTag, aNode, 0, 0, 0, 0, 0, 0, "PVFileOPPortIn"),
+        OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVMFDummyFileOutputInPort"),
+        iDataQueue(this, &iSyncUtil),
+        iNode(NULL),
+        iSkipMediaDataPending(false),
+        iSkipMediaDataCmdId(0),
+        iSkipMediaDataContext(NULL),
+        iExtensionRefCount(0),
+        iState(PORT_STATE_BUFFERING),
+        iFormat(PVMF_MIME_FORMAT_UNKNOWN),
+        iSkipAlreadyComplete(false),
+        iSkipResumeTimestamp(0),
+        iLastDataTimestampSet(false),
+        iLastDataTimestamp(0)
+{
+    ConstructL(aNode);
+#if (PVMF_PORT_BASE_IMPL_STATS)
+    oscl_memset((void*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::ConstructL(PVMFNodeInterface* aContainerNode)
+{
+    if (!aContainerNode)
+        OSCL_LEAVE(OsclErrArgument);
+
+    iNode = (PVMFDummyFileOutputNode*)aContainerNode;
+    AddToScheduler();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputInPort::Run()
+{
+    if (iSkipAlreadyComplete)
+    {
+        iSkipAlreadyComplete = false;
+        SkipMediaDataComplete();
+    }
+
+    if (!iSkipMediaDataPending && iState == PORT_STATE_BUFFERING)
+    {
+        return;
+    }
+
+    PVMFSharedMediaMsgPtr mediamsgptr;
+    {
+        uint32 dropped;
+        uint32 skipped;
+        PVMFStatus retval = iDataQueue.DequeueMediaData(mediamsgptr, &dropped, &skipped);
+        if (dropped > 0)
+        {
+            iNode->PVMFNodeInterface::ReportInfoEvent(PVMFInfoDataDiscarded);
+        }
+
+        if (retval == PVMFSuccess)
+        {
+            //schedule next processing.  this may wakeup one time too many, but
+            //there's no good way to evaluate at this point whether we need
+            //to process more data or not.
+            if (!iDataQueue.DataQueue().empty())
+            {
+                RunIfNotReady();
+            }
+
+            PVMFTimestamp datatailtime = mediamsgptr->getTimestamp();
+            if (mediamsgptr->getFormatID() == PVMF_MEDIA_MSG_DATA_FORMAT_ID)
+            {
+                PVMFSharedMediaDataPtr mediaData;
+                convertToPVMFMediaData(mediaData, mediamsgptr);
+                uint32 markerInfo = mediaData->getMarkerInfo();
+                if (markerInfo & PVMF_MEDIA_DATA_MARKER_INFO_DURATION_AVAILABLE_BIT)
+                {
+                    datatailtime += mediamsgptr->getDuration();
+                }
+            }
+            iLastDataTimestamp = datatailtime;
+            iLastDataTimestampSet = true;
+
+            if (mediamsgptr->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+            {
+                // If skip media data is pending, complete it
+                if (iSkipMediaDataPending)
+                {
+                    if (datatailtime >= iSkipResumeTimestamp)
+                    {
+                        LOG_STACK_TRACE((0, "PVMFDummyFileOutputInPort::Run In middle of skip so cancelling skip and sending out PVMFInfoEndOfData in response to EOS media cmd"));
+                        // Cancel and complete the skip
+                        CancelSkipMediaData();
+                        SkipMediaDataComplete();
+                        // Send out EndOfData event
+                        iNode->ReportInfoEvent(PVMFInfoEndOfData);
+                    }
+                    else
+                    {
+                        // Ignore this EOS associated with data to be flushed
+                        LOG_STACK_TRACE((0, "PVMFDummyFileOutputInPort::Run EOS being ignored since it is to be flushed in SkipMediaData"));
+                    }
+                }
+                else
+                {
+                    // Send EndOfData event
+                    LOG_STACK_TRACE((0, "PVMFDummyFileOutputInPort::Run Sending out PVMFInfoEndOfData in response to EOS media cmd"));
+                    iNode->ReportInfoEvent(PVMFInfoEndOfData);
+                }
+            }
+            else
+            {
+                // This is media data that is in-sync.
+                // Check if it needs to be dropped when skipping
+                if (iSkipMediaDataPending)
+                {
+                    if (datatailtime < iSkipResumeTimestamp)
+                    {
+                        // Data needs to be dropped
+                        return;
+                    }
+                }
+
+                // Write out the data
+                PVMFSharedMediaDataPtr mediaDataPtr;
+                convertToPVMFMediaData(mediaDataPtr, mediamsgptr);
+                PVMFStatus status = iNode->ProcessIncomingData(mediaDataPtr);
+                if (status != PVMFSuccess)
+                {
+                    iNode->iOutputFile.Flush();
+                }
+            }
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputInPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
+{
+    LOG_STACK_TRACE((0, "PVMFDummyFileOutputInPort::AllocateKvp"));
+    uint8* buf = NULL;
+    uint32 keyLen = oscl_strlen(aKey) + 1;
+    int32 err = 0;
+
+    OSCL_TRY(err,
+             buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
+             if (!buf)
+             OSCL_LEAVE(OsclErrNoMemory);
+            );
+    OSCL_FIRST_CATCH_ANY(err,
+                         LOG_ERR((0, "PVMFDummyFileOutputInPort::AllocateKvp: Error - kvp allocation failed"));
+                         return PVMFErrNoMemory;
+                        );
+
+    int32 i = 0;
+    PvmiKvp* curKvp = aKvp = OSCL_PLACEMENT_NEW(buf, PvmiKvp);
+    buf += sizeof(PvmiKvp);
+    for (i = 1; i < aNumParams; i++)
+    {
+        curKvp += i;
+        curKvp = OSCL_PLACEMENT_NEW(buf, PvmiKvp);
+        buf += sizeof(PvmiKvp);
+    }
+
+    for (i = 0; i < aNumParams; i++)
+    {
+        aKvp[i].key = (char*)buf;
+        oscl_strncpy(aKvp[i].key, aKey, keyLen);
+        buf += keyLen;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputInPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    LOG_STACK_TRACE((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
+
+    if (!aKvp)
+    {
+        LOG_ERR((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
+        return PVMFFailure;
+    }
+
+    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0)
+    {
+        if (IsFormatSupported(aKvp->value.pChar_value))
+        {
+            if (aSetParam)
+                iFormat = aKvp->value.pChar_value;
+            return PVMFSuccess;
+        }
+        else
+        {
+            return PVMFErrNotSupported;
+        }
+    }
+    else if (pv_mime_strcmp(aKvp->key, PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE) == 0)
+    {
+        if (IsFormatSupported(aKvp->value.pChar_value))
+        {
+            if (aSetParam)
+                iFormat = aKvp->value.pChar_value;
+            return PVMFSuccess;
+        }
+        else
+        {
+            return PVMFErrNotSupported;
+        }
+    }
+    else if (pv_mime_strcmp(aKvp->key, MOUT_AUDIO_FORMAT_KEY) == 0)
+    {
+        LOG_DEBUG((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: Got audio format key"));
+        // just return success for now
+        return PVMFSuccess;
+    }
+    else if (pv_mime_strcmp(aKvp->key, MOUT_AUDIO_SAMPLING_RATE_KEY) == 0)
+    {
+        LOG_DEBUG((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: Audio sample rate=%d", aKvp->value.uint32_value));
+        // just return success for now
+        return PVMFSuccess;
+    }
+    else if (pv_mime_strcmp(aKvp->key, MOUT_AUDIO_NUM_CHANNELS_KEY) == 0)
+    {
+        LOG_DEBUG((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: Audio num channels=%d", aKvp->value.uint32_value));
+        // just return success for now
+        return PVMFSuccess;
+    }
+    else if (pv_mime_strcmp(aKvp->key, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        PVMFStatus status =
+            iNode->WriteFormatSpecificInfo((OsclAny*)(aKvp->value.pChar_value), aKvp->capacity);
+
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: WriteFormatSpecificInfo Error"));
+        }
+        return status;
+    }
+    else if (pv_mime_strcmp(aKvp->key, PVMF_BITRATE_VALUE_KEY) == 0)
+    {
+        LOG_DEBUG((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: bitrate=%d", aKvp->value.uint32_value));
+        // just return success for now
+        return PVMFSuccess;
+    }
+    else if (pv_mime_strcmp(aKvp->key, PVMF_FRAMERATE_VALUE_KEY) == 0)
+    {
+        LOG_DEBUG((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: framerate=%d", aKvp->value.uint32_value));
+        // just return success for now
+        return PVMFSuccess;
+    }
+
+    LOG_ERR((0, "PVMFDummyFileOutputInPort::VerifyAndSetParameter: Error - Unsupported parameter"));
+    return PVMFFailure;
+}
diff --git a/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_inport.h b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_inport.h
new file mode 100644
index 0000000..53893b5
--- /dev/null
+++ b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_inport.h
@@ -0,0 +1,187 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_fileoutput_inport.h
+ * @brief Input port for simple file output node
+ *
+ */
+
+#ifndef PVMF_FILEOUTPUT_INPORT_H_INCLUDED
+#define PVMF_FILEOUTPUT_INPORT_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_port_interface.h"
+#endif
+#ifndef PVMF_NODES_SYNC_CONTROL_H_INCLUDED
+#include "pvmf_nodes_sync_control.h"
+#endif
+#ifndef PVMF_SYNC_UTIL_DATA_QUEUE_H_INCLUDED
+#include "pvmf_sync_util_data_queue.h"
+#endif
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+class PVMFDummyFileOutputNode;
+
+//Default vector reserve size
+#define PVMF_FILE_OUTPUT_NODE_PORT_VECTOR_RESERVE 10
+
+// Capability mime strings
+#define PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS "x-pvmf/file/encode/input_formats"
+//#define PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/file/encode/input_formats;valtype=int32"
+#define PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=char*"
+
+#define PVMF_MAX_CMDID_CNTR 0x7FFFFFFF
+#define PVMF_MAX_TIME_STAMP 0xFFFFFFFF
+class PVMFDummyFileOutputInPort : public PvmfPortBaseImpl
+            , public PvmiCapabilityAndConfig
+            , public PvmfSyncUtilDataQueueObserver
+            , public OsclTimerObject
+            , public PvmfNodesSyncControlInterface
+{
+    public:
+        PVMFDummyFileOutputInPort(int32 aTag, PVMFNodeInterface* aNode);
+        ~PVMFDummyFileOutputInPort();
+
+        void Start();
+        void Pause();
+        void Stop();
+
+        // Pure virtual from PVInterface
+        void addRef();
+        void removeRef();
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+        // Pure virtuals from PvmfNodesSyncControlInterface
+        PVMFStatus SetClock(PVMFMediaClock* aClock);
+        PVMFStatus ChangeClockRate(int32 aRate);
+        PVMFStatus SetMargins(int32 aEarlyMargin, int32 aLateMargin);
+        void ClockStarted(void) {} // Not needed
+        void ClockStopped(void) {} // Not needed
+        PVMFCommandId SkipMediaData(PVMFSessionId aSessionId,
+                                    PVMFTimestamp aResumeTimestamp,
+                                    uint32 aStreamID,
+                                    bool aPlayBackPositionContinuous = false,
+                                    OsclAny* aContext = NULL);
+
+        // Pure virtuals from PvmfSyncUtilDataQueueObserver
+        void ScheduleProcessData(PvmfSyncUtilDataQueue* aDataQueue, uint32 aTimeMilliseconds);
+        void SkipMediaDataComplete();
+        void CancelSkipMediaData();
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        // Pure virtuals from PVMFPortInterface
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr);
+
+        bool IsFormatSupported(PVMFFormatType);
+        void FormatUpdated();
+
+        PvmfSyncUtilDataQueue iDataQueue;
+
+        //overload of the routine in PVMFPortBaseImpl
+        PVMFStatus ClearMsgQueues()
+        {//when the port queue is cleared, also clear the sync queue.
+            PvmfPortBaseImpl::ClearMsgQueues();
+            iDataQueue.Clear();
+            return PVMFSuccess;
+        }
+
+    private:
+
+        void ConstructL(PVMFNodeInterface* aContainerNode);
+        void Run();
+
+        /**
+         * Allocate a specified number of key-value pairs and set the keys
+         *
+         * @param aKvp Output parameter to hold the allocated key-value pairs
+         * @param aKey Key for the allocated key-value pairs
+         * @param aNumParams Number of key-value pairs to be allocated
+         * @return Completion status
+         */
+        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
+
+        /**
+         * Verify one key-value pair parameter against capability of the port and
+         * if the aSetParam flag is set, set the value of the parameter corresponding to
+         * the key.
+         *
+         * @param aKvp Key-value pair parameter to be verified
+         * @param aSetParam If true, set the value of parameter corresponding to the key.
+         * @return PVMFSuccess if parameter is supported, else PVMFFailure
+         */
+        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
+
+        PVMFDummyFileOutputNode* iNode;
+        PvmfSyncUtil iSyncUtil;
+
+        bool iSkipMediaDataPending;
+        PVMFSessionId iSkipMediaDataSessionId;
+        PVMFCommandId iSkipMediaDataCmdId;
+        OsclAny* iSkipMediaDataContext;
+        uint32 iExtensionRefCount;
+
+        enum PortState
+        {
+            PORT_STATE_BUFFERING = 0,
+            PORT_STATE_STARTED,
+        };
+        PortState iState;
+
+        PVMFFormatType iFormat;
+        OsclMemAllocator iAlloc;
+
+        bool iSkipAlreadyComplete;
+        PVMFTimestamp iSkipResumeTimestamp;
+        bool iLastDataTimestampSet;
+        PVMFTimestamp iLastDataTimestamp;
+
+        friend class PVMFDummyFileOutputNode;
+};
+
+#endif // PVMF_FILEOUTPUT_INPORT_H_INCLUDED
diff --git a/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node.cpp b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node.cpp
new file mode 100644
index 0000000..ff73a0d
--- /dev/null
+++ b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node.cpp
@@ -0,0 +1,1418 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_dummy_fileoutput_node.cpp
+ * @brief Simple dummy file output node. Does not Write incoming data to any
+ *   file
+ *
+ */
+
+#include "pvmf_dummy_fileoutput_inport.h"
+#include "pvmf_dummy_fileoutput_node.h"
+#include "pvlogger.h"
+#include "oscl_error_codes.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+#include "pvmf_timedtext.h"
+
+////////////////////////////////////////////////////////////////////////////
+PVMFDummyFileOutputNode::PVMFDummyFileOutputNode(int32 aPriority)
+        : OsclActiveObject(aPriority, "PVMFDummyFileOutputNode")
+        , iCmdIdCounter(0)
+        , iInPort(NULL)
+        , iFileOpened(0)
+        , iFirstMediaData(false)
+        , iLogger(NULL)
+        , iFormat(PVMF_MIME_FORMAT_UNKNOWN)
+        , iExtensionRefCount(0)
+        , iMaxFileSizeEnabled(false)
+        , iMaxDurationEnabled(false)
+        , iMaxFileSize(0)
+        , iMaxDuration(0)
+        , iFileSize(0)
+        , iFileSizeReportEnabled(false)
+        , iDurationReportEnabled(false)
+        , iFileSizeReportFreq(0)
+        , iDurationReportFreq(0)
+        , iNextFileSizeReport(0)
+        , iNextDurationReport(0)
+        , iClock(NULL)
+        , iEarlyMargin(DEFAULT_EARLY_MARGIN)
+        , iLateMargin(DEFAULT_LATE_MARGIN)
+{
+    ConstructL();
+    int32 err;
+    OSCL_TRY(err,
+
+             //Create the input command queue.  Use a reserve to avoid lots of
+             //dynamic memory allocation.
+             iInputCommands.Construct(PVMF_FILE_OUTPUT_NODE_COMMAND_ID_START, PVMF_FILE_OUTPUT_NODE_COMMAND_VECTOR_RESERVE);
+
+             //Create the "current command" queue.  It will only contain one
+             //command at a time, so use a reserve of 1.
+             iCurrentCommand.Construct(0, 1);
+
+             //Create the port vector.
+             iPortVector.Construct(PVMF_FILE_OUTPUT_NODE_PORT_VECTOR_RESERVE);
+
+             //Set the node capability data.
+             //This node can support an unlimited number of ports.
+             iCapability.iCanSupportMultipleInputPorts = false;
+             iCapability.iCanSupportMultipleOutputPorts = false;
+             iCapability.iHasMaxNumberOfPorts = true;
+             iCapability.iMaxNumberOfPorts = 1;
+            );
+
+    if (err != OsclErrNone)
+    {
+        //if a leave happened, cleanup and re-throw the error
+        iInputCommands.clear();
+        iCurrentCommand.clear();
+        iPortVector.clear();
+        iCapability.iInputFormatCapability.clear();
+        iCapability.iOutputFormatCapability.clear();
+        OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
+        OSCL_CLEANUP_BASE_CLASS(OsclActiveObject);
+        OSCL_LEAVE(err);
+    }
+    ChangeNodeState(EPVMFNodeCreated);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFDummyFileOutputNode::~PVMFDummyFileOutputNode()
+{
+    //thread logoff
+    if (IsAdded())
+        RemoveFromScheduler();
+
+    //Cleanup allocated interfaces
+
+
+    //Cleanup allocated ports
+    if (iInPort)
+    {
+        OSCL_DELETE(((PVMFDummyFileOutputInPort*)iInPort));
+        iInPort = NULL;
+    }
+
+    //Cleanup commands
+    //The command queues are self-deleting, but we want to
+    //notify the observer of unprocessed commands.
+    while (!iCurrentCommand.empty())
+    {
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
+    }
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+    }
+
+    //cleanup port activity events
+    iPortActivityQueue.clear();
+
+
+    if (iAlloc)
+    {
+        OSCL_DELETE(iAlloc);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::ConstructL()
+{
+    iAlloc = (Oscl_DefAlloc*)(new PVMFFileOutputAlloc());
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::ThreadLogon()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:ThreadLogon"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+            if (!IsAdded())
+                AddToScheduler();
+            iLogger = PVLogger::GetLoggerObject("PVMFDummyFileOutputNode");
+            SetState(EPVMFNodeIdle);
+            return PVMFSuccess;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+        default:
+            return PVMFErrInvalidState;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::ThreadLogoff()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:ThreadLogoff"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            if (IsAdded())
+                RemoveFromScheduler();
+            iLogger = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+
+        default:
+            return PVMFErrInvalidState;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::CloseOutputFile()
+{
+    // Close output file
+    if (iFileOpened)
+    {
+        iOutputFile.Close();
+        iFs.Close();
+        iFileOpened = 0;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Init"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Prepare"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:GetCapability"));
+    iCapability.iInputFormatCapability.clear();
+
+    if (iFormat != PVMF_MIME_FORMAT_UNKNOWN)
+    {
+        // Format is already set, so return only that one
+        iCapability.iInputFormatCapability.push_back(iFormat);
+    }
+    else
+    {
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_M4V);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM8);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM16);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_YUV420);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_ADTS);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_H2632000);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_3GPP_TIMEDTEXT);
+    }
+    aNodeCapability = iCapability;
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:QueryUUID"));
+
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:QueryInterface"));
+
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:RequestPort"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:ReleasePort"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFPortIter* PVMFDummyFileOutputNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:GetPorts"));
+
+    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
+    iPortVector.Reset();
+    return &iPortVector;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Start"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Stop"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+/**
+//Queue an asynchronous node command
+*/
+PVMFCommandId PVMFDummyFileOutputNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Flush"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Pause"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:Reset"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:CancelAllCommands"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:CancelCommand"));
+    PVMFDummyFileOutputNodeCommand cmd;
+    cmd.PVMFDummyFileOutputNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
+    return QueueCommandL(cmd);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::removeRef()
+{
+    if (iExtensionRefCount > 0)
+        --iExtensionRefCount;
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFDummyFileOutputNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == PVMFDummyFileOutputNodeConfigUuid)
+    {
+        PVMFDummyFileOutputNodeConfigInterface* myInterface = OSCL_STATIC_CAST(PVMFDummyFileOutputNodeConfigInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+    }
+    else if (uuid == PvmfComposerSizeAndDurationUuid)
+    {
+        PvmfComposerSizeAndDurationInterface* myInterface = OSCL_STATIC_CAST(PvmfComposerSizeAndDurationInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+    }
+    else if (uuid == PvmfNodesSyncControlUuid)
+    {
+        PvmfNodesSyncControlInterface* myInterface = OSCL_STATIC_CAST(PvmfNodesSyncControlInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+    }
+
+    else if (uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        PvmiCapabilityAndConfig* myInterface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+    }
+
+    else
+    {
+        iface = NULL;
+        return false;
+    }
+
+    return true;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::SetMaxDuration(bool aEnable, uint32 aMaxDurationMilliseconds)
+{
+    iMaxDurationEnabled = aEnable;
+    if (iMaxDurationEnabled)
+    {
+        iMaxDuration = aMaxDurationMilliseconds;
+    }
+    else
+    {
+        iMaxDuration = 0;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::GetMaxDurationConfig(bool& aEnable, uint32& aMaxDurationMilliseconds)
+{
+    aEnable = iMaxDurationEnabled;
+    aMaxDurationMilliseconds = iMaxDuration;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::SetDurationProgressReport(bool aEnable, uint32 aReportFrequency)
+{
+    iDurationReportEnabled = aEnable;
+    if (iDurationReportEnabled)
+    {
+        iDurationReportFreq = aReportFrequency;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::GetDurationProgressReportConfig(bool& aEnable, uint32& aReportFrequency)
+{
+    aEnable = iDurationReportEnabled;
+    aReportFrequency = iDurationReportFreq;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::SetClock(PVMFMediaClock* aClock)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::SetClock: aClock=0x%x", aClock));
+
+    iClock = aClock;
+    if (iInPort)
+    {
+        return ((PVMFDummyFileOutputInPort*)iInPort)->SetClock(aClock);
+    }
+
+    return PVMFSuccess;
+}
+
+///////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::ChangeClockRate(int32 aRate)
+{
+    OSCL_UNUSED_ARG(aRate);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::ChangeClockRate: aRate=%d", aRate));
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::SetMargins(int32 aEarlyMargin, int32 aLateMargin)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::SetMargins: aEarlyMargin=%d, aLateMargin=%d", aEarlyMargin, aLateMargin));
+
+    iEarlyMargin = aEarlyMargin;
+    iLateMargin = aLateMargin;
+    if (iInPort)
+    {
+        return ((PVMFDummyFileOutputInPort*)iInPort)->SetMargins(aEarlyMargin, aLateMargin);
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::ClockStarted(void)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::ClockStarted"));
+
+    if (iInPort)
+    {
+        ((PVMFDummyFileOutputInPort*)iInPort)->Start();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::ClockStopped(void)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::ClockStopped"));
+
+    if (iInPort)
+    {
+        ((PVMFDummyFileOutputInPort*)iInPort)->Pause();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFDummyFileOutputNode::SkipMediaData(PVMFSessionId aSessionId,
+        PVMFTimestamp aResumeTimestamp,
+        uint32 aStreamID,
+        bool aPlayBackPositionContinuous,
+        OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::SkipMediaData: aResumeTimestamp=%d, aContext=0x%x",
+                     aResumeTimestamp, aContext));
+
+    if (!iInPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileOutputNode::SkipMediaData: Error - Input port has not been created"));
+        OSCL_LEAVE(OsclErrNotReady);
+        return 0;
+    }
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodeInitialized:
+        case EPVMFNodePaused:
+            return ((PVMFDummyFileOutputInPort*)iInPort)->SkipMediaData(aSessionId, aResumeTimestamp, aStreamID, aPlayBackPositionContinuous, aContext);
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFDummyFileOutputNode::SkipMediaData: Error - Wrong state"));
+            OSCL_LEAVE(OsclErrInvalidState);
+            return 0;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::Run()
+{
+    if (!iInputCommands.empty())
+    {
+        if (ProcessCommand(iInputCommands.front()))
+        {
+            //note: need to check the state before re-scheduling
+            //since the node could have been reset in the ProcessCommand
+            //call.
+            if (iInterfaceState != EPVMFNodeCreated)
+                RunIfNotReady();
+            return;
+        }
+    }
+
+    // Process port activity
+    if (!iPortActivityQueue.empty()
+            && (iInterfaceState == EPVMFNodeStarted || FlushPending()))
+    {
+        // If the port activity cannot be processed because a port is
+        // busy, discard the activity and continue to process the next
+        // activity in queue until getting to one that can be processed.
+        while (!iPortActivityQueue.empty())
+        {
+            if (ProcessPortActivity())
+                break; //processed a port
+        }
+        //Re-schedule
+        RunIfNotReady();
+        return;
+    }
+
+    //If we get here we did not process any ports or commands.
+    //Check for completion of a flush command...
+    if (FlushPending()
+            && iPortActivityQueue.empty())
+    {
+        SetState(EPVMFNodePrepared);
+        iInPort->ResumeInput();
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+        RunIfNotReady();
+    }
+}
+
+void PVMFDummyFileOutputNode::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFDummyFileOutputNode::PortActivity: port=0x%x, type=%d",
+                     this, aActivity.iPort, aActivity.iType));
+
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            //An outgoing message was queued on this port.
+            //We only need to queue a port activity event on the
+            //first message.  Additional events will be queued during
+            //the port processing as needed.
+            if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
+                QueuePortActivity(aActivity);
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            if (aActivity.iPort->IncomingMsgQueueSize() == 1)
+                QueuePortActivity(aActivity);
+            break;
+
+        case PVMF_PORT_ACTIVITY_DELETED:
+            //Report port deleted info event to the node.
+            ReportInfoEvent(PVMFInfoPortDeleted
+                            , (OsclAny*)aActivity.iPort);
+            //Purge any port activity events already queued
+            //for this port.
+            {
+                for (uint32 i = 0;i < iPortActivityQueue.size();)
+                {
+                    if (iPortActivityQueue[i].iPort == aActivity.iPort)
+                        iPortActivityQueue.erase(&iPortActivityQueue[i]);
+                    else
+                        i++;
+                }
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECT:
+            //nothing needed.
+            break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            //nothing needed.
+            break;
+        default:
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////
+// Port Processing routines
+/////////////////////////////////////////////////////
+
+void PVMFDummyFileOutputNode::QueuePortActivity(const PVMFPortActivity &aActivity)
+{
+    //queue a new port activity event
+    int32 err;
+    OSCL_TRY(err, iPortActivityQueue.push_back(aActivity););
+    if (err != OsclErrNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFDummyFileOutputNode::PortActivity: Error - iPortActivityQueue.push_back() failed", this));
+        ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+    }
+    else
+    {
+        //wake up the AO to process the port activity event.
+        RunIfNotReady();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::ProcessIncomingData(PVMFSharedMediaDataPtr aMediaData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::ProcessIncomingData()"));
+
+    PVMFStatus status = PVMFSuccess;
+
+    OsclRefCounterMemFrag frag;
+    uint32 numFrags = aMediaData->getNumFragments();
+    OsclRefCounterMemFrag formatSpecificInfo;
+    aMediaData->getFormatSpecificInfo(formatSpecificInfo);
+
+    for (uint32 i = 0; (i < numFrags) && status == PVMFSuccess; i++)
+    {
+        aMediaData->getMediaFragment(i, frag);
+        switch (iInterfaceState)
+        {
+            case EPVMFNodeStarted:
+
+                break;
+
+            case EPVMFNodeInitialized:
+                // Already stopped. Ignore incoming data.
+                break;
+
+            default:
+                // Wrong state
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFDummyFileOutputNode::ProcessIncomingData: Error - Wrong state"));
+                status = PVMFFailure;
+                break;
+        }
+    }
+
+    return status;
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::SendDurationProgress(uint32 aTimestamp)
+{
+
+    if (iDurationReportEnabled &&
+            aTimestamp >= iNextDurationReport)
+    {
+        iNextDurationReport = aTimestamp - (aTimestamp % iDurationReportFreq) + iDurationReportFreq;
+        ReportInfoEvent(PVMF_COMPOSER_DURATION_PROGRESS, (OsclAny*)aTimestamp);
+    }
+    return PVMFSuccess;
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::SendFileSizeProgress()
+{
+    if (iFileSizeReportEnabled &&
+            iFileSize >= iNextFileSizeReport)
+    {
+        iNextFileSizeReport = iFileSize - (iFileSize % iFileSizeReportFreq) + iFileSizeReportFreq;
+        ReportInfoEvent(PVMF_COMPOSER_FILESIZE_PROGRESS, (OsclAny*)iFileSize);
+    }
+    return PVMFSuccess;
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::CheckMaxFileSize(uint32 aFrameSize)
+{
+    if (iMaxFileSizeEnabled)
+    {
+        if ((iFileSize + aFrameSize) >= iMaxFileSize)
+        {
+            // Change state to initialized
+            ChangeNodeState(EPVMFNodeInitialized);
+
+            // Clear all pending port activity
+            ClearPendingPortActivity();
+
+            // Report max file size event
+            ReportInfoEvent(PVMF_COMPOSER_MAXFILESIZE_REACHED, NULL);
+            return PVMFSuccess;
+        }
+
+        return PVMFPending;
+    }
+    return PVMFErrNotSupported;
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::CheckMaxDuration(uint32 aTimestamp)
+{
+    if (iMaxDurationEnabled)
+    {
+        if (aTimestamp >= iMaxDuration)
+        {
+            // Change state to initialized
+            ChangeNodeState(EPVMFNodeInitialized);
+
+            // Clear all pending port activity
+            ClearPendingPortActivity();
+
+            // Report max duration event
+            ReportInfoEvent(PVMF_COMPOSER_MAXDURATION_REACHED, NULL);
+            return PVMFSuccess;
+        }
+
+        return PVMFPending;
+    }
+    return PVMFErrNotSupported;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::ClearPendingPortActivity()
+{
+    // index starts at 1 because the current command (i.e. iCmdQueue[0]) will be
+    // erased inside Run
+
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+    }
+}
+
+void PVMFDummyFileOutputNode::ChangeNodeState(TPVMFNodeInterfaceState aNewState)
+{
+    iInterfaceState = aNewState;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+void PVMFDummyFileOutputNode::CommandComplete(PVMFDummyFileOutputNodeCmdQ& aCmdQ, PVMFDummyFileOutputNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFDummyFileOutputNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
+                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+}
+
+PVMFCommandId PVMFDummyFileOutputNode::QueueCommandL(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iInputCommands.AddL(aCmd);
+
+    //wakeup the AO
+    RunIfNotReady();
+
+    return id;
+}
+
+
+/////////////////////////////////////////////////////
+bool PVMFDummyFileOutputNode::ProcessPortActivity()
+{//called by the AO to process a port activity message
+    //Pop the queue...
+    PVMFPortActivity activity(iPortActivityQueue.front());
+    iPortActivityQueue.erase(&iPortActivityQueue.front());
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFDummyFileOutputNode::ProcessPortActivity: port=0x%x, type=%d",
+                     this, activity.iPort, activity.iType));
+
+    int32 err = OsclErrNone;
+
+    PVMFStatus status = PVMFSuccess;
+    switch (activity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            status = ProcessIncomingMsg(activity.iPort);
+            //if there is still data, queue another port activity event.
+            //tbd-- do we need to do this even if port is busy?
+            if (activity.iPort->IncomingMsgQueueSize() > 0)
+            {
+                OSCL_TRY(err, iPortActivityQueue.push_back(activity););
+            }
+            break;
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+        default:
+            return false;
+            // break;	This statement was removed to avoid compiler warning for Unreachable Code
+    }
+
+    return true;
+}
+
+/////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
+{
+    //Called by the AO to process one buffer off the port's
+    //incoming data queue.  This routine will dequeue and
+    //dispatch the data.
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFDummyFileOutputNode::ProcessIncomingMsg: aPort=0x%x", this, aPort));
+
+    if (aPort->GetPortTag() != PVMF_DUMMY_FILE_OUTPUT_NODE_PORT_TYPE_SINK)
+    {
+        return PVMFFailure;
+    }
+    PVMFSharedMediaMsgPtr msg;
+    PVMFStatus status = aPort->DequeueIncomingMsg(msg);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFDummyFileOutputNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed", this));
+        return status;
+    }
+    /*
+       INFORMATION!!!
+       The FileOutputNode is generally used by the engine unit tests as SinkNode
+       For now, most of the unit tests have OBSOLETED the use of FileOutputNode,
+       But still some of the tests are using the FileOutputNode in place of,
+       MIO (RefFileOutput).
+
+       Since the usage FileOutputNode is not defined yet, we are adding support for
+       BOS Message as a NO-OP so that the node should be able to handle Any and all
+       the BOS Messages gracefully.
+
+       IMPORTANT!!!,
+       For Complete support of BOS in the FileOutputNode, we need to make more changes.
+       Those changes will be done only once the life scope of FileOutputNode is defined.
+    */
+    if (msg->getFormatID() == PVMF_MEDIA_CMD_BOS_FORMAT_ID)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVFileOutputNode::ProcessIncomingMsg BOS Recieved"));
+        return PVMFSuccess;
+    }
+
+    // Transfer to the port's sync queue to do synchronization
+    // This is temporary until data is directly saved to the sync queue
+    uint32 dropped;
+    uint32 skipped;
+    status = ((PVMFDummyFileOutputInPort*)aPort)->iDataQueue.QueueMediaData(msg, &dropped, &skipped);
+    if (dropped > 0)
+    {
+        PVMFNodeInterface::ReportInfoEvent(PVMFInfoDataDiscarded);
+    }
+
+    if (status == PVMFErrNoMemory)
+    {
+        return PVMFFailure;
+    }
+    else
+    {
+        return PVMFSuccess;
+    }
+}
+
+bool PVMFDummyFileOutputNode::ProcessCommand(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    //normally this node will not start processing one command
+    //until the prior one is finished.  However, a hi priority
+    //command such as Cancel must be able to interrupt a command
+    //in progress.
+    if (!iCurrentCommand.empty() && !aCmd.hipri())
+        return false;
+
+    switch (aCmd.iCmd)
+    {
+        case PVMF_GENERIC_NODE_QUERYUUID:
+            DoQueryUuid(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_INIT:
+            DoInit(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PREPARE:
+            DoPrepare(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_START:
+            DoStart(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_STOP:
+            DoStop(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_FLUSH:
+            DoFlush(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PAUSE:
+            DoPause(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RESET:
+            DoReset(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+            DoCancelAllCommands(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELCOMMAND:
+            DoCancelCommand(aCmd);
+            break;
+
+        default://unknown command type
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            break;
+    }
+
+    return true;
+}
+
+/**
+//A routine to tell if a flush operation is in progress.
+*/
+bool PVMFDummyFileOutputNode::FlushPending()
+{
+    return (iCurrentCommand.size() > 0
+            && iCurrentCommand.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
+}
+
+void PVMFDummyFileOutputNode::DoQueryUuid(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    //This node supports Query UUID from any state
+
+    OSCL_String* mimetype;
+    Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
+    bool exactmatch;
+    aCmd.PVMFDummyFileOutputNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
+
+    //Try to match the input mimetype against any of
+    //the custom interfaces for this node
+    //Match against custom interface1...
+    if (*mimetype == PVMF_FILE_OUTPUT_NODE_CUSTOM1_MIMETYPE
+            //also match against base mimetypes for custom interface1,
+            //unless exactmatch is set.
+            || (!exactmatch && *mimetype == PVMF_FILE_OUTPUT_NODE_MIMETYPE)
+            || (!exactmatch && *mimetype == PVMF_BASEMIMETYPE))
+    {
+
+        //PVUuid uuid(PVMF_SOCKET_NODE_CUSTOM1_UUID);
+        uuidvec->push_back(PVMFDummyFileOutputNodeConfigUuid);
+        uuidvec->push_back(PvmfComposerSizeAndDurationUuid);
+        uuidvec->push_back(PvmfNodesSyncControlUuid);
+    }
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+void PVMFDummyFileOutputNode::DoQueryInterface(PVMFDummyFileOutputNodeCommand&  aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::DoQueryInterface"));
+
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVMFDummyFileOutputNodeCommandBase::Parse(uuid, ptr);
+
+    if (queryInterface(*uuid, *ptr))
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+}
+
+void PVMFDummyFileOutputNode::DoInit(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVMFStatus iRet = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            //this node doesn't need to do anything to get ready
+            //to start.
+            SetState(EPVMFNodeInitialized);
+            break;
+        case EPVMFNodeInitialized:
+            break;
+        default:
+            iRet = PVMFErrInvalidState;
+            break;
+    }
+    CommandComplete(iInputCommands, aCmd, iRet);
+}
+
+/**
+//Called by the command handler AO to do the node Prepare
+*/
+void PVMFDummyFileOutputNode::DoPrepare(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVMFStatus iRet = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+            //this node doesn't need to do anything to get ready
+            //to start.
+            SetState(EPVMFNodePrepared);
+            break;
+        case EPVMFNodePrepared:
+            break;
+        default:
+            iRet = PVMFErrInvalidState;
+            break;
+    }
+    CommandComplete(iInputCommands, aCmd, iRet);
+}
+
+void PVMFDummyFileOutputNode::DoStart(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVMFStatus status = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodePrepared:
+        case EPVMFNodePaused:
+        {
+            if (!iClock)
+            {
+                // If not using sync clock, start processing incoming data
+                ((PVMFDummyFileOutputInPort*)iInPort)->Start();
+            }
+            if (!iFileOpened)
+            {
+                if (iFs.Connect() != 0)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFDummyFileOutputNode::DoStart: iFs.Connect Error."));
+                    status = PVMFErrNoResources;
+                    break;
+                }
+
+                if (0 != iOutputFile.Open(iOutputFileName.get_cstr(), Oscl_File::MODE_READWRITE | Oscl_File::MODE_BINARY, iFs))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFDummyFileOutputNode::DoStart: iOutputFile.Open Error."));
+                    status = PVMFErrNoResources;
+                    break;
+                }
+
+                iFileOpened = 1;
+
+                iFirstMediaData = true;
+            }
+            SetState(EPVMFNodeStarted);
+
+            break;
+        }
+        case EPVMFNodeStarted:
+            status = PVMFSuccess;
+            break;
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+
+    CommandComplete(iInputCommands, aCmd, status);
+}
+
+void PVMFDummyFileOutputNode::DoStop(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            // Stop data source
+            if (iInPort)
+            {
+
+                ((PVMFDummyFileOutputInPort*)iInPort)->Stop();
+                CloseOutputFile();
+            }
+
+            // Clear queued messages in ports
+            uint32 i;
+            for (i = 0; i < iPortVector.size(); i++)
+                iPortVector[i]->ClearMsgQueues();
+
+            // Clear scheduled port activities
+            iPortActivityQueue.clear();
+
+            //transition to Initialized state
+            SetState(EPVMFNodePrepared);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        case EPVMFNodePrepared:
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+void PVMFDummyFileOutputNode::DoFlush(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            //the flush is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until the flush completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            //Notify all ports to suspend their input
+            {
+                for (uint32 i = 0;i < iPortVector.size();i++)
+                    iPortVector[i]->SuspendInput();
+            }
+
+            // Stop data source
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+void PVMFDummyFileOutputNode::DoPause(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        {
+            // Pause data source
+            if (!iClock)
+            {
+                // If not using sync clock, pause processing of incoming data
+                ((PVMFDummyFileOutputInPort*)iInPort)->Pause();
+            }
+
+            SetState(EPVMFNodePaused);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        }
+        case EPVMFNodePaused:
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        }
+        break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+void PVMFDummyFileOutputNode::DoReset(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    if (IsAdded())
+    {
+        if (iInPort)
+        {
+            OSCL_DELETE(((PVMFDummyFileOutputInPort*)iInPort));
+            iInPort = NULL;
+        }
+
+        //logoff & go back to Created state.
+        SetState(EPVMFNodeIdle);
+        ThreadLogoff();
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+    }
+}
+
+
+void PVMFDummyFileOutputNode::DoRequestPort(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::DoRequestPort"));
+    //This node supports port request from any state
+
+    //retrieve port tag.
+    int32 tag;
+    OSCL_String* portconfig;
+
+    aCmd.PVMFDummyFileOutputNodeCommandBase::Parse(tag, portconfig);
+
+    //validate the tag...
+    switch (tag)
+    {
+        case PVMF_DUMMY_FILE_OUTPUT_NODE_PORT_TYPE_SINK:
+            break;
+        default:
+            //bad port tag
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFDummyFileOutputNode::DoRequestPort: Error - Invalid port tag"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            return;
+    }
+
+    if (iInPort)
+    {
+        // it's been taken for now, so reject this request
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+        return;
+    }
+
+    // Create and configure output port
+    int32 err;
+    PVMFFormatType fmt = PVMF_MIME_FORMAT_UNKNOWN;
+    if (portconfig)
+    {
+        fmt = portconfig->get_str();
+    }
+
+    if (iFormat != PVMF_MIME_FORMAT_UNKNOWN &&
+            iFormat != fmt)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileOutputNode::DoRequestPort: Error - Format not supported (format was preset)"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+        return;
+    }
+
+    OSCL_TRY(err, iInPort = OSCL_NEW(PVMFDummyFileOutputInPort, (tag, this)););
+    if (err != OsclErrNone || !iInPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFDummyFileOutputNode::DoRequestPort: Error - PVMFDummyFileOutputInPort::Create() failed"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        return;
+    }
+
+    ((PVMFDummyFileOutputInPort*)iInPort)->SetClock(iClock);
+    ((PVMFDummyFileOutputInPort*)iInPort)->SetMargins(iEarlyMargin, iLateMargin);
+
+    //if format was provided in mimestring, set it now.
+    if (portconfig)
+    {
+        PVMFFormatType fmt = portconfig->get_str();
+        if (fmt != PVMF_MIME_FORMAT_UNKNOWN
+                && ((PVMFDummyFileOutputInPort*)iInPort)->IsFormatSupported(fmt))
+        {
+            ((PVMFDummyFileOutputInPort*)iInPort)->iFormat = fmt;
+            ((PVMFDummyFileOutputInPort*)iInPort)->FormatUpdated();
+        }
+    }
+
+    //Return the port pointer to the caller.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)iInPort);
+}
+
+void PVMFDummyFileOutputNode::DoReleasePort(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::DoReleasePort"));
+
+    if (iInPort)
+    {
+        OSCL_DELETE(((PVMFDummyFileOutputInPort*)iInPort));
+        iInPort = NULL;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        return;
+    }
+    CommandComplete(iInputCommands, aCmd, PVMFFailure);
+}
+
+void PVMFDummyFileOutputNode::DoCancelAllCommands(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFDummyFileOutputNode::DoCancelAllCommands"));
+    //first cancel the current command if any
+    {
+        while (!iCurrentCommand.empty())
+            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
+    }
+
+    //next cancel all queued commands
+    {
+        //start at element 1 since this cancel command is element 0.
+        while (iInputCommands.size() > 1)
+            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
+    }
+
+    //finally, report cancel complete.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+void PVMFDummyFileOutputNode::DoCancelCommand(PVMFDummyFileOutputNodeCommand& aCmd)
+{
+    //extract the command ID from the parameters.
+    PVMFCommandId id;
+    aCmd.PVMFDummyFileOutputNodeCommandBase::Parse(id);
+
+    //first check "current" command if any
+    {
+        PVMFDummyFileOutputNodeCommand* cmd = iCurrentCommand.FindById(id);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+
+    //next check input queue.
+    {
+        //start at element 1 since this cancel command is element 0.
+        PVMFDummyFileOutputNodeCommand* cmd = iInputCommands.FindById(id, 1);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+    //if we get here the command isn't queued so the cancel fails.
+    CommandComplete(iInputCommands, aCmd, PVMFFailure);
+}
diff --git a/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node.h b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node.h
new file mode 100644
index 0000000..50a08e0
--- /dev/null
+++ b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node.h
@@ -0,0 +1,451 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_fileoutput_node.h
+ * @brief Simple file output node. Writes incoming data to specified
+ * file without any media type specific file format
+ *
+ */
+
+#ifndef PVMF_FILEOUTPUT_NODE_H_INCLUDED
+#define PVMF_FILEOUTPUT_NODE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+#ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
+#include "pvmf_dummy_fileoutput_config.h"
+#endif
+#ifndef PVMF_FILEOUTPUT_FACTORY_H_INCLUDED
+#include "pvmf_dummy_fileoutput_factory.h"
+#endif
+#ifndef PVMF_COMPOSER_SIZE_AND_DURATION_H_INCLUDED
+#include "pvmf_composer_size_and_duration.h"
+#endif
+#ifndef PVMF_NODES_SYNC_CONTROL_H_INCLUDED
+#include "pvmf_nodes_sync_control.h"
+#endif
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+#ifndef PVMF_FILEOUTPUT_INPORT_H
+#include "pvmf_dummy_fileoutput_inport.h"
+#endif
+
+// Macros for AMR header
+#define	AMR_HEADER		"#!AMR\n"
+#define AMR_HEADER_SIZE	6
+
+////////////////////////////////////////////////////////////////////////////
+class PVMFFileOutputAlloc : public Oscl_DefAlloc
+{
+    public:
+        void* allocate(const uint32 size)
+        {
+            void* tmp = (void*)oscl_malloc(size);
+            return tmp;
+        }
+
+        void deallocate(void* p)
+        {
+            oscl_free(p);
+        }
+};
+
+////////////////////////////////////////////////////////////////////////////
+//Default vector reserve size
+#define PVMF_FILE_OUTPUT_NODE_COMMAND_VECTOR_RESERVE 10
+
+//Starting value for command IDs
+#define PVMF_FILE_OUTPUT_NODE_COMMAND_ID_START 6000
+
+//memory allocator type for this node.
+typedef OsclMemAllocator PVMFDummyFileOutputNodeAllocator;
+
+// Forward declaration
+class PVMFFileOutputInPort;
+class PVLogger;
+
+//Node command type.
+typedef PVMFGenericNodeCommand<PVMFDummyFileOutputNodeAllocator> PVMFDummyFileOutputNodeCommandBase;
+class PVMFDummyFileOutputNodeCommand: public PVMFDummyFileOutputNodeCommandBase
+{
+    public:
+        //constructor for Custom2 command
+        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
+        {
+            PVMFDummyFileOutputNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)arg1;
+            iParam2 = (OsclAny*)arg2;
+            iParam3 = (OsclAny*) & arg3;
+        }
+        void Parse(int32&arg1, int32&arg2, int32*&arg3)
+        {
+            arg1 = (int32)iParam1;
+            arg2 = (int32)iParam2;
+            arg3 = (int32*)iParam3;
+        }
+
+        enum PVFileOutputNodeCmdType
+        {
+            PVFILEOUTPUT_NODE_CMD_QUERYUUID,
+            PVFILEOUTPUT_NODE_CMD_QUERYINTERFACE,
+            PVFILEOUTPUT_NODE_CMD_INIT,
+            PVFILEOUTPUT_NODE_CMD_REQUESTPORT,
+            PVFILEOUTPUT_NODE_CMD_START,
+            PVFILEOUTPUT_NODE_CMD_PAUSE,
+            PVFILEOUTPUT_NODE_CMD_STOP,
+            PVFILEOUTPUT_NODE_CMD_RELEASEPORT,
+            PVFILEOUTPUT_NODE_CMD_RESET,
+            PVFILEOUTPUT_NODE_CMD_CANCELCMD,
+            PVFILEOUTPUT_NODE_CMD_CANCELALL,
+            PVFILEOUTPUT_NODE_CMD_SKIPMEDIADATA,
+            PVFILEOUTPUT_NODE_CMD_INVALID
+        };
+};
+//Command queue type
+typedef PVMFNodeCommandQueue<PVMFDummyFileOutputNodeCommand, PVMFDummyFileOutputNodeAllocator> PVMFDummyFileOutputNodeCmdQ;
+
+//Mimetypes for the custom interface
+#define PVMF_FILE_OUTPUT_NODE_CUSTOM1_MIMETYPE "pvxxx/FileOutputNode/Custom1"
+#define PVMF_FILE_OUTPUT_NODE_MIMETYPE "pvxxx/FileOutputNode"
+#define PVMF_BASEMIMETYPE "pvxxx"
+
+////////////////////////////////////////////////////////////////////////////
+class PVMFDummyFileOutputNode :	public OsclActiveObject, public PVMFNodeInterface,
+            public PVMFDummyFileOutputNodeConfigInterface,
+            public PvmfComposerSizeAndDurationInterface,
+            public PvmfNodesSyncControlInterface,
+            public PvmiCapabilityAndConfig
+{
+    public:
+        PVMFDummyFileOutputNode(int32 aPriority);
+        ~PVMFDummyFileOutputNode();
+
+        // Virtual functions of PVMFNodeInterface
+        PVMFStatus ThreadLogon();
+        PVMFStatus ThreadLogoff();
+        PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+        PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
+                                Oscl_Vector<PVUuid, PVMFDummyFileOutputNodeAllocator>& aUuids,
+                                bool aExactUuidsOnly = false,
+                                const OsclAny* aContext = NULL);
+        PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                                     PVInterface*& aInterfacePtr,
+                                     const OsclAny* aContext = NULL);
+
+        PVMFCommandId RequestPort(PVMFSessionId aSession
+                                  , int32 aPortTag
+                                  , const PvmfMimeString* aPortConfig = NULL
+                                                                        , const OsclAny* aContext = NULL);
+
+        PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+        PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
+        PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+
+        // Pure virtual from PvInterface
+        void addRef();
+        void removeRef();
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+        //from PVMFPortActivityHandler
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        // Pure virtual from PVMFDummyFileOutputNodeConfigInterface
+        PVMFStatus SetOutputFileName(const OSCL_wString& aFileName)
+        {
+            OSCL_UNUSED_ARG(aFileName);
+            return 0;
+        }
+
+        // Pure virtual from PvmfComposerSizeAndDurationInterface
+        PVMFStatus SetMaxFileSize(bool aEnable, uint32 aMaxFileSizeBytes)
+        {
+            OSCL_UNUSED_ARG(aEnable);
+            OSCL_UNUSED_ARG(aMaxFileSizeBytes);
+            return 0;
+        }
+        void GetMaxFileSizeConfig(bool& aEnable, uint32& aMaxFileSizeBytes)
+        {
+            OSCL_UNUSED_ARG(aEnable);
+            OSCL_UNUSED_ARG(aMaxFileSizeBytes);
+        }
+        PVMFStatus SetMaxDuration(bool aEnable, uint32 aMaxDurationMilliseconds);
+        void GetMaxDurationConfig(bool& aEnable, uint32& aMaxDurationMilliseconds);
+        PVMFStatus SetFileSizeProgressReport(bool aEnable, uint32 aReportFrequency)
+        {
+            OSCL_UNUSED_ARG(aEnable);
+            OSCL_UNUSED_ARG(aReportFrequency);
+            return 0;
+        }
+        void GetFileSizeProgressReportConfig(bool& aEnable, uint32& aReportFrequency)
+        {
+            OSCL_UNUSED_ARG(aEnable);
+            OSCL_UNUSED_ARG(aReportFrequency);
+        }
+        PVMFStatus SetDurationProgressReport(bool aEnable, uint32 aReportFrequency);
+        void GetDurationProgressReportConfig(bool& aEnable, uint32& aReportFrequency);
+
+        // Pure virtuals from PvmfNodesSyncControlInterface
+        PVMFStatus SetClock(PVMFMediaClock* aClock);
+        PVMFStatus ChangeClockRate(int32 aRate);
+        PVMFStatus SetMargins(int32 aEarlyMargin, int32 aLateMargin);
+        void ClockStarted(void);
+        void ClockStopped(void);
+        PVMFCommandId SkipMediaData(PVMFSessionId aSessionId,
+                                    PVMFTimestamp aResumeTimestamp,
+                                    uint32 aStreamID,
+                                    bool aPlayBackPositionContinuous = false,
+                                    OsclAny* aContext = NULL);
+
+        friend class PVMFDummyFileOutputInPort;
+        friend class PVMFDummyFileOutputNodeFactory;
+
+
+        // implemetation of PvmiCapabilityAndConfig class functions here
+
+        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+
+        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                                     PvmiKvp*& aParameters, int& num_parameter_elements,
+                                     PvmiCapabilityContext aContext);
+        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                                  PvmiKvp* aParameters, int num_parameter_elements);
+        void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                               int num_elements, PvmiKvp * & aRet_kvp);
+        PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                         int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        // function used in VerifyParametersSync n SetParametersSync of capability class
+        PVMFStatus VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam);
+
+        // function used in getParametersSync of capability class
+        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
+
+
+    private:
+        void ConstructL();
+        void Run();
+
+        void CommandComplete(PVMFDummyFileOutputNodeCmdQ&, PVMFDummyFileOutputNodeCommand&, PVMFStatus, OsclAny* aData = NULL);
+
+        PVMFCommandId QueueCommandL(PVMFDummyFileOutputNodeCommand& aCmd);
+        /**
+         * Process a port activity. This method is called by Run to process a port activity.
+         *
+         */
+        bool ProcessPortActivity();
+        void QueuePortActivity(const PVMFPortActivity &aActivity);
+
+        bool ProcessCommand(PVMFDummyFileOutputNodeCommand&);
+        bool FlushPending();
+
+        //Command handlers.
+        void DoReset(PVMFDummyFileOutputNodeCommand&);
+        void DoQueryUuid(PVMFDummyFileOutputNodeCommand&);
+        void DoQueryInterface(PVMFDummyFileOutputNodeCommand&);
+        void DoRequestPort(PVMFDummyFileOutputNodeCommand&);
+        void DoReleasePort(PVMFDummyFileOutputNodeCommand&);
+        void DoInit(PVMFDummyFileOutputNodeCommand&);
+        void DoPrepare(PVMFDummyFileOutputNodeCommand&);
+        void DoStart(PVMFDummyFileOutputNodeCommand&);
+        void DoStop(PVMFDummyFileOutputNodeCommand&);
+        void DoFlush(PVMFDummyFileOutputNodeCommand&);
+        void DoPause(PVMFDummyFileOutputNodeCommand&);
+        void DoCancelAllCommands(PVMFDummyFileOutputNodeCommand&);
+        void DoCancelCommand(PVMFDummyFileOutputNodeCommand&);
+
+
+        void CloseOutputFile();
+        void ChangeNodeState(TPVMFNodeInterfaceState aNewState);
+
+        // Handle command and data events
+        PVMFStatus ProcessIncomingData(PVMFSharedMediaDataPtr aMediaData);
+
+        PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
+
+        /**
+         * Send file size progress report if enabled.
+         * @return PVMFFailure if informational observer is not set, else PVMFSuccess
+         */
+        PVMFStatus SendFileSizeProgress();
+
+        /**
+         * Send duration progress report if enabled.
+         * @param aTimestamp Timestamp of current frame in milliseconds.
+         * @return PVMFFailure if informational observer is not set, else PVMFSuccess
+         */
+        PVMFStatus SendDurationProgress(uint32 aTimestamp);
+
+        /**
+         * Check if maximum file size or duration is reached if a maximum is set.
+         *
+         * @param aFrameSize Size of current frame in bytes.
+         * @return PVMFSuccess if feature is enabled and the maximum file size / duration is reached.
+         *         PVMFPending if feature is enabled and the max file size / duration has not been reached.
+         *         PVMFErrNotSupported if feature is not enabled.
+         *         PVMFFailure if informational observer is not set or if max file size or duration is set
+         *         but the finalizing output file failed.
+         */
+        PVMFStatus CheckMaxFileSize(uint32 aFrameSize);
+
+        /**
+         * Check if maximum file size or duration is reached if a maximum is set.
+         *
+         * @param aTimestamp Timestamp of current frame in milliseconds.
+         * @return PVMFSuccess if feature is enabled and the maximum file size / duration is reached.
+         *         PVMFPending if feature is enabled and the max file size / duration has not been reached.
+         *         PVMFErrNotSupported if feature is not enabled.
+         *         PVMFFailure if informational observer is not set or if max file size or duration is set
+         *         but the finalizing output file failed.
+         */
+        PVMFStatus CheckMaxDuration(uint32 aTimestamp);
+
+        /**
+         * Write data to output file.
+         *
+         * @param aData Data to be written to file.
+         * @param aSize Size of data to be written to file.
+         * @return PVMFSuccess if data is written, or maximum file size is reached, else PVMFFailure.
+         */
+        PVMFStatus WriteData(OsclAny* aData, uint32 aSize);
+
+        /**
+         * Write memory fragment to output file.
+         *
+         * @param aMemFrag Memory fragment object whose data has to be written to output file.
+         * @param aTimestamp Timestamp of the frame to be written in milliseconds.
+         * @return PVMFSuccess if memory fragment is written, or max file size or duration is reached, else PVMFFailure.
+         */
+        PVMFStatus WriteData(OsclRefCounterMemFrag aMemFrag, uint32 aTimestamp);
+
+        /**
+         * Write format specific info to output file.
+         *
+         * @param aData Data to be written to file.
+         * @param aSize Size of data to be written to file.
+         * @return PVMFSuccess if data is written, or maximum file size is reached, else PVMFFailure.
+         */
+        PVMFStatus WriteFormatSpecificInfo(OsclAny* aPtr, uint32 aSize)
+        {
+            OSCL_UNUSED_ARG(aPtr);
+            OSCL_UNUSED_ARG(aSize);
+            return 0;
+        }
+
+        /** Clear all pending port activity after max file size or duration is reached. */
+        void ClearPendingPortActivity();
+
+        // Queue of commands
+        PVMFCommandId iCmdIdCounter;
+
+        // Input port
+        PVMFPortInterface* iInPort;
+
+        // Output file name
+        OSCL_wHeapString<OsclMemAllocator> iOutputFileName;
+
+        // Allocator
+        Oscl_DefAlloc* iAlloc;
+
+        // Output file
+        Oscl_FileServer iFs;
+        Oscl_File iOutputFile;
+        int32 iFileOpened;
+
+        bool iFirstMediaData;
+
+        PVLogger* iLogger;
+
+        PVMFFormatType iFormat;
+
+        uint32 iExtensionRefCount;
+        PVMFNodeCapability iCapability;
+
+        PVMFDummyFileOutputNodeCmdQ iInputCommands;
+        PVMFDummyFileOutputNodeCmdQ iCurrentCommand;
+
+        PVMFPortVector<PVMFDummyFileOutputInPort, PVMFDummyFileOutputNodeAllocator> iPortVector;
+        Oscl_Vector<PVMFPortActivity, PVMFDummyFileOutputNodeAllocator> iPortActivityQueue;
+
+        // Variables for max file size and duration feature
+        bool iMaxFileSizeEnabled;
+        bool iMaxDurationEnabled;
+        uint32 iMaxFileSize;
+        uint32 iMaxDuration;
+        uint32 iFileSize;
+
+        // Variables for progress report feature
+        bool iFileSizeReportEnabled;
+        bool iDurationReportEnabled;
+        uint32 iFileSizeReportFreq;
+        uint32 iDurationReportFreq;
+        uint32 iNextFileSizeReport;
+        uint32 iNextDurationReport;
+
+        // Variables for media data queue and synchronization
+        PVMFMediaClock* iClock;
+        int32 iEarlyMargin;
+        int32 iLateMargin;
+};
+
+#endif // PVMF_FILEOUTPUT_NODE_H_INCLUDED
diff --git a/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node_cap_config.cpp b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node_cap_config.cpp
new file mode 100644
index 0000000..bc8c054
--- /dev/null
+++ b/nodes/pvdummyoutputnode/src/pvmf_dummy_fileoutput_node_cap_config.cpp
@@ -0,0 +1,512 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_FILEOUTPUT_NODE_H_INCLUDED
+#include "pvmf_dummy_fileoutput_node.h"
+#endif
+
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef PVMI_KVP_UTIL_H_INCLUDED
+#include "pvmi_kvp_util.h"
+#endif
+#define FILE_OUTPUT_NKEY_MAX_LEN 64
+struct FileOutputNodeKeyStringData
+{
+    char iString[FILE_OUTPUT_NKEY_MAX_LEN];
+    PvmiKvpType iType;
+    PvmiKvpValueType iValueType;
+};
+
+#define FILEOUTPUTNODECONFIG_BASE_NUMKEYS 2
+#define FILEOUTPUTCONFIG_KEYSTRING_SIZE 128
+
+static const FileOutputNodeKeyStringData FileOutputNodeConfig_BaseKeys[] =
+{
+    {"parameter1", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"parameter2", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+};
+
+enum BaseKeys_IndexMapType
+{
+    PARAMETER1 = 0,
+    PARAMETER2
+};
+static const uint FileOutputNodeConfig_NumBaseKeys =
+    (sizeof(FileOutputNodeConfig_BaseKeys) /
+     sizeof(FileOutputNodeKeyStringData));
+
+
+///////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFDummyFileOutputNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::GetConfigParameter() In"));
+
+    aNumParamElements = 0;
+
+    // Allocate memory for the KVP
+    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
+    if (aParameters == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::GetConfigParameter() Memory allocation for KVP failed"));
+        return PVMFErrNoMemory;
+    }
+    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
+    // Allocate memory for the key string in KVP
+    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(FILEOUTPUTCONFIG_KEYSTRING_SIZE * sizeof(char));
+    if (NULL == memblock)
+    {
+        oscl_free(aParameters);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::GetConfigParameter() Memory allocation for key string failed"));
+        return PVMFErrNoMemory;
+    }
+    oscl_strset(memblock, 0, FILEOUTPUTCONFIG_KEYSTRING_SIZE * sizeof(char));
+    // Assign the key string buffer to KVP
+    aParameters[0].key = memblock;
+
+    // Copy the key string
+    oscl_strncat(aParameters[0].key, PVMF_MIME_FILE_OUTPUT, oscl_strlen(aParameters[0].key));
+    oscl_strncat(aParameters[0].key, FileOutputNodeConfig_BaseKeys[aIndex].iString, oscl_strlen(aParameters[0].key));
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), oscl_strlen(aParameters[0].key));
+    switch (FileOutputNodeConfig_BaseKeys[aIndex].iValueType)
+    {
+        case PVMI_KVPVALTYPE_BITARRAY32:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(aParameters[0].key));
+            break;
+
+        case PVMI_KVPVALTYPE_KSV:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(aParameters[0].key));
+            break;
+
+        case PVMI_KVPVALTYPE_BOOL:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(aParameters[0].key));
+            break;
+
+        case PVMI_KVPVALTYPE_INT32:
+            if (aReqattr == PVMI_KVPATTR_CUR)
+            {
+                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(aParameters[0].key));
+            }
+            break;
+        case PVMI_KVPVALTYPE_UINT32:
+        default:
+            if (PVMI_KVPATTR_CAP == aReqattr)
+            {
+                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(aParameters[0].key));
+            }
+            else
+            {
+                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(aParameters[0].key));
+            }
+            break;
+    }
+    aParameters[0].key[FILEOUTPUTCONFIG_KEYSTRING_SIZE-1] = 0;
+
+    // Copy the requested info
+    switch (aIndex)
+    {
+        case PARAMETER1:	// "parameter1"
+            break;
+
+        case PARAMETER2:	// "parameter2"
+            break;
+
+        default:
+            // Invalid index
+            oscl_free(aParameters[0].key);
+            oscl_free(aParameters);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::GetConfigParameter() Invalid index to file output node parameter"));
+            return PVMFErrNotSupported;
+    }
+
+    aNumParamElements = 1;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::GetConfigParameter() Out"));
+    return PVMFSuccess;
+}
+
+
+PVMFStatus PVMFDummyFileOutputNode::VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam)
+{
+    OSCL_UNUSED_ARG(aSetParam);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::VerifyAndSetConfigParameter() In"));
+
+    // Determine the valtype
+    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
+    if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::VerifyAndSetConfigParameter() Valtype in key string unknown"));
+        return PVMFErrNotSupported;
+    }
+
+    // Retrieve the fourth component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(PVMF_MIME_MIN_COMP_IDX, aParameter.key, compstr);
+
+    int32 fileoutput4ind;
+    for (fileoutput4ind = 0; fileoutput4ind < FILEOUTPUTNODECONFIG_BASE_NUMKEYS; ++fileoutput4ind)
+    {
+        // Go through each component string at 4th level
+        if (pv_mime_strcmp(compstr, (char*)(FileOutputNodeConfig_BaseKeys[fileoutput4ind].iString)) >= 0)
+        {
+            // Break out of the for loop
+            break;
+        }
+    }
+
+    if (FILEOUTPUTNODECONFIG_BASE_NUMKEYS <= fileoutput4ind)
+    {
+        // Match couldn't be found or non-leaf node specified
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::VerifyAndSetConfigParameter() Unsupported key or non-leaf node"));
+        return PVMFErrNotSupported;
+    }
+
+    // Verify the valtype
+    if (keyvaltype != FileOutputNodeConfig_BaseKeys[fileoutput4ind].iValueType)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::VerifyAndSetConfigParameter() Valtype does not match for key"));
+        return PVMFErrNotSupported;
+    }
+
+    switch (fileoutput4ind)
+    {
+        case PARAMETER1: // "parameter1"
+            break;
+
+        case PARAMETER2: // "parameter2"
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::VerifyAndSetConfigParameter() Invalid index for file output node parameter"));
+            return PVMFErrNotSupported;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::VerifyAndSetConfigParameter() Out"));
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+//					PvmiCapConfigInterface Virtual Functions
+////////////////////////////////////////////////////////////////////////////
+
+void PVMFDummyFileOutputNode::createContext(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+}
+
+void PVMFDummyFileOutputNode::setContextParameters(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext,
+        PvmiKvp* aParameters,
+        int aNumElements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumElements);
+}
+
+void PVMFDummyFileOutputNode::DeleteContext(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+}
+
+PVMFCommandId PVMFDummyFileOutputNode::setParametersAsync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int aNumElements,
+        PvmiKvp*& aRet_kvp,
+        OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aRet_kvp);
+    OSCL_UNUSED_ARG(aNumElements);
+//	PVMFDummyFileOutputNodeCommand cmd;
+//	cmd.PVMFMP4FFParserNodeCommand::Construct(NULL, PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS,aSession, aParameters, aNumElements, aRet_kvp, aContext);
+//	return QueueCommandL(cmd);
+    return 0;
+}
+
+uint32 PVMFDummyFileOutputNode::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    OSCL_UNUSED_ARG(aSession);
+    return 0;
+}
+
+PVMFStatus PVMFDummyFileOutputNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::verifyParametersSync()"));
+    OSCL_UNUSED_ARG(aSession);
+
+    if (NULL == aParameters || aNumElements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::verifyParametersSync() Passed in parameter invalid"));
+        return PVMFErrArgument;
+    }
+
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if ((pv_mime_strcmp(compstr, PVMF_MIME_FILE_OUTPUT) < 0) || compcount < PVMF_MIME_MIN_COMP_CNT)
+        {
+            // First 4 components should be "x-pvmf/file/output" and there must
+            // be at least four components
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::verifyParametersSync() Unsupported key"));
+            return PVMFErrNotSupported;
+        }
+
+        if (PVMF_MIME_MIN_COMP_CNT == compcount)
+        {
+            // Verify and set the passed-in file output node setting
+            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], false);
+            if (retval != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::verifyParametersSync() Setting parameter %d failed", paramind));
+                return retval;
+            }
+        }
+        else
+        {
+            // Do not support more than 4 components right now
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::verifyParametersSync() Unsupported key"));
+            return PVMFErrNotSupported;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::verifyParametersSync() Out"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFDummyFileOutputNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::releaseParameters()"));
+    OSCL_UNUSED_ARG(aSession);
+
+    if (aParameters == NULL || aNumElements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::releaseParameters() KVP list is NULL or number of elements is 0"));
+        return PVMFErrArgument;
+    }
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aParameters[0].key);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
+
+    if ((pv_mime_strcmp(compstr, PVMF_MIME_FILE_OUTPUT) < 0) || compcount < PVMF_MIME_MIN_COMP_IDX)
+    {
+        // First 3 component should be "x-pvmf/file/output" and there must
+        // be at least four components
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::releaseParameters() Unsupported key"));
+        return PVMFErrNotSupported;
+    }
+
+    // Retrieve the third component from the key string
+    pv_mime_string_extract_type(PVMF_MIME_MIN_COMP_IDX, aParameters[0].key, compstr);
+
+    // Go through each KVP and release memory for value if allocated from heap
+    for (int32 ii = 0; ii < aNumElements; ++ii)
+    {
+        // Next check if it is a value type that allocated memory
+        PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
+        if (kvptype == PVMI_KVPTYPE_VALUE || kvptype == PVMI_KVPTYPE_UNKNOWN)
+        {
+            PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
+            if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::releaseParameters() Valtype not specified in key string"));
+                return PVMFErrNotSupported;
+            }
+
+            if ((PVMI_KVPVALTYPE_CHARPTR == keyvaltype) && NULL != (aParameters[ii].value.pChar_value))
+            {
+                oscl_free(aParameters[ii].value.pChar_value);
+                aParameters[ii].value.pChar_value = NULL;
+            }
+            else if ((PVMI_KVPVALTYPE_KSV == keyvaltype) && NULL != (aParameters[ii].value.key_specific_value))
+            {
+                oscl_free(aParameters[ii].value.key_specific_value);
+                aParameters[ii].value.key_specific_value = NULL;
+            }
+            else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
+            {
+                range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
+                aParameters[ii].value.key_specific_value = NULL;
+                oscl_free(rui32);
+            }
+            // TODO Add more types if file output node starts returning more types
+        }
+    }
+
+    // file output node allocated its key strings in one chunk so just free the first key string ptr
+    oscl_free(aParameters[0].key);
+
+    // Free memory for the parameter list
+    oscl_free(aParameters);
+    aParameters = NULL;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::releaseParameters() Out"));
+    return PVMFSuccess;
+}
+
+
+
+PVMFStatus PVMFDummyFileOutputNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::getParametersSync()"));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+
+    // Initialize the output parameters
+    aNumParamElements = 0;
+    aParameters = NULL;
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aIdentifier);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aIdentifier, compstr);
+
+    if ((pv_mime_strcmp(compstr, PVMF_MIME_FILE_OUTPUT) < 0) || compcount < PVMF_MIME_MIN_COMP_CNT)
+    {
+        // First 4 components should be "x-pvmf/file/output" and there must
+        // be at least 4 components
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::getParametersSync() Invalid key string"));
+        return PVMFErrNotSupported;
+    }
+    // Retrieve the fourth component from the key string
+    pv_mime_string_extract_type(PVMF_MIME_MIN_COMP_IDX, aIdentifier, compstr);
+
+    for (int32 fileoutput4ind = 0; fileoutput4ind < FILEOUTPUTNODECONFIG_BASE_NUMKEYS; ++fileoutput4ind)
+    {
+        // Go through each file output  component string at 4th level
+        if (pv_mime_strcmp(compstr, (char*)(FileOutputNodeConfig_BaseKeys[fileoutput4ind].iString)) >= 0)
+        {
+            if (PVMF_MIME_MIN_COMP_CNT == compcount)
+            {
+                // Determine what is requested
+                PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
+                if (reqattr == PVMI_KVPATTR_UNKNOWN)
+                {
+                    reqattr = PVMI_KVPATTR_CUR;
+                }
+
+                // Return the requested info
+                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, fileoutput4ind, reqattr);
+                if (retval != PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::getParametersSync() Retrieving file output node parameter failed"));
+                    return retval;
+                }
+            }
+            else
+            {
+                // Right now file output node doesn't support more than 4 components
+                // for this sub-key string so error out
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::getParametersSync() Unsupported key"));
+                return PVMFErrNotSupported;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::getParametersSync() Out"));
+    if (0 == aNumParamElements)
+    {
+        // If no one could get the parameter, return error
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::getParametersSync() Unsupported key"));
+        return PVMFFailure;
+    }
+    else
+    {
+        return PVMFSuccess;
+    }
+}
+
+void PVMFDummyFileOutputNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::setParametersSync()"));
+    OSCL_UNUSED_ARG(aSession);
+    // Complete the request synchronously
+
+    if (NULL == aParameters || aNumElements < 1)
+    {
+        if (aParameters)
+        {
+            aRetKVP = aParameters;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::setParametersSync() Passed in parameter invalid"));
+        return;
+    }
+
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if ((pv_mime_strcmp(compstr, PVMF_MIME_FILE_OUTPUT) < 0) || compcount < PVMF_MIME_MIN_COMP_CNT)
+        {
+            // First 3 components should be "x-pvmf/file/output" and there must
+            // be at least four components
+            aRetKVP = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::setParametersSync() Unsupported key"));
+            return;
+        }
+
+        if (PVMF_MIME_MIN_COMP_CNT == compcount)
+        {
+            // Verify and set the passed-in mp4 file output node setting
+            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
+            if (PVMFSuccess != retval)
+            {
+                aRetKVP = &aParameters[paramind];
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::setParametersSync() Setting parameter %d failed", paramind));
+                return;
+            }
+        }
+        else
+        {
+            // Do not support more than 5 components right now
+            aRetKVP = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFDummyFileOutputNode::setParametersSync() Unsupported key"));
+            return;
+        }
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFDummyFileOutputNode::setParametersSync() Out"));
+}
+
+
+void PVMFDummyFileOutputNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    ciObserver = aObserver;
+}
diff --git a/nodes/pvfileoutputnode/Android.mk b/nodes/pvfileoutputnode/Android.mk
index efa295a..82caa1a 100644
--- a/nodes/pvfileoutputnode/Android.mk
+++ b/nodes/pvfileoutputnode/Android.mk
@@ -3,30 +3,33 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_fileoutput_inport.cpp \
-	src/pvmf_fileoutput_node.cpp \
-	src/pvmf_fileoutput_factory.cpp \
-	src/pvmf_fileoutput_node_cap_config.cpp
-
+ 	src/pvmf_fileoutput_node.cpp \
+ 	src/pvmf_fileoutput_factory.cpp \
+ 	src/pvmf_fileoutput_node_cap_config.cpp
 
 
 LOCAL_MODULE := libpvfileoutputnode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvfileoutputnode/include \
-	$(PV_TOP)//nodes/pvfileoutputnode/src \
-	$(PV_TOP)//nodes/pvfileoutputnode/include \
-	$(PV_TOP)//nodes/pvfileoutputnode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvfileoutputnode/../common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvfileoutputnode/src \
+ 	$(PV_TOP)/nodes/pvfileoutputnode/include \
+ 	$(PV_TOP)/nodes/pvfileoutputnode/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvmf_fileoutput_config.h\
-	include/pvmf_fileoutput_factory.h
+	include/pvmf_fileoutput_config.h \
+ 	include/pvmf_fileoutput_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvfileoutputnode/build/make/local.mk b/nodes/pvfileoutputnode/build/make/local.mk
new file mode 100644
index 0000000..b9faf63
--- /dev/null
+++ b/nodes/pvfileoutputnode/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvfileoutputnode
+
+
+
+
+XINCDIRS += ../../include ../../../../pvmi/pvmf/include ../../../common/include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_fileoutput_inport.cpp \
+	pvmf_fileoutput_node.cpp \
+	pvmf_fileoutput_factory.cpp \
+	pvmf_fileoutput_node_cap_config.cpp
+
+HDRS := pvmf_fileoutput_config.h\
+	pvmf_fileoutput_factory.h
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvfileoutputnode/build/make/makefile b/nodes/pvfileoutputnode/build/make/makefile
deleted file mode 100644
index 068cbbb..0000000
--- a/nodes/pvfileoutputnode/build/make/makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvfileoutputnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../include -I../../../../pvmi/pvmf/include -I../../../common/include 
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_fileoutput_inport.cpp \
-	pvmf_fileoutput_node.cpp \
-	pvmf_fileoutput_factory.cpp \
-	pvmf_fileoutput_node_cap_config.cpp
-
-HDRS =  pvmf_fileoutput_config.h\
-	pvmf_fileoutput_factory.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvfileoutputnode/include/pvmf_fileoutput_config.h b/nodes/pvfileoutputnode/include/pvmf_fileoutput_config.h
index 0d01170..d6bda9c 100644
--- a/nodes/pvfileoutputnode/include/pvmf_fileoutput_config.h
+++ b/nodes/pvfileoutputnode/include/pvmf_fileoutput_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvfileoutputnode/include/pvmf_fileoutput_factory.h b/nodes/pvfileoutputnode/include/pvmf_fileoutput_factory.h
index dd0fba8..620c49c 100644
--- a/nodes/pvfileoutputnode/include/pvmf_fileoutput_factory.h
+++ b/nodes/pvfileoutputnode/include/pvmf_fileoutput_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvfileoutputnode/src/pvmf_fileoutput_factory.cpp b/nodes/pvfileoutputnode/src/pvmf_fileoutput_factory.cpp
index 130cdd8..d8d6b8c 100644
--- a/nodes/pvfileoutputnode/src/pvmf_fileoutput_factory.cpp
+++ b/nodes/pvfileoutputnode/src/pvmf_fileoutput_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.cpp b/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.cpp
index 5abe4b3..f72d474 100644
--- a/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.cpp
+++ b/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -95,7 +95,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFFileOutputInPort::SetClock(OsclClock* aClock)
+PVMFStatus PVMFFileOutputInPort::SetClock(PVMFMediaClock* aClock)
 {
     return iDataQueue.SetClock(aClock);
 }
@@ -115,24 +115,14 @@
 
 ////////////////////////////////////////////////////////////////////////////
 PVMFCommandId PVMFFileOutputInPort::SkipMediaData(PVMFSessionId aSessionId,
-        PVMFTimestamp aStartingTimestamp,
         PVMFTimestamp aResumeTimestamp,
         uint32 aStreamID,
-        bool aRenderSkippedData,
         bool aPlayBackPositionContinuous,
         OsclAny* aContext)
 {
     OSCL_UNUSED_ARG(aStreamID);
     OSCL_UNUSED_ARG(aPlayBackPositionContinuous);
 
-    // Validate the passed-in timestamps
-    if (aResumeTimestamp < aStartingTimestamp)
-    {
-        // Resume timestamp must be greater than or equal to the starting timestamp
-        OSCL_LEAVE(OsclErrArgument);
-        return 0;
-    }
-
     // To handle case where media data are in queues but
     // not processed yet
     if (iLastDataTimestampSet == false)
@@ -144,6 +134,7 @@
             if (iLastDataTimestamp == 0xFFFFFFFF)
             {
                 // TEMP Handle unknown timestamp
+                // Will be removed when unknown timestamp is incorporated in architecture
                 iLastDataTimestamp = 0;
             }
             else
@@ -169,6 +160,7 @@
             if (iLastDataTimestamp == 0xFFFFFFFF)
             {
                 // TEMP Handle unknown timestamp
+                // Will be removed when unknown timestamp is incorporated in architecture
                 iLastDataTimestamp = 0;
             }
             else
@@ -211,9 +203,7 @@
     switch (iDataQueue.SkipMediaData(aResumeTimestamp, true))
     {
         case PVMFPending:
-            iSkipStartTimestamp = aStartingTimestamp;
             iSkipResumeTimestamp = aResumeTimestamp;
-            iSkipRenderSkippedData = aRenderSkippedData;
             iSkipMediaDataPending = true;
             iSkipMediaDataContext = aContext;
 
@@ -243,9 +233,7 @@
 ////////////////////////////////////////////////////////////////////////////
 void PVMFFileOutputInPort::SkipMediaDataComplete()
 {
-    iSkipStartTimestamp = 0;
     iSkipResumeTimestamp = 0;
-    iSkipRenderSkippedData = false;
     //Report completion to the session observer.
     PVMFCmdResp resp(iSkipMediaDataCmdId, iSkipMediaDataContext, PVMFSuccess);
     iNode->ReportCmdCompleteEvent(iSkipMediaDataSessionId, resp);
@@ -257,9 +245,7 @@
 ////////////////////////////////////////////////////////////////////////////
 void PVMFFileOutputInPort::CancelSkipMediaData()
 {
-    iSkipStartTimestamp = 0;
     iSkipResumeTimestamp = 0;
-    iSkipRenderSkippedData = false;
     iDataQueue.CancelSkipMediaData();
 }
 
@@ -279,51 +265,54 @@
 ////////////////////////////////////////////////////////////////////////////
 bool PVMFFileOutputInPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return ((aFmt == PVMF_AMR_IETF) ||
-            (aFmt == PVMF_AMR_IETF_COMBINED) ||
-            (aFmt == PVMF_AMR_IF2) ||
-            (aFmt == PVMF_ADTS) ||
-            (aFmt == PVMF_MPEG4_AUDIO) ||
-            (aFmt == PVMF_LATM) ||
-            (aFmt == PVMF_M4V) ||
-            (aFmt == PVMF_H263) ||
-            (aFmt == PVMF_H264_RAW) ||
-            (aFmt == PVMF_H264_MP4) ||
-            (aFmt == PVMF_H264) ||
-            (aFmt == PVMF_PCM) ||
-            (aFmt == PVMF_PCM8) ||
-            (aFmt == PVMF_PCM16) ||
-            (aFmt == PVMF_YUV420) ||
-            (aFmt == PVMF_3GPP_TIMEDTEXT));
+    if ((aFmt == PVMF_MIME_AMR_IETF) ||
+            (aFmt == PVMF_MIME_AMR) ||
+            (aFmt == PVMF_MIME_AMR_IF2) ||
+            (aFmt == PVMF_MIME_ADTS) ||
+            (aFmt == PVMF_MIME_MPEG4_AUDIO) ||
+            (aFmt == PVMF_MIME_LATM) ||
+            (aFmt == PVMF_MIME_M4V) ||
+            (aFmt == PVMF_MIME_H2631998) ||
+            (aFmt == PVMF_MIME_H2632000) ||
+            (aFmt == PVMF_MIME_H264_VIDEO_RAW) ||
+            (aFmt == PVMF_MIME_H264_VIDEO_MP4) ||
+            (aFmt == PVMF_MIME_H264_VIDEO) ||
+            (aFmt == PVMF_MIME_PCM) ||
+            (aFmt == PVMF_MIME_PCM8) ||
+            (aFmt == PVMF_MIME_PCM16) ||
+            (aFmt == PVMF_MIME_YUV420) ||
+            (aFmt == PVMF_MIME_3GPP_TIMEDTEXT))
+    {
+        return true;
+    }
+    return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PVMFFileOutputInPort::FormatUpdated()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFFileOutputInPort::FormatUpdated %d", iFormat));
+                    , (0, "PVMFFileOutputInPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
     //set port name for datapath logging
-    int32 index = GetMediaTypeIndex(iFormat);
-    switch (index)
+    if (iFormat.isAudio())
     {
-        case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-        case PVMF_COMPRESSED_AUDIO_FORMAT:
-            SetName("FileOutIn(Audio)");
-            iDataQueue.SetName("FileOutIn(Audio)");
-            break;
-        case PVMF_UNCOMPRESSED_VIDEO_FORMAT:
-        case PVMF_COMPRESSED_VIDEO_FORMAT:
-            SetName("FileOutIn(Video)");
-            iDataQueue.SetName("FileOutIn(Video)");
-            break;
-        case PVMF_TEXT_FORMAT:
-            SetName("FileOutIn(Text)");
-            iDataQueue.SetName("FileOutIn(Text)");
-            break;
-        default:
-            SetName("FileOutIn");
-            iDataQueue.SetName("FileOutIn");
-            break;
+        SetName("FileOutIn(Audio)");
+        iDataQueue.SetName("FileOutIn(Audio)");
+    }
+    else if (iFormat.isVideo())
+    {
+        SetName("FileOutIn(Video)");
+        iDataQueue.SetName("FileOutIn(Video)");
+    }
+    else if (iFormat.isText())
+    {
+        SetName("FileOutIn(Text)");
+        iDataQueue.SetName("FileOutIn(Text)");
+    }
+    else
+    {
+        SetName("FileOutIn");
+        iDataQueue.SetName("FileOutIn");
     }
 }
 
@@ -353,55 +342,56 @@
 
     if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
     {
-        num_parameter_elements = 15;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
+        num_parameter_elements = 16;
+        status = AllocateKvp(parameters, (PvmiKeyType)INPUT_FORMATS_VALTYPE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMFFileOutputInPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            parameters[0].value.uint32_value = PVMF_AMR_IETF;
-            parameters[1].value.uint32_value = PVMF_AMR_IETF_COMBINED;
-            parameters[2].value.uint32_value = PVMF_ADTS;
-            parameters[3].value.uint32_value = PVMF_MPEG4_AUDIO;
-            parameters[4].value.uint32_value = PVMF_LATM;
-            parameters[5].value.uint32_value = PVMF_M4V;
-            parameters[6].value.uint32_value = PVMF_H263;
-            parameters[7].value.uint32_value = PVMF_PCM8;
-            parameters[8].value.uint32_value = PVMF_PCM16;
-            parameters[9].value.uint32_value = PVMF_YUV420;
-            parameters[10].value.uint32_value = PVMF_AMR_IF2;
-            parameters[11].value.uint32_value = PVMF_H264_RAW;
-            parameters[12].value.uint32_value = PVMF_H264_MP4;
-            parameters[13].value.uint32_value = PVMF_H264;
-            parameters[14].value.uint32_value = PVMF_3GPP_TIMEDTEXT;
+            parameters[0].value.pChar_value = (char*)PVMF_MIME_AMR_IETF;
+            parameters[1].value.pChar_value = (char*)PVMF_MIME_AMR;
+            parameters[2].value.pChar_value = (char*)PVMF_MIME_ADTS;
+            parameters[3].value.pChar_value = (char*)PVMF_MIME_MPEG4_AUDIO;
+            parameters[4].value.pChar_value = (char*)PVMF_MIME_LATM;
+            parameters[5].value.pChar_value = (char*)PVMF_MIME_M4V;
+            parameters[6].value.pChar_value = (char*)PVMF_MIME_H2631998;
+            parameters[7].value.pChar_value = (char*)PVMF_MIME_H2632000;
+            parameters[8].value.pChar_value = (char*)PVMF_MIME_PCM8;
+            parameters[9].value.pChar_value = (char*)PVMF_MIME_PCM16;
+            parameters[10].value.pChar_value = (char*)PVMF_MIME_YUV420;
+            parameters[11].value.pChar_value = (char*)PVMF_MIME_AMR_IF2;
+            parameters[12].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_RAW;
+            parameters[13].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_MP4;
+            parameters[14].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO;
+            parameters[15].value.pChar_value = (char*)PVMF_MIME_3GPP_TIMEDTEXT;
         }
     }
     else if (pv_mime_strcmp(identifier, INPUT_FORMATS_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)INPUT_FORMATS_VALTYPE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMFFileOutputInPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            parameters[0].value.uint32_value = iFormat;
+            parameters[0].value.pChar_value = (char*)iFormat.getMIMEStrPtr();
         }
     }
     else if (pv_mime_strcmp(identifier, PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMFFileOutputInPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            parameters[0].value.int32_value = iFormat;
+            parameters[0].value.pChar_value = (char*)iFormat.getMIMEStrPtr();
         }
     }
 
@@ -519,11 +509,9 @@
         iSkipMediaDataContext(NULL),
         iExtensionRefCount(0),
         iState(PORT_STATE_BUFFERING),
-        iFormat(PVMF_FORMAT_UNKNOWN),
+        iFormat(PVMF_MIME_FORMAT_UNKNOWN),
         iSkipAlreadyComplete(false),
-        iSkipStartTimestamp(0),
         iSkipResumeTimestamp(0),
-        iSkipRenderSkippedData(false),
         iLastDataTimestampSet(false),
         iLastDataTimestamp(0)
 {
@@ -596,8 +584,7 @@
                 // If skip media data is pending, complete it
                 if (iSkipMediaDataPending)
                 {
-                    if (datatailtime >= iSkipResumeTimestamp ||
-                            datatailtime >= iSkipStartTimestamp)
+                    if (datatailtime >= iSkipResumeTimestamp)
                     {
                         LOG_STACK_TRACE((0, "PVMFFileOutputInPort::Run In middle of skip so cancelling skip and sending out PVMFInfoEndOfData in response to EOS media cmd"));
                         // Cancel and complete the skip
@@ -625,8 +612,7 @@
                 // Check if it needs to be dropped when skipping
                 if (iSkipMediaDataPending)
                 {
-                    if (datatailtime < iSkipStartTimestamp ||
-                            (datatailtime < iSkipResumeTimestamp && iSkipRenderSkippedData == false))
+                    if (datatailtime < iSkipResumeTimestamp)
                     {
                         // Data needs to be dropped
                         return;
@@ -697,10 +683,10 @@
 
     if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0)
     {
-        if (IsFormatSupported(aKvp->value.uint32_value))
+        if (IsFormatSupported(aKvp->value.pChar_value))
         {
             if (aSetParam)
-                iFormat = aKvp->value.uint32_value;
+                iFormat = aKvp->value.pChar_value;
             return PVMFSuccess;
         }
         else
@@ -710,10 +696,10 @@
     }
     else if (pv_mime_strcmp(aKvp->key, PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE) == 0)
     {
-        if (IsFormatSupported(aKvp->value.int32_value))
+        if (IsFormatSupported(aKvp->value.pChar_value))
         {
             if (aSetParam)
-                iFormat = aKvp->value.int32_value;
+                iFormat = aKvp->value.pChar_value;
             return PVMFSuccess;
         }
         else
diff --git a/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.h b/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.h
index b9910ae..c227880 100644
--- a/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.h
+++ b/nodes/pvfileoutputnode/src/pvmf_fileoutput_inport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@
 
 // Capability mime strings
 #define PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS "x-pvmf/file/encode/input_formats"
-#define PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=int32"
+#define PVMF_FILE_OUTPUT_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=char*"
 
 class PVMFFileOutputInPort : public PvmfPortBaseImpl
             , public PvmiCapabilityAndConfig
@@ -79,16 +79,14 @@
         bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
 
         // Pure virtuals from PvmfNodesSyncControlInterface
-        PVMFStatus SetClock(OsclClock* aClock);
+        PVMFStatus SetClock(PVMFMediaClock* aClock);
         PVMFStatus ChangeClockRate(int32 aRate);
         PVMFStatus SetMargins(int32 aEarlyMargin, int32 aLateMargin);
         void ClockStarted(void) {} // Not needed
         void ClockStopped(void) {} // Not needed
         PVMFCommandId SkipMediaData(PVMFSessionId aSessionId,
-                                    PVMFTimestamp aStartingTimestamp,
                                     PVMFTimestamp aResumeTimestamp,
                                     uint32 aStreamID,
-                                    bool aRenderSkippedData = false,
                                     bool aPlayBackPositionContinuous = false,
                                     OsclAny* aContext = NULL);
 
@@ -176,9 +174,7 @@
         OsclMemAllocator iAlloc;
 
         bool iSkipAlreadyComplete;
-        PVMFTimestamp iSkipStartTimestamp;
         PVMFTimestamp iSkipResumeTimestamp;
-        bool iSkipRenderSkippedData;
         bool iLastDataTimestampSet;
         PVMFTimestamp iLastDataTimestamp;
 
diff --git a/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.cpp b/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.cpp
index c9fe3d1..17dd8ab 100644
--- a/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.cpp
+++ b/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@
         , iFileOpened(0)
         , iFirstMediaData(false)
         , iLogger(NULL)
-        , iFormat(PVMF_FORMAT_UNKNOWN)
+        , iFormat(PVMF_MIME_FORMAT_UNKNOWN)
         , iExtensionRefCount(0)
         , iMaxFileSizeEnabled(false)
         , iMaxDurationEnabled(false)
@@ -212,25 +212,26 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFFileOutputNode:GetCapability"));
     iCapability.iInputFormatCapability.clear();
 
-    if (iFormat != PVMF_FORMAT_UNKNOWN)
+    if (iFormat != PVMF_MIME_FORMAT_UNKNOWN)
     {
         // Format is already set, so return only that one
         iCapability.iInputFormatCapability.push_back(iFormat);
     }
     else
     {
-        iCapability.iInputFormatCapability.push_back(PVMF_AMR_IETF);
-        iCapability.iInputFormatCapability.push_back(PVMF_M4V);
-        iCapability.iInputFormatCapability.push_back(PVMF_PCM8);
-        iCapability.iInputFormatCapability.push_back(PVMF_PCM16);
-        iCapability.iInputFormatCapability.push_back(PVMF_YUV420);
-        iCapability.iInputFormatCapability.push_back(PVMF_ADTS);
-        iCapability.iInputFormatCapability.push_back(PVMF_H263);
-        iCapability.iInputFormatCapability.push_back(PVMF_H264_RAW);
-        iCapability.iInputFormatCapability.push_back(PVMF_H264_MP4);
-        iCapability.iInputFormatCapability.push_back(PVMF_H264);
-        iCapability.iInputFormatCapability.push_back(PVMF_PCM);
-        iCapability.iInputFormatCapability.push_back(PVMF_3GPP_TIMEDTEXT);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_M4V);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM8);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM16);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_YUV420);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_ADTS);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_H2631998);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_H2632000);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_RAW);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_MP4);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM);
+        iCapability.iInputFormatCapability.push_back(PVMF_MIME_3GPP_TIMEDTEXT);
     }
     aNodeCapability = iCapability;
     return PVMFSuccess;
@@ -514,7 +515,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFFileOutputNode::SetClock(OsclClock* aClock)
+PVMFStatus PVMFFileOutputNode::SetClock(PVMFMediaClock* aClock)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFFileOutputNode::SetClock: aClock=0x%x", aClock));
@@ -531,6 +532,7 @@
 ///////////////////////////////////////////////////////////////////////////
 PVMFStatus PVMFFileOutputNode::ChangeClockRate(int32 aRate)
 {
+    OSCL_UNUSED_ARG(aRate);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFFileOutputNode::ChangeClockRate: aRate=%d", aRate));
 
@@ -579,16 +581,14 @@
 
 ////////////////////////////////////////////////////////////////////////////
 PVMFCommandId PVMFFileOutputNode::SkipMediaData(PVMFSessionId aSessionId,
-        PVMFTimestamp aStartingTimestamp,
         PVMFTimestamp aResumeTimestamp,
         uint32 aStreamID,
-        bool aRenderSkippedData,
         bool aPlayBackPositionContinuous,
         OsclAny* aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFFileOutputNode::SkipMediaData: aStartingTimestamp=%d, aResumeTimestamp=%d, aRenderSkippedData=%d, aContext=0x%x",
-                     aStartingTimestamp, aResumeTimestamp, aRenderSkippedData, aContext));
+                    (0, "PVMFFileOutputNode::SkipMediaData: aResumeTimestamp=%d, aContext=0x%x",
+                     aResumeTimestamp, aContext));
 
     if (!iInPort)
     {
@@ -603,7 +603,7 @@
         case EPVMFNodeStarted:
         case EPVMFNodeInitialized:
         case EPVMFNodePaused:
-            return ((PVMFFileOutputInPort*)iInPort)->SkipMediaData(aSessionId, aStartingTimestamp, aResumeTimestamp, aStreamID, aRenderSkippedData, aPlayBackPositionContinuous, aContext);
+            return ((PVMFFileOutputInPort*)iInPort)->SkipMediaData(aSessionId, aResumeTimestamp, aStreamID, aPlayBackPositionContinuous, aContext);
 
         default:
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -761,15 +761,17 @@
                     }
                 }
 
-                switch (((PVMFFileOutputInPort*)iInPort)->iFormat)
+                if (((PVMFFileOutputInPort*)iInPort)->iFormat == PVMF_MIME_3GPP_TIMEDTEXT)
                 {
-                    case PVMF_3GPP_TIMEDTEXT:
+                    PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*)(frag.getMemFragPtr());
+                    // Output the text sample entry
+                    if (textmediadata->iTextSampleEntry.GetRep() != NULL)
                     {
                         PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*)(frag.getMemFragPtr());
                         // Output the text sample entry
                         if (textmediadata->iTextSampleEntry.GetRep() != NULL)
                         {
-                            // TODO Write out the text sample entry in a better format
+                            // @TODO Write out the text sample entry in a better format
                             status = WriteData((OsclAny*)(textmediadata->iTextSampleEntry.GetRep()), sizeof(PVMFTimedTextSampleEntry));
                             if (status == PVMFFailure)
                             {
@@ -783,21 +785,20 @@
                         if (status == PVMFFailure)
                         {
                             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFFileOutputNode::ProcessIncomingData: Error - WriteData failed for text sample data"));
+                                            (0, "PVMFFileOutputNode::ProcessIncomingData: Error - WriteData failed for text sample entry"));
                             return PVMFFailure;
                         }
                     }
-                    break;
-
-                    default:
-                        status = WriteData(frag, aMediaData->getTimestamp());
-                        if (status == PVMFFailure)
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFFileOutputNode::ProcessIncomingData: Error - WriteData failed"));
-                            return PVMFFailure;
-                        }
-                        break;
+                }
+                else
+                {
+                    status = WriteData(frag, aMediaData->getTimestamp());
+                    if (status == PVMFFailure)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVMFFileOutputNode::ProcessIncomingData: Error - WriteData failed"));
+                        return PVMFFailure;
+                    }
                 }
 
                 break;
@@ -848,85 +849,83 @@
     if (iFirstMediaData)
     {
         // Add the amr header if required
-        switch (((PVMFFileOutputInPort*)iInPort)->iFormat)
+        if (((PVMFFileOutputInPort*)iInPort)->iFormat == PVMF_MIME_AMR_IETF)
         {
-            case PVMF_AMR_IETF:
-                // Check if the incoming data has "#!AMR\n" string
-                if (aSize < AMR_HEADER_SIZE ||
-                        oscl_strncmp((const char*)aPtr, AMR_HEADER, AMR_HEADER_SIZE) != 0)
+            // Check if the incoming data has "#!AMR\n" string
+            if (aSize < AMR_HEADER_SIZE ||
+                    oscl_strncmp((const char*)aPtr, AMR_HEADER, AMR_HEADER_SIZE) != 0)
+            {
+                // AMR header not found, add AMR header to file first
+                status = WriteData((OsclAny*)AMR_HEADER, AMR_HEADER_SIZE);
+                if (status != PVMFSuccess)
                 {
-                    // AMR header not found, add AMR header to file first
-                    status = WriteData((OsclAny*)AMR_HEADER, AMR_HEADER_SIZE);
-                    if (status != PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
-                        return status;
-                    }
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
+                    return status;
                 }
-                iFirstMediaData = false;
-                break;
-
-            case PVMF_M4V:
-                if (aSize > 0)
+            }
+            iFirstMediaData = false;
+        }
+        else if (((PVMFFileOutputInPort*)iInPort)->iFormat == PVMF_MIME_M4V)
+        {
+            if (aSize > 0)
+            {
+                status = WriteData(aPtr, aSize);
+                if (status != PVMFSuccess)
                 {
-                    status = WriteData(aPtr, aSize);
-                    if (status != PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
-                        return status;
-                    }
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
+                    return status;
                 }
-                iFirstMediaData = false;
-                break;
-
-            case PVMF_PCM8:
-                if (aSize > 0)
+            }
+            iFirstMediaData = false;
+        }
+        else if (((PVMFFileOutputInPort*)iInPort)->iFormat == PVMF_MIME_PCM8)
+        {
+            if (aSize > 0)
+            {
+                status = WriteData(aPtr, aSize);
+                if (status != PVMFSuccess)
                 {
-                    status = WriteData(aPtr, aSize);
-                    if (status != PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
-                        return status;
-                    }
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
+                    return status;
                 }
-                iFirstMediaData = false;
-                break;
-
-            case PVMF_PCM16:
-                if (aSize > 0)
+            }
+            iFirstMediaData = false;
+        }
+        else if (((PVMFFileOutputInPort*)iInPort)->iFormat == PVMF_MIME_PCM16)
+        {
+            if (aSize > 0)
+            {
+                status = WriteData(aPtr, aSize);
+                if (status != PVMFSuccess)
                 {
-                    status = WriteData(aPtr, aSize);
-                    if (status != PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
-                        return status;
-                    }
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
+                    return status;
                 }
-                iFirstMediaData = false;
-                break;
-
-            case PVMF_3GPP_TIMEDTEXT:
-                if (aSize > 0)
+            }
+            iFirstMediaData = false;
+        }
+        else if (((PVMFFileOutputInPort*)iInPort)->iFormat == PVMF_MIME_3GPP_TIMEDTEXT)
+        {
+            if (aSize > 0)
+            {
+                // TODO Write out the text track level info in some formatted way
+                status = WriteData(aPtr, aSize);
+                if (status != PVMFSuccess)
                 {
-                    // TODO Write out the text track level info in some formatted way
-                    status = WriteData(aPtr, aSize);
-                    if (status != PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
-                        return status;
-                    }
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFFileOutputNode::WriteFormatSpecificInfo: Error - WriteData failed"));
+                    return status;
                 }
-                iFirstMediaData = false;
-                break;
-
-            default:
-                iFirstMediaData = false;
-                break;
+            }
+            iFirstMediaData = false;
+        }
+        else
+        {
+            iFirstMediaData = false;
         }
     }
     return status;
@@ -1078,6 +1077,7 @@
 //////////////////////////////////////////////////////////////////////////////////
 void PVMFFileOutputNode::ClearPendingPortActivity()
 {
+    // index starts at 1 because the current command (i.e. iCmdQueue[0]) will be erased inside Run
     while (!iInputCommands.empty())
     {
         CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
@@ -1173,10 +1173,25 @@
                         (0, "0x%x PVMFFileOutputNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed", this));
         return status;
     }
+    /*
+       INFORMATION!!!
+       The FileOutputNode is generally used by the engine unit tests as SinkNode
+       For now, most of the unit tests have OBSOLETED the use of FileOutputNode,
+       But still some of the tests are using the FileOutputNode in place of,
+       MIO (RefFileOutput).
+
+       Since the usage FileOutputNode is not defined yet, we are adding support for
+       BOS Message as a NO-OP so that the node should be able to handle Any and all
+       the BOS Messages gracefully.
+
+       IMPORTANT!!!,
+       For Complete support of BOS in the FileOutputNode, we need to make more changes.
+       Those changes will be done only once the life scope of FileOutputNode is defined.
+    */
     if (msg->getFormatID() == PVMF_MEDIA_CMD_BOS_FORMAT_ID)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVFileOutputNode::ProcessIncomingMsg BOS Recieved"));
+                        (0, "PVFileOutputNode::ProcessIncomingMsg BOS Received"));
         return PVMFSuccess;
     }
 
@@ -1422,23 +1437,25 @@
         case EPVMFNodeStarted:
         case EPVMFNodePaused:
             // Stop data source
-        {
-            ((PVMFFileOutputInPort*)iInPort)->Stop();
-            CloseOutputFile();
-        }
+            if (iInPort)
+            {
 
-        // Clear queued messages in ports
-        uint32 i;
-        for (i = 0; i < iPortVector.size(); i++)
-            iPortVector[i]->ClearMsgQueues();
+                ((PVMFFileOutputInPort*)iInPort)->Stop();
+                CloseOutputFile();
+            }
 
-        // Clear scheduled port activities
-        iPortActivityQueue.clear();
+            // Clear queued messages in ports
+            uint32 i;
+            for (i = 0; i < iPortVector.size(); i++)
+                iPortVector[i]->ClearMsgQueues();
 
-        //transition to Initialized state
-        SetState(EPVMFNodePrepared);
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-        break;
+            // Clear scheduled port activities
+            iPortActivityQueue.clear();
+
+            //transition to Initialized state
+            SetState(EPVMFNodePrepared);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
         case EPVMFNodePrepared:
             CommandComplete(iInputCommands, aCmd, PVMFSuccess);
             break;
@@ -1521,7 +1538,6 @@
 
         //logoff & go back to Created state.
         SetState(EPVMFNodeIdle);
-        ThreadLogoff();
         CommandComplete(iInputCommands, aCmd, PVMFSuccess);
     }
     else
@@ -1565,13 +1581,13 @@
 
     // Create and configure output port
     int32 err;
-    PVMFFormatType fmt = PVMF_FORMAT_UNKNOWN;
+    PVMFFormatType fmt = PVMF_MIME_FORMAT_UNKNOWN;
     if (portconfig)
     {
-        fmt = GetFormatIndex(portconfig->get_str());
+        fmt = portconfig->get_str();
     }
 
-    if (iFormat != PVMF_FORMAT_UNKNOWN &&
+    if (iFormat != PVMF_MIME_FORMAT_UNKNOWN &&
             iFormat != fmt)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
@@ -1595,8 +1611,8 @@
     //if format was provided in mimestring, set it now.
     if (portconfig)
     {
-        PVMFFormatType fmt = GetFormatIndex(portconfig->get_str());
-        if (fmt != PVMF_FORMAT_UNKNOWN
+        PVMFFormatType fmt = portconfig->get_str();
+        if (fmt != PVMF_MIME_FORMAT_UNKNOWN
                 && ((PVMFFileOutputInPort*)iInPort)->IsFormatSupported(fmt))
         {
             ((PVMFFileOutputInPort*)iInPort)->iFormat = fmt;
diff --git a/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.h b/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.h
index 8e8f50e..8e56641 100644
--- a/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.h
+++ b/nodes/pvfileoutputnode/src/pvmf_fileoutput_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,11 +44,8 @@
 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
 #include "oscl_scheduler_ao.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
-#endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED
 #include "pvmf_format_type.h"
@@ -222,16 +219,14 @@
         void GetDurationProgressReportConfig(bool& aEnable, uint32& aReportFrequency);
 
         // Pure virtuals from PvmfNodesSyncControlInterface
-        PVMFStatus SetClock(OsclClock* aClock);
+        PVMFStatus SetClock(PVMFMediaClock* aClock);
         PVMFStatus ChangeClockRate(int32 aRate);
         PVMFStatus SetMargins(int32 aEarlyMargin, int32 aLateMargin);
         void ClockStarted(void);
         void ClockStopped(void);
         PVMFCommandId SkipMediaData(PVMFSessionId aSessionId,
-                                    PVMFTimestamp aStartingTimestamp,
                                     PVMFTimestamp aResumeTimestamp,
                                     uint32 aStreamID,
-                                    bool aRenderSkippedData = false,
                                     bool aPlayBackPositionContinuous = false,
                                     OsclAny* aContext = NULL);
 
@@ -421,7 +416,7 @@
         uint32 iNextDurationReport;
 
         // Variables for media data queue and synchronization
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
         int32 iEarlyMargin;
         int32 iLateMargin;
 };
diff --git a/nodes/pvfileoutputnode/src/pvmf_fileoutput_node_cap_config.cpp b/nodes/pvfileoutputnode/src/pvmf_fileoutput_node_cap_config.cpp
index 8ccc97f..e36cb83 100644
--- a/nodes/pvfileoutputnode/src/pvmf_fileoutput_node_cap_config.cpp
+++ b/nodes/pvfileoutputnode/src/pvmf_fileoutput_node_cap_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -400,7 +400,7 @@
                 aParameters[ii].value.key_specific_value = NULL;
                 oscl_free(rui32);
             }
-            // TODO Add more types if file output node starts returning more types
+            // @TODO Add more types if file output node starts returning more types
         }
     }
 
diff --git a/nodes/pvloopbacknode/build/make/local.mk b/nodes/pvloopbacknode/build/make/local.mk
new file mode 100644
index 0000000..54b6344
--- /dev/null
+++ b/nodes/pvloopbacknode/build/make/local.mk
@@ -0,0 +1,28 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvloopbacknode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_loopback_ioport.cpp  pvmf_loopback_node.cpp
+
+
+HDRS := pvmf_loopback_ioport.h  pvmf_loopback_node.h
+
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvloopbacknode/include/pvmf_loopback_ioport.h b/nodes/pvloopbacknode/include/pvmf_loopback_ioport.h
new file mode 100644
index 0000000..ec6c02f
--- /dev/null
+++ b/nodes/pvloopbacknode/include/pvmf_loopback_ioport.h
@@ -0,0 +1,131 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_loopback_ioport.h
+ * @brief Input/Output port for simple loopback node
+ *
+ */
+
+#ifndef PVMF_LOOPBACK_IOPORT_H_INCLUDED
+#define PVMF_LOOPBACK_IOPORT_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_port_interface.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+// Capability mime strings
+#define PVMF_LOOPBACK_PORT_INPUT_FORMATS ".../input_formats"
+#define PVMF_LOOPBACK_PORT_INPUT_FORMATS_VALTYPE ".../input_formats;valtype=uint32"
+
+class PVLogger;
+class PVMFLoopbackNode;
+
+class PVMFLoopbackIOPort : public PvmfPortBaseImpl
+            , public PvmiCapabilityAndConfigPortFormatImpl
+            , public OsclActiveObject
+            , public PVMFPortActivityHandler
+{
+    public:
+        PVMFLoopbackIOPort(int32 aTag
+                           , PVMFLoopbackNode* aNode);
+
+        PVMFLoopbackIOPort(int32 aTag
+                           , PVMFLoopbackNode* aNode
+                           , uint32 aInCapacity
+                           , uint32 aInReserve
+                           , uint32 aInThreshold
+                           , uint32 aOutCapacity
+                           , uint32 aOutReserve
+                           , uint32 aOutThreshold);
+
+        ~PVMFLoopbackIOPort();
+
+        // from PvmiCapabilityAndConfigPortFormatImpl
+        bool IsFormatSupported(PVMFFormatType);
+        void FormatUpdated();
+
+
+// this port supports config interface
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+                aPtr = (PvmiCapabilityAndConfig*)this;
+            else
+                aPtr = NULL;
+        }
+
+        void Reset();
+
+        void SetDestNode(PVMFLoopbackNode* aNode)
+        {
+            iNode = aNode;
+        }
+
+    private:
+
+        void Construct(PVMFLoopbackNode*);
+        PVMFLoopbackNode* iNode;
+
+        uint32 iTimedSendBytes;
+        uint32 iWriteDataLength;
+        uint32 iFirstSendStartTime;
+
+        PVLogger *iLogger;
+
+        //from OsclActiveObject
+        void Run();
+
+        //from PVMFPortActivityHandler
+        void HandlePortActivity(const PVMFPortActivity &);
+
+        //for port data processing.
+        bool iWaiting;
+        PVMFStatus ProcessIncomingMsg();
+
+        friend class PVMFLoopbackNode;
+
+        friend class Oscl_TAlloc<PVMFLoopbackIOPort, OsclMemAllocator>;
+
+};
+
+#endif // PVMF_LOOPBACK_IOPORT_H_INCLUDED
diff --git a/nodes/pvloopbacknode/include/pvmf_loopback_node.h b/nodes/pvloopbacknode/include/pvmf_loopback_node.h
new file mode 100644
index 0000000..77a9c87
--- /dev/null
+++ b/nodes/pvloopbacknode/include/pvmf_loopback_node.h
@@ -0,0 +1,250 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_loopback_node.h
+ * @brief Simple loopback node. Incoming data is immediately routed to outport if it exists
+ *
+ */
+
+#ifndef PVMF_LOOPBACK_NODE_H_INCLUDED
+#define PVMF_LOOPBACK_NODE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_NODE_UTIL_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_LOOPBACK_IOPORT_H_INCLUDED
+#include "pvmf_loopback_ioport.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+////////////////////////////////////////////////////////////////////////////
+
+
+//Default vector reserve size
+#define PVMF_LOOPBACK_NODE_COMMAND_VECTOR_RESERVE 10
+
+//Starting value for command IDs
+#define PVMF_LOOPBACK_NODE_COMMAND_ID_START 6000
+
+
+typedef enum
+{
+    PVMF_LOOPBACKNODE_PORT_TYPE_LOOPBACK = 3
+} PVMFLoopbackNodePortType;
+
+//memory allocator type for this node.
+typedef OsclMemAllocator PVMFLoopbackNodeAllocator;
+
+///////////////////////////////////////////////////////////////////////////
+class PVMFLoopbackAlloc : public Oscl_DefAlloc
+{
+    public:
+        void* allocate(const uint32 size)
+        {
+            void* tmp = (void*)oscl_malloc(size);
+            return tmp;
+        }
+
+        void deallocate(void* p)
+        {
+            oscl_free(p);
+        }
+};
+
+
+typedef PVMFGenericNodeCommand<PVMFLoopbackNodeAllocator> PVMFLoopbackNodeCommandBase;
+class PVMFLoopbackNodeCmd: public PVMFGenericNodeCommand<PVMFLoopbackNodeAllocator>
+{
+    public:
+        //constructor for Custom2 command
+        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
+        {
+            PVMFLoopbackNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)arg1;
+            iParam2 = (OsclAny*)arg2;
+            iParam3 = (OsclAny*) & arg3;
+        }
+        void Parse(int32&arg1, int32&arg2, int32*&arg3)
+        {
+            arg1 = (int32)iParam1;
+            arg2 = (int32)iParam2;
+            arg3 = (int32*)iParam3;
+        }
+};
+
+enum PVMFLoopbackNodeCmdType
+{
+    PVMFLOOPBACK_NODE_CMD_INIT,
+    PVMFLOOPBACK_NODE_CMD_REQUESTPORT,
+    PVMFLOOPBACK_NODE_CMD_START,
+    PVMFLOOPBACK_NODE_CMD_PAUSE,
+    PVMFLOOPBACK_NODE_CMD_STOP,
+    PVMFLOOPBACK_NODE_CMD_RELEASEPORT,
+    PVMFLOOPBACK_NODE_CMD_RESET,
+    PVMFLOOPBACK_NODE_CMD_PREPARE,
+    PVMFLOOPBACK_NODE_CMD_FLUSH,
+    PVMFLOOPBACK_NODE_CMD_CANCELCMD,
+    PVMFLOOPBACK_NODE_CMD_CANCELALL,
+    PVMFLOOPBACK_NODE_CMD_INVALID
+};
+
+typedef PVMFNodeCommandQueue<PVMFLoopbackNodeCmd, PVMFLoopbackNodeAllocator> PVMFLoopbackNodeCmdQ;
+
+
+// Forward declaration
+class PVMFLoopbackIOPort;
+
+////////////////////////////////////////////////////////////////////////////
+class PVMFLoopbackNode : public PVMFNodeInterface
+            , public OsclActiveObject
+{
+    public:
+
+        OSCL_IMPORT_REF static PVMFNodeInterface* Create();
+        OSCL_IMPORT_REF ~PVMFLoopbackNode();
+
+        // Virtual functions of PVMFNodeInterface
+        //from PVMFNodeInterface
+        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL)
+        {
+            OSCL_UNUSED_ARG(aFilter);
+            return &iPortVector;
+        }
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, PVMFLoopbackNodeAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId
+                , int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+
+
+        // For input port to access private function / data
+        friend class PVMFLoopbackIOPort;
+        //from PVMFPortActivityHandler.
+        void HandlePortActivity(const PVMFPortActivity& aActivity)
+        {
+            OSCL_UNUSED_ARG(aActivity);
+        };
+
+        PVMFPortVector<PVMFLoopbackIOPort, PVMFLoopbackNodeAllocator> iPortVector;
+
+    private:
+        PVMFLoopbackNode(int32 aPriority);
+        void DoCancel();
+        void Run();
+
+        //Command processing
+        PVMFCommandId QueueCommandL(PVMFLoopbackNodeCmd&);
+        bool ProcessCommand(PVMFLoopbackNodeCmd&);
+        void CommandComplete(PVMFLoopbackNodeCmdQ&, PVMFLoopbackNodeCmd&, PVMFStatus, OsclAny* aData = NULL);
+        bool FlushPending();
+        PVMFLoopbackNodeCmdQ iInputCommands;
+        PVMFLoopbackNodeCmdQ iCurrentCommand;
+
+        //Command handlers.
+        void DoReset(PVMFLoopbackNodeCmd&);
+        void DoRequestPort(PVMFLoopbackNodeCmd&);
+        void DoReleasePort(PVMFLoopbackNodeCmd&);
+        void DoInit(PVMFLoopbackNodeCmd&);
+        void DoPrepare(PVMFLoopbackNodeCmd&);
+        void DoStart(PVMFLoopbackNodeCmd&);
+        void DoStop(PVMFLoopbackNodeCmd&);
+        void DoFlush(PVMFLoopbackNodeCmd&);
+        void DoPause(PVMFLoopbackNodeCmd&);
+
+        // Event reporting
+        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
+        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
+        void SetState(TPVMFNodeInterfaceState);
+
+
+        PVMFCommandId iCmdIdCounter;
+
+        // Input port
+        PVMFLoopbackIOPort* iIOPort;
+
+        PVMFNodeCapability iCapability;
+        PVLogger *iLogger;
+
+        PVMFNodeCmdStatusObserver *iObserver;
+};
+
+#endif // PVMF_LOOPBACK_NODE_H_INCLUDED
diff --git a/nodes/pvloopbacknode/src/pvmf_loopback_ioport.cpp b/nodes/pvloopbacknode/src/pvmf_loopback_ioport.cpp
new file mode 100644
index 0000000..a458115
--- /dev/null
+++ b/nodes/pvloopbacknode/src/pvmf_loopback_ioport.cpp
@@ -0,0 +1,268 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/**
+ *
+ * @file pvmf_loopback_ioport.h
+ * @brief Input/Output port for simple loopback node
+ *
+ */
+
+#include "oscl_mem_basic_functions.h"
+#include "pv_mime_string_utils.h"
+#include "pvmf_node_interface.h"
+
+
+#ifndef PVMF_LOOPBACK_IOPORT_H_INCLUDED
+#include "pvmf_loopback_ioport.h"
+#endif
+
+#ifndef PVMF_LOOPBACK_NODE_H_INCLUDED
+#include "pvmf_loopback_node.h"
+#endif
+
+#include "pvlogger.h"
+#include "oscl_tickcount.h"
+
+////////////////////////////////////////////////////////////////////////////
+
+PVMFLoopbackIOPort::PVMFLoopbackIOPort(int32 aTag, PVMFLoopbackNode* aNode)
+        : PvmfPortBaseImpl(aTag, this)
+        , OsclActiveObject(OsclActiveObject::EPriorityNominal, "PVMFLoopbackPort")
+{
+    Construct(aNode);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFLoopbackIOPort::PVMFLoopbackIOPort(int32 aTag, PVMFLoopbackNode* aNode
+                                       , uint32 aInCapacity
+                                       , uint32 aInReserve
+                                       , uint32 aInThreshold
+                                       , uint32 aOutCapacity
+                                       , uint32 aOutReserve
+                                       , uint32 aOutThreshold)
+        : PvmfPortBaseImpl(aTag, this, aInCapacity, aInReserve, aInThreshold, aOutCapacity, aOutReserve, aOutThreshold)
+        , OsclActiveObject(OsclActiveObject::EPriorityNominal, "PVMFLoopbackPort")
+{
+    Construct(aNode);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFLoopbackIOPort::Construct(PVMFLoopbackNode*aNode)
+{
+    iNode = aNode;
+    iWaiting = false;
+    iLogger = PVLogger::GetLoggerObject("PVMFLoopbackPort");
+    PvmiCapabilityAndConfigPortFormatImpl::Construct(
+        PVMF_LOOPBACK_PORT_INPUT_FORMATS
+        , PVMF_LOOPBACK_PORT_INPUT_FORMATS_VALTYPE);
+    AddToScheduler();
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFLoopbackIOPort::~PVMFLoopbackIOPort()
+{
+    Disconnect();
+    Reset();
+    if (IsAdded())
+        RemoveFromScheduler();
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////
+
+bool PVMFLoopbackIOPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    OSCL_UNUSED_ARG(aFmt);
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFLoopbackIOPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFLoopbackPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
+}
+////////////////////////////////////////////////////////////////////////////
+
+
+////////////////////////////////////////////////////////////////////////////
+
+void PVMFLoopbackIOPort::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFLoopbackPort::PortActivity: port=0x%x, type=%d",
+                     this, aActivity.iPort, aActivity.iType));
+
+    //A port is reporting some activity or state change.  This code
+    //figures out whether we need to queue a processing event
+    //for the AO, and/or report a node event to the observer.
+
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_CREATED:
+#if 0
+            //Report port created info event to the node.
+            iNode->ReportInfoEvent(PVMF_NODE_INFO_EVENT_PORT_CREATED
+                                   , (OsclAny*)aActivity.iPort);
+#endif
+            break;
+
+        case PVMF_PORT_ACTIVITY_DELETED:
+#if 0
+            //Report port deleted info event to the node.
+            iNode->ReportInfoEvent(PVMF_NODE_INFO_EVENT_PORT_DELETED
+                                   , (OsclAny*)aActivity.iPort);
+#endif
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECT:
+            //nothing needed.
+            break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            //nothing needed.
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            //An outgoing message was queued on this port.
+            //Wakeup the AO on the first message only-- after
+            //that it re-schedules itself as needed.
+            if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
+                RunIfNotReady();
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            //An incoming message was queued on this port.
+            //Wakeup the AO on the first message only-- after
+            //that it re-schedules itself as needed.
+            if (aActivity.iPort->IncomingMsgQueueSize() == 1)
+                RunIfNotReady();
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
+            //Outgoing queue is now busy.
+            //No action is needed here-- the node checks for
+            //outgoing queue busy as needed during data processing.
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
+            //the loopback port may be waiting on this event.
+
+            if (iWaiting)
+            {
+                iWaiting = false;
+                RunIfNotReady();
+            }
+            break;
+
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
+            // The connected port has become busy (its incoming queue is
+            // busy).
+            // No action is needed here-- the port processing code
+            // checks for connected port busy during data processing.
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+            // The connected port has transitioned from Busy to Ready.
+            if (OutgoingMsgQueueSize() > 0)
+                RunIfNotReady();
+            break;
+
+        default:
+            break;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFLoopbackIOPort::Reset()
+{
+    Cancel();
+    ClearMsgQueues();
+    iWaiting = false;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+void PVMFLoopbackIOPort::Run()
+{
+    //data should move through the ports only
+    //when the node is active or flushing
+    if (iNode->GetState() != EPVMFNodeStarted
+            && !iNode->FlushPending())
+        return;
+
+    //Process incoming messages
+    if (!iWaiting
+            && IncomingMsgQueueSize() > 0)
+    {
+        //dispatch the incoming data.
+        if (ProcessIncomingMsg() != PVMFSuccess)
+            iNode->ReportErrorEvent(PVMF_NODE_ERROR_EVENT_LAST, (OsclAny*)this);
+
+        //re-schedule if more data
+        if (!iWaiting
+                && IncomingMsgQueueSize() > 0)
+        {
+            RunIfNotReady();
+        }
+    }
+
+    //Process outgoing messages
+    if (OutgoingMsgQueueSize() > 0
+            && !IsConnectedPortBusy())
+    {
+        //Send data to connected port
+        PVMFStatus status = Send();
+        if (status != PVMFSuccess)
+            iNode->ReportErrorEvent(PVMF_NODE_ERROR_EVENT_LAST, (OsclAny*)this);
+
+        //Reschedule if there's more data to process...
+        if (OutgoingMsgQueueSize() > 0
+                && !IsConnectedPortBusy())
+        {
+            RunIfNotReady();
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+PVMFStatus PVMFLoopbackIOPort::ProcessIncomingMsg()
+{
+    if (IsOutgoingQueueBusy())
+    {
+        iWaiting = true;
+        return PVMFSuccess;
+    }
+
+    //Move the incoming message from the input queue
+    //to the output queue...
+    PVMFSharedMediaMsgPtr msg;
+    PVMFStatus status = DequeueIncomingMsg(msg);
+    if (status != PVMFSuccess)
+        return status;
+    status = QueueOutgoingMsg(msg);
+    if (status != PVMFSuccess)
+        return status;
+
+    return PVMFSuccess;
+
+}
diff --git a/nodes/pvloopbacknode/src/pvmf_loopback_node.cpp b/nodes/pvloopbacknode/src/pvmf_loopback_node.cpp
new file mode 100644
index 0000000..c800389
--- /dev/null
+++ b/nodes/pvloopbacknode/src/pvmf_loopback_node.cpp
@@ -0,0 +1,736 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_loopback_node.cpp
+ * @brief Simple file output node. Writes incoming data to specified
+ * file without any media type specific file format
+ *
+ */
+#include "pvlogger.h"
+#include "pvmf_loopback_ioport.h"
+#include "pvmf_loopback_node.h"
+
+#define LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
+#define LOGINFO(m) LOGINFOMED(m)
+
+// Use default DLL entry point for Symbian
+#include "oscl_dll.h"
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface *PVMFLoopbackNode::Create()
+{
+    PVMFLoopbackNode *self = OSCL_NEW(PVMFLoopbackNode, (OsclActiveObject::EPriorityNominal));
+    return self;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFLoopbackNode::PVMFLoopbackNode(int32 aPriority) : OsclActiveObject(aPriority, "LoopbackNode")
+        , iCmdIdCounter(0)
+        , iIOPort(NULL)
+{
+    iLogger = NULL;
+    int32 err;
+    OSCL_TRY(err,
+
+             //Create the input command queue.  Use a reserve to avoid lots of
+             //dynamic memory allocation.
+             iInputCommands.Construct(PVMF_LOOPBACK_NODE_COMMAND_ID_START, PVMF_LOOPBACK_NODE_COMMAND_VECTOR_RESERVE);
+
+             //Create the "current command" queue.  It will only contain one
+             //command at a time, so use a reserve of 1.
+             iCurrentCommand.Construct(0, 1);
+
+             //Set the node capability data.
+             //This node can support an unlimited number of ports.
+             iCapability.iCanSupportMultipleInputPorts = true;
+             iCapability.iCanSupportMultipleOutputPorts = true;
+             iCapability.iHasMaxNumberOfPorts = false;
+             iCapability.iMaxNumberOfPorts = 0;//no maximum
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM16);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_RGB24);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_MP3);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_PCM16);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_RGB24);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_MP3);
+
+            );
+
+    if (err != OsclErrNone)
+    {
+        //if a leave happened, cleanup and re-throw the error
+        iInputCommands.clear();
+        iCurrentCommand.clear();
+        iCapability.iInputFormatCapability.clear();
+        iCapability.iOutputFormatCapability.clear();
+        OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
+        OSCL_CLEANUP_BASE_CLASS(OsclActiveObject);
+        OSCL_LEAVE(err);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFLoopbackNode::~PVMFLoopbackNode()
+{
+
+    if (IsAdded())
+        RemoveFromScheduler();
+    if (iIOPort)
+    {
+        OSCL_DELETE(iIOPort);
+        iIOPort = NULL;
+    }
+
+    while (!iCurrentCommand.empty())
+    {
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
+        iCurrentCommand.Erase(&iCurrentCommand.front());
+    }
+
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+        iInputCommands.Erase(&iInputCommands.front());
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFLoopbackNode::DoCancel()
+{
+    OsclActiveObject::DoCancel();
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFLoopbackNode::ThreadLogon()
+{
+
+    LOGINFO((0, "loopbackNode:ThreadLogon"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+            if (!IsAdded())
+                AddToScheduler();
+            iLogger = PVLogger::GetLoggerObject("PVMFLoopbackNode");
+            SetState(EPVMFNodeIdle);
+            return PVMFSuccess;
+            break;
+        default:
+            return PVMFErrInvalidState;
+            break;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFLoopbackNode::ThreadLogoff()
+{
+
+    LOGINFO((0, "PVMFLoopbackNode:ThreadLogoff"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            if (IsAdded())
+                RemoveFromScheduler();
+            iLogger = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+            break;
+
+        default:
+            return PVMFErrInvalidState;
+            break;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFLoopbackNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    LOGINFO((0, "PVMFLoopbackNode:GetCapability"));
+    aNodeCapability = iCapability;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:QueryUUID"));
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aUuids);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(s);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:QueryInterface"));
+    OSCL_UNUSED_ARG(aUuid);
+    OSCL_UNUSED_ARG(aInterfacePtr);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(s);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:RequestPort"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
+
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:ReleasePort"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "SampleNode:Prepare"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:Init"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:Start"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:Stop"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:Flush"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:Pause"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    LOGINFO((0, "PVMFLoopbackNode:Reset"));
+    PVMFLoopbackNodeCmd cmd;
+    cmd.PVMFLoopbackNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(s);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+/**
+//Queue an asynchronous node command
+*/
+OSCL_EXPORT_REF PVMFCommandId PVMFLoopbackNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aCmdId);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(s);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+
+PVMFCommandId PVMFLoopbackNode::QueueCommandL(PVMFLoopbackNodeCmd& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iInputCommands.AddL(aCmd);
+
+    //wakeup the AO
+    RunIfNotReady();
+
+    return id;
+}
+////////////////////////////////////////////////////////////////////////////
+void PVMFLoopbackNode::Run()
+{
+    //Process commands.
+    if (!iInputCommands.empty())
+    {
+        if (ProcessCommand(iInputCommands.front()))
+        {
+            //re-schedule if more commands to do
+            //and node isn't reset.
+            if (!iInputCommands.empty()
+                    && iInterfaceState != EPVMFNodeCreated)
+            {
+                RunIfNotReady();
+            }
+        }
+    }
+
+    //this AO needs to monitor for node flush completion.
+    if (FlushPending())
+    {
+        //uint32 i;
+        if (iIOPort->IncomingMsgQueueSize() > 0
+                || iIOPort->OutgoingMsgQueueSize() > 0)
+        {
+            //need to wait on completion...
+            RunIfNotReady();
+            return;
+        }
+        //Flush is complete.  Go to prepared state.
+        SetState(EPVMFNodePrepared);
+        //resume port input so the ports can be re-started.
+        iIOPort->ResumeInput();
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+    }
+}
+
+
+
+
+///////////////////////////////////////////////////////////////////////////
+bool PVMFLoopbackNode::ProcessCommand(PVMFLoopbackNodeCmd& aCmd)
+{
+    //normally this node will not start processing one command
+    //until the prior one is finished.  However, a hi priority
+    //command such as Cancel must be able to interrupt a command
+    //in progress.
+    if (!iCurrentCommand.empty() && !aCmd.hipri())
+        return false;
+
+    switch (aCmd.iCmd)
+    {
+
+
+        case PVMF_GENERIC_NODE_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_INIT:
+            DoInit(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PREPARE:
+            DoPrepare(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_START:
+            DoStart(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_STOP:
+            DoStop(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_FLUSH:
+            DoFlush(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PAUSE:
+            DoPause(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RESET:
+            DoReset(aCmd);
+            break;
+
+        default://unknown command type
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            break;
+    }
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFLoopbackNode::CommandComplete(PVMFLoopbackNodeCmdQ& aCmdQ, PVMFLoopbackNodeCmd& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    LOGINFO((0, "SampleNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
+             , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+}
+
+
+
+//////////////////////////////////////////////////////////////////
+
+
+/**
+//Called by the command handler AO to do the node Init
+*/
+void PVMFLoopbackNode::DoInit(PVMFLoopbackNodeCmd& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            //this node doesn't need to do anything
+            SetState(EPVMFNodeInitialized);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+////////////////////////////////////////////////
+void PVMFLoopbackNode::DoStart(PVMFLoopbackNodeCmd& aCmd)
+{
+    PVMFStatus status = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodePrepared:
+        case EPVMFNodePaused:
+            //transition to Started
+            SetState(EPVMFNodeStarted);
+            //wakeup the port
+            iIOPort->RunIfNotReady();
+
+            break;
+
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+
+    CommandComplete(iInputCommands, aCmd, status);
+}
+
+
+/**
+//Called by the command handler AO to do the node Prepare
+*/
+void PVMFLoopbackNode::DoPrepare(PVMFLoopbackNodeCmd& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+            //this node doesn't need to do anything to get ready
+            //to start.
+            SetState(EPVMFNodePrepared);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Stop
+*/
+void PVMFLoopbackNode::DoStop(PVMFLoopbackNodeCmd& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+
+            //Resetting the IO Port
+            if (iIOPort)
+            {
+                iIOPort->Reset();
+            }
+            //transition to Prepared state
+            SetState(EPVMFNodePrepared);
+
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Pause
+*/
+void PVMFLoopbackNode::DoPause(PVMFLoopbackNodeCmd& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+            // Pause data source
+            SetState(EPVMFNodePaused);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//Called by the command handler AO to do the node Flush
+*/
+void PVMFLoopbackNode::DoFlush(PVMFLoopbackNodeCmd& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            //the flush is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until the flush completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            iIOPort->SuspendInput();
+
+            //if node isn't active wakeup the ports
+            //so they'll flush.
+            if (iInterfaceState != EPVMFNodeStarted)
+            {
+                iIOPort->RunIfNotReady();
+            }
+
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/**
+//A routine to tell if a flush operation is in progress.
+*/
+bool PVMFLoopbackNode::FlushPending()
+{
+    return (iCurrentCommand.size() > 0
+            && iCurrentCommand.front().iCmd == PVMFLOOPBACK_NODE_CMD_FLUSH);
+}
+
+
+void PVMFLoopbackNode::SetState(TPVMFNodeInterfaceState s)
+{
+    LOGINFO((0, "LoopbackNode:SetState %d", s));
+    PVMFNodeInterface::SetState(s);
+}
+/**
+//Called by the command handler AO to do the node Reset.
+*/
+void PVMFLoopbackNode::DoReset(PVMFLoopbackNodeCmd& aCmd)
+{
+    //This example node allows a reset from any idle state.
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+        case EPVMFNodeIdle:
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        {
+            if (iIOPort)
+            {
+                //delete ports and notify observer.
+                OSCL_DELETE(iIOPort);
+                iIOPort = NULL;
+            }
+            //logoff & go back to Created state.
+            SetState(EPVMFNodeIdle);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        }
+        break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+
+
+}
+
+
+/**
+// called by the command handler AO to do Request Port
+*/
+void PVMFLoopbackNode::DoRequestPort(PVMFLoopbackNodeCmd& aCmd)
+{
+    int32 tag;
+    OSCL_String* mimetype;
+    aCmd.PVMFLoopbackNodeCommandBase::Parse(tag, mimetype);
+
+    switch (tag)
+    {
+        case PVMF_LOOPBACKNODE_PORT_TYPE_LOOPBACK:
+            break;
+
+        default:
+        {
+            //bad port tag
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFLoopbackNode::DoRequestPort: Error - Invalid port tag"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            return;
+        }
+        break;
+    }
+
+    iIOPort = OSCL_NEW(PVMFLoopbackIOPort, (tag, this));
+
+    if (!iIOPort)
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        return;
+    }
+
+    if (mimetype)
+    {
+        PVMFFormatType fmt = mimetype->get_str();
+        if (fmt != PVMF_MIME_FORMAT_UNKNOWN && iIOPort->IsFormatSupported(fmt))
+        {
+            iIOPort->iFormat = fmt;
+            iIOPort->FormatUpdated();
+        }
+    }
+
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)iIOPort);
+}
+
+
+/**
+// called by the command handler AO to do Request Port
+*/
+void PVMFLoopbackNode::DoReleasePort(PVMFLoopbackNodeCmd& aCmd)
+
+{
+    if (iIOPort)
+    {
+        OSCL_DELETE(iIOPort);
+        iIOPort = NULL;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+}
+
+
+void PVMFLoopbackNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData)
+{
+    LOGINFO((0, "LoopbackNode:NodeInfoEvent Type %d Data %d"
+             , aEventType, aEventData));
+
+    PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
+}
+
+void PVMFLoopbackNode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData)
+{
+    LOGINFO((0, "LoopbackNode:NodeErrorEvent Type %d Data %d"
+             , aEventType, aEventData));
+
+    PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
+}
+
diff --git a/nodes/pvmediainputnode/Android.mk b/nodes/pvmediainputnode/Android.mk
index 847fe41..c95cf8a 100644
--- a/nodes/pvmediainputnode/Android.mk
+++ b/nodes/pvmediainputnode/Android.mk
@@ -3,32 +3,35 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_media_input_node_outport.cpp \
-	src/pvmf_media_input_node.cpp \
-	src/pvmf_media_input_data_buffer.cpp \
-	src/pvmf_media_input_node_cap_config.cpp
-
+ 	src/pvmf_media_input_node.cpp \
+ 	src/pvmf_media_input_data_buffer.cpp \
+ 	src/pvmf_media_input_node_cap_config.cpp
 
 
 LOCAL_MODULE := libpvmediainputnode
 
-LOCAL_CFLAGS := -DTEXT_TRACK_DESC_INFO  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DTEXT_TRACK_DESC_INFO -D_TEST_AE_ERROR_HANDLING $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvmediainputnode/src \
-	$(PV_TOP)//nodes/pvmediainputnode/src \
-	$(PV_TOP)//nodes/pvmediainputnode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvmediainputnode/../../nodes/common/include \
-	$(PV_TOP)//nodes/pvmediainputnode/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvmediainputnode/src \
+ 	$(PV_TOP)/nodes/pvmediainputnode/src \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/nodes/pvmediainputnode/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/pvmf_media_input_data_buffer.h \
-	src/pvmf_media_input_node.h \
-	src/../include/pvmf_media_input_node_factory.h \
-	src/../include/pvmf_media_input_node_events.h
+ 	src/pvmf_media_input_node.h \
+ 	src/../include/pvmf_media_input_node_factory.h \
+ 	src/../include/pvmf_media_input_node_events.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvmediainputnode/build/make_pvauthor/local.mk b/nodes/pvmediainputnode/build/make_pvauthor/local.mk
new file mode 100644
index 0000000..a3eec59
--- /dev/null
+++ b/nodes/pvmediainputnode/build/make_pvauthor/local.mk
@@ -0,0 +1,34 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmediainputnode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+XCPPFLAGS += -DTEXT_TRACK_DESC_INFO -D_TEST_AE_ERROR_HANDLING
+
+XINCDIRS += ../../../../pvmi/pvmf/include ../../../../nodes/common/include ../../include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvmf_media_input_node_outport.cpp \
+		pvmf_media_input_node.cpp \
+		pvmf_media_input_data_buffer.cpp \
+		pvmf_media_input_node_cap_config.cpp
+
+HDRS := pvmf_media_input_data_buffer.h \
+		pvmf_media_input_node.h \
+        ../include/pvmf_media_input_node_factory.h \
+        ../include/pvmf_media_input_node_events.h
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvmediainputnode/build/make_pvauthor/makefile b/nodes/pvmediainputnode/build/make_pvauthor/makefile
deleted file mode 100644
index a701c77..0000000
--- a/nodes/pvmediainputnode/build/make_pvauthor/makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmediainputnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-XCPPFLAGS += -DTEXT_TRACK_DESC_INFO
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../../../pvmi/pvmf/include -I../../../../nodes/common/include -I../../include 
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	pvmf_media_input_node_outport.cpp \
-		pvmf_media_input_node.cpp \
-		pvmf_media_input_data_buffer.cpp \
-		pvmf_media_input_node_cap_config.cpp
-
-HDRS =	pvmf_media_input_data_buffer.h \
-		pvmf_media_input_node.h \
-        ../include/pvmf_media_input_node_factory.h \
-        ../include/pvmf_media_input_node_events.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvmediainputnode/include/pvmf_media_input_node_events.h b/nodes/pvmediainputnode/include/pvmf_media_input_node_events.h
index 713cba3..d2899f7 100644
--- a/nodes/pvmediainputnode/include/pvmf_media_input_node_events.h
+++ b/nodes/pvmediainputnode/include/pvmf_media_input_node_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmediainputnode/include/pvmf_media_input_node_factory.h b/nodes/pvmediainputnode/include/pvmf_media_input_node_factory.h
index 93f9822..28450cc 100644
--- a/nodes/pvmediainputnode/include/pvmf_media_input_node_factory.h
+++ b/nodes/pvmediainputnode/include/pvmf_media_input_node_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.cpp b/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.cpp
index 4d36b44..da03a14 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.cpp
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
 #include "pvmf_simple_media_buffer.h"
 #endif
 
-PvmfMediaInputDataBufferCleanup::PvmfMediaInputDataBufferCleanup(Oscl_DefAlloc* in_gen_alloc,
+PvmfMediaInputDataBufferCleanup::PvmfMediaInputDataBufferCleanup(OsclMemPoolFixedChunkAllocator* in_gen_alloc,
         PvmiMediaTransfer* aMediaInput,
         PVMFCommandId aCmdId,
         OsclAny* aContext)
@@ -64,10 +64,11 @@
     else
     {
         gen_alloc->deallocate(ptr);
+
     }
 }
 
-PvmfMediaInputDataBufferAlloc::PvmfMediaInputDataBufferAlloc(Oscl_DefAlloc* opt_gen_alloc)
+PvmfMediaInputDataBufferAlloc::PvmfMediaInputDataBufferAlloc(OsclMemPoolFixedChunkAllocator* opt_gen_alloc)
         : gen_alloc(opt_gen_alloc)
 {
     iLogger = PVLogger::GetLoggerObject("PvmfMediaInputDataBufferAlloc");
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.h b/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.h
index a2d2338..12009b2 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.h
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_data_buffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,17 +36,20 @@
 #ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
 #include "pvmf_media_data_impl.h"
 #endif
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
 
 class PvmfMediaInputDataBufferCleanup : public OsclDestructDealloc
 {
     public:
-        PvmfMediaInputDataBufferCleanup(Oscl_DefAlloc* in_gen_alloc, PvmiMediaTransfer* aMediaInput,
+        PvmfMediaInputDataBufferCleanup(OsclMemPoolFixedChunkAllocator* in_gen_alloc, PvmiMediaTransfer* aMediaInput,
                                         PVMFCommandId aCmdId, OsclAny* aContext = NULL);
         virtual ~PvmfMediaInputDataBufferCleanup() {};
         virtual void destruct_and_dealloc(OsclAny* ptr);
 
     private:
-        Oscl_DefAlloc* gen_alloc;
+        OsclMemPoolFixedChunkAllocator* gen_alloc;
 
         // Variables needed to call writeComplete
         PvmiMediaTransfer* iMediaInput;
@@ -59,12 +62,12 @@
 class PvmfMediaInputDataBufferAlloc
 {
     public:
-        PvmfMediaInputDataBufferAlloc(Oscl_DefAlloc* opt_gen_alloc = 0);
+        PvmfMediaInputDataBufferAlloc(OsclMemPoolFixedChunkAllocator* opt_gen_alloc = 0);
         virtual OsclSharedPtr<PVMFMediaDataImpl> allocate(PvmiMediaTransfer* aMediaInput, uint8* aData,
                 uint32 aDataLength, PVMFCommandId aCmdId, OsclAny* aContext = NULL);
 
     private:
-        Oscl_DefAlloc* gen_alloc;
+        OsclMemPoolFixedChunkAllocator* gen_alloc;
         PVLogger* iLogger;
 };
 
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_node.cpp b/nodes/pvmediainputnode/src/pvmf_media_input_node.cpp
index 4cf831e..ea86bd8 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_node.cpp
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,6 +48,15 @@
 #define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
 #define LOGINFO(m) LOGINFOMED(m)
 
+#ifdef _TEST_AE_ERROR_HANDLING
+#define FAIL_NODE_CMD_START 2
+#define FAIL_NODE_CMD_STOP 3
+#define FAIL_NODE_CMD_FLUSH 4
+#define FAIL_NODE_CMD_PAUSE 5
+#define FAIL_NODE_CMD_RELEASE_PORT 7
+#endif
+
+
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFNodeInterface* PvmfMediaInputNodeFactory::Create(PvmiMIOControl* aMIOControl)
 {
@@ -97,6 +106,12 @@
         iMediaIOControl->ThreadLogon();
 
     SetState(EPVMFNodeIdle);
+#ifdef _TEST_AE_ERROR_HANDLING
+    iErrorHandlingStartFailed = false;
+    iErrorHandlingStopFailed = false;
+    iError_No_Memory = false;
+    iError_Out_Queue_Busy = false;
+#endif
     return PVMFSuccess;
 }
 
@@ -147,12 +162,12 @@
     // Get input formats capability from media IO
     kvp = NULL;
     numParams = 0;
-    status = iMediaIOConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+    status = iMediaIOConfig->getParametersSync(NULL, (PvmiKeyType)INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
     if (status == PVMFSuccess)
     {
         OSCL_TRY(err,
                  for (i = 0; i < numParams; i++)
-                 aNodeCapability.iInputFormatCapability.push_back(kvp[i].value.uint32_value);
+                 aNodeCapability.iInputFormatCapability.push_back(PVMFFormatType(kvp[i].value.pChar_value));
                 );
         if (kvp)
             iMediaIOConfig->releaseParameters(0, kvp, numParams);
@@ -162,12 +177,12 @@
     // Get output formats capability from media IO
     kvp = NULL;
     numParams = 0;
-    status = iMediaIOConfig->getParametersSync(NULL, OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+    status = iMediaIOConfig->getParametersSync(NULL, (PvmiKeyType)OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
     if (status == PVMFSuccess)
     {
         OSCL_TRY(err,
                  for (i = 0; i < numParams; i++)
-                 aNodeCapability.iOutputFormatCapability.push_back(kvp[i].value.uint32_value);
+                 aNodeCapability.iOutputFormatCapability.push_back(PVMFFormatType(kvp[i].value.pChar_value));
                 );
         if (kvp)
             iMediaIOConfig->releaseParameters(0, kvp, numParams);
@@ -373,7 +388,7 @@
     {
         iMediaIOCancelPending = false;
 
-        Assert(!iCancelCommand.empty());
+        OSCL_ASSERT(!iCancelCommand.empty());
 
         //Current cancel command is now complete.
         CommandComplete(iCancelCommand, iCancelCommand.front(), PVMFSuccess);
@@ -382,7 +397,7 @@
     else if (iMediaIORequest != ENone
              && aResponse.GetCmdId() == iMediaIOCmdId)
     {
-        Assert(!iCurrentCommand.empty());
+        OSCL_ASSERT(!iCurrentCommand.empty());
         PvmfMediaInputNodeCmd& cmd = iCurrentCommand.front();
 
         switch (iMediaIORequest)
@@ -392,6 +407,19 @@
                 {
                     cmd.iEventCode = PvmfMediaInputNodeErr_MediaIOQueryCapConfigInterface;
                 }
+                else
+                {
+                    if (iMediaIOConfigPVI)
+                    {
+
+                        iMediaIOConfig = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, iMediaIOConfigPVI);
+                        iMediaIOConfigPVI = NULL;
+                    }
+                    else
+                    {
+                        LOGERROR((0, "PvmfMediaInputNode:RequestComplete Error:Not setting Queryinterface ,iTempCapConfigInterface is NULL"));
+                    }
+                }
                 break;
 
             case EInit:
@@ -445,7 +473,7 @@
                 break;
 
             default:
-                Assert(false);
+                OSCL_ASSERT(false);
                 break;
         }
 
@@ -469,16 +497,39 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmfMediaInputNode::ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aEventType);
+    OSCL_UNUSED_ARG(aExtMsg);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmfMediaInputNode::ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aEventType);
+    OSCL_UNUSED_ARG(aExtMsg);
+}
+
+////////////////////////////////////////////////////////////////////////////
 PvmfMediaInputNode::PvmfMediaInputNode()
         : OsclActiveObject(OsclActiveObject::EPriorityNominal, "PvmfMediaInputNode")
         , iMediaIOControl(NULL)
         , iMediaIOSession(NULL)
         , iMediaIOConfig(NULL)
+        , iMediaIOConfigPVI(NULL)
         , iMediaIOState(PvmfMediaInputNode::MIO_STATE_IDLE)
         , iEventUuid(PvmfMediaInputNodeEventTypesUUID)
         , iExtensionRefCount(0)
         , iLogger(NULL)
 {
+#ifdef _TEST_AE_ERROR_HANDLING
+    iChunkCount = 0;
+    iErrorTrackID = -1;
+    iTrackID = 0;
+    iErrorCancelMioRequest = false;
+    iErrorSendMioRequest = 0;
+    iErrorNodeCmd = 0;
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -492,7 +543,7 @@
     //a crash when they callback-- so panic here instead.
     if (!iCancelCommand.empty()
             || iMediaIORequest != ENone)
-        OsclError::Panic("PVMIOND", 1);
+        OSCL_ASSERT(0);
 
     //Cleanup allocated ports
     while (!iOutPortVector.empty())
@@ -566,7 +617,7 @@
     }
 
     //The newest or highest pri command is in the front of the queue.
-    Assert(!iInputCommands.empty());
+    OSCL_ASSERT(!iInputCommands.empty());
     PvmfMediaInputNodeCmd& aCmd = iInputCommands.front();
 
     PVMFStatus cmdstatus;
@@ -594,7 +645,7 @@
                     break;
 
                 default:
-                    Assert(false);
+                    OSCL_ASSERT(false);
                     cmdstatus = PVMFFailure;
                     break;
             }
@@ -672,7 +723,7 @@
                     break;
 
                 default://unknown command type
-                    Assert(false);
+                    OSCL_ASSERT(false);
                     cmdstatus = PVMFFailure;
                     break;
             }
@@ -872,9 +923,9 @@
             //set the format from the mimestring.
             if (mimetype)
             {
-                PVMFFormatType fmt = GetFormatIndex(mimetype->get_str());
-                if (fmt != PVMF_FORMAT_UNKNOWN)
-                    port->Configure(fmt);
+                PVMFFormatType fmt = mimetype->get_str();
+                if (fmt != PVMF_MIME_FORMAT_UNKNOWN)
+                    port->Configure(fmt, mimetype);
             }
 
             //Add the port to the port vector.
@@ -913,6 +964,13 @@
     {
         PvmfMediaInputNodeOutPort* port = (PvmfMediaInputNodeOutPort*)p;
         PvmfMediaInputNodeOutPort** portPtr = iOutPortVector.FindByValue(port);
+
+#ifdef _TEST_AE_ERROR_HANDLING
+        if (FAIL_NODE_CMD_RELEASE_PORT == iErrorNodeCmd)
+        {
+            portPtr = NULL;
+        }
+#endif
         if (portPtr)
         {
             (*portPtr)->Disconnect();
@@ -978,6 +1036,12 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PvmfMediaInputNode::DoStart"));
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_START == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     if (EPVMFNodeStarted == iInterfaceState)
     {
         return PVMFSuccess;
@@ -1004,6 +1068,12 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmfMediaInputNode::DoStop(PvmfMediaInputNodeCmd& aCmd)
 {
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_STOP == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     if (EPVMFNodePrepared == iInterfaceState)
     {
         return PVMFSuccess;
@@ -1025,6 +1095,12 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmfMediaInputNode::DoFlush(PvmfMediaInputNodeCmd& aCmd)
 {
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_FLUSH == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     if (iInterfaceState != EPVMFNodeStarted
             && iInterfaceState != EPVMFNodePaused)
         return PVMFErrInvalidState;
@@ -1076,6 +1152,12 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmfMediaInputNode::DoPause(PvmfMediaInputNodeCmd& aCmd)
 {
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_PAUSE == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     if (EPVMFNodePaused == iInterfaceState)
     {
         return PVMFSuccess;
@@ -1102,13 +1184,7 @@
 
         //logoff & go back to Created state.
         SetState(EPVMFNodeIdle);
-        PVMFStatus status = ThreadLogoff();
-        //currently thread logoff can't fail.
-        //if any error returns are added, then a node error event should
-        //be added also.
-        Assert(status == PVMFSuccess);
-
-        return status;
+        return PVMFSuccess;
     }
     else
     {
@@ -1198,7 +1274,7 @@
 
 
     //there should not be a MIO command in progress..
-    Assert(iMediaIORequest == ENone);
+    OSCL_ASSERT(iMediaIORequest == ENone);
 
 
     //save media io request.
@@ -1214,7 +1290,7 @@
             int32 err ;
             OSCL_TRY(err,
                      iMediaIOCmdId = iMediaIOControl->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                     (PVInterface*&)iMediaIOConfig, NULL);
+                                     iMediaIOConfigPVI, NULL);
                     );
 
             if (err != OsclErrNone)
@@ -1269,6 +1345,12 @@
 
             int32 err ;
             OSCL_TRY(err, iMediaIOCmdId = iMediaIOControl->Start(););
+#ifdef _TEST_AE_ERROR_HANDLING
+            if (iErrorHandlingStartFailed)
+            {
+                err = OsclErrGeneral;
+            }
+#endif
 
             if (err != OsclErrNone)
             {
@@ -1296,6 +1378,13 @@
             int32 err = 0 ;
             OSCL_TRY(err, iMediaIOCmdId = iMediaIOControl->Pause(););
 
+#ifdef _TEST_AE_ERROR_HANDLING
+
+            if (iErrorSendMioRequest == 2)
+            {
+                err = OsclErrGeneral;
+            }
+#endif
             if (err != OsclErrNone)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -1322,6 +1411,12 @@
 
             int32 err ;
             OSCL_TRY(err, iMediaIOCmdId = iMediaIOControl->Stop(););
+#ifdef _TEST_AE_ERROR_HANDLING
+            if (iErrorHandlingStopFailed)
+            {
+                err = OsclErrGeneral;
+            }
+#endif
 
             if (err != OsclErrNone)
             {
@@ -1339,7 +1434,7 @@
 
         default:
             status = PVMFFailure;
-            Assert(false);//unrecognized command.
+            OSCL_ASSERT(false);//unrecognized command.
     }
 
     if (status == PVMFPending)
@@ -1353,14 +1448,21 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmfMediaInputNode::CancelMioRequest(PvmfMediaInputNodeCmd& aCmd)
 {
-    Assert(iMediaIORequest != ENone);
+    OSCL_ASSERT(iMediaIORequest != ENone);
 
-    Assert(!iMediaIOCancelPending);
+    OSCL_ASSERT(!iMediaIOCancelPending);
 
     //Issue the cancel to the MIO.
     iMediaIOCancelPending = true;
     int32 err;
     OSCL_TRY(err, iMediaIOCancelCmdId = iMediaIOControl->CancelCommand(iMediaIOCmdId););
+
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (iErrorCancelMioRequest)
+    {
+        err = OsclErrGeneral;
+    }
+#endif
     if (err != OsclErrNone)
     {
         aCmd.iEventCode = PvmfMediaInputNodeErr_MediaIOCancelCommand;
@@ -1447,15 +1549,7 @@
     return true;
 }
 
-////////////////////////////////////////////////////////////////////////////
-void PvmfMediaInputNode::Assert(bool condition)
-{
-    if (!condition)
-    {
-        LOGERROR((0, "PvmfMediaInputNode::Assert Failed!"));
-        OSCL_ASSERT(0);
-    }
-}
+
 
 
 
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_node.h b/nodes/pvmediainputnode/src/pvmf_media_input_node.h
index 9aa9c5b..28a89a6 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_node.h
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -182,6 +182,8 @@
 
         // PvmiMIOObserver implementation
         OSCL_IMPORT_REF void RequestCompleted(const PVMFCmdResp& aResponse);
+        OSCL_IMPORT_REF void ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL);
+        OSCL_IMPORT_REF void ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL);
 
         friend class PvmfMediaInputNodeOutPort;
 
@@ -260,7 +262,6 @@
         void SetState(TPVMFNodeInterfaceState);
 
         bool PortQueuesEmpty();
-        void Assert(bool condition);
         void SendEndOfTrackCommand(const PvmiMediaXferHeader& data_header_info);
 
         // Node capability.
@@ -275,6 +276,7 @@
         PvmiMIOControl* iMediaIOControl;
         PvmiMIOSession iMediaIOSession;
         PvmiCapabilityAndConfig* iMediaIOConfig;
+        PVInterface* iMediaIOConfigPVI;
         enum
         {
             MIO_STATE_IDLE
@@ -303,6 +305,26 @@
 
         //logger
         PVLogger* iLogger;
+#ifdef _TEST_AE_ERROR_HANDLING
+        bool iErrorHandlingInitFailed;
+        bool iErrorHandlingStartFailed;
+        bool iErrorHandlingStopFailed;
+        bool iErrorCancelMioRequest;
+        bool iError_No_Memory;
+        bool iError_Out_Queue_Busy;
+        uint32 iErrorSendMioRequest;
+        uint32 iErrorNodeCmd;
+        uint32 iChunkCount;
+        int32 iErrorTrackID;
+        uint32 iTrackID;
+        typedef struct timeStamp_keytpe
+        {
+            uint8 mode;
+            uint32 duration;
+            uint32 track_no;
+        }TimeStamp_KSV;
+        TimeStamp_KSV iErrorTimeStamp;
+#endif
 };
 
 #endif // PVMF_MEDIA_INPUT_NODE_H_INCLUDED
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_node_cap_config.cpp b/nodes/pvmediainputnode/src/pvmf_media_input_node_cap_config.cpp
index e59e970..5aa9e7e 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_node_cap_config.cpp
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_node_cap_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,22 +34,50 @@
     PvmiKvpValueType iValueType;
 };
 
+#ifdef _TEST_AE_ERROR_HANDLING
+#define MEDIAINPUTNODECONFIG_BASE_NUMKEYS 12
+#else
 #define MEDIAINPUTNODECONFIG_BASE_NUMKEYS 2
+#endif
 #define MEDIAINPUTCONFIG_KEYSTRING_SIZE 128
 
-static const MediaInputNodeKeyStringData MediaInputNodeConfig_BaseKeys[] =
+const MediaInputNodeKeyStringData MediaInputNodeConfig_BaseKeys[] =
 {
     {"parameter1", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"parameter2", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+#ifdef _TEST_AE_ERROR_HANDLING
+    , {"error_adddatasource_start", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error_adddatasource_stop", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error_no_memorybuffer_avaliable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error_out_queue_busy", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error-time-stamp", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_KSV}
+    , {"error-sendmiorequest", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"error-cancelmiorequest", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error-corruptinputdata", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"error-node-cmd", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"error-data-path-stall", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+#endif
 };
 
 enum BaseKeys_IndexMapType
 {
     PARAMETER1 = 0,
     PARAMETER2
+#ifdef _TEST_AE_ERROR_HANDLING
+    , ERROR_ADDDATASOURCE_START
+    , ERROR_ADDDATASOURCE_STOP
+    , ERROR_NO_MEMORY
+    , ERROR_OUT_QUEUE_BUSY
+    , ERROR_TIME_STAMP
+    , ERROR_SENDMIOREQUEST
+    , ERROR_CANCELMIOREQUEST
+    , ERROR_CORRUPT_INPUTDATA
+    , ERROR_NODE_CMD
+    , ERROR_DATAPATH_STALL
+#endif
 };
 
-static const uint MediaInputNodeConfig_NumBaseKeys =
+const uint MediaInputNodeConfig_NumBaseKeys =
     (sizeof(MediaInputNodeConfig_BaseKeys) /
      sizeof(MediaInputNodeKeyStringData));
 
@@ -131,9 +159,9 @@
         char* compstr = NULL;
         pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
 
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media-io")) < 0) || compcount < 3)
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/datasource")) < 0) || compcount < 3)
         {
-            // First 3 components should be "x-pvmf/media-io" and there must
+            // First 3 components should be "x-pvmf/datasource" and there must
             // be at least four components
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::verifyParametersSync() Unsupported key"));
             return PVMFErrNotSupported;
@@ -178,9 +206,9 @@
     char* compstr = NULL;
     pv_mime_string_extract_type(0, aParameters[0].key, compstr);
 
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media-io")) < 0) || compcount < 2)
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/datasource")) < 0) || compcount < 2)
     {
-        // First 2 component should be "x-pvmf/media-io" and there must
+        // First 2 component should be "x-pvmf/datasource" and there must
         // be at least three components
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::releaseParameters() Unsupported key"));
         return PVMFErrNotSupported;
@@ -219,7 +247,7 @@
                 aParameters[ii].value.key_specific_value = NULL;
                 oscl_free(rui32);
             }
-            // TODO Add more types if media io node starts returning more types
+            // @TODO Add more types if media io node starts returning more types
         }
     }
 
@@ -251,21 +279,21 @@
     char* compstr = NULL;
     pv_mime_string_extract_type(0, aIdentifier, compstr);
 
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media-io")) < 0) || compcount < 2)
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/datasource")) < 0) || compcount < 2)
     {
-        // First 2 components should be "x-pvmf/media-io" and there must
+        // First 2 components should be "x-pvmf/datasource" and there must
         // be at least 2 components
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::getParametersSync() Invalid key string"));
         return PVMFErrNotSupported;
     }
 
-    // Retrieve the fourth component from the key string
+    // Retrieve the third component from the key string
     pv_mime_string_extract_type(2, aIdentifier, compstr);
 
-    for (int32 mediaio4ind = 0; mediaio4ind < MEDIAINPUTNODECONFIG_BASE_NUMKEYS; ++mediaio4ind)
+    for (int32 mediaiovalidind = 0; mediaiovalidind < MEDIAINPUTNODECONFIG_BASE_NUMKEYS; ++mediaiovalidind)
     {
-        // Go through each media io component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(MediaInputNodeConfig_BaseKeys[mediaio4ind].iString)) >= 0)
+        // Go through each media io component string at 3rd level
+        if (pv_mime_strcmp(compstr, (char*)(MediaInputNodeConfig_BaseKeys[mediaiovalidind].iString)) >= 0)
         {
             if (3 == compcount)
             {
@@ -277,7 +305,7 @@
                 }
 
                 // Return the requested info
-                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, mediaio4ind, reqattr);
+                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, mediaiovalidind, reqattr);
                 if (PVMFSuccess != retval)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::getParametersSync() Retrieving media io node parameter failed"));
@@ -291,7 +319,7 @@
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::getParametersSync() Unsupported key"));
                 return PVMFErrNotSupported;
             }
-            // Breakout of the for(mediaio4ind) loop
+            // Breakout of the for(mediaiovalidind) loop
             break;
         }
     }
@@ -334,9 +362,9 @@
         char* compstr = NULL;
         pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
 
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media-io")) < 0) || compcount < 2)
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/datasource")) < 0) || compcount < 2)
         {
-            // First 2 components should be "x-pvmf/media-io" and there must
+            // First 2 components should be "x-pvmf/datasource" and there must
             // be at least four components
             aRetKVP = &aParameters[paramind];
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::setParametersSync() Unsupported key"));
@@ -378,22 +406,22 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::VerifyAndSetConfigParameter() Valtype in key string unknown"));
         return PVMFErrNotSupported;
     }
-    // Retrieve the fourth component from the key string
+    // Retrieve the third component from the key string
     char* compstr = NULL;
     pv_mime_string_extract_type(2, aParameter.key, compstr);
 
-    int32 mediaio4ind;
-    for (mediaio4ind = 0; mediaio4ind < MEDIAINPUTNODECONFIG_BASE_NUMKEYS; ++mediaio4ind)
+    int32 mediaiovalidind;
+    for (mediaiovalidind = 0; mediaiovalidind < MEDIAINPUTNODECONFIG_BASE_NUMKEYS; ++mediaiovalidind)
     {
-        // Go through each component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(MediaInputNodeConfig_BaseKeys[mediaio4ind].iString)) >= 0)
+        // Go through each component string at 3rd level
+        if (pv_mime_strcmp(compstr, (char*)(MediaInputNodeConfig_BaseKeys[mediaiovalidind].iString)) >= 0)
         {
             // Break out of the for loop
             break;
         }
     }
 
-    if (MEDIAINPUTNODECONFIG_BASE_NUMKEYS <= mediaio4ind)
+    if (MEDIAINPUTNODECONFIG_BASE_NUMKEYS <= mediaiovalidind)
     {
         // Match couldn't be found or non-leaf node specified
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::VerifyAndSetConfigParameter() Unsupported key or non-leaf node"));
@@ -401,13 +429,13 @@
     }
 
     // Verify the valtype
-    if (keyvaltype != MediaInputNodeConfig_BaseKeys[mediaio4ind].iValueType)
+    if (keyvaltype != MediaInputNodeConfig_BaseKeys[mediaiovalidind].iValueType)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PvmfMediaInputNode::VerifyAndSetConfigParameter() Valtype does not match for key"));
         return PVMFErrNotSupported;
     }
 
-    switch (mediaio4ind)
+    switch (mediaiovalidind)
     {
         case PARAMETER1: // parameter1
             // Change the parameter
@@ -424,7 +452,75 @@
                 // set the parameter here
             }
             break;
-
+#ifdef _TEST_AE_ERROR_HANDLING
+        case ERROR_ADDDATASOURCE_START://error_adddatasource_start
+            if (aSetParam)
+            {
+                iErrorHandlingStartFailed = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_ADDDATASOURCE_STOP://error_adddatasource_stop
+            if (aSetParam)
+            {
+                iErrorHandlingStopFailed = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_NO_MEMORY:
+            if (aSetParam)
+            {
+                iError_No_Memory = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_OUT_QUEUE_BUSY:
+            if (aSetParam)
+            {
+                iError_Out_Queue_Busy = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_TIME_STAMP: //error-time-stamp
+            if (aSetParam)
+            {
+                TimeStamp_KSV* TempTimeStamp = NULL;
+                TempTimeStamp = OSCL_DYNAMIC_CAST(TimeStamp_KSV*, aParameter.value.key_specific_value);
+                iErrorTimeStamp.mode = TempTimeStamp->mode;
+                iErrorTimeStamp.duration = TempTimeStamp->duration;
+                iErrorTimeStamp.track_no = TempTimeStamp->track_no;
+            }
+            break;
+        case ERROR_SENDMIOREQUEST: //error-sendmiorequest
+            if (aSetParam)
+            {
+                iErrorSendMioRequest = aParameter.value.uint32_value;
+            }
+            break;
+        case ERROR_CANCELMIOREQUEST:  //error-cancelmiorequest
+            if (aSetParam)
+            {
+                iErrorCancelMioRequest = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_CORRUPT_INPUTDATA:  //error-corrupt-input-data
+            if (aSetParam)
+            {
+                iChunkCount = aParameter.value.uint32_value;
+                char* x = (char*)oscl_strstr(aParameter.key, "=");
+                x = x + 1;
+                PV_atoi(x, 'd', oscl_strlen(x), iTrackID);
+            }
+            break;
+        case ERROR_NODE_CMD: //error-node-cmd
+            if (aSetParam)
+            {
+                iErrorNodeCmd = aParameter.value.uint32_value;
+            }
+            break;
+        case ERROR_DATAPATH_STALL: //error-data-path-stall
+            if (aSetParam)
+            {
+                iErrorTrackID = aParameter.value.uint32_value;
+            }
+            break;
+#endif
         default:
             OSCL_ASSERT(0);
     }
@@ -465,7 +561,7 @@
     aParameters[0].key = memblock;
 
     // Copy the key string
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/media-io/"), 21);
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/datasource/"), 21);
     oscl_strncat(aParameters[0].key, MediaInputNodeConfig_BaseKeys[aIndex].iString, oscl_strlen(MediaInputNodeConfig_BaseKeys[aIndex].iString));
     oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";valtype="), 20);
 
@@ -536,7 +632,76 @@
                 // Return capability
             }
             break;
-
+#ifdef _TEST_AE_ERROR_HANDLING
+        case ERROR_ADDDATASOURCE_START: //error_adddatasource_start
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iErrorHandlingStartFailed;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.bool_value = true;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+        case ERROR_ADDDATASOURCE_STOP: //error_adddatasource_stop
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iErrorHandlingStopFailed;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.bool_value = true;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+        case ERROR_NO_MEMORY:
+        {
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iError_No_Memory;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.bool_value = true;
+            }
+            else
+            {
+                // Return capability
+            }
+        }
+        break;
+        case ERROR_OUT_QUEUE_BUSY:
+        {
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iError_Out_Queue_Busy;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.bool_value = true;
+            }
+            else
+            {
+                // Return capability
+            }
+        }
+        break;
+#endif
         default:
             // Invalid index
             oscl_free(aParameters[0].key);
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.cpp b/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.cpp
index 23ce2da..d2c1c37 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.cpp
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,39 +49,89 @@
 #define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
 #define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
 #define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_INFO,m);
 
 ////////////////////////////////////////////////////////////////////////////
 PvmfMediaInputNodeOutPort::PvmfMediaInputNodeOutPort(PvmfMediaInputNode* aNode, const char* aName)
         : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmfMediaInputNodeOutPort")
         , PvmfPortBaseImpl(PVMF_MEDIAIO_NODE_OUTPUT_PORT_TAG
                            //this port handles its own port activity
-                           , this
-                           //input queue isn't needed
-                           , 0, 0, 0
-                           //use an unlimited output queue
-                           , 10, 10, 70, aName)
+                           , this, aName)
         , iNode(aNode)
-        , iMediaDataMemPool(PVMIO_MEDIADATA_POOLNUM)
         , iState(PvmfMediaInputNodeOutPort::PORT_STATE_BUFFERING)
         , inum_text_sample(0)
         , imax_num_sample(0)
 {
     iCmdId = 0;
     AddToScheduler();
-    iFormatType = PVMF_FORMAT_UNKNOWN;
-    iWriteFailed = false;
+    iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
     iPeer = NULL;
+    iWriteState = EWriteOK;
+    iMediaDataAllocMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVMIO_MEDIADATA_POOLNUM));
+    iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVMIO_MEDIADATA_POOLNUM));
+    iMediaDataAlloc = OSCL_NEW(PvmfMediaInputDataBufferAlloc, (iMediaDataAllocMemPool));
+    iDataPathLogger = PVLogger::GetLoggerObject("datapath.sourcenode");
+#ifdef _TEST_AE_EROR_HANDLING
+    iTimeStampJunk = 0x000FFFFF;
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////
 PvmfMediaInputNodeOutPort::~PvmfMediaInputNodeOutPort()
 {
-    ClearMsgQueues();
+    PvmfPortBaseImpl::ClearMsgQueues();
+
+
+    if (iMediaDataAlloc != NULL)
+    {
+        OSCL_DELETE(iMediaDataAlloc);
+    }
+
+    if (iMediaDataAllocMemPool)
+    {
+        iMediaDataAllocMemPool->removeRef();
+    }
+
+    if (iMediaDataMemPool)
+    {
+        iMediaDataMemPool->removeRef();
+    }
+    iDataPathLogger = NULL;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PvmfMediaInputNodeOutPort::Start()
 {
+    iWriteState = EWriteOK;
+#ifdef _TEST_AE_ERROR_HANDLING
+
+    if (iNode->iError_Out_Queue_Busy)
+    {
+        PvmfPortBaseImpl::SetCapacity(EPVIncomingDataQueue, 0);
+        PvmfPortBaseImpl::SetReserve(EPVIncomingDataQueue, 0);
+        PvmfPortBaseImpl::SetThreshold(EPVIncomingDataQueue, 0);
+        PvmfPortBaseImpl::SetCapacity(EPVOutgoingDataQueue, 1);
+        PvmfPortBaseImpl::SetReserve(EPVOutgoingDataQueue, 2);
+        PvmfPortBaseImpl::SetThreshold(EPVOutgoingDataQueue, 100);
+    }
+    else
+    {
+        PvmfPortBaseImpl::SetCapacity(EPVIncomingDataQueue, 0);
+        PvmfPortBaseImpl::SetReserve(EPVIncomingDataQueue, 0);
+        PvmfPortBaseImpl::SetThreshold(EPVIncomingDataQueue, 0);
+        PvmfPortBaseImpl::SetCapacity(EPVOutgoingDataQueue, 10);
+        PvmfPortBaseImpl::SetReserve(EPVOutgoingDataQueue, 10);
+        PvmfPortBaseImpl::SetThreshold(EPVOutgoingDataQueue, 70);
+    }
+#else
+    PvmfPortBaseImpl::SetCapacity(EPVIncomingDataQueue, 0);
+    PvmfPortBaseImpl::SetReserve(EPVIncomingDataQueue, 0);
+    PvmfPortBaseImpl::SetThreshold(EPVIncomingDataQueue, 0);
+    PvmfPortBaseImpl::SetCapacity(EPVOutgoingDataQueue, 10);
+    PvmfPortBaseImpl::SetReserve(EPVOutgoingDataQueue, 10);
+    PvmfPortBaseImpl::SetThreshold(EPVOutgoingDataQueue, 70);
+
+#endif
     iState = PvmfMediaInputNodeOutPort::PORT_STATE_STARTED;
     if (iNode->iMediaIOState == PvmfMediaInputNode::MIO_STATE_STARTED)
     {
@@ -105,12 +155,14 @@
 ////////////////////////////////////////////////////////////////////////////
 void PvmfMediaInputNodeOutPort::Stop()
 {
-    ClearMsgQueues();
+    iWriteState = EWriteOK;
+    PvmfPortBaseImpl::ClearMsgQueues();
     iState = PvmfMediaInputNodeOutPort::PORT_STATE_BUFFERING;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfMediaInputNodeOutPort::Configure(PVMFFormatType aPortProperty)
+PVMFStatus PvmfMediaInputNodeOutPort::Configure(PVMFFormatType aPortProperty,
+        OSCL_String* aMime)
 {
     if (iConnectedPort)
     {
@@ -119,6 +171,7 @@
     }
 
     iFormatType = aPortProperty;
+    iMimeType = *aMime;
     return PVMFSuccess;
 }
 
@@ -162,6 +215,8 @@
         return status;
 
     iNode->iMediaIOControl->deleteMediaTransfer(iNode->iMediaIOSession, iMediaInput);
+    if (iMediaInput)
+        iMediaInput->setPeer(0);
     return PVMFSuccess;
 }
 
@@ -172,6 +227,8 @@
     if (status != PVMFSuccess)
         return status;
 
+    if (iMediaInput)
+        iMediaInput->setPeer(0);
     iNode->iMediaIOControl->deleteMediaTransfer(iNode->iMediaIOSession, iMediaInput);
     return PVMFSuccess;
 }
@@ -195,158 +252,265 @@
         const PvmiMediaXferHeader& data_header_info,
         OsclAny* context)
 {
-    if (PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == format_type)
+    if (iWriteState == EWriteOK)
     {
-        switch (format_index)
+        if (PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION == format_type)
         {
-                //added for timed text support
-                //here it handles the configuration information for timed text and passes it to the composernode
-
-            case PVMI_MEDIAXFER_FMT_INDEX_FMT_SPECIFIC_INFO:
+            switch (format_index)
             {
+                    //added for timed text support
+                    //here it handles the configuration information for timed text and passes it to the composernode
+
+                case PVMI_MEDIAXFER_FMT_INDEX_FMT_SPECIFIC_INFO:
+                {
 #ifdef TEXT_TRACK_DESC_INFO
 
-                if (PVMF_TEXT_FORMAT == iFormatType)
-                {
-                    //get indexing info to map text data with config info
-                    PvmiKvp* textKvp = OSCL_STATIC_CAST(PvmiKvp*, data);
-                    PVA_FF_TextSampleDescInfo* pDecoderinfo;
-                    pDecoderinfo = OSCL_STATIC_CAST(PVA_FF_TextSampleDescInfo*, textKvp->value.key_specific_value);
+                    if (iFormatType == PVMF_MIME_3GPP_TIMEDTEXT)
+                    {
+                        //get indexing info to map text data with config info
+                        PvmiKvp* textKvp = OSCL_STATIC_CAST(PvmiKvp*, data);
+                        PVA_FF_TextSampleDescInfo* pDecoderinfo;
+                        pDecoderinfo = OSCL_STATIC_CAST(PVA_FF_TextSampleDescInfo*, textKvp->value.key_specific_value);
 
-                    itext_sample_index.push_back(pDecoderinfo->sdindex);
-                    istart_text_sample.push_back(pDecoderinfo->start_sample_num);
-                    iend_text_sample.push_back(pDecoderinfo->end_sample_num);
-                    imax_num_sample = pDecoderinfo->end_sample_num;
-                }
+                        itext_sample_index.push_back(pDecoderinfo->sdindex);
+                        istart_text_sample.push_back(pDecoderinfo->start_sample_num);
+                        iend_text_sample.push_back(pDecoderinfo->end_sample_num);
+                        imax_num_sample = pDecoderinfo->end_sample_num + 1;
+                    }
 
-                uint32 cmdId = *(OSCL_STATIC_CAST(uint32*, context));
+                    uint32 cmdId = *(OSCL_STATIC_CAST(uint32*, context));
 
-                PvmiCapabilityAndConfig* config = NULL;
-                iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                               (OsclAny*&)config);
+                    OsclAny* temp = NULL;
+                    iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
-                PvmiKvp* mioKvp = OSCL_STATIC_CAST(PvmiKvp*, data);
-                PvmiKvp* ret_kvp = NULL;
-                config->setParametersSync(NULL, mioKvp, 1, ret_kvp);
-                iMediaInput->writeComplete(PVMFSuccess, cmdId, NULL);
-                return 0;
+                    PvmiKvp* mioKvp = OSCL_STATIC_CAST(PvmiKvp*, data);
+                    PvmiKvp* ret_kvp = NULL;
+                    config->setParametersSync(NULL, mioKvp, 1, ret_kvp);
+                    iMediaInput->writeComplete(PVMFSuccess, cmdId, NULL);
+                    return 0;
 
 #endif
-            }
-            break;
-            case PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM:
-            {
+                }
+                break;
+                case PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM:
+                {
 
-                SendEndOfTrackCommand(data_header_info);
-                MediaIOStarted();
+                    SendEndOfTrackCommand(data_header_info);
+                    MediaIOStarted();
 
-                iState = PvmfMediaInputNodeOutPort::PORT_STATE_ENDOFTRACK;
-                return iCmdId++;
-            }
-            break;
-            default:
-            {
-                LOG_DEBUG((0, "Ignoring Format Index :%d since not supported\n", format_index));
+                    return iCmdId++;
+                }
+                break;
+                default:
+                {
+                    LOG_DEBUG((0, "Ignoring Format Index :%d since not supported\n", format_index));
 
-                iNode->ReportErrorEvent(PVMFErrPortProcessing);
-                OsclError::Leave(OsclErrGeneral);
+                    iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)NULL);
+                    OsclError::Leave(OsclErrGeneral);
+
+                }
 
             }
 
         }
 
+        // TODO: Handle incoming data here. Create a media data using PvmiMIOSourceDataBufferAlloc::allocate,
+        // save the data there, put the media data to outgoing queue.
+        // If the port is started, schedule to send in Run
+
+        else if (PVMI_MEDIAXFER_FMT_TYPE_DATA == format_type)
+        {
+            //if the outgoing queue is full, we can't accept data
+            //now.
+
+            if (IsOutgoingQueueBusy())
+            {
+                iWriteState = EWriteBusy;
+                OsclError::Leave(OsclErrBusy);
+            }
+
+            // Create new media data buffer
+            PVMFSharedMediaDataPtr mediaData;
+            int32 err = 0;
+
+            if (iCmdId == 0x7FFFFFFF)
+                iCmdId = 0;
+#ifdef _TEST_AE_ERROR_HANDLING
+
+            if (data_header_info.stream_id == iNode->iTrackID)
+            {
+                uint32 ii = 0;
+                while (iNode->iChunkCount > 0)
+                {
+                    uint32 sz = data_len - 5;
+
+                    for (ii = 0; ii <= sz; ii++)
+                    {
+                        uint8* ptr = data + ii;
+                        *ptr = 0;
+                    }
+
+                    iNode->iChunkCount--;
+                }
+
+            }
+#endif
+#ifdef _TEST_AE_ERROR_HANDLING
+            if (iNode->iError_No_Memory)
+            {
+                err = OsclErrBusy;
+                if (IsAdded())
+                {
+                    RunIfNotReady();
+                }
+            }
+            else
+            {
+                OSCL_TRY(err,
+                         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(iMediaInput, data,
+                                 data_len, iCmdId, context);
+                         mediaData = PVMFMediaData::createMediaData(mediaDataImpl, iMediaDataMemPool););
+            }
+#else
+            OSCL_TRY(err,
+                     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(iMediaInput, data,
+                             data_len, iCmdId, context);
+                     mediaData = PVMFMediaData::createMediaData(mediaDataImpl, iMediaDataMemPool););
+
+
+#endif
+            if (err)
+            {
+                iMediaDataAllocMemPool->notifyfreechunkavailable(*this);
+                iWriteState = EWriteBusy;
+                OsclError::Leave(OsclErrBusy);
+            }
+            // Set timestamp
+#ifdef _TEST_AE_ERROR_HANDLING
+
+            if ((data_header_info.stream_id == iNode->iErrorTimeStamp.track_no) && (1 == iNode->iErrorTimeStamp.mode))
+            {
+
+                if (iTimeStampJunk == 0)
+                {
+                    iTimeStampJunk = 0x000FFFFF;
+                }
+
+                mediaData->setTimestamp(iTimeStampJunk);
+                iTimeStampJunk = iTimeStampJunk - 33;
+            }
+            else if ((data_header_info.stream_id == iNode->iErrorTimeStamp.track_no) && (2 == iNode->iErrorTimeStamp.mode))
+            {
+                if (data_header_info.timestamp >= iNode->iErrorTimeStamp.duration)
+                {
+                    mediaData->setTimestamp(0);
+                }
+            }
+            else if ((data_header_info.stream_id == iNode->iErrorTimeStamp.track_no) && (3 == iNode->iErrorTimeStamp.mode))
+            {
+                mediaData->setTimestamp(0);
+            }
+            else
+            {
+                mediaData->setTimestamp(data_header_info.timestamp);
+            }
+#else
+            mediaData->setTimestamp(data_header_info.timestamp);
+#endif
+            mediaData->setSeqNum(data_header_info.seq_num);
+            mediaData->setMediaFragFilledLen(0, data_len);
+            mediaData->setStreamID(data_header_info.stream_id);
+
+            LOGDATATRAFFIC((0, "PvmfMediaInputNodeOutPort::writeAsync:"
+                            "StreamID=%d, TS=%d, Len=%d, SN=%d, MimeType=%s",
+                            data_header_info.stream_id,  data_header_info.timestamp, data_len,
+                            data_header_info.seq_num, iMimeType.get_cstr()));
+            if (itext_sample_index.size())
+            {
+                bool found = false;
+                OsclMemAllocDestructDealloc<uint8> my_alloc;
+                OsclRefCounter* my_refcnt;
+                uint aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+                uint8* my_ptr = (uint8*) my_alloc.allocate(aligned_refcnt_size + sizeof(int32));
+                my_refcnt = new(my_ptr) OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr);
+                my_ptr += aligned_refcnt_size;
+
+                OsclMemoryFragment memfrag;
+                memfrag.len = 0;
+                memfrag.ptr = my_ptr;
+
+                memfrag.len = sizeof(int32);
+
+                if (inum_text_sample >= imax_num_sample)
+                {
+                    while (inum_text_sample >= imax_num_sample)
+                    {
+                        inum_text_sample = inum_text_sample - imax_num_sample;
+                    }
+                }
+                for (uint32 ii = 0; ii < itext_sample_index.size(); ii++)
+                {
+                    if (inum_text_sample >= istart_text_sample[ii] && inum_text_sample <= iend_text_sample[ii])
+                    {
+                        found = true;
+                        memfrag.ptr = &(itext_sample_index[ii]);//vector stores the sample index no.
+                    }//this index no. gives the sample description index information
+                    if (found)
+                    {
+                        break;
+                    }
+                }
+
+                inum_text_sample += 1;
+                // Save format specific info
+                OsclRefCounterMemFrag configinfo(memfrag, my_refcnt, sizeof(int32));
+                iFormatSpecificInfo = configinfo;
+                mediaData->setFormatSpecificInfo(iFormatSpecificInfo);
+            }
+            // Convert media data to MediaMsg
+            PVMFSharedMediaMsgPtr mediaMsg;
+            convertToPVMFMediaMsg(mediaMsg, mediaData);
+            PVMFStatus status;
+#ifdef _TEST_AE_ERROR_HANDLING
+
+            if ((iNode->iErrorTrackID > 0) && (data_header_info.stream_id == (uint32)iNode->iErrorTrackID))
+            {
+                status = PVMFSuccess;
+            }
+            else
+            {
+                status = QueueOutgoingMsg(mediaMsg);
+            }
+#else
+            status = QueueOutgoingMsg(mediaMsg);
+
+#endif
+            if (status != PVMFSuccess)
+            {
+                iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)status);
+                OsclError::Leave(OsclErrGeneral);
+            }
+
+            if (iState == PvmfMediaInputNodeOutPort::PORT_STATE_STARTED)
+                RunIfNotReady();
+
+            return iCmdId++;
+        }
+        else
+        {
+            LOG_DEBUG((0, "Ignoring Format Type :%d since not supported\n", format_type));
+            iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)NULL);
+            OsclError::Leave(OsclErrGeneral);
+        }
     }
-
-    // TODO: Handle incoming data here. Create a media data using PvmiMIOSourceDataBufferAlloc::allocate,
-    // save the data there, put the media data to outgoing queue.
-    // If the port is started, schedule to send in Run
-
     else
     {
-        //if the outgoing queue is full, we can't accept data
-        //now.
-        if (IsOutgoingQueueBusy())
-        {
-            iWriteFailed = true;
-            OsclError::Leave(OsclErrGeneral);
-        }
-
-        // Create new media data buffer
-        PVMFSharedMediaDataPtr mediaData;
-        int32 err = 0;
-
-        if (iCmdId == 0x7FFFFFFF)
-            iCmdId = 0;
-
-        OSCL_TRY(err,
-                 OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc.allocate(iMediaInput, data,
-                         data_len, iCmdId, context);
-                 mediaData = PVMFMediaData::createMediaData(mediaDataImpl, &iMediaDataMemPool);
-                );
-
-        // Set timestamp
-        mediaData->setTimestamp(data_header_info.timestamp);
-        mediaData->setSeqNum(data_header_info.seq_num);
-        mediaData->setMediaFragFilledLen(0, data_len);
-        mediaData->setStreamID(data_header_info.stream_id);
-
-        if (itext_sample_index.size())
-        {
-            bool found = false;
-            OsclMemAllocDestructDealloc<uint8> my_alloc;
-            OsclRefCounter* my_refcnt;
-            uint aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
-            uint8* my_ptr = (uint8*) my_alloc.allocate(aligned_refcnt_size + sizeof(int32));
-            my_refcnt = new(my_ptr) OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr);
-            my_ptr += aligned_refcnt_size;
-
-            OsclMemoryFragment memfrag;
-            memfrag.len = 0;
-            memfrag.ptr = my_ptr;
-
-            memfrag.len = sizeof(int32);
-            if (inum_text_sample > imax_num_sample)
-            {
-                while (inum_text_sample > imax_num_sample)
-                {
-                    inum_text_sample = inum_text_sample - imax_num_sample;
-                }
-            }
-            for (uint32 ii = 0; ii < itext_sample_index.size(); ii++)
-            {
-                if (inum_text_sample >= istart_text_sample[ii] && inum_text_sample <= iend_text_sample[ii])
-                {
-                    found = true;
-                    memfrag.ptr = &(itext_sample_index[ii]);//vector stores the sample index no.
-                }//this index no. gives the sample description index information
-                if (found)
-                {
-                    break;
-                }
-            }
-
-            inum_text_sample += 1;
-            // Save format specific info
-            OsclRefCounterMemFrag configinfo(memfrag, my_refcnt, sizeof(int32));
-            iFormatSpecificInfo = configinfo;
-            mediaData->setFormatSpecificInfo(iFormatSpecificInfo);
-        }
-        // Convert media data to MediaMsg
-        PVMFSharedMediaMsgPtr mediaMsg;
-        convertToPVMFMediaMsg(mediaMsg, mediaData);
-
-        PVMFStatus status = QueueOutgoingMsg(mediaMsg);
-        if (status != PVMFSuccess)
-        {
-            iNode->ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)status);
-            OsclError::Leave(OsclErrGeneral);
-        }
-
-        if (iState == PvmfMediaInputNodeOutPort::PORT_STATE_STARTED)
-            RunIfNotReady();
-
-        return iCmdId++;
+        OsclError::Leave(OsclErrBusy);
     }
+
+    return 0;
+
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -534,8 +698,18 @@
     if (iState == PvmfMediaInputNodeOutPort::PORT_STATE_BUFFERING)
         return;
 
-    if (OutgoingMsgQueueSize() > 0
-            && !IsConnectedPortBusy())
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (iNode->iError_No_Memory)
+    {
+        if (iMediaInput && iWriteState == EWriteBusy)
+        {
+            iWriteState = EWriteOK;
+            iMediaInput->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+            iNode->iError_No_Memory = false;
+        }
+    }
+#endif
+    if ((OutgoingMsgQueueSize() > 0) && (!IsConnectedPortBusy()))
     {
         //transfer data to connected port.
         PVMFStatus status = Send();
@@ -562,6 +736,33 @@
 {
     switch (aActivity.iType)
     {
+        case PVMF_PORT_ACTIVITY_CONNECT:
+        {
+            //get the mimetype
+            OsclAny* temp = NULL;
+            iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+            PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
+            if (config != NULL)
+            {
+                int numKvp = 0;
+                PvmiKvp* kvpPtr = NULL;
+                PVMFStatus status =
+                    config->getParametersSync(NULL,
+                                              (char*)INPUT_FORMATS_CUR_QUERY, kvpPtr, numKvp, NULL);
+                if (status == PVMFSuccess)
+                {
+                    iFormatType = kvpPtr[0].value.pChar_value;
+                    iMimeType = iFormatType.getMIMEStrPtr();
+                }
+                config->releaseParameters(NULL, kvpPtr, numKvp);
+            }
+        }
+        break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            break;
+
         case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
             //wakeup the AO when the first message arrives.
             if (OutgoingMsgQueueSize() == 1)
@@ -575,15 +776,20 @@
             break;
 
         case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            if (iWriteFailed)
+            if (iMediaInput && (iWriteState == EWriteBusy))
             {
-                iWriteFailed = false;
+                iWriteState = EWriteOK;
                 //let the peer know they can try to write again.
-                if (iPeer)
-                    iPeer->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+                iMediaInput->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
             }
             break;
-
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
+        {
+            iWriteState = EWriteBusy;
+        }
+        break;
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
+            break;
         default:
             break;
     }
@@ -612,5 +818,20 @@
         OsclError::Leave(OsclErrGeneral);
     }
 
+    LOGDATATRAFFIC((0, "PvmfMediaInputNodeOutPort::SendEndOfTrackCommand - EOS Sent:"
+                    "StreamID=%d, TS=%d, SN=%d, MimeType=%s",
+                    data_header_info.stream_id,  data_header_info.timestamp,
+                    data_header_info.seq_num, iMimeType.get_cstr()));
 }
 
+void PvmfMediaInputNodeOutPort :: freechunkavailable(OsclAny*)
+{
+    if (iWriteState == EWriteBusy)
+    {
+        iWriteState = EWriteOK;
+        if (IsAdded())
+        {
+            iMediaInput->statusUpdate(PVMI_MEDIAXFER_STATUS_WRITE);
+        }
+    }
+}
diff --git a/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.h b/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.h
index 708aabd..97dc3e7 100644
--- a/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.h
+++ b/nodes/pvmediainputnode/src/pvmf_media_input_node_outport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,6 +63,7 @@
 class PvmfMediaInputNode;
 
 class PvmfMediaInputNodeOutPort : public OsclTimerObject,
+            public OsclMemPoolFixedChunkAllocatorObserver,
             public PvmfPortBaseImpl,
             public PvmiMediaTransfer,
             public PVMFPortActivityHandler,
@@ -77,7 +78,7 @@
         void Pause();
         void Stop();
 
-        PVMFStatus Configure(PVMFFormatType aPortProperty);
+        PVMFStatus Configure(PVMFFormatType aPortProperty, OSCL_String* aMime);
 
         // these override the PvmfPortBaseImpl routines
         OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
@@ -133,7 +134,7 @@
     private:
 
         void Run();
-
+        void freechunkavailable(OsclAny*);
         // Container node
         PvmfMediaInputNode* iNode;
 
@@ -145,9 +146,12 @@
 
         uint32 iCmdId;
 
-        PvmfMediaInputDataBufferAlloc iMediaDataAlloc;
-        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
+        PvmfMediaInputDataBufferAlloc* iMediaDataAlloc;
+        OsclMemPoolFixedChunkAllocator* iMediaDataAllocMemPool;
+        OsclMemPoolFixedChunkAllocator* iMediaDataMemPool;
 
+        enum WriteState {EWriteBusy, EWriteOK};
+        WriteState iWriteState;
         enum PortState
         {
             PORT_STATE_BUFFERING = 0,
@@ -158,7 +162,7 @@
         PVMFFormatType iFormat;
 
         //for flow control
-        bool iWriteFailed;
+
         PvmiMediaTransfer* iPeer;
 
 
@@ -170,6 +174,12 @@
         OsclRefCounterMemFrag iFormatSpecificInfo;
         uint32 inum_text_sample;
         uint32 imax_num_sample;
+#ifdef _TEST_AE_ERROR_HANDLING
+        uint32 iTimeStampJunk;
+#endif
+        //logging
+        OSCL_HeapString<OsclMemAllocator> iMimeType;
+        PVLogger* iDataPathLogger;
 };
 
 #endif // PVMF_MEDIA_INPUT_NODE_INPORT_H_INCLUDED
diff --git a/nodes/pvmediaoutputnode/Android.mk b/nodes/pvmediaoutputnode/Android.mk
index bd55c2f..1ef74f9 100644
--- a/nodes/pvmediaoutputnode/Android.mk
+++ b/nodes/pvmediaoutputnode/Android.mk
@@ -3,30 +3,33 @@
 
 LOCAL_SRC_FILES := \
 	src/pv_media_output_node_inport.cpp \
-	src/pv_media_output_node.cpp
-
+ 	src/pv_media_output_node.cpp
 
 
 LOCAL_MODULE := libpvmediaoutputnode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvmediaoutputnode/src \
-	$(PV_TOP)//nodes/pvmediaoutputnode/src \
-	$(PV_TOP)//nodes/pvmediaoutputnode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvmediaoutputnode/../../nodes/common/include \
-	$(PV_TOP)//nodes/pvmediaoutputnode/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvmediaoutputnode/src \
+ 	$(PV_TOP)/nodes/pvmediaoutputnode/src \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/nodes/pvmediaoutputnode/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/pv_media_output_node.h \
-	src/../include/pv_media_output_node_factory.h \
-	src/../include/pv_media_output_node_registry_factory.h \
-	src/../include/pv_media_output_node_events.h
+ 	src/../include/pv_media_output_node_factory.h \
+ 	src/../include/pv_media_output_node_registry_factory.h \
+ 	src/../include/pv_media_output_node_events.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvmediaoutputnode/build/make/local.mk b/nodes/pvmediaoutputnode/build/make/local.mk
new file mode 100644
index 0000000..0d94447
--- /dev/null
+++ b/nodes/pvmediaoutputnode/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmediaoutputnode
+
+
+
+
+XINCDIRS += ../../../../pvmi/pvmf/include ../../../../nodes/common/include ../../include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pv_media_output_node_inport.cpp \
+	pv_media_output_node.cpp 
+
+HDRS := pv_media_output_node.h \
+        ../include/pv_media_output_node_factory.h \
+        ../include/pv_media_output_node_registry_factory.h \
+        ../include/pv_media_output_node_events.h
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvmediaoutputnode/build/make/makefile b/nodes/pvmediaoutputnode/build/make/makefile
deleted file mode 100644
index 496e8b3..0000000
--- a/nodes/pvmediaoutputnode/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmediaoutputnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../../../pvmi/pvmf/include -I../../../../nodes/common/include -I../../include 
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	pv_media_output_node_inport.cpp \
-	pv_media_output_node.cpp 
-
-HDRS =	pv_media_output_node.h \
-        ../include/pv_media_output_node_factory.h \
-        ../include/pv_media_output_node_registry_factory.h \
-        ../include/pv_media_output_node_events.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvmediaoutputnode/include/pv_media_output_node_events.h b/nodes/pvmediaoutputnode/include/pv_media_output_node_events.h
index c7c29c7..9e825b2 100644
--- a/nodes/pvmediaoutputnode/include/pv_media_output_node_events.h
+++ b/nodes/pvmediaoutputnode/include/pv_media_output_node_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,6 +78,7 @@
     , PVMFMoutNodeErr_MediaIOFlush
     , PVMFMoutNodeErr_MediaIODiscardData
     , PVMFMoutNodeErr_MediaIOCancelCommand
+    , PVMFMoutNodeErr_MediaIOReset
 
     //These error codes indicate errors in the data transfer to the media
     //Output componenet
diff --git a/nodes/pvmediaoutputnode/include/pv_media_output_node_factory.h b/nodes/pvmediaoutputnode/include/pv_media_output_node_factory.h
index e2e568d..591e250 100644
--- a/nodes/pvmediaoutputnode/include/pv_media_output_node_factory.h
+++ b/nodes/pvmediaoutputnode/include/pv_media_output_node_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmediaoutputnode/include/pv_media_output_node_registry_factory.h b/nodes/pvmediaoutputnode/include/pv_media_output_node_registry_factory.h
index b13d91d..02a45ec 100644
--- a/nodes/pvmediaoutputnode/include/pv_media_output_node_registry_factory.h
+++ b/nodes/pvmediaoutputnode/include/pv_media_output_node_registry_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmediaoutputnode/src/pv_media_output_node.cpp b/nodes/pvmediaoutputnode/src/pv_media_output_node.cpp
index cfe5b91..26461cd 100644
--- a/nodes/pvmediaoutputnode/src/pv_media_output_node.cpp
+++ b/nodes/pvmediaoutputnode/src/pv_media_output_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
 #define LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
 #define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
 #define LOGINFO(m) LOGINFOMED(m)
+#define LOGDIAGNOSTICS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF,iDiagnosticsLogger,PVLOGMSG_INFO,m);
 
 //this should always be 1. set this to zero if
 //you want to bypass avsync (typically used in
@@ -47,16 +48,6 @@
 #define PVMF_MEDIA_OUTPUT_NODE_ENABLE_AV_SYNC 1
 
 ////////////////////////////////////////////////////////////////////////////
-void PVMediaOutputNode::Assert(bool condition)
-{
-    if (!condition)
-    {
-        LOGERROR((0, "PVMediaOutputNode::Assert Failed!"));
-        OSCL_ASSERT(0);
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFNodeInterface* PVMediaOutputNodeFactory::CreateMediaOutputNode(
     PvmiMIOControl* aMIOControl)
 {
@@ -91,6 +82,8 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMediaOutputNode::~PVMediaOutputNode()
 {
+    LogDiagnostics();
+
     Cancel();
     if (IsAdded())
         RemoveFromScheduler();
@@ -110,7 +103,7 @@
     //a crash when they callback-- so panic here instead.
     if (!iCancelCommand.empty()
             || iMediaIORequest != ENone)
-        OsclError::Panic("PVMOUT", PVMoutPanic_OutstandingMIO_Command);
+        OSCL_ASSERT(0);//OsclError::Panic("PVMOUT",PVMoutPanic_OutstandingMIO_Command);
 
     //Cleanup allocated ports
     while (!iInPortVector.empty())
@@ -138,6 +131,7 @@
 
     iLogger = PVLogger::GetLoggerObject("PVMediaOutputNode");
     iReposLogger = PVLogger::GetLoggerObject("pvplayerrepos.mionode");
+    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.mionode");
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMediaOutputNode::ThreadLogon"));
@@ -151,6 +145,13 @@
         iMediaIOState = STATE_LOGGED_ON;
     }
 
+    if (iMIOControl->connect(iMIOSession, this) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMediaOutputNode::ThreadLogon: Error - iMIOControl->connect failed"));
+        return PVMFFailure;
+    }
+
     SetState(EPVMFNodeIdle);
     return PVMFSuccess;
 }
@@ -180,7 +181,7 @@
         // This is to reduce risk to existing MIOs.
         //
         // It can be moved to the internal node reset in the future.
-        PVMFStatus status = iMIOControl->Reset(iMIOSession);
+        PVMFStatus status = PVMFFailure;
         status = iMIOControl->disconnect(iMIOSession);
         //ignore any returned errors.
         iMIOControl->ThreadLogoff();
@@ -211,12 +212,12 @@
     // Get input formats capability from media IO
     kvp = NULL;
     numParams = 0;
-    status = iMIOConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+    status = iMIOConfig->getParametersSync(NULL, (char*)INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
     if (status == PVMFSuccess)
     {
         OSCL_TRY(err,
                  for (i = 0; i < numParams; i++)
-                 aNodeCapability.iInputFormatCapability.push_back(kvp[i].value.uint32_value);
+                 aNodeCapability.iInputFormatCapability.push_back(PVMFFormatType(kvp[i].value.pChar_value));
                 );
         if (kvp)
             iMIOConfig->releaseParameters(0, kvp, numParams);
@@ -226,12 +227,12 @@
     // Get output formats capability from media IO
     kvp = NULL;
     numParams = 0;
-    status = iMIOConfig->getParametersSync(NULL, OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+    status = iMIOConfig->getParametersSync(NULL, (char*)OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
     if (status == PVMFSuccess)
     {
         OSCL_TRY(err,
                  for (i = 0; i < numParams; i++)
-                 aNodeCapability.iOutputFormatCapability.push_back(kvp[i].value.uint32_value);
+                 aNodeCapability.iOutputFormatCapability.push_back(PVMFFormatType(kvp[i].value.pChar_value));
                 );
         if (kvp)
             iMIOConfig->releaseParameters(0, kvp, numParams);
@@ -425,7 +426,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMediaOutputNode::SetClock(OsclClock* aClock)
+OSCL_EXPORT_REF PVMFStatus PVMediaOutputNode::SetClock(PVMFMediaClock* aClock)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMediaOutputNode::SetClock: aClock=0x%x", aClock));
@@ -524,10 +525,8 @@
 
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFCommandId PVMediaOutputNode::SkipMediaData(PVMFSessionId s,
-        PVMFTimestamp aStartingTimestamp,
         PVMFTimestamp aResumeTimestamp,
         uint32 aStreamID,
-        bool aRenderSkippedData ,
         bool aPlayBackPositionContinuous,
         OsclAny* aContext)
 {
@@ -538,9 +537,7 @@
     PVMediaOutputNodeCmd cmd;
     cmd.Construct(s,
                   PVMF_MEDIAOUTPUTNODE_SKIPMEDIADATA,
-                  aStartingTimestamp,
                   aResumeTimestamp,
-                  aRenderSkippedData,
                   aStreamID,
                   aPlayBackPositionContinuous,
                   aContext);
@@ -560,7 +557,7 @@
     {
         iMediaIOCancelPending = false;
 
-        Assert(!iCancelCommand.empty());
+        OSCL_ASSERT(!iCancelCommand.empty());
 
         //Current cancel command is now complete.
         CommandComplete(iCancelCommand, iCancelCommand.front(), PVMFSuccess);
@@ -569,12 +566,14 @@
     else if (iMediaIORequest != ENone
              && aResponse.GetCmdId() == iMediaIOCmdId)
     {
-        Assert(!iCurrentCommand.empty());
+        OSCL_ASSERT(!iCurrentCommand.empty());
         PVMediaOutputNodeCmd& cmd = iCurrentCommand.front();
 
         switch (iMediaIORequest)
         {
             case EQueryCapability:
+                iMIOConfig = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, iMIOConfigPVI);
+                iMIOConfigPVI = NULL;
                 if (aResponse.GetCmdStatus() != PVMFSuccess)
                     cmd.iEventCode = PVMFMoutNodeErr_MediaIOQueryCapConfigInterface;
                 CommandComplete(iCurrentCommand, iCurrentCommand.front(), aResponse.GetCmdStatus());
@@ -583,6 +582,8 @@
             case EQueryClockExtension:
                 //ignore any error from this query since the interface is optional.
                 iMediaIORequest = ENone;
+                iMIOClockExtension = OSCL_STATIC_CAST(PvmiClockExtensionInterface*, iMIOClockExtensionPVI);
+                iMIOClockExtensionPVI = NULL;
                 //re-do the clock setting call since iMIOClockExtension may have changed.
                 if (aResponse.GetCmdStatus() == PVMFSuccess
                         && iMIOClockExtension)
@@ -651,8 +652,22 @@
             }
             break;
 
+            case EReset:
+            {
+                if (aResponse.GetCmdStatus() != PVMFSuccess)
+                {
+                    cmd.iEventCode = PVMFMoutNodeErr_MediaIOReset;
+                }
+                else
+                {
+                    iMediaIOState = STATE_LOGGED_ON;
+                }
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), aResponse.GetCmdStatus());
+            }
+            break;
+
             default:
-                Assert(false);
+                OSCL_ASSERT(false);
                 CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
                 break;
         }
@@ -666,6 +681,25 @@
     }
 }
 
+OSCL_EXPORT_REF void PVMediaOutputNode::ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aEventType);
+    OSCL_UNUSED_ARG(aExtMsg);
+}
+OSCL_EXPORT_REF void PVMediaOutputNode::ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aExtMsg);
+    if (PVMFMIOConfigurationComplete == aEventType)
+    {
+        LOGINFO((0, "PVMediaOutputNode::ReportInfoEvent PVMFMIOConfigurationComplete received"));
+        for (uint32 i = 0; i < iInPortVector.size(); i++)
+        {
+            iInPortVector[i]->SetMIOComponentConfigStatus(true);
+        }
+    }
+}
+
+
 ////////////////////////////////////////////////////////////////////////////
 PVMediaOutputNode::PVMediaOutputNode()
         : OsclActiveObject(OsclActiveObject::EPriorityNominal, "PVMediaOutputNode")
@@ -673,12 +707,17 @@
         , iMIOControl(NULL)
         , iMIOSession(NULL)
         , iMIOConfig(NULL)
+        , iMIOConfigPVI(NULL)
+        , iMediaIOState(STATE_IDLE)
         , iClock(NULL)
         , iEarlyMargin(DEFAULT_EARLY_MARGIN)
         , iLateMargin(DEFAULT_LATE_MARGIN)
+        , iDiagnosticsLogger(NULL)
+        , iDiagnosticsLogged(false)
         , iExtensionRefCount(0)
         , iLogger(NULL)
-        , iMediaIOState(STATE_IDLE)
+        , iReposLogger(NULL)
+        , iRecentBOSStreamID(0)
 {
 }
 
@@ -694,7 +733,8 @@
     iMediaIORequest = ENone;
     iMediaIOCancelPending = false;
     iMIOClockExtension = NULL;
-    iClockRate = 1;
+    iMIOClockExtensionPVI = NULL;
+    iClockRate = 100000;
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -764,6 +804,9 @@
                         iInPortVector[i]->ResumeInput();
                 }
                 break;
+            case PVMF_GENERIC_NODE_RESET:
+                SetState(EPVMFNodeIdle);
+                break;
             default:
                 break;
         }
@@ -874,7 +917,7 @@
     }
 
     //The newest or highest pri command is in the front of the queue.
-    Assert(!iInputCommands.empty());
+    OSCL_ASSERT(!iInputCommands.empty());
     PVMediaOutputNodeCmd& aCmd = iInputCommands.front();
 
     PVMFStatus cmdstatus;
@@ -902,7 +945,7 @@
                     break;
 
                 default:
-                    Assert(false);
+                    OSCL_ASSERT(false);
                     cmdstatus = PVMFFailure;
                     break;
             }
@@ -986,7 +1029,7 @@
                     break;
 
                 default://unknown command type
-                    Assert(false);
+                    OSCL_ASSERT(false);
                     cmdstatus = PVMFFailure;
                     break;
             }
@@ -1069,21 +1112,6 @@
             }
             PVMediaOutputNodePort *port = OSCL_PLACEMENT_NEW(ptr, PVMediaOutputNodePort(this));
 
-            //set the format from the mimestring, if provided
-            if (mimetype)
-            {
-                GetFormatIndex(mimetype->get_str());
-                PVMFStatus status = port->Configure(*mimetype);
-                if (status != PVMFSuccess)
-                {
-                    //bad format!
-                    iInPortVector.DestructAndDealloc(port);
-                    return PVMFErrArgument;
-                }
-            }
-
-            iSinkFormatString = *mimetype;
-
             //Add the port to the port vector.
             OSCL_TRY(err, iInPortVector.AddL(port););
             if (err != OsclErrNone)
@@ -1092,6 +1120,21 @@
                 return PVMFErrNoMemory;
             }
 
+            //set the format from the mimestring, if provided
+            if (mimetype)
+            {
+                PVMFStatus status = port->Configure(*mimetype);
+                if (status != PVMFSuccess)
+                {
+                    //bad format!
+                    iInPortVector.Erase(&port);
+                    iInPortVector.DestructAndDealloc(port);
+                    return PVMFErrArgument;
+                }
+            }
+
+            iSinkFormatString = *mimetype;
+
             //pass the current clock settings to the port.
             SetClock(iClock);
 
@@ -1129,14 +1172,6 @@
         return PVMFFailure;
     }
 
-    if (iMIOControl->connect(iMIOSession, this) != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMediaOutputNode::DoInit: Error - iMIOControl->connect failed"));
-        aCmd.iEventCode = PVMFMoutNodeErr_MediaIOConnect;
-        return PVMFFailure;
-    }
-
     //Query for MIO interfaces.
     return SendMioRequest(aCmd, EQueryClockExtension);
 }
@@ -1164,35 +1199,15 @@
             && iInterfaceState != EPVMFNodePaused)
         return PVMFErrInvalidState;
 
-    //see whether to delay the MIO start command until config info
-    //is received on the port.  When the config is received the
-    //port will call MioConfigured. Media output node start will
-    //not complete till MioConfigured is called.
-    if (iInPortVector.size() > 0 && iInPortVector[0]->iWaitForConfig)
-    {
-        return PVMFPending;
-    }
+    iDiagnosticsLogged = false;
+    iInPortVector[0]->iFramesDropped = 0;
+    iInPortVector[0]->iTotalFrames = 0;
+
     //Start the MIO
+
     return SendMioRequest(aCmd, EStart);
 }
 
-////////////////////////////////////////////////////////////////////////////
-void PVMediaOutputNode::MioConfigured()
-//called by the port when the MIO was just configured.
-//only called for ports that need to wait on config before starting
-//the MIO.
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMediaOutputNode::MioConfigured() called"));
-    if (iCurrentCommand.front().iCmd == PVMF_GENERIC_NODE_START)
-    {
-        //implies that media output node start is waiting for
-        //media output comp to be configured
-        //Now that media output comp has been configured,
-        //start it
-        SendMioRequest(iCurrentCommand.front(), EStart);
-    }
-}
 
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PVMediaOutputNode::DoStop(PVMediaOutputNodeCmd& aCmd)
@@ -1207,6 +1222,7 @@
             && iInterfaceState != EPVMFNodePaused)
         return PVMFErrInvalidState;
 
+    LogDiagnostics();
 
     if (iMediaIOState == STATE_STARTED || iMediaIOState == STATE_PAUSED)
     {
@@ -1262,13 +1278,10 @@
     //3) Then we wait for all discard data to complete and all ports to
     //report BOS. Ports call "ReportBOS" when they recv BOS.
 
-    PVMFTimestamp startingTimestamp, resumeTimestamp;
-    bool renderSkippedData ;
+    PVMFTimestamp resumeTimestamp;
     bool playbackpositioncontinuous;
     uint32 streamID;
-    aCmd.Parse(startingTimestamp,
-               resumeTimestamp,
-               renderSkippedData,
+    aCmd.Parse(resumeTimestamp,
                playbackpositioncontinuous,
                streamID);
     iRecentBOSStreamID = streamID;
@@ -1526,22 +1539,29 @@
 {
     OSCL_UNUSED_ARG(aCmd);
 
-    //delete all ports and notify observer.
-    while (!iInPortVector.empty())
-        iInPortVector.Erase(&iInPortVector.front());
+    LogDiagnostics();
 
-    //restore original port vector reserve.
+    // delete all ports and notify observer.
+    while (!iInPortVector.empty())
+    {
+        iInPortVector.front()->Disconnect();
+        iInPortVector.Erase(&iInPortVector.front());
+    }
+
+    // restore original port vector reserve.
     iInPortVector.Reconstruct();
 
-    //logoff & go back to Created state.
-    SetState(EPVMFNodeIdle);
-    PVMFStatus status = ThreadLogoff();
-    //currently thread logoff can't fail.
-    //if any error returns are added, then a node error event should
-    //be added also.
-    Assert(status == PVMFSuccess);
-
-    return status;
+    if ((iInterfaceState == EPVMFNodeIdle) ||
+            (iInterfaceState == EPVMFNodeCreated))
+    {
+        // node is either in Created or Idle state, no need to call Reset on MIO. MIO has not been
+        // connected yet so no need to send a asynchronous command to MIO.
+        return PVMFSuccess;
+    }
+    else
+    {
+        return SendMioRequest(aCmd, EReset);
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -1550,9 +1570,9 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMediaOutputNode::CancelMioRequest In"));
 
-    Assert(iMediaIORequest != ENone);
+    OSCL_ASSERT(iMediaIORequest != ENone);
 
-    Assert(!iMediaIOCancelPending);
+    OSCL_ASSERT(!iMediaIOCancelPending);
 
     //Issue the cancel to the MIO.
     iMediaIOCancelPending = true;
@@ -1577,7 +1597,7 @@
 
 
     //there should not be a MIO command in progress..
-    Assert(iMediaIORequest == ENone);
+    OSCL_ASSERT(iMediaIORequest == ENone);
 
 
     //save media io request.
@@ -1591,15 +1611,16 @@
         case EQueryCapability:
         {
             int32 err ;
+            iMIOConfigPVI = NULL;
             OSCL_TRY(err,
                      iMediaIOCmdId = iMIOControl->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                     (PVInterface*&)iMIOConfig, NULL);
+                                     iMIOConfigPVI, NULL);
                     );
 
             if (err != OsclErrNone)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMediaOutputNode::DoInit: Error - iMIOControl->QueryInterface(cap & config) failed"));
+                                (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->QueryInterface(cap & config) failed"));
                 aCmd.iEventCode = PVMFMoutNodeErr_MediaIOQueryCapConfigInterface;
                 status = PVMFFailure;
             }
@@ -1613,15 +1634,16 @@
         case EQueryClockExtension:
         {
             int32 err ;
+            iMIOClockExtensionPVI = NULL;
             OSCL_TRY(err,
                      iMediaIOCmdId = iMIOControl->QueryInterface(PvmiClockExtensionInterfaceUuid,
-                                     (PVInterface*&)iMIOClockExtension, NULL);
+                                     iMIOClockExtensionPVI, NULL);
                     );
 
             if (err != OsclErrNone)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMediaOutputNode::DoInit: Error iMIOControl->QueryInterface(clock ext) failed"));
+                                (0, "PVMediaOutputNode::SendMioRequest: Error iMIOControl->QueryInterface(clock ext) failed"));
                 //this interface is optional so ignore the error
                 status = PVMFSuccess;
             }
@@ -1634,13 +1656,20 @@
 
         case EInit:
         {
-            int32 err ;
-            OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Init(););
-
-            if (err != OsclErrNone)
+            int32 err = OsclErrNone;
+            PvmiMediaTransfer* mediaTransfer = NULL;
+            if (iInPortVector.size() > 0)
+            {
+                mediaTransfer = iInPortVector[0]->getMediaTransfer();
+            }
+            if (mediaTransfer != NULL)
+            {
+                OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Init(););
+            }
+            if ((err != OsclErrNone) || (mediaTransfer == NULL))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMediaOutputNode::DoInit: Error - iMIOControl->Init failed"));
+                                (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->Init failed"));
                 aCmd.iEventCode = PVMFMoutNodeErr_MediaIOInit;
                 status = PVMFFailure;
             }
@@ -1654,13 +1683,20 @@
         case EStart:
         {
 
-            int32 err ;
-            OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Start(););
-
-            if (err != OsclErrNone)
+            int32 err = OsclErrNone;
+            PvmiMediaTransfer* mediaTransfer = NULL;
+            if (iInPortVector.size() > 0)
+            {
+                mediaTransfer = iInPortVector[0]->getMediaTransfer();
+            }
+            if (mediaTransfer != NULL)
+            {
+                OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Start(););
+            }
+            if ((err != OsclErrNone) || (mediaTransfer == NULL))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMediaOutputNode::DoInit: Error - iMIOControl->Start failed"));
+                                (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->Start failed"));
                 aCmd.iEventCode = PVMFMoutNodeErr_MediaIOStart;
                 status = PVMFFailure;
             }
@@ -1673,14 +1709,20 @@
 
         case EPause:
         {
-
-            int32 err ;
-            OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Pause(););
-
-            if (err != OsclErrNone)
+            int32 err = OsclErrNone;
+            PvmiMediaTransfer* mediaTransfer = NULL;
+            if (iInPortVector.size() > 0)
+            {
+                mediaTransfer = iInPortVector[0]->getMediaTransfer();
+            }
+            if (mediaTransfer != NULL)
+            {
+                OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Pause(););
+            }
+            if ((err != OsclErrNone) || (mediaTransfer == NULL))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMediaOutputNode::DoInit: Error - iMIOControl->Pause failed"));
+                                (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->Pause failed"));
                 aCmd.iEventCode = PVMFMoutNodeErr_MediaIOPause;
                 status = PVMFFailure;
             }
@@ -1694,13 +1736,27 @@
         case EStop:
         {
 
-            int32 err ;
-            OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Stop(););
-
-            if (err != OsclErrNone)
+            int32 err = OsclErrNone;
+            PvmiMediaTransfer* mediaTransfer = NULL;
+            if (iInPortVector.size() > 0)
+            {
+                mediaTransfer = iInPortVector[0]->getMediaTransfer();
+            }
+            else
+            {
+                /*There can be cases where stop is called after ports have been released and in such cases
+                we succeed stop as no-op assuming a subsequent reset will be called which would
+                guarantee proper reset of mio comp. */
+                return PVMFSuccess;
+            }
+            if (mediaTransfer != NULL)
+            {
+                OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Stop(););
+            }
+            if ((err != OsclErrNone) || (mediaTransfer == NULL))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMediaOutputNode::DoInit: Error - iMIOControl->Stop failed"));
+                                (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->Stop failed"));
                 aCmd.iEventCode = PVMFMoutNodeErr_MediaIOStop;
                 status = PVMFFailure;
             }
@@ -1713,17 +1769,23 @@
 
         case EDiscard:
         {
-            int32 err;
-            PVMFTimestamp startingTimestamp, resumeTimestamp;
-            bool renderSkippedData;
-            bool playbackpositioncontinuous;
-            uint32 streamId;
-            aCmd.Parse(startingTimestamp, resumeTimestamp, renderSkippedData, playbackpositioncontinuous, streamId);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
-                            (0, "PVMediaOutputNode::SendMioRequest(EDiscard): skipTimestamp=%d", resumeTimestamp));
-            OSCL_TRY(err, iMediaIOCmdId = iMIOControl->DiscardData(resumeTimestamp););
-
-            if (err != OsclErrNone)
+            int32 err = OsclErrNone;
+            PvmiMediaTransfer* mediaTransfer = NULL;
+            if (iInPortVector.size() > 0)
+            {
+                mediaTransfer = iInPortVector[0]->getMediaTransfer();
+            }
+            if (mediaTransfer != NULL)
+            {
+                PVMFTimestamp resumeTimestamp;
+                bool playbackpositioncontinuous;
+                uint32 streamId;
+                aCmd.Parse(resumeTimestamp, playbackpositioncontinuous, streamId);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iReposLogger, PVLOGMSG_INFO,
+                                (0, "PVMediaOutputNode::SendMioRequest(EDiscard): skipTimestamp=%d", resumeTimestamp));
+                OSCL_TRY(err, iMediaIOCmdId = iMIOControl->DiscardData(resumeTimestamp););
+            }
+            if ((err != OsclErrNone) || (mediaTransfer == NULL))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->DiscardData failed"));
@@ -1737,8 +1799,26 @@
         }
         break;
 
+        case EReset:
+        {
+            int32 err ;
+            OSCL_TRY(err, iMediaIOCmdId = iMIOControl->Reset(););
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMediaOutputNode::SendMioRequest: Error - iMIOControl->Reset failed"));
+                aCmd.iEventCode = PVMFMoutNodeErr_MediaIOReset;
+                status = PVMFFailure;
+            }
+            else
+            {
+                status = PVMFPending;
+            }
+        }
+        break;
+
         default:
-            Assert(false);//unrecognized command.
+            OSCL_ASSERT(false);//unrecognized command.
             status = PVMFFailure;
             break;
     }
@@ -1800,7 +1880,30 @@
 OSCL_EXPORT_REF PVMFStatus PVMediaOutputNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
 {
     OSCL_UNUSED_ARG(aSession);
-    return (iMIOConfig->verifyParametersSync(iMIOSession, aParameters, num_elements));
+    if (iMIOConfig)
+    {
+        return (iMIOConfig->verifyParametersSync(iMIOSession, aParameters, num_elements));
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMediaOutputNode::getParametersSync(PvmiMIOSession aSession,
+        PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters,
+        int& aNumParamElements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    return (iMIOConfig->getParametersSync(iMIOSession, aIdentifier, aParameters, aNumParamElements, aContext));
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMediaOutputNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    return (iMIOConfig->releaseParameters(iMIOSession, aParameters, num_elements));
 }
 
 void PVMediaOutputNode::ReportBOS()
@@ -1827,6 +1930,20 @@
     return PVMFPending;
 }
 
+void PVMediaOutputNode::LogDiagnostics()
+{
+    if (iDiagnosticsLogged == false)
+    {
+        iDiagnosticsLogged = true;
+
+        if (!iInPortVector.empty())
+        {
+            LOGDIAGNOSTICS((0, "PVMediaOutputNode:LogDiagnostics Mime %s, FramesDropped/TotalFrames %d/%d"
+                            , iSinkFormatString.get_str(), iInPortVector[0]->iFramesDropped, iInPortVector[0]->iTotalFrames));
+        }
+    }
+}
+
 
 
 
diff --git a/nodes/pvmediaoutputnode/src/pv_media_output_node.h b/nodes/pvmediaoutputnode/src/pv_media_output_node.h
index 9bd2c3c..24c1635 100644
--- a/nodes/pvmediaoutputnode/src/pv_media_output_node.h
+++ b/nodes/pvmediaoutputnode/src/pv_media_output_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -94,9 +94,7 @@
     public:
         //for SkipMediaData
         void Construct(PVMFSessionId s, int32 aCmd
-                       , PVMFTimestamp aStartingTimestamp
                        , PVMFTimestamp aResumeTimestamp
-                       , bool aRenderSkippedData
                        , uint32 aStreamID
                        , bool aPlayBackPositionContinuous
                        , const OsclAny* aContext)
@@ -104,24 +102,18 @@
             iSession = s;
             iCmd = aCmd;
             iContext = aContext;
-            iParam1 = (OsclAny*)aStartingTimestamp;
-            iParam2 = (OsclAny*)aResumeTimestamp;
-            iParam3 = (OsclAny*)aRenderSkippedData;
-            iParam4 = (OsclAny*)aPlayBackPositionContinuous;
-            iParam5 = (OsclAny*)aStreamID;
+            iParam1 = (OsclAny*)aResumeTimestamp;
+            iParam2 = (OsclAny*)aPlayBackPositionContinuous;
+            iParam3 = (OsclAny*)aStreamID;
             iEventCode = PVMFMoutNodeErr_First;
         }
-        void Parse(PVMFTimestamp& aStartingTimestamp
-                   , PVMFTimestamp& aResumeTimestamp
-                   , bool& aRenderSkippedData
+        void Parse(PVMFTimestamp& aResumeTimestamp
                    , bool& aPlayBackPositionContinuous
                    , uint32& aStreamID)
         {
-            aStartingTimestamp = (PVMFTimestamp)iParam1;
-            aResumeTimestamp = (PVMFTimestamp)iParam2;
-            aRenderSkippedData = (iParam3) ? true : false;
-            aPlayBackPositionContinuous = (iParam4) ? true : false;
-            aStreamID = (uint32)iParam5;
+            aResumeTimestamp = (PVMFTimestamp)iParam1;
+            aPlayBackPositionContinuous = (iParam2) ? true : false;
+            aStreamID = (uint32)iParam3;
         }
         //this holds an event code associated with the command status
         PVMFStatus iEventCode;
@@ -218,21 +210,22 @@
         OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
 
         // Pure virtuals from PvmfNodesSyncControlInterface
-        OSCL_IMPORT_REF PVMFStatus SetClock(OsclClock* aClock);
+        OSCL_IMPORT_REF PVMFStatus SetClock(PVMFMediaClock* aClock);
         OSCL_IMPORT_REF PVMFStatus ChangeClockRate(int32 aRate);
         OSCL_IMPORT_REF PVMFStatus SetMargins(int32 aEarlyMargin, int32 aLateMargin);
         OSCL_IMPORT_REF void ClockStarted(void);
         OSCL_IMPORT_REF void ClockStopped(void);
         OSCL_IMPORT_REF PVMFCommandId SkipMediaData(PVMFSessionId aSession,
-                PVMFTimestamp aStartingTimestamp,
                 PVMFTimestamp aResumeTimestamp,
                 uint32 aStreamID = 0,
-                bool aRenderSkippedData = false,
                 bool aPlayBackPositionContinuous = false,
                 OsclAny* aContext = NULL);
 
         // PvmiMIOObserver implementation
         OSCL_IMPORT_REF void RequestCompleted(const PVMFCmdResp& aResponse);
+        OSCL_IMPORT_REF void ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL);
+        OSCL_IMPORT_REF void ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL);
+
 
         bool IsMioRequestPending()
         {
@@ -242,28 +235,14 @@
         // From PvmiCapabilityAndConfig
         // Implement pure virtuals from PvmiCapabilityAndConfig interface
         OSCL_IMPORT_REF virtual PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
+        OSCL_IMPORT_REF virtual PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF virtual PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
 
         // Unsupported PvmiCapabilityAndConfig methods
         void virtual setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
         {
             OSCL_UNUSED_ARG(aObserver);
         };
-        PVMFStatus virtual getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-        {
-            OSCL_UNUSED_ARG(aSession);
-            OSCL_UNUSED_ARG(aIdentifier);
-            OSCL_UNUSED_ARG(aParameters);
-            OSCL_UNUSED_ARG(aNumParamElements);
-            OSCL_UNUSED_ARG(aContext);
-            return PVMFSuccess;
-        }
-        PVMFStatus virtual releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-        {
-            OSCL_UNUSED_ARG(aSession);
-            OSCL_UNUSED_ARG(aParameters);
-            OSCL_UNUSED_ARG(aNumElements);
-            return PVMFSuccess;
-        }
         void virtual createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
         {
             OSCL_UNUSED_ARG(aSession);
@@ -368,6 +347,7 @@
         PvmiMIOControl* iMIOControl;
         PvmiMIOSession iMIOSession;
         PvmiCapabilityAndConfig* iMIOConfig;
+        PVInterface* iMIOConfigPVI;
         enum EMioRequest
         {
             ENone
@@ -378,6 +358,7 @@
             , EPause
             , EStop
             , EDiscard
+            , EReset
         } ;
         EMioRequest iMediaIORequest;
         enum MioStates
@@ -394,18 +375,23 @@
         bool iMediaIOCancelPending;
         PVMFStatus SendMioRequest(PVMediaOutputNodeCmd& aCmd, EMioRequest);
         PVMFStatus CancelMioRequest(PVMediaOutputNodeCmd& aCmd);
-        void MioConfigured();
 
         // Ports
         PVMFPortVector<PVMediaOutputNodePort, OsclMemAllocator> iInPortVector;
         bool PortQueuesEmpty();
 
         // Variables for media data queue and synchronization
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
         int32 iEarlyMargin;
         int32 iLateMargin;
         int32 iClockRate;
         PvmiClockExtensionInterface* iMIOClockExtension;
+        PVInterface* iMIOClockExtensionPVI;
+
+        /* Diagnostic log related */
+        PVLogger* iDiagnosticsLogger;
+        bool iDiagnosticsLogged;
+        void LogDiagnostics();
 
         // Extension reference counter
         uint32 iExtensionRefCount;
@@ -417,19 +403,12 @@
         PVLogger* iLogger;
         PVLogger* iReposLogger;
 
-        void Assert(bool condition);
-
         OSCL_HeapString<OsclMemAllocator> iSinkFormatString;
 
         uint32 iRecentBOSStreamID;
         PVMFStatus CheckForBOS();
 };
 
-enum PVMoutPanic
-{
-    PVMoutPanic_OutstandingMIO_Command = 1
-    , PVMoutPanic_OutstandingMIO_WriteCommand
-};
 
 #endif // PVMI_IO_INTERFACE_NODE_H_INCLUDED
 
diff --git a/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.cpp b/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.cpp
index cb8ad72..2e2f238 100644
--- a/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.cpp
+++ b/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,68 +43,14 @@
 #define PVMF_MOPORT_LOGERROR(x)	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, x);
 
 
-////////////////////////////////////////////////////////////////////////////
-PVMediaOutputNodePortTimer::PVMediaOutputNodePortTimer(PVMediaOutputNodePortTimerObserver* aObserver)
-        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVMediaOutputNodePortTimer"),
-        iDurationInMS(0),
-        iObserver(aObserver),
-        iStarted(false)
-{
-    AddToScheduler();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMediaOutputNodePortTimer::~PVMediaOutputNodePortTimer()
-{
-    Stop();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMediaOutputNodePortTimer::Start()
-{
-    RunIfNotReady(iDurationInMS*1000);
-    iStarted = true;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMediaOutputNodePortTimer::setTimerDurationInMS(uint32 duration)
-{
-    iDurationInMS = duration;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMediaOutputNodePortTimer::Stop()
-{
-    Cancel();
-    iStarted = false;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMediaOutputNodePortTimer::Run()
-{
-    if (!iStarted)
-        return;
-
-    if (!iObserver)
-    {
-        return;
-    }
-
-    iObserver->PVMediaOutputNodePortTimerEvent();
-    /*
-     * Do not reschudule the AO here. Observer would reschedule this AO
-     * once it is done processing the timer event.
-     */
-}
-
 //for logging media data info
 void PVMediaOutputNodePort::LogMediaDataInfo(const char* msg, PVMFSharedMediaDataPtr mediaData)
 {
     if (!mediaData.GetRep())
+    {
+        OSCL_UNUSED_ARG(msg);
         return;
+    }
     LOGDATAPATH(
         (0, "MOUT %s %s MediaData SeqNum %d, SId %d, TS %d"
          , PortName()
@@ -120,7 +66,12 @@
 void PVMediaOutputNodePort::LogMediaDataInfo(const char* msg, PVMFSharedMediaDataPtr mediaData, int32 cmdid, int32 qdepth)
 {
     if (!mediaData.GetRep())
+    {
+        OSCL_UNUSED_ARG(msg);
+        OSCL_UNUSED_ARG(cmdid);
+        OSCL_UNUSED_ARG(qdepth);
         return;
+    }
     LOGDATAPATH(
         (0, "MOUT %s %s, Write Id %d, MediaData SeqNum %d, SId %d, TS %d, Cleanup Q-depth %d"
          , PortName()
@@ -137,6 +88,12 @@
 //for logging media xfer info
 void PVMediaOutputNodePort::LogDatapath(const char*msg)
 {
+
+    if (!iDatapathLogger)
+    {
+        OSCL_UNUSED_ARG(msg);
+        return; //unexpected call.
+    }
     LOGDATAPATH(
         (0, "MOUT %s %s"
          , PortName()
@@ -157,34 +114,41 @@
         , iNode(aNode)
 {
     AddToScheduler();
-
-    iWaitForConfig = true;
     isUnCompressedMIO = false;
 
     iExtensionRefCount = 0;
-    iPortFormat = PVMF_FORMAT_UNKNOWN;
+    iPortFormat = PVMF_MIME_FORMAT_UNKNOWN;
 
     iMediaTransfer = NULL;
     iMioInfoErrorCmdId = 0;
-    iMediaTypeIndex = PVMF_FORMAT_UNKNOWN;
+    iMediaType = PVMF_MEDIA_UNKNOWN;
     iWriteState = EWriteOK;
     iCleanupQueue.reserve(1);
     iWriteAsyncContext = 0;
     iWriteAsyncEOSContext = 0;
     iWriteAsyncReConfigContext = 0;
     iClock = NULL;
+    iClockNotificationsInf = NULL;
+    oClockCallBackPending = false;
+    iDelayEarlyFrameCallBkId = 0;
     iClockRate = 1;
     iEarlyMargin = 0;
     iLateMargin = 0;
-    iDelayTimer = NULL;
-    // By default we treat the MIO's to be active. For active MIO's MIO node will not
-    // wait for clock to start before it sends out the data to MIO comp. For passive MIO's
-    // oActiveMediaOutputComp and oProcessIncomingMessage will be set to false in EnableMediaSync.
-    // MIO node will wait for clock to start before sending data to passive MIO's.
-    oActiveMediaOutputComp = true;
-    oProcessIncomingMessage = true;
+    oActiveMediaOutputComp = true; // By default we treat the MIO's to be active.
+
+    // MIO node waits for MIO component configuration to complete before sending data. Once configuration is
+    // complete, MIO node waits for clock to start if mio component is passive. For active MIO's, it does not
+    // wait for clock to start before sending data. It sends data as soon as MIO component configuration is
+    // complete.
+
+    oProcessIncomingMessage = false;
+
+
+    oMIOComponentConfigured = false;
+
     iConsecutiveFramesDropped = 0;
     iLateFrameEventSent = false;
+
     iFragIndex = 0;
 
     iSkipTimestamp = 0;
@@ -194,7 +158,10 @@
     iFrameStepMode = false;
     iClockFrameCount = 0;
     iSyncFrameCount = 0;
-    iEOSStreamId  = 0;
+    iFramesDropped = 0;
+    iTotalFrames = 0;
+
+    iEosStreamIDVec.reserve(2);
 
     iOsclErrorTrapImp = OsclErrorTrap::GetErrorTrapImp();
     iLogger = PVLogger::GetLoggerObject("PVMediaOutputNodePort");
@@ -233,17 +200,15 @@
         OSCL_TRY(err, iMediaTransfer->cancelAllCommands(););
         ClearCleanupQueue();
     }
-    if (iDelayTimer != NULL)
-    {
-        iDelayTimer->Stop();
-        OSCL_DELETE(iDelayTimer);
-        iDelayTimer = NULL;
-    }
     if (iClock != NULL)
     {
-        iClock->RemoveClockObserver(*this);
-        iClock->RemoveClockStateObserver(*this);
-        iClock = NULL;
+        if (iClockNotificationsInf != NULL)
+        {
+            iClockNotificationsInf->RemoveClockObserver(*this);
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+            iClockNotificationsInf = NULL;
+        }
     }
 }
 
@@ -256,30 +221,7 @@
         // Must disconnect before changing port properties, so return error
         return PVMFFailure;
     }
-    PVMFFormatType fmt = GetFormatIndex(fmtstr.get_str());
-    //set port name for datapath logging.
-    int32 mediaindex = GetMediaTypeIndex(fmt);
-
-    if (mediaindex == PVMF_COMPRESSED_AUDIO_FORMAT ||
-            mediaindex == PVMF_UNCOMPRESSED_AUDIO_FORMAT)
-    {
-        SetName("MediaOutIn(Audio)");
-    }
-    else if (mediaindex == PVMF_COMPRESSED_VIDEO_FORMAT ||
-             mediaindex == PVMF_UNCOMPRESSED_VIDEO_FORMAT)
-    {
-        SetName("MediaOutIn(Video)");
-    }
-    else
-    {
-        SetName("MediaOutIn");
-    }
-
-    if ((mediaindex == PVMF_UNCOMPRESSED_AUDIO_FORMAT) ||
-            (mediaindex == PVMF_UNCOMPRESSED_VIDEO_FORMAT))
-    {
-        isUnCompressedMIO = true;
-    }
+    PVMFFormatType fmt = fmtstr.get_cstr();
 
     if (IsFormatSupported(fmt))
     {
@@ -291,8 +233,8 @@
     }
     else
     {
-        iPortFormat = PVMF_FORMAT_UNKNOWN;
-        iSinkFormat = PVMF_FORMAT_UNKNOWN;
+        iPortFormat = PVMF_MIME_FORMAT_UNKNOWN;
+        iSinkFormat = PVMF_MIME_FORMAT_UNKNOWN;
         iSinkFormatString = fmtstr;
         return PVMFFailure;
     }
@@ -323,9 +265,10 @@
 
     iSkipTimestamp = 0;
 
-    PvmiCapabilityAndConfig *config;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                          (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
     if (config != NULL)
     {
         PvmiKvp* configKvp = NULL;
@@ -394,8 +337,13 @@
     }
     if (iClock != NULL)
     {
-        iClock->RemoveClockObserver(*this);
-        iClock->RemoveClockStateObserver(*this);
+        if (iClockNotificationsInf != NULL)
+        {
+            iClockNotificationsInf->RemoveClockObserver(*this);
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+        }
+        iClockNotificationsInf = NULL;
         iClock = NULL;
     }
     if (iCurrentMediaMsg.GetRep() != NULL)
@@ -430,7 +378,9 @@
 OSCL_EXPORT_REF PVMFStatus PVMediaOutputNodePort::ClearMsgQueues()
 {
     if (iCurrentMediaMsg.GetRep() != NULL)
+    {
         iCurrentMediaMsg.Unbind();
+    }
 
     PvmfPortBaseImpl::ClearMsgQueues();
     //cancel any pending write operations
@@ -485,20 +435,98 @@
 ////////////////////////////////////////////////////////////////////////////
 void PVMediaOutputNodePort::NodeStarted()
 {
+    //it is possible that we attempted to call writeasync
+    //before media output comp start (can happen for active components)
+    //in those cases the comp can either accept or reject data
+    //if it rejected it by doing a leave, attempt to send data again
+    //now that we are done with start. Do not do the same for passive
+    //comps since this method is called during a pause-resume, and we
+    //do not want to attempt sending media data to passive comps till
+    //clock has been started
+    if ((iWriteState == EWriteWait) &&
+            (true == oActiveMediaOutputComp))
+    {
+        iWriteState = EWriteOK;
+        PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::NodeStarted - WriteAsync Enabled - Fmt=%s, iWriteState=%d",
+                                 iSinkFormatString.get_str(),
+                                 iWriteState));
+        oProcessIncomingMessage = true;
+
+        if (iCurrentMediaMsg.GetRep() != NULL)
+        {
+            //attempt to send data current media msg if any
+            SendData();
+        }
+    }
+
     RunIfNotReady();
 }
 
+// Attempt to process incoming message only after the mio component is fully configured
+// and the clock is set by the node.
+void PVMediaOutputNodePort::ProcessIncomingMessageIfPossible()
+{
+    if (oMIOComponentConfigured && iClock)
+    {
+        PVMF_MOPORT_LOGDATAPATH(
+            (0, "PVMediaOutputNodePort::ProcessIncomingMessageIfPossible: Fmt - Fmt=%s, MIOCompConfigured=%d, ActiveMIO=%d, ClockState=%d",
+             iSinkFormatString.get_str(), oMIOComponentConfigured, oActiveMediaOutputComp, iClock->GetState()));
+
+        PVMF_MOPORT_LOGDEBUG(
+            (0, "PVMediaOutputNodePort::ProcessIncomingMessageIfPossible: Fmt - Fmt=%s, MIOCompConfigured=%d, ActiveMIO=%d, ClockState=%d",
+             iSinkFormatString.get_str(), oMIOComponentConfigured, oActiveMediaOutputComp, iClock->GetState()));
+
+        if (true == oActiveMediaOutputComp)
+        {
+            oProcessIncomingMessage = true;
+        }
+        else
+        {
+            if (iClock->GetState() == PVMFMediaClock::RUNNING)
+            {
+                oProcessIncomingMessage = true;
+            }
+        }
+        RunIfNotReady();
+    }
+    else
+    {
+        PVMF_MOPORT_LOGDEBUG(
+            (0, "PVMediaOutputNodePort::ProcessIncomingMessageIfPossible: Fmt - Fmt=%s, MIOCompConfigured=%d, iClock=0x%x",
+             iSinkFormatString.get_str(), oMIOComponentConfigured, iClock));
+    }
+}
+
+void PVMediaOutputNodePort::SetMIOComponentConfigStatus(bool aStatus)
+{
+    oMIOComponentConfigured = aStatus;
+
+    ProcessIncomingMessageIfPossible();
+}
+
+
 ////////////////////////////////////////////////////////////////////////////
 //for sync control interface
-PVMFStatus PVMediaOutputNodePort::SetClock(OsclClock* aClock)
+PVMFStatus PVMediaOutputNodePort::SetClock(PVMFMediaClock* aClock)
 {
-    if (aClock == NULL)
+    if (NULL == aClock)
     {
         return PVMFErrArgument;
     }
     iClock = aClock;
-    iClock->SetClockObserver(*this);
-    iClock->SetClockStateObserver(*this);
+
+    ProcessIncomingMessageIfPossible();
+
+    iClock->ConstructMediaClockNotificationsInterface(iClockNotificationsInf, *this);
+
+    if (NULL == iClockNotificationsInf)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    iClockNotificationsInf->SetClockObserver(*this);
+    iClockNotificationsInf->SetClockStateObserver(*this);
+
     return PVMFSuccess;
 }
 
@@ -507,22 +535,21 @@
     //wait on play clock
     oProcessIncomingMessage = false;
     oActiveMediaOutputComp = false;
-    if (iDelayTimer != NULL)
-    {
-        OSCL_DELETE(iDelayTimer);
-        iDelayTimer = NULL;
-    }
-    iDelayTimer = OSCL_NEW(PVMediaOutputNodePortTimer, (this));
 }
 
 ////////////////////////////////////////////////////////////////////////////
 //for sync control interface
 PVMFStatus PVMediaOutputNodePort::ChangeClockRate(int32 aRate)
 {
+    if (0 == aRate)
+    {
+        // A 0 value of clockrate is not handled
+        return PVMFFailure;
+    }
     iClockRate = aRate;
 
     PVMFStatus status;
-    status = SetMIOParameterInt32(MOUT_MEDIAXFER_OUTPUT_RATE, aRate);
+    status = SetMIOParameterInt32((char*)MOUT_MEDIAXFER_OUTPUT_RATE, aRate);
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,
                     "PVMediaOutputNodePort::ChangeClockRate rate %d",
@@ -678,13 +705,6 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
                     (0, "PVMediaOutputNodePort::writeComplete status %d cmdId %d context 0x%x", status, aCmdId, aContext));
 
-    //we don't expect any error status to be returned here
-    //except possibly cancelled
-    if (status != PVMFSuccess && status != PVMFErrCancelled)
-    {
-        iNode->ReportErrorEvent(PVMFErrPortProcessing, NULL, PVMFMoutNodeErr_WriteComplete);
-    }
-
     // Check if the writeComplete is in response to EOS message
     if (&iWriteAsyncEOSContext == (uint32*)aContext)
     {
@@ -696,21 +716,40 @@
         }
         else
         {
-            // Asynchronous completion
-            if (status == PVMFSuccess && iNode->IsMioRequestPending() == false)
+            // Report End of Data to the user of media output node
+            // only if the EOS media transfer completes successfully and
+            // there is no pending MIO control request
+            PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::writeComplete For EOS - Fmt=%s",
+                                     iSinkFormatString.get_str()));
+            if (iEosStreamIDVec.size() != 0)
             {
-                // Report End of Data to the user of media output node
-                // only if the EOS media transfer completes successfully and
-                // there is no pending MIO control request
-                PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::writeComplete For EOS - Fmt=%s",
-                                         iSinkFormatString.get_str()));
-                uint32 iStreamID = iEOSStreamId;
-                iNode->ReportInfoEvent(PVMFInfoEndOfData, (OsclAny*)&iStreamID);
+                //iEosStreamIDVec is used as a FIFO to store the steamids of eos sent to mio comp.
+                //streamid is pushed in at front when call writeasync(eos) to mio comp.
+                //streamid is poped out from end when mio comp. calls writecomplete(eos),
+                //we report PVMFInfoEndOfData with the poped streamid.
+                //This logic depends on Mio comp. process data(at least eos msg) in a sequencial style.
+                uint32 EosStreamID = iEosStreamIDVec.back();
+
+                // Asynchronous completion
+                if (status == PVMFSuccess)
+                {
+                    // Report EndofData to engine only if MIO comp sends success for End Of Stream.
+                    // FOr other return codes just pop out the EOS from the vector.
+                    iNode->ReportInfoEvent(PVMFInfoEndOfData, (OsclAny*)&EosStreamID);
+                }
+                else
+                {
+                    PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::writeComplete EOS media transfer completed but PVMFInfoEndOfData not sent"));
+                }
+
+                iEosStreamIDVec.pop_back();
             }
             else
             {
-                PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::writeComplete EOS media transfer completed but PVMFInfoEndOfData not sent"));
+                PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::writeComplete - Invalid iEosStreamIDVec size=0"));
+                OSCL_ASSERT(false);
             }
+
         }
     }
     // Check if the writeComplete is in response to Reconfig message
@@ -729,7 +768,7 @@
         }
     }
     //detect cases where the current SendData call is completing synchronously.
-    else if (iWriteState == EWriteBusy && (uint32)aContext == iWriteAsyncContext)
+    else if (iWriteState == EWriteBusy)
     {
         //synchronous completion
         iWriteState = EWriteOK;
@@ -806,23 +845,29 @@
     if (status_flags & PVMI_MEDIAXFER_STATUS_WRITE)
     {
         //recover from a previous async write error.
-        if (iWriteState == EWriteWait && (iClock->GetState() != OsclClock::STOPPED))
+        if (iWriteState == EWriteWait)
         {
-            iWriteState = EWriteOK;
             PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::statusUpdate - WriteAsync Enabled - Fmt=%s, iWriteState=%d",
                                      iSinkFormatString.get_str(),
                                      iWriteState));
-            oProcessIncomingMessage = true;
-            if (iCurrentMediaMsg.GetRep() != NULL)
+            iWriteState = EWriteOK;
+
+            // Allow data to be processed if possible
+            ProcessIncomingMessageIfPossible();
+
+            if (oProcessIncomingMessage == true)
             {
-                //attempt to send data current media msg if any
-                SendData();
-            }
-            //reschedule if there is more stuff waiting and
-            //if we can process more data
-            if (IncomingMsgQueueSize() > 0)
-            {
-                RunIfNotReady();
+                if (iCurrentMediaMsg.GetRep() != NULL)
+                {
+                    //attempt to send data current media msg if any
+                    SendData();
+                }
+                //reschedule if there is more stuff waiting and
+                //if we can process more data
+                if (IncomingMsgQueueSize() > 0)
+                {
+                    RunIfNotReady();
+                }
             }
         }
     }
@@ -859,42 +904,21 @@
 bool PVMediaOutputNodePort::IsFormatSupported(PVMFFormatType aFmt)
 // for PvmiCapabilityAndConfigPortFormatImpl interface
 {
-    //Try to get supported formats from the media I/O component.
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    PVMFStatus status = iNode->iMIOConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status == PVMFSuccess)
+    //Verify if the format is supported by the media I/O component.
+    PvmiKvp kvpFormatType;
+
+    OSCL_StackString<64> iKVPFormatType = _STRLIT_CHAR(PVMF_FORMAT_TYPE_VALUE_KEY);
+
+    kvpFormatType.key = NULL;
+    kvpFormatType.key = iKVPFormatType.get_str();
+    kvpFormatType.value.pChar_value = (char*)aFmt.getMIMEStrPtr();
+
+    PVMFStatus status = iNode->iMIOConfig->verifyParametersSync(NULL, &kvpFormatType, 1);
+    if (status != PVMFSuccess)
     {
-        bool found = false;
-        for (int32 i = 0;i < numParams;i++)
-        {
-            if (aFmt == kvp[i].value.uint32_value)
-            {
-                found = true;
-                break;
-            }
-        }
-        iNode->iMIOConfig->releaseParameters(0, kvp, numParams);
-        return found;
+        return false;
     }
-    else
-    {
-        //if media I/O did not report its formats, then assume all formats
-        //are OK.  do this since some MIO may not have the query support.
-        //at least verify it's an audio or video format...
-        int32 mt = GetMediaTypeIndex(aFmt);
-        switch (mt)
-        {
-            case PVMF_COMPRESSED_AUDIO_FORMAT:
-            case PVMF_COMPRESSED_VIDEO_FORMAT:
-            case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-            case PVMF_UNCOMPRESSED_VIDEO_FORMAT:
-            case PVMF_TEXT_FORMAT:
-                return true;
-            default:
-                return false;
-        }
-    }
+    return true;
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -903,43 +927,57 @@
 {
     //called when format was just set, either through capability and config,
     //for by node during port request.
-    //save the media type index.
-    iMediaTypeIndex = GetMediaTypeIndex(iSinkFormat);
-
-    switch (iMediaTypeIndex)
+    if (iSinkFormat.isAudio())
     {
-        case PVMF_COMPRESSED_AUDIO_FORMAT:
-            //pass the selected format to the MIO component.
-            //ignore any failure since not all MIO may support the feature.
-            SetMIOParameterPchar(MOUT_AUDIO_FORMAT_KEY, iSinkFormatString.get_str());
-            break;
+        //set port name for datapath logging.
+        SetName("MediaOutIn(Audio)");
 
-        case PVMF_COMPRESSED_VIDEO_FORMAT:
-            //pass the selected format to the MIO component.
-            //ignore any failure since not all MIO may support the feature.
-            SetMIOParameterPchar(MOUT_VIDEO_FORMAT_KEY, iSinkFormatString.get_str());
-            break;
+        //pass the selected format to the MIO component.
+        //ignore any failure since not all MIO may support the feature.
+        SetMIOParameterPchar((char*)MOUT_AUDIO_FORMAT_KEY, iSinkFormatString.get_str());
 
-        case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-            //pass the selected format to the MIO component.
-            //ignore any failure since not all MIO may support the feature.
-            SetMIOParameterPchar(MOUT_AUDIO_FORMAT_KEY, iSinkFormatString.get_str());
-            break;
+        //save the media type.
+        if (iSinkFormat.isCompressed())
+        {
+            iMediaType = PVMF_MEDIA_COMPRESSED_AUDIO;
+        }
+        else
+        {
+            iMediaType = PVMF_MEDIA_UNCOMPRESSED_AUDIO;
+            isUnCompressedMIO = true;
+        }
+    }
+    else if (iSinkFormat.isVideo())
+    {
+        //set port name for datapath logging.
+        SetName("MediaOutIn(Video)");
 
-        case PVMF_UNCOMPRESSED_VIDEO_FORMAT:
-            //pass the selected format to the MIO component.
-            //ignore any failure since not all MIO may support the feature.
-            SetMIOParameterPchar(MOUT_VIDEO_FORMAT_KEY, iSinkFormatString.get_str());
-            break;
+        //pass the selected format to the MIO component.
+        //ignore any failure since not all MIO may support the feature.
+        SetMIOParameterPchar((char*)MOUT_VIDEO_FORMAT_KEY, iSinkFormatString.get_str());
 
-        case PVMF_TEXT_FORMAT:
-            //pass the selected format to the MIO component.
-            //ignore any failure since not all MIO may support the feature.
-            SetMIOParameterPchar(MOUT_TEXT_FORMAT_KEY, iSinkFormatString.get_str());
-            break;
+        //save the media type.
+        if (iSinkFormat.isCompressed())
+        {
+            iMediaType = PVMF_MEDIA_COMPRESSED_VIDEO;
+        }
+        else
+        {
+            iMediaType = PVMF_MEDIA_UNCOMPRESSED_VIDEO;
+            isUnCompressedMIO = true;
+        }
+    }
+    else if (iSinkFormat.isText())
+    {
+        //set port name for datapath logging.
+        SetName("MediaOutIn");
 
-        default:
-            break;
+        //pass the selected format to the MIO component.
+        //ignore any failure since not all MIO may support the feature.
+        SetMIOParameterPchar((char*)MOUT_TEXT_FORMAT_KEY, iSinkFormatString.get_str());
+
+        //save the media type.
+        iMediaType = PVMF_MEDIA_TEXT;
     }
 }
 
@@ -947,9 +985,75 @@
 void PVMediaOutputNodePort::SendData()
 //send data to the MIO componenent.
 {
+    const int32 toleranceWndForCallback = 0;
     if (iCurrentMediaMsg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
     {
-        SendEndOfData();
+        if (oActiveMediaOutputComp)
+        {
+            SendEndOfData();
+        }
+        else if (iFrameStepMode == false)
+        {
+            uint32 delta = 0;
+            PVMFMediaOutputNodePortMediaTimeStatus status = CheckMediaTimeStamp(delta);
+            if (status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_ON_TIME || status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_LATE)
+            {
+                SendEndOfData();
+            }
+            else if (status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_EARLY)
+            {
+
+                OSCL_ASSERT(false == oClockCallBackPending);
+                //stop processing input, since we are not done with the current media msg
+                oProcessIncomingMessage = false;
+                oClockCallBackPending = false;
+
+                if (NULL != iClockNotificationsInf)
+                {
+                    PVMFStatus status =
+                        iClockNotificationsInf->SetCallbackDeltaTime(delta, //delta time in clock when callBack should be called
+                                toleranceWndForCallback,
+                                this, //observer object to be called on timeout
+                                false, //no threadLock
+                                NULL, //no context
+                                iDelayEarlyFrameCallBkId); //ID used to identify the timer for cancellation
+                    if (PVMFSuccess != status)
+                    {
+                        //If delta specified for the callback is too large, then callback to the Mediaclock notification interface does not succeed
+                        //Possible reasons for huge difference between the playback clock and the timestamp could be
+                        //Sample is intended to be played after a very long time from now (as indicated by the data source(streaming server/file)).
+                        //Timestamp is corrupted in the source node.
+                        PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendData - Could not set callback notification for send data %d delta %u", status, delta));
+                        iNode->ReportErrorEvent(PVMFErrCorrupt, NULL, PVMFMoutNodeErr_Unexpected);
+                        return;
+                    }
+                    else
+                    {
+                        oClockCallBackPending = true;
+                    }
+                }
+                else
+                {
+                    PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendData - Fmt=%s, No callback notification Intf ",
+                                          iSinkFormatString.get_str()));
+                    OSCL_ASSERT(false);
+                }
+            }
+        }
+        else if (iFrameStepMode == true)
+        {
+            PVMFMediaOutputNodePortMediaTimeStatus status = CheckMediaFrameStep();
+            if (status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_ON_TIME || status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_LATE)
+            {
+                SendEndOfData();
+            }
+            else if (status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_EARLY)
+            {
+                //stop processing input, since we are not done with the current media msg
+                oProcessIncomingMessage = false;
+                //wait on ClockCountUpdated call back from oscl clock
+            }
+        }
     }
     else if (iCurrentMediaMsg->getFormatID() == PVMF_MEDIA_CMD_RE_CONFIG_FORMAT_ID)
     {
@@ -976,16 +1080,35 @@
             }
             else if (status == PVMF_MEDIAOUTPUTNODEPORT_MEDIA_EARLY)
             {
+
+                OSCL_ASSERT(false == oClockCallBackPending);
                 //stop processing input, since we are not done with the current media msg
                 oProcessIncomingMessage = false;
-                if (iDelayTimer != NULL)
+                oClockCallBackPending = false;
+
+                if (NULL != iClockNotificationsInf)
                 {
-                    iDelayTimer->setTimerDurationInMS(delta);
-                    iDelayTimer->Start();
+                    PVMFStatus status =
+                        iClockNotificationsInf->SetCallbackDeltaTime(delta, //delta time in clock when callBack should be called
+                                toleranceWndForCallback,
+                                this, //observer object to be called on timeout
+                                false, //no threadLock
+                                NULL, //no context
+                                iDelayEarlyFrameCallBkId); //ID used to identify the timer for cancellation
+                    if (PVMFSuccess != status)
+                    {
+                        PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendData - Could not set callback notification for early frame %d delta %u", status, delta));
+                        iNode->ReportErrorEvent(PVMFErrCorrupt, NULL, PVMFMoutNodeErr_Unexpected);
+                        return;
+                    }
+                    else
+                    {
+                        oClockCallBackPending = true;
+                    }
                 }
                 else
                 {
-                    PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendData - Fmt=%s, No Delay Timer",
+                    PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendData - Fmt=%s, No callback notification Intf ",
                                           iSinkFormatString.get_str()));
                     OSCL_ASSERT(false);
                 }
@@ -1059,9 +1182,8 @@
         OsclRefCounterMemFrag frag;
         mediaData->getMediaFragment(fragindex, frag);
 
-        ++iWriteAsyncContext;
         iWriteState = EWriteBusy;
-        int32 err;
+        int32 err = OsclErrNone;
         int32 cmdId = 0;
 
         uint32 flags = PVMI_MEDIAXFER_MEDIA_DATA_FLAG_NONE;
@@ -1084,21 +1206,18 @@
         mediaxferhdr.stream_id = mediaData->getStreamID();
         mediaxferhdr.private_data_length = privatedatalength;
         mediaxferhdr.private_data_ptr = privatedataptr;
-        OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
-                        cmdId = iMediaTransfer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA,  /*format_type*/
-                                                           PVMI_MEDIAXFER_FMT_INDEX_DATA, /*format_index*/
-                                                           (uint8*)frag.getMemFragPtr(),
-                                                           frag.getMemFragSize(),
-                                                           mediaxferhdr,
-                                                           (OsclAny*)iWriteAsyncContext);
-                       );
+        err = WriteDataToMIO(cmdId, mediaxferhdr, frag);
 
         if (err != OsclErrNone)
         {
-            //if a leave occurs in the writeAsync call, we suspend data
-            //transfer until a statusUpdate call from the MIO component
-            //tells us to resume.
-            //this is not an error-- it's the normal flow control mechanism.
+            // A Busy or an InvalidState leave can occur in a writeAsync call. If a leave occurs in writeasync call,
+            // suspend data transfer.
+            // A Busy leave is not an error and is a normal flow control mechanism.
+            // Some MIO components can do a InvalidState leave if writeasyncs are called before calling Start on MIOs.
+            // Data transfer to MIOs will resume when
+            // 1) In case of Busy Leave: A statusUpdate call from the MIO component tells us to resume.
+            // 2) In case of InvalidState Leave: A statusUpdate call from the MIO component tells us to resume. OR
+            //                                   MIO sends the command complete for Start.
             iWriteState = EWriteWait;
 
             //stop processing input, since we are not done with the current media msg
@@ -1108,7 +1227,7 @@
                                      iSinkFormatString.get_str(),
                                      err));
 
-            return ;//wait on statusUpdate call from the MIO component.
+            return ;//wait on statusUpdate call or start complete from the MIO component.
         }
         else
         {
@@ -1178,7 +1297,14 @@
     mediaxferhdr.duration = 0;
     mediaxferhdr.flags = PVMI_MEDIAXFER_MEDIA_DATA_FLAG_NONE;
     mediaxferhdr.stream_id = iCurrentMediaMsg->getStreamID();
-    iEOSStreamId = mediaxferhdr.stream_id;
+    uint32 EosStreamId = mediaxferhdr.stream_id;
+
+    //iEosStreamIDVec is used as a FIFO to store the steamids of eos sent to mio comp.
+    //streamid is pushed in at front when call writeasync(eos) to mio comp.
+    //streamid is poped out from end when mio comp. calls writecomplete(eos),
+    //we report PVMFInfoEndOfData with the poped streamid.
+    //This logic depends on Mio comp. process data(at least eos msg) in a sequencial style.
+    iEosStreamIDVec.push_front(EosStreamId);
     OSCL_TRY(err,
              cmdId = iMediaTransfer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION,  /*format_type*/
                                                 PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM, /*format_index*/
@@ -1190,20 +1316,35 @@
 
     if (err != OsclErrNone)
     {
-        //if a leave occurs in the writeAsync call, we suspend data
-        //transfer until a statusUpdate call from the MIO component
-        //tells us to resume.
-        //this is not an error-- it's the normal flow control mechanism.
+        // A Busy or an InvalidState leave can occur in a writeAsync call. If a leave occurs in writeasync call,
+        // suspend data transfer.
+        // A Busy leave is not an error and is a normal flow control mechanism.
+        // Some MIO components can do a InvalidState leave if writeasyncs are called before calling Start on MIOs.
+        // Data transfer to MIOs will resume when
+        // 1) In case of Busy Leave: A statusUpdate call from the MIO component tells us to resume.
+        // 2) In case of InvalidState Leave: A statusUpdate call from the MIO component tells us to resume. OR
+        //                                   MIO sends the command complete for Start.
         iWriteState = EWriteWait;
 
         //stop processing input, since we are not done with the current media msg
         oProcessIncomingMessage = false;
 
+        // StreamID popped from vector when leave occurs in the writeAsync call
+        if (iEosStreamIDVec.size() != 0)
+        {
+            iEosStreamIDVec.erase(iEosStreamIDVec.begin());
+        }
+        else
+        {
+            PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendEndOfData - Invalid iEosStreamIDVec size=0"));
+            OSCL_ASSERT(false);
+        }
+
         PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::SendEndOfData - WriteAsyncLeave - Fmt=%s, LeaveCode=%d",
                                  iSinkFormatString.get_str(),
                                  err));
 
-        return ;//wait on statusUpdate call from the MIO component
+        return ;//wait on statusUpdate call or start complete from the MIO component.
     }
     else
     {
@@ -1231,8 +1372,22 @@
                                      iCleanupQueue.size()));
 
             // Report End of Data to the user of media output node
-            uint32 iStreamID = iEOSStreamId;
-            iNode->ReportInfoEvent(PVMFInfoEndOfData, (OsclAny*)&iStreamID);
+            if (iEosStreamIDVec.size() != 0)
+            {
+                //iEosStreamIDVec is used as a FIFO to store the steamids of eos sent to mio comp.
+                //streamid is pushed in at front when call writeasync(eos) to mio comp.
+                //streamid is poped out from end when mio comp. calls writecomplete(eos),
+                //we report PVMFInfoEndOfData with the poped streamid.
+                //This logic depends on Mio comp. process data(at least eos msg) in a sequencial style.
+                uint32 EosStreamID = iEosStreamIDVec.back();
+                iNode->ReportInfoEvent(PVMFInfoEndOfData, (OsclAny*)&EosStreamID);
+                iEosStreamIDVec.pop_back();
+            }
+            else
+            {
+                PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::SendEndOfData - Invalid iEosStreamIDVec size=0"));
+                OSCL_ASSERT(false);
+            }
         }
         //we are done with current media msg - either we are truly done (sync write complete) or we are
         //waiting on async write complete. there is no need to push this msg into cleanup queue since it
@@ -1323,9 +1478,11 @@
     //aTimeStamp is assumed to be in milliseconds
     if (iClock != NULL)
     {
-        uint64 clock_msec64;
-        iClock->GetCurrentTime64(clock_msec64, OSCLCLOCK_MSEC);
-        uint32 clock_msec32 = Oscl_Int64_Utils::get_uint64_lower32(clock_msec64);
+        uint32 clock_msec32;
+        bool overflowFlag = false;
+
+        iClock->GetCurrentTime32(clock_msec32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+
 
         uint32 clock_adjforearlymargin = clock_msec32 + iEarlyMargin;
         uint32 ts_adjforlatemargin = aTimeStamp + iLateMargin;
@@ -1381,6 +1538,7 @@
             // Say clock is 1000ms, late margin is 200ms, then any timestamp earlier than 800ms should be
             // dropped, as late. If ts is less than 800ms, then (ts + 200 - 1000) will be larger than wrap threshold
             aDelta = (clock_msec32 - aTimeStamp);
+            iFramesDropped++;
             PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::CheckMediaTimeStamp - Late - Fmt=%s, Seq=%d, Ts=%d, Clock=%d, Delta=%d",
                                      iSinkFormatString.get_str(),
                                      iCurrentMediaMsg->getSeqNum(),
@@ -1388,12 +1546,12 @@
                                      clock_msec32,
                                      aDelta));
             iConsecutiveFramesDropped++;
-            if (iMediaTypeIndex == PVMF_UNCOMPRESSED_VIDEO_FORMAT)
+            if (iMediaType == PVMF_MEDIA_UNCOMPRESSED_VIDEO)
             {
                 if ((iConsecutiveFramesDropped >= THRESHOLD_FOR_DROPPED_VIDEO_FRAMES) && (iLateFrameEventSent == false))
                 {
                     iLateFrameEventSent = true;
-                    iNode->ReportInfoEvent(PVMFInfoVideoTrackFallingBehind);
+                    iNode->ReportInfoEvent(PVMFInfoVideoTrackFallingBehind, (OsclAny*)NULL);
                 }
             }
             return PVMF_MEDIAOUTPUTNODEPORT_MEDIA_LATE;
@@ -1434,8 +1592,8 @@
                                      iSinkFormatString.get_str(),
                                      iCurrentMediaMsg->getSeqNum(),
                                      iCurrentMediaMsg->getTimestamp(),
-                                     Oscl_Int64_Utils::get_int64_lower32(iClockFrameCount),
-                                     Oscl_Int64_Utils::get_int64_lower32(iSyncFrameCount)));
+                                     iClockFrameCount,
+                                     iSyncFrameCount));
             iSyncFrameCount++;
             return PVMF_MEDIAOUTPUTNODEPORT_MEDIA_LATE;
         }
@@ -1447,8 +1605,8 @@
                                      iSinkFormatString.get_str(),
                                      iCurrentMediaMsg->getSeqNum(),
                                      iCurrentMediaMsg->getTimestamp(),
-                                     Oscl_Int64_Utils::get_int64_lower32(iClockFrameCount),
-                                     Oscl_Int64_Utils::get_int64_lower32(iSyncFrameCount)));
+                                     iClockFrameCount,
+                                     iSyncFrameCount));
             return PVMF_MEDIAOUTPUTNODEPORT_MEDIA_EARLY;
         }
         else
@@ -1457,8 +1615,8 @@
                                      iSinkFormatString.get_str(),
                                      iCurrentMediaMsg->getSeqNum(),
                                      iCurrentMediaMsg->getTimestamp(),
-                                     Oscl_Int64_Utils::get_int64_lower32(iClockFrameCount),
-                                     Oscl_Int64_Utils::get_int64_lower32(iSyncFrameCount)));
+                                     iClockFrameCount,
+                                     iSyncFrameCount));
             iSyncFrameCount++;
             return PVMF_MEDIAOUTPUTNODEPORT_MEDIA_ON_TIME;
         }
@@ -1489,7 +1647,7 @@
      * single Run call. Since we could process multiple media msgs per Run
      * we need to account for BOS and Skip as well.
      */
-    while (IncomingMsgQueueSize() > 0)
+    while ((IncomingMsgQueueSize() > 0) || (iCurrentMediaMsg.GetRep() != NULL))
     {
         bool oMsgDqd = false;
         if (iCurrentMediaMsg.GetRep() == NULL)
@@ -1500,7 +1658,7 @@
             {
                 PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::Run: DequeueIncomingMsg Failed - Fmt=%s",
                                       iSinkFormatString.get_str()));
-                OsclError::Panic("PVMOUT", 2);
+                OSCL_ASSERT(0);
             }
             else
             {
@@ -1570,20 +1728,6 @@
         else
         {
             //implies that this message needs to be consumed
-            if (iSendStartOfDataEvent == true)
-            {
-                //implies that we are attempting to process the first media msg during
-                //after skip, a mediamsg whose timestamp is equal to or greater than
-                //iSkipTimestamp
-                PVMF_MOPORT_LOGREPOS((0, "PVMediaOutputNodePort::Run: PVMFInfoStartOfData - Fmt=%s",
-                                      iSinkFormatString.get_str()));
-                PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::Run: PVMFInfoStartOfData - Fmt=%s",
-                                         iSinkFormatString.get_str()));
-                uint32 iStreamID = iRecentStreamID;
-                iNode->ReportInfoEvent(PVMFInfoStartOfData, (OsclAny*)&iStreamID);
-
-                iSendStartOfDataEvent = false;
-            }
             if (oMsgDqd == true)
             {
                 //logging
@@ -1606,6 +1750,7 @@
                 }
                 else if (iCurrentMediaMsg->getFormatID() < PVMF_MEDIA_CMD_FORMAT_IDS_START)
                 {
+                    iTotalFrames++;
                     PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::Run - MediaMsg Recvd - Seq=%d, TS=%d, Fmt=%s, Qs=%d",
                                              iCurrentMediaMsg->getSeqNum(),
                                              iCurrentMediaMsg->getTimestamp(),
@@ -1613,7 +1758,26 @@
                                              IncomingMsgQueueSize()));
                 }
             }
-            if (oProcessIncomingMessage == true)
+
+            if ((iSendStartOfDataEvent == true) && oMIOComponentConfigured)
+            {
+                //implies that we are attempting to process the first media msg during
+                //after skip, a mediamsg whose timestamp is equal to or greater than
+                //iSkipTimestamp
+                PVMF_MOPORT_LOGREPOS((0, "PVMediaOutputNodePort::Run: PVMFInfoStartOfData - Fmt=%s",
+                                      iSinkFormatString.get_str()));
+                PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::Run: PVMFInfoStartOfData - Fmt=%s",
+                                         iSinkFormatString.get_str()));
+                uint32 iStreamID = iRecentStreamID;
+                iNode->ReportInfoEvent(PVMFInfoStartOfData, (OsclAny*)&iStreamID);
+                iSendStartOfDataEvent = false;
+            }
+
+            // We need to check for valid CurrentMediaMsg because it is possible that SendData has been
+            // called from ClockStateUpdated when all tracks report InfoStartofData and Engine starts the clock
+            // If dequeued data has already been sent, we cant send that data again, it will crash
+            // so just return and AO will be scheduled again for next data.
+            if ((oProcessIncomingMessage == true) && (iCurrentMediaMsg.GetRep() != NULL))
             {
                 SendData();
             }
@@ -1755,7 +1919,7 @@
                     }
                     else
                     {
-                        if (iSendStartOfDataEvent == true)
+                        if ((iSendStartOfDataEvent == true) && oMIOComponentConfigured)
                         {
                             //implies that we are attempting to process the first media msg during
                             //after skip, a mediamsg whose timestamp is equal to or greater than
@@ -1766,7 +1930,6 @@
                                                      iSinkFormatString.get_str()));
                             uint32 iStreamID = iRecentStreamID;
                             iNode->ReportInfoEvent(PVMFInfoStartOfData, (OsclAny*)&iStreamID);
-
                             iSendStartOfDataEvent = false;
                         }
                         if (oProcessIncomingMessage)
@@ -1775,9 +1938,9 @@
                             if ((iCurrentMediaMsg.GetRep() != NULL) ||
                                     (iFragIndex != 0))
                             {
-                                PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::HPA: DequeueIncomingMsg oProcessIncomingMessage Invalid - Fmt=%s",
-                                                      iSinkFormatString.get_str()));
-                                OSCL_ASSERT(false);
+                                PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::HPA: DequeueIncomingMsg ignoring msg. Still processing previous msg iCurrentMediaMsg: 0x%x  iFragIndex: %d- Fmt=%s",
+                                                         iCurrentMediaMsg.GetRep(), iFragIndex, iSinkFormatString.get_str()));
+                                return;
                             }
                             if (DequeueIncomingMsg(iCurrentMediaMsg) == PVMFSuccess)
                             {
@@ -1800,6 +1963,7 @@
                                 }
                                 else if (iCurrentMediaMsg->getFormatID() < PVMF_MEDIA_CMD_FORMAT_IDS_START)
                                 {
+                                    iTotalFrames++;
                                     PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::HPA - MediaMsg Recvd - Seq=%d, TS=%d, Fmt=%s, Qs=%d",
                                                              iCurrentMediaMsg->getSeqNum(),
                                                              iCurrentMediaMsg->getTimestamp(),
@@ -1808,6 +1972,9 @@
                                 }
 
                                 SendData();
+
+
+
                                 if ((oProcessIncomingMessage == true) &&
                                         (IncomingMsgQueueSize() > 0))
                                 {
@@ -1858,22 +2025,15 @@
     if (0 == aParameters)
     {
         PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::ConfigMIO: No format-specific info for this track."));
-        if (iWaitForConfig == true)
-        {
-            iNode->MioConfigured();
-            iWaitForConfig = false;
-        }
         return PVMFSuccess;//no format-specific info, so nothing needed.
     }
     uint8* data = (uint8*)aParameters->value.key_specific_value;
-    uint32 data_len = aParameters->capacity;
-
     PVMFStatus status;
 
     //formatted data gets sent to the MIO on first arrival
-    switch (iMediaTypeIndex)
+    switch (iMediaType)
     {
-        case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
+        case PVMF_MEDIA_UNCOMPRESSED_AUDIO:
         {
             channelSampleInfo* pcm16Info = (channelSampleInfo*)data;
             PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::ConfigMIO - SamplingRate=%d, NumChannels=%d",
@@ -1882,17 +2042,17 @@
             //ignore any failures since not all MIO may suppport the parameters.
             //Note: send the parameters individually since some MIO may not know
             //how to process arrays.
-            status = SetMIOParameterUint32(MOUT_AUDIO_SAMPLING_RATE_KEY,
+            status = SetMIOParameterUint32((char*)MOUT_AUDIO_SAMPLING_RATE_KEY,
                                            pcm16Info->samplingRate);
             if (status == PVMFSuccess)
             {
-                SetMIOParameterUint32(MOUT_AUDIO_NUM_CHANNELS_KEY,
+                SetMIOParameterUint32((char*)MOUT_AUDIO_NUM_CHANNELS_KEY,
                                       pcm16Info->desiredChannels);
             }
         }
         break;
 
-        case PVMF_UNCOMPRESSED_VIDEO_FORMAT:
+        case PVMF_MEDIA_UNCOMPRESSED_VIDEO:
         {
             PVMFYuvFormatSpecificInfo0* yuvInfo = (PVMFYuvFormatSpecificInfo0*)data;
             PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::ConfigMIO - Width=%d, Height=%d, DispWidth=%d, DispHeight=%d",
@@ -1901,38 +2061,37 @@
             //ignore any failures since not all MIO may suppport the parameters.
             //Note: send the parameters individually since some MIO may not know
             //how to process arrays.
-            status = SetMIOParameterUint32(MOUT_VIDEO_WIDTH_KEY,
+            status = SetMIOParameterUint32((char*)MOUT_VIDEO_WIDTH_KEY,
                                            yuvInfo->width);
             if (status == PVMFSuccess)
             {
-                status = SetMIOParameterUint32(MOUT_VIDEO_HEIGHT_KEY,
+                status = SetMIOParameterUint32((char*)MOUT_VIDEO_HEIGHT_KEY,
                                                yuvInfo->height);
             }
             if (status == PVMFSuccess)
             {
-                status = SetMIOParameterUint32(MOUT_VIDEO_DISPLAY_WIDTH_KEY,
+                status = SetMIOParameterUint32((char*)MOUT_VIDEO_DISPLAY_WIDTH_KEY,
                                                yuvInfo->display_width);
             }
             if (status == PVMFSuccess)
             {
-                status = SetMIOParameterUint32(MOUT_VIDEO_DISPLAY_HEIGHT_KEY,
+                status = SetMIOParameterUint32((char*)MOUT_VIDEO_DISPLAY_HEIGHT_KEY,
                                                yuvInfo->display_height);
             }
             if (status == PVMFSuccess)
             {
                 // ignore status here
-                SetMIOParameterUint32(MOUT_VIDEO_SUBFORMAT_KEY,
+                SetMIOParameterFormat((char*)MOUT_VIDEO_SUBFORMAT_KEY,
                                       yuvInfo->video_format);
             }
         }
         break;
-
-        case PVMF_COMPRESSED_AUDIO_FORMAT:
-        case PVMF_COMPRESSED_VIDEO_FORMAT:
+        case PVMF_MEDIA_COMPRESSED_AUDIO:
+        case PVMF_MEDIA_COMPRESSED_VIDEO:
             //for compressed formats, the format-specific info is sent as kvp
         {
             PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::ConfigMIO Setting Codec Header - Len=%d, Fmt=%s",
-                                     data_len, iSinkFormatString.get_str()));
+                                     aParameters->capacity, iSinkFormatString.get_str()));
 
             // We will enable the following line after source node fix KVP issue
             //oscl_assert(aParameters->length == aParameters->capacity)
@@ -1956,11 +2115,11 @@
         }
         break;
 
-        case PVMF_TEXT_FORMAT:
+        case PVMF_MEDIA_TEXT:
             //for text formats, the format-specific info is sent as kvp
         {
             PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::ConfigMIO Setting Codec Header - Len=%d, Fmt=%s",
-                                     data_len, iSinkFormatString.get_str()));
+                                     aParameters->capacity, iSinkFormatString.get_str()));
 
             // We will enable the following line after source node fix KVP issue
             //oscl_assert(aParameters->length == aParameters->capacity)
@@ -1985,21 +2144,14 @@
 
         default:
             status = PVMFErrNotSupported;
-            iNode->Assert(false);
+            OSCL_ASSERT(false);
             break;
     }
     if (status != PVMFSuccess)
     {
         iNode->ReportErrorEvent(PVMFErrResource, NULL, PVMFMoutNodeErr_MediaIOSetParameterSync);
     }
-    else
-    {
-        if (iWaitForConfig == true)
-        {
-            iNode->MioConfigured();
-            iWaitForConfig = false;
-        }
-    }
+
     return status;
 }
 
@@ -2091,6 +2243,34 @@
     return PVMFSuccess;
 }
 
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMediaOutputNodePort::SetMIOParameterFormat(PvmiKeyType aKey, PVMFFormatType aFormatType)
+//to set parameters to the MIO component through its config interface.
+{
+    OsclMemAllocator alloc;
+    PvmiKvp kvp;
+    PvmiKvp* retKvp = NULL; // for return value
+
+    kvp.key = NULL;
+    kvp.length = oscl_strlen(aKey) + 1; // +1 for \0
+    kvp.capacity = kvp.length;
+
+    kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+    if (!kvp.key)
+        return PVMFErrNoMemory;
+
+    oscl_strncpy(kvp.key, aKey, kvp.length);
+    kvp.value.pChar_value = (char*)aFormatType.getMIMEStrPtr();
+
+    int32 err;
+    OSCL_TRY(err, iNode->iMIOConfig->setParametersSync(iNode->iMIOSession, &kvp, 1, retKvp););
+    alloc.deallocate(kvp.key);
+
+    if (err != OsclErrNone || retKvp)
+        return PVMFFailure;
+
+    return PVMFSuccess;
+}
 
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFStatus PVMediaOutputNodePort::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
@@ -2184,30 +2364,52 @@
     // to notify the media output node that configuration is complete, so that media output node can complete its pending start
     if (aMsgPtr->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
     {
-        if (iWaitForConfig == true)
+        if (false == oMIOComponentConfigured)
         {
-            iNode->MioConfigured();
-            iWaitForConfig = false;
+            OSCL_ASSERT(oProcessIncomingMessage != true);
+            oMIOComponentConfigured = true;
+            oProcessIncomingMessage = true;
         }
     }
     return true;
 }
 
-void PVMediaOutputNodePort::PVMediaOutputNodePortTimerEvent()
+void PVMediaOutputNodePort::ProcessCallBack(uint32 callBackID,
+        PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy,
+        uint32 aDelta,
+        const OsclAny* aContextData,
+        PVMFStatus aStatus)
 {
-    //timer expires, reset the boolean so that we can start processing more data if need be
-    oProcessIncomingMessage = true;
-    if (iCurrentMediaMsg.GetRep() != NULL)
+    OSCL_UNUSED_ARG(aTimerAccuracy);
+    OSCL_UNUSED_ARG(aDelta);
+    OSCL_UNUSED_ARG(aContextData);
+    PVMF_MOPORT_LOGDEBUG((0, "PVMediaOutputNodePort::ProcessCallBack In Callback id [%d] CallbackStatus [%d]", callBackID, aStatus));
+    if (PVMFSuccess == aStatus)
     {
-        //attempt to send data current media msg if any
-        SendData();
-    }
-    //reschedule if there is more stuff waiting and
-    //if we can process more data
-    if ((oProcessIncomingMessage == true) &&
-            (IncomingMsgQueueSize() > 0))
-    {
-        RunIfNotReady();
+        if (iDelayEarlyFrameCallBkId == callBackID)
+        {
+            oClockCallBackPending = false;
+            //timer expires, reset the boolean so that we can start processing more data if need be
+            oProcessIncomingMessage = true;
+            if (iCurrentMediaMsg.GetRep() != NULL)
+            {
+                //attempt to send data current media msg if any
+                SendData();
+            }
+            //reschedule if there is more stuff waiting and
+            //if we can process more data
+            if ((oProcessIncomingMessage == true) &&
+                    (IncomingMsgQueueSize() > 0))
+            {
+                RunIfNotReady();
+            }
+        }
+        else
+        {
+            PVMF_MOPORT_LOGERROR((0, "PVMediaOutputNodePort::ProcessCallBack- Error stray callback from iClockNotificationsInf callBackID[%d]", callBackID));
+            OSCL_ASSERT(false);
+        }
+
     }
 }
 
@@ -2223,11 +2425,13 @@
     iSkipTimestamp = aSkipTS;
     iRecentStreamID = aStreamID;
     iSendStartOfDataEvent = true;
-    //cancel any outstanding delay timer
-    if (iDelayTimer != NULL)
+    if (oClockCallBackPending)
     {
-        iDelayTimer->Stop();
+        iClockNotificationsInf->CancelCallback(iDelayEarlyFrameCallBkId, false);
     }
+    oClockCallBackPending = false;
+    iDelayEarlyFrameCallBkId = 0;
+
     //release the current media msg right here instead of
     //waiting on a reschedule. this is to avoid deadlocks
     //in case the upstream node is just operating with a
@@ -2294,7 +2498,7 @@
     //assume that the stream ids are a montonically increasing
     //sequence
     uint32 delta = 0;
-    bool oOldStream = IsEarlier(aMsg->getStreamID(), iRecentStreamID, delta);
+    bool oOldStream = PVTimeComparisonUtils::IsEarlier(aMsg->getStreamID(), iRecentStreamID, delta);
     if (oOldStream && delta > 0)
     {
         //a zero delta could mean the stream ids are equal
@@ -2314,7 +2518,7 @@
         if (iSendStartOfDataEvent == true)
         {
             delta = 0;
-            bool tsEarly = IsEarlier(aMsg->getTimestamp(), iSkipTimestamp, delta);
+            bool tsEarly = PVTimeComparisonUtils::IsEarlier(aMsg->getTimestamp(), iSkipTimestamp, delta);
             if (tsEarly && delta > 0)
             {
                 //a zero delta could mean the timestamps are equal
@@ -2352,16 +2556,13 @@
         iSyncFrameCount = 0;
         iClockFrameCount = 0;
     }
-    if (iDelayTimer != NULL)
+    if (oClockCallBackPending)
     {
-        iDelayTimer->Stop();
+        iClockNotificationsInf->CancelCallback(iDelayEarlyFrameCallBkId, false);
     }
-    oProcessIncomingMessage = true;
-    if (iCurrentMediaMsg.GetRep() != NULL)
-    {
-        //attempt to send data current media msg if any
-        SendData();
-    }
+    oClockCallBackPending = false;
+    iDelayEarlyFrameCallBkId = 0;
+
     //reschedule if there is more stuff waiting and
     //if we can process more data
     if ((oProcessIncomingMessage == true) &&
@@ -2379,6 +2580,7 @@
         iClock->GetCountTimebase()->GetCount(iClockFrameCount);
         //wake up the AO to process data
         oProcessIncomingMessage = true;
+
         if (iCurrentMediaMsg.GetRep() != NULL)
         {
             //attempt to send data current media msg if any
@@ -2398,12 +2600,17 @@
 {
 }
 
+void PVMediaOutputNodePort::NotificationsInterfaceDestroyed()
+{
+    iClockNotificationsInf = NULL;
+}
+
 void PVMediaOutputNodePort::ClockStateUpdated()
 {
     if (iClock == NULL)
         return;
 
-    if (iClock->GetState() == OsclClock::PAUSED)
+    if (iClock->GetState() == PVMFMediaClock::PAUSED)
     {
         PVMF_MOPORT_LOGREPOS((0, "PVMediaOutputNodePort::ClockStateUpdated: Clock Paused - Fmt=%s",
                               iSinkFormatString.get_str()));
@@ -2415,28 +2622,45 @@
         if (oActiveMediaOutputComp == false)
         {
             oProcessIncomingMessage = false;
-            if (iDelayTimer != NULL)
+            if (oClockCallBackPending)
             {
-                iDelayTimer->Stop();
+                iClockNotificationsInf->CancelCallback(iDelayEarlyFrameCallBkId, false);
             }
+            oClockCallBackPending = false;
+            iDelayEarlyFrameCallBkId = 0;
         }
     }
-    else if (iClock->GetState() == OsclClock::RUNNING)
+    else if (iClock->GetState() == PVMFMediaClock::RUNNING)
     {
         PVMF_MOPORT_LOGREPOS((0, "PVMediaOutputNodePort::ClockStateUpdated: Clock Running - Fmt=%s",
                               iSinkFormatString.get_str()));
         PVMF_MOPORT_LOGDATAPATH((0, "PVMediaOutputNodePort::ClockStateUpdated: Clock Running - Fmt=%s",
                                  iSinkFormatString.get_str()));
-        //start processing input msgs
-        oProcessIncomingMessage = true;
+
+        //If MIO component is configured, messages can be processed now.
+        if (oMIOComponentConfigured)
+        {
+            oProcessIncomingMessage = true;
+        }
+
+        if (oClockCallBackPending)
+        {
+            iClockNotificationsInf->CancelCallback(iDelayEarlyFrameCallBkId, false);
+        }
+        oClockCallBackPending = false;
+        iDelayEarlyFrameCallBkId = 0;
+
+
         //reset write state as well, in case mo comp is still busy
         //it will leave again, so that state will get reset
         iWriteState = EWriteOK;
+
         if (iCurrentMediaMsg.GetRep() != NULL)
         {
             //attempt to send data current media msg if any
             SendData();
         }
+
         //reschedule if there is more stuff waiting and
         //if we can process more data
         if ((oProcessIncomingMessage == true) &&
@@ -2445,7 +2669,7 @@
             RunIfNotReady();
         }
     }
-    else if (iClock->GetState() == OsclClock::STOPPED)
+    else if (iClock->GetState() == PVMFMediaClock::STOPPED)
     {
         PVMF_MOPORT_LOGREPOS((0, "PVMediaOutputNodePort::ClockStateUpdated: Clock Stopped - Fmt=%s",
                               iSinkFormatString.get_str()));
@@ -2458,10 +2682,12 @@
         if (oActiveMediaOutputComp == false)
         {
             oProcessIncomingMessage = false;
-            if (iDelayTimer != NULL)
+            if (oClockCallBackPending)
             {
-                iDelayTimer->Stop();
+                iClockNotificationsInf->CancelCallback(iDelayEarlyFrameCallBkId, false);
             }
+            oClockCallBackPending = false;
+            iDelayEarlyFrameCallBkId = 0;
         }
     }
     RunIfNotReady();
@@ -2490,13 +2716,15 @@
     }
 }
 
-
-
-
-
-
-
-
-
-
-
+int32 PVMediaOutputNodePort::WriteDataToMIO(int32 &aCmdId, PvmiMediaXferHeader &aMediaxferhdr, OsclRefCounterMemFrag &aFrag)
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY_NO_TLS(iOsclErrorTrapImp, leavecode,
+                    aCmdId = iMediaTransfer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA,  /*format_type*/
+                                                        PVMI_MEDIAXFER_FMT_INDEX_DATA, /*format_index*/
+                                                        (uint8*)aFrag.getMemFragPtr(),
+                                                        aFrag.getMemFragSize(),
+                                                        aMediaxferhdr,
+                                                        (OsclAny*) & iWriteAsyncContext););
+    return leavecode;
+}
diff --git a/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.h b/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.h
index 1c111af..300048d 100644
--- a/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.h
+++ b/nodes/pvmediaoutputnode/src/pv_media_output_node_inport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,59 +78,15 @@
 
 #define THRESHOLD_FOR_DROPPED_VIDEO_FRAMES 120
 
-/**
- * Observer class for the inactivity timer AO
- */
-class PVMediaOutputNodePortTimerObserver
-{
-    public:
-        virtual ~PVMediaOutputNodePortTimerObserver() {}
-        /**
-         * A timer event, indicating that the timer has expired.
-         */
-        virtual void PVMediaOutputNodePortTimerEvent() = 0;
-};
-
-/**
- * Timer used while pacing data for passive media output comps
- */
-class PVMediaOutputNodePortTimer : public OsclTimerObject
-{
-    public:
-        PVMediaOutputNodePortTimer(PVMediaOutputNodePortTimerObserver* aObserver);
-
-        virtual ~PVMediaOutputNodePortTimer();
-
-        /** Start Timer */
-        PVMFStatus Start();
-
-        PVMFStatus setTimerDurationInMS(uint32 duration);
-
-        /** Stop Timer events */
-        PVMFStatus Stop();
-
-        bool IsTimerStarted()
-        {
-            return iStarted;
-        }
-
-    private:
-        void Run();
-        uint32 iDurationInMS;
-        PVMediaOutputNodePortTimerObserver* iObserver;
-        bool iStarted;
-};
-
-
 class PVMediaOutputNodePort : public OsclTimerObject
             , public PvmfPortBaseImpl
             , public PvmfNodesSyncControlInterface
             , public PvmiMediaTransfer
             , public PVMFPortActivityHandler
             , public PvmiCapabilityAndConfig
-            , public PVMediaOutputNodePortTimerObserver
-            , public OsclClockObserver
-            , public OsclClockStateObserver
+            , public PVMFMediaClockObserver
+            , public PVMFMediaClockStateObserver
+            , public PVMFMediaClockNotificationsObs
 {
     public:
         PVMediaOutputNodePort(PVMediaOutputNode* aNode);
@@ -157,23 +113,19 @@
         bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
 
         // Pure virtuals from PvmfNodesSyncControlInterface
-        PVMFStatus SetClock(OsclClock* aClock);
+        PVMFStatus SetClock(PVMFMediaClock* aClock);
         PVMFStatus ChangeClockRate(int32 aRate);
         PVMFStatus SetMargins(int32 aEarlyMargin, int32 aLateMargin);
         void ClockStarted();
         void ClockStopped();
         PVMFCommandId SkipMediaData(int32,
-                                    PVMFTimestamp aStartingTimestamp,
                                     PVMFTimestamp aResumeTimestamp,
                                     uint32 aStreamID,
-                                    bool aRenderSkippedData = false,
                                     bool aPlayBackPositionContinuous = false,
                                     OsclAny* aContext = NULL)
         {
-            OSCL_UNUSED_ARG(aStartingTimestamp);
             OSCL_UNUSED_ARG(aResumeTimestamp);
             OSCL_UNUSED_ARG(aStreamID);
-            OSCL_UNUSED_ARG(aRenderSkippedData);
             OSCL_UNUSED_ARG(aPlayBackPositionContinuous);
             OSCL_UNUSED_ARG(aContext);
             OSCL_LEAVE(OsclErrNotSupported);
@@ -240,31 +192,42 @@
             }
         }
 
-        //From OsclClockObserver
+        //From PVMFMediaClockObserver
         void ClockTimebaseUpdated();
         void ClockCountUpdated();
         void ClockAdjusted();
         //From OsclClockStateObserver
         void ClockStateUpdated();
+        void NotificationsInterfaceDestroyed();
 
         //To allow the node to set the port format.
         PVMFFormatType iPortFormat;
         bool IsFormatSupported(PVMFFormatType);
         void FormatUpdated();
 
-        //from PVMediaOutputNodePortTimerObserver
-        void PVMediaOutputNodePortTimerEvent();
+        //for processing the callbacks for the notifications requested to iClockNotificationsInf
+        void ProcessCallBack(uint32 callBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 aDelta, const OsclAny* aContextData, PVMFStatus aStatus);
+
+        void ProcessIncomingMessageIfPossible();
+        // MIO node sets this status when MIO component's config is complete.
+        void SetMIOComponentConfigStatus(bool aStatus);
 
         void SetSkipTimeStamp(uint32 aSkipTS, uint32 aStreamID);
         void CancelSkip();
 
-        bool iWaitForConfig;
         bool isUnCompressedMIO;
+        uint32 iFramesDropped;
+        uint32 iTotalFrames;
 
         //BOS related
         Oscl_Vector<uint32, OsclMemAllocator> iBOSStreamIDVec;
         void ClearPreviousBOSStreamIDs(uint32 aID);
 
+        int32 WriteDataToMIO(int32 &aCmdId, PvmiMediaXferHeader &aMediaxferhdr, OsclRefCounterMemFrag &aFrag);
+        PvmiMediaTransfer* getMediaTransfer()
+        {
+            return iMediaTransfer;
+        }
     private:
         void Run();
         bool peekHead(PVMFSharedMediaMsgPtr& dataPtr, bool& bBos);
@@ -272,6 +235,7 @@
         PVMFStatus SetMIOParameterInt32(PvmiKeyType aKey, int32 aValue);
         PVMFStatus SetMIOParameterUint32(PvmiKeyType aKey, uint32 aValue);
         PVMFStatus SetMIOParameterPchar(PvmiKeyType aKey, char* aValue);
+        PVMFStatus SetMIOParameterFormat(PvmiKeyType aKey, PVMFFormatType aFormatType);
 
         // Container node
         PVMediaOutputNode* iNode;
@@ -283,7 +247,15 @@
         //data transfer related
         PvmiMediaTransfer* iMediaTransfer;
         PVMFCommandId iMioInfoErrorCmdId;
-        PvmfMediaTypeIndex iMediaTypeIndex;
+        enum PVMFMediaType
+        {
+            PVMF_MEDIA_UNKNOWN = 0,
+            PVMF_MEDIA_UNCOMPRESSED_AUDIO,
+            PVMF_MEDIA_COMPRESSED_AUDIO,
+            PVMF_MEDIA_UNCOMPRESSED_VIDEO,
+            PVMF_MEDIA_COMPRESSED_VIDEO,
+            PVMF_MEDIA_TEXT
+        } iMediaType;
         enum WriteState {EWriteBusy, EWriteWait, EWriteOK};
         WriteState iWriteState;
         //media data cleanup queue
@@ -299,13 +271,16 @@
         uint32 iWriteAsyncContext;
         uint32 iWriteAsyncEOSContext;
         uint32 iWriteAsyncReConfigContext;
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
+        PVMFMediaClockNotificationsInterface *iClockNotificationsInf;
+        bool oClockCallBackPending;
+        uint32 iDelayEarlyFrameCallBkId;
         int32 iClockRate;
         uint32 iEarlyMargin;
         uint32 iLateMargin;
-        PVMediaOutputNodePortTimer* iDelayTimer;
         bool oActiveMediaOutputComp;
         bool oProcessIncomingMessage;
+        bool oMIOComponentConfigured;
         uint32 iConsecutiveFramesDropped;
         bool iLateFrameEventSent;
         PVMFSharedMediaMsgPtr iCurrentMediaMsg;
@@ -325,15 +300,21 @@
         PVMFMediaOutputNodePortMediaTimeStatus CheckMediaTimeStamp(uint32& aDelta);
         PVMFMediaOutputNodePortMediaTimeStatus CheckMediaFrameStep();
         uint32 iRecentStreamID;
-        uint32 iEOSStreamId;
+
+        //iEosStreamIDVec is used as a FIFO to store the steamids of eos sent to mio comp.
+        //streamid is pushed in at front when call writeasync(eos) to mio comp.
+        //streamid is poped out from end when mio comp. calls writecomplete(eos),
+        //we report PVMFInfoEndOfData with the poped streamid.
+        //This logic depends on Mio comp. process data(at least eos msg) in a sequencial style.
+        Oscl_Vector<uint32, OsclMemAllocator> iEosStreamIDVec;
         uint32 iSkipTimestamp;
         bool iSendStartOfDataEvent;
         bool DataToSkip(PVMFSharedMediaMsgPtr& aMsg);
 
         //frame step related
         bool iFrameStepMode;
-        int64 iClockFrameCount;
-        int64 iSyncFrameCount;
+        int32 iClockFrameCount;
+        int32 iSyncFrameCount;
 
         //for datapath logging
         void LogMediaDataInfo(const char* msg, PVMFSharedMediaDataPtr mediaData, int32 p1, int32 p2);
diff --git a/nodes/pvmp3ffparsernode/Android.mk b/nodes/pvmp3ffparsernode/Android.mk
index 08a1cf7..1b94f03 100644
--- a/nodes/pvmp3ffparsernode/Android.mk
+++ b/nodes/pvmp3ffparsernode/Android.mk
@@ -3,30 +3,29 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_mp3ffparser_node.cpp \
-	src/pvmf_mp3ffparser_outport.cpp \
-	src/pvmf_mp3ffparser_factory.cpp
-
+ 	src/pvmf_mp3ffparser_outport.cpp \
+ 	src/pvmf_mp3ffparser_factory.cpp
 
 
 LOCAL_MODULE := libpvmp3ffparsernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvmp3ffparsernode/include \
-	$(PV_TOP)//nodes/pvmp3ffparsernode/src \
-	$(PV_TOP)//nodes/pvmp3ffparsernode/../../fileformats/mp3/parser/include/ \
-	$(PV_TOP)//nodes/pvmp3ffparsernode/../common/include \
-	$(PV_TOP)//nodes/pvmp3ffparsernode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvmp3ffparsernode/../../baselibs/pv_mime_utils/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvmp3ffparsernode/src \
+ 	$(PV_TOP)/nodes/pvmp3ffparsernode/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_mp3ffparser_factory.h \
-	include/pvmf_mp3ffparser_defs.h
+ 	include/pvmf_mp3ffparser_defs.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvmp3ffparsernode/build/make/local.mk b/nodes/pvmp3ffparsernode/build/make/local.mk
new file mode 100644
index 0000000..a4036c8
--- /dev/null
+++ b/nodes/pvmp3ffparsernode/build/make/local.mk
@@ -0,0 +1,25 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp3ffparsernode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+SRCDIR := ../../src
+
+INCSRCDIR := ../../include
+
+SRCS := pvmf_mp3ffparser_node.cpp pvmf_mp3ffparser_outport.cpp pvmf_mp3ffparser_factory.cpp
+
+HDRS := pvmf_mp3ffparser_factory.h pvmf_mp3ffparser_defs.h
+
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvmp3ffparsernode/build/make/makefile b/nodes/pvmp3ffparsernode/build/make/makefile
deleted file mode 100755
index 03ff29b..0000000
--- a/nodes/pvmp3ffparsernode/build/make/makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp3ffparsernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-XINCDIRS += -I../../../../fileformats/mp3/parser/include/
-XINCDIRS += -I ../../../common/include -I../../../../pvmi/pvmf/include -I../../../../baselibs/pv_mime_utils/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-
-# Extra spaces at the end of the next line will cause the header installation step to fail.
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pvmf_mp3ffparser_node.cpp pvmf_mp3ffparser_outport.cpp pvmf_mp3ffparser_factory.cpp
-
-HDRS =     pvmf_mp3ffparser_factory.h pvmf_mp3ffparser_defs.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_defs.h b/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_defs.h
index 6212536..9c93198 100644
--- a/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_defs.h
+++ b/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -55,4 +55,5 @@
 #define PVMF_MP3FFPARSER_NODE_MIMETYPE "pvxxx/MP3FFParserNode"
 #define PVMF_BASEMIMETYPE "pvxxx"
 
-#endif // end PVMF_MP3FFPARSER_DEFS_H_INCLUDED
\ No newline at end of file
+#endif // end PVMF_MP3FFPARSER_DEFS_H_INCLUDED
+
diff --git a/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_factory.h b/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_factory.h
index bc24753..99d2464 100644
--- a/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_factory.h
+++ b/nodes/pvmp3ffparsernode/include/pvmf_mp3ffparser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_factory.cpp b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_factory.cpp
index 30ccb3c..65fb36d 100644
--- a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_factory.cpp
+++ b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.cpp b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.cpp
index 55fa0ae..39ff65f 100644
--- a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.cpp
+++ b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,6 @@
 #ifndef PVMF_MP3FFPARSER_NODE_H_INCLUDED
 #include "pvmf_mp3ffparser_node.h"
 #endif
-#ifndef IMP3FF_H_INCLUDED
-#include "imp3ff.h"  // Includes for the core file format mp3 parser library
-#endif
 #ifndef PVLOGGER_H_INCLUDED
 #include "pvlogger.h"
 #endif
@@ -45,11 +42,11 @@
 #define COMMON_PLAYBACK_CLOCK_TIMESCALE 1000
 
 // Constants used for memory pools
-#define PVMP3FF_MEDIADATA_CHUNKS_IN_POOL	8
-#define PVMP3FF_MEDIADATA_CHUNKSIZE			128
+#define PVMP3FF_MEDIADATA_CHUNKS_IN_POOL    8
+#define PVMP3FF_MEDIADATA_CHUNKSIZE         256
 // the maximum frame size depends on K * bitrate/sampling_rate
-#define PVMP3FF_DEFAULT_MAX_FRAMESIZE		4096
-#define PVMF3FF_DEFAULT_NUM_OF_FRAMES		2
+#define PVMP3FF_DEFAULT_MAX_FRAMESIZE       4096
+#define PVMF3FF_DEFAULT_NUM_OF_FRAMES       5
 #define PVMF3FF_DURATION_SCAN_AO_DELAY      1000
 /**
  * Macros for calling PVLogger
@@ -60,14 +57,6 @@
 #define LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
 #define LOGINFO(m) LOGINFOMED(m)
 
-void PVMFMP3FFParserNode::Assert(bool aCondition)
-{
-    if (!aCondition)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_CRIT, (0, "PVMFMP3FFParserNode Assertion Failed!"));
-        OSCL_ASSERT(0);
-    }
-}
 
 /**
  * Constructor
@@ -86,6 +75,7 @@
         iSendDecodeFormatSpecificInfo(true)
 {
     iCPMContainer.iCPMLicenseInterface = NULL;
+    iCPMContainer.iCPMLicenseInterfacePVI = NULL;
     iUseCPMPluginRegistry = false;
     iCPMContainer.iCPMMetaDataExtensionInterface   = NULL;
     iCPMGetMetaDataKeysCmdId = 0;
@@ -102,8 +92,8 @@
     iFileSizeRecvd = false;
     iFileSize = 0;
     iCheckForMP3HeaderDuringInit = false;
-
     iDurationCalcAO = NULL;
+
     int32 err;
 
     OSCL_TRY(err,
@@ -127,8 +117,8 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = false;
              iCapability.iMaxNumberOfPorts = 0;//no maximum
-             iCapability.iInputFormatCapability.push_back(PVMF_MP3);
-             iCapability.iOutputFormatCapability.push_back(PVMF_MP3);
+             iCapability.iInputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_MP3));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_MP3));
              // secondry construction
              Construct();
             );
@@ -170,7 +160,6 @@
  */
 PVMFMP3FFParserNode::~PVMFMP3FFParserNode()
 {
-    //ThreadLogoff
     if (IsAdded())
     {
         RemoveFromScheduler();
@@ -184,8 +173,9 @@
     // Unbind the download progress clock
     iDownloadProgressClock.Unbind();
     // Release the download progress interface, if any
-    if (iDownloadProgressInterface)
+    if (iDownloadProgressInterface != NULL)
     {
+        iDownloadProgressInterface->cancelResumeNotification();
         iDownloadProgressInterface->removeRef();
         iDownloadProgressInterface = NULL;
     }
@@ -194,7 +184,7 @@
     //so panic here instead.
     if (iCPMContainer.CmdPending())
     {
-        OsclError::Panic("PVMP3FF", 1);
+        OSCL_ASSERT(0);
     }
 
     //Cleanup allocated ports
@@ -289,7 +279,7 @@
 }
 
 /**
- * Retrive a port iterator.
+ * Retrieve a port iterator.
  */
 PVMFPortIter* PVMFMP3FFParserNode::GetPorts(const PVMFPortFilter* aFilter)
 {
@@ -731,7 +721,6 @@
                 break;
             case PVMF_GENERIC_NODE_RESET:
                 SetState(EPVMFNodeIdle);
-                ThreadLogoff();
                 break;
             default:
                 break;
@@ -782,7 +771,11 @@
         case EPVMFNodePaused:
         case EPVMFNodeError:
         {
-            if (iDurationCalcAO->IsBusy())
+            if (iDownloadProgressInterface != NULL)
+            {
+                iDownloadProgressInterface->cancelResumeNotification();
+            }
+            if (iDurationCalcAO && iDurationCalcAO->IsBusy())
             {
                 iDurationCalcAO->Cancel();
             }
@@ -935,7 +928,7 @@
 
     // Create base port with default settings...
     PVMFMP3FFParserPort*outport = new(ptr) PVMFMP3FFParserPort(tag, this,
-            0, 0, 0,	// input queue isn't needed.
+            0, 0, 0,    // input queue isn't needed.
             DEFAULT_DATA_QUEUE_CAPACITY,
             DEFAULT_DATA_QUEUE_CAPACITY,
             DEFAULT_READY_TO_RECEIVE_THRESHOLD_PERCENT);
@@ -949,8 +942,7 @@
     }
 
     OsclMemPoolResizableAllocator* trackdatamempool = NULL;
-    TrackDataMemPoolProxyAlloc* trackdatamempoolproxy = NULL;
-    PVMFSimpleMediaBufferCombinedAlloc *mediadataimplalloc = NULL;
+    PVMFResizableSimpleMediaMsgAlloc *mediadataimplalloc = NULL;
     PVMFMemPoolFixedChunkAllocator* mediadatamempool = NULL;
     MediaClockConverter* clockconv = NULL;
     err = 0;
@@ -959,12 +951,11 @@
              // Instantiate the mem pool which will hold the actual track data
              trackdatamempool = OSCL_NEW(OsclMemPoolResizableAllocator,
                                          (2 * PVMF3FF_DEFAULT_NUM_OF_FRAMES * iMaxFrameSize, 2));
-             trackdatamempoolproxy = OSCL_NEW(TrackDataMemPoolProxyAlloc, (*trackdatamempool));
 
              // Instantiate an allocator for the mediadata implementation,
-             //have it use the mem pool defined above as its allocator
-             mediadataimplalloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc,
-                                           (trackdatamempoolproxy));
+             // have it use the mem pool defined above as its allocator
+             mediadataimplalloc = OSCL_NEW(PVMFResizableSimpleMediaMsgAlloc, (trackdatamempool));
+
              // Instantiate another memory pool for the media data structures.
              mediadatamempool = OSCL_NEW(PVMFMemPoolFixedChunkAllocator,
                                          ("Mp3FFPar", PVMP3FF_MEDIADATA_CHUNKS_IN_POOL,
@@ -972,8 +963,7 @@
              clockconv = OSCL_NEW(MediaClockConverter, (iMP3File->GetTimescale()));
             ); // Try block end
 
-    if (err != 0 || trackdatamempool == NULL || !trackdatamempoolproxy ||
-            mediadataimplalloc == NULL || mediadatamempool == NULL || clockconv == NULL)
+    if (err != 0 || trackdatamempool == NULL || mediadataimplalloc == NULL || mediadatamempool == NULL || clockconv == NULL)
     {
         if (clockconv)
         {
@@ -991,22 +981,20 @@
         {
             trackdatamempool->removeRef();
         }
-        if (trackdatamempoolproxy)
-        {
-            OSCL_DELETE(trackdatamempoolproxy);
-        }
         iPortVector.Erase(&outport);
 
         return PVMFErrNoMemory;
     }
 
+    trackdatamempool->enablenullpointerreturn();
+    mediadatamempool->enablenullpointerreturn();
+
     // Instantiate the PVMP3FFNodeTrackPortInfo object that contains the port.
     iTrack.iPort = outport;
     iTrack.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_UNINITIALIZED;
     iTrack.iClockConverter = clockconv;
     iTrack.iMediaDataMemPool = mediadatamempool;
     iTrack.iTrackDataMemoryPool = trackdatamempool;
-    iTrack.iTrackDataMemoryPoolProxy = trackdatamempoolproxy;
     iTrack.iMediaDataImplAlloc = mediadataimplalloc;
     iTrack.timestamp_offset = 0;
 
@@ -1025,10 +1013,13 @@
                     (0, "PVMFMP3FFParserNode::DoReleasePort() In"));
     //Find the port in the port vector
     PVMFStatus status;
-    PVMFMP3FFParserPort* port;
-    aCmd.PVMFMP3FFParserNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* p = NULL;
+    aCmd.PVMFMP3FFParserNodeCommandBase::Parse(p);
+
+    PVMFMP3FFParserPort* port = (PVMFMP3FFParserPort*)p;
+
     PVMFMP3FFParserPort** portPtr = iPortVector.FindByValue(port);
-    if (iDurationCalcAO->IsBusy())
+    if (iDurationCalcAO && iDurationCalcAO->IsBusy())
     {
         iDurationCalcAO->Cancel();
     }
@@ -1065,7 +1056,7 @@
             {
                 // Instantiate the IMpeg3File object, this class represents the mp3ff library
                 MP3ErrorType bSuccess = MP3_SUCCESS;
-                int32 leavecode = 0;
+
                 PVMFDataStreamFactory* dsFactory = iCPMContainer.iCPMContentAccessFactory;
                 if ((dsFactory == NULL) && (iDataStreamFactory != NULL))
                 {
@@ -1073,25 +1064,22 @@
                 }
 
                 // Try block start
-                OSCL_TRY(leavecode, iMP3File = OSCL_NEW(IMpeg3File,
-                                                        (iSourceURL, bSuccess,
-                                                         &iFileServer, dsFactory,
-                                                         iFileHandle, false)));
+                PVMFStatus returncode = CreateMP3FileObject(bSuccess, dsFactory);
                 // Try block end
 
-                if (leavecode || !iMP3File || (bSuccess != MP3_SUCCESS))
+                if ((returncode != PVMFSuccess) || !iMP3File || (bSuccess != MP3_SUCCESS))
                 {
                     // creation of IMpeg3File object failed or resulted in error
                     SetState(EPVMFNodeError);
                     return PVMFErrResource;
                 }
+                int32 leavecode = 0;
                 OSCL_TRY(leavecode, iDurationCalcAO = OSCL_NEW(PVMp3DurationCalculator,
                                                       (OsclActiveObject::EPriorityIdle, iMP3File, this)));
-                if (leavecode || !iDurationCalcAO)
+                if (leavecode)
                 {
-                    // creation of iDurationCalcAO object failed or resulted in error
-                    SetState(EPVMFNodeError);
-                    return PVMFErrResource;
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFMP3FFParserNode::DoInit() Duration Scan is disabled DurationCalcAO not created"));
                 }
             }
             //If a CPM flag was provided in the source data, then
@@ -1115,7 +1103,7 @@
             else
             {
                 status = CheckForMP3HeaderAvailability();
-                if (status == MP3_SUCCESS)
+                if (status == MP3_SUCCESS && iDurationCalcAO)
                 {
                     iDurationCalcAO->ScheduleAO();
                 }
@@ -1167,11 +1155,15 @@
             }
             return PVMFSuccess;
         }
-        uint32 ts = 0;
-        iDownloadProgressInterface->requestResumeNotification(ts, iDownloadComplete);
-        // Data is not available, autopause the track.
-        iAutoPaused = true;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFMP3FFParserNode::DoPrepare() - Auto Pause Triggered, TS = %d", ts));
+        if (bytesReady == 0)
+        {
+
+            uint32 ts = 0;
+            iDownloadProgressInterface->requestResumeNotification(ts, iDownloadComplete);
+            // Data is not available, autopause the track.
+            iAutoPaused = true;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFMP3FFParserNode::DoPrepare() - Auto Pause Triggered, TS = %d", ts));
+        }
     }
     return PVMFSuccess;
 }
@@ -1215,12 +1207,14 @@
  */
 PVMFStatus PVMFMP3FFParserNode::DoStop(PVMFMP3FFParserNodeCommand& aCmd)
 {
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFMP3FFParserNode::DoStop() In"));
 
     OSCL_UNUSED_ARG(aCmd);
     PVMFStatus status = PVMFSuccess;
     // Process Stop according to the Node State
+    iStreamID = 0;
     switch (iInterfaceState)
     {
         case EPVMFNodeStarted:
@@ -1239,7 +1233,10 @@
             status = PVMFSuccess;
             iFileSizeRecvd = false;
             iDownloadComplete = false;
-            iDurationCalcAO->Cancel();
+            if (iDurationCalcAO)
+            {
+                iDurationCalcAO->Cancel();
+            }
         }
         break;
         default:
@@ -1286,7 +1283,7 @@
             }
             // reset the track
             ResetTrack();
-            if (iDurationCalcAO->IsBusy())
+            if (iDurationCalcAO && iDurationCalcAO->IsBusy())
             {
                 iDurationCalcAO->Cancel();
             }
@@ -1442,9 +1439,7 @@
     /* Copy the requested keys */
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
     uint32 lcv = 0;
-
     for (lcv = 0; lcv < iCPMMetadataKeys.size(); lcv++)
     {
         if (query_key == NULL)
@@ -1454,11 +1449,11 @@
             if (num_entries > (uint32)starting_index)
             {
                 /* Past the starting index so copy the key */
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP3FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushBackCPMMetadataKeys(keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -1472,11 +1467,11 @@
                 if (num_entries > (uint32)starting_index)
                 {
                     /* Past the starting index so copy the key */
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP3FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushBackCPMMetadataKeys(keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -1488,9 +1483,11 @@
         }
     }
     return PVMFSuccess;
-
 }
 
+
+
+
 /**
  * CommandHandler for fetching Metadata Values
  */
@@ -1636,7 +1633,7 @@
         // Port was busy
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                         (0, "PVMFMP3FFParserNode::ProcessOutgoingMsg: \
-						Connected port goes into busy state"));
+                        Connected port goes into busy state"));
     }
     return status;
 }
@@ -1656,16 +1653,34 @@
     {
         // Read capacity notification was delivered
         iCheckForMP3HeaderDuringInit = false;
-
         PVMFStatus cmdStatus = CheckForMP3HeaderAvailability();
-        if (cmdStatus == PVMFSuccess)
+        if (PVMFSuccess == cmdStatus)
         {
             LOGINFO((0, "PVMFMP3FFParserNode::Run() CheckForMP3HeaderAvailability() succeeded"));
             // complete init command
             CompleteInit(cmdStatus);
         }
-        else
+        else if (PVMFErrUnderflow == cmdStatus)
         {
+            if (iMP3File)
+            {
+                bool nextBytes = true;
+                uint32 currCapacity = 0;
+                uint32 minBytesRequired = iMP3File->GetMinBytesRequired(nextBytes);
+                // CheckForMP3HeaderAvailability has failed because of underflow.
+                // parser needs more bytes to do parsing and verification of the clip.
+                PvmiDataStreamStatus status = iDataStreamInterface->QueryReadCapacity(iDataStreamSessionID,
+                                              currCapacity);
+
+                if (PVDS_SUCCESS == status && currCapacity < minBytesRequired + iMP3MetaDataSize)
+                {
+                    // Request for read capacity notification was issued
+                    iRequestReadCapacityNotificationID =
+                        iDataStreamInterface->RequestReadCapacityNotification(iDataStreamSessionID,
+                                *this,
+                                iMP3MetaDataSize + minBytesRequired);
+                }
+            }
             LOGINFO((0, "PVMFMP3FFParserNode::Run() CheckForMP3HeaderAvailability() failed %d", cmdStatus));
         }
         return;
@@ -1759,9 +1774,14 @@
 
 int32 PVMFMP3FFParserNode::convertSizeToTime(uint32 aFileSize, uint32& aNPTInMS)
 {
-    OSCL_UNUSED_ARG(aFileSize);
-    OSCL_UNUSED_ARG(aNPTInMS);
-    return -1;
+    if (!iMP3File)
+    {
+        return -1;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFMP3FFParserNode::ConvertSizeToTime() aFileSize=%d, aNPTInMS=%d", aFileSize, aNPTInMS));
+
+    return iMP3File->ConvertSizeToTime(aFileSize, aNPTInMS);
 }
 
 void PVMFMP3FFParserNode::setFileSize(const uint32 aFileSize)
@@ -1942,18 +1962,20 @@
     // Create new media data buffer from pool
     int errcode = 0;
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
+
     // Try block start
     OSCL_TRY(errcode,
              mediaDataImplOut = aTrackPortInfo.iMediaDataImplAlloc->allocate(numsamples * iMaxFrameSize)
             );
     // Try block end
+
     if (errcode != 0)
     {
         // There was an error while allocating MediaDataImpl
         if (errcode == OsclErrNoResources)
         {
             aTrackPortInfo.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_TRACKDATAPOOLEMPTY;
-            aTrackPortInfo.iTrackDataMemoryPool->notifyfreeblockavailable(*this, numsamples*iMaxFrameSize);	// Enable flag to receive event when next deallocate() is called on pool
+            aTrackPortInfo.iTrackDataMemoryPool->notifyfreeblockavailable(*this, numsamples*iMaxFrameSize); // Enable flag to receive event when next deallocate() is called on pool
         }
         else if (errcode == OsclErrNoMemory)
         {
@@ -1975,23 +1997,28 @@
         }
         // All above conditions were Error conditions
         return false;
-    } //end if
+    }
+
+    if (mediaDataImplOut.GetRep() == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP3FFParserNode::RetrieveTrackData() No Resource Found"));
+        aTrackPortInfo.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_TRACKDATAPOOLEMPTY;
+        aTrackPortInfo.iTrackDataMemoryPool->notifyfreeblockavailable(*this);
+        return false;
+    }
 
     // Reset error code for further processing
-    errcode = 0;
+    errcode = OsclErrNoResources;
     PVMFSharedMediaDataPtr mediadataout;
-    // Try block start
-    OSCL_TRY(errcode,
-             mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut,
-                            aTrackPortInfo.iMediaDataMemPool)
-            );
-    // Try block end
-    // Catch block start
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackPortInfo.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_MEDIADATAPOOLEMPTY;
-                         aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(*this);
-                         return false);
-    // Catch block end
+    mediadataout =
+        PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool);
+
+    if (mediadataout.GetRep() == NULL)
+    {
+        aTrackPortInfo.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_MEDIADATAPOOLEMPTY;
+        aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(*this);
+        return false;
+    }
 
     // Retrieve memory fragment to write to
     OsclRefCounterMemFrag refCtrMemFragOut;
@@ -2023,12 +2050,12 @@
     {
         // Set buffer size
         mediadataout->setMediaFragFilledLen(0, actualdatasize);
+        mediaDataImplOut->setCapacity(actualdatasize);
         // Return the unused space from mempool back
         if (refCtrMemFragOut.getCapacity() > actualdatasize)
         {
             // Need to go to the resizable memory pool and free some memory
-            aTrackPortInfo.iTrackDataMemoryPoolProxy->trim(refCtrMemFragOut.getCapacity() - actualdatasize);
-            mediaDataImplOut->setCapacity(actualdatasize);
+            aTrackPortInfo.iMediaDataImplAlloc->ResizeMemoryFragment(mediaDataImplOut);
         }
 
         // Set format specific info for the first frame
@@ -2039,6 +2066,20 @@
             iSendDecodeFormatSpecificInfo = false;
             mediadataout->setFormatSpecificInfo(iDecodeFormatSpecificInfo);
         }
+
+        // Set M bit to 1 always - MP3 FF only outputs complete frames
+        uint32 markerInfo = 0;
+        markerInfo |= PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
+
+        // Set Key Frame bit
+        if (aTrackPortInfo.iFirstFrame)
+        {
+            markerInfo |= PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT;
+            aTrackPortInfo.iFirstFrame = false;
+        }
+        mediaDataImplOut->setMarkerInfo(markerInfo);
+
+
         // Save the media data in the trackport info
         aTrackPortInfo.iMediaData = mediadataout;
 
@@ -2077,6 +2118,17 @@
             // Check if DPI is present
             if (iDownloadProgressInterface != NULL)
             {
+                if (retval > 0)
+                {
+                    //parser reported underflow during local playback session
+                    if (!SendTrackData(iTrack))
+                    {
+                        // SendTrackData un-successful
+                        iTrack.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_SENDDATA;
+                        return true;
+                    }
+                }
+
                 if (iDownloadComplete)
                 {
                     aTrackPortInfo.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
@@ -2091,7 +2143,7 @@
                 iAutoPaused = true;
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                                 (0, "PVMFMP3FFParserNode::RetrieveTrackData() \
-								Auto pause Triggered"));
+                                Auto pause Triggered"));
                 return false;
             }
             else
@@ -2109,11 +2161,22 @@
         }
         else
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
-                            (0, "PVMFMP3FFParserNode::RetrieveTrackData() \
-							Unknown error reported by mp3ff %d", error));
-            ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aTrackPortInfo.iPort));
+            PVMFStatus errCode = PVMFErrArgument;
+            if (error == MP3_ERROR_UNKNOWN_OBJECT)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                (0, "PVMFMP3FFParserNode::RetrieveTrackData() \
+                                Clip format not identified by parser %d", error));
+                errCode = PVMFErrNotSupported;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE,
+                                (0, "PVMFMP3FFParserNode::RetrieveTrackData() \
+                                Unknown error code reported err code  %d", error));
+            }
             aTrackPortInfo.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
+            ReportErrorEvent(errCode);
             return false;
         }
     }
@@ -2176,14 +2239,14 @@
         // Output queue is busy, so wait for the output queue being ready
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                         (0, "PVMFMP3FFParserNode::SendBeginOfMediaStreamCommand: \
-						Outgoing queue busy. "));
+                        Outgoing queue busy. "));
         return false;
     }
     // BOS was sent successfully, reset the BOS flag
     aTrackPortInfoPtr.iSendBOS = false;
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                     (0, "PVMFMP3FFParserNode::SendBeginOfMediaStreamCommand: \
-					BOS Sent StreamID %d", iStreamID));
+                    BOS Sent StreamID %d", iStreamID));
     return true;
 }
 
@@ -2274,7 +2337,7 @@
     {
         SetState(EPVMFNodeError);
         ReportErrorEvent(PVMFErrResource);
-        return mp3Err;
+        return PVMFErrUnderflow;
     }
 
     // Find out what the largest frame in the file is. This information is used
@@ -2285,7 +2348,7 @@
         iMaxFrameSize = PVMP3FF_DEFAULT_MAX_FRAMESIZE;
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
                         (0, "PVMFMP3FFParserNode::ParseFile() Mp3FF \
-						MaxFrameSize %d", iMaxFrameSize));
+                        MaxFrameSize %d", iMaxFrameSize));
     }
 
     // get config Details from mp3ff
@@ -2295,7 +2358,7 @@
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
                         (0, "PVMFMP3FFParserNode::ParseFile() Mp3FF \
-						Config Not returned", iMaxFrameSize));
+                        Config Not returned", iMaxFrameSize));
 
     }
     else
@@ -2315,6 +2378,7 @@
     iTrack.iSeqNum = 0;
     iTrack.timestamp_offset = 0;
     iTrack.iSendBOS = false;
+    iTrack.iFirstFrame = false;
     iAutoPaused = false;
 }
 
@@ -2333,12 +2397,6 @@
         iTrack.iTrackDataMemoryPool = NULL;
     }
 
-    if (iTrack.iTrackDataMemoryPoolProxy != NULL)
-    {
-        OSCL_DELETE(iTrack.iTrackDataMemoryPoolProxy);
-        iTrack.iTrackDataMemoryPoolProxy = NULL;
-    }
-
     if (iTrack.iMediaDataImplAlloc != NULL)
     {
         OSCL_DELETE(iTrack.iMediaDataImplAlloc);
@@ -2347,7 +2405,8 @@
 
     if (iTrack.iMediaDataMemPool != NULL)
     {
-        OSCL_DELETE(iTrack.iMediaDataMemPool);
+        iTrack.iMediaDataMemPool->CancelFreeChunkAvailableCallback();
+        iTrack.iMediaDataMemPool->removeRef();
         iTrack.iMediaDataMemPool = NULL;
     }
 
@@ -2389,7 +2448,7 @@
     }
     iMP3ParserNodeMetadataValueCount = 0;
 
-    iUseCPMPluginRegistry = NULL;
+    iUseCPMPluginRegistry = false;
     iCPMSourceData.iFileHandle = NULL;
 
     if (iFileHandle)
@@ -2513,7 +2572,7 @@
         CleanupFileSource();
     }
 
-    if (aSourceFormat != PVMF_MP3FF)
+    if (aSourceFormat != PVMF_MIME_MP3FF)
     {
         // Node doesnt support any other format than MP3
         return PVMFFailure;
@@ -2594,13 +2653,13 @@
     return PVMFSuccess;
 }
 
-PVMFStatus PVMFMP3FFParserNode::SetClientPlayBackClock(OsclClock* aClientClock)
+PVMFStatus PVMFMP3FFParserNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
 }
 
-PVMFStatus PVMFMP3FFParserNode::SetEstimatedServerClock(OsclClock* aClientClock)
+PVMFStatus PVMFMP3FFParserNode::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
@@ -2730,6 +2789,7 @@
     {
         numvalentries = iMP3File->GetNumMetadataValues(aKeyList);
     }
+
     if (iCPMContainer.iCPMMetaDataExtensionInterface != NULL)
     {
         numvalentries +=
@@ -2808,7 +2868,7 @@
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                         (0, "PVMFMP3FFParserNode::ReleaseNodeMetadataValues() \
-					   MP3 file not parsed yet"));
+                       MP3 file not parsed yet"));
         return PVMFFailure;
     }
 
@@ -2818,15 +2878,16 @@
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                         (0, "PVMFMP3FFParserNode::ReleaseNodeMetadataValues() \
-						Invalid start/end index"));
+                        Invalid start/end index"));
         return PVMFErrArgument;
     }
 
-    // Go through the specified values and free it
-    for (uint32 i = start; i < end; i++)
-    {
-        iMP3File->ReleaseMetadataValue(aValueList[i]);
-    }
+    if (end >= aValueList.size())
+        // Go through the specified values and free it
+        for (uint32 i = start; i < end; i++)
+        {
+            iMP3File->ReleaseMetadataValue(aValueList[i]);
+        }
     return PVMFSuccess;
 }
 
@@ -2903,7 +2964,7 @@
  */
 PVMFCommandId PVMFMP3FFParserNode::SetDataSourceRate(PVMFSessionId aSessionId,
         int32 aRate,
-        OsclTimebase* aTimebase,
+        PVMFTimebase* aTimebase,
         OsclAny* aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2923,13 +2984,8 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFMP3FFParserNode::DoSetDataSourceRate() In"));
-    // Retrieve the new rate
-    int32 rate;
-    OsclTimebase* timebase = NULL;
-    aCmd.PVMFMP3FFParserNodeCommand::Parse(rate, timebase);
-    // This source node does not throttle the rate, so no restrictions are imposed by the source
+    OSCL_UNUSED_ARG(aCmd);
     return PVMFSuccess;
-
 }
 
 /**
@@ -2953,33 +3009,24 @@
                                            actualMediaDataTS, seektosyncpoint,
                                            streamID);
 
-    bool retVal = false;
-    // duplicate bos has been received, dont perform reposition at source node
-    if (iStreamID == streamID) retVal = true;
-
     iStreamID = streamID;
     iTrack.iSendBOS = true;
-
-    if (retVal)
-    {
-        RunIfNotReady();
-        return PVMFSuccess;
-    }
+    iTrack.iFirstFrame = true;
 
     if (iDownloadProgressClock.GetRep())
     {
         // Get the amount downloaded so far
         bool tmpbool = false;
         uint32 dltime = 0;
-        iDownloadProgressClock->GetCurrentTime32(dltime, tmpbool, OSCLCLOCK_MSEC);
+        iDownloadProgressClock->GetCurrentTime32(dltime, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
         // Check if the requested time is past the downloaded clip
         if (targetNPT >= dltime)
         {
             // For now, fail in this case. In future, we want to reposition to valid location.
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                             (0, "PVMFMP3FFParserNode::DoSetDataSourcePosition() \
-							Positioning past the amount downloaded so return as \
-							argument error"));
+                            Positioning past the amount downloaded so return as \
+                            argument error"));
             return PVMFErrArgument;
         }
     }
@@ -2994,18 +3041,28 @@
     {
         // report End of Stream on the track and reset the track to zero.
         iTrack.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
-        *actualNPT = iMP3File->SeekToTimestamp(0);
+        iMP3File->SeekToTimestamp(0);
+        *actualNPT = duration;
         iTrack.iClockConverter->set_clock_other_timescale(*actualMediaDataTS, COMMON_PLAYBACK_CLOCK_TIMESCALE);
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                         (0, "PVMFMP3FFParserNode::DoSetDataSourcePosition: targetNPT=%d, actualNPT=%d, actualMediaTS=%d",
                          targetNPT, *actualNPT, *actualMediaDataTS));
+        if (iAutoPaused)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP3FFParserNode::DoSetDataSourcePosition Track Autopaused"));
+            iAutoPaused = false;
+            if (iDownloadProgressInterface != NULL)
+            {
+                iDownloadProgressInterface->cancelResumeNotification();
+            }
+        }
         return PVMFSuccess;
     }
     // Seek to the next NPT
     // MP3 FF seeks to the beginning if the requested time is past the end of clip
     *actualNPT = iMP3File->SeekToTimestamp(targetNPT);
 
-    if (*actualNPT == duration)
+    if (duration > 0 && *actualNPT == duration)
     {
         // this means there was no data to render after the seek so just send End of Track
         iTrack.iClockConverter->set_clock_other_timescale(*actualMediaDataTS, COMMON_PLAYBACK_CLOCK_TIMESCALE);
@@ -3017,20 +3074,16 @@
     iTrack.timestamp_offset -= *actualNPT;
 
     // Reposition has occured, so reset the track state
-    if (iTrack.iState == PVMP3FFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK ||
-            iTrack.iState == PVMP3FFNodeTrackPortInfo::TRACKSTATE_DOWNLOAD_AUTOPAUSE)
+    if (iAutoPaused)
     {
-        if (iAutoPaused)
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP3FFParserNode::DoSetDataSourcePosition Track Autopaused"));
+        iAutoPaused = false;
+        if (iDownloadProgressInterface != NULL)
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP3FFParserNode::DoSetDataSourcePosition Track Autopaused"));
-            iAutoPaused = false;
-            if (iDownloadProgressInterface != NULL)
-            {
-                iDownloadProgressInterface->cancelResumeNotification();
-            }
+            iDownloadProgressInterface->cancelResumeNotification();
         }
-        iTrack.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
     }
+    iTrack.iState = PVMP3FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                     (0, "PVMFMP3FFParserNode::DoSetDataSourcePosition: targetNPT=%d, actualNPT=%d, actualMediaTS=%d",
@@ -3059,7 +3112,7 @@
         // Get the amount downloaded so far
         bool tmpbool = false;
         uint32 dltime = 0;
-        iDownloadProgressClock->GetCurrentTime32(dltime, tmpbool, OSCLCLOCK_MSEC);
+        iDownloadProgressClock->GetCurrentTime32(dltime, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
         // Check if the requested time is past clip dl
         if (targetNPT >= dltime)
         {
@@ -3069,6 +3122,12 @@
     // Determine the actual NPT without actually repositioning
     // MP3 FF goes to the beginning if the requested time is past the end of clip
     *actualNPT = targetNPT;
+    uint32 duration = iMP3File->GetDuration();
+    if (duration > 0 && targetNPT >= duration)
+    {
+        // return without any call on parser library.
+        return PVMFSuccess;
+    }
     iMP3File->SeekPointFromTimestamp(*actualNPT);
     return PVMFSuccess;
 }
@@ -3216,9 +3275,10 @@
 
 PVMFCommandId PVMFCPMContainerMp3::GetCPMLicenseInterface()
 {
+    iCPMLicenseInterfacePVI = NULL;
     return (iCPM->QueryInterface(iSessionId,
                                  PVMFCPMPluginLicenseInterfaceUuid,
-                                 OSCL_STATIC_CAST(PVInterface*&, iCPMLicenseInterface)));
+                                 iCPMLicenseInterfacePVI));
 }
 
 
@@ -3390,9 +3450,9 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFCPMContainerMp3::IssueCommand In"));
 
-    Assert(iCmdState == EIdle && iCancelCmdState == EIdle);
+    OSCL_ASSERT(iCmdState == EIdle && iCancelCmdState == EIdle);
     // Find the current node command since we may need its parameters.
-    Assert(!iContainer->iCurrentCommand.empty());
+    OSCL_ASSERT(!iContainer->iCurrentCommand.empty());
     PVMFMP3FFParserNodeCommand* nodeCmd = &iContainer->iCurrentCommand.front();
 
     //save the sub-node command code
@@ -3410,8 +3470,8 @@
             //make sure any prior instance is cleaned up
             Cleanup();
             //Create a CPM instance.
-            Assert(iCPM == NULL);
-            Assert(iContainer->iUseCPMPluginRegistry == true);
+            OSCL_ASSERT(iCPM == NULL);
+            OSCL_ASSERT(iContainer->iUseCPMPluginRegistry == true);
             iCPM = PVMFCPMFactory::CreateContentPolicyManager(*this);
             if (!iCPM)
             {
@@ -3426,7 +3486,7 @@
             return PVMFPending;
 
         case ECPMOpenSession:
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling OpenSession"));
             iCmdState = EBusy;
@@ -3434,7 +3494,7 @@
             return PVMFPending;
 
         case ECPMRegisterContent:
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling RegisterContent"));
             iCmdState = EBusy;
@@ -3445,7 +3505,7 @@
             return PVMFPending;
 
         case ECPMGetLicenseInterface:
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling GetCPMLicenseInterface"));
             iCmdState = EBusy;
@@ -3454,7 +3514,7 @@
 
         case ECPMGetLicenseW:
         {
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling ECPMGetLicenseW"));
             iCmdState = EBusy;
@@ -3462,6 +3522,8 @@
             OsclAny* data = NULL;
             uint32 dataSize = 0;
             int32 timeoutMsec = 0;
+            iCPMLicenseInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, iCPMLicenseInterfacePVI);
+            iCPMLicenseInterfacePVI = NULL;
             nodeCmd->Parse(contentName,
                            data,
                            dataSize,
@@ -3476,7 +3538,7 @@
         }
         case ECPMGetLicense:
         {
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling ECPMGetLicense"));
 
@@ -3485,6 +3547,8 @@
             OsclAny* data = NULL;
             uint32 dataSize = 0;
             int32 timeoutMsec = 0;
+            iCPMLicenseInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, iCPMLicenseInterfacePVI);
+            iCPMLicenseInterfacePVI = NULL;
             nodeCmd->Parse(contentName,
                            data,
                            dataSize,
@@ -3500,7 +3564,7 @@
         }
         case ECPMApproveUsage:
         {
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             GetCPMMetaDataExtensionInterface();
             iCPMContentType = iCPM->GetCPMContentType(iSessionId);
             if ((iCPMContentType == PVMF_CPM_FORMAT_OMA1) ||
@@ -3537,17 +3601,16 @@
             {
                 /* Unsupported format - use it as unprotected content */
                 PVMFStatus status = iContainer->CheckForMP3HeaderAvailability();
-                if (status == PVMFSuccess)
-                {
-                    iContainer->CompleteInit(status);
-                }
+                return status;
+
             }
             return PVMFSuccess;
         }
 
         case ECPMCheckUsage:
+        {
             iContainer->oWaitingOnLicense = false;
-            PVMFStatus status;
+            PVMFStatus status = PVMFFailure;
             //Check for usage approval, and if approved, parse the file.
             if ((iCPMContentType == PVMF_CPM_FORMAT_OMA1) ||
                     (iCPMContentType == PVMF_CPM_FORMAT_AUTHORIZE_BEFORE_ACCESS))
@@ -3561,22 +3624,19 @@
                 {
                     return PVMFFailure;//unexpected, since ApproveUsage succeeded.
                 }
+                status = iContainer->CheckForMP3HeaderAvailability();
+                return status;
             }
-            if (status == PVMFSuccess)
-            {
-                if (PVMFSuccess == iContainer->CheckForMP3HeaderAvailability())
-                {
-                    iContainer->CompleteInit(status);
-                }
-            }
+
             return status;
+        }
 
 
         case ECPMUsageComplete:
             if ((iCPMContentType == PVMF_CPM_FORMAT_OMA1) ||
                     (iCPMContentType == PVMF_CPM_FORMAT_AUTHORIZE_BEFORE_ACCESS))
             {
-                Assert(iCPM != NULL);
+                OSCL_ASSERT(iCPM != NULL);
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                                 (0, "PVMFCPMContainerMp3::IssueCommand Calling UsageComplete"));
 
@@ -3584,25 +3644,26 @@
                 iCmdId = iCPM->UsageComplete(iSessionId, iUsageID);
                 return PVMFPending;
             }
-            return PVMFSuccess;
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling UsageComplete"));
+            return PVMFSuccess;
+
         case ECPMCloseSession:
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling CloseSession"));
             iCmdState = EBusy;
             iCmdId = iCPM->CloseSession(iSessionId);
             return PVMFPending;
         case ECPMReset:
-            Assert(iCPM != NULL);
+            OSCL_ASSERT(iCPM != NULL);
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iContainer->iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFCPMContainerMp3::IssueCommand Calling Reset"));
             iCmdState = EBusy;
             iCmdId = iCPM->Reset();
             return PVMFPending;
         default:
-            Assert(false);
+            OSCL_ASSERT(false);
             return PVMFFailure;
     }
 }
@@ -3712,15 +3773,7 @@
     }
     else
     {
-        Assert(false);//unexpected response
-    }
-}
-
-void PVMFSubNodeContainerBaseMp3::Assert(bool aCondition)
-{
-    if (!aCondition)
-    {
-        iContainer->Assert(aCondition);
+        OSCL_ASSERT(false);//unexpected response
     }
 }
 
@@ -3728,9 +3781,9 @@
         OsclAny*aEventData)
 {
     // Sub-node command is completed, process the result.
-    Assert(aStatus != PVMFPending);
+    OSCL_ASSERT(aStatus != PVMFPending);
     // Pop the sub-node command vector.
-    Assert(!iContainer->iSubNodeCmdVec.empty());
+    OSCL_ASSERT(!iContainer->iSubNodeCmdVec.empty());
     iContainer->iSubNodeCmdVec.erase(&iContainer->iSubNodeCmdVec.front());
 
     iCmdState = EIdle;
@@ -3759,7 +3812,7 @@
     else
     {
         //node command is done.
-        Assert(!iContainer->iCurrentCommand.empty());
+        OSCL_ASSERT(!iContainer->iCurrentCommand.empty());
         iContainer->CommandComplete(iContainer->iCurrentCommand, iContainer->iCurrentCommand.front(), status, aExtMsg, aEventData);
     }
 }
@@ -3770,7 +3823,7 @@
     OSCL_UNUSED_ARG(aExtMsg);
     OSCL_UNUSED_ARG(aEventData);
 
-    Assert(aStatus != PVMFPending);
+    OSCL_ASSERT(aStatus != PVMFPending);
     iCancelCmdState = EIdle;
     //print and ignore any failed sub-node cancel commands.
     if (aStatus != PVMFSuccess)
@@ -3780,7 +3833,7 @@
     }
 
     //Node cancel command is now done.
-    Assert(!iContainer->iCancelCommand.empty());
+    OSCL_ASSERT(!iContainer->iCancelCommand.empty());
     iContainer->CommandComplete(iContainer->iCancelCommand, iContainer->iCancelCommand.front(), aStatus, NULL, NULL);
 }
 
@@ -3800,7 +3853,6 @@
             {
                 // set flag
                 iCheckForMP3HeaderDuringInit = true;
-
                 // Re-schedule the node
                 RunIfNotReady();
             }
@@ -3878,9 +3930,6 @@
          * First check if we have minimum number of bytes to recognize
          * the file and determine the header size.
          */
-        uint32 contentLength =  iDataStreamInterface->GetContentLength();
-        minBytesRequired = (minBytesRequired > contentLength) ? contentLength : minBytesRequired;
-
         uint32 currCapacity = 0;
         PvmiDataStreamStatus status = iDataStreamInterface->QueryReadCapacity(iDataStreamSessionID,
                                       currCapacity);
@@ -3902,7 +3951,7 @@
             {
                 /* Fetch the id3 tag size, if any and make it persistent in cache*/
                 iDataStreamInterface->MakePersistent(0, iMP3MetaDataSize);
-                if (currCapacity < (uint32)iMP3MetaDataSize)
+                if (currCapacity < iMP3MetaDataSize)
                 {
                     iRequestReadCapacityNotificationID =
                         iDataStreamInterface->RequestReadCapacityNotification(iDataStreamSessionID,
@@ -3917,11 +3966,8 @@
             }
         }
     }
-    if (PVMFSuccess != ParseFile())
-    {
-        return PVMFFailure;
-    }
-    return PVMFSuccess;
+    PVMFStatus status = ParseFile();
+    return status;
 }
 
 void PVMFMP3FFParserNode::GetCPMMetaDataKeys()
@@ -3939,9 +3985,10 @@
 
 bool PVMFCPMContainerMp3::GetCPMMetaDataExtensionInterface()
 {
+    PVInterface* temp = NULL;
     bool retVal =
-        iCPM->queryInterface(KPVMFMetadataExtensionUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMMetaDataExtensionInterface));
+        iCPM->queryInterface(KPVMFMetadataExtensionUuid, temp);
+    iCPMMetaDataExtensionInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, temp);
     return retVal;
 }
 PVMp3DurationCalculator::PVMp3DurationCalculator(int32 aPriority, IMpeg3File* aMP3File, PVMFNodeInterface* aNode, bool aScanEnabled):
@@ -4026,3 +4073,22 @@
         iErrorCode = iMP3File->ScanMP3File(PVMF3FF_DEFAULT_NUM_OF_FRAMES * 5);
     }
 }
+
+PVMFStatus PVMFMP3FFParserNode::CreateMP3FileObject(MP3ErrorType &aSuccess, PVMFCPMPluginAccessInterfaceFactory*aCPM)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, iMP3File = OSCL_NEW(IMpeg3File,
+                                            (iSourceURL, aSuccess,
+                                             &iFileServer, aCPM,
+                                             iFileHandle, false)));
+    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFMP3FFParserNode::PushBackCPMMetadataKeys(PVMFMetadataList *&aKeyListPtr, uint32 aLcv)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aKeyListPtr->push_back(iCPMMetadataKeys[aLcv]));
+    OSCL_FIRST_CATCH_ANY(leavecode, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP3FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));return PVMFErrNoMemory);
+    return PVMFSuccess;
+}
diff --git a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.h b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.h
index 00e7a3d..e668313 100644
--- a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.h
+++ b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,8 +47,8 @@
 #include "pvmf_media_data.h"
 #endif
 
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
+#ifndef PVMF_RESIZABLE_SIMPLE_MEDIAMSG_H_INCLUDED
+#include "pvmf_resizable_simple_mediamsg.h"
 #endif
 
 #ifndef PVMF_FFPARSERNODE_PORT_H_INCLUDED
@@ -164,7 +164,6 @@
             iType = n;
             iContainer = c;
         }
-        void Assert(bool);
 
         virtual void Cleanup() = 0;
         virtual PVMFStatus IssueCommand(int32) = 0;
@@ -236,6 +235,7 @@
         PvmiKvp iAuthorizationDataKvp;
         PVMFCPMUsageID iUsageID;
         PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
+        PVInterface* iCPMLicenseInterfacePVI;
         PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
 
         PVMFStatus CreateUsageKeys();
@@ -245,45 +245,6 @@
 };
 
 
-// Allocator wrapper for the memory pool that saves the last block pointer allocated
-// so it can be resized later
-class TrackDataMemPoolProxyAlloc : public Oscl_DefAlloc
-{
-    public:
-        TrackDataMemPoolProxyAlloc(OsclMemPoolResizableAllocator& aMemPool)
-        {
-            iMemPoolAllocPtr = &aMemPool;
-            iLastAllocatedBlockPtr = NULL;
-        }
-
-        virtual ~TrackDataMemPoolProxyAlloc()
-        {
-        }
-
-        OsclAny* allocate(const uint32 size)
-        {
-            OSCL_ASSERT(iMemPoolAllocPtr);
-            iLastAllocatedBlockPtr = iMemPoolAllocPtr->allocate(size);
-            return iLastAllocatedBlockPtr;
-        }
-
-        void deallocate(OsclAny* p)
-        {
-            OSCL_ASSERT(iMemPoolAllocPtr);
-            iMemPoolAllocPtr->deallocate(p);
-        }
-
-        bool trim(uint32 aBytesToFree)
-        {
-            OSCL_ASSERT(iMemPoolAllocPtr);
-            OSCL_ASSERT(iLastAllocatedBlockPtr);
-            return iMemPoolAllocPtr->trim(iLastAllocatedBlockPtr, aBytesToFree);
-        }
-
-        OsclMemPoolResizableAllocator* iMemPoolAllocPtr;
-        OsclAny* iLastAllocatedBlockPtr;
-}; // end class TrackDataMemPoolProxyAlloc
-
 class PVMP3FFNodeTrackPortInfo
 {
     public:
@@ -311,12 +272,12 @@
             iPort = NULL;
             iState = TRACKSTATE_UNINITIALIZED;
             iTrackDataMemoryPool = NULL;
-            iTrackDataMemoryPoolProxy = NULL;
             iMediaDataImplAlloc = NULL;
             iMediaDataMemPool = NULL;
             timestamp_offset = 0;
             iSeqNum = 0;
             iSendBOS = false;
+            iFirstFrame = false;
         }
 
         PVMP3FFNodeTrackPortInfo(const PVMP3FFNodeTrackPortInfo& aSrc)
@@ -326,12 +287,12 @@
             iMediaData = aSrc.iMediaData;
             iState = aSrc.iState;
             iTrackDataMemoryPool = aSrc.iTrackDataMemoryPool;
-            iTrackDataMemoryPoolProxy = aSrc.iTrackDataMemoryPoolProxy;
             iMediaDataImplAlloc = aSrc.iMediaDataImplAlloc;
             iMediaDataMemPool = aSrc.iMediaDataMemPool;
             timestamp_offset = aSrc.timestamp_offset;
             iSeqNum = aSrc.iSeqNum;
             iSendBOS = aSrc.iSendBOS;
+            iFirstFrame = aSrc.iFirstFrame;
         }
 
         ~PVMP3FFNodeTrackPortInfo()
@@ -350,11 +311,8 @@
         // Output buffer memory pool
         OsclMemPoolResizableAllocator *iTrackDataMemoryPool;
 
-        // Allocator wrapper for the output buffer memory pool
-        TrackDataMemPoolProxyAlloc* iTrackDataMemoryPoolProxy;
-
         // Allocator for simple media data buffer impl
-        PVMFSimpleMediaBufferCombinedAlloc *iMediaDataImplAlloc;
+        PVMFResizableSimpleMediaMsgAlloc *iMediaDataImplAlloc;
 
         // Memory pool for simple media data
         PVMFMemPoolFixedChunkAllocator *iMediaDataMemPool;
@@ -365,12 +323,14 @@
 
         PVMFFormatType iFormatType;
         uint32 iBitrate;
-        uint32 timestamp_offset;
+        int32 timestamp_offset;
 
         // Sequence number
         uint32 iSeqNum;
         //bos flag
         bool iSendBOS;
+        // Random access point idenfier
+        bool iFirstFrame;
 };  // end class PVMP3FFNodeTrackPortInfo
 
 //Forward Declarations
@@ -448,8 +408,8 @@
         bool queryInterface(const PVUuid& uuid, PVInterface *& iface);
 
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         //From PVMFTrackSelectionExtensionInterface
         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
@@ -489,7 +449,7 @@
 
         virtual PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId,
                                                 int32 aRate,
-                                                OsclTimebase* aTimebase = NULL,
+                                                PVMFTimebase* aTimebase = NULL,
                                                 OsclAny* aContext = NULL);
 
         /* From PVMFFormatProgDownloadSupportInterface */
@@ -619,6 +579,8 @@
         void DataStreamCommandCompleted(const PVMFCmdResp& aResponse);
         void DataStreamInformationalEvent(const PVMFAsyncEvent& aEvent);
         void DataStreamErrorEvent(const PVMFAsyncEvent& aEvent);
+        PVMFStatus CreateMP3FileObject(MP3ErrorType &aSuccess, PVMFCPMPluginAccessInterfaceFactory*aCPM);
+        PVMFStatus PushBackCPMMetadataKeys(PVMFMetadataList *&aKeyListPtr, uint32 aLcv);
 
     protected:
         void Push(PVMFSubNodeContainerBaseMp3&, PVMFSubNodeContainerBaseMp3::CmdType);
@@ -669,12 +631,12 @@
 
         /* These vars are used for the prog. download to auto pause*/
         static const uint32 iTIMESTAMPDELTA;
-        OsclSharedPtr<OsclClock> iDownloadProgressClock;
+        OsclSharedPtr<PVMFMediaClock> iDownloadProgressClock;
         PVMFDownloadProgressInterface* iDownloadProgressInterface;
         bool iAutoPaused;
         bool iDownloadComplete;
         PvmiDataStreamCommandId iRequestReadCapacityNotificationID;
-        int32 iMP3MetaDataSize;
+        uint32 iMP3MetaDataSize;
 
         // Data Stream vars
         PVMIDataStreamSyncInterface* iDataStreamInterface;
@@ -699,7 +661,6 @@
         };
         Oscl_Vector<SubNodeCmd, OsclMemAllocator> iSubNodeCmdVec;
 
-        void Assert(bool);
         PVMFStatus DoGetLicense(PVMFMP3FFParserNodeCommand& aCmd,
                                 bool aWideCharVersion = false);
         PVMFStatus DoCancelGetLicense(PVMFMP3FFParserNodeCommand& aCmd);
diff --git a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node_internal.h b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node_internal.h
index 650a3b9..55a2e99 100644
--- a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node_internal.h
+++ b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_node_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,8 +34,8 @@
 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
 #include "pvmf_meta_data_extension.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 
@@ -107,7 +107,7 @@
         }
 
         // Constructor and parser for SetDataSourceRate
-        void Construct(PVMFSessionId aSessionId, int32 cmd, int32 aRate, OsclTimebase* aTimebase, const OsclAny* aContext)
+        void Construct(PVMFSessionId aSessionId, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny* aContext)
         {
             PVMFMP3FFParserNodeCommandBase::Construct(aSessionId, cmd, aContext);
             iParam1 = (OsclAny*)aRate;
@@ -116,10 +116,10 @@
             iParam4 = NULL;
             iParam5 = NULL;
         }
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
         {
             aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
+            aTimebase = (PVMFTimebase*)iParam2;
         }
 
         // Constructor and parser for GetNodeMetadataKeys
diff --git a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.cpp b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.cpp
index 20e4b12..8facf0d 100644
--- a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.cpp
+++ b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,11 +28,18 @@
 #ifndef PVMF_MP3FFPARSER_DEFS_H_INCLUDED
 #include "pvmf_mp3ffparser_defs.h"
 #endif
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+#ifndef PVMF_MP3FFPARSER_NODE_H_INCLUDED
+#include "pvmf_mp3ffparser_node.h"
+#endif
 
 ////////////////////////////////////////////////////////////////////////////
 PVMFMP3FFParserPort::PVMFMP3FFParserPort(int32 aTag, PVMFNodeInterface* aNode)
         : PvmfPortBaseImpl(aTag, aNode, "Mp3ParOut(Audio)")
 {
+    iMP3ParserNode = OSCL_STATIC_CAST(PVMFMP3FFParserNode*, aNode);
     Construct();
 }
 
@@ -53,6 +60,7 @@
                            aOutThreshold,
                            "Mp3ParOut(Audio)")
 {
+    iMP3ParserNode = OSCL_STATIC_CAST(PVMFMP3FFParserNode*, aNode);
     Construct();
 }
 
@@ -78,14 +86,175 @@
 ////////////////////////////////////////////////////////////////////////////
 bool PVMFMP3FFParserPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return (aFmt == PVMF_MP3);
+    bool formatSupported = false;
+    if (aFmt == PVMF_MIME_MP3)
+    {
+        formatSupported = true;
+    }
+    return formatSupported;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PVMFMP3FFParserPort::FormatUpdated()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO,
-                    (0, "PVMFMP3FFParserPort::FormatUpdated %d", iFormat));
+    return;
 }
 
+PVMFStatus PVMFMP3FFParserPort::Connect(PVMFPortInterface* aPort)
+{
+    PVMF_MP3FPARSERNODE_LOGINFO((0, "PVMFMP3FFParserPort::Connect: aPort=0x%x", aPort));
 
+    if (!aPort)
+    {
+        PVMF_MP3FPARSERNODE_LOGERROR((0, "PVMFMP3FFParserPort::Connect: Error - Connecting to invalid port"));
+        return PVMFErrArgument;
+    }
+
+    if (iConnectedPort)
+    {
+        PVMF_MP3FPARSERNODE_LOGERROR((0, "PVMFMP3FFParserPort::Connect: Error - Already connected"));
+        return PVMFFailure;
+    }
+
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
+    if (config != NULL)
+    {
+        if (!(pvmiSetPortFormatSpecificInfoSync(config, PVMF_FORMAT_SPECIFIC_INFO_KEY)))
+        {
+            PVMF_MP3FPARSERNODE_LOGERROR((0, "PVMFMP3FFParserPort::Connect: Error - Unable To Send Format Specific Info To Peer"));
+            return PVMFFailure;
+        }
+    }
+
+    /*
+     * Automatically connect the peer.
+     */
+    if (aPort->PeerConnect(this) != PVMFSuccess)
+    {
+        PVMF_MP3FPARSERNODE_LOGERROR((0, "PVMFMP3FFParserPort::Connect: Error - Peer Connect failed"));
+        return PVMFFailure;
+    }
+
+    iConnectedPort = aPort;
+
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+bool
+PVMFMP3FFParserPort::pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort,
+        const char* aFormatValType)
+{
+    /*
+     * Create PvmiKvp for capability settings
+     */
+    if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        OsclMemAllocator alloc;
+        PvmiKvp kvp;
+        kvp.key = NULL;
+        int32 KeyLenth = oscl_strlen(aFormatValType) + 1; // +1 for \0
+        kvp.key = (PvmiKeyType)alloc.ALLOCATE(KeyLenth);
+        if (kvp.key == NULL)
+        {
+            return false;
+        }
+        oscl_strncpy(kvp.key, aFormatValType, KeyLenth);
+        if (iMP3ParserNode->iDecodeFormatSpecificInfo.getMemFragSize() == 0)
+        {
+            kvp.value.key_specific_value = 0;
+            kvp.length = kvp.capacity = 0;
+        }
+        else
+        {
+            kvp.value.key_specific_value = (OsclAny*)(iMP3ParserNode->iDecodeFormatSpecificInfo.getMemFragPtr());
+            kvp.length = kvp.capacity = iMP3ParserNode->iDecodeFormatSpecificInfo.getMemFragSize();
+        }
+        PvmiKvp* retKvp = NULL; // for return value
+        int32 err;
+        OSCL_TRY(err, aPort->setParametersSync(NULL, &kvp, 1, retKvp););
+        /* ignore the error for now */
+        alloc.deallocate((OsclAny*)(kvp.key));
+        return true;
+    }
+    return false;
+}
+
+bool
+PVMFMP3FFParserPort::pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType,
+        PvmiKvp*& aKvp)
+{
+    /*
+     * Create PvmiKvp for capability settings
+     */
+    if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        OsclMemAllocator alloc;
+        aKvp->key = NULL;
+        int32 KeyLenth = oscl_strlen(aFormatValType) + 1; // +1 for \0
+        aKvp->key = (PvmiKeyType)alloc.ALLOCATE(KeyLenth);
+        if (aKvp->key == NULL)
+        {
+            return false;
+        }
+        oscl_strncpy(aKvp->key, aFormatValType, KeyLenth);
+        if (iMP3ParserNode->iDecodeFormatSpecificInfo.getMemFragSize() == 0)
+        {
+            aKvp->value.key_specific_value = 0;
+            aKvp->length = aKvp->capacity = 0;
+        }
+        else
+        {
+            aKvp->value.key_specific_value = (OsclAny*)(iMP3ParserNode->iDecodeFormatSpecificInfo.getMemFragPtr());
+            aKvp->length = aKvp->capacity = iMP3ParserNode->iDecodeFormatSpecificInfo.getMemFragSize();
+        }
+        return true;
+    }
+    return false;
+}
+
+PVMFStatus PVMFMP3FFParserPort::getParametersSync(PvmiMIOSession aSession,
+        PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    PVMF_MP3FPARSERNODE_LOGINFO((0, "PVMFMP3FFParserPort::getParametersSync: aSession=0x%x, aIdentifier=%s, aParameters=0x%x, num_parameters_elements=%d, aContext=0x%x",
+                                 aSession, aIdentifier, aParameters, num_parameter_elements, aContext));
+
+    num_parameter_elements = 0;
+
+    if (pv_mime_strcmp(aIdentifier, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        if (!pvmiGetPortFormatSpecificInfoSync(PVMF_FORMAT_SPECIFIC_INFO_KEY, aParameters))
+        {
+            return PVMFFailure;
+        }
+    }
+
+    num_parameter_elements = 1;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFMP3FFParserPort::releaseParameters(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(num_elements);
+
+    PVMF_MP3FPARSERNODE_LOGINFO((0, "PVMFMP3FFParserPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
+                                 aSession, aParameters, num_elements));
+
+    if (pv_mime_strcmp(aParameters->key, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        OsclMemAllocator alloc;
+        alloc.deallocate((OsclAny*)(aParameters->key));
+    }
+    return PVMFSuccess;
+}
diff --git a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.h b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.h
index 0139b97..fa1af59 100644
--- a/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.h
+++ b/nodes/pvmp3ffparsernode/src/pvmf_mp3ffparser_outport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,11 @@
 //Default vector reserve size
 #define PVMF_MP3FFPARSER_NODE_PORT_VECTOR_RESERVE 10
 
+#define PVMF_MP3FPARSERNODE_LOGINFO(m)  PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_INFO,m);
+#define PVMF_MP3FPARSERNODE_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+
+class PVMFMP3FFParserNode;
+
 /**
  * An example of a PVMF port implementation.
  *
@@ -99,12 +104,81 @@
                 aPtr = NULL;
         }
 
+        /* Over ride Connect() */
+        PVMFStatus Connect(PVMFPortInterface* aPort);
+
+        /* Implement pure virtuals from PvmiCapabilityAndConfig interface */
+        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                                     PvmiKvp*& aParameters, int& num_parameter_elements,	PvmiCapabilityContext aContext);
+        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        /* Unsupported PvmiCapabilityAndConfig methods */
+        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                               int num_elements, PvmiKvp * & aRet_kvp)
+        {
+            OSCL_UNUSED_ARG(aSession);
+            OSCL_UNUSED_ARG(aParameters);
+            OSCL_UNUSED_ARG(aRet_kvp);
+            OSCL_UNUSED_ARG(num_elements);
+        }
+        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+        {
+            OSCL_UNUSED_ARG(aSession);
+            OSCL_UNUSED_ARG(aParameters);
+            OSCL_UNUSED_ARG(num_elements);
+            return PVMFErrNotSupported;
+        }
+        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+        {
+            OSCL_UNUSED_ARG(aObserver);
+        };
+        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+        {
+            OSCL_UNUSED_ARG(aSession);
+            OSCL_UNUSED_ARG(aContext);
+        };
+        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                                  PvmiKvp* aParameters, int num_parameter_elements)
+        {
+            OSCL_UNUSED_ARG(aSession);
+            OSCL_UNUSED_ARG(aContext);
+            OSCL_UNUSED_ARG(aParameters);
+            OSCL_UNUSED_ARG(num_parameter_elements);
+        };
+        void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+        {
+            OSCL_UNUSED_ARG(aSession);
+            OSCL_UNUSED_ARG(aContext);
+        };
+        PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                         int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL)
+        {
+            OSCL_UNUSED_ARG(aRet_kvp);
+            OSCL_UNUSED_ARG(aSession);
+            OSCL_UNUSED_ARG(aParameters);
+            OSCL_UNUSED_ARG(num_elements);
+            OSCL_UNUSED_ARG(context);
+            return -1;
+        }
+        uint32 getCapabilityMetric(PvmiMIOSession aSession)
+        {
+            OSCL_UNUSED_ARG(aSession);
+            return 0;
+        }
+
     private:
         void Construct();
 
+        bool pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort,
+                                               const char* aFormatValType);
+
+        bool pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType,
+                                               PvmiKvp*& aKvp);
+
         PVLogger *iLogger;
         uint32 iNumFramesGenerated; //number of source frames generated.
 
+        PVMFMP3FFParserNode * iMP3ParserNode;
         friend class PVMFMP3FFParserNode;
 };
 
diff --git a/nodes/pvmp4ffcomposernode/Android.mk b/nodes/pvmp4ffcomposernode/Android.mk
index 70321d3..1c4571b 100644
--- a/nodes/pvmp4ffcomposernode/Android.mk
+++ b/nodes/pvmp4ffcomposernode/Android.mk
@@ -3,39 +3,41 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmp4ffcn_port.cpp \
-	src/pvmp4ffcn_node.cpp \
-	src/pvmp4ffcn_node_cap_config.cpp
-
+ 	src/pvmp4ffcn_node.cpp \
+ 	src/pvmp4ffcn_node_cap_config.cpp
 
 
 LOCAL_MODULE := libpvmp4ffcomposernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)/fileformats/mp4/composer/include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/src \
-	$(PV_TOP)/$(SDK_LOCAL)/installed_include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/src \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../nodes/common/include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../baselibs/pv_mime_utils/src \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../engines/author/include \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../baselibs/media_data_structures/src \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../oscl/oscl/osclio/src \
-	$(PV_TOP)//nodes/pvmp4ffcomposernode/../../fileformats/mp4/composer/config/opencore \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvmp4ffcomposernode/src \
+ 	$(PV_TOP)/nodes/pvmp4ffcomposernode/include \
+ 	/installed_include \
+ 	$(PV_TOP)/nodes/pvmp4ffcomposernode/src \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/nodes/pvmp4ffcomposernode/include \
+ 	$(PV_TOP)/baselibs/pv_mime_utils/src \
+ 	$(PV_TOP)/engines/author/include \
+ 	$(PV_TOP)/baselibs/media_data_structures/src \
+ 	$(PV_TOP)/oscl/oscl/osclio/src \
+ 	$(PV_TOP)/fileformats/mp4/composer/config/opencore \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmp4ffcn_clipconfig.h \
-	include/pvmp4ffcn_factory.h \
-	include/pvmp4ffcn_trackconfig.h \
-	include/pvmp4ffcn_types.h
+ 	include/pvmp4ffcn_factory.h \
+ 	include/pvmp4ffcn_trackconfig.h \
+ 	include/pvmp4ffcn_types.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvmp4ffcomposernode/build_opencore/make/local.mk b/nodes/pvmp4ffcomposernode/build_opencore/make/local.mk
new file mode 100644
index 0000000..e218727
--- /dev/null
+++ b/nodes/pvmp4ffcomposernode/build_opencore/make/local.mk
@@ -0,0 +1,25 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4ffcomposernode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += $(SDK_LOCAL)/installed_include ../../src ../../../../nodes/common/include ../../../../pvmi/pvmf/include  ../../include  ../../../../baselibs/pv_mime_utils/src  ../../../../engines/author/include  ../../../../baselibs/media_data_structures/src  ../../../../oscl/oscl/osclio/src  ../../../../fileformats/mp4/composer/config/opencore
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmp4ffcn_port.cpp pvmp4ffcn_node.cpp pvmp4ffcn_node_cap_config.cpp
+
+HDRS := pvmp4ffcn_clipconfig.h pvmp4ffcn_factory.h pvmp4ffcn_trackconfig.h pvmp4ffcn_types.h 
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvmp4ffcomposernode/build_opencore/make/makefile b/nodes/pvmp4ffcomposernode/build_opencore/make/makefile
deleted file mode 100644
index 52e5a55..0000000
--- a/nodes/pvmp4ffcomposernode/build_opencore/make/makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4ffcomposernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this path so that correct headers should be picked up for author
-XINCDIRS += -I$(SDK_LOCAL)/installed_include -I../../src -I../../../../nodes/common/include -I../../../../pvmi/pvmf/include -I ../../include -I ../../../../baselibs/pv_mime_utils/src -I ../../../../engines/author/include -I ../../../../baselibs/media_data_structures/src -I ../../../../oscl/oscl/osclio/src -I ../../../../fileformats/mp4/composer/config/opencore
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmp4ffcn_port.cpp pvmp4ffcn_node.cpp pvmp4ffcn_node_cap_config.cpp
-
-HDRS =  pvmp4ffcn_clipconfig.h pvmp4ffcn_factory.h pvmp4ffcn_trackconfig.h pvmp4ffcn_types.h 
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_clipconfig.h b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_clipconfig.h
index a32a3f6..eb4b4b3 100644
--- a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_clipconfig.h
+++ b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_clipconfig.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,19 +42,14 @@
 #include "pv_mp4ffcomposer_config.h"
 #endif
 
+
+#ifndef PVMI_KVP_H_INCLUDED
+#include "pvmi_kvp.h"
+#endif
 #define KPVMp4FFCNClipConfigUuid PVUuid(0x2e3b479f,0x2c46,0x465c,0xba,0x41,0xb8,0x91,0x11,0xa9,0xdf,0x3a)
 
 typedef enum
 {
-    /**
-     * This mode authors non Progressive Downloadable output files using temp files
-     * during authoring:
-     * Meta data towards the end of the clip
-     * Media data is not interleaved. Temp files are used.
-     * Media data is authored in separate media atoms for each track
-     * Temporary files are written to the same directory as the output file.
-     */
-    PVMP4FFCN_PV_FAST_TRACK_CONTENT_MODE = 0x00000000,
 
     /**
      * This mode authors 3GPP Progressive Downloadable output files:
@@ -73,6 +68,23 @@
     PVMP4FFCN_3GPP_DOWNLOAD_MODE = 0x00000009,
 
 
+    /**
+     * This mode authors I-Motion compliant output files:
+     * Meta Data is upfront.
+     * Media Data is interleaved. Temp files are used.
+     * Imotion DRM and Udta atoms are authored
+     * Temporary files are written to the same directory as the output file.
+     */
+    PVMP4FFCN_IMOTION_PSEUDO_STREAMING_MODE = 0x00000007,
+
+    /**
+     * This mode authors I-Motion compliant output files:
+     * Meta Data is towards the end of the file.
+     * Media Data is interleaved.
+     * Imotion DRM and Udta atoms are authored
+     * NoTemp files are used.
+     */
+    PVMP4FFCN_IMOTION_DOWNLOAD_MODE = 0x0000000D,
 
     /**
      * This mode authors movie fragment files:
@@ -85,39 +97,6 @@
 
 } PVMp4FFCN_AuthoringMode;
 
-#ifdef XXXX
-
-
-typedef enum
-{
-    /**
-     * This mode authors non Progressive Downloadable output files using temp files
-     * during authoring:
-     * Meta data towards the end of the clip
-     * Media data is not interleaved. Temp files are used.
-     * Media data is authored in separate media atoms for each track
-     * Temporary files are written to the same directory as the output file.
-     */
-    PVMP4FFCN_NON_3GPP_PROGRESSIVE_DOWNLOADABLE_WITH_TEMP_FILES = 0x00000000,
-
-    /**
-     * This mode authors 3GPP Progressive Downloadable output files:
-     * Meta Data is upfront.
-     * Media Data is interleaved. Temp files are used.
-     * Temporary files are written to the same directory as the output file.
-     */
-    PVMF4FFCN_3GPP_PROGRESSIVE_DOWNLOADABLE = 0x00000003,
-
-
-    /**
-     * This mode authors non Progressive Downloadable output files without using
-     * temp files during authoring:
-     * Meta data towards the end of the clip
-     * Media data is interleaved. No temp files are used.
-     */
-    PVMP4FFCN_NON_3GPP_PROGRESSIVE_DOWNLOADABLE_NO_TEMP_FILES = 0x00000009
-} PVMp4FFCN_AuthoringMode;
-#endif
 /**
  * PVMp4FFCNClipConfigInterface allows a client to control properties of PVMp4FFComposerNode
  */
@@ -180,10 +159,10 @@
         /* This is an optional configuration API that should be called before Start() is called.
          *
          * @param aVersion   version string.
-         * @param aLangCode  16 bit ISO-639-2/T Language code
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetVersion(const OSCL_wString& aVersion, uint16 aLangCode = 0) = 0;
+        virtual PVMFStatus SetVersion(const OSCL_wString& aVersion, const OSCL_String& aLangCode) = 0;
 
         /**
          * This method populates the title string. Title string contains
@@ -194,10 +173,10 @@
         /* This is an optional configuration API that should be called before Start() is called.
          *
          * @param aTitle   title string.
-         * @param aLangCode  16 bit ISO-639-2/T Language code
+         * @param aLangCode OSCL_HeapString ISO-639-2/T Language code
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetTitle(const OSCL_wString& aTitle, uint16 aLangCode = 0) = 0;
+        virtual PVMFStatus SetTitle(const OSCL_wString& aTitle, const OSCL_String& aLangCode) = 0;
 
         /**
          * This method populates the author string. Title string information about
@@ -207,10 +186,10 @@
         /* This is an optional configuration API that should be called before Start() is called.
          *
          * @param aAuthor   author string.
-         * @param aLangCode  16 bit ISO-639-2/T Language code
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetAuthor(const OSCL_wString& aAuthor, uint16 aLangCode = 0) = 0;
+        virtual PVMFStatus SetAuthor(const OSCL_wString& aAuthor, const OSCL_String& aLangCode) = 0;
 
 
         /**
@@ -222,10 +201,10 @@
         /* This is an optional configuration API that should be called before Start() is called.
          *
          * @param aCopyright   Copyright string.
-         * @param aLangCode  16 bit ISO-639-2/T Language code
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetCopyright(const OSCL_wString& aCopyright, uint16 aLangCode = 0) = 0;
+        virtual PVMFStatus SetCopyright(const OSCL_wString& aCopyright, const OSCL_String& aLangCode) = 0;
 
         /**
          * This method populates the description string. Description string contains
@@ -236,10 +215,10 @@
         /* This is an optional configuration API that should be called before Start() is called.
          *
          * @param aDescription   Description string.
-         * @param aLangCode  16 bit ISO-639-2/T Language code
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetDescription(const OSCL_wString& aDescription, uint16 aLangCode = 0) = 0;
+        virtual PVMFStatus SetDescription(const OSCL_wString& aDescription, const OSCL_String& aLangCode) = 0;
 
         /**
          * This method populates the rating string. Rating string contains
@@ -249,10 +228,10 @@
         /* This is an optional configuration API that should be called before Start() is called.
          *
          * @param aRating   Rating string.
-         * @param aLangCode  16 bit ISO-639-2/T Language code
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetRating(const OSCL_wString& aRating, uint16 aLangCode = 0) = 0;
+        virtual PVMFStatus SetRating(const OSCL_wString& aRating, const OSCL_String& aLangCode) = 0;
 
         /**
          * This method ests the creation date in ISO 8601 format
@@ -276,6 +255,97 @@
          * @return Completion status of this method.
          */
         virtual PVMFStatus SetRealTimeAuthoring(const bool aRealTime) = 0;
+        /* This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aAlbum_Title   Album string.
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetAlbumInfo(const OSCL_wString& aAlbum_Title, const OSCL_String& aLangCode) = 0;
+        /* This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aRecordingYear   Recoding year.
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetRecordingYear(uint16 aRecordingYear) = 0;
+        /**
+         * This method populates the performer string. Performer string contains information about
+         * the the performer of the clip.
+         * Currently only wide char strings are supported.
+         * Language code is currently used only in case of IMOTION authoring mode,
+         * to populate the IMOTION author info atom.
+         *
+         * This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aPerformer  performer string.
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetPerformer(const OSCL_wString& aPerformer, const OSCL_String& aLangCode) = 0;
+
+        /**
+         * This method populates the genre string. Genre string contains information about
+         * the the genre of the clip.
+         * Currently only wide char strings are supported.
+         * Language code is currently used only in case of IMOTION authoring mode,
+         * to populate the IMOTION author info atom.
+         *
+         * This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aGenre  genre string.
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetGenre(const OSCL_wString& aGenre, const OSCL_String& aLangCode) = 0;
+
+        /**
+         * This method populates the Classification string. classification string contains information about
+         * the the classification of the clip .
+         * Currently only wide char strings are supported.
+         * Language code is currently used only in case of IMOTION authoring mode,
+         * to populate the IMOTION author info atom.
+         *
+         * This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aClassificationInfo   classification information string.
+         * @param aClassificationEntity classification Entity string.
+         * @param aClassificationTable  classification Table string.
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetClassification(const OSCL_wString& aClassificationInfo, uint32 aClassificationEntity, uint16 aClassificationTable, const OSCL_String& aLangCode) = 0;
+        /**
+         * This method populates the keyword string. keyword string contains information about
+         * the the keyword of the clip.
+         * Currently only wide char strings are supported.
+         * Language code is currently used only in case of IMOTION authoring mode,
+         * to populate the IMOTION author info atom.
+         *
+         * This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aKeyWordInfo  Keyword information string.
+         * @param aLangCode  OSCL_HeapString ISO-639-2/T Language code
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetKeyWord(const OSCL_wString& aKeyWordInfo, const OSCL_String& aLangCode) = 0;
+        /**
+         * This method populates the LocationInfo string. LocationInfo string contains information about
+         * the the Location of the clip.
+         *
+         * This is an optional configuration API that should be called before Start() is called.
+         *
+         * @param aLocation_info  Instance of class PvmfAssetInfo3GPPLocationStruct
+         * @return Completion status of this method.
+         */
+        virtual PVMFStatus SetLocationInfo(PvmfAssetInfo3GPPLocationStruct& aLocation_info) = 0;
+        /**
+        * This method pouplates the aLang string. aLang contains the language code as a heap string and
+        * this function is used to convert the lang code into uint16 format and stores the lang code into
+        * the authored media file.
+        * @param aLang Language code in Heap String format,
+        * @return lang_code in a uint16 format.
+        */
+        virtual uint16 ConvertLangCode(const OSCL_String& aLang) = 0;
 };
 
 #endif // PVMP4FFCN_CLIPCONFIG_H_INCLUDED
diff --git a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_factory.h b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_factory.h
index 2764821..345bcc6 100644
--- a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_factory.h
+++ b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_settings.h b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_settings.h
index 7be3c53..616b6ac 100644
--- a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_settings.h
+++ b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_settings.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_trackconfig.h b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_trackconfig.h
index 7c4770a..88c857d 100644
--- a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_trackconfig.h
+++ b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_trackconfig.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_types.h b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_types.h
index 432489a..f71a43b 100644
--- a/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_types.h
+++ b/nodes/pvmp4ffcomposernode/include/pvmp4ffcn_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp
index ccacf95..955947e 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,9 +39,20 @@
 #define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
 #define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
 #define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_INFO,m);
+
+#ifdef _TEST_AE_ERROR_HANDLING
+const uint32 FAIL_NODE_CMD_START = 2;
+const uint32 FAIL_NODE_CMD_STOP = 3;
+const uint32 FAIL_NODE_CMD_FLUSH = 4;
+const uint32 FAIL_NODE_CMD_PAUSE = 5;
+const uint32 FAIL_NODE_CMD_RELEASE_PORT = 7;
+#endif
 
 #define SLASH '/'
 
+#define LANG_CODE_SIZE 3
+
 // Define entry point for this DLL
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
@@ -82,6 +93,7 @@
         , iAuthoringMode(PVMP4FF_3GPP_DOWNLOAD_MODE)
         , iPresentationTimescale(1000)
         , iMovieFragmentDuration(2000)
+        , iRecordingYear(0)
         , iClockConverter(8000)
         , iExtensionRefCount(0)
         , iRealTimeTS(false)
@@ -103,9 +115,11 @@
         , iTrackId_H264(0)
         , iTrackId_Text(0)
         , iSyncSample(0)
+        , iformat_h264(PVMF_MIME_FORMAT_UNKNOWN)
+        , iformat_text(PVMF_MIME_FORMAT_UNKNOWN)
         , iNodeEndOfDataReached(false)
-        , iformat_h264(PVMF_FORMAT_UNKNOWN)
-        , iformat_text(PVMF_FORMAT_UNKNOWN)
+        , iSampleInTrack(false)
+        , iFileRendered(false)
 {
     iInterfaceState = EPVMFNodeCreated;
     iNum_PPS_Set = 0;
@@ -119,11 +133,13 @@
     iNumSamplesAdded = 0;
     oDiagnosticsLogged = false;
     iDiagnosticsLogger = PVLogger::GetLoggerObject("pvauthordiagnostics.composer.mp4");
-
+    // Statistics
+    for (uint32 i = 0; i < 3; i++)
+        oscl_memset(&(iStats[i]), 0, sizeof(PVMp4FFCNStats));
 #endif
 
     iLogger = PVLogger::GetLoggerObject("PVMp4FFComposerNode");
-
+    iDataPathLogger = PVLogger::GetLoggerObject("datapath.sinknode.mp4composer");
     int32 err;
     OSCL_TRY(err,
              //Create the input command queue.  Use a reserve to avoid lots of
@@ -148,10 +164,19 @@
                          OSCL_LEAVE(err);
                         );
 
-#if PROFILING_ON
-    // Statistics
-    for (uint32 i = 0; i < 3; i++)
-        oscl_memset(&(iStats[i]), 0, sizeof(PVMp4FFCNStats));
+#ifdef _TEST_AE_ERROR_HANDLING
+    iErrorHandlingAddMemFrag = false;
+    iErrorHandlingAddTrack = false;
+    iErrorCreateComposer = false;
+    iErrorRenderToFile = false;
+    iErrorAddTrack = PVMF_MIME_FORMAT_UNKNOWN;
+    iErrorNodeCmd = 0;
+    iTestFileSize = 0;
+    iTestTimeStamp = 0;
+    iErrorAddSample = 0;
+    iFileSize = 0;
+    iFileDuration = 0;
+    iErrorDataPathStall = 0;
 #endif
 }
 
@@ -167,6 +192,22 @@
     if (iMpeg4File)
     {
         PVA_FF_IMpeg4File::DestroyMP4FileObject(iMpeg4File);
+
+        if (!iFileRendered)
+        {
+            iFs.Connect();
+            iFs.Oscl_DeleteFile(iFileName.get_cstr());
+            iFs.Close();
+        }
+    }
+    for (uint32 i = 0; i < iKeyWordVector.size() ; i++)
+    {
+        if (iKeyWordVector[i] != NULL)
+        {
+            OSCL_DELETE(iKeyWordVector[i]);
+            iKeyWordVector[i] = NULL;
+        }
+
     }
 
     if (pConfig != NULL)
@@ -175,6 +216,20 @@
         iConfigSize = 0;
     }
 
+    if (iLocationInfo._location_name != NULL)
+    {
+        OSCL_FREE(iLocationInfo._location_name);
+    }
+
+    if (iLocationInfo._astronomical_body != NULL)
+    {
+        OSCL_FREE(iLocationInfo._astronomical_body);
+    }
+
+    if (iLocationInfo._additional_notes != NULL)
+    {
+        OSCL_FREE(iLocationInfo._additional_notes);
+    }
     // Cleanup allocated ports
     while (!iInPorts.empty())
     {
@@ -200,7 +255,7 @@
     Cancel();
     if (iInterfaceState != EPVMFNodeCreated)
         iInterfaceState = EPVMFNodeIdle;
-    ThreadLogoff();
+
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -228,6 +283,7 @@
             if (IsAdded())
                 RemoveFromScheduler();
             iLogger = NULL;
+            iDataPathLogger = NULL;
             SetState(EPVMFNodeCreated);
             return PVMFSuccess;
 
@@ -243,11 +299,12 @@
     aNodeCapability.iCanSupportMultipleOutputPorts = false;
     aNodeCapability.iHasMaxNumberOfPorts = true;
     aNodeCapability.iMaxNumberOfPorts = PVMF_MP4FFCN_MAX_INPUT_PORT + PVMF_MP4FFCN_MAX_OUTPUT_PORT;
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_M4V);
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_H264_MP4);
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_H263);
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_AMR_IETF);
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_3GPP_TIMEDTEXT);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_M4V);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_MP4);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H2631998);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H2632000);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_3GPP_TIMEDTEXT);
 
     return PVMFSuccess;
 }
@@ -439,6 +496,17 @@
 ////////////////////////////////////////////////////////////////////////////
 //            PVMp4FFCNClipConfigInterface routines
 ////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint16 PVMp4FFComposerNode::ConvertLangCode(const OSCL_String & aLang)
+{
+    int i = 0;
+    char lang[LANG_CODE_SIZE] = {0};
+    oscl_strncpy(lang, aLang.get_cstr(), LANG_CODE_SIZE);
+
+    uint16 lang_code = ((((uint16)lang[i] - 0x60) << 10) | (((uint16)lang[i+1] - 0x60) << 5) | ((uint16)lang[i+2] - 0x60));
+
+    return lang_code;
+}
+/////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetOutputFileName(const OSCL_wString& aFileName)
 {
     if (iInterfaceState != EPVMFNodeIdle && iInterfaceState != EPVMFNodeInitialized)
@@ -471,7 +539,7 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetVersion(const OSCL_wString& aVersion, uint16 aLangCode)
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetVersion(const OSCL_wString& aVersion, const OSCL_String& aLangCode)
 {
     if (iInterfaceState != EPVMFNodeIdle &&
             iInterfaceState != EPVMFNodeInitialized &&
@@ -479,12 +547,12 @@
         return PVMFErrInvalidState;
 
     iVersion.iDataString = aVersion;
-    iVersion.iLangCode = aLangCode;
+    iVersion.iLangCode = ConvertLangCode(aLangCode);
     return PVMFSuccess;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetTitle(const OSCL_wString& aTitle, uint16 aLangCode)
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetTitle(const OSCL_wString& aTitle, const OSCL_String& aLangCode)
 {
     if (iInterfaceState != EPVMFNodeIdle &&
             iInterfaceState != EPVMFNodeInitialized &&
@@ -492,12 +560,12 @@
         return PVMFErrInvalidState;
 
     iTitle.iDataString = aTitle;
-    iTitle.iLangCode = aLangCode;
+    iTitle.iLangCode = ConvertLangCode(aLangCode);
     return PVMFSuccess;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetAuthor(const OSCL_wString& aAuthor, uint16 aLangCode)
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetAuthor(const OSCL_wString& aAuthor, const OSCL_String& aLangCode)
 {
     if (iInterfaceState != EPVMFNodeIdle &&
             iInterfaceState != EPVMFNodeInitialized &&
@@ -505,12 +573,12 @@
         return PVMFErrInvalidState;
 
     iAuthor.iDataString = aAuthor;
-    iAuthor.iLangCode = aLangCode;
+    iAuthor.iLangCode = ConvertLangCode(aLangCode);
     return PVMFSuccess;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetCopyright(const OSCL_wString& aCopyright, uint16 aLangCode)
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetCopyright(const OSCL_wString& aCopyright, const OSCL_String& aLangCode)
 {
     if (iInterfaceState != EPVMFNodeIdle &&
             iInterfaceState != EPVMFNodeInitialized &&
@@ -518,12 +586,12 @@
         return PVMFErrInvalidState;
 
     iCopyright.iDataString = aCopyright;
-    iCopyright.iLangCode = aLangCode;
+    iCopyright.iLangCode = ConvertLangCode(aLangCode);
     return PVMFSuccess;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetDescription(const OSCL_wString& aDescription, uint16 aLangCode)
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetDescription(const OSCL_wString& aDescription, const OSCL_String& aLangCode)
 {
     if (iInterfaceState != EPVMFNodeIdle &&
             iInterfaceState != EPVMFNodeInitialized &&
@@ -531,12 +599,12 @@
         return PVMFErrInvalidState;
 
     iDescription.iDataString = aDescription;
-    iDescription.iLangCode = aLangCode;
+    iDescription.iLangCode = ConvertLangCode(aLangCode);
     return PVMFSuccess;
 }
 
 ////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetRating(const OSCL_wString& aRating, uint16 aLangCode)
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetRating(const OSCL_wString& aRating, const OSCL_String& aLangCode)
 {
     if (iInterfaceState != EPVMFNodeIdle &&
             iInterfaceState != EPVMFNodeInitialized &&
@@ -544,7 +612,7 @@
         return PVMFErrInvalidState;
 
     iRating.iDataString = aRating;
-    iRating.iLangCode = aLangCode;
+    iRating.iLangCode = ConvertLangCode(aLangCode);
     return PVMFSuccess;
 }
 
@@ -571,6 +639,126 @@
 }
 
 ////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetAlbumInfo(const OSCL_wString& aAlbumTitle, const OSCL_String& aLangCode)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    iAlbumTitle.iDataString = aAlbumTitle;
+    iAlbumTitle.iLangCode = ConvertLangCode(aLangCode);
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetRecordingYear(uint16 aRecordingYear)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    iRecordingYear = aRecordingYear;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetPerformer(const OSCL_wString& aPerformer, const OSCL_String& aLangCode)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    iPerformer.iDataString = aPerformer;
+    iPerformer.iLangCode = ConvertLangCode(aLangCode);
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetGenre(const OSCL_wString& aGenre, const OSCL_String& aLangCode)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    iGenre.iDataString = aGenre;
+    iGenre.iLangCode = ConvertLangCode(aLangCode);
+    return PVMFSuccess;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetClassification(const OSCL_wString& aClassificationInfo, uint32 aClassificationEntity, uint16 aClassificationTable, const OSCL_String& aLangCode)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    iClassification.iDataString = aClassificationInfo;
+    iClassification.iClassificationEntity = aClassificationEntity;
+    iClassification.iClassificationTable = aClassificationTable;
+    iClassification.iLangCode = ConvertLangCode(aLangCode);
+    return PVMFSuccess;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetKeyWord(const OSCL_wString& aKeyWordInfo, const OSCL_String& aLangCode)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    PVMP4FFCN_KeyWord *KeyWord = NULL;
+
+    uint16 langCode = ConvertLangCode(aLangCode);
+    KeyWord = OSCL_NEW(PVMP4FFCN_KeyWord, (aKeyWordInfo, aKeyWordInfo.get_size(), langCode));
+
+    iKeyWordVector.push_back(KeyWord);
+
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetLocationInfo(PvmfAssetInfo3GPPLocationStruct& aLocation_info)
+{
+    if (iInterfaceState != EPVMFNodeIdle &&
+            iInterfaceState != EPVMFNodeInitialized &&
+            iInterfaceState != EPVMFNodePrepared)
+        return PVMFErrInvalidState;
+
+    iLocationInfo._location_name = NULL;
+    uint32 size = oscl_strlen(aLocation_info._location_name);
+    iLocationInfo._location_name = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * size + 10);
+    oscl_strncpy(iLocationInfo._location_name, aLocation_info._location_name, size);
+    iLocationInfo._location_name[size+1] = 0;
+
+    iLocationInfo._astronomical_body = NULL;
+    size = oscl_strlen(aLocation_info._astronomical_body);
+    iLocationInfo._astronomical_body = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * size + 10);
+    oscl_strncpy(iLocationInfo._astronomical_body, aLocation_info._astronomical_body, size);
+    iLocationInfo._astronomical_body[size+1] = 0;
+
+    iLocationInfo._additional_notes = NULL;
+    size = oscl_strlen(aLocation_info._additional_notes);
+    iLocationInfo._additional_notes = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * size + 10);
+    oscl_strncpy(iLocationInfo._additional_notes, aLocation_info._additional_notes, size);
+    iLocationInfo._additional_notes[size+1] = 0;
+
+    iLocationInfo._role = aLocation_info._role;
+    iLocationInfo._longitude = aLocation_info._longitude;
+    iLocationInfo._latitude = aLocation_info._latitude;
+    iLocationInfo._altitude = aLocation_info._altitude;
+    iLocationInfo._langCode = ConvertLangCode(aLocation_info.Lang_code);
+
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
 //                PVMp4FFCNTrackConfigInterface routines
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFStatus PVMp4FFComposerNode::SetTrackReference(const PVMFPortInterface& aPort,
@@ -935,19 +1123,20 @@
     // if format was provided in mimestring, set it now.
     if (portconfig)
     {
-        PVMFFormatType format = GetFormatIndex(portconfig->get_str());
-        switch (format)
+        PVMFFormatType format = portconfig->get_str();
+        if (format == PVMF_MIME_3GPP_TIMEDTEXT ||
+                format == PVMF_MIME_H264_VIDEO_MP4 ||
+                format == PVMF_MIME_M4V ||
+                format == PVMF_MIME_H2631998 ||
+                format == PVMF_MIME_H2632000 ||
+                format == PVMF_MIME_AMR_IETF)
         {
-            case PVMF_3GPP_TIMEDTEXT:
-            case PVMF_H264_MP4:
-            case PVMF_M4V:
-            case PVMF_H263:
-            case PVMF_AMR_IETF:
-                port->SetFormat(format);
-                break;
-            default:
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNotSupported);
-                return;
+            port->SetFormat(format);
+        }
+        else
+        {
+            CommandComplete(iCmdQueue, aCmd, PVMFErrNotSupported);
+            return;
         }
     }
 
@@ -967,17 +1156,33 @@
 void PVMp4FFComposerNode::DoReleasePort(PVMp4FFCNCmd& aCmd)
 {
     //Find the port in the port vector
-    PVMp4FFComposerPort* port;
+    PVMFPortInterface* p = NULL;
 
     for (uint32 i = 0; i < iInPorts.size(); i++)
     {
-        aCmd.Parse((PVMFPortInterface*&)port);
+        aCmd.Parse(p);
+
+        PVMp4FFComposerPort* port = (PVMp4FFComposerPort*)p;
+
         PVMp4FFComposerPort** portPtr = iInPorts.FindByValue(port);
         if (portPtr)
         {
             //delete the port.
             iInPorts.Erase(portPtr);
+
+#ifdef _TEST_AE_ERROR_HANDLING
+            if (FAIL_NODE_CMD_RELEASE_PORT == iErrorNodeCmd)
+            {
+                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
+
+            }
+            else
+            {
+                CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
+            }
+#else
             CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
+#endif
 
         }
         else
@@ -1036,7 +1241,12 @@
 {
     PVMFStatus status = PVMFSuccess;
     uint32 i = 0;
-
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_START == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     switch (iInterfaceState)
     {
         case EPVMFNodePrepared:
@@ -1065,24 +1275,26 @@
             iFileType = 0;
             for (i = 0; i < iInPorts.size(); i++)
             {
-                switch (iInPorts[i]->GetFormat())
+                if (iInPorts[i]->GetFormat() == PVMF_MIME_H264_VIDEO_MP4 ||
+                        iInPorts[i]->GetFormat() == PVMF_MIME_M4V ||
+                        iInPorts[i]->GetFormat() == PVMF_MIME_H2631998 ||
+                        iInPorts[i]->GetFormat() == PVMF_MIME_H2632000)
                 {
-                    case PVMF_H264_MP4:
-                    case PVMF_M4V:
-                    case PVMF_H263:
-                        iFileType |= FILE_TYPE_VIDEO;
-                        break;
-
-                    case PVMF_AMR_IETF:
-                        iFileType |= FILE_TYPE_AUDIO;
-                        break;
-                    case PVMF_3GPP_TIMEDTEXT:
-                        iFileType |= FILE_TYPE_TIMED_TEXT;
-                        break;
-                    default:
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMp4FFComposerNode::DoStart: Error - Unsupported format"));
-                        return;
+                    iFileType |= FILE_TYPE_VIDEO;
+                }
+                else if (iInPorts[i]->GetFormat() == PVMF_MIME_AMR_IETF)
+                {
+                    iFileType |= FILE_TYPE_AUDIO;
+                }
+                else if (iInPorts[i]->GetFormat() == PVMF_MIME_3GPP_TIMEDTEXT)
+                {
+                    iFileType |= FILE_TYPE_TIMED_TEXT;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMp4FFComposerNode::DoStart: Error - Unsupported format"));
+                    return;
                 }
             }
 
@@ -1096,9 +1308,26 @@
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                             (0, "PVMp4FFComposerNode::DoStart: Calling PVA_FF_IMpeg4File::createMP4File(%d,0x%x,%d)",
                              iFileType, &iFs, iAuthoringMode));
+#ifdef _TEST_AE_ERROR_HANDLING //test case to fail mp4 file parser
+            if (iErrorCreateComposer)
+            {
+                //to fail createMP4File()
+                OSCL_wHeapString<OsclMemAllocator> ErrFileName;
+
+                iMpeg4File = PVA_FF_IMpeg4File::createMP4File(iFileType, iOutputPath, iPostfix,
+                             (void*) & iFs, iAuthoringMode, ErrFileName, iCacheSize);
+
+            }
+            else
+            {
+                iMpeg4File = PVA_FF_IMpeg4File::createMP4File(iFileType, iOutputPath, iPostfix,
+                             (void*) & iFs, iAuthoringMode, iFileName, iCacheSize);
+
+            }
+#else
             iMpeg4File = PVA_FF_IMpeg4File::createMP4File(iFileType, iOutputPath, iPostfix,
                          (void*) & iFs, iAuthoringMode, iFileName, iCacheSize);
-
+#endif
             if (!iMpeg4File)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
@@ -1116,7 +1345,19 @@
             iMpeg4File->setRating(iRating.iDataString, iRating.iLangCode);
             iMpeg4File->setCreationDate(iCreationDate);
             iMpeg4File->setMovieFragmentDuration(iMovieFragmentDuration);
+            iMpeg4File->setAlbumInfo(iAlbumTitle.iDataString, iAlbumTitle.iLangCode);
+            iMpeg4File->setRecordingYear(iRecordingYear);
 
+            iMpeg4File->setPerformer(iPerformer.iDataString, iPerformer.iLangCode);
+            iMpeg4File->setGenre(iGenre.iDataString, iGenre.iLangCode);
+            iMpeg4File->setClassification(iClassification.iDataString, iClassification.iClassificationEntity, iClassification.iClassificationTable, iClassification.iLangCode);
+
+            for (i = 0; i < iKeyWordVector.size() ; i++)
+            {
+                iMpeg4File->setKeyWord(iKeyWordVector[i]->iKeyWordSize, iKeyWordVector[i]->iData_String, iKeyWordVector[i]->iLang_Code);
+            }
+
+            iMpeg4File->setLocationInfo(&iLocationInfo);
             for (i = 0; i < iInPorts.size(); i++)
             {
                 status = AddTrack(iInPorts[i]);
@@ -1178,41 +1419,55 @@
         return PVMFFailure;
     }
 
-    switch (aPort->GetFormat())
+    if (aPort->GetFormat() == PVMF_MIME_3GPP_TIMEDTEXT)
     {
-        case PVMF_3GPP_TIMEDTEXT:
-            codecType = CODEC_TYPE_TIMED_TEXT;
-            mediaType = MEDIA_TYPE_TEXT;
-            break;
-        case PVMF_H264_MP4:
-            codecType = CODEC_TYPE_AVC_VIDEO;
-            mediaType = MEDIA_TYPE_VISUAL;
-            break;
-        case PVMF_M4V:
-            codecType = CODEC_TYPE_MPEG4_VIDEO;
-            mediaType = MEDIA_TYPE_VISUAL;
-            break;
-
-        case PVMF_H263:
-            codecType = CODEC_TYPE_BASELINE_H263_VIDEO;
-            mediaType = MEDIA_TYPE_VISUAL;
-            break;
-
-        case PVMF_AMR_IETF:
-            codecType = CODEC_TYPE_AMR_AUDIO;
-            mediaType = MEDIA_TYPE_AUDIO;
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMp4FFComposerNode::AddTrack: Error - Unsupported format"));
-            return PVMFFailure;
+        codecType = CODEC_TYPE_TIMED_TEXT;
+        mediaType = MEDIA_TYPE_TEXT;
+    }
+    else if (aPort->GetFormat() == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        codecType = CODEC_TYPE_AVC_VIDEO;
+        mediaType = MEDIA_TYPE_VISUAL;
+    }
+    else if (aPort->GetFormat() == PVMF_MIME_M4V)
+    {
+        codecType = CODEC_TYPE_MPEG4_VIDEO;
+        mediaType = MEDIA_TYPE_VISUAL;
+    }
+    else if (aPort->GetFormat() == PVMF_MIME_H2631998 ||
+             aPort->GetFormat() == PVMF_MIME_H2632000)
+    {
+        codecType = CODEC_TYPE_BASELINE_H263_VIDEO;
+        mediaType = MEDIA_TYPE_VISUAL;
+    }
+    else if (aPort->GetFormat() == PVMF_MIME_AMR_IETF)
+    {
+        codecType = CODEC_TYPE_AMR_AUDIO;
+        mediaType = MEDIA_TYPE_AUDIO;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMp4FFComposerNode::AddTrack: Error - Unsupported format"));
+        return PVMFFailure;
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                     (0, "PVMp4FFComposerNode::AddTrack: Calling PVA_FF_IMpeg4File::addTrack(0x%x,0x%x)",
                      mediaType, codecType));
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (aPort->GetFormat() == iErrorAddTrack)
+    {
+        return PVMFFailure;
+    }
+#endif
     trackId = iMpeg4File->addTrack(mediaType, codecType);
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (iErrorHandlingAddTrack)
+    {
+        trackId = 0;
+    }
+#endif
     if (trackId == 0)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
@@ -1276,7 +1531,12 @@
         LogDiagnostics();
     }
 #endif
-
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_STOP == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     switch (iInterfaceState)
     {
         case EPVMFNodeStarted:
@@ -1285,7 +1545,12 @@
             if (!iNodeEndOfDataReached)
             {
                 WriteDecoderSpecificInfo();
-                status = RenderToFile();
+                if (iSampleInTrack)
+                {
+                    status = RenderToFile();
+                }
+
+                iSampleInTrack = false;
             }
 
             iNodeEndOfDataReached = false;
@@ -1293,8 +1558,8 @@
             {
                 iInPorts[ii]->iEndOfDataReached = false;
             }
-
         }
+        SetState(EPVMFNodePrepared);
         break;
         case EPVMFNodePrepared:
             status = PVMFSuccess;
@@ -1315,7 +1580,7 @@
     iConfigSize = 0;
     int32 trackId;
 
-    if (iformat_h264 == PVMF_H264_MP4)
+    if (iformat_h264 == PVMF_MIME_H264_VIDEO_MP4)
     {
         trackId = iTrackId_H264;
 
@@ -1359,7 +1624,7 @@
         iMpeg4File->setDecoderSpecificInfo(pConfig, iConfigSize, trackId);
     }
 
-    if (iformat_text == PVMF_3GPP_TIMEDTEXT)
+    if (iformat_text == PVMF_MIME_3GPP_TIMEDTEXT)
     {
         for (uint32 ii = 0;ii < textdecodervector.size();ii++)
         {
@@ -1378,6 +1643,16 @@
     uint32 i;
     for (i = 0; i < iInPorts.size(); i++)
         iInPorts[i]->ClearMsgQueues();
+#ifdef _TEST_AE_ERROR_HANDLING //to fail renderToFile
+    if (iErrorRenderToFile)
+    {
+        if (iMpeg4File)
+        {
+            PVA_FF_IMpeg4File::DestroyMP4FileObject(iMpeg4File);
+            iMpeg4File = NULL;
+        }
+    }
+#endif
 
     if (!iMpeg4File || !iMpeg4File->renderToFile(iFileName))
     {
@@ -1398,6 +1673,8 @@
             oscl_memset(&(iStats[i]), 0, sizeof(PVMp4FFCNStats));
         }
 #endif
+
+        LOGDATATRAFFIC((0, "PVMp4FFComposerNode::RenderToFile() Done"));
         // Delete file format library
         if (iMpeg4File)
         {
@@ -1410,7 +1687,10 @@
         status = PVMFSuccess;
     }
 
-
+    if (PVMFSuccess == status)
+    {
+        iFileRendered = true;
+    }
     return status;
 }
 
@@ -1418,7 +1698,12 @@
 void PVMp4FFComposerNode::DoFlush(PVMp4FFCNCmd& aCmd)
 {
     LOG_STACK_TRACE((0, "PVMp4FFComposerNode::DoFlush() iInterfaceState:%d", iInterfaceState));
-
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_FLUSH == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     switch (iInterfaceState)
     {
         case EPVMFNodeStarted:
@@ -1443,11 +1728,10 @@
 
             // Move the command from the input command queue to the current command, where
             // it will remain until the flush completes.
-            OSCL_TRY(err, iCurrentCmd.StoreL(aCmd););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                                 return;
-                                );
+            err = StoreCurrentCommand(iCurrentCmd, aCmd, iCmdQueue);
+            if (0 != err)
+                return;
+
             iCmdQueue.Erase(&aCmd);
 
             if (!msgPending)
@@ -1458,7 +1742,7 @@
             break;
 
         default:
-
+            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
             break;
     }
 }
@@ -1491,7 +1775,13 @@
     {
         WriteDecoderSpecificInfo();
         // Finalize output file
-        status = RenderToFile();
+        if (iSampleInTrack)
+        {
+            status = RenderToFile();
+        }
+
+        iSampleInTrack = false;
+
         if (status != PVMFSuccess)
             LOG_ERR((0, "PVMp4FFComposerNode::FlushComplete: Error - RenderToFile failed"));
     }
@@ -1521,6 +1811,13 @@
 void PVMp4FFComposerNode::DoPause(PVMp4FFCNCmd& aCmd)
 {
     PVMFStatus status = PVMFSuccess;
+
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_PAUSE == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
     switch (iInterfaceState)
     {
         case EPVMFNodeStarted:
@@ -1549,6 +1846,12 @@
 
     if (IsAdded())
     {
+        if (iSampleInTrack)
+        {
+            status = RenderToFile();
+            iSampleInTrack = false;
+        }
+
         //delete all ports and notify observer.
         while (!iInPorts.empty())
             iInPorts.Erase(&iInPorts.front());
@@ -1559,7 +1862,7 @@
 
         //logoff & go back to Created state.
         SetState(EPVMFNodeIdle);
-        status = ThreadLogoff();
+        status = PVMFSuccess;
     }
     else
     {
@@ -1656,6 +1959,9 @@
             }
             if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
             {
+                LOGDATATRAFFIC((0, "PVMp4FFComposerNode::ProcessIncomingMsg: EOS Recvd - TrackID=%d, StreamID=%d, TS=%d, Mime=%s",
+                                port->GetTrackId(), msg->getStreamID(), msg->getTimestamp(), port->GetMimeType().get_cstr()));
+
                 port->iEndOfDataReached = true;
                 //check if EOS has been received on all connected ports.
                 uint32 ii = 0;
@@ -1672,7 +1978,11 @@
                 {
                     //Close the file since EOS is received on every connected port
                     WriteDecoderSpecificInfo();
-                    status = RenderToFile();
+                    if (iSampleInTrack)
+                    {
+                        status = RenderToFile();
+                        iSampleInTrack = false;
+                    }
 
                     //report EOS info to engine
                     ReportInfoEvent(PVMF_COMPOSER_EOS_REACHED);
@@ -1685,7 +1995,7 @@
             convertToPVMFMediaData(mediaDataPtr, msg);
 
             int32 trackId = port->GetTrackId();
-            if ((mediaDataPtr->getSeqNum() == 0) && (port->GetFormat() == PVMF_M4V))
+            if ((mediaDataPtr->getSeqNum() == 0) && (port->GetFormat() == PVMF_MIME_M4V))
             {
                 // Set VOL Header
                 OsclRefCounterMemFrag volHeader;
@@ -1700,12 +2010,12 @@
                 iMpeg4File->setDecoderSpecificInfo((uint8*)volHeader.getMemFragPtr(),
                                                    (int32)volHeader.getMemFragSize(), trackId);
             }
-            if ((mediaDataPtr->getSeqNum() == 0) && (port->GetFormat() == PVMF_H264_MP4))
+            if ((mediaDataPtr->getSeqNum() == 0) && (port->GetFormat() == PVMF_MIME_H264_VIDEO_MP4))
             {
                 iTrackId_H264 = port->GetTrackId();
                 iformat_h264 = port->GetFormat();
             }
-            if (port->GetFormat() == PVMF_3GPP_TIMEDTEXT)
+            if (port->GetFormat() == PVMF_MIME_3GPP_TIMEDTEXT)
             {
                 iTrackId_Text = port->GetTrackId();
                 iformat_text = port->GetFormat();
@@ -1721,7 +2031,7 @@
                 int32* pVal = (int32*)textconfiginfo.getMemFragPtr();
                 iText_sdIndex = *pVal;
             }
-            if ((port->GetFormat() == PVMF_AMR_IETF) && mediaDataPtr->getErrorsFlag())
+            if ((port->GetFormat() == PVMF_MIME_AMR_IETF) && mediaDataPtr->getErrorsFlag())
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NOTICE,
                                 (0, "PVMp4FFComposerNode::ProcessIncomingMsg: Error flag set for AMR!"));
@@ -1732,7 +2042,11 @@
             OsclRefCounterMemFrag memFrag;
             uint32 numFrags = mediaDataPtr->getNumFragments();
             uint32 timestamp = mediaDataPtr->getTimestamp();
-            iSyncSample = mediaDataPtr->getMarkerInfo(); //gives the I frame info
+            iSyncSample = 0;
+            if (mediaDataPtr->getMarkerInfo()&PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT)
+            {
+                iSyncSample = 1;
+            }
 
             Oscl_Vector<OsclMemoryFragment, OsclMemAllocator> pFrame; //vector to store the nals in the particular case of AVC
             for (uint32 i = 0; (i < numFrags) && status == PVMFSuccess; i++)
@@ -1775,8 +2089,8 @@
         PVMp4FFComposerPort *aPort)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: aFormat=0x%x, aTimestamp=%d, aTrackId=%d",
-                     aFormat, aTimestamp, aTrackId));
+                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: aFormat=%s, aTimestamp=%d, aTrackId=%d",
+                     aFormat.getMIMEStrPtr(), aTimestamp, aTrackId));
 
     if (iRealTimeTS)
     {
@@ -1818,31 +2132,239 @@
         }
     }
 
-    switch (aFormat)
+    if (aFormat == PVMF_MIME_3GPP_TIMEDTEXT ||
+            aFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+            aFormat == PVMF_MIME_M4V ||
+            aFormat == PVMF_MIME_H2631998 ||
+            aFormat == PVMF_MIME_H2632000)
     {
-        case PVMF_3GPP_TIMEDTEXT:
-        case PVMF_H264_MP4:
-        case PVMF_M4V:
-        case PVMF_H263:
+        status = CheckMaxDuration(aTimestamp);
+        if (status == PVMFFailure)
         {
-            status = CheckMaxDuration(aTimestamp);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - CheckMaxDuration failed"));
+            return status;
+        }
+        else if (status == PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMp4FFComposerNode::AddMemFragToTrack: Maxmimum duration reached"));
+            return status;
+        }
+
+        for (i = 0; i < aFrame.size(); i++)
+        {
+            size = aFrame[i].len;
+            status = CheckMaxFileSize(size);
             if (status == PVMFFailure)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - CheckMaxDuration failed"));
+                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - CheckMaxFileSize failed"));
                 return status;
             }
             else if (status == PVMFSuccess)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Maxmimum duration reached"));
+                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Maxmimum file size reached"));
                 return status;
             }
 
-            for (i = 0; i < aFrame.size(); i++)
+            //No data for some reason.
+            if (size == 0)
             {
-                size = aFrame[i].len;
-                status = CheckMaxFileSize(size);
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_NOTICE,
+                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: no data in frag!"));
+                return PVMFSuccess;
+            }
+        }
+        uint8 codingType = CODING_TYPE_P;
+
+        if (iRealTimeTS)
+        {
+            if (aTimestamp <= aPort->GetLastTS())
+            {
+                aTimestamp = aPort->GetLastTS() + 1;
+            }
+
+            aPort->SetLastTS(aTimestamp);
+        }
+
+        //iSyncSample is obtained from the marker info
+        //to identify the I Frame
+        if (iSyncSample)
+        {
+            codingType = CODING_TYPE_I;
+        }
+
+        // Format: mtb (1) | layer_id (3) | coding_type (2) | ref_select_code (2)
+        // flags |= ((stream->iHintTrack.MTB & 0x01) << 7);
+        // flags |= ((stream->iHintTrack.LayerID & 0x07) << 4);
+        flags |= ((codingType & 0x03) << 2);
+        // flags |= (stream->iHintTrack.RefSelCode & 0x03);
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Calling addSampleToTrack(%d, 0x%x, %d, %d, %d)",
+                         aTrackId, data, size, aTimestamp, flags));
+
+        LOGDATATRAFFIC((0, "PVMp4FFComposerNode::AddMemFragToTrack: TrackID=%d, Size=%d, TS=%d, Flags=%d, Mime=%s",
+                        aTrackId, size, aTimestamp, flags, aPort->GetMimeType().get_cstr()));
+
+        if (aFormat == PVMF_MIME_3GPP_TIMEDTEXT)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMp4FFComposerNode::AddMemFragToTrack: Calling addtextSampleToTrack(%d, 0x%x, %d, %d, %d)",
+                             aTrackId, data, size, aTimestamp, flags));
+            int32 index = iText_sdIndex;
+
+            if (index >= 0)
+            {
+#if PROFILING_ON
+                uint32 start = OsclTickCount::TickCount();
+#endif
+                if (!iMpeg4File->addTextSampleToTrack(aTrackId, aFrame, aTimestamp, flags, index, NULL))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addTextSampleToTrack for Timed Text failed"));
+                    return PVMFFailure;
+                }
+                iSampleInTrack = true;
+#if PROFILING_ON
+                uint32 stop = OsclTickCount::TickCount();
+                uint32 comptime = OsclTickCount::TicksToMsec(stop - start);
+                uint32 dataSize = 0;
+                for (uint32 ii = 0; ii < aFrame.size(); ii++)
+                {
+                    dataSize += aFrame[ii].len;
+                }
+                GenerateDiagnostics(comptime, dataSize);
+#endif
+            }
+        }
+        else
+        {
+
+#if PROFILING_ON
+            uint32 start = OsclTickCount::TickCount();
+#endif
+
+#ifdef _TEST_AE_ERROR_HANDLING
+
+            if (1 == iErrorAddSample)
+            {
+                if (iTestFileSize <= iFileSize) //iTestFileSize set in sendProgressReport()
+                {
+                    if (!iMpeg4File->addSampleToTrack(aTrackId, aFrame, aTimestamp, flags))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addSampleToTrack failed"));
+                        return PVMFFailure;
+                    }
+                }
+            }
+            else if (2 == iErrorAddSample)
+            {
+
+                if (aTimestamp <= iFileDuration)
+                {
+                    if (!iMpeg4File->addSampleToTrack(aTrackId, aFrame, aTimestamp, flags))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addSampleToTrack failed"));
+                        return PVMFFailure;
+                    }
+                }
+            }
+            else
+            {
+                if (!iMpeg4File->addSampleToTrack(aTrackId, aFrame, aTimestamp, flags))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addSampleToTrack failed"));
+                    return PVMFFailure;
+                }
+            }
+
+#else
+            if (!iMpeg4File->addSampleToTrack(aTrackId, aFrame, aTimestamp, flags))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addSampleToTrack failed"));
+                return PVMFFailure;
+            }
+#endif
+            iSampleInTrack = true;
+#ifdef _TEST_AE_ERROR_HANDLING
+            if (iErrorHandlingAddMemFrag == true)
+            {
+                return PVMFFailure; //Just to trigger error handling
+            }
+#endif
+
+#if PROFILING_ON
+            uint32 stop = OsclTickCount::TickCount();
+            uint32 comptime = OsclTickCount::TicksToMsec(stop - start);
+            uint32 dataSize = 0;
+            for (uint32 ii = 0; ii < aFrame.size(); ii++)
+            {
+                dataSize += aFrame[ii].len;
+            }
+            GenerateDiagnostics(comptime, dataSize);
+#endif
+        }
+
+
+        // Send progress report after sample is successfully added
+        SendProgressReport(aTimestamp);
+
+#if PROFILING_ON
+        ++(stats->iNumFrames);
+        stats->iDuration = aTimestamp;
+#endif
+    }
+    else if (aFormat == PVMF_MIME_AMR_IETF)
+    {
+        if (iRealTimeTS)
+        {
+            if (((int32) aTimestamp - (int32) aPort->GetLastTS()) < 20)
+            {
+                aTimestamp = aPort->GetLastTS() + 20;
+            }
+
+            aPort->SetLastTS(aTimestamp);
+        }
+
+        uint32 bytesProcessed = 0;
+        uint32 frameSize = 0;
+        Oscl_Vector<OsclMemoryFragment, OsclMemAllocator> amrfrags;
+        for (i = 0; i < aFrame.size(); i++)
+        {
+            bytesProcessed = 0;
+            size = aFrame[i].len;
+            data = OSCL_REINTERPRET_CAST(uint8*, aFrame[i].ptr);
+            // Parse audio data and add one 20ms frame to track at a time
+            while (bytesProcessed < size)
+            {
+                // Check for max duration
+                status = CheckMaxDuration(aTimestamp);
+                if (status == PVMFFailure)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - CheckMaxDuration failed"));
+                    return status;
+                }
+                else if (status == PVMFSuccess)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
+                                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: Maxmimum duration reached"));
+                    return status;
+                }
+
+                // Update clock converter
+                iClockConverter.set_clock_other_timescale(aTimestamp, 1000);
+
+                // Check max file size
+                frameSize = GetIETFFrameSize(data[0]);
+                status = CheckMaxFileSize(frameSize);
                 if (status == PVMFFailure)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
@@ -1856,243 +2378,60 @@
                     return status;
                 }
 
-                //No data for some reason.
-                if (size == 0)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_NOTICE,
-                                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: no data in frag!"));
-                    return PVMFSuccess;
-                }
-            }
-            uint8 codeType = 1;
-
-            if (iRealTimeTS)
-            {
-                if (aTimestamp <= aPort->GetLastTS())
-                {
-                    aTimestamp = aPort->GetLastTS() + 1;
-                }
-
-                aPort->SetLastTS(aTimestamp);
-            }
-
-            switch (aFormat)
-            {
-                case PVMF_H264_MP4:
-                {
-                    if (iSyncSample) //iSyncSample is obtained from the marker info
-                        codeType = 0;  //to identify the I Frame in the case of AVC
-                }
-                break;
-                case PVMF_M4V:
-                    for (i = 0;i < aFrame.size();i++)
-                    {
-                        data = OSCL_REINTERPRET_CAST(uint8*, aFrame[i].ptr);
-                        if (data[4] <= 0x3F)
-                            codeType = 0; // I-frame
-                    }
-
-                    break;
-                case PVMF_H263:
-                    for (i = 0;i < aFrame.size();i++)
-                    {
-                        data = OSCL_REINTERPRET_CAST(uint8*, aFrame[i].ptr);
-                        if (!(data[4] & 0x02))
-                            codeType = 0; // I-frame
-                    }
-                    break;
-            }
-
-            // Format: mtb (1) | layer_id (3) | coding_type (2) | ref_select_code (2)
-            // flags |= ((stream->iHintTrack.MTB & 0x01) << 7);
-            // flags |= ((stream->iHintTrack.LayerID & 0x07) << 4);
-            flags |= ((codeType & 0x03) << 2);
-            // flags |= (stream->iHintTrack.RefSelCode & 0x03);
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMp4FFComposerNode::AddMemFragToTrack: Calling addSampleToTrack(%d, 0x%x, %d, %d, %d)",
-                             aTrackId, data, size, aTimestamp, flags));
-
-            if (aFormat == PVMF_3GPP_TIMEDTEXT)
-            {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Calling addtextSampleToTrack(%d, 0x%x, %d, %d, %d)",
-                                 aTrackId, data, size, aTimestamp, flags));
-                int32 index = iText_sdIndex;
+                                (0, "PVMp4FFComposerNode::AddMemFragToTrack: Calling addSampleToTrack(%d, 0x%x, %d, %d, %d)",
+                                 aTrackId, data, frameSize, iClockConverter.get_current_timestamp(), flags));
 
-                if (index >= 0)
-                {
-#if PROFILING_ON
-                    uint32 start = OsclTickCount::TickCount();
-#endif
-                    if (!iMpeg4File->addTextSampleToTrack(aTrackId, aFrame, aTimestamp, flags, index, NULL))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addTextSampleToTrack for Timed Text failed"));
-                        return PVMFFailure;
-                    }
-#if PROFILING_ON
-                    uint32 stop = OsclTickCount::TickCount();
-                    uint32 comptime = OsclTickCount::TicksToMsec(stop - start);
-                    uint32 dataSize = 0;
-                    for (uint32 ii = 0; ii < aFrame.size(); ii++)
-                    {
-                        dataSize += aFrame[ii].len;
-                    }
-                    GenerateDiagnostics(comptime, dataSize);
-#endif
-                }
-            }
-            else
-            {
+
+                OsclMemoryFragment amr_memfrag;
+                amr_memfrag.len = frameSize;
+                amr_memfrag.ptr = data;
+                amrfrags.push_back(amr_memfrag);
 
 #if PROFILING_ON
                 uint32 start = OsclTickCount::TickCount();
 #endif
+                uint32 amrts = iClockConverter.get_current_timestamp();
 
-                if (!iMpeg4File->addSampleToTrack(aTrackId, aFrame, aTimestamp, flags))
+                LOGDATATRAFFIC((0, "PVMp4FFComposerNode::AddMemFragToTrack: TrackID=%d, Size=%d, TS=%d, Flags=%d, Mime=%s",
+                                aTrackId, frameSize, amrts, flags, aPort->GetMimeType().get_cstr()));
+
+                if (!iMpeg4File->addSampleToTrack(aTrackId, amrfrags, amrts, flags))
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                                     (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addSampleToTrack failed"));
                     return PVMFFailure;
                 }
-
+                iSampleInTrack = true;
 #if PROFILING_ON
                 uint32 stop = OsclTickCount::TickCount();
                 uint32 comptime = OsclTickCount::TicksToMsec(stop - start);
                 uint32 dataSize = 0;
-                for (uint32 ii = 0; ii < aFrame.size(); ii++)
+                for (uint32 ii = 0; ii < amrfrags.size(); ii++)
                 {
-                    dataSize += aFrame[ii].len;
+                    dataSize += amrfrags[ii].len;
                 }
                 GenerateDiagnostics(comptime, dataSize);
+
 #endif
-            }
 
-
-            // Send progress report after sample is successfully added
-            SendProgressReport(aTimestamp);
+                // Send progress report after sample is successfully added
+                SendProgressReport(aTimestamp);
 
 #if PROFILING_ON
-            ++(stats->iNumFrames);
-            stats->iDuration = aTimestamp;
+                ++(stats->iNumFrames);
+                stats->iDuration = aTimestamp;
 #endif
+                data += frameSize;
+                bytesProcessed += frameSize;
+                aTimestamp += 20;
+                amrfrags.clear();
+            }
         }
-        break;
-
-        case PVMF_AMR_IETF:
+        if (iRealTimeTS)
         {
-            if (iRealTimeTS)
-            {
-                if (((int32) aTimestamp - (int32) aPort->GetLastTS()) < 20)
-                {
-                    aTimestamp = aPort->GetLastTS() + 20;
-                }
-
-                aPort->SetLastTS(aTimestamp);
-            }
-
-            uint32 bytesProcessed = 0;
-            uint32 frameSize = 0;
-            Oscl_Vector<OsclMemoryFragment, OsclMemAllocator> amrfrags;
-            for (i = 0; i < aFrame.size(); i++)
-            {
-                bytesProcessed = 0;
-                size = aFrame[i].len;
-                data = OSCL_REINTERPRET_CAST(uint8*, aFrame[i].ptr);
-                // Parse audio data and add one 20ms frame to track at a time
-                while (bytesProcessed < size)
-                {
-                    // Check for max duration
-                    status = CheckMaxDuration(aTimestamp);
-                    if (status == PVMFFailure)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - CheckMaxDuration failed"));
-                        return status;
-                    }
-                    else if (status == PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Maxmimum duration reached"));
-                        return status;
-                    }
-
-                    // Update clock converter
-                    iClockConverter.set_clock_other_timescale(aTimestamp, 1000);
-
-                    // Check max file size
-                    frameSize = GetIETFFrameSize(data[0]);
-                    status = CheckMaxFileSize(frameSize);
-                    if (status == PVMFFailure)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - CheckMaxFileSize failed"));
-                        return status;
-                    }
-                    else if (status == PVMFSuccess)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Maxmimum file size reached"));
-                        return status;
-                    }
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMp4FFComposerNode::AddMemFragToTrack: Calling addSampleToTrack(%d, 0x%x, %d, %d, %d)",
-                                     aTrackId, data, frameSize, iClockConverter.get_current_timestamp(), flags));
-
-
-                    OsclMemoryFragment amr_memfrag;
-                    amr_memfrag.len = frameSize;
-                    amr_memfrag.ptr = data;
-                    amrfrags.push_back(amr_memfrag);
-
-#if PROFILING_ON
-                    uint32 start = OsclTickCount::TickCount();
-#endif
-
-                    if (!iMpeg4File->addSampleToTrack(aTrackId, amrfrags,
-                                                      iClockConverter.get_current_timestamp(), flags))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMp4FFComposerNode::AddMemFragToTrack: Error - addSampleToTrack failed"));
-                        return PVMFFailure;
-                    }
-
-#if PROFILING_ON
-                    uint32 stop = OsclTickCount::TickCount();
-                    uint32 comptime = OsclTickCount::TicksToMsec(stop - start);
-                    uint32 dataSize = 0;
-                    for (uint32 ii = 0; ii < amrfrags.size(); ii++)
-                    {
-                        dataSize += amrfrags[ii].len;
-                    }
-                    GenerateDiagnostics(comptime, dataSize);
-
-#endif
-
-                    // Send progress report after sample is successfully added
-                    SendProgressReport(aTimestamp);
-
-#if PROFILING_ON
-                    ++(stats->iNumFrames);
-                    stats->iDuration = aTimestamp;
-#endif
-                    data += frameSize;
-                    bytesProcessed += frameSize;
-                    aTimestamp += 20;
-                    amrfrags.clear();
-                }
-            }
-            if (iRealTimeTS)
-            {
-                aPort->SetLastTS(aTimestamp - 20);
-            }
+            aPort->SetLastTS(aTimestamp - 20);
         }
-        break;
-
-        default:
-            break;
     }
 
     return PVMFSuccess;
@@ -2120,6 +2459,8 @@
     }
     iNumSamplesAdded++;
 #endif
+    OSCL_UNUSED_ARG(aTime);
+    OSCL_UNUSED_ARG(aSize);
 }
 //////////////////////////////////////////////////////////////////////////////////
 int32 PVMp4FFComposerNode::GetIETFFrameSize(uint8 aFrameType)
@@ -2177,6 +2518,9 @@
             iNextFileSizeReport = fileSize - (fileSize % iFileSizeReportFreq) + iFileSizeReportFreq;
             ReportInfoEvent(PVMF_COMPOSER_FILESIZE_PROGRESS, (OsclAny*)fileSize);
         }
+#ifdef _TEST_AE_ERROR_HANDLING
+        iTestFileSize = fileSize; //iTestTimeStamp to fail the addSampleTrack() once a particulare time duration is reached as specified in testapp.
+#endif
     }
 
     return PVMFSuccess;
@@ -2194,8 +2538,12 @@
         if ((metaDataSize + mediaDataSize + aFrameSize) >= iMaxFileSize)
         {
             // Finalized output file
-            if (RenderToFile() != PVMFSuccess)
-                return PVMFFailure;
+            if (iSampleInTrack)
+            {
+                iSampleInTrack = false;
+                if (RenderToFile() != PVMFSuccess)
+                    return PVMFFailure;
+            }
 
             ReportInfoEvent(PVMF_COMPOSER_MAXFILESIZE_REACHED, NULL);
             return PVMFSuccess;
@@ -2210,13 +2558,21 @@
 //////////////////////////////////////////////////////////////////////////////////
 PVMFStatus PVMp4FFComposerNode::CheckMaxDuration(uint32 aTimestamp)
 {
+    //if(!iInfoObserver)
+    //	return PVMFFailure;
+
     if (iMaxDurationEnabled)
     {
         if (aTimestamp >= iMaxTimeDuration)
         {
             // Finalize output file
-            if (RenderToFile() != PVMFSuccess)
-                return PVMFFailure;
+            if (iSampleInTrack)
+            {
+                iSampleInTrack = false;
+                if (RenderToFile() != PVMFSuccess)
+                    return PVMFFailure;
+            }
+
 
             ReportInfoEvent(PVMF_COMPOSER_MAXDURATION_REACHED, NULL);
             return PVMFSuccess;
@@ -2268,7 +2624,16 @@
 #endif
 }
 
-
+int32 PVMp4FFComposerNode::StoreCurrentCommand(PVMp4FFCNCmdQueue& aCurrentCmd, PVMp4FFCNCmd& aCmd, PVMp4FFCNCmdQueue& aCmdQueue)
+{
+    int32 err = 0;
+    OSCL_TRY(err, aCurrentCmd.StoreL(aCmd););
+    OSCL_FIRST_CATCH_ANY(err,
+                         CommandComplete(aCmdQueue, aCmd, PVMFErrNoMemory);
+                         return err;
+                        );
+    return err;
+}
 
 
 
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.h b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.h
index 9f15ee5..e41ca08 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.h
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -82,6 +82,9 @@
 #include "pvmf_media_msg_format_ids.h"
 #endif
 
+#ifndef PVMI_KVP_H_INCLUDED
+#include "pvmi_kvp.h"
+#endif
 // Forward declaration
 class PVMp4FFComposerPort;
 
@@ -101,8 +104,8 @@
 #define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
 
 #if PROFILING_ON
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #endif
 
@@ -155,14 +158,22 @@
         OSCL_IMPORT_REF PVMFStatus SetOutputFileName(const OSCL_wString& aFileName);
         OSCL_IMPORT_REF PVMFStatus SetAuthoringMode(PVMp4FFCN_AuthoringMode aAuthoringMode = PVMP4FFCN_3GPP_DOWNLOAD_MODE);
         OSCL_IMPORT_REF PVMFStatus SetPresentationTimescale(uint32 aTimescale);
-        OSCL_IMPORT_REF PVMFStatus SetVersion(const OSCL_wString& aVersion, uint16 aLangCode = 0);
-        OSCL_IMPORT_REF PVMFStatus SetTitle(const OSCL_wString& aTitle, uint16 aLangCode = 0);
-        OSCL_IMPORT_REF PVMFStatus SetAuthor(const OSCL_wString& aAuthor, uint16 aLangCode = 0);
-        OSCL_IMPORT_REF PVMFStatus SetCopyright(const OSCL_wString& aCopyright, uint16 aLangCode = 0);
-        OSCL_IMPORT_REF PVMFStatus SetDescription(const OSCL_wString& aDescription, uint16 aLangCode = 0);
-        OSCL_IMPORT_REF PVMFStatus SetRating(const OSCL_wString& aRating, uint16 aLangCode = 0);
+        OSCL_IMPORT_REF PVMFStatus SetVersion(const OSCL_wString& aVersion, const OSCL_String& aLangCode);
+        OSCL_IMPORT_REF PVMFStatus SetTitle(const OSCL_wString& aTitle, const OSCL_String& aLangCode);
+        OSCL_IMPORT_REF PVMFStatus SetAuthor(const OSCL_wString& aAuthor, const OSCL_String& aLangCode);
+        OSCL_IMPORT_REF PVMFStatus SetCopyright(const OSCL_wString& aCopyright, const OSCL_String& aLangCode);
+        OSCL_IMPORT_REF PVMFStatus SetDescription(const OSCL_wString& aDescription, const OSCL_String& aLangCode);
+        OSCL_IMPORT_REF PVMFStatus SetRating(const OSCL_wString& aRating, const OSCL_String& aLangCode);
         OSCL_IMPORT_REF PVMFStatus SetCreationDate(const OSCL_wString& aCreationDate);
         OSCL_IMPORT_REF PVMFStatus SetRealTimeAuthoring(const bool aRealTime);
+        OSCL_IMPORT_REF PVMFStatus SetAlbumInfo(const OSCL_wString& aAlbum_Title, const OSCL_String& aLangCode);
+        OSCL_IMPORT_REF PVMFStatus SetRecordingYear(uint16 aRecordingYear);
+        OSCL_IMPORT_REF PVMFStatus SetPerformer(const OSCL_wString& aPerformer, const OSCL_String& aLangCode);
+        OSCL_EXPORT_REF PVMFStatus SetGenre(const OSCL_wString& aGenre, const OSCL_String& aLangCode);
+        OSCL_EXPORT_REF PVMFStatus SetClassification(const OSCL_wString& aClassificationInfo, uint32 aClassificationEntity, uint16 aClassificationTable, const OSCL_String& aLangCode);
+        OSCL_EXPORT_REF PVMFStatus SetKeyWord(const OSCL_wString& aKeyWordInfo, const OSCL_String& aLangCode);
+        OSCL_EXPORT_REF PVMFStatus SetLocationInfo(PvmfAssetInfo3GPPLocationStruct& aLocation_info);
+        OSCL_IMPORT_REF uint16 ConvertLangCode(const OSCL_String& aLang);
 
         // Pure virtual functions from PVMp4FFCNTrackConfigInterface
         OSCL_IMPORT_REF PVMFStatus SetTrackReference(const PVMFPortInterface& aPort,
@@ -318,6 +329,7 @@
     private:
         void GenerateDiagnostics(uint32 aTime, uint32 aSize);
         void LogDiagnostics();
+        int32 StoreCurrentCommand(PVMp4FFCNCmdQueue&, PVMp4FFCNCmd&, PVMp4FFCNCmdQueue&);
 
         // Node command queue
         PVMp4FFCNCmdQueue iCmdQueue;
@@ -341,16 +353,43 @@
         struct PVMP4FFCN_MetaDataString
         {
 public:
-            PVMP4FFCN_MetaDataString(): iLangCode(0) {};
+            PVMP4FFCN_MetaDataString(): iClassificationEntity(0), iClassificationTable(0), iLangCode(0) {};
             OSCL_wHeapString<OsclMemAllocator> iDataString;
+            uint32 iClassificationEntity;
+            uint16 iClassificationTable;
             uint16 iLangCode;
         };
+        class PVMP4FFCN_KeyWord
+        {
+            public:
+                PVMP4FFCN_KeyWord(): iKeyWordSize(0), iLang_Code(0) {};
+                ~PVMP4FFCN_KeyWord() {};
+                uint32 iKeyWordSize;
+                uint16 iLang_Code;
+                OSCL_wHeapString<OsclMemAllocator> iData_String;
+
+                PVMP4FFCN_KeyWord(const OSCL_wString& aData_String, uint32 aKeyWordSize, uint16 aLang_Code)
+                {
+                    iData_String = aData_String;
+                    iKeyWordSize = aKeyWordSize;
+                    iLang_Code = aLang_Code;
+                }
+
+        };
         PVMP4FFCN_MetaDataString iVersion;
         PVMP4FFCN_MetaDataString iTitle;
         PVMP4FFCN_MetaDataString iAuthor;
         PVMP4FFCN_MetaDataString iCopyright;
         PVMP4FFCN_MetaDataString iDescription;
         PVMP4FFCN_MetaDataString iRating;
+        PVMP4FFCN_MetaDataString iAlbumTitle;
+        uint16 iRecordingYear;
+        PVMP4FFCN_MetaDataString iPerformer;
+        PVMP4FFCN_MetaDataString iGenre;
+        PVMP4FFCN_MetaDataString iClassification;
+        Oscl_Vector<PVMP4FFCN_KeyWord* , OsclMemAllocator> iKeyWordVector;
+
+        PvmfAssetInfo3GPPLocationStruct iLocationInfo;
         OSCL_wHeapString<OsclMemAllocator> iCreationDate;
 
         // Convert from timescale
@@ -358,6 +397,7 @@
 
         // Debug logging
         PVLogger* iLogger;
+        PVLogger* iDataPathLogger;
 
         uint32 iExtensionRefCount;
 
@@ -387,6 +427,8 @@
         PVMFFormatType iformat_h264;
         PVMFFormatType iformat_text;
         bool iNodeEndOfDataReached;
+        bool iSampleInTrack;
+        bool iFileRendered;
 
 #if PROFILING_ON
         uint32 iMaxSampleAddTime;
@@ -407,6 +449,20 @@
 
         PVMp4FFCNStats iStats[3];
 #endif
+#ifdef _TEST_AE_ERROR_HANDLING
+        bool iErrorHandlingAddMemFrag;
+        bool iErrorHandlingAddTrack;
+        bool iErrorCreateComposer;
+        bool iErrorRenderToFile;
+        PVMFFormatType iErrorAddTrack;
+        uint32 iErrorNodeCmd;
+        uint32 iTestFileSize;
+        uint32 iTestTimeStamp;
+        uint32 iErrorAddSample;
+        uint32 iFileSize;
+        uint32 iFileDuration;
+        uint32 iErrorDataPathStall;
+#endif
 };
 
 #endif // PVMP4FFC_NODE_H_INCLUDED
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node_cap_config.cpp b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node_cap_config.cpp
index 0a94d8b..d556eb5 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node_cap_config.cpp
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_node_cap_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,19 +46,43 @@
     PvmiKvpValueType iValueType;
 };
 
+#ifdef _TEST_AE_ERROR_HANDLING
+#define MP4COMPOSERNODECONFIG_BASE_NUMKEYS 10
+#else
 #define MP4COMPOSERNODECONFIG_BASE_NUMKEYS 2
+#endif
 #define MP4CONFIG_KEYSTRING_SIZE 128
 
 static const MP4ComposerNodeKeyStringData MP4ComposerNodeConfig_BaseKeys[] =
 {
     {"presentation-timescale", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"pv-cache-size", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+#ifdef _TEST_AE_ERROR_HANDLING
+    , {"error_start_addmemfrag", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error_start_addtrack", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error-addtrack", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}
+    , {"error-node-cmd", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"error-create-composer", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error-render-to-file", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error-addsample", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"data-path-stall", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+#endif
 };
 
 enum BaseKeys_IndexMapType
 {
     PRESENTATION_TIMESCALE = 0,
     PV_CACHE_SIZE
+#ifdef _TEST_AE_ERROR_HANDLING
+    , ERROR_START_ADDMEMFRAG
+    , ERROR_START_ADDTRACK
+    , ERROR_ADDTRACK
+    , ERROR_NODE_CMD
+    , ERROR_CREATE_COMPOSER
+    , ERROR_RENDERTOFILE
+    , ERROR_ADD_SAMPLE
+    , ERROR_DATAPATH_STALL
+#endif
 };
 
 
@@ -90,7 +114,7 @@
     aParameters[0].key = memblock;
 
     // Copy the key string
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("fileio/"), 7);
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/composer/mp4/"), 7);
     oscl_strncat(aParameters[0].key, MP4ComposerNodeConfig_BaseKeys[aIndex].iString, oscl_strlen(MP4ComposerNodeConfig_BaseKeys[aIndex].iString));
     oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
     switch (MP4ComposerNodeConfig_BaseKeys[aIndex].iValueType)
@@ -113,6 +137,9 @@
                 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
             }
             break;
+        case PVMI_KVPVALTYPE_CHARPTR:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
+            break;
         case PVMI_KVPVALTYPE_UINT32:
         default:
             if (PVMI_KVPATTR_CAP == aReqattr)
@@ -138,6 +165,7 @@
             }
             else if (PVMI_KVPATTR_DEF == aReqattr)
             {
+                // return default
             }
             else
             {
@@ -173,7 +201,40 @@
                 aParameters[0].value.key_specific_value = (void*)rui32;
             }
             break;
-
+#ifdef _TEST_AE_ERROR_HANDLING
+        case ERROR_START_ADDMEMFRAG:
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iErrorHandlingAddMemFrag;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // return default
+                aParameters[0].value.bool_value  = true;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+        case ERROR_START_ADDTRACK:
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iErrorHandlingAddTrack;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // return default
+                aParameters[0].value.bool_value  = true;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+#endif
         default:
             // Invalid index
             oscl_free(aParameters[0].key);
@@ -203,7 +264,7 @@
 
     // Retrieve the fourth component from the key string
     char* compstr = NULL;
-    pv_mime_string_extract_type(1, aParameter.key, compstr);
+    pv_mime_string_extract_type(3, aParameter.key, compstr);
 
     int32 mp4comp4ind;
     for (mp4comp4ind = 0; mp4comp4ind < MP4COMPOSERNODECONFIG_BASE_NUMKEYS; ++mp4comp4ind)
@@ -248,7 +309,100 @@
                 iCacheSize = aParameter.value.uint32_value ;
             }
             break;
+#ifdef _TEST_AE_ERROR_HANDLING
+        case ERROR_START_ADDMEMFRAG:
+            // change the parameter
+            if (aSetParam)
+            {
+                // set any parameter here
+                iErrorHandlingAddMemFrag = aParameter.value.bool_value ;
+            }
+            break;
+        case ERROR_START_ADDTRACK:
+            // change the parameter
+            if (aSetParam)
+            {
+                // set any parameter here
+                iErrorHandlingAddTrack = aParameter.value.bool_value ;
+            }
+            break;
+        case ERROR_ADDTRACK: //error in AddTrack()
+            if (aSetParam)
+            {
+                //char* paramstr = NULL;
+                char* val_key = aParameter.value.pChar_value;
+                if (pv_mime_strcmp(val_key, "PVMF_MIME_H264_VIDEO_MP4") == 0)
+                {
+                    iErrorAddTrack = PVMF_MIME_H264_VIDEO_MP4;
+                }
+                if (pv_mime_strcmp(val_key, "PVMF_MIME_3GPP_TIMEDTEXT") == 0)
+                {
+                    iErrorAddTrack = PVMF_MIME_3GPP_TIMEDTEXT;
+                }
+                if (pv_mime_strcmp(val_key, "PVMF_MIME_M4V") == 0)
+                {
+                    iErrorAddTrack = PVMF_MIME_M4V;
+                }
+                if (pv_mime_strcmp(val_key, "PVMF_MIME_H2631998") == 0)
+                {
+                    iErrorAddTrack = PVMF_MIME_H2631998;
+                }
+                if (pv_mime_strcmp(val_key, "PVMF_MIME_H2632000") == 0)
+                {
+                    iErrorAddTrack = PVMF_MIME_H2632000;
+                }
+                if (pv_mime_strcmp(val_key, "PVMF_MIME_AMR_IETF") == 0)
+                {
+                    iErrorAddTrack = PVMF_MIME_AMR_IETF;
+                }
 
+            }
+            break;
+        case ERROR_NODE_CMD:
+            if (aSetParam)
+            {
+                iErrorNodeCmd = aParameter.value.uint32_value;
+            }
+            break;
+        case ERROR_CREATE_COMPOSER:
+            if (aSetParam)
+            {
+                iErrorCreateComposer = aParameter.value.bool_value ;
+            }
+            break;
+        case ERROR_RENDERTOFILE:
+            if (aSetParam)
+            {
+                iErrorRenderToFile = aParameter.value.bool_value ;
+            }
+            break;
+        case ERROR_ADD_SAMPLE:
+            if (aSetParam)
+            {
+                char* paramstr = NULL;
+                OSCL_HeapString<OsclMemAllocator> mode1 = "mode=filesize";
+                OSCL_HeapString<OsclMemAllocator> mode2 = "mode=duration";
+
+                if (pv_mime_string_parse_param(aParameter.key, mode1.get_str(), paramstr) > 0)
+                {
+                    iFileSize = aParameter.value.uint32_value;
+                    iErrorAddSample = 1;
+                }
+                else if (pv_mime_string_parse_param(aParameter.key, mode2.get_str(), paramstr) > 0)
+                {
+                    iFileDuration = aParameter.value.uint32_value;
+                    iErrorAddSample = 2;
+                }
+
+            }
+            break;
+        case ERROR_DATAPATH_STALL:
+            if (aSetParam)
+            {
+                iErrorDataPathStall = aParameter.value.uint32_value;
+            }
+            break;
+#endif
         default:
             OSCL_ASSERT(0);
     }
@@ -332,9 +486,9 @@
         char* compstr = NULL;
         pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
 
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("fileio")) < 0) || compcount < 2)
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/composer/mp4")) < 0) || compcount < 2)
         {
-            // First 2 components should be "fileio" and there must
+            // First 2 components should be "x-pvmf/composer/mp4" and there must
             // be at least four components
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::verifyParametersSync() Unsupported key"));
             return PVMFErrNotSupported;
@@ -380,9 +534,9 @@
     char* compstr = NULL;
     pv_mime_string_extract_type(0, aParameters[0].key, compstr);
 
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("fileio")) < 0) || compcount < 2)
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/composer/mp4")) < 0) || compcount < 2)
     {
-        // First 2 component should be "fileio" and there must
+        // First 2 component should be "x-pvmf/composer/mp4" and there must
         // be at least two components
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::releaseParameters() Unsupported key"));
         return PVMFErrNotSupported;
@@ -427,7 +581,7 @@
                 aParameters[ii].value.key_specific_value = NULL;
                 oscl_free(rui32);
             }
-            // TODO Add more types if composer node starts returning more types
+            // @TODO Add more types if composer node starts returning more types
         }
     }
 
@@ -460,9 +614,9 @@
     char* compstr = NULL;
     pv_mime_string_extract_type(0, aIdentifier, compstr);
 
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("fileio")) < 0) || compcount < 2)
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/composer/mp4")) < 0) || compcount < 2)
     {
-        // First 2 components should be "fileio" and there must
+        // First 2 components should be "x-pvmf/composer/mp4" and there must
         // be at least 2 components
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::getParametersSync() Invalid key string"));
         return PVMFErrNotSupported;
@@ -539,16 +693,16 @@
         char* compstr = NULL;
         pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
 
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("fileio")) < 0) || compcount < 2)
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/composer/mp4")) < 0) || compcount < 2)
         {
-            // First 2 components should be "fileio" and there must
+            // First 2 components should be "x-pvmf/composer/mp4" and there must
             // be at least 2 components
             aRetKVP = &aParameters[paramind];
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMp4FFComposerNode::setParametersSync() Unsupported key"));
             return;
         }
 
-        if (2 == compcount)
+        if (4 == compcount)
         {
             // Verify and set the passed-in mp4 composer node setting
             PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp
index 3f816eb..0e6f01a 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@
         OsclActiveObject(aPriority, "PVMp4FFComposerPort"),
         iNode(aNode),
         iTrackId(0),
-        iFormat(PVMF_FORMAT_UNKNOWN),
+        iFormat(PVMF_MIME_FORMAT_UNKNOWN),
         iReferencePort(NULL),
         iLastTS(0),
         iEndOfDataReached(false)
@@ -139,8 +139,10 @@
         return PVMFFailure;
     }
 
-    PvmiCapabilityAndConfig* config = NULL;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
     if (!config)
     {
         LOG_ERR((0, "PVMp4FFComposerPort::Connect: Error - Peer port does not support capability interface"));
@@ -204,8 +206,10 @@
 
     // When connection is initiated by peer, this port still needs to query the peer
     // for input format configuration data
-    PvmiCapabilityAndConfig* config = NULL;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
     if (!config)
     {
         LOG_ERR((0, "PVMp4FFComposerPort::PeerConnect: Error - Peer port does not support capability interface"));
@@ -255,34 +259,36 @@
     num_parameter_elements = 0;
     PVMFStatus status = PVMFFailure;
 
-    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
+    //identifier is a key and is assumed to be null terminated
+    if (oscl_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
     {
-        num_parameter_elements = 5;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
+        num_parameter_elements = 6;
+        status = AllocateKvp(parameters, (PvmiKeyType)INPUT_FORMATS_VALTYPE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMp4FFComposerPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            parameters[0].value.uint32_value = PVMF_AMR_IETF;
-            parameters[1].value.uint32_value = PVMF_M4V;
-            parameters[2].value.uint32_value = PVMF_H263;
-            parameters[3].value.uint32_value = PVMF_H264_MP4;
-            parameters[4].value.uint32_value = PVMF_3GPP_TIMEDTEXT;
+            parameters[0].value.pChar_value = (char*)PVMF_MIME_AMR_IETF;
+            parameters[1].value.pChar_value = (char*)PVMF_MIME_M4V;
+            parameters[2].value.pChar_value = (char*)PVMF_MIME_H2631998;
+            parameters[3].value.pChar_value = (char*)PVMF_MIME_H2632000;
+            parameters[4].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_MP4;
+            parameters[5].value.pChar_value = (char*)PVMF_MIME_3GPP_TIMEDTEXT;
         }
     }
-    else if (pv_mime_strcmp(identifier, INPUT_FORMATS_CUR_QUERY) == 0)
+    else if (oscl_strcmp(identifier, INPUT_FORMATS_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)INPUT_FORMATS_VALTYPE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMp4FFComposerPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            parameters[0].value.uint32_value = iFormat;
+            parameters[0].value.pChar_value = (char*)iFormat.getMIMEStrPtr();
         }
     }
 
@@ -340,7 +346,7 @@
     OSCL_UNUSED_ARG(session);
 
     ret_kvp = NULL;
-    if (iFormat == PVMF_H264_MP4)
+    if (iFormat == PVMF_MIME_H264_VIDEO_MP4)
     {
         //this code is specific to H264 file format
         for (int32 i = 0;i < num_elements;i++)//assuming the memory is allocated for key
@@ -365,7 +371,7 @@
             }
         }
     }
-    if (iFormat == PVMF_3GPP_TIMEDTEXT)
+    if (iFormat == PVMF_MIME_3GPP_TIMEDTEXT)
     {
         for (int32 i = 0;i < num_elements;i++)//assuming the memory is allocated for keys
         {
@@ -497,7 +503,19 @@
     if (!iEndOfDataReached && (IncomingMsgQueueSize() > 0))
     {
         //dispatch the incoming data.
+#ifdef _TEST_AE_ERROR_HANDLING
+
+        if (1 == iNode->iErrorDataPathStall)
+        {
+            status = PVMFSuccess;
+        }
+        else
+        {
+            status = iNode->ProcessIncomingMsg(this);
+        }
+#else
         status = iNode->ProcessIncomingMsg(this);
+#endif
         switch (status)
         {
             case PVMFSuccess:
@@ -577,21 +595,22 @@
 
     if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0)
     {
-        switch (aKvp->value.uint32_value)
+        if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_3GPP_TIMEDTEXT) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_AMR_IETF) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H264_VIDEO_MP4) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_M4V) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H2631998) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H2632000) == 0)
         {
-            case PVMF_3GPP_TIMEDTEXT:
-            case PVMF_AMR_IETF:
-            case PVMF_H264_MP4:
-            case PVMF_M4V:
-            case PVMF_H263:
-                if (aSetParam)
-                    iFormat = aKvp->value.uint32_value;
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PVMp4FFComposerPort::VerifyAndSetParameter: Error - Unsupported format %d",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
+            if (aSetParam)
+                iFormat = aKvp->value.pChar_value;
+            return PVMFSuccess;
+        }
+        else
+        {
+            LOG_ERR((0, "PVMp4FFComposerPort::VerifyAndSetParameter: Error - Unsupported format %d",
+                     aKvp->value.uint32_value));
+            return PVMFFailure;
         }
     }
 
@@ -615,7 +634,7 @@
     int32 err = 0;
 
     // Get current output formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, OUTPUT_FORMATS_CUR_QUERY, kvp, numParams, NULL);
+    PVMFStatus status = aConfig->getParametersSync(NULL, (PvmiKeyType)OUTPUT_FORMATS_CUR_QUERY, kvp, numParams, NULL);
     if (status != PVMFSuccess || numParams != 1)
     {
         LOG_ERR((0, "PVMp4FFComposerPort::NegotiateInputSettings: Error - config->getParametersSync(output_formats) failed"));
@@ -623,20 +642,22 @@
     }
 
     // Check if data format from peer is supported
-    switch (kvp->value.uint32_value)
+    if (pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_3GPP_TIMEDTEXT) == 0 ||
+            pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_AMR_IETF) == 0 ||
+            pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_H264_VIDEO_MP4) == 0 ||
+            pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_M4V) == 0 ||
+            pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_H2631998) == 0 ||
+            pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_H2632000) == 0)
     {
-        case PVMF_3GPP_TIMEDTEXT:
-        case PVMF_AMR_IETF:
-        case PVMF_H264_MP4:
-        case PVMF_M4V:
-        case PVMF_H263:
-            break;
-        default:
-            return PVMFErrNotSupported;
+        // do nothing
+    }
+    else
+    {
+        return PVMFErrNotSupported;
     }
 
     // Set format of this port, peer port and container node
-    iFormat = kvp->value.uint32_value;
+    iFormat = kvp->value.pChar_value;
     OSCL_TRY(err, aConfig->setParametersSync(NULL, kvp, 1, retKvp););
     OSCL_FIRST_CATCH_ANY(err,
                          LOG_ERR((0, "PVMp4FFComposerPort::NegotiateInputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
@@ -660,25 +681,28 @@
     int numParams = 0;
 
     // Get data bitrate from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, OUTPUT_BITRATE_CUR_QUERY, kvp, numParams, NULL);
+    PVMFStatus status = aConfig->getParametersSync(NULL, (PvmiKeyType)OUTPUT_BITRATE_CUR_QUERY, kvp, numParams, NULL);
     if (status != PVMFSuccess || !kvp || numParams != 1)
     {
         LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Bitrate info not available. Use default"));
-        switch (iFormat)
+        if (iFormat == PVMF_MIME_3GPP_TIMEDTEXT)
         {
-            case PVMF_3GPP_TIMEDTEXT:
-                iFormatSpecificConfig.iBitrate = PVMF_MP4FFCN_TEXT_BITRATE;
-                break;
-            case PVMF_AMR_IETF:
-                iFormatSpecificConfig.iBitrate = PVMF_MP4FFCN_AUDIO_BITRATE;
-                break;
-            case PVMF_H264_MP4:
-            case PVMF_M4V:
-            case PVMF_H263:
-                iFormatSpecificConfig.iBitrate = PVMF_MP4FFCN_VIDEO_BITRATE;
-                break;
-            default:
-                return PVMFErrNotSupported;
+            iFormatSpecificConfig.iBitrate = PVMF_MP4FFCN_TEXT_BITRATE;
+        }
+        else if (iFormat == PVMF_MIME_AMR_IETF)
+        {
+            iFormatSpecificConfig.iBitrate = PVMF_MP4FFCN_AUDIO_BITRATE;
+        }
+        else if (iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+                 iFormat == PVMF_MIME_M4V ||
+                 iFormat == PVMF_MIME_H2631998 ||
+                 iFormat == PVMF_MIME_H2632000)
+        {
+            iFormatSpecificConfig.iBitrate = PVMF_MP4FFCN_VIDEO_BITRATE;
+        }
+        else
+        {
+            return PVMFErrNotSupported;
         }
     }
     else
@@ -690,141 +714,142 @@
     numParams = 0;
 
     // Get timescale from peer
-    switch (iFormat)
+    if (iFormat == PVMF_MIME_AMR_IETF)
     {
-        case PVMF_AMR_IETF:
-            status = aConfig->getParametersSync(NULL, AUDIO_OUTPUT_SAMPLING_RATE_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || !kvp || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Sampling rate info not available. Use default"));
-                iFormatSpecificConfig.iTimescale = PVMF_MP4FFCN_AUDIO_TIMESCALE;
-            }
-            else
-            {
-                iFormatSpecificConfig.iTimescale = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
-            break;
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)AUDIO_OUTPUT_SAMPLING_RATE_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Sampling rate info not available. Use default"));
+            iFormatSpecificConfig.iTimescale = PVMF_MP4FFCN_AUDIO_TIMESCALE;
+        }
+        else
+        {
+            iFormatSpecificConfig.iTimescale = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
+    }
+    else if (iFormat == PVMF_MIME_H2631998 ||
+             iFormat == PVMF_MIME_H2632000)
+    {
+        iFormatSpecificConfig.iH263Profile = PVMF_MP4FFCN_VIDEO_H263_PROFILE;
+        iFormatSpecificConfig.iH263Level = PVMF_MP4FFCN_VIDEO_H263_LEVEL;
+        // Do not break here. Continue to configure the other video parameters
+    }
+    else if (iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+             iFormat == PVMF_MIME_M4V)
+    {
+        iFormatSpecificConfig.iIFrameInterval = PVMF_MP4FFCN_VIDEO_IFRAME_INTERVAL;
+        iFormatSpecificConfig.iRateControlType = PVMP4FFCN_RATE_CONTROL_CBR;
 
-        case PVMF_H263:
-            iFormatSpecificConfig.iH263Profile = PVMF_MP4FFCN_VIDEO_H263_PROFILE;
-            iFormatSpecificConfig.iH263Level = PVMF_MP4FFCN_VIDEO_H263_LEVEL;
-            // Do not break here. Continue to configure the other video parameters
+        // Get size (in pixels) of video data from peer
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)VIDEO_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame width not available. Use default"));
+            iFormatSpecificConfig.iWidth = PVMF_MP4FFCN_VIDEO_FRAME_WIDTH;
+        }
+        else
+        {
+            iFormatSpecificConfig.iWidth = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
 
-        case PVMF_H264_MP4:
-        case PVMF_M4V:
-            iFormatSpecificConfig.iIFrameInterval = PVMF_MP4FFCN_VIDEO_IFRAME_INTERVAL;
-            iFormatSpecificConfig.iRateControlType = PVMP4FFCN_RATE_CONTROL_CBR;
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)VIDEO_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame height info not available. Use default"));
+            iFormatSpecificConfig.iHeight = PVMF_MP4FFCN_VIDEO_FRAME_HEIGHT;
+        }
+        else
+        {
+            iFormatSpecificConfig.iHeight = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
 
-            // Get size (in pixels) of video data from peer
-            status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame width not available. Use default"));
-                iFormatSpecificConfig.iWidth = PVMF_MP4FFCN_VIDEO_FRAME_WIDTH;
-            }
-            else
-            {
-                iFormatSpecificConfig.iWidth = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
+        // Get video frame rate from peer
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame rate not available. Use default"));
+            iFormatSpecificConfig.iFrameRate = PVMF_MP4FFCN_VIDEO_FRAME_RATE;
+        }
+        else
+        {
+            // Set input frame rate of container node
+            iFormatSpecificConfig.iFrameRate = kvp[0].value.float_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
 
-            status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame height info not available. Use default"));
-                iFormatSpecificConfig.iHeight = PVMF_MP4FFCN_VIDEO_FRAME_HEIGHT;
-            }
-            else
-            {
-                iFormatSpecificConfig.iHeight = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)OUTPUT_TIMESCALE_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Sampling rate info not available. Use default"));
+            iFormatSpecificConfig.iTimescale = PVMF_MP4FFCN_VIDEO_TIMESCALE;
+        }
+        else
+        {
+            iFormatSpecificConfig.iTimescale = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
+    }
+    else if (iFormat == PVMF_MIME_3GPP_TIMEDTEXT)
+    {
+        // Get size (in pixels) of Text data from peer
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)TEXT_INPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame width not available. Use default"));
+            iFormatSpecificConfig.iWidth = PVMF_MP4FFCN_TEXT_FRAME_WIDTH;
+        }
+        else
+        {
+            iFormatSpecificConfig.iWidth = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
 
-            // Get video frame rate from peer
-            status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame rate not available. Use default"));
-                iFormatSpecificConfig.iFrameRate = PVMF_MP4FFCN_VIDEO_FRAME_RATE;
-            }
-            else
-            {
-                // Set input frame rate of container node
-                iFormatSpecificConfig.iFrameRate = kvp[0].value.float_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)TEXT_INPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame height info not available. Use default"));
+            iFormatSpecificConfig.iHeight = PVMF_MP4FFCN_TEXT_FRAME_HEIGHT;
+        }
+        else
+        {
+            iFormatSpecificConfig.iHeight = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
 
-            status = aConfig->getParametersSync(NULL, OUTPUT_TIMESCALE_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || !kvp || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Sampling rate info not available. Use default"));
-                iFormatSpecificConfig.iTimescale = PVMF_MP4FFCN_VIDEO_TIMESCALE;
-            }
-            else
-            {
-                iFormatSpecificConfig.iTimescale = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
-            break;
-        case PVMF_3GPP_TIMEDTEXT:
-            // Get size (in pixels) of Text data from peer
-            status = aConfig->getParametersSync(NULL, TEXT_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame width not available. Use default"));
-                iFormatSpecificConfig.iWidth = PVMF_MP4FFCN_TEXT_FRAME_WIDTH;
-            }
-            else
-            {
-                iFormatSpecificConfig.iWidth = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
-
-            status = aConfig->getParametersSync(NULL, TEXT_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Frame height info not available. Use default"));
-                iFormatSpecificConfig.iHeight = PVMF_MP4FFCN_TEXT_FRAME_HEIGHT;
-            }
-            else
-            {
-                iFormatSpecificConfig.iHeight = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
-
-            status = aConfig->getParametersSync(NULL, OUTPUT_TIMESCALE_CUR_QUERY, kvp, numParams, NULL);
-            if (status != PVMFSuccess || !kvp || numParams != 1)
-            {
-                LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Sampling rate info not available. Use default"));
-                iFormatSpecificConfig.iTimescale = PVMF_MP4FFCN_TEXT_TIMESCALE;
-            }
-            else
-            {
-                iFormatSpecificConfig.iTimescale = kvp[0].value.uint32_value;
-                aConfig->releaseParameters(NULL, kvp, numParams);
-            }
-            kvp = NULL;
-            numParams = 0;
-            break;
-
-
-        default:
-            return PVMFErrNotSupported;
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)OUTPUT_TIMESCALE_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            LOG_DEBUG((0, "PVMp4FFComposerPort::GetInputParametersFromPeer: Sampling rate info not available. Use default"));
+            iFormatSpecificConfig.iTimescale = PVMF_MP4FFCN_TEXT_TIMESCALE;
+        }
+        else
+        {
+            iFormatSpecificConfig.iTimescale = kvp[0].value.uint32_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+        kvp = NULL;
+        numParams = 0;
+    }
+    else
+    {
+        return PVMFErrNotSupported;
     }
 
     return PVMFSuccess;
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h
index b23bf9e..fbda5e1 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -121,18 +121,24 @@
         void SetFormat(PVMFFormatType aFormat)
         {
             iFormat = aFormat;
+            iMimeType = aFormat.getMIMEStrPtr();
         }
         PVMFFormatType GetFormat()
         {
             return iFormat;
         }
+        OSCL_String& GetMimeType()
+        {
+            return iMimeType;
+        }
         PVMP4FFCNFormatSpecificConfig* GetFormatSpecificConfig()
         {
             PvmiCapabilityAndConfig* config = NULL;
             if (iConnectedPort)
             {
-                iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                               (OsclAny*&)config);
+                OsclAny* temp = NULL;
+                iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
                 if (config)
                 {
                     GetInputParametersFromPeer(config);
@@ -227,6 +233,9 @@
         OsclMemAllocator iAlloc;
         PVLogger* iLogger;
         bool iEndOfDataReached;
+
+        //logging
+        OSCL_HeapString<OsclMemAllocator> iMimeType;
 };
 
 #endif // PVMP4FFCN_PORT_H_INCLUDED
diff --git a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h
index ee9a724..d342565 100644
--- a/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h
+++ b/nodes/pvmp4ffcomposernode/src/pvmp4ffcn_tunables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffparsernode/Android.mk b/nodes/pvmp4ffparsernode/Android.mk
index c190947..d2fc868 100644
--- a/nodes/pvmp4ffparsernode/Android.mk
+++ b/nodes/pvmp4ffparsernode/Android.mk
@@ -3,36 +3,33 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_mp4ffparser_node.cpp \
-	src/pvmf_mp4ffparser_factory.cpp \
-	src/pvmf_mp4ffparser_outport.cpp \
-	src/pvmf_mp4ffparser_node_metadata.cpp \
-	src/pvmf_mp4ffparser_node_cap_config.cpp
-
+ 	src/pvmf_mp4ffparser_factory.cpp \
+ 	src/pvmf_mp4ffparser_outport.cpp \
+ 	src/pvmf_mp4ffparser_node_metadata.cpp \
+ 	src/pvmf_mp4ffparser_node_cap_config.cpp
 
 
 LOCAL_MODULE := libpvmp4ffparsernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)/fileformats/mp4/parser/include \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/include \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/src \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/src/default \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/../../fileformats/mp4/parser/include/ \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/../../fileformats/mp4/parser/config/opencore \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/../common/include \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/../../pvmi/pvmf/include \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/../../codecs_v2/utilities/m4v_config_parser/include \
-	$(PV_TOP)//nodes/pvmp4ffparsernode/../../codecs_v2/audio/aac/dec/util/getactualaacconfig/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvmp4ffparsernode/src \
+ 	$(PV_TOP)/nodes/pvmp4ffparsernode/include \
+ 	$(PV_TOP)/nodes/pvmp4ffparsernode/src/default \
+ 	$(PV_TOP)/fileformats/mp4/parser/utils/mp4recognizer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_mp4ffparser_factory.h \
-	include/pvmf_mp4ffparser_events.h
+ 	include/pvmf_mp4ffparser_events.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvmp4ffparsernode/build_opencore/make/local.mk b/nodes/pvmp4ffparsernode/build_opencore/make/local.mk
new file mode 100644
index 0000000..a656e43
--- /dev/null
+++ b/nodes/pvmp4ffparsernode/build_opencore/make/local.mk
@@ -0,0 +1,28 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4ffparsernode
+
+
+
+
+XINCDIRS += ../../src/default 
+XINCDIRS += ../../../../fileformats/mp4/parser/utils/mp4recognizer/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_mp4ffparser_node.cpp pvmf_mp4ffparser_factory.cpp pvmf_mp4ffparser_outport.cpp pvmf_mp4ffparser_node_metadata.cpp pvmf_mp4ffparser_node_cap_config.cpp
+
+HDRS := pvmf_mp4ffparser_factory.h \
+	pvmf_mp4ffparser_events.h
+
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvmp4ffparsernode/build_opencore/make/makefile b/nodes/pvmp4ffparsernode/build_opencore/make/makefile
deleted file mode 100644
index 8f3fa1f..0000000
--- a/nodes/pvmp4ffparsernode/build_opencore/make/makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4ffparsernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this so that correct headers for player get included
-XINCDIRS += -I../../src/default
-XINCDIRS += -I../../../../fileformats/mp4/parser/include/ -I../../../../fileformats/mp4/parser/config/opencore
-XINCDIRS += -I ../../../common/include -I../../../../pvmi/pvmf/include
-XINCDIRS += -I../../../../codecs_v2/utilities/m4v_config_parser/include
-XINCDIRS += -I../../../../codecs_v2/audio/aac/dec/util/getactualaacconfig/include
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_mp4ffparser_node.cpp pvmf_mp4ffparser_factory.cpp pvmf_mp4ffparser_outport.cpp pvmf_mp4ffparser_node_metadata.cpp pvmf_mp4ffparser_node_cap_config.cpp
-
-HDRS =  pvmf_mp4ffparser_factory.h \
-	pvmf_mp4ffparser_events.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_defs.h b/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_defs.h
index d249537..817ce53 100644
--- a/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_defs.h
+++ b/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
 // Capability mime strings
 #define PVMF_MP4FFPARSER_PORT_INPUT_FORMATS "x-pvmf/parser/mp4ff/input_formats"
 //#define PVMF_MP4FFPARSER_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/parser/mp4ff/input_formats;valtype=int32"
-#define PVMF_MP4FFPARSER_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=int32"
+#define PVMF_MP4FFPARSER_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=char*"
 
 #define PVMF_MP4FFPARSER_NODE_PSEUDO_STREAMING_BUFFER_DURATION_IN_MS 4000
 
@@ -58,5 +58,23 @@
 #define MIN_JITTER_BUFFER_DURATION_IN_MS	   1000
 #define MAX_JITTER_BUFFER_DURATION_IN_MS	   10000
 
+// Format Type integer defines
+#define PVMF_MP4_PARSER_NODE_FORMAT_UNKNOWN		0
+#define PVMF_MP4_PARSER_NODE_AMR				1
+#define PVMF_MP4_PARSER_NODE_AMRWB				2
+#define PVMF_MP4_PARSER_NODE_AMR_IETF			3
+#define PVMF_MP4_PARSER_NODE_AMRWB_IETF			4
+#define PVMF_MP4_PARSER_NODE_AMR_IF2			5
+#define PVMF_MP4_PARSER_NODE_ADIF				6
+#define PVMF_MP4_PARSER_NODE_ADTS				7
+#define PVMF_MP4_PARSER_NODE_MPEG4_AUDIO		8
+#define PVMF_MP4_PARSER_NODE_M4V				9
+#define PVMF_MP4_PARSER_NODE_H2631998			10
+#define PVMF_MP4_PARSER_NODE_H2632000			11
+#define PVMF_MP4_PARSER_NODE_H264_RAW			12
+#define PVMF_MP4_PARSER_NODE_H264_MP4			13
+#define PVMF_MP4_PARSER_NODE_H264				14
+#define PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT	15
+
 #endif // PVMF_MP4FFPARSER_DEFS_H_INCLUDED
 
diff --git a/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_events.h b/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_events.h
index a002005..32ee02b 100644
--- a/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_events.h
+++ b/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_factory.h b/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_factory.h
index 1cb823b..476f006 100644
--- a/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_factory.h
+++ b/nodes/pvmp4ffparsernode/include/pvmf_mp4ffparser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffparsernode/src/default/pvmf_mp4ffparser_node_tuneables.h b/nodes/pvmp4ffparsernode/src/default/pvmf_mp4ffparser_node_tuneables.h
index a306695..d4c9085 100644
--- a/nodes/pvmp4ffparsernode/src/default/pvmf_mp4ffparser_node_tuneables.h
+++ b/nodes/pvmp4ffparsernode/src/default/pvmf_mp4ffparser_node_tuneables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -74,6 +74,9 @@
 // Number of samples to be retrieved for Best Thumbnail Mode
 #define NUMSAMPLES_BEST_THUMBNAIL_MODE 10
 
+//flag, enable(1) or disable(0) functionality to break up aac frames into multiple media messages
+#define PVMFMP4FF_BREAKUP_AAC_FRAMES_INTO_MULTIPLE_MEDIA_FRAGS 1
+
 #endif // PVMF_MP4FFPARSER_NODE_TUNEABLES_H_INCLUDED
 
 
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_factory.cpp b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_factory.cpp
index 3aabc81..59736e2 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_factory.cpp
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.cpp b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.cpp
index c09414d..be2938b 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.cpp
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 
 #include "impeg4file.h"
 
-
 #include "media_clock_converter.h"
 
 #include "pvlogger.h"
@@ -44,8 +43,6 @@
 
 #include "pvmf_mp4ffparser_events.h"
 
-#include "pvmf_basic_errorinfomessage.h"
-
 #include "pvmf_errorinfomessage_extension.h"
 
 #include "pvmf_download_progress_interface.h"
@@ -78,7 +75,6 @@
 
 #include "oscl_exclusive_ptr.h"
 
-
 #define PVMF_MP4_MIME_FORMAT_AUDIO_UNKNOWN	"x-pvmf/audio/unknown"
 #define PVMF_MP4_MIME_FORMAT_VIDEO_UNKNOWN	"x-pvmf/video/unknown"
 #define PVMF_MP4_MIME_FORMAT_UNKNOWN		"x-pvmf/unknown-media/unknown"
@@ -98,10 +94,16 @@
         iPortIter(NULL),
         iLogger(NULL),
         iBackwardReposFlag(false), /* To avoid backwardlooping :: A flag to remember backward repositioning */
-        iForwardReposFlag(false)
-
+        iForwardReposFlag(false),
+        iPlayBackDirection(PVMF_DATA_SOURCE_DIRECTION_FORWARD),
+        iParseAudioDuringFF(false),
+        iParseAudioDuringREW(false),
+        iParseVideoOnly(false),
+        iDataRate(NORMAL_PLAYRATE),
+        minFileOffsetTrackID(0)
 {
     iClientPlayBackClock = NULL;
+    iClockNotificationsInf = NULL;
     autopaused = false;
     iDownloadFileSize = 0;
     download_progress_interface = NULL;
@@ -122,6 +124,7 @@
     iCPMRequestUsageId = 0;
     iCPMUsageCompleteCmdId = 0;
     iCPMCloseSessionCmdId = 0;
+    iCPMSequenceInProgress = false;
     iCPMResetCmdId = 0;
     iRequestedUsage.key = NULL;
     iApprovedUsage.key = NULL;
@@ -132,6 +135,8 @@
 
     iInterfaceState = EPVMFNodeCreated;
     iParsingMode = PVMF_MP4FF_PARSER_NODE_ENABLE_PARSER_OPTIMIZATION;
+    oIsAACFramesFragmented = PVMFMP4FF_BREAKUP_AAC_FRAMES_INTO_MULTIPLE_MEDIA_FRAGS;
+
     iUseCPMPluginRegistry = false;
     iFileHandle = NULL;
 
@@ -147,10 +152,12 @@
     iFileSizeLastConvertedToTime = 0;
 
     iExternalDownload = false;
+    iUnderFlowEventReported = false;
     iUnderFlowCheckTimer = NULL;
 
     iCPMMetaDataExtensionInterface = NULL;
     iCPMLicenseInterface             = NULL;
+    iCPMLicenseInterfacePVI          = NULL;
     iCPMGetMetaDataKeysCmdId       = 0;
     iCPMGetMetaDataValuesCmdId     = 0;
     iMP4ParserNodeMetadataValueCount = 0;
@@ -183,7 +190,6 @@
 
     iJitterBufferDurationInMs = PVMF_MP4FFPARSER_NODE_PSEUDO_STREAMING_BUFFER_DURATION_IN_MS;
     iBaseKey = INVALID;
-
     iJitterBufferDurationInMs = PVMF_MP4FFPARSER_NODE_PSEUDO_STREAMING_BUFFER_DURATION_IN_MS;
     iBaseKey = INVALID;
 
@@ -203,13 +209,14 @@
              iCapability.iCanSupportMultipleOutputPorts = true;
              iCapability.iHasMaxNumberOfPorts = true;
              iCapability.iMaxNumberOfPorts = 6;
-             iCapability.iInputFormatCapability.push_back(PVMF_MPEG4FF);
-             iCapability.iOutputFormatCapability.push_back(PVMF_AMR_IETF);
-             iCapability.iOutputFormatCapability.push_back(PVMF_AMRWB_IETF);
-             iCapability.iOutputFormatCapability.push_back(PVMF_MPEG4_AUDIO);
-             iCapability.iOutputFormatCapability.push_back(PVMF_M4V);
-             iCapability.iOutputFormatCapability.push_back(PVMF_H263);
-             iCapability.iOutputFormatCapability.push_back(PVMF_H264_MP4);
+             iCapability.iInputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_MPEG4FF));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_AMR_IETF));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_AMRWB_IETF));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_MPEG4_AUDIO));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_M4V));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_H2631998));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_H2632000));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_H264_VIDEO_MP4));
 
              iAvailableMetadataKeys.clear();
 
@@ -243,6 +250,17 @@
 
 PVMFMP4FFParserNode::~PVMFMP4FFParserNode()
 {
+    //remove the clock observer
+    if (iClientPlayBackClock != NULL)
+    {
+        if (iClockNotificationsInf != NULL)
+        {
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iClientPlayBackClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+            iClockNotificationsInf = NULL;
+        }
+    }
+
     LogDiagnostics();
     Cancel();
     if (IsAdded())
@@ -254,12 +272,13 @@
     {
         iUnderFlowCheckTimer->Clear();
     }
-    OSCL_TEMPLATED_DELETE(iUnderFlowCheckTimer, OsclTimer<OsclMemAllocator>, OsclTimer);
+    OSCL_DELETE(iUnderFlowCheckTimer);
 
-    download_progress_clock.Unbind();
     // release the download progress interface if any
-    if (download_progress_interface)
+    if (download_progress_interface != NULL)
     {
+        download_progress_interface->cancelResumeNotification();
+        download_progress_clock.Unbind();
         download_progress_interface->removeRef();
         download_progress_interface = NULL;
     }
@@ -331,6 +350,11 @@
         }
         iLogger = PVLogger::GetLoggerObject("PVMFMP4FFParserNode");
         iDataPathLogger = PVLogger::GetLoggerObject("datapath.sourcenode.mp4parsernode");
+        iAVCDataPathLogger = PVLogger::GetLoggerObject("datapath.sourcenode.mp4parsernode.avc");
+        if (iAVCDataPathLogger != NULL)
+        {
+            iAVCDataPathLogger->DisableAppenderInheritance();
+        }
         iClockLogger = PVLogger::GetLoggerObject("clock");
         iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.mp4parsernode");
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::ThreadLogon() called"));
@@ -359,6 +383,7 @@
         }
         iLogger = NULL;
         iDataPathLogger = NULL;
+        iAVCDataPathLogger = NULL;
         iClockLogger = NULL;
         iDiagnosticsLogger = NULL;
 
@@ -584,6 +609,11 @@
         PVMFCPMPluginLicenseInterface* myInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, this);
         iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
     }
+    else if (uuid == PvmfDataSourceDirectionControlUuid)
+    {
+        PvmfDataSourceDirectionControlInterface* myInterface = OSCL_STATIC_CAST(PvmfDataSourceDirectionControlInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
     else
     {
         return false;
@@ -608,13 +638,13 @@
     PVMFFormatType inputFormatType = aSourceFormat;
 
     /* In case of FT we need to know about it, else init would not complete until the file is fully downloaded */
-    if (inputFormatType == PVMF_DATA_SOURCE_PVX_FILE)
+    if (inputFormatType == PVMF_MIME_DATA_SOURCE_PVX_FILE)
     {
         iFastTrackSession = true;
-        inputFormatType = PVMF_MPEG4FF;
+        inputFormatType = PVMF_MIME_MPEG4FF;
     }
 
-    if (inputFormatType == PVMF_MPEG4FF)
+    if (inputFormatType == PVMF_MIME_MPEG4FF)
     {
         iFilename = aSourceURL;
         iSourceFormat = inputFormatType;
@@ -721,13 +751,33 @@
     return PVMFFailure;
 }
 
-PVMFStatus PVMFMP4FFParserNode::SetClientPlayBackClock(OsclClock* aClock)
+PVMFStatus PVMFMP4FFParserNode::SetClientPlayBackClock(PVMFMediaClock* aClock)
 {
+    if (aClock == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    if (iClockNotificationsInf && iClientPlayBackClock)
+    {
+        iClockNotificationsInf->RemoveClockStateObserver(*this);
+        iClientPlayBackClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+        iClockNotificationsInf = NULL;
+    }
     iClientPlayBackClock = aClock;
+    iClientPlayBackClock->ConstructMediaClockNotificationsInterface(iClockNotificationsInf, *this);
+
+    if (NULL == iClockNotificationsInf)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    iClockNotificationsInf->SetClockStateObserver(*this);
+
     return PVMFSuccess;
 }
 
-PVMFStatus PVMFMP4FFParserNode::SetEstimatedServerClock(OsclClock* /*aClientClock*/)
+PVMFStatus PVMFMP4FFParserNode::SetEstimatedServerClock(PVMFMediaClock* /*aClientClock*/)
 {
     return PVMFErrNotSupported;
 }
@@ -776,54 +826,14 @@
         uint64 trackDuration = iMP4FileHandle->getTrackMediaDuration(iIdList[i]);
         tmpTrackInfo.setTrackDurationValue(trackDuration);
 
+        OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+        iMP4FileHandle->getTrackMIMEType(iIdList[i], trackMIMEType);
+
         OSCL_FastString iMime;
-        PVMFFormatType trackformattype = PVMF_FORMAT_UNKNOWN;
-        switch (iMP4FileHandle->getTrackOTIType(iIdList[i]))
-        {
-            case MPEG4_VIDEO://PVMF_MIME_M4V
-                iMime = _STRLIT_CHAR(PVMF_MIME_M4V);
-                trackformattype = PVMF_M4V;
-                break;
+        iMime.set(trackMIMEType.get_str(), oscl_strlen(trackMIMEType.get_str()));
 
-            case H263_VIDEO://PVMF_MIME_H2632000
-                iMime = _STRLIT_CHAR(PVMF_MIME_H2632000);
-                trackformattype = PVMF_H263;
-                break;
+        PVMFFormatType trackformattype = trackMIMEType.get_str();
 
-            case AVC_VIDEO: //PVMF_MIME_H264_VIDEO_MP4
-                iMime = _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4);
-                trackformattype = PVMF_H264_MP4;
-                break;
-
-            case MPEG4_AUDIO://PVMF_MIME_M4A
-                iMime = _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO);
-                trackformattype = PVMF_MPEG4_AUDIO;
-                break;
-
-            case MPEG2_AUDIO_LC://PVMF_MIME_M4A
-                iMime = _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO);
-                trackformattype = PVMF_MPEG4_AUDIO;
-                break;
-
-            case AMR_AUDIO_3GPP://PVMF_MIME_AMR_IETF
-                iMime = _STRLIT_CHAR(PVMF_MIME_AMR_IETF);
-                trackformattype = PVMF_AMR_IETF;
-                break;
-
-            case AMRWB_AUDIO_3GPP://PVMF_MIME_AMRWB_IETF
-                iMime = _STRLIT_CHAR(PVMF_MIME_AMRWB_IETF);
-                trackformattype = PVMF_AMRWB_IETF;
-                break;
-
-            case TIMED_TEXT: // PVMF_MIME_3GPP_TIMEDTEXT
-                iMime = _STRLIT_CHAR(PVMF_MIME_3GPP_TIMEDTEXT);
-                trackformattype = PVMF_3GPP_TIMEDTEXT;
-                break;
-
-            default:
-                iMime = _STRLIT_CHAR(PVMF_MIME_FORMAT_UNKNOWN);
-                break;
-        }
         tmpTrackInfo.setTrackMimeType(iMime);
 
         OsclRefCounterMemFrag config;
@@ -919,7 +929,7 @@
     return QueueCommandL(cmd);
 }
 
-PVMFCommandId PVMFMP4FFParserNode::SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, OsclTimebase* aTimebase, OsclAny* aContext)
+PVMFCommandId PVMFMP4FFParserNode::SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, PVMFTimebase* aTimebase, OsclAny* aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::SetDataSourceRate() called"));
 
@@ -928,6 +938,17 @@
     return QueueCommandL(cmd);
 }
 
+PVMFCommandId PVMFMP4FFParserNode::SetDataSourceDirection(PVMFSessionId aSessionId, int32 aDirection, PVMFTimestamp& aActualNPT,
+        PVMFTimestamp& aActualMediaDataTS, PVMFTimebase* aTimebase, OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::SetDataSourceDirection() called"));
+
+    PVMFMP4FFParserNodeCommand cmd;
+    cmd.PVMFMP4FFParserNodeCommand::Construct(aSessionId, PVMP4FF_NODE_CMD_SETDATASOURCEDIRECTION, aDirection, aActualNPT, aActualMediaDataTS,
+            aTimebase, aContext);
+
+    return QueueCommandL(cmd);
+}
 
 PVMFStatus PVMFMP4FFParserNode::GetAvailableTracks(Oscl_Vector<PVMFTrackInfo, OsclMemAllocator>& aTracks)
 {
@@ -1617,6 +1638,11 @@
             }
             break;
 
+        case PVMP4FF_NODE_CMD_SETDATASOURCEDIRECTION:
+            cmdstatus = DoSetDataSourceDirection(aCmd);
+            CommandComplete(iInputCommands, aCmd, cmdstatus);
+            break;
+
         default://unknown command type
             CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
             break;
@@ -1661,9 +1687,7 @@
                 ChangeNodeState(EPVMFNodePrepared);
                 break;
             case PVMF_GENERIC_NODE_RESET:
-                //drive this node back to Created state.
                 ChangeNodeState(EPVMFNodeIdle);
-                ThreadLogoff();
                 break;
         }
     }
@@ -1678,14 +1702,13 @@
     PVMFBasicErrorInfoMessage* errormsg = NULL;
     if (aEventUUID && aEventCode)
     {
-        int32 leavecode = 0;
-        OSCL_TRY(leavecode, errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL)));
+        int32 leavecode = CreateErrorInfoMsg(&errormsg, *aEventUUID, *aEventCode);
         if (leavecode == 0 && errormsg)
         {
             extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
         }
-    }
 
+    }
     //create response
     PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
     PVMFSessionId session = aCmd.iSession;
@@ -1796,7 +1819,7 @@
     bool exactmatch;
     aCmd.PVMFMP4FFParserNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
 
-    // TODO Add MIME string matching
+    // @TODO Add MIME string matching
     // For now just return all available extension interface UUID
     uuidvec->push_back(PVMF_TRACK_SELECTION_INTERFACE_UUID);
     uuidvec->push_back(PVMF_DATA_SOURCE_INIT_INTERFACE_UUID);
@@ -1804,6 +1827,7 @@
     uuidvec->push_back(PvmfDataSourcePlaybackControlUuid);
     uuidvec->push_back(PVMF_TRACK_LEVEL_INFO_INTERFACE_UUID);
     uuidvec->push_back(PVMF_MP4_PROGDOWNLOAD_SUPPORT_INTERFACE_UUID);
+    uuidvec->push_back(PvmfDataSourceDirectionControlUuid);
 
     return PVMFSuccess;
 }
@@ -1855,8 +1879,8 @@
     // Return the pointer to the port in the command complete message
 
     // Determine the format type from the MIME type string
-    PVMFFormatType formattype = GetFormatTypeFromMIMEType(mimetype);
-    if (formattype == PVMF_FORMAT_UNKNOWN)
+    PVMFFormatType formattype = mimetype->get_cstr();
+    if (formattype == PVMF_MIME_FORMAT_UNKNOWN)
     {
         // Unknown track type
         return PVMFErrArgument;
@@ -1869,7 +1893,7 @@
     OSCL_ASSERT(trackmaxdatasize > 0 && trackmaxqueuedepth > 0);
 
     // Track ID is the port tag
-    // TODO might need validation on the port tag==track ID.
+    // @TODO might need validation on the port tag==track ID.
     int32 trackid = tag;
     if (trackid < 0)
     {
@@ -1885,21 +1909,20 @@
     }
 
     //set the names for datapath logging
-    int32 mediatype = GetMediaTypeIndex(formattype);
     OSCL_StackString<20> portname;
     OSCL_StackString<20> mempoolname;
     bool oTextTrack = false;
-    if (mediatype == PVMF_UNCOMPRESSED_AUDIO_FORMAT || mediatype == PVMF_COMPRESSED_AUDIO_FORMAT)
+    if (formattype.isAudio())
     {
         portname = "PVMFMP4FFParOut(Audio)";
         mempoolname = "PVMFMP4FFPar(Audio)";
     }
-    else if (mediatype == PVMF_UNCOMPRESSED_VIDEO_FORMAT || mediatype == PVMF_COMPRESSED_VIDEO_FORMAT)
+    else if (formattype.isVideo())
     {
         portname = "PVMFMP4FFParOut(Video)";
         mempoolname = "PVMFMP4FFPar(Video)";
     }
-    else
+    else if (formattype.isText())
     {
         oTextTrack = true;
         portname = "PVMFMP4FFParOut(Misc)";
@@ -1910,8 +1933,7 @@
     PVMFPortInterface* outport = NULL;
     MediaClockConverter* clockconv = NULL;
     OsclMemPoolResizableAllocator* trackdatamempool = NULL;
-    TrackDataMemPoolProxyAlloc* trackdatamempoolproxy = NULL;
-    PVMFSimpleMediaBufferCombinedAlloc* mediadataimplalloc = NULL;
+    PVMFResizableSimpleMediaMsgAlloc* mediadataimplalloc = NULL;
     PVMFTimedTextMediaDataAlloc* textmediadataimplalloc = NULL;
     PVMFMemPoolFixedChunkAllocator* mediadatamempool = NULL;
     OsclMemPoolFixedChunkAllocator* mediadatagroupimplmempool = NULL;
@@ -1922,9 +1944,7 @@
                  outport = OSCL_NEW(PVMFMP4FFParserOutPort, (tag, this, portname.get_str()));
                  clockconv = OSCL_NEW(MediaClockConverter, (iMP4FileHandle->getTrackMediaTimescale(trackid)));
                  trackdatamempool = OSCL_NEW(OsclMemPoolResizableAllocator, (trackmaxqueuedepth * trackmaxdatasize, PVMF_MP4FF_PARSER_NODE_MEM_POOL_GROWTH_LIMIT));
-                 trackdatamempoolproxy = OSCL_NEW(TrackDataMemPoolProxyAlloc, (*trackdatamempool));
-                 mediadataimplalloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (trackdatamempoolproxy));
-                 textmediadataimplalloc = OSCL_NEW(PVMFTimedTextMediaDataAlloc, (trackdatamempoolproxy));
+                 mediadataimplalloc = OSCL_NEW(PVMFResizableSimpleMediaMsgAlloc, (trackdatamempool));
                  mediadatamempool = OSCL_NEW(PVMFMemPoolFixedChunkAllocator, (mempoolname.get_str(), PVMP4FF_MEDIADATA_POOLNUM, PVMP4FF_MEDIADATA_CHUNKSIZE));
                  mediadatagroupimplmempool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVMP4FF_MEDIADATA_POOLNUM));
                  mediadatagroupalloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (PVMP4FF_MEDIADATA_POOLNUM, 20, mediadatagroupimplmempool));
@@ -1936,16 +1956,31 @@
                  outport = OSCL_NEW(PVMFMP4FFParserOutPort, (tag, this, portname.get_str()));
                  clockconv = OSCL_NEW(MediaClockConverter, (iMP4FileHandle->getTrackMediaTimescale(trackid)));
                  trackdatamempool = OSCL_NEW(OsclMemPoolResizableAllocator, (trackmaxqueuedepth * trackmaxdatasize, PVMF_MP4FF_PARSER_NODE_MEM_POOL_GROWTH_LIMIT));
-                 trackdatamempoolproxy = OSCL_NEW(TrackDataMemPoolProxyAlloc, (*trackdatamempool));
-                 mediadataimplalloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (trackdatamempoolproxy));
-                 textmediadataimplalloc = OSCL_NEW(PVMFTimedTextMediaDataAlloc, (trackdatamempoolproxy));
+                 textmediadataimplalloc = OSCL_NEW(PVMFTimedTextMediaDataAlloc, (trackdatamempool));
                  mediadatamempool = OSCL_NEW(PVMFMemPoolFixedChunkAllocator, (mempoolname.get_str(), PVMP4FF_TEXT_TRACK_MEDIADATA_POOLNUM, PVMP4FF_MEDIADATA_CHUNKSIZE));
                  mediadatagroupimplmempool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVMP4FF_MEDIADATA_POOLNUM));
                  mediadatagroupalloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (PVMP4FF_TEXT_TRACK_MEDIADATA_POOLNUM, 20, mediadatagroupimplmempool));
                 );
     }
-    if (leavecode || !outport || !clockconv || !trackdatamempool || !trackdatamempoolproxy || !mediadataimplalloc ||
-            !textmediadataimplalloc || !mediadatamempool || !mediadatagroupimplmempool || !mediadatagroupalloc)
+
+    bool memerr = false;
+    if (oTextTrack == false)
+    {
+        if (leavecode || !outport || !clockconv || !trackdatamempool || !mediadataimplalloc ||
+                !mediadatamempool || !mediadatagroupimplmempool || !mediadatagroupalloc)
+        {
+            memerr = true;
+        }
+    }
+    else
+    {
+        if (leavecode || !outport || !clockconv || !trackdatamempool ||
+                !textmediadataimplalloc || !mediadatamempool || !mediadatagroupimplmempool || !mediadatagroupalloc)
+        {
+            memerr = true;
+        }
+    }
+    if (memerr == true)
     {
         if (outport)
         {
@@ -1960,10 +1995,6 @@
             trackdatamempool->removeRef();
             trackdatamempool = NULL;
         }
-        if (trackdatamempoolproxy)
-        {
-            OSCL_DELETE(trackdatamempoolproxy);
-        }
         if (mediadataimplalloc)
         {
             OSCL_DELETE(mediadataimplalloc);
@@ -1984,10 +2015,13 @@
         {
             mediadatagroupimplmempool->removeRef();
         }
-
         return PVMFErrNoMemory;
     }
 
+    mediadatagroupimplmempool->enablenullpointerreturn();
+    trackdatamempool->enablenullpointerreturn();
+    mediadatamempool->enablenullpointerreturn();
+
     mediadatagroupalloc->create();
 
     // Add the selected track/port to track list
@@ -1995,10 +2029,29 @@
     trackportinfo.iTrackId = trackid;
     trackportinfo.iPortInterface = outport;
     trackportinfo.iFormatType = formattype;
+    // assign the integer format type based on the format type recieved
+    // these are formats being used during media data flow, so just assign
+    // integer values to these types, others defined as unknown.
+    if (formattype == PVMF_MIME_MPEG4_AUDIO)
+    {
+        trackportinfo.iFormatTypeInteger = PVMF_MP4_PARSER_NODE_MPEG4_AUDIO;
+    }
+    else if (formattype == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        trackportinfo.iFormatTypeInteger = PVMF_MP4_PARSER_NODE_H264_MP4;
+    }
+    else if (formattype == PVMF_MIME_3GPP_TIMEDTEXT)
+    {
+        trackportinfo.iFormatTypeInteger = PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT;
+    }
+    else
+    {
+        trackportinfo.iFormatTypeInteger = PVMF_MP4_PARSER_NODE_FORMAT_UNKNOWN;
+    }
     RetrieveTrackConfigInfo(trackid,
                             formattype,
                             trackportinfo.iFormatSpecificConfig);
-    if (formattype == PVMF_MPEG4_AUDIO)
+    if (formattype == PVMF_MIME_MPEG4_AUDIO)
     {
         RetrieveTrackConfigInfoAndFirstSample(trackid,
                                               formattype,
@@ -2011,7 +2064,6 @@
     trackportinfo.iTrackMaxDataSize = trackmaxdatasize;
     trackportinfo.iTrackMaxQueueDepth = trackmaxqueuedepth;
     trackportinfo.iTrackDataMemoryPool = trackdatamempool;
-    trackportinfo.iTrackDataMemoryPoolProxy = trackdatamempoolproxy;
     trackportinfo.iMediaDataImplAlloc = mediadataimplalloc;
     trackportinfo.iTextMediaDataImplAlloc = textmediadataimplalloc;
     trackportinfo.iMediaDataMemPool = mediadatamempool;
@@ -2021,87 +2073,89 @@
     trackportinfo.iTimestamp = tsStartOffset;
     trackportinfo.iSeqNum = 0;
 
-    switch (formattype)
+    // TEMP: Number of samples to retrieve should be negotiated between
+    // the nodes but for now hardcode the values
+    // By default retrieve one bundle of samples from the file format parser
+    if (formattype == PVMF_MIME_M4V)
     {
-        case PVMF_M4V:
-            trackportinfo.iNumSamples = M4V_NUMSAMPLES;
-            break;
-
-        case PVMF_H263:
-            trackportinfo.iNumSamples = H263_NUMSAMPLES;
-            break;
-
-        case PVMF_H264_MP4:
-            trackportinfo.iNumSamples = H264_MP4_NUMSAMPLES;
-            break;
-
-        case PVMF_MPEG4_AUDIO:
-            trackportinfo.iNumSamples = MPEG4_AUDIO_NUMSAMPLES;
-            break;
-
-        case PVMF_AMR_IETF:
-            if (trackportinfo.iNumAMRSamplesToRetrieve > 0)
+        trackportinfo.iNumSamples = M4V_NUMSAMPLES;
+    }
+    else if (formattype == PVMF_MIME_H2631998 ||
+             formattype == PVMF_MIME_H2632000)
+    {
+        trackportinfo.iNumSamples = H263_NUMSAMPLES;
+    }
+    else if (formattype == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        trackportinfo.iNumSamples = H264_MP4_NUMSAMPLES;
+    }
+    else if (formattype == PVMF_MIME_MPEG4_AUDIO)
+    {
+        trackportinfo.iNumSamples = MPEG4_AUDIO_NUMSAMPLES;
+    }
+    else if (formattype == PVMF_MIME_AMR_IETF)
+    {
+        if (trackportinfo.iNumAMRSamplesToRetrieve > 0)
+        {
+            trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
+        }
+        else
+        {
+            // Need to determine the number of AMR samples to get based on
+            // number of frames to get and number of frames per sample
+            int32 framespersample = iMP4FileHandle->getNumAMRFramesPerSample(trackid);
+            if (framespersample > 0)
             {
-                trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
+                trackportinfo.iNumAMRSamplesToRetrieve = AMR_IETF_NUMFRAMES / framespersample;
+                if (trackportinfo.iNumAMRSamplesToRetrieve == 0 || (AMR_IETF_NUMFRAMES % framespersample > 0))
+                {
+                    // Increment if 0 or if there is a remainder
+                    ++trackportinfo.iNumAMRSamplesToRetrieve;
+                }
             }
             else
             {
-                // Need to determine the number of AMR samples to get based on
-                // number of frames to get and number of frames per sample
-                int32 framespersample = iMP4FileHandle->getNumAMRFramesPerSample(trackid);
-                if (framespersample > 0)
-                {
-                    trackportinfo.iNumAMRSamplesToRetrieve = AMR_IETF_NUMFRAMES / framespersample;
-                    if (trackportinfo.iNumAMRSamplesToRetrieve == 0 || (AMR_IETF_NUMFRAMES % framespersample > 0))
-                    {
-                        // Increment if 0 or if there is a remainder
-                        ++trackportinfo.iNumAMRSamplesToRetrieve;
-                    }
-                }
-                else
-                {
-                    // Assume 1 AMR frame per sample
-                    trackportinfo.iNumAMRSamplesToRetrieve = AMR_IETF_NUMFRAMES;
-                }
+                // Assume 1 AMR frame per sample
+                trackportinfo.iNumAMRSamplesToRetrieve = AMR_IETF_NUMFRAMES;
             }
+        }
+        trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
+    }
+    else if (formattype == PVMF_MIME_AMRWB_IETF)
+    {
+        if (trackportinfo.iNumAMRSamplesToRetrieve > 0)
+        {
             trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
-            break;
-
-        case PVMF_AMRWB_IETF:
-            if (trackportinfo.iNumAMRSamplesToRetrieve > 0)
+        }
+        else
+        {
+            // Need to determine the number of AMR samples to get based on
+            // number of frames to get and number of frames per sample
+            int32 framespersample = iMP4FileHandle->getNumAMRFramesPerSample(trackid);
+            if (framespersample > 0)
             {
-                trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
+                trackportinfo.iNumAMRSamplesToRetrieve = AMRWB_IETF_NUMFRAMES / framespersample;
+                if (trackportinfo.iNumAMRSamplesToRetrieve == 0 || (AMRWB_IETF_NUMFRAMES % framespersample > 0))
+                {
+                    // Increment if 0 or if there is a remainder
+                    ++trackportinfo.iNumAMRSamplesToRetrieve;
+                }
             }
             else
             {
-                // Need to determine the number of AMR samples to get based on
-                // number of frames to get and number of frames per sample
-                int32 framespersample = iMP4FileHandle->getNumAMRFramesPerSample(trackid);
-                if (framespersample > 0)
-                {
-                    trackportinfo.iNumAMRSamplesToRetrieve = AMRWB_IETF_NUMFRAMES / framespersample;
-                    if (trackportinfo.iNumAMRSamplesToRetrieve == 0 || (AMRWB_IETF_NUMFRAMES % framespersample > 0))
-                    {
-                        // Increment if 0 or if there is a remainder
-                        ++trackportinfo.iNumAMRSamplesToRetrieve;
-                    }
-                }
-                else
-                {
-                    // Assume 1 AMRWB frame per sample
-                    trackportinfo.iNumAMRSamplesToRetrieve = AMRWB_IETF_NUMFRAMES;
-                }
+                // Assume 1 AMRWB frame per sample
+                trackportinfo.iNumAMRSamplesToRetrieve = AMRWB_IETF_NUMFRAMES;
             }
-            trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
-            break;
-
-        case PVMF_3GPP_TIMEDTEXT:
-            trackportinfo.iNumSamples = TIMEDTEXT_NUMSAMPLES;
-            break;
-
-        default:
-            trackportinfo.iNumSamples = UNKNOWN_NUMSAMPLES;
-            break;
+        }
+        trackportinfo.iNumSamples = trackportinfo.iNumAMRSamplesToRetrieve;
+    }
+    else if (formattype == PVMF_MIME_3GPP_TIMEDTEXT)
+    {
+        trackportinfo.iNumSamples = TIMEDTEXT_NUMSAMPLES;
+    }
+    else
+    {
+        trackportinfo.iNumSamples = UNKNOWN_NUMSAMPLES;
     }
 
     if (iPortDataLog)
@@ -2109,13 +2163,11 @@
         OSCL_StackString<512> portLoggerTag(_STRLIT_CHAR("PVMFMP4ParserNode"));
         portLoggerTag += iLogFileIndex;
         iLogFileIndex += 1;
-        if (mediatype == PVMF_UNCOMPRESSED_AUDIO_FORMAT ||
-                mediatype == PVMF_COMPRESSED_AUDIO_FORMAT)
+        if (formattype.isAudio())
         {
             portLoggerTag += _STRLIT_CHAR("audio");
         }
-        else if (mediatype == PVMF_UNCOMPRESSED_VIDEO_FORMAT ||
-                 mediatype == PVMF_COMPRESSED_VIDEO_FORMAT)
+        else if (formattype.isVideo())
         {
             portLoggerTag += _STRLIT_CHAR("video");
         }
@@ -2152,49 +2204,48 @@
 }
 
 
-void PVMFMP4FFParserNode::GetTrackMaxParameters(PVMFFormatType& aFormatType, uint32& aMaxDataSize, uint32& aMaxQueueDepth)
+void PVMFMP4FFParserNode::GetTrackMaxParameters(PVMFFormatType aFormatType, uint32& aMaxDataSize, uint32& aMaxQueueDepth)
 {
-    switch (aFormatType)
+    if (aFormatType == PVMF_MIME_M4V)
     {
-        case PVMF_M4V:
-            aMaxDataSize = M4V_MAXTRACKDATASIZE;
-            aMaxQueueDepth = M4V_MAXTRACKQUEUEDEPTH;
-            break;
-
-        case PVMF_H263:
-            aMaxDataSize = H263_MAXTRACKDATASIZE;
-            aMaxQueueDepth = H263_MAXTRACKQUEUEDEPTH;
-            break;
-
-        case PVMF_H264_MP4:
-            aMaxDataSize = H264_MP4_MAXTRACKDATASIZE;
-            aMaxQueueDepth = H264_MP4_MAXTRACKQUEUEDEPTH;
-            break;
-
-        case PVMF_MPEG4_AUDIO:
-            aMaxDataSize = MPEG4_AUDIO_MAXTRACKDATASIZE;
-            aMaxQueueDepth = MPEG4_AUDIO_MAXTRACKQUEUEDEPTH;
-            break;
-
-        case PVMF_AMR_IETF:
-            aMaxDataSize = AMR_IETF_MAXTRACKDATASIZE;
-            aMaxQueueDepth = AMR_IETF_MAXTRACKQUEUEDEPTH;
-            break;
-
-        case PVMF_AMRWB_IETF:
-            aMaxDataSize = AMRWB_IETF_MAXTRACKDATASIZE;
-            aMaxQueueDepth = AMRWB_IETF_MAXTRACKQUEUEDEPTH;
-            break;
-
-        case PVMF_3GPP_TIMEDTEXT:
-            aMaxDataSize = TIMEDTEXT_MAXTRACKDATASIZE;
-            aMaxQueueDepth = TIMEDTEXT_MAXTRACKQUEUEDEPTH;
-            break;
-
-        default:
-            aMaxDataSize = UNKNOWN_MAXTRACKDATASIZE;
-            aMaxQueueDepth = UNKNOWN_MAXTRACKQUEUEDEPTH;
-            break;
+        aMaxDataSize = M4V_MAXTRACKDATASIZE;
+        aMaxQueueDepth = M4V_MAXTRACKQUEUEDEPTH;
+    }
+    else if (aFormatType == PVMF_MIME_H2631998 ||
+             aFormatType == PVMF_MIME_H2632000)
+    {
+        aMaxDataSize = H263_MAXTRACKDATASIZE;
+        aMaxQueueDepth = H263_MAXTRACKQUEUEDEPTH;
+    }
+    else if (aFormatType == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        aMaxDataSize = H264_MP4_MAXTRACKDATASIZE;
+        aMaxQueueDepth = H264_MP4_MAXTRACKQUEUEDEPTH;
+    }
+    else if (aFormatType == PVMF_MIME_MPEG4_AUDIO)
+    {
+        aMaxDataSize = MPEG4_AUDIO_MAXTRACKDATASIZE;
+        aMaxQueueDepth = MPEG4_AUDIO_MAXTRACKQUEUEDEPTH;
+    }
+    else if (aFormatType == PVMF_MIME_AMR_IETF)
+    {
+        aMaxDataSize = AMR_IETF_MAXTRACKDATASIZE;
+        aMaxQueueDepth = AMR_IETF_MAXTRACKQUEUEDEPTH;
+    }
+    else if (aFormatType == PVMF_MIME_AMRWB_IETF)
+    {
+        aMaxDataSize = AMRWB_IETF_MAXTRACKDATASIZE;
+        aMaxQueueDepth = AMRWB_IETF_MAXTRACKQUEUEDEPTH;
+    }
+    else if (aFormatType == PVMF_MIME_3GPP_TIMEDTEXT)
+    {
+        aMaxDataSize = TIMEDTEXT_MAXTRACKDATASIZE;
+        aMaxQueueDepth = TIMEDTEXT_MAXTRACKQUEUEDEPTH;
+    }
+    else
+    {
+        aMaxDataSize = UNKNOWN_MAXTRACKDATASIZE;
+        aMaxQueueDepth = UNKNOWN_MAXTRACKQUEUEDEPTH;
     }
 }
 
@@ -2227,13 +2278,10 @@
             }
             if (iNodeTrackPortList[i].iTrackDataMemoryPool)
             {
+                iNodeTrackPortList[i].iTrackDataMemoryPool->CancelFreeChunkAvailableCallback();
                 iNodeTrackPortList[i].iTrackDataMemoryPool->removeRef();
                 iNodeTrackPortList[i].iTrackDataMemoryPool = NULL;
             }
-            if (iNodeTrackPortList[i].iTrackDataMemoryPoolProxy)
-            {
-                OSCL_DELETE(iNodeTrackPortList[i].iTrackDataMemoryPoolProxy);
-            }
             if (iNodeTrackPortList[i].iMediaDataImplAlloc)
             {
                 OSCL_DELETE(iNodeTrackPortList[i].iMediaDataImplAlloc);
@@ -2244,7 +2292,8 @@
             }
             if (iNodeTrackPortList[i].iMediaDataMemPool)
             {
-                OSCL_DELETE(iNodeTrackPortList[i].iMediaDataMemPool);
+                iNodeTrackPortList[i].iMediaDataMemPool->CancelFreeChunkAvailableCallback();
+                iNodeTrackPortList[i].iMediaDataMemPool->removeRef();
             }
             if (iNodeTrackPortList[i].iMediaDataGroupAlloc)
             {
@@ -2316,7 +2365,7 @@
                 retval = iMP4FileHandle->peekNextBundledAccessUnits(trackID,
                          &numSamples,
                          &info);
-                if (retval == EVERYTHING_FINE || END_OF_TRACK == retval)
+                if ((retval == EVERYTHING_FINE || END_OF_TRACK == retval) && numSamples > 0)
                 {
                     uint32 sampleSize = info.len;
                     if (sampleSize > 0)
@@ -2475,6 +2524,15 @@
                         &eventcode);
         return oRet;
     }
+    if (iExternalDownload == true)
+    {
+        oRet = iMP4FileHandle->CreateDataStreamSessionForExternalDownload(iFilename,
+                dsFactory,
+                iFileHandle,
+                &iFileServer);
+        if (!oRet)
+            return oRet;
+    }
 
     PVMFStatus status = InitMetaData();
 
@@ -2606,13 +2664,19 @@
                 iMP4FileHandle->RequestReadCapacityNotification(*this, offset);
             if (retVal == EVERYTHING_FINE)
             {
+                // parser node will not report underflow in this case but will set the
+                // variables so that data ready event can be send to engine once datastream
+                // downloads requested data.
                 autopaused = true;
-                ReportUnderFlow();
-                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoPrepare - Reporting Underflow - Holding off on Prepare Complete"));
+                iUnderFlowEventReported = true;
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoPrepare - Holding off on Prepare Complete because of Insufficient Downloaded Data"));
                 return PVMFPending;
             }
             else if (retVal == SUFFICIENT_DATA_IN_FILE)
             {
+                // report prepare success and send data ready event to engine.
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoPrepare - Sufficient data in file, send success and data ready event"));
+                ReportMP4FFParserInfoEvent(PVMFInfoDataReady);
                 return PVMFSuccess;
             }
             PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoPrepare - RequestReadCapacityNotification Failed - Ret=%d",  retVal));
@@ -2685,7 +2749,7 @@
     OSCL_UNUSED_ARG(aCmd);
 
     LogDiagnostics();
-
+    iStreamID = 0;
     if (iInterfaceState != EPVMFNodeStarted &&
             iInterfaceState != EPVMFNodePaused)
     {
@@ -2695,6 +2759,13 @@
     // stop and reset position to beginning
     ResetAllTracks();
 
+    // reset direction rate state variables
+    iPlayBackDirection = PVMF_DATA_SOURCE_DIRECTION_FORWARD;
+    iParseAudioDuringFF = false;
+    iParseAudioDuringREW = false;
+    iParseVideoOnly = false;
+    iDataRate = NORMAL_PLAYRATE;
+
     // Reset the MP4 FF to beginning
     if (iMP4FileHandle)
     {
@@ -2745,6 +2816,32 @@
         return PVMFErrInvalidState;
     }
 
+    if (!iUnderFlowEventReported && iExternalDownload)
+    {
+        /*
+         * Since sourcenode is in paused state, so ..
+         * Reset all PS related variable,
+         * Cancel the underflow timer so that no underflow event could be sent in paused state,
+         * Set all tracks state to GETDATA.
+         */
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger,  PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::DoPause() - SN is paused, cancel UF timer, reset all PS variables"));
+        for (uint32 i = 0; i < iNodeTrackPortList.size(); ++i)
+        {
+            iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
+        }
+        autopaused = false;
+        iUnderFlowCheckTimer->Cancel(PVMF_MP4FFPARSERNODE_UNDERFLOW_STATUS_TIMER_ID);
+
+        // Cancel any DS callback since Sourcenode is Paused.
+        MP4_ERROR_CODE retVal = iMP4FileHandle->CancelNotificationSync();
+
+        if (retVal != EVERYTHING_FINE)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::DoPause() - Error in Cancelling, Logging this."));
+            OSCL_ASSERT(retVal);
+        }
+
+    }
     return PVMFSuccess;
 }
 
@@ -2757,11 +2854,34 @@
 
     LogDiagnostics();
 
+    //remove the clock observer
+    if (iClientPlayBackClock != NULL)
+    {
+        if (iClockNotificationsInf != NULL)
+        {
+            iClockNotificationsInf->RemoveClockStateObserver(*this);
+            iClientPlayBackClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+            iClockNotificationsInf = NULL;
+        }
+    }
+
     if (iUnderFlowCheckTimer != NULL)
     {
         iUnderFlowCheckTimer->Clear();
     }
 
+    // reset direction rate state variables
+    iPlayBackDirection = PVMF_DATA_SOURCE_DIRECTION_FORWARD;
+    iParseAudioDuringFF = false;
+    iParseAudioDuringREW = false;
+    iParseVideoOnly = false;
+    iDataRate = NORMAL_PLAYRATE;
+
+    if (download_progress_interface != NULL)
+    {
+        download_progress_interface->cancelResumeNotification();
+    }
+
     if (iMP4FileHandle != NULL)
     {
         /* Indicates that the init was successfull */
@@ -2788,8 +2908,6 @@
             CleanupFileSource();
             iSelectedTrackInfoList.clear();
             SetState(EPVMFNodeIdle);
-            ThreadLogoff();
-
             return PVMFSuccess;
 
         }
@@ -2910,12 +3028,17 @@
     {
         if (iDataStreamInterface != NULL)
         {
+            if (iCPMSequenceInProgress)
+            {
+                return PVMFPending;
+            }
             if (iProgressivelyDownlodable == true && iDataStreamRequestPending)
             {
                 // send a cancel notification to datastream module.
                 iDataStreamRequestPending = false;
 
                 PvmiDataStreamStatus retVal = iDataStreamInterface->CancelNotificationSync(iDataStreamSessionID);
+
                 if (retVal == PVDS_SUCCESS)
                 {
                     // Complete Init as cancelled.
@@ -3014,24 +3137,6 @@
 
     aCmd.PVMFMP4FFParserNodeCommand::Parse(targetNPT, actualNPT, actualMediaDataTS, seektosyncpoint, streamID);
 
-    bool retVal = false;
-    // duplicate bos has been received
-    // dont perform reposition at source node
-    if (iStreamID == streamID)
-        retVal = true;
-    for (i = 0; i < iNodeTrackPortList.size(); ++i)
-    {
-        iNodeTrackPortList[i].iSendBOS = true;
-    }
-    //save the stream id for next media segment
-    iStreamID = streamID;
-
-    if (retVal)
-    {
-        OSCL_ARRAY_DELETE(trackList);
-        return PVMFSuccess;
-    }
-
     // Validate the parameters
     if (actualNPT == NULL || actualMediaDataTS == NULL)
     {
@@ -3040,13 +3145,33 @@
         return PVMFErrArgument;
     }
 
+    for (i = 0; i < iNodeTrackPortList.size(); ++i)
+    {
+        iNodeTrackPortList[i].iSendBOS = true;
+    }
+    //save the stream id for next media segment
+    iStreamID = streamID;
+
+    // this will guarantee that reverse mode starts from a valid TS
+    if (PVMF_DATA_SOURCE_DIRECTION_REVERSE == iPlayBackDirection)
+    {
+        iStartForNextTSSearch = targetNPT;
+        for (uint32 i = 0; i < iNodeTrackPortList.size();  i++)
+        {
+            if (iMP4FileHandle->getTrackMediaType(iNodeTrackPortList[i].iTrackId) == MEDIA_TYPE_VISUAL)
+            {
+                iPrevSampleTS = iMP4FileHandle->getMediaTimestampForCurrentSample(iNodeTrackPortList[i].iTrackId);
+                iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
+            }
+        }
+    }
     // First check if MP4 file is being downloaded to make sure the requested position is before amount downloaded
     if (download_progress_clock.GetRep())
     {
         // Get the amount downloaded so far
         bool tmpbool = false;
         uint32 dltime = 0;
-        download_progress_clock->GetCurrentTime32(dltime, tmpbool, OSCLCLOCK_MSEC);
+        download_progress_clock->GetCurrentTime32(dltime, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
         // Check if the requested time is past that
         if (targetNPT >= dltime)
         {
@@ -3123,7 +3248,7 @@
         mcc.update_clock(duration);
         durationms = mcc.get_converted_ts(1000);
     }
-    if (targetNPT >= durationms)
+    if ((targetNPT >= durationms) && (PVMF_DATA_SOURCE_DIRECTION_REVERSE != iPlayBackDirection))
     {
         //report EOT for all streams.
         for (i = 0; i < iNodeTrackPortList.size(); i++)
@@ -3137,7 +3262,31 @@
             iNodeTrackPortList[i].iTimestamp = iNodeTrackPortList[i].iClockConverter->get_current_timestamp();
         }
 
-        *actualNPT = 0;
+        // Cancel callback notifications on Datastream
+        if (autopaused || iExternalDownload)
+        {
+            PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition Cancel notification callback"));
+            autopaused = false;
+            if (download_progress_interface != NULL && iDataStreamInterface != NULL)
+            {
+                download_progress_interface->cancelResumeNotification();
+            }
+            else if (iExternalDownload)
+            {
+                // Cancel the Underflow check Timer
+                iUnderFlowCheckTimer->Cancel(PVMF_MP4FFPARSERNODE_UNDERFLOW_STATUS_TIMER_ID);
+
+                //Cancel the callback. This should also succeed if there is nothing to cancel
+                MP4_ERROR_CODE retVal = iMP4FileHandle->CancelNotificationSync();
+                if (retVal != EVERYTHING_FINE)
+                {
+                    PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition Wrong Datastream SessionID"));
+                    OSCL_ASSERT(false);
+                }
+            }
+        }
+
+        *actualNPT = durationms;
         OSCL_ARRAY_DELETE(trackList);
         return PVMFSuccess;
     }
@@ -3145,7 +3294,7 @@
     PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() *actualMediaDataTS %d",
                                          *actualMediaDataTS));
 
-    // Change of logic: Individual track will call seperate resetPlayback
+    // Change of logic: Individual track will call separate resetPlayback
     // Sequence of call is video->audio->text.If a few is not available that call will be skipped.
     // Ony One track id is provided in tempTrackId. Updated targetNPT is passed into next resetPlayback
     // More than 3 TRAK per MOOV not handled, first occurance of individual Track will be considered.
@@ -3157,6 +3306,7 @@
     // Rest the video present before calling the resetPlayback Individually
     iMP4FileHandle->ResetVideoTrackPresentFlag();
 
+    int32 minFileOffset = 0x7FFFFFFF;
     if (0 != trackList[0])
     {
         tempNPT = targetNPT;		// For logging Purpose
@@ -3164,6 +3314,19 @@
         targetNPT = iMP4FileHandle->resetPlayback(targetNPT, (uint16)TRACK_NO_PER_RESET_PLAYBACK_CALL,
                     &tempTrackId, seektosyncpoint);
 
+        MediaClockConverter mcc(1000);
+        mcc.update_clock(targetNPT);
+        uint32 mediats = mcc.get_converted_ts(iMP4FileHandle->getTrackMediaTimescale(tempTrackId));
+
+        int32 offset = 0;
+        int32 ret = iMP4FileHandle->getOffsetByTime(tempTrackId, mediats, &offset, 0);
+        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() getOffsetByTime ret %d Track %d NPT %d Offset %d",
+                                             ret, trackList[0], targetNPT, offset));
+        OSCL_UNUSED_ARG(ret);
+
+        minFileOffset = offset;
+        minFileOffsetTrackID = tempTrackId;
+
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() Video targetNPT = %d returns actualNPT=%d for trackId=%d",
                                              tempNPT, targetNPT, trackList[0]));
     }
@@ -3175,6 +3338,22 @@
         targetNPT = iMP4FileHandle->resetPlayback(targetNPT, (uint16)TRACK_NO_PER_RESET_PLAYBACK_CALL,
                     &tempTrackId, seektosyncpoint);
 
+        MediaClockConverter mcc(1000);
+        mcc.update_clock(targetNPT);
+        uint32 mediats = mcc.get_converted_ts(iMP4FileHandle->getTrackMediaTimescale(tempTrackId));
+
+        int32 offset = 0;
+        int32 ret = iMP4FileHandle->getOffsetByTime(tempTrackId, mediats, &offset, 0);
+        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() getOffsetByTime ret %d Track %d NPT %d Offset %d",
+                                             ret, trackList[1], targetNPT, offset));
+        OSCL_UNUSED_ARG(ret);
+
+        if (minFileOffset > offset)
+        {
+            minFileOffset = offset;
+            minFileOffsetTrackID = tempTrackId;
+        }
+
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() Audio targetNPT = %d returns actualNPT=%d for trackId=%d",
                                              tempNPT, targetNPT, trackList[1]));
     }
@@ -3191,6 +3370,22 @@
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() Text targetNPT = %d returns actualNPT=%d for trackId=%d",
                                              targetNPT, tempNPT, trackList[2]));
 
+        MediaClockConverter mcc(1000);
+        mcc.update_clock(tempNPT);
+        uint32 mediats = mcc.get_converted_ts(iMP4FileHandle->getTrackMediaTimescale(tempTrackId));
+
+        int32 offset = 0;
+        int32 ret = iMP4FileHandle->getOffsetByTime(tempTrackId, mediats, &offset, 0);
+        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() getOffsetByTime ret %d Track %d NPT %d Offset %d",
+                                             ret, trackList[2], tempNPT, offset));
+        OSCL_UNUSED_ARG(ret);
+
+        if (minFileOffset > offset)
+        {
+            minFileOffset = offset;
+            minFileOffsetTrackID = tempTrackId;
+        }
+
         // Use case, Text Only Track, *actualNPT will be set to output of Text resetPlayback.
         if ((0 == trackList[0]) && (0 == trackList[1]))
         {
@@ -3207,30 +3402,38 @@
     uint32 numSamples = 1;
     uint32 mints = 0xFFFFFFFF;
     int32 retval = EVERYTHING_FINE;
+    int32 *retValPerTrack = NULL;
+    uint32 *retNumSamplesPerTrack = NULL;
+    uint32 *trackTSAfterRepo = NULL;
+    //array to keep the timestamp of those samples from where playback has to be started i.e. timestamp of current samples to be played back.
+    trackTSAfterRepo = (uint32*) OSCL_MALLOC(iNodeTrackPortList.size() * sizeof(uint32));
+    retValPerTrack = (int32*) OSCL_MALLOC(iNodeTrackPortList.size() * sizeof(int32));
+    retNumSamplesPerTrack = (uint32*) OSCL_MALLOC(iNodeTrackPortList.size() * sizeof(uint32));
 
     for (i = 0; i < iNodeTrackPortList.size(); i++)
     {
         // Peek the next sample to get the duration of the last sample
         numSamples = 1;
         retval = iMP4FileHandle->peekNextBundledAccessUnits(iNodeTrackPortList[i].iTrackId, &numSamples, &info);
+        trackTSAfterRepo[i] = info.ts;
+        retNumSamplesPerTrack[i] = numSamples;
+        retValPerTrack[i] = retval;
+
         if (((retval == EVERYTHING_FINE) || (retval == END_OF_TRACK))
                 && (numSamples > 0))
         {
             // Check if sample info was returned. Only use valid
             // samples for this search
-            if (numSamples > 0)
-            {
-                // Set the new starting timestamp to the clock convert
-                iNodeTrackPortList[i].iClockConverter->set_clock(info.ts, 0);
+            // Set the new starting timestamp to the clock convert
+            iNodeTrackPortList[i].iClockConverter->set_clock(info.ts, 0);
 
-                // Check if this is the minimum
-                if (iNodeTrackPortList[i].iFormatType != PVMF_3GPP_TIMEDTEXT)
+            // Check if this is the minimum
+            if (iNodeTrackPortList[i].iFormatType != PVMF_MIME_3GPP_TIMEDTEXT)
+            {
+                uint32 trackstartts = iNodeTrackPortList[i].iClockConverter->get_converted_ts(1000);
+                if (trackstartts < mints)
                 {
-                    uint32 trackstartts = iNodeTrackPortList[i].iClockConverter->get_converted_ts(1000);
-                    if (trackstartts < mints)
-                    {
-                        mints = trackstartts;
-                    }
+                    mints = trackstartts;
                 }
             }
         }
@@ -3238,6 +3441,25 @@
         {
             // do nothing. No need to use the track to calculate mints, as next sample is EOT.
         }
+        else if (retval == INSUFFICIENT_DATA)
+        {
+            iNodeTrackPortList[i].iClockConverter->set_clock_other_timescale(*actualMediaDataTS, 1000);
+            if (iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK
+                    || iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK)
+            {
+                iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
+            }
+
+            iNodeTrackPortList[i].iTimestamp = iNodeTrackPortList[i].iClockConverter->get_current_timestamp();
+            iNodeTrackPortList[i].iFirstFrameAfterRepositioning = true;
+            iNodeTrackPortList[i].iCurrentTextSampleEntry.Unbind();
+            // convert target NPT to media timescale
+            MediaClockConverter mcc(1000);
+            mcc.update_clock(targetNPT);
+            uint32 targetNPTtInMediaTimeScale =
+                mcc.get_converted_ts(iMP4FileHandle->getTrackMediaTimescale(iNodeTrackPortList[i].iTrackId));
+            iNodeTrackPortList[i].iTargetNPTInMediaTimeScale = targetNPTtInMediaTimeScale;
+        }
         else
         {
             // Return as error
@@ -3248,6 +3470,10 @@
                 aEventCode = PVMFFFErrMisc;
             }
             OSCL_ARRAY_DELETE(trackList);
+            OSCL_DELETE(trackTSAfterRepo);
+            OSCL_DELETE(retValPerTrack);
+            OSCL_DELETE(retNumSamplesPerTrack);
+            trackTSAfterRepo = NULL;
             return PVMFErrResource;
         }
     }
@@ -3265,9 +3491,8 @@
     // Now adjust the timestamp of each track in reference to this minimum
     for (i = 0; i < iNodeTrackPortList.size(); i++)
     {
-        numSamples = 1;
-        retval = iMP4FileHandle->peekNextBundledAccessUnits(iNodeTrackPortList[i].iTrackId, &numSamples, &info);
-        if (retval == EVERYTHING_FINE || retval == END_OF_TRACK)
+        // now no need to call 2nd peek, we have timestamp of current sample and retValPerTrack[i] by 1st peek call.
+        if (retValPerTrack[i] == EVERYTHING_FINE || retValPerTrack[i] == END_OF_TRACK)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, \
                             (0, "PVMFMP4FFParserNode::DoSetDataSourcePositionA: targetNPT1 =%d, TrackId=%d, State =%d,\
@@ -3275,11 +3500,11 @@
                              iNodeTrackPortList[i].iState, iNodeTrackPortList[i].iTimestamp, \
                              iNodeTrackPortList[i].iTargetNPTInMediaTimeScale));
 
-            if (numSamples > 0)
+            if (retNumSamplesPerTrack[i] > 0)
             {
-                iNodeTrackPortList[i].iClockConverter->set_clock(info.ts, 0);
+                iNodeTrackPortList[i].iClockConverter->set_clock(trackTSAfterRepo[i], 0);
                 uint32 trackts = iNodeTrackPortList[i].iClockConverter->get_converted_ts(1000);
-                if (iNodeTrackPortList[i].iFormatType == PVMF_3GPP_TIMEDTEXT && trackts < mints)
+                if (iNodeTrackPortList[i].iFormatType == PVMF_MIME_3GPP_TIMEDTEXT && trackts < mints)
                 {
                     uint32 diffMintsTrackts = mints - trackts;
 
@@ -3297,7 +3522,7 @@
                 }
                 else
                 {
-                    if (retval == END_OF_TRACK)
+                    if (retValPerTrack[i] == END_OF_TRACK)
                     {
                         // if next sample is EOT then just assign actualMediaDataTS as the TS for the sample.
                         iNodeTrackPortList[i].iClockConverter->set_clock_other_timescale(*actualMediaDataTS, 1000);
@@ -3317,20 +3542,30 @@
                 iNodeTrackPortList[i].iClockConverter->set_clock_other_timescale(*actualMediaDataTS, 1000);
             }
 
-            if (iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK ||
-                    iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_DOWNLOAD_AUTOPAUSE)
+
+            if (autopaused || iExternalDownload)
             {
-                if (autopaused)
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition Cancel notification callback"));
+                autopaused = false;
+                if (download_progress_interface != NULL && iDataStreamInterface != NULL)
                 {
-                    PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition Track Autopaused"));
-                    autopaused = false;
-                    if (download_progress_interface != NULL && iDataStreamInterface != NULL)
+                    download_progress_interface->cancelResumeNotification();
+                }
+                else if (iExternalDownload)
+                {
+                    // Cancel the Underflow check Timer
+                    iUnderFlowCheckTimer->Cancel(PVMF_MP4FFPARSERNODE_UNDERFLOW_STATUS_TIMER_ID);
+
+                    //Cancel the callback. This should also succeed if there is nothing to cancel
+                    MP4_ERROR_CODE retval = iMP4FileHandle->CancelNotificationSync();
+                    if (retval != EVERYTHING_FINE)
                     {
-                        download_progress_interface->cancelResumeNotification();
+                        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::DoSetDataSourcePosition Wrong Datastream SessionID"));
+                        OSCL_ASSERT(false);
                     }
                 }
-                iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
             }
+            iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
 
             iNodeTrackPortList[i].iTimestamp = iNodeTrackPortList[i].iClockConverter->get_current_timestamp();
             iNodeTrackPortList[i].iFirstFrameAfterRepositioning = true;
@@ -3348,36 +3583,6 @@
                              iNodeTrackPortList[i].iState, iNodeTrackPortList[i].iTimestamp, \
                              iNodeTrackPortList[i].iTargetNPTInMediaTimeScale));
         }
-        else if (retval == INSUFFICIENT_DATA)
-        {
-            iNodeTrackPortList[i].iClockConverter->set_clock_other_timescale(*actualMediaDataTS, 1000);
-            if (iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK)
-            {
-                iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
-            }
-
-            iNodeTrackPortList[i].iTimestamp = iNodeTrackPortList[i].iClockConverter->get_current_timestamp();
-            iNodeTrackPortList[i].iFirstFrameAfterRepositioning = true;
-            iNodeTrackPortList[i].iCurrentTextSampleEntry.Unbind();
-            // convert target NPT to media timescale
-            MediaClockConverter mcc(1000);
-            mcc.update_clock(targetNPT);
-            uint32 targetNPTtInMediaTimeScale =
-                mcc.get_converted_ts(iMP4FileHandle->getTrackMediaTimescale(iNodeTrackPortList[i].iTrackId));
-            iNodeTrackPortList[i].iTargetNPTInMediaTimeScale = targetNPTtInMediaTimeScale;
-        }
-        else
-        {
-            // Return as error
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() Peeking next sample failed while adjusting the track timestamp %d", retval));
-            if (!MapMP4ErrorCodeToEventCode(retval, aEventUuid, aEventCode))
-            {
-                aEventUuid = PVMFFileFormatEventTypesUUID;
-                aEventCode = PVMFFFErrMisc;
-            }
-            OSCL_ARRAY_DELETE(trackList);
-            return PVMFErrResource;
-        }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
@@ -3389,6 +3594,10 @@
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::DoSetDataSourcePosition() Out"));
     OSCL_ARRAY_DELETE(trackList);
+    OSCL_DELETE(trackTSAfterRepo);
+    trackTSAfterRepo = NULL;
+    OSCL_DELETE(retValPerTrack);
+    OSCL_DELETE(retNumSamplesPerTrack);
     return PVMFSuccess;
 }
 
@@ -3417,7 +3626,7 @@
         // Get the amount downloaded so far
         bool tmpbool = false;
         uint32 dltime = 0;
-        download_progress_clock->GetCurrentTime32(dltime, tmpbool, OSCLCLOCK_MSEC);
+        download_progress_clock->GetCurrentTime32(dltime, tmpbool, PVMF_MEDIA_CLOCK_MSEC);
         // Check if the requested time is past that
         if (targetNPT >= dltime)
         {
@@ -3508,7 +3717,7 @@
 
     // Retrieve the new rate
     int32 rate;
-    OsclTimebase* timebase = NULL;
+    PVMFTimebase* timebase = NULL;
     aCmd.PVMFMP4FFParserNodeCommand::Parse(rate, timebase);
 
     if (timebase == NULL)
@@ -3520,15 +3729,162 @@
             return PVMFErrNotSupported;
         }
     }
-    else
+
+    // if we are going ff to normal or vice versa, we need to set the node to disable non-video
+    if (!iParseAudioDuringFF && (iDataRate != rate) && (PVMF_DATA_SOURCE_DIRECTION_FORWARD == iPlayBackDirection))
     {
-        // Allow outside timebase
+        // coming to normal rate?
+        if (rate == NORMAL_PLAYRATE)
+        {
+            iParseVideoOnly = false;
+        }
+        // switching to FF or rew?
+        else
+        {
+            // since we know ff will not have audio, just disable audio now.
+            // If it is going to REW, DoSetDataSourceDirection will modify it there
+            iParseVideoOnly = true;
+        }
     }
 
+
+    iDataRate = rate;
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::DoSetDataSourceRate() Out"));
     return PVMFSuccess;
 }
 
+PVMFStatus PVMFMP4FFParserNode::DoSetDataSourceDirection(PVMFMP4FFParserNodeCommand& aCmd)
+{
+    int32 direction = -1;
+    uint32* actualNPT = NULL;
+    uint32* actualMediaDataTS = NULL;
+    PVMFTimebase* timebase;
+
+    aCmd.PVMFMP4FFParserNodeCommand::Parse(direction, actualNPT, actualMediaDataTS, timebase);
+
+    /* Validate the parameters */
+    if ((actualNPT == NULL) || (actualMediaDataTS == NULL))
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+        return PVMFFailure;
+    }
+
+    *actualMediaDataTS = 0;
+
+    /*
+     * The media data timestamp of the next sample will start from the maximum
+     * of timestamp on all selected tracks.  This media data timestamp will
+     * correspond to the actual NPT.
+     */
+    uint32 i;
+    for (i = 0; i < iNodeTrackPortList.size(); i++)
+    {
+        uint32 timeStamp = 0;
+        /* Use an arbitary delta */
+        timeStamp = iNodeTrackPortList[i].iTimestamp;
+
+        iNodeTrackPortList[i].iClockConverter->set_clock(timeStamp, 0);
+        timeStamp = iNodeTrackPortList[i].iClockConverter->get_converted_ts(1000);
+
+        /*
+         * Actual media data TS is the max timestamp of all selected tracks
+         */
+        if (timeStamp > *actualMediaDataTS)
+        {
+            *actualMediaDataTS = timeStamp;
+        }
+    }
+
+    /* ensure all current track TS starts after max of selected track */
+    //In MP4, TS could be max of selected track, but here we need to
+    //have it more than max of selected track because the duration of
+    //sample in asf is not set.Therefore comparison in the sync util
+    //(aDataTimeStamp + aDuration)> iResumeTimeStamp fails for the
+    //first valid packet send out from the parser node to the sync util
+    //and is discarded.
+
+    MediaClockConverter mcc(1000);
+    mcc.update_clock(*actualMediaDataTS);
+    for (i = 0; i < iNodeTrackPortList.size(); i++)
+    {
+        uint32 actualMediaDataTSInMediaTimeScale =
+            mcc.get_converted_ts(iMP4FileHandle->getTrackMediaTimescale(iNodeTrackPortList[i].iTrackId));
+        iNodeTrackPortList[i].iTimestamp = actualMediaDataTSInMediaTimeScale;
+    }
+
+    *actualNPT = 0;
+    /*
+     * If SetDataSourceDirection call made in prepared state, with fwd direction
+     * do nothing.
+     */
+    if ((iInterfaceState == EPVMFNodePrepared) &&
+            (direction == PVMF_DATA_SOURCE_DIRECTION_FORWARD))
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        return PVMFSuccess;
+    }
+
+    /*
+     * If direction is reverse then actual NPT is the max of all track NPTs.
+     * If direction is forward then actual NPT is the min of all track NPTs.
+     * iPrevSampleTimeStamp is the NPT TS of the last retrieved sample
+     */
+    uint32 actualNPT32 = 0;
+    if (direction == PVMF_DATA_SOURCE_DIRECTION_FORWARD)
+    {
+        // if switching back to forward at 100000, make sure everything is set to parse
+        // othrewise check what ff should be for non-video tracks and set it
+
+        iParseVideoOnly = ((iDataRate == NORMAL_PLAYRATE) || iParseAudioDuringFF) ? false : true;
+
+        actualNPT32 = 0x7FFFFFFF;
+        for (i = 0; i < iNodeTrackPortList.size(); i++)
+        {
+            uint32 lastTS = iMP4FileHandle->getMediaTimestampForCurrentSample(iNodeTrackPortList[i].iTrackId);
+            iNodeTrackPortList[i].iClockConverter->set_clock(lastTS, 0);
+            lastTS = iNodeTrackPortList[i].iClockConverter->get_converted_ts(1000);
+            if (lastTS < actualNPT32)
+            {
+                actualNPT32 = lastTS;
+            }
+
+            // temporarily disable all tracks until the next setdatasourceposition comes in
+            iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK;
+        }
+    }
+    else if (PVMF_DATA_SOURCE_DIRECTION_REVERSE == direction)
+    {
+        iParseVideoOnly = iParseAudioDuringREW ? false : true;
+
+        actualNPT32 = 0;
+        for (i = 0; i < iNodeTrackPortList.size(); i++)
+        {
+            uint32 lastTS = iMP4FileHandle->getMediaTimestampForCurrentSample(iNodeTrackPortList[i].iTrackId);
+            iNodeTrackPortList[i].iClockConverter->set_clock(lastTS, 0);
+            lastTS = iNodeTrackPortList[i].iClockConverter->get_converted_ts(1000);
+            if (lastTS > actualNPT32)
+                actualNPT32 = lastTS;
+
+            // stop transmitting until after repositioning
+            iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_ENDOFTRACK;
+        }
+    }
+    else
+    {
+        OSCL_ASSERT(false);
+    }
+
+    *actualNPT = actualNPT32;
+
+    iPlayBackDirection = direction;
+
+    PVMF_MP4FFPARSERNODE_LOGINFO((0, "PVMFMP4FFParserNode::DoSetDataSourceDirection: direction=%d, actualNPT=%d, actualTS=%d",
+                                  direction, *actualNPT, *actualMediaDataTS));
+
+    return PVMFSuccess;
+}
+
 
 void PVMFMP4FFParserNode::HandleTrackState()
 {
@@ -3553,12 +3909,35 @@
                     if (!SendBeginOfMediaStreamCommand(iNodeTrackPortList[i]))
                         break;
                 }
+                if (iNodeTrackPortList[i].iFirstFrameAfterRepositioning)
+                {
+                    //after repo, let the track with min file offset retrieve data first
+                    uint32 j = 0;
+                    for (j = 0; j < iNodeTrackPortList.size(); ++j)
+                    {
+                        if (minFileOffsetTrackID == iNodeTrackPortList[j].iTrackId)
+                        {
+                            break;
+                        }
+                    }
+                    if ((i != j) && (iNodeTrackPortList[j].iFirstFrameAfterRepositioning))
+                    {
+                        //LOGE("Ln %d UGLY? Yes. minFileOffsetTrackID %d Skipped iTrackId %d", __LINE__, minFileOffsetTrackID , iNodeTrackPortList[j].iTrackId);
+                        break;
+                    }
+                }
+
                 if (!RetrieveTrackData(iNodeTrackPortList[i]))
                 {
                     if (iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK)
                     {
                         RunIfNotReady();
                     }
+                    if (iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_SKIP_CORRUPT_SAMPLE)
+                    {
+                        iNodeTrackPortList[i].iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_GETDATA;
+                        RunIfNotReady();
+                    }
                     break;
                 }
                 if (iNodeTrackPortList[i].iState == PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRACKMAXDATASIZE_RESIZE)
@@ -3620,7 +3999,7 @@
 
 bool PVMFMP4FFParserNode::RetrieveTrackConfigInfo(uint32 aTrackId, PVMFFormatType aFormatType, OsclRefCounterMemFrag &aConfig)
 {
-    if (aFormatType == PVMF_3GPP_TIMEDTEXT)
+    if (aFormatType == PVMF_MIME_3GPP_TIMEDTEXT)
     {
         // For timed text
         // Create refcounted mem frag for text track's format specific info
@@ -3706,7 +4085,7 @@
         PVMFFormatType aFormatType,
         OsclRefCounterMemFrag &aConfig)
 {
-    if (aFormatType == PVMF_MPEG4_AUDIO)
+    if (aFormatType == PVMF_MIME_MPEG4_AUDIO)
     {
         // Check if the track has decoder config info
         uint32 specinfosize =
@@ -3734,7 +4113,7 @@
         retval = iMP4FileHandle->peekNextBundledAccessUnits(aTrackId,
                  &numSamples,
                  &info);
-        if (retval == EVERYTHING_FINE || END_OF_TRACK == retval)
+        if ((retval == EVERYTHING_FINE || END_OF_TRACK == retval) && numSamples > 0)
         {
             uint32 sampleSize = info.len;
             if (sampleSize > 0)
@@ -3803,6 +4182,7 @@
     MediaMetaInfo *info = (MediaMetaInfo*) OSCL_MALLOC(numsamples * sizeof(MediaMetaInfo));
     if (NULL == info)
     {
+        // If we get here, an error has occurred
         ReportMP4FFParserErrorEvent(PVMFErrProcessing, NULL, NULL, NULL);
         return false;
     }
@@ -3819,6 +4199,7 @@
         }
         else
         {
+            // If we get here, an error has occurred
             OSCL_FREE(info);
             ReportMP4FFParserErrorEvent(PVMFErrProcessing, NULL, NULL, NULL);
             return false;
@@ -3833,9 +4214,9 @@
     uint32 msec = clock_conv.get_converted_ts(MILLISECOND_TIMESCALE);
 
     // get the download progress clock time
-    uint64 download_time;
-    download_progress_clock->GetCurrentTime64(download_time, OSCLCLOCK_MSEC);
-    uint32 clock_msec32 = Oscl_Int64_Utils::get_uint64_lower32(download_time);
+    uint32 clock_msec32;
+    bool overload = 0;
+    download_progress_clock->GetCurrentTime32(clock_msec32, overload, PVMF_MEDIA_CLOCK_MSEC);
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFMP4FFParserNode:: P/R checkTrackPosition() Track[%d] numsamples=%d, availTS=%d, reqTS=%d, playedTS=%d", \
@@ -3893,72 +4274,68 @@
     uint32 trackid = aTrackPortInfo.iTrackId;
 
     // Create a data buffer from pool
-    int errcode = 0;
+    int errcode = OsclErrNoResources;
 
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
-    if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+    if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
     {
-        OSCL_TRY(errcode, mediaDataImplOut = aTrackPortInfo.iTextMediaDataImplAlloc->allocate(aTrackPortInfo.iTrackMaxDataSize));
+        mediaDataImplOut = aTrackPortInfo.iTextMediaDataImplAlloc->allocate(aTrackPortInfo.iTrackMaxDataSize);
     }
     else
     {
-        OSCL_TRY(errcode, mediaDataImplOut = aTrackPortInfo.iMediaDataImplAlloc->allocate(aTrackPortInfo.iTrackMaxDataSize));
+        mediaDataImplOut = aTrackPortInfo.iMediaDataImplAlloc->allocate(aTrackPortInfo.iTrackMaxDataSize);
     }
-    if (errcode != 0)
+
+    if (mediaDataImplOut.GetRep() != NULL)
     {
-        if (errcode == OsclErrNoResources)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP4FFParserNode::RetrieveTrackData() No Resource Found"));
-            aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRACKDATAPOOLEMPTY;
-            aTrackPortInfo.iTrackDataMemoryPool->notifyfreeblockavailable(aTrackPortInfo, aTrackPortInfo.iTrackMaxDataSize);	// Enable flag to receive event when next deallocate() is called on pool
-            return false;
-        }
-        else if (errcode == OsclErrNoMemory)
-        {
-            // Memory allocation for the pool failed
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::RetrieveTrackData() Memory allocation for buffer memory pool failed"));
-            aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_ERROR;
-            ReportMP4FFParserErrorEvent(PVMFErrNoMemory, NULL);
-            return false;
-        }
-        else if (errcode == OsclErrArgument)
-        {
-            // Invalid parameters passed to mempool
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::RetrieveTrackData() Invalid parameters passed to buffer memory pool"));
-            aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_ERROR;
-            ReportMP4FFParserErrorEvent(PVMFErrArgument, NULL);
-            return false;
-        }
-        else
-        {
-            // General error
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::RetrieveTrackData() allocate() on mempool did a leave %d", errcode));
-            aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_ERROR;
-            ReportMP4FFParserErrorEvent(PVMFFailure, NULL);
-            return false;
-        }
+        errcode = OsclErrNone;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP4FFParserNode::RetrieveTrackData() No Resource Found"));
+        aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_TRACKDATAPOOLEMPTY;
+        aTrackPortInfo.iTrackDataMemoryPool->notifyfreeblockavailable(aTrackPortInfo, aTrackPortInfo.iTrackMaxDataSize);	// Enable flag to receive event when next deallocate() is called on pool
+        return false;
     }
 
     // Now create a PVMF media data from pool
-    errcode = 0;
+    errcode = OsclErrNoResources;
     PVMFSharedMediaDataPtr mediadataout;
-    OSCL_TRY(errcode, mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool));
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP4FFParserNode::RetrieveTrackData() Memory allocation for media data memory pool failed"));
-                         aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_MEDIADATAPOOLEMPTY;
-                         aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(aTrackPortInfo);		// Enable flag to receive event when next deallocate() is called on pool
-                         return false);
+    mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool);
+    if (mediadataout.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
+
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP4FFParserNode::RetrieveTrackData() Memory allocation for media data memory pool failed"));
+        aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_MEDIADATAPOOLEMPTY;
+        aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(aTrackPortInfo);		// Enable flag to receive event when next deallocate() is called on pool
+        return false;
+    }
 
     // Try creating a PVMF media frag group if H.264
     OsclSharedPtr<PVMFMediaDataImpl> mediadatafraggroup;
-    if ((aTrackPortInfo.iFormatType == PVMF_H264_MP4) || (aTrackPortInfo.iFormatType == PVMF_MPEG4_AUDIO))
+    if ((aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_H264_MP4) ||
+            ((aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_MPEG4_AUDIO) &&
+             (oIsAACFramesFragmented)))
     {
-        OSCL_TRY(errcode , mediadatafraggroup = aTrackPortInfo.iMediaDataGroupAlloc->allocate());
-        OSCL_FIRST_CATCH_ANY(errcode,
-                             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::RetrieveTrackData() Allocating from media data group alloc failed"));
-                             aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_MEDIADATAFRAGGROUPPOOLEMPTY;
-                             aTrackPortInfo.iMediaDataGroupAlloc->notifyfreechunkavailable(aTrackPortInfo);
-                             return false);
+        errcode = OsclErrNoResources;
+        mediadatafraggroup = aTrackPortInfo.iMediaDataGroupAlloc->allocate();
+        if (mediadatafraggroup.GetRep() != NULL)
+        {
+            errcode = OsclErrNone;
+        }
+
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::RetrieveTrackData() Allocating from media data group alloc failed"));
+            aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_MEDIADATAFRAGGROUPPOOLEMPTY;
+            aTrackPortInfo.iMediaDataGroupAlloc->notifyfreechunkavailable(aTrackPortInfo);
+            return false;
+        }
+
     }
 
     uint32 numsamples = aTrackPortInfo.iNumSamples;
@@ -3993,7 +4370,7 @@
     }
     else
     {
-        if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+        if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
         {
             PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*) refCtrMemFragOut.getMemFrag().ptr;
             iGau.buf.fragments[0].ptr = textmediadata->iTextSample;
@@ -4034,6 +4411,33 @@
             return false;
         }
     }
+    else if ((PVMF_DATA_SOURCE_DIRECTION_REVERSE == iPlayBackDirection) &&
+             (iMP4FileHandle->getTrackMediaType(aTrackPortInfo.iTrackId) == MEDIA_TYPE_VISUAL))
+    {
+        uint32 numSamples = 1;
+        uint32 keySampleNumber;
+        if (aTrackPortInfo.iFirstFrameAfterRepositioning)
+        {
+            iPrevSampleTS = iMP4FileHandle->getMediaTimestampForCurrentSample(trackid);
+            retval = iMP4FileHandle->getPrevKeyMediaSample(iPrevSampleTS, keySampleNumber, trackid,
+                     &numSamples, &iGau);
+            iStartForNextTSSearch = iMP4FileHandle->getMediaTimestampForCurrentSample(trackid) - 2 * iGau.info[0].ts_delta;
+        }
+        else
+        {
+            if (iStartForNextTSSearch <= 0)
+            {
+                retval = END_OF_TRACK;
+            }
+            else
+            {
+                retval = iMP4FileHandle->getPrevKeyMediaSample(iStartForNextTSSearch, keySampleNumber, trackid,
+                         &numSamples, &iGau);
+                iStartForNextTSSearch = iMP4FileHandle->getMediaTimestampForCurrentSample(trackid) - 2 * iGau.info[0].ts_delta;
+            }
+        }
+
+    }
     else
     {
         retval = iMP4FileHandle->getNextBundledAccessUnits(trackid, &numsamples, &iGau);
@@ -4078,21 +4482,46 @@
     for (uint32 i = 0; i < iGau.numMediaSamples; ++i)
     {
         actualdatasize += iGau.info[i].len;
-        tsDelta += iGau.info[i].ts_delta;
-        if (iGau.info[i].ts < aTrackPortInfo.iTargetNPTInMediaTimeScale)
+        if ((PVMF_DATA_SOURCE_DIRECTION_REVERSE == iPlayBackDirection) &&
+                (iMP4FileHandle->getTrackMediaType(aTrackPortInfo.iTrackId) == MEDIA_TYPE_VISUAL))
         {
-            oSetNoRenderBit = true;
+            // for reverse we are just using I frames so need to get delta from total differnece in time
+            tsDelta += oscl_abs(iGau.info[0].ts - iPrevSampleTS);
+            if (0 == tsDelta)
+                tsDelta += iGau.info[i].ts_delta;
+
+            iPrevSampleTS = iGau.info[0].ts;
+
+            // in the case of backwards playback, dont render if ts greater than targetnpt.
+            if (iGau.info[i].ts > aTrackPortInfo.iTargetNPTInMediaTimeScale)
+            {
+                oSetNoRenderBit = true;
+            }
+            else
+            {
+                //we are past the no render point, so reset to zero
+                aTrackPortInfo.iTargetNPTInMediaTimeScale = 0x7FFFFFFF;
+            }
         }
         else
         {
-            //we are past the no render point, so reset to zero
-            aTrackPortInfo.iTargetNPTInMediaTimeScale = 0;
+            tsDelta += iGau.info[i].ts_delta;
+
+            if (iGau.info[i].ts < aTrackPortInfo.iTargetNPTInMediaTimeScale)
+            {
+                oSetNoRenderBit = true;
+            }
+            else
+            {
+                //we are past the no render point, so reset to zero
+                aTrackPortInfo.iTargetNPTInMediaTimeScale = 0;
+            }
         }
     }
 
     // Save the first frame flag for output media data's random access point flag
     bool israndomaccesspt = aTrackPortInfo.iFirstFrameAfterRepositioning;
-    if (israndomaccesspt)
+    if (aTrackPortInfo.iFirstFrameAfterRepositioning)
     {
         // If it is first frame after repositioning, media data timestamp should be
         // at the spot set when SetDataSourcePosition was processed and doesn't need to
@@ -4114,7 +4543,7 @@
             }
             aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
             // End of track reached so send EOS media command
-            if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+            if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
             {
                 iEOTForTextSentToMIO = true;
                 iSetTextSampleDurationZero = false;
@@ -4131,29 +4560,32 @@
                 uint32 outSize = actualdatasize;
 
                 uint32 currticks = OsclTickCount::TickCount();
-                uint32 StartTime = OsclTickCount::TicksToMsec(currticks);
+                uint32 StartTime;
+                StartTime = OsclTickCount::TicksToMsec(currticks);
 
-                if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+                if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
                 {
                     PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*) refCtrMemFragOut.getMemFrag().ptr;
                     iDecryptionInterface->DecryptAccessUnit(iOMA2DecryptionBuffer,
                                                             inSize,
-                                                            (uint8*&)(textmediadata->iTextSample),
+                                                            textmediadata->iTextSample,
                                                             outSize, trackid);
                 }
                 else
                 {
+                    uint8* memfrag = (uint8*)(refCtrMemFragOut.getMemFrag().ptr);
+
                     iDecryptionInterface->DecryptAccessUnit(iOMA2DecryptionBuffer,
                                                             inSize,
-                                                            (uint8*&)(refCtrMemFragOut.getMemFrag().ptr),
+                                                            memfrag,
                                                             outSize, trackid);
                 }
                 currticks = OsclTickCount::TickCount();
-                uint32 EndTime = OsclTickCount::TicksToMsec(currticks);
-                uint32 decryptTime32 = EndTime - StartTime;
+                uint32 EndTime;
+                EndTime = OsclTickCount::TicksToMsec(currticks);
 
                 actualdatasize = outSize;
-                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::RetrieveTrackData - DecryptAccessUnit - Mime=%s, TrackID=%d, InSize=%d, OutSize=%d, DecryptTime=%d", aTrackPortInfo.iMimeType.get_cstr(), aTrackPortInfo.iTrackId, inSize, outSize, decryptTime32));
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::RetrieveTrackData - DecryptAccessUnit - Mime=%s, TrackID=%d, InSize=%d, OutSize=%d, DecryptTime=%d", aTrackPortInfo.iMimeType.get_cstr(), aTrackPortInfo.iTrackId, inSize, outSize, EndTime - StartTime));
             }
             else
             {
@@ -4168,7 +4600,7 @@
         OsclSharedPtr<PVMFMediaDataImpl> media_data_impl;
         mediadataout->getMediaDataImpl(media_data_impl);
 
-        if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+        if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
         {
             PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*) refCtrMemFragOut.getMemFrag().ptr;
 
@@ -4256,14 +4688,13 @@
             {
                 // Need to go to the resizable memory pool and free some memory
                 uint32 bytestofree = textmediadata->iTextSampleCapacity - actualdatasize;
-                aTrackPortInfo.iTrackDataMemoryPoolProxy->trim(bytestofree);
-
                 // Update the capacity
                 media_data_impl->setCapacity(media_data_impl->getCapacity() - bytestofree);
                 textmediadata->iTextSampleCapacity -= bytestofree;
-
                 // Set buffer size
                 mediadataout->setMediaFragFilledLen(0, refCtrMemFragOut.getCapacity() - bytestofree);
+                //resize the fragment
+                aTrackPortInfo.iTextMediaDataImplAlloc->ResizeMemoryFragment(mediaDataImplOut);
             }
 
             OsclBinIStreamBigEndian textSampleStream;
@@ -4314,6 +4745,7 @@
                 }
                 textmediadata->iTextSampleLength -= 4;
                 textmediadata->iTextSampleCapacity -= 4;
+                // text sample length includes the 0xFEFF marker
                 textSampleLengthFromSample -= 2;
             }
             else
@@ -4340,13 +4772,12 @@
         {
             // Set buffer size
             mediadataout->setMediaFragFilledLen(0, actualdatasize);
-
+            media_data_impl->setCapacity(actualdatasize);
             // Return the unused space from mempool back
             if (refCtrMemFragOut.getCapacity() > actualdatasize)
             {
                 // Need to go to the resizable memory pool and free some memory
-                aTrackPortInfo.iTrackDataMemoryPoolProxy->trim(refCtrMemFragOut.getCapacity() - actualdatasize);
-                media_data_impl->setCapacity(actualdatasize);
+                aTrackPortInfo.iMediaDataImplAlloc->ResizeMemoryFragment(mediaDataImplOut);
             }
         }
 
@@ -4372,6 +4803,12 @@
         {
             markerInfo |= PVMF_MEDIA_DATA_MARKER_INFO_NO_RENDER_BIT;
         }
+        if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_H264_MP4)
+        {
+            // Set End-of-NAL bit to 1 always - no NAL fragmentation for now
+            markerInfo |= PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
+        }
+
         media_data_impl->setMarkerInfo(markerInfo);
 
         // Retrieve timestamp and convert to milliseconds
@@ -4387,9 +4824,8 @@
         //for logging
         MediaClockConverter mcc(iMP4FileHandle->getTrackMediaTimescale(aTrackPortInfo.iTrackId));
         mcc.update_clock(iGau.info[0].ts);
-        uint32 nptInMS = mcc.get_converted_ts(1000);
 
-        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::RetrieveTrackData - Mime=%s, TrackID=%d, Size=%d, NPT=%d, MediaTS=%d, SEQNUM=%d, DUR=%d, NoRen=%d", aTrackPortInfo.iMimeType.get_cstr(), aTrackPortInfo.iTrackId, actualdatasize, nptInMS, timestamp, aTrackPortInfo.iSeqNum, tsDelta, oSetNoRenderBit));
+        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::RetrieveTrackData - Mime=%s, TrackID=%d, Size=%d, NPT=%d, MediaTS=%d, SEQNUM=%d, DUR=%d, Marker=0x%x", aTrackPortInfo.iMimeType.get_cstr(), aTrackPortInfo.iTrackId, actualdatasize, mcc.get_converted_ts(1000), timestamp, aTrackPortInfo.iSeqNum, tsDelta, markerInfo));
 
         // Advance aTrackPortInfo.iTimestamp to the timestamp at the end of the
         // all samples in the group, i.e. current duration.
@@ -4397,7 +4833,7 @@
         aTrackPortInfo.iClockConverter->set_clock(aTrackPortInfo.iTimestamp, 0);
         uint32 timestamp_next = aTrackPortInfo.iClockConverter->get_converted_ts(1000);
         uint32 duration_msec = timestamp_next - timestamp;
-        if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+        if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
         {
             aTrackPortInfo.iMediaData->setDuration(duration_text_msec);
         }
@@ -4440,16 +4876,34 @@
 
             if (!autopaused)
             {
+                uint32 requestedTimestamp = aTrackPortInfo.iTimestamp;
+                // If Parser library reported Insufficient data after seek, the requested
+                // timestamp here should be TS of sample from new position, so peek the
+                // sample.
+                if (israndomaccesspt)
+                {
+                    uint32 numSamples = 1;
+                    MediaMetaInfo info;
+
+                    retval = iMP4FileHandle->peekNextBundledAccessUnits(aTrackPortInfo.iTrackId, &numSamples, &info);
+                    if (((retval == EVERYTHING_FINE) || (retval == END_OF_TRACK))
+                            && (numSamples > 0))
+                    {
+                        aTrackPortInfo.iClockConverter->set_clock(info.ts, 0);
+                        requestedTimestamp = aTrackPortInfo.iClockConverter->get_converted_ts(1000);
+                    }
+                }
+
                 if ((NULL != iDataStreamInterface) && (0 != iDataStreamInterface->QueryBufferingCapacity()))
                 {
                     // if progressive streaming, playResumeNotifcation is guaranteed to be called
                     // with the proper download complete state, ignore the current download status
                     bool dlcomplete = false;
-                    download_progress_interface->requestResumeNotification(aTrackPortInfo.iTimestamp, dlcomplete);
+                    download_progress_interface->requestResumeNotification(requestedTimestamp, dlcomplete);
                 }
                 else
                 {
-                    download_progress_interface->requestResumeNotification(aTrackPortInfo.iTimestamp, iDownloadComplete);
+                    download_progress_interface->requestResumeNotification(requestedTimestamp, iDownloadComplete);
                 }
             }
             aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_DOWNLOAD_AUTOPAUSE;
@@ -4459,7 +4913,7 @@
             PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::RetrieveTrackData() - Auto Pause Triggered, TS = %d, FileSize=%d",
                                                  aTrackPortInfo.iTimestamp, currentFileSize));
 
-            // Check if content is poorly interleaved only for PS.
+            // check if content is poorly interleaved only for PS
             // After repositioning, parser will get INSUFFICIENT_DATA immediately and then the poorlyinterleavedcontent event logic will be excercised.
             // To make sure that the reposition behaviour and the playback without interruption behavior are consistent, disable the check for first INSUFFICIENT_DATA after repositioning.
             if ((NULL != iDataStreamInterface) && (iPoorlyInterleavedContentEventSent == false) && (!israndomaccesspt))
@@ -4475,11 +4929,12 @@
                         return false;
                     }
                     int32 retval = EVERYTHING_FINE;
-                    for (uint32 i = 0; i < iNodeTrackPortList.size(); i++)
-                    {
-                        // Peek the next sample to get the duration of the last sample
-                        uint32 numSamples = iNodeTrackPortList[i].iNumSamples;
-
+                    int32 err = 0;
+                    OSCL_TRY(err,
+                             for (uint32 i = 0; i < iNodeTrackPortList.size(); i++)
+                {
+                    // Peek the next sample to get the duration of the last sample
+                    uint32 numSamples = iNodeTrackPortList[i].iNumSamples;
                         MediaMetaInfo* info = NULL;
                         info = (MediaMetaInfo*) OSCL_MALLOC(numSamples * sizeof(MediaMetaInfo));
                         if (info == NULL)
@@ -4517,6 +4972,8 @@
                         }
                         OSCL_FREE(info);
                     }
+                            );
+                    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
 
                     uint32 maxOffsetDiff = 0;
                     for (uint32 ii = 0; ii < iNodeTrackPortList.size(); ii++)
@@ -4551,6 +5008,8 @@
                         // The content is poorly interleaved.
                         ReportMP4FFParserInfoEvent(PVMFInfoPoorlyInterleavedContent);
                         iPoorlyInterleavedContentEventSent = true;
+                        // @TODO - For now, don't treat this as EOS.
+                        // aTrackPortInfo.iState=PVMP4FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
                     }
                     OSCL_FREE(trackOffset);
                 }
@@ -4568,6 +5027,7 @@
 #endif
             if (status == PVMFSuccess)
             {
+                //Request for callback
                 MP4_ERROR_CODE retVal =
                     iMP4FileHandle->RequestReadCapacityNotification(*this, offset);
                 if (retVal == EVERYTHING_FINE)
@@ -4645,19 +5105,31 @@
         return false;
     }
 
-    if (aTrackPortInfo.iFormatType == PVMF_H264_MP4)
+    if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_H264_MP4)
     {
         // Check that the media frag group has been allocated
         OSCL_ASSERT(mediadatafraggroup.GetRep() != NULL);
-        return GenerateAVCNALGroup(aTrackPortInfo, mediadatafraggroup);
+        if (GenerateAVCNALGroup(aTrackPortInfo, mediadatafraggroup) == false)
+        {
+            //This means that this AVC frame is corrupt, do not send it downstream
+            //We do not need to declare EOS here, let us keep going
+            //may be succeeding samples are ok
+            aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_SKIP_CORRUPT_SAMPLE;
+            return false;
+        }
+        else
+        {
+            return true;
+        }
     }
-    else if (aTrackPortInfo.iFormatType == PVMF_MPEG4_AUDIO)
+    else if ((aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_MPEG4_AUDIO)
+             && (oIsAACFramesFragmented))
     {
         // Check that the media frag group has been allocated
         OSCL_ASSERT(mediadatafraggroup.GetRep() != NULL);
         return GenerateAACFrameFrags(aTrackPortInfo, mediadatafraggroup);
     }
-    else if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT)
+    else if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT)
     {
         // Check if the text sample entry needs to be set
         PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*) refCtrMemFragOut.getMemFrag().ptr;
@@ -4678,6 +5150,15 @@
         LogMediaData(aTrackPortInfo.iMediaData, aTrackPortInfo.iPortInterface);
     }
 
+    // if going reverse, dump all non-video data.
+    if (iParseVideoOnly && (iMP4FileHandle->getTrackMediaType(aTrackPortInfo.iTrackId) != MEDIA_TYPE_VISUAL))
+    {
+        // Don't need the ref to iMediaData so unbind it
+        aTrackPortInfo.iState = PVMP4FFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
+        aTrackPortInfo.iMediaData.Unbind();
+        return false;
+    }
+
     // Set the track specific config info
     aTrackPortInfo.iMediaData->setFormatSpecificInfo(aTrackPortInfo.iFormatSpecificConfig);
 
@@ -4752,11 +5233,9 @@
 
                 // Set flag to show that that we have appended at least one frag
                 appended_data = true;
-            }
-            else
-            {
-            }
-        }
+
+            }  // End of if (iInfo->len > 0)
+        } // End of if (iInfo) not NULL
         ii++;
         iInfo = NULL;
     }
@@ -4808,6 +5287,7 @@
     OsclBinIStreamBigEndian sampleStream;
     sampleStream.Attach(memFragIn.getMemFrag().ptr, memFragIn.getMemFrag().len);
 
+    int32 numNAL = 0;
     while (samplesize > 0)
     {
         int32 nallen = 0;
@@ -4818,19 +5298,34 @@
 
             if ((nallen < 0) || (nallen > samplesize))
             {
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC_AVC((0, "PVMFMP4FFParserNode::GenerateAVCNALGroup - Corrupt Sample - SeqNum=%d, SampleSize=%d, NALSize=%d, TS=%d",
+                                                        aTrackPortInfo.iMediaData->getSeqNum(), samplesize, nallen,
+                                                        aTrackPortInfo.iMediaData->getTimestamp()));
+                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::GenerateAVCNALGroup - SeqNum=%d, Size=%d, TS=%d, PTR=0x%x, RC=%d", aTrackPortInfo.iMediaData->getSeqNum(), samplesize, aTrackPortInfo.iMediaData->getTimestamp(), sample, memFragIn.getRefCounter()->getCount()));
                 //ignore corrupt samples / nals
                 return true;
             }
 
-            OsclMemoryFragment memFrag;
-            memFrag.ptr = sample;
-            memFrag.len = nallen;
+            if (nallen > 0)
+            {
+                OsclMemoryFragment memFrag;
+                memFrag.ptr = sample;
+                memFrag.len = nallen;
 
-            refCntIn->addRef();
-            OsclRefCounterMemFrag refCountMemFragOut(memFrag, refCntIn, 0);
-            aMediaFragGroup->appendMediaFragment(refCountMemFragOut);
+                refCntIn->addRef();
+                OsclRefCounterMemFrag refCountMemFragOut(memFrag, refCntIn, 0);
+                aMediaFragGroup->appendMediaFragment(refCountMemFragOut);
 
-            sampleStream.seekFromCurrentPosition(nallen);
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC_AVC((0, "	PVMFMP4FFParserNode::GenerateAVCNALGroup - SN=%d, TS=%d, SS-NALSize=%d, NALSize=%d, NALNum=%d",
+                                                        aTrackPortInfo.iMediaData->getSeqNum(),
+                                                        aTrackPortInfo.iMediaData->getTimestamp(),
+                                                        samplesize - nallen,
+                                                        nallen,
+                                                        numNAL));
+
+                sampleStream.seekFromCurrentPosition(nallen);
+                numNAL++;
+            }
             sample += nallen;
             samplesize -= nallen;
         }
@@ -4840,12 +5335,33 @@
         }
     }
 
+    //check to see if we added any memfrags
+    if (aMediaFragGroup->getNumFragments() == 0)
+    {
+        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC_AVC((0, "PVMFMP4FFParserNode::GenerateAVCNALGroup - No Valid NALs - SeqNum=%d, SampleSize=%d, TS=%d",
+                                                aTrackPortInfo.iMediaData->getSeqNum(), memFragIn.getMemFrag().len,
+                                                aTrackPortInfo.iMediaData->getTimestamp()));
+        PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::GenerateAVCNALGroup - No Valid NALs - SeqNum=%d, Size=%d, TS=%d",
+                                       aTrackPortInfo.iMediaData->getSeqNum(),
+                                       memFragIn.getMemFrag().len,
+                                       aTrackPortInfo.iMediaData->getTimestamp()));
+        //ignore corrupt samples / nals
+        return false;
+    }
+
     PVMFSharedMediaDataPtr avcNALGroup;
     avcNALGroup = PVMFMediaData::createMediaData(aMediaFragGroup, aTrackPortInfo.iMediaData->getMessageHeader());
     avcNALGroup->setSeqNum(aTrackPortInfo.iMediaData->getSeqNum());
     avcNALGroup->setTimestamp(aTrackPortInfo.iMediaData->getTimestamp());
     avcNALGroup->setFormatSpecificInfo(aTrackPortInfo.iFormatSpecificConfig);
 
+    PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC_AVC((0, "PVMFMP4FFParserNode::GenerateAVCNALGroup - SN=%d, SS=%d, NumNAL=%d, TS=%d, Marker=0x%x",
+                                            avcNALGroup->getSeqNum(),
+                                            memFragIn.getMemFrag().len,
+                                            numNAL,
+                                            avcNALGroup->getTimestamp(),
+                                            avcNALGroup->getMarkerInfo()));
+
     // Replace the track's output media data with the frag group one
     aTrackPortInfo.iMediaData = avcNALGroup;
 
@@ -4877,7 +5393,6 @@
     return false;
 }
 
-
 bool PVMFMP4FFParserNode::UpdateTextSampleEntry(PVMP4FFNodeTrackPortInfo& aTrackPortInfo, uint32 aEntryIndex, PVMFTimedTextMediaData& aTextMediaData)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::UpdateTextSampleEntry() In"));
@@ -4948,10 +5463,11 @@
             OSCL_FIRST_CATCH_ANY(errcode,
                                  PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::UpdateTextSampleEntry() Memory for PVMFTimedTextFontRecord list could not be allocated"));
                                  return false);
-
-            for (uint16 i = 0; i < textse_ptr->iFontEntryCount; ++i)
-            {
-                FontRecord* fontrec = textsampleentry->getFontRecordAt(i);
+            errcode = 0;
+            OSCL_TRY(errcode,
+                     for (uint16 i = 0; i < textse_ptr->iFontEntryCount; ++i)
+        {
+            FontRecord* fontrec = textsampleentry->getFontRecordAt(i);
                 if (fontrec)
                 {
                     textse_ptr->iFontRecordList[i].iFontID = fontrec->getFontID();
@@ -4959,11 +5475,7 @@
                     if (textse_ptr->iFontRecordList[i].iFontNameLength > 0)
                     {
                         // Allocate memory for the font name
-                        errcode = 0;
-                        OSCL_TRY(errcode, textse_ptr->iFontRecordList[i].iFontName = OSCL_ARRAY_NEW(uint8, textse_ptr->iFontRecordList[i].iFontNameLength + 1));
-                        OSCL_FIRST_CATCH_ANY(errcode,
-                                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::UpdateTextSampleEntry() Memory for font name could not be allocated"));
-                                             return false);
+                        textse_ptr->iFontRecordList[i].iFontName = OSCL_ARRAY_NEW(uint8, textse_ptr->iFontRecordList[i].iFontNameLength + 1);
 
                         // Copy the font name string
                         oscl_strncpy((char*)(textse_ptr->iFontRecordList[i].iFontName), (char*)(fontrec->getFontName()), textse_ptr->iFontRecordList[i].iFontNameLength + 1);
@@ -4977,8 +5489,11 @@
                     textse_ptr->iFontRecordList[i].iFontName = NULL;
                 }
             }
+                    );
+            OSCL_FIRST_CATCH_ANY(errcode,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::UpdateTextSampleEntry() Memory for font name could not be allocated"));
+                                 return false);
         }
-
         // Save the text track's text sample entry
         aTrackPortInfo.iCurrentTextSampleEntry = tmp_shared_tse;
         // Save the state so text sample entry is only read when changed or not set yet
@@ -4992,7 +5507,6 @@
     return true;
 }
 
-
 bool PVMFMP4FFParserNode::SendEndOfTrackCommand(PVMP4FFNodeTrackPortInfo& aTrackPortInfo)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::SendEndOfTrackCommand() In"));
@@ -5017,7 +5531,8 @@
     //EOS timestamp(aTrackPortInfo.iTimestamp)is considered while deciding the iResumeTimeStamp in the mediaoutput node
     //therefore its length should also be considered while making decision to forward or drop the packet
     //at the mediaoutput node.
-    if (aTrackPortInfo.iFormatType == PVMF_3GPP_TIMEDTEXT && iEOTForTextSentToMIO)
+    if (aTrackPortInfo.iFormatTypeInteger == PVMF_MP4_PARSER_NODE_3GPP_TIMED_TEXT &&
+            iEOTForTextSentToMIO)
     {
         iEOTForTextSentToMIO = false;
         if (iSetTextSampleDurationZero)
@@ -5274,29 +5789,6 @@
     return status;
 }
 
-
-PVMFFormatType PVMFMP4FFParserNode::GetFormatTypeFromMIMEType(PvmfMimeString* aMIMEString)
-{
-    //convert the mimestring to a PVMF format code and verify it.
-    PVMFFormatType fmt = GetFormatIndex(aMIMEString->get_str());
-    switch (fmt)
-    {
-        case PVMF_AMR_IETF:
-        case PVMF_AMRWB_IETF:
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_M4V:
-        case PVMF_H263:
-        case PVMF_H264_MP4:
-        case PVMF_3GPP_TIMEDTEXT:
-            return fmt;
-
-        default:
-            //unsupported fmt
-            return PVMF_FORMAT_UNKNOWN;
-    }
-}
-
-
 void PVMFMP4FFParserNode::ResetAllTracks()
 {
     for (uint32 i = 0; i < iNodeTrackPortList.size(); ++i)
@@ -5327,13 +5819,10 @@
         }
         if (iNodeTrackPortList[0].iTrackDataMemoryPool)
         {
+            iNodeTrackPortList[0].iTrackDataMemoryPool->CancelFreeChunkAvailableCallback();
             iNodeTrackPortList[0].iTrackDataMemoryPool->removeRef();
             iNodeTrackPortList[0].iTrackDataMemoryPool = NULL;
         }
-        if (iNodeTrackPortList[0].iTrackDataMemoryPoolProxy)
-        {
-            OSCL_DELETE(iNodeTrackPortList[0].iTrackDataMemoryPoolProxy);
-        }
         if (iNodeTrackPortList[0].iMediaDataImplAlloc)
         {
             OSCL_DELETE(iNodeTrackPortList[0].iMediaDataImplAlloc);
@@ -5344,7 +5833,8 @@
         }
         if (iNodeTrackPortList[0].iMediaDataMemPool)
         {
-            OSCL_DELETE(iNodeTrackPortList[0].iMediaDataMemPool);
+            iNodeTrackPortList[0].iMediaDataMemPool->CancelFreeChunkAvailableCallback();
+            iNodeTrackPortList[0].iMediaDataMemPool->removeRef();
         }
         if (iNodeTrackPortList[0].iMediaDataGroupAlloc)
         {
@@ -5409,6 +5899,7 @@
     iDownloadComplete = false;
     iMP4HeaderSize = 0;
     iProgressivelyDownlodable = false;
+    iCPMSequenceInProgress = false;
     iFastTrackSession = false;
     iProtectedFile = false;
     iExternalDownload = false;
@@ -5416,6 +5907,10 @@
 
     if (iMP4FileHandle)
     {
+        if (iExternalDownload == true)
+        {
+            iMP4FileHandle->DestroyDataStreamForExternalDownload();
+        }
         IMpeg4File::DestroyMP4FileObject(iMP4FileHandle);
         iMP4FileHandle = NULL;
     }
@@ -5449,8 +5944,10 @@
     }
 
     oWaitingOnLicense = false;
+    iPoorlyInterleavedContentEventSent = false;
 }
 
+// From PVMFMP4ProgDownloadSupportInterface
 int32 PVMFMP4FFParserNode::convertSizeToTime(uint32 fileSize, uint32& timeStamp)
 {
     if (iMP4FileHandle == NULL)
@@ -5459,7 +5956,7 @@
     }
     timeStamp = 0xFFFFFFFF;
     if (iNodeTrackPortList.size() <= 0)
-    {//if track selection is not done, use all the tracks for calculation to avoid deadlock. JJ 12/19/07
+    {//if track selection is not done, use all the tracks for calculation to avoid deadlock.
         int32 iNumTracks = iMP4FileHandle->getNumTracks();
         uint32 iIdList[16];
         if (iNumTracks != iMP4FileHandle->getTrackIDList(iIdList, iNumTracks))
@@ -5635,38 +6132,41 @@
         /* Callbacks intiated  as part of node init */
         if (iDownloadComplete == true)
         {
-            PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::playResumeNotification() - Download Complete"));
-            /*
-             * Can come here only if we are doing PDL / PPB.
-             * Init is still pending and download has completed.
-             * A few possible scenarios here:
-             * - Non-PDL, Non-DRM clip - we are waiting for the complete
-             * file to be downloaded before we can parse the movie atom.
-             * - OMA1 DRM clip - CPM seq complete, and
-             * we were waiting on more data.
-             * - OMA2 PDCF DRM clip - were waiting on more data to parse the movie atom,
-             * CPM seq not complete since we need contents of movie atom to authorize
-             * with CPM
-             * - PDL, Non-DRM clip - we were waiting on more data and
-             * download has completed
-             */
-            if (iCPM)
+            if (iCPMSequenceInProgress == false)
             {
-                if (iCPMContentType == PVMF_CPM_FORMAT_OMA2)
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::playResumeNotification() - Download Complete"));
+                /*
+                 * Can come here only if we are doing PDL / PPB.
+                 * Init is still pending and download has completed.
+                 * A few possible scenarios here:
+                 * - Non-PDL, Non-DRM clip - we are waiting for the complete
+                 * file to be downloaded before we can parse the movie atom.
+                 * - OMA1 DRM clip - CPM seq complete, and
+                 * we were waiting on more data.
+                 * - OMA2 PDCF DRM clip - were waiting on more data to parse the movie atom,
+                 * CPM seq not complete since we need contents of movie atom to authorize
+                 * with CPM
+                 * - PDL, Non-DRM clip - we were waiting on more data and
+                 * download has completed
+                 */
+                if (iCPM)
                 {
-                    PVMP4FFNodeTrackOMA2DRMInfo* oma2trackInfo = NULL;
-                    if (ParseMP4File(iCurrentCommand,
-                                     iCurrentCommand.front()))
+                    if (iCPMContentType == PVMF_CPM_FORMAT_OMA2)
                     {
-                        if (CheckForOMA2AuthorizationComplete(oma2trackInfo) == PVMFPending)
+                        PVMP4FFNodeTrackOMA2DRMInfo* oma2trackInfo = NULL;
+                        if (ParseMP4File(iCurrentCommand,
+                                         iCurrentCommand.front()))
                         {
-                            RequestUsage(oma2trackInfo);
-                            return;
+                            if (CheckForOMA2AuthorizationComplete(oma2trackInfo) == PVMFPending)
+                            {
+                                RequestUsage(oma2trackInfo);
+                                return;
+                            }
                         }
                     }
                 }
+                CompleteInit(iCurrentCommand, iCurrentCommand.front());
             }
-            CompleteInit(iCurrentCommand, iCurrentCommand.front());
         }
         //Ignore this callback we are waiting on notifydownload complete
     }
@@ -6164,24 +6664,29 @@
 /* CPM related */
 void PVMFMP4FFParserNode::InitCPM()
 {
+    iCPMSequenceInProgress = true;
     iCPMInitCmdId = iCPM->Init();
 }
 
 void PVMFMP4FFParserNode::OpenCPMSession()
 {
+    iCPMSequenceInProgress = true;
     iCPMOpenSessionCmdId = iCPM->OpenSession(iCPMSessionID);
 }
 
 void PVMFMP4FFParserNode::GetCPMLicenseInterface()
 {
+    iCPMSequenceInProgress = true;
+    iCPMLicenseInterfacePVI = NULL;
     iCPMGetLicenseInterfaceCmdId =
         iCPM->QueryInterface(iCPMSessionID,
                              PVMFCPMPluginLicenseInterfaceUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMLicenseInterface));
+                             iCPMLicenseInterfacePVI);
 }
 
 bool PVMFMP4FFParserNode::GetCPMContentAccessFactory()
 {
+    iCPMSequenceInProgress = true;
     PVMFStatus status = iCPM->GetContentAccessFactory(iCPMSessionID,
                         iCPMContentAccessFactory);
     if (status != PVMFSuccess)
@@ -6193,6 +6698,7 @@
 
 void PVMFMP4FFParserNode::CPMRegisterContent()
 {
+    iCPMSequenceInProgress = true;
     if (iSourceContextDataValid == true)
     {
         iCPMRegisterContentCmdId = iCPM->RegisterContent(iCPMSessionID,
@@ -6216,9 +6722,11 @@
 
 bool PVMFMP4FFParserNode::GetCPMMetaDataExtensionInterface()
 {
+    iCPMSequenceInProgress = true;
+    PVInterface* temp = NULL;
     bool retVal =
-        iCPM->queryInterface(KPVMFMetadataExtensionUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMMetaDataExtensionInterface));
+        iCPM->queryInterface(KPVMFMetadataExtensionUuid, temp);
+    iCPMMetaDataExtensionInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, temp);
     return retVal;
 }
 
@@ -6369,6 +6877,7 @@
         }
     }
 
+    iCPMSequenceInProgress = true;
     iCPMRequestUsageId = iCPM->ApproveUsage(iCPMSessionID,
                                             iRequestedUsage,
                                             iApprovedUsage,
@@ -6562,6 +7071,7 @@
 
 void PVMFMP4FFParserNode::SendUsageComplete()
 {
+    iCPMSequenceInProgress = true;
     iCPMUsageCompleteCmdId = iCPM->UsageComplete(iCPMSessionID, iUsageID);
 }
 
@@ -6628,6 +7138,7 @@
 
 void PVMFMP4FFParserNode::CPMCommandCompleted(const PVMFCmdResp& aResponse)
 {
+    iCPMSequenceInProgress = false;
     PVMFCommandId id = aResponse.GetCmdId();
     PVMFStatus status =
         CheckCPMCommandCompleteStatus(id, aResponse.GetCmdStatus());
@@ -6714,6 +7225,8 @@
         }
         else if (id == iCPMGetLicenseInterfaceCmdId)
         {
+            iCPMLicenseInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, iCPMLicenseInterfacePVI);
+            iCPMLicenseInterfacePVI = NULL;
             GetCPMContentType();
             if ((iCPMContentType == PVMF_CPM_FORMAT_OMA1) ||
                     (iCPMContentType == PVMF_CPM_FORMAT_AUTHORIZE_BEFORE_ACCESS))
@@ -6846,6 +7359,7 @@
         }
         else
         {
+            /* Unknown cmd - error */
             CommandComplete(iCurrentCommand,
                             iCurrentCommand.front(),
                             PVMFFailure);
@@ -6957,7 +7471,7 @@
         {
                 /*
                 ** Its possible that track reports inufficient data but does not report Underflow and
-                ** justs sets the timer. If we recieve DataStreamCommandComplete means we need not report
+                ** justs sets the timer. If we receive DataStreamCommandComplete means we need not report
                 ** underflow now, so set track state as GETDATA, cancel the timer and schedule Node to
                 ** retrieve data. This case will only happen if CheckForUnderflow returns Pending for
                 ** any track.
@@ -7103,7 +7617,6 @@
     OSCL_ASSERT(false);
 }
 
-
 void PVMFMP4FFParserNode::getBrand(uint32 aBrandVal, char *BrandVal)
 {
     BrandVal[0] = (aBrandVal >> 24);
@@ -7268,6 +7781,15 @@
                 }
             }
         }
+        else if (retCode == INSUFFICIENT_DATA)
+        {
+            iRequestReadCapacityNotificationID =
+                iDataStreamInterface->RequestReadCapacityNotification(iDataStreamSessionID,
+                        *this,
+                        (iMP4HeaderSize + MP4_MIN_BYTES_FOR_GETTING_MOVIE_HDR_SIZE));
+            iDataStreamRequestPending = true;
+            return PVMFPending;
+        }
         else if (retCode == NOT_PROGRESSIVE_STREAMABLE)
         {
             // progressive playback and no movie atom found
@@ -7285,17 +7807,17 @@
 
 PVMFStatus PVMFMP4FFParserNode::CheckForUnderFlow(PVMP4FFNodeTrackPortInfo* aInfo)
 {
-    uint64 timebase64 = 0;
-    uint64 clientClock = 0;
+    uint32 timebase32 = 0;
+    uint32 clientClock32 = 0;
+    bool overload = 0;
     if (iClientPlayBackClock != NULL)
     {
-        iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_MSEC, timebase64);
+        iClientPlayBackClock->GetCurrentTime32(clientClock32, overload, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     }
     else
     {
         return PVMFFailure;
     }
-    uint32 clientClock32 = Oscl_Int64_Utils::get_uint64_lower32(clientClock);
 
     MediaClockConverter clock_conv(*(aInfo->iClockConverter));
     clock_conv.update_clock(aInfo->iTimestamp);
@@ -7304,7 +7826,7 @@
     {
         uint32 diff32 = (msec - clientClock32);
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::CheckForUnderFlow - Diff Bet Client Clock(%d) and Track Media TS(%d) = %d", clientClock32, msec, diff32));
-        if (diff32 < PVMP4FF_UNDERFLOW_THRESHOLD_IN_MS || aInfo->iFormatType == PVMF_AMR_IETF || aInfo->iFormatType == PVMF_MPEG4_AUDIO)
+        if (diff32 < PVMP4FF_UNDERFLOW_THRESHOLD_IN_MS || aInfo->iFormatType == PVMF_MIME_AMR_IETF || aInfo->iFormatType == PVMF_MIME_MPEG4_AUDIO)
         {
             PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::CheckForUnderFlow - Time To Auto Pause"));
             return PVMFSuccess;
@@ -7321,7 +7843,6 @@
     else
     {
         PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::CheckForUnderFlow - Client Clock Greater than Media TS, Clock=%d, MaxMTS=%d",  clientClock32, msec));
-        //should never happen
         OSCL_ASSERT(false);
     }
 
@@ -7362,7 +7883,6 @@
     {
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::ReportUnderFlow - Reporting UnderFlow"));
         ReportInfoEvent(PVMFInfoUnderflow);
-        iNPTAtUnderFlow = 0;
         iUnderFlowEventReported = true;
         return PVMFSuccess;
     }
@@ -7382,12 +7902,13 @@
             }
         }
     }
-    uint64 timebase64 = 0;
-    uint64 clientClock = 0;
-    if (iClientPlayBackClock != NULL)
-        iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_MSEC, timebase64);
+    uint32 timebase32 = 0;
+    uint32 clientClock32 = 0;
+    bool overload = 0;
 
-    uint32 clientClock32 = Oscl_Int64_Utils::get_uint64_lower32(clientClock);
+    if (iClientPlayBackClock != NULL)
+        iClientPlayBackClock->GetCurrentTime32(clientClock32, overload, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+
 
     uint32 currentFileSize = 0;
     MP4_ERROR_CODE code = iMP4FileHandle->GetCurrentFileSize(currentFileSize);
@@ -7397,12 +7918,12 @@
         return PVMFFailure;
     }
 
-    iNPTAtUnderFlow = 0;
     iUnderFlowEventReported = false;
-    convertSizeToTime(currentFileSize, iNPTAtUnderFlow);
+    uint32 currNPT = 0;
+    convertSizeToTime(currentFileSize, currNPT);
 
     PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::ReportUnderFlow - ClientClock = %d", clientClock32));
-    PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::ReportUnderFlow - NPTInMS = %d, FileSize = %d", iNPTAtUnderFlow, currentFileSize));
+    PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::ReportUnderFlow - NPTInMS = %d, FileSize = %d", currNPT, currentFileSize));
     PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::ReportUnderFlow - Min Media TS = %d", minTS));
 
     if (clientClock32 <= minTS)
@@ -7421,7 +7942,6 @@
             }
             PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::ReportUnderFlow - Reporting UnderFlow"));
             ReportInfoEvent(PVMFInfoUnderflow);
-            iNPTAtUnderFlow = 0;
             iUnderFlowEventReported = true;
         }
         else
@@ -7458,12 +7978,6 @@
                 uint32 currNPT = 0;
                 convertSizeToTime(currentFileSize, currNPT);
 
-                uint32 diffInNPT = 0;
-                if (currNPT > iNPTAtUnderFlow)
-                {
-                    diffInNPT = (iNPTAtUnderFlow - currNPT);
-                    iNPTAtUnderFlow = currNPT;
-                }
                 uint32 minTS = 0xFFFFFFFF;
                 Oscl_Vector<PVMP4FFNodeTrackPortInfo, OsclMemAllocator>::iterator it;
                 for (it = iNodeTrackPortList.begin(); it != iNodeTrackPortList.end(); it++)
@@ -7479,17 +7993,15 @@
                         }
                     }
                 }
-                uint64 timebase64 = 0;
-                uint64 clientClock = 0;
-
+                uint32 timebase32 = 0;
+                uint32 clientClock32 = 0;
+                bool overload = 0;
                 if (iClientPlayBackClock != NULL)
-                    iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_MSEC, timebase64);
+                    iClientPlayBackClock->GetCurrentTime32(clientClock32, overload, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 
-                uint32 clientClock32 = Oscl_Int64_Utils::get_uint64_lower32(clientClock);
-                minTS += diffInNPT;
 
                 PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::TimeoutOccurred - ClientClock = %d", clientClock32));
-                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::TimeoutOccurred - NPTInMS = %d, DiffInNPT = %d, FileSize = %d", currNPT, diffInNPT, currentFileSize));
+                PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::TimeoutOccurred - NPTInMS = %d,  FileSize = %d", currNPT, currentFileSize));
                 PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::TimeoutOccurred - Min Media TS = %d", minTS));
 
                 if (clientClock32 <= minTS)
@@ -7509,7 +8021,6 @@
 
                         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::TimeoutOccurred - Reporting UnderFlow"));
                         ReportInfoEvent(PVMFInfoUnderflow);
-                        iNPTAtUnderFlow = 0;
                         iUnderFlowEventReported = true;
                     }
                     else
@@ -7536,16 +8047,15 @@
         }
         else if (iDownloadComplete == false && iUnderFlowEventReported == false)
         {
-            uint64 timebase64 = 0;
-            uint64 clientClock = 0;
+            uint32 timebase32 = 0;
+            uint32 clientClock32 = 0;
+            bool overload = 0;
             uint32 msec = 0;
             if (iClientPlayBackClock != NULL)
             {
-                iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_MSEC, timebase64);
+                iClientPlayBackClock->GetCurrentTime32(clientClock32, overload, PVMF_MEDIA_CLOCK_MSEC, timebase32);
             }
 
-            uint32 clientClock32 = Oscl_Int64_Utils::get_uint64_lower32(clientClock);
-
             Oscl_Vector<PVMP4FFNodeTrackPortInfo, OsclMemAllocator>::iterator it;
             for (it = iNodeTrackPortList.begin(); it != iNodeTrackPortList.end(); it++)
             {
@@ -7586,6 +8096,7 @@
             else
             {
                 PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::TimeoutOccurred - Client Clock Greater than Media TS, Clock=%d, MaxMTS=%d",  clientClock32, msec));
+                //should never happen
                 OSCL_ASSERT(false);
             }
             PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode::TimeoutOccurred - UnderFlow TimeOut - After AutoResume"));
@@ -7676,8 +8187,11 @@
     int32 display_width = 0;
     int32 display_height = 0;
 
-    uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(aId);
-    if (trackOTIType  == H263_VIDEO)
+    OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+    iMP4FileHandle->getTrackMIMEType(aId, trackMIMEType);
+
+    if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
     {
         H263DecoderSpecificInfo *ptr =
             (H263DecoderSpecificInfo *)iMP4FileHandle->getTrackDecoderSpecificInfoAtSDI(aId, 0);
@@ -7702,7 +8216,7 @@
             retval = iMP4FileHandle->peekNextBundledAccessUnits(aId,
                      &numSamples,
                      &info);
-            if (retval == EVERYTHING_FINE || END_OF_TRACK == retval)
+            if ((retval == EVERYTHING_FINE || END_OF_TRACK == retval) && numSamples > 0)
             {
                 uint32 sampleSize = info.len;
                 if (sampleSize > 0)
@@ -7733,10 +8247,10 @@
 
                         int16 status =
                             iDecodeShortHeader(&streamType,
-                                               (int*) & width,
-                                               (int*) & height,
-                                               (int*) & display_width,
-                                               (int*) & display_height);
+                                               (int32*) & width,
+                                               (int32*) & height,
+                                               (int32*) & display_width,
+                                               (int32*) & display_height);
                         if (status != 0)
                         {
                             return PVMFFailure;
@@ -7755,8 +8269,14 @@
         }
 
     }
-    else if (trackOTIType  == AVC_VIDEO)
+    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0)
     {
+        display_width = iMP4FileHandle->getVideoFrameWidth(aId);
+        if (display_width > 0)
+        {
+            aDisplayWidth = display_width;
+        }
+
         uint32 specinfosize =
             iMP4FileHandle->getTrackDecoderSpecificInfoSize(aId);
         if (specinfosize != 0)
@@ -7764,24 +8284,35 @@
             // Retrieve the decoder specific info from file parser
             uint8* specinfoptr =
                 iMP4FileHandle->getTrackDecoderSpecificInfoContent(aId);
+            int32 profile, level = 0;// this info is discarded
             int16 status =
                 iGetAVCConfigInfo(specinfoptr,
                                   (int32)specinfosize,
-                                  (int*) & width,
-                                  (int*) & height,
-                                  (int*) & display_width,
-                                  (int*) & display_height);
+                                  (int32*) & width,
+                                  (int32*) & height,
+                                  (int32*) & display_width,
+                                  (int32*) & display_height,
+                                  (int32*) & profile,
+                                  (int32*) & level);
             if (status != 0)
             {
                 return PVMFFailure;
             }
 
             aWidth = width;
-            aDisplayWidth = display_width;
+
+            if (aDisplayWidth == 0)
+                aDisplayWidth = display_width;
         }
     }
-    else if (trackOTIType  == MPEG4_VIDEO)
+    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0)
     {
+        display_width = iMP4FileHandle->getVideoFrameWidth(aId);
+        if (display_width > 0)
+        {
+            aDisplayWidth = display_width;
+        }
+
         uint32 specinfosize =
             iMP4FileHandle->getTrackDecoderSpecificInfoSize(aId);
         if (specinfosize != 0)
@@ -7792,17 +8323,19 @@
             int16 status =
                 iGetM4VConfigInfo(specinfoptr,
                                   (int32)specinfosize,
-                                  (int*) & width,
-                                  (int*) & height,
-                                  (int*) & display_width,
-                                  (int*) & display_height);
+                                  (int32*) & width,
+                                  (int32*) & height,
+                                  (int32*) & display_width,
+                                  (int32*) & display_height);
             if (status != 0)
             {
                 return PVMFFailure;
             }
 
             aWidth = width;
-            aDisplayWidth = display_width;
+
+            if (aDisplayWidth == 0)
+                aDisplayWidth = display_width;
         }
     }
 
@@ -7816,8 +8349,10 @@
     int32 display_width = 0;
     int32 display_height = 0;
 
-    uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(aId);
-    if (trackOTIType  == H263_VIDEO)
+    OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+    iMP4FileHandle->getTrackMIMEType(aId, trackMIMEType);
+
+    if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
     {
         H263DecoderSpecificInfo *ptr =
             (H263DecoderSpecificInfo *)iMP4FileHandle->getTrackDecoderSpecificInfoAtSDI(aId, 0);
@@ -7840,7 +8375,7 @@
             retval = iMP4FileHandle->peekNextBundledAccessUnits(aId,
                      &numSamples,
                      &info);
-            if (retval == EVERYTHING_FINE || END_OF_TRACK == retval)
+            if ((retval == EVERYTHING_FINE || END_OF_TRACK == retval) && numSamples > 0)
             {
                 uint32 sampleSize = info.len;
                 if (sampleSize > 0)
@@ -7871,10 +8406,10 @@
 
                         int16 status =
                             iDecodeShortHeader(&streamType,
-                                               (int*) & width,
-                                               (int*) & height,
-                                               (int*) & display_width,
-                                               (int*) & display_height);
+                                               (int32*) & width,
+                                               (int32*) & height,
+                                               (int32*) & display_width,
+                                               (int32*) & display_height);
                         if (status != 0)
                         {
                             return PVMFFailure;
@@ -7892,8 +8427,14 @@
             }
         }
     }
-    if (trackOTIType  == AVC_VIDEO)
+    if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0)
     {
+        display_height = iMP4FileHandle->getVideoFrameHeight(aId);
+        if (display_height > 0)
+        {
+            aDisplayHeight = display_height;
+        }
+
         uint32 specinfosize =
             iMP4FileHandle->getTrackDecoderSpecificInfoSize(aId);
         if (specinfosize != 0)
@@ -7901,24 +8442,35 @@
             // Retrieve the decoder specific info from file parser
             uint8* specinfoptr =
                 iMP4FileHandle->getTrackDecoderSpecificInfoContent(aId);
+            int profile, level = 0; // this info is discarded here
             int16 status =
                 iGetAVCConfigInfo(specinfoptr,
                                   (int32)specinfosize,
-                                  (int*) & width,
-                                  (int*) & height,
-                                  (int*) & display_width,
-                                  (int*) & display_height);
+                                  (int32*) & width,
+                                  (int32*) & height,
+                                  (int32*) & display_width,
+                                  (int32*) & display_height,
+                                  (int32*) & profile,
+                                  (int32*) & level);
             if (status != 0)
             {
                 return PVMFFailure;
             }
 
             aHeight = height;
-            aDisplayHeight = display_height;
+
+            if (aDisplayHeight == 0)
+                aDisplayHeight = display_height;
         }
     }
-    else if (trackOTIType  == MPEG4_VIDEO)
+    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0)
     {
+        display_height = iMP4FileHandle->getVideoFrameHeight(aId);
+        if (display_height > 0)
+        {
+            aDisplayHeight = display_height;
+        }
+
         uint32 specinfosize =
             iMP4FileHandle->getTrackDecoderSpecificInfoSize(aId);
         if (specinfosize != 0)
@@ -7929,17 +8481,20 @@
             int16 status =
                 iGetM4VConfigInfo(specinfoptr,
                                   (int32)specinfosize,
-                                  (int*) & width,
-                                  (int*) & height,
-                                  (int*) & display_width,
-                                  (int*) & display_height);
+                                  (int32*) & width,
+                                  (int32*) & height,
+                                  (int32*) & display_width,
+                                  (int32*) & display_height);
             if (status != 0)
             {
                 return PVMFFailure;
             }
 
             aHeight = height;
-            aDisplayHeight = display_height;
+
+            if (aDisplayHeight == 0)
+                aDisplayHeight = display_height;
+
         }
     }
 
@@ -8024,15 +8579,17 @@
     uint8 audioObjectType;
     uint8 sampleRateIndex;
 
-    uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(aId);
-    if ((trackOTIType  == AMR_AUDIO) ||
-            (trackOTIType  == AMR_AUDIO_3GPP) ||
-            (trackOTIType  == AMRWB_AUDIO_3GPP))
+    OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+    iMP4FileHandle->getTrackMIMEType(aId, trackMIMEType);
+
+    if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR, oscl_strlen(PVMF_MIME_AMR)) == 0) ||
+            (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0) ||
+            (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0))
     {
         //always mono
         num_channels = 1;
     }
-    else if (trackOTIType  == MPEG4_AUDIO)
+    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0)
     {
         int32 specinfosize =
             (int32)(iMP4FileHandle->getTrackDecoderSpecificInfoSize(aId));
@@ -8049,6 +8606,7 @@
                                &num_channels);
         }
     }
+
     return num_channels;
 }
 
@@ -8066,17 +8624,21 @@
          7350
         };
 
-    uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(aId);
-    if ((trackOTIType  == AMR_AUDIO) ||
-            (trackOTIType  == AMR_AUDIO_3GPP))
+    OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+    iMP4FileHandle->getTrackMIMEType(aId, trackMIMEType);
+
+    if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR, oscl_strlen(PVMF_MIME_AMR)) == 0) ||
+            (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0))
     {
         //always 8KHz
         sample_rate = 8000;
     }
-    else if (trackOTIType  == AMRWB_AUDIO_3GPP)
+    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0)
+    {
         //always 16KHz
         sample_rate = 16000;
-    else if (trackOTIType  == MPEG4_AUDIO)
+    }
+    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0)
     {
         int32 specinfosize =
             (int32)(iMP4FileHandle->getTrackDecoderSpecificInfoSize(aId));
@@ -8168,18 +8730,14 @@
             return PVMFSuccess;
         }
 
-        uint64 trackduration  = iMP4FileHandle->getTrackMediaDuration(aId);
-        uint32 samplecount = iMP4FileHandle->getSampleCountInTrack(aId);
+        uint64 trackduration;
+        uint32 samplecount;
+        trackduration = iMP4FileHandle->getTrackMediaDuration(aId);
+        samplecount = iMP4FileHandle->getSampleCountInTrack(aId);
 
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode:FindBestThumbnailKeyFrame - TrackDuration=%2d", trackduration));
         PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode:FindBestThumbnailKeyFrame - TotalNumSamples=%d", samplecount));
-
-        MediaClockConverter mcc(iMP4FileHandle->getTrackMediaTimescale(aId));
-        mcc.update_clock(trackduration);
-        uint32 TrackDurationInSec = mcc.get_converted_ts(1);
-        uint32 frame_rate = samplecount / TrackDurationInSec;
-        uint32 bitRate = (uint32) iMP4FileHandle->getTrackAverageBitrate(aId);
-        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode:FindBestThumbnailKeyFrame - FrameRate=%d, BitRate=%d", frame_rate, bitRate));
+        PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC((0, "PVMFMP4FFParserNode:FindBestThumbnailKeyFrame - BitRate=%d", (uint32)iMP4FileHandle->getTrackAverageBitrate(aId)));
 
         //go thru the key frame list and determine the optimal key frame
         uint32 keySampleNum = syncfrnum[0];
@@ -8412,25 +8970,34 @@
     return true;
 }
 
+void PVMFMP4FFParserNode::NotificationsInterfaceDestroyed()
+{
+    iClockNotificationsInf = NULL;
+}
+
+void PVMFMP4FFParserNode::ClockStateUpdated()
+{
+    if ((iExternalDownload && iUnderFlowEventReported) ||
+            (autopaused && download_progress_interface != NULL))
+    {
+        // Don't let anyone start the clock while the source node is in underflow
+        if (iClientPlayBackClock != NULL)
+        {
+            if (iClientPlayBackClock->GetState() == PVMFMediaClock::RUNNING)
+            {
+                iClientPlayBackClock->Pause();
+            }
+        }
+    }
+}
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+int32 PVMFMP4FFParserNode::CreateErrorInfoMsg(PVMFBasicErrorInfoMessage** aErrorMsg, PVUuid aEventUUID, int32 aEventCode)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, *aErrorMsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, aEventUUID, NULL)));
+    return leavecode;
+}
 
 
 
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.h b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.h
index 24f6209..f494775 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.h
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,8 +23,8 @@
 #include "oscl_base.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #ifndef OSCL_TIMER_H_INCLUDED
@@ -170,6 +170,15 @@
 #ifndef PVMI_KVP_UTIL_H_INCLUDED
 #include "pvmi_kvp_util.h"
 #endif
+
+#ifndef PVMF_BASIC_ERRORINFOMESSAGE_H_INCLUDED
+#include "pvmf_basic_errorinfomessage.h"
+#endif
+
+#ifndef PVMF_DATA_SOURCE_DIRECTION_CONTROL_H_INCLUDED
+#include "pvmf_data_source_direction_control.h"
+#endif
+
 /**
 * Node command handling
 */
@@ -191,6 +200,8 @@
 
 #define PVMF_MP4FFPARSERNODE_MAX_CPM_METADATA_KEYS 256
 
+#define NORMAL_PLAYRATE 100000
+
 typedef PVMFGenericNodeCommand<OsclMemAllocator> PVMFMP4FFParserNodeCommandBase;
 
 enum PVMFMP4FFParserNodeCommandType
@@ -204,6 +215,7 @@
     , PVMP4FF_NODE_CMD_GET_LICENSE
     , PVMP4FF_NODE_CMD_CANCEL_GET_LICENSE
     , PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS
+    , PVMP4FF_NODE_CMD_SETDATASOURCEDIRECTION
 };
 
 class PVMFMP4FFParserNodeCommand : public PVMFMP4FFParserNodeCommandBase
@@ -340,9 +352,31 @@
             aSeekPointAfterTargetNPT = (PVMFTimestamp*)iParam5;
             aSeekToSyncPoint = (iParam3) ? true : false;
         }
+        /* Constructor and parser for SetDataSourceDirection */
+        void Construct(PVMFSessionId s, int32 cmd, int32 aDirection,
+                       PVMFTimestamp& aActualNPT, PVMFTimestamp& aActualMediaDataTS,
+                       PVMFTimebase* aTimebase, OsclAny* aContext)
+        {
+            PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aDirection;
+            iParam2 = (OsclAny*) & aActualNPT;
+            iParam3 = (OsclAny*) & aActualMediaDataTS;
+            iParam4 = (OsclAny*)aTimebase;
+            iParam5 = NULL;
+        }
+        void Parse(int32& aDirection,
+                   PVMFTimestamp*& aActualNPT,
+                   PVMFTimestamp*& aActualMediaDataTS,
+                   PVMFTimebase*& aTimebase)
+        {
+            aDirection = (int32)iParam1;
+            aActualNPT = (PVMFTimestamp*)iParam2;
+            aActualMediaDataTS = (PVMFTimestamp*)iParam3;
+            aTimebase = (PVMFTimebase*)iParam4;
+        }
 
         // Constructor and parser for SetDataSourceRate
-        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, OsclTimebase* aTimebase, const OsclAny*aContext)
+        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny*aContext)
         {
             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
             iParam1 = (OsclAny*)aRate;
@@ -351,10 +385,10 @@
             iParam4 = NULL;
             iParam5 = NULL;
         }
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
         {
             aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
+            aTimebase = (PVMFTimebase*)iParam2;
         }
 
         /* Constructor and parser for GetLicenseW */
@@ -454,46 +488,6 @@
 };
 typedef PVMFNodeCommandQueue<PVMFMP4FFParserNodeCommand, OsclMemAllocator> PVMFMP4FFParserNodeCmdQueue;
 
-
-// Allocator wrapper for the memory pool that saves the last block pointer allocated
-// so it can be resized later
-class TrackDataMemPoolProxyAlloc : public Oscl_DefAlloc
-{
-    public:
-        TrackDataMemPoolProxyAlloc(OsclMemPoolResizableAllocator& aMemPool)
-        {
-            iMemPoolAllocPtr = &aMemPool;
-            iLastAllocatedBlockPtr = NULL;
-        }
-
-        virtual ~TrackDataMemPoolProxyAlloc()
-        {
-        }
-
-        OsclAny* allocate(const uint32 size)
-        {
-            OSCL_ASSERT(iMemPoolAllocPtr);
-            iLastAllocatedBlockPtr = iMemPoolAllocPtr->allocate(size);
-            return iLastAllocatedBlockPtr;
-        }
-
-        void deallocate(OsclAny* p)
-        {
-            OSCL_ASSERT(iMemPoolAllocPtr);
-            iMemPoolAllocPtr->deallocate(p);
-        }
-
-        bool trim(uint32 aBytesToFree)
-        {
-            OSCL_ASSERT(iMemPoolAllocPtr);
-            OSCL_ASSERT(iLastAllocatedBlockPtr);
-            return iMemPoolAllocPtr->trim(iLastAllocatedBlockPtr, aBytesToFree);
-        }
-
-        OsclMemPoolResizableAllocator* iMemPoolAllocPtr;
-        OsclAny* iLastAllocatedBlockPtr;
-};
-
 //Command queue type
 typedef PVMFNodeCommandQueue<PVMFMP4FFParserNodeCommand, OsclMemAllocator> PVMFMP4FFParserNodeCmdQueue;
 
@@ -505,7 +499,7 @@
 class PVMFMP4FFParserOutPort;
 class PVMFMP4FFPortIter;
 class PVLogger;
-class OsclClock;
+class PVMFMediaClock;
 
 enum BaseKeys_SelectionType
 {
@@ -529,7 +523,9 @@
             public PVMFFormatProgDownloadSupportInterface,
             public OsclTimerObserver,
             public PVMFCPMPluginLicenseInterface,
-            public PvmiCapabilityAndConfig
+            public PvmiCapabilityAndConfig,
+            public PVMFMediaClockStateObserver, // For observing the playback clock states
+            public PvmfDataSourceDirectionControlInterface
 {
     public:
         PVMFMP4FFParserNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
@@ -611,8 +607,8 @@
 
         // From PVMFDataSourceInitializationExtensionInterface
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         // From PVMFTrackSelectionExtensionInterface
         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
@@ -637,7 +633,9 @@
         PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId, PVMFTimestamp aTargetNPT,
                                               PVMFTimestamp& aSeekPointBeforeTargetNPT, PVMFTimestamp& aSeekPointAfterTargetNPT,  OsclAny* aContext = NULL, bool aSeekToSyncPoint = true);
 
-        PVMFCommandId SetDataSourceRate(PVMFSessionId aSession, int32 aRate, OsclTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
+        PVMFCommandId SetDataSourceRate(PVMFSessionId aSession, int32 aRate, PVMFTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
+        PVMFCommandId SetDataSourceDirection(PVMFSessionId aSessionId, int32 aDirection, PVMFTimestamp& aActualNPT,
+                                             PVMFTimestamp& aActualMediaDataTS, PVMFTimebase* aTimebase, OsclAny* aContext);
 
         // From PVMFTrackLevelInfoExtensionInterface
         PVMFStatus GetAvailableTracks(Oscl_Vector<PVMFTrackInfo, OsclMemAllocator>& aTracks);
@@ -716,6 +714,10 @@
         PVMFStatus GetLicenseStatus(
             PVMFCPMLicenseStatus& aStatus) ;
 
+        //from PVMFMediaClockStateObserver
+        void ClockStateUpdated();
+        void NotificationsInterfaceDestroyed();
+
     private:
         // from OsclTimerObject
         void Run();
@@ -740,7 +742,7 @@
         PVMFStatus DoQueryUuid(PVMFMP4FFParserNodeCommand& aCmd);
         PVMFStatus DoQueryInterface(PVMFMP4FFParserNodeCommand& aCmd);
         PVMFStatus DoRequestPort(PVMFMP4FFParserNodeCommand& aCmd, PVMFPortInterface*&);
-        void GetTrackMaxParameters(PVMFFormatType& aFormatType, uint32& aMaxDataSize, uint32& aMaxQueueDepth);
+        void GetTrackMaxParameters(PVMFFormatType aFormatType, uint32& aMaxDataSize, uint32& aMaxQueueDepth);
         PVMFStatus DoReleasePort(PVMFMP4FFParserNodeCommand& aCmd);
 
         PVMFStatus DoInit(PVMFMP4FFParserNodeCommand& aCmd);
@@ -796,6 +798,8 @@
         PVMFStatus DoQueryDataSourcePosition(PVMFMP4FFParserNodeCommand& aCmd);
         PVMFStatus DoSetDataSourceRate(PVMFMP4FFParserNodeCommand& aCmd);
 
+        PVMFStatus DoSetDataSourceDirection(PVMFMP4FFParserNodeCommand& aCmd);
+
         void HandleTrackState();
         bool RetrieveTrackConfigInfo(uint32 aTrackId,
                                      PVMFFormatType aFormatType,
@@ -839,7 +843,8 @@
 
         OSCL_wHeapString<OsclMemAllocator> iFilename;
         PVMFFormatType iSourceFormat;
-        OsclClock* iClientPlayBackClock;
+        PVMFMediaClock* iClientPlayBackClock;
+        PVMFMediaClockNotificationsInterface *iClockNotificationsInf;
         bool iUseCPMPluginRegistry;
         PVMFLocalDataSource iCPMSourceData;
         PVMFSourceContextData iSourceContextData;
@@ -863,13 +868,14 @@
         PVMFNodeCapability iCapability;
         PVLogger* iLogger;
         PVLogger* iDataPathLogger;
+        PVLogger* iAVCDataPathLogger;
         PVLogger* iClockLogger;
         PVLogger* iDiagnosticsLogger;
         // Reference counter for extension
         uint32 iExtensionRefCount;
 
         // variables to support download autopause
-        OsclSharedPtr<OsclClock> download_progress_clock;
+        OsclSharedPtr<PVMFMediaClock> download_progress_clock;
         PVMFDownloadProgressInterface* download_progress_interface;
         uint32 iDownloadFileSize;
         bool autopaused;
@@ -893,12 +899,14 @@
         PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
         PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
         PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
+        PVInterface* iCPMLicenseInterfacePVI;
         PVMFCPMPluginAccessUnitDecryptionInterface* iDecryptionInterface;
         PvmiKvp iRequestedUsage;
         PvmiKvp iApprovedUsage;
         PvmiKvp iAuthorizationDataKvp;
         PVMFCPMUsageID iUsageID;
         bool oWaitingOnLicense;
+        bool iPoorlyInterleavedContentEventSent;
 
         PVMFCommandId iCPMInitCmdId;
         PVMFCommandId iCPMOpenSessionCmdId;
@@ -955,6 +963,13 @@
         void getBrand(uint32 langcode, char *LangCode);
 
         PVMFStatus CheckForMP4HeaderAvailability();
+        int32 CreateErrorInfoMsg(PVMFBasicErrorInfoMessage** aErrorMsg, PVUuid aEventUUID, int32 aEventCode);
+        void CreateDurationInfoMsg(uint32 adurationms);
+        PVMFStatus PushKVPToMetadataValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>* aVecPtr, PvmiKvp& aKvpVal);
+        PVMFStatus CreateNewArray(uint32** aTrackidList, uint32 aNumTracks);
+        PVMFStatus PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetadataKeys,
+                                   PVMFMetadataList *&aKeyListPtr,
+                                   uint32 aLcv);
         PVMIDataStreamSyncInterface* iDataStreamInterface;
         PVMFDataStreamFactory* iDataStreamFactory;
         PVMFDataStreamReadCapacityObserver* iDataStreamReadCapacityObserver;
@@ -970,7 +985,6 @@
         /* External PseudoStreaming related */
         bool iExternalDownload;
 
-        uint32 iNPTAtUnderFlow;
         bool iUnderFlowEventReported;
         PVMFStatus ReportUnderFlow();
         OsclTimer<OsclMemAllocator> *iUnderFlowCheckTimer;
@@ -1010,7 +1024,18 @@
         BaseKeys_SelectionType iBaseKey;
         uint32 iJitterBufferDurationInMs;
         bool iDataStreamRequestPending;
-        bool iPoorlyInterleavedContentEventSent;
+        bool iCPMSequenceInProgress;
+        bool oIsAACFramesFragmented;
+
+        int32 iPlayBackDirection;
+        int32 iStartForNextTSSearch;
+        int32 iPrevSampleTS;
+        bool iParseAudioDuringFF;
+        bool iParseAudioDuringREW;
+        bool iParseVideoOnly;
+        int32 iDataRate;
+
+        int32 minFileOffsetTrackID;
 };
 
 
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_cap_config.cpp b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_cap_config.cpp
index 0810f3c..3d2e4b7 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_cap_config.cpp
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_cap_config.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -203,12 +203,12 @@
             oscl_strset(memblock, 0, MP4ParserNodeConfig_Num_Net_Keys*MP4CONFIG_KEYSTRING_SIZE*sizeof(char));
             // Assign the key string buffer to each KVP
             int32 j;
-            for (j = 0; j < MP4ParserNodeConfig_Num_Net_Keys; ++j)
+            for (j = 0; j < (int32)MP4ParserNodeConfig_Num_Net_Keys; ++j)
             {
                 aParameters[j].key = memblock + (j * MP4CONFIG_KEYSTRING_SIZE);
             }
             // Copy the requested info
-            for (j = 0; j < MP4ParserNodeConfig_Num_Net_Keys; ++j)
+            for (j = 0; j < (int32)MP4ParserNodeConfig_Num_Net_Keys; ++j)
             {
                 oscl_strncat(aParameters[j].key, _STRLIT_CHAR("x-pvmf/net/"), 11);
                 oscl_strncat(aParameters[j].key, MP4ParserNodeConfig_Net_Keys[j].iString, oscl_strlen(MP4ParserNodeConfig_Net_Keys[j].iString));
@@ -267,8 +267,8 @@
             {
                 reqattr = PVMI_KVPATTR_CUR;
             }
-            int i;
-            for (i = 0; i < MP4ParserNodeConfig_Num_Net_Keys; i++)
+            int32 i;
+            for (i = 0; i < (int32)MP4ParserNodeConfig_Num_Net_Keys; i++)
             {
                 if (pv_mime_strcmp(compstr, (char*)(MP4ParserNodeConfig_Net_Keys[i].iString)) >= 0)
                 {
@@ -276,7 +276,7 @@
                 }
             }
 
-            if (i == MP4ParserNodeConfig_Num_Net_Keys)
+            if (i == (int32)MP4ParserNodeConfig_Num_Net_Keys)
             {
                 // no match found
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
@@ -465,7 +465,7 @@
 
 
     // Go through each parameter
-    for (int paramind = 0; paramind < num_elements; ++paramind)
+    for (int32 paramind = 0; paramind < num_elements; ++paramind)
     {
         // Count the number of components and parameters in the key
         int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
@@ -484,7 +484,6 @@
                 uint i;
                 for (i = 0; i < MP4ParserNodeConfig_Num_FileIO_Keys; i++)
                 {
-                    char *x = (char*)MP4ParserNodeConfig_FileIO_Keys[i].iString;
                     if (pv_mime_strcmp(compstr, (char*)(MP4ParserNodeConfig_FileIO_Keys[i].iString)) >= 0)
                     {
                         break;
@@ -527,19 +526,18 @@
                 if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
                 {
                     iBaseKey = NET;
-                    int i;
+                    int32 i;
                     //Extract the third component from the key string
                     pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
-                    for (i = 0; i < MP4ParserNodeConfig_Num_Net_Keys; i++)
+                    for (i = 0; i < (int32)MP4ParserNodeConfig_Num_Net_Keys; i++)
                     {
-                        char *x = (char*)MP4ParserNodeConfig_Net_Keys[i].iString;
                         if (pv_mime_strcmp(compstr, (char*)(MP4ParserNodeConfig_Net_Keys[i].iString)) >= 0)
                         {
                             break;
                         }
                     }
 
-                    if (MP4ParserNodeConfig_Num_Net_Keys == i)
+                    if ((int32)MP4ParserNodeConfig_Num_Net_Keys == i)
                     {
                         // invalid third component
                         aRet_kvp = &aParameters[paramind];
@@ -557,6 +555,32 @@
                         return;
                     }
                 }
+                else if (pv_mime_strcmp(compstr, _STRLIT_CHAR("parser/ff_noaudio")) >= 0)
+                {
+                    // Make sure its a bool value
+                    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[paramind].key);
+                    if (PVMI_KVPVALTYPE_BOOL != keyvaltype)
+                    {
+                        aRet_kvp = &aParameters[paramind];
+                        PVMF_MP4FFPARSERNODE_LOGINFO((0, "PVMFMP4FFParserNode::setParametersSync Setting "
+                                                      "ff_noaudio valtype error"));
+                        return;
+                    }
+                    iParseAudioDuringFF = aParameters[paramind].value.bool_value;
+                }
+                else if (pv_mime_strcmp(compstr, _STRLIT_CHAR("parser/rew_noaudio")) >= 0)
+                {
+                    // Make sure its a bool value
+                    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[paramind].key);
+                    if (PVMI_KVPVALTYPE_BOOL != keyvaltype)
+                    {
+                        aRet_kvp = &aParameters[paramind];
+                        PVMF_MP4FFPARSERNODE_LOGINFO((0, "PVMFMP4FFParserNode::setParametersSync Setting "
+                                                      "ff_noaudio valtype error"));
+                        return;
+                    }
+                    iParseAudioDuringREW = aParameters[paramind].value.bool_value;
+                }
                 else
                 {
                     // Unknown key string
@@ -634,8 +658,8 @@
         {
             iBaseKey = FILE_IO;
             pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
-            int i;
-            for (i = 0; i < MP4ParserNodeConfig_Num_FileIO_Keys; i++)
+            int32 i;
+            for (i = 0; i < (int32)MP4ParserNodeConfig_Num_FileIO_Keys; i++)
             {
                 if (pv_mime_strcmp(compstr, (char*)(MP4ParserNodeConfig_FileIO_Keys[i].iString)) >= 0)
                 {
@@ -643,7 +667,7 @@
                 }
             }
 
-            if (MP4ParserNodeConfig_Num_FileIO_Keys == i)
+            if ((int32)MP4ParserNodeConfig_Num_FileIO_Keys == i)
             {
                 return PVMFErrArgument;
             }
@@ -663,9 +687,9 @@
             if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
             {
                 iBaseKey = NET;
-                int i;
+                int32 i;
                 pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
-                for (i = 0; i < MP4ParserNodeConfig_Num_Net_Keys; i++)
+                for (i = 0; i < (int32)MP4ParserNodeConfig_Num_Net_Keys; i++)
                 {
                     if (pv_mime_strcmp(compstr, (char*)(MP4ParserNodeConfig_Net_Keys[i].iString)) >= 0)
                     {
@@ -673,7 +697,7 @@
                     }
                 }
 
-                if (MP4ParserNodeConfig_Num_Net_Keys == i)
+                if ((int32)MP4ParserNodeConfig_Num_Net_Keys == i)
                 {
                     return PVMFErrArgument;
                 }
@@ -1118,7 +1142,7 @@
             break;
 
             default:
-                OSCL_ASSERT(0);
+                return PVMFErrNotSupported;
         }
     }
 
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_metadata.cpp b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_metadata.cpp
index 95bf6c8..eb752bc 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_metadata.cpp
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_node_metadata.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@
 
 #include "oscl_exclusive_ptr.h"
 
-
 // Constant character strings for metadata keys
 static const char PVMP4METADATA_CLIP_TYPE_KEY[] = "clip-type";
 static const char PVMP4METADATA_ALBUM_KEY[] = "album";
@@ -109,6 +108,9 @@
 #define PVMF_MP4_MIME_FORMAT_VIDEO_UNKNOWN	"x-pvmf/video/unknown"
 #define PVMF_MP4_MIME_FORMAT_UNKNOWN		"x-pvmf/unknown-media/unknown"
 
+#define MILLISECOND_TIMESCALE (1000)
+#define PVMF_MP4_MAX_UINT32   (0xffffffffU)
+
 uint32 PVMFMP4FFParserNode::GetNumMetadataKeys(char* aQueryKeyString)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFMP4FFParserNode::GetNumMetadataKeys() called"));
@@ -175,10 +177,12 @@
     // Retrieve the track ID list
     OsclExclusiveArrayPtr<uint32> trackidlistexclusiveptr;
     uint32* trackidlist = NULL;
-    int32 leavecode = 0;
     uint32 numTracks = (uint32)(iNumTracks);
-    OSCL_TRY(leavecode, trackidlist = OSCL_ARRAY_NEW(uint32, numTracks););
-    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory;);
+    PVMFStatus status = CreateNewArray(&trackidlist, numTracks);
+    if (PVMFErrNoMemory == status)
+    {
+        return PVMFErrNoMemory;
+    }
     oscl_memset(trackidlist, 0, sizeof(uint32)*(numTracks));
     iMP4FileHandle->getTrackIDList(trackidlist, numTracks);
     trackidlistexclusiveptr.set(trackidlist);
@@ -423,8 +427,7 @@
             // Increment the counter for the number of values found so far
             ++numvalentries;
         }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP4METADATA_DURATION_KEY) == 0 &&
-                 iMP4FileHandle->getMovieDuration() > (uint64)0 && iMP4FileHandle->getMovieTimescale() > 0)
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMP4METADATA_DURATION_KEY) == 0)
         {
             // Movie Duration
             // Increment the counter for the number of values found so far
@@ -470,7 +473,11 @@
             }
             //get track id from index
             uint32 trackID = startindex + 1;
-            if (iMP4FileHandle->getTrackOTIType(trackID) == H263_VIDEO)
+
+            OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+            iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+            if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
             {
                 // Increment the counter for the number of values found so far
                 ++numvalentries;
@@ -502,7 +509,11 @@
             }
             //get track id from index
             uint32 trackID = startindex + 1;
-            if (iMP4FileHandle->getTrackOTIType(trackID) == H263_VIDEO)
+
+            OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+            iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+            if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
             {
                 // Increment the counter for the number of values found so far
                 ++numvalentries;
@@ -534,9 +545,13 @@
             }
             //get track id from index
             uint32 trackID = startindex + 1;
-            uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(trackID);
-            if ((trackOTIType == H263_VIDEO) || (trackOTIType == MPEG4_VIDEO) ||
-                    (trackOTIType == AVC_VIDEO))
+            OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+            iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+            if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0) ||
+                    (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0) ||
+                    (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0))
             {
                 // Increment the counter for the number of values found so far
                 ++numvalentries;
@@ -631,32 +646,42 @@
         }
         else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY) != NULL)
         {
-            // Track Number
+            uint32 numCDTrackNumber = 0;
 
-            // Determine the index requested. Default to all tracks
-            // Check if the file has at least one track
-            int32 numtracks = iMP4FileHandle->getNumTracks();
-            if (numtracks <= 0)
-            {
-                break;
-            }
-            uint32 startindex = 0;
-            uint32 endindex = (uint32)numtracks - 1;
-            // Check if the index parameter is present
-            const char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMP4METADATA_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
-            {
-                break;
-            }
+            if (iMP4FileHandle->getITunesThisTrackNo() > 0)
+                numCDTrackNumber++;
 
-            // Increment the counter for the number of values found so far
-            numvalentries += (endindex + 1 - startindex);
+
+            if (numCDTrackNumber > 0)
+            {
+                // Track Number
+
+                // Determine the index requested. Default to all tracks
+                // Check if the file has at least one track
+                int32 numtracks = iMP4FileHandle->getNumTracks();
+                if (numtracks <= 0)
+                {
+                    break;
+                }
+                uint32 startindex = 0;
+                uint32 endindex = (uint32)numtracks - 1;
+                // Check if the index parameter is present
+                const char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMP4METADATA_INDEX);
+                if (indexstr != NULL)
+                {
+                    // Retrieve the index values
+                    GetIndexParamValues(indexstr, startindex, endindex);
+                }
+                // Validate the indices
+                if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
+                {
+                    break;
+                }
+
+                // Increment the counter for the number of values found so far
+                numvalentries += (endindex + 1 - startindex);
+                numvalentries = numCDTrackNumber * numvalentries;
+            }
         }
         else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMP4METADATA_TRACKINFO_BITRATE_KEY) != NULL)
         {
@@ -727,49 +752,45 @@
             // Return a KVP for each index
             for (uint32 i = startindex; i <= endindex; ++i)
             {
-                switch (iMP4FileHandle->getTrackOTIType(trackidlist[i]))
+                OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+                iMP4FileHandle->getTrackMIMEType(trackidlist[i], trackMIMEType);
+
+                if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0)
                 {
-                    case MPEG4_VIDEO:
-                        if (tracktype == 1)
-                        {
-                            ++numvalentries;
-                        }
-                        break;
-
-                    case H263_VIDEO:
-                        if (tracktype == 1)
-                        {
-                            ++numvalentries;
-                        }
-                        break;
-
-                    case AVC_VIDEO:
-                        if (tracktype == 1)
-                        {
-                            ++numvalentries;
-                        }
-                        break;
-
-                    case MPEG4_AUDIO:
-                        if (tracktype == 2)
-                        {
-                            ++numvalentries;
-                        }
-                        break;
-
-                    case AMR_AUDIO_3GPP:
-                    case AMRWB_AUDIO_3GPP:
+                    if (tracktype == 1)
                     {
-                        if (tracktype == 2)
-                        {
-                            ++numvalentries;
-                        }
+                        ++numvalentries;
                     }
-                    break;
-
-                    case TIMED_TEXT:
-                    default:
-                        break;
+                }
+                else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
+                {
+                    if (tracktype == 1)
+                    {
+                        ++numvalentries;
+                    }
+                }
+                else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0)
+                {
+                    if (tracktype == 1)
+                    {
+                        ++numvalentries;
+                    }
+                }
+                else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0)
+                {
+                    if (tracktype == 2)
+                    {
+                        ++numvalentries;
+                    }
+                }
+                else if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0) ||
+                         (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0))
+                {
+                    if (tracktype == 2)
+                    {
+                        ++numvalentries;
+                    }
                 }
             }
         }
@@ -1136,7 +1157,7 @@
         return -1;
     }
 
-    int32 NumMetaDataKeysAvailable = 0, numkeys = 0;
+    int32 NumMetaDataKeysAvailable = 0;
 
     int32 iNumTracks = iMP4FileHandle->getNumTracks();
     uint32 iIdList[16];
@@ -1151,22 +1172,26 @@
     for (int32 i = iNumTracks - 1; i >= 0; i--)
     {
         uint32 trackID = iIdList[i];
-        uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(trackID);
-        if (trackOTIType == H263_VIDEO)
+
+        OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+        iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+        if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
         {
             //track id is a one based index
             NumMetaDataKeysAvailable += 2;
         }
-        if ((trackOTIType == H263_VIDEO) ||
-                (trackOTIType == MPEG4_VIDEO) ||
-                (trackOTIType == AVC_VIDEO))
+        if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0))
         {
             NumMetaDataKeysAvailable += 4;
         }
-        if ((trackOTIType == AMR_AUDIO) ||
-                (trackOTIType == MPEG4_AUDIO) ||
-                (trackOTIType == AMR_AUDIO_3GPP) ||
-                (trackOTIType == AMRWB_AUDIO_3GPP))
+        if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR, oscl_strlen(PVMF_MIME_AMR)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0))
         {
             NumMetaDataKeysAvailable += 3;
         }
@@ -1350,15 +1375,20 @@
         indexparam[17] = '\0';
 
         uint32 trackID = iIdList[i];
-        uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(trackID);
-        if (trackOTIType == H263_VIDEO)
+
+        OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+        iMP4FileHandle->getTrackMIMEType(trackID, (OSCL_String&)trackMIMEType);
+
+        if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000))) == 0)
         {
             PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_VIDEO_PROFILE_KEY, indexparam);
             PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_VIDEO_LEVEL_KEY, indexparam);
         }
-        if ((trackOTIType  == H263_VIDEO) ||
-                (trackOTIType  == MPEG4_VIDEO) ||
-                (trackOTIType  == AVC_VIDEO))
+
+        if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0))
         {
             uint64 trackduration  = iMP4FileHandle->getTrackMediaDuration(trackID);
             uint32 samplecount = iMP4FileHandle->getSampleCountInTrack(trackID);
@@ -1367,9 +1397,22 @@
             mcc.update_clock(trackduration);
             uint32 TrackDurationInSec = mcc.get_converted_ts(1);
             uint32 frame_rate = 0;
-            if (TrackDurationInSec > 0)
+            uint32 OverflowThreshold = PVMF_MP4_MAX_UINT32 / MILLISECOND_TIMESCALE;
+            // If overflow could not happen, we calculate it in millisecond
+            if (TrackDurationInSec < OverflowThreshold && samplecount < OverflowThreshold)
             {
-                frame_rate = samplecount / TrackDurationInSec;
+                uint32 TrackDurationInMilliSec = mcc.get_converted_ts(MILLISECOND_TIMESCALE);
+                if (TrackDurationInMilliSec > 0)
+                {
+                    frame_rate = samplecount * MILLISECOND_TIMESCALE / TrackDurationInMilliSec;
+                }
+            }
+            else // if overflow could happen when calculate in millisecond, we calculate it in second
+            {
+                if (TrackDurationInSec > 0)
+                {
+                    frame_rate = samplecount / TrackDurationInSec;
+                }
             }
             if (frame_rate > 0)
             {
@@ -1382,10 +1425,11 @@
             }
             PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, indexparam);
         }
-        if ((trackOTIType == AMR_AUDIO) ||
-                (trackOTIType == MPEG4_AUDIO) ||
-                (trackOTIType == AMR_AUDIO_3GPP) ||
-                (trackOTIType == AMRWB_AUDIO_3GPP))
+
+        if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR, oscl_strlen(PVMF_MIME_AMR)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0) ||
+                (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0))
         {
             PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_AUDIO_FORMAT_KEY, indexparam);
             PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_AUDIO_NUMCHANNELS_KEY, indexparam);
@@ -1500,14 +1544,7 @@
             mcc.update_clock(duration);
             durationms = mcc.get_converted_ts(1000);
         }
-        int32 leavecode = 0;
-        PVMFDurationInfoMessage* eventmsg = NULL;
-        OSCL_TRY(leavecode, eventmsg = OSCL_NEW(PVMFDurationInfoMessage, (durationms)));
-        PVMFNodeInterface::ReportInfoEvent(PVMFInfoDurationAvailable, NULL, OSCL_STATIC_CAST(PVInterface*, eventmsg));
-        if (eventmsg)
-        {
-            eventmsg->removeRef();
-        }
+        CreateDurationInfoMsg(durationms);
     }
 
     if (iMP4FileHandle->getITunesBeatsPerMinute() > 0)
@@ -1584,10 +1621,12 @@
 
         PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_SELECTED_KEY, indexparam);
 
-        PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY, indexparam);
+        if (iMP4FileHandle->getITunesThisTrackNo() > 0)
+        {
+            PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY, indexparam);
+        }
 
         PushToAvailableMetadataKeysList(PVMP4METADATA_TRACKINFO_NUM_KEY_SAMPLES_KEY, indexparam);
-
     }
 
     //set clip duration on download progress interface
@@ -1654,7 +1693,6 @@
     // Copy the requested keys
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
     uint32 lcv = 0;
     for (lcv = 0; lcv < iCPMMetadataKeys.size(); lcv++)
     {
@@ -1665,11 +1703,11 @@
             if (num_entries > starting_index)
             {
                 /* Past the starting index so copy the key */
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushValueToList(iCPMMetadataKeys, keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -1683,11 +1721,11 @@
                 if (num_entries > starting_index)
                 {
                     /* Past the starting index so copy the key */
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushValueToList(iCPMMetadataKeys, keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -1707,11 +1745,11 @@
             if (num_entries > starting_index)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushValueToList(iAvailableMetadataKeys, keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -1725,11 +1763,11 @@
                 if (num_entries > starting_index)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushValueToList(iAvailableMetadataKeys, keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -1781,10 +1819,12 @@
         // Retrieve the track ID list
         OsclExclusiveArrayPtr<uint32> trackidlistexclusiveptr;
         uint32* trackidlist = NULL;
-        int32 leavecode = 0;
         uint32 numTracks = (uint32)(iMP4FileHandle->getNumTracks());
-        OSCL_TRY(leavecode, trackidlist = OSCL_ARRAY_NEW(uint32, numTracks););
-        OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory;);
+        PVMFStatus status = CreateNewArray(&trackidlist, numTracks);
+        if (PVMFErrNoMemory == status)
+        {
+            return PVMFErrNoMemory;
+        }
         oscl_memset(trackidlist, 0, sizeof(uint32)*(numTracks));
         iMP4FileHandle->getTrackIDList(trackidlist, numTracks);
         trackidlistexclusiveptr.set(trackidlist);
@@ -1812,7 +1852,7 @@
 
                 if (countAuthor > 0)
                 {
-                    for (idx = 0; idx < countAuthor ; idx++)
+                    for (idx = 0; idx < (int32)countAuthor ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -1829,7 +1869,6 @@
 
 
                             char lang_param[43];
-
                             if (iLangCode != 0)
                             {
                                 int8 LangCode[4];
@@ -1852,7 +1891,6 @@
                                 char_enc_param[21] = '\0';
                                 oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
                             }
-
                             PVMFStatus retval =
                                 PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
                                         PVMP4METADATA_AUTHOR_KEY,
@@ -2266,8 +2304,7 @@
 
                         uint32* trackList = NULL;
                         uint32 numTracks = iNodeTrackPortList.size();
-                        OSCL_TRY(leavecode, trackList = OSCL_ARRAY_NEW(uint32, numTracks););
-
+                        CreateNewArray(&trackList, numTracks);
                         if (trackList)
                         {
                             for (uint32 i = 0; i < iNodeTrackPortList.size(); i++)
@@ -2328,8 +2365,6 @@
                 }
 
             }
-
-
             else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMP4METADATA_CLIP_TYPE_KEY) == 0)
             {
                 // clip-type
@@ -2377,7 +2412,7 @@
 
                 if (countAlbum > 0)
                 {
-                    for (idx = 0; idx < countAlbum ; idx++)
+                    for (idx = 0; idx < (int32)countAlbum ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -2386,75 +2421,71 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getAlbum(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getAlbum(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getAlbum Failed"));
-                                return PVMFFailure;
-                            }
 
-
-                            char lang_param[43];
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_ALBUM_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
+                                }
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
+                                {
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
                                 }
 
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_ALBUM_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
 
@@ -2473,7 +2504,7 @@
 
                 if (countComment > 0)
                 {
-                    for (idx = 0; idx < countComment ; idx++)
+                    for (idx = 0; idx < (int32)countComment ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -2482,75 +2513,69 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getComment(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getComment(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getComment Failed"));
-                                return PVMFFailure;
-                            }
 
-
-                            char lang_param[43];
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_COMMENT_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_COMMENT_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
 
@@ -2616,19 +2641,14 @@
                     }
                     if (KeyVal.key != NULL)
                     {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
-                        if (leavecode != 0)
+                        PVMFStatus status = PushKVPToMetadataValueList(valuelistptr, KeyVal);
+                        if (status != PVMFSuccess)
                         {
-                            OSCL_ARRAY_DELETE(KeyVal.key);
-                            KeyVal.key = NULL;
+                            return status;
                         }
-                        else
-                        {
-                            /* Increment the value list entry counter */
-                            ++numentriesadded;
-                            IsMetadataValAddedBefore = true;
-                        }
+                        // Increment the counter for number of value entries added to the list
+                        ++numentriesadded;
+                        IsMetadataValAddedBefore = true;
 
                         /* Check if the max number of value entries were added */
                         if (max_entries > 0 && numentriesadded >= max_entries)
@@ -2650,7 +2670,7 @@
 
                 if (countTitle > 0)
                 {
-                    for (idx = 0; idx < countTitle ; idx++)
+                    for (idx = 0; idx < (int32)countTitle ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -2659,75 +2679,71 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getTitle(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getTitle(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getTitle Failed"));
-                                return PVMFFailure;
-                            }
 
 
-                            char lang_param[43];
 
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_TITLE_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_TITLE_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
 
@@ -2746,7 +2762,7 @@
 
                 if (countDescription > 0)
                 {
-                    for (idx = 0; idx < countDescription ; idx++)
+                    for (idx = 0; idx < (int32)countDescription ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -2755,75 +2771,70 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getDescription(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getDescription(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getDescription Failed"));
-                                return PVMFFailure;
-                            }
 
 
-                            char lang_param[43];
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_DESCRIPTION_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_DESCRIPTION_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
 
@@ -2841,7 +2852,7 @@
 
                 if (countRating > 0)
                 {
-                    for (idx = 0; idx < countRating ; idx++)
+                    for (idx = 0; idx < (int32)countRating ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -2850,79 +2861,73 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getRating(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getRating(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getRating Failed"));
-                                return PVMFFailure;
-                            }
 
-
-                            char lang_param[43];
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_RATING_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_RATING_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
 
-                        }
+                        } //End of Outer If
                     }
 
                 }
@@ -2936,7 +2941,7 @@
 
                 if (countCopyright > 0)
                 {
-                    for (idx = 0; idx < countCopyright ; idx++)
+                    for (idx = 0; idx < (int32)countCopyright ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -2945,80 +2950,72 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getCopyright(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getCopyright(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getCopyright Failed"));
-                                return PVMFFailure;
-                            }
-
-
-                            char lang_param[43];
-
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_COPYRIGHT_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_COPYRIGHT_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
-
                         }
+
                     }
 
                 }
@@ -3032,7 +3029,7 @@
 
                 if (countArtist > 0)
                 {
-                    for (idx = 0; idx < countArtist ; idx++)
+                    for (idx = 0; idx < (int32)countArtist ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -3041,75 +3038,69 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getArtist(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getArtist(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getArtist Failed"));
-                                return PVMFFailure;
-                            }
 
-
-                            char lang_param[43];
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_ARTIST_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                PVMFStatus retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_ARTIST_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
 
@@ -3192,13 +3183,13 @@
             else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMP4METADATA_GENRE_KEY) == 0)
             {
                 // Genre
-
+                PVMFStatus retval = PVMFFailure;
                 uint32 countGenre = 0;
                 countGenre = iMP4FileHandle->getNumGenre();
 
                 if (countGenre > 0)
                 {
-                    for (idx = 0; idx < countGenre ; idx++)
+                    for (idx = 0; idx < (int32)countGenre ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -3207,75 +3198,68 @@
                         if (numvalentries > starting_index)
                         {
 
-                            if (!iMP4FileHandle->getGenre(idx, valuestring, iLangCode, charType))
+                            if (iMP4FileHandle->getGenre(idx, valuestring, iLangCode, charType) != PVMFErrArgument)
                             {
-                                PVMF_MP4FFPARSERNODE_LOGERROR((0, "PVMFMP4FFParserNode::DoGetMetadataValues - getGenre Failed"));
-                                return PVMFFailure;
-                            }
-
-
-                            char lang_param[43];
-
-                            if (iLangCode != 0)
-                            {
-                                int8 LangCode[4];
-                                getLanguageCode(iLangCode, LangCode);
-                                LangCode[3] = '\0';
-                                oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
-                                lang_param[20] = '\0';
-                            }
-                            else
-                            {
-                                lang_param[0] = '\0';
-                            }
-                            KeyVal.key = NULL;
-                            KeyVal.value.pWChar_value = NULL;
-                            KeyVal.value.pChar_value = NULL;
-                            if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
-                            {
-                                char char_enc_param[22];
-                                oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
-                                char_enc_param[21] = '\0';
-                                oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
-                            }
-
-
-                            PVMFStatus retval =
-                                PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
-                                        PVMP4METADATA_GENRE_KEY,
-                                        valuestring,
-                                        lang_param);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                            // Add the KVP to the list if the key string was created
-                            if (KeyVal.key != NULL)
-                            {
-                                leavecode = AddToValueList(*valuelistptr, KeyVal);
-                                if (leavecode != 0)
+                                char lang_param[43];
+                                if (iLangCode != 0)
                                 {
-                                    if (KeyVal.value.pWChar_value != NULL)
-                                    {
-                                        OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
-                                        KeyVal.value.pWChar_value = NULL;
-                                    }
-
-                                    OSCL_ARRAY_DELETE(KeyVal.key);
-                                    KeyVal.key = NULL;
+                                    int8 LangCode[4];
+                                    getLanguageCode(iLangCode, LangCode);
+                                    LangCode[3] = '\0';
+                                    oscl_snprintf(lang_param, 20, ";%s%s", PVMP4METADATA_LANG_CODE, LangCode);
+                                    lang_param[20] = '\0';
                                 }
                                 else
                                 {
-                                    // Increment the value list entry counter
-                                    ++numentriesadded;
-                                    IsMetadataValAddedBefore = true;
+                                    lang_param[0] = '\0';
                                 }
-
-                                // Check if the max number of value entries were added
-                                if (max_entries > 0 && numentriesadded >= max_entries)
+                                KeyVal.key = NULL;
+                                KeyVal.value.pWChar_value = NULL;
+                                KeyVal.value.pChar_value = NULL;
+                                if (charType != ORIGINAL_CHAR_TYPE_UNKNOWN)
                                 {
-                                    iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                                    return PVMFSuccess;
+                                    char char_enc_param[22];
+                                    oscl_snprintf(char_enc_param, 22, ";%s%s", PVMP4METADATA_ORIG_CHAR_ENC, orig_char_enc[charType-1]);
+                                    char_enc_param[21] = '\0';
+                                    oscl_strncat(lang_param, char_enc_param, oscl_strlen(char_enc_param));
+                                }
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                                            PVMP4METADATA_GENRE_KEY,
+                                            valuestring,
+                                            lang_param);
+                                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                                {
+                                    break;
+                                }
+                                // Add the KVP to the list if the key string was created
+                                if (KeyVal.key != NULL)
+                                {
+                                    leavecode = AddToValueList(*valuelistptr, KeyVal);
+                                    if (leavecode != 0)
+                                    {
+                                        if (KeyVal.value.pWChar_value != NULL)
+                                        {
+                                            OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                            KeyVal.value.pWChar_value = NULL;
+                                        }
+
+                                        OSCL_ARRAY_DELETE(KeyVal.key);
+                                        KeyVal.key = NULL;
+                                    }
+                                    else
+                                    {
+                                        // Increment the value list entry counter
+                                        ++numentriesadded;
+                                        IsMetadataValAddedBefore = true;
+                                    }
+
+                                    // Check if the max number of value entries were added
+                                    if (max_entries > 0 && numentriesadded >= max_entries)
+                                    {
+                                        iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                        return PVMFSuccess;
+                                    }
                                 }
                             }
                             uint32 value = iMP4FileHandle->getITunesGnreID();
@@ -3284,7 +3268,6 @@
                                 KeyVal.key = NULL;
                                 KeyVal.value.pWChar_value = NULL;
                                 KeyVal.value.pChar_value = NULL;
-
                                 retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal, PVMP4METADATA_GENRE_KEY, value);
 
                                 if (retval != PVMFSuccess && retval != PVMFErrArgument)
@@ -3543,7 +3526,12 @@
                 //get track id from index
                 uint32 trackID = startindex + 1;
                 uint32 iProfile = 0;
-                if (iMP4FileHandle->getTrackOTIType(trackID) == H263_VIDEO)
+
+                OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+                iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+                if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
                 {
                     H263DecoderSpecificInfo *ptr = (H263DecoderSpecificInfo *)iMP4FileHandle->getTrackDecoderSpecificInfoAtSDI(trackID, 0);
                     iProfile = ptr->getCodecProfile();
@@ -3594,7 +3582,12 @@
                 //get track id from index
                 uint32 trackID = startindex + 1;
                 uint32 iLevel = 0;
-                if (iMP4FileHandle->getTrackOTIType(trackID) == H263_VIDEO)
+
+                OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+                iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+                if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
                 {
                     H263DecoderSpecificInfo *ptr = (H263DecoderSpecificInfo *)iMP4FileHandle->getTrackDecoderSpecificInfoAtSDI(trackID, 0);
                     iLevel = ptr->getCodecLevel();
@@ -3649,9 +3642,13 @@
                 iMP4FileHandle->getTrackIDList(iIdList, numtracks);
                 uint32 trackID = iIdList[startindex];
 
-                uint8 trackOTIType = iMP4FileHandle->getTrackOTIType(trackID);
-                if ((trackOTIType == H263_VIDEO) || (trackOTIType == MPEG4_VIDEO) ||
-                        (trackOTIType == AVC_VIDEO))
+                OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+                iMP4FileHandle->getTrackMIMEType(trackID, trackMIMEType);
+
+                if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0) ||
+                        (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0) ||
+                        (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0))
                 {
                     uint64 trackduration  = iMP4FileHandle->getTrackMediaDuration(trackID);
                     uint32 samplecount = iMP4FileHandle->getSampleCountInTrack(trackID);
@@ -3659,12 +3656,33 @@
                     MediaClockConverter mcc(iMP4FileHandle->getTrackMediaTimescale(trackID));
                     mcc.update_clock(trackduration);
                     uint32 TrackDurationInSec = mcc.get_converted_ts(1);
+                    uint32 frame_rate = 0;
 
-                    if (!TrackDurationInSec)
+                    uint32 OverflowThreshold = PVMF_MP4_MAX_UINT32 / MILLISECOND_TIMESCALE;
+                    // If overflow could not happen, we calculate it in millisecond
+                    if (TrackDurationInSec < OverflowThreshold && samplecount < OverflowThreshold)
                     {
-                        continue;
+                        uint32 TrackDurationInMilliSec = mcc.get_converted_ts(MILLISECOND_TIMESCALE);
+                        if (TrackDurationInMilliSec > 0)
+                        {
+                            frame_rate = samplecount * MILLISECOND_TIMESCALE / TrackDurationInMilliSec;
+                        }
+                        else
+                        {
+                            continue;
+                        }
                     }
-                    uint32 frame_rate = samplecount / TrackDurationInSec;
+                    else // if overflow could happen when calculate in millisecond, we calculate it in second
+                    {
+                        if (TrackDurationInSec > 0)
+                        {
+                            frame_rate = samplecount / TrackDurationInSec;
+                        }
+                        else
+                        {
+                            continue;
+                        }
+                    }
 
                     // Increment the counter for the number of values found so far
                     ++numvalentries;
@@ -3717,7 +3735,7 @@
 
                 if (countYear > 0)
                 {
-                    for (idx = 0; idx < countYear ; idx++)
+                    for (idx = 0; idx < (int32)countYear ; idx++)
                     {
                         // Increment the counter for the number of values found so far
                         ++numvalentries;
@@ -3825,117 +3843,119 @@
                     indexparam[15] = '\0';
 
                     PVMFStatus retval = PVMFErrArgument;
-                    switch (iMP4FileHandle->getTrackOTIType(trackidlist[i]))
+
+                    OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+                    iMP4FileHandle->getTrackMIMEType(trackidlist[i], (OSCL_String&)trackMIMEType);
+
+                    if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0)
                     {
-                        case MPEG4_VIDEO:
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
-                            {
-                                retval =
-                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
-                                            PVMP4METADATA_TRACKINFO_TYPE_KEY,
-                                            _STRLIT_CHAR(PVMF_MIME_M4V),
-                                            indexparam);
-                            }
-                            break;
-
-                        case H263_VIDEO:
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
-                            {
-                                retval =
-                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
-                                            PVMP4METADATA_TRACKINFO_TYPE_KEY,
-                                            _STRLIT_CHAR(PVMF_MIME_H2631998),
-                                            indexparam);
-                            }
-                            break;
-
-                        case AVC_VIDEO:
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
-                            {
-                                retval =
-                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), indexparam);
-                            }
-                            break;
-
-                        case MPEG4_AUDIO:
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
-                            {
-                                retval =
-                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), indexparam);
-                            }
-                            break;
-
-                        case AMR_AUDIO_3GPP:
-                        case AMRWB_AUDIO_3GPP:
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
                         {
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
-                            {
-                                retval =
-                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_AMR_IETF), indexparam);
-                            }
+                            retval =
+                                PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                        PVMP4METADATA_TRACKINFO_TYPE_KEY,
+                                        _STRLIT_CHAR(PVMF_MIME_M4V),
+                                        indexparam);
                         }
-                        break;
-
-                        case TIMED_TEXT:
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
+                    }
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
+                        {
+                            retval =
+                                PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                        PVMP4METADATA_TRACKINFO_TYPE_KEY,
+                                        _STRLIT_CHAR(PVMF_MIME_H2631998),
+                                        indexparam);
+                        }
+                    }
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0)
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
+                        {
+                            retval =
+                                PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), indexparam);
+                        }
+                    }
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0)
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
+                        {
+                            retval =
+                                PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), indexparam);
+                        }
+                    }
+                    else if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0) ||
+                             (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0))
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
+                        {
+                            retval =
+                                PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_AMR_IETF), indexparam);
+                        }
+                    }
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_3GPP_TIMEDTEXT, oscl_strlen(PVMF_MIME_3GPP_TIMEDTEXT)) == 0)
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
+                        {
+                            retval =
+                                PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_3GPP_TIMEDTEXT), indexparam);
+                        }
+                    }
+                    else
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        if (numvalentries > starting_index)
+                        {
+                            if (iMP4FileHandle->getTrackMediaType(trackidlist[i]) == MEDIA_TYPE_VISUAL)
                             {
                                 retval =
-                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TYPE_KEY, _STRLIT_CHAR(PVMF_MIME_3GPP_TIMEDTEXT), indexparam);
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                            PVMP4METADATA_TRACKINFO_TYPE_KEY,
+                                            _STRLIT_CHAR(PVMF_MP4_MIME_FORMAT_VIDEO_UNKNOWN),
+                                            indexparam);
                             }
-                            break;
-
-                        default:
-                            // Increment the counter for the number of values found so far
-                            ++numvalentries;
-                            // Add the value entry if past the starting index
-                            if (numvalentries > starting_index)
+                            else if (iMP4FileHandle->getTrackMediaType(trackidlist[i]) == MEDIA_TYPE_AUDIO)
                             {
-                                if (iMP4FileHandle->getTrackMediaType(trackidlist[i]) == MEDIA_TYPE_VISUAL)
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
-                                                PVMP4METADATA_TRACKINFO_TYPE_KEY,
-                                                _STRLIT_CHAR(PVMF_MP4_MIME_FORMAT_VIDEO_UNKNOWN),
-                                                indexparam);
-                                }
-                                else if (iMP4FileHandle->getTrackMediaType(trackidlist[i]) == MEDIA_TYPE_AUDIO)
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
-                                                PVMP4METADATA_TRACKINFO_TYPE_KEY,
-                                                _STRLIT_CHAR(PVMF_MP4_MIME_FORMAT_AUDIO_UNKNOWN),
-                                                indexparam);
-                                }
-                                else
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
-                                                PVMP4METADATA_TRACKINFO_TYPE_KEY,
-                                                _STRLIT_CHAR(PVMF_MP4_MIME_FORMAT_UNKNOWN),
-                                                indexparam);
-
-                                }
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                            PVMP4METADATA_TRACKINFO_TYPE_KEY,
+                                            _STRLIT_CHAR(PVMF_MP4_MIME_FORMAT_AUDIO_UNKNOWN),
+                                            indexparam);
+                            }
+                            else
+                            {
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                            PVMP4METADATA_TRACKINFO_TYPE_KEY,
+                                            _STRLIT_CHAR(PVMF_MP4_MIME_FORMAT_UNKNOWN),
+                                            indexparam);
 
                             }
-                            break;
+
+                        }
+
                     }
 
                     if (retval != PVMFSuccess && retval != PVMFErrArgument)
@@ -4086,7 +4106,15 @@
                     if (numvalentries > starting_index)
                     {
                         char indextimescaleparam[36];
-                        oscl_snprintf(indextimescaleparam, 36, ";%s%d;%s%d", PVMP4METADATA_INDEX, i, PVMP4METADATA_TIMESCALE, iMP4FileHandle->getTrackMediaTimescale(trackidlist[i]));
+                        uint32 timeScale = 0;
+
+                        if (iParsingMode && iMP4FileHandle->IsMovieFragmentsPresent())
+                            timeScale = iMP4FileHandle->getMovieTimescale();
+                        else
+                            timeScale = iMP4FileHandle->getTrackMediaTimescale(trackidlist[i]);
+
+                        oscl_snprintf(indextimescaleparam, 36, ";%s%d;%s%d", PVMP4METADATA_INDEX, i, PVMP4METADATA_TIMESCALE, timeScale);
+
                         indextimescaleparam[35] = '\0';
 
                         uint64 trackduration64 = iMP4FileHandle->getTrackMediaDuration(trackidlist[i]);
@@ -4200,10 +4228,10 @@
                     }
                 }
             }
-            else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY) != NULL)
+            else if ((oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY) != NULL) &&
+                     iMP4FileHandle->getITunesThisTrackNo() > 0)
             {
-                // Track Number
-
+                // iTunes Current Track Number
                 // Determine the index requested. Default to all tracks
                 // Check if the file has at least one track
                 int32 numtracks = iMP4FileHandle->getNumTracks();
@@ -4231,7 +4259,6 @@
                 {
                     PvmiKvp trackkvp;
                     trackkvp.key = NULL;
-
                     // Increment the counter for the number of values found so far
                     ++numvalentries;
                     // Add the value entry if past the starting index
@@ -4242,42 +4269,45 @@
                         oscl_snprintf(indexparam, 16, ";%s%d", PVMP4METADATA_INDEX, i);
                         indexparam[15] = '\0';
 
-                        uint32 track_number = 0;
+                        uint32 track_number = iMP4FileHandle->getITunesThisTrackNo(); // Always returns unsigned value
 
+                        char cdTrackNumber[6];
+                        uint16 totalTrackNumber = iMP4FileHandle->getITunesTotalTracks();
+                        oscl_snprintf(cdTrackNumber, 6, "%d/%d", track_number, totalTrackNumber);
+                        cdTrackNumber[5] = '\0';
 
-                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp, PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY, track_number, indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = AddToValueList(*valuelistptr, trackkvp);
-                        if (leavecode != 0)
+                        retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_TRACK_NUMBER_KEY, cdTrackNumber, indexparam);
+                        if ((retval != PVMFSuccess) && (retval != PVMFErrArgument))
                         {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                            IsMetadataValAddedBefore = true;
+                            break;
                         }
 
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        if (trackkvp.key != NULL)
                         {
-                            iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
+                            leavecode = AddToValueList(*valuelistptr, trackkvp);
+                            if (leavecode != 0)
+                            {
+                                OSCL_ARRAY_DELETE(trackkvp.key);
+                                trackkvp.key = NULL;
+                            }
+                            else
+                            {
+                                // Increment the value list entry counter
+                                ++numentriesadded;
+                                IsMetadataValAddedBefore = true;
+                            }
+
+                            // Check if the max number of value entries were added
+                            if (max_entries > 0 && numentriesadded >= max_entries)
+                            {
+
+                                iMP4ParserNodeMetadataValueCount = (*valuelistptr).size();
+                                return PVMFSuccess;
+                            }
                         }
                     }
                 }
             }
-
             else if ((oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMP4METADATA_TRACKINFO_AUDIO_FORMAT_KEY) != NULL) ||
                      (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY) != NULL))
             {
@@ -4327,75 +4357,70 @@
                     indexparam[15] = '\0';
 
                     PVMFStatus retval = PVMFErrArgument;
-                    switch (iMP4FileHandle->getTrackOTIType(trackidlist[i]))
+                    OSCL_HeapString<OsclMemAllocator> trackMIMEType;
+
+                    iMP4FileHandle->getTrackMIMEType(trackidlist[i], trackMIMEType);
+
+                    if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_M4V, oscl_strlen(PVMF_MIME_M4V)) == 0)
                     {
-                        case MPEG4_VIDEO:
-                            if (tracktype == 1)
-                            {
-                                ++numvalentries;
-                                if (numvalentries > starting_index)
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_M4V), indexparam);
-                                }
-                            }
-                            break;
-
-                        case H263_VIDEO:
-                            if (tracktype == 1)
-                            {
-                                ++numvalentries;
-                                if (numvalentries > starting_index)
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_H2631998), indexparam);
-                                }
-                            }
-                            break;
-
-                        case AVC_VIDEO:
-                            if (tracktype == 1)
-                            {
-                                ++numvalentries;
-                                if (numvalentries > starting_index)
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), indexparam);
-                                }
-                            }
-                            break;
-
-                        case MPEG4_AUDIO:
-                            if (tracktype == 2)
-                            {
-                                ++numvalentries;
-                                if (numvalentries > starting_index)
-                                {
-                                    retval =
-                                        PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_AUDIO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), indexparam);
-                                }
-                            }
-                            break;
-
-                        case AMR_AUDIO_3GPP:
-                        case AMRWB_AUDIO_3GPP:
+                        if (tracktype == 1)
                         {
-                            if (tracktype == 2)
+                            ++numvalentries;
+                            if (numvalentries > starting_index)
                             {
-                                ++numvalentries;
-                                if (numvalentries > starting_index)
-                                {
-                                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_AUDIO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_AMR_IETF), indexparam);
-                                }
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_M4V), indexparam);
                             }
                         }
-                        break;
-
-                        case TIMED_TEXT:
-                        default:
-                            break;
                     }
-
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H2632000, oscl_strlen(PVMF_MIME_H2632000)) == 0)
+                    {
+                        if (tracktype == 1)
+                        {
+                            ++numvalentries;
+                            if (numvalentries > starting_index)
+                            {
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_H2631998), indexparam);
+                            }
+                        }
+                    }
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_H264_VIDEO_MP4, oscl_strlen(PVMF_MIME_H264_VIDEO_MP4)) == 0)
+                    {
+                        if (tracktype == 1)
+                        {
+                            ++numvalentries;
+                            if (numvalentries > starting_index)
+                            {
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_VIDEO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), indexparam);
+                            }
+                        }
+                    }
+                    else if (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_MPEG4_AUDIO, oscl_strlen(PVMF_MIME_MPEG4_AUDIO)) == 0)
+                    {
+                        if (tracktype == 2)
+                        {
+                            ++numvalentries;
+                            if (numvalentries > starting_index)
+                            {
+                                retval =
+                                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_AUDIO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), indexparam);
+                            }
+                        }
+                    }
+                    else if ((oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMR_IETF, oscl_strlen(PVMF_MIME_AMR_IETF)) == 0) ||
+                             (oscl_strncmp(trackMIMEType.get_str(), PVMF_MIME_AMRWB_IETF, oscl_strlen(PVMF_MIME_AMRWB_IETF)) == 0))
+                    {
+                        if (tracktype == 2)
+                        {
+                            ++numvalentries;
+                            if (numvalentries > starting_index)
+                            {
+                                retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp, PVMP4METADATA_TRACKINFO_AUDIO_FORMAT_KEY, _STRLIT_CHAR(PVMF_MIME_AMR_IETF), indexparam);
+                            }
+                        }
+                    }
                     if (retval != PVMFSuccess && retval != PVMFErrArgument)
                     {
                         break;
@@ -5189,14 +5214,47 @@
     LangCode[2] = 0x60 + ((langcode) & 0x1F);
 }
 
+void PVMFMP4FFParserNode::CreateDurationInfoMsg(uint32 adurationms)
+{
+    int32 leavecode = 0;
+    PVMFDurationInfoMessage* eventmsg = NULL;
+    OSCL_TRY(leavecode, eventmsg = OSCL_NEW(PVMFDurationInfoMessage, (adurationms)));
+    PVMFNodeInterface::ReportInfoEvent(PVMFInfoDurationAvailable, NULL, OSCL_STATIC_CAST(PVInterface*, eventmsg));
+    if (eventmsg)
+    {
+        eventmsg->removeRef();
+    }
+}
 
+PVMFStatus PVMFMP4FFParserNode::PushKVPToMetadataValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>* aVecPtr, PvmiKvp& aKvpVal)
+{
+    if (aVecPtr == NULL)
+    {
+        return PVMFErrArgument;
+    }
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aVecPtr->push_back(aKvpVal););
+    if (leavecode != 0)
+    {
+        OSCL_ARRAY_DELETE(aKvpVal.key);
+        aKvpVal.key = NULL;
+        return PVMFErrNoMemory;
+    }
+    return PVMFSuccess;
+}
 
+PVMFStatus PVMFMP4FFParserNode::CreateNewArray(uint32** aTrackidList, uint32 aNumTracks)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, *aTrackidList = OSCL_ARRAY_NEW(uint32, aNumTracks););
+    OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory;);
+    return PVMFSuccess;
+}
 
-
-
-
-
-
-
-
-
+PVMFStatus PVMFMP4FFParserNode::PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetaDataKeys, PVMFMetadataList *&aKeyListPtr, uint32 aLcv)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aKeyListPtr->push_back(aRefMetaDataKeys[aLcv]));
+    OSCL_FIRST_CATCH_ANY(leavecode, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFMP4FFParserNode::PushValueToList() Memory allocation failure when copying metadata key"));return PVMFErrNoMemory);
+    return PVMFSuccess;
+}
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.cpp b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.cpp
index 8bc99f2..cdef850 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.cpp
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -69,25 +69,26 @@
 
 bool PVMFMP4FFParserOutPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    switch (aFmt)
+    if (aFmt == PVMF_MIME_M4V ||
+            aFmt == PVMF_MIME_H2631998 ||
+            aFmt == PVMF_MIME_H2632000 ||
+            aFmt == PVMF_MIME_H264_VIDEO_MP4 ||
+            aFmt == PVMF_MIME_MPEG4_AUDIO ||
+            aFmt == PVMF_MIME_AMR_IETF ||
+            aFmt == PVMF_MIME_3GPP_TIMEDTEXT)
     {
-        case PVMF_M4V:
-        case PVMF_H263:
-        case PVMF_H264_MP4:
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_AMR_IETF:
-        case PVMF_3GPP_TIMEDTEXT:
-            return true;
-
-        default:
-            return false;
+        return true;
+    }
+    else
+    {
+        return false;
     }
 }
 
 
 void PVMFMP4FFParserOutPort::FormatUpdated()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP4FFParserOutPort::FormatUpdated %d", iFormat));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFMP4FFParserOutPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
 }
 
 PVMFStatus PVMFMP4FFParserOutPort::Connect(PVMFPortInterface* aPort)
@@ -106,10 +107,9 @@
         return PVMFFailure;
     }
 
-    PvmiCapabilityAndConfig *config;
-
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                          (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
     if (config != NULL)
     {
diff --git a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.h b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.h
index b645c5e..0fd7abc 100644
--- a/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.h
+++ b/nodes/pvmp4ffparsernode/src/pvmf_mp4ffparser_outport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,10 @@
 #include "oscl_timer.h"
 #endif
 
+#ifndef PVMF_RESIZABLE_SIMPLE_MEDIAMSG_H_INCLUDED
+#include "pvmf_resizable_simple_mediamsg.h"
+#endif
+
 #include "pvmf_mp4ffparser_node.h"
 
 #define PVMF_MP4FFPARSERNODE_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
@@ -68,6 +72,7 @@
 #define PVMF_MP4FFPARSERNODE_LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
 #define PVMF_MP4FFPARSERNODE_LOGINFO(m) PVMF_MP4FFPARSERNODE_LOGINFOMED(m)
 #define PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_INFO,m);
+#define PVMF_MP4FFPARSERNODE_LOGDATATRAFFIC_AVC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iAVCDataPathLogger,PVLOGMSG_INFO,m);
 #define PVMF_MP4FFPARSERNODE_LOGCLOCK(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iClockLogger,PVLOGMSG_INFO,m);
 #define PVMF_MP4FFPARSERNODE_LOGBIN(iPortLogger, m) PVLOGGER_LOGBIN(PVLOGMSG_INST_LLDBG, iPortLogger, PVLOGMSG_ERR, m);
 #define PVMF_MP4FFPARSERNODE_LOGDIAGNOSTICS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF,iDiagnosticsLogger,PVLOGMSG_INFO,m);
@@ -75,7 +80,6 @@
 * Port/Track information
 */
 class MediaClockConverter;
-class TrackDataMemPoolProxyAlloc;
 
 class VideoTrackDimensionInfo
 {
@@ -118,20 +122,21 @@
             TRACKSTATE_ERROR,
             TRACKSTATE_DOWNLOAD_AUTOPAUSE,
             TRACKSTATE_SEND_ENDOFTRACK,
-            TRACKSTATE_TRACKMAXDATASIZE_RESIZE
+            TRACKSTATE_TRACKMAXDATASIZE_RESIZE,
+            TRACKSTATE_SKIP_CORRUPT_SAMPLE
         };
 
         PVMP4FFNodeTrackPortInfo()
         {
             iTrackId = -1;
             iPortInterface = NULL;
-            iFormatType = PVMF_FORMAT_UNKNOWN;
+            iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            iFormatTypeInteger = 0;
             iClockConverter = NULL;
             iState = TRACKSTATE_UNINITIALIZED;
             iTrackMaxDataSize = 0;
             iTrackMaxQueueDepth = 0;
             iTrackDataMemoryPool = NULL;
-            iTrackDataMemoryPoolProxy = NULL;
             iMediaDataImplAlloc = NULL;
             iTextMediaDataImplAlloc = NULL;
             iMediaDataMemPool = NULL;
@@ -172,6 +177,7 @@
             iPortInterface = aSrc.iPortInterface;
             iMimeType = aSrc.iMimeType;
             iFormatType = aSrc.iFormatType;
+            iFormatTypeInteger = aSrc.iFormatTypeInteger;
             iClockConverter = aSrc.iClockConverter;
             iFormatSpecificConfig = aSrc.iFormatSpecificConfig;
             iFormatSpecificConfigAndFirstSample = aSrc.iFormatSpecificConfigAndFirstSample;
@@ -180,7 +186,6 @@
             iTrackMaxDataSize = aSrc.iTrackMaxDataSize;
             iTrackMaxQueueDepth = aSrc.iTrackMaxQueueDepth;
             iTrackDataMemoryPool = aSrc.iTrackDataMemoryPool;
-            iTrackDataMemoryPoolProxy = aSrc.iTrackDataMemoryPoolProxy;
             iMediaDataImplAlloc = aSrc.iMediaDataImplAlloc;
             iTextMediaDataImplAlloc = aSrc.iTextMediaDataImplAlloc;
             iMediaDataMemPool = aSrc.iMediaDataMemPool;
@@ -222,11 +227,6 @@
         void freechunkavailable(OsclAny*)
         {
 
-            /*	if (iMimeType.get_size() > 0) //pvdt29435
-            	{
-            		//PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMP4FFNodeTrackPortInfo::freechunkavailable() called %s",iMimeType.get_cstr()));
-            	}
-            */
             if (iState == TRACKSTATE_MEDIADATAPOOLEMPTY || iState == TRACKSTATE_MEDIADATAFRAGGROUPPOOLEMPTY)
             {
                 //PVLogger* iDataPathLogger = PVLogger::GetLoggerObject("datapath.sourcenode.mp4parsernode");
@@ -249,12 +249,6 @@
         // calling notifyfreeblockavailable() on the mempool
         void freeblockavailable(OsclAny*)
         {
-            /*
-            if (iMimeType.get_size() > 0) //pvdt29435
-            {
-            	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMP4FFNodeTrackPortInfo::freeblockavailable() called %s",iMimeType.get_cstr()));
-            }
-            */
             // Check if track is waiting for track data to be available
             if (iState == TRACKSTATE_TRACKDATAPOOLEMPTY)
             {
@@ -281,6 +275,8 @@
         OSCL_HeapString<OsclMemAllocator> iMimeType;
         // Format type for the port
         PVMFFormatType iFormatType;
+        // Integer Format type for the port
+        uint32 iFormatTypeInteger;
         // Converter to convert from track timescale to milliseconds
         MediaClockConverter* iClockConverter;
         // Shared memory pointer holding the decoder specific config info for this track
@@ -298,10 +294,8 @@
         uint32 iTrackMaxQueueDepth;
         // Output buffer memory pool
         OsclMemPoolResizableAllocator *iTrackDataMemoryPool;
-        // Allocator wrapper for the output buffer memory pool
-        TrackDataMemPoolProxyAlloc* iTrackDataMemoryPoolProxy;
         // Allocator for simple media data buffer impl
-        PVMFSimpleMediaBufferCombinedAlloc *iMediaDataImplAlloc;
+        PVMFResizableSimpleMediaMsgAlloc *iMediaDataImplAlloc;
         // Allocator for text track simple media data buffer impl
         PVMFTimedTextMediaDataAlloc* iTextMediaDataImplAlloc;
         // Memory pool for simple media data
diff --git a/nodes/pvomxaudiodecnode/Android.mk b/nodes/pvomxaudiodecnode/Android.mk
index a7539a5..e0303db 100644
--- a/nodes/pvomxaudiodecnode/Android.mk
+++ b/nodes/pvomxaudiodecnode/Android.mk
@@ -3,29 +3,32 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_omx_audiodec_factory.cpp \
-	src/pvmf_omx_audiodec_node.cpp \
-	src/pvmf_omx_audiodec_port.cpp \
-	src/pvmf_omx_audiodec_callbacks.cpp
-
+ 	src/pvmf_omx_audiodec_node.cpp
 
 
 LOCAL_MODULE := libpvomxaudiodecnode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvomxaudiodecnode/include \
-	$(PV_TOP)//nodes/pvomxaudiodecnode/src \
-	$(PV_TOP)//nodes/pvomxaudiodecnode/../../extern_libs_v2/khronos/openmax/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvomxaudiodecnode/src \
+ 	$(PV_TOP)/nodes/pvomxaudiodecnode/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/baselibs/threadsafe_callback_ao/src \
+ 	$(PV_TOP)/nodes/pvomxbasedecnode/include \
+ 	$(PV_TOP)/nodes/pvomxbasedecnode/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvmf_omx_audiodec_defs.h \
-	include/pvmf_omx_audiodec_factory.h \
-	include/pvmf_omx_audiodec_port.h
+ 	include/pvmf_omx_audiodec_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvomxaudiodecnode/build/make/local.mk b/nodes/pvomxaudiodecnode/build/make/local.mk
new file mode 100644
index 0000000..5493fff
--- /dev/null
+++ b/nodes/pvomxaudiodecnode/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvomxaudiodecnode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += \
+  ../../../../extern_libs_v2/khronos/openmax/include \
+
+XINCDIRS += ../../../../extern_libs_v2/khronos/openmax/include \
+            ../../../../baselibs/threadsafe_callback_ao/src \
+            ../../../pvomxbasedecnode/include \
+            ../../../pvomxbasedecnode/src
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_omx_audiodec_factory.cpp \
+	pvmf_omx_audiodec_node.cpp
+
+HDRS :=	pvmf_omx_audiodec_factory.h 
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvomxaudiodecnode/build/make/makefile b/nodes/pvomxaudiodecnode/build/make/makefile
deleted file mode 100644
index ec10b34..0000000
--- a/nodes/pvomxaudiodecnode/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvomxaudiodecnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += \
-	-I ../../../../extern_libs_v2/khronos/openmax/include \
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_omx_audiodec_factory.cpp \
-	pvmf_omx_audiodec_node.cpp \
-	pvmf_omx_audiodec_port.cpp \
-	pvmf_omx_audiodec_callbacks.cpp
-
-HDRS =  pvmf_omx_audiodec_defs.h \
-	pvmf_omx_audiodec_factory.h \
-	pvmf_omx_audiodec_port.h 
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_defs.h b/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_defs.h
deleted file mode 100644
index ac1a541..0000000
--- a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_defs.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_AUDIODEC_DEFS_H_INCLUDED
-#define PVMF_OMX_AUDIODEC_DEFS_H_INCLUDED
-
-// Error and info messages
-//
-
-enum PVMFOMXAudioDecNodeErrors
-{
-    // Video decoder node failed to initialize the video decoder. Fatal error so the node needs to be reset.
-    PVOMXAUDIODECNODE_ERROR_DECODER_INIT_FAILED = PVMF_NODE_ERROR_EVENT_LAST
-};
-
-enum PVMFOMXAudioDecNodeInfo
-{
-    // Decoding of a frame failed. Video decoder node will continue on to decode the next frame
-    PVOMXAUDIODECNODE_INFO_DECODEFRAME_FAILED = PVMF_NODE_INFO_EVENT_LAST,
-    // Input bitstream buffer overflowed (frame too large or couldn't find frame marker). Data will be dropped until the next frame marker is found
-    // then frame will be decoded.
-    PVOMXAUDIODECNODE_INFO_INPUTBITSTREAMBUFFER_OVERFLOW
-};
-
-#endif // PVMF_OMXAUDIODEC_DEFS_H_INCLUDED
-
-
diff --git a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_factory.h b/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_factory.h
index 5182859..d8af98a 100644
--- a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_factory.h
+++ b/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,8 +36,8 @@
  * PVMFOMXAudioDecNodeFactory Class
  *
  * a singleton class which instantiates and provides
- * access to OMX video decoder node. It returns a PVMFNodeInterface
- * reference, the interface class of the PVMFVideoDecNode.
+ * access to OMX audio decoder node. It returns a PVMFNodeInterface
+ * reference, the interface class of the PVMFAudioDecNode.
  *
  * The client is expected to contain and maintain a pointer to the instance created
  * while the node is active.
@@ -48,7 +48,7 @@
         /**
          * Creates an instance of a PVMFOMXAudioDecNode. If the creation fails, this function will leave.
          *
-         * @param aPriority The active object priority for the node. Default is nominal priority if not specified
+         * @param aPriority The active object priority for the node. Default is standard priority if not specified
          * @returns A pointer to an instance of PVMFOMXAudioDecNode as PVMFNodeInterface reference or leaves if instantiation fails
          **/
         OSCL_IMPORT_REF static PVMFNodeInterface* CreatePVMFOMXAudioDecNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
diff --git a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_node_extension_interface.h b/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_node_extension_interface.h
deleted file mode 100644
index d70329e..0000000
--- a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_node_extension_interface.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_AUDIODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-#define PVMF_OMX_AUDIODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-
-struct PVMFOMXAudioDecNodeConfig
-{
-    bool iPostProcessingEnable;
-    int32 iPostProcessingMode;
-    bool iDropFrame;
-    uint32 iMimeType;
-};
-
-//Mimetype and Uuid for the custom interface
-#define PVMF_OMX_AUDIO_DEC_NODE_CUSTOM1_UUID 2,3,4,0xef,0xbe,0xbf,0xdf,0x30,0x21,0x73,0x33
-
-//Mimetypes for the custom interface
-#define PVMF_OMX_AUDIO_DEC_NODE_CUSTOM1_MIMETYPE "pvxxx/OMXAudioDecNode/Custom1"
-
-class PVMFOMXAudioDecNodeExtensionInterface : public PVInterface
-{
-    public:
-        //**********begin PVInterface
-        virtual void addRef() = 0;
-        virtual void removeRef() = 0;
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
-        //**********end PVInterface
-
-        virtual PVMFStatus SetDecoderNodeConfiguration(PVMFOMXAudioDecNodeConfig& aConfig) = 0;
-
-};
-
-#endif //PVMF_OMX_AUDIODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-
-
diff --git a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_port.h b/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_port.h
deleted file mode 100644
index 0e33187..0000000
--- a/nodes/pvomxaudiodecnode/include/pvmf_omx_audiodec_port.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_AUDIODEC_PORT_H_INCLUDED
-#define PVMF_OMX_AUDIODEC_PORT_H_INCLUDED
-
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-
-#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
-#include "pvmf_port_base_impl.h"
-#endif
-
-#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
-#include "pvmi_config_and_capability_utils.h"
-#endif
-
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-
-class PVMFOMXAudioDecNode;
-
-//Default vector reserve size
-#define PVMF_OMX_AUDIO_DEC_NODE_PORT_VECTOR_RESERVE 10
-
-
-#define PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS "x-pvmf/video/decode/input_formats"
-//#define PVMF_VID_DEC_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/video/decode/input_formats;valtype=int32"
-#define PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=int32"
-
-typedef enum
-{
-    PVMF_OMX_AUDIO_DEC_NODE_PORT_TYPE_SOURCE,
-    PVMF_OMX_AUDIO_DEC_NODE_PORT_TYPE_SINK,
-} PVMFOMXAudioDecPortType;
-
-class PVMFOMXAudioDecPort : public PvmfPortBaseImpl
-            , public PvmiCapabilityAndConfigPortFormatImpl
-{
-    public:
-        PVMFOMXAudioDecPort(int32 aTag, PVMFNodeInterface* aNode, char*);
-        ~PVMFOMXAudioDecPort();
-
-        // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface
-        bool IsFormatSupported(PVMFFormatType);
-        void FormatUpdated();
-        bool pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag);
-        // this port supports config interface
-        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
-        {
-            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-                aPtr = (PvmiCapabilityAndConfig*)this;
-            else
-                aPtr = NULL;
-        }
-
-        PVMFStatus Connect(PVMFPortInterface* aPort);
-
-        void setParametersSync(PvmiMIOSession aSession,
-                               PvmiKvp* aParameters,
-                               int num_elements,
-                               PvmiKvp * & aRet_kvp);
-
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-        PVMFStatus verifyConnectedPortParametersSync(const char* aFormatValType, OsclAny* aConfig);
-
-        uint32 getTrackConfigSize()
-        {
-            return iTrackConfigSize;
-        }
-        uint8* getTrackConfig()
-        {
-            return iTrackConfig;
-        }
-
-
-
-    private:
-        void Construct();
-        PVLogger *iLogger;
-        uint32 iNumFramesGenerated; //number of source frames generated.
-        uint32 iNumFramesConsumed; //number of frames consumed & discarded.
-        uint32 iTrackConfigSize;
-        uint8* iTrackConfig;
-
-        friend class PVMFOMXAudioDecNode;
-        PVMFOMXAudioDecNode* iOMXNode;
-};
-
-#endif // PVMF_OMX_AUDIODEC_PORT_H_INCLUDED
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_callbacks.cpp b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_callbacks.cpp
deleted file mode 100644
index c18e3ee..0000000
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_callbacks.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_omx_audiodec_callbacks.h"
-#include "pvmf_omx_audiodec_node.h"
-
-/* Audio - 3 OMX callback related methods */
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-EventHandlerThreadSafeCallbackAO_Audio::EventHandlerThreadSafeCallbackAO_Audio(void* aObserver,
-        uint32 aDepth,
-        const char* aAOname,
-        int32 aPriority)
-        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
-    if (iMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO_Audio::CreateMemPool() Memory pool failed to allocate"));
-    }
-    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-    // created in the 2nd thread and will fail to deallocate properly.
-
-    OsclAny *dummy = iMemoryPool->allocate(sizeof(EventHandlerSpecificData_Audio));
-    iMemoryPool->deallocate(dummy);
-}
-
-EventHandlerThreadSafeCallbackAO_Audio::~EventHandlerThreadSafeCallbackAO_Audio()
-{
-    if (iMemoryPool)
-    {
-
-        iMemoryPool->removeRef();
-        iMemoryPool = NULL;
-    }
-}
-OsclReturnCode EventHandlerThreadSafeCallbackAO_Audio::ProcessEvent(OsclAny* EventData)
-{
-    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
-    if (iObserver != NULL)
-    {
-        PVMFOMXAudioDecNode* ptr = (PVMFOMXAudioDecNode*) iObserver;
-
-        ptr->ProcessCallbackEventHandler_MultiThreaded(EventData);
-
-    }
-    return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void EventHandlerThreadSafeCallbackAO_Audio::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::Run() In"));
-
-    OsclAny *P; // parameter to dequeue
-    OsclReturnCode status = OsclSuccess;
-
-    do
-    {
-
-
-        P = DeQueue(status);
-
-
-        if ((status == OsclSuccess) || (status == OsclPending))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::Run() - Calling Process Event"));
-            ProcessEvent(P);
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::Run() - could not dequeue event data"));
-        }
-
-
-        // it is possible that an event arrives between dequeueing the last event and this point.
-        // If this is the case, we will be rescheduled and process the event
-        // in the next RunL
-
-
-    }
-    while (status == OsclSuccess);
-    // if the status is "OsclPending" there were no more events in the queue
-    // (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* EventHandlerThreadSafeCallbackAO_Audio::DeQueue(OsclReturnCode &stat)
-{
-    OsclAny *pData;
-    OsclProcStatus::eOsclProcError sema_status;
-
-    stat = OsclSuccess;
-
-    // Protect the queue while accessing it:
-    Mutex.Lock();
-
-    if (Q->NumElem == 0)
-    {
-        // nothing to de-queue
-        stat = OsclFailure;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::DeQueue() - No events in the queue - return ()"));
-        Mutex.Unlock();
-
-        return NULL;
-    }
-
-    pData = (Q->pFirst[Q->index_out]).pData;
-
-    Q->index_out++;
-    // roll-over the index
-    if (Q->index_out == Q->MaxNumElements)
-        Q->index_out = 0;
-
-    Q->NumElem--;
-    // check if there is need to call waitforevent
-    if ((Q->NumElem) == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::RunL() - No more events, call WaitForEvent()"));
-        PendForExec();
-        stat = OsclPending; // let the RunL know that the last event was pulled out of the queue
-        // so that it can get out of the loop
-    }
-
-    //release queue access
-    Mutex.Unlock();
-
-    // Signal the semaphore that controls the remote thread.
-    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-    sema_status = RemoteThreadCtrlSema.Signal();
-    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
-    {
-        stat = OsclFailure;
-        return NULL;
-    }
-
-    return pData;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-EmptyBufferDoneThreadSafeCallbackAO_Audio::EmptyBufferDoneThreadSafeCallbackAO_Audio(void* aObserver,
-        uint32 aDepth,
-        const char* aAOname,
-        int32 aPriority)
-        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
-    if (iMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO_Audio::CreateMemPool() Memory pool failed to allocate"));
-
-    }
-    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-    // created in the 2nd thread and will fail to deallocate properly.
-
-    OsclAny *dummy = iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData_Audio));
-    iMemoryPool->deallocate(dummy);
-}
-
-EmptyBufferDoneThreadSafeCallbackAO_Audio::~EmptyBufferDoneThreadSafeCallbackAO_Audio()
-{
-    if (iMemoryPool)
-    {
-
-        iMemoryPool->removeRef();
-        iMemoryPool = NULL;
-    }
-
-}
-OsclReturnCode EmptyBufferDoneThreadSafeCallbackAO_Audio::ProcessEvent(OsclAny* EventData)
-{
-    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
-    if (iObserver != NULL)
-    {
-        PVMFOMXAudioDecNode* ptr = (PVMFOMXAudioDecNode *) iObserver;
-
-        ptr->ProcessCallbackEmptyBufferDone_MultiThreaded(EventData);
-
-    }
-    return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void EmptyBufferDoneThreadSafeCallbackAO_Audio::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO_Audio::Run() In"));
-
-    OsclAny *P; // parameter to dequeue
-    OsclReturnCode status = OsclSuccess;
-
-    do
-    {
-
-
-        P = DeQueue(status);
-
-
-        if ((status == OsclSuccess) || (status == OsclPending))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO_Audio::Run() - Calling Process Event"));
-            ProcessEvent(P);
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO_Audio::Run() - could not dequeue event data"));
-        }
-
-
-        // it is possible that an event arrives between dequeueing the last event and this point.
-        // If this is the case, we will be rescheduled and process the event
-        // in the next RunL
-
-
-    }
-    while (status == OsclSuccess);
-    // if the status is "OsclPending" there were no more events in the queue
-    // (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO_Audio::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* EmptyBufferDoneThreadSafeCallbackAO_Audio::DeQueue(OsclReturnCode &stat)
-{
-    OsclAny *pData;
-    OsclProcStatus::eOsclProcError sema_status;
-
-    stat = OsclSuccess;
-
-    // Protect the queue while accessing it:
-    Mutex.Lock();
-
-    if (Q->NumElem == 0)
-    {
-        // nothing to de-queue
-        stat = OsclFailure;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO_Audio::DeQueue() - No events in the queue - return ()"));
-        Mutex.Unlock();
-
-        return NULL;
-    }
-
-    pData = (Q->pFirst[Q->index_out]).pData;
-
-    Q->index_out++;
-    // roll-over the index
-    if (Q->index_out == Q->MaxNumElements)
-        Q->index_out = 0;
-
-    Q->NumElem--;
-    // check if there is need to call waitforevent
-    if ((Q->NumElem) == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO_Audio::RunL() - No more events, call WaitForEvent()"));
-        PendForExec();
-        stat = OsclPending; // let the RunL know that the last event was pulled out of the queue
-        // so that it can get out of the loop
-    }
-
-    //release queue access
-    Mutex.Unlock();
-
-    // Signal the semaphore that controls the remote thread.
-    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-    sema_status = RemoteThreadCtrlSema.Signal();
-    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
-    {
-        stat = OsclFailure;
-        return NULL;
-    }
-
-    return pData;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-FillBufferDoneThreadSafeCallbackAO_Audio::FillBufferDoneThreadSafeCallbackAO_Audio(void* aObserver,
-        uint32 aDepth,
-        const char* aAOname,
-        int32 aPriority)
-        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
-    if (iMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO_Audio::CreateMemPool() Memory pool failed to allocate"));
-    }
-    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-    // created in the 2nd thread and will fail to deallocate properly.
-
-    OsclAny *dummy = iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData_Audio));
-    iMemoryPool->deallocate(dummy);
-}
-
-FillBufferDoneThreadSafeCallbackAO_Audio::~FillBufferDoneThreadSafeCallbackAO_Audio()
-{
-    if (iMemoryPool)
-    {
-        iMemoryPool->removeRef();
-        iMemoryPool = NULL;
-    }
-}
-
-OsclReturnCode FillBufferDoneThreadSafeCallbackAO_Audio::ProcessEvent(OsclAny* EventData)
-{
-    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
-    if (iObserver != NULL)
-    {
-        PVMFOMXAudioDecNode* ptr = (PVMFOMXAudioDecNode*) iObserver;
-
-        ptr->ProcessCallbackFillBufferDone_MultiThreaded(EventData);
-
-    }
-    return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void FillBufferDoneThreadSafeCallbackAO_Audio::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO_Audio::Run() In"));
-
-    OsclAny *P; // parameter to dequeue
-    OsclReturnCode status;
-    uint32 num_queue_elements;
-
-    do
-    {
-
-
-        P = DeQueue(status);
-
-
-        if ((status == OsclSuccess) || (status == OsclPending))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO_Audio::Run() - Calling Process Event"));
-            ProcessEvent(P);
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO_Audio::Run() - could not dequeue event data"));
-        }
-
-
-        // it is possible that an event arrives between dequeueing the last event and this point.
-        // If this is the case, we will be rescheduled and process the event
-        // in the next RunL
-
-
-    }
-    while (status == OsclSuccess);
-    // if the status is "OsclPending" there were no more events in the queue
-    // (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO_Audio::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* FillBufferDoneThreadSafeCallbackAO_Audio::DeQueue(OsclReturnCode &stat)
-{
-    OsclAny *pData;
-    OsclProcStatus::eOsclProcError sema_status;
-
-    stat = OsclSuccess;
-
-    // Protect the queue while accessing it:
-    Mutex.Lock();
-
-    if (Q->NumElem == 0)
-    {
-        // nothing to de-queue
-        stat = OsclFailure;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO_Audio::DeQueue() - No events in the queue - return ()"));
-        Mutex.Unlock();
-
-        return NULL;
-    }
-
-    pData = (Q->pFirst[Q->index_out]).pData;
-
-    Q->index_out++;
-    // roll-over the index
-    if (Q->index_out == Q->MaxNumElements)
-        Q->index_out = 0;
-
-    Q->NumElem--;
-    // check if there is need to call waitforevent
-    if ((Q->NumElem) == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO_Audio::RunL() - No more events, call WaitForEvent()"));
-        PendForExec();
-        stat = OsclPending; // let the RunL know that the last event was pulled out of the queue
-        // so that it can get out of the loop
-    }
-
-    //release queue access
-    Mutex.Unlock();
-
-    // Signal the semaphore that controls the remote thread.
-    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-    sema_status = RemoteThreadCtrlSema.Signal();
-    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
-    {
-        stat = OsclFailure;
-        return NULL;
-    }
-
-    return pData;
-}
-
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_callbacks.h b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_callbacks.h
deleted file mode 100644
index 4ae4640..0000000
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_callbacks.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_AUDIODEC_CALLBACKS_H_INCLUDED
-#define PVMF_OMX_AUDIODEC_CALLBACKS_H_INCLUDED
-
-
-/* Audio: 3 OMX callback related active object definitions */
-
-
-#ifndef THREADSAFE_CALLBACK_AO_H_INCLUDED
-#include "threadsafe_callback_ao.h"
-#endif
-
-#ifndef THREADSAFE_MEMPOOL_H_INCLUDED
-#include "threadsafe_mempool.h"
-#endif
-
-
-#ifndef OMX_Types_h
-#include "omx_types.h"
-#endif
-
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-// structure that contains EventHandler callback type parameters:
-typedef struct EventHandlerSpecificData_Audio
-{
-    OMX_HANDLETYPE hComponent;
-    OMX_PTR pAppData;
-    OMX_EVENTTYPE eEvent;
-    OMX_U32 nData1;
-    OMX_U32 nData2;
-    OMX_PTR pEventData;
-} EventHandlerSpecificData_Audio;
-
-
-// structure that contains EmptyBufferDone callback type parameters:
-typedef struct EmptyBufferDoneSpecificData_Audio
-{
-    OMX_HANDLETYPE hComponent;
-    OMX_PTR pAppData;
-    OMX_BUFFERHEADERTYPE* pBuffer;
-} EmptyBufferDoneSpecificData_Audio;
-
-
-// structure that contains FillBufferDone callback type parameters:
-typedef struct FillBufferDoneSpecificData_Audio
-{
-    OMX_HANDLETYPE hComponent;
-    OMX_PTR pAppData;
-    OMX_BUFFERHEADERTYPE* pBuffer;
-} FillBufferDoneSpecificData_Audio;
-
-
-// This class defines the callback AO that handles the callbacks from the remote thread in a thread-safe way.
-// The callback events arriving from the remote thread are queued and processed later in PV thread context.
-// The class is DERIVED from the "ThreadSafeCallbackAO" class defined in "threadsafe_callback_ao.h/cpp"
-// OVERLOAD THE METHOD : "ProcessEvent" so that it does something meaningful
-
-
-// Test AO receives the remote thread specific API callback and then calls the generic API "ReceiveEvent"
-const char EventHandlerAOName_Audio[] = "EventHandlerCallbackAO_Audio";
-const char EmptyBufferDoneAOName_Audio[] = "EventHandlerCallbackAO_Audio";
-const char FillBufferDoneAOName_Audio[] = "EventHandlerCallbackAO_Audio";
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class EventHandlerThreadSafeCallbackAO_Audio : public ThreadSafeCallbackAO
-{
-    public:
-        // Constructor
-        EventHandlerThreadSafeCallbackAO_Audio(
-            void* aObserver = NULL,
-            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-            const char* aAOname = EventHandlerAOName_Audio,
-            int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-
-        // OVERLOADED ProcessEvent
-        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-        virtual void Run();
-        virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-        OsclReturnCode ProcessEvent(OsclAny* EventData);
-        virtual ~EventHandlerThreadSafeCallbackAO_Audio();
-        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-
-};
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class EmptyBufferDoneThreadSafeCallbackAO_Audio : public ThreadSafeCallbackAO
-{
-    public:
-        // Constructor
-        EmptyBufferDoneThreadSafeCallbackAO_Audio(
-            void* aObserver = NULL,
-            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-            const char* aAOname = EmptyBufferDoneAOName_Audio,
-            int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        // OVERLOADED ProcessEvent
-        OsclReturnCode ProcessEvent(OsclAny* EventData);
-
-        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-        virtual void Run();
-        virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-        virtual ~EmptyBufferDoneThreadSafeCallbackAO_Audio();
-        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-};
-
-
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class FillBufferDoneThreadSafeCallbackAO_Audio : public ThreadSafeCallbackAO
-{
-    public:
-        // Constructor
-        FillBufferDoneThreadSafeCallbackAO_Audio(void* aObserver = NULL,
-                uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-                const char* aAOname = FillBufferDoneAOName_Audio,
-                int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        // OVERLOADED ProcessEvent
-        OsclReturnCode ProcessEvent(OsclAny* EventData);
-        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-        virtual void Run();
-        virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-        virtual ~FillBufferDoneThreadSafeCallbackAO_Audio();
-        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-};
-
-#endif	//#ifndef PVMF_OMX_AUDIODEC_CALLBACKS_H_INLCUDED
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_factory.cpp b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_factory.cpp
index 8f43eae..0e7cb0d 100644
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_factory.cpp
+++ b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,13 +24,14 @@
 #include "oscl_error_codes.h"
 #include "oscl_exception.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
 /* Audio decoder node factory methods */
 
+
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PVMFNodeInterface* PVMFOMXAudioDecNodeFactory::CreatePVMFOMXAudioDecNode(int32 aPriority)
 {
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_media_buffer.h b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_media_buffer.h
deleted file mode 100644
index 77bb5ad..0000000
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_media_buffer.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_OMX_VIDEODEC_MEDIA_BUFFER_H_INCLUDED
-#define PV_OMX_VIDEODEC_MEDIA_BUFFER_H_INCLUDED
-
-
-#ifndef OSCL_ERROR_H_INCLUDED
-#include "oscl_error.h"
-#endif
-
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-
-#ifndef OSCL_SHARED_PTR_H_INCLUDED
-#include "oscl_shared_ptr.h"
-#endif
-
-
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////
-/////////////////////////
-/////////////////////////
-// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
-//						1) Deallocates the underlying output buffer
-//						2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
-//					  Deallocator is created as part of the wrapper, and travels with the buffer wrapper
-
-class PVOMXBufferSharedPtrWrapperCombinedCleanupDA : public OsclDestructDealloc
-{
-    public:
-        PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
-                buf_alloc(allocator), ptr_to_data_to_dealloc(pMempoolData) {};
-        virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
-
-        virtual void destruct_and_dealloc(OsclAny* ptr)
-        {
-            // call buffer deallocator
-            if (buf_alloc != NULL)
-            {
-                buf_alloc->deallocate(ptr_to_data_to_dealloc);
-            }
-
-            // finally, free the shared ptr wrapper memory
-            oscl_free(ptr);
-        }
-
-    private:
-        Oscl_DefAlloc* buf_alloc;
-        void *ptr_to_data_to_dealloc;
-};
-
-#endif
-
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
index f84d87b..db84041 100644
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
+++ b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 #include "pvmf_omx_audiodec_node.h"
 #include "pvlogger.h"
 #include "oscl_error_codes.h"
-#include "pvmf_omx_audiodec_port.h"
+#include "pvmf_omx_basedec_port.h"
 #include "pv_mime_string_utils.h"
 #include "oscl_snprintf.h"
 #include "pvmf_media_cmd.h"
@@ -26,10 +26,23 @@
 #include "pvmi_kvp_util.h"
 #include "latmpayloadparser.h"
 
+
 #include "omx_core.h"
-#include "pvmf_omx_audiodec_callbacks.h"     //used for thin AO in Decoder's callbacks
+#include "pvmf_omx_basedec_callbacks.h"     //used for thin AO in Decoder's callbacks
 #include "pv_omxcore.h"
-#include "pv_omxmastercore.h"
+
+// needed for capability and config
+#include "pv_audio_config_parser.h"
+
+
+#define CONFIG_SIZE_AND_VERSION(param) \
+	    param.nSize=sizeof(param); \
+	    param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR; \
+	    param.nVersion.s.nVersionMinor = SPECVERSIONMINOR; \
+	    param.nVersion.s.nRevision = SPECREVISION; \
+	    param.nVersion.s.nStep = SPECSTEP;
+
+
 
 #define PVOMXAUDIODEC_MEDIADATA_POOLNUM 2*NUMBER_OUTPUT_BUFFER
 #define PVOMXAUDIODEC_MEDIADATA_CHUNKSIZE 128
@@ -52,288 +65,13 @@
 
 static const char PVOMXAUDIODECMETADATA_SEMICOLON[] = ";";
 
-
-
-// OMX CALLBACKS
-// 1) AO OMX component running in the same thread as the OMX node
-//	In this case, the callbacks can be called directly from the component
-//	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
-//	The callback can perform do RunIfNotReady
-
-// 2) Multithreaded component
-//	In this case, the callback is made using the threadsafe callback (TSCB) AO
-//	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent) => event is queued
-//  Node thread		 : dequeue event => TSCB(ProcessEvent)->ProcessCallbackEventHandler->EventHandlerProcessing
-
-
-
-// callback for Event Handler - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling EventHandlerProcessing
-OMX_ERRORTYPE CallbackEventHandler_Audio(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_EVENTTYPE aEvent,
-        OMX_OUT OMX_U32 aData1,
-        OMX_OUT OMX_U32 aData2,
-        OMX_OUT OMX_PTR aEventData)
-{
-
-    PVMFOMXAudioDecNode *Node = (PVMFOMXAudioDecNode *) aAppData;
-
-    if (Node->IsComponentMultiThreaded())
-    {
-        // allocate the memory for the callback event specific data
-        EventHandlerSpecificData_Audio* ED = (EventHandlerSpecificData_Audio*) Node->iThreadSafeHandlerEventHandler->iMemoryPool->allocate(sizeof(EventHandlerSpecificData_Audio));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->eEvent = aEvent;
-        ED->nData1 = aData1;
-        ED->nData2 = aData2;
-        ED->pEventData = aEventData;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerEventHandler->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-
-        OMX_ERRORTYPE status;
-        status = Node->EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
-        return status;
-    }
-
-}
-
-// callback for EmptyBufferDone - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling EmptyBufferDoneProcessing
-OMX_ERRORTYPE CallbackEmptyBufferDone_Audio(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-
-    PVMFOMXAudioDecNode *Node = (PVMFOMXAudioDecNode *) aAppData;
-    if (Node->IsComponentMultiThreaded())
-    {
-
-        // allocate the memory for the callback event specific data
-        //EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) oscl_malloc(sizeof (EmptyBufferDoneSpecificData));
-        EmptyBufferDoneSpecificData_Audio* ED = (EmptyBufferDoneSpecificData_Audio*) Node->iThreadSafeHandlerEmptyBufferDone->iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData_Audio));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->pBuffer = aBuffer;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerEmptyBufferDone->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
-        return status;
-    }
-
-}
-
-// callback for FillBufferDone - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling FillBufferDoneProcessing
-OMX_ERRORTYPE CallbackFillBufferDone_Audio(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-    PVMFOMXAudioDecNode *Node = (PVMFOMXAudioDecNode *) aAppData;
-    if (Node->IsComponentMultiThreaded())
-    {
-
-        // allocate the memory for the callback event specific data
-        //FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) oscl_malloc(sizeof (FillBufferDoneSpecificData));
-        FillBufferDoneSpecificData_Audio* ED = (FillBufferDoneSpecificData_Audio*) Node->iThreadSafeHandlerFillBufferDone->iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData_Audio));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->pBuffer = aBuffer;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerFillBufferDone->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
-        return status;
-    }
-
-}
-
-// Callback processing in multithreaded case - dequeued event - call EventHandlerProcessing
-OsclReturnCode PVMFOMXAudioDecNode::ProcessCallbackEventHandler_MultiThreaded(OsclAny* P)
-{
-
-    // re-cast the pointer
-
-    EventHandlerSpecificData_Audio* ED = (EventHandlerSpecificData_Audio*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_EVENTTYPE aEvent = ED->eEvent;
-    OMX_U32 aData1 = ED->nData1;
-    OMX_U32 aData2 = ED->nData2;
-    OMX_PTR aEventData = ED->pEventData;
-
-
-    EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
-
-
-    // release the allocated memory when no longer needed
-
-    iThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-
-
-// Callback processing in multithreaded case - dequeued event - call EmptyBufferDoneProcessing
-OsclReturnCode PVMFOMXAudioDecNode::ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P)
-{
-
-
-    // re-cast the pointer
-    EmptyBufferDoneSpecificData_Audio* ED = (EmptyBufferDoneSpecificData_Audio*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
-
-    EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
-
-    // release the allocated memory when no longer needed
-
-    iThreadSafeHandlerEmptyBufferDone->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-
-// Callback processing in multithreaded case - dequeued event - call FillBufferDoneProcessing
-OsclReturnCode PVMFOMXAudioDecNode::ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P)
-{
-
-    // re-cast the pointer
-    FillBufferDoneSpecificData_Audio* ED = (FillBufferDoneSpecificData_Audio*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
-
-
-    FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
-
-
-    // release the allocated memory when no longer needed
-
-    iThreadSafeHandlerFillBufferDone->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-//////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////
-
-
-
 /////////////////////////////////////////////////////////////////////////////
-// Class Distructor
+// Class Destructor
 /////////////////////////////////////////////////////////////////////////////
 PVMFOMXAudioDecNode::~PVMFOMXAudioDecNode()
 {
-    LogDiagnostics();
-
-    //Clearup decoder
-    DeleteOMXAudioDecoder();
     DeleteLATMParser();
-    // Cleanup callback AOs and Mempools
-    if (iThreadSafeHandlerEventHandler)
-    {
-        OSCL_DELETE(iThreadSafeHandlerEventHandler);
-        iThreadSafeHandlerEventHandler = NULL;
-    }
-    if (iThreadSafeHandlerEmptyBufferDone)
-    {
-        OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
-        iThreadSafeHandlerEmptyBufferDone = NULL;
-    }
-    if (iThreadSafeHandlerFillBufferDone)
-    {
-        OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
-        iThreadSafeHandlerFillBufferDone = NULL;
-    }
-
-    if (iMediaDataMemPool)
-    {
-        iMediaDataMemPool->removeRef();
-        iMediaDataMemPool = NULL;
-    }
-
-    if (iOutBufMemoryPool)
-    {
-        iOutBufMemoryPool->removeRef();
-        iOutBufMemoryPool = NULL;
-    }
-    if (iInBufMemoryPool)
-    {
-        iInBufMemoryPool->removeRef();
-        iInBufMemoryPool = NULL;
-    }
-
-    //Thread logoff
-    if (IsAdded())
-    {
-        RemoveFromScheduler();
-        iIsAdded = false;
-    }
-
-    //Cleanup allocated interfaces
-
-    //Cleanup allocated ports
     ReleaseAllPorts();
-
-    //Cleanup commands
-    //The command queues are self-deleting, but we want to
-    //notify the observer of unprocessed commands.
-    while (!iCurrentCommand.empty())
-    {
-        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
-    }
-    while (!iInputCommands.empty())
-    {
-        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
-    }
-
-    //Release Input buffer
-    iDataIn.Unbind();
-
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -352,7 +90,7 @@
                 iIsAdded = true;
             }
             iLogger = PVLogger::GetLoggerObject("PVMFOMXAudioDecNode");
-            iRunLogger = PVLogger::GetLoggerObject("Run.PVMFOMXAudioDecNode");
+            iRunlLogger = PVLogger::GetLoggerObject("Run.PVMFOMXAudioDecNode");
             iDataPathLogger = PVLogger::GetLoggerObject("datapath");
             iClockLogger = PVLogger::GetLoggerObject("clock");
             iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.decnode.OMXAudioDecnode");
@@ -365,198 +103,6 @@
     }
 }
 
-/////////////////////////////////////////////////////////////////////////////
-// Remove AO from the scheduler
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::ThreadLogoff()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFOMXAudioDecNode:ThreadLogoff"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            if (IsAdded())
-            {
-                RemoveFromScheduler();
-                iIsAdded = false;
-            }
-            iLogger = NULL;
-            SetState(EPVMFNodeCreated);
-            return PVMFSuccess;
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-
-        default:
-            return PVMFErrInvalidState;
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
-
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::GetCapability(PVMFNodeCapability& aNodeCapability)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::GetCapability() called"));
-
-    aNodeCapability = iCapability;
-    return PVMFSuccess;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFPortIter* PVMFOMXAudioDecNode::GetPorts(const PVMFPortFilter* aFilter)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::GetPorts() called"));
-
-    OSCL_UNUSED_ARG(aFilter);
-
-    return NULL;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::QueueCommandL(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVMFCommandId id;
-
-    id = iInputCommands.AddL(aCmd);
-
-    if (iInputCommands.size() == 1)
-    {
-        //wakeup the AO all the rest of input commands will reschedule the AO in Run
-        RunIfNotReady();
-    }
-    return id;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, PVMFOMXAudioDecNodeAllocator>& aUuids,
-        bool aExactUuidsOnly,
-        const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::QueryUUID() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
-        PVInterface*& aInterfacePtr,
-        const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::QueryInterface() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* /* aPortConfig */, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::RequestPort() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_REQUESTPORT, aPortTag, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ReleasePort() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RELEASEPORT, aPort, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Init(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Init() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_INIT, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Prepare() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_PREPARE, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Start(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Start() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_START, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Stop(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Stop() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_STOP, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Flush(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Flush() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_FLUSH, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Pause(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Pause() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_PAUSE, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::Reset(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Reset() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::CancelAllCommands() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_CANCELALL, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::CancelCommand() called"));
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommandBase::Construct(s, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_CANCELCMD, aCmdId, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::SetDecoderNodeConfiguration(PVMFOMXAudioDecNodeConfig& aNodeConfig)
-{
-    iNodeConfig = aNodeConfig;
-    return PVMFSuccess;
-}
-
-
 /////////////////////
 // Private Section //
 /////////////////////
@@ -565,34 +111,7 @@
 // Class Constructor
 /////////////////////////////////////////////////////////////////////////////
 PVMFOMXAudioDecNode::PVMFOMXAudioDecNode(int32 aPriority) :
-        OsclActiveObject(aPriority, "PVMFOMXAudioDecNode"),
-        iInPort(NULL),
-        iOutPort(NULL),
-        iOutBufMemoryPool(NULL),
-        iMediaDataMemPool(NULL),
-        iOMXComponentOutputBufferSize(0),
-        iOutputAllocSize(0),
-        iProcessingState(EPVMFOMXAudioDecNodeProcessingState_Idle),
-        iOMXAudioDecoder(NULL),
-        iSendBOS(false),
-        iStreamID(0),
-        iBOSTimestamp(0),
-        iSeqNum(0),
-        iSeqNum_In(0),
-        iIsAdded(true),
-        iLogger(NULL),
-        iDataPathLogger(NULL),
-        iClockLogger(NULL),
-        iExtensionRefCount(0),
-        iEndOfDataReached(false),
-        iEndOfDataTimestamp(0),
-        iDiagnosticsLogger(NULL),
-        iDiagnosticsLogged(false),
-        iNewWidth(0),
-        iNewHeight(0),
-        iAvgBitrateValue(0),
-        iResetInProgress(false),
-        iResetMsgSent(false)
+        PVMFOMXBaseDecNode(aPriority, "PVMFOMXAudioDecNode")
 {
     iInterfaceState = EPVMFNodeCreated;
 
@@ -604,7 +123,7 @@
 
              //Create the input command queue.  Use a reserve to avoid lots of
              //dynamic memory allocation.
-             iInputCommands.Construct(PVMF_OMXAUDIODEC_NODE_COMMAND_ID_START, PVMF_OMXAUDIODEC_NODE_COMMAND_VECTOR_RESERVE);
+             iInputCommands.Construct(PVMF_OMXBASEDEC_NODE_COMMAND_ID_START, PVMF_OMXBASEDEC_NODE_COMMAND_VECTOR_RESERVE);
 
              //Create the "current command" queue.  It will only contain one
              //command at a time, so use a reserve of 1.
@@ -616,433 +135,39 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = true;
              iCapability.iMaxNumberOfPorts = 2;
-             iCapability.iInputFormatCapability.push_back(PVMF_MPEG4_AUDIO);
-             iCapability.iInputFormatCapability.push_back(PVMF_ADIF);
-             iCapability.iInputFormatCapability.push_back(PVMF_LATM);
-             iCapability.iInputFormatCapability.push_back(PVMF_ASF_MPEG4_AUDIO);
-             iCapability.iInputFormatCapability.push_back(PVMF_AAC_SIZEHDR);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_MPEG4_AUDIO);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_ADIF);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_LATM);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_ASF_MPEG4_AUDIO);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_AAC_SIZEHDR);
 
-             iCapability.iInputFormatCapability.push_back(PVMF_AMR_IF2);
-             iCapability.iInputFormatCapability.push_back(PVMF_AMR_IETF);
-             iCapability.iInputFormatCapability.push_back(PVMF_AMR_IETF_COMBINED);
-             iCapability.iInputFormatCapability.push_back(PVMF_AMRWB_IETF);
-             iCapability.iInputFormatCapability.push_back(PVMF_AMRWB_IETF_PAYLOAD);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMR_IF2);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMR);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMRWB_IETF);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_AMRWB);
 
-             iCapability.iInputFormatCapability.push_back(PVMF_MP3);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_MP3);
 
-             iCapability.iInputFormatCapability.push_back(PVMF_WMA);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_WMA);
 
-             iCapability.iOutputFormatCapability.push_back(PVMF_PCM16);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_PCM16);
 
              iAvailableMetadataKeys.reserve(PVMF_OMXAUDIODEC_NUM_METADATA_VALUES);
              iAvailableMetadataKeys.clear();
             );
-
-
-
-    iThreadSafeHandlerEventHandler = NULL;
-    iThreadSafeHandlerEmptyBufferDone = NULL;
-    iThreadSafeHandlerFillBufferDone = NULL;
-
-    iInBufMemoryPool = NULL;
-    iOutBufMemoryPool = NULL;
-
-    // init to some value
-    iOMXComponentOutputBufferSize = 0;
-    iNumOutputBuffers = 0;
-    iOMXComponentInputBufferSize = 0;
-    iNumInputBuffers = 0;
-
-    iDoNotSendOutputBuffersDownstreamFlag = false;
-    iDoNotSaveInputBuffersFlag = false;
-
-    iOutputBuffersFreed = true;// buffers have not been created yet, so they can be considered freed
-    iInputBuffersFreed = true;
-
-    // dynamic port reconfig init vars
-    iSecondPortReportedChange = false;
-    iDynamicReconfigInProgress = false;
-    iPauseCommandWasSentToComponent = false;
-    iStopCommandWasSentToComponent = false;
-
-    // EOS flag init
-    iIsEOSSentToComponent = false;
-    iIsEOSReceivedFromComponent = false;
-
     // LATM init
     iLATMParser = NULL;
     iLATMConfigBuffer = NULL;
     iLATMConfigBufferSize = 0;
 
-    // reset repositioning related flags
-    iIsRepositioningRequestSentToComponent = false;
-    iIsRepositionDoneReceivedFromComponent = false;
-    iIsOutputPortFlushed = false;
-    iIsInputPortFlushed = false;
-
-    iIsRepositionIdleDoneReceivedFromComponent = false;
-    iIsRepositionIdleRequestSentToComponent = false;
-    iIsRepositionExecRequestSentToComponent = false;
-    iIsRepositionExecDoneReceivedFromComponent = false;
-
-    // init state of component
-    iCurrentDecoderState = OMX_StateInvalid;
-
-    iOutTimeStamp = 0;
-
-    // counts output frames (for logging)
-    iFrameCounter = 0;
     //Try Allocate FSI buffer
 
     // Do This first in case of Query
     OSCL_TRY(err, iFsiFragmentAlloc.size(PVOMXAUDIODEC_MEDIADATA_POOLNUM, sizeof(channelSampleInfo)));
 
 
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// Local Run Routine
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Run() In"));
-
-    // if reset is in progress, call DoReset again until Reset Msg is sent
-    if ((iResetInProgress == true) &&
-            (iResetMsgSent == false) &&
-            (iCurrentCommand.size() > 0) &&
-            (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-       )
-    {
-        DoReset(iCurrentCommand.front());
-        return; // don't do anything else
-    }
-    //Check for NODE commands...
-    if (!iInputCommands.empty())
-    {
-        if (ProcessCommand(iInputCommands.front()))
-        {
-            if (iInterfaceState != EPVMFNodeCreated
-                    && (!iInputCommands.empty() || (iInPort && (iInPort->IncomingMsgQueueSize() > 0)) ||
-                        (iDataIn.GetRep() != NULL) || (iDynamicReconfigInProgress == true)))
-            {
-                // reschedule if more data is available, or if port reconfig needs to be finished (even if there is no new data)
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - rescheduling after process command"));
-                RunIfNotReady();
-            }
-            return;
-        }
-
-        if (!iInputCommands.empty())
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - rescheduling to process more commands"));
-            RunIfNotReady();
-        }
-    }
-
-    if (((iCurrentCommand.size() == 0) && (iInterfaceState != EPVMFNodeStarted)) ||
-            ((iCurrentCommand.size() > 0) && (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_START) && (iInterfaceState != EPVMFNodeStarted)))
-    {
-        // rescheduling because of input data will be handled in Command Processing Part
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - Node not in Started state yet"));
-        return;
-    }
-
-
-    // Process port activity, push out all outgoing messages
-    if (iOutPort)
-    {
-        while (iOutPort->OutgoingMsgQueueSize())
-        {
-            // if port is busy it is going to wakeup from port ready event
-            if (!ProcessOutgoingMsg(iOutPort))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - Outgoing Port Busy, cannot send more msgs"));
-                break;
-            }
-        }
-    }
-
-    int loopCount = 0;
-    // try to consume all data from input port at once
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-    uint32 startticks = OsclTickCount::TickCount();
-    uint32 starttime = OsclTickCount::TicksToMsec(startticks);
-#endif
-
-    do
-    {
-        // Process port activity if there is no input data that is being processed
-        // Do not accept any input if EOS needs to be sent out
-        if (iInPort && (iInPort->IncomingMsgQueueSize() > 0) && (iDataIn.GetRep() == NULL) && !iEndOfDataReached)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - Getting more input"));
-            if (!ProcessIncomingMsg(iInPort))
-            {
-                //Re-schedule
-                RunIfNotReady();
-                return;
-            }
-        }
-
-        if (iSendBOS)
-        {
-
-            // this routine may be re-entered multiple times in multiple Run's before the component goes through cycle execute->idle->execute
-            if (!HandleRepositioning())
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - Repositioning not done yet"));
-
-                return;
-            }
-
-            SendBeginOfMediaStreamCommand();
-
-
-        }
-        // If in init or ready to decode state, process data in the input port if there is input available and input buffers are present
-        // (note: at EOS, iDataIn will not be available)
-
-        if ((iDataIn.GetRep() != NULL) ||
-                ((iNumOutstandingOutputBuffers < iNumOutputBuffers) &&
-                 (iProcessingState == EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode) &&
-                 (iResetMsgSent == false)) ||
-                ((iDynamicReconfigInProgress == true) && (iResetMsgSent == false))
-
-           )
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::Run() - Calling HandleProcessingState"));
-
-            // input data is available, that means there is video data to be decoded
-            if (HandleProcessingState() != PVMFSuccess)
-            {
-                // If HandleProcessingState does not return Success, we must wait for an event
-                // no point in  rescheduling
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXAudioDecNode::Run() - HandleProcessingState did not return Success"));
-
-                return;
-            }
-        }
-
-        loopCount++;
-    }
-    while (iInPort &&
-            (((iInPort->IncomingMsgQueueSize() > 0) || (iDataIn.GetRep() != NULL)) && (iNumOutstandingInputBuffers < iNumInputBuffers))
-            && (!iEndOfDataReached)
-            && (iResetMsgSent == false)
-          );
-
-#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_REL)
-    uint32 endticks = OsclTickCount::TickCount();
-    uint32 endtime = OsclTickCount::TicksToMsec(endticks);
-    uint32 timeinloop = (endtime - starttime);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iRunLogger, PVLOGMSG_INFO,
-                    (0, "PVMFOMXAudioDecNode::Run() - LoopCount = %d, Time spent in loop(in ms) = %d, iNumOutstandingInputBuffers = %d, iNumOutstandingOutputBuffers = %d ",
-                     loopCount, timeinloop, iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
-#endif
-
-    // EOS processing:
-    // first send an empty buffer to OMX component and mark the EOS flag
-    // wait for the OMX component to send async event to indicate that it has reached this EOS buffer
-    // then, create and send the EOS message downstream
-
-    if (iEndOfDataReached && !iDynamicReconfigInProgress)
-    {
-
-        // if EOS was not sent yet and we have an available input buffer, send EOS buffer to component
-        if (!iIsEOSSentToComponent && (iNumOutstandingInputBuffers < iNumInputBuffers))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::Run() - Sending EOS marked buffer To Component "));
-
-            iIsEOSSentToComponent = true;
-
-            // if the component is not yet initialized or if it's in the middle of port reconfig,
-            // don't send EOS buffer to component. It does not care. Just set the flag as if we received
-            // EOS from the component to enable sending EOS downstream
-            if (iProcessingState != EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode)
-            {
-
-                iIsEOSReceivedFromComponent = true;
-            }
-            else if (!SendEOSBufferToOMXComponent())
-
-            {
-                // for some reason, Component can't receive the EOS buffer
-                // it could be that it is not initialized yet (because EOS could be the first msg). In this case,
-                // send the EOS downstream anyway
-                iIsEOSReceivedFromComponent = true;
-            }
-        }
-
-        // we must wait for event (acknowledgment from component)
-        // before sending EOS downstream. This is because OMX Component will send
-        // the EOS event only after processing remaining buffers
-
-        if (iIsEOSReceivedFromComponent)
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::Run() - Received EOS from component, Sending EOS msg downstream "));
-
-            if (iOutPort && iOutPort->IsOutgoingQueueBusy())
-            {
-                // note: we already tried to empty the outgoing q. If it's still busy,
-                // it means that output port is busy. Just return and wait for the port to become free.
-                // this will wake up the node and it will send out a msg from the q etc.
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXAudioDecNode::Run() - - EOS cannot be sent downstream, outgoing queue busy - wait"));
-                return;
-            }
-
-            if (SendEndOfTrackCommand()) // this will only q the EOS
-            {
-                // EOS send downstream OK, so reset the flag
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXAudioDecNode::Run() - EOS was queued to be sent downstream"));
-
-                iEndOfDataReached = false; // to resume normal processing, reset the flags
-                iIsEOSSentToComponent = false;
-                iIsEOSReceivedFromComponent = false;
-
-                RunIfNotReady(); // Run again to send out the EOS msg from the outgoing q, and resume
-                // normal processing
-                ReportInfoEvent(PVMFInfoEndOfData);
-            }
-        }
-        else
-        {
-            // keep sending output buffers, it's possible that the component needs to flush output
-            //	data at the end
-            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
-            {
-                if (!SendOutputBufferToOMXComponent())
-                    break;
-            }
-        }
-
-    }
-
-
-    //Check for flash command complition...
-    if (iInPort && iOutPort && (iCurrentCommand.size() > 0) &&
-            (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_FLUSH) &&
-            (iInPort->IncomingMsgQueueSize() == 0) &&
-            (iOutPort->OutgoingMsgQueueSize() == 0) &&
-            (iDataIn.GetRep() == NULL))
-    {
-        //flush command is completed
-        //Debug check-- all the port queues should be empty at this point.
-
-        OSCL_ASSERT(iInPort->IncomingMsgQueueSize() == 0 && iOutPort->OutgoingMsgQueueSize() == 0);
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::Run() - Flush pending"));
-        iEndOfDataReached = false;
-        iIsEOSSentToComponent = false;
-        iIsEOSReceivedFromComponent = false;
-
-
-        //Flush is complete.  Go to initialized state.
-        SetState(EPVMFNodePrepared);
-        //resume port input so the ports can be re-started.
-        iInPort->ResumeInput();
-        iOutPort->ResumeInput();
-        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::Run() Out"));
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will dispatch recived commands
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::ProcessCommand(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    //normally this node will not start processing one command
-    //until the prior one is finished.  However, a hi priority
-    //command such as Cancel must be able to interrupt a command
-    //in progress.
-    if (!iCurrentCommand.empty() && !aCmd.hipri())
-        return false;
-
-
-    switch (aCmd.iCmd)
-    {
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_CANCELCMD:
-            DoCancelCommand(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_CANCELALL:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_GETNODEMETADATAKEY:
-        {
-            PVMFStatus retval = DoGetNodeMetadataKey(aCmd);
-            CommandComplete(iInputCommands, aCmd, retval);
-        }
-        break;
-
-        case PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_GETNODEMETADATAVALUE:
-        {
-            PVMFStatus retval = DoGetNodeMetadataValue(aCmd);
-            CommandComplete(iInputCommands, aCmd, retval);
-        }
-        break;
-
-        default://unknown command type
-            CommandComplete(iInputCommands, aCmd, PVMFFailure);
-            break;
-    }
-
-    return true;
+    OSCL_TRY(err, iPrivateDataFsiFragmentAlloc.size(PVOMXAUDIODEC_MEDIADATA_POOLNUM, sizeof(OsclAny *)));
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -1059,18 +184,18 @@
 
     PVMFStatus status = PVMFFailure;
 #ifdef SIMULATE_DROP_MSGS
-    if ((((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed % 300 == 299))  // && (((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed < 30) )
+    if ((((PVMFOMXDecPort*)aPort)->iNumFramesConsumed % 300 == 299))  // && (((PVMFOMXDecPort*)aPort)->iNumFramesConsumed < 30) )
     {
 
         // just dequeue
         PVMFSharedMediaMsgPtr msg;
 
         status = aPort->DequeueIncomingMsg(msg);
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
         status = aPort->DequeueIncomingMsg(msg);
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
         status = aPort->DequeueIncomingMsg(msg);
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
 
 #ifdef _DEBUG
         printf("PVMFOMXAudioDecNode::ProcessIncomingMsg() SIMULATED DROP 3 MSGS\n");
@@ -1082,7 +207,7 @@
 
 #ifdef SIMULATE_BOS
 
-    if ((((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed == 6))
+    if ((((PVMFOMXDecPort*)aPort)->iNumFramesConsumed == 6))
     {
 
         PVMFSharedMediaCmdPtr BOSCmdPtr = PVMFMediaCmd::createMediaCmd();
@@ -1106,13 +231,14 @@
 #ifdef _DEBUG
         printf("PVMFOMXAudioDecNode::ProcessIncomingMsg() SIMULATED BOS\n");
 #endif
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
         return true;
 
     }
 #endif
+
 #ifdef SIMULATE_PREMATURE_EOS
-    if (((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed == 5)
+    if (((PVMFOMXDecPort*)aPort)->iNumFramesConsumed == 5)
     {
         PVMFSharedMediaCmdPtr EOSCmdPtr = PVMFMediaCmd::createMediaCmd();
 
@@ -1126,7 +252,7 @@
         PVMFSharedMediaMsgPtr mediaMsgOut;
         convertToPVMFMediaCmdMsg(mediaMsgOut, EOSCmdPtr);
 
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
 
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                         (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg: SIMULATED EOS"));
@@ -1162,9 +288,30 @@
         iBOSTimestamp = msg->getTimestamp();
         iSendBOS = true;
 
+        // if new BOS arrives, and
+        //if we're in the middle of a partial frame assembly
+        // abandon it and start fresh
+        if (iObtainNewInputBuffer == false)
+        {
+            if (iInputBufferUnderConstruction != NULL)
+            {
+                if (iInBufMemoryPool != NULL)
+                {
+                    iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
+                }
+                iInputBufferUnderConstruction = NULL;
+            }
+            iObtainNewInputBuffer = true;
+
+        }
+
+        // needed to init the sequence numbers and timestamp for partial frame assembly
+        iFirstDataMsgAfterBOS = true;
+        iKeepDroppingMsgsUntilMarkerBit = false;
+
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                         (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg: Received BOS stream %d, timestamp %d", iStreamID, iBOSTimestamp));
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
         return true;
     }
     else if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
@@ -1177,7 +324,7 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                         (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg: Received EOS"));
 
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
         return true; // do not do conversion into media data, just set the flag and leave
     }
 
@@ -1185,7 +332,7 @@
     ///////////////////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////
     // For LATM data, need to convert to raw bitstream
-    if (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_LATM)
+    if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM)
     {
         // Keep looping and parsing LATM data until frame complete or data queue runs out
         uint8 retval; //=FRAME_INCOMPLETE;
@@ -1239,7 +386,7 @@
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                                 (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg: Received EOS"));
 
-                ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+                ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
                 return true; // do not do conversion into media data, just set the flag and leave
 
             }
@@ -1248,7 +395,7 @@
             convertToPVMFMediaData(mediaData, msg);
 
 
-            ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+            ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
 
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iDataPathLogger, PVLOGMSG_INFO,
                             (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg: TS=%d, SEQNUM= %d", msg->getTimestamp(), msg->getSeqNum()));
@@ -1328,723 +475,286 @@
                         (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg: TS=%d, SEQNUM= %d", msg->getTimestamp(), msg->getSeqNum()));
 
         convertToPVMFMediaData(iDataIn, msg);
-        ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed++;
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
     }
 
     iCurrFragNum = 0; // for new message, reset the fragment counter
     iIsNewDataFragment = true;
 
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg() Received %d frames", ((PVMFOMXAudioDecPort*)aPort)->iNumFramesConsumed));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ProcessIncomingMsg() Received %d frames", ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed));
 
     //return true if we processed an activity...
     return true;
 }
 
 /////////////////////////////////////////////////////////////////////////////
-// This routine will process outgoing message by sending it into output the port
+// This routine will handle the PortReEnable state
 /////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::ProcessOutgoingMsg(PVMFPortInterface* aPort)
+PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable()
 {
-    //Called by the AO to process one message off the outgoing
-    //message queue for the given port.  This routine will
-    //try to send the data to the connected port.
+    // set the port index so that we get parameters for the proper port
+    iParamPort.nPortIndex = iPortIndexForDynamicReconfig;
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "0x%x PVMFOMXAudioDecNode::ProcessOutgoingMsg: aPort=0x%x", this, aPort));
+    CONFIG_SIZE_AND_VERSION(iParamPort);
 
-    PVMFStatus status = aPort->Send();
-    if (status == PVMFErrBusy)
+    // get new parameters of the port
+    OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+    // send command for port re-enabling (for this to happen, we must first recreate the buffers)
+    OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);
+
+
+    // get also input info (for frame duration if necessary)
+    OMX_ERRORTYPE Err;
+    OMX_PTR CodecProfilePtr;
+    OMX_INDEXTYPE CodecProfileIndx;
+    OMX_AUDIO_PARAM_AACPROFILETYPE Audio_Aac_Param;
+
+    // determine the proper index and structure (based on codec type)
+    if (iInPort)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "0x%x PVMFOMXAudioDecNode::ProcessOutgoingMsg: Connected port goes into busy state", this));
-    }
-
-    //Report any unexpected failure in port processing...
-    //(the InvalidState error happens when port input is suspended,
-    //so don't report it.)
-    if (status != PVMFErrBusy
-            && status != PVMFSuccess
-            && status != PVMFErrInvalidState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "0x%x PVMFOMXAudioDecNode::Run: Error - ProcessPortActivity failed. port=0x%x, type=%d",
-                         this, iOutPort, PVMF_PORT_ACTIVITY_OUTGOING_MSG));
-        ReportErrorEvent(PVMFErrPortProcessing);
-    }
-
-    //return true if we processed an activity...
-    return (status != PVMFErrBusy);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will process received data usign State Machine
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::HandleProcessingState()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::HandleProcessingState() In"));
-
-    PVMFStatus status = PVMFSuccess;
-
-    switch (iProcessingState)
-    {
-        case EPVMFOMXAudioDecNodeProcessingState_InitDecoder:
+        // AAC
+        if (((PVMFOMXDecPort*)iInPort)->iFormat ==  PVMF_MIME_MPEG4_AUDIO ||
+                ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM ||
+                ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ADIF ||
+                ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ASF_MPEG4_AUDIO ||
+                ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AAC_SIZEHDR) // for testing
         {
-            // do init only if input data is available
-            if (iDataIn.GetRep() != NULL)
+            CodecProfilePtr = (OMX_PTR) & Audio_Aac_Param;
+            CodecProfileIndx = OMX_IndexParamAudioAac;
+            Audio_Aac_Param.nPortIndex = iInputPortIndex;
+
+            CONFIG_SIZE_AND_VERSION(Audio_Aac_Param);
+
+
+            // get parameters:
+            Err = OMX_GetParameter(iOMXDecoder, CodecProfileIndx, CodecProfilePtr);
+            if (Err != OMX_ErrorNone)
             {
-                if (!InitDecoder(iDataIn))
-                {
-                    // Decoder initialization failed. Fatal error
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Decoder initialization failed"));
-                    ReportErrorEvent(PVMFErrResourceConfiguration);
-                    ChangeNodeState(EPVMFNodeError);
-                    break;
-                }
-
-                iProcessingState = EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode;
-                // spin once to send output buffers
-                RunIfNotReady();
-                status = PVMFSuccess; // allow rescheduling
-            }
-            break;
-        }
-
-        case EPVMFOMXAudioDecNodeProcessingState_WaitForInitCompletion:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() WaitForInitCompletion -> wait for config buffer to return"));
-
-
-            status = PVMFErrNoMemory; // prevent rescheduling
-            break;
-        }
-        // The FOLLOWING 4 states handle Dynamic Port Reconfiguration
-        case EPVMFOMXAudioDecNodeProcessingState_PortReconfig:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Sending Port Disable Command"));
-
-            // Collect all buffers first (before starting the portDisable command)
-            // FIRST send a flush command. This will return all buffers from the component. Any outstanding buffers are in MIO
-            // Then wait for all buffers to come back from MIO. If we haven't sent port disable, we'll be able to process
-            // other commands in the copmponent (such as pause, stop etc.)
-            OMX_ERRORTYPE err = OMX_ErrorNone;
-            OMX_STATETYPE sState;
-
-            // first check the state (if executing or paused, continue)
-            err = OMX_GetState(iOMXAudioDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState (): PortReconfig Can't get State of decoder - trying to send port flush request!"));
+                                (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Input port parameters problem"));
 
-                sState = OMX_StateInvalid;
-                ReportErrorEvent(PVMFErrResourceConfiguration);
-                ChangeNodeState(EPVMFNodeError);
-                status = PVMFFailure;
-                break;
+                SetState(EPVMFNodeError);
+                ReportErrorEvent(PVMFErrResource);
+                return PVMFErrResource;
             }
-
-            if ((sState != OMX_StateExecuting) && (sState != OMX_StatePause))
-            {
-                // possibly as a consequence of a previously queued cmd to go to Idle state?
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState (): PortReconfig: Component State is not executing or paused, do not proceed with port flush"));
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState (): PortReconfig Sending Flush command to component"));
-
-                // the port will now start returning outstanding buffers
-                // set the flag to prevent output from going downstream (in case of output port being reconfigured)
-                // set the flag to prevent input from being saved and returned to component (in case of input port being reconfigured)
-                // set the state to wait for port saying it is disabled
-                if (iPortIndexForDynamicReconfig == iOutputPortIndex)
-                {
-                    iDoNotSendOutputBuffersDownstreamFlag = true;
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Output Port"));
-                }
-                else if (iPortIndexForDynamicReconfig == iInputPortIndex)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Input Port"));
-
-                    iDoNotSaveInputBuffersFlag = true;
-                }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> UNKNOWN PORT"));
-                    sState = OMX_StateInvalid;
-                    ReportErrorEvent(PVMFErrResourceConfiguration);
-                    ChangeNodeState(EPVMFNodeError);
-                    status = PVMFFailure;
-                    break;
-                }
-
-                // send command to flush appropriate port
-                err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandFlush, iPortIndexForDynamicReconfig, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState (): PortReconfig : Can't send flush command !"));
-
-                    sState = OMX_StateInvalid;
-                    ReportErrorEvent(PVMFErrResourceConfiguration);
-                    ChangeNodeState(EPVMFNodeError);
-                    status = PVMFFailure;
-                    break;
-                }
-            }
-            // now sit back and wait for buffers to return
-            // if there is a pause/stop cmd in the meanwhile, component will process it
-            // and the node will end up in pause/stop state (so this internal state does not matter)
-            iProcessingState = EPVMFOMXAudioDecNodeProcessingState_WaitForBufferReturn;
-            // fall through to the next case to check if all buffers are already back
         }
-
-        case EPVMFOMXAudioDecNodeProcessingState_WaitForBufferReturn:
-        {
-            // as buffers are coming back, Run may be called, wait until all buffers are back, then Free them all
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn "));
-            // check if it's output port being reconfigured
-            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn Output "));
-
-                // if all buffers have returned, free them
-                if (iNumOutstandingOutputBuffers == 0)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> all output buffers are back, send port disable command"));
-
-                    // port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
-                    OMX_SendCommand(iOMXAudioDecoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> all output buffers are back, free them"));
-                    if (false == iOutputBuffersFreed)
-                    {
-                        if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
-                                                      iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                      iNumOutputBuffers, // number of buffers
-                                                      iOutputPortIndex, // port idx
-                                                      false // this is not input
-                                                     ))
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot free output buffers "));
-
-                            SetState(EPVMFNodeError);
-                            ReportErrorEvent(PVMFErrNoMemory);
-                            return PVMFErrNoMemory;
-                        }
-                    }
-                    // if the callback (that port is disabled) has not arrived yet, wait for it
-                    // if it has arrived, it will set the state to PortReEnable
-                    if (iProcessingState != EPVMFOMXAudioDecNodeProcessingState_PortReEnable)
-                        iProcessingState = EPVMFOMXAudioDecNodeProcessingState_WaitForPortDisable;
-
-                    status = PVMFSuccess; // allow rescheduling of the node potentially
-                }
-                else
-                    status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic rescheduling
-                // but each buffer will reschedule the node when it comes in
-            }
-            else if (iPortIndexForDynamicReconfig == iInputPortIndex)
-            { // this is input port
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn Input"));
-
-
-                // if all buffers have returned, free them
-                if (iNumOutstandingInputBuffers == 0)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> all input buffers are back, send port disable command"));
-
-                    // port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
-                    OMX_SendCommand(iOMXAudioDecoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> all input buffers are back, free them"));
-
-
-                    if (false == iInputBuffersFreed)
-                    {
-                        if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
-                                                      iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                      iNumInputBuffers, // number of buffers
-                                                      iInputPortIndex, // port idx
-                                                      true // this is input
-                                                     ))
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot free input buffers "));
-
-                            SetState(EPVMFNodeError);
-                            ReportErrorEvent(PVMFErrNoMemory);
-                            return PVMFErrNoMemory;
-
-                        }
-                    }
-                    // if the callback (that port is disabled) has not arrived yet, wait for it
-                    // if it has arrived, it will set the state to PortReEnable
-                    if (iProcessingState != EPVMFOMXAudioDecNodeProcessingState_PortReEnable)
-                        iProcessingState = EPVMFOMXAudioDecNodeProcessingState_WaitForPortDisable;
-
-                    status = PVMFSuccess; // allow rescheduling of the node
-                }
-                else
-                    status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic
-                // rescheduling. Each buffer will reschedule the node
-                // when it comes in
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState() WaitForBufferReturn -> UNKNOWN PORT"));
-            }
-
-            // the state will be changed to PortReEnable once we get confirmation that Port was actually disabled
-            break;
-        }
-
-        case EPVMFOMXAudioDecNodeProcessingState_WaitForPortDisable:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> wait for port disable callback"));
-            // do nothing. Just wait for the port to become disabled (we'll get event from component, which will
-            // transition the state to PortReEnable
-            status = PVMFErrNoMemory; // prevent Rescheduling the node
-            break;
-        }
-
-        case EPVMFOMXAudioDecNodeProcessingState_PortReEnable:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Sending reenable port command"));
-            // set the port index so that we get parameters for the proper port
-            iParamPort.nPortIndex = iPortIndexForDynamicReconfig;
-            // iParamPort.nVersion = OMX_VERSION;
-
-            // get new parameters of the port
-            OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
-
-            // send command for port re-enabling (for this to happen, we must first recreate the buffers)
-            OMX_SendCommand(iOMXAudioDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);
-
-
-            // get also input info (for frame duration if necessary)
-            OMX_ERRORTYPE Err;
-            OMX_PTR CodecProfilePtr;
-            OMX_INDEXTYPE CodecProfileIndx;
-            OMX_AUDIO_PARAM_AACPROFILETYPE Audio_Aac_Param;
-
-            // determine the proper index and structure (based on codec type)
-            if (iInPort)
-            {
-                switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
-                {
-                        // AAC
-                    case PVMF_MPEG4_AUDIO:
-                    case PVMF_LATM:
-                    case PVMF_ADIF:
-                    case PVMF_ASF_MPEG4_AUDIO:
-                    case PVMF_AAC_SIZEHDR: // for testing
-                        CodecProfilePtr = (OMX_PTR) & Audio_Aac_Param;
-                        CodecProfileIndx = OMX_IndexParamAudioAac;
-                        Audio_Aac_Param.nPortIndex = iInputPortIndex;
-                        Audio_Aac_Param.nSize = sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE);
-                        Audio_Aac_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-                        Audio_Aac_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-                        Audio_Aac_Param.nVersion.s.nRevision = SPECREVISION;
-                        Audio_Aac_Param.nVersion.s.nStep = SPECSTEP;
-
-                        // get parameters:
-                        Err = OMX_GetParameter(iOMXAudioDecoder, CodecProfileIndx, CodecProfilePtr);
-                        if (Err != OMX_ErrorNone)
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Input port parameters problem"));
-
-                            SetState(EPVMFNodeError);
-                            ReportErrorEvent(PVMFErrResource);
-                            return PVMFErrResource;
-                        }
-
-                        break;
-
-                    default:
-                        break;
-                }
-            }
-
-
-
-
-            switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
-            {
-                case PVMF_MPEG4_AUDIO:
-                case PVMF_LATM:
-                case PVMF_ADIF:
-                case PVMF_ASF_MPEG4_AUDIO:
-                case PVMF_AAC_SIZEHDR: // for testing
-                    iSamplesPerFrame = Audio_Aac_Param.nFrameLength;
-                    break;
-
-                    // AMR
-                case PVMF_AMR_IF2:
-                case PVMF_AMR_IETF:
-                case PVMF_AMR_IETF_COMBINED:
-                    // AMR NB has fs=8khz Mono and the frame is 20ms long, i.e. there is 160 samples per frame
-                    iSamplesPerFrame = PVOMXAUDIODEC_AMRNB_SAMPLES_PER_FRAME;
-                    break;
-
-                case PVMF_AMRWB_IETF:
-                case PVMF_AMRWB_IETF_PAYLOAD:
-                    // AMR WB has fs=16khz Mono and the frame is 20ms long, i.e. there is 320 samples per frame
-                    iSamplesPerFrame = PVOMXAUDIODEC_AMRWB_SAMPLES_PER_FRAME;
-                    break;
-
-                case PVMF_MP3:
-                    // frame size is either 576 or 1152 samples per frame. However, this information cannot be
-                    // obtained through OMX MP3 Params. Assume that it's 1152
-                    iSamplesPerFrame = PVOMXAUDIODEC_MP3_DEFAULT_SAMPLES_PER_FRAME;
-                    break;
-
-                case PVMF_WMA:
-                    // output frame size is unknown in WMA. However, the PV-WMA decoder can control the number
-                    // of samples it places in an output buffer, so we can create an output buffer of arbitrary size
-                    // and let the decoder control how it is filled
-                    iSamplesPerFrame = 0; // unknown
-                    break;
-
-                default:
-                    break;
-            }
-
-            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
-            {
-
-                // GET the output buffer params and sizes
-                OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
-                Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
-                Audio_Pcm_Param.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
-                Audio_Pcm_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-                Audio_Pcm_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-                Audio_Pcm_Param.nVersion.s.nRevision = SPECREVISION;
-                Audio_Pcm_Param.nVersion.s.nStep = SPECSTEP;
-
-
-                Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
-                if (Err != OMX_ErrorNone)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot get component output parameters"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrResource);
-                    return PVMFErrResource;
-                }
-
-                iPCMSamplingRate = Audio_Pcm_Param.nSamplingRate; // can be set to 0 (if unknown)
-
-                if (iPCMSamplingRate == 0) // use default sampling rate (i.e. 48000)
-                    iPCMSamplingRate = PVOMXAUDIODEC_DEFAULT_SAMPLINGRATE;
-
-                iNumberOfAudioChannels = Audio_Pcm_Param.nChannels;		// should be 1 or 2
-                if (iNumberOfAudioChannels != 1 && iNumberOfAudioChannels != 2)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Output parameters num channels = %d", iNumberOfAudioChannels));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrResource);
-                    return PVMFErrResource;
-                }
-
-                if (iSamplesPerFrame != 0) // if this value is known
-                {
-                    // CALCULATE NumBytes per frame, Msec per frame, etc.
-                    iNumBytesPerFrame = 2 * iSamplesPerFrame * iNumberOfAudioChannels;
-                    iMilliSecPerFrame = (iSamplesPerFrame * 1000) / iPCMSamplingRate;
-                    // Determine the size of each PCM output buffer. Size would be big enough to hold certain time amount of PCM data
-                    uint32 numframes = PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME / iMilliSecPerFrame;
-
-                    if (PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME % iMilliSecPerFrame)
-                    {
-                        // If there is a remainder, include one more frame
-                        ++numframes;
-                    }
-
-                    // set the output buffer size accordingly:
-                    iOMXComponentOutputBufferSize = numframes * iNumBytesPerFrame;
-                }
-                else
-                    iOMXComponentOutputBufferSize = (iPCMSamplingRate * 1000) / (PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME);
-
-                // do we need to increase the number of buffers?
-                if (iNumOutputBuffers < iParamPort.nBufferCountMin)
-                    iNumOutputBuffers = iParamPort.nBufferCountMin;
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState() new output buffers %d, size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
-
-                /* Allocate output buffers */
-                if (!CreateOutMemPool(iNumOutputBuffers))
-                {
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot allocate output buffers "));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-                }
-
-                if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
-                                               iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                               iNumOutputBuffers, // number of buffers
-                                               iOMXComponentOutputBufferSize, // actual buffer size
-                                               iOutputPortIndex, // port idx
-                                               iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
-                                               false // this is not input
-                                              ))
-                {
-
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot provide output buffers to component"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-
-                }
-
-                // do not drop output any more, i.e. enable output to be sent downstream
-                iDoNotSendOutputBuffersDownstreamFlag = false;
-
-
-            }
-            else
-            {
-                // this is input port
-
-                iOMXComponentInputBufferSize = iParamPort.nBufferSize;
-                // do we need to increase the number of buffers?
-                if (iNumInputBuffers < iParamPort.nBufferCountMin)
-                    iNumInputBuffers = iParamPort.nBufferCountMin;
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState() new buffers %d, size %d", iNumInputBuffers, iOMXComponentInputBufferSize));
-
-                /* Allocate input buffers */
-                if (!CreateInputMemPool(iNumInputBuffers))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot allocate new input buffers to component"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-                }
-
-                if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
-                                               iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                               iNumInputBuffers, // number of buffers
-                                               iOMXComponentInputBufferSize, // actual buffer size
-                                               iInputPortIndex, // port idx
-                                               iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
-                                               true // this is input
-                                              ))
-                {
-
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> Cannot provide new input buffers to component"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-
-                }
-                // do not drop partially consumed input
-                iDoNotSaveInputBuffersFlag = false;
-
-            }
-
-            // if the callback that the port was re-enabled has not arrived yet, wait for it
-            // if it has arrived, it will set the state to either PortReconfig or to ReadyToDecode
-            if (iProcessingState != EPVMFOMXAudioDecNodeProcessingState_PortReconfig &&
-                    iProcessingState != EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode)
-                iProcessingState = EPVMFOMXAudioDecNodeProcessingState_WaitForPortEnable;
-
-            status = PVMFSuccess; // allow rescheduling of the node
-            break;
-        }
-
-        case EPVMFOMXAudioDecNodeProcessingState_WaitForPortEnable:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Port Reconfiguration -> wait for port enable callback"));
-            // do nothing. Just wait for the port to become enabled (we'll get event from component, which will
-            // transition the state to ReadyToDecode
-            status = PVMFErrNoMemory; // prevent ReScheduling
-            break;
-        }
-
-        // NORMAL DATA FLOW STATE:
-        case EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Ready To Decode start"));
-            // In normal data flow and decoding state
-            // Send all available output buffers to the decoder
-
-            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
-            {
-                // grab buffer header from the mempool if possible, and send to component
-                if (!SendOutputBufferToOMXComponent())
-
-                    break;
-
-            }
-
-
-            // next, see if partially consumed input buffer needs to be resent back to OMX component
-            // NOTE: it is not allowed that the component returns more than 1 partially consumed input buffers
-            //		 i.e. if a partially consumed input buffer is returned, it is assumed that the OMX component
-            //		 will be waiting to get data
-
-            if (iInputBufferToResendToComponent != NULL)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXAudioDecNode::HandleProcessingState() Sending previous - partially consumed input back to the OMX component"));
-
-                OMX_EmptyThisBuffer(iOMXAudioDecoder, iInputBufferToResendToComponent);
-                iInputBufferToResendToComponent = NULL; // do this only once
-            }
-            else if ((iNumOutstandingInputBuffers < iNumInputBuffers) && (iDataIn.GetRep() != NULL))
-            {
-                // try to get an input buffer header
-                // and send the input data over to the component
-                SendInputBufferToOMXComponent();
-            }
-
-            status = PVMFSuccess;
-            break;
-
-
-        }
-        case EPVMFOMXAudioDecNodeProcessingState_Stopping:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Stopping -> wait for Component to move from Executing->Idle"));
-
-
-            status = PVMFErrNoMemory; // prevent rescheduling
-            break;
-        }
-
-        case EPVMFOMXAudioDecNodeProcessingState_Pausing:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleProcessingState() Pausing -> wait for Component to move from Executing->Pause"));
-
-
-            status = PVMFErrNoMemory; // prevent rescheduling
-            break;
-        }
-
-
-        case EPVMFOMXAudioDecNodeProcessingState_WaitForOutgoingQueue:
-            status = PVMFErrNoMemory;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::HandleProcessingState() Do nothing since waiting for output port queue to become available"));
-            break;
-
-        default:
-            break;
+        // for AMR, frame sizes are known, no need to get the parameters
+        // for MP3, frame sizes cannot be obtained through OMX params
+        // for WMA, frame sizes cannot be obtained through OMX params
     }
 
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::HandleProcessingState() Out"));
-
-    return status;
-
-}
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::SendOutputBufferToOMXComponent()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendOutputBufferToOMXComponent() In"));
 
 
-    OutputBufCtrlStruct_Audio *output_buf = NULL;
-    int32 errcode = 0;
-
-    // try to get output buffer header
-    OSCL_TRY(errcode, output_buf = (OutputBufCtrlStruct_Audio *) iOutBufMemoryPool->allocate(iOutputAllocSize));
-    if (errcode != 0)
+    PVMFFormatType Format = PVMF_MIME_FORMAT_UNKNOWN;
+    if (iInPort != NULL)
     {
-        if (errcode == OsclErrNoResources)
+        Format = ((PVMFOMXDecPort*)iInPort)->iFormat;
+    }
+    if (Format ==  PVMF_MIME_MPEG4_AUDIO ||
+            Format == PVMF_MIME_LATM ||
+            Format == PVMF_MIME_ADIF ||
+            Format == PVMF_MIME_ASF_MPEG4_AUDIO ||
+            Format == PVMF_MIME_AAC_SIZEHDR) // for testing
+    {
+        iSamplesPerFrame = Audio_Aac_Param.nFrameLength;
+    }
+    // AMR
+    else if (Format == PVMF_MIME_AMR_IF2 ||
+             Format == PVMF_MIME_AMR_IETF ||
+             Format == PVMF_MIME_AMR)
+    {
+        // AMR NB has fs=8khz Mono and the frame is 20ms long, i.e. there is 160 samples per frame
+        iSamplesPerFrame = PVOMXAUDIODEC_AMRNB_SAMPLES_PER_FRAME;
+    }
+    else if (Format == PVMF_MIME_AMRWB_IETF ||
+             Format == PVMF_MIME_AMRWB)
+    {
+        // AMR WB has fs=16khz Mono and the frame is 20ms long, i.e. there is 320 samples per frame
+        iSamplesPerFrame = PVOMXAUDIODEC_AMRWB_SAMPLES_PER_FRAME;
+    }
+    else if (Format == PVMF_MIME_MP3)
+    {
+        // frame size is either 576 or 1152 samples per frame. However, this information cannot be
+        // obtained through OMX MP3 Params. Assume that it's 1152
+        iSamplesPerFrame = PVOMXAUDIODEC_MP3_DEFAULT_SAMPLES_PER_FRAME;
+    }
+    else if (Format == PVMF_MIME_WMA)
+    {
+        // output frame size is unknown in WMA. However, the PV-WMA decoder can control the number
+        // of samples it places in an output buffer, so we can create an output buffer of arbitrary size
+        // and let the decoder control how it is filled
+        iSamplesPerFrame = 0; // unknown
+    }
+
+    // is this output port?
+    if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+    {
+
+        // GET the output buffer params and sizes
+        OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
+        Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
+
+        CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
+
+
+
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+        if (Err != OMX_ErrorNone)
         {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot get component output parameters"));
 
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                            PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::SendOutputBufferToOMXComponent() No more output buffers in the mempool"));
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrResource);
+            return PVMFErrResource;
+        }
 
-            iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *) iOutBufMemoryPool); // To signal when next deallocate() is called on mempool
+        iPCMSamplingRate = Audio_Pcm_Param.nSamplingRate; // can be set to 0 (if unknown)
 
-            return false;
+        if (iPCMSamplingRate == 0) // use default sampling rate (i.e. 48000)
+            iPCMSamplingRate = PVOMXAUDIODEC_DEFAULT_SAMPLINGRATE;
+
+        iNumberOfAudioChannels = Audio_Pcm_Param.nChannels;		// should be 1 or 2
+        if (iNumberOfAudioChannels != 1 && iNumberOfAudioChannels != 2)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Output parameters num channels = %d", iNumberOfAudioChannels));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrResource);
+            return PVMFErrResource;
+        }
+
+        if ((iSamplesPerFrame != 0) && ((iSamplesPerFrame * 1000) > iPCMSamplingRate))
+            // if this iSamplesPerFrame is known and is large enough to ensure that the iMilliSecPerFrame calculation
+            // below won't be set to 0.
+        {
+            // CALCULATE NumBytes per frame, Msec per frame, etc.
+            iNumBytesPerFrame = 2 * iSamplesPerFrame * iNumberOfAudioChannels;
+            iMilliSecPerFrame = (iSamplesPerFrame * 1000) / iPCMSamplingRate;
+            // Determine the size of each PCM output buffer. Size would be big enough to hold certain time amount of PCM data
+            uint32 numframes = PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME / iMilliSecPerFrame;
+
+            if (PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME % iMilliSecPerFrame)
+            {
+                // If there is a remainder, include one more frame
+                ++numframes;
+            }
+
+            // set the output buffer size accordingly:
+            iOMXComponentOutputBufferSize = numframes * iNumBytesPerFrame;
         }
         else
-        {
-            // Memory allocation for the pool failed
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::SendOutputBufferToOMXComponent() Output mempool error"));
+            iOMXComponentOutputBufferSize = (2 * iNumberOfAudioChannels * PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME * iPCMSamplingRate) / 1000; // assuming 16 bits per sample
 
+        if (iOMXComponentOutputBufferSize < iParamPort.nBufferSize)
+        {
+            // the OMX spec says that nBuffersize is a read only field, but the client is allowed to allocate
+            // a buffer size larger than nBufferSize.
+            iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
+        }
+
+
+        // do we need to increase the number of buffers?
+        if (iNumOutputBuffers < iParamPort.nBufferCountMin)
+            iNumOutputBuffers = iParamPort.nBufferCountMin;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::HandlePortReEnable() new output buffers %d, size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
+
+        /* Allocate output buffers */
+        if (!CreateOutMemPool(iNumOutputBuffers))
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot allocate output buffers "));
 
             SetState(EPVMFNodeError);
             ReportErrorEvent(PVMFErrNoMemory);
-            return false;
+            return PVMFErrNoMemory;
         }
 
+        if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
+                                       iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                       iNumOutputBuffers, // number of buffers
+                                       iOMXComponentOutputBufferSize, // actual buffer size
+                                       iOutputPortIndex, // port idx
+                                       iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
+                                       false // this is not input
+                                      ))
+        {
+
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot provide output buffers to component"));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return PVMFErrNoMemory;
+
+        }
+
+        // do not drop output any more, i.e. enable output to be sent downstream
+        iDoNotSendOutputBuffersDownstreamFlag = false;
+
+
+    }
+    else
+    {
+        // this is input port
+
+        iOMXComponentInputBufferSize = iParamPort.nBufferSize;
+        // do we need to increase the number of buffers?
+        if (iNumInputBuffers < iParamPort.nBufferCountMin)
+            iNumInputBuffers = iParamPort.nBufferCountMin;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::HandlePortReEnable() new buffers %d, size %d", iNumInputBuffers, iOMXComponentInputBufferSize));
+
+        /* Allocate input buffers */
+        if (!CreateInputMemPool(iNumInputBuffers))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot allocate new input buffers to component"));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return PVMFErrNoMemory;
+        }
+
+        if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
+                                       iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                       iNumInputBuffers, // number of buffers
+                                       iOMXComponentInputBufferSize, // actual buffer size
+                                       iInputPortIndex, // port idx
+                                       iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
+                                       true // this is input
+                                      ))
+        {
+
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot provide new input buffers to component"));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return PVMFErrNoMemory;
+
+        }
+        // do not drop partially consumed input
+        iDoNotSaveInputBuffersFlag = false;
+
     }
 
-    //for every allocated buffer, make sure you notify when buffer is released. Keep track of allocated buffers
-    // use mempool as context to recognize which buffer (input or output) was returned
-    iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *)iOutBufMemoryPool);
-    iNumOutstandingOutputBuffers++;
+    // if the callback that the port was re-enabled has not arrived yet, wait for it
+    // if it has arrived, it will set the state to either PortReconfig or to ReadyToDecode
+    if (iProcessingState != EPVMFOMXBaseDecNodeProcessingState_PortReconfig &&
+            iProcessingState != EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_WaitForPortEnable;
 
-    output_buf->pBufHdr->nFilledLen = 0; // make sure you tell OMX component buffer is empty
-    output_buf->pBufHdr->nOffset = 0;
-    output_buf->pBufHdr->pAppPrivate = output_buf; // set pAppPrivate to be pointer to output_buf
-    // (this is context for future release of this buffer to the mempool)
-    // this was done during buffer creation, but still repeat just in case
-    output_buf->pBufHdr->nFlags = 0; //Clear flags
-    OMX_FillThisBuffer(iOMXAudioDecoder, output_buf->pBufHdr);
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendOutputBufferToOMXComponent() Out"));
-
-    return true;
+    return PVMFSuccess; // allow rescheduling of the node
 }
 ////////////////////////////////////////////////////////////////////////////////
 bool PVMFOMXAudioDecNode::NegotiateComponentParameters()
@@ -2058,8 +768,58 @@
     uint32 NumPorts;
     uint32 ii;
 
+
+    pvAudioConfigParserInputs aInputs;
+    pvAudioConfigParserOutputs aOutputs;
+
+    aInputs.inPtr = (uint8*)((PVMFOMXDecPort*)iInPort)->iTrackConfig;
+    aInputs.inBytes = (int32)((PVMFOMXDecPort*)iInPort)->iTrackConfigSize;
+    aInputs.iMimeType = ((PVMFOMXDecPort*)iInPort)->iFormat;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Calling audio config parser - TrackConfig = %p, TrackConfigSize = %d, mimetype = %s", aInputs.inPtr, aInputs.inBytes, aInputs.iMimeType.getMIMEStrPtr()));
+
+
+    if (aInputs.inBytes == 0 || aInputs.inPtr == NULL)
+    {
+        if (aInputs.iMimeType == PVMF_MIME_WMA ||
+                aInputs.iMimeType == PVMF_MIME_MPEG4_AUDIO ||
+                aInputs.iMimeType == PVMF_MIME_LATM ||
+                aInputs.iMimeType == PVMF_MIME_ADIF ||
+                aInputs.iMimeType == PVMF_MIME_ASF_MPEG4_AUDIO ||
+                aInputs.iMimeType == PVMF_MIME_AAC_SIZEHDR)
+        {
+            return false;
+        }
+    }
+
+    int16 status;
+    status = pv_audio_config_parser(&aInputs, &aOutputs);
+    if (status == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() pv_audio_config_parser()-unsupported parameters\n"));
+        return false;
+    }
+
+    if (aInputs.iMimeType == PVMF_MIME_WMA)
+    {
+        iNumberOfAudioChannels = aOutputs.Channels;
+        iPCMSamplingRate = aOutputs.SamplesPerSec;
+    }
+    else if (aInputs.iMimeType == PVMF_MIME_MPEG4_AUDIO ||
+             aInputs.iMimeType == PVMF_MIME_LATM ||
+             aInputs.iMimeType == PVMF_MIME_ADIF ||
+             aInputs.iMimeType == PVMF_MIME_ASF_MPEG4_AUDIO ||
+             aInputs.iMimeType == PVMF_MIME_AAC_SIZEHDR)
+
+    {
+        iNumberOfAudioChannels = aOutputs.Channels;
+    }
+
+    CONFIG_SIZE_AND_VERSION(AudioPortParameters);
     // get starting number
-    Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamAudioInit, &AudioPortParameters);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioInit, &AudioPortParameters);
     NumPorts = AudioPortParameters.nPorts; // must be at least 2 of them (in&out)
 
     if (Err != OMX_ErrorNone || NumPorts < 2)
@@ -2070,7 +830,7 @@
     }
 
 
-    // loop through video ports starting from the starting index to find index of the first input port
+    // loop through ports starting from the starting index to find index of the first input port
     for (ii = AudioPortParameters.nStartPortNumber ;ii < AudioPortParameters.nStartPortNumber + NumPorts; ii++)
     {
         // get port parameters, and determine if it is input or output
@@ -2080,7 +840,10 @@
 
         //port
         iParamPort.nPortIndex = ii;
-        Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+        CONFIG_SIZE_AND_VERSION(iParamPort);
+
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
 
         if (Err != OMX_ErrorNone)
         {
@@ -2107,17 +870,19 @@
     }
 
 
-    // loop through video ports starting from the starting index to find index of the first output port
+    // loop through ports starting from the starting index to find index of the first output port
     for (ii = AudioPortParameters.nStartPortNumber ;ii < AudioPortParameters.nStartPortNumber + NumPorts; ii++)
     {
         // get port parameters, and determine if it is input or output
         // if there are more than 2 ports, the first one we encounter that has output direction is picked
 
-        iParamPort.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
 
         //port
         iParamPort.nPortIndex = ii;
-        Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+        CONFIG_SIZE_AND_VERSION(iParamPort);
+
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
 
         if (Err != OMX_ErrorNone)
         {
@@ -2146,11 +911,12 @@
 
 
     // now get input parameters
-    iParamPort.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
+
+    CONFIG_SIZE_AND_VERSION(iParamPort);
 
     //Input port
     iParamPort.nPortIndex = iInputPortIndex;
-    Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2159,11 +925,13 @@
     }
 
     // preset the number of input buffers
-    iNumInputBuffers = NUMBER_INPUT_BUFFER;
+    //iNumInputBuffers = NUMBER_INPUT_BUFFER;
+    iNumInputBuffers = iParamPort.nBufferCountActual;  // use the value provided by component
 
     // do we need to increase the number of buffers?
     if (iNumInputBuffers < iParamPort.nBufferCountMin)
         iNumInputBuffers = iParamPort.nBufferCountMin;
+
     iOMXComponentInputBufferSize = iParamPort.nBufferSize;
 
     iParamPort.nBufferCountActual = iNumInputBuffers;
@@ -2172,7 +940,15 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Inport buffers %d,size %d", iNumInputBuffers, iOMXComponentInputBufferSize));
 
-    Err = OMX_SetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+    // Codec specific info set/get: SamplingRate, formats etc.
+    if (!GetSetCodecSpecificInfo())
+        return false;
+
+
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+
+    Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2182,15 +958,18 @@
 
 
 
-
     // Codec specific info set/get: SamplingRate, formats etc.
     if (!GetSetCodecSpecificInfo())
         return false;
 
 
+
     //Port 1 for output port
     iParamPort.nPortIndex = iOutputPortIndex;
-    Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2199,7 +978,10 @@
     }
 
     // set number of output buffers and the size
-    iNumOutputBuffers = NUMBER_OUTPUT_BUFFER;
+    iNumOutputBuffers = iParamPort.nBufferCountActual;
+
+    if (iNumOutputBuffers > NUMBER_OUTPUT_BUFFER)
+        iNumOutputBuffers = NUMBER_OUTPUT_BUFFER; // make sure to limit this number to what the port can hold
 
 
     if (iNumOutputBuffers < iParamPort.nBufferCountMin)
@@ -2210,7 +992,9 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Outport buffers %d,size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
 
-    Err = OMX_SetParameter(iOMXAudioDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+
+    Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2218,6 +1002,81 @@
         return false;
     }
 
+    //Set input audio format
+    //This is need it since a single component could handle differents roles
+
+    // Init to desire format
+    PVMFFormatType Format = PVMF_MIME_FORMAT_UNKNOWN;
+    if (iInPort != NULL)
+    {
+        Format = ((PVMFOMXDecPort*)iInPort)->iFormat;
+    }
+    if (Format == PVMF_MIME_MPEG4_AUDIO ||
+            Format == PVMF_MIME_LATM ||
+            Format == PVMF_MIME_ADIF ||
+            Format == PVMF_MIME_ASF_MPEG4_AUDIO ||
+            Format == PVMF_MIME_AAC_SIZEHDR)
+    {
+        iOMXAudioCompressionFormat = OMX_AUDIO_CodingAAC;
+    }
+    else if (Format == PVMF_MIME_AMR_IF2 ||
+             Format == PVMF_MIME_AMR_IETF ||
+             Format == PVMF_MIME_AMR ||
+             Format == PVMF_MIME_AMRWB_IETF ||
+             Format == PVMF_MIME_AMRWB)
+    {
+        iOMXAudioCompressionFormat = OMX_AUDIO_CodingAMR;
+    }
+    else if (Format == PVMF_MIME_MP3)
+    {
+        iOMXAudioCompressionFormat = OMX_AUDIO_CodingMP3;
+    }
+    else if (Format == PVMF_MIME_WMA)
+    {
+        iOMXAudioCompressionFormat = OMX_AUDIO_CodingWMA;
+    }
+    else
+    {
+        // Illegal codec specified.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Problem setting audio compression format"));
+        return false;
+    }
+
+
+    OMX_AUDIO_PARAM_PORTFORMATTYPE AudioPortFormat;
+    CONFIG_SIZE_AND_VERSION(AudioPortFormat);
+    AudioPortFormat.nPortIndex = iInputPortIndex;
+
+    // Search the proper format index and set it.
+    // Since we already know that the component has the role we need, search until finding the proper nIndex
+    // if component does not find the format will return OMX_ErrorNoMore
+
+    for (ii = 0;; ii++)
+    {
+        AudioPortFormat.nIndex = ii;
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioPortFormat, &AudioPortFormat);
+        if (Err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Problem setting audio compression format"));
+            return false;
+        }
+        if (iOMXAudioCompressionFormat == AudioPortFormat.eEncoding)
+        {
+            break;
+        }
+    }
+    // Now set the format to confirm parameters
+    Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamAudioPortFormat, &AudioPortFormat);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Problem setting audio compression format"));
+        return false;
+    }
+
+
     return true;
 }
 
@@ -2226,78 +1085,67 @@
 
     // for AAC, need to let the decoder know about the type of AAC format. Need to get the frame length
     // need to get the parameters
-    OMX_PTR CodecProfilePtr;
-    OMX_INDEXTYPE CodecProfileIndx;
+    OMX_PTR CodecProfilePtr = NULL;
+    OMX_INDEXTYPE CodecProfileIndx = OMX_IndexAudioStartUnused;
     OMX_AUDIO_PARAM_AACPROFILETYPE Audio_Aac_Param;
     OMX_AUDIO_PARAM_AMRTYPE Audio_Amr_Param;
     OMX_AUDIO_PARAM_MP3TYPE Audio_Mp3_Param;
     OMX_AUDIO_PARAM_WMATYPE Audio_Wma_Param;
     OMX_ERRORTYPE Err = OMX_ErrorNone;
+    PVMFFormatType Format = PVMF_MIME_FORMAT_UNKNOWN;
 
     // determine the proper index and structure (based on codec type)
-    switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
+
+    if (iInPort != NULL)
     {
+        Format = ((PVMFOMXDecPort*)iInPort)->iFormat;
+    }
+    if (Format ==  PVMF_MIME_MPEG4_AUDIO ||
+            Format == PVMF_MIME_LATM ||
+            Format == PVMF_MIME_ADIF ||
+            Format == PVMF_MIME_ASF_MPEG4_AUDIO ||
+            Format == PVMF_MIME_AAC_SIZEHDR) // for testing
+    {
+        // AAC
 
-            // AAC
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_LATM:
-        case PVMF_ADIF:
-        case PVMF_ASF_MPEG4_AUDIO:
-        case PVMF_AAC_SIZEHDR: // for testing
-            CodecProfilePtr = (OMX_PTR) & Audio_Aac_Param;
-            CodecProfileIndx = OMX_IndexParamAudioAac;
-            Audio_Aac_Param.nPortIndex = iInputPortIndex;
-            Audio_Aac_Param.nSize = sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE);
-            Audio_Aac_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-            Audio_Aac_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-            Audio_Aac_Param.nVersion.s.nRevision = SPECREVISION;
-            Audio_Aac_Param.nVersion.s.nStep = SPECSTEP;
-            break;
+        CodecProfilePtr = (OMX_PTR) & Audio_Aac_Param;
+        CodecProfileIndx = OMX_IndexParamAudioAac;
+        Audio_Aac_Param.nPortIndex = iInputPortIndex;
 
-            // AMR
-        case PVMF_AMR_IF2:
-        case PVMF_AMR_IETF:
-        case PVMF_AMR_IETF_COMBINED:
-        case PVMF_AMRWB_IETF:
-        case PVMF_AMRWB_IETF_PAYLOAD:
-            CodecProfilePtr = (OMX_PTR) & Audio_Amr_Param;
-            CodecProfileIndx = OMX_IndexParamAudioAmr;
-            Audio_Amr_Param.nPortIndex = iInputPortIndex;
-            Audio_Amr_Param.nSize = sizeof(OMX_AUDIO_PARAM_AMRTYPE);
-            Audio_Amr_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-            Audio_Amr_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-            Audio_Amr_Param.nVersion.s.nRevision = SPECREVISION;
-            Audio_Amr_Param.nVersion.s.nStep = SPECSTEP;
-            break;
-            // MP3
-        case PVMF_MP3:
-            CodecProfilePtr = (OMX_PTR) & Audio_Mp3_Param;
-            CodecProfileIndx = OMX_IndexParamAudioMp3;
-            Audio_Mp3_Param.nPortIndex = iInputPortIndex;
-            Audio_Mp3_Param.nSize = sizeof(OMX_AUDIO_PARAM_MP3TYPE);
-            Audio_Mp3_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-            Audio_Mp3_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-            Audio_Mp3_Param.nVersion.s.nRevision = SPECREVISION;
-            Audio_Mp3_Param.nVersion.s.nStep = SPECSTEP;
-            break;
-            //WMA
-        case PVMF_WMA:
-            CodecProfilePtr = (OMX_PTR) & Audio_Wma_Param;
-            CodecProfileIndx = OMX_IndexParamAudioWma;
-            Audio_Wma_Param.nPortIndex = iInputPortIndex;
-            Audio_Wma_Param.nSize = sizeof(OMX_AUDIO_PARAM_WMATYPE);
-            Audio_Wma_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-            Audio_Wma_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-            Audio_Wma_Param.nVersion.s.nRevision = SPECREVISION;
-            Audio_Wma_Param.nVersion.s.nStep = SPECSTEP;
-            break;
+        CONFIG_SIZE_AND_VERSION(Audio_Aac_Param);
+    }
+    // AMR
+    else if (Format ==  PVMF_MIME_AMR_IF2 ||
+             Format == PVMF_MIME_AMR_IETF ||
+             Format == PVMF_MIME_AMR ||
+             Format == PVMF_MIME_AMRWB_IETF ||
+             Format == PVMF_MIME_AMRWB)
+    {
+        CodecProfilePtr = (OMX_PTR) & Audio_Amr_Param;
+        CodecProfileIndx = OMX_IndexParamAudioAmr;
+        Audio_Amr_Param.nPortIndex = iInputPortIndex;
 
-        default:
-            break;
+        CONFIG_SIZE_AND_VERSION(Audio_Amr_Param);
+    }
+    else if (Format == PVMF_MIME_MP3)
+    {
+        CodecProfilePtr = (OMX_PTR) & Audio_Mp3_Param;
+        CodecProfileIndx = OMX_IndexParamAudioMp3;
+        Audio_Mp3_Param.nPortIndex = iInputPortIndex;
+
+        CONFIG_SIZE_AND_VERSION(Audio_Mp3_Param);
+    }
+    else if (Format == PVMF_MIME_WMA)
+    {
+        CodecProfilePtr = (OMX_PTR) & Audio_Wma_Param;
+        CodecProfileIndx = OMX_IndexParamAudioWma;
+        Audio_Wma_Param.nPortIndex = iInputPortIndex;
+
+        CONFIG_SIZE_AND_VERSION(Audio_Wma_Param);
     }
 
     // first get parameters:
-    Err = OMX_GetParameter(iOMXAudioDecoder, CodecProfileIndx, CodecProfilePtr);
+    Err = OMX_GetParameter(iOMXDecoder, CodecProfileIndx, CodecProfilePtr);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2305,92 +1153,86 @@
         return false;
     }
     // Set the stream format
-    switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
+
+
+    // AAC FORMATS:
+    if (Format ==  PVMF_MIME_MPEG4_AUDIO)
     {
-
-            // AAC FORMATS:
-        case PVMF_MPEG4_AUDIO:
-            Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
-            break;
-        case PVMF_LATM:
-            Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4LATM;
-            break;
-        case PVMF_ADIF:
-            Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatADIF;
-
-            break;
-        case PVMF_ASF_MPEG4_AUDIO:
-            Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
-
-            break;
-        case PVMF_AAC_SIZEHDR: // for testing
-            Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
-            break;
-
-
-            // AMR FORMATS
-        case PVMF_AMR_IF2:
-            Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatIF2;
-            Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; // we don't know the bitrate yet, but for init
-            // purposes, we'll set this to any NarrowBand bitrate
-            // to indicate NB vs WB
-
-            break;
-
-            // File format
-            // NB
-        case PVMF_AMR_IETF:
-            Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
-            Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; // we don't know the bitrate yet, but for init
-            // purposes, we'll set this to any NarrowBand bitrate
-            // to indicate NB vs WB
-            break;
-
-            // WB
-        case PVMF_AMRWB_IETF:
-            Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
-            Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0; // we don't know the bitrate yet, but for init
-            // purposes, we'll set this to any WideBand bitrate
-            // to indicate NB vs WB
-
-            break;
-
-            // streaming with Table of Contents
-
-        case PVMF_AMR_IETF_COMBINED:
-            Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatRTPPayload;
-            Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; // we don't know the bitrate yet, but for init
-            // purposes, we'll set this to any WideBand bitrate
-            // to indicate NB vs WB
-
-            break;
-        case PVMF_AMRWB_IETF_PAYLOAD:
-            Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatRTPPayload;
-            Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0; // we don't know the bitrate yet, but for init
-            // purposes, we'll set this to any WideBand bitrate
-            // to indicate NB vs WB
-
-            break;
-
-        case PVMF_MP3:
-            // nothing to do here
-            break;
-
-        case PVMF_WMA:
-            Audio_Wma_Param.eFormat = OMX_AUDIO_WMAFormatUnused; // set this initially
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Unknown format in input port negotiation "));
-            return false;
-
+        Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
+    }
+    else if (Format == PVMF_MIME_LATM)
+    {
+        Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4LATM;
+    }
+    else if (Format == PVMF_MIME_ADIF)
+    {
+        Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatADIF;
+    }
+    else if (Format == PVMF_MIME_ASF_MPEG4_AUDIO)
+    {
+        Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
+    }
+    else if (Format == PVMF_MIME_AAC_SIZEHDR) // for testing
+    {
+        Audio_Aac_Param.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
+    }
+    // AMR FORMATS
+    else if (Format == PVMF_MIME_AMR_IF2)
+    {
+        Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatIF2;
+        Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; // we don't know the bitrate yet, but for init
+        // purposes, we'll set this to any NarrowBand bitrate
+        // to indicate NB vs WB
+    }
+    // File format
+    // NB
+    else if (Format == PVMF_MIME_AMR_IETF)
+    {
+        Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
+        Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; // we don't know the bitrate yet, but for init
+        // purposes, we'll set this to any NarrowBand bitrate
+        // to indicate NB vs WB
+    }
+    // WB
+    else if (Format == PVMF_MIME_AMRWB_IETF)
+    {
+        Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
+        Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0; // we don't know the bitrate yet, but for init
+        // purposes, we'll set this to any WideBand bitrate
+        // to indicate NB vs WB
+    }
+    // streaming with Table of Contents
+    else if (Format == PVMF_MIME_AMR)
+    {
+        Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatRTPPayload;
+        Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeNB0; // we don't know the bitrate yet, but for init
+        // purposes, we'll set this to any WideBand bitrate
+        // to indicate NB vs WB
+    }
+    else if (Format == PVMF_MIME_AMRWB)
+    {
+        Audio_Amr_Param.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatRTPPayload;
+        Audio_Amr_Param.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0; // we don't know the bitrate yet, but for init
+        // purposes, we'll set this to any WideBand bitrate
+        // to indicate NB vs WB
+    }
+    else if (Format == PVMF_MIME_MP3)
+    {
+        // nothing to do here
+    }
+    else if (Format == PVMF_MIME_WMA)
+    {
+        Audio_Wma_Param.eFormat = OMX_AUDIO_WMAFormatUnused; // set this initially
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Unknown format in input port negotiation "));
+        return false;
     }
 
-
-
     // set parameters to inform teh component of the stream type
-    Err = OMX_SetParameter(iOMXAudioDecoder, CodecProfileIndx, CodecProfilePtr);
+    Err = OMX_SetParameter(iOMXDecoder, CodecProfileIndx, CodecProfilePtr);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2400,49 +1242,43 @@
 
 
     // read the output frame size
-
-    switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
+    // AAC
+    if (Format ==  PVMF_MIME_MPEG4_AUDIO ||
+            Format == PVMF_MIME_LATM ||
+            Format == PVMF_MIME_ADIF ||
+            Format == PVMF_MIME_ASF_MPEG4_AUDIO ||
+            Format == PVMF_MIME_AAC_SIZEHDR) // for testing
     {
-            // AAC
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_LATM:
-        case PVMF_ADIF:
-        case PVMF_ASF_MPEG4_AUDIO:
-        case PVMF_AAC_SIZEHDR: // for testing
-            // AAC frame size is 1024 samples or 2048 samples for AAC-HE
-            iSamplesPerFrame = Audio_Aac_Param.nFrameLength;
-            break;
-
-            // AMR
-        case PVMF_AMR_IF2:
-        case PVMF_AMR_IETF:
-        case PVMF_AMR_IETF_COMBINED:
-            // AMR NB has fs=8khz Mono and the frame is 20ms long, i.e. there is 160 samples per frame
-            iSamplesPerFrame = PVOMXAUDIODEC_AMRNB_SAMPLES_PER_FRAME;
-            break;
-
-        case PVMF_AMRWB_IETF:
-        case PVMF_AMRWB_IETF_PAYLOAD:
-            // AMR WB has fs=16khz Mono and the frame is 20ms long, i.e. there is 320 samples per frame
-            iSamplesPerFrame = PVOMXAUDIODEC_AMRWB_SAMPLES_PER_FRAME;
-            break;
-
-        case PVMF_MP3:
-            // frame size is either 576 or 1152 samples per frame. However, this information cannot be
-            // obtained through OMX MP3 Params. Assume that it's 1152
-            iSamplesPerFrame = PVOMXAUDIODEC_MP3_DEFAULT_SAMPLES_PER_FRAME;
-            break;
-        case PVMF_WMA:
-            // output frame size is unknown in WMA. However, the PV-WMA decoder can control the number
-            // of samples it places in an output buffer, so we can create an output buffer of arbitrary size
-            // and let the decoder control how it is filled
-            iSamplesPerFrame = 0; // unknown
-            break;
-
-        default:
-            break;
+        // AAC frame size is 1024 samples or 2048 samples for AAC-HE
+        iSamplesPerFrame = Audio_Aac_Param.nFrameLength;
     }
-
+    // AMR
+    else if (Format == PVMF_MIME_AMR_IF2 ||
+             Format == PVMF_MIME_AMR_IETF ||
+             Format == PVMF_MIME_AMR)
+    {
+        // AMR NB has fs=8khz Mono and the frame is 20ms long, i.e. there is 160 samples per frame
+        iSamplesPerFrame = PVOMXAUDIODEC_AMRNB_SAMPLES_PER_FRAME;
+    }
+    else if (Format == PVMF_MIME_AMRWB_IETF ||
+             Format == PVMF_MIME_AMRWB)
+    {
+        // AMR WB has fs=16khz Mono and the frame is 20ms long, i.e. there is 320 samples per frame
+        iSamplesPerFrame = PVOMXAUDIODEC_AMRWB_SAMPLES_PER_FRAME;
+    }
+    else if (Format == PVMF_MIME_MP3)
+    {
+        // frame size is either 576 or 1152 samples per frame. However, this information cannot be
+        // obtained through OMX MP3 Params. Assume that it's 1152
+        iSamplesPerFrame = PVOMXAUDIODEC_MP3_DEFAULT_SAMPLES_PER_FRAME;
+    }
+    else if (Format == PVMF_MIME_WMA)
+    {
+        // output frame size is unknown in WMA. However, the PV-WMA decoder can control the number
+        // of samples it places in an output buffer, so we can create an output buffer of arbitrary size
+        // and let the decoder control how it is filled
+        iSamplesPerFrame = 0; // unknown
+    }
 
     // iSamplesPerFrame depends on the codec.
     // for AAC: iSamplesPerFrame = 1024
@@ -2455,14 +1291,11 @@
     // GET the output buffer params and sizes
     OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
     Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
-    Audio_Pcm_Param.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
-    Audio_Pcm_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-    Audio_Pcm_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-    Audio_Pcm_Param.nVersion.s.nRevision = SPECREVISION;
-    Audio_Pcm_Param.nVersion.s.nStep = SPECSTEP;
+
+    CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
 
 
-    Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -2482,7 +1315,9 @@
         return false;
 
 
-    if (iSamplesPerFrame != 0) // if this value is known
+    if ((iSamplesPerFrame != 0) && ((iSamplesPerFrame * 1000) > iPCMSamplingRate))
+        // if this iSamplesPerFrame is known and is large enough to ensure that the iMilliSecPerFrame calculation
+        // below won't be set to 0.
     {
         // CALCULATE NumBytes per frame, Msec per frame, etc.
 
@@ -2500,450 +1335,33 @@
         iOMXComponentOutputBufferSize = numframes * iNumBytesPerFrame;
     }
     else
-        iOMXComponentOutputBufferSize = (iPCMSamplingRate * 1000) / (PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME);
+        iOMXComponentOutputBufferSize = (2 * iNumberOfAudioChannels * PVOMXAUDIODEC_DEFAULT_OUTPUTPCM_TIME * iPCMSamplingRate) / 1000; // assuming 16 bits per sample
 
-    return true;
-
-}
-
-bool PVMFOMXAudioDecNode::SetDefaultCapabilityFlags()
-{
-
-    iIsOMXComponentMultiThreaded = true;
-
-    iOMXComponentSupportsExternalOutputBufferAlloc = true;
-    iOMXComponentSupportsExternalInputBufferAlloc = true;
-    iOMXComponentSupportsMovableInputBuffers = true; //false;
-
-
-    return true;
-}
-
-
-
-bool PVMFOMXAudioDecNode::SendEOSBufferToOMXComponent()
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendEOSBufferToOMXComponent() In"));
-
-
-    // first of all, check if the component is running. EOS could be sent prior to component/decoder
-    // even being initialized
-
-    // returning false will ensure that the EOS will be sent downstream anyway without waiting for the
-    // Component to respond
-    if (iCurrentDecoderState != OMX_StateExecuting)
-        return false;
-
-    // get an input buffer. Without a buffer, no point in proceeding
-    InputBufCtrlStruct_Audio *input_buf = NULL;
-    int32 errcode = 0;
-
-    // we already checked that the number of buffers is OK, so we don't expect problems
-    // try to get input buffer header
-    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct_Audio *) iInBufMemoryPool->allocate(iInputAllocSize));
-    if (errcode != 0)
+    //Port 1 for output port
+    iParamPort.nPortIndex = iOutputPortIndex;
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
     {
-        if (errcode == OsclErrNoResources)
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                            PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::SendEOSBufferToOMXComponent() No more buffers in the mempool - unexpected"));
-
-            iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-            return false;
-        }
-        else
-        {
-            // Memory allocation for the pool failed
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::SendEOSBufferToOMXComponent() Input mempool error"));
-
-
-            SetState(EPVMFNodeError);
-            ReportErrorEvent(PVMFErrNoMemory);
-            return false;
-        }
-
-    }
-
-    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
-    iNumOutstandingInputBuffers++;
-
-    // in this case, no need to use input msg refcounter. Make sure its unbound
-    (input_buf->pMediaData).Unbind();
-
-    // THIS IS AN EMPTY BUFFER. FLAGS ARE THE ONLY IMPORTANT THING
-    input_buf->pBufHdr->nFilledLen = 0;
-    input_buf->pBufHdr->nOffset = 0;
-    input_buf->pBufHdr->nTimeStamp = iEndOfDataTimestamp;
-
-    // set ptr to input_buf structure for Context (for when the buffer is returned)
-    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-    // do not use Mark here (but init to NULL to prevent problems)
-    input_buf->pBufHdr->hMarkTargetComponent = NULL;
-    input_buf->pBufHdr->pMarkData = NULL;
-
-
-    // init buffer flags
-    input_buf->pBufHdr->nFlags = 0;
-
-    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-    // most importantly, set the EOS flag:
-    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_EOS;
-
-    // send buffer to component
-    OMX_EmptyThisBuffer(iOMXAudioDecoder, input_buf->pBufHdr);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendEOSBufferToOMXComponent() Out"));
-
-    return true;
-
-}
-
-
-bool PVMFOMXAudioDecNode::SendInputBufferToOMXComponent()
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() In"));
-
-
-    // first of all , get an input buffer. Without a buffer, no point in proceeding
-    InputBufCtrlStruct_Audio *input_buf = NULL;
-    int32 errcode = 0;
-
-    do
-    {
-        // do loop to loop over all fragments
-
-        // try to get input buffer header
-        OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct_Audio *) iInBufMemoryPool->allocate(iInputAllocSize));
-        if (errcode != 0)
-        {
-            if (errcode == OsclErrNoResources)
-            {
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                                PVLOGMSG_DEBUG, (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() No more buffers in the mempool"));
-
-                iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-                return false;
-            }
-            else
-            {
-                // Memory allocation for the pool failed
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() Input mempool error"));
-
-
-                SetState(EPVMFNodeError);
-                ReportErrorEvent(PVMFErrNoMemory);
-                return false;
-            }
-
-        }
-
-        // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-        iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
-        iNumOutstandingInputBuffers++;
-
-        // Now we have the buffer header (i.e. a buffer) to send to component:
-        // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
-        //	into OMX component without copying (and update the input msg refcount)
-        //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
-
-        // When copying content, a special case is when the input fragment is larger than the buffer and has to
-        //	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
-
-        // if this is the first fragment in a new message, extract some info:
-        if (iCurrFragNum == 0)
-        {
-
-            // NOTE: SeqNum differ in Codec and in Node because of the fact that
-            // one msg can contain multiple fragments that are sent to the codec as
-            // separate buffers. Node tracks msgs and codec tracks even separate fragments
-
-            iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
-            // amount that the input seq. number increased
-
-            iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
-            iInTimestamp = iDataIn->getTimestamp();
-            iInDuration = iDataIn->getDuration();
-            iInNumFrags = iDataIn->getNumFragments();
-
-            if (iSetMarkerBitForEveryFrag == true)
-            {
-                iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
-            }
-            else
-            {
-                iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
-            }
-
-            //Force marker bit for AMR streaming formats (marker bit may not be set even though full frames are present)
-            if (iInPort && (
-                        (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IETF_COMBINED) ||
-                        (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMRWB_IETF_PAYLOAD) ||
-                        (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_MP3)
-                    )
-               )
-            {
-                iCurrentMsgMarkerBit = PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
-            }
-
-            // logging info:
-            if (iDataIn->getNumFragments() > 1)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - New msg has MULTI-FRAGMENTS"));
-            }
-
-            if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT) && !(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT))
-            {
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - New msg has NO MARKER BIT"));
-            }
-        }
-
-
-        // get a memfrag from the message
-        OsclRefCounterMemFrag frag;
-        iDataIn->getMediaFragment(iCurrFragNum, frag);
-
-
-        if (iOMXComponentSupportsMovableInputBuffers)
-        {
-            // no copying required
-
-            // increment the RefCounter of the message associated with the mem fragment/buffer
-            // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
-            // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
-
-            iDataIn.GetRefCounter()->addRef();
-
-            // associate the buffer ctrl structure with the message ref counter and ptr
-            input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
-
-
-            // set pointer to the data, length, offset
-            input_buf->pBufHdr->pBuffer = (uint8 *)frag.getMemFragPtr();
-            input_buf->pBufHdr->nFilledLen = frag.getMemFragSize();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - Buffer 0x%x of size %d, %d frag out of tot. %d", input_buf->pBufHdr->pBuffer, frag.getMemFragSize(), iCurrFragNum + 1, iDataIn->getNumFragments()));
-
-            iCurrFragNum++; // increment fragment number and move on to the next
-            iIsNewDataFragment = true; // update the flag
-
-        }
-        else
-        {
-
-            // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
-            (input_buf->pMediaData).Unbind();
-
-            // is this a new data fragment or are we still working on separating the old one?
-            if (iIsNewDataFragment == true)
-            {
-                //  if fragment size is larger than the buffer size,
-                //	need to break up the fragment even further into smaller chunks
-
-                // init variables needed for fragment separation
-                iCopyPosition = 0;
-                iFragmentSizeRemainingToCopy  = frag.getMemFragSize();
-
-            }
-
-            // can the remaining fragment fit into the buffer?
-            if (iFragmentSizeRemainingToCopy <= (input_buf->pBufHdr->nAllocLen))
-            {
-
-                oscl_memcpy(input_buf->pBufHdr->pBuffer,
-                            (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
-                            iFragmentSizeRemainingToCopy);
-
-                input_buf->pBufHdr->nFilledLen = iFragmentSizeRemainingToCopy;
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d", iFragmentSizeRemainingToCopy, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen));
-
-                iCopyPosition += iFragmentSizeRemainingToCopy;
-                iFragmentSizeRemainingToCopy = 0;
-
-
-
-                iIsNewDataFragment = true; // done with this fragment. Get a new one
-                iCurrFragNum++;
-
-            }
-            else
-            {
-                // copy as much as you can of the current fragment into the current buffer
-                oscl_memcpy(input_buf->pBufHdr->pBuffer,
-                            (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
-                            input_buf->pBufHdr->nAllocLen);
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d", input_buf->pBufHdr->nAllocLen, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen));
-
-                input_buf->pBufHdr->nFilledLen = input_buf->pBufHdr->nAllocLen;
-                iCopyPosition += input_buf->pBufHdr->nAllocLen; // move current position within fragment forward
-                iFragmentSizeRemainingToCopy -= input_buf->pBufHdr->nAllocLen;
-                iIsNewDataFragment = false; // set the flag to indicate we're still working on the "old" fragment
-            }
-
-        }
-
-
-        // set buffer fields (this is the same regardless of whether the input is movable or not
-        input_buf->pBufHdr->nOffset = 0;
-        input_buf->pBufHdr->nTimeStamp = iInTimestamp;
-
-        // set ptr to input_buf structure for Context (for when the buffer is returned)
-        input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-        // do not use Mark here (but init to NULL to prevent problems)
-        input_buf->pBufHdr->hMarkTargetComponent = NULL;
-        input_buf->pBufHdr->pMarkData = NULL;
-
-
-        // init buffer flags
-        input_buf->pBufHdr->nFlags = 0;
-
-        // set marker bit on or off
-        // a) AAC - file playback - each fragment is a complete frame (1 msg may contain multiple fragments/frames)
-        //    AAC - streaming	- 1 msg may contain a partial frame, but LATM parser will assemble a full frame
-        //						(when LATM parser is done, we attach a marker bit to the data it produces)
-
-        // b) AMR - file playback - each msg is N whole frames (marker bit is always set)
-        //    AMR - streaming   - each msg is N whole frames (marker bit is missing from incoming msgs -set it here)
-
-        // c) MP3 - file playback - 1 msg is N whole frames
-
-
-        if (iSetMarkerBitForEveryFrag == true)
-        {
-
-
-            if (iIsNewDataFragment)
-            {
-                if ((iDataIn->getNumFragments() > 1))
-                {
-                    // if more than 1 fragment in the message and we have not broken it up
-                    //(i.e. this is the last piece of a broken up piece), put marker bit on it unconditionally
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - END OF FRAGMENT - Multifragmented msg AVC case, Buffer 0x%x MARKER bit set to 1", input_buf->pBufHdr->pBuffer));
-                    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-                }
-                else if ((iDataIn->getNumFragments() == 1))
-                {
-                    // this is (the last piece of broken up by us) single-fragmented message. This can be a piece of a NAL (streaming) or a full NAL (file )
-                    // apply marker bit if the message carries one
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - END OF FRAGMENT - Buffer 0x%x MARKER bit set to %d", input_buf->pBufHdr->pBuffer, iCurrentMsgMarkerBit));
-
-                    if (iCurrentMsgMarkerBit)
-                        input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
-                }
-            }
-            else
-            {
-                // we are separating fragments that are too big, i.e. bigger than
-                // what 1 buffer can hold, this fragment Can NEVER have marker bit
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - NOT END OF FRAGMENT - Buffer 0x%x MARKER bit set to 0", input_buf->pBufHdr->pBuffer));
-
-            }
-        }
-        else
-        {
-            // "normal" case, i.e. only fragments at ends of msgs may have marker bit set
-            //					fragments in the middle of a message never have marker bit set
-            // there is also a (slight) possibility we broke up the fragment into more fragments
-            //	because they can't fit into input buffer. In this case, make sure you apply
-            //	the marker bit (if necessary) only to the very last piece of the very last fragment
-
-            // for all other cases, clear the marker bit flag for the buffer
-            if ((iCurrFragNum == iDataIn->getNumFragments()) && iIsNewDataFragment)
-            {
-                // if all the fragments have been exhausted, and this is the last piece
-                // of the (possibly broken up) last fragment
-
-                // use the marker bit from the end of message
-                if (iCurrentMsgMarkerBit)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 1", input_buf->pBufHdr->pBuffer));
-
-                    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
-                }
-                else
-                {
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 0", input_buf->pBufHdr->pBuffer));
-                }
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - NOT END OF MESSAGE - Buffer 0x%x MARKER bit set to 0", input_buf->pBufHdr->pBuffer));
-            }
-
-
-        }// end of else(setmarkerbitforeveryfrag)
-
-
-        // set the key frame flag if necessary (mark every fragment that belongs to it)
-        if (iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT)
-            input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
-
-
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() - SENDING Buffer 0x%x MARKER bit set to %d,TS=%d", input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFlags, input_buf->pBufHdr->nTimeStamp));
-
-
-        OMX_EmptyThisBuffer(iOMXAudioDecoder, input_buf->pBufHdr);
-
-
-        // if we sent all fragments to OMX component, decouple the input message from iDataIn
-        // Input message is "decoupled", so that we can get a new message for processing into iDataIn
-        //	However, the actual message is released completely to upstream mempool once all of its fragments
-        //	are returned by the OMX component
-
-        if (iCurrFragNum == iDataIn->getNumFragments())
-        {
-            iDataIn.Unbind();
-
-        }
-
-
+                        (0, "PVMFOMXAudioDecNode::NegotiateComponentParameters() Problem negotiating with output port %d ", iOutputPortIndex));
+        return false;
     }
-    while (iCurrFragNum < iInNumFrags); //iDataIn->getNumFragments());
 
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendInputBufferToOMXComponent() Out"));
+    if (iOMXComponentOutputBufferSize < iParamPort.nBufferSize)
+    {
+        // the OMX spec says that nBuffersize is a read only field, but the client is allowed to allocate
+        // a buffer size larger than nBufferSize.
+        iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
+    }
 
     return true;
 
 }
+
 /////////////////////////////////////////////////////////////////////////////
 bool PVMFOMXAudioDecNode::InitDecoder(PVMFSharedMediaDataPtr& DataIn)
 {
-    uint16 length = 0, size = 0;
-
 
     OsclRefCounterMemFrag DataFrag;
     OsclRefCounterMemFrag refCtrMemFragOut;
@@ -2955,73 +1373,55 @@
     //		here, we're sending input/config buffers.
     //		Then, we'll go to ReadyToDecode state and send output as well
 
-    switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
+    if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM)
     {
-        case PVMF_LATM:
+        // must have the LATM config buffer and size already present
+        if (iLATMConfigBuffer != NULL)
         {
-
-            // must have the LATM config buffer and size already present
-            if (iLATMConfigBuffer != NULL)
-            {
-                initbuffer = iLATMConfigBuffer;
-                initbufsize = iLATMConfigBufferSize;
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::InitDecoder() Error - LATM config buffer not present"));
-                return false;
-            }
-
-
+            initbuffer = iLATMConfigBuffer;
+            initbufsize = iLATMConfigBufferSize;
         }
-        break;
-
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_ADIF:
-        case PVMF_ASF_MPEG4_AUDIO:
-        case PVMF_AAC_SIZEHDR: // for testing
+        else
         {
-            // get format specific info and send it as config data:
-            DataIn->getFormatSpecificInfo(DataFrag);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::InitDecoder() VOL header (Size=%d)", DataFrag.getMemFragSize()));
-
-            //get pointer to the data fragment
-            initbuffer = (uint8 *) DataFrag.getMemFragPtr();
-            initbufsize = (int32) DataFrag.getMemFragSize();
-
-        }			// in some cases, initbufsize may be 0, and initbuf= NULL. Config is done after 1st frame of data
-        break;
-
-        case PVMF_AMR_IF2:
-        case PVMF_AMR_IETF:
-        case PVMF_AMR_IETF_COMBINED:
-        case PVMF_AMRWB_IETF:
-        case PVMF_AMRWB_IETF_PAYLOAD:
-        case PVMF_MP3:
-        {
-            initbuffer = NULL; // no special config header. Need to decode 1 frame
-            initbufsize = 0;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXAudioDecNode::InitDecoder() Error - LATM config buffer not present"));
+            return false;
         }
-        break;
+    }
+    else if (((PVMFOMXDecPort*)iInPort)->iFormat ==  PVMF_MIME_MPEG4_AUDIO ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ADIF ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ASF_MPEG4_AUDIO ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AAC_SIZEHDR) // for testing
+    {
+        // get format specific info and send it as config data:
+        DataIn->getFormatSpecificInfo(DataFrag);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::InitDecoder() VOL header (Size=%d)", DataFrag.getMemFragSize()));
 
-        case PVMF_WMA:
+        //get pointer to the data fragment
+        initbuffer = (uint8 *) DataFrag.getMemFragPtr();
+        initbufsize = (int32) DataFrag.getMemFragSize();
 
-            // in case of WMA, get config parameters from the port
-            initbuffer = ((PVMFOMXAudioDecPort*)iInPort)->getTrackConfig();
-            initbufsize = (int32)((PVMFOMXAudioDecPort*)iInPort)->getTrackConfigSize();
+    }			// in some cases, initbufsize may be 0, and initbuf= NULL. Config is done after 1st frame of data
+    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IF2 ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IETF ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB_IETF ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB ||
+             ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MP3)
+    {
+        initbuffer = NULL; // no special config header. Need to decode 1 frame
+        initbufsize = 0;
+    }
 
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::InitDecoder() for WMA Decoder. Initialization data Size %d.", initbufsize));
+    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMA)
+    {
+        // in case of WMA, get config parameters from the port
+        initbuffer = ((PVMFOMXDecPort*)iInPort)->getTrackConfig();
+        initbufsize = (int32)((PVMFOMXDecPort*)iInPort)->getTrackConfigSize();
 
-
-            break;
-
-
-        default:
-
-            break;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::InitDecoder() for WMA Decoder. Initialization data Size %d.", initbufsize));
     }
 
 
@@ -3047,591 +1447,6 @@
 
 
 
-bool PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent(uint8 *initbuffer, uint32 initbufsize)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() In"));
-
-
-    // first of all , get an input buffer. Without a buffer, no point in proceeding
-    InputBufCtrlStruct_Audio *input_buf = NULL;
-    int32 errcode = 0;
-
-    // try to get input buffer header
-    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct_Audio *) iInBufMemoryPool->allocate(iInputAllocSize));
-    if (errcode != 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() Input buffer mempool problem -unexpected at init"));
-
-        return false;
-    }
-
-    // Got a buffer OK
-    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
-    iNumOutstandingInputBuffers++;
-
-    // Now we have the buffer header (i.e. a buffer) to send to component:
-    // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
-    //	into OMX component without copying (and update the input msg refcount)
-    //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
-
-    // When copying content, a special case is when the input fragment is larger than the buffer and has to
-    //	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
-
-    iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
-    // amount that the input seq. number increased
-
-    iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
-    iInTimestamp = iDataIn->getTimestamp();
-    iInDuration = iDataIn->getDuration();
-
-
-    if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT))
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() - New msg has NO MARKER BIT"));
-    }
-
-
-    if (iOMXComponentSupportsMovableInputBuffers)
-    {
-        // no copying required
-
-        // increment the RefCounter of the message associated with the mem fragment/buffer
-        // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
-        // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
-
-        iDataIn.GetRefCounter()->addRef();
-
-        // associate the buffer ctrl structure with the message ref counter and ptr
-        input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
-
-
-        // set pointer to the data, length, offset
-        input_buf->pBufHdr->pBuffer = initbuffer;
-        input_buf->pBufHdr->nFilledLen = initbufsize;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() - Config Buffer 0x%x of size %d", initbuffer, initbufsize));
-
-    }
-    else
-    {
-
-        // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
-        (input_buf->pMediaData).Unbind();
-
-        // we assume the buffer is large enough to fit the config data
-
-        iCopyPosition = 0;
-        iFragmentSizeRemainingToCopy  = initbufsize;
-
-
-
-        // can the remaining fragment fit into the buffer?
-        if (iFragmentSizeRemainingToCopy <= (input_buf->pBufHdr->nAllocLen))
-        {
-
-            oscl_memcpy(input_buf->pBufHdr->pBuffer,
-                        (void *)(initbuffer + iCopyPosition),
-                        iFragmentSizeRemainingToCopy);
-
-            input_buf->pBufHdr->nFilledLen = iFragmentSizeRemainingToCopy;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() - Copied %d bytes into buffer 0x%x of size %d", iFragmentSizeRemainingToCopy, input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen));
-
-            iCopyPosition += iFragmentSizeRemainingToCopy;
-            iFragmentSizeRemainingToCopy = 0;
-
-
-        }
-        else
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() Config buffer too large problem -unexpected at init"));
-
-            return false;
-        }
-
-    }
-
-
-    // set buffer fields (this is the same regardless of whether the input is movable or not
-    input_buf->pBufHdr->nOffset = 0;
-    input_buf->pBufHdr->nTimeStamp = iInTimestamp;
-
-    // set ptr to input_buf structure for Context (for when the buffer is returned)
-    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-    // do not use Mark here (but init to NULL to prevent problems)
-    input_buf->pBufHdr->hMarkTargetComponent = NULL;
-    input_buf->pBufHdr->pMarkData = NULL;
-
-
-    // init buffer flags
-    input_buf->pBufHdr->nFlags = 0;
-
-    // set marker bit on
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendConfigBufferToOMXComponent() - END OF FRAGMENT - Buffer 0x%x MARKER bit set to 1", input_buf->pBufHdr->pBuffer));
-
-    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
-    OMX_EmptyThisBuffer(iOMXAudioDecoder, input_buf->pBufHdr);
-
-    return true;
-
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::CreateOutMemPool(uint32 num_buffers)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::CreateOutMemPool() start"));
-    // In the case OMX component wants to allocate its own buffers,
-    // mempool only contains OutputBufCtrlStructures (i.e. ptrs to buffer headers)
-    // In case OMX component uses pre-allocated buffers (here),
-    // mempool allocates OutputBufCtrlStructure (i.e. ptrs to buffer hdrs), followed by actual buffers
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::CreateOutMemPool() Allocating output buffer header pointers"));
-
-    iOutputAllocSize = oscl_mem_aligned_size((uint32)sizeof(OutputBufCtrlStruct_Audio));
-
-    if (iOMXComponentSupportsExternalOutputBufferAlloc)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::CreateOutMemPool() Allocating output buffers of size %d as well", iOMXComponentOutputBufferSize));
-
-        //pre-negotiated output buffer size
-        iOutputAllocSize += iOMXComponentOutputBufferSize;
-    }
-
-    // for media data wrapper
-    if (iMediaDataMemPool)
-    {
-        iMediaDataMemPool->removeRef();
-        iMediaDataMemPool = NULL;
-    }
-
-    if (iOutBufMemoryPool)
-    {
-        iOutBufMemoryPool->removeRef();
-        iOutBufMemoryPool = NULL;
-    }
-
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iOutBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
-    if (leavecode || iOutBufMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::CreateOutMemPool() Memory pool structure for output buffers failed to allocate"));
-        return false;
-    }
-
-
-
-    // allocate a dummy buffer to actually create the mempool
-    OsclAny *dummy_alloc = NULL; // this dummy buffer will be released at end of scope
-    leavecode = 0;
-    OSCL_TRY(leavecode, dummy_alloc = iOutBufMemoryPool->allocate(iOutputAllocSize));
-    if (leavecode || dummy_alloc == NULL)
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::CreateOutMemPool() Memory pool for output buffers failed to allocate"));
-        return false;
-    }
-    iOutBufMemoryPool->deallocate(dummy_alloc);
-    // init the counter
-    iNumOutstandingOutputBuffers = 0;
-
-    // allocate mempool for media data message wrapper
-    leavecode = 0;
-    OSCL_TRY(leavecode, iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers, PVOMXAUDIODEC_MEDIADATA_CHUNKSIZE)));
-    if (leavecode || iMediaDataMemPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::CreateOutMemPool() Media Data Buffer pool for output buffers failed to allocate"));
-        return false;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::CreateOutMemPool() done"));
-    return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////// Creates memory pool for input buffer management ///////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::CreateInputMemPool(uint32 num_buffers)
-{
-    // 3 cases in order of preference and simplicity
-
-    // Case 1 (buffers allocated upstream - no memcpy needed):
-    //	PV OMX Component - We use buffers allocated outside the OMX node (i.e. allocated upstream)
-    // Mempool contains InputBufCtrlStructures (ptrs to buffer headers and PMVFMediaData ptrs - to keep track of when to unbind input msgs)
-
-    // NOTE:	in this case, when providing input buffers to OMX component,
-    //			OMX_UseBuffer calls will provide some initial pointers and sizes of buffers, but these
-    //			are dummy values. Actual buffer pointers and filled sizes will be obtained from the input msg fragments.
-    //			The PV OMX component will use the buffers even if the ptrs differ from the ones during initialization
-    //			3rd party OMX components can also use this case if they are capable of ignoring the actual buffer pointers in
-    //			buffer header field (i.e. if after OMX_UseBuffer(...) call, they allow the ptr to actual buffer data to change at a later time
-
-    // CASE 2 (buffers allocated in the node - memcpy needed)
-    //			If 3rd party OMX component can use buffers allocated outside the OMX component, but it cannot
-    //			change buffer ptr allocations dynamically (i.e. after initialization with OMX_UseBuffer call is complete)
-
-    //		Mempool contains InputBufCtrlStructures (ptrs to buffer headers, PVMFMediaData ptrs to keep track of when to unbind input msgs) +
-    //				actual buffers.
-    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component
-
-    // CASE 3 (buffers allocated in the component - memcpy needed)
-    //			If 3rd party OMX component must allocate its own buffers
-    //			Mempool only contains InputBufCtrlStruct (ptrs to buffer headers + PMVFMediaData ptrs to keep track of when to unbind input msgs)
-    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component (like in case 2)
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::CreateInputMemPool() start "));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::CreateInputMemPool() allocating buffer header pointers and shared media data ptrs "));
-
-
-
-    iInputAllocSize = oscl_mem_aligned_size((uint32) sizeof(InputBufCtrlStruct_Audio)); //aligned_size_buffer_header_ptr+aligned_size_media_data_ptr;
-
-    // Need to allocate buffers in the node either if component supports external buffers buffers
-    // but they are not movable
-
-    if ((iOMXComponentSupportsExternalInputBufferAlloc && !iOMXComponentSupportsMovableInputBuffers))
-    {
-        //pre-negotiated input buffer size
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::CreateOutMemPool() Allocating input buffers of size %d as well", iOMXComponentInputBufferSize));
-
-        iInputAllocSize += iOMXComponentInputBufferSize;
-    }
-
-    if (iInBufMemoryPool)
-    {
-        iInBufMemoryPool->removeRef();
-        iInBufMemoryPool = NULL;
-    }
-
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iInBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
-    if (leavecode || iInBufMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::CreateInputMemPool() Memory pool structure for input buffers failed to allocate"));
-        return false;
-    }
-    // try to allocate a dummy buffer to actually create the mempool and allocate the needed memory
-    // allocate a dummy buffer to actually create the mempool, this dummy buffer will be released at end of scope of this method
-    OsclAny *dummy_alloc = NULL;
-    leavecode = 0;
-    OSCL_TRY(leavecode, dummy_alloc = iInBufMemoryPool->allocate(iInputAllocSize));
-    if (leavecode || dummy_alloc == NULL)
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::CreateInputMemPool() Memory pool for input buffers failed to allocate"));
-        return false;
-    }
-
-    // init the counter
-    iNumOutstandingInputBuffers = 0;
-
-
-    iInputBufferToResendToComponent = NULL; // nothing to resend yet
-    iInBufMemoryPool->deallocate(dummy_alloc);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::CreateInputMemPool() done"));
-    return true;
-}
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-        uint32 aNumBuffers,    // number of buffers
-        uint32 aActualBufferSize, // aactual buffer size
-        uint32 aPortIndex,      // port idx
-        bool aUseBufferOK,		// can component use OMX_UseBuffer or should it use OMX_AllocateBuffer
-        bool	aIsThisInputBuffer		// is this input or output
-                                                   )
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ProvideBuffersToComponent() enter"));
-
-    uint32 ii = 0;
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
-
-    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
-    if (ctrl_struct_ptr == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::ProvideBuffersToComponent ctrl_struct_ptr == NULL"));
-        return false;
-    }
-
-
-    // Now, go through all buffers and tell component to
-    // either use a buffer, or to allocate its own buffer
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-
-        int32 errcode = 0;
-        // get the address where the buf hdr ptr will be stored
-        OSCL_TRY(errcode, ctrl_struct_ptr[ii] = (OsclAny *) aMemPool->allocate(aAllocSize));
-        if ((errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL))
-        {
-            if (errcode == OsclErrNoResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::ProvideBuffersToComponent ->allocate() failed for no mempool chunk available"));
-            }
-            else
-            {
-                // General error
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::ProvideBuffersToComponent ->allocate() failed due to some general error"));
-
-                ReportErrorEvent(PVMFFailure);
-                ChangeNodeState(EPVMFNodeError);
-            }
-
-            return false;
-        }
-
-        if (aUseBufferOK)
-        {
-            // Buffers are already allocated outside OMX component.
-            // In case of output buffers, the buffer itself is located
-            // just after the buffer header pointer.
-
-            // In case of input buffers, the buffer header pointer is followed by a MediaDataSharedPtr
-            //	which is used to ensure proper unbinding of the input messages. The buffer itself is either:
-            //		a) allocated upstream (and the ptr to the buffer
-            //			is a dummy pointer to which the component does not pay attention - PV OMX component)
-            //		b) located just after the buffer header pointer and MediaDataSharedPtr
-
-            uint8 *pB = ((uint8*) ctrl_struct_ptr[ii]);
-
-
-            // in case of input buffers, initialize also MediaDataSharedPtr structure
-            if (aIsThisInputBuffer)
-            {
-
-                InputBufCtrlStruct_Audio *temp = (InputBufCtrlStruct_Audio *) ctrl_struct_ptr[ii];
-                oscl_memset(&(temp->pMediaData), 0, sizeof(PVMFSharedMediaDataPtr));
-                temp->pMediaData = PVMFSharedMediaDataPtr(NULL, NULL);
-
-                // advance ptr to skip the structure
-                pB += oscl_mem_aligned_size(sizeof(InputBufCtrlStruct_Audio));
-
-                err = OMX_UseBuffer(iOMXAudioDecoder,	// hComponent
-                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
-                                    aPortIndex,				// port index (for port for which buffer is provided)
-                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
-                                    //				to have a context when component returns with a callback (i.e. to know
-                                    //				what to free etc.
-                                    (OMX_U32)aActualBufferSize,		// buffer size
-                                    pB);						// buffer data ptr
-
-            }
-            else
-            {
-                OutputBufCtrlStruct_Audio *temp = (OutputBufCtrlStruct_Audio *) ctrl_struct_ptr[ii];
-                // advance buffer ptr to skip the structure
-                pB += oscl_mem_aligned_size(sizeof(OutputBufCtrlStruct_Audio));
-
-
-                err = OMX_UseBuffer(iOMXAudioDecoder,	// hComponent
-                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
-                                    aPortIndex,				// port index (for port for which buffer is provided)
-                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
-                                    //				to have a context when component returns with a callback (i.e. to know
-                                    //				what to free etc.
-                                    (OMX_U32)aActualBufferSize,		// buffer size
-                                    pB);						// buffer data ptr
-
-
-            }
-
-
-        }
-        else
-        {
-            // the component must allocate its own buffers.
-            if (aIsThisInputBuffer)
-            {
-
-                InputBufCtrlStruct_Audio *temp = (InputBufCtrlStruct_Audio *) ctrl_struct_ptr[ii];
-                err = OMX_AllocateBuffer(iOMXAudioDecoder,
-                                         &(temp->pBufHdr),
-                                         aPortIndex,
-                                         ctrl_struct_ptr[ii],
-                                         (OMX_U32)aActualBufferSize);
-            }
-            else
-            {
-                OutputBufCtrlStruct_Audio *temp = (OutputBufCtrlStruct_Audio *) ctrl_struct_ptr[ii];
-                err = OMX_AllocateBuffer(iOMXAudioDecoder,
-                                         &(temp->pBufHdr),
-                                         aPortIndex,
-                                         ctrl_struct_ptr[ii],
-                                         (OMX_U32)aActualBufferSize);
-            }
-
-        }
-
-        if (err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::ProvideBuffersToComponent() Problem using/allocating a buffer"));
-
-
-            return false;
-        }
-
-    }
-
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-        // after initializing the buffer hdr ptrs, return them
-        // to the mempool
-        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
-    }
-
-    oscl_free(ctrl_struct_ptr);
-    // set the flags
-    if (aIsThisInputBuffer)
-    {
-        iInputBuffersFreed = false;
-    }
-    else
-    {
-        iOutputBuffersFreed = false;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ProvideBuffersToComponent() done"));
-    return true;
-}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-        uint32 aNumBuffers,    // number of buffers
-        uint32 aPortIndex,      // port idx
-        bool	aIsThisInputBuffer		// is this input or output
-                                                  )
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::FreeBuffersToComponent() enter"));
-
-    uint32 ii = 0;
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
-
-    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
-    if (ctrl_struct_ptr == NULL)
-    {
-        return false;
-    }
-
-
-    // Now, go through all buffers and tell component to free them
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-
-        int32 errcode = 0;
-        // get the address where the buf hdr ptr will be stored
-
-        OSCL_TRY(errcode, ctrl_struct_ptr[ii] = (OsclAny *) aMemPool->allocate(aAllocSize));
-        if ((errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL))
-        {
-            if (errcode == OsclErrNoResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::FreeBuffersFromComponent ->allocate() failed for no mempool chunk available"));
-            }
-            else
-            {
-                // General error
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::FreeBuffersFromComponent ->allocate() failed due to some general error"));
-
-                ReportErrorEvent(PVMFFailure);
-                ChangeNodeState(EPVMFNodeError);
-            }
-
-            return false;
-        }
-        // to maintain correct count
-        aMemPool->notifyfreechunkavailable((*this), (OsclAny*) aMemPool);
-
-        if (aIsThisInputBuffer)
-        {
-
-            iNumOutstandingInputBuffers++;
-            // get the buf hdr pointer
-            InputBufCtrlStruct_Audio *temp = (InputBufCtrlStruct_Audio *) ctrl_struct_ptr[ii];
-            err = OMX_FreeBuffer(iOMXAudioDecoder,
-                                 aPortIndex,
-                                 temp->pBufHdr);
-
-        }
-        else
-        {
-            iNumOutstandingOutputBuffers++;
-            OutputBufCtrlStruct_Audio *temp = (OutputBufCtrlStruct_Audio *) ctrl_struct_ptr[ii];
-            err = OMX_FreeBuffer(iOMXAudioDecoder,
-                                 aPortIndex,
-                                 temp->pBufHdr);
-
-        }
-
-        if (err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::FreeBuffersFromComponent() Problem freeing a buffer"));
-
-            return false;
-        }
-
-    }
-
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-        // after freeing the buffer hdr ptrs, return them
-        // to the mempool (which will itself then be deleted promptly)
-        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
-    }
-
-    oscl_free(ctrl_struct_ptr);
-
-    // mark buffers as freed (so as not to do it twice)
-    if (aIsThisInputBuffer)
-    {
-        iInputBuffersFreed = true;
-    }
-    else
-    {
-        iOutputBuffersFreed = true;
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::FreeBuffersFromComponent() done"));
-    return true;
-}
-
-
-
 /////////////////////////////////////////////////////////////////////////////
 ////////////////////// CALLBACK PROCESSING FOR EVENT HANDLER
 /////////////////////////////////////////////////////////////////////////////
@@ -3663,6 +1478,7 @@
                 case OMX_CommandFlush:
                 {
                     // flush can be sent as part of repositioning or as part of port reconfig
+
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                     (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_CommandFlush - completed on port %d", aData2));
 
@@ -3682,7 +1498,9 @@
                             iIsRepositionDoneReceivedFromComponent = true;
                         }
                     }
-                    RunIfNotReady();
+
+                    if (IsAdded())
+                        RunIfNotReady();
 
                 }
 
@@ -3692,7 +1510,7 @@
                 {
                     // if port disable command is done, we can re-allocate the buffers and re-enable the port
 
-                    iProcessingState = EPVMFOMXAudioDecNodeProcessingState_PortReEnable;
+                    iProcessingState = EPVMFOMXBaseDecNodeProcessingState_PortReEnable;
                     iPortIndexForDynamicReconfig =  aData2;
 
                     RunIfNotReady();
@@ -3708,7 +1526,7 @@
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                         (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, dynamic reconfiguration needed on port %d", aData2, iSecondPortToReconfig));
 
-                        iProcessingState = EPVMFOMXAudioDecNodeProcessingState_PortReconfig;
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_PortReconfig;
                         iPortIndexForDynamicReconfig = iSecondPortToReconfig;
                         iSecondPortReportedChange = false;
                     }
@@ -3716,20 +1534,19 @@
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                         (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, resuming normal data flow", aData2));
-                        iProcessingState = EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode;
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
                         iDynamicReconfigInProgress = false;
                         // in case pause or stop command was sent to component
                         // change processing state (because the node might otherwise
                         // start sending buffers to component before pause/stop is processed)
                         if (iPauseCommandWasSentToComponent)
                         {
-                            iProcessingState = EPVMFOMXAudioDecNodeProcessingState_Pausing;
+                            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Pausing;
                         }
                         if (iStopCommandWasSentToComponent)
                         {
-                            iProcessingState = EPVMFOMXAudioDecNodeProcessingState_Stopping;
+                            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Stopping;
                         }
-
                     }
                     RunIfNotReady();
                     break;
@@ -3756,7 +1573,7 @@
         case OMX_EventError:
         {
 
-            if (aData1 == OMX_ErrorStreamCorrupt)
+            if (aData1 == (OMX_U32) OMX_ErrorStreamCorrupt)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_EventError - Bitstream corrupt error"));
@@ -3770,7 +1587,7 @@
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_EventError"));
                 // for now, any error from the component will be reported as error
-                ReportErrorEvent(PVMFErrorEvent, NULL, NULL);
+                ReportErrorEvent(PVMFErrProcessing, NULL, NULL);
                 SetState(EPVMFNodeError);
             }
             break;
@@ -3781,6 +1598,10 @@
 
         case OMX_EventBufferFlag:
         {
+            // the component is reporting it encountered end of stream flag
+            // we'll send EOS when we receive the last buffer marked with eos
+
+
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_EventBufferFlag (EOS) flag returned from OMX component"));
 
@@ -3823,14 +1644,11 @@
                     // GET the output buffer params and sizes
                     OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
                     Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
-                    Audio_Pcm_Param.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
-                    Audio_Pcm_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-                    Audio_Pcm_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-                    Audio_Pcm_Param.nVersion.s.nRevision = SPECREVISION;
-                    Audio_Pcm_Param.nVersion.s.nStep = SPECSTEP;
+                    CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
 
 
-                    Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+
+                    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
                     if (Err != OMX_ErrorNone)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
@@ -3853,6 +1671,7 @@
 
                         SetState(EPVMFNodeError);
                         ReportErrorEvent(PVMFErrResource);
+
                     }
                 }
             }
@@ -3861,7 +1680,7 @@
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                                 (0, "PVMFOMXAudioDecNode::EventHandlerProcessing: OMX_EventPortSettingsChanged returned for port %d", aData1));
 
-                iProcessingState = EPVMFOMXAudioDecNodeProcessingState_PortReconfig;
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_PortReconfig;
                 iPortIndexForDynamicReconfig = aData1;
                 // start "discarding" data right away, don't wait
                 // check the audio sampling rate and fs right away in case of output port
@@ -3873,14 +1692,11 @@
                     // GET the output buffer params and sizes
                     OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
                     Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params
-                    Audio_Pcm_Param.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
-                    Audio_Pcm_Param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
-                    Audio_Pcm_Param.nVersion.s.nVersionMinor = SPECVERSIONMINOR;
-                    Audio_Pcm_Param.nVersion.s.nRevision = SPECREVISION;
-                    Audio_Pcm_Param.nVersion.s.nStep = SPECSTEP;
+
+                    CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
 
 
-                    Err = OMX_GetParameter(iOMXAudioDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+                    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
                     if (Err != OMX_ErrorNone)
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
@@ -3904,9 +1720,7 @@
 
                         SetState(EPVMFNodeError);
                         ReportErrorEvent(PVMFErrResource);
-
                     }
-
                 }
                 iDynamicReconfigInProgress = true;
             }
@@ -3943,348 +1757,6 @@
 
 
 
-/////////////////////////////////////////////////////////////////////////////
-// This function handles the event of OMX component state change
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::HandleComponentStateChange(OMX_U32 decoder_state)
-{
-    switch (decoder_state)
-    {
-        case OMX_StateIdle:
-        {
-            iCurrentDecoderState = OMX_StateIdle;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleComponentStateChange: OMX_StateIdle reached"));
-
-            //  this state can be reached either going from OMX_Loaded->OMX_Idle (preparing)
-            //	or going from OMX_Executing->OMX_Idle (stopping)
-
-            // Also, in case of Audio, repositioning is done by performing Executing->Idle ->Executing
-            if (iIsRepositionIdleRequestSentToComponent)
-            {
-                iIsRepositionIdleDoneReceivedFromComponent = true;
-                RunIfNotReady();
-            }
-            else if ((iCurrentCommand.size() > 0) &&
-                     (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_PREPARE))
-            {
-                iProcessingState = EPVMFOMXAudioDecNodeProcessingState_InitDecoder;
-                SetState(EPVMFNodePrepared);
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-                RunIfNotReady();
-            }
-            else if ((iCurrentCommand.size() > 0) &&
-                     (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_STOP))
-            {
-                // if we are stopped, we won't start until the node gets DoStart command.
-                //	in this case, we are ready to start sending buffers
-                if (iProcessingState == EPVMFOMXAudioDecNodeProcessingState_Stopping)
-                    iProcessingState = EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode;
-                // if the processing state was not stopping, leave the state as it was (continue port reconfiguration)
-                SetState(EPVMFNodePrepared);
-                iStopCommandWasSentToComponent = false;
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-
-                RunIfNotReady();
-            }
-            else if ((iCurrentCommand.size() > 0) &&
-                     (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET))
-            {
-                // State change to Idle was initiated due to Reset. First need to reach idle, and then loaded
-                // Once Idle is reached, we need to initiate idle->loaded transition
-                RunIfNotReady();
-            }
-            break;
-        }//end of case OMX_StateIdle
-
-        case OMX_StateExecuting:
-        {
-            iCurrentDecoderState = OMX_StateExecuting;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleComponentStateChange: OMX_StateExecuting reached"));
-
-            // this state can be reached going from OMX_Idle -> OMX_Executing (preparing)
-            //	or going from OMX_Pause -> OMX_Executing (coming from pause)
-            //	This is a response to "DoStart" command
-
-            // Also, during repositioning, idle->executing transition can be requested
-            if (iIsRepositionExecRequestSentToComponent)
-            {
-                iIsRepositionExecDoneReceivedFromComponent = true;
-                RunIfNotReady();
-            }
-            else if ((iCurrentCommand.size() > 0) &&
-                     (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_START))
-            {
-                SetState(EPVMFNodeStarted);
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-
-                RunIfNotReady();
-            }
-
-            break;
-        }//end of case OMX_StateExecuting
-
-        case OMX_StatePause:
-        {
-            iCurrentDecoderState = OMX_StatePause;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleComponentStateChange: OMX_StatePause reached"));
-
-
-            //	This state can be reached going from OMX_Executing-> OMX_Pause
-            if ((iCurrentCommand.size() > 0) &&
-                    (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_PAUSE))
-            {
-
-                // if we are paused, we won't start until the node gets DoStart command.
-                //	in this case, we are ready to start sending buffers
-
-                if (iProcessingState == EPVMFOMXAudioDecNodeProcessingState_Pausing)
-                    iProcessingState = EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode;
-
-
-
-                SetState(EPVMFNodePaused);
-                iPauseCommandWasSentToComponent = false;
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-                RunIfNotReady();
-            }
-
-            break;
-        }//end of case OMX_StatePause
-
-        case OMX_StateLoaded:
-        {
-            iCurrentDecoderState = OMX_StateLoaded;
-
-            //  this state can be reached only going from OMX_Idle ->OMX_Loaded (stopped to reset)
-            //
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleComponentStateChange: OMX_StateLoaded reached"));
-            //Check if command's responce is pending
-            if ((iCurrentCommand.size() > 0) &&
-                    (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET))
-            {
-
-                // move this here
-                if (iInPort)
-                {
-                    OSCL_DELETE(((PVMFOMXAudioDecPort*)iInPort));
-                    iInPort = NULL;
-                }
-
-                if (iOutPort)
-                {
-                    OSCL_DELETE(((PVMFOMXAudioDecPort*)iOutPort));
-                    iOutPort = NULL;
-                }
-
-                iDataIn.Unbind();
-
-                // Reset the metadata key list
-                iAvailableMetadataKeys.clear();
-
-
-                iProcessingState = EPVMFOMXAudioDecNodeProcessingState_Idle;
-                //logoff & go back to Created state.
-                SetState(EPVMFNodeIdle);
-                PVMFStatus status = ThreadLogoff();
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), status);
-                iResetInProgress = false;
-                iResetMsgSent = false;
-                //DeleteOMXAudioDecoder();
-            }
-
-            break;
-        }//end of case OMX_StateLoaded
-
-        case OMX_StateInvalid:
-        default:
-        {
-            iCurrentDecoderState = OMX_StateInvalid;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::HandleComponentStateChange: OMX_StateInvalid reached"));
-
-            break;
-        }//end of case OMX_StateInvalid
-
-    }//end of switch(decoder_state)
-
-}
-
-
-
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR EMPTY BUFFER DONE - input buffer was consumed
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXAudioDecNode::EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::EmptyBufferDoneProcessing: In"));
-
-    OSCL_ASSERT((void*) aComponent == (void*) iOMXAudioDecoder); // component should match the component
-    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
-
-    // first, get the buffer "context", i.e. pointer to application private data that contains the
-    // address of the mempool buffer (so that it can be released)
-    InputBufCtrlStruct_Audio *pContext = (InputBufCtrlStruct_Audio *)(aBuffer->pAppPrivate);
-
-
-
-    // if a buffer is not empty, we should send the same buffer back to the component
-    // do not release it in this case
-    if ((aBuffer->nFilledLen > 0) && (iDoNotSaveInputBuffersFlag == false))
-        // if dynamic port reconfig is in progress for input port, don't keep the buffer
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::EmptyBufferDoneProcessing: Input buffer returned with %d bytes still in it, TS=%d", aBuffer->nFilledLen, aBuffer->nTimeStamp));
-
-        iInputBufferToResendToComponent = NULL;
-
-    }
-
-    {
-
-        iInputBufferToResendToComponent = NULL;
-
-        // input buffer is to be released,
-        // refcount needs to be decremented (possibly - the input msg associated with the buffer will be unbound)
-        // NOTE: in case of "moveable" input buffers (passed into component without copying), unbinding decrements a refcount which eventually results
-        //			in input message being released back to upstream mempool once all its fragments are returned
-        //		in case of input buffers passed into component by copying, unbinding has no effect
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::EmptyBufferDoneProcessing: Release input buffer with TS=%d (with %d refcount remaining of input message)", aBuffer->nTimeStamp, (pContext->pMediaData).get_count() - 1));
-
-
-        (pContext->pMediaData).Unbind();
-
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::EmptyBufferDoneProcessing: Release input buffer %x back to mempool", pContext));
-
-        iInBufMemoryPool->deallocate((OsclAny *) pContext);
-    }
-
-    // the OMX spec says that no error is to be returned
-    return OMX_ErrorNone;
-
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR FILL BUFFER DONE - output buffer is ready
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXAudioDecNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: In"));
-
-    OSCL_ASSERT((void*) aComponent == (void*) iOMXAudioDecoder); // component should match the component
-    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
-
-    // first, get the buffer "context", i.e. pointer to application private data that contains the
-    // address of the mempool buffer (so that it can be released)
-    OsclAny *pContext = (OsclAny*) aBuffer->pAppPrivate;
-
-
-    // check for EOS flag
-    if ((aBuffer->nFlags & OMX_BUFFERFLAG_EOS))
-    {
-        // EOS received
-        iIsEOSReceivedFromComponent = true;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: Output buffer has EOS set"));
-
-    }
-
-    // if a buffer is empty, or if it should not be sent downstream (say, due to state change)
-    // release the buffer back to the pool
-    if ((aBuffer->nFilledLen == 0) || (iDoNotSendOutputBuffersDownstreamFlag == true))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: Release output buffer %x back to mempool - buffer empty or not to be sent downstream", pContext));
-
-        iOutBufMemoryPool->deallocate(pContext);
-
-    }
-    else
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "Output frame %d received", iFrameCounter++));
-
-        // get pointer to actual buffer data
-        uint8 *pBufdata = ((uint8*) aBuffer->pBuffer);
-        // move the data pointer based on offset info
-        pBufdata += aBuffer->nOffset;
-
-        iOutTimeStamp = aBuffer->nTimeStamp;
-        //iOutTimeStamp = iInTimestamp;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: Wrapping buffer %x of size %d", pBufdata, aBuffer->nFilledLen));
-        // wrap the buffer into the MediaDataImpl wrapper, and queue it for sending downstream
-        // wrapping will create a refcounter. When refcounter goes to 0 i.e. when media data
-        // is released in downstream components, the custom deallocator will automatically release the buffer back to the
-        //	mempool. To do that, the deallocator needs to have info about Context
-        // NOTE: we had to wait until now to wrap the buffer data because we only know
-        //			now where the actual data is located (based on buffer offset)
-        OsclSharedPtr<PVMFMediaDataImpl> MediaDataOut = WrapOutputBuffer(pBufdata, (uint32)(aBuffer->nFilledLen), pContext);
-
-        // if you can't get the MediaDataOut, release the buffer back to the pool
-        if (MediaDataOut.GetRep() == NULL)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: Problem wrapping buffer %x of size %d - releasing the buffer", pBufdata, aBuffer->nFilledLen));
-
-            iOutBufMemoryPool->deallocate(pContext);
-        }
-        else
-        {
-
-            // if there's a problem queuing output buffer, MediaDataOut will expire at end of scope and
-            // release buffer back to the pool, (this should not be the case)
-            if (QueueOutputBuffer(MediaDataOut, aBuffer->nFilledLen))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: Buffer %x of size %d queued - reschedule the node to send out", pBufdata, aBuffer->nFilledLen));
-
-                // if queing went OK,
-                // re-schedule the node so that outgoing queue can be emptied (unless the outgoing port is busy)
-                if ((iOutPort) && !(iOutPort->IsConnectedPortBusy()))
-                    RunIfNotReady();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::FillBufferDoneProcessing: Problem queing buffer %x of size %d - releasing the buffer", pBufdata, aBuffer->nFilledLen));
-            }
-
-
-        }
-
-    }
-    // the OMX spec says that no error is to be returned
-    return OMX_ErrorNone;
-
-}
 ////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////// Put output buffer in outgoing queue //////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4293,7 +1765,7 @@
 
     bool status = true;
     PVMFSharedMediaDataPtr mediaDataOut;
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
 
     // NOTE: ASSUMPTION IS THAT OUTGOING QUEUE IS BIG ENOUGH TO QUEUE ALL THE OUTPUT BUFFERS
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -4309,7 +1781,7 @@
 
     OSCL_TRY(leavecode,
              mediaDataOut = PVMFMediaData::createMediaData(mediadataimplout, iMediaDataMemPool););
-    if (leavecode == 0)
+    if (OsclErrNone == leavecode)
     {
 
         // Update the filled length of the fragment
@@ -4342,16 +1814,26 @@
             {
 
                 channelSampleInfo* pcminfo = (channelSampleInfo*) FsiMemfrag.getMemFragPtr();
-                OSCL_ASSERT(pcminfo != NULL);
+                if (pcminfo != NULL)
+                {
+                    OSCL_ASSERT(pcminfo != NULL);
 
-                pcminfo->samplingRate    = iPCMSamplingRate;
-                pcminfo->desiredChannels = iNumberOfAudioChannels;
+                    pcminfo->samplingRate    = iPCMSamplingRate;
+                    pcminfo->desiredChannels = iNumberOfAudioChannels;
 
-                mediaDataOut->setFormatSpecificInfo(FsiMemfrag);
-                ((PVMFOMXAudioDecPort*)iOutPort)->pvmiSetPortFormatSpecificInfoSync(FsiMemfrag);
+                    mediaDataOut->setFormatSpecificInfo(FsiMemfrag);
+                    ((PVMFOMXDecPort*)iOutPort)->pvmiSetPortFormatSpecificInfoSync(FsiMemfrag);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                    (0, "PVMFOMXAudioDecNode::QueueOutputFrame - Problem allocating Output FSI"));
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return false; // this is going to make everything go out of scope
+                }
             }
             else
-
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                                 (0, "PVMFOMXAudioDecNode::QueueOutputFrame - Problem allocating Output FSI"));
@@ -4376,7 +1858,7 @@
             }
             else
             {
-                // we should not get here because we always check for whether queue is busy or not MC
+                // we should not get here because we always check for whether queue is busy or not
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVMFOMXAudioDecNode::QueueOutputFrame(): Send frame failed"));
                 return false;
@@ -4385,7 +1867,7 @@
         }
 
 
-    }//end of if (leavecode==0)
+    }//end of if (OsclErrNone == leavecode)
     else
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -4397,1059 +1879,8 @@
 
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////// Attach a MediaDataImpl wrapper (refcount, deallocator etc.)
-/////////////////////////////// to the output buffer /////////////////////////////////////////
-OsclSharedPtr<PVMFMediaDataImpl> PVMFOMXAudioDecNode::WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext)
-{
-    // wrap output buffer into a mediadataimpl
-    uint32 aligned_class_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
-    uint32 aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PVOMXBufferSharedPtrWrapperCombinedCleanupDA));
-    uint32 aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-    uint8 *my_ptr = (uint8*) oscl_malloc(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
-
-    if (my_ptr == NULL)
-    {
-        OsclSharedPtr<PVMFMediaDataImpl> null_buff(NULL, NULL);
-        return null_buff;
-    }
-    // create a deallocator and pass the buffer_allocator to it as well as pointer to data that needs to be returned to the mempool
-    PVOMXBufferSharedPtrWrapperCombinedCleanupDA *cleanup_ptr =
-        OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVOMXBufferSharedPtrWrapperCombinedCleanupDA(iOutBufMemoryPool, pContext));
-
-    // create the ref counter after the cleanup object (refcount is set to 1 at creation)
-    OsclRefCounterDA *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
-
-    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
-
-    PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer((void *) pData, // ptr to data
-                                        aDataLen, // capacity
-                                        my_refcnt));   // ref counter
-
-    OsclSharedPtr<PVMFMediaDataImpl> MediaDataImplOut(media_data_ptr, my_refcnt);
-
-    MediaDataImplOut->setMediaFragFilledLen(0, aDataLen);
-
-    return MediaDataImplOut;
-
-}
-//////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::SendBeginOfMediaStreamCommand()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendBeginOfMediaStreamCommand() In"));
-
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-    // Set the formatID, timestamp, sequenceNumber and streamID for the media message
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
-    sharedMediaCmdPtr->setTimestamp(iBOSTimestamp);
-    //reset the sequence number
-    sharedMediaCmdPtr->setSeqNum(iSeqNum);
-    sharedMediaCmdPtr->setStreamID(iStreamID);
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::SendBeginOfMediaStreamCommand() Outgoing queue busy"));
-        return false;
-    }
-
-    iSendBOS = false;
-
-    // reset repositioning related flags
-    iIsRepositionIdleDoneReceivedFromComponent = false;
-    iIsRepositionIdleRequestSentToComponent = false;
-    iIsRepositionExecRequestSentToComponent = false;
-    iIsRepositionExecDoneReceivedFromComponent = false;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendBeginOfMediaStreamCommand() BOS Sent StreamID %d", iStreamID));
-    return true;
-}
-////////////////////////////////////
-bool PVMFOMXAudioDecNode::SendEndOfTrackCommand(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendEndOfTrackCommand() In"));
-
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    sharedMediaCmdPtr->setTimestamp(iEndOfDataTimestamp);
-
-    // Set the sequence number
-    sharedMediaCmdPtr->setSeqNum(iSeqNum++);
-    // set stream ID
-    sharedMediaCmdPtr->setStreamID(iStreamID);
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
-    {
-        // this should not happen because we check for queue busy before calling this function
-        return false;
-    }
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::SendEndOfTrackCommand() Out"));
-    return true;
-}
-
 /////////////////////////////////////////////////////////////////////////////
-//The various command handlers call this routine when a command is complete.
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::CommandComplete(PVMFOMXAudioDecNodeCmdQ& aCmdQ, PVMFOMXAudioDecNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    //create response
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
-    PVMFSessionId session = aCmd.iSession;
-
-    //Erase the command from the queue.
-    aCmdQ.Erase(&aCmd);
-
-    //Report completion to the session observer.
-    ReportCmdCompleteEvent(session, resp);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoInit(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoInit() In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-        {
-            SetState(EPVMFNodeInitialized);
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            break;
-        }
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoPrepare(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OMX_STRING Role = NULL;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-        {
-            if (NULL == iInPort)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFFailure);
-            }
-
-            // Check format of input data
-
-            uint32 Format = ((PVMFOMXAudioDecPort*)iInPort)->iFormat;
-            switch (Format)
-            {
-                    // AAC
-                case PVMF_MPEG4_AUDIO:
-                case PVMF_LATM:
-                case PVMF_ADIF:
-                case PVMF_ASF_MPEG4_AUDIO:
-                case PVMF_AAC_SIZEHDR:
-                    Role = "audio_decoder.aac";
-                    break;
-
-                    // AMR
-                case PVMF_AMR_IF2:
-                case PVMF_AMR_IETF:
-                case PVMF_AMR_IETF_COMBINED:
-                case PVMF_AMRWB_IETF:
-                case PVMF_AMRWB_IETF_PAYLOAD:
-
-                    Role = "audio_decoder.amr";
-                    break;
-
-                case PVMF_MP3:
-
-                    Role = "audio_decoder.mp3";
-                    break;
-
-                case PVMF_WMA:
-                    Role = "audio_decoder.wma";
-                    break;
-
-                default:
-                    // Illegal codec specified.
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFAVCNode::DoPrepare() Input port format other then codec type"));
-                    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
-                    return;
-            }
-
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::Initializing OMX component and decoder for role %s", Role));
-
-            /* Set callback structure */
-            iCallbacks.EventHandler    = CallbackEventHandler_Audio; //event_handler;
-            iCallbacks.EmptyBufferDone = CallbackEmptyBufferDone_Audio; //empty_buffer_done;
-            iCallbacks.FillBufferDone  = CallbackFillBufferDone_Audio; //fill_buffer_done;
-
-
-            // determine components which can fit the role
-            // then, create the component. If multiple components fit the role,
-            // the first one registered will be selected. If that one fails to
-            // be created, the second one in the list is selected etc.
-            OMX_U32 num_comps = 0;
-            OMX_STRING *CompOfRole;
-            // call once to find out the number of components that can fit the role
-            PV_MasterOMX_GetComponentsOfRole(Role, &num_comps, NULL);
-            uint32 ii;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::DoPrepare(): There are %d components of role %s ", num_comps, Role));
-
-            if (num_comps > 0)
-            {
-                CompOfRole = (OMX_STRING *)oscl_malloc(num_comps * sizeof(OMX_STRING));
-
-                for (ii = 0; ii < num_comps; ii++)
-                    CompOfRole[ii] = (OMX_STRING) oscl_malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
-
-                // call 2nd time to get the component names
-                PV_MasterOMX_GetComponentsOfRole(Role, &num_comps, (OMX_U8 **)CompOfRole);
-
-                for (ii = 0; ii < num_comps; ii++)
-                {
-                    // try to create component
-                    err = PV_MasterOMX_GetHandle(&iOMXAudioDecoder, (OMX_STRING) CompOfRole[ii], (OMX_PTR) this, (OMX_CALLBACKTYPE *) & iCallbacks);
-                    // if successful, no need to continue
-                    if ((err == OMX_ErrorNone) && (iOMXAudioDecoder != NULL))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMFOMXAudioDecNode::DoPrepare(): Got Component %s handle ", CompOfRole[ii]));
-
-                        break;
-                    }
-                    else
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMFOMXAudioDecNode::DoPrepare(): Cannot get component %s handle, try another component if available", CompOfRole[ii]));
-                    }
-
-                }
-                // whether successful or not, need to free CompOfRoles
-                for (ii = 0; ii < num_comps; ii++)
-                {
-                    oscl_free(CompOfRole[ii]);
-                    CompOfRole[ii] = NULL;
-                }
-
-                oscl_free(CompOfRole);
-                // check if there was a problem
-                if ((err != OMX_ErrorNone) || (iOMXAudioDecoder == NULL))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::Can't get handle for decoder!"));
-                    iOMXAudioDecoder = NULL;
-                    CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                    return;
-                }
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::No component can handle role %s !", Role));
-                iOMXAudioDecoder = NULL;
-                CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                return;
-            }
-
-
-
-            if (!iOMXAudioDecoder)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            // GET CAPABILITY FLAGS FROM PV COMPONENT, IF this fails, use defaults
-            PV_OMXComponentCapabilityFlagsType Cap_flags;
-            err = OMX_GetParameter(iOMXAudioDecoder, (OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX, &Cap_flags);
-            if (err != OMX_ErrorNone)
-            {
-                SetDefaultCapabilityFlags();
-            }
-            else
-            {
-                iIsOMXComponentMultiThreaded =					 Cap_flags.iIsOMXComponentMultiThreaded;
-                iOMXComponentSupportsExternalInputBufferAlloc =	 Cap_flags.iOMXComponentSupportsExternalInputBufferAlloc;
-                iOMXComponentSupportsExternalOutputBufferAlloc = Cap_flags.iOMXComponentSupportsExternalOutputBufferAlloc;
-                iOMXComponentSupportsMovableInputBuffers =		 Cap_flags.iOMXComponentSupportsMovableInputBuffers;
-            }
-
-
-            // find out about parameters
-
-            if (!NegotiateComponentParameters())
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPrepare() Cannot get component parameters"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            // create active objects to handle callbacks in case of multithreaded implementation
-
-            // NOTE: CREATE THE THREADSAFE CALLBACK AOs REGARDLESS OF WHETHER MULTITHREADED COMPONENT OR NOT
-            //		If it is not multithreaded, we won't use them
-            //		The Flag iIsComponentMultiThreaded decides which mechanism is used for callbacks.
-            //		This flag is set by looking at component capabilities (or to true by default)
-
-            if (iThreadSafeHandlerEventHandler)
-            {
-                OSCL_DELETE(iThreadSafeHandlerEventHandler);
-                iThreadSafeHandlerEventHandler = NULL;
-            }
-            // substitute default parameters: observer(this node),queuedepth(3),nameAO for logging
-            // Get the priority of video dec node, and set the threadsafe callback AO priority to 1 higher
-            iThreadSafeHandlerEventHandler = OSCL_NEW(EventHandlerThreadSafeCallbackAO_Audio, (this, 10, "EventHandlerAO_Audio", Priority() + 2));
-
-            if (iThreadSafeHandlerEmptyBufferDone)
-            {
-                OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
-                iThreadSafeHandlerEmptyBufferDone = NULL;
-            }
-            // use queue depth of iNumInputBuffers to prevent deadlock
-            iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO_Audio, (this, iNumInputBuffers, "EmptyBufferDoneAO_Audio", Priority() + 1));
-
-            if (iThreadSafeHandlerFillBufferDone)
-            {
-                OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
-                iThreadSafeHandlerFillBufferDone = NULL;
-            }
-            // use queue depth of iNumOutputBuffers to prevent deadlock
-            iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO_Audio, (this, iNumOutputBuffers, "FillBufferDoneAO_Audio", Priority() + 1));
-
-            if ((iThreadSafeHandlerEventHandler == NULL) ||
-                    (iThreadSafeHandlerEmptyBufferDone == NULL) ||
-                    (iThreadSafeHandlerFillBufferDone == NULL)
-               )
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::Can't get threadsafe callbacks for decoder!"));
-                iOMXAudioDecoder = NULL;
-            }
-
-
-            iSetMarkerBitForEveryFrag = false;
-
-
-            // Init Decoder
-            iCurrentDecoderState = OMX_StateLoaded;
-
-            /* Change state to OMX_StateIdle from OMX_StateLoaded. */
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::DoPrepare(): Changing Component state Loaded -> Idle "));
-
-            err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-            if (err != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPrepare() Can't send StateSet command!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-
-            /* Allocate input buffers */
-            if (!CreateInputMemPool(iNumInputBuffers))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPrepare() Can't allocate mempool for input buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
-                                           iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                           iNumInputBuffers, // number of buffers
-                                           iOMXComponentInputBufferSize, // actual buffer size
-                                           iInputPortIndex, // port idx
-                                           iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
-                                           true // this is input
-                                          ))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPrepare() Component can't use input buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-
-            /* Allocate output buffers */
-            if (!CreateOutMemPool(iNumOutputBuffers))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPrepare() Can't allocate mempool for output buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
-                                           iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                           iNumOutputBuffers, // number of buffers
-                                           iOMXComponentOutputBufferSize, // actual buffer size
-                                           iOutputPortIndex, // port idx
-                                           iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
-                                           false // this is not input
-                                          ))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPrepare() Component can't use output buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-
-            //this command is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until it completes. We have to wait for
-            // OMX component state transition to complete
-
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-        }
-        break;
-
-        case EPVMFNodePrepared:
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoStart(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoStart() In"));
-
-    iDiagnosticsLogged = false;
-
-    PVMFStatus status = PVMFSuccess;
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodePrepared:
-        case EPVMFNodePaused:
-        {
-            //Get state of OpenMAX decoder
-            err = OMX_GetState(iOMXAudioDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-
-                                (0, "PVMFOMXAudioDecNode::DoStart(): Can't get State of decoder!"));
-
-                sState = OMX_StateInvalid;
-            }
-
-            if ((sState == OMX_StateIdle) || (sState == OMX_StatePause))
-            {
-                /* Change state to OMX_StateExecuting form OMX_StateIdle. */
-                // init the flag
-                if (!iDynamicReconfigInProgress)
-                {
-                    iDoNotSendOutputBuffersDownstreamFlag = false; // or if output was not being sent downstream due to state changes
-                    // re-enable sending output
-                    iDoNotSaveInputBuffersFlag = false;
-                }
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::DoStart() Changing Component state Idle->Executing"));
-
-                err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::DoStart(): Can't send StateSet command to decoder!"));
-
-                    status = PVMFErrInvalidState;
-                }
-
-            }
-            else
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoStart(): Decoder is not in the Idle or Pause state!"));
-
-                status = PVMFErrInvalidState;
-            }
-
-
-        }
-        break;
-
-        default:
-            status = PVMFErrInvalidState;
-            break;
-    }
-
-    if (status == PVMFErrInvalidState)
-    {
-        CommandComplete(iInputCommands, aCmd, status);
-    }
-    else
-    {
-        //this command is asynchronous.  move the command from
-        //the input command queue to the current command, where
-        //it will remain until it completes.
-        int32 err;
-        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-        if (err != OsclErrNone)
-        {
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-        }
-        iInputCommands.Erase(&aCmd);
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoStop(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoStop() In"));
-
-    LogDiagnostics();
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        case EPVMFNodePrepared:
-            // Stop data source
-            // This will also prevent execution of HandleProcessingState
-
-            iDataIn.Unbind();
-            // Clear queued messages in ports
-            if (iInPort)
-            {
-                iInPort->ClearMsgQueues();
-            }
-
-            if (iOutPort)
-            {
-                iOutPort->ClearMsgQueues();
-            }
-
-            // Clear the data flags
-
-            iEndOfDataReached = false;
-            iIsEOSSentToComponent = false;
-            iIsEOSReceivedFromComponent = false;
-
-
-            iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
-            iDoNotSaveInputBuffersFlag = true;
-
-            //Get state of OpenMAX decoder
-            err = OMX_GetState(iOMXAudioDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoStop(): Can't get State of decoder!"));
-
-                sState = OMX_StateInvalid;
-            }
-
-            if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
-            {
-                /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::DoStop() Changing Component State Executing->Idle or Pause->Idle"));
-
-                err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::DoStop(): Can't send StateSet command to decoder!"));
-
-                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                    break;
-                }
-
-                // prevent the node from sending more buffers etc.
-                // if port reconfiguration is in process, let the state remain one of the port config states
-                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
-                if (iProcessingState == EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode)
-                    iProcessingState = EPVMFOMXAudioDecNodeProcessingState_Stopping;
-
-                // indicate that stop cmd was sent
-                if (iDynamicReconfigInProgress)
-                {
-                    iStopCommandWasSentToComponent = true;
-                }
-
-
-
-            }
-            else
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoStop(): Decoder is not in the Executing or Pause state!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                break;
-            }
-
-            //this command is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until it completes.
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-            break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoFlush(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            //the flush is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until the flush completes.
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-            //Notify all ports to suspend their input
-            if (iInPort)
-            {
-                iInPort->SuspendInput();
-            }
-            if (iOutPort)
-            {
-                iOutPort->SuspendInput();
-            }
-            break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoPause(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoPause() In"));
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-
-
-            //Get state of OpenMAX decoder
-            err = OMX_GetState(iOMXAudioDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPause(): Can't get State of decoder!"));
-
-                sState = OMX_StateInvalid;
-            }
-
-            if (sState == OMX_StateExecuting)
-            {
-                /* Change state to OMX_StatePause from OMX_StateExecuting. */
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXAudioDecNode::DoPause() Changing Component State Executing->Pause"));
-
-                err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandStateSet, OMX_StatePause, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::DoPause(): Can't send StateSet command to decoder!"));
-
-                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                    break;
-                }
-
-                // prevent the node from sending more buffers etc.
-                // if port reconfiguration is in process, let the state remain one of the port config states
-                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
-                if (iProcessingState == EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode)
-                    iProcessingState = EPVMFOMXAudioDecNodeProcessingState_Pausing;
-
-                // indicate that pause cmd was sent
-                if (iDynamicReconfigInProgress)
-                {
-                    iPauseCommandWasSentToComponent = true;
-                }
-
-
-            }
-            else
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXAudioDecNode::DoPause(): Decoder is not in the Executing state!"));
-                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                break;
-            }
-
-            //this command is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until it completes.
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-            break;
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoReset(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::DoReset() In"));
-
-    LogDiagnostics();
-
-    switch (iInterfaceState)
-    {
-
-        case EPVMFNodeIdle:
-        case EPVMFNodeInitialized:
-        case EPVMFNodePrepared:
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        case EPVMFNodeError:
-
-        {
-            //Check if decoder is initilized
-            if (iOMXAudioDecoder != NULL)
-            {
-                //Get state of OpenMAX decoder
-                err = OMX_GetState(iOMXAudioDecoder, &sState);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::DoReset(): Can't get State of decoder!"));
-                    if (iResetInProgress)
-                    {
-                        // cmd is in current q
-                        iResetInProgress = false;
-                        if ((iCurrentCommand.size() > 0) &&
-                                (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-                           )
-                        {
-                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
-                        }
-
-                    }
-                    else
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                    }
-                    return;
-                }
-
-                if (sState == OMX_StateLoaded)
-                {
-                    // this is a value obtained by synchronous call to component. Either the component was
-                    // already in this state without node issuing any commands,
-                    // or perhaps we started the Reset, but the callback notification has not yet arrived.
-                    if (iResetInProgress)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXAudioDecNode::DoReset() OMX comp is in loaded state. Wait for official callback to change variables etc."));
-                        return;
-                    }
-                    else
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                        return;
-                    }
-                }
-
-                if (sState == OMX_StateIdle)
-                {
-
-
-                    //this command is asynchronous.  move the command from
-                    //the input command queue to the current command, where
-                    //it will remain until it is completed.
-                    if (!iResetInProgress)
-                    {
-                        int32 err;
-                        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-                        if (err != OsclErrNone)
-                        {
-                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
-                        }
-                        iInputCommands.Erase(&aCmd);
-
-                        iResetInProgress = true;
-                    }
-
-                    // if buffers aren't all back (due to timing issues with different callback AOs
-                    //		state change can be reported before all buffers are returned)
-                    if (iNumOutstandingInputBuffers > 0 || iNumOutstandingOutputBuffers > 0)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXAudioDecNode::DoReset() Waiting for %d input and-or %d output buffers", iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
-
-                        return;
-                    }
-
-                    if (!iResetMsgSent)
-                    {
-                        // We can come here only if all buffers are already back
-                        // Don't repeat any of this twice.
-                        /* Change state to OMX_StateLoaded form OMX_StateIdle. */
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXAudioDecNode::DoReset() Changing Component State Idle->Loaded"));
-
-                        err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandStateSet, OMX_StateLoaded, NULL);
-                        if (err != OMX_ErrorNone)
-                        {
-                            //Error condition report
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXAudioDecNode::DoReset(): Can't send StateSet command to decoder!"));
-                        }
-
-                        iResetMsgSent = true;
-
-
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXAudioDecNode::DoReset() freeing output buffers"));
-
-                        if (false == iOutputBuffersFreed)
-                        {
-                            if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
-                                                          iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                          iNumOutputBuffers, // number of buffers
-                                                          iOutputPortIndex, // port idx
-                                                          false // this is not input
-                                                         ))
-                            {
-                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                                (0, "PVMFOMXAudioDecNode::DoReset() Cannot free output buffers "));
-
-                                if (iResetInProgress)
-                                {
-                                    iResetInProgress = false;
-                                    if ((iCurrentCommand.size() > 0) &&
-                                            (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-                                       )
-                                    {
-                                        CommandComplete(iCurrentCommand, iCurrentCommand.front() , PVMFErrResource);
-                                    }
-                                }
-
-                            }
-
-                        }
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXAudioDecNode::DoReset() freeing input buffers "));
-                        if (false == iInputBuffersFreed)
-                        {
-                            if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
-                                                          iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                          iNumInputBuffers, // number of buffers
-                                                          iInputPortIndex, // port idx
-                                                          true // this is input
-                                                         ))
-                            {
-                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                                (0, "PVMFOMXAudioDecNode::DoReset() Cannot free input buffers "));
-
-                                if (iResetInProgress)
-                                {
-                                    iResetInProgress = false;
-                                    if ((iCurrentCommand.size() > 0) &&
-                                            (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-                                       )
-                                    {
-                                        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
-                                    }
-                                }
-
-
-                            }
-                        }
-
-
-
-                        iEndOfDataReached = false;
-                        iIsEOSSentToComponent = false;
-                        iIsEOSReceivedFromComponent = false;
-
-
-
-                        // also, perform Port deletion when the component replies with the command
-                        // complete, not right here
-                    } // end of if(iResetMsgSent)
-
-
-                    return;
-
-                }
-                else
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXAudioDecNode::DoReset(): Decoder is not in the Idle state!"));
-                    if (iResetInProgress)
-                    {
-                        iResetInProgress = false;
-                        if ((iCurrentCommand.size() > 0) &&
-                                (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-                           )
-                        {
-                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrInvalidState);
-                        }
-                    }
-                    else
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                    }
-                    break;
-                }//end of if (sState == OMX_StateIdle)
-            }//end of if (iOMXAudioDecoder != NULL)
-
-            //delete all ports and notify observer.
-            if (iInPort)
-            {
-                OSCL_DELETE(((PVMFOMXAudioDecPort*)iInPort));
-                iInPort = NULL;
-            }
-
-            if (iOutPort)
-            {
-                OSCL_DELETE(((PVMFOMXAudioDecPort*)iOutPort));
-                iOutPort = NULL;
-            }
-
-            iDataIn.Unbind();
-
-
-            // Reset the metadata key list
-            iAvailableMetadataKeys.clear();
-
-            iEndOfDataReached = false;
-            iIsEOSSentToComponent = false;
-            iIsEOSReceivedFromComponent = false;
-
-
-            iProcessingState = EPVMFOMXAudioDecNodeProcessingState_Idle;
-            //logoff & go back to Created state.
-            SetState(EPVMFNodeIdle);
-
-
-            if (iResetInProgress)
-            {
-                iResetInProgress = false;
-                if ((iCurrentCommand.size() > 0) &&
-                        (iCurrentCommand.front().iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-                   )
-                {
-                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-                }
-            }
-            else
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            }
-
-        }
-        break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoRequestPort(PVMFOMXAudioDecNodeCommand& aCmd)
+void PVMFOMXAudioDecNode::DoRequestPort(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXAudioDecNode::DoRequestPort() In"));
@@ -5459,20 +1890,20 @@
     int32 tag;
     OSCL_String* portconfig;
 
-    aCmd.PVMFOMXAudioDecNodeCommandBase::Parse(tag, portconfig);
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(tag, portconfig);
 
     PVMFPortInterface* port = NULL;
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     //validate the tag...
     switch (tag)
     {
-        case PVMF_OMX_AUDIO_DEC_NODE_PORT_TYPE_SOURCE:
+        case PVMF_OMX_DEC_NODE_PORT_TYPE_INPUT:
             if (iInPort)
             {
                 CommandComplete(iInputCommands, aCmd, PVMFFailure);
                 break;
             }
-            OSCL_TRY(leavecode, iInPort = OSCL_NEW(PVMFOMXAudioDecPort, ((int32)tag, this, "OMXAudioDecIn(Video)")););
+            OSCL_TRY(leavecode, iInPort = OSCL_NEW(PVMFOMXDecPort, ((int32)tag, this, (OMX_STRING)PVMF_OMX_AUDIO_DEC_INPUT_PORT_NAME)););
             if (leavecode || iInPort == NULL)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -5483,13 +1914,13 @@
             port = iInPort;
             break;
 
-        case PVMF_OMX_AUDIO_DEC_NODE_PORT_TYPE_SINK:
+        case PVMF_OMX_DEC_NODE_PORT_TYPE_OUTPUT:
             if (iOutPort)
             {
                 CommandComplete(iInputCommands, aCmd, PVMFFailure);
                 break;
             }
-            OSCL_TRY(leavecode, iOutPort = OSCL_NEW(PVMFOMXAudioDecPort, ((int32)tag, this, "OMXAudioDecOut(Video)")));
+            OSCL_TRY(leavecode, iOutPort = OSCL_NEW(PVMFOMXDecPort, ((int32)tag, this, (OMX_STRING)PVMF_OMX_AUDIO_DEC_OUTPUT_PORT_NAME)));
             if (leavecode || iOutPort == NULL)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -5513,21 +1944,23 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoReleasePort(PVMFOMXAudioDecNodeCommand& aCmd)
+void PVMFOMXAudioDecNode::DoReleasePort(PVMFOMXBaseDecNodeCommand& aCmd)
 {
-    PVMFOMXAudioDecPort* port;
-    aCmd.PVMFOMXAudioDecNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* temp;
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(temp);
+
+    PVMFOMXDecPort* port = (PVMFOMXDecPort*)temp;
 
     if (port != NULL && (port == iInPort || port == iOutPort))
     {
         if (port == iInPort)
         {
-            OSCL_DELETE(((PVMFOMXAudioDecPort*)iInPort));
+            OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
             iInPort = NULL;
         }
         else
         {
-            OSCL_DELETE(((PVMFOMXAudioDecPort*)iOutPort));
+            OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
             iOutPort = NULL;
         }
         //delete the port.
@@ -5541,7 +1974,7 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::DoGetNodeMetadataKey(PVMFOMXAudioDecNodeCommand& aCmd)
+PVMFStatus PVMFOMXAudioDecNode::DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXAudioDecNode::DoGetNodeMetadataKey() In"));
@@ -5551,7 +1984,7 @@
     int32 max_entries;
     char* query_key;
 
-    aCmd.PVMFOMXAudioDecNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
+    aCmd.PVMFOMXBaseDecNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
 
     // Check parameters
     if (keylistptr == NULL)
@@ -5569,7 +2002,7 @@
     // Copy the requested keys
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     for (uint32 lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
     {
         if (query_key == NULL)
@@ -5579,11 +2012,13 @@
             if (num_entries > starting_index)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                leavecode = OsclErrNone;
+                leavecode = PushKVPKey(iAvailableMetadataKeys[lcv], keylistptr);
+                if (OsclErrNone != leavecode)
+                {
+                    return PVMFErrNoMemory;
+                }
+
                 num_added++;
             }
         }
@@ -5597,11 +2032,13 @@
                 if (num_entries > starting_index)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    leavecode = OsclErrNone;
+                    leavecode = PushKVPKey(iAvailableMetadataKeys[lcv], keylistptr);
+                    if (OsclErrNone != leavecode)
+                    {
+                        return PVMFErrNoMemory;
+                    }
+
                     num_added++;
                 }
             }
@@ -5618,14 +2055,14 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::DoGetNodeMetadataValue(PVMFOMXAudioDecNodeCommand& aCmd)
+PVMFStatus PVMFOMXAudioDecNode::DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     PVMFMetadataList* keylistptr = NULL;
     Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
     uint32 starting_index;
     int32 max_entries;
 
-    aCmd.PVMFOMXAudioDecNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
+    aCmd.PVMFOMXBaseDecNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
 
     // Check the parameters
     if (keylistptr == NULL || valuelistptr == NULL)
@@ -5645,10 +2082,12 @@
     int32 numentriesadded = 0;
     for (uint32 lcv = 0; lcv < numkeys; lcv++)
     {
-        int32 leavecode = 0;
+        int32 leavecode = OsclErrNone;
+        int32 leavecode1 = OsclErrNone;
         PvmiKvp KeyVal;
         KeyVal.key = NULL;
         uint32 KeyLen = 0;
+
         if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_CHANNELS_KEY) == 0))
         {
             // PCM output channels
@@ -5665,12 +2104,9 @@
                     KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                     // Allocate memory for the string
-                    leavecode = 0;
-                    OSCL_TRY(leavecode,
-                             KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                            );
-
-                    if (leavecode == 0)
+                    leavecode = OsclErrNone;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                    if (OsclErrNone == leavecode)
                     {
                         // Copy the key string
                         oscl_strncpy(KeyVal.key, PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_CHANNELS_KEY, oscl_strlen(PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_CHANNELS_KEY) + 1);
@@ -5708,12 +2144,9 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                if (OsclErrNone == leavecode)
                 {
                     // Copy the key string
                     oscl_strncpy(KeyVal.key, PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_SAMPLERATE_KEY, oscl_strlen(PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_SAMPLERATE_KEY) + 1);
@@ -5739,17 +2172,17 @@
                  iInPort != NULL)
         {
             // Format
-            if ((((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_LATM) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_MPEG4_AUDIO) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_ADIF) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AAC_SIZEHDR) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IF2) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IETF) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IETF_COMBINED) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMRWB_IETF) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMRWB_IETF_PAYLOAD) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_MP3) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_WMA)
+            if ((((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MPEG4_AUDIO) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ADIF) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AAC_SIZEHDR) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IF2) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IETF) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB_IETF) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MP3) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMA)
 
                )
             {
@@ -5764,62 +2197,62 @@
                     KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*" and NULL terminator
 
                     uint32 valuelen = 0;
-                    switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
+                    if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM)
                     {
-                        case PVMF_LATM:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_LATM)) + 1; // Value string plus one for NULL terminator
-                            break;
-
-                        case PVMF_MPEG4_AUDIO:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO)) + 1; // Value string plus one for NULL terminator
-                            break;
-                        case PVMF_ADIF:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_ADIF)) + 1;
-                            break;
-
-                        case PVMF_AMR_IF2:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMR_IF2)) + 1;
-                            break;
-
-                        case PVMF_AMR_IETF:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMR_IETF)) + 1;
-                            break;
-
-                        case PVMF_AMR_IETF_COMBINED:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMR)) + 1;
-                            break;
-
-                        case PVMF_AMRWB_IETF:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMRWB_IETF)) + 1;
-                            break;
-
-                        case PVMF_AMRWB_IETF_PAYLOAD:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMRWB)) + 1;
-                            break;
-
-                        case PVMF_MP3:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_MP3)) + 1;
-                            break;
-
-                        case PVMF_WMA:
-                            valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_WMA)) + 1;
-                            break;
-
-                        default:
-                            // Should not enter here
-                            OSCL_ASSERT(false);
-                            valuelen = 1;
-                            break;
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_LATM)) + 1; // Value string plus one for NULL terminator
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MPEG4_AUDIO)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO)) + 1; // Value string plus one for NULL terminator
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ADIF)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_ADIF)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IF2)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMR_IF2)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IETF)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMR_IETF)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMR)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB_IETF)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMRWB_IETF)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_AMRWB)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MP3)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_MP3)) + 1;
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMA)
+                    {
+                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_WMA)) + 1;
+                    }
+                    else
+                    {
+                        // Should not enter here
+                        OSCL_ASSERT(false);
+                        valuelen = 1;
                     }
 
                     // Allocate memory for the strings
-                    leavecode = 0;
-                    OSCL_TRY(leavecode,
-                             KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                             KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                            );
+                    leavecode = OsclErrNone;
+                    KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                    if (OsclErrNone == leavecode)
+                    {
+                        KeyVal.value.pChar_value = (char*) AllocateKVPKeyArray(leavecode1, PVMI_KVPVALTYPE_CHARPTR, valuelen);
+                    }
 
-                    if (leavecode == 0)
+                    if (OsclErrNone == leavecode && OsclErrNone == leavecode1)
                     {
                         // Copy the key string
                         oscl_strncpy(KeyVal.key, PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_FORMAT_KEY, oscl_strlen(PVOMXAUDIODECMETADATA_CODECINFO_AUDIO_FORMAT_KEY) + 1);
@@ -5828,52 +2261,50 @@
                         oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
                         KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
                         // Copy the value
-                        switch (((PVMFOMXAudioDecPort*)iInPort)->iFormat)
+                        if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM)
                         {
-                            case PVMF_LATM:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_LATM), valuelen);
-                                break;
-
-                            case PVMF_MPEG4_AUDIO:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), valuelen);
-                                break;
-
-                            case PVMF_ADIF:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_ADIF), valuelen);
-                                break;
-
-                            case PVMF_AMR_IF2:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMR_IF2), valuelen);
-                                break;
-
-                            case PVMF_AMR_IETF:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMR_IETF), valuelen);
-                                break;
-
-                            case PVMF_AMR_IETF_COMBINED:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMR), valuelen);
-                                break;
-
-                            case PVMF_AMRWB_IETF:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMRWB_IETF), valuelen);
-                                break;
-
-                            case PVMF_AMRWB_IETF_PAYLOAD:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMRWB), valuelen);
-                                break;
-
-                            case PVMF_MP3:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_MP3), valuelen);
-                                break;
-
-                            case PVMF_WMA:
-                                oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_WMA), valuelen);
-                                break;
-
-                            default:
-                                // Should not enter here
-                                OSCL_ASSERT(false);
-                                break;
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_LATM), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MPEG4_AUDIO)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_MPEG4_AUDIO), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ADIF)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_ADIF), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IF2)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMR_IF2), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IETF)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMR_IETF), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMR), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB_IETF)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMRWB_IETF), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_AMRWB), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MP3)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_MP3), valuelen);
+                        }
+                        else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMA)
+                        {
+                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_WMA), valuelen);
+                        }
+                        else
+                        {
+                            // Should not enter here
+                            OSCL_ASSERT(false);
                         }
                         KeyVal.value.pChar_value[valuelen-1] = NULL_TERM_CHAR;
                         // Set the length and capacity
@@ -5900,9 +2331,9 @@
 
         if (KeyVal.key != NULL)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
-            if (leavecode != 0)
+            leavecode = OsclErrNone;
+            leavecode = PushKVP(KeyVal, *valuelistptr);
+            if (OsclErrNone != leavecode)
             {
                 switch (GetValTypeFromKeyString(KeyVal.key))
                 {
@@ -5951,7 +2382,7 @@
     {
         iInPort->ClearMsgQueues();
         iInPort->Disconnect();
-        OSCL_DELETE(((PVMFOMXAudioDecPort*)iInPort));
+        OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
         iInPort = NULL;
     }
 
@@ -5959,7 +2390,7 @@
     {
         iOutPort->ClearMsgQueues();
         iOutPort->Disconnect();
-        OSCL_DELETE(((PVMFOMXAudioDecPort*)iOutPort));
+        OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
         iOutPort = NULL;
     }
 
@@ -5967,426 +2398,32 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-// Clean Up Decoder
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::DeleteOMXAudioDecoder()
-{
-    OMX_ERRORTYPE  err;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::DeleteOMXAudioDecoder() In"));
-
-    if (iOMXAudioDecoder != NULL)
-    {
-        /* Free Component handle. */
-        err = PV_MasterOMX_FreeHandle(iOMXAudioDecoder);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::DeleteOMXAudioDecoder(): Can't free decoder's handle!"));
-        }
-        iOMXAudioDecoder = NULL;
-
-    }//end of if (iOMXAudioDecoder != NULL)
-
-
-    return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::ChangeNodeState(TPVMFNodeInterfaceState aNewState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ChangeNodeState() Changing state from %d to %d", iInterfaceState, aNewState));
-    iInterfaceState = aNewState;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::freechunkavailable(OsclAny *aContext)
-{
-
-    // check context to see whether input or output buffer was returned to the mempool
-    if (aContext == (OsclAny *) iInBufMemoryPool)
-    {
-
-        iNumOutstandingInputBuffers--;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::freechunkavailable() Memory chunk in INPUT mempool was deallocated, %d out of %d now available", iNumInputBuffers - iNumOutstandingInputBuffers, iNumInputBuffers));
-
-        // notification only works once.
-        // If there are multiple buffers coming back in a row, make sure to set the notification
-        // flag in the mempool again, so that next buffer also causes notification
-        iInBufMemoryPool->notifyfreechunkavailable(*this, aContext);
-
-    }
-    else if (aContext == (OsclAny *) iOutBufMemoryPool)
-    {
-
-        iNumOutstandingOutputBuffers--;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::freechunkavailable() Memory chunk in OUTPUT mempool was deallocated, %d out of %d now available", iNumOutputBuffers - iNumOutstandingOutputBuffers, iNumOutputBuffers));
-
-        // notification only works once.
-        // If there are multiple buffers coming back in a row, make sure to set the notification
-        // flag in the mempool again, so that next buffer also causes notification
-        iOutBufMemoryPool->notifyfreechunkavailable(*this, aContext);
-
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::freechunkavailable() UNKNOWN mempool "));
-
-    }
-
-    // reschedule
-    if (IsAdded())
-        RunIfNotReady();
-
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::HandlePortActivity(const PVMFPortActivity &aActivity)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "0x%x PVMFOMXAudioDecNode::PortActivity: port=0x%x, type=%d",
-                     this, aActivity.iPort, aActivity.iType));
-
-    switch (aActivity.iType)
-    {
-        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-            //An outgoing message was queued on this port.
-            //We only need to queue a port activity event on the
-            //first message.  Additional events will be queued during
-            //the port processing as needed.
-            if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
-            {
-                //wake up the AO to process the port activity event.
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXAudioDecNode::PortActivity: IncomingMsgQueueSize=%d", aActivity.iPort->IncomingMsgQueueSize()));
-            if (aActivity.iPort->IncomingMsgQueueSize() == 1)
-            {
-                //wake up the AO to process the port activity event.
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            if (iProcessingState == EPVMFOMXAudioDecNodeProcessingState_WaitForOutgoingQueue)
-            {
-                iProcessingState = EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECT:
-            //nothing needed.
-            break;
-
-        case PVMF_PORT_ACTIVITY_DISCONNECT:
-            //clear the node input data when either port is disconnected.
-
-            iDataIn.Unbind();
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-            // The connected port has become busy (its incoming queue is
-            // busy).
-            // No action is needed here-- the port processing code
-            // checks for connected port busy during data processing.
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-            // The connected port has transitioned from Busy to Ready to Receive.
-            // It's time to start processing outgoing messages again.
-
-            //iProcessingState should transition from WaitForOutputPort to ReadyToDecode
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "0x%x PVMFOMXAudioDecNode::PortActivity: Connected port is now ready", this));
-            RunIfNotReady();
-            break;
-
-        default:
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoCancelAllCommands(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::DoCancelAllCommands"));
-
-    //first cancel the current command if any
-    {
-        while (!iCurrentCommand.empty())
-        {
-            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
-        }
-
-    }
-
-    //next cancel all queued commands
-    {
-        //start at element 1 since this cancel command is element 0.
-        while (iInputCommands.size() > 1)
-        {
-            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
-        }
-    }
-
-    if (iResetInProgress && !iResetMsgSent)
-    {
-        // if reset is started but reset msg has not been sent, we can cancel reset
-        // as if nothing happened. Otherwise, the callback will set the flag back to false
-        iResetInProgress = false;
-    }
-    //finally, report cancel complete.
-    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoCancelCommand(PVMFOMXAudioDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::DoCancelCommand"));
-
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.PVMFOMXAudioDecNodeCommandBase::Parse(id);
-
-    //first check "current" command if any
-    {
-        PVMFOMXAudioDecNodeCommand* cmd = iCurrentCommand.FindById(id);
-        if (cmd)
-        {
-
-            // if reset is being canceled:
-            if (cmd->iCmd == PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_RESET)
-            {
-                if (iResetInProgress && !iResetMsgSent)
-                {
-                    // if reset is started but reset msg has not been sent, we can cancel reset
-                    // as if nothing happened. Otherwise, the callback will set the flag back to false
-                    iResetInProgress = false;
-                }
-            }
-            //cancel the queued command
-            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PVMFOMXAudioDecNodeCommand* cmd = iInputCommands.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoQueryUuid(PVMFOMXAudioDecNodeCommand& aCmd)
+void PVMFOMXAudioDecNode::DoQueryUuid(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     //This node supports Query UUID from any state
 
     OSCL_String* mimetype;
     Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
     bool exactmatch;
-    aCmd.PVMFOMXAudioDecNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
 
     //Try to match the input mimetype against any of
     //the custom interfaces for this node
 
     //Match against custom interface1...
-    if (*mimetype == PVMF_OMX_AUDIO_DEC_NODE_CUSTOM1_MIMETYPE
+    if (*mimetype == PVMF_OMX_BASE_DEC_NODE_CUSTOM1_MIMETYPE
             //also match against base mimetypes for custom interface1,
             //unless exactmatch is set.
             || (!exactmatch && *mimetype == PVMF_OMX_AUDIO_DEC_NODE_MIMETYPE)
             || (!exactmatch && *mimetype == PVMF_BASEMIMETYPE))
     {
 
-        PVUuid uuid(PVMF_OMX_AUDIO_DEC_NODE_CUSTOM1_UUID);
+        PVUuid uuid(PVMF_OMX_BASE_DEC_NODE_CUSTOM1_UUID);
         uuidvec->push_back(uuid);
     }
     CommandComplete(iInputCommands, aCmd, PVMFSuccess);
 }
 
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::DoQueryInterface(PVMFOMXAudioDecNodeCommand&  aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::DoQueryInterface"));
-    PVUuid* uuid;
-    PVInterface** ptr;
-    aCmd.PVMFOMXAudioDecNodeCommandBase::Parse(uuid, ptr);
-
-    if (*uuid == PVUuid(PVMF_OMX_AUDIO_DEC_NODE_CUSTOM1_UUID))
-    {
-        addRef();
-        *ptr = (PVMFOMXAudioDecNodeExtensionInterface*)this;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else if (*uuid == PVUuid(KPVMFMetadataExtensionUuid))
-    {
-        addRef();
-        *ptr = (PVMFMetadataExtensionInterface*)this;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else if (*uuid == PVUuid(PVMI_CAPABILITY_AND_CONFIG_PVUUID))
-    {
-        addRef();
-        *ptr = (PvmiCapabilityAndConfig*)this;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else
-    {
-        //not supported
-        *ptr = NULL;
-        CommandComplete(iInputCommands, aCmd, PVMFFailure);
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::removeRef()
-{
-    --iExtensionRefCount;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    PVUuid my_uuid(PVMF_OMX_AUDIO_DEC_NODE_CUSTOM1_UUID);
-    if (uuid == my_uuid)
-    {
-        PVMFOMXAudioDecNodeExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFOMXAudioDecNodeExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-        return true;
-    }
-    else if (uuid == KPVMFMetadataExtensionUuid)
-    {
-        PVMFMetadataExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-        return true;
-    }
-    return false;
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecNode::HandleRepositioning()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::HandleRepositioning() IN"));
-
-
-    // 1) Send Flush command to component for both input and output ports
-    // 2) "Wait" until component flushes both ports
-    // 3) Resume
-    OMX_ERRORTYPE  err = OMX_ErrorNone;
-    OMX_STATETYPE sState = OMX_StateInvalid;
-
-
-    if (!iIsRepositioningRequestSentToComponent)
-    {
-
-        // first check the state (if executing or paused, continue)
-        err = OMX_GetState(iOMXAudioDecoder, &sState);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::HandleRepositioning(): Can't get State of decoder - trying to send reposition request!"));
-
-            sState = OMX_StateInvalid;
-            ReportErrorEvent(PVMFErrResourceConfiguration);
-            ChangeNodeState(EPVMFNodeError);
-            return false;
-        }
-
-        if ((sState != OMX_StateExecuting) && (sState != OMX_StatePause))
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXAudioDecNode::HandleRepositioning() Component State is not executing or paused, do not proceed with repositioning"));
-
-            return true;
-
-        }
-
-
-        iIsRepositioningRequestSentToComponent = true; // prevent sending requests multiple times
-        iIsInputPortFlushed = false;	// flag that will be set to true once component flushes the port
-        iIsOutputPortFlushed = false;
-        iDoNotSendOutputBuffersDownstreamFlag = true;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::HandleRepositioning() Sending Flush command to component"));
-
-        // send command to flush all ports (arg is -1)
-        err = OMX_SendCommand(iOMXAudioDecoder, OMX_CommandFlush, -1, NULL);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXAudioDecNode::HandleRepositioning(): Can't send flush command  - trying to send reposition request!"));
-
-            sState = OMX_StateInvalid;
-            ReportErrorEvent(PVMFErrResourceConfiguration);
-            ChangeNodeState(EPVMFNodeError);
-            return false;
-        }
-
-    }
-
-    if (iIsRepositionDoneReceivedFromComponent)
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXAudioDecNode::HandleRepositioning() Component has flushed both ports, and is done repositioning"));
-
-        iIsRepositioningRequestSentToComponent = false; // enable sending requests again
-        iIsRepositionDoneReceivedFromComponent = false;
-        iIsInputPortFlushed = false;
-        iIsOutputPortFlushed = false;
-
-        iDoNotSendOutputBuffersDownstreamFlag = false;
-        return true;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXAudioDecNode::HandleRepositioning() Component is not yet done repositioning "));
-
-    return false;
-}
-
-
-
 PVMFStatus PVMFOMXAudioDecNode::CreateLATMParser()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFOMXAudioDecNode::CreateLATMParser() In"));
@@ -6458,114 +2495,6 @@
 
 }
 
-///////////////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    OSCL_UNUSED_ARG(aObserver);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::setObserver()"));
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::setObserver() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-PVMFStatus PVMFOMXAudioDecNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::getParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
-}
-
-
-PVMFStatus PVMFOMXAudioDecNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::releaseParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    return DoCapConfigReleaseParameters(aParameters, aNumElements);
-}
-
-
-void PVMFOMXAudioDecNode::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::createContext()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::createContext() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-void PVMFOMXAudioDecNode::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::setContextParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumParamElements);
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::setContextParameters() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-void PVMFOMXAudioDecNode::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DeleteContext()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::DeleteContext() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-void PVMFOMXAudioDecNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::setParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    // Complete the request synchronously
-    DoCapConfigSetParameters(aParameters, aNumElements, aRetKVP);
-}
-
-
-PVMFCommandId PVMFOMXAudioDecNode::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::setParametersAsync()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    OSCL_UNUSED_ARG(aRetKVP);
-    OSCL_UNUSED_ARG(aContext);
-
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::setParametersAsync() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-    return 0;
-}
-
-
-uint32 PVMFOMXAudioDecNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::getCapabilityMetric()"));
-    OSCL_UNUSED_ARG(aSession);
-    // Not supported so return 0
-    return 0;
-}
-
-
-PVMFStatus PVMFOMXAudioDecNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::verifyParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    return DoCapConfigVerifyParameters(aParameters, aNumElements);
-}
-
-
 /////////////////////////////////////////////////////////////////////////////
 uint32 PVMFOMXAudioDecNode::GetNumMetadataValues(PVMFMetadataList& aKeyList)
 {
@@ -6600,16 +2529,16 @@
                  iInPort != NULL)
         {
             // Format
-            if ((((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_LATM) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_MPEG4_AUDIO) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_ADIF) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IF2) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IETF) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMR_IETF_COMBINED) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMRWB_IETF) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_AMRWB_IETF_PAYLOAD) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_MP3) ||
-                    (((PVMFOMXAudioDecPort*)iInPort)->iFormat == PVMF_WMA)
+            if ((((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_LATM) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MPEG4_AUDIO) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_ADIF) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IF2) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR_IETF) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB_IETF) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_MP3) ||
+                    (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMA)
 
                )
 
@@ -6622,152 +2551,6 @@
     return numvalentries;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries, char* query_key, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNodeCommand::GetNodeMetadataKeys() called"));
-
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommand::Construct(aSessionId, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_GETNODEMETADATAKEY, &aKeyList, starting_index, max_entries, query_key, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXAudioDecNode::GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNodeCommand::GetNodeMetadataValue() called"));
-
-    PVMFOMXAudioDecNodeCommand cmd;
-    cmd.PVMFOMXAudioDecNodeCommand::Construct(aSessionId, PVMFOMXAudioDecNodeCommand::PVOMXAUDIODEC_NODE_CMD_GETNODEMETADATAVALUE, &aKeyList, &aValueList, starting_index, max_entries, aContext);
-    return QueueCommandL(cmd);
-}
-
-// From PVMFMetadataExtensionInterface
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::ReleaseNodeMetadataKeys(PVMFMetadataList& , uint32 , uint32)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ReleaseNodeMetadataKeys() called"));
-    //nothing needed-- there's no dynamic allocation in this node's key list
-    return PVMFSuccess;
-}
-
-// From PVMFMetadataExtensionInterface
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 start, uint32 end)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::ReleaseNodeMetadataValues() called"));
-
-    if (aValueList.size() == 0 || start < 0 || start > end)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::ReleaseNodeMetadataValues() Invalid start/end index"));
-        return PVMFErrArgument;
-    }
-
-    if (end >= aValueList.size())
-    {
-        end = aValueList.size() - 1;
-    }
-
-    for (uint32 i = start; i <= end; i++)
-    {
-        if (aValueList[i].key != NULL)
-        {
-            switch (GetValTypeFromKeyString(aValueList[i].key))
-            {
-                case PVMI_KVPVALTYPE_CHARPTR:
-                    if (aValueList[i].value.pChar_value != NULL)
-                    {
-                        OSCL_ARRAY_DELETE(aValueList[i].value.pChar_value);
-                        aValueList[i].value.pChar_value = NULL;
-                    }
-                    break;
-
-                case PVMI_KVPVALTYPE_UINT32:
-                case PVMI_KVPVALTYPE_UINT8:
-                    // No memory to free for these valtypes
-                    break;
-
-                default:
-                    // Should not get a value that wasn't created from here
-                    break;
-            }
-
-            OSCL_ARRAY_DELETE(aValueList[i].key);
-            aValueList[i].key = NULL;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-// CAPABILITY CONFIG PRIVATE
-PVMFStatus PVMFOMXAudioDecNode::DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoCapConfigGetParametersSync() In"));
-    OSCL_UNUSED_ARG(aContext);
-
-    return PVMFFailure;
-}
-
-
-PVMFStatus PVMFOMXAudioDecNode::DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoCapConfigReleaseParameters() Out"));
-    return PVMFSuccess;
-}
-
-
-void PVMFOMXAudioDecNode::DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
-{
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoCapConfigSetParameters() Out"));
-}
-
-
-PVMFStatus PVMFOMXAudioDecNode::DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoCapConfigVerifyParameters() In"));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoCapConfigVerifyParameters() Out"));
-    return PVMFSuccess;
-}
-
-
-
-PVMFStatus PVMFOMXAudioDecNode::DoGetVideoDecNodeParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoGetVideoDecNodeParameter() In"));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoGetVideoDecNodeParameter() Out"));
-    return PVMFSuccess;
-}
-
-
-
-PVMFStatus PVMFOMXAudioDecNode::DoVerifyAndSetVideoDecNodeParameter(PvmiKvp& aParameter, bool aSetParam)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoVerifyAndSetVideoDecNodeParameter() In"));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::DoVerifyAndSetVideoDecNodeParameter() Out"));
-    return PVMFSuccess;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecNode::LogDiagnostics()
-{
-    if (iDiagnosticsLogged == false)
-    {
-        iDiagnosticsLogged = true;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"));
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFOMXAudioDecNode - Number of YUV Frames Sent = %d", iSeqNum));
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFOMXAudioDecNode - TS of last decoded video frame = %d", iOutTimeStamp));
-    }
-}
 
 // needed for WMA parameter verification
 bool PVMFOMXAudioDecNode::VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
@@ -6776,7 +2559,7 @@
     OSCL_UNUSED_ARG(num_elements);
     if (pv_mime_strcmp(aParameters->key, PVMF_BITRATE_VALUE_KEY) == 0)
     {
-        if (((PVMFOMXAudioDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_BITRATE_VALUE_KEY, &(aParameters->value.uint32_value)) != PVMFSuccess)
+        if (((PVMFOMXDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_BITRATE_VALUE_KEY, &(aParameters->value.uint32_value)) != PVMFSuccess)
         {
             return false;
         }
@@ -6787,11 +2570,143 @@
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXAudioDecNode::VerifyParametersSync() - Unsupported Key"));
         OSCL_ASSERT(false);
     }
-    return true;
+
+    bool cap_exchange_status = false;
+
+    pvAudioConfigParserInputs aInputs;
+    pvAudioConfigParserOutputs aOutputs;
+
+    aInputs.inPtr = (uint8*)(aParameters->value.key_specific_value);
+    aInputs.inBytes = (int32)aParameters->capacity;
+    aInputs.iMimeType = PVMF_MIME_WMA;
+
+
+    if (aInputs.inBytes == 0 || aInputs.inPtr == NULL)
+    {
+        return cap_exchange_status;
+    }
+
+
+    int32 status;
+    status = pv_audio_config_parser(&aInputs, &aOutputs);
+    if (0 != status)
+    {
+        cap_exchange_status = true;
+
+        iPCMSamplingRate = aOutputs.SamplesPerSec;
+        iNumberOfAudioChannels = aOutputs.Channels;
+
+        if ((iNumberOfAudioChannels != 1 && iNumberOfAudioChannels != 2) ||
+                (iPCMSamplingRate <= 0))
+        {
+            cap_exchange_status = false;
+        }
+    }
+
+    return cap_exchange_status;
+
 }
 
 
+PVMFStatus PVMFOMXAudioDecNode::DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements)
+{
+    OSCL_UNUSED_ARG(aNumElements);
 
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXAudioDecNode::DoCapConfigVerifyParameters() In\n"));
+
+    pvAudioConfigParserInputs aInputs;
+    pvAudioConfigParserOutputs aOutputs;
+
+    aInputs.inPtr = (uint8*)(aParameters->value.key_specific_value);
+    aInputs.inBytes = (int32)aParameters->capacity;
+    aInputs.iMimeType = iNodeConfig.iMimeType;
+
+    if (aInputs.inBytes == 0 || aInputs.inPtr == NULL)
+    {
+        // in case of following formats - config codec data is expected to
+        // be present in the query. If not, config parser cannot be called
+        if (aInputs.iMimeType == PVMF_MIME_WMA ||
+                aInputs.iMimeType == PVMF_MIME_MPEG4_AUDIO ||
+                aInputs.iMimeType == PVMF_MIME_LATM ||
+                aInputs.iMimeType == PVMF_MIME_ADIF ||
+                aInputs.iMimeType == PVMF_MIME_ASF_MPEG4_AUDIO ||
+                aInputs.iMimeType == PVMF_MIME_AAC_SIZEHDR)
+        {
+            if (aInputs.iMimeType == PVMF_MIME_LATM)
+            {
+                return PVMFErrNotSupported;
+            }
+            else
+            {
+                // DV TO_DO: remove this
+                OSCL_LEAVE(OsclErrNotSupported);
+            }
+        }
+    }
+
+
+    int16 status;
+    status = pv_audio_config_parser(&aInputs, &aOutputs);
+    if (status == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::DoCapConfigVerifyParameters() ->pv_audio_config_parser() PVMFErrNotSupported\n"));
+        return PVMFErrNotSupported;
+    }
+
+    if (aInputs.iMimeType == PVMF_MIME_WMA)
+    {
+        iNumberOfAudioChannels = aOutputs.Channels;
+        iPCMSamplingRate = aOutputs.SamplesPerSec;
+    }
+    else if (aInputs.iMimeType == PVMF_MIME_MPEG4_AUDIO ||
+             aInputs.iMimeType == PVMF_MIME_LATM ||
+             aInputs.iMimeType == PVMF_MIME_ADIF ||
+             aInputs.iMimeType == PVMF_MIME_ASF_MPEG4_AUDIO ||
+             aInputs.iMimeType == PVMF_MIME_AAC_SIZEHDR)
+    {
+        iNumberOfAudioChannels = aOutputs.Channels;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXAudioDecNode::DoCapConfigVerifyParameters() Out\n"));
+    return PVMFSuccess;
+}
+
+void PVMFOMXAudioDecNode::DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXAudioDecNode::DoCapConfigSetParameters() In\n"));
+    OSCL_UNUSED_ARG(aNumElements);
+    OSCL_UNUSED_ARG(aRetKVP);
+
+    // find out if the audio dec format key is used for the query
+    if (pv_mime_strcmp(aParameters->key, PVMF_AUDIO_DEC_FORMAT_TYPE_VALUE_KEY) == 0)
+    {
+        // set the mime type if audio format is being used
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::DoCapConfigSetParameters() set audio dec format type to %s\n", aParameters->value.pChar_value));
+
+        iNodeConfig.iMimeType = aParameters->value.pChar_value;
+    }
+
+    else
+    {
+        // For now, ignore other queries
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXAudioDecNode::DoCapConfigSetParameters() Key not used"));
+
+        // indicate "error" by setting return KVP to the original
+        aRetKVP = aParameters;
+    }
+
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXAudioDecNode::DoCapConfigSetParameters() Out\n"));
+}
 
 
 
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.h b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.h
index 0c1281f..7e7295a 100644
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.h
+++ b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,91 +18,14 @@
 #ifndef PVMF_OMX_AUDIODEC_NODE_H_INCLUDED
 #define PVMF_OMX_AUDIODEC_NODE_H_INCLUDED
 
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef PVMF_MEMPOOL_H_INCLUDED
-#include "pvmf_mempool.h"
-#endif
-
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-
-#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
-#include "pvmf_pool_buffer_allocator.h"
-#endif
-
-
-#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
-#include "pvmf_pool_buffer_allocator.h"
-#endif
-
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
+#ifndef PVMF_OMX_BASEDEC_NODE_H_INCLUDED
+#include "pvmf_omx_basedec_node.h"
 #endif
 
 #ifndef PVMF_OMX_AUDIODEC_PORT_H_INCLUDED
-#include "pvmf_omx_audiodec_port.h"
+#include "pvmf_omx_basedec_port.h"
 #endif
 
-#ifndef PVMF_OMX_AUDIODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-#include "pvmf_omx_audiodec_node_extension_interface.h"
-#endif
-
-#ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
-#include "pvmf_meta_data_extension.h"
-#endif
-
-#ifndef PV_MIME_STRING_UTILS_H_INCLUDED
-#include "pv_mime_string_utils.h"
-#endif
-
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef PVMF_OMX_AUDIODEC_CALLBACKS_H_INCLUDED
-#include "pvmf_omx_audiodec_callbacks.h"
-#endif
-
-
-#ifndef OSCLCONFIG_IO_H_INCLUDED
-#include "osclconfig_io.h"
-#endif
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
-#endif
-#endif
 
 #define PVMFOMXAUDIODECNODE_NUM_CMD_IN_POOL 8
 #define PVOMXAUDIODEC_DEFAULT_SAMPLINGRATE 48000
@@ -118,237 +41,25 @@
 };
 
 
-typedef struct OutputBufCtrlStruct_Audio
-{
-    OMX_BUFFERHEADERTYPE *pBufHdr;
-}OutputBufCtrlStruct_Audio;
-
-typedef struct InputBufCtrlStruct_Audio
-{
-    OMX_BUFFERHEADERTYPE *pBufHdr;
-    PVMFSharedMediaDataPtr pMediaData;
-} InputBufCtrlStruct_Audio;
-
-
 // fwd class declaration
-class PVLogger;
 class PV_LATM_Parser;
-//memory allocator type for this node.
-typedef OsclMemAllocator PVMFOMXAudioDecNodeAllocator;
-
-
-// CALLBACK PROTOTYPES
-OMX_ERRORTYPE CallbackEventHandler_Audio(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_EVENTTYPE aEvent,
-        OMX_OUT OMX_U32 aData1,
-        OMX_OUT OMX_U32 aData2,
-        OMX_OUT OMX_PTR aEventData);
-
-OMX_ERRORTYPE CallbackEmptyBufferDone_Audio(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-OMX_ERRORTYPE CallbackFillBufferDone_Audio(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-
-
-//Default values for number of Input/Output buffers. If the component needs more than this, it will be
-// negotiated. If the component does not need more than this number, the default is used
-#define NUMBER_INPUT_BUFFER 5
-#define NUMBER_OUTPUT_BUFFER 9
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////
-/////////////////////////
-/////////////////////////
-// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
-//						1) Deallocates the underlying output buffer
-//						2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
-//					  Deallocator is created as part of the wrapper, and travels with the buffer wrapper
-
-class PVOMXBufferSharedPtrWrapperCombinedCleanupDA : public OsclDestructDealloc
-{
-    public:
-        PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
-                buf_alloc(allocator), ptr_to_data_to_dealloc(pMempoolData) {};
-        virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
-
-        virtual void destruct_and_dealloc(OsclAny* ptr)
-        {
-            // call buffer deallocator
-            if (buf_alloc != NULL)
-            {
-                buf_alloc->deallocate(ptr_to_data_to_dealloc);
-            }
-
-            // finally, free the shared ptr wrapper memory
-            oscl_free(ptr);
-        }
-
-    private:
-        Oscl_DefAlloc* buf_alloc;
-        void *ptr_to_data_to_dealloc;
-};
-
-
-#define PVMFOMXAudioDecNodeCommandBase PVMFGenericNodeCommand<PVMFOMXAudioDecNodeAllocator>  // to remove typedef warning on symbian
-
-class PVMFOMXAudioDecNodeCommand: public PVMFOMXAudioDecNodeCommandBase
-{
-    public:
-        //constructor for Custom2 command
-        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
-        {
-            PVMFOMXAudioDecNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)arg1;
-            iParam2 = (OsclAny*)arg2;
-            iParam3 = (OsclAny*) & arg3;
-        }
-        void Parse(int32&arg1, int32&arg2, int32*&arg3)
-        {
-            arg1 = (int32)iParam1;
-            arg2 = (int32)iParam2;
-            arg3 = (int32*)iParam3;
-        }
-
-        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, uint32 aStartIndex, int32 aMaxEntries, char* aQueryKey, const OsclAny* aContext)
-        {
-            PVMFOMXAudioDecNodeCommandBase::Construct(s, cmd, aContext);
-            iStartIndex = aStartIndex;
-            iMaxEntries = aMaxEntries;
-
-            if (aQueryKey == NULL)
-            {
-                query_key[0] = 0;
-            }
-            else
-            {
-                if (aQueryKey != NULL)
-                    oscl_strncpy(query_key, aQueryKey, oscl_strlen(aQueryKey) + 1);
-            }
-
-            iParam1 = (OsclAny*)aKeyList;
-            iParam2 = NULL;
-            iParam3 = NULL;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        }
-
-        void Parse(PVMFMetadataList*& MetaDataListPtr, uint32 &aStartingIndex, int32 &aMaxEntries, char*&aQueryKey)
-        {
-            MetaDataListPtr = (PVMFMetadataList*)iParam1;
-            aStartingIndex = iStartIndex;
-            aMaxEntries = iMaxEntries;
-            if (query_key[0] == 0)
-            {
-                aQueryKey = NULL;
-            }
-            else
-            {
-                aQueryKey = query_key;
-            }
-        }
-
-        // Constructor and parser for GetNodeMetadataValue
-        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, uint32 aStartIndex, int32 aMaxEntries, const OsclAny* aContext)
-        {
-            PVMFOMXAudioDecNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aKeyList;
-            iParam2 = (OsclAny*)aValueList;
-
-            iStartIndex = aStartIndex;
-            iMaxEntries = aMaxEntries;
-
-            iParam3 = NULL;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        }
-        void Parse(PVMFMetadataList* &aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList, uint32 &aStartingIndex, int32 &aMaxEntries)
-        {
-            aKeyList = (PVMFMetadataList*)iParam1;
-            aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
-            aStartingIndex = iStartIndex;
-            aMaxEntries = iMaxEntries;
-        }
-
-        virtual bool hipri()
-        {	//this routine identifies commands that need to
-            //go at the front of the queue.  derived command
-            //classes can override it if needed.
-            return (iCmd == PVOMXAUDIODEC_NODE_CMD_CANCELALL
-                    || iCmd == PVOMXAUDIODEC_NODE_CMD_CANCELCMD);
-        }
-
-        enum PVOMXAudioDecNodeCmdType
-        {
-            PVOMXAUDIODEC_NODE_CMD_QUERYUUID,
-            PVOMXAUDIODEC_NODE_CMD_QUERYINTERFACE,
-            PVOMXAUDIODEC_NODE_CMD_INIT,
-            PVOMXAUDIODEC_NODE_CMD_PREPARE,
-            PVOMXAUDIODEC_NODE_CMD_REQUESTPORT,
-            PVOMXAUDIODEC_NODE_CMD_START,
-            PVOMXAUDIODEC_NODE_CMD_PAUSE,
-            PVOMXAUDIODEC_NODE_CMD_STOP,
-            PVOMXAUDIODEC_NODE_CMD_FLUSH,
-            PVOMXAUDIODEC_NODE_CMD_RELEASEPORT,
-            PVOMXAUDIODEC_NODE_CMD_RESET,
-            PVOMXAUDIODEC_NODE_CMD_CANCELCMD,
-            PVOMXAUDIODEC_NODE_CMD_CANCELALL,
-            PVOMXAUDIODEC_NODE_CMD_INVALID,
-            PVOMXAUDIODEC_NODE_CMD_GETNODEMETADATAKEY,
-            PVOMXAUDIODEC_NODE_CMD_GETNODEMETADATAVALUE
-        };
-
-    private:
-        uint32 iStartIndex;
-        uint32 iMaxEntries;
-        char query_key[256];
-
-};
-
-//Default vector reserve size
-#define PVMF_OMXAUDIODEC_NODE_COMMAND_VECTOR_RESERVE 10
-
-//Starting value for command IDs
-#define PVMF_OMXAUDIODEC_NODE_COMMAND_ID_START 6000
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////
-//CAPABILITY AND CONFIG
-
-// Structure to hold the key string info for
-// videodecnode's capability-and-config
-struct PVOMXAudioDecNodeKeyStringData
-{
-    char iString[64];
-    PvmiKvpType iType;
-    PvmiKvpValueType iValueType;
-};
-
-// The number of characters to allocate for the key string
-#define PVOMXAUDIODECNODECONFIG_KEYSTRING_SIZE 128
-
 
 
 /// #########################################################
 /// #########################################################
 // Key string info at the base level ("x-pvmf/audio/decoder")
 #define PVOMXAUDIODECNODECONFIG_BASE_NUMKEYS 6
-const PVOMXAudioDecNodeKeyStringData PVOMXAudioDecNodeConfigBaseKeys[PVOMXAUDIODECNODECONFIG_BASE_NUMKEYS] =
+const PVOMXBaseDecNodeKeyStringData PVOMXAudioDecNodeConfigBaseKeys[PVOMXAUDIODECNODECONFIG_BASE_NUMKEYS] =
 {
     {"silenceinsertion_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
     {"aac_he_v1_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
     {"aac_he_v2_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
-    {"format-type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    {"format-type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}
 };
 
-// Key string info at render ("x-pvmf/video/render")
+// Key string info at render ("x-pvmf/audio/render")
 #define PVOMXAUDIODECNODECONFIG_RENDER_NUMKEYS 2
-const PVOMXAudioDecNodeKeyStringData PVOMXAudioDecNodeConfigRenderKeys[PVOMXAUDIODECNODECONFIG_RENDER_NUMKEYS] =
+const PVOMXBaseDecNodeKeyStringData PVOMXAudioDecNodeConfigRenderKeys[PVOMXAUDIODECNODECONFIG_RENDER_NUMKEYS] =
 {
     {"sampling_rate", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"channels", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
@@ -359,25 +70,12 @@
 /////////###############################################################
 //// ###################################################################
 
-
-
-
-
 //Mimetypes for the custom interface
 #define PVMF_OMX_AUDIO_DEC_NODE_MIMETYPE "pvxxx/OMXAudioDecNode"
 #define PVMF_BASEMIMETYPE "pvxxx"
 
-//Command queue type
-typedef PVMFNodeCommandQueue<PVMFOMXAudioDecNodeCommand, PVMFOMXAudioDecNodeAllocator> PVMFOMXAudioDecNodeCmdQ;
-
-
 class PVMFOMXAudioDecNode
-            : public OsclActiveObject
-            , public PVMFNodeInterface
-            , public OsclMemPoolFixedChunkAllocatorObserver
-            , public PVMFOMXAudioDecNodeExtensionInterface
-            , public PVMFMetadataExtensionInterface
-            , public PvmiCapabilityAndConfig
+            : public PVMFOMXBaseDecNode
 
 {
     public:
@@ -386,74 +84,12 @@
 
         // From PVMFNodeInterface
         PVMFStatus ThreadLogon();
-        PVMFStatus ThreadLogoff();
-        PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
-        PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
-        PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
-                                Oscl_Vector<PVUuid, PVMFOMXAudioDecNodeAllocator>& aUuids,
-                                bool aExactUuidsOnly = false,
-                                const OsclAny* aContext = NULL);
-        PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
-                                     PVInterface*& aInterfacePtr,
-                                     const OsclAny* aContext = NULL);
-        PVMFCommandId RequestPort(PVMFSessionId
-                                  , int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL);
-        PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
-        PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
-        PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-        // From PVInterface
-        virtual void addRef();
-        virtual void removeRef();
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        virtual PVMFStatus SetDecoderNodeConfiguration(PVMFOMXAudioDecNodeConfig& aConfig);
 
         //**********begin PVMFMetadataExtensionInterface
         uint32 GetNumMetadataKeys(char* query_key = NULL);
         uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
-        PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries,
-                                          char* query_key = NULL, const OsclAny* aContextData = NULL);
-        PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList,
-                                            Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContextData = NULL);
-        PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, uint32 starting_index, uint32 end_index);
-        PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, uint32 end_index);
         //**********End PVMFMetadataExtensionInterface
 
-        //********** CB Functions to serve OpenMAX Decoder
-
-        //Process callback functions. They will be executed in testapp thread context
-        //	These callbacks are used only in the Multithreaded component case
-        OsclReturnCode ProcessCallbackEventHandler_MultiThreaded(OsclAny* P);
-        OsclReturnCode ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P);
-        OsclReturnCode ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P);
-
-        //Callback objects - again, these are used only in the case of Multithreaded component
-        EventHandlerThreadSafeCallbackAO_Audio*	 iThreadSafeHandlerEventHandler;
-        EmptyBufferDoneThreadSafeCallbackAO_Audio* iThreadSafeHandlerEmptyBufferDone;
-        FillBufferDoneThreadSafeCallbackAO_Audio*  iThreadSafeHandlerFillBufferDone;
-
-        OMX_CALLBACKTYPE       iCallbacks; // structure that contains callback ptrs.
-        // OMX CALLBACKS
-        // 1) AO OMX component running in the same thread as the OMX node
-        //	In this case, the callbacks can be called directly from the component
-        //	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
-        //	The callback can perform do RunIfNotReady
-
-        // 2) Multithreaded component
-        //	In this case, the callback is made using the threadsafe callback (TSCB) AO
-        //	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent)
-        //  Node thread		 : TSCB(ProcessEvent)->ProcessCallbackEventHandler_MultiThreaded->EventHandlerProcessing
-
 
         //==============================================================================
 
@@ -464,283 +100,35 @@
                                              OMX_OUT OMX_U32 aData2,
                                              OMX_OUT OMX_PTR aEventData);
 
-        OMX_ERRORTYPE EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-                                                OMX_OUT OMX_PTR aAppData,
-                                                OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-        OMX_ERRORTYPE FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-                                               OMX_OUT OMX_PTR aAppData,
-                                               OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-
-
-        bool IsComponentMultiThreaded()
-        {
-            return iIsOMXComponentMultiThreaded;
-        };
-
-
-        // From PvmiCapabilityAndConfig
-        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
-        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
-        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements);
-        void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
-        PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext = NULL);
-        uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
-
         // for WMA params
         bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
 
+        PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
+        void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
 
-    private:
-        void CommandComplete(PVMFOMXAudioDecNodeCmdQ& aCmdQ, PVMFOMXAudioDecNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData = NULL);
+    protected:
 
-        void DoQueryUuid(PVMFOMXAudioDecNodeCommand&);
-        void DoQueryInterface(PVMFOMXAudioDecNodeCommand&);
-        void DoRequestPort(PVMFOMXAudioDecNodeCommand&);
-        void DoReleasePort(PVMFOMXAudioDecNodeCommand&);
-        void DoInit(PVMFOMXAudioDecNodeCommand&);
-        void DoPrepare(PVMFOMXAudioDecNodeCommand&);
-        void DoStart(PVMFOMXAudioDecNodeCommand&);
-        void DoStop(PVMFOMXAudioDecNodeCommand&);
-        void DoPause(PVMFOMXAudioDecNodeCommand&);
-        void DoReset(PVMFOMXAudioDecNodeCommand&);
-        void DoFlush(PVMFOMXAudioDecNodeCommand&);
-        PVMFStatus DoGetNodeMetadataKey(PVMFOMXAudioDecNodeCommand&);
-        PVMFStatus DoGetNodeMetadataValue(PVMFOMXAudioDecNodeCommand&);
-        void DoCancelAllCommands(PVMFOMXAudioDecNodeCommand&);
-        void DoCancelCommand(PVMFOMXAudioDecNodeCommand&);
-
-        void Run();
-        bool ProcessCommand(PVMFOMXAudioDecNodeCommand& aCmd);
+        void DoQueryUuid(PVMFOMXBaseDecNodeCommand&);
+        void DoRequestPort(PVMFOMXBaseDecNodeCommand&);
+        void DoReleasePort(PVMFOMXBaseDecNodeCommand&);
+        PVMFStatus DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand&);
+        PVMFStatus DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand&);
         bool ProcessIncomingMsg(PVMFPortInterface* aPort);
-        bool ProcessOutgoingMsg(PVMFPortInterface* aPort);
-        PVMFStatus HandleProcessingState();
+        PVMFStatus HandlePortReEnable();
 
         bool InitDecoder(PVMFSharedMediaDataPtr&);
 
         bool NegotiateComponentParameters();
         bool GetSetCodecSpecificInfo();
-        bool SetDefaultCapabilityFlags();
-        bool CreateOutMemPool(uint32 num);
-        bool CreateInputMemPool(uint32 num);
-        bool ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-                                       uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                       uint32 aNumBuffers,    // number of buffers
-                                       uint32 aActualBufferSize, // aactual buffer size
-                                       uint32 aPortIndex,      // port idx
-                                       bool aUseBufferOK,	// can component use OMX_UseBuffer?
-                                       bool	aIsThisInputBuffer // is this input or output
-                                      );
-
-        bool FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-                                      uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                      uint32 aNumBuffers,    // number of buffers
-                                      uint32 aPortIndex,      // port idx
-                                      bool	aIsThisInputBuffer		// is this input or output
-                                     );
-
-        OsclSharedPtr<class PVMFMediaDataImpl> WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext);
         bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen);
 
-        bool SendOutputBufferToOMXComponent();
-        bool SendInputBufferToOMXComponent();
-
-        bool SendConfigBufferToOMXComponent(uint8 *initbuffer, uint32 initbufsize);
-        bool SendEOSBufferToOMXComponent();
-
-        bool HandleRepositioning(void);
-        bool SendBeginOfMediaStreamCommand(void);
-        bool SendEndOfTrackCommand(void);
-
         // latm parser for AAC - LATM
         PVMFStatus CreateLATMParser(void);
         PVMFStatus DeleteLATMParser(void);
 
         bool ReleaseAllPorts();
-        bool DeleteOMXAudioDecoder();
 
-        void ChangeNodeState(TPVMFNodeInterfaceState aNewState);
-
-        void HandleComponentStateChange(OMX_U32 decoder_state);
-
-
-
-        // Capability And Config Helper Methods
-        PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
-        PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements);
-        void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
-        PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
-
-        PVMFStatus DoGetVideoDecNodeParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
-        PVMFStatus DoVerifyAndSetVideoDecNodeParameter(PvmiKvp& aParameter, bool aSetParam);
-
-
-        // From OsclMemPoolFixedChunkAllocatorObserver
-        void freechunkavailable(OsclAny*);
-
-        PVMFCommandId QueueCommandL(PVMFOMXAudioDecNodeCommand& aCmd);
-
-
-        friend class PVMFOMXAudioDecPort;
-
-        // Ports pointers
-        PVMFPortInterface* iInPort;
-        PVMFPortInterface* iOutPort;
-
-        // Commands
-        PVMFOMXAudioDecNodeCmdQ iInputCommands;
-        PVMFOMXAudioDecNodeCmdQ iCurrentCommand;
-
-        // Shared pointer for Media Msg.Input buffer
-        PVMFSharedMediaDataPtr iDataIn;
-
-
-        // OUTPUT BUFFER RELATED MEMBERS
-
-
-        // Output buffer memory pool
-        OsclMemPoolFixedChunkAllocator *iOutBufMemoryPool;
-        //PVOMXBufferAllocatorImplementation *iOutBufMemoryPool;
-        // Memory pool for simple media data
-        OsclMemPoolFixedChunkAllocator *iMediaDataMemPool;
-
-        // Fragment pool for format specific info
-        PVMFBufferPoolAllocator iFsiFragmentAlloc;
-
-        // Size of output buffer (negotiated with component)
-        uint32 iOMXComponentOutputBufferSize;
-
-        // size of output to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
-        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentOutputBufferSize)
-        uint32 iOutputAllocSize;
-
-        // Number of output buffers (negotiated with component)
-        uint32 iNumOutputBuffers;
-
-        // Number of output buffers in possession of the component or downstream,
-        // namely, number of unavailable buffers
-        uint32 iNumOutstandingOutputBuffers;
-
-        // flag to prevent sending output buffers downstream during flushing etc.
-        bool iDoNotSendOutputBuffersDownstreamFlag;
-
-        // flag to prevent freeing the buffers twice
-        bool iOutputBuffersFreed;
-
-
-        // INPUT BUFFER RELATED MEMBERS
-        OsclMemPoolFixedChunkAllocator *iInBufMemoryPool;
-        uint32 iOMXComponentInputBufferSize; // size of input buffer that the component sees (negotiated with the component)
-        uint32 iInputAllocSize; 	// size of input buffer to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
-        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentInputBufferSize)
-        uint32 iNumInputBuffers; // total num of input buffers (negotiated with component)
-
-        uint32 iNumOutstandingInputBuffers; // number of input buffers in use (i.e. unavailable)
-
-        bool iDoNotSaveInputBuffersFlag;
-
-        // flag to prevent freeing buffers twice
-        bool iInputBuffersFreed;
-
-        // input buffer fragmentation etc.
-        uint32 iCopyPosition;				// for copying memfrag data into a buffer
-        uint32 iFragmentSizeRemainingToCopy;
-        bool	iIsNewDataFragment;
-
-        // input data info
-        uint32 iCurrFragNum;
-        uint32 iCodecSeqNum;	// sequence number tracking
-        uint32 iInPacketSeqNum;
-
-        uint32 iInTimestamp;
-        uint32 iInDuration;
-        uint32 iInNumFrags;
-        uint32 iCurrentMsgMarkerBit;
-
-        // DYNAMIC PORT RE-CONFIGURATION
-        uint32 iInputPortIndex;
-        uint32 iOutputPortIndex;
-        OMX_PARAM_PORTDEFINITIONTYPE iParamPort;
-        uint32 iPortIndexForDynamicReconfig;
-        bool iSecondPortReportedChange;
-        bool iDynamicReconfigInProgress;
-        uint32 iSecondPortToReconfig;
-        bool iPauseCommandWasSentToComponent;
-        bool iStopCommandWasSentToComponent;
-
-
-
-        OMX_BUFFERHEADERTYPE *iInputBufferToResendToComponent; // ptr to input buffer that is not empty, but that the OMX component returned
-        // we need to resend this same buffer back to the component
-
-
-        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS
-        bool iOMXComponentSupportsExternalOutputBufferAlloc;
-        bool iOMXComponentSupportsExternalInputBufferAlloc;
-        bool iOMXComponentSupportsMovableInputBuffers;
-        bool iSetMarkerBitForEveryFrag; // is every fragment complete frame (AVC file playback = each fragment is a NAL)
-        bool iIsOMXComponentMultiThreaded;
-
-        // State definitions for HandleProcessingState() state machine
-        typedef enum
-        {
-            EPVMFOMXAudioDecNodeProcessingState_Idle,                  //default state after constraction/reset
-            EPVMFOMXAudioDecNodeProcessingState_InitDecoder,           //initialization of H264 decoder after handle was obtained
-            EPVMFOMXAudioDecNodeProcessingState_WaitForInitCompletion, // waiting for init completion
-            EPVMFOMXAudioDecNodeProcessingState_ReadyToDecode,         //nornal operation state of the decoder
-            EPVMFOMXAudioDecNodeProcessingState_WaitForOutputBuffer,   //wait state for avalible media output buffer
-            EPVMFOMXAudioDecNodeProcessingState_WaitForOutputPort,     //wait state, output port is busy
-            EPVMFOMXAudioDecNodeProcessingState_WaitForOutgoingQueue,   //wait state, outgoing queue
-            EPVMFOMXAudioDecNodeProcessingState_PortReconfig,			// Dynamic Port Reconfiguration - step 1
-            EPVMFOMXAudioDecNodeProcessingState_WaitForBufferReturn,		//	step 2
-            EPVMFOMXAudioDecNodeProcessingState_WaitForPortDisable,		// Dynamic Port Reconfiguration - step 3
-            EPVMFOMXAudioDecNodeProcessingState_PortReEnable,			// Dynamic Port Reconfiguration - step 4
-            EPVMFOMXAudioDecNodeProcessingState_WaitForPortEnable,		// step 5
-            EPVMFOMXAudioDecNodeProcessingState_Stopping,				// when STOP command is issued, the node has to wait for component to transition into
-            // idle state. The buffers keep coming back , the node is rescheduled
-            // to run. Prevent the node from sending buffers back
-            EPVMFOMXAudioDecNodeProcessingState_Pausing					// when PAUSE command is issued, the node has to wait for component to transition into
-            // paused state. This
-            // prevents the node from sending buffers back
-        } PVMFOMXAudioDecNode_ProcessingState;
-
-        // State of HandleProcessingState() state machine
-        PVMFOMXAudioDecNode_ProcessingState iProcessingState;
-
-        // Handle of OMX Component
-        OMX_HANDLETYPE iOMXAudioDecoder;
-
-        // Current State of the component
-        OMX_STATETYPE iCurrentDecoderState;
-
-        // BOS
-        bool iSendBOS;
-        uint32 iStreamID;
-        uint32 iBOSTimestamp;
-
-        // repositioning related flags
-        bool iIsRepositioningRequestSentToComponent;
-        bool iIsRepositionDoneReceivedFromComponent;
-        bool iIsOutputPortFlushed;
-        bool iIsInputPortFlushed;
-
-        bool iIsRepositionIdleDoneReceivedFromComponent;
-        bool iIsRepositionIdleRequestSentToComponent;
-        bool iIsRepositionExecRequestSentToComponent;
-        bool iIsRepositionExecDoneReceivedFromComponent;
-
-        //EOS control flags
-        bool iIsEOSSentToComponent;
-        bool iIsEOSReceivedFromComponent;
-
-
-        // Send Fsi configuration flag
-        bool	sendFsi;
+        OMX_AUDIO_CODINGTYPE iOMXAudioCompressionFormat;
 
         // Audio parameters
         // the output buffer size is calculated from the parameters below
@@ -756,70 +144,6 @@
         uint8 *iLATMConfigBuffer;
         uint32 iLATMConfigBufferSize;
 
-        // Pointer to input data fragment
-        uint8* iBitstreamBuffer;
-        // Size of input data fragment
-        int32 iBitstreamSize;
-
-        // Output frame sequence counter
-        uint32 iSeqNum;
-
-        // Input frame sequence counter
-        uint32 iSeqNum_In;
-
-        // Added to Scheduler Flag
-        bool iIsAdded;
-
-        // Log related
-        PVLogger* iLogger;
-        PVLogger* iDataPathLogger;
-        PVLogger* iClockLogger;
-        PVLogger *iRunLogger;
-
-        // Counter of fragment read from current Media Msg.Input buffer
-        uint fragnum;
-        // Number of fragments in the Media Msg.Input buffer
-        uint numfrags;
-
-        // Time stamp to be used on output buffer
-        uint32 iOutTimeStamp;
-
-        // Node configuration update
-        PVMFOMXAudioDecNodeConfig iNodeConfig;
-
-        // Capability exchange
-        PVMFNodeCapability iCapability;
-
-        // Reference counter for extension
-        uint32 iExtensionRefCount;
-
-        // Vector for KVP
-        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
-
-        // EOS flag
-        bool iEndOfDataReached;
-        // Time stame upon EOS
-        PVMFTimestamp iEndOfDataTimestamp;
-
-        /* Diagnostic log related */
-        PVLogger* iDiagnosticsLogger;
-        bool iDiagnosticsLogged;
-        void LogDiagnostics();
-
-        uint32 iFrameCounter;
-
-        uint32 iH263MaxBitstreamFrameSize;
-        uint32 iH263MaxWidth;
-        uint32 iH263MaxHeight;
-        uint32 iM4VMaxBitstreamFrameSize;
-        uint32 iM4VMaxWidth;
-        uint32 iM4VMaxHeight;
-
-        uint32 iNewWidth , iNewHeight;
-
-        uint32 iAvgBitrateValue;
-        bool iResetInProgress;
-        bool iResetMsgSent;
 };
 
 
diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_port.cpp b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_port.cpp
deleted file mode 100644
index c51678a..0000000
--- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_port.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_omx_audiodec_port.h"
-#include "pvmf_omx_audiodec_node.h"
-
-
-PVMFOMXAudioDecPort::PVMFOMXAudioDecPort(int32 aTag, PVMFNodeInterface* aNode, char*name)
-        : PvmfPortBaseImpl(aTag, aNode, name)
-{
-
-    iOMXNode = (PVMFOMXAudioDecNode *) aNode;
-    Construct();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecPort::Construct()
-{
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXAudioDecPort");
-    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
-    iNumFramesGenerated = 0;
-    iNumFramesConsumed = 0;
-    iTrackConfig = NULL;
-    iTrackConfigSize = 0;
-    PvmiCapabilityAndConfigPortFormatImpl::Construct(
-        PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS
-        , PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS_VALTYPE);
-}
-
-
-PVMFOMXAudioDecPort::~PVMFOMXAudioDecPort()
-{
-    if (iTrackConfig != NULL)
-    {
-        OSCL_FREE(iTrackConfig);
-        iTrackConfigSize = 0;
-    }
-    Disconnect();
-    ClearMsgQueues();
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXAudioDecPort::IsFormatSupported(PVMFFormatType aFmt)
-{
-
-    return ((aFmt == PVMF_PCM16) ||
-            (aFmt == PVMF_LATM) ||
-            (aFmt == PVMF_MPEG4_AUDIO) ||
-            (aFmt == PVMF_ADIF) ||
-            (aFmt == PVMF_ASF_MPEG4_AUDIO) ||
-            (aFmt == PVMF_AAC_SIZEHDR) ||
-            (aFmt == PVMF_AMR_IF2) ||
-            (aFmt == PVMF_AMR_IETF) ||
-            (aFmt == PVMF_AMR_IETF_COMBINED) ||
-            (aFmt == PVMF_AMRWB_IETF) ||
-            (aFmt == PVMF_AMRWB_IETF_PAYLOAD) ||
-            (aFmt == PVMF_MP3) ||
-            (aFmt == PVMF_WMA)
-           );
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXAudioDecPort::FormatUpdated()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFOMXAudioDecPort::FormatUpdated %d", iFormat));
-}
-
-
-bool
-PVMFOMXAudioDecPort::pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag)
-{
-    if ((iConnectedPort) &&
-            (iTag == PVMF_OMX_AUDIO_DEC_NODE_PORT_TYPE_SINK))
-    {
-        PvmiCapabilityAndConfig *config = NULL;
-        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                       (OsclAny*&)config);
-
-        /*
-         * Create PvmiKvp for capability settings
-         */
-        if ((config) && (aMemFrag.getMemFragSize() > 0))
-        {
-            OsclMemAllocator alloc;
-            PvmiKvp kvp;
-            kvp.key = NULL;
-            kvp.length = oscl_strlen(PVMF_FORMAT_SPECIFIC_INFO_KEY) + 1; // +1 for \0
-            kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
-            if (kvp.key == NULL)
-            {
-                return false;
-            }
-            oscl_strncpy(kvp.key, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp.length);
-
-            kvp.value.key_specific_value = (OsclAny*)(aMemFrag.getMemFragPtr());
-            kvp.capacity = aMemFrag.getMemFragSize();
-            PvmiKvp* retKvp = NULL; // for return value
-            int32 err;
-            OSCL_TRY(err, config->setParametersSync(NULL, &kvp, 1, retKvp););
-            /* ignore the error for now */
-            alloc.deallocate((OsclAny*)(kvp.key));
-        }
-        return true;
-    }
-    return false;
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXAudioDecPort::Connect(PVMFPortInterface* aPort)
-{
-    if (!aPort)
-    {
-        return PVMFErrArgument;
-    }
-
-    if (iConnectedPort)
-    {
-        return PVMFFailure;
-    }
-
-    PvmiCapabilityAndConfig *config;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-
-    if (config != NULL)
-    {
-        PvmiKvp kv;
-        PvmiKvp* kvp = &kv;
-        int numKvp = 0;
-        PVMFStatus status =
-            config->getParametersSync(NULL, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp, numKvp, NULL);
-        if (status == PVMFSuccess)
-        {
-            if (iTrackConfig != NULL)
-            {
-                OSCL_FREE(iTrackConfig);
-                iTrackConfigSize = 0;
-            }
-            if (kvp)
-            {
-                iTrackConfigSize = kvp->capacity;
-                iTrackConfig = (uint8*)(OSCL_MALLOC(sizeof(uint8) * iTrackConfigSize));
-                oscl_memcpy(iTrackConfig, kvp->value.key_specific_value, iTrackConfigSize);
-            }
-            //config->releaseParameters(NULL, kvp, numKvp);
-            OsclMemAllocator alloc;
-            alloc.deallocate((OsclAny*)kvp->key);
-        }
-    }
-
-    // Automatically connect the peer.
-
-    if (aPort->PeerConnect(this) != PVMFSuccess)
-    {
-        return PVMFFailure;
-    }
-
-    iConnectedPort = aPort;
-    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
-    return PVMFSuccess;
-}
-
-
-void PVMFOMXAudioDecPort::setParametersSync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int num_elements,
-        PvmiKvp * & aRet_kvp)
-{
-
-    // if port connect needs format specific info
-    if (aParameters && pv_mime_strcmp(aParameters->key, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
-    {
-        if (iTrackConfig != NULL)
-        {
-            OSCL_FREE(iTrackConfig);
-            iTrackConfigSize = 0;
-        }
-        iTrackConfigSize = aParameters->capacity;
-        iTrackConfig = (uint8*)(OSCL_MALLOC(sizeof(uint8) * iTrackConfigSize));
-        oscl_memcpy(iTrackConfig, aParameters->value.key_specific_value, iTrackConfigSize);
-        return;
-    }
-    // call the base class function
-    PvmiCapabilityAndConfigPortFormatImpl::setParametersSync(aSession, aParameters, num_elements, aRet_kvp);
-
-}
-
-// MACROS DEFINITIONS FOR verifyParametersSync
-#define GetUnalignedWord( pb, w ) \
-            (w) = ((uint16) *(pb + 1) << 8) + *pb;
-
-#define GetUnalignedDword( pb, dw ) \
-            (dw) = ((uint32) *(pb + 3) << 24) + \
-                   ((uint32) *(pb + 2) << 16) + \
-                   ((uint16) *(pb + 1) << 8) + *pb;
-
-#define GetUnalignedWordEx( pb, w )     GetUnalignedWord( pb, w ); (pb) += sizeof(uint16);
-#define GetUnalignedDwordEx( pb, dw )   GetUnalignedDword( pb, dw ); (pb) += sizeof(uint32);
-
-#define LoadWORD( w, p )    GetUnalignedWordEx( p, w )
-#define LoadDWORD( dw, p )  GetUnalignedDwordEx( p, dw )
-
-#define WAVE_FORMAT_MSAUDIO1  0x0160
-#define WAVE_FORMAT_WMAUDIO2  0x0161
-#define WAVE_FORMAT_WMAUDIO3  0x0162
-#define WAVE_FORMAT_WMAUDIO_LOSSLESS  0x0163
-
-#define WAVE_FORMAT_MSSPEECH  10
-
-#define ENCOPT3_UNSUPPORTED_OPTS 0xd000
-
-PVMFStatus PVMFOMXAudioDecPort::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
-{
-
-    // in case of WMA call the Node verify to make sure that the parameters are OK
-    // (the node will also make sure that the downstream node is OK with the change
-    // if necessary)
-    if (iFormat == PVMF_WMA)
-    {
-        if (iOMXNode->VerifyParametersSync(aSession, aParameters, num_elements))
-        {
-            return PVMFSuccess;
-        }
-    }
-    else
-    {
-        return PVMFSuccess;
-    }
-
-    return PVMFErrNotSupported;
-}
-
-PVMFStatus PVMFOMXAudioDecPort::verifyConnectedPortParametersSync(const char* aFormatValType,
-        OsclAny* aConfig)
-{
-
-    PVMFStatus status = PVMFErrNotSupported;
-    PvmiCapabilityAndConfig *capConfig;
-    if (iConnectedPort)
-    {
-        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                       (OsclAny*&)capConfig);
-    }
-    else
-        return PVMFFailure;
-
-    if (capConfig != NULL)
-    {
-        if (pv_mime_strcmp(aFormatValType, PVMF_BITRATE_VALUE_KEY) == 0)
-        {
-            if (aConfig != NULL)
-            {
-                OsclMemAllocator alloc;
-                PvmiKvp kvp;
-                kvp.key = NULL;
-                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
-                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
-                if (kvp.key == NULL)
-                {
-                    return PVMFErrNoMemory;
-                }
-                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
-                uint32* bitrate = (uint32*)aConfig;
-                kvp.value.uint32_value = *bitrate;
-
-                int32 err;
-                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
-                /* ignore the error for now */
-                alloc.deallocate((OsclAny*)(kvp.key));
-
-                return status;
-            }
-        }
-        return PVMFErrArgument;
-    }
-    return PVMFFailure;
-}
-
-
diff --git a/nodes/pvomxbasedecnode/Android.mk b/nodes/pvomxbasedecnode/Android.mk
new file mode 100644
index 0000000..51f94f0
--- /dev/null
+++ b/nodes/pvomxbasedecnode/Android.mk
@@ -0,0 +1,35 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pvmf_omx_basedec_node.cpp \
+ 	src/pvmf_omx_basedec_port.cpp \
+ 	src/pvmf_omx_basedec_callbacks.cpp
+
+
+LOCAL_MODULE := libpvomxbasedecnode
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/nodes/pvomxbasedecnode/src \
+ 	$(PV_TOP)/nodes/pvomxbasedecnode/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pvmf_omx_basedec_defs.h \
+ 	include/pvmf_omx_basedec_port.h \
+ 	include/pvmf_omx_basedec_node.h \
+ 	include/pvmf_omx_basedec_callbacks.h \
+ 	include/pvmf_omx_basedec_node_extension_interface.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/nodes/pvomxbasedecnode/build/make/local.mk b/nodes/pvomxbasedecnode/build/make/local.mk
new file mode 100644
index 0000000..7d14862
--- /dev/null
+++ b/nodes/pvomxbasedecnode/build/make/local.mk
@@ -0,0 +1,24 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvomxbasedecnode
+
+XINCDIRS += ../../../../extern_libs_v2/khronos/openmax/include
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS :=	pvmf_omx_basedec_node.cpp \
+        pvmf_omx_basedec_port.cpp \
+        pvmf_omx_basedec_callbacks.cpp
+
+HDRS := pvmf_omx_basedec_defs.h \
+        pvmf_omx_basedec_port.h \
+        pvmf_omx_basedec_node.h \
+        pvmf_omx_basedec_callbacks.h \
+        pvmf_omx_basedec_node_extension_interface.h
+
+include $(MK)/library.mk
diff --git a/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_callbacks.h b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_callbacks.h
new file mode 100644
index 0000000..8f2f905
--- /dev/null
+++ b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_callbacks.h
@@ -0,0 +1,152 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_BASEDEC_CALLBACKS_H_INCLUDED
+#define PVMF_OMX_BASEDEC_CALLBACKS_H_INCLUDED
+
+#ifndef THREADSAFE_CALLBACK_AO_H_INCLUDED
+#include "threadsafe_callback_ao.h"
+#endif
+
+#ifndef THREADSAFE_MEMPOOL_H_INCLUDED
+#include "threadsafe_mempool.h"
+#endif
+
+#ifndef OMX_Types_h
+#include "omx_types.h"
+#endif
+
+#ifndef OMX_Core_h
+#include "omx_core.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+// structure that contains EventHandler callback type parameters:
+typedef struct EventHandlerSpecificData
+{
+    OMX_HANDLETYPE hComponent;
+    OMX_PTR pAppData;
+    OMX_EVENTTYPE eEvent;
+    OMX_U32 nData1;
+    OMX_U32 nData2;
+    OMX_PTR pEventData;
+} EventHandlerSpecificData;
+
+
+// structure that contains EmptyBufferDone callback type parameters:
+typedef struct EmptyBufferDoneSpecificData
+{
+    OMX_HANDLETYPE hComponent;
+    OMX_PTR pAppData;
+    OMX_BUFFERHEADERTYPE* pBuffer;
+} EmptyBufferDoneSpecificData;
+
+
+// structure that contains FillBufferDone callback type parameters:
+typedef struct FillBufferDoneSpecificData
+{
+    OMX_HANDLETYPE hComponent;
+    OMX_PTR pAppData;
+    OMX_BUFFERHEADERTYPE* pBuffer;
+} FillBufferDoneSpecificData;
+
+
+// This class defines the callback AO that handles the callbacks from the remote thread in a thread-safe way.
+// The callback events arriving from the remote thread are queued and processed later in PV thread context.
+// The class is DERIVED from the "ThreadSafeCallbackAO" class defined in "threadsafe_callback_ao.h/cpp"
+// OVERLOAD THE METHOD : "ProcessEvent" so that it does something meaningful
+
+
+// Test AO receives the remote thread specific API callback and then calls the generic API "ReceiveEvent"
+const char EventHandlerAOName[] = "EventHandlerCallbackAO";
+const char EmptyBufferDoneAOName[] = "EventHandlerCallbackAO";
+const char FillBufferDoneAOName[] = "EventHandlerCallbackAO";
+
+
+/**************** CLASS FOR EVENT HANDLER *************/
+class EventHandlerThreadSafeCallbackAO : public ThreadSafeCallbackAO
+{
+    public:
+        // Constructor
+        EventHandlerThreadSafeCallbackAO(
+            void* aObserver = NULL,
+            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
+            const char* aAOname = EventHandlerAOName,
+            int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+
+        // OVERLOADED ProcessEvent
+        OsclReturnCode ProcessEvent(OsclAny* EventData);
+
+        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
+        virtual void Run();
+        virtual OsclAny* DeQueue(OsclReturnCode &stat);
+
+        virtual ~EventHandlerThreadSafeCallbackAO();
+        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
+
+};
+
+
+/**************** CLASS FOR EVENT HANDLER *************/
+class EmptyBufferDoneThreadSafeCallbackAO : public ThreadSafeCallbackAO
+{
+    public:
+        // Constructor
+        EmptyBufferDoneThreadSafeCallbackAO(
+            void* aObserver = NULL,
+            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
+            const char* aAOname = EmptyBufferDoneAOName,
+            int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        // OVERLOADED ProcessEvent
+        OsclReturnCode ProcessEvent(OsclAny* EventData);
+
+        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
+        virtual void Run();
+        virtual OsclAny* DeQueue(OsclReturnCode &stat);
+
+        virtual ~EmptyBufferDoneThreadSafeCallbackAO();
+        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
+};
+
+
+
+
+/**************** CLASS FOR EVENT HANDLER *************/
+class FillBufferDoneThreadSafeCallbackAO : public ThreadSafeCallbackAO
+{
+    public:
+        // Constructor
+        FillBufferDoneThreadSafeCallbackAO(void* aObserver = NULL,
+                                           uint32 aDepth = DEFAULT_QUEUE_DEPTH,
+                                           const char* aAOname = FillBufferDoneAOName,
+                                           int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        // OVERLOADED ProcessEvent
+        OsclReturnCode ProcessEvent(OsclAny* EventData);
+        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
+        virtual void Run();
+        virtual OsclAny* DeQueue(OsclReturnCode &stat);
+
+        virtual ~FillBufferDoneThreadSafeCallbackAO();
+        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
+};
+
+#endif	//#ifndef PVMF_OMX_BASEDEC_CALLBACKS_H_INLCUDED
diff --git a/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_defs.h b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_defs.h
new file mode 100644
index 0000000..e13b034
--- /dev/null
+++ b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_defs.h
@@ -0,0 +1,40 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_BASEDEC_DEFS_H_INCLUDED
+#define PVMF_OMX_BASEDEC_DEFS_H_INCLUDED
+
+// Error and info messages
+//
+enum PVMFOMXBaseDecNodeErrors
+{
+    // Base decoder node failed to initialize the base decoder. Fatal error so the node needs to be reset.
+    PVOMXBASEDECNODE_ERROR_DECODER_INIT_FAILED = PVMF_NODE_ERROR_EVENT_LAST
+};
+
+enum PVMFOMXBaseDecNodeInfo
+{
+    // Decoding of a frame failed. Base decoder node will continue on to decode the next frame
+    PVOMXBASEDECNODE_INFO_DECODEFRAME_FAILED = PVMF_NODE_INFO_EVENT_LAST,
+    // Input bitstream buffer overflowed (frame too large or couldn't find frame marker). Data will be dropped until the next frame marker is found
+    // then frame will be decoded.
+    PVOMXBASEDECNODE_INFO_INPUTBITSTREAMBUFFER_OVERFLOW
+};
+
+#endif // PVMF_OMXBASEDEC_DEFS_H_INCLUDED
+
+
diff --git a/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_node.h b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_node.h
new file mode 100644
index 0000000..a00b916
--- /dev/null
+++ b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_node.h
@@ -0,0 +1,788 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_BASEDEC_NODE_H_INCLUDED
+#define PVMF_OMX_BASEDEC_NODE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef PVMF_MEMPOOL_H_INCLUDED
+#include "pvmf_mempool.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_OMX_BASEDEC_PORT_H_INCLUDED
+#include "pvmf_omx_basedec_port.h"
+#endif
+
+#ifndef PVMF_OMX_BASEDEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+#include "pvmf_omx_basedec_node_extension_interface.h"
+#endif
+
+#ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
+#include "pvmf_meta_data_extension.h"
+#endif
+
+#ifndef PV_MIME_STRING_UTILS_H_INCLUDED
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef OMX_Core_h
+#include "omx_core.h"
+#endif
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#ifndef PVMF_OMX_BASEDEC_CALLBACKS_H_INCLUDED
+#include "pvmf_omx_basedec_callbacks.h"
+#endif
+
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
+#endif
+
+
+typedef struct OutputBufCtrlStruct
+{
+    OMX_BUFFERHEADERTYPE *pBufHdr;
+}OutputBufCtrlStruct;
+
+typedef struct InputBufCtrlStruct
+{
+    OMX_BUFFERHEADERTYPE *pBufHdr;
+    PVMFSharedMediaDataPtr pMediaData;
+} InputBufCtrlStruct;
+
+
+// fwd class declaration
+class PVLogger;
+//memory allocator type for this node.
+typedef OsclMemAllocator PVMFOMXBaseDecNodeAllocator;
+
+
+// CALLBACK PROTOTYPES
+OMX_ERRORTYPE CallbackEventHandler(OMX_OUT OMX_HANDLETYPE aComponent,
+                                   OMX_OUT OMX_PTR aAppData,
+                                   OMX_OUT OMX_EVENTTYPE aEvent,
+                                   OMX_OUT OMX_U32 aData1,
+                                   OMX_OUT OMX_U32 aData2,
+                                   OMX_OUT OMX_PTR aEventData);
+
+OMX_ERRORTYPE CallbackEmptyBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
+                                      OMX_OUT OMX_PTR aAppData,
+                                      OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+OMX_ERRORTYPE CallbackFillBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
+                                     OMX_OUT OMX_PTR aAppData,
+                                     OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+
+
+//Default values for number of Input/Output buffers. If the component needs more than this, it will be
+// negotiated. If the component does not need more than this number, the default is used
+#define NUMBER_INPUT_BUFFER 5
+#define NUMBER_OUTPUT_BUFFER 9
+
+// nal start code is 0001
+#define NAL_START_CODE_SIZE 4
+const unsigned char NAL_START_CODE[4] = {0, 0, 0, 1};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////
+/////////////////////////
+/////////////////////////
+// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
+//						1) Deallocates the underlying output buffer
+//						2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
+//					  Deallocator is created as part of the wrapper, and travels with the buffer wrapper
+
+class PVOMXBufferSharedPtrWrapperCombinedCleanupDA : public OsclDestructDealloc
+{
+    public:
+        PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
+                buf_alloc(allocator), ptr_to_data_to_dealloc(pMempoolData) {};
+        virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
+
+        virtual void destruct_and_dealloc(OsclAny* ptr)
+        {
+            // call buffer deallocator
+            if (buf_alloc != NULL)
+            {
+                buf_alloc->deallocate(ptr_to_data_to_dealloc);
+            }
+
+            // finally, free the shared ptr wrapper memory
+            oscl_free(ptr);
+        }
+
+    private:
+        Oscl_DefAlloc* buf_alloc;
+        void *ptr_to_data_to_dealloc;
+};
+
+
+#define PVMFOMXBaseDecNodeCommandBase PVMFGenericNodeCommand<PVMFOMXBaseDecNodeAllocator>
+
+class PVMFOMXBaseDecNodeCommand: public PVMFOMXBaseDecNodeCommandBase
+{
+    public:
+        //constructor for Custom2 command
+        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
+        {
+            PVMFOMXBaseDecNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)arg1;
+            iParam2 = (OsclAny*)arg2;
+            iParam3 = (OsclAny*) & arg3;
+        }
+        void Parse(int32&arg1, int32&arg2, int32*&arg3)
+        {
+            arg1 = (int32)iParam1;
+            arg2 = (int32)iParam2;
+            arg3 = (int32*)iParam3;
+        }
+
+        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, uint32 aStartIndex, int32 aMaxEntries, char* aQueryKey, const OsclAny* aContext)
+        {
+            PVMFOMXBaseDecNodeCommandBase::Construct(s, cmd, aContext);
+            iStartIndex = aStartIndex;
+            iMaxEntries = aMaxEntries;
+
+            if (aQueryKey == NULL)
+            {
+                query_key[0] = 0;
+            }
+            else
+            {
+                if (aQueryKey != NULL)
+                    oscl_strncpy(query_key, aQueryKey, oscl_strlen(aQueryKey) + 1);
+            }
+
+            iParam1 = (OsclAny*)aKeyList;
+            iParam2 = NULL;
+            iParam3 = NULL;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        }
+
+        void Parse(PVMFMetadataList*& MetaDataListPtr, uint32 &aStartingIndex, int32 &aMaxEntries, char*&aQueryKey)
+        {
+            MetaDataListPtr = (PVMFMetadataList*)iParam1;
+            aStartingIndex = iStartIndex;
+            aMaxEntries = iMaxEntries;
+            if (query_key[0] == 0)
+            {
+                aQueryKey = NULL;
+            }
+            else
+            {
+                aQueryKey = query_key;
+            }
+        }
+
+        // Constructor and parser for GetNodeMetadataValue
+        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, uint32 aStartIndex, int32 aMaxEntries, const OsclAny* aContext)
+        {
+            PVMFOMXBaseDecNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aKeyList;
+            iParam2 = (OsclAny*)aValueList;
+
+            iStartIndex = aStartIndex;
+            iMaxEntries = aMaxEntries;
+
+            iParam3 = NULL;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        }
+        void Parse(PVMFMetadataList* &aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList, uint32 &aStartingIndex, int32 &aMaxEntries)
+        {
+            aKeyList = (PVMFMetadataList*)iParam1;
+            aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
+            aStartingIndex = iStartIndex;
+            aMaxEntries = iMaxEntries;
+        }
+
+        virtual bool hipri()
+        {
+            //this routine identifies commands that need to
+            //go at the front of the queue.  derived command
+            //classes can override it if needed.
+            return (iCmd == PVOMXBASEDEC_NODE_CMD_CANCELALL
+                    || iCmd == PVOMXBASEDEC_NODE_CMD_CANCELCMD);
+        }
+
+        enum PVOMXBaseDecNodeCmdType
+        {
+            PVOMXBASEDEC_NODE_CMD_QUERYUUID,
+            PVOMXBASEDEC_NODE_CMD_QUERYINTERFACE,
+            PVOMXBASEDEC_NODE_CMD_INIT,
+            PVOMXBASEDEC_NODE_CMD_PREPARE,
+            PVOMXBASEDEC_NODE_CMD_REQUESTPORT,
+            PVOMXBASEDEC_NODE_CMD_START,
+            PVOMXBASEDEC_NODE_CMD_PAUSE,
+            PVOMXBASEDEC_NODE_CMD_STOP,
+            PVOMXBASEDEC_NODE_CMD_FLUSH,
+            PVOMXBASEDEC_NODE_CMD_RELEASEPORT,
+            PVOMXBASEDEC_NODE_CMD_RESET,
+            PVOMXBASEDEC_NODE_CMD_CANCELCMD,
+            PVOMXBASEDEC_NODE_CMD_CANCELALL,
+            PVOMXBASEDEC_NODE_CMD_INVALID,
+            PVOMXBASEDEC_NODE_CMD_GETNODEMETADATAKEY,
+            PVOMXBASEDEC_NODE_CMD_GETNODEMETADATAVALUE
+        };
+
+    private:
+        uint32 iStartIndex;
+        uint32 iMaxEntries;
+        char query_key[256];
+
+};
+
+//Default vector reserve size
+#define PVMF_OMXBASEDEC_NODE_COMMAND_VECTOR_RESERVE 10
+
+//Starting value for command IDs
+#define PVMF_OMXBASEDEC_NODE_COMMAND_ID_START 6000
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+//CAPABILITY AND CONFIG
+
+// Structure to hold the key string info for
+// capability-and-config
+struct PVOMXBaseDecNodeKeyStringData
+{
+    char iString[64];
+    PvmiKvpType iType;
+    PvmiKvpValueType iValueType;
+};
+
+// The number of characters to allocate for the key string
+#define PVOMXBASEDECNODECONFIG_KEYSTRING_SIZE 128
+
+//Mimetypes for the custom interface
+#define PVMF_OMX_BASE_DEC_NODE_MIMETYPE "pvxxx/OMXBaseDecNode"
+#define PVMF_BASEMIMETYPE "pvxxx"
+
+//Command queue type
+typedef PVMFNodeCommandQueue<PVMFOMXBaseDecNodeCommand, PVMFOMXBaseDecNodeAllocator> PVMFOMXBaseDecNodeCmdQ;
+
+
+class PVMFOMXBaseDecNode
+            : public OsclActiveObject
+            , public PVMFNodeInterface
+            , public OsclMemPoolFixedChunkAllocatorObserver
+            , public PVMFOMXBaseDecNodeExtensionInterface
+            , public PVMFMetadataExtensionInterface
+            , public PvmiCapabilityAndConfig
+
+{
+    public:
+        OSCL_IMPORT_REF PVMFOMXBaseDecNode(int32 aPriority, const char aAOName[]);
+        OSCL_IMPORT_REF virtual ~PVMFOMXBaseDecNode();
+
+        // From PVMFNodeInterface
+        OSCL_IMPORT_REF virtual PVMFStatus ThreadLogon() = 0;
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, PVMFOMXBaseDecNodeAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId
+                , int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+
+        // From PVMFPortActivityHandler
+        OSCL_IMPORT_REF void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        // From PVInterface
+        OSCL_IMPORT_REF virtual void addRef();
+        OSCL_IMPORT_REF virtual void removeRef();
+        OSCL_IMPORT_REF virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        OSCL_IMPORT_REF virtual PVMFStatus SetDecoderNodeConfiguration(PVMFOMXBaseDecNodeConfig& aConfig);
+
+        //**********begin PVMFMetadataExtensionInterface
+        OSCL_IMPORT_REF virtual uint32 GetNumMetadataKeys(char* query_key = NULL) = 0;
+        OSCL_IMPORT_REF virtual uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList) = 0;
+        OSCL_IMPORT_REF PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries,
+                char* query_key = NULL, const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList,
+                Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, uint32 starting_index, uint32 end_index);
+        OSCL_IMPORT_REF PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, uint32 end_index);
+        //**********End PVMFMetadataExtensionInterface
+        OSCL_IMPORT_REF virtual bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements) = 0;
+
+        //********** CB Functions to serve OpenMAX Decoder
+
+        //Process callback functions. They will be executed in testapp thread context
+        //	These callbacks are used only in the Multithreaded component case
+        OSCL_IMPORT_REF OsclReturnCode ProcessCallbackEventHandler_MultiThreaded(OsclAny* P);
+        OSCL_IMPORT_REF OsclReturnCode ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P);
+        OSCL_IMPORT_REF OsclReturnCode ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P);
+
+        //Callback objects - again, these are used only in the case of Multithreaded component
+        EventHandlerThreadSafeCallbackAO*	 iThreadSafeHandlerEventHandler;
+        EmptyBufferDoneThreadSafeCallbackAO* iThreadSafeHandlerEmptyBufferDone;
+        FillBufferDoneThreadSafeCallbackAO*  iThreadSafeHandlerFillBufferDone;
+
+        OMX_CALLBACKTYPE       iCallbacks; // structure that contains callback ptrs.
+        // OMX CALLBACKS
+        // 1) AO OMX component running in the same thread as the OMX node
+        //	In this case, the callbacks can be called directly from the component
+        //	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
+        //	The callback can perform do RunIfNotReady
+
+        // 2) Multithreaded component
+        //	In this case, the callback is made using the threadsafe callback (TSCB) AO
+        //	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent)
+        //  Node thread		 : TSCB(ProcessEvent)->ProcessCallbackEventHandler_MultiThreaded->EventHandlerProcessing
+
+
+        //==============================================================================
+
+        OSCL_IMPORT_REF virtual OMX_ERRORTYPE EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+                OMX_OUT OMX_PTR aAppData,
+                OMX_OUT OMX_EVENTTYPE aEvent,
+                OMX_OUT OMX_U32 aData1,
+                OMX_OUT OMX_U32 aData2,
+                OMX_OUT OMX_PTR aEventData) = 0;
+
+        OSCL_IMPORT_REF OMX_ERRORTYPE EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+                OMX_OUT OMX_PTR aAppData,
+                OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+        OSCL_IMPORT_REF OMX_ERRORTYPE FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+                OMX_OUT OMX_PTR aAppData,
+                OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+        bool IsComponentMultiThreaded()
+        {
+            return iIsOMXComponentMultiThreaded;
+        };
+
+        // From PvmiCapabilityAndConfig
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
+        OSCL_IMPORT_REF virtual bool ProcessIncomingMsg(PVMFPortInterface* aPort);
+        OSCL_IMPORT_REF void Run();
+    protected:
+        OSCL_IMPORT_REF void CommandComplete(PVMFOMXBaseDecNodeCmdQ& aCmdQ, PVMFOMXBaseDecNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData = NULL);
+
+        virtual void DoQueryUuid(PVMFOMXBaseDecNodeCommand&) = 0;
+        void DoQueryInterface(PVMFOMXBaseDecNodeCommand&);
+        virtual void DoRequestPort(PVMFOMXBaseDecNodeCommand&) = 0;
+        virtual void DoReleasePort(PVMFOMXBaseDecNodeCommand&) = 0;
+        void DoInit(PVMFOMXBaseDecNodeCommand&);
+        void DoPrepare(PVMFOMXBaseDecNodeCommand&);
+        void DoStart(PVMFOMXBaseDecNodeCommand&);
+        void DoStop(PVMFOMXBaseDecNodeCommand&);
+        void DoPause(PVMFOMXBaseDecNodeCommand&);
+        void DoReset(PVMFOMXBaseDecNodeCommand&);
+        void DoFlush(PVMFOMXBaseDecNodeCommand&);
+        virtual PVMFStatus DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand&) = 0;
+        virtual PVMFStatus DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand&) = 0;
+        void DoCancelAllCommands(PVMFOMXBaseDecNodeCommand&);
+        void DoCancelCommand(PVMFOMXBaseDecNodeCommand&);
+
+        bool ProcessCommand(PVMFOMXBaseDecNodeCommand& aCmd);
+        bool ProcessOutgoingMsg(PVMFPortInterface* aPort);
+        PVMFStatus HandleProcessingState();
+        virtual PVMFStatus HandlePortReEnable() = 0;
+
+        virtual bool InitDecoder(PVMFSharedMediaDataPtr&) = 0;
+
+        OSCL_IMPORT_REF OsclAny* AllocateKVPKeyArray(int32& aLeaveCode, PvmiKvpValueType aValueType, int32 aNumElements);
+        int32 PushKVPKey(OSCL_HeapString<OsclMemAllocator>& aString, PVMFMetadataList* aKeyList)
+        {
+            int32 leavecode = OsclErrNone;
+            OSCL_TRY(leavecode, aKeyList->push_back(aString));
+            return leavecode;
+        }
+
+        int32 PushKVPKey(const char* aString, PVMFMetadataList& aKeyList)
+        {
+            int32 leavecode = OsclErrNone;
+            OSCL_TRY(leavecode, aKeyList.push_back(aString));
+            return leavecode;
+        }
+
+        int32 PushKVP(PvmiKvp aKVP, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList)
+        {
+            int32 leavecode = OsclErrNone;
+            OSCL_TRY(leavecode, aValueList.push_back(aKVP));
+            return leavecode;
+        }
+
+        int32 AllocateChunkFromMemPool(OsclAny*& aCtrlStructPtr, OsclMemPoolFixedChunkAllocator *aMemPool, int32 aAllocSize)
+        {
+            int32 leavecode = OsclErrNone;
+            OSCL_TRY(leavecode, aCtrlStructPtr = (OsclAny *) aMemPool->allocate(aAllocSize));
+            return leavecode;
+        }
+
+        // DV:
+        virtual bool NegotiateComponentParameters() = 0;
+
+        bool SetDefaultCapabilityFlags();
+        OSCL_IMPORT_REF bool CreateOutMemPool(uint32 num);
+        OSCL_IMPORT_REF bool CreateInputMemPool(uint32 num);
+        OSCL_IMPORT_REF bool ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+                uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                uint32 aNumBuffers,    // number of buffers
+                uint32 aActualBufferSize, // aactual buffer size
+                uint32 aPortIndex,      // port idx
+                bool aUseBufferOK,	// can component use OMX_UseBuffer?
+                bool	aIsThisInputBuffer // is this input or output
+                                                      );
+
+        bool FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+                                      uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                      uint32 aNumBuffers,    // number of buffers
+                                      uint32 aPortIndex,      // port idx
+                                      bool	aIsThisInputBuffer		// is this input or output
+                                     );
+
+        OsclSharedPtr<class PVMFMediaDataImpl> WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext);
+        virtual bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen) = 0;
+
+        bool SendOutputBufferToOMXComponent();
+        OSCL_IMPORT_REF bool SendInputBufferToOMXComponent();
+
+        OSCL_IMPORT_REF bool SendConfigBufferToOMXComponent(uint8 *initbuffer, uint32 initbufsize);
+        bool SendEOSBufferToOMXComponent();
+
+        bool HandleRepositioning(void);
+        bool SendBeginOfMediaStreamCommand(void);
+        bool SendEndOfTrackCommand(void);
+
+
+
+        virtual bool ReleaseAllPorts() = 0;
+        bool DeleteOMXBaseDecoder();
+
+        OSCL_IMPORT_REF void ChangeNodeState(TPVMFNodeInterfaceState aNewState);
+
+        OSCL_IMPORT_REF void HandleComponentStateChange(OMX_U32 decoder_state);
+
+        // Capability And Config Helper Methods
+        OSCL_IMPORT_REF virtual PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF virtual PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements);
+        OSCL_IMPORT_REF virtual void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
+        OSCL_IMPORT_REF virtual PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
+
+        // From OsclMemPoolFixedChunkAllocatorObserver
+        OSCL_IMPORT_REF void freechunkavailable(OsclAny*);
+
+        OSCL_IMPORT_REF PVMFCommandId QueueCommandL(PVMFOMXBaseDecNodeCommand& aCmd);
+
+        friend class PVMFOMXBaseDecPort;
+
+        // Ports pointers
+        PVMFPortInterface* iInPort;
+        PVMFPortInterface* iOutPort;
+
+        // Commands
+        PVMFOMXBaseDecNodeCmdQ iInputCommands;
+        PVMFOMXBaseDecNodeCmdQ iCurrentCommand;
+
+        // Shared pointer for Media Msg.Input buffer
+        PVMFSharedMediaDataPtr iDataIn;
+
+        // OUTPUT BUFFER RELATED MEMBERS
+        // Output buffer memory pool
+        OsclMemPoolFixedChunkAllocator *iOutBufMemoryPool;
+
+        // Memory pool for simple media data
+        OsclMemPoolFixedChunkAllocator *iMediaDataMemPool;
+
+        // Fragment pool for format specific info
+        PVMFBufferPoolAllocator iFsiFragmentAlloc;
+        // Fragment pool for private data format specific info
+        PVMFBufferPoolAllocator iPrivateDataFsiFragmentAlloc;
+
+        // Size of output buffer (negotiated with component)
+        uint32 iOMXComponentOutputBufferSize;
+
+        // size of output to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
+        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentOutputBufferSize)
+        uint32 iOutputAllocSize;
+
+        // Number of output buffers (negotiated with component)
+        uint32 iNumOutputBuffers;
+
+        // Number of output buffers in possession of the component or downstream,
+        // namely, number of unavailable buffers
+        uint32 iNumOutstandingOutputBuffers;
+
+        // flag to prevent sending output buffers downstream during flushing etc.
+        bool iDoNotSendOutputBuffersDownstreamFlag;
+
+        // flag to prevent freeing the buffers twice
+        bool iOutputBuffersFreed;
+
+
+        OsclAny *ipPrivateData;
+
+        // INPUT BUFFER RELATED MEMBERS
+        OsclMemPoolFixedChunkAllocator *iInBufMemoryPool;
+        uint32 iOMXComponentInputBufferSize; // size of input buffer that the component sees (negotiated with the component)
+        uint32 iInputAllocSize; 	// size of input buffer to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
+        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentInputBufferSize)
+        uint32 iNumInputBuffers; // total num of input buffers (negotiated with component)
+
+        uint32 iNumOutstandingInputBuffers; // number of input buffers in use (i.e. unavailable)
+
+        bool iDoNotSaveInputBuffersFlag;
+
+        // flag to prevent freeing buffers twice
+        bool iInputBuffersFreed;
+
+        // input buffer fragmentation etc.
+        uint32 iCopyPosition;				// for copying memfrag data into a buffer
+        uint32 iFragmentSizeRemainingToCopy;
+        bool	iIsNewDataFragment;
+        // partial frame assembly logic flags
+        bool	iFirstPieceOfPartialFrame;
+        bool	iObtainNewInputBuffer;
+        bool	iKeepDroppingMsgsUntilMarkerBit;
+        bool	iFirstDataMsgAfterBOS;
+        InputBufCtrlStruct *iInputBufferUnderConstruction;
+
+        OSCL_IMPORT_REF void DropCurrentBufferUnderConstruction();
+        OSCL_IMPORT_REF void SendIncompleteBufferUnderConstruction();
+
+        // input data info
+        uint32 iCurrFragNum;
+        uint32 iCodecSeqNum;	// sequence number tracking
+        uint32 iInPacketSeqNum;
+
+        uint32 iInTimestamp;
+        uint32 iInDuration;
+        uint32 iInNumFrags;
+        uint32 iCurrentMsgMarkerBit;
+
+        // DYNAMIC PORT RE-CONFIGURATION
+        uint32 iInputPortIndex;
+        uint32 iOutputPortIndex;
+        OMX_PARAM_PORTDEFINITIONTYPE iParamPort;
+        uint32 iPortIndexForDynamicReconfig;
+        bool iSecondPortReportedChange;
+        bool iDynamicReconfigInProgress;
+        uint32 iSecondPortToReconfig;
+        bool iPauseCommandWasSentToComponent;
+        bool iStopCommandWasSentToComponent;
+
+        OMX_BUFFERHEADERTYPE *iInputBufferToResendToComponent; // ptr to input buffer that is not empty, but that the OMX component returned
+        // we need to resend this same buffer back to the component
+
+        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS
+        bool iOMXComponentSupportsExternalOutputBufferAlloc;
+        bool iOMXComponentSupportsExternalInputBufferAlloc;
+        bool iOMXComponentSupportsMovableInputBuffers;
+        bool iSetMarkerBitForEveryFrag; // is every fragment complete frame (e.g. AVC file playback = each fragment is a NAL)
+        bool iIsOMXComponentMultiThreaded;
+        bool iOMXComponentSupportsPartialFrames;
+        bool iOMXComponentNeedsNALStartCode;
+        bool iOMXComponentCanHandleIncompleteFrames;
+
+        // State definitions for HandleProcessingState() state machine
+        typedef enum
+        {
+            EPVMFOMXBaseDecNodeProcessingState_Idle,                  //default state after constraction/reset
+            EPVMFOMXBaseDecNodeProcessingState_InitDecoder,           //initialization of H264 decoder after handle was obtained
+            EPVMFOMXBaseDecNodeProcessingState_WaitForInitCompletion, // waiting for init completion
+            EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode,         //nornal operation state of the decoder
+            EPVMFOMXBaseDecNodeProcessingState_WaitForOutputBuffer,   //wait state for avalible media output buffer
+            EPVMFOMXBaseDecNodeProcessingState_WaitForOutputPort,     //wait state, output port is busy
+            EPVMFOMXBaseDecNodeProcessingState_WaitForOutgoingQueue,   //wait state, outgoing queue
+            EPVMFOMXBaseDecNodeProcessingState_PortReconfig,			// Dynamic Port Reconfiguration - step 1
+            EPVMFOMXBaseDecNodeProcessingState_WaitForBufferReturn,		//	step 2
+            EPVMFOMXBaseDecNodeProcessingState_WaitForPortDisable,		// Dynamic Port Reconfiguration - step 3
+            EPVMFOMXBaseDecNodeProcessingState_PortReEnable,			// Dynamic Port Reconfiguration - step 4
+            EPVMFOMXBaseDecNodeProcessingState_WaitForPortEnable,		// step 5
+            EPVMFOMXBaseDecNodeProcessingState_Stopping,				// when STOP command is issued, the node has to wait for component to transition into
+            // idle state. The buffers keep coming back , the node is rescheduled
+            // to run. Prevent the node from sending buffers back
+            EPVMFOMXBaseDecNodeProcessingState_Pausing					// when PAUSE command is issued, the node has to wait for component to transition into
+            // paused state.
+            // Video: This prevents the node from sending buffers back
+            // Audio: The buffers may still keep coming back , the node is rescheduled
+            // to run. Prevent the node from sending buffers back to component
+
+        } PVMFOMXBaseDecNode_ProcessingState;
+
+        // State of HandleProcessingState() state machine
+        PVMFOMXBaseDecNode_ProcessingState iProcessingState;
+
+        // Handle of OMX Component
+        OMX_HANDLETYPE iOMXDecoder;
+
+        // Current State of the component
+        OMX_STATETYPE iCurrentDecoderState;
+
+        // BOS
+        bool iSendBOS;
+        uint32 iStreamID;
+        uint32 iBOSTimestamp;
+
+        // repositioning related flags
+        bool iIsRepositioningRequestSentToComponent;
+        bool iIsRepositionDoneReceivedFromComponent;
+        bool iIsOutputPortFlushed;
+        bool iIsInputPortFlushed;
+
+        //EOS control flags
+        bool iIsEOSSentToComponent;
+        bool iIsEOSReceivedFromComponent;
+
+        // Send Fsi configuration flag
+        bool	sendFsi;
+
+        // Pointer to input data fragment
+        uint8* iBitstreamBuffer;
+        // Size of input data fragment
+        int32 iBitstreamSize;
+
+        // Output frame sequence counter
+        uint32 iSeqNum;
+
+        // Input frame sequence counter
+        uint32 iSeqNum_In;
+
+        // Added to Scheduler Flag
+        bool iIsAdded;
+
+        // Log related
+        PVLogger* iLogger;
+        PVLogger* iDataPathLogger;
+        PVLogger* iClockLogger;
+        PVLogger *iRunlLogger;
+
+        // Counter of fragment read from current Media Msg.Input buffer
+        uint fragnum;
+        // Number of fragments in the Media Msg.Input buffer
+        uint numfrags;
+
+        // Time stamp to be used on output buffer
+        uint32 iOutTimeStamp;
+
+        // Node configuration update
+        PVMFOMXBaseDecNodeConfig iNodeConfig;
+
+        // Capability exchange
+        PVMFNodeCapability iCapability;
+
+        // Reference counter for extension
+        uint32 iExtensionRefCount;
+
+        // Vector for KVP
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
+
+        // EOS flag
+        bool iEndOfDataReached;
+        // Time stame upon EOS
+        PVMFTimestamp iEndOfDataTimestamp;
+
+        /* Diagnostic log related */
+        PVLogger* iDiagnosticsLogger;
+        bool iDiagnosticsLogged;
+        void LogDiagnostics();
+
+        uint32 iFrameCounter;
+
+        uint32 iAvgBitrateValue;
+        bool iResetInProgress;
+        bool iResetMsgSent;
+        bool iStopInResetMsgSent;
+};
+
+
+#endif // PVMF_OMXBASEDEC_NODE_H_INCLUDED
+
diff --git a/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_node_extension_interface.h b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_node_extension_interface.h
new file mode 100644
index 0000000..e4ea506
--- /dev/null
+++ b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_node_extension_interface.h
@@ -0,0 +1,50 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_BASEDEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+#define PVMF_OMX_BASEDEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+
+struct PVMFOMXBaseDecNodeConfig
+{
+    bool iPostProcessingEnable;
+    int32 iPostProcessingMode;
+    bool iDropFrame;
+    PVMFFormatType iMimeType;
+};
+
+//Mimetype and Uuid for the custom interface
+#define PVMF_OMX_BASE_DEC_NODE_CUSTOM1_UUID 1,2,3,0xde,0xad,0xae,0xcf,0x20,0x11,0x73,0x33
+
+//Mimetypes for the custom interface
+#define PVMF_OMX_BASE_DEC_NODE_CUSTOM1_MIMETYPE "pvxxx/OMXBaseDecNode/Custom1"
+
+class PVMFOMXBaseDecNodeExtensionInterface : public PVInterface
+{
+    public:
+        //**********begin PVInterface
+        virtual void addRef() = 0;
+        virtual void removeRef() = 0;
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+        //**********end PVInterface
+
+        virtual PVMFStatus SetDecoderNodeConfiguration(PVMFOMXBaseDecNodeConfig& aConfig) = 0;
+
+};
+
+#endif //PVMF_OMX_BASEDEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+
+
diff --git a/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_port.h b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_port.h
new file mode 100644
index 0000000..c62cdff
--- /dev/null
+++ b/nodes/pvomxbasedecnode/include/pvmf_omx_basedec_port.h
@@ -0,0 +1,128 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_DEC_PORT_H_INCLUDED
+#define PVMF_OMX_DEC_PORT_H_INCLUDED
+
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+class PVMFOMXBaseDecNode;
+class PVMFOMXAudioDecNode;
+class PVMFOMXVideoDecNode;
+
+
+//Default vector reserve size
+#define PVMF_OMX_DEC_NODE_PORT_VECTOR_RESERVE 10
+
+#define PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS "x-pvmf/audio/decode/input_formats"
+#define PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=int32"
+#define PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS "x-pvmf/video/decode/input_formats"
+#define PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=int32"
+
+#define PVMF_OMX_VIDEO_DEC_INPUT_PORT_NAME "OMXVideoDecIn"
+#define PVMF_OMX_VIDEO_DEC_OUTPUT_PORT_NAME "OMXVideoDecOut"
+#define PVMF_OMX_AUDIO_DEC_INPUT_PORT_NAME "OMXAudioDecIn"
+#define PVMF_OMX_AUDIO_DEC_OUTPUT_PORT_NAME "OMXAudioDecOut"
+
+typedef enum
+{
+    PVMF_OMX_DEC_NODE_PORT_TYPE_INPUT,
+    PVMF_OMX_DEC_NODE_PORT_TYPE_OUTPUT,
+} PVMFOMXDecPortType;
+
+
+class PVMFOMXDecPort : public PvmfPortBaseImpl
+            , public PvmiCapabilityAndConfigPortFormatImpl
+{
+    public:
+        OSCL_IMPORT_REF PVMFOMXDecPort(int32 aTag, PVMFNodeInterface* aNode, const char*);
+        OSCL_IMPORT_REF ~PVMFOMXDecPort();
+
+
+        // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface
+        OSCL_IMPORT_REF bool IsFormatSupported(PVMFFormatType);
+        OSCL_IMPORT_REF void FormatUpdated();
+
+        // this port supports config interface
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+                aPtr = (PvmiCapabilityAndConfig*)this;
+            else
+                aPtr = NULL;
+        }
+
+        OSCL_IMPORT_REF bool pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag);
+
+        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession,
+                                               PvmiKvp* aParameters,
+                                               int num_elements,
+                                               PvmiKvp * & aRet_kvp);
+
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF PVMFStatus verifyConnectedPortParametersSync(const char* aFormatValType, OsclAny* aConfig);
+        uint32 getTrackConfigSize()
+        {
+            return iTrackConfigSize;
+        }
+        uint8* getTrackConfig()
+        {
+            return iTrackConfig;
+        }
+
+
+
+    private:
+
+
+        OSCL_IMPORT_REF void Construct();
+        PVLogger *iLogger;
+        uint32 iNumFramesGenerated; //number of source frames generated.
+        uint32 iNumFramesConsumed; //number of frames consumed & discarded.
+        uint32 iTrackConfigSize;
+        uint8* iTrackConfig;
+        friend class PVMFOMXBaseDecNode;
+        friend class PVMFOMXVideoDecNode;
+        friend class PVMFOMXAudioDecNode;
+        PVMFOMXBaseDecNode* iOMXNode;
+};
+
+#endif // PVMF_OMX_DEC_PORT_H_INCLUDED
diff --git a/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_callbacks.cpp b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_callbacks.cpp
new file mode 100644
index 0000000..5e0e252
--- /dev/null
+++ b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_callbacks.cpp
@@ -0,0 +1,446 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_omx_basedec_callbacks.h"
+#include "pvmf_omx_basedec_node.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+EventHandlerThreadSafeCallbackAO::EventHandlerThreadSafeCallbackAO(void* aObserver,
+        uint32 aDepth,
+        const char* aAOname,
+        int32 aPriority)
+        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
+{
+
+    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
+    if (iMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
+    }
+    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
+    // created in the 2nd thread and will fail to deallocate properly.
+
+    OsclAny *dummy = iMemoryPool->allocate(sizeof(EventHandlerSpecificData));
+    iMemoryPool->deallocate(dummy);
+}
+
+EventHandlerThreadSafeCallbackAO::~EventHandlerThreadSafeCallbackAO()
+{
+    if (iMemoryPool)
+    {
+
+        iMemoryPool->removeRef();
+        iMemoryPool = NULL;
+    }
+}
+OsclReturnCode EventHandlerThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
+{
+    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
+    if (iObserver != NULL)
+    {
+        PVMFOMXBaseDecNode* ptr = (PVMFOMXBaseDecNode*) iObserver;
+
+        ptr->ProcessCallbackEventHandler_MultiThreaded(EventData);
+
+    }
+    return OsclSuccess;
+}
+
+// We override the Run to process multiple (i.e. all in the queue) events in one Run
+
+void EventHandlerThreadSafeCallbackAO::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() In"));
+
+    OsclAny *P; // parameter to dequeue
+    OsclReturnCode status = OsclSuccess;
+
+
+    do
+    {
+
+
+        P = DeQueue(status);
+
+
+        if ((status == OsclSuccess) || (status == OsclPending))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO_Audio::Run() - Calling Process Event"));
+            ProcessEvent(P);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() - could not dequeue event data"));
+        }
+
+
+        // it is possible that an event arrives between dequeueing the last event and this point.
+        // If this is the case, we will be rescheduled and process the event
+        // in the next Run
+
+
+    }
+    while (status == OsclSuccess);
+    // if the status is "OsclPending" there were no more events in the queue
+    // (if another event arrived in the meanwhile, AO will be rescheduled)
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() Out"));
+}
+
+// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
+// (i.e. PendForExec control is done in the loop in Run)
+OsclAny* EventHandlerThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
+{
+    OsclAny *pData;
+    OsclProcStatus::eOsclProcError sema_status;
+
+    stat = OsclSuccess;
+
+    // Protect the queue while accessing it:
+    Mutex.Lock();
+
+    if (Q->NumElem == 0)
+    {
+        // nothing to de-queue
+        stat = OsclFailure;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
+        Mutex.Unlock();
+
+        return NULL;
+    }
+
+    pData = (Q->pFirst[Q->index_out]).pData;
+
+    Q->index_out++;
+    // roll-over the index
+    if (Q->index_out == Q->MaxNumElements)
+        Q->index_out = 0;
+
+    Q->NumElem--;
+    // check if there is need to call PendForExec
+    if ((Q->NumElem) == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
+        PendForExec();
+        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
+        // so that it can get out of the loop
+    }
+
+
+    //release queue access
+    Mutex.Unlock();
+
+    // Signal the semaphore that controls the remote thread.
+    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
+    sema_status = RemoteThreadCtrlSema.Signal();
+    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
+    {
+        stat = OsclFailure;
+        return NULL;
+    }
+
+    return pData;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////
+EmptyBufferDoneThreadSafeCallbackAO::EmptyBufferDoneThreadSafeCallbackAO(void* aObserver,
+        uint32 aDepth,
+        const char* aAOname,
+        int32 aPriority)
+        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
+{
+
+    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
+    if (iMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
+
+    }
+    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
+    // created in the 2nd thread and will fail to deallocate properly.
+
+    OsclAny *dummy = iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData));
+    iMemoryPool->deallocate(dummy);
+}
+
+EmptyBufferDoneThreadSafeCallbackAO::~EmptyBufferDoneThreadSafeCallbackAO()
+{
+    if (iMemoryPool)
+    {
+
+        iMemoryPool->removeRef();
+        iMemoryPool = NULL;
+    }
+
+}
+OsclReturnCode EmptyBufferDoneThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
+{
+    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
+    if (iObserver != NULL)
+    {
+        PVMFOMXBaseDecNode* ptr = (PVMFOMXBaseDecNode *) iObserver;
+
+        ptr->ProcessCallbackEmptyBufferDone_MultiThreaded(EventData);
+
+    }
+    return OsclSuccess;
+}
+
+// We override the Run to process multiple (i.e. all in the queue) events in one Run
+
+void EmptyBufferDoneThreadSafeCallbackAO::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() In"));
+
+    OsclAny *P; // parameter to dequeue
+    OsclReturnCode status = OsclSuccess;
+
+    do
+    {
+
+
+        P = DeQueue(status);
+
+
+        if ((status == OsclSuccess) || (status == OsclPending))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() - Calling Process Event"));
+            ProcessEvent(P);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() - could not dequeue event data"));
+        }
+
+
+        // it is possible that an event arrives between dequeueing the last event and this point.
+        // If this is the case, we will be rescheduled and process the event
+        // in the next Run
+
+
+    }
+    while (status == OsclSuccess);
+    // if the status is "OsclPending" there were no more events in the queue
+    // (if another event arrived in the meanwhile, AO will be rescheduled)
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() Out"));
+}
+
+// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
+// (i.e. PendForExec control is done in the loop in Run)
+OsclAny* EmptyBufferDoneThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
+{
+    OsclAny *pData;
+    OsclProcStatus::eOsclProcError sema_status;
+
+    stat = OsclSuccess;
+
+    // Protect the queue while accessing it:
+    Mutex.Lock();
+
+    if (Q->NumElem == 0)
+    {
+        // nothing to de-queue
+        stat = OsclFailure;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
+        Mutex.Unlock();
+
+        return NULL;
+    }
+
+    pData = (Q->pFirst[Q->index_out]).pData;
+
+    Q->index_out++;
+    // roll-over the index
+    if (Q->index_out == Q->MaxNumElements)
+        Q->index_out = 0;
+
+    Q->NumElem--;
+    // check if there is need to call PendForExec
+    if ((Q->NumElem) == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
+        PendForExec();
+        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
+        // so that it can get out of the loop
+    }
+
+    //release queue access
+    Mutex.Unlock();
+
+    // Signal the semaphore that controls the remote thread.
+    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
+    sema_status = RemoteThreadCtrlSema.Signal();
+    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
+    {
+        stat = OsclFailure;
+        return NULL;
+    }
+
+    return pData;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+FillBufferDoneThreadSafeCallbackAO::FillBufferDoneThreadSafeCallbackAO(void* aObserver,
+        uint32 aDepth,
+        const char* aAOname,
+        int32 aPriority)
+        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
+{
+
+    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
+    if (iMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
+    }
+    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
+    // created in the 2nd thread and will fail to deallocate properly.
+
+    OsclAny *dummy = iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData));
+    iMemoryPool->deallocate(dummy);
+}
+
+FillBufferDoneThreadSafeCallbackAO::~FillBufferDoneThreadSafeCallbackAO()
+{
+    if (iMemoryPool)
+    {
+
+        iMemoryPool->removeRef();
+        iMemoryPool = NULL;
+    }
+}
+
+OsclReturnCode FillBufferDoneThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
+{
+    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
+    if (iObserver != NULL)
+    {
+        PVMFOMXBaseDecNode* ptr = (PVMFOMXBaseDecNode*) iObserver;
+
+        ptr->ProcessCallbackFillBufferDone_MultiThreaded(EventData);
+
+    }
+    return OsclSuccess;
+}
+
+// We override the Run to process multiple (i.e. all in the queue) events in one Run
+
+void FillBufferDoneThreadSafeCallbackAO::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() In"));
+
+    OsclAny *P; // parameter to dequeue
+    OsclReturnCode status = OsclSuccess;
+
+    do
+    {
+
+
+        P = DeQueue(status);
+
+
+        if ((status == OsclSuccess) || (status == OsclPending))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() - Calling Process Event"));
+            ProcessEvent(P);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() - could not dequeue event data"));
+        }
+
+
+        // it is possible that an event arrives between dequeueing the last event and this point.
+        // If this is the case, we will be rescheduled and process the event
+        // in the next Run
+
+
+    }
+    while (status == OsclSuccess);
+    // if the status is "OsclPending" there were no more events in the queue
+    // (if another event arrived in the meanwhile, AO will be rescheduled)
+
+
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() Out"));
+}
+
+// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
+// (i.e. PendForExec control is done in the loop in Run)
+OsclAny* FillBufferDoneThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
+{
+    OsclAny *pData;
+    OsclProcStatus::eOsclProcError sema_status;
+
+    stat = OsclSuccess;
+
+    // Protect the queue while accessing it:
+    Mutex.Lock();
+
+    if (Q->NumElem == 0)
+    {
+        // nothing to de-queue
+        stat = OsclFailure;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
+        Mutex.Unlock();
+
+        return NULL;
+    }
+
+    pData = (Q->pFirst[Q->index_out]).pData;
+
+    Q->index_out++;
+    // roll-over the index
+    if (Q->index_out == Q->MaxNumElements)
+        Q->index_out = 0;
+
+    Q->NumElem--;
+    // check if there is need to call PendForExec
+    if ((Q->NumElem) == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
+        PendForExec();
+        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
+        // so that it can get out of the loop
+    }
+
+    //release queue access
+    Mutex.Unlock();
+
+    // Signal the semaphore that controls the remote thread.
+    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
+    sema_status = RemoteThreadCtrlSema.Signal();
+    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
+    {
+        stat = OsclFailure;
+        return NULL;
+    }
+
+    return pData;
+}
diff --git a/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp
new file mode 100644
index 0000000..5851af4
--- /dev/null
+++ b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_node.cpp
@@ -0,0 +1,5151 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_omx_basedec_node.h"
+#include "pvlogger.h"
+#include "oscl_error_codes.h"
+#include "pvmf_omx_basedec_port.h"
+#include "pv_mime_string_utils.h"
+#include "oscl_snprintf.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+#include "pvmi_kvp_util.h"
+
+#include "omx_core.h"
+#include "pvmf_omx_basedec_callbacks.h"     //used for thin AO in Decoder's callbacks
+#include "pv_omxcore.h"
+
+#define CONFIG_SIZE_AND_VERSION(param) \
+	    param.nSize=sizeof(param); \
+	    param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR; \
+	    param.nVersion.s.nVersionMinor = SPECVERSIONMINOR; \
+	    param.nVersion.s.nRevision = SPECREVISION; \
+	    param.nVersion.s.nStep = SPECSTEP;
+
+#define PVOMXBASEDEC_MEDIADATA_CHUNKSIZE 128
+
+
+// OMX CALLBACKS
+// 1) AO OMX component running in the same thread as the OMX node
+//	In this case, the callbacks can be called directly from the component
+//	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
+//	The callback can perform do RunIfNotReady
+
+// 2) Multithreaded component
+//	In this case, the callback is made using the threadsafe callback (TSCB) AO
+//	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent) => event is queued
+//  Node thread		 : dequeue event => TSCB(ProcessEvent)->ProcessCallbackEventHandler->EventHandlerProcessing
+
+
+
+// callback for Event Handler - in multithreaded case, event is queued to be processed later
+//	in AO case, event is processed immediately by calling EventHandlerProcessing
+OMX_ERRORTYPE CallbackEventHandler(OMX_OUT OMX_HANDLETYPE aComponent,
+                                   OMX_OUT OMX_PTR aAppData,
+                                   OMX_OUT OMX_EVENTTYPE aEvent,
+                                   OMX_OUT OMX_U32 aData1,
+                                   OMX_OUT OMX_U32 aData2,
+                                   OMX_OUT OMX_PTR aEventData)
+{
+
+    PVMFOMXBaseDecNode *Node = (PVMFOMXBaseDecNode *) aAppData;
+
+    if (Node->IsComponentMultiThreaded())
+    {
+        // allocate the memory for the callback event specific data
+        //EventHandlerSpecificData* ED = (EventHandlerSpecificData*) oscl_malloc(sizeof (EventHandlerSpecificData));
+        EventHandlerSpecificData* ED = (EventHandlerSpecificData*) Node->iThreadSafeHandlerEventHandler->iMemoryPool->allocate(sizeof(EventHandlerSpecificData));
+
+        // pack the relevant data into the structure
+        ED->hComponent = aComponent;
+        ED->pAppData = aAppData;
+        ED->eEvent = aEvent;
+        ED->nData1 = aData1;
+        ED->nData2 = aData2;
+        ED->pEventData = aEventData;
+
+        // convert the pointer into OsclAny ptr
+        OsclAny* P = (OsclAny*) ED;
+
+
+        // CALL the generic callback AO API:
+        Node->iThreadSafeHandlerEventHandler->ReceiveEvent(P);
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+
+        OMX_ERRORTYPE status;
+        status = Node->EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
+        return status;
+    }
+
+}
+
+// callback for EmptyBufferDone - in multithreaded case, event is queued to be processed later
+//	in AO case, event is processed immediately by calling EmptyBufferDoneProcessing
+OMX_ERRORTYPE CallbackEmptyBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
+                                      OMX_OUT OMX_PTR aAppData,
+                                      OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+
+    PVMFOMXBaseDecNode *Node = (PVMFOMXBaseDecNode *) aAppData;
+    if (Node->IsComponentMultiThreaded())
+    {
+
+        // allocate the memory for the callback event specific data
+        //EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) oscl_malloc(sizeof (EmptyBufferDoneSpecificData));
+        EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) Node->iThreadSafeHandlerEmptyBufferDone->iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData));
+
+        // pack the relevant data into the structure
+        ED->hComponent = aComponent;
+        ED->pAppData = aAppData;
+        ED->pBuffer = aBuffer;
+
+        // convert the pointer into OsclAny ptr
+        OsclAny* P = (OsclAny*) ED;
+
+        // CALL the generic callback AO API:
+        Node->iThreadSafeHandlerEmptyBufferDone->ReceiveEvent(P);
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        OMX_ERRORTYPE status;
+        status = Node->EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
+        return status;
+    }
+
+}
+
+// callback for FillBufferDone - in multithreaded case, event is queued to be processed later
+//	in AO case, event is processed immediately by calling FillBufferDoneProcessing
+OMX_ERRORTYPE CallbackFillBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
+                                     OMX_OUT OMX_PTR aAppData,
+                                     OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+    PVMFOMXBaseDecNode *Node = (PVMFOMXBaseDecNode *) aAppData;
+    if (Node->IsComponentMultiThreaded())
+    {
+
+        // allocate the memory for the callback event specific data
+        //FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) oscl_malloc(sizeof (FillBufferDoneSpecificData));
+        FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) Node->iThreadSafeHandlerFillBufferDone->iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData));
+
+        // pack the relevant data into the structure
+        ED->hComponent = aComponent;
+        ED->pAppData = aAppData;
+        ED->pBuffer = aBuffer;
+
+        // convert the pointer into OsclAny ptr
+        OsclAny* P = (OsclAny*) ED;
+
+        // CALL the generic callback AO API:
+        Node->iThreadSafeHandlerFillBufferDone->ReceiveEvent(P);
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        OMX_ERRORTYPE status;
+        status = Node->FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
+        return status;
+    }
+
+}
+
+// Callback processing in multithreaded case - dequeued event - call EventHandlerProcessing
+OSCL_EXPORT_REF OsclReturnCode PVMFOMXBaseDecNode::ProcessCallbackEventHandler_MultiThreaded(OsclAny* P)
+{
+
+    // re-cast the pointer
+
+    EventHandlerSpecificData* ED = (EventHandlerSpecificData*) P;
+
+    OMX_HANDLETYPE aComponent = ED->hComponent;
+    OMX_PTR aAppData = ED->pAppData;
+    OMX_EVENTTYPE aEvent = ED->eEvent;
+    OMX_U32 aData1 = ED->nData1;
+    OMX_U32 aData2 = ED->nData2;
+    OMX_PTR aEventData = ED->pEventData;
+
+
+    EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
+
+
+    // release the allocated memory when no longer needed
+
+    iThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);
+    ED = NULL;
+
+    return OsclSuccess;
+}
+
+
+
+// Callback processing in multithreaded case - dequeued event - call EmptyBufferDoneProcessing
+OSCL_EXPORT_REF OsclReturnCode PVMFOMXBaseDecNode::ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P)
+{
+
+
+    // re-cast the pointer
+    EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) P;
+
+    OMX_HANDLETYPE aComponent = ED->hComponent;
+    OMX_PTR aAppData = ED->pAppData;
+    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
+
+    EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
+
+    // release the allocated memory when no longer needed
+
+    iThreadSafeHandlerEmptyBufferDone->iMemoryPool->deallocate(ED);
+    ED = NULL;
+
+    return OsclSuccess;
+}
+
+
+// Callback processing in multithreaded case - dequeued event - call FillBufferDoneProcessing
+OSCL_EXPORT_REF OsclReturnCode PVMFOMXBaseDecNode::ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P)
+{
+
+    // re-cast the pointer
+    FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) P;
+
+    OMX_HANDLETYPE aComponent = ED->hComponent;
+    OMX_PTR aAppData = ED->pAppData;
+    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
+
+
+    FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
+
+
+    // release the allocated memory when no longer needed
+
+    iThreadSafeHandlerFillBufferDone->iMemoryPool->deallocate(ED);
+    ED = NULL;
+
+    return OsclSuccess;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Class Destructor
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFOMXBaseDecNode::~PVMFOMXBaseDecNode()
+{
+    LogDiagnostics();
+
+    //Clearup decoder
+    DeleteOMXBaseDecoder();
+
+    // Cleanup callback AOs and Mempools
+    if (iThreadSafeHandlerEventHandler)
+    {
+        OSCL_DELETE(iThreadSafeHandlerEventHandler);
+        iThreadSafeHandlerEventHandler = NULL;
+    }
+    if (iThreadSafeHandlerEmptyBufferDone)
+    {
+        OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
+        iThreadSafeHandlerEmptyBufferDone = NULL;
+    }
+    if (iThreadSafeHandlerFillBufferDone)
+    {
+        OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
+        iThreadSafeHandlerFillBufferDone = NULL;
+    }
+
+    if (iMediaDataMemPool)
+    {
+        iMediaDataMemPool->removeRef();
+        iMediaDataMemPool = NULL;
+    }
+
+    if (iOutBufMemoryPool)
+    {
+        iOutBufMemoryPool->removeRef();
+        iOutBufMemoryPool = NULL;
+    }
+    if (iInBufMemoryPool)
+    {
+        iInBufMemoryPool->removeRef();
+        iInBufMemoryPool = NULL;
+    }
+
+    //Thread logoff
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+        iIsAdded = false;
+    }
+
+    //Cleanup commands
+    //The command queues are self-deleting, but we want to
+    //notify the observer of unprocessed commands.
+    while (!iCurrentCommand.empty())
+    {
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
+    }
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+    }
+
+    //Release Input buffer
+    iDataIn.Unbind();
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Remove AO from the scheduler
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::ThreadLogoff()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "%s:ThreadLogoff", iName.Str()));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            if (IsAdded())
+            {
+                RemoveFromScheduler();
+                iIsAdded = false;
+            }
+            iLogger = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+
+
+        default:
+            return PVMFErrInvalidState;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::GetCapability() called", iName.Str()));
+
+    aNodeCapability = iCapability;
+    return PVMFSuccess;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFPortIter* PVMFOMXBaseDecNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::GetPorts() called", iName.Str()));
+
+    OSCL_UNUSED_ARG(aFilter);
+
+    return NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::QueueCommandL(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iInputCommands.AddL(aCmd);
+
+    if (iInputCommands.size() == 1)
+    {
+        //wakeup the AO all the rest of input commands will reschedule the AO in Run
+        RunIfNotReady();
+    }
+    return id;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, PVMFOMXBaseDecNodeAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::QueryUUID() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::QueryInterface() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* /* aPortConfig */, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::RequestPort() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_REQUESTPORT, aPortTag, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ReleasePort() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Init() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Prepare() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Start() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Stop() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Flush() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Pause() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Reset() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::CancelAllCommands() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_CANCELALL, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::CancelCommand() called", iName.Str()));
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommandBase::Construct(s, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_CANCELCMD, aCmdId, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::SetDecoderNodeConfiguration(PVMFOMXBaseDecNodeConfig& aNodeConfig)
+{
+    iNodeConfig = aNodeConfig;
+    return PVMFSuccess;
+}
+
+
+/////////////////////
+// Private Section //
+/////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Class Constructor
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFOMXBaseDecNode::PVMFOMXBaseDecNode(int32 aPriority, const char aAOName[]) :
+        OsclActiveObject(aPriority, aAOName),
+        iInPort(NULL),
+        iOutPort(NULL),
+        iOutBufMemoryPool(NULL),
+        iMediaDataMemPool(NULL),
+        iOMXComponentOutputBufferSize(0),
+        iOutputAllocSize(0),
+        iProcessingState(EPVMFOMXBaseDecNodeProcessingState_Idle),
+        iOMXDecoder(NULL),
+        iSendBOS(false),
+        iStreamID(0),
+        iBOSTimestamp(0),
+        iSeqNum(0),
+        iSeqNum_In(0),
+        iIsAdded(true),
+        iLogger(NULL),
+        iDataPathLogger(NULL),
+        iClockLogger(NULL),
+        iExtensionRefCount(0),
+        iEndOfDataReached(false),
+        iEndOfDataTimestamp(0),
+        iDiagnosticsLogger(NULL),
+        iDiagnosticsLogged(false),
+        iAvgBitrateValue(0),
+        iResetInProgress(false),
+        iResetMsgSent(false),
+        iStopInResetMsgSent(false)
+{
+    iThreadSafeHandlerEventHandler = NULL;
+    iThreadSafeHandlerEmptyBufferDone = NULL;
+    iThreadSafeHandlerFillBufferDone = NULL;
+
+    iInBufMemoryPool = NULL;
+    iOutBufMemoryPool = NULL;
+
+    // init to some value
+    iOMXComponentOutputBufferSize = 0;
+    iNumOutputBuffers = 0;
+    iOMXComponentInputBufferSize = 0;
+    iNumInputBuffers = 0;
+
+    iDoNotSendOutputBuffersDownstreamFlag = false;
+    iDoNotSaveInputBuffersFlag = false;
+
+    iOutputBuffersFreed = true;// buffers have not been created yet, so they can be considered freed
+    iInputBuffersFreed = true;
+
+    // dynamic port reconfig init vars
+    iSecondPortReportedChange = false;
+    iDynamicReconfigInProgress = false;
+    iPauseCommandWasSentToComponent = false;
+    iStopCommandWasSentToComponent = false;
+
+    // EOS flag init
+    iIsEOSSentToComponent = false;
+    iIsEOSReceivedFromComponent = false;
+
+    // reset repositioning related flags
+    iIsRepositioningRequestSentToComponent = false;
+    iIsRepositionDoneReceivedFromComponent = false;
+    iIsOutputPortFlushed = false;
+    iIsInputPortFlushed = false;
+
+    // init state of component
+    iCurrentDecoderState = OMX_StateInvalid;
+
+    iOutTimeStamp = 0;
+
+    // counts output frames (for logging)
+    iFrameCounter = 0;
+    iInputBufferUnderConstruction = NULL; // for partial frame assembly
+    iFirstPieceOfPartialFrame = true;
+    iObtainNewInputBuffer = true;
+    iFirstDataMsgAfterBOS = true;
+    iKeepDroppingMsgsUntilMarkerBit = false;
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Local Run Routine
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Run() In", iName.Str()));
+
+    // if reset is in progress, call DoReset again until Reset Msg is sent
+    if ((iResetInProgress == true) &&
+            (iResetMsgSent == false) &&
+            (iCurrentCommand.size() > 0) &&
+            (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+       )
+    {
+        DoReset(iCurrentCommand.front());
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Calling DoReset", iName.Str()));
+        return; // don't do anything else
+    }
+    //Check for NODE commands...
+    if (!iInputCommands.empty())
+    {
+        if (ProcessCommand(iInputCommands.front()))
+        {
+            if (iInterfaceState != EPVMFNodeCreated
+                    && (!iInputCommands.empty() || (iInPort && (iInPort->IncomingMsgQueueSize() > 0)) ||
+                        (iDataIn.GetRep() != NULL) || (iDynamicReconfigInProgress == true) ||
+                        ((iNumOutstandingOutputBuffers < iNumOutputBuffers) &&
+                         (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode))
+                       ))
+            {
+                // reschedule if more data is available, or if port reconfig needs to be finished (even if there is no new data)
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - rescheduling after process command", iName.Str()));
+                RunIfNotReady();
+            }
+            return;
+        }
+
+        if (!iInputCommands.empty())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - rescheduling to process more commands", iName.Str()));
+            RunIfNotReady();
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Input commands empty", iName.Str()));
+    }
+
+    if (((iCurrentCommand.size() == 0) && (iInterfaceState != EPVMFNodeStarted)) ||
+            ((iCurrentCommand.size() > 0) && (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_START) && (iInterfaceState != EPVMFNodeStarted)))
+    {
+        // rescheduling because of input data will be handled in Command Processing Part
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Node not in Started state yet", iName.Str()));
+        return;
+    }
+
+
+    // Process port activity, push out all outgoing messages
+    if (iOutPort)
+    {
+        while (iOutPort->OutgoingMsgQueueSize())
+        {
+            // if port is busy it is going to wakeup from port ready event
+            if (!ProcessOutgoingMsg(iOutPort))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Outgoing Port Busy, cannot send more msgs", iName.Str()));
+                break;
+            }
+        }
+    }
+    int loopCount = 0;
+#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
+    uint32 startticks = OsclTickCount::TickCount();
+    uint32 starttime = OsclTickCount::TicksToMsec(startticks);
+#endif
+    do // Try to consume all the data from the Input port
+    {
+        // Process port activity if there is no input data that is being processed
+        // Do not accept any input if EOS needs to be sent out
+        if (iInPort && (iInPort->IncomingMsgQueueSize() > 0) && (iDataIn.GetRep() == NULL) &&
+                (!iEndOfDataReached) &&
+                (!iDynamicReconfigInProgress) &&
+                (!iIsRepositioningRequestSentToComponent)
+           )
+
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Getting more input", iName.Str()));
+            if (!ProcessIncomingMsg(iInPort))
+            {
+                //Re-schedule
+                RunIfNotReady();
+                return;
+            }
+        }
+
+        if (iSendBOS)
+        {
+
+            // this routine may be re-entered multiple times in multiple Run's before the component goes through cycle execute->idle->execute
+            if (!HandleRepositioning())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Repositioning not done yet", iName.Str()));
+
+                return;
+            }
+
+            SendBeginOfMediaStreamCommand();
+
+
+        }
+        // If in init or ready to decode state, process data in the input port if there is input available and input buffers are present
+        // (note: at EOS, iDataIn will not be available)
+
+        if ((iDataIn.GetRep() != NULL) ||
+                ((iNumOutstandingOutputBuffers < iNumOutputBuffers) &&
+                 (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode) &&
+                 (iResetMsgSent == false)) ||
+                ((iDynamicReconfigInProgress == true) && (iResetMsgSent == false))
+
+           )
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::Run() - Calling HandleProcessingState", iName.Str()));
+
+            // input data is available, that means there is input data to be decoded
+            if (HandleProcessingState() != PVMFSuccess)
+            {
+                // If HandleProcessingState does not return Success, we must wait for an event
+                // no point in  rescheduling
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "%s::Run() - HandleProcessingState did not return Success", iName.Str()));
+
+                return;
+            }
+        }
+
+        loopCount++;
+    }
+    while (iInPort &&
+            (((iInPort->IncomingMsgQueueSize() > 0) || (iDataIn.GetRep() != NULL)) && (iNumOutstandingInputBuffers < iNumInputBuffers))
+            && (!iEndOfDataReached)
+            && (iResetMsgSent == false)
+          );
+#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
+    uint32 endticks = OsclTickCount::TickCount();
+    uint32 endtime = OsclTickCount::TicksToMsec(endticks);
+    uint32 timeinloop;
+    timeinloop = (endtime - starttime);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iRunlLogger, PVLOGMSG_INFO,
+                    (0, "%s::Run() - LoopCount = %d, Time spent in loop(in ms) = %d, iNumOutstandingInputBuffers = %d, iNumOutstandingOutputBuffers = %d ",
+                     iName.Str(), loopCount, timeinloop, iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
+#endif
+
+    // EOS processing:
+    // first send an empty buffer to OMX component and mark the EOS flag
+    // wait for the OMX component to send async event to indicate that it has reached this EOS buffer
+    // then, create and send the EOS message downstream
+
+    if (iEndOfDataReached && !iDynamicReconfigInProgress)
+    {
+
+        // if EOS was not sent yet and we have an available input buffer, send EOS buffer to component
+        if (!iIsEOSSentToComponent && (iNumOutstandingInputBuffers < iNumInputBuffers))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::Run() - Sending EOS marked buffer To Component ", iName.Str()));
+
+            iIsEOSSentToComponent = true;
+
+            // if the component is not yet initialized or if it's in the middle of port reconfig,
+            // don't send EOS buffer to component. It does not care. Just set the flag as if we received
+            // EOS from the component to enable sending EOS downstream
+            if (iProcessingState != EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+            {
+
+                iIsEOSReceivedFromComponent = true;
+            }
+            else if (!SendEOSBufferToOMXComponent())
+
+            {
+                // for some reason, Component can't receive the EOS buffer
+                // it could be that it is not initialized yet (because EOS could be the first msg). In this case,
+                // send the EOS downstream anyway
+                iIsEOSReceivedFromComponent = true;
+            }
+        }
+
+        // DV: we must wait for event (acknowledgment from component)
+        // before sending EOS downstream. This is because OMX Component will send
+        // the EOS event only after processing remaining buffers
+
+        if (iIsEOSReceivedFromComponent)
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::Run() - Received EOS from component, Sending EOS msg downstream ", iName.Str()));
+
+            if (iOutPort && iOutPort->IsOutgoingQueueBusy())
+            {
+                // note: we already tried to empty the outgoing q. If it's still busy,
+                // it means that output port is busy. Just return and wait for the port to become free.
+                // this will wake up the node and it will send out a msg from the q etc.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "%s::Run() - - EOS cannot be sent downstream, outgoing queue busy - wait", iName.Str()));
+                return;
+            }
+
+            if (SendEndOfTrackCommand()) // this will only q the EOS
+            {
+                // EOS send downstream OK, so reset the flag
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "%s::Run() - EOS was queued to be sent downstream", iName.Str()));
+
+                iEndOfDataReached = false; // to resume normal processing, reset the flags
+                iIsEOSSentToComponent = false;
+                iIsEOSReceivedFromComponent = false;
+
+                RunIfNotReady(); // Run again to send out the EOS msg from the outgoing q, and resume
+                // normal processing
+                ReportInfoEvent(PVMFInfoEndOfData);
+            }
+        }
+        else
+        {
+            // keep sending output buffers, it's possible that the component needs to flush output
+            //	data at the end
+            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
+            {
+                if (!SendOutputBufferToOMXComponent())
+                    break;
+            }
+        }
+
+    }
+
+
+    //Check for flash command complition...
+    if (iInPort && iOutPort && (iCurrentCommand.size() > 0) &&
+            (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_FLUSH) &&
+            (iInPort->IncomingMsgQueueSize() == 0) &&
+            (iOutPort->OutgoingMsgQueueSize() == 0) &&
+            (iDataIn.GetRep() == NULL))
+    {
+        //flush command is complited
+        //Debug check-- all the port queues should be empty at this point.
+
+        OSCL_ASSERT(iInPort->IncomingMsgQueueSize() == 0 && iOutPort->OutgoingMsgQueueSize() == 0);
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "%s::Run() - Flush pending", iName.Str()));
+        iEndOfDataReached = false;
+        iIsEOSSentToComponent = false;
+        iIsEOSReceivedFromComponent = false;
+
+
+        //Flush is complete.  Go to initialized state.
+        SetState(EPVMFNodePrepared);
+        //resume port input so the ports can be re-started.
+        iInPort->ResumeInput();
+        iOutPort->ResumeInput();
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+        RunIfNotReady();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::Run() Out", iName.Str()));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will dispatch recived commands
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::ProcessCommand(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    //normally this node will not start processing one command
+    //until the prior one is finished.  However, a hi priority
+    //command such as Cancel must be able to interrupt a command
+    //in progress.
+    if (!iCurrentCommand.empty() && !aCmd.hipri())
+        return false;
+
+    switch (aCmd.iCmd)
+    {
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_QUERYUUID:
+            DoQueryUuid(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_INIT:
+            DoInit(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_PREPARE:
+            DoPrepare(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_START:
+            DoStart(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_STOP:
+            DoStop(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_FLUSH:
+            DoFlush(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_PAUSE:
+            DoPause(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET:
+            DoReset(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_CANCELCMD:
+            DoCancelCommand(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_CANCELALL:
+            DoCancelAllCommands(aCmd);
+            break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_GETNODEMETADATAKEY:
+        {
+            PVMFStatus retval = DoGetNodeMetadataKey(aCmd);
+            CommandComplete(iInputCommands, aCmd, retval);
+        }
+        break;
+
+        case PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_GETNODEMETADATAVALUE:
+        {
+            PVMFStatus retval = DoGetNodeMetadataValue(aCmd);
+            CommandComplete(iInputCommands, aCmd, retval);
+        }
+        break;
+
+        default://unknown command type
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            break;
+    }
+
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will process incomming message from the port
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
+{
+    //Called by the AO to process one buffer off the port's
+    //incoming data queue.  This routine will dequeue and
+    //dispatch the data.
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x %s::ProcessIncomingMsg: aPort=0x%x", this, iName.Str(), aPort));
+
+    PVMFStatus status = PVMFFailure;
+
+
+//#define SIMULATE_BOS
+#ifdef SIMULATE_BOS
+
+    if (((PVMFOMXDecPort*)aPort)->iNumFramesConsumed == 6))
+    {
+
+        PVMFSharedMediaCmdPtr BOSCmdPtr = PVMFMediaCmd::createMediaCmd();
+
+        // Set the format ID to BOS
+        BOSCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
+
+        // Set the timestamp
+        BOSCmdPtr->setTimestamp(201);
+        BOSCmdPtr->setStreamID(0);
+
+        // Convert to media message and send it out
+        PVMFSharedMediaMsgPtr mediaMsgOut;
+        convertToPVMFMediaCmdMsg(mediaMsgOut, BOSCmdPtr);
+
+        //store the stream id and time stamp of bos message
+        iStreamID = mediaMsgOut->getStreamID();
+        iBOSTimestamp = mediaMsgOut->getTimestamp();
+        iSendBOS = true;
+
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
+        return true;
+
+    }
+#endif
+//#define SIMULATE_PREMATURE_EOS
+#ifdef SIMULATE_PREMATURE_EOS
+    if (((PVMFOMXDecPort*)aPort)->iNumFramesConsumed == 5)
+    {
+        PVMFSharedMediaCmdPtr EOSCmdPtr = PVMFMediaCmd::createMediaCmd();
+
+        // Set the format ID to EOS
+        EOSCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
+
+        // Set the timestamp
+        EOSCmdPtr->setTimestamp(200);
+
+        // Convert to media message and send it out
+        PVMFSharedMediaMsgPtr mediaMsgOut;
+        convertToPVMFMediaCmdMsg(mediaMsgOut, EOSCmdPtr);
+
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::ProcessIncomingMsg: SIMULATED EOS", iName.Str()));
+
+        // Set EOS flag
+        iEndOfDataReached = true;
+        // Save the timestamp for the EOS cmd
+        iEndOfDataTimestamp = mediaMsgOut->getTimestamp();
+
+        return true;
+    }
+
+#endif
+
+
+
+    PVMFSharedMediaMsgPtr msg;
+
+    status = aPort->DequeueIncomingMsg(msg);
+    if (status != PVMFSuccess)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "0x%x %s::ProcessIncomingMsg: Error - DequeueIncomingMsg failed", this, iName.Str()));
+        return false;
+    }
+
+    if (msg->getFormatID() == PVMF_MEDIA_CMD_BOS_FORMAT_ID)
+    {
+        //store the stream id and time stamp of bos message
+        iStreamID = msg->getStreamID();
+        iBOSTimestamp = msg->getTimestamp();
+        iSendBOS = true;
+
+        // if new BOS arrives, and
+        //if we're in the middle of a partial frame assembly
+        // abandon it and start fresh
+        if (iObtainNewInputBuffer == false)
+        {
+            if (iInputBufferUnderConstruction != NULL)
+            {
+                if (iInBufMemoryPool != NULL)
+                {
+                    iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
+                }
+                iInputBufferUnderConstruction = NULL;
+            }
+            iObtainNewInputBuffer = true;
+
+        }
+
+        // needed to init the sequence numbers and timestamp for partial frame assembly
+        iFirstDataMsgAfterBOS = true;
+        iKeepDroppingMsgsUntilMarkerBit = false;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::ProcessIncomingMsg: Received BOS stream %d, timestamp %d", iName.Str(), iStreamID, iBOSTimestamp));
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
+        return true;
+    }
+    else if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+    {
+        // Set EOS flag
+        iEndOfDataReached = true;
+        // Save the timestamp for the EOS cmd
+        iEndOfDataTimestamp = msg->getTimestamp();
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::ProcessIncomingMsg: Received EOS", iName.Str()));
+
+        ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
+        return true; // do not do conversion into media data, just set the flag and leave
+    }
+
+    convertToPVMFMediaData(iDataIn, msg);
+
+
+    iCurrFragNum = 0; // for new message, reset the fragment counter
+    iIsNewDataFragment = true;
+
+    ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed++;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ProcessIncomingMsg() Received %d frames", iName.Str(), ((PVMFOMXDecPort*)aPort)->iNumFramesConsumed));
+
+    //return true if we processed an activity...
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will process outgoing message by sending it into output the port
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::ProcessOutgoingMsg(PVMFPortInterface* aPort)
+{
+    //Called by the AO to process one message off the outgoing
+    //message queue for the given port.  This routine will
+    //try to send the data to the connected port.
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x %s::ProcessOutgoingMsg: aPort=0x%x", this, iName.Str(), aPort));
+
+    PVMFStatus status = aPort->Send();
+    if (status == PVMFErrBusy)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "0x%x %s::ProcessOutgoingMsg: Connected port goes into busy state", this, iName.Str()));
+    }
+
+    //Report any unexpected failure in port processing...
+    //(the InvalidState error happens when port input is suspended,
+    //so don't report it.)
+    if (status != PVMFErrBusy
+            && status != PVMFSuccess
+            && status != PVMFErrInvalidState)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x %s::Run: Error - ProcessPortActivity failed. port=0x%x, type=%d",
+                         this, iName.Str(), iOutPort, PVMF_PORT_ACTIVITY_OUTGOING_MSG));
+        ReportErrorEvent(PVMFErrPortProcessing);
+    }
+
+    //return true if we processed an activity...
+    return (status != PVMFErrBusy);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will process received data usign State Machine
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXBaseDecNode::HandleProcessingState()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::HandleProcessingState() In", iName.Str()));
+
+    PVMFStatus status = PVMFSuccess;
+
+    switch (iProcessingState)
+    {
+        case EPVMFOMXBaseDecNodeProcessingState_InitDecoder:
+        {
+            // do init only if input data is available
+            if (iDataIn.GetRep() != NULL)
+            {
+                if (!InitDecoder(iDataIn))
+                {
+                    // Decoder initialization failed. Fatal error
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::HandleProcessingState() Decoder initialization failed", iName.Str()));
+                    ReportErrorEvent(PVMFErrResourceConfiguration);
+                    ChangeNodeState(EPVMFNodeError);
+                    break;
+                }
+
+                // if a callback already happened, continue to decoding. If not, wait
+                // it is also possible that port settings changed event may occur.
+                //DV: temp
+                //if(iProcessingState != EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+                //	iProcessingState = EPVMFOMXBaseDecNodeProcessingState_WaitForInitCompletion;
+
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
+                // spin once to send output buffers
+                RunIfNotReady();
+                status = PVMFSuccess; // allow rescheduling
+            }
+            break;
+        }
+
+        case EPVMFOMXBaseDecNodeProcessingState_WaitForInitCompletion:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() WaitForInitCompletion -> wait for config buffer to return", iName.Str()));
+
+
+            status = PVMFPending; // prevent rescheduling
+            break;
+        }
+        // The FOLLOWING 4 states handle Dynamic Port Reconfiguration
+        case EPVMFOMXBaseDecNodeProcessingState_PortReconfig:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Port Reconfiguration -> Sending Flush Command", iName.Str()));
+
+
+            // Collect all buffers first (before starting the portDisable command)
+            // FIRST send a flush command. This will return all buffers from the component. Any outstanding buffers are in MIO
+            // Then wait for all buffers to come back from MIO. If we haven't sent port disable, we'll be able to process
+            // other commands in the copmponent (such as pause, stop etc.)
+            OMX_ERRORTYPE err = OMX_ErrorNone;
+            OMX_STATETYPE sState;
+
+            // first check the state (if executing or paused, continue)
+            err = OMX_GetState(iOMXDecoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::HandleProcessingState (): PortReconfig Can't get State of decoder - trying to send port flush request!", iName.Str()));
+
+                sState = OMX_StateInvalid;
+                ReportErrorEvent(PVMFErrResourceConfiguration);
+                ChangeNodeState(EPVMFNodeError);
+                status = PVMFFailure;
+                break;
+            }
+
+            if ((sState != OMX_StateExecuting) && (sState != OMX_StatePause))
+            {
+
+                // possibly as a consequence of a previously queued cmd to go to Idle state?
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::HandleProcessingState (): PortReconfig: Component State is not executing or paused, do not proceed with port flush", iName.Str()));
+
+
+            }
+            else
+            {
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::HandleProcessingState (): PortReconfig Sending Flush command to component", iName.Str()));
+
+
+                // the port will now start returning outstanding buffers
+                // set the flag to prevent output from going downstream (in case of output port being reconfigd)
+                // set the flag to prevent input from being saved and returned to component (in case of input port being reconfigd)
+                // set the state to wait for port saying it is disabled
+                if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+                {
+                    iDoNotSendOutputBuffersDownstreamFlag = true;
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::HandleProcessingState() Port Reconfiguration -> Output Port", iName.Str()));
+
+                }
+                else if (iPortIndexForDynamicReconfig == iInputPortIndex)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::HandleProcessingState() Port Reconfiguration -> Input Port", iName.Str()));
+
+                    iDoNotSaveInputBuffersFlag = true;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::HandleProcessingState() Port Reconfiguration -> UNKNOWN PORT", iName.Str()));
+
+                    sState = OMX_StateInvalid;
+                    ReportErrorEvent(PVMFErrResourceConfiguration);
+                    ChangeNodeState(EPVMFNodeError);
+                    status = PVMFFailure;
+                    break;
+
+                }
+
+                // send command to flush appropriate port
+                err = OMX_SendCommand(iOMXDecoder, OMX_CommandFlush, iPortIndexForDynamicReconfig, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::HandleProcessingState (): PortReconfig : Can't send flush command !", iName.Str()));
+
+                    sState = OMX_StateInvalid;
+                    ReportErrorEvent(PVMFErrResourceConfiguration);
+                    ChangeNodeState(EPVMFNodeError);
+                    status = PVMFFailure;
+                    break;
+                }
+
+
+
+            }
+
+            // now sit back and wait for buffers to return
+            // if there is a pause/stop cmd in the meanwhile, component will process it
+            // and the node will end up in pause/stop state (so this internal state does not matter)
+            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_WaitForBufferReturn;
+
+
+            // fall through to the next case to check if all buffers are already back
+
+
+
+        }
+
+        case EPVMFOMXBaseDecNodeProcessingState_WaitForBufferReturn:
+        {
+            // as buffers are coming back, Run may be called, wait until all buffers are back, then Free them all
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn ", iName.Str()));
+            // check if it's output port being reconfigured
+            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+            {
+                // if all buffers have returned, free them
+                if (iNumOutstandingOutputBuffers == 0)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::HandleProcessingState() Port Reconfiguration -> all output buffers are back, free them", iName.Str()));
+
+                    // port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
+                    OMX_SendCommand(iOMXDecoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
+
+
+                    if (false == iOutputBuffersFreed)
+                    {
+                        if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
+                                                      iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                      iNumOutputBuffers, // number of buffers
+                                                      iOutputPortIndex, // port idx
+                                                      false // this is not input
+                                                     ))
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "%s::HandleProcessingState() Port Reconfiguration -> Cannot free output buffers ", iName.Str()));
+
+                            SetState(EPVMFNodeError);
+                            ReportErrorEvent(PVMFErrNoMemory);
+                            return PVMFErrNoMemory;
+                        }
+                    }
+                    // if the callback (that port is disabled) has not arrived yet, wait for it
+                    // if it has arrived, it will set the state to PortReEnable
+                    if (iProcessingState != EPVMFOMXBaseDecNodeProcessingState_PortReEnable)
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_WaitForPortDisable;
+
+                    status = PVMFSuccess; // allow rescheduling of the node potentially
+                }
+                else
+                    status = PVMFPending; // must wait for buffers to come back. No point in automatic rescheduling
+                // but each buffer will reschedule the node when it comes in
+            }
+            else
+            {
+                // this is input port
+
+                // if all buffers have returned, free them
+                if (iNumOutstandingInputBuffers == 0)
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::HandleProcessingState() Port Reconfiguration -> all input buffers are back, free them", iName.Str()));
+
+                    // port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
+                    OMX_SendCommand(iOMXDecoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
+
+                    if (false == iInputBuffersFreed)
+                    {
+                        if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
+                                                      iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                      iNumInputBuffers, // number of buffers
+                                                      iInputPortIndex, // port idx
+                                                      true // this is input
+                                                     ))
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "%s::HandleProcessingState() Port Reconfiguration -> Cannot free input buffers ", iName.Str()));
+
+                            SetState(EPVMFNodeError);
+                            ReportErrorEvent(PVMFErrNoMemory);
+                            return PVMFErrNoMemory;
+
+                        }
+                    }
+                    // if the callback (that port is disabled) has not arrived yet, wait for it
+                    // if it has arrived, it will set the state to PortReEnable
+                    if (iProcessingState != EPVMFOMXBaseDecNodeProcessingState_PortReEnable)
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_WaitForPortDisable;
+
+                    status = PVMFSuccess; // allow rescheduling of the node
+                }
+                else
+                    status = PVMFPending; // must wait for buffers to come back. No point in automatic
+                // rescheduling. Each buffer will reschedule the node
+                // when it comes in
+            }
+
+
+            // the state will be changed to PortReEnable once we get confirmation that Port was actually disabled
+            break;
+        }
+
+        case EPVMFOMXBaseDecNodeProcessingState_WaitForPortDisable:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Port Reconfiguration -> wait for port disable callback", iName.Str()));
+            // do nothing. Just wait for the port to become disabled (we'll get event from component, which will
+            // transition the state to PortReEnable
+            status = PVMFPending; // prevent Rescheduling the node
+            break;
+        }
+
+        case EPVMFOMXBaseDecNodeProcessingState_PortReEnable:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Port Reconfiguration -> Sending reenable port command", iName.Str()));
+
+            status = HandlePortReEnable();
+            break;
+        }
+
+        case EPVMFOMXBaseDecNodeProcessingState_WaitForPortEnable:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Port Reconfiguration -> wait for port enable callback", iName.Str()));
+            // do nothing. Just wait for the port to become enabled (we'll get event from component, which will
+            // transition the state to ReadyToDecode
+            status = PVMFPending; // prevent ReScheduling
+            break;
+        }
+
+        // NORMAL DATA FLOW STATE:
+        case EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Ready To Decode start", iName.Str()));
+            // In normal data flow and decoding state
+            // Send all available output buffers to the decoder
+
+            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
+            {
+                // grab buffer header from the mempool if possible, and send to component
+                if (!SendOutputBufferToOMXComponent())
+
+                    break;
+
+            }
+
+
+            // next, see if partially consumed input buffer needs to be resent back to OMX component
+            // NOTE: it is not allowed that the component returns more than 1 partially consumed input buffers
+            //		 i.e. if a partially consumed input buffer is returned, it is assumed that the OMX component
+            //		 will be waiting to get data
+
+            if (iInputBufferToResendToComponent != NULL)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "%s::HandleProcessingState() Sending previous - partially consumed input back to the OMX component", iName.Str()));
+
+                OMX_EmptyThisBuffer(iOMXDecoder, iInputBufferToResendToComponent);
+                iInputBufferToResendToComponent = NULL; // do this only once
+            }
+            else if ((iNumOutstandingInputBuffers < iNumInputBuffers) && (iDataIn.GetRep() != NULL))
+            {
+                // try to get an input buffer header
+                // and send the input data over to the component
+                SendInputBufferToOMXComponent();
+            }
+
+            status = PVMFSuccess;
+            break;
+
+
+        }
+        case EPVMFOMXBaseDecNodeProcessingState_Stopping:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Stopping -> wait for Component to move from Executing->Idle", iName.Str()));
+
+
+            status = PVMFPending; // prevent rescheduling
+            break;
+        }
+
+        case EPVMFOMXBaseDecNodeProcessingState_Pausing:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleProcessingState() Pausing -> wait for Component to move from Executing->Pause", iName.Str()));
+
+
+            status = PVMFPending; // prevent rescheduling
+            break;
+        }
+
+
+        case EPVMFOMXBaseDecNodeProcessingState_WaitForOutgoingQueue:
+            status = PVMFPending;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::HandleProcessingState() Do nothing since waiting for output port queue to become available", iName.Str()));
+            break;
+
+        default:
+            break;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::HandleProcessingState() Out", iName.Str()));
+
+    return status;
+
+}
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::SendOutputBufferToOMXComponent()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendOutputBufferToOMXComponent() In", iName.Str()));
+
+
+    OutputBufCtrlStruct *output_buf = NULL;
+    int32 errcode = OsclErrNone;
+
+    // try to get output buffer header
+    OSCL_TRY(errcode, output_buf = (OutputBufCtrlStruct *) iOutBufMemoryPool->allocate(iOutputAllocSize));
+    if (OsclErrNone != errcode)
+    {
+        if (OsclErrNoResources == errcode)
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                            PVLOGMSG_DEBUG, (0, "%s::SendOutputBufferToOMXComponent() No more output buffers in the mempool", iName.Str()));
+
+            iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *) iOutBufMemoryPool); // To signal when next deallocate() is called on mempool
+
+            return false;
+        }
+        else
+        {
+            // Memory allocation for the pool failed
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::SendOutputBufferToOMXComponent() Output mempool error", iName.Str()));
+
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return false;
+        }
+
+    }
+
+    //for every allocated buffer, make sure you notify when buffer is released. Keep track of allocated buffers
+    // use mempool as context to recognize which buffer (input or output) was returned
+    iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *)iOutBufMemoryPool);
+    iNumOutstandingOutputBuffers++;
+
+    output_buf->pBufHdr->nFilledLen = 0; // make sure you tell OMX component buffer is empty
+    output_buf->pBufHdr->nOffset = 0;
+    output_buf->pBufHdr->pAppPrivate = output_buf; // set pAppPrivate to be pointer to output_buf
+    // (this is context for future release of this buffer to the mempool)
+    // this was done during buffer creation, but still repeat just in case
+
+    output_buf->pBufHdr->nFlags = 0; // zero out the flags
+
+    OMX_FillThisBuffer(iOMXDecoder, output_buf->pBufHdr);
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendOutputBufferToOMXComponent() Out", iName.Str()));
+
+    return true;
+}
+////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::SetDefaultCapabilityFlags()
+{
+
+    iIsOMXComponentMultiThreaded = true;
+
+    iOMXComponentSupportsExternalOutputBufferAlloc = false;
+    iOMXComponentSupportsExternalInputBufferAlloc = false;
+    iOMXComponentSupportsMovableInputBuffers = false;
+    iOMXComponentNeedsNALStartCode = true;
+    iOMXComponentSupportsPartialFrames = false;
+    iOMXComponentCanHandleIncompleteFrames = true;
+
+    return true;
+}
+
+
+
+bool PVMFOMXBaseDecNode::SendEOSBufferToOMXComponent()
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendEOSBufferToOMXComponent() In", iName.Str()));
+
+
+    // first of all, check if the component is running. EOS could be sent prior to component/decoder
+    // even being initialized
+
+    // returning false will ensure that the EOS will be sent downstream anyway without waiting for the
+    // Component to respond
+    if (iCurrentDecoderState != OMX_StateExecuting)
+        return false;
+
+    // get an input buffer. Without a buffer, no point in proceeding
+    InputBufCtrlStruct *input_buf = NULL;
+    int32 errcode = OsclErrNone;
+
+    // we already checked that the number of buffers is OK, so we don't expect problems
+    // try to get input buffer header
+    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
+    if (OsclErrNone != errcode)
+    {
+        if (OsclErrNoResources == errcode)
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                            PVLOGMSG_DEBUG, (0, "%s::SendEOSBufferToOMXComponent() No more buffers in the mempool - unexpected", iName.Str()));
+
+            iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
+
+            return false;
+        }
+        else
+        {
+            // Memory allocation for the pool failed
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::SendEOSBufferToOMXComponent() Input mempool error", iName.Str()));
+
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return false;
+        }
+
+    }
+
+    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
+    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
+    iNumOutstandingInputBuffers++;
+
+    // in this case, no need to use input msg refcounter. Make sure its unbound
+    (input_buf->pMediaData).Unbind();
+
+    // THIS IS AN EMPTY BUFFER. FLAGS ARE THE ONLY IMPORTANT THING
+    input_buf->pBufHdr->nFilledLen = 0;
+    input_buf->pBufHdr->nOffset = 0;
+    input_buf->pBufHdr->nTimeStamp = iEndOfDataTimestamp;
+
+    // set ptr to input_buf structure for Context (for when the buffer is returned)
+    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
+
+    // do not use Mark here (but init to NULL to prevent problems)
+    input_buf->pBufHdr->hMarkTargetComponent = NULL;
+    input_buf->pBufHdr->pMarkData = NULL;
+
+
+    // init buffer flags
+    input_buf->pBufHdr->nFlags = 0;
+
+    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+    // most importantly, set the EOS flag:
+    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_EOS;
+
+    // send buffer to component
+    OMX_EmptyThisBuffer(iOMXDecoder, input_buf->pBufHdr);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendEOSBufferToOMXComponent() Out", iName.Str()));
+
+    return true;
+
+}
+
+// this method is called under certain conditions only if the node is doing partial frame assembly
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::DropCurrentBufferUnderConstruction()
+{
+    if (iObtainNewInputBuffer == false)
+    {
+        if (iInputBufferUnderConstruction != NULL)
+        {
+            if (iInBufMemoryPool != NULL)
+            {
+                iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
+            }
+
+            iInputBufferUnderConstruction = NULL;
+        }
+        iObtainNewInputBuffer = true;
+
+    }
+}
+
+// this method is called under certain conditions only if the node is doing partial frame assembly
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::SendIncompleteBufferUnderConstruction()
+{
+
+    // this should never be the case, but check anyway
+    if (iInputBufferUnderConstruction != NULL)
+    {
+        // mark as end of frame (the actual end piece is missing)
+        iInputBufferUnderConstruction->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::SendIncompleteBufferUnderConstruction()  - Sending Incomplete Buffer 0x%x to OMX Component MARKER field set to %x, TS=%d", iName.Str(), iInputBufferUnderConstruction->pBufHdr->pBuffer, iInputBufferUnderConstruction->pBufHdr->nFlags, iInTimestamp));
+
+        OMX_EmptyThisBuffer(iOMXDecoder, iInputBufferUnderConstruction->pBufHdr);
+
+
+        iInputBufferUnderConstruction = NULL;
+        iObtainNewInputBuffer = true;
+
+    }
+}
+
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::SendInputBufferToOMXComponent()
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendInputBufferToOMXComponent() In", iName.Str()));
+
+
+    // first need to take care of  missing packets if node is assembling partial frames.
+    // The action depends whether the component (I) can handle incomplete frames/NALs or (II) cannot handle incomplete frames/NALs
+    if (!iOMXComponentSupportsPartialFrames)
+    {
+
+        // there are 4 cases after receiving a media msg and realizing there were missing packet(s):
+
+        // a) TS remains the same - i.e. missing 1 or more pieces in the middle of the same frame
+        //		 I) basically ignore  - keep assembling the same frame  (middle will be missing)
+        //		II) drop current buffer, drop msgs until next msg with marker bit arrives
+
+
+        // b) TS is different than previous frame. Previous frame was sent OK (had marker bit).
+        //				New frame assembly has not started yet. one or more pieces are missing from
+        //				the beginning of the frame
+        //	  	 I) basically ignore - get a new buffer and start assembling new frame (beginning will be missing)
+        //		II) no buffer to drop, but keep dropping msgs until next msg with marker bit arrives
+
+        // c) TS is different than previous frame. Frame assembly has started (we were in the middle of a frame)
+        //		but only 1 piece is missing => We know that the missing frame must have had the marker bit
+
+        //		 I) send out current buffer (last piece will be missing), get a new buffer and start assembling new frame (which is OK)
+        //		II) just drop current buffer. Get a new buffer and start assembling new frame (no need to wait for marker bit)
+
+        // d) TS is different than previous frame. Frame assembly has started ( we were in the middle of a frame)
+        //		multiple pieces are missing => The last piece of the frame with the marker bit is missing for sure, but
+        //		there could be also other frames missing or the beginning of the next frame is missing etc.
+
+        //		 I) send out current bufer (last piece will be missing). Get a new buffer and start assembling new frame (beginning COULD BE missing as well)
+        //		II) drop current buffer. Keep dropping msgs until next msg with marker bit arrives
+
+
+        // extract info from the media message
+
+        uint32 current_msg_seq_num = iDataIn->getSeqNum();
+        uint32 current_msg_ts = iDataIn->getTimestamp();
+        uint32 current_msg_marker;
+        if (iSetMarkerBitForEveryFrag == true) // PV AVC case
+        {
+
+            current_msg_marker = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
+        }
+        else
+        {
+            current_msg_marker = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
+        }
+
+        // check if this is the very first data msg
+        if (iFirstDataMsgAfterBOS)
+        {
+            iFirstDataMsgAfterBOS = false;
+            //init the sequence number & ts to make sure dropping logic does not kick in
+            iInPacketSeqNum = current_msg_seq_num - 1;
+            iInTimestamp = current_msg_ts - 10;
+        }
+
+
+        // first check if we need to keep dropping msgs
+        if (iKeepDroppingMsgsUntilMarkerBit)
+        {
+            // drop this message
+            iDataIn.Unbind();
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::SendInputBufferToOMXComponent() Dropping input msg with seqnum %d until marker bit", iName.Str(), current_msg_seq_num));
+
+            //if msg has marker bit, stop dropping msgs
+            if (current_msg_marker != 0)
+            {
+                iKeepDroppingMsgsUntilMarkerBit = false;
+                // also remember the sequence number & timestamp so that we have reference
+                iInPacketSeqNum = current_msg_seq_num;
+                iInTimestamp = current_msg_ts;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() Input msg with seqnum %d has marker bit set. Stop dropping msgs", iName.Str(), current_msg_seq_num));
+
+            }
+            return true;
+        }
+
+        // is there something missing?
+        // compare current and saved sequence number - difference should be exactly 1
+        //	if it is more, there is something missing
+        if ((current_msg_seq_num - iInPacketSeqNum) > 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::SendInputBufferToOMXComponent() - MISSING PACKET DETECTED. Input msg with seqnum %d, TS=%d. Previous seqnum: %d, Previous TS: %d", iName.Str(), current_msg_seq_num, iInPacketSeqNum, current_msg_ts, iInTimestamp));
+
+            // find out which case it is by comparing TS
+            if (current_msg_ts == iInTimestamp)
+            {
+
+                // this is CASE a)
+                // same ts, i.e. pieces are missing from the middle of the current frame
+                if (!iOMXComponentCanHandleIncompleteFrames)
+                {
+                    // drop current buffer, drop msgs until you hit msg with marker bit
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - Drop current buffer under construction. Keep dropping msgs until marker bit", iName.Str()));
+
+                    DropCurrentBufferUnderConstruction();
+                    iKeepDroppingMsgsUntilMarkerBit = true;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - Continue processing", iName.Str()));
+
+                }
+            }
+            else // new ts and old ts are different
+            {
+                //  are we at the beginning of the new frame assembly?
+                if (iObtainNewInputBuffer)
+                {
+                    // CASE b)
+                    // i.e. we sent out previous frame, but have not started assembling a new frame. Pieces are missing from the beginning
+                    if (!iOMXComponentCanHandleIncompleteFrames)
+                    {
+                        // there is no current buffer to drop, but drop msgs until you hit msg with marker bit
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::SendInputBufferToOMXComponent() - No current buffer under construction. Keep dropping msgs until marker bit", iName.Str()));
+
+                        iKeepDroppingMsgsUntilMarkerBit = true;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::SendInputBufferToOMXComponent() - Continue processing", iName.Str()));
+                    }
+                }
+                else	// no, we are in the middle of a frame assembly, but new ts is different
+                {
+                    // is only 1 msg missing?
+                    if ((current_msg_seq_num - iInPacketSeqNum) == 2)
+                    {
+                        // CASE c)
+                        // only the last piece of the previous frame is missing
+                        if (iOMXComponentCanHandleIncompleteFrames)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                            (0, "%s::SendInputBufferToOMXComponent() - Send incomplete buffer under construction. Start assembling new frame", iName.Str()));
+
+                            SendIncompleteBufferUnderConstruction();
+                        }
+                        else
+                        {
+                            // drop current frame only, but no need to wait until next marker bit.
+                            // start assembling new frame
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                            (0, "%s::SendInputBufferToOMXComponent() - Drop current buffer under construction. It's OK to start assembling new frame. Only 1 packet is missing", iName.Str()));
+
+                            DropCurrentBufferUnderConstruction();
+                        }
+                    }
+                    else
+                    {
+                        // CASE d)
+                        // (multiple) final piece(s) of the previous frame are missing and possibly pieces at the
+                        // beginning of a new frame are also missing
+                        if (iOMXComponentCanHandleIncompleteFrames)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                            (0, "%s::SendInputBufferToOMXComponent() - Send incomplete buffer under construction. Start assembling new frame (potentially damaged)", iName.Str()));
+
+                            SendIncompleteBufferUnderConstruction();
+                        }
+                        else
+                        {
+                            // drop current frame. start assembling new frame, but first keep dropping
+                            // until you hit msg with marker bit.
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                            (0, "%s::SendInputBufferToOMXComponent() - Drop current buffer under construction. Keep dropping msgs until marker bit", iName.Str()));
+
+                            DropCurrentBufferUnderConstruction();
+                            iKeepDroppingMsgsUntilMarkerBit = true;
+                        }
+                    }
+                }// end of if(obtainNewInputBuffer)/else
+            }// end of if(curr_msg_ts == iInTimestamp)
+        }//end of if(deltaseqnum>1)/else
+
+        // check if we need to keep dropping msgs
+        if (iKeepDroppingMsgsUntilMarkerBit)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::SendInputBufferToOMXComponent() Dropping input msg with seqnum %d until marker bit", iName.Str(), current_msg_seq_num));
+
+            // drop this message
+            iDataIn.Unbind();
+
+            //if msg has marker bit, stop dropping msgs
+            if (current_msg_marker != 0)
+            {
+                iKeepDroppingMsgsUntilMarkerBit = false;
+                // also remember the sequence number & timestamp so that we have reference
+                iInPacketSeqNum = current_msg_seq_num;
+                iInTimestamp = current_msg_ts;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() Input msg with seqnum %d has marker bit set. Stop dropping msgs", iName.Str(), current_msg_seq_num));
+
+            }
+            return true;
+        }
+
+    }// end of if/else (iOMXSUpportsPartialFrames)
+
+    InputBufCtrlStruct *input_buf = NULL;
+    int32 errcode = OsclErrNone;
+
+// NOTE: a) if NAL start codes must be inserted i.e. iOMXComponentNeedsNALStartCodes is TRUE, then iOMXComponentSupportsMovableInputBuffers must be set to FALSE.
+//		 b) if iOMXComponentSupportsPartialFrames is FALSE, then iOMXComponentSupportsMovableInputBuffers must be FALSE as well
+//		 c) if iOMXCOmponentSupportsPartialFrames is FALSE, and the input frame/NAL size is larger than the buffer size, the frame/NAL is discarded
+
+    do
+    {
+        // do loop to loop over all fragments
+        // first of all , get an input buffer. Without a buffer, no point in proceeding
+        if (iObtainNewInputBuffer == true) // if partial frames are being reconstructed, we may be copying data into
+            //existing buffer, so we don't need the new buffer
+        {
+            // try to get input buffer header
+            OsclAny* temp;
+            errcode = AllocateChunkFromMemPool(temp, iInBufMemoryPool, iInputAllocSize);
+            input_buf = (InputBufCtrlStruct*) temp;
+            if (OsclErrNone != errcode)
+            {
+                if (OsclErrNoResources == errcode)
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                    PVLOGMSG_DEBUG, (0, "%s::SendInputBufferToOMXComponent() No more buffers in the mempool", iName.Str()));
+
+                    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
+
+                    return false;
+                }
+                else
+                {
+                    // Memory allocation for the pool failed
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::SendInputBufferToOMXComponent() Input mempool error", iName.Str()));
+
+
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return false;
+                }
+
+            }
+
+            // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
+            iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
+            iNumOutstandingInputBuffers++;
+
+            // Now we have the buffer header (i.e. a buffer) to send to component:
+            // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
+            //	into OMX component without copying (and update the input msg refcount)
+            //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
+            input_buf->pBufHdr->nFilledLen = 0; // init this for now
+            // save this in a class member
+            iInputBufferUnderConstruction = input_buf;
+            // set flags
+            if (iOMXComponentSupportsPartialFrames == true)
+            {
+                // if partial frames can be sent, then send them
+                // but we'll always need the new buffer for the new fragment
+                iObtainNewInputBuffer = true;
+            }
+            else
+            {
+                // if we need to assemble partial frames, then obtain a new buffer
+                // only after assembling the partial frame
+                iObtainNewInputBuffer = false;
+            }
+
+            iFirstPieceOfPartialFrame = true;
+        }
+        else
+        {
+            input_buf = iInputBufferUnderConstruction;
+        }
+
+        // When copying content, a special case is when the input fragment is larger than the buffer and has to
+        //	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
+
+        // if this is the first fragment in a new message, extract some info:
+        if (iCurrFragNum == 0)
+        {
+
+            // NOTE: SeqNum differ in Codec and in Node because of the fact that
+            // one msg can contain multiple fragments that are sent to the codec as
+            // separate buffers. Node tracks msgs and codec tracks even separate fragments
+
+            iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
+            // amount that the input seq. number increased
+
+            iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
+            iInTimestamp = iDataIn->getTimestamp();
+            iInDuration = iDataIn->getDuration();
+            iInNumFrags = iDataIn->getNumFragments();
+
+            if (iSetMarkerBitForEveryFrag == true) // PV AVC case
+            {
+                iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
+            }
+            else
+            {
+                iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
+            }
+
+            //Force marker bit for AMR streaming formats (marker bit may not be set even though full frames are present)
+            if (iInPort && (
+                        (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMR) ||
+                        (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_AMRWB)
+                    ))
+            {
+                iCurrentMsgMarkerBit = PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
+            }
+
+
+            // logging info:
+            if (iDataIn->getNumFragments() > 1)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() - New msg has MULTI-FRAGMENTS", iName.Str()));
+            }
+
+            if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT) && !(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT))
+            {
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() - New msg has NO MARKER BIT", iName.Str()));
+            }
+        }
+
+
+        // get a memfrag from the message
+        OsclRefCounterMemFrag frag;
+        iDataIn->getMediaFragment(iCurrFragNum, frag);
+
+
+        if (iOMXComponentSupportsMovableInputBuffers)
+        {
+            // no copying required
+
+            // increment the RefCounter of the message associated with the mem fragment/buffer
+            // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
+            // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
+
+            iDataIn.GetRefCounter()->addRef();
+
+            // associate the buffer ctrl structure with the message ref counter and ptr
+            input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
+
+
+            // set pointer to the data, length, offset
+            input_buf->pBufHdr->pBuffer = (uint8 *)frag.getMemFragPtr();
+            input_buf->pBufHdr->nFilledLen = frag.getMemFragSize();
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::SendInputBufferToOMXComponent() - Buffer 0x%x of size %d, %d frag out of tot. %d, TS=%d", iName.Str(), input_buf->pBufHdr->pBuffer, frag.getMemFragSize(), iCurrFragNum + 1, iDataIn->getNumFragments(), iInTimestamp));
+
+            iCurrFragNum++; // increment fragment number and move on to the next
+            iIsNewDataFragment = true; // update the flag
+
+        }
+        else
+        {
+
+            // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
+            (input_buf->pMediaData).Unbind();
+
+            if (iOMXComponentNeedsNALStartCode == true && iFirstPieceOfPartialFrame == true)
+            {
+                oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
+                            (void *) NAL_START_CODE,
+                            NAL_START_CODE_SIZE);
+                input_buf->pBufHdr->nFilledLen += NAL_START_CODE_SIZE;
+                iFirstPieceOfPartialFrame = false;
+
+            }
+
+            // is this a new data fragment or are we still working on separating the old one?
+            if (iIsNewDataFragment == true)
+            {
+                //  if fragment size is larger than the buffer size,
+                //	need to break up the fragment even further into smaller chunks
+
+                // init variables needed for fragment separation
+                iCopyPosition = 0;
+                iFragmentSizeRemainingToCopy  = frag.getMemFragSize();
+
+            }
+
+            // can the remaining fragment fit into the buffer?
+            uint32 bytes_remaining_in_buffer = (input_buf->pBufHdr->nAllocLen - input_buf->pBufHdr->nFilledLen);
+
+            if (iFragmentSizeRemainingToCopy <= bytes_remaining_in_buffer)
+            {
+
+                oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
+                            (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
+                            iFragmentSizeRemainingToCopy);
+
+                input_buf->pBufHdr->nFilledLen += iFragmentSizeRemainingToCopy;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d ", iName.Str(), iFragmentSizeRemainingToCopy, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen, iInTimestamp));
+
+                iCopyPosition += iFragmentSizeRemainingToCopy;
+                iFragmentSizeRemainingToCopy = 0;
+
+
+
+                iIsNewDataFragment = true; // done with this fragment. Get a new one
+                iCurrFragNum++;
+
+            }
+            else
+            {
+                // copy as much as you can of the current fragment into the current buffer
+                if (bytes_remaining_in_buffer > 0)
+                {
+                    oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
+                                (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
+                                bytes_remaining_in_buffer);
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d", iName.Str(), input_buf->pBufHdr->nAllocLen, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen, iInTimestamp));
+                }
+                input_buf->pBufHdr->nFilledLen = input_buf->pBufHdr->nAllocLen;
+                iCopyPosition += bytes_remaining_in_buffer; // move current position within fragment forward
+                iFragmentSizeRemainingToCopy -= bytes_remaining_in_buffer;
+                iIsNewDataFragment = false; // set the flag to indicate we're still working on the "old" fragment
+                if (!iOMXComponentSupportsPartialFrames)
+                {
+                    // if partial frames are not supported, and data cannot fit into the buffer, i.e. the buffer is full at this point
+                    // simply go through remaining fragments if they exist and "drop" them
+                    // i.e. send what data is alrady copied in the buffer and ingore the rest
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - Reconstructing partial frame - more data cannot fit in buffer 0x%x, TS=%d.Skipping data.", iName.Str(), input_buf->pBufHdr->pBuffer, iInTimestamp));
+
+                    iIsNewDataFragment = true; // done with this fragment, get a new one
+                    iCurrFragNum++;
+                }
+
+
+            }
+
+        }
+
+
+        // set buffer fields (this is the same regardless of whether the input is movable or not
+        input_buf->pBufHdr->nOffset = 0;
+        input_buf->pBufHdr->nTimeStamp = iInTimestamp;
+
+        // set ptr to input_buf structure for Context (for when the buffer is returned)
+        input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
+
+        // do not use Mark here (but init to NULL to prevent problems)
+        input_buf->pBufHdr->hMarkTargetComponent = NULL;
+        input_buf->pBufHdr->pMarkData = NULL;
+
+
+        // init buffer flags
+        input_buf->pBufHdr->nFlags = 0;
+
+        // set marker bit on or off
+        // Audio:
+        // a) AAC - file playback - each fragment is a complete frame (1 msg may contain multiple fragments/frames)
+        //    AAC - streaming	- 1 msg may contain a partial frame, but LATM parser will assemble a full frame
+        //						(when LATM parser is done, we attach a marker bit to the data it produces)
+
+        // b) AMR - file playback - each msg is N whole frames (marker bit is always set)
+        //    AMR - streaming   - each msg is N whole frames (marker bit is missing from incoming msgs -set it here)
+
+        // c) MP3 - file playback - 1 msg is N whole frames
+        //
+        // Video:
+        // a) AVC - file playback - each fragment is a complete NAL (1 or more frags i.e. NALs per msg)
+        //    AVC - streaming	- 1 msg contains 1 full NAL or a portion of a NAL
+        // NAL may be broken up over multiple msgs. Frags are not allowed in streaming
+        // b) M4V - file playback - each msg is 1 frame
+        //    M4V - streaming   - 1 frame may be broken up into multiple messages and fragments
+
+        // c) WMV - file playback - 1 frame is 1 msg
+        //    WMV - streaming     - 1 frame may be broken up into multiple messages and fragments
+
+
+        if (iSetMarkerBitForEveryFrag == true)
+        {
+
+
+            if (iIsNewDataFragment)
+            {
+                if ((iDataIn->getNumFragments() > 1))
+                {
+                    // if more than 1 fragment in the message and we have not broken it up
+                    //(i.e. this is the last piece of a broken up piece), put marker bit on it unconditionally
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - END OF FRAGMENT - Multifragmented msg AVC case, Buffer 0x%x MARKER bit set to 1", iName.Str(), input_buf->pBufHdr->pBuffer));
+                    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+                    // if NAL is complete, make sure you send it and obtain new buffer
+                    iObtainNewInputBuffer = true;
+                }
+                else if ((iDataIn->getNumFragments() == 1))
+                {
+                    // this is (the last piece of broken up by us) single-fragmented message. This can be a piece of a NAL (streaming) or a full NAL (file )
+                    // apply marker bit if the message carries one
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - END OF FRAGMENT - Buffer 0x%x MARKER bit set to %d", iName.Str(), input_buf->pBufHdr->pBuffer, iCurrentMsgMarkerBit));
+
+                    if (iCurrentMsgMarkerBit)
+                    {
+                        input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+                        // once NAL is complete, make sure you send it and obtain new buffer
+
+                        iObtainNewInputBuffer = true;
+                    }
+                }
+            }
+            else
+            {
+                // we are separating fragments that are too big, i.e. bigger than
+                // what 1 buffer can hold, this fragment Can NEVER have marker bit
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() - NOT END OF FRAGMENT - Buffer 0x%x MARKER bit set to 0", iName.Str(), input_buf->pBufHdr->pBuffer));
+
+            }
+        }
+        else
+        {
+            // "normal" case, i.e. only fragments at ends of msgs may have marker bit set
+            //					fragments in the middle of a message never have marker bit set
+            // there is also a (slight) possibility we broke up the fragment into more fragments
+            //	because they can't fit into input buffer. In this case, make sure you apply
+            //	the marker bit (if necessary) only to the very last piece of the very last fragment
+
+            // for all other cases, clear the marker bit flag for the buffer
+            if ((iCurrFragNum == iDataIn->getNumFragments()) && iIsNewDataFragment)
+            {
+                // if all the fragments have been exhausted, and this is the last piece
+                // of the (possibly broken up) last fragment
+
+                // use the marker bit from the end of message
+                if (iCurrentMsgMarkerBit)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 1, TS=%d", iName.Str(), input_buf->pBufHdr->pBuffer, iInTimestamp));
+
+                    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+                    // once frame is complete, make sure you send it and obtain new buffer
+
+                    iObtainNewInputBuffer = true;
+                }
+                else
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "%s::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 0, TS=%d", iName.Str(), input_buf->pBufHdr->pBuffer, iInTimestamp));
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::SendInputBufferToOMXComponent() - NOT END OF MESSAGE - Buffer 0x%x MARKER bit set to 0, TS=%d", iName.Str(), input_buf->pBufHdr->pBuffer, iInTimestamp));
+            }
+
+
+        }// end of else(setmarkerbitforeveryfrag)
+
+
+        // set the key frame flag if necessary (mark every fragment that belongs to it)
+        if (iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT)
+            input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+
+        if (iObtainNewInputBuffer == true)
+        {
+            // if partial frames are supported, this flag will always be set
+            // if partial frames are not supported, this flag will be set only
+            // if the partial frame/NAL has been assembled, so we can send it
+
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::SendInputBufferToOMXComponent()  - Sending Buffer 0x%x to OMX Component MARKER field set to %x, TS=%d", iName.Str(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFlags, iInTimestamp));
+
+            OMX_EmptyThisBuffer(iOMXDecoder, input_buf->pBufHdr);
+            iInputBufferUnderConstruction = NULL; // this buffer is gone to OMX component now
+        }
+
+        // if we sent all fragments to OMX component, decouple the input message from iDataIn
+        // Input message is "decoupled", so that we can get a new message for processing into iDataIn
+        //	However, the actual message is released completely to upstream mempool once all of its fragments
+        //	are returned by the OMX component
+
+        if (iCurrFragNum == iDataIn->getNumFragments())
+        {
+            iDataIn.Unbind();
+
+        }
+
+
+    }
+    while (iCurrFragNum < iInNumFrags); //iDataIn->getNumFragments());
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendInputBufferToOMXComponent() Out", iName.Str()));
+
+    return true;
+
+}
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::SendConfigBufferToOMXComponent(uint8 *initbuffer, uint32 initbufsize)
+
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendConfigBufferToOMXComponent() In", iName.Str()));
+
+
+    // first of all , get an input buffer. Without a buffer, no point in proceeding
+    InputBufCtrlStruct *input_buf = NULL;
+    int32 errcode = OsclErrNone;
+
+    // try to get input buffer header
+    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
+    if (OsclErrNone != errcode)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "%s::SendConfigBufferToOMXComponent() Input buffer mempool problem -unexpected at init", iName.Str()));
+
+        return false;
+    }
+
+    // Got a buffer OK
+    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
+    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
+    iNumOutstandingInputBuffers++;
+
+    input_buf->pBufHdr->nFilledLen = 0; //init this to 0
+
+    // Now we have the buffer header (i.e. a buffer) to send to component:
+    // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
+    //	into OMX component without copying (and update the input msg refcount)
+    //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
+
+    // When copying content, a special case is when the input fragment is larger than the buffer and has to
+    //	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
+
+    iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
+    // amount that the input seq. number increased
+
+    iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
+    iInTimestamp = iDataIn->getTimestamp();
+    iInDuration = iDataIn->getDuration();
+
+
+    if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT))
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::SendConfigBufferToOMXComponent() - New msg has NO MARKER BIT", iName.Str()));
+    }
+
+
+    if (iOMXComponentSupportsMovableInputBuffers)
+    {
+        // no copying required
+
+        // increment the RefCounter of the message associated with the mem fragment/buffer
+        // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
+        // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
+
+        iDataIn.GetRefCounter()->addRef();
+
+        // associate the buffer ctrl structure with the message ref counter and ptr
+        input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
+
+
+        // set pointer to the data, length, offset
+        input_buf->pBufHdr->pBuffer = initbuffer;
+        input_buf->pBufHdr->nFilledLen = initbufsize;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::SendConfigBufferToOMXComponent() - Config Buffer 0x%x of size %d", iName.Str(), initbuffer, initbufsize));
+
+    }
+    else
+    {
+
+        // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
+        (input_buf->pMediaData).Unbind();
+
+        // we assume the buffer is large enough to fit the config data
+
+        iCopyPosition = 0;
+        iFragmentSizeRemainingToCopy  = initbufsize;
+
+        if (iOMXComponentNeedsNALStartCode == true)
+        {
+            oscl_memcpy(input_buf->pBufHdr->pBuffer,
+                        (void *) NAL_START_CODE,
+                        NAL_START_CODE_SIZE);
+            input_buf->pBufHdr->nFilledLen += NAL_START_CODE_SIZE;
+
+        }
+
+        // can the remaining fragment fit into the buffer?
+        uint32 bytes_remaining_in_buffer = (input_buf->pBufHdr->nAllocLen - input_buf->pBufHdr->nFilledLen);
+
+        if (iFragmentSizeRemainingToCopy <= bytes_remaining_in_buffer)
+        {
+
+            oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
+                        (void *)(initbuffer + iCopyPosition),
+                        iFragmentSizeRemainingToCopy);
+
+            input_buf->pBufHdr->nFilledLen += iFragmentSizeRemainingToCopy;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::SendConfigBufferToOMXComponent() - Copied %d bytes into buffer 0x%x of size %d", iName.Str(), iFragmentSizeRemainingToCopy, input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen));
+
+            iCopyPosition += iFragmentSizeRemainingToCopy;
+            iFragmentSizeRemainingToCopy = 0;
+
+
+        }
+        else
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::SendConfigBufferToOMXComponent() Config buffer too large problem -unexpected at init", iName.Str()));
+
+            return false;
+        }
+
+    }
+
+
+    // set buffer fields (this is the same regardless of whether the input is movable or not
+    input_buf->pBufHdr->nOffset = 0;
+    input_buf->pBufHdr->nTimeStamp = iInTimestamp;
+
+    // set ptr to input_buf structure for Context (for when the buffer is returned)
+    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
+
+    // do not use Mark here (but init to NULL to prevent problems)
+    input_buf->pBufHdr->hMarkTargetComponent = NULL;
+    input_buf->pBufHdr->pMarkData = NULL;
+
+
+    // init buffer flags
+    input_buf->pBufHdr->nFlags = 0;
+
+    // set marker bit on
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendConfigBufferToOMXComponent() - END OF FRAGMENT - Buffer 0x%x MARKER bit set to 1", iName.Str(), input_buf->pBufHdr->pBuffer));
+
+    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+
+    // set buffer flag indicating buffer contains codec config data
+    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+
+    OMX_EmptyThisBuffer(iOMXDecoder, input_buf->pBufHdr);
+
+    return true;
+
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::CreateOutMemPool(uint32 num_buffers)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::CreateOutMemPool() start", iName.Str()));
+    // In the case OMX component wants to allocate its own buffers,
+    // mempool only contains OutputBufCtrlStructures (i.e. ptrs to buffer headers)
+    // In case OMX component uses pre-allocated buffers (here),
+    // mempool allocates OutputBufCtrlStructure (i.e. ptrs to buffer hdrs), followed by actual buffers
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::CreateOutMemPool() Allocating output buffer header pointers", iName.Str()));
+
+    iOutputAllocSize = oscl_mem_aligned_size((uint32)sizeof(OutputBufCtrlStruct));
+
+    if (iOMXComponentSupportsExternalOutputBufferAlloc)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::CreateOutMemPool() Allocating output buffers of size %d as well", iName.Str(), iOMXComponentOutputBufferSize));
+
+        //pre-negotiated output buffer size
+        iOutputAllocSize += iOMXComponentOutputBufferSize;
+    }
+
+    // for media data wrapper
+    if (iMediaDataMemPool)
+    {
+        iMediaDataMemPool->removeRef();
+        iMediaDataMemPool = NULL;
+    }
+
+    if (iOutBufMemoryPool)
+    {
+        iOutBufMemoryPool->removeRef();
+        iOutBufMemoryPool = NULL;
+    }
+
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, iOutBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
+    if (leavecode || iOutBufMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "%s::CreateOutMemPool() Memory pool structure for output buffers failed to allocate", iName.Str()));
+        return false;
+    }
+
+
+
+    // allocate a dummy buffer to actually create the mempool
+    OsclAny *dummy_alloc = NULL; // this dummy buffer will be released at end of scope
+    leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, dummy_alloc = iOutBufMemoryPool->allocate(iOutputAllocSize));
+    if (leavecode || dummy_alloc == NULL)
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "%s::CreateOutMemPool() Memory pool for output buffers failed to allocate", iName.Str()));
+        return false;
+    }
+    iOutBufMemoryPool->deallocate(dummy_alloc);
+    // init the counter
+    iNumOutstandingOutputBuffers = 0;
+
+    // allocate mempool for media data message wrapper
+    leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers, PVOMXBASEDEC_MEDIADATA_CHUNKSIZE)));
+    if (leavecode || iMediaDataMemPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::CreateOutMemPool() Media Data Buffer pool for output buffers failed to allocate", iName.Str()));
+        return false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::CreateOutMemPool() done", iName.Str()));
+    return true;
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////// Creates memory pool for input buffer management ///////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::CreateInputMemPool(uint32 num_buffers)
+{
+    // 3 cases in order of preference and simplicity
+
+    // Case 1 (buffers allocated upstream - no memcpy needed):
+    //	PV OMX Component - We use buffers allocated outside the OMX node (i.e. allocated upstream)
+    // Mempool contains InputBufCtrlStructures (ptrs to buffer headers and PMVFMediaData ptrs - to keep track of when to unbind input msgs)
+
+    // NOTE:	in this case, when providing input buffers to OMX component,
+    //			OMX_UseBuffer calls will provide some initial pointers and sizes of buffers, but these
+    //			are dummy values. Actual buffer pointers and filled sizes will be obtained from the input msg fragments.
+    //			The PV OMX component will use the buffers even if the ptrs differ from the ones during initialization
+    //			3rd party OMX components can also use this case if they are capable of ignoring the actual buffer pointers in
+    //			buffer header field (i.e. if after OMX_UseBuffer(...) call, they allow the ptr to actual buffer data to change at a later time
+
+    // CASE 2 (buffers allocated in the node - memcpy needed)
+    //			If 3rd party OMX component can use buffers allocated outside the OMX component, but it cannot
+    //			change buffer ptr allocations dynamically (i.e. after initialization with OMX_UseBuffer call is complete)
+
+    //		Mempool contains InputBufCtrlStructures (ptrs to buffer headers, PVMFMediaData ptrs to keep track of when to unbind input msgs) +
+    //				actual buffers.
+    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component
+
+    // CASE 3 (buffers allocated in the component - memcpy needed)
+    //			If 3rd party OMX component must allocate its own buffers
+    //			Mempool only contains InputBufCtrlStruct (ptrs to buffer headers + PMVFMediaData ptrs to keep track of when to unbind input msgs)
+    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component (like in case 2)
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::CreateInputMemPool() start ", iName.Str()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::CreateInputMemPool() allocating buffer header pointers and shared media data ptrs ", iName.Str()));
+
+
+
+    iInputAllocSize = oscl_mem_aligned_size((uint32) sizeof(InputBufCtrlStruct)); //aligned_size_buffer_header_ptr+aligned_size_media_data_ptr;
+
+    // Need to allocate buffers in the node either if component supports external buffers buffers
+    // but they are not movable
+
+    if ((iOMXComponentSupportsExternalInputBufferAlloc && !iOMXComponentSupportsMovableInputBuffers))
+    {
+        //pre-negotiated input buffer size
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::CreateOutMemPool() Allocating input buffers of size %d as well", iName.Str(), iOMXComponentInputBufferSize));
+
+        iInputAllocSize += iOMXComponentInputBufferSize;
+    }
+
+    if (iInBufMemoryPool)
+    {
+        iInBufMemoryPool->removeRef();
+        iInBufMemoryPool = NULL;
+    }
+
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, iInBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
+    if (leavecode || iInBufMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "%s::CreateInputMemPool() Memory pool structure for input buffers failed to allocate", iName.Str()));
+        return false;
+    }
+    // try to allocate a dummy buffer to actually create the mempool and allocate the needed memory
+    // allocate a dummy buffer to actually create the mempool, this dummy buffer will be released at end of scope of this method
+    OsclAny *dummy_alloc = NULL;
+    leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, dummy_alloc = iInBufMemoryPool->allocate(iInputAllocSize));
+    if (leavecode || dummy_alloc == NULL)
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "%s::CreateInputMemPool() Memory pool for input buffers failed to allocate", iName.Str()));
+        return false;
+    }
+
+    // init the counter
+    iNumOutstandingInputBuffers = 0;
+
+
+    iInputBufferToResendToComponent = NULL; // nothing to resend yet
+    iInBufMemoryPool->deallocate(dummy_alloc);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::CreateInputMemPool() done", iName.Str()));
+    return true;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+        uint32 aNumBuffers,    // number of buffers
+        uint32 aActualBufferSize, // aactual buffer size
+        uint32 aPortIndex,      // port idx
+        bool aUseBufferOK,		// can component use OMX_UseBuffer or should it use OMX_AllocateBuffer
+        bool	aIsThisInputBuffer		// is this input or output
+                                                                  )
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ProvideBuffersToComponent() enter", iName.Str()));
+
+    uint32 ii = 0;
+    OMX_ERRORTYPE err = OMX_ErrorNone;
+    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
+
+    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
+    if (ctrl_struct_ptr == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::ProvideBuffersToComponent ctrl_struct_ptr == NULL", iName.Str()));
+        return false;
+    }
+
+    // Now, go through all buffers and tell component to
+    // either use a buffer, or to allocate its own buffer
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+
+        int32 errcode = OsclErrNone;
+        // get the address where the buf hdr ptr will be stored
+        errcode = AllocateChunkFromMemPool(ctrl_struct_ptr[ii], aMemPool, aAllocSize);
+        if ((OsclErrNone != errcode) || (ctrl_struct_ptr[ii] == NULL))
+        {
+            if (OsclErrNoResources == errcode)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::ProvideBuffersToComponent ->allocate() failed for no mempool chunk available", iName.Str()));
+            }
+            else
+            {
+                // General error
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::ProvideBuffersToComponent ->allocate() failed due to some general error", iName.Str()));
+
+                ReportErrorEvent(PVMFFailure);
+                ChangeNodeState(EPVMFNodeError);
+            }
+
+            return false;
+        }
+
+        if (aUseBufferOK)
+        {
+            // Buffers are already allocated outside OMX component.
+            // In case of output buffers, the buffer itself is located
+            // just after the buffer header pointer.
+
+            // In case of input buffers, the buffer header pointer is followed by a MediaDataSharedPtr
+            //	which is used to ensure proper unbinding of the input messages. The buffer itself is either:
+            //		a) allocated upstream (and the ptr to the buffer
+            //			is a dummy pointer to which the component does not pay attention - PV OMX component)
+            //		b) located just after the buffer header pointer and MediaDataSharedPtr
+
+            uint8 *pB = ((uint8*) ctrl_struct_ptr[ii]);
+
+
+            // in case of input buffers, initialize also MediaDataSharedPtr structure
+            if (aIsThisInputBuffer)
+            {
+
+                InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                oscl_memset(&(temp->pMediaData), 0, sizeof(PVMFSharedMediaDataPtr));
+                temp->pMediaData = PVMFSharedMediaDataPtr(NULL, NULL);
+
+                // advance ptr to skip the structure
+                pB += oscl_mem_aligned_size(sizeof(InputBufCtrlStruct));
+
+                err = OMX_UseBuffer(iOMXDecoder,	// hComponent
+                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
+                                    aPortIndex,				// port index (for port for which buffer is provided)
+                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
+                                    //				to have a context when component returns with a callback (i.e. to know
+                                    //				what to free etc.
+                                    (OMX_U32)aActualBufferSize,		// buffer size
+                                    pB);						// buffer data ptr
+
+            }
+            else
+            {
+                OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                // advance buffer ptr to skip the structure
+                pB += oscl_mem_aligned_size(sizeof(OutputBufCtrlStruct));
+
+
+                err = OMX_UseBuffer(iOMXDecoder,	// hComponent
+                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
+                                    aPortIndex,				// port index (for port for which buffer is provided)
+                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
+                                    //				to have a context when component returns with a callback (i.e. to know
+                                    //				what to free etc.
+                                    (OMX_U32)aActualBufferSize,		// buffer size
+                                    pB);						// buffer data ptr
+
+
+            }
+
+
+        }
+        else
+        {
+            // the component must allocate its own buffers.
+            if (aIsThisInputBuffer)
+            {
+
+                InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                // make sure to init all this to NULL
+                oscl_memset(&(temp->pMediaData), 0, sizeof(PVMFSharedMediaDataPtr));
+                temp->pMediaData = PVMFSharedMediaDataPtr(NULL, NULL);
+
+                err = OMX_AllocateBuffer(iOMXDecoder,
+                                         &(temp->pBufHdr),
+                                         aPortIndex,
+                                         ctrl_struct_ptr[ii],
+                                         (OMX_U32)aActualBufferSize);
+            }
+            else
+            {
+                OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                err = OMX_AllocateBuffer(iOMXDecoder,
+                                         &(temp->pBufHdr),
+                                         aPortIndex,
+                                         ctrl_struct_ptr[ii],
+                                         (OMX_U32)aActualBufferSize);
+            }
+
+        }
+
+        if (err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::ProvideBuffersToComponent() Problem using/allocating a buffer", iName.Str()));
+
+
+            return false;
+        }
+
+    }
+
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+        // after initializing the buffer hdr ptrs, return them
+        // to the mempool
+        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
+    }
+
+    oscl_free(ctrl_struct_ptr);
+    // set the flags
+    if (aIsThisInputBuffer)
+    {
+        iInputBuffersFreed = false;
+    }
+    else
+    {
+        iOutputBuffersFreed = false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ProvideBuffersToComponent() done", iName.Str()));
+    return true;
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+        uint32 aNumBuffers,    // number of buffers
+        uint32 aPortIndex,      // port idx
+        bool	aIsThisInputBuffer		// is this input or output
+                                                 )
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::FreeBuffersToComponent() enter", iName.Str()));
+
+    uint32 ii = 0;
+    OMX_ERRORTYPE err = OMX_ErrorNone;
+    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
+
+    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
+    if (ctrl_struct_ptr == NULL)
+    {
+        return false;
+    }
+
+
+    // Now, go through all buffers and tell component to free them
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+
+        int32 errcode = OsclErrNone;
+        // get the address where the buf hdr ptr will be stored
+
+        errcode = AllocateChunkFromMemPool(ctrl_struct_ptr[ii], aMemPool, aAllocSize);
+        if ((OsclErrNone != errcode) || (ctrl_struct_ptr[ii] == NULL))
+        {
+            if (OsclErrNoResources == errcode)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::FreeBuffersFromComponent ->allocate() failed for no mempool chunk available", iName.Str()));
+            }
+            else
+            {
+                // General error
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::FreeBuffersFromComponent ->allocate() failed due to some general error", iName.Str()));
+
+                ReportErrorEvent(PVMFFailure);
+                ChangeNodeState(EPVMFNodeError);
+            }
+
+            return false;
+        }
+        // to maintain correct count
+        aMemPool->notifyfreechunkavailable((*this), (OsclAny*) aMemPool);
+
+        if (aIsThisInputBuffer)
+        {
+
+            iNumOutstandingInputBuffers++;
+            // get the buf hdr pointer
+            InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
+            err = OMX_FreeBuffer(iOMXDecoder,
+                                 aPortIndex,
+                                 temp->pBufHdr);
+
+        }
+        else
+        {
+            iNumOutstandingOutputBuffers++;
+            OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
+            err = OMX_FreeBuffer(iOMXDecoder,
+                                 aPortIndex,
+                                 temp->pBufHdr);
+
+        }
+
+        if (err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::FreeBuffersFromComponent() Problem freeing a buffer", iName.Str()));
+
+            return false;
+        }
+
+    }
+
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+        // after freeing the buffer hdr ptrs, return them
+        // to the mempool (which will itself then be deleted promptly)
+        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
+    }
+
+    oscl_free(ctrl_struct_ptr);
+
+    // mark buffers as freed (so as not to do it twice)
+    if (aIsThisInputBuffer)
+    {
+        iInputBuffersFreed = true;
+    }
+    else
+    {
+        iOutputBuffersFreed = true;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::FreeBuffersFromComponent() done", iName.Str()));
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This function handles the event of OMX component state change
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::HandleComponentStateChange(OMX_U32 decoder_state)
+{
+    switch (decoder_state)
+    {
+        case OMX_StateIdle:
+        {
+            iCurrentDecoderState = OMX_StateIdle;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleComponentStateChange: OMX_StateIdle reached", iName.Str()));
+
+            //  this state can be reached either going from OMX_Loaded->OMX_Idle (preparing)
+            //	or going from OMX_Executing->OMX_Idle (stopping)
+
+
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_PREPARE))
+            {
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_InitDecoder;
+                SetState(EPVMFNodePrepared);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                RunIfNotReady();
+            }
+            else if ((iCurrentCommand.size() > 0) &&
+                     (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_STOP))
+            {
+                // if we are stopped, we won't start until the node gets DoStart command.
+                //	in this case, we are ready to start sending buffers
+                if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_Stopping)
+                    iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
+                // if the processing state was not stopping, leave the state as it was (continue port reconfiguration)
+                SetState(EPVMFNodePrepared);
+                iStopCommandWasSentToComponent = false;
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+
+                RunIfNotReady();
+            }
+            else if ((iCurrentCommand.size() > 0) &&
+                     (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET))
+            {
+                // State change to Idle was initiated due to Reset. First need to reach idle, and then loaded
+                // Once Idle is reached, we need to initiate idle->loaded transition
+                iStopInResetMsgSent = false;
+                RunIfNotReady();
+            }
+            break;
+        }//end of case OMX_StateIdle
+
+        case OMX_StateExecuting:
+        {
+            iCurrentDecoderState = OMX_StateExecuting;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleComponentStateChange: OMX_StateExecuting reached", iName.Str()));
+
+            // this state can be reached going from OMX_Idle -> OMX_Executing (preparing)
+            //	or going from OMX_Pause -> OMX_Executing (coming from pause)
+            //	either way, this is a response to "DoStart" command
+
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_START))
+            {
+                SetState(EPVMFNodeStarted);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+
+                RunIfNotReady();
+            }
+
+            break;
+        }//end of case OMX_StateExecuting
+
+        case OMX_StatePause:
+        {
+            iCurrentDecoderState = OMX_StatePause;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleComponentStateChange: OMX_StatePause reached", iName.Str()));
+
+            // if we are paused, we won't start until the node gets DoStart command.
+            //	in this case, we are ready to start sending buffers
+            if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_Pausing)
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
+
+            //	This state can be reached going from OMX_Executing-> OMX_Pause
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_PAUSE))
+            {
+
+                // if we are paused, we won't start until the node gets DoStart command.
+                //	in this case, we are ready to start sending buffers
+                if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_Pausing)
+                    iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
+                // if the processing state was not pausing, leave the state as it was (continue port reconfiguration)
+
+
+                SetState(EPVMFNodePaused);
+                iPauseCommandWasSentToComponent = false;
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                RunIfNotReady();
+            }
+
+            break;
+        }//end of case OMX_StatePause
+
+        case OMX_StateLoaded:
+        {
+            iCurrentDecoderState = OMX_StateLoaded;
+
+            //  this state can be reached only going from OMX_Idle ->OMX_Loaded (stopped to reset)
+            //
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleComponentStateChange: OMX_StateLoaded reached", iName.Str()));
+            //Check if command's responce is pending
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET))
+            {
+
+                // move this here
+                if (iInPort)
+                {
+                    OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
+                    iInPort = NULL;
+                }
+
+                if (iOutPort)
+                {
+                    OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
+                    iOutPort = NULL;
+                }
+
+                iDataIn.Unbind();
+
+                // Reset the metadata key list
+                iAvailableMetadataKeys.clear();
+
+
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Idle;
+                //logoff & go back to Created state.
+                SetState(EPVMFNodeIdle);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                iResetInProgress = false;
+                iResetMsgSent = false;
+            }
+
+            break;
+        }//end of case OMX_StateLoaded
+
+        case OMX_StateInvalid:
+        default:
+        {
+            iCurrentDecoderState = OMX_StateInvalid;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::HandleComponentStateChange: OMX_StateInvalid reached", iName.Str()));
+
+            break;
+        }//end of case OMX_StateInvalid
+
+    }//end of switch(decoder_state)
+
+}
+
+
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+////////////////////// CALLBACK PROCESSING FOR EMPTY BUFFER DONE - input buffer was consumed
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE PVMFOMXBaseDecNode::EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+    OSCL_UNUSED_ARG(aComponent);
+    OSCL_UNUSED_ARG(aAppData);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::EmptyBufferDoneProcessing: In", iName.Str()));
+
+    OSCL_ASSERT((void*) aComponent == (void*) iOMXDecoder); // component should match the component
+    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
+
+    // first, get the buffer "context", i.e. pointer to application private data that contains the
+    // address of the mempool buffer (so that it can be released)
+    InputBufCtrlStruct *pContext = (InputBufCtrlStruct *)(aBuffer->pAppPrivate);
+
+
+
+    // if a buffer is not empty, log a msg, but release anyway
+    if ((aBuffer->nFilledLen > 0) && (iDoNotSaveInputBuffersFlag == false))
+        // if dynamic port reconfig is in progress for input port, don't keep the buffer
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::EmptyBufferDoneProcessing: Input buffer returned non-empty with %d bytes still in it", iName.Str(), aBuffer->nFilledLen));
+
+
+    }
+
+
+    iInputBufferToResendToComponent = NULL;
+
+    // input buffer is to be released,
+    // refcount needs to be decremented (possibly - the input msg associated with the buffer will be unbound)
+    // NOTE: in case of "moveable" input buffers (passed into component without copying), unbinding decrements a refcount which eventually results
+    //			in input message being released back to upstream mempool once all its fragments are returned
+    //		in case of input buffers passed into component by copying, unbinding has no effect
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::EmptyBufferDoneProcessing: Release input buffer with TS=%d (with %d refcount remaining of input message)", iName.Str(), aBuffer->nTimeStamp, (pContext->pMediaData).get_count() - 1));
+
+
+    (pContext->pMediaData).Unbind();
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::EmptyBufferDoneProcessing: Release input buffer %x back to mempool", iName.Str(), pContext));
+
+    iInBufMemoryPool->deallocate((OsclAny *) pContext);
+
+
+    // the OMX spec says that no error is to be returned
+    return OMX_ErrorNone;
+
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+////////////////////// CALLBACK PROCESSING FOR FILL BUFFER DONE - output buffer is ready
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE PVMFOMXBaseDecNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+    OSCL_UNUSED_ARG(aComponent);
+    OSCL_UNUSED_ARG(aAppData);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::FillBufferDoneProcessing: In", iName.Str()));
+
+    OSCL_ASSERT((void*) aComponent == (void*) iOMXDecoder); // component should match the component
+    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
+
+    // first, get the buffer "context", i.e. pointer to application private data that contains the
+    // address of the mempool buffer (so that it can be released)
+    OsclAny *pContext = (OsclAny*) aBuffer->pAppPrivate;
+
+
+    // check for EOS flag
+    if ((aBuffer->nFlags & OMX_BUFFERFLAG_EOS))
+    {
+        // EOS received - enable sending EOS msg
+        iIsEOSReceivedFromComponent = true;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::FillBufferDoneProcessing: Output buffer has EOS set", iName.Str()));
+
+    }
+
+    // if a buffer is empty, or if it should not be sent downstream (say, due to state change)
+    // release the buffer back to the pool
+    if ((aBuffer->nFilledLen == 0) || (iDoNotSendOutputBuffersDownstreamFlag == true))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::FillBufferDoneProcessing: Release output buffer %x back to mempool - buffer empty or not to be sent downstream", iName.Str(), pContext));
+
+        iOutBufMemoryPool->deallocate(pContext);
+
+    }
+    else
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::FillBufferDoneProcessing: Output frame %d received", iName.Str(), iFrameCounter++));
+
+        // get pointer to actual buffer data
+        uint8 *pBufdata = ((uint8*) aBuffer->pBuffer);
+        // move the data pointer based on offset info
+        pBufdata += aBuffer->nOffset;
+
+        iOutTimeStamp = aBuffer->nTimeStamp;
+
+        ipPrivateData = (OsclAny *) aBuffer->pPlatformPrivate; // record the pointer
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::FillBufferDoneProcessing: Wrapping buffer %x of size %d", iName.Str(), pBufdata, aBuffer->nFilledLen));
+        // wrap the buffer into the MediaDataImpl wrapper, and queue it for sending downstream
+        // wrapping will create a refcounter. When refcounter goes to 0 i.e. when media data
+        // is released in downstream components, the custom deallocator will automatically release the buffer back to the
+        //	mempool. To do that, the deallocator needs to have info about Context
+        // NOTE: we had to wait until now to wrap the buffer data because we only know
+        //			now where the actual data is located (based on buffer offset)
+        OsclSharedPtr<PVMFMediaDataImpl> MediaDataOut = WrapOutputBuffer(pBufdata, (uint32)(aBuffer->nFilledLen), pContext);
+
+        // if you can't get the MediaDataOut, release the buffer back to the pool
+        if (MediaDataOut.GetRep() == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::FillBufferDoneProcessing: Problem wrapping buffer %x of size %d - releasing the buffer", iName.Str(), pBufdata, aBuffer->nFilledLen));
+
+            iOutBufMemoryPool->deallocate(pContext);
+        }
+        else
+        {
+
+            // if there's a problem queuing output buffer, MediaDataOut will expire at end of scope and
+            // release buffer back to the pool, (this should not be the case)
+            if (QueueOutputBuffer(MediaDataOut, aBuffer->nFilledLen))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::FillBufferDoneProcessing: Buffer %x of size %d queued - reschedule the node to send out", iName.Str(), pBufdata, aBuffer->nFilledLen));
+
+                // if queing went OK,
+                // re-schedule the node so that outgoing queue can be emptied (unless the outgoing port is busy)
+                if ((iOutPort) && !(iOutPort->IsConnectedPortBusy()))
+                    RunIfNotReady();
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::FillBufferDoneProcessing: Problem queing buffer %x of size %d - releasing the buffer", iName.Str(), pBufdata, aBuffer->nFilledLen));
+            }
+
+
+        }
+
+    }
+    // the OMX spec says that no error is to be returned
+    return OMX_ErrorNone;
+
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////// Attach a MediaDataImpl wrapper (refcount, deallocator etc.)
+/////////////////////////////// to the output buffer /////////////////////////////////////////
+OsclSharedPtr<PVMFMediaDataImpl> PVMFOMXBaseDecNode::WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext)
+{
+    // wrap output buffer into a mediadataimpl
+    uint32 aligned_class_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+    uint32 aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PVOMXBufferSharedPtrWrapperCombinedCleanupDA));
+    uint32 aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+    uint8 *my_ptr = (uint8*) oscl_malloc(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
+
+    if (my_ptr == NULL)
+    {
+        OsclSharedPtr<PVMFMediaDataImpl> null_buff(NULL, NULL);
+        return null_buff;
+    }
+    // create a deallocator and pass the buffer_allocator to it as well as pointer to data that needs to be returned to the mempool
+    PVOMXBufferSharedPtrWrapperCombinedCleanupDA *cleanup_ptr =
+        OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVOMXBufferSharedPtrWrapperCombinedCleanupDA(iOutBufMemoryPool, pContext));
+
+    //ModifiedPvciBufferCombinedCleanup* cleanup_ptr = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size,ModifiedPvciBufferCombinedCleanup(aOutput.GetRefCounter()) );
+
+    // create the ref counter after the cleanup object (refcount is set to 1 at creation)
+    OsclRefCounterDA *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
+
+    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
+
+    PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer((void *) pData, // ptr to data
+                                        aDataLen, // capacity
+                                        my_refcnt));   // ref counter
+
+    OsclSharedPtr<PVMFMediaDataImpl> MediaDataImplOut(media_data_ptr, my_refcnt);
+
+    MediaDataImplOut->setMediaFragFilledLen(0, aDataLen);
+
+    return MediaDataImplOut;
+
+}
+//////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::SendBeginOfMediaStreamCommand()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendBeginOfMediaStreamCommand() In", iName.Str()));
+
+    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
+    // Set the formatID, timestamp, sequenceNumber and streamID for the media message
+    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
+    sharedMediaCmdPtr->setTimestamp(iBOSTimestamp);
+    //reset the sequence number
+    uint32 seqNum = 0;
+    sharedMediaCmdPtr->setSeqNum(seqNum);
+    sharedMediaCmdPtr->setStreamID(iStreamID);
+
+    PVMFSharedMediaMsgPtr mediaMsgOut;
+    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
+    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::SendBeginOfMediaStreamCommand() Outgoing queue busy", iName.Str()));
+        return false;
+    }
+
+    iSendBOS = false;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendBeginOfMediaStreamCommand() BOS Sent StreamID %d", iName.Str(), iStreamID));
+    return true;
+}
+////////////////////////////////////
+bool PVMFOMXBaseDecNode::SendEndOfTrackCommand(void)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendEndOfTrackCommand() In", iName.Str()));
+
+    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
+
+    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
+
+    // Set the timestamp
+    sharedMediaCmdPtr->setTimestamp(iEndOfDataTimestamp);
+
+    // Set Streamid
+    sharedMediaCmdPtr->setStreamID(iStreamID);
+
+    // Set the sequence number
+    sharedMediaCmdPtr->setSeqNum(iSeqNum++);
+
+    PVMFSharedMediaMsgPtr mediaMsgOut;
+    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
+    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
+    {
+        // this should not happen because we check for queue busy before calling this function
+        return false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::SendEndOfTrackCommand() Out", iName.Str()));
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//The various command handlers call this routine when a command is complete.
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::CommandComplete(PVMFOMXBaseDecNodeCmdQ& aCmdQ, PVMFOMXBaseDecNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s:CommandComplete Id %d Cmd %d Status %d Context %d Data %d",
+                    iName.Str(), aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoInit(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoInit() In", iName.Str()));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        {
+            SetState(EPVMFNodeInitialized);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        }
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoPrepare(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    OMX_ERRORTYPE err = OMX_ErrorNone;
+    OMX_STRING Role = NULL;
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        {
+            if (NULL == iInPort)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::DoPrepare() Input port not initialized", iName.Str()));
+                CommandComplete(iInputCommands, aCmd, PVMFFailure);
+                return;
+            }
+
+            // Check format of input data
+            PVMFFormatType format = ((PVMFOMXDecPort*)iInPort)->iFormat;
+            // AAC
+            if (format == PVMF_MIME_MPEG4_AUDIO ||
+                    format == PVMF_MIME_LATM ||
+                    format == PVMF_MIME_ADIF ||
+                    format == PVMF_MIME_ASF_MPEG4_AUDIO ||
+                    format == PVMF_MIME_AAC_SIZEHDR)
+            {
+                Role = (OMX_STRING)"audio_decoder.aac";
+            }
+            // AMR
+            else if (format == PVMF_MIME_AMR_IF2 ||
+                     format == PVMF_MIME_AMR_IETF ||
+                     format == PVMF_MIME_AMR ||
+                     format == PVMF_MIME_AMRWB_IETF ||
+                     format == PVMF_MIME_AMRWB)
+            {
+                Role = (OMX_STRING)"audio_decoder.amr";
+            }
+            else if (format == PVMF_MIME_MP3)
+            {
+                Role = (OMX_STRING)"audio_decoder.mp3";
+            }
+            else if (format ==  PVMF_MIME_WMA)
+            {
+                Role = (OMX_STRING)"audio_decoder.wma";
+            }
+            else if (format ==  PVMF_MIME_H264_VIDEO ||
+                     format == PVMF_MIME_H264_VIDEO_MP4 ||
+                     format == PVMF_MIME_H264_VIDEO_RAW)
+            {
+                Role = (OMX_STRING)"video_decoder.avc";
+            }
+            else if (format ==  PVMF_MIME_M4V)
+            {
+                Role = (OMX_STRING)"video_decoder.mpeg4";
+            }
+            else if (format ==  PVMF_MIME_H2631998 ||
+                     format == PVMF_MIME_H2632000)
+            {
+                Role = (OMX_STRING)"video_decoder.h263";
+            }
+            else if (format ==  PVMF_MIME_WMV)
+            {
+                Role = (OMX_STRING)"video_decoder.wmv";
+            }
+            else
+            {
+                // Illegal codec specified.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::DoPrepare() Input port format other then codec type", iName.Str()));
+                CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+                return;
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::Initializing OMX component and decoder for role %s", iName.Str(), Role));
+
+            /* Set callback structure */
+            iCallbacks.EventHandler    = CallbackEventHandler; //event_handler;
+            iCallbacks.EmptyBufferDone = CallbackEmptyBufferDone; //empty_buffer_done;
+            iCallbacks.FillBufferDone  = CallbackFillBufferDone; //fill_buffer_done;
+
+
+            // determine components which can fit the role
+            // then, create the component. If multiple components fit the role,
+            // the first one registered will be selected. If that one fails to
+            // be created, the second one in the list is selected etc.
+            OMX_U32 num_comps = 0;
+            OMX_STRING *CompOfRole;
+            // call once to find out the number of components that can fit the role
+            OMX_GetComponentsOfRole(Role, &num_comps, NULL);
+            uint32 ii;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::DoPrepare(): There are %d components of role %s ", iName.Str(), num_comps, Role));
+
+            if (num_comps > 0)
+            {
+                CompOfRole = (OMX_STRING *)oscl_malloc(num_comps * sizeof(OMX_STRING));
+
+                for (ii = 0; ii < num_comps; ii++)
+                    CompOfRole[ii] = (OMX_STRING) oscl_malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
+
+                // call 2nd time to get the component names
+                OMX_GetComponentsOfRole(Role, &num_comps, (OMX_U8 **)CompOfRole);
+
+                for (ii = 0; ii < num_comps; ii++)
+                {
+                    // try to create component
+                    err = OMX_GetHandle(&iOMXDecoder, (OMX_STRING) CompOfRole[ii], (OMX_PTR) this, (OMX_CALLBACKTYPE *) & iCallbacks);
+                    // if successful, no need to continue
+                    if ((err == OMX_ErrorNone) && (iOMXDecoder != NULL))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                        (0, "%s::DoPrepare(): Got Component %s handle ", iName.Str(), CompOfRole[ii]));
+
+                        break;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                        (0, "%s::DoPrepare(): Cannot get component %s handle, try another component if available", iName.Str(), CompOfRole[ii]));
+                    }
+
+                }
+                // whether successful or not, need to free CompOfRoles
+                for (ii = 0; ii < num_comps; ii++)
+                {
+                    oscl_free(CompOfRole[ii]);
+                    CompOfRole[ii] = NULL;
+                }
+
+                oscl_free(CompOfRole);
+                // check if there was a problem
+                if ((err != OMX_ErrorNone) || (iOMXDecoder == NULL))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::Can't get handle for decoder!", iName.Str()));
+                    iOMXDecoder = NULL;
+                    CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                    return;
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::No component can handle role %s !", iName.Str(), Role));
+                iOMXDecoder = NULL;
+                CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                return;
+            }
+
+
+
+            if (!iOMXDecoder)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            OMX_PARAM_COMPONENTROLETYPE RoleParam;
+            CONFIG_SIZE_AND_VERSION(RoleParam);
+            oscl_strncpy((OMX_STRING)RoleParam.cRole, (OMX_STRING)Role, OMX_MAX_STRINGNAME_SIZE);
+            err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamStandardComponentRole, &RoleParam);
+            if (err != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Problem setting component role", iName.Str()));
+                // ignore this error since component may not support this parameter
+            }
+
+            // GET CAPABILITY FLAGS FROM PV COMPONENT, IF this fails, use defaults
+            PV_OMXComponentCapabilityFlagsType Cap_flags;
+            err = OMX_GetParameter(iOMXDecoder, (OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX, &Cap_flags);
+            if (err != OMX_ErrorNone)
+            {
+                SetDefaultCapabilityFlags();
+            }
+            else
+            {
+                iIsOMXComponentMultiThreaded = (OMX_TRUE == Cap_flags.iIsOMXComponentMultiThreaded) ? true : false;
+                iOMXComponentSupportsExternalInputBufferAlloc = (OMX_TRUE == Cap_flags.iOMXComponentSupportsExternalInputBufferAlloc) ? true : false;
+                iOMXComponentSupportsExternalOutputBufferAlloc = (OMX_TRUE == Cap_flags.iOMXComponentSupportsExternalOutputBufferAlloc) ? true : false;
+                iOMXComponentSupportsMovableInputBuffers = (OMX_TRUE == Cap_flags.iOMXComponentSupportsMovableInputBuffers) ? true : false;
+                iOMXComponentSupportsPartialFrames = (OMX_TRUE == Cap_flags.iOMXComponentSupportsPartialFrames) ? true : false;
+                iOMXComponentNeedsNALStartCode = (OMX_FALSE == Cap_flags.iOMXComponentSupportsPartialFrames) ? true : false;
+                iOMXComponentCanHandleIncompleteFrames = (OMX_TRUE == Cap_flags.iOMXComponentCanHandleIncompleteFrames) ? true : false;
+            }
+
+            // do some sanity checking
+
+            if ((format != PVMF_MIME_H264_VIDEO) && (format != PVMF_MIME_H264_VIDEO_MP4) && (format != PVMF_MIME_H264_VIDEO_RAW))
+            {
+                iOMXComponentNeedsNALStartCode = false;
+            }
+
+            // make sure that copying is used where necessary
+            if (!iOMXComponentSupportsPartialFrames || iOMXComponentNeedsNALStartCode)
+            {
+                iOMXComponentSupportsMovableInputBuffers = false;
+            }
+
+            // find out about parameters
+
+            if (!NegotiateComponentParameters())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Cannot get component parameters", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            // create active objects to handle callbacks in case of multithreaded implementation
+
+            // NOTE: CREATE THE THREADSAFE CALLBACK AOs REGARDLESS OF WHETHER MULTITHREADED COMPONENT OR NOT
+            //		If it is not multithreaded, we won't use them
+            //		The Flag iIsComponentMultiThreaded decides which mechanism is used for callbacks.
+            //		This flag is set by looking at component capabilities (or to true by default)
+
+            if (iThreadSafeHandlerEventHandler)
+            {
+                OSCL_DELETE(iThreadSafeHandlerEventHandler);
+                iThreadSafeHandlerEventHandler = NULL;
+            }
+            // substitute default parameters: observer(this node),queuedepth(3),nameAO for logging
+            // Get the priority of the dec node, and set the threadsafe callback AO priority to 1 higher
+            iThreadSafeHandlerEventHandler = OSCL_NEW(EventHandlerThreadSafeCallbackAO, (this, 10, "EventHandlerAO", Priority() + 2));
+
+            if (iThreadSafeHandlerEmptyBufferDone)
+            {
+                OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
+                iThreadSafeHandlerEmptyBufferDone = NULL;
+            }
+            // use queue depth of iNumInputBuffers to prevent deadlock
+            iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1));
+
+            if (iThreadSafeHandlerFillBufferDone)
+            {
+                OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
+                iThreadSafeHandlerFillBufferDone = NULL;
+            }
+            // use queue depth of iNumOutputBuffers to prevent deadlock
+            iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1));
+
+            if ((iThreadSafeHandlerEventHandler == NULL) ||
+                    (iThreadSafeHandlerEmptyBufferDone == NULL) ||
+                    (iThreadSafeHandlerFillBufferDone == NULL)
+               )
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::Can't get threadsafe callbacks for decoder!", iName.Str()));
+                iOMXDecoder = NULL;
+            }
+
+            // ONLY FOR AVC FILE PLAYBACK WILL 1 FRAGMENT CONTAIN ONE FULL NAL
+            if ((format == PVMF_MIME_H264_VIDEO) || (format == PVMF_MIME_H264_VIDEO_MP4))
+            {
+                // every memory fragment in case of AVC is a full NAL
+                iSetMarkerBitForEveryFrag = true;
+            }
+            else
+            {
+                iSetMarkerBitForEveryFrag = false;
+            }
+
+
+            // Init Decoder
+            iCurrentDecoderState = OMX_StateLoaded;
+
+            /* Change state to OMX_StateIdle from OMX_StateLoaded. */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::DoPrepare(): Changing Component state Loaded -> Idle ", iName.Str()));
+
+            err = OMX_SendCommand(iOMXDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+            if (err != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Can't send StateSet command!", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+
+            /* Allocate input buffers */
+            if (!CreateInputMemPool(iNumInputBuffers))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Can't allocate mempool for input buffers!", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
+                                           iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                           iNumInputBuffers, // number of buffers
+                                           iOMXComponentInputBufferSize, // actual buffer size
+                                           iInputPortIndex, // port idx
+                                           iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
+                                           true // this is input
+                                          ))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Component can't use input buffers!", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+
+            /* Allocate output buffers */
+            if (!CreateOutMemPool(iNumOutputBuffers))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Can't allocate mempool for output buffers!", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
+                                           iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                           iNumOutputBuffers, // number of buffers
+                                           iOMXComponentOutputBufferSize, // actual buffer size
+                                           iOutputPortIndex, // port idx
+                                           iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
+                                           false // this is not input
+                                          ))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPrepare() Component can't use output buffers!", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+
+            //this command is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until it completes. We have to wait for
+            // OMX component state transition to complete
+
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+        }
+        break;
+        case EPVMFNodePrepared:
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoStart(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoStart() In", iName.Str()));
+
+    iDiagnosticsLogged = false;
+
+    PVMFStatus status = PVMFSuccess;
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodePrepared:
+        case EPVMFNodePaused:
+        {
+            //Get state of OpenMAX decoder
+            err = OMX_GetState(iOMXDecoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+
+                                (0, "%s::DoStart(): Can't get State of decoder!", iName.Str()));
+
+                sState = OMX_StateInvalid;
+            }
+
+            if ((sState == OMX_StateIdle) || (sState == OMX_StatePause))
+            {
+                /* Change state to OMX_StateExecuting form OMX_StateIdle. */
+                // init the flag
+                if (!iDynamicReconfigInProgress)
+                {
+
+                    iDoNotSendOutputBuffersDownstreamFlag = false; // or if output was not being sent downstream due to state changes
+                    // re-anable sending output
+
+                    iDoNotSaveInputBuffersFlag = false;
+
+                }
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::DoStart() Changing Component state Idle->Executing", iName.Str()));
+
+                err = OMX_SendCommand(iOMXDecoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::DoStart(): Can't send StateSet command to decoder!", iName.Str()));
+
+                    status = PVMFErrInvalidState;
+                }
+
+            }
+            else
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoStart(): Decoder is not in the Idle or Pause state!", iName.Str()));
+
+                status = PVMFErrInvalidState;
+            }
+
+
+        }
+        break;
+
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+
+    if (status == PVMFErrInvalidState)
+    {
+        CommandComplete(iInputCommands, aCmd, status);
+    }
+    else
+    {
+        //this command is asynchronous.  move the command from
+        //the input command queue to the current command, where
+        //it will remain until it completes.
+        int32 err;
+        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+        if (err != OsclErrNone)
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        }
+        iInputCommands.Erase(&aCmd);
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoStop(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoStop() In", iName.Str()));
+
+    LogDiagnostics();
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        case EPVMFNodePrepared:
+            // Stop data source
+            // This will also prevent execution of HandleProcessingState
+
+            iDataIn.Unbind();
+            // Clear queued messages in ports
+            if (iInPort)
+            {
+                iInPort->ClearMsgQueues();
+            }
+
+            if (iOutPort)
+            {
+                iOutPort->ClearMsgQueues();
+            }
+
+            // Clear the data flags
+
+            iEndOfDataReached = false;
+            iIsEOSSentToComponent = false;
+            iIsEOSReceivedFromComponent = false;
+
+
+            iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
+            iDoNotSaveInputBuffersFlag = true;
+
+            //if we're in the middle of a partial frame assembly
+            // abandon it and start fresh
+            if (iObtainNewInputBuffer == false)
+            {
+                if (iInputBufferUnderConstruction != NULL)
+                {
+                    if (iInBufMemoryPool != NULL)
+                    {
+                        iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
+                    }
+                    iInputBufferUnderConstruction = NULL;
+                }
+                iObtainNewInputBuffer = true;
+
+            }
+
+            iFirstDataMsgAfterBOS = true;
+
+            //Get state of OpenMAX decoder
+            err = OMX_GetState(iOMXDecoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoStop(): Can't get State of decoder!", iName.Str()));
+
+                sState = OMX_StateInvalid;
+            }
+
+            if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
+            {
+                /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::DoStop() Changing Component State Executing->Idle or Pause->Idle", iName.Str()));
+
+                err = OMX_SendCommand(iOMXDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::DoStop(): Can't send StateSet command to decoder!", iName.Str()));
+
+                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                    break;
+                }
+
+                // prevent the node from sending more buffers etc.
+                // if port reconfiguration is in process, let the state remain one of the port config states
+                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
+                if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+                    iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Stopping;
+
+                // indicate that stop cmd was sent
+                if (iDynamicReconfigInProgress)
+                {
+                    iStopCommandWasSentToComponent = true;
+                }
+
+
+            }
+            else
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoStop(): Decoder is not in the Executing or Pause state!", iName.Str()));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                break;
+            }
+
+            //this command is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until it completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoFlush(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            //the flush is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until the flush completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            //Notify all ports to suspend their input
+            if (iInPort)
+            {
+                iInPort->SuspendInput();
+            }
+            if (iOutPort)
+            {
+                iOutPort->SuspendInput();
+            }
+            // Stop data source
+
+            // DV: Sending "OMX_CommandFlush" to the decoder: Not supported yet
+
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoPause(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoPause() In", iName.Str()));
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+
+
+            //Get state of OpenMAX decoder
+            err = OMX_GetState(iOMXDecoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPause(): Can't get State of decoder!", iName.Str()));
+
+                sState = OMX_StateInvalid;
+            }
+
+            if (sState == OMX_StateExecuting)
+            {
+                /* Change state to OMX_StatePause from OMX_StateExecuting. */
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "%s::DoPause() Changing Component State Executing->Idle", iName.Str()));
+
+
+                // prevent the node from sending more buffers etc.
+                // if port reconfiguration is in process, let the state remain one of the port config states
+                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
+                if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+                    iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Pausing;
+
+                // indicate that pause cmd was sent
+                if (iDynamicReconfigInProgress)
+                {
+                    iPauseCommandWasSentToComponent = true;
+                }
+
+                err = OMX_SendCommand(iOMXDecoder, OMX_CommandStateSet, OMX_StatePause, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::DoPause(): Can't send StateSet command to decoder!", iName.Str()));
+
+                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                    break;
+                }
+
+            }
+            else
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "%s::DoPause(): Decoder is not in the Executing state!", iName.Str()));
+                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                break;
+            }
+
+            //this command is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until it completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoReset(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::DoReset() In", iName.Str()));
+
+    LogDiagnostics();
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        case EPVMFNodeError:
+        {
+            //Check if decoder is initilized
+            if (iOMXDecoder != NULL)
+            {
+
+                //if we're in the middle of a partial frame assembly
+                // abandon it and start fresh
+                if (iObtainNewInputBuffer == false)
+                {
+                    if (iInputBufferUnderConstruction != NULL)
+                    {
+                        if (iInBufMemoryPool != NULL)
+                        {
+                            iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
+                        }
+                        iInputBufferUnderConstruction = NULL;
+                    }
+                    iObtainNewInputBuffer = true;
+
+                }
+
+                iFirstDataMsgAfterBOS = true;
+                iKeepDroppingMsgsUntilMarkerBit = false;
+
+                //Get state of OpenMAX decoder
+                err = OMX_GetState(iOMXDecoder, &sState);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::DoReset(): Can't get State of decoder!", iName.Str()));
+                    if (iResetInProgress)
+                    {
+                        // cmd is in current q
+                        iResetInProgress = false;
+                        if ((iCurrentCommand.size() > 0) &&
+                                (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+                           )
+                        {
+                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
+                        }
+
+                    }
+                    else
+                    {
+                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                    }
+                    return;
+                }
+
+                if (sState == OMX_StateLoaded)
+                {
+                    // this is a value obtained by synchronous call to component. Either the component was
+                    // already in this state without node issuing any commands,
+                    // or perhaps we started the Reset, but the callback notification has not yet arrived.
+                    if (iResetInProgress)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::DoReset() OMX comp is in loaded state. Wait for official callback to change variables etc.", iName.Str()));
+                        return;
+                    }
+                    else
+                    {
+
+                        //CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                        //delete all ports and notify observer.
+                        if (iInPort)
+                        {
+                            OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
+                            iInPort = NULL;
+                        }
+
+                        if (iOutPort)
+                        {
+                            OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
+                            iOutPort = NULL;
+                        }
+
+                        iDataIn.Unbind();
+
+
+                        // Reset the metadata key list
+                        iAvailableMetadataKeys.clear();
+
+                        iEndOfDataReached = false;
+                        iIsEOSSentToComponent = false;
+                        iIsEOSReceivedFromComponent = false;
+
+
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Idle;
+
+                        SetState(EPVMFNodeIdle);
+
+                        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+
+                        return;
+                    }
+                }
+
+                if (sState == OMX_StateIdle)
+                {
+
+
+                    //this command is asynchronous.  move the command from
+                    //the input command queue to the current command, where
+                    //it will remain until it is completed.
+                    if (!iResetInProgress)
+                    {
+                        int32 err;
+                        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+                        if (err != OsclErrNone)
+                        {
+                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                            return;
+                        }
+                        iInputCommands.Erase(&aCmd);
+
+                        iResetInProgress = true;
+                    }
+
+                    // if buffers aren't all back (due to timing issues with different callback AOs
+                    //		state change can be reported before all buffers are returned)
+                    if (iNumOutstandingInputBuffers > 0 || iNumOutstandingOutputBuffers > 0)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::DoReset() Waiting for %d input and-or %d output buffers", iName.Str(), iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
+
+                        return;
+                    }
+
+                    if (!iResetMsgSent)
+                    {
+                        // We can come here only if all buffers are already back
+                        // Don't repeat any of this twice.
+                        /* Change state to OMX_StateLoaded form OMX_StateIdle. */
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::DoReset() Changing Component State Idle->Loaded", iName.Str()));
+
+                        err = OMX_SendCommand(iOMXDecoder, OMX_CommandStateSet, OMX_StateLoaded, NULL);
+                        if (err != OMX_ErrorNone)
+                        {
+                            //Error condition report
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "%s::DoReset(): Can't send StateSet command to decoder!", iName.Str()));
+                        }
+
+                        iResetMsgSent = true;
+
+
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::DoReset() freeing output buffers", iName.Str()));
+
+                        if (false == iOutputBuffersFreed)
+                        {
+                            if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
+                                                          iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                          iNumOutputBuffers, // number of buffers
+                                                          iOutputPortIndex, // port idx
+                                                          false // this is not input
+                                                         ))
+                            {
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                (0, "%s::DoReset() Cannot free output buffers ", iName.Str()));
+
+                                if (iResetInProgress)
+                                {
+                                    iResetInProgress = false;
+                                    if ((iCurrentCommand.size() > 0) &&
+                                            (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+                                       )
+                                    {
+                                        CommandComplete(iCurrentCommand, iCurrentCommand.front() , PVMFErrResource);
+                                    }
+                                }
+
+                            }
+
+                        }
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::DoReset() freeing input buffers ", iName.Str()));
+                        if (false == iInputBuffersFreed)
+                        {
+                            if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
+                                                          iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                          iNumInputBuffers, // number of buffers
+                                                          iInputPortIndex, // port idx
+                                                          true // this is input
+                                                         ))
+                            {
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                (0, "%s::DoReset() Cannot free input buffers ", iName.Str()));
+
+                                if (iResetInProgress)
+                                {
+                                    iResetInProgress = false;
+                                    if ((iCurrentCommand.size() > 0) &&
+                                            (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+                                       )
+                                    {
+                                        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
+                                    }
+                                }
+
+
+                            }
+                        }
+
+
+
+                        iEndOfDataReached = false;
+                        iIsEOSSentToComponent = false;
+                        iIsEOSReceivedFromComponent = false;
+
+
+
+                        // also, perform Port deletion when the component replies with the command
+                        // complete, not right here
+                    } // end of if(iResetMsgSent)
+
+
+                    return;
+
+                }
+
+                if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
+                {
+                    /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
+
+                    if (!iStopInResetMsgSent)
+                    {
+                        // replicate behavior of stop cmd
+                        iDataIn.Unbind();
+                        // Clear queued messages in ports
+                        if (iInPort)
+                        {
+                            iInPort->ClearMsgQueues();
+                        }
+
+                        if (iOutPort)
+                        {
+                            iOutPort->ClearMsgQueues();
+                        }
+
+                        // Clear the data flags
+
+                        iEndOfDataReached = false;
+                        iIsEOSSentToComponent = false;
+                        iIsEOSReceivedFromComponent = false;
+
+
+                        iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
+                        iDoNotSaveInputBuffersFlag = true;
+
+
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "%s::DoReset() Changing Component State Executing->Idle or Pause->Idle", iName.Str()));
+
+                        err = OMX_SendCommand(iOMXDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+                        if (err != OMX_ErrorNone)
+                        {
+                            //Error condition report
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "%s::DoReset(): Can't send StateSet command to decoder!", iName.Str()));
+
+                            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                            break;
+                        }
+
+                        iStopInResetMsgSent = true;
+                        // prevent the node from sending more buffers etc.
+                        // if port reconfiguration is in process, let the state remain one of the port config states
+                        //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
+                        if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+                            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Stopping;
+                    }
+
+                    return;
+
+                }
+                else
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "%s::DoReset(): Decoder is not in the Idle state!", iName.Str()));
+                    if (iResetInProgress)
+                    {
+                        iResetInProgress = false;
+                        if ((iCurrentCommand.size() > 0) &&
+                                (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+                           )
+                        {
+                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrInvalidState);
+                        }
+                    }
+                    else
+                    {
+                        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                    }
+                    break;
+                }//end of if (sState == OMX_StateIdle)
+            }//end of if (iOMXDecoder != NULL)
+
+            //delete all ports and notify observer.
+            if (iInPort)
+            {
+                OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
+                iInPort = NULL;
+            }
+
+            if (iOutPort)
+            {
+                OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
+                iOutPort = NULL;
+            }
+
+            iDataIn.Unbind();
+
+
+            // Reset the metadata key list
+            iAvailableMetadataKeys.clear();
+
+            iEndOfDataReached = false;
+            iIsEOSSentToComponent = false;
+            iIsEOSReceivedFromComponent = false;
+
+
+            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Idle;
+            //logoff & go back to Created state.
+            SetState(EPVMFNodeIdle);
+
+
+            if (iResetInProgress)
+            {
+                iResetInProgress = false;
+                if ((iCurrentCommand.size() > 0) &&
+                        (iCurrentCommand.front().iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+                   )
+                {
+                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                }
+            }
+            else
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            }
+
+        }
+        break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Clean Up Decoder
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::DeleteOMXBaseDecoder()
+{
+    OMX_ERRORTYPE  err;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::DeleteOMXBaseDecoder() In", iName.Str()));
+
+    if (iOMXDecoder != NULL)
+    {
+        /* Free Component handle. */
+        err = OMX_FreeHandle(iOMXDecoder);
+        if (err != OMX_ErrorNone)
+        {
+            //Error condition report
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::DeleteOMXBaseDecoder(): Can't free decoder's handle!", iName.Str()));
+        }
+        iOMXDecoder = NULL;
+
+    }//end of if (iOMXDecoder != NULL)
+
+
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::ChangeNodeState(TPVMFNodeInterfaceState aNewState)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ChangeNodeState() Changing state from %d to %d", iName.Str(), iInterfaceState, aNewState));
+    iInterfaceState = aNewState;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::freechunkavailable(OsclAny *aContext)
+{
+
+    // check context to see whether input or output buffer was returned to the mempool
+    if (aContext == (OsclAny *) iInBufMemoryPool)
+    {
+
+        iNumOutstandingInputBuffers--;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::freechunkavailable() Memory chunk in INPUT mempool was deallocated, %d out of %d now available", iName.Str(), iNumInputBuffers - iNumOutstandingInputBuffers, iNumInputBuffers));
+
+        // notification only works once.
+        // If there are multiple buffers coming back in a row, make sure to set the notification
+        // flag in the mempool again, so that next buffer also causes notification
+        iInBufMemoryPool->notifyfreechunkavailable(*this, aContext);
+
+    }
+    else if (aContext == (OsclAny *) iOutBufMemoryPool)
+    {
+
+        iNumOutstandingOutputBuffers--;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::freechunkavailable() Memory chunk in OUTPUT mempool was deallocated, %d out of %d now available", iName.Str(), iNumOutputBuffers - iNumOutstandingOutputBuffers, iNumOutputBuffers));
+
+        // notification only works once.
+        // If there are multiple buffers coming back in a row, make sure to set the notification
+        // flag in the mempool again, so that next buffer also causes notification
+        iOutBufMemoryPool->notifyfreechunkavailable(*this, aContext);
+
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::freechunkavailable() UNKNOWN mempool ", iName.Str()));
+
+    }
+
+    // reschedule
+    if (IsAdded())
+        RunIfNotReady();
+
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFOMXBaseDecNode::PortActivity: port=0x%x, type=%d",
+                     this, aActivity.iPort, aActivity.iType));
+
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            //An outgoing message was queued on this port.
+            //We only need to queue a port activity event on the
+            //first message.  Additional events will be queued during
+            //the port processing as needed.
+            if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
+            {
+                //wake up the AO to process the port activity event.
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "%s::PortActivity: IncomingMsgQueueSize=%d", iName.Str(), aActivity.iPort->IncomingMsgQueueSize()));
+            if (aActivity.iPort->IncomingMsgQueueSize() == 1)
+            {
+                //wake up the AO to process the port activity event.
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
+            if (iProcessingState == EPVMFOMXBaseDecNodeProcessingState_WaitForOutgoingQueue)
+            {
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECT:
+            //nothing needed.
+            break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            //clear the node input data when either port is disconnected.
+
+            iDataIn.Unbind();
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
+            // The connected port has become busy (its incoming queue is
+            // busy).
+            // No action is needed here-- the port processing code
+            // checks for connected port busy during data processing.
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+            // The connected port has transitioned from Busy to Ready to Receive.
+            // It's time to start processing outgoing messages again.
+
+            //iProcessingState should transition from WaitForOutputPort to ReadyToDecode
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "0x%x PVMFOMXBaseDecNode::PortActivity: Connected port is now ready", this));
+            RunIfNotReady();
+            break;
+
+        default:
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoCancelAllCommands(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::DoCancelAllCommands", iName.Str()));
+
+    //first cancel the current command if any
+    {
+        while (!iCurrentCommand.empty())
+        {
+            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
+        }
+
+    }
+
+    //next cancel all queued commands
+    {
+        //start at element 1 since this cancel command is element 0.
+        while (iInputCommands.size() > 1)
+        {
+            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
+        }
+    }
+
+    if (iResetInProgress && !iResetMsgSent)
+    {
+        // if reset is started but reset msg has not been sent, we can cancel reset
+        // as if nothing happened. Otherwise, the callback will set the flag back to false
+        iResetInProgress = false;
+    }
+    //finally, report cancel complete.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoCancelCommand(PVMFOMXBaseDecNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::DoCancelCommand", iName.Str()));
+
+    //extract the command ID from the parameters.
+    PVMFCommandId id;
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(id);
+
+    //first check "current" command if any
+    {
+        PVMFOMXBaseDecNodeCommand* cmd = iCurrentCommand.FindById(id);
+        if (cmd)
+        {
+
+            // if reset is being canceled:
+            if (cmd->iCmd == PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_RESET)
+            {
+                if (iResetInProgress && !iResetMsgSent)
+                {
+                    // if reset is started but reset msg has not been sent, we can cancel reset
+                    // as if nothing happened. Otherwise, the callback will set the flag back to false
+                    iResetInProgress = false;
+                }
+            }
+            //cancel the queued command
+            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+
+    //next check input queue.
+    {
+        //start at element 1 since this cancel command is element 0.
+        PVMFOMXBaseDecNodeCommand* cmd = iInputCommands.FindById(id, 1);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+    //if we get here the command isn't queued so the cancel fails.
+    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::DoQueryInterface(PVMFOMXBaseDecNodeCommand&  aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::DoQueryInterface", iName.Str()));
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(uuid, ptr);
+
+    if (*uuid == PVUuid(PVMF_OMX_BASE_DEC_NODE_CUSTOM1_UUID))
+    {
+        addRef();
+        *ptr = (PVMFOMXBaseDecNodeExtensionInterface*)this;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else if (*uuid == PVUuid(KPVMFMetadataExtensionUuid))
+    {
+        addRef();
+        *ptr = (PVMFMetadataExtensionInterface*)this;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else if (*uuid == PVUuid(PVMI_CAPABILITY_AND_CONFIG_PVUUID))
+    {
+        addRef();
+        *ptr = (PvmiCapabilityAndConfig*)this;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        //not supported
+        *ptr = NULL;
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::removeRef()
+{
+    --iExtensionRefCount;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXBaseDecNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    PVUuid my_uuid(PVMF_OMX_BASE_DEC_NODE_CUSTOM1_UUID);
+    if (uuid == my_uuid)
+    {
+        PVMFOMXBaseDecNodeExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFOMXBaseDecNodeExtensionInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+        return true;
+    }
+    else if (uuid == KPVMFMetadataExtensionUuid)
+    {
+        PVMFMetadataExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+        return true;
+    }
+    return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXBaseDecNode::HandleRepositioning()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::HandleRepositioning() IN", iName.Str()));
+
+
+    // 1) Send Flush command to component for both input and output ports
+    // 2) "Wait" until component flushes both ports
+    // 3) Resume
+    OMX_ERRORTYPE  err = OMX_ErrorNone;
+    OMX_STATETYPE sState = OMX_StateInvalid;
+
+
+    if (!iIsRepositioningRequestSentToComponent)
+    {
+
+        // first check the state (if executing or paused, continue)
+        err = OMX_GetState(iOMXDecoder, &sState);
+        if (err != OMX_ErrorNone)
+        {
+            //Error condition report
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::HandleRepositioning(): Can't get State of decoder - trying to send reposition request!", iName.Str()));
+
+            sState = OMX_StateInvalid;
+            ReportErrorEvent(PVMFErrResourceConfiguration);
+            ChangeNodeState(EPVMFNodeError);
+            return false;
+        }
+
+        if ((sState != OMX_StateExecuting) && (sState != OMX_StatePause))
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "%s::HandleRepositioning() Component State is not executing or paused, do not proceed with repositioning", iName.Str()));
+
+            return true;
+
+        }
+
+
+        iIsRepositioningRequestSentToComponent = true; // prevent sending requests multiple times
+        iIsInputPortFlushed = false;	// flag that will be set to true once component flushes the port
+        iIsOutputPortFlushed = false;
+        iDoNotSendOutputBuffersDownstreamFlag = true;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::HandleRepositioning() Sending Flush command to component", iName.Str()));
+
+        // send command to flush all ports (arg is OMX_ALL)
+        err = OMX_SendCommand(iOMXDecoder, OMX_CommandFlush, OMX_ALL, NULL);
+        if (err != OMX_ErrorNone)
+        {
+            //Error condition report
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "%s::HandleRepositioning(): Can't send flush command  - trying to send reposition request!", iName.Str()));
+
+            sState = OMX_StateInvalid;
+            ReportErrorEvent(PVMFErrResourceConfiguration);
+            ChangeNodeState(EPVMFNodeError);
+            return false;
+        }
+
+    }
+
+    if (iIsRepositionDoneReceivedFromComponent)
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "%s::HandleRepositioning() Component has flushed both ports, and is done repositioning", iName.Str()));
+
+        iIsRepositioningRequestSentToComponent = false; // enable sending requests again
+        iIsRepositionDoneReceivedFromComponent = false;
+        iIsInputPortFlushed = false;
+        iIsOutputPortFlushed = false;
+
+        iDoNotSendOutputBuffersDownstreamFlag = false;
+        return true;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "%s::HandleRepositioning() Component is not yet done repositioning ", iName.Str()));
+
+    return false;
+
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::setObserver()", iName.Str()));
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::setObserver() is not supported!", iName.Str()));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::getParametersSync()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+
+    return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::releaseParameters()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+
+    return DoCapConfigReleaseParameters(aParameters, aNumElements);
+}
+
+
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::createContext()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::createContext() is not supported!", iName.Str()));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::setContextParameters()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumParamElements);
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::setContextParameters() is not supported!", iName.Str()));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DeleteContext()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::DeleteContext() is not supported!", iName.Str()));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::setParametersSync()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+
+    // Complete the request synchronously
+    DoCapConfigSetParameters(aParameters, aNumElements, aRetKVP);
+}
+
+
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::setParametersAsync()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumElements);
+    OSCL_UNUSED_ARG(aRetKVP);
+    OSCL_UNUSED_ARG(aContext);
+
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::setParametersAsync() is not supported!", iName.Str()));
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return 0;
+}
+
+
+OSCL_EXPORT_REF uint32 PVMFOMXBaseDecNode::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::getCapabilityMetric()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+    // Not supported so return 0
+    return 0;
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::verifyParametersSync()", iName.Str()));
+    OSCL_UNUSED_ARG(aSession);
+
+    return DoCapConfigVerifyParameters(aParameters, aNumElements);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries, char* query_key, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%sCommand::GetNodeMetadataKeys() called", iName.Str()));
+
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommand::Construct(aSessionId, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_GETNODEMETADATAKEY, &aKeyList, starting_index, max_entries, query_key, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFOMXBaseDecNode::GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%sCommand::GetNodeMetadataValue() called", iName.Str()));
+
+    PVMFOMXBaseDecNodeCommand cmd;
+    cmd.PVMFOMXBaseDecNodeCommand::Construct(aSessionId, PVMFOMXBaseDecNodeCommand::PVOMXBASEDEC_NODE_CMD_GETNODEMETADATAVALUE, &aKeyList, &aValueList, starting_index, max_entries, aContext);
+    return QueueCommandL(cmd);
+}
+
+// From PVMFMetadataExtensionInterface
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::ReleaseNodeMetadataKeys(PVMFMetadataList& , uint32 , uint32)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ReleaseNodeMetadataKeys() called", iName.Str()));
+    //nothing needed-- there's no dynamic allocation in this node's key list
+    return PVMFSuccess;
+}
+
+// From PVMFMetadataExtensionInterface
+/////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 start, uint32 end)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::ReleaseNodeMetadataValues() called", iName.Str()));
+
+    if (aValueList.size() == 0 || start > end)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "%s::ReleaseNodeMetadataValues() Invalid start/end index", iName.Str()));
+        return PVMFErrArgument;
+    }
+
+    if (end >= aValueList.size())
+    {
+        end = aValueList.size() - 1;
+    }
+
+    for (uint32 i = start; i <= end; i++)
+    {
+        if (aValueList[i].key != NULL)
+        {
+            switch (GetValTypeFromKeyString(aValueList[i].key))
+            {
+                case PVMI_KVPVALTYPE_CHARPTR:
+                    if (aValueList[i].value.pChar_value != NULL)
+                    {
+                        OSCL_ARRAY_DELETE(aValueList[i].value.pChar_value);
+                        aValueList[i].value.pChar_value = NULL;
+                    }
+                    break;
+
+                case PVMI_KVPVALTYPE_UINT32:
+                case PVMI_KVPVALTYPE_UINT8:
+                    // No memory to free for these valtypes
+                    break;
+
+                default:
+                    // Should not get a value that wasn't created from here
+                    break;
+            }
+
+            OSCL_ARRAY_DELETE(aValueList[i].key);
+            aValueList[i].key = NULL;
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////
+// CAPABILITY CONFIG PRIVATE
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aIdentifier);
+    OSCL_UNUSED_ARG(aNumParamElements);
+    OSCL_UNUSED_ARG(aContext);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoCapConfigGetParametersSync() In", iName.Str()));
+
+    return PVMFFailure;
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements)
+{
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumElements);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoCapConfigReleaseParameters() Out", iName.Str()));
+    return PVMFSuccess;
+}
+
+
+OSCL_EXPORT_REF void PVMFOMXBaseDecNode::DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
+{
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumElements);
+    OSCL_UNUSED_ARG(aRetKVP);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoCapConfigSetParameters() Out", iName.Str()));
+}
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXBaseDecNode::DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements)
+{
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumElements);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoCapConfigVerifyParameters() In", iName.Str()));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "%s::DoCapConfigVerifyParameters() Out", iName.Str()));
+    return PVMFSuccess;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXBaseDecNode::LogDiagnostics()
+{
+    if (iDiagnosticsLogged == false)
+    {
+        iDiagnosticsLogged = true;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "%s - Number of Frames Sent = %d", iName.Str(), iSeqNum));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "%s - TS of last decoded frame = %d", iName.Str(), iOutTimeStamp));
+    }
+}
+
+
+OSCL_EXPORT_REF OsclAny* PVMFOMXBaseDecNode::AllocateKVPKeyArray(int32& aLeaveCode, PvmiKvpValueType aValueType, int32 aNumElements)
+{
+    int32 leaveCode = OsclErrNone;
+    OsclAny* aBuffer = NULL;
+    switch (aValueType)
+    {
+        case PVMI_KVPVALTYPE_WCHARPTR:
+            OSCL_TRY(leaveCode,
+                     aBuffer = (oscl_wchar*) OSCL_ARRAY_NEW(oscl_wchar, aNumElements);
+                    );
+            break;
+
+        case PVMI_KVPVALTYPE_CHARPTR:
+            OSCL_TRY(leaveCode,
+                     aBuffer = (char*) OSCL_ARRAY_NEW(char, aNumElements);
+                    );
+            break;
+        case PVMI_KVPVALTYPE_UINT8PTR:
+            OSCL_TRY(leaveCode,
+                     aBuffer = (uint8*) OSCL_ARRAY_NEW(uint8, aNumElements);
+                    );
+            break;
+        default:
+            break;
+    }
+    aLeaveCode = leaveCode;
+    return aBuffer;
+}
+
+
+
+
+
diff --git a/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_port.cpp b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_port.cpp
new file mode 100644
index 0000000..d1826c2
--- /dev/null
+++ b/nodes/pvomxbasedecnode/src/pvmf_omx_basedec_port.cpp
@@ -0,0 +1,332 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_omx_basedec_port.h"
+#include "pvmf_omx_basedec_node.h"
+
+
+OSCL_EXPORT_REF PVMFOMXDecPort::PVMFOMXDecPort(int32 aTag, PVMFNodeInterface* aNode, const char*name)
+        : PvmfPortBaseImpl(aTag, aNode, name)
+{
+    iOMXNode = (PVMFOMXBaseDecNode *) aNode;
+    Construct();
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXDecPort::Construct()
+{
+    iLogger = PVLogger::GetLoggerObject(PortName());
+    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
+    iNumFramesGenerated = 0;
+    iNumFramesConsumed = 0;
+    iTrackConfig = NULL;
+    iTrackConfigSize = 0;
+    if ((oscl_strcmp(PortName(), PVMF_OMX_VIDEO_DEC_INPUT_PORT_NAME) == 0) || (oscl_strcmp(PortName(), PVMF_OMX_VIDEO_DEC_OUTPUT_PORT_NAME) == 0))
+    {
+        PvmiCapabilityAndConfigPortFormatImpl::Construct(
+            PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS
+            , PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS_VALTYPE);
+    }
+    else if ((oscl_strcmp(PortName(), PVMF_OMX_AUDIO_DEC_INPUT_PORT_NAME) == 0) || (oscl_strcmp(PortName(), PVMF_OMX_AUDIO_DEC_OUTPUT_PORT_NAME) == 0))
+    {
+        PvmiCapabilityAndConfigPortFormatImpl::Construct(
+            PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS
+            , PVMF_OMX_AUDIO_DEC_PORT_INPUT_FORMATS_VALTYPE);
+    }
+}
+
+
+OSCL_EXPORT_REF PVMFOMXDecPort::~PVMFOMXDecPort()
+{
+    if (iTrackConfig != NULL)
+    {
+        OSCL_FREE(iTrackConfig);
+        iTrackConfigSize = 0;
+    }
+
+    Disconnect();
+    ClearMsgQueues();
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXDecPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    bool isSupported = false;
+
+    if ((oscl_strcmp(PortName(), PVMF_OMX_VIDEO_DEC_INPUT_PORT_NAME) == 0) || (oscl_strcmp(PortName(), PVMF_OMX_VIDEO_DEC_OUTPUT_PORT_NAME) == 0))
+    {
+        isSupported = ((aFmt == PVMF_MIME_YUV420) ||
+                       (aFmt == PVMF_MIME_H264_VIDEO_RAW) ||
+                       (aFmt == PVMF_MIME_H264_VIDEO_MP4) ||
+                       (aFmt == PVMF_MIME_H264_VIDEO) ||
+                       (aFmt == PVMF_MIME_M4V) ||
+                       (aFmt == PVMF_MIME_H2631998) ||
+                       (aFmt == PVMF_MIME_H2632000) ||
+                       (aFmt == PVMF_MIME_WMV)
+                      );
+    }
+    else if ((oscl_strcmp(PortName(), PVMF_OMX_AUDIO_DEC_INPUT_PORT_NAME) == 0) || (oscl_strcmp(PortName(), PVMF_OMX_AUDIO_DEC_OUTPUT_PORT_NAME) == 0))
+    {
+        isSupported = ((aFmt == PVMF_MIME_PCM16) ||
+                       (aFmt == PVMF_MIME_LATM) ||
+                       (aFmt == PVMF_MIME_MPEG4_AUDIO) ||
+                       (aFmt == PVMF_MIME_ADIF) ||
+                       (aFmt == PVMF_MIME_ASF_MPEG4_AUDIO) ||
+                       (aFmt == PVMF_MIME_AAC_SIZEHDR) ||
+                       (aFmt == PVMF_MIME_AMR_IF2) ||
+                       (aFmt == PVMF_MIME_AMR_IETF) ||
+                       (aFmt == PVMF_MIME_AMR) ||
+                       (aFmt == PVMF_MIME_AMRWB_IETF) ||
+                       (aFmt == PVMF_MIME_AMRWB) ||
+                       (aFmt == PVMF_MIME_MP3) ||
+                       (aFmt == PVMF_MIME_WMA)
+                      );
+    }
+
+    return isSupported;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVMFOMXDecPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "%s::FormatUpdated %s", PortName(), iFormat.getMIMEStrPtr()));
+}
+
+OSCL_EXPORT_REF bool
+PVMFOMXDecPort::pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag)
+{
+    if ((iConnectedPort) &&
+            (iTag == PVMF_OMX_DEC_NODE_PORT_TYPE_OUTPUT))
+    {
+        OsclAny* temp = NULL;
+        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+
+        PvmiCapabilityAndConfig *config = (PvmiCapabilityAndConfig*)temp;
+
+        /*
+         * Create PvmiKvp for capability settings
+         */
+        if ((config) && (aMemFrag.getMemFragSize() > 0))
+        {
+            OsclMemAllocator alloc;
+            PvmiKvp kvp;
+            kvp.key = NULL;
+            kvp.length = oscl_strlen(PVMF_FORMAT_SPECIFIC_INFO_KEY) + 1; // +1 for \0
+            kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+            if (kvp.key == NULL)
+            {
+                return false;
+            }
+            oscl_strncpy(kvp.key, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp.length);
+
+            kvp.value.key_specific_value = (OsclAny*)(aMemFrag.getMemFragPtr());
+            kvp.capacity = aMemFrag.getMemFragSize();
+            PvmiKvp* retKvp = NULL; // for return value
+            int32 err;
+            OSCL_TRY(err, config->setParametersSync(NULL, &kvp, 1, retKvp););
+            /* ignore the error for now */
+            alloc.deallocate((OsclAny*)(kvp.key));
+        }
+        return true;
+    }
+    return false;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXDecPort::Connect(PVMFPortInterface* aPort)
+{
+    if (!aPort)
+    {
+        return PVMFErrArgument;
+    }
+
+    if (iConnectedPort)
+    {
+        return PVMFFailure;
+    }
+
+    OsclAny* temp;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = (PvmiCapabilityAndConfig*)temp;
+
+    if (config != NULL)
+    {
+        PvmiKvp* kvp;
+        int numKvp = 0;
+        PVMFStatus status =
+            config->getParametersSync(NULL, (PvmiKeyType)PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp, numKvp, NULL);
+        if (status == PVMFSuccess)
+        {
+            if (iTrackConfig != NULL)
+            {
+                OSCL_FREE(iTrackConfig);
+                iTrackConfigSize = 0;
+            }
+            if (kvp)
+            {
+                iTrackConfigSize = kvp->capacity;
+                iTrackConfig = (uint8*)(OSCL_MALLOC(sizeof(uint8) * iTrackConfigSize));
+                oscl_memcpy(iTrackConfig, kvp->value.key_specific_value, iTrackConfigSize);
+            }
+            config->releaseParameters(NULL, kvp, numKvp);
+        }
+
+    }
+
+    // Automatically connect the peer.
+
+    if (aPort->PeerConnect(this) != PVMFSuccess)
+    {
+        return PVMFFailure;
+    }
+
+    iConnectedPort = aPort;
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+// needed for WMV port exchange
+OSCL_EXPORT_REF void PVMFOMXDecPort::setParametersSync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements,
+        PvmiKvp * & aRet_kvp)
+{
+
+    // if port connect needs format specific info
+    if (aParameters && pv_mime_strcmp(aParameters->key, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        if (iTrackConfig != NULL)
+        {
+            OSCL_FREE(iTrackConfig);
+            iTrackConfigSize = 0;
+        }
+        iTrackConfigSize = aParameters->capacity;
+        iTrackConfig = (uint8*)(OSCL_MALLOC(sizeof(uint8) * iTrackConfigSize));
+        oscl_memcpy(iTrackConfig, aParameters->value.key_specific_value, iTrackConfigSize);
+        return;
+    }
+    // call the base class function
+    PvmiCapabilityAndConfigPortFormatImpl::setParametersSync(aSession, aParameters, num_elements, aRet_kvp);
+
+}
+
+
+
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXDecPort::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+
+    OSCL_UNUSED_ARG(aSession);
+
+
+
+    // in case of WMV or WMA call the Node verify to make sure that the parameters are OK
+    // (the node will also make sure that the downstream node is OK with the change
+    // if necessary)
+    if (iFormat == PVMF_MIME_WMV || iFormat == PVMF_MIME_WMA)
+    {
+        if (iOMXNode->VerifyParametersSync(aSession, aParameters, num_elements))
+        {
+            return PVMFSuccess;
+        }
+        else
+        {
+            return PVMFErrNotSupported;
+        }
+    }
+    else
+    {
+        return PVMFSuccess;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFOMXDecPort::verifyConnectedPortParametersSync(const char* aFormatValType,
+        OsclAny* aConfig)
+{
+    PVMFStatus status = PVMFErrNotSupported;
+    OsclAny* temp;
+    if (iConnectedPort)
+    {
+        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    }
+    else
+        return PVMFFailure;
+
+    PvmiCapabilityAndConfig *capConfig = (PvmiCapabilityAndConfig*)temp;
+
+    if (capConfig != NULL)
+    {
+        if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+        {
+            OsclRefCounterMemFrag* aFormatValue = (OsclRefCounterMemFrag*)aConfig;
+            if (aFormatValue->getMemFragSize() > 0)
+            {
+                OsclMemAllocator alloc;
+                PvmiKvp kvp;
+                kvp.key = NULL;
+                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+                if (kvp.key == NULL)
+                {
+                    return PVMFErrNoMemory;
+                }
+                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
+
+                kvp.value.key_specific_value = (OsclAny*)(aFormatValue->getMemFragPtr());
+                kvp.capacity = aFormatValue->getMemFragSize();
+                int32 err;
+                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
+                /* ignore the error for now */
+                alloc.deallocate((OsclAny*)(kvp.key));
+
+                return status;
+            }
+        }
+        else if (pv_mime_strcmp(aFormatValType, PVMF_BITRATE_VALUE_KEY) == 0 ||
+                 pv_mime_strcmp(aFormatValType, PVMF_FRAMERATE_VALUE_KEY) == 0)
+        {
+            if (aConfig != NULL)
+            {
+                OsclMemAllocator alloc;
+                PvmiKvp kvp;
+                kvp.key = NULL;
+                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+                if (kvp.key == NULL)
+                {
+                    return PVMFErrNoMemory;
+                }
+                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
+                uint32* bitrate = (uint32*)aConfig;
+                kvp.value.uint32_value = *bitrate;
+
+                int32 err;
+                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
+                /* ignore the error for now */
+                alloc.deallocate((OsclAny*)(kvp.key));
+
+                return status;
+            }
+        }
+        return PVMFErrArgument;
+    }
+    return PVMFFailure;
+}
+
+
+
+
diff --git a/nodes/pvomxencnode/Android.mk b/nodes/pvomxencnode/Android.mk
new file mode 100644
index 0000000..ccd7520
--- /dev/null
+++ b/nodes/pvomxencnode/Android.mk
@@ -0,0 +1,34 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pvmf_omx_enc_factory.cpp \
+ 	src/pvmf_omx_enc_node.cpp \
+ 	src/pvmf_omx_enc_port.cpp \
+ 	src/pvmf_omx_enc_callbacks.cpp
+
+
+LOCAL_MODULE := libpvomxencnode
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/nodes/pvomxencnode/src \
+ 	$(PV_TOP)/nodes/pvomxencnode/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pvmf_omx_enc_defs.h \
+ 	include/pvmf_omx_enc_factory.h \
+ 	include/pvmf_omx_enc_port.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/nodes/pvomxencnode/build/make/local.mk b/nodes/pvomxencnode/build/make/local.mk
new file mode 100644
index 0000000..ef5d3bb
--- /dev/null
+++ b/nodes/pvomxencnode/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvomxencnode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += \
+  ../../../../extern_libs_v2/khronos/openmax/include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_omx_enc_factory.cpp \
+	pvmf_omx_enc_node.cpp \
+	pvmf_omx_enc_port.cpp \
+	pvmf_omx_enc_callbacks.cpp
+
+HDRS := pvmf_omx_enc_defs.h \
+	pvmf_omx_enc_factory.h \
+	pvmf_omx_enc_port.h 
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvomxencnode/include/pvmf_omx_enc_defs.h b/nodes/pvomxencnode/include/pvmf_omx_enc_defs.h
new file mode 100644
index 0000000..5560489
--- /dev/null
+++ b/nodes/pvomxencnode/include/pvmf_omx_enc_defs.h
@@ -0,0 +1,39 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_ENC_DEFS_H_INCLUDED
+#define PVMF_OMX_ENC_DEFS_H_INCLUDED
+
+// Error and info messages
+//
+enum PVMFOMXEncNodeErrors
+{
+    // Enc node failed to initialize the encoder. Fatal error so the node needs to be reset.
+    PVOMXENCNODE_ERROR_ENCODER_INIT_FAILED = PVMF_NODE_ERROR_EVENT_LAST
+};
+
+enum PVMFOMXEncNodeInfo
+{
+    // Encoding of a frame failed. Encoder node will continue on to encode the next frame
+    PVOMXENCNODE_INFO_ENCODEFRAME_FAILED = PVMF_NODE_INFO_EVENT_LAST,
+    // Input bitstream buffer overflowed (frame too large or couldn't find frame marker).
+    PVOMXENCNODE_INFO_INPUTBITSTREAMBUFFER_OVERFLOW
+};
+
+#endif // PVMF_OMXENC_DEFS_H_INCLUDED
+
+
diff --git a/nodes/pvomxencnode/include/pvmf_omx_enc_factory.h b/nodes/pvomxencnode/include/pvmf_omx_enc_factory.h
new file mode 100644
index 0000000..fdd6ccd
--- /dev/null
+++ b/nodes/pvomxencnode/include/pvmf_omx_enc_factory.h
@@ -0,0 +1,68 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_ENC_FACTORY_H_INCLUDED
+#define PVMF_OMX_ENC_FACTORY_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+// Forward declaration
+class PVMFNodeInterface;
+
+#define KPVMFOMXVideoEncNodeUuid PVUuid(0x7f39e8d1,0x1232,0x4394,0xad,0x85,0x43,0xe3,0x29,0x11,0x9a,0x4a)
+#define KPVMFOMXAudioEncNodeUuid PVUuid(0x6f29e7d1,0x2222,0x3384,0xcd,0x55,0x23,0xa3,0x19,0x51,0xaa,0xca)
+
+/**
+ * PVMFOMXEncNodeFactory Class
+ *
+ * a singleton class which instantiates and provides
+ * access to OMX encoder node. It returns a PVMFNodeInterface
+ * reference, the interface class of the PVMFOMXEncNode.
+ *
+ * The client is expected to contain and maintain a pointer to the instance created
+ * while the node is active.
+ */
+class PVMFOMXEncNodeFactory
+{
+    public:
+        /**
+         * Creates an instance of a PVMFOMXEncNode. If the creation fails, this function will leave.
+         *
+         * @param aPriority The active object priority for the node. Default is standard priority if not specified
+         * @returns A pointer to an instance of PVMFOMXEncNode as PVMFNodeInterface reference or leaves if instantiation fails
+         **/
+        OSCL_IMPORT_REF static PVMFNodeInterface* CreatePVMFOMXEncNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        /**
+         * Deletes an instance of PVMFOMXEncNode
+         * and reclaims all allocated resources.  An instance can be deleted only in
+         * the idle state. An attempt to delete in any other state will fail and return false.
+         *
+         * @param aNode The PVMFOMXEncNode instance to be deleted
+         * @returns A status code indicating success or failure of deletion
+         **/
+        OSCL_IMPORT_REF static bool DeletePVMFOMXEncNode(PVMFNodeInterface* aNode);
+};
+
+#endif // PVMF_OMX_ENC_FACTORY_H_INCLUDED
+
diff --git a/nodes/pvomxencnode/include/pvmf_omx_enc_node_extension_interface.h b/nodes/pvomxencnode/include/pvmf_omx_enc_node_extension_interface.h
new file mode 100644
index 0000000..0e46a3d
--- /dev/null
+++ b/nodes/pvomxencnode/include/pvmf_omx_enc_node_extension_interface.h
@@ -0,0 +1,49 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_ENC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+#define PVMF_OMX_ENC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+
+struct PVMFOMXEncNodeConfig
+{
+    bool iPostProcessingEnable;
+    int32 iPostProcessingMode;
+    bool iDropFrame;
+    uint32 iMimeType;
+};
+
+//Mimetype and Uuid for the custom interface
+#define PVMF_OMX_ENC_NODE_CUSTOM1_UUID 1,2,3,0xde,0xad,0xae,0xcf,0x20,0x11,0x73,0x33
+
+//Mimetypes for the custom interface
+#define PVMF_OMX_ENC_NODE_CUSTOM1_MIMETYPE "pvxxx/OMXEncNode/Custom1"
+
+class PVMFOMXEncNodeExtensionInterface : public PVInterface
+{
+    public:
+        //**********begin PVInterface
+        virtual void addRef() = 0;
+        virtual void removeRef() = 0;
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+        //**********end PVInterface
+
+
+};
+
+#endif //PVMF_OMX_ENC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+
+
diff --git a/nodes/pvomxencnode/include/pvmf_omx_enc_port.h b/nodes/pvomxencnode/include/pvmf_omx_enc_port.h
new file mode 100644
index 0000000..19c22f7
--- /dev/null
+++ b/nodes/pvomxencnode/include/pvmf_omx_enc_port.h
@@ -0,0 +1,226 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_ENC_PORT_H_INCLUDED
+#define PVMF_OMX_ENC_PORT_H_INCLUDED
+
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+#ifndef PV_MIME_STRING_UTILS_H_INCLUDED
+#include "pv_mime_string_utils.h"
+#endif
+
+class PVMFOMXEncNode;
+class PVMFOMXEncInputFormatCompareLess;
+//Default vector reserve size
+#define PVMF_OMX_ENC_NODE_PORT_VECTOR_RESERVE 10
+
+
+
+typedef enum
+{
+    PVMF_OMX_ENC_NODE_PORT_TYPE_INPUT,
+    PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT,
+} PVMFOMXEncPortType;
+
+class PVMFOMXEncPort : public PvmfPortBaseImpl
+            , public PvmiCapabilityAndConfigPortFormatImpl
+{
+    public:
+        PVMFOMXEncPort(int32 aTag, PVMFNodeInterface* aNode, const char*);
+        ~PVMFOMXEncPort();
+
+        // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface
+        bool IsFormatSupported(PVMFFormatType);
+        void FormatUpdated();
+
+        // this port supports config interface
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+                aPtr = (PvmiCapabilityAndConfig*)this;
+            else
+                aPtr = NULL;
+        }
+
+        bool pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag);
+
+        PVMFStatus Connect(PVMFPortInterface* aPort);
+        void setParametersSync(PvmiMIOSession aSession,
+                               PvmiKvp* aParameters,
+                               int num_elements,
+                               PvmiKvp * & aRet_kvp);
+
+        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        PVMFStatus verifyConnectedPortParametersSync(const char* aFormatValType, OsclAny* aConfig);
+        uint32 getTrackConfigSize()
+        {
+            return iTrackConfigSize;
+        }
+        uint8* getTrackConfig()
+        {
+            return iTrackConfig;
+        }
+
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession session,
+                PvmiKeyType identifier,
+                PvmiKvp*& parameters,
+                int& num_parameter_elements,
+                PvmiCapabilityContext context);
+
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession session,
+                PvmiKvp* parameters,
+                int num_elements);
+
+        // For AVC specific call
+        void SendSPS_PPS(OsclMemoryFragment *aSPSs, int aNumSPSs, OsclMemoryFragment *aPPSs, int aNumPPSs);
+
+    private:
+        void Construct();
+
+/////////////////////////////////////////////////////////////////////////////////////
+        ///encoder specific
+        /**
+        * Synchronous query of input port parameters
+        */
+        PVMFStatus GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
+                                          int& num_parameter_elements);
+
+        /**
+         * Synchronous query of output port parameters
+         */
+        PVMFStatus GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
+                                           int& num_parameter_elements);
+        /**
+         * Allocate a specified number of key-value pairs and set the keys
+         *
+         * @param aKvp Output parameter to hold the allocated key-value pairs
+         * @param aKey Key for the allocated key-value pairs
+         * @param aNumParams Number of key-value pairs to be allocated
+         * @return Completion status
+         */
+        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
+
+        /**
+         * Verify one key-value pair parameter against capability of the port and
+         * if the aSetParam flag is set, set the value of the parameter corresponding to
+         * the key.
+         *
+         * @param aKvp Key-value pair parameter to be verified
+         * @param aSetParam If true, set the value of parameter corresponding to the key.
+         * @return PVMFSuccess if parameter is supported, else PVMFFailure
+         */
+        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
+
+        /**
+         * Negotiates input port settings (format, video size and frame rate) and
+         * configures the peer port and the container node with these settings
+         *
+         * @param aConfig Capability and config object for peer port
+         * @return PVMFSuccess if settings are successfully negotiated.
+         */
+        PVMFStatus NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig);
+
+        /**
+         * Negotiates output port settings and configures the peer port using settings
+         * from the container node.
+         *
+         * @param aConfig Capability and config object for peer port
+         * @return PVMFSuccess if settings are successfully negotiated.
+         */
+        PVMFStatus NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig);
+        int32 Config_ParametersSync(PvmiCapabilityAndConfig*&, PvmiKvp*&, PvmiKvp*&);
+        int32 PushKVP(OsclPriorityQueue<PvmiKvp*, OsclMemAllocator, Oscl_Vector<PvmiKvp*, OsclMemAllocator>, PVMFOMXEncInputFormatCompareLess>&, PvmiKvp*);
+
+        OsclMemAllocator iAlloc;
+//////////////////////////////////////////////////////////////////////////
+
+        PVLogger *iLogger;
+        uint32 iNumFramesGenerated; //number of source frames generated.
+        uint32 iNumFramesConsumed; //number of frames consumed & discarded.
+        uint32 iTrackConfigSize;
+        uint8* iTrackConfig;
+        friend class PVMFOMXEncNode;
+        PVMFOMXEncNode* iOMXNode;
+};
+
+class PVMFOMXEncInputFormatCompareLess
+{
+    public:
+        /**
+         * The algorithm used in OsclPriorityQueue needs a compare function
+         * that returns true when A's priority is less than B's
+         * @return true if A's priority is less than B's, else false
+         */
+        int compare(PvmiKvp*& a, PvmiKvp*& b) const
+        {
+            return (PVMFOMXEncInputFormatCompareLess::GetPriority(a) <
+                    PVMFOMXEncInputFormatCompareLess::GetPriority(b));
+        }
+
+        /**
+         * Returns the priority of each command
+         * @return A 0-based priority number. A lower number indicates lower priority.
+         */
+        static int GetPriority(PvmiKvp*& aKvp)
+        {
+            if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_YUV420) == 0)
+            {
+                return 3;
+            }
+            else if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_YUV422) == 0)
+            {
+                return 2;
+            }
+            else if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_RGB12) == 0)
+            {
+                return 1;
+            }
+            else if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_RGB24) == 0)
+            {
+                return 0;
+            }
+            else
+            {
+                return 0;
+            }
+        }
+};
+#endif // PVMF_OMX_ENC_PORT_H_INCLUDED
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_callbacks.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_callbacks.cpp
new file mode 100644
index 0000000..a676db3
--- /dev/null
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_callbacks.cpp
@@ -0,0 +1,448 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_omx_enc_callbacks.h"
+#include "pvmf_omx_enc_node.h"
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+EventHandlerThreadSafeCallbackAOEnc::EventHandlerThreadSafeCallbackAOEnc(void* aObserver,
+        uint32 aDepth,
+        const char* aAOname,
+        int32 aPriority)
+        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
+{
+
+    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
+    if (iMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
+    }
+    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
+    // created in the 2nd thread and will fail to deallocate properly.
+
+    OsclAny *dummy = iMemoryPool->allocate(sizeof(EventHandlerSpecificData));
+    iMemoryPool->deallocate(dummy);
+}
+
+EventHandlerThreadSafeCallbackAOEnc::~EventHandlerThreadSafeCallbackAOEnc()
+{
+    if (iMemoryPool)
+    {
+        iMemoryPool->removeRef();
+        iMemoryPool = NULL;
+    }
+}
+OsclReturnCode EventHandlerThreadSafeCallbackAOEnc::ProcessEvent(OsclAny* EventData)
+{
+    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
+    if (iObserver != NULL)
+    {
+        PVMFOMXEncNode* ptr = (PVMFOMXEncNode*) iObserver;
+
+        ptr->ProcessCallbackEventHandler_MultiThreaded(EventData);
+
+    }
+    return OsclSuccess;
+}
+
+// We override the Run to process multiple (i.e. all in the queue) events in one Run
+
+void EventHandlerThreadSafeCallbackAOEnc::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAOEnc::Run() In"));
+
+    OsclAny *P; // parameter to dequeue
+    OsclReturnCode status = OsclSuccess;
+
+
+    do
+    {
+
+
+        P = DeQueue(status);
+        // status is either OsclSuccess or OsclPending (if the last event was pulled
+        // from the queue)
+
+        if ((status == OsclSuccess) || (status == OsclPending))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAOEnc::Run() - Calling Process Event"));
+            ProcessEvent(P);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAOEnc::Run() - could not dequeue event data"));
+        }
+
+
+        // it is possible that an event arrives between dequeueing the last event and this point.
+        // If this is the case, we will be rescheduled and process the event
+        // in the next Run
+
+
+    }
+    while (status == OsclSuccess);
+    // if the status is "OsclPending" there were no more events in the queue
+    // (if another event arrived in the meanwhile, AO will be rescheduled)
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAOEnc::Run() Out"));
+}
+
+// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
+// (i.e. PendForExec control is done in the loop in Run)
+OsclAny* EventHandlerThreadSafeCallbackAOEnc::DeQueue(OsclReturnCode &stat)
+{
+    OsclAny *pData;
+    OsclProcStatus::eOsclProcError sema_status;
+
+    stat = OsclSuccess;
+
+    // Protect the queue while accessing it:
+    Mutex.Lock();
+
+    if (Q->NumElem == 0)
+    {
+        // nothing to de-queue
+        stat = OsclFailure;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAOEnc::DeQueue() - No events in the queue - return ()"));
+        Mutex.Unlock();
+
+        return NULL;
+    }
+
+    pData = (Q->pFirst[Q->index_out]).pData;
+
+    Q->index_out++;
+    // roll-over the index
+    if (Q->index_out == Q->MaxNumElements)
+        Q->index_out = 0;
+
+    Q->NumElem--;
+
+    // check if there is need to call waitforevent
+    if ((Q->NumElem) == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAOEnc::Run() - No more events, call PendForExec()"));
+        PendForExec();
+        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
+        // so that it can get out of the loop
+    }
+
+
+    //release queue access
+    Mutex.Unlock();
+
+    // Signal the semaphore that controls the remote thread.
+    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
+    sema_status = RemoteThreadCtrlSema.Signal();
+    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
+    {
+        stat = OsclFailure;
+        return NULL;
+    }
+
+    return pData;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////
+EmptyBufferDoneThreadSafeCallbackAOEnc::EmptyBufferDoneThreadSafeCallbackAOEnc(void* aObserver,
+        uint32 aDepth,
+        const char* aAOname,
+        int32 aPriority)
+        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
+{
+
+    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
+    if (iMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
+
+    }
+    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
+    // created in the 2nd thread and will fail to deallocate properly.
+
+    OsclAny *dummy = iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData));
+    iMemoryPool->deallocate(dummy);
+}
+
+EmptyBufferDoneThreadSafeCallbackAOEnc::~EmptyBufferDoneThreadSafeCallbackAOEnc()
+{
+    if (iMemoryPool)
+    {
+
+        iMemoryPool->removeRef();
+        iMemoryPool = NULL;
+    }
+
+}
+OsclReturnCode EmptyBufferDoneThreadSafeCallbackAOEnc::ProcessEvent(OsclAny* EventData)
+{
+    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
+    if (iObserver != NULL)
+    {
+        PVMFOMXEncNode* ptr = (PVMFOMXEncNode *) iObserver;
+
+        ptr->ProcessCallbackEmptyBufferDone_MultiThreaded(EventData);
+
+    }
+    return OsclSuccess;
+}
+
+// We override the Run to process multiple (i.e. all in the queue) events in one Run
+
+void EmptyBufferDoneThreadSafeCallbackAOEnc::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAOEnc::Run() In"));
+
+    OsclAny *P; // parameter to dequeue
+    OsclReturnCode status = OsclSuccess;
+
+    do
+    {
+
+
+        P = DeQueue(status);
+
+
+        if ((status == OsclSuccess) || (status == OsclPending))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAOEnc::Run() - Calling Process Event"));
+            ProcessEvent(P);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAOEnc::Run() - could not dequeue event data"));
+        }
+
+
+        // it is possible that an event arrives between dequeueing the last event and this point.
+        // If this is the case, we will be rescheduled and process the event
+        // in the next Run
+
+
+    }
+    while (status == OsclSuccess);
+    // if the status is "OsclPending" there were no more events in the queue
+    // (if another event arrived in the meanwhile, AO will be rescheduled)
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAOEnc::Run() Out"));
+}
+
+// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
+// (i.e. PendForExec control is done in the loop in Run)
+OsclAny* EmptyBufferDoneThreadSafeCallbackAOEnc::DeQueue(OsclReturnCode &stat)
+{
+    OsclAny *pData;
+    OsclProcStatus::eOsclProcError sema_status;
+
+    stat = OsclSuccess;
+
+    // Protect the queue while accessing it:
+    Mutex.Lock();
+
+    if (Q->NumElem == 0)
+    {
+        // nothing to de-queue
+        stat = OsclFailure;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAOEnc::DeQueue() - No events in the queue - return ()"));
+        Mutex.Unlock();
+
+        return NULL;
+    }
+
+    pData = (Q->pFirst[Q->index_out]).pData;
+
+    Q->index_out++;
+    // roll-over the index
+    if (Q->index_out == Q->MaxNumElements)
+        Q->index_out = 0;
+
+    Q->NumElem--;
+
+    // check if there is need to call waitforevent
+    if ((Q->NumElem) == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAOEnc::Run() - No more events, call PendForExec()"));
+        PendForExec();
+        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
+        // so that it can get out of the loop
+    }
+
+    //release queue access
+    Mutex.Unlock();
+
+    // Signal the semaphore that controls the remote thread.
+    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
+    sema_status = RemoteThreadCtrlSema.Signal();
+    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
+    {
+        stat = OsclFailure;
+        return NULL;
+    }
+
+    return pData;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+FillBufferDoneThreadSafeCallbackAOEnc::FillBufferDoneThreadSafeCallbackAOEnc(void* aObserver,
+        uint32 aDepth,
+        const char* aAOname,
+        int32 aPriority)
+        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
+{
+
+    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
+    if (iMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
+    }
+    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
+    // created in the 2nd thread and will fail to deallocate properly.
+
+    OsclAny *dummy = iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData));
+    iMemoryPool->deallocate(dummy);
+}
+
+FillBufferDoneThreadSafeCallbackAOEnc::~FillBufferDoneThreadSafeCallbackAOEnc()
+{
+    if (iMemoryPool)
+    {
+
+        iMemoryPool->removeRef();
+        iMemoryPool = NULL;
+    }
+}
+
+OsclReturnCode FillBufferDoneThreadSafeCallbackAOEnc::ProcessEvent(OsclAny* EventData)
+{
+    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
+    if (iObserver != NULL)
+    {
+        PVMFOMXEncNode* ptr = (PVMFOMXEncNode*) iObserver;
+
+        ptr->ProcessCallbackFillBufferDone_MultiThreaded(EventData);
+
+    }
+    return OsclSuccess;
+}
+
+// We override the Run to process multiple (i.e. all in the queue) events in one Run
+
+void FillBufferDoneThreadSafeCallbackAOEnc::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAOEnc::Run() In"));
+
+    OsclAny *P; // parameter to dequeue
+    OsclReturnCode status = OsclSuccess;
+
+    do
+    {
+
+
+        P = DeQueue(status);
+
+
+        if ((status == OsclSuccess) || (status == OsclPending))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAOEnc::Run() - Calling Process Event"));
+            ProcessEvent(P);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAOEnc::Run() - could not dequeue event data"));
+        }
+
+
+        // it is possible that an event arrives between dequeueing the last event and this point.
+        // If this is the case, we will be rescheduled and process the event
+        // in the next Run
+
+
+    }
+    while (status == OsclSuccess);
+    // if the status is "OsclPending" there were no more events in the queue
+    // (if another event arrived in the meanwhile, AO will be rescheduled)
+
+
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAOEnc::Run() Out"));
+}
+
+// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
+// (i.e. PendForExec control is done in the loop in Run)
+OsclAny* FillBufferDoneThreadSafeCallbackAOEnc::DeQueue(OsclReturnCode &stat)
+{
+    OsclAny *pData;
+    OsclProcStatus::eOsclProcError sema_status;
+
+    stat = OsclSuccess;
+
+    // Protect the queue while accessing it:
+    Mutex.Lock();
+
+    if (Q->NumElem == 0)
+    {
+        // nothing to de-queue
+        stat = OsclFailure;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAOEnc::DeQueue() - No events in the queue - return ()"));
+        Mutex.Unlock();
+
+        return NULL;
+    }
+
+    pData = (Q->pFirst[Q->index_out]).pData;
+
+    Q->index_out++;
+    // roll-over the index
+    if (Q->index_out == Q->MaxNumElements)
+        Q->index_out = 0;
+
+    Q->NumElem--;
+    // check if there is need to call waitforevent
+    if ((Q->NumElem) == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAOEnc::Run() - No more events, call PendForExec()"));
+        PendForExec();
+        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
+        // so that it can get out of the loop
+    }
+
+    //release queue access
+    Mutex.Unlock();
+
+    // Signal the semaphore that controls the remote thread.
+    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
+    sema_status = RemoteThreadCtrlSema.Signal();
+    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
+    {
+        stat = OsclFailure;
+        return NULL;
+    }
+
+    return pData;
+}
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_callbacks.h b/nodes/pvomxencnode/src/pvmf_omx_enc_callbacks.h
new file mode 100644
index 0000000..7130b29
--- /dev/null
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_callbacks.h
@@ -0,0 +1,154 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_ENC_CALLBACKS_H_INCLUDED
+#define PVMF_OMX_ENC_CALLBACKS_H_INCLUDED
+
+
+#ifndef THREADSAFE_CALLBACK_AO_H_INCLUDED
+#include "threadsafe_callback_ao.h"
+#endif
+
+#ifndef THREADSAFE_MEMPOOL_H_INCLUDED
+#include "threadsafe_mempool.h"
+#endif
+
+
+#ifndef OMX_Types_h
+#include "omx_types.h"
+#endif
+
+#ifndef OMX_Core_h
+#include "omx_core.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+// structure that contains EventHandler callback type parameters:
+typedef struct EventHandlerSpecificData
+{
+    OMX_HANDLETYPE hComponent;
+    OMX_PTR pAppData;
+    OMX_EVENTTYPE eEvent;
+    OMX_U32 nData1;
+    OMX_U32 nData2;
+    OMX_PTR pEventData;
+} EventHandlerSpecificData;
+
+
+// structure that contains EmptyBufferDone callback type parameters:
+typedef struct EmptyBufferDoneSpecificData
+{
+    OMX_HANDLETYPE hComponent;
+    OMX_PTR pAppData;
+    OMX_BUFFERHEADERTYPE* pBuffer;
+} EmptyBufferDoneSpecificData;
+
+
+// structure that contains FillBufferDone callback type parameters:
+typedef struct FillBufferDoneSpecificData
+{
+    OMX_HANDLETYPE hComponent;
+    OMX_PTR pAppData;
+    OMX_BUFFERHEADERTYPE* pBuffer;
+} FillBufferDoneSpecificData;
+
+
+// This class defines the callback AO that handles the callbacks from the remote thread in a thread-safe way.
+// The callback events arriving from the remote thread are queued and processed later in PV thread context.
+// The class is DERIVED from the "ThreadSafeCallbackAO" class defined in "threadsafe_callback_ao.h/cpp"
+// OVERLOAD THE METHOD : "ProcessEvent" so that it does something meaningful
+
+
+// Test AO receives the remote thread specific API callback and then calls the generic API "ReceiveEvent"
+const char EventHandlerAOName[] = "EventHandlerCallbackAO";
+const char EmptyBufferDoneAOName[] = "EventHandlerCallbackAO";
+const char FillBufferDoneAOName[] = "EventHandlerCallbackAO";
+
+
+/**************** CLASS FOR EVENT HANDLER *************/
+class EventHandlerThreadSafeCallbackAOEnc : public ThreadSafeCallbackAO
+{
+    public:
+        // Constructor
+        EventHandlerThreadSafeCallbackAOEnc(
+            void* aObserver = NULL,
+            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
+            const char* aAOname = EventHandlerAOName,
+            int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+
+        // OVERLOADED ProcessEvent
+        OsclReturnCode ProcessEvent(OsclAny* EventData);
+
+        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
+        virtual void Run();
+        virtual OsclAny* DeQueue(OsclReturnCode &stat);
+
+        virtual ~EventHandlerThreadSafeCallbackAOEnc();
+        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
+
+};
+
+
+/**************** CLASS FOR EVENT HANDLER *************/
+class EmptyBufferDoneThreadSafeCallbackAOEnc : public ThreadSafeCallbackAO
+{
+    public:
+        // Constructor
+        EmptyBufferDoneThreadSafeCallbackAOEnc(
+            void* aObserver = NULL,
+            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
+            const char* aAOname = EmptyBufferDoneAOName,
+            int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        // OVERLOADED ProcessEvent
+        OsclReturnCode ProcessEvent(OsclAny* EventData);
+
+        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
+        virtual void Run();
+        virtual OsclAny* DeQueue(OsclReturnCode &stat);
+
+        virtual ~EmptyBufferDoneThreadSafeCallbackAOEnc();
+        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
+};
+
+
+
+
+/**************** CLASS FOR EVENT HANDLER *************/
+class FillBufferDoneThreadSafeCallbackAOEnc : public ThreadSafeCallbackAO
+{
+    public:
+        // Constructor
+        FillBufferDoneThreadSafeCallbackAOEnc(void* aObserver = NULL,
+                                              uint32 aDepth = DEFAULT_QUEUE_DEPTH,
+                                              const char* aAOname = FillBufferDoneAOName,
+                                              int32 aPriority = OsclActiveObject::EPriorityNominal);
+
+        // OVERLOADED ProcessEvent
+        OsclReturnCode ProcessEvent(OsclAny* EventData);
+        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
+        virtual void Run();
+        virtual OsclAny* DeQueue(OsclReturnCode &stat);
+
+        virtual ~FillBufferDoneThreadSafeCallbackAOEnc();
+        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
+};
+
+#endif	//#ifndef PVMF_OMX_ENC_CALLBACKS_H_INLCUDED
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_factory.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_factory.cpp
new file mode 100644
index 0000000..ce7a144
--- /dev/null
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_factory.cpp
@@ -0,0 +1,60 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmf_omx_enc_factory.cpp
+ * @brief Singleton factory for PVMFOMXEncNode
+ */
+
+#include "oscl_base.h"
+
+#include "pvmf_omx_enc_node.h"
+#include "pvmf_omx_enc_factory.h"
+
+#include "oscl_error_codes.h"
+#include "oscl_exception.h"
+
+// Use default DLL entry point
+#include "oscl_dll.h"
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVMFOMXEncNodeFactory::CreatePVMFOMXEncNode(int32 aPriority)
+{
+    PVMFNodeInterface* node = NULL;
+    node = new PVMFOMXEncNode(aPriority);
+    if (node == NULL)
+    {
+        OSCL_LEAVE(OsclErrNoMemory);
+    }
+    return node;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNodeFactory::DeletePVMFOMXEncNode(PVMFNodeInterface* aNode)
+{
+    if (aNode)
+    {
+        delete aNode;
+        return true;
+    }
+
+    return false;
+}
+
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp
new file mode 100644
index 0000000..a62cd55
--- /dev/null
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp
@@ -0,0 +1,8915 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_omx_enc_node.h"
+#include "pvlogger.h"
+#include "oscl_error_codes.h"
+#include "pvmf_omx_enc_port.h"
+#include "pv_mime_string_utils.h"
+#include "oscl_snprintf.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+#include "pvmi_kvp_util.h"
+
+#ifdef _DEBUG
+#include <stdio.h>
+#endif
+
+#include "omx_core.h"
+#include "pvmf_omx_enc_callbacks.h"     //used for thin AO in encoder's callbacks
+#include "pv_omxcore.h"
+
+#define CONFIG_SIZE_AND_VERSION(param) \
+	    param.nSize=sizeof(param); \
+	    param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR; \
+	    param.nVersion.s.nVersionMinor = SPECVERSIONMINOR; \
+	    param.nVersion.s.nRevision = SPECREVISION; \
+	    param.nVersion.s.nStep = SPECSTEP;
+
+
+#define CHECK_OMX_ERR_AND_RETURN(Err, str) \
+		if (Err != OMX_ErrorNone) \
+		{	\
+			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,	(0, str));	\
+		}
+
+
+#define PVOMXENC_EXTRA_YUVBUFFER_POOLNUM 3
+#define PVOMXENC_MEDIADATA_POOLNUM (PVOMXENCMAXNUMDPBFRAMESPLUS1 + PVOMXENC_EXTRA_YUVBUFFER_POOLNUM)
+#define PVOMXENC_MEDIADATA_CHUNKSIZE 128
+
+
+const uint32 DEFAULT_VOL_HEADER_LENGTH = 28;
+const uint8 DEFAULT_VOL_HEADER[DEFAULT_VOL_HEADER_LENGTH] =
+{
+    0x00, 0x00, 0x01, 0xB0, 0x08, 0x00, 0x00, 0x01,
+    0xB5, 0x09,	0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x01, 0x20, 0x00, 0x84, 0x40, 0xFA, 0x28, 0x2C,
+    0x20, 0x90, 0xA2, 0x1F
+};
+
+
+#ifdef _TEST_AE_ERROR_HANDLING
+const uint32 FAIL_NODE_CMD_START = 2;
+const uint32 FAIL_NODE_CMD_STOP = 3;
+const uint32 FAIL_NODE_CMD_FLUSH = 4;
+const uint32 FAIL_NODE_CMD_PAUSE = 5;
+const uint32 FAIL_NODE_CMD_RELEASE_PORT = 7;
+#endif
+
+#define PVMF_OMXENC_NUM_METADATA_VALUES 6
+
+// Constant character strings for metadata keys
+static const char PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY[] = "codec-info/video/format";
+static const char PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY[] = "codec-info/video/width";
+static const char PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY[] = "codec-info/video/height";
+static const char PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY[] = "codec-info/video/profile";
+static const char PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY[] = "codec-info/video/level";
+static const char PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY[] = "codec-info/video/avgbitrate";//(bits per sec)
+
+
+static const char PVOMXENCMETADATA_SEMICOLON[] = ";";
+
+static const char LOG_ID_AUDIO_AMR[]  = "Audio_AMR";
+static const char LOG_ID_VIDEO_H263[] = "Video_H263";
+static const char LOG_ID_VIDEO_M4V[] =  "Video_M4V";
+static const char LOG_ID_VIDEO_AVC[] =  "Video_AVC";
+static const char LOG_ID_UNKNOWN[] = "TypeNotSetYet";
+
+// OMX CALLBACKS
+// 1) AO OMX component running in the same thread as the OMX node
+//	In this case, the callbacks can be called directly from the component
+//	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
+//	The callback can perform do RunIfNotReady
+
+// 2) Multithreaded component
+//	In this case, the callback is made using the threadsafe callback (TSCB) AO
+//	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent) => event is queued
+//  Node thread		 : dequeue event => TSCB(ProcessEvent)->ProcessCallbackEventHandler->EventHandlerProcessing
+
+
+
+// callback for Event Handler - in multithreaded case, event is queued to be processed later
+//	in AO case, event is processed immediately by calling EventHandlerProcessing
+OMX_ERRORTYPE CallbackEventHandlerEnc(OMX_OUT OMX_HANDLETYPE aComponent,
+                                      OMX_OUT OMX_PTR aAppData,
+                                      OMX_OUT OMX_EVENTTYPE aEvent,
+                                      OMX_OUT OMX_U32 aData1,
+                                      OMX_OUT OMX_U32 aData2,
+                                      OMX_OUT OMX_PTR aEventData)
+{
+
+    PVMFOMXEncNode *Node = (PVMFOMXEncNode *) aAppData;
+
+    if (Node->IsComponentMultiThreaded())
+    {
+        // allocate the memory for the callback event specific data
+        //EventHandlerSpecificData* ED = (EventHandlerSpecificData*) oscl_malloc(sizeof (EventHandlerSpecificData));
+        EventHandlerSpecificData* ED = (EventHandlerSpecificData*) Node->iThreadSafeHandlerEventHandler->iMemoryPool->allocate(sizeof(EventHandlerSpecificData));
+
+        // pack the relevant data into the structure
+        ED->hComponent = aComponent;
+        ED->pAppData = aAppData;
+        ED->eEvent = aEvent;
+        ED->nData1 = aData1;
+        ED->nData2 = aData2;
+        ED->pEventData = aEventData;
+
+        // convert the pointer into OsclAny ptr
+        OsclAny* P = (OsclAny*) ED;
+
+
+        // CALL the generic callback AO API:
+        Node->iThreadSafeHandlerEventHandler->ReceiveEvent(P);
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+
+        OMX_ERRORTYPE status;
+        status = Node->EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
+        return status;
+    }
+
+}
+
+
+// callback for EmptyBufferDone - in multithreaded case, event is queued to be processed later
+//	in AO case, event is processed immediately by calling EmptyBufferDoneProcessing
+OMX_ERRORTYPE CallbackEmptyBufferDoneEnc(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+
+    PVMFOMXEncNode *Node = (PVMFOMXEncNode *) aAppData;
+    if (Node->IsComponentMultiThreaded())
+    {
+
+        // allocate the memory for the callback event specific data
+        //EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) oscl_malloc(sizeof (EmptyBufferDoneSpecificData));
+        EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) Node->iThreadSafeHandlerEmptyBufferDone->iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData));
+
+        // pack the relevant data into the structure
+        ED->hComponent = aComponent;
+        ED->pAppData = aAppData;
+        ED->pBuffer = aBuffer;
+
+        // convert the pointer into OsclAny ptr
+        OsclAny* P = (OsclAny*) ED;
+
+        // CALL the generic callback AO API:
+        Node->iThreadSafeHandlerEmptyBufferDone->ReceiveEvent(P);
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        OMX_ERRORTYPE status;
+        status = Node->EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
+        return status;
+    }
+
+}
+
+// callback for FillBufferDone - in multithreaded case, event is queued to be processed later
+//	in AO case, event is processed immediately by calling FillBufferDoneProcessing
+OMX_ERRORTYPE CallbackFillBufferDoneEnc(OMX_OUT OMX_HANDLETYPE aComponent,
+                                        OMX_OUT OMX_PTR aAppData,
+                                        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+    PVMFOMXEncNode *Node = (PVMFOMXEncNode *) aAppData;
+    if (Node->IsComponentMultiThreaded())
+    {
+
+        // allocate the memory for the callback event specific data
+        //FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) oscl_malloc(sizeof (FillBufferDoneSpecificData));
+        FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) Node->iThreadSafeHandlerFillBufferDone->iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData));
+
+        // pack the relevant data into the structure
+        ED->hComponent = aComponent;
+        ED->pAppData = aAppData;
+        ED->pBuffer = aBuffer;
+
+        // convert the pointer into OsclAny ptr
+        OsclAny* P = (OsclAny*) ED;
+
+        // CALL the generic callback AO API:
+        Node->iThreadSafeHandlerFillBufferDone->ReceiveEvent(P);
+
+        return OMX_ErrorNone;
+    }
+    else
+    {
+        OMX_ERRORTYPE status;
+        status = Node->FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
+        return status;
+    }
+
+}
+
+// Callback processing in multithreaded case - dequeued event - call EventHandlerProcessing
+OsclReturnCode PVMFOMXEncNode::ProcessCallbackEventHandler_MultiThreaded(OsclAny* P)
+{
+
+    // re-cast the pointer
+
+    EventHandlerSpecificData* ED = (EventHandlerSpecificData*) P;
+
+    OMX_HANDLETYPE aComponent = ED->hComponent;
+    OMX_PTR aAppData = ED->pAppData;
+    OMX_EVENTTYPE aEvent = ED->eEvent;
+    OMX_U32 aData1 = ED->nData1;
+    OMX_U32 aData2 = ED->nData2;
+    OMX_PTR aEventData = ED->pEventData;
+
+
+    EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
+
+
+    // release the allocated memory when no longer needed
+
+    iThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);
+    ED = NULL;
+
+    return OsclSuccess;
+}
+
+
+
+// Callback processing in multithreaded case - dequeued event - call EmptyBufferDoneProcessing
+OsclReturnCode PVMFOMXEncNode::ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P)
+{
+
+
+    // re-cast the pointer
+    EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) P;
+
+    OMX_HANDLETYPE aComponent = ED->hComponent;
+    OMX_PTR aAppData = ED->pAppData;
+    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
+
+    EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
+
+    // release the allocated memory when no longer needed
+
+    iThreadSafeHandlerEmptyBufferDone->iMemoryPool->deallocate(ED);
+    ED = NULL;
+
+    return OsclSuccess;
+}
+
+
+// Callback processing in multithreaded case - dequeued event - call FillBufferDoneProcessing
+OsclReturnCode PVMFOMXEncNode::ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P)
+{
+
+    // re-cast the pointer
+    FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) P;
+
+    OMX_HANDLETYPE aComponent = ED->hComponent;
+    OMX_PTR aAppData = ED->pAppData;
+    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
+
+
+    FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
+
+
+    // release the allocated memory when no longer needed
+
+    iThreadSafeHandlerFillBufferDone->iMemoryPool->deallocate(ED);
+    ED = NULL;
+
+    return OsclSuccess;
+}
+/////////////////////////////////////////////////////////////////////////////
+// Class Destructor
+/////////////////////////////////////////////////////////////////////////////
+PVMFOMXEncNode::~PVMFOMXEncNode()
+{
+    LogDiagnostics();
+
+    //Clearup encoder
+    DeleteOMXEncoder();
+
+    // Cleanup callback AOs and Mempools
+    if (iThreadSafeHandlerEventHandler)
+    {
+        OSCL_DELETE(iThreadSafeHandlerEventHandler);
+        iThreadSafeHandlerEventHandler = NULL;
+    }
+    if (iThreadSafeHandlerEmptyBufferDone)
+    {
+        OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
+        iThreadSafeHandlerEmptyBufferDone = NULL;
+    }
+    if (iThreadSafeHandlerFillBufferDone)
+    {
+        OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
+        iThreadSafeHandlerFillBufferDone = NULL;
+    }
+
+    if (iMediaDataMemPool)
+    {
+        iMediaDataMemPool->removeRef();
+        iMediaDataMemPool = NULL;
+    }
+
+    if (iOutBufMemoryPool)
+    {
+        iOutBufMemoryPool->removeRef();
+        iOutBufMemoryPool = NULL;
+    }
+    if (iInBufMemoryPool)
+    {
+        iInBufMemoryPool->removeRef();
+        iInBufMemoryPool = NULL;
+    }
+
+    //Thread logoff
+    if (IsAdded())
+    {
+        RemoveFromScheduler();
+        iIsAdded = false;
+    }
+
+    //Cleanup allocated interfaces
+
+    //Cleanup allocated ports
+    ReleaseAllPorts();
+
+    //Cleanup commands
+    //The command queues are self-deleting, but we want to
+    //notify the observer of unprocessed commands.
+    while (!iCurrentCommand.empty())
+    {
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
+    }
+    while (!iInputCommands.empty())
+    {
+        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
+    }
+
+    //Release Input buffer
+    iDataIn.Unbind();
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Add AO to the scheduler
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::ThreadLogon()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFOMXEncNode:ThreadLogon"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+            if (!IsAdded())
+            {
+                AddToScheduler();
+                iIsAdded = true;
+            }
+
+            SetState(EPVMFNodeIdle);
+            return PVMFSuccess;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+        default:
+            return PVMFErrInvalidState;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Remove AO from the scheduler
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::ThreadLogoff()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFOMXEncNode-%s::ThreadLogoff", iNodeTypeId));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            if (IsAdded())
+            {
+                RemoveFromScheduler();
+                iIsAdded = false;
+            }
+            iLogger = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+
+        default:
+            return PVMFErrInvalidState;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetCapability() called", iNodeTypeId));
+
+    aNodeCapability = iCapability;
+    return PVMFSuccess;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFPortIter* PVMFOMXEncNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetPorts() %s called", iNodeTypeId));
+
+    OSCL_UNUSED_ARG(aFilter);
+
+    return NULL;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::QueueCommandL(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iInputCommands.AddL(aCmd);
+
+    if (iInputCommands.size() == 1)
+    {
+        //wakeup the AO all the rest of input commands will reschedule the AO in Run
+        RunIfNotReady();
+    }
+    return id;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+                                        Oscl_Vector<PVUuid, PVMFOMXEncNodeAllocator>& aUuids,
+                                        bool aExactUuidsOnly,
+                                        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::QueryUUID() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::QueryInterface() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::RequestPort() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+
+// DUSAN V.: IMPORTANT NOTE - ENGINE IS SENDING THE MIME TYPE FOR THE ENCODER INPUT/OUTPUT FORMAT THRU THE PORT PARAMETER
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag, aPortConfig, aContext);
+    return QueueCommandL(cmd);
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ReleasePort() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Init() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Prepare() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Start() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Stop() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Flush() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_FLUSH, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Pause() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_PAUSE, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Reset() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::CancelAllCommands() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_CANCELALL, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::CancelCommand() called", iNodeTypeId));
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommandBase::Construct(s, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_CANCELCMD, aCmdId, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+
+
+
+/////////////////////
+// Private Section //
+/////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Class Constructor
+/////////////////////////////////////////////////////////////////////////////
+PVMFOMXEncNode::PVMFOMXEncNode(int32 aPriority) :
+        OsclActiveObject(aPriority, "PVMFOMXEncNode"),
+        iInPort(NULL),
+        iOutPort(NULL),
+        iOutBufMemoryPool(NULL),
+        iMediaDataMemPool(NULL),
+        iOMXComponentOutputBufferSize(0),
+        iOutputAllocSize(0),
+        iProcessingState(EPVMFOMXEncNodeProcessingState_Idle),
+        iOMXEncoder(NULL),
+        iSendBOS(false),
+        iStreamID(0),
+        iBOSTimestamp(0),
+        iSeqNum(0),
+        iSeqNum_In(0),
+        iIsAdded(true),
+        iLogger(NULL),
+        iDataPathLogger(NULL),
+        iClockLogger(NULL),
+        iExtensionRefCount(0),
+        iEndOfDataReached(false),
+        iEndOfDataTimestamp(0),
+        iDiagnosticsLogger(NULL),
+        iDiagnosticsLogged(false),
+        iAvgBitrateValue(0),
+        iResetInProgress(false),
+        iResetMsgSent(false),
+        iStopInResetMsgSent(false)
+{
+    iInterfaceState = EPVMFNodeCreated;
+
+
+    // Allocate memory for VOL header
+    uint refCounterSize = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+    uint VolHdrSize = refCounterSize + DEFAULT_VOL_HEADER_LENGTH;
+    uint8 *memBufferVOLHeader = NULL;
+
+    uint ParamSetSize = refCounterSize + DEFAULT_PARAMS_SET_LENGTH;
+    uint8 *memBufferParamSet = NULL;
+
+
+    int32 err;
+    OSCL_TRY(err,
+
+             //Create the input command queue.  Use a reserve to avoid lots of
+             //dynamic memory allocation.
+             iInputCommands.Construct(PVMF_OMXENC_NODE_COMMAND_ID_START, PVMF_OMXENC_NODE_COMMAND_VECTOR_RESERVE);
+
+             //Create the "current command" queue.  It will only contain one
+             //command at a time, so use a reserve of 1.
+             iCurrentCommand.Construct(0, 1);
+
+             //Set the node capability data.
+             //This node can support an unlimited number of ports.
+             iCapability.iCanSupportMultipleInputPorts = false;
+             iCapability.iCanSupportMultipleOutputPorts = false;
+             iCapability.iHasMaxNumberOfPorts = true;
+             iCapability.iMaxNumberOfPorts = 2;
+
+             // video output
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_MP4);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_RAW);
+             //iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H264_VIDEO);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_M4V);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2631998);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2632000);
+             //iCapability.iOutputFormatCapability.push_back(PVMF_MIME_WMV);
+             // audio output
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_AMR_IETF);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_AMR_IF2);
+
+             // video input
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_YUV420);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_YUV422);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_RGB24);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_RGB12);
+
+             // audio input
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_PCM16);
+
+
+
+             iAvailableMetadataKeys.reserve(PVMF_OMXENC_NUM_METADATA_VALUES);
+             iAvailableMetadataKeys.clear();
+
+             // for VOL header
+             memBufferVOLHeader = (uint8*)iAlloc.allocate(VolHdrSize);
+             if (!memBufferVOLHeader)
+{
+    OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    memBufferParamSet = (uint8*) iAlloc.allocate(ParamSetSize);
+    if (!memBufferParamSet)
+{
+    OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+            );
+
+    // Save default VOL header
+    oscl_memset(memBufferVOLHeader, 0, DEFAULT_VOL_HEADER_LENGTH);
+    OsclMemoryFragment volHeader;
+    OsclRefCounter* refCounterVOLHeader = new(memBufferVOLHeader) OsclRefCounterDA(memBufferVOLHeader,
+            (OsclDestructDealloc*)&iAlloc);
+    memBufferVOLHeader += refCounterSize;
+    volHeader.ptr = memBufferVOLHeader;
+    oscl_memcpy(volHeader.ptr, (OsclAny*)DEFAULT_VOL_HEADER, DEFAULT_VOL_HEADER_LENGTH);
+    volHeader.len = DEFAULT_VOL_HEADER_LENGTH;
+    iVolHeader = OsclRefCounterMemFrag(volHeader, refCounterVOLHeader, DEFAULT_VOL_HEADER_LENGTH);
+
+
+    // construct SPS&PPS placeholder
+    oscl_memset(memBufferParamSet, 0, DEFAULT_PARAMS_SET_LENGTH);
+    OsclMemoryFragment paramSet;
+    OsclRefCounter* refCounterParamSet = new(memBufferParamSet) OsclRefCounterDA(memBufferParamSet,
+            (OsclDestructDealloc*)&iAlloc);
+    memBufferParamSet += refCounterSize;
+    paramSet.ptr = memBufferParamSet;
+    paramSet.len = DEFAULT_PARAMS_SET_LENGTH;
+
+    iParamSet = OsclRefCounterMemFrag(paramSet, refCounterParamSet, DEFAULT_PARAMS_SET_LENGTH);
+
+    // initialize length and number of sps/ppss
+    iParamSet.getMemFrag().len = 0;
+    iNumPPSs = 0;
+    iNumSPSs = 0;
+    iSpsPpsSequenceOver = false;
+    iFirstNAL = false; //set this to false so that mp4 can proceed without a problem.
+    // in case of AVC, this flag will be set after spspps
+
+    iThreadSafeHandlerEventHandler = NULL;
+    iThreadSafeHandlerEmptyBufferDone = NULL;
+    iThreadSafeHandlerFillBufferDone = NULL;
+
+    iInBufMemoryPool = NULL;
+    iOutBufMemoryPool = NULL;
+
+    // init to some value
+    iOMXComponentOutputBufferSize = 0;
+    iNumOutputBuffers = 0;
+    iOMXComponentInputBufferSize = 0;
+    iNumInputBuffers = 0;
+
+    iDoNotSendOutputBuffersDownstreamFlag = false;
+    iDoNotSaveInputBuffersFlag = false;
+
+
+    iOutputBuffersFreed = true;// buffers have not been created yet, so they can be considered freed
+    iInputBuffersFreed = true;
+
+    // dynamic port reconfig init vars
+    iSecondPortReportedChange = false;
+    iDynamicReconfigInProgress = false;
+
+    // EOS flag init
+    iIsEOSSentToComponent = false;
+    iIsEOSReceivedFromComponent = false;
+
+    // init state of component
+    iCurrentEncoderState = OMX_StateInvalid;
+
+    iTimeStampOut = 0;
+    iTimeStampPrevious = 0;
+    iBufferLenOut = 0;
+    iBufferLenPrevious = 0;
+    iEndOfFrameFlagPrevious = 0;
+    iKeyFrameFlagPrevious = 0;
+    iEndOfNALFlagPrevious = 0;
+
+
+    iEndOfFrameFlagOut = 0;
+    iKeyFrameFlagOut = 0;
+    iEndOfNALFlagOut = 0;
+
+    // counts output frames (for logging)
+    iFrameCounter = 0;
+    iInFormat = PVMF_MIME_FORMAT_UNKNOWN;
+    iOutFormat = PVMF_MIME_FORMAT_UNKNOWN;
+
+    // zero out encoder param structure
+
+    oscl_memset(&iVideoInputFormat, 0, sizeof(iVideoInputFormat));
+
+    // set default values
+    iVideoInputFormat.iVideoFormat = EI_YUV420;
+    iVideoInputFormat.iFrameWidth = DEFAULT_FRAME_WIDTH;
+    iVideoInputFormat.iFrameHeight = DEFAULT_FRAME_HEIGHT;
+    iVideoInputFormat.iFrameRate = (float)DEFAULT_FRAME_RATE;
+    iVideoInputFormat.iFrameOrientation = 0;
+
+    oscl_memset(&iVideoEncodeParam, 0, sizeof(iVideoEncodeParam));
+
+    iVideoEncodeParam.iEncodeID = 0;
+    iVideoEncodeParam.iNumLayer = 1;
+    iVideoEncodeParam.iFrameWidth[0] = DEFAULT_FRAME_WIDTH;
+    iVideoEncodeParam.iFrameHeight[0] = DEFAULT_FRAME_HEIGHT;
+    iVideoEncodeParam.iBitRate[0] = DEFAULT_BITRATE;
+    iVideoEncodeParam.iFrameRate[0] = (float)DEFAULT_FRAME_RATE;
+    iVideoEncodeParam.iFrameQuality = 10;
+    iVideoEncodeParam.iSceneDetection = false;
+    iVideoEncodeParam.iRVLCEnable = false;
+    iVideoEncodeParam.iIFrameInterval = DEFAULT_FRAME_RATE * 10;
+    iVideoEncodeParam.iBufferDelay = (float)0.2;
+    iVideoEncodeParam.iContentType = EI_H263;
+    iVideoEncodeParam.iRateControlType = ECBR_1;
+    iVideoEncodeParam.iIquant[0] = 15;
+    iVideoEncodeParam.iPquant[0] = 12;
+    iVideoEncodeParam.iBquant[0] = 12;
+    iVideoEncodeParam.iSearchRange = 16;
+    iVideoEncodeParam.iMV8x8 = false;
+    iVideoEncodeParam.iMVHalfPel = true;
+    iVideoEncodeParam.iPacketSize = 256;
+    iVideoEncodeParam.iNoCurrentSkip = false;
+    iVideoEncodeParam.iNoFrameSkip = false;
+    iVideoEncodeParam.iClipDuration = 0;
+    iVideoEncodeParam.iProfileLevel = EI_CORE_LEVEL2;
+    /////////////////AVC SPECIFIC///////////////////////////
+    iVideoEncodeParam.iEncMode = EI_ENCMODE_RECORDER;
+    iVideoEncodeParam.iAVCProfile = EI_PROFILE_BASELINE;
+    iVideoEncodeParam.iAVCLevel = EI_LEVEL_11;
+
+
+    oscl_memset(&iAudioInputFormat, 0, sizeof(iAudioInputFormat));
+    // Currently, set according to AMR values
+    iAudioInputFormat.iInputInterleaveMode = EINTERLEAVE_LR;
+    iAudioInputFormat.iInputBitsPerSample = 16;
+    iAudioInputFormat.iInputNumChannels = 1;
+    iAudioInputFormat.iInputSamplingRate = 8000;
+
+    oscl_memset(&iAudioEncodeParam, 0, sizeof(iAudioEncodeParam));
+
+    iAudioEncodeParam.iMaxNumOutputFramesPerBuffer = MAX_NUM_AMR_FRAMES_PER_BUFFER;
+    iAudioEncodeParam.iOutputBitrate = GSM_AMR_12_2;
+    iAudioEncodeParam.iOutputNumChannels = iAudioInputFormat.iInputNumChannels;
+    iAudioEncodeParam.iOutputSamplingRate = iAudioInputFormat.iInputSamplingRate;
+
+
+#ifdef _TEST_AE_ERROR_HANDLING
+    iErrorHandlingInit = false;
+    iErrorHandlingEncodeCount = 0;
+    iCountFrames = 0;
+    iErrorDataPathStall = 0;
+    iErrorNodeCmd = 0;
+    iErrorConfigHeader = false;
+    iErrorEncodeFlag = 0;
+#endif
+
+    sendYuvFsi = true;
+
+    iNodeTypeId = LOG_ID_UNKNOWN;
+#if 1
+    iLogger = PVLogger::GetLoggerObject("PVMFOMXEncNode");
+    iRunlLogger = PVLogger::GetLoggerObject("Run.PVMFOMXEncNode");
+    iDataPathLogger = PVLogger::GetLoggerObject("datapath");
+    iClockLogger = PVLogger::GetLoggerObject("clock");
+    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.encnode.OMXEncnode");
+#endif
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Local Run Routine
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Run() In", iNodeTypeId));
+
+    // if reset is in progress, call DoReset again until Reset Msg is sent
+    if ((iResetInProgress == true) &&
+            (iResetMsgSent == false) &&
+            (iCurrentCommand.size() > 0) &&
+            (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+       )
+    {
+        DoReset(iCurrentCommand.front());
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - Calling DoReset", iNodeTypeId));
+        return; // don't do anything else
+    }
+    //Check for NODE commands...
+    if (!iInputCommands.empty())
+    {
+        if (ProcessCommand(iInputCommands.front()))
+        {
+            if (iInterfaceState != EPVMFNodeCreated
+                    && (!iInputCommands.empty() || (iInPort && (iInPort->IncomingMsgQueueSize() > 0)) ||
+                        (iDataIn.GetRep() != NULL)))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - rescheduling after process command", iNodeTypeId));
+                RunIfNotReady();
+            }
+            return;
+        }
+
+        if (!iInputCommands.empty())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - rescheduling to process more commands", iNodeTypeId));
+            RunIfNotReady();
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - Input commands empty", iNodeTypeId));
+    }
+
+    if (((iCurrentCommand.size() == 0) && (iInterfaceState != EPVMFNodeStarted)) ||
+            ((iCurrentCommand.size() > 0) && (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_START) && (iInterfaceState != EPVMFNodeStarted)))
+    {
+        // rescheduling because of input data will be handled in Command Processing Part
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - Node not in Started state yet", iNodeTypeId));
+        return;
+    }
+
+
+    // Process port activity, push out all outgoing messages
+    if (iOutPort)
+    {
+        while (iOutPort->OutgoingMsgQueueSize())
+        {
+            // if port is busy it is going to wakeup from port ready event
+            if (!ProcessOutgoingMsg(iOutPort))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - Outgoing Port Busy, cannot send more msgs", iNodeTypeId));
+                break;
+            }
+        }
+    }
+    int loopCount = 0;
+#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
+    uint32 startticks = OsclTickCount::TickCount();
+    uint32 starttime = OsclTickCount::TicksToMsec(startticks);
+#endif
+    do // Try to consume all the data from the Input port
+    {
+        // Process port activity if there is no input data that is being processed
+        // Do not accept any input if EOS needs to be sent out
+        if (iInPort && (iInPort->IncomingMsgQueueSize() > 0) && (iDataIn.GetRep() == NULL) && !iEndOfDataReached)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - Getting more input", iNodeTypeId));
+            if (!ProcessIncomingMsg(iInPort))
+            {
+                //Re-schedule to come back.
+                RunIfNotReady();
+                return;
+            }
+        }
+
+        if (iSendBOS)
+        {
+            SendBeginOfMediaStreamCommand();
+        }
+
+        // If in init or ready to encode state, process data in the input port if there is input available and input buffers are present
+        // (note: at EOS, iDataIn will not be available)
+        if ((iDataIn.GetRep() != NULL) ||
+                ((iNumOutstandingOutputBuffers < iNumOutputBuffers) &&
+                 (iProcessingState == EPVMFOMXEncNodeProcessingState_ReadyToEncode) &&
+                 (iResetMsgSent == false)) ||
+                ((iDynamicReconfigInProgress == true) && (iResetMsgSent == false))
+           )
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::Run() - Calling HandleProcessingState", iNodeTypeId));
+
+            // input data is available, that means there is data to be encoded
+            if (HandleProcessingState() != PVMFSuccess)
+            {
+                // If HandleProcessingState does not return Success, we must wait for an event
+                // no point in  rescheduling
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "PVMFOMXEncNode-%s::Run() - HandleProcessingState did not return Success", iNodeTypeId));
+                return;
+            }
+        }
+        loopCount++;
+    }
+    while (iInPort &&
+            (((iInPort->IncomingMsgQueueSize() > 0) || (iDataIn.GetRep() != NULL)) && (iNumOutstandingInputBuffers < iNumInputBuffers))
+            && (!iEndOfDataReached)
+            && (iResetMsgSent == false)
+          );
+#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
+    uint32 endticks = OsclTickCount::TickCount();
+    uint32 endtime = OsclTickCount::TicksToMsec(endticks);
+    uint32 timeinloop;
+    timeinloop  = (endtime - starttime);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iRunlLogger, PVLOGMSG_INFO,
+                    (0, "PVMFOMXEncNode-%s::Run() - LoopCount = %d, Time spent in loop(in ms) = %d, iNumOutstandingInputBuffers = %d, iNumOutstandingOutputBuffers = %d ", iNodeTypeId,
+                     loopCount, timeinloop, iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
+#endif
+    // EOS processing:
+    // first send an empty buffer to OMX component and mark the EOS flag
+    // wait for the OMX component to send async event to indicate that it has reached this EOS buffer
+    // then, create and send the EOS message downstream
+
+    if (iEndOfDataReached && !iDynamicReconfigInProgress)
+    {
+
+        // if EOS was not sent yet and we have an available input buffer, send EOS buffer to component
+        if (!iIsEOSSentToComponent && (iNumOutstandingInputBuffers < iNumInputBuffers))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::Run() - Sending EOS marked buffer To Component ", iNodeTypeId));
+
+            iIsEOSSentToComponent = true;
+
+
+            // if the component is not yet initialized or if it's in the middle of port reconfig,
+            // don't send EOS buffer to component. It does not care. Just set the flag as if we received
+            // EOS from the component to enable sending EOS downstream
+            if (iProcessingState != EPVMFOMXEncNodeProcessingState_ReadyToEncode)
+            {
+
+                iIsEOSReceivedFromComponent = true;
+            }
+            else if (!SendEOSBufferToOMXComponent())
+            {
+                // for some reason, Component can't receive the EOS buffer
+                // it could be that it is not initialized yet (because EOS could be the first msg). In this case,
+                // send the EOS downstream anyway
+                iIsEOSReceivedFromComponent = true;
+            }
+        }
+
+        // DV: we must wait for event (acknowledgment from component)
+        // before sending EOS downstream. This is because OMX Component will send
+        // the EOS event only after processing remaining buffers
+
+        if (iIsEOSReceivedFromComponent)
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::Run() - Received EOS from component, Sending EOS msg downstream ", iNodeTypeId));
+
+            if (iOutPort && iOutPort->IsOutgoingQueueBusy())
+            {
+                // note: we already tried to empty the outgoing q. If it's still busy,
+                // it means that output port is busy. Just return and wait for the port to become free.
+                // this will wake up the node and it will send out a msg from the q etc.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "PVMFOMXEncNode-%s::Run() - - EOS cannot be sent downstream, outgoing queue busy - wait", iNodeTypeId));
+                return;
+            }
+
+            if (SendEndOfTrackCommand()) // this will only q the EOS
+            {
+                // EOS send downstream OK, so reset the flag
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "PVMFOMXEncNode-%s::Run() - EOS was queued to be sent downstream", iNodeTypeId));
+
+                iEndOfDataReached = false; // to resume normal processing, reset the flags
+                iIsEOSSentToComponent = false;
+                iIsEOSReceivedFromComponent = false;
+
+                RunIfNotReady(); // Run again to send out the EOS msg from the outgoing q, and resume
+                // normal processing
+
+                // END OF STREAM EVENT reported by the downstream node.
+                //ReportInfoEvent(PVMFInfoEndOfData);
+            }
+        }
+        else
+        {
+            // keep sending output buffers, it's possible that the component needs to flush output
+            //	data at the end
+            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
+            {
+                if (!SendOutputBufferToOMXComponent())
+                    break;
+            }
+        }
+
+    }
+
+
+    //Check for flash command complition...
+    if (iInPort && iOutPort && (iCurrentCommand.size() > 0) &&
+            (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_FLUSH) &&
+            (iInPort->IncomingMsgQueueSize() == 0) &&
+            (iOutPort->OutgoingMsgQueueSize() == 0) &&
+            (iDataIn.GetRep() == NULL) &&
+            (iNumOutstandingOutputBuffers == iNumOutputBuffers) && // all output buffers are with the component or outstanding
+            (iNumOutstandingInputBuffers == 0) // all input buffers were processed and returned. These 2 conditions mean the component is idle
+       )
+    {
+        //flush command is almost completed
+        //Debug check-- all the port queues should be empty at this point.
+        OMX_ERRORTYPE err = OMX_ErrorNone;
+        OMX_STATETYPE sState = OMX_StateInvalid;
+
+        OSCL_ASSERT(iInPort->IncomingMsgQueueSize() == 0 && iOutPort->OutgoingMsgQueueSize() == 0);
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::Run() - Flush pending", iNodeTypeId));
+
+        // now, drive the state of the omx component to IDLE - wait for the callback from the component and send cmd complete from there
+        iDataIn.Unbind();
+        iPreviousMediaData.Unbind(); // make sure nothing is holding this data
+        if ((iOutFormat == PVMF_MIME_H264_VIDEO_MP4) || (iOutFormat == PVMF_MIME_H264_VIDEO_RAW))
+        {
+            // prepare for next start
+            iFirstNAL = true;
+        }
+
+        // Clear the data flags
+
+        iEndOfDataReached = false;
+        iIsEOSSentToComponent = false;
+        iIsEOSReceivedFromComponent = false;
+
+
+        iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
+        iDoNotSaveInputBuffersFlag = true;
+
+
+        //Get state of OpenMAX encoder
+        err = OMX_GetState(iOMXEncoder, &sState);
+        if (err != OMX_ErrorNone)
+        {
+            //Error condition report
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::Run(): Flush pending - Can't get State of encoder!", iNodeTypeId));
+
+            sState = OMX_StateInvalid;
+        }
+
+        if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
+        {
+            /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::Run(): Flush pending:  Changing Component State Executing->Idle or Pause->Idle", iNodeTypeId));
+
+            err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::Run(): Flush pending : Can't send StateSet command to encoder!", iNodeTypeId));
+
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrInvalidState);
+                return;
+            }
+
+            // prevent the node from sending more buffers etc.
+            // if port reconfiguration is in process, let the state remain one of the port config states
+            //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
+            if (iProcessingState == EPVMFOMXEncNodeProcessingState_ReadyToEncode)
+                iProcessingState = EPVMFOMXEncNodeProcessingState_Stopping;
+
+        }
+        else
+        {
+            //Error condition report
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::Run(): Flush pending : Encoder is not in the Executing or Pause state!", iNodeTypeId));
+
+            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrInvalidState);
+            return;
+        }
+
+
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::Run() Out", iNodeTypeId));
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will dispatch recived commands
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::ProcessCommand(PVMFOMXEncNodeCommand& aCmd)
+{
+    //normally this node will not start processing one command
+    //until the prior one is finished.  However, a hi priority
+    //command such as Cancel must be able to interrupt a command
+    //in progress.
+    if (!iCurrentCommand.empty() && !aCmd.hipri())
+        return false;
+
+    switch (aCmd.iCmd)
+    {
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_QUERYUUID:
+            DoQueryUuid(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_INIT:
+            DoInit(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_PREPARE:
+            DoPrepare(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_START:
+            DoStart(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_STOP:
+            DoStop(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_FLUSH:
+            DoFlush(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_PAUSE:
+            DoPause(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET:
+            DoReset(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_CANCELCMD:
+            DoCancelCommand(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_CANCELALL:
+            DoCancelAllCommands(aCmd);
+            break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_GETNODEMETADATAKEY:
+        {
+            PVMFStatus retval = DoGetNodeMetadataKey(aCmd);
+            CommandComplete(iInputCommands, aCmd, retval);
+        }
+        break;
+
+        case PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_GETNODEMETADATAVALUE:
+        {
+            PVMFStatus retval = DoGetNodeMetadataValue(aCmd);
+            CommandComplete(iInputCommands, aCmd, retval);
+        }
+        break;
+
+        default://unknown command type
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            break;
+    }
+
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will process incomming message from the port
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
+{
+    //Called by the AO to process one buffer off the port's
+    //incoming data queue.  This routine will dequeue and
+    //dispatch the data.
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFOMXEncNode-%s::ProcessIncomingMsg: aPort=0x%x", this, iNodeTypeId, aPort));
+
+    PVMFStatus status = PVMFFailure;
+
+
+//#define SIMULATE_BOS
+#ifdef SIMULATE_BOS
+
+    if (((PVMFOMXEncPort*)aPort)->iNumFramesConsumed == 6))
+    {
+
+        PVMFSharedMediaCmdPtr BOSCmdPtr = PVMFMediaCmd::createMediaCmd();
+
+        // Set the format ID to BOS
+        BOSCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
+
+        // Set the timestamp
+        BOSCmdPtr->setTimestamp(201);
+        BOSCmdPtr->setStreamID(0);
+
+        // Convert to media message and send it out
+        PVMFSharedMediaMsgPtr mediaMsgOut;
+        convertToPVMFMediaCmdMsg(mediaMsgOut, BOSCmdPtr);
+
+        //store the stream id and time stamp of bos message
+        iStreamID = mediaMsgOut->getStreamID();
+        iBOSTimestamp = mediaMsgOut->getTimestamp();
+        iSendBOS = true;
+
+#ifdef _DEBUG
+        printf("PVMFOMXEncNode-%s::ProcessIncomingMsg() SIMULATED BOS\n", iNodeTypeId);
+#endif
+        ((PVMFOMXEncPort*)aPort)->iNumFramesConsumed++;
+        return true;
+
+    }
+#endif
+//#define SIMULATE_PREMATURE_EOS
+#ifdef SIMULATE_PREMATURE_EOS
+    if (((PVMFOMXEncPort*)aPort)->iNumFramesConsumed == 5)
+    {
+        PVMFSharedMediaCmdPtr EOSCmdPtr = PVMFMediaCmd::createMediaCmd();
+
+        // Set the format ID to EOS
+        EOSCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
+
+        // Set the timestamp
+        EOSCmdPtr->setTimestamp(200);
+
+        // Convert to media message and send it out
+        PVMFSharedMediaMsgPtr mediaMsgOut;
+        convertToPVMFMediaCmdMsg(mediaMsgOut, EOSCmdPtr);
+
+        ((PVMFOMXEncPort*)aPort)->iNumFramesConsumed++;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::ProcessIncomingMsg: SIMULATED EOS", iNodeTypeId));
+#ifdef _DEBUG
+        printf("PVMFOMXEncNode-%s::ProcessIncomingMsg() SIMULATED EOS\n", iNodeTypeId);
+#endif
+        // Set EOS flag
+        iEndOfDataReached = true;
+        // Save the timestamp for the EOS cmd
+        iEndOfDataTimestamp = mediaMsgOut->getTimestamp();
+
+        return true;
+    }
+
+#endif
+
+
+
+    PVMFSharedMediaMsgPtr msg;
+
+    status = aPort->DequeueIncomingMsg(msg);
+    if (status != PVMFSuccess)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "0x%x PVMFOMXEncNode-%s::ProcessIncomingMsg: Error - DequeueIncomingMsg failed", this, iNodeTypeId));
+        return false;
+    }
+
+    if (msg->getFormatID() == PVMF_MEDIA_CMD_BOS_FORMAT_ID)
+    {
+        //store the stream id and time stamp of bos message
+        iStreamID = msg->getStreamID();
+        iBOSTimestamp = msg->getTimestamp();
+        iSendBOS = true;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::ProcessIncomingMsg: Received BOS stream %d, timestamp %d", iNodeTypeId, iStreamID, iBOSTimestamp));
+        ((PVMFOMXEncPort*)aPort)->iNumFramesConsumed++;
+        return true;
+    }
+    else if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+    {
+        // Set EOS flag
+        iEndOfDataReached = true;
+        // Save the timestamp for the EOS cmd
+        iEndOfDataTimestamp = msg->getTimestamp();
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::ProcessIncomingMsg: Received EOS", iNodeTypeId));
+
+        ((PVMFOMXEncPort*)aPort)->iNumFramesConsumed++;
+        return true; // do not do conversion into media data, just set the flag and leave
+    }
+
+    convertToPVMFMediaData(iDataIn, msg);
+
+
+    iCurrFragNum = 0; // for new message, reset the fragment counter
+
+
+    ((PVMFOMXEncPort*)aPort)->iNumFramesConsumed++;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ProcessIncomingMsg() Received %d frames", iNodeTypeId, ((PVMFOMXEncPort*)aPort)->iNumFramesConsumed));
+
+    //return true if we processed an activity...
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will process outgoing message by sending it into output the port
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::ProcessOutgoingMsg(PVMFPortInterface* aPort)
+{
+    //Called by the AO to process one message off the outgoing
+    //message queue for the given port.  This routine will
+    //try to send the data to the connected port.
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFOMXEncNode-%s::ProcessOutgoingMsg: aPort=0x%x", this, iNodeTypeId, aPort));
+
+    PVMFStatus status = aPort->Send();
+    if (status == PVMFErrBusy)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "0x%x PVMFOMXEncNode-%s::ProcessOutgoingMsg: Connected port goes into busy state", this, iNodeTypeId));
+    }
+
+    //Report any unexpected failure in port processing...
+    //(the InvalidState error happens when port input is suspended,
+    //so don't report it.)
+    if (status != PVMFErrBusy
+            && status != PVMFSuccess
+            && status != PVMFErrInvalidState)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFOMXEncNode-%s::ProcessOutgoingMsg: Error - ProcessPortActivity failed. port=0x%x, type=%d",
+                         this, iNodeTypeId, iOutPort, PVMF_PORT_ACTIVITY_OUTGOING_MSG));
+        ReportErrorEvent(PVMFErrPortProcessing);
+    }
+
+    //return true if we processed an activity...
+    return (status != PVMFErrBusy);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// This routine will process received data usign State Machine
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::HandleProcessingState()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::HandleProcessingState() In", iNodeTypeId));
+
+    PVMFStatus status = PVMFSuccess;
+
+    switch (iProcessingState)
+    {
+
+            // The FOLLOWING 4 states handle Dynamic Port Reconfiguration
+        case EPVMFOMXEncNodeProcessingState_PortReconfig:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Sending Port Disable Command", iNodeTypeId));
+
+            // port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
+            OMX_SendCommand(iOMXEncoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
+            // the port will now start returning outstanding buffers
+            // set the flag to prevent output from going downstream (in case of output port being reconfigd)
+            // set the flag to prevent input from being saved and returned to component (in case of input port being reconfigd)
+            // set the state to wait for port saying it is disabled
+            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+            {
+                iDoNotSendOutputBuffersDownstreamFlag = true;
+            }
+            else if (iPortIndexForDynamicReconfig == iInputPortIndex)
+            {
+                iDoNotSaveInputBuffersFlag = true;
+
+            }
+            iProcessingState = EPVMFOMXEncNodeProcessingState_WaitForBufferReturn;
+
+
+            // fall through to the next case to check if all buffers are already back
+        }
+
+        case EPVMFOMXEncNodeProcessingState_WaitForBufferReturn:
+        {
+            // as buffers are coming back, Run may be called, wait until all buffers are back, then Free them all
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn ", iNodeTypeId));
+            // check if it's output port being reconfigured
+            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+            {
+                // if all buffers have returned, free them
+                if (iNumOutstandingOutputBuffers == 0)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> all output buffers are back, free them", iNodeTypeId));
+                    if (false == iOutputBuffersFreed)
+                    {
+                        if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
+                                                      iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                      iNumOutputBuffers, // number of buffers
+                                                      iOutputPortIndex, // port idx
+                                                      false // this is not input
+                                                     ))
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Cannot free output buffers ", iNodeTypeId));
+
+                            SetState(EPVMFNodeError);
+                            ReportErrorEvent(PVMFErrNoMemory);
+                            return PVMFErrNoMemory;
+                        }
+                    }
+                    // if the callback (that port is disabled) has not arrived yet, wait for it
+                    // if it has arrived, it will set the state to PortReEnable
+                    if (iProcessingState != EPVMFOMXEncNodeProcessingState_PortReEnable)
+                        iProcessingState = EPVMFOMXEncNodeProcessingState_WaitForPortDisable;
+
+                    status = PVMFSuccess; // allow rescheduling of the node potentially
+                }
+                else
+                    status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic rescheduling
+                // but each buffer will reschedule the node when it comes in
+            }
+            else
+            {
+                // this is input port
+
+                // if all buffers have returned, free them
+                if (iNumOutstandingInputBuffers == 0)
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> all input buffers are back, free them", iNodeTypeId));
+                    if (false == iInputBuffersFreed)
+                    {
+                        if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
+                                                      iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                      iNumInputBuffers, // number of buffers
+                                                      iInputPortIndex, // port idx
+                                                      true // this is input
+                                                     ))
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Cannot free input buffers ", iNodeTypeId));
+
+                            SetState(EPVMFNodeError);
+                            ReportErrorEvent(PVMFErrNoMemory);
+                            return PVMFErrNoMemory;
+
+                        }
+                    }
+                    // if the callback (that port is disabled) has not arrived yet, wait for it
+                    // if it has arrived, it will set the state to PortReEnable
+                    if (iProcessingState != EPVMFOMXEncNodeProcessingState_PortReEnable)
+                        iProcessingState = EPVMFOMXEncNodeProcessingState_WaitForPortDisable;
+
+                    status = PVMFSuccess; // allow rescheduling of the node
+                }
+                else
+                    status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic
+                // rescheduling. Each buffer will reschedule the node
+                // when it comes in
+            }
+
+
+            // the state will be changed to PortReEnable once we get confirmation that Port was actually disabled
+            break;
+        }
+
+        case EPVMFOMXEncNodeProcessingState_WaitForPortDisable:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> wait for port disable callback", iNodeTypeId));
+            // do nothing. Just wait for the port to become disabled (we'll get event from component, which will
+            // transition the state to PortReEnable
+            status = PVMFErrNoMemory; // prevent Rescheduling the node
+            break;
+        }
+
+        case EPVMFOMXEncNodeProcessingState_PortReEnable:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Sending reenable port command", iNodeTypeId));
+            // set the port index so that we get parameters for the proper port
+            iParamPort.nPortIndex = iPortIndexForDynamicReconfig;
+            // iParamPort.nVersion = OMX_VERSION;
+
+            // get new parameters of the port
+            OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+            // send command for port re-enabling (for this to happen, we must first recreate the buffers)
+            OMX_SendCommand(iOMXEncoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);
+
+            // is this output port?
+            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+            {
+                iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 15) & (~15)) * ((iParamPort.format.video.nFrameHeight + 15) & (~15)) * 3 / 2;
+
+                // check the new buffer size
+                if (iInPort)
+                {
+                    if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO ||
+                            ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+                            ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW ||
+                            ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_M4V ||
+                            ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2631998 ||
+                            ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
+                    {
+                        iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 15) & (~15)) * ((iParamPort.format.video.nFrameHeight + 15) & (~15)) * 3 / 2;
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_WMV)
+                    {
+                        // This is a requirement for the WMV encoder that we have currently
+                        iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 3) & (~3)) * (iParamPort.format.video.nFrameHeight) * 3 / 2;
+                    }
+                    else
+                    {
+                        OSCL_ASSERT(false);
+                    }
+                }
+                // set the new width / height
+                iYUVWidth =  iParamPort.format.video.nFrameWidth;
+                iYUVHeight = iParamPort.format.video.nFrameHeight;
+
+                if (iOMXComponentOutputBufferSize < iParamPort.nBufferSize)
+                    iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
+
+                // do we need to increase the number of buffers?
+                if (iNumOutputBuffers < iParamPort.nBufferCountMin)
+                    iNumOutputBuffers = iParamPort.nBufferCountMin;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::HandleProcessingState() new output buffers %d, size %d", iNodeTypeId, iNumOutputBuffers, iOMXComponentOutputBufferSize));
+
+                /* Allocate output buffers */
+                if (!CreateOutMemPool(iNumOutputBuffers))
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Cannot allocate output buffers ", iNodeTypeId));
+
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return PVMFErrNoMemory;
+                }
+
+                if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
+                                               iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                               iNumOutputBuffers, // number of buffers
+                                               iOMXComponentOutputBufferSize, // actual buffer size
+                                               iOutputPortIndex, // port idx
+                                               iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
+                                               false // this is not input
+                                              ))
+                {
+
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Cannot provide output buffers to component", iNodeTypeId));
+
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return PVMFErrNoMemory;
+
+                }
+
+                // do not drop output any more, i.e. enable output to be sent downstream
+                iDoNotSendOutputBuffersDownstreamFlag = false;
+
+
+            }
+            else
+            {
+                // this is input port
+
+                iOMXComponentInputBufferSize = iParamPort.nBufferSize;
+                // do we need to increase the number of buffers?
+                if (iNumInputBuffers < iParamPort.nBufferCountMin)
+                    iNumInputBuffers = iParamPort.nBufferCountMin;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::HandleProcessingState() new buffers %d, size %d", iNodeTypeId, iNumInputBuffers, iOMXComponentInputBufferSize));
+
+                /* Allocate input buffers */
+                if (!CreateInputMemPool(iNumInputBuffers))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Cannot allocate new input buffers to component", iNodeTypeId));
+
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return PVMFErrNoMemory;
+                }
+
+                if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
+                                               iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                               iNumInputBuffers, // number of buffers
+                                               iOMXComponentInputBufferSize, // actual buffer size
+                                               iInputPortIndex, // port idx
+                                               iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
+                                               true // this is input
+                                              ))
+                {
+
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Cannot provide new input buffers to component", iNodeTypeId));
+
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return PVMFErrNoMemory;
+
+                }
+                // do not drop partially consumed input
+                iDoNotSaveInputBuffersFlag = false;
+
+
+            }
+
+            // if the callback that the port was re-enabled has not arrived yet, wait for it
+            // if it has arrived, it will set the state to either PortReconfig or to ReadyToEncode
+            if (iProcessingState != EPVMFOMXEncNodeProcessingState_PortReconfig &&
+                    iProcessingState != EPVMFOMXEncNodeProcessingState_ReadyToEncode)
+                iProcessingState = EPVMFOMXEncNodeProcessingState_WaitForPortEnable;
+
+            status = PVMFSuccess; // allow rescheduling of the node
+            break;
+        }
+
+        case EPVMFOMXEncNodeProcessingState_WaitForPortEnable:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> wait for port enable callback", iNodeTypeId));
+            // do nothing. Just wait for the port to become enabled (we'll get event from component, which will
+            // transition the state to ReadyToEncode
+            status = PVMFErrNoMemory; // prevent ReScheduling
+            break;
+        }
+
+        // NORMAL DATA FLOW STATE:
+        case EPVMFOMXEncNodeProcessingState_ReadyToEncode:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Ready To Encode start", iNodeTypeId));
+            // In normal data flow and decoding state
+            // Send all available output buffers to the encoder
+
+            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
+            {
+                // grab buffer header from the mempool if possible, and send to component
+                if (!SendOutputBufferToOMXComponent())
+
+                    break;
+
+            }
+
+
+            // next, see if partially consumed input buffer needs to be resent back to OMX component
+            // NOTE: it is not allowed that the component returns more than 1 partially consumed input buffers
+            //		 i.e. if a partially consumed input buffer is returned, it is assumed that the OMX component
+            //		 will be waiting to get data
+
+            if (iInputBufferToResendToComponent != NULL)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "PVMFOMXEncNode-%s::HandleProcessingState() Sending previous - partially consumed input back to the OMX component", iNodeTypeId));
+
+                OMX_EmptyThisBuffer(iOMXEncoder, iInputBufferToResendToComponent);
+                iInputBufferToResendToComponent = NULL; // do this only once
+            }
+            else if ((iNumOutstandingInputBuffers < iNumInputBuffers) && (iDataIn.GetRep() != NULL))
+            {
+                // try to get an input buffer header
+                // and send the input data over to the component
+                SendInputBufferToOMXComponent();
+            }
+
+            status = PVMFSuccess;
+            break;
+
+
+        }
+        case EPVMFOMXEncNodeProcessingState_Stopping:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleProcessingState() Stopping -> wait for Component to move from Executing->Idle", iNodeTypeId));
+
+
+            status = PVMFErrNoMemory; // prevent rescheduling
+            break;
+        }
+
+        case EPVMFOMXEncNodeProcessingState_WaitForOutgoingQueue:
+            status = PVMFErrNoMemory;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::HandleProcessingState() Do nothing since waiting for output port queue to become available", iNodeTypeId));
+            break;
+
+        default:
+            break;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::HandleProcessingState() Out", iNodeTypeId));
+
+    return status;
+
+}
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::SendOutputBufferToOMXComponent()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendOutputBufferToOMXComponent() In", iNodeTypeId));
+
+
+    OutputBufCtrlStruct *output_buf = NULL;
+    int32 errcode = 0;
+
+    // try to get output buffer header
+    OSCL_TRY(errcode, output_buf = (OutputBufCtrlStruct *) iOutBufMemoryPool->allocate(iOutputAllocSize));
+    if (errcode != 0)
+    {
+        if (errcode == OsclErrNoResources)
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                            PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::SendOutputBufferToOMXComponent() No more output buffers in the mempool", iNodeTypeId));
+
+            iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *) iOutBufMemoryPool); // To signal when next deallocate() is called on mempool
+
+            return false;
+        }
+        else
+        {
+            // Memory allocation for the pool failed
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SendOutputBufferToOMXComponent() Output mempool error", iNodeTypeId));
+
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return false;
+        }
+
+    }
+
+    //for every allocated buffer, make sure you notify when buffer is released. Keep track of allocated buffers
+    // use mempool as context to recognize which buffer (input or output) was returned
+    iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *)iOutBufMemoryPool);
+    iNumOutstandingOutputBuffers++;
+
+    output_buf->pBufHdr->nFilledLen = 0; // make sure you tell OMX component buffer is empty
+    output_buf->pBufHdr->nOffset = 0;
+    output_buf->pBufHdr->pAppPrivate = output_buf; // set pAppPrivate to be pointer to output_buf
+    // (this is context for future release of this buffer to the mempool)
+    // this was done during buffer creation, but still repeat just in case
+
+    output_buf->pBufHdr->nFlags = 0; // zero out the flags
+    OMX_FillThisBuffer(iOMXEncoder, output_buf->pBufHdr);
+
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendOutputBufferToOMXComponent() Out", iNodeTypeId));
+
+    return true;
+}
+////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::NegotiateVideoComponentParameters()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::NegotiateVideoParameters() In", iNodeTypeId));
+
+    OMX_ERRORTYPE Err;
+    OMX_CONFIG_ROTATIONTYPE InputRotationType;
+
+    // first get the number of ports and port indices
+    OMX_PORT_PARAM_TYPE VideoPortParameters;
+    uint32 NumPorts;
+    uint32 ii;
+
+    // get starting number
+    CONFIG_SIZE_AND_VERSION(VideoPortParameters);
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoInit, &VideoPortParameters);
+    NumPorts = VideoPortParameters.nPorts; // must be at least 2 of them (in&out)
+
+    if (Err != OMX_ErrorNone || NumPorts < 2)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() There is insuffucient (%d) ports", iNodeTypeId, NumPorts));
+        return false;
+    }
+
+
+    // loop through video ports starting from the starting index to find index of the first input port
+    for (ii = VideoPortParameters.nStartPortNumber ;ii < VideoPortParameters.nStartPortNumber + NumPorts; ii++)
+    {
+        // get port parameters, and determine if it is input or output
+        // if there are more than 2 ports, the first one we encounter that has input direction is picked
+
+
+        CONFIG_SIZE_AND_VERSION(iParamPort);
+        //port
+        iParamPort.nPortIndex = ii; // iInputPortIndex; //OMF_MC_H264D_PORT_INDEX_OF_STREAM;
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+        if (Err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem negotiating with port %d ", iNodeTypeId, ii));
+
+            return false;
+        }
+
+        if (iParamPort.eDir == OMX_DirInput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Found Input port index %d ", iNodeTypeId, ii));
+
+            iInputPortIndex = ii;
+            break;
+        }
+    }
+    if (ii == VideoPortParameters.nStartPortNumber + NumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Cannot find any input port ", iNodeTypeId));
+        return false;
+    }
+
+
+    // loop through video ports starting from the starting index to find index of the first output port
+    for (ii = VideoPortParameters.nStartPortNumber ;ii < VideoPortParameters.nStartPortNumber + NumPorts; ii++)
+    {
+        // get port parameters, and determine if it is input or output
+        // if there are more than 2 ports, the first one we encounter that has output direction is picked
+
+
+        CONFIG_SIZE_AND_VERSION(iParamPort);
+        //port
+        iParamPort.nPortIndex = ii;
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+        if (Err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem negotiating with port %d ", iNodeTypeId, ii));
+
+            return false;
+        }
+
+        if (iParamPort.eDir == OMX_DirOutput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Found Output port index %d ", iNodeTypeId, ii));
+
+            iOutputPortIndex = ii;
+            break;
+        }
+    }
+    if (ii == VideoPortParameters.nStartPortNumber + NumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Cannot find any output port ", iNodeTypeId));
+        return false;
+    }
+
+
+
+    // now get input parameters
+
+
+    //INPUT PORT
+
+    // first check if encode parameters have been set correctly
+    if ((0 == iVideoEncodeParam.iFrameWidth[0]) ||
+            (0 == iVideoEncodeParam.iFrameHeight[0]) ||
+            (0 == iVideoEncodeParam.iFrameRate[0])   ||
+            (0 == iVideoEncodeParam.iBitRate[0]) ||
+            (0 == iVideoInputFormat.iFrameWidth) ||
+            (0 == iVideoInputFormat.iFrameHeight) ||
+            (0 == iVideoInputFormat.iFrameRate)
+       )
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Encode parameters not set correctly", iNodeTypeId));
+        return false;
+    }
+
+    // first of all, check if the port supports the adequate port format
+    OMX_VIDEO_PARAM_PORTFORMATTYPE Video_port_format;
+
+    OMX_COLOR_FORMATTYPE DesiredPortColorFormat = OMX_COLOR_FormatYUV420Planar;
+
+    CONFIG_SIZE_AND_VERSION(Video_port_format);
+
+    Video_port_format.nPortIndex = iInputPortIndex; // set input port as target
+
+    // loop over supported formats until we hit the one we want
+    // or until the component has no more supported formats (in which case it returns OMX_ErrorNoMore
+    Err = OMX_ErrorNone;
+    Video_port_format.nIndex = 0; //init the format counter
+    while (OMX_ErrorNone == Err)
+    {
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoPortFormat, &Video_port_format);
+        if ((OMX_ErrorNone != Err))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem getting port format for input port %d or no desired port format found", iNodeTypeId, iInputPortIndex));
+            return false;
+        }
+
+        if ((Video_port_format.eColorFormat == DesiredPortColorFormat))
+            break;
+
+        Video_port_format.nIndex ++;
+    }
+
+    // OK, we've found the desired format, set it as the one used
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoPortFormat, &Video_port_format);
+    if ((OMX_ErrorNone != Err))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem setting port format for input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+
+
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    iParamPort.nPortIndex = iInputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem negotiating with input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+    if (iInFormat == PVMF_MIME_RGB24)
+    {
+        iOMXComponentInputBufferSize = (iVideoInputFormat.iFrameWidth * iVideoInputFormat.iFrameHeight * 3);
+        iParamPort.format.video.eColorFormat = OMX_COLOR_Format24bitRGB888;
+    }
+    else if (iInFormat == PVMF_MIME_RGB12)
+    {
+        iOMXComponentInputBufferSize = (iVideoInputFormat.iFrameWidth * iVideoInputFormat.iFrameHeight * 2);
+        iParamPort.format.video.eColorFormat = OMX_COLOR_Format12bitRGB444;
+    }
+    else if (iInFormat == PVMF_MIME_YUV420)
+    {
+        iOMXComponentInputBufferSize = (iVideoInputFormat.iFrameWidth * iVideoInputFormat.iFrameHeight * 3) >> 1;
+        iParamPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem with input port %d color format", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+    //Set the input buffer size to the encoder component
+    iParamPort.nBufferSize = iOMXComponentInputBufferSize;
+
+    // set the width and height of video frame and input framerate
+
+    iParamPort.format.video.nFrameWidth = iVideoInputFormat.iFrameWidth;
+    iParamPort.format.video.nFrameHeight = iVideoInputFormat.iFrameHeight;
+    // This is Q16 value, so shift by 16 first and cast to preserve accuracy
+    iParamPort.format.video.xFramerate = (uint32)(iVideoInputFormat.iFrameRate * (1 << 16));
+
+    // indicate that input is uncompressed so that color format is valid
+    iParamPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+
+    // let the component decide about the number of input buffers
+    iNumInputBuffers = iParamPort.nBufferCountActual;
+
+    // do we need to increase the number of buffers?
+    if (iNumInputBuffers < iParamPort.nBufferCountMin)
+        iNumInputBuffers = iParamPort.nBufferCountMin;
+
+
+    // if component allows us to allocate buffers, we'll decide how many to allocate
+    if (iOMXComponentSupportsExternalInputBufferAlloc && (iParamPort.nBufferCountMin < NUMBER_INPUT_BUFFER))
+    {
+        // preset the number of input buffers
+        iNumInputBuffers = NUMBER_INPUT_BUFFER;
+    }
+
+    // set the number of input buffer
+    iParamPort.nBufferCountActual = iNumInputBuffers;
+
+    // set the number of actual input buffers
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Inport buffers %d,size %d", iNodeTypeId, iNumInputBuffers, iOMXComponentInputBufferSize));
+
+    // lock in the input port parameters
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem setting parameters in input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+
+//////////////////// OUTPUT PORT //////////////////////////////////////////////
+    CONFIG_SIZE_AND_VERSION(Video_port_format);
+
+    Video_port_format.nPortIndex = iOutputPortIndex; // set output port as target
+    OMX_VIDEO_CODINGTYPE DesiredPortFormat = OMX_VIDEO_CodingUnused;
+    if (iOutFormat == PVMF_MIME_M4V)
+    {
+        DesiredPortFormat = OMX_VIDEO_CodingMPEG4;
+    }
+    else if (iOutFormat == PVMF_MIME_H2631998 ||
+             iOutFormat == PVMF_MIME_H2632000)
+    {
+        DesiredPortFormat = OMX_VIDEO_CodingH263;
+    }
+    else if (iOutFormat == PVMF_MIME_H264_VIDEO_RAW ||
+             iOutFormat == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        DesiredPortFormat = OMX_VIDEO_CodingAVC;
+    }
+    else
+    {
+        DesiredPortFormat = OMX_VIDEO_CodingUnused;
+    }
+
+    if (DesiredPortFormat == OMX_VIDEO_CodingUnused)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem with output port %d format", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+    // loop over supported formats until we hit the one we want
+    // or until the component has no more supported formats (in which case it returns OMX_ErrorNoMore
+    Err = OMX_ErrorNone;
+    Video_port_format.nIndex = 0; //init the format counter
+    while (OMX_ErrorNone == Err)
+    {
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoPortFormat, &Video_port_format);
+        if ((OMX_ErrorNone != Err))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem getting port format for output port %d or no desired port format found", iNodeTypeId, iOutputPortIndex));
+            return false;
+        }
+
+        if ((Video_port_format.eCompressionFormat == DesiredPortFormat))
+            break;
+
+        Video_port_format.nIndex ++;
+    }
+
+    // OK, we've found the desired format, set it as the one used
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoPortFormat, &Video_port_format);
+    if ((OMX_ErrorNone != Err))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem setting port format for output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+
+
+
+    //Port 1 for output port
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    iParamPort.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem negotiating with output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+    // let the component decide output buffer size
+    iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
+
+    // let the component decide num output buffers
+    iNumOutputBuffers = iParamPort.nBufferCountActual;
+
+
+    //check the number
+    if (iNumOutputBuffers < iParamPort.nBufferCountMin)
+        iNumOutputBuffers = iParamPort.nBufferCountMin;
+
+
+    // set the number ourselves
+    if (iOMXComponentSupportsExternalOutputBufferAlloc && (iParamPort.nBufferCountMin < NUMBER_OUTPUT_BUFFER))
+    {
+        iNumOutputBuffers = NUMBER_OUTPUT_BUFFER;
+    }
+
+    iParamPort.nBufferCountActual = iNumOutputBuffers;
+
+
+    // set the output (target) bitrate, framerate, width/height etc.
+    iParamPort.format.video.nFrameWidth = iVideoEncodeParam.iFrameWidth[0];
+    iParamPort.format.video.nFrameHeight = iVideoEncodeParam.iFrameHeight[0];
+    // Q16 value, cast after the shift to preserve the accuracy.
+    iParamPort.format.video.xFramerate = (uint32)(iVideoEncodeParam.iFrameRate[0] * (1 << 16));
+
+    iParamPort.format.video.nBitrate = iVideoEncodeParam.iBitRate[0];
+    iParamPort.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+
+    if (iOutFormat == PVMF_MIME_M4V)
+    {
+        iParamPort.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4;
+    }
+    else if (iOutFormat == PVMF_MIME_H2631998 ||
+             iOutFormat == PVMF_MIME_H2632000)
+    {
+        iParamPort.format.video.eCompressionFormat = OMX_VIDEO_CodingH263;
+    }
+    else if (iOutFormat == PVMF_MIME_H264_VIDEO_RAW ||
+             iOutFormat == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        iParamPort.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+    }
+    else
+    {
+        iParamPort.format.video.eCompressionFormat = OMX_VIDEO_CodingAutoDetect;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Outport buffers %d,size %d", iNodeTypeId, iNumOutputBuffers, iOMXComponentOutputBufferSize));
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem setting parameters in output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+    InputRotationType.nPortIndex = iInputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexConfigCommonRotate, &InputRotationType);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem getting OMX_IndexConfigCommonRotate param ", iNodeTypeId));
+        return false;
+    }
+
+    //Set the OMX_CONFIG_ROTATIONTYPE parameters
+    InputRotationType.nRotation = ((iVideoInputFormat.iFrameOrientation == 1) ? 180 : 0);
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexConfigCommonRotate, &InputRotationType);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateVideoComponentParameters() Problem setting OMX_IndexConfigCommonRotate param ", iNodeTypeId));
+        return false;
+    }
+
+
+    // now call codec specific parameter setting
+    bool status = true;
+    if (iOutFormat == PVMF_MIME_M4V)
+    {
+        status = SetMP4EncoderParameters();
+    }
+    else if (iOutFormat == PVMF_MIME_H2631998 ||
+             iOutFormat == PVMF_MIME_H2632000)
+    {
+        status = SetH263EncoderParameters();
+    }
+    else if (iOutFormat == PVMF_MIME_H264_VIDEO_RAW ||
+             iOutFormat == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        status = SetH264EncoderParameters();
+    }
+
+    return status;
+}
+bool PVMFOMXEncNode::SetMP4EncoderParameters()
+{
+    OMX_ERRORTYPE Err = OMX_ErrorNone;
+
+    OMX_VIDEO_PARAM_MPEG4TYPE Mpeg4Type;
+    OMX_VIDEO_PARAM_BITRATETYPE BitRateType;
+    OMX_VIDEO_PARAM_QUANTIZATIONTYPE QuantParam;
+    OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE ErrCorrType;
+
+    // DV: VALUES HERE ARE FOR THE MOST PART HARDCODED BASED ON PV DEFAULTS
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE MotionVector;
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE RefreshParam;
+
+
+    CONFIG_SIZE_AND_VERSION(Mpeg4Type);
+    Mpeg4Type.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoMpeg4, &Mpeg4Type);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //Set the OMX_VIDEO_PARAM_MPEG4TYPE parameters
+
+    Mpeg4Type.nPortIndex = iOutputPortIndex;
+    // extra parameters - hardcoded
+    Mpeg4Type.nSliceHeaderSpacing = 0;
+    Mpeg4Type.bSVH = OMX_FALSE; //((iEncoderParam.iContentType == EI_H263)? true: false);
+    Mpeg4Type.bGov = OMX_FALSE; // disable or enable GOV header
+    // extra parameters - hardcoded
+    Mpeg4Type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+
+
+    // params based on iFrame interval
+    if (iVideoEncodeParam.iIFrameInterval == -1) // encode only one frame
+    {
+        Mpeg4Type.nPFrames = 0xFFFFFFFF;
+    }
+    else if (iVideoEncodeParam.iIFrameInterval == 0) // no P frames
+    {
+        Mpeg4Type.nPFrames = 0;
+        Mpeg4Type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI; // maps to only supporting I-frames
+    }
+    else
+    {
+        Mpeg4Type.nPFrames = (OMX_U32)(iVideoEncodeParam.iIFrameInterval * iVideoEncodeParam.iFrameRate[0] - 1);
+    }
+
+    // extra parameters - hardcoded
+    Mpeg4Type.nBFrames = 0;
+    Mpeg4Type.nIDCVLCThreshold = 0;
+    Mpeg4Type.bACPred = OMX_TRUE;
+    Mpeg4Type.nMaxPacketSize = iVideoEncodeParam.iPacketSize;
+    Mpeg4Type.nTimeIncRes = 1000; // (in relation to (should be higher than) frame rate )
+    Mpeg4Type.nHeaderExtension = 0;
+    Mpeg4Type.bReversibleVLC = ((iVideoEncodeParam.iRVLCEnable == true) ? OMX_TRUE : OMX_FALSE);
+
+    switch (iVideoEncodeParam.iProfileLevel)
+    {
+
+        case EI_SIMPLE_LEVEL0:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level0;
+            break;
+
+        case EI_SIMPLE_LEVEL1:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level1;
+            break;
+
+        case EI_SIMPLE_LEVEL2:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level2;
+            break;
+
+        case EI_SIMPLE_LEVEL3:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimple;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level3;
+            break;
+
+        case EI_CORE_LEVEL1:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileCore;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level1;
+            break;
+
+        case EI_CORE_LEVEL2:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileCore;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level2;
+            break;
+
+        case EI_SIMPLE_SCALABLE_LEVEL0:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level0;
+            break;
+
+        case EI_SIMPLE_SCALABLE_LEVEL1:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level1;
+            break;
+
+        case EI_SIMPLE_SCALABLE_LEVEL2:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level2;
+            break;
+
+        case EI_CORE_SCALABLE_LEVEL1:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level1;
+            break;
+
+        case EI_CORE_SCALABLE_LEVEL2:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level2;
+            break;
+
+        case EI_CORE_SCALABLE_LEVEL3:
+            Mpeg4Type.eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable;
+            Mpeg4Type.eLevel = OMX_VIDEO_MPEG4Level3;
+            break;
+
+    }
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoMpeg4, &Mpeg4Type);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //OMX_VIDEO_PARAM_BITRATETYPE Settings
+    CONFIG_SIZE_AND_VERSION(BitRateType);
+
+    BitRateType.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoBitrate, &BitRateType);
+
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //Set the parameters now
+    BitRateType.nPortIndex = iOutputPortIndex;
+    switch (iVideoEncodeParam.iRateControlType)
+    {
+        case ECONSTANT_Q:
+            BitRateType.eControlRate = OMX_Video_ControlRateDisable;
+            break;
+        case ECBR_1:
+            BitRateType.eControlRate = OMX_Video_ControlRateConstant;
+            break;
+        case EVBR_1:
+            BitRateType.eControlRate = OMX_Video_ControlRateVariable;
+            break;
+        default:
+            BitRateType.eControlRate = OMX_Video_ControlRateDisable;
+            break;
+    }
+
+    BitRateType.nTargetBitrate = iVideoEncodeParam.iBitRate[0];
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoBitrate, &BitRateType);
+
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //OMX_VIDEO_PARAM_QUANTIZATIONTYPE Settings
+    if (BitRateType.eControlRate == OMX_Video_ControlRateDisable)
+    {
+        CONFIG_SIZE_AND_VERSION(QuantParam);
+        QuantParam.nPortIndex = iOutputPortIndex;
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoQuantization, &QuantParam);
+        if (OMX_ErrorNone != Err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+        }
+
+        //Set the parameters now
+        QuantParam.nPortIndex = iOutputPortIndex;
+        QuantParam.nQpI = DEFAULT_OMX_MP4ENC_QPI;
+        QuantParam.nQpP = DEFAULT_OMX_MP4ENC_QPP;
+        QuantParam.nQpB = DEFAULT_OMX_MP4ENC_QPB;
+        Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoQuantization, &QuantParam);
+        if (OMX_ErrorNone != Err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+        }
+    }
+
+
+
+    //OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE Settings (For streaming/2-way)
+
+    CONFIG_SIZE_AND_VERSION(ErrCorrType);
+    ErrCorrType.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoErrorCorrection, &ErrCorrType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //Set the parameters now
+    ErrCorrType.nPortIndex = iOutputPortIndex;
+    if (iVideoEncodeParam.iContentType == EI_M4V_STREAMING)
+    {
+        ErrCorrType.bEnableDataPartitioning = OMX_TRUE;
+        ErrCorrType.bEnableResync = OMX_TRUE;
+    }
+    else
+    {
+        ErrCorrType.bEnableDataPartitioning = OMX_FALSE;
+        ErrCorrType.bEnableResync = OMX_FALSE;
+    }
+
+    // extra parameters - hardcoded
+    ErrCorrType.bEnableHEC = OMX_FALSE;
+    ErrCorrType.nResynchMarkerSpacing = iVideoEncodeParam.iPacketSize;
+    ErrCorrType.bEnableRVLC = ((iVideoEncodeParam.iRVLCEnable == true) ? OMX_TRUE : OMX_FALSE); // corresponds to encode param rvlcEnable
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoErrorCorrection, &ErrCorrType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_MOTIONVECTORTYPE Settings
+    CONFIG_SIZE_AND_VERSION(MotionVector);
+    MotionVector.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoMotionVector, &MotionVector);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    MotionVector.nPortIndex = iOutputPortIndex;
+
+    // extra parameters - hardcoded
+    MotionVector.sXSearchRange = iVideoEncodeParam.iSearchRange;
+    MotionVector.sYSearchRange = iVideoEncodeParam.iSearchRange;
+    MotionVector.bFourMV = ((iVideoEncodeParam.iMV8x8 == true) ? OMX_TRUE : OMX_FALSE);
+    MotionVector.eAccuracy = ((iVideoEncodeParam.iMVHalfPel == true) ? OMX_Video_MotionVectorHalfPel : OMX_Video_MotionVectorPixel);
+    MotionVector.bUnrestrictedMVs = OMX_TRUE;
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoMotionVector, &MotionVector);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE Settings
+    CONFIG_SIZE_AND_VERSION(RefreshParam);
+    RefreshParam.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoIntraRefresh, &RefreshParam);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    // extra parameters - hardcoded based on PV defaults
+    RefreshParam.nPortIndex = iOutputPortIndex;
+    RefreshParam.eRefreshMode = OMX_VIDEO_IntraRefreshBoth;
+    RefreshParam.nCirMBs = iVideoEncodeParam.iNumIntraMBRefresh;
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoIntraRefresh, &RefreshParam);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetMP4EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    return true;
+}
+
+bool PVMFOMXEncNode::SetH263EncoderParameters()
+{
+
+    OMX_ERRORTYPE Err = OMX_ErrorNone;
+
+    OMX_VIDEO_PARAM_H263TYPE H263Type;
+    OMX_VIDEO_PARAM_BITRATETYPE BitRateType;
+    OMX_VIDEO_PARAM_QUANTIZATIONTYPE QuantParam;
+    OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE ErrCorrType;
+
+    // DV: VALUES HERE ARE FOR THE MOST PART HARDCODED BASED ON PV DEFAULTS
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE MotionVector;
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE RefreshParam;
+
+
+    CONFIG_SIZE_AND_VERSION(H263Type);
+    H263Type.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoH263, &H263Type);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //Set the OMX_VIDEO_PARAM_H263TYPE parameters
+
+    //DV: Here, we only set the nPFrames and AllowedFrameTypes, i.e. iIFrameInterval related variables
+
+    H263Type.nPortIndex = iOutputPortIndex;
+
+    H263Type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+    if (iVideoEncodeParam.iIFrameInterval == -1) // encode only one I frame followed by P frames
+    {
+        H263Type.nPFrames = 0xFFFFFFFF;
+    }
+    else if (iVideoEncodeParam.iIFrameInterval == 0) // no P frames
+    {
+        H263Type.nPFrames = 0;
+        H263Type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI; // maps to only supporting I-frames
+    }
+    else
+    {
+        H263Type.nPFrames = (OMX_U32)(iVideoEncodeParam.iIFrameInterval * iVideoEncodeParam.iFrameRate[0] - 1);
+    }
+
+    // extra parameters - hardcoded
+    H263Type.nBFrames = 0;
+    H263Type.eProfile = OMX_VIDEO_H263ProfileBaseline;
+    H263Type.eLevel = OMX_VIDEO_H263Level45;
+    H263Type.bPLUSPTYPEAllowed = OMX_FALSE;
+    H263Type.bForceRoundingTypeToZero = OMX_FALSE;
+    H263Type.nPictureHeaderRepetition = 0;
+    H263Type.nGOBHeaderInterval = 2;
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoH263, &H263Type);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //OMX_VIDEO_PARAM_BITRATETYPE Settings
+    CONFIG_SIZE_AND_VERSION(BitRateType);
+
+    BitRateType.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoBitrate, &BitRateType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //Set the parameters now
+    BitRateType.nPortIndex = iOutputPortIndex;
+    switch (iVideoEncodeParam.iRateControlType)
+    {
+        case ECONSTANT_Q:
+            BitRateType.eControlRate = OMX_Video_ControlRateDisable;
+            break;
+        case ECBR_1:
+            BitRateType.eControlRate = OMX_Video_ControlRateConstant;
+            break;
+        case EVBR_1:
+            BitRateType.eControlRate = OMX_Video_ControlRateVariable;
+            break;
+        default:
+            BitRateType.eControlRate = OMX_Video_ControlRateDisable;
+            break;
+    }
+
+    BitRateType.nTargetBitrate = iVideoEncodeParam.iBitRate[0];
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoBitrate, &BitRateType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_QUANTIZATIONTYPE Settings
+    if (BitRateType.eControlRate == OMX_Video_ControlRateDisable)
+    {
+        CONFIG_SIZE_AND_VERSION(QuantParam);
+        QuantParam.nPortIndex = iOutputPortIndex;
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoQuantization, &QuantParam);
+        if (OMX_ErrorNone != Err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+        }
+
+        //Set the parameters now
+        QuantParam.nPortIndex = iOutputPortIndex;
+        QuantParam.nQpI = DEFAULT_OMX_MP4ENC_QPI;
+        QuantParam.nQpP = DEFAULT_OMX_MP4ENC_QPP;
+        QuantParam.nQpB = DEFAULT_OMX_MP4ENC_QPB;
+        Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoQuantization, &QuantParam);
+        if (OMX_ErrorNone != Err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+        }
+    }
+
+
+    //OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE Settings (For streaming/2-way)
+
+    CONFIG_SIZE_AND_VERSION(ErrCorrType);
+    ErrCorrType.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoErrorCorrection, &ErrCorrType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //Set the parameters now
+    ErrCorrType.nPortIndex = iOutputPortIndex;
+    //if (iVideoEncodeParam.iContentType == EI_M4V_STREAMING)
+    //{
+    //    ErrCorrType.bEnableDataPartitioning = OMX_TRUE;
+    //}
+    //else
+    //{
+    //    ErrCorrType.bEnableDataPartitioning = OMX_FALSE;
+    //}
+    ErrCorrType.bEnableHEC = OMX_FALSE;
+    ErrCorrType.bEnableResync = OMX_FALSE;
+    ErrCorrType.nResynchMarkerSpacing = 0;
+    ErrCorrType.bEnableRVLC = OMX_FALSE;		// corresponds to encode param rvlcEnable
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoErrorCorrection, &ErrCorrType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+
+    //OMX_VIDEO_PARAM_MOTIONVECTORTYPE Settings
+    CONFIG_SIZE_AND_VERSION(MotionVector);
+    MotionVector.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoMotionVector, &MotionVector);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    // extra parameters - hardcoded
+    MotionVector.sXSearchRange = iVideoEncodeParam.iSearchRange;
+    MotionVector.sYSearchRange = iVideoEncodeParam.iSearchRange;
+    MotionVector.bFourMV =  OMX_FALSE;
+    MotionVector.eAccuracy = ((iVideoEncodeParam.iMVHalfPel == true) ? OMX_Video_MotionVectorHalfPel : OMX_Video_MotionVectorPixel);
+    MotionVector.bUnrestrictedMVs = OMX_FALSE;
+
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoMotionVector, &MotionVector);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE Settings
+
+    CONFIG_SIZE_AND_VERSION(RefreshParam);
+    RefreshParam.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoIntraRefresh, &RefreshParam);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    // extra parameters - hardcoded based on PV defaults
+    RefreshParam.nPortIndex = iOutputPortIndex;
+    RefreshParam.eRefreshMode = OMX_VIDEO_IntraRefreshBoth;
+    RefreshParam.nCirMBs = iVideoEncodeParam.iNumIntraMBRefresh;
+
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoIntraRefresh, &RefreshParam);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH263EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    return true;
+}
+
+bool PVMFOMXEncNode::SetH264EncoderParameters()
+{
+    OMX_ERRORTYPE Err = OMX_ErrorNone;
+
+    OMX_VIDEO_PARAM_AVCTYPE H264Type;
+    OMX_VIDEO_PARAM_BITRATETYPE BitRateType;
+    OMX_VIDEO_PARAM_QUANTIZATIONTYPE QuantParam;
+
+    // to be refined
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE MotionVector;
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE RefreshParam;
+    OMX_VIDEO_PARAM_VBSMCTYPE VbsmcType;
+
+
+    CONFIG_SIZE_AND_VERSION(H264Type);
+    H264Type.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoAvc, &H264Type);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    H264Type.nPortIndex = iOutputPortIndex;
+
+    H264Type.nAllowedPictureTypes  = OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
+    if (iVideoEncodeParam.iIFrameInterval == -1) // encode only one I frame followed by P frames
+    {
+        H264Type.nPFrames = 0xFFFFFFFF;
+    }
+    else if (iVideoEncodeParam.iIFrameInterval == 0) // no P frames
+    {
+        H264Type.nPFrames = 0;
+        H264Type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI; // maps to only supporting I-frames
+    }
+    else
+    {
+        H264Type.nPFrames = (OMX_U32)(iVideoEncodeParam.iIFrameInterval * iVideoEncodeParam.iFrameRate[0] - 1);
+    }
+
+    // extra parameters -hardcoded
+    H264Type.nSliceHeaderSpacing = 0;
+    H264Type.nBFrames = 0;
+    H264Type.bUseHadamard = OMX_TRUE;
+    H264Type.nRefFrames = 1;
+    H264Type.nRefIdx10ActiveMinus1 = 0;
+    H264Type.nRefIdx11ActiveMinus1 = 0;
+    H264Type.bEnableUEP = OMX_FALSE;
+    H264Type.bEnableFMO = OMX_FALSE;
+    H264Type.bEnableASO = OMX_FALSE;
+    H264Type.bEnableRS = OMX_FALSE;
+    H264Type.eProfile = OMX_VIDEO_AVCProfileBaseline;
+    H264Type.eLevel = OMX_VIDEO_AVCLevel1b;
+    H264Type.bFrameMBsOnly = OMX_TRUE;
+    H264Type.bMBAFF = OMX_FALSE;
+    H264Type.bEntropyCodingCABAC = OMX_FALSE;
+    H264Type.bWeightedPPrediction = OMX_FALSE;
+    H264Type.bconstIpred = OMX_FALSE;
+    H264Type.bDirect8x8Inference = OMX_FALSE;
+    H264Type.bDirectSpatialTemporal = OMX_FALSE;
+    H264Type.nCabacInitIdc = 0;
+    H264Type.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;
+
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoAvc, &H264Type);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_BITRATETYPE Settings
+    CONFIG_SIZE_AND_VERSION(BitRateType);
+
+    BitRateType.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoBitrate, &BitRateType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    //Set the parameters now
+    BitRateType.nPortIndex = iOutputPortIndex;
+    switch (iVideoEncodeParam.iRateControlType)
+    {
+        case ECONSTANT_Q:
+            BitRateType.eControlRate = OMX_Video_ControlRateDisable;
+            break;
+        case ECBR_1:
+            BitRateType.eControlRate = OMX_Video_ControlRateConstant;
+            break;
+        case EVBR_1:
+            BitRateType.eControlRate = OMX_Video_ControlRateVariable;
+            break;
+        default:
+            BitRateType.eControlRate = OMX_Video_ControlRateDisable;
+            break;
+    }
+
+    BitRateType.nTargetBitrate = iVideoEncodeParam.iBitRate[0];
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoBitrate, &BitRateType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_QUANTIZATIONTYPE Settings
+    if (BitRateType.eControlRate == OMX_Video_ControlRateDisable)
+    {
+        CONFIG_SIZE_AND_VERSION(QuantParam);
+        QuantParam.nPortIndex = iOutputPortIndex;
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoQuantization, &QuantParam);
+        if (OMX_ErrorNone != Err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+        }
+
+        //Set the parameters now
+        QuantParam.nPortIndex = iOutputPortIndex;
+        QuantParam.nQpI = DEFAULT_OMX_AVCENC_QPI;
+        QuantParam.nQpP = DEFAULT_OMX_AVCENC_QPP;
+        QuantParam.nQpB = DEFAULT_OMX_AVCENC_QPB;
+        Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoQuantization, &QuantParam);
+        if (OMX_ErrorNone != Err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+        }
+    }
+
+
+
+
+    //OMX_VIDEO_PARAM_MOTIONVECTORTYPE Settings
+    CONFIG_SIZE_AND_VERSION(MotionVector);
+    MotionVector.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoMotionVector, &MotionVector);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    // extra parameters - hardcoded
+    MotionVector.sXSearchRange = iVideoEncodeParam.iSearchRange;
+    MotionVector.sYSearchRange = iVideoEncodeParam.iSearchRange;
+    MotionVector.bFourMV =  OMX_FALSE;
+    MotionVector.eAccuracy = OMX_Video_MotionVectorQuarterPel; // hardcoded
+    MotionVector.bUnrestrictedMVs = OMX_TRUE;
+
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoMotionVector, &MotionVector);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE Settings
+
+    CONFIG_SIZE_AND_VERSION(RefreshParam);
+    RefreshParam.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoIntraRefresh, &RefreshParam);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    // extra parameters - hardcoded based on PV defaults
+    RefreshParam.nPortIndex = iOutputPortIndex;
+    RefreshParam.eRefreshMode = OMX_VIDEO_IntraRefreshBoth;
+    RefreshParam.nCirMBs = iVideoEncodeParam.iNumIntraMBRefresh;
+
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoIntraRefresh, &RefreshParam);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    CONFIG_SIZE_AND_VERSION(VbsmcType);
+    VbsmcType.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamVideoVBSMC, &VbsmcType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    VbsmcType.b16x16 = OMX_TRUE;
+    VbsmcType.b16x8 = VbsmcType.b8x16 = VbsmcType.b8x8 = VbsmcType.b8x4 = VbsmcType.b4x8 = VbsmcType.b4x4 = OMX_FALSE;
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamVideoVBSMC, &VbsmcType);
+    if (OMX_ErrorNone != Err)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetH264EncoderParameters Parameter Invalid", iNodeTypeId));
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::NegotiateAudioComponentParameters()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::NegotiateAudioParameters() In", iNodeTypeId));
+
+    OMX_ERRORTYPE Err;
+
+    // first get the number of ports and port indices
+    OMX_PORT_PARAM_TYPE AudioPortParameters;
+    uint32 NumPorts;
+    uint32 ii;
+
+    // get starting number
+    CONFIG_SIZE_AND_VERSION(AudioPortParameters);
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamAudioInit, &AudioPortParameters);
+    NumPorts = AudioPortParameters.nPorts; // must be at least 2 of them (in&out)
+
+    if (Err != OMX_ErrorNone || NumPorts < 2)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() There is insuffucient (%d) ports", iNodeTypeId, NumPorts));
+        return false;
+    }
+
+
+    // loop through ports starting from the starting index to find index of the first input port
+    for (ii = AudioPortParameters.nStartPortNumber ;ii < AudioPortParameters.nStartPortNumber + NumPorts; ii++)
+    {
+        // get port parameters, and determine if it is input or output
+        // if there are more than 2 ports, the first one we encounter that has input direction is picked
+
+
+        CONFIG_SIZE_AND_VERSION(iParamPort);
+        //port
+        iParamPort.nPortIndex = ii;
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+        if (Err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem negotiating with port %d ", iNodeTypeId, ii));
+
+            return false;
+        }
+
+        if (iParamPort.eDir == OMX_DirInput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Found Input port index %d ", iNodeTypeId, ii));
+
+            iInputPortIndex = ii;
+            break;
+        }
+    }
+    if (ii == AudioPortParameters.nStartPortNumber + NumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Cannot find any input port ", iNodeTypeId));
+        return false;
+    }
+
+
+    // loop through ports starting from the starting index to find index of the first output port
+    for (ii = AudioPortParameters.nStartPortNumber ;ii < AudioPortParameters.nStartPortNumber + NumPorts; ii++)
+    {
+        // get port parameters, and determine if it is input or output
+        // if there are more than 2 ports, the first one we encounter that has output direction is picked
+
+
+        CONFIG_SIZE_AND_VERSION(iParamPort);
+        //port
+        iParamPort.nPortIndex = ii;
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+        if (Err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem negotiating with port %d ", iNodeTypeId, ii));
+
+            return false;
+        }
+
+        if (iParamPort.eDir == OMX_DirOutput)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Found Output port index %d ", iNodeTypeId, ii));
+
+            iOutputPortIndex = ii;
+            break;
+        }
+    }
+    if (ii == AudioPortParameters.nStartPortNumber + NumPorts)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Cannot find any output port ", iNodeTypeId));
+        return false;
+    }
+
+
+
+    // now get input parameters
+
+
+    //INPUT PORT
+
+    // first basic check if encode parameters have been set correctly
+    if ((0 == iAudioEncodeParam.iMaxNumOutputFramesPerBuffer) ||
+            (0 == iAudioEncodeParam.iOutputBitrate) ||
+            (0 == iAudioEncodeParam.iOutputNumChannels) ||
+            (2 < iAudioEncodeParam.iOutputNumChannels) ||
+            (0 == iAudioEncodeParam.iOutputSamplingRate) ||
+            (0 == iAudioInputFormat.iInputBitsPerSample) ||
+            (0 == iAudioInputFormat.iInputNumChannels) ||
+            (2 < iAudioInputFormat.iInputNumChannels) ||
+            (0 == iAudioInputFormat.iInputSamplingRate)
+       )
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Encode parameters not set correctly", iNodeTypeId));
+        return false;
+    }
+
+    // first of all, check if the port supports the adequate port format
+    OMX_AUDIO_PARAM_PORTFORMATTYPE Audio_port_format;
+    OMX_AUDIO_CODINGTYPE DesiredPortFormat = OMX_AUDIO_CodingPCM;
+    CONFIG_SIZE_AND_VERSION(Audio_port_format);
+
+    Audio_port_format.nPortIndex = iInputPortIndex; // set input port as target
+
+    // loop over supported formats until we hit the one we want
+    // or until the component has no more supported formats (in which case it returns OMX_ErrorNoMore
+    Err = OMX_ErrorNone;
+    Audio_port_format.nIndex = 0; //init the format counter
+    while (OMX_ErrorNone == Err)
+    {
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamAudioPortFormat, &Audio_port_format);
+        if ((OMX_ErrorNone != Err))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem getting port format for input port %d or no desired port format found", iNodeTypeId, iInputPortIndex));
+            return false;
+        }
+
+        if (Audio_port_format.eEncoding == DesiredPortFormat)
+            break;
+
+        Audio_port_format.nIndex ++;
+    }
+
+    // OK, we've found the desired format, set it as the one used
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamAudioPortFormat, &Audio_port_format);
+    if ((OMX_ErrorNone != Err))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem setting port format for input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+
+
+
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    iParamPort.nPortIndex = iInputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem negotiating with input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+    if (iInFormat == PVMF_MIME_PCM16)
+    {
+        iOMXComponentInputBufferSize = MAX_NUM_AMR_FRAMES_PER_BUFFER * (PVMF_AMRENC_DEFAULT_FRAME_DURATION * PVMF_AMRENC_DEFAULT_SAMPLING_RATE * PVMF_AMRENC_DEFAULT_BITSPERSAMPLE) / (1000 * 8);
+
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem with input port %d color format", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+    //Set the input buffer size to the encoder component
+    iParamPort.nBufferSize = iOMXComponentInputBufferSize;
+
+    // set Encoding type
+
+    //iParamPort.format.audio.bFlagErrorConcealment = OMX_TRUE;
+
+    // indicate that input is uncompressed i.e. PCM
+    iParamPort.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
+
+    // let the component decide about the number of input buffers
+    iNumInputBuffers = iParamPort.nBufferCountActual;
+
+    // do we need to increase the number of buffers?
+    if (iNumInputBuffers < iParamPort.nBufferCountMin)
+        iNumInputBuffers = iParamPort.nBufferCountMin;
+
+
+    // if component allows us to allocate buffers, we'll decide how many to allocate
+    if (iOMXComponentSupportsExternalInputBufferAlloc && (iParamPort.nBufferCountMin < NUMBER_INPUT_BUFFER))
+    {
+        // preset the number of input buffers
+        iNumInputBuffers = NUMBER_INPUT_BUFFER;
+    }
+
+    // set the number of input buffer
+    iParamPort.nBufferCountActual = iNumInputBuffers;
+
+    // set the number of actual input buffers
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Inport buffers %d,size %d", iNodeTypeId, iNumInputBuffers, iOMXComponentInputBufferSize));
+
+    // lock in the input port parameters
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem setting parameters in input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+    // For INPUT, we also need to set the PCM parameters, such as sampling rate, etc.
+    // GET the output buffer params and sizes
+    OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param;
+    Audio_Pcm_Param.nPortIndex = iInputPortIndex;
+
+    CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
+
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem getting PCM parameters with input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+
+    Audio_Pcm_Param.nChannels		=	(OMX_U32) iAudioInputFormat.iInputNumChannels;
+    Audio_Pcm_Param.eNumData		=	OMX_NumericalDataSigned; // signed
+    Audio_Pcm_Param.eEndian			=	OMX_EndianLittle; // little-endian
+    Audio_Pcm_Param.bInterleaved	=	((EINTERLEAVE_LR == iAudioInputFormat.iInputInterleaveMode) ? OMX_TRUE : OMX_FALSE);
+    Audio_Pcm_Param.nBitPerSample	=	(OMX_U32) iAudioInputFormat.iInputBitsPerSample;
+    Audio_Pcm_Param.nSamplingRate	=	(OMX_U32) iAudioInputFormat.iInputSamplingRate;
+    Audio_Pcm_Param.ePCMMode		=	OMX_AUDIO_PCMModeLinear;
+    // don't set - let use default Audio_Pcm_Param.eChannelMapping
+
+
+    CONFIG_SIZE_AND_VERSION(Audio_Pcm_Param);
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamAudioPcm, &Audio_Pcm_Param);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem setting PCM parameters with input port %d ", iNodeTypeId, iInputPortIndex));
+        return false;
+    }
+
+    //////////////////////// OUTPUT PORT////////////////////////////////////////////////
+
+    // first of all, check if the port supports the adequate port format
+    if (iOutFormat == PVMF_MIME_AMR_IETF ||
+            iOutFormat == PVMF_MIME_AMR_IF2)
+    {
+        DesiredPortFormat = OMX_AUDIO_CodingAMR;
+    }
+    else
+    {
+        DesiredPortFormat = OMX_AUDIO_CodingUnused;
+    }
+
+    if (DesiredPortFormat == OMX_AUDIO_CodingUnused)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem with output port %d format", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+    CONFIG_SIZE_AND_VERSION(Audio_port_format);
+
+    Audio_port_format.nPortIndex = iOutputPortIndex; // set output port as target
+
+    // loop over supported formats until we hit the one we want
+    // or until the component has no more supported formats (in which case it returns OMX_ErrorNoMore
+    Err = OMX_ErrorNone;
+    Audio_port_format.nIndex = 0; //init the format counter
+    while (OMX_ErrorNone == Err)
+    {
+
+        Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamAudioPortFormat, &Audio_port_format);
+        if ((OMX_ErrorNone != Err))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem getting port format for output port %d or no desired port format found", iNodeTypeId, iOutputPortIndex));
+            return false;
+        }
+
+        if (Audio_port_format.eEncoding == DesiredPortFormat)
+            break;
+
+        Audio_port_format.nIndex ++;
+    }
+
+    // OK, we've found the desired format, set it as the one used
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamAudioPortFormat, &Audio_port_format);
+    if ((OMX_ErrorNone != Err))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem setting port format for output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+
+    //Port 1 for output port
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    iParamPort.nPortIndex = iOutputPortIndex;
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem negotiating with output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+    // let the component decide output buffer size
+    iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
+
+    // let the component decide num output buffers
+    iNumOutputBuffers = iParamPort.nBufferCountActual;
+
+    //check the number
+    if (iNumOutputBuffers < iParamPort.nBufferCountMin)
+        iNumOutputBuffers = iParamPort.nBufferCountMin;
+
+
+    // set the number ourselves
+    if (iOMXComponentSupportsExternalOutputBufferAlloc && (iParamPort.nBufferCountMin < NUMBER_OUTPUT_BUFFER))
+    {
+        iNumOutputBuffers = NUMBER_OUTPUT_BUFFER;
+    }
+
+    iParamPort.nBufferCountActual = iNumOutputBuffers;
+
+
+    // set the output (target) format, etc.
+    iParamPort.format.audio.bFlagErrorConcealment = OMX_TRUE;
+
+
+
+    if (iOutFormat == PVMF_MIME_AMR_IETF ||
+            iOutFormat == PVMF_MIME_AMR_IF2)
+    {
+        iParamPort.format.audio.eEncoding = OMX_AUDIO_CodingAMR;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Outport buffers %d,size %d", iNodeTypeId, iNumOutputBuffers, iOMXComponentOutputBufferSize));
+
+
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamPortDefinition, &iParamPort);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::NegotiateAudioComponentParameters() Problem setting parameters in output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+
+    // now call codec specific parameter setting
+    bool status = true;
+    if (iOutFormat == PVMF_MIME_AMR_IETF ||
+            iOutFormat == PVMF_MIME_AMR_IF2)
+    {
+        status = SetAMREncoderParameters();
+    }
+
+    return status;
+}
+bool PVMFOMXEncNode::SetAMREncoderParameters()
+{
+
+    OMX_ERRORTYPE Err = OMX_ErrorNone;
+    OMX_AUDIO_PARAM_AMRTYPE AmrType;
+
+    CONFIG_SIZE_AND_VERSION(AmrType);
+    AmrType.nPortIndex = iOutputPortIndex;
+
+    Err = OMX_GetParameter(iOMXEncoder, OMX_IndexParamAudioAmr, &AmrType);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetAMREncoderParameters - Problem getting AMR parameters in output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+    AmrType.nChannels = iAudioEncodeParam.iOutputNumChannels;
+
+    AmrType.eAMRBandMode = OMX_AUDIO_AMRBandModeNB7; // use 12.2 kbps
+    AmrType.eAMRDTXMode = OMX_AUDIO_AMRDTXModeOnAuto;
+
+    if (iOutFormat == PVMF_MIME_AMR_IETF)
+    {
+        AmrType.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatRTPPayload;
+    }
+    else if (iOutFormat == PVMF_MIME_AMR_IF2)
+    {
+        AmrType.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatIF2;
+    }
+
+    Err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamAudioAmr, &AmrType);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SetAMREncoderParameters - Problem setting AMR parameters in output port %d ", iNodeTypeId, iOutputPortIndex));
+        return false;
+    }
+
+    return true;
+}
+
+bool PVMFOMXEncNode::SetDefaultCapabilityFlags()
+{
+
+    iIsOMXComponentMultiThreaded = true;
+
+    iOMXComponentSupportsExternalOutputBufferAlloc = false;
+    iOMXComponentSupportsExternalInputBufferAlloc = false;
+    iOMXComponentSupportsMovableInputBuffers = false;
+
+    iOMXComponentNeedsNALStartCode = true;
+    iOMXComponentSupportsPartialFrames = false;
+    iOMXComponentCanHandleIncompleteFrames = false;
+
+    return true;
+}
+
+
+
+bool PVMFOMXEncNode::SendEOSBufferToOMXComponent()
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendEOSBufferToOMXComponent() In", iNodeTypeId));
+
+
+    // first of all, check if the component is running. EOS could be sent prior to component/encoder
+    // even being initialized
+
+    // returning false will ensure that the EOS will be sent downstream anyway without waiting for the
+    // Component to respond
+    if (iCurrentEncoderState != OMX_StateExecuting)
+        return false;
+
+    // get an input buffer. Without a buffer, no point in proceeding
+    InputBufCtrlStruct *input_buf = NULL;
+    int32 errcode = 0;
+
+    // we already checked that the number of buffers is OK, so we don't expect problems
+    // try to get input buffer header
+    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
+    if (errcode != 0)
+    {
+        if (errcode == OsclErrNoResources)
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                            PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::SendEOSBufferToOMXComponent() No more buffers in the mempool - unexpected", iNodeTypeId));
+
+            iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
+
+            return false;
+        }
+        else
+        {
+            // Memory allocation for the pool failed
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SendEOSBufferToOMXComponent() Input mempool error", iNodeTypeId));
+
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return false;
+        }
+
+    }
+
+    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
+    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
+    iNumOutstandingInputBuffers++;
+
+    // in this case, no need to use input msg refcounter. Make sure its unbound
+    (input_buf->pMediaData).Unbind();
+
+    // THIS IS AN EMPTY BUFFER. FLAGS ARE THE ONLY IMPORTANT THING
+    input_buf->pBufHdr->nFilledLen = 0;
+    input_buf->pBufHdr->nOffset = 0;
+    input_buf->pBufHdr->nTimeStamp = iEndOfDataTimestamp;
+
+    // set ptr to input_buf structure for Context (for when the buffer is returned)
+    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
+
+    // do not use Mark here (but init to NULL to prevent problems)
+    input_buf->pBufHdr->hMarkTargetComponent = NULL;
+    input_buf->pBufHdr->pMarkData = NULL;
+
+
+    // init buffer flags
+    input_buf->pBufHdr->nFlags = 0;
+
+    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+    // most importantly, set the EOS flag:
+    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_EOS;
+
+    // send buffer to component
+    OMX_EmptyThisBuffer(iOMXEncoder, input_buf->pBufHdr);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendEOSBufferToOMXComponent() Out", iNodeTypeId));
+
+    return true;
+
+}
+
+
+bool PVMFOMXEncNode::SendInputBufferToOMXComponent()
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() In", iNodeTypeId));
+
+    // first of all , get an input buffer. Without a buffer, no point in proceeding
+    InputBufCtrlStruct *input_buf = NULL;
+    int32 errcode = 0;
+
+    do
+    {
+        // do loop to loop over all fragments
+
+        // try to get input buffer header
+        InputBufCtrlStruct *temp = NULL;
+        OSCL_TRY(errcode, temp = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
+        input_buf = temp;
+        if (errcode != 0)
+        {
+            if (errcode == OsclErrNoResources)
+            {
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                                PVLOGMSG_DEBUG, (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() No more buffers in the mempool", iNodeTypeId));
+
+                iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
+
+                return false;
+            }
+            else
+            {
+                // Memory allocation for the pool failed
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() Input mempool error", iNodeTypeId));
+
+
+                SetState(EPVMFNodeError);
+                ReportErrorEvent(PVMFErrNoMemory);
+                return false;
+            }
+
+        }
+
+        // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
+        iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
+        iNumOutstandingInputBuffers++;
+
+        // Now we have the buffer header (i.e. a buffer) to send to component:
+        // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
+        //	into OMX component without copying (and update the input msg refcount)
+        //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
+
+
+        // if this is the first fragment in a new message, extract some info:
+        if (iCurrFragNum == 0)
+        {
+
+            // NOTE: SeqNum differ in Codec and in Node because of the fact that
+            // one msg can contain multiple fragments that are sent to the codec as
+            // separate buffers. Node tracks msgs and codec tracks even separate fragments
+
+            iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
+            // amount that the input seq. number increased
+
+            iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
+            iInTimestamp = iDataIn->getTimestamp();
+            iInDuration = iDataIn->getDuration();
+            iInNumFrags = iDataIn->getNumFragments();
+
+
+
+            iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
+
+
+            // logging info:
+            if (iDataIn->getNumFragments() > 1)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() - New msg has MULTI-FRAGMENTS", iNodeTypeId));
+            }
+
+            if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT))
+            {
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() - New msg has NO MARKER BIT", iNodeTypeId));
+            }
+        }
+
+
+        // get a memfrag from the message
+        OsclRefCounterMemFrag frag;
+        iDataIn->getMediaFragment(iCurrFragNum, frag);
+
+
+        if (iOMXComponentSupportsMovableInputBuffers)
+        {
+            // no copying required
+
+            // increment the RefCounter of the message associated with the mem fragment/buffer
+            // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
+            // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
+
+            iDataIn.GetRefCounter()->addRef();
+
+            // associate the buffer ctrl structure with the message ref counter and ptr
+            input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
+
+
+            // set pointer to the data, length, offset
+            input_buf->pBufHdr->pBuffer = (uint8 *)frag.getMemFragPtr();
+            input_buf->pBufHdr->nFilledLen = frag.getMemFragSize();
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() - Buffer 0x%x of size %d, %d frag out of tot. %d, TS=%d", iNodeTypeId, input_buf->pBufHdr->pBuffer, frag.getMemFragSize(), iCurrFragNum + 1, iDataIn->getNumFragments(), iInTimestamp));
+
+            iCurrFragNum++; // increment fragment number and move on to the next
+
+
+        }
+        else
+        {
+
+            // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
+            (input_buf->pMediaData).Unbind();
+
+
+            // init variables
+            iCopyPosition = 0;
+            iFragmentSizeRemainingToCopy  = frag.getMemFragSize();
+
+
+            // can the remaining fragment fit into the buffer?
+            if (iFragmentSizeRemainingToCopy <= (input_buf->pBufHdr->nAllocLen))
+            {
+
+                oscl_memcpy(input_buf->pBufHdr->pBuffer,
+                            (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
+                            iFragmentSizeRemainingToCopy);
+
+                input_buf->pBufHdr->nFilledLen = iFragmentSizeRemainingToCopy;
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d ", iNodeTypeId, iFragmentSizeRemainingToCopy, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen, iInTimestamp));
+
+                iCopyPosition += iFragmentSizeRemainingToCopy;
+                iFragmentSizeRemainingToCopy = 0;
+
+
+
+            }
+            else
+            {
+                // copy as much as you can of the current fragment into the current buffer
+                oscl_memcpy(input_buf->pBufHdr->pBuffer,
+                            (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
+                            input_buf->pBufHdr->nAllocLen);
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() - Frame cannot fit into input buffer ! Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d", iNodeTypeId, input_buf->pBufHdr->nAllocLen, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen, iInTimestamp));
+
+                input_buf->pBufHdr->nFilledLen = input_buf->pBufHdr->nAllocLen;
+                iCopyPosition += input_buf->pBufHdr->nAllocLen; // move current position within fragment forward
+                iFragmentSizeRemainingToCopy -= input_buf->pBufHdr->nAllocLen;
+
+            }
+
+            // proceed to the next fragment regardless of input buffer size
+            iCurrFragNum++;
+        }
+
+
+        // set buffer fields (this is the same regardless of whether the input is movable or not
+        input_buf->pBufHdr->nOffset = 0;
+        input_buf->pBufHdr->nTimeStamp = iInTimestamp;
+
+        // set ptr to input_buf structure for Context (for when the buffer is returned)
+        input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
+
+        // do not use Mark here (but init to NULL to prevent problems)
+        input_buf->pBufHdr->hMarkTargetComponent = NULL;
+        input_buf->pBufHdr->pMarkData = NULL;
+
+
+        // init buffer flags
+        input_buf->pBufHdr->nFlags = 0;
+
+
+        // set the key frame flag if necessary (mark every fragment that belongs to it)
+        if (iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT)
+            input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+
+
+        // in case of encoder, all input frames should be marked
+        input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
+        OMX_EmptyThisBuffer(iOMXEncoder, input_buf->pBufHdr);
+
+
+        // if we sent all fragments to OMX component, decouple the input message from iDataIn
+        // Input message is "decoupled", so that we can get a new message for processing into iDataIn
+        //	However, the actual message is released completely to upstream mempool once all of its fragments
+        //	are returned by the OMX component
+
+        if (iCurrFragNum == iDataIn->getNumFragments())
+        {
+            iDataIn.Unbind();
+
+        }
+
+
+    }
+    while (iCurrFragNum < iInNumFrags); //iDataIn->getNumFragments());
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendInputBufferToOMXComponent() Out", iNodeTypeId));
+
+    return true;
+
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::CreateOutMemPool(uint32 num_buffers)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::CreateOutMemPool() start", iNodeTypeId));
+    // In the case OMX component wants to allocate its own buffers,
+    // mempool only contains OutputBufCtrlStructures (i.e. ptrs to buffer headers)
+    // In case OMX component uses pre-allocated buffers (here),
+    // mempool allocates OutputBufCtrlStructure (i.e. ptrs to buffer hdrs), followed by actual buffers
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::CreateOutMemPool() Allocating output buffer header pointers", iNodeTypeId));
+
+    iOutputAllocSize = oscl_mem_aligned_size((uint32)sizeof(OutputBufCtrlStruct));
+
+    if (iOMXComponentSupportsExternalOutputBufferAlloc)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::CreateOutMemPool() Allocating output buffers of size %d as well", iNodeTypeId, iOMXComponentOutputBufferSize));
+
+        //pre-negotiated output buffer size
+        iOutputAllocSize += iOMXComponentOutputBufferSize;
+    }
+
+    // ENCODER SPECIFIC FOR AVC RAW (BYTESTREAM) FORMAT
+    if (iOutFormat == PVMF_MIME_H264_VIDEO_RAW)
+    {
+        iOutputAllocSize += 4; // NAL SYNC WORD SIZE
+    }
+
+    // for media data wrapper
+    if (iMediaDataMemPool)
+    {
+        iMediaDataMemPool->removeRef();
+        iMediaDataMemPool = NULL;
+    }
+
+    if (iOutBufMemoryPool)
+    {
+        iOutBufMemoryPool->removeRef();
+        iOutBufMemoryPool = NULL;
+    }
+
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, iOutBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
+    if (leavecode || iOutBufMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::CreateOutMemPool() Memory pool structure for output buffers failed to allocate", iNodeTypeId));
+        return false;
+    }
+
+
+
+    // allocate a dummy buffer to actually create the mempool
+    OsclAny *dummy_alloc = NULL; // this dummy buffer will be released at end of scope
+    leavecode = 0;
+    OSCL_TRY(leavecode, dummy_alloc = iOutBufMemoryPool->allocate(iOutputAllocSize));
+    if (leavecode || dummy_alloc == NULL)
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::CreateOutMemPool() Memory pool for output buffers failed to allocate", iNodeTypeId));
+        return false;
+    }
+    iOutBufMemoryPool->deallocate(dummy_alloc);
+    // init the counter
+    iNumOutstandingOutputBuffers = 0;
+
+    // allocate mempool for media data message wrapper
+    leavecode = 0;
+    OSCL_TRY(leavecode, iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers, PVOMXENC_MEDIADATA_CHUNKSIZE)));
+    if (leavecode || iMediaDataMemPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::CreateOutMemPool() Media Data Buffer pool for output buffers failed to allocate", iNodeTypeId));
+        return false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::CreateOutMemPool() done", iNodeTypeId));
+    return true;
+}
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////// Creates memory pool for input buffer management ///////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::CreateInputMemPool(uint32 num_buffers)
+{
+    // 3 cases in order of preference and simplicity
+
+    // Case 1 (buffers allocated upstream - no memcpy needed):
+    //	PV OMX Component - We use buffers allocated outside the OMX node (i.e. allocated upstream)
+    // Mempool contains InputBufCtrlStructures (ptrs to buffer headers and PMVFMediaData ptrs - to keep track of when to unbind input msgs)
+
+    // NOTE:	in this case, when providing input buffers to OMX component,
+    //			OMX_UseBuffer calls will provide some initial pointers and sizes of buffers, but these
+    //			are dummy values. Actual buffer pointers and filled sizes will be obtained from the input msg fragments.
+    //			The PV OMX component will use the buffers even if the ptrs differ from the ones during initialization
+    //			3rd party OMX components can also use this case if they are capable of ignoring the actual buffer pointers in
+    //			buffer header field (i.e. if after OMX_UseBuffer(...) call, they allow the ptr to actual buffer data to change at a later time
+
+    // CASE 2 (buffers allocated in the node - memcpy needed)
+    //			If 3rd party OMX component can use buffers allocated outside the OMX component, but it cannot
+    //			change buffer ptr allocations dynamically (i.e. after initialization with OMX_UseBuffer call is complete)
+
+    //		Mempool contains InputBufCtrlStructures (ptrs to buffer headers, PVMFMediaData ptrs to keep track of when to unbind input msgs) +
+    //				actual buffers.
+    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component
+
+    // CASE 3 (buffers allocated in the component - memcpy needed)
+    //			If 3rd party OMX component must allocate its own buffers
+    //			Mempool only contains InputBufCtrlStruct (ptrs to buffer headers + PMVFMediaData ptrs to keep track of when to unbind input msgs)
+    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component (like in case 2)
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::CreateInputMemPool() start ", iNodeTypeId));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::CreateInputMemPool() allocating buffer header pointers and shared media data ptrs ", iNodeTypeId));
+
+
+
+    iInputAllocSize = oscl_mem_aligned_size((uint32) sizeof(InputBufCtrlStruct)); //aligned_size_buffer_header_ptr+aligned_size_media_data_ptr;
+
+    // Need to allocate buffers in the node either if component supports external buffers buffers
+    // but they are not movable
+
+    if ((iOMXComponentSupportsExternalInputBufferAlloc && !iOMXComponentSupportsMovableInputBuffers))
+    {
+        //pre-negotiated input buffer size
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::CreateOutMemPool() Allocating input buffers of size %d as well", iNodeTypeId, iOMXComponentInputBufferSize));
+
+        iInputAllocSize += iOMXComponentInputBufferSize;
+    }
+
+    if (iInBufMemoryPool)
+    {
+        iInBufMemoryPool->removeRef();
+        iInBufMemoryPool = NULL;
+    }
+
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, iInBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
+    if (leavecode || iInBufMemoryPool == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::CreateInputMemPool() Memory pool structure for input buffers failed to allocate", iNodeTypeId));
+        return false;
+    }
+    // try to allocate a dummy buffer to actually create the mempool and allocate the needed memory
+    // allocate a dummy buffer to actually create the mempool, this dummy buffer will be released at end of scope of this method
+    OsclAny *dummy_alloc = NULL;
+    leavecode = 0;
+    OSCL_TRY(leavecode, dummy_alloc = iInBufMemoryPool->allocate(iInputAllocSize));
+    if (leavecode || dummy_alloc == NULL)
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                        PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::CreateInputMemPool() Memory pool for input buffers failed to allocate", iNodeTypeId));
+        return false;
+    }
+
+    // init the counter
+    iNumOutstandingInputBuffers = 0;
+
+
+    iInputBufferToResendToComponent = NULL; // nothing to resend yet
+    iInBufMemoryPool->deallocate(dummy_alloc);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::CreateInputMemPool() done", iNodeTypeId));
+    return true;
+}
+////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+        uint32 aNumBuffers,    // number of buffers
+        uint32 aActualBufferSize, // aactual buffer size
+        uint32 aPortIndex,      // port idx
+        bool aUseBufferOK,		// can component use OMX_UseBuffer or should it use OMX_AllocateBuffer
+        bool	aIsThisInputBuffer		// is this input or output
+                                              )
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ProvideBuffersToComponent() enter", iNodeTypeId));
+
+    uint32 ii = 0;
+    OMX_ERRORTYPE err = OMX_ErrorNone;
+    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
+
+    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
+    if (ctrl_struct_ptr == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::ProvideBuffersToComponent ctrl_struct_ptr == NULL", iNodeTypeId));
+        return false;
+    }
+
+
+    // Now, go through all buffers and tell component to
+    // either use a buffer, or to allocate its own buffer
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+
+        int32 errcode = 0;
+        // get the address where the buf hdr ptr will be stored
+        errcode = MemAllocate(ctrl_struct_ptr[ii], aMemPool, aAllocSize);
+        if ((errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL))
+        {
+            if (errcode == OsclErrNoResources)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::ProvideBuffersToComponent ->allocate() failed for no mempool chunk available", iNodeTypeId));
+            }
+            else
+            {
+                // General error
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::ProvideBuffersToComponent ->allocate() failed due to some general error", iNodeTypeId));
+
+                ReportErrorEvent(PVMFFailure);
+                ChangeNodeState(EPVMFNodeError);
+            }
+
+            return false;
+        }
+
+        if (aUseBufferOK)
+        {
+            // Buffers are already allocated outside OMX component.
+            // In case of output buffers, the buffer itself is located
+            // just after the buffer header pointer.
+
+            // In case of input buffers, the buffer header pointer is followed by a MediaDataSharedPtr
+            //	which is used to ensure proper unbinding of the input messages. The buffer itself is either:
+            //		a) allocated upstream (and the ptr to the buffer
+            //			is a dummy pointer to which the component does not pay attention - PV OMX component)
+            //		b) located just after the buffer header pointer and MediaDataSharedPtr
+
+            uint8 *pB = ((uint8*) ctrl_struct_ptr[ii]);
+
+
+            // in case of input buffers, initialize also MediaDataSharedPtr structure
+            if (aIsThisInputBuffer)
+            {
+
+                InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                oscl_memset(&(temp->pMediaData), 0, sizeof(PVMFSharedMediaDataPtr));
+                temp->pMediaData = PVMFSharedMediaDataPtr(NULL, NULL);
+
+                // advance ptr to skip the structure
+                pB += oscl_mem_aligned_size(sizeof(InputBufCtrlStruct));
+
+                err = OMX_UseBuffer(iOMXEncoder,	// hComponent
+                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
+                                    aPortIndex,				// port index (for port for which buffer is provided)
+                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
+                                    //				to have a context when component returns with a callback (i.e. to know
+                                    //				what to free etc.
+                                    (OMX_U32)aActualBufferSize,		// buffer size
+                                    pB);						// buffer data ptr
+
+            }
+            else
+            {
+                OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                // advance buffer ptr to skip the structure
+                pB += oscl_mem_aligned_size(sizeof(OutputBufCtrlStruct));
+
+                if (iOutFormat == PVMF_MIME_H264_VIDEO_RAW)
+                {
+                    // write out NAL sync word at the beginning of the buffer
+                    pB[0] = 0;
+                    pB[1] = 0;
+                    pB[2] = 0;
+                    pB[3] = 1;
+                    pB += 4;
+
+                    // THe buffer that the component knows is always the same
+                    // The node will move the ptr -4 when it needs teh sync word
+                }
+
+                err = OMX_UseBuffer(iOMXEncoder,	// hComponent
+                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
+                                    aPortIndex,				// port index (for port for which buffer is provided)
+                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
+                                    //				to have a context when component returns with a callback (i.e. to know
+                                    //				what to free etc.
+                                    (OMX_U32)aActualBufferSize,		// buffer size
+                                    pB);						// buffer data ptr
+
+
+            }
+
+
+        }
+        else
+        {
+            // the component must allocate its own buffers.
+            if (aIsThisInputBuffer)
+            {
+
+                InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                err = OMX_AllocateBuffer(iOMXEncoder,
+                                         &(temp->pBufHdr),
+                                         aPortIndex,
+                                         ctrl_struct_ptr[ii],
+                                         (OMX_U32)aActualBufferSize);
+            }
+            else
+            {
+                OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
+                err = OMX_AllocateBuffer(iOMXEncoder,
+                                         &(temp->pBufHdr),
+                                         aPortIndex,
+                                         ctrl_struct_ptr[ii],
+                                         (OMX_U32)aActualBufferSize);
+            }
+
+        }
+
+        if (err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::ProvideBuffersToComponent() Problem using/allocating a buffer", iNodeTypeId));
+
+
+            return false;
+        }
+
+    }
+
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+        // after initializing the buffer hdr ptrs, return them
+        // to the mempool
+        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
+    }
+
+    oscl_free(ctrl_struct_ptr);
+    // set the flags
+    if (aIsThisInputBuffer)
+    {
+        iInputBuffersFreed = false;
+    }
+    else
+    {
+        iOutputBuffersFreed = false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ProvideBuffersToComponent() done", iNodeTypeId));
+    return true;
+}
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+        uint32 aNumBuffers,    // number of buffers
+        uint32 aPortIndex,      // port idx
+        bool	aIsThisInputBuffer		// is this input or output
+                                             )
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::FreeBuffersToComponent() enter", iNodeTypeId));
+
+    uint32 ii = 0;
+    OMX_ERRORTYPE err = OMX_ErrorNone;
+    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
+
+    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
+    if (ctrl_struct_ptr == NULL)
+    {
+        return false;
+    }
+
+
+    // Now, go through all buffers and tell component to free them
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+
+        int32 errcode = 0;
+        // get the address where the buf hdr ptr will be stored
+
+        errcode = MemAllocate(ctrl_struct_ptr[ii], aMemPool, aAllocSize);
+        if ((errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL))
+        {
+            if (errcode == OsclErrNoResources)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::FreeBuffersFromComponent ->allocate() failed for no mempool chunk available", iNodeTypeId));
+            }
+            else
+            {
+                // General error
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::FreeBuffersFromComponent ->allocate() failed due to some general error", iNodeTypeId));
+
+                ReportErrorEvent(PVMFFailure);
+                ChangeNodeState(EPVMFNodeError);
+            }
+
+            return false;
+        }
+        // to maintain correct count
+        aMemPool->notifyfreechunkavailable((*this), (OsclAny*) aMemPool);
+
+        if (aIsThisInputBuffer)
+        {
+
+            iNumOutstandingInputBuffers++;
+            // get the buf hdr pointer
+            InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
+            err = OMX_FreeBuffer(iOMXEncoder,
+                                 aPortIndex,
+                                 temp->pBufHdr);
+
+        }
+        else
+        {
+            iNumOutstandingOutputBuffers++;
+            OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
+            err = OMX_FreeBuffer(iOMXEncoder,
+                                 aPortIndex,
+                                 temp->pBufHdr);
+
+        }
+
+        if (err != OMX_ErrorNone)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::FreeBuffersFromComponent() Problem freeing a buffer", iNodeTypeId));
+
+            return false;
+        }
+
+    }
+
+    for (ii = 0; ii < aNumBuffers; ii++)
+    {
+        // after freeing the buffer hdr ptrs, return them
+        // to the mempool (which will itself then be deleted promptly)
+        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
+    }
+
+    oscl_free(ctrl_struct_ptr);
+
+    // mark buffers as freed (so as not to do it twice)
+    if (aIsThisInputBuffer)
+    {
+        iInputBuffersFreed = true;
+    }
+    else
+    {
+        iOutputBuffersFreed = true;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::FreeBuffersFromComponent() done", iNodeTypeId));
+    return true;
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+////////////////////// CALLBACK PROCESSING FOR EVENT HANDLER
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE PVMFOMXEncNode::EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_EVENTTYPE aEvent,
+        OMX_OUT OMX_U32 aData1,
+        OMX_OUT OMX_U32 aData2,
+        OMX_OUT OMX_PTR aEventData)
+{
+    OSCL_UNUSED_ARG(aComponent);
+    OSCL_UNUSED_ARG(aAppData);
+    OSCL_UNUSED_ARG(aEventData);
+
+    switch (aEvent)
+    {
+        case OMX_EventCmdComplete:
+        {
+
+            switch (aData1)
+            {
+                case OMX_CommandStateSet:
+                {
+                    HandleComponentStateChange(aData2);
+                    break;
+                }
+                case OMX_CommandFlush:            //not supported
+                    // nothing to do here yet
+                    break;
+
+                case OMX_CommandPortDisable:
+                {
+                    // if port disable command is done, we can re-allocate the buffers and re-enable the port
+
+                    iProcessingState = EPVMFOMXEncNodeProcessingState_PortReEnable;
+                    iPortIndexForDynamicReconfig =  aData2;
+
+                    RunIfNotReady();
+                    break;
+                }
+                case OMX_CommandPortEnable:
+                    // port enable command is done. Check if the other port also reported change.
+                    // If not, we can start data flow. Otherwise, must start dynamic reconfig procedure for
+                    // the other port as well.
+                {
+                    if (iSecondPortReportedChange)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, dynamic reconfiguration needed on port %d", iNodeTypeId, aData2, iSecondPortToReconfig));
+
+                        iProcessingState = EPVMFOMXEncNodeProcessingState_PortReconfig;
+                        iPortIndexForDynamicReconfig = iSecondPortToReconfig;
+                        iSecondPortReportedChange = false;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                        (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, resuming normal data flow", iNodeTypeId, aData2));
+                        iProcessingState = EPVMFOMXEncNodeProcessingState_ReadyToEncode;
+                        iDynamicReconfigInProgress = false;
+                    }
+                    RunIfNotReady();
+                    break;
+                }
+
+                case OMX_CommandMarkBuffer:
+                    // nothing to do here yet;
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_CommandMarkBuffer - completed - no action taken", iNodeTypeId));
+
+                    break;
+
+                default:
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: Unsupported event", iNodeTypeId));
+                    break;
+                }
+            }//end of switch (aData1)
+
+            break;
+        }//end of case OMX_EventCmdComplete
+
+        case OMX_EventError:
+        {
+
+            if (aData1 == (OMX_U32) OMX_ErrorStreamCorrupt)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventError - Bitstream corrupt error", iNodeTypeId));
+                // Errors from corrupt bitstream are reported as info events
+                ReportInfoEvent(PVMFInfoProcessingFailure, NULL);
+
+            }
+            else
+            {
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventError", iNodeTypeId));
+                // for now, any error from the component will be reported as error
+                ReportErrorEvent(PVMFErrorEvent, NULL, NULL);
+                SetState(EPVMFNodeError);
+            }
+            break;
+
+        }
+
+        case OMX_EventBufferFlag:
+        {
+            // the component is reporting it encountered end of stream flag
+            // we'll send eos when we get the actual last buffer with marked eos
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventBufferFlag (EOS) flag returned from OMX component", iNodeTypeId));
+
+            RunIfNotReady();
+            break;
+        }//end of case OMX_EventBufferFlag
+
+        case OMX_EventMark:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventMark returned from OMX component - no action taken", iNodeTypeId));
+
+            RunIfNotReady();
+            break;
+        }//end of case OMX_EventMark
+
+        case OMX_EventPortSettingsChanged:
+        {
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventPortSettingsChanged returned from OMX component", iNodeTypeId));
+
+            // first check if dynamic reconfiguration is already in progress,
+            // if so, wait until this is completed, and then initiate the 2nd reconfiguration
+            if (iDynamicReconfigInProgress)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventPortSettingsChanged returned for port %d, dynamic reconfig already in progress", iNodeTypeId, aData1));
+
+                iSecondPortToReconfig = aData1;
+                iSecondPortReportedChange = true;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventPortSettingsChanged returned for port %d", iNodeTypeId, aData1));
+
+                iProcessingState = EPVMFOMXEncNodeProcessingState_PortReconfig;
+                iPortIndexForDynamicReconfig = aData1;
+                iDynamicReconfigInProgress = true;
+            }
+
+            RunIfNotReady();
+            break;
+        }//end of case OMX_PortSettingsChanged
+
+        case OMX_EventResourcesAcquired:        //not supported
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::EventHandlerProcessing: OMX_EventResourcesAcquired returned from OMX component - no action taken", iNodeTypeId));
+
+            RunIfNotReady();
+
+            break;
+        }
+
+        default:
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::EventHandlerProcessing:  Unknown Event returned from OMX component - no action taken", iNodeTypeId));
+
+            break;
+        }
+
+    }//end of switch (eEvent)
+
+
+
+    return OMX_ErrorNone;
+}
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+// This function handles the event of OMX component state change
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::HandleComponentStateChange(OMX_U32 encoder_state)
+{
+    switch (encoder_state)
+    {
+        case OMX_StateIdle:
+        {
+            iCurrentEncoderState = OMX_StateIdle;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleComponentStateChange: OMX_StateIdle reached", iNodeTypeId));
+
+            //  this state can be reached either going from OMX_Loaded->OMX_Idle (preparing)
+            //	or going from OMX_Executing->OMX_Idle (stopping)
+
+
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_PREPARE))
+            {
+                iProcessingState = EPVMFOMXEncNodeProcessingState_ReadyToEncode;
+                SetState(EPVMFNodePrepared);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                RunIfNotReady();
+            }
+            else if ((iCurrentCommand.size() > 0) &&
+                     (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_STOP))
+            {
+                // if we are stopped, we won't start until the node gets DoStart command.
+                //	in this case, we are ready to start sending buffers
+                if (iProcessingState == EPVMFOMXEncNodeProcessingState_Stopping)
+                    iProcessingState = EPVMFOMXEncNodeProcessingState_ReadyToEncode;
+                // if the processing state was not stopping, leave the state as it was (continue port reconfiguration)
+                SetState(EPVMFNodePrepared);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+
+                RunIfNotReady();
+            }
+            else if ((iCurrentCommand.size() > 0) &&
+                     (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_FLUSH))
+            {
+                // if there is a flush, similar to the case of stop, we won't start until the node gets
+                // DoStart command. In this case, we'll be ready
+                if (iProcessingState == EPVMFOMXEncNodeProcessingState_Stopping)
+                    iProcessingState = EPVMFOMXEncNodeProcessingState_ReadyToEncode;
+
+
+
+                //Flush is complete.  Go to prepared state.
+                SetState(EPVMFNodePrepared);
+                //resume port input (if possible) so the ports can be re-started.
+                if (iInPort)
+                {
+                    iInPort->ResumeInput();
+                }
+                if (iOutPort)
+                {
+                    iOutPort->ResumeInput();
+                }
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                RunIfNotReady();
+
+            }
+            else if ((iCurrentCommand.size() > 0) &&
+                     (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET))
+            {
+                // State change to Idle was initiated due to Reset. First need to reach idle, and then loaded
+                // Once Idle is reached, we need to initiate idle->loaded transition
+                iStopInResetMsgSent = false;
+                RunIfNotReady();
+            }
+            break;
+        }//end of case OMX_StateIdle
+
+        case OMX_StateExecuting:
+        {
+            iCurrentEncoderState = OMX_StateExecuting;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleComponentStateChange: OMX_StateExecuting reached", iNodeTypeId));
+
+            // this state can be reached going from OMX_Idle -> OMX_Executing (preparing)
+            //	or going from OMX_Pause -> OMX_Executing (coming from pause)
+            //	either way, this is a response to "DoStart" command
+
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_START))
+            {
+                SetState(EPVMFNodeStarted);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+
+                RunIfNotReady();
+            }
+
+            break;
+        }//end of case OMX_StateExecuting
+
+        case OMX_StatePause:
+        {
+            iCurrentEncoderState = OMX_StatePause;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleComponentStateChange: OMX_StatePause reached", iNodeTypeId));
+
+
+            //	This state can be reached going from OMX_Executing-> OMX_Pause
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_PAUSE))
+            {
+                SetState(EPVMFNodePaused);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                RunIfNotReady();
+            }
+
+            break;
+        }//end of case OMX_StatePause
+
+        case OMX_StateLoaded:
+        {
+            iCurrentEncoderState = OMX_StateLoaded;
+
+            //  this state can be reached only going from OMX_Idle ->OMX_Loaded (stopped to reset)
+            //
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::HandleComponentStateChange: OMX_StateLoaded reached", iNodeTypeId));
+            //Check if command's responce is pending
+            if ((iCurrentCommand.size() > 0) &&
+                    (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET))
+            {
+
+                // move this here
+                if (iInPort)
+                {
+                    OSCL_DELETE(((PVMFOMXEncPort*)iInPort));
+                    iInPort = NULL;
+                }
+
+                if (iOutPort)
+                {
+                    OSCL_DELETE(((PVMFOMXEncPort*)iOutPort));
+                    iOutPort = NULL;
+                }
+
+                iDataIn.Unbind();
+
+                // Reset the metadata key list
+                iAvailableMetadataKeys.clear();
+
+
+                iProcessingState = EPVMFOMXEncNodeProcessingState_Idle;
+                //logoff & go back to Created state.
+                SetState(EPVMFNodeIdle);
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                iResetInProgress = false;
+                iResetMsgSent = false;
+            }
+
+            break;
+        }//end of case OMX_StateLoaded
+
+        case OMX_StateInvalid:
+        default:
+        {
+            iCurrentEncoderState = OMX_StateInvalid;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::HandleComponentStateChange: OMX_StateInvalid reached", iNodeTypeId));
+
+            break;
+        }//end of case OMX_StateInvalid
+
+    }//end of switch(encoder_state)
+
+}
+
+
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+////////////////////// CALLBACK PROCESSING FOR EMPTY BUFFER DONE - input buffer was consumed
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE PVMFOMXEncNode::EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+
+    OSCL_UNUSED_ARG(aComponent);
+    OSCL_UNUSED_ARG(aAppData);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::EmptyBufferDoneProcessing: In", iNodeTypeId));
+
+    OSCL_ASSERT((void*) aComponent == (void*) iOMXEncoder); // component should match the component
+    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
+
+    // first, get the buffer "context", i.e. pointer to application private data that contains the
+    // address of the mempool buffer (so that it can be released)
+    InputBufCtrlStruct *pContext = (InputBufCtrlStruct *)(aBuffer->pAppPrivate);
+
+
+
+    // if a buffer is not empty, log a msg, but release anyway
+    if ((aBuffer->nFilledLen > 0) && (iDoNotSaveInputBuffersFlag == false))
+        // if dynamic port reconfig is in progress for input port, don't keep the buffer
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::EmptyBufferDoneProcessing: Input buffer returned non-empty with %d bytes still in it", iNodeTypeId, aBuffer->nFilledLen));
+
+
+    }
+
+    iInputBufferToResendToComponent = NULL;
+
+
+    // input buffer is to be released,
+    // refcount needs to be decremented (possibly - the input msg associated with the buffer will be unbound)
+    // NOTE: in case of "moveable" input buffers (passed into component without copying), unbinding decrements a refcount which eventually results
+    //			in input message being released back to upstream mempool once all its fragments are returned
+    //		in case of input buffers passed into component by copying, unbinding has no effect
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::EmptyBufferDoneProcessing: Release input buffer (with %d refcount remaining of input message)", iNodeTypeId, (pContext->pMediaData).get_count() - 1));
+
+
+    (pContext->pMediaData).Unbind();
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::EmptyBufferDoneProcessing: Release input buffer %x back to mempool", iNodeTypeId, pContext));
+
+    iInBufMemoryPool->deallocate((OsclAny *) pContext);
+
+
+    // the OMX spec says that no error is to be returned
+    return OMX_ErrorNone;
+
+}
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+////////////////////// CALLBACK PROCESSING FOR FILL BUFFER DONE - output buffer is ready
+/////////////////////////////////////////////////////////////////////////////
+OMX_ERRORTYPE PVMFOMXEncNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
+{
+
+    OSCL_UNUSED_ARG(aComponent);
+    OSCL_UNUSED_ARG(aAppData);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: In", iNodeTypeId));
+
+    OSCL_ASSERT((void*) aComponent == (void*) iOMXEncoder); // component should match the component
+    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
+
+    // first, get the buffer "context", i.e. pointer to application private data that contains the
+    // address of the mempool buffer (so that it can be released)
+    OsclAny *pContext = (OsclAny*) aBuffer->pAppPrivate;
+
+
+    // check for EOS flag
+    if ((aBuffer->nFlags & OMX_BUFFERFLAG_EOS))
+    {
+        // EOS received - enable sending EOS msg
+        iIsEOSReceivedFromComponent = true;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Output buffer has EOS set", iNodeTypeId));
+
+    }
+
+    // if a buffer is empty, or if it should not be sent downstream (say, due to state change)
+    // release the buffer back to the pool
+    if ((aBuffer->nFilledLen == 0) || (iDoNotSendOutputBuffersDownstreamFlag == true))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Release output buffer %x back to mempool - buffer empty or not to be sent downstream", iNodeTypeId, pContext));
+
+        iOutBufMemoryPool->deallocate(pContext);
+
+    }
+    else
+    {
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Output frame %d received", iNodeTypeId, iFrameCounter));
+
+        iFrameCounter++;
+        // get pointer to actual buffer data
+        uint8 *pBufdata = ((uint8*) aBuffer->pBuffer);
+        // move the data pointer based on offset info
+        pBufdata += aBuffer->nOffset;
+
+        uint32 bufLen = (uint32) aBuffer->nFilledLen;
+
+        // in case of mp4 streaming and the very 1st buffer, save vol header separately
+        if ((iOutFormat == PVMF_MIME_M4V) && (iVideoEncodeParam.iContentType == EI_M4V_STREAMING)
+                && (iFrameCounter == 1))
+        {
+
+            // save the first buffer since this is the VOL header
+
+            uint refCounterSize = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+            OsclMemoryFragment volHeader;
+            volHeader.ptr = NULL;
+            volHeader.len = aBuffer->nFilledLen; // vol header size should be (28)
+            uint8* memBuffer = (uint8*)iAlloc.allocate(refCounterSize + volHeader.len);
+            oscl_memset(memBuffer, 0, refCounterSize + volHeader.len);
+            OsclRefCounter* refCounter = OSCL_PLACEMENT_NEW(memBuffer, OsclRefCounterDA(memBuffer, (OsclDestructDealloc*) & iAlloc));
+            memBuffer += refCounterSize;
+            volHeader.ptr = (OsclAny*)memBuffer;
+
+            // copy the vol header from OMX buffer
+            oscl_memcpy(volHeader.ptr, pBufdata, volHeader.len);
+
+            // save in class variable
+            iVolHeader = OsclRefCounterMemFrag(volHeader, refCounter, volHeader.len);
+
+            // release the OMX buffer
+            iOutBufMemoryPool->deallocate(pContext);
+            return OMX_ErrorNone;
+        }
+
+        // in case of avc mp4, need to save sps/pps sequences
+        if ((iOutFormat == PVMF_MIME_H264_VIDEO_MP4) && (!iSpsPpsSequenceOver))
+        {
+
+            // detect nal type
+            uint8 *bitstream = pBufdata;
+            int nal_type;
+
+            // adjust the pointers in the iParamSet memfragment
+            uint8 *destptr = (uint8*) iParamSet.getMemFragPtr();
+            uint32 length = iParamSet.getMemFrag().len;
+            uint32 capacity = iParamSet.getCapacity();
+
+            destptr += length;
+
+
+            nal_type = bitstream[0] & 0x1F;
+
+            if (nal_type == 0x07) // SPS type NAL
+            {
+                // can the SPS fit into the buffer
+                if (aBuffer->nFilledLen <= (capacity - length))
+                {
+                    iSPSs[iNumSPSs].ptr = destptr;
+                    iSPSs[iNumSPSs++].len = aBuffer->nFilledLen;
+
+                    oscl_memcpy(destptr, pBufdata, aBuffer->nFilledLen); // copy SPS into iParamSet memfragment
+                    length += aBuffer->nFilledLen;
+                    iParamSet.getMemFrag().len = length; // update length
+                }
+
+
+                // release the OMX buffer
+                iOutBufMemoryPool->deallocate(pContext);
+                return OMX_ErrorNone;
+            }
+            else if (nal_type == 0x08) // PPS type NAL
+            {
+
+                // can the PPS fit into the buffer?
+                if (aBuffer->nFilledLen <= (capacity - length))
+                {
+
+                    iPPSs[iNumPPSs].ptr = destptr;
+                    iPPSs[iNumPPSs++].len = aBuffer->nFilledLen;
+
+                    oscl_memcpy(destptr, pBufdata, aBuffer->nFilledLen); // copy PPS into iParamSet memfragment
+                    length += aBuffer->nFilledLen;
+                    iParamSet.getMemFrag().len = length; // update length
+
+
+                }
+
+                // release the OMX buffer
+                iOutBufMemoryPool->deallocate(pContext);
+                return OMX_ErrorNone;
+            }
+            else
+            {
+                // this is neither SPS nor PPS
+                // stop recording SPS/PPS
+                iSpsPpsSequenceOver = true;
+                iFirstNAL = true; // set indicator of first NAL
+                // send out SPS/PPS recorded so far
+                if (((PVMFOMXEncPort*)iOutPort))
+                {
+                    ((PVMFOMXEncPort*)iOutPort)->SendSPS_PPS(iSPSs, iNumSPSs, iPPSs, iNumPPSs);
+                }
+            }
+
+        }
+
+        // adjust ptr to data to expose the NAL sync word if necessary
+        if ((iOutFormat == PVMF_MIME_H264_VIDEO_RAW) &&
+                (iOMXComponentSupportsExternalOutputBufferAlloc) &&
+                ((iFirstNAL == true) || (iEndOfNALFlagPrevious != 0))
+           )
+        {
+            pBufdata -= 4;
+            bufLen += 4;
+        }
+
+        // otherwise, queue output buffer
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Wrapping buffer %x of size %d", iNodeTypeId, pBufdata, aBuffer->nFilledLen));
+        // wrap the buffer into the MediaDataImpl wrapper, and queue it for sending downstream
+        // wrapping will create a refcounter. When refcounter goes to 0 i.e. when media data
+        // is released in downstream components, the custom deallocator will automatically release the buffer back to the
+        //	mempool. To do that, the deallocator needs to have info about Context
+        // NOTE: we had to wait until now to wrap the buffer data because we only know
+        //			now where the actual data is located (based on buffer offset)
+        OsclSharedPtr<PVMFMediaDataImpl> MediaDataCurr = WrapOutputBuffer(pBufdata, bufLen, pContext);
+
+        // if you can't get the MediaDataCurr, release the buffer back to the pool
+        if (MediaDataCurr.GetRep() == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Problem wrapping buffer %x of size %d - releasing the buffer", iNodeTypeId, pBufdata, aBuffer->nFilledLen));
+
+            iOutBufMemoryPool->deallocate(pContext);
+        }
+        else
+        {
+            OsclSharedPtr<PVMFMediaDataImpl> MediaDataOut;
+
+            //DV - NOTE:
+            //In case of AVC, OMX_EndOfFrameFlag is used to mark the end of NAL
+            //				  End of frame is determined by comparing timestamps
+            //				As a consequence, there is a lag of one buffer
+            //				i.e. we send/queue the previous buffer and keep the current one so that
+            //				When the next buffer arrives, we can compare timestamps etc.
+
+            // In case of MP4, OMX_EndOFFrameFlag is used to mark end of frame and there is no lag
+
+            if ((iOutFormat == PVMF_MIME_H264_VIDEO_MP4) || (iOutFormat == PVMF_MIME_H264_VIDEO_RAW))
+            {
+
+                MediaDataOut = iPreviousMediaData; // send out previous media data
+
+                // copy data to be attached with outgoing media data from previous buffer
+                iTimeStampOut = iTimeStampPrevious;
+                iKeyFrameFlagOut = iKeyFrameFlagPrevious;
+                iEndOfNALFlagOut = iEndOfNALFlagPrevious;
+                // figure out if we need to set end of frame based on TS
+                if (aBuffer->nTimeStamp != iTimeStampPrevious)
+                    iEndOfFrameFlagOut = 1;
+                else
+                    iEndOfFrameFlagOut = 0;
+                iBufferLenOut = iBufferLenPrevious;
+
+                // now read the info for the current data
+                iPreviousMediaData = MediaDataCurr;
+                // record timestamp, flags etc.
+                iTimeStampPrevious = aBuffer->nTimeStamp;
+                // check for Key Frame
+                iKeyFrameFlagPrevious = (aBuffer->nFlags & OMX_BUFFERFLAG_SYNCFRAME);
+                // for avc, ENDOFFRAMEFLAG is used to delimit NALs
+                iEndOfNALFlagPrevious = (aBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME);
+                iBufferLenPrevious = bufLen;
+
+
+            }
+            else // MP4 case
+            {
+
+                MediaDataOut = MediaDataCurr;
+                // record timestamp, flags etc.
+                iTimeStampOut = aBuffer->nTimeStamp;
+                // check for Key Frame
+                iKeyFrameFlagOut = (aBuffer->nFlags & OMX_BUFFERFLAG_SYNCFRAME);
+                iEndOfNALFlagOut = 0; // set this to 0 for mp4
+                //check for END OF FRAME FLAG
+                iEndOfFrameFlagOut = (aBuffer->nFlags & OMX_BUFFERFLAG_ENDOFFRAME);
+                iBufferLenOut = aBuffer->nFilledLen;
+
+
+            }
+            // if there's a problem queuing output buffer, MediaDataCurr will expire at end of scope and
+            // release buffer back to the pool, (this should not be the case)
+
+            // queue only if not the first NAL
+            if (!iFirstNAL)
+            {
+                if (QueueOutputBuffer(MediaDataOut, iBufferLenOut))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Buffer %x of size %d queued - reschedule the node to send out", iNodeTypeId, pBufdata, aBuffer->nFilledLen));
+
+                    // if queing went OK,
+                    // re-schedule the node so that outgoing queue can be emptied (unless the outgoing port is busy)
+                    if ((iOutPort) && !(iOutPort->IsConnectedPortBusy()))
+                        RunIfNotReady();
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Problem queing buffer %x of size %d - releasing the buffer", iNodeTypeId, pBufdata, aBuffer->nFilledLen));
+                }
+            }
+            else
+            {
+                iFirstNAL = false;
+            }
+
+            // if EOS and AVC (with a lag), queue also the last buffer
+            if ((aBuffer->nFlags & OMX_BUFFERFLAG_EOS) &&
+                    ((iOutFormat == PVMF_MIME_H264_VIDEO_MP4) || (iOutFormat == PVMF_MIME_H264_VIDEO_RAW))
+               )
+            {
+
+                MediaDataOut = iPreviousMediaData; // send out previous media data
+
+                // copy data to be attached with outgoing media data from previous buffer
+                iTimeStampOut = iTimeStampPrevious;
+                iKeyFrameFlagOut = iKeyFrameFlagPrevious;
+                iEndOfNALFlagOut =   1;
+                iEndOfFrameFlagOut = 1;
+
+                iBufferLenOut = iBufferLenPrevious;
+
+                if (QueueOutputBuffer(MediaDataOut, iBufferLenOut))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Buffer %x of size %d queued - reschedule the node to send out", iNodeTypeId, pBufdata, aBuffer->nFilledLen));
+
+                    // if queing went OK,
+                    // re-schedule the node so that outgoing queue can be emptied (unless the outgoing port is busy)
+                    if ((iOutPort) && !(iOutPort->IsConnectedPortBusy()))
+                        RunIfNotReady();
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "PVMFOMXEncNode-%s::FillBufferDoneProcessing: Problem queing buffer %x of size %d - releasing the buffer", iNodeTypeId, pBufdata, aBuffer->nFilledLen));
+                }
+
+            }
+        }
+
+    }
+    // the OMX spec says that no error is to be returned
+    return OMX_ErrorNone;
+
+}
+////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////// Put output buffer in outgoing queue //////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen)
+{
+
+    bool status = true;
+    PVMFSharedMediaDataPtr mediaDataOut;
+    int32 leavecode = 0;
+
+    // NOTE: ASSUMPTION IS THAT OUTGOING QUEUE IS BIG ENOUGH TO QUEUE ALL THE OUTPUT BUFFERS
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::QueueOutputFrame: In", iNodeTypeId));
+
+    // First check if we can put outgoing msg. into the queue
+    if (iOutPort->IsOutgoingQueueBusy())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "PVMFOMXEncNode-%s::QueueOutputFrame() OutgoingQueue is busy", iNodeTypeId));
+        return false;
+    }
+
+    OSCL_TRY(leavecode,
+             mediaDataOut = PVMFMediaData::createMediaData(mediadataimplout, iMediaDataMemPool););
+    if (leavecode == 0)
+    {
+
+        uint32 marker_bits = mediaDataOut->getMarkerInfo();
+
+        if (iEndOfFrameFlagOut != 0)
+        {
+            marker_bits |= PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
+        }
+
+        if (iKeyFrameFlagOut != 0)
+        {
+            marker_bits |= PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT;
+        }
+
+        if (iEndOfNALFlagOut != 0)
+        {
+            marker_bits |= PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
+        }
+
+        // attach marker bit
+        mediaDataOut->setMarkerInfo(marker_bits);
+
+
+        // Update the filled length of the fragment
+        mediaDataOut->setMediaFragFilledLen(0, aDataLen);
+
+        // Set timestamp
+        mediaDataOut->setTimestamp(iTimeStampOut);
+
+        // Set Streamid
+        mediaDataOut->setStreamID(iStreamID);
+
+        // Set sequence number
+        mediaDataOut->setSeqNum(iSeqNum++);
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iDataPathLogger, PVLOGMSG_INFO, (0, ":PVMFOMXEncNode::QueueOutputFrame(): - SeqNum=%d, TS=%d", iNodeTypeId, iSeqNum, iTimeStampOut));
+
+
+        // Check if Fsi needs to be sent (VOL header)
+        if (sendYuvFsi && (iVideoEncodeParam.iContentType == EI_M4V_STREAMING))
+        {
+
+            mediaDataOut->setFormatSpecificInfo(iVolHeader);
+
+            // Reset the flag
+            sendYuvFsi = false;
+        }
+        else
+        {
+            sendYuvFsi = false;
+        }
+
+        // Send frame to downstream node
+        PVMFSharedMediaMsgPtr mediaMsgOut;
+        convertToPVMFMediaMsg(mediaMsgOut, mediaDataOut);
+
+        if (iOutPort && (iOutPort->QueueOutgoingMsg(mediaMsgOut) == PVMFSuccess))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVMFOMXEncNode-%s::QueueOutputFrame(): Queued frame OK ", iNodeTypeId));
+
+        }
+        else
+        {
+            // we should not get here because we always check for whether queue is busy or not
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::QueueOutputFrame(): Send frame failed", iNodeTypeId));
+            return false;
+        }
+
+
+
+
+    }//end of if (leavecode==0)
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::QueueOutputFrame() call PVMFMediaData::createMediaData is failed", iNodeTypeId));
+        return false;
+    }
+
+    return status;
+
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////// Attach a MediaDataImpl wrapper (refcount, deallocator etc.)
+/////////////////////////////// to the output buffer /////////////////////////////////////////
+OsclSharedPtr<PVMFMediaDataImpl> PVMFOMXEncNode::WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext)
+{
+    // wrap output buffer into a mediadataimpl
+    uint32 aligned_class_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+    uint32 aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PVOMXBufferSharedPtrWrapperCombinedCleanupDA));
+    uint32 aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+    uint8 *my_ptr = (uint8*) oscl_malloc(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
+
+    if (my_ptr == NULL)
+    {
+        OsclSharedPtr<PVMFMediaDataImpl> null_buff(NULL, NULL);
+        return null_buff;
+    }
+    // create a deallocator and pass the buffer_allocator to it as well as pointer to data that needs to be returned to the mempool
+    PVOMXBufferSharedPtrWrapperCombinedCleanupDA *cleanup_ptr =
+        OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVOMXBufferSharedPtrWrapperCombinedCleanupDA(iOutBufMemoryPool, pContext));
+
+    //ModifiedPvciBufferCombinedCleanup* cleanup_ptr = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size,ModifiedPvciBufferCombinedCleanup(aOutput.GetRefCounter()) );
+
+    // create the ref counter after the cleanup object (refcount is set to 1 at creation)
+    OsclRefCounterDA *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
+
+    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
+
+    PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer((void *) pData, // ptr to data
+                                        aDataLen, // capacity
+                                        my_refcnt));   // ref counter
+
+    OsclSharedPtr<PVMFMediaDataImpl> MediaDataImplOut(media_data_ptr, my_refcnt);
+
+    MediaDataImplOut->setMediaFragFilledLen(0, aDataLen);
+
+    return MediaDataImplOut;
+
+}
+//////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::SendBeginOfMediaStreamCommand()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendBeginOfMediaStreamCommand() In", iNodeTypeId));
+
+    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
+    // Set the formatID, timestamp, sequenceNumber and streamID for the media message
+    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
+    sharedMediaCmdPtr->setTimestamp(iBOSTimestamp);
+    //reset the sequence number
+    uint32 seqNum = 0;
+    sharedMediaCmdPtr->setSeqNum(seqNum);
+    sharedMediaCmdPtr->setStreamID(iStreamID);
+
+    PVMFSharedMediaMsgPtr mediaMsgOut;
+    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
+    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::SendBeginOfMediaStreamCommand() Outgoing queue busy", iNodeTypeId));
+        return false;
+    }
+
+    iSendBOS = false;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendBeginOfMediaStreamCommand() BOS Sent StreamID %d", iNodeTypeId, iStreamID));
+    return true;
+}
+////////////////////////////////////
+bool PVMFOMXEncNode::SendEndOfTrackCommand(void)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendEndOfTrackCommand() In", iNodeTypeId));
+
+    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
+
+    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
+
+    // Set the timestamp
+    sharedMediaCmdPtr->setTimestamp(iEndOfDataTimestamp);
+
+    // Set Streamid
+    sharedMediaCmdPtr->setStreamID(iStreamID);
+
+    // Set the sequence number
+    sharedMediaCmdPtr->setSeqNum(iSeqNum++);
+
+    PVMFSharedMediaMsgPtr mediaMsgOut;
+    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
+    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
+    {
+        // this should not happen because we check for queue busy before calling this function
+        return false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SendEndOfTrackCommand() Out", iNodeTypeId));
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+//The various command handlers call this routine when a command is complete.
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::CommandComplete(PVMFOMXEncNodeCmdQ& aCmdQ, PVMFOMXEncNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::CommandComplete Id %d Cmd %d Status %d Context %d Data %d", iNodeTypeId
+                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoInit(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoInit() In", iNodeTypeId));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        {
+            SetState(EPVMFNodeInitialized);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        }
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoPrepare(PVMFOMXEncNodeCommand& aCmd)
+{
+    OMX_ERRORTYPE err = OMX_ErrorNone;
+    OMX_STRING Role = NULL;
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        {
+            if (NULL == iInPort)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            }
+
+
+            // by now the encode parameters have been set
+
+            if (iOutFormat == PVMF_MIME_H2631998 ||
+                    iOutFormat == PVMF_MIME_H2632000)
+            {
+                Role = (OMX_STRING)"video_encoder.h263";
+                iNodeTypeId = LOG_ID_VIDEO_H263;
+            }
+            else if (iOutFormat == PVMF_MIME_M4V)
+            {
+                Role = (OMX_STRING)"video_encoder.mpeg4";
+                iNodeTypeId = LOG_ID_VIDEO_M4V;
+            }
+            else if (iOutFormat == PVMF_MIME_H264_VIDEO_RAW ||
+                     iOutFormat == PVMF_MIME_H264_VIDEO_MP4)
+            {
+                Role = (OMX_STRING)"video_encoder.avc";
+                iNodeTypeId = LOG_ID_VIDEO_AVC;
+                iFirstNAL = true; // set this flag to prevent node from queueing the first
+                // buffer
+            }
+            else if (iOutFormat == PVMF_MIME_AMR_IETF ||
+                     iOutFormat == PVMF_MIME_AMR_IF2)
+            {
+                Role = (OMX_STRING)"audio_encoder.amr";
+                iNodeTypeId = LOG_ID_AUDIO_AMR;
+            }
+            else
+            {
+                // Illegal codec specified.
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoPrepare() Input port format other then codec type", iNodeTypeId));
+                CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+                return;
+            }
+
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::Initializing OMX component and encoder for role %s", iNodeTypeId, Role));
+
+            /* Set callback structure */
+            iCallbacks.EventHandler    = CallbackEventHandlerEnc; //event_handler;
+            iCallbacks.EmptyBufferDone = CallbackEmptyBufferDoneEnc; //empty_buffer_done;
+            iCallbacks.FillBufferDone  = CallbackFillBufferDoneEnc; //fill_buffer_done;
+
+
+            // determine components which can fit the role
+            // then, create the component. If multiple components fit the role,
+            // the first one registered will be selected. If that one fails to
+            // be created, the second one in the list is selected etc.
+            OMX_U32 num_comps = 0;
+            OMX_STRING *CompOfRole;
+            // call once to find out the number of components that can fit the role
+            OMX_GetComponentsOfRole(Role, &num_comps, NULL);
+            uint32 ii;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::DoPrepare(): There are %d components of role %s ", iNodeTypeId, num_comps, Role));
+
+            if (num_comps > 0)
+            {
+                CompOfRole = (OMX_STRING *)oscl_malloc(num_comps * sizeof(OMX_STRING));
+
+                for (ii = 0; ii < num_comps; ii++)
+                    CompOfRole[ii] = (OMX_STRING) oscl_malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
+
+                // call 2nd time to get the component names
+                OMX_GetComponentsOfRole(Role, &num_comps, (OMX_U8 **)CompOfRole);
+
+                for (ii = 0; ii < num_comps; ii++)
+                {
+                    // try to create component
+                    err = OMX_GetHandle(&iOMXEncoder, (OMX_STRING) CompOfRole[ii], (OMX_PTR) this, (OMX_CALLBACKTYPE *) & iCallbacks);
+                    // if successful, no need to continue
+                    if ((err == OMX_ErrorNone) && (iOMXEncoder != NULL))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                        (0, "PVMFOMXEncNode-%s::DoPrepare(): Got Component %s handle ", iNodeTypeId, CompOfRole[ii]));
+
+                        break;
+                    }
+                    else
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                        (0, "PVMFOMXEncNode-%s::DoPrepare(): Cannot get component %s handle, try another component if available", iNodeTypeId, CompOfRole[ii]));
+                    }
+
+                }
+                // whether successful or not, need to free CompOfRoles
+                for (ii = 0; ii < num_comps; ii++)
+                {
+                    oscl_free(CompOfRole[ii]);
+                    CompOfRole[ii] = NULL;
+                }
+
+                oscl_free(CompOfRole);
+                // check if there was a problem
+                if ((err != OMX_ErrorNone) || (iOMXEncoder == NULL))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::Can't get handle for encoder!", iNodeTypeId));
+                    iOMXEncoder = NULL;
+                    CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                    return;
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::No component can handle role %s !", iNodeTypeId, Role));
+                iOMXEncoder = NULL;
+                CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                return;
+            }
+
+
+
+            if (!iOMXEncoder)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            OMX_PARAM_COMPONENTROLETYPE RoleParam;
+            CONFIG_SIZE_AND_VERSION(RoleParam);
+            oscl_strncpy((OMX_STRING)RoleParam.cRole, (OMX_STRING)Role, OMX_MAX_STRINGNAME_SIZE);
+            err = OMX_SetParameter(iOMXEncoder, OMX_IndexParamStandardComponentRole, &RoleParam);
+            if (err != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPrepare() Problem setting component role", iNodeTypeId));
+                // ignore error since not all components may support this parameter
+            }
+
+            // GET CAPABILITY FLAGS FROM PV COMPONENT, IF this fails, use defaults
+            PV_OMXComponentCapabilityFlagsType Cap_flags;
+            err = OMX_GetParameter(iOMXEncoder, (OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX, &Cap_flags);
+            if (err != OMX_ErrorNone)
+            {
+                SetDefaultCapabilityFlags();
+            }
+            else
+            {
+                iIsOMXComponentMultiThreaded = (OMX_TRUE == Cap_flags.iIsOMXComponentMultiThreaded) ? true : false;
+                iOMXComponentSupportsExternalInputBufferAlloc = (OMX_TRUE == Cap_flags.iOMXComponentSupportsExternalInputBufferAlloc) ? true : false;
+                iOMXComponentSupportsExternalOutputBufferAlloc = (OMX_TRUE == Cap_flags.iOMXComponentSupportsExternalOutputBufferAlloc) ? true : false;
+                iOMXComponentSupportsMovableInputBuffers = (OMX_TRUE == Cap_flags.iOMXComponentSupportsMovableInputBuffers) ? true : false;
+                iOMXComponentSupportsPartialFrames = (OMX_TRUE == Cap_flags.iOMXComponentSupportsPartialFrames) ? true : false;
+                iOMXComponentNeedsNALStartCode = (OMX_FALSE == Cap_flags.iOMXComponentSupportsPartialFrames) ? true : false;
+                iOMXComponentCanHandleIncompleteFrames = (OMX_TRUE == Cap_flags.iOMXComponentCanHandleIncompleteFrames) ? true : false;
+            }
+
+
+            // find out about parameters
+            if ((iOutFormat == PVMF_MIME_AMR_IETF) || (iOutFormat == PVMF_MIME_AMR_IF2))
+            {
+                if (!NegotiateAudioComponentParameters())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoPrepare() Cannot get component parameters", iNodeTypeId));
+
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                    return;
+                }
+            }
+            else
+            {
+
+                if (!NegotiateVideoComponentParameters())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoPrepare() Cannot get component parameters", iNodeTypeId));
+
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                    return;
+                }
+            }
+
+            // create active objects to handle callbacks in case of multithreaded implementation
+
+            // NOTE: CREATE THE THREADSAFE CALLBACK AOs REGARDLESS OF WHETHER MULTITHREADED COMPONENT OR NOT
+            //		If it is not multithreaded, we won't use them
+            //		The Flag iIsComponentMultiThreaded decides which mechanism is used for callbacks.
+            //		This flag is set by looking at component capabilities (or to true by default)
+
+            if (iThreadSafeHandlerEventHandler)
+            {
+                OSCL_DELETE(iThreadSafeHandlerEventHandler);
+                iThreadSafeHandlerEventHandler = NULL;
+            }
+            // substitute default parameters: observer(this node),queuedepth(3),nameAO for logging
+            // Get the priority of the encoder node, and set the threadsafe callback AO priority to 1 higher
+
+            iThreadSafeHandlerEventHandler = OSCL_NEW(EventHandlerThreadSafeCallbackAOEnc, (this, 10, "EventHandlerAO", Priority() + 2));
+
+            if (iThreadSafeHandlerEmptyBufferDone)
+            {
+                OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
+                iThreadSafeHandlerEmptyBufferDone = NULL;
+            }
+            // use queue depth of iNumInputBuffers to prevent deadlock
+            iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAOEnc, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1));
+
+            if (iThreadSafeHandlerFillBufferDone)
+            {
+                OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
+                iThreadSafeHandlerFillBufferDone = NULL;
+            }
+            // use queue depth of iNumOutputBuffers to prevent deadlock
+            iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAOEnc, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1));
+
+            if ((iThreadSafeHandlerEventHandler == NULL) ||
+                    (iThreadSafeHandlerEmptyBufferDone == NULL) ||
+                    (iThreadSafeHandlerFillBufferDone == NULL)
+               )
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::Can't get threadsafe callbacks for encoder!", iNodeTypeId));
+                iOMXEncoder = NULL;
+            }
+
+
+            // Init Encoder
+            iCurrentEncoderState = OMX_StateLoaded;
+
+            /* Change state to OMX_StateIdle from OMX_StateLoaded. */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::DoPrepare(): Changing Component state Loaded -> Idle ", iNodeTypeId));
+
+            err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+            if (err != OMX_ErrorNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPrepare() Can't send StateSet command!", iNodeTypeId));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+
+            /* Allocate input buffers */
+            if (!CreateInputMemPool(iNumInputBuffers))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPrepare() Can't allocate mempool for input buffers!", iNodeTypeId));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
+                                           iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                           iNumInputBuffers, // number of buffers
+                                           iOMXComponentInputBufferSize, // actual buffer size
+                                           iInputPortIndex, // port idx
+                                           iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
+                                           true // this is input
+                                          ))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPrepare() Component can't use input buffers!", iNodeTypeId));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+
+            /* Allocate output buffers */
+            if (!CreateOutMemPool(iNumOutputBuffers))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPrepare() Can't allocate mempool for output buffers!", iNodeTypeId));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+            if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
+                                           iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                           iNumOutputBuffers, // number of buffers
+                                           iOMXComponentOutputBufferSize, // actual buffer size
+                                           iOutputPortIndex, // port idx
+                                           iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
+                                           false // this is not input
+                                          ))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPrepare() Component can't use output buffers!", iNodeTypeId));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
+                return;
+            }
+
+
+            //this command is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until it completes. We have to wait for
+            // OMX component state transition to complete
+
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+        }
+        break;
+        case EPVMFNodePrepared:
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoStart(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoStart() In", iNodeTypeId));
+
+    iDiagnosticsLogged = false;
+
+    PVMFStatus status = PVMFSuccess;
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_START == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
+
+
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodePrepared:
+        case EPVMFNodePaused:
+        {
+            //Get state of OpenMAX encoder
+            err = OMX_GetState(iOMXEncoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoStart(): Can't get State of encoder!", iNodeTypeId));
+
+                sState = OMX_StateInvalid;
+            }
+#ifdef _TEST_AE_ERROR_HANDLING
+            if (iErrorHandlingInit)
+            {
+                //some random state ,we want Init to fail
+
+                sState = OMX_StateInvalid;
+            }
+#endif
+            if ((sState == OMX_StateIdle) || (sState == OMX_StatePause))
+            {
+                /* Change state to OMX_StateExecuting form OMX_StateIdle. */
+                // init the flag
+                iDoNotSendOutputBuffersDownstreamFlag = false; // or if output was not being sent downstream due to state changes
+                // re-anable sending output
+
+                iDoNotSaveInputBuffersFlag = false;
+
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::DoStart() Changing Component state Idle->Executing", iNodeTypeId));
+
+                err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoStart(): Can't send StateSet command to encoder!", iNodeTypeId));
+
+                    status = PVMFErrInvalidState;
+                }
+
+            }
+            else
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoStart(): Encoder is not in the Idle or Pause state!", iNodeTypeId));
+
+                status = PVMFErrInvalidState;
+            }
+
+
+        }
+        break;
+
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+
+    if (status == PVMFErrInvalidState)
+    {
+        CommandComplete(iInputCommands, aCmd, status);
+    }
+    else
+    {
+        //this command is asynchronous.  move the command from
+        //the input command queue to the current command, where
+        //it will remain until it completes.
+        int32 err;
+        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+        if (err != OsclErrNone)
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        }
+        iInputCommands.Erase(&aCmd);
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoStop(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoStop() In", iNodeTypeId));
+
+    LogDiagnostics();
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_STOP == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        case EPVMFNodePrepared:
+            // Stop data source
+            // This will also prevent execution of HandleProcessingState
+
+            iDataIn.Unbind();
+            iPreviousMediaData.Unbind();
+            if ((iOutFormat == PVMF_MIME_H264_VIDEO_MP4) || (iOutFormat == PVMF_MIME_H264_VIDEO_RAW))
+            {
+                // prepare for next start (if it comes)
+                iFirstNAL = true;
+            }
+            // Clear queued messages in ports
+            if (iInPort)
+            {
+                iInPort->ClearMsgQueues();
+            }
+
+            if (iOutPort)
+            {
+                iOutPort->ClearMsgQueues();
+            }
+
+            // Clear the data flags
+
+            iEndOfDataReached = false;
+            iIsEOSSentToComponent = false;
+            iIsEOSReceivedFromComponent = false;
+
+
+            iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
+            iDoNotSaveInputBuffersFlag = true;
+
+
+            //Get state of OpenMAX encoder
+            err = OMX_GetState(iOMXEncoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoStop(): Can't get State of encoder!", iNodeTypeId));
+
+                sState = OMX_StateInvalid;
+            }
+
+            if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
+            {
+                /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::DoStop() Changing Component State Executing->Idle or Pause->Idle", iNodeTypeId));
+
+                err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoStop(): Can't send StateSet command to encoder!", iNodeTypeId));
+
+                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                    break;
+                }
+
+                // prevent the node from sending more buffers etc.
+                // if port reconfiguration is in process, let the state remain one of the port config states
+                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
+                if (iProcessingState == EPVMFOMXEncNodeProcessingState_ReadyToEncode)
+                    iProcessingState = EPVMFOMXEncNodeProcessingState_Stopping;
+
+            }
+            else
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoStop(): Encoder is not in the Executing or Pause state!", iNodeTypeId));
+
+                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                break;
+            }
+
+            //this command is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until it completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoFlush(PVMFOMXEncNodeCommand& aCmd)
+{
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_FLUSH == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            //the flush is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until the flush completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            //Notify all ports to suspend their input
+            if (iInPort)
+            {
+                iInPort->SuspendInput();
+            }
+            RunIfNotReady();
+            if (iOutPort)
+            {
+                iOutPort->SuspendInput();
+            }
+            // Stop data source
+
+            // DV: Sending "OMX_CommandFlush" to the encoder;
+            // Not used because PV Flush command expects data to be processed before getting out
+            iDoNotSendOutputBuffersDownstreamFlag = true; // collect output buffers
+
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoPause(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoPause() In", iNodeTypeId));
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_PAUSE == iErrorNodeCmd)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+
+
+            //Get state of OpenMAX encoder
+            err = OMX_GetState(iOMXEncoder, &sState);
+            if (err != OMX_ErrorNone)
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPause(): Can't get State of encoder!", iNodeTypeId));
+
+                sState = OMX_StateInvalid;
+            }
+
+            if (sState == OMX_StateExecuting)
+            {
+                /* Change state to OMX_StatePause from OMX_StateExecuting. */
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVMFOMXEncNode-%s::DoPause() Changing Component State Executing->Idle", iNodeTypeId));
+
+                err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StatePause, NULL);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoPause(): Can't send StateSet command to encoder!", iNodeTypeId));
+
+                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                    break;
+                }
+
+            }
+            else
+            {
+                //Error condition report
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoPause(): Encoder is not in the Executing state!", iNodeTypeId));
+                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                break;
+            }
+
+            //this command is asynchronous.  move the command from
+            //the input command queue to the current command, where
+            //it will remain until it completes.
+            int32 err;
+            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+            if (err != OsclErrNone)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+            iInputCommands.Erase(&aCmd);
+
+            break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoReset(PVMFOMXEncNodeCommand& aCmd)
+{
+
+    OMX_ERRORTYPE  err;
+    OMX_STATETYPE sState;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DoReset() In", iNodeTypeId));
+
+    LogDiagnostics();
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        case EPVMFNodeError:
+        {
+            //Check if encoder is initilized
+            if (iOMXEncoder != NULL)
+            {
+                //Get state of OpenMAX encoder
+                err = OMX_GetState(iOMXEncoder, &sState);
+                if (err != OMX_ErrorNone)
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoReset(): Can't get State of encoder!", iNodeTypeId));
+                    if (iResetInProgress)
+                    {
+                        // cmd is in current q
+                        iResetInProgress = false;
+                        if ((iCurrentCommand.size() > 0) &&
+                                (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+                           )
+                        {
+                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
+                        }
+
+                    }
+                    else
+                    {
+                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                    }
+                    return;
+                }
+
+                if (sState == OMX_StateLoaded)
+                {
+                    // this is a value obtained by synchronous call to component. Either the component was
+                    // already in this state without node issuing any commands,
+                    // or perhaps we started the Reset, but the callback notification has not yet arrived.
+                    if (iResetInProgress)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "PVMFOMXEncNode-%s::DoReset() OMX comp is in loaded state. Wait for official callback to change variables etc.", iNodeTypeId));
+                        return;
+                    }
+                    else
+                    {
+                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
+                        return;
+                    }
+                }
+
+                if (sState == OMX_StateIdle)
+                {
+
+
+                    //this command is asynchronous.  move the command from
+                    //the input command queue to the current command, where
+                    //it will remain until it is completed.
+                    if (!iResetInProgress)
+                    {
+                        int32 err;
+                        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+                        if (err != OsclErrNone)
+                        {
+                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                            return;
+                        }
+                        iInputCommands.Erase(&aCmd);
+
+                        iResetInProgress = true;
+                    }
+
+                    // if buffers aren't all back (due to timing issues with different callback AOs
+                    //		state change can be reported before all buffers are returned)
+                    if (iNumOutstandingInputBuffers > 0 || iNumOutstandingOutputBuffers > 0)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "PVMFOMXEncNode-%s::DoReset() Waiting for %d input and-or %d output buffers", iNodeTypeId, iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
+
+                        return;
+                    }
+
+                    if (!iResetMsgSent)
+                    {
+                        // We can come here only if all buffers are already back
+                        // Don't repeat any of this twice.
+                        /* Change state to OMX_StateLoaded form OMX_StateIdle. */
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "PVMFOMXEncNode-%s::DoReset() Changing Component State Idle->Loaded", iNodeTypeId));
+
+                        err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateLoaded, NULL);
+                        if (err != OMX_ErrorNone)
+                        {
+                            //Error condition report
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "PVMFOMXEncNode-%s::DoReset(): Can't send StateSet command to encoder!", iNodeTypeId));
+                        }
+
+                        iResetMsgSent = true;
+
+
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "PVMFOMXEncNode-%s::DoReset() freeing output buffers", iNodeTypeId));
+
+                        if (false == iOutputBuffersFreed)
+                        {
+                            if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
+                                                          iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                          iNumOutputBuffers, // number of buffers
+                                                          iOutputPortIndex, // port idx
+                                                          false // this is not input
+                                                         ))
+                            {
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                (0, "PVMFOMXEncNode-%s::DoReset() Cannot free output buffers ", iNodeTypeId));
+
+                                if (iResetInProgress)
+                                {
+                                    iResetInProgress = false;
+                                    if ((iCurrentCommand.size() > 0) &&
+                                            (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+                                       )
+                                    {
+                                        CommandComplete(iCurrentCommand, iCurrentCommand.front() , PVMFErrResource);
+                                    }
+                                }
+
+                            }
+
+                        }
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "PVMFOMXEncNode-%s::DoReset() freeing input buffers ", iNodeTypeId));
+                        if (false == iInputBuffersFreed)
+                        {
+                            if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
+                                                          iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                                          iNumInputBuffers, // number of buffers
+                                                          iInputPortIndex, // port idx
+                                                          true // this is input
+                                                         ))
+                            {
+                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                (0, "PVMFOMXEncNode-%s::DoReset() Cannot free input buffers ", iNodeTypeId));
+
+                                if (iResetInProgress)
+                                {
+                                    iResetInProgress = false;
+                                    if ((iCurrentCommand.size() > 0) &&
+                                            (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+                                       )
+                                    {
+                                        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
+                                    }
+                                }
+
+
+                            }
+                        }
+
+
+
+                        iEndOfDataReached = false;
+                        iIsEOSSentToComponent = false;
+                        iIsEOSReceivedFromComponent = false;
+
+
+
+                        // also, perform Port deletion when the component replies with the command
+                        // complete, not right here
+                    } // end of if(iResetMsgSent)
+
+
+                    return;
+
+                }
+                if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
+                {
+                    /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
+
+                    if (!iStopInResetMsgSent)
+                    {
+
+                        // don't send twice in a row
+
+                        iDataIn.Unbind();
+                        iPreviousMediaData.Unbind();
+                        if ((iOutFormat == PVMF_MIME_H264_VIDEO_MP4) || (iOutFormat == PVMF_MIME_H264_VIDEO_RAW))
+                        {
+                            // prepare for next start (if it comes)
+                            iFirstNAL = true;
+                        }
+                        // Clear queued messages in ports
+                        if (iInPort)
+                        {
+                            iInPort->ClearMsgQueues();
+                        }
+
+                        if (iOutPort)
+                        {
+                            iOutPort->ClearMsgQueues();
+                        }
+
+                        // Clear the data flags
+
+                        iEndOfDataReached = false;
+                        iIsEOSSentToComponent = false;
+                        iIsEOSReceivedFromComponent = false;
+
+
+                        iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
+                        iDoNotSaveInputBuffersFlag = true;
+
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "PVMFOMXEncNode-%s::DoReset() Changing Component State Executing->Idle or Pause->Idle", iNodeTypeId));
+
+                        err = OMX_SendCommand(iOMXEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
+                        if (err != OMX_ErrorNone)
+                        {
+                            //Error condition report
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                            (0, "PVMFOMXEncNode-%s::DoReset(): Can't send StateSet command to Encoder!", iNodeTypeId));
+
+                            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                            break;
+                        }
+
+                        iStopInResetMsgSent = true;
+
+                        // prevent the node from sending more buffers etc.
+                        // if port reconfiguration is in process, let the state remain one of the port config states
+                        //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
+                        if (iProcessingState == EPVMFOMXEncNodeProcessingState_ReadyToEncode)
+                            iProcessingState = EPVMFOMXEncNodeProcessingState_Stopping;
+                    }
+                    return;
+
+                }
+                else
+                {
+                    //Error condition report
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoReset(): Encoder is not in the Idle state!", iNodeTypeId));
+                    if (iResetInProgress)
+                    {
+                        iResetInProgress = false;
+                        if ((iCurrentCommand.size() > 0) &&
+                                (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+                           )
+                        {
+                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrInvalidState);
+                        }
+                    }
+                    else
+                    {
+                        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+                    }
+                    break;
+                }//end of if (sState == OMX_StateIdle)
+            }//end of if (iOMXEncoder != NULL)
+
+            //delete all ports and notify observer.
+            if (iInPort)
+            {
+                OSCL_DELETE(((PVMFOMXEncPort*)iInPort));
+                iInPort = NULL;
+            }
+
+            if (iOutPort)
+            {
+                OSCL_DELETE(((PVMFOMXEncPort*)iOutPort));
+                iOutPort = NULL;
+            }
+
+            iDataIn.Unbind();
+
+
+            // Reset the metadata key list
+            iAvailableMetadataKeys.clear();
+
+            iEndOfDataReached = false;
+            iIsEOSSentToComponent = false;
+            iIsEOSReceivedFromComponent = false;
+
+
+            iProcessingState = EPVMFOMXEncNodeProcessingState_Idle;
+            //logoff & go back to Created state.
+            SetState(EPVMFNodeIdle);
+
+
+            if (iResetInProgress)
+            {
+                iResetInProgress = false;
+                if ((iCurrentCommand.size() > 0) &&
+                        (iCurrentCommand.front().iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+                   )
+                {
+                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+                }
+            }
+            else
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            }
+
+        }
+        break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoRequestPort(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DoRequestPort() In", iNodeTypeId));
+    //This node supports port request from any state
+
+    //retrieve port tag.
+    int32 tag;
+    OSCL_String* portconfig;
+
+    aCmd.PVMFOMXEncNodeCommandBase::Parse(tag, portconfig);
+
+    PVMFPortInterface* port = NULL;
+
+
+    int32 leavecode = 0;
+    //validate the tag...
+
+    switch (tag)
+    {
+        case PVMF_OMX_ENC_NODE_PORT_TYPE_INPUT:
+            if (iInPort)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFFailure);
+                break;
+            }
+            OSCL_TRY(leavecode, iInPort = OSCL_NEW(PVMFOMXEncPort, ((int32)tag, this, "OMXEncIn")););
+            if (leavecode || iInPort == NULL)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoRequestPort: Error - Input port instantiation failed", iNodeTypeId));
+                CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+                return;
+            }
+
+            // if format was provided in mimestring, set it now.
+            if (portconfig)
+            {
+                PVMFFormatType format = portconfig->get_str();
+                if (((PVMFOMXEncPort*)iInPort)->IsFormatSupported(format))
+                {
+                    ((PVMFOMXEncPort*)iInPort)->iFormat = format;
+                }
+                else
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoRequestPort: Error - Input port does not support format %s", iNodeTypeId, format.getMIMEStrPtr()));
+                    OSCL_DELETE(((PVMFOMXEncPort*)iInPort));
+                    iInPort = NULL;
+                    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+                    return;
+                }
+
+            }
+
+
+            port = iInPort;
+            break;
+
+        case PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT:
+            if (iOutPort)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFFailure);
+                break;
+            }
+            OSCL_TRY(leavecode, iOutPort = OSCL_NEW(PVMFOMXEncPort, ((int32)tag, this, "OMXEncOut")));
+            if (leavecode || iOutPort == NULL)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXEncNode-%s::DoRequestPort: Error - Output port instantiation failed", iNodeTypeId));
+                CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+                return;
+            }
+
+            // if format was provided in mimestring, set it now.
+            if (portconfig)
+            {
+                PVMFFormatType format = portconfig->get_str();
+                if (((PVMFOMXEncPort*)iOutPort)->IsFormatSupported(format) && (SetCodecType(format) == PVMFSuccess))
+                {
+                    ((PVMFOMXEncPort*)iOutPort)->iFormat = format;
+                }
+                else
+                {
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFOMXEncNode-%s::DoRequestPort: Error - Output port does not support format %s", iNodeTypeId, format.getMIMEStrPtr()));
+                    OSCL_DELETE(((PVMFOMXEncPort*)iOutPort));
+                    iOutPort = NULL;
+                    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+                    return;
+                }
+
+
+            }
+
+            port = iOutPort;
+            break;
+
+        default:
+            //bad port tag
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::DoRequestPort: Error - Invalid port tag", iNodeTypeId));
+            CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+            return;
+    }
+
+    //Return the port pointer to the caller.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)port);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoReleasePort(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVMFPortInterface* temp;
+    aCmd.PVMFOMXEncNodeCommandBase::Parse(temp);
+    PVMFOMXEncPort* port = (PVMFOMXEncPort*) temp;
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (FAIL_NODE_CMD_RELEASE_PORT == iErrorNodeCmd)
+    {
+        port = NULL;
+    }
+#endif
+
+    if (port != NULL && (port == iInPort || port == iOutPort))
+    {
+        if (port == iInPort)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::DoReleasePort Input port released", iNodeTypeId));
+
+            OSCL_DELETE(((PVMFOMXEncPort*)iInPort));
+            iInPort = NULL;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVMFOMXEncNode-%s::DoReleasePort Output port released", iNodeTypeId));
+
+            OSCL_DELETE(((PVMFOMXEncPort*)iOutPort));
+            iOutPort = NULL;
+        }
+        //delete the port.
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        //port not found.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::DoReleasePort ERROR unknown port cannot be released", iNodeTypeId));
+
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::DoGetNodeMetadataKey(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DoGetNodeMetadataKey() In", iNodeTypeId));
+
+    PVMFMetadataList* keylistptr = NULL;
+    uint32 starting_index;
+    int32 max_entries;
+    char* query_key;
+
+    aCmd.PVMFOMXEncNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
+
+    // Check parameters
+    if (keylistptr == NULL)
+    {
+        // The list pointer is invalid
+        return PVMFErrArgument;
+    }
+
+    // Update the available metadata keys
+    iAvailableMetadataKeys.clear();
+    int32 leavecode = 0;
+    leavecode = Push_Back_MetadataKeys(PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY);
+
+    if (iYUVWidth > 0 && iYUVHeight > 0)
+    {
+        leavecode = 0;
+        leavecode = Push_Back_MetadataKeys(PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY);
+        if (0 == leavecode)
+            leavecode = Push_Back_MetadataKeys(PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY);
+    }
+    // add the profile, level and avgbitrate
+    PVMF_MPEGVideoProfileType aProfile;
+    PVMF_MPEGVideoLevelType aLevel;
+    if (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess)
+    {
+        // For H263 this metadata will be available only after first frame decoding
+        leavecode = 0;
+        leavecode = Push_Back_MetadataKeys(PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY);
+        if (0 == leavecode)
+            leavecode = Push_Back_MetadataKeys(PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY);
+    }
+    if (0 == leavecode)
+        leavecode = Push_Back_MetadataKeys(PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY);
+
+    if ((starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
+    {
+        // Invalid starting index and/or max entries
+        return PVMFErrArgument;
+    }
+
+    // Copy the requested keys
+    uint32 num_entries = 0;
+    int32 num_added = 0;
+    for (uint32 lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
+    {
+        if (query_key == NULL)
+        {
+            // No query key so this key is counted
+            ++num_entries;
+            if (num_entries > starting_index)
+            {
+                // Past the starting index so copy the key
+                leavecode = 0;
+                leavecode = Push_Back_MetadataKeys(keylistptr, lcv);
+                OSCL_FIRST_CATCH_ANY(leavecode,
+                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                     (0, "PVMFOMXEncNode-%s::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key", iNodeTypeId));
+                                     return PVMFErrNoMemory);
+                num_added++;
+            }
+        }
+        else
+        {
+            // Check if the key matche the query key
+            if (pv_mime_strcmp(iAvailableMetadataKeys[lcv].get_cstr(), query_key) >= 0)
+            {
+                // This key is counted
+                ++num_entries;
+                if (num_entries > starting_index)
+                {
+                    // Past the starting index so copy the key
+                    leavecode = 0;
+                    leavecode = Push_Back_MetadataKeys(keylistptr, lcv);
+                    OSCL_FIRST_CATCH_ANY(leavecode,
+                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key", iNodeTypeId));
+                                         return PVMFErrNoMemory);
+                    num_added++;
+                }
+            }
+        }
+
+        // Check if max number of entries have been copied
+        if (max_entries > 0 && num_added >= max_entries)
+        {
+            break;
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::DoGetNodeMetadataValue(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoGetNodeMetadataValue() In", iNodeTypeId));
+
+    PVMFMetadataList* keylistptr = NULL;
+    Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
+    uint32 starting_index;
+    int32 max_entries;
+
+    aCmd.PVMFOMXEncNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
+
+    // Check the parameters
+    if (keylistptr == NULL || valuelistptr == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    uint32 numkeys = keylistptr->size();
+
+    if (starting_index > (numkeys - 1) || numkeys <= 0 || max_entries == 0)
+    {
+        // Don't do anything
+        return PVMFErrArgument;
+    }
+
+    uint32 numvalentries = 0;
+    int32 numentriesadded = 0;
+    for (uint32 lcv = 0; lcv < numkeys; lcv++)
+    {
+        int32 leavecode = 0;
+        PvmiKvp KeyVal;
+        KeyVal.key = NULL;
+        uint32 KeyLen = 0;
+
+        if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY) == 0) &&
+                iYUVWidth > 0)
+        {
+            // Video width
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                KeyLen = oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY) + 1; // for "codec-info/video/width;"
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
+
+                // Allocate memory for the string
+                leavecode = 0;
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+
+
+
+                if (leavecode == 0)
+                {
+                    // Copy the key string
+                    oscl_strncpy(KeyVal.key, PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY, oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY) + 1);
+                    oscl_strncat(KeyVal.key, PVOMXENCMETADATA_SEMICOLON, oscl_strlen(PVOMXENCMETADATA_SEMICOLON));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                    KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                    // Copy the value
+                    KeyVal.value.uint32_value = iYUVWidth;
+                    // Set the length and capacity
+                    KeyVal.length = 1;
+                    KeyVal.capacity = 1;
+                }
+                else
+                {
+                    // Memory allocation failed
+                    KeyVal.key = NULL;
+                    break;
+                }
+            }
+        }
+        else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY) == 0) &&
+                 iYUVHeight > 0)
+        {
+            // Video height
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                KeyLen = oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY) + 1; // for "codec-info/video/height;"
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
+
+                // Allocate memory for the string
+                leavecode = 0;
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+
+
+
+                if (leavecode == 0)
+                {
+                    // Copy the key string
+                    oscl_strncpy(KeyVal.key, PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY, oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY) + 1);
+                    oscl_strncat(KeyVal.key, PVOMXENCMETADATA_SEMICOLON, oscl_strlen(PVOMXENCMETADATA_SEMICOLON));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                    KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                    // Copy the value
+                    KeyVal.value.uint32_value = iYUVHeight;
+                    // Set the length and capacity
+                    KeyVal.length = 1;
+                    KeyVal.capacity = 1;
+                }
+                else
+                {
+                    // Memory allocation failed
+                    KeyVal.key = NULL;
+                    break;
+                }
+            }
+        }
+        else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY) == 0))
+        {
+            // Video profile
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                KeyLen = oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY) + 1; // for "codec-info/video/profile;"
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
+
+                // Allocate memory for the string
+                leavecode = 0;
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+
+
+
+                if (leavecode == 0)
+                {
+                    PVMF_MPEGVideoProfileType aProfile;
+                    PVMF_MPEGVideoLevelType aLevel;
+                    if (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess)
+                    {
+                        // Copy the key string
+                        oscl_strncpy(KeyVal.key, PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY, oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY) + 1);
+                        oscl_strncat(KeyVal.key, PVOMXENCMETADATA_SEMICOLON, oscl_strlen(PVOMXENCMETADATA_SEMICOLON));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                        KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                        // Copy the value
+                        KeyVal.value.uint32_value = (uint32)aProfile; // This is to be decided, who will interpret these value
+                        // Set the length and capacity
+                        KeyVal.length = 1;
+                        KeyVal.capacity = 1;
+                    }
+                    else
+                    {
+                        // Memory allocation failed
+                        KeyVal.key = NULL;
+                        break;
+                    }
+                }
+                else
+                {
+                    // Memory allocation failed
+                    KeyVal.key = NULL;
+                    break;
+                }
+            }
+        }
+        else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY) == 0))
+        {
+            // Video level
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                KeyLen = oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY) + 1; // for "codec-info/video/level;"
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
+
+                // Allocate memory for the string
+                leavecode = 0;
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+
+
+
+                if (leavecode == 0)
+                {
+                    PVMF_MPEGVideoProfileType aProfile;
+                    PVMF_MPEGVideoLevelType aLevel;
+                    if (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess)
+                    {
+                        // Copy the key string
+                        oscl_strncpy(KeyVal.key, PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY, oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY) + 1);
+                        oscl_strncat(KeyVal.key, PVOMXENCMETADATA_SEMICOLON, oscl_strlen(PVOMXENCMETADATA_SEMICOLON));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                        oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                        KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                        // Copy the value
+                        KeyVal.value.uint32_value = (uint32)aLevel; // This is to be decided, who will interpret these value
+                        // Set the length and capacity
+                        KeyVal.length = 1;
+                        KeyVal.capacity = 1;
+                    }
+                    else
+                    {
+                        // Memory allocation failed
+                        KeyVal.key = NULL;
+                        break;
+                    }
+                }
+                else
+                {
+                    // Memory allocation failed
+                    KeyVal.key = NULL;
+                    break;
+                }
+            }
+        }
+        else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY) == 0) &&
+                 (iAvgBitrateValue > 0))
+        {
+            // Video average bitrate
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                KeyLen = oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY) + 1; // for "codec-info/video/avgbitrate;"
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
+
+                // Allocate memory for the string
+                leavecode = 0;
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+
+
+
+                if (leavecode == 0)
+                {
+                    // Copy the key string
+                    oscl_strncpy(KeyVal.key, PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY, oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY) + 1);
+                    oscl_strncat(KeyVal.key, PVOMXENCMETADATA_SEMICOLON, oscl_strlen(PVOMXENCMETADATA_SEMICOLON));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+                    KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                    // Copy the value
+                    KeyVal.value.uint32_value = iAvgBitrateValue;
+                    // Set the length and capacity
+                    KeyVal.length = 1;
+                    KeyVal.capacity = 1;
+
+                }
+                else
+                {
+                    // Memory allocation failed
+                    KeyVal.key = NULL;
+                    break;
+                }
+            }
+        }
+        else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY) == 0) &&
+                 (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2631998 || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2632000 || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_M4V ||
+                  ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+                  ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW  || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_WMV))
+        {
+            // Format
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                KeyLen = oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY) + 1; // for "codec-info/video/format;"
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
+                KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*" and NULL terminator
+
+                uint32 valuelen = 0;
+                if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO_RAW)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_M4V)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_M4V)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2631998)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H2631998)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
+                {
+                    oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H2632000), valuelen);
+                }
+                else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_WMV)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_WMV)) + 1; // Value string plus one for NULL terminator
+                }
+                else
+                {
+                    // Should not enter here
+                    OSCL_ASSERT(false);
+                    valuelen = 1;
+                }
+
+                // Allocate memory for the strings
+                leavecode = 0;
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+                if (0 == leavecode)
+                {
+                    leavecode = CreateNewArray(KeyVal.value.pChar_value , valuelen);
+                }
+
+                if (leavecode == 0)
+                {
+                    // Copy the key string
+                    oscl_strncpy(KeyVal.key, PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY, oscl_strlen(PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY) + 1);
+                    oscl_strncat(KeyVal.key, PVOMXENCMETADATA_SEMICOLON, oscl_strlen(PVOMXENCMETADATA_SEMICOLON));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+                    oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
+                    KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
+                    // Copy the value
+                    if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO), valuelen);
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), valuelen);
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_RAW), valuelen);
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_M4V)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_M4V), valuelen);
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2631998)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H2631998), valuelen);
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H2632000), valuelen);
+                    }
+                    else if (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_WMV)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_WMV), valuelen);
+                    }
+                    else
+                    {
+                        // Should not enter here
+                        OSCL_ASSERT(false);
+                        valuelen = 1;
+                    }
+
+                    KeyVal.value.pChar_value[valuelen-1] = NULL_TERM_CHAR;
+                    // Set the length and capacity
+                    KeyVal.length = valuelen;
+                    KeyVal.capacity = valuelen;
+                }
+                else
+                {
+                    // Memory allocation failed so clean up
+                    if (KeyVal.key)
+                    {
+                        OSCL_ARRAY_DELETE(KeyVal.key);
+                        KeyVal.key = NULL;
+                    }
+                    if (KeyVal.value.pChar_value)
+                    {
+                        OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
+                    }
+                    break;
+                }
+            }
+        }
+
+        if (KeyVal.key != NULL)
+        {
+            leavecode = 0;
+            leavecode = PushBackKeyVal(valuelistptr, KeyVal);
+            if (leavecode != 0)
+            {
+                switch (GetValTypeFromKeyString(KeyVal.key))
+                {
+                    case PVMI_KVPVALTYPE_CHARPTR:
+                        if (KeyVal.value.pChar_value != NULL)
+                        {
+                            OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
+                            KeyVal.value.pChar_value = NULL;
+                        }
+                        break;
+
+                    default:
+                        // Add more case statements if other value types are returned
+                        break;
+                }
+
+                OSCL_ARRAY_DELETE(KeyVal.key);
+                KeyVal.key = NULL;
+            }
+            else
+            {
+                // Increment the counter for number of value entries added to the list
+                ++numentriesadded;
+            }
+
+            // Check if the max number of value entries were added
+            if (max_entries > 0 && numentriesadded >= max_entries)
+            {
+                break;
+            }
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::ReleaseAllPorts()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ReleaseAllPorts() In", iNodeTypeId));
+
+    if (iInPort)
+    {
+        iInPort->ClearMsgQueues();
+        iInPort->Disconnect();
+        OSCL_DELETE(((PVMFOMXEncPort*)iInPort));
+        iInPort = NULL;
+    }
+
+    if (iOutPort)
+    {
+        iOutPort->ClearMsgQueues();
+        iOutPort->Disconnect();
+        OSCL_DELETE(((PVMFOMXEncPort*)iOutPort));
+        iOutPort = NULL;
+    }
+
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Clean Up Encoder
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::DeleteOMXEncoder()
+{
+    OMX_ERRORTYPE  err;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DeleteOMXEncoder() In", iNodeTypeId));
+
+    if (iOMXEncoder != NULL)
+    {
+        /* Free Component handle. */
+        err = OMX_FreeHandle(iOMXEncoder);
+        if (err != OMX_ErrorNone)
+        {
+            //Error condition report
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::DeleteOMXEncoder(): Can't free encoder's handle!", iNodeTypeId));
+        }
+        iOMXEncoder = NULL;
+
+    }//end of if (iOMXEncoder != NULL)
+
+
+    return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::ChangeNodeState(TPVMFNodeInterfaceState aNewState)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ChangeNodeState() Changing state from %d to %d", iNodeTypeId, iInterfaceState, aNewState));
+    iInterfaceState = aNewState;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::freechunkavailable(OsclAny *aContext)
+{
+
+    // check context to see whether input or output buffer was returned to the mempool
+    if (aContext == (OsclAny *) iInBufMemoryPool)
+    {
+
+        iNumOutstandingInputBuffers--;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::freechunkavailable() Memory chunk in INPUT mempool was deallocated, %d out of %d now available", iNodeTypeId, iNumInputBuffers - iNumOutstandingInputBuffers, iNumInputBuffers));
+
+        // notification only works once.
+        // If there are multiple buffers coming back in a row, make sure to set the notification
+        // flag in the mempool again, so that next buffer also causes notification
+        iInBufMemoryPool->notifyfreechunkavailable(*this, aContext);
+
+    }
+    else if (aContext == (OsclAny *) iOutBufMemoryPool)
+    {
+
+        iNumOutstandingOutputBuffers--;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::freechunkavailable() Memory chunk in OUTPUT mempool was deallocated, %d out of %d now available", iNodeTypeId, iNumOutputBuffers - iNumOutstandingOutputBuffers, iNumOutputBuffers));
+
+        // notification only works once.
+        // If there are multiple buffers coming back in a row, make sure to set the notification
+        // flag in the mempool again, so that next buffer also causes notification
+        iOutBufMemoryPool->notifyfreechunkavailable(*this, aContext);
+
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXEncNode-%s::freechunkavailable() UNKNOWN mempool ", iNodeTypeId));
+
+    }
+
+    // reschedule
+    if (IsAdded())
+        RunIfNotReady();
+
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFOMXEncNode-%s::PortActivity: port=0x%x, type=%d",
+                     this, iNodeTypeId, aActivity.iPort, aActivity.iType));
+
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            //An outgoing message was queued on this port.
+            //We only need to queue a port activity event on the
+            //first message.  Additional events will be queued during
+            //the port processing as needed.
+            if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
+            {
+                //wake up the AO to process the port activity event.
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFOMXEncNode-%s::PortActivity: IncomingMsgQueueSize=%d", iNodeTypeId, aActivity.iPort->IncomingMsgQueueSize()));
+            if (aActivity.iPort->IncomingMsgQueueSize() == 1)
+            {
+                //wake up the AO to process the port activity event.
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
+            if (iProcessingState == EPVMFOMXEncNodeProcessingState_WaitForOutgoingQueue)
+            {
+                iProcessingState = EPVMFOMXEncNodeProcessingState_ReadyToEncode;
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECT:
+            //nothing needed.
+            break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            //clear the node input data when either port is disconnected.
+
+            iDataIn.Unbind();
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
+            // The connected port has become busy (its incoming queue is
+            // busy).
+            // No action is needed here-- the port processing code
+            // checks for connected port busy during data processing.
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
+            // The connected port has transitioned from Busy to Ready to Receive.
+            // It's time to start processing outgoing messages again.
+
+            //iProcessingState should transition from WaitForOutputPort to ReadyToEncode
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "0x%x PVMFOMXEncNode-%s::PortActivity: Connected port is now ready", this, iNodeTypeId));
+            RunIfNotReady();
+            break;
+
+        default:
+            break;
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoCancelAllCommands(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DoCancelAllCommands", iNodeTypeId));
+
+    //first cancel the current command if any
+    {
+        while (!iCurrentCommand.empty())
+        {
+            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
+        }
+
+    }
+
+    //next cancel all queued commands
+    {
+        //start at element 1 since this cancel command is element 0.
+        while (iInputCommands.size() > 1)
+        {
+            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
+        }
+    }
+
+    if (iResetInProgress && !iResetMsgSent)
+    {
+        // if reset is started but reset msg has not been sent, we can cancel reset
+        // as if nothing happened. Otherwise, the callback will set the flag back to false
+        iResetInProgress = false;
+    }
+    //finally, report cancel complete.
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoCancelCommand(PVMFOMXEncNodeCommand& aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DoCancelCommand", iNodeTypeId));
+
+    //extract the command ID from the parameters.
+    PVMFCommandId id;
+    aCmd.PVMFOMXEncNodeCommandBase::Parse(id);
+
+    //first check "current" command if any
+    {
+        PVMFOMXEncNodeCommand* cmd = iCurrentCommand.FindById(id);
+        if (cmd)
+        {
+
+            // if reset is being canceled:
+            if (cmd->iCmd == PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_RESET)
+            {
+                if (iResetInProgress && !iResetMsgSent)
+                {
+                    // if reset is started but reset msg has not been sent, we can cancel reset
+                    // as if nothing happened. Otherwise, the callback will set the flag back to false
+                    iResetInProgress = false;
+                }
+            }
+            //cancel the queued command
+            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+
+    //next check input queue.
+    {
+        //start at element 1 since this cancel command is element 0.
+        PVMFOMXEncNodeCommand* cmd = iInputCommands.FindById(id, 1);
+        if (cmd)
+        {
+            //cancel the queued command
+            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
+            //report cancel success
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            return;
+        }
+    }
+    //if we get here the command isn't queued so the cancel fails.
+    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoQueryUuid(PVMFOMXEncNodeCommand& aCmd)
+{
+    //This node supports Query UUID from any state
+
+    OSCL_String* mimetype;
+    Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
+    bool exactmatch;
+    aCmd.PVMFOMXEncNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
+
+    //Try to match the input mimetype against any of
+    //the custom interfaces for this node
+
+    //Match against custom interface1...
+    if (*mimetype == PVMF_OMX_ENC_NODE_CUSTOM1_MIMETYPE
+            //also match against base mimetypes for custom interface1,
+            //unless exactmatch is set.
+            || (!exactmatch && *mimetype == PVMF_OMX_ENC_NODE_MIMETYPE)
+            || (!exactmatch && *mimetype == PVMF_BASEMIMETYPE))
+    {
+
+        PVUuid uuid(PVMF_OMX_ENC_NODE_CUSTOM1_UUID);
+        uuidvec->push_back(uuid);
+    }
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::DoQueryInterface(PVMFOMXEncNodeCommand&  aCmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::DoQueryInterface", iNodeTypeId));
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVMFOMXEncNodeCommandBase::Parse(uuid, ptr);
+
+    if (*uuid == PVUuid(PVMF_OMX_ENC_NODE_CUSTOM1_UUID))
+    {
+        addRef();
+        *ptr = (PVMFOMXEncNodeExtensionInterface*)this;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else if (*uuid == PVUuid(KPVMFMetadataExtensionUuid))
+    {
+        addRef();
+        *ptr = (PVMFMetadataExtensionInterface*)this;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else if (*uuid == PVUuid(PVMI_CAPABILITY_AND_CONFIG_PVUUID))
+    {
+        addRef();
+        *ptr = (PvmiCapabilityAndConfig*)this;
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else if (*uuid == PVMp4H263EncExtensionUUID)
+    {
+        addRef();
+        *ptr = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, this);
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        //iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+
+    }
+    else if (*uuid == PVAMREncExtensionUUID)
+    {
+        addRef();
+        *ptr = OSCL_STATIC_CAST(PVAMREncExtensionInterface*, this);
+        //iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+
+    }
+    else
+    {
+        //not supported
+        *ptr = NULL;
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+    }
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::addRef()
+{
+    ++iExtensionRefCount;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::removeRef()
+{
+    --iExtensionRefCount;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    PVUuid my_uuid(PVMF_OMX_ENC_NODE_CUSTOM1_UUID);
+    if (uuid == my_uuid)
+    {
+        PVMFOMXEncNodeExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFOMXEncNodeExtensionInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+        return true;
+    }
+    else if (uuid == KPVMFMetadataExtensionUuid)
+    {
+        PVMFMetadataExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+        ++iExtensionRefCount;
+        return true;
+    }
+    return false;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+uint32 PVMFOMXEncNode::GetNumMetadataKeys(char* aQueryKeyString)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetNumMetadataKeys() called", iNodeTypeId));
+
+    // Update the available metadata keys
+    iAvailableMetadataKeys.clear();
+    int32 errcode = 0;
+    OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY));
+
+    if (iYUVWidth > 0 && iYUVHeight > 0)
+    {
+        errcode = 0;
+        OSCL_TRY(errcode,
+                 iAvailableMetadataKeys.push_back(PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY);
+                 iAvailableMetadataKeys.push_back(PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY));
+    }
+    // add the profile, level and avgbitrate
+    PVMF_MPEGVideoProfileType aProfile;
+    PVMF_MPEGVideoLevelType aLevel;
+    if (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess)
+    {
+        // For H263 this metadata will be available only after first frame decoding
+        errcode = 0;
+        OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY));
+        errcode = 0;
+        OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY));
+    }
+    errcode = 0;
+    OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY));
+
+
+
+    uint32 num_entries = 0;
+
+    if (aQueryKeyString == NULL)
+    {
+        num_entries = iAvailableMetadataKeys.size();
+    }
+    else
+    {
+        for (uint32 i = 0; i < iAvailableMetadataKeys.size(); i++)
+        {
+            if (pv_mime_strcmp(iAvailableMetadataKeys[i].get_cstr(), aQueryKeyString) >= 0)
+            {
+                num_entries++;
+            }
+        }
+    }
+    return num_entries; // Number of elements
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::setObserver()", iNodeTypeId));
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::setObserver() is not supported!", iNodeTypeId));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+PVMFStatus PVMFOMXEncNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::getParametersSync()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+
+    return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
+}
+
+
+PVMFStatus PVMFOMXEncNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::releaseParameters()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+
+    return DoCapConfigReleaseParameters(aParameters, aNumElements);
+}
+
+
+void PVMFOMXEncNode::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::createContext()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::createContext() is not supported!", iNodeTypeId));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+void PVMFOMXEncNode::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::setContextParameters()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumParamElements);
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::setContextParameters() is not supported!", iNodeTypeId));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+void PVMFOMXEncNode::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DeleteContext()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DeleteContext() is not supported!", iNodeTypeId));
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+
+void PVMFOMXEncNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::setParametersSync()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+
+    // Complete the request synchronously
+    DoCapConfigSetParameters(aParameters, aNumElements, aRetKVP);
+}
+
+
+PVMFCommandId PVMFOMXEncNode::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::setParametersAsync()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aNumElements);
+    OSCL_UNUSED_ARG(aRetKVP);
+    OSCL_UNUSED_ARG(aContext);
+
+    // This method is not supported so leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::setParametersAsync() is not supported!", iNodeTypeId));
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return 0;
+}
+
+
+uint32 PVMFOMXEncNode::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::getCapabilityMetric()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+    // Not supported so return 0
+    return 0;
+}
+
+
+PVMFStatus PVMFOMXEncNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::verifyParametersSync()", iNodeTypeId));
+    OSCL_UNUSED_ARG(aSession);
+
+    return DoCapConfigVerifyParameters(aParameters, aNumElements);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+uint32 PVMFOMXEncNode::GetNumMetadataValues(PVMFMetadataList& aKeyList)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetNumMetadataValues() called", iNodeTypeId));
+
+    uint32 numkeys = aKeyList.size();
+
+    if (numkeys <= 0)
+    {
+        // Don't do anything
+        return 0;
+    }
+
+    // Count the number of value entries for the provided key list
+    uint32 numvalentries = 0;
+    PVMF_MPEGVideoProfileType aProfile;
+    PVMF_MPEGVideoLevelType aLevel;
+    for (uint32 lcv = 0; lcv < numkeys; lcv++)
+    {
+        if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_WIDTH_KEY) == 0) &&
+                iYUVWidth > 0)
+        {
+            // Video width
+            ++numvalentries;
+        }
+        else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_HEIGHT_KEY) == 0) &&
+                 iYUVHeight > 0)
+        {
+            // Video height
+            ++numvalentries;
+        }
+        else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_PROFILE_KEY) == 0) &&
+                 (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess))
+
+        {
+            // Video profile
+            ++numvalentries;
+        }
+        else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_LEVEL_KEY) == 0) &&
+                 (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess))
+        {
+            // Video level
+            ++numvalentries;
+        }
+        else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY) == 0) &&
+                 (iAvgBitrateValue > 0))
+
+        {
+            // Video average bitrate
+            if (iAvgBitrateValue > 0)
+                ++numvalentries;
+        }
+        else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXENCMETADATA_CODECINFO_VIDEO_FORMAT_KEY) == 0) &&
+                 (((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_WMV || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_M4V || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2631998 || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H2632000 || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 || ((PVMFOMXEncPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW))
+        {
+            // Format
+            ++numvalentries;
+        }
+    }
+
+    return numvalentries;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries, char* query_key, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNodeCommand::GetNodeMetadataKeys() called", iNodeTypeId));
+
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommand::Construct(aSessionId, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_GETNODEMETADATAKEY, &aKeyList, starting_index, max_entries, query_key, aContext);
+    return QueueCommandL(cmd);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFOMXEncNode::GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNodeCommand::GetNodeMetadataValue() called", iNodeTypeId));
+
+    PVMFOMXEncNodeCommand cmd;
+    cmd.PVMFOMXEncNodeCommand::Construct(aSessionId, PVMFOMXEncNodeCommand::PVOMXENC_NODE_CMD_GETNODEMETADATAVALUE, &aKeyList, &aValueList, starting_index, max_entries, aContext);
+    return QueueCommandL(cmd);
+}
+
+// From PVMFMetadataExtensionInterface
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::ReleaseNodeMetadataKeys(PVMFMetadataList& , uint32 , uint32)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ReleaseNodeMetadataKeys() called", iNodeTypeId));
+    //nothing needed-- there's no dynamic allocation in this node's key list
+    return PVMFSuccess;
+}
+
+// From PVMFMetadataExtensionInterface
+/////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 start, uint32 end)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::ReleaseNodeMetadataValues() called", iNodeTypeId));
+
+    if (aValueList.size() == 0 || start > end)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::ReleaseNodeMetadataValues() Invalid start/end index", iNodeTypeId));
+        return PVMFErrArgument;
+    }
+
+    if (end >= aValueList.size())
+    {
+        end = aValueList.size() - 1;
+    }
+
+    for (uint32 i = start; i <= end; i++)
+    {
+        if (aValueList[i].key != NULL)
+        {
+            switch (GetValTypeFromKeyString(aValueList[i].key))
+            {
+                case PVMI_KVPVALTYPE_CHARPTR:
+                    if (aValueList[i].value.pChar_value != NULL)
+                    {
+                        OSCL_ARRAY_DELETE(aValueList[i].value.pChar_value);
+                        aValueList[i].value.pChar_value = NULL;
+                    }
+                    break;
+
+                case PVMI_KVPVALTYPE_UINT32:
+                case PVMI_KVPVALTYPE_UINT8:
+                    // No memory to free for these valtypes
+                    break;
+
+                default:
+                    // Should not get a value that wasn't created from here
+                    break;
+            }
+
+            OSCL_ARRAY_DELETE(aValueList[i].key);
+            aValueList[i].key = NULL;
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+
+
+
+
+
+PVMFStatus PVMFOMXEncNode::GetProfileAndLevel(PVMF_MPEGVideoProfileType& aProfile, PVMF_MPEGVideoLevelType& aLevel)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetProfileAndLevel() In", iNodeTypeId));
+
+    if (NULL == iOMXEncoder)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::GetProfileAndLevel() iEncoder is Null", iNodeTypeId));
+        aProfile = PV_MPEG_VIDEO_RESERVED_PROFILE;
+        aLevel	= PV_MPEG_VIDEO_LEVEL_UNKNOWN;
+        return PVMFFailure;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::GetProfileAndLevel() iEncoder is Null", iNodeTypeId));
+    aProfile = PV_MPEG_VIDEO_RESERVED_PROFILE;
+    aLevel	= PV_MPEG_VIDEO_LEVEL_UNKNOWN;
+    // DV: FOR NOW, JUST RETURN FAILURE, WE DON'T SUPPORT THIS FEATURE YET
+    return PVMFFailure;
+
+
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncNode::LogDiagnostics()
+{
+    if (iDiagnosticsLogged == false)
+    {
+        iDiagnosticsLogged = true;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFOMXEncNode-%s - Number of Media Msgs Sent = %d", iNodeTypeId, iSeqNum));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFOMXEncNode-%s - TS of last encoded msg = %d", iNodeTypeId, iTimeStampOut));
+    }
+}
+
+
+
+//////////////////////////////////
+/////EXTENSION INTERFACE
+////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetNumLayers(uint32 aNumLayers)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetNumLayers: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    if (aNumLayers > MAX_LAYER)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::SetNumLayers: Error Max num layers is %d", iNodeTypeId, MAX_LAYER));
+        return false;
+    }
+
+    iVideoEncodeParam.iNumLayer = aNumLayers;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetOutputBitRate(uint32 aLayer, uint32 aBitRate)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::SetOutputBitRate: Error iInterfaceState=%d", iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    if ((int32)aLayer >= iVideoEncodeParam.iNumLayer)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::SetOutputBitRate: Error Invalid layer number", iNodeTypeId));
+        return false;
+    }
+
+    iVideoEncodeParam.iBitRate[aLayer] = aBitRate;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetOutputFrameSize: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    if ((int32)aLayer >= iVideoEncodeParam.iNumLayer)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::SetOutputFrameSize: Error Invalid layer number", iNodeTypeId));
+        return false;
+    }
+
+    iVideoEncodeParam.iFrameWidth[aLayer] = aWidth;
+    iVideoEncodeParam.iFrameHeight[aLayer] = aHeight;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetOutputFrameRate: Error iInterfaceState=%d", iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    if ((int32)aLayer >= iVideoEncodeParam.iNumLayer)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::SetOutputFrameRate: Error Invalid layer number", iNodeTypeId));
+        return false;
+    }
+
+    iVideoEncodeParam.iFrameRate[aLayer] = OSCL_STATIC_CAST(float, aFrameRate);
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes)
+{
+    OSCL_UNUSED_ARG(aLayer);
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetSegmentTargetSize: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    iVideoEncodeParam.iPacketSize = aSizeBytes;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl)
+{
+    OSCL_UNUSED_ARG(aLayer);
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetRateControlType: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    switch (aRateControl)
+    {
+        case PVMFVEN_RATE_CONTROL_CONSTANT_Q:
+            iVideoEncodeParam.iRateControlType = ECONSTANT_Q;
+            break;
+        case PVMFVEN_RATE_CONTROL_CBR:
+            iVideoEncodeParam.iRateControlType = ECBR_1;
+            break;
+        case PVMFVEN_RATE_CONTROL_VBR:
+            iVideoEncodeParam.iRateControlType = EVBR_1;
+            break;
+        default:
+            return false;
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetDataPartitioning(bool aDataPartitioning)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetDataPartitioning: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    if (iVideoEncodeParam.iContentType == EI_H263 || iVideoEncodeParam.iContentType == EI_H264)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::SetDataPartitioning: Error data partitioning not supported for H263 or H264", iNodeTypeId));
+
+        // ignore the error
+        return true;
+        //return false;
+    }
+
+    if (aDataPartitioning)
+        iVideoEncodeParam.iContentType = EI_M4V_STREAMING;
+    else
+        iVideoEncodeParam.iContentType = EI_M4V_DOWNLOAD;
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetIFrameInterval(uint32 aIFrameInterval)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetIFrameInterval: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    iVideoEncodeParam.iIFrameInterval = aIFrameInterval;
+    return true;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetSceneDetection(bool aSCD)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SetSceneDetection to %d", iNodeTypeId, aSCD));
+
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncEncNode-%s::SetIFrameInterval: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    iVideoEncodeParam.iSceneDetection = aSCD;
+
+    return true;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetRVLC(bool aRVLC)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SetRVLC", iNodeTypeId));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncEncNode-%s::SetRVLC: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+
+        default:
+            break;
+    }
+
+    if (iVideoEncodeParam.iContentType == EI_H263 || iVideoEncodeParam.iContentType == EI_H264)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::SetRVLC : RVLC not supported for H263 or H264", iNodeTypeId));
+
+        // ignore the error
+        return true;
+    }
+
+    iVideoEncodeParam.iRVLCEnable = aRVLC;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::GetVolHeader(OsclRefCounterMemFrag& aVolHeader)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::GetVolHeader", iNodeTypeId));
+
+#ifdef _TEST_AE_ERROR_HANDLING
+    if (iErrorConfigHeader)
+    {
+        iInterfaceState = EPVMFNodeError;
+    }
+#endif
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::GetVolHeader: Error - Wrong state", iNodeTypeId));
+            return false;
+    }
+
+    if ((iVideoEncodeParam.iContentType == EI_H263) || (iVideoEncodeParam.iContentType == EI_H264))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::GetVolHeader: Error - VOL header only for M4V encode", iNodeTypeId));
+        return false;
+    }
+
+    uint8 *ptr = (uint8 *) iVolHeader.getMemFragPtr();
+    //If data partioning mode
+    if (iVideoEncodeParam.iContentType == EI_M4V_STREAMING)
+    {
+        ptr[iVolHeader.getMemFragSize() - 1] = 0x8F;
+    }
+    //else combined mode
+    else if (iVideoEncodeParam.iContentType == EI_M4V_DOWNLOAD)
+    {
+        ptr[iVolHeader.getMemFragSize() - 1] = 0x1F;
+    }
+
+    aVolHeader = iVolHeader;
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::RequestIFrame()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::RequestIFrame", iNodeTypeId));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::RequestIFrame: Error - Wrong state", iNodeTypeId));
+            return false;
+    }
+
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetCodec(PVMFFormatType aCodec)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SetCodec %s", iNodeTypeId, aCodec.getMIMEStrPtr()));
+
+    if (SetCodecType(aCodec) == PVMFSuccess)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+
+}
+
+
+
+PVMFStatus PVMFOMXEncNode::SetCodecType(PVMFFormatType aCodec)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetCodecType: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+
+            return PVMFErrInvalidState;
+        default:
+            break;
+    }
+
+    if (aCodec == PVMF_MIME_H2631998)
+    {
+        iVideoEncodeParam.iContentType = EI_H263;
+        iOutFormat = PVMF_MIME_H2631998;
+    }
+    else if (aCodec == PVMF_MIME_H2632000)
+    {
+        iVideoEncodeParam.iContentType = EI_H263;
+        iOutFormat = PVMF_MIME_H2632000;
+    }
+    else if (aCodec == PVMF_MIME_M4V)
+    {
+        iVideoEncodeParam.iContentType = EI_M4V_STREAMING;
+        iOutFormat = PVMF_MIME_M4V;
+    }
+    else if (aCodec == PVMF_MIME_H264_VIDEO_RAW ||
+             aCodec == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        iVideoEncodeParam.iContentType = EI_H264;
+        iOutFormat = aCodec;
+    }
+    else if (aCodec == PVMF_MIME_AMR_IETF ||
+             aCodec == PVMF_MIME_AMR_IF2)
+    {
+        iOutFormat = aCodec;
+    }
+    else
+    {
+        return PVMFErrNotSupported;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF bool PVMFOMXEncNode::SetFSIParam(uint8* aFSIBuff, int aFSIBuffLength)
+{
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                    (0, "PVMFOMXEncNode-%s::SetFSIParam: Error- NOT IMPLEMENTED", iNodeTypeId));
+    OSCL_UNUSED_ARG(aFSIBuff);
+    OSCL_UNUSED_ARG(aFSIBuffLength);
+
+    return true;
+}
+
+
+
+// The input format methods are called from the port
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::SetInputFormat(PVMFFormatType aFormat)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SetInputFormat: aFormat=%s", iNodeTypeId, aFormat.getMIMEStrPtr()));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetInputFormat: Error - iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return PVMFErrInvalidState;
+        default:
+            break;
+    }
+
+    iInFormat = aFormat;
+
+    if (aFormat == PVMF_MIME_YUV420)
+    {
+        iVideoInputFormat.iVideoFormat = EI_YUV420;
+    }
+    else if (aFormat == PVMF_MIME_YUV422)
+    {
+        iVideoInputFormat.iVideoFormat = EI_UYVY;
+    }
+    else if (aFormat == PVMF_MIME_RGB24)
+    {
+        iVideoInputFormat.iVideoFormat = EI_RGB24;
+    }
+    else if (aFormat == PVMF_MIME_RGB12)
+    {
+        iVideoInputFormat.iVideoFormat = EI_RGB12;
+    }
+    else if (aFormat == PVMF_MIME_PCM16)
+    {
+        // nothing to do here, but don't fail
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetInputFrameSize: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+        default:
+            break;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SetInputFrameSize: aWidth=%d, aHeight=%d, aFrmOrient=%d", iNodeTypeId, aWidth, aHeight, aFrmOrient));
+
+    iVideoInputFormat.iFrameWidth = aWidth;
+    iVideoInputFormat.iFrameHeight = aHeight;
+    iVideoInputFormat.iFrameOrientation = aFrmOrient;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::SetInputFrameRate(OsclFloat aFrameRate)
+{
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncNode-%s::SetInputFrameRate: Error iInterfaceState=%d", iNodeTypeId, iInterfaceState));
+            return false;
+        default:
+            break;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::SetInputFrameRate: aFrameRate=%d", iNodeTypeId, aFrameRate));
+
+    iVideoInputFormat.iFrameRate = OSCL_STATIC_CAST(float, aFrameRate);
+    iVideoEncodeParam.iNoFrameSkip = iVideoEncodeParam.iNoCurrentSkip = false;
+    return true;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFFormatType PVMFOMXEncNode::GetCodecType()
+{
+    return iOutFormat;
+}
+
+////////////////////////////////////////////////////////////////////////////
+// DV: Note - for video - there is an uint32 arg
+uint32 PVMFOMXEncNode::GetOutputBitRate(uint32 aLayer)
+{
+    if ((int32)aLayer >= iVideoEncodeParam.iNumLayer)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::GetOutputBitRate: Error - Invalid layer number", iNodeTypeId));
+        return 0;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::GetOutputBitRate: =%d", iNodeTypeId, iVideoEncodeParam.iBitRate[aLayer]));
+
+    return iVideoEncodeParam.iBitRate[aLayer];
+}
+
+////////////////////////////////////////////////////////////////////////////
+OsclFloat PVMFOMXEncNode::GetOutputFrameRate(uint32 aLayer)
+{
+    if ((int32)aLayer >= iVideoEncodeParam.iNumLayer)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::GetOutputFrameRate: Error Invalid layer number", iNodeTypeId));
+        return 0;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXEncNode-%s::GetOutputFrameRate: =%f", iNodeTypeId, (OsclFloat) iVideoEncodeParam.iFrameRate[aLayer]));
+
+    return (OsclFloat)iVideoEncodeParam.iFrameRate[aLayer];
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight)
+{
+    if ((int32)aLayer >= iVideoEncodeParam.iNumLayer)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXEncNode-%s::GetOutputFrameSize: Error Invalid layer number", iNodeTypeId));
+        return PVMFFailure;
+    }
+
+    aWidth = iVideoEncodeParam.iFrameWidth[aLayer];
+    aHeight = iVideoEncodeParam.iFrameHeight[aLayer];
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+uint32 PVMFOMXEncNode::GetIFrameInterval()
+{
+    return iVideoEncodeParam.iIFrameInterval;
+}
+/////////////////////////////////////////////////////////////////////////////
+/////////////////////////AMRENCInterfaceExtension //////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXEncNode::SetOutputBitRate(PVMF_GSMAMR_Rate aBitRate)
+{
+    iAudioEncodeParam.iOutputBitrate = aBitRate;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXEncNode::SetMaxNumOutputFramesPerBuffer(uint32 aNumOutputFrames)
+{
+    iAudioEncodeParam.iMaxNumOutputFramesPerBuffer = aNumOutputFrames;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::SetInputSamplingRate(uint32 aSamplingRate)
+{
+    if (aSamplingRate != 8000)
+        return PVMFErrNotSupported;
+
+    iAudioInputFormat.iInputSamplingRate = aSamplingRate;
+
+    // set output as well
+    iAudioEncodeParam.iOutputSamplingRate = aSamplingRate;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::SetInputBitsPerSample(uint32 aBitsPerSample)
+{
+    if (aBitsPerSample != 16)
+        return PVMFErrNotSupported;
+
+    iAudioInputFormat.iInputBitsPerSample = aBitsPerSample;
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncNode::SetInputNumChannels(uint32 aNumChannels)
+{
+    if (aNumChannels != 1)
+        return PVMFErrNotSupported;
+
+    iAudioInputFormat.iInputNumChannels = aNumChannels;
+
+    //set output as well
+    iAudioEncodeParam.iOutputNumChannels = aNumChannels;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+uint32 PVMFOMXEncNode::GetOutputBitRate()
+{
+    switch (iAudioEncodeParam.iOutputBitrate)
+    {
+        case GSM_AMR_4_75:
+            return 4750;
+        case GSM_AMR_5_15:
+            return 5150;
+        case GSM_AMR_5_90:
+            return 5900;
+        case GSM_AMR_6_70:
+            return 6700;
+        case GSM_AMR_7_40:
+            return 7400;
+        case GSM_AMR_7_95:
+            return 7950;
+        case GSM_AMR_10_2:
+            return 10200;
+        case GSM_AMR_12_2:
+            return 12200;
+        default:
+            return 0;
+    }
+}
+
+
+///////////////////////// FROM CAP CONFIG IN VIDEO ENC NODE ////////////////////
+PVMFStatus PVMFOMXEncNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetConfigParameter() In", iNodeTypeId));
+
+    aNumParamElements = 0;
+
+    // Allocate memory for the KVP
+    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
+    if (NULL == aParameters)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::GetConfigParameter() Memory allocation for KVP failed", iNodeTypeId));
+        return PVMFErrNoMemory;
+    }
+    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
+    // Allocate memory for the key string in KVP
+    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVOMXENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
+    if (NULL == memblock)
+    {
+        oscl_free(aParameters);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::GetConfigParameter() Memory allocation for key string failed", iNodeTypeId));
+        return PVMFErrNoMemory;
+    }
+    oscl_strset(memblock, 0, PVOMXENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
+    // Assign the key string buffer to KVP
+    aParameters[0].key = memblock;
+
+    // Copy the key string
+    if (iInFormat == PVMF_MIME_PCM16)
+    {
+        // Copy the key string
+        oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/encoder/audio/"), 21);
+        oscl_strncat(aParameters[0].key, PVOMXEncNodeConfigBaseKeys[aIndex].iString, oscl_strlen(PVOMXEncNodeConfigBaseKeys[aIndex].iString));
+        oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
+    }
+    else
+    {
+        oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/encoder/video/"), 21);
+        oscl_strncat(aParameters[0].key, PVOMXEncNodeConfigBaseKeys[aIndex].iString, oscl_strlen(PVOMXEncNodeConfigBaseKeys[aIndex].iString));
+        oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
+    }
+    switch (PVOMXEncNodeConfigBaseKeys[aIndex].iValueType)
+    {
+        case PVMI_KVPVALTYPE_BITARRAY32:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_KSV:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_BOOL:
+            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_INT32:
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
+            }
+            break;
+        case PVMI_KVPVALTYPE_UINT32:
+        default:
+            if (PVMI_KVPATTR_CAP == aReqattr)
+            {
+                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
+            }
+            else
+            {
+                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
+            }
+            break;
+    }
+    aParameters[0].key[PVOMXENCNODECONFIG_KEYSTRING_SIZE-1] = 0;
+
+    // Copy the requested info
+    switch (aIndex)
+    {
+
+        case SAMPLING_RATE:	// "sampling_rate"
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // get the parameter here
+                aParameters[0].value.uint32_value = iAudioInputFormat.iInputSamplingRate;
+
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = PVMF_AMRENC_DEFAULT_SAMPLING_RATE;
+
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+
+        case CHANNELS:	// "channels"
+
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // get the par
+                aParameters[0].value.uint32_value = iAudioInputFormat.iInputNumChannels;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = PVMF_AMRENC_DEFAULT_NUM_CHANNELS;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+
+        case ENCODING_MODE:	// "encoding_mode"
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.uint32_value = iVideoEncodeParam.iEncMode;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = EI_ENCMODE_RECORDER;//default setting
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+
+#ifdef _TEST_AE_ERROR_HANDLING
+        case ERROR_START_INIT://error_start_init
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.bool_value = iErrorHandlingInit;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.bool_value = true;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+        case ERROR_ENCODE://error_encode
+            if (PVMI_KVPATTR_CUR == aReqattr)
+            {
+                // Return current value
+                aParameters[0].value.uint32_value = iErrorHandlingEncodeCount;
+            }
+            else if (PVMI_KVPATTR_DEF == aReqattr)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = 1;
+            }
+            else
+            {
+                // Return capability
+            }
+            break;
+
+#endif
+
+        default:
+            // Invalid index
+            oscl_free(aParameters[0].key);
+            oscl_free(aParameters);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::GetConfigParameter() Invalid index to video enc node parameter", iNodeTypeId));
+            return PVMFErrNotSupported;
+    }
+
+    aNumParamElements = 1;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::GetConfigParameter() Out", iNodeTypeId));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFOMXEncNode::VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::VerifyAndSetConfigParameter() In", iNodeTypeId));
+
+    // Determine the valtype
+    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
+    if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::VerifyAndSetConfigParameter() Valtype in key string unknown", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+    // Retrieve the fourth component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(3, aParameter.key, compstr);
+
+    int32 enccomp4ind;
+    for (enccomp4ind = 0; enccomp4ind < PVOMXENCNODECONFIG_BASE_NUMKEYS; ++enccomp4ind)
+    {
+        // Go through each component string at 4th level
+        if (pv_mime_strcmp(compstr, (char*)(PVOMXEncNodeConfigBaseKeys[enccomp4ind].iString)) >= 0)
+        {
+            // Break out of the for loop
+            break;
+        }
+    }
+
+    if (PVOMXENCNODECONFIG_BASE_NUMKEYS <= enccomp4ind)
+    {
+        // Match couldn't be found or non-leaf node specified
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::VerifyAndSetConfigParameter() Unsupported key or non-leaf node", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+
+    // Verify the valtype
+    if (keyvaltype != PVOMXEncNodeConfigBaseKeys[enccomp4ind].iValueType)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::VerifyAndSetConfigParameter() Valtype does not match for key", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+
+    switch (enccomp4ind)
+    {
+
+
+        case SAMPLING_RATE: // "sampling_rate"
+            // Change the parameter
+            if (aSetParam)
+            {
+                // set the parameter here
+                iAudioInputFormat.iInputSamplingRate = aParameter.value.uint32_value;
+                iAudioEncodeParam.iOutputSamplingRate = aParameter.value.uint32_value;
+            }
+            break;
+
+        case CHANNELS:  // "channels"
+            // change the parameter
+            if (aSetParam)
+            {
+                // set the parameter here
+                iAudioInputFormat.iInputNumChannels = aParameter.value.uint32_value;
+                iAudioEncodeParam.iOutputNumChannels = aParameter.value.uint32_value;
+            }
+            break;
+        case ENCODING_MODE: // "encoding_mode"
+            // change the parameter
+            if (aSetParam)
+            {
+                iVideoEncodeParam.iEncMode = (EncEncodingMode)aParameter.value.uint32_value;
+            }
+            break;
+
+
+
+#ifdef _TEST_AE_ERROR_HANDLING
+        case ERROR_START_INIT: // "error_start_init"
+            // change the parameter
+            if (aSetParam)
+            {
+                iErrorHandlingInit = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_ENCODE: // "error_avcencode"
+            // change the parameter
+            if (aSetParam)
+            {
+
+                char* paramstr = NULL;
+                OSCL_HeapString<OsclMemAllocator> mode1 = "mode=duration";
+                OSCL_HeapString<OsclMemAllocator> mode2 = "mode=frames";
+
+                if (pv_mime_string_parse_param(aParameter.key, mode1.get_str(), paramstr) > 0)
+                {
+                    iErrorEncodeFlag = 1;
+                    iErrorHandlingEncodeCount = aParameter.value.uint32_value;
+
+                }
+
+                else if (pv_mime_string_parse_param(aParameter.key, mode2.get_str(), paramstr) > 0)
+                {
+                    iErrorEncodeFlag = 2;
+                    iErrorHandlingEncodeCount = aParameter.value.uint32_value;
+
+                }
+            }
+            break;
+        case ERROR_NODE_CMD: //"error-node-cmd"
+            if (aSetParam)
+            {
+                iErrorNodeCmd = aParameter.value.uint32_value;
+            }
+            break;
+        case ERROR_CONFIG_HEADER:
+            if (aSetParam)
+            {
+                iErrorConfigHeader = aParameter.value.bool_value;
+            }
+            break;
+        case ERROR_DATAPATH_STALL:
+            if (aSetParam)
+            {
+                iErrorDataPathStall = aParameter.value.uint32_value;
+            }
+            break;
+#endif
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::VerifyAndSetConfigParameter() Invalid index for video enc node parameter", iNodeTypeId));
+            return PVMFErrNotSupported;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::VerifyAndSetConfigParameter() Out", iNodeTypeId));
+    return PVMFSuccess;
+}
+
+//void PVMFOMXEncNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP)
+void PVMFOMXEncNode::DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters()", iNodeTypeId));
+    //OSCL_UNUSED_ARG(aSession);
+
+    if (NULL == aParameters || aNumElements < 1)
+    {
+        if (aParameters)
+        {
+            aRetKVP = aParameters;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters() Passed in parameter invalid", iNodeTypeId));
+        return;
+    }
+
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+
+        if ((
+                    (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) < 0) &&
+                    (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) < 0)
+                ) || (compcount < 4))
+        {
+            // First 3 components should be "x-pvmf/encoder/video" or "x-pvmf/encoder/audio" and there must
+            // be at least 4 components
+            aRetKVP = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters() Unsupported key", iNodeTypeId));
+            return;
+        }
+
+        // check if audio parameters are asked from video enc instance or vice versa
+        if (((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) > 0) && (iInFormat == PVMF_MIME_PCM16)) ||
+                ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) > 0) && (iInFormat != PVMF_MIME_PCM16))
+           )
+        {
+
+            aRetKVP = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters() Unsupported key", iNodeTypeId));
+            return;
+        }
+
+        if (4 == compcount)
+        {
+            // Verify and set the passed-in video enc node setting
+            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
+            if (PVMFSuccess != retval)
+            {
+                aRetKVP = &aParameters[paramind];
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters() Setting parameter %d failed", iNodeTypeId, paramind));
+                return;
+            }
+        }
+
+        else
+        {
+            // Do not support more than 4 components right now
+            aRetKVP = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters() Unsupported key", iNodeTypeId));
+            return;
+        }
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigSetParameters() Out", iNodeTypeId));
+}
+
+
+//PVMFStatus PVMFOMXEncNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
+PVMFStatus PVMFOMXEncNode::DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParametersSync()", iNodeTypeId));
+    //OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+
+    // Initialize the output parameters
+    aNumParamElements = 0;
+    aParameters = NULL;
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aIdentifier);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aIdentifier, compstr);
+
+    if ((
+                (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) < 0) &&
+                (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) < 0)
+            ) || (compcount < 4))
+    {
+        // First 3 components should be "x-pvmf/encoder/video" or  "x-pvmf/encoder/audio" and there must
+        // be at least 4 components
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParametersSync() Invalid key string", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+
+    // check if audio parameters are asked from video enc instance or vice versa
+    if (((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) > 0) && (iInFormat == PVMF_MIME_PCM16)) ||
+            ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) > 0) && (iInFormat != PVMF_MIME_PCM16))
+       )
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParameters() Unsupported key", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+
+    // Retrieve the fourth component from the key string
+    pv_mime_string_extract_type(3, aIdentifier, compstr);
+
+    for (int32 enccomp4ind = 0; enccomp4ind < PVOMXENCNODECONFIG_BASE_NUMKEYS; ++enccomp4ind)
+    {
+        // Go through each video enc component string at 4th level
+        if (pv_mime_strcmp(compstr, (char*)(PVOMXEncNodeConfigBaseKeys[enccomp4ind].iString)) >= 0)
+        {
+            if (4 == compcount)
+            {
+                // Determine what is requested
+                PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
+                if (PVMI_KVPATTR_UNKNOWN == reqattr)
+                {
+                    reqattr = PVMI_KVPATTR_CUR;
+                }
+
+                // Return the requested info
+                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, enccomp4ind, reqattr);
+                if (PVMFSuccess != retval)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParametersSync() Retrieving video enc node parameter failed", iNodeTypeId));
+                    return retval;
+                }
+            }
+            else
+            {
+                // Right now videoenc node doesn't support more than 4 components
+                // for this sub-key string so error out
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParametersSync() Unsupported key", iNodeTypeId));
+                return PVMFErrNotSupported;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParametersSync() Out", iNodeTypeId));
+    if (aNumParamElements == 0)
+    {
+        // If no one could get the parameter, return error
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigGetParametersSync() Unsupported key", iNodeTypeId));
+        return PVMFFailure;
+    }
+    else
+    {
+        return PVMFSuccess;
+    }
+}
+
+//PVMFStatus PVMFOMXEncNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+PVMFStatus PVMFOMXEncNode::DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::releaseParameters()", iNodeTypeId));
+    //OSCL_UNUSED_ARG(aSession);
+
+    if (aParameters == NULL || aNumElements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigReleaseParameters() KVP list is NULL or number of elements is 0", iNodeTypeId));
+        return PVMFErrArgument;
+    }
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aParameters[0].key);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
+
+    if ((
+                (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) < 0) &&
+                (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) < 0)
+            ) || (compcount < 3))
+    {
+        // First 3 component should be "x-pvmf/encoder/video" or "x-pvmf/encoder/audio" and there must
+        // be at least three components
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigReleaseParameters() Unsupported key", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+
+    // check if audio parameters are asked from video enc instance or vice versa
+    if (((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) > 0) && (iInFormat == PVMF_MIME_PCM16)) ||
+            ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) > 0) && (iInFormat != PVMF_MIME_PCM16))
+       )
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigReleaseParameters() Unsupported key", iNodeTypeId));
+        return PVMFErrNotSupported;
+    }
+
+    // Retrieve the third component from the key string
+    pv_mime_string_extract_type(2, aParameters[0].key, compstr);
+
+    // Go through each KVP and release memory for value if allocated from heap
+    for (int32 ii = 0; ii < aNumElements; ++ii)
+    {
+        // Next check if it is a value type that allocated memory
+        PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
+        if (PVMI_KVPTYPE_VALUE == kvptype || PVMI_KVPTYPE_UNKNOWN == kvptype)
+        {
+            PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
+            if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigReleaseParameters() Valtype not specified in key string", iNodeTypeId));
+                return PVMFErrNotSupported;
+            }
+
+            if (PVMI_KVPVALTYPE_CHARPTR == keyvaltype && NULL != aParameters[ii].value.pChar_value)
+            {
+                oscl_free(aParameters[ii].value.pChar_value);
+                aParameters[ii].value.pChar_value = NULL;
+            }
+            else if (keyvaltype == PVMI_KVPVALTYPE_KSV && NULL != aParameters[ii].value.key_specific_value)
+            {
+                oscl_free(aParameters[ii].value.key_specific_value);
+                aParameters[ii].value.key_specific_value = NULL;
+            }
+            else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
+            {
+                range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
+                aParameters[ii].value.key_specific_value = NULL;
+                oscl_free(rui32);
+            }
+            // @TODO Add more types if video enc node starts returning more types
+        }
+    }
+
+    // Video enc node allocated its key strings in one chunk so just free the first key string ptr
+    oscl_free(aParameters[0].key);
+
+    // Free memory for the parameter list
+    oscl_free(aParameters);
+    aParameters = NULL;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigReleaseParameters() Out", iNodeTypeId));
+    return PVMFSuccess;
+}
+
+
+//PVMFStatus PVMFOMXEncNode::verifyParametersSync (PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
+PVMFStatus PVMFOMXEncNode::DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters()", iNodeTypeId));
+    //OSCL_UNUSED_ARG(aSession);
+
+    if (NULL == aParameters || aNumElements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters() Passed in parameter invalid", iNodeTypeId));
+        return PVMFErrArgument;
+    }
+
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if (
+            ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) < 0) &&
+             (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) < 0)
+            ) || compcount < 3)
+        {
+            // First 3 components should be "x-pvmf/encoder/video" or
+            // "x-pvmf/enoder/audio" and there must
+            // be at least 3 components
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters() Unsupported key", iNodeTypeId));
+            return PVMFErrNotSupported;
+        }
+
+        // check if audio parameters are asked from video enc instance or vice versa
+        if (((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/video")) > 0) && (iInFormat == PVMF_MIME_PCM16)) ||
+                ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/encoder/audio")) > 0) && (iInFormat != PVMF_MIME_PCM16))
+           )
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters() Unsupported key", iNodeTypeId));
+            return PVMFErrNotSupported;
+        }
+
+        if (4 == compcount)
+        {
+            // Verify and set the passed-in video enc node setting
+            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], false);
+            if (retval != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters() Setting parameter %d failed", iNodeTypeId, paramind));
+                return retval;
+            }
+        }
+        else
+        {
+            // Do not support more than 4 components right now
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters() Unsupported key", iNodeTypeId));
+            return PVMFErrNotSupported;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncNode-%s::DoCapConfigVerifyParameters() Out", iNodeTypeId));
+    return PVMFSuccess;
+
+}
+
+int32 PVMFOMXEncNode::PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, (*aValueListPtr).push_back(aKeyVal));
+    return leavecode;
+}
+
+int32 PVMFOMXEncNode::Push_Back_MetadataKeys(const char* aMetadataKey)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(aMetadataKey));
+    return leavecode;
+}
+
+int32 PVMFOMXEncNode::Push_Back_MetadataKeys(PVMFMetadataList *&aKeylistptr, uint32 aLcv)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aKeylistptr->push_back(iAvailableMetadataKeys[aLcv]));
+    return leavecode;
+}
+
+int32 PVMFOMXEncNode::CreateNewArray(char*& aPtr, int32 aLen)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode,
+             aPtr = OSCL_ARRAY_NEW(char, aLen););
+    return leavecode;
+}
+
+int32 PVMFOMXEncNode::MemAllocate(OsclAny *&aPtr, OsclMemPoolFixedChunkAllocator *aMemPool, uint32 aAllocSize)
+{
+    uint32 errcode = 0;
+    OSCL_TRY(errcode, aPtr = (OsclAny *) aMemPool->allocate(aAllocSize));
+    return errcode;
+}
+
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_node.h b/nodes/pvomxencnode/src/pvmf_omx_enc_node.h
new file mode 100644
index 0000000..4111fe9
--- /dev/null
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_node.h
@@ -0,0 +1,1387 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_OMX_ENC_NODE_H_INCLUDED
+#define PVMF_OMX_ENC_NODE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef PVMF_MEMPOOL_H_INCLUDED
+#include "pvmf_mempool.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVMF_VIDEO_H_INCLUDED
+#include "pvmf_video.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_OMX_ENC_PORT_H_INCLUDED
+#include "pvmf_omx_enc_port.h"
+#endif
+
+#ifndef PVMF_OMX_ENC_NODE_EXTENSION_INTERFACE_H_INCLUDED
+#include "pvmf_omx_enc_node_extension_interface.h"
+#endif
+
+#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
+#include "pvmp4h263encextension.h"
+#endif
+
+#ifndef PVMFAMRENCNODE_EXTENSION_H_INCLUDED
+#include "pvmfamrencnode_extension.h"
+#endif
+
+// DV: NOTE - this needs to be fixed
+//#ifndef __PVM4VENCODER_H
+//#include "pvm4vencoder.h"
+//#endif
+
+#ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
+#include "pvmf_meta_data_extension.h"
+#endif
+
+#ifndef PV_MIME_STRING_UTILS_H_INCLUDED
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef OMX_Core_h
+#include "omx_core.h"
+#endif
+
+#ifndef OMX_Component_h
+#include "omx_component.h"
+#endif
+
+#ifndef PVMF_OMX_ENC_CALLBACKS_H_INCLUDED
+#include "pvmf_omx_enc_callbacks.h"
+#endif
+
+
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
+#endif
+
+#define PVMFOMXENCNODE_NUM_CMD_IN_POOL 8
+#define PVOMXENCMAXNUMDPBFRAMESPLUS1 17
+
+
+typedef struct OutputBufCtrlStruct
+{
+    OMX_BUFFERHEADERTYPE *pBufHdr;
+}OutputBufCtrlStruct;
+
+typedef struct InputBufCtrlStruct
+{
+    OMX_BUFFERHEADERTYPE *pBufHdr;
+    PVMFSharedMediaDataPtr pMediaData;
+} InputBufCtrlStruct;
+
+
+// fwd class declaration
+class PVLogger;
+//memory allocator type for this node.
+typedef OsclMemAllocator PVMFOMXEncNodeAllocator;
+typedef OsclMemAllocDestructDealloc<uint8> PVMFOMXEncNodeAllocDestructDealloc;
+
+
+// CALLBACK PROTOTYPES
+OMX_ERRORTYPE CallbackEventHandlerEnc(OMX_OUT OMX_HANDLETYPE aComponent,
+                                      OMX_OUT OMX_PTR aAppData,
+                                      OMX_OUT OMX_EVENTTYPE aEvent,
+                                      OMX_OUT OMX_U32 aData1,
+                                      OMX_OUT OMX_U32 aData2,
+                                      OMX_OUT OMX_PTR aEventData);
+
+OMX_ERRORTYPE CallbackEmptyBufferDoneEnc(OMX_OUT OMX_HANDLETYPE aComponent,
+        OMX_OUT OMX_PTR aAppData,
+        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+OMX_ERRORTYPE CallbackFillBufferDoneEnc(OMX_OUT OMX_HANDLETYPE aComponent,
+                                        OMX_OUT OMX_PTR aAppData,
+                                        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+
+
+//Default values for number of Input/Output buffers. If the component needs more than this, it will be
+// negotiated. If the component does not need more than this number, the default is used
+#define NUMBER_INPUT_BUFFER 5
+#define NUMBER_OUTPUT_BUFFER 9
+
+// for AMR encoder
+#define MAX_NUM_AMR_FRAMES_PER_BUFFER 25
+#define PVMF_AMRENC_DEFAULT_SAMPLING_RATE 8000
+#define PVMF_AMRENC_DEFAULT_NUM_CHANNELS 1
+#define PVMF_AMRENC_DEFAULT_BITSPERSAMPLE 16
+// in milliseconds
+#define PVMF_AMRENC_DEFAULT_FRAME_DURATION 20
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////
+/////////////////////////
+/////////////////////////
+// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
+//						1) Deallocates the underlying output buffer
+//						2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
+//					  Deallocator is created as part of the wrapper, and travels with the buffer wrapper
+
+class PVOMXBufferSharedPtrWrapperCombinedCleanupDA : public OsclDestructDealloc
+{
+    public:
+        PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
+                buf_alloc(allocator), ptr_to_data_to_dealloc(pMempoolData) {};
+        virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
+
+        virtual void destruct_and_dealloc(OsclAny* ptr)
+        {
+            // call buffer deallocator
+            if (buf_alloc != NULL)
+            {
+                buf_alloc->deallocate(ptr_to_data_to_dealloc);
+            }
+
+            // finally, free the shared ptr wrapper memory
+            oscl_free(ptr);
+        }
+
+    private:
+        Oscl_DefAlloc* buf_alloc;
+        void *ptr_to_data_to_dealloc;
+};
+
+
+
+#define PVMFOMXEncNodeCommandBase PVMFGenericNodeCommand<PVMFOMXEncNodeAllocator>
+
+class PVMFOMXEncNodeCommand: public PVMFOMXEncNodeCommandBase
+{
+    public:
+        //constructor for Custom2 command
+        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
+        {
+            PVMFOMXEncNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)arg1;
+            iParam2 = (OsclAny*)arg2;
+            iParam3 = (OsclAny*) & arg3;
+        }
+        void Parse(int32&arg1, int32&arg2, int32*&arg3)
+        {
+            arg1 = (int32)iParam1;
+            arg2 = (int32)iParam2;
+            arg3 = (int32*)iParam3;
+        }
+
+        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, uint32 aStartIndex, int32 aMaxEntries, char* aQueryKey, const OsclAny* aContext)
+        {
+            PVMFOMXEncNodeCommandBase::Construct(s, cmd, aContext);
+            iStartIndex = aStartIndex;
+            iMaxEntries = aMaxEntries;
+
+            if (aQueryKey == NULL)
+            {
+                query_key[0] = 0;
+            }
+            else
+            {
+                if (aQueryKey != NULL)
+                    oscl_strncpy(query_key, aQueryKey, oscl_strlen(aQueryKey) + 1);
+            }
+
+            iParam1 = (OsclAny*)aKeyList;
+            iParam2 = NULL;
+            iParam3 = NULL;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        }
+
+        void Parse(PVMFMetadataList*& MetaDataListPtr, uint32 &aStartingIndex, int32 &aMaxEntries, char*&aQueryKey)
+        {
+            MetaDataListPtr = (PVMFMetadataList*)iParam1;
+            aStartingIndex = iStartIndex;
+            aMaxEntries = iMaxEntries;
+            if (query_key[0] == 0)
+            {
+                aQueryKey = NULL;
+            }
+            else
+            {
+                aQueryKey = query_key;
+            }
+        }
+
+        // Constructor and parser for GetNodeMetadataValue
+        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, uint32 aStartIndex, int32 aMaxEntries, const OsclAny* aContext)
+        {
+            PVMFOMXEncNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aKeyList;
+            iParam2 = (OsclAny*)aValueList;
+
+            iStartIndex = aStartIndex;
+            iMaxEntries = aMaxEntries;
+
+            iParam3 = NULL;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        }
+        void Parse(PVMFMetadataList* &aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList, uint32 &aStartingIndex, int32 &aMaxEntries)
+        {
+            aKeyList = (PVMFMetadataList*)iParam1;
+            aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
+            aStartingIndex = iStartIndex;
+            aMaxEntries = iMaxEntries;
+        }
+
+
+        virtual bool hipri()
+        {
+            //this routine identifies commands that need to
+            //go at the front of the queue.  derived command
+            //classes can override it if needed.
+            return (iCmd == PVOMXENC_NODE_CMD_CANCELALL
+                    || iCmd == PVOMXENC_NODE_CMD_CANCELCMD);
+        }
+
+        enum PVOMXEncNodeCmdType
+        {
+            PVOMXENC_NODE_CMD_QUERYUUID,
+            PVOMXENC_NODE_CMD_QUERYINTERFACE,
+            PVOMXENC_NODE_CMD_REQUESTPORT,
+            PVOMXENC_NODE_CMD_RELEASEPORT,
+            PVOMXENC_NODE_CMD_INIT,
+            PVOMXENC_NODE_CMD_PREPARE,
+            PVOMXENC_NODE_CMD_START,
+            PVOMXENC_NODE_CMD_STOP,
+            PVOMXENC_NODE_CMD_FLUSH,
+            PVOMXENC_NODE_CMD_PAUSE,
+            PVOMXENC_NODE_CMD_RESET,
+            PVOMXENC_NODE_CMD_CANCELALL,
+            PVOMXENC_NODE_CMD_CANCELCMD,
+            PVOMXENC_NODE_CMD_GETNODEMETADATAKEY,
+            PVOMXENC_NODE_CMD_GETNODEMETADATAVALUE,
+            PVOMXENC_NODE_CMD_INVALID
+        };
+
+
+
+
+    private:
+        uint32 iStartIndex;
+        uint32 iMaxEntries;
+        char query_key[256];
+
+};
+
+//Default vector reserve size
+#define PVMF_OMXENC_NODE_COMMAND_VECTOR_RESERVE 10
+
+//Starting value for command IDs
+#define PVMF_OMXENC_NODE_COMMAND_ID_START 6000
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////// STRUCTURES FOR ENCODING PARAMETERS ////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////
+#define MAX_LAYER 1
+
+/** Contains supported input format */
+enum EncVideoInputFormat
+{
+    EI_RGB24,
+    EI_RGB12,
+    EI_YUV420,
+    EI_UYVY
+};
+
+/** Type of contents for optimal encoding mode. */
+enum EncContentType
+{
+    /** Content is to be streamed in real-time. */
+    EI_M4V_STREAMING,
+
+    /** Content is to be downloaded and playbacked later.*/
+    EI_M4V_DOWNLOAD,
+
+    /** Content is to be 3gpp baseline compliant. */
+    EI_H263,
+
+    EI_H264
+};
+
+/** Rate control type. */
+enum EncRateControlType
+{
+    /** Constant quality, variable bit rate, fixed quantization level. */
+    ECONSTANT_Q,
+
+    /** Short-term constant bit rate control. */
+    ECBR_1,
+
+    /** Long-term constant bit rate control. */
+    EVBR_1
+};
+
+/** Targeted profile and level to encode. */
+enum EncM4VProfileLevel
+{
+    /* Non-scalable profile */
+    EI_SIMPLE_LEVEL0 = 0,
+    EI_SIMPLE_LEVEL1,
+    EI_SIMPLE_LEVEL2,
+    EI_SIMPLE_LEVEL3,
+    EI_CORE_LEVEL1,
+    EI_CORE_LEVEL2,
+
+    /* Scalable profile */
+    EI_SIMPLE_SCALABLE_LEVEL0 = 6,
+    EI_SIMPLE_SCALABLE_LEVEL1,
+    EI_SIMPLE_SCALABLE_LEVEL2,
+
+    EI_CORE_SCALABLE_LEVEL1 = 10,
+    EI_CORE_SCALABLE_LEVEL2,
+    EI_CORE_SCALABLE_LEVEL3
+};
+
+/** Targeted profile to encode. */
+enum EncAVCProfile
+{
+    /* Non-scalable profile */
+    EI_PROFILE_DEFAULT,
+    EI_PROFILE_BASELINE,
+    EI_PROFILE_MAIN,
+    EI_PROFILE_EXTENDED,
+    EI_PROFILE_HIGH,
+    EI_PROFILE_HIGH10,
+    EI_PROFILE_HIGH422,
+    EI_PROFILE_HIGH444
+};
+
+/** Targeted level to encode. */
+enum EncAVCLevel
+{
+    EI_LEVEL_AUTODETECT,
+    EI_LEVEL_1,
+    EI_LEVEL_1B,
+    EI_LEVEL_11,
+    EI_LEVEL_12,
+    EI_LEVEL_13,
+    EI_LEVEL_2,
+    EI_LEVEL_21,
+    EI_LEVEL_22,
+    EI_LEVEL_3,
+    EI_LEVEL_31,
+    EI_LEVEL_32,
+    EI_LEVEL_4,
+    EI_LEVEL_41,
+    EI_LEVEL_42,
+    EI_LEVEL_5,
+    EI_LEVEL_51,
+};
+
+/** Output format */
+enum TAVCEIOutputFormat
+{
+    /** output in byte stream format according to Annex B */
+    EAVCEI_OUTPUT_ANNEXB,
+
+    /** output for MP4 file format */
+    EAVCEI_OUTPUT_MP4,
+
+    /** output in RTP format according to RFC 3984 */
+    EAVCEI_OUTPUT_RTP
+};
+
+
+
+/** Type of contents for optimal encoding mode. */
+enum EncEncodingMode
+{
+    /** Content is encoded as fast as possible with error protection */
+    EI_ENCMODE_TWOWAY,
+
+    /** Content is encoded as fast as possible without error protection */
+    EI_ENCMODE_RECORDER,
+
+    /** Content is encoded with better quality (slow) with error protection */
+    EI_ENCMODE_STREAMING,
+
+    /** Content is encoded with better quality (slow) without error protection */
+    EI_ENCMODE_DOWNLOAD
+};
+
+
+/** This structure contains encoder settings. */
+typedef struct PV_VideoEncodeParam
+{
+
+////////////////////////////////////////////////////////////////////////////////////
+////////////////////////// COMMON PARAMETERS ///////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////
+
+    /** Specifies an  ID that will be used to specify this encoder while returning
+    the bitstream in asynchronous mode. */
+    uint32				iEncodeID;
+
+
+    /** Specifies whether base only (iNumLayer = 1) or base + enhancement layer
+    (iNumLayer =2 ) is to be used. */
+    int32				iNumLayer;
+
+    /** Specifies the width in pixels of the encoded frames. IFrameWidth[0] is for
+    base layer and iFrameWidth[1] is for enhanced layer. */
+    int 				iFrameWidth[MAX_LAYER];
+
+    /** Specifies the height in pixels of the encoded frames. IFrameHeight[0] is for
+    base layer and iFrameHeight[1] is for enhanced layer. */
+    int					iFrameHeight[MAX_LAYER];
+
+    /** Specifies the cumulative bit rate in bit per second. IBitRate[0] is for base
+    layer and iBitRate[1] is for base+enhanced layer.*/
+    int 				iBitRate[MAX_LAYER];
+
+    /** Specifies the cumulative frame rate in frame per second. IFrameRate[0] is for
+    base layer and iFrameRate[1] is for base+enhanced layer. */
+    float 				iFrameRate[MAX_LAYER];
+
+    /** Specifies the rate control algorithm among one of the following constant Q,
+    CBR and VBR.  The structure EncRateControlType is defined above.*/
+    EncRateControlType iRateControlType;
+
+    /** Specifies the initial quantization parameter for the first I-frame. If constant Q
+    rate control is used, this QP will be used for all the I-frames. This number must be
+    set between 1 and 31, otherwise, Initialize() will fail. */
+    int					iIquant[2];
+
+    /** Specifies the initial quantization parameter for the first P-frame. If constant Q
+    rate control is used, this QP will be used for all the P-frames. This number must be
+    set between 1 and 31, otherwise, Initialize() will fail. */
+    int					iPquant[2];
+
+    /** Specifies the initial quantization parameter for the first B-frame. If constant Q
+    rate control is used, this QP will be used for all the B-frames. This number must be
+    set between 1 and 31, otherwise, Initialize() will fail. */
+    int					iBquant[2];
+
+
+    /** Specifies the maximum number of P-frames between 2 INTRA frames. An INTRA mode is
+    forced to a frame once this interval is reached. When there is only one I-frame is present
+    at the beginning of the clip, iIFrameInterval should be set to -1. */
+    int32				iIFrameInterval;
+
+    /** According to iIFrameInterval setting, the minimum number of intra MB per frame is
+    optimally calculated for error resiliency. However, when iIFrameInterval is set to -1,
+    iNumIntraMBRefresh must be specified to guarantee the minimum number of intra
+    macroblocks per frame.*/
+    uint32				iNumIntraMBRefresh;
+
+    /** Specifies automatic scene detection where I-frame will be used the the first frame
+    in a new scene. */
+    bool				iSceneDetection;
+
+    /** Specifies the packet size in bytes which represents the number of bytes between two resync markers.
+    For EI_M4V_DOWNLOAD and EI_H263, if iPacketSize is set to 0, there will be no resync markers in the bitstream.
+    For EI_M4V_STREAMING is parameter must be set to a value greater than 0. For AVC, this value specifies
+    the packet size in bytes which represents the desired number of bytes per NAL.
+    If this number is set to 0, the AVC encoder will encode the entire slice group as one NAL. */
+    uint32				iPacketSize;
+
+    /** Specifies the VBV buffer size which determines the end-to-end delay between the
+    encoder and the decoder.  The size is in unit of seconds. For download application,
+    the buffer size can be larger than the streaming application. For 2-way application,
+    this buffer shall be kept minimal. For a special case, in VBR mode, iBufferDelay will
+    be set to -1 to allow buffer underflow. */
+    float				iBufferDelay;
+
+
+    /** Specifies the duration of the clip in millisecond.*/
+    int32				iClipDuration;
+
+
+////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////// H263/M4V specific parameters ///////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////
+
+    /** Specifies the profile and level used to encode the bitstream. When present,
+    other settings will be checked against the range allowable by this target profile
+    and level. Fail may be returned from the Initialize call. */
+    EncM4VProfileLevel	iProfileLevel;
+
+    /** Specifies the picture quality factor on the scale of 1 to 10. It trades off
+    the picture quality with the frame rate. Higher frame quality means lower frame rate.
+    Lower frame quality for higher frame rate.*/
+    int32				iFrameQuality;
+
+
+    /** Enable the use of iFrameQuality to determine the frame rate. If it is false,
+    the encoder will try to meet the specified frame rate regardless of the frame quality.*/
+    bool				iEnableFrameQuality;
+
+
+    /** Specifies the type of the access whether it is streaming, EI_H263, EI_M4V_STREAMING
+    (data partitioning mode) or download, EI_M4V_DOWNLOAD (combined mode).*/
+    EncContentType		iContentType;
+
+
+    /** Specifies high quality but also high complexity mode for rate control. */
+    bool				iRDOptimal;
+
+
+    /** Specifies the search range in pixel unit for motion vector. The range of the
+    motion vector will be of dimension [-iSearchRange.5, +iSearchRange.0]. */
+    int32				iSearchRange;
+
+    /** Specifies the use of 8x8 motion vectors. */
+    bool				iMV8x8;
+
+    /** Specifies the use of half-pel motion vectors. */
+    bool				iMVHalfPel;
+
+    /** Specifies whether the current frame skipping decision is allowed after encoding
+    the current frame. If there is no memory of what has been coded for the current frame,
+    iNoCurrentSkip has to be on. */
+    bool				iNoCurrentSkip;
+
+    /** Specifies that no frame skipping is allowed. Frame skipping is a tool used to
+    control the average number of bits spent to meet the target bit rate. */
+    bool				iNoFrameSkip;
+
+    /** Specifies whether RVLC (reversible VLC) is to be used or not.
+    */
+    bool				iRVLCEnable;
+
+////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////// H264 specific parameters ///////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////
+
+    /** Specifies the targeted profile, and will also specifies available tools for iEncMode.
+    If default is used, encoder will choose its own preferred profile. If autodetect is used, encoder
+    will check other settings and choose the right profile that doesn't have any conflicts. */
+    EncAVCProfile		iAVCProfile;
+
+    /** Specifies the target level  When present,
+    other settings will be checked against the range allowable by this target level.
+    Fail will returned upon Initialize call. If not known, users must set it to autodetect. Encoder will
+    calculate the right level that doesn't conflict with other settings. */
+    EncAVCLevel			iAVCLevel;
+
+    /** Specifies the encoding mode. This translates to the complexity of encoding modes and
+    error resilient tools. This is for future use - enc mode will be used to set other parameters to appropriate
+    values.
+    */
+
+    EncEncodingMode		iEncMode;
+
+    /** Specifies that SPS and PPS are retrieved first and sent out-of-band */
+    //bool				iOutOfBandParamSet;
+
+
+} PV_VideoEncodeParam;
+
+
+
+/** Structure for input format information */
+typedef struct PV_VideoInputFormat
+{
+    /** Contains the width in pixels of the input frame. */
+    int32 			iFrameWidth;
+
+    /** Contains the height in pixels of the input frame. */
+    int32			iFrameHeight;
+
+    /** Contains the input frame rate in the unit of frame per second. */
+    float			iFrameRate;
+
+    /** Contains Frame Orientation. Used for RGB input. 1 means Bottom_UP RGB, 0 means Top_Down RGB, -1 for video formats other than RGB*/
+    int				iFrameOrientation;
+
+    /** Contains the format of the input video, e.g., YUV 4:2:0, UYVY, RGB24, etc. */
+    EncVideoInputFormat 	iVideoFormat;
+} PV_VideoInputFormat;
+
+
+/** Structure for audio encode information */
+typedef struct PV_AudioEncodeParam
+{
+
+    // DESCRIPTION: Final sampling frequency used when encoding in Hz.
+    //              For example, "44100" Hz.
+    // USAGE:       If the input sampling rate is not appropriate (e.g.,
+    //              the codec requires a different sampling frequency),
+    //              the CAEI will fill this in with the final sampling
+    //              rate. The CAEI will perform resampling if the
+    //              input sampling frequency is not the same as the output
+    //              sampling frequency.
+    uint32 iOutputSamplingRate;
+
+    // DESCRIPTION: Number of output channels:1=Mono,2=Stereo. (Mono uses 1
+    //              channel; Stereo uses 2 channels).
+    // USAGE:       The CAEI will fill this in if it needs to convert
+    //              the input samples to what is required by the codec.
+    uint8 iOutputNumChannels;
+
+    // DESCRIPTION: Currently, output bitrate is expressed as GSM-AMR type rate
+    PVMF_GSMAMR_Rate iOutputBitrate;
+
+    //
+    uint32	iMaxNumOutputFramesPerBuffer;
+
+
+} PV_AudioEncodeParam;
+
+enum EInterleaveMode
+{
+    EINTERLEAVE_LR,        // interleaved left-right
+    EGROUPED_LR,           // non-interleaved left-right
+    ENUM_INTERLEAVE_MODES  // number of modes supported
+};
+
+/** Structure for input format information */
+typedef struct PV_AudioInputFormat
+{
+
+
+    // DESCRIPTION: Number of bits per sample. For example, set it to "16"
+    //              bits for PCM.
+    // USAGE:       The authoring application is required to fill this in.
+    //
+    int32 iInputBitsPerSample;
+
+    // DESCRIPTION: Sampling rate of the input samples in Hz.
+    //              For example, set it to "22050" Hz. AMRNB is always 8khz
+    // USAGE:       The authoring application is required to fill this in.
+    //              If sampling rate is not known until CAEI is initialized,
+    //              use '0'.
+    uint32 iInputSamplingRate;
+
+
+    // DESCRIPTION: Number of input channels:1=Mono,2=Stereo.(Mono uses 1 channel;
+    //              Stereo uses 2 channels).
+    // USAGE:       The authoring application is required to fill this in.
+    //
+    uint8 iInputNumChannels;
+
+    // DESCRIPTION: Whether to interleave or not the multi-channel input samples:
+    //              EINTERLEAVE_LR  = LRLRLRLRLR    (interleaved left-right)
+    //              EGROUPED_LR = LLLLLL...RRRRRR   (non-interleaved left-right)
+    // USAGE:       The authoring application is required to fill this in.
+    //
+    EInterleaveMode iInputInterleaveMode;
+
+
+
+} PV_AudioInputFormat;
+
+
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+//CAPABILITY AND CONFIG
+
+// Structure to hold the key string info for
+// encnode's capability-and-config
+struct PVOMXEncNodeKeyStringData
+{
+    char iString[64];
+    PvmiKvpType iType;
+    PvmiKvpValueType iValueType;
+};
+
+// The number of characters to allocate for the key string
+#define PVOMXENCNODECONFIG_KEYSTRING_SIZE 128
+
+
+// Key string info at the base level ("x-pvmf/encoder/video")
+//								  or ("x-pvmf/encoder/audio")
+
+#ifdef _TEST_AE_ERROR_HANDLING
+#define PVOMXENCNODECONFIG_BASE_NUMKEYS 8
+#else
+#define PVOMXENCNODECONFIG_BASE_NUMKEYS 3
+#endif
+
+const PVOMXEncNodeKeyStringData PVOMXEncNodeConfigBaseKeys[PVOMXENCNODECONFIG_BASE_NUMKEYS] =
+{
+    {"sampling_rate", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"channels", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"encoding_mode", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+#ifdef _TEST_AE_ERROR_HANDLING
+    , {"error_start_init", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"error-encode", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"error-node-cmd", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    , {"error-config-header", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+    , {"data-path-stall", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+#endif
+};
+
+enum BaseKeys_IndexMapType
+{
+    SAMPLING_RATE = 0, // audio
+    CHANNELS,			// audio
+    ENCODING_MODE		// avc
+#ifdef _TEST_AE_ERROR_HANDLING
+    , ERROR_START_INIT
+    , ERROR_ENCODE
+    , ERROR_NODE_CMD
+    , ERROR_CONFIG_HEADER
+    , ERROR_DATAPATH_STALL
+#endif
+};
+
+// default encode parameters
+#define DEFAULT_BITRATE 32000
+#define DEFAULT_FRAME_WIDTH 176
+#define DEFAULT_FRAME_HEIGHT 144
+#define DEFAULT_FRAME_RATE 5
+#define DEFAULT_OMX_MP4ENC_QPI 15
+#define DEFAULT_OMX_MP4ENC_QPP 12
+#define DEFAULT_OMX_MP4ENC_QPB 12
+
+#define DEFAULT_OMX_AVCENC_QPI 25
+#define DEFAULT_OMX_AVCENC_QPP 30
+#define DEFAULT_OMX_AVCENC_QPB 33
+
+#define PVMF_AVCENC_NODE_SPS_VECTOR_RESERVE 16  // max allowed by standard
+#define PVMF_AVCENC_NODE_PPS_VECTOR_RESERVE 256 // max allowed by standard
+#define DEFAULT_PARAMS_SET_LENGTH 256
+
+typedef enum
+{
+    PV_MPEG_VIDEO_SIMPLE_PROFILE = 0,
+    PV_MPEG_VIDEO_SIMPLE_SCALABLE_PROFILE,
+    PV_MPEG_VIDEO_CORE_PROFILE,
+    PV_MPEG_VIDEO_MAIN_PROFILE,
+    PV_MPEG_VIDEO_N_BIT_PROFILE,
+    PV_MPEG_VIDEO_SCALABLE_TEXTURE_PROFILE,
+    PV_MPEG_VIDEO_SIMPLE_FACE_ANIMATION_PROFILE,
+    PV_MPEG_VIDEO_SIMPLE_FBA_PROFILE,
+    PV_MPEG_VIDEO_BASIC_ANIMATED_TEXTURE_PROFILE,
+    PV_MPEG_VIDEO_HYBRID_PROFILE,
+    PV_MPEG_VIDEO_ADVANCE_REAL_TIME_SIMPLE_PROFILE,
+    PV_MPEG_VIDEO_CORE_SCALABLE_PROFILE,
+    PV_MPEG_VIDEO_ADVANCE_CODING_EFFICIENCY_PROFILE,
+    PV_MPEG_VIDEO_ADVANCE_CORE_PROFILE,
+    PV_MPEG_VIDEO_ADVANCE_SCALABLE_TEXTURE_PROFILE,
+    PV_MPEG_VIDEO_SIMPLE_STUDIO_PROFILE,
+    PV_MPEG_VIDEO_CORE_STUDIO_PROFILE,
+    PV_MPEG_VIDEO_ADVANCE_SIMPLE_PROFILE,
+    PV_MPEG_VIDEO_FINE_GRANUALITY_SCALABLE_PROFILE,
+    PV_MPEG_VIDEO_RESERVED_PROFILE
+}PVMF_MPEGVideoProfileType;
+
+typedef enum
+{
+    PV_MPEG_VIDEO_LEVEL0 = 0,
+    PV_MPEG_VIDEO_LEVEL1,
+    PV_MPEG_VIDEO_LEVEL2,
+    PV_MPEG_VIDEO_LEVEL3,
+    PV_MPEG_VIDEO_LEVEL4,
+    PV_MPEG_VIDEO_LEVEL5,
+    PV_MPEG_VIDEO_LEVEL_UNKNOWN
+
+}PVMF_MPEGVideoLevelType;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+
+
+//Mimetypes for the custom interface
+#define PVMF_OMX_ENC_NODE_MIMETYPE "pvxxx/OMXEncNode"
+#define PVMF_BASEMIMETYPE "pvxxx"
+
+//Command queue type
+typedef PVMFNodeCommandQueue<PVMFOMXEncNodeCommand, PVMFOMXEncNodeAllocator> PVMFOMXEncNodeCmdQ;
+
+
+class PVMFOMXEncNode
+            : public OsclActiveObject
+            , public PVMFNodeInterface
+            , public OsclMemPoolFixedChunkAllocatorObserver
+            , public PVMFOMXEncNodeExtensionInterface
+            , public PVMFMetadataExtensionInterface
+            , public PvmiCapabilityAndConfig
+            , public PVMp4H263EncExtensionInterface
+            , public PVAMREncExtensionInterface
+
+{
+    public:
+        PVMFOMXEncNode(int32 aPriority);
+        ~PVMFOMXEncNode();
+
+        // From PVMFNodeInterface
+        PVMFStatus ThreadLogon();
+        PVMFStatus ThreadLogoff();
+        PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+        PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
+                                Oscl_Vector<PVUuid, PVMFOMXEncNodeAllocator>& aUuids,
+                                bool aExactUuidsOnly = false,
+                                const OsclAny* aContext = NULL);
+        PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                                     PVInterface*& aInterfacePtr,
+                                     const OsclAny* aContext = NULL);
+        PVMFCommandId RequestPort(PVMFSessionId
+                                  , int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL);
+        PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+        PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
+        PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
+        PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+
+        // From PVMFPortActivityHandler
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        // From PVInterface
+        virtual void addRef();
+        virtual void removeRef();
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+
+        //**********begin PVMFMetadataExtensionInterface
+        uint32 GetNumMetadataKeys(char* query_key = NULL);
+        uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
+        PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries,
+                                          char* query_key = NULL, const OsclAny* aContextData = NULL);
+        PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList,
+                                            Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContextData = NULL);
+        PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, uint32 starting_index, uint32 end_index);
+        PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, uint32 end_index);
+        //**********End PVMFMetadataExtensionInterface
+
+        bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+        //********** CB Functions to serve OpenMAX Encoder
+
+        //Process callback functions. They will be executed in testapp thread context
+        //	These callbacks are used only in the Multithreaded component case
+        OsclReturnCode ProcessCallbackEventHandler_MultiThreaded(OsclAny* P);
+        OsclReturnCode ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P);
+        OsclReturnCode ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P);
+
+        //Callback objects - again, these are used only in the case of Multithreaded component
+        EventHandlerThreadSafeCallbackAOEnc*	 iThreadSafeHandlerEventHandler;
+        EmptyBufferDoneThreadSafeCallbackAOEnc* iThreadSafeHandlerEmptyBufferDone;
+        FillBufferDoneThreadSafeCallbackAOEnc*  iThreadSafeHandlerFillBufferDone;
+
+        OMX_CALLBACKTYPE       iCallbacks; // structure that contains callback ptrs.
+        // OMX CALLBACKS
+        // 1) AO OMX component running in the same thread as the OMX node
+        //	In this case, the callbacks can be called directly from the component
+        //	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
+        //	The callback can perform do RunIfNotReady
+
+        // 2) Multithreaded component
+        //	In this case, the callback is made using the threadsafe callback (TSCB) AO
+        //	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent)
+        //  Node thread		 : TSCB(ProcessEvent)->ProcessCallbackEventHandler_MultiThreaded->EventHandlerProcessing
+
+
+        //==============================================================================
+
+        OMX_ERRORTYPE EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+                                             OMX_OUT OMX_PTR aAppData,
+                                             OMX_OUT OMX_EVENTTYPE aEvent,
+                                             OMX_OUT OMX_U32 aData1,
+                                             OMX_OUT OMX_U32 aData2,
+                                             OMX_OUT OMX_PTR aEventData);
+
+        OMX_ERRORTYPE EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+                                                OMX_OUT OMX_PTR aAppData,
+                                                OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+        OMX_ERRORTYPE FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
+                                               OMX_OUT OMX_PTR aAppData,
+                                               OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+
+
+
+        bool IsComponentMultiThreaded()
+        {
+            return iIsOMXComponentMultiThreaded;
+        };
+
+
+        // From PvmiCapabilityAndConfig
+        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
+        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
+        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements);
+        void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
+        PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext = NULL);
+        uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
+
+        // Virtual functions of PVMp4H263EncExtensionInterface
+//	OSCL_IMPORT_REF void addRef();
+//	OSCL_IMPORT_REF void removeRef();
+//	OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        OSCL_IMPORT_REF bool SetNumLayers(uint32 aNumLayers);
+        OSCL_IMPORT_REF bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate);
+        OSCL_IMPORT_REF bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight);
+        OSCL_IMPORT_REF bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate);
+        OSCL_IMPORT_REF bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes);
+        OSCL_IMPORT_REF bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl);
+        OSCL_IMPORT_REF bool SetDataPartitioning(bool aDataPartitioning);
+        OSCL_IMPORT_REF bool SetRVLC(bool aRVLC);
+        OSCL_IMPORT_REF bool SetIFrameInterval(uint32 aIFrameInterval);
+        OSCL_IMPORT_REF bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader);
+        OSCL_IMPORT_REF bool RequestIFrame();
+        OSCL_IMPORT_REF bool SetSceneDetection(bool aSCD);
+        OSCL_IMPORT_REF bool SetCodec(PVMFFormatType aCodec);
+
+
+
+        PVMFStatus SetCodecType(PVMFFormatType aCodec);
+
+        OSCL_IMPORT_REF virtual bool SetFSIParam(uint8* aFSIBuff, int aFSIBuffLength);
+
+        // from AMREncExtensionInterface
+        OSCL_IMPORT_REF PVMFStatus SetOutputBitRate(PVMF_GSMAMR_Rate aBitRate);
+        OSCL_IMPORT_REF PVMFStatus SetMaxNumOutputFramesPerBuffer(uint32 aNumOutputFrames);
+
+        PVMFStatus SetInputSamplingRate(uint32 aSamplingRate);
+        PVMFStatus SetInputBitsPerSample(uint32 aBitsPerSample);
+        PVMFStatus SetInputNumChannels(uint32 aNumChannels);
+        uint32 GetOutputBitRate(); // for audio - void
+        // encoder input format setting
+        /////////////////////////////////////////////////////
+        //      Encoder settings routine
+        /////////////////////////////////////////////////////
+        PVMFStatus SetInputFormat(PVMFFormatType aFormat);
+        PVMFStatus SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient = 0);
+        PVMFStatus SetInputFrameRate(OsclFloat aFrameRate);
+
+
+        PVMFFormatType GetCodecType();
+        uint32 GetOutputBitRate(uint32 aLayer);
+        OsclFloat GetOutputFrameRate(uint32 aLayer);
+        PVMFStatus GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight);
+        uint32 GetIFrameInterval();
+
+    private:
+        void CommandComplete(PVMFOMXEncNodeCmdQ& aCmdQ, PVMFOMXEncNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData = NULL);
+
+        void DoQueryUuid(PVMFOMXEncNodeCommand&);
+        void DoQueryInterface(PVMFOMXEncNodeCommand&);
+        void DoRequestPort(PVMFOMXEncNodeCommand&);
+        void DoReleasePort(PVMFOMXEncNodeCommand&);
+        void DoInit(PVMFOMXEncNodeCommand&);
+        void DoPrepare(PVMFOMXEncNodeCommand&);
+        void DoStart(PVMFOMXEncNodeCommand&);
+        void DoStop(PVMFOMXEncNodeCommand&);
+        void DoPause(PVMFOMXEncNodeCommand&);
+        void DoReset(PVMFOMXEncNodeCommand&);
+        void DoFlush(PVMFOMXEncNodeCommand&);
+        PVMFStatus DoGetNodeMetadataKey(PVMFOMXEncNodeCommand&);
+        PVMFStatus DoGetNodeMetadataValue(PVMFOMXEncNodeCommand&);
+        void DoCancelAllCommands(PVMFOMXEncNodeCommand&);
+        void DoCancelCommand(PVMFOMXEncNodeCommand&);
+
+        void Run();
+        bool ProcessCommand(PVMFOMXEncNodeCommand& aCmd);
+        bool ProcessIncomingMsg(PVMFPortInterface* aPort);
+        bool ProcessOutgoingMsg(PVMFPortInterface* aPort);
+        PVMFStatus HandleProcessingState();
+
+
+
+
+        // DV:
+        bool NegotiateVideoComponentParameters();
+        bool SetMP4EncoderParameters();
+        bool SetH263EncoderParameters();
+        bool SetH264EncoderParameters();
+
+        bool NegotiateAudioComponentParameters();
+        bool SetAMREncoderParameters();
+
+        bool SetDefaultCapabilityFlags();
+        bool CreateOutMemPool(uint32 num);
+        bool CreateInputMemPool(uint32 num);
+        bool ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+                                       uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                       uint32 aNumBuffers,    // number of buffers
+                                       uint32 aActualBufferSize, // aactual buffer size
+                                       uint32 aPortIndex,      // port idx
+                                       bool aUseBufferOK,	// can component use OMX_UseBuffer?
+                                       bool	aIsThisInputBuffer // is this input or output
+                                      );
+
+        bool FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
+                                      uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                      uint32 aNumBuffers,    // number of buffers
+                                      uint32 aPortIndex,      // port idx
+                                      bool	aIsThisInputBuffer		// is this input or output
+                                     );
+
+        OsclSharedPtr<class PVMFMediaDataImpl> WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext);
+        bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen);
+
+        bool SendOutputBufferToOMXComponent();
+        bool SendInputBufferToOMXComponent();
+
+
+        bool SendEOSBufferToOMXComponent();
+
+        bool SendBeginOfMediaStreamCommand(void);
+        bool SendEndOfTrackCommand(void);
+
+
+
+        bool ReleaseAllPorts();
+        bool DeleteOMXEncoder();
+
+        void ChangeNodeState(TPVMFNodeInterfaceState aNewState);
+
+        void HandleComponentStateChange(OMX_U32 encoder_state);
+
+        // Capability And Config Helper Methods
+        PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
+        PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements);
+        void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
+        PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
+
+        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr);
+        PVMFStatus VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam);
+
+        PVMFStatus GetProfileAndLevel(PVMF_MPEGVideoProfileType& aProfile, PVMF_MPEGVideoLevelType& aLevel);
+
+
+
+        void freechunkavailable(OsclAny*);
+
+        PVMFCommandId QueueCommandL(PVMFOMXEncNodeCommand& aCmd);
+
+
+        int32 PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*&, PvmiKvp&);
+        int32 Push_Back_MetadataKeys(const char*);
+        int32 Push_Back_MetadataKeys(PVMFMetadataList*&, uint32);
+        int32 CreateNewArray(char*&, int32);
+        int32 MemAllocate(OsclAny*& , OsclMemPoolFixedChunkAllocator*, uint32);
+
+        friend class PVMFOMXEncPort;
+
+        // Ports pointers
+        PVMFPortInterface* iInPort;
+        PVMFPortInterface* iOutPort;
+
+        // Commands
+        PVMFOMXEncNodeCmdQ iInputCommands;
+        PVMFOMXEncNodeCmdQ iCurrentCommand;
+
+        // Shared pointer for Media Msg.Input buffer
+        PVMFSharedMediaDataPtr iDataIn;
+
+
+        // OUTPUT BUFFER RELATED MEMBERS
+
+
+        // Output buffer memory pool
+        OsclMemPoolFixedChunkAllocator *iOutBufMemoryPool;
+
+        // Memory pool for simple media data
+        OsclMemPoolFixedChunkAllocator *iMediaDataMemPool;
+
+
+
+        // Size of output buffer (negotiated with component)
+        uint32 iOMXComponentOutputBufferSize;
+
+        // size of output to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
+        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentOutputBufferSize)
+        uint32 iOutputAllocSize;
+
+        // Number of output buffers (negotiated with component)
+        uint32 iNumOutputBuffers;
+
+        // Number of output buffers in possession of the component or downstream,
+        // namely, number of unavailable buffers
+        uint32 iNumOutstandingOutputBuffers;
+
+        // flag to prevent sending output buffers downstream during flushing etc.
+        bool iDoNotSendOutputBuffersDownstreamFlag;
+
+        // flag to prevent freeing the buffers twice
+        bool iOutputBuffersFreed;
+
+
+        // INPUT BUFFER RELATED MEMBERS
+        OsclMemPoolFixedChunkAllocator *iInBufMemoryPool;
+        uint32 iOMXComponentInputBufferSize; // size of input buffer that the component sees (negotiated with the component)
+        uint32 iInputAllocSize; 	// size of input buffer to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
+        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentInputBufferSize)
+        uint32 iNumInputBuffers; // total num of input buffers (negotiated with component)
+
+        uint32 iNumOutstandingInputBuffers; // number of input buffers in use (i.e. unavailable)
+
+        bool iDoNotSaveInputBuffersFlag;
+
+        // flag to prevent freeing buffers twice
+        bool iInputBuffersFreed;
+
+        // input buffer fragmentation etc.
+        uint32 iCopyPosition;				// for copying memfrag data into a buffer
+        uint32 iFragmentSizeRemainingToCopy;
+        bool	iIsNewDataFragment;
+
+        // input data info
+        uint32 iCurrFragNum;
+        uint32 iCodecSeqNum;	// sequence number tracking
+        uint32 iInPacketSeqNum;
+
+        uint32 iInTimestamp;
+        uint32 iInDuration;
+        uint32 iInNumFrags;
+        uint32 iCurrentMsgMarkerBit;
+
+        // DYNAMIC PORT RE-CONFIGURATION
+        uint32 iInputPortIndex;
+        uint32 iOutputPortIndex;
+        OMX_PARAM_PORTDEFINITIONTYPE iParamPort;
+        uint32 iPortIndexForDynamicReconfig;
+        bool iSecondPortReportedChange;
+        bool iDynamicReconfigInProgress;
+        uint32 iSecondPortToReconfig;
+
+
+
+        OMX_BUFFERHEADERTYPE *iInputBufferToResendToComponent; // ptr to input buffer that is not empty, but that the OMX component returned
+        // we need to resend this same buffer back to the component
+
+
+        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS
+        bool iOMXComponentSupportsExternalOutputBufferAlloc;
+        bool iOMXComponentSupportsExternalInputBufferAlloc;
+        bool iOMXComponentSupportsMovableInputBuffers;
+        bool iOMXComponentNeedsNALStartCode;
+        bool iOMXComponentSupportsPartialFrames;
+        bool iOMXComponentCanHandleIncompleteFrames;
+
+        bool iSetMarkerBitForEveryFrag;
+        bool iIsOMXComponentMultiThreaded;
+
+        // State definitions for HandleProcessingState() state machine
+        typedef enum
+        {
+            EPVMFOMXEncNodeProcessingState_Idle,                  //default state after constraction/reset
+            EPVMFOMXEncNodeProcessingState_ReadyToEncode,         //nornal operation state of the encoder
+            EPVMFOMXEncNodeProcessingState_WaitForOutputBuffer,   //wait state for avalible media output buffer
+            EPVMFOMXEncNodeProcessingState_WaitForOutputPort,     //wait state, output port is busy
+            EPVMFOMXEncNodeProcessingState_WaitForOutgoingQueue,   //wait state, outgoing queue
+            EPVMFOMXEncNodeProcessingState_PortReconfig,			// Dynamic Port Reconfiguration - step 1
+            EPVMFOMXEncNodeProcessingState_WaitForBufferReturn,		//	step 2
+            EPVMFOMXEncNodeProcessingState_WaitForPortDisable,		// Dynamic Port Reconfiguration - step 3
+            EPVMFOMXEncNodeProcessingState_PortReEnable,			// Dynamic Port Reconfiguration - step 4
+            EPVMFOMXEncNodeProcessingState_WaitForPortEnable,		// step 5
+            EPVMFOMXEncNodeProcessingState_Stopping				// when STOP command is issued, the node has to wait for component to transition into
+            // idle state. The buffers keep coming back , the node is rescheduled
+            // to run. Prevent the node from sending buffers back
+        } PVMFOMXEncNode_ProcessingState;
+
+        // State of HandleProcessingState() state machine
+        PVMFOMXEncNode_ProcessingState iProcessingState;
+
+        // Handle of OMX Component
+        OMX_HANDLETYPE iOMXEncoder;
+
+        // Current State of the component
+        OMX_STATETYPE iCurrentEncoderState;
+
+        // BOS
+        bool iSendBOS;
+        uint32 iStreamID;
+        uint32 iBOSTimestamp;
+
+        //EOS control flags
+        bool iIsEOSSentToComponent;
+        bool iIsEOSReceivedFromComponent;
+
+        // Send Fsi configuration flag
+        bool	sendYuvFsi;
+
+        // Width of encoded frame
+        int32 iYUVWidth;
+        // Height of encoded frame
+        int32 iYUVHeight;
+
+
+
+        // Pointer to input data fragment
+        uint8* iBitstreamBuffer;
+        // Size of input data fragment
+        int32 iBitstreamSize;
+
+        // Output frame sequence counter
+        uint32 iSeqNum;
+
+        // Input frame sequence counter
+        uint32 iSeqNum_In;
+
+        // Added to Scheduler Flag
+        bool iIsAdded;
+
+        // Log related
+        PVLogger* iLogger;
+        PVLogger* iDataPathLogger;
+        PVLogger* iClockLogger;
+        PVLogger *iRunlLogger;
+        const char *iNodeTypeId;
+
+        // Counter of fragment read from current Media Msg.Input buffer
+        uint fragnum;
+        // Number of fragments in the Media Msg.Input buffer
+        uint numfrags;
+
+
+        // Node configuration update
+        //PVMFOMXEncNodeConfig iNodeConfig;
+
+        // Capability exchange
+        PVMFNodeCapability iCapability;
+
+        // Reference counter for extension
+        uint32 iExtensionRefCount;
+
+        // Vector for KVP
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
+
+        // EOS flag
+        bool iEndOfDataReached;
+        // Time stame upon EOS
+        PVMFTimestamp iEndOfDataTimestamp;
+
+        /* Diagnostic log related */
+        PVLogger* iDiagnosticsLogger;
+        bool iDiagnosticsLogged;
+        void LogDiagnostics();
+
+        uint32 iFrameCounter;
+
+
+
+        uint32 iAvgBitrateValue;
+        bool iResetInProgress;
+        bool iResetMsgSent;
+        bool iStopInResetMsgSent;
+
+        PV_VideoEncodeParam iVideoEncodeParam;
+        PV_VideoInputFormat iVideoInputFormat;
+        PV_AudioEncodeParam iAudioEncodeParam;
+        PV_AudioInputFormat iAudioInputFormat;
+
+        PVMFFormatType iInFormat;
+        PVMFFormatType iOutFormat;
+
+        PVMFOMXEncNodeAllocDestructDealloc iAlloc;
+        OsclRefCounterMemFrag iVolHeader; /** Vol header */
+
+        OsclRefCounterMemFrag iParamSet; /* place holder for sps,pps values */
+        OsclMemoryFragment iSPSs[PVMF_AVCENC_NODE_SPS_VECTOR_RESERVE]; // just ptrs
+        OsclMemoryFragment iPPSs[PVMF_AVCENC_NODE_PPS_VECTOR_RESERVE]; // just ptrs
+        int   iNumSPSs;
+        int	  iNumPPSs;
+        bool iSpsPpsSequenceOver;
+        OsclSharedPtr<PVMFMediaDataImpl> iPreviousMediaData;
+        bool iFirstNAL;
+
+        uint32 iEndOfFrameFlagPrevious;
+        uint32 iKeyFrameFlagPrevious;
+        uint32 iEndOfNALFlagPrevious;
+        uint32 iTimeStampPrevious;
+        uint32 iBufferLenPrevious;
+
+        uint32 iEndOfFrameFlagOut;
+        uint32 iKeyFrameFlagOut;
+        uint32 iEndOfNALFlagOut;
+        uint32 iTimeStampOut;
+        uint32 iBufferLenOut;
+
+
+
+#ifdef _TEST_AE_ERROR_HANDLING
+        bool   iErrorHandlingInit;
+        uint32 iErrorHandlingEncodeCount;
+        int    iCountFrames;
+        uint32 iErrorNodeCmd;
+        bool iErrorConfigHeader;
+        uint32 iErrorEncodeFlag;
+        uint32 iErrorDataPathStall;
+#endif
+};
+
+
+#endif // PVMF_OMXENC_NODE_H_INCLUDED
+
diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp
new file mode 100644
index 0000000..704a613
--- /dev/null
+++ b/nodes/pvomxencnode/src/pvmf_omx_enc_port.cpp
@@ -0,0 +1,992 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_omx_enc_port.h"
+#include "pvmf_omx_enc_node.h"
+
+
+PVMFOMXEncPort::PVMFOMXEncPort(int32 aTag, PVMFNodeInterface* aNode, const char*name)
+        : PvmfPortBaseImpl(aTag, aNode, name)
+{
+    iOMXNode = (PVMFOMXEncNode *) aNode;
+    Construct();
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncPort::Construct()
+{
+    iLogger = PVLogger::GetLoggerObject("PVMFOMXEncPort");
+    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
+    iNumFramesGenerated = 0;
+    iNumFramesConsumed = 0;
+    iTrackConfig = NULL;
+    iTrackConfigSize = 0;
+
+}
+
+
+PVMFOMXEncPort::~PVMFOMXEncPort()
+{
+    if (iTrackConfig != NULL)
+    {
+        OSCL_FREE(iTrackConfig);
+        iTrackConfigSize = 0;
+    }
+
+    Disconnect();
+    ClearMsgQueues();
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFOMXEncPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    if ((aFmt == PVMF_MIME_YUV420) ||
+            (aFmt == PVMF_MIME_YUV422) ||
+            (aFmt == PVMF_MIME_RGB12) ||
+            (aFmt == PVMF_MIME_RGB24) ||
+            (aFmt == PVMF_MIME_PCM16) ||
+            (aFmt == PVMF_MIME_H264_VIDEO_RAW) ||
+            (aFmt == PVMF_MIME_H264_VIDEO_MP4) ||
+            //(aFmt==PVMF_MIME_H264_VIDEO) ||
+            (aFmt == PVMF_MIME_M4V) ||
+            (aFmt == PVMF_MIME_H2631998) ||
+            (aFmt == PVMF_MIME_H2632000) ||
+            (aFmt == PVMF_MIME_AMR_IETF) ||
+            (aFmt == PVMF_MIME_AMR_IF2))
+    {
+        return true;
+    }
+    return false;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFOMXEncPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFOMXEncPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
+}
+
+bool
+PVMFOMXEncPort::pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag)
+{
+    if ((iConnectedPort) &&
+            (iTag == PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT))
+    {
+        OsclAny* temp = NULL;
+        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+        PvmiCapabilityAndConfig *config = (PvmiCapabilityAndConfig*) temp;
+
+        /*
+         * Create PvmiKvp for capability settings
+         */
+        if ((config) && (aMemFrag.getMemFragSize() > 0))
+        {
+            OsclMemAllocator alloc;
+            PvmiKvp kvp;
+            kvp.key = NULL;
+            kvp.length = oscl_strlen(PVMF_FORMAT_SPECIFIC_INFO_KEY) + 1; // +1 for \0
+            kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+            if (kvp.key == NULL)
+            {
+                return false;
+            }
+            oscl_strncpy(kvp.key, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp.length);
+
+            kvp.value.key_specific_value = (OsclAny*)(aMemFrag.getMemFragPtr());
+            kvp.capacity = aMemFrag.getMemFragSize();
+            PvmiKvp* retKvp = NULL; // for return value
+            int32 err;
+            OSCL_TRY(err, config->setParametersSync(NULL, &kvp, 1, retKvp););
+            /* ignore the error for now */
+            alloc.deallocate((OsclAny*)(kvp.key));
+        }
+        return true;
+    }
+    return false;
+}
+
+PVMFStatus PVMFOMXEncPort::Connect(PVMFPortInterface* aPort)
+{
+    if (!aPort)
+    {
+        return PVMFErrArgument;
+    }
+
+    if (iConnectedPort)
+    {
+        return PVMFFailure;
+    }
+
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig* config = (PvmiCapabilityAndConfig*) temp;
+    if (!config)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - Peer port does not support capability interface"));
+        return PVMFFailure;
+    }
+
+    PVMFStatus status = PVMFSuccess;
+    switch (iTag)
+    {
+        case PVMF_OMX_ENC_NODE_PORT_TYPE_INPUT:
+            status = NegotiateInputSettings(config);
+            break;
+        case PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT:
+            status = NegotiateOutputSettings(config);
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - Invalid port tag"));
+            status = PVMFFailure;
+    }
+
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - Settings negotiation failed. status=%d", status));
+        return status;
+    }
+
+
+
+    // Automatically connect the peer.
+
+    if (aPort->PeerConnect(this) != PVMFSuccess)
+    {
+        return PVMFFailure;
+    }
+
+    iConnectedPort = aPort;
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+// needed for WMV port exchange
+void PVMFOMXEncPort::setParametersSync(PvmiMIOSession aSession,
+                                       PvmiKvp* aParameters,
+                                       int num_elements,
+                                       PvmiKvp * & aRet_kvp)
+{
+
+    OSCL_UNUSED_ARG(aSession);
+    PVMFStatus status = PVMFSuccess;
+    aRet_kvp = NULL;
+
+    for (int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(aParameters[i]), true);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXEncPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
+            aRet_kvp = &(aParameters[i]);
+            OSCL_LEAVE(OsclErrArgument);
+        }
+    }
+
+
+}
+
+
+
+
+PVMFStatus PVMFOMXEncPort::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+
+    OSCL_UNUSED_ARG(aSession);
+
+    PVMFStatus status = PVMFSuccess;
+    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
+        status = VerifyAndSetParameter(&(aParameters[i]));
+
+    return status;
+
+
+}
+
+PVMFStatus PVMFOMXEncPort::verifyConnectedPortParametersSync(const char* aFormatValType,
+        OsclAny* aConfig)
+{
+    PVMFStatus status = PVMFErrNotSupported;
+    PvmiCapabilityAndConfig *capConfig;
+    if (iConnectedPort)
+    {
+        OsclAny* temp = NULL;
+        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+        capConfig = (PvmiCapabilityAndConfig*) temp;
+    }
+    else
+        return PVMFFailure;
+
+    if (capConfig != NULL)
+    {
+        if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+        {
+            OsclRefCounterMemFrag* aFormatValue = (OsclRefCounterMemFrag*)aConfig;
+            if (aFormatValue->getMemFragSize() > 0)
+            {
+                OsclMemAllocator alloc;
+                PvmiKvp kvp;
+                kvp.key = NULL;
+                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+                if (kvp.key == NULL)
+                {
+                    return PVMFErrNoMemory;
+                }
+                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
+
+                kvp.value.key_specific_value = (OsclAny*)(aFormatValue->getMemFragPtr());
+                kvp.capacity = aFormatValue->getMemFragSize();
+                int32 err;
+                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
+                /* ignore the error for now */
+                alloc.deallocate((OsclAny*)(kvp.key));
+
+                return status;
+            }
+        }
+        else if (pv_mime_strcmp(aFormatValType, PVMF_BITRATE_VALUE_KEY) == 0 ||
+                 pv_mime_strcmp(aFormatValType, PVMF_FRAMERATE_VALUE_KEY) == 0)
+        {
+            if (aConfig != NULL)
+            {
+                OsclMemAllocator alloc;
+                PvmiKvp kvp;
+                kvp.key = NULL;
+                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+                if (kvp.key == NULL)
+                {
+                    return PVMFErrNoMemory;
+                }
+                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
+                uint32* bitrate = (uint32*)aConfig;
+                kvp.value.uint32_value = *bitrate;
+
+                int32 err;
+                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
+                /* ignore the error for now */
+                alloc.deallocate((OsclAny*)(kvp.key));
+
+                return status;
+            }
+        }
+        return PVMFErrArgument;
+    }
+    return PVMFFailure;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////
+/////////////////// ENCODER SPECIFIC EXCHANGE TO SET PARAMETERS
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncPort::GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
+        int& num_parameter_elements)
+{
+    if (iTag != PVMF_OMX_ENC_NODE_PORT_TYPE_INPUT)
+        return PVMFFailure;
+
+    PVMFStatus status = PVMFSuccess;
+
+    // this comparison only goes up to delimiter (i.e. ; or /)
+    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
+    {
+        // get the first parameter as well to compare
+        char *param1 = NULL;
+        char *param2 = NULL;
+        pv_mime_string_extract_param(0, identifier, param1);
+        pv_mime_string_extract_param(0, (char*)INPUT_FORMATS_CAP_QUERY, param2);
+
+        if (pv_mime_strcmp(param1, param2) == 0)
+        {
+            num_parameter_elements = 5;
+            status = AllocateKvp(parameters, (OMX_STRING)INPUT_FORMATS_VALTYPE, num_parameter_elements);
+            if (status != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetInputParametersSync: Error - AllocateKvp failed. status=%d", status));
+                return status;
+            }
+
+            parameters[0].value.pChar_value = (char*)PVMF_MIME_YUV420;
+            parameters[1].value.pChar_value = (char*)PVMF_MIME_YUV422;
+            parameters[2].value.pChar_value = (char*)PVMF_MIME_RGB12;
+            parameters[3].value.pChar_value = (char*)PVMF_MIME_RGB24;
+            parameters[4].value.pChar_value = (char*)PVMF_MIME_PCM16;
+        }
+    }
+
+    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CUR_QUERY) == 0)
+    {
+        // get the first parameter as well to compare
+        char *param1 = NULL;
+        char *param2 = NULL;
+        pv_mime_string_extract_param(0, identifier, param1);
+        pv_mime_string_extract_param(0, (char*)INPUT_FORMATS_CUR_QUERY, param2);
+
+        if (pv_mime_strcmp(param1, param2) == 0)
+        {
+            num_parameter_elements = 1;
+            status = AllocateKvp(parameters, (PvmiKeyType)INPUT_FORMATS_VALTYPE, num_parameter_elements);
+            if (status != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetInputParametersSync: Error - AllocateKvp failed. status=%d", status));
+                return status;
+            }
+            parameters[0].value.pChar_value = (char*)iFormat.getMIMEStrPtr();
+        }
+    }
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncPort::GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
+        int& num_parameter_elements)
+{
+    if (iTag != PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT)
+        return PVMFFailure;
+
+    PVMFStatus status = PVMFSuccess;
+
+    // this comparison only goes up to the first delimiter i.e. ; or /
+    if (pv_mime_strcmp(identifier, (OMX_STRING)OUTPUT_FORMATS_CAP_QUERY) == 0)
+    {
+        // get the first parameter as well to compare
+        char *param1 = NULL;
+        char *param2 = NULL;
+        pv_mime_string_extract_param(0, identifier, param1);
+        pv_mime_string_extract_param(0, (char*)OUTPUT_FORMATS_CAP_QUERY, param2);
+
+        if (pv_mime_strcmp(param1, param2) == 0)
+        {
+            num_parameter_elements = 7;
+            status = AllocateKvp(parameters, (OMX_STRING)OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
+            if (status != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            }
+            else
+            {
+                parameters[0].value.pChar_value = (char*)PVMF_MIME_H2631998;
+                parameters[1].value.pChar_value = (char*)PVMF_MIME_H2632000;
+                parameters[2].value.pChar_value = (char*)PVMF_MIME_M4V;
+                parameters[3].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_RAW;
+                parameters[4].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_MP4;
+                parameters[5].value.pChar_value = (char*)PVMF_MIME_AMR_IETF;
+                parameters[6].value.pChar_value = (char*)PVMF_MIME_AMR_IF2;
+
+            }
+        }
+    }
+
+    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
+    {
+        // get the first parameter as well to compare
+        char *param1 = NULL;
+        char *param2 = NULL;
+        pv_mime_string_extract_param(0, identifier, param1);
+        pv_mime_string_extract_param(0, (char*)OUTPUT_FORMATS_CUR_QUERY, param2);
+
+        if (pv_mime_strcmp(param1, param2) == 0)
+        {
+            num_parameter_elements = 1;
+            status = AllocateKvp(parameters, (OMX_STRING)OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
+            if (status != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            }
+            else
+            {
+                parameters[0].value.pChar_value = (char*)iOMXNode->GetCodecType().getMIMEStrPtr();
+            }
+        }
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, (OMX_STRING)VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+
+        uint32 width, height;
+        status = iOMXNode->GetOutputFrameSize(0, width, height);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error -iOMXNode->GetOutputFrameSize failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.uint32_value = width;
+        }
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, (OMX_STRING)VIDEO_OUTPUT_HEIGHT_CUR_VALUE, num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        else
+        {
+            uint32 width, height;
+            status = iOMXNode->GetOutputFrameSize(0, width, height);
+            if (status != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - iOMXNode->GetOutputFrameSize failed. status=%d", status));
+            }
+            else
+            {
+                parameters[0].value.uint32_value = height;
+            }
+        }
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, (OMX_STRING)VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        else
+        {
+            parameters[0].value.float_value = iOMXNode->GetOutputFrameRate(0);
+        }
+    }
+    else if (pv_mime_strcmp(identifier, OUTPUT_BITRATE_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, (OMX_STRING)OUTPUT_BITRATE_CUR_VALUE, num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        else
+        {
+
+            // NOTE: we assume that port format will be set before this call
+            if ((iFormat == PVMF_MIME_AMR_IETF) || (iFormat == PVMF_MIME_AMR_IF2))
+            {
+                parameters[0].value.uint32_value = iOMXNode->GetOutputBitRate(); // use audio version - void arg
+            }
+            else if (iFormat == PVMF_MIME_H2631998 ||
+                     iFormat == PVMF_MIME_H2632000 ||
+                     iFormat == PVMF_MIME_M4V ||
+                     iFormat == PVMF_MIME_H264_VIDEO_RAW ||
+                     iFormat == PVMF_MIME_H264_VIDEO_MP4
+                    )
+
+            {
+                // use the video version
+                parameters[0].value.uint32_value = iOMXNode->GetOutputBitRate(0);
+            }
+            else
+            {
+                status = PVMFFailure;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - status=%d", status));
+                return status;
+            }
+
+        }
+    }
+    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters, (OMX_STRING)VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_VALUE, num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        else
+        {
+            parameters[0].value.uint32_value = iOMXNode->GetIFrameInterval();
+        }
+    }
+
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncPort::AllocateKvp"));
+    uint8* buf = NULL;
+    uint32 keyLen = oscl_strlen(aKey) + 1;
+    int32 err = 0;
+
+    OSCL_TRY(err,
+             buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
+             if (!buf)
+             OSCL_LEAVE(OsclErrNoMemory);
+            );
+    OSCL_FIRST_CATCH_ANY(err,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::AllocateKvp: Error - kvp allocation failed"));
+                         return PVMFErrNoMemory;
+                        );
+
+    int32 i = 0;
+    PvmiKvp* curKvp = aKvp = new(buf) PvmiKvp;
+    buf += sizeof(PvmiKvp);
+    for (i = 1; i < aNumParams; i++)
+    {
+        curKvp += i;
+        curKvp = new(buf) PvmiKvp;
+        buf += sizeof(PvmiKvp);
+    }
+
+    for (i = 0; i < aNumParams; i++)
+    {
+        aKvp[i].key = (char*)buf;
+        oscl_strncpy(aKvp[i].key, aKey, keyLen);
+        buf += keyLen;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
+
+    if (!aKvp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
+        return PVMFFailure;
+    }
+
+    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0 &&
+            iTag == PVMF_OMX_ENC_NODE_PORT_TYPE_INPUT)
+    {
+        if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_YUV420) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_YUV422) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_RGB12) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_RGB24) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_PCM16) == 0)
+        {
+            if (aSetParam)
+            {
+                iFormat = aKvp->value.pChar_value;
+                iOMXNode->SetInputFormat(iFormat);
+            }
+            return PVMFSuccess;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::VerifyAndSetParameter: Error - Input format %d not supported",
+                            aKvp->value.uint32_value));
+            return PVMFFailure;
+        }
+    }
+    else if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0 &&
+             iTag == PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT)
+    {
+        if (pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H2631998) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H2632000) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_M4V) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H264_VIDEO_RAW) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_H264_VIDEO_MP4) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_AMR_IETF) == 0 ||
+                pv_mime_strcmp(aKvp->value.pChar_value, PVMF_MIME_AMR_IF2) == 0)
+        {
+            if (aSetParam)
+            {
+                iFormat = aKvp->value.pChar_value;
+                iOMXNode->SetCodecType(iFormat);
+            }
+            return PVMFSuccess;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::VerifyAndSetParameter: Error - Output format %d not supported",
+                            aKvp->value.uint32_value));
+            return PVMFFailure;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::VerifyAndSetParameter: Error - Unsupported parameter"));
+    return PVMFFailure;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncPort::NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncPort::NegotiateInputSettings: aConfig=0x%x", aConfig));
+    if (!aConfig)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: Error - Invalid config object"));
+        return PVMFFailure;
+    }
+
+    PvmiKvp* kvp = NULL;
+    int numParams = 0;
+    int32 err = 0;
+    PVMFFormatType videoFormat = 0;
+    // Get supported output formats from peer
+    PVMFStatus status = aConfig->getParametersSync(NULL, (OMX_STRING)OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+    if (status != PVMFSuccess || numParams == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: Error - config->getParametersSync(output_formats) failed"));
+        return status;
+    }
+
+    OsclPriorityQueue < PvmiKvp*, OsclMemAllocator,
+    Oscl_Vector<PvmiKvp*, OsclMemAllocator>,
+    PVMFOMXEncInputFormatCompareLess > sortedKvp;
+
+    // Using a priority queue, sort the kvp's returned from aConfig->getParametersSync
+    // according to the preference of this port. Formats that are not supported are
+    // not pushed to the priority queue and hence dropped from consideration.
+    PvmiKvp* selectedAudioKvp = NULL;
+    for (int32 i = 0; i < numParams; i++)
+    {
+        if (pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_YUV420) == 0 ||
+                pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_YUV422) == 0 ||
+                pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_RGB12) == 0 ||
+                pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_RGB24) == 0)
+        {
+            videoFormat = kvp[i].value.pChar_value;
+            err = PushKVP(sortedKvp, &(kvp[i]));
+            OSCL_FIRST_CATCH_ANY(err,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: Error - sortedKvp.push failed"));
+                                 return PVMFErrNoMemory;
+                                );
+        }
+        else if (pv_mime_strcmp(kvp->value.pChar_value, PVMF_MIME_PCM16) == 0)
+        {
+            selectedAudioKvp = &kvp[i];
+        }
+    }
+
+    if (sortedKvp.size() == 0 && (selectedAudioKvp == NULL))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: Error - No matching supported input format"));
+        // Release parameters back to peer
+        aConfig->releaseParameters(NULL, kvp, numParams);
+        kvp = NULL;
+        numParams = 0;
+        return PVMFFailure;
+    }
+
+    PvmiKvp* selectedKvp = NULL;
+    if (sortedKvp.size() != 0)
+    {
+        selectedKvp = sortedKvp.top();
+    }
+    else
+    {
+        selectedKvp = selectedAudioKvp;
+    }
+    PvmiKvp* retKvp = NULL;
+
+    // Set format of this port, peer port and container node
+    iFormat = selectedKvp->value.pChar_value;
+    iOMXNode->SetInputFormat(iFormat);
+    err = Config_ParametersSync(aConfig, selectedKvp, retKvp);
+    OSCL_FIRST_CATCH_ANY(err,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
+                         return PVMFFailure;
+                        );
+
+    // Release parameters back to peer and reset for the next query
+    aConfig->releaseParameters(NULL, kvp, numParams);
+    kvp = NULL;
+    numParams = 0;
+
+    // audio/video negotiation differ
+    if (iFormat == PVMF_MIME_PCM16)
+    {
+        // audio i.e. AMR for now
+
+        // first set bitspersample to 16
+        iOMXNode->SetInputBitsPerSample(PVMF_AMRENC_DEFAULT_BITSPERSAMPLE);
+
+
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)AUDIO_OUTPUT_SAMPLING_RATE_CUR_QUERY, kvp, numParams, NULL);
+        uint32 samplingRate = 0;
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: config->getParametersSync(sampling rate) not supported. Use default."));
+            samplingRate = PVMF_AMRENC_DEFAULT_SAMPLING_RATE;
+        }
+        else
+        {
+            samplingRate = kvp[0].value.uint32_value;
+
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+
+
+        // Forward settings to encoder
+        iOMXNode->SetInputSamplingRate(samplingRate);
+        kvp = NULL;
+        numParams = 0;
+
+        status = aConfig->getParametersSync(NULL, (PvmiKeyType)AUDIO_OUTPUT_NUM_CHANNELS_CUR_QUERY, kvp, numParams, NULL);
+        uint32 numChannels = 0;
+        if (status != PVMFSuccess || !kvp || numParams != 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateInputSettings: config->getParametersSync(num channels) not supported. Use default"));
+            numChannels = PVMF_AMRENC_DEFAULT_NUM_CHANNELS;
+        }
+        else
+        {
+            numChannels = kvp[0].value.uint32_value;
+
+            aConfig->releaseParameters(NULL, kvp, numParams);
+        }
+
+        // Forward settings to encoder
+        iOMXNode->SetInputNumChannels(numChannels);
+        kvp = NULL;
+        numParams = 0;
+
+        return PVMFSuccess;
+
+    }
+    else
+    {
+        // video
+        // Get size (in pixels) of video data from peer
+        uint32 width = 0;
+        uint32 height = 0;
+        uint8 orientation = 0;
+        status = aConfig->getParametersSync(NULL, (OMX_STRING)VIDEO_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - config->getParametersSync(current width) failed"));
+            return status;
+        }
+        width = kvp[0].value.uint32_value;
+        aConfig->releaseParameters(NULL, kvp, numParams);
+        kvp = NULL;
+        numParams = 0;
+
+        status = aConfig->getParametersSync(NULL, (OMX_STRING)VIDEO_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - config->getParametersSync(current height) failed"));
+            return status;
+        }
+        height = kvp[0].value.uint32_value;
+        aConfig->releaseParameters(NULL, kvp, numParams);
+        kvp = NULL;
+        numParams = 0;
+
+        if ((videoFormat == PVMF_MIME_RGB12) || (videoFormat == PVMF_MIME_RGB24))
+        {
+            status = aConfig->getParametersSync(NULL, (OMX_STRING)VIDEO_FRAME_ORIENTATION_CUR_QUERY, kvp, numParams, NULL);
+            if (status != PVMFSuccess || numParams != 1)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - config->getParametersSync(current height) failed"));
+                return status;
+            }
+
+            orientation = kvp[0].value.uint8_value;
+            aConfig->releaseParameters(NULL, kvp, numParams);
+            kvp = NULL;
+            numParams = 0;
+
+        }
+        // Set input frame size of container node
+        iOMXNode->SetInputFrameSize(width, height, orientation);
+
+        // Get video frame rate from peer
+        status = aConfig->getParametersSync(NULL, (OMX_STRING)VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY, kvp, numParams, NULL);
+        if (status != PVMFSuccess || numParams != 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::Connect: Error - config->getParametersSync(current frame rate) failed"));
+            return status;
+        }
+
+        // Set input frame rate of container node
+        iOMXNode->SetInputFrameRate(kvp[0].value.float_value);
+        aConfig->releaseParameters(NULL, kvp, numParams);
+        kvp = NULL;
+        numParams = 0;
+        return status;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFOMXEncPort::NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncPort::NegotiateOutputSettings: aConfig=0x%x", aConfig));
+    if (!aConfig)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateOutputSettings: Error - Invalid config object"));
+        return PVMFFailure;
+    }
+
+    PvmiKvp* kvp = NULL;
+    int numParams = 0;
+    int32 i = 0;
+    int32 err = 0;
+
+    // Get supported input formats from peer
+    PVMFStatus status = aConfig->getParametersSync(NULL, (OMX_STRING)INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
+    if (status != PVMFSuccess || numParams == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateOutputSettings: Error - config->getParametersSync(input_formats) failed"));
+        return status;
+    }
+
+    PvmiKvp* selectedKvp = NULL;
+    PvmiKvp* retKvp = NULL;
+    for (i = 0; i < numParams && !selectedKvp; i++)
+    {
+        if (pv_mime_strcmp(kvp[i].value.pChar_value, (char*)iFormat.getMIMEStrPtr()) == 0)
+            selectedKvp = &(kvp[i]);
+    }
+
+    if (!selectedKvp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateOutputSettings: Error - Output format not supported by peer"));
+        return PVMFFailure;
+    }
+
+    err = Config_ParametersSync(aConfig, selectedKvp, retKvp);
+    OSCL_FIRST_CATCH_ANY(err,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::NegotiateOutputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
+                         return PVMFFailure;
+                        );
+
+    aConfig->releaseParameters(NULL, kvp, numParams);
+    kvp = NULL;
+    numParams = 0;
+
+    return PVMFSuccess;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXEncPort::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXEncPort::getParametersSync"));
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+    parameters = NULL;
+    num_parameter_elements = 0;
+    PVMFStatus status = PVMFFailure;
+
+    switch (iTag)
+    {
+        case PVMF_OMX_ENC_NODE_PORT_TYPE_INPUT:
+            return GetInputParametersSync(identifier, parameters, num_parameter_elements);
+        case PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT:
+            return GetOutputParametersSync(identifier, parameters, num_parameter_elements);
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXEncPort::getParametersSync: Error - Invalid port tag"));
+            break;
+    }
+
+    return status;
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFOMXEncPort::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if (parameters)
+    {
+        iAlloc.deallocate((OsclAny*)parameters);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+
+// AVC Encoder specific call to send set of SPS and PPS nals to the composer
+void PVMFOMXEncPort::SendSPS_PPS(OsclMemoryFragment *aSPSs, int aNumSPSs, OsclMemoryFragment *aPPSs, int aNumPPSs)
+{
+    int ii;
+
+    OsclAny* temp = NULL;
+    iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig* config = (PvmiCapabilityAndConfig*) temp;
+    if (config)
+    {
+        for (ii = 0; ii < aNumSPSs; ii++)
+        {
+            // send SPS
+            PvmiKvp* sps, *ret;
+            AllocateKvp(sps, (OMX_STRING)VIDEO_AVC_OUTPUT_SPS_CUR_VALUE, 1);
+
+            sps->value.key_specific_value = aSPSs[ii].ptr;
+            sps->capacity = aSPSs[ii].len;
+            config->setParametersSync(NULL, sps, 1, ret);
+            if (ret)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOmxEncPort::SendSPS_PPS: Error returned Kvp is not null."));
+            }
+            // Release parameters back to peer and reset for the next query
+            config->releaseParameters(NULL, sps, 1);
+        }
+        for (ii = 0; ii < aNumPPSs; ii++)
+        {
+            // send PPS
+            PvmiKvp* pps, *ret;
+            AllocateKvp(pps, (OMX_STRING)VIDEO_AVC_OUTPUT_PPS_CUR_VALUE, 1);
+
+            pps->value.key_specific_value = aPPSs[ii].ptr;
+            pps->capacity = aPPSs[ii].len;
+            config->setParametersSync(NULL, pps, 1, ret);
+            if (ret)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOmxEncPort::SendSPS_PPS: Error returned Kvp is not null."));
+            }
+            // Release parameters back to peer and reset for the next query
+            config->releaseParameters(NULL, pps, 1);
+        }
+    }
+
+    return ;
+}
+
+int32 PVMFOMXEncPort::Config_ParametersSync(PvmiCapabilityAndConfig *&aConfig, PvmiKvp *&aSelectedKvp, PvmiKvp *&aRetKvp)
+{
+    int32 err = 0;
+    OSCL_TRY(err, aConfig->setParametersSync(NULL, aSelectedKvp, 1, aRetKvp););
+    return err;
+}
+
+int32 PVMFOMXEncPort::PushKVP(OsclPriorityQueue<PvmiKvp*, OsclMemAllocator, Oscl_Vector<PvmiKvp*, OsclMemAllocator>, PVMFOMXEncInputFormatCompareLess> &aSortedKvp, PvmiKvp *aKvp)
+{
+    int32 err = 0;
+    OSCL_TRY(err, aSortedKvp.push(aKvp););
+    return err;
+}
+
diff --git a/nodes/pvomxvideodecnode/Android.mk b/nodes/pvomxvideodecnode/Android.mk
index d8c0786..00f599e 100644
--- a/nodes/pvomxvideodecnode/Android.mk
+++ b/nodes/pvomxvideodecnode/Android.mk
@@ -3,30 +3,32 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_omx_videodec_factory.cpp \
-	src/pvmf_omx_videodec_node.cpp \
-	src/pvmf_omx_videodec_port.cpp \
-	src/pvmf_omx_videodec_callbacks.cpp
-
+ 	src/pvmf_omx_videodec_node.cpp
 
 
 LOCAL_MODULE := libpvomxvideodecnode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvomxvideodecnode/include \
-	$(PV_TOP)//nodes/pvomxvideodecnode/src \
-	$(PV_TOP)//nodes/pvomxvideodecnode/../../extern_libs_v2/khronos/openmax/include \
-	$(PV_TOP)//nodes/pvomxvideodecnode/../../codecs_v2/video/wmv_vc1/dec/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvomxvideodecnode/src \
+ 	$(PV_TOP)/nodes/pvomxvideodecnode/include \
+ 	$(PV_TOP)/extern_libs_v2/khronos/openmax/include \
+ 	$(PV_TOP)/codecs_v2/video/wmv_vc1/dec/src \
+ 	$(PV_TOP)/baselibs/threadsafe_callback_ao/src \
+ 	$(PV_TOP)/nodes/pvomxbasedecnode/include \
+ 	$(PV_TOP)/nodes/pvomxbasedecnode/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvmf_omx_videodec_defs.h \
-	include/pvmf_omx_videodec_factory.h \
-	include/pvmf_omx_videodec_port.h
+ 	include/pvmf_omx_videodec_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvomxvideodecnode/build/make/local.mk b/nodes/pvomxvideodecnode/build/make/local.mk
new file mode 100644
index 0000000..4903682
--- /dev/null
+++ b/nodes/pvomxvideodecnode/build/make/local.mk
@@ -0,0 +1,24 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvomxvideodecnode
+
+XINCDIRS += ../../../../extern_libs_v2/khronos/openmax/include \
+            ../../../../codecs_v2/video/wmv_vc1/dec/src \
+            ../../../../baselibs/threadsafe_callback_ao/src \
+            ../../../pvomxbasedecnode/include \
+            ../../../pvomxbasedecnode/src
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_omx_videodec_factory.cpp \
+	pvmf_omx_videodec_node.cpp
+
+HDRS := pvmf_omx_videodec_factory.h
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvomxvideodecnode/build/make/makefile b/nodes/pvomxvideodecnode/build/make/makefile
deleted file mode 100644
index a398309..0000000
--- a/nodes/pvomxvideodecnode/build/make/makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvomxvideodecnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += \
-	-I ../../../../extern_libs_v2/khronos/openmax/include \
-	-I ../../../../codecs_v2/video/wmv_vc1/dec/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_omx_videodec_factory.cpp \
-	pvmf_omx_videodec_node.cpp \
-	pvmf_omx_videodec_port.cpp \
-	pvmf_omx_videodec_callbacks.cpp
-
-HDRS =  pvmf_omx_videodec_defs.h \
-	pvmf_omx_videodec_factory.h \
-	pvmf_omx_videodec_port.h 
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_defs.h b/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_defs.h
deleted file mode 100644
index d59c0f1..0000000
--- a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_defs.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEODEC_DEFS_H_INCLUDED
-#define PVMF_OMX_VIDEODEC_DEFS_H_INCLUDED
-
-// Error and info messages
-//
-enum PVMFOMXVideoDecNodeErrors
-{
-    // Video decoder node failed to initialize the video decoder. Fatal error so the node needs to be reset.
-    PVOMXVIDEODECNODE_ERROR_DECODER_INIT_FAILED = PVMF_NODE_ERROR_EVENT_LAST
-};
-
-enum PVMFOMXVideoDecNodeInfo
-{
-    // Decoding of a frame failed. Video decoder node will continue on to decode the next frame
-    PVOMXVIDEODECNODE_INFO_DECODEFRAME_FAILED = PVMF_NODE_INFO_EVENT_LAST,
-    // Input bitstream buffer overflowed (frame too large or couldn't find frame marker). Data will be dropped until the next frame marker is found
-    // then frame will be decoded.
-    PVOMXVIDEODECNODE_INFO_INPUTBITSTREAMBUFFER_OVERFLOW
-};
-
-#endif // PVMF_OMXVIDEODEC_DEFS_H_INCLUDED
-
-
diff --git a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_factory.h b/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_factory.h
index 865dfdd..719040f 100644
--- a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_factory.h
+++ b/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_node_extension_interface.h b/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_node_extension_interface.h
deleted file mode 100644
index d6c3514..0000000
--- a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_node_extension_interface.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-#define PVMF_OMX_VIDEODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-
-struct PVMFOMXVideoDecNodeConfig
-{
-    bool iPostProcessingEnable;
-    int32 iPostProcessingMode;
-    bool iDropFrame;
-    uint32 iMimeType;
-};
-
-//Mimetype and Uuid for the custom interface
-#define PVMF_OMX_VIDEO_DEC_NODE_CUSTOM1_UUID 1,2,3,0xde,0xad,0xae,0xcf,0x20,0x11,0x73,0x33
-
-//Mimetypes for the custom interface
-#define PVMF_OMX_VIDEO_DEC_NODE_CUSTOM1_MIMETYPE "pvxxx/OMXVideoDecNode/Custom1"
-
-class PVMFOMXVideoDecNodeExtensionInterface : public PVInterface
-{
-    public:
-        //**********begin PVInterface
-        virtual void addRef() = 0;
-        virtual void removeRef() = 0;
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
-        //**********end PVInterface
-
-        virtual PVMFStatus SetDecoderNodeConfiguration(PVMFOMXVideoDecNodeConfig& aConfig) = 0;
-
-};
-
-#endif //PVMF_OMX_VIDEODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-
-
diff --git a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_port.h b/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_port.h
deleted file mode 100644
index bafbbd8..0000000
--- a/nodes/pvomxvideodecnode/include/pvmf_omx_videodec_port.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEODEC_PORT_H_INCLUDED
-#define PVMF_OMX_VIDEODEC_PORT_H_INCLUDED
-
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-
-#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
-#include "pvmf_port_base_impl.h"
-#endif
-
-#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
-#include "pvmi_config_and_capability_utils.h"
-#endif
-
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-
-class PVMFOMXVideoDecNode;
-
-//Default vector reserve size
-#define PVMF_OMX_VIDEO_DEC_NODE_PORT_VECTOR_RESERVE 10
-
-
-#define PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS "x-pvmf/video/decode/input_formats"
-//#define PVMF_VID_DEC_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/video/decode/input_formats;valtype=int32"
-#define PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS_VALTYPE "x-pvmf/port/formattype;valtype=int32"
-
-typedef enum
-{
-    PVMF_OMX_VIDEO_DEC_NODE_PORT_TYPE_SOURCE,
-    PVMF_OMX_VIDEO_DEC_NODE_PORT_TYPE_SINK,
-} PVMFOMXVideoDecPortType;
-
-class PVMFOMXVideoDecPort : public PvmfPortBaseImpl
-            , public PvmiCapabilityAndConfigPortFormatImpl
-{
-    public:
-        PVMFOMXVideoDecPort(int32 aTag, PVMFNodeInterface* aNode, const char*);
-        ~PVMFOMXVideoDecPort();
-
-        // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface
-        bool IsFormatSupported(PVMFFormatType);
-        void FormatUpdated();
-
-        // this port supports config interface
-        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
-        {
-            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-                aPtr = (PvmiCapabilityAndConfig*)this;
-            else
-                aPtr = NULL;
-        }
-
-        bool pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag);
-
-        PVMFStatus Connect(PVMFPortInterface* aPort);
-        void setParametersSync(PvmiMIOSession aSession,
-                               PvmiKvp* aParameters,
-                               int num_elements,
-                               PvmiKvp * & aRet_kvp);
-
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-        PVMFStatus verifyConnectedPortParametersSync(const char* aFormatValType, OsclAny* aConfig);
-        uint32 getTrackConfigSize()
-        {
-            return iTrackConfigSize;
-        }
-        uint8* getTrackConfig()
-        {
-            return iTrackConfig;
-        }
-
-
-
-    private:
-        void Construct();
-        PVLogger *iLogger;
-        uint32 iNumFramesGenerated; //number of source frames generated.
-        uint32 iNumFramesConsumed; //number of frames consumed & discarded.
-        uint32 iTrackConfigSize;
-        uint8* iTrackConfig;
-        friend class PVMFOMXVideoDecNode;
-        PVMFOMXVideoDecNode* iOMXNode;
-};
-
-#endif // PVMF_OMX_VIDEODEC_PORT_H_INCLUDED
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_callbacks.cpp b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_callbacks.cpp
deleted file mode 100644
index 02ef71a..0000000
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_callbacks.cpp
+++ /dev/null
@@ -1,448 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_omx_videodec_callbacks.h"
-#include "pvmf_omx_videodec_node.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-EventHandlerThreadSafeCallbackAO::EventHandlerThreadSafeCallbackAO(void* aObserver,
-        uint32 aDepth,
-        const char* aAOname,
-        int32 aPriority)
-        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
-    if (iMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
-    }
-    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-    // created in the 2nd thread and will fail to deallocate properly.
-
-    OsclAny *dummy = iMemoryPool->allocate(sizeof(EventHandlerSpecificData));
-    iMemoryPool->deallocate(dummy);
-}
-
-EventHandlerThreadSafeCallbackAO::~EventHandlerThreadSafeCallbackAO()
-{
-    if (iMemoryPool)
-    {
-        iMemoryPool->removeRef();
-        iMemoryPool = NULL;
-    }
-}
-OsclReturnCode EventHandlerThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
-{
-    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
-    if (iObserver != NULL)
-    {
-        PVMFOMXVideoDecNode* ptr = (PVMFOMXVideoDecNode*) iObserver;
-
-        ptr->ProcessCallbackEventHandler_MultiThreaded(EventData);
-
-    }
-    return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void EventHandlerThreadSafeCallbackAO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() In"));
-
-    OsclAny *P; // parameter to dequeue
-    OsclReturnCode status = OsclSuccess;
-
-
-    do
-    {
-
-
-        P = DeQueue(status);
-        // status is either OsclSuccess or OsclPending (if the last event was pulled
-        // from the queue)
-
-        if ((status == OsclSuccess) || (status == OsclPending))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() - Calling Process Event"));
-            ProcessEvent(P);
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() - could not dequeue event data"));
-        }
-
-
-        // it is possible that an event arrives between dequeueing the last event and this point.
-        // If this is the case, we will be rescheduled and process the event
-        // in the next Run
-
-
-    }
-    while (status == OsclSuccess);
-    // if the status is "OsclPending" there were no more events in the queue
-    // (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* EventHandlerThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
-{
-    OsclAny *pData;
-    OsclProcStatus::eOsclProcError sema_status;
-
-    stat = OsclSuccess;
-
-    // Protect the queue while accessing it:
-    Mutex.Lock();
-
-    if (Q->NumElem == 0)
-    {
-        // nothing to de-queue
-        stat = OsclFailure;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
-        Mutex.Unlock();
-
-        return NULL;
-    }
-
-    pData = (Q->pFirst[Q->index_out]).pData;
-
-    Q->index_out++;
-    // roll-over the index
-    if (Q->index_out == Q->MaxNumElements)
-        Q->index_out = 0;
-
-    Q->NumElem--;
-
-    // check if there is need to call waitforevent
-    if ((Q->NumElem) == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EventHandlerThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
-        PendForExec();
-        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
-        // so that it can get out of the loop
-    }
-
-
-    //release queue access
-    Mutex.Unlock();
-
-    // Signal the semaphore that controls the remote thread.
-    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-    sema_status = RemoteThreadCtrlSema.Signal();
-    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
-    {
-        stat = OsclFailure;
-        return NULL;
-    }
-
-    return pData;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-EmptyBufferDoneThreadSafeCallbackAO::EmptyBufferDoneThreadSafeCallbackAO(void* aObserver,
-        uint32 aDepth,
-        const char* aAOname,
-        int32 aPriority)
-        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
-    if (iMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
-
-    }
-    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-    // created in the 2nd thread and will fail to deallocate properly.
-
-    OsclAny *dummy = iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData));
-    iMemoryPool->deallocate(dummy);
-}
-
-EmptyBufferDoneThreadSafeCallbackAO::~EmptyBufferDoneThreadSafeCallbackAO()
-{
-    if (iMemoryPool)
-    {
-
-        iMemoryPool->removeRef();
-        iMemoryPool = NULL;
-    }
-
-}
-OsclReturnCode EmptyBufferDoneThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
-{
-    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
-    if (iObserver != NULL)
-    {
-        PVMFOMXVideoDecNode* ptr = (PVMFOMXVideoDecNode *) iObserver;
-
-        ptr->ProcessCallbackEmptyBufferDone_MultiThreaded(EventData);
-
-    }
-    return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void EmptyBufferDoneThreadSafeCallbackAO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() In"));
-
-    OsclAny *P; // parameter to dequeue
-    OsclReturnCode status = OsclSuccess;
-
-    do
-    {
-
-
-        P = DeQueue(status);
-
-
-        if ((status == OsclSuccess) || (status == OsclPending))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() - Calling Process Event"));
-            ProcessEvent(P);
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() - could not dequeue event data"));
-        }
-
-
-        // it is possible that an event arrives between dequeueing the last event and this point.
-        // If this is the case, we will be rescheduled and process the event
-        // in the next Run
-
-
-    }
-    while (status == OsclSuccess);
-    // if the status is "OsclPending" there were no more events in the queue
-    // (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* EmptyBufferDoneThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
-{
-    OsclAny *pData;
-    OsclProcStatus::eOsclProcError sema_status;
-
-    stat = OsclSuccess;
-
-    // Protect the queue while accessing it:
-    Mutex.Lock();
-
-    if (Q->NumElem == 0)
-    {
-        // nothing to de-queue
-        stat = OsclFailure;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
-        Mutex.Unlock();
-
-        return NULL;
-    }
-
-    pData = (Q->pFirst[Q->index_out]).pData;
-
-    Q->index_out++;
-    // roll-over the index
-    if (Q->index_out == Q->MaxNumElements)
-        Q->index_out = 0;
-
-    Q->NumElem--;
-
-    // check if there is need to call waitforevent
-    if ((Q->NumElem) == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "EmptyBufferDoneThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
-        PendForExec();
-        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
-        // so that it can get out of the loop
-    }
-
-    //release queue access
-    Mutex.Unlock();
-
-    // Signal the semaphore that controls the remote thread.
-    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-    sema_status = RemoteThreadCtrlSema.Signal();
-    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
-    {
-        stat = OsclFailure;
-        return NULL;
-    }
-
-    return pData;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-FillBufferDoneThreadSafeCallbackAO::FillBufferDoneThreadSafeCallbackAO(void* aObserver,
-        uint32 aDepth,
-        const char* aAOname,
-        int32 aPriority)
-        : ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-    iMemoryPool = ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth + 2);
-    if (iMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
-    }
-    // MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-    // created in the 2nd thread and will fail to deallocate properly.
-
-    OsclAny *dummy = iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData));
-    iMemoryPool->deallocate(dummy);
-}
-
-FillBufferDoneThreadSafeCallbackAO::~FillBufferDoneThreadSafeCallbackAO()
-{
-    if (iMemoryPool)
-    {
-
-        iMemoryPool->removeRef();
-        iMemoryPool = NULL;
-    }
-}
-
-OsclReturnCode FillBufferDoneThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
-{
-    // In this case, ProcessEvent calls the method of the primary test AO to process the Event
-    if (iObserver != NULL)
-    {
-        PVMFOMXVideoDecNode* ptr = (PVMFOMXVideoDecNode*) iObserver;
-
-        ptr->ProcessCallbackFillBufferDone_MultiThreaded(EventData);
-
-    }
-    return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void FillBufferDoneThreadSafeCallbackAO::Run()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() In"));
-
-    OsclAny *P; // parameter to dequeue
-    OsclReturnCode status = OsclSuccess;
-
-    do
-    {
-
-
-        P = DeQueue(status);
-
-
-        if ((status == OsclSuccess) || (status == OsclPending))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() - Calling Process Event"));
-            ProcessEvent(P);
-        }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() - could not dequeue event data"));
-        }
-
-
-        // it is possible that an event arrives between dequeueing the last event and this point.
-        // If this is the case, we will be rescheduled and process the event
-        // in the next Run
-
-
-    }
-    while (status == OsclSuccess);
-    // if the status is "OsclPending" there were no more events in the queue
-    // (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* FillBufferDoneThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
-{
-    OsclAny *pData;
-    OsclProcStatus::eOsclProcError sema_status;
-
-    stat = OsclSuccess;
-
-    // Protect the queue while accessing it:
-    Mutex.Lock();
-
-    if (Q->NumElem == 0)
-    {
-        // nothing to de-queue
-        stat = OsclFailure;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
-        Mutex.Unlock();
-
-        return NULL;
-    }
-
-    pData = (Q->pFirst[Q->index_out]).pData;
-
-    Q->index_out++;
-    // roll-over the index
-    if (Q->index_out == Q->MaxNumElements)
-        Q->index_out = 0;
-
-    Q->NumElem--;
-    // check if there is need to call waitforevent
-    if ((Q->NumElem) == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "FillBufferDoneThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
-        PendForExec();
-        stat = OsclPending; // let the Run know that the last event was pulled out of the queue
-        // so that it can get out of the loop
-    }
-
-    //release queue access
-    Mutex.Unlock();
-
-    // Signal the semaphore that controls the remote thread.
-    // The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-    sema_status = RemoteThreadCtrlSema.Signal();
-    if (sema_status != OsclProcStatus::SUCCESS_ERROR)
-    {
-        stat = OsclFailure;
-        return NULL;
-    }
-
-    return pData;
-}
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_callbacks.h b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_callbacks.h
deleted file mode 100644
index 1159913..0000000
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_callbacks.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEODEC_CALLBACKS_H_INCLUDED
-#define PVMF_OMX_VIDEODEC_CALLBACKS_H_INCLUDED
-
-
-#ifndef THREADSAFE_CALLBACK_AO_H_INCLUDED
-#include "threadsafe_callback_ao.h"
-#endif
-
-#ifndef THREADSAFE_MEMPOOL_H_INCLUDED
-#include "threadsafe_mempool.h"
-#endif
-
-
-#ifndef OMX_Types_h
-#include "omx_types.h"
-#endif
-
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-// structure that contains EventHandler callback type parameters:
-typedef struct EventHandlerSpecificData
-{
-    OMX_HANDLETYPE hComponent;
-    OMX_PTR pAppData;
-    OMX_EVENTTYPE eEvent;
-    OMX_U32 nData1;
-    OMX_U32 nData2;
-    OMX_PTR pEventData;
-} EventHandlerSpecificData;
-
-
-// structure that contains EmptyBufferDone callback type parameters:
-typedef struct EmptyBufferDoneSpecificData
-{
-    OMX_HANDLETYPE hComponent;
-    OMX_PTR pAppData;
-    OMX_BUFFERHEADERTYPE* pBuffer;
-} EmptyBufferDoneSpecificData;
-
-
-// structure that contains FillBufferDone callback type parameters:
-typedef struct FillBufferDoneSpecificData
-{
-    OMX_HANDLETYPE hComponent;
-    OMX_PTR pAppData;
-    OMX_BUFFERHEADERTYPE* pBuffer;
-} FillBufferDoneSpecificData;
-
-
-// This class defines the callback AO that handles the callbacks from the remote thread in a thread-safe way.
-// The callback events arriving from the remote thread are queued and processed later in PV thread context.
-// The class is DERIVED from the "ThreadSafeCallbackAO" class defined in "threadsafe_callback_ao.h/cpp"
-// OVERLOAD THE METHOD : "ProcessEvent" so that it does something meaningful
-
-
-// Test AO receives the remote thread specific API callback and then calls the generic API "ReceiveEvent"
-const char EventHandlerAOName[] = "EventHandlerCallbackAO";
-const char EmptyBufferDoneAOName[] = "EventHandlerCallbackAO";
-const char FillBufferDoneAOName[] = "EventHandlerCallbackAO";
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class EventHandlerThreadSafeCallbackAO : public ThreadSafeCallbackAO
-{
-    public:
-        // Constructor
-        EventHandlerThreadSafeCallbackAO(
-            void* aObserver = NULL,
-            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-            const char* aAOname = EventHandlerAOName,
-            int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-
-        // OVERLOADED ProcessEvent
-        OsclReturnCode ProcessEvent(OsclAny* EventData);
-
-        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-        virtual void Run();
-        virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-        virtual ~EventHandlerThreadSafeCallbackAO();
-        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-
-};
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class EmptyBufferDoneThreadSafeCallbackAO : public ThreadSafeCallbackAO
-{
-    public:
-        // Constructor
-        EmptyBufferDoneThreadSafeCallbackAO(
-            void* aObserver = NULL,
-            uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-            const char* aAOname = EmptyBufferDoneAOName,
-            int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        // OVERLOADED ProcessEvent
-        OsclReturnCode ProcessEvent(OsclAny* EventData);
-
-        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-        virtual void Run();
-        virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-        virtual ~EmptyBufferDoneThreadSafeCallbackAO();
-        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-};
-
-
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class FillBufferDoneThreadSafeCallbackAO : public ThreadSafeCallbackAO
-{
-    public:
-        // Constructor
-        FillBufferDoneThreadSafeCallbackAO(void* aObserver = NULL,
-                                           uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-                                           const char* aAOname = FillBufferDoneAOName,
-                                           int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        // OVERLOADED ProcessEvent
-        OsclReturnCode ProcessEvent(OsclAny* EventData);
-        // overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-        virtual void Run();
-        virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-        virtual ~FillBufferDoneThreadSafeCallbackAO();
-        ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-};
-
-#endif	//#ifndef PVMF_OMX_VIDEODEC_CALLBACKS_H_INLCUDED
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_factory.cpp b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_factory.cpp
index 545e446..18b17ef 100644
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_factory.cpp
+++ b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
 #include "oscl_error_codes.h"
 #include "oscl_exception.h"
 
-// Use default DLL entry point for Symbian
+// Use default DLL entry point
 #include "oscl_dll.h"
 
 OSCL_DLL_ENTRY_POINT_DEFAULT()
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_media_buffer.h b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_media_buffer.h
deleted file mode 100644
index b505f4f..0000000
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_media_buffer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PV_OMX_VIDEODEC_MEDIA_BUFFER_H_INCLUDED
-#define PV_OMX_VIDEODEC_MEDIA_BUFFER_H_INCLUDED
-
-
-#ifndef OSCL_ERROR_H_INCLUDED
-#include "oscl_error.h"
-#endif
-
-#ifndef OSCL_SCHEDULER_H_INCLUDED
-#include "oscl_scheduler.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-
-#ifndef OSCL_SHARED_PTR_H_INCLUDED
-#include "oscl_shared_ptr.h"
-#endif
-
-
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////
-/////////////////////////
-/////////////////////////
-// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
-//						1) Deallocates the underlying output buffer
-//						2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
-//					  Deallocator is created as part of the wrapper, and travels with the buffer wrapper
-
-class PVOMXBufferSharedPtrWrapperCombinedCleanupDA : public OsclDestructDealloc
-{
-    public:
-        PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
-                buf_alloc(allocator), ptr_to_data_to_dealloc(pMempoolData) {};
-        virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
-
-        virtual void destruct_and_dealloc(OsclAny* ptr)
-        {
-            // call buffer deallocator
-            if (buf_alloc != NULL)
-            {
-                buf_alloc->deallocate(ptr_to_data_to_dealloc);
-            }
-
-            // finally, free the shared ptr wrapper memory
-            oscl_free(ptr);
-        }
-
-    private:
-        Oscl_DefAlloc* buf_alloc;
-        void *ptr_to_data_to_dealloc;
-};
-
-#endif
-
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp
index 362b179..4d5c38f 100644
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp
+++ b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
 #include "pvmf_omx_videodec_node.h"
 #include "pvlogger.h"
 #include "oscl_error_codes.h"
-#include "pvmf_omx_videodec_port.h"
+#include "pvmf_omx_basedec_port.h"
 #include "pv_mime_string_utils.h"
 #include "oscl_snprintf.h"
 #include "pvmf_media_cmd.h"
@@ -27,32 +27,28 @@
 // needed for capability and config
 #include "pv_video_config_parser.h"
 
-#ifdef _DEBUG
-#include <stdio.h>
-#endif
 
 #include "omx_core.h"
-#include "pvmf_omx_videodec_callbacks.h"     //used for thin AO in Decoder's callbacks
+#include "pvmf_omx_basedec_callbacks.h"     //used for thin AO in Decoder's callbacks
 #include "pv_omxcore.h"
-#include "pv_omxmastercore.h"
+#include "omx_video.h"
 
-
-static const OMX_U32 OMX_SPEC_VERSION = 0x00000101;
-#define CONFIG_VERSION_SIZE(param) \
-       param.nVersion.nVersion = OMX_SPEC_VERSION; \
-       param.nSize = sizeof(param);
+#define CONFIG_SIZE_AND_VERSION(param) \
+	    param.nSize=sizeof(param); \
+	    param.nVersion.s.nVersionMajor = SPECVERSIONMAJOR; \
+	    param.nVersion.s.nVersionMinor = SPECVERSIONMINOR; \
+	    param.nVersion.s.nRevision = SPECREVISION; \
+	    param.nVersion.s.nStep = SPECSTEP;
 
 
 #define PVOMXVIDEODEC_EXTRA_YUVBUFFER_POOLNUM 3
 #define PVOMXVIDEODEC_MEDIADATA_POOLNUM (PVOMXVIDEODECMAXNUMDPBFRAMESPLUS1 + PVOMXVIDEODEC_EXTRA_YUVBUFFER_POOLNUM)
-#define PVOMXVIDEODEC_MEDIADATA_CHUNKSIZE 128
 
 
 // Node default settings
 #define PVOMXVIDEODECNODE_CONFIG_POSTPROCENABLE_DEF false
 #define PVOMXVIDEODECNODE_CONFIG_POSTPROCTYPE_DEF 0  // 0 (nopostproc),1(deblock),3(deblock&&dering)
 #define PVOMXVIDEODECNODE_CONFIG_DROPFRAMEENABLE_DEF false
-#define PVOMXVIDEODECNODE_CONFIG_MIMETYPE_DEF 0
 // H263 default settings
 #define PVOMXVIDEODECNODE_CONFIG_H263MAXBITSTREAMFRAMESIZE_DEF 40000
 #define PVOMXVIDEODECNODE_CONFIG_H263MAXBITSTREAMFRAMESIZE_MIN 20000
@@ -98,288 +94,12 @@
 
 
 
-// OMX CALLBACKS
-// 1) AO OMX component running in the same thread as the OMX node
-//	In this case, the callbacks can be called directly from the component
-//	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
-//	The callback can perform do RunIfNotReady
-
-// 2) Multithreaded component
-//	In this case, the callback is made using the threadsafe callback (TSCB) AO
-//	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent) => event is queued
-//  Node thread		 : dequeue event => TSCB(ProcessEvent)->ProcessCallbackEventHandler->EventHandlerProcessing
-
-
-
-// callback for Event Handler - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling EventHandlerProcessing
-OMX_ERRORTYPE CallbackEventHandler(OMX_OUT OMX_HANDLETYPE aComponent,
-                                   OMX_OUT OMX_PTR aAppData,
-                                   OMX_OUT OMX_EVENTTYPE aEvent,
-                                   OMX_OUT OMX_U32 aData1,
-                                   OMX_OUT OMX_U32 aData2,
-                                   OMX_OUT OMX_PTR aEventData)
-{
-
-    PVMFOMXVideoDecNode *Node = (PVMFOMXVideoDecNode *) aAppData;
-
-    if (Node->IsComponentMultiThreaded())
-    {
-        // allocate the memory for the callback event specific data
-        //EventHandlerSpecificData* ED = (EventHandlerSpecificData*) oscl_malloc(sizeof (EventHandlerSpecificData));
-        EventHandlerSpecificData* ED = (EventHandlerSpecificData*) Node->iThreadSafeHandlerEventHandler->iMemoryPool->allocate(sizeof(EventHandlerSpecificData));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->eEvent = aEvent;
-        ED->nData1 = aData1;
-        ED->nData2 = aData2;
-        ED->pEventData = aEventData;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerEventHandler->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-
-        OMX_ERRORTYPE status;
-        status = Node->EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
-        return status;
-    }
-
-}
-
-
-// callback for EmptyBufferDone - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling EmptyBufferDoneProcessing
-OMX_ERRORTYPE CallbackEmptyBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
-                                      OMX_OUT OMX_PTR aAppData,
-                                      OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-
-    PVMFOMXVideoDecNode *Node = (PVMFOMXVideoDecNode *) aAppData;
-    if (Node->IsComponentMultiThreaded())
-    {
-
-        // allocate the memory for the callback event specific data
-        //EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) oscl_malloc(sizeof (EmptyBufferDoneSpecificData));
-        EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) Node->iThreadSafeHandlerEmptyBufferDone->iMemoryPool->allocate(sizeof(EmptyBufferDoneSpecificData));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->pBuffer = aBuffer;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerEmptyBufferDone->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
-        return status;
-    }
-
-}
-
-// callback for FillBufferDone - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling FillBufferDoneProcessing
-OMX_ERRORTYPE CallbackFillBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
-                                     OMX_OUT OMX_PTR aAppData,
-                                     OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-    PVMFOMXVideoDecNode *Node = (PVMFOMXVideoDecNode *) aAppData;
-    if (Node->IsComponentMultiThreaded())
-    {
-
-        // allocate the memory for the callback event specific data
-        //FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) oscl_malloc(sizeof (FillBufferDoneSpecificData));
-        FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) Node->iThreadSafeHandlerFillBufferDone->iMemoryPool->allocate(sizeof(FillBufferDoneSpecificData));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->pBuffer = aBuffer;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerFillBufferDone->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
-        return status;
-    }
-
-}
-
-// Callback processing in multithreaded case - dequeued event - call EventHandlerProcessing
-OsclReturnCode PVMFOMXVideoDecNode::ProcessCallbackEventHandler_MultiThreaded(OsclAny* P)
-{
-
-    // re-cast the pointer
-
-    EventHandlerSpecificData* ED = (EventHandlerSpecificData*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_EVENTTYPE aEvent = ED->eEvent;
-    OMX_U32 aData1 = ED->nData1;
-    OMX_U32 aData2 = ED->nData2;
-    OMX_PTR aEventData = ED->pEventData;
-
-
-    EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
-
-
-    // release the allocated memory when no longer needed
-
-    iThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-
-
-// Callback processing in multithreaded case - dequeued event - call EmptyBufferDoneProcessing
-OsclReturnCode PVMFOMXVideoDecNode::ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P)
-{
-
-
-    // re-cast the pointer
-    EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
-
-    EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
-
-    // release the allocated memory when no longer needed
-
-    iThreadSafeHandlerEmptyBufferDone->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-
-// Callback processing in multithreaded case - dequeued event - call FillBufferDoneProcessing
-OsclReturnCode PVMFOMXVideoDecNode::ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P)
-{
-
-    // re-cast the pointer
-    FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
-
-
-    FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
-
-
-    // release the allocated memory when no longer needed
-
-    iThreadSafeHandlerFillBufferDone->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-//////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////
-
-
-
 /////////////////////////////////////////////////////////////////////////////
-// Class Distructor
+// Class Destructor
 /////////////////////////////////////////////////////////////////////////////
 PVMFOMXVideoDecNode::~PVMFOMXVideoDecNode()
 {
-    LogDiagnostics();
-
-    //Clearup decoder
-    DeleteOMXVideoDecoder();
-
-    // Cleanup callback AOs and Mempools
-    if (iThreadSafeHandlerEventHandler)
-    {
-        OSCL_DELETE(iThreadSafeHandlerEventHandler);
-        iThreadSafeHandlerEventHandler = NULL;
-    }
-    if (iThreadSafeHandlerEmptyBufferDone)
-    {
-        OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
-        iThreadSafeHandlerEmptyBufferDone = NULL;
-    }
-    if (iThreadSafeHandlerFillBufferDone)
-    {
-        OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
-        iThreadSafeHandlerFillBufferDone = NULL;
-    }
-
-    if (iMediaDataMemPool)
-    {
-        iMediaDataMemPool->removeRef();
-        iMediaDataMemPool = NULL;
-    }
-
-    if (iOutBufMemoryPool)
-    {
-        iOutBufMemoryPool->removeRef();
-        iOutBufMemoryPool = NULL;
-    }
-    if (iInBufMemoryPool)
-    {
-        iInBufMemoryPool->removeRef();
-        iInBufMemoryPool = NULL;
-    }
-
-    //Thread logoff
-    if (IsAdded())
-    {
-        RemoveFromScheduler();
-        iIsAdded = false;
-    }
-
-    //Cleanup allocated interfaces
-
-    //Cleanup allocated ports
     ReleaseAllPorts();
-
-    //Cleanup commands
-    //The command queues are self-deleting, but we want to
-    //notify the observer of unprocessed commands.
-    while (!iCurrentCommand.empty())
-    {
-        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
-    }
-    while (!iInputCommands.empty())
-    {
-        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
-    }
-
-    //Release Input buffer
-    iDataIn.Unbind();
-
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -410,194 +130,6 @@
     }
 }
 
-/////////////////////////////////////////////////////////////////////////////
-// Remove AO from the scheduler
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::ThreadLogoff()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFOMXVideoDecNode:ThreadLogoff"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            if (IsAdded())
-            {
-                RemoveFromScheduler();
-                iIsAdded = false;
-            }
-            iLogger = NULL;
-            SetState(EPVMFNodeCreated);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::GetCapability(PVMFNodeCapability& aNodeCapability)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::GetCapability() called"));
-
-    aNodeCapability = iCapability;
-    return PVMFSuccess;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFPortIter* PVMFOMXVideoDecNode::GetPorts(const PVMFPortFilter* aFilter)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::GetPorts() called"));
-
-    OSCL_UNUSED_ARG(aFilter);
-
-    return NULL;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::QueueCommandL(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVMFCommandId id;
-
-    id = iInputCommands.AddL(aCmd);
-
-    if (iInputCommands.size() == 1)
-    {
-        //wakeup the AO all the rest of input commands will reschedule the AO in Run
-        RunIfNotReady();
-    }
-    return id;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, PVMFOMXVideoDecNodeAllocator>& aUuids,
-        bool aExactUuidsOnly,
-        const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::QueryUUID() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
-        PVInterface*& aInterfacePtr,
-        const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::QueryInterface() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* /* aPortConfig */, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::RequestPort() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_REQUESTPORT, aPortTag, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ReleasePort() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RELEASEPORT, aPort, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Init(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Init() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_INIT, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Prepare() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_PREPARE, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Start(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Start() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_START, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Stop(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Stop() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_STOP, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Flush(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Flush() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_FLUSH, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Pause(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Pause() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_PAUSE, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::Reset(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Reset() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::CancelAllCommands() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_CANCELALL, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::CancelCommand() called"));
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommandBase::Construct(s, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_CANCELCMD, aCmdId, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::SetDecoderNodeConfiguration(PVMFOMXVideoDecNodeConfig& aNodeConfig)
-{
-    iNodeConfig = aNodeConfig;
-    return PVMFSuccess;
-}
-
-
 /////////////////////
 // Private Section //
 /////////////////////
@@ -606,29 +138,7 @@
 // Class Constructor
 /////////////////////////////////////////////////////////////////////////////
 PVMFOMXVideoDecNode::PVMFOMXVideoDecNode(int32 aPriority) :
-        OsclActiveObject(aPriority, "PVMFOMXVideoDecNode"),
-        iInPort(NULL),
-        iOutPort(NULL),
-        iOutBufMemoryPool(NULL),
-        iMediaDataMemPool(NULL),
-        iOMXComponentOutputBufferSize(0),
-        iOutputAllocSize(0),
-        iProcessingState(EPVMFOMXVideoDecNodeProcessingState_Idle),
-        iOMXVideoDecoder(NULL),
-        iSendBOS(false),
-        iStreamID(0),
-        iBOSTimestamp(0),
-        iSeqNum(0),
-        iSeqNum_In(0),
-        iIsAdded(true),
-        iLogger(NULL),
-        iDataPathLogger(NULL),
-        iClockLogger(NULL),
-        iExtensionRefCount(0),
-        iEndOfDataReached(false),
-        iEndOfDataTimestamp(0),
-        iDiagnosticsLogger(NULL),
-        iDiagnosticsLogged(false),
+        PVMFOMXBaseDecNode(aPriority, "PVMFOMXVideoDecNode"),
         iH263MaxBitstreamFrameSize(PVOMXVIDEODECNODE_CONFIG_H263MAXBITSTREAMFRAMESIZE_DEF),
         iH263MaxWidth(PVOMXVIDEODECNODE_CONFIG_H263MAXWIDTH_DEF),
         iH263MaxHeight(PVOMXVIDEODECNODE_CONFIG_H263MAXHEIGHT_DEF),
@@ -636,17 +146,14 @@
         iM4VMaxWidth(PVOMXVIDEODECNODE_CONFIG_M4VMAXWIDTH_DEF),
         iM4VMaxHeight(PVOMXVIDEODECNODE_CONFIG_M4VMAXHEIGHT_DEF),
         iNewWidth(0),
-        iNewHeight(0),
-        iAvgBitrateValue(0),
-        iResetInProgress(false),
-        iResetMsgSent(false)
+        iNewHeight(0)
 {
     iInterfaceState = EPVMFNodeCreated;
 
     iNodeConfig.iPostProcessingEnable = PVOMXVIDEODECNODE_CONFIG_POSTPROCENABLE_DEF;
     iNodeConfig.iPostProcessingMode = PVOMXVIDEODECNODE_CONFIG_POSTPROCTYPE_DEF;
     iNodeConfig.iDropFrame = PVOMXVIDEODECNODE_CONFIG_DROPFRAMEENABLE_DEF;
-    iNodeConfig.iMimeType = PVOMXVIDEODECNODE_CONFIG_MIMETYPE_DEF;
+    iNodeConfig.iMimeType = PVMF_MIME_FORMAT_UNKNOWN;
 
 
     int32 err;
@@ -654,7 +161,7 @@
 
              //Create the input command queue.  Use a reserve to avoid lots of
              //dynamic memory allocation.
-             iInputCommands.Construct(PVMF_OMXVIDEODEC_NODE_COMMAND_ID_START, PVMF_OMXVIDEODEC_NODE_COMMAND_VECTOR_RESERVE);
+             iInputCommands.Construct(PVMF_OMXBASEDEC_NODE_COMMAND_ID_START, PVMF_OMXBASEDEC_NODE_COMMAND_VECTOR_RESERVE);
 
              //Create the "current command" queue.  It will only contain one
              //command at a time, so use a reserve of 1.
@@ -666,1070 +173,174 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = true;
              iCapability.iMaxNumberOfPorts = 2;
-             iCapability.iInputFormatCapability.push_back(PVMF_H264_MP4);
-             iCapability.iInputFormatCapability.push_back(PVMF_H264_RAW);
-             iCapability.iInputFormatCapability.push_back(PVMF_H264);
-             iCapability.iInputFormatCapability.push_back(PVMF_M4V);
-             iCapability.iInputFormatCapability.push_back(PVMF_H263);
-             iCapability.iInputFormatCapability.push_back(PVMF_WMV);
-             iCapability.iOutputFormatCapability.push_back(PVMF_YUV420);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_MP4);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO_RAW);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_H264_VIDEO);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_M4V);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_H2631998);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_H2632000);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_WMV);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_YUV420);
 
              iAvailableMetadataKeys.reserve(PVMF_OMXVIDEODEC_NUM_METADATA_VALUES);
              iAvailableMetadataKeys.clear();
             );
 
-
-
-    iThreadSafeHandlerEventHandler = NULL;
-    iThreadSafeHandlerEmptyBufferDone = NULL;
-    iThreadSafeHandlerFillBufferDone = NULL;
-
-    iInBufMemoryPool = NULL;
-    iOutBufMemoryPool = NULL;
-
-    // init to some value
-    iOMXComponentOutputBufferSize = 0;
-    iNumOutputBuffers = 0;
-    iOMXComponentInputBufferSize = 0;
-    iNumInputBuffers = 0;
-
-    iDoNotSendOutputBuffersDownstreamFlag = false;
-    iDoNotSaveInputBuffersFlag = false;
-
-
-    iOutputBuffersFreed = true;// buffers have not been created yet, so they can be considered freed
-    iInputBuffersFreed = true;
-
-    // dynamic port reconfig init vars
-    iSecondPortReportedChange = false;
-    iDynamicReconfigInProgress = false;
-    iPauseCommandWasSentToComponent = false;
-    iStopCommandWasSentToComponent = false;
-
-
-    // EOS flag init
-    iIsEOSSentToComponent = false;
-    iIsEOSReceivedFromComponent = false;
-
-    // init state of component
-    iCurrentDecoderState = OMX_StateInvalid;
-
-    iOutTimeStamp = 0;
-
-    // counts output frames (for logging)
-    iOutFrameReceived = 0;
-    iOutFrameSent = 0;
-    iInFrameSent = 0;
-    iInFrameReceived = 0;
-    // reset repositioning related flags
-    iIsRepositioningRequestSentToComponent = false;
-    iIsRepositionDoneReceivedFromComponent = false;
-    iIsOutputPortFlushed = false;
-    iIsInputPortFlushed = false;
-
-    iInputBufferUnderConstruction = NULL; // for partial frame assembly
-    iFirstPieceOfPartialFrame = true;
-    iObtainNewInputBuffer = true;
-    iFirstDataMsgAfterBOS = true;
-    iKeepDroppingMsgsUntilMarkerBit = false;
-
     // need to init this allocator since verifyParameterSync (using the buffers) may be called through
-    // port interface before anything else happens. This seems a good place to do it
-    OSCL_TRY(err, iYuvFsiFragmentAlloc.size(PVOMXVIDEODEC_MEDIADATA_POOLNUM, sizeof(PVMFYuvFormatSpecificInfo0)));
+    // port interface before anything else happens.
+    OSCL_TRY(err, iFsiFragmentAlloc.size(PVOMXVIDEODEC_MEDIADATA_POOLNUM, sizeof(PVMFYuvFormatSpecificInfo0)));
 
     OSCL_TRY(err, iPrivateDataFsiFragmentAlloc.size(PVOMXVIDEODEC_MEDIADATA_POOLNUM, sizeof(OsclAny *)));
-
-
-
 }
 
 /////////////////////////////////////////////////////////////////////////////
-// Local Run Routine
+// This routine will handle the PortReEnable state
 /////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::Run()
+PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable()
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Run() In"));
+    // set the port index so that we get parameters for the proper port
+    iParamPort.nPortIndex = iPortIndexForDynamicReconfig;
 
-    // if reset is in progress, call DoReset again until Reset Msg is sent
-    if ((iResetInProgress == true) &&
-            (iResetMsgSent == false) &&
-            (iCurrentCommand.size() > 0) &&
-            (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-       )
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+
+    // get new parameters of the port
+    OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+
+    // send command for port re-enabling (for this to happen, we must first recreate the buffers)
+    OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);
+
+    // is this output port?
+    if (iPortIndexForDynamicReconfig == iOutputPortIndex)
     {
-        DoReset(iCurrentCommand.front());
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Calling DoReset"));
-        return; // don't do anything else
-    }
-    //Check for NODE commands...
-    if (!iInputCommands.empty())
-    {
-        if (ProcessCommand(iInputCommands.front()))
+        iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 15) & (~15)) * ((iParamPort.format.video.nFrameHeight + 15) & (~15)) * 3 / 2;
+
+        // check the new buffer size
+        if (iInPort)
         {
-            if (iInterfaceState != EPVMFNodeCreated
-                    && (!iInputCommands.empty() || (iInPort && (iInPort->IncomingMsgQueueSize() > 0)) ||
-                        (iDataIn.GetRep() != NULL)))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - rescheduling after process command"));
-                RunIfNotReady();
-            }
-            return;
-        }
-
-        if (!iInputCommands.empty())
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - rescheduling to process more commands"));
-            RunIfNotReady();
-        }
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Input commands empty"));
-    }
-
-    if (((iCurrentCommand.size() == 0) && (iInterfaceState != EPVMFNodeStarted)) ||
-            ((iCurrentCommand.size() > 0) && (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_START) && (iInterfaceState != EPVMFNodeStarted)))
-    {
-        // rescheduling because of input data will be handled in Command Processing Part
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Node not in Started state yet"));
-        return;
-    }
-
-
-    // Process port activity, push out all outgoing messages
-    if (iOutPort)
-    {
-        while (iOutPort->OutgoingMsgQueueSize())
-        {
-            // if port is busy it is going to wakeup from port ready event
-            if (!ProcessOutgoingMsg(iOutPort))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Outgoing Port Busy, cannot send more msgs"));
-                break;
-            }
-        }
-    }
-    int loopCount = 0;
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-    uint32 startticks = OsclTickCount::TickCount();
-    uint32 starttime = OsclTickCount::TicksToMsec(startticks);
-#endif
-    do // Try to consume all the data from the Input port
-    {
-        // Process port activity if there is no input data that is being processed
-        // Do not accept any input if EOS needs to be sent out
-        if (iInPort && (iInPort->IncomingMsgQueueSize() > 0) && (iDataIn.GetRep() == NULL) && !iEndOfDataReached)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Getting more input"));
-            if (!ProcessIncomingMsg(iInPort))
-            {
-                //Re-schedule to come back.
-                RunIfNotReady();
-                return;
-            }
-        }
-
-        if (iSendBOS)
-        {
-
-            // this routine may be re-entered multiple times in multiple Run's before the component goes through flushing all ports
-            if (!HandleRepositioning())
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Repositioning not done yet"));
-
-                return;
-            }
-
-            SendBeginOfMediaStreamCommand();
-        }
-
-        // If in init or ready to decode state, process data in the input port if there is input available and input buffers are present
-        // (note: at EOS, iDataIn will not be available)
-        if ((iDataIn.GetRep() != NULL) ||
-                ((iNumOutstandingOutputBuffers < iNumOutputBuffers) &&
-                 (iProcessingState == EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode) &&
-                 (iResetMsgSent == false)) ||
-                ((iDynamicReconfigInProgress == true) && (iResetMsgSent == false))
-           )
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::Run() - Calling HandleProcessingState"));
-
-            // input data is available, that means there is video data to be decoded
-            if (HandleProcessingState() != PVMFSuccess)
-            {
-                // If HandleProcessingState does not return Success, we must wait for an event
-                // no point in  rescheduling
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXVideoDecNode::Run() - HandleProcessingState did not return Success"));
-                return;
-            }
-        }
-        loopCount++;
-    }
-    while (iInPort &&
-            (((iInPort->IncomingMsgQueueSize() > 0) || (iDataIn.GetRep() != NULL)) && (iNumOutstandingInputBuffers < iNumInputBuffers))
-            && (!iEndOfDataReached)
-            && (iResetMsgSent == false)
-          );
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-    uint32 endticks = OsclTickCount::TickCount();
-    uint32 endtime = OsclTickCount::TicksToMsec(endticks);
-    uint32 timeinloop = (endtime - starttime);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iRunlLogger, PVLOGMSG_INFO,
-                    (0, "PVMFOMXVideoDecNode::Run() - LoopCount = %d, Time spent in loop(in ms) = %d, iNumOutstandingInputBuffers = %d, iNumOutstandingOutputBuffers = %d ",
-                     loopCount, timeinloop, iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
-#endif
-    // EOS processing:
-    // first send an empty buffer to OMX component and mark the EOS flag
-    // wait for the OMX component to send async event to indicate that it has reached this EOS buffer
-    // then, create and send the EOS message downstream
-
-    if (iEndOfDataReached && !iDynamicReconfigInProgress)
-    {
-
-        // if EOS was not sent yet and we have an available input buffer, send EOS buffer to component
-        if (!iIsEOSSentToComponent && (iNumOutstandingInputBuffers < iNumInputBuffers))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::Run() - Sending EOS marked buffer To Component "));
-
-            iIsEOSSentToComponent = true;
-
-
-            // if the component is not yet initialized or if it's in the middle of port reconfig,
-            // don't send EOS buffer to component. It does not care. Just set the flag as if we received
-            // EOS from the component to enable sending EOS downstream
-            if (iProcessingState != EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode)
-            {
-
-                iIsEOSReceivedFromComponent = true;
-            }
-            else if (!SendEOSBufferToOMXComponent())
-            {
-                // for some reason, Component can't receive the EOS buffer
-                // it could be that it is not initialized yet (because EOS could be the first msg). In this case,
-                // send the EOS downstream anyway
-                iIsEOSReceivedFromComponent = true;
-            }
-        }
-
-        // we must wait for event (acknowledgment from component)
-        // before sending EOS downstream. This is because OMX Component will send
-        // the EOS event only after processing remaining buffers
-
-        if (iIsEOSReceivedFromComponent)
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::Run() - Received EOS from component, Sending EOS msg downstream "));
-
-            if (iOutPort && iOutPort->IsOutgoingQueueBusy())
-            {
-                // note: we already tried to empty the outgoing q. If it's still busy,
-                // it means that output port is busy. Just return and wait for the port to become free.
-                // this will wake up the node and it will send out a msg from the q etc.
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXVideoDecNode::Run() - - EOS cannot be sent downstream, outgoing queue busy - wait"));
-                return;
-            }
-
-            if (SendEndOfTrackCommand()) // this will only q the EOS
-            {
-                // EOS send downstream OK, so reset the flag
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXVideoDecNode::Run() - EOS was queued to be sent downstream"));
-
-                iEndOfDataReached = false; // to resume normal processing, reset the flags
-                iIsEOSSentToComponent = false;
-                iIsEOSReceivedFromComponent = false;
-
-                RunIfNotReady(); // Run again to send out the EOS msg from the outgoing q, and resume
-                // normal processing
-                ReportInfoEvent(PVMFInfoEndOfData);
-            }
-        }
-        else
-        {
-            // keep sending output buffers, it's possible that the component needs to flush output
-            //	data at the end
-            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
-            {
-                if (!SendOutputBufferToOMXComponent())
-                    break;
-            }
-        }
-
-    }
-
-
-    //Check for flash command complition...
-    if (iInPort && iOutPort && (iCurrentCommand.size() > 0) &&
-            (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_FLUSH) &&
-            (iInPort->IncomingMsgQueueSize() == 0) &&
-            (iOutPort->OutgoingMsgQueueSize() == 0) &&
-            (iDataIn.GetRep() == NULL))
-    {
-        //flush command is complited
-        //Debug check-- all the port queues should be empty at this point.
-
-        OSCL_ASSERT(iInPort->IncomingMsgQueueSize() == 0 && iOutPort->OutgoingMsgQueueSize() == 0);
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::Run() - Flush pending"));
-        iEndOfDataReached = false;
-        iIsEOSSentToComponent = false;
-        iIsEOSReceivedFromComponent = false;
-
-
-        //Flush is complete.  Go to initialized state.
-        SetState(EPVMFNodePrepared);
-        //resume port input so the ports can be re-started.
-        iInPort->ResumeInput();
-        iOutPort->ResumeInput();
-        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-        RunIfNotReady();
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::Run() Out"));
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will dispatch recived commands
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::ProcessCommand(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    //normally this node will not start processing one command
-    //until the prior one is finished.  However, a hi priority
-    //command such as Cancel must be able to interrupt a command
-    //in progress.
-    if (!iCurrentCommand.empty() && !aCmd.hipri())
-        return false;
-
-    switch (aCmd.iCmd)
-    {
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_CANCELCMD:
-            DoCancelCommand(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_CANCELALL:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_GETNODEMETADATAKEY:
-        {
-            PVMFStatus retval = DoGetNodeMetadataKey(aCmd);
-            CommandComplete(iInputCommands, aCmd, retval);
-        }
-        break;
-
-        case PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_GETNODEMETADATAVALUE:
-        {
-            PVMFStatus retval = DoGetNodeMetadataValue(aCmd);
-            CommandComplete(iInputCommands, aCmd, retval);
-        }
-        break;
-
-        default://unknown command type
-            CommandComplete(iInputCommands, aCmd, PVMFFailure);
-            break;
-    }
-
-    return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will process incomming message from the port
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
-{
-    //Called by the AO to process one buffer off the port's
-    //incoming data queue.  This routine will dequeue and
-    //dispatch the data.
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "0x%x PVMFOMXVideoDecNode::ProcessIncomingMsg: aPort=0x%x", this, aPort));
-
-    PVMFStatus status = PVMFFailure;
-
-
-#ifdef SIMULATE_BOS
-
-    if (((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed == 6))
-    {
-
-        PVMFSharedMediaCmdPtr BOSCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-        // Set the format ID to BOS
-        BOSCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
-
-        // Set the timestamp
-        BOSCmdPtr->setTimestamp(201);
-        BOSCmdPtr->setStreamID(0);
-
-        // Convert to media message and send it out
-        PVMFSharedMediaMsgPtr mediaMsgOut;
-        convertToPVMFMediaCmdMsg(mediaMsgOut, BOSCmdPtr);
-
-        //store the stream id and time stamp of bos message
-        iStreamID = mediaMsgOut->getStreamID();
-        iBOSTimestamp = mediaMsgOut->getTimestamp();
-        iSendBOS = true;
-
-#ifdef _DEBUG
-        printf("PVMFOMXVideoDecNode::ProcessIncomingMsg() SIMULATED BOS\n");
-#endif
-        ((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed++;
-        return true;
-
-    }
-#endif
-#ifdef SIMULATE_PREMATURE_EOS
-    if (((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed == 5)
-    {
-        PVMFSharedMediaCmdPtr EOSCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-        // Set the format ID to EOS
-        EOSCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-        // Set the timestamp
-        EOSCmdPtr->setTimestamp(200);
-
-        // Convert to media message and send it out
-        PVMFSharedMediaMsgPtr mediaMsgOut;
-        convertToPVMFMediaCmdMsg(mediaMsgOut, EOSCmdPtr);
-
-        ((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed++;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::ProcessIncomingMsg: SIMULATED EOS"));
-#ifdef _DEBUG
-        printf("PVMFOMXVideoDecNode::ProcessIncomingMsg() SIMULATED EOS\n");
-#endif
-        // Set EOS flag
-        iEndOfDataReached = true;
-        // Save the timestamp for the EOS cmd
-        iEndOfDataTimestamp = mediaMsgOut->getTimestamp();
-
-        return true;
-    }
-
-#endif
-
-
-
-    PVMFSharedMediaMsgPtr msg;
-
-    status = aPort->DequeueIncomingMsg(msg);
-    if (status != PVMFSuccess)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                    (0, "0x%x PVMFOMXVideoDecNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed", this));
-        return false;
-    }
-
-    if (msg->getFormatID() == PVMF_MEDIA_CMD_BOS_FORMAT_ID)
-    {
-        //store the stream id and time stamp of bos message
-        iStreamID = msg->getStreamID();
-        iBOSTimestamp = msg->getTimestamp();
-        iSendBOS = true;
-
-        // if new BOS arrives, and
-        //if we're in the middle of a partial frame assembly
-        // abandon it and start fresh
-        if (iObtainNewInputBuffer == false)
-        {
-            if (iInputBufferUnderConstruction != NULL)
-            {
-                if (iInBufMemoryPool != NULL)
-                {
-                    iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
-                }
-                iInputBufferUnderConstruction = NULL;
-            }
-            iObtainNewInputBuffer = true;
-
-        }
-
-        // needed to init the sequence numbers and timestamp for partial frame assembly
-        iFirstDataMsgAfterBOS = true;
-        iKeepDroppingMsgsUntilMarkerBit = false;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::ProcessIncomingMsg: Received BOS stream %d, timestamp %d", iStreamID, iBOSTimestamp));
-        ((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed++;
-        return true;
-    }
-    else if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
-    {
-        // Set EOS flag
-        iEndOfDataReached = true;
-        // Save the timestamp for the EOS cmd
-        iEndOfDataTimestamp = msg->getTimestamp();
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::ProcessIncomingMsg: Received EOS"));
-
-        ((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed++;
-        return true; // do not do conversion into media data, just set the flag and leave
-    }
-
-    convertToPVMFMediaData(iDataIn, msg);
-
-
-    iCurrFragNum = 0; // for new message, reset the fragment counter
-    iIsNewDataFragment = true;
-
-    ((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed++;
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ProcessIncomingMsg() Received %d frames", ((PVMFOMXVideoDecPort*)aPort)->iNumFramesConsumed));
-
-    //return true if we processed an activity...
-    return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will process outgoing message by sending it into output the port
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::ProcessOutgoingMsg(PVMFPortInterface* aPort)
-{
-    //Called by the AO to process one message off the outgoing
-    //message queue for the given port.  This routine will
-    //try to send the data to the connected port.
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "0x%x PVMFOMXVideoDecNode::ProcessOutgoingMsg: aPort=0x%x", this, aPort));
-
-    PVMFStatus status = aPort->Send();
-    if (status == PVMFErrBusy)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "0x%x PVMFOMXVideoDecNode::ProcessOutgoingMsg: Connected port goes into busy state", this));
-    }
-
-    //Report any unexpected failure in port processing...
-    //(the InvalidState error happens when port input is suspended,
-    //so don't report it.)
-    if (status != PVMFErrBusy
-            && status != PVMFSuccess
-            && status != PVMFErrInvalidState)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "0x%x PVMFOMXVideoDecNode::Run: Error - ProcessPortActivity failed. port=0x%x, type=%d",
-                         this, iOutPort, PVMF_PORT_ACTIVITY_OUTGOING_MSG));
-        ReportErrorEvent(PVMFErrPortProcessing);
-    }
-
-    //return true if we processed an activity...
-    return (status != PVMFErrBusy);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will process received data usign State Machine
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::HandleProcessingState()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::HandleProcessingState() In"));
-
-    PVMFStatus status = PVMFSuccess;
-
-    switch (iProcessingState)
-    {
-        case EPVMFOMXVideoDecNodeProcessingState_InitDecoder:
-        {
-            // do init only if input data is available
-            if (iDataIn.GetRep() != NULL)
-            {
-                if (!InitDecoder(iDataIn))
-                {
-                    // Decoder initialization failed. Fatal error
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Decoder initialization failed"));
-                    ReportErrorEvent(PVMFErrResourceConfiguration);
-                    ChangeNodeState(EPVMFNodeError);
-                    break;
-                }
-
-                iProcessingState = EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode;
-                // spin once to send output buffers
-                RunIfNotReady();
-                status = PVMFSuccess; // allow rescheduling
-            }
-            break;
-        }
-
-        case EPVMFOMXVideoDecNodeProcessingState_WaitForInitCompletion:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() WaitForInitCompletion -> wait for config buffer to return"));
-
-
-            status = PVMFErrNoMemory; // prevent rescheduling
-            break;
-        }
-        // The FOLLOWING 4 states handle Dynamic Port Reconfiguration
-        case EPVMFOMXVideoDecNodeProcessingState_PortReconfig:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Sending Port Disable Command"));
-
-            // port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
-            OMX_SendCommand(iOMXVideoDecoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
-            // the port will now start returning outstanding buffers
-            // set the flag to prevent output from going downstream (in case of output port being reconfigd)
-            // set the flag to prevent input from being saved and returned to component (in case of input port being reconfigd)
-            // set the state to wait for port saying it is disabled
-            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
-            {
-                iDoNotSendOutputBuffersDownstreamFlag = true;
-            }
-            else if (iPortIndexForDynamicReconfig == iInputPortIndex)
-            {
-                iDoNotSaveInputBuffersFlag = true;
-
-            }
-            iProcessingState = EPVMFOMXVideoDecNodeProcessingState_WaitForBufferReturn;
-
-
-            // fall through to the next case to check if all buffers are already back
-        }
-
-        case EPVMFOMXVideoDecNodeProcessingState_WaitForBufferReturn:
-        {
-            // as buffers are coming back, Run may be called, wait until all buffers are back, then Free them all
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn "));
-            // check if it's output port being reconfigured
-            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
-            {
-                // if all buffers have returned, free them
-                if (iNumOutstandingOutputBuffers == 0)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> all output buffers are back, free them"));
-                    if (false == iOutputBuffersFreed)
-                    {
-                        if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
-                                                      iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                      iNumOutputBuffers, // number of buffers
-                                                      iOutputPortIndex, // port idx
-                                                      false // this is not input
-                                                     ))
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Cannot free output buffers "));
-
-                            SetState(EPVMFNodeError);
-                            ReportErrorEvent(PVMFErrNoMemory);
-                            return PVMFErrNoMemory;
-                        }
-                    }
-                    // if the callback (that port is disabled) has not arrived yet, wait for it
-                    // if it has arrived, it will set the state to PortReEnable
-                    if (iProcessingState != EPVMFOMXVideoDecNodeProcessingState_PortReEnable)
-                        iProcessingState = EPVMFOMXVideoDecNodeProcessingState_WaitForPortDisable;
-
-                    status = PVMFSuccess; // allow rescheduling of the node potentially
-                }
-                else
-                    status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic rescheduling
-                // but each buffer will reschedule the node when it comes in
-            }
-            else
-            { // this is input port
-
-                // if all buffers have returned, free them
-                if (iNumOutstandingInputBuffers == 0)
-                {
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> all input buffers are back, free them"));
-                    if (false == iInputBuffersFreed)
-                    {
-                        if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
-                                                      iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                      iNumInputBuffers, // number of buffers
-                                                      iInputPortIndex, // port idx
-                                                      true // this is input
-                                                     ))
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Cannot free input buffers "));
-
-                            SetState(EPVMFNodeError);
-                            ReportErrorEvent(PVMFErrNoMemory);
-                            return PVMFErrNoMemory;
-
-                        }
-                    }
-                    // if the callback (that port is disabled) has not arrived yet, wait for it
-                    // if it has arrived, it will set the state to PortReEnable
-                    if (iProcessingState != EPVMFOMXVideoDecNodeProcessingState_PortReEnable)
-                        iProcessingState = EPVMFOMXVideoDecNodeProcessingState_WaitForPortDisable;
-
-                    status = PVMFSuccess; // allow rescheduling of the node
-                }
-                else
-                    status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic
-                // rescheduling. Each buffer will reschedule the node
-                // when it comes in
-            }
-
-
-            // the state will be changed to PortReEnable once we get confirmation that Port was actually disabled
-            break;
-        }
-
-        case EPVMFOMXVideoDecNodeProcessingState_WaitForPortDisable:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> wait for port disable callback"));
-            // do nothing. Just wait for the port to become disabled (we'll get event from component, which will
-            // transition the state to PortReEnable
-            status = PVMFErrNoMemory; // prevent Rescheduling the node
-            break;
-        }
-
-        case EPVMFOMXVideoDecNodeProcessingState_PortReEnable:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Sending reenable port command"));
-            // set the port index so that we get parameters for the proper port
-            iParamPort.nPortIndex = iPortIndexForDynamicReconfig;
-
-            // get new parameters of the port
-            OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
-
-            // send command for port re-enabling (for this to happen, we must first recreate the buffers)
-            OMX_SendCommand(iOMXVideoDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);
-
-            // is this output port?
-            if (iPortIndexForDynamicReconfig == iOutputPortIndex)
+            if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO ||
+                    ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+                    ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW ||
+                    ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_M4V ||
+                    ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2631998 ||
+                    ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
             {
                 iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 15) & (~15)) * ((iParamPort.format.video.nFrameHeight + 15) & (~15)) * 3 / 2;
-
-                // check the new buffer size
-                if (iInPort)
-                {
-                    switch (((PVMFOMXVideoDecPort*)iInPort)->iFormat)
-                    {
-                        case PVMF_H264:
-                        case PVMF_H264_MP4:
-                        case PVMF_H264_RAW:
-                        case PVMF_M4V:
-                        case PVMF_H263:
-                            iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 15) & (~15)) * ((iParamPort.format.video.nFrameHeight + 15) & (~15)) * 3 / 2;
-                            break;
-                        case PVMF_WMV: // This is a requirement for the WMV decoder that we have currently
-                            iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 3) & (~3)) * (iParamPort.format.video.nFrameHeight) * 3 / 2;
-                            break;
-                        default:
-                            OSCL_ASSERT(false);
-                            break;
-                    }
-                }
-                // set the new width / height
-                iYUVWidth =  iParamPort.format.video.nFrameWidth;
-                iYUVHeight = iParamPort.format.video.nFrameHeight;
-
-                if (iOMXComponentOutputBufferSize < iParamPort.nBufferSize)
-                    iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
-
-                // do we need to increase the number of buffers?
-                if (iNumOutputBuffers < iParamPort.nBufferCountMin)
-                    iNumOutputBuffers = iParamPort.nBufferCountMin;
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::HandleProcessingState() new output buffers %d, size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
-
-                /* Allocate output buffers */
-                if (!CreateOutMemPool(iNumOutputBuffers))
-                {
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Cannot allocate output buffers "));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-                }
-
-                if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
-                                               iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                               iNumOutputBuffers, // number of buffers
-                                               iOMXComponentOutputBufferSize, // actual buffer size
-                                               iOutputPortIndex, // port idx
-                                               iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
-                                               false // this is not input
-                                              ))
-                {
-
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Cannot provide output buffers to component"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-
-                }
-
-                // do not drop output any more, i.e. enable output to be sent downstream
-                iDoNotSendOutputBuffersDownstreamFlag = false;
-
-
+            }
+            else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV) // This is a requirement for the WMV decoder that we have currently
+            {
+                iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 3) & (~3)) * (iParamPort.format.video.nFrameHeight) * 3 / 2;
             }
             else
             {
-                // this is input port
-
-                iOMXComponentInputBufferSize = iParamPort.nBufferSize;
-                // do we need to increase the number of buffers?
-                if (iNumInputBuffers < iParamPort.nBufferCountMin)
-                    iNumInputBuffers = iParamPort.nBufferCountMin;
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::HandleProcessingState() new buffers %d, size %d", iNumInputBuffers, iOMXComponentInputBufferSize));
-
-                /* Allocate input buffers */
-                if (!CreateInputMemPool(iNumInputBuffers))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Cannot allocate new input buffers to component"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-                }
-
-                if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
-                                               iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                               iNumInputBuffers, // number of buffers
-                                               iOMXComponentInputBufferSize, // actual buffer size
-                                               iInputPortIndex, // port idx
-                                               iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
-                                               true // this is input
-                                              ))
-                {
-
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> Cannot provide new input buffers to component"));
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return PVMFErrNoMemory;
-
-                }
-                // do not drop partially consumed input
-                iDoNotSaveInputBuffersFlag = false;
-
-
+                OSCL_ASSERT(false);
             }
-
-            // if the callback that the port was re-enabled has not arrived yet, wait for it
-            // if it has arrived, it will set the state to either PortReconfig or to ReadyToDecode
-            if (iProcessingState != EPVMFOMXVideoDecNodeProcessingState_PortReconfig &&
-                    iProcessingState != EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode)
-                iProcessingState = EPVMFOMXVideoDecNodeProcessingState_WaitForPortEnable;
-
-            status = PVMFSuccess; // allow rescheduling of the node
-            break;
         }
+        // set the new width / height
+        iYUVWidth =  iParamPort.format.video.nFrameWidth;
+        iYUVHeight = iParamPort.format.video.nFrameHeight;
 
-        case EPVMFOMXVideoDecNodeProcessingState_WaitForPortEnable:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Port Reconfiguration -> wait for port enable callback"));
-            // do nothing. Just wait for the port to become enabled (we'll get event from component, which will
-            // transition the state to ReadyToDecode
-            status = PVMFErrNoMemory; // prevent ReScheduling
-            break;
-        }
+        if (iOMXComponentOutputBufferSize < iParamPort.nBufferSize)
+            iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
 
-        // NORMAL DATA FLOW STATE:
-        case EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode:
+        // do we need to increase the number of buffers?
+        if (iNumOutputBuffers < iParamPort.nBufferCountMin)
+            iNumOutputBuffers = iParamPort.nBufferCountMin;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXVideoDecNode::HandlePortReEnable() new output buffers %d, size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
+
+        /* Allocate output buffers */
+        if (!CreateOutMemPool(iNumOutputBuffers))
         {
 
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Ready To Decode start"));
-            // In normal data flow and decoding state
-            // Send all available output buffers to the decoder
-
-            while (iNumOutstandingOutputBuffers < iNumOutputBuffers)
-            {
-                // grab buffer header from the mempool if possible, and send to component
-                if (!SendOutputBufferToOMXComponent())
-
-                    break;
-
-            }
-
-
-            // next, see if partially consumed input buffer needs to be resent back to OMX component
-            // NOTE: it is not allowed that the component returns more than 1 partially consumed input buffers
-            //		 i.e. if a partially consumed input buffer is returned, it is assumed that the OMX component
-            //		 will be waiting to get data
-
-            if (iInputBufferToResendToComponent != NULL)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                (0, "PVMFOMXVideoDecNode::HandleProcessingState() Sending previous - partially consumed input back to the OMX component"));
-
-                OMX_EmptyThisBuffer(iOMXVideoDecoder, iInputBufferToResendToComponent);
-                iInputBufferToResendToComponent = NULL; // do this only once
-            }
-            else if ((iNumOutstandingInputBuffers < iNumInputBuffers) && (iDataIn.GetRep() != NULL))
-            {
-                // try to get an input buffer header
-                // and send the input data over to the component
-                SendInputBufferToOMXComponent();
-            }
-
-            status = PVMFSuccess;
-            break;
-
-
-        }
-        case EPVMFOMXVideoDecNodeProcessingState_Stopping:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Stopping -> wait for Component to move from Executing->Idle"));
-
-            status = PVMFErrNoMemory; // prevent rescheduling
-            break;
-        }
-
-        case EPVMFOMXVideoDecNodeProcessingState_Pausing:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleProcessingState() Pausing -> wait for Component to move from Executing->Pause"));
-
-
-            status = PVMFErrNoMemory; // prevent rescheduling
-            break;
-        }
-
-        case EPVMFOMXVideoDecNodeProcessingState_WaitForOutgoingQueue:
-            status = PVMFErrNoMemory;
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::HandleProcessingState() Do nothing since waiting for output port queue to become available"));
-            break;
-
-        default:
-            break;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::HandleProcessingState() Out"));
-
-    return status;
-
-}
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::SendOutputBufferToOMXComponent()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendOutputBufferToOMXComponent() In"));
-
-
-    OutputBufCtrlStruct *output_buf = NULL;
-    int32 errcode = 0;
-
-    // try to get output buffer header
-    OSCL_TRY(errcode, output_buf = (OutputBufCtrlStruct *) iOutBufMemoryPool->allocate(iOutputAllocSize));
-    if (errcode != 0)
-    {
-        if (errcode == OsclErrNoResources)
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                            PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::SendOutputBufferToOMXComponent() No more output buffers in the mempool"));
-
-            iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *) iOutBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-            return false;
-        }
-        else
-        {
-            // Memory allocation for the pool failed
             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::SendOutputBufferToOMXComponent() Output mempool error"));
-
+                            (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot allocate output buffers "));
 
             SetState(EPVMFNodeError);
             ReportErrorEvent(PVMFErrNoMemory);
-            return false;
+            return PVMFErrNoMemory;
         }
 
+        if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
+                                       iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                       iNumOutputBuffers, // number of buffers
+                                       iOMXComponentOutputBufferSize, // actual buffer size
+                                       iOutputPortIndex, // port idx
+                                       iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
+                                       false // this is not input
+                                      ))
+        {
+
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot provide output buffers to component"));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return PVMFErrNoMemory;
+
+        }
+
+        // do not drop output any more, i.e. enable output to be sent downstream
+        iDoNotSendOutputBuffersDownstreamFlag = false;
+
+
+    }
+    else
+    {
+        // this is input port
+
+        iOMXComponentInputBufferSize = iParamPort.nBufferSize;
+        // do we need to increase the number of buffers?
+        if (iNumInputBuffers < iParamPort.nBufferCountMin)
+            iNumInputBuffers = iParamPort.nBufferCountMin;
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXVideoDecNode::HandlePortReEnable() new buffers %d, size %d", iNumInputBuffers, iOMXComponentInputBufferSize));
+
+        /* Allocate input buffers */
+        if (!CreateInputMemPool(iNumInputBuffers))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot allocate new input buffers to component"));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return PVMFErrNoMemory;
+        }
+
+        if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
+                                       iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
+                                       iNumInputBuffers, // number of buffers
+                                       iOMXComponentInputBufferSize, // actual buffer size
+                                       iInputPortIndex, // port idx
+                                       iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
+                                       true // this is input
+                                      ))
+        {
+
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Port Reconfiguration -> Cannot provide new input buffers to component"));
+
+            SetState(EPVMFNodeError);
+            ReportErrorEvent(PVMFErrNoMemory);
+            return PVMFErrNoMemory;
+
+        }
+        // do not drop partially consumed input
+        iDoNotSaveInputBuffersFlag = false;
+
+
     }
 
-    //for every allocated buffer, make sure you notify when buffer is released. Keep track of allocated buffers
-    // use mempool as context to recognize which buffer (input or output) was returned
-    iOutBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny *)iOutBufMemoryPool);
-    iNumOutstandingOutputBuffers++;
+    // if the callback that the port was re-enabled has not arrived yet, wait for it
+    // if it has arrived, it will set the state to either PortReconfig or to ReadyToDecode
+    if (iProcessingState != EPVMFOMXBaseDecNodeProcessingState_PortReconfig &&
+            iProcessingState != EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode)
+        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_WaitForPortEnable;
 
-    output_buf->pBufHdr->nFilledLen = 0; // make sure you tell OMX component buffer is empty
-    output_buf->pBufHdr->nOffset = 0;
-    output_buf->pBufHdr->pAppPrivate = output_buf; // set pAppPrivate to be pointer to output_buf
-    // (this is context for future release of this buffer to the mempool)
-    // this was done during buffer creation, but still repeat just in case
-    output_buf->pBufHdr->nFlags = 0; // Clear flags
-    OMX_FillThisBuffer(iOMXVideoDecoder, output_buf->pBufHdr);
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendOutputBufferToOMXComponent() Out"));
-
-    return true;
+    return PVMFSuccess; // allow rescheduling of the node
 }
 ////////////////////////////////////////////////////////////////////////////////
 bool PVMFOMXVideoDecNode::NegotiateComponentParameters()
@@ -1743,9 +354,10 @@
     uint32 NumPorts;
     uint32 ii;
 
+    //set version and size;
+    CONFIG_SIZE_AND_VERSION(VideoPortParameters);
     // get starting number
-    CONFIG_VERSION_SIZE(VideoPortParameters);
-    Err = OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamVideoInit, &VideoPortParameters);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamVideoInit, &VideoPortParameters);
     NumPorts = VideoPortParameters.nPorts; // must be at least 2 of them (in&out)
 
     if (Err != OMX_ErrorNone || NumPorts < 2)
@@ -1762,12 +374,11 @@
         // get port parameters, and determine if it is input or output
         // if there are more than 2 ports, the first one we encounter that has input direction is picked
 
+        CONFIG_SIZE_AND_VERSION(iParamPort);
 
         //port
-        CONFIG_VERSION_SIZE(iParamPort);
-
         iParamPort.nPortIndex = ii; // iInputPortIndex; //OMF_MC_H264D_PORT_INDEX_OF_STREAM;
-        Err = OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
 
         if (Err != OMX_ErrorNone)
         {
@@ -1800,11 +411,11 @@
         // get port parameters, and determine if it is input or output
         // if there are more than 2 ports, the first one we encounter that has output direction is picked
 
-        CONFIG_VERSION_SIZE(iParamPort);
+        CONFIG_SIZE_AND_VERSION(iParamPort);
 
         //port
         iParamPort.nPortIndex = ii;
-        Err = OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
 
         if (Err != OMX_ErrorNone)
         {
@@ -1830,10 +441,14 @@
         return false;
     }
 
-    CONFIG_VERSION_SIZE(iParamPort);
+
+
+    // now get input parameters
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+
     //Input port
     iParamPort.nPortIndex = iInputPortIndex;
-    Err = OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1842,8 +457,9 @@
     }
 
     // preset the number of input buffers
+
     //iNumInputBuffers = NUMBER_INPUT_BUFFER;
-    iNumInputBuffers = iParamPort.nBufferCountActual;
+    iNumInputBuffers = iParamPort.nBufferCountActual;  // use the value provided by component
 
     // do we need to increase the number of buffers?
     if (iNumInputBuffers < iParamPort.nBufferCountMin)
@@ -1859,9 +475,13 @@
     pvVideoConfigParserInputs aInputs;
     pvVideoConfigParserOutputs aOutputs;
 
-    aInputs.inPtr = (uint8*)((PVMFOMXVideoDecPort*)iInPort)->iTrackConfig;
-    aInputs.inBytes = (int32)((PVMFOMXVideoDecPort*)iInPort)->iTrackConfigSize;
-    aInputs.iMimeType = ((PVMFOMXVideoDecPort*)iInPort)->iFormat;
+    aInputs.inPtr = (uint8*)((PVMFOMXDecPort*)iInPort)->iTrackConfig;
+    aInputs.inBytes = (int32)((PVMFOMXDecPort*)iInPort)->iTrackConfigSize;
+    aInputs.iMimeType = ((PVMFOMXDecPort*)iInPort)->iFormat;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXVideoDecNode::NegotiateComponentParameters() Calling video config parser - TrackConfig = %p, TrackConfigSize = %d, mimetype = %s", aInputs.inPtr, aInputs.inBytes, aInputs.iMimeType.getMIMEStrPtr()));
+
 
     int16 status;
     status = pv_video_config_parser(&aInputs, &aOutputs);
@@ -1870,16 +490,19 @@
         return false;
     }
 
-// before setting the buffer size, get track config from the port, and feed it to the config parser and then  port settings of
-// the OMX component
-// set the width/height on INPUT port parameters (this may change during port reconfig)
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFOMXVideoDecNode::NegotiateComponentParameters() pv config parser says width=%d and height=%d", aOutputs.width, aOutputs.height));
+
+
+    // set the width/height on INPUT port parameters (this may change during port reconfig)
     if ((aOutputs.width != 0) && (aOutputs.height != 0))
     {
         iParamPort.format.video.nFrameWidth = aOutputs.width;
         iParamPort.format.video.nFrameHeight = aOutputs.height;
     }
 
-    Err = OMX_SetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1888,10 +511,9 @@
     }
 
     //Port 1 for output port
-    CONFIG_VERSION_SIZE(iParamPort);
-
     iParamPort.nPortIndex = iOutputPortIndex;
-    Err = OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    CONFIG_SIZE_AND_VERSION(iParamPort);
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1899,14 +521,11 @@
         return false;
     }
 
-    iNumOutputBuffers = iParamPort.nBufferCountActual;
-    if (iNumOutputBuffers > NUMBER_OUTPUT_BUFFER)
-        iNumOutputBuffers = NUMBER_OUTPUT_BUFFER;
-
     // check if params are OK. In case of H263, width/height cannot be obtained until
     // 1st frame is decoded, so read them from the output port.
     // otherwise, used Width/Height from the config parser utility
-    if ((aOutputs.width != 0) && (aOutputs.height != 0) && iInPort && ((PVMFOMXVideoDecPort*)iInPort)->iFormat != PVMF_H263)
+    // set the width/height based on port parameters (this may change during port reconfig)
+    if ((aOutputs.width != 0) && (aOutputs.height != 0) && iInPort && (((PVMFOMXDecPort*)iInPort)->iFormat != PVMF_MIME_H2631998 || ((PVMFOMXDecPort*)iInPort)->iFormat != PVMF_MIME_H2632000))
     {
         iYUVWidth  = aOutputs.width;
         iYUVHeight = aOutputs.height;
@@ -1917,16 +536,21 @@
         iYUVHeight = iParamPort.format.video.nFrameHeight;
     }
 
+    //iNumOutputBuffers = NUMBER_OUTPUT_BUFFER;
+    iNumOutputBuffers = iParamPort.nBufferCountActual;
+    if (iNumOutputBuffers > NUMBER_OUTPUT_BUFFER)
+        iNumOutputBuffers = NUMBER_OUTPUT_BUFFER; // make sure number of output buffers is not larger than port queue size
     iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
     if (iNumOutputBuffers < iParamPort.nBufferCountMin)
         iNumOutputBuffers = iParamPort.nBufferCountMin;
 
     iParamPort.nBufferCountActual = iNumOutputBuffers;
+    CONFIG_SIZE_AND_VERSION(iParamPort);
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXVideoDecNode::NegotiateComponentParameters() Outport buffers %d,size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
 
-    Err = OMX_SetParameter(iOMXVideoDecoder, OMX_IndexParamPortDefinition, &iParamPort);
+    Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamPortDefinition, &iParamPort);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1935,11 +559,12 @@
     }
 
 
-// Get video color format
+
+    // Get video color format
     OMX_VIDEO_PARAM_PORTFORMATTYPE VideoPortFormat;
     // init to unknown
     iOMXVideoColorFormat = OMX_COLOR_FormatUnused;
-    CONFIG_VERSION_SIZE(VideoPortFormat);
+    CONFIG_SIZE_AND_VERSION(VideoPortFormat);
     VideoPortFormat.nPortIndex = iOutputPortIndex;
 
     VideoPortFormat.nIndex = 0; // read the preferred format - first
@@ -1947,7 +572,8 @@
 // doing this in a while loop while incrementing nIndex will get all supported formats
 // until component says OMX_ErrorNoMore
 // For now, we just use the preferred one (with nIndex=0) assuming it is supported at MIO
-    Err = OMX_GetParameter(iOMXVideoDecoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
+
+    Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
     if (Err != OMX_ErrorNone)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1962,8 +588,9 @@
 
 
         // Now set the format to confirm parameters
-        CONFIG_VERSION_SIZE(VideoPortFormat);
-        Err = OMX_SetParameter(iOMXVideoDecoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
+        CONFIG_SIZE_AND_VERSION(VideoPortFormat);
+
+        Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
         if (Err != OMX_ErrorNone)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -1972,817 +599,144 @@
         }
     }
 
-
     // now that we have the color format, interpret it
     if (iOMXVideoColorFormat == OMX_COLOR_Format8bitRGB332)
     {
-        iYUVFormat = PVMF_RGB8;
+        iYUVFormat = PVMF_MIME_RGB8;
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_Format12bitRGB444)
     {
-        iYUVFormat = PVMF_RGB12;
+        iYUVFormat = PVMF_MIME_RGB12;
     }
     else if (iOMXVideoColorFormat >= OMX_COLOR_Format16bitARGB4444 && iOMXVideoColorFormat <= OMX_COLOR_Format16bitBGR565)
     {
-        iYUVFormat = PVMF_RGB16;
+        iYUVFormat = PVMF_MIME_RGB16;
     }
     else if (iOMXVideoColorFormat >= OMX_COLOR_Format24bitRGB888 && iOMXVideoColorFormat <= OMX_COLOR_Format24bitARGB1887)
     {
-        iYUVFormat = PVMF_RGB24;
+        iYUVFormat = PVMF_MIME_RGB24;
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV420Planar)
     {
-        iYUVFormat = PVMF_YUV420_PLANAR; // Y, U, V are separate - entire planes
+        iYUVFormat = PVMF_MIME_YUV420_PLANAR; // Y, U, V are separate - entire planes
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV420PackedPlanar)
     {
-        iYUVFormat = PVMF_YUV420_PACKEDPLANAR; // each slice contains Y,U,V separate
+        iYUVFormat = PVMF_MIME_YUV420_PACKEDPLANAR; // each slice contains Y,U,V separate
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar)
     {
-        iYUVFormat = PVMF_YUV420_SEMIPLANAR; // Y and UV interleaved - entire planes
+        iYUVFormat = PVMF_MIME_YUV420_SEMIPLANAR; // Y and UV interleaved - entire planes
     }
-    else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV422PackedSemiPlanar)
+    else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar)
     {
-        iYUVFormat = PVMF_YUV422_PACKEDSEMIPLANAR; // Y and UV interleaved - sliced
+        iYUVFormat = PVMF_MIME_YUV420_PACKEDSEMIPLANAR; // Y and UV interleaved - sliced
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV422Planar)
     {
-        iYUVFormat = PVMF_YUV422_PLANAR; // Y, U, V are separate - entire planes
+        iYUVFormat = PVMF_MIME_YUV422_PLANAR; // Y, U, V are separate - entire planes
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV422PackedPlanar)
     {
-        iYUVFormat = PVMF_YUV422_PACKEDPLANAR; // each slice contains Y,U,V separate
+        iYUVFormat = PVMF_MIME_YUV422_PACKEDPLANAR; // each slice contains Y,U,V separate
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV422SemiPlanar)
     {
-        iYUVFormat = PVMF_YUV422_SEMIPLANAR; // Y and UV interleaved - entire planes
+        iYUVFormat = PVMF_MIME_YUV422_SEMIPLANAR; // Y and UV interleaved - entire planes
     }
     else if (iOMXVideoColorFormat == OMX_COLOR_FormatYUV422PackedSemiPlanar)
     {
-        iYUVFormat = PVMF_YUV422_PACKEDSEMIPLANAR; // Y and UV interleaved - sliced
+        iYUVFormat = PVMF_MIME_YUV422_PACKEDSEMIPLANAR; // Y and UV interleaved - sliced
     }
-    else if (iOMXVideoColorFormat == 0x7FA30C00)
+    else if (iOMXVideoColorFormat == 0x7FA30C00) // SPECIAL VALUE
     {
-        iYUVFormat = PVMF_YUV420_SEMIPLANAR_YVU; // semiplanar with Y and VU interleaved
+        iYUVFormat = PVMF_MIME_YUV420_SEMIPLANAR_YVU; // semiplanar with Y and VU interleaved
     }
     else
     {
-        iYUVFormat = PVMF_FORMAT_UNKNOWN;
+        iYUVFormat = PVMF_MIME_FORMAT_UNKNOWN;
         return false;
     }
-    return true;
-}
 
-bool PVMFOMXVideoDecNode::SetDefaultCapabilityFlags()
-{
+    //Set input video format
+    //This is need it since a single component could handle differents roles
 
-    iIsOMXComponentMultiThreaded = true;
-
-    iOMXComponentSupportsExternalOutputBufferAlloc = false;
-    iOMXComponentSupportsExternalInputBufferAlloc = false;
-    iOMXComponentSupportsMovableInputBuffers = false;
-
-    iOMXComponentSupportsPartialFrames = false;
-    iOMXComponentNeedsNALStartCode = true;
-    iOMXComponentCanHandleIncompleteFrames = true;
-
-    return true;
-}
-
-
-
-bool PVMFOMXVideoDecNode::SendEOSBufferToOMXComponent()
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendEOSBufferToOMXComponent() In"));
-
-
-    // first of all, check if the component is running. EOS could be sent prior to component/decoder
-    // even being initialized
-
-    // returning false will ensure that the EOS will be sent downstream anyway without waiting for the
-    // Component to respond
-    if (iCurrentDecoderState != OMX_StateExecuting)
-        return false;
-
-    // get an input buffer. Without a buffer, no point in proceeding
-    InputBufCtrlStruct *input_buf = NULL;
-    int32 errcode = 0;
-
-    // we already checked that the number of buffers is OK, so we don't expect problems
-    // try to get input buffer header
-    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
-    if (errcode != 0)
+    // Init to desire format
+    PVMFFormatType Format = PVMF_MIME_FORMAT_UNKNOWN;
+    if (iInPort != NULL)
     {
-        if (errcode == OsclErrNoResources)
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                            PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::SendEOSBufferToOMXComponent() No more buffers in the mempool - unexpected"));
-
-            iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-            return false;
-        }
-        else
-        {
-            // Memory allocation for the pool failed
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::SendEOSBufferToOMXComponent() Input mempool error"));
-
-
-            SetState(EPVMFNodeError);
-            ReportErrorEvent(PVMFErrNoMemory);
-            return false;
-        }
-
+        Format = ((PVMFOMXDecPort*)iInPort)->iFormat;
     }
-
-    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
-    iNumOutstandingInputBuffers++;
-
-    // in this case, no need to use input msg refcounter. Make sure its unbound
-    (input_buf->pMediaData).Unbind();
-
-    // THIS IS AN EMPTY BUFFER. FLAGS ARE THE ONLY IMPORTANT THING
-    input_buf->pBufHdr->nFilledLen = 0;
-    input_buf->pBufHdr->nOffset = 0;
-    input_buf->pBufHdr->nTimeStamp = iEndOfDataTimestamp;
-
-    // set ptr to input_buf structure for Context (for when the buffer is returned)
-    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-    // do not use Mark here (but init to NULL to prevent problems)
-    input_buf->pBufHdr->hMarkTargetComponent = NULL;
-    input_buf->pBufHdr->pMarkData = NULL;
-
-
-    // init buffer flags
-    input_buf->pBufHdr->nFlags = 0;
-
-    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-    // most importantly, set the EOS flag:
-    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_EOS;
-
-    // send buffer to component
-    OMX_EmptyThisBuffer(iOMXVideoDecoder, input_buf->pBufHdr);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendEOSBufferToOMXComponent() Out"));
-
-    return true;
-
-}
-
-// this method is called under certain conditions only if the node is doing partial frame assembly
-void PVMFOMXVideoDecNode::DropCurrentBufferUnderConstruction()
-{
-    if (iObtainNewInputBuffer == false)
+    if (Format == PVMF_MIME_H264_VIDEO ||
+            Format == PVMF_MIME_H264_VIDEO_MP4 ||
+            Format == PVMF_MIME_H264_VIDEO_RAW)
     {
-        if (iInputBufferUnderConstruction != NULL)
-        {
-            if (iInBufMemoryPool != NULL)
-            {
-                iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
-            }
-
-            iInputBufferUnderConstruction = NULL;
-        }
-        iObtainNewInputBuffer = true;
-
+        iOMXVideoCompressionFormat = OMX_VIDEO_CodingAVC;
     }
-}
-
-// this method is called under certain conditions only if the node is doing partial frame assembly
-void PVMFOMXVideoDecNode::SendIncompleteBufferUnderConstruction()
-{
-
-    // this should never be the case, but check anyway
-    if (iInputBufferUnderConstruction != NULL)
+    else if (Format == PVMF_MIME_M4V)
     {
-        // mark as end of frame (the actual end piece is missing)
-        iInputBufferUnderConstruction->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
+        iOMXVideoCompressionFormat = OMX_VIDEO_CodingMPEG4;
+    }
+    else if (Format == PVMF_MIME_H2631998 ||
+             Format == PVMF_MIME_H2632000)
+    {
+        iOMXVideoCompressionFormat = OMX_VIDEO_CodingH263;
+    }
+    else if (Format == PVMF_MIME_WMV)
+    {
+        iOMXVideoCompressionFormat = OMX_VIDEO_CodingWMV;
+    }
+    else
+    {
+        // Illegal codec specified.
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::SendIncompleteBufferUnderConstruction()  - Sending Incomplete Buffer 0x%x to OMX Component MARKER field set to %x, TS=%d", iInputBufferUnderConstruction->pBufHdr->pBuffer, iInputBufferUnderConstruction->pBufHdr->nFlags, iInTimestamp));
-
-        OMX_EmptyThisBuffer(iOMXVideoDecoder, iInputBufferUnderConstruction->pBufHdr);
-
-        iInputBufferUnderConstruction = NULL;
-        iObtainNewInputBuffer = true;
-
+                        (0, "PVMFOMXVideoDecNode::NegotiateComponentParameters() Problem setting video compression format"));
+        return false;
     }
-}
-
-bool PVMFOMXVideoDecNode::SendInputBufferToOMXComponent()
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() In"));
 
 
-    // first need to take care of  missing packets if node is assembling partial frames.
-    // The action depends whether the component (I) can handle incomplete frames/NALs or (II) cannot handle incomplete frames/NALs
-    if (!iOMXComponentSupportsPartialFrames)
+    CONFIG_SIZE_AND_VERSION(VideoPortFormat);
+    VideoPortFormat.nPortIndex = iInputPortIndex;
+
+    // Search the proper format index and set it.
+    // Since we already know that the component has the role we need, search until finding the proper nIndex
+    // if component does not find the format will return OMX_ErrorNoMore
+
+    for (ii = 0;; ii++)
     {
-
-        // there are 4 cases after receiving a media msg and realizing there were missing packet(s):
-
-        // a) TS remains the same - i.e. missing 1 or more pieces in the middle of the same frame
-        //		 I) basically ignore  - keep assembling the same frame  (middle will be missing)
-        //		II) drop current buffer, drop msgs until next msg with marker bit arrives
-
-
-        // b) TS is different than previous frame. Previous frame was sent OK (had marker bit).
-        //				New frame assembly has not started yet. one or more pieces are missing from
-        //				the beginning of the frame
-        //	  	 I) basically ignore - get a new buffer and start assembling new frame (beginning will be missing)
-        //		II) no buffer to drop, but keep dropping msgs until next msg with marker bit arrives
-
-        // c) TS is different than previous frame. Frame assembly has started (we were in the middle of a frame)
-        //		but only 1 piece is missing => We know that the missing frame must have had the marker bit
-
-        //		 I) send out current buffer (last piece will be missing), get a new buffer and start assembling new frame (which is OK)
-        //		II) just drop current buffer. Get a new buffer and start assembling new frame (no need to wait for marker bit)
-
-        // d) TS is different than previous frame. Frame assembly has started ( we were in the middle of a frame)
-        //		multiple pieces are missing => The last piece of the frame with the marker bit is missing for sure, but
-        //		there could be also other frames missing or the beginning of the next frame is missing etc.
-
-        //		 I) send out current bufer (last piece will be missing). Get a new buffer and start assembling new frame (beginning COULD BE missing as well)
-        //		II) drop current buffer. Keep dropping msgs until next msg with marker bit arrives
-
-
-        // extract info from the media message
-
-        uint32 current_msg_seq_num = iDataIn->getSeqNum();
-        uint32 current_msg_ts = iDataIn->getTimestamp();
-        uint32 current_msg_marker;
-        if (iSetMarkerBitForEveryFrag == true) // PV AVC case
-        {
-
-            current_msg_marker = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
-        }
-        else
-        {
-            current_msg_marker = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
-        }
-
-        // check if this is the very first data msg
-        if (iFirstDataMsgAfterBOS)
-        {
-            iFirstDataMsgAfterBOS = false;
-            //init the sequence number & ts to make sure dropping logic does not kick in
-            iInPacketSeqNum = current_msg_seq_num - 1;
-            iInTimestamp = current_msg_ts - 10;
-        }
-
-
-        // first check if we need to keep dropping msgs
-        if (iKeepDroppingMsgsUntilMarkerBit)
-        {
-            // drop this message
-            iDataIn.Unbind();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() Dropping input msg with seqnum %d until marker bit", current_msg_seq_num));
-
-            //if msg has marker bit, stop dropping msgs
-            if (current_msg_marker != 0)
-            {
-                iKeepDroppingMsgsUntilMarkerBit = false;
-                // also remember the sequence number & timestamp so that we have reference
-                iInPacketSeqNum = current_msg_seq_num;
-                iInTimestamp = current_msg_ts;
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() Input msg with seqnum %d has marker bit set. Stop dropping msgs", current_msg_seq_num));
-
-            }
-            return true;
-        }
-
-        // compare current and saved sequence number - difference should be exactly 1
-        //	if it is more, there is something missing
-        if ((current_msg_seq_num - iInPacketSeqNum) > 1)
+        VideoPortFormat.nIndex = ii;
+        Err = OMX_GetParameter(iOMXDecoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
+        if (Err != OMX_ErrorNone)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - MISSING PACKET DETECTED. Input msg with seqnum %d, TS=%d. Previous seqnum: %d, Previous TS: %d", current_msg_seq_num, iInPacketSeqNum, current_msg_ts, iInTimestamp));
-
-            // find out which case it is by comparing TS
-            if (current_msg_ts == iInTimestamp)
-            {
-
-                // this is CASE a)
-                // same ts, i.e. pieces are missing from the middle of the current frame
-                if (!iOMXComponentCanHandleIncompleteFrames)
-                {
-                    // drop current buffer, drop msgs until you hit msg with marker bit
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Drop current buffer under construction. Keep dropping msgs until marker bit"));
-
-                    DropCurrentBufferUnderConstruction();
-                    iKeepDroppingMsgsUntilMarkerBit = true;
-                }
-                else
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Continue processing"));
-
-                }
-            }
-            else // new ts and old ts are different
-            {
-                //  are we at the beginning of the new frame assembly?
-                if (iObtainNewInputBuffer)
-                {
-                    // CASE b)
-                    // i.e. we sent out previous frame, but have not started assembling a new frame. Pieces are missing from the beginning
-                    if (!iOMXComponentCanHandleIncompleteFrames)
-                    {
-                        // there is no current buffer to drop, but drop msgs until you hit msg with marker bit
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - No current buffer under construction. Keep dropping msgs until marker bit"));
-
-                        iKeepDroppingMsgsUntilMarkerBit = true;
-                    }
-                    else
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Continue processing"));
-                    }
-                }
-                else	// no, we are in the middle of a frame assembly, but new ts is different
-                {
-                    // is only 1 msg missing?
-                    if ((current_msg_seq_num - iInPacketSeqNum) == 2)
-                    {
-                        // CASE c)
-                        // only the last piece of the previous frame is missing
-                        if (iOMXComponentCanHandleIncompleteFrames)
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Send incomplete buffer under construction. Start assembling new frame"));
-
-                            SendIncompleteBufferUnderConstruction();
-                        }
-                        else
-                        {
-                            // drop current frame only, but no need to wait until next marker bit.
-                            // start assembling new frame
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Drop current buffer under construction. It's OK to start assembling new frame. Only 1 packet is missing"));
-
-                            DropCurrentBufferUnderConstruction();
-                        }
-                    }
-                    else
-                    {
-                        // CASE d)
-                        // (multiple) final piece(s) of the previous frame are missing and possibly pieces at the
-                        // beginning of a new frame are also missing
-                        if (iOMXComponentCanHandleIncompleteFrames)
-                        {
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Send incomplete buffer under construction. Start assembling new frame (potentially damaged)"));
-
-                            SendIncompleteBufferUnderConstruction();
-                        }
-                        else
-                        {
-                            // drop current frame. start assembling new frame, but first keep dropping
-                            // until you hit msg with marker bit.
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Drop current buffer under construction. Keep dropping msgs until marker bit"));
-
-                            DropCurrentBufferUnderConstruction();
-                            iKeepDroppingMsgsUntilMarkerBit = true;
-                        }
-                    }
-                }// end of if(obtainNewInputBuffer)/else
-            }// end of if(curr_msg_ts == iInTimestamp)
-        }//end of if(deltaseqnum>1)/else
-
-        // check if we need to keep dropping msgs
-        if (iKeepDroppingMsgsUntilMarkerBit)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() Dropping input msg with seqnum %d until marker bit", current_msg_seq_num));
-
-            // drop this message
-            iDataIn.Unbind();
-
-            //if msg has marker bit, stop dropping msgs
-            if (current_msg_marker != 0)
-            {
-                iKeepDroppingMsgsUntilMarkerBit = false;
-                // also remember the sequence number & timestamp so that we have reference
-                iInPacketSeqNum = current_msg_seq_num;
-                iInTimestamp = current_msg_ts;
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() Input msg with seqnum %d has marker bit set. Stop dropping msgs", current_msg_seq_num));
-
-            }
-            return true;
+                            (0, "PVMFOMXVideoDecNode::NegotiateComponentParameters() Problem setting video compression format"));
+            return false;
         }
-
-    }// end of if/else (iOMXSUpportsPartialFrames)
-
-    InputBufCtrlStruct *input_buf = NULL;
-    int32 errcode = 0;
-
-// NOTE: a) if NAL start codes must be inserted i.e. iOMXComponentNeedsNALStartCodes is TRUE, then iOMXComponentSupportsMovableInputBuffers must be set to FALSE.
-//		 b) if iOMXComponentSupportsPartialFrames is FALSE, then iOMXComponentSupportsMovableInputBuffers must be FALSE as well
-//		 c) if iOMXCOmponentSupportsPartialFrames is FALSE, and the input frame/NAL size is larger than the buffer size, the frame/NAL is discarded
-
-    do
-    {
-        // do loop to loop over all fragments
-        // first of all , get an input buffer. Without a buffer, no point in proceeding
-        if (iObtainNewInputBuffer == true) // if partial frames are being reconstructed, we may be copying data into
-            //existing buffer, so we don't need the new buffer
+        if (iOMXVideoCompressionFormat == VideoPortFormat.eCompressionFormat)
         {
-            // try to get input buffer header
-            OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
-            if (errcode != 0)
-            {
-                if (errcode == OsclErrNoResources)
-                {
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                                    PVLOGMSG_DEBUG, (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() No more buffers in the mempool"));
-
-                    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-                    return false;
-                }
-                else
-                {
-                    // Memory allocation for the pool failed
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() Input mempool error"));
-
-
-                    SetState(EPVMFNodeError);
-                    ReportErrorEvent(PVMFErrNoMemory);
-                    return false;
-                }
-
-            }
-
-            // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-            iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
-            iNumOutstandingInputBuffers++;
-
-            // Now we have the buffer header (i.e. a buffer) to send to component:
-            // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
-            //	into OMX component without copying (and update the input msg refcount)
-            //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
-            input_buf->pBufHdr->nFilledLen = 0; // init this for now
-            // save this in a class member
-            iInputBufferUnderConstruction = input_buf;
-            // set flags
-            if (iOMXComponentSupportsPartialFrames == true)
-            {
-                // if partial frames can be sent, then send them
-                // but we'll always need the new buffer for the new fragment
-                iObtainNewInputBuffer = true;
-            }
-            else
-            {
-                // if we need to assemble partial frames, then obtain a new buffer
-                // only after assembling the partial frame
-                iObtainNewInputBuffer = false;
-            }
-
-            iFirstPieceOfPartialFrame = true;
+            break;
         }
-        else
-        {
-            input_buf = iInputBufferUnderConstruction;
-        }
-
-        // When copying content, a special case is when the input fragment is larger than the buffer and has to
-        //	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
-
-        // if this is the first fragment in a new message, extract some info:
-        if (iCurrFragNum == 0)
-        {
-
-            // NOTE: SeqNum differ in Codec and in Node because of the fact that
-            // one msg can contain multiple fragments that are sent to the codec as
-            // separate buffers. Node tracks msgs and codec tracks even separate fragments
-
-            iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
-            // amount that the input seq. number increased
-
-            iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
-            iInTimestamp = iDataIn->getTimestamp();
-            iInDuration = iDataIn->getDuration();
-            iInNumFrags = iDataIn->getNumFragments();
-
-            if (iSetMarkerBitForEveryFrag == true) // PV AVC case
-            {
-                iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT;
-            }
-            else
-            {
-                iCurrentMsgMarkerBit = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
-            }
-
-            // logging info:
-            if (iDataIn->getNumFragments() > 1)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - New msg has MULTI-FRAGMENTS"));
-            }
-
-            if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT) && !(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT))
-            {
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - New msg has NO MARKER BIT"));
-            }
-        }
-
-
-        // get a memfrag from the message
-        OsclRefCounterMemFrag frag;
-        iDataIn->getMediaFragment(iCurrFragNum, frag);
-
-
-        if (iOMXComponentSupportsMovableInputBuffers)
-        {
-            // no copying required
-            // Note: This cannot be used for NAL start code insertion and
-            //		 for the case when partial frames are not supported by the component
-
-            // increment the RefCounter of the message associated with the mem fragment/buffer
-            // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
-            // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
-
-            iDataIn.GetRefCounter()->addRef();
-
-            // associate the buffer ctrl structure with the message ref counter and ptr
-            input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
-
-
-            // set pointer to the data, length, offset
-            input_buf->pBufHdr->pBuffer = (uint8 *)frag.getMemFragPtr();
-            input_buf->pBufHdr->nFilledLen = frag.getMemFragSize();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Buffer 0x%x of size %d, %d frag out of tot. %d, TS=%d", input_buf->pBufHdr->pBuffer, frag.getMemFragSize(), iCurrFragNum + 1, iDataIn->getNumFragments(), iInTimestamp));
-
-            iCurrFragNum++; // increment fragment number and move on to the next
-            iIsNewDataFragment = true; // update the flag
-
-        }
-        else
-        {
-
-            // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
-            (input_buf->pMediaData).Unbind();
-
-
-            if (iOMXComponentNeedsNALStartCode == true && iFirstPieceOfPartialFrame == true)
-            {
-                oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
-                            (void *) NAL_START_CODE,
-                            NAL_START_CODE_SIZE);
-                input_buf->pBufHdr->nFilledLen += NAL_START_CODE_SIZE;
-                iFirstPieceOfPartialFrame = false;
-
-            }
-
-            // is this a new data fragment or are we still working on separating the old one?
-            if (iIsNewDataFragment == true)
-            {
-                //  if fragment size is larger than the buffer size,
-                //	need to break up the fragment even further into smaller chunks
-
-                // init variables needed for fragment separation
-                iCopyPosition = 0;
-                iFragmentSizeRemainingToCopy  = frag.getMemFragSize();
-
-            }
-
-            // can the remaining fragment fit into the buffer?
-            uint32 bytes_remaining_in_buffer = (input_buf->pBufHdr->nAllocLen - input_buf->pBufHdr->nFilledLen);
-
-            if (iFragmentSizeRemainingToCopy <= bytes_remaining_in_buffer)
-            {
-
-                oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
-                            (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
-                            iFragmentSizeRemainingToCopy);
-
-                input_buf->pBufHdr->nFilledLen += iFragmentSizeRemainingToCopy;
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d ", iFragmentSizeRemainingToCopy, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen, iInTimestamp));
-
-                iCopyPosition += iFragmentSizeRemainingToCopy;
-                iFragmentSizeRemainingToCopy = 0;
-
-
-
-                iIsNewDataFragment = true; // done with this fragment. Get a new one
-                iCurrFragNum++;
-
-            }
-            else
-            {
-                // copy as much as you can of the current fragment into the current buffer
-                if (bytes_remaining_in_buffer > 0)
-                {
-                    oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
-                                (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
-                                bytes_remaining_in_buffer);
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d", input_buf->pBufHdr->nAllocLen, iCurrFragNum + 1, iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen, iInTimestamp));
-                }
-                input_buf->pBufHdr->nFilledLen = input_buf->pBufHdr->nAllocLen;
-                iCopyPosition += bytes_remaining_in_buffer; // move current position within fragment forward
-                iFragmentSizeRemainingToCopy -= bytes_remaining_in_buffer;
-                iIsNewDataFragment = false; // set the flag to indicate we're still working on the "old" fragment
-
-                if (!iOMXComponentSupportsPartialFrames)
-                {
-                    // if partial frames are not supported, and data cannot fit into the buffer, i.e. the buffer is full at this point
-                    // simply go through remaining fragments if they exist and "drop" them
-                    // i.e. send what data is alrady copied in the buffer and ingore the rest
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - Reconstructing partial frame - more data cannot fit in buffer 0x%x, TS=%d.Skipping data.", input_buf->pBufHdr->pBuffer, iInTimestamp));
-
-                    iIsNewDataFragment = true; // done with this fragment, get a new one
-                    iCurrFragNum++;
-                }
-
-
-            }
-
-        }
-
-
-        // set buffer fields (this is the same regardless of whether the input is movable or not)
-        input_buf->pBufHdr->nOffset = 0;
-        input_buf->pBufHdr->nTimeStamp = iInTimestamp;
-
-        // set ptr to input_buf structure for Context (for when the buffer is returned)
-        input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-        // do not use Mark here (but init to NULL to prevent problems)
-        input_buf->pBufHdr->hMarkTargetComponent = NULL;
-        input_buf->pBufHdr->pMarkData = NULL;
-
-
-        // init buffer flags
-        input_buf->pBufHdr->nFlags = 0;
-
-        // set marker bit on or off
-        // a) AVC - file playback - each fragment is a complete NAL (1 or more frags i.e. NALs per msg)
-        //    AVC - streaming	- 1 msg contains 1 full NAL or a portion of a NAL
-        // NAL may be broken up over multiple msgs. Frags are not allowed in streaming
-        // b) M4V - file playback - each msg is 1 frame
-        //    M4V - streaming   - 1 frame may be broken up into multiple messages and fragments
-
-        // c) WMV - file playback - 1 frame is 1 msg
-        //    WMV - streaming     - 1 frame may be broken up into multiple messages and fragments
-
-        if (iSetMarkerBitForEveryFrag == true)
-        {
-            // this is basically the AVC case of PV
-            //
-            if (iIsNewDataFragment)
-            {
-                if ((iDataIn->getNumFragments() > 1))
-                {
-                    // if more than 1 fragment in the message and we have not broken it up
-                    //(i.e. this is the last piece of a broken up piece), put marker bit on it unconditionally
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - END OF FRAGMENT - Multifragmented msg AVC case, Buffer 0x%x MARKER bit set to 1, TS=%d", input_buf->pBufHdr->pBuffer, iInTimestamp));
-                    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-                    // if NAL is complete, make sure you send it and obtain new buffer
-                    iObtainNewInputBuffer = true;
-                }
-                else if ((iDataIn->getNumFragments() == 1))
-                {
-                    // this is (the last piece of broken up by us) single-fragmented message. This can be a piece of a NAL (streaming) or a full NAL (file )
-                    // apply marker bit if the message carries one
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - END OF FRAGMENT - Buffer 0x%x MARKER bit set to %d, TS=%d", input_buf->pBufHdr->pBuffer, iCurrentMsgMarkerBit, iInTimestamp));
-
-                    if (iCurrentMsgMarkerBit)
-                    {
-                        input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-                        // once NAL is complete, make sure you send it and obtain new buffer
-
-                        iObtainNewInputBuffer = true;
-                    }
-
-                }
-            }
-            else
-            {
-                // we are separating fragments that are too big, i.e. bigger than
-                // what 1 buffer can hold, this fragment Can NEVER have marker bit
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - NOT END OF FRAGMENT - Buffer 0x%x MARKER bit set to 0, TS=%d", input_buf->pBufHdr->pBuffer, iInTimestamp));
-
-            }
-        }
-        else
-        {
-            // "normal" case, i.e. only fragments at ends of msgs may have marker bit set
-            //					fragments in the middle of a message never have marker bit set
-            // there is also a (slight) possibility we broke up the fragment into more fragments
-            //	because they can't fit into input buffer. In this case, make sure you apply
-            //	the marker bit (if necessary) only to the very last piece of the very last fragment
-
-            // for all other cases, clear the marker bit flag for the buffer
-            if ((iCurrFragNum == iDataIn->getNumFragments()) && iIsNewDataFragment)
-            {
-                // if all the fragments have been exhausted, and this is the last piece
-                // of the (possibly broken up) last fragment
-
-                // use the marker bit from the end of message
-                if (iCurrentMsgMarkerBit)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 1, TS=%d", input_buf->pBufHdr->pBuffer, iInTimestamp));
-
-                    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-                    // once frame is complete, make sure you send it and obtain new buffer
-
-                    iObtainNewInputBuffer = true;
-                }
-                else
-                {
-
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 0, TS=%d", input_buf->pBufHdr->pBuffer, iInTimestamp));
-                }
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() - NOT END OF MESSAGE - Buffer 0x%x MARKER bit set to 0, TS=%d", input_buf->pBufHdr->pBuffer, iInTimestamp));
-            }
-
-
-        }// end of else(setmarkerbitforeveryfrag)
-
-
-        // set the key frame flag if necessary (mark every fragment that belongs to it)
-        if (iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT)
-            input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
-
-        if (iObtainNewInputBuffer == true)
-        {
-            // if partial frames are supported, this flag will always be set
-            // if partial frames are not supported, this flag will be set only
-            // if the partial frame/NAL has been assembled, so we can send it
-
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent()  - Sending Buffer 0x%x to OMX Component MARKER field set to %x, TS=%d", input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFlags, iInTimestamp));
-
-            OMX_EmptyThisBuffer(iOMXVideoDecoder, input_buf->pBufHdr);
-            iInputBufferUnderConstruction = NULL; // this buffer is gone to OMX component now
-        }
-
-        // if we sent all fragments to OMX component, decouple the input message from iDataIn
-        // Input message is "decoupled", so that we can get a new message for processing into iDataIn
-        //	However, the actual message is released completely to upstream mempool once all of its fragments
-        //	are returned by the OMX component
-
-        if (iCurrFragNum == iDataIn->getNumFragments())
-        {
-            iDataIn.Unbind();
-
-        }
-
-
     }
-    while (iCurrFragNum < iInNumFrags); //iDataIn->getNumFragments());
-
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendInputBufferToOMXComponent() Out"));
+    // Now set the format to confirm parameters
+    Err = OMX_SetParameter(iOMXDecoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
+    if (Err != OMX_ErrorNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVMFOMXVideoDecNode::NegotiateComponentParameters() Problem setting video compression format"));
+        return false;
+    }
 
     return true;
-
 }
+
 /////////////////////////////////////////////////////////////////////////////
 bool PVMFOMXVideoDecNode::InitDecoder(PVMFSharedMediaDataPtr& DataIn)
 {
+    OSCL_UNUSED_ARG(DataIn);
+
     uint16 length = 0, size = 0;
     uint8 *tmp_ptr;
+    PVMFFormatType Format = PVMF_MIME_FORMAT_UNKNOWN;
 
     OsclRefCounterMemFrag DataFrag;
     OsclRefCounterMemFrag refCtrMemFragOut;
@@ -2793,110 +747,95 @@
     //		here, we're sending input/config buffers.
     //		Then, we'll go to ReadyToDecode state and send output as well
 
-    switch (((PVMFOMXVideoDecPort*)iInPort)->iFormat)
+    if (iInPort != NULL)
     {
-        case PVMF_H264:
-        case PVMF_H264_MP4:
+        Format = ((PVMFOMXDecPort*)iInPort)->iFormat;
+    }
+    if (Format == PVMF_MIME_H264_VIDEO ||
+            Format == PVMF_MIME_H264_VIDEO_MP4)
+    {
+        uint8* initbuffer = ((PVMFOMXDecPort*)iInPort)->getTrackConfig();
+        int32 initbufsize = (int32)((PVMFOMXDecPort*)iInPort)->getTrackConfigSize();
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::InitDecoder() for H264 Decoder. Initialization data Size %d.", initbufsize));
+
+        if (initbufsize > 0)
         {
-            DataIn->getFormatSpecificInfo(DataFrag);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::InitDecoder() Config NALs (Size=%d)", DataFrag.getMemFragSize()));
-            //get pointer to the data fragment
-            uint8* initbuffer = (uint8 *) DataFrag.getMemFragPtr();
-            uint32 initbufsize = (int32) DataFrag.getMemFragSize();
 
-            if (initbufsize > 0)
+            // there may be more than 1 NAL in config info in format specific data memfragment (SPS, PPS)
+            tmp_ptr = initbuffer;
+            do
             {
-
-                // there may be more than 1 NAL in config info in format specific data memfragment (SPS, PPS)
-                tmp_ptr = initbuffer;
-                do
-                {
-                    length = (uint16)(tmp_ptr[1] << 8) | tmp_ptr[0];
-                    size += (length + 2);
-                    if (size > initbufsize)
-                        break;
-                    tmp_ptr += 2;
+                length = (uint16)(tmp_ptr[1] << 8) | tmp_ptr[0];
+                size += (length + 2);
+                if (size > initbufsize)
+                    break;
+                tmp_ptr += 2;
 
 
-                    if (!SendConfigBufferToOMXComponent(tmp_ptr, length))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFOMXVideoDecNode::InitDecoder() Error in processing config buffer"));
-                        return false;
-
-                    }
-
-                    tmp_ptr += length;
-
-                }
-                while (size < initbufsize);
-            }
-
-        }
-        break;
-
-
-        case PVMF_M4V:
-        case PVMF_H263:
-        {
-            DataIn->getFormatSpecificInfo(DataFrag);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::InitDecoder() VOL header (Size=%d)", DataFrag.getMemFragSize()));
-
-            //get pointer to the data fragment
-            uint8* initbuffer = (uint8 *) DataFrag.getMemFragPtr();
-            uint32 initbufsize = (int32) DataFrag.getMemFragSize();
-
-            // for H263, the initbufsize is 0, and initbuf= NULL. Config is done after 1st frame of data
-            if (initbufsize > 0)
-            {
-
-                if (!SendConfigBufferToOMXComponent(initbuffer, initbufsize))
+                if (!SendConfigBufferToOMXComponent(tmp_ptr, length))
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                                     (0, "PVMFOMXVideoDecNode::InitDecoder() Error in processing config buffer"));
                     return false;
+
                 }
+
+                tmp_ptr += length;
+
             }
-
-
+            while (size < initbufsize);
         }
-        break;
-        case PVMF_WMV:
+    }
+    else if (Format == PVMF_MIME_M4V ||
+             Format == PVMF_MIME_H2631998 ||
+             Format == PVMF_MIME_H2632000)
+    {
+        uint8* initbuffer = ((PVMFOMXDecPort*)iInPort)->getTrackConfig();
+        int32 initbufsize = (int32)((PVMFOMXDecPort*)iInPort)->getTrackConfigSize();
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::InitDecoder() for H263 Decoder. Initialization data Size %d.", initbufsize));
+
+        // for H263, the initbufsize is 0, and initbuf= NULL. Config is done after 1st frame of data
+        if (initbufsize > 0)
         {
 
-            // in case of WMV, get config parameters from the port
-            uint8* initbuffer = ((PVMFOMXVideoDecPort*)iInPort)->getTrackConfig();
-            int32 initbufsize = (int32)((PVMFOMXVideoDecPort*)iInPort)->getTrackConfigSize();
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::InitDecoder() for WMV Decoder. Initialization data Size %d.", initbufsize));
-
-            if (initbufsize > 0)
+            if (!SendConfigBufferToOMXComponent(initbuffer, initbufsize))
             {
-
-                if (!SendConfigBufferToOMXComponent(initbuffer, initbufsize))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::InitDecoder() Error in processing config buffer"));
-                    return false;
-                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXVideoDecNode::InitDecoder() Error in processing config buffer"));
+                return false;
             }
         }
-        break;
-        case PVMF_H264_RAW:
-        default:
-            // Unknown codec type
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::InitDecoder() Unknown codec type"));
-            return false;
+    }
+    else if (Format == PVMF_MIME_WMV)
+    {
+        uint8* initbuffer = ((PVMFOMXDecPort*)iInPort)->getTrackConfig();
+        int32 initbufsize = (int32)((PVMFOMXDecPort*)iInPort)->getTrackConfigSize();
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::InitDecoder() for WMV Decoder. Initialization data Size %d.", initbufsize));
+
+        if (initbufsize > 0)
+        {
+
+            if (!SendConfigBufferToOMXComponent(initbuffer, initbufsize))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFOMXVideoDecNode::InitDecoder() Error in processing config buffer"));
+                return false;
+            }
+        }
+    }
+    else
+    {
+        // Unknown codec type
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFOMXVideoDecNode::InitDecoder() Unknown codec type"));
+        return false;
     }
 
-
     //Varibles initialization
-    sendYuvFsi = true;
-
-
+    sendFsi = true;
 
     iLastYUVWidth = 0;
     iLastYUVHeight = 0;
@@ -2908,607 +847,6 @@
 
 
 
-bool PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent(uint8 *initbuffer, uint32 initbufsize)
-
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() In"));
-
-
-    // first of all , get an input buffer. Without a buffer, no point in proceeding
-    InputBufCtrlStruct *input_buf = NULL;
-    int32 errcode = 0;
-
-    // try to get input buffer header
-    OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
-    if (errcode != 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() Input buffer mempool problem -unexpected at init"));
-
-        return false;
-    }
-
-    // Got a buffer OK
-    // keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-    iInBufMemoryPool->notifyfreechunkavailable(*this, (OsclAny*) iInBufMemoryPool);
-    iNumOutstandingInputBuffers++;
-
-    input_buf->pBufHdr->nFilledLen = 0; //init this to 0
-
-    // Now we have the buffer header (i.e. a buffer) to send to component:
-    // Depending on OMX component capabilities, either pass the input msg fragment(s) directly
-    //	into OMX component without copying (and update the input msg refcount)
-    //	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
-
-    // When copying content, a special case is when the input fragment is larger than the buffer and has to
-    //	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
-
-    iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
-    // amount that the input seq. number increased
-
-    iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
-    iInTimestamp = iDataIn->getTimestamp();
-    iInDuration = iDataIn->getDuration();
-
-
-    if (!(iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT))
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() - New msg has NO MARKER BIT"));
-    }
-
-
-    if (iOMXComponentSupportsMovableInputBuffers)
-    {
-        // no copying required
-
-        // increment the RefCounter of the message associated with the mem fragment/buffer
-        // when sending this buffer to OMX component. (When getting the buffer back, the refcounter
-        // will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
-
-        iDataIn.GetRefCounter()->addRef();
-
-        // associate the buffer ctrl structure with the message ref counter and ptr
-        input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(), iDataIn.GetRefCounter());
-
-
-        // set pointer to the data, length, offset
-        input_buf->pBufHdr->pBuffer = initbuffer;
-        input_buf->pBufHdr->nFilledLen = initbufsize;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() - Config Buffer 0x%x of size %d", initbuffer, initbufsize));
-
-    }
-    else
-    {
-
-        // in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
-        (input_buf->pMediaData).Unbind();
-
-        // we assume the buffer is large enough to fit the config data
-
-        iCopyPosition = 0;
-        iFragmentSizeRemainingToCopy  = initbufsize;
-
-        if (iOMXComponentNeedsNALStartCode == true)
-        {
-
-            oscl_memcpy(input_buf->pBufHdr->pBuffer,
-                        (void *) NAL_START_CODE,
-                        NAL_START_CODE_SIZE);
-            input_buf->pBufHdr->nFilledLen += NAL_START_CODE_SIZE;
-
-        }
-
-        // can the remaining fragment fit into the buffer?
-        uint32 bytes_remaining_in_buffer = (input_buf->pBufHdr->nAllocLen - input_buf->pBufHdr->nFilledLen);
-
-        if (iFragmentSizeRemainingToCopy <= bytes_remaining_in_buffer)
-        {
-
-            oscl_memcpy(input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
-                        (void *)(initbuffer + iCopyPosition),
-                        iFragmentSizeRemainingToCopy);
-
-            input_buf->pBufHdr->nFilledLen += iFragmentSizeRemainingToCopy;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() - Copied %d bytes into buffer 0x%x of size %d", iFragmentSizeRemainingToCopy, input_buf->pBufHdr->pBuffer, input_buf->pBufHdr->nFilledLen));
-
-            iCopyPosition += iFragmentSizeRemainingToCopy;
-            iFragmentSizeRemainingToCopy = 0;
-
-
-        }
-        else
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() Config buffer too large problem -unexpected at init"));
-
-            return false;
-        }
-
-    }
-
-
-    // set buffer fields (this is the same regardless of whether the input is movable or not
-    input_buf->pBufHdr->nOffset = 0;
-    input_buf->pBufHdr->nTimeStamp = iInTimestamp;
-
-    // set ptr to input_buf structure for Context (for when the buffer is returned)
-    input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-    // do not use Mark here (but init to NULL to prevent problems)
-    input_buf->pBufHdr->hMarkTargetComponent = NULL;
-    input_buf->pBufHdr->pMarkData = NULL;
-
-
-    // init buffer flags
-    input_buf->pBufHdr->nFlags = 0;
-
-    // set marker bit on
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendConfigBufferToOMXComponent() - END OF FRAGMENT - Buffer 0x%x MARKER bit set to 1", input_buf->pBufHdr->pBuffer));
-
-    input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
-    OMX_EmptyThisBuffer(iOMXVideoDecoder, input_buf->pBufHdr);
-
-    return true;
-
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::CreateOutMemPool(uint32 num_buffers)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::CreateOutMemPool() start"));
-    // In the case OMX component wants to allocate its own buffers,
-    // mempool only contains OutputBufCtrlStructures (i.e. ptrs to buffer headers)
-    // In case OMX component uses pre-allocated buffers (here),
-    // mempool allocates OutputBufCtrlStructure (i.e. ptrs to buffer hdrs), followed by actual buffers
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::CreateOutMemPool() Allocating output buffer header pointers"));
-
-    iOutputAllocSize = oscl_mem_aligned_size((uint32)sizeof(OutputBufCtrlStruct));
-
-    if (iOMXComponentSupportsExternalOutputBufferAlloc)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::CreateOutMemPool() Allocating output buffers of size %d as well", iOMXComponentOutputBufferSize));
-
-        //pre-negotiated output buffer size
-        iOutputAllocSize += iOMXComponentOutputBufferSize;
-    }
-
-    // for media data wrapper
-    if (iMediaDataMemPool)
-    {
-        iMediaDataMemPool->removeRef();
-        iMediaDataMemPool = NULL;
-    }
-
-    if (iOutBufMemoryPool)
-    {
-        iOutBufMemoryPool->removeRef();
-        iOutBufMemoryPool = NULL;
-    }
-
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iOutBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
-    if (leavecode || iOutBufMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::CreateOutMemPool() Memory pool structure for output buffers failed to allocate"));
-        return false;
-    }
-
-
-
-    // allocate a dummy buffer to actually create the mempool
-    OsclAny *dummy_alloc = NULL; // this dummy buffer will be released at end of scope
-    leavecode = 0;
-    OSCL_TRY(leavecode, dummy_alloc = iOutBufMemoryPool->allocate(iOutputAllocSize));
-    if (leavecode || dummy_alloc == NULL)
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::CreateOutMemPool() Memory pool for output buffers failed to allocate"));
-        return false;
-    }
-    iOutBufMemoryPool->deallocate(dummy_alloc);
-    // init the counter
-    iNumOutstandingOutputBuffers = 0;
-
-    // allocate mempool for media data message wrapper
-    leavecode = 0;
-    OSCL_TRY(leavecode, iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers, PVOMXVIDEODEC_MEDIADATA_CHUNKSIZE)));
-    if (leavecode || iMediaDataMemPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::CreateOutMemPool() Media Data Buffer pool for output buffers failed to allocate"));
-        return false;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::CreateOutMemPool() done"));
-    return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////// Creates memory pool for input buffer management ///////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::CreateInputMemPool(uint32 num_buffers)
-{
-    // 3 cases in order of preference and simplicity
-
-    // Case 1 (buffers allocated upstream - no memcpy needed):
-    //	PV OMX Component - We use buffers allocated outside the OMX node (i.e. allocated upstream)
-    // Mempool contains InputBufCtrlStructures (ptrs to buffer headers and PMVFMediaData ptrs - to keep track of when to unbind input msgs)
-
-    // NOTE:	in this case, when providing input buffers to OMX component,
-    //			OMX_UseBuffer calls will provide some initial pointers and sizes of buffers, but these
-    //			are dummy values. Actual buffer pointers and filled sizes will be obtained from the input msg fragments.
-    //			The PV OMX component will use the buffers even if the ptrs differ from the ones during initialization
-    //			3rd party OMX components can also use this case if they are capable of ignoring the actual buffer pointers in
-    //			buffer header field (i.e. if after OMX_UseBuffer(...) call, they allow the ptr to actual buffer data to change at a later time
-
-    // CASE 2 (buffers allocated in the node - memcpy needed)
-    //			If 3rd party OMX component can use buffers allocated outside the OMX component, but it cannot
-    //			change buffer ptr allocations dynamically (i.e. after initialization with OMX_UseBuffer call is complete)
-
-    //		Mempool contains InputBufCtrlStructures (ptrs to buffer headers, PVMFMediaData ptrs to keep track of when to unbind input msgs) +
-    //				actual buffers.
-    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component
-
-    // CASE 3 (buffers allocated in the component - memcpy needed)
-    //			If 3rd party OMX component must allocate its own buffers
-    //			Mempool only contains InputBufCtrlStruct (ptrs to buffer headers + PMVFMediaData ptrs to keep track of when to unbind input msgs)
-    //			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component (like in case 2)
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::CreateInputMemPool() start "));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::CreateInputMemPool() allocating buffer header pointers and shared media data ptrs "));
-
-
-
-    iInputAllocSize = oscl_mem_aligned_size((uint32) sizeof(InputBufCtrlStruct)); //aligned_size_buffer_header_ptr+aligned_size_media_data_ptr;
-
-    // Need to allocate buffers in the node either if component supports external buffers buffers
-    // but they are not movable
-
-    if ((iOMXComponentSupportsExternalInputBufferAlloc && !iOMXComponentSupportsMovableInputBuffers))
-    {
-        //pre-negotiated input buffer size
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::CreateOutMemPool() Allocating input buffers of size %d as well", iOMXComponentInputBufferSize));
-
-        iInputAllocSize += iOMXComponentInputBufferSize;
-    }
-
-    if (iInBufMemoryPool)
-    {
-        iInBufMemoryPool->removeRef();
-        iInBufMemoryPool = NULL;
-    }
-
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iInBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
-    if (leavecode || iInBufMemoryPool == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::CreateInputMemPool() Memory pool structure for input buffers failed to allocate"));
-        return false;
-    }
-    // try to allocate a dummy buffer to actually create the mempool and allocate the needed memory
-    // allocate a dummy buffer to actually create the mempool, this dummy buffer will be released at end of scope of this method
-    OsclAny *dummy_alloc = NULL;
-    leavecode = 0;
-    OSCL_TRY(leavecode, dummy_alloc = iInBufMemoryPool->allocate(iInputAllocSize));
-    if (leavecode || dummy_alloc == NULL)
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-                        PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::CreateInputMemPool() Memory pool for input buffers failed to allocate"));
-        return false;
-    }
-
-    // init the counter
-    iNumOutstandingInputBuffers = 0;
-
-
-    iInputBufferToResendToComponent = NULL; // nothing to resend yet
-    iInBufMemoryPool->deallocate(dummy_alloc);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::CreateInputMemPool() done"));
-    return true;
-}
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-        uint32 aNumBuffers,    // number of buffers
-        uint32 aActualBufferSize, // aactual buffer size
-        uint32 aPortIndex,      // port idx
-        bool aUseBufferOK,		// can component use OMX_UseBuffer or should it use OMX_AllocateBuffer
-        bool	aIsThisInputBuffer		// is this input or output
-                                                   )
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ProvideBuffersToComponent() enter"));
-
-    uint32 ii = 0;
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
-
-    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
-    if (ctrl_struct_ptr == NULL)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::ProvideBuffersToComponent ctrl_struct_ptr == NULL"));
-        return false;
-    }
-
-
-    // Now, go through all buffers and tell component to
-    // either use a buffer, or to allocate its own buffer
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-
-        int32 errcode = 0;
-        // get the address where the buf hdr ptr will be stored
-        OSCL_TRY(errcode, ctrl_struct_ptr[ii] = (OsclAny *) aMemPool->allocate(aAllocSize));
-        if ((errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL))
-        {
-            if (errcode == OsclErrNoResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::ProvideBuffersToComponent ->allocate() failed for no mempool chunk available"));
-            }
-            else
-            {
-                // General error
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::ProvideBuffersToComponent ->allocate() failed due to some general error"));
-
-                ReportErrorEvent(PVMFFailure);
-                ChangeNodeState(EPVMFNodeError);
-            }
-
-            return false;
-        }
-
-        if (aUseBufferOK)
-        {
-            // Buffers are already allocated outside OMX component.
-            // In case of output buffers, the buffer itself is located
-            // just after the buffer header pointer.
-
-            // In case of input buffers, the buffer header pointer is followed by a MediaDataSharedPtr
-            //	which is used to ensure proper unbinding of the input messages. The buffer itself is either:
-            //		a) allocated upstream (and the ptr to the buffer
-            //			is a dummy pointer to which the component does not pay attention - PV OMX component)
-            //		b) located just after the buffer header pointer and MediaDataSharedPtr
-
-            uint8 *pB = ((uint8*) ctrl_struct_ptr[ii]);
-
-
-            // in case of input buffers, initialize also MediaDataSharedPtr structure
-            if (aIsThisInputBuffer)
-            {
-
-                InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
-                oscl_memset(&(temp->pMediaData), 0, sizeof(PVMFSharedMediaDataPtr));
-                temp->pMediaData = PVMFSharedMediaDataPtr(NULL, NULL);
-
-                // advance ptr to skip the structure
-                pB += oscl_mem_aligned_size(sizeof(InputBufCtrlStruct));
-
-                err = OMX_UseBuffer(iOMXVideoDecoder,	// hComponent
-                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
-                                    aPortIndex,				// port index (for port for which buffer is provided)
-                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
-                                    //				to have a context when component returns with a callback (i.e. to know
-                                    //				what to free etc.
-                                    (OMX_U32)aActualBufferSize,		// buffer size
-                                    pB);						// buffer data ptr
-
-            }
-            else
-            {
-                OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
-                // advance buffer ptr to skip the structure
-                pB += oscl_mem_aligned_size(sizeof(OutputBufCtrlStruct));
-
-
-                err = OMX_UseBuffer(iOMXVideoDecoder,	// hComponent
-                                    &(temp->pBufHdr),		// address where ptr to buffer header will be stored
-                                    aPortIndex,				// port index (for port for which buffer is provided)
-                                    ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
-                                    //				to have a context when component returns with a callback (i.e. to know
-                                    //				what to free etc.
-                                    (OMX_U32)aActualBufferSize,		// buffer size
-                                    pB);						// buffer data ptr
-
-
-            }
-
-
-        }
-        else
-        {
-            // the component must allocate its own buffers.
-            if (aIsThisInputBuffer)
-            {
-
-                InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
-                // make sure ptrs are initialized to NULL
-                oscl_memset(&(temp->pMediaData), 0, sizeof(PVMFSharedMediaDataPtr));
-                temp->pMediaData = PVMFSharedMediaDataPtr(NULL, NULL);
-
-                err = OMX_AllocateBuffer(iOMXVideoDecoder,
-                                         &(temp->pBufHdr),
-                                         aPortIndex,
-                                         ctrl_struct_ptr[ii],
-                                         (OMX_U32)aActualBufferSize);
-            }
-            else
-            {
-                OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
-                err = OMX_AllocateBuffer(iOMXVideoDecoder,
-                                         &(temp->pBufHdr),
-                                         aPortIndex,
-                                         ctrl_struct_ptr[ii],
-                                         (OMX_U32)aActualBufferSize);
-            }
-
-        }
-
-        if (err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::ProvideBuffersToComponent() Problem using/allocating a buffer"));
-
-
-            return false;
-        }
-
-    }
-
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-        // after initializing the buffer hdr ptrs, return them
-        // to the mempool
-        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
-    }
-
-    oscl_free(ctrl_struct_ptr);
-    // set the flags
-    if (aIsThisInputBuffer)
-    {
-        iInputBuffersFreed = false;
-    }
-    else
-    {
-        iOutputBuffersFreed = false;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ProvideBuffersToComponent() done"));
-    return true;
-}
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-        uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-        uint32 aNumBuffers,    // number of buffers
-        uint32 aPortIndex,      // port idx
-        bool	aIsThisInputBuffer		// is this input or output
-                                                  )
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::FreeBuffersToComponent() enter"));
-
-    uint32 ii = 0;
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
-
-    ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
-    if (ctrl_struct_ptr == NULL)
-    {
-        return false;
-    }
-
-
-    // Now, go through all buffers and tell component to free them
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-
-        int32 errcode = 0;
-        // get the address where the buf hdr ptr will be stored
-
-        OSCL_TRY(errcode, ctrl_struct_ptr[ii] = (OsclAny *) aMemPool->allocate(aAllocSize));
-        if ((errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL))
-        {
-            if (errcode == OsclErrNoResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::FreeBuffersFromComponent ->allocate() failed for no mempool chunk available"));
-            }
-            else
-            {
-                // General error
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::FreeBuffersFromComponent ->allocate() failed due to some general error"));
-
-                ReportErrorEvent(PVMFFailure);
-                ChangeNodeState(EPVMFNodeError);
-            }
-
-            return false;
-        }
-        // to maintain correct count
-        aMemPool->notifyfreechunkavailable((*this), (OsclAny*) aMemPool);
-
-        if (aIsThisInputBuffer)
-        {
-
-            iNumOutstandingInputBuffers++;
-            // get the buf hdr pointer
-            InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
-            err = OMX_FreeBuffer(iOMXVideoDecoder,
-                                 aPortIndex,
-                                 temp->pBufHdr);
-
-        }
-        else
-        {
-            iNumOutstandingOutputBuffers++;
-            OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
-            err = OMX_FreeBuffer(iOMXVideoDecoder,
-                                 aPortIndex,
-                                 temp->pBufHdr);
-
-        }
-
-        if (err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::FreeBuffersFromComponent() Problem freeing a buffer"));
-
-            return false;
-        }
-
-    }
-
-    for (ii = 0; ii < aNumBuffers; ii++)
-    {
-        // after freeing the buffer hdr ptrs, return them
-        // to the mempool (which will itself then be deleted promptly)
-        aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
-    }
-
-    oscl_free(ctrl_struct_ptr);
-
-    // mark buffers as freed (so as not to do it twice)
-    if (aIsThisInputBuffer)
-    {
-        iInputBuffersFreed = true;
-    }
-    else
-    {
-        iOutputBuffersFreed = true;
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::FreeBuffersFromComponent() done"));
-    return true;
-}
-
-
-
 /////////////////////////////////////////////////////////////////////////////
 ////////////////////// CALLBACK PROCESSING FOR EVENT HANDLER
 /////////////////////////////////////////////////////////////////////////////
@@ -3541,21 +879,25 @@
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                     (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_CommandFlush - completed on port %d", aData2));
 
-                    if (aData2 == iOutputPortIndex)
+                    if (iIsRepositioningRequestSentToComponent)
                     {
-                        iIsOutputPortFlushed = true;
-                    }
-                    else if (aData2 == iInputPortIndex)
-                    {
-                        iIsInputPortFlushed = true;
+                        if (aData2 == iOutputPortIndex)
+                        {
+                            iIsOutputPortFlushed = true;
+                        }
+                        else if (aData2 == iInputPortIndex)
+                        {
+                            iIsInputPortFlushed = true;
+                        }
+
+                        if (iIsOutputPortFlushed && iIsInputPortFlushed)
+                        {
+                            iIsRepositionDoneReceivedFromComponent = true;
+                        }
                     }
 
-                    if (iIsOutputPortFlushed && iIsInputPortFlushed)
-                    {
-                        iIsRepositionDoneReceivedFromComponent = true;
-                    }
-                    RunIfNotReady();
-
+                    if (IsAdded())
+                        RunIfNotReady();
 
                 }
                 break;
@@ -3564,7 +906,7 @@
                 {
                     // if port disable command is done, we can re-allocate the buffers and re-enable the port
 
-                    iProcessingState = EPVMFOMXVideoDecNodeProcessingState_PortReEnable;
+                    iProcessingState = EPVMFOMXBaseDecNodeProcessingState_PortReEnable;
                     iPortIndexForDynamicReconfig =  aData2;
 
                     RunIfNotReady();
@@ -3580,7 +922,7 @@
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                         (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, dynamic reconfiguration needed on port %d", aData2, iSecondPortToReconfig));
 
-                        iProcessingState = EPVMFOMXVideoDecNodeProcessingState_PortReconfig;
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_PortReconfig;
                         iPortIndexForDynamicReconfig = iSecondPortToReconfig;
                         iSecondPortReportedChange = false;
                     }
@@ -3588,20 +930,19 @@
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                         (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, resuming normal data flow", aData2));
-                        iProcessingState = EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode;
+                        iProcessingState = EPVMFOMXBaseDecNodeProcessingState_ReadyToDecode;
                         iDynamicReconfigInProgress = false;
                         // in case pause or stop command was sent to component
                         // change processing state (because the node might otherwise
                         // start sending buffers to component before pause/stop is processed)
                         if (iPauseCommandWasSentToComponent)
                         {
-                            iProcessingState = EPVMFOMXVideoDecNodeProcessingState_Pausing;
+                            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Pausing;
                         }
                         if (iStopCommandWasSentToComponent)
                         {
-                            iProcessingState = EPVMFOMXVideoDecNodeProcessingState_Stopping;
+                            iProcessingState = EPVMFOMXBaseDecNodeProcessingState_Stopping;
                         }
-
                     }
                     RunIfNotReady();
                     break;
@@ -3628,7 +969,7 @@
         case OMX_EventError:
         {
 
-            if (aData1 == OMX_ErrorStreamCorrupt)
+            if (aData1 == (OMX_U32) OMX_ErrorStreamCorrupt)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_EventError - Bitstream corrupt error"));
@@ -3636,13 +977,6 @@
                 ReportInfoEvent(PVMFInfoProcessingFailure, NULL);
 
             }
-            else if (aData1 == OMX_ErrorInsufficientResources)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_EventError - Insufficient Resources"));
-                ReportErrorEvent(PVMFErrNoResources);
-                SetState(EPVMFNodeError);
-            }
             else
             {
 
@@ -3658,6 +992,9 @@
 
         case OMX_EventBufferFlag:
         {
+            // the component is reporting it encountered end of stream flag
+            // we'll send eos when we get the actual last buffer with marked eos
+
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_EventBufferFlag (EOS) flag returned from OMX component"));
 
@@ -3696,7 +1033,7 @@
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                                 (0, "PVMFOMXVideoDecNode::EventHandlerProcessing: OMX_EventPortSettingsChanged returned for port %d", aData1));
 
-                iProcessingState = EPVMFOMXVideoDecNodeProcessingState_PortReconfig;
+                iProcessingState = EPVMFOMXBaseDecNodeProcessingState_PortReconfig;
                 iPortIndexForDynamicReconfig = aData1;
                 iDynamicReconfigInProgress = true;
             }
@@ -3733,333 +1070,6 @@
 
 
 
-/////////////////////////////////////////////////////////////////////////////
-// This function handles the event of OMX component state change
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::HandleComponentStateChange(OMX_U32 decoder_state)
-{
-    switch (decoder_state)
-    {
-        case OMX_StateIdle:
-        {
-            iCurrentDecoderState = OMX_StateIdle;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleComponentStateChange: OMX_StateIdle reached"));
-
-            //  this state can be reached either going from OMX_Loaded->OMX_Idle (preparing)
-            //	or going from OMX_Executing->OMX_Idle (stopping)
-
-
-            if ((iCurrentCommand.size() > 0) &&
-                    (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_PREPARE))
-            {
-                iProcessingState = EPVMFOMXVideoDecNodeProcessingState_InitDecoder;
-                SetState(EPVMFNodePrepared);
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-                RunIfNotReady();
-            }
-            else if ((iCurrentCommand.size() > 0) &&
-                     (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_STOP))
-            {
-                // if we are stopped, we won't start until the node gets DoStart command.
-                //	in this case, we are ready to start sending buffers
-                if (iProcessingState == EPVMFOMXVideoDecNodeProcessingState_Stopping)
-                    iProcessingState = EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode;
-                // if the processing state was not stopping, leave the state as it was (continue port reconfiguration)
-                SetState(EPVMFNodePrepared);
-                iStopCommandWasSentToComponent = false;
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-
-                RunIfNotReady();
-            }
-            else if ((iCurrentCommand.size() > 0) &&
-                     (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET))
-            {
-                // State change to Idle was initiated due to Reset. First need to reach idle, and then loaded
-                // Once Idle is reached, we need to initiate idle->loaded transition
-                RunIfNotReady();
-            }
-            break;
-        }//end of case OMX_StateIdle
-
-        case OMX_StateExecuting:
-        {
-            iCurrentDecoderState = OMX_StateExecuting;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleComponentStateChange: OMX_StateExecuting reached"));
-
-            // this state can be reached going from OMX_Idle -> OMX_Executing (preparing)
-            //	or going from OMX_Pause -> OMX_Executing (coming from pause)
-            //	either way, this is a response to "DoStart" command
-
-            if ((iCurrentCommand.size() > 0) &&
-                    (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_START))
-            {
-                SetState(EPVMFNodeStarted);
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-
-                RunIfNotReady();
-            }
-
-            break;
-        }//end of case OMX_StateExecuting
-
-        case OMX_StatePause:
-        {
-            iCurrentDecoderState = OMX_StatePause;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleComponentStateChange: OMX_StatePause reached"));
-
-
-            //	This state can be reached going from OMX_Executing-> OMX_Pause
-            if ((iCurrentCommand.size() > 0) &&
-                    (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_PAUSE))
-            {
-                // if we are paused, we won't start until the node gets DoStart command.
-                //	in this case, we are ready to start sending buffers
-                if (iProcessingState == EPVMFOMXVideoDecNodeProcessingState_Pausing)
-                    iProcessingState = EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode;
-                // if the processing state was not pausing, leave the state as it was (continue port reconfiguration)
-
-
-                SetState(EPVMFNodePaused);
-                iPauseCommandWasSentToComponent = false;
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-                RunIfNotReady();
-            }
-
-            break;
-        }//end of case OMX_StatePause
-
-        case OMX_StateLoaded:
-        {
-            iCurrentDecoderState = OMX_StateLoaded;
-
-            //  this state can be reached only going from OMX_Idle ->OMX_Loaded (stopped to reset)
-            //
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleComponentStateChange: OMX_StateLoaded reached"));
-            //Check if command's responce is pending
-            if ((iCurrentCommand.size() > 0) &&
-                    (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET))
-            {
-
-                // move this here
-                if (iInPort)
-                {
-                    OSCL_DELETE(((PVMFOMXVideoDecPort*)iInPort));
-                    iInPort = NULL;
-                }
-
-                if (iOutPort)
-                {
-                    OSCL_DELETE(((PVMFOMXVideoDecPort*)iOutPort));
-                    iOutPort = NULL;
-                }
-
-                iDataIn.Unbind();
-
-                // Reset the metadata key list
-                iAvailableMetadataKeys.clear();
-
-
-                iProcessingState = EPVMFOMXVideoDecNodeProcessingState_Idle;
-                //logoff & go back to Created state.
-                SetState(EPVMFNodeIdle);
-                PVMFStatus status = ThreadLogoff();
-                CommandComplete(iCurrentCommand, iCurrentCommand.front(), status);
-                iResetInProgress = false;
-                iResetMsgSent = false;
-                //DeleteOMXVideoDecoder();
-            }
-
-            break;
-        }//end of case OMX_StateLoaded
-
-        case OMX_StateInvalid:
-        default:
-        {
-            iCurrentDecoderState = OMX_StateInvalid;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::HandleComponentStateChange: OMX_StateInvalid reached"));
-
-            break;
-        }//end of case OMX_StateInvalid
-
-    }//end of switch(decoder_state)
-
-}
-
-
-
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR EMPTY BUFFER DONE - input buffer was consumed
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXVideoDecNode::EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::EmptyBufferDoneProcessing: In"));
-
-    OSCL_ASSERT((void*) aComponent == (void*) iOMXVideoDecoder); // component should match the component
-    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
-
-    // first, get the buffer "context", i.e. pointer to application private data that contains the
-    // address of the mempool buffer (so that it can be released)
-    InputBufCtrlStruct *pContext = (InputBufCtrlStruct *)(aBuffer->pAppPrivate);
-
-
-
-    // if a buffer is not empty, log a msg, but release anyway
-    if ((aBuffer->nFilledLen > 0) && (iDoNotSaveInputBuffersFlag == false))
-        // if dynamic port reconfig is in progress for input port, don't keep the buffer
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::EmptyBufferDoneProcessing: Input buffer returned non-empty with %d bytes still in it", aBuffer->nFilledLen));
-
-
-    }
-
-    iInputBufferToResendToComponent = NULL;
-
-
-    // input buffer is to be released,
-    // refcount needs to be decremented (possibly - the input msg associated with the buffer will be unbound)
-    // NOTE: in case of "moveable" input buffers (passed into component without copying), unbinding decrements a refcount which eventually results
-    //			in input message being released back to upstream mempool once all its fragments are returned
-    //		in case of input buffers passed into component by copying, unbinding has no effect
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::EmptyBufferDoneProcessing: Release input buffer (with %d refcount remaining of input message)", (pContext->pMediaData).get_count() - 1));
-
-
-    (pContext->pMediaData).Unbind();
-
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::EmptyBufferDoneProcessing: Release input buffer %x back to mempool", pContext));
-
-    iInBufMemoryPool->deallocate((OsclAny *) pContext);
-
-
-    // the OMX spec says that no error is to be returned
-    return OMX_ErrorNone;
-
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR FILL BUFFER DONE - output buffer is ready
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXVideoDecNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: In"));
-
-    OSCL_ASSERT((void*) aComponent == (void*) iOMXVideoDecoder); // component should match the component
-    OSCL_ASSERT(aAppData == (OMX_PTR)(this));		// AppData should represent this node ptr
-
-    // first, get the buffer "context", i.e. pointer to application private data that contains the
-    // address of the mempool buffer (so that it can be released)
-    OsclAny *pContext = (OsclAny*) aBuffer->pAppPrivate;
-
-
-    // check for EOS flag
-    if ((aBuffer->nFlags & OMX_BUFFERFLAG_EOS))
-    {
-        // EOS received
-        iIsEOSReceivedFromComponent = true;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Output buffer has EOS set"));
-
-    }
-
-    // if a buffer is empty, or if it should not be sent downstream (say, due to state change)
-    // release the buffer back to the pool
-    if ((aBuffer->nFilledLen == 0) || (iDoNotSendOutputBuffersDownstreamFlag == true))
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Release output buffer %x back to mempool - buffer empty or not to be sent downstream", pContext));
-
-        iOutBufMemoryPool->deallocate(pContext);
-
-    }
-    else
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Output frame %d received", iFrameCounter++));
-
-        // get pointer to actual buffer data
-        uint8 *pBufdata = ((uint8*) aBuffer->pBuffer);
-        // move the data pointer based on offset info
-        pBufdata += aBuffer->nOffset;
-
-        iOutTimeStamp = aBuffer->nTimeStamp;
-        //ipPrivateData =  aBuffer->pPlatformPrivate; // record the pointer
-        oscl_memcpy(&ipPrivateData, &(aBuffer->pPlatformPrivate), sizeof(ipPrivateData));
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Wrapping buffer %x of size %d", pBufdata, aBuffer->nFilledLen));
-        // wrap the buffer into the MediaDataImpl wrapper, and queue it for sending downstream
-        // wrapping will create a refcounter. When refcounter goes to 0 i.e. when media data
-        // is released in downstream components, the custom deallocator will automatically release the buffer back to the
-        //	mempool. To do that, the deallocator needs to have info about Context
-        // NOTE: we had to wait until now to wrap the buffer data because we only know
-        //			now where the actual data is located (based on buffer offset)
-        OsclSharedPtr<PVMFMediaDataImpl> MediaDataOut = WrapOutputBuffer(pBufdata, (uint32)(aBuffer->nFilledLen), pContext);
-
-        // if you can't get the MediaDataOut, release the buffer back to the pool
-        if (MediaDataOut.GetRep() == NULL)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Problem wrapping buffer %x of size %d - releasing the buffer", pBufdata, aBuffer->nFilledLen));
-
-            iOutBufMemoryPool->deallocate(pContext);
-        }
-        else
-        {
-
-            // if there's a problem queuing output buffer, MediaDataOut will expire at end of scope and
-            // release buffer back to the pool, (this should not be the case)
-            if (QueueOutputBuffer(MediaDataOut, aBuffer->nFilledLen))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Buffer %x of size %d queued - reschedule the node to send out", pBufdata, aBuffer->nFilledLen));
-
-                // if queing went OK,
-                // re-schedule the node so that outgoing queue can be emptied (unless the outgoing port is busy)
-                if ((iOutPort) && !(iOutPort->IsConnectedPortBusy()))
-                    RunIfNotReady();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::FillBufferDoneProcessing: Problem queing buffer %x of size %d - releasing the buffer", pBufdata, aBuffer->nFilledLen));
-            }
-
-
-        }
-
-    }
-    // the OMX spec says that no error is to be returned
-    return OMX_ErrorNone;
-
-}
 ////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////// Put output buffer in outgoing queue //////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -4068,7 +1078,7 @@
 
     bool status = true;
     PVMFSharedMediaDataPtr mediaDataOut;
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
 
     // NOTE: ASSUMPTION IS THAT OUTGOING QUEUE IS BIG ENOUGH TO QUEUE ALL THE OUTPUT BUFFERS
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
@@ -4084,7 +1094,7 @@
 
     OSCL_TRY(leavecode,
              mediaDataOut = PVMFMediaData::createMediaData(mediadataimplout, iMediaDataMemPool););
-    if (leavecode == 0)
+    if (OsclErrNone == leavecode)
     {
 
         // Update the filled length of the fragment
@@ -4106,7 +1116,7 @@
                             (0, "PVMFOMXVideoDecNode::QueueOutputFrame - Sending YUV FSI"));
 
             // set a flag to send Fsi configuration
-            sendYuvFsi = true;
+            sendFsi = true;
             //store new values for reference
             iLastYUVWidth = iYUVWidth ;
             iLastYUVHeight = iYUVHeight;
@@ -4115,61 +1125,73 @@
         int fsiErrorCode = 0;
 
         // Check if Fsi configuration need to be sent
-        if (sendYuvFsi)
+        if (sendFsi)
         {
             OsclRefCounterMemFrag yuvFsiMemfrag;
 
-            OSCL_TRY(fsiErrorCode, yuvFsiMemfrag = iYuvFsiFragmentAlloc.get(););
+            OSCL_TRY(fsiErrorCode, yuvFsiMemfrag = iFsiFragmentAlloc.get(););
 
             OSCL_FIRST_CATCH_ANY(fsiErrorCode, PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                                  (0, "PVMFOMXVideoDecNode::RemoveOutputFrame() Failed to allocate memory for  FSI")));
 
             if (fsiErrorCode == 0)
             {
-                PVMFYuvFormatSpecificInfo0* fsiInfo = (PVMFYuvFormatSpecificInfo0*)yuvFsiMemfrag.getMemFragPtr();
-
-                fsiInfo->uid = PVMFYuvFormatSpecificInfo0_UID;
-                fsiInfo->video_format = iYUVFormat;
-                fsiInfo->display_width = iYUVWidth;
-                fsiInfo->display_height = iYUVHeight;
-                switch (((PVMFOMXVideoDecPort*)iInPort)->iFormat)
+                PVMFYuvFormatSpecificInfo0* fsiInfo = OSCL_PLACEMENT_NEW(yuvFsiMemfrag.getMemFragPtr(), PVMFYuvFormatSpecificInfo0());
+                if (fsiInfo != NULL)
                 {
-                    case PVMF_H264:
-                    case PVMF_H264_MP4:
-                    case PVMF_H264_RAW:
-                    case PVMF_M4V:
-                    case PVMF_H263:
+                    fsiInfo->uid = PVMFYuvFormatSpecificInfo0_UID;
+                    fsiInfo->video_format = iYUVFormat;
+                    fsiInfo->display_width = iYUVWidth;
+                    fsiInfo->display_height = iYUVHeight;
+
+                    if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO ||
+                            ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+                            ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW ||
+                            ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_M4V ||
+                            ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2631998 ||
+                            ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
+                    {
                         fsiInfo->width = (iYUVWidth + 15) & (~15);
                         fsiInfo->height = (iYUVHeight + 15) & (~15);
-                        break;
-                    case PVMF_WMV:
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV)
+                    {
                         fsiInfo->width = (iYUVWidth + 3) & -4;
                         fsiInfo->height = iYUVHeight;
-                        break;
-                    default:
+                    }
+                    else
+                    {
                         fsiInfo->width = iYUVWidth;
                         fsiInfo->height = iYUVHeight;
-                        break;
-                }
+                    }
 
-                //mediaDataOut->setFormatSpecificInfo(yuvFsiMemfrag);
-                ((PVMFOMXVideoDecPort*)iOutPort)->pvmiSetPortFormatSpecificInfoSync(yuvFsiMemfrag);
+                    //mediaDataOut->setFormatSpecificInfo(yuvFsiMemfrag);
+                    ((PVMFOMXDecPort*)iOutPort)->pvmiSetPortFormatSpecificInfoSync(yuvFsiMemfrag);
+                    fsiInfo->video_format.~PVMFFormatType();
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                    (0, "PVMFOMXVideoDecNode::QueueOutputFrame - Problem allocating Output FSI"));
+                    SetState(EPVMFNodeError);
+                    ReportErrorEvent(PVMFErrNoMemory);
+                    return false; // this is going to make everything go out of scope
+                }
             }
             else
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                                 (0, "PVMFOMXVideoDecNode::QueueOutputFrame - Problem allocating Output FSI"));
-                SetState(EPVMFNodeError);
-                ReportErrorEvent(PVMFErrNoMemory);
                 return false; // this is going to make everything go out of scope
             }
 
+
             // Reset the flag
-            sendYuvFsi = false;
+            sendFsi = false;
         }
 
-// in case of special YVU format, attach fsi to every outgoing message containing ptr to private data
-        if (iYUVFormat == PVMF_YUV420_SEMIPLANAR_YVU)
+        // in case of special YVU format, attach fsi to every outgoing message containing ptr to private data
+        if (iYUVFormat == PVMF_MIME_YUV420_SEMIPLANAR_YVU)
         {
             OsclRefCounterMemFrag privatedataFsiMemFrag;
 
@@ -4182,8 +1204,8 @@
             if (fsiErrorCode == 0)
             {
                 uint8 *fsiptr = (uint8*) privatedataFsiMemFrag.getMemFragPtr();
-                privatedataFsiMemFrag.getMemFrag().len = sizeof(ipPrivateData);
-                oscl_memcpy(fsiptr, &ipPrivateData, sizeof(ipPrivateData)); // store ptr data into fsi
+                privatedataFsiMemFrag.getMemFrag().len = sizeof(OsclAny*);
+                oscl_memcpy(fsiptr, &ipPrivateData, sizeof(OsclAny *)); // store ptr data into fsi
                 mediaDataOut->setFormatSpecificInfo(privatedataFsiMemFrag);
             }
             else
@@ -4204,13 +1226,13 @@
 
             if (iOutPort && (iOutPort->QueueOutgoingMsg(mediaMsgOut) == PVMFSuccess))
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO,
                                 (0, "PVMFOMXVideoDecNode::QueueOutputFrame(): Queued frame OK "));
 
             }
             else
             {
-                // we should not get here because we always check for whether queue is busy or not MC
+                // we should not get here because we always check for whether queue is busy or not
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
                                 (0, "PVMFOMXVideoDecNode::QueueOutputFrame(): Send frame failed"));
                 return false;
@@ -4231,1095 +1253,8 @@
 
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////// Attach a MediaDataImpl wrapper (refcount, deallocator etc.)
-/////////////////////////////// to the output buffer /////////////////////////////////////////
-OsclSharedPtr<PVMFMediaDataImpl> PVMFOMXVideoDecNode::WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext)
-{
-    // wrap output buffer into a mediadataimpl
-    uint32 aligned_class_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
-    uint32 aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PVOMXBufferSharedPtrWrapperCombinedCleanupDA));
-    uint32 aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-    uint8 *my_ptr = (uint8*) oscl_malloc(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
-
-    if (my_ptr == NULL)
-    {
-        OsclSharedPtr<PVMFMediaDataImpl> null_buff(NULL, NULL);
-        return null_buff;
-    }
-    // create a deallocator and pass the buffer_allocator to it as well as pointer to data that needs to be returned to the mempool
-    PVOMXBufferSharedPtrWrapperCombinedCleanupDA *cleanup_ptr =
-        OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVOMXBufferSharedPtrWrapperCombinedCleanupDA(iOutBufMemoryPool, pContext));
-
-    // create the ref counter after the cleanup object (refcount is set to 1 at creation)
-    OsclRefCounterDA *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
-
-    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
-
-    PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer((void *) pData, // ptr to data
-                                        aDataLen, // capacity
-                                        my_refcnt));   // ref counter
-
-    OsclSharedPtr<PVMFMediaDataImpl> MediaDataImplOut(media_data_ptr, my_refcnt);
-
-    MediaDataImplOut->setMediaFragFilledLen(0, aDataLen);
-
-    return MediaDataImplOut;
-
-}
-//////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::SendBeginOfMediaStreamCommand()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendBeginOfMediaStreamCommand() In"));
-
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-    // Set the formatID, timestamp, sequenceNumber and streamID for the media message
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
-    sharedMediaCmdPtr->setTimestamp(iBOSTimestamp);
-    //reset the sequence number
-    uint32 seqNum = 0;
-    sharedMediaCmdPtr->setSeqNum(seqNum);
-    sharedMediaCmdPtr->setStreamID(iStreamID);
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::SendBeginOfMediaStreamCommand() Outgoing queue busy"));
-        return false;
-    }
-
-    iSendBOS = false;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendBeginOfMediaStreamCommand() BOS Sent StreamID %d", iStreamID));
-    return true;
-}
-////////////////////////////////////
-bool PVMFOMXVideoDecNode::SendEndOfTrackCommand(void)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendEndOfTrackCommand() In"));
-
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    sharedMediaCmdPtr->setTimestamp(iEndOfDataTimestamp);
-
-    // Set Streamid
-    sharedMediaCmdPtr->setStreamID(iStreamID);
-
-    // Set the sequence number
-    sharedMediaCmdPtr->setSeqNum(iSeqNum++);
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-    if (iOutPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess)
-    {
-        // this should not happen because we check for queue busy before calling this function
-        return false;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::SendEndOfTrackCommand() Out"));
-    return true;
-}
-
 /////////////////////////////////////////////////////////////////////////////
-//The various command handlers call this routine when a command is complete.
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::CommandComplete(PVMFOMXVideoDecNodeCmdQ& aCmdQ, PVMFOMXVideoDecNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    //create response
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
-    PVMFSessionId session = aCmd.iSession;
-
-    //Erase the command from the queue.
-    aCmdQ.Erase(&aCmd);
-
-    //Report completion to the session observer.
-    ReportCmdCompleteEvent(session, resp);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoInit(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DoInit() In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-        {
-            SetState(EPVMFNodeInitialized);
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            break;
-        }
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoPrepare(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OMX_STRING Role = NULL;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-        {
-            if (NULL == iInPort)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFFailure);
-            }
-
-            // Check format of input data
-
-            uint32 Format = ((PVMFOMXVideoDecPort*)iInPort)->iFormat;
-            switch (Format)
-            {
-                case PVMF_H264:
-                case PVMF_H264_MP4:
-                case PVMF_H264_RAW:
-                    Role = "video_decoder.avc";
-                    break;
-                case PVMF_M4V:
-                    Role = "video_decoder.mpeg4";
-                    break;
-                case PVMF_H263:
-                    Role = "video_decoder.h263";
-                    break;
-                case PVMF_WMV:
-                    Role = "video_decoder.wmv";
-                    break;
-
-                default:
-                    // Illegal codec specified.
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::DoPrepare() Input port format other then codec type"));
-                    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
-                    return;
-            }
-
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::Initializing OMX component and decoder for role %s", Role));
-
-            /* Set callback structure */
-            iCallbacks.EventHandler    = CallbackEventHandler; //event_handler;
-            iCallbacks.EmptyBufferDone = CallbackEmptyBufferDone; //empty_buffer_done;
-            iCallbacks.FillBufferDone  = CallbackFillBufferDone; //fill_buffer_done;
-
-
-            // determine components which can fit the role
-            // then, create the component. If multiple components fit the role,
-            // the first one registered will be selected. If that one fails to
-            // be created, the second one in the list is selected etc.
-            OMX_U32 num_comps = 0;
-            OMX_STRING *CompOfRole;
-            // call once to find out the number of components that can fit the role
-            //PV_Master
-            PV_MasterOMX_GetComponentsOfRole(Role, &num_comps, NULL);
-            uint32 ii;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::DoPrepare(): There are %d components of role %s ", num_comps, Role));
-
-            if (num_comps > 0)
-            {
-                CompOfRole = (OMX_STRING *)oscl_malloc(num_comps * sizeof(OMX_STRING));
-
-                for (ii = 0; ii < num_comps; ii++)
-                    CompOfRole[ii] = (OMX_STRING) oscl_malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
-
-                // call 2nd time to get the component names
-                //PV_Master
-                PV_MasterOMX_GetComponentsOfRole(Role, &num_comps, (OMX_U8 **)CompOfRole);
-
-                for (ii = 0; ii < num_comps; ii++)
-                {
-                    // try to create component
-                    err = PV_MasterOMX_GetHandle(&iOMXVideoDecoder, (OMX_STRING) CompOfRole[ii], (OMX_PTR) this, (OMX_CALLBACKTYPE *) & iCallbacks);
-
-                    // if successful, no need to continue
-                    if ((err == OMX_ErrorNone) && (iOMXVideoDecoder != NULL))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMFOMXVideoDecNode::DoPrepare(): Got Component %s handle ", CompOfRole[ii]));
-
-                        break;
-                    }
-                    else
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMFOMXVideoDecNode::DoPrepare(): Cannot get component %s handle, try another component if available", CompOfRole[ii]));
-                    }
-
-                }
-                // whether successful or not, need to free CompOfRoles
-                for (ii = 0; ii < num_comps; ii++)
-                {
-                    oscl_free(CompOfRole[ii]);
-                    CompOfRole[ii] = NULL;
-                }
-
-                oscl_free(CompOfRole);
-                // check if there was a problem
-                if ((err != OMX_ErrorNone) || (iOMXVideoDecoder == NULL))
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::Can't get handle for decoder!"));
-                    iOMXVideoDecoder = NULL;
-                    CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                    return;
-                }
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::No component can handle role %s !", Role));
-                iOMXVideoDecoder = NULL;
-                CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                return;
-            }
-
-
-
-            if (!iOMXVideoDecoder)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            // GET CAPABILITY FLAGS FROM PV COMPONENT, IF this fails, use defaults
-            PV_OMXComponentCapabilityFlagsType Cap_flags;
-            err = OMX_GetParameter(iOMXVideoDecoder, (OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX, &Cap_flags);
-            if (err != OMX_ErrorNone)
-            {
-                SetDefaultCapabilityFlags();
-            }
-            else
-            {
-                iIsOMXComponentMultiThreaded =					 Cap_flags.iIsOMXComponentMultiThreaded;
-                iOMXComponentSupportsExternalInputBufferAlloc =	 Cap_flags.iOMXComponentSupportsExternalInputBufferAlloc;
-                iOMXComponentSupportsExternalOutputBufferAlloc = Cap_flags.iOMXComponentSupportsExternalOutputBufferAlloc;
-                iOMXComponentSupportsMovableInputBuffers =		 Cap_flags.iOMXComponentSupportsMovableInputBuffers;
-                //temporarily define 3 flags here
-                iOMXComponentSupportsPartialFrames = true;
-                iOMXComponentNeedsNALStartCode = false;
-                iOMXComponentCanHandleIncompleteFrames = true;
-            }
-            // do some sanity checking
-
-            if ((Format != PVMF_H264) && (Format != PVMF_H264_MP4) && (Format != PVMF_H264_RAW))
-            {
-                iOMXComponentNeedsNALStartCode = false;
-            }
-
-            // make sure that copying is used where necessary
-            if (!iOMXComponentSupportsPartialFrames || iOMXComponentNeedsNALStartCode)
-            {
-                iOMXComponentSupportsMovableInputBuffers = false;
-            }
-
-            // find out about parameters
-
-            if (!NegotiateComponentParameters())
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPrepare() Cannot get component parameters"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            // create active objects to handle callbacks in case of multithreaded implementation
-
-            // NOTE: CREATE THE THREADSAFE CALLBACK AOs REGARDLESS OF WHETHER MULTITHREADED COMPONENT OR NOT
-            //		If it is not multithreaded, we won't use them
-            //		The Flag iIsComponentMultiThreaded decides which mechanism is used for callbacks.
-            //		This flag is set by looking at component capabilities (or to true by default)
-
-            if (iThreadSafeHandlerEventHandler)
-            {
-                OSCL_DELETE(iThreadSafeHandlerEventHandler);
-                iThreadSafeHandlerEventHandler = NULL;
-            }
-            // substitute default parameters: observer(this node),queuedepth(3),nameAO for logging
-            // Get the priority of video dec node, and set the threadsafe callback AO priority to 1 higher
-            iThreadSafeHandlerEventHandler = OSCL_NEW(EventHandlerThreadSafeCallbackAO, (this, 10, "EventHandlerAO", Priority() + 2));
-
-            if (iThreadSafeHandlerEmptyBufferDone)
-            {
-                OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
-                iThreadSafeHandlerEmptyBufferDone = NULL;
-            }
-            // use queue depth of iNumInputBuffers to prevent deadlock
-            iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1));
-
-            if (iThreadSafeHandlerFillBufferDone)
-            {
-                OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
-                iThreadSafeHandlerFillBufferDone = NULL;
-            }
-            // use queue depth of iNumOutputBuffers to prevent deadlock
-            iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1));
-
-            if ((iThreadSafeHandlerEventHandler == NULL) ||
-                    (iThreadSafeHandlerEmptyBufferDone == NULL) ||
-                    (iThreadSafeHandlerFillBufferDone == NULL)
-               )
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::Can't get threadsafe callbacks for decoder!"));
-                iOMXVideoDecoder = NULL;
-            }
-
-            // ONLY FOR AVC FILE PLAYBACK WILL 1 FRAGMENT CONTAIN ONE FULL NAL
-            if ((Format == PVMF_H264) || (Format == PVMF_H264_MP4))
-            {
-                // every memory fragment in case of AVC is a full NAL
-                iSetMarkerBitForEveryFrag = true;
-            }
-            else
-            {
-                iSetMarkerBitForEveryFrag = false;
-            }
-
-
-            // Init Decoder
-            iCurrentDecoderState = OMX_StateLoaded;
-            /* Change state to OMX_StateIdle from OMX_StateLoaded. */
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::DoPrepare(): Changing Component state Loaded -> Idle "));
-
-            err = OMX_SendCommand(iOMXVideoDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-
-            if (err != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPrepare() Can't send StateSet command!"));
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-            /* Allocate input buffers */
-            if (!CreateInputMemPool(iNumInputBuffers))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPrepare() Can't allocate mempool for input buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            if (!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
-                                           iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                           iNumInputBuffers, // number of buffers
-                                           iOMXComponentInputBufferSize, // actual buffer size
-                                           iInputPortIndex, // port idx
-                                           iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
-                                           true // this is input
-                                          ))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPrepare() Component can't use input buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-
-            /* Allocate output buffers */
-            if (!CreateOutMemPool(iNumOutputBuffers))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPrepare() Can't allocate mempool for output buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            if (!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
-                                           iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                           iNumOutputBuffers, // number of buffers
-                                           iOMXComponentOutputBufferSize, // actual buffer size
-                                           iOutputPortIndex, // port idx
-                                           iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
-                                           false // this is not input
-                                          ))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPrepare() Component can't use output buffers!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-
-            //this command is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until it completes. We have to wait for
-            // OMX component state transition to complete
-
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-        }
-        break;
-        case EPVMFNodePrepared:
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoStart(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DoStart() In"));
-
-    iDiagnosticsLogged = false;
-
-    PVMFStatus status = PVMFSuccess;
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodePrepared:
-        case EPVMFNodePaused:
-        {
-            //Get state of OpenMAX decoder
-            err = OMX_GetState(iOMXVideoDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-
-                                (0, "PVMFOMXVideoDecNode::DoStart(): Can't get State of decoder!"));
-
-                sState = OMX_StateInvalid;
-            }
-
-            if ((sState == OMX_StateIdle) || (sState == OMX_StatePause))
-            {
-                /* Change state to OMX_StateExecuting form OMX_StateIdle. */
-                // init the flag
-                iDoNotSendOutputBuffersDownstreamFlag = false; // or if output was not being sent downstream due to state changes
-                // re-anable sending output
-
-                iDoNotSaveInputBuffersFlag = false;
-
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::DoStart() Changing Component state Idle->Executing"));
-
-                err = OMX_SendCommand(iOMXVideoDecoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::DoStart(): Can't send StateSet command to decoder!"));
-
-                    status = PVMFErrInvalidState;
-                }
-
-            }
-            else
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoStart(): Decoder is not in the Idle or Pause state!"));
-
-                status = PVMFErrInvalidState;
-            }
-
-
-        }
-        break;
-
-        default:
-            status = PVMFErrInvalidState;
-            break;
-    }
-
-    if (status == PVMFErrInvalidState)
-    {
-        CommandComplete(iInputCommands, aCmd, status);
-    }
-    else
-    {
-        //this command is asynchronous.  move the command from
-        //the input command queue to the current command, where
-        //it will remain until it completes.
-        int32 err;
-        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-        if (err != OsclErrNone)
-        {
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-        }
-        iInputCommands.Erase(&aCmd);
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoStop(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DoStop() In"));
-
-    LogDiagnostics();
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        case EPVMFNodePrepared:
-            // Stop data source
-            // This will also prevent execution of HandleProcessingState
-
-            iDataIn.Unbind();
-            // Clear queued messages in ports
-            if (iInPort)
-            {
-                iInPort->ClearMsgQueues();
-            }
-
-            if (iOutPort)
-            {
-                iOutPort->ClearMsgQueues();
-            }
-
-            // Clear the data flags
-
-            iEndOfDataReached = false;
-            iIsEOSSentToComponent = false;
-            iIsEOSReceivedFromComponent = false;
-
-
-            iDoNotSendOutputBuffersDownstreamFlag = true; // stop sending output buffers downstream
-            iDoNotSaveInputBuffersFlag = true;
-
-            //if we're in the middle of a partial frame assembly
-            // abandon it and start fresh
-            if (iObtainNewInputBuffer == false)
-            {
-                if (iInputBufferUnderConstruction != NULL)
-                {
-                    if (iInBufMemoryPool != NULL)
-                    {
-                        iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
-                    }
-                    iInputBufferUnderConstruction = NULL;
-                }
-                iObtainNewInputBuffer = true;
-
-            }
-
-            iFirstDataMsgAfterBOS = true;
-
-            //Get state of OpenMAX decoder
-            err = OMX_GetState(iOMXVideoDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoStop(): Can't get State of decoder!"));
-
-                sState = OMX_StateInvalid;
-            }
-
-            if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
-            {
-                /* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::DoStop() Changing Component State Executing->Idle or Pause->Idle"));
-
-                err = OMX_SendCommand(iOMXVideoDecoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::DoStop(): Can't send StateSet command to decoder!"));
-
-                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                    break;
-                }
-
-                // prevent the node from sending more buffers etc.
-                // if port reconfiguration is in process, let the state remain one of the port config states
-                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
-                if (iProcessingState == EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode)
-                    iProcessingState = EPVMFOMXVideoDecNodeProcessingState_Stopping;
-
-                // indicate that stop cmd was sent
-                if (iDynamicReconfigInProgress)
-                {
-                    iStopCommandWasSentToComponent = true;
-                }
-
-            }
-            else
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoStop(): Decoder is not in the Executing or Pause state!"));
-
-                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                break;
-            }
-
-            //this command is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until it completes.
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-            break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoFlush(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            //the flush is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until the flush completes.
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-            //Notify all ports to suspend their input
-            if (iInPort)
-            {
-                iInPort->SuspendInput();
-            }
-            if (iOutPort)
-            {
-                iOutPort->SuspendInput();
-            }
-            // Stop data source
-
-            break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoPause(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DoPause() In"));
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-
-
-            //Get state of OpenMAX decoder
-            err = OMX_GetState(iOMXVideoDecoder, &sState);
-            if (err != OMX_ErrorNone)
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPause(): Can't get State of decoder!"));
-
-                sState = OMX_StateInvalid;
-            }
-
-            if (sState == OMX_StateExecuting)
-            {
-                /* Change state to OMX_StatePause from OMX_StateExecuting. */
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoDecNode::DoPause() Changing Component State Executing->Idle"));
-
-                err = OMX_SendCommand(iOMXVideoDecoder, OMX_CommandStateSet, OMX_StatePause, NULL);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::DoPause(): Can't send StateSet command to decoder!"));
-
-                    CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                    break;
-                }
-                // prevent the node from sending more buffers etc.
-                // if port reconfiguration is in process, let the state remain one of the port config states
-                //	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
-                if (iProcessingState == EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode)
-                    iProcessingState = EPVMFOMXVideoDecNodeProcessingState_Pausing;
-
-                // indicate that pause cmd was sent
-                if (iDynamicReconfigInProgress)
-                {
-                    iPauseCommandWasSentToComponent = true;
-                }
-
-
-            }
-            else
-            {
-                //Error condition report
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoDecNode::DoPause(): Decoder is not in the Executing state!"));
-                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                break;
-            }
-
-            //this command is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until it completes.
-            int32 err;
-            OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-            if (err != OsclErrNone)
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-            iInputCommands.Erase(&aCmd);
-
-            break;
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoReset(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-
-    OMX_ERRORTYPE  err;
-    OMX_STATETYPE sState;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::DoReset() In"));
-
-    LogDiagnostics();
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-        case EPVMFNodeInitialized:
-        case EPVMFNodePrepared:
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        case EPVMFNodeError:
-        {
-            //Check if decoder is initilized
-            if (iOMXVideoDecoder != NULL)
-            {
-
-                //if we're in the middle of a partial frame assembly
-                // abandon it and start fresh
-                if (iObtainNewInputBuffer == false)
-                {
-                    if (iInputBufferUnderConstruction != NULL)
-                    {
-                        if (iInBufMemoryPool != NULL)
-                        {
-                            iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
-                        }
-                        iInputBufferUnderConstruction = NULL;
-                    }
-                    iObtainNewInputBuffer = true;
-
-                }
-
-                iFirstDataMsgAfterBOS = true;
-                iKeepDroppingMsgsUntilMarkerBit = false;
-
-                //Get state of OpenMAX decoder
-                err = OMX_GetState(iOMXVideoDecoder, &sState);
-                if (err != OMX_ErrorNone)
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::DoReset(): Can't get State of decoder!"));
-                    if (iResetInProgress)
-                    {
-                        // cmd is in current q
-                        iResetInProgress = false;
-                        if ((iCurrentCommand.size() > 0) &&
-                                (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-                           )
-                        {
-                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
-                        }
-
-                    }
-                    else
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                    }
-                    return;
-                }
-
-                if (sState == OMX_StateLoaded)
-                {
-                    // this is a value obtained by synchronous call to component. Either the component was
-                    // already in this state without node issuing any commands,
-                    // or perhaps we started the Reset, but the callback notification has not yet arrived.
-                    if (iResetInProgress)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::DoReset() OMX comp is in loaded state. Wait for official callback to change variables etc."));
-                        return;
-                    }
-                    else
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrResource);
-                        return;
-                    }
-                }
-
-                if (sState == OMX_StateIdle)
-                {
-
-
-                    //this command is asynchronous.  move the command from
-                    //the input command queue to the current command, where
-                    //it will remain until it is completed.
-                    if (!iResetInProgress)
-                    {
-                        int32 err;
-                        OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-                        if (err != OsclErrNone)
-                        {
-                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
-                        }
-                        iInputCommands.Erase(&aCmd);
-
-                        iResetInProgress = true;
-                    }
-
-                    // if buffers aren't all back (due to timing issues with different callback AOs
-                    //		state change can be reported before all buffers are returned)
-                    if (iNumOutstandingInputBuffers > 0 || iNumOutstandingOutputBuffers > 0)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::DoReset() Waiting for %d input and-or %d output buffers", iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
-
-                        return;
-                    }
-
-                    if (!iResetMsgSent)
-                    {
-                        // We can come here only if all buffers are already back
-                        // Don't repeat any of this twice.
-                        /* Change state to OMX_StateLoaded form OMX_StateIdle. */
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::DoReset() Changing Component State Idle->Loaded"));
-
-                        err = OMX_SendCommand(iOMXVideoDecoder, OMX_CommandStateSet, OMX_StateLoaded, NULL);
-                        if (err != OMX_ErrorNone)
-                        {
-                            //Error condition report
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                            (0, "PVMFOMXVideoDecNode::DoReset(): Can't send StateSet command to decoder!"));
-                        }
-
-                        iResetMsgSent = true;
-
-
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::DoReset() freeing output buffers"));
-
-                        if (false == iOutputBuffersFreed)
-                        {
-                            if (!FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
-                                                          iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                          iNumOutputBuffers, // number of buffers
-                                                          iOutputPortIndex, // port idx
-                                                          false // this is not input
-                                                         ))
-                            {
-                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                                (0, "PVMFOMXVideoDecNode::DoReset() Cannot free output buffers "));
-
-                                if (iResetInProgress)
-                                {
-                                    iResetInProgress = false;
-                                    if ((iCurrentCommand.size() > 0) &&
-                                            (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-                                       )
-                                    {
-                                        CommandComplete(iCurrentCommand, iCurrentCommand.front() , PVMFErrResource);
-                                    }
-                                }
-
-                            }
-
-                        }
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                        (0, "PVMFOMXVideoDecNode::DoReset() freeing input buffers "));
-                        if (false == iInputBuffersFreed)
-                        {
-                            if (!FreeBuffersFromComponent(iInBufMemoryPool, // allocator
-                                                          iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                                          iNumInputBuffers, // number of buffers
-                                                          iInputPortIndex, // port idx
-                                                          true // this is input
-                                                         ))
-                            {
-                                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                                (0, "PVMFOMXVideoDecNode::DoReset() Cannot free input buffers "));
-
-                                if (iResetInProgress)
-                                {
-                                    iResetInProgress = false;
-                                    if ((iCurrentCommand.size() > 0) &&
-                                            (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-                                       )
-                                    {
-                                        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrResource);
-                                    }
-                                }
-
-
-                            }
-                        }
-
-
-
-                        iEndOfDataReached = false;
-                        iIsEOSSentToComponent = false;
-                        iIsEOSReceivedFromComponent = false;
-
-
-
-                        // also, perform Port deletion when the component replies with the command
-                        // complete, not right here
-                    } // end of if(iResetMsgSent)
-
-
-                    return;
-
-                }
-                else
-                {
-                    //Error condition report
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoDecNode::DoReset(): Decoder is not in the Idle state!"));
-                    if (iResetInProgress)
-                    {
-                        iResetInProgress = false;
-                        if ((iCurrentCommand.size() > 0) &&
-                                (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-                           )
-                        {
-                            CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrInvalidState);
-                        }
-                    }
-                    else
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-                    }
-                    break;
-                }//end of if (sState == OMX_StateIdle)
-            }//end of if (iOMXVideoDecoder != NULL)
-
-            //delete all ports and notify observer.
-            if (iInPort)
-            {
-                OSCL_DELETE(((PVMFOMXVideoDecPort*)iInPort));
-                iInPort = NULL;
-            }
-
-            if (iOutPort)
-            {
-                OSCL_DELETE(((PVMFOMXVideoDecPort*)iOutPort));
-                iOutPort = NULL;
-            }
-
-            iDataIn.Unbind();
-
-
-            // Reset the metadata key list
-            iAvailableMetadataKeys.clear();
-
-            iEndOfDataReached = false;
-            iIsEOSSentToComponent = false;
-            iIsEOSReceivedFromComponent = false;
-
-
-            iProcessingState = EPVMFOMXVideoDecNodeProcessingState_Idle;
-            //logoff & go back to Created state.
-            SetState(EPVMFNodeIdle);
-
-
-            if (iResetInProgress)
-            {
-                iResetInProgress = false;
-                if ((iCurrentCommand.size() > 0) &&
-                        (iCurrentCommand.front().iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-                   )
-                {
-                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
-                }
-            }
-            else
-            {
-                CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            }
-
-        }
-        break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoRequestPort(PVMFOMXVideoDecNodeCommand& aCmd)
+void PVMFOMXVideoDecNode::DoRequestPort(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXVideoDecNode::DoRequestPort() In"));
@@ -5329,20 +1264,20 @@
     int32 tag;
     OSCL_String* portconfig;
 
-    aCmd.PVMFOMXVideoDecNodeCommandBase::Parse(tag, portconfig);
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(tag, portconfig);
 
     PVMFPortInterface* port = NULL;
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     //validate the tag...
     switch (tag)
     {
-        case PVMF_OMX_VIDEO_DEC_NODE_PORT_TYPE_SOURCE:
+        case PVMF_OMX_DEC_NODE_PORT_TYPE_INPUT:
             if (iInPort)
             {
                 CommandComplete(iInputCommands, aCmd, PVMFFailure);
                 break;
             }
-            OSCL_TRY(leavecode, iInPort = OSCL_NEW(PVMFOMXVideoDecPort, ((int32)tag, this, "OMXVideoDecIn(Video)")););
+            OSCL_TRY(leavecode, iInPort = OSCL_NEW(PVMFOMXDecPort, ((int32)tag, this, PVMF_OMX_VIDEO_DEC_INPUT_PORT_NAME)););
             if (leavecode || iInPort == NULL)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -5353,13 +1288,13 @@
             port = iInPort;
             break;
 
-        case PVMF_OMX_VIDEO_DEC_NODE_PORT_TYPE_SINK:
+        case PVMF_OMX_DEC_NODE_PORT_TYPE_OUTPUT:
             if (iOutPort)
             {
                 CommandComplete(iInputCommands, aCmd, PVMFFailure);
                 break;
             }
-            OSCL_TRY(leavecode, iOutPort = OSCL_NEW(PVMFOMXVideoDecPort, ((int32)tag, this, "OMXVideoDecOut(Video)")));
+            OSCL_TRY(leavecode, iOutPort = OSCL_NEW(PVMFOMXDecPort, ((int32)tag, this, PVMF_OMX_VIDEO_DEC_OUTPUT_PORT_NAME)));
             if (leavecode || iOutPort == NULL)
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -5383,21 +1318,22 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoReleasePort(PVMFOMXVideoDecNodeCommand& aCmd)
+void PVMFOMXVideoDecNode::DoReleasePort(PVMFOMXBaseDecNodeCommand& aCmd)
 {
-    PVMFOMXVideoDecPort* port;
-    aCmd.PVMFOMXVideoDecNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* p = NULL;
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(p);
+    PVMFOMXDecPort* port = (PVMFOMXDecPort*)p;
 
     if (port != NULL && (port == iInPort || port == iOutPort))
     {
         if (port == iInPort)
         {
-            OSCL_DELETE(((PVMFOMXVideoDecPort*)iInPort));
+            OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
             iInPort = NULL;
         }
         else
         {
-            OSCL_DELETE(((PVMFOMXVideoDecPort*)iOutPort));
+            OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
             iOutPort = NULL;
         }
         //delete the port.
@@ -5411,7 +1347,7 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::DoGetNodeMetadataKey(PVMFOMXVideoDecNodeCommand& aCmd)
+PVMFStatus PVMFOMXVideoDecNode::DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFOMXVideoDecNode::DoGetNodeMetadataKey() In"));
@@ -5421,7 +1357,7 @@
     int32 max_entries;
     char* query_key;
 
-    aCmd.PVMFOMXVideoDecNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
+    aCmd.PVMFOMXBaseDecNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
 
     // Check parameters
     if (keylistptr == NULL)
@@ -5432,15 +1368,28 @@
 
     // Update the available metadata keys
     iAvailableMetadataKeys.clear();
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY));
+    int32 leavecode = OsclErrNone;
+    leavecode = PushKVPKey(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY, iAvailableMetadataKeys);
+    if (OsclErrNone != leavecode)
+    {
+        return PVMFErrNoMemory;
+    }
 
     if (iYUVWidth > 0 && iYUVHeight > 0)
     {
-        leavecode = 0;
-        OSCL_TRY(leavecode,
-                 iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_WIDTH_KEY);
-                 iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_HEIGHT_KEY));
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_WIDTH_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
+        {
+            return PVMFErrNoMemory;
+        }
+
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_HEIGHT_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
+        {
+            return PVMFErrNoMemory;
+        }
     }
     // add the profile, level and avgbitrate
     PVMF_MPEGVideoProfileType aProfile;
@@ -5448,16 +1397,28 @@
     if (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess)
     {
         // For H263 this metadata will be available only after first frame decoding
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_PROFILE_KEY));
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_LEVEL_KEY));
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_PROFILE_KEY, iAvailableMetadataKeys);
+        if (leavecode != OsclErrNone)
+        {
+            return PVMFErrNoMemory;
+        }
+
+        leavecode = OsclErrNone;
+        leavecode = PushKVPKey(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_LEVEL_KEY, iAvailableMetadataKeys);
+        if (OsclErrNone != leavecode)
+        {
+            return PVMFErrNoMemory;
+        }
     }
-    leavecode = 0;
-    OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY));
+    leavecode = OsclErrNone;
+    leavecode = PushKVPKey(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY, iAvailableMetadataKeys);
+    if (OsclErrNone != leavecode)
+    {
+        return PVMFErrNoMemory;
+    }
 
-
-    if ((starting_index < 0) || (starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
+    if ((starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
     {
         // Invalid starting index and/or max entries
         return PVMFErrArgument;
@@ -5475,12 +1436,12 @@
             if (num_entries > starting_index)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                                     (0, "PVMFOMXVIDEODECNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                leavecode = OsclErrNone;
+                leavecode = PushKVPKey(iAvailableMetadataKeys[lcv] , keylistptr);
+                if (OsclErrNone != leavecode)
+                {
+                    return PVMFErrNoMemory;
+                }
                 num_added++;
             }
         }
@@ -5494,11 +1455,13 @@
                 if (num_entries > starting_index)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    leavecode = OsclErrNone;
+                    leavecode = PushKVPKey(iAvailableMetadataKeys[lcv] , keylistptr);
+                    if (OsclErrNone != leavecode)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
+                        return PVMFErrNoMemory;
+                    }
                     num_added++;
                 }
             }
@@ -5515,7 +1478,7 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::DoGetNodeMetadataValue(PVMFOMXVideoDecNodeCommand& aCmd)
+PVMFStatus PVMFOMXVideoDecNode::DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DoGetNodeMetadataValue() In"));
 
@@ -5524,7 +1487,7 @@
     uint32 starting_index;
     int32 max_entries;
 
-    aCmd.PVMFOMXVideoDecNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
+    aCmd.PVMFOMXBaseDecNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
 
     // Check the parameters
     if (keylistptr == NULL || valuelistptr == NULL)
@@ -5534,7 +1497,7 @@
 
     uint32 numkeys = keylistptr->size();
 
-    if (starting_index < 0 || starting_index > (numkeys - 1) || numkeys <= 0 || max_entries == 0)
+    if (starting_index > (numkeys - 1) || numkeys <= 0 || max_entries == 0)
     {
         // Don't do anything
         return PVMFErrArgument;
@@ -5544,7 +1507,8 @@
     int32 numentriesadded = 0;
     for (uint32 lcv = 0; lcv < numkeys; lcv++)
     {
-        int32 leavecode = 0;
+        int32 leavecode = OsclErrNone;
+        int32 leavecode1 = OsclErrNone;
         PvmiKvp KeyVal;
         KeyVal.key = NULL;
         uint32 KeyLen = 0;
@@ -5564,12 +1528,9 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                if (OsclErrNone == leavecode)
                 {
                     // Copy the key string
                     oscl_strncpy(KeyVal.key, PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_WIDTH_KEY, oscl_strlen(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_WIDTH_KEY) + 1);
@@ -5606,12 +1567,9 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
-                if (leavecode == 0)
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                if (OsclErrNone == leavecode)
                 {
                     // Copy the key string
                     oscl_strncpy(KeyVal.key, PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_HEIGHT_KEY, oscl_strlen(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_HEIGHT_KEY) + 1);
@@ -5647,12 +1605,10 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                if (leavecode == 0)
+                if (OsclErrNone == leavecode)
                 {
                     PVMF_MPEGVideoProfileType aProfile;
                     PVMF_MPEGVideoLevelType aLevel;
@@ -5699,12 +1655,10 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                if (leavecode == 0)
+                if (OsclErrNone == leavecode)
                 {
                     PVMF_MPEGVideoProfileType aProfile;
                     PVMF_MPEGVideoLevelType aLevel;
@@ -5752,12 +1706,10 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
 
-                if (leavecode == 0)
+                if (OsclErrNone == leavecode)
                 {
                     // Copy the key string
                     oscl_strncpy(KeyVal.key, PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY, oscl_strlen(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY) + 1);
@@ -5781,10 +1733,10 @@
             }
         }
         else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY) == 0) &&
-                 (((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H263 || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_M4V ||
-                  ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H264 || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H264_MP4 ||
-                  ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H264_RAW
-                  || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_WMV))
+                 (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2631998 || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2632000 ||
+                  ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_M4V ||
+                  ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 ||
+                  ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW  || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV))
         {
             // Format
             // Increment the counter for the number of values found so far
@@ -5798,45 +1750,51 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*" and NULL terminator
 
                 uint32 valuelen = 0;
-                switch (((PVMFOMXVideoDecPort*)iInPort)->iFormat)
+
+                if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO)
                 {
-                    case PVMF_H264:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO)) + 1; // Value string plus one for NULL terminator
-                        break;
-
-                    case PVMF_H264_MP4:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4)) + 1; // Value string plus one for NULL terminator
-                        break;
-
-                    case PVMF_H264_RAW:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO_RAW)) + 1; // Value string plus one for NULL terminator
-                        break;
-
-                    case PVMF_M4V:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_M4V)) + 1; // Value string plus one for NULL terminator
-                        break;
-
-                    case PVMF_H263:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H2631998)) + 1; // Value string plus one for NULL terminator
-                        break;
-                    case PVMF_WMV:
-                        valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_WMV)) + 1; // Value string plus one for NULL terminator
-                        break;
-                    default:
-                        // Should not enter here
-                        OSCL_ASSERT(false);
-                        valuelen = 1;
-                        break;
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H264_VIDEO_RAW)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_M4V)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_M4V)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2631998)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H2631998)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_H2632000)) + 1; // Value string plus one for NULL terminator
+                }
+                else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV)
+                {
+                    valuelen = oscl_strlen(_STRLIT_CHAR(PVMF_MIME_WMV)) + 1; // Value string plus one for NULL terminator
+                }
+                else
+                {
+                    // Should not enter here
+                    OSCL_ASSERT(false);
+                    valuelen = 1;
                 }
 
                 // Allocate memory for the strings
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                         KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                        );
+                leavecode = OsclErrNone;
+                KeyVal.key = (char*) AllocateKVPKeyArray(leavecode, PVMI_KVPVALTYPE_CHARPTR, KeyLen);
+                if (OsclErrNone == leavecode)
+                {
+                    KeyVal.value.pChar_value = (char*) AllocateKVPKeyArray(leavecode1, PVMI_KVPVALTYPE_CHARPTR, valuelen);
+                }
 
-                if (leavecode == 0)
+                if (OsclErrNone == leavecode && OsclErrNone == leavecode1)
                 {
                     // Copy the key string
                     oscl_strncpy(KeyVal.key, PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY, oscl_strlen(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY) + 1);
@@ -5845,33 +1803,38 @@
                     oscl_strncat(KeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
                     KeyVal.key[KeyLen-1] = NULL_TERM_CHAR;
                     // Copy the value
-                    switch (((PVMFOMXVideoDecPort*)iInPort)->iFormat)
+                    if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO)
                     {
-                        case PVMF_H264:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO), valuelen);
-                            break;
-
-                        case PVMF_H264_MP4:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), valuelen);
-                            break;
-
-                        case PVMF_H264_RAW:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_RAW), valuelen);
-                            break;
-                        case PVMF_M4V:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_M4V), valuelen);
-                            break;
-                        case PVMF_H263:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H2631998), valuelen);
-                            break;
-                        case PVMF_WMV:
-                            oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_WMV), valuelen);
-                            break;
-
-                        default:
-                            // Should not enter here
-                            OSCL_ASSERT(false);
-                            break;
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO), valuelen);
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_MP4), valuelen);
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H264_VIDEO_RAW), valuelen);
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_M4V)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_M4V), valuelen);
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2631998)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H2631998), valuelen);
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2632000)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_H2632000), valuelen);
+                    }
+                    else if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV)
+                    {
+                        oscl_strncpy(KeyVal.value.pChar_value, _STRLIT_CHAR(PVMF_MIME_WMV), valuelen);
+                    }
+                    else
+                    {
+                        // Should not enter here
+                        OSCL_ASSERT(false);
                     }
                     KeyVal.value.pChar_value[valuelen-1] = NULL_TERM_CHAR;
                     // Set the length and capacity
@@ -5897,9 +1860,9 @@
 
         if (KeyVal.key != NULL)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
-            if (leavecode != 0)
+            leavecode = OsclErrNone;
+            leavecode = PushKVP(KeyVal, *valuelistptr);
+            if (OsclErrNone != leavecode)
             {
                 switch (GetValTypeFromKeyString(KeyVal.key))
                 {
@@ -5945,7 +1908,7 @@
     {
         iInPort->ClearMsgQueues();
         iInPort->Disconnect();
-        OSCL_DELETE(((PVMFOMXVideoDecPort*)iInPort));
+        OSCL_DELETE(((PVMFOMXDecPort*)iInPort));
         iInPort = NULL;
     }
 
@@ -5953,7 +1916,7 @@
     {
         iOutPort->ClearMsgQueues();
         iOutPort->Disconnect();
-        OSCL_DELETE(((PVMFOMXVideoDecPort*)iOutPort));
+        OSCL_DELETE(((PVMFOMXDecPort*)iOutPort));
         iOutPort = NULL;
     }
 
@@ -5961,440 +1924,45 @@
 }
 
 /////////////////////////////////////////////////////////////////////////////
-// Clean Up Decoder
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::DeleteOMXVideoDecoder()
-{
-    OMX_ERRORTYPE  err;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::DeleteOMXVideoDecoder() In"));
-
-    if (iOMXVideoDecoder != NULL)
-    {
-        /* Free Component handle. */
-        err = PV_MasterOMX_FreeHandle(iOMXVideoDecoder);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::DeleteOMXVideoDecoder(): Can't free decoder's handle!"));
-        }
-        iOMXVideoDecoder = NULL;
-
-    }//end of if (iOMXVideoDecoder != NULL)
-
-
-    return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::ChangeNodeState(TPVMFNodeInterfaceState aNewState)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ChangeNodeState() Changing state from %d to %d", iInterfaceState, aNewState));
-    iInterfaceState = aNewState;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::freechunkavailable(OsclAny *aContext)
-{
-
-    // check context to see whether input or output buffer was returned to the mempool
-    if (aContext == (OsclAny *) iInBufMemoryPool)
-    {
-
-        iNumOutstandingInputBuffers--;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::freechunkavailable() Memory chunk in INPUT mempool was deallocated, %d out of %d now available", iNumInputBuffers - iNumOutstandingInputBuffers, iNumInputBuffers));
-
-        // notification only works once.
-        // If there are multiple buffers coming back in a row, make sure to set the notification
-        // flag in the mempool again, so that next buffer also causes notification
-        iInBufMemoryPool->notifyfreechunkavailable(*this, aContext);
-
-    }
-    else if (aContext == (OsclAny *) iOutBufMemoryPool)
-    {
-
-        iNumOutstandingOutputBuffers--;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::freechunkavailable() Memory chunk in OUTPUT mempool was deallocated, %d out of %d now available", iNumOutputBuffers - iNumOutstandingOutputBuffers, iNumOutputBuffers));
-
-        // notification only works once.
-        // If there are multiple buffers coming back in a row, make sure to set the notification
-        // flag in the mempool again, so that next buffer also causes notification
-        iOutBufMemoryPool->notifyfreechunkavailable(*this, aContext);
-
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::freechunkavailable() UNKNOWN mempool "));
-
-    }
-
-    // reschedule
-    if (IsAdded())
-        RunIfNotReady();
-
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::HandlePortActivity(const PVMFPortActivity &aActivity)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "0x%x PVMFOMXVideoDecNode::PortActivity: port=0x%x, type=%d",
-                     this, aActivity.iPort, aActivity.iType));
-
-    switch (aActivity.iType)
-    {
-        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-            //An outgoing message was queued on this port.
-            //We only need to queue a port activity event on the
-            //first message.  Additional events will be queued during
-            //the port processing as needed.
-            if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
-            {
-                //wake up the AO to process the port activity event.
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoDecNode::PortActivity: IncomingMsgQueueSize=%d", aActivity.iPort->IncomingMsgQueueSize()));
-            if (aActivity.iPort->IncomingMsgQueueSize() == 1)
-            {
-                //wake up the AO to process the port activity event.
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            if (iProcessingState == EPVMFOMXVideoDecNodeProcessingState_WaitForOutgoingQueue)
-            {
-                iProcessingState = EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode;
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECT:
-            //nothing needed.
-            break;
-
-        case PVMF_PORT_ACTIVITY_DISCONNECT:
-            //clear the node input data when either port is disconnected.
-
-            iDataIn.Unbind();
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-            // The connected port has become busy (its incoming queue is
-            // busy).
-            // No action is needed here-- the port processing code
-            // checks for connected port busy during data processing.
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-            // The connected port has transitioned from Busy to Ready to Receive.
-            // It's time to start processing outgoing messages again.
-
-            //iProcessingState should transition from WaitForOutputPort to ReadyToDecode
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "0x%x PVMFOMXVideoDecNode::PortActivity: Connected port is now ready", this));
-            RunIfNotReady();
-            break;
-
-        default:
-            break;
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoCancelAllCommands(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::DoCancelAllCommands"));
-
-    //first cancel the current command if any
-    {
-        while (!iCurrentCommand.empty())
-        {
-            CommandComplete(iCurrentCommand, iCurrentCommand[0], PVMFErrCancelled);
-        }
-
-    }
-
-    //next cancel all queued commands
-    {
-        //start at element 1 since this cancel command is element 0.
-        while (iInputCommands.size() > 1)
-        {
-            CommandComplete(iInputCommands, iInputCommands[1], PVMFErrCancelled);
-        }
-    }
-
-    if (iResetInProgress && !iResetMsgSent)
-    {
-        // if reset is started but reset msg has not been sent, we can cancel reset
-        // as if nothing happened. Otherwise, the callback will set the flag back to false
-        iResetInProgress = false;
-    }
-    //finally, report cancel complete.
-    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoCancelCommand(PVMFOMXVideoDecNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::DoCancelCommand"));
-
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.PVMFOMXVideoDecNodeCommandBase::Parse(id);
-
-    //first check "current" command if any
-    {
-        PVMFOMXVideoDecNodeCommand* cmd = iCurrentCommand.FindById(id);
-        if (cmd)
-        {
-
-            // if reset is being canceled:
-            if (cmd->iCmd == PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_RESET)
-            {
-                if (iResetInProgress && !iResetMsgSent)
-                {
-                    // if reset is started but reset msg has not been sent, we can cancel reset
-                    // as if nothing happened. Otherwise, the callback will set the flag back to false
-                    iResetInProgress = false;
-                }
-            }
-            //cancel the queued command
-            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PVMFOMXVideoDecNodeCommand* cmd = iInputCommands.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoQueryUuid(PVMFOMXVideoDecNodeCommand& aCmd)
+void PVMFOMXVideoDecNode::DoQueryUuid(PVMFOMXBaseDecNodeCommand& aCmd)
 {
     //This node supports Query UUID from any state
 
     OSCL_String* mimetype;
     Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
     bool exactmatch;
-    aCmd.PVMFOMXVideoDecNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
+    aCmd.PVMFOMXBaseDecNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
 
     //Try to match the input mimetype against any of
     //the custom interfaces for this node
 
     //Match against custom interface1...
-    if (*mimetype == PVMF_OMX_VIDEO_DEC_NODE_CUSTOM1_MIMETYPE
+    if (*mimetype == PVMF_OMX_BASE_DEC_NODE_CUSTOM1_MIMETYPE
             //also match against base mimetypes for custom interface1,
             //unless exactmatch is set.
             || (!exactmatch && *mimetype == PVMF_OMX_VIDEO_DEC_NODE_MIMETYPE)
             || (!exactmatch && *mimetype == PVMF_BASEMIMETYPE))
     {
 
-        PVUuid uuid(PVMF_OMX_VIDEO_DEC_NODE_CUSTOM1_UUID);
+        PVUuid uuid(PVMF_OMX_BASE_DEC_NODE_CUSTOM1_UUID);
         uuidvec->push_back(uuid);
     }
     CommandComplete(iInputCommands, aCmd, PVMFSuccess);
 }
 
 /////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::DoQueryInterface(PVMFOMXVideoDecNodeCommand&  aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::DoQueryInterface"));
-    PVUuid* uuid;
-    PVInterface** ptr;
-    aCmd.PVMFOMXVideoDecNodeCommandBase::Parse(uuid, ptr);
-
-    if (*uuid == PVUuid(PVMF_OMX_VIDEO_DEC_NODE_CUSTOM1_UUID))
-    {
-        addRef();
-        *ptr = (PVMFOMXVideoDecNodeExtensionInterface*)this;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else if (*uuid == PVUuid(KPVMFMetadataExtensionUuid))
-    {
-        addRef();
-        *ptr = (PVMFMetadataExtensionInterface*)this;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else if (*uuid == PVUuid(PVMI_CAPABILITY_AND_CONFIG_PVUUID))
-    {
-        addRef();
-        *ptr = (PvmiCapabilityAndConfig*)this;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else
-    {
-        //not supported
-        *ptr = NULL;
-        CommandComplete(iInputCommands, aCmd, PVMFFailure);
-    }
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::removeRef()
-{
-    --iExtensionRefCount;
-}
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::HandleRepositioning()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::HandleRepositioning() IN"));
-
-
-    // 1) Send Flush command to component for both input and output ports
-    // 2) "Wait" until component flushes both ports
-    // 3) Resume
-    OMX_ERRORTYPE  err = OMX_ErrorNone;
-    OMX_STATETYPE sState = OMX_StateInvalid;
-
-
-    if (!iIsRepositioningRequestSentToComponent)
-    {
-
-        // first check the state (if executing or paused, continue)
-        err = OMX_GetState(iOMXVideoDecoder, &sState);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::HandleRepositioning(): Can't get State of decoder - trying to send reposition request!"));
-
-            sState = OMX_StateInvalid;
-            ReportErrorEvent(PVMFErrResourceConfiguration);
-            ChangeNodeState(EPVMFNodeError);
-            return false;
-        }
-
-        if ((sState != OMX_StateExecuting) && (sState != OMX_StatePause))
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoDecNode::HandleRepositioning() Component State is not executing or paused, do not proceed with repositioning"));
-
-            return true;
-        }
-
-        iIsRepositioningRequestSentToComponent = true; // prevent sending requests multiple times
-        iIsInputPortFlushed = false;	// flag that will be set to true once component flushes the port
-        iIsOutputPortFlushed = false;
-        iDoNotSendOutputBuffersDownstreamFlag = true;
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::HandleRepositioning() Sending Flush command to component"));
-
-        // send command to flush all ports (arg is -1)
-
-        err = OMX_SendCommand(iOMXVideoDecoder, OMX_CommandFlush, -1, NULL);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoDecNode::HandleRepositioning(): Can't send flush command  - trying to send reposition request!"));
-
-            sState = OMX_StateInvalid;
-            ReportErrorEvent(PVMFErrResourceConfiguration);
-            ChangeNodeState(EPVMFNodeError);
-            return false;
-        }
-    }
-
-    if (iIsRepositionDoneReceivedFromComponent)
-    {
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoDecNode::HandleRepositioning() Component has flushed both ports, and is done repositioning"));
-
-        iIsRepositioningRequestSentToComponent = false; // enable sending requests again
-        iIsRepositionDoneReceivedFromComponent = false;
-        iIsInputPortFlushed = false;
-        iIsOutputPortFlushed = false;
-
-        iDoNotSendOutputBuffersDownstreamFlag = false;
-        return true;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoDecNode::HandleRepositioning() Component is not yet done repositioning "));
-
-    return false;
-
-}
-
-
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    PVUuid my_uuid(PVMF_OMX_VIDEO_DEC_NODE_CUSTOM1_UUID);
-    if (uuid == my_uuid)
-    {
-        PVMFOMXVideoDecNodeExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFOMXVideoDecNodeExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-        return true;
-    }
-    else if (uuid == KPVMFMetadataExtensionUuid)
-    {
-        PVMFMetadataExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-        return true;
-    }
-    return false;
-}
-
-/////////////////////////////////////////////////////////////////////////////
 uint32 PVMFOMXVideoDecNode::GetNumMetadataKeys(char* aQueryKeyString)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::GetNumMetadataKeys() called"));
 
     // Update the available metadata keys
     iAvailableMetadataKeys.clear();
-    int32 errcode = 0;
+    int32 errcode = OsclErrNone;
     OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY));
 
     if (iYUVWidth > 0 && iYUVHeight > 0)
     {
-        errcode = 0;
+        errcode = OsclErrNone;
         OSCL_TRY(errcode,
                  iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_WIDTH_KEY);
                  iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_HEIGHT_KEY));
@@ -6405,12 +1973,12 @@
     if (GetProfileAndLevel(aProfile, aLevel) == PVMFSuccess)
     {
         // For H263 this metadata will be available only after first frame decoding
-        errcode = 0;
+        errcode = OsclErrNone;
         OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_PROFILE_KEY));
-        errcode = 0;
+        errcode = OsclErrNone;
         OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_LEVEL_KEY));
     }
-    errcode = 0;
+    errcode = OsclErrNone;
     OSCL_TRY(errcode, iAvailableMetadataKeys.push_back(PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_AVGBITRATE_KEY));
 
 
@@ -6434,114 +2002,6 @@
     return num_entries; // Number of elements
 }
 
-///////////////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    OSCL_UNUSED_ARG(aObserver);
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::setObserver()"));
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::setObserver() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-PVMFStatus PVMFOMXVideoDecNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::getParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
-}
-
-
-PVMFStatus PVMFOMXVideoDecNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::releaseParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    return DoCapConfigReleaseParameters(aParameters, aNumElements);
-}
-
-
-void PVMFOMXVideoDecNode::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::createContext()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::createContext() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-void PVMFOMXVideoDecNode::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::setContextParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumParamElements);
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::setContextParameters() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-void PVMFOMXVideoDecNode::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DeleteContext()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::DeleteContext() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-
-void PVMFOMXVideoDecNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::setParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    // Complete the request synchronously
-    DoCapConfigSetParameters(aParameters, aNumElements, aRetKVP);
-}
-
-
-PVMFCommandId PVMFOMXVideoDecNode::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::setParametersAsync()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    OSCL_UNUSED_ARG(aRetKVP);
-    OSCL_UNUSED_ARG(aContext);
-
-    // This method is not supported so leave
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::setParametersAsync() is not supported!"));
-    OSCL_LEAVE(PVMFErrNotSupported);
-    return 0;
-}
-
-
-uint32 PVMFOMXVideoDecNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::getCapabilityMetric()"));
-    OSCL_UNUSED_ARG(aSession);
-    // Not supported so return 0
-    return 0;
-}
-
-
-PVMFStatus PVMFOMXVideoDecNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::verifyParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    return DoCapConfigVerifyParameters(aParameters, aNumElements);
-}
-
-
 /////////////////////////////////////////////////////////////////////////////
 uint32 PVMFOMXVideoDecNode::GetNumMetadataValues(PVMFMetadataList& aKeyList)
 {
@@ -6595,9 +2055,7 @@
                 ++numvalentries;
         }
         else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVOMXVIDEODECMETADATA_CODECINFO_VIDEO_FORMAT_KEY) == 0) &&
-                 (
-                     ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_WMV ||
-                     ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_M4V || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H263 || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H264 || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H264_MP4 || ((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_H264_RAW))
+                 (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_M4V || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2631998 || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H2632000 || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_MP4 || ((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_H264_VIDEO_RAW))
         {
             // Format
             ++numvalentries;
@@ -6607,85 +2065,6 @@
     return numvalentries;
 }
 
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries, char* query_key, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNodeCommand::GetNodeMetadataKeys() called"));
-
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommand::Construct(aSessionId, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_GETNODEMETADATAKEY, &aKeyList, starting_index, max_entries, query_key, aContext);
-    return QueueCommandL(cmd);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoDecNode::GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNodeCommand::GetNodeMetadataValue() called"));
-
-    PVMFOMXVideoDecNodeCommand cmd;
-    cmd.PVMFOMXVideoDecNodeCommand::Construct(aSessionId, PVMFOMXVideoDecNodeCommand::PVOMXVIDEODEC_NODE_CMD_GETNODEMETADATAVALUE, &aKeyList, &aValueList, starting_index, max_entries, aContext);
-    return QueueCommandL(cmd);
-}
-
-// From PVMFMetadataExtensionInterface
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::ReleaseNodeMetadataKeys(PVMFMetadataList& , uint32 , uint32)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ReleaseNodeMetadataKeys() called"));
-    //nothing needed-- there's no dynamic allocation in this node's key list
-    return PVMFSuccess;
-}
-
-// From PVMFMetadataExtensionInterface
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoDecNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 start, uint32 end)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::ReleaseNodeMetadataValues() called"));
-
-    if (aValueList.size() == 0 || start < 0 || start > end)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::ReleaseNodeMetadataValues() Invalid start/end index"));
-        return PVMFErrArgument;
-    }
-
-    if (end >= aValueList.size())
-    {
-        end = aValueList.size() - 1;
-    }
-
-    for (uint32 i = start; i <= end; i++)
-    {
-        if (aValueList[i].key != NULL)
-        {
-            switch (GetValTypeFromKeyString(aValueList[i].key))
-            {
-                case PVMI_KVPVALTYPE_CHARPTR:
-                    if (aValueList[i].value.pChar_value != NULL)
-                    {
-                        OSCL_ARRAY_DELETE(aValueList[i].value.pChar_value);
-                        aValueList[i].value.pChar_value = NULL;
-                    }
-                    break;
-
-                case PVMI_KVPVALTYPE_UINT32:
-                case PVMI_KVPVALTYPE_UINT8:
-                    // No memory to free for these valtypes
-                    break;
-
-                default:
-                    // Should not get a value that wasn't created from here
-                    break;
-            }
-
-            OSCL_ARRAY_DELETE(aValueList[i].key);
-            aValueList[i].key = NULL;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////
 // CAPABILITY CONFIG PRIVATE
 PVMFStatus PVMFOMXVideoDecNode::DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
@@ -7296,10 +2675,7 @@
     return (i -j);
 }
 
-/* TODO: Functions of the decoder are directly being called here.
-   Should this be a place where we add an interface that is to be implemented
-   by the 3rd party codecs to negotiate the capability and config ???
-*/
+
 PVMFStatus PVMFOMXVideoDecNode::DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::DoCapConfigVerifyParameters() In"));
@@ -7514,12 +2890,12 @@
             if (reqattr == PVMI_KVPATTR_CUR)
             {
                 // Return current value
-                aParameters[0].value.uint32_value = iNodeConfig.iMimeType;
+                aParameters[0].value.pChar_value = (char*)iNodeConfig.iMimeType.getMIMEStrPtr();
             }
             else if (reqattr == PVMI_KVPATTR_DEF)
             {
                 // Return default
-                aParameters[0].value.uint32_value = PVOMXVIDEODECNODE_CONFIG_MIMETYPE_DEF;
+                aParameters[0].value.pChar_value = (char*)PVMF_MIME_FORMAT_UNKNOWN;
             }
 
             break;
@@ -7858,9 +3234,10 @@
             if (aSetParam)
             {
                 iNodeConfig.iPostProcessingMode = aParameter.value.uint32_value;
-                if (iNodeConfig.iPostProcessingEnable && iOMXVideoDecoder)
+                if (iNodeConfig.iPostProcessingEnable && iOMXDecoder)
                 {
-
+                    // Don't do anything yet: Need to communicate post-processing to decoder
+                    //iVideoDecoder->SetPostProcType(iNodeConfig.iPostProcessingMode);
                 }
             }
             break;
@@ -7893,7 +3270,7 @@
                     return PVMFErrInvalidState;
                 }
 
-                iNodeConfig.iMimeType = aParameter.value.uint32_value;
+                iNodeConfig.iMimeType = aParameter.value.pChar_value;
             }
             break;
 
@@ -8131,7 +3508,7 @@
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXVideoDecNode::GetProfileAndLevel() In"));
 
-    if (NULL == iOMXVideoDecoder)
+    if (NULL == iOMXDecoder)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::GetProfileAndLevel() iVideoDecoder is Null"));
         aProfile = PV_MPEG_VIDEO_RESERVED_PROFILE;
@@ -8142,26 +3519,13 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::GetProfileAndLevel() iVideoDecoder is Null"));
     aProfile = PV_MPEG_VIDEO_RESERVED_PROFILE;
     aLevel	= PV_MPEG_VIDEO_LEVEL_UNKNOWN;
+    // FOR NOW, JUST RETURN FAILURE, WE DON'T SUPPORT THIS FEATURE YET
     return PVMFFailure;
 
 
 }
 
 
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecNode::LogDiagnostics()
-{
-    if (iDiagnosticsLogged == false)
-    {
-        iDiagnosticsLogged = true;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"));
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFOMXVideoDecNode - Number of YUV Frames Sent = %d", iSeqNum));
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFOMXVideoDecNode - TS of last decoded video frame = %d", iOutTimeStamp));
-    }
-}
-
-
-
 // DEFINITIONS for parsing the config information & sequence header for WMV
 
 #define GetUnalignedDword( pb, dw ) \
@@ -8191,18 +3555,21 @@
 #define SC_SEQ          0x0F
 #define SC_ENTRY        0x0E
 
+
 bool PVMFOMXVideoDecNode::VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
 {
-    // call this in case of WMV format
-    //return true;
+    // unused parameters
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(num_elements);
 
-    if (((PVMFOMXVideoDecPort*)iInPort)->iFormat == PVMF_WMV)
+    // call this in case of WMV format
+    if (((PVMFOMXDecPort*)iInPort)->iFormat == PVMF_MIME_WMV)
     {
 
         //verify bitrate
         if (pv_mime_strcmp(aParameters->key, PVMF_BITRATE_VALUE_KEY) == 0)
         {
-            if (((PVMFOMXVideoDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_BITRATE_VALUE_KEY, &(aParameters->value.uint32_value)) != PVMFSuccess)
+            if (((PVMFOMXDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_BITRATE_VALUE_KEY, &(aParameters->value.uint32_value)) != PVMFSuccess)
             {
                 return false;
             }
@@ -8210,7 +3577,7 @@
         }
         else if (pv_mime_strcmp(aParameters->key, PVMF_FRAMERATE_VALUE_KEY) == 0)
         {
-            if (((PVMFOMXVideoDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_FRAMERATE_VALUE_KEY, &(aParameters->value.uint32_value)) != PVMFSuccess)
+            if (((PVMFOMXDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_FRAMERATE_VALUE_KEY, &(aParameters->value.uint32_value)) != PVMFSuccess)
             {
                 return false;
             }
@@ -8246,29 +3613,40 @@
         if (((iNewWidth != (uint32)iYUVWidth) || (iNewHeight != (uint32)iYUVHeight)) && iOutPort != NULL)
         {
             // see if downstream node can handle the re-sizing
-            int32 errcode;
+            int32 errcode = OsclErrNone;
             OsclRefCounterMemFrag yuvFsiMemfrag;
-            OSCL_TRY(errcode, yuvFsiMemfrag = iYuvFsiFragmentAlloc.get());
+            OSCL_TRY(errcode, yuvFsiMemfrag = iFsiFragmentAlloc.get());
 
 
             OSCL_FIRST_CATCH_ANY(errcode, PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoDecNode::VerifyParametersSync() Failed to allocate memory for verifyParametersSync FSI")));
-            if (errcode == 0)
+            if (OsclErrNone == errcode)
             {
-                PVMFYuvFormatSpecificInfo0 * fsiInfo = (PVMFYuvFormatSpecificInfo0*)yuvFsiMemfrag.getMemFragPtr();
-                fsiInfo->video_format = PVMF_YUV420_PLANAR;
-                fsiInfo->uid = PVMFYuvFormatSpecificInfo0_UID;
-                fsiInfo->display_width = iNewWidth;
-                fsiInfo->display_height = iNewHeight;
-                fsiInfo->width = (iNewWidth + 3) & -4;
-                fsiInfo->height = iNewHeight;
+                PVMFYuvFormatSpecificInfo0* fsiInfo = OSCL_PLACEMENT_NEW(yuvFsiMemfrag.getMemFragPtr(), PVMFYuvFormatSpecificInfo0());
+                if (fsiInfo != NULL)
+                {
+                    fsiInfo->video_format = PVMF_MIME_YUV420;
+                    fsiInfo->uid = PVMFYuvFormatSpecificInfo0_UID;
+                    fsiInfo->display_width = iNewWidth;
+                    fsiInfo->display_height = iNewHeight;
+                    fsiInfo->width = (iNewWidth + 3) & -4;
+                    fsiInfo->height = iNewHeight;
 
+                    if (((PVMFOMXDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_FORMAT_SPECIFIC_INFO_KEY, &yuvFsiMemfrag) != PVMFSuccess)
+                    {
+                        fsiInfo->video_format.~PVMFFormatType();
+                        return false;
+                    }
+                    fsiInfo->video_format.~PVMFFormatType();
+                }
+                else
+                {
+                    return false;
+                }
             }
             else
+            {
                 return false;
-
-            if (((PVMFOMXVideoDecPort*)iOutPort)->verifyConnectedPortParametersSync(PVMF_FORMAT_SPECIFIC_INFO_KEY, &yuvFsiMemfrag) != PVMFSuccess)
-                return false;
-
+            }
         }
 
         pData += 4; //position ptr to Compression type
@@ -8454,14 +3832,8 @@
                 return false;
         }
 
-    } // end of if(format == PVMF_WMV)
+    } // end of if(format == PVMF_MIME_WMV)
     return true;
 }
 
 
-
-
-
-
-
-
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.h b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.h
index 849bb95..d6bcf50 100644
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.h
+++ b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,331 +18,43 @@
 #ifndef PVMF_OMX_VIDEODEC_NODE_H_INCLUDED
 #define PVMF_OMX_VIDEODEC_NODE_H_INCLUDED
 
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef PVMF_MEMPOOL_H_INCLUDED
-#include "pvmf_mempool.h"
-#endif
-
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-
-#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
-#include "pvmf_pool_buffer_allocator.h"
-#endif
-
 #ifndef PVMF_VIDEO_H_INCLUDED
 #include "pvmf_video.h"
 #endif
 
-#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
-#include "pvmf_pool_buffer_allocator.h"
-#endif
-
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
+#ifndef PVMF_OMX_BASEDEC_NODE_H_INCLUDED
+#include "pvmf_omx_basedec_node.h"
 #endif
 
 #ifndef PVMF_OMX_VIDEODEC_PORT_H_INCLUDED
-#include "pvmf_omx_videodec_port.h"
-#endif
-
-#ifndef PVMF_OMX_VIDEODEC_NODE_EXTENSION_INTERFACE_H_INCLUDED
-#include "pvmf_omx_videodec_node_extension_interface.h"
-#endif
-
-#ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
-#include "pvmf_meta_data_extension.h"
-#endif
-
-#ifndef PV_MIME_STRING_UTILS_H_INCLUDED
-#include "pv_mime_string_utils.h"
-#endif
-
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef PVMF_OMX_VIDEODEC_CALLBACKS_H_INCLUDED
-#include "pvmf_omx_videodec_callbacks.h"
-#endif
-
-
-#ifndef OSCLCONFIG_IO_H_INCLUDED
-#include "osclconfig_io.h"
-#endif
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
-#endif
+#include "pvmf_omx_basedec_port.h"
 #endif
 
 #define PVMFOMXVIDEODECNODE_NUM_CMD_IN_POOL 8
 #define PVOMXVIDEODECMAXNUMDPBFRAMESPLUS1 17
 
+#define PVOMX_VIDEO_DECODER_H264 "video_decoder.avc"
+#define PVOMX_VIDEO_DECODER_MPEG4 "video_decoder.mpeg4"
+#define PVOMX_VIDEO_DECODER_H263 "video_decoder.h263"
+#define PVOMX_VIDEO_DECODER_WMV "video_decoder.wmv"
 
-typedef struct OutputBufCtrlStruct
-{
-    OMX_BUFFERHEADERTYPE *pBufHdr;
-}OutputBufCtrlStruct;
-
-typedef struct InputBufCtrlStruct
-{
-    OMX_BUFFERHEADERTYPE *pBufHdr;
-    PVMFSharedMediaDataPtr pMediaData;
-} InputBufCtrlStruct;
-
-
-// fwd class declaration
-class PVLogger;
-//memory allocator type for this node.
-typedef OsclMemAllocator PVMFOMXVideoDecNodeAllocator;
-
-
-// CALLBACK PROTOTYPES
-OMX_ERRORTYPE CallbackEventHandler(OMX_OUT OMX_HANDLETYPE aComponent,
-                                   OMX_OUT OMX_PTR aAppData,
-                                   OMX_OUT OMX_EVENTTYPE aEvent,
-                                   OMX_OUT OMX_U32 aData1,
-                                   OMX_OUT OMX_U32 aData2,
-                                   OMX_OUT OMX_PTR aEventData);
-
-OMX_ERRORTYPE CallbackEmptyBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
-                                      OMX_OUT OMX_PTR aAppData,
-                                      OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-OMX_ERRORTYPE CallbackFillBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
-                                     OMX_OUT OMX_PTR aAppData,
-                                     OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-
-
-//Default values for number of Input/Output buffers. If the component needs more than this, it will be
-// negotiated. If the component does not need more than this number, the default is used
-#define NUMBER_INPUT_BUFFER 5
-#define NUMBER_OUTPUT_BUFFER 9
-
-// nal start code is 0001
-#define NAL_START_CODE_SIZE 4
-const unsigned char NAL_START_CODE[4] = {0, 0, 0, 1};
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////
-/////////////////////////
-/////////////////////////
-// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
-//						1) Deallocates the underlying output buffer
-//						2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
-//					  Deallocator is created as part of the wrapper, and travels with the buffer wrapper
-
-class PVOMXBufferSharedPtrWrapperCombinedCleanupDA : public OsclDestructDealloc
-{
-    public:
-        PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
-                buf_alloc(allocator), ptr_to_data_to_dealloc(pMempoolData) {};
-        virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
-
-        virtual void destruct_and_dealloc(OsclAny* ptr)
-        {
-            // call buffer deallocator
-            if (buf_alloc != NULL)
-            {
-                buf_alloc->deallocate(ptr_to_data_to_dealloc);
-            }
-
-            // finally, free the shared ptr wrapper memory
-            oscl_free(ptr);
-        }
-
-    private:
-        Oscl_DefAlloc* buf_alloc;
-        void *ptr_to_data_to_dealloc;
-};
-
-
-//typedef PVMFGenericNodeCommand<PVMFAVCDecNodeAllocator> PVMFAVCDecNodeCommandBase;
-#define PVMFOMXVideoDecNodeCommandBase PVMFGenericNodeCommand<PVMFOMXVideoDecNodeAllocator>  // to remove typedef warning on symbian
-
-class PVMFOMXVideoDecNodeCommand: public PVMFOMXVideoDecNodeCommandBase
-{
-    public:
-        //constructor for Custom2 command
-        void Construct(PVMFSessionId s, int32 cmd, int32 arg1, int32 arg2, int32& arg3, const OsclAny*aContext)
-        {
-            PVMFOMXVideoDecNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)arg1;
-            iParam2 = (OsclAny*)arg2;
-            iParam3 = (OsclAny*) & arg3;
-        }
-        void Parse(int32&arg1, int32&arg2, int32*&arg3)
-        {
-            arg1 = (int32)iParam1;
-            arg2 = (int32)iParam2;
-            arg3 = (int32*)iParam3;
-        }
-
-        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, uint32 aStartIndex, int32 aMaxEntries, char* aQueryKey, const OsclAny* aContext)
-        {
-            PVMFOMXVideoDecNodeCommandBase::Construct(s, cmd, aContext);
-            iStartIndex = aStartIndex;
-            iMaxEntries = aMaxEntries;
-
-            if (aQueryKey == NULL)
-            {
-                query_key[0] = 0;
-            }
-            else
-            {
-                if (aQueryKey != NULL)
-                    oscl_strncpy(query_key, aQueryKey, oscl_strlen(aQueryKey) + 1);
-            }
-
-            iParam1 = (OsclAny*)aKeyList;
-            iParam2 = NULL;
-            iParam3 = NULL;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        }
-
-        void Parse(PVMFMetadataList*& MetaDataListPtr, uint32 &aStartingIndex, int32 &aMaxEntries, char*&aQueryKey)
-        {
-            MetaDataListPtr = (PVMFMetadataList*)iParam1;
-            aStartingIndex = iStartIndex;
-            aMaxEntries = iMaxEntries;
-            if (query_key[0] == 0)
-            {
-                aQueryKey = NULL;
-            }
-            else
-            {
-                aQueryKey = query_key;
-            }
-        }
-
-        // Constructor and parser for GetNodeMetadataValue
-        void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList* aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, uint32 aStartIndex, int32 aMaxEntries, const OsclAny* aContext)
-        {
-            PVMFOMXVideoDecNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aKeyList;
-            iParam2 = (OsclAny*)aValueList;
-
-            iStartIndex = aStartIndex;
-            iMaxEntries = aMaxEntries;
-
-            iParam3 = NULL;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        }
-        void Parse(PVMFMetadataList* &aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList, uint32 &aStartingIndex, int32 &aMaxEntries)
-        {
-            aKeyList = (PVMFMetadataList*)iParam1;
-            aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
-            aStartingIndex = iStartIndex;
-            aMaxEntries = iMaxEntries;
-        }
-
-        virtual bool hipri()
-        {	//this routine identifies commands that need to
-            //go at the front of the queue.  derived command
-            //classes can override it if needed.
-            return (iCmd == PVOMXVIDEODEC_NODE_CMD_CANCELALL
-                    || iCmd == PVOMXVIDEODEC_NODE_CMD_CANCELCMD);
-        }
-
-        enum PVOMXVideoDecNodeCmdType
-        {
-            PVOMXVIDEODEC_NODE_CMD_QUERYUUID,
-            PVOMXVIDEODEC_NODE_CMD_QUERYINTERFACE,
-            PVOMXVIDEODEC_NODE_CMD_INIT,
-            PVOMXVIDEODEC_NODE_CMD_PREPARE,
-            PVOMXVIDEODEC_NODE_CMD_REQUESTPORT,
-            PVOMXVIDEODEC_NODE_CMD_START,
-            PVOMXVIDEODEC_NODE_CMD_PAUSE,
-            PVOMXVIDEODEC_NODE_CMD_STOP,
-            PVOMXVIDEODEC_NODE_CMD_FLUSH,
-            PVOMXVIDEODEC_NODE_CMD_RELEASEPORT,
-            PVOMXVIDEODEC_NODE_CMD_RESET,
-            PVOMXVIDEODEC_NODE_CMD_CANCELCMD,
-            PVOMXVIDEODEC_NODE_CMD_CANCELALL,
-            PVOMXVIDEODEC_NODE_CMD_INVALID,
-            PVOMXVIDEODEC_NODE_CMD_GETNODEMETADATAKEY,
-            PVOMXVIDEODEC_NODE_CMD_GETNODEMETADATAVALUE
-        };
-
-    private:
-        uint32 iStartIndex;
-        uint32 iMaxEntries;
-        char query_key[256];
-
-};
-
-//Default vector reserve size
-#define PVMF_OMXVIDEODEC_NODE_COMMAND_VECTOR_RESERVE 10
-
-//Starting value for command IDs
-#define PVMF_OMXVIDEODEC_NODE_COMMAND_ID_START 6000
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////
-//CAPABILITY AND CONFIG
-
-// Structure to hold the key string info for
-// videodecnode's capability-and-config
-struct PVOMXVideoDecNodeKeyStringData
-{
-    char iString[64];
-    PvmiKvpType iType;
-    PvmiKvpValueType iValueType;
-};
-
-// The number of characters to allocate for the key string
 #define PVOMXVIDEODECNODECONFIG_KEYSTRING_SIZE 128
 
 // Key string info at the base level ("x-pvmf/video/decoder")
 #define PVOMXVIDEODECNODECONFIG_BASE_NUMKEYS 6
-const PVOMXVideoDecNodeKeyStringData PVOMXVideoDecNodeConfigBaseKeys[PVOMXVIDEODECNODECONFIG_BASE_NUMKEYS] =
+const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigBaseKeys[PVOMXVIDEODECNODECONFIG_BASE_NUMKEYS] =
 {
     {"postproc_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
     {"postproc_type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BITARRAY32},
     {"dropframe_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
     {"h263", PVMI_KVPTYPE_AGGREGATE, PVMI_KVPVALTYPE_KSV},
     {"m4v", PVMI_KVPTYPE_AGGREGATE, PVMI_KVPVALTYPE_KSV},
-    {"format-type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
+    {"format-type", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}
 };
 
 // Key string info at the h263 level ("x-pvmf/video/decoder/h263")
 #define PVOMXVIDEODECNODECONFIG_H263_NUMKEYS 2
-const PVOMXVideoDecNodeKeyStringData PVOMXVideoDecNodeConfigH263Keys[PVOMXVIDEODECNODECONFIG_H263_NUMKEYS] =
+const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigH263Keys[PVOMXVIDEODECNODECONFIG_H263_NUMKEYS] =
 {
     {"maxbitstreamframesize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"maxdimension", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_UINT32}
@@ -350,7 +62,7 @@
 
 // Key string info at the m4v level ("x-pvmf/video/decoder/m4v")
 #define PVOMXVIDEODECNODECONFIG_M4V_NUMKEYS 2
-const PVOMXVideoDecNodeKeyStringData PVOMXVideoDecNodeConfigM4VKeys[PVOMXVIDEODECNODECONFIG_M4V_NUMKEYS] =
+const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigM4VKeys[PVOMXVIDEODECNODECONFIG_M4V_NUMKEYS] =
 {
     {"maxbitstreamframesize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"maxdimension", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_UINT32}
@@ -358,7 +70,7 @@
 
 // Key string info at the render level ("x-pvmf/video/render")
 #define PVOMXVIDEODECNODECONFIG_RENDER_NUMKEYS 2
-const PVOMXVideoDecNodeKeyStringData PVOMXVideoDecNodeConfigRenderKeys[PVOMXVIDEODECNODECONFIG_RENDER_NUMKEYS] =
+const PVOMXBaseDecNodeKeyStringData PVOMXVideoDecNodeConfigRenderKeys[PVOMXVIDEODECNODECONFIG_RENDER_NUMKEYS] =
 {
     {"width", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
     {"height", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
@@ -411,18 +123,8 @@
 #define PVMF_OMX_VIDEO_DEC_NODE_MIMETYPE "pvxxx/OMXVideoDecNode"
 #define PVMF_BASEMIMETYPE "pvxxx"
 
-//Command queue type
-typedef PVMFNodeCommandQueue<PVMFOMXVideoDecNodeCommand, PVMFOMXVideoDecNodeAllocator> PVMFOMXVideoDecNodeCmdQ;
-
-
 class PVMFOMXVideoDecNode
-            : public OsclActiveObject
-            , public PVMFNodeInterface
-            , public OsclMemPoolFixedChunkAllocatorObserver
-            , public PVMFOMXVideoDecNodeExtensionInterface
-            , public PVMFMetadataExtensionInterface
-            , public PvmiCapabilityAndConfig
-
+            : public PVMFOMXBaseDecNode
 {
     public:
         PVMFOMXVideoDecNode(int32 aPriority);
@@ -430,76 +132,12 @@
 
         // From PVMFNodeInterface
         PVMFStatus ThreadLogon();
-        PVMFStatus ThreadLogoff();
-        PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
-        PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
-        PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType,
-                                Oscl_Vector<PVUuid, PVMFOMXVideoDecNodeAllocator>& aUuids,
-                                bool aExactUuidsOnly = false,
-                                const OsclAny* aContext = NULL);
-        PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
-                                     PVInterface*& aInterfacePtr,
-                                     const OsclAny* aContext = NULL);
-        PVMFCommandId RequestPort(PVMFSessionId
-                                  , int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL);
-        PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
-        PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL);
-        PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL);
-        PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-        // From PVInterface
-        virtual void addRef();
-        virtual void removeRef();
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        virtual PVMFStatus SetDecoderNodeConfiguration(PVMFOMXVideoDecNodeConfig& aConfig);
 
         //**********begin PVMFMetadataExtensionInterface
         uint32 GetNumMetadataKeys(char* query_key = NULL);
         uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
-        PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 starting_index, int32 max_entries,
-                                          char* query_key = NULL, const OsclAny* aContextData = NULL);
-        PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList,
-                                            Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, int32 max_entries, const OsclAny* aContextData = NULL);
-        PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, uint32 starting_index, uint32 end_index);
-        PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 starting_index, uint32 end_index);
         //**********End PVMFMetadataExtensionInterface
 
-        bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-
-        //********** CB Functions to serve OpenMAX Decoder
-
-        //Process callback functions. They will be executed in testapp thread context
-        //	These callbacks are used only in the Multithreaded component case
-        OsclReturnCode ProcessCallbackEventHandler_MultiThreaded(OsclAny* P);
-        OsclReturnCode ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P);
-        OsclReturnCode ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P);
-
-        //Callback objects - again, these are used only in the case of Multithreaded component
-        EventHandlerThreadSafeCallbackAO*	 iThreadSafeHandlerEventHandler;
-        EmptyBufferDoneThreadSafeCallbackAO* iThreadSafeHandlerEmptyBufferDone;
-        FillBufferDoneThreadSafeCallbackAO*  iThreadSafeHandlerFillBufferDone;
-
-        OMX_CALLBACKTYPE       iCallbacks; // structure that contains callback ptrs.
-        // OMX CALLBACKS
-        // 1) AO OMX component running in the same thread as the OMX node
-        //	In this case, the callbacks can be called directly from the component
-        //	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
-        //	The callback can perform do RunIfNotReady
-
-        // 2) Multithreaded component
-        //	In this case, the callback is made using the threadsafe callback (TSCB) AO
-        //	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent)
-        //  Node thread		 : TSCB(ProcessEvent)->ProcessCallbackEventHandler_MultiThreaded->EventHandlerProcessing
-
 
         //==============================================================================
 
@@ -510,114 +148,29 @@
                                              OMX_OUT OMX_U32 aData2,
                                              OMX_OUT OMX_PTR aEventData);
 
-        OMX_ERRORTYPE EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-                                                OMX_OUT OMX_PTR aAppData,
-                                                OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
+        // for WMV params
+        bool VerifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+    protected:
 
-        OMX_ERRORTYPE FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-                                               OMX_OUT OMX_PTR aAppData,
-                                               OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-
-
-        bool IsComponentMultiThreaded()
-        {
-            return iIsOMXComponentMultiThreaded;
-        };
-
-
-        // From PvmiCapabilityAndConfig
-        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
-        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
-        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements);
-        void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
-        PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext = NULL);
-        uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
-
-
-
-
-    private:
-        void CommandComplete(PVMFOMXVideoDecNodeCmdQ& aCmdQ, PVMFOMXVideoDecNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData = NULL);
-
-        void DoQueryUuid(PVMFOMXVideoDecNodeCommand&);
-        void DoQueryInterface(PVMFOMXVideoDecNodeCommand&);
-        void DoRequestPort(PVMFOMXVideoDecNodeCommand&);
-        void DoReleasePort(PVMFOMXVideoDecNodeCommand&);
-        void DoInit(PVMFOMXVideoDecNodeCommand&);
-        void DoPrepare(PVMFOMXVideoDecNodeCommand&);
-        void DoStart(PVMFOMXVideoDecNodeCommand&);
-        void DoStop(PVMFOMXVideoDecNodeCommand&);
-        void DoPause(PVMFOMXVideoDecNodeCommand&);
-        void DoReset(PVMFOMXVideoDecNodeCommand&);
-        void DoFlush(PVMFOMXVideoDecNodeCommand&);
-        PVMFStatus DoGetNodeMetadataKey(PVMFOMXVideoDecNodeCommand&);
-        PVMFStatus DoGetNodeMetadataValue(PVMFOMXVideoDecNodeCommand&);
-        void DoCancelAllCommands(PVMFOMXVideoDecNodeCommand&);
-        void DoCancelCommand(PVMFOMXVideoDecNodeCommand&);
-
-        void Run();
-        bool ProcessCommand(PVMFOMXVideoDecNodeCommand& aCmd);
-        bool ProcessIncomingMsg(PVMFPortInterface* aPort);
-        bool ProcessOutgoingMsg(PVMFPortInterface* aPort);
-        PVMFStatus HandleProcessingState();
+        void DoQueryUuid(PVMFOMXBaseDecNodeCommand&);
+        void DoRequestPort(PVMFOMXBaseDecNodeCommand&);
+        void DoReleasePort(PVMFOMXBaseDecNodeCommand&);
+        PVMFStatus DoGetNodeMetadataKey(PVMFOMXBaseDecNodeCommand&);
+        PVMFStatus DoGetNodeMetadataValue(PVMFOMXBaseDecNodeCommand&);
+        PVMFStatus HandlePortReEnable();
 
         bool InitDecoder(PVMFSharedMediaDataPtr&);
 
         bool NegotiateComponentParameters();
-        bool SetDefaultCapabilityFlags();
-        bool CreateOutMemPool(uint32 num);
-        bool CreateInputMemPool(uint32 num);
-        bool ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-                                       uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                       uint32 aNumBuffers,    // number of buffers
-                                       uint32 aActualBufferSize, // aactual buffer size
-                                       uint32 aPortIndex,      // port idx
-                                       bool aUseBufferOK,	// can component use OMX_UseBuffer?
-                                       bool	aIsThisInputBuffer // is this input or output
-                                      );
-
-        bool FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-                                      uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-                                      uint32 aNumBuffers,    // number of buffers
-                                      uint32 aPortIndex,      // port idx
-                                      bool	aIsThisInputBuffer		// is this input or output
-                                     );
-
-        OsclSharedPtr<class PVMFMediaDataImpl> WrapOutputBuffer(uint8 *pData, uint32 aDataLen, OsclAny *pContext);
+        bool GetSetCodecSpecificInfo();
         bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout, uint32 aDataLen);
 
-        bool SendOutputBufferToOMXComponent();
-        bool SendInputBufferToOMXComponent();
-
-        bool SendConfigBufferToOMXComponent(uint8 *initbuffer, uint32 initbufsize);
-        bool SendEOSBufferToOMXComponent();
-
-        bool HandleRepositioning(void);
-        bool SendBeginOfMediaStreamCommand(void);
-        bool SendEndOfTrackCommand(void);
-
-
-
         bool ReleaseAllPorts();
-        bool DeleteOMXVideoDecoder();
-
-        void ChangeNodeState(TPVMFNodeInterfaceState aNewState);
-
-        void HandleComponentStateChange(OMX_U32 decoder_state);
-
-
-
         // Capability And Config Helper Methods
         PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
         PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements);
         void DoCapConfigSetParameters(PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
         PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
-
         PVMFStatus DoGetVideoDecNodeParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
         PVMFStatus DoGetH263DecoderParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
         PVMFStatus DoGetM4VDecoderParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
@@ -628,186 +181,9 @@
         PVMFStatus GetProfileAndLevel(PVMF_MPEGVideoProfileType& aProfile, PVMF_MPEGVideoLevelType& aLevel);
         int32 GetNAL_OMXNode(uint8** bitstream, int* size);
 
-        // From OsclMemPoolFixedChunkAllocatorObserver
-        void freechunkavailable(OsclAny*);
-
-        PVMFCommandId QueueCommandL(PVMFOMXVideoDecNodeCommand& aCmd);
-
-
-        friend class PVMFOMXVideoDecPort;
-
-        // Ports pointers
-        PVMFPortInterface* iInPort;
-        PVMFPortInterface* iOutPort;
-
-        // Commands
-        PVMFOMXVideoDecNodeCmdQ iInputCommands;
-        PVMFOMXVideoDecNodeCmdQ iCurrentCommand;
-
-        // Shared pointer for Media Msg.Input buffer
-        PVMFSharedMediaDataPtr iDataIn;
-
-
-        // OUTPUT BUFFER RELATED MEMBERS
-
-
-        // Output buffer memory pool
-        OsclMemPoolFixedChunkAllocator *iOutBufMemoryPool;
-        //PVOMXBufferAllocatorImplementation *iOutBufMemoryPool;
-        // Memory pool for simple media data
-        OsclMemPoolFixedChunkAllocator *iMediaDataMemPool;
-
-        // Fragment pool for YUV format specific info
-        PVMFBufferPoolAllocator iYuvFsiFragmentAlloc;
-        // Fragment pool for private data format specific info
-        PVMFBufferPoolAllocator iPrivateDataFsiFragmentAlloc;
-
-
-
-        // Size of output buffer (negotiated with component)
-        uint32 iOMXComponentOutputBufferSize;
-
-        // size of output to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
-        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentOutputBufferSize)
-        uint32 iOutputAllocSize;
-
-        // Number of output buffers (negotiated with component)
-        uint32 iNumOutputBuffers;
-
-        // Number of output buffers in possession of the component or downstream,
-        // namely, number of unavailable buffers
-        uint32 iNumOutstandingOutputBuffers;
-
-        // flag to prevent sending output buffers downstream during flushing etc.
-        bool iDoNotSendOutputBuffersDownstreamFlag;
-
-        // flag to prevent freeing the buffers twice
-        bool iOutputBuffersFreed;
-
-        // ptr to private data to be sent with output buffer
-        OMX_PTR ipPrivateData;
-
-        // INPUT BUFFER RELATED MEMBERS
-        OsclMemPoolFixedChunkAllocator *iInBufMemoryPool;
-        uint32 iOMXComponentInputBufferSize; // size of input buffer that the component sees (negotiated with the component)
-        uint32 iInputAllocSize; 	// size of input buffer to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
-        // (OMX_USE_BUFFER = size of buf header + iOMXCoponentInputBufferSize)
-        uint32 iNumInputBuffers; // total num of input buffers (negotiated with component)
-
-        uint32 iNumOutstandingInputBuffers; // number of input buffers in use (i.e. unavailable)
-
-        bool iDoNotSaveInputBuffersFlag;
-
-        // flag to prevent freeing buffers twice
-        bool iInputBuffersFreed;
-
-        // input buffer fragmentation etc.
-        uint32 iCopyPosition;				// for copying memfrag data into a buffer
-        uint32 iFragmentSizeRemainingToCopy;
-        bool	iIsNewDataFragment;
-        // partial frame assembly logic flags
-        bool	iFirstPieceOfPartialFrame;
-        bool	iObtainNewInputBuffer;
-        bool	iKeepDroppingMsgsUntilMarkerBit;
-        bool	iFirstDataMsgAfterBOS;
-
-        bool iCONFIGFRAMESENT;
-
-        InputBufCtrlStruct *iInputBufferUnderConstruction;
-
-        void DropCurrentBufferUnderConstruction();
-        void SendIncompleteBufferUnderConstruction();
-
-        // input data info
-        uint32 iCurrFragNum;
-        uint32 iCodecSeqNum;	// sequence number tracking
-        uint32 iInPacketSeqNum;
-
-        uint32 iInTimestamp;
-        uint32 iInDuration;
-        uint32 iInNumFrags;
-        uint32 iCurrentMsgMarkerBit;
-
-        // DYNAMIC PORT RE-CONFIGURATION
-        uint32 iInputPortIndex;
-        uint32 iOutputPortIndex;
-        OMX_PARAM_PORTDEFINITIONTYPE iParamPort;
-        uint32 iPortIndexForDynamicReconfig;
-        bool iSecondPortReportedChange;
-        bool iDynamicReconfigInProgress;
-        uint32 iSecondPortToReconfig;
-        bool iPauseCommandWasSentToComponent;
-        bool iStopCommandWasSentToComponent;
-
-
         OMX_COLOR_FORMATTYPE iOMXVideoColorFormat;
-
-        OMX_BUFFERHEADERTYPE *iInputBufferToResendToComponent; // ptr to input buffer that is not empty, but that the OMX component returned
-        // we need to resend this same buffer back to the component
-
-
-        ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS
-        bool iOMXComponentSupportsExternalOutputBufferAlloc;
-        bool iOMXComponentSupportsExternalInputBufferAlloc;
-        bool iOMXComponentSupportsMovableInputBuffers;
-        bool iSetMarkerBitForEveryFrag; // is every fragment complete frame (AVC file playback = each fragment is a NAL)
-        bool iIsOMXComponentMultiThreaded;
-        bool iOMXComponentSupportsPartialFrames;
-        bool iOMXComponentNeedsNALStartCode;
-        bool iOMXComponentCanHandleIncompleteFrames;
-
-        // State definitions for HandleProcessingState() state machine
-        typedef enum
-        {
-            EPVMFOMXVideoDecNodeProcessingState_Idle,                  //default state after constraction/reset
-            EPVMFOMXVideoDecNodeProcessingState_InitDecoder,           //initialization of H264 decoder after handle was obtained
-            EPVMFOMXVideoDecNodeProcessingState_WaitForInitCompletion, // waiting for init completion
-            EPVMFOMXVideoDecNodeProcessingState_ReadyToDecode,         //nornal operation state of the decoder
-            EPVMFOMXVideoDecNodeProcessingState_WaitForOutputBuffer,   //wait state for avalible media output buffer
-            EPVMFOMXVideoDecNodeProcessingState_WaitForOutputPort,     //wait state, output port is busy
-            EPVMFOMXVideoDecNodeProcessingState_WaitForOutgoingQueue,   //wait state, outgoing queue
-            EPVMFOMXVideoDecNodeProcessingState_PortReconfig,			// Dynamic Port Reconfiguration - step 1
-            EPVMFOMXVideoDecNodeProcessingState_WaitForBufferReturn,		//	step 2
-            EPVMFOMXVideoDecNodeProcessingState_WaitForPortDisable,		// Dynamic Port Reconfiguration - step 3
-            EPVMFOMXVideoDecNodeProcessingState_PortReEnable,			// Dynamic Port Reconfiguration - step 4
-            EPVMFOMXVideoDecNodeProcessingState_WaitForPortEnable,		// step 5
-            EPVMFOMXVideoDecNodeProcessingState_Stopping,				// when STOP command is issued, the node has to wait for component to transition into
-            // idle state. The buffers keep coming back , the node is rescheduled
-            // to run. Prevent the node from sending buffers back
-
-            EPVMFOMXVideoDecNodeProcessingState_Pausing					// when PAUSE command is issued, the node has to wait for component to transition into
-            // paused state. The buffers may still keep coming back , the node is rescheduled
-            // to run. Prevent the node from sending buffers back to component
-        } PVMFOMXVideoDecNode_ProcessingState;
-
-        // State of HandleProcessingState() state machine
-        PVMFOMXVideoDecNode_ProcessingState iProcessingState;
-
-        // Handle of OMX Component
-        OMX_HANDLETYPE iOMXVideoDecoder;
-
-        // Current State of the component
-        OMX_STATETYPE iCurrentDecoderState;
-
-        // BOS
-        bool iSendBOS;
-        uint32 iStreamID;
-        uint32 iBOSTimestamp;
-
-        //EOS control flags
-        bool iIsEOSSentToComponent;
-        bool iIsEOSReceivedFromComponent;
-
-        // repositioning related flags
-        bool iIsRepositioningRequestSentToComponent;
-        bool iIsRepositionDoneReceivedFromComponent;
-        bool iIsOutputPortFlushed;
-        bool iIsInputPortFlushed;
-
-        // Send Fsi configuration flag
-        bool	sendYuvFsi;
-
-        PvmfFormatIndex iYUVFormat;
+        OMX_VIDEO_CODINGTYPE iOMXVideoCompressionFormat;
+        PVMFFormatType iYUVFormat;
         // Width of decoded frame
         int32 iYUVWidth;
         // Height of decoded frame
@@ -817,63 +193,6 @@
         // Last stored value of hight
         int32 iLastYUVHeight;
 
-
-        // Pointer to input data fragment
-        uint8* iBitstreamBuffer;
-        // Size of input data fragment
-        int32 iBitstreamSize;
-
-        // Output frame sequence counter
-        uint32 iSeqNum;
-
-        // Input frame sequence counter
-        uint32 iSeqNum_In;
-
-        // Added to Scheduler Flag
-        bool iIsAdded;
-
-        // Log related
-        PVLogger* iLogger;
-        PVLogger* iDataPathLogger;
-        PVLogger* iClockLogger;
-        PVLogger *iRunlLogger;
-
-        // Counter of fragment read from current Media Msg.Input buffer
-        uint fragnum;
-        // Number of fragments in the Media Msg.Input buffer
-        uint numfrags;
-
-        // Time stamp to be used on output buffer
-        uint32 iOutTimeStamp;
-
-        // Node configuration update
-        PVMFOMXVideoDecNodeConfig iNodeConfig;
-
-        // Capability exchange
-        PVMFNodeCapability iCapability;
-
-        // Reference counter for extension
-        uint32 iExtensionRefCount;
-
-        // Vector for KVP
-        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
-
-        // EOS flag
-        bool iEndOfDataReached;
-        // Time stame upon EOS
-        PVMFTimestamp iEndOfDataTimestamp;
-
-        /* Diagnostic log related */
-        PVLogger* iDiagnosticsLogger;
-        bool iDiagnosticsLogged;
-        void LogDiagnostics();
-
-        uint32 iFrameCounter;
-        uint32 iInFrameSent;
-        uint32 iInFrameReceived;
-        uint32 iOutFrameSent;
-        uint32 iOutFrameReceived;
-
         uint32 iH263MaxBitstreamFrameSize;
         uint32 iH263MaxWidth;
         uint32 iH263MaxHeight;
@@ -883,9 +202,6 @@
 
         uint32 iNewWidth , iNewHeight;
 
-        uint32 iAvgBitrateValue;
-        bool iResetInProgress;
-        bool iResetMsgSent;
 };
 
 
diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_port.cpp b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_port.cpp
deleted file mode 100644
index 67de378..0000000
--- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_port.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_omx_videodec_port.h"
-#include "pvmf_omx_videodec_node.h"
-
-
-PVMFOMXVideoDecPort::PVMFOMXVideoDecPort(int32 aTag, PVMFNodeInterface* aNode, const char*name)
-        : PvmfPortBaseImpl(aTag, aNode, name)
-{
-    iOMXNode = (PVMFOMXVideoDecNode *) aNode;
-    Construct();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecPort::Construct()
-{
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXVideoDecPort");
-    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
-    iNumFramesGenerated = 0;
-    iNumFramesConsumed = 0;
-    iTrackConfig = NULL;
-    iTrackConfigSize = 0;
-    PvmiCapabilityAndConfigPortFormatImpl::Construct(
-        PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS
-        , PVMF_OMX_VIDEO_DEC_PORT_INPUT_FORMATS_VALTYPE);
-}
-
-
-PVMFOMXVideoDecPort::~PVMFOMXVideoDecPort()
-{
-    if (iTrackConfig != NULL)
-    {
-        OSCL_FREE(iTrackConfig);
-        iTrackConfigSize = 0;
-    }
-
-    Disconnect();
-    ClearMsgQueues();
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoDecPort::IsFormatSupported(PVMFFormatType aFmt)
-{
-    return ((aFmt == PVMF_YUV420) || (aFmt == PVMF_H264_RAW) || (aFmt == PVMF_H264_MP4) || (aFmt == PVMF_H264) || (aFmt == PVMF_M4V) || (aFmt == PVMF_H263)
-            || (aFmt == PVMF_WMV)
-           );
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoDecPort::FormatUpdated()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFOMXVideoDecPort::FormatUpdated %d", iFormat));
-}
-
-bool
-PVMFOMXVideoDecPort::pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag)
-{
-    if ((iConnectedPort) &&
-            (iTag == PVMF_OMX_VIDEO_DEC_NODE_PORT_TYPE_SINK))
-    {
-        PvmiCapabilityAndConfig *config = NULL;
-        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                       (OsclAny*&)config);
-
-        /*
-         * Create PvmiKvp for capability settings
-         */
-        if ((config) && (aMemFrag.getMemFragSize() > 0))
-        {
-            OsclMemAllocator alloc;
-            PvmiKvp kvp;
-            kvp.key = NULL;
-            kvp.length = oscl_strlen(PVMF_FORMAT_SPECIFIC_INFO_KEY) + 1; // +1 for \0
-            kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
-            if (kvp.key == NULL)
-            {
-                return false;
-            }
-            oscl_strncpy(kvp.key, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp.length);
-
-            kvp.value.key_specific_value = (OsclAny*)(aMemFrag.getMemFragPtr());
-            kvp.capacity = aMemFrag.getMemFragSize();
-            PvmiKvp* retKvp = NULL; // for return value
-            int32 err;
-            OSCL_TRY(err, config->setParametersSync(NULL, &kvp, 1, retKvp););
-            /* ignore the error for now */
-            alloc.deallocate((OsclAny*)(kvp.key));
-        }
-        return true;
-    }
-    return false;
-}
-
-PVMFStatus PVMFOMXVideoDecPort::Connect(PVMFPortInterface* aPort)
-{
-    if (!aPort)
-    {
-        return PVMFErrArgument;
-    }
-
-    if (iConnectedPort)
-    {
-        return PVMFFailure;
-    }
-
-    PvmiCapabilityAndConfig *config;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-
-    if (config != NULL)
-    {
-        PvmiKvp kv;
-        PvmiKvp* kvp = &kv;
-        int numKvp = 0;
-        PVMFStatus status =
-            config->getParametersSync(NULL, (PvmiKeyType)PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp, numKvp, NULL);
-        if (status == PVMFSuccess)
-        {
-            if (iTrackConfig != NULL)
-            {
-                OSCL_FREE(iTrackConfig);
-                iTrackConfigSize = 0;
-            }
-            if (kvp)
-            {
-                iTrackConfigSize = kvp->capacity;
-                iTrackConfig = (uint8*)(OSCL_MALLOC(sizeof(uint8) * iTrackConfigSize));
-                oscl_memcpy(iTrackConfig, kvp->value.key_specific_value, iTrackConfigSize);
-            }
-
-            config->releaseParameters(NULL, kvp, numKvp);
-        }
-
-    }
-
-    // Automatically connect the peer.
-
-    if (aPort->PeerConnect(this) != PVMFSuccess)
-    {
-        return PVMFFailure;
-    }
-
-    iConnectedPort = aPort;
-    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
-    return PVMFSuccess;
-}
-
-void PVMFOMXVideoDecPort::setParametersSync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int num_elements,
-        PvmiKvp * & aRet_kvp)
-{
-
-    // if port connect needs format specific info
-    if (aParameters && pv_mime_strcmp(aParameters->key, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
-    {
-        if (iTrackConfig != NULL)
-        {
-            OSCL_FREE(iTrackConfig);
-            iTrackConfigSize = 0;
-        }
-        iTrackConfigSize = aParameters->capacity;
-        iTrackConfig = (uint8*)(OSCL_MALLOC(sizeof(uint8) * iTrackConfigSize));
-        oscl_memcpy(iTrackConfig, aParameters->value.key_specific_value, iTrackConfigSize);
-        return;
-    }
-    // call the base class function
-    PvmiCapabilityAndConfigPortFormatImpl::setParametersSync(aSession, aParameters, num_elements, aRet_kvp);
-
-}
-
-
-
-
-PVMFStatus PVMFOMXVideoDecPort::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
-{
-
-    OSCL_UNUSED_ARG(aSession);
-
-    // in case of WMV call the Node verify to make sure that the parameters are OK
-    // (the node will also make sure that the downstream node is OK with the change
-    // if necessary)
-    if (iFormat == PVMF_WMV)
-    {
-        if (iOMXNode->VerifyParametersSync(aSession, aParameters, num_elements))
-        {
-            return PVMFSuccess;
-        }
-        else
-        {
-            return PVMFErrNotSupported;
-        }
-    }
-    else
-    {
-        return PVMFSuccess;
-    }
-}
-
-PVMFStatus PVMFOMXVideoDecPort::verifyConnectedPortParametersSync(const char* aFormatValType,
-        OsclAny* aConfig)
-{
-    PVMFStatus status = PVMFErrNotSupported;
-    PvmiCapabilityAndConfig *capConfig;
-    if (iConnectedPort)
-    {
-        iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                       (OsclAny*&)capConfig);
-    }
-    else
-        return PVMFFailure;
-
-    if (capConfig != NULL)
-    {
-        if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
-        {
-            OsclRefCounterMemFrag* aFormatValue = (OsclRefCounterMemFrag*)aConfig;
-            if (aFormatValue->getMemFragSize() > 0)
-            {
-                OsclMemAllocator alloc;
-                PvmiKvp kvp;
-                kvp.key = NULL;
-                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
-                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
-                if (kvp.key == NULL)
-                {
-                    return PVMFErrNoMemory;
-                }
-                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
-
-                kvp.value.key_specific_value = (OsclAny*)(aFormatValue->getMemFragPtr());
-                kvp.capacity = aFormatValue->getMemFragSize();
-                int32 err;
-                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
-                /* ignore the error for now */
-                alloc.deallocate((OsclAny*)(kvp.key));
-
-                return status;
-            }
-        }
-        else if (pv_mime_strcmp(aFormatValType, PVMF_BITRATE_VALUE_KEY) == 0 ||
-                 pv_mime_strcmp(aFormatValType, PVMF_FRAMERATE_VALUE_KEY) == 0)
-        {
-            if (aConfig != NULL)
-            {
-                OsclMemAllocator alloc;
-                PvmiKvp kvp;
-                kvp.key = NULL;
-                kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
-                kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
-                if (kvp.key == NULL)
-                {
-                    return PVMFErrNoMemory;
-                }
-                oscl_strncpy(kvp.key, aFormatValType, kvp.length);
-                uint32* bitrate = (uint32*)aConfig;
-                kvp.value.uint32_value = *bitrate;
-
-                int32 err;
-                OSCL_TRY(err, status = capConfig->verifyParametersSync(NULL, &kvp, 1););
-                /* ignore the error for now */
-                alloc.deallocate((OsclAny*)(kvp.key));
-
-                return status;
-            }
-        }
-        return PVMFErrArgument;
-    }
-    return PVMFFailure;
-}
-
-
-
-
diff --git a/nodes/pvomxvideoencnode/Android.mk b/nodes/pvomxvideoencnode/Android.mk
deleted file mode 100644
index 65b4a3c..0000000
--- a/nodes/pvomxvideoencnode/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/pvmf_omx_videoenc_port.cpp \
-	src/pvmf_omx_videoenc_node.cpp \
-	src/pvmf_omx_videoenc_node_cap_config.cpp \
-	src/pvmf_omx_videoenc_callbacks.cpp
-
-
-
-LOCAL_MODULE := libpvomxvideoencnode
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)/nodes/pvvideoencnode/include \
-	$(PV_TOP)/nodes/pvvideoencnode/src \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/pvmf_omx_videoenc_node_factory.h \
-	include/pvmf_omx_videoenc_node_types.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvomxvideoencnode/include/pvmf_omx_videoenc_node_factory.h b/nodes/pvomxvideoencnode/include/pvmf_omx_videoenc_node_factory.h
deleted file mode 100644
index 575908a..0000000
--- a/nodes/pvomxvideoencnode/include/pvmf_omx_videoenc_node_factory.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_NODE_FACTORY_H_INCLUDED
-#define PVMF_OMX_VIDEOENC_NODE_FACTORY_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-// Forward declarations
-class PVMFNodeInterface;
-
-/** Uuid of PV Video Encoder Node */
-#define PVMFOMXVideoEncNodeUuid PVUuid(0xbb4d38d1,0xcc90,0x44e7,0x9a,0x38,0xbd,0x97,0x67,0x24,0xbe,0xef)
-
-/**
- * Factory class for PVMFVideoEncNode
- */
-class PVMFOMXVideoEncNodeFactory
-{
-public:
-	/**
-     * Creates an instance of a PV video encoder node. If the creation fails, this function will leave.
-     *
-	 * @param aPriority The active object priority for the node. Default is standard priority if not specified
-     * @returns A pointer to an author or leaves if instantiation fails
-     **/
-	OSCL_IMPORT_REF static PVMFNodeInterface* CreateVideoEncNode(int32 aPriority=OsclActiveObject::EPriorityNominal);
-
-    /**
-     * This function allows the application to delete an instance of file input node
-     * and reclaim all allocated resources.  An instance can be deleted only in
-     * the idle state. An attempt to delete in any other state will fail and return false.
-     *
-     * @param aNode The file input node to be deleted.
-     * @returns A status code indicating success or failure.
-     **/
-	OSCL_IMPORT_REF static bool DeleteVideoEncNode(PVMFNodeInterface* aNode);
-};
-
-#endif // PVMF_OMX_VIDEOENC_NODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvomxvideoencnode/include/pvmf_omx_videoenc_node_types.h b/nodes/pvomxvideoencnode/include/pvmf_omx_videoenc_node_types.h
deleted file mode 100644
index 4bf3937..0000000
--- a/nodes/pvomxvideoencnode/include/pvmf_omx_videoenc_node_types.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_NODE_TYPES_H_INCLUDED
-#define PVMF_OMX_VIDEOENC_NODE_TYPES_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-///////////////////////////////////////////////
-// Port tags
-///////////////////////////////////////////////
-
-/** Enumerated list of port tags supported by the node for the port requests.*/
-typedef enum
-{
-	PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT = 0,
-	PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT
-} PVMFOmxVideoEncNodePortType;
-
-///////////////////////////////////////////////
-// Error Events
-///////////////////////////////////////////////
-
-enum PVMFOmxVideoEncNodeErrorEvent
-{
-	PVMF_OMX_VIDEOENC_NODE_ERROR_ENCODE_ERROR = PVMF_NODE_ERROR_EVENT_LAST
-};
-
-///////////////////////////////////////////////
-// Information Events
-///////////////////////////////////////////////
-
-// Enumerated list of informational event from PVMFVideoEncNode
-enum PVMFOmxVideoEncNodeInfoEvent
-{
-	PVMF_OMX_VIDEOENC_NODE_INFO = PVMF_NODE_INFO_EVENT_LAST
-};
-
-
-#endif // PVMF_OMX_VIDEOENC_NODE_TYPES_H_INCLUDED
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_callbacks.cpp b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_callbacks.cpp
deleted file mode 100644
index 97c5118..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_callbacks.cpp
+++ /dev/null
@@ -1,437 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_omx_videoenc_callbacks.h"
-#include "pvmf_omx_videoenc_node.h"
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-EventHandlerThreadSafeCallbackAO::EventHandlerThreadSafeCallbackAO(void* aObserver,
-																   uint32 aDepth,
-																   const char* aAOname,
-																   int32 aPriority)
-	:ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-	iMemoryPool=ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth+2);
-	if (iMemoryPool==NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
-	}
-	// MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-	// created in the 2nd thread and will fail to deallocate properly.
-
-	OsclAny *dummy = iMemoryPool->allocate(sizeof (EventHandlerSpecificData));
-	iMemoryPool->deallocate(dummy);
-}
-
-EventHandlerThreadSafeCallbackAO::~EventHandlerThreadSafeCallbackAO()
-{
-	if(iMemoryPool)
-	{
-		iMemoryPool->removeRef();
-		iMemoryPool = NULL;
-	}
-}
-OsclReturnCode EventHandlerThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
-{
-	// In this case, ProcessEvent calls the method of the primary test AO to process the Event
-	if (iObserver != NULL)
-	{
-		PVMFOMXVideoEncNode* ptr = (PVMFOMXVideoEncNode*)iObserver;
-
-		ptr->ProcessCallbackEventHandler_MultiThreaded(EventData);
-
-	}
-	return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void EventHandlerThreadSafeCallbackAO::Run()
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EventHandlerThreadSafeCallbackAO::Run() In"));
-
-	OsclAny *P; // parameter to dequeue
-	OsclReturnCode status=OsclSuccess;
-
-
-	do{
-
-
-		P=DeQueue(status);
-		// status is either OsclSuccess or OsclPending (if the last event was pulled
-		// from the queue)
-
-		if( (status == OsclSuccess) || (status==OsclPending) ){
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EventHandlerThreadSafeCallbackAO::Run() - Calling Process Event"));
-			ProcessEvent(P);
-		}
-		else{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EventHandlerThreadSafeCallbackAO::Run() - could not dequeue event data"));
-		}
-
-
-		// it is possible that an event arrives between dequeueing the last event and this point.
-		// If this is the case, we will be rescheduled and process the event
-		// in the next Run
-
-
-	}while(status == OsclSuccess);
-	// if the status is "OsclPending" there were no more events in the queue
-	// (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EventHandlerThreadSafeCallbackAO::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* EventHandlerThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
-{
-	OsclAny *pData;
-	OsclProcStatus::eOsclProcError sema_status;
-
-	stat = OsclSuccess;
-
-	// Protect the queue while accessing it:
-	Mutex.Lock();
-
-	if ( Q->NumElem == 0 )
-	{
-		// nothing to de-queue
-		stat = OsclFailure;
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EventHandlerThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
-		Mutex.Unlock();
-
-		return NULL;
-	}
-
-	pData = (Q->pFirst[Q->index_out]).pData;
-
-	Q->index_out++;
-	// roll-over the index
-	if(Q->index_out == Q->MaxNumElements)
-		Q->index_out = 0;
-
-	Q->NumElem--;
-
-	// check if there is need to call waitforevent
-	if( (Q->NumElem) == 0)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EventHandlerThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
-		PendForExec();
-		stat = OsclPending; // let the Run know that the last event was pulled out of the queue
-							// so that it can get out of the loop
-	}
-
-
-	//release queue access
-	Mutex.Unlock();
-
-	// Signal the semaphore that controls the remote thread.
-	// The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-	sema_status = RemoteThreadCtrlSema.Signal();
-	if(sema_status != OsclProcStatus::SUCCESS_ERROR)
-	{
-		stat = OsclFailure;
-		return NULL;
-	}
-
-	return pData;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////
-EmptyBufferDoneThreadSafeCallbackAO::EmptyBufferDoneThreadSafeCallbackAO(void* aObserver,
-																	uint32 aDepth,
-																	const char* aAOname,
-																	int32 aPriority)
-	:ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-	iMemoryPool=ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth+2);
-	if (iMemoryPool==NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
-
-	}
-	// MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-	// created in the 2nd thread and will fail to deallocate properly.
-
-	OsclAny *dummy = iMemoryPool->allocate(sizeof (EmptyBufferDoneSpecificData));
-	iMemoryPool->deallocate(dummy);
-}
-
-EmptyBufferDoneThreadSafeCallbackAO::~EmptyBufferDoneThreadSafeCallbackAO()
-{
-	if(iMemoryPool)
-	{
-
-		iMemoryPool->removeRef();
-		iMemoryPool = NULL;
-	}
-
-}
-OsclReturnCode EmptyBufferDoneThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
-{
-	// In this case, ProcessEvent calls the method of the primary test AO to process the Event
-	if (iObserver != NULL)
-	{
-		PVMFOMXVideoEncNode* ptr = (PVMFOMXVideoEncNode *) iObserver;
-
-		ptr->ProcessCallbackEmptyBufferDone_MultiThreaded(EventData);
-
-	}
-	return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void EmptyBufferDoneThreadSafeCallbackAO::Run()
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EmptyBufferDoneThreadSafeCallbackAO::Run() In"));
-
-	OsclAny *P; // parameter to dequeue
-	OsclReturnCode status=OsclSuccess;
-
-	do{
-
-
-		P=DeQueue(status);
-
-
-		if( (status == OsclSuccess) || (status==OsclPending) ){
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EmptyBufferDoneThreadSafeCallbackAO::Run() - Calling Process Event"));
-			ProcessEvent(P);
-		}
-		else{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EmptyBufferDoneThreadSafeCallbackAO::Run() - could not dequeue event data"));
-		}
-
-
-		// it is possible that an event arrives between dequeueing the last event and this point.
-			// If this is the case, we will be rescheduled and process the event
-		// in the next Run
-
-
-	}while(status == OsclSuccess);
-	// if the status is "OsclPending" there were no more events in the queue
-	// (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EmptyBufferDoneThreadSafeCallbackAO::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* EmptyBufferDoneThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
-{
-	OsclAny *pData;
-	OsclProcStatus::eOsclProcError sema_status;
-
-	stat = OsclSuccess;
-
-	// Protect the queue while accessing it:
-	Mutex.Lock();
-
-	if ( Q->NumElem == 0 )
-	{
-		// nothing to de-queue
-		stat = OsclFailure;
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EmptyBufferDoneThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
-		Mutex.Unlock();
-
-		return NULL;
-	}
-
-	pData = (Q->pFirst[Q->index_out]).pData;
-
-	Q->index_out++;
-	// roll-over the index
-	if(Q->index_out == Q->MaxNumElements)
-		Q->index_out = 0;
-
-	Q->NumElem--;
-
-	// check if there is need to call waitforevent
-	if( (Q->NumElem) == 0)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"EmptyBufferDoneThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
-		PendForExec();
-		stat = OsclPending; // let the Run know that the last event was pulled out of the queue
-							// so that it can get out of the loop
-	}
-
-	//release queue access
-	Mutex.Unlock();
-
-	// Signal the semaphore that controls the remote thread.
-	// The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-	sema_status = RemoteThreadCtrlSema.Signal();
-	if(sema_status != OsclProcStatus::SUCCESS_ERROR)
-	{
-		stat = OsclFailure;
-		return NULL;
-	}
-
-	return pData;
-}
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-FillBufferDoneThreadSafeCallbackAO::FillBufferDoneThreadSafeCallbackAO(void* aObserver,
-																	uint32 aDepth,
-																	const char* aAOname,
-																	int32 aPriority)
-	:ThreadSafeCallbackAO(aObserver, aDepth, aAOname, aPriority)
-{
-
-	iMemoryPool=ThreadSafeMemPoolFixedChunkAllocator::Create(aDepth+2);
-	if (iMemoryPool==NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"EventHandlerTSCAO::CreateMemPool() Memory pool failed to allocate"));
-	}
-	// MUST do a dummy ALLOC HERE TO Create mempool. Otherwise the mempool will be
-	// created in the 2nd thread and will fail to deallocate properly.
-
-	OsclAny *dummy = iMemoryPool->allocate(sizeof (FillBufferDoneSpecificData));
-	iMemoryPool->deallocate(dummy);
-}
-
-FillBufferDoneThreadSafeCallbackAO::~FillBufferDoneThreadSafeCallbackAO()
-{
-	if(iMemoryPool)
-	{
-
-		iMemoryPool->removeRef();
-		iMemoryPool = NULL;
-	}
-}
-
-OsclReturnCode FillBufferDoneThreadSafeCallbackAO::ProcessEvent(OsclAny* EventData)
-{
-	// In this case, ProcessEvent calls the method of the primary test AO to process the Event
-	if (iObserver != NULL)
-	{
-		PVMFOMXVideoEncNode* ptr = (PVMFOMXVideoEncNode*) iObserver;
-
-		ptr->ProcessCallbackFillBufferDone_MultiThreaded(EventData);
-
-	}
-	return OsclSuccess;
-}
-
-// We override the Run to process multiple (i.e. all in the queue) events in one Run
-
-void FillBufferDoneThreadSafeCallbackAO::Run()
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"FillBufferDoneThreadSafeCallbackAO::Run() In"));
-
-	OsclAny *P; // parameter to dequeue
-	OsclReturnCode status=OsclSuccess;
-
-	do{
-
-
-		P=DeQueue(status);
-
-
-		if( (status == OsclSuccess) || (status==OsclPending) ){
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"FillBufferDoneThreadSafeCallbackAO::Run() - Calling Process Event"));
-			ProcessEvent(P);
-		}
-		else{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"FillBufferDoneThreadSafeCallbackAO::Run() - could not dequeue event data"));
-		}
-
-
-		// it is possible that an event arrives between dequeueing the last event and this point.
-		// If this is the case, we will be rescheduled and process the event
-		// in the next Run
-
-
-	}while(status == OsclSuccess);
-	// if the status is "OsclPending" there were no more events in the queue
-	// (if another event arrived in the meanwhile, AO will be rescheduled)
-
-
-
-
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"FillBufferDoneThreadSafeCallbackAO::Run() Out"));
-}
-
-// same as base-class DeQueue method, except no RunIfNotReady/PendForExec is called (since all events are processed in a loop)
-// (i.e. PendForExec control is done in the loop in Run)
-OsclAny* FillBufferDoneThreadSafeCallbackAO::DeQueue(OsclReturnCode &stat)
-{
-	OsclAny *pData;
-	OsclProcStatus::eOsclProcError sema_status;
-
-	stat = OsclSuccess;
-
-	// Protect the queue while accessing it:
-	Mutex.Lock();
-
-	if ( Q->NumElem == 0 )
-	{
-		// nothing to de-queue
-		stat = OsclFailure;
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"FillBufferDoneThreadSafeCallbackAO::DeQueue() - No events in the queue - return ()"));
-		Mutex.Unlock();
-
-		return NULL;
-	}
-
-	pData = (Q->pFirst[Q->index_out]).pData;
-
-	Q->index_out++;
-	// roll-over the index
-	if(Q->index_out == Q->MaxNumElements)
-		Q->index_out = 0;
-
-	Q->NumElem--;
-	// check if there is need to call waitforevent
-	if( (Q->NumElem) == 0)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"FillBufferDoneThreadSafeCallbackAO::Run() - No more events, call PendForExec()"));
-		PendForExec();
-		stat = OsclPending; // let the Run know that the last event was pulled out of the queue
-							// so that it can get out of the loop
-	}
-
-	//release queue access
-	Mutex.Unlock();
-
-	// Signal the semaphore that controls the remote thread.
-	// The remote thread might be blocked and waiting for an event to be processed in case the event queue is full
-	sema_status = RemoteThreadCtrlSema.Signal();
-	if(sema_status != OsclProcStatus::SUCCESS_ERROR)
-	{
-		stat = OsclFailure;
-		return NULL;
-	}
-
-	return pData;
-}
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_callbacks.h b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_callbacks.h
deleted file mode 100644
index eac0214..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_callbacks.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_CALLBACKS_H_INCLUDED
-#define PVMF_OMX_VIDEOENC_CALLBACKS_H_INCLUDED
-
-
-#ifndef THREADSAFE_CALLBACK_AO_H_INCLUDED
-#include "threadsafe_callback_ao.h"
-#endif
-
-#ifndef THREADSAFE_MEMPOOL_H_INCLUDED
-#include "threadsafe_mempool.h"
-#endif
-
-
-#ifndef OMX_Types_h
-#include "omx_types.h"
-#endif
-
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-// structure that contains EventHandler callback type parameters:
-typedef struct EventHandlerSpecificData
-{
-	OMX_HANDLETYPE hComponent;
-	OMX_PTR pAppData;
-	OMX_EVENTTYPE eEvent;
-	OMX_U32 nData1;
-	OMX_U32 nData2;
-	OMX_PTR pEventData;
-} EventHandlerSpecificData;
-
-
-// structure that contains EmptyBufferDone callback type parameters:
-typedef struct EmptyBufferDoneSpecificData
-{
-	OMX_HANDLETYPE hComponent;
-	OMX_PTR pAppData;
-	OMX_BUFFERHEADERTYPE* pBuffer;
-} EmptyBufferDoneSpecificData;
-
-
-// structure that contains FillBufferDone callback type parameters:
-typedef struct FillBufferDoneSpecificData
-{
-	OMX_HANDLETYPE hComponent;
-	OMX_PTR pAppData;
-	OMX_BUFFERHEADERTYPE* pBuffer;
-} FillBufferDoneSpecificData;
-
-
-// This class defines the callback AO that handles the callbacks from the remote thread in a thread-safe way.
-// The callback events arriving from the remote thread are queued and processed later in PV thread context.
-// The class is DERIVED from the "ThreadSafeCallbackAO" class defined in "threadsafe_callback_ao.h/cpp"
-// OVERLOAD THE METHOD : "ProcessEvent" so that it does something meaningful
-
-
-// Test AO receives the remote thread specific API callback and then calls the generic API "ReceiveEvent"
-const char EventHandlerAOName[] = "EventHandlerCallbackAO";
-const char EmptyBufferDoneAOName[] = "EventHandlerCallbackAO";
-const char FillBufferDoneAOName[] = "EventHandlerCallbackAO";
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class EventHandlerThreadSafeCallbackAO : public ThreadSafeCallbackAO
-{
-public:
-	// Constructor
-	EventHandlerThreadSafeCallbackAO(
-										void* aObserver = NULL,
-										uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-										const char* aAOname = EventHandlerAOName,
-										int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-
-	// OVERLOADED ProcessEvent
-	OsclReturnCode ProcessEvent(OsclAny* EventData);
-
-	// overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-	virtual void Run();
-	virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-	virtual ~EventHandlerThreadSafeCallbackAO();
-	ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-
-};
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class EmptyBufferDoneThreadSafeCallbackAO : public ThreadSafeCallbackAO
-{
-public:
-	// Constructor
-	EmptyBufferDoneThreadSafeCallbackAO(
-										void* aObserver = NULL,
-										uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-										const char* aAOname = EmptyBufferDoneAOName,
-										int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-	// OVERLOADED ProcessEvent
-	OsclReturnCode ProcessEvent(OsclAny* EventData);
-
-	// overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-	virtual void Run();
-	virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-	virtual ~EmptyBufferDoneThreadSafeCallbackAO();
-	ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-};
-
-
-
-
-/**************** CLASS FOR EVENT HANDLER *************/
-class FillBufferDoneThreadSafeCallbackAO : public ThreadSafeCallbackAO
-{
-public:
-	// Constructor
-	FillBufferDoneThreadSafeCallbackAO(void* aObserver = NULL,
-										uint32 aDepth = DEFAULT_QUEUE_DEPTH,
-										const char* aAOname = FillBufferDoneAOName,
-										int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-	// OVERLOADED ProcessEvent
-	OsclReturnCode ProcessEvent(OsclAny* EventData);
-	// overloaded Run and DeQueue to optimize performance (and process more than 1 event per Run)
-	virtual void Run();
-	virtual OsclAny* DeQueue(OsclReturnCode &stat);
-
-	virtual ~FillBufferDoneThreadSafeCallbackAO();
-	ThreadSafeMemPoolFixedChunkAllocator *iMemoryPool;
-};
-
-#endif	//#ifndef PVMF_OMX_VIDEODEC_CALLBACKS_H_INLCUDED
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node.cpp b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node.cpp
deleted file mode 100644
index e59441a..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node.cpp
+++ /dev/null
@@ -1,5614 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "PVMFOMXVideoEncNode"
-#include <utils/Log.h>
-
-#ifndef PVMF_OMX_VIDEOENC_NODE_H_INCLUDED
-#include "pvmf_omx_videoenc_node.h"
-#endif
-#ifndef OSCL_ERROR_CODES_H_INCLUDED
-#include "oscl_error_codes.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_PORT_H_INCLUDED
-#include "pvmf_omx_videoenc_port.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_NODE_FACTORY_H_INCLUDED
-#include "pvmf_omx_videoenc_node_factory.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_omx_videoenc_node_types.h"
-#endif
-#ifndef OSCL_DLL_H_INCLUDED
-#include "oscl_dll.h"
-#endif
-#ifndef PVMF_MEDIA_MSG_FORMAT_IDS_H_INCLUDED
-#include "pvmf_media_msg_format_ids.h"
-#endif
-#ifndef PVMF_MEDIA_CMD_H_INCLUDED
-#include "pvmf_media_cmd.h"
-#endif
-
-#include "omx_core.h"
-#include "pvmf_omx_videoenc_callbacks.h"     //used for thin AO in encoder's callbacks
-#include "pv_omxcore.h"
-#include "pv_omxmastercore.h"
-
-
-static const OMX_U32 OMX_SPEC_VERSION = 0x00000101;
-#define CONFIG_VERSION_SIZE(param) \
-       param.nVersion.nVersion = OMX_SPEC_VERSION; \
-       param.nSize = sizeof(param);
-
-#define PVOMXVIDEOENC_MEDIADATA_CHUNKSIZE 128
-
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-static const uint32 DEFAULT_VOL_HEADER_LENGTH = 28;
-static const uint8 DEFAULT_VOL_HEADER[DEFAULT_VOL_HEADER_LENGTH] =
-{
-	0x00, 0x00, 0x01, 0xB0, 0x08, 0x00, 0x00, 0x01,
-	0xB5, 0x09, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-	0x01, 0x20, 0x00, 0x84, 0x40, 0x07, 0xA8, 0x50,
-	0x20, 0xF0, 0xA3, 0x1F
-};
-
-// OMX CALLBACKS
-// 1) AO OMX component running in the same thread as the OMX node
-//	In this case, the callbacks can be called directly from the component
-//	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
-//	The callback can perform do RunIfNotReady
-
-// 2) Multithreaded component
-//	In this case, the callback is made using the threadsafe callback (TSCB) AO
-//	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent) => event is queued
-//  Node thread		 : dequeue event => TSCB(ProcessEvent)->ProcessCallbackEventHandler->EventHandlerProcessing
-
-// callback for Event Handler - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling EventHandlerProcessing
-OMX_ERRORTYPE CallbackEventHandler(OMX_OUT OMX_HANDLETYPE aComponent,
-                                   OMX_OUT OMX_PTR aAppData,
-                                   OMX_OUT OMX_EVENTTYPE aEvent,
-                                   OMX_OUT OMX_U32 aData1,
-                                   OMX_OUT OMX_U32 aData2,
-                                   OMX_OUT OMX_PTR aEventData)
-{
-    PVMFOMXVideoEncNode *Node = (PVMFOMXVideoEncNode *) aAppData;
-
-    if ( Node->IsComponentMultiThreaded() )
-    {
-        // allocate the memory for the callback event specific data
-        //EventHandlerSpecificData* ED = (EventHandlerSpecificData*) oscl_malloc(sizeof (EventHandlerSpecificData));
-        EventHandlerSpecificData* ED = (EventHandlerSpecificData*) Node->iThreadSafeHandlerEventHandler->iMemoryPool->allocate(sizeof (EventHandlerSpecificData));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->eEvent = aEvent;
-        ED->nData1 = aData1;
-        ED->nData2 = aData2;
-        ED->pEventData = aEventData;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerEventHandler->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
-        return status;
-    }
-
-}
-
-
-// callback for EmptyBufferDone - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling EmptyBufferDoneProcessing
-OMX_ERRORTYPE CallbackEmptyBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
-                                      OMX_OUT OMX_PTR aAppData,
-                                      OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-    PVMFOMXVideoEncNode *Node = (PVMFOMXVideoEncNode *) aAppData;
-    if ( Node->IsComponentMultiThreaded() )
-    {
-        // allocate the memory for the callback event specific data
-        //EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) oscl_malloc(sizeof (EmptyBufferDoneSpecificData));
-        EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) Node->iThreadSafeHandlerEmptyBufferDone->iMemoryPool->allocate(sizeof (EmptyBufferDoneSpecificData));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->pBuffer = aBuffer;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerEmptyBufferDone->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
-        return status;
-    }
-
-}
-
-// callback for FillBufferDone - in multithreaded case, event is queued to be processed later
-//	in AO case, event is processed immediately by calling FillBufferDoneProcessing
-OMX_ERRORTYPE CallbackFillBufferDone(OMX_OUT OMX_HANDLETYPE aComponent,
-                                     OMX_OUT OMX_PTR aAppData,
-                                     OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-    PVMFOMXVideoEncNode *Node = (PVMFOMXVideoEncNode *) aAppData;
-    if ( Node->IsComponentMultiThreaded() )
-    {
-        // allocate the memory for the callback event specific data
-        //FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) oscl_malloc(sizeof (FillBufferDoneSpecificData));
-        FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) Node->iThreadSafeHandlerFillBufferDone->iMemoryPool->allocate(sizeof (FillBufferDoneSpecificData));
-
-        // pack the relevant data into the structure
-        ED->hComponent = aComponent;
-        ED->pAppData = aAppData;
-        ED->pBuffer = aBuffer;
-
-        // convert the pointer into OsclAny ptr
-        OsclAny* P = (OsclAny*) ED;
-
-        // CALL the generic callback AO API:
-        Node->iThreadSafeHandlerFillBufferDone->ReceiveEvent(P);
-
-        return OMX_ErrorNone;
-    }
-    else
-    {
-        OMX_ERRORTYPE status;
-        status = Node->FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
-        return status;
-    }
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-//              PVMFOMXVideoEncNodeFactory implementation
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFNodeInterface* PVMFOMXVideoEncNodeFactory::CreateVideoEncNode(int32 aPriority)
-{
-    int32 err = 0;
-    PVMFOMXVideoEncNode* node = NULL;
-
-    OSCL_TRY(err,
-             node = OSCL_NEW(PVMFOMXVideoEncNode, (aPriority));
-             if (!node)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err, return NULL;);
-
-    return (PVMFNodeInterface*)node;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNodeFactory::DeleteVideoEncNode(PVMFNodeInterface* aNode)
-{
-    if (!aNode)
-        return false;
-
-    OSCL_DELETE(aNode);
-    aNode = NULL;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//              PVMFOMXVideoEncNode implementation
-////////////////////////////////////////////////////////////////////////////
-PVMFOMXVideoEncNode::PVMFOMXVideoEncNode(int32 aPriority) :
-        OsclTimerObject(aPriority, "PVMFOMXVideoEncNode"),
-        iMediaBufferMemPool(PVVIDENC_MEDIADATA_POOLNUM, PVVIDENC_MEDIABUFFER_CHUNKSIZE),
-        iMediaDataMemPoolOld(PVVIDENC_MEDIADATA_POOLNUM, PVVIDENC_MEDIADATA_CHUNKSIZE)
-{
-    mInputBufferRefCount = 0;
-    iInterfaceState = EPVMFNodeCreated;
-
-	// CB Functions to serve OpenMAX Encoder
-    iThreadSafeHandlerEventHandler = NULL;
-    iThreadSafeHandlerEmptyBufferDone = NULL;
-    iThreadSafeHandlerFillBufferDone = NULL;
-	memset(&iCallbacks, 0, sizeof(iCallbacks));
-
-	// Handle of OMX Component
-	iOMXVideoEncoder = NULL;
-
-	// Current State of the component
-	OMX_STATETYPE iCurrentEncoderState = OMX_StateInvalid;
-
-	// Shared pointer for Media Msg.Input buffer
-	//PVMFSharedMediaDataPtr iDataIn; //Init this value ?
-
-	//EOS control flags
-	iIsEOSSentToComponent = false;
-	iIsEOSReceivedFromComponent = false;
-
-	// OMX COMPONENT CAPABILITY RELATED MEMBERS
-	iOMXComponentSupportsExternalOutputBufferAlloc = false;
-	iOMXComponentSupportsExternalInputBufferAlloc = false;
-	iOMXComponentSupportsMovableInputBuffers = false;
-	iIsOMXComponentMultiThreaded = true;
-	iOMXComponentSupportsPartialFrames = false;
-	iOMXComponentCanHandleIncompleteFrames = true;
-
-	// DYNAMIC PORT RE-CONFIGURATION
-	iInputPortIndex = 0;
-	iOutputPortIndex = 0;
-	memset(&iParamPort, 0, sizeof(iParamPort));
-	iPortIndexForDynamicReconfig = 0;
-	iSecondPortReportedChange = false;
-	iDynamicReconfigInProgress = false;
-	iSecondPortToReconfig = 0;
-
-	// OUTPUT BUFFER RELATED MEMBERS
-	iMediaDataMemPool = NULL;
-	iOutBufMemoryPool = NULL;
-	iOMXComponentOutputBufferSize = 0;
-	iOutputAllocSize = 0;
-	iNumOutputBuffers = 0;
-	iNumOutstandingOutputBuffers = 0;
-	iDoNotSendOutputBuffersDownstreamFlag = false;
-	iOutputBuffersFreed = false;
-	ipPrivateData = NULL;
-
-	// INPUT BUFFER RELATED MEMBERS
-	iInBufMemoryPool = NULL;
-	iOMXComponentInputBufferSize = 0;
-	iInputAllocSize = 0;
-	iNumInputBuffers = 0;
-	iNumOutstandingInputBuffers = 0;
-	iDoNotSaveInputBuffersFlag = false;
-	iInputBuffersFreed = false;
-
-	iOMXComponentInputYUVFormat = PVMF_YUV420;
-	iInputBufferToResendToComponent = NULL;
-
-	iProcessingState = EPVMFOMXVideoEncNodeProcessingState_Idle;
-
-	iResetInProgress = false;
-	iResetMsgSent = false;
-
-	// Time stamp to be used on output buffer
-	iOutTimeStamp = 0;
-
-	// input buffer fragmentation etc.
-	iCopyPosition = 0;
-	iFragmentSizeRemainingToCopy = 0;
-	iIsNewDataFragment = true;
-
-	// partial frame assembly logic flags
-	iObtainNewInputBuffer = true;
-	iKeepDroppingMsgsUntilMarkerBit = false;
-
-	iInputBufferUnderConstruction = NULL;
-
-	// input data info
-	iCurrFragNum = 0;
-	iCodecSeqNum = 0;
-	iInPacketSeqNum = 0;
-	iInTimestamp = 0;
-	iInDuration = 0;
-	iInNumFrags = 0;
-	iCurrentMsgMarkerBit = 1;
-
-	iEndOfDataReached = false;
-	iEndOfDataTimestamp = 0;
-
-    iExtensionRefCount = 0;
-
-    iSeqNum = 0;
-
-	// Allocate memory for VOL header
-	uint refCounterSize = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-	uint size = refCounterSize + DEFAULT_VOL_HEADER_LENGTH;
-	uint8 *memBuffer = NULL;
-
-    int32 err;
-    OSCL_TRY(err,
-             //Create the input command queue
-             iCmdQueue.Construct(PVMF_OMX_VIDEOENC_NODE_CMD_ID_START, PVMF_OMX_VIDEOENC_NODE_CMD_QUEUE_RESERVE);
-             iCurrentCmd.Construct(0, 1); // There's only 1 current command
-
-             //Create the port vector.
-             iInPort.Construct(PVMF_OMX_VIDEOENC_NODE_PORT_VECTOR_RESERVE);
-             iOutPort.Construct(PVMF_OMX_VIDEOENC_NODE_PORT_VECTOR_RESERVE);
-
-             // Create media data allocator
-             iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (&iMediaBufferMemPool));
-             if (!iMediaDataAlloc)
-             OSCL_LEAVE(OsclErrNoMemory);
-
-			 memBuffer = (uint8*)iAlloc.allocate(size);
-			 if (!memBuffer)
-			 {
-				 OSCL_LEAVE(PVMFErrNoMemory);
-			 }
-
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         // If a leave happened, cleanup and re-throw the error
-                         iCmdQueue.clear();
-                         iInPort.clear();
-                         iOutPort.clear();
-                         OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
-                         OSCL_CLEANUP_BASE_CLASS(OsclTimerObject);
-                         OSCL_LEAVE(err);
-                        );
-
-	// Save default VOL header
-	oscl_memset(memBuffer, 0, DEFAULT_VOL_HEADER_LENGTH);
-	OsclMemoryFragment volHeader;
-	OsclRefCounter* refCounter = new (memBuffer) OsclRefCounterDA(memBuffer,
-		(OsclDestructDealloc*)&iAlloc);
-	memBuffer += refCounterSize;
-	volHeader.ptr = memBuffer;
-	oscl_memcpy(volHeader.ptr, (OsclAny*)DEFAULT_VOL_HEADER, DEFAULT_VOL_HEADER_LENGTH);
-	volHeader.len = DEFAULT_VOL_HEADER_LENGTH;
-	iVolHeader = OsclRefCounterMemFrag(volHeader, refCounter, DEFAULT_VOL_HEADER_LENGTH);
-
-    ConstructEncoderParams();
-
-    iLogger = PVLogger::GetLoggerObject("PVMFOMXVideoEncNode");
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFOMXVideoEncNode::~PVMFOMXVideoEncNode()
-{
-	//Clearup encoder
-    DeleteVideoEncoder();
-
-	// Cleanup callback AOs and Mempools
-	if(iThreadSafeHandlerEventHandler)
-	{
-		OSCL_DELETE(iThreadSafeHandlerEventHandler);
-		iThreadSafeHandlerEventHandler = NULL;
-	}
-	if(iThreadSafeHandlerEmptyBufferDone)
-	{
-		OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
-		iThreadSafeHandlerEmptyBufferDone = NULL;
-	}
-	if(iThreadSafeHandlerFillBufferDone)
-	{
-		OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
-		iThreadSafeHandlerFillBufferDone = NULL;
-	}
-
-	if (iMediaDataMemPool)
-	{
-		iMediaDataMemPool->removeRef();
-		iMediaDataMemPool = NULL;
-	}
-
-	if (iOutBufMemoryPool)
-	{
-		iOutBufMemoryPool->removeRef();
-		iOutBufMemoryPool = NULL;
-	}
-	if(iInBufMemoryPool)
-	{
-		iInBufMemoryPool->removeRef();
-		iInBufMemoryPool = NULL;
-	}
-
-    if (iMediaDataAlloc)
-    {
-        OSCL_DELETE(iMediaDataAlloc);
-        iMediaDataAlloc = NULL;
-    }
-
-    while (!iInPort.empty())
-        iInPort.Erase(&iInPort.front());
-    while (!iOutPort.empty())
-        iOutPort.Erase(&iOutPort.front());
-
-    Cancel();
-    SetState(EPVMFNodeIdle);
-    ThreadLogoff();
-
-	//Release Input buffer
-	iDataIn.Unbind();
-
-}
-
-//=================================================================================================
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFOMXVideoEncNode::ThreadLogon()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeCreated:
-            if (!IsAdded())
-                AddToScheduler();
-            SetState(EPVMFNodeIdle);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFOMXVideoEncNode::ThreadLogoff()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            if (IsAdded())
-                RemoveFromScheduler();
-            iLogger = NULL;
-            SetState(EPVMFNodeCreated);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFOMXVideoEncNode::GetCapability(PVMFNodeCapability& aNodeCapability)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::GetCapability"));
-
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_YUV420);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_M4V);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_H263);
-    aNodeCapability.iCanSupportMultipleOutputPorts = false;
-    aNodeCapability.iCanSupportMultipleInputPorts = false;
-    aNodeCapability.iHasMaxNumberOfPorts = true;
-    aNodeCapability.iMaxNumberOfPorts = 2;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFPortIter* PVMFOMXVideoEncNode::GetPorts(const PVMFPortFilter* aFilter)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::GetPorts"));
-    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
-
-    int32 err = 0;
-    PVMFVideoEncPortVector* port = NULL;
-    OSCL_TRY(err,
-             port = OSCL_NEW(PVMFVideoEncPortVector, ());
-             if (!port)
-                 return NULL;
-
-             uint32 i;
-             for (i = 0; i < iInPort.size(); i++)
-                 port->AddL(iInPort[i]);
-             for (i = 0; i < iOutPort.size(); i++)
-                 port->AddL(iOutPort[i]);
-             port->Reset();
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFOMXVideoEncNode::GetPorts: Error - Out of memory"));
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::QueryUUID(PVMFSessionId aSession,
-        const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-        bool aExactUuidsOnly,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::QueryUUID"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYUUID,
-                  aMimeType, aUuids, aExactUuidsOnly, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::QueryInterface(PVMFSessionId aSession,
-        const PVUuid& aUuid,
-        PVInterface*& aInterfacePtr,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::QueryInterface"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYINTERFACE,
-                  aUuid, aInterfacePtr, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::RequestPort(PVMFSessionId aSession,
-        int32 aPortTag,
-        const PvmfMimeString* aPortConfig,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::RequestPort: aPortTag=%d", aPortTag));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_REQUESTPORT,
-                  aPortTag, aPortConfig, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::ReleasePort(PVMFSessionId aSession,
-        PVMFPortInterface& aPort,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::ReleasePort"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Init(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Init"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_INIT, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Prepare(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Prepare"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PREPARE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Start(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Start"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_START, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Stop(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Stop"));
-    PVMFVideoEncNodeCommand cmd;
-
-    // DoFlush before DoStop
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_FLUSH, aContext);
-    QueueCommandL(cmd);
-
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_STOP, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Flush(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Flush"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_FLUSH, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Pause(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Pause"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PAUSE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::Reset(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Reset"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RESET, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::CancelAllCommands"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFOMXVideoEncNode::CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::CancelCommand: aCmdId=%d", aCmdId));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::HandlePortActivity(const PVMFPortActivity &aActivity)
-{
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0, "0x%x PVMFOMXVideoEncNode::PortActivity: port=0x%x, type=%d",
-		this, aActivity.iPort, aActivity.iType));
-
-	switch(aActivity.iType)
-	{
-		case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-			//An outgoing message was queued on this port.
-			//We only need to queue a port activity event on the
-			//first message.  Additional events will be queued during
-			//the port processing as needed.
-			if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
-			{
-				//wake up the AO to process the port activity event.
-				RunIfNotReady();
-			}
-			break;
-
-		case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-				(0, "PVMFOMXVideoEncNode::PortActivity: IncomingMsgQueueSize=%d", aActivity.iPort->IncomingMsgQueueSize()));
-			if(aActivity.iPort->IncomingMsgQueueSize() == 1)
-			{
-				//wake up the AO to process the port activity event.
-				RunIfNotReady();
-			}
-			break;
-
-		case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-			if (iProcessingState == EPVMFOMXVideoEncNodeProcessingState_WaitForOutgoingQueue)
-			{
-				iProcessingState = EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode;
-				RunIfNotReady();
-			}
-			break;
-
-		case PVMF_PORT_ACTIVITY_CONNECT:
-			//nothing needed.
-			break;
-
-		case PVMF_PORT_ACTIVITY_DISCONNECT:
-			//clear the node input data when either port is disconnected.
-
-			iDataIn.Unbind();
-			break;
-
-		case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-			// The connected port has become busy (its incoming queue is
-			// busy).
-			// No action is needed here-- the port processing code
-			// checks for connected port busy during data processing.
-			break;
-
-		case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-			// The connected port has transitioned from Busy to Ready to Receive.
-			// It's time to start processing outgoing messages again.
-
-			//iProcessingState should transition from WaitForOutputPort to ReadyToDecode
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-				(0, "0x%x PVMFOMXVideoEncNode::PortActivity: Connected port is now ready", this));
-			RunIfNotReady();
-			break;
-
-		default:
-			break;
-	}
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFOMXVideoEncNode::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFOMXVideoEncNode::removeRef()
-{
-    if (iExtensionRefCount > 0)
-        --iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    if (uuid == PVMp4H263EncExtensionUUID)
-    {
-        PVMp4H263EncExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else if (uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-    {
-        PvmiCapabilityAndConfig* myInterface = 	OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else
-    {
-        iface = NULL;
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetNumLayers(uint32 aNumLayers)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetNumLayers: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if (aNumLayers > MAX_LAYER) // MAX_LAYER defined in cvei.h
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::SetNumLayers: Error Max num layers is %d", MAX_LAYER));
-        return false;
-    }
-
-    iEncodeParam.iNumLayer = aNumLayers;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetOutputBitRate(uint32 aLayer, uint32 aBitRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetOutputBitRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::SetOutputBitRate: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iBitRate[aLayer] = aBitRate;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetOutputFrameSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::SetOutputFrameSize: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iFrameWidth[aLayer] = aWidth;
-    iEncodeParam.iFrameHeight[aLayer] = aHeight;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate)
-{
-    LOGV("SetOutputFrameRate: %f", aFrameRate);
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetOutputFrameRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::SetOutputFrameRate: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iFrameRate[aLayer] = OSCL_STATIC_CAST(float, aFrameRate);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes)
-{
-    OSCL_UNUSED_ARG(aLayer);
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetSegmentTargetSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    iEncodeParam.iPacketSize = aSizeBytes;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl)
-{
-    OSCL_UNUSED_ARG(aLayer);
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetRateControlType: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    switch (aRateControl)
-    {
-        case PVMFVEN_RATE_CONTROL_CONSTANT_Q:
-            iEncodeParam.iRateControlType = ECONSTANT_Q;
-            break;
-        case PVMFVEN_RATE_CONTROL_CBR:
-            iEncodeParam.iRateControlType = ECBR_1;
-            break;
-        case PVMFVEN_RATE_CONTROL_VBR:
-            iEncodeParam.iRateControlType = EVBR_1;
-            break;
-        default:
-            return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetDataPartitioning(bool aDataPartitioning)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetDataPartitioning: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if (iEncodeParam.iContentType == ECVEI_H263)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::SetDataPartitioning: Error data partitioning not supported for H263"));
-        return false;
-    }
-
-    if (aDataPartitioning)
-        iEncodeParam.iContentType = ECVEI_STREAMING;
-    else
-        iEncodeParam.iContentType = ECVEI_DOWNLOAD;
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetIFrameInterval(uint32 aIFrameInterval)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetIFrameInterval: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    iEncodeParam.iIFrameInterval = aIFrameInterval;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetRVLC(bool aRVLC)
-{
-    OSCL_UNUSED_ARG(aRVLC);
-
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::SetRVLC"));
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::GetVolHeader(OsclRefCounterMemFrag& aVolHeader)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::GetVolHeader"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-        case EPVMFNodePrepared:
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::GetVolHeader: Error - Wrong state"));
-            return false;
-    }
-
-    if (iEncodeParam.iContentType == ECVEI_H263)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::GetVolHeader: Error - VOL header only for M4V encode"));
-        return false;
-    }
-
-	uint8 *ptr = (uint8 *)iVolHeader.getMemFragPtr();
-	//If data partioning mode
-	if (iEncodeParam.iContentType == ECVEI_STREAMING)
-	{
-		ptr[iVolHeader.getMemFragSize() - 1] = 0x8F;
-	}
-	//else combined mode
-	else
-	{
-		ptr[iVolHeader.getMemFragSize() - 1] = 0x1F;
-	}
-
-	aVolHeader = iVolHeader;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::RequestIFrame()
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::RequestIFrame"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            break;
-        default:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::RequestIFrame: Error - Wrong state"));
-            return false;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFOMXVideoEncNode::SetCodec(PVMFFormatType aCodec)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::SetCodec %d", aCodec));
-
-    if (SetCodecType(aCodec) == PVMFSuccess)
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::HandlePVCVEIEvent(uint32 aId, uint32 aEvent, uint32 aParam1)
-{
-    OSCL_UNUSED_ARG(aId);
-    OSCL_UNUSED_ARG(aEvent);
-    OSCL_UNUSED_ARG(aParam1);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                        Private methods
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::ConstructEncoderParams()
-{
-    iInputFormat.iVideoFormat = ECVEI_YUV420;
-    iInputFormat.iFrameWidth = DEFAULT_FRAME_WIDTH;
-    iInputFormat.iFrameHeight = DEFAULT_FRAME_HEIGHT;
-    iInputFormat.iFrameRate = (float)DEFAULT_FRAME_RATE;
-
-    oscl_memset(&iEncodeParam, 0, sizeof(TPVVideoEncodeParam));
-    iEncodeParam.iEncodeID = 0;
-    iEncodeParam.iNumLayer = 1;
-    iEncodeParam.iFrameWidth[0] = DEFAULT_FRAME_WIDTH;
-    iEncodeParam.iFrameHeight[0] = DEFAULT_FRAME_HEIGHT;
-    iEncodeParam.iBitRate[0] = DEFAULT_BITRATE;
-    iEncodeParam.iFrameRate[0] = (float)DEFAULT_FRAME_RATE;
-    iEncodeParam.iFrameQuality = 10;
-    iEncodeParam.iIFrameInterval = 10;
-    iEncodeParam.iBufferDelay = (float)0.2;
-    iEncodeParam.iContentType = ECVEI_H263;
-    iEncodeParam.iRateControlType = ECBR_1;
-    iEncodeParam.iIquant[0] = 15;
-    iEncodeParam.iPquant[0] = 12;
-    iEncodeParam.iBquant[0] = 12;
-    iEncodeParam.iSearchRange = 16;
-    iEncodeParam.iMV8x8 = false;
-    iEncodeParam.iPacketSize = 256;
-    iEncodeParam.iNoCurrentSkip = false;
-    iEncodeParam.iNoFrameSkip = false;
-    iEncodeParam.iClipDuration = 0;
-    iEncodeParam.iProfileLevel = ECVEI_CORE_LEVEL2;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::Run()
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Run"));
-
-	// if reset is in progress, call DoReset again until Reset Msg is sent
-	if((iResetInProgress == true) &&
-	   (iResetMsgSent == false) &&
-	   (iCurrentCmd.size() > 0) &&
-	   (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_RESET)
-	)
-	{
-		DoReset(iCurrentCmd.front());
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - Calling DoReset"));
-		return; // don't do anything else
-	}
-	//Check for NODE commands...
-	if (!iCmdQueue.empty())
-	{
-		if (ProcessCommand(iCmdQueue.front()))
-		{
-			if (iInterfaceState != EPVMFNodeCreated
-				&& (!iCmdQueue.empty() || (iInPort.size() > 0 && (iInPort[0]->IncomingMsgQueueSize() > 0)) ||
-				(iDataIn.GetRep()!=NULL) ))
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - rescheduling after process command"));
-				RunIfNotReady();
-			}
-			return;
-		}
-
-		if (!iCmdQueue.empty())
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - rescheduling to process more commands"));
-			RunIfNotReady();
-		}
-	}
-	else
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - Input commands empty"));
-	}
-
-	if ( ( (iCurrentCmd.size() == 0) && (iInterfaceState != EPVMFNodeStarted) ) ||
-	     ( (iCurrentCmd.size()>0) && (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_START) && (iInterfaceState != EPVMFNodeStarted) ) )
-	{
-		// rescheduling because of input data will be handled in Command Processing Part
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - Node not in Started state yet"));
-		return;
-	}
-
-	// Process port activity, push out all outgoing messages
-	if(iOutPort.size() > 0)
-	{
-		while(iOutPort[0]->OutgoingMsgQueueSize())
-		{
-			// if port is busy it is going to wakeup from port ready event
-			if(!ProcessOutgoingMsg(iOutPort[0]))
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - Outgoing Port Busy, cannot send more msgs"));
-				break;
-			}
-		}
-	}
-
-	int loopCount = 0;
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-	uint32 startticks = OsclTickCount::TickCount();
-	uint32 starttime = OsclTickCount::TicksToMsec(startticks);
-#endif
-	do // Try to consume all the data from the Input port
-	{
-		// Process port activity if there is no input data that is being processed
-		// Do not accept any input if EOS needs to be sent out
-		if(iInPort.size() && (iInPort[0]->IncomingMsgQueueSize() > 0) && (iDataIn.GetRep() == NULL) && !iEndOfDataReached)
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - Getting more input"));
-			if (ProcessIncomingMsg(iInPort[0]) != PVMFSuccess)
-			{
-				//Re-schedule to come back.
-				RunIfNotReady();
-				return;
-			}
-		}
-
-		// If in init or ready to decode state, process data in the input port if there is input available and input buffers are present
-		// (note: at EOS, iDataIn will not be available)
-		if( (iDataIn.GetRep() != NULL) ||
-		    	((iNumOutstandingOutputBuffers < iNumOutputBuffers) &&
-				(iProcessingState == EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode) &&
-				(iResetMsgSent == false)) ||
-				( (iDynamicReconfigInProgress == true) && (iResetMsgSent==false))
-		  )
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-				(0,"PVMFOMXVideoEncNode::Run() - Calling HandleProcessingState"));
-
-			// input data is available, that means there is video data to be decoded
-    		if(HandleProcessingState() != PVMFSuccess)
-			{
-				// If HandleProcessingState does not return Success, we must wait for an event
-				// no point in  rescheduling
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-					(0,"PVMFOMXVideoEncNode::Run() - HandleProcessingState did not return Success"));
-				return;
-			}
-    	}
-    	loopCount++;
-	}while( iInPort.size() &&
-	        (( (iInPort[0]->IncomingMsgQueueSize() > 0) || (iDataIn.GetRep() != NULL) ) && (iNumOutstandingInputBuffers < iNumInputBuffers) )
-			&& (!iEndOfDataReached)
-			&& (iResetMsgSent == false)
-	      );
-#if (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_REL)
-	uint32 endticks = OsclTickCount::TickCount();
-	uint32 endtime = OsclTickCount::TicksToMsec(endticks);
-	uint32 timeinloop = (endtime - starttime);
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_INFO,
-				   (0,"PVMFOMXVideoEncNode::Run() - LoopCount = %d, Time spent in loop(in ms) = %d, iNumOutstandingInputBuffers = %d, iNumOutstandingOutputBuffers = %d ",
-				   loopCount, timeinloop, iNumOutstandingInputBuffers, iNumOutstandingOutputBuffers));
-#endif
-	// EOS processing:
-	// first send an empty buffer to OMX component and mark the EOS flag
-	// wait for the OMX component to send async event to indicate that it has reached this EOS buffer
-	// then, create and send the EOS message downstream
-
-	if(iEndOfDataReached && !iDynamicReconfigInProgress)
-	{
-
-		// if EOS was not sent yet and we have an available ninput buffer, send EOS buffer to component
-		if(!iIsEOSSentToComponent && (iNumOutstandingInputBuffers < iNumInputBuffers) )
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-				(0,"PVMFOMXVideoEncNode::Run() - Sending EOS marked buffer To Component "));
-
-			iIsEOSSentToComponent = true;
-
-
-			// if the component is not yet initialized or if it's in the middle of port reconfig,
-			// don't send EOS buffer to component. It does not care. Just set the flag as if we received
-			// EOS from the component to enable sending EOS downstream
-			if(iProcessingState != EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode)
-			{
-				iIsEOSReceivedFromComponent = true;
-			}
-			else if( !SendEOSBufferToOMXComponent() )
-			{
-				// for some reason, Component can't receive the EOS buffer
-				// it could be that it is not initialized yet (because EOS could be the first msg). In this case,
-				// send the EOS downstream anyway
-				iIsEOSReceivedFromComponent = true;
-			}
-		}
-
-		// We must wait for event (acknowledgment from component)
-		// before sending EOS downstream. This is because OMX Component will send
-		// the EOS event only after processing remaining buffers
-
-		if(iIsEOSReceivedFromComponent)
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-				(0,"PVMFOMXVideoEncNode::Run() - Received EOS from component, Sending EOS msg downstream "));
-
-			if((iOutPort.size() > 0) && iOutPort[0]->IsOutgoingQueueBusy())
-			{
-				// note: we already tried to empty the outgoing q. If it's still busy,
-				// it means that output port is busy. Just return and wait for the port to become free.
-				// this will wake up the node and it will send out a msg from the q etc.
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-				(0,"PVMFOMXVideoEncNode::Run() - - EOS cannot be sent downstream, outgoing queue busy - wait"));
-				return;
-			}
-
-			if(SendEndOfTrackCommand()) // this will only q the EOS
-			{
-				// EOS send downstream OK, so reset the flag
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-					(0,"PVMFOMXVideoEncNode::Run() - EOS was queued to be sent downstream"));
-
-				iEndOfDataReached = false; // to resume normal processing, reset the flags
-				iIsEOSSentToComponent = false;
-				iIsEOSReceivedFromComponent = false;
-
-				RunIfNotReady(); // Run again to send out the EOS msg from the outgoing q, and resume
-								 // normal processing
-				ReportInfoEvent(PVMFInfoEndOfData);
-			}
-		}
-		else
-		{
-			// keep sending output buffers, it's possible that the component needs to flush output
-			//	data at the end
-			while(iNumOutstandingOutputBuffers < iNumOutputBuffers)
-			{
-				if(!SendOutputBufferToOMXComponent())
-					break;
-			}
-		}
-
-	}
-
-
-	//Check for flash command complition...
-	if ((iInPort.size() > 0) && (iOutPort.size() > 0) && (iCurrentCmd.size()>0)&&
-		(iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH)&&
-		(iInPort[0]->IncomingMsgQueueSize() == 0)&&
-		(iOutPort[0]->OutgoingMsgQueueSize() == 0)&&
-		(iDataIn.GetRep() == NULL) )
-	{
-			//flush command is complited
-			//Debug check-- all the port queues should be empty at this point.
-
-			OSCL_ASSERT(iInPort[0]->IncomingMsgQueueSize() == 0 && iOutPort[0]->OutgoingMsgQueueSize() == 0);
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::Run() - Flush pending"));
-			iEndOfDataReached=false;
-			iIsEOSSentToComponent = false;
-			iIsEOSReceivedFromComponent = false;
-
-
-			//Flush is complete.  Go to initialized state.
-			SetState(EPVMFNodePrepared);
-			//resume port input so the ports can be re-started.
-			iInPort[0]->ResumeInput();
-			iOutPort[0]->ResumeInput();
-			CommandComplete(iCurrentCmd,iCurrentCmd.front(),PVMFSuccess);
-			RunIfNotReady();
-	}
-
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::Run: Out"));
-}
-
-/////////////////////////////////////////////////////
-//     Command processing routines
-/////////////////////////////////////////////////////
-PVMFCommandId PVMFOMXVideoEncNode::QueueCommandL(PVMFVideoEncNodeCommand& aCmd)
-{
-    if (iInterfaceState == EPVMFNodeCreated)
-    {
-        OSCL_LEAVE(OsclErrNotReady);
-        // return 0;	This statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVMFCommandId id = iCmdQueue.AddL(aCmd);
-    RunIfNotReady();
-    return id;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::ProcessCommand(PVMFVideoEncNodeCommand& aCmd)
-{
-    // If a command is active, only high priority commands can interrupt
-    // the processing
-    if (!iCurrentCmd.empty() && !aCmd.hipri())
-        return false;
-
-    switch (aCmd.iCmd)
-    {
-        case PVMF_GENERIC_NODE_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELCOMMAND:
-            DoCancelCommand(aCmd);
-            break;
-
-        default://unknown command type
-            LOG_ERR((0, "PVMFOMXVideoEncNode::ProcessCommand: Error - Unknown command type %d", aCmd.iCmd));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            break;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::CommandComplete(PVMFVideoEncNodeCmdQueue& aCmdQueue, PVMFVideoEncNodeCommand& aCmd,
-        PVMFStatus aStatus, OsclAny* aData)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::CommandComplete: Id=%d, Type=%d, Status=%d, Context=0x%x, Data0x%x"
-                     , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aData));
-
-    //create response
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aData);
-    PVMFSessionId session = aCmd.iSession;
-
-    //Erase the command from the queue.
-    aCmdQueue.Erase(&aCmd);
-
-    //Report completion to the session observer.
-    ReportCmdCompleteEvent(session, resp);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoQueryUuid(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::DoQueryUuid"));
-    OSCL_String* mimetype;
-    Oscl_Vector<PVUuid, OsclMemAllocator>* uuidvec;
-    bool exactMatch;
-    aCmd.Parse(mimetype, uuidvec, exactMatch);
-
-    int32 err = 0;
-    PVMFStatus status = PVMFSuccess;
-    OSCL_TRY(err, uuidvec->push_back(PVMp4H263EncExtensionUUID););
-    OSCL_FIRST_CATCH_ANY(err, status = PVMFErrNoMemory;);
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoQueryInterface(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::DoQueryInterface"));
-    PVUuid* uuid;
-    PVInterface** ptr;
-    aCmd.Parse(uuid, ptr);
-
-    PVMFStatus status = PVMFSuccess;
-    if (!queryInterface(*uuid, *ptr))
-        status = PVMFFailure;
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoRequestPort(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::DoRequestPort"));
-    int32 tag;
-    OSCL_String* mimetype;
-    PVMFVideoEncPort* port = NULL;
-    aCmd.Parse(tag, mimetype);
-
-    switch (tag)
-    {
-        case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (iInPort.size() >= PVMF_OMX_VIDEOENC_NODE_MAX_INPUT_PORT)
-            {
-                LOG_ERR((0, "PVMFOMXVideoEncNode::DoRequestPort: Error - Max number of input port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVVideoEncIn";
-
-            port = AllocatePort(iInPort, tag, mimetype, portname.get_cstr());
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-
-        break;
-
-        case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-        {
-            if (iOutPort.size() >= PVMF_OMX_VIDEOENC_NODE_MAX_OUTPUT_PORT)
-            {
-                LOG_ERR((0, "PVMFOMXVideoEncNode::DoRequestPort: Error - Max number of output port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVVideoEncOut";
-
-            port = AllocatePort(iOutPort, tag, mimetype, portname.get_cstr());
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        break;
-
-        default:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::DoRequestPort: Error - Invalid port tag"));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            return;
-    }
-
-    //Return the port pointer to the caller.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess, (OsclAny*)port);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncPort* PVMFOMXVideoEncNode::AllocatePort(PVMFVideoEncPortVector& aPortVector, int32 aTag,
-        OSCL_String* aMimeType, const char* aName)
-{
-    int32 err = 0;
-    OsclAny* ptr = NULL;
-
-    // Allocate a new port
-    OSCL_TRY(err,
-             ptr = aPortVector.Allocate();
-             if (!ptr)
-             OSCL_LEAVE(PVMFErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFOMXVideoEncNode::AllocatePort: Error - iPortVector Out of memory"));
-                         return NULL;
-                        );
-    PVMFVideoEncPort* port = OSCL_PLACEMENT_NEW(ptr, PVMFVideoEncPort(aTag, this, Priority(), aName));
-
-    // if format was provided in mimestring, set it now.
-    if (aMimeType)
-    {
-        PVMFFormatType format = GetFormatIndex(aMimeType->get_str());
-        if ((port->SetFormat(format) != PVMFSuccess) ||
-                ((aTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT) && (SetCodecType(format) != PVMFSuccess)))
-        {
-            aPortVector.DestructAndDealloc(port);
-            LOG_ERR((0, "PVMFOMXVideoEncNode::AllocatePort: Error - port->SetFormat or SetCodecType failed"));
-            return NULL;
-        }
-    }
-
-    OSCL_TRY(err, aPortVector.AddL(port););
-    OSCL_FIRST_CATCH_ANY(err,
-                         aPortVector.DestructAndDealloc(port);
-                         return NULL;
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoReleasePort(PVMFVideoEncNodeCommand& aCmd)
-{
-    //Find the port in the port vector
-    PVMFVideoEncPort* port = NULL;
-    PVMFVideoEncPort** portPtr = NULL;
-    aCmd.Parse((PVMFPortInterface*&)port);
-
-    if (!port)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::DoReleasePort: Error - Invalid port pointer"));
-        CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-        return;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (port->GetPortTag())
-    {
-        case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT:
-            portPtr = iInPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PVMFOMXVideoEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iInPort.Erase(portPtr);
-            }
-            break;
-
-        case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-            portPtr = iOutPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PVMFOMXVideoEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iOutPort.Erase(portPtr);
-            }
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::DoReleasePort: Error - Invalid port tag"));
-            status = PVMFFailure;
-            break;
-    }
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoInit(PVMFVideoEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            SetState(EPVMFNodeInitialized);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeInitialized:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoPrepare(PVMFVideoEncNodeCommand& aCmd)
-{
-    OMX_ERRORTYPE err = OMX_ErrorNone;
-    OMX_STRING Role = NULL;
-
-    LOG_STACK_TRACE((0, "PVMFVIdeoEncNode::DoPrepare"));
-    mInputBufferRefCount = 0;
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-		{
-            // Check format of output data
-            uint32 Format = ((PVMFVideoEncPort*)iOutPort[0])->iFormat;
-            switch (Format)
-            {
-                case PVMF_H263:
-                    Role = "video_encoder.h263";
-                    break;
-                case PVMF_M4V:
-                    Role = "video_encoder.mpeg4";
-                    break;
-                case PVMF_H264:
-                case PVMF_H264_MP4:
-                case PVMF_H264_RAW:
-                    //Role = "video_encoder.avc";
-                    //break;
-                case PVMF_WMV:
-                    //Role = "video_encoder.wmv";
-                    //break;
-                default:
-                    // Illegal codec specified.
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFOMXVideoEncNode::DoPrepare() Input port format other then codec type"));
-                    CommandComplete(iCmdQueue, aCmd, PVMFErrArgument);
-                    return;
-            }
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoEncNode::Initializing OMX component and encoder for role %s", Role));
-
-            /* Set callback structure */
-            iCallbacks.EventHandler    = CallbackEventHandler;    //event_handler;
-            iCallbacks.EmptyBufferDone = CallbackEmptyBufferDone; //empty_buffer_done;
-            iCallbacks.FillBufferDone  = CallbackFillBufferDone;  //fill_buffer_done;
-
-            // determine components which can fit the role
-            // then, create the component. If multiple components fit the role,
-            // the first one registered will be selected. If that one fails to
-            // be created, the second one in the list is selected etc.
-            OMX_U32 num_comps = 0;
-            OMX_STRING *CompOfRole;
-            // call once to find out the number of components that can fit the role
-            //PV_Master
-            PV_MasterOMX_GetComponentsOfRole(Role, &num_comps, NULL);
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                            (0, "PVMFOMXVideoEncNode::DoPrepare(): There are %d components of role %s ", num_comps, Role));
-
-            int i;
-
-            if (num_comps > 0)
-            {
-                CompOfRole = (OMX_STRING *)oscl_malloc(num_comps * sizeof(OMX_STRING));
-
-                for (i = 0; i < num_comps; i++)
-                    CompOfRole[i] = (OMX_STRING) oscl_malloc(PV_OMX_MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8));
-
-                // call 2nd time to get the component names
-                //PV_Master
-                PV_MasterOMX_GetComponentsOfRole(Role, &num_comps, (OMX_U8 **)CompOfRole);
-
-                for (i = 0; i < num_comps; i++)
-                {
-                    // try to create component
-                    err = PV_MasterOMX_GetHandle(&iOMXVideoEncoder, (OMX_STRING)CompOfRole[i], (OMX_PTR)this, (OMX_CALLBACKTYPE *) & iCallbacks);
-
-                    // if successful, no need to continue
-                    if ( (err == OMX_ErrorNone) && (iOMXVideoEncoder != NULL))
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMFOMXVideoEncNode::DoPrepare(): Got Component %s handle ", CompOfRole[i]));
-
-                        break;
-                    }
-                    else
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                                        (0, "PVMFOMXVideoEncNode::DoPrepare(): Cannot get component %s handle, try another component if available", CompOfRole[i]));
-                    }
-                }
-                // whether successful or not, need to free CompOfRoles
-                for (i = 0; i < num_comps; i++)
-                {
-                    oscl_free(CompOfRole[i]);
-                    CompOfRole[i] = NULL;
-                }
-
-                oscl_free(CompOfRole);
-                // check if there was a problem
-                if ( (err != OMX_ErrorNone) || (iOMXVideoEncoder == NULL) )
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoEncNode::Can't get handle for encoder!"));
-                    iOMXVideoEncoder = NULL;
-                    CommandComplete(iCmdQueue, aCmd, PVMFErrResource);
-                    return;
-                }
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoEncNode::No component can handle role %s !", Role));
-                iOMXVideoEncoder = NULL;
-                CommandComplete(iCmdQueue, aCmd, PVMFErrResource);
-                return;
-            }
-
-            if (!iOMXVideoEncoder)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-            // GET CAPABILITY FLAGS FROM PV COMPONENT, IF this fails, use defaults
-            PV_OMXComponentCapabilityFlagsType Cap_flags = {OMX_FALSE, OMX_FALSE, OMX_FALSE, OMX_FALSE};
-            err = OMX_GetParameter(iOMXVideoEncoder, (OMX_INDEXTYPE)PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX, &Cap_flags);
-            if (err != OMX_ErrorNone)
-            {
-                SetDefaultCapabilityFlags();
-            }
-            else
-            {
-                iIsOMXComponentMultiThreaded =					 Cap_flags.iIsOMXComponentMultiThreaded;
-                iOMXComponentSupportsExternalInputBufferAlloc =	 Cap_flags.iOMXComponentSupportsExternalInputBufferAlloc;
-                iOMXComponentSupportsExternalOutputBufferAlloc = Cap_flags.iOMXComponentSupportsExternalOutputBufferAlloc;
-                iOMXComponentSupportsMovableInputBuffers =		 Cap_flags.iOMXComponentSupportsMovableInputBuffers;
-                //temporarily define 3 flags here
-                iOMXComponentSupportsPartialFrames = true;
-                iOMXComponentCanHandleIncompleteFrames = true;
-            }
-
-            // make sure that copying is used where necessary
-            if (!iOMXComponentSupportsPartialFrames)
-            {
-                iOMXComponentSupportsMovableInputBuffers = false;
-            }
-
-            // find out about parameters
-            if (!NegotiateComponentParameters())
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoEncNode::DoPrepare() Cannot get component parameters"));
-
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoResources);
-                return;
-            }
-
-			// create active objects to handle callbacks in case of multithreaded implementation
-			// NOTE: CREATE THE THREADSAFE CALLBACK AOs REGARDLESS OF WHETHER MULTITHREADED COMPONENT OR NOT
-			//		If it is not multithreaded, we won't use them
-			//		The Flag iIsComponentMultiThreaded decides which mechanism is used for callbacks.
-			//		This flag is set by looking at component capabilities (or to true by default)
-			if(iThreadSafeHandlerEventHandler)
-			{
-				OSCL_DELETE(iThreadSafeHandlerEventHandler);
-				iThreadSafeHandlerEventHandler = NULL;
-			}
-			// substitute default parameters: observer(this node),queuedepth(3),nameAO for logging
-			// Get the priority of video dec node, and set the threadsafe callback AO priority to 1 higher
-			iThreadSafeHandlerEventHandler = OSCL_NEW(EventHandlerThreadSafeCallbackAO,(this,10,"EventHandlerAO",Priority()+2));
-
-			if(iThreadSafeHandlerEmptyBufferDone)
-			{
-				OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone);
-				iThreadSafeHandlerEmptyBufferDone = NULL;
-			}
-			// use queue depth of iNumInputBuffers to prevent deadlock
-			iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO,(this,iNumInputBuffers,"EmptyBufferDoneAO",Priority()+1));
-
-			if(iThreadSafeHandlerFillBufferDone)
-			{
-				OSCL_DELETE(iThreadSafeHandlerFillBufferDone);
-				iThreadSafeHandlerFillBufferDone = NULL;
-			}
-			// use queue depth of iNumOutputBuffers to prevent deadlock
-			iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO,(this,iNumOutputBuffers,"FillBufferDoneAO",Priority()+1));
-
-			if( (iThreadSafeHandlerEventHandler == NULL) ||
-				(iThreadSafeHandlerEmptyBufferDone == NULL) ||
-				(iThreadSafeHandlerFillBufferDone == NULL)
-			)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::Can't get threadsafe callbacks for encoder!"));
-						iOMXVideoEncoder = NULL;
-			}
-
-			// Init Encoder
-			iCurrentEncoderState = OMX_StateLoaded;
-
-            /* Change state to OMX_StateIdle from OMX_StateLoaded. */
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                (0,"PVMFOMXVideoEncNode::DoPrepare(): Changing Component state Loaded -> Idle "));
-
-            err = OMX_SendCommand(iOMXVideoEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-            if (err != OMX_ErrorNone)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                    (0,"PVMFOMXVideoEncNode::DoPrepare() Can't send StateSet command!"));
-                CommandComplete(iCmdQueue,aCmd,PVMFErrNoResources);
-                return;
-            }
-
-			/* Allocate input buffers */
-			if(!CreateInputMemPool(iNumInputBuffers))
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::DoPrepare() Can't allocate mempool for input buffers!"));
-
-				CommandComplete(iCmdQueue,aCmd,PVMFErrNoResources);
-				return;
-			}
-
-			if(!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
-										  iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  iNumInputBuffers, // number of buffers
-										  iOMXComponentInputBufferSize, // actual buffer size
-										  iInputPortIndex, // port idx
-										  iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
-										  true // this is input
-										  ))
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::DoPrepare() Component can't use input buffers!"));
-
-				CommandComplete(iCmdQueue,aCmd,PVMFErrNoResources);
-				return;
-			}
-
-			/* Allocate output buffers */
-			if(!CreateOutputMemPool(iNumOutputBuffers))
-			{
-
-                                LOGE("DoPrepare(): failed in allocating mempool for output buffers!");
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::DoPrepare() Can't allocate mempool for output buffers!"));
-
-				CommandComplete(iCmdQueue,aCmd,PVMFErrNoResources);
-				return;
-			}
-
-			if(!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
-										  iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  iNumOutputBuffers, // number of buffers
-										  iOMXComponentOutputBufferSize, // actual buffer size
-										  iOutputPortIndex, // port idx
-										  iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
-										  false // this is not input
-										  ))
-			{
-
-                                LOGE("DoPrepare(): OMX component failed in using output buffers!");
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::DoPrepare() Component can't use output buffers!"));
-
-				CommandComplete(iCmdQueue,aCmd,PVMFErrNoResources);
-				return;
-			}
-
-			//this command is asynchronous.  move the command from
-			//the input command queue to the current command, where
-			//it will remain until it completes. We have to wait for
-			// OMX component state transition to complete
-#if 1
-			int32 err;
-			OSCL_TRY(err,iCurrentCmd.StoreL(aCmd););
-			if (err!=OsclErrNone)
-			{
-				CommandComplete(iCmdQueue,aCmd,PVMFErrNoMemory);
-				return;
-			}
-			iCmdQueue.Erase(&aCmd);
-#else
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-#endif
-            break;
-		}
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoStart(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::DoStart"));
-
-	PVMFStatus status = PVMFSuccess;
-
-	OMX_ERRORTYPE  err;
-	OMX_STATETYPE sState;
-
-	switch(iInterfaceState)
-	{
-		case EPVMFNodePrepared:
-		case EPVMFNodePaused:
-		{
-			//Get state of OpenMAX encoder
-			err = OMX_GetState(iOMXVideoEncoder, &sState);
-			if (err != OMX_ErrorNone)
-			{
-				//Error condition report
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-
-					(0,"PVMFOMXVideoEncNode::DoStart(): Can't get State of encoder!"));
-
-				sState = OMX_StateInvalid;
-			}
-
-			if ((sState == OMX_StateIdle) || (sState == OMX_StatePause))
-			{
-				/* Change state to OMX_StateExecuting form OMX_StateIdle. */
-				// init the flag
-				iDoNotSendOutputBuffersDownstreamFlag = false; // or if output was not being sent downstream due to state changes
-																// re-anable sending output
-
-				iDoNotSaveInputBuffersFlag = false;
-
-
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-					(0,"PVMFOMXVideoEncNode::DoStart() Changing Component state Idle->Executing"));
-
-				err = OMX_SendCommand(iOMXVideoEncoder, OMX_CommandStateSet, OMX_StateExecuting, NULL);
-				if (err != OMX_ErrorNone)
-				{
-					//Error condition report
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::DoStart(): Can't send StateSet command to encoder!"));
-
-					status = PVMFErrInvalidState;
-				}
-
-			}
-			else
-			{
-				//Error condition report
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::DoStart(): Encoder is not in the Idle or Pause state!"));
-
-				status = PVMFErrInvalidState;
-			}
-		}
-			break;
-
-		default:
-			status = PVMFErrInvalidState;
-			break;
-	}
-
-	if (status == PVMFErrInvalidState)
-	{
-		CommandComplete(iCmdQueue, aCmd, status);
-	}
-	else
-	{
-		//this command is asynchronous.  move the command from
-		//the input command queue to the current command, where
-		//it will remain until it completes.
-		int32 err;
-		OSCL_TRY(err,iCurrentCmd.StoreL(aCmd););
-		if (err!=OsclErrNone)
-		{
-			CommandComplete(iCmdQueue,aCmd,PVMFErrNoMemory);
-		}
-		iCmdQueue.Erase(&aCmd);
-	}
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoStop(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::DoStop"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        {
-            // Clear queued messages in ports
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                iInPort[i]->ClearMsgQueues();
-            for (i = 0; i < iOutPort.size(); i++)
-                iOutPort[i]->ClearMsgQueues();
-
-            // Video encoder is created on Start, so in parallel it's deleted in Stop
-            DeleteVideoEncoder();
-            //transition to Prepared state
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-
-        }
-        break;
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DeleteVideoEncoder()
-{
-
-    if (iOMXVideoEncoder != NULL)
-    {
-        OMX_ERRORTYPE err;
-        /* Free Component handle. */
-        err = PV_MasterOMX_FreeHandle(iOMXVideoEncoder);
-        if (err != OMX_ErrorNone)
-        {
-            //Error condition report
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoEncNode::DeleteVideoEncoder(): Can't free encoder's handle!"));
-        }
-        iOMXVideoEncoder = NULL;
-
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoFlush(PVMFVideoEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            int32 err;
-            uint32 i;
-            bool msgPending;
-            msgPending = false;
-
-            for (i = 0; i < iInPort.size(); i++)
-            {
-                if (iInPort[i]->IncomingMsgQueueSize() > 0)
-                    msgPending = true;
-                iInPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessIncomingMsgReady
-                    // to wake up port AO
-                    ((PVMFVideoEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                }
-            }
-
-            for (i = 0; i < iOutPort.size(); i++)
-            {
-                if (iOutPort[i]->OutgoingMsgQueueSize() > 0)
-                    msgPending = true;
-                iOutPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessOutgoingMsgReady
-                    // to wake up port AO
-                    ((PVMFVideoEncPort*)iOutPort[i])->ProcessOutgoingMsgReady();
-                }
-            }
-
-			OMX_ERRORTYPE omx_err;
-			OMX_STATETYPE sState;
-
-			//Get state of OpenMAX encoder
-			omx_err = OMX_GetState(iOMXVideoEncoder, &sState);
-			if (omx_err != OMX_ErrorNone)
-			{
-				//Error condition report
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::DoStop(): Can't get State of encoder!"));
-
-				sState = OMX_StateInvalid;
-			}
-
-			if ((sState == OMX_StateExecuting) || (sState == OMX_StatePause))
-			{
-				/* Change state to OMX_StateIdle from OMX_StateExecuting or OMX_StatePause. */
-
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-					(0,"PVMFOMXVideoEncNode::DoStop() Changing Component State Executing->Idle or Pause->Idle"));
-
-				omx_err = OMX_SendCommand(iOMXVideoEncoder, OMX_CommandStateSet, OMX_StateIdle, NULL);
-				if (omx_err != OMX_ErrorNone)
-				{
-					//Error condition report
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					 (0,"PVMFOMXVideoEncNode::DoStop(): Can't send StateSet command to encoder!"));
-
-					CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-					break;
-				}
-
-				// prevent the node from sending more buffers etc.
-				// if port reconfiguration is in process, let the state remain one of the port config states
-				//	if there is a start command, we can do it seemlessly (by continuing the port reconfig)
-				if(iProcessingState == EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode)
-					iProcessingState = EPVMFOMXVideoEncNodeProcessingState_Stopping;
-
-                                // HTC fix for race condition between pv omx encoder node and qualcomm encoder
-                                LOGV("==> %s: mInputBufferRefCount = %d", __FUNCTION__, mInputBufferRefCount);
-                                if (mInputBufferRefCount != 0) {
-                                    LOGV("@@@@@@@ wait for encoder @@@@@@@@");
-                                    return;
-                                }
-
-			}
-			else
-			{
-				//Error condition report
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-					(0,"PVMFOMXVideoEncNode::DoStop(): Encoder is not in the Executing or Pause state!"));
-
-				CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-				break;
-			}
-
-            //the flush is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until the flush completes.
-            OSCL_TRY(err, iCurrentCmd.StoreL(aCmd););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                                 return;
-                                );
-            iCmdQueue.Erase(&aCmd);
-            if (!msgPending)
-            {
-                FlushComplete();
-                return;
-            }
-            break;
-
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::IsFlushPending()
-{
-    return (iCurrentCmd.size() > 0
-            && iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::FlushComplete()
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::FlushComplete"));
-    uint32 i = 0;
-
-    // Flush is complete only when all queues of all ports are clear.
-    // Other wise, just return from this method and wait for FlushComplete
-    // from the remaining ports.
-    for (i = 0; i < iInPort.size(); i++)
-    {
-        if ( iInPort[i]->IncomingMsgQueueSize() > 0 ||
-                iInPort[i]->OutgoingMsgQueueSize() > 0 )
-        {
-            return;
-        }
-    }
-
-    for (i = 0; i < iOutPort.size(); i++)
-    {
-        if ( iOutPort[i]->IncomingMsgQueueSize() > 0 ||
-                iOutPort[i]->OutgoingMsgQueueSize() > 0 )
-        {
-            return;
-        }
-    }
-
-    // Video encoder is created on Start, so in parallel it's deleted when Flush is completed
-    // FIXME: Need to understand whether this code is needed
-    // DeleteVideoEncoder();
-    // resume port input so the ports can be re-started.
-    for (i = 0; i < iInPort.size(); i++)
-        iInPort[i]->ResumeInput();
-    for (i = 0; i < iOutPort.size(); i++)
-        iOutPort[i]->ResumeInput();
-
-    // Flush is complete.  Go to prepared state.
-    //SetState(EPVMFNodePrepared);
-    //CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-
-    //if (!iCmdQueue.empty())
-    //{
-    //    // If command queue is not empty, schedule to process the next command
-    //    RunIfNotReady();
-    //}
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoPause(PVMFVideoEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-            SetState(EPVMFNodePaused);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePaused:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoReset(PVMFVideoEncNodeCommand& aCmd)
-{
-
-	OMX_ERRORTYPE  err;
-	OMX_STATETYPE sState;
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::DoReset() In"));
-
-	switch(iInterfaceState)
-	{
-		case EPVMFNodeIdle:
-		case EPVMFNodeInitialized:
-		case EPVMFNodePrepared:
-		case EPVMFNodeStarted:
-		case EPVMFNodePaused:
-		case EPVMFNodeError:
-		{
-			//Check if encoder is initilized
-			if (iOMXVideoEncoder != NULL)
-			{
-
-				//if we're in the middle of a partial frame assembly
-				// abandon it and start fresh
-				if(iObtainNewInputBuffer == false)
-				{
-					if(iInputBufferUnderConstruction != NULL)
-					{
-						if(iInBufMemoryPool!=NULL )
-						{
-							iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
-						}
-						iInputBufferUnderConstruction = NULL;
-					}
-					iObtainNewInputBuffer = true;
-
-				}
-
-				iKeepDroppingMsgsUntilMarkerBit = false;
-
-				// HTC's fix for the race condition between pv omx encoder node and qualcomm encoder
-				// Remove polling the state of OpenMAX encoder to reduce the extra delay
-				err = OMX_GetState(iOMXVideoEncoder, &sState);
-				if (err != OMX_ErrorNone)
-				{
-					//Error condition report
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::DoReset(): Can't get State of encoder!"));
-					if(iResetInProgress)
-					{
-						// cmd is in current q
-						iResetInProgress = false;
-						if((iCurrentCmd.size()>0) &&
-						   (iCurrentCmd.front().iCmd==PVMF_GENERIC_NODE_RESET)
-						   )
-						{
-							CommandComplete(iCurrentCmd,iCurrentCmd.front(),PVMFErrResource);
-						}
-					}
-					else
-					{
-						CommandComplete(iCmdQueue,aCmd,PVMFErrResource);
-					}
-					return;
-				}
-
-				if (sState == OMX_StateLoaded)
-				{
-					// this is a value obtained by synchronous call to component. Either the component was
-					// already in this state without node issuing any commands,
-					// or perhaps we started the Reset, but the callback notification has not yet arrived.
-					if(iResetInProgress)
-					{
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						 (0,"PVMFOMXVideoEncNode::DoReset() OMX comp is in loaded state. Wait for official callback to change variables etc."));
-						return;
-					}
-					else
-					{
-						CommandComplete(iCmdQueue,aCmd,PVMFErrResource);
-						return;
-					}
-				}
-
-				if (sState == OMX_StateIdle)
-				{
-					//this command is asynchronous.  move the command from
-					//the input command queue to the current command, where
-					//it will remain until it is completed.
-					if(!iResetInProgress)
-					{
-						int32 err;
-						OSCL_TRY(err,iCurrentCmd.StoreL(aCmd););
-						if (err != OsclErrNone)
-						{
-							CommandComplete(iCmdQueue,aCmd,PVMFErrNoMemory);
-							return;
-						}
-						iCmdQueue.Erase(&aCmd);
-
-						iResetInProgress = true;
-					}
-
-					// if buffers aren't all back (due to timing issues with different callback AOs
-					//		state change can be reported before all buffers are returned)
-					if(iNumOutstandingInputBuffers > 0 || iNumOutstandingOutputBuffers > 0)
-					{
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::DoReset() Waiting for %d input and-or %d output buffers",iNumOutstandingInputBuffers,iNumOutstandingOutputBuffers));
-
-						return;
-					}
-
-					if(!iResetMsgSent)
-					{
-						// We can come here only if all buffers are already back
-						// Don't repeat any of this twice.
-						/* Change state to OMX_StateLoaded form OMX_StateIdle. */
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-							(0,"PVMFOMXVideoEncNode::DoReset() Changing Component State Idle->Loaded"));
-
-						err = OMX_SendCommand(iOMXVideoEncoder, OMX_CommandStateSet, OMX_StateLoaded, NULL);
-						if (err != OMX_ErrorNone)
-						{
-							//Error condition report
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-								(0,"PVMFOMXVideoEncNode::DoReset(): Can't send StateSet command to encoder!"));
-						}
-
-						iResetMsgSent = true;
-
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-							(0,"PVMFOMXVideoEncNode::DoReset() freeing output buffers"));
-
-						if(iOutputBuffersFreed == false)
-						{
-							if( !FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
-										  iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  iNumOutputBuffers, // number of buffers
-										  iOutputPortIndex, // port idx
-										  false // this is not input
-										  ))
-							{
-								PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-									(0,"PVMFOMXVideoEncNode::DoReset() Cannot free output buffers "));
-
-								if(iResetInProgress)
-								{
-									iResetInProgress = false;
-									if((iCurrentCmd.size() > 0) &&
-										(iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_RESET)
-									)
-									{
-										CommandComplete(iCurrentCmd,iCurrentCmd.front() ,PVMFErrResource);
-									}
-								}
-							}
-						}
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-							(0,"PVMFOMXVideoEncNode::DoReset() freeing input buffers "));
-
-						if(iInputBuffersFreed == false)
-						{
-							if( !FreeBuffersFromComponent(iInBufMemoryPool, // allocator
-												  iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-												  iNumInputBuffers, // number of buffers
-												  iInputPortIndex, // port idx
-												  true // this is input
-												  ))
-							{
-								PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-									(0,"PVMFOMXVideoEncNode::DoReset() Cannot free input buffers "));
-
-								if(iResetInProgress)
-								{
-									iResetInProgress = false;
-									if((iCurrentCmd.size() > 0) &&
-									   (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_RESET)
-									   )
-									{
-										CommandComplete(iCurrentCmd,iCurrentCmd.front(),PVMFErrResource);
-									}
-								}
-							}
-						}
-
-						iEndOfDataReached = false;
-						iIsEOSSentToComponent = false;
-						iIsEOSReceivedFromComponent = false;
-
-						// also, perform Port deletion when the component replies with the command
-						// complete, not right here
-					} // end of if(iResetMsgSent)
-
-					return;
-
-				}
-				else
-				{
-					//Error condition report
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::DoReset(): encoder is not in the Idle state!"));
-					if(iResetInProgress)
-					{
-						iResetInProgress = false;
-						if( (iCurrentCmd.size()>0) &&
-							(iCurrentCmd.front().iCmd==PVMF_GENERIC_NODE_RESET)
-							)
-						{
-							CommandComplete(iCurrentCmd,iCurrentCmd.front(),PVMFErrInvalidState);
-						}
-					}
-					else
-					{
-                                                // HTC's fix for the race condition between pv omx encoder node and
-                                                // qualcomm encoder.
-                                                if (sState == OMX_StateExecuting) {
-                                                    LOGV("@@@@@@@@@@@ reset wait for encoder @@@@@@@@@@");
-                                                    return;
-                                                }
-						CommandComplete(iCmdQueue,aCmd,PVMFErrInvalidState);
-					}
-					break;
-				}//end of if (sState == OMX_StateIdle)
-			}//end of if (iOMXVideoEncoder != NULL)
-
-		    //This example node allows a reset from any idle state.
-		    if (IsAdded())
-		    {
-		        while (!iInPort.empty())
-		            iInPort.Erase(&iInPort.front());
-		        while (!iOutPort.empty())
-		            iOutPort.Erase(&iOutPort.front());
-
-		        //restore original port vector reserve.
-		        iInPort.Reconstruct();
-		        iOutPort.Reconstruct();
-		    }
-		    else
-		    {
-		        OSCL_LEAVE(OsclErrInvalidState);
-
-		    }
-
-			iDataIn.Unbind();
-
-			iEndOfDataReached = false;
-			iIsEOSSentToComponent = false;
-			iIsEOSReceivedFromComponent = false;
-
-			iProcessingState = EPVMFOMXVideoEncNodeProcessingState_Idle;
-			//logoff & go back to Created state.
-			SetState(EPVMFNodeIdle);
-
-			if(iResetInProgress)
-			{
-				iResetInProgress = false;
-				if((iCurrentCmd.size()>0) &&
-				   (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_RESET)
-				   )
-				{
-					CommandComplete(iCurrentCmd,iCurrentCmd.front(),PVMFSuccess);
-				}
-			}
-			else
-			{
-				CommandComplete(iCmdQueue,aCmd,PVMFSuccess);
-			}
-		}
-		break;
-
-		default:
-			CommandComplete(iCmdQueue,aCmd,PVMFErrInvalidState);
-			break;
-	}
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoCancelAllCommands(PVMFVideoEncNodeCommand& aCmd)
-{
-    //first cancel the current command if any
-    {
-        while (!iCurrentCmd.empty())
-            CommandComplete(iCurrentCmd, iCurrentCmd[0], PVMFErrCancelled);
-    }
-
-    //next cancel all queued commands
-    {
-        //start at element 1 since this cancel command is element 0.
-        while (iCmdQueue.size() > 1)
-            CommandComplete(iCmdQueue, iCmdQueue[1], PVMFErrCancelled);
-    }
-
-    //finally, report cancel complete.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::DoCancelCommand(PVMFVideoEncNodeCommand& aCmd)
-{
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.Parse(id);
-
-    //first check "current" command if any
-    {
-        PVMFVideoEncNodeCommand* cmd = iCurrentCmd.FindById(id);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCurrentCmd, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PVMFVideoEncNodeCommand* cmd = iCmdQueue.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCmdQueue, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//               Port activity processing routines
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::IsProcessOutgoingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsConnectedPortBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::IsProcessIncomingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsOutgoingQueueBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::ProcessIncomingMsg: aPort=0x%x", aPort));
-    PVMFStatus status = PVMFFailure;
-
-    switch (aPort->GetPortTag())
-    {
-        case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (!IsProcessIncomingMsgReady())
-            {
-                LOG_ERR((0, "PVMFOMXVideoEncNode::ProcessIncomingMsg: Error - Not ready."));
-                return PVMFErrBusy;
-            }
-
-            PVMFSharedMediaMsgPtr msg;
-            status = aPort->DequeueIncomingMsg(msg);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PVMFOMXVideoEncNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed"));
-                return status;
-            }
-
-            if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
-            {
-                status = SendEndOfTrackCommand(msg);
-                return status;
-            }
-			convertToPVMFMediaData(iDataIn, msg);
-			status = PVMFSuccess;
-
-			iCurrFragNum = 0; // for new message, reset the fragment counter
-			iIsNewDataFragment = true;
-        }
-        break;
-
-        case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-            // Nothing to be done
-            status = PVMFSuccess;
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::ProcessIncomingMsg: Error - Invalid port tag"));
-            ReportErrorEvent(PVMF_OMX_VIDEOENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)aPort);
-            status = PVMFFailure;
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::SendEncodedBitstream(PVMFSharedMediaDataPtr& iMediaData)
-{
-    PVMFStatus status = PVMFSuccess;
-
-    // Send bitstream data to downstream node
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaMsg(mediaMsgOut, iMediaData);
-
-    for (uint32 i = 0; i < iOutPort.size(); i++)
-    {
-        status = iOutPort[i]->QueueOutgoingMsg(mediaMsgOut);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SendEncodedBitstream: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Encoder settings routines
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::SetCodecType(PVMFFormatType aCodec)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetCodecType: Error iInterfaceState=%d", iInterfaceState));
-            return PVMFErrInvalidState;
-        default:
-            break;
-    }
-
-    switch (aCodec)
-    {
-        case PVMF_H263:
-            iEncodeParam.iContentType = ECVEI_H263;
-            break;
-        case PVMF_M4V:
-            iEncodeParam.iContentType = ECVEI_STREAMING;
-            break;
-        default:
-            return PVMFErrNotSupported;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::SetInputFormat(PVMFFormatType aFormat)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::SetInputFormat: aFormat=%d", aFormat));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetInputFormat: Error - iInterfaceState=%d", iInterfaceState));
-            return PVMFErrInvalidState;
-        default:
-            break;
-    }
-
-    switch (aFormat)
-    {
-        case PVMF_YUV420:
-            iInputFormat.iVideoFormat = ECVEI_YUV420;
-            break;
-        case PVMF_YUV422:
-            iInputFormat.iVideoFormat = ECVEI_UYVY;
-            break;
-        case PVMF_RGB24:
-            iInputFormat.iVideoFormat = ECVEI_RGB24;
-            break;
-        case PVMF_RGB12:
-            iInputFormat.iVideoFormat = ECVEI_RGB12;
-            break;
-        default:
-            return PVMFFailure;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetInputFrameSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-        default:
-            break;
-    }
-
-    iInputFormat.iFrameWidth = aWidth;
-    iInputFormat.iFrameHeight = aHeight;
-    iInputFormat.iFrameOrientation = aFrmOrient;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::SetInputFrameRate(OsclFloat aFrameRate)
-{
-    LOGV("SetInputFrameRate(%f)", aFrameRate);
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SetInputFrameRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-        default:
-            break;
-    }
-
-    if (aFrameRate < MIN_FRAME_RATE_IN_FPS) {
-        LOGE("intended input frame rate is too low");
-        return false;
-    }
-    iInputFormat.iFrameRate = OSCL_STATIC_CAST(float, aFrameRate);
-    iEncodeParam.iNoFrameSkip = iEncodeParam.iNoCurrentSkip = false;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFFormatType PVMFOMXVideoEncNode::GetCodecType()
-{
-    switch (iEncodeParam.iContentType)
-    {
-        case ECVEI_H263:
-            return PVMF_H263;
-        case ECVEI_STREAMING:
-        case ECVEI_DOWNLOAD:
-            return PVMF_M4V;
-        default:
-            return PVMF_FORMAT_UNKNOWN;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PVMFOMXVideoEncNode::GetOutputBitRate(uint32 aLayer)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::GetOutputBitRate: Error - Invalid layer number"));
-        return 0;
-    }
-
-    return iEncodeParam.iBitRate[aLayer];
-}
-
-////////////////////////////////////////////////////////////////////////////
-OsclFloat PVMFOMXVideoEncNode::GetOutputFrameRate(uint32 aLayer)
-{
-    LOGV("GetOutputFrameRate");
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::GetOutputFrameRate: Error Invalid layer number"));
-        return 0;
-    }
-   
-    return (OsclFloat)iEncodeParam.iFrameRate[aLayer];
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFOMXVideoEncNode::GetOutputFrameSize: Error Invalid layer number"));
-        return PVMFFailure;
-    }
-
-    aWidth = iEncodeParam.iFrameWidth[aLayer];
-    aHeight = iEncodeParam.iFrameHeight[aLayer];
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PVMFOMXVideoEncNode::GetIFrameInterval()
-{
-    return iEncodeParam.iIFrameInterval;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Event reporting routines.
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::SetState(TPVMFNodeInterfaceState aState)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::SetState %d", aState));
-    PVMFNodeInterface::SetState(aState);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_ERR((0, "PVMFOMXVideoEncNode::ReportErrorEvent: aEventType=%d aEventData=0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_STACK_TRACE((0, "PVMFOMXVideoEncNode::ReportInfoEvent: aEventType=%d, aEventData0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
-}
-
-PVMFStatus PVMFOMXVideoEncNode::SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg)
-{
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    sharedMediaCmdPtr->setTimestamp(aMsg->getTimestamp());
-
-    // Set the sequence number
-    sharedMediaCmdPtr->setSeqNum(aMsg->getSeqNum());
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-
-    for (uint32 ii = 0; ii < iOutPort.size(); ii++)
-    {
-        PVMFStatus status = iOutPort[ii]->QueueOutgoingMsg(mediaMsgOut);
-
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SendEndOfTrackCommand: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::SetDefaultCapabilityFlags()
-{
-
-    iIsOMXComponentMultiThreaded = true;
-
-    iOMXComponentSupportsExternalOutputBufferAlloc = true;
-    iOMXComponentSupportsExternalInputBufferAlloc = false;
-    iOMXComponentSupportsMovableInputBuffers = false;
-
-    iOMXComponentSupportsPartialFrames = false;
-    iOMXComponentCanHandleIncompleteFrames = false;
-
-    return true;
-}
-////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::NegotiateComponentParameters()
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() In"));
-
-    OMX_ERRORTYPE Err;
-    // first get the number of ports and port indices
-    OMX_PORT_PARAM_TYPE VideoPortParameters;
-    uint32 NumPorts;
-    uint32 ii;
-
-    // get starting number
-    CONFIG_VERSION_SIZE(VideoPortParameters);
-    Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamVideoInit, &VideoPortParameters);
-    NumPorts = VideoPortParameters.nPorts; // must be at least 2 of them (in&out)
-
-    if ( Err != OMX_ErrorNone || NumPorts < 2)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() There is insuffucient (%d) ports", NumPorts));
-        return false;
-    }
-
-    // loop through video ports starting from the starting index to find index of the first input port
-    for (ii = VideoPortParameters.nStartPortNumber ;ii < VideoPortParameters.nStartPortNumber + NumPorts; ii++)
-    {
-        // get port parameters, and determine if it is input or output
-        // if there are more than 2 ports, the first one we encounter that has input direction is picked
-
-        //port
-        CONFIG_VERSION_SIZE(iParamPort);
-
-        iParamPort.nPortIndex = ii; // iInputPortIndex; //OMF_MC_H264D_PORT_INDEX_OF_STREAM;
-        Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-
-        if (Err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with port %d ", ii));
-
-            return false;
-        }
-
-        if (iParamPort.eDir == OMX_DirInput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Found Input port index %d ", ii));
-
-            iInputPortIndex = ii;
-            break;
-        }
-    }
-    if (ii == VideoPortParameters.nStartPortNumber + NumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Cannot find any input port "));
-        return false;
-    }
-
-    // loop through video ports starting from the starting index to find index of the first output port
-    for (ii = VideoPortParameters.nStartPortNumber ;ii < VideoPortParameters.nStartPortNumber + NumPorts; ii++)
-    {
-        // get port parameters, and determine if it is input or output
-        // if there are more than 2 ports, the first one we encounter that has output direction is picked
-
-        CONFIG_VERSION_SIZE(iParamPort);
-
-        //port
-        iParamPort.nPortIndex = ii;
-        Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-
-        if (Err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with port %d ", ii));
-
-            return false;
-        }
-
-        if (iParamPort.eDir == OMX_DirOutput)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Found Output port index %d ", ii));
-
-            iOutputPortIndex = ii;
-            break;
-        }
-    }
-    if (ii == VideoPortParameters.nStartPortNumber + NumPorts)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Cannot find any output port "));
-        return false;
-    }
-
-    CONFIG_VERSION_SIZE(iParamPort);
-    //Input port
-    iParamPort.nPortIndex = iInputPortIndex;
-    Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with input port %d ", iInputPortIndex));
-        return false;
-    }
-
-    uint32 width, height;
-    GetOutputFrameSize(0, width, height);
-
-    iParamPort.format.video.nFrameWidth = width;
-    iParamPort.format.video.nFrameHeight = height;
-
-    Err = OMX_SetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem setting parameters in input port %d ", iInputPortIndex));
-        return false;
-    }
-
-    //Port 1 for output port
-    CONFIG_VERSION_SIZE(iParamPort);
-
-    iParamPort.nPortIndex = iOutputPortIndex;
-    Err = OMX_GetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output port %d ", iOutputPortIndex));
-        return false;
-    }
-
-    iParamPort.format.video.nFrameWidth = width;
-    iParamPort.format.video.nFrameHeight = height;
-
-    Err = OMX_SetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem setting parameters in output port %d ", iOutputPortIndex));
-        return false;
-    }
-
-    // FIXME: This should consider non-mpeg4 component {
-    //*********************************************************************************************
-    //*********************************************************************************************
-    OMX_VIDEO_PARAM_PROFILELEVELTYPE profileLevel; // OMX_IndexParamVideoProfileLevelCurrent
-    CONFIG_VERSION_SIZE(profileLevel);
-    Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamVideoProfileLevelCurrent, &profileLevel);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output profileLevel"));
-        return false;
-    }
-    if (width <= 176)
-    {
-        profileLevel.eLevel = OMX_VIDEO_MPEG4Level0;
-    }
-    else
-    {
-        profileLevel.eLevel = OMX_VIDEO_MPEG4Level1;
-    }
-    Err = OMX_SetParameter(iOMXVideoEncoder, OMX_IndexParamVideoProfileLevelCurrent, &profileLevel);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output profileLevel"));
-        return false;
-    }
-    //*********************************************************************************************
-    //*********************************************************************************************
-    // FIXME: This should consider non-mpeg4 component {
-
-    OMX_VIDEO_PARAM_BITRATETYPE bitrate; // OMX_IndexParamVideoBitrate
-    CONFIG_VERSION_SIZE(bitrate);
-    Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamVideoBitrate, &bitrate);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output bitrate"));
-        return false;
-    }
-    bitrate.eControlRate = OMX_Video_ControlRateVariable;
-    bitrate.nTargetBitrate = GetOutputBitRate(0);
-    Err = OMX_SetParameter(iOMXVideoEncoder, OMX_IndexParamVideoBitrate, &bitrate);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output bitrate"));
-        return false;
-    }
-
-    OMX_CONFIG_FRAMERATETYPE framerate; // OMX_IndexConfigVideoFramerate
-    CONFIG_VERSION_SIZE(framerate);
-    Err = OMX_GetConfig(iOMXVideoEncoder, OMX_IndexConfigVideoFramerate, &framerate);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output framerate"));
-        return false;
-    }
-    int nFrameRate = (int)GetOutputFrameRate(0);
-    framerate.xEncodeFramerate = nFrameRate << 16;
-    Err = OMX_SetConfig(iOMXVideoEncoder, OMX_IndexConfigVideoFramerate, &framerate);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output framerate"));
-        return false;
-    }
-
-    CONFIG_VERSION_SIZE(iParamPort);
-    //Input port
-    iParamPort.nPortIndex = iInputPortIndex;
-    Err = OMX_GetParameter(iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with input port %d ", iInputPortIndex));
-        return false;
-    }
-
-    // preset the number of input buffers
-    //iNumInputBuffers = NUMBER_INPUT_BUFFER;
-    iNumInputBuffers = iParamPort.nBufferCountActual;
-
-    // do we need to increase the number of buffers?
-    if (iNumInputBuffers < iParamPort.nBufferCountMin)
-        iNumInputBuffers = iParamPort.nBufferCountMin;
-
-    iOMXComponentInputBufferSize = iParamPort.nBufferSize;
-
-    iParamPort.nBufferCountActual = iNumInputBuffers;
-
-    // set the number of actual input buffers
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Inport buffers %d,size %d", iNumInputBuffers, iOMXComponentInputBufferSize));
-
-    Err = OMX_SetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem setting parameters in input port %d ", iInputPortIndex));
-        return false;
-    }
-
-    //Port 1 for output port
-    CONFIG_VERSION_SIZE(iParamPort);
-
-    iParamPort.nPortIndex = iOutputPortIndex;
-    Err = OMX_GetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem negotiating with output port %d ", iOutputPortIndex));
-        return false;
-    }
-
-    iNumOutputBuffers = iParamPort.nBufferCountActual;
-    if (iNumOutputBuffers > NUMBER_OUTPUT_BUFFER)
-        iNumOutputBuffers = NUMBER_OUTPUT_BUFFER;
-
-    iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
-
-    // FIXME:
-    // Allocate larger output buffer to reduce the chance that qualcomm encoder
-    // overflows the supplied buffers. This should never happen, if qualcomm
-    // encoder checks the buffer size before writing output data to the buffer. 
-    if (iInputFormat.iFrameRate > MIN_FRAME_RATE_IN_FPS) {
-        // Qualcomm encoder rate control assumes fixed frame rate; thus, we have to
-        // consider the worst case for buffer size allocation. The required buffer size
-        // according to Qualcomm is inversely proportional to the input frame rate. 
-        iOMXComponentOutputBufferSize *= (iInputFormat.iFrameRate / MIN_FRAME_RATE_IN_FPS);
-    }
-    iParamPort.nBufferSize = iOMXComponentOutputBufferSize;  // Keep encoder informed of the updated size
-    
-    if (iNumOutputBuffers < iParamPort.nBufferCountMin)
-        iNumOutputBuffers = iParamPort.nBufferCountMin;
-
-    iParamPort.nBufferCountActual = iNumOutputBuffers;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Outport buffers %d,size %d", iNumOutputBuffers, iOMXComponentOutputBufferSize));
-
-    Err = OMX_SetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-    if (Err != OMX_ErrorNone)
-    {
-        LOGE("NegotiateComponentParameters(): failed in setting parameters in output port %d ", iOutputPortIndex);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem setting parameters in output port %d ", iOutputPortIndex));
-        return false;
-    }
-
-    // Get video color format
-    OMX_VIDEO_PARAM_PORTFORMATTYPE VideoPortFormat;
-    OMX_COLOR_FORMATTYPE VideoColorFormat;
-    // init to unknown
-    VideoColorFormat = OMX_COLOR_FormatUnused;
-    CONFIG_VERSION_SIZE(VideoPortFormat);
-    VideoPortFormat.nPortIndex = iInputPortIndex;
-    VideoPortFormat.nIndex = 0; // read the preferred format - first
-
-    // doing this in a while loop while incrementing nIndex will get all supported formats
-    // until component says OMX_ErrorNoMore
-    // For now, we just use the preferred one (with nIndex=0) assuming it is supported at MIO
-    Err = OMX_GetParameter (iOMXVideoEncoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
-    if (Err != OMX_ErrorNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem getting video port format"));
-        return false;
-    }
-    // check if color format is valid
-    if (VideoPortFormat.eCompressionFormat == OMX_VIDEO_CodingUnused)
-    {
-        // color format is valid, so read it
-        VideoColorFormat = VideoPortFormat.eColorFormat;
-
-
-        // Now set the format to confirm parameters
-        CONFIG_VERSION_SIZE(VideoPortFormat);
-        Err = OMX_SetParameter (iOMXVideoEncoder, OMX_IndexParamVideoPortFormat, &VideoPortFormat);
-        if (Err != OMX_ErrorNone)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::NegotiateComponentParameters() Problem setting video port format"));
-            return false;
-        }
-    }
-
-    // now that we have the color format, interpret it
-    if (VideoColorFormat == OMX_COLOR_Format8bitRGB332)
-    {
-        iOMXComponentInputYUVFormat = PVMF_RGB8;
-    }
-    else if (VideoColorFormat == OMX_COLOR_Format12bitRGB444)
-    {
-        iOMXComponentInputYUVFormat = PVMF_RGB12;
-    }
-    else if (VideoColorFormat >= OMX_COLOR_Format16bitARGB4444 && VideoColorFormat <= OMX_COLOR_Format16bitBGR565)
-    {
-        iOMXComponentInputYUVFormat = PVMF_RGB16;
-    }
-    else if (VideoColorFormat >= OMX_COLOR_Format24bitRGB888 && VideoColorFormat <= OMX_COLOR_Format24bitARGB1887)
-    {
-        iOMXComponentInputYUVFormat = PVMF_RGB24;
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV420Planar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV420_PLANAR; // Y, U, V are separate - entire planes
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV420PackedPlanar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV420_PACKEDPLANAR; // each slice contains Y,U,V separate
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV420_SEMIPLANAR; // Y and UV interleaved - entire planes
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV422PackedSemiPlanar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV422_PACKEDSEMIPLANAR; // Y and UV interleaved - sliced
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV422Planar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV422_PLANAR; // Y, U, V are separate - entire planes
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV422PackedPlanar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV422_PACKEDPLANAR; // each slice contains Y,U,V separate
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV422SemiPlanar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV422_SEMIPLANAR; // Y and UV interleaved - entire planes
-    }
-    else if (VideoColorFormat == OMX_COLOR_FormatYUV422PackedSemiPlanar)
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV422_PACKEDSEMIPLANAR; // Y and UV interleaved - sliced
-    }
-    else if (VideoColorFormat == 0x7FA30C00) // TODO: Implementation specific value, need a better way to handle this
-    {
-        iOMXComponentInputYUVFormat = PVMF_YUV420_SEMIPLANAR_YVU; // semiplanar with Y and VU interleaved
-    }
-    else
-    {
-        iOMXComponentInputYUVFormat = PVMF_FORMAT_UNKNOWN;
-        return false;
-    }
-
-    return true;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::CreateOutputMemPool(uint32 num_buffers)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::CreateOutMemPool() start"));
-	// In the case OMX component wants to allocate its own buffers,
-	// mempool only contains OutputBufCtrlStructures (i.e. ptrs to buffer headers)
-	// In case OMX component uses pre-allocated buffers (here),
-	// mempool allocates OutputBufCtrlStructure (i.e. ptrs to buffer hdrs), followed by actual buffers
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::CreateOutMemPool() Allocating output buffer header pointers"));
-
-	iOutputAllocSize = oscl_mem_aligned_size((uint32)sizeof(OutputBufCtrlStruct));
-
-	if(iOMXComponentSupportsExternalOutputBufferAlloc)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::CreateOutMemPool() Allocating output buffers of size %d as well",iOMXComponentOutputBufferSize));
-		// Actual output buffer size is based on pre-negotiated output buffer size
-		iOutputAllocSize += (iOMXComponentOutputBufferSize + 4096);
-	}
-        LOGD("@@@@@@@@@@@@ iOutputAllocSize = %d and iOMXComponentOutputBufferSize = %d @@@@@@@@@@@@@", iOutputAllocSize, iOMXComponentOutputBufferSize);
-
-	// for media data wrapper
-	if (iMediaDataMemPool)
-	{
-		iMediaDataMemPool->removeRef();
-		iMediaDataMemPool = NULL;
-	}
-
-	if (iOutBufMemoryPool)
-	{
-		iOutBufMemoryPool->removeRef();
-		iOutBufMemoryPool = NULL;
-	}
-
-	int32 leavecode = 0;
-	OSCL_TRY(leavecode, iOutBufMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers)););
-	if (leavecode || iOutBufMemoryPool == NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::CreateOutMemPool() Memory pool structure for output buffers failed to allocate"));
-		return false;
-	}
-
-	// allocate a dummy buffer to actually create the mempool
-	OsclAny *dummy_alloc = NULL; // this dummy buffer will be released at end of scope
-	leavecode = 0;
-	OSCL_TRY(leavecode, dummy_alloc = iOutBufMemoryPool->allocate(iOutputAllocSize));
-	if (leavecode || dummy_alloc == NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::CreateOutMemPool() Memory pool for output buffers failed to allocate"));
-		return false;
-	}
-	iOutBufMemoryPool->deallocate(dummy_alloc);
-	// init the counter
-	iNumOutstandingOutputBuffers = 0;
-
-	// allocate mempool for media data message wrapper
-	leavecode = 0;
-	OSCL_TRY(leavecode, iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (num_buffers, PVOMXVIDEOENC_MEDIADATA_CHUNKSIZE)) );
-	if (leavecode || iMediaDataMemPool == NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::CreateOutMemPool() Media Data Buffer pool for output buffers failed to allocate"));
-		return false;
-	}
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::CreateOutMemPool() done"));
-	return true;
-}
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////// Creates memory pool for input buffer management ///////////////////////
-/////////////////////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::CreateInputMemPool(uint32 num_buffers)
-{
-	// 3 cases in order of preference and simplicity
-
-	// Case 1 (buffers allocated upstream - no memcpy needed):
-	//	PV OMX Component - We use buffers allocated outside the OMX node (i.e. allocated upstream)
-	// Mempool contains InputBufCtrlStructures (ptrs to buffer headers and PMVFMediaData ptrs - to keep track of when to unbind input msgs)
-
-	// NOTE:	in this case, when providing input buffers to OMX component,
-	//			OMX_UseBuffer calls will provide some initial pointers and sizes of buffers, but these
-	//			are dummy values. Actual buffer pointers and filled sizes will be obtained from the input msg fragments.
-	//			The PV OMX component will use the buffers even if the ptrs differ from the ones during initialization
-	//			3rd party OMX components can also use this case if they are capable of ignoring the actual buffer pointers in
-	//			buffer header field (i.e. if after OMX_UseBuffer(...) call, they allow the ptr to actual buffer data to change at a later time
-
-	// CASE 2 (buffers allocated in the node - memcpy needed)
-	//			If 3rd party OMX component can use buffers allocated outside the OMX component, but it cannot
-	//			change buffer ptr allocations dynamically (i.e. after initialization with OMX_UseBuffer call is complete)
-
-	//		Mempool contains InputBufCtrlStructures (ptrs to buffer headers, PVMFMediaData ptrs to keep track of when to unbind input msgs) +
-	//				actual buffers.
-	//			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component
-
-	// CASE 3 (buffers allocated in the component - memcpy needed)
-	//			If 3rd party OMX component must allocate its own buffers
-	//			Mempool only contains InputBufCtrlStruct (ptrs to buffer headers + PMVFMediaData ptrs to keep track of when to unbind input msgs)
-	//			NOTE: Data must be copied from input message into the local buffer before the buffer is given to the OMX component (like in case 2)
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::CreateInputMemPool() start "));
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::CreateInputMemPool() allocating buffer header pointers and shared media data ptrs "));
-
-	iInputAllocSize = oscl_mem_aligned_size((uint32) sizeof(InputBufCtrlStruct)); //aligned_size_buffer_header_ptr+aligned_size_media_data_ptr;
-
-	// Need to allocate buffers in the node either if component supports external buffers buffers
-	// but they are not movable
-
-	if(iOMXComponentSupportsExternalInputBufferAlloc)
-	{
-		//pre-negotiated input buffer size
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::CreateOutMemPool() Allocating input buffers of size %d as well",iOMXComponentInputBufferSize));
-
-		iInputAllocSize += iOMXComponentInputBufferSize;
-	}
-
-	if (iInBufMemoryPool)
-	{
-		iInBufMemoryPool->removeRef();
-		iInBufMemoryPool = NULL;
-	}
-
-	int32 leavecode = 0;
-	OSCL_TRY(leavecode, iInBufMemoryPool = OSCL_NEW( OsclMemPoolFixedChunkAllocator, (num_buffers)););
-	if (leavecode || iInBufMemoryPool == NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::CreateInputMemPool() Memory pool structure for input buffers failed to allocate"));
-		return false;
-	}
-	// try to allocate a dummy buffer to actually create the mempool and allocate the needed memory
-	// allocate a dummy buffer to actually create the mempool, this dummy buffer will be released at end of scope of this method
-	OsclAny *dummy_alloc = NULL;
-	leavecode = 0;
-	OSCL_TRY(leavecode, dummy_alloc = iInBufMemoryPool->allocate(iInputAllocSize));
-	if (leavecode || dummy_alloc==NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-		PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::CreateInputMemPool() Memory pool for input buffers failed to allocate"));
-		return false;
-	}
-	iInBufMemoryPool->deallocate(dummy_alloc);
-
-	// init the counter
-	iNumOutstandingInputBuffers = 0;
-
-	iInputBufferToResendToComponent = NULL; // nothing to resend yet
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::CreateInputMemPool() done"));
-	return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-										  uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  uint32 aNumBuffers,    // number of buffers
-										  uint32 aActualBufferSize, // aactual buffer size
-										  uint32 aPortIndex,      // port idx
-										  bool aUseBufferOK,		// can component use OMX_UseBuffer or should it use OMX_AllocateBuffer
-										  bool	aIsThisInputBuffer		// is this input or output
-										  )
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::ProvideBuffersToComponent() enter"));
-
-	uint32 ii=0;
-	OMX_ERRORTYPE err = OMX_ErrorNone;
-	OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
-
-	ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
-	if(ctrl_struct_ptr == NULL)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::ProvideBuffersToComponent ctrl_struct_ptr == NULL"));
-		return false;
-	}
-
-	// Now, go through all buffers and tell component to
-	// either use a buffer, or to allocate its own buffer
-	for (ii = 0; ii < aNumBuffers; ii++)
-	{
-		int32 errcode=0;
-		// get the address where the buf hdr ptr will be stored
-		OSCL_TRY(errcode, ctrl_struct_ptr[ii] = (OsclAny *) aMemPool->allocate(aAllocSize));
-		if ( (errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL) )
-		{
-			if (errcode == OsclErrNoResources)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::ProvideBuffersToComponent ->allocate() failed for no mempool chunk available"));
-			}
-			else
-			{
-				// General error
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-				(0,"PVMFOMXVideoEncNode::ProvideBuffersToComponent ->allocate() failed due to some general error"));
-
-				ReportErrorEvent(PVMFFailure);
-				SetState(EPVMFNodeError);
-			}
-
-			return false;
-		}
-
-		memset(ctrl_struct_ptr[ii], 0, aAllocSize);
-
-		if(aUseBufferOK)
-		{
-			// Buffers are already allocated outside OMX component.
-			// In case of output buffers, the buffer itself is located
-			// just after the buffer header pointer.
-
-			// In case of input buffers, the buffer header pointer is followed by a MediaDataSharedPtr
-			//	which is used to ensure proper unbinding of the input messages. The buffer itself is either:
-			//		a) allocated upstream (and the ptr to the buffer
-			//			is a dummy pointer to which the component does not pay attention - PV OMX component)
-			//		b) located just after the buffer header pointer and MediaDataSharedPtr
-
-			uint8 *pB = ((uint8*) ctrl_struct_ptr[ii]);
-
-			// in case of input buffers, initialize also MediaDataSharedPtr structure
-			if(aIsThisInputBuffer)
-			{
-				InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
-				temp->pMediaData = PVMFSharedMediaDataPtr(NULL,NULL);
-
-				// advance ptr to skip the structure
-				pB += oscl_mem_aligned_size(sizeof(InputBufCtrlStruct));
-
-				err = OMX_UseBuffer(iOMXVideoEncoder,	// hComponent
-								&(temp->pBufHdr),		// address where ptr to buffer header will be stored
-								aPortIndex,				// port index (for port for which buffer is provided)
-								ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
-														//				to have a context when component returns with a callback (i.e. to know
-														//				what to free etc.
-								(OMX_U32)aActualBufferSize,	// buffer size
-								pB);						// buffer data ptr
-
-			}
-			else
-			{
-				OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
-
-				// advance buffer ptr to skip the structure
-				pB += oscl_mem_aligned_size(sizeof(OutputBufCtrlStruct));
-
-					err = OMX_UseBuffer(iOMXVideoEncoder,	// hComponent
-								&(temp->pBufHdr),		// address where ptr to buffer header will be stored
-								aPortIndex,				// port index (for port for which buffer is provided)
-								ctrl_struct_ptr[ii],	// App. private data = pointer to beginning of allocated data
-														//				to have a context when component returns with a callback (i.e. to know
-														//				what to free etc.
-								(OMX_U32)aActualBufferSize,	// buffer size
-								pB);						// buffer data ptr
-			}
-		}
-		else{
-			// the component must allocate its own buffers.
-			if(aIsThisInputBuffer)
-			{
-
-				InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
-				// make sure ptrs are initialized to NULL
-				temp->pMediaData = PVMFSharedMediaDataPtr(NULL,NULL);
-
-				err = OMX_AllocateBuffer(iOMXVideoEncoder,
-									&(temp->pBufHdr),
-									aPortIndex,
-									ctrl_struct_ptr[ii],
-									(OMX_U32)aActualBufferSize);
-			}
-			else
-			{
-				OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
-				err = OMX_AllocateBuffer(iOMXVideoEncoder,
-									&(temp->pBufHdr),
-									aPortIndex,
-									ctrl_struct_ptr[ii],
-									(OMX_U32)aActualBufferSize);
-			}
-
-		}
-
-		if (err != OMX_ErrorNone)
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-			(0,"PVMFOMXVideoEncNode::ProvideBuffersToComponent() Problem using/allocating a buffer"));
-
-			return false;
-		}
-
-	}
-
-	for(ii = 0; ii < aNumBuffers; ii++)
-	{
-		// after initializing the buffer hdr ptrs, return them
-		// to the mempool
-		aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
-	}
-
-	oscl_free(ctrl_struct_ptr);
-	// set the flags
-	if(aIsThisInputBuffer)
-	{
-		iInputBuffersFreed = false;
-	}
-	else
-	{
-		iOutputBuffersFreed = false;
-	}
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::ProvideBuffersToComponent() done"));
-	return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-										  uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  uint32 aNumBuffers,    // number of buffers
-										  uint32 aPortIndex,      // port idx
-										  bool	aIsThisInputBuffer		// is this input or output
-										  )
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::FreeBuffersToComponent() enter"));
-
-	uint32 ii=0;
-	OMX_ERRORTYPE err = OMX_ErrorNone;
-	OsclAny **ctrl_struct_ptr = NULL;	// temporary array to keep the addresses of buffer ctrl structures and buffers
-
-	ctrl_struct_ptr = (OsclAny **) oscl_malloc(aNumBuffers * sizeof(OsclAny *));
-	if(ctrl_struct_ptr == NULL)
-	{
-		return false;
-	}
-
-	// Now, go through all buffers and tell component to free them
-	for (ii = 0; ii < aNumBuffers; ii++)
-	{
-		int32 errcode=0;
-		// get the address where the buf hdr ptr will be stored
-
-		OSCL_TRY(errcode, ctrl_struct_ptr[ii] = (OsclAny *) aMemPool->allocate(aAllocSize));
-		if ( (errcode != OsclErrNone) || (ctrl_struct_ptr[ii] == NULL) )
-		{
-			if (errcode == OsclErrNoResources)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::FreeBuffersFromComponent ->allocate() failed for no mempool chunk available"));
-			}
-			else
-			{
-				// General error
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-				(0,"PVMFOMXVideoEncNode::FreeBuffersFromComponent ->allocate() failed due to some general error"));
-
-				ReportErrorEvent(PVMFFailure);
-				SetState(EPVMFNodeError);
-			}
-
-			return false;
-		}
-		// to maintain correct count
-		aMemPool->notifyfreechunkavailable( (*this), (OsclAny*) aMemPool);
-
-		if(aIsThisInputBuffer)
-		{
-			iNumOutstandingInputBuffers++;
-			// get the buf hdr pointer
-			InputBufCtrlStruct *temp = (InputBufCtrlStruct *) ctrl_struct_ptr[ii];
-			err = OMX_FreeBuffer(iOMXVideoEncoder,
-								aPortIndex,
-								temp->pBufHdr);
-		}
-		else
-		{
-			iNumOutstandingOutputBuffers++;
-			OutputBufCtrlStruct *temp = (OutputBufCtrlStruct *) ctrl_struct_ptr[ii];
-			err = OMX_FreeBuffer(iOMXVideoEncoder,
-								 aPortIndex,
-								 temp->pBufHdr);
-		}
-
-		if (err != OMX_ErrorNone)
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-			(0,"PVMFOMXVideoEncNode::FreeBuffersFromComponent() Problem freeing a buffer"));
-
-			return false;
-		}
-
-	}
-
-	for(ii = 0; ii < aNumBuffers; ii++)
-	{
-		// after freeing the buffer hdr ptrs, return them
-		// to the mempool (which will itself then be deleted promptly)
-		aMemPool->deallocate((OsclAny*) ctrl_struct_ptr[ii]);
-	}
-
-	oscl_free(ctrl_struct_ptr);
-
-	// mark buffers as freed (so as not to do it twice)
-	if(aIsThisInputBuffer)
-	{
-		iInputBuffersFreed = true;
-	}
-	else
-	{
-		iOutputBuffersFreed = true;
-	}
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::FreeBuffersFromComponent() done"));
-	return true;
-}
-
-// Callback processing in multithreaded case - dequeued event - call EventHandlerProcessing
-OsclReturnCode PVMFOMXVideoEncNode::ProcessCallbackEventHandler_MultiThreaded(OsclAny* P)
-{
-    // re-cast the pointer
-    EventHandlerSpecificData* ED = (EventHandlerSpecificData*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_EVENTTYPE aEvent = ED->eEvent;
-    OMX_U32 aData1 = ED->nData1;
-    OMX_U32 aData2 = ED->nData2;
-    OMX_PTR aEventData = ED->pEventData;
-
-    EventHandlerProcessing(aComponent, aAppData, aEvent, aData1, aData2, aEventData);
-
-    // release the allocated memory when no longer needed
-    iThreadSafeHandlerEventHandler->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-// Callback processing in multithreaded case - dequeued event - call EmptyBufferDoneProcessing
-OsclReturnCode PVMFOMXVideoEncNode::ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P)
-{
-    // re-cast the pointer
-    EmptyBufferDoneSpecificData* ED = (EmptyBufferDoneSpecificData*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
-
-    EmptyBufferDoneProcessing(aComponent, aAppData, aBuffer);
-
-    // release the allocated memory when no longer needed
-    iThreadSafeHandlerEmptyBufferDone->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-
-// Callback processing in multithreaded case - dequeued event - call FillBufferDoneProcessing
-OsclReturnCode PVMFOMXVideoEncNode::ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P)
-{
-    // re-cast the pointer
-    FillBufferDoneSpecificData* ED = (FillBufferDoneSpecificData*) P;
-
-    OMX_HANDLETYPE aComponent = ED->hComponent;
-    OMX_PTR aAppData = ED->pAppData;
-    OMX_BUFFERHEADERTYPE* aBuffer = ED->pBuffer;
-
-    FillBufferDoneProcessing(aComponent, aAppData, aBuffer);
-
-    // release the allocated memory when no longer needed
-    iThreadSafeHandlerFillBufferDone->iMemoryPool->deallocate(ED);
-    ED = NULL;
-
-    return OsclSuccess;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR EVENT HANDLER
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXVideoEncNode::EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_EVENTTYPE aEvent,
-        OMX_OUT OMX_U32 aData1,
-        OMX_OUT OMX_U32 aData2,
-        OMX_OUT OMX_PTR aEventData)
-{
-    OSCL_UNUSED_ARG(aComponent);
-    OSCL_UNUSED_ARG(aAppData);
-    OSCL_UNUSED_ARG(aEventData);
-
-    switch (aEvent)
-    {
-        case OMX_EventCmdComplete:
-        {
-
-            switch (aData1)
-            {
-                case OMX_CommandStateSet:
-                {
-                    HandleComponentStateChange(aData2);
-                    break;
-                }
-                case OMX_CommandPortDisable:
-                {
-                    // if port disable command is done, we can re-allocate the buffers and re-enable the port
-
-                    iProcessingState = EPVMFOMXVideoEncNodeProcessingState_PortReEnable;
-                    iPortIndexForDynamicReconfig = aData2;
-
-                    RunIfNotReady();
-                    break;
-                }
-                case OMX_CommandPortEnable:
-                    // port enable command is done. Check if the other port also reported change.
-                    // If not, we can start data flow. Otherwise, must start dynamic reconfig procedure for
-                    // the other port as well.
-                {
-                    if (iSecondPortReportedChange)
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, dynamic reconfiguration needed on port %d", aData2, iSecondPortToReconfig));
-
-                        iProcessingState = EPVMFOMXVideoEncNodeProcessingState_PortReconfig;
-                        iPortIndexForDynamicReconfig = iSecondPortToReconfig;
-                        iSecondPortReportedChange = false;
-                    }
-                    else
-                    {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_CommandPortEnable - completed on port %d, resuming normal data flow", aData2));
-                        iProcessingState = EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode;
-                        iDynamicReconfigInProgress = false;
-                    }
-                    RunIfNotReady();
-                    break;
-                }
-                case OMX_CommandMarkBuffer:
-                    // nothing to do here yet;
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_CommandMarkBuffer - completed - no action taken"));
-
-                    break;
-
-                default:
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: Unsupported event"));
-                    break;
-                }
-            }//end of switch (aData1)
-
-            break;
-        }//end of case OMX_EventCmdComplete
-
-        case OMX_EventError:
-        {
-
-            if (aData1 == OMX_ErrorStreamCorrupt)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventError - Bitstream corrupt error"));
-                // Errors from corrupt bitstream are reported as info events
-                ReportInfoEvent(PVMFInfoProcessingFailure, NULL);
-
-            }
-            else
-            {
-
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventError"));
-                // for now, any error from the component will be reported as error
-                ReportErrorEvent(PVMF_OMX_VIDEOENC_NODE_ERROR_ENCODE_ERROR, NULL);
-                SetState(EPVMFNodeError);
-            }
-            break;
-
-        }
-
-        case OMX_EventBufferFlag:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventBufferFlag (EOS) flag returned from OMX component"));
-
-            RunIfNotReady();
-            break;
-        }//end of case OMX_EventBufferFlag
-
-        case OMX_EventMark:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventMark returned from OMX component - no action taken"));
-
-            RunIfNotReady();
-            break;
-        }//end of case OMX_EventMark
-
-        case OMX_EventPortSettingsChanged:
-        {
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventPortSettingsChanged returned from OMX component"));
-
-            // first check if dynamic reconfiguration is already in progress,
-            // if so, wait until this is completed, and then initiate the 2nd reconfiguration
-            if (iDynamicReconfigInProgress)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventPortSettingsChanged returned for port %d, dynamic reconfig already in progress", aData1));
-
-                iSecondPortToReconfig = aData1;
-                iSecondPortReportedChange = true;
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventPortSettingsChanged returned for port %d", aData1));
-
-                iProcessingState = EPVMFOMXVideoEncNodeProcessingState_PortReconfig;
-                iPortIndexForDynamicReconfig = aData1;
-                iDynamicReconfigInProgress = true;
-            }
-
-            RunIfNotReady();
-            break;
-        }//end of case OMX_PortSettingsChanged
-
-        case OMX_EventResourcesAcquired:        //not supported
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::EventHandlerProcessing: OMX_EventResourcesAcquired returned from OMX component - no action taken"));
-
-            RunIfNotReady();
-
-            break;
-        }
-
-        default:
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::EventHandlerProcessing:  Unknown Event returned from OMX component - no action taken"));
-
-            break;
-        }
-
-    }//end of switch (eEvent)
-
-    return OMX_ErrorNone;
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////
-// This function handles the event of OMX component state change
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::HandleComponentStateChange(OMX_U32 encoder_state)
-{
-    switch (encoder_state)
-    {
-        case OMX_StateIdle:
-        {
-            iCurrentEncoderState = OMX_StateIdle;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::HandleComponentStateChange: OMX_StateIdle reached"));
-
-            //  this state can be reached either going from OMX_Loaded->OMX_Idle (preparing)
-            //	or going from OMX_Executing->OMX_Idle (stopping)
-
-            if ((iCurrentCmd.size() > 0) &&
-                    (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_PREPARE))
-            {
-                iProcessingState = EPVMFOMXVideoEncNodeProcessingState_InitEncoder;
-                SetState(EPVMFNodePrepared);
-                CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-                RunIfNotReady();
-            }
-            else if ((iCurrentCmd.size() > 0) &&
-                     (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_STOP))
-            {
-                // if we are stopped, we won't start until the node gets DoStart command.
-                //	in this case, we are ready to start sending buffers
-                if (iProcessingState == EPVMFOMXVideoEncNodeProcessingState_Stopping)
-                    iProcessingState = EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode;
-                // if the processing state was not stopping, leave the state as it was (continue port reconfiguration)
-                SetState(EPVMFNodePrepared);
-                CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-
-                RunIfNotReady();
-            }
-            else if ((iCurrentCmd.size() > 0) &&
-                     (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_RESET))
-            {
-                // State change to Idle was initiated due to Reset. First need to reach idle, and then loaded
-                // Once Idle is reached, we need to initiate idle->loaded transition
-                RunIfNotReady();
-            }
-            else if ((iCurrentCmd.size() > 0) &&
-                     (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH))
-            {
-
-                SetState(EPVMFNodePrepared);
-                CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-
-                // State change to Idle was initiated due to Reset. First need to reach idle, and then loaded
-                // Once Idle is reached, we need to initiate idle->loaded transition
-                RunIfNotReady();
-            }
-			break;
-        }//end of case OMX_StateIdle
-
-        case OMX_StateExecuting:
-        {
-            iCurrentEncoderState = OMX_StateExecuting;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::HandleComponentStateChange: OMX_StateExecuting reached"));
-
-            // this state can be reached going from OMX_Idle -> OMX_Executing (preparing)
-            //	or going from OMX_Pause -> OMX_Executing (coming from pause)
-            //	either way, this is a response to "DoStart" command
-
-            if ((iCurrentCmd.size() > 0) &&
-                    (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_START))
-            {
-                SetState(EPVMFNodeStarted);
-                CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-
-                RunIfNotReady();
-            }
-
-            break;
-        }//end of case OMX_StateExecuting
-
-        case OMX_StatePause:
-        {
-            iCurrentEncoderState = OMX_StatePause;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::HandleComponentStateChange: OMX_StatePause reached"));
-
-
-            //	This state can be reached going from OMX_Executing-> OMX_Pause
-            if ((iCurrentCmd.size() > 0) &&
-                    (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_PAUSE))
-            {
-                // if we are paused, we won't start until the node gets DoStart command.
-                //	in this case, we are ready to start sending buffers
-                if (iProcessingState == EPVMFOMXVideoEncNodeProcessingState_Pausing)
-                    iProcessingState = EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode;
-                // if the processing state was not pausing, leave the state as it was (continue port reconfiguration)
-
-
-                SetState(EPVMFNodePaused);
-                CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-                RunIfNotReady();
-            }
-
-            break;
-        }//end of case OMX_StatePause
-
-        case OMX_StateLoaded:
-        {
-            iCurrentEncoderState = OMX_StateLoaded;
-
-            //  this state can be reached only going from OMX_Idle ->OMX_Loaded (stopped to reset)
-            //
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::HandleComponentStateChange: OMX_StateLoaded reached"));
-            //Check if command's responce is pending
-            if ((iCurrentCmd.size() > 0) &&
-                ((iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_RESET) ||
-                 (iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH)))
-            {
-                // move this here
-                while (!iInPort.empty())
-                    iInPort.Erase(&iInPort.front());
-                while (!iOutPort.empty())
-                    iOutPort.Erase(&iOutPort.front());
-
-                iDataIn.Unbind();
-
-                iProcessingState = EPVMFOMXVideoEncNodeProcessingState_Idle;
-                //logoff & go back to Created state.
-                SetState(EPVMFNodeIdle);
-                PVMFStatus status = ThreadLogoff();
-                CommandComplete(iCurrentCmd, iCurrentCmd.front(), status);
-                iResetInProgress = false;
-                iResetMsgSent = false;
-                DeleteVideoEncoder();
-            }
-
-            break;
-        }//end of case OMX_StateLoaded
-
-        case OMX_StateInvalid:
-        default:
-        {
-            iCurrentEncoderState = OMX_StateInvalid;
-
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFOMXVideoEncNode::HandleComponentStateChange: OMX_StateInvalid reached"));
-
-            break;
-        }//end of case OMX_StateInvalid
-
-    }
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR EMPTY BUFFER DONE - input buffer was consumed
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXVideoEncNode::EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::EmptyBufferDoneProcessing: In"));
-    
-    LOGV("==> %s: mInputBufferRefCount = %d", __FUNCTION__, mInputBufferRefCount);
-    if (mInputBufferRefCount > 0) {
-        --mInputBufferRefCount;
-    }
-    OSCL_ASSERT((void*) aComponent == (void*) iOMXVideoEncoder); // component should match the component
-    OSCL_ASSERT(aAppData == (OMX_PTR) (this));		// AppData should represent this node ptr
-
-    // first, get the buffer "context", i.e. pointer to application private data that contains the
-    // address of the mempool buffer (so that it can be released)
-    InputBufCtrlStruct *pContext = (InputBufCtrlStruct *) (aBuffer->pAppPrivate);
-
-    // if a buffer is not empty, log a msg, but release anyway
-    if ( (aBuffer->nFilledLen > 0) && (iDoNotSaveInputBuffersFlag == false) )
-        // if dynamic port reconfig is in progress for input port, don't keep the buffer
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::EmptyBufferDoneProcessing: Input buffer returned non-empty with %d bytes still in it", aBuffer->nFilledLen));
-
-
-    }
-
-    iInputBufferToResendToComponent = NULL;
-
-
-    // input buffer is to be released,
-    // refcount needs to be decremented (possibly - the input msg associated with the buffer will be unbound)
-    // NOTE: in case of "moveable" input buffers (passed into component without copying), unbinding decrements a refcount which eventually results
-    //			in input message being released back to upstream mempool once all its fragments are returned
-    //		in case of input buffers passed into component by copying, unbinding has no effect
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::EmptyBufferDoneProcessing: Release input buffer (with %d refcount remaining of input message)", (pContext->pMediaData).get_count() - 1 ));
-
-
-    (pContext->pMediaData).Unbind();
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::EmptyBufferDoneProcessing: Release input buffer %x back to mempool", pContext));
-
-    iInBufMemoryPool->deallocate((OsclAny *) pContext);
-
-
-    // the OMX spec says that no error is to be returned
-    return OMX_ErrorNone;
-
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-////////////////////// CALLBACK PROCESSING FOR FILL BUFFER DONE - output buffer is ready
-/////////////////////////////////////////////////////////////////////////////
-OMX_ERRORTYPE PVMFOMXVideoEncNode::FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-        OMX_OUT OMX_PTR aAppData,
-        OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: In"));
-
-    OSCL_ASSERT((void*) aComponent == (void*) iOMXVideoEncoder); // component should match the component
-    OSCL_ASSERT(aAppData == (OMX_PTR) (this));		// AppData should represent this node ptr
-
-    // first, get the buffer "context", i.e. pointer to application private data that contains the
-    // address of the mempool buffer (so that it can be released)
-    OsclAny *pContext = (OsclAny*) aBuffer->pAppPrivate;
-
-
-    // check for EOS flag
-    if ( (aBuffer->nFlags & OMX_BUFFERFLAG_EOS) )
-    {
-        // EOS received
-        iIsEOSReceivedFromComponent = true;
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Output buffer has EOS set"));
-
-    }
-
-    // if a buffer is empty, or if it should not be sent downstream (say, due to state change)
-    // release the buffer back to the pool
-    if ( (aBuffer->nFilledLen == 0) || (iDoNotSendOutputBuffersDownstreamFlag == true) )
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Release output buffer %x back to mempool - buffer empty or not to be sent downstream", pContext));
-
-        iOutBufMemoryPool->deallocate(pContext);
-    }
-    else
-    {
-
-#if 0
-        // iFrameCounter was not defined. The information about the total number of output frame
-        // might be useful, but removed it for now. -jdong
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Output frame %d received", iFrameCounter++));
-#endif
-
-        // get pointer to actual buffer data
-        uint8 *pBufdata = ((uint8*) aBuffer->pBuffer);
-        // move the data pointer based on offset info
-        pBufdata += aBuffer->nOffset;
-
-		if ((iSeqNum == 0) && (((PVMFVideoEncPort*)iOutPort[0])->iFormat == PVMF_M4V))
-		{
-#if 0
-			const char frame_header_start[4] = {0x00, 0x00, 0x01, 0xB6};
-			int i;
-
-			iVOLSize = 0;
-			for (i=0; i<aBuffer->nFilledLen-4; i++)
-			{
-				if (memcmp(&pBufdata[i], frame_header_start, 4) != 0)
-				{
-					iVOLHeader[i] = pBufdata[i];
-					iVOLSize++;
-				}
-				else
-				{
-					break;
-				}
-			}
-#else
-			memcpy(iVolHeader.getMemFragPtr(), pBufdata, DEFAULT_VOL_HEADER_LENGTH);
-#endif
-		}
-
-
-		aBuffer->nTimeStamp /= 1000;
-        iOutTimeStamp = aBuffer->nTimeStamp;
-        //ipPrivateData =  aBuffer->pPlatformPrivate; // record the pointer
-        oscl_memcpy(&ipPrivateData, &(aBuffer->pPlatformPrivate), sizeof(ipPrivateData));
-
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                        (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Wrapping buffer %x of size %d", pBufdata, aBuffer->nFilledLen));
-        // wrap the buffer into the MediaDataImpl wrapper, and queue it for sending downstream
-        // wrapping will create a refcounter. When refcounter goes to 0 i.e. when media data
-        // is released in downstream components, the custom deallocator will automatically release the buffer back to the
-        //	mempool. To do that, the deallocator needs to have info about Context
-        // NOTE: we had to wait until now to wrap the buffer data because we only know
-        //			now where the actual data is located (based on buffer offset)
-        OsclSharedPtr<PVMFMediaDataImpl> MediaDataOut = WrapOutputBuffer(pBufdata, (uint32) (aBuffer->nFilledLen), pContext);
-
-        // if you can't get the MediaDataOut, release the buffer back to the pool
-        if (MediaDataOut.GetRep() == NULL)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                            (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Problem wrapping buffer %x of size %d - releasing the buffer", pBufdata, aBuffer->nFilledLen));
-
-            iOutBufMemoryPool->deallocate(pContext);
-        }
-        else
-        {
-
-            // if there's a problem queuing output buffer, MediaDataOut will expire at end of scope and
-            // release buffer back to the pool, (this should not be the case)
-            if (QueueOutputBuffer(MediaDataOut, aBuffer->nFilledLen))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Buffer %x of size %d queued - reschedule the node to send out", pBufdata, aBuffer->nFilledLen));
-
-                // if queing went OK,
-                // re-schedule the node so that outgoing queue can be emptied (unless the outgoing port is busy)
-                if ( (iOutPort.size() > 0) && !(iOutPort[0]->IsConnectedPortBusy()) )
-                    RunIfNotReady();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                (0, "PVMFOMXVideoEncNode::FillBufferDoneProcessing: Problem queing buffer %x of size %d - releasing the buffer", pBufdata, aBuffer->nFilledLen));
-            }
-
-
-        }
-
-    }
-    // the OMX spec says that no error is to be returned
-    return OMX_ErrorNone;
-
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////// Attach a MediaDataImpl wrapper (refcount, deallocator etc.)
-/////////////////////////////// to the output buffer /////////////////////////////////////////
-OsclSharedPtr<PVMFMediaDataImpl> PVMFOMXVideoEncNode::WrapOutputBuffer(uint8 *pData,uint32 aDataLen, OsclAny *pContext)
-{
-	// wrap output buffer into a mediadataimpl
-	 uint32 aligned_class_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
-	 uint32 aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PVOMXBufferSharedPtrWrapperCombinedCleanupDA));
-	 uint32 aligned_refcnt_size = oscl_mem_aligned_size(sizeof (OsclRefCounterDA));
-	 uint8 *my_ptr = (uint8*) oscl_malloc(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
-
-	if(my_ptr == NULL)
-	{
-		OsclSharedPtr<PVMFMediaDataImpl> null_buff(NULL,NULL);
-		return null_buff;
-	}
-	 // create a deallocator and pass the buffer_allocator to it as well as pointer to data that needs to be returned to the mempool
-	 PVOMXBufferSharedPtrWrapperCombinedCleanupDA *cleanup_ptr =
-		 OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PVOMXBufferSharedPtrWrapperCombinedCleanupDA(iOutBufMemoryPool,pContext) );
-
-	//ModifiedPvciBufferCombinedCleanup* cleanup_ptr = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size,ModifiedPvciBufferCombinedCleanup(aOutput.GetRefCounter()) );
-
-    // create the ref counter after the cleanup object (refcount is set to 1 at creation)
-    OsclRefCounterDA *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr,cleanup_ptr) );
-
-    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
-
-	PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer((void *) pData, // ptr to data
-							                                             aDataLen, // capacity
-													                     my_refcnt ) ); // ref counter
-
-	OsclSharedPtr<PVMFMediaDataImpl> MediaDataImplOut(media_data_ptr, my_refcnt);
-
-	MediaDataImplOut->setMediaFragFilledLen(0,aDataLen);
-
-	return MediaDataImplOut;
-
-}
-
-bool PVMFOMXVideoEncNode::QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout,uint32 aDataLen)
-{
-	bool status = true;
-	PVMFSharedMediaDataPtr mediaDataOut;
-	int32 leavecode = 0;
-
-	// NOTE: ASSUMPTION IS THAT OUTGOING QUEUE IS BIG ENOUGH TO QUEUE ALL THE OUTPUT BUFFERS
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::QueueOutputFrame: In"));
-
-// FIXME: Is this correct?
-// Remove checking IsOutgoingQueueBusy
-/*
-	// First check if we can put outgoing msg. into the queue
-	if (iOutPort[0]->IsOutgoingQueueBusy())
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-			(0,"PVMFOMXVideoEncNode::QueueOutputFrame() OutgoingQueue is busy"));
-		return false;
-	}
-*/
-	OSCL_TRY(leavecode,
-		mediaDataOut = PVMFMediaData::createMediaData(mediadataimplout,iMediaDataMemPool););
-	if (leavecode==0)
-	{
-		// Update the filled length of the fragment
-		mediaDataOut->setMediaFragFilledLen(0, aDataLen);
-		// Set timestamp
-		mediaDataOut->setTimestamp(iOutTimeStamp);
-		// Set Streamid
-		//mediaDataOut->setStreamID(iStreamID);
-		// Set sequence number
-		mediaDataOut->setSeqNum(iSeqNum++);
-
-		// Send vol header for m4v bitstream
-		if(mediaDataOut->getSeqNum() == 0 && iEncodeParam.iContentType == ECVEI_STREAMING)
-			mediaDataOut->setFormatSpecificInfo(iVolHeader);
-
-		SendEncodedBitstream(mediaDataOut);
-	}
-
-	return status;
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will process received data usign State Machine
-/////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFOMXVideoEncNode::HandleProcessingState()
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::HandleProcessingState() In"));
-
-	PVMFStatus status = PVMFSuccess;
-
-	switch(iProcessingState)
-	{
-		case EPVMFOMXVideoEncNodeProcessingState_InitEncoder:
-		{
-			// do init only if input data is available
-			if(iDataIn.GetRep() != NULL)
-			{
-				//if (!InitEncoder(iDataIn))
-				//{
-				//	// Encoder initialization failed. Fatal error
-				//	PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-				//		(0,"PVMFOMXVideoEncNode::HandleProcessingState() encoder initialization failed"));
-				//	ReportErrorEvent(PVMFErrResourceConfiguration);
-				//	ChangeNodeState(EPVMFNodeError);
-				//	break;
-				//}
-
-				iProcessingState = EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode;
-				// spin once to send output buffers
-				RunIfNotReady();
-				status = PVMFSuccess; // allow rescheduling
-			}
-			break;
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_WaitForInitCompletion:
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::HandleProcessingState() WaitForInitCompletion -> wait for config buffer to return"));
-
-			status = PVMFErrNoMemory; // prevent rescheduling
-			break;
-		}
-		// The FOLLOWING 4 states handle Dynamic Port Reconfiguration
-		case EPVMFOMXVideoEncNodeProcessingState_PortReconfig:
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Sending Port Disable Command"));
-
-			// port reconfiguration is required. Only one port at a time is disabled and then re-enabled after buffer resizing
-			OMX_SendCommand(iOMXVideoEncoder, OMX_CommandPortDisable, iPortIndexForDynamicReconfig, NULL);
-			// the port will now start returning outstanding buffers
-			// set the flag to prevent output from going downstream (in case of output port being reconfigd)
-			// set the flag to prevent input from being saved and returned to component (in case of input port being reconfigd)
-			// set the state to wait for port saying it is disabled
-			if(iPortIndexForDynamicReconfig == iOutputPortIndex)
-			{
-				iDoNotSendOutputBuffersDownstreamFlag = true;
-			}
-			else if(iPortIndexForDynamicReconfig == iInputPortIndex)
-			{
-				iDoNotSaveInputBuffersFlag = true;
-
-			}
-			iProcessingState = EPVMFOMXVideoEncNodeProcessingState_WaitForBufferReturn;
-
-			// fall through to the next case to check if all buffers are already back
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_WaitForBufferReturn:
-		{
-			// as buffers are coming back, Run may be called, wait until all buffers are back, then Free them all
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> WaitForBufferReturn "));
-			// check if it's output port being reconfigured
-			if(iPortIndexForDynamicReconfig == iOutputPortIndex)
-			{
-				// if all buffers have returned, free them
-				if(iNumOutstandingOutputBuffers == 0)
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> all output buffers are back, free them"));
-					if(false == iOutputBuffersFreed)
-					{
-						if( !FreeBuffersFromComponent(iOutBufMemoryPool, // allocator
-										  iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  iNumOutputBuffers, // number of buffers
-										  iOutputPortIndex, // port idx
-										  false // this is not input
-										  ))
-						{
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-							(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Cannot free output buffers "));
-
-							SetState(EPVMFNodeError);
-							ReportErrorEvent(PVMFErrNoMemory);
-							return PVMFErrNoMemory;
-						}
-					}
-					// if the callback (that port is disabled) has not arrived yet, wait for it
-					// if it has arrived, it will set the state to PortReEnable
-					if(iProcessingState != EPVMFOMXVideoEncNodeProcessingState_PortReEnable)
-						iProcessingState = EPVMFOMXVideoEncNodeProcessingState_WaitForPortDisable;
-
-					status = PVMFSuccess; // allow rescheduling of the node potentially
-				}
-				else
-					status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic rescheduling
-											// but each buffer will reschedule the node when it comes in
-			}
-			else
-			{ // this is input port
-
-				// if all buffers have returned, free them
-				if(iNumOutstandingInputBuffers == 0)
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> all input buffers are back, free them"));
-					if(false == iInputBuffersFreed){
-						if( !FreeBuffersFromComponent(iInBufMemoryPool, // allocator
-											  iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-											  iNumInputBuffers, // number of buffers
-											  iInputPortIndex, // port idx
-											  true // this is input
-											  ))
-						{
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-							(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Cannot free input buffers "));
-
-							SetState(EPVMFNodeError);
-							ReportErrorEvent(PVMFErrNoMemory);
-							return PVMFErrNoMemory;
-
-						}
-					}
-					// if the callback (that port is disabled) has not arrived yet, wait for it
-					// if it has arrived, it will set the state to PortReEnable
-					if(iProcessingState != EPVMFOMXVideoEncNodeProcessingState_PortReEnable)
-						iProcessingState = EPVMFOMXVideoEncNodeProcessingState_WaitForPortDisable;
-
-					status = PVMFSuccess; // allow rescheduling of the node
-				}
-				else
-					status = PVMFErrNoMemory; // must wait for buffers to come back. No point in automatic
-										   // rescheduling. Each buffer will reschedule the node
-											// when it comes in
-			}
-
-
-			// the state will be changed to PortReEnable once we get confirmation that Port was actually disabled
-			break;
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_WaitForPortDisable:
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> wait for port disable callback"));
-			// do nothing. Just wait for the port to become disabled (we'll get event from component, which will
-			// transition the state to PortReEnable
-			status = PVMFErrNoMemory; // prevent Rescheduling the node
-			break;
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_PortReEnable:
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Sending reenable port command"));
-			// set the port index so that we get parameters for the proper port
-			iParamPort.nPortIndex = iPortIndexForDynamicReconfig;
-			//iParamPort.nVersion = OMX_VERSION;
-
-			// get new parameters of the port
-			OMX_GetParameter (iOMXVideoEncoder, OMX_IndexParamPortDefinition, &iParamPort);
-
-			// send command for port re-enabling (for this to happen, we must first recreate the buffers)
-			OMX_SendCommand(iOMXVideoEncoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);
-
-			// is this output port?
-			if(iPortIndexForDynamicReconfig == iOutputPortIndex)
-			{
-				iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth+15)&(~15))*((iParamPort.format.video.nFrameHeight + 15) &(~15)) * 3/2;
-
-				// check the new buffer size
-				if(iInPort.size())
-				{
-					switch (((PVMFVideoEncPort*)iInPort[0])->iFormat)
-					{
-						case PVMF_H264:
-						case PVMF_H264_MP4:
-						case PVMF_H264_RAW:
-						case PVMF_M4V:
-						case PVMF_H263:
-							iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 15)&(~15)) * ((iParamPort.format.video.nFrameHeight + 15)&(~15)) * 3/2;
-							break;
-						case PVMF_WMV: // This is a requirement for the WMV encoder that we have currently
-							iOMXComponentOutputBufferSize = ((iParamPort.format.video.nFrameWidth + 3)&(~3)) * (iParamPort.format.video.nFrameHeight) * 3/2;
-							break;
-						default:
-							OSCL_ASSERT(false);
-							break;
-					}
-				}
-				// FIXME: Is this needed?
-				// set the new width / height
-				//iYUVWidth =  iParamPort.format.video.nFrameWidth;
-				//iYUVHeight = iParamPort.format.video.nFrameHeight;
-
-				if(iOMXComponentOutputBufferSize < iParamPort.nBufferSize)
-					iOMXComponentOutputBufferSize = iParamPort.nBufferSize;
-
-				// do we need to increase the number of buffers?
-				if(iNumOutputBuffers < iParamPort.nBufferCountMin)
-					iNumOutputBuffers = iParamPort.nBufferCountMin;
-
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-					(0,"PVMFOMXVideoEncNode::HandleProcessingState() new output buffers %d, size %d",iNumOutputBuffers,iOMXComponentOutputBufferSize));
-
-					/* Allocate output buffers */
-				if(!CreateOutputMemPool(iNumOutputBuffers))
-				{
-                                        LOGE("HandleProcessingState(): port reconfiguration -> Cannot allocate output buffers");
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Cannot allocate output buffers "));
-
-					SetState(EPVMFNodeError);
-					ReportErrorEvent(PVMFErrNoMemory);
-					return PVMFErrNoMemory;
-				}
-
-				if(!ProvideBuffersToComponent(iOutBufMemoryPool, // allocator
-										  iOutputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  iNumOutputBuffers, // number of buffers
-										  iOMXComponentOutputBufferSize, // actual buffer size
-										  iOutputPortIndex, // port idx
-										  iOMXComponentSupportsExternalOutputBufferAlloc, // can component use OMX_UseBuffer
-										  false // this is not input
-										  ))
-				{
-
-                                        LOGE("HandleProcessingState(): port reconfiguration -> Cannot provide output buffers to component");
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Cannot provide output buffers to component"));
-
-					SetState(EPVMFNodeError);
-					ReportErrorEvent(PVMFErrNoMemory);
-					return PVMFErrNoMemory;
-
-				}
-
-				// do not drop output any more, i.e. enable output to be sent downstream
-				iDoNotSendOutputBuffersDownstreamFlag = false;
-
-
-			}
-			else
-			{
-				// this is input port
-
-				iOMXComponentInputBufferSize = iParamPort.nBufferSize;
-				// do we need to increase the number of buffers?
-				if(iNumInputBuffers < iParamPort.nBufferCountMin)
-					iNumInputBuffers = iParamPort.nBufferCountMin;
-
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-					(0,"PVMFOMXVideoEncNode::HandleProcessingState() new buffers %d, size %d",iNumInputBuffers,iOMXComponentInputBufferSize));
-
-				/* Allocate input buffers */
-				if(!CreateInputMemPool(iNumInputBuffers))
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Cannot allocate new input buffers to component"));
-
-					SetState(EPVMFNodeError);
-					ReportErrorEvent(PVMFErrNoMemory);
-					return PVMFErrNoMemory;
-				}
-
-				if(!ProvideBuffersToComponent(iInBufMemoryPool, // allocator
-											  iInputAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-											  iNumInputBuffers, // number of buffers
-											  iOMXComponentInputBufferSize, // actual buffer size
-											  iInputPortIndex, // port idx
-											  iOMXComponentSupportsExternalInputBufferAlloc, // can component use OMX_UseBuffer
-											  true // this is input
-											  ))
-				{
-
-
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> Cannot provide new input buffers to component"));
-
-					SetState(EPVMFNodeError);
-					ReportErrorEvent(PVMFErrNoMemory);
-					return PVMFErrNoMemory;
-
-				}
-				// do not drop partially consumed input
-				iDoNotSaveInputBuffersFlag = false;
-
-
-			}
-
-			// if the callback that the port was re-enabled has not arrived yet, wait for it
-			// if it has arrived, it will set the state to either PortReconfig or to ReadyToDecode
-			if(iProcessingState != EPVMFOMXVideoEncNodeProcessingState_PortReconfig &&
-				iProcessingState !=EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode)
-					iProcessingState = EPVMFOMXVideoEncNodeProcessingState_WaitForPortEnable;
-
-			status = PVMFSuccess; // allow rescheduling of the node
-			break;
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_WaitForPortEnable:
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::HandleProcessingState() Port Reconfiguration -> wait for port enable callback"));
-			// do nothing. Just wait for the port to become enabled (we'll get event from component, which will
-			// transition the state to ReadyToDecode
-			status = PVMFErrNoMemory; // prevent ReScheduling
-			break;
-		}
-
-		// NORMAL DATA FLOW STATE:
-		case EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode:
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::HandleProcessingState() Ready To Decode start"));
-			// In normal data flow and decoding state
-			// Send all available output buffers to the encoder
-
-			while( iNumOutstandingOutputBuffers < iNumOutputBuffers)
-			{
-				// grab buffer header from the mempool if possible, and send to component
-				if(!SendOutputBufferToOMXComponent() )
-
-					break;
-
-			}
-
-			// next, see if partially consumed input buffer needs to be resent back to OMX component
-			// NOTE: it is not allowed that the component returns more than 1 partially consumed input buffers
-			//		 i.e. if a partially consumed input buffer is returned, it is assumed that the OMX component
-			//		 will be waiting to get data
-
-			if(iInputBufferToResendToComponent != NULL)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-					(0,"PVMFOMXVideoEncNode::HandleProcessingState() Sending previous - partially consumed input back to the OMX component"));
-
-				OMX_EmptyThisBuffer(iOMXVideoEncoder, iInputBufferToResendToComponent);
-				iInputBufferToResendToComponent = NULL; // do this only once
-			}
-			else if( (iNumOutstandingInputBuffers < iNumInputBuffers) && (iDataIn.GetRep()!=NULL) )
-			{
-				// try to get an input buffer header
-				// and send the input data over to the component
-				SendInputBufferToOMXComponent();
-			}
-
-			status = PVMFSuccess;
-			break;
-
-
-		}
-		case EPVMFOMXVideoEncNodeProcessingState_Stopping:
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::HandleProcessingState() Stopping -> wait for Component to move from Executing->Idle"));
-
-			status = PVMFErrNoMemory; // prevent rescheduling
-			break;
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_Pausing:
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::HandleProcessingState() Pausing -> wait for Component to move from Executing->Pause"));
-
-
-			status = PVMFErrNoMemory; // prevent rescheduling
-			break;
-		}
-
-		case EPVMFOMXVideoEncNodeProcessingState_WaitForOutgoingQueue:
-			status = PVMFErrNoMemory;
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::HandleProcessingState() Do nothing since waiting for output port queue to become available"));
-			break;
-
-		default:
-			break;
-	}
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::HandleProcessingState() Out"));
-
-	return status;
-
-}
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::SendOutputBufferToOMXComponent()
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::SendOutputBufferToOMXComponent() In"));
-
-
-	OutputBufCtrlStruct *output_buf=NULL;
-	int32 errcode=0;
-
-	// try to get output buffer header
-	OSCL_TRY(errcode, output_buf = (OutputBufCtrlStruct *) iOutBufMemoryPool->allocate(iOutputAllocSize));
-	if (errcode != 0)
-	{
-		if (errcode == OsclErrNoResources)
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-				PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::SendOutputBufferToOMXComponent() No more output buffers in the mempool"));
-
-			iOutBufMemoryPool->notifyfreechunkavailable(*this,(OsclAny *) iOutBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-			return false;
-		}
-		else
-		{
-			// Memory allocation for the pool failed
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-				(0,"PVMFOMXVideoEncNode::SendOutputBufferToOMXComponent() Output mempool error"));
-
-
-			SetState(EPVMFNodeError);
-			ReportErrorEvent(PVMFErrNoMemory);
-			return false;
-		}
-
-	}
-
-	//for every allocated buffer, make sure you notify when buffer is released. Keep track of allocated buffers
-	// use mempool as context to recognize which buffer (input or output) was returned
-	iOutBufMemoryPool->notifyfreechunkavailable(*this,(OsclAny *)iOutBufMemoryPool);
-	iNumOutstandingOutputBuffers++;
-
-	output_buf->pBufHdr->nFilledLen = 0; // make sure you tell OMX component buffer is empty
-	output_buf->pBufHdr->nOffset = 0;
-	output_buf->pBufHdr->pAppPrivate = output_buf; // set pAppPrivate to be pointer to output_buf
-												   // (this is context for future release of this buffer to the mempool)
-													// this was done during buffer creation, but still repeat just in case
-    output_buf->pBufHdr->nFlags = 0; // Clear flags
-
-	OMX_FillThisBuffer(iOMXVideoEncoder,output_buf->pBufHdr);
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::SendOutputBufferToOMXComponent() Out"));
-
-	return true;
-}
-
-bool PVMFOMXVideoEncNode::SendInputBufferToOMXComponent()
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() In"));
-
-
-	// first need to take care of  missing packets if node is assembling partial frames.
-	// The action depends whether the component (I) can handle incomplete frames/NALs or (II) cannot handle incomplete frames/NALs
-	if(!iOMXComponentSupportsPartialFrames)
-	{
-		// there are 4 cases after receiving a media msg and realizing there were missing packet(s):
-
-		// a) TS remains the same - i.e. missing 1 or more pieces in the middle of the same frame
-		//		 I) basically ignore  - keep assembling the same frame  (middle will be missing)
-		//		II) drop current buffer, drop msgs until next msg with marker bit arrives
-
-
-		// b) TS is different than previous frame. Previous frame was sent OK (had marker bit).
-		//				New frame assembly has not started yet. one or more pieces are missing from
-		//				the beginning of the frame
-		//	  	 I) basically ignore - get a new buffer and start assembling new frame (beginning will be missing)
-		//		II) no buffer to drop, but keep dropping msgs until next msg with marker bit arrives
-
-		// c) TS is different than previous frame. Frame assembly has started (we were in the middle of a frame)
-		//		but only 1 piece is missing => We know that the missing frame must have had the marker bit
-
-		//		 I) send out current buffer (last piece will be missing), get a new buffer and start assembling new frame (which is OK)
-		//		II) just drop current buffer. Get a new buffer and start assembling new frame (no need to wait for marker bit)
-
-		// d) TS is different than previous frame. Frame assembly has started ( we were in the middle of a frame)
-		//		multiple pieces are missing => The last piece of the frame with the marker bit is missing for sure, but
-		//		there could be also other frames missing or the beginning of the next frame is missing etc.
-
-		//		 I) send out current bufer (last piece will be missing). Get a new buffer and start assembling new frame (beginning COULD BE missing as well)
-		//		II) drop current buffer. Keep dropping msgs until next msg with marker bit arrives
-
-
-		// extract info from the media message
-
-		uint32 current_msg_seq_num = iDataIn->getSeqNum();
-		uint32 current_msg_ts = iDataIn->getTimestamp();
-		uint32 current_msg_marker = iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
-
-		// first check if we need to keep dropping msgs
-		if(iKeepDroppingMsgsUntilMarkerBit)
-		{
-			// drop this message
-			iDataIn.Unbind();
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() Dropping input msg with seqnum %d until marker bit",current_msg_seq_num));
-
-			//if msg has marker bit, stop dropping msgs
-			if(current_msg_marker != 0)
-			{
-				iKeepDroppingMsgsUntilMarkerBit = false;
-				// also remember the sequence number & timestamp so that we have reference
-				iInPacketSeqNum = current_msg_seq_num;
-				iInTimestamp = current_msg_ts;
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() Input msg with seqnum %d has marker bit set. Stop dropping msgs",current_msg_seq_num));
-
-			}
-			return true;
-		}
-
-		// is there something missing?
-		// compare current and saved sequence number - difference should be exactly 1
-		//	if it is more, there is something missing
-		if( (current_msg_seq_num - iInPacketSeqNum) > 1 )
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - MISSING PACKET DETECTED. Input msg with seqnum %d, TS=%d. Previous seqnum: %d, Previous TS: %d",current_msg_seq_num,iInPacketSeqNum,current_msg_ts,iInTimestamp));
-
-			// find out which case it is by comparing TS
-			if( current_msg_ts == iInTimestamp)
-			{
-
-				// this is CASE a)
-				// same ts, i.e. pieces are missing from the middle of the current frame
-				if(!iOMXComponentCanHandleIncompleteFrames)
-				{
-					// drop current buffer, drop msgs until you hit msg with marker bit
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Drop current buffer under construction. Keep dropping msgs until marker bit"));
-
-					DropCurrentBufferUnderConstruction();
-					iKeepDroppingMsgsUntilMarkerBit = true;
-				}
-				else
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Continue processing" ));
-
-				}
-			}
-			else // new ts and old ts are different
-			{
-				//  are we at the beginning of the new frame assembly?
-				if(iObtainNewInputBuffer)
-				{
-					// CASE b)
-					// i.e. we sent out previous frame, but have not started assembling a new frame. Pieces are missing from the beginning
-					if(!iOMXComponentCanHandleIncompleteFrames)
-					{
-						// there is no current buffer to drop, but drop msgs until you hit msg with marker bit
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-							(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - No current buffer under construction. Keep dropping msgs until marker bit"));
-
-						iKeepDroppingMsgsUntilMarkerBit = true;
-					}
-					else
-					{
-						PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Continue processing" ));
-					}
-				}
-				else	// no, we are in the middle of a frame assembly, but new ts is different
-				{
-					// is only 1 msg missing?
-					if( (current_msg_seq_num - iInPacketSeqNum) == 2)
-					{
-						// CASE c)
-						// only the last piece of the previous frame is missing
-						if(iOMXComponentCanHandleIncompleteFrames)
-						{
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-								(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Send incomplete buffer under construction. Start assembling new frame" ));
-
-							SendIncompleteBufferUnderConstruction();
-						}
-						else
-						{
-							// drop current frame only, but no need to wait until next marker bit.
-							// start assembling new frame
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-								(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Drop current buffer under construction. It's OK to start assembling new frame. Only 1 packet is missing"));
-
-							DropCurrentBufferUnderConstruction();
-						}
-					}
-					else
-					{
-						// CASE d)
-						// (multiple) final piece(s) of the previous frame are missing and possibly pieces at the
-						// beginning of a new frame are also missing
-						if(iOMXComponentCanHandleIncompleteFrames)
-						{
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-								(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Send incomplete buffer under construction. Start assembling new frame (potentially damaged)" ));
-
-							SendIncompleteBufferUnderConstruction();
-						}
-						else
-						{
-							// drop current frame. start assembling new frame, but first keep dropping
-							// until you hit msg with marker bit.
-							PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-								(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Drop current buffer under construction. Keep dropping msgs until marker bit"));
-
-							DropCurrentBufferUnderConstruction();
-							iKeepDroppingMsgsUntilMarkerBit = true;
-						}
-					}
-				}// end of if(obtainNewInputBuffer)/else
-			}// end of if(curr_msg_ts == iInTimestamp)
-		}//end of if(deltaseqnum>1)/else
-
-		// check if we need to keep dropping msgs
-		if(iKeepDroppingMsgsUntilMarkerBit)
-		{
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() Dropping input msg with seqnum %d until marker bit",current_msg_seq_num));
-
-			// drop this message
-			iDataIn.Unbind();
-
-			//if msg has marker bit, stop dropping msgs
-			if(current_msg_marker != 0)
-			{
-				iKeepDroppingMsgsUntilMarkerBit = false;
-				// also remember the sequence number & timestamp so that we have reference
-				iInPacketSeqNum = current_msg_seq_num;
-				iInTimestamp = current_msg_ts;
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-					(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() Input msg with seqnum %d has marker bit set. Stop dropping msgs",current_msg_seq_num));
-
-			}
-			return true;
-		}
-
-	}// end of if/else (iOMXSUpportsPartialFrames)
-
-	InputBufCtrlStruct *input_buf = NULL;
-	int32 errcode=0;
-
-	// NOTE: a) if NAL start codes must be inserted i.e. iOMXComponentNeedsNALStartCodes is TRUE, then iOMXComponentSupportsMovableInputBuffers must be set to FALSE.
-	//		 b) if iOMXComponentSupportsPartialFrames is FALSE, then iOMXComponentSupportsMovableInputBuffers must be FALSE as well
-	//		 c) if iOMXCOmponentSupportsPartialFrames is FALSE, and the input frame/NAL size is larger than the buffer size, the frame/NAL is discarded
-
-	do{
-		// do loop to loop over all fragments
-		// first of all , get an input buffer. Without a buffer, no point in proceeding
-		if(iObtainNewInputBuffer == true) // if partial frames are being reconstructed, we may be copying data into
-											//existing buffer, so we don't need the new buffer
-		{
-			// try to get input buffer header
-			OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
-			if (errcode!=0)
-			{
-				if (errcode==OsclErrNoResources)
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-						PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() No more buffers in the mempool"));
-
-					iInBufMemoryPool->notifyfreechunkavailable(*this,(OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-					return false;
-				}
-				else
-				{
-					// Memory allocation for the pool failed
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() Input mempool error"));
-
-
-					SetState(EPVMFNodeError);
-					ReportErrorEvent(PVMFErrNoMemory);
-					return false;
-				}
-
-			}
-
-			// keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-			iInBufMemoryPool->notifyfreechunkavailable(*this,(OsclAny*) iInBufMemoryPool);
-			iNumOutstandingInputBuffers++;
-
-			// Now we have the buffer header (i.e. a buffer) to send to component:
-			// Depending on OMX component capabilities, either pass the input msg fragment(s) directly
-			//	into OMX component without copying (and update the input msg refcount)
-			//	or memcopy the content of input msg memfrag(s) into OMX component allocated buffers
-			input_buf->pBufHdr->nFilledLen = 0; // init this for now
-			// save this in a class member
-			iInputBufferUnderConstruction = input_buf;
-			// set flags
-			if(iOMXComponentSupportsPartialFrames == true)
-			{
-				// if partial frames can be sent, then send them
-				// but we'll always need the new buffer for the new fragment
-				iObtainNewInputBuffer = true;
-			}
-			else{
-				// if we need to assemble partial frames, then obtain a new buffer
-				// only after assembling the partial frame
-				iObtainNewInputBuffer = false;
-			}
-		}
-		else
-		{
-			input_buf = iInputBufferUnderConstruction;
-		}
-
-		// When copying content, a special case is when the input fragment is larger than the buffer and has to
-		//	be fragmented here and broken over 2 or more buffers. Potential problem with available buffers etc.
-
-		// if this is the first fragment in a new message, extract some info:
-		if(iCurrFragNum == 0){
-
-			// NOTE: SeqNum differ in Codec and in Node because of the fact that
-			// one msg can contain multiple fragments that are sent to the codec as
-			// separate buffers. Node tracks msgs and codec tracks even separate fragments
-
-			iCodecSeqNum += (iDataIn->getSeqNum() - iInPacketSeqNum); // increment the codec seq. # by the same
-																  // amount that the input seq. number increased
-
-			iInPacketSeqNum = iDataIn->getSeqNum(); // remember input sequence number
-			iInTimestamp = iDataIn->getTimestamp();
-			iInDuration = iDataIn->getDuration();
-			iInNumFrags = iDataIn->getNumFragments();
-
-			// logging info:
-			if (iDataIn->getNumFragments() > 1)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - New msg has MULTI-FRAGMENTS"));
-			}
-
-			if(!( iDataIn->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT))
-			{
-
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - New msg has NO MARKER BIT"));
-			}
-		}
-
-
-		// get a memfrag from the message
-		OsclRefCounterMemFrag frag;
-		iDataIn->getMediaFragment(iCurrFragNum,frag);
-
-
-		if(iOMXComponentSupportsMovableInputBuffers)
-		{
-			// no copying required
-			// Note: This cannot be used for NAL start code insertion and
-			//		 for the case when partial frames are not supported by the component
-
-			// increment the RefCounter of the message associated with the mem fragment/buffer
-			// when sending this buffer to OMX component. (When getting the buffer back, the refcounter
-			// will be decremented. Thus, when the last fragment is returned, the input mssage is finally released
-
-			iDataIn.GetRefCounter()->addRef();
-
-			// associate the buffer ctrl structure with the message ref counter and ptr
-			input_buf->pMediaData = PVMFSharedMediaDataPtr(iDataIn.GetRep(),iDataIn.GetRefCounter());
-
-
-			// set pointer to the data, length, offset
-			input_buf->pBufHdr->pBuffer = (uint8 *)frag.getMemFragPtr();
-			input_buf->pBufHdr->nFilledLen = frag.getMemFragSize();
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Buffer 0x%x of size %d, %d frag out of tot. %d, TS=%d",input_buf->pBufHdr->pBuffer,frag.getMemFragSize(),iCurrFragNum+1,iDataIn->getNumFragments(),iInTimestamp ));
-
-			iCurrFragNum++; // increment fragment number and move on to the next
-			iIsNewDataFragment = true; // update the flag
-
-		}
-		else
-		{
-			// in this case, no need to use input msg refcounter, each buffer fragment is copied over and treated separately
-			(input_buf->pMediaData).Unbind();
-
-			// is this a new data fragment or are we still working on separating the old one?
-			if(iIsNewDataFragment == true)
-			{
-				//  if fragment size is larger than the buffer size,
-				//	need to break up the fragment even further into smaller chunks
-
-				// init variables needed for fragment separation
-				iCopyPosition = 0;
-				iFragmentSizeRemainingToCopy  = frag.getMemFragSize();
-
-			}
-
-			// can the remaining fragment fit into the buffer?
-			uint32 bytes_remaining_in_buffer = (input_buf->pBufHdr->nAllocLen - input_buf->pBufHdr->nFilledLen);
-
-			if( iFragmentSizeRemainingToCopy <= bytes_remaining_in_buffer )
-			{
-				oscl_memcpy( input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
-							 (void *) ((uint8 *)frag.getMemFragPtr() + iCopyPosition),
-							 iFragmentSizeRemainingToCopy);
-
-				input_buf->pBufHdr->nFilledLen += iFragmentSizeRemainingToCopy;
-
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-					(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d ",iFragmentSizeRemainingToCopy,iCurrFragNum+1,iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer,input_buf->pBufHdr->nFilledLen,iInTimestamp));
-
-				iCopyPosition += iFragmentSizeRemainingToCopy;
-				iFragmentSizeRemainingToCopy = 0;
-
-
-
-				iIsNewDataFragment = true; // done with this fragment. Get a new one
-				iCurrFragNum++;
-
-			}
-			else
-			{
-				// copy as much as you can of the current fragment into the current buffer
-				if(bytes_remaining_in_buffer>0)
-				{
-					oscl_memcpy( input_buf->pBufHdr->pBuffer + input_buf->pBufHdr->nFilledLen,
-								 (void *)((uint8 *)frag.getMemFragPtr() + iCopyPosition),
-								 bytes_remaining_in_buffer);
-
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Copied %d bytes of fragment %d out of %d into buffer 0x%x of size %d, TS=%d",input_buf->pBufHdr->nAllocLen,iCurrFragNum+1,iDataIn->getNumFragments(), input_buf->pBufHdr->pBuffer,input_buf->pBufHdr->nFilledLen,iInTimestamp));
-				}
-				input_buf->pBufHdr->nFilledLen = input_buf->pBufHdr->nAllocLen;
-				iCopyPosition += bytes_remaining_in_buffer; // move current position within fragment forward
-				iFragmentSizeRemainingToCopy -= bytes_remaining_in_buffer;
-				iIsNewDataFragment = false; // set the flag to indicate we're still working on the "old" fragment
-
-				if(!iOMXComponentSupportsPartialFrames)
-				{
-					// if partial frames are not supported, and data cannot fit into the buffer, i.e. the buffer is full at this point
-					// simply go through remaining fragments if they exist and "drop" them
-					// i.e. send what data is alrady copied in the buffer and ingore the rest
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - Reconstructing partial frame - more data cannot fit in buffer 0x%x, TS=%d.Skipping data.",input_buf->pBufHdr->pBuffer,iInTimestamp));
-
-					iIsNewDataFragment = true; // done with this fragment, get a new one
-					iCurrFragNum++;
-				}
-			}
-
-		}
-
-
-		// set buffer fields (this is the same regardless of whether the input is movable or not)
-		input_buf->pBufHdr->nOffset = 0;
-		input_buf->pBufHdr->nTimeStamp = iInTimestamp;
-		input_buf->pBufHdr->nTimeStamp *= 1000;
-
-		// set ptr to input_buf structure for Context (for when the buffer is returned)
-		input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-		// do not use Mark here (but init to NULL to prevent problems)
-		input_buf->pBufHdr->hMarkTargetComponent = NULL;
-		input_buf->pBufHdr->pMarkData = NULL;
-
-
-		// init buffer flags
-		input_buf->pBufHdr->nFlags = 0;
-
-		{
-			// "normal" case, i.e. only fragments at ends of msgs may have marker bit set
-			//					fragments in the middle of a message never have marker bit set
-			// there is also a (slight) possibility we broke up the fragment into more fragments
-			//	because they can't fit into input buffer. In this case, make sure you apply
-			//	the marker bit (if necessary) only to the very last piece of the very last fragment
-
-			// for all other cases, clear the marker bit flag for the buffer
-			if( (iCurrFragNum == iDataIn->getNumFragments()) && iIsNewDataFragment)
-			{
-				// if all the fragments have been exhausted, and this is the last piece
-				// of the (possibly broken up) last fragment
-
-				// use the marker bit from the end of message
-				if( iCurrentMsgMarkerBit )
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 1, TS=%d",input_buf->pBufHdr->pBuffer,iInTimestamp));
-
-					input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-					// once frame is complete, make sure you send it and obtain new buffer
-
-					iObtainNewInputBuffer = true;
-				}
-				else{
-
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - END OF MESSAGE - Buffer 0x%x MARKER bit set to 0, TS=%d",input_buf->pBufHdr->pBuffer,iInTimestamp));
-				}
-			}
-			else
-			{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-						(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() - NOT END OF MESSAGE - Buffer 0x%x MARKER bit set to 0, TS=%d",input_buf->pBufHdr->pBuffer,iInTimestamp));
-			}
-
-
-		}// end of else(setmarkerbitforeveryfrag)
-
-
-		if(iObtainNewInputBuffer == true)
-		{
-			// if partial frames are supported, this flag will always be set
-			// if partial frames are not supported, this flag will be set only
-			// if the partial frame/NAL has been assembled, so we can send it
-
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-				(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent()  - Sending Buffer 0x%x to OMX Component MARKER field set to %x, TS=%d",input_buf->pBufHdr->pBuffer,input_buf->pBufHdr->nFlags,iInTimestamp));
-
-
-			OMX_EmptyThisBuffer(iOMXVideoEncoder,input_buf->pBufHdr);
-			iInputBufferUnderConstruction = NULL; // this buffer is gone to OMX component now
-                        
-                        // HTC fix for race condition between pv omx encoder node and qualcomm encoder
-                        ++mInputBufferRefCount;
-                        LOGV("==> %s: mInputBufferRefCount = %d", __FUNCTION__, mInputBufferRefCount);
-		}
-
-		// if we sent all fragments to OMX component, decouple the input message from iDataIn
-		// Input message is "decoupled", so that we can get a new message for processing into iDataIn
-		//	However, the actual message is released completely to upstream mempool once all of its fragments
-		//	are returned by the OMX component
-
-		if(iCurrFragNum == iDataIn->getNumFragments())
-		{
-			iDataIn.Unbind();
-
-		}
-	}while(iCurrFragNum < iInNumFrags); //iDataIn->getNumFragments());
-
-
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::SendInputBufferToOMXComponent() Out"));
-
-	return true;
-
-}
-
-bool PVMFOMXVideoEncNode::SendEOSBufferToOMXComponent()
-{
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::SendEOSBufferToOMXComponent() In"));
-
-
-	// first of all, check if the component is running. EOS could be sent prior to component/encoder
-	// even being initialized
-
-	// returning false will ensure that the EOS will be sent downstream anyway without waiting for the
-	// Component to respond
-	if(iCurrentEncoderState != OMX_StateExecuting)
-		return false;
-
-	// get an input buffer. Without a buffer, no point in proceeding
-	InputBufCtrlStruct *input_buf = NULL;
-	int32 errcode = 0;
-
-	// we already checked that the number of buffers is OK, so we don't expect problems
-	// try to get input buffer header
-	OSCL_TRY(errcode, input_buf = (InputBufCtrlStruct *) iInBufMemoryPool->allocate(iInputAllocSize));
-	if (errcode != 0)
-	{
-		if (errcode == OsclErrNoResources)
-		{
-
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
-				PVLOGMSG_DEBUG, (0,"PVMFOMXVideoEncNode::SendEOSBufferToOMXComponent() No more buffers in the mempool - unexpected"));
-
-			iInBufMemoryPool->notifyfreechunkavailable(*this,(OsclAny*) iInBufMemoryPool); // To signal when next deallocate() is called on mempool
-
-			return false;
-		}
-		else
-		{
-			// Memory allocation for the pool failed
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-				(0,"PVMFOMXVideoEncNode::SendEOSBufferToOMXComponent() Input mempool error"));
-
-
-			SetState(EPVMFNodeError);
-			ReportErrorEvent(PVMFErrNoMemory);
-			return false;
-		}
-
-	}
-
-	// keep track of buffers. When buffer is deallocated/released, the counter will be decremented
-	iInBufMemoryPool->notifyfreechunkavailable(*this,(OsclAny*) iInBufMemoryPool);
-	iNumOutstandingInputBuffers++;
-
-	// in this case, no need to use input msg refcounter. Make sure its unbound
-	(input_buf->pMediaData).Unbind();
-
-	// THIS IS AN EMPTY BUFFER. FLAGS ARE THE ONLY IMPORTANT THING
-	input_buf->pBufHdr->nFilledLen = 0;
-	input_buf->pBufHdr->nOffset = 0;
-	input_buf->pBufHdr->nTimeStamp = iEndOfDataTimestamp;
-
-	// set ptr to input_buf structure for Context (for when the buffer is returned)
-	input_buf->pBufHdr->pAppPrivate = (OMX_PTR) input_buf;
-
-	// do not use Mark here (but init to NULL to prevent problems)
-	input_buf->pBufHdr->hMarkTargetComponent = NULL;
-	input_buf->pBufHdr->pMarkData = NULL;
-
-
-	// init buffer flags
-	input_buf->pBufHdr->nFlags = 0;
-
-	input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-	// most importantly, set the EOS flag:
-	input_buf->pBufHdr->nFlags |= OMX_BUFFERFLAG_EOS;
-
-	// send buffer to component
-	OMX_EmptyThisBuffer(iOMXVideoEncoder, input_buf->pBufHdr);
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0,"PVMFOMXVideoEncNode::SendEOSBufferToOMXComponent() Out"));
-
-	return true;
-
-}
-
-// this method is called under certain conditions only if the node is doing partial frame assembly
-void PVMFOMXVideoEncNode::DropCurrentBufferUnderConstruction()
-{
-	if(iObtainNewInputBuffer == false)
-	{
-		if(iInputBufferUnderConstruction != NULL)
-		{
-			if(iInBufMemoryPool != NULL )
-			{
-				iInBufMemoryPool->deallocate((OsclAny *)iInputBufferUnderConstruction);
-			}
-
-			iInputBufferUnderConstruction = NULL;
-		}
-		iObtainNewInputBuffer = true;
-
-	}
-}
-// this method is called under certain conditions only if the node is doing partial frame assembly
-void PVMFOMXVideoEncNode::SendIncompleteBufferUnderConstruction()
-{
-	// this should never be the case, but check anyway
-	if(iInputBufferUnderConstruction !=NULL)
-	{
-		// mark as end of frame (the actual end piece is missing)
-		iInputBufferUnderConstruction->pBufHdr->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::SendIncompleteBufferUnderConstruction()  - Sending Incomplete Buffer 0x%x to OMX Component MARKER field set to %x, TS=%d",iInputBufferUnderConstruction->pBufHdr->pBuffer,iInputBufferUnderConstruction->pBufHdr->nFlags,iInTimestamp));
-
-		OMX_EmptyThisBuffer(iOMXVideoEncoder,iInputBufferUnderConstruction->pBufHdr);
-
-		iInputBufferUnderConstruction = NULL;
-		iObtainNewInputBuffer = true;
-	}
-}
-/////////////////////////////////////////////////////////////////////////////
-void PVMFOMXVideoEncNode::freechunkavailable(OsclAny *aContext)
-{
-	// check context to see whether input or output buffer was returned to the mempool
-	if(aContext == (OsclAny *) iInBufMemoryPool)
-	{
-
-		iNumOutstandingInputBuffers--;
-
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::freechunkavailable() Memory chunk in INPUT mempool was deallocated, %d out of %d now available",iNumInputBuffers-iNumOutstandingInputBuffers,iNumInputBuffers));
-
-		// notification only works once.
-		// If there are multiple buffers coming back in a row, make sure to set the notification
-		// flag in the mempool again, so that next buffer also causes notification
-		iInBufMemoryPool->notifyfreechunkavailable(*this,aContext);
-
-	}
-	else if(aContext == (OsclAny *) iOutBufMemoryPool)
-	{
-
-		iNumOutstandingOutputBuffers--;
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::freechunkavailable() Memory chunk in OUTPUT mempool was deallocated, %d out of %d now available",iNumOutputBuffers-iNumOutstandingOutputBuffers,iNumOutputBuffers));
-
-		// notification only works once.
-		// If there are multiple buffers coming back in a row, make sure to set the notification
-		// flag in the mempool again, so that next buffer also causes notification
-		iOutBufMemoryPool->notifyfreechunkavailable(*this,aContext);
-
-	}
-	else
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-			(0,"PVMFOMXVideoEncNode::freechunkavailable() UNKNOWN mempool "));
-
-	}
-
-	// reschedule
-	if(IsAdded())
-		RunIfNotReady();
-
-
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// This routine will process outgoing message by sending it into output the port
-/////////////////////////////////////////////////////////////////////////////
-bool PVMFOMXVideoEncNode::ProcessOutgoingMsg(PVMFPortInterface* aPort)
-{
-	//Called by the AO to process one message off the outgoing
-	//message queue for the given port.  This routine will
-	//try to send the data to the connected port.
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-		(0, "0x%x PVMFOMXVideoEncNode::ProcessOutgoingMsg: aPort=0x%x", this, aPort));
-
-	PVMFStatus status = aPort->Send();
-	if(status == PVMFErrBusy)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-			(0, "0x%x PVMFOMXVideoEncNode::ProcessOutgoingMsg: Connected port goes into busy state", this));
-	}
-
-	//Report any unexpected failure in port processing...
-	//(the InvalidState error happens when port input is suspended,
-	//so don't report it.)
-	if (status!=PVMFErrBusy
-		&& status!=PVMFSuccess
-		&& status!=PVMFErrInvalidState)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-			(0, "0x%x PVMFOMXVideoEncNode::Run: Error - ProcessPortActivity failed. port=0x%x, type=%d",
-			this, iOutPort, PVMF_PORT_ACTIVITY_OUTGOING_MSG));
-		ReportErrorEvent(PVMFErrPortProcessing);
-	}
-
-	//return true if we processed an activity...
-	return (status!=PVMFErrBusy);
-}
-
-PVMFStatus PVMFOMXVideoEncNode::SendEndOfTrackCommand()
-{
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    //sharedMediaCmdPtr->setTimestamp(aMsg->getTimestamp());
-    sharedMediaCmdPtr->setTimestamp(iEndOfDataTimestamp);
-
-    // Set the sequence number
-    //sharedMediaCmdPtr->setSeqNum(aMsg->getSeqNum());
-    sharedMediaCmdPtr->setSeqNum(iSeqNum++);
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-
-    for (uint32 ii = 0; ii < iOutPort.size(); ii++)
-    {
-        PVMFStatus status = iOutPort[ii]->QueueOutgoingMsg(mediaMsgOut);
-
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFOMXVideoEncNode::SendEndOfTrackCommand: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node.h b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node.h
deleted file mode 100644
index 74df0e9..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node.h
+++ /dev/null
@@ -1,544 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_NODE_H_INCLUDED
-#define PVMF_OMX_VIDEOENC_NODE_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef __PVM4VENCODER_H
-#include "pvm4vencoder.h"
-#endif
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-#include "pvmp4h263encextension.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_TUNEABLES_H_INCLUDED
-#include "pvmf_omx_videoenc_tuneables.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-#ifndef OSCL_TICKCOUNT_H_INCLUDED
-#include "oscl_tickcount.h"
-#endif
-
-//Holmes add for omx {
-#ifndef OMX_Core_h
-#include "omx_core.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_CALLBACKS_H_INCLUDED
-#include "pvmf_omx_videoenc_callbacks.h"
-#endif
-
-//Default values for number of Input/Output buffers. If the component needs more than this, it will be
-// negotiated. If the component does not need more than this number, the default is used
-#define NUMBER_INPUT_BUFFER 3
-#define NUMBER_OUTPUT_BUFFER 5
-
-typedef struct OutputBufCtrlStruct
-{
-	OMX_BUFFERHEADERTYPE *pBufHdr;
-}
-OutputBufCtrlStruct;
-
-typedef struct InputBufCtrlStruct
-{
-	OMX_BUFFERHEADERTYPE *pBufHdr;
-	PVMFSharedMediaDataPtr pMediaData;
-}
-InputBufCtrlStruct;
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// CUSTOM DEALLOCATOR FOR MEDIA DATA SHARED PTR WRAPPER:
-//	1) Deallocates the underlying output buffer
-//	2) Deallocates the pvci buffer wrapper and the rest of accompanying structures
-//	   Deallocator is created as part of the wrapper, and travels with the buffer wrapper
-
-class PVOMXBufferSharedPtrWrapperCombinedCleanupDA
-	: public OsclDestructDealloc
-{
-public:
-	PVOMXBufferSharedPtrWrapperCombinedCleanupDA(Oscl_DefAlloc* allocator, void *pMempoolData) :
-		buf_alloc(allocator),ptr_to_data_to_dealloc(pMempoolData) {};
-	virtual ~PVOMXBufferSharedPtrWrapperCombinedCleanupDA() {};
-
-	virtual void destruct_and_dealloc(OsclAny* ptr)
-	{
-		// call buffer deallocator
-		if(buf_alloc !=NULL)
-		{
-		buf_alloc->deallocate(ptr_to_data_to_dealloc);
-		}
-
-		// finally, free the shared ptr wrapper memory
-		oscl_free(ptr);
-	}
-
-private:
-	Oscl_DefAlloc* buf_alloc;
-	void *ptr_to_data_to_dealloc;
-};
-//Holmes add for omx }
-
-
-// Forward declarations
-class PVMFVideoEncPort;
-class OsclClock;
-
-// Allocators
-typedef OsclMemAllocDestructDealloc<uint8> PVMFVideoEncNodeAllocDestructDealloc;
-typedef OsclMemAllocator PVMFVideoEncNodeAlloc;
-
-/** Node command type */
-typedef PVMFGenericNodeCommand<PVMFVideoEncNodeAlloc> PVMFVideoEncNodeCommand;
-
-/** Command queue type */
-typedef PVMFNodeCommandQueue<PVMFVideoEncNodeCommand,PVMFVideoEncNodeAlloc> PVMFVideoEncNodeCmdQueue;
-
-/** Port vector type */
-typedef PVMFPortVector<PVMFVideoEncPort,PVMFVideoEncNodeAlloc> PVMFVideoEncPortVector;
-
-////////////////////////////////////////////////////////////////////////////
-class PVMFOMXVideoEncNode
-    : public OsclTimerObject
-    , public PVMFNodeInterface
-    , public OsclMemPoolFixedChunkAllocatorObserver
-    , public MPVCVEIObserver //remove?
-    , public PVMp4H263EncExtensionInterface //remove?
-    , public PvmiCapabilityAndConfig
-{
-public:
-	PVMFOMXVideoEncNode(int32 aPriority);
-	~PVMFOMXVideoEncNode();
-
-	// Virtual functions of PVMFNodeInterface
-	OSCL_IMPORT_REF PVMFStatus ThreadLogon();
-	OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
-	OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
-	OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
-    OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId aSession,
-	                                      const PvmfMimeString& aMimeType,
-                                          Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-                                          bool aExactUuidsOnly=false,
-                                          const OsclAny* aContext=NULL);
-    OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSession,
-	                                           const PVUuid& aUuid,
-                                               PVInterface*& aInterfacePtr,
-                                               const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession, int32 aPortTag,
-	                                        const PvmfMimeString* aPortConfig=NULL,
-	                                        const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId aSession, PVMFPortInterface& aPort,
-	                                        const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-	OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId aSession, const OsclAny* aContext=NULL);
-    OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContextData=NULL);
-    OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId,
-	                                          const OsclAny* aContextData=NULL);
-
-	// From PVMFPortActivityHandler
-	void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-	// Virtual functions of PVMp4H263EncExtensionInterface
-	OSCL_IMPORT_REF void addRef();
-	OSCL_IMPORT_REF void removeRef();
-	OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-	OSCL_IMPORT_REF bool SetNumLayers(uint32 aNumLayers);
-	OSCL_IMPORT_REF bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate);
-	OSCL_IMPORT_REF bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight);
-	OSCL_IMPORT_REF bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate);
-	OSCL_IMPORT_REF bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes);
-	OSCL_IMPORT_REF bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl);
-	OSCL_IMPORT_REF bool SetDataPartitioning(bool aDataPartitioning);
-	OSCL_IMPORT_REF bool SetRVLC(bool aRVLC);
-	OSCL_IMPORT_REF bool SetIFrameInterval(uint32 aIFrameInterval);
-	OSCL_IMPORT_REF bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader);
-	OSCL_IMPORT_REF bool RequestIFrame();
-	OSCL_IMPORT_REF bool SetCodec(PVMFFormatType aCodec);
-
-	// From MPVCVEIObserver
-	void HandlePVCVEIEvent(uint32 aId, uint32 aEvent, uint32 aParam1);
-
-	// implemetation of PvmiCapabilityAndConfig class functions here
-	void setObserver (PvmiConfigAndCapabilityCmdObserver* aObserver);
-
-	uint32 getCapabilityMetric (PvmiMIOSession aSession);
-    PVMFStatus getParametersSync(PvmiMIOSession aSession,
-		                                 PvmiKeyType aIdentifier,
-		                                 PvmiKvp*& aParameters,
-		                                 int& aNumParamElements,
-		                                 PvmiCapabilityContext aContext);
-	void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-		                           int num_elements, PvmiKvp * & aRet_kvp);
-	PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
-                                             PvmiKvp* aParameters,
-		                                     int num_elements,
-		                                     PvmiKvp*& aRet_kvp,
-		                                     OsclAny* context=NULL);
-	void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                                      PvmiKvp* aParameters, int num_parameter_elements);
-	PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
-                                            PvmiKvp* aParameters,
-                                            int num_elements);
-	PVMFStatus releaseParameters(PvmiMIOSession aSession,
-		                                 PvmiKvp* aParameters,
-		                                 int num_elements);
-    void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-	void DeleteContext(PvmiMIOSession aSession,
-                               PvmiCapabilityContext& aContext);
-	// function used in getParametersSync of capability class
-    PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
-                                  int32 aIndex, PvmiKvpAttr reqattr);
-    // function used in VerifyParametersSync n SetParametersSync of capability class
-	PVMFStatus VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam);
-
-//Holmes add for omx {
-	// Virtual functions of OsclMemPoolFixedChunkAllocatorObserver
-	void freechunkavailable(OsclAny *aContext);
-
-	//*****************************************************
-	//********** CB Functions to serve OpenMAX Encoder
-	//*****************************************************
-	//Process callback functions. They will be executed in testapp thread context
-	//	These callbacks are used only in the Multithreaded component case
-	OsclReturnCode ProcessCallbackEventHandler_MultiThreaded(OsclAny* P);
-	OsclReturnCode ProcessCallbackEmptyBufferDone_MultiThreaded(OsclAny* P);
-	OsclReturnCode ProcessCallbackFillBufferDone_MultiThreaded(OsclAny* P);
-
-	//Callback objects - again, these are used only in the case of Multithreaded component
-	EventHandlerThreadSafeCallbackAO*	 iThreadSafeHandlerEventHandler;
-	EmptyBufferDoneThreadSafeCallbackAO* iThreadSafeHandlerEmptyBufferDone;
-	FillBufferDoneThreadSafeCallbackAO*  iThreadSafeHandlerFillBufferDone;
-
-	OMX_CALLBACKTYPE       iCallbacks; // structure that contains callback ptrs.
-
-	// OMX CALLBACKS
-	// 1) AO OMX component running in the same thread as the OMX node
-	//	In this case, the callbacks can be called directly from the component
-	//	The callback: OMX Component->CallbackEventHandler->EventHandlerProcessing
-	//	The callback can perform do RunIfNotReady
-	// 2) Multithreaded component
-	//	In this case, the callback is made using the threadsafe callback (TSCB) AO
-	//	Component thread : OMX Component->CallbackEventHandler->TSCB(ReceiveEvent)
-	//  Node thread		 : TSCB(ProcessEvent)->ProcessCallbackEventHandler_MultiThreaded->EventHandlerProcessing
-	//==============================================================================
-
-	OMX_ERRORTYPE EventHandlerProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-								  OMX_OUT OMX_PTR aAppData,
-								  OMX_OUT OMX_EVENTTYPE aEvent,
-								  OMX_OUT OMX_U32 aData1,
-								  OMX_OUT OMX_U32 aData2,
-								  OMX_OUT OMX_PTR aEventData);
-
-	OMX_ERRORTYPE EmptyBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-									 OMX_OUT OMX_PTR aAppData,
-									 OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-	OMX_ERRORTYPE FillBufferDoneProcessing(OMX_OUT OMX_HANDLETYPE aComponent,
-									OMX_OUT OMX_PTR aAppData,
-									OMX_OUT OMX_BUFFERHEADERTYPE* aBuffer);
-
-	bool IsComponentMultiThreaded() {return iIsOMXComponentMultiThreaded;};
-//Holmes add for omx }
-
-private:
-	void ConstructEncoderParams();
-
-	// From OsclTimerObject
-	void Run();
-
-	/////////////////////////////////////////////////////
-	//     Command processing routines
-	/////////////////////////////////////////////////////
-	PVMFCommandId QueueCommandL(PVMFVideoEncNodeCommand& aCmd);
-	bool ProcessCommand(PVMFVideoEncNodeCommand& aCmd);
-	void CommandComplete(PVMFVideoEncNodeCmdQueue& aCmdQueue, PVMFVideoEncNodeCommand& aCmd,
-	                     PVMFStatus aStatus, OsclAny* aData=NULL);
-	void DoQueryUuid(PVMFVideoEncNodeCommand& aCmd);
-	void DoQueryInterface(PVMFVideoEncNodeCommand& aCmd);
-	void DoRequestPort(PVMFVideoEncNodeCommand& aCmd);
-	PVMFVideoEncPort* AllocatePort(PVMFVideoEncPortVector& aPortVector, int32 aTag, OSCL_String* aMimeType, const char* aName = NULL);
-	void DoReleasePort(PVMFVideoEncNodeCommand& aCmd);
-	void DoInit(PVMFVideoEncNodeCommand& aCmd);
-	void DoPrepare(PVMFVideoEncNodeCommand& aCmd);
-	void DoStart(PVMFVideoEncNodeCommand& aCmd);
-	void DoStop(PVMFVideoEncNodeCommand& aCmd);
-	void DeleteVideoEncoder();
-	void DoFlush(PVMFVideoEncNodeCommand& aCmd);
-	bool IsFlushPending();
-	void FlushComplete();
-	void DoPause(PVMFVideoEncNodeCommand& aCmd);
-	void DoReset(PVMFVideoEncNodeCommand& aCmd);
-	void DoCancelAllCommands(PVMFVideoEncNodeCommand& aCmd);
-	void DoCancelCommand(PVMFVideoEncNodeCommand& aCmd);
-
-	/////////////////////////////////////////////////////
-	//      Port activity processing routines
-	/////////////////////////////////////////////////////
-	bool IsProcessOutgoingMsgReady();
-	bool IsProcessIncomingMsgReady();
-	PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
-	PVMFStatus SyncEncodeAndSend(PVMFSharedMediaDataPtr& aMediaData);
-	PVMFStatus SendEncodedBitstream(PVMFSharedMediaDataPtr& iMediaData);
-
-	/////////////////////////////////////////////////////
-	//      Encoder settings routine
-	/////////////////////////////////////////////////////
-	PVMFStatus SetInputFormat(PVMFFormatType aFormat);
-	PVMFStatus SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient = 0);
-	PVMFStatus SetInputFrameRate(OsclFloat aFrameRate);
-	PVMFStatus SetCodecType(PVMFFormatType aCodec);
-	PVMFFormatType GetCodecType();
-	uint32 GetOutputBitRate(uint32 aLayer);
-	OsclFloat GetOutputFrameRate(uint32 aLayer);
-	PVMFStatus GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight);
-	uint32 GetIFrameInterval();
-
-	// Event reporting
-	void ReportErrorEvent(PVMFEventType aEventType,OsclAny* aEventData=NULL);
-	void ReportInfoEvent(PVMFEventType aEventType,OsclAny* aEventData=NULL);
-	void SetState(TPVMFNodeInterfaceState aState);
-	PVMFStatus SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg);
-
-//Holmes add for omx {
-        // Resolve race condition between pv omx encoder node and qualcomm encoder
-        uint32 mInputBufferRefCount;
-
-	bool SetDefaultCapabilityFlags();
-	bool NegotiateComponentParameters();
-	bool CreateOutputMemPool(uint32 num_buffers);
-	bool CreateInputMemPool(uint32 num_buffers);
-	bool ProvideBuffersToComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-										  uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  uint32 aNumBuffers,    // number of buffers
-										  uint32 aActualBufferSize, // aactual buffer size
-										  uint32 aPortIndex,      // port idx
-										  bool aUseBufferOK,		// can component use OMX_UseBuffer or should it use OMX_AllocateBuffer
-										  bool	aIsThisInputBuffer		// is this input or output
-										  );
-	bool FreeBuffersFromComponent(OsclMemPoolFixedChunkAllocator *aMemPool, // allocator
-										  uint32 aAllocSize,	 // size to allocate from pool (hdr only or hdr+ buffer)
-										  uint32 aNumBuffers,    // number of buffers
-										  uint32 aPortIndex,      // port idx
-										  bool	aIsThisInputBuffer		// is this input or output
-										  );
-	void HandleComponentStateChange(OMX_U32 decoder_state);
-	OsclSharedPtr<PVMFMediaDataImpl> WrapOutputBuffer(uint8 *pData,uint32 aDataLen, OsclAny *pContext);
-	bool QueueOutputBuffer(OsclSharedPtr<PVMFMediaDataImpl> &mediadataimplout,uint32 aDataLen);
-	PVMFStatus HandleProcessingState();
-	bool SendOutputBufferToOMXComponent();
-	bool SendInputBufferToOMXComponent();
-	bool SendEOSBufferToOMXComponent();
-	void DropCurrentBufferUnderConstruction();
-	void SendIncompleteBufferUnderConstruction();
-	bool ProcessOutgoingMsg(PVMFPortInterface* aPort);
-	PVMFStatus SendEndOfTrackCommand(); //temp overloading
-
-
-	// Handle of OMX Component
-	OMX_HANDLETYPE iOMXVideoEncoder;
-
-	// Current State of the component
-	OMX_STATETYPE iCurrentEncoderState;
-
-	// Shared pointer for Media Msg.Input buffer
-	PVMFSharedMediaDataPtr iDataIn;
-
-	//EOS control flags
-	bool iIsEOSSentToComponent;
-	bool iIsEOSReceivedFromComponent;
-
-	////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS
-	bool iOMXComponentSupportsExternalOutputBufferAlloc;
-	bool iOMXComponentSupportsExternalInputBufferAlloc;
-	bool iOMXComponentSupportsMovableInputBuffers;
-	bool iIsOMXComponentMultiThreaded;
-	bool iOMXComponentSupportsPartialFrames;
-	bool iOMXComponentCanHandleIncompleteFrames;
-
-	// DYNAMIC PORT RE-CONFIGURATION
-	uint32 iInputPortIndex;
-	uint32 iOutputPortIndex;
-	OMX_PARAM_PORTDEFINITIONTYPE iParamPort;
-	uint32 iPortIndexForDynamicReconfig;
-	bool iSecondPortReportedChange;
-	bool iDynamicReconfigInProgress;
-	uint32 iSecondPortToReconfig;
-
-	// OUTPUT BUFFER RELATED MEMBERS
-	OsclMemPoolFixedChunkAllocator *iMediaDataMemPool;
-	OsclMemPoolFixedChunkAllocator *iOutBufMemoryPool;
-	uint32 iOMXComponentOutputBufferSize; // Size of output buffer (negotiated with component)
-	uint32 iOutputAllocSize; // size of output to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
-							// (OMX_USE_BUFFER = size of buf header + iOMXCoponentOutputBufferSize)
-	uint32 iNumOutputBuffers; // Number of output buffers (negotiated with component)
-	uint32 iNumOutstandingOutputBuffers; // Number of output buffers in possession of the component or downstream,
-										// namely, number of unavailable buffers
-	bool iDoNotSendOutputBuffersDownstreamFlag; // flag to prevent sending output buffers downstream during flushing etc.
-	bool iOutputBuffersFreed; // flag to prevent freeing the buffers twice
-	OMX_PTR ipPrivateData; // ptr to private data to be sent with output buffer
-
-	// INPUT BUFFER RELATED MEMBERS
-	OsclMemPoolFixedChunkAllocator *iInBufMemoryPool;
-	uint32 iOMXComponentInputBufferSize; // size of input buffer that the component sees (negotiated with the component)
-	uint32 iInputAllocSize; // size of input buffer to allocate (OMX_ALLOCATE_BUFFER =  size of buf header )
-							// (OMX_USE_BUFFER = size of buf header + iOMXCoponentInputBufferSize)
-	uint32 iNumInputBuffers; // total num of input buffers (negotiated with component)
-	uint32 iNumOutstandingInputBuffers; // number of input buffers in use (i.e. unavailable)
-
-	bool iDoNotSaveInputBuffersFlag;
-	bool iInputBuffersFreed; // flag to prevent freeing buffers twice
-
-	//
-	PvmfFormatIndex iOMXComponentInputYUVFormat;
-
-	//
-	OMX_BUFFERHEADERTYPE *iInputBufferToResendToComponent; // ptr to input buffer that is not empty, but that the OMX component returned
-															// we need to resend this same buffer back to the component
-
-    // State definitions for HandleProcessingState() state machine
-	typedef enum
-	{
-		EPVMFOMXVideoEncNodeProcessingState_Idle,                   //default state after constraction/reset
-		EPVMFOMXVideoEncNodeProcessingState_InitEncoder,            //initialization of encoder after handle was obtained
-		EPVMFOMXVideoEncNodeProcessingState_WaitForInitCompletion,  // waiting for init completion
-		EPVMFOMXVideoEncNodeProcessingState_ReadyToEncode,          //nornal operation state of the decoder
-		EPVMFOMXVideoEncNodeProcessingState_WaitForOutputBuffer,    //wait state for avalible media output buffer
-		EPVMFOMXVideoEncNodeProcessingState_WaitForOutputPort,      //wait state, output port is busy
-		EPVMFOMXVideoEncNodeProcessingState_WaitForOutgoingQueue,   //wait state, outgoing queue
-		EPVMFOMXVideoEncNodeProcessingState_PortReconfig,			// Dynamic Port Reconfiguration - step 1
-		EPVMFOMXVideoEncNodeProcessingState_WaitForBufferReturn,    // Dynamic Port Reconfiguration - step 2
-		EPVMFOMXVideoEncNodeProcessingState_WaitForPortDisable,		// Dynamic Port Reconfiguration - step 3
-		EPVMFOMXVideoEncNodeProcessingState_PortReEnable,			// Dynamic Port Reconfiguration - step 4
-		EPVMFOMXVideoEncNodeProcessingState_WaitForPortEnable,		// Dynamic Port Reconfiguration - step 5
-		EPVMFOMXVideoEncNodeProcessingState_Stopping,				// when STOP command is issued, the node has to wait for component to transition into
-																	// idle state. The buffers keep coming back , the node is rescheduled
-																	// to run. Prevent the node from sending buffers back
-		EPVMFOMXVideoEncNodeProcessingState_Pausing					// when PAUSE command is issued, the node has to wait for component to transition into
-																	// paused state. The buffers may still keep coming back , the node is rescheduled
-																	// to run. Prevent the node from sending buffers back to component
-	}
-	PVMFOMXVideoEncNode_ProcessingState;
-
-    // State of HandleProcessingState() state machine
-	PVMFOMXVideoEncNode_ProcessingState iProcessingState;
-
-	bool iResetInProgress;
-	bool iResetMsgSent;
-
-	// Time stamp to be used on output buffer
-	uint32 iOutTimeStamp;
-
-	// input buffer fragmentation etc.
-	uint32 iCopyPosition;				// for copying memfrag data into a buffer
-	uint32 iFragmentSizeRemainingToCopy;
-	bool iIsNewDataFragment;
-
-	// partial frame assembly logic flags
-	bool iObtainNewInputBuffer;
-	bool iKeepDroppingMsgsUntilMarkerBit;
-	InputBufCtrlStruct *iInputBufferUnderConstruction;
-
-	// input data info
-	uint32 iCurrFragNum;
-	uint32 iCodecSeqNum;	// sequence number tracking
-	uint32 iInPacketSeqNum;
-
-	uint32 iInTimestamp;
-	uint32 iInDuration;
-	uint32 iInNumFrags;
-	uint32 iCurrentMsgMarkerBit;
-
-	// EOS flag
-	bool iEndOfDataReached;
-	// Time stame upon EOS
-	PVMFTimestamp iEndOfDataTimestamp;
-
-//Holmes add for omx }
-
-	// Allocators
-	PVMFVideoEncNodeAllocDestructDealloc iAlloc;
-	OsclMemPoolFixedChunkAllocator iMediaBufferMemPool;
-	PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc;
-	OsclMemPoolFixedChunkAllocator iMediaDataMemPoolOld;
-
-
-	// Command queue
-	PVMFVideoEncNodeCmdQueue iCmdQueue;
-
-	// A queue is used to hold the current command so it's easy to find out
-	// whether a command is in progress, and allow cancel to interrupt
-	PVMFVideoEncNodeCmdQueue iCurrentCmd;
-
-	// Ports and port activity
-	PVMFVideoEncPortVector iInPort;
-	PVMFVideoEncPortVector iOutPort;
-	friend class PVMFVideoEncPort;
-
-	PVLogger* iLogger;
-
-	int32 iExtensionRefCount;
-
-	// Encoder
-	//CPVM4VEncoder* iVideoEncoder;
-	TPVVideoInputFormat iInputFormat;
-	TPVVideoEncodeParam iEncodeParam;
-	uint32 iSeqNum; /** Sequence number */
-	OsclRefCounterMemFrag iVolHeader; /** Vol header */
-
-};
-
-#endif // PVMF_OMX_VIDEOENC_NODE_H_INCLUDED
-
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node_cap_config.cpp b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node_cap_config.cpp
deleted file mode 100644
index 4cad05b..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_node_cap_config.cpp
+++ /dev/null
@@ -1,562 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_NODE_H_INCLUDED
-#include "pvmf_omx_videoenc_node.h"
-#endif
-
-#ifndef PVMF_OMX_VIDEOENC_PORT_H_INCLUDED
-#include "pvmf_omx_videoenc_port.h"
-#endif
-
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-
-#ifndef PVMI_KVP_UTIL_H_INCLUDED
-#include "pvmi_kvp_util.h"
-#endif
-
-
-// Structure to hold the key string info for
-// videoencnode's capability-and-config
-struct PVVideoEncNodeKeyStringData
-{
-	char iString[64];
-	PvmiKvpType iType;
-	PvmiKvpValueType iValueType;
-};
-
-// The number of characters to allocate for the key string
-#define PVVIDEOENCNODECONFIG_KEYSTRING_SIZE 128
-
-// Key string info at the base level ("x-pvmf/video/render")
-#define PVVIDEOENCNODECONFIG_BASE_NUMKEYS 3
-
-const PVVideoEncNodeKeyStringData PVVideoEncNodeConfigBaseKeys[PVVIDEOENCNODECONFIG_BASE_NUMKEYS]=
-{
-	{"output_width", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-	{"output_height", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
-};
-
-enum BaseKeys_IndexMapType
-{
-    OUTPUT_WIDTH = 0,
-	OUTPUT_HEIGHT
-};
-
-PVMFStatus PVMFOMXVideoEncNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::GetConfigParameter() In"));
-
-	aNumParamElements=0;
-
-	// Allocate memory for the KVP
-	aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
-	if (NULL == aParameters)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::GetConfigParameter() Memory allocation for KVP failed"));
-		return PVMFErrNoMemory;
-	}
-	oscl_memset(aParameters, 0, sizeof(PvmiKvp));
-	// Allocate memory for the key string in KVP
-	PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVVIDEOENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
-	if (NULL == memblock)
-	{
-		oscl_free(aParameters);
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::GetConfigParameter() Memory allocation for key string failed"));
-		return PVMFErrNoMemory;
-	}
-	oscl_strset(memblock, 0, PVVIDEOENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
-	// Assign the key string buffer to KVP
-	aParameters[0].key = memblock;
-
-	// Copy the key string
-	oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/video/render/"), 21);
-	oscl_strncat(aParameters[0].key, PVVideoEncNodeConfigBaseKeys[aIndex].iString, oscl_strlen(PVVideoEncNodeConfigBaseKeys[aIndex].iString));
-	oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
-	switch (PVVideoEncNodeConfigBaseKeys[aIndex].iValueType)
-	{
-	case PVMI_KVPVALTYPE_BITARRAY32:
-		oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING));
-		break;
-
-	case PVMI_KVPVALTYPE_KSV:
-		oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-		break;
-
-	case PVMI_KVPVALTYPE_BOOL:
-		oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
-		break;
-
-	case PVMI_KVPVALTYPE_INT32:
-		if(PVMI_KVPATTR_CUR == aReqattr)
-		{
-			oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-		}
-		break;
-	case PVMI_KVPVALTYPE_UINT32:
-	default:
-		if(PVMI_KVPATTR_CAP == aReqattr)
-		{
-			oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-		}
-		else
-		{
-			oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
-		}
-		break;
-	}
-	aParameters[0].key[PVVIDEOENCNODECONFIG_KEYSTRING_SIZE-1] = 0;
-
-	// Copy the requested info
-	switch(aIndex)
-	{
-	case OUTPUT_WIDTH:	// "output_width"
-		if (PVMI_KVPATTR_CUR == aReqattr)
-		{
-			// Return current value
-			int32 aLayer = 0;
-			aParameters[0].value.uint32_value = iEncodeParam.iFrameWidth[aLayer];
-		}
-		else if (PVMI_KVPATTR_DEF == aReqattr)
-		{
-			// Return default
-			aParameters[0].value.uint32_value = DEFAULT_FRAME_WIDTH;
-		}
-		else
-		{
-			// Return capability
-		}
-		break;
-
-	case OUTPUT_HEIGHT:	// "output_height"
-		if (PVMI_KVPATTR_CUR == aReqattr)
-		{
-			// Return current value
-			int32 aLayer = 0;
-			aParameters[0].value.uint32_value = iEncodeParam.iFrameHeight[aLayer];
-		}
-		else if (PVMI_KVPATTR_DEF == aReqattr)
-		{
-			// Return default
-			aParameters[0].value.uint32_value = DEFAULT_FRAME_HEIGHT;
-		}
-		else
-		{
-			// Return capability
-		}
-		break;
-
-	default:
-		// Invalid index
-		oscl_free(aParameters[0].key);
-		oscl_free(aParameters);
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::GetConfigParameter() Invalid index to video enc node parameter"));
-		return PVMFErrNotSupported;
-	}
-
-	aNumParamElements = 1;
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::GetConfigParameter() Out"));
-	return PVMFSuccess;
-}
-
-PVMFStatus PVMFOMXVideoEncNode::VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::VerifyAndSetConfigParameter() In"));
-
-	// Determine the valtype
-	PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
-	if(PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::VerifyAndSetConfigParameter() Valtype in key string unknown"));
-		return PVMFErrNotSupported;
-	}
-	// Retrieve the fourth component from the key string
-	char* compstr = NULL;
-	pv_mime_string_extract_type(3, aParameter.key, compstr);
-
-	int32 venccomp4ind;
-	for (venccomp4ind = 0; venccomp4ind < PVVIDEOENCNODECONFIG_BASE_NUMKEYS; ++venccomp4ind)
-	{
-		// Go through each component string at 4th level
-		if (pv_mime_strcmp(compstr, (char*)(PVVideoEncNodeConfigBaseKeys[venccomp4ind].iString))>=0)
-		{
-			// Break out of the for loop
-			break;
-		}
-	}
-
-	if ( PVVIDEOENCNODECONFIG_BASE_NUMKEYS <= venccomp4ind)
-	{
-		// Match couldn't be found or non-leaf node specified
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::VerifyAndSetConfigParameter() Unsupported key or non-leaf node"));
-		return PVMFErrNotSupported;
-	}
-
-	// Verify the valtype
-	if (keyvaltype != PVVideoEncNodeConfigBaseKeys[venccomp4ind].iValueType)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::VerifyAndSetConfigParameter() Valtype does not match for key"));
-		return PVMFErrNotSupported;
-	}
-
-	switch(venccomp4ind)
-	{
-	case OUTPUT_WIDTH: // "output_width"
-			// change the parameter
-		if (aSetParam)
-		{
-			int32 aLayer = 0;
-			iEncodeParam.iFrameWidth[aLayer] = aParameter.value.uint32_value;
-		}
-		break;
-
-	case OUTPUT_HEIGHT: // "output_height"
-			// change the parameter
-		if (aSetParam)
-		{
-			int32 aLayer = 0;
-			iEncodeParam.iFrameHeight[aLayer] = aParameter.value.uint32_value;
-		}
-		break;
-
-	default:
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::VerifyAndSetConfigParameter() Invalid index for video enc node parameter"));
-		return PVMFErrNotSupported;
-	}
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::VerifyAndSetConfigParameter() Out"));
-	return PVMFSuccess;
-}
-
-void PVMFOMXVideoEncNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::setParametersSync()"));
-	OSCL_UNUSED_ARG(aSession);
-
-	if (NULL == aParameters || aNumElements < 1)
-	{
-		if (aParameters)
-		{
-			aRetKVP=aParameters;
-		}
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::setParametersSync() Passed in parameter invalid"));
-		return;
-	}
-
-	// Go through each parameter
-	for (int32 paramind = 0; paramind<aNumElements; ++paramind)
-	{
-		// Count the number of components and parameters in the key
-		int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-		// Retrieve the first component from the key string
-		char* compstr = NULL;
-		pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-		if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 3)
-		{
-			// First 3 components should be "x-pvmf/video/render" and there must
-			// be at least 3 components
-			aRetKVP = &aParameters[paramind];
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::setParametersSync() Unsupported key"));
-			return;
-		}
-
-		if (4 == compcount )
-		{
-			// Verify and set the passed-in video enc node setting
-			PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
-			if (PVMFSuccess != retval)
-			{
-				aRetKVP = &aParameters[paramind];
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::setParametersSync() Setting parameter %d failed", paramind));
-				return;
-			}
-		}
-
-		else
-		{
-			// Do not support more than 4 components right now
-			aRetKVP = &aParameters[paramind];
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::setParametersSync() Unsupported key"));
-			return;
-		}
-	}
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::setParametersSync() Out"));
-}
-
-
-PVMFStatus PVMFOMXVideoEncNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::getParametersSync()"));
-	OSCL_UNUSED_ARG(aSession);
-	OSCL_UNUSED_ARG(aContext);
-
-	// Initialize the output parameters
-	aNumParamElements = 0;
-	aParameters = NULL;
-
-	// Count the number of components and parameters in the key
-	int compcount = pv_mime_string_compcnt(aIdentifier);
-	// Retrieve the first component from the key string
-	char* compstr = NULL;
-	pv_mime_string_extract_type(0, aIdentifier, compstr);
-
-	if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 4)
-	{
-		// First 3 components should be "x-pvmf/video/render" and there must
-		// be at least 3 components
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::getParametersSync() Invalid key string"));
-		 return PVMFErrNotSupported;
-	}
-
-	// Retrieve the fourth component from the key string
-	pv_mime_string_extract_type(3, aIdentifier, compstr);
-
-	for (int32 venccomp4ind = 0; venccomp4ind < PVVIDEOENCNODECONFIG_BASE_NUMKEYS; ++venccomp4ind)
-	{
-		// Go through each video enc component string at 4th level
-		if (pv_mime_strcmp(compstr, (char*)(PVVideoEncNodeConfigBaseKeys[venccomp4ind].iString)) >= 0)
-		{
-			if (4 == compcount)
-			{
-				// Determine what is requested
-				PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
-				if(PVMI_KVPATTR_UNKNOWN == reqattr)
-				{
-					reqattr = PVMI_KVPATTR_CUR;
-				}
-
-				// Return the requested info
-				PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, venccomp4ind, reqattr);
-				if (PVMFSuccess != retval)
-				{
-					PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::getParametersSync() Retrieving video enc node parameter failed"));
-					return retval;
-				}
-			}
-			else
-			{
-				// Right now videoenc node doesn't support more than 4 components
-				// for this sub-key string so error out
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::getParametersSync() Unsupported key"));
-				return PVMFErrNotSupported;
-			}
-		}
-	}
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::getParametersSync() Out"));
-	if (aNumParamElements == 0)
-	{
-		// If no one could get the parameter, return error
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::getParametersSync() Unsupported key"));
-		return PVMFFailure;
-	}
-	else
-	{
-		return PVMFSuccess;
-	}
-}
-
-PVMFStatus PVMFOMXVideoEncNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::releaseParameters()"));
-	OSCL_UNUSED_ARG(aSession);
-
-	if (aParameters == NULL || aNumElements < 1)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::releaseParameters() KVP list is NULL or number of elements is 0"));
-		return PVMFErrArgument;
-	}
-
-	// Count the number of components and parameters in the key
-	int compcount=pv_mime_string_compcnt(aParameters[0].key);
-	// Retrieve the first component from the key string
-	char* compstr = NULL;
-	pv_mime_string_extract_type(0, aParameters[0].key, compstr);
-
-	if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 3)
-	{
-		// First 3 component should be "x-pvmf/video/render" and there must
-		// be at least three components
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::releaseParameters() Unsupported key"));
-		return PVMFErrNotSupported;
-	}
-
-	// Retrieve the third component from the key string
-	pv_mime_string_extract_type(2, aParameters[0].key, compstr);
-
-	// Go through each KVP and release memory for value if allocated from heap
-	for (int32 ii = 0; ii < aNumElements; ++ii)
-	{
-		// Next check if it is a value type that allocated memory
-		PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
-		if (PVMI_KVPTYPE_VALUE == kvptype || PVMI_KVPTYPE_UNKNOWN == kvptype)
-		{
-			PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
-			if(PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::releaseParameters() Valtype not specified in key string"));
-				return PVMFErrNotSupported;
-			}
-
-			if (PVMI_KVPVALTYPE_CHARPTR == keyvaltype && NULL != aParameters[ii].value.pChar_value)
-			{
-				oscl_free(aParameters[ii].value.pChar_value);
-				aParameters[ii].value.pChar_value = NULL;
-			}
-			else if (keyvaltype == PVMI_KVPVALTYPE_KSV && NULL != aParameters[ii].value.key_specific_value)
-			{
-				oscl_free(aParameters[ii].value.key_specific_value);
-				aParameters[ii].value.key_specific_value = NULL;
-			}
-			else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
-			{
-				range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
-				aParameters[ii].value.key_specific_value = NULL;
-				oscl_free(rui32);
-			}
-			// TODO Add more types if video enc node starts returning more types
-		}
-	}
-
-	// Video enc node allocated its key strings in one chunk so just free the first key string ptr
-	oscl_free(aParameters[0].key);
-
-	// Free memory for the parameter list
-	oscl_free(aParameters);
-	aParameters=NULL;
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::releaseParameters() Out"));
-	return PVMFSuccess;
-}
-
-
-PVMFStatus PVMFOMXVideoEncNode::verifyParametersSync (PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::verifyParametersSync()"));
-	OSCL_UNUSED_ARG(aSession);
-
-	if (NULL == aParameters || aNumElements < 1)
-	{
-		PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::verifyParametersSync() Passed in parameter invalid"));
-		return PVMFErrArgument;
-	}
-
-	// Go through each parameter
-	for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-	{
-		// Count the number of components and parameters in the key
-		int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-		// Retrieve the first component from the key string
-		char* compstr = NULL;
-		pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-		if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 3)
-		{
-			// First 3 components should be "x-pvmf/video/decoder" and there must
-			// be at least 3 components
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::verifyParametersSync() Unsupported key"));
-			return PVMFErrNotSupported;
-		}
-
-		if (4 == compcount)
-		{
-			// Verify and set the passed-in video enc node setting
-			PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], false);
-			if (retval != PVMFSuccess)
-			{
-				PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::verifyParametersSync() Setting parameter %d failed", paramind));
-				return retval;
-			}
-		}
-		else
-		{
-			// Do not support more than 4 components right now
-			PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0,"PVMFOMXVideoEncNode::verifyParametersSync() Unsupported key"));
-			return PVMFErrNotSupported;
-		}
-	}
-
-	PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"PVMFOMXVideoEncNode::verifyParametersSync() Out"));
-	return PVMFSuccess;
-
-}
-
-uint32 PVMFOMXVideoEncNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-	OSCL_UNUSED_ARG(aSession);
-    return 0;
-}
-
-//PvmiCapConfigInterface
-void PVMFOMXVideoEncNode::createContext(PvmiMIOSession aSession,
-                                             PvmiCapabilityContext& aContext)
-{
-	OSCL_UNUSED_ARG(aSession);
-	OSCL_UNUSED_ARG(aContext);
-	// not supported
-	OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFOMXVideoEncNode::setContextParameters(PvmiMIOSession aSession,
-                                                    PvmiCapabilityContext& aContext,
-                                                    PvmiKvp* aParameters,
-                                                    int aNumElements)
-{
-	OSCL_UNUSED_ARG(aSession);
-	OSCL_UNUSED_ARG(aContext);
-	OSCL_UNUSED_ARG(aParameters);
-	OSCL_UNUSED_ARG(aNumElements);
-	// not supported
-	OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFOMXVideoEncNode::DeleteContext(PvmiMIOSession aSession,
-                                             PvmiCapabilityContext& aContext)
-{
-	OSCL_UNUSED_ARG(aSession);
-	OSCL_UNUSED_ARG(aContext);
-	// not supported
-	OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-PVMFCommandId PVMFOMXVideoEncNode::setParametersAsync(PvmiMIOSession aSession,
-                                         PvmiKvp* aParameters,
-		                                 int aNumElements,
-		                                 PvmiKvp*& aRet_kvp,
-		                                 OsclAny* aContext)
-{
-	OSCL_UNUSED_ARG(aSession);
-	OSCL_UNUSED_ARG(aContext);
-	OSCL_UNUSED_ARG(aParameters);
-	OSCL_UNUSED_ARG(aNumElements);
-	OSCL_UNUSED_ARG(aRet_kvp);
-//	PVMFVideoEncNodeCommand cmd;
-//	cmd.PVMFMP4FFParserNodeCommand::Construct(NULL, PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS, aSession, aParameters, num_elements, aRet_kvp, context);
-//	return QueueCommandL(cmd);
-	return 0;
-}
-
-void PVMFOMXVideoEncNode::setObserver (PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    ciObserver = aObserver;
-}
-
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_port.cpp b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_port.cpp
deleted file mode 100644
index 7fe8cbd..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_port.cpp
+++ /dev/null
@@ -1,933 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_PORT_H_INCLUDED
-#include "pvmf_omx_videoenc_port.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_omx_videoenc_node_types.h"
-#endif
-#ifndef PVMF_OMX_VIDEOENC_NODE_H_INCLUDED
-#include "pvmf_omx_videoenc_node.h"
-#endif
-
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncPort::PVMFVideoEncPort(int32 aTag, PVMFOMXVideoEncNode* aNode, int32 aPriority, const char* name)
- :  PvmfPortBaseImpl(aTag, this,
-		PVMF_OMX_VIDEOENC_PORT_CAPACITY, PVMF_OMX_VIDEOENC_PORT_RESERVE, PVMF_OMX_VIDEOENC_PORT_THRESHOLD,
-		PVMF_OMX_VIDEOENC_PORT_CAPACITY, PVMF_OMX_VIDEOENC_PORT_RESERVE, PVMF_OMX_VIDEOENC_PORT_THRESHOLD, name),
-	OsclActiveObject(aPriority, "PVMFVideoEncPort"),
-	iFormat(PVMF_FORMAT_UNKNOWN),
-	iNode(aNode)
-{
-	AddToScheduler();
-	iLogger = PVLogger::GetLoggerObject("PVMFVideoEncPort");
-#if PVMF_PORT_BASE_IMPL_STATS
-	oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncPort::~PVMFVideoEncPort()
-{
-	Disconnect();
-	ClearMsgQueues();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
-{
-	if(aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-		aPtr = (PvmiCapabilityAndConfig*)this;
-	else
-		aPtr = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::Connect(PVMFPortInterface* aPort)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::Connect: aPort=0x%x", aPort));
-
-	if(!aPort)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - Connecting to invalid port"));
-		return PVMFErrArgument;
-	}
-
-	if(iConnectedPort)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - Already connected"));
-		return PVMFFailure;
-	}
-
-	PvmiCapabilityAndConfig* config = NULL;
-	aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-	if(!config)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - Peer port does not support capability interface"));
-		return PVMFFailure;
-	}
-
-	PVMFStatus status = PVMFSuccess;
-	switch(iTag)
-	{
-	case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT:
-		status = NegotiateInputSettings(config);
-		break;
-	case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-		status = NegotiateOutputSettings(config);
-		break;
-	default:
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - Invalid port tag"));
-		status = PVMFFailure;
-	}
-
-	if(status != PVMFSuccess)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - Settings negotiation failed. status=%d",status));
-		return status;
-	}
-
-	//Automatically connect the peer.
-	if (aPort->PeerConnect(this)!=PVMFSuccess)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - Peer Connect failed"));
-		return PVMFFailure;
-	}
-
-	iConnectedPort = aPort;
-
-#if PVMF_PORT_BASE_IMPL_STATS
-	// Reset statistics
-	oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-
-	PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
-	return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                  PvmiCapabilityAndConfig
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-	// Not supported
-	OSCL_UNUSED_ARG(aObserver);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::getParametersSync(PvmiMIOSession session,
-                                                             PvmiKeyType identifier,
-                                                             PvmiKvp*& parameters,
-                                                             int& num_parameter_elements,
-                                                             PvmiCapabilityContext context)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::getParametersSync"));
-	OSCL_UNUSED_ARG(session);
-	OSCL_UNUSED_ARG(context);
-
-	parameters = NULL;
-	num_parameter_elements = 0;
-	PVMFStatus status = PVMFFailure;
-
-	switch(iTag)
-	{
-	case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT:
-		return GetInputParametersSync(identifier, parameters, num_parameter_elements);
-	case PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-		return GetOutputParametersSync(identifier, parameters, num_parameter_elements);
-	default:
-		LOG_ERR((0,"PVMFVideoEncPort::getParametersSync: Error - Invalid port tag"));
-		break;
-	}
-
-	return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::releaseParameters(PvmiMIOSession session,
-                                                             PvmiKvp* parameters,
-                                                             int num_elements)
-{
-	OSCL_UNUSED_ARG(session);
-	OSCL_UNUSED_ARG(num_elements);
-
-	if(parameters)
-	{
-		iAlloc.deallocate((OsclAny*)parameters);
-		return PVMFSuccess;
-	}
-	else
-	{
-		return PVMFFailure;
-	}
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-	OSCL_UNUSED_ARG(session);
-	OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::setContextParameters(PvmiMIOSession session,
-                                                          PvmiCapabilityContext& context,
-                                                          PvmiKvp* parameters, int num_parameter_elements)
-{
-	OSCL_UNUSED_ARG(session);
-	OSCL_UNUSED_ARG(context);
-	OSCL_UNUSED_ARG(parameters);
-	OSCL_UNUSED_ARG(num_parameter_elements);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-	OSCL_UNUSED_ARG(session);
-	OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
-                                                       int num_elements, PvmiKvp*& ret_kvp)
-{
-	OSCL_UNUSED_ARG(session);
-	PVMFStatus status = PVMFSuccess;
-	ret_kvp = NULL;
-
-	for(int32 i = 0; i < num_elements; i++)
-	{
-		status = VerifyAndSetParameter(&(parameters[i]), true);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
-			ret_kvp = &(parameters[i]);
-			OSCL_LEAVE(OsclErrArgument);
-		}
-	}
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncPort::setParametersAsync(PvmiMIOSession session,
-                                                                 PvmiKvp* parameters,
-                                                                 int num_elements,
-                                                                 PvmiKvp*& ret_kvp,
-                                                                 OsclAny* context)
-{
-	OSCL_UNUSED_ARG(session);
-	OSCL_UNUSED_ARG(parameters);
-	OSCL_UNUSED_ARG(num_elements);
-	OSCL_UNUSED_ARG(ret_kvp);
-	OSCL_UNUSED_ARG(context);
-	return -1;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF uint32 PVMFVideoEncPort::getCapabilityMetric (PvmiMIOSession session)
-{
-	OSCL_UNUSED_ARG(session);
-    return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::verifyParametersSync(PvmiMIOSession session,
-												                PvmiKvp* parameters, int num_elements)
-{
-	OSCL_UNUSED_ARG(session);
-
-	PVMFStatus status = PVMFSuccess;
-	for(int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
-		status = VerifyAndSetParameter(&(parameters[i]));
-
-	return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::SetFormat(PVMFFormatType aFormat)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::SetFormat: aFormat=%d", aFormat));
-	if(!IsFormatSupported(aFormat))
-		return PVMFFailure;
-
-	iFormat = aFormat;
-	return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::ProcessIncomingMsgReady()
-{
-	if(IncomingMsgQueueSize() > 0)
-		RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::ProcessOutgoingMsgReady()
-{
-	if(OutgoingMsgQueueSize() > 0)
-		RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from PVMFPortActivityHandler
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::HandlePortActivity(const PVMFPortActivity& aActivity)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::HandlePortActivity: type=%d", aActivity.iType));
-
-	if(aActivity.iPort != this)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::HandlePortActivity: Error - Activity is not on this port"));
-		return;
-	}
-
-	switch(aActivity.iType)
-	{
-	case PVMF_PORT_ACTIVITY_CREATED:
-		//Report port created info event to the node.
-		iNode->ReportInfoEvent(PVMFInfoPortCreated,
-			(OsclAny*)aActivity.iPort);
-		break;
-
-	case PVMF_PORT_ACTIVITY_DELETED:
-		//Report port deleted info event to the node.
-		iNode->ReportInfoEvent(PVMFInfoPortDeleted,
-			(OsclAny*)aActivity.iPort);
-		break;
-
-	case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-		// Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-		if( OutgoingMsgQueueSize() == 1 &&
-		    !IsConnectedPortBusy())
-		{
-			RunIfNotReady();
-		}
-		break;
-
-	case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-		//Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-		if(IncomingMsgQueueSize() == 1 &&
-		   iNode->IsProcessIncomingMsgReady())
-		{
-			RunIfNotReady();
-		}
-		break;
-
-	case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
-		// This is handled in the input port side when IsProcessIncomingMsgReady call failed
-		break;
-
-	case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-		// Notifies the node that the output queue is ready, and the node would
-		// resume encoding incoming data
-		iNode->HandlePortActivity(aActivity);
-		break;
-
-	case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-		if(OutgoingMsgQueueSize() > 0)
-			RunIfNotReady();
-		break;
-
-	case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-		// This is handled when iNode->ProcessOutgoingMsg failed with busy
-		break;
-
-	case PVMF_PORT_ACTIVITY_CONNECT:
-	case PVMF_PORT_ACTIVITY_DISCONNECT:
-	default:
-		break;
-	}
-
-	//Holmes add
-	iNode->HandlePortActivity(aActivity);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from OsclActiveObject
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::Run()
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::Run"));
-	PVMFStatus status = PVMFSuccess;
-
-	// Process incoming messages
-	if(iTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT)
-	{
-		if(IncomingMsgQueueSize() > 0)
-		{
-			//dispatch the incoming data.
-			status = iNode->ProcessIncomingMsg(this);
-			switch(status)
-			{
-			case PVMFSuccess:
-				// Reschedule if there is more data and the node did not become busy
-				// after processing the current msg
-				if(IncomingMsgQueueSize() > 0 && iNode->IsProcessIncomingMsgReady())
-				{
-					RunIfNotReady();
-				}
-				break;
-
-			case PVMFErrBusy:
-				// Node busy. Don't schedule next data
-				break;
-
-			default:
-				LOG_ERR((0,"PVMFVideoEncPort::Run: Error - ProcessIncomingMsg failed. status=%d", status));
-				break;
-			}
-		}
-
-		if(iNode->IsFlushPending())
-		{
-			if(IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-				iNode->FlushComplete();
-		}
-	}
-
-	//Process outgoing messages
-	if(iTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-	{
-		if(OutgoingMsgQueueSize() > 0)
-		{
-			if(iNode->IsProcessOutgoingMsgReady())
-			{
-				//Send data to connected port
-				status = Send();
-				switch(status)
-				{
-				case PVMFSuccess:
-					// Reschedule if there's more data to process and connected port did not become busy
-					// after receiving the last msg
-					if(OutgoingMsgQueueSize() > 0 && iNode->IsProcessOutgoingMsgReady())
-					{
-						RunIfNotReady();
-					}
-					break;
-
-				case PVMFErrBusy:
-					// Connected port busy. Don't schedule next data
-					break;
-
-				default:
-					LOG_ERR((0, "PVMFVideoEncPort::Run: Error - Send() failed. status=%d", status));
-					iNode->ReportErrorEvent(PVMF_OMX_VIDEOENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)this);
-					break;
-				}
-
-				if(iNode->IsFlushPending())
-				{
-					if(IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-						iNode->FlushComplete();
-				}
-			}
-		}
-
-		if(iNode->IsFlushPending())
-		{
-			if(IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-				iNode->FlushComplete();
-		}
-	}
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Capabilities exchange handling routines
-////////////////////////////////////////////////////////////////////////////
-bool PVMFVideoEncPort::IsFormatSupported(PVMFFormatType aFormat)
-{
-	if(iTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT)
-	{
-		switch(aFormat)
-		{
-		case PVMF_YUV420:
-		case PVMF_YUV422:
-		case PVMF_RGB12:
-		case PVMF_RGB24:
-			return true;
-		default:
-			break;
-		}
-	}
-	else if(iTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-	{
-		switch(aFormat)
-		{
-		case PVMF_H263:
-		case PVMF_M4V:
-			return true;
-		default:
-			break;
-		}
-	}
-
-	return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                                    int& num_parameter_elements)
-{
-	if(iTag != PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT)
-		return PVMFFailure;
-
-	PVMFStatus status = PVMFSuccess;
-
-	if(pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
-	{
-		num_parameter_elements = 4;
-		status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetInputParametersSync: Error - AllocateKvp failed. status=%d",status));
-			return status;
-		}
-
-		parameters[0].value.uint32_value = PVMF_YUV420;
-		parameters[1].value.uint32_value = PVMF_YUV422;
-		parameters[2].value.uint32_value = PVMF_RGB12;
-		parameters[3].value.uint32_value = PVMF_RGB24;
-	}
-
-	return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                                     int& num_parameter_elements)
-{
-	if(iTag != PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-		return PVMFFailure;
-
-	PVMFStatus status = PVMFSuccess;
-
-	if(pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0)
-	{
-		num_parameter_elements = 2;
-		status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-		}
-		else
-		{
-			parameters[0].value.uint32_value = PVMF_H263;
-			parameters[1].value.uint32_value = PVMF_M4V;
-		}
-	}
-	else if(pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
-	{
-		num_parameter_elements = 1;
-		status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-		}
-		else
-		{
-			parameters[0].value.uint32_value = iNode->GetCodecType();
-		}
-	}
-	else if(pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
-	{
-		num_parameter_elements = 1;
-		status = AllocateKvp(parameters, VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-			return status;
-		}
-
-		uint32 width, height;
-		status = iNode->GetOutputFrameSize(0, width, height);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error -iNode->GetOutputFrameSize failed. status=%d",status));
-		}
-		else
-		{
-			parameters[0].value.uint32_value = width;
-		}
-	}
-	else if(pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
-	{
-		num_parameter_elements = 1;
-		status = AllocateKvp(parameters, VIDEO_OUTPUT_HEIGHT_CUR_VALUE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-			return status;
-		}
-		else
-		{
-			uint32 width, height;
-			status = iNode->GetOutputFrameSize(0, width, height);
-			if(status != PVMFSuccess)
-			{
-				LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - iNode->GetOutputFrameSize failed. status=%d",status));
-			}
-			else
-			{
-				parameters[0].value.uint32_value = height;
-			}
-		}
-	}
-	else if(pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
-	{
-		num_parameter_elements = 1;
-		status = AllocateKvp(parameters, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-			return status;
-		}
-		else
-		{
-			parameters[0].value.float_value = iNode->GetOutputFrameRate(0);
-		}
-	}
-	else if(pv_mime_strcmp(identifier, OUTPUT_BITRATE_CUR_QUERY) == 0)
-	{
-		num_parameter_elements = 1;
-		status = AllocateKvp(parameters, OUTPUT_BITRATE_CUR_VALUE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-			return status;
-		}
-		else
-		{
-			parameters[0].value.uint32_value = iNode->GetOutputBitRate(0);
-		}
-	}
-	else if(pv_mime_strcmp(identifier, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_QUERY) == 0)
-	{
-		num_parameter_elements = 1;
-		status = AllocateKvp(parameters, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_VALUE, num_parameter_elements);
-		if(status != PVMFSuccess)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d",status));
-			return status;
-		}
-		else
-		{
-			parameters[0].value.uint32_value = iNode->GetIFrameInterval();
-		}
-	}
-
-	return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
-{
-	LOG_STACK_TRACE((0, "PVMFVideoEncPort::AllocateKvp"));
-	uint8* buf = NULL;
-	uint32 keyLen = oscl_strlen(aKey) + 1;
-	int32 err = 0;
-
-	OSCL_TRY(err,
-		buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
-		if(!buf)
-			OSCL_LEAVE(OsclErrNoMemory);
-	);
-	OSCL_FIRST_CATCH_ANY(err,
-		LOG_ERR((0,"PVMFVideoEncPort::AllocateKvp: Error - kvp allocation failed"));
-		return PVMFErrNoMemory;
-	);
-
-	int32 i = 0;
-	PvmiKvp* curKvp = aKvp = new (buf) PvmiKvp;
-	buf += sizeof(PvmiKvp);
-	for(i = 1; i < aNumParams; i++)
-	{
-		curKvp += i;
-		curKvp = new (buf) PvmiKvp;
-		buf += sizeof(PvmiKvp);
-	}
-
-	for(i = 0; i < aNumParams; i++)
-	{
-		aKvp[i].key = (char*)buf;
-		oscl_strncpy(aKvp[i].key, aKey, keyLen);
-		buf += keyLen;
-	}
-
-	return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
-
-	if(!aKvp)
-	{
-		LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
-		return PVMFFailure;
-	}
-
-	if( pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0 &&
-	    iTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_INPUT)
-	{
-		switch(aKvp->value.uint32_value)
-		{
-		case PVMF_YUV420:
-		case PVMF_YUV422:
-		case PVMF_RGB12:
-		case PVMF_RGB24:
-			if(aSetParam)
-			{
-				iFormat = aKvp->value.uint32_value;
-				iNode->SetInputFormat(iFormat);
-			}
-			return PVMFSuccess;
-
-		default:
-			LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Input format %d not supported",
-				aKvp->value.uint32_value));
-			return PVMFFailure;
-		}
-	}
-	else if(pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0 &&
-	        iTag == PVMF_OMX_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-	{
-		switch(aKvp->value.uint32_value)
-		{
-		case PVMF_H263:
-		case PVMF_M4V:
-			if(aSetParam)
-			{
-				iFormat = aKvp->value.uint32_value;
-				iNode->SetCodecType(iFormat);
-			}
-			return PVMFSuccess;
-
-		default:
-			LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Output format %d not supported",
-				aKvp->value.uint32_value));
-			return PVMFFailure;
-		}
-	}
-
-	LOG_ERR((0,"PVMFVideoEncPort::VerifyAndSetParameter: Error - Unsupported parameter"));
-	return PVMFFailure;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::NegotiateInputSettings: aConfig=0x%x", aConfig));
-	if(!aConfig)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateInputSettings: Error - Invalid config object"));
-		return PVMFFailure;
-	}
-
-	PvmiKvp* kvp = NULL;
-	int numParams = 0;
-	int32 err = 0;
-	uint32 videoFormat;
-	// Get supported output formats from peer
-	PVMFStatus status = aConfig->getParametersSync(NULL, OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-	if(status != PVMFSuccess || numParams == 0)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateInputSettings: Error - config->getParametersSync(output_formats) failed"));
-		return status;
-	}
-
-	OsclPriorityQueue<PvmiKvp*,OsclMemAllocator,
-		Oscl_Vector<PvmiKvp*,OsclMemAllocator>,
-		PVMFVideoEncInputFormatCompareLess> sortedKvp;
-
-	// Using a priority queue, sort the kvp's returned from aConfig->getParametersSync
-	// according to the preference of this port. Formats that are not supported are
-	// not pushed to the priority queue and hence dropped from consideration.
-	for(int32 i = 0; i < numParams; i++)
-	{
-		switch(kvp[i].value.uint32_value)
-		{
-		case PVMF_YUV420:
-		case PVMF_YUV422:
-		case PVMF_RGB12:
-		case PVMF_RGB24:
-			{
-				videoFormat = kvp[i].value.uint32_value;
-				OSCL_TRY(err, sortedKvp.push(&(kvp[i])););
-				OSCL_FIRST_CATCH_ANY(err,
-					LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - sortedKvp.push failed"));
-					return PVMFErrNoMemory;
-				);
-			}
-			break;
-		default:
-			break;
-		}
-	}
-
-	if(sortedKvp.size() == 0)
-	{
-		LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - No matching supported input format"));
-		// Release parameters back to peer
-		aConfig->releaseParameters(NULL, kvp, numParams);
-		kvp = NULL;
-		numParams = 0;
-		return PVMFFailure;
-	}
-
-	PvmiKvp* selectedKvp = sortedKvp.top();
-	PvmiKvp* retKvp = NULL;
-
-	// Set format of this port, peer port and container node
-	iFormat = selectedKvp->value.uint32_value;
-	iNode->SetInputFormat(iFormat);
-	OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-	OSCL_FIRST_CATCH_ANY(err,
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateInputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-		return PVMFFailure;
-	);
-
-	// Release parameters back to peer and reset for the next query
-	aConfig->releaseParameters(NULL, kvp, numParams);
-	kvp = NULL;
-	numParams = 0;
-
-	// Get size (in pixels) of video data from peer
-	uint32 width = 0;
-	uint32 height = 0;
-	uint8 orientation = 0;
-	status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
-	if(status != PVMFSuccess || numParams != 1)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - config->getParametersSync(current width) failed"));
-		return status;
-	}
-	width = kvp[0].value.uint32_value;
-	aConfig->releaseParameters(NULL, kvp, numParams);
-	kvp = NULL;
-	numParams = 0;
-
-	status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
-	if(status != PVMFSuccess || numParams != 1)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - config->getParametersSync(current height) failed"));
-		return status;
-	}
-	height = kvp[0].value.uint32_value;
-	aConfig->releaseParameters(NULL, kvp, numParams);
-	kvp = NULL;
-	numParams = 0;
-
-	if ((PVMF_RGB12 == videoFormat) || (PVMF_RGB24 == videoFormat))
-	{
-		status = aConfig->getParametersSync(NULL, VIDEO_FRAME_ORIENTATION_CUR_QUERY, kvp, numParams, NULL);
-		if(status != PVMFSuccess || numParams != 1)
-		{
-			LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - config->getParametersSync(current height) failed"));
-			return status;
-		}
-
-		orientation = kvp[0].value.uint8_value;
-		aConfig->releaseParameters(NULL, kvp, numParams);
-		kvp = NULL;
-		numParams = 0;
-
-	}
-	// Set input frame size of container node
-	iNode->SetInputFrameSize(width, height, orientation);
-
-	// Get video frame rate from peer
-	status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY, kvp, numParams, NULL);
-	if(status != PVMFSuccess || numParams != 1)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::Connect: Error - config->getParametersSync(current frame rate) failed"));
-		return status;
-	}
-
-	// Set input frame rate of container node
-	iNode->SetInputFrameRate(kvp[0].value.float_value);
-	aConfig->releaseParameters(NULL, kvp, numParams);
-	kvp = NULL;
-	numParams = 0;
-	return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-	LOG_STACK_TRACE((0,"PVMFVideoEncPort::NegotiateOutputSettings: aConfig=0x%x", aConfig));
-	if(!aConfig)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateOutputSettings: Error - Invalid config object"));
-		return PVMFFailure;
-	}
-
-	PvmiKvp* kvp = NULL;
-	int numParams = 0;
-	int32 i = 0;
-	int32 err = 0;
-
-	// Get supported input formats from peer
-	PVMFStatus status = aConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-	if(status != PVMFSuccess || numParams == 0)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateOutputSettings: Error - config->getParametersSync(input_formats) failed"));
-		return status;
-	}
-
-	PvmiKvp* selectedKvp = NULL;
-	PvmiKvp* retKvp = NULL;
-	for(i = 0; i < numParams && !selectedKvp; i++)
-	{
-		if(kvp[i].value.uint32_value == iFormat)
-			selectedKvp = &(kvp[i]);
-	}
-
-	if(!selectedKvp)
-	{
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateOutputSettings: Error - Output format not supported by peer"));
-		return PVMFFailure;
-	}
-
-	OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-	OSCL_FIRST_CATCH_ANY(err,
-		LOG_ERR((0,"PVMFVideoEncPort::NegotiateOutputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-		return PVMFFailure;
-	);
-
-	aConfig->releaseParameters(NULL, kvp, numParams);
-	kvp = NULL;
-	numParams = 0;
-
-	return PVMFSuccess;
-}
-
-
-
-
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_port.h b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_port.h
deleted file mode 100644
index 6710698..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_port.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_PORT_H_INCLUDED
-#define PVMF_OMX_VIDEOENC_PORT_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
-#include "pvmf_port_base_impl.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
-#include "pvmi_config_and_capability_utils.h"
-#endif
-
-// Forward declaration
-class PVMFOMXVideoEncNode;
-
-class PVMFVideoEncPort : public PvmfPortBaseImpl,
-                         public PvmiCapabilityAndConfig,
-                         public PVMFPortActivityHandler,
-                         public OsclActiveObject
-{
-public:
-	PVMFVideoEncPort(int32 aTag, PVMFOMXVideoEncNode* aNode, int32 aPriority, const char* name = NULL);
-	~PVMFVideoEncPort();
-
-	// Overload PvmfPortBaseImpl methods
-	OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
-	OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
-
-
-	// Implement pure virtuals from PvmiCapabilityAndConfig interface
-	OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-	OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
-	                                           PvmiKvp*& aParameters, int& num_parameter_elements,
-	                                           PvmiCapabilityContext aContext);
-	OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-	OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-	OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-	                                        PvmiKvp* aParameters, int num_parameter_elements);
-	OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-	OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-	                                     int num_elements, PvmiKvp * & aRet_kvp);
-	OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-	                                               int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context=NULL);
-	OSCL_IMPORT_REF uint32 getCapabilityMetric (PvmiMIOSession aSession);
-	OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-
-	PVMFStatus SetFormat(PVMFFormatType aFormat);
-
-	// Notification from node to resume processing incoming msg
-	void ProcessIncomingMsgReady();
-	void ProcessOutgoingMsgReady();
-
-	// From PVMFPortActivityHandler
-	void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-	PVMFFormatType iFormat;
-
-private:
-	// Implement pure virtuals from OsclActiveObject
-	void Run();
-
-	/**
-	 * Check if a format is supported for a specific port type
-	 * @return true if specified format is supported for the specified port type
-	 */
-	bool IsFormatSupported(PVMFFormatType aFormat);
-
-	/**
-	 * Synchronous query of input port parameters
-	 */
-	PVMFStatus GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-	                                  int& num_parameter_elements);
-
-	/**
-	 * Synchronous query of output port parameters
-	 */
-	PVMFStatus GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-	                                   int& num_parameter_elements);
-	/**
-	 * Allocate a specified number of key-value pairs and set the keys
-	 *
-	 * @param aKvp Output parameter to hold the allocated key-value pairs
-	 * @param aKey Key for the allocated key-value pairs
-	 * @param aNumParams Number of key-value pairs to be allocated
-	 * @return Completion status
-	 */
-	PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
-
-	/**
-	 * Verify one key-value pair parameter against capability of the port and
-	 * if the aSetParam flag is set, set the value of the parameter corresponding to
-	 * the key.
-	 *
-	 * @param aKvp Key-value pair parameter to be verified
-	 * @param aSetParam If true, set the value of parameter corresponding to the key.
-	 * @return PVMFSuccess if parameter is supported, else PVMFFailure
-	 */
-	PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam=false);
-
-	/**
-	 * Negotiates input port settings (format, video size and frame rate) and
-	 * configures the peer port and the container node with these settings
-	 *
-	 * @param aConfig Capability and config object for peer port
-	 * @return PVMFSuccess if settings are successfully negotiated.
-	 */
-	PVMFStatus NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig);
-
-	/**
-	 * Negotiates output port settings and configures the peer port using settings
-	 * from the container node.
-	 *
-	 * @param aConfig Capability and config object for peer port
-	 * @return PVMFSuccess if settings are successfully negotiated.
-	 */
-	PVMFStatus NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig);
-
-	OsclMemAllocator iAlloc;
-	PVMFOMXVideoEncNode* iNode;
-};
-
-class PVMFVideoEncInputFormatCompareLess
-{
-public:
-	/**
-	 * The algorithm used in OsclPriorityQueue needs a compare function
-	 * that returns true when A's priority is less than B's
-	 * @return true if A's priority is less than B's, else false
-	 */
-	int compare(PvmiKvp*& a, PvmiKvp*& b) const
-	{
-		return (PVMFVideoEncInputFormatCompareLess::GetPriority(a) <
-			PVMFVideoEncInputFormatCompareLess::GetPriority(b));
-	}
-
-	/**
-	 * Returns the priority of each command
-	 * @return A 0-based priority number. A lower number indicates lower priority.
-	 */
-	static int GetPriority(PvmiKvp*& aKvp)
-	{
-		switch(aKvp->value.uint32_value)
-		{
-		case PVMF_YUV420:
-			return 3;
-		case PVMF_YUV422:
-			return 2;
-		case PVMF_RGB12:
-			return 1;
-		case PVMF_RGB24:
-			return 0;
-		default:
-			return 0;
-		}
-	}
-};
-
-#endif // PVMF_OMX_VIDEOENC_INPORT_H_INCLUDED
diff --git a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_tuneables.h b/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_tuneables.h
deleted file mode 100644
index 0e34da8..0000000
--- a/nodes/pvomxvideoencnode/src/pvmf_omx_videoenc_tuneables.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- * Copyright (C) 2008 HTC Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_OMX_VIDEOENC_TUNEABLES_H_INCLUDED
-#define PVMF_OMX_VIDEOENC_TUNEABLES_H_INCLUDED
-
-// Turn on statistics
-#define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
-
-// Default port queue reserve size
-#define PVMF_OMX_VIDEOENC_NODE_PORT_VECTOR_RESERVE 2
-#define PVMF_OMX_VIDEOENC_NODE_MAX_INPUT_PORT 1
-#define PVMF_OMX_VIDEOENC_NODE_MAX_OUTPUT_PORT 1
-#define PVMF_OMX_VIDEOENC_NODE_PORT_ACTIVITY_RESERVE 10
-
-// Default command queue reserve size
-#define PVMF_OMX_VIDEOENC_NODE_CMD_QUEUE_RESERVE 10
-
-// Starting value for command IDs
-#define PVMF_OMX_VIDEOENC_NODE_CMD_ID_START 10000
-
-#define DEFAULT_BITRATE 32000
-#define DEFAULT_FRAME_WIDTH 176
-#define DEFAULT_FRAME_HEIGHT 144
-#define DEFAULT_FRAME_RATE 5
-#define MAX_OUTBUF_SIZE 8192
-#define MAX_NUM_INPUTDATA	2
-#define MAX_NUM_OUTPUTDATA	2
-
-// This defines the minimum frame rate that will be always used in compute
-// the required buffer size by Qualcomm rate control so as to reduce the
-// chance of buffer overflow (Qualcomm encoder should prevent this from 
-// happening in the first place). This is different from DEFAULT_FRAME_RATE.
-#define MIN_FRAME_RATE_IN_FPS 5.0
-
-#define PVVIDENC_MEDIADATA_POOLNUM 8
-#define PVVIDENC_MEDIADATA_CHUNKSIZE 128
-#define PVVIDENC_MEDIABUFFER_CHUNKSIZE (MAX_OUTBUF_SIZE+128)
-
-// Port queue settings
-#define PVMF_OMX_VIDEOENC_PORT_CAPACITY 10
-#define PVMF_OMX_VIDEOENC_PORT_RESERVE 10
-#define PVMF_OMX_VIDEOENC_PORT_THRESHOLD 50
-
-
-#endif // PVMF_OMX_VIDEOENC_TUNEABLES_H_INCLUDED
diff --git a/nodes/pvprotocolenginenode/Android.mk b/nodes/pvprotocolenginenode/Android.mk
index 43aa9e3..a0d2653 100644
--- a/nodes/pvprotocolenginenode/Android.mk
+++ b/nodes/pvprotocolenginenode/Android.mk
@@ -2,47 +2,42 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvdl_config_file.cpp \
 	src/pvmf_protocol_engine_common.cpp \
-	src/pvmf_protocol_engine_download_common.cpp \
-	src/pvmf_protocol_engine_progressive_download.cpp \
-	src/pvmf_protocol_engine_node_common.cpp \
-	src/pvmf_protocol_engine_node_download_common.cpp \
-	src/pvmf_protocol_engine_node_progressive_download.cpp \
-	src/pvmf_protocol_engine_node_progressive_streaming.cpp \
-	src/pvmf_protocol_engine_factory.cpp \
-	src/pvmf_protocol_engine_port.cpp
-
+ 	src/pvmf_protocol_engine_node_common.cpp \
+ 	src/pvmf_protocol_engine_factory.cpp \
+ 	src/pvmf_protocol_engine_port.cpp \
+ 	src/pvdl_config_file.cpp \
+ 	src/pvmf_protocol_engine_download_common.cpp \
+ 	src/pvmf_protocol_engine_node_download_common.cpp \
+ 	src/pvmf_protocol_engine_node_progressive_streaming.cpp \
+ 	src/pvmf_protocol_engine_progressive_download.cpp \
+ 	src/pvmf_protocol_engine_node_progressive_download.cpp
 
 
 LOCAL_MODULE := libprotocolenginenode
 
-LOCAL_CFLAGS := -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_DOWNLOAD_ENABLED -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_STREAMING_ENABLED  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_STREAMING_ENABLED -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_DOWNLOAD_ENABLED $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvprotocolenginenode/include \
-	$(PV_TOP)//nodes/pvprotocolenginenode/src \
-	$(PV_TOP)/protocols/http_paracom/include \
-	$(PV_TOP)/nodes/common/include \
-	$(PV_TOP)/baselibs/pv_mime_utils/src \
-	$(PV_TOP)/protocols/sdp/common/include \
-	$(PV_TOP)/protocols/sdp/parser/include \
-	$(PV_TOP)/baselibs/gen_data_structures/src \
-	$(PV_TOP)/baselibs/media_data_structures/src \
-	$(PV_TOP)/fileformats/pvx/parser/include \
-	$(PV_TOP)//nodes/pvprotocolenginenode/config/$(BUILD_ARCH) \
-	$(PV_TOP)//nodes/pvprotocolenginenode/config/linux \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvprotocolenginenode/src \
+ 	$(PV_TOP)/nodes/pvprotocolenginenode/include \
+ 	$(PV_TOP)/nodes/pvprotocolenginenode/config/linux_nj \
+ 	$(PV_TOP)/nodes/pvprotocolenginenode/config/linux \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_protocol_engine_factory.h \
-	include/pvmf_protocol_engine_defs.h \
-	include/pvmf_protocol_engine_node_extension.h \
-	include/pvmf_protocol_engine_command_format_ids.h \
-	include/pvmf_protocol_engine_node_events.h
+ 	include/pvmf_protocol_engine_defs.h \
+ 	include/pvmf_protocol_engine_node_extension.h \
+ 	include/pvmf_protocol_engine_command_format_ids.h \
+ 	include/pvmf_protocol_engine_node_events.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvprotocolenginenode/build/make/makefile b/nodes/pvprotocolenginenode/build/make/makefile
deleted file mode 100644
index 2040429..0000000
--- a/nodes/pvprotocolenginenode/build/make/makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = protocolenginenode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-XCPPFLAGS += -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_DOWNLOAD_ENABLED -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_STREAMING_ENABLED 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I $(VOB_BASE_DIR)/protocols/http_paracom/include -I $(VOB_BASE_DIR)/nodes/common/include -I $(VOB_BASE_DIR)/baselibs/pv_mime_utils/src -I $(VOB_BASE_DIR)/protocols/sdp/common/include -I $(VOB_BASE_DIR)/protocols/sdp/parser/include -I $(VOB_BASE_DIR)/baselibs/gen_data_structures/src -I $(VOB_BASE_DIR)/baselibs/media_data_structures/src -I $(VOB_BASE_DIR)/fileformats/pvx/parser/include
-XINCDIRS += -I ../../config/$(BUILD_ARCH) -I ../../config/linux
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = 	pvdl_config_file.cpp \
-	pvmf_protocol_engine_common.cpp \
-	pvmf_protocol_engine_download_common.cpp \
-	pvmf_protocol_engine_progressive_download.cpp \
-	pvmf_protocol_engine_node_common.cpp \
-	pvmf_protocol_engine_node_download_common.cpp \
-	pvmf_protocol_engine_node_progressive_download.cpp \
-	pvmf_protocol_engine_node_progressive_streaming.cpp \
-	pvmf_protocol_engine_factory.cpp \
-	pvmf_protocol_engine_port.cpp
-	
-
-HDRS =  pvmf_protocol_engine_factory.h \
-	pvmf_protocol_engine_defs.h \
-	pvmf_protocol_engine_node_extension.h \
-	pvmf_protocol_engine_command_format_ids.h \
-	pvmf_protocol_engine_node_events.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvprotocolenginenode/build/make_segments/local.mk b/nodes/pvprotocolenginenode/build/make_segments/local.mk
new file mode 100644
index 0000000..319dd7f
--- /dev/null
+++ b/nodes/pvprotocolenginenode/build/make_segments/local.mk
@@ -0,0 +1,36 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := protocolenginenode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../config/$(BUILD_ARCH) ../../config/linux
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_protocol_engine_common.cpp \
+	pvmf_protocol_engine_node_common.cpp \
+	pvmf_protocol_engine_factory.cpp \
+	pvmf_protocol_engine_port.cpp \
+
+HDRS := pvmf_protocol_engine_factory.h \
+	pvmf_protocol_engine_defs.h \
+	pvmf_protocol_engine_node_extension.h \
+	pvmf_protocol_engine_command_format_ids.h \
+	pvmf_protocol_engine_node_events.h
+
+
+# include $(call process_include_list,$(LOCAL_PATH),$(PROTOCOL_PLUGINS))
+
+include $(MK)/library.mk
diff --git a/nodes/pvprotocolenginenode/build/make_segments/pe_dl_common.mk b/nodes/pvprotocolenginenode/build/make_segments/pe_dl_common.mk
new file mode 100644
index 0000000..c330b72
--- /dev/null
+++ b/nodes/pvprotocolenginenode/build/make_segments/pe_dl_common.mk
@@ -0,0 +1,8 @@
+
+# Makefile segment for download common
+#
+
+SRCS += pvdl_config_file.cpp \
+	pvmf_protocol_engine_download_common.cpp \
+	pvmf_protocol_engine_node_download_common.cpp 
+	
diff --git a/nodes/pvprotocolenginenode/build/make_segments/pe_pdl.mk b/nodes/pvprotocolenginenode/build/make_segments/pe_pdl.mk
new file mode 100644
index 0000000..abe6d4c
--- /dev/null
+++ b/nodes/pvprotocolenginenode/build/make_segments/pe_pdl.mk
@@ -0,0 +1,8 @@
+
+# Makefile segment for PDL
+#
+
+XCPPFLAGS += -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_DOWNLOAD_ENABLED 
+
+SRCS += pvmf_protocol_engine_progressive_download.cpp \
+	pvmf_protocol_engine_node_progressive_download.cpp
diff --git a/nodes/pvprotocolenginenode/build/make_segments/pe_ps.mk b/nodes/pvprotocolenginenode/build/make_segments/pe_ps.mk
new file mode 100644
index 0000000..fc6e8eb
--- /dev/null
+++ b/nodes/pvprotocolenginenode/build/make_segments/pe_ps.mk
@@ -0,0 +1,7 @@
+
+# Makefile segment for PS
+#
+
+XCPPFLAGS += -DPV_PROTOCOL_ENGINE_NODE_PROGRESSIVE_STREAMING_ENABLED
+
+SRCS += pvmf_protocol_engine_node_progressive_streaming.cpp
diff --git a/nodes/pvprotocolenginenode/config/linux/pvmf_protocolengine_node_tunables.h b/nodes/pvprotocolenginenode/config/linux/pvmf_protocolengine_node_tunables.h
index 7939397..9689c65 100644
--- a/nodes/pvprotocolenginenode/config/linux/pvmf_protocolengine_node_tunables.h
+++ b/nodes/pvprotocolenginenode/config/linux/pvmf_protocolengine_node_tunables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,11 +18,7 @@
 #ifndef PVMF_PROTOCOL_ENGINE_NODE_TUNABLES_H_INCLUDED
 #define PVMF_PROTOCOL_ENGINE_NODE_TUNABLES_H_INCLUDED
 
-#ifndef PV_PLAYER_SDKINFO_H_INCLUDED
-#include "../../../engines/player/src/pv_player_sdkinfo.h"
-#endif
-
-#define PDL_HTTP_USER_AGENT			_STRLIT_CHAR(PVPLAYER_ENGINE_SDKINFO_LABEL)
+#define PDL_HTTP_USER_AGENT			_STRLIT_CHAR("PVPLAYER 04.07.00.01")
 #define PDL_HTTP_VERSION_NUMBER		0 // 0 => Http Version1.0 ; 1 => Http Version1.1
 
 // macros for memory pool
@@ -38,6 +34,8 @@
 #define DEFAULT_MAX_SERVER_RESPONSE_DURATION_IN_SEC 60
 #define DEFAULT_KEEPALIVE_TIMEOUT_IN_SEC 60
 #define DEFAULT_MAX_SERVER_RESPONSE_DURATION_IN_SEC_FOR_STOPEOS_LOGGING 4
+#define DEFAULT_WALLCLOCK_TIMEOUT_IN_SEC 2
+#define DEFAULT_BUFFER_STATUS_CLOCK_TIMEOUT_IN_SEC 2
 #define DEFAULT_TIMER_VECTOR_RESERVE_NUMBER 8
 #define PVPROTOCOLENGINENODE_TIMER_FREQUENCY 1 // 1 means 1 sec, 1000 means 1msec
 
@@ -47,7 +45,7 @@
 #define BITMASK_HTTPHEAD 4
 
 // macros for user-agent
-#define DEFAULT_DL_USER_AGNET			_STRLIT_CHAR(PVPLAYER_ENGINE_SDKINFO_LABEL)
+#define DEFAULT_DL_USER_AGNET			_STRLIT_CHAR("PVPlayer/4.0 (Beta release)")
 #define DEFAULT_MS_STREAMING_USER_AGENT _STRLIT_CHAR("NSPlayer/10.0.0.3646")
 
 // marcos for download algorithm pre-condition checks
@@ -80,7 +78,7 @@
 #define PROTOCOLENGINENODE_SPACE_ASCIICODE 0x20
 #define BUFFER_SIZE_FOR_ZERO_OUT_DATA_STREAM_OBJECT 10240
 #ifndef EVENT_HANDLER_TOTAL
-#define EVENT_HANDLER_TOTAL 8
+#define EVENT_HANDLER_TOTAL 9
 #endif
 
 #endif // PVMF_PROTOCOL_ENGINE_NODE_TUNABLES_H_INCLUDED
diff --git a/nodes/pvprotocolenginenode/config/linux_nj/pvmf_protocolengine_node_tunables.h b/nodes/pvprotocolenginenode/config/linux_nj/pvmf_protocolengine_node_tunables.h
new file mode 100644
index 0000000..9689c65
--- /dev/null
+++ b/nodes/pvprotocolenginenode/config/linux_nj/pvmf_protocolengine_node_tunables.h
@@ -0,0 +1,85 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_PROTOCOL_ENGINE_NODE_TUNABLES_H_INCLUDED
+#define PVMF_PROTOCOL_ENGINE_NODE_TUNABLES_H_INCLUDED
+
+#define PDL_HTTP_USER_AGENT			_STRLIT_CHAR("PVPLAYER 04.07.00.01")
+#define PDL_HTTP_VERSION_NUMBER		0 // 0 => Http Version1.0 ; 1 => Http Version1.1
+
+// macros for memory pool
+#define PVHTTPDOWNLOADOUTPUT_CONTENTDATA_POOLNUM 16
+#define PVHTTPSTREAMINGOUTPUT_CONTENTDATA_POOLNUM 1024
+#define PVHTTPDOWNLOADOUTPUT_MEDIADATA_CHUNKSIZE 128
+#ifndef PVHTTPDOWNLOADOUTPUT_CONTENTDATA_CHUNKSIZE
+#define PVHTTPDOWNLOADOUTPUT_CONTENTDATA_CHUNKSIZE 8000
+#endif
+
+// macros for timer
+#define DEFAULT_MAX_SERVER_INACTIVITY_DURATION_IN_SEC 60
+#define DEFAULT_MAX_SERVER_RESPONSE_DURATION_IN_SEC 60
+#define DEFAULT_KEEPALIVE_TIMEOUT_IN_SEC 60
+#define DEFAULT_MAX_SERVER_RESPONSE_DURATION_IN_SEC_FOR_STOPEOS_LOGGING 4
+#define DEFAULT_WALLCLOCK_TIMEOUT_IN_SEC 2
+#define DEFAULT_BUFFER_STATUS_CLOCK_TIMEOUT_IN_SEC 2
+#define DEFAULT_TIMER_VECTOR_RESERVE_NUMBER 8
+#define PVPROTOCOLENGINENODE_TIMER_FREQUENCY 1 // 1 means 1 sec, 1000 means 1msec
+
+// bitmask for http method for extension header
+#define BITMASK_HTTPGET 1
+#define BITMASK_HTTPPOST 2
+#define BITMASK_HTTPHEAD 4
+
+// macros for user-agent
+#define DEFAULT_DL_USER_AGNET			_STRLIT_CHAR("PVPlayer/4.0 (Beta release)")
+#define DEFAULT_MS_STREAMING_USER_AGENT _STRLIT_CHAR("NSPlayer/10.0.0.3646")
+
+// marcos for download algorithm pre-condition checks
+#define PVPROTOCOLENGINE_INIT_DOWNLOAD_TIME_THRESHOLD  1000 // 1000msec
+#define PVPROTOCOLENGINE_INIT_DOWNLOAD_SIZE_PERCENTAGE_THRESHOLD  10 // 10% of file size
+#define PVPROTOCOLENGINE_INIT_DOWNLOAD_SIZE_THRESHOLD  4096 // 4Kbytes
+#define PVPROTOCOLENGINE_INIT_DOWNLOAD_TIME_THRESHOLD_WITH_CLIPBITRATE  10 // 10sec
+#define PVPROTOCOLENGINE_JITTER_BUFFER_SIZE_BYTES  10240 // 10Kbytes
+#define PVPROTOCOLENGINE_JITTER_BUFFER_SIZE_TIME   4	// 4sec worth of data
+#define PVPROTOCOLENGINE_JITTER_BUFFER_SIZE_DLPERCENTAGE   15	// 15% of file size
+
+// marcos for the fixed-point calculation in auto-resume decision
+#define PVPROTOCOLENGINE_AUTO_RESUME_FIXED_CALCULATION_MAX_LIMIT_RIGHT_SHIFT_FACTOR  16 // 2^16=65536
+#define PVPROTOCOLENGINE_AUTO_RESUME_FIXED_CALCULATION_RIGHT_SHIFT 10
+
+// macros for download byte percentage calculation: downloadSize*100/fileSize
+#define PVPROTOCOLENGINE_DOWNLOAD_BYTE_PERCENTAGE_CONVERTION_100 100 // 100
+#define PVPROTOCOLENGINE_DOWNLOAD_BYTE_PERCENTAGE_DLSIZE_LIMIT_RIGHT_SHIFT_FACTOR   25 //2^25 =33554432 // 33554432 = 2^32 / 2^7 = 2^25
+#define PVPROTOCOLENGINE_DOWNLOAD_BYTE_PERCENTAGE_DLSIZE_RIGHTSHIFT_FACTOR 7 // right shift 7 bits, 2^7 > 100
+#define PVPROTOCOLENGINE_MINIMAL_BUFFERING_TIME_FOR_FASTTRACK  7000		// 7000msec
+
+// macros for duration calcuation: fileSize*1000/playback rate
+#define PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_LIMIT_RIGHT_SHIFT_FACTOR   22 //2^21 =4194304 
+#define PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR 10 // right shift 7 bits, 2^7 > 100
+
+
+
+// macros for misc stuff
+#define PVPROTOCOLENGINE_RESERVED_NUMBER_OF_FRAMES 4
+#define PROTOCOLENGINENODE_SPACE_ASCIICODE 0x20
+#define BUFFER_SIZE_FOR_ZERO_OUT_DATA_STREAM_OBJECT 10240
+#ifndef EVENT_HANDLER_TOTAL
+#define EVENT_HANDLER_TOTAL 9
+#endif
+
+#endif // PVMF_PROTOCOL_ENGINE_NODE_TUNABLES_H_INCLUDED
+
diff --git a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_command_format_ids.h b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_command_format_ids.h
index 995b8f1..b4afabb 100644
--- a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_command_format_ids.h
+++ b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_command_format_ids.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_defs.h b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_defs.h
index 03b3b96..c79bdae 100644
--- a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_defs.h
+++ b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_factory.h b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_factory.h
index 17e6771..0172b02 100644
--- a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_factory.h
+++ b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_events.h b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_events.h
index d16cb31..f009eab 100644
--- a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_events.h
+++ b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -93,6 +93,7 @@
     // some processing errors, especially for pending commands with failure, within the range [200, 299], which is not HTTP status error code range
     PVProtocolEngineNodeErrorNotHTTPErrorStart									 = PVProtocolEngineNodeErrorEventStart + 200,
     PVProtocolEngineNodeErrorProcessingFailure									 = PVProtocolEngineNodeErrorNotHTTPErrorStart + 90, // 1314
+    PVProtocolEngineNodeErrorProcessingFailure_MaximumSizeLimitation			 = PVProtocolEngineNodeErrorProcessingFailure - 19, // 1295
     PVProtocolEngineNodeErrorProcessingFailure_ContentLengthNotMatch			 = PVProtocolEngineNodeErrorProcessingFailure - 16, // 1298
     PVProtocolEngineNodeErrorProcessingFailure_TimeoutServerInactivity		     = PVProtocolEngineNodeErrorProcessingFailure - 15, // 1299
     PVProtocolEngineNodeErrorProcessingFailure_TimeoutServerNoResponce			 = PVProtocolEngineNodeErrorProcessingFailure - 14, // 1300
@@ -114,6 +115,9 @@
     PVProtocolEngineNodeErrorHTTPRedirect_NotValidUrl						= PVProtocolEngineNodeErrorProcessingFailure + 1,	// 1315
     PVProtocolEngineNodeErrorHTTPRedirect_TrialsExceedLimit,																// 1316
     PVProtocolEngineNodeErrorHTTPErrorCode401_InvalidRealm,																	// 1317
+    PVProtocolEngineNodeErrorHTTPErrorCode401_UnsupportedAuthenticationType,												// 1318
+    PVProtocolEngineNodeErrorHTTPErrorCode401_NoAuthenticationHeader,														// 1319
+
 
     PVProtocolEngineNodeErrorNotHTTPErrorEnd								= PVProtocolEngineNodeErrorEventStart + 299,
 
diff --git a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_extension.h b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_extension.h
index 79b35b5..e6cb05f 100644
--- a/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_extension.h
+++ b/nodes/pvprotocolenginenode/include/pvmf_protocol_engine_node_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -89,7 +89,7 @@
         virtual PVMFStatus GetHTTPHeader(uint8*& aHeader, uint32& aHeaderLen) = 0;
 
         /**
-         * Retrieves the file size. The file size is retrived from http header
+         * Retrieves the file size. The file size is retrieved from http header
          * But server might not announce the file size info. In this case, file size
          * is not available, and set to zero.
          * @param aFileSize returned download file size.
@@ -100,7 +100,7 @@
          * Retrieves the host name and port number for socket node port request
          * set up by download manager node
          *
-         * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvs.pv.com;remote_port=554"
+         * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
          * @return true if config info is provided, else false.
          * Note that this extension interface must be called AFTER data source
          * initialization interface (url is provided) gets called, otherwise it would fail
@@ -248,7 +248,7 @@
     public:
 
         /**
-         * Retrieves the ASF header. The ASF header can be retrived in fragments
+         * Retrieves the ASF header. The ASF header can be retrieved in fragments
          *
          * @param aHeader a vector of fragments
          * @param aHeaderLen length of header data.
@@ -269,7 +269,7 @@
          * Retrieves the host name and port number for socket node port request
          * set up by streaming manager node
          *
-         * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvs.pv.com;remote_port=554"
+         * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
          * @return true if config info is provided, else false.
          * Note that this extension interface must be called AFTER data source
          * initialization interface (url is provided) gets called, otherwise it would fail
@@ -280,7 +280,7 @@
          * Retrieves the host name and port number for socket node port request, based on logging URL
          * set up by streaming manager node
          *
-         * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvs.pv.com;remote_port=554"
+         * @param aPortConfig string of IP/DNS address + port number, like "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
          * @return true if config info is provided, else false.
          * Note that this extension interface must be called AFTER data source
          * initialization interface (url is provided) gets called, otherwise it would fail
@@ -423,6 +423,19 @@
          */
         virtual void SetAccelDuration(const uint32 aAccelDuration) = 0;
 
+        /**
+         * Set number of buffers to be allocated for media data pool
+         * @param aVal, the number calculated by SM node
+         * @return void
+         */
+        virtual void SetNumBuffersInMediaDataPoolSMCalc(uint32 aVal) = 0;
+
+        /**
+         * Set the max http stremaing size.
+         * @param aMaxHttpStreamingSize
+         */
+        virtual void SetMaxHttpStreamingSize(const uint32 aMaxHttpStreamingSize) = 0;
+
 };
 
 #endif // PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
diff --git a/nodes/pvprotocolenginenode/src/pvdl_config_file.cpp b/nodes/pvprotocolenginenode/src/pvdl_config_file.cpp
index a6e8061..243344e 100644
--- a/nodes/pvprotocolenginenode/src/pvdl_config_file.cpp
+++ b/nodes/pvprotocolenginenode/src/pvdl_config_file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -367,6 +367,7 @@
 
         //the file size after it is completly downloaded.
         iOverallFileSize = *tmpPtr++;
+        //for FastTrack, this would be the accumulated bytes downloaded
         iCurrentFileSize = *tmpPtr++;
         if (iOverallFileSize == 0 ||
                 iMaxAllowedFileSize < iOverallFileSize ||
@@ -381,6 +382,7 @@
         iSendTimeout = *tmpPtr++;
         iRecvTimeout = *tmpPtr++;
 
+        //FastTrack only
         iRangeStartTime = *tmpPtr++; //in ms
         uint32 aSelectedTrackIDsSize = *tmpPtr++;
 
@@ -574,6 +576,7 @@
     *tmpPtr++ = 	iMaxAllowedFileSize;
     //the file size after it is completly downloaded.
     *tmpPtr++ = 	iOverallFileSize;
+    //for FastTrack, this would be the accumulated bytes downloaded
     *tmpPtr++ = 	iCurrentFileSize;
     // flag of whether to have content length for the previous download
     *tmpPtr++ =		iHasContentLength;
@@ -582,6 +585,7 @@
     *tmpPtr++ = 	iSendTimeout;
     *tmpPtr++ = 	iRecvTimeout;
 
+    //FastTrack only
     *tmpPtr++ = 	iRangeStartTime; //in ms
     *tmpPtr++ = 	iSelectedTrackIDs.size();
 
diff --git a/nodes/pvprotocolenginenode/src/pvdl_config_file.h b/nodes/pvprotocolenginenode/src/pvdl_config_file.h
index 4b83287..00351cb 100644
--- a/nodes/pvprotocolenginenode/src/pvdl_config_file.h
+++ b/nodes/pvprotocolenginenode/src/pvdl_config_file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,8 +48,8 @@
             LoadConfigStatus_NonCriticalError = -2 // read failure, url mismatch, headers unavailable
         };
 
-        PVDlCfgFile();
-        virtual ~PVDlCfgFile();
+        OSCL_IMPORT_REF PVDlCfgFile();
+        OSCL_IMPORT_REF virtual ~PVDlCfgFile();
 
         OSCL_IMPORT_REF void SetConfigFileName(OSCL_wString &aFileName)
         {
@@ -276,9 +276,9 @@
         {
             return bIsNewSession;
         };
-        void SetNewSession()
+        void SetNewSession(const bool aNewSession = true)
         {
-            bIsNewSession = true;
+            bIsNewSession = aNewSession;
         }
 
         bool HasContentLength() const
@@ -365,6 +365,7 @@
         uint32 iMaxAllowedFileSize;
         //the file size after it is completly downloaded.
         uint32	iOverallFileSize;
+        //for FastTrack, this would be the accumulated bytes downloaded
         uint32	iCurrentFileSize;
         //flag of whether to have content length for the previous download
         // boolean variable, but intentionally choose uint32 instead of bool, for consistency with other variables
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.cpp
index f0832e9..c4953f2 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,8 +22,6 @@
 #define LOGINFODATAPATH(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m);
 #define PVMF_PROTOCOL_ENGINE_LOGINFODATAPATH(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iDataPathLogger,PVLOGMSG_INFO,m);
 #define PVMF_PROTOCOL_ENGINE_LOGERRINFODATAPATH(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iDataPathErrLogger,PVLOGMSG_INFO,m);
-#define PROTOCOLENGINE_REDIRECT_STATUS_CODE_START	300
-#define PROTOCOLENGINE_REDIRECT_STATUS_CODE_END		399
 
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -113,15 +111,15 @@
     typedef char mbchar;
     mbchar* aUrl = tmpUrl8.get_str();
 
-    mbchar *server_ip_ptr = oscl_strstr(((mbchar*)aUrl), "//");
+    mbchar *server_ip_ptr = OSCL_CONST_CAST(mbchar*, oscl_strstr(((mbchar*)aUrl), "//"));
     if (server_ip_ptr == NULL) return false;
     server_ip_ptr += 2;
 
     /* Locate the IP address. */
-    mbchar *server_port_ptr = oscl_strstr(server_ip_ptr, ":");
+    mbchar *server_port_ptr = OSCL_CONST_CAST(mbchar*, oscl_strstr(server_ip_ptr, ":"));
     mbchar *tmp_ptr = server_port_ptr;
     if (tmp_ptr == NULL) tmp_ptr = server_ip_ptr;
-    mbchar *clip_name = oscl_strstr(tmp_ptr, "/");
+    mbchar *clip_name = OSCL_CONST_CAST(mbchar*, oscl_strstr(tmp_ptr, "/"));
     if (clip_name != NULL) *clip_name++ = '\0';
 
     /* Locate the port number if provided. */
@@ -135,7 +133,7 @@
     }
 
     /* relocate the server IP address, either stop at ':' or '/' */
-    mbchar *server_end_ptr = oscl_strstr(server_ip_ptr, "/");
+    mbchar *server_end_ptr = OSCL_CONST_CAST(mbchar*, oscl_strstr(server_ip_ptr, "/"));
     if (server_end_ptr) *server_end_ptr = '\0';
 
     OSCL_HeapString<OsclMemAllocator> tmpServerName(server_ip_ptr, oscl_strlen(server_ip_ptr));
@@ -178,8 +176,11 @@
 
             // save output data if there is
             iOutputQueue->clear();
-            uint32 size = saveOutputData(entityUnit, *iOutputQueue);
-            if (size == 0xFFFFFFFF) return PARSE_GENERAL_ERROR;
+            uint32 size = 0;
+            if (!saveOutputData(entityUnit, *iOutputQueue, size))
+            {
+                return PARSE_GENERAL_ERROR;
+            }
 
             if (parsingStatus == HTTPParser::PARSE_HEADER_AVAILABLE)
             {
@@ -237,7 +238,7 @@
     if (!iInput.getValidMediaData(aDataInQueue, aMediaData, isEOS)) return PARSE_NO_INPUT_DATA;
     if (isEOS)
     {
-        if (!isRedirectResponse)
+        if (!isRedirectResponse())
         {
             iNumEOSMessagesAfterRequest++;
             iTotalDLSizeForPrevEOS = iTotalDLSizeAtCurrEOS;
@@ -288,7 +289,6 @@
 
     // Has Sever header
     char *ptr = (char*)serverValue.c_str();
-
     for (int32 i = 0; i < serverValue.length(); i++)
     {
         if (!PE_isDigit(*ptr))
@@ -305,25 +305,24 @@
     }
 }
 
-uint32 HttpParsingBasicObject::saveOutputData(RefCountHTTPEntityUnit &entityUnit, OUTPUT_DATA_QUEUE &aOutputData)
+bool HttpParsingBasicObject::saveOutputData(RefCountHTTPEntityUnit &entityUnit, OUTPUT_DATA_QUEUE &aOutputData, uint32 &aTotalEntityDataSize)
 {
-    uint32 size = 0;
-    for (uint32 i = 0; i < entityUnit.getEntityUnit().getNumFragments();i++)
-    {
-        OsclRefCounterMemFrag memfrag;
-        entityUnit.getEntityUnit().getMemFrag(i, memfrag);
-        int32 err = 0;
-        OSCL_TRY(err, aOutputData.push_back(memfrag););
-        if (err) return 0xFFFFFFFF;
-        size += memfrag.getMemFragSize();
+    aTotalEntityDataSize = 0;
+    int32 err = 0;
+    OSCL_TRY(err,
+             for (uint32 i = 0; i < entityUnit.getEntityUnit().getNumFragments();i++)
+{
+    OsclRefCounterMemFrag memfrag;
+    entityUnit.getEntityUnit().getMemFrag(i, memfrag);
+        aOutputData.push_back(memfrag);
+        aTotalEntityDataSize += memfrag.getMemFragSize();
     }
-    return size;
+            );
+    return (err == 0);
 }
 
 int32 HttpParsingBasicObject::checkParsingDone(const int32 parsingStatus)
 {
-    isRedirectResponse = false;
-
     // check error case
     if (parsingStatus < 0)
     {
@@ -332,16 +331,6 @@
         if (parsingStatus == HTTPParser::PARSE_TRANSFER_ENCODING_NOT_SUPPORTED) return PARSE_TRANSFER_ENCODING_NOT_SUPPORTED;
         return PARSE_GENERAL_ERROR; // error happens;
     }
-    if (parsingStatus == HTTPParser::PARSE_STATUS_LINE_SHOW_NOT_SUCCESSFUL)
-    {
-        // TBD, probably polulate the error codes
-        uint32 httpStatusCode = getStatusCode();
-        if (PROTOCOLENGINE_REDIRECT_STATUS_CODE_START <= httpStatusCode && httpStatusCode <= PROTOCOLENGINE_REDIRECT_STATUS_CODE_END)
-        {
-            isRedirectResponse = true;
-        }
-        return PARSE_STATUS_LINE_SHOW_NOT_SUCCESSFUL; // status code >= 300
-    }
 
     if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_MESSAGE ||
             parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA ||
@@ -358,15 +347,28 @@
             if (status == PROCESS_SUCCESS_END_OF_MESSAGE_TRUNCATED) return status;
         }
     }
-    if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_MESSAGE)	return PARSE_SUCCESS_END_OF_MESSAGE;
-    if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA)	return PARSE_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA;
-    if (parsingStatus == HTTPParser::PARSE_NEED_MORE_DATA)			return PARSE_NEED_MORE_DATA;
-    if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_INPUT)		return PARSE_SUCCESS_END_OF_INPUT;
+    if (parsingStatus == HTTPParser::PARSE_STATUS_LINE_SHOW_NOT_SUCCESSFUL)		  return PARSE_STATUS_LINE_SHOW_NOT_SUCCESSFUL; // status code >= 300
+    if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_MESSAGE)				  return PARSE_SUCCESS_END_OF_MESSAGE;
+    if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA) return PARSE_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA;
+    if (parsingStatus == HTTPParser::PARSE_NEED_MORE_DATA)						  return PARSE_NEED_MORE_DATA;
+    if (parsingStatus == HTTPParser::PARSE_SUCCESS_END_OF_INPUT)					  return PARSE_SUCCESS_END_OF_INPUT;
 
     // HTTPParser::PARSE_SUCCESS or HTTPParser::PARSE_HEADER_AVAILABLE
     return PARSE_SUCCESS;
 }
 
+bool HttpParsingBasicObject::isRedirectResponse()
+{
+    bool aPartOfRedirectResponse = false;
+    uint32 httpStatusCode = getStatusCode();
+    if (PROTOCOLENGINE_REDIRECT_STATUS_CODE_START <= httpStatusCode && httpStatusCode <= PROTOCOLENGINE_REDIRECT_STATUS_CODE_END)
+    {
+        aPartOfRedirectResponse = true;
+    }
+    return aPartOfRedirectResponse;
+}
+
+
 // factory method
 HttpParsingBasicObject* HttpParsingBasicObject::create()
 {
@@ -436,49 +438,99 @@
     return false;
 }
 
+bool HttpParsingBasicObject::isServerSupportBasicAuthentication()
+{
+    StrCSumPtrLen aAuthenKey = "WWW-Authenticate";
+    uint32 numFieldsByKey = iParser->getNumberOfFieldsByKey(aAuthenKey);
+    uint32 i = 0;
+    for (i = 0; i < numFieldsByKey; i++)
+    {
+        StrPtrLen aAuthenValue;
+        iParser->getField(aAuthenKey, aAuthenValue, i);
+        const char *ptrRealm = aAuthenValue.c_str();
+        uint32 len = aAuthenValue.length();
+        uint32 length = 0;
+
+        getRealmPtr(ptrRealm, len, length);
+        getBasicPtr(aAuthenValue, length);
+        if (length >= 6) return true;
+    }
+    return false;
+}
+
 bool HttpParsingBasicObject::getAuthenInfo(OSCL_String &aRealm)
 {
     StrCSumPtrLen aAuthenKey = "WWW-Authenticate";
+    uint32 numFieldsByKey = iParser->getNumberOfFieldsByKey(aAuthenKey);
+    uint32 i = 0;
+    for (i = 0; i < numFieldsByKey; i++)
+    {
+        StrPtrLen aAuthenValue;
+        iParser->getField(aAuthenKey, aAuthenValue, i);
+        const char *ptrRealm = aAuthenValue.c_str();
+        uint32 len = aAuthenValue.length();
+        uint32 length = 0;
+
+        getRealmPtr(ptrRealm, len, length);
+        if (len < 6) continue;
+
+        getBasicPtr(aAuthenValue, length);
+        if (length < 6) continue;
+
+        ptrRealm += 6;
+        len -= 6;
+        aRealm = OSCL_HeapString<OsclMemAllocator> (ptrRealm, len);
+        return true;
+    }
+    return false;
+}
+
+void HttpParsingBasicObject::getRealmPtr(const char *&ptrRealm, uint32 &len, uint32 &length)
+{
+    while (!(((ptrRealm[0]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'r') &&
+             ((ptrRealm[1]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'e') &&
+             ((ptrRealm[2]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'a') &&
+             ((ptrRealm[3]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'l') &&
+             ((ptrRealm[4]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'm') &&
+             ((ptrRealm[5]  | OSCL_ASCII_CASE_MAGIC_BIT) == '=')) &&
+            len >= 6)
+    {
+        ptrRealm++;
+        len--;
+        length++;
+    }
+}
+
+void HttpParsingBasicObject::getBasicPtr(const StrPtrLen aAuthenValue, uint32 &length)
+{
+    const char *ptrBasic = aAuthenValue.c_str();
+    while (!(((ptrBasic[0]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'b') &&
+             ((ptrBasic[1]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'a') &&
+             ((ptrBasic[2]  | OSCL_ASCII_CASE_MAGIC_BIT) == 's') &&
+             ((ptrBasic[3]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'i') &&
+             ((ptrBasic[4]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'c') &&
+             ((ptrBasic[5]  | OSCL_ASCII_CASE_MAGIC_BIT) == ' ')) &&
+            length >= 6)
+    {
+        ptrBasic++;
+        length--;
+    }
+}
+
+bool HttpParsingBasicObject::isServerSendAuthenticationHeader()
+{
+    StrCSumPtrLen aAuthenKey = "WWW-Authenticate";
     StrPtrLen aAuthenValue;
     if (iParser->getField(aAuthenKey, aAuthenValue))
     {
         if (aAuthenValue.length() > 0)
         {
-            StrPtrLen realmField;
-            if (getRealmField(aAuthenValue, realmField))
-            {
-                aRealm = OSCL_HeapString<OsclMemAllocator> (realmField.c_str(), realmField.length());
-                return true;
-            }
+            return true;
         }
     }
     return false;
 }
 
-bool HttpParsingBasicObject::getRealmField(const StrPtrLen &aInputData, StrPtrLen &aOuputData)
-{
-    // get playback time
-    char *ptr = (char *)aInputData.c_str();
-    uint32 len = aInputData.length();
-    while (!(((ptr[0]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'r') &&
-             ((ptr[1]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'e') &&
-             ((ptr[2]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'a') &&
-             ((ptr[3]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'l') &&
-             ((ptr[4]  | OSCL_ASCII_CASE_MAGIC_BIT) == 'm') &&
-             ((ptr[5]  | OSCL_ASCII_CASE_MAGIC_BIT) == '=')) &&
-            len >= 6)
-    {
-        ptr++;
-        len--;
-    }
-    if (len < 6) return false;
-    ptr += 6;
-    len -= 6;
-    aOuputData = StrPtrLen(ptr, len);
-    return true;
-}
-
-
 int32 HttpParsingBasicObject::isNewContentRangeInfoMatchingCurrentOne(const uint32 aPrevContentLength)
 {
     // First, consider content-length match
@@ -619,7 +671,7 @@
     memFrag.len = fragOut.getCapacity();
     int32 status = composeRequest(memFrag);
     if (status != PROCESS_SUCCESS) return status;
-    mediaData->setMediaFragFilledLen(0, getCurrentRequestLength()); // don't count NULL
+    mediaData->setMediaFragFilledLen(0, iComposer->getCurrentRequestLength(iURI.isUseAbsoluteURI())); // don't count NULL
 
     // send to port
     iObserver->ProtocolRequestAvailable(getProtocolRequestType());
@@ -735,10 +787,10 @@
     int32 deltaMilliSec1 = pBWEstInfo->iLatestMediaDataTimestamp - pBWEstInfo->iFirstMediaDataTsPerRequest;
     if (deltaMilliSec1 <= 0) return 0;
 
-    OsclFloat downloadRate0 = ((OsclFloat)getDownloadSize() / (OsclFloat)deltaMilliSec0) * 1000.0; // try to avoid overflow problem for 32-bit interger multiplication
-    OsclFloat downloadRate  = ((OsclFloat)getDownloadSize() / (OsclFloat)deltaMilliSec) * 1000.0; // try to avoid overflow problem for 32-bit interger multiplication
+    OsclFloat downloadRate0 = ((OsclFloat)getDownloadSize() / (OsclFloat)deltaMilliSec0) * (OsclFloat)1000.0; // try to avoid overflow problem for 32-bit interger multiplication
+    OsclFloat downloadRate  = ((OsclFloat)getDownloadSize() / (OsclFloat)deltaMilliSec) * (OsclFloat)1000.0; // try to avoid overflow problem for 32-bit interger multiplication
     OsclFloat downloadRate1 = ((OsclFloat)(pBWEstInfo->iTotalSizePerRequest) /
-                               (OsclFloat)deltaMilliSec1) * 1000.0; // try to avoid overflow problem for 32-bit interger multiplication
+                               (OsclFloat)deltaMilliSec1) * (OsclFloat)1000.0; // try to avoid overflow problem for 32-bit interger multiplication
 
     LOGINFODATAPATH((0, "ProtocolState::getDownloadRate(), deltaMilliSec0=%d, downloadSize=%d, downloadRate0=%d",
                      deltaMilliSec0, getDownloadSize(), (uint32)downloadRate0));
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.h
index 56d390c..4dbab32 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -219,6 +219,22 @@
         {
             return iParser->getAuthenInfo(aRealm);
         }
+        bool isServerSupportBasicAuthentication()
+        {
+            return iParser->isServerSupportBasicAuthentication();
+        }
+        bool isServerSendAuthenticationHeader()
+        {
+            return iParser->isServerSendAuthenticationHeader();
+        }
+        void getBasicPtr(const StrPtrLen aAuthenValue, uint32 &length)
+        {
+            iParser->getBasicPtr(aAuthenValue, length);
+        }
+        void getRealmPtr(const char *&ptrRealm, uint32 &len, uint32 &length)
+        {
+            iParser->getRealmPtr(ptrRealm, len, length);
+        }
         virtual uint32 getCurrentPlaybackTime()
         {
             return 0;    // only used in fast track
@@ -325,10 +341,6 @@
         virtual bool setHeaderFields() = 0;
         // do final compose, fixed for all derived classes
         virtual int32 doCompose(OsclMemoryFragment &aFrag);
-        virtual uint32 getCurrentRequestLength()
-        {
-            return iComposer->getCurrentRequestLength(iURI.isUseAbsoluteURI());
-        }
         bool setExtensionFields(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aExtensionHeaderKeys,
                                 Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aExtensionHeaderValues,
                                 Oscl_Vector<uint32, OsclMemAllocator> &aMaskBitForHTTPMethod,
@@ -549,6 +561,22 @@
         {
             return iCurrState->getAuthenInfo(aRealm);
         }
+        bool isServerSupportBasicAuthentication()
+        {
+            return iParser->isServerSupportBasicAuthentication();
+        }
+        bool isServerSendAuthenticationHeader()
+        {
+            return iParser->isServerSendAuthenticationHeader();
+        }
+        void getBasicPtr(const StrPtrLen aAuthenValue, uint32 &length)
+        {
+            iParser->getBasicPtr(aAuthenValue, length);
+        }
+        void getRealmPtr(const char *&ptrRealm, uint32 &len, uint32 &length)
+        {
+            iParser->getRealmPtr(ptrRealm, len, length);
+        }
         uint32 getCurrentPlaybackTime()
         {
             return iCurrState->getCurrentPlaybackTime();    // only used in fast track
@@ -570,6 +598,11 @@
             return iCurrState->isCurrentStateOptional();    // optional state can be by-passed regardless of any error happened
         }
 
+        void resetTotalHttpStreamingSize()
+        {
+            if (iParser) iParser->resetTotalHttpStreamingSize();
+        }
+
         virtual void reset()
         {
             if (iParser) iParser->resetForBadConnectionDetection();
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.cpp
index b550ccb..8e88123 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.h
index 868aaab..97fb602 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_download_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,12 @@
             return false;
         }
 
+        virtual void reset()
+        {
+            iOutputDataQueue.clear();
+            ProtocolState::reset();
+        }
+
         // constructor
         DownloadState() : iSetContentLengthFlagtoConfigFileObject(false)
         {
@@ -45,7 +51,7 @@
         // virtual destructor, let internal objects destruct automatically
         virtual ~DownloadState()
         {
-            ;
+            reset();
         }
 
     protected:
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_factory.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_factory.cpp
index 65c36ce..15a9634 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_factory.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_internal.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_internal.h
index 2886cb0..0290aef 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_internal.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,8 +43,8 @@
 #include "oscl_str_ptr_len.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #ifndef OSCL_TIME_H_INCLUDED
@@ -123,7 +123,9 @@
     PROCESS_TIMEOUT_SERVER_INACTIVITY		 = PROCESS_ERROR_FIRST - 15,
     PROCESS_CONTENT_LENGTH_NOT_MATCH		 = PROCESS_ERROR_FIRST - 16,
     PROCESS_CONTENT_RANGE_INFO_NOT_MATCH	 = PROCESS_ERROR_FIRST - 17,
-    PROCESS_OUTPUT_TO_OUTPUT_PORT_FAILURE	 = PROCESS_ERROR_FIRST - 18
+    PROCESS_OUTPUT_TO_OUTPUT_PORT_FAILURE	 = PROCESS_ERROR_FIRST - 18,
+    PROCESS_REACHED_MAXIMUM_SIZE_LIMITATION	 = PROCESS_ERROR_FIRST - 19
+
 };
 
 enum ProtocolType
@@ -159,6 +161,8 @@
 typedef Oscl_Vector<OsclRefCounterMemFrag, OsclMemAllocator> OUTPUT_DATA_QUEUE;
 
 #define PE_isDigit(c) ((c) >= 48 && (c) <= 57)
+#define PROTOCOLENGINE_REDIRECT_STATUS_CODE_START	300
+#define PROTOCOLENGINE_REDIRECT_STATUS_CODE_END		399
 
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -270,7 +274,7 @@
             my_ptr += (aligned_refcnt_size + aligned_cleanup_size);
 
             // 3. create OsclMemoryFragment object after refcounter object and cleanup object
-            OsclMemoryFragment* memfrag_ptr = OSCL_PLACEMENT_NEW(my_ptr, OsclMemoryFragment());
+            OsclMemoryFragment* memfrag_ptr = OSCL_PLACEMENT_NEW(my_ptr, OsclMemoryFragment);
             memfrag_ptr->ptr = (void*)(my_ptr + aligned_class_size);
             memfrag_ptr->len = requested_size;
 
@@ -293,7 +297,7 @@
             my_ptr += aligned_refcnt_size;
 
             // 2. create OsclMemoryFragment object after refcounter object object
-            OsclMemoryFragment* memfrag_ptr = OSCL_PLACEMENT_NEW(my_ptr, OsclMemoryFragment());
+            OsclMemoryFragment* memfrag_ptr = OSCL_PLACEMENT_NEW(my_ptr, OsclMemoryFragment);
             memfrag_ptr->ptr = (void*)(my_ptr + aligned_class_size);
             memfrag_ptr->len = requested_size;
 
@@ -340,6 +344,7 @@
             iMaxASFHeaderSize = PVPROTOCOLENGINE_DEFAULT_MAXIMUM_ASF_HEADER_SIZE;
             iAccelBitrate = DEFAULT_MS_STREAMING_ACCEL_BITRATE;
             iAccelDuration = DEFAULT_MS_STREAMING_ACCEL_DURATION;
+            iMaxHttpStreamingSize = 0;
             iStreamIDList.clear();
             iStreamPlayBackModeList.clear();
             iUserAgent = OSCL_HeapString<OsclMemAllocator> (_STRLIT_CHAR("NSPlayer/10.0.0.3646"));
@@ -403,6 +408,7 @@
             iExtensionHeadersPurgeOnRedirect = x.iExtensionHeadersPurgeOnRedirect;
             iAccelBitrate					= x.iAccelBitrate;
             iAccelDuration					= x.iAccelDuration;
+            iMaxHttpStreamingSize           = x.iMaxHttpStreamingSize;
             return *this;
         }
 
@@ -418,6 +424,7 @@
         uint32 iMaxASFHeaderSize;
         uint32 iAccelBitrate;
         uint32 iAccelDuration;
+        uint32 iMaxHttpStreamingSize;
         OSCL_HeapString<OsclMemAllocator> iUserAgent;
         OSCL_HeapString<OsclMemAllocator> iUserID;
         OSCL_HeapString<OsclMemAllocator> iUserPasswd;
@@ -636,6 +643,16 @@
             return iTotalDLHttpBodySize;
         }
         void setDownloadSize(const uint32 aInitialSize = 0);
+
+        uint32 getTotalHttpStreamingSize()
+        {
+            return iTotalHttpStreamingSize;
+        }
+        void resetTotalHttpStreamingSize()
+        {
+            iTotalHttpStreamingSize = 0;
+        }
+
         uint32 getStatusCode()
         {
             return (iParser == NULL ? 0 : iParser->getHTTPStatusCode());
@@ -651,6 +668,11 @@
         bool getRedirectURI(OSCL_String &aRedirectUri);
         bool getContentType(OSCL_String &aContentType);
         bool getAuthenInfo(OSCL_String &aRealm);
+        bool isServerSupportBasicAuthentication();
+        bool isServerSendAuthenticationHeader();
+        void getBasicPtr(const StrPtrLen aAuthenValue, uint32 &length);
+        void getRealmPtr(const char *&ptrRealm, uint32 &len, uint32 &length);
+
         uint32 getServerVersionNumber()
         {
             return iServerVersionNumber;
@@ -721,7 +743,6 @@
             iBWEstInfo.clear();
             iHttpHeaderParsed = false;
             iTotalDLHttpBodySize = 0;
-            isRedirectResponse = false;
             iLatestMediaDataTimestamp = 0;
         }
 
@@ -755,6 +776,7 @@
             iDataPathLogger = PVLogger::GetLoggerObject("protocolenginenode.protocolengine");
             iDataPathErrLogger = PVLogger::GetLoggerObject("datapath.sourcenode.protocolenginenode");
             iClockLogger = PVLogger::GetLoggerObject("clock");
+            iTotalHttpStreamingSize = 0;
             reset();
         }
 
@@ -765,13 +787,13 @@
         // EOS input can be indicated as the sign of bad request (the request just sent is bad request, especially badk URL)
         int32 validateEOSInput(int32 parsingStatus);
         // return total size of all data in entityUnit, ~0=0xffffffff means error
-        uint32 saveOutputData(RefCountHTTPEntityUnit &entityUnit, OUTPUT_DATA_QUEUE &aOutputData);
+        bool saveOutputData(RefCountHTTPEntityUnit &entityUnit, OUTPUT_DATA_QUEUE &aOutputData, uint32 &aTotalEntityDataSize);
         // return codes conversion, may send out callback for end of message or end of input cases
         int32 checkParsingDone(const int32 parsingStatus);
         // extract the server version number from server field of a HTTP response
         void extractServerVersionNum();
-        // extract realm field from WWW-Authenticate header
-        bool getRealmField(const StrPtrLen &aInputData, StrPtrLen &aOuputData);
+        // called by getNextMediaData()
+        bool isRedirectResponse();
 
         void clearInputOutput()
         {
@@ -793,7 +815,6 @@
         uint32 iTotalDLSizeForPrevEOS; // for detecting download size change between two adjacent EOSs or start and first EOS
         uint32 iTotalDLSizeAtCurrEOS;
         uint32  iLatestMediaDataTimestamp;
-        bool isRedirectResponse;
         BandwidthEstimationInfo iBWEstInfo;
         uint32 iNumRetry;
 
@@ -801,6 +822,8 @@
         PVLogger* iDataPathLogger;
         PVLogger* iDataPathErrLogger;
         PVLogger* iClockLogger;
+
+        uint32 iTotalHttpStreamingSize;
 };
 
 
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node.h
index 2233bc8..dfc49d2 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -146,14 +146,14 @@
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL,
                                                PVMFFormatType& aSourceFormat,
                                                OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
 
         // From PVMFProtocolEngineNodeExtensionInterface and
         // From PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface
         PVMFStatus GetHTTPHeader(uint8*& aHeader, uint32& aHeaderLen);
         void GetFileSize(uint32& aFileSize)
         {
-            aFileSize = iInterfacingObjectContainer.getFileSize();
+            aFileSize = (iInterfacingObjectContainer == NULL ? 0 : iInterfacingObjectContainer->getFileSize());
         }
         bool GetSocketConfig(OSCL_String &aPortConfig);
         bool GetSocketConfigForLogging(OSCL_String &aPortConfig);
@@ -165,11 +165,11 @@
         {
             uint32 timeout = aTimeout;
             if ((int32)timeout < 0) timeout = 0x7fffffff;
-            iInterfacingObjectContainer.setKeepAliveTimeout(timeout);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setKeepAliveTimeout(timeout);
         }
         void SetNumRedirectTrials(const uint32 aNumTrials)
         {
-            iInterfacingObjectContainer.setNumRedirectTrials(aNumTrials);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setNumRedirectTrials(aNumTrials);
         }
         void SetHttpExtensionHeaderField(OSCL_String &aFieldKey, OSCL_String &aFieldValue, const HttpMethod aMethod = HTTP_GET, const bool aPurgeOnRedirect = false);
         void SetLoggingURL(OSCL_wString& aSourceURL);
@@ -179,11 +179,11 @@
         }
         bool SetStreamingProxy(OSCL_wString& aProxyURL, const uint32 aProxyPort)
         {
-            return iInterfacingObjectContainer.setStreamingProxy(aProxyURL, aProxyPort);
+            return (iInterfacingObjectContainer == NULL ? false : iInterfacingObjectContainer->setStreamingProxy(aProxyURL, aProxyPort));
         }
         void DisableHttpHeadRequest(const bool aDisableHeadRequest = true)
         {
-            iInterfacingObjectContainer.setHttpHeadRequestDisabled(aDisableHeadRequest);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setHttpHeadRequestDisabled(aDisableHeadRequest);
         }
         bool GetASFHeader(Oscl_Vector<OsclRefCounterMemFrag, OsclMemAllocator> &aHeader)
         {
@@ -191,7 +191,7 @@
         }
         bool SetStreamParams(const PVMFProtocolEngineNodeMSHTTPStreamingParams &aParams)
         {
-            iInterfacingObjectContainer.setStreamParams((PVMFProtocolEngineNodeMSHTTPStreamingParams &)aParams);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setStreamParams((PVMFProtocolEngineNodeMSHTTPStreamingParams &)aParams);
             return true;
         }
         PVMFCommandId Seek(PVMFSessionId aSessionId, uint64 aNPTInMS, uint32& aFirstSeqNumAfterSeek, OsclAny* aContext);
@@ -200,25 +200,35 @@
         PVMFStatus SetMediaMsgAllocatorNumBuffers(PVMFPortInterface* aPort, uint32 aNumBuffersInAllocator)
         {
             OSCL_UNUSED_ARG(aPort);
-            iInterfacingObjectContainer.setMediaMsgAllocatorNumBuffers(aNumBuffersInAllocator);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setMediaMsgAllocatorNumBuffers(aNumBuffersInAllocator);
             return PVMFSuccess;
         }
         void SetMaxASFHeaderSize(const uint32 aMaxASFHeaderSize = PVPROTOCOLENGINE_DEFAULT_MAXIMUM_ASF_HEADER_SIZE)
         {
-            iInterfacingObjectContainer.setMaxASFHeaderSize(aMaxASFHeaderSize);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setMaxASFHeaderSize(aMaxASFHeaderSize);
         }
         void SetUserAuthInfo(OSCL_String &aUserID, OSCL_String &aPasswd)
         {
-            iInterfacingObjectContainer.setUserAuthInfo(aUserID, aPasswd);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->setUserAuthInfo(aUserID, aPasswd);
         }
         bool IsWMServerVersion4();
         void SetAccelBitrate(const uint32 aAccelBitrate)
         {
-            iInterfacingObjectContainer.SetAccelBitrate(aAccelBitrate);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->SetAccelBitrate(aAccelBitrate);
         }
         void SetAccelDuration(const uint32 aAccelDuration)
         {
-            iInterfacingObjectContainer.SetAccelDuration(aAccelDuration);
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->SetAccelDuration(aAccelDuration);
+        }
+
+        void SetNumBuffersInMediaDataPoolSMCalc(uint32 aVal)
+        {
+            iInterfacingObjectContainer->setNumBuffersInMediaDataPoolSMCalc(aVal);
+        }
+
+        void SetMaxHttpStreamingSize(const uint32 aMaxHttpStreamingSize)
+        {
+            if (iInterfacingObjectContainer) iInterfacingObjectContainer->SetMaxHttpStreamingSize(aMaxHttpStreamingSize);
         }
 
         // From PVMIDatastreamuserInterface
@@ -227,7 +237,7 @@
         // From PVMFDownloadProgressInterface
         void setFormatDownloadSupportInterface(PVMFFormatProgDownloadSupportInterface* download_support_interface);
         void setClipDuration(const uint32 aClipDurationMsec);
-        OsclSharedPtr<OsclClock> getDownloadProgressClock();
+        OsclSharedPtr<PVMFMediaClock> getDownloadProgressClock();
         void requestResumeNotification(const uint32 currentNPTReadPosition,
                                        bool& aDownloadComplete);
         void cancelResumeNotification();
@@ -253,7 +263,7 @@
         void HandlePortActivity(const PVMFPortActivity& aActivity);
 
         //From PVMFDataSourceInitializationExtensionInterface, the following two APIs are not used in this node
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock)
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock)
         {
             OSCL_UNUSED_ARG(aClientClock);
             OSCL_LEAVE(OsclErrNotSupported);
@@ -269,8 +279,11 @@
         // Port processing
         bool ProcessPortActivity();
         void QueuePortActivity(const PVMFPortActivity& aActivity);
+        void QueueActivityIncomingMessage(const PVMFStatus aStatus, const PVMFPortActivity &aActivity); // called by ProcessPortActivity()
+        void QueueActivityOutgoingMessage(const PVMFStatus aStatus, const PVMFPortActivity &aActivity); // called by ProcessPortActivity()
         PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
         PVMFStatus ProcessOutgoingMsg(PVMFPortInterface* aPort);
+        PVMFStatus PostProcessForMsgSentSuccess(PVMFPortInterface* aPort, PVMFSharedMediaMsgPtr &aMsg);
         void SendOutgoingQueueReadyEvent(PVMFPortInterface* aPort);
         bool SearchPortActivityInQueue(const PVMFPortActivityType aType);
         void ProcessOutgoingQueueReady();
@@ -284,7 +297,8 @@
                              PVMFProtocolEngineNodeCommand&,
                              PVMFStatus, OsclAny* aData = NULL,
                              PVUuid* aEventUUID = NULL,
-                             int32* aEventCode = NULL);
+                             int32* aEventCode = NULL,
+                             int32 aEventDataLen = 0);
         int32 HandleCommandComplete(PVMFProtocolEngineNodeCmdQ& aCmdQ,
                                     PVMFProtocolEngineNodeCommand& aCmd,
                                     int32 aStatus);
@@ -308,8 +322,6 @@
         PVMFStatus DoSeek(PVMFProtocolEngineNodeCommand&);
         PVMFStatus DoBitsteamSwitch(PVMFProtocolEngineNodeCommand&);
         PVMFStatus DoReposition(PVMFProtocolEngineNodeCommand&);
-        void StartDataFlowByCommand(const bool needDoSocketReconnect = true);
-        void RescheduleNewDataFlow();
         bool CheckAvailabilityOfDoStart(PVMFProtocolEngineNodeCommand& aCmd); // called in DoStart() only
         inline bool IsDataFlowEventAlreadyInQueue(const PVProtocolEngineNodeInternalEventType aEventType);
 
@@ -317,8 +329,8 @@
         void HandleRunFlush();
 
         // Event reporting
-        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, int32 aEventCode = 0);
-        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, int32 aEventCode = 0);
+        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, const int32 aEventCode = 0, OsclAny* aEventLocalBuffer = NULL, const uint32 aEventLocalBufferSize = 0);
+        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, const int32 aEventCode = 0, int32 aEventDataLen = 0);
         void SetState(TPVMFNodeInterfaceState);
 
         // From ProtocolObserver
@@ -332,6 +344,7 @@
         void OutputBufferAvailable();
         void OutputBufferPoolFull();
         void ReadyToUpdateDownloadControl();
+        bool QueueOutgoingMsgSentSuccess(PVMFProtocolEnginePort *aPort, PVMFSharedMediaMsgPtr &aMsg);
 
         // From OsclTimerObserver
         void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
@@ -355,6 +368,8 @@
         bool RecreateProtocolObjectsForProgressiveStreaming(OsclAny* aSourceData);
         ProtocolContainerFactory* CreateProtocolContainerFactory(const uint32 aProtocolType);
         bool SendPortMediaCommand(PVMFProtocolEnginePort *aPort, PVUid32 aCmdId, const bool isForLogging = false);
+        void RerunForPostProcessAfterOutgoingMsgSent(PVMFProtocolEnginePort *aPort, PVMFSharedMediaMsgPtr &aMsg);
+        void LogPortMediaCmdQueued(PVMFProtocolEnginePort *aPort, PVUid32 aCmdId);
         bool CheckFormatSpecificInfoForMediaCommand(PVMFSharedMediaCmdPtr &aCmdPtr, PVUid32 aCmdId, const bool isForLogging = false);
         void ClearPorts(const bool aNeedDelete = false);
         void Clear(const bool aNeedDelete = false);
@@ -366,7 +381,7 @@
         PVProtocolEngineNodePrcoessingState iProcessingState;
 
         // this object container contains the multiple input data from node user and output data to node user
-        InterfacingObjectContainer iInterfacingObjectContainer;
+        InterfacingObjectContainer *iInterfacingObjectContainer;
 
         friend class ProtocolContainer;
         friend class DownloadContainer;
@@ -390,6 +405,7 @@
         friend class EndOfDataProcessingHandler;
         friend class ServerResponseErrorBypassingHandler;
         friend class CheckResumeNotificationHandler;
+        friend class OutgoingMsgSentSuccessHandler;
 
         HttpBasedProtocol *iProtocol;
         ProtocolContainer *iProtocolContainer;
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.cpp
index 049c33a..ebe43c6 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,10 +25,9 @@
 #include "pvmf_media_msg_format_ids.h"
 #include "pv_mime_string_utils.h"
 #include "pvmi_kvp_util.h"
-#include "oscl_utf8conv.h"
 
-//#include "pvmf_protocol_engine.h"
 #include "oscl_snprintf.h"
+#include "oscl_utf8conv.h"
 
 /**
 //Macros for calling PVLogger
@@ -55,6 +54,7 @@
         OsclTimerObject(aPriority, "PVMFProtocolEngineNode"),
         iStatusCode(0),
         iProcessingState(ProcessingState_Idle),
+        iInterfacingObjectContainer(NULL),
         iProtocol(NULL),
         iProtocolContainer(NULL),
         iProtocolContainerFactory(NULL),
@@ -100,7 +100,7 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = false;
              iCapability.iMaxNumberOfPorts = 0;//no maximum
-             iCapability.iInputFormatCapability.push_back(PVMF_INET_TCP);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_INET_TCP);
 
              // create the internal data queue
              iDataInQueue.reserve(PVPROTOCOLENGINE_RESERVED_NUMBER_OF_FRAMES);
@@ -451,7 +451,7 @@
     }
     else if (uuid == PVMF_TRACK_SELECTION_INTERFACE_UUID)
     {
-        if (iInterfacingObjectContainer.getDownloadFormat() != PVMF_DATA_SOURCE_PVX_FILE) return false;
+        if (!iInterfacingObjectContainer || iInterfacingObjectContainer->getDownloadFormat() != PVMF_MIME_DATA_SOURCE_PVX_FILE) return false;
         PVMFTrackSelectionExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMFTrackSelectionExtensionInterface*, this);
         iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
         addRef();
@@ -624,7 +624,8 @@
         PVMFStatus aStatus,
         OsclAny* aEventData,
         PVUuid* aEventUUID,
-        int32* aEventCode)
+        int32* aEventCode,
+        int32 aEventDataLen)
 
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFProtocolEngineNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
@@ -640,6 +641,11 @@
 
     //create response
     PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
+    if (aEventDataLen != 0)
+    {
+        resp.SetEventDataLen(aEventDataLen);
+    }
+
     PVMFSessionId session = aCmd.iSession;
 
     //Erase the command from the queue.
@@ -659,10 +665,6 @@
 {
     LOGINFO((0, "PVMFProtocolEngineNode::DoReset()"));
 
-    //Flush the datstream
-    if (iNodeOutput)
-        iNodeOutput->flushDataStream();
-
     // Allow a reset on ANY state.
     Clear(true); // true means deleting the relevant objects
 
@@ -766,7 +768,7 @@
     }
 
     //Return the port pointer to the caller.
-    CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)port);
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)port, 0, 0, sizeof(PVMFProtocolEnginePort));
     return PVMFSuccess;
 }
 
@@ -781,8 +783,12 @@
     PVMFStatus status = PVMFSuccess;
 
     //Find the port in the port vector
-    PVMFProtocolEnginePort* port = NULL;
-    aCmd.PVMFProtocolEngineNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* p = NULL;
+    aCmd.PVMFProtocolEngineNodeCommandBase::Parse(p);
+
+    PVMFProtocolEnginePort* port = (PVMFProtocolEnginePort*)p;
+
+
     if (port == NULL) status = PVMFErrArgument;
 
     PVMFProtocolEnginePort** portPtr = iPortVector.FindByValue(port);
@@ -917,14 +923,14 @@
 {
     LOGINFO((0, "PVMFProtocolEngineNode::DoStart()"));
     LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoStart() : Start command gets called and executed, iInterfaceState=%d, currSocketConnection=%d",
-                     (int32)iInterfaceState, (uint32)iInterfacingObjectContainer.isSocketConnectionUp()));
+                     (int32)iInterfaceState, (uint32)iInterfacingObjectContainer->isSocketConnectionUp()));
 
     // check if download/streaming is done, if it is done, no need to start/resume download/streaming
     if (CheckAvailabilityOfDoStart(aCmd)) return PVMFSuccess;
 
     PVMFStatus status = PVMFSuccess;
     iProcessingState = ProcessingState_NormalDataflow;
-    iInterfacingObjectContainer.setInputDataUnwanted(false);
+    iInterfacingObjectContainer->setInputDataUnwanted(false);
     switch (iInterfaceState)
     {
         case EPVMFNodePrepared:
@@ -934,7 +940,12 @@
                 // do socket reconnect for init->start, prepare->start and stop->start
                 // for pause->start, no need. For seek, no start command is issued. doseek() will
                 // do socket reconnect
-                StartDataFlowByCommand(iProtocolContainer->needSocketReconnect()); // make start command (prepare->start) asynchonous
+                iProtocolContainer->startDataFlowByCommand(iProtocolContainer->needSocketReconnect()); // make start command (prepare->start) asynchonous
+
+                // Transition to BeingStarted
+                // intentionally set node state as this node internal state to ignore any left-over messages from POST port from previous stop or EOS handling
+                SetState((TPVMFNodeInterfaceState)PVMFProtocolEngineNodeState_BeingStarted);
+
                 return PVMFPending;
             }
             status = PVMFSuccess;
@@ -943,16 +954,25 @@
 
         case EPVMFNodePaused:
         {
-            // Transition to BeingStarted
-            // intentionally set node state as this node internal state to ignore any left-over messages from POST port because currently node is paused state.
-            // need to differentiate this case from the paused case.
-            SetState((TPVMFNodeInterfaceState)PVMFProtocolEngineNodeState_BeingStarted);
+            if (iInterfacingObjectContainer->getTruncatedForLimitSize())
+            {
+                LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoStart() : size limitation"));
+                status = PVMFSuccess;
+                break;
+            }
+            else
+            {
+                // Transition to BeingStarted
+                // intentionally set node state as this node internal state to ignore any left-over messages from POST port because currently node is paused state.
+                // need to differentiate this case from the paused case.
+                SetState((TPVMFNodeInterfaceState)PVMFProtocolEngineNodeState_BeingStarted);
 
-            iProtocol->resume();
-            StartDataFlowByCommand();
-            return PVMFPending;
+                iProtocol->resume();
+                iProtocolContainer->startDataFlowByCommand();
+                return PVMFPending;
 
-            // break;	This statement was removed to avoid compiler warning for Unreachable Code
+                // break;	This statement was removed to avoid compiler warning for Unreachable Code
+            }
         }
 
         /*
@@ -975,7 +995,7 @@
 bool PVMFProtocolEngineNode::CheckAvailabilityOfDoStart(PVMFProtocolEngineNodeCommand& aCmd)
 {
     // check if download/streaming is done, if it is done, no need to start/resume download/streaming
-    if (iInterfacingObjectContainer.isDownloadStreamingDone())
+    if (iInterfacingObjectContainer->isDownloadStreamingDone())
     {
         SetState(EPVMFNodeStarted);
         CommandComplete(iInputCommands, aCmd, PVMFSuccess);
@@ -992,6 +1012,13 @@
     LOGINFO((0, "PVMFProtocolEngineNode::DoPause()"));
     LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoPause() : Pause command gets called and executed, iInterfaceState=%d", (int32)iInterfaceState));
 
+    if (iInterfacingObjectContainer->getTruncatedForLimitSize())
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoPause() : size limitation = PVMFSuccess"));
+        return PVMFSuccess;
+    }
+
     PVMFStatus status = PVMFSuccess;
     switch (iInterfaceState)
     {
@@ -1024,6 +1051,12 @@
 */
 PVMFStatus PVMFProtocolEngineNode::DoSeek(PVMFProtocolEngineNodeCommand& aCmd)
 {
+    if (iInterfacingObjectContainer->getTruncatedForLimitSize())
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoSeek() : size limitation = PVMFFailure"));
+        return PVMFFailure;
+    }
     return iProtocolContainer->doSeek(aCmd);
 }
 
@@ -1033,43 +1066,26 @@
 */
 PVMFStatus PVMFProtocolEngineNode::DoBitsteamSwitch(PVMFProtocolEngineNodeCommand& aCmd)
 {
+    if (iInterfacingObjectContainer->getTruncatedForLimitSize())
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoBitsteamSwitch() : size limitation = PVMFFailure"));
+        return PVMFFailure;
+    }
     return iProtocolContainer->doBitstreamSwitch(aCmd);
 }
 
 PVMFStatus PVMFProtocolEngineNode::DoReposition(PVMFProtocolEngineNodeCommand& aCmd)
 {
+    if (iInterfacingObjectContainer->getTruncatedForLimitSize())
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::DoReposition() : size limitation = PVMFFailure"));
+        return PVMFFailure;
+    }
     return iProtocolContainer->doSeek(aCmd);
 }
 
-void PVMFProtocolEngineNode::StartDataFlowByCommand(const bool needDoSocketReconnect)
-{
-    // flush out existing data at this point
-    iDataInQueue.clear();
-    iNodeOutput->discardData();
-    ClearPorts(); // clear any queued messages in ports
-
-    // cancel all the existing timers
-    iNodeTimer->clear();
-
-    // disable info update at this point, will be enabled when new response comes in
-    iProtocolContainer->enableInfoUpdate(false);
-
-    // socket reconnect
-    if (needDoSocketReconnect) iProtocolContainer->reconnectSocket();
-
-    RescheduleNewDataFlow();
-}
-
-void PVMFProtocolEngineNode::RescheduleNewDataFlow()
-{
-    PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_StartDataflowByCommand);
-    iInternalEventQueue.clear();
-    iInternalEventQueue.push_back(aEvent);
-    iProcessingState = ProcessingState_NormalDataflow;
-    iInterfacingObjectContainer.setInputDataUnwanted(false);
-    RunIfNotReady();
-}
-
 /**
 //Called by the command handler AO to do the node Stop
 */
@@ -1154,8 +1170,8 @@
 */
 bool PVMFProtocolEngineNode::FlushPending()
 {
-    return (iCurrentCommand.size() > 0
-            && iCurrentCommand.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
+    return (iCurrentCommand.size() > 0 &&
+            iCurrentCommand.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
 }
 
 
@@ -1183,7 +1199,7 @@
 
     //finally, report cancel complete.
     CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    iInterfacingObjectContainer.setCancelCmdHappened();
+    if (iInterfacingObjectContainer) iInterfacingObjectContainer->setCancelCmdHappened();
     return PVMFSuccess;
 }
 
@@ -1209,7 +1225,7 @@
         //report cancel success
         CommandComplete(iInputCommands, aCmd, PVMFSuccess);
         // set cancel cmd happened flag for stop command processing
-        iInterfacingObjectContainer.setCancelCmdHappened();
+        if (iInterfacingObjectContainer) iInterfacingObjectContainer->setCancelCmdHappened();
         return PVMFSuccess;
     }
 
@@ -1224,14 +1240,14 @@
         //report cancel success
         CommandComplete(iInputCommands, aCmd, PVMFSuccess);
         // set cancel cmd happened flag for stop command processing
-        iInterfacingObjectContainer.setCancelCmdHappened();
+        if (iInterfacingObjectContainer) iInterfacingObjectContainer->setCancelCmdHappened();
         return PVMFSuccess;
     }
 
     //at this point, nothing needs to be cancelled and thus report cancel complete
     CommandComplete(iInputCommands, aCmd, PVMFSuccess);
     // set cancel cmd happened flag for stop command processing
-    iInterfacingObjectContainer.setCancelCmdHappened();
+    if (iInterfacingObjectContainer) iInterfacingObjectContainer->setCancelCmdHappened();
     return PVMFSuccess;
 }
 
@@ -1245,7 +1261,7 @@
     PVMFNodeInterface::SetState(s);
 }
 
-void PVMFProtocolEngineNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData, int32 aEventCode)
+void PVMFProtocolEngineNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData, const int32 aEventCode, OsclAny* aEventLocalBuffer, const uint32 aEventLocalBufferSize)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFProtocolEngineNode:NodeInfoEvent Type %d Data %d",
                     aEventType, aEventData));
@@ -1259,26 +1275,15 @@
     {
         //report extended event.
         PVUuid uuid = PVMFPROTOCOLENGINENODEInfoEventTypesUUID;
-        PVMFBasicErrorInfoMessage*msg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, uuid, NULL));
-
-        uint8* eventCodeData = NULL;
-        uint32 eventCodeDataLength = 0;
-        if (aEventCode == (int32)PVMFPROTOCOLENGINENODEInfo_BufferingStatus ||
-                aEventCode == (int32)PVMFPROTOCOLENGINENODEInfo_TruncatedContentByServerDisconnect)
-        {
-            // download percentage
-            int32 data = (int32)aEventData;
-            eventCodeData = (uint8*)(&data);
-            eventCodeDataLength = sizeof(data);
-        }
+        PVMFBasicErrorInfoMessage *msg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, uuid, NULL));
 
         PVMFAsyncEvent event(PVMFInfoEvent,
                              aEventType,
                              NULL, //context
                              msg,
                              aEventData,
-                             eventCodeData,
-                             eventCodeDataLength);
+                             (uint8*)aEventLocalBuffer,
+                             aEventLocalBufferSize);
 
         //report to the session observers.
         PVMFNodeInterface::ReportInfoEvent(event);
@@ -1290,33 +1295,35 @@
 
 void PVMFProtocolEngineNode::ReportErrorEvent(PVMFEventType aEventType,
         OsclAny* aEventData,
-        int32 aEventCode)
+        const int32 aEventCode,
+        int32 aEventDataLen)
 {
     LOGINFO((0, "PVMFProtocolEngineNode::ReportErrorEvent() Type %d Data %d"
              , aEventType, aEventData));
 
-    if (aEventCode == 0)
-    {
-        // basic error event
-        PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
-    }
-    else
+    PVMFBasicErrorInfoMessage*msg  = NULL;
+
+    if (aEventCode != 0)
     {
         // extended error event with aEventCode
         PVUuid uuid = PVProtocolEngineNodeErrorEventTypesUUID;
-        PVMFBasicErrorInfoMessage*msg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, uuid, NULL));
-
-        PVMFAsyncEvent event(PVMFErrorEvent,
-                             aEventType,
-                             NULL, // context
-                             msg,
-                             aEventData,
-                             NULL,
-                             0);
-
-        PVMFNodeInterface::ReportErrorEvent(event);
-        if (msg) msg->removeRef();
+        msg = OSCL_NEW(PVMFBasicErrorInfoMessage, (aEventCode, uuid, NULL));
     }
+
+    PVMFAsyncEvent event(PVMFErrorEvent,
+                         aEventType,
+                         NULL, // context
+                         msg,
+                         aEventData,
+                         NULL,
+                         0);
+
+    if (aEventDataLen != 0)
+        event.SetEventDataLen(aEventDataLen);
+
+    PVMFNodeInterface::ReportErrorEvent(event);
+    if (msg) msg->removeRef();
+
 }
 
 /////////////////////////////////////////////////////
@@ -1332,7 +1339,7 @@
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                         (0, "PVMFProtocolEngineNode::QueuePortActivity() Error - iPortActivityQueue.push_back() failed"));
-        ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+        ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort), sizeof(PVMFProtocolEnginePort));
     }
     else
     {
@@ -1384,7 +1391,7 @@
             {
                 LOGINFODATAPATH((0, "PVMFProtocolEngineNode::HandlePortActivity: port=0x%x, type=%d(PVMF_PORT_ACTIVITY_CONNECT), PE node output port connected to downstream node port!",
                                  aActivity.iPort, aActivity.iType));
-                iInterfacingObjectContainer.setOutputPortConnect();
+                iInterfacingObjectContainer->setOutputPortConnect();
             }
 
             break;
@@ -1402,7 +1409,7 @@
             {
                 LOGINFODATAPATH((0, "PVMFProtocolEngineNode::HandlePortActivity: port=0x%x, type=%d(PVMF_PORT_ACTIVITY_DISCONNECT), PE node output port disconnected from downstream node port!",
                                  aActivity.iPort, aActivity.iType));
-                iInterfacingObjectContainer.setOutputPortConnect(false);
+                iInterfacingObjectContainer->setOutputPortConnect(false);
             }
             break;
 
@@ -1484,8 +1491,6 @@
     LOGINFODATAPATH((0, "PVMFProtocolEngineNode::ProcessPortActivity() port=0x%x, type=%d, IncomingQueueSize=%d, OutgoingQueueSize=%d, iInterfaceState=%d, PAQSize=%d",
                      activity.iPort, activity.iType, activity.iPort->IncomingMsgQueueSize(), activity.iPort->OutgoingMsgQueueSize(), iInterfaceState, iPortActivityQueue.size()));
 
-    int32 err = OsclErrNone;
-
     PVMFStatus status = PVMFSuccess;
     switch (activity.iType)
     {
@@ -1493,27 +1498,14 @@
             status = ProcessOutgoingMsg(activity.iPort);
             //Re-queue the port activity event as long as there's
             //more data to process and it isn't in a Busy state.
-            if (status != PVMFErrBusy
-                    && activity.iPort->OutgoingMsgQueueSize() > 0)
-            {
-                OSCL_TRY(err, iPortActivityQueue.push_back(activity););
-            }
+            QueueActivityOutgoingMessage(status, activity);
             break;
 
         case PVMF_PORT_ACTIVITY_INCOMING_MSG:
             status = ProcessIncomingMsg(activity.iPort);
             //Re-queue the port activity event as long as there's
             //more data to process and it isn't in a Busy state.
-            if (status != PVMFErrBusy
-                    && activity.iPort->IncomingMsgQueueSize() > 0)
-            {
-                //OSCL_TRY(err,iPortActivityQueue.push_back(activity););
-                // only insert outgoing queue ready event in case of no such event in the port activity queue
-                if (!SearchPortActivityInQueue(PVMF_PORT_ACTIVITY_INCOMING_MSG))
-                {
-                    OSCL_TRY(err, iPortActivityQueue.push_back(activity););
-                }
-            }
+            QueueActivityIncomingMessage(status, activity);
             break;
 
         case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
@@ -1526,21 +1518,12 @@
             break;
     }
 
-    //report a failure in queueing new activity...
-    if (err != OsclErrNone)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMFProtocolEngineNode::ProcessPortActivity() Error - queue port activity failed. port=0x%x, type=%d",
-                         activity.iPort, activity.iType));
-        ReportErrorEvent(PVMFErrPortProcessing);
-    }
-
     //Report any unexpected failure in port processing...
     //(the InvalidState error happens when port input is suspended,
     //so don't report it.)
-    if (status != PVMFErrBusy
-            && status != PVMFSuccess
-            && status != PVMFErrInvalidState)
+    if (status != PVMFErrBusy &&
+            status != PVMFSuccess &&
+            status != PVMFErrInvalidState)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                         (0, "PVMFProtocolEngineNode::ProcessPortActivity() Error - ProcessPortActivity failed. port=0x%x, type=%d",
@@ -1552,6 +1535,33 @@
     return (status != PVMFErrBusy);
 }
 
+// wrap OSCL_TRY block
+void PVMFProtocolEngineNode::QueueActivityOutgoingMessage(const PVMFStatus aStatus, const PVMFPortActivity &aActivity)
+{
+    if (aStatus != PVMFErrBusy && aActivity.iPort->OutgoingMsgQueueSize() > 0)
+    {
+        int32 err;
+        OSCL_TRY(err, iPortActivityQueue.push_back(aActivity););
+        if (err) ReportErrorEvent(PVMFErrPortProcessing);
+    }
+}
+
+// wrap OSCL_TRY block
+void PVMFProtocolEngineNode::QueueActivityIncomingMessage(const PVMFStatus aStatus, const PVMFPortActivity &aActivity)
+{
+    //Re-queue the port activity event as long as there's more data to process and it isn't in a Busy state.
+    if (aStatus != PVMFErrBusy && aActivity.iPort->IncomingMsgQueueSize() > 0)
+    {
+        //OSCL_TRY(err,iPortActivityQueue.push_back(activity););
+        // only insert outgoing queue ready event in case of no such event in the port activity queue
+        if (!SearchPortActivityInQueue(PVMF_PORT_ACTIVITY_INCOMING_MSG))
+        {
+            int32 err;
+            OSCL_TRY(err, iPortActivityQueue.push_back(aActivity););
+            if (err) ReportErrorEvent(PVMFErrPortProcessing);
+        }
+    }
+}
 
 /////////////////////////////////////////////////////
 PVMFStatus PVMFProtocolEngineNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
@@ -1591,7 +1601,7 @@
         bool isEOS = (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID);
         if (aPort->GetPortTag() == PVMF_PROTOCOLENGINENODE_PORT_TYPE_INPUT)
         {
-            iInterfacingObjectContainer.updateSocketConnectFlags(isEOS); // will update flags
+            iInterfacingObjectContainer->updateSocketConnectFlags(isEOS); // will update flags
         }
 
         if (IgnoreCurrentInputData(aPort, isEOS, msg))
@@ -1657,7 +1667,7 @@
 bool PVMFProtocolEngineNode::IgnoreCurrentInputData(PVMFPortInterface* aPort, const bool isEOS, PVMFSharedMediaMsgPtr &aMsg)
 {
     OSCL_UNUSED_ARG(aMsg);
-    if (iInterfacingObjectContainer.ignoreCurrentInputData())
+    if (iInterfacingObjectContainer->ignoreCurrentInputData())
     {
         if (aPort->GetPortTag() == PVMF_PROTOCOLENGINENODE_PORT_TYPE_INPUT)
         {
@@ -1683,7 +1693,7 @@
         if (!isEOS &&
                 (iInterfaceState == EPVMFNodeStarted ||
                  iInterfaceState == (TPVMFNodeInterfaceState)PVMFProtocolEngineNodeState_BeingStarted) &&
-                !iInterfacingObjectContainer.isDownloadStreamingDone())
+                !iInterfacingObjectContainer->isDownloadStreamingDone())
         {
             return true;
         }
@@ -1694,9 +1704,9 @@
 
 bool PVMFProtocolEngineNode::CheckEndOfProcessingInIgoreData(const bool isEOS, const bool isDataPort)
 {
-    if (!iInterfacingObjectContainer.isDownloadStreamingDone()) return false;
+    if (!iInterfacingObjectContainer->isDownloadStreamingDone()) return false;
 
-    EndOfDataProcessingInfo *aInfo = iInterfacingObjectContainer.getEOPInfo();
+    EndOfDataProcessingInfo *aInfo = iInterfacingObjectContainer->getEOPInfo();
     if (isEOS)
     {
         if (iProtocolContainer->needCheckEOSAfterDisconnectSocket())
@@ -1723,7 +1733,7 @@
         return true;
     }
 
-    // Current situation: iInterfacingObjectContainer.isDownloadStreamingDone() = true
+    // Current situation: iInterfacingObjectContainer->isDownloadStreamingDone() = true
     if (isDataPort) return true;
     return false;
 }
@@ -1734,6 +1744,7 @@
     {
         LOGINFODATAPATH((0, "PVMFProtocolEngineNode::LogIncomingMessage() GOT EOS! port=0x%x, iInterfaceState=%d",
                          aPort, iInterfaceState));
+        OSCL_UNUSED_ARG(aPort); // to avoid warning of unused variable, 'aPort'
     }
     else
     {
@@ -1770,8 +1781,6 @@
     // check whether outgoing message is media command or media data
     PVMFSharedMediaMsgPtr msg;
     if (!((PVMFProtocolEnginePort*)aPort)->PeekOutgoingMsg(msg)) return PVMFFailure;
-    bool isMediaData = (msg->getFormatID() <  PVMF_MEDIA_CMD_FORMAT_IDS_START) ||
-                       (msg->getFormatID() == PVMF_MEDIA_CMD_SOCKET_CONNECT_FORMAT_ID);
 
     PVMFStatus status = aPort->Send();
     if (status == PVMFErrBusy)
@@ -1780,42 +1789,53 @@
     }
     if (status != PVMFSuccess) return status;
 
+    return PostProcessForMsgSentSuccess(aPort, msg);
+}
+
+PVMFStatus PVMFProtocolEngineNode::PostProcessForMsgSentSuccess(PVMFPortInterface* aPort, PVMFSharedMediaMsgPtr &aMsg)
+{
+    PVMFStatus status = PVMFSuccess;
+
     // keep track the sequence no of the media msg just sent out successfully
-    iInterfacingObjectContainer.setLatestPacketNumSent(msg->getSeqNum());
-    if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+    iInterfacingObjectContainer->setLatestPacketNumSent(aMsg->getSeqNum());
+
+    // set up server response timer and cancel inactivity timer
+    bool isMediaData = (aMsg->getFormatID() <  PVMF_MEDIA_CMD_FORMAT_IDS_START) ||
+                       (aMsg->getFormatID() == PVMF_MEDIA_CMD_SOCKET_CONNECT_FORMAT_ID);
+    UpdateTimersInProcessOutgoingMsg(isMediaData, aPort);
+
+    // send() success means outgoing queue should always be ready, then send out outgoing queue ready event
+    if ((PVMFProtocolEnginePort*)aPort == iPortOut) SendOutgoingQueueReadyEvent(aPort);
+
+    // handle the remaining post processing for the different media cmds.
+    if (aMsg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::ProcessOutgoingMsg() Send() SUCCESS: EOS SENT! SEQNUM= %d, MsgID=%d, port=0x%x", msg->getSeqNum(), msg->getFormatID(), aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::PostProcessForMsgSentSuccess() Send() SUCCESS: EOS SENT! SEQNUM= %d, MsgID=%d, port=0x%x", aMsg->getSeqNum(), aMsg->getFormatID(), aPort));
 
         // complete the pending command if there is, especially for the case of sending EOS due to error
         ProtocolStateErrorInfo aInfo(0, false);
         PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_ProtocolStateError, (OsclAny*)(&aInfo));
         DispatchInternalEvent(&aEvent);
     }
-    else if (msg->getFormatID() == PVMF_MEDIA_CMD_RE_CONFIG_FORMAT_ID)
+    else if (aMsg->getFormatID() == PVMF_MEDIA_CMD_RE_CONFIG_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::ProcessOutgoingMsg() Send() SUCCESS: RE_CONFIG SENT! SEQNUM= %d, MsgID=%d, port=0x%x", msg->getSeqNum(), msg->getFormatID(), aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::PostProcessForMsgSentSuccess() Send() SUCCESS: RE_CONFIG SENT! SEQNUM= %d, MsgID=%d, port=0x%x", aMsg->getSeqNum(), aMsg->getFormatID(), aPort));
 
         uint32 aFirstPacketNum = 0xFFFFFFFF;
         PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_FirstPacketAvailable, (OsclAny*)aFirstPacketNum);
         DispatchInternalEvent(&aEvent);
     }
-    else if (msg->getFormatID() == PVMF_MEDIA_CMD_SOCKET_CONNECT_FORMAT_ID)
+    else if (aMsg->getFormatID() == PVMF_MEDIA_CMD_SOCKET_CONNECT_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::ProcessOutgoingMsg() Send() SUCCESS: SOCKET CONNECT SENT! SEQNUM= %d, MsgID=%d, port=0x%x", msg->getSeqNum(), msg->getFormatID(), aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::PostProcessForMsgSentSuccess() Send() SUCCESS: SOCKET CONNECT SENT! SEQNUM= %d, MsgID=%d, port=0x%x", aMsg->getSeqNum(), aMsg->getFormatID(), aPort));
         bool status = iProtocolContainer->completeRepositionRequest();
-        if (status) LOGINFODATAPATH((0, "PVMFProtocolEngineNode::ProcessOutgoingMsg() Send() SOCKET CONNECT cmd SUCCESS: complete data stream reposition request"));
+        if (status) LOGINFODATAPATH((0, "PVMFProtocolEngineNode::PostProcessForMsgSentSuccess() Send() SOCKET CONNECT cmd SUCCESS: complete data stream reposition request"));
     }
     else
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::ProcessOutgoingMsg() Send() SUCCESS: SEQNUM= %d, MsgID=%d, port=0x%x", msg->getSeqNum(), msg->getFormatID(), aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::PostProcessForMsgSentSuccess() Send() SUCCESS: SEQNUM= %d, MsgID=%d, port=0x%x", aMsg->getSeqNum(), aMsg->getFormatID(), aPort));
     }
 
-
-    // set up server response timer and cancel inactivity timer
-    UpdateTimersInProcessOutgoingMsg(isMediaData, aPort);
-
-    // send() success means outgoing queue should always be ready, then send out outgoing queue ready event
-    if ((PVMFProtocolEnginePort*)aPort == iPortOut) SendOutgoingQueueReadyEvent(aPort);
     return status;
 }
 
@@ -1829,7 +1849,7 @@
         iNodeTimer->cancel(SERVER_INACTIVITY_TIMER_ID);
 
         uint32 timerID = SERVER_RESPONSE_TIMER_ID;
-        if (iInterfacingObjectContainer.isDownloadStreamingDone() && (PVMFProtocolEnginePort*)aPort == iPortInForLogging)
+        if (iInterfacingObjectContainer->isDownloadStreamingDone() && (PVMFProtocolEnginePort*)aPort == iPortInForLogging)
         {
             // logging POST for EOS and stop
             timerID = SERVER_RESPONSE_TIMER_ID_FOR_STOPEOS_LOGGING;
@@ -1878,7 +1898,8 @@
     PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_StartDataflowByPortOutgoingQueueReady);
     iInternalEventQueue.push_back(aEvent);
     iProcessingState = ProcessingState_NormalDataflow; // enable data flow
-    RunIfNotReady();
+    if (IsAdded())
+        RunIfNotReady();
 }
 
 /**
@@ -2033,8 +2054,8 @@
 void PVMFProtocolEngineNode::ProtocolStateComplete(const ProtocolStateCompleteInfo &aInfo)
 {
     PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_ProtocolStateComplete);
-    iInterfacingObjectContainer.setProtocolStateCompleteInfo(aInfo);
-    //aEvent.iEventInfo = (OsclAny*)iInterfacingObjectContainer.getProtocolStateCompleteInfo();
+    iInterfacingObjectContainer->setProtocolStateCompleteInfo(aInfo);
+    //aEvent.iEventInfo = (OsclAny*)iInterfacingObjectContainer->getProtocolStateCompleteInfo();
     DispatchInternalEvent(&aEvent);
 }
 
@@ -2111,10 +2132,18 @@
     iProtocolContainer->doInfoUpdate(PROCESS_SUCCESS);
 }
 
+bool PVMFProtocolEngineNode::QueueOutgoingMsgSentSuccess(PVMFProtocolEnginePort *aPort, PVMFSharedMediaMsgPtr &aMsg)
+{
+    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::QueueOutgoingMsgSentSuccess() - Msg queued and sent successfully!, Port=0x%x", aPort));
+    RerunForPostProcessAfterOutgoingMsgSent(aPort, aMsg);
+    return true;
+}
+
+
 void PVMFProtocolEngineNode::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
 {
     OSCL_UNUSED_ARG(timeoutInfo);
-    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::TimeoutOccurred()  timerID = %d, (0-server response, 1-inactivity, 2-KeepAlive, 3-Logging response), iInterfaceState=%d",
+    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::TimeoutOccurred()  timerID = %d, (0-server response, 1-inactivity, 2-KeepAlive, 3-Logging response, 4-Wall clock, 5-Buffer status timer), iInterfaceState=%d",
                      timerID, (int32)iInterfaceState));
 
     iProtocolContainer->handleTimeout(timerID);
@@ -2180,6 +2209,11 @@
 #endif
 
 
+#if defined(PV_PROTOCOL_ENGINE_NODE_WMHTTPSTREAMING_ENABLED)
+        case PVHTTPPROTOCOL_MS_HTTP_STREAMING:
+            aFactory = OSCL_NEW(MsHttpStreamingContainerFactory, ());
+            break;
+#endif
 
         default:
             break;
@@ -2199,7 +2233,15 @@
 
     if (aNeedDelete)
     {
-        while (!iPortVector.empty()) iPortVector.Erase(&iPortVector.front());
+        while (!iPortVector.empty())
+        {
+            PVMFProtocolEnginePort* port = iPortVector.front();
+            iPortVector.Erase(&iPortVector.front());
+
+            if (port == iPortInForData)	iPortInForData = NULL;
+            if (port == iPortInForLogging) iPortInForLogging = NULL;
+            if (port == iPortOut) iPortOut = NULL;
+        }
         // Restore original port vector reserve.
         iPortVector.Reconstruct();
     }
@@ -2227,14 +2269,8 @@
         PVMFFormatType& aSourceFormat,
         OsclAny* aSourceData)
 {
-    if ((aSourceFormat != PVMF_DATA_SOURCE_HTTP_URL) &&
-            (aSourceFormat != PVMF_DATA_SOURCE_PVX_FILE)) return PVMFErrNotSupported;
-
-    // set download format
-    iInterfacingObjectContainer.setDownloadFormat(aSourceFormat);
-
-    // set URI
-    if (!iInterfacingObjectContainer.getURIObject().setURI(aSourceURL)) return PVMFFailure;
+    if ((aSourceFormat != PVMF_MIME_DATA_SOURCE_HTTP_URL) &&
+            (aSourceFormat != PVMF_MIME_DATA_SOURCE_PVX_FILE)) return PVMFErrNotSupported;
 
     // create protocol objects
     if (!CreateProtocolObjects(GetProtocolType(aSourceFormat, aSourceData))) return PVMFErrNoMemory;
@@ -2245,13 +2281,20 @@
     // need to recreate protocol objects for progressive streaming based on source data
     if (!RecreateProtocolObjectsForProgressiveStreaming(aSourceData)) return PVMFErrNoMemory;
 
+    // set download format
+    if (iInterfacingObjectContainer) iInterfacingObjectContainer->setDownloadFormat(aSourceFormat);
+
+    // set URI
+    if (!iInterfacingObjectContainer->getURIObject().setURI(aSourceURL)) return PVMFFailure;
+
+
     // create and set iCfgFile
-    if (!iProtocolContainer->createCfgFile(iInterfacingObjectContainer.getURIObject().getURI())) return PVMFFailure;
+    if (!iProtocolContainer->createCfgFile(iInterfacingObjectContainer->getURIObject().getURI())) return PVMFFailure;
     return PVMFSuccess;
 }
 
 
-PVMFStatus PVMFProtocolEngineNode::SetClientPlayBackClock(OsclClock* aClientClock)
+PVMFStatus PVMFProtocolEngineNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
     if (iDownloadControl)
     {
@@ -2269,9 +2312,9 @@
     // just use sourcedata to differentiate ms http streaming and download for a short-term solution
     if (!aSourceData)
         return PVHTTPPROTOCOL_MS_HTTP_STREAMING;
-    else if (aSourceFormat == PVMF_DATA_SOURCE_PVX_FILE)
+    else if (aSourceFormat == PVMF_MIME_DATA_SOURCE_PVX_FILE)
         return PVHTTPPROTOCOL_FASTTRACK_DOWNLOAD;
-    else if (aSourceFormat == PVMF_DATA_SOURCE_HTTP_URL)
+    else if (aSourceFormat == PVMF_MIME_DATA_SOURCE_HTTP_URL)
     {
         return PVHTTPPROTOCOL_PROGRESSIVE_DOWNLOAD;
     }
@@ -2284,27 +2327,27 @@
 {
     OSCL_UNUSED_ARG(aFactoryTag);
     OSCL_UNUSED_ARG(aFactoryConfig);
-    iInterfacingObjectContainer.setDataStreamFactory(&aFactory);
+    iInterfacingObjectContainer->setDataStreamFactory(&aFactory);
 }
 
 
 // From PVMFProtocolEngineNodeExtensionInterface
 PVMFStatus PVMFProtocolEngineNode::GetHTTPHeader(uint8*& aHeader, uint32& aHeaderLen)
 {
-    iInterfacingObjectContainer.getHTTPHeader(aHeader, aHeaderLen);
+    iInterfacingObjectContainer->getHTTPHeader(aHeader, aHeaderLen);
     return PVMFSuccess;
 }
 
 bool PVMFProtocolEngineNode::GetSocketConfig(OSCL_String &aPortConfig)
 {
     if (CheckUsingProxy(aPortConfig)) return true;
-    return GetSocketConfigImp(iInterfacingObjectContainer.getURIObject(), aPortConfig);
+    return GetSocketConfigImp(iInterfacingObjectContainer->getURIObject(), aPortConfig);
 }
 
 bool PVMFProtocolEngineNode::GetSocketConfigForLogging(OSCL_String &aPortConfig)
 {
     if (CheckUsingProxy(aPortConfig)) return true;
-    return GetSocketConfigImp(iInterfacingObjectContainer.getLoggingURIObject(), aPortConfig);
+    return GetSocketConfigImp(iInterfacingObjectContainer->getLoggingURIObject(), aPortConfig);
 }
 
 bool PVMFProtocolEngineNode::GetSocketConfigImp(const INetURI &aURI, OSCL_String &aPortConfig)
@@ -2325,7 +2368,7 @@
 
 bool PVMFProtocolEngineNode::ComposeSocketConfig(OSCL_String &aServerAddr, const uint32 aPortNum, OSCL_String &aPortConfig)
 {
-    // compose port config string: "TCP/remote_address=pvs.pv.com;remote_port=554"
+    // compose port config string: "TCP/remote_address=pvserveroha.pv.com;remote_port=554"
     uint32 tempBufSize = aServerAddr.get_size() + 64;
     OsclMemAllocator alloc;
     char *buffer = (char*)alloc.allocate(tempBufSize);
@@ -2349,8 +2392,8 @@
     uint32 aProxyPort = 0;
     OSCL_HeapString<OsclMemAllocator> aProxyName;
     if (!getProxy(aProxyName, aProxyPort)) return false;
-    iInterfacingObjectContainer.getURIObject().setUsAbsoluteURI();
-    iInterfacingObjectContainer.getLoggingURIObject().setUsAbsoluteURI();
+    iInterfacingObjectContainer->getURIObject().setUsAbsoluteURI();
+    iInterfacingObjectContainer->getLoggingURIObject().setUsAbsoluteURI();
     return ComposeSocketConfig(aProxyName, aProxyPort, aPortConfig);
 }
 
@@ -2380,7 +2423,7 @@
 
 void PVMFProtocolEngineNode::SetLoggingURL(OSCL_wString& aSourceURL)
 {
-    iInterfacingObjectContainer.setLoggingURI(aSourceURL);
+    iInterfacingObjectContainer->setLoggingURI(aSourceURL);
 }
 
 void PVMFProtocolEngineNode::SetNetworkTimeout(const uint32 aTimeout)
@@ -2411,6 +2454,8 @@
 
 void PVMFProtocolEngineNode::setFormatDownloadSupportInterface(PVMFFormatProgDownloadSupportInterface* download_support_interface)
 {
+    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::setFormatDownloadSupportInterface() IN, download_support_interface=0x%x", download_support_interface));
+
     if (iDownloadControl && iDownloadProgess)
     {
         iDownloadControl->setSupportObject((OsclAny *)download_support_interface, DownloadControlSupportObjectType_SupportInterface);
@@ -2429,21 +2474,21 @@
     if (iDownloadProgess) iDownloadProgess->setClipDuration(aClipDurationMsec);
 }
 
-OsclSharedPtr<OsclClock> PVMFProtocolEngineNode::getDownloadProgressClock()
+OsclSharedPtr<PVMFMediaClock> PVMFProtocolEngineNode::getDownloadProgressClock()
 {
-    OsclSharedPtr<OsclClock> clock;
+    OsclSharedPtr<PVMFMediaClock> clock;
     iDownloadControl->getDownloadClock(clock);
     return clock;
 }
 
 void PVMFProtocolEngineNode::requestResumeNotification(const uint32 currentNPTReadPosition, bool& aDownloadComplete)
 {
-    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::requestResumeNotification(), currentNPTReadPosition=%d", currentNPTReadPosition));
+    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::requestResumeNotification() IN, currentNPTReadPosition=%d", currentNPTReadPosition));
 
     bool needSendUnderflowEvent = false;
     iDownloadControl->requestResumeNotification(currentNPTReadPosition, aDownloadComplete, needSendUnderflowEvent);
-    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::requestResumeNotification(), after iDownloadControl->requestResumeNotification(), aDownloadComplete=%d, needSendUnderflowEvent=%d",
-                     aDownloadComplete, needSendUnderflowEvent));
+    LOGINFODATAPATH((0, "PVMFProtocolEngineNode::requestResumeNotification(), after iDownloadControl->requestResumeNotification(), currentNPTReadPosition=%d, needSendUnderflowEvent=%d, aDownloadComplete=%d",
+                     currentNPTReadPosition, (uint32)needSendUnderflowEvent, (uint32)aDownloadComplete));
 
     // report underflow event for download incomplete
     // but only send it once, for multiple back to back requestResumeNotification
@@ -2451,7 +2496,7 @@
 
     if (aDownloadComplete)  // end of processing
     {
-        EndOfDataProcessingInfo *aInfo = iInterfacingObjectContainer.getEOPInfo();
+        EndOfDataProcessingInfo *aInfo = iInterfacingObjectContainer->getEOPInfo();
         aInfo->clear();
         aInfo->iSendResumeNotification = true;
         PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_EndOfProcessing, (OsclAny*)aInfo);
@@ -2468,7 +2513,10 @@
 {
     LOGINFODATAPATH((0, "PVMFProtocolEngineNode::cancelResumeNotification"));
 
-    iDownloadControl->cancelResumeNotification();
+    if (iDownloadControl != NULL)
+    {
+        iDownloadControl->cancelResumeNotification();
+    }
 }
 
 bool PVMFProtocolEngineNode::SendPortMediaCommand(PVMFProtocolEnginePort *aPort, PVUid32 aCmdId, const bool isForLogging)
@@ -2485,27 +2533,53 @@
     // Convert to media message and send it out
     PVMFSharedMediaMsgPtr mediaMsgOut;
     convertToPVMFMediaCmdMsg(mediaMsgOut, aCmdPtr);
-    if (aPort->QueueOutgoingMsg(mediaMsgOut) != PVMFSuccess) return false;
+    PVMFStatus status = aPort->QueueOutgoingMsg(mediaMsgOut);
+    if (status < PVMFSuccess) return false;
+    if (status == PVMFSuccessOutgoingMsgSent)
+    {
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::SendPortMediaCommand() - Msg queued and sent successfully!, Port=0x%x", aPort));
+        RerunForPostProcessAfterOutgoingMsgSent(aPort, mediaMsgOut);
+    }
 
+    LogPortMediaCmdQueued(aPort, aCmdId);
+    return true;
+}
+
+void PVMFProtocolEngineNode::RerunForPostProcessAfterOutgoingMsgSent(PVMFProtocolEnginePort *aPort, PVMFSharedMediaMsgPtr &aMsg)
+{
+    // form PVProtocolEngineNodeInternalEventType_OutgoingMsgQueuedAndSentSuccessfully event
+    OutgoingMsgSentSuccessInfo aInfo(aPort, aMsg);
+    OutgoingMsgSentSuccessInfoVec *aVec = iInterfacingObjectContainer->getOutgoingMsgSentSuccessInfoVec();
+    aVec->push_back(aInfo);
+    PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_OutgoingMsgQueuedAndSentSuccessfully,
+            (OsclAny*)aVec);
+    iInternalEventQueue.push_back(aEvent);
+    SetProcessingState(ProcessingState_NormalDataflow);
+    RunIfNotReady();
+}
+
+void PVMFProtocolEngineNode::LogPortMediaCmdQueued(PVMFProtocolEnginePort *aPort, PVUid32 aCmdId)
+{
     // log message
     if (aCmdId == PVMF_MEDIA_CMD_SOCKET_CONNECT_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::SendPortMediaCommand() - RECONNECT SENT, Port=0x%x", aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::LogPortMediaCmdQueued() - RECONNECT SENT, Port=0x%x", aPort));
     }
     else if (aCmdId == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::SendPortMediaCommand() - EOS SENT, Port=0x%x", aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::LogPortMediaCmdQueued() - EOS SENT, Port=0x%x", aPort));
     }
     else if (aCmdId == PVMF_MEDIA_CMD_RE_CONFIG_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::SendPortMediaCommand() - RE_CONFIG SENT, Port=0x%x", aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::LogPortMediaCmdQueued() - RE_CONFIG SENT, Port=0x%x", aPort));
     }
     else if (aCmdId == PVMF_MEDIA_CMD_SOCKET_DISCONNECT_FORMAT_ID)
     {
-        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::SendPortMediaCommand() - DISCONNECT SENT, Port=0x%x", aPort));
+        LOGINFODATAPATH((0, "PVMFProtocolEngineNode::LogPortMediaCmdQueued() - DISCONNECT SENT, Port=0x%x", aPort));
     }
 
-    return true;
+    OSCL_UNUSED_ARG(aPort); // to avoid warning of unused variable 'aPort'
+
 }
 
 bool PVMFProtocolEngineNode::CheckFormatSpecificInfoForMediaCommand(PVMFSharedMediaCmdPtr &aCmdPtr, PVUid32 aCmdId, const bool isForLogging)
@@ -2515,9 +2589,9 @@
     // for socket recconnect command, set port config as format specific info
     bool needAttachFormatSpecificInfo = false;
     OSCL_HeapString<OsclMemAllocator> aPortConfig;
-    if (iInterfacingObjectContainer.getCurrNumRedirectTrials() > 0 || iInterfaceState == EPVMFNodePaused)
+    if (iInterfacingObjectContainer->getCurrNumRedirectTrials() > 0 || iInterfaceState == EPVMFNodePaused)
     {
-        bool hasLoggingUrl = !iInterfacingObjectContainer.getLoggingURIObject().empty();
+        bool hasLoggingUrl = !iInterfacingObjectContainer->getLoggingURIObject().empty();
         if (isForLogging && hasLoggingUrl)
         {
             if (!GetSocketConfigForLogging(aPortConfig)) return false;
@@ -2528,9 +2602,9 @@
         }
         needAttachFormatSpecificInfo = true;
     }
-    else if (iInterfacingObjectContainer.isDownloadStreamingDone())
+    else if (iInterfacingObjectContainer->isDownloadStreamingDone())
     {
-        bool hasLoggingUrl = !iInterfacingObjectContainer.getLoggingURIObject().empty();
+        bool hasLoggingUrl = !iInterfacingObjectContainer->getLoggingURIObject().empty();
         if (hasLoggingUrl)
         {
             if (!GetSocketConfigForLogging(aPortConfig)) return false;
@@ -2575,7 +2649,7 @@
         iNode(aNode),
         iInterfacingObjectContainer(NULL)
 {
-    if (aNode) iInterfacingObjectContainer = &aNode->iInterfacingObjectContainer;
+    if (aNode) iInterfacingObjectContainer = aNode->iInterfacingObjectContainer;
     iDataPathLogger = PVLogger::GetLoggerObject(NODEDATAPATHLOGGER_TAG);
 }
 
@@ -2583,6 +2657,7 @@
 {
     if (!iNode->iProtocol			||
             !iNode->iNodeOutput			||
+            !iInterfacingObjectContainer ||
             iInterfacingObjectContainer->getURIObject().empty() ||
             !iInterfacingObjectContainer->getDataStreamFactory() ||
             !iNode->iPortInForData) return false;
@@ -2613,8 +2688,8 @@
 
     // start data flow
     // if the current socket connection is down, then do socket reconnect
-    bool needSocketReconnect = !iNode->iInterfacingObjectContainer.isSocketConnectionUp();
-    iNode->StartDataFlowByCommand(needSocketReconnect);
+    bool needSocketReconnect = !iNode->iInterfacingObjectContainer->isSocketConnectionUp();
+    startDataFlowByCommand(needSocketReconnect);
 
     return PVMFPending;
 }
@@ -2634,6 +2709,79 @@
     return true;
 }
 
+PVMFStatus ProtocolContainer::doStop()
+{
+    // send socket disconnect command if necessary
+    sendSocketDisconnectCmd();
+
+    // disable sending logging message, but try to disconnect socket
+    // use end of processing event to streamline all end of processing cases for stop
+    EndOfDataProcessingInfo *aEOPInfo = iNode->iInterfacingObjectContainer->getEOPInfo();
+    aEOPInfo->clear();
+    aEOPInfo->iForceStop = true;
+    PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_EndOfProcessing, (OsclAny*)aEOPInfo);
+    iNode->DispatchInternalEvent(&aEvent);
+
+    return PVMFSuccess;
+}
+
+void ProtocolContainer::sendSocketDisconnectCmd()
+{
+    if (iNode->SendPortMediaCommand(iNode->iPortInForData, PVMF_MEDIA_CMD_SOCKET_DISCONNECT_FORMAT_ID))
+    {
+        if (iNode->iPortInForData->Send())
+        {
+            LOGINFODATAPATH((0, "ProtocolContainer::doStop()->sendSocketDisconnectCmd(), Send() SUCCESS: MsgID=%d(SOCKET DISCONNECT)", (uint32)PVMF_MEDIA_CMD_SOCKET_DISCONNECT_FORMAT_ID));
+        }
+    }
+}
+
+void ProtocolContainer::startDataFlowByCommand(const bool needDoSocketReconnect)
+{
+    // flush out existing data at this point
+    checkEOSMsgFromInputPort();
+    iNode->iDataInQueue.clear();
+    iNode->ClearPorts(); // clear any queued messages in ports
+
+    // cancel all the existing timers
+    iNode->iNodeTimer->clear();
+
+    // disable info update at this point, will be enabled when new response comes in
+    enableInfoUpdate(false);
+
+    // socket reconnect
+    if (needDoSocketReconnect) reconnectSocket();
+
+    rescheduleNewDataFlow();
+}
+
+void ProtocolContainer::checkEOSMsgFromInputPort()
+{
+    if (iNode->iPortInForData->IncomingMsgQueueSize() == 0)  return;
+
+    // input port has media message
+    while (iNode->iPortInForData->IncomingMsgQueueSize() > 0)
+    {
+        PVMFSharedMediaMsgPtr msg;
+        PVMFStatus status = iNode->iPortInForData->DequeueIncomingMsg(msg);
+        if (status != PVMFSuccess) continue;
+        if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+        {
+            iInterfacingObjectContainer->updateSocketConnectFlags(true);
+            return;
+        }
+    }
+}
+
+void ProtocolContainer::rescheduleNewDataFlow()
+{
+    PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_StartDataflowByCommand);
+    iNode->iInternalEventQueue.push_back(aEvent);
+    iNode->iProcessingState = ProcessingState_NormalDataflow;
+    iNode->iInterfacingObjectContainer->setInputDataUnwanted(false);
+    iNode->RunIfNotReady();
+}
+
 void ProtocolContainer::doClear(const bool aNeedDelete)
 {
     // clear ports
@@ -2641,8 +2789,8 @@
 
     // Clean up the internal stuff
     iNode->iDataInQueue.clear();
-    iNode->iInternalEventQueue.clear();
-    iNode->iInterfacingObjectContainer.clear();
+    clearInternalEventQueue();
+    iNode->iInterfacingObjectContainer->clear();
     if (iNode->iNodeTimer) iNode->iNodeTimer->clear();
     //if(iNode->iDownloadControl) iNode->iDownloadControl->clear();
 }
@@ -2661,8 +2809,8 @@
 
     // Clean up the internal stuff
     iNode->iDataInQueue.clear();
-    iNode->iInternalEventQueue.clear();
-    //iNode->iInterfacingObjectContainer.clear();
+    clearInternalEventQueue();
+    //iNode->iInterfacingObjectContainer->clear();
     if (iNode->iNodeTimer) iNode->iNodeTimer->clear();
     if (iNode->iDownloadControl) iNode->iDownloadControl->clear();
     if (iNode->iEventReport) iNode->iEventReport->clear();
@@ -2671,6 +2819,13 @@
     if (iNode->iProtocol) iNode->iProtocol->sendRequest();
 }
 
+void ProtocolContainer::clearInternalEventQueue()
+{
+    iNode->iInternalEventQueue.clear();
+    OutgoingMsgSentSuccessInfoVec *aVec = iInterfacingObjectContainer->getOutgoingMsgSentSuccessInfoVec();
+    aVec->clear();
+}
+
 bool ProtocolContainer::reconnectSocket(const bool aForceSocketReconnect)
 {
     if (!aForceSocketReconnect)
@@ -2694,7 +2849,7 @@
     else   // EOS packet hasn't been received, so re-connect socket
     {
         bool aForceSocketReconnect = false;
-        if (!iNode->iInterfacingObjectContainer.isPrevSocketConnectionUp())
+        if (!iNode->iInterfacingObjectContainer->isPrevSocketConnectionUp())
         {
             // the situation is, previous connection is down and the current connection is down.
             // then force reconnect
@@ -2718,6 +2873,11 @@
 
 bool ProtocolContainer::createProtocolObjects()
 {
+    // create iInterfacingObjectContainer
+    iNode->iInterfacingObjectContainer = OSCL_NEW(InterfacingObjectContainer, ());
+    if (!iNode->iInterfacingObjectContainer) return false;
+    iInterfacingObjectContainer = iNode->iInterfacingObjectContainer;
+
     // create iPortConfigFSInfoAlloc for redirect port config
     iNode->iPortConfigFSInfoAlloc = OSCL_NEW(OsclRefCounterMemFragAlloc, (&iNode->iPortConfigMemPool));
     if (!iNode->iPortConfigFSInfoAlloc) return false;
@@ -2738,6 +2898,8 @@
     iNode->iNodeTimer->set(SERVER_RESPONSE_TIMER_ID);
     iNode->iNodeTimer->set(SERVER_INACTIVITY_TIMER_ID);
     iNode->iNodeTimer->set(SERVER_RESPONSE_TIMER_ID_FOR_STOPEOS_LOGGING);
+    iNode->iNodeTimer->set(WALL_CLOCK_TIMER_ID);
+    iNode->iNodeTimer->set(BUFFER_STATUS_TIMER_ID);
     return true;
 }
 bool ProtocolContainer::createEventHandlers()
@@ -2758,6 +2920,8 @@
     if (!iNode->iEventHandlers[6]) return false;
     iNode->iEventHandlers[7] = OSCL_NEW(CheckResumeNotificationHandler, (iNode));
     if (!iNode->iEventHandlers[7]) return false;
+    iNode->iEventHandlers[8] = OSCL_NEW(OutgoingMsgSentSuccessHandler, (iNode));
+    if (!iNode->iEventHandlers[8]) return false;
 
     iNode->iEventHandlers[EVENT_HANDLER_TOTAL-1] = OSCL_NEW(NormalDataFlowHandler, (iNode));
     if (!iNode->iEventHandlers[EVENT_HANDLER_TOTAL-1]) return false;
@@ -2766,22 +2930,24 @@
 
 void ProtocolContainer::deleteProtocolObjects()
 {
-    if (iNode->iPortConfigFSInfoAlloc)	OSCL_DELETE(iNode->iPortConfigFSInfoAlloc);
+    if (iNode->iInterfacingObjectContainer)	OSCL_DELETE(iNode->iInterfacingObjectContainer);
+    iNode->iInterfacingObjectContainer = NULL;
+    if (iNode->iPortConfigFSInfoAlloc)		OSCL_DELETE(iNode->iPortConfigFSInfoAlloc);
     iNode->iPortConfigFSInfoAlloc = NULL;
-    if (iNode->iNodeTimer)				OSCL_DELETE(iNode->iNodeTimer);
+    if (iNode->iNodeTimer)					OSCL_DELETE(iNode->iNodeTimer);
     iNode->iNodeTimer			  = NULL;
 
-    if (iNode->iProtocol)				OSCL_DELETE(iNode->iProtocol);
+    if (iNode->iProtocol)					OSCL_DELETE(iNode->iProtocol);
     iNode->iProtocol			  = NULL;
-    if (iNode->iNodeOutput)				OSCL_DELETE(iNode->iNodeOutput);
+    if (iNode->iNodeOutput)					OSCL_DELETE(iNode->iNodeOutput);
     iNode->iNodeOutput			  = NULL;
-    if (iNode->iDownloadControl)			OSCL_DELETE(iNode->iDownloadControl);
+    if (iNode->iDownloadControl)				OSCL_DELETE(iNode->iDownloadControl);
     iNode->iDownloadControl		  = NULL;
-    if (iNode->iDownloadProgess)			OSCL_DELETE(iNode->iDownloadProgess);
+    if (iNode->iDownloadProgess)				OSCL_DELETE(iNode->iDownloadProgess);
     iNode->iDownloadProgess		  = NULL;
-    if (iNode->iUserAgentField)			OSCL_DELETE(iNode->iUserAgentField);
+    if (iNode->iUserAgentField)				OSCL_DELETE(iNode->iUserAgentField);
     iNode->iUserAgentField		  = NULL;
-    if (iNode->iEventReport)				OSCL_DELETE(iNode->iEventReport);
+    if (iNode->iEventReport)					OSCL_DELETE(iNode->iEventReport);
     iNode->iEventReport			  = NULL;
 
     for (uint32 i = 0; i < EVENT_HANDLER_TOTAL; i++)
@@ -2805,8 +2971,8 @@
 bool ProtocolContainer::ignoreThisTimeout(const int32 timerID)
 {
     // check the end processing status: EOS recved and whole session is done
-    if (iNode->iInterfacingObjectContainer.isEOSAchieved() &&
-            iNode->iInterfacingObjectContainer.isWholeSessionDone()) return true;
+    if (iNode->iInterfacingObjectContainer->isEOSAchieved() &&
+            iNode->iInterfacingObjectContainer->isWholeSessionDone()) return true;
 
     // Next, all focus on checking server inactivity timeout
     if (timerID != (int32)SERVER_INACTIVITY_TIMER_ID) return false;
@@ -2832,7 +2998,7 @@
 
 bool ProtocolContainer::handleTimeoutErr(const int32 timerID)
 {
-    if (iNode->iInterfacingObjectContainer.isDownloadStreamingDone() ||
+    if (iNode->iInterfacingObjectContainer->isDownloadStreamingDone() ||
             iNode->iInterfaceState == EPVMFNodePaused) return false;
 
     int32 timeoutErr = PVMFErrTimeout;
@@ -2847,20 +3013,21 @@
 
 bool ProtocolContainer::handleProtocolStateComplete(PVProtocolEngineNodeInternalEvent &aEvent, PVProtocolEngineNodeInternalEventHandler *aEventHandler)
 {
-    bool aSessionDone = iNode->iInterfacingObjectContainer.isWholeSessionDone();
-    bool aDownloadStreamingDone = iNode->iInterfacingObjectContainer.isDownloadStreamingDone();
+    bool aSessionDone = iNode->iInterfacingObjectContainer->isWholeSessionDone();
+    bool aDownloadStreamingDone = iNode->iInterfacingObjectContainer->isDownloadStreamingDone();
     OSCL_UNUSED_ARG(aDownloadStreamingDone);
-    bool aEOSArrived = iNode->iInterfacingObjectContainer.isEOSAchieved();
+    bool aEOSArrived = iNode->iInterfacingObjectContainer->isEOSAchieved();
 
-    iNode->iInterfacingObjectContainer.setInputDataUnwanted();
+    iNode->iInterfacingObjectContainer->setInputDataUnwanted();
     if (aSessionDone)
     {
         // flush all the remaining output
         iNode->iNodeOutput->flushData();
         iNode->iNodeTimer->clear();
-        if (aEOSArrived && iNode->iInterfacingObjectContainer.getOutputPortConnect())
+        if (aEOSArrived && iNode->iInterfacingObjectContainer->getOutputPortConnect())
         {
-            return iNode->iProtocolContainer->doEOS(); // true EOS
+            iNode->iProtocolContainer->doEOS(); // true EOS
+            return aEventHandler->completePendingCommand(aEvent);
         }
     }
     iNode->iProcessingState = ProcessingState_Idle;
@@ -2890,8 +3057,9 @@
             PVUuid uuid = PVProtocolEngineNodeErrorEventTypesUUID;
             int32 basePVMFErrorCode = getBasePVMFErrorReturnCode(errorCode);
             char *errEventData = NULL;
-            handleAuthenErrResponse(errorCode, errEventData);
-            iNode->CommandComplete(iNode->iCurrentCommand, iNode->iCurrentCommand.front(), basePVMFErrorCode, errEventData, &uuid, &errorCode);
+            uint32 errEventDataLen = 0;
+            handleErrResponse(basePVMFErrorCode, errorCode, errEventData, errEventDataLen);
+            iNode->CommandComplete(iNode->iCurrentCommand, iNode->iCurrentCommand.front(), basePVMFErrorCode, errEventData, &uuid, &errorCode, errEventDataLen);
             LOGINFODATAPATH((0, "PVProtocolEngineNodeInternalEventHandler::completePendingCommandWithError(), basePVMFErrorCode=%d, extensionErrorCode=%d",
                              basePVMFErrorCode, errorCode));
         }
@@ -2905,8 +3073,9 @@
         {
             int32 basePVMFErrorCode = getBasePVMFErrorReturnCode(errorCode, false); // false for error event
             char *errEventData = NULL;
-            handleAuthenErrResponse(errorCode, errEventData);
-            iNode->ReportErrorEvent(basePVMFErrorCode, errEventData, errorCode);
+            uint32 eventDataLen = 0;
+            handleErrResponse(basePVMFErrorCode, errorCode, errEventData, eventDataLen);
+            iNode->ReportErrorEvent(basePVMFErrorCode, errEventData, errorCode, eventDataLen);
             LOGINFODATAPATH((0, "PVProtocolEngineNodeInternalEventHandler::completePendingCommandWithError(), basePVMFErrorCode=%d, extensionErrorCode=%d",
                              basePVMFErrorCode, errorCode));
         }
@@ -2930,8 +3099,6 @@
     if (!isForCommandComplete) pvmfReturnCode = PVMFErrProcessing; // if not for command complete, should for error event
     if (iNode->iProtocolContainer->isHTTP409ForLowDiskSpace(errorCode)) pvmfReturnCode = PVMFLowDiskSpace;
 
-    LOGERRORDATAPATH((0, "PVProtocolEngineNodeInternalEventHandler::getBasePVMFErrorReturnCode(), error code %d", errorCode));
-
     switch (errorCode)
     {
         case PVProtocolEngineNodeErrorProcessingFailure_TimeoutServerNoResponce:
@@ -2941,8 +3108,20 @@
 
         case PVProtocolEngineNodeErrorHTTPErrorCode401:
         case PVProtocolEngineNodeErrorHTTPErrorCode407:
+        case PVProtocolEngineNodeErrorHTTPErrorCode401_InvalidRealm:
             pvmfReturnCode = PVMFErrHTTPAuthenticationRequired;
             break;
+
+        case PVProtocolEngineNodeErrorHTTPErrorCode401_UnsupportedAuthenticationType:
+            pvmfReturnCode = PVMFErrNotSupported;
+            break;
+
+        case PVProtocolEngineNodeErrorHTTPRedirect_TrialsExceedLimit:
+            if (iNode->iInterfacingObjectContainer->getNumRedirectTrials() == 0)
+            {
+                pvmfReturnCode = PVMFErrRedirect;
+            }
+            break;
         default:
             break;
     }
@@ -2950,14 +3129,41 @@
     return pvmfReturnCode;
 }
 
-void PVProtocolEngineNodeInternalEventHandler::handleAuthenErrResponse(int32 &aErrCode, char* &aEventData)
+void PVProtocolEngineNodeInternalEventHandler::handleErrResponse(int32 &aBaseCode, int32 &errCode, char* &aEventData, uint32 &aEventDataLen)
+{
+    if (aBaseCode == PVMFErrRedirect)
+    {
+        handleRedirectErrResponse(aEventData, aEventDataLen);
+    }
+    else
+    {
+        handleAuthenErrResponse(errCode, aEventData, aEventDataLen);
+        aBaseCode = getBasePVMFErrorReturnCode(errCode);
+    }
+}
+
+void PVProtocolEngineNodeInternalEventHandler::handleAuthenErrResponse(int32 &aErrCode, char* &aEventData, uint32 &aEventDataLen)
 {
     aEventData = NULL;
+    aEventDataLen = 0;
     if (aErrCode == PVProtocolEngineNodeErrorHTTPErrorCode401)
     {
+        if (false == iNode->iProtocol->isServerSendAuthenticationHeader())
+        {
+            aErrCode = PVProtocolEngineNodeErrorHTTPErrorCode401_NoAuthenticationHeader;
+            return;
+        }
+
+        if (false == iNode->iProtocol->isServerSupportBasicAuthentication())
+        {
+            aErrCode = PVProtocolEngineNodeErrorHTTPErrorCode401_UnsupportedAuthenticationType;
+            return;
+        }
+
         if (iNode->iProtocol->getAuthenInfo(iAuthenInfoRealm))
         {
             aEventData = (char*)iAuthenInfoRealm.get_cstr();
+            aEventDataLen = iAuthenInfoRealm.get_size() + 1; //Incremented by one to save c string terminating char ('\0')
         }
         else
         {
@@ -2966,6 +3172,21 @@
     }
 }
 
+void PVProtocolEngineNodeInternalEventHandler::handleRedirectErrResponse(char* &aEventData, uint32 &aEventDataLen)
+{
+    aEventData = NULL;
+    aEventDataLen = 0;
+    // set the new url into info event
+    OSCL_HeapString<OsclMemAllocator> newUrl;
+    iNode->iProtocol->getRedirectURI(newUrl);
+
+    // then set this value
+    iNode->iInterfacingObjectContainer->setURI(newUrl, true);
+    iNode->iProtocol->setURI(iNode->iInterfacingObjectContainer->getURIObject());
+
+    aEventData = (char*)iNode->iInterfacingObjectContainer->getURIObject().getURI().get_cstr();
+    aEventDataLen = iNode->iInterfacingObjectContainer->getURIObject().getURI().get_size() + 1;
+}
 
 inline bool PVProtocolEngineNodeInternalEventHandler::isCurrEventMatchCurrPendingCommand(uint32 aCurrEventId)
 {
@@ -3014,11 +3235,11 @@
 bool PVProtocolEngineNodeInternalEventHandler::isBeingStopped(const int32 aStatus)
 {
     // stopped, stop command is completed and node state is changed to prepared state
-    if (iNode->iInterfacingObjectContainer.isWholeSessionDone() &&
+    if (iNode->iInterfacingObjectContainer->isWholeSessionDone() &&
             iNode->iInterfaceState == EPVMFNodePrepared) return true;
 
     // being stopped, stop command is pending plus protcol state complete
-    return (iNode->iInterfacingObjectContainer.isWholeSessionDone() &&
+    return (iNode->iInterfacingObjectContainer->isWholeSessionDone() &&
             isStopCmdPending() &&
             isProtocolStateComplete(aStatus));
 }
@@ -3094,17 +3315,17 @@
 {
     bool isInfoEvent = true;
     int32 errCode = parseServerResponseCode(aErrorCode, isInfoEvent);
-    uint32 numRedirectTrials = iNode->iInterfacingObjectContainer.getNumRedirectTrials();
-    uint32 numCurrRedirectTrials = iNode->iInterfacingObjectContainer.getCurrNumRedirectTrials();
+    uint32 numRedirectTrials = iNode->iInterfacingObjectContainer->getNumRedirectTrials();
+    uint32 numCurrRedirectTrials = iNode->iInterfacingObjectContainer->getCurrNumRedirectTrials();
 
     if (isInfoEvent && ++numCurrRedirectTrials <= numRedirectTrials)
     {
-        iNode->iInterfacingObjectContainer.setCurrNumRedirectTrials(numCurrRedirectTrials);
+        iNode->iInterfacingObjectContainer->setCurrNumRedirectTrials(numCurrRedirectTrials);
 
         if (handleRedirect())
         {
             // set the new url into info event
-            OSCL_HeapString<OsclMemAllocator> url(iNode->iInterfacingObjectContainer.getURIObject().getURI());
+            OSCL_HeapString<OsclMemAllocator> url(iNode->iInterfacingObjectContainer->getURIObject().getURI());
             iNode->ReportInfoEvent(PVMFInfoRemoteSourceNotification, (OsclAny*)(url.get_cstr()), errCode);
             return 0;
         }
@@ -3128,7 +3349,8 @@
     isInfoEvent = true;
     int32 errCode = aErrorCode;
     // redirect code 3xx
-    if (errCode >= 300 && errCode < 400)
+    if (errCode >= (int32)PROTOCOLENGINE_REDIRECT_STATUS_CODE_START &&
+            errCode <= (int32)PROTOCOLENGINE_REDIRECT_STATUS_CODE_END)
     {
         errCode += PVMFPROTOCOLENGINENODEInfo_Redirect;
     }
@@ -3162,8 +3384,8 @@
     if (iNode->iProtocol->getRedirectURI(newUrl) && newUrl.get_size() > 0)
     {
         // then set info to protocol
-        iNode->iInterfacingObjectContainer.setURI(newUrl, true);
-        iNode->iProtocol->setURI(iNode->iInterfacingObjectContainer.getURIObject());
+        iNode->iInterfacingObjectContainer->setURI(newUrl, true);
+        iNode->iProtocol->setURI(iNode->iInterfacingObjectContainer->getURIObject());
         iNode->iProtocolContainer->reconnectSocket();
         // Activate so processing will continue
         iNode->iEventReport->startRealDataflow();
@@ -3180,21 +3402,26 @@
 
     // get Http header
     OUTPUT_DATA_QUEUE aHttpHeader = *((OUTPUT_DATA_QUEUE*)aEvent.iEventData);
-    uint32 headerLength = iNode->iInterfacingObjectContainer.setHttpHeader(aHttpHeader);
+    uint32 headerLength = iNode->iInterfacingObjectContainer->setHttpHeader(aHttpHeader);
+    bool status = true;
     if (iNode->iProtocol && headerLength > 0)
     {
         uint32 length = iNode->iProtocol->getContentLength();
-        iNode->iInterfacingObjectContainer.setFileSize(length);
+        iNode->iInterfacingObjectContainer->setFileSize(length);
         iNode->iNodeOutput->setContentLength(length);
-        if (!iNode->iProtocolContainer->downloadUpdateForHttpHeaderAvailable()) return false;
+        status = iNode->iProtocolContainer->downloadUpdateForHttpHeaderAvailable();
     }
 
     // check PVMFInfoContentLength, PVMFErrContentTooLarge and PVMFInfoContentTruncated before completing the command
     iNode->iEventReport->checkContentInfoEvent(PROCESS_SUCCESS);
 
     // complete start command if it is not completed
-    if (completePendingCommand(aEvent)) iNode->iEventReport->startRealDataflow();
-    return true;
+    if (completePendingCommand(aEvent))
+    {
+        iNode->iEventReport->startRealDataflow();
+    }
+
+    return status;
 }
 
 bool FirstPacketAvailableHandler::handle(PVProtocolEngineNodeInternalEvent &aEvent)
@@ -3219,7 +3446,6 @@
         *aFirstSeqNumAfterSeekOrSwitch = aFirstPacketNumber;
 
         // send RE_CONFIG port command or complete seek command
-
         if (aCmd.iCmd == PVPROTOCOLENGINE_NODE_CMD_BITSTREAM_SWITCH)
         {
             // send RE_CONFIG port command
@@ -3249,9 +3475,9 @@
 
 bool ProtocolStateCompleteHandler::handle(PVProtocolEngineNodeInternalEvent &aEvent)
 {
-    bool aSessionDone = iNode->iInterfacingObjectContainer.isWholeSessionDone();
-    bool aDownloadStreamingDone = iNode->iInterfacingObjectContainer.isDownloadStreamingDone();
-    bool aEOSArrived = iNode->iInterfacingObjectContainer.isEOSAchieved();
+    bool aSessionDone = iNode->iInterfacingObjectContainer->isWholeSessionDone();
+    bool aDownloadStreamingDone = iNode->iInterfacingObjectContainer->isDownloadStreamingDone();
+    bool aEOSArrived = iNode->iInterfacingObjectContainer->isEOSAchieved();
 
     LOGINFODATAPATH((0, "ProtocolStateCompleteHandler::handle() : iNode->iInterfaceState = %d, sessionDone=%d,DownloadStreamingDone=%d,EOSArrived=%d",
                      iNode->iInterfaceState, (uint32)aSessionDone, (uint32)aDownloadStreamingDone, (uint32)aEOSArrived));
@@ -3324,8 +3550,8 @@
 
 inline bool NormalDataFlowHandler::isReadyGotoNextState(const int32 aStatus)
 {
-    return (aStatus == PROCESS_SUCCESS_END_OF_MESSAGE &&
-            !iNode->iInterfacingObjectContainer.isWholeSessionDone() &&
+    return (((aStatus == PROCESS_SUCCESS_END_OF_MESSAGE) || ((aStatus == PROCESS_SUCCESS_END_OF_MESSAGE_TRUNCATED))) &&
+            !iNode->iInterfacingObjectContainer->isWholeSessionDone() &&
             iNode->iInterfaceState != EPVMFNodePaused);
 }
 
@@ -3358,7 +3584,7 @@
 
 bool NormalDataFlowHandler::handleEOSLogging()
 {
-    if (iNode->iInterfacingObjectContainer.isDownloadStreamingDone() &&
+    if (iNode->iInterfacingObjectContainer->isDownloadStreamingDone() &&
             !iSendSocketReconnect &&
             iNode->iPortInForLogging)
     {
@@ -3373,7 +3599,7 @@
         LOGINFODATAPATH((0, "NormalDataFlowHandler::handleEOSLogging() server stop/eos logging response timer starts! timerID=3, timeoutValue=%d",
                          iNode->iNodeTimer->getTimeout(SERVER_RESPONSE_TIMER_ID_FOR_STOPEOS_LOGGING)));
     }
-    else if (!iNode->iInterfacingObjectContainer.isDownloadStreamingDone())
+    else if (!iNode->iInterfacingObjectContainer->isDownloadStreamingDone())
     {
         // reset the flag
         iSendSocketReconnect = false;
@@ -3386,7 +3612,7 @@
     if (aStatus != PROCESS_SUCCESS_GOT_EOS) return false;
 
     if (//(iNode->iInterfaceState==EPVMFNodeStarted || iNode->iInterfaceState==EPVMFNodePrepared || iNode->iInterfaceState==EPVMFNodeInitialized) &&
-        !iNode->iInterfacingObjectContainer.isDownloadStreamingDone())   // only issue socket reconnect during the streaming
+        !iNode->iInterfacingObjectContainer->isDownloadStreamingDone())   // only issue socket reconnect during the streaming
     {
         LOGINFODATAPATH((0, "NormalDataFlowHandler::handleEOS() : status == PROCESS_SUCCESS_GOT_EOS"));
         iNode->iProtocolContainer->doEOS(false);
@@ -3405,7 +3631,7 @@
     if (!isBeingStopped(aStatus)) return false;
 
     // use end of processing event to streamline all end of processing cases for stop
-    EndOfDataProcessingInfo *aEOPInfo = iNode->iInterfacingObjectContainer.getEOPInfo();
+    EndOfDataProcessingInfo *aEOPInfo = iNode->iInterfacingObjectContainer->getEOPInfo();
     aEOPInfo->clear();
     aEOPInfo->iStreamingDone = true;
     PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_EndOfProcessing, (OsclAny*)aEOPInfo);
@@ -3421,6 +3647,7 @@
     if (aInfo->iSendResumeNotification)
     {
         iNode->iDownloadControl->checkResumeNotification();
+        iNode->iNodeTimer->clear();
         LOGINFODATAPATH((0, "EndOfDataProcessingHandler::handle(), send resume notification to parser node, for DOWNLOAD COMPLETE"));
     }
     if (aInfo->iExtraDataComeIn)
@@ -3479,6 +3706,15 @@
     return true;
 }
 
+bool OutgoingMsgSentSuccessHandler::handle(PVProtocolEngineNodeInternalEvent &aEvent)
+{
+    OutgoingMsgSentSuccessInfoVec *aVec = (OutgoingMsgSentSuccessInfoVec*)aEvent.iEventInfo;
+    if (!aVec || aVec->empty()) return false;
+    bool retVal = (iNode->PostProcessForMsgSentSuccess(aVec->front().iPort, aVec->front().iMsg) == PVMFSuccess);
+    if (!aVec->empty()) aVec->erase(aVec->begin());
+    return retVal;
+}
+
 
 ////////////////////////////////////////////////////////////////////////////////////
 //////	PVMFProtocolEngineNodeOutput implementation
@@ -3500,6 +3736,7 @@
     iLogger = PVLogger::GetLoggerObject("PVMFProtocolEngineNode");
     iDataPathLogger = PVLogger::GetLoggerObject(NODEDATAPATHLOGGER_TAG);
     iClockLogger = PVLogger::GetLoggerObject("clock");
+    iMediaDataMemPool.enablenullpointerreturn();
 }
 
 PVMFProtocolEngineNodeOutput::~PVMFProtocolEngineNodeOutput()
@@ -3534,7 +3771,7 @@
 bool PVMFProtocolEngineNodeOutput::createMediaData(PVMFSharedMediaDataPtr &aMediaData, uint32 aRequestSize)
 {
     // check if need to create memory pool
-    int32 errcode = 0;
+    int32 errcode = OsclErrNone;
     if (!iMediaDataAlloc)
     {
         errcode = createMemPool();
@@ -3544,12 +3781,22 @@
     OsclSharedPtr<PVMFMediaDataImpl> mediadataImpl;
     errcode = 0;
     OSCL_TRY(errcode, mediadataImpl = iMediaDataAlloc->allocate(aRequestSize));
-    if (errcode != 0) return false;
+    if (errcode != OsclErrNone) return false;
+
 
     // Then wrap it around with PVMFMediaData
     iMediaData.Unbind();
-    OSCL_TRY(errcode, iMediaData = PVMFMediaData::createMediaData(mediadataImpl, &iMediaDataMemPool));
-    if (errcode != 0) return false;
+
+    errcode = OsclErrNoResources;
+
+    iMediaData = PVMFMediaData::createMediaData(mediadataImpl, &iMediaDataMemPool);
+
+    if (iMediaData.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
+
+    if (errcode != OsclErrNone) return false;
 
     aMediaData = iMediaData;
     return true;
@@ -3562,6 +3809,7 @@
     OSCL_TRY(errcode, iContentDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVHTTPDOWNLOADOUTPUT_CONTENTDATA_POOLNUM)));
     if (errcode || iContentDataMemPool == NULL) return PVMFErrNoMemory;
 
+
     OSCL_TRY(errcode, iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iContentDataMemPool)));
     if (errcode || iMediaDataAlloc == NULL) return PVMFErrNoMemory;
 
@@ -3605,7 +3853,12 @@
                      mediaMsgOut->getSeqNum(), dataSize, aPort));
 
     PVMFStatus status = aPort->QueueOutgoingMsg(mediaMsgOut);
-    return (status == PVMFSuccess);
+    if (status < PVMFSuccess) return false;
+    if (status == PVMFSuccessOutgoingMsgSent)
+    {
+        return iObserver->QueueOutgoingMsgSentSuccess(aPort, mediaMsgOut);
+    }
+    return true;
 }
 
 bool PVMFProtocolEngineNodeOutput::passDownNewOutputData(OUTPUT_DATA_QUEUE &aOutputQueue, OsclAny* aSideInfo)
@@ -3735,7 +3988,7 @@
 EventReporter::EventReporter(PVMFProtocolEngineNode *aNode) : iNode(aNode)
 {
     clear();
-    if (aNode) iInterfacingObjectContainer = &aNode->iInterfacingObjectContainer;
+    if (aNode) iInterfacingObjectContainer = aNode->iInterfacingObjectContainer;
     iDataPathLogger = PVLogger::GetLoggerObject(NODEDATAPATHLOGGER_TAG);
 }
 
@@ -3756,16 +4009,18 @@
 
 // constructor
 InterfacingObjectContainer::InterfacingObjectContainer() :
-        iDownloadFormat(PVMF_DATA_SOURCE_HTTP_URL),
+        iDownloadFormat(PVMF_MIME_DATA_SOURCE_HTTP_URL),
         iDataStreamFactory(NULL),
         iNumBuffersInAllocator(PVHTTPSTREAMINGOUTPUT_CONTENTDATA_POOLNUM),
         iNumRedirectTrials(PVPROTOCOLENGINE_DEFAULT_NUMBER_OF_REDIRECT_TRIALS),
+        iNumBuffersInMediaDataPoolSMCalc(PVHTTPSTREAMINGOUTPUT_CONTENTDATA_POOLNUM),
         iCurrSocketConnection(true),
         iPrevSocketConnection(true),
         iLatestDataPacketNumSent(0),
         iOutputPortConnected(false)
 {
     clear();
+    iOutgoingMsgSentSuccessInfoVec.reserve(PVMF_PROTOCOLENGINE_NODE_COMMAND_VECTOR_RESERVE / 4);
 }
 
 // set and get http header
@@ -3803,6 +4058,10 @@
     alloc.deallocate(buf);
     return true;
 }
+void InterfacingObjectContainer::setNumBuffersInMediaDataPoolSMCalc(uint32 aVal)
+{
+    iNumBuffersInMediaDataPoolSMCalc = aVal;
+}
 
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -3838,7 +4097,7 @@
 {
     if (iWatchdogTimer)
     {
-        OSCL_TEMPLATED_DELETE(iWatchdogTimer, OsclTimer<PVMFProtocolEngineNodeAllocator>, OsclTimer);
+        OSCL_DELETE(iWatchdogTimer);
         iWatchdogTimer = NULL;
     }
 
@@ -3938,6 +4197,10 @@
             return DEFAULT_KEEPALIVE_TIMEOUT_IN_SEC;
         case SERVER_RESPONSE_TIMER_ID_FOR_STOPEOS_LOGGING:
             return DEFAULT_MAX_SERVER_RESPONSE_DURATION_IN_SEC_FOR_STOPEOS_LOGGING;
+        case WALL_CLOCK_TIMER_ID:
+            return DEFAULT_WALLCLOCK_TIMEOUT_IN_SEC;
+        case BUFFER_STATUS_TIMER_ID:
+            return DEFAULT_BUFFER_STATUS_CLOCK_TIMEOUT_IN_SEC;
         default:
             break;
     }
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.h
index 2a58843..936b161 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -96,7 +96,7 @@
 ///////////////////////////////////////////////////////
 
 //Default vector reserve size
-#define PVMF_PROTOCOLENGINE_NODE_COMMAND_VECTOR_RESERVE 10
+#define PVMF_PROTOCOLENGINE_NODE_COMMAND_VECTOR_RESERVE 16
 
 //Starting value for command IDs
 #define PVMF_PROTOCOLENGINE_NODE_COMMAND_ID_START 6000
@@ -208,14 +208,20 @@
 
 // two macros used in the array member and function parameter below
 #define PVHTTPDOWNLOADOUTPUT_CONTENTDATA_CHUNKSIZE 8000
-#define EVENT_HANDLER_TOTAL 9
+#define EVENT_HANDLER_TOTAL 10
 
 enum NetworkTimerType
 {
     SERVER_RESPONSE_TIMER_ID = 0,
     SERVER_INACTIVITY_TIMER_ID,
     SERVER_KEEPALIVE_TIMER_ID,
-    SERVER_RESPONSE_TIMER_ID_FOR_STOPEOS_LOGGING
+    SERVER_RESPONSE_TIMER_ID_FOR_STOPEOS_LOGGING,
+    // handle data processing in case of no data input (PE node will become idle) for download/progressive streaming,
+    // so there should be a way to activate PE node to continue data processing if needed
+    WALL_CLOCK_TIMER_ID,
+    // a timer to report buffer status periodically, say at every up to 2sec, at least buffer status has to be reported
+    // which tells our system is running
+    BUFFER_STATUS_TIMER_ID
 };
 
 enum PVHttpProtocol
@@ -252,6 +258,13 @@
 #endif
 
 
+#if defined(PV_PROTOCOL_ENGINE_NODE_WMHTTPSTREAMING_ENABLED)
+class MsHttpStreamingContainerFactory : public ProtocolContainerFactory
+{
+    public:
+        ProtocolContainer* create(PVMFProtocolEngineNode *aNode = NULL);
+};
+#endif
 
 
 // Forward declarations
@@ -291,7 +304,7 @@
         virtual PVMFStatus doPrepare();							// used in PVMFProtocolEngineNode::doPrepare, the default implementation is for both 3gpp and fasttrack download
         virtual bool doProPrepare()
         {
-            return true;
+            return true;    // used only for fasttrack, invoke the call to generate SDP info.
         }
         virtual int32 doPreStart()
         {
@@ -301,10 +314,7 @@
         {
             return true;
         }
-        virtual PVMFStatus doStop()
-        {
-            return PVMFSuccess;
-        }
+        virtual PVMFStatus doStop();
         virtual bool doEOS(const bool isTrueEOS = true);
         virtual bool doInfoUpdate(const uint32 downloadStatus)
         {
@@ -326,6 +336,7 @@
         {
             return true;
         }
+        virtual void startDataFlowByCommand(const bool needDoSocketReconnect = true);
 
         virtual void doClear(const bool aNeedDelete = false);
         virtual void doStopClear();
@@ -364,6 +375,7 @@
         virtual void handleTimeout(const int32 timerID);
         virtual bool handleProtocolStateComplete(PVProtocolEngineNodeInternalEvent &aEvent, PVProtocolEngineNodeInternalEventHandler *aEventHandler);
 
+        // for fasttrack only
         virtual PVMFStatus getMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo)
         {
             OSCL_UNUSED_ARG(aInfo);
@@ -382,6 +394,7 @@
             return false;
         }
 
+        // for ms http streaming only
         virtual void setLoggingStartInPause(const bool aLoggingStartInPause = true)
         {
             OSCL_UNUSED_ARG(aLoggingStartInPause);
@@ -445,7 +458,12 @@
             OSCL_UNUSED_ARG(timerID);
             return false;
         }
-
+        // called by doStop()
+        virtual void sendSocketDisconnectCmd();
+        // called by handleTimeout()
+        virtual bool ignoreThisTimeout(const int32 timerID);
+        // called by startDataFlowByCommand()
+        void rescheduleNewDataFlow();
 
     private:
         //called by createProtocolObjects()
@@ -453,9 +471,13 @@
         bool createEventHandlers();
 
         // called by handleTimeout()
-        bool ignoreThisTimeout(const int32 timerID);
         bool handleTimeoutErr(const int32 timerID);
 
+        // called by startDataFlowByCommand()
+        void checkEOSMsgFromInputPort();
+        // called by doClear or doCancelClear()
+        void clearInternalEventQueue();
+
     protected:
         PVMFProtocolEngineNode *iNode;
         InterfacingObjectContainer *iInterfacingObjectContainer;
@@ -507,9 +529,10 @@
     PVProtocolEngineNodeInternalEventType_ServerResponseError_Bypassing,
     PVProtocolEngineNodeInternalEventType_ProtocolStateError,
     PVProtocolEngineNodeInternalEventType_CheckResumeNotificationMaually,
+    PVProtocolEngineNodeInternalEventType_OutgoingMsgQueuedAndSentSuccessfully,
 
     // data flow event
-    PVProtocolEngineNodeInternalEventType_IncomingMessageReady = 8,
+    PVProtocolEngineNodeInternalEventType_IncomingMessageReady = 9,
     PVProtocolEngineNodeInternalEventType_HasExtraInputData,
     PVProtocolEngineNodeInternalEventType_OutputDataReady,
     PVProtocolEngineNodeInternalEventType_StartDataflowByCommand,
@@ -521,7 +544,7 @@
 struct PVProtocolEngineNodeInternalEvent
 {
     PVProtocolEngineNodeInternalEventType iEventId;
-    OsclAny *iEventInfo; // any other side info except the actual data, such as error code, sequence number(http streaming)
+    OsclAny *iEventInfo; // any other side info except the actual data, such as error code, sequence number(http streaming), seek offset(fasttrack)
     OsclAny *iEventData; // actual data for the event
 
     // default constructor
@@ -625,6 +648,31 @@
     }
 };
 
+// this structure defines infomation needed for OutgoingMsgSentSuccessHandler, will be as iEventInfo
+struct OutgoingMsgSentSuccessInfo
+{
+    PVMFProtocolEnginePort *iPort;
+    PVMFSharedMediaMsgPtr iMsg;
+
+    // constructor
+    OutgoingMsgSentSuccessInfo(): iPort(NULL)
+    {
+        ;
+    }
+    OutgoingMsgSentSuccessInfo(PVMFProtocolEnginePort *aPort, PVMFSharedMediaMsgPtr &aMsg) :
+            iPort(aPort), iMsg(aMsg)
+    {
+        ;
+    }
+
+    OutgoingMsgSentSuccessInfo &operator=(const OutgoingMsgSentSuccessInfo& x)
+    {
+        iPort = x.iPort;
+        iMsg  = x.iMsg;
+        return *this;
+    }
+};
+
 // use polymophism to handle variant events
 class PVProtocolEngineNodeInternalEventHandler
 {
@@ -644,7 +692,9 @@
         inline bool isCurrEventMatchCurrPendingCommand(uint32 aCurrEventId);
         bool completePendingCommandWithError(PVProtocolEngineNodeInternalEvent &aEvent);
         int32 getBasePVMFErrorReturnCode(const int32 errorCode, const bool isForCommandComplete = true);
-        void handleAuthenErrResponse(int32 &aErrCode, char* &aEventData);
+        void handleErrResponse(int32 &aBaseCode, int32 &aErrCode, char* &aEventData, uint32 &aEventDataLen);
+        void handleAuthenErrResponse(int32 &aErrCode, char* &aEventData, uint32 &aEventDataLen);
+        void handleRedirectErrResponse(char* &aEventData, uint32 &aEventDataLen);
         inline bool isStopCmdPending(); // called by isBeingStopped
         inline bool isProtocolStateComplete(const int32 aStatus);
 
@@ -809,6 +859,21 @@
         }
 };
 
+class OutgoingMsgSentSuccessHandler : public PVProtocolEngineNodeInternalEventHandler
+{
+    public:
+        bool handle(PVProtocolEngineNodeInternalEvent &aEvent);
+
+        // constructor
+        OutgoingMsgSentSuccessHandler(PVMFProtocolEngineNode *aNode) :
+                PVProtocolEngineNodeInternalEventHandler(aNode)
+        {
+            ;
+        }
+};
+
+
+
 
 ////////////////////////////////////////////////////////////////////////////////////
 //////	PVMFProtocolEngineNodeOutput
@@ -828,6 +893,8 @@
         // notify the node that the new data is already written the file and then download control and status
         // should be updated responsively
         virtual void ReadyToUpdateDownloadControl() = 0;
+        // notify the node that a media message has been queued in outgoing message queue successfully
+        virtual bool QueueOutgoingMsgSentSuccess(PVMFProtocolEnginePort *aPort, PVMFSharedMediaMsgPtr &aMsg) = 0;
 };
 
 enum NodeOutputType
@@ -851,6 +918,15 @@
         virtual bool passDownNewOutputData(OUTPUT_DATA_QUEUE &aOutputQueue, OsclAny* aSideInfo = NULL);
         virtual int32 flushData(const uint32 aOutputType = NodeOutputType_InputPortForData) = 0;
         virtual int32 initialize(OsclAny* aInitInfo = NULL) = 0;
+        virtual int32 reCreateMemPool(uint32 aNumPool)
+        {
+            OSCL_UNUSED_ARG(aNumPool);
+            return PROCESS_SUCCESS;
+        }
+        virtual uint32 getNumBuffersInMediaDataPool()
+        {
+            return 0;
+        }
         bool getBuffer(PVMFSharedMediaDataPtr &aMediaData, uint32 aRequestSize = PVHTTPDOWNLOADOUTPUT_CONTENTDATA_CHUNKSIZE);
         virtual void discardData(const bool aNeedReopen = false);
         virtual bool isPortBusy();
@@ -896,10 +972,15 @@
         {
             return 0;
         }
+        // in case of progressive streaming, the following two sizes mean available cache size and maximum cache size
         virtual uint32 getAvailableOutputSize()
         {
             return 0xFFFFFFFF;
         }
+        virtual uint32 getMaxAvailableOutputSize()
+        {
+            return 0;
+        }
 
         // constructor and destructor
         PVMFProtocolEngineNodeOutput(PVMFProtocolEngineNodeOutputObserver *aObserver = NULL);
@@ -978,7 +1059,7 @@
         virtual int32 checkResumeNotification(const bool aDownloadComplete = true) = 0;
         // return true for the new download progress
         // From PVMFDownloadProgressInterface API
-        virtual void getDownloadClock(OsclSharedPtr<OsclClock> &aClock) = 0;
+        virtual void getDownloadClock(OsclSharedPtr<PVMFMediaClock> &aClock) = 0;
         // From PVMFDownloadProgressInterface API
         virtual void setClipDuration(const uint32 aClipDurationMsec) = 0;
         // for auto-resume control for resume download
@@ -1024,6 +1105,8 @@
 };
 
 
+// This class wraps up user agent setting, differentiated in progessive download, fastrack and ms http streaming.
+// Any this kind of variation should be wrapped up into an object
 class UserAgentField
 {
     public:
@@ -1080,11 +1163,19 @@
             return true;
         }
 
-        // send data ready event when download control algorithm enables
+        // enable some specific events
         virtual void sendDataReadyEvent()
         {
             ;
         }
+        virtual void enableBufferingCompleteEvent()
+        {
+            ;
+        }
+        virtual void sendBufferStatusEvent()
+        {
+            ;
+        }
 
         virtual void clear();
 
@@ -1099,6 +1190,8 @@
         PVLogger *iDataPathLogger;
 };
 
+typedef Oscl_Vector<OutgoingMsgSentSuccessInfo, PVMFProtocolEngineNodeAllocator> OutgoingMsgSentSuccessInfoVec;
+
 // This class interfaces between the node and node user, which is in fact a data holder and holds the data set by the node public APIs
 // and some output data return to node user
 class InterfacingObjectContainer
@@ -1171,6 +1264,12 @@
             iStreamParams.iAccelDuration = aAccelDuration;
         }
 
+        //set max streaming size
+        void SetMaxHttpStreamingSize(uint32 aMaxHttpStreamingSize)
+        {
+            iStreamParams.iMaxHttpStreamingSize = aMaxHttpStreamingSize;
+        }
+
         // set and get number of buffers in media message allocator in http streaming
         void setMediaMsgAllocatorNumBuffers(const uint32 aNumBuffersInAllocator)
         {
@@ -1237,9 +1336,9 @@
         {
             return iSocketReconnectCmdSent;
         }
-        void setSocketReconnectCmdSent()
+        void setSocketReconnectCmdSent(const bool aSocketReconnectCmdSent = true)
         {
-            iSocketReconnectCmdSent = true;
+            iSocketReconnectCmdSent = aSocketReconnectCmdSent;
         }
         bool ignoreCurrentInputData() const
         {
@@ -1311,6 +1410,11 @@
             }
         }
 
+        void setNumBuffersInMediaDataPoolSMCalc(uint32 aVal);
+        uint32 getNumBuffersInMediaDataPoolSMCalc() const
+        {
+            return iNumBuffersInMediaDataPoolSMCalc;
+        }
         // iOutputPortConnected
         void setOutputPortConnect(const bool aConnected = true)
         {
@@ -1357,6 +1461,12 @@
         {
             return &iProtocolStateCompleteInfo;
         }
+
+        OutgoingMsgSentSuccessInfoVec *getOutgoingMsgSentSuccessInfoVec()
+        {
+            return &iOutgoingMsgSentSuccessInfoVec;
+        }
+
         bool isDownloadStreamingDone()
         {
             return iProtocolStateCompleteInfo.isDownloadStreamingDone;
@@ -1370,8 +1480,22 @@
             return iProtocolStateCompleteInfo.isEOSAchieved;
         }
 
+        void setTruncatedForLimitSize(const bool aTruncatedForLimitSize = false)
+        {
+            iTruncatedForLimitSize = aTruncatedForLimitSize;
+        }
+        bool getTruncatedForLimitSize() const
+        {
+            return iTruncatedForLimitSize;
+        }
+
         // constructor
         InterfacingObjectContainer();
+        ~InterfacingObjectContainer()
+        {
+            clear();
+            iOutgoingMsgSentSuccessInfoVec.clear();
+        }
 
         // clear
         void clear()
@@ -1383,9 +1507,10 @@
             isCurrentInputDataUnwanted	= true; // when clear(), treat all the input data unwanted (that needs to be ignored), let command and event to enable it
             iProcessingDone				= false;
             iKeepAliveTimeout			= 0;
-            iDisableHeadRequest			= true; // changed on the request of panasonic san
+            iDisableHeadRequest			= true; // changed on the request of Japan
             iMaxASFHeaderSize			= 0;
             iCancelCmdHappened			= false;
+            iTruncatedForLimitSize		= false;
             iProtocolStateCompleteInfo.clear();
         }
 
@@ -1405,6 +1530,7 @@
         uint32 iNumRedirectTrials;
         uint32 iCurrRedirectTrials;
 
+        uint32 iNumBuffersInMediaDataPoolSMCalc;
         // get from GetHTTPHeader()
         char iHttpHeaderBuffer[PVHTTPDOWNLOADOUTPUT_CONTENTDATA_CHUNKSIZE+1]; // to hold http header
         uint32 iHttpHeaderLength;
@@ -1442,6 +1568,12 @@
         // work as a global variable
         EndOfDataProcessingInfo iEOPInfo;
         ProtocolStateCompleteInfo iProtocolStateCompleteInfo;
+        OutgoingMsgSentSuccessInfoVec iOutgoingMsgSentSuccessInfoVec;
+
+        // This flag mean data-size reach limitation or not
+        // true : data reached limitation
+        // false: data don't reach limitation
+        bool iTruncatedForLimitSize;
 };
 
 
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.cpp
index bd47e94..f30b1de 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
 #include "pvmf_protocol_engine_node.h"
 #include "pvmf_protocol_engine_node_download_common.h"
 #include "pvmf_protocolengine_node_tunables.h"
+#include "pvmf_protocol_engine_command_format_ids.h"
+
 
 #include "pvlogger.h"
 /**
@@ -34,19 +36,16 @@
 #define PVMF_PROTOCOL_ENGINE_LOGBIN(iPortLogger, m) PVLOGGER_LOGBIN(PVLOGMSG_INST_LLDBG, iPortLogger, PVLOGMSG_ERR, m);
 #define	NODEDATAPATHLOGGER_TAG "datapath.sourcenode.protocolenginenode"
 
-#ifdef ANDROID
-#define LOG_NDEBUG 0
-#include <utils/Log.h>
-#undef LOG_TAG
-#define LOG_TAG "ProtocolEngine"
-#endif
 
 ////////////////////////////////////////////////////////////////////////////////////
 //////	DownloadContainer implementation
 ////////////////////////////////////////////////////////////////////////////////////
 
 // constructor
-DownloadContainer::DownloadContainer(PVMFProtocolEngineNode *aNode) : ProtocolContainer(aNode)
+DownloadContainer::DownloadContainer(PVMFProtocolEngineNode *aNode) :
+        ProtocolContainer(aNode),
+        iForceSocketReconnect(false),
+        iNeedCheckResumeNotificationManually(false)
 {
     ;
 }
@@ -74,11 +73,13 @@
 
     if (!aCfgFile->IsNewSession() && aCfgFile->GetCurrentFileSize() >= aCfgFile->GetOverallFileSize())
     {
-        iNode->iInterfacingObjectContainer.setFileSize(aCfgFile->GetOverallFileSize());
+        iNode->iInterfacingObjectContainer->setFileSize(aCfgFile->GetOverallFileSize());
         iNode->SetState(EPVMFNodeStarted);
+        iNode->iNodeTimer->clear();
         iNode->iEventReport->startRealDataflow();
         iNode->iEventReport->checkReportEvent(PROCESS_SUCCESS_END_OF_MESSAGE);
         iNode->iDownloadControl->checkResumeNotification();
+        iNode->iInterfacingObjectContainer->setInputDataUnwanted();
         return PROCESS_SUCCESS_END_OF_MESSAGE;
     }
     return PROCESS_SUCCESS;
@@ -90,6 +91,18 @@
     return true;
 }
 
+PVMFStatus DownloadContainer::doStop()
+{
+    ProtocolContainer::doStop();
+
+    // set resume download mode for stop and play
+    OsclSharedPtr<PVDlCfgFile> aCfgFile = iNode->iCfgFileContainer->getCfgFile();
+    aCfgFile->SetNewSession(false); // set resume download session for the next time
+
+    iForceSocketReconnect = true;
+    return PVMFSuccess;
+}
+
 void DownloadContainer::doClear(const bool aNeedDelete)
 {
     // save config
@@ -175,8 +188,8 @@
     config.isResumeDownload		= true;
     if (iNode->iNodeOutput->initialize((OsclAny*)(&config)) != PVMFSuccess) return false;
     iNode->iNodeOutput->discardData(true); // true means closing and reopening the data stream object
-    iNode->StartDataFlowByCommand();
     iNode->iEventReport->startRealDataflow();
+    startDataFlowByCommand();
     return true;
 }
 
@@ -207,7 +220,7 @@
     // pass objects to node output object
     iNode->iNodeOutput->setOutputObject((OsclAny*)iNode->iPortInForData);
     iNode->iNodeOutput->setOutputObject((OsclAny*)iInterfacingObjectContainer->getDataStreamFactory(), NodeOutputType_DataStreamFactory);
-    iNode->iInterfacingObjectContainer.setOutputPortConnect();  // for sending disconnect after download complete
+    iNode->iInterfacingObjectContainer->setOutputPortConnect();  // for sending disconnect after download complete
 
     OsclSharedPtr<PVDlCfgFile> aCfgFile = iNode->iCfgFileContainer->getCfgFile();
     DownloadOutputConfig config;
@@ -241,6 +254,7 @@
     iNode->iDownloadControl->setSupportObject((OsclAny*)iNode->iProtocol, DownloadControlSupportObjectType_ProtocolEngine);
     iNode->iDownloadControl->setSupportObject((OsclAny*)iNode->iDownloadProgess, DownloadControlSupportObjectType_DownloadProgress);
     iNode->iDownloadControl->setSupportObject((OsclAny*)iNode->iNodeOutput, DownloadControlSupportObjectType_OutputObject);
+    iNode->iDownloadControl->setSupportObject((OsclAny*)iNode->iCfgFileContainer, DownloadControlSupportObjectType_ConfigFileContainer);
 
     iNode->iDownloadProgess->setSupportObject((OsclAny*)iNode->iProtocol, DownloadControlSupportObjectType_ProtocolEngine);
     iNode->iDownloadProgess->setSupportObject((OsclAny*)iNode->iCfgFileContainer, DownloadControlSupportObjectType_ConfigFileContainer);
@@ -280,6 +294,42 @@
     return ProtocolContainer::handleProtocolStateComplete(aEvent, aEventHandler);
 }
 
+void DownloadContainer::checkSendResumeNotification()
+{
+    iNode->iNodeTimer->start(WALL_CLOCK_TIMER_ID);
+
+    if (needToCheckResumeNotificationMaually())
+    {
+        iNeedCheckResumeNotificationManually = false;
+        // form PVProtocolEngineNodeInternalEventType_CheckResumeNotificationMaually event
+        PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_CheckResumeNotificationMaually);
+        iNode->iInternalEventQueue.clear();
+        iNode->iInternalEventQueue.push_back(aEvent);
+        iNode->SetProcessingState(ProcessingState_NormalDataflow);
+        iNode->RunIfNotReady();
+    }
+}
+
+bool DownloadContainer::ignoreThisTimeout(const int32 timerID)
+{
+    if (timerID != (int32)WALL_CLOCK_TIMER_ID && timerID != BUFFER_STATUS_TIMER_ID)
+    {
+        return ProtocolContainer::ignoreThisTimeout(timerID);
+    }
+
+    // in case of WALL_CLOCK_TIMER_ID
+    if (timerID == (int32)WALL_CLOCK_TIMER_ID)
+    {
+        iNeedCheckResumeNotificationManually = true;
+        checkSendResumeNotification();
+    }
+    else if (timerID == BUFFER_STATUS_TIMER_ID)
+    {
+        iNode->iEventReport->sendBufferStatusEvent();
+    }
+    return true;
+}
+
 ////////////////////////////////////////////////////////////////////////////////////
 //////	pvHttpDownloadOutput implementation
 ////////////////////////////////////////////////////////////////////////////////////
@@ -392,11 +442,6 @@
 
 void pvHttpDownloadOutput::discardData(const bool aNeedReopen)
 {
-    discardDataBody(aNeedReopen);
-}
-
-void pvHttpDownloadOutput::discardDataBody(const bool aNeedReopen, const uint32 aSeekOffset)
-{
     // discard the existing data inside the data stream object
     if (iDataStream && isOpenDataStream)
     {
@@ -405,11 +450,6 @@
             iDataStream->CloseSession(iSessionID);
             iDataStream->OpenSession(iSessionID, PVDS_REWRITE);
         }
-        else
-        {
-            // for progressive playback, the file offset may not be 0 after reconnect
-            iDataStream->Seek(iSessionID, aSeekOffset, PVDS_SEEK_SET);
-        }
     }
     PVMFProtocolEngineNodeOutput::discardData();
 }
@@ -424,6 +464,11 @@
     return writeCapacity;
 }
 
+uint32 pvHttpDownloadOutput::getMaxAvailableOutputSize()
+{
+    return (iDataStream == NULL ? 0 : iDataStream->QueryBufferingCapacity());
+}
+
 ////////////////////////////////////////////////////////////////////////////////////
 //////	pvDownloadControl implementation
 ////////////////////////////////////////////////////////////////////////////////////
@@ -431,9 +476,15 @@
 pvDownloadControl::pvDownloadControl() :
         iCurrentPlaybackClock(NULL),
         iProgDownloadSI(NULL),
-        iNodeOutput(NULL)
+        iProtocol(NULL),
+        iDownloadProgress(NULL),
+        iNodeOutput(NULL),
+        iCfgFileContainer(NULL),
+        iFirstResumeNotificationSent(false),
+        iClipDurationMsec(0),
+        iFileSize(0)
 {
-    clear();
+    clearBody();
     createDownloadClock(); // may leave
     iDataPathLogger = PVLogger::GetLoggerObject(NODEDATAPATHLOGGER_TAG);
 }
@@ -442,28 +493,32 @@
 {
     // check whether there is still pending resume request
     if (iProgDownloadSI) sendResumeNotification(true);
-    iProgDownloadSI = NULL;
+    clearBody();
+}
 
-    iPlaybackUnderflow			= true;
-    iDownloadComplete			= false;
-    iRequestResumeNotification	= false;
-    iCurrentNPTReadPosition		= 0;
-    iClipDurationMsec			= 0;
-    iPlaybackByteRate			= 0;
-    iClipByterate				= 0;
-    iPrevDownloadSize			= 0;
-    iDlAlgoPreConditionMet		= false;
-    iSetFileSize				= false;
+void pvDownloadControl::clearBody()
+{
+    iPlaybackUnderflow			 = true;
+    iDownloadComplete			 = false;
+    iRequestResumeNotification	 = false;
+    iCurrentNPTReadPosition		 = 0;
+    iPlaybackByteRate			 = 0;
+    iClipByterate				 = 0;
+    iPrevDownloadSize			 = 0;
+    iDlAlgoPreConditionMet		 = false;
+    iSetFileSize				 = false;
     iSendDownloadCompleteNotification = false;
 }
 
+
 // requst resume notification, implementation of PVMFDownloadProgressInterface API
 void pvDownloadControl::requestResumeNotification(const uint32 currentNPTReadPosition, bool& aDownloadComplete, bool& aNeedSendUnderflowEvent)
 {
-    LOGINFODATAPATH((0, "pvDownloadControl::requestResumeNotification(), iPlaybackUnderflow=%d, iRequestResumeNotification=%d, iDownloadComplete=%d",
-                     iPlaybackUnderflow, iRequestResumeNotification, iDownloadComplete));
+    LOGINFODATAPATH((0, "pvDownloadControl::requestResumeNotification() IN, iPlaybackUnderflow=%d, iRequestResumeNotification=%d, iDownloadComplete=%d",
+                     (uint32)iPlaybackUnderflow, (uint32)iRequestResumeNotification, (uint32)iDownloadComplete));
 
-    aNeedSendUnderflowEvent = !iRequestResumeNotification;
+    if (iFirstResumeNotificationSent) aNeedSendUnderflowEvent = !iRequestResumeNotification;
+    else aNeedSendUnderflowEvent = false;
 
     if (!(aDownloadComplete = iDownloadComplete))
     {
@@ -483,8 +538,13 @@
         // estimate playback rate
         iPlaybackByteRate = divisionInMilliSec(iProtocol->getDownloadSize(), currentNPTReadPosition);
 
-        LOGINFODATAPATH((0, "pvDownloadControl::requestResumeNotification(), currentNPTReadPosition=%d, playbackRate=%dbps, prevDownloadSize=%d",
-                         currentNPTReadPosition, (iPlaybackByteRate << 3), iPrevDownloadSize));
+        uint32 iPrevDownloadSizeOrig = 0;
+        iPrevDownloadSizeOrig = iPrevDownloadSize;
+        if (iClipByterate == 0 && iClipDurationMsec > 0) iClipByterate = divisionInMilliSec(iFileSize, iClipDurationMsec);
+        iPrevDownloadSize = OSCL_MAX(iPrevDownloadSize, currentNPTReadPosition / 1000 * iClipByterate);
+
+        LOGINFODATAPATH((0, "pvDownloadControl::requestResumeNotification(), currentNPTReadPosition=%d, playbackRate=%dbps, prevDownloadSize=%d, iPrevDownloadSizeOrig=%d, iClipByterate=%dbps",
+                         currentNPTReadPosition, (iPlaybackByteRate << 3), iPrevDownloadSize, iPrevDownloadSizeOrig, (iClipByterate << 3)));
     }
 }
 
@@ -494,6 +554,9 @@
     {
         case DownloadControlSupportObjectType_SupportInterface:
             iProgDownloadSI = (PVMFFormatProgDownloadSupportInterface*)aDLSupportObject;
+            // in high bandwidth conditions, iProgDownloadSI gets set AFTER download is complete, then
+            // need to check resume notification again if something is pending
+            if (iDownloadComplete) checkResumeNotification(iDownloadComplete);
             break;
 
         case DownloadControlSupportObjectType_ProgressInterface:
@@ -503,7 +566,7 @@
             break;
         }
         case DownloadControlSupportObjectType_EnginePlaybackClock:
-            iCurrentPlaybackClock = (OsclClock *)aDLSupportObject;
+            iCurrentPlaybackClock = (PVMFMediaClock *)aDLSupportObject;
             break;
 
         case DownloadControlSupportObjectType_ProtocolEngine:
@@ -518,6 +581,17 @@
             iNodeOutput = (PVMFProtocolEngineNodeOutput *)aDLSupportObject;
             break;
 
+        case DownloadControlSupportObjectType_ConfigFileContainer:
+            iCfgFileContainer = (PVDlCfgFileContainer *)aDLSupportObject;
+            if (!iCfgFileContainer->getCfgFile()->IsNewSession())
+            {
+                if (iCfgFileContainer->getCfgFile()->HasContentLength())
+                {
+                    iFileSize = iCfgFileContainer->getCfgFile()->GetOverallFileSize();
+                }
+            }
+            break;
+
         default:
             break;
     }
@@ -529,11 +603,15 @@
 //				 0 means anything else
 int32 pvDownloadControl::checkResumeNotification(const bool aDownloadComplete)
 {
-    LOGINFODATAPATH((0, "pvDownloadControl::checkResumeNotification() IN, iPlaybackUnderflow=%d, iRequestResumeNotification=%d, aDownloadComplete=%d",
-                     (uint32)iPlaybackUnderflow, (uint32)iRequestResumeNotification, (uint32)aDownloadComplete));
+    //LOGINFODATAPATH((0, "pvDownloadControl::checkResumeNotification() IN, iPlaybackUnderflow=%d, iRequestResumeNotification=%d, aDownloadComplete=%d",
+    //	(uint32)iPlaybackUnderflow, (uint32)iRequestResumeNotification, (uint32)aDownloadComplete));
 
     // short-cut: download complete
-    if (!checkDownloadCompleteForResumeNotification(aDownloadComplete)) return 0;
+    if (!checkDownloadCompleteForResumeNotification(aDownloadComplete))
+    {
+        LOGINFODATAPATH((0, "pvDownloadControl::checkResumeNotification()->checkDownloadCompleteForResumeNotification() return false, iProgDownloadSI=0x%x", iProgDownloadSI));
+        return 0;
+    }
 
     // real work that causes some PDL and PS differences
     if (!iPlaybackUnderflow && iRequestResumeNotification)
@@ -542,18 +620,15 @@
         return 2;
     }
 
-
     // check if need to resume playback
     if (iPlaybackUnderflow &&
             isResumePlayback(iProtocol->getDownloadRate(),
                              iNodeOutput->getCurrentOutputSize(),
-                             iProtocol->getContentLength()))
+                             iFileSize))
     {
-#ifdef ANDROID
-        LOGV("DownloadRate %d bytes per sec. Downloaded Bytes %d/%d", iProtocol->getDownloadRate(), iNodeOutput->getCurrentOutputSize(), iProtocol->getContentLength());
-#endif
         iPlaybackUnderflow = false;
         sendResumeNotification(iDownloadComplete);
+        iFirstResumeNotificationSent = true;
         return 1;
     }
 
@@ -568,10 +643,14 @@
     }
 
     iDownloadComplete = aDownloadComplete;
-    if (!pvDownloadControl::isInfoReady()) return false;
+
+    // update iFileSize to minimize dependency on protocol object and improve the efficiency
+    updateFileSize();
+
+    if (!isInfoReady()) return false;
 
     // set file size to parser node
-    setFileSize(iProtocol->getContentLength());
+    setFileSize(iFileSize);
 
     // send download complete notification to parser node
     if (aDownloadComplete) sendDownloadCompleteNotification();
@@ -581,6 +660,14 @@
     return true;
 }
 
+void pvDownloadControl::updateFileSize()
+{
+    if (iProtocol)
+    {
+        if (iProtocol->getContentLength() > 0 && iFileSize == 0) iFileSize = iProtocol->getContentLength();
+    }
+}
+
 void pvDownloadControl::setFileSize(const uint32 aFileSize)
 {
     if (iSetFileSize) return;
@@ -592,10 +679,11 @@
 
 void pvDownloadControl::sendResumeNotification(bool aDownloadComplete)
 {
-    if (iRequestResumeNotification)
+    if (iRequestResumeNotification && iProgDownloadSI)
     {
         iProgDownloadSI->playResumeNotification(aDownloadComplete);
         iRequestResumeNotification = false;
+        iFirstResumeNotificationSent = true;
         if (aDownloadComplete) iPlaybackUnderflow = false;
 
         // sync up with actual download complete
@@ -616,17 +704,18 @@
 // create iDlProgressClock, will leave when memory allocation fails
 void pvDownloadControl::createDownloadClock()
 {
-    // create shared OsclClock
-    PVDlSharedPtrAlloc<OsclClock> alloc;
-    OsclClock* myClock = alloc.allocate();
-    OsclRefCounterSA< PVDlSharedPtrAlloc<OsclClock> > *refcnt = new OsclRefCounterSA< PVDlSharedPtrAlloc<OsclClock> >(myClock);
-    OsclSharedPtr<OsclClock> myHandle(myClock, refcnt);
+    // create shared PVMFMediaClock
+    PVDlSharedPtrAlloc<PVMFMediaClock> alloc;
+    PVMFMediaClock* myClock = alloc.allocate();
+    OsclRefCounterSA< PVDlSharedPtrAlloc<PVMFMediaClock> > *refcnt = new OsclRefCounterSA< PVDlSharedPtrAlloc<PVMFMediaClock> >(myClock);
+    OsclSharedPtr<PVMFMediaClock> myHandle(myClock, refcnt);
     iDlProgressClock = myHandle;
 
     // set the clock base
     iDlProgressClock->SetClockTimebase(iEstimatedServerClockTimeBase);
     uint32 startTime = 0; // for type conversion
-    iDlProgressClock->SetStartTime32(startTime, OSCLCLOCK_SEC);
+    bool bOverflowFlag = false;
+    iDlProgressClock->SetStartTime32(startTime, PVMF_MEDIA_CLOCK_SEC, bOverflowFlag);
 }
 
 
@@ -648,6 +737,7 @@
     // check playback clock, if not available, then switch to the old algorithm
     if (!iCurrentPlaybackClock) return isResumePlaybackWithOldAlg(aDownloadRate, aFileSize - aCurrDownloadSize);
 
+
     // check the pre-conditins including initial download time/size for download rate estimation purpose
     if (!isDlAlgoPreConditionMet(aDownloadRate, iClipDurationMsec, aCurrDownloadSize, aFileSize)) return false;
 
@@ -726,12 +816,16 @@
 {
     aPlaybackTime = 0;
     bool isPbOverflow = false;
-    iCurrentPlaybackClock->GetCurrentTime32(aPlaybackTime, isPbOverflow, OSCLCLOCK_MSEC);
+    iCurrentPlaybackClock->GetCurrentTime32(aPlaybackTime, isPbOverflow, PVMF_MEDIA_CLOCK_MSEC);
     if (isPbOverflow)
     {
         LOGERRORDATAPATH((0, "pvDownloadControl::getPlaybackTimeFromEngineClock(), Playback clock overflow %d", isPbOverflow));
         return false;
     }
+
+    LOGINFODATAPATH((0, "pvDownloadControl::getPlaybackTimeFromEngineClock(), aPlaybackTime=%d, iCurrentNPTReadPosition=%d",
+                     aPlaybackTime, iCurrentNPTReadPosition));
+    aPlaybackTime = OSCL_MAX(aPlaybackTime, iCurrentNPTReadPosition);
     return true;
 }
 
@@ -740,6 +834,11 @@
         const uint32 aDownloadRate,
         const uint32 aRemainingPlaybackTime)
 {
+
+#if 0
+    // the float-point calculation: aRemainingDLSize<0.0009*aDownloadRate*aRemainingPlaybackTime
+    return (aRemainingDLSize < 0.0009*aDownloadRate*aRemainingPlaybackTime);
+#else
     // fixed-point calculation
     // 0.0009 = 1/1111 ~= 1/1024 = 1/2^10 = right shift 10 bits
     // aRemainingDLSize<(aDownloadRate*aRemainingPlaybackTime>>10)
@@ -756,6 +855,7 @@
         uint32 maxRightShift10 = max >> PVPROTOCOLENGINE_AUTO_RESUME_FIXED_CALCULATION_RIGHT_SHIFT; // right shift 10 bits
         return (aRemainingDLSize / maxRightShift10 < min);
     }
+#endif
 }
 
 // result = x*1000/y
@@ -763,15 +863,27 @@
 {
     // result = x*1000/y
     // handle overflow issue
-    uint32 result = 0;
-    if (x >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_LIMIT_RIGHT_SHIFT_FACTOR)
-    {
-        result = (x >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR) * 1000 /
-                 (y >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR);
-    }
+    if (x >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_LIMIT_RIGHT_SHIFT_FACTOR == 0) return x*1000 / y; // no overflow
+
+    // x*1000 overflows
+    uint32 result = (x >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR) * 1000;
+    if (result < y) result /= (y >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR);
     else
     {
-        result = x * 1000 / y;
+        uint32 resultTmp = result / y;
+        if (resultTmp >> PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_LIMIT_RIGHT_SHIFT_FACTOR) /* overflow */  result = 0xffffffff;
+        else
+        {
+            // check the accuracy of result/y
+            uint32 halfRightShift = PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR >> 1;
+            if (resultTmp >> halfRightShift)
+                result = resultTmp << PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR;
+            else
+            {
+                result /= (y >> halfRightShift);
+                result <<= (PVPROTOCOLENGINE_DOWNLOAD_DURATION_CALCULATION_RIGHTSHIFT_FACTOR - halfRightShift);
+            }
+        }
     }
     return result;
 }
@@ -779,8 +891,9 @@
 bool pvDownloadControl::isResumePlaybackWithOldAlg(const uint32 aDownloadRate, const uint32 aRemainingDownloadSize)
 {
     // get the download progress clock time
-    uint64 download_time;
-    iDlProgressClock->GetCurrentTime64(download_time, OSCLCLOCK_MSEC);
+    uint32 download_time;
+    bool overflowFlag = false;
+    iDlProgressClock->GetCurrentTime32(download_time, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
     uint32 currentNPTDownloadPosition = Oscl_Int64_Utils::get_uint64_lower32(download_time);
 
     LOGINFODATAPATH((0, "pvDownloadControl::isResumePlaybackWithOldAlg(), download_time=%dms, download_complete=%d\n", download_time, iDownloadComplete));
@@ -855,7 +968,7 @@
 
 bool DownloadProgress::update(const bool aDownloadComplete)
 {
-    if (!aDownloadComplete) updateDownloadClock();
+    updateDownloadClock(aDownloadComplete);
 
     // update download progress
     uint32 newProgressPercent = 0;
@@ -1142,6 +1255,7 @@
     iSendContentTypeEvent			= false;
     iSendUnexpectedDataEvent		= false;
     iSendServerDisconnectEvent		= false;
+    iPrevDownloadProgress = 0;
 
     EventReporter::clear();
 }
@@ -1150,8 +1264,46 @@
 {
     iNode->ReportInfoEvent(PVMFInfoDataReady, (OsclAny*)iNode->iProtocol->getDownloadRate());
     iSendInitialDataReadyEvent = true;
+    iNode->iNodeTimer->cancel(WALL_CLOCK_TIMER_ID);
 }
 
+void downloadEventReporter::enableBufferingCompleteEvent()
+{
+    iSendBufferCompleteInfoEvent = false;
+}
+
+void downloadEventReporter::sendBufferStatusEvent()
+{
+    sendBufferStatusEventBody(true);
+}
+
+void downloadEventReporter::sendBufferStatusEventBody(const bool aForceToSend)
+{
+    if (!iStarted || !iNode->iDownloadProgess) return;
+
+    uint32 aProgessPercent = 0;
+    bool status = iNode->iDownloadProgess->getNewProgressPercent(aProgessPercent);
+    if (!status && aForceToSend) aProgessPercent = iPrevDownloadProgress;
+
+    if ((status || aForceToSend))
+    {
+        reportBufferStatusEvent(aProgessPercent);
+        iPrevDownloadProgress = aProgessPercent;
+        if (iPrevDownloadProgress < 100) iNode->iNodeTimer->start(BUFFER_STATUS_TIMER_ID);
+    }
+}
+
+void downloadEventReporter::reportBufferStatusEvent(const uint32 aDownloadPercent)
+{
+    iNode->ReportInfoEvent(PVMFInfoBufferingStatus,
+                           NULL,
+                           PVMFPROTOCOLENGINENODEInfo_BufferingStatus,
+                           (uint8*)(&aDownloadPercent),
+                           sizeof(aDownloadPercent));
+    LOGINFODATAPATH((0, "downloadEventReporter::reportBufferStatusEvent() DOWNLOAD PERCENTAGE: %d", aDownloadPercent));
+}
+
+
 bool downloadEventReporter::checkReportEvent(const uint32 downloadStatus)
 {
     // PVMFInfoContentLength, PVMFErrContentTooLarge and PVMFInfoContentTruncated
@@ -1168,19 +1320,17 @@
     {
         iNode->ReportInfoEvent(PVMFInfoBufferingStart); // first coming media data triggers sending PVMFInfoBufferingStart event
         iSendBufferStartInfoEvent = true;
-        if (!isDownloadComplete(downloadStatus)) return true;
+        if (!isDownloadComplete(downloadStatus))
+        {
+            iNode->iNodeTimer->start(BUFFER_STATUS_TIMER_ID);
+            return true;
+        }
     }
 
     // PVMFInfoBufferingStatus and PVMFInfoBufferingComplete event
     if (iStarted && iNode->iDownloadProgess)
     {
-        uint32 aProgessPercent = 0;
-        if (iNode->iDownloadProgess->getNewProgressPercent(aProgessPercent))
-        {
-            iNode->ReportInfoEvent(PVMFInfoBufferingStatus, (OsclAny*)aProgessPercent,
-                                   PVMFPROTOCOLENGINENODEInfo_BufferingStatus);
-            LOGINFODATAPATH((0, "downloadEventReporter::checkBufferInfoEvent() DOWNLOAD PERCENTAGE: %d", aProgessPercent));
-        }
+        sendBufferStatusEventBody();
 
         // check and send buffer complete, data ready and unexpected data events
         checkBufferCompleteEvent(downloadStatus);
@@ -1199,8 +1349,7 @@
         if (aProgessPercent < 100)
         {
             aProgessPercent = 100;
-            iNode->ReportInfoEvent(PVMFInfoBufferingStatus, (OsclAny*)aProgessPercent,
-                                   PVMFPROTOCOLENGINENODEInfo_BufferingStatus);
+            reportBufferStatusEvent(aProgessPercent);
         }
 
         // send buffer complete event
@@ -1213,6 +1362,9 @@
             iNode->ReportInfoEvent(PVMFInfoDataReady);
             iSendInitialDataReadyEvent = true;
         }
+
+        // clear the timer again because of download completion
+        iNode->iNodeTimer->clear();
     }
 
     checkUnexpectedDataAndServerDisconnectEvent(downloadStatus);
@@ -1297,6 +1449,9 @@
         // PVMFErrContentTooLarge
         if (fileSize > maxAllowedFileSize)
         {
+            // before error out, settle down the interaction with parser node
+            iNode->iDownloadControl->checkResumeNotification(false);
+
             ProtocolStateErrorInfo aInfo(PVMFErrContentTooLarge);
             PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_ProtocolStateError, (OsclAny*)(&aInfo));
             iNode->DispatchInternalEvent(&aEvent);
@@ -1316,8 +1471,12 @@
         if (status > 0)
         {
             if (status == 1) iNode->ReportInfoEvent(PVMFInfoContentTruncated, (OsclAny*)iNode->iProtocol->getDownloadSize());
-            if (status == 2) iNode->ReportInfoEvent(PVMFInfoContentTruncated, (OsclAny*)iNode->iProtocol->getDownloadSize(),
-                                                        PVMFPROTOCOLENGINENODEInfo_TruncatedContentByServerDisconnect);
+            if (status == 2)
+            {
+                iNode->ReportInfoEvent(PVMFInfoContentTruncated,
+                                       (OsclAny*)iNode->iProtocol->getDownloadSize(),
+                                       PVMFPROTOCOLENGINENODEInfo_TruncatedContentByServerDisconnect);
+            }
             //iNode->Clear();
             iSendContentTruncateEvent = true;
         }
@@ -1342,7 +1501,7 @@
         if (currDownloadSize < contentLength) return 2;
     }
 
-    // 2. no content length case : download size >= maximum file size (storage size)
+    // 2. no content length case : download size > maximum file size (storage size)
     if (contentLength == 0)
     {
         if (downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_TRUNCATED) return 1;
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.h
index db81ddf..ec6019e 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_download_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@
         virtual void deleteProtocolObjects();
         virtual int32 doPreStart();
         virtual bool doPause();
+        virtual PVMFStatus doStop();
         virtual void doClear(const bool aNeedDelete = false);
         virtual void doCancelClear();
         virtual bool doInfoUpdate(const uint32 downloadStatus);
@@ -55,6 +56,7 @@
         virtual bool downloadUpdateForHttpHeaderAvailable();
         virtual bool isStreamingPlayback();
         virtual bool handleProtocolStateComplete(PVProtocolEngineNodeInternalEvent &aEvent, PVProtocolEngineNodeInternalEventHandler *aEventHandler);
+        virtual void checkSendResumeNotification();
 
     protected:
         virtual int32 initNodeOutput();
@@ -68,11 +70,20 @@
                     downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA ||
                     downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_BY_SERVER_DISCONNECT);
         }
+        virtual bool ignoreThisTimeout(const int32 timerID);
+        virtual bool needToCheckResumeNotificationMaually()
+        {
+            return iNeedCheckResumeNotificationManually;
+        }
 
     private:
         //called by createProtocolObjects()
         bool createNetworkTimer();
         bool createEventHandlers();
+
+    protected:
+        bool iForceSocketReconnect;
+        bool iNeedCheckResumeNotificationManually;
 };
 
 ////////////////////////////////////////////////////////////////////////////////////
@@ -103,6 +114,7 @@
         virtual int32 flushData(const uint32 aOutputType = NodeOutputType_InputPortForData);
         virtual void discardData(const bool aNeedReopen = false);
         uint32 getAvailableOutputSize();
+        uint32 getMaxAvailableOutputSize();
 
         // constructor and destructor
         pvHttpDownloadOutput(PVMFProtocolEngineNodeOutputObserver *aObserver = NULL);
@@ -114,7 +126,6 @@
         uint32 writeToDataStream(OUTPUT_DATA_QUEUE &aOutputQueue);
         bool writeToDataStream(uint8 *aBuffer, uint32 aBufferLen);
         virtual int32 openDataStream(OsclAny* aInitInfo);
-        void discardDataBody(const bool aNeedReopen, const uint32 aSeekOffset = 0);
         // reset
         virtual void reset();
 
@@ -139,7 +150,7 @@
         pvDownloadControl();
         virtual ~pvDownloadControl()
         {
-            clear();
+            clearBody();
         }
 
 
@@ -163,7 +174,7 @@
         virtual int32 checkResumeNotification(const bool aDownloadComplete = true);
 
         // From PVMFDownloadProgressInterface API
-        virtual void getDownloadClock(OsclSharedPtr<OsclClock> &aClock)
+        virtual void getDownloadClock(OsclSharedPtr<PVMFMediaClock> &aClock)
         {
             OSCL_UNUSED_ARG(aClock);
         }
@@ -208,7 +219,6 @@
         bool isInfoReady()
         {
             return !(iDlProgressClock.GetRep() == NULL ||
-                     iProgDownloadSI == NULL			 ||
                      iProtocol == NULL				 ||
                      iDownloadProgress == NULL		 ||
                      iNodeOutput == NULL);
@@ -285,23 +295,31 @@
         void setFileSize(const uint32 aFileSize);
         bool getPlaybackTimeFromEngineClock(uint32 &aPlaybackTime);
 
+    private:
+        void updateFileSize();
+        void clearBody();
+
+
     protected:
         // download control
-        OsclTimebase_Tickcount iEstimatedServerClockTimeBase;
-        OsclSharedPtr<OsclClock> iDlProgressClock;
-        OsclClock* iCurrentPlaybackClock;
+        PVMFTimebase_Tickcount iEstimatedServerClockTimeBase;
+        OsclSharedPtr<PVMFMediaClock> iDlProgressClock;
+        PVMFMediaClock* iCurrentPlaybackClock;
         PVMFFormatProgDownloadSupportInterface *iProgDownloadSI;
         HttpBasedProtocol *iProtocol;
         DownloadProgressInterface *iDownloadProgress;
         PVMFProtocolEngineNodeOutput *iNodeOutput;
+        PVDlCfgFileContainer *iCfgFileContainer;
 
         bool iPlaybackUnderflow;
         bool iDownloadComplete;
         bool iRequestResumeNotification;
+        bool iFirstResumeNotificationSent;
         uint32 iCurrentNPTReadPosition;
         uint32 iClipDurationMsec;
         uint32 iPlaybackByteRate;
         uint32 iPrevDownloadSize;
+        uint32 iFileSize;
 
         bool iDlAlgoPreConditionMet;
         bool iSetFileSize;
@@ -353,7 +371,7 @@
 
     protected:
         virtual uint32 getClipDuration();
-        virtual bool updateDownloadClock() = 0;
+        virtual bool updateDownloadClock(const bool aDownloadComplete) = 0;
         virtual bool calculateDownloadPercent(uint32 &aDownloadProgressPercent);
         virtual void reset();
 
@@ -499,8 +517,10 @@
         bool checkContentInfoEvent(const uint32 downloadStatus);
         void clear();
 
-        // send data ready event when download control algorithm enables
+        // enable some specific events
         void sendDataReadyEvent();
+        void enableBufferingCompleteEvent();
+        void sendBufferStatusEvent();
 
     protected:
         virtual bool needToCheckContentInfoEvent()
@@ -527,6 +547,9 @@
                     downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA ||
                     downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_BY_SERVER_DISCONNECT);
         }
+        // will be overriden in case of PS
+        // called by sendBufferStatusEventBody()
+        virtual void reportBufferStatusEvent(const uint32 aDownloadPercent);
 
     protected:
         bool iSendBufferStartInfoEvent;
@@ -538,6 +561,12 @@
         bool iSendContentTypeEvent;
         bool iSendUnexpectedDataEvent;
         bool iSendServerDisconnectEvent;
+
+    private:
+        void sendBufferStatusEventBody(const bool aForceToSend = false);
+
+    private:
+        uint32 iPrevDownloadProgress;
 };
 
 #endif
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.cpp
index 8c4c9a1..018e49d 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,6 +61,8 @@
 
 bool ProgressiveDownloadContainer::createProtocolObjects()
 {
+    if (!ProtocolContainer::createProtocolObjects()) return false;
+
     iNode->iProtocol		 = OSCL_NEW(ProgressiveDownload, ());
     iNode->iNodeOutput		 = OSCL_NEW(pvHttpDownloadOutput, (iNode));
     iNode->iDownloadControl  = OSCL_NEW(progressiveDownloadControl, ());
@@ -73,21 +75,21 @@
     if (!iNode->iProtocol		|| !iNode->iNodeOutput  || !iNode->iDownloadControl  ||
             !iNode->iDownloadProgess || !iNode->iEventReport || !iNode->iCfgFileContainer ||
             !iNode->iUserAgentField  || !iNode->iDownloadSource) return false;
-
-    return ProtocolContainer::createProtocolObjects();
+    return true;
 }
 
 bool ProgressiveDownloadContainer::needSocketReconnect()
 {
     // currently, only disallow socket reconnect for head request disabled during prepare->start
     if (iNode->iInterfaceState == EPVMFNodePrepared &&
-            iNode->iInterfacingObjectContainer.getHttpHeadRequestDisabled()) return false;
+            iNode->iInterfacingObjectContainer->getHttpHeadRequestDisabled() &&
+            !iForceSocketReconnect) return false;
     return true;
 }
 
 PVMFStatus ProgressiveDownloadContainer::initImpl()
 {
-    if (!iNode->iInterfacingObjectContainer.getHttpHeadRequestDisabled()) return ProtocolContainer::initImpl();
+    if (!iNode->iInterfacingObjectContainer->getHttpHeadRequestDisabled()) return ProtocolContainer::initImpl();
 
     if (!isObjectsReady())
     {
@@ -111,7 +113,7 @@
 {
     OsclSharedPtr<PVDlCfgFile> aCfgFile = iNode->iCfgFileContainer->getCfgFile();
     if (aCfgFile.GetRep() == NULL) return false;
-    aCfgFile->setHttpHeadRequestDisabled(iNode->iInterfacingObjectContainer.getHttpHeadRequestDisabled());
+    aCfgFile->setHttpHeadRequestDisabled(iNode->iInterfacingObjectContainer->getHttpHeadRequestDisabled());
     return DownloadContainer::initProtocol_SetConfigInfo();
 }
 
@@ -154,7 +156,8 @@
         uint32 aInstantByterate = divisionInMilliSec(aCurrDownloadSize, aNPTInMS);			// aCurrDownloadSize*1000/aNPTInMS
         LOGINFODATAPATH((0, "progressiveDownloadControl::isPlaybackRateCloseToClipBitrate, check Instant rate=%d(currDLSize=%d, NPTTimeMs=%d), clip bitrate=%d",
                          (aInstantByterate << 3), aCurrDownloadSize, aNPTInMS, (iClipByterate << 3)));
-        if (OSCL_ABS(aInstantByterate - iClipByterate) < GET_10_PERCENT(iClipByterate) || // OSCL_ABS(aInstantByterate-iClipByterate)/iClipByterate < 1/8-1/64=0.109
+        uint32 diffByterate = (aInstantByterate >= iClipByterate ? aInstantByterate - iClipByterate : iClipByterate - aInstantByterate);
+        if (diffByterate < GET_10_PERCENT(iClipByterate) || // OSCL_ABS(aInstantByterate-iClipByterate)/iClipByterate < 1/8-1/64=0.109
                 isBufferingEnoughTime(aCurrDownloadSize, PVPROTOCOLENGINE_JITTER_BUFFER_SIZE_TIME, aNPTInMS))
         {
             if (isBufferingEnoughTime(aCurrDownloadSize, PVPROTOCOLENGINE_JITTER_BUFFER_SIZE_TIME, aNPTInMS))
@@ -196,7 +199,7 @@
             uint32 aPrevNPTInMS = 0;
             if (iProgDownloadSI->convertSizeToTime(iPrevDownloadSize, aPrevNPTInMS) == 0)
             {
-                return ((aNPTInMS -aPrevNPTInMS) >= aBufferTimeLimitInSec*1000);
+                return (aNPTInMS > aPrevNPTInMS && (aNPTInMS - aPrevNPTInMS) >= aBufferTimeLimitInSec*1000);
             }
         }
     }
@@ -208,16 +211,15 @@
     aNewDurationMsec = aCurrDurationMsec;
     if (aCurrDurationMsec > 0 && iClipByterate == 0)
     {
-        if (iProtocol->getContentLength() > 0) iClipByterate = divisionInMilliSec(iProtocol->getContentLength(), aCurrDurationMsec);
+        if (iFileSize > 0) iClipByterate = divisionInMilliSec(iFileSize, aCurrDurationMsec);
     }
 
     if (iPlaybackByteRate > 0)
     {
-        uint32 aFileSize = iProtocol->getContentLength();
         if (iPlaybackByteRate > iClipByterate)
         {
             uint32 averPlaybackRate = (iClipByterate + iPlaybackByteRate) / 2;
-            aNewDurationMsec = divisionInMilliSec(aFileSize, averPlaybackRate); // aFileSize/averPlaybackRate*1000
+            aNewDurationMsec = divisionInMilliSec(iFileSize, averPlaybackRate); // aFileSize/averPlaybackRate*1000
         }
     }
     return true;
@@ -294,7 +296,8 @@
         // larger than that from output object
 
         if (iProgDownloadSI->convertSizeToTime(iNodeOutput->getCurrentOutputSize(), aDownloadNPTTime) != 0) return false;
-        iDlProgressClock->SetStartTime32(aDownloadNPTTime, OSCLCLOCK_MSEC);
+        bool bOverflowFlag = false;
+        iDlProgressClock->SetStartTime32(aDownloadNPTTime, PVMF_MEDIA_CLOCK_MSEC, bOverflowFlag);
     }
     return true;
 }
@@ -322,8 +325,9 @@
     DownloadProgress::setSupportObject(aDLSupportObject, aType);
 }
 
-bool ProgressiveDownloadProgress::updateDownloadClock()
+bool ProgressiveDownloadProgress::updateDownloadClock(const bool aDownloadComplete)
 {
+    OSCL_UNUSED_ARG(aDownloadComplete);
     if (iProtocol) iDownloadSize = iNodeOutput->getCurrentOutputSize();
     if (iDownloadSize == 0) return false;
     return checkDownloadPercentModeAndUpdateDLClock();
@@ -373,12 +377,17 @@
     {
         // byte-based download percentage
         aDownloadProgressPercent = iDownloadSize;
-        if (aFileSize)
+        if (aFileSize > 0)
         {
             aDownloadProgressPercent = getDownloadBytePercent(iDownloadSize, aFileSize);
             if (aDownloadProgressPercent > 100) aDownloadProgressPercent = 100;
             if (aDownloadProgressPercent == 100) iDownloadSize = aFileSize;
         }
+        else
+        {
+            uint32 aMaxFileSize = iCfgFileContainer->getCfgFile()->GetMaxAllowedFileSize();
+            if (aDownloadProgressPercent > aMaxFileSize) aDownloadProgressPercent = aMaxFileSize;
+        }
     }
     return true;
 }
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.h
index 6f753d1..f9f47e5 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_download.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -137,7 +137,7 @@
 
     protected:
         virtual bool calculateDownloadPercent(uint32 &aDownloadProgressPercent);
-        bool updateDownloadClock();
+        bool updateDownloadClock(const bool aDownloadComplete);
         bool calculateDownloadPercentBody(uint32 &aDownloadProgressPercent, const uint32 aFileSize);
         // determine if download percent is time-based or byte-based
         bool checkDownloadPercentModeAndUpdateDLClock();
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.cpp
index 1b3367d..3180345 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 #include "pvmf_protocol_engine_node.h"
 #include "pvmf_protocol_engine_node_progressive_streaming.h"
 #include "pvmf_protocol_engine_progressive_download.h"
+#include "pvmf_protocolengine_node_tunables.h"
 
 #include "pvlogger.h"
 
@@ -35,6 +36,8 @@
 #define PVMF_PROTOCOL_ENGINE_LOGBIN(iPortLogger, m) PVLOGGER_LOGBIN(PVLOGMSG_INST_LLDBG, iPortLogger, PVLOGMSG_ERR, m);
 #define	NODEDATAPATHLOGGER_TAG "datapath.sourcenode.protocolenginenode"
 
+#define IS_OVERFLOW_FOR_100x(x) ( (x)>>((sizeof((x))<<2)-PVPROTOCOLENGINE_DOWNLOAD_BYTE_PERCENTAGE_DLSIZE_RIGHTSHIFT_FACTOR) ) // (x)>>(32-7)=(x)>>25
+
 ////////////////////////////////////////////////////////////////////////////////////
 //////	ProgressiveStreamingContainerFactory implementation
 ////////////////////////////////////////////////////////////////////////////////////
@@ -47,14 +50,15 @@
 //////	ProgressiveStreamingContainer implementation
 ////////////////////////////////////////////////////////////////////////////////////
 ProgressiveStreamingContainer::ProgressiveStreamingContainer(PVMFProtocolEngineNode *aNode) :
-        ProgressiveDownloadContainer(aNode),
-        iEnableInfoUpdate(true)
+        ProgressiveDownloadContainer(aNode), iEnableInfoUpdate(true)
 {
     ;
 }
 
 bool ProgressiveStreamingContainer::createProtocolObjects()
 {
+    if (!ProtocolContainer::createProtocolObjects()) return false;
+
     iNode->iProtocol		 = OSCL_NEW(ProgressiveStreaming, ());
     iNode->iNodeOutput		 = OSCL_NEW(pvProgressiveStreamingOutput, (iNode));
     iNode->iDownloadControl  = OSCL_NEW(progressiveStreamingControl, ());
@@ -72,15 +76,22 @@
     {
         iNode->iNodeOutput->setDataStreamSourceRequestObserver((PvmiDataStreamRequestObserver*)iNode);
     }
-
-    return ProtocolContainer::createProtocolObjects();
+    return true;
 }
 
 PVMFStatus ProgressiveStreamingContainer::doStop()
 {
+    PVMFStatus status = DownloadContainer::doStop();
+    if (status != PVMFSuccess) return status;
     // For progressive streaming, tell the data stream to flush,
     // so that the socket buffer can be returned to socket node for reset
     iNode->iNodeOutput->flushDataStream();
+
+    // set resume download mode for stop and play
+    OsclSharedPtr<PVDlCfgFile> aCfgFile = iNode->iCfgFileContainer->getCfgFile();
+    aCfgFile->SetNewSession(true); // don't set resume download session for the next time
+    if (aCfgFile->GetCurrentFileSize() >= aCfgFile->GetOverallFileSize()) aCfgFile->SetCurrentFileSize(0);
+
     return PVMFSuccess;
 }
 
@@ -107,15 +118,16 @@
 {
     // reset streaming done and session done flag to restart streaming
     ProtocolStateCompleteInfo aInfo;
-    iNode->iInterfacingObjectContainer.setProtocolStateCompleteInfo(aInfo, true);
+    iNode->iInterfacingObjectContainer->setProtocolStateCompleteInfo(aInfo, true);
 
     // HTTP GET request looks at the current file size to determine is Range header is needed
+    // TBD, there may be a better way to do this
     OsclSharedPtr<PVDlCfgFile> aCfgFile = iNode->iCfgFileContainer->getCfgFile();
     aCfgFile->SetCurrentFileSize(aNewOffset);
 
     // Reconnect and send new GET request
     iNode->iProtocol->seek(aNewOffset);
-    iNode->StartDataFlowByCommand();
+    startDataFlowByCommand();
 
     return PVMFPending;
 }
@@ -135,6 +147,7 @@
     iNode->iNodeOutput->setCurrentOutputSize(newOffset);
     iNode->iDownloadControl->setPrevDownloadSize(newOffset);
 
+    // find out if download was completed for the previous GET request
     // reset initial buffering algo variables
     iNode->iDownloadControl->clearPerRequest();
 
@@ -143,6 +156,8 @@
     // Make the Command Complete notification
     iNode->iNodeOutput->dataStreamCommandCompleted(resp);
     iNode->iCurrentCommand.Erase(pCmd);
+    iNode->iInterfaceState = EPVMFNodeStarted;
+    iNode->iEventReport->startRealDataflow(); // since the state gets changed to started state, enable the buffer status update
     return true;
 }
 
@@ -160,7 +175,6 @@
     if (iNode->iDownloadControl->checkResumeNotification(downloadComplete) == 1)
     {
         LOGINFODATAPATH((0, "ProgressiveStreamingContainer::updateDownloadControl, send data ready event to parser node, downloadComplete=false"));
-
         // report data ready event
         iNode->iEventReport->sendDataReadyEvent();
     }
@@ -169,19 +183,12 @@
     iNode->iDownloadProgess->update(isDownloadComplete);
 }
 
-void ProgressiveStreamingContainer::checkSendResumeNotification()
+bool ProgressiveStreamingContainer::needToCheckResumeNotificationMaually()
 {
-    // check the special case to trigger node running to send back resume notification to parser node if there is
-    if (iNode->iNodeOutput->getAvailableOutputSize() == 0 && iEnableInfoUpdate)
-    {
-        //!iNode->IsRepositioningRequestPending()) {
-        // form PVProtocolEngineNodeInternalEventType_CheckResumeNotificationMaually event
-        PVProtocolEngineNodeInternalEvent aEvent(PVProtocolEngineNodeInternalEventType_CheckResumeNotificationMaually);
-        iNode->iInternalEventQueue.clear();
-        iNode->iInternalEventQueue.push_back(aEvent);
-        iNode->SetProcessingState(ProcessingState_NormalDataflow);
-        iNode->RunIfNotReady();
-    }
+    iNode->iEventReport->enableBufferingCompleteEvent();
+
+    if (DownloadContainer::needToCheckResumeNotificationMaually()) return true;
+    return (iNode->iNodeOutput->getAvailableOutputSize() == 0 && iEnableInfoUpdate);
 }
 
 bool ProgressiveStreamingContainer::doInfoUpdate(const uint32 downloadStatus)
@@ -189,7 +196,6 @@
     // For pending reposition request, don't do auto-resume checking
     //if(iNode->IsRepositioningRequestPending()) return true;
     if (!iEnableInfoUpdate) return true;
-
     return DownloadContainer::doInfoUpdate(downloadStatus);
 }
 
@@ -336,20 +342,22 @@
                      (uint32)iPlaybackUnderflow, (uint32)iRequestResumeNotification, (uint32)iDownloadComplete));
 
     iDownloadComplete = aDownloadComplete = false;
+    iSendDownloadCompleteNotification = false;
     pvDownloadControl::requestResumeNotification(currentNPTReadPosition, aDownloadComplete, aNeedSendUnderflowEvent);
 }
 
-
 void progressiveStreamingControl::clearPerRequest()
 {
     // for progressive playback
     // after each repositioning (aka new GET request)
     // the following variables must be reset
     // to enable auto pause and resume to function properly
-    iDlAlgoPreConditionMet         = false;
-    iDownloadComplete              = false;
+    iDlAlgoPreConditionMet = false;
+    iDownloadComplete      = false;
+    iSendDownloadCompleteNotification = false;
 }
 
+
 ////////////////////////////////////////////////////////////////////////////////////
 //////	ProgressiveStreamingProgress implementation
 ////////////////////////////////////////////////////////////////////////////////////
@@ -367,3 +375,44 @@
     return ProgressiveDownloadProgress::calculateDownloadPercentBody(aDownloadProgressPercent, fileSize);
 }
 
+////////////////////////////////////////////////////////////////////////////////////
+//////	progressiveStreamingEventReporter implementation
+////////////////////////////////////////////////////////////////////////////////////
+void progressiveStreamingEventReporter::reportBufferStatusEvent(const uint32 aDownloadPercent)
+{
+    // calculate buffer fullness
+
+    uint32 aBufferFullness = getBufferFullness();
+    if (aBufferFullness == 0xffffffff) return;
+
+    iNode->ReportInfoEvent(PVMFInfoBufferingStatus,
+                           (OsclAny*)aBufferFullness,
+                           PVMFPROTOCOLENGINENODEInfo_BufferingStatus,
+                           (uint8*)(&aDownloadPercent),
+                           sizeof(aDownloadPercent));
+    LOGINFODATAPATH((0, "progressiveStreamingEventReporter::reportBufferStatusEvent() DOWNLOAD PERCENTAGE: %d", aDownloadPercent));
+}
+
+uint32 progressiveStreamingEventReporter::getBufferFullness()
+{
+
+    uint32 aCacheSize = iNode->iNodeOutput->getMaxAvailableOutputSize();
+    if (aCacheSize == 0) return 0xffffffff;
+    uint32 aCacheFilledSize = iNode->iNodeOutput->getAvailableOutputSize();
+    if (aCacheFilledSize >= aCacheSize) return 100;
+
+    // avoid fix-point multiplication overflow
+    uint32 aBufferEmptiness = 0xffffffff;
+    if (IS_OVERFLOW_FOR_100x(aCacheFilledSize) > 0)
+    {
+        aBufferEmptiness = (aCacheFilledSize >> PVPROTOCOLENGINE_DOWNLOAD_BYTE_PERCENTAGE_DLSIZE_RIGHTSHIFT_FACTOR) * 100 /
+                           (aCacheSize >> PVPROTOCOLENGINE_DOWNLOAD_BYTE_PERCENTAGE_DLSIZE_RIGHTSHIFT_FACTOR);
+    }
+    else
+    {
+        aBufferEmptiness = aCacheFilledSize * 100 / aCacheSize;
+    }
+
+    return 100 -aBufferEmptiness;
+}
+
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.h
index d1c469f..4e99c7e 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_node_progressive_streaming.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@
         PVMFStatus doStop();
         PVMFStatus doSeek(PVMFProtocolEngineNodeCommand& aCmd);
         bool completeRepositionRequest();
-        void checkSendResumeNotification();
         bool doInfoUpdate(const uint32 downloadStatus);
         void enableInfoUpdate(const bool aEnabled = true)
         {
@@ -49,6 +48,7 @@
         uint32 getSeekOffset(PVMFProtocolEngineNodeCommand& aCmd);
         PVMFStatus doSeekBody(uint32 aNewOffset);
         void updateDownloadControl(const bool isDownloadComplete = false);
+        bool needToCheckResumeNotificationMaually();
 
     private:
         bool iEnableInfoUpdate;
@@ -82,7 +82,7 @@
         pvProgressiveStreamingOutput(PVMFProtocolEngineNodeOutputObserver *aObserver = NULL);
         virtual ~pvProgressiveStreamingOutput()
         {
-            ;
+            flushDataStream();
         }
 
     private:
@@ -167,6 +167,10 @@
         {
             OSCL_UNUSED_ARG(downloadStatus);
         }
+        // in case of progressive streaming, add buffer fullness information into buffer status report
+        void reportBufferStatusEvent(const uint32 aDownloadPercent);
+        // called by reportBufferStatusEvent
+        uint32 getBufferFullness();
 };
 
 
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.cpp
index 4187e82..a038a37 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,17 +70,34 @@
 ////////////////////////////////////////////////////////////////////////////
 bool PVMFProtocolEnginePort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return (aFmt == PVMF_INET_TCP);
+    bool formatSupported = false;
+    if (aFmt == PVMF_MIME_INET_TCP)
+    {
+        formatSupported = true;
+    }
+    return formatSupported;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PVMFProtocolEnginePort::FormatUpdated()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFProtocolEnginePort::FormatUpdated() %d", iFormat));
+                    , (0, "PVMFProtocolEnginePort::FormatUpdated() %s", iFormat.getMIMEStrPtr()));
 }
 
 ////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFProtocolEnginePort::QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg)
+{
+    uint32 aOutgoingQueueSizeBefore = OutgoingMsgQueueSize();
+    PVMFStatus status = PvmfPortBaseImpl::QueueOutgoingMsg(aMsg);
+    if (status != PVMFSuccess) return status;
+    uint32 aOutgoingQueueSizeAfter = OutgoingMsgQueueSize();
+    if (aOutgoingQueueSizeBefore == aOutgoingQueueSizeAfter) return PVMFSuccessOutgoingMsgSent;
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
 bool PVMFProtocolEnginePort::PeekOutgoingMsg(PVMFSharedMediaMsgPtr& aMsg)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.h
index 995cd9e..071c982 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@
 //Default vector reserve size
 #define PVMF_PROTOCOLENGINE_NODE_PORT_VECTOR_RESERVE 10
 
+const PVMFStatus PVMFSuccessOutgoingMsgSent = 10;
+
 
 class PVMFProtocolEnginePort : public PvmfPortBaseImpl,
             public PvmiCapabilityAndConfigPortFormatImpl
@@ -75,6 +77,9 @@
             }
         }
 
+        // override the base implementation
+        PVMFStatus QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg);
+
         bool PeekOutgoingMsg(PVMFSharedMediaMsgPtr& aMsg);
 
     private:
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.cpp b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.cpp
index 44e04d9..7b80b5a 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.cpp
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,10 +54,11 @@
 
 int32 ProgressiveDownloadState_HEAD::OutputDataAvailable(OUTPUT_DATA_QUEUE *aOutputQueue, const bool isHttpHeader)
 {
-    OSCL_ASSERT(isHttpHeader == true);
-    //if(iObserver) iObserver->HttpHeaderAvailable(*aOutputQueue);
-    iDataSideInfo.set(ProtocolEngineOutputDataType_HttpHeader);
-    iObserver->OutputDataAvailable(*aOutputQueue, iDataSideInfo);
+    if (isHttpHeader)
+    {
+        iDataSideInfo.set(ProtocolEngineOutputDataType_HttpHeader);
+        iObserver->OutputDataAvailable(*aOutputQueue, iDataSideInfo);
+    }
     return HttpParsingBasicObject::PARSE_SUCCESS;
 }
 
diff --git a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.h b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.h
index 5fe79c3..056660a 100644
--- a/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.h
+++ b/nodes/pvprotocolenginenode/src/pvmf_protocol_engine_progressive_download.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,7 +67,6 @@
 
         void reset()
         {
-            iOutputDataQueue.clear();
             iSendEndOfMessageTruncate = false;
             DownloadState::reset();
         }
diff --git a/nodes/pvsocketnode/Android.mk b/nodes/pvsocketnode/Android.mk
index 44a5eb7..df36cfc 100644
--- a/nodes/pvsocketnode/Android.mk
+++ b/nodes/pvsocketnode/Android.mk
@@ -3,31 +3,35 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_socket_node.cpp \
-	src/pvmf_socket_factory.cpp \
-	src/pvmf_socket_port.cpp
-
+ 	src/pvmf_socket_node_extension_interface.cpp \
+ 	src/pvmf_socket_factory.cpp \
+ 	src/pvmf_socket_port.cpp
 
 
 LOCAL_MODULE := libpvsocketnode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvsocketnode/include \
-	$(PV_TOP)//nodes/pvsocketnode/src \
-	$(PV_TOP)//nodes/pvsocketnode/../streaming/common/include \
-	$(PV_TOP)//nodes/pvsocketnode/config/common \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvsocketnode/src \
+ 	$(PV_TOP)/nodes/pvsocketnode/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_TOP)/nodes/pvsocketnode/config/common \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_socket_node_extension_interface.h \
-	include/pvmf_socket_factory.h \
-	include/pvmf_socket_node.h \
-	include/pvmf_socket_port.h \
-	include/pvmf_socket_node_events.h
+ 	include/pvmf_socket_factory.h \
+ 	include/pvmf_socket_node.h \
+ 	include/pvmf_socket_port.h \
+ 	include/pvmf_socket_node_events.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvsocketnode/build/make/local.mk b/nodes/pvsocketnode/build/make/local.mk
new file mode 100644
index 0000000..d3442fc
--- /dev/null
+++ b/nodes/pvsocketnode/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvsocketnode
+
+
+XINCDIRS +=  ../../../streaming/common/include  ../../config/common
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_socket_node.cpp \
+        pvmf_socket_node_extension_interface.cpp \
+	pvmf_socket_factory.cpp \
+	pvmf_socket_port.cpp
+
+HDRS := pvmf_socket_node_extension_interface.h \
+	pvmf_socket_factory.h \
+	pvmf_socket_node.h \
+	pvmf_socket_port.h \
+	pvmf_socket_node_events.h
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvsocketnode/build/make/makefile b/nodes/pvsocketnode/build/make/makefile
deleted file mode 100644
index 65be8db..0000000
--- a/nodes/pvsocketnode/build/make/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvsocketnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../streaming/common/include -I ../../config/common
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =  pvmf_socket_node.cpp \
-	pvmf_socket_factory.cpp \
-	pvmf_socket_port.cpp
-
-HDRS = 	pvmf_socket_node_extension_interface.h \
-	pvmf_socket_factory.h \
-	pvmf_socket_node.h \
-	pvmf_socket_port.h \
-	pvmf_socket_node_events.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvsocketnode/config/common/pvmf_socket_node_tunables.h b/nodes/pvsocketnode/config/common/pvmf_socket_node_tunables.h
index 35c17d5..09dc3ba 100644
--- a/nodes/pvsocketnode/config/common/pvmf_socket_node_tunables.h
+++ b/nodes/pvsocketnode/config/common/pvmf_socket_node_tunables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -91,6 +91,7 @@
 */
 #ifndef SNODE_UDP_MULTI_MAX_BYTES_PER_RECV
 #define SNODE_UDP_MULTI_MAX_BYTES_PER_RECV (16*1024)
+#define SNODE_UDP_MULTI_MIN_BYTES_PER_RECV (2*1024)
 #endif
 
 #endif// PVMF_SOCKET_NODE_TUNABLES_H_INCLUDED
diff --git a/nodes/pvsocketnode/include/pvmf_socket_factory.h b/nodes/pvsocketnode/include/pvmf_socket_factory.h
index d2c0d86..fdb3a68 100644
--- a/nodes/pvsocketnode/include/pvmf_socket_factory.h
+++ b/nodes/pvsocketnode/include/pvmf_socket_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvsocketnode/include/pvmf_socket_node.h b/nodes/pvsocketnode/include/pvmf_socket_node.h
index 86c5fef..49b3af9 100644
--- a/nodes/pvsocketnode/include/pvmf_socket_node.h
+++ b/nodes/pvsocketnode/include/pvmf_socket_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -72,7 +72,9 @@
 #ifndef PVMF_SM_TUNABLES_H_INCLUDED
 #include "pvmf_sm_tunables.h"
 #endif
-
+#ifndef PVMF_RESIZABLE_SIMPLE_MEDIAMSG_H_INCLUDED
+#include "pvmf_resizable_simple_mediamsg.h"
+#endif
 #include "pvmf_socket_node_events.h"
 #include "pvmf_media_frag_group.h"
 
@@ -91,6 +93,8 @@
 #define PVMF_SOCKETNODE_LOGWARNING(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_WARNING,m);
 #define PVMF_SOCKETNODE_LOGDATATRAFFIC_I(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_INFO,m);
 #define PVMF_SOCKETNODE_LOGDATATRAFFIC_E(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_ERR,m);
+#define PVMF_SOCKETNODE_LOGDATATRAFFIC_RTP(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerRTP,PVLOGMSG_INFO,m);
+#define PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerRTCP,PVLOGMSG_INFO,m);
 
 //memory allocator type for this node.
 typedef OsclMemAllocator PVMFSocketNodeAllocator;
@@ -131,50 +135,61 @@
 
         OsclSharedPtr<PVMFMediaDataImpl> getMediaDataImpl(uint32 size)
         {
-            return (iSocketAllocSharedPtr->createSharedBuffer(size));
+            OsclSharedPtr<PVMFMediaDataImpl> mediaImpl = iMediaMsgAllocator->allocate(size);
+            return mediaImpl;
         }
 
         void resizeSocketDataBuffer(OsclSharedPtr<PVMFMediaDataImpl>& aSharedBuffer)
         {
-            if (iSocketAllocSharedPtr.GetRep() != NULL)
+            if (iMediaMsgAllocator != NULL)
             {
-                iSocketAllocSharedPtr->ResizeMemoryFragment(aSharedBuffer);
+                iMediaMsgAllocator->ResizeMemoryFragment(aSharedBuffer);
             }
         }
 
-        void notifyfreechunkavailable(OsclMemPoolFixedChunkAllocatorObserver& aObserver,
-                                      uint32 aSize,
-                                      OsclAny* aContextData = NULL)
+        void CreateAllocators(const OSCL_HeapString<OsclMemAllocator>& iMime, uint32 aSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes);
+        OsclMemPoolResizableAllocator* CreateResizableDataBufferAllocator(const char* allocatorName);
+        void CreateDefaultDataBufferAllocator(const char* allocatorName);
+        void CreateUDPMultipleRecvAllocator();
+
+        uint32 GetMaxSizeMediaMsgLen();
+
+        void DestroyAllocators();
+        void DestroyUDPMultipleRecvAllocator();
+
+        class SharedDataBufferInfo
         {
-            if (iSocketAllocSharedPtr.GetRep() != NULL)
-            {
-                iSocketAllocSharedPtr->notifyfreechunkavailable(aObserver, aSize, aContextData);
-            }
-        }
-
-        void CancelFreeChunkAvailableCallback()
-        {
-            if (iSocketAllocSharedPtr.GetRep() != NULL)
-            {
-                iSocketAllocSharedPtr->CancelFreeChunkAvailableCallback();
-            }
-        }
-
-        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> iSocketAllocSharedPtr;
-
+            public:
+                SharedDataBufferInfo(): iSize(0), iResizeSize(0), iMaxNumResizes(0), iExpectedNumberOfBlocksPerBuffer(0) {}
+                void Init(uint32 aSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes)
+                {
+                    iSize = aSize;
+                    iResizeSize = aResizeSize;
+                    iMaxNumResizes = aMaxNumResizes;
+                    iExpectedNumberOfBlocksPerBuffer = aExpectedNumberOfBlocksPerBuffer;
+                }
+                uint32 iSize;
+                uint32 iResizeSize;
+                uint32 iMaxNumResizes;
+                uint32 iExpectedNumberOfBlocksPerBuffer;
+        };
+        SharedDataBufferInfo iSharedDataBufferInfo;
         // Memory pool for media data objects
         OsclMemPoolFixedChunkAllocator* iMediaDataMemPool;
 
-        int32 iPortTag;
+        // Allocators for persisting the data received from the server (on all the ports) are created in respective SocketConfig.
+        //For UDP [RTSP Based Streaming], allocators will be created before connection of port to its peer completes.
+        //For TCP [MSHTTP Streaming], size of the memory pool for Data is determined only after receiving ASF header from the streaming server
+        //therefore, to persist the response of the Server before completion of receiving the ASF header, an internal shared buffer allocator is created.
+        PVMFResizableSimpleMediaMsgAlloc* iMediaMsgAllocator;
+        OsclMemPoolResizableAllocator*	iSharedBufferAlloc;
+        OsclMemPoolResizableAllocator*	iInternalAlloc;//[MSHTTP Streaming Specific specific]
 
-        // Allocator created in this node, for TCP only.
-        // (For UDP, the JB node owns the allocator and passes
-        // it in during the call to setSocketPortMemAllocator)
-        PVMFSMSharedBufferAllocWithReSize* iInternalAlloc;
-
-        // Allocator for multiple receives, for UDP only.
+        // Allocator for multiple receives[ for UDP only, will be created and used only when SNODE_ENABLE_UDP_MULTI_PACKET is defined].
         PVMFMediaFragGroupCombinedAlloc<PVMFSocketNodeAllocator>* iMediaFragGroupAlloc;
         OsclMemPoolFixedChunkAllocator* iMediaFragGroupAllocMempool;
+
+        int32 iPortTag;
 };
 
 /*
@@ -552,7 +567,7 @@
 ** SocketPortConfig contains all the information associated with a port including
 ** the Oscl socket, memory pool, and status.
 */
-class SocketPortConfig : public OsclMemPoolFixedChunkAllocatorObserver
+class SocketPortConfig : public OsclMemPoolFixedChunkAllocatorObserver, public OsclMemPoolResizableAllocatorObserver
 {
     public:
         SocketPortConfig()
@@ -566,12 +581,13 @@
             iContainer = NULL;
             iTag = PVMF_SOCKET_NODE_PORT_TYPE_UNKNOWN;
             iRTP = false;
+            iRTCP = false;
         };
-
-        void DoSetSocketPortMemAllocator(PVLogger*, OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc);
-        void CleanupMemPools();
+        void CleanupMemPools(Oscl_DefAlloc& aAlloc);
+        void CreateAllocators(uint32 aSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes);
 
         void freechunkavailable(OsclAny* aContextData);
+        void freeblockavailable(OsclAny* aContextData);
 
         SocketPortState iState;
 
@@ -597,6 +613,7 @@
 
         OSCL_HeapString<OsclMemAllocator> iMime;
         bool iRTP;
+        bool iRTCP;
 
 #if(ENABLE_SOCKET_NODE_STATS)
         SocketNodePortStats iPortStats;
@@ -712,32 +729,16 @@
 ** The Socket Node
 */
 class PVMFSocketNode
-            : public PVMFNodeInterface
+            : public PVInterface
+            , public PVMFNodeInterface
             , public OsclActiveObject
             , public OsclSocketObserver
             , public OsclDNSObserver
-            , public PVMFSocketNodeExtensionInterface
 {
     public:
-
         OSCL_IMPORT_REF PVMFSocketNode(int32 aPriority);
         OSCL_IMPORT_REF ~PVMFSocketNode();
 
-
-        //**********begin PVMFSocketNodeExtensionInterface
-        OSCL_IMPORT_REF void addRef();
-        OSCL_IMPORT_REF void removeRef();
-        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        OSCL_IMPORT_REF PVMFStatus AllocateConsecutivePorts(PvmfMimeString* aPortConfig,
-                uint32& aLowerPortNum,
-                uint32& aHigherPortNum, uint32& aStartPortNum);
-        OSCL_IMPORT_REF PVMFStatus SetMaxTCPRecvBufferSize(uint32 aBufferSize);
-        OSCL_IMPORT_REF PVMFStatus GetMaxTCPRecvBufferSize(uint32& aSize);
-        OSCL_IMPORT_REF PVMFStatus SetMaxTCPRecvBufferCount(uint32 aBufferSize);
-        OSCL_IMPORT_REF PVMFStatus GetMaxTCPRecvBufferCount(uint32& aSize);
-
-        //**********end PVMFSocketNodeExtensionInterface
-
         //************ begin OsclSocketObserver
         OSCL_IMPORT_REF void HandleSocketEvent(int32 aId, TPVSocketFxn aFxn, TPVSocketEvent aEvent, int32 aError);
         //************ end OsclSocketObserver
@@ -782,9 +783,26 @@
         OSCL_IMPORT_REF bool GetPortConfig(PVMFPortInterface &aPort, OsclNetworkAddress &aLocalAdd, OsclNetworkAddress &aRemoteAdd);
         OSCL_IMPORT_REF bool SetPortConfig(PVMFPortInterface &aPort, OsclNetworkAddress aLocalAdd, OsclNetworkAddress aRemoteAdd);
 
-        OSCL_IMPORT_REF bool setSocketPortMemAllocator(PVMFPortInterface* aPort,
-                OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc);
+        virtual void addRef()
+        {
+        }
 
+        virtual void removeRef()
+        {
+        }
+
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+        //**********begin PVMFSocketNodeExtensionInterface
+        PVMFStatus AllocateConsecutivePorts(PvmfMimeString* aPortConfig,
+                                            uint32& aLowerPortNum,
+                                            uint32& aHigherPortNum, uint32& aStartPortNum);
+        OSCL_IMPORT_REF PVMFStatus SetMaxTCPRecvBufferSize(uint32 aBufferSize);
+        OSCL_IMPORT_REF PVMFStatus GetMaxTCPRecvBufferSize(uint32& aSize);
+        OSCL_IMPORT_REF PVMFStatus SetMaxTCPRecvBufferCount(uint32 aBufferSize);
+        OSCL_IMPORT_REF PVMFStatus GetMaxTCPRecvBufferCount(uint32& aSize);
+        OsclMemPoolResizableAllocator* CreateSharedBuffer(const PVMFPortInterface* aPort , uint32 aBufferSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes);
+        //**********end PVMFSocketNodeExtensionInterface
 
     private:
         friend class SocketPortConfig;
@@ -793,16 +811,8 @@
         void Run();
 
         /*********************************************
-        * Socket extension interface
-        **********************************************/
-
-        // Reference counter for extension
-        uint32 iExtensionRefCount;
-
-        /*********************************************
         * Command Processing and Event Notification
         **********************************************/
-
         //Command queue type
         typedef PVMFNodeCommandQueue<PVMFSocketNodeCommand, PVMFSocketNodeAllocator> PVMFSocketNodeCmdQ;
 
@@ -851,6 +861,11 @@
 
         PVMFStatus DoCancelCurrentCommand(PVMFSocketNodeCmdQ& aCmdQ, PVMFSocketNodeCommand& aCmd);
         PVMFStatus DoStopNodeActivity();
+        int32 SocketPlacementNew(PVMFSocketNodeMemPool*&, OsclAny*, int32);
+        int32 CreateMediaData(SocketPortConfig&, OsclSharedPtr<PVMFMediaDataImpl>&);
+        int32 Allocate(SocketPortConfig&, OsclSharedPtr<PVMFMediaDataImpl>&);
+        int32 GetMediaDataImpl(SocketPortConfig&, OsclSharedPtr<PVMFMediaDataImpl>&, int32);
+
         PVMFSocketPort* iRequestedPort;
 
         //node state
@@ -880,8 +895,8 @@
         * Oscl Socket Handling
         **********************************************/
 
-        void HandleRecvComplete(SocketPortConfig& tmpSockConfig, PVMFStatus, PVMFSocketActivity*);
-        void HandleRecvFromComplete(SocketPortConfig& tmpSockConfig, PVMFStatus, PVMFSocketActivity*);
+        void HandleRecvComplete(SocketPortConfig& tmpSockConfig, PVMFStatus, PVMFSocketActivity*, bool);
+        void HandleRecvFromComplete(SocketPortConfig& tmpSockConfig, PVMFStatus, PVMFSocketActivity*, bool);
 
         OsclSocketServ	*iSockServ;
 
@@ -893,6 +908,7 @@
         const int TIMEOUT_SHUTDOWN;
         const int UDP_PORT_RANGE;
         const int MAX_UDP_PACKET_SIZE;
+        const int MIN_UDP_PACKET_SIZE;
 
         int32 iMaxTcpRecvBufferSize;
         int32 iMaxTcpRecvBufferCount;
@@ -982,18 +998,44 @@
 
         PVLogger *iLogger;
         PVLogger *iDataPathLogger;
+        PVLogger *iDataPathLoggerRTP;
+        PVLogger *iDataPathLoggerRTCP;
 
         void LogRTPHeaderFields(SocketPortConfig& aSockConfig,
                                 OsclRefCounterMemFrag& memFragIn);
 
+        void LogRTCPHeaderFields(SocketPortConfig& aSockConfig,
+                                 OsclRefCounterMemFrag& memFragIn);
+
         OsclErrorTrapImp* iOsclErrorTrapImp;
 
         PVMFSocketNodeAllocator iAlloc;
-
+        PVMFSocketNodeExtensionInterface* iExtensionInterface;
 #if(ENABLE_SOCKET_NODE_STATS)
         SocketNodeStats iSocketNodeStats;
 #endif
 };
 
+class PVMFSocketNodeExtensionInterfaceImpl: public PVInterfaceImpl<PVMFSocketNodeAllocator>, public  PVMFSocketNodeExtensionInterface
+{
+    public:
+        PVMFSocketNodeExtensionInterfaceImpl(PVMFSocketNode* iContainer);
+        ~PVMFSocketNodeExtensionInterfaceImpl();
+        virtual void addRef();
+        virtual void removeRef();
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface); //From PVInterface
+        OSCL_IMPORT_REF virtual PVMFStatus AllocateConsecutivePorts(PvmfMimeString* aPortConfig,
+                uint32& aLowerPortNum,
+                uint32& aHigherPortNum, uint32& aStartPortNum);
+
+        OSCL_IMPORT_REF virtual PVMFStatus SetMaxTCPRecvBufferSize(uint32 aBufferSize);
+        OSCL_IMPORT_REF virtual PVMFStatus GetMaxTCPRecvBufferSize(uint32& aSize);
+        OSCL_IMPORT_REF virtual PVMFStatus SetMaxTCPRecvBufferCount(uint32 aCount);
+        OSCL_IMPORT_REF virtual PVMFStatus GetMaxTCPRecvBufferCount(uint32& aCount);
+        OSCL_IMPORT_REF virtual OsclMemPoolResizableAllocator* CreateSharedBuffer(const PVMFPortInterface* aPort , uint32 aBufferSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes);
+    private:
+        PVMFSocketNode *iContainer;
+};
+
 #endif //PVMF_SOCKET_NODE_H_INCLUDED
 
diff --git a/nodes/pvsocketnode/include/pvmf_socket_node_events.h b/nodes/pvsocketnode/include/pvmf_socket_node_events.h
index 6c9013a..0dc91a1 100644
--- a/nodes/pvsocketnode/include/pvmf_socket_node_events.h
+++ b/nodes/pvsocketnode/include/pvmf_socket_node_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvsocketnode/include/pvmf_socket_node_extension_interface.h b/nodes/pvsocketnode/include/pvmf_socket_node_extension_interface.h
index bad0edd..77934bc 100644
--- a/nodes/pvsocketnode/include/pvmf_socket_node_extension_interface.h
+++ b/nodes/pvsocketnode/include/pvmf_socket_node_extension_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,21 +24,23 @@
 
 #define PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID PVUuid(1,2,3,0xfe,0xcd,0xee,0x1f,0x00,0x11,0x22,0x33)
 
+class PVMFSocketNode;
 
 class PVMFSocketNodeExtensionInterface : public PVInterface
 {
     public:
-        OSCL_IMPORT_REF virtual void addRef() = 0;
-        OSCL_IMPORT_REF virtual void removeRef() = 0;
-        OSCL_IMPORT_REF virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+        virtual ~PVMFSocketNodeExtensionInterface() {}
         OSCL_IMPORT_REF virtual PVMFStatus AllocateConsecutivePorts(PvmfMimeString* aPortConfig,
                 uint32& aLowerPortNum,
                 uint32& aHigherPortNum, uint32& aStartPortNum) = 0;
 
         OSCL_IMPORT_REF virtual PVMFStatus SetMaxTCPRecvBufferSize(uint32 aBufferSize) = 0;
         OSCL_IMPORT_REF virtual PVMFStatus GetMaxTCPRecvBufferSize(uint32& aSize) = 0;
-};
+        OSCL_IMPORT_REF virtual PVMFStatus SetMaxTCPRecvBufferCount(uint32 aCount) = 0;
+        OSCL_IMPORT_REF virtual PVMFStatus GetMaxTCPRecvBufferCount(uint32& aCount) = 0;
+        OSCL_IMPORT_REF virtual OsclMemPoolResizableAllocator* CreateSharedBuffer(const PVMFPortInterface* aPort , uint32 aBufferSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes) = 0;
 
+};
 #endif //PVMF_SOCKET_NODE_EXTENSION_INTERFACE_H_INCLUDED
 
 
diff --git a/nodes/pvsocketnode/include/pvmf_socket_output_port.h b/nodes/pvsocketnode/include/pvmf_socket_output_port.h
index 9a5c85d..596146c 100644
--- a/nodes/pvsocketnode/include/pvmf_socket_output_port.h
+++ b/nodes/pvsocketnode/include/pvmf_socket_output_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvsocketnode/include/pvmf_socket_port.h b/nodes/pvsocketnode/include/pvmf_socket_port.h
index 5062fcc..6328033 100644
--- a/nodes/pvsocketnode/include/pvmf_socket_port.h
+++ b/nodes/pvsocketnode/include/pvmf_socket_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -128,8 +128,6 @@
 
         PVMFStatus PeekIncomingMsg(PVMFSharedMediaMsgPtr& aMsg);
 
-        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> iAllocSharedPtr;
-
         SocketPortConfig* iConfig;
         PVMFSocketNodePortTag iPortTag;
 
diff --git a/nodes/pvsocketnode/src/pvmf_socket_factory.cpp b/nodes/pvsocketnode/src/pvmf_socket_factory.cpp
index 1677d76..7639193 100644
--- a/nodes/pvsocketnode/src/pvmf_socket_factory.cpp
+++ b/nodes/pvsocketnode/src/pvmf_socket_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvsocketnode/src/pvmf_socket_node.cpp b/nodes/pvsocketnode/src/pvmf_socket_node.cpp
index 64aec6e..00f5fdb 100644
--- a/nodes/pvsocketnode/src/pvmf_socket_node.cpp
+++ b/nodes/pvsocketnode/src/pvmf_socket_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
 #include "oscl_rand.h"
 #include "oscl_time.h"
 #include "pvmf_socket_node_tunables.h"
-
+#include "oscl_bin_stream.h"
 // Use default DLL entry point for Symbian
 #include "oscl_dll.h"
 
@@ -42,9 +42,156 @@
 {
     iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (aMemPoolNumBufs, MEDIA_DATA_CLASS_SIZE));
     iInternalAlloc = NULL;
-#if SNODE_ENABLE_UDP_MULTI_PACKET
+    iSharedBufferAlloc = NULL;
+    iMediaMsgAllocator = NULL;
     iMediaFragGroupAlloc = NULL;
     iMediaFragGroupAllocMempool = NULL;
+}
+
+void PVMFSocketNodeMemPool::CreateAllocators(const OSCL_HeapString<OsclMemAllocator>& iMime, uint32 aSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes)
+{
+    if (!iSharedBufferAlloc)
+    {
+        iSharedDataBufferInfo.Init(aSize, aExpectedNumberOfBlocksPerBuffer, aResizeSize, aMaxNumResizes);
+        const uint32 maxAllocatorNameLen = 255;
+        char allocatorName[maxAllocatorNameLen];
+        const uint32 strLenForMimeName  = maxAllocatorNameLen - oscl_strlen("InternalSocketBuffer");
+        oscl_strncpy(allocatorName, iMime.get_cstr(), strLenForMimeName);
+        allocatorName[strLenForMimeName] = '\0';
+        oscl_strcat(allocatorName, "InternalSocketBuffer");
+        CreateDefaultDataBufferAllocator(allocatorName);
+    }
+#if SNODE_ENABLE_UDP_MULTI_PACKET
+    CreateUDPMultipleRecvAllocator();
+#endif
+}
+
+OsclMemPoolResizableAllocator* PVMFSocketNodeMemPool::CreateResizableDataBufferAllocator(const char* allocatorName)
+{
+    OSCL_UNUSED_ARG(allocatorName);
+    if (iMediaMsgAllocator)
+    {
+        /*
+         * It may be possible that the allocator was binded to iInternalAlloc/iSharedBufferAlloc
+         * So destruct it.
+         * Deallocation of iInternalAlloc/iSharedBufferAlloc will be done as part of Reset/Destruction of node
+         */
+        OSCL_DELETE(iMediaMsgAllocator);
+        iMediaMsgAllocator = NULL;
+    }
+
+    OSCL_ASSERT(iSharedBufferAlloc == NULL);
+    if (iSharedBufferAlloc)
+        return NULL;
+
+
+    iSharedBufferAlloc = OSCL_NEW(OsclMemPoolResizableAllocator, (iSharedDataBufferInfo.iSize, (1 + iSharedDataBufferInfo.iMaxNumResizes),
+                                  iSharedDataBufferInfo.iExpectedNumberOfBlocksPerBuffer));
+    iSharedBufferAlloc->setMaxSzForNewMemPoolBuffer(iSharedDataBufferInfo.iResizeSize);
+    iMediaMsgAllocator = OSCL_NEW(PVMFResizableSimpleMediaMsgAlloc, (iSharedBufferAlloc));
+    return iSharedBufferAlloc;
+}
+
+void PVMFSocketNodeMemPool::CreateDefaultDataBufferAllocator(const char* allocatorName)
+{
+    OSCL_UNUSED_ARG(allocatorName);
+    if (iMediaMsgAllocator)
+    {
+        /*
+         * It may be possible that the allocator was binded to iInternalAlloc/iSharedBufferAlloc
+         * So destruct it.
+         * Deallocation of iInternalAlloc/iSharedBufferAlloc will be done as part of Reset/Destruction of node
+         */
+        OSCL_DELETE(iMediaMsgAllocator);
+        iMediaMsgAllocator = NULL;
+    }
+
+    OSCL_ASSERT(iInternalAlloc == NULL);
+    if (iInternalAlloc)
+        return;
+
+    iInternalAlloc = OSCL_NEW(OsclMemPoolResizableAllocator, (iSharedDataBufferInfo.iSize, (1 + iSharedDataBufferInfo.iMaxNumResizes),
+                              iSharedDataBufferInfo.iExpectedNumberOfBlocksPerBuffer));
+    iInternalAlloc->setMaxSzForNewMemPoolBuffer(iSharedDataBufferInfo.iResizeSize);
+    iMediaMsgAllocator = OSCL_NEW(PVMFResizableSimpleMediaMsgAlloc, (iInternalAlloc));
+}
+
+void PVMFSocketNodeMemPool::CreateUDPMultipleRecvAllocator()
+{
+#if SNODE_ENABLE_UDP_MULTI_PACKET
+    //Create the multiple-receive allocator
+    iMediaFragGroupAllocMempool
+    = OSCL_NEW(OsclMemPoolFixedChunkAllocator
+               , (SNODE_UDP_MULTI_FRAG_ALLOCATOR_MAX_MSGS)
+              );
+    iMediaFragGroupAlloc
+    = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<PVMFSocketNodeAllocator>
+               , (SNODE_UDP_MULTI_FRAG_ALLOCATOR_MAX_MSGS
+                  , SNODE_UDP_MULTI_FRAG_ALLOCATOR_MAX_FRAGS_PER_MSG
+                  , iMediaFragGroupAllocMempool)
+              );
+    iMediaFragGroupAlloc->create();
+#endif
+}
+
+uint32 PVMFSocketNodeMemPool::GetMaxSizeMediaMsgLen()
+{
+    OsclMemPoolResizableAllocator* resizableAllocator = NULL;
+
+    const uint32 wrappingOverhead = iMediaMsgAllocator->GetMediaMsgAllocationOverheadBytes();
+
+    if (iSharedBufferAlloc)
+    {
+        resizableAllocator = OSCL_STATIC_CAST(OsclMemPoolResizableAllocator*, iSharedBufferAlloc);
+    }
+    else if (iInternalAlloc)
+    {
+        resizableAllocator = OSCL_STATIC_CAST(OsclMemPoolResizableAllocator*, iInternalAlloc);
+    }
+
+    if (resizableAllocator)
+    {
+        return (resizableAllocator->getLargestContiguousFreeBlockSize() - wrappingOverhead);
+    }
+
+    return 0;
+}
+
+void PVMFSocketNodeMemPool::DestroyAllocators()
+{
+    if (iInternalAlloc != NULL)
+    {
+        iInternalAlloc->CancelFreeChunkAvailableCallback();
+        iInternalAlloc->removeRef();
+    }
+    if (iSharedBufferAlloc != NULL)
+    {
+        iSharedBufferAlloc->CancelFreeChunkAvailableCallback();
+        iSharedBufferAlloc->removeRef();
+    }
+    if (iMediaMsgAllocator)
+    {
+        OSCL_DELETE(iMediaMsgAllocator);
+        iMediaMsgAllocator = NULL;
+    }
+#if SNODE_ENABLE_UDP_MULTI_PACKET
+    DestroyUDPMultipleRecvAllocator();
+#endif
+}
+
+void PVMFSocketNodeMemPool::DestroyUDPMultipleRecvAllocator()
+{
+#if SNODE_ENABLE_UDP_MULTI_PACKET
+    if (iMediaFragGroupAlloc)
+    {
+        iMediaFragGroupAlloc->removeRef();
+        iMediaFragGroupAlloc = NULL;
+    }
+    if (iMediaFragGroupAllocMempool)
+    {
+        iMediaFragGroupAllocMempool->removeRef();
+        iMediaFragGroupAllocMempool = NULL;
+    }
 #endif
 }
 
@@ -87,91 +234,22 @@
 // SocketPortConfig
 //////////////////////////////////////////////////
 
-void SocketPortConfig::DoSetSocketPortMemAllocator(PVLogger* aLogger, OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc)
+void SocketPortConfig::CreateAllocators(uint32 aSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes)
 {
-    if (aAlloc.GetRep())
+    iMemPool->CreateAllocators(iMime, aSize, aExpectedNumberOfBlocksPerBuffer, aResizeSize, aMaxNumResizes);
+}
+
+void SocketPortConfig::CleanupMemPools(Oscl_DefAlloc& aAlloc)
+{
+    if (iMemPool)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, PVLOGMSG_INFO, (0, "SocketPortConfig::DoSetSocketPortMemAllocator() Using input mem allocator"));
-        /*
-         * Deletion of any previously created allocators is handled as part of
-         * reset / node delete. So just re-assign the shared ptr here.
-         */
-        if (iMemPool->iSocketAllocSharedPtr.GetRep() != NULL)
-        {
-            iMemPool->iSocketAllocSharedPtr.Unbind();
-        }
-        iMemPool->iSocketAllocSharedPtr = aAlloc;
-
-#if SNODE_ENABLE_UDP_MULTI_PACKET
-        //Create the multiple-receive allocator
-        iMemPool->iMediaFragGroupAllocMempool
-        = OSCL_NEW(OsclMemPoolFixedChunkAllocator
-                   , (SNODE_UDP_MULTI_FRAG_ALLOCATOR_MAX_MSGS)
-                  );
-        iMemPool->iMediaFragGroupAlloc
-        = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<PVMFSocketNodeAllocator>
-                   , (SNODE_UDP_MULTI_FRAG_ALLOCATOR_MAX_MSGS
-                      , SNODE_UDP_MULTI_FRAG_ALLOCATOR_MAX_FRAGS_PER_MSG
-                      , iMemPool->iMediaFragGroupAllocMempool)
-                  );
-        iMemPool->iMediaFragGroupAlloc->create();
-#endif
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, aLogger, PVLOGMSG_INFO, (0, "SocketPortConfig::DoSetSocketPortMemAllocator() no mem allocator. Create one"));
-
-        uint aligned_socket_alloc_size = oscl_mem_aligned_size(sizeof(PVMFSMSharedBufferAllocWithReSize));
-
-        uint aligned_refcnt_size = 	oscl_mem_aligned_size(sizeof(OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>));
-
-        OsclMemAllocator my_alloc;
-        uint8 *my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size + aligned_socket_alloc_size);
-        OsclRefCounter *my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>(my_ptr));
-        my_ptr += aligned_refcnt_size;
-
-        // allow one resize for a maximum mempool size of TCP_BUFFER_SIZE*TCP_BUFFER_IN_MEMPOOL
-        iMemPool->iInternalAlloc = OSCL_NEW(PVMFSMSharedBufferAllocWithReSize, (
-                                                iContainer->iMaxTcpRecvBufferSize * (iContainer->iMaxTcpRecvBufferCount - 1), "TCPsocketBuffer",
-                                                1, iContainer->iMaxTcpRecvBufferSize));
-
-        PVMFSharedSocketDataBufferAlloc *alloc_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSharedSocketDataBufferAlloc(iMemPool->iInternalAlloc));
-
-        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> shared_alloc(alloc_ptr, my_refcnt);
-        iMemPool->iSocketAllocSharedPtr = shared_alloc;
+        iMemPool->DestroyAllocators();
+        iMemPool->~PVMFSocketNodeMemPool();
+        aAlloc.deallocate((OsclAny*)(iMemPool));
+        iMemPool = NULL;
     }
 }
 
-void SocketPortConfig::CleanupMemPools()
-{
-    if (iMemPool->iInternalAlloc != NULL)
-    {
-        iMemPool->iInternalAlloc->DecrementKeepAliveCount();
-        uint32 numOutStandingBuffers =
-            iMemPool->iInternalAlloc->getNumOutStandingBuffers();
-        if (numOutStandingBuffers == 0)
-        {
-            OSCL_DELETE((iMemPool->iInternalAlloc));
-            iMemPool->iInternalAlloc = NULL;
-        }
-    }
-#if SNODE_ENABLE_UDP_MULTI_PACKET
-    if (iMemPool->iMediaFragGroupAlloc)
-    {
-        iMemPool->iMediaFragGroupAlloc->removeRef();
-        iMemPool->iMediaFragGroupAlloc = NULL;
-    }
-    if (iMemPool->iMediaFragGroupAllocMempool)
-    {
-        iMemPool->iMediaFragGroupAllocMempool->removeRef();
-        iMemPool->iMediaFragGroupAllocMempool = NULL;
-    }
-#endif
-    PVMFSocketNodeAllocator alloc;
-    iMemPool->~PVMFSocketNodeMemPool();
-    alloc.deallocate((OsclAny*)(iMemPool));
-    iMemPool = NULL;
-}
 //////////////////////////////////////////////////
 // End SocketPortConfig
 //////////////////////////////////////////////////
@@ -190,19 +268,20 @@
         , TIMEOUT_SHUTDOWN(10000)
         , UDP_PORT_RANGE(2000)
         , MAX_UDP_PACKET_SIZE(MAX_SOCKET_BUFFER_SIZE)
-
+        , MIN_UDP_PACKET_SIZE(MIN_SOCKET_BUFFER_SIZE)
 {
     iLogger = NULL;
     iDataPathLogger = NULL;
+    iDataPathLoggerRTP = NULL;
+    iDataPathLoggerRTCP = NULL;
     iOsclErrorTrapImp = NULL;
-    iExtensionRefCount = 0;
     iSockServ = NULL;
     iMaxTcpRecvBufferSize = SNODE_DEFAULT_SOCKET_TCP_BUFFER_SIZE;
     iMaxTcpRecvBufferCount = SNODE_DEFAULT_SOCKET_TCP_BUFFER_COUNT;
     iSocketID = 0;
     iCommandErrorCode = PVMFSocketNodeErrorEventStart;
     iErrorEventErrorCode = PVMFSocketNodeErrorEventStart;
-
+    iExtensionInterface = NULL;
     iInSocketCallback = false;
     iNumStopPortActivityPending = (-1);//inactive.
 
@@ -229,13 +308,14 @@
              iCapability.iHasMaxNumberOfPorts = false;
              iCapability.iMaxNumberOfPorts = 0;//no maximum
 
-             iCapability.iInputFormatCapability.push_back(PVMF_INET_UDP);
-             iCapability.iInputFormatCapability.push_back(PVMF_INET_TCP);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_INET_UDP);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_INET_TCP);
 
-             iCapability.iOutputFormatCapability.push_back(PVMF_INET_TCP);
-             iCapability.iOutputFormatCapability.push_back(PVMF_INET_UDP);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_INET_TCP);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_INET_UDP);
 
              iDnsCache.NewL();
+
             );
 
     if (err != OsclErrNone)
@@ -266,6 +346,10 @@
     if (IsAdded())
         RemoveFromScheduler();
 
+    if (iExtensionInterface)
+    {
+        iExtensionInterface->removeRef();
+    }
 
     /* Cleanup allocated ports */
     CleanupPorts();
@@ -273,7 +357,6 @@
     CleanupClosedTCPSockets();
     CleanupClosedUDPSockets();
     CleanupClosedDNS();
-
     //Cleanup commands
     //The command queues are self-deleting, but we want to
     //notify the observer of unprocessed commands.
@@ -313,13 +396,13 @@
                 AddToScheduler();
             iLogger = PVLogger::GetLoggerObject("PVMFSocketNode");
             iDataPathLogger = PVLogger::GetLoggerObject("datapath.socketnode");
+            iDataPathLoggerRTP = PVLogger::GetLoggerObject("datapath.socketnode.rtp");
+            iDataPathLoggerRTCP = PVLogger::GetLoggerObject("datapath.socketnode.rtcp");
             iOsclErrorTrapImp = OsclErrorTrap::GetErrorTrapImp();
             SetState(EPVMFNodeIdle);
             return PVMFSuccess;
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
         default:
             return PVMFErrInvalidState;
-            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
     }
 }
 
@@ -336,6 +419,8 @@
                 RemoveFromScheduler();
             iLogger = NULL;
             iDataPathLogger = NULL;
+            iDataPathLoggerRTP = NULL;
+            iDataPathLoggerRTCP = NULL;
             iOsclErrorTrapImp = NULL;
             SetState(EPVMFNodeCreated);
 #if(ENABLE_SOCKET_NODE_STATS)
@@ -343,9 +428,11 @@
 #endif
             return PVMFSuccess;
         }
+        // break;	This break statement was removed to avoid compiler warning for Unreachable Code
 
         default:
             return PVMFErrInvalidState;
+            // break;	This break statement was removed to avoid compiler warning for Unreachable Code
     }
 }
 
@@ -357,7 +444,7 @@
     return PVMFSuccess;
 }
 
-//retrive a port iterator.
+//retrieve a port iterator.
 OSCL_EXPORT_REF PVMFPortIter* PVMFSocketNode::GetPorts(const PVMFPortFilter* aFilter)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFSocketNode:GetPorts"));
@@ -493,13 +580,11 @@
             PVMFSocketPort* sockPort = OSCL_STATIC_CAST(PVMFSocketPort*, aActivity.iPort);
             OSCL_ASSERT(sockPort && sockPort->iConfig);
             SocketPortConfig& aSockConfig = *sockPort->iConfig;
-
+            aSockConfig.CreateAllocators(iMaxTcpRecvBufferSize * (iMaxTcpRecvBufferCount - 1), iMaxTcpRecvBufferCount - 1, iMaxTcpRecvBufferSize, 1);
 #if(ENABLE_SOCKET_NODE_STATS)
             aSockConfig.iPortStats.iNumPortEventConnect++;
 #endif
 
-            setSocketPortMemAllocator(aActivity.iPort, sockPort->iAllocSharedPtr);
-
             //Receives may have been blocked waiting on the port to be connected, so check here.
             //Note: This is a known use case for HTTP streaming, where the port request and connect
             //can happen after the node start
@@ -611,52 +696,10 @@
     return false;
 }
 
-OSCL_EXPORT_REF bool PVMFSocketNode::setSocketPortMemAllocator(PVMFPortInterface* aInPort,
-        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> aAlloc)
-{
-
-    PVMFSocketPort* aPort = OSCL_STATIC_CAST(PVMFSocketPort*, aInPort);
-    SocketPortConfig* tmpSockConfig = (aPort) ? aPort->iConfig : NULL;
-    if (NULL != tmpSockConfig)
-    {
-        tmpSockConfig->DoSetSocketPortMemAllocator(iLogger, aAlloc);
-        return true;
-    }
-    return false;
-}
-
 //////////////////////////////////////////////////
 // End Additional Public APIs unique to Socket Node
 //////////////////////////////////////////////////
 
-///////////////////////////
-// Socket Extension Interface
-///////////////////////////
-
-OSCL_EXPORT_REF void PVMFSocketNode::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-OSCL_EXPORT_REF void PVMFSocketNode::removeRef()
-{
-    --iExtensionRefCount;
-}
-
-OSCL_EXPORT_REF bool PVMFSocketNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    PVUuid my_uuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID);
-    if (uuid == my_uuid)
-    {
-        PVMFSocketNodeExtensionInterface* myInterface =
-            OSCL_STATIC_CAST(PVMFSocketNodeExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-        return true;
-    }
-
-    return false;
-}
 
 //Create UDP sockets on consecutive ports.
 //This is needed because 3GPP streaming servers require consecutive ports.
@@ -725,6 +768,7 @@
         higher_sock_config->iAddr.iLocalAdd.port =
             lower_sock_config->iAddr.iLocalAdd.port + 1;
         higher_sock_config->iSockId = startSockID++;
+        higher_sock_config->iRTCP = true;
 
         if (NULL == (higher_sock_config->iUDPSocket = (OsclUDPSocket*)CreateOsclSocketAndBind(higher_sock_config->iAddr, higher_sock_config->iSockId)))
         {
@@ -757,13 +801,11 @@
         {
             //Delete and try again
             OsclUDPSocket* udpSocket1 = lower_sock_config->iUDPSocket;
-            udpSocket1->Close();
             udpSocket1->~OsclUDPSocket();
             iAlloc.deallocate(udpSocket1);
             lower_sock_config->iUDPSocket = NULL;
 
             OsclUDPSocket* udpSocket2 = higher_sock_config->iUDPSocket;
-            udpSocket2->Close();
             udpSocket2->~OsclUDPSocket();
             iAlloc.deallocate(udpSocket2);
             higher_sock_config->iUDPSocket = NULL;
@@ -801,18 +843,32 @@
     return PVMFSuccess;
 }
 
-OSCL_EXPORT_REF PVMFStatus PVMFSocketNode::SetMaxTCPRecvBufferCount(uint32 aBufferSize)
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNode::SetMaxTCPRecvBufferCount(uint32 aCount)
 {
-    iMaxTcpRecvBufferCount = aBufferSize;
+    iMaxTcpRecvBufferCount = aCount;
     return PVMFSuccess;
 }
 
-OSCL_EXPORT_REF PVMFStatus PVMFSocketNode::GetMaxTCPRecvBufferCount(uint32& aSize)
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNode::GetMaxTCPRecvBufferCount(uint32& aCount)
 {
-    aSize = iMaxTcpRecvBufferCount;
+    aCount = iMaxTcpRecvBufferCount;
     return PVMFSuccess;
 }
 
+OsclMemPoolResizableAllocator* PVMFSocketNode::CreateSharedBuffer(const PVMFPortInterface* aPort , uint32 aBufferSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes)
+{
+    //validate input params if required..
+    OSCL_ASSERT(aPort);
+    if (!aPort)
+        return NULL;
+
+    //If data buffer for the port is already created and is existing, then destroy the prev buffer and create new one (with requested attributes).
+    //CreateResizableDataBufferAllocator func will take care of this.
+    SocketPortConfig* portConfig = OSCL_STATIC_CAST(PVMFSocketPort*, aPort)->iConfig;
+    PVMFSocketNodeMemPool * portMemPool = portConfig->iMemPool;
+    portMemPool->iSharedDataBufferInfo.Init(aBufferSize, aExpectedNumberOfBlocksPerBuffer, aResizeSize, aMaxNumResizes);
+    return portMemPool->CreateResizableDataBufferAllocator(portConfig->iMime.get_cstr());
+}
 ///////////////////////////
 // End Socket Extension Interface
 ///////////////////////////
@@ -1485,7 +1541,15 @@
     if (aSize)
     {//wait on data buffer
         PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0, "PVMFSocketNode::StartRecvWaitOnMemory, wait on data buffer - SockId=%d, Mime=%s ", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
-        aSockConfig.iMemPool->notifyfreechunkavailable(aSockConfig, aSize, NULL);
+        if (aSockConfig.iMemPool->iSharedBufferAlloc)
+        {
+            aSockConfig.iMemPool->iSharedBufferAlloc->notifyfreeblockavailable(aSockConfig, aSize, NULL);
+        }
+        else
+        {
+            if (aSockConfig.iMemPool->iInternalAlloc)
+                aSockConfig.iMemPool->iInternalAlloc->notifyfreeblockavailable(aSockConfig, aSize, NULL);
+        }
     }
     else
     {//wait on media data wrapper
@@ -1591,11 +1655,54 @@
                 break;
         }
 
+        //Socket node provides the buffer to receive the data on the socket
+        //Socket node gets this from the mem pool.
+        //It may be possible that socket node may not be able to get the
+        //buffer of required size from the mempool
+        //If we are not able to get the packets from the OS, then the packets
+        //received from server will eventually be lost.
+        //In general, streaming server will be sending the UDP packets of small size
+        //(say 2048 bytes.. = MIN_UDP_PACKET_SIZE)
+        //So its better to attempt to allocate the memory of size
+        //SNODE_UDP_MULTI_MIN_BYTES_PER_RECV + MIN_UDP_PACKET_SIZE/MIN_UDP_PACKET_SIZE
+        //in such cases.
+
+        const int32 largestMediaMsgSz = aSockConfig.iMemPool->GetMaxSizeMediaMsgLen();
+
+        PVMF_SOCKETNODE_LOGINFO((0, "PVMFSocketNode::StartRecvOperation - MaxSizeMediMsg  %d memSize %d", largestMediaMsgSz, memSize));
+
+        if (memSize > largestMediaMsgSz)
+        {
+#if SNODE_ENABLE_UDP_MULTI_PACKET
+            multiRecvLimitBytes = MIN_UDP_PACKET_SIZE;
+
+            const int32 minBufferToContinueRecv = (SNODE_UDP_MULTI_MIN_BYTES_PER_RECV + MIN_UDP_PACKET_SIZE);
+
+            if (largestMediaMsgSz >= minBufferToContinueRecv)
+            {
+                memSize = largestMediaMsgSz;
+            }
+            else
+            {
+                memSize = minBufferToContinueRecv;
+            }
+#else
+            if (largestMediaMsgSz >= MIN_UDP_PACKET_SIZE)
+            {
+                memSize = largestMediaMsgSz;
+            }
+            else
+            {
+                memSize = MIN_UDP_PACKET_SIZE;
+            }
+#endif
+            PVMF_SOCKETNODE_LOGINFO((0, "PVMFSocketNode::StartRecvOperation - Resizing Mem Request Attributes## NewSz %d recvLimitBytes %d", memSize, multiRecvLimitBytes));
+        }
+
         //Create the media data impl.
         int32 err;
         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
-        OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
-                        mediaDataImpl = aSockConfig.iMemPool->getMediaDataImpl(memSize););
+        err = GetMediaDataImpl(aSockConfig, mediaDataImpl, memSize);
         if (err != OsclErrNone)
         {
             StartRecvWaitOnMemory(aSockConfig, memSize);
@@ -1605,8 +1712,7 @@
         }
 
         //Create the media data buffer.
-        OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
-                        aSockConfig.iPendingRecvMediaData = PVMFMediaData::createMediaData(mediaDataImpl, aSockConfig.iMemPool->iMediaDataMemPool););
+        err = CreateMediaData(aSockConfig, mediaDataImpl);
         if (err != OsclErrNone)
         {
             StartRecvWaitOnMemory(aSockConfig);
@@ -1652,9 +1758,8 @@
         //Allocate memory
         int32 err;
         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
-        OSCL_TRY(err,
-                 mediaDataImpl = aSockConfig.iMemPool->getMediaDataImpl(iMaxTcpRecvBufferSize););
-        if (err != OsclErrNone)
+        mediaDataImpl = aSockConfig.iMemPool->getMediaDataImpl(iMaxTcpRecvBufferSize);
+        if (NULL == mediaDataImpl.GetRep())
         {
             StartRecvWaitOnMemory(aSockConfig, iMaxTcpRecvBufferSize);
             status = PVMFPending;
@@ -1728,6 +1833,7 @@
     OSCL_ASSERT(aStatus != PVMFPending);
 
     PVMFStatus status = aStatus;
+    bool recvOperationCanceled = aSockConfig.iState.iRecvOperationCanceled;
 
     //Update the state
     TPVSocketPortRecvOperation curOp = aSockConfig.iState.iRecvOperation;
@@ -1756,12 +1862,12 @@
                     case EPVSocketRecv:
                         HandleRecvComplete(aSockConfig
                                            , aSockConfig.iSocketRecvActivity.iStatus
-                                           , &aSockConfig.iSocketRecvActivity);
+                                           , &aSockConfig.iSocketRecvActivity, recvOperationCanceled);
                         break;
                     case EPVSocketRecvFrom:
                         HandleRecvFromComplete(aSockConfig
                                                , aSockConfig.iSocketRecvActivity.iStatus
-                                               , &aSockConfig.iSocketRecvActivity);
+                                               , &aSockConfig.iSocketRecvActivity, recvOperationCanceled);
                         break;
                     default:
                         OSCL_ASSERT(0);//invalid arg
@@ -1774,14 +1880,14 @@
             //TCP receive is complete
             PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0, "PVMFSocketNode::RecvOperationComplete Recv - SockId=%d, Mime=%s ", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
 
-            HandleRecvComplete(aSockConfig, aStatus, aSocketActivity);
+            HandleRecvComplete(aSockConfig, aStatus, aSocketActivity, recvOperationCanceled);
             break;
 
         case EPVSocketPortRecvOperation_RecvFrom:
             //UDP receive from is complete
             PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0, "PVMFSocketNode::RecvOperationComplete RecvFrom - SockId=%d, Mime=%s ", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
 
-            HandleRecvFromComplete(aSockConfig, aStatus, aSocketActivity);
+            HandleRecvFromComplete(aSockConfig, aStatus, aSocketActivity, recvOperationCanceled);
             break;
 
         default:
@@ -1860,7 +1966,12 @@
         case EPVSocketPortRecvOperation_WaitOnMemory:
             PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0, "PVMFSocketNode::CancelRecvOperation Cancelling WaitOnMemory - SockId=%d, Mime=%s ", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
             if (aSockConfig.iMemPool != NULL)
-                aSockConfig.iMemPool->CancelFreeChunkAvailableCallback();
+            {
+                if (aSockConfig.iMemPool->iInternalAlloc)
+                    aSockConfig.iMemPool->iInternalAlloc->CancelFreeChunkAvailableCallback();
+                if (aSockConfig.iMemPool->iSharedBufferAlloc)
+                    aSockConfig.iMemPool->iSharedBufferAlloc->CancelFreeChunkAvailableCallback();
+            }
             //clear the state
             aSockConfig.iState.iRecvOperation = EPVSocketPortRecvOperation_None;
             break;
@@ -1891,6 +2002,11 @@
     }
 }
 
+void SocketPortConfig::freeblockavailable(OsclAny* aContextData)
+{
+    freechunkavailable(aContextData);
+}
+
 //Handler for a "recv" complete.  This handles two input cases:
 // - Operation failed to initiate.  Status will be in aStatus and aSocketActivity will be NULL.
 // - Operation completed asynchronously via HandleSocketEvent callback. Status will be in aStatus
@@ -1900,18 +2016,35 @@
 // - Received data sent to connected port
 // - Result queued on socket activity queue for later processing.
 // - Error or cancellation processed.
-void PVMFSocketNode::HandleRecvComplete(SocketPortConfig& aSockConfig, PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity)
+void PVMFSocketNode::HandleRecvComplete(SocketPortConfig& aSockConfig, PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity, bool aRecvOperationCanceled)
 {
     PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFSocketNode::HandleRecvComplete() In"));
 
     //operation should be complete when this is called.
     OSCL_ASSERT(aStatus != PVMFPending);
 
+
+    int32 sockActivityEvent = aSocketActivity->iEvent;
+    PVMFStatus status = aStatus;
+
+    int32 tmplen;
+    aSockConfig.iTCPSocket->GetRecvData(&tmplen);
+
+    // If data length is <= zero and aSocketActivity->iEvent is EPVSocketSuccess, it should be treated as failure.
+    // On some platforms, its possible to get data length as zero and aSocketActivity->iEvent as EPVSocketSuccess.
+    if (EPVSocketSuccess == sockActivityEvent && tmplen <= 0)
+    {
+        PVMF_SOCKETNODE_LOGINFO((0, "PVMFSocketNode::HandleRecvFromComplete() Sucessful Recv With Zero Length. Treating as failure."));
+
+        sockActivityEvent = EPVSocketFailure;
+        status = PVMFFailure;
+    }
+
     //If there's no socket activity input, then this must be a failure in initiating
     //a Recv operation.
     if (!aSocketActivity)
     {
-        OSCL_ASSERT(aStatus != PVMFSuccess);
+        OSCL_ASSERT(status != PVMFSuccess);
         PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvComplete: Request Failed - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
         ReportSocketNodeError(PVMFErrResource, PVMFSocketNodeErrorSocketFailure);
         //release media data
@@ -1923,7 +2056,7 @@
     //Otherwise this is a result from Oscl Sockets of a Recv call.
 
     //See whether we can send this data to the connected port
-    if (aSocketActivity->iEvent == EPVSocketSuccess)
+    if (sockActivityEvent == EPVSocketSuccess)
     {
         if (!aSockConfig.iPVMFPort
                 || !aSockConfig.iPVMFPort->IsConnected())
@@ -1944,24 +2077,19 @@
     //If we get here then it's time to process the recv result.
 
     //Release media data on failure
-    if (aStatus != PVMFSuccess)
+    if (status != PVMFSuccess)
     {
         if (aSockConfig.iPendingRecvMediaData.GetRep())
             aSockConfig.iPendingRecvMediaData.Unbind();
     }
 
-    switch (aSocketActivity->iEvent)
+    switch (sockActivityEvent)
     {
         case EPVSocketSuccess:
         {
             //Get data length and set media buffer size
             int32 len;
             aSockConfig.iTCPSocket->GetRecvData(&len);
-            if (len <= 0)
-            {
-                PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleRecvComplete - Sucessful Recv With Zero Length"));
-                OSCL_ASSERT(false);
-            }
             aSockConfig.iPendingRecvMediaData->setMediaFragFilledLen(0, len);
 
             // Resize the buffer
@@ -2007,11 +2135,21 @@
         case EPVSocketTimeout:
         {
             PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvComplete: Request TimedOut - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
-            PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleSocketRecv() ERROR EPVSocketTimeout Ln %d", __LINE__));
+            PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleRecvComplete() ERROR EPVSocketTimeout Ln %d", __LINE__));
             ReportSocketNodeError(PVMFErrTimeout, PVMFSocketNodeErrorSocketTimeOut);
         }
         break;
 
+        case EPVSocketCancel:
+            //On some OS we may get EPVSocketCancel for recv failures, so check whether this
+            //was response to a cancel command or not.
+            if (aRecvOperationCanceled)
+            {
+                PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvComplete: Request Cancelled - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
+                PVMF_SOCKETNODE_LOGINFO((0, "PVMFSocketNode::HandleRecvComplete() EPVSocketCancel"));
+                break;
+            }
+            //else fallthrough to the failure processing...
         case EPVSocketFailure:
         {
             //After a receive failure, we may need to do a TCP shutdown.
@@ -2045,13 +2183,6 @@
         }
         break;
 
-        case EPVSocketCancel:
-        {
-            PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvComplete: Request Cancelled - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
-            PVMF_SOCKETNODE_LOGINFO((0, "PVMFSocketNode::HandleRecvComplete() EPVSocketCancel"));
-        }
-        break;
-
         default:
             OSCL_ASSERT(0);
             break;
@@ -2067,8 +2198,9 @@
 // - Received data sent to connected port
 // - Result queued on socket activity queue for later processing.
 // - Error or cancellation processed.
-void PVMFSocketNode::HandleRecvFromComplete(SocketPortConfig& aSockConfig, PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity)
+void PVMFSocketNode::HandleRecvFromComplete(SocketPortConfig& aSockConfig, PVMFStatus aStatus, PVMFSocketActivity* aSocketActivity, bool aRecvOperationCanceled)
 {
+    OSCL_UNUSED_ARG(aStatus);
     PVMF_SOCKETNODE_LOGSTACKTRACE((0, "PVMFSocketNode::HandleRecvFromComplete() In"));
 
     //operation should be complete when this is called.
@@ -2137,7 +2269,7 @@
             }
             else
             {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketNode::HandleSocketRecvFrom() ERROR:mempool not found"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketNode::HandleRecvFromComplete() ERROR:mempool not found"));
                 PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvFromComplete: ERROR mempool not found - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
                 return;//unexpected, cleanup
             }
@@ -2149,8 +2281,7 @@
             //Allocate a new media frag group.
             int32 err;
             OsclSharedPtr< PVMFMediaDataImpl > mediaFragGroup;
-            OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
-                            mediaFragGroup = aSockConfig.iMemPool->iMediaFragGroupAlloc->allocate(););
+            err = Allocate(aSockConfig, mediaFragGroup);
             if (err != OsclErrNone)
             {
                 //Unexpected error.  With current usage by JB node, this pool should
@@ -2180,7 +2311,13 @@
                 mediaFragGroup->appendMediaFragment(multiFrag);
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
                 if (aSockConfig.iRTP)
+                {
                     LogRTPHeaderFields(aSockConfig, multiFrag);
+                }
+                else if (aSockConfig.iRTCP)
+                {
+                    LogRTCPHeaderFields(aSockConfig, multiFrag);
+                }
 #endif
             }
 
@@ -2189,8 +2326,7 @@
             //can just unbind the current message then re-allocate it with the
             //new data.
             aSockConfig.iPendingRecvMediaData.Unbind();
-            OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
-                            aSockConfig.iPendingRecvMediaData = PVMFMediaData::createMediaData(mediaFragGroup, aSockConfig.iMemPool->iMediaDataMemPool););
+            err = CreateMediaData(aSockConfig, mediaFragGroup);
             if (err != OsclErrNone)
             {
                 //unexpected since we just freed one message
@@ -2208,6 +2344,12 @@
                 aSockConfig.iPendingRecvMediaData->getMediaFragment(0, memfrag);
                 LogRTPHeaderFields(aSockConfig, memfrag);
             }
+            else if (aSockConfig.iRTCP)
+            {
+                OsclRefCounterMemFrag memfrag;
+                aSockConfig.iPendingRecvMediaData->getMediaFragment(0, memfrag);
+                LogRTCPHeaderFields(aSockConfig, memfrag);
+            }
 #endif
 
 #endif //SNODE_ENABLE_UDP_MULTI_PACKET
@@ -2223,7 +2365,7 @@
             if (status != PVMFSuccess)
             {
                 //should never get here because we already checked outgoign queue earlier.
-                PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleSocketRecvFrom() ERROR:%d, Outgoing queue size=%d. Data discarded!", status, aSockConfig.iPVMFPort->OutgoingMsgQueueSize()));
+                PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleRecvFromComplete() ERROR:%d, Outgoing queue size=%d. Data discarded!", status, aSockConfig.iPVMFPort->OutgoingMsgQueueSize()));
                 ReportErrorEvent(PVMFInfoOverflow);
             }
 
@@ -2241,31 +2383,34 @@
         //report error events.
         switch (aSocketActivity->iEvent)
         {
+            case EPVSocketCancel:
+                //On some OS we may get EPVSocketCancel for recv failures, so check whether this
+                //was response to a cancel command or not.
+                if (aRecvOperationCanceled)
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvFromComplete: Request Cancelled - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
+                    break;
+                }
+                //else fallthrough to failure processing...
             case EPVSocketFailure:
                 //report RTP failures.
                 //Note: do not report RTCP errors, because some servers send zero-byte packets
                 //and we want to be tolerant of that case.
                 if (aSockConfig.iTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
                 {
-                    PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleSocketRecvFrom: Request Failed - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvFromComplete: Request Failed - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
                     ReportSocketNodeError(PVMFErrResource, PVMFSocketNodeErrorSocketFailure);
                 }
                 break;
 
             case EPVSocketTimeout:
             {
-                PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleSocketRecvFrom: Request TimedOut - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
-                PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleSocketRecvFrom() ERROR EPVSocketTimeout Ln %d", __LINE__));
+                PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleRecvFromComplete: Request TimedOut - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
+                PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleRecvFromComplete() ERROR EPVSocketTimeout Ln %d", __LINE__));
                 ReportSocketNodeError(PVMFErrTimeout, PVMFSocketNodeErrorSocketTimeOut);
             }
             break;
 
-            case EPVSocketCancel:
-            {
-                PVMF_SOCKETNODE_LOGDATATRAFFIC_E((0, "PVMFSocketNode::HandleSocketRecvFrom: Request Cancelled - SockId=%d, Mime=%s", aSockConfig.iSockId, aSockConfig.iMime.get_str()));
-            }
-            break;
-
             default:
                 break;
         }
@@ -2746,6 +2891,7 @@
     //All sequences other than input data message will
     //block receive operations, so may need to start or resume receives now.
     if (curSequence != EPVSocketPortSequence_InputDataMsg
+            && (aStatus == PVMFSuccess)
             && CanReceive(aSockConfig))
     {
         StartRecvOperation(aSockConfig);
@@ -2753,8 +2899,11 @@
 
     //Input message processing may have been blocked waiting on
     //this sequence to complete, so resume now.
-    if (CanProcessIncomingMsg(aSockConfig))
+    if (CanProcessIncomingMsg(aSockConfig)
+            && (aStatus == PVMFSuccess))
+    {
         ProcessIncomingMsg(aSockConfig);
+    }
 }
 
 //////////////////////////////////////
@@ -2978,7 +3127,6 @@
                     //go back to Idle state
                     iPortVector.Reconstruct();
                     SetState(EPVMFNodeIdle);
-                    ThreadLogoff();
                 }
                 break;
 
@@ -3053,7 +3201,7 @@
                                       PVUuid* aEventUUID,
                                       int32* aEventCode)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR,
                     (0, "PVMFSocketNode:NodeErrorEvent Type %d Data %d"
                      , aEventType, aEventData));
 
@@ -3165,6 +3313,31 @@
     return PVMFSuccess;
 }
 
+bool PVMFSocketNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    iface = NULL;
+    if (uuid == PVUuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID))
+    {
+        if (!iExtensionInterface)
+        {
+            iExtensionInterface = OSCL_NEW(PVMFSocketNodeExtensionInterfaceImpl, (this));
+        }
+        if (iExtensionInterface)
+        {
+            return (iExtensionInterface->queryInterface(uuid, iface));
+        }
+        else
+        {
+            PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::queryInterface: Error - Out of memory"));
+            OSCL_LEAVE(OsclErrNoMemory);
+            return false;
+        }
+    }
+    else
+    {
+        return false;
+    }
+}
 
 PVMFStatus PVMFSocketNode::DoQueryInterface(PVMFSocketNodeCommand&  aCmd)
 {
@@ -3174,14 +3347,27 @@
     PVUuid* uuid;
     PVInterface** ptr;
     aCmd.PVMFSocketNodeCommandBase::Parse(uuid, ptr);
-
     if (*uuid == PVUuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID))
     {
-        addRef();
-        PVMFSocketNodeExtensionInterface* myInterface =
-            OSCL_STATIC_CAST(PVMFSocketNodeExtensionInterface*, this);
-        *ptr = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        return PVMFSuccess;
+        if (!iExtensionInterface)
+        {
+            iExtensionInterface = OSCL_NEW(PVMFSocketNodeExtensionInterfaceImpl, (this));
+        }
+        if (iExtensionInterface)
+        {
+            if (iExtensionInterface->queryInterface(*uuid, *ptr))
+            {
+                return PVMFSuccess;
+            }
+            else
+            {
+                return PVMFErrNotSupported;
+            }
+        }
+        else
+        {
+            return PVMFErrNoMemory;
+        }
     }
     else
     {//not supported
@@ -3315,6 +3501,8 @@
             PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::DoRequestPort: ERROR - Invalid protocol for port request"));
             return PVMFFailure;
     }
+    PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::DoRequestPort: ERROR - Invalid protocol for port request"));
+    return PVMFFailure;
 }
 
 //Release ports is a do-nothing for this node.
@@ -3624,6 +3812,7 @@
 
 PVMFStatus PVMFSocketNode::DoCancelAllCommands(PVMFSocketNodeCommand& aCmd)
 {
+    OSCL_UNUSED_ARG(aCmd);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFSocketNode::DoCancelCommand() IN"));
 
     //This is not a conventional "cancel all" implementation.
@@ -3651,6 +3840,7 @@
 //It only needs to handle those commands that may have asynchronous completion.
 PVMFStatus PVMFSocketNode::DoCancelCurrentCommand(PVMFSocketNodeCmdQ& aCmdQ, PVMFSocketNodeCommand& aCmd)
 {
+    OSCL_UNUSED_ARG(aCmdQ);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFSocketNode::DoCancelCurrentCommand()"));
     switch (aCmd.iCmd)
     {
@@ -3768,11 +3958,6 @@
 
     iInSocketCallback = true;
 
-    if (aEvent != EPVSocketSuccess)
-    {
-        PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleSocketEvent: Error - Failure"));
-    }
-
     SocketPortConfig* sockConfigPtr = FindSocketPortConfig((uint32)aId);
     if (!sockConfigPtr)
     {
@@ -3781,6 +3966,11 @@
     }
     else
     {
+        if (aEvent != EPVSocketSuccess)
+        {
+            PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::HandleSocketEvent: Error - Event=%d, SockId=%d, Mime=%s",
+                                      aEvent, aId, sockConfigPtr->iMime.get_cstr()));
+        }
 #if(ENABLE_SOCKET_NODE_STATS)
         sockConfigPtr->iPortStats.iNumSocketCallback++;
 #endif
@@ -3902,7 +4092,7 @@
             //source tag is used for RTP
         {
             int32 errcode = 0;
-            OSCL_TRY(errcode, aMemPool = OSCL_PLACEMENT_NEW(MemPtr, PVMFSocketNodeMemPool(DEFAULT_NUM_MEDIA_MSGS_IN_JITTER_BUFFER);));
+            errcode = SocketPlacementNew(aMemPool, MemPtr, DEFAULT_NUM_MEDIA_MSGS_IN_JITTER_BUFFER);
             if (errcode != OsclErrNone)
             {
                 PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::DoRequestPort: PVMFSocketNodeMemPool Construct Failed Ln %d", err, __LINE__));
@@ -3916,7 +4106,7 @@
             //sink tag is used for RTCP
         {
             int32 errcode = 0;
-            OSCL_TRY(errcode, aMemPool = OSCL_PLACEMENT_NEW(MemPtr, PVMFSocketNodeMemPool(SNODE_DEFAULT_NUMBER_MEDIADATA_IN_MEMPOOL);));
+            errcode = SocketPlacementNew(aMemPool, MemPtr, SNODE_DEFAULT_NUMBER_MEDIADATA_IN_MEMPOOL);
             if (errcode != OsclErrNone)
             {
                 PVMF_SOCKETNODE_LOGERROR((0, "PVMFSocketNode::DoRequestPort: PVMFSocketNodeMemPool Construct Failed Ln %d", err, __LINE__));
@@ -4156,7 +4346,6 @@
         }
         else
         {
-            aSockConfig.iUDPSocket->Close();
             aSockConfig.iUDPSocket->~OsclUDPSocket();
             iAlloc.deallocate(aSockConfig.iUDPSocket);
             aSockConfig.iUDPSocket = NULL;
@@ -4209,7 +4398,7 @@
             CleanupTCP(*it);
             CleanupUDP(*it);
             CleanupDNS(*it);
-            it->CleanupMemPools();
+            it->CleanupMemPools(iAlloc);
             OSCL_DELETE(it);
             iPortVector.front()->iConfig = NULL;
         }
@@ -4223,7 +4412,7 @@
         CleanupTCP(*it);
         CleanupUDP(*it);
         CleanupDNS(*it);
-        it->CleanupMemPools();
+        it->CleanupMemPools(iAlloc);
         OSCL_DELETE(it);
         iAllocatedPortVector.erase(&iAllocatedPortVector.front());
     }
@@ -4297,11 +4486,11 @@
 
     OSCL_StackString<128> address("remote_address=");
 
-    char *tmpHead = oscl_strstr(head, address.get_cstr());
+    char *tmpHead = OSCL_CONST_CAST(char*, oscl_strstr(head, address.get_cstr()));
     if (tmpHead)
     {
         tmpHead += address.get_size();
-        char *tmpTail = oscl_strstr(tmpHead, ";");
+        char *tmpTail = OSCL_CONST_CAST(char*, oscl_strstr(tmpHead, ";"));
         if (tmpTail == NULL)
         {
             tmpTail = tail;
@@ -4328,11 +4517,11 @@
         aSockConfig.iLocalAdd.port = (myport >> 1) << 1;	//start from even;
     }
     OSCL_StackString<128> client_port("client_port=");
-    tmpHead = oscl_strstr(head, client_port.get_cstr());
+    tmpHead = OSCL_CONST_CAST(char*, oscl_strstr(head, client_port.get_cstr()));
     if (tmpHead)
     {
         tmpHead += client_port.get_size();
-        char *tmpTail = oscl_strstr(tmpHead, ";");
+        char *tmpTail = OSCL_CONST_CAST(char*, oscl_strstr(tmpHead, ";"));
         if (tmpTail == NULL)
         {
             tmpTail = tail;
@@ -4350,11 +4539,11 @@
 
     aSockConfig.iRemoteAdd.port = 0;
     OSCL_StackString<128> server_port("remote_port=");
-    tmpHead = oscl_strstr(head, server_port.get_cstr());
+    tmpHead = OSCL_CONST_CAST(char*, oscl_strstr(head, server_port.get_cstr()));
     if (tmpHead)
     {
         tmpHead += server_port.get_size();
-        char *tmpTail = oscl_strstr(tmpHead, ";");
+        char *tmpTail = OSCL_CONST_CAST(char*, oscl_strstr(tmpHead, ";"));
         if (tmpTail == NULL)
         {
             tmpTail = tail;
@@ -4372,11 +4561,11 @@
     }
 
     OSCL_StackString<128> mime("mime=");
-    tmpHead = oscl_strstr(head, mime.get_cstr());
+    tmpHead = OSCL_CONST_CAST(char*, oscl_strstr(head, mime.get_cstr()));
     if (tmpHead)
     {
         tmpHead += mime.get_size();
-        char *tmpTail = oscl_strstr(tmpHead, ";");
+        char *tmpTail = OSCL_CONST_CAST(char*, oscl_strstr(tmpHead, ";"));
         if (tmpTail == NULL)
         {
             tmpTail = tail;
@@ -4398,6 +4587,7 @@
 void PVMFSocketNode::LogRTPHeaderFields(SocketPortConfig& aSockConfig,
                                         OsclRefCounterMemFrag& memFragIn)
 {
+    OSCL_UNUSED_ARG(aSockConfig);
     uint8* rtpHeader = NULL;
     uint32 rtpPacketLen = 0;
 
@@ -4437,25 +4627,119 @@
         uint16 seqNum16 = 0;
         oscl_memcpy((char *)&seqNum16, rtpHeader, sizeof(seqNum16));
         big_endian_to_host((char *)&seqNum16, sizeof(seqNum16));
-        uint32 seqNum = (uint32)seqNum16;
         rtpHeader += 2;
 
         /* Parse rtp time stamp */
         uint32 ts32 = 0;
         oscl_memcpy((char *)&ts32, rtpHeader, sizeof(ts32));
         big_endian_to_host((char *)&ts32, sizeof(ts32));
-        PVMFTimestamp rtpTimeStamp = (PVMFTimestamp)ts32;
         rtpHeader += 4;
 
         /* Parse SSRC */
         uint32 ssrc32 = 0;
         oscl_memcpy((char *)&ssrc32, rtpHeader, sizeof(ssrc32));
         big_endian_to_host((char *)&ssrc32, sizeof(ssrc32));
-        uint32 SSRC = ssrc32;
         rtpHeader += 4;
 
-        PVMF_SOCKETNODE_LOGDATATRAFFIC_I((0, "SN-RTP - Mime=%s, ssrc=%d, seq=%d, ts=%d, len=%d",
-                                          aSockConfig.iMime.get_cstr(), SSRC, seqNum, rtpTimeStamp, rtpPacketLen));
+        PVMF_SOCKETNODE_LOGDATATRAFFIC_RTP((0, "SN-RTP - Mime=%s, ssrc=%d, seq=%d, ts=%d, len=%d",
+                                            aSockConfig.iMime.get_cstr(), ssrc32, (uint32)seqNum16, (PVMFTimestamp)ts32, rtpPacketLen));
+    }
+}
+
+void PVMFSocketNode::LogRTCPHeaderFields(SocketPortConfig& aSockConfig,
+        OsclRefCounterMemFrag& memFragIn)
+{
+    OSCL_UNUSED_ARG(aSockConfig);
+    const uint8 SR_PACKET_TYPE = 200;
+    const uint8 RR_PACKET_TYPE = 201;
+    const uint8 SDES_PACKET_TYPE = 202;
+    const uint8 BYE_PACKET_TYPE = 203;
+    const uint8 APP_PACKET_TYPE = 204;
+    uint8* rtcpHeader = NULL;
+    int32 rtcpPacketLen = 0;
+
+    /* Get start of RTP packet */
+    rtcpHeader    = (uint8*)(memFragIn.getMemFrag().ptr);
+    rtcpPacketLen = (int32)(memFragIn.getMemFrag().len);
+
+    if ((rtcpHeader != NULL) && (rtcpPacketLen > 0))
+    {
+        while (rtcpPacketLen > 0)
+        {
+            OsclBinIStreamBigEndian inStream;
+            inStream.Attach(rtcpHeader, rtcpPacketLen);
+            uint8 tempChar;
+            inStream >> tempChar;
+            if (inStream.fail())
+            {
+                PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, Invalid RTCP Packet",
+                                                     aSockConfig.iMime.get_cstr()));
+                return;
+            }
+            // read the type
+            uint8 payloadType;
+            uint16 rtcpLength;
+            inStream >> payloadType;
+            inStream >> rtcpLength;
+            if (inStream.fail())
+            {
+                PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, Invalid RTCP Packet Headers",
+                                                     aSockConfig.iMime.get_cstr()));
+                return;
+            }
+            switch (payloadType)
+            {
+                case SR_PACKET_TYPE:
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, RTCP_SR RECVD",
+                                                         aSockConfig.iMime.get_cstr()));
+                }
+                break;
+
+                case RR_PACKET_TYPE:
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, RTCP_RR RECVD",
+                                                         aSockConfig.iMime.get_cstr()));
+                }
+                break;
+
+                case SDES_PACKET_TYPE:
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, RTCP_SDES_PKT RECVD",
+                                                         aSockConfig.iMime.get_cstr()));
+                }
+                break;
+
+                case BYE_PACKET_TYPE:
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, RTCP_BYE RECVD",
+                                                         aSockConfig.iMime.get_cstr()));
+                }
+                break;
+
+                case APP_PACKET_TYPE:
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, RTCP_APP_PKT RECVD",
+                                                         aSockConfig.iMime.get_cstr()));
+                }
+                break;
+
+                default:
+                    break;
+            }
+            rtcpPacketLen -= (rtcpLength + 1) * 4;
+            rtcpHeader += (rtcpLength + 1) * 4;
+            if (rtcpLength)
+            {
+                inStream.seekFromCurrentPosition((rtcpLength*4));
+                if (inStream.fail())
+                {
+                    PVMF_SOCKETNODE_LOGDATATRAFFIC_RTCP((0, "SN-RTCP - Mime=%s, RTCP Packet Read Failed",
+                                                         aSockConfig.iMime.get_cstr()));
+                    return;
+                }
+            }
+        } //end of while loop
     }
 }
 
@@ -4488,11 +4772,41 @@
         ProcessCommand(iPendingCmdQueue, iPendingCmdQueue.front());
 }
 
+int32 PVMFSocketNode::SocketPlacementNew(PVMFSocketNodeMemPool *& aMemPool, OsclAny *aMemPtr, int32 aMemPoolNumBufs)
+{
+    int32 errcode = 0;
+    OSCL_TRY(errcode, aMemPool = OSCL_PLACEMENT_NEW(aMemPtr, PVMFSocketNodeMemPool(aMemPoolNumBufs);));
+    return errcode;
+}
 
+int32 PVMFSocketNode::CreateMediaData(SocketPortConfig& aSockConfig, OsclSharedPtr< PVMFMediaDataImpl > &aMediaptr)
+{
+    int32 err = 0;
+    OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
+                    aSockConfig.iPendingRecvMediaData = PVMFMediaData::createMediaData(aMediaptr, aSockConfig.iMemPool->iMediaDataMemPool););
+    return err;
+}
 
+int32 PVMFSocketNode::Allocate(SocketPortConfig &aSockConfig, OsclSharedPtr< PVMFMediaDataImpl > &aMediaFragGroup)
+{
+#if SNODE_ENABLE_UDP_MULTI_PACKET
+    int32 err = 0;
+    OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err,
+                    aMediaFragGroup = aSockConfig.iMemPool->iMediaFragGroupAlloc->allocate(););
+    return err;
+#else
+    return OsclErrNotSupported;
+#endif
+}
 
-
-
-
-
+int32 PVMFSocketNode::GetMediaDataImpl(SocketPortConfig& aSockConfig, OsclSharedPtr<PVMFMediaDataImpl> &aMediaDataImpl, int32 aMemSize)
+{
+    int32 err = 0;
+    aMediaDataImpl = aSockConfig.iMemPool->getMediaDataImpl(aMemSize);
+    if (NULL == aMediaDataImpl.GetRep())
+    {
+        err = OsclErrNoMemory;
+    }
+    return err;
+}
 
diff --git a/nodes/pvsocketnode/src/pvmf_socket_node_extension_interface.cpp b/nodes/pvsocketnode/src/pvmf_socket_node_extension_interface.cpp
new file mode 100644
index 0000000..2a01e6d
--- /dev/null
+++ b/nodes/pvsocketnode/src/pvmf_socket_node_extension_interface.cpp
@@ -0,0 +1,84 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SOCKET_NODE_H_INCLUDED
+#include "pvmf_socket_node.h"
+#endif
+
+void PVMFSocketNodeExtensionInterfaceImpl::addRef()
+{
+    PVInterfaceImpl<PVMFSocketNodeAllocator>::addRef();
+}
+void PVMFSocketNodeExtensionInterfaceImpl::removeRef()
+{
+    PVInterfaceImpl<PVMFSocketNodeAllocator>::removeRef();
+}
+
+bool PVMFSocketNodeExtensionInterfaceImpl::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == Uuid())
+    {
+        addRef();
+        iface = this;
+        return true;
+    }
+    else
+    {
+        iface = NULL;
+        return false;
+    }
+}
+
+PVMFSocketNodeExtensionInterfaceImpl::PVMFSocketNodeExtensionInterfaceImpl(PVMFSocketNode* aContainer): PVInterfaceImpl<PVMFSocketNodeAllocator>(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID), iContainer(aContainer)
+{
+}
+
+PVMFSocketNodeExtensionInterfaceImpl::~PVMFSocketNodeExtensionInterfaceImpl()
+{
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNodeExtensionInterfaceImpl::AllocateConsecutivePorts(PvmfMimeString* aPortConfig,
+        uint32& aLowerPortNum,
+        uint32& aHigherPortNum, uint32& aStartPortNum)
+{
+    return iContainer->AllocateConsecutivePorts(aPortConfig, aLowerPortNum, aHigherPortNum, aStartPortNum);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNodeExtensionInterfaceImpl::SetMaxTCPRecvBufferSize(uint32 aBufferSize)
+{
+    return iContainer->SetMaxTCPRecvBufferSize(aBufferSize);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNodeExtensionInterfaceImpl::GetMaxTCPRecvBufferSize(uint32& aSize)
+{
+    return iContainer->GetMaxTCPRecvBufferSize(aSize);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNodeExtensionInterfaceImpl::SetMaxTCPRecvBufferCount(uint32 aCount)
+{
+    return iContainer->SetMaxTCPRecvBufferCount(aCount);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFSocketNodeExtensionInterfaceImpl::GetMaxTCPRecvBufferCount(uint32& aCount)
+{
+    return iContainer->GetMaxTCPRecvBufferCount(aCount);
+}
+
+OSCL_EXPORT_REF OsclMemPoolResizableAllocator* PVMFSocketNodeExtensionInterfaceImpl::CreateSharedBuffer(const PVMFPortInterface* aPort , uint32 aBufferSize, uint32 aExpectedNumberOfBlocksPerBuffer, uint32 aResizeSize, uint32 aMaxNumResizes)
+{
+    return iContainer->CreateSharedBuffer(aPort, aBufferSize, aExpectedNumberOfBlocksPerBuffer, aResizeSize, aMaxNumResizes);
+}
diff --git a/nodes/pvsocketnode/src/pvmf_socket_port.cpp b/nodes/pvsocketnode/src/pvmf_socket_port.cpp
index 1b90009..223ee6b 100644
--- a/nodes/pvsocketnode/src/pvmf_socket_port.cpp
+++ b/nodes/pvsocketnode/src/pvmf_socket_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -67,14 +67,19 @@
 ////////////////////////////////////////////////////////////////////////////
 bool PVMFSocketPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return (aFmt == PVMF_INET_UDP) || (aFmt == PVMF_INET_TCP);
+    bool formatSupported = false;
+    if ((aFmt == PVMF_MIME_INET_UDP) || (aFmt == PVMF_MIME_INET_TCP))
+    {
+        formatSupported = true;
+    }
+    return formatSupported;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PVMFSocketPort::FormatUpdated()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFSocketPort::FormatUpdated %d", iFormat));
+                    , (0, "PVMFSocketPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
 }
 
 void PVMFSocketPort::setParametersSync(PvmiMIOSession aSession,
@@ -82,6 +87,7 @@
                                        int num_elements,
                                        PvmiKvp * & aRet_kvp)
 {
+    OSCL_UNUSED_ARG(aSession);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::getParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d, aRet_kvp=0x%x",
                     aSession, aParameters, num_elements, aRet_kvp));
 
@@ -96,12 +102,6 @@
         aRet_kvp = aParameters;
         OSCL_LEAVE(OsclErrArgument);
     }
-    else
-    {
-        aRet_kvp = NULL;
-        iAllocSharedPtr =
-            *((OsclSharedPtr<PVMFSharedSocketDataBufferAlloc>*)(aParameters->value.key_specific_value));
-    }
 }
 
 PVMFStatus PVMFSocketPort::getParametersSync(PvmiMIOSession aSession,
@@ -134,6 +134,7 @@
         PvmiKvp* aParameters,
         int num_elements)
 {
+    OSCL_UNUSED_ARG(aSession);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
                     aSession, aParameters, num_elements));
 
@@ -259,4 +260,5 @@
         return (cpPort->iIncomingQueue.iBusy);
     }
     return (PvmfPortBaseImpl::IsOutgoingQueueBusy());;
-}
\ No newline at end of file
+}
+
diff --git a/nodes/pvvideoencnode/Android.mk b/nodes/pvvideoencnode/Android.mk
deleted file mode 100644
index 6c1f148..0000000
--- a/nodes/pvvideoencnode/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/pvmf_videoenc_port.cpp \
-	src/pvmf_videoenc_node.cpp \
-	src/pvmf_videoenc_node_cap_config.cpp
-
-
-
-LOCAL_MODULE := libpvvideoencnode
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvvideoencnode/include \
-	$(PV_TOP)//nodes/pvvideoencnode/src \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/pvmf_videoenc_node_factory.h \
-	include/pvmf_videoenc_node_types.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvvideoencnode/build/make/makefile b/nodes/pvvideoencnode/build/make/makefile
deleted file mode 100755
index e29beea..0000000
--- a/nodes/pvvideoencnode/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvvideoencnode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =  pvmf_videoenc_port.cpp \
-	pvmf_videoenc_node.cpp \
-	pvmf_videoenc_node_cap_config.cpp
-
-
-HDRS =  pvmf_videoenc_node_factory.h \
-	pvmf_videoenc_node_types.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/pvvideoencnode/include/pvmf_videoenc_node_factory.h b/nodes/pvvideoencnode/include/pvmf_videoenc_node_factory.h
deleted file mode 100644
index 7c866ea..0000000
--- a/nodes/pvvideoencnode/include/pvmf_videoenc_node_factory.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMFVIDEOENCNODE_FACTORY_H_INCLUDED
-#define PVMFVIDEOENCNODE_FACTORY_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-
-// Forward declarations
-class PVMFNodeInterface;
-
-/** Uuid of PV Video Encoder Node */
-#define PVMFVideoEncNodeUuid PVUuid(0xbb4d38d1,0xcc90,0x44e7,0x9a,0x38,0xbd,0x97,0x67,0x24,0x5d,0xfa)
-
-/**
- * Factory class for PVMFVideoEncNode
- */
-class PVMFVideoEncNodeFactory
-{
-    public:
-        /**
-         * Creates an instance of a PV video encoder node. If the creation fails, this function will leave.
-         *
-         * @param aPriority The active object priority for the node. Default is standard priority if not specified
-         * @returns A pointer to an author or leaves if instantiation fails
-         **/
-        OSCL_IMPORT_REF static PVMFNodeInterface* CreateVideoEncNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
-
-        /**
-         * This function allows the application to delete an instance of file input node
-         * and reclaim all allocated resources.  An instance can be deleted only in
-         * the idle state. An attempt to delete in any other state will fail and return false.
-         *
-         * @param aNode The file input node to be deleted.
-         * @returns A status code indicating success or failure.
-         **/
-        OSCL_IMPORT_REF static bool DeleteVideoEncNode(PVMFNodeInterface* aNode);
-};
-
-#endif // PVMFVIDEOENCNODE_FACTORY_H_INCLUDED
diff --git a/nodes/pvvideoencnode/include/pvmf_videoenc_node_types.h b/nodes/pvvideoencnode/include/pvmf_videoenc_node_types.h
deleted file mode 100644
index 4a36aa2..0000000
--- a/nodes/pvvideoencnode/include/pvmf_videoenc_node_types.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_NODE_TYPES_H_INCLUDED
-#define PVMF_VIDEOENC_NODE_TYPES_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-
-///////////////////////////////////////////////
-// Port tags
-///////////////////////////////////////////////
-
-/** Enumerated list of port tags supported by the node for the port requests.*/
-typedef enum
-{
-    PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT = 0,
-    PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT
-} PVMFVideoEncNodePortType;
-
-///////////////////////////////////////////////
-// Error Events
-///////////////////////////////////////////////
-
-enum PVMFVideoEncNodeErrorEvent
-{
-    PVMF_VIDEOENC_NODE_ERROR_ENCODE_ERROR = PVMF_NODE_ERROR_EVENT_LAST
-};
-
-///////////////////////////////////////////////
-// Information Events
-///////////////////////////////////////////////
-
-// Enumerated list of informational event from PVMFVideoEncNode
-enum PVMFVideoEncNodeInfoEvent
-{
-    PVMF_VIDEOENC_NODE_INFO = PVMF_NODE_INFO_EVENT_LAST
-};
-
-
-#endif // PVMF_VIDEOENC_NODE_TYPES_H_INCLUDED
diff --git a/nodes/pvvideoencnode/src/pvmf_videoenc_node.cpp b/nodes/pvvideoencnode/src/pvmf_videoenc_node.cpp
deleted file mode 100644
index 417db40..0000000
--- a/nodes/pvvideoencnode/src/pvmf_videoenc_node.cpp
+++ /dev/null
@@ -1,1983 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_NODE_H_INCLUDED
-#include "pvmf_videoenc_node.h"
-#endif
-#ifndef OSCL_ERROR_CODES_H_INCLUDED
-#include "oscl_error_codes.h"
-#endif
-#ifndef PVMF_VIDEOENC_PORT_H_INCLUDED
-#include "pvmf_videoenc_port.h"
-#endif
-#ifndef PVMF_VIDEOENC_NODE_FACTORY_H_INCLUDED
-#include "pvmf_videoenc_node_factory.h"
-#endif
-#ifndef PVMF_VIDEOENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_videoenc_node_types.h"
-#endif
-#ifndef OSCL_DLL_H_INCLUDED
-#include "oscl_dll.h"
-#endif
-#ifndef PVMF_MEDIA_MSG_FORMAT_IDS_H_INCLUDED
-#include "pvmf_media_msg_format_ids.h"
-#endif
-#ifndef PVMF_MEDIA_CMD_H_INCLUDED
-#include "pvmf_media_cmd.h"
-#endif
-
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-// DLL entry point
-OSCL_DLL_ENTRY_POINT_DEFAULT()
-
-const uint32 DEFAULT_VOL_HEADER_LENGTH = 28;
-const uint8 DEFAULT_VOL_HEADER[DEFAULT_VOL_HEADER_LENGTH] =
-{
-    0x00, 0x00, 0x01, 0xB0, 0x08, 0x00, 0x00, 0x01,
-    0xB5, 0x09,	0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0x01, 0x20, 0x00, 0x84, 0x40, 0xFA, 0x28, 0x2C,
-    0x20, 0x90, 0xA2, 0x1F
-};
-
-////////////////////////////////////////////////////////////////////////////
-//              PVMFVideoEncNodeFactory implementation
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFNodeInterface* PVMFVideoEncNodeFactory::CreateVideoEncNode(int32 aPriority)
-{
-    int32 err = 0;
-    PVMFVideoEncNode* node = NULL;
-
-    OSCL_TRY(err,
-             node = OSCL_NEW(PVMFVideoEncNode, (aPriority));
-             if (!node)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err, return NULL;);
-
-    return (PVMFNodeInterface*)node;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNodeFactory::DeleteVideoEncNode(PVMFNodeInterface* aNode)
-{
-    if (!aNode)
-        return false;
-
-    PVMFVideoEncNode* node = (PVMFVideoEncNode*)aNode;
-    OSCL_DELETE(node);
-    aNode = NULL;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//              PVMFVideoEncNode implementation
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncNode::PVMFVideoEncNode(int32 aPriority) :
-        OsclTimerObject(aPriority, "PVMFVideoEncNode"),
-        iMediaBufferMemPool(PVVIDENC_MEDIADATA_POOLNUM, PVVIDENC_MEDIABUFFER_CHUNKSIZE),
-        iMediaDataMemPool(PVVIDENC_MEDIADATA_POOLNUM, PVVIDENC_MEDIADATA_CHUNKSIZE),
-        iVideoEncoder(NULL),
-        iSeqNum(0),
-        iDiagnosticsLogger(NULL),
-        total_ticks(0),
-        iExtensionRefCount(0)
-{
-    iInterfaceState = EPVMFNodeCreated;
-
-    // Allocate memory for VOL header
-    uint refCounterSize = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-    uint size = refCounterSize + DEFAULT_VOL_HEADER_LENGTH;
-    uint8 *memBuffer = NULL;
-
-    int32 err;
-    OSCL_TRY(err,
-             //Create the input command queue
-             iCmdQueue.Construct(PVMF_VIDEOENC_NODE_CMD_ID_START, PVMF_VIDEOENC_NODE_CMD_QUEUE_RESERVE);
-             iCurrentCmd.Construct(0, 1); // There's only 1 current command
-
-             //Create the port vector.
-             iInPort.Construct(PVMF_VIDEOENC_NODE_PORT_VECTOR_RESERVE);
-             iOutPort.Construct(PVMF_VIDEOENC_NODE_PORT_VECTOR_RESERVE);
-
-             // Reserve space for port activity queue
-             iPortActivityQueue.reserve(PVMF_VIDEOENC_NODE_PORT_ACTIVITY_RESERVE);
-
-             // Create media data allocator
-             iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (&iMediaBufferMemPool));
-             if (!iMediaDataAlloc)
-             OSCL_LEAVE(OsclErrNoMemory);
-
-             memBuffer = (uint8*)iAlloc.allocate(size);
-             if (!memBuffer)
-    {
-        OSCL_LEAVE(PVMFErrNoMemory);
-        }
-            );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         // If a leave happened, cleanup and re-throw the error
-                         iCmdQueue.clear();
-                         iInPort.clear();
-                         iOutPort.clear();
-                         OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
-                         OSCL_CLEANUP_BASE_CLASS(OsclTimerObject);
-                         OSCL_LEAVE(err);
-                        );
-
-    // Save default VOL header
-    oscl_memset(memBuffer, 0, DEFAULT_VOL_HEADER_LENGTH);
-    OsclMemoryFragment volHeader;
-    OsclRefCounter* refCounter = new(memBuffer) OsclRefCounterDA(memBuffer,
-            (OsclDestructDealloc*)&iAlloc);
-    memBuffer += refCounterSize;
-    volHeader.ptr = memBuffer;
-    oscl_memcpy(volHeader.ptr, (OsclAny*)DEFAULT_VOL_HEADER, DEFAULT_VOL_HEADER_LENGTH);
-    volHeader.len = DEFAULT_VOL_HEADER_LENGTH;
-    iVolHeader = OsclRefCounterMemFrag(volHeader, refCounter, DEFAULT_VOL_HEADER_LENGTH);
-
-    ConstructEncoderParams();
-
-#if PROFILING_ON
-    oscl_memset(&iStats, 0, sizeof(PVVideoEncNodeStats));
-    iStats.iMinEncTime = 0;
-    oDiagnosticsLogged = false;
-#endif
-    iLogger = PVLogger::GetLoggerObject("PVMFVideoEncNode");
-    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvauthordiagnostics.encnode.h263encnode");
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncNode::~PVMFVideoEncNode()
-{
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-
-    if (iMediaDataAlloc)
-    {
-        OSCL_DELETE(iMediaDataAlloc);
-        iMediaDataAlloc = NULL;
-    }
-
-    DeleteVideoEncoder();
-
-    while (!iInPort.empty())
-        iInPort.Erase(&iInPort.front());
-    while (!iOutPort.empty())
-        iOutPort.Erase(&iOutPort.front());
-
-    Cancel();
-    SetState(EPVMFNodeIdle);
-    ThreadLogoff();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncNode::ThreadLogon()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeCreated:
-            if (!IsAdded())
-                AddToScheduler();
-            SetState(EPVMFNodeIdle);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncNode::ThreadLogoff()
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            if (IsAdded())
-                RemoveFromScheduler();
-            iLogger = NULL;
-            SetState(EPVMFNodeCreated);
-            return PVMFSuccess;
-
-        default:
-            return PVMFErrInvalidState;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncNode::GetCapability(PVMFNodeCapability& aNodeCapability)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::GetCapability"));
-
-    aNodeCapability.iInputFormatCapability.push_back(PVMF_YUV420);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_M4V);
-    aNodeCapability.iOutputFormatCapability.push_back(PVMF_H263);
-    aNodeCapability.iCanSupportMultipleOutputPorts = false;
-    aNodeCapability.iCanSupportMultipleInputPorts = false;
-    aNodeCapability.iHasMaxNumberOfPorts = true;
-    aNodeCapability.iMaxNumberOfPorts = 2;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFPortIter* PVMFVideoEncNode::GetPorts(const PVMFPortFilter* aFilter)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::GetPorts"));
-    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
-
-    int32 err = 0;
-    PVMFVideoEncPortVector* port = NULL;
-    OSCL_TRY(err,
-             port = OSCL_NEW(PVMFVideoEncPortVector, ());
-             if (!port)
-             return NULL;
-
-             uint32 i;
-             for (i = 0; i < iInPort.size(); i++)
-                 port->AddL(iInPort[i]);
-                 for (i = 0; i < iOutPort.size(); i++)
-                     port->AddL(iOutPort[i]);
-                     port->Reset();
-                    );
-
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFVideoEncNode::GetPorts: Error - Out of memory"));
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::QueryUUID(PVMFSessionId aSession,
-        const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-        bool aExactUuidsOnly,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::QueryUUID"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYUUID,
-                  aMimeType, aUuids, aExactUuidsOnly, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::QueryInterface(PVMFSessionId aSession,
-        const PVUuid& aUuid,
-        PVInterface*& aInterfacePtr,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::QueryInterface"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYINTERFACE,
-                  aUuid, aInterfacePtr, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::RequestPort(PVMFSessionId aSession,
-        int32 aPortTag,
-        const PvmfMimeString* aPortConfig,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::RequestPort: aPortTag=%d", aPortTag));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_REQUESTPORT,
-                  aPortTag, aPortConfig, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::ReleasePort(PVMFSessionId aSession,
-        PVMFPortInterface& aPort,
-        const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::ReleasePort"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Init(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Init"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_INIT, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Prepare(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Prepare"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PREPARE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Start(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Start"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_START, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Stop(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Stop"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_STOP, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Flush(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Flush"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_FLUSH, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Pause(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Pause"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_PAUSE, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::Reset(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Reset"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_RESET, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::CancelAllCommands"));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELALLCOMMANDS, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncNode::CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::CancelCommand: aCmdId=%d", aCmdId));
-    PVMFVideoEncNodeCommand cmd;
-    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELCOMMAND, aCmdId, aContext);
-    return QueueCommandL(cmd);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::HandlePortActivity(const PVMFPortActivity &aActivity)
-{
-    // Only outgoing queue ready activity are forwarded on to the node
-    // by the output port.  The rest of the events for output port and all events
-    // for input port are handled within the port AO.
-    if (aActivity.iPort->GetPortTag() == PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aActivity.iType)
-        {
-            case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-                // Notifies the node that the output queue is ready, and the node would
-                // resume encoding incoming data
-                uint32 i;
-                for (i = 0; i < iInPort.size(); i++)
-                    ((PVMFVideoEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                break;
-
-            default:
-                break;
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncNode::addRef()
-{
-    ++iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncNode::removeRef()
-{
-    if (iExtensionRefCount > 0)
-        --iExtensionRefCount;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
-{
-    if (uuid == PVMp4H263EncExtensionUUID)
-    {
-        PVMp4H263EncExtensionInterface* myInterface = OSCL_STATIC_CAST(PVMp4H263EncExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else if (uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-    {
-        PvmiCapabilityAndConfig* myInterface = 	OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-    }
-    else
-    {
-        iface = NULL;
-        return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetNumLayers(uint32 aNumLayers)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetNumLayers: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if (aNumLayers > MAX_LAYER) // MAX_LAYER defined in cvei.h
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SetNumLayers: Error Max num layers is %d", MAX_LAYER));
-        return false;
-    }
-
-    iEncodeParam.iNumLayer = aNumLayers;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetOutputBitRate(uint32 aLayer, uint32 aBitRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetOutputBitRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SetOutputBitRate: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iBitRate[aLayer] = aBitRate;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetOutputFrameSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SetOutputFrameSize: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iFrameWidth[aLayer] = aWidth;
-    iEncodeParam.iFrameHeight[aLayer] = aHeight;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetOutputFrameRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SetOutputFrameRate: Error Invalid layer number"));
-        return false;
-    }
-
-    iEncodeParam.iFrameRate[aLayer] = OSCL_STATIC_CAST(float, aFrameRate);
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes)
-{
-    OSCL_UNUSED_ARG(aLayer);
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetSegmentTargetSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    iEncodeParam.iPacketSize = aSizeBytes;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl)
-{
-    OSCL_UNUSED_ARG(aLayer);
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetRateControlType: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    switch (aRateControl)
-    {
-        case PVMFVEN_RATE_CONTROL_CONSTANT_Q:
-            iEncodeParam.iRateControlType = ECONSTANT_Q;
-            break;
-        case PVMFVEN_RATE_CONTROL_CBR:
-            iEncodeParam.iRateControlType = ECBR_1;
-            break;
-        case PVMFVEN_RATE_CONTROL_VBR:
-            iEncodeParam.iRateControlType = EVBR_1;
-            break;
-        default:
-            return false;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetDataPartitioning(bool aDataPartitioning)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetDataPartitioning: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    if (iEncodeParam.iContentType == ECVEI_H263)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SetDataPartitioning: Error data partitioning not supported for H263"));
-        return false;
-    }
-
-    if (aDataPartitioning)
-        iEncodeParam.iContentType = ECVEI_STREAMING;
-    else
-        iEncodeParam.iContentType = ECVEI_DOWNLOAD;
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetIFrameInterval(uint32 aIFrameInterval)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetIFrameInterval: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-
-        default:
-            break;
-    }
-
-    iEncodeParam.iIFrameInterval = aIFrameInterval;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetRVLC(bool aRVLC)
-{
-    OSCL_UNUSED_ARG(aRVLC);
-
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::SetRVLC"));
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::GetVolHeader(OsclRefCounterMemFrag& aVolHeader)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::GetVolHeader"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-        case EPVMFNodePrepared:
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFVideoEncNode::GetVolHeader: Error - Wrong state"));
-            return false;
-    }
-
-    if (iEncodeParam.iContentType == ECVEI_H263)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::GetVolHeader: Error - VOL header only for M4V encode"));
-        return false;
-    }
-
-    uint8 *ptr = (uint8 *) iVolHeader.getMemFragPtr();
-    //If data partioning mode
-    if (iEncodeParam.iContentType == ECVEI_STREAMING)
-    {
-        ptr[iVolHeader.getMemFragSize() - 1] = 0x8F;
-    }
-    //else combined mode
-    else
-    {
-        ptr[iVolHeader.getMemFragSize() - 1] = 0x1F;
-    }
-
-    aVolHeader = iVolHeader;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::RequestIFrame()
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::RequestIFrame"));
-
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            break;
-        default:
-            LOG_ERR((0, "PVMFVideoEncNode::RequestIFrame: Error - Wrong state"));
-            return false;
-    }
-
-    if (!iVideoEncoder || iVideoEncoder->IFrameRequest() == ECVEI_FAIL)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::RequestIFrame: Error - IFrameRequest failed"));
-        return false;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF bool PVMFVideoEncNode::SetCodec(PVMFFormatType aCodec)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::SetCodec %d", aCodec));
-
-    if (SetCodecType(aCodec) == PVMFSuccess)
-    {
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::HandlePVCVEIEvent(uint32 aId, uint32 aEvent, uint32 aParam1)
-{
-    OSCL_UNUSED_ARG(aId);
-    OSCL_UNUSED_ARG(aEvent);
-    OSCL_UNUSED_ARG(aParam1);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                        Private methods
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::ConstructEncoderParams()
-{
-    iInputFormat.iVideoFormat = ECVEI_YUV420;
-    iInputFormat.iFrameWidth = DEFAULT_FRAME_WIDTH;
-    iInputFormat.iFrameHeight = DEFAULT_FRAME_HEIGHT;
-    iInputFormat.iFrameRate = (float)DEFAULT_FRAME_RATE;
-
-    oscl_memset(&iEncodeParam, 0, sizeof(TPVVideoEncodeParam));
-    iEncodeParam.iEncodeID = 0;
-    iEncodeParam.iNumLayer = 1;
-    iEncodeParam.iFrameWidth[0] = DEFAULT_FRAME_WIDTH;
-    iEncodeParam.iFrameHeight[0] = DEFAULT_FRAME_HEIGHT;
-    iEncodeParam.iBitRate[0] = DEFAULT_BITRATE;
-    iEncodeParam.iFrameRate[0] = (float)DEFAULT_FRAME_RATE;
-    iEncodeParam.iFrameQuality = 10;
-    iEncodeParam.iIFrameInterval = 10;
-    iEncodeParam.iBufferDelay = (float)0.2;
-    iEncodeParam.iContentType = ECVEI_H263;
-    iEncodeParam.iRateControlType = ECBR_1;
-    iEncodeParam.iIquant[0] = 15;
-    iEncodeParam.iPquant[0] = 12;
-    iEncodeParam.iBquant[0] = 12;
-    iEncodeParam.iSearchRange = 16;
-    iEncodeParam.iMV8x8 = false;
-    iEncodeParam.iPacketSize = 256;
-    iEncodeParam.iNoCurrentSkip = false;
-    iEncodeParam.iNoFrameSkip = false;
-    iEncodeParam.iClipDuration = 0;
-    iEncodeParam.iProfileLevel = ECVEI_CORE_LEVEL2;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::Run()
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Run"));
-
-    if (!iCmdQueue.empty())
-    {
-        if (ProcessCommand(iCmdQueue.front()))
-        {
-            // Need to check the state before re-scheduling since the node could have
-            // been reset in the ProcessCommand call
-            if (iInterfaceState != EPVMFNodeCreated)
-                RunIfNotReady();
-        }
-    }
-
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::Run: Out"));
-}
-
-/////////////////////////////////////////////////////
-//     Command processing routines
-/////////////////////////////////////////////////////
-PVMFCommandId PVMFVideoEncNode::QueueCommandL(PVMFVideoEncNodeCommand& aCmd)
-{
-    if (iInterfaceState == EPVMFNodeCreated)
-    {
-        OSCL_LEAVE(OsclErrNotReady);
-        // return 0;	This statement was removed to avoid compiler warning for Unreachable Code
-    }
-
-    PVMFCommandId id = iCmdQueue.AddL(aCmd);
-    RunIfNotReady();
-    return id;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFVideoEncNode::ProcessCommand(PVMFVideoEncNodeCommand& aCmd)
-{
-    // If a command is active, only high priority commands can interrupt
-    // the processing
-    if (!iCurrentCmd.empty() && !aCmd.hipri())
-        return false;
-
-    switch (aCmd.iCmd)
-    {
-        case PVMF_GENERIC_NODE_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMF_GENERIC_NODE_CANCELCOMMAND:
-            DoCancelCommand(aCmd);
-            break;
-
-        default://unknown command type
-            LOG_ERR((0, "PVMFVideoEncNode::ProcessCommand: Error - Unknown command type %d", aCmd.iCmd));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            break;
-    }
-
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::CommandComplete(PVMFVideoEncNodeCmdQueue& aCmdQueue, PVMFVideoEncNodeCommand& aCmd,
-                                       PVMFStatus aStatus, OsclAny* aData)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::CommandComplete: Id=%d, Type=%d, Status=%d, Context=0x%x, Data0x%x"
-                     , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aData));
-
-    //create response
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aData);
-    PVMFSessionId session = aCmd.iSession;
-
-    //Erase the command from the queue.
-    aCmdQueue.Erase(&aCmd);
-
-    //Report completion to the session observer.
-    ReportCmdCompleteEvent(session, resp);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoQueryUuid(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::DoQueryUuid"));
-    OSCL_String* mimetype;
-    Oscl_Vector<PVUuid, OsclMemAllocator>* uuidvec;
-    bool exactMatch;
-    aCmd.Parse(mimetype, uuidvec, exactMatch);
-
-    int32 err = 0;
-    PVMFStatus status = PVMFSuccess;
-    OSCL_TRY(err, uuidvec->push_back(PVMp4H263EncExtensionUUID););
-    OSCL_FIRST_CATCH_ANY(err, status = PVMFErrNoMemory;);
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoQueryInterface(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::DoQueryInterface"));
-    PVUuid* uuid;
-    PVInterface** ptr;
-    aCmd.Parse(uuid, ptr);
-
-    PVMFStatus status = PVMFSuccess;
-    if (!queryInterface(*uuid, *ptr))
-        status = PVMFFailure;
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoRequestPort(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::DoRequestPort"));
-    int32 tag;
-    OSCL_String* mimetype;
-    PVMFVideoEncPort* port = NULL;
-    aCmd.Parse(tag, mimetype);
-
-    switch (tag)
-    {
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (iInPort.size() >= PVMF_VIDEOENC_NODE_MAX_INPUT_PORT)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::DoRequestPort: Error - Max number of input port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVVideoEncIn";
-
-            port = AllocatePort(iInPort, tag, mimetype, portname.get_cstr());
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-
-        break;
-
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-        {
-            if (iOutPort.size() >= PVMF_VIDEOENC_NODE_MAX_OUTPUT_PORT)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::DoRequestPort: Error - Max number of output port already allocated"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            OSCL_StackString<20> portname;
-            portname = "PVVideoEncOut";
-
-            port = AllocatePort(iOutPort, tag, mimetype, portname.get_cstr());
-            if (!port)
-            {
-                CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        break;
-
-        default:
-            LOG_ERR((0, "PVMFVideoEncNode::DoRequestPort: Error - Invalid port tag"));
-            CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-            return;
-    }
-
-    //Return the port pointer to the caller.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess, (OsclAny*)port);
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncPort* PVMFVideoEncNode::AllocatePort(PVMFVideoEncPortVector& aPortVector, int32 aTag,
-        OSCL_String* aMimeType, const char* aName)
-{
-    int32 err = 0;
-    OsclAny* ptr = NULL;
-
-    // Allocate a new port
-    OSCL_TRY(err,
-             ptr = aPortVector.Allocate();
-             if (!ptr)
-             OSCL_LEAVE(PVMFErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFVideoEncNode::AllocatePort: Error - iPortVector Out of memory"));
-                         return NULL;
-                        );
-    PVMFVideoEncPort* port = OSCL_PLACEMENT_NEW(ptr, PVMFVideoEncPort(aTag, this, Priority(), aName));
-
-    // if format was provided in mimestring, set it now.
-    if (aMimeType)
-    {
-        PVMFFormatType format = GetFormatIndex(aMimeType->get_str());
-        if ((port->SetFormat(format) != PVMFSuccess) ||
-                ((aTag == PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT) && (SetCodecType(format) != PVMFSuccess)))
-        {
-            aPortVector.DestructAndDealloc(port);
-            LOG_ERR((0, "PVMFVideoEncNode::AllocatePort: Error - port->SetFormat or SetCodecType failed"));
-            return NULL;
-        }
-    }
-
-    OSCL_TRY(err, aPortVector.AddL(port););
-    OSCL_FIRST_CATCH_ANY(err,
-                         aPortVector.DestructAndDealloc(port);
-                         return NULL;
-                        );
-
-    return port;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoReleasePort(PVMFVideoEncNodeCommand& aCmd)
-{
-    //Find the port in the port vector
-    PVMFVideoEncPort* port = NULL;
-    PVMFVideoEncPort** portPtr = NULL;
-    aCmd.Parse((PVMFPortInterface*&)port);
-
-    if (!port)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::DoReleasePort: Error - Invalid port pointer"));
-        CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-        return;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (port->GetPortTag())
-    {
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT:
-            portPtr = iInPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iInPort.Erase(portPtr);
-            }
-            break;
-
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-            portPtr = iOutPort.FindByValue(port);
-            if (!portPtr)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::DoReleasePort: Error - Port not found"));
-                status = PVMFFailure;
-            }
-            else
-            {
-                iOutPort.Erase(portPtr);
-            }
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFVideoEncNode::DoReleasePort: Error - Invalid port tag"));
-            status = PVMFFailure;
-            break;
-    }
-
-    CommandComplete(iCmdQueue, aCmd, status);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoInit(PVMFVideoEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-            SetState(EPVMFNodeInitialized);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeInitialized:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoPrepare(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFVIdeoEncNode::DoPrepare"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoStart(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::DoStart"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodePrepared:
-            iVideoEncoder = CPVM4VEncoder::New(0);
-            if (!iVideoEncoder)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::DoPrepare: new CommonVideoEncoder failed"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            iVideoEncoder->SetObserver(this);
-
-            if (iVideoEncoder->Initialize(&iInputFormat, &iEncodeParam) == ECVEI_FAIL)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::DoPrepare: CommonVideoEncoder::Initialize failed"));
-                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                return;
-            }
-
-            if (iEncodeParam.iContentType == ECVEI_STREAMING)
-            {
-                // M4V output, get VOL header
-                uint refCounterSize = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-                OsclMemoryFragment volHeader;
-                volHeader.ptr = NULL;
-                volHeader.len = 32; // Encoder requires that buffer size is greater than vol header size (28)
-                uint8* memBuffer = (uint8*)iAlloc.allocate(refCounterSize + volHeader.len);
-                oscl_memset(memBuffer, 0, refCounterSize + volHeader.len);
-                OsclRefCounter* refCounter = OSCL_PLACEMENT_NEW(memBuffer, OsclRefCounterDA(memBuffer, (OsclDestructDealloc*) & iAlloc));
-                memBuffer += refCounterSize;
-                volHeader.ptr = (OsclAny*)memBuffer;
-
-                int32 length = volHeader.len;
-                if (iVideoEncoder->GetVolHeader((uint8*)volHeader.ptr, &length, /*layer*/0) == ECVEI_FAIL)
-                {
-                    LOG_ERR((0, "PVMFVideoEncNode::DoPrepare: Error - CPVM4VEncoder::GetVolHeader failed"));
-                    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-                    return;
-                }
-                volHeader.len = length;
-                iVolHeader = OsclRefCounterMemFrag(volHeader, refCounter, 32);
-            }
-
-            SetState(EPVMFNodeStarted);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-
-        case EPVMFNodePaused:
-            SetState(EPVMFNodeStarted);
-
-            // Notify input port that the node is ready to process incoming msg again
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                ((PVMFVideoEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodeStarted:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoStop(PVMFVideoEncNodeCommand& aCmd)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::DoStop"));
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        {
-            // Clear queued messages in ports
-            uint32 i;
-            for (i = 0; i < iInPort.size(); i++)
-                iInPort[i]->ClearMsgQueues();
-            for (i = 0; i < iOutPort.size(); i++)
-                iOutPort[i]->ClearMsgQueues();
-
-            // Video encoder is created on Start, so in parallel it's deleted in Stop
-            DeleteVideoEncoder();
-            //transition to Prepared state
-            SetState(EPVMFNodePrepared);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-        }
-        break;
-        case EPVMFNodePrepared:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DeleteVideoEncoder()
-{
-    if (iVideoEncoder)
-    {
-        if (iMediaDataAlloc)
-        {
-            PVMFVideoEncNodeOutputData outputData;
-            PVMFStatus status = outputData.Allocate(iMediaDataAlloc, &iMediaDataMemPool);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::SyncEncodeAndSend: Error - outputData.Allocate failed"));
-                return;
-            }
-
-            // Flush and discard output data
-            while (iVideoEncoder->FlushOutput(&(outputData.iEncoderOutput)) == ECVEI_FLUSH)
-            {
-                outputData.iEncoderOutput.iBitStreamSize = MAX_OUTBUF_SIZE;
-            }
-        }
-
-        iVideoEncoder->Terminate();
-        OSCL_DELETE(iVideoEncoder);
-        iVideoEncoder = NULL;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoFlush(PVMFVideoEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            int32 err;
-            uint32 i;
-            bool msgPending;
-            msgPending = false;
-
-            for (i = 0; i < iInPort.size(); i++)
-            {
-                if (iInPort[i]->IncomingMsgQueueSize() > 0)
-                    msgPending = true;
-                iInPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessIncomingMsgReady
-                    // to wake up port AO
-                    ((PVMFVideoEncPort*)iInPort[i])->ProcessIncomingMsgReady();
-                }
-            }
-
-            for (i = 0; i < iOutPort.size(); i++)
-            {
-                if (iOutPort[i]->OutgoingMsgQueueSize() > 0)
-                    msgPending = true;
-                iOutPort[i]->SuspendInput();
-                if (iInterfaceState != EPVMFNodeStarted)
-                {
-                    // Port is in idle if node state is not started. Call ProcessOutgoingMsgReady
-                    // to wake up port AO
-                    ((PVMFVideoEncPort*)iOutPort[i])->ProcessOutgoingMsgReady();
-                }
-            }
-
-            //the flush is asynchronous.  move the command from
-            //the input command queue to the current command, where
-            //it will remain until the flush completes.
-            OSCL_TRY(err, iCurrentCmd.StoreL(aCmd););
-            OSCL_FIRST_CATCH_ANY(err,
-                                 CommandComplete(iCmdQueue, aCmd, PVMFErrNoMemory);
-                                 return;
-                                );
-            iCmdQueue.Erase(&aCmd);
-            if (!msgPending)
-            {
-                FlushComplete();
-                return;
-            }
-            break;
-
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFVideoEncNode::IsFlushPending()
-{
-    return (iCurrentCmd.size() > 0
-            && iCurrentCmd.front().iCmd == PVMF_GENERIC_NODE_FLUSH);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::FlushComplete()
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::FlushComplete"));
-    uint32 i = 0;
-
-    // Flush is complete only when all queues of all ports are clear.
-    // Other wise, just return from this method and wait for FlushComplete
-    // from the remaining ports.
-    for (i = 0; i < iInPort.size(); i++)
-    {
-        if (iInPort[i]->IncomingMsgQueueSize() > 0 ||
-                iInPort[i]->OutgoingMsgQueueSize() > 0)
-        {
-            return;
-        }
-    }
-
-    for (i = 0; i < iOutPort.size(); i++)
-    {
-        if (iOutPort[i]->IncomingMsgQueueSize() > 0 ||
-                iOutPort[i]->OutgoingMsgQueueSize() > 0)
-        {
-            return;
-        }
-    }
-
-    // Video encoder is created on Start, so in parallel it's deleted when Flush is completed
-    DeleteVideoEncoder();
-    //resume port input so the ports can be re-started.
-    for (i = 0; i < iInPort.size(); i++)
-        iInPort[i]->ResumeInput();
-    for (i = 0; i < iOutPort.size(); i++)
-        iOutPort[i]->ResumeInput();
-
-    // Flush is complete.  Go to prepared state.
-    SetState(EPVMFNodePrepared);
-    CommandComplete(iCurrentCmd, iCurrentCmd.front(), PVMFSuccess);
-
-    if (!iCmdQueue.empty())
-    {
-        // If command queue is not empty, schedule to process the next command
-        RunIfNotReady();
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoPause(PVMFVideoEncNodeCommand& aCmd)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-            SetState(EPVMFNodePaused);
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        case EPVMFNodePaused:
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            break;
-        default:
-            CommandComplete(iCmdQueue, aCmd, PVMFErrInvalidState);
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoReset(PVMFVideoEncNodeCommand& aCmd)
-{
-
-    //This example node allows a reset from any idle state.
-#if PROFILING_ON
-    if (!oDiagnosticsLogged)
-    {
-        LogDiagnostics();
-    }
-#endif
-
-
-    if (IsAdded())
-    {
-        while (!iInPort.empty())
-            iInPort.Erase(&iInPort.front());
-        while (!iOutPort.empty())
-            iOutPort.Erase(&iOutPort.front());
-
-        //restore original port vector reserve.
-        iInPort.Reconstruct();
-        iOutPort.Reconstruct();
-
-        //logoff & go back to Created state.
-        SetState(EPVMFNodeIdle);
-        CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-    }
-    else
-    {
-        OSCL_LEAVE(OsclErrInvalidState);
-
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoCancelAllCommands(PVMFVideoEncNodeCommand& aCmd)
-{
-    //first cancel the current command if any
-    {
-        while (!iCurrentCmd.empty())
-            CommandComplete(iCurrentCmd, iCurrentCmd[0], PVMFErrCancelled);
-    }
-
-    //next cancel all queued commands
-    {
-        //start at element 1 since this cancel command is element 0.
-        while (iCmdQueue.size() > 1)
-            CommandComplete(iCmdQueue, iCmdQueue[1], PVMFErrCancelled);
-    }
-
-    //finally, report cancel complete.
-    CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::DoCancelCommand(PVMFVideoEncNodeCommand& aCmd)
-{
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.Parse(id);
-
-    //first check "current" command if any
-    {
-        PVMFVideoEncNodeCommand* cmd = iCurrentCmd.FindById(id);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCurrentCmd, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PVMFVideoEncNodeCommand* cmd = iCmdQueue.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCmdQueue, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iCmdQueue, aCmd, PVMFFailure);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//               Port activity processing routines
-////////////////////////////////////////////////////////////////////////////
-bool PVMFVideoEncNode::IsProcessOutgoingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsConnectedPortBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-bool PVMFVideoEncNode::IsProcessIncomingMsgReady()
-{
-    if (iInterfaceState == EPVMFNodeStarted || IsFlushPending())
-    {
-        for (uint32 i = 0; i < iOutPort.size(); i++)
-        {
-            if (iOutPort[i]->IsOutgoingQueueBusy())
-                return false;
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::ProcessIncomingMsg: aPort=0x%x", aPort));
-    PVMFStatus status = PVMFFailure;
-
-    switch (aPort->GetPortTag())
-    {
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT:
-        {
-            if (!IsProcessIncomingMsgReady())
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::ProcessIncomingMsg: Error - Not ready."));
-                return PVMFErrBusy;
-            }
-
-            PVMFSharedMediaMsgPtr msg;
-            status = aPort->DequeueIncomingMsg(msg);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PVMFVideoEncNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed"));
-                return status;
-            }
-
-            if (msg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
-            {
-                status = SendEndOfTrackCommand(msg);
-                return status;
-            }
-            // Put the data on the data queue
-            PVMFSharedMediaDataPtr mediaData;
-            convertToPVMFMediaData(mediaData, msg);
-            status = SyncEncodeAndSend(mediaData);
-            switch (status)
-            {
-                case PVMFSuccess:
-                    break;
-                case PVMFErrBusy:
-                    LOG_DEBUG((0, "PVMFVideoEncNode::ProcessIncomingMsg: Outgoing queue busy. This should not happen."));
-                    break;
-                default:
-                    ReportErrorEvent(PVMF_VIDEOENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)aPort);
-                    break;
-            }
-        }
-        break;
-
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-            // Nothing to be done
-            status = PVMFSuccess;
-            break;
-
-        default:
-            LOG_ERR((0, "PVMFVideoEncNode::ProcessIncomingMsg: Error - Invalid port tag"));
-            ReportErrorEvent(PVMF_VIDEOENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)aPort);
-            status = PVMFFailure;
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::SyncEncodeAndSend(PVMFSharedMediaDataPtr& aMediaData)
-{
-    // Get the next data fragment
-    OsclRefCounterMemFrag frag;
-    aMediaData->getMediaFragment(0, frag);
-
-    TPVVideoInputData inputData;
-    inputData.iSource = (uint8*)frag.getMemFragPtr();
-    inputData.iTimeStamp = aMediaData->getTimestamp();
-
-    PVMFVideoEncNodeOutputData outputData;
-    PVMFStatus status = outputData.Allocate(iMediaDataAlloc, &iMediaDataMemPool);
-    if (status != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SyncEncodeAndSend: Error - outputData.Allocate failed"));
-        return status;
-    }
-
-#if	PROFILING_ON
-    uint32 startTicks = OsclTickCount::TickCount();
-#endif
-    if (iVideoEncoder->EncodeFrame(&inputData, &(outputData.iEncoderOutput)) == ECVEI_SUCCESS)
-    {
-        if (outputData.iEncoderOutput.iBitStreamSize > 0)
-        {
-#if PROFILING_ON
-            uint32 endTicks = OsclTickCount::TickCount();
-            uint32 enctime = OsclTickCount::TicksToMsec(endTicks - startTicks);
-            total_ticks += (endTicks - startTicks);
-
-            ++iStats.iNumFrames;
-            iStats.iDuration = outputData.iEncoderOutput.iVideoTimeStamp;
-            if ((iStats.iMinEncTime > enctime) || (0 == iStats.iMinEncTime))
-            {
-                iStats.iMinEncTime = enctime;
-            }
-            if (iStats.iMaxEncTime < enctime)
-            {
-                iStats.iMaxEncTime = enctime;
-            }
-#endif
-            return SendEncodedBitstream(outputData);
-        }
-        else
-        {
-#if PROFILING_ON
-            ++iStats.iNumFramesSkipped;
-#endif
-            LOG_DEBUG((0, "PVMFVideoEncNode::SyncEncodeAndSend(): Skipped frame"));
-            return PVMFSuccess;
-        }
-    }
-    else
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::SyncEncodeAndSend(): Error - EncodeFrame failed"));
-        return PVMFFailure;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::SendEncodedBitstream(PVMFVideoEncNodeOutputData& aOutputData)
-{
-    PVMFStatus status = PVMFSuccess;
-
-    // update the filled length of the fragment
-    aOutputData.iMediaData->setMediaFragFilledLen(0, aOutputData.iEncoderOutput.iBitStreamSize);
-
-    // Set timestamp
-    aOutputData.iMediaData->setTimestamp(aOutputData.iEncoderOutput.iVideoTimeStamp);
-
-    // Set sequence number
-    aOutputData.iMediaData->setSeqNum(iSeqNum++);
-
-    // Send vol header for m4v bitstream
-    if (aOutputData.iMediaData->getSeqNum() == 0 && iEncodeParam.iContentType == ECVEI_STREAMING)
-        aOutputData.iMediaData->setFormatSpecificInfo(iVolHeader);
-
-    // Send bitstream data to downstream node
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaMsg(mediaMsgOut, aOutputData.iMediaData);
-
-    for (uint32 i = 0; i < iOutPort.size(); i++)
-    {
-        status = iOutPort[i]->QueueOutgoingMsg(mediaMsgOut);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncNode::SendEncodedBitstream: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Encoder settings routines
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::SetCodecType(PVMFFormatType aCodec)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetCodecType: Error iInterfaceState=%d", iInterfaceState));
-            return PVMFErrInvalidState;
-        default:
-            break;
-    }
-
-    switch (aCodec)
-    {
-        case PVMF_H263:
-            iEncodeParam.iContentType = ECVEI_H263;
-            break;
-        case PVMF_M4V:
-            iEncodeParam.iContentType = ECVEI_STREAMING;
-            break;
-        default:
-            return PVMFErrNotSupported;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::SetInputFormat(PVMFFormatType aFormat)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::SetInputFormat: aFormat=%d", aFormat));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetInputFormat: Error - iInterfaceState=%d", iInterfaceState));
-            return PVMFErrInvalidState;
-        default:
-            break;
-    }
-
-    switch (aFormat)
-    {
-        case PVMF_YUV420:
-            iInputFormat.iVideoFormat = ECVEI_YUV420;
-            break;
-        case PVMF_YUV422:
-            iInputFormat.iVideoFormat = ECVEI_UYVY;
-            break;
-        case PVMF_RGB24:
-            iInputFormat.iVideoFormat = ECVEI_RGB24;
-            break;
-        case PVMF_RGB12:
-            iInputFormat.iVideoFormat = ECVEI_RGB12;
-            break;
-        default:
-            return PVMFFailure;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetInputFrameSize: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-        default:
-            break;
-    }
-
-    iInputFormat.iFrameWidth = aWidth;
-    iInputFormat.iFrameHeight = aHeight;
-    iInputFormat.iFrameOrientation = aFrmOrient;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::SetInputFrameRate(OsclFloat aFrameRate)
-{
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-            LOG_ERR((0, "PVMFVideoEncNode::SetInputFrameRate: Error iInterfaceState=%d", iInterfaceState));
-            return false;
-        default:
-            break;
-    }
-
-    iInputFormat.iFrameRate = OSCL_STATIC_CAST(float, aFrameRate);
-    iEncodeParam.iNoFrameSkip = iEncodeParam.iNoCurrentSkip = false;
-    return true;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFFormatType PVMFVideoEncNode::GetCodecType()
-{
-    switch (iEncodeParam.iContentType)
-    {
-        case ECVEI_H263:
-            return PVMF_H263;
-        case ECVEI_STREAMING:
-        case ECVEI_DOWNLOAD:
-            return PVMF_M4V;
-        default:
-            return PVMF_FORMAT_UNKNOWN;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PVMFVideoEncNode::GetOutputBitRate(uint32 aLayer)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::GetOutputBitRate: Error - Invalid layer number"));
-        return 0;
-    }
-
-    return iEncodeParam.iBitRate[aLayer];
-}
-
-////////////////////////////////////////////////////////////////////////////
-OsclFloat PVMFVideoEncNode::GetOutputFrameRate(uint32 aLayer)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::GetOutputFrameRate: Error Invalid layer number"));
-        return 0;
-    }
-
-    return (OsclFloat)iEncodeParam.iFrameRate[aLayer];
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNode::GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight)
-{
-    if ((int32)aLayer >= iEncodeParam.iNumLayer)
-    {
-        LOG_ERR((0, "PVMFVideoEncNode::GetOutputFrameSize: Error Invalid layer number"));
-        return PVMFFailure;
-    }
-
-    aWidth = iEncodeParam.iFrameWidth[aLayer];
-    aHeight = iEncodeParam.iFrameHeight[aLayer];
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-uint32 PVMFVideoEncNode::GetIFrameInterval()
-{
-    return iEncodeParam.iIFrameInterval;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                 Event reporting routines.
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::SetState(TPVMFNodeInterfaceState aState)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::SetState %d", aState));
-    PVMFNodeInterface::SetState(aState);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_ERR((0, "PVMFVideoEncNode::ReportErrorEvent: aEventType=%d aEventData=0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncNode::ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncNode::ReportInfoEvent: aEventType=%d, aEventData0x%x", aEventType, aEventData));
-    PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
-}
-
-////////////////////////////////////////////////////////////////////////////
-//            PVMFVideoEncNodeOutputData implementation
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncNodeOutputData::PVMFVideoEncNodeOutputData()
-{
-    oscl_memset(&iEncoderOutput, 0, sizeof(TPVVideoOutputData));
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncNodeOutputData::PVMFVideoEncNodeOutputData(const PVMFVideoEncNodeOutputData& aData)
-{
-    iEncoderOutput.iFrame = aData.iEncoderOutput.iFrame;
-    iEncoderOutput.iLayerNumber = aData.iEncoderOutput.iLayerNumber;
-    iEncoderOutput.iBitStream = aData.iEncoderOutput.iBitStream;
-    iEncoderOutput.iBitStreamSize = aData.iEncoderOutput.iBitStreamSize;
-    iEncoderOutput.iVideoTimeStamp = aData.iEncoderOutput.iVideoTimeStamp;
-    iEncoderOutput.iExternalTimeStamp = aData.iEncoderOutput.iExternalTimeStamp;
-    iEncoderOutput.iHintTrack.MTB = aData.iEncoderOutput.iHintTrack.MTB;
-    iEncoderOutput.iHintTrack.LayerID = aData.iEncoderOutput.iHintTrack.LayerID;
-    iEncoderOutput.iHintTrack.CodeType = aData.iEncoderOutput.iHintTrack.CodeType;
-    iEncoderOutput.iHintTrack.RefSelCode = aData.iEncoderOutput.iHintTrack.RefSelCode;
-    iMediaData = aData.iMediaData;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncNodeOutputData::Allocate(PVMFSimpleMediaBufferCombinedAlloc* aBufferAlloc,
-        PVMFVideoEncNodeMemPool* aMemPool)
-{
-    int32 err = 0;
-    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
-    OsclRefCounterMemFrag refCtrMemFragOut;
-
-    OSCL_TRY(err, mediaDataImplOut = aBufferAlloc->allocate(MAX_OUTBUF_SIZE););
-    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
-
-    OSCL_TRY(err, iMediaData = PVMFMediaData::createMediaData(mediaDataImplOut, aMemPool););
-    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
-
-    // Retrieve memory fragment to write to
-    iMediaData->getMediaFragment(0, refCtrMemFragOut);
-    iEncoderOutput.iBitStream = (uint8*)refCtrMemFragOut.getMemFrag().ptr;
-    oscl_memset(iEncoderOutput.iBitStream, 0, MAX_OUTBUF_SIZE);
-    iEncoderOutput.iBitStreamSize = MAX_OUTBUF_SIZE;
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFVideoEncNode::SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg)
-{
-    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
-
-    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_EOS_FORMAT_ID);
-
-    // Set the timestamp
-    sharedMediaCmdPtr->setTimestamp(aMsg->getTimestamp());
-
-    // Set the sequence number
-    sharedMediaCmdPtr->setSeqNum(aMsg->getSeqNum());
-
-    PVMFSharedMediaMsgPtr mediaMsgOut;
-    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
-
-    for (uint32 ii = 0; ii < iOutPort.size(); ii++)
-    {
-        PVMFStatus status = iOutPort[ii]->QueueOutgoingMsg(mediaMsgOut);
-
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncNode::SendEndOfTrackCommand: Error - QueueOutgoingMsg failed. status=%d", status));
-            return status;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-void PVMFVideoEncNode::LogDiagnostics()
-{
-
-#if	PROFILING_ON
-    oDiagnosticsLogged = true;
-    uint32 frame_rate =  0;
-    if (iStats.iDuration > 0)
-    {
-        frame_rate = (iStats.iNumFrames * 1000) / iStats.iDuration;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iDiagnosticsLogger, PVLOGMSG_DEBUG, (0, "PVMFVideoEncNode Stats: Frame Rate = %d, NumFrames=%d, NumSkippedFrames=%d, Final Timestamp=%d, Total Encode Time(in ms)=%d",
-                    frame_rate, iStats.iNumFrames, iStats.iNumFramesSkipped, iStats.iDuration, OsclTickCount::TicksToMsec(total_ticks)));
-
-    if (iStats.iNumFrames > 0)
-    {
-        iStats.iAverageEncTime = (OsclTickCount::TicksToMsec(total_ticks)) / iStats.iNumFrames;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFVideoEncNode Stats: EncTime(max:%d, min:%d, average:%d)/n",
-                    iStats.iMaxEncTime, iStats.iMinEncTime, iStats.iAverageEncTime));
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO, (0, "PVMFVideoEncNode Stats: NumFrames=%d, NumSkippedFrames=%d, Final Timestamp=%d, Time to encode(in ms)=%d",
-                    iStats.iNumFrames, iStats.iNumFramesSkipped, iStats.iDuration, OsclTickCount::TicksToMsec(total_ticks)));
-
-    oscl_memset(&iStats, 0, sizeof(PVVideoEncNodeStats));
-#endif
-
-}
\ No newline at end of file
diff --git a/nodes/pvvideoencnode/src/pvmf_videoenc_node.h b/nodes/pvvideoencnode/src/pvmf_videoenc_node.h
deleted file mode 100644
index 6f91a6f..0000000
--- a/nodes/pvvideoencnode/src/pvmf_videoenc_node.h
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_NODE_H_INCLUDED
-#define PVMF_VIDEOENC_NODE_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
-#include "pvmf_format_type.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef __PVM4VENCODER_H
-#include "pvm4vencoder.h"
-#endif
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
-#include "pvmf_simple_media_buffer.h"
-#endif
-#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-#include "pvmp4h263encextension.h"
-#endif
-#ifndef PVMF_VIDEOENC_TUNEABLES_H_INCLUDED
-#include "pvmf_videoenc_tuneables.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-#ifndef OSCL_TICKCOUNT_H_INCLUDED
-#include "oscl_tickcount.h"
-#endif
-// Forward declarations
-class PVMFVideoEncPort;
-class PVMFVideoEncNodeOutputData;
-class OsclClock;
-// Allocators
-typedef OsclMemAllocDestructDealloc<uint8> PVMFVideoEncNodeAllocDestructDealloc;
-typedef OsclMemAllocator PVMFVideoEncNodeAlloc;
-typedef OsclMemPoolFixedChunkAllocator PVMFVideoEncNodeMemPool;
-
-/** Node command type */
-typedef PVMFGenericNodeCommand<PVMFVideoEncNodeAlloc> PVMFVideoEncNodeCommand;
-
-/** Command queue type */
-typedef PVMFNodeCommandQueue<PVMFVideoEncNodeCommand, PVMFVideoEncNodeAlloc> PVMFVideoEncNodeCmdQueue;
-
-/** Port vector type */
-typedef PVMFPortVector<PVMFVideoEncPort, PVMFVideoEncNodeAlloc> PVMFVideoEncPortVector;
-
-////////////////////////////////////////////////////////////////////////////
-class PVMFVideoEncNode : public OsclTimerObject, public PVMFNodeInterface, public MPVCVEIObserver,
-            public PVMp4H263EncExtensionInterface, public PvmiCapabilityAndConfig
-{
-    public:
-        PVMFVideoEncNode(int32 aPriority);
-        ~PVMFVideoEncNode();
-
-        // Virtual functions of PVMFNodeInterface
-        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
-        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
-        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
-        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
-        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId aSession,
-                                                const PvmfMimeString& aMimeType,
-                                                Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
-                                                bool aExactUuidsOnly = false,
-                                                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSession,
-                const PVUuid& aUuid,
-                PVInterface*& aInterfacePtr,
-                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession, int32 aPortTag,
-                const PvmfMimeString* aPortConfig = NULL,
-                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId aSession, PVMFPortInterface& aPort,
-                const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId aSession, const OsclAny* aContext = NULL);
-        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContextData = NULL);
-        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId,
-                const OsclAny* aContextData = NULL);
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-        // Virtual functions of PVMp4H263EncExtensionInterface
-        OSCL_IMPORT_REF void addRef();
-        OSCL_IMPORT_REF void removeRef();
-        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
-        OSCL_IMPORT_REF bool SetNumLayers(uint32 aNumLayers);
-        OSCL_IMPORT_REF bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate);
-        OSCL_IMPORT_REF bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight);
-        OSCL_IMPORT_REF bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate);
-        OSCL_IMPORT_REF bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes);
-        OSCL_IMPORT_REF bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl);
-        OSCL_IMPORT_REF bool SetDataPartitioning(bool aDataPartitioning);
-        OSCL_IMPORT_REF bool SetRVLC(bool aRVLC);
-        OSCL_IMPORT_REF bool SetIFrameInterval(uint32 aIFrameInterval);
-        OSCL_IMPORT_REF bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader);
-        OSCL_IMPORT_REF bool RequestIFrame();
-        OSCL_IMPORT_REF bool SetCodec(PVMFFormatType aCodec);
-
-        // From MPVCVEIObserver
-        void HandlePVCVEIEvent(uint32 aId, uint32 aEvent, uint32 aParam1);
-
-        // implemetation of PvmiCapabilityAndConfig class functions here
-        void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-
-        PVMFStatus getParametersSync(PvmiMIOSession aSession,
-                                     PvmiKeyType aIdentifier,
-                                     PvmiKvp*& aParameters,
-                                     int& aNumParamElements,
-                                     PvmiCapabilityContext aContext);
-        PVMFStatus releaseParameters(PvmiMIOSession aSession,
-                                     PvmiKvp* aParameters,
-                                     int num_elements);
-        void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                                  PvmiKvp* aParameters, int num_parameter_elements);
-        void DeleteContext(PvmiMIOSession aSession,
-                           PvmiCapabilityContext& aContext);
-        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                               int num_elements, PvmiKvp * & aRet_kvp);
-        PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
-                                         PvmiKvp* aParameters,
-                                         int num_elements,
-                                         PvmiKvp*& aRet_kvp,
-                                         OsclAny* context = NULL);
-        uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
-                                        PvmiKvp* aParameters,
-                                        int num_elements);
-
-        // function used in getParametersSync of capability class
-        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
-                                      int32 aIndex, PvmiKvpAttr reqattr);
-        // function used in VerifyParametersSync n SetParametersSync of capability class
-        PVMFStatus VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam);
-
-
-    private:
-        void ConstructEncoderParams();
-
-        // From OsclTimerObject
-        void Run();
-
-        /////////////////////////////////////////////////////
-        //     Command processing routines
-        /////////////////////////////////////////////////////
-        PVMFCommandId QueueCommandL(PVMFVideoEncNodeCommand& aCmd);
-        bool ProcessCommand(PVMFVideoEncNodeCommand& aCmd);
-        void CommandComplete(PVMFVideoEncNodeCmdQueue& aCmdQueue, PVMFVideoEncNodeCommand& aCmd,
-                             PVMFStatus aStatus, OsclAny* aData = NULL);
-        void DoQueryUuid(PVMFVideoEncNodeCommand& aCmd);
-        void DoQueryInterface(PVMFVideoEncNodeCommand& aCmd);
-        void DoRequestPort(PVMFVideoEncNodeCommand& aCmd);
-        PVMFVideoEncPort* AllocatePort(PVMFVideoEncPortVector& aPortVector, int32 aTag, OSCL_String* aMimeType, const char* aName = NULL);
-        void DoReleasePort(PVMFVideoEncNodeCommand& aCmd);
-        void DoInit(PVMFVideoEncNodeCommand& aCmd);
-        void DoPrepare(PVMFVideoEncNodeCommand& aCmd);
-        void DoStart(PVMFVideoEncNodeCommand& aCmd);
-        void DoStop(PVMFVideoEncNodeCommand& aCmd);
-        void DeleteVideoEncoder();
-        void DoFlush(PVMFVideoEncNodeCommand& aCmd);
-        bool IsFlushPending();
-        void FlushComplete();
-        void DoPause(PVMFVideoEncNodeCommand& aCmd);
-        void DoReset(PVMFVideoEncNodeCommand& aCmd);
-        void DoCancelAllCommands(PVMFVideoEncNodeCommand& aCmd);
-        void DoCancelCommand(PVMFVideoEncNodeCommand& aCmd);
-
-        /////////////////////////////////////////////////////
-        //      Port activity processing routines
-        /////////////////////////////////////////////////////
-        bool IsProcessOutgoingMsgReady();
-        bool IsProcessIncomingMsgReady();
-        PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
-        PVMFStatus SyncEncodeAndSend(PVMFSharedMediaDataPtr& aMediaData);
-        PVMFStatus SendEncodedBitstream(PVMFVideoEncNodeOutputData& aOutputData);
-
-        /////////////////////////////////////////////////////
-        //      Encoder settings routine
-        /////////////////////////////////////////////////////
-        PVMFStatus SetInputFormat(PVMFFormatType aFormat);
-        PVMFStatus SetInputFrameSize(uint32 aWidth, uint32 aHeight, uint8 aFrmOrient = 0);
-        PVMFStatus SetInputFrameRate(OsclFloat aFrameRate);
-        PVMFStatus SetCodecType(PVMFFormatType aCodec);
-        PVMFFormatType GetCodecType();
-        uint32 GetOutputBitRate(uint32 aLayer);
-        OsclFloat GetOutputFrameRate(uint32 aLayer);
-        PVMFStatus GetOutputFrameSize(uint32 aLayer, uint32& aWidth, uint32& aHeight);
-        uint32 GetIFrameInterval();
-
-        // Event reporting
-        void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
-        void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL);
-        void SetState(TPVMFNodeInterfaceState aState);
-        PVMFStatus SendEndOfTrackCommand(PVMFSharedMediaMsgPtr& aMsg);
-    private:
-        void LogDiagnostics();
-        // Allocators
-        PVMFVideoEncNodeAllocDestructDealloc iAlloc;
-        PVMFVideoEncNodeMemPool iMediaBufferMemPool;
-        PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc;
-        PVMFVideoEncNodeMemPool iMediaDataMemPool;
-
-        // Command queue
-        PVMFVideoEncNodeCmdQueue iCmdQueue;
-
-        // A queue is used to hold the current command so it's easy to find out
-        // whether a command is in progress, and allow cancel to interrupt
-        PVMFVideoEncNodeCmdQueue iCurrentCmd;
-
-        // Ports and port activity
-        PVMFVideoEncPortVector iInPort;
-        PVMFVideoEncPortVector iOutPort;
-        Oscl_Vector<PVMFPortActivity, PVMFVideoEncNodeAlloc> iPortActivityQueue;
-        friend class PVMFVideoEncPort;
-
-        // Encoder
-        CPVM4VEncoder* iVideoEncoder;
-        TPVVideoInputFormat iInputFormat;
-        TPVVideoEncodeParam iEncodeParam;
-        OsclRefCounterMemFrag iVolHeader; /** Vol header */
-        uint32 iSeqNum; /** Sequence number */
-
-        PVLogger* iLogger;
-
-        PVLogger* iDiagnosticsLogger;
-        uint32 total_ticks;
-
-        int32 iExtensionRefCount;
-
-#if PROFILING_ON
-        // Statistics
-        struct PVVideoEncNodeStats
-        {
-            uint32 iNumFrames;
-            uint32 iNumFramesSkipped;
-            uint32 iDuration;
-            uint32 iMinEncTime;
-            uint32 iMaxEncTime;
-            uint32 iAverageEncTime;
-        };
-        PVVideoEncNodeStats iStats;
-        bool oDiagnosticsLogged;
-#endif
-};
-
-////////////////////////////////////////////////////////////////////////////
-class PVMFVideoEncNodeOutputData
-{
-    public:
-        PVMFVideoEncNodeOutputData();
-        PVMFVideoEncNodeOutputData(const PVMFVideoEncNodeOutputData& aData);
-        PVMFStatus Allocate(PVMFSimpleMediaBufferCombinedAlloc* aBufferAlloc, PVMFVideoEncNodeMemPool* aMemPool);
-
-        TPVVideoOutputData iEncoderOutput;
-        PVMFSharedMediaDataPtr iMediaData;
-};
-
-#endif // PVMF_VIDEOENC_NODE_H_INCLUDED
-
diff --git a/nodes/pvvideoencnode/src/pvmf_videoenc_node_cap_config.cpp b/nodes/pvvideoencnode/src/pvmf_videoenc_node_cap_config.cpp
deleted file mode 100644
index 8066858..0000000
--- a/nodes/pvvideoencnode/src/pvmf_videoenc_node_cap_config.cpp
+++ /dev/null
@@ -1,561 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_NODE_H_INCLUDED
-#include "pvmf_videoenc_node.h"
-#endif
-
-#ifndef PVMF_VIDEOENC_PORT_H_INCLUDED
-#include "pvmf_videoenc_port.h"
-#endif
-
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-
-#ifndef PVMI_KVP_UTIL_H_INCLUDED
-#include "pvmi_kvp_util.h"
-#endif
-
-
-// Structure to hold the key string info for
-// videoencnode's capability-and-config
-struct PVVideoEncNodeKeyStringData
-{
-    char iString[64];
-    PvmiKvpType iType;
-    PvmiKvpValueType iValueType;
-};
-
-// The number of characters to allocate for the key string
-#define PVVIDEOENCNODECONFIG_KEYSTRING_SIZE 128
-
-// Key string info at the base level ("x-pvmf/video/render")
-#define PVVIDEOENCNODECONFIG_BASE_NUMKEYS 3
-
-const PVVideoEncNodeKeyStringData PVVideoEncNodeConfigBaseKeys[PVVIDEOENCNODECONFIG_BASE_NUMKEYS] =
-{
-    {"output_width", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"output_height", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}
-};
-
-enum BaseKeys_IndexMapType
-{
-    OUTPUT_WIDTH = 0,
-    OUTPUT_HEIGHT
-};
-
-PVMFStatus PVMFVideoEncNode::GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr aReqattr)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::GetConfigParameter() In"));
-
-    aNumParamElements = 0;
-
-    // Allocate memory for the KVP
-    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
-    if (NULL == aParameters)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::GetConfigParameter() Memory allocation for KVP failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
-    // Allocate memory for the key string in KVP
-    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVVIDEOENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
-    if (NULL == memblock)
-    {
-        oscl_free(aParameters);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::GetConfigParameter() Memory allocation for key string failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_strset(memblock, 0, PVVIDEOENCNODECONFIG_KEYSTRING_SIZE * sizeof(char));
-    // Assign the key string buffer to KVP
-    aParameters[0].key = memblock;
-
-    // Copy the key string
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/video/render/"), 21);
-    oscl_strncat(aParameters[0].key, PVVideoEncNodeConfigBaseKeys[aIndex].iString, oscl_strlen(PVVideoEncNodeConfigBaseKeys[aIndex].iString));
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
-    switch (PVVideoEncNodeConfigBaseKeys[aIndex].iValueType)
-    {
-        case PVMI_KVPVALTYPE_BITARRAY32:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BITARRAY32_STRING), oscl_strlen(PVMI_KVPVALTYPE_BITARRAY32_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_KSV:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_BOOL:
-            oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_INT32:
-            if (PVMI_KVPATTR_CUR == aReqattr)
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            break;
-        case PVMI_KVPVALTYPE_UINT32:
-        default:
-            if (PVMI_KVPATTR_CAP == aReqattr)
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            else
-            {
-                oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
-            }
-            break;
-    }
-    aParameters[0].key[PVVIDEOENCNODECONFIG_KEYSTRING_SIZE-1] = 0;
-
-    // Copy the requested info
-    switch (aIndex)
-    {
-        case OUTPUT_WIDTH:	// "output_width"
-            if (PVMI_KVPATTR_CUR == aReqattr)
-            {
-                // Return current value
-                int32 aLayer = 0;
-                aParameters[0].value.uint32_value = iEncodeParam.iFrameWidth[aLayer];
-            }
-            else if (PVMI_KVPATTR_DEF == aReqattr)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = DEFAULT_FRAME_WIDTH;
-            }
-            else
-            {
-                // Return capability
-            }
-            break;
-
-        case OUTPUT_HEIGHT:	// "output_height"
-            if (PVMI_KVPATTR_CUR == aReqattr)
-            {
-                // Return current value
-                int32 aLayer = 0;
-                aParameters[0].value.uint32_value = iEncodeParam.iFrameHeight[aLayer];
-            }
-            else if (PVMI_KVPATTR_DEF == aReqattr)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = DEFAULT_FRAME_HEIGHT;
-            }
-            else
-            {
-                // Return capability
-            }
-            break;
-
-        default:
-            // Invalid index
-            oscl_free(aParameters[0].key);
-            oscl_free(aParameters);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::GetConfigParameter() Invalid index to video enc node parameter"));
-            return PVMFErrNotSupported;
-    }
-
-    aNumParamElements = 1;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::GetConfigParameter() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFVideoEncNode::VerifyAndSetConfigParameter(PvmiKvp& aParameter, bool aSetParam)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::VerifyAndSetConfigParameter() In"));
-
-    // Determine the valtype
-    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
-    if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::VerifyAndSetConfigParameter() Valtype in key string unknown"));
-        return PVMFErrNotSupported;
-    }
-    // Retrieve the fourth component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(3, aParameter.key, compstr);
-
-    int32 venccomp4ind;
-    for (venccomp4ind = 0; venccomp4ind < PVVIDEOENCNODECONFIG_BASE_NUMKEYS; ++venccomp4ind)
-    {
-        // Go through each component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(PVVideoEncNodeConfigBaseKeys[venccomp4ind].iString)) >= 0)
-        {
-            // Break out of the for loop
-            break;
-        }
-    }
-
-    if (PVVIDEOENCNODECONFIG_BASE_NUMKEYS <= venccomp4ind)
-    {
-        // Match couldn't be found or non-leaf node specified
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::VerifyAndSetConfigParameter() Unsupported key or non-leaf node"));
-        return PVMFErrNotSupported;
-    }
-
-    // Verify the valtype
-    if (keyvaltype != PVVideoEncNodeConfigBaseKeys[venccomp4ind].iValueType)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::VerifyAndSetConfigParameter() Valtype does not match for key"));
-        return PVMFErrNotSupported;
-    }
-
-    switch (venccomp4ind)
-    {
-        case OUTPUT_WIDTH: // "output_width"
-            // change the parameter
-            if (aSetParam)
-            {
-                int32 aLayer = 0;
-                iEncodeParam.iFrameWidth[aLayer] = aParameter.value.uint32_value;
-            }
-            break;
-
-        case OUTPUT_HEIGHT: // "output_height"
-            // change the parameter
-            if (aSetParam)
-            {
-                int32 aLayer = 0;
-                iEncodeParam.iFrameHeight[aLayer] = aParameter.value.uint32_value;
-            }
-            break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::VerifyAndSetConfigParameter() Invalid index for video enc node parameter"));
-            return PVMFErrNotSupported;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::VerifyAndSetConfigParameter() Out"));
-    return PVMFSuccess;
-}
-
-void PVMFVideoEncNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::setParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (NULL == aParameters || aNumElements < 1)
-    {
-        if (aParameters)
-        {
-            aRetKVP = aParameters;
-        }
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::setParametersSync() Passed in parameter invalid"));
-        return;
-    }
-
-    // Go through each parameter
-    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 3)
-        {
-            // First 3 components should be "x-pvmf/video/render" and there must
-            // be at least 3 components
-            aRetKVP = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::setParametersSync() Unsupported key"));
-            return;
-        }
-
-        if (4 == compcount)
-        {
-            // Verify and set the passed-in video enc node setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], true);
-            if (PVMFSuccess != retval)
-            {
-                aRetKVP = &aParameters[paramind];
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::setParametersSync() Setting parameter %d failed", paramind));
-                return;
-            }
-        }
-
-        else
-        {
-            // Do not support more than 4 components right now
-            aRetKVP = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::setParametersSync() Unsupported key"));
-            return;
-        }
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::setParametersSync() Out"));
-}
-
-
-PVMFStatus PVMFVideoEncNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::getParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-
-    // Initialize the output parameters
-    aNumParamElements = 0;
-    aParameters = NULL;
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aIdentifier);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aIdentifier, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 4)
-    {
-        // First 3 components should be "x-pvmf/video/render" and there must
-        // be at least 3 components
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::getParametersSync() Invalid key string"));
-        return PVMFErrNotSupported;
-    }
-
-    // Retrieve the fourth component from the key string
-    pv_mime_string_extract_type(3, aIdentifier, compstr);
-
-    for (int32 venccomp4ind = 0; venccomp4ind < PVVIDEOENCNODECONFIG_BASE_NUMKEYS; ++venccomp4ind)
-    {
-        // Go through each video enc component string at 4th level
-        if (pv_mime_strcmp(compstr, (char*)(PVVideoEncNodeConfigBaseKeys[venccomp4ind].iString)) >= 0)
-        {
-            if (4 == compcount)
-            {
-                // Determine what is requested
-                PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
-                if (PVMI_KVPATTR_UNKNOWN == reqattr)
-                {
-                    reqattr = PVMI_KVPATTR_CUR;
-                }
-
-                // Return the requested info
-                PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, venccomp4ind, reqattr);
-                if (PVMFSuccess != retval)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::getParametersSync() Retrieving video enc node parameter failed"));
-                    return retval;
-                }
-            }
-            else
-            {
-                // Right now videoenc node doesn't support more than 4 components
-                // for this sub-key string so error out
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::getParametersSync() Unsupported key"));
-                return PVMFErrNotSupported;
-            }
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::getParametersSync() Out"));
-    if (aNumParamElements == 0)
-    {
-        // If no one could get the parameter, return error
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::getParametersSync() Unsupported key"));
-        return PVMFFailure;
-    }
-    else
-    {
-        return PVMFSuccess;
-    }
-}
-
-PVMFStatus PVMFVideoEncNode::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::releaseParameters()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (aParameters == NULL || aNumElements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::releaseParameters() KVP list is NULL or number of elements is 0"));
-        return PVMFErrArgument;
-    }
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aParameters[0].key);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 3)
-    {
-        // First 3 component should be "x-pvmf/video/render" and there must
-        // be at least three components
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::releaseParameters() Unsupported key"));
-        return PVMFErrNotSupported;
-    }
-
-    // Retrieve the third component from the key string
-    pv_mime_string_extract_type(2, aParameters[0].key, compstr);
-
-    // Go through each KVP and release memory for value if allocated from heap
-    for (int32 ii = 0; ii < aNumElements; ++ii)
-    {
-        // Next check if it is a value type that allocated memory
-        PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
-        if (PVMI_KVPTYPE_VALUE == kvptype || PVMI_KVPTYPE_UNKNOWN == kvptype)
-        {
-            PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
-            if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::releaseParameters() Valtype not specified in key string"));
-                return PVMFErrNotSupported;
-            }
-
-            if (PVMI_KVPVALTYPE_CHARPTR == keyvaltype && NULL != aParameters[ii].value.pChar_value)
-            {
-                oscl_free(aParameters[ii].value.pChar_value);
-                aParameters[ii].value.pChar_value = NULL;
-            }
-            else if (keyvaltype == PVMI_KVPVALTYPE_KSV && NULL != aParameters[ii].value.key_specific_value)
-            {
-                oscl_free(aParameters[ii].value.key_specific_value);
-                aParameters[ii].value.key_specific_value = NULL;
-            }
-            else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
-            {
-                range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
-                aParameters[ii].value.key_specific_value = NULL;
-                oscl_free(rui32);
-            }
-            // TODO Add more types if video enc node starts returning more types
-        }
-    }
-
-    // Video enc node allocated its key strings in one chunk so just free the first key string ptr
-    oscl_free(aParameters[0].key);
-
-    // Free memory for the parameter list
-    oscl_free(aParameters);
-    aParameters = NULL;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::releaseParameters() Out"));
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVMFVideoEncNode::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::verifyParametersSync()"));
-    OSCL_UNUSED_ARG(aSession);
-
-    if (NULL == aParameters || aNumElements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::verifyParametersSync() Passed in parameter invalid"));
-        return PVMFErrArgument;
-    }
-
-    // Go through each parameter
-    for (int32 paramind = 0; paramind < aNumElements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/video/render")) < 0) || compcount < 3)
-        {
-            // First 3 components should be "x-pvmf/video/decoder" and there must
-            // be at least 3 components
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::verifyParametersSync() Unsupported key"));
-            return PVMFErrNotSupported;
-        }
-
-        if (4 == compcount)
-        {
-            // Verify and set the passed-in video enc node setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(aParameters[paramind], false);
-            if (retval != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::verifyParametersSync() Setting parameter %d failed", paramind));
-                return retval;
-            }
-        }
-        else
-        {
-            // Do not support more than 4 components right now
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoEncNode::verifyParametersSync() Unsupported key"));
-            return PVMFErrNotSupported;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoEncNode::verifyParametersSync() Out"));
-    return PVMFSuccess;
-
-}
-
-uint32 PVMFVideoEncNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-    OSCL_UNUSED_ARG(aSession);
-    return 0;
-}
-
-//PvmiCapConfigInterface
-void PVMFVideoEncNode::createContext(PvmiMIOSession aSession,
-                                     PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFVideoEncNode::setContextParameters(PvmiMIOSession aSession,
-        PvmiCapabilityContext& aContext,
-        PvmiKvp* aParameters,
-        int aNumElements)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFVideoEncNode::DeleteContext(PvmiMIOSession aSession,
-                                     PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-PVMFCommandId PVMFVideoEncNode::setParametersAsync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int aNumElements,
-        PvmiKvp*& aRet_kvp,
-        OsclAny* aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(aNumElements);
-    OSCL_UNUSED_ARG(aRet_kvp);
-//	PVMFVideoEncNodeCommand cmd;
-//	cmd.PVMFMP4FFParserNodeCommand::Construct(NULL, PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS, aSession, aParameters, num_elements, aRet_kvp, context);
-//	return QueueCommandL(cmd);
-    return 0;
-}
-
-void PVMFVideoEncNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    ciObserver = aObserver;
-}
-
diff --git a/nodes/pvvideoencnode/src/pvmf_videoenc_port.cpp b/nodes/pvvideoencnode/src/pvmf_videoenc_port.cpp
deleted file mode 100644
index d4379eb..0000000
--- a/nodes/pvvideoencnode/src/pvmf_videoenc_port.cpp
+++ /dev/null
@@ -1,929 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_PORT_H_INCLUDED
-#include "pvmf_videoenc_port.h"
-#endif
-#ifndef OSCL_PRIQUEUE_H_INCLUDED
-#include "oscl_priqueue.h"
-#endif
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-#ifndef PVMF_VIDEOENC_NODE_TYPES_H_INCLUDED
-#include "pvmf_videoenc_node_types.h"
-#endif
-#ifndef PVMF_VIDEOENC_NODE_H_INCLUDED
-#include "pvmf_videoenc_node.h"
-#endif
-
-#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m);
-#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m);
-#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncPort::PVMFVideoEncPort(int32 aTag, PVMFVideoEncNode* aNode, int32 aPriority, const char* name)
-        :  PvmfPortBaseImpl(aTag, this,
-                            PVMF_VIDEOENC_PORT_CAPACITY, PVMF_VIDEOENC_PORT_RESERVE, PVMF_VIDEOENC_PORT_THRESHOLD,
-                            PVMF_VIDEOENC_PORT_CAPACITY, PVMF_VIDEOENC_PORT_RESERVE, PVMF_VIDEOENC_PORT_THRESHOLD, name),
-        OsclActiveObject(aPriority, "PVMFVideoEncPort"),
-        iFormat(PVMF_FORMAT_UNKNOWN),
-        iNode(aNode)
-{
-    AddToScheduler();
-    iLogger = PVLogger::GetLoggerObject("PVMFVideoEncPort");
-#if PVMF_PORT_BASE_IMPL_STATS
-    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFVideoEncPort::~PVMFVideoEncPort()
-{
-    Disconnect();
-    ClearMsgQueues();
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
-{
-    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
-        aPtr = (PvmiCapabilityAndConfig*)this;
-    else
-        aPtr = NULL;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::Connect(PVMFPortInterface* aPort)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::Connect: aPort=0x%x", aPort));
-
-    if (!aPort)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - Connecting to invalid port"));
-        return PVMFErrArgument;
-    }
-
-    if (iConnectedPort)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - Already connected"));
-        return PVMFFailure;
-    }
-
-    PvmiCapabilityAndConfig* config = NULL;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
-    if (!config)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - Peer port does not support capability interface"));
-        return PVMFFailure;
-    }
-
-    PVMFStatus status = PVMFSuccess;
-    switch (iTag)
-    {
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT:
-            status = NegotiateInputSettings(config);
-            break;
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-            status = NegotiateOutputSettings(config);
-            break;
-        default:
-            LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - Invalid port tag"));
-            status = PVMFFailure;
-    }
-
-    if (status != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - Settings negotiation failed. status=%d", status));
-        return status;
-    }
-
-    //Automatically connect the peer.
-    if (aPort->PeerConnect(this) != PVMFSuccess)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - Peer Connect failed"));
-        return PVMFFailure;
-    }
-
-    iConnectedPort = aPort;
-
-#if PVMF_PORT_BASE_IMPL_STATS
-    // Reset statistics
-    oscl_memset((OsclAny*)&(PvmfPortBaseImpl::iStats), 0, sizeof(PvmfPortBaseImplStats));
-#endif
-
-    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-//                  PvmiCapabilityAndConfig
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-{
-    // Not supported
-    OSCL_UNUSED_ARG(aObserver);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::getParametersSync(PvmiMIOSession session,
-        PvmiKeyType identifier,
-        PvmiKvp*& parameters,
-        int& num_parameter_elements,
-        PvmiCapabilityContext context)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::getParametersSync"));
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-
-    parameters = NULL;
-    num_parameter_elements = 0;
-    PVMFStatus status = PVMFFailure;
-
-    switch (iTag)
-    {
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT:
-            return GetInputParametersSync(identifier, parameters, num_parameter_elements);
-        case PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT:
-            return GetOutputParametersSync(identifier, parameters, num_parameter_elements);
-        default:
-            LOG_ERR((0, "PVMFVideoEncPort::getParametersSync: Error - Invalid port tag"));
-            break;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::releaseParameters(PvmiMIOSession session,
-        PvmiKvp* parameters,
-        int num_elements)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(num_elements);
-
-    if (parameters)
-    {
-        iAlloc.deallocate((OsclAny*)parameters);
-        return PVMFSuccess;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::setContextParameters(PvmiMIOSession session,
-        PvmiCapabilityContext& context,
-        PvmiKvp* parameters, int num_parameter_elements)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-    OSCL_UNUSED_ARG(parameters);
-    OSCL_UNUSED_ARG(num_parameter_elements);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(context);
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF void PVMFVideoEncPort::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
-        int num_elements, PvmiKvp*& ret_kvp)
-{
-    OSCL_UNUSED_ARG(session);
-    PVMFStatus status = PVMFSuccess;
-    ret_kvp = NULL;
-
-    for (int32 i = 0; i < num_elements; i++)
-    {
-        status = VerifyAndSetParameter(&(parameters[i]), true);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
-            ret_kvp = &(parameters[i]);
-            OSCL_LEAVE(OsclErrArgument);
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFCommandId PVMFVideoEncPort::setParametersAsync(PvmiMIOSession session,
-        PvmiKvp* parameters,
-        int num_elements,
-        PvmiKvp*& ret_kvp,
-        OsclAny* context)
-{
-    OSCL_UNUSED_ARG(session);
-    OSCL_UNUSED_ARG(parameters);
-    OSCL_UNUSED_ARG(num_elements);
-    OSCL_UNUSED_ARG(ret_kvp);
-    OSCL_UNUSED_ARG(context);
-    return -1;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF uint32 PVMFVideoEncPort::getCapabilityMetric(PvmiMIOSession session)
-{
-    OSCL_UNUSED_ARG(session);
-    return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////
-OSCL_EXPORT_REF PVMFStatus PVMFVideoEncPort::verifyParametersSync(PvmiMIOSession session,
-        PvmiKvp* parameters, int num_elements)
-{
-    OSCL_UNUSED_ARG(session);
-
-    PVMFStatus status = PVMFSuccess;
-    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
-        status = VerifyAndSetParameter(&(parameters[i]));
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::SetFormat(PVMFFormatType aFormat)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::SetFormat: aFormat=%d", aFormat));
-    if (!IsFormatSupported(aFormat))
-        return PVMFFailure;
-
-    iFormat = aFormat;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::ProcessIncomingMsgReady()
-{
-    if (IncomingMsgQueueSize() > 0)
-        RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::ProcessOutgoingMsgReady()
-{
-    if (OutgoingMsgQueueSize() > 0)
-        RunIfNotReady();
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from PVMFPortActivityHandler
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::HandlePortActivity(const PVMFPortActivity& aActivity)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::HandlePortActivity: type=%d", aActivity.iType));
-
-    if (aActivity.iPort != this)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::HandlePortActivity: Error - Activity is not on this port"));
-        return;
-    }
-
-    switch (aActivity.iType)
-    {
-        case PVMF_PORT_ACTIVITY_CREATED:
-            //Report port created info event to the node.
-            iNode->ReportInfoEvent(PVMFInfoPortCreated,
-                                   (OsclAny*)aActivity.iPort);
-            break;
-
-        case PVMF_PORT_ACTIVITY_DELETED:
-            //Report port deleted info event to the node.
-            iNode->ReportInfoEvent(PVMFInfoPortDeleted,
-                                   (OsclAny*)aActivity.iPort);
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
-            // Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-            if (OutgoingMsgQueueSize() == 1 &&
-                    !IsConnectedPortBusy())
-            {
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
-            //Wakeup the AO on the first message only. After that it re-schedules itself as needed.
-            if (IncomingMsgQueueSize() == 1 &&
-                    iNode->IsProcessIncomingMsgReady())
-            {
-                RunIfNotReady();
-            }
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY:
-            // This is handled in the input port side when IsProcessIncomingMsgReady call failed
-            break;
-
-        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
-            // Notifies the node that the output queue is ready, and the node would
-            // resume encoding incoming data
-            iNode->HandlePortActivity(aActivity);
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY:
-            if (OutgoingMsgQueueSize() > 0)
-                RunIfNotReady();
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECTED_PORT_BUSY:
-            // This is handled when iNode->ProcessOutgoingMsg failed with busy
-            break;
-
-        case PVMF_PORT_ACTIVITY_CONNECT:
-        case PVMF_PORT_ACTIVITY_DISCONNECT:
-        default:
-            break;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Pure virtuals from OsclActiveObject
-////////////////////////////////////////////////////////////////////////////
-void PVMFVideoEncPort::Run()
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::Run"));
-    PVMFStatus status = PVMFSuccess;
-
-    // Process incoming messages
-    if (iTag == PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT)
-    {
-        if (IncomingMsgQueueSize() > 0)
-        {
-            //dispatch the incoming data.
-            status = iNode->ProcessIncomingMsg(this);
-            switch (status)
-            {
-                case PVMFSuccess:
-                    // Reschedule if there is more data and the node did not become busy
-                    // after processing the current msg
-                    if (IncomingMsgQueueSize() > 0 && iNode->IsProcessIncomingMsgReady())
-                    {
-                        RunIfNotReady();
-                    }
-                    break;
-
-                case PVMFErrBusy:
-                    // Node busy. Don't schedule next data
-                    break;
-
-                default:
-                    LOG_ERR((0, "PVMFVideoEncPort::Run: Error - ProcessIncomingMsg failed. status=%d", status));
-                    break;
-            }
-        }
-
-        if (iNode->IsFlushPending())
-        {
-            if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                iNode->FlushComplete();
-        }
-    }
-
-    //Process outgoing messages
-    if (iTag == PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        if (OutgoingMsgQueueSize() > 0)
-        {
-            if (iNode->IsProcessOutgoingMsgReady())
-            {
-                //Send data to connected port
-                status = Send();
-                switch (status)
-                {
-                    case PVMFSuccess:
-                        // Reschedule if there's more data to process and connected port did not become busy
-                        // after receiving the last msg
-                        if (OutgoingMsgQueueSize() > 0 && iNode->IsProcessOutgoingMsgReady())
-                        {
-                            RunIfNotReady();
-                        }
-                        break;
-
-                    case PVMFErrBusy:
-                        // Connected port busy. Don't schedule next data
-                        break;
-
-                    default:
-                        LOG_ERR((0, "PVMFVideoEncPort::Run: Error - Send() failed. status=%d", status));
-                        iNode->ReportErrorEvent(PVMF_VIDEOENC_NODE_ERROR_ENCODE_ERROR, (OsclAny*)this);
-                        break;
-                }
-
-                if (iNode->IsFlushPending())
-                {
-                    if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                        iNode->FlushComplete();
-                }
-            }
-        }
-
-        if (iNode->IsFlushPending())
-        {
-            if (IncomingMsgQueueSize() == 0 && OutgoingMsgQueueSize() == 0)
-                iNode->FlushComplete();
-        }
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-//           Capabilities exchange handling routines
-////////////////////////////////////////////////////////////////////////////
-bool PVMFVideoEncPort::IsFormatSupported(PVMFFormatType aFormat)
-{
-    if (iTag == PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT)
-    {
-        switch (aFormat)
-        {
-            case PVMF_YUV420:
-            case PVMF_YUV422:
-            case PVMF_RGB12:
-            case PVMF_RGB24:
-                return true;
-            default:
-                break;
-        }
-    }
-    else if (iTag == PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aFormat)
-        {
-            case PVMF_H263:
-            case PVMF_M4V:
-                return true;
-            default:
-                break;
-        }
-    }
-
-    return false;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-        int& num_parameter_elements)
-{
-    if (iTag != PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT)
-        return PVMFFailure;
-
-    PVMFStatus status = PVMFSuccess;
-
-    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
-    {
-        num_parameter_elements = 4;
-        status = AllocateKvp(parameters, INPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetInputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-
-        parameters[0].value.uint32_value = PVMF_YUV420;
-        parameters[1].value.uint32_value = PVMF_YUV422;
-        parameters[2].value.uint32_value = PVMF_RGB12;
-        parameters[3].value.uint32_value = PVMF_RGB24;
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-        int& num_parameter_elements)
-{
-    if (iTag != PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-        return PVMFFailure;
-
-    PVMFStatus status = PVMFSuccess;
-
-    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0)
-    {
-        num_parameter_elements = 2;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = PVMF_H263;
-            parameters[1].value.uint32_value = PVMF_M4V;
-        }
-    }
-    else if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iNode->GetCodecType();
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-
-        uint32 width, height;
-        status = iNode->GetOutputFrameSize(0, width, height);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error -iNode->GetOutputFrameSize failed. status=%d", status));
-        }
-        else
-        {
-            parameters[0].value.uint32_value = width;
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_HEIGHT_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            uint32 width, height;
-            status = iNode->GetOutputFrameSize(0, width, height);
-            if (status != PVMFSuccess)
-            {
-                LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - iNode->GetOutputFrameSize failed. status=%d", status));
-            }
-            else
-            {
-                parameters[0].value.uint32_value = height;
-            }
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.float_value = iNode->GetOutputFrameRate(0);
-        }
-    }
-    else if (pv_mime_strcmp(identifier, OUTPUT_BITRATE_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_BITRATE_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iNode->GetOutputBitRate(0);
-        }
-    }
-    else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_QUERY) == 0)
-    {
-        num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_IFRAME_INTERVAL_CUR_VALUE, num_parameter_elements);
-        if (status != PVMFSuccess)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
-            return status;
-        }
-        else
-        {
-            parameters[0].value.uint32_value = iNode->GetIFrameInterval();
-        }
-    }
-
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::AllocateKvp"));
-    uint8* buf = NULL;
-    uint32 keyLen = oscl_strlen(aKey) + 1;
-    int32 err = 0;
-
-    OSCL_TRY(err,
-             buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
-             if (!buf)
-             OSCL_LEAVE(OsclErrNoMemory);
-            );
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFVideoEncPort::AllocateKvp: Error - kvp allocation failed"));
-                         return PVMFErrNoMemory;
-                        );
-
-    int32 i = 0;
-    PvmiKvp* curKvp = aKvp = new(buf) PvmiKvp;
-    buf += sizeof(PvmiKvp);
-    for (i = 1; i < aNumParams; i++)
-    {
-        curKvp += i;
-        curKvp = new(buf) PvmiKvp;
-        buf += sizeof(PvmiKvp);
-    }
-
-    for (i = 0; i < aNumParams; i++)
-    {
-        aKvp[i].key = (char*)buf;
-        oscl_strncpy(aKvp[i].key, aKey, keyLen);
-        buf += keyLen;
-    }
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
-
-    if (!aKvp)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Invalid key-value pair"));
-        return PVMFFailure;
-    }
-
-    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0 &&
-            iTag == PVMF_VIDEOENC_NODE_PORT_TYPE_INPUT)
-    {
-        switch (aKvp->value.uint32_value)
-        {
-            case PVMF_YUV420:
-            case PVMF_YUV422:
-            case PVMF_RGB12:
-            case PVMF_RGB24:
-                if (aSetParam)
-                {
-                    iFormat = aKvp->value.uint32_value;
-                    iNode->SetInputFormat(iFormat);
-                }
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Input format %d not supported",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
-        }
-    }
-    else if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0 &&
-             iTag == PVMF_VIDEOENC_NODE_PORT_TYPE_OUTPUT)
-    {
-        switch (aKvp->value.uint32_value)
-        {
-            case PVMF_H263:
-            case PVMF_M4V:
-                if (aSetParam)
-                {
-                    iFormat = aKvp->value.uint32_value;
-                    iNode->SetCodecType(iFormat);
-                }
-                return PVMFSuccess;
-
-            default:
-                LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Output format %d not supported",
-                         aKvp->value.uint32_value));
-                return PVMFFailure;
-        }
-    }
-
-    LOG_ERR((0, "PVMFVideoEncPort::VerifyAndSetParameter: Error - Unsupported parameter"));
-    return PVMFFailure;
-}
-
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::NegotiateInputSettings: aConfig=0x%x", aConfig));
-    if (!aConfig)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - Invalid config object"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    int32 err = 0;
-    uint32 videoFormat;
-    // Get supported output formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, OUTPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams == 0)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - config->getParametersSync(output_formats) failed"));
-        return status;
-    }
-
-    OsclPriorityQueue < PvmiKvp*, OsclMemAllocator,
-    Oscl_Vector<PvmiKvp*, OsclMemAllocator>,
-    PVMFVideoEncInputFormatCompareLess > sortedKvp;
-
-    // Using a priority queue, sort the kvp's returned from aConfig->getParametersSync
-    // according to the preference of this port. Formats that are not supported are
-    // not pushed to the priority queue and hence dropped from consideration.
-    for (int32 i = 0; i < numParams; i++)
-    {
-        switch (kvp[i].value.uint32_value)
-        {
-            case PVMF_YUV420:
-            case PVMF_YUV422:
-            case PVMF_RGB12:
-            case PVMF_RGB24:
-            {
-                videoFormat = kvp[i].value.uint32_value;
-                OSCL_TRY(err, sortedKvp.push(&(kvp[i])););
-                OSCL_FIRST_CATCH_ANY(err,
-                                     LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - sortedKvp.push failed"));
-                                     return PVMFErrNoMemory;
-                                    );
-            }
-            break;
-            default:
-                break;
-        }
-    }
-
-    if (sortedKvp.size() == 0)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - No matching supported input format"));
-        // Release parameters back to peer
-        aConfig->releaseParameters(NULL, kvp, numParams);
-        kvp = NULL;
-        numParams = 0;
-        return PVMFFailure;
-    }
-
-    PvmiKvp* selectedKvp = sortedKvp.top();
-    PvmiKvp* retKvp = NULL;
-
-    // Set format of this port, peer port and container node
-    iFormat = selectedKvp->value.uint32_value;
-    iNode->SetInputFormat(iFormat);
-    OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFVideoEncPort::NegotiateInputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-                         return PVMFFailure;
-                        );
-
-    // Release parameters back to peer and reset for the next query
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    // Get size (in pixels) of video data from peer
-    uint32 width = 0;
-    uint32 height = 0;
-    uint8 orientation = 0;
-    status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_WIDTH_CUR_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams != 1)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - config->getParametersSync(current width) failed"));
-        return status;
-    }
-    width = kvp[0].value.uint32_value;
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_HEIGHT_CUR_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams != 1)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - config->getParametersSync(current height) failed"));
-        return status;
-    }
-    height = kvp[0].value.uint32_value;
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    if ((PVMF_RGB12 == videoFormat) || (PVMF_RGB24 == videoFormat))
-    {
-        status = aConfig->getParametersSync(NULL, VIDEO_FRAME_ORIENTATION_CUR_QUERY, kvp, numParams, NULL);
-        if (status != PVMFSuccess || numParams != 1)
-        {
-            LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - config->getParametersSync(current height) failed"));
-            return status;
-        }
-
-        orientation = kvp[0].value.uint8_value;
-        aConfig->releaseParameters(NULL, kvp, numParams);
-        kvp = NULL;
-        numParams = 0;
-
-    }
-    // Set input frame size of container node
-    iNode->SetInputFrameSize(width, height, orientation);
-
-    // Get video frame rate from peer
-    status = aConfig->getParametersSync(NULL, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams != 1)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::Connect: Error - config->getParametersSync(current frame rate) failed"));
-        return status;
-    }
-
-    // Set input frame rate of container node
-    iNode->SetInputFrameRate(kvp[0].value.float_value);
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-    return status;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PVMFVideoEncPort::NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig)
-{
-    LOG_STACK_TRACE((0, "PVMFVideoEncPort::NegotiateOutputSettings: aConfig=0x%x", aConfig));
-    if (!aConfig)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::NegotiateOutputSettings: Error - Invalid config object"));
-        return PVMFFailure;
-    }
-
-    PvmiKvp* kvp = NULL;
-    int numParams = 0;
-    int32 i = 0;
-    int32 err = 0;
-
-    // Get supported input formats from peer
-    PVMFStatus status = aConfig->getParametersSync(NULL, INPUT_FORMATS_CAP_QUERY, kvp, numParams, NULL);
-    if (status != PVMFSuccess || numParams == 0)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::NegotiateOutputSettings: Error - config->getParametersSync(input_formats) failed"));
-        return status;
-    }
-
-    PvmiKvp* selectedKvp = NULL;
-    PvmiKvp* retKvp = NULL;
-    for (i = 0; i < numParams && !selectedKvp; i++)
-    {
-        if (kvp[i].value.uint32_value == iFormat)
-            selectedKvp = &(kvp[i]);
-    }
-
-    if (!selectedKvp)
-    {
-        LOG_ERR((0, "PVMFVideoEncPort::NegotiateOutputSettings: Error - Output format not supported by peer"));
-        return PVMFFailure;
-    }
-
-    OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
-    OSCL_FIRST_CATCH_ANY(err,
-                         LOG_ERR((0, "PVMFVideoEncPort::NegotiateOutputSettings: Error - aConfig->setParametersSync failed. err=%d", err));
-                         return PVMFFailure;
-                        );
-
-    aConfig->releaseParameters(NULL, kvp, numParams);
-    kvp = NULL;
-    numParams = 0;
-
-    return PVMFSuccess;
-}
-
-
-
-
diff --git a/nodes/pvvideoencnode/src/pvmf_videoenc_port.h b/nodes/pvvideoencnode/src/pvmf_videoenc_port.h
deleted file mode 100644
index d236a8f..0000000
--- a/nodes/pvvideoencnode/src/pvmf_videoenc_port.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_PORT_H_INCLUDED
-#define PVMF_VIDEOENC_PORT_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
-#include "pvmf_port_base_impl.h"
-#endif
-#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
-#include "pvmf_node_interface.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
-#include "pvmi_config_and_capability_utils.h"
-#endif
-
-// Forward declaration
-class PVMFVideoEncNode;
-
-class PVMFVideoEncPort : public PvmfPortBaseImpl,
-            public PvmiCapabilityAndConfig,
-            public PVMFPortActivityHandler,
-            public OsclActiveObject
-{
-    public:
-        PVMFVideoEncPort(int32 aTag, PVMFVideoEncNode* aNode, int32 aPriority, const char* name = NULL);
-        ~PVMFVideoEncPort();
-
-        // Overload PvmfPortBaseImpl methods
-        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
-        OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
-
-
-        // Implement pure virtuals from PvmiCapabilityAndConfig interface
-        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
-        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
-                PvmiKvp*& aParameters, int& num_parameter_elements,
-                PvmiCapabilityContext aContext);
-        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                PvmiKvp* aParameters, int num_parameter_elements);
-        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                                               int num_elements, PvmiKvp * & aRet_kvp);
-        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
-        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
-
-        PVMFStatus SetFormat(PVMFFormatType aFormat);
-
-        // Notification from node to resume processing incoming msg
-        void ProcessIncomingMsgReady();
-        void ProcessOutgoingMsgReady();
-
-        // From PVMFPortActivityHandler
-        void HandlePortActivity(const PVMFPortActivity& aActivity);
-
-    private:
-        // Implement pure virtuals from OsclActiveObject
-        void Run();
-
-        /**
-         * Check if a format is supported for a specific port type
-         * @return true if specified format is supported for the specified port type
-         */
-        bool IsFormatSupported(PVMFFormatType aFormat);
-
-        /**
-         * Synchronous query of input port parameters
-         */
-        PVMFStatus GetInputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                          int& num_parameter_elements);
-
-        /**
-         * Synchronous query of output port parameters
-         */
-        PVMFStatus GetOutputParametersSync(PvmiKeyType identifier, PvmiKvp*& parameters,
-                                           int& num_parameter_elements);
-        /**
-         * Allocate a specified number of key-value pairs and set the keys
-         *
-         * @param aKvp Output parameter to hold the allocated key-value pairs
-         * @param aKey Key for the allocated key-value pairs
-         * @param aNumParams Number of key-value pairs to be allocated
-         * @return Completion status
-         */
-        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
-
-        /**
-         * Verify one key-value pair parameter against capability of the port and
-         * if the aSetParam flag is set, set the value of the parameter corresponding to
-         * the key.
-         *
-         * @param aKvp Key-value pair parameter to be verified
-         * @param aSetParam If true, set the value of parameter corresponding to the key.
-         * @return PVMFSuccess if parameter is supported, else PVMFFailure
-         */
-        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
-
-        /**
-         * Negotiates input port settings (format, video size and frame rate) and
-         * configures the peer port and the container node with these settings
-         *
-         * @param aConfig Capability and config object for peer port
-         * @return PVMFSuccess if settings are successfully negotiated.
-         */
-        PVMFStatus NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig);
-
-        /**
-         * Negotiates output port settings and configures the peer port using settings
-         * from the container node.
-         *
-         * @param aConfig Capability and config object for peer port
-         * @return PVMFSuccess if settings are successfully negotiated.
-         */
-        PVMFStatus NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig);
-
-        PVMFFormatType iFormat;
-        OsclMemAllocator iAlloc;
-        PVMFVideoEncNode* iNode;
-};
-
-class PVMFVideoEncInputFormatCompareLess
-{
-    public:
-        /**
-         * The algorithm used in OsclPriorityQueue needs a compare function
-         * that returns true when A's priority is less than B's
-         * @return true if A's priority is less than B's, else false
-         */
-        int compare(PvmiKvp*& a, PvmiKvp*& b) const
-        {
-            return (PVMFVideoEncInputFormatCompareLess::GetPriority(a) <
-                    PVMFVideoEncInputFormatCompareLess::GetPriority(b));
-        }
-
-        /**
-         * Returns the priority of each command
-         * @return A 0-based priority number. A lower number indicates lower priority.
-         */
-        static int GetPriority(PvmiKvp*& aKvp)
-        {
-            switch (aKvp->value.uint32_value)
-            {
-                case PVMF_YUV420:
-                    return 3;
-                case PVMF_YUV422:
-                    return 2;
-                case PVMF_RGB12:
-                    return 1;
-                case PVMF_RGB24:
-                    return 0;
-                default:
-                    return 0;
-            }
-        }
-};
-
-#endif // PVMF_VIDEOENC_INPORT_H_INCLUDED
diff --git a/nodes/pvvideoencnode/src/pvmf_videoenc_tuneables.h b/nodes/pvvideoencnode/src/pvmf_videoenc_tuneables.h
deleted file mode 100644
index 6e2b30b..0000000
--- a/nodes/pvvideoencnode/src/pvmf_videoenc_tuneables.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_VIDEOENC_TUNEABLES_H_INCLUDED
-#define PVMF_VIDEOENC_TUNEABLES_H_INCLUDED
-
-// Turn on statistics
-#define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
-
-// Default port queue reserve size
-#define PVMF_VIDEOENC_NODE_PORT_VECTOR_RESERVE 2
-#define PVMF_VIDEOENC_NODE_MAX_INPUT_PORT 1
-#define PVMF_VIDEOENC_NODE_MAX_OUTPUT_PORT 1
-#define PVMF_VIDEOENC_NODE_PORT_ACTIVITY_RESERVE 10
-
-// Default command queue reserve size
-#define PVMF_VIDEOENC_NODE_CMD_QUEUE_RESERVE 10
-
-// Starting value for command IDs
-#define PVMF_VIDEOENC_NODE_CMD_ID_START 10000
-
-#define DEFAULT_BITRATE 32000
-#define DEFAULT_FRAME_WIDTH 176
-#define DEFAULT_FRAME_HEIGHT 144
-#define DEFAULT_FRAME_RATE 5
-#define MAX_OUTBUF_SIZE 8192
-#define MAX_NUM_INPUTDATA	2
-#define MAX_NUM_OUTPUTDATA	2
-
-#define PVVIDENC_MEDIADATA_POOLNUM 8
-#define PVVIDENC_MEDIADATA_CHUNKSIZE 128
-#define PVVIDENC_MEDIABUFFER_CHUNKSIZE (MAX_OUTBUF_SIZE+128)
-
-// Port queue settings
-#define PVMF_VIDEOENC_PORT_CAPACITY 10
-#define PVMF_VIDEOENC_PORT_RESERVE 10
-#define PVMF_VIDEOENC_PORT_THRESHOLD 50
-
-
-#endif // PVMF_VIDEOENC_TUNEABLES_H_INCLUDED
diff --git a/nodes/pvvideoparsernode/Android.mk b/nodes/pvvideoparsernode/Android.mk
new file mode 100644
index 0000000..4e64b46
--- /dev/null
+++ b/nodes/pvvideoparsernode/Android.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pvmf_videoparser_port.cpp \
+ 	src/pvmf_videoparser_node.cpp
+
+
+LOCAL_MODULE := libpvvideoparsernode
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/nodes/pvvideoparsernode/src \
+ 	$(PV_TOP)/nodes/pvvideoparsernode/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pvmf_videoparser_port.h \
+ 	include/pvmf_videoparser_node.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/nodes/pvvideoparsernode/build/make/local.mk b/nodes/pvvideoparsernode/build/make/local.mk
new file mode 100644
index 0000000..4bb04f1
--- /dev/null
+++ b/nodes/pvvideoparsernode/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvvideoparsernode
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_videoparser_port.cpp \
+	pvmf_videoparser_node.cpp
+
+
+HDRS := pvmf_videoparser_port.h \
+	pvmf_videoparser_node.h
+
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/pvvideoparsernode/include/pvmf_videoparser_node.h b/nodes/pvvideoparsernode/include/pvmf_videoparser_node.h
new file mode 100644
index 0000000..462aeaf
--- /dev/null
+++ b/nodes/pvvideoparsernode/include/pvmf_videoparser_node.h
@@ -0,0 +1,305 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_videoparser_node.h
+ * @brief Video parser node. Parses incoming video bitstream into decodable frames.
+ *
+ */
+
+#ifndef PVMF_VIDEOPARSER_NODE_H_INCLUDED
+#define PVMF_VIDEOPARSER_NODE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+#ifndef PVT_COMMON_H_INCLUDED
+#include "pvt_common.h"
+#endif
+
+#define MAX_VIDEO_FRAME_PARSE_SIZE 22000
+#define MAX_VIDEO_FRAMES 3
+#define PVVIDEOPARSER_MEDIADATA_SIZE 128
+
+typedef struct vidparser_port_property
+{
+    PVMFFormatType format;
+    OSCL_HeapString<OsclMemAllocator> mimetype;
+    int32		porttag;
+} VideoParserPortProperty;
+
+////////////////////////////////////////////////////////////////////////////
+class PVMFVideoParserAlloc : public Oscl_DefAlloc
+{
+    public:
+        void* allocate(const uint32 size)
+        {
+            void* tmp = (void*)oscl_malloc(size);
+            return tmp;
+        }
+
+        void deallocate(void* p)
+        {
+            oscl_free(p);
+        }
+};
+
+enum PVMFVideoParserNodeCmdType
+{
+    PVMFVIDEOPARSER_NODE_CMD_INIT,
+    PVMFVIDEOPARSER_NODE_CMD_REQUESTPORT,
+    PVMFVIDEOPARSER_NODE_CMD_PREPARE,
+    PVMFVIDEOPARSER_NODE_CMD_START,
+    PVMFVIDEOPARSER_NODE_CMD_PAUSE,
+    PVMFVIDEOPARSER_NODE_CMD_STOP,
+    PVMFVIDEOPARSER_NODE_CMD_RELEASEPORT,
+    PVMFVIDEOPARSER_NODE_CMD_QUERY_INTERFACE,
+    PVMFVIDEOPARSER_NODE_CMD_QUERY_UUID,
+    PVMFVIDEOPARSER_NODE_CMD_RESET,
+    PVMFVIDEOPARSER_NODE_CMD_FLUSH,
+    PVMFVIDEOPARSER_NODE_CMD_CANCELCMD,
+    PVMFVIDEOPARSER_NODE_CMD_CANCELALL,
+    PVMFVIDEOPARSER_NODE_CMD_INVALID
+};
+
+class PVMFVideoParserNodeCmd
+{
+    public:
+        PVMFVideoParserNodeCmd() : iSession(-1),
+                iId(-1),
+                iType(PVMFVIDEOPARSER_NODE_CMD_INVALID),
+                iPort(NULL),
+                iContext(NULL),
+                iData(NULL)
+
+        {}
+
+        PVMFVideoParserNodeCmd(const PVMFVideoParserNodeCmd& aCmd) :
+                iSession(aCmd.iSession),
+                iId(aCmd.iId),
+                iType(aCmd.iType),
+                iPort(aCmd.iPort),
+                iContext(aCmd.iContext),
+                iData(aCmd.iData)
+        {}
+
+        ~PVMFVideoParserNodeCmd()
+        {}
+
+        PVMFSessionId iSession;
+        int32 iId;
+        int32 iType;
+        PVMFPortInterface* iPort;
+        OsclAny* iContext;
+        OsclAny* iData;
+
+        /**
+         * Equality operator, for use by OsclPriorityQueue.
+         */
+        bool operator==(const PVMFVideoParserNodeCmd& aCmd) const
+        {
+            return iId == aCmd.iId;
+        }
+
+};
+
+
+
+class PVMFVideoParserNodeCmdCompareLess
+{
+    public:
+        /**
+        * The algorithm used in OsclPriorityQueue needs a compare function
+        * that returns true when A's priority is less than B's
+        * @return true if A's priority is less than B's, else false
+        */
+        int compare(PVMFVideoParserNodeCmd& a, PVMFVideoParserNodeCmd& b) const
+        {
+            return (PVMFVideoParserNodeCmdCompareLess::GetPriority(a) < PVMFVideoParserNodeCmdCompareLess::GetPriority(b));
+        }
+
+        /**
+        * Returns the priority of each command
+        * @return A 0-based priority number. A lower number indicates lower priority.
+        */
+        static int GetPriority(PVMFVideoParserNodeCmd& aCmd)
+        {
+            switch (aCmd.iType)
+            {
+                case PVMFVIDEOPARSER_NODE_CMD_INIT:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_REQUESTPORT:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_START:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_PAUSE:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_STOP:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_RELEASEPORT:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_RESET:
+                    return 5;
+                case PVMFVIDEOPARSER_NODE_CMD_CANCELCMD:
+                    return 9;
+                case PVMFVIDEOPARSER_NODE_CMD_CANCELALL:
+                    return 10;
+                default:
+                    return 0;
+            }
+        }
+};
+
+class PVLogger;
+
+////////////////////////////////////////////////////////////////////////////
+class PVMFVideoParserNode : public OsclActiveObject, public PVMFNodeInterface
+{
+    public:
+        OSCL_IMPORT_REF static PVMFNodeInterface* Create(uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen);
+        OSCL_IMPORT_REF ~PVMFVideoParserNode();
+
+        // Virtual functions of PVMFNodeInterface
+        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF void HandlePortActivity(const PVMFPortActivity&);
+
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter);
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId aSession,
+                                                const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSession,
+                const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession
+                , int32 aPortTag
+                , const PvmfMimeString* aPortConfig = NULL
+                                                      , const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId aSession
+                , PVMFPortInterface& aPort
+                , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId aSession
+                                           , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId aSession
+                                              , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId aSession
+                                           , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId aSession
+                                            , const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId aSession
+                , const OsclAny* aContextData = NULL) ;
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId aSession
+                , PVMFCommandId aCmdId
+                , const OsclAny* aContextData = NULL) ;
+
+
+        // For input port to access private function / data
+        friend class PVMFVideoParserPort;
+
+        void Run();
+
+    private:
+        int AddPortActivity(const PVMFPortActivity& activity);
+
+        PVMFVideoParserNode();
+        void ConstructL(uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen);
+        void DoCancel();
+
+        void QueuePortActivity(const PVMFPortActivity &aActivity);
+
+        bool ProcessPortActivity();
+        PVMFStatus ProcessOutgoingMsg(PVMFPortInterface* aPort);
+        PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
+
+        // Handle command and data events
+        PVMFCommandId AddCmdToQueue(PVMFVideoParserNodeCmdType aType, PVMFSessionId s, PVMFPortInterface* aPort, const OsclAny* aContext, OsclAny* aData = NULL);
+        PVMFStatus HandleCmdStart(PVMFVideoParserNodeCmd* aCmd);
+        PVMFPortInterface *HandleCmdRequestPort(PVMFVideoParserNodeCmd* aCmd, PVMFStatus &aStatus);
+        PVMFStatus HandleCmdReleasePort(PVMFVideoParserNodeCmd* aCmd);
+
+        void DataReceived(OsclSharedPtr<PVMFMediaMsg>& aMsg);
+        void SendFrame();
+        bool FrameMarkerExists(uint8* aDataPtr, int32 aDataSize, uint32 aCrcError);
+
+        Oscl_Vector<PVMFPortActivity, OsclMemAllocator> iPortActivityQueue;
+        // Queue of commands
+        OsclPriorityQueue<PVMFVideoParserNodeCmd, PVMFVideoParserAlloc, Oscl_Vector<PVMFVideoParserNodeCmd, PVMFVideoParserAlloc>, PVMFVideoParserNodeCmdCompareLess> iCmdQueue;
+        PVMFCommandId iCmdIdCounter;
+
+        // Input port
+        PVMFPortInterface* iInputPort;
+        PVMFPortInterface* iOutputPort;
+
+        // Allocator
+        Oscl_DefAlloc* iAlloc;
+
+        uint8 iNumOnes[256];
+        PVMFFormatType iFormatType;
+        // Integer Format type for the port
+        PVCodecType_t iFormatTypeInteger;
+        bool iFirstFrameFound;
+        PVMFSharedMediaDataPtr iVideoFrame;
+
+        // Frame buffer memory pool
+        OsclMemPoolFixedChunkAllocator *iVidParserMemoryPool;
+        // Allocator for simple media data buffer
+        PVMFSimpleMediaBufferCombinedAlloc *iMediaDataAlloc;
+        // Memory pool for simple media data
+        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
+
+        PVLogger *iLogger;
+
+        // Format specific info associated with the codec in this datapath
+        uint8* iFormatSpecificInfo;
+        uint32 iFormatSpecificInfoLen;
+};
+
+#endif // PVMF_VIDEOPARSER_NODE_H_INCLUDED
diff --git a/nodes/pvvideoparsernode/include/pvmf_videoparser_port.h b/nodes/pvvideoparsernode/include/pvmf_videoparser_port.h
new file mode 100644
index 0000000..ce4f942
--- /dev/null
+++ b/nodes/pvvideoparsernode/include/pvmf_videoparser_port.h
@@ -0,0 +1,109 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_VIDEODEC_PORT_H_INCLUDED
+#define PVMF_VIDEODEC_PORT_H_INCLUDED
+
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+class PVMFVideoParserNode;
+
+//Default vector reserve size
+#define PVMF_VIDEOPARSER_NODE_PORT_VECTOR_RESERVE 10
+
+typedef enum
+{
+    PVMF_VIDEOPARSER_NODE_PORT_TYPE_SINK = 0,
+    PVMF_VIDEOPARSER_NODE_PORT_TYPE_SOURCE,
+} PVMFVideoParserPortType;
+
+class PVMFVideoParserPort : public PvmfPortBaseImpl
+            , public PvmiCapabilityAndConfigPortFormatImpl
+{
+    public:
+        PVMFVideoParserPort(int32 aTag,
+                            PVMFFormatType format,
+                            PVMFNodeInterface* aNode,
+                            uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen,
+                            char*);
+        ~PVMFVideoParserPort();
+
+        // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface
+        bool IsFormatSupported(PVMFFormatType);
+        void FormatUpdated();
+
+        // this port supports config interface
+        void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
+        {
+            if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+                aPtr = (PvmiCapabilityAndConfig*)this;
+            else
+                aPtr = NULL;
+        }
+
+        /* Over ride Connect() */
+        PVMFStatus Connect(PVMFPortInterface* aPort);
+        PVMFStatus PeerConnect(PVMFPortInterface* aPort);
+
+        /* Implement pure virtuals from PvmiCapabilityAndConfig interface */
+        PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                                     PvmiKvp*& aParameters, int& num_parameter_elements,	PvmiCapabilityContext aContext);
+        PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                               int num_elements, PvmiKvp * & aRet_kvp);
+        PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+
+    private:
+        void Construct(int32 aTag, PVMFFormatType format, uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen);
+
+        bool pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort,
+                                               const char* aFormatValType);
+
+        bool pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType,
+                                               PvmiKvp*& aKvp);
+
+        PVLogger *iLogger;
+
+        // Format specific info associated with the codec in this datapath
+        uint8* iFormatSpecificInfo;
+        uint32 iFormatSpecificInfoLen;
+};
+
+#endif // PVMF_VIDEODEC_PORT_H_INCLUDED
diff --git a/nodes/pvvideoparsernode/src/pvmf_videoparser_node.cpp b/nodes/pvvideoparsernode/src/pvmf_videoparser_node.cpp
new file mode 100644
index 0000000..a1d78fb
--- /dev/null
+++ b/nodes/pvvideoparsernode/src/pvmf_videoparser_node.cpp
@@ -0,0 +1,1098 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *
+ * @file pvmf_videoparser_node.cpp
+ * @brief Video parser node. Parses incoming video bitstream into frames.
+ *
+ */
+#include "pvmf_videoparser_port.h"
+#include "pvmf_videoparser_node.h"
+#include "pvlogger.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+
+#define VOP_START_BYTE_1 0x00
+#define VOP_START_BYTE_2 0x00
+#define VOP_START_BYTE_3 0x01
+#define VOP_START_BYTE_4 0xB6
+#define GOV_START_BYTE_4 0xB3
+
+#define H263_START_BYTE_1 0x00
+#define H263_START_BYTE_2 0x00
+#define H263_START_BYTE_3 0x80
+#define H263_START_BYTE_3_MASK 0xFC
+
+#define VOL_HEADER_START_BYTE_1 0x00
+#define VOL_HEADER_START_BYTE_2 0x00
+#define VOL_HEADER_START_BYTE_3 0x01
+#define VOL_HEADER_START_BYTE_4 0xB0
+
+static const uint8 M4vScLlookup[] =
+{
+    0x18  /*00000=11000*/, 0x19/*00001=11001*/, 0x18/*00010=11000*/, 0x19/*00011=11001*/,
+    0x0C  /*00100=01100*/, 0x0C/*00101=01100*/, 0x0C/*00110=01100*/, 0x0C/*00111=01100*/,
+    0x0C  /*01000=01100*/, 0x19/*01001=11001*/, 0x18/*01010=11000*/, 0x19/*01011=11001*/,
+    0x0C  /*01100=01100*/ , 0x0C/*01101=01100*/, 0x0C/*01110=01100*/, 0x0C/*01111=01100*/,
+    0x18  /*10000=11000*/, 0x19/*10001=11001*/, 0x18/*10010=11000*/, 0x19/*10011=11001*/,
+    0x18  /*10100=11000*/ , 0x19/*10101=11001*/, 0x18/*10110=11000*/, 0x19/*10111=11001*/,
+    0x18  /*11000=11000*/, 0x19/*11001=11001*/, 0x18/*11010=11000*/ , 0x19/*11011=11001*/,
+    0x18  /*11100=11000*/ , 0x19/*11101=11001*/, 0x18/*11110=11000*/, 0x19/*11111=11001*/
+};
+
+#include "oscl_dll.h"
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFNodeInterface* PVMFVideoParserNode::Create(uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen)
+{
+    PVMFVideoParserNode* aRet = OSCL_NEW(PVMFVideoParserNode, ());
+    if (aRet)
+    {
+        aRet->ConstructL(aFormatSpecificInfo, aFormatSpecificInfoLen);
+        aRet->AddToScheduler();
+    }
+
+    return aRet;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFVideoParserNode::PVMFVideoParserNode() : OsclActiveObject(OsclActiveObject::EPriorityNominal, "VideoParserNode"),
+        iCmdIdCounter(0),
+        iInputPort(NULL),
+        iOutputPort(NULL),
+        iFormatType(PVMF_MIME_FORMAT_UNKNOWN),
+        iFormatTypeInteger(PV_CODEC_TYPE_NONE),
+        iFirstFrameFound(false),
+        iVidParserMemoryPool(NULL),
+        iMediaDataAlloc(NULL),
+        iMediaDataMemPool(MAX_VIDEO_FRAMES, PVVIDEOPARSER_MEDIADATA_SIZE),
+        iLogger(NULL),
+        iFormatSpecificInfo(NULL),
+        iFormatSpecificInfoLen(0)
+{
+    SetState(EPVMFNodeCreated);
+    // Create a 256 element table with number of 1 bits in each index value
+    // Ex: 0->0, 1->1, 2->1, 3->2, 4->1, 5->2, 6->2
+    for (int n  = 0; n <= 0xFF; n++)
+    {
+        int m = n;
+        int cnt = 0;
+        while (m)
+        {
+            if (m & 0x1)
+            {
+                cnt++;
+            }
+            m >>= 1;
+        }
+        iNumOnes[n] = (uint8)cnt;
+    }
+
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFVideoParserNode::~PVMFVideoParserNode()
+{
+    if (iFormatSpecificInfo)
+    {
+        OSCL_FREE(iFormatSpecificInfo);
+        iFormatSpecificInfo = NULL;
+    }
+
+    if (iMediaDataAlloc)
+    {
+        OSCL_DELETE(iMediaDataAlloc);
+        iMediaDataAlloc = NULL;
+    }
+
+    if (iVidParserMemoryPool)
+    {
+        OSCL_DELETE(iVidParserMemoryPool);
+        iVidParserMemoryPool = NULL;
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserNode::ConstructL(uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen)
+{
+    iVidParserMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (MAX_VIDEO_FRAMES));
+    if (iVidParserMemoryPool == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    iVidParserMemoryPool->enablenullpointerreturn();
+
+    iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iVidParserMemoryPool));
+    if (iMediaDataAlloc == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    if (aFormatSpecificInfo && aFormatSpecificInfoLen)
+    {
+        iFormatSpecificInfo = (uint8*)OSCL_MALLOC(aFormatSpecificInfoLen);
+        if (iFormatSpecificInfo == NULL)
+        {
+            OSCL_LEAVE(PVMFErrNoMemory);
+        }
+        oscl_memcpy(iFormatSpecificInfo, aFormatSpecificInfo, aFormatSpecificInfoLen);
+        iFormatSpecificInfoLen = aFormatSpecificInfoLen;
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserNode::DoCancel()
+{
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PVMFVideoParserNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    aNodeCapability.iCanSupportMultipleInputPorts = false;
+    aNodeCapability.iCanSupportMultipleOutputPorts = false;
+    aNodeCapability.iHasMaxNumberOfPorts = true;
+    aNodeCapability.iMaxNumberOfPorts = 2;
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_M4V);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H2631998);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H2632000);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_M4V);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2631998);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2632000);
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFPortIter* PVMFVideoParserNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    OSCL_UNUSED_ARG(aFilter);
+    return NULL;
+}
+PVMFStatus PVMFVideoParserNode::ThreadLogon()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFVideoParserNode:ThreadLogon"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+            if (!IsAdded())
+            {
+                AddToScheduler();
+            }
+            iLogger = PVLogger::GetLoggerObject("PVMFVideoParserNode");
+            SetState(EPVMFNodeIdle);
+            return PVMFSuccess;
+        default:
+            return PVMFErrInvalidState;
+    }
+}
+
+PVMFStatus PVMFVideoParserNode::ThreadLogoff()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFVideoParserNode:ThreadLogoff"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+            if (IsAdded())
+            {
+                RemoveFromScheduler();
+            }
+            iLogger = NULL;
+            SetState(EPVMFNodeCreated);
+            return PVMFSuccess;
+
+        default:
+            return PVMFErrInvalidState;
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aUuids);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+    OSCL_UNUSED_ARG(aContext);
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_QUERY_UUID, s, NULL, aContext, NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::QueryInterface(PVMFSessionId s, const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aUuid);
+    OSCL_UNUSED_ARG(aInterfacePtr);
+    OSCL_UNUSED_ARG(aContext);
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_QUERY_INTERFACE, s, NULL, aContext, NULL);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::RequestPort(PVMFSessionId s, int32 aPortTag, const PvmfMimeString* aPortConfig, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::RequestPort called, format %s, port tag %d\n", aPortConfig ? aPortConfig->get_cstr() : "\"\"", aPortTag));
+    // Copy property
+    VideoParserPortProperty* property = OSCL_NEW(VideoParserPortProperty, ());
+    if (property != NULL)
+    {
+        property->porttag = aPortTag;
+        property->format = aPortConfig->get_str();
+        //property->mimetype = *aPortConfig;
+    }
+
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_REQUESTPORT, s, NULL, aContext, property);
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::ReleasePort\n"));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_RELEASEPORT, s, &aPort, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Init(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Init, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_INIT, s, NULL, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Start(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Start, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_START, s, NULL, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Prepare(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Prepare, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_PREPARE, s, NULL, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Flush, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_FLUSH, s, NULL, aContext);
+}
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Stop, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_STOP, s, NULL, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Pause, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_PAUSE, s, NULL, aContext);
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::Reset(PVMFSessionId s, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::Reset, state %d\n", iInterfaceState));
+    return AddCmdToQueue(PVMFVIDEOPARSER_NODE_CMD_RESET, s, NULL, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::CancelAllCommands, state %d\n", iInterfaceState));
+    OSCL_UNUSED_ARG(s);
+    OSCL_UNUSED_ARG(aContextData);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PVMFVideoParserNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContextData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::CancelCommand, state %d\n", iInterfaceState));
+    OSCL_UNUSED_ARG(s);
+    OSCL_UNUSED_ARG(aCmdId);
+    OSCL_UNUSED_ARG(aContextData);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFVideoParserNode::AddCmdToQueue(PVMFVideoParserNodeCmdType aType, PVMFSessionId s, PVMFPortInterface* aPort, const OsclAny* aContext, OsclAny* aData)
+{
+    PVMFVideoParserNodeCmd cmd;
+    cmd.iSession = s;
+    cmd.iType = aType;
+    cmd.iPort = aPort;
+    cmd.iContext = (OsclAny *) aContext;
+    cmd.iData = aData;
+    cmd.iId = iCmdIdCounter;
+    ++iCmdIdCounter;
+
+    iCmdQueue.push(cmd);
+
+    RunIfNotReady();
+    return cmd.iId;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserNode::Run()
+{
+    PVMFPortInterface *port = NULL;
+    OsclAny *eventData = NULL;
+
+    if (!iCmdQueue.empty())
+    {
+        PVMFStatus status = PVMFSuccess;
+        PVMFVideoParserNodeCmd cmd(iCmdQueue.top());
+        iCmdQueue.pop();
+        switch (cmd.iType)
+        {
+            case PVMFVIDEOPARSER_NODE_CMD_INIT:
+            {
+                if (iInterfaceState == EPVMFNodeIdle)
+                {
+                    OsclSharedPtr<PVMFMediaDataImpl> tempImpl;
+
+                    tempImpl = iMediaDataAlloc->allocate(MAX_VIDEO_FRAME_PARSE_SIZE);
+
+                    if (!tempImpl || !tempImpl->getCapacity())
+                    {
+                        SetState(EPVMFNodeIdle);
+                        status = PVMFErrNoMemory;
+                    }
+                    else
+                    {
+                        tempImpl.Unbind();
+                        SetState(EPVMFNodeInitialized);
+                    }
+                    tempImpl.Unbind();
+                }
+                else
+                {
+                    status = PVMFErrInvalidState;
+                }
+            }
+            break;
+            case PVMFVIDEOPARSER_NODE_CMD_PREPARE:
+
+                if (iInterfaceState != EPVMFNodeInitialized)
+                {
+                    status = PVMFErrInvalidState;
+                }
+                else
+                {
+                    SetState(EPVMFNodePrepared);
+                }
+                break;
+
+            case PVMFVIDEOPARSER_NODE_CMD_START:
+                if (iInterfaceState == EPVMFNodePaused || iInterfaceState == EPVMFNodePrepared)
+                {
+                    status = HandleCmdStart(&cmd);
+                }
+                else
+                {
+                    status = PVMFErrInvalidState;
+                }
+                break;
+
+            case PVMFVIDEOPARSER_NODE_CMD_STOP:
+                if (iInterfaceState == EPVMFNodeStarted)
+                {
+                    SetState(EPVMFNodePrepared);
+                }
+                else
+                {
+                    status = PVMFErrInvalidState;
+                }
+                break;
+
+            case PVMFVIDEOPARSER_NODE_CMD_RESET:
+                switch (iInterfaceState)
+                {
+                    case EPVMFNodeCreated:
+                    case EPVMFNodeIdle:
+                    case EPVMFNodeInitialized:
+                    case EPVMFNodePrepared:
+                    {
+                        if (iInputPort)
+                        {
+                            OSCL_DELETE(iInputPort);
+                            iInputPort = NULL;
+                        }
+
+                        if (iOutputPort)
+                        {
+                            OSCL_DELETE(iOutputPort);
+                            iOutputPort = NULL;
+                        }
+
+                        iVideoFrame.Unbind();
+
+                        while (iPortActivityQueue.size())
+                        {
+
+                            PVMFPortActivity activity(iPortActivityQueue.front());
+                            iPortActivityQueue.erase(&iPortActivityQueue.front());
+                        }
+                        while (iCmdQueue.size())
+                        {
+
+                            PVMFVideoParserNodeCmd cmd(iCmdQueue.top());
+                            iCmdQueue.pop();
+                            PVMFCmdResp resp(cmd.iId, cmd.iContext, PVMFFailure, eventData);
+                            ReportCmdCompleteEvent(cmd.iSession, resp);
+                        }
+
+
+                        SetState(EPVMFNodeIdle);
+                        status = PVMFSuccess;
+                    }
+                    default:
+                        status = PVMFErrInvalidState;
+                        break;
+                }
+                break;
+
+            case PVMFVIDEOPARSER_NODE_CMD_PAUSE:
+                if (iInterfaceState == EPVMFNodeStarted)
+                {
+                    SetState(EPVMFNodePaused);
+                }
+                else
+                {
+                    status = PVMFErrInvalidState;
+                }
+                break;
+
+            case PVMFVIDEOPARSER_NODE_CMD_REQUESTPORT:
+                switch (iInterfaceState)
+                {
+
+                    case EPVMFNodeInitialized:
+                    case EPVMFNodePrepared:
+                    case EPVMFNodeStarted:
+                    {
+                        port = HandleCmdRequestPort(&cmd, status);
+                        eventData = (OsclAny*)port;
+                        if (cmd.iData != NULL)
+                        {
+                            OSCL_DELETE(((VideoParserPortProperty*)cmd.iData)); // Allocated dynamically in RequestPort()
+                        }
+                    }
+                    break;
+                    default:
+                        status = PVMFErrInvalidState;
+                        break;
+                }
+                break;
+
+            case PVMFVIDEOPARSER_NODE_CMD_RELEASEPORT:
+            {
+                status = HandleCmdReleasePort(&cmd);
+            }
+            break;
+            case PVMFVIDEOPARSER_NODE_CMD_FLUSH:
+                break;
+            case PVMFVIDEOPARSER_NODE_CMD_QUERY_INTERFACE:
+            case PVMFVIDEOPARSER_NODE_CMD_QUERY_UUID:
+            default:
+            {
+                status = PVMFErrNotSupported;
+            }
+            break;
+        }
+        PVMFCmdResp resp(cmd.iId, cmd.iContext, status, eventData);
+        ReportCmdCompleteEvent(cmd.iSession, resp);
+    }
+
+    if (!iPortActivityQueue.empty() && (iInterfaceState == EPVMFNodeStarted))
+    {
+        // If the port activity cannot be processed because a port is
+        // busy, discard the activity and continue to process the next
+        // activity in queue until getting to one that can be processed.
+        while (!iPortActivityQueue.empty())
+        {
+            if (ProcessPortActivity())
+            {
+                break; //processed a port
+            }
+        }
+    }
+
+    if (!iPortActivityQueue.empty() || !iCmdQueue.empty())
+    {
+        // Run again if there are more commands to process
+        RunIfNotReady();
+    }
+
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFVideoParserNode::HandleCmdStart(PVMFVideoParserNodeCmd* aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::HandleCmdStart, input port %x, output port %x\n", iInputPort, iOutputPort));
+
+    SetState(EPVMFNodeStarted);
+    return PVMFSuccess;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PVMFPortInterface *PVMFVideoParserNode::HandleCmdRequestPort(PVMFVideoParserNodeCmd* aCmd, PVMFStatus &aStatus)
+{
+    VideoParserPortProperty *property = (VideoParserPortProperty*)aCmd->iData;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::HandleCmdRequestPort\n"));
+
+    aStatus  = PVMFSuccess;
+
+    if (!property)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, no port property\n"));
+        aStatus = PVMFErrNoMemory;
+        return NULL;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::HandleCmdRequestPort, port type %d, format %s\n", property->porttag, (property->format).getMIMEStrPtr()));
+
+    if (!((property->format == PVMF_MIME_M4V) || (property->format == PVMF_MIME_H2631998) || (property->format == PVMF_MIME_H2632000)))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, unknown format\n"));
+        aStatus = PVMFErrArgument;
+        return NULL;
+    }
+
+    switch (property->porttag)
+    {
+        case PVMF_VIDEOPARSER_NODE_PORT_TYPE_SINK:
+            if (iOutputPort && iFormatType != property->format)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, output format (%s) doesn't match input format (%s)\n", iFormatType.getMIMEStrPtr(), (property->format).getMIMEStrPtr()));
+                //Output format doesn't match output format.
+                aStatus = PVMFFailure;
+                return NULL;
+            }
+
+            if (iInputPort)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, input port already exists\n"));
+                // it's been taken for now, so reject this request
+                aStatus = PVMFFailure;
+                return NULL;
+            }
+
+            // Create and configure output port
+            iInputPort = OSCL_NEW(PVMFVideoParserPort, (property->porttag,
+                                  property->format,
+                                  this,
+                                  iFormatSpecificInfo, iFormatSpecificInfoLen,
+                                  OSCL_STATIC_CAST(char*, "PVMFVideoParserInputPort")));
+            if (!iInputPort)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, unable to allocate input port\n"));
+                aStatus = PVMFErrNoMemory;
+                return NULL;
+            }
+
+            iFormatType = property->format;
+            if ((iFormatType == PVMF_MIME_H2631998) || (iFormatType == PVMF_MIME_H2632000))
+            {
+                iFormatTypeInteger = PV_VID_TYPE_H263;
+            }
+            else if (iFormatType == PVMF_MIME_M4V)
+            {
+                iFormatTypeInteger = PV_VID_TYPE_MPEG4;
+            }
+            return iInputPort;
+
+        case PVMF_VIDEOPARSER_NODE_PORT_TYPE_SOURCE:
+
+            if (iInputPort)
+            {
+                if (iFormatType != property->format)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, input format (%s) doesn't match output format (%s)\n", iFormatType.getMIMEStrPtr(), (property->format).getMIMEStrPtr()));
+                    //Input format doesn't match output format.
+                    aStatus = PVMFFailure;
+                    return NULL;
+                }
+            }
+
+
+            if (iOutputPort)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, output port already exists\n"));
+                // it's been taken for now, so reject this request
+                aStatus = PVMFFailure;
+                return NULL;
+            }
+
+            iOutputPort = OSCL_NEW(PVMFVideoParserPort, (property->porttag,
+                                   property->format,
+                                   this,
+                                   iFormatSpecificInfo, iFormatSpecificInfoLen,
+                                   OSCL_STATIC_CAST(char*, "PVMFVideoParserOutputPort")));
+            if (!iOutputPort)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, unable to allocate output port\n"));
+                aStatus = PVMFErrNoMemory;
+                return NULL;
+            }
+
+            iFormatType = property->format;
+            if ((iFormatType == PVMF_MIME_H2631998) || (iFormatType == PVMF_MIME_H2632000))
+            {
+                iFormatTypeInteger = PV_VID_TYPE_H263;
+            }
+            else if (iFormatType == PVMF_MIME_M4V)
+            {
+                iFormatTypeInteger = PV_VID_TYPE_MPEG4;
+            }
+
+            return iOutputPort;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdStart, unknown port type\n"));
+            aStatus = PVMFErrNotSupported;
+            return NULL;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFVideoParserNode::HandleCmdReleasePort(PVMFVideoParserNodeCmd* aCmd)
+{
+    if (aCmd->iPort == iInputPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFVideoParserNode::HandleCmdReleasePort, release input port\n"));
+        iInputPort->Disconnect();
+        OSCL_DELETE(iInputPort);
+        iInputPort = NULL;
+        return PVMFSuccess;
+    }
+    else if (aCmd->iPort == iOutputPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFVideoParserNode::HandleCmdReleasePort, release output port\n"));
+        iOutputPort->Disconnect();
+        OSCL_DELETE(iOutputPort);
+        iOutputPort = NULL;
+        return PVMFSuccess;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::HandleCmdReleasePort, unknown port to release\n"));
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserNode::DataReceived(OsclSharedPtr<PVMFMediaMsg>& aMsg)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::DataReceived, state %d\n", iInterfaceState));
+    if (iInterfaceState == EPVMFNodeStarted)
+    {
+        PVMFSharedMediaDataPtr mediaData;
+        OsclRefCounterMemFrag memFrag;
+        OsclRefCounterMemFrag curVideoFrag;
+
+        convertToPVMFMediaData(mediaData, aMsg);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::DataReceived, Num fragments=%d, filled size=%d\n", mediaData->getNumFragments(), mediaData->getFilledSize()));
+
+
+        for (uint32 i = 0; i < mediaData->getNumFragments(); i++)
+        {
+            mediaData->getMediaFragment(i, memFrag);
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFVideoParserNode::DataReceived, frag size %d, idx %d\n", memFrag.getMemFragSize(), i));
+
+            //Make sure it can fit in the video buffer.
+            if (memFrag.getMemFragSize() > MAX_VIDEO_FRAME_PARSE_SIZE)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::DataReceived, frag cannot fit into video buffer\n"));
+                continue;
+            }
+
+            if (FrameMarkerExists((uint8 *)memFrag.getMemFragPtr(), memFrag.getMemFragSize(), mediaData->getErrorsFlag()))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_DEBUG, (0, "PVMFVideoParserNode::DataReceived, frame found\n"));
+                //If buffer exists then send it.
+                if (iVideoFrame.GetRep())
+                {
+                    SendFrame();
+                }
+            }
+
+            //If data cannot fit in remaining buffer space, send current buffer regardless
+            if (iVideoFrame.GetRep() && (iVideoFrame->getFilledSize() + memFrag.getMemFragSize()) > iVideoFrame->getCapacity())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFVideoParserNode::DataReceived, frag data cannot fit into remaining buffer space\n"));
+                SendFrame();
+            }
+
+            if (!iVideoFrame.GetRep())
+            {
+                OsclRefCounterMemFrag formatSpecificInfo;
+                OsclSharedPtr<PVMFMediaDataImpl> tempImpl;
+
+                // Drop rest of data if unable to allocate next buffer
+                tempImpl = iMediaDataAlloc->allocate(MAX_VIDEO_FRAME_PARSE_SIZE)
+                           ;
+
+                if (!tempImpl)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFVideoParserNode::DataReceived, unable to allocate media impl\n"));
+                    return;
+                }
+                iVideoFrame = PVMFMediaData::createMediaData(tempImpl, &iMediaDataMemPool);
+
+                if (!iVideoFrame)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFVideoParserNode::DataReceived, unable to allocate media data\n"));
+                    tempImpl.Unbind();
+                    return;
+                }
+                iVideoFrame->setTimestamp(mediaData->getTimestamp());
+                iVideoFrame->setSeqNum(1);
+                mediaData->getFormatSpecificInfo(formatSpecificInfo);
+                iVideoFrame->setFormatSpecificInfo(formatSpecificInfo);
+            }
+            if (memFrag.getMemFragSize() > 0)
+            {
+                iVideoFrame->getMediaFragment(0, curVideoFrag);
+                oscl_memcpy((uint8 *)curVideoFrag.getMemFragPtr() + iVideoFrame->getFilledSize(), memFrag.getMemFragPtr(), memFrag.getMemFragSize());
+                iVideoFrame->setMediaFragFilledLen(0, iVideoFrame->getFilledSize() + memFrag.getMemFragSize());
+            }
+        }
+    }
+}
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserNode::SendFrame()
+{
+    OsclSharedPtr<PVMFMediaMsg> mediaMsg;
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
+    if (iVideoFrame->getMediaDataImpl(mediaDataImpl))
+    {
+        mediaDataImpl->setMarkerInfo(1);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFVideoParserNode::SendFrame() cannot get media data impl\n"));
+    }
+
+    convertToPVMFMediaMsg(mediaMsg, iVideoFrame);
+
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFVideoParserNode::SendFrame, size %d\n", iVideoFrame->getFilledSize()));
+
+    if (iOutputPort) iOutputPort->QueueOutgoingMsg(mediaMsg);
+    iVideoFrame.Unbind();
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFVideoParserNode::FrameMarkerExists(uint8* aDataPtr,
+        int32 aDataSize,
+        uint32 aCrcError)
+{
+    uint16 match_cnt = 0;
+    if (iFormatTypeInteger == PV_VID_TYPE_H263)
+    {
+        //If start of new frame.
+        if ((aDataSize > 2) &&
+                (aDataPtr[0] == H263_START_BYTE_1) &&
+                (aDataPtr[1] == H263_START_BYTE_2) &&
+                ((aDataPtr[2] & H263_START_BYTE_3_MASK) == H263_START_BYTE_3))
+        {
+            return true;
+        }
+    }
+
+    else if (iFormatTypeInteger == PV_VID_TYPE_MPEG4)
+    {
+        if (!aCrcError)
+        {
+            if (aDataSize >= 3)
+            {
+                if ((aDataPtr[0] == VOP_START_BYTE_1) &&
+                        (aDataPtr[1] == VOP_START_BYTE_2) &&
+                        (aDataPtr[2] == VOP_START_BYTE_3))
+                {
+                    return true;
+                }
+            }
+        }
+        else
+        {
+            if (aDataSize > 4)
+            {
+                int16 nBitsCorrected = 0;
+                //If start of new frame.
+                match_cnt = (uint16)(iNumOnes[(aDataPtr[0] ^ VOP_START_BYTE_1)] +
+                                     iNumOnes[(aDataPtr[1] ^ VOP_START_BYTE_2)]);
+                if (match_cnt > 2)
+                {
+                    return false;
+                }
+
+                nBitsCorrected = match_cnt;
+
+                if (aDataPtr[2] & 0x80)
+                {
+                    return false;
+                }
+
+                // Match the next 12 bits
+                match_cnt = (uint16)(iNumOnes[(aDataPtr[2] ^ VOP_START_BYTE_3)] +
+                                     iNumOnes[((aDataPtr[3] & 0xF8) ^ 0xB0)]);
+                if (match_cnt > 1)
+                {
+                    return false;
+                }
+                nBitsCorrected = (int16)(nBitsCorrected + match_cnt);
+
+                uint8 c3 = 0, c4 = 0;
+                uint8 c = (uint8)(aDataPtr[3] & 0x07);
+                c3 = VOP_START_BYTE_4 &  0xF0;
+                c = (uint8)(c << 2 | aDataPtr[4] >> 6);
+                c = M4vScLlookup[c];
+                c3 |= (c >> 2);
+                c4 = (uint8)(aDataPtr[4] & 0x3F);
+                c4 |= (c << 6);
+
+                nBitsCorrected = (int16)(nBitsCorrected + iNumOnes[((c3^aDataPtr[3]) + (c4 ^ aDataPtr[4]))]);
+
+                aDataPtr[0] = VOP_START_BYTE_1;
+                aDataPtr[1] = VOP_START_BYTE_2;
+                aDataPtr[2] = VOP_START_BYTE_3;
+                aDataPtr[3] = c3;
+                aDataPtr[4] = c4;
+
+                return true;
+            }
+        }
+    }
+
+    else
+    {
+        // Unhandled codec type. Error
+        return false;
+    }
+
+    return false;
+}
+
+void PVMFVideoParserNode::HandlePortActivity(const PVMFPortActivity& aActivity)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFVideoParserNode::PortActivity: port=0x%x, type=%d",
+                     this, aActivity.iPort, aActivity.iType));
+
+    switch (aActivity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            if (ProcessOutgoingMsg(aActivity.iPort) != PVMFSuccess)
+            {
+                if (aActivity.iPort->OutgoingMsgQueueSize() == 1)
+                    QueuePortActivity(aActivity);
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+
+            if (ProcessIncomingMsg(aActivity.iPort) != PVMFSuccess)
+            {
+                if (aActivity.iPort->IncomingMsgQueueSize() == 1)
+                    QueuePortActivity(aActivity);
+            }
+
+            break;
+
+        case PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_READY:
+            if (aActivity.iPort->OutgoingMsgQueueSize() > 0)
+            {
+                RunIfNotReady();
+            }
+            break;
+
+        case PVMF_PORT_ACTIVITY_CONNECT:
+            //nothing needed.
+            break;
+
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+            //clear the node input queue when either port is disconnected.
+            break;
+        default:
+            break;
+    }
+}
+
+int PVMFVideoParserNode::AddPortActivity(const PVMFPortActivity& activity)
+{
+    int32 err = OsclErrNone;
+    OSCL_TRY(err, iPortActivityQueue.push_back(activity););
+    return err;
+}
+
+bool PVMFVideoParserNode::ProcessPortActivity()
+{//called by the AO to process a port activity message
+
+    //Pop the queue...
+    PVMFPortActivity activity(iPortActivityQueue.front());
+    iPortActivityQueue.erase(&iPortActivityQueue.front());
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFVideoParserNode::ProcessPortActivity: port=0x%x, type=%d",
+                     this, activity.iPort, activity.iType));
+
+    int32 err = OsclErrNone;
+
+    PVMFStatus status = PVMFSuccess;
+    switch (activity.iType)
+    {
+        case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
+            status = ProcessOutgoingMsg(activity.iPort);
+            //Re-queue the port activity event as long as there's
+            //more data to process and it isn't in a Busy state.
+            if (status != PVMFErrBusy
+                    && activity.iPort->OutgoingMsgQueueSize() > 0)
+            {
+                err = AddPortActivity(activity);
+            }
+            break;
+        case PVMF_PORT_ACTIVITY_INCOMING_MSG:
+            status = ProcessIncomingMsg(activity.iPort);
+            //Re-queue the port activity event as long as there's
+            //more data to process and it isn't in a Busy state.
+            if (status != PVMFErrBusy
+                    && activity.iPort->IncomingMsgQueueSize() > 0)
+            {
+                err = AddPortActivity(activity);
+            }
+            break;
+        default:
+            break;
+    }
+
+    //report a failure in queueing new activity...
+    if (err != OsclErrNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFVideoParserNode::Run: Error - queue port activity failed. port=0x%x, type=%d", this, activity.iPort, activity.iType));
+        ReportErrorEvent(PVMFErrPortProcessing);
+    }
+
+    //return true if we processed an activity...
+    return (status != PVMFErrBusy);
+}
+
+void PVMFVideoParserNode::QueuePortActivity(const PVMFPortActivity &aActivity)
+{
+    //queue a new port activity event
+    int32 err;
+    err = AddPortActivity(aActivity);
+    if (err != OsclErrNone)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFVideoParserNode::PortActivity: Error - iPortActivityQueue.push_back() failed", this));
+        ReportErrorEvent(PVMFErrPortProcessing, (OsclAny*)(aActivity.iPort));
+    }
+    else
+    {
+        //wake up the AO to process the port activity event.
+        RunIfNotReady();
+    }
+}
+
+
+PVMFStatus PVMFVideoParserNode::ProcessOutgoingMsg(PVMFPortInterface* aPort)
+{
+    //Called by the AO to process one message off the outgoing
+    //message queue for the given port.  This routine will
+    //try to send the data to the connected port.
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFVideoParserNode::ProcessOutgoingMsg: aPort=0x%x", this, aPort));
+
+    PVMFStatus status = aPort->Send();
+    if (status == PVMFErrBusy)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                        (0, "0x%x PVMFVideoParserNode::ProcessOutgoingMsg: Connected port goes into busy state", this));
+    }
+
+    return status;
+}
+
+PVMFStatus PVMFVideoParserNode::ProcessIncomingMsg(PVMFPortInterface* aPort)
+{
+    PVMFSharedMediaMsgPtr msg;
+    if (iInterfaceState != EPVMFNodeStarted)
+        return PVMFFailure;
+    PVMFStatus status = aPort->DequeueIncomingMsg(msg);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "0x%x PVMFVideoParserNode::ProcessIncomingMsg: Error - DequeueIncomingMsg failed", this));
+    }
+    else if (msg->getFormatID() == PVMF_MEDIA_CMD_BOS_FORMAT_ID)
+    {
+        PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
+        // Set the formatID, timestamp, sequenceNumber and streamID for the media message
+        sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
+        sharedMediaCmdPtr->setTimestamp(msg->getTimestamp());
+        sharedMediaCmdPtr->setSeqNum(msg->getSeqNum());
+        sharedMediaCmdPtr->setStreamID(msg->getStreamID());
+
+        PVMFSharedMediaMsgPtr mediaMsgOut;
+        convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
+        PVMFStatus retVal = iOutputPort->QueueOutgoingMsg(mediaMsgOut);
+
+        if (retVal != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                            (0, "PVMFVideoParserNode::SendBeginOfMediaStreamCommand: Outgoing queue busy. "));
+        }
+        msg.Unbind();
+        return retVal;
+    }
+    else
+    {
+        DataReceived(msg);
+    }
+    return status;
+}
diff --git a/nodes/pvvideoparsernode/src/pvmf_videoparser_port.cpp b/nodes/pvvideoparsernode/src/pvmf_videoparser_port.cpp
new file mode 100644
index 0000000..9c4ba0f
--- /dev/null
+++ b/nodes/pvvideoparsernode/src/pvmf_videoparser_port.cpp
@@ -0,0 +1,321 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_videoparser_port.h"
+#include "pvmf_videoparser_node.h"
+#include "pv_mime_string_utils.h"
+
+
+PVMFVideoParserPort::PVMFVideoParserPort(int32 aTag,
+        PVMFFormatType format,
+        PVMFNodeInterface* aNode,
+        uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen,
+        char*name)
+        : PvmfPortBaseImpl(aTag, aNode, name),
+        iFormatSpecificInfo(NULL),
+        iFormatSpecificInfoLen(0)
+{
+    Construct(aTag, format, aFormatSpecificInfo, aFormatSpecificInfoLen);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserPort::Construct(int32 aTag, PVMFFormatType format, uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen)
+{
+    if (aTag == PVMF_VIDEOPARSER_NODE_PORT_TYPE_SINK)
+    {
+        iLogger = PVLogger::GetLoggerObject("PVMFVideoParserPort(Input)");
+        PvmiCapabilityAndConfigPortFormatImpl::Construct(INPUT_FORMATS_CAP_QUERY , INPUT_FORMATS_VALTYPE);
+    }
+    else
+    {
+        iLogger = PVLogger::GetLoggerObject("PVMFVideoParserPort(Output)");
+        PvmiCapabilityAndConfigPortFormatImpl::Construct(OUTPUT_FORMATS_CAP_QUERY , OUTPUT_FORMATS_VALTYPE);
+    }
+    oscl_memset(&iStats, 0, sizeof(PvmfPortBaseImplStats));
+    iFormat = format;
+
+    if (aFormatSpecificInfo && aFormatSpecificInfoLen)
+    {
+        iFormatSpecificInfo = (uint8*)OSCL_MALLOC(aFormatSpecificInfoLen);
+        if (iFormatSpecificInfo == NULL)
+        {
+            OSCL_LEAVE(PVMFErrNoMemory);
+        }
+        oscl_memcpy(iFormatSpecificInfo, aFormatSpecificInfo, aFormatSpecificInfoLen);
+        iFormatSpecificInfoLen = aFormatSpecificInfoLen;
+    }
+}
+
+
+PVMFVideoParserPort::~PVMFVideoParserPort()
+{
+    Disconnect();
+    ClearMsgQueues();
+}
+
+////////////////////////////////////////////////////////////////////////////
+bool PVMFVideoParserPort::IsFormatSupported(PVMFFormatType aFmt)
+{
+    return ((aFmt == PVMF_MIME_M4V) || (aFmt == PVMF_MIME_H2631998) || (aFmt == PVMF_MIME_H2632000));
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PVMFVideoParserPort::FormatUpdated()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFVideoParserPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
+}
+
+
+PVMFStatus PVMFVideoParserPort::Connect(PVMFPortInterface* aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFVideoParserPort::Connect: aPort=0x%x", aPort));
+    if (!aPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                        , (0, "PVMFVideoParserPort::Connect: Error - Connecting to invalid port"));
+        return PVMFErrArgument;
+    }
+
+    if (iConnectedPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                        , (0, "PVMFVideoParserPort::Connect: Error - Already connected"));
+        return PVMFFailure;
+    }
+
+    OsclAny* config = NULL;
+
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, config);
+
+    if (config != NULL)
+    {
+        if (!(pvmiSetPortFormatSpecificInfoSync(OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, config),
+                                                PVMF_FORMAT_SPECIFIC_INFO_KEY)))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                            , (0, "PVMFVideoParserPort::Connect: Error - Unable To Send Format Specific Info To Peer"));
+            return PVMFFailure;
+        }
+    }
+
+    /*
+     * Automatically connect the peer.
+     */
+    if (aPort->PeerConnect(this) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                        , (0, "PVMFVideoParserPort::Connect: Error - Peer Connect failed"));
+        return PVMFFailure;
+    }
+
+    iConnectedPort = aPort;
+
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFVideoParserPort::PeerConnect(PVMFPortInterface* aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "0x%x PVMFVideoParserPort::PeerConnect: aPort=0x%x", this, aPort));
+
+    if (!aPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFVideoParserPort::PeerConnect: Error - Connecting to invalid port", this));
+        return PVMFErrArgument;
+    }
+
+    if (iConnectedPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                        (0, "0x%x PVMFVideoParserPort::PeerConnect: Error - Already connected", this));
+        return PVMFFailure;
+    }
+
+    iConnectedPort = aPort;
+
+    OsclAny *config = NULL;
+
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, config);
+
+    if (config != NULL)
+    {
+        if (!(pvmiSetPortFormatSpecificInfoSync(OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, config), PVMF_FORMAT_SPECIFIC_INFO_KEY)))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                            , (0, "PVMFVideoParserPort::PeerConnect: Error - Unable To Send Format Specific Info To Peer"));
+            return PVMFFailure;
+        }
+    }
+
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFVideoParserPort::getParametersSync(PvmiMIOSession aSession,
+        PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aIdentifier);
+    OSCL_UNUSED_ARG(aContext);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFVideoParserPort::getParametersSync: aSession=0x%x, aIdentifier=%s, aParameters=0x%x, num_parameters_elements=%d, aContext=0x%x",
+                       aSession, aIdentifier, aParameters, num_parameter_elements, aContext));
+
+    num_parameter_elements = 0;
+
+    if (pv_mime_strcmp(aIdentifier, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        if (!pvmiGetPortFormatSpecificInfoSync(PVMF_FORMAT_SPECIFIC_INFO_KEY, aParameters))
+        {
+            return PVMFFailure;
+        }
+        num_parameter_elements = 1;
+        return PVMFSuccess;
+    }
+    return PvmiCapabilityAndConfigPortFormatImpl::getParametersSync(aSession, aIdentifier, aParameters, num_parameter_elements, aContext);
+}
+
+
+PVMFStatus PVMFVideoParserPort::releaseParameters(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(num_elements);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFVideoParserPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
+                       aSession, aParameters, num_elements));
+
+    if (pv_mime_strcmp(aParameters->key, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        OsclMemAllocator alloc;
+        alloc.deallocate((OsclAny*)(aParameters->key));
+        return PVMFSuccess;
+    }
+
+    return PvmiCapabilityAndConfigPortFormatImpl::releaseParameters(aSession, aParameters, num_elements);
+}
+
+void PVMFVideoParserPort::setParametersSync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements,
+        PvmiKvp * & aRet_kvp)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(aRet_kvp);
+    OSCL_UNUSED_ARG(num_elements);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFVideoParserPort::getParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d, aRet_kvp=0x%x",
+                       aSession, aParameters, num_elements, aRet_kvp));
+}
+
+PVMFStatus PVMFVideoParserPort::verifyParametersSync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
+                    , (0, "PVMFVideoParserPort::verifyParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d",
+                       aSession, aParameters, num_elements));
+    return PVMFErrNotSupported;
+}
+
+
+bool
+PVMFVideoParserPort::pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort,
+        const char* aFormatValType)
+{
+    /*
+     * Create PvmiKvp for capability settings
+     */
+    if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        OsclMemAllocator alloc;
+        PvmiKvp kvp;
+        kvp.key = NULL;
+        kvp.length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+        kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
+        if (kvp.key == NULL)
+        {
+            return false;
+        }
+        oscl_strncpy(kvp.key, aFormatValType, kvp.length);
+        if (iFormatSpecificInfoLen == 0)
+        {
+            kvp.value.key_specific_value = 0;
+            kvp.capacity = 0;
+        }
+        else
+        {
+            kvp.value.key_specific_value = (OsclAny*)iFormatSpecificInfo;
+            kvp.capacity = iFormatSpecificInfoLen;
+        }
+
+        PvmiKvp* retKvp = NULL; // for return value
+        int32 err;
+        OSCL_TRY(err, aPort->setParametersSync(NULL, &kvp, 1, retKvp););
+        /* ignore the error for now */
+        alloc.deallocate((OsclAny*)(kvp.key));
+        return true;
+    }
+    return false;
+}
+
+bool
+PVMFVideoParserPort::pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType,
+        PvmiKvp*& aKvp)
+{
+    /*
+     * Create PvmiKvp for capability settings
+     */
+
+    if (pv_mime_strcmp(aFormatValType, PVMF_FORMAT_SPECIFIC_INFO_KEY) == 0)
+    {
+        OsclMemAllocator alloc;
+        aKvp->key = NULL;
+        aKvp->length = oscl_strlen(aFormatValType) + 1; // +1 for \0
+        aKvp->key = (PvmiKeyType)alloc.ALLOCATE(aKvp->length);
+        if (aKvp->key == NULL)
+        {
+            return false;
+        }
+        oscl_strncpy(aKvp->key, aFormatValType, aKvp->length);
+        if (iFormatSpecificInfoLen == 0)
+        {
+            aKvp->value.key_specific_value = 0;
+            aKvp->capacity = 0;
+        }
+        else
+        {
+            aKvp->value.key_specific_value = (OsclAny*)iFormatSpecificInfo;
+            aKvp->capacity = iFormatSpecificInfoLen;
+        }
+        return true;
+    }
+    return false;
+}
diff --git a/nodes/pvwavffparsernode/Android.mk b/nodes/pvwavffparsernode/Android.mk
index dba63c8..2a9fd02 100644
--- a/nodes/pvwavffparsernode/Android.mk
+++ b/nodes/pvwavffparsernode/Android.mk
@@ -3,27 +3,29 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_wavffparser_node.cpp \
-	src/pvmf_wavffparser_port.cpp \
-	src/pvmf_wavffparser_factory.cpp
-
+ 	src/pvmf_wavffparser_port.cpp \
+ 	src/pvmf_wavffparser_factory.cpp
 
 
 LOCAL_MODULE := libpvwavffparsernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/pvwavffparsernode/include \
-	$(PV_TOP)//nodes/pvwavffparsernode/src \
-	$(PV_TOP)//nodes/pvwavffparsernode/../common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/pvwavffparsernode/src \
+ 	$(PV_TOP)/nodes/pvwavffparsernode/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_wavffparser_factory.h \
-	include/pvmf_wavffparser_defs.h
+ 	include/pvmf_wavffparser_defs.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/pvwavffparsernode/build/make/local.mk b/nodes/pvwavffparsernode/build/make/local.mk
new file mode 100644
index 0000000..9f4f5b5
--- /dev/null
+++ b/nodes/pvwavffparsernode/build/make/local.mk
@@ -0,0 +1,20 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvwavffparsernode
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_wavffparser_node.cpp pvmf_wavffparser_port.cpp pvmf_wavffparser_factory.cpp
+
+HDRS := pvmf_wavffparser_factory.h pvmf_wavffparser_defs.h 
+
+
+
+include $(MK)/library.mk
diff --git a/nodes/pvwavffparsernode/build/make/makefile b/nodes/pvwavffparsernode/build/make/makefile
deleted file mode 100755
index ba36bce..0000000
--- a/nodes/pvwavffparsernode/build/make/makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvwavffparsernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../common/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_wavffparser_node.cpp pvmf_wavffparser_port.cpp pvmf_wavffparser_factory.cpp
-
-HDRS =  pvmf_wavffparser_factory.h pvmf_wavffparser_defs.h 
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/nodes/pvwavffparsernode/include/pvmf_wavffparser_defs.h b/nodes/pvwavffparsernode/include/pvmf_wavffparser_defs.h
index ac27719..d9bd5b3 100644
--- a/nodes/pvwavffparsernode/include/pvmf_wavffparser_defs.h
+++ b/nodes/pvwavffparsernode/include/pvmf_wavffparser_defs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvwavffparsernode/include/pvmf_wavffparser_factory.h b/nodes/pvwavffparsernode/include/pvmf_wavffparser_factory.h
index 4649bf1..7b908cd 100644
--- a/nodes/pvwavffparsernode/include/pvmf_wavffparser_factory.h
+++ b/nodes/pvwavffparsernode/include/pvmf_wavffparser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvwavffparsernode/src/pvmf_wavffparser_factory.cpp b/nodes/pvwavffparsernode/src/pvmf_wavffparser_factory.cpp
index 88230a4..552ef6a 100644
--- a/nodes/pvwavffparsernode/src/pvmf_wavffparser_factory.cpp
+++ b/nodes/pvwavffparsernode/src/pvmf_wavffparser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.cpp b/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.cpp
index 2787c10..8cb0c64 100644
--- a/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.cpp
+++ b/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,11 +50,11 @@
 
 PVMFWAVFFParserNode::PVMFWAVFFParserNode(int32 aPriority) :
         OsclTimerObject(aPriority, "PVMFWAVFFParserNode"),
+        iStreamID(0),
         iOutPort(NULL),
         iLogger(NULL),
         iCmdRespPort(NULL),
         iWAVParser(NULL),
-        iStreamID(0),
         iExtensionRefCount(0)
 {
     int32 err;
@@ -73,9 +73,9 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = true;
              iCapability.iMaxNumberOfPorts = 2;//no maximum
-             iCapability.iInputFormatCapability.push_back(PVMF_WAVFF);
-             iCapability.iOutputFormatCapability.push_back(PVMF_PCM8);
-             iCapability.iOutputFormatCapability.push_back(PVMF_PCM16);
+             iCapability.iInputFormatCapability.push_back(PVMF_MIME_WAVFF);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_PCM8);
+             iCapability.iOutputFormatCapability.push_back(PVMF_MIME_PCM16);
             );
 
     if (err != OsclErrNone)
@@ -96,8 +96,6 @@
 PVMFWAVFFParserNode::~PVMFWAVFFParserNode()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFWAVFFParserNode::~PVMFWAVFFParserNode() called"));
-    ThreadLogoff();
-
     //Cleanup commands
     //The command queues are self-deleting, but we want to
     //notify the observer of unprocessed commands.
@@ -459,7 +457,7 @@
             if (status != PVMFErrBusy
                     && activity.iPort->OutgoingMsgQueueSize() > 0)
             {
-                OSCL_TRY(err, iPortActivityQueue.push_back(activity););
+                err = PushBackPortActivity(activity);
             }
             break;
 
@@ -548,8 +546,7 @@
                 {
                     if (iSelectedTrackList[i].iState == PVWAVFFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK)
                     {
-                        // will return true here and will send EOS in next AO call.
-                        ret_status = true;
+                        ReportInfoEvent(PVMFInfoEndOfData);
                     }
                     break;
                 }
@@ -619,10 +616,11 @@
 bool PVMFWAVFFParserNode::RetrieveTrackData(PVWAVFFNodeTrackPortInfo& aTrackPortInfo)
 {
     // Create a data buffer from pool
-    int32 errcode = 0;
+    int32 errcode = OsclErrNone;
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
     OSCL_TRY(errcode, mediaDataImplOut = aTrackPortInfo.iMediaDataImplAlloc->allocate(trackdata_bufsize));
-    if (errcode != 0)
+
+    if (errcode != OsclErrNone)
     {
         if (errcode == OsclErrNoResources)
         {
@@ -652,13 +650,22 @@
         }
     }
 
+
     // Now create a PVMF media data from pool
-    errcode = 0;
+    errcode = OsclErrNoResources;
     PVMFSharedMediaDataPtr mediadataout;
-    OSCL_TRY(errcode, mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool));
-    OSCL_FIRST_CATCH_ANY(errcode,
-                         aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(aTrackPortInfo);		// Enable flag to receive event when next deallocate() is called on pool
-                         return false);
+    mediadataout = PVMFMediaData::createMediaData(mediaDataImplOut, aTrackPortInfo.iMediaDataMemPool);
+
+    if (mediadataout.GetRep() != NULL)
+    {
+        errcode = OsclErrNone;
+    }
+
+    else
+    {
+        aTrackPortInfo.iMediaDataMemPool->notifyfreechunkavailable(aTrackPortInfo);		// Enable flag to receive event when next deallocate() is called on pool
+        return false;
+    }
 
     // Retrieve memory fragment to write to
     OsclRefCounterMemFrag refCtrMemFragOut;
@@ -669,44 +676,60 @@
     uint32 samplesread = 0;
     PVWavParserReturnCode retcode = iWAVParser->GetPCMData((uint8*)memFragOut.ptr, refCtrMemFragOut.getCapacity(), trackdata_num_samples, samplesread);
 
-    if (retcode == PVWAVPARSER_OK)
+    if ((retcode == PVWAVPARSER_OK) || (retcode == PVWAVPARSER_END_OF_FILE))
     {
         if (samplesread == 0)
         {
             // Only partial sample so return and set active to call HandleTrackState() again
-            RunIfNotReady();
-            return false;
+            if (retcode != PVWAVPARSER_END_OF_FILE)
+            {
+                RunIfNotReady();
+                return false;
+            }
         }
-        memFragOut.len = samplesread * wavinfo.BytesPerSample * wavinfo.NumChannels;
-        mediadataout->setMediaFragFilledLen(0, memFragOut.len);
+        else
+        {
+            memFragOut.len = samplesread * wavinfo.BytesPerSample * wavinfo.NumChannels;
+            mediadataout->setMediaFragFilledLen(0, memFragOut.len);
 
-        // set the timestamp
-        uint32 timestamp = aTrackPortInfo.iClockConverter->get_converted_ts(COMMON_PLAYBACK_CLOCK_TIMESCALE);
+            // set the timestamp
+            uint32 timestamp = aTrackPortInfo.iClockConverter->get_converted_ts(COMMON_PLAYBACK_CLOCK_TIMESCALE);
 
-        // set the timestamp
-        mediadataout->setTimestamp(timestamp);
+            // set the timestamp
+            mediadataout->setTimestamp(timestamp);
 
-        // set the sequence number
-        mediadataout->setSeqNum(aTrackPortInfo.iSeqNum++);
+            // set the sequence number
+            mediadataout->setSeqNum(aTrackPortInfo.iSeqNum++);
 
-        // set the stream id
-        mediadataout->setStreamID(iStreamID);
+            // set the stream id
+            mediadataout->setStreamID(iStreamID);
 
-        aTrackPortInfo.iMediaData = mediadataout;
+            aTrackPortInfo.iMediaData = mediadataout;
 
-        // increment the clock based on this sample duration
-        timestamp = aTrackPortInfo.iClockConverter->get_current_timestamp();
-        timestamp += samplesread;
-        aTrackPortInfo.iClockConverter->update_clock(timestamp);
-    }
-    else if (retcode == PVWAVPARSER_END_OF_FILE)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFWAVFFParserNode::RetrieveTrackData() WAV Parser END_OF_FILE"));
+            // increment the clock based on this sample duration
+            timestamp = aTrackPortInfo.iClockConverter->get_current_timestamp();
+            timestamp += samplesread;
+            aTrackPortInfo.iClockConverter->update_clock(timestamp);
+        }
+        if (retcode == PVWAVPARSER_END_OF_FILE)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFWAVFFParserNode::RetrieveTrackData() WAV Parser END_OF_FILE"));
 
-        // Set track state for sending EOS message
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFWAVFFParserNode::RetrieveTrackData Set Track State to send EOS"));
-        aTrackPortInfo.iState = PVWAVFFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
-        return false;
+            if (SendEndOfTrackCommand(aTrackPortInfo))
+            {
+                // EOS message sent so change state
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFWAVFFParserNode::RetrieveTrackData() Sending EOS message succeeded"));
+                aTrackPortInfo.iState = PVWAVFFNodeTrackPortInfo::TRACKSTATE_SEND_ENDOFTRACK;
+                return false;
+            }
+            else
+            {
+                // EOS message could not be queued so keep in same state and try again later
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_NOTICE, (0, "PVMFWAVFFParserNode::RetrieveTrackData() Sending EOS message failed"));
+                return true;
+            }
+        }
+
     }
     else
     {
@@ -1128,9 +1151,10 @@
             {
                 // set the new parameters on the connected port
 
-                PvmiCapabilityAndConfig* config = NULL;
-                iOutPort->iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                        (OsclAny*&)config);
+                OsclAny* temp = NULL;
+                iOutPort->iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+                PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
                 if (!config)
                 {
                     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
@@ -1360,16 +1384,12 @@
 
 void PVMFWAVFFParserNode::DoReset(PVMFWAVFFNodeCommand& aCmd)
 {
-    PVMFStatus status = PVMFSuccess;
-
     ReleaseAllPorts();
-
     //discard any port activity events
     iPortActivityQueue.clear();
     CleanupFileSource();
     SetState(EPVMFNodeIdle);
-
-    CommandComplete(iInputCommands, aCmd, status);
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess);
 
 }
 
@@ -1442,6 +1462,11 @@
     iSelectedTrackList[0].iTrackDataMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (PVWAVFF_MEDIADATA_POOLNUM));
     iSelectedTrackList[0].iMediaDataImplAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iSelectedTrackList[0].iTrackDataMemoryPool));
     iSelectedTrackList[0].iMediaDataMemPool = OSCL_NEW(PVMFMemPoolFixedChunkAllocator, ("WavFFPar", PVWAVFF_MEDIADATA_POOLNUM, PVWAVFF_MEDIADATA_CHUNKSIZE));
+    if (iSelectedTrackList[0].iMediaDataMemPool)
+    {
+        iSelectedTrackList[0].iMediaDataMemPool->enablenullpointerreturn();
+    }
+
 }
 
 
@@ -1524,7 +1549,6 @@
                                  CommandComplete(iInputCommands, aCmd, PVMFFailure);
                                  return;);
 
-
         }
 
         iPortActivityQueue.reserve(PVMF_WAVFFPARSER_NODE_COMMAND_VECTOR_RESERVE);
@@ -1767,7 +1791,7 @@
 
     OSCL_UNUSED_ARG(aSourceData);
 
-    if (aSourceFormat != PVMF_WAVFF)
+    if (aSourceFormat != PVMF_MIME_WAVFF)
     {
         return PVMFFailure;
     }
@@ -1776,13 +1800,13 @@
     return PVMFSuccess;
 }
 
-PVMFStatus PVMFWAVFFParserNode::SetClientPlayBackClock(OsclClock* aClientClock)
+PVMFStatus PVMFWAVFFParserNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
 }
 
-PVMFStatus PVMFWAVFFParserNode::SetEstimatedServerClock(OsclClock* aClientClock)
+PVMFStatus PVMFWAVFFParserNode::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFSuccess;
@@ -1801,7 +1825,7 @@
 
     uint32 duration_sec = wavinfo.NumSamples / wavinfo.SampleRate;
     uint32 duration_msec = wavinfo.NumSamples % wavinfo.SampleRate;
-    uint32 duration = (duration_msec * 1000) / wavinfo.SampleRate + duration_sec * 1000 ;
+    uint32 duration = (duration_msec * 1000) / wavinfo.NumSamples + duration_sec * 1000 ;
 
     aInfo.setDurationValue(duration);
     // Current version of WAV parser is limited to 1 channel
@@ -1915,7 +1939,8 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFWAVParserNode::QueryDataSourcePosition: aTargetNPT=%d, aSeekToSyncPoint=%d, aContext=0x%x",
-                     aTargetNPT, aSeekToSyncPoint, aContext));
+                     aTargetNPT, aSeekToSyncPoint,  aContext));
+    OSCL_UNUSED_ARG(aSeekPointAfterTargetNPT);
 
     PVMFWAVFFNodeCommand cmd;
     // Construct not changed, aSeekPointBeforeTargetNPThas replace aAcutalNPT
@@ -1924,7 +1949,7 @@
 }
 
 
-PVMFCommandId PVMFWAVFFParserNode::SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, OsclTimebase* aTimebase, OsclAny* aContext)
+PVMFCommandId PVMFWAVFFParserNode::SetDataSourceRate(PVMFSessionId aSessionId, int32 aRate, PVMFTimebase* aTimebase, OsclAny* aContext)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFWAVFFParserNode::SetDataSourceRate() called"));
 
@@ -1944,12 +1969,6 @@
     uint32 streamID = 0;
     aCmd.PVMFWAVFFNodeCommand::Parse(targetNPT, actualNPT, actualMediaDataTS, jumpToIFrame, streamID);
 
-    bool retVal = false;
-    // duplicate bos has been received
-    // dont perform reposition at source node
-    if (iStreamID == streamID)
-        retVal = true;
-
     uint32 i = 0;
     for (i = 0; i < iSelectedTrackList.size(); ++i)
     {
@@ -1958,25 +1977,13 @@
     //save the stream id for next media segment
     iStreamID = streamID;
 
-    if (retVal)
-    {
-        for (i = 0; i < iSelectedTrackList.size(); ++i)
-        {
-            iSelectedTrackList[i].iState = PVWAVFFNodeTrackPortInfo::TRACKSTATE_TRANSMITTING_SENDDATA;
-        }
-
-        RunIfNotReady();
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFWAVFFParserNode::DoSetDataSourcePosition() Out"));
-        return;
-    }
 
     *actualMediaDataTS = iSelectedTrackList[0].iClockConverter->get_converted_ts(COMMON_PLAYBACK_CLOCK_TIMESCALE);
 
     // see if targetNPT is greater than or equal to clip duration.
     uint32 duration_sec = wavinfo.NumSamples / wavinfo.SampleRate;
     uint32 duration_msec = wavinfo.NumSamples % wavinfo.SampleRate;
-    uint32 duration = (duration_msec * 1000) / wavinfo.SampleRate + duration_sec * 1000 ;
+    uint32 duration = (duration_msec * 1000) / wavinfo.NumSamples + duration_sec * 1000 ;
     uint32 tempTargetNPT = targetNPT;
     if (tempTargetNPT >= duration)
     {
@@ -2001,6 +2008,11 @@
         uint32 position_sec = target_sample / wavinfo.SampleRate;
         uint32 position_msec = target_sample % wavinfo.SampleRate;
         *actualNPT = (position_msec * 1000) / wavinfo.NumSamples + position_sec * 1000;
+        if (tempTargetNPT >= duration)
+        {
+            // need to send duration in *actualNPT
+            *actualNPT = duration;
+        }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFWAVFFParserNode::DoSetDataSourcePosition() targetNPT=%d, target sample=%d, actualNPT=%d, actualMediaTS=%d", targetNPT, target_sample, *actualNPT, *actualMediaDataTS));
@@ -2096,7 +2108,7 @@
 
     // Retrieve the new rate
     int32 rate;
-    OsclTimebase* timebase = NULL;
+    PVMFTimebase* timebase = NULL;
     PVMFStatus cmdstatus = PVMFSuccess;
     aCmd.PVMFWAVFFNodeCommand::Parse(rate, timebase);
 
@@ -2421,7 +2433,7 @@
     // Copy the requested keys
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
+
     for (uint32 lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
     {
         if (query_key == NULL)
@@ -2431,11 +2443,11 @@
             if (num_entries > starting_index)
             {
                 // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFWAVFFParserNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
+                PVMFStatus status = PushBackMetadataKeys(keylistptr, lcv);
+                if (PVMFErrNoMemory == status)
+                {
+                    return status;
+                }
                 num_added++;
             }
         }
@@ -2449,11 +2461,11 @@
                 if (num_entries > starting_index)
                 {
                     // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFWAVFFParserNode::DoGetNodeMetadataKey() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    PVMFStatus status = PushBackMetadataKeys(keylistptr, lcv);
+                    if (PVMFErrNoMemory == status)
+                    {
+                        return status;
+                    }
                     num_added++;
                 }
             }
@@ -2465,11 +2477,11 @@
             break;
         }
     }
-
     return PVMFSuccess;
 }
 
 
+
 PVMFStatus PVMFWAVFFParserNode::DoGetNodeMetadataValue(PVMFWAVFFNodeCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFWAVFFParserNode::DoGetMetadataValue() In"));
@@ -2525,11 +2537,7 @@
                 KeyLen += oscl_strlen(PVWAVMETADATA_TIMESCALE1000) + 1; // for "timescale=1000" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
                 if (leavecode == 0)
                 {
                     // Copy the key string
@@ -2544,7 +2552,7 @@
                     {
                         uint32 duration_sec = wavinfo.NumSamples / wavinfo.SampleRate;
                         uint32 duration_msec = wavinfo.NumSamples % wavinfo.SampleRate;
-                        uint32 duration = (duration_msec * 1000) / wavinfo.SampleRate + duration_sec * 1000 ;
+                        uint32 duration = (duration_msec * 1000) / wavinfo.NumSamples + duration_sec * 1000 ;
                         KeyVal.value.uint32_value = duration;
                     }
                     // Set the length and capacity
@@ -2573,11 +2581,7 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
                 if (leavecode == 0)
                 {
                     // Copy the key string
@@ -2616,10 +2620,7 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
 
                 if (leavecode == 0)
                 {
@@ -2661,11 +2662,7 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
                 if (leavecode == 0)
                 {
                     // Copy the key string
@@ -2706,11 +2703,7 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
-
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
                 if (leavecode == 0)
                 {
                     // Copy the key string
@@ -2751,10 +2744,7 @@
                 KeyLen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
 
                 // Allocate memory for the string
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                        );
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
 
                 if (leavecode == 0)
                 {
@@ -2818,11 +2808,11 @@
                 }
 
                 // Allocate memory for the strings
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         KeyVal.key = OSCL_ARRAY_NEW(char, KeyLen);
-                         KeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-                        );
+                leavecode = CreateNewArray(KeyVal.key, KeyLen);
+                if (0 == leavecode)
+                {
+                    leavecode = CreateNewArray(KeyVal.value.pChar_value, valuelen);
+                }
 
                 if (leavecode == 0)
                 {
@@ -2878,8 +2868,7 @@
 
         if (KeyVal.key != NULL)
         {
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
+            leavecode = PushBackKeyVal(valuelistptr, KeyVal);
             if (leavecode != 0)
             {
                 switch (GetValTypeFromKeyString(KeyVal.key))
@@ -3033,5 +3022,34 @@
 }
 
 
+int32 PVMFWAVFFParserNode::PushBackPortActivity(PVMFPortActivity &aActivity)
+{
+    int32 err = OsclErrNone;
+    OSCL_TRY(err, iPortActivityQueue.push_back(aActivity););
+    return err;
+}
 
+int32 PVMFWAVFFParserNode::CreateNewArray(char*& aPtr, int32 aLen)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode,
+             aPtr = OSCL_ARRAY_NEW(char, aLen););
+    return leavecode;
+}
+
+int32 PVMFWAVFFParserNode::PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, (*aValueListPtr).push_back(aKeyVal));
+    return leavecode;
+}
+
+PVMFStatus PVMFWAVFFParserNode::PushBackMetadataKeys(PVMFMetadataList *&aKeyListPtr, uint32 aLcv)
+{
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, aKeyListPtr->push_back(iAvailableMetadataKeys[aLcv]));
+    OSCL_FIRST_CATCH_ANY(leavecode,	PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFRMFFParserNode::DoGetMetadataKeys() Memory allocation failure when copying metadata key"));return PVMFErrNoMemory);
+
+    return PVMFSuccess;
+}
 
diff --git a/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.h b/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.h
index cac276e..830051b 100644
--- a/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.h
+++ b/nodes/pvwavffparsernode/src/pvmf_wavffparser_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -119,7 +119,8 @@
             iSendBOS = false;
         }
 
-        PVWAVFFNodeTrackPortInfo(const PVWAVFFNodeTrackPortInfo& aSrc)
+        PVWAVFFNodeTrackPortInfo(const PVWAVFFNodeTrackPortInfo& aSrc):
+                OsclMemPoolFixedChunkAllocatorObserver()
         {
             iTrackId = aSrc.iTrackId;
             iPort = aSrc.iPort;
@@ -279,7 +280,7 @@
         }
 
         // Constructor and parser for SetDataSourceRate
-        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, OsclTimebase* aTimebase, const OsclAny* aContext)
+        void Construct(PVMFSessionId s, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny* aContext)
         {
             PVMFWAVFFNodeCommandBase::Construct(s, cmd, aContext);
             iParam1 = (OsclAny*)aRate;
@@ -288,10 +289,10 @@
             iParam4 = NULL;
             iParam5 = NULL;
         }
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
         {
             aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
+            aTimebase = (PVMFTimebase*)iParam2;
         }
 
         //need to overlaod the base Destroy routine to cleanup metadata key.
@@ -385,8 +386,8 @@
         void removeRef();
         bool queryInterface(const PVUuid& uuid, PVInterface *& iface);
         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
-        PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         //From PVMFTrackSelectionExtensionInterface
         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
@@ -422,7 +423,7 @@
                                               PVMFTimestamp& aSeekPointBeforeTargetNPT, PVMFTimestamp& aSeekPointAfterTargetNPT,
                                               OsclAny* aContext = NULL, bool aSeekToSyncPoint = true);
 
-        PVMFCommandId SetDataSourceRate(PVMFSessionId aSession, int32 aRate, OsclTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
+        PVMFCommandId SetDataSourceRate(PVMFSessionId aSession, int32 aRate, PVMFTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
 
 
     private:
@@ -495,6 +496,10 @@
         void ResetAllTracks();
         bool ReleaseAllPorts();
         void CleanupFileSource();
+        int32 PushBackPortActivity(PVMFPortActivity &aActivity);
+        int32 CreateNewArray(char*& aPtr, int32 aLen);
+        int32 PushBackKeyVal(Oscl_Vector<PvmiKvp, OsclMemAllocator>*& aValueListPtr, PvmiKvp &aKeyVal);
+        PVMFStatus PushBackMetadataKeys(PVMFMetadataList *&aKeyListPtr, uint32 aLcv);
 
     private: // private member variables
 
diff --git a/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.cpp b/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.cpp
index e8722aa..2481e60 100644
--- a/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.cpp
+++ b/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,19 +44,23 @@
 
 bool PVMFWAVFFParserOutPort::IsFormatSupported(PVMFFormatType aFmt)
 {
-    return ((aFmt == PVMF_PCM ||
-             aFmt == PVMF_PCM8 ||
-             aFmt == PVMF_PCM16 ||
-             aFmt == PVMF_PCM16_BE ||
-             aFmt == PVMF_PCM_ULAW ||
-             aFmt == PVMF_PCM_ALAW));
+    if ((aFmt == PVMF_MIME_PCM ||
+            aFmt == PVMF_MIME_PCM8 ||
+            aFmt == PVMF_MIME_PCM16 ||
+            aFmt == PVMF_MIME_PCM16_BE ||
+            aFmt == PVMF_MIME_ULAW ||
+            aFmt == PVMF_MIME_ALAW))
+    {
+        return true;
+    }
+    return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PVMFWAVFFParserOutPort::FormatUpdated()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFWAVFFParserOutPort::FormatUpdated %d", iFormat));
+                    , (0, "PVMFWAVFFParserOutPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
 }
 
 
@@ -68,7 +72,7 @@
 {
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_STACK_TRACE
-                    , (0, "PVMFWAVFFParserOutPort::FormatUpdated %d", iFormat));
+                    , (0, "PVMFWAVFFParserOutPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
 
     if (!aPort)
     {
@@ -82,8 +86,10 @@
         return PVMFFailure;
     }
 
-    PvmiCapabilityAndConfig* config = NULL;
-    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, (OsclAny*&)config);
+    OsclAny* temp = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
+
     if (!config)
     {
         LOG_ERR((0, "PVMFWAVFFParserOutPort::Connect: Error - Peer port does not support capability interface"));
diff --git a/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.h b/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.h
index da044f2..2d6aadc 100644
--- a/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.h
+++ b/nodes/pvwavffparsernode/src/pvmf_wavffparser_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/pvwavffparsernode/src/wav_parsernode_tunables.h b/nodes/pvwavffparsernode/src/wav_parsernode_tunables.h
index 30bc51d..6d49f79 100644
--- a/nodes/pvwavffparsernode/src/wav_parsernode_tunables.h
+++ b/nodes/pvwavffparsernode/src/wav_parsernode_tunables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/common/include/pvmf_sm_tunables.h b/nodes/streaming/common/include/pvmf_sm_tunables.h
index 76101ff..a5d3627 100644
--- a/nodes/streaming/common/include/pvmf_sm_tunables.h
+++ b/nodes/streaming/common/include/pvmf_sm_tunables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@
  */
 #define PVMF_JITTER_BUFFER_NODE_MEDIA_MSG_SIZE 128
 
-#define DEFAULT_MAX_INACTIVITY_DURATION_IN_MS 15000
+#define DEFAULT_MAX_INACTIVITY_DURATION_IN_MS 70000
 
 #define DEFAULT_NUM_FRAGMENTS_IN_MEDIA_MSG 1
 
@@ -66,6 +66,7 @@
 #else
 //This should be the same size as DEFAULT_RTPPACKETSOURCE_TCP_BUFFER_SIZE.
 #define MAX_SOCKET_BUFFER_SIZE        (16*1024)
+#define MIN_SOCKET_BUFFER_SIZE        (2*1024)
 #endif
 #define MAX_FEEDBACK_SOCKET_BUFFER_SIZE   (1500)
 
@@ -107,6 +108,9 @@
 #define DEFAULT_RTCP_MEM_POOL_BUFFERS 4
 #define RTCP_RAND_SEED 666
 
+#define MIN_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC	1
+#define MAX_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC	300
+
 // RTCP INTERVAL related
 #define DEFAULT_RTCP_INTERVAL_USEC 1000000
 #define DEFAULT_RTCP_INTERVAL_SEC  1
@@ -118,7 +122,9 @@
 #define MIN_JITTER_BUFFER_DURATION_IN_MS     1000
 
 #define DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS 500
-#define DEFAULT_PLAY_BACK_THRESHOLD_IN_MS    100
+#define DEFAULT_PLAY_BACK_THRESHOLD_IN_MS    250
+#define DEFAULT_ESTIMATED_SERVER_KEEPAHEAD_FOR_OOO_SYNC_IN_MS	500
+
 /* Status event happends at 5 Hz (200 msec) intervals */
 #define PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_FREQUENCY 5
 #define PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_CYCLES 1
@@ -130,7 +136,7 @@
 #define PVMF_JB_NO_RESIZE_ALLOC_NUM_CHUNKS_FB  16
 #define PVMF_JB_NO_RESIZE_ALLOC_CHUNK_SIZE (MAX_SOCKET_BUFFER_SIZE + 128)
 
-#define PVMF_EOS_TIMER_GAURD_BAND_IN_MS 1000
+#define PVMF_EOS_TIMER_GAURD_BAND_IN_MS 200
 
 /* Firewall packet related */
 #define PVMF_JITTER_BUFFER_NODE_DEFAULT_FIREWALL_PKT_ATTEMPTS 3
@@ -142,10 +148,15 @@
 
 #define JITTERBUFFERNODE_MAX_RUNL_TIME_IN_MS 25
 
+#define PVMF_SM_MSHTTP_NODE_DEFAULT_JITTER_BUFFER_SIZE (2*1024*1024)
 /* Media layer node related */
 #define MEDIALAYERNODE_MAXNUM_MEDIA_DATA     10
 #define MEDIALAYERNODE_MAX_RUNL_TIME_IN_MS   25
 
+/* Jitter buffer overflow related */
+#define CONSECUTIVE_LOW_BUFFER_COUNT_THRESHOLD 100
+#define MIN_PERCENT_OCCUPANCY_THRESHOLD 10
+#define JITTER_BUFFER_DURATION_MULTIPLIER_THRESHOLD 1.5
 #endif
 
 
diff --git a/nodes/streaming/common/include/pvmf_streaming_asf_interfaces.h b/nodes/streaming/common/include/pvmf_streaming_asf_interfaces.h
index 57f2122..43b3c52 100644
--- a/nodes/streaming/common/include/pvmf_streaming_asf_interfaces.h
+++ b/nodes/streaming/common/include/pvmf_streaming_asf_interfaces.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/common/include/pvmf_streaming_buffer_allocators.h b/nodes/streaming/common/include/pvmf_streaming_buffer_allocators.h
index 92695fb..a068f5b 100644
--- a/nodes/streaming/common/include/pvmf_streaming_buffer_allocators.h
+++ b/nodes/streaming/common/include/pvmf_streaming_buffer_allocators.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,11 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*
- *
- *
- *
- ***************************************************************************/
 /**
  * @file pvmf_streaming_buffer_allocators.h
  */
@@ -525,7 +520,10 @@
                 {
                     OSCL_ASSERT(phead != NULL);
                     ReassemblyBlock* p = phead;
-                    phead = p->pnext;
+                    if (p)
+                    {
+                        phead = p->pnext;
+                    }
                     OSCL_DELETE(p);
                 }
 /////// START: clean the head
@@ -792,6 +790,9 @@
                                   const OsclAny* aDeallocPtr,
                                   bool oEnableOutofOrderCheck = true)
         {
+            OSCL_ASSERT(aPCContainer);
+            if (!aPCContainer)
+                return PVMF_RESIZE_ALLOC_NO_MEMORY;
             uint32 seqNum = 0;
             uint32 blkSize = 0;
             uint8* p = ((uint8*)(aDeallocPtr) - PVMF_RESIZE_ALLOC_OVERHEAD);
@@ -808,10 +809,10 @@
                     {//just allocated, now free, so we pretend we didn't allocate this one to increase mem efficiency
                         if (aPCContainer->iAllocationPtr != p + blkSize)
                         {
-                            PVMF_SOCKALLOC_LOGERROR((0, "SM ATTN seqNum %d blkSize %d iAlloc 0x%x p 0x%x Ln %d"
-                                                     , seqNum, blkSize, aPCContainer->iAllocationPtr, p, __LINE__));
-                            PVMF_SOCKALLOC_LOGERROR((0, "SM ATTN start 0x%x end 0x%x lastD 0x%x Ln %d"
-                                                     , aPCContainer->iParentChunkStart, aPCContainer->iParentChunkEnd, aPCContainer->iEndOfLastDeallocatedBlock, __LINE__));
+                            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "SM ATTN seqNum %d blkSize %d iAlloc 0x%x p 0x%x Ln %d"
+                                                                    , seqNum, blkSize, aPCContainer->iAllocationPtr, p, __LINE__));
+                            PVMF_SOCKALLOC_LOG_ALLOC_RESIZE_DEALLOC((0, "SM ATTN start 0x%x end 0x%x lastD 0x%x Ln %d"
+                                                                    , aPCContainer->iParentChunkStart, aPCContainer->iParentChunkEnd, aPCContainer->iEndOfLastDeallocatedBlock, __LINE__));
                         }
 
                         iJJDataDbgSize -= (blkSize - PVMF_RESIZE_ALLOC_OVERHEAD);
@@ -820,7 +821,6 @@
 
                         iNumOutStandingBuffers--;
                         iSeqCount--;
-                        PVMF_SOCKALLOC_LOGERROR((0, "JJMEM RECY ptr 0x%x size %d new %d new2 %d Ln %d", p, blkSize, iJJDataSize, iJJDataDbgSize, __LINE__));
                         return (PVMF_RESIZE_ALLOC_SUCCESS);
                     }
 
@@ -932,6 +932,7 @@
             {
                 PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - INVALID PTR!!! Name=%s", iName.get_cstr()));
                 OSCL_LEAVE(OsclErrArgument);
+                return;
             }
             /* Deallocate the current ptr */
             PVMF_RESIZE_ALLOC_ERROR_CODE errCode = DeallocateFromParentChunk(parentChunkContainer, p);
@@ -960,7 +961,6 @@
 
                     if (NULL != deleteList)
                     {
-                        PVMF_SOCKALLOC_LOGERROR((0, "JJMEM RECY start new %d new2 %d Ln %d", iJJDataSize, iJJDataDbgSize, __LINE__));
                         for (int32 i = (*deleteList).size() - 1; i >= 0; i--)
                         {
                             uint8* p = (uint8*)((*deleteList)[i].ptr);
@@ -970,6 +970,7 @@
                             {
                                 PVMF_SOCKALLOC_LOGERROR((0, "PVMFSMSharedBufferAllocWithReSize::deallocate - INVALID PTR!!! Name=%s Ln %d", iName.get_cstr(), __LINE__));
                                 OSCL_LEAVE(OsclErrArgument);
+                                return;
                             }
                             uint32 seqNum = 0;
                             uint32 blkSize = 0;
@@ -1000,7 +1001,6 @@
                         }
 
                         iOutOfOrderBlocks.PruneHead(deleteList);
-                        PVMF_SOCKALLOC_LOGERROR((0, "JJMEM RECY done new %d new2 %d Ln %d", iJJDataSize, iJJDataDbgSize, __LINE__));
                     }
                 }
             }
@@ -1031,7 +1031,7 @@
             if (iSeqCount > seqNum + 1)
             {
                 //Resize can ONLY be applied to the buffer just allocated.
-                PVMF_SOCKALLOC_LOGERROR((0, "JJMEM Resize ERROR seq %d iSeqCount %d iJJDataSize %d", seqNum, iSeqCount, iJJDataSize));
+                PVMF_SOCKALLOC_LOGERROR((0, "Resize ERROR seq %d iSeqCount %d iJJDataSize %d", seqNum, iSeqCount, iJJDataSize));
                 return (PVMF_RESIZE_ALLOC_MEMORY_CORRUPT);
             }
             /* reset the block size */
@@ -1179,7 +1179,7 @@
                     truespace += maxSize;
                 }
             }
-            PVMF_SOCKALLOC_LOGERROR((0, "SM alloc space new1 %d new2 %d kspace %d Ln %d", iJJDataSize, iJJDataDbgSize, truespace, __LINE__));
+            PVMF_SOCKALLOC_LOG_AVAILABILITY((0, "SM alloc space new1 %d new2 %d kspace %d Ln %d", iJJDataSize, iJJDataDbgSize, truespace, __LINE__));
             return (truespace);
         }
 
diff --git a/nodes/streaming/common/include/pvmf_streaming_mem_config.h b/nodes/streaming/common/include/pvmf_streaming_mem_config.h
index 6c21fcb..f685a42 100644
--- a/nodes/streaming/common/include/pvmf_streaming_mem_config.h
+++ b/nodes/streaming/common/include/pvmf_streaming_mem_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/common/include/pvmf_streaming_real_interfaces.h b/nodes/streaming/common/include/pvmf_streaming_real_interfaces.h
index 1df6362..9db9d54 100644
--- a/nodes/streaming/common/include/pvmf_streaming_real_interfaces.h
+++ b/nodes/streaming/common/include/pvmf_streaming_real_interfaces.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/config/opencore/pvmf_sm_config.h b/nodes/streaming/config/opencore/pvmf_sm_config.h
deleted file mode 100644
index cf9eac4..0000000
--- a/nodes/streaming/config/opencore/pvmf_sm_config.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//     SM C O N F I G   ( O P E N  C O R E  C O N F I G   I N F O )
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-#ifndef PVMF_SM_CONFIG_H_INCLUDED
-#define PVMF_SM_CONFIG_H_INCLUDED
-
-
-
-
-#endif // PVMF_SM_CONFIG_H_INCLUDED
diff --git a/nodes/streaming/jitterbuffernode/Android.mk b/nodes/streaming/jitterbuffernode/Android.mk
index 0e0a69f..cb3191e 100644
--- a/nodes/streaming/jitterbuffernode/Android.mk
+++ b/nodes/streaming/jitterbuffernode/Android.mk
@@ -3,38 +3,42 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_jitter_buffer_extension_interface.cpp \
-	src/pvmf_jitter_buffer_port.cpp \
-	src/pvmf_jitter_buffer_impl.cpp \
-	src/pvmf_rtcp_timer.cpp \
-	src/pvmf_jitter_buffer_node.cpp \
-	src/pvmf_jb_inactivity_timer.cpp
-
+ 	src/pvmf_jitter_buffer_port.cpp \
+ 	src/pvmf_jitter_buffer_impl.cpp \
+ 	src/pvmf_rtcp_timer.cpp \
+ 	src/pvmf_jitter_buffer_node.cpp \
+ 	src/pvmf_jb_inactivity_timer.cpp
 
 
 LOCAL_MODULE := libpvjitterbuffernode
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/streaming/jitterbuffernode/include \
-	$(PV_TOP)//nodes/streaming/jitterbuffernode/src \
-	$(PV_TOP)//nodes/streaming/jitterbuffernode/../common/include \
-	$(PV_TOP)//nodes/streaming/jitterbuffernode/../config/opencore \
-	$(PV_TOP)//nodes/streaming/jitterbuffernode/../streamingmanager/include \
-	$(PV_TOP)//nodes/streaming/jitterbuffernode/../../../protocols/rtp/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/streaming/jitterbuffernode/src \
+ 	$(PV_TOP)/nodes/streaming/jitterbuffernode/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/plugins/mshttp/config \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/include \
+ 	$(PV_TOP)/protocols/rtp/src \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/config/3gpp \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_jitter_buffer_ext_interface.h \
-	include/pvmf_jitter_buffer_internal.h \
-	include/pvmf_jitter_buffer_port.h \
-	include/pvmf_jitter_buffer.h \
-	include/pvmf_jitter_buffer_node.h \
-	include/pvmf_rtcp_timer.h \
-	include/pvmf_jb_inactivity_timer.h
+ 	include/pvmf_jitter_buffer_internal.h \
+ 	include/pvmf_jitter_buffer_port.h \
+ 	include/pvmf_jitter_buffer.h \
+ 	include/pvmf_jitter_buffer_node.h \
+ 	include/pvmf_rtcp_timer.h \
+ 	include/pvmf_jb_inactivity_timer.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/streaming/jitterbuffernode/build/make/jb_rtsp.mk b/nodes/streaming/jitterbuffernode/build/make/jb_rtsp.mk
new file mode 100644
index 0000000..5e10b6a
--- /dev/null
+++ b/nodes/streaming/jitterbuffernode/build/make/jb_rtsp.mk
@@ -0,0 +1,3 @@
+
+XINCDIRS += -I ../../../streamingmanager/config/3gpp
+
diff --git a/nodes/streaming/jitterbuffernode/build/make/local.mk b/nodes/streaming/jitterbuffernode/build/make/local.mk
new file mode 100644
index 0000000..78506aa
--- /dev/null
+++ b/nodes/streaming/jitterbuffernode/build/make/local.mk
@@ -0,0 +1,36 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvjitterbuffernode
+
+
+
+
+XINCDIRS += ../../../common/include ../../../streamingmanager/plugins/mshttp/config ../../../streamingmanager/include ../../../../../protocols/rtp/src
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_jitter_buffer_extension_interface.cpp \
+	pvmf_jitter_buffer_port.cpp \
+	pvmf_jitter_buffer_impl.cpp \
+	pvmf_rtcp_timer.cpp \
+	pvmf_jitter_buffer_node.cpp \
+	pvmf_jb_inactivity_timer.cpp
+
+HDRS := pvmf_jitter_buffer_ext_interface.h \
+	pvmf_jitter_buffer_internal.h \
+	pvmf_jitter_buffer_port.h \
+	pvmf_jitter_buffer.h \
+	pvmf_jitter_buffer_node.h \
+	pvmf_rtcp_timer.h \
+	pvmf_jb_inactivity_timer.h
+
+
+include $(MK)/library.mk
+
diff --git a/nodes/streaming/jitterbuffernode/build/make/makefile b/nodes/streaming/jitterbuffernode/build/make/makefile
deleted file mode 100644
index f0d9c88..0000000
--- a/nodes/streaming/jitterbuffernode/build/make/makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvjitterbuffernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../common/include -I ../../../config/opencore -I ../../../streamingmanager/include -I ../../../../../protocols/rtp/src
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pvmf_jitter_buffer_extension_interface.cpp \
-	pvmf_jitter_buffer_port.cpp \
-	pvmf_jitter_buffer_impl.cpp \
-	pvmf_rtcp_timer.cpp \
-	pvmf_jitter_buffer_node.cpp \
-	pvmf_jb_inactivity_timer.cpp
-
-HDRS = pvmf_jitter_buffer_ext_interface.h \
-	pvmf_jitter_buffer_internal.h \
-	pvmf_jitter_buffer_port.h \
-	pvmf_jitter_buffer.h \
-	pvmf_jitter_buffer_node.h \
-	pvmf_rtcp_timer.h \
-	pvmf_jb_inactivity_timer.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_jb_inactivity_timer.h b/nodes/streaming/jitterbuffernode/include/pvmf_jb_inactivity_timer.h
index 2c3f7ae..80be5a1 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_jb_inactivity_timer.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_jb_inactivity_timer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
 #ifndef OSCL_BASE_H_INCLUDED
 #include "oscl_base.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PVLOGGER_H_INCLUDED
 #include "pvlogger.h"
@@ -37,57 +37,6 @@
 #include "pvmf_sm_tunables.h"
 #endif
 
-/**
- * Observer class for the inactivity timer AO
- */
-class PvmfJBInactivityTimerObserver
-{
-    public:
-        virtual ~PvmfJBInactivityTimerObserver() {}
-        /**
-         * A timer event, indicating that the inactivity timer has expired.
-         */
-        virtual void PVMFJBInactivityTimerEvent() = 0;
-};
-
-/**
- * Inactivity timer object to Jitter Buffer node. This object generates event
- * on remote inactivity (no UDP traffic from server for a certain time)
- */
-class PvmfJBInactivityTimer : public OsclTimerObject
-{
-    public:
-        PvmfJBInactivityTimer(PvmfJBInactivityTimerObserver* aObserver);
-
-        virtual ~PvmfJBInactivityTimer();
-
-        /** Start Timer */
-        PVMFStatus Start();
-
-        PVMFStatus setMaxInactivityDurationInMS(uint32 duration);
-
-        uint32 getMaxInactivityDurationInMS()
-        {
-            return iInactivityDurationInMS;
-        }
-
-        /** Stop Timer events */
-        PVMFStatus Stop();
-
-        bool IsTimerStarted()
-        {
-            return iStarted;
-        }
-
-    private:
-        void Run();
-
-        uint32 iInactivityDurationInMS;
-        PvmfJBInactivityTimerObserver* iObserver;
-        PVLogger* iLogger;
-        bool iStarted;
-};
-
 
 /**
  * Observer class for the session duration timer AO
@@ -133,14 +82,14 @@
             return iStarted;
         }
 
-        void SetEstimatedServerClock(OsclClock* aEstimatedServerClock)
+        void SetEstimatedServerClock(PVMFMediaClock* aEstimatedServerClock)
         {
             iEstimatedServerClock = aEstimatedServerClock;
         }
 
         void EstimatedServerClockUpdated();
 
-        uint64 GetExpectedEstimatedServClockValAtSessionEnd()
+        uint32 GetExpectedEstimatedServClockValAtSessionEnd()
         {
             return iExpectedEstimatedServClockValAtSessionEnd;
         }
@@ -165,7 +114,7 @@
             return iElapsedSessionDurationInMS;
         }
 
-        uint64 GetEstimatedServClockValAtLastCancel()
+        uint32 GetEstimatedServClockValAtLastCancel()
         {
             return iEstimatedServClockValAtLastCancel;
         }
@@ -175,8 +124,10 @@
             iEstimatedServClockValAtLastCancel = 0;
             if (iEstimatedServerClock != NULL)
             {
-                uint64 timebase64 = 0;
-                iEstimatedServerClock->GetCurrentTime64(iEstimatedServClockValAtLastCancel, OSCLCLOCK_MSEC, timebase64);
+                uint32 timebase32 = 0;
+                bool overflowFlag = false;
+                iEstimatedServerClock->GetCurrentTime32(iEstimatedServClockValAtLastCancel, overflowFlag,
+                                                        PVMF_MEDIA_CLOCK_MSEC, timebase32);
             }
         }
 
@@ -190,122 +141,18 @@
         PVLogger* iLogger;
         bool iStarted;
 
-        OsclClock iClock;
-        OsclTimebase_Tickcount iClockTimeBase;
-        uint64 iTimerStartTimeInMS;
+        PVMFMediaClock iClock;
+        PVMFTimebase_Tickcount iClockTimeBase;
+        uint32 iTimerStartTimeInMS;
         uint64 iMonitoringIntervalElapsed;
 
-        OsclClock* iEstimatedServerClock;
-        uint64 iEstimatedServClockValAtLastCancel;
-        uint64 iExpectedEstimatedServClockValAtSessionEnd;
+        PVMFMediaClock* iEstimatedServerClock;
+        uint32 iEstimatedServClockValAtLastCancel;
+        uint32 iExpectedEstimatedServClockValAtSessionEnd;
 
         PVLogger *iClockLoggerSessionDuration;
 };
 
-/**
- * Observer class for the jitter buffer duration timer AO
- */
-class PvmfJBJitterBufferDurationTimerObserver
-{
-    public:
-        virtual ~PvmfJBJitterBufferDurationTimerObserver() {}
-        /**
-         * A timer event, indicating that the timer has expired.
-         */
-        virtual void PVMFJBJitterBufferDurationTimerEvent() = 0;
-};
-
-/**
- * Bufferingduration timer object to Jitter Buffer node.
- * This object generates event when the jitter buffer duration expires
- */
-class PvmfJBJitterBufferDurationTimer : public OsclTimerObject
-{
-    public:
-        PvmfJBJitterBufferDurationTimer(PvmfJBJitterBufferDurationTimerObserver* aObserver);
-
-        virtual ~PvmfJBJitterBufferDurationTimer();
-
-        /** Start Timer */
-        PVMFStatus Start();
-
-        PVMFStatus setJitterBufferDurationInMS(uint32 duration);
-
-        uint32 getJitterBufferDurationInMS()
-        {
-            return iJitterBufferDurationInMS;
-        }
-
-        /** Stop Timer events */
-        PVMFStatus Stop();
-
-        bool IsTimerStarted()
-        {
-            return iStarted;
-        }
-
-    private:
-        void Run();
-
-        uint32 iJitterBufferDurationInMS;
-        PvmfJBJitterBufferDurationTimerObserver* iObserver;
-        PVLogger* iLogger;
-        bool iStarted;
-
-        OsclClock iRunClock;
-        OsclTimebase_Tickcount iRunClockTimeBase;
-};
-
-/**
- * Observer class for the firewall packet timer AO
- */
-class PvmfFirewallPacketTimerObserver
-{
-    public:
-        virtual ~PvmfFirewallPacketTimerObserver() {}
-        /**
-         * A timer event, indicating that the timer has expired.
-         */
-        virtual void PvmfFirewallPacketTimerEvent() = 0;
-};
-
-/**
- * FirewallPacketTimer object to Jitter Buffer node.
- * This object generates event when the Firewall packet recv timeout expires
- */
-class PvmfFirewallPacketTimer : public OsclTimerObject
-{
-    public:
-        PvmfFirewallPacketTimer(PvmfFirewallPacketTimerObserver* aObserver);
-
-        virtual ~PvmfFirewallPacketTimer();
-
-        /** Start Timer */
-        PVMFStatus Start();
-
-        PVMFStatus setFirewallPacketRecvTimeOutInMS(uint32 aRecvTimeOut);
-
-        uint32 getFirewallPacketRecvTimeOutInMS()
-        {
-            return iFirewallPacketRecvTimeOutInMS;
-        }
-
-        /** Stop Timer events */
-        PVMFStatus Stop();
-
-        bool IsTimerStarted()
-        {
-            return iStarted;
-        }
-
-    private:
-        void Run();
-
-        uint32 iFirewallPacketRecvTimeOutInMS;
-        PvmfFirewallPacketTimerObserver* iObserver;
-        PVLogger* iLogger;
-        bool iStarted;
-};
 
 #endif // PVMF_JB_INACTIVITY_TIMER_H_INCLUDED
 
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer.h b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer.h
index 33f106e..75e792a 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,25 +78,6 @@
 #define RTP_HEADER_M_BIT_OFFSET 7
 #define RTP_HEADER_PT_MASK      0x7F
 
-/* ASF HEADER CONSTANTS */
-#define ASF_DATA_PACKET_HEADER_ERROR_CORRECTION_PRESENT_MASK     0x80
-#define ASF_DATA_PACKET_HEADER_ERROR_CORRECTION_DATA_LENGTH_MASK 0x07
-#define ASF_DATA_PACKET_HEADER_SEQUENCE_LENGTH_TYPE_OFFSET       1
-#define ASF_DATA_PACKET_HEADER_SEQUENCE_LENGTH_TYPE_MASK         0x06
-#define ASF_DATA_PACKET_HEADER_PADDING_LENGTH_TYPE_OFFSET        3
-#define ASF_DATA_PACKET_HEADER_PADDING_LENGTH_TYPE_MASK          0x18
-#define ASF_DATA_PACKET_HEADER_PACKET_LENGTH_TYPE_OFFSET         5
-#define ASF_DATA_PACKET_HEADER_PACKET_LENGTH_TYPE_MASK           0x60
-/*
- * 1 - Error correction flags
- * 7 (worstcase) - Error correction data length
- * 1 - Length Type;
- * 1 - Property Flags;
- * 4 each(worst case) - PacketLength, Sequence, PaddingLength
- * 4 - Send Time
- * 2 - Duration
- */
-#define MAX_ASF_DATA_PACKET_HEADER_SIZE_IN_BYTES   28
 
 #define PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID 1
 
@@ -117,6 +98,8 @@
 typedef enum
 {
     PVMF_JITTER_BUFFER_ADD_ELEM_ERROR,
+    PVMF_JITTER_BUFFER_ADD_ELEM_ERR_LATE_PACKET,
+    PVMF_JITTER_BUFFER_ADD_ELEM_PACKET_OVERWRITE,
     PVMF_JITTER_BUFFER_ADD_ELEM_SUCCESS,
     PVMF_JITTER_BUFFER_ADD_ELEM_UNEXPECTED_DATA
 } PVMFJitterBufferAddElemStatus;
@@ -150,9 +133,11 @@
         seqNum = 0;
         rtpTimeBaseSet = false;
         rtpTime = 0;
+        nptTimeBaseSet = false;
         nptTimeInMS = 0;
         rtpTimeScale = 0;
         nptTimeInRTPTimeScale = 0;
+        isPlayAfterPause = false;
     };
 
     bool   seqNumBaseSet;
@@ -160,8 +145,10 @@
     bool   rtpTimeBaseSet;
     uint32 rtpTime;
     uint32 nptTimeInMS;
+    bool   nptTimeBaseSet;
     uint32 rtpTimeScale;
     uint32 nptTimeInRTPTimeScale;
+    bool   isPlayAfterPause;
 } PVMFRTPInfoParams;
 
 class MediaCommandMsgHolder
@@ -315,6 +302,7 @@
             readOffset = 0;
             firstSeqNumAdded = 0;
             sJitterBufferParams.currentOccupancy = 0;
+            sJitterBufferParams.packetSizeInBytesLeftInBuffer = 0;
         }
 
         void ResetJitterBufferStats()
@@ -401,6 +389,9 @@
                     return PVMF_JITTER_BUFFER_ADD_ELEM_ERROR;
                 }
 
+                /*
+                 * During ASF streaming this will happen if there is a backwards seek.
+                 */
                 if ((iHeaderFormat == PVMF_JITTER_BUFFER_TRANSPORT_HEADER_RTP) &&
                         (iBroadCastSession == true))
                 {
@@ -428,7 +419,7 @@
                         if (diff16 > PVMF_JITTER_BUFFER_ROLL_OVER_THRESHOLD_16BIT)
                         {
                             /* too late - discard the packet */
-                            oRet = PVMF_JITTER_BUFFER_ADD_ELEM_ERROR;
+                            oRet = PVMF_JITTER_BUFFER_ADD_ELEM_ERR_LATE_PACKET;
                             return (oRet);
                         }
                         else
@@ -445,7 +436,7 @@
                         if ((seqNum - lastRetrievedSeqNum) > PVMF_JITTER_BUFFER_ROLL_OVER_THRESHOLD_32BIT)
                         {
                             /* too late - discard the packet */
-                            oRet = PVMF_JITTER_BUFFER_ADD_ELEM_ERROR;
+                            oRet = PVMF_JITTER_BUFFER_ADD_ELEM_ERR_LATE_PACKET;
                             return (oRet);
                         }
                         else
@@ -502,6 +493,7 @@
                     sJitterBufferParams.maxTimeStampRegistered = elem->getTimestamp();
                 }
                 sJitterBufferParams.currentOccupancy = numElems;
+                oRet = PVMF_JITTER_BUFFER_ADD_ELEM_PACKET_OVERWRITE;
                 return (oRet);
             }
             /* Duplicate Packet - Ignore */
@@ -595,6 +587,13 @@
             aSeqNum = dataPkt.GetRep()->getSeqNum();
             return;
         }
+        void peekMaxElementTimeStamp(PVMFTimestamp& aTS,
+                                     uint32& aSeqNum)
+        {
+            aTS = sJitterBufferParams.maxTimeStampRegistered;
+            aSeqNum = sJitterBufferParams.maxSeqNumRegistered;
+            return;
+        }
 
         bool CheckCurrentReadPosition()
         {
@@ -642,7 +641,7 @@
             iMediaPtrVec[aIndex] = aMediaPtr;
         }
 
-        void PurgeElementsWithSeqNumsLessThan(uint32 aSeqNum)
+        void PurgeElementsWithSeqNumsLessThan(uint32 aSeqNum, uint32& aPrevSeqNumBaseOut)
         {
             if (!iMediaPtrVec.empty())
             {
@@ -654,11 +653,27 @@
                     {
                         if (it->GetRep() != NULL)
                         {
+                            /* Get packet size */
+                            uint32 size = 0;
+                            uint32 numFragments = it->GetRep()->getNumFragments();
+                            for (uint32 i = 0; i < numFragments; i++)
+                            {
+                                OsclRefCounterMemFrag memFragIn;
+                                it->GetRep()->getMediaFragment(i, memFragIn);
+                                size += memFragIn.getMemFrag().len;
+                            }
+                            sJitterBufferParams.packetSizeInBytesLeftInBuffer -= size;
                             it->Unbind();
                         }
                     }
                     numElems = 0;
-                    //iMediaPtrVec.clear();
+                    /* If after purging all elements, we want to determine the TS of the previous element
+                     * (with DeterminePrevTimeStampPeek()), it will give as false information if the
+                     * seqnum has wrapped around. So because of that, we set aPrevSeqNumBaseOut to be smaller
+                     * than the current seqnum.
+                     */
+                    aPrevSeqNumBaseOut = aSeqNum - 1;
+
                 }
                 else if (aSeqNum > lastRetrievedSeqNum)
                 {
@@ -685,6 +700,16 @@
                         {
                             if (elem->getSeqNum() < aSeqNum)
                             {
+                                /* Get packet size */
+                                uint32 size = 0;
+                                uint32 numFragments = elem->getNumFragments();
+                                for (uint32 i = 0; i < numFragments; i++)
+                                {
+                                    OsclRefCounterMemFrag memFragIn;
+                                    elem->getMediaFragment(i, memFragIn);
+                                    size += memFragIn.getMemFrag().len;
+                                }
+                                sJitterBufferParams.packetSizeInBytesLeftInBuffer -= size;
                                 elem.Unbind();
                                 iMediaPtrVec[offset] = elem;
                                 numElems--;
@@ -725,8 +750,17 @@
                         if (tmpTS >= aTS)
                             break;
 
+                        /* Get packet size */
+                        uint32 size = 0;
+                        uint32 numFragments = dataPkt->getNumFragments();
+                        for (uint32 i = 0; i < numFragments; i++)
+                        {
+                            OsclRefCounterMemFrag memFragIn;
+                            dataPkt->getMediaFragment(i, memFragIn);
+                            size += memFragIn.getMemFrag().len;
+                        }
+                        sJitterBufferParams.packetSizeInBytesLeftInBuffer -= size;
                         (iMediaPtrVec[readOffset]).Unbind();
-
                         numElems--;
                     }
                     readOffset++;
@@ -806,7 +840,7 @@
     public:
         virtual ~PVMFJitterBuffer() {}
 
-        virtual void SetEstimatedServerClock(OsclClock* aEstServClock) = 0;
+        virtual void SetEstimatedServerClock(PVMFMediaClock* aEstServClock) = 0;
         virtual bool ParsePacketHeader(PVMFSharedMediaDataPtr& inDataPacket,
                                        PVMFSharedMediaDataPtr& outDataPacket,
                                        uint32 aFragIndex = 0) = 0;
@@ -816,11 +850,12 @@
         virtual void FlushJitterBuffer() = 0;
         virtual void ResetJitterBuffer() = 0;
         virtual void setSSRC(uint32 aSSRC) = 0;
-        virtual void setRTPInfoParams(PVMFRTPInfoParams rtpInfoParams) = 0;
+        virtual void setRTPInfoParams(PVMFRTPInfoParams rtpInfoParams, bool oPlayAfterASeek) = 0;
         virtual bool CheckSpaceAvailability() = 0;
         virtual bool CheckForMemoryAvailability() = 0;
         virtual bool CheckCurrentReadPosition() = 0;
         virtual PVMFTimestamp peekNextElementTimeStamp() = 0;
+        virtual PVMFTimestamp peekMaxElementTimeStamp() = 0;
         virtual bool IsEmpty() = 0;
         virtual void SetEOS(bool aVal) = 0;
         virtual bool GetEOS() = 0;
@@ -840,7 +875,7 @@
         virtual bool addMediaCommand(PVMFSharedMediaMsgPtr& aMediaCmd) = 0;
         virtual bool CheckForPendingCommands(PVMFSharedMediaMsgPtr& aCmdMsg) = 0;
         virtual void SetAdjustedTSInMS(PVMFTimestamp aAdjustedTS) = 0;
-        virtual uint32 GetRTPTimeStampOffset(void) = 0;
+        virtual bool GetRTPTimeStampOffset(uint32& aTimeStampOffset) = 0;
         virtual void   SetRTPTimeStampOffset(uint32 newTSBase) = 0;
         virtual PVMFSharedMediaDataPtr& GetFirstDataPacket(void) = 0;
         virtual void AdjustRTPTimeStamp() = 0;
@@ -855,7 +890,7 @@
                              bool aInPlaceProcessing = true);
         virtual ~PVMFJitterBufferImpl();
 
-        void SetEstimatedServerClock(OsclClock* aEstServClock)
+        void SetEstimatedServerClock(PVMFMediaClock* aEstServClock)
         {
             iEstimatedServerClock = aEstServClock;
         }
@@ -873,6 +908,8 @@
         {
             iFirstDataPackets.clear();
             iJitterBuffer->Clear();
+            iJitterBuffer->ResetJitterBufferStats();
+            iRTPInfoParamsVec.clear();
         };
 
         void ResetJitterBuffer();
@@ -885,7 +922,7 @@
             SSRCLock = aSSRC;
         }
 
-        void setRTPInfoParams(PVMFRTPInfoParams rtpInfo)
+        void setRTPInfoParams(PVMFRTPInfoParams rtpInfo, bool oPlayAfterASeek)
         {
             iJitterBuffer->setRTPInfoParams(rtpInfo);
             PVMFRTPInfoParams iRTPInfoParams;
@@ -899,15 +936,19 @@
             {
                 iRTPInfoParams.rtpTime = rtpInfo.rtpTime;
             }
-            iRTPInfoParams.nptTimeInMS = rtpInfo.nptTimeInMS;
             iRTPInfoParams.rtpTimeScale = rtpInfo.rtpTimeScale;
             iRTPTimeScale = rtpInfo.rtpTimeScale;
             iEstServClockMediaClockConvertor.set_timescale(iRTPTimeScale);
             iMediaClockConvertor.set_timescale(1000);
             iMediaClockConvertor.set_clock_other_timescale(0, iRTPInfoParams.rtpTimeScale);
-            iMediaClockConvertor.update_clock(iRTPInfoParams.nptTimeInMS);
-            iRTPInfoParams.nptTimeInRTPTimeScale =
-                iMediaClockConvertor.get_converted_ts(iRTPInfoParams.rtpTimeScale);
+            iRTPInfoParams.nptTimeBaseSet = rtpInfo.nptTimeBaseSet;
+            if (iRTPInfoParams.nptTimeBaseSet == true)
+            {
+                iRTPInfoParams.nptTimeInMS = rtpInfo.nptTimeInMS;
+                iMediaClockConvertor.update_clock(iRTPInfoParams.nptTimeInMS);
+                iRTPInfoParams.nptTimeInRTPTimeScale =
+                    iMediaClockConvertor.get_converted_ts(iRTPInfoParams.rtpTimeScale);
+            }
             /* In case this is the first rtp info set TS calc variables */
             if (iRTPInfoParamsVec.size() == 0)
             {
@@ -916,6 +957,12 @@
                     iPrevTSOut = iRTPInfoParams.rtpTime;
                     iPrevTSIn = iRTPInfoParams.rtpTime;
                     iPrevAdjustedRTPTS = iRTPInfoParams.rtpTime;
+
+                    if (iPlayListRTPTimeBaseSet == false)
+                    {
+                        iPlayListRTPTimeBaseSet = true;
+                        iPlayListRTPTimeBase = iRTPInfoParams.rtpTime;
+                    }
                 }
                 else
                 {
@@ -927,6 +974,7 @@
                         iPrevAdjustedRTPTS = seqLockTimeStamp;
                     }
                 }
+
                 if (iRTPInfoParams.seqNumBaseSet)
                 {
                     iPrevSeqNumBaseOut = iRTPInfoParams.seqNum;
@@ -941,6 +989,21 @@
                         iPrevSeqNumBaseIn = iFirstSeqNum;
                     }
                 }
+                /* Initialize the variables used for ts calculation between pause and resume */
+                if (iRTPInfoParams.nptTimeBaseSet)
+                {
+                    iPrevNptTimeInRTPTimeScale = iRTPInfoParams.nptTimeInRTPTimeScale;
+                    isPrevNptTimeSet = true;
+                }
+                if (iRTPInfoParams.rtpTimeBaseSet)
+                {
+                    iPrevRtpTimeBase = iRTPInfoParams.rtpTime;
+                    isPrevRtpTimeSet = true;
+                }
+            }
+            else
+            {
+                iRTPInfoParams.isPlayAfterPause = !oPlayAfterASeek;
             }
             if (iRTPInfoParams.rtpTimeBaseSet)
             {
@@ -1003,7 +1066,7 @@
         };
 
         PVMFTimestamp peekNextElementTimeStamp();
-
+        PVMFTimestamp peekMaxElementTimeStamp();
         void SetEOS(bool aVal)
         {
             oEOS = aVal;
@@ -1028,6 +1091,10 @@
                             uint32 aFragIndex = 0);
 
 
+        bool Allocate(OsclSharedPtr<PVMFMediaDataImpl>& mediaDataOut);
+
+        bool CreateMediaData(PVMFSharedMediaDataPtr& dataPacket, OsclSharedPtr<PVMFMediaDataImpl>& mediaDataOut);
+
         void setPlayRange(int32 aStartTimeInMS, int32 aStopTimeInMS)
         {
             iStartTimeInMS = aStartTimeInMS;
@@ -1155,15 +1222,26 @@
             PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferImpl::SetAdjustedTS(): adjustedTSInRTPTS=%d, iMonotonicTS=%d", adjustedTSInRTPTS, Oscl_Int64_Utils::get_uint64_lower32(iMonotonicTimeStamp)));
 
         }
-        uint32 GetRTPTimeStampOffset(void)
+        bool GetRTPTimeStampOffset(uint32& aTimeStampOffset)
         {
-            return seqLockTimeStamp;
+            if (seqNumLock)
+                aTimeStampOffset = seqLockTimeStamp;
+
+            return seqNumLock;
         }
+
         void   SetRTPTimeStampOffset(uint32 newTSBase)
         {
-            seqLockTimeStamp = newTSBase;
-            iMonotonicTimeStamp = 0;
+            // This function must be used only to offset the RTP TB
+            // for broadcast streaming.
+            // Based on that, the following is assumed:
+            // 1) seqLockTimeStamp is valid
+            // 2) newTSBase <= seqLockTimeStamp
+
+            iMonotonicTimeStamp += (seqLockTimeStamp - newTSBase);
+            iMaxAdjustedRTPTS += (seqLockTimeStamp - newTSBase);
         }
+
         PVMFSharedMediaDataPtr& GetFirstDataPacket(void)
         {
             return firstDataPacket;
@@ -1273,6 +1351,7 @@
         PVLogger *iDataPathLoggerIn;
         PVLogger *iDataPathLoggerOut;
         PVLogger *iClockLogger;
+        PVLogger *iClockLoggerRebuff;
 
         OSCL_HeapString<PVMFJitterBufferNodeAllocator> iMimeType;
 
@@ -1281,8 +1360,8 @@
         double iInterArrivalJitterD;
         int32  iInterArrivalJitter;
 
-        OsclClock *iPacketArrivalClock;
-        OsclTimebase_Tickcount iPacketArrivalTimeBase;
+        PVMFMediaClock *iPacketArrivalClock;
+        PVMFTimebase_Tickcount iPacketArrivalTimeBase;
 
         int32 iStartTimeInMS;
         int32 iStopTimeInMS;
@@ -1296,13 +1375,17 @@
         PVMFTimestamp iPrevTSIn;
         uint32 iPrevSeqNumBaseIn;
 
-        OsclClock* iEstimatedServerClock;
-        OsclTimebase_Tickcount iTickCount;
+        PVMFMediaClock* iEstimatedServerClock;
+        PVMFTimebase_Tickcount iTickCount;
         uint32 iRTPTimeScale;
         MediaClockConverter iEstServClockMediaClockConvertor;
         PVMFJitterBufferObserver* iObserver;
         OsclAny* iObserverContext;
 
+        // RTP Timebase for playlists
+        uint32 iPlayListRTPTimeBase;
+        bool iPlayListRTPTimeBaseSet;
+
         bool iInPlaceProcessing;
 
         PVMFJitterBufferTransportHeaderFormat iHeaderFormat;
@@ -1318,6 +1401,10 @@
         OsclAny* iServerClockUpdateNotificationObserverContext;
 
         bool iBroadCastSession;
+        bool   isPrevNptTimeSet;
+        uint32 iPrevNptTimeInRTPTimeScale;
+        bool   isPrevRtpTimeSet;
+        uint32 iPrevRtpTimeBase;
 };
 
 #endif
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_ext_interface.h b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_ext_interface.h
index a24c937..2c00af4 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_ext_interface.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_ext_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@
 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
 #include "oscl_string_containers.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PV_UUID_H_INCLUDED
 #include "pv_uuid.h"
@@ -39,10 +39,17 @@
 #ifndef RTSP_TIME_FORMAT_H
 #include "rtsp_time_formats.h"
 #endif
+#ifndef PVMF_STREAMING_BUFFER_ALLOCATORS_H_INCLUDED
+#include "pvmf_streaming_buffer_allocators.h"
+#endif
 #ifndef PVMF_SM_TUNABLES_H_INCLUDED
 #include "pvmf_sm_tunables.h"
 #endif
+#ifndef PVMF_SM_CONFIG_H_INCLUDED
+#include "pvmf_sm_config.h"
+#endif
 
+class PvmfPortBaseImpl;
 //memory allocator type for this node.
 typedef OsclMemAllocator PVMFJitterBufferNodeAllocator;
 
@@ -94,7 +101,15 @@
         OSCL_IMPORT_REF virtual void getJitterBufferRebufferingThresholdInMilliSeconds(uint32& aThreshold) = 0;
         OSCL_IMPORT_REF virtual void setJitterBufferDurationInMilliSeconds(uint32 duration) = 0;
         OSCL_IMPORT_REF virtual void getJitterBufferDurationInMilliSeconds(uint32& duration) = 0;
-        OSCL_IMPORT_REF virtual void setClientPlayBackClock(OsclClock* clientClock) = 0;
+
+        OSCL_IMPORT_REF virtual void setEarlyDecodingTimeInMilliSeconds(uint32 duration) = 0;
+        OSCL_IMPORT_REF virtual void setBurstThreshold(float burstThreshold) = 0;
+
+        //While in buffering/start state, Jitter Buffer node expects its upstream peer node to send media msg at its input port in duration < inactivity duration
+        OSCL_IMPORT_REF virtual void setMaxInactivityDurationForMediaInMs(uint32 duration) = 0;
+        OSCL_IMPORT_REF virtual void getMaxInactivityDurationForMediaInMs(uint32& duration) = 0;
+
+        OSCL_IMPORT_REF virtual void setClientPlayBackClock(PVMFMediaClock* clientClock) = 0;
         OSCL_IMPORT_REF virtual bool PrepareForRepositioning(bool oUseExpectedClientClockVal = false,
                 uint32 aExpectedClientClockVal = 0) = 0;
         OSCL_IMPORT_REF virtual bool setPortSSRC(PVMFPortInterface* aPort, uint32 aSSRC) = 0;
@@ -103,6 +118,7 @@
                 uint32 aSeqNumBase,
                 bool   aRTPTimeBasePresent,
                 uint32 aRTPTimeBase,
+                bool   aNPTTimeBasePresent,
                 uint32 aNPTInMS,
                 bool oPlayAfterASeek = false) = 0;
         OSCL_IMPORT_REF virtual bool setPortRTCPParams(PVMFPortInterface* aPort,
@@ -110,19 +126,26 @@
                 uint32 aRR,
                 uint32 aRS) = 0;
         OSCL_IMPORT_REF virtual PVMFTimestamp getActualMediaDataTSAfterSeek() = 0;
+        OSCL_IMPORT_REF virtual PVMFTimestamp getMaxMediaDataTS() = 0;
         OSCL_IMPORT_REF virtual void addRef() = 0;
         OSCL_IMPORT_REF virtual void removeRef() = 0;
         OSCL_IMPORT_REF virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
         OSCL_IMPORT_REF virtual PVMFStatus setServerInfo(PVMFJitterBufferFireWallPacketInfo& aServerInfo) = 0;
         OSCL_IMPORT_REF virtual PVMFStatus NotifyOutOfBandEOS() = 0;
         OSCL_IMPORT_REF virtual PVMFStatus SendBOSMessage(uint32 aStramID) = 0;
-        OSCL_IMPORT_REF virtual OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> CreateResizablePortAllocator(uint32 aSize,
-                OSCL_String& aName) = 0;
+
+        OSCL_IMPORT_REF virtual void SetJitterBufferChunkAllocator(OsclMemPoolResizableAllocator* aDataBufferAllocator, const PVMFPortInterface* aPort) = 0;
+
+        OSCL_IMPORT_REF virtual void SetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32 aSize, uint32 aResizeSize, uint32 aMaxNumResizes, uint32 aExpectedNumberOfBlocksPerBuffer) = 0;
+        OSCL_IMPORT_REF virtual void GetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32& aSize, uint32& aResizeSize, uint32& aMaxNumResizes, uint32& aExpectedNumberOfBlocksPerBuffer) const = 0;
+
         OSCL_IMPORT_REF virtual void SetSharedBufferResizeParams(uint32 maxNumResizes, uint32 resizeSize) = 0;
         OSCL_IMPORT_REF virtual void GetSharedBufferResizeParams(uint32& maxNumResizes, uint32& resizeSize) = 0;
 
         OSCL_IMPORT_REF virtual bool ClearJitterBuffer(PVMFPortInterface* aPort,
                 uint32 aSeqNum) = 0;
+        OSCL_IMPORT_REF virtual void FlushJitterBuffer() = 0;
+
         OSCL_IMPORT_REF virtual bool NotifyAutoPauseComplete() = 0;
         OSCL_IMPORT_REF virtual bool NotifyAutoResumeComplete() = 0;
         OSCL_IMPORT_REF virtual PVMFStatus SetTransportType(PVMFPortInterface* aPort,
@@ -132,6 +155,10 @@
 
         OSCL_IMPORT_REF virtual void SetBroadCastSession() = 0;
         OSCL_IMPORT_REF virtual void DisableFireWallPackets() = 0;
+        OSCL_IMPORT_REF virtual void UpdateJitterBufferState() = 0;
+        OSCL_IMPORT_REF virtual void StartOutputPorts() = 0;
+        OSCL_IMPORT_REF virtual void StopOutputPorts() = 0;
+        OSCL_IMPORT_REF virtual bool PrepareForPlaylistSwitch() = 0;
 };
 
 //Mimetype and Uuid for the extension interface
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_internal.h b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_internal.h
index d4500ce..77fa626 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_internal.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,7 +42,9 @@
 #define PVMF_JBNODE_LOGINFO(m) PVMF_JBNODE_LOGINFOMED(m)
 #define PVMF_JBNODE_LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_INFO,m);
 #define PVMF_JBNODE_LOGDATATRAFFIC_IN(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerIn,PVLOGMSG_INFO,m);
+#define PVMF_JBNODE_LOGDATATRAFFIC_IN_E(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerIn,PVLOGMSG_ERR,m);
 #define PVMF_JBNODE_LOGDATATRAFFIC_OUT(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerOut,PVLOGMSG_INFO,m);
+#define PVMF_JBNODE_LOGDATATRAFFIC_OUT_E(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerOut,PVLOGMSG_ERR,m);
 #define PVMF_JBNODE_LOGCLOCK(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iClockLogger,PVLOGMSG_INFO,m);
 #define PVMF_JBNODE_LOGCLOCK_SESSION_DURATION(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iClockLoggerSessionDuration,PVLOGMSG_INFO,m);
 #define PVMF_JBNODE_LOGCLOCK_REBUFF(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iClockLoggerRebuff,PVLOGMSG_INFO,m);
@@ -50,7 +52,10 @@
 #define PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerFlowCtrl,PVLOGMSG_INFO,m);
 #define PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerFlowCtrl,PVLOGMSG_ERR,m);
 #define PVMF_JBNODE_LOG_RTCP(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerRTCP,PVLOGMSG_INFO,m);
+#define PVMF_JBNODE_LOG_RTCP_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerRTCP,PVLOGMSG_ERR,m);
 #define PVMF_JBNODE_LOG_FW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLoggerFireWall,PVLOGMSG_INFO,m);
+#define PVMF_JBNODE_LOG_EVENTS_CLOCK(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iJBEventsClockLogger ,PVLOGMSG_INFO,m);
+#define PVMF_JBNODE_LOG_RTCP_AVSYNC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iRTCPAVSyncLogger,PVLOGMSG_INFO,m);
 
 #define PVMF_JITTER_BUFFER_NEW(auditCB,T,params,ptr)\
 {\
@@ -64,7 +69,7 @@
 
 #define PVMF_JITTER_BUFFER_TEMPLATED_DELETE(auditCB, T, Tsimple, ptr)\
 {\
-OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
+OSCL_DELETE(ptr);\
 }
 
 //Default vector reserve size
@@ -146,7 +151,13 @@
         OSCL_IMPORT_REF void getJitterBufferRebufferingThresholdInMilliSeconds(uint32& aThreshold);
         OSCL_IMPORT_REF void setJitterBufferDurationInMilliSeconds(uint32 duration);
         OSCL_IMPORT_REF void getJitterBufferDurationInMilliSeconds(uint32& duration);
-        OSCL_IMPORT_REF void setClientPlayBackClock(OsclClock* clientClock);
+
+        OSCL_IMPORT_REF void setEarlyDecodingTimeInMilliSeconds(uint32 duration);
+        OSCL_IMPORT_REF void setBurstThreshold(float burstThreshold);
+
+        OSCL_IMPORT_REF void setClientPlayBackClock(PVMFMediaClock* clientClock);
+        OSCL_IMPORT_REF void setMaxInactivityDurationForMediaInMs(uint32 duration);
+        OSCL_IMPORT_REF void getMaxInactivityDurationForMediaInMs(uint32& duration);
 
         OSCL_IMPORT_REF bool PrepareForRepositioning(bool oUseExpectedClientClockVal = false,
                 uint32 aExpectedClientClockVal = 0);
@@ -158,6 +169,7 @@
                                               uint32 aSeqNumBase,
                                               bool   aRTPTimeBasePresent,
                                               uint32 aRTPTimeBase,
+                                              bool   aNPTTimeBasePresent,
                                               uint32 aNPTInMS,
                                               bool oPlayAfterASeek = false);
 
@@ -167,6 +179,7 @@
                                                uint32 aRS);
 
         OSCL_IMPORT_REF PVMFTimestamp getActualMediaDataTSAfterSeek();
+        OSCL_IMPORT_REF PVMFTimestamp getMaxMediaDataTS();
 
         void addRef()
         {
@@ -180,6 +193,7 @@
         {
             if (uuid == Uuid())
             {
+                addRef();
                 iface = this;
                 return true;
             }
@@ -195,12 +209,11 @@
         OSCL_IMPORT_REF PVMFStatus NotifyOutOfBandEOS();
         OSCL_IMPORT_REF PVMFStatus SendBOSMessage(uint32 aStramID);
 
-        OSCL_IMPORT_REF OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> CreateResizablePortAllocator(uint32 aSize, OSCL_String& aName);
-
         OSCL_IMPORT_REF void SetSharedBufferResizeParams(uint32 maxNumResizes, uint32 resizeSize);
         OSCL_IMPORT_REF void GetSharedBufferResizeParams(uint32& maxNumResizes, uint32& resizeSize);
 
         OSCL_IMPORT_REF bool ClearJitterBuffer(PVMFPortInterface* aPort, uint32 aSeqNum);
+        OSCL_IMPORT_REF void FlushJitterBuffer();
 
         OSCL_IMPORT_REF bool NotifyAutoPauseComplete();
 
@@ -215,6 +228,15 @@
         OSCL_IMPORT_REF void SetBroadCastSession();
         OSCL_IMPORT_REF void DisableFireWallPackets();
 
+
+        OSCL_IMPORT_REF void StartOutputPorts();
+        OSCL_IMPORT_REF void StopOutputPorts();
+        OSCL_IMPORT_REF void UpdateJitterBufferState();
+        OSCL_IMPORT_REF virtual void SetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32 aSize, uint32 aResizeSize, uint32 aMaxNumResizes, uint32 aExpectedNumberOfBlocksPerBuffer);
+        OSCL_IMPORT_REF virtual void GetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32& aSize, uint32& aResizeSize, uint32& aMaxNumResizes, uint32& aExpectedNumberOfBlocksPerBuffer) const;
+        OSCL_IMPORT_REF void SetJitterBufferChunkAllocator(OsclMemPoolResizableAllocator* aDataBufferAllocator, const PVMFPortInterface* aPort);
+        OSCL_IMPORT_REF virtual bool PrepareForPlaylistSwitch();
+
     private:
         PVMFJitterBufferNode *iContainer;
         friend class PVMFJitterBufferNode;
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_node.h b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_node.h
index e7c3645..df33062 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_node.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
 #ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
 #include "oscl_exclusive_ptr.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef OSCL_TIMER_H_INCLUDED
 #include "oscl_timer.h"
@@ -95,21 +95,42 @@
 
 class PVLogger;
 
-class PVMFJitterBufferNode : public PVMFNodeInterface,
+class PVMFMediaClockNotificationsIntfContext
+{
+    public:
+        PVMFMediaClockNotificationsIntfContext(): iClockNotificationIntf(NULL), iContext(NULL) {}
+        void SetContext(PVMFMediaClockNotificationsInterface* aClockNotificationsInterface, OsclAny* aContext)
+        {
+            iClockNotificationIntf = aClockNotificationsInterface;
+            iContext = aContext;
+        }
+        const OsclAny* GetContextData() const
+        {
+            return iContext;
+        }
+
+        const PVMFMediaClockNotificationsInterface* GetMediaClockNotificationsInterface() const
+        {
+            return  iClockNotificationIntf;
+        }
+
+    private:
+        PVMFMediaClockNotificationsInterface* iClockNotificationIntf;
+        OsclAny* iContext;
+};
+
+class PVMFJitterBufferNode : public PVInterface,
+            public PVMFNodeInterface,
             public OsclActiveObject,
             public PVMFNodeErrorEventObserver,
             public PVMFNodeInfoEventObserver,
             public PVMFNodeCmdStatusObserver,
             public PvmfRtcpTimerObserver,
-            public PvmfJBInactivityTimerObserver,
             public PvmfJBSessionDurationTimerObserver,
-            public PvmfJBJitterBufferDurationTimerObserver,
-            public OsclTimerObserver,
             public PVMFJitterBufferObserver,
-            public PvmfFirewallPacketTimerObserver,
-            public OsclMemPoolFixedChunkAllocatorObserver,
-            public OsclClockStateObserver,
-            public PVMFSMSharedBufferAllocWithReSizeAllocDeallocObserver
+            public PVMFMediaClockStateObserver,
+            public OsclMemPoolResizableAllocatorMemoryObserver,
+            public PVMFMediaClockNotificationsObs
 {
     public:
         OSCL_IMPORT_REF PVMFJitterBufferNode(int32 aPriority);
@@ -185,9 +206,50 @@
 
         //from PVMFPortActivityHandler
         void HandlePortActivity(const PVMFPortActivity& aActivity);
-        //from OsclClockStateObserver
+        //from PVMFMediaClockStateObserver
         virtual void ClockStateUpdated();
+        // Need to set jb state to ready when handing 404, 415 response
+        virtual void UpdateJitterBufferState();
+        void NotificationsInterfaceDestroyed();
+
+        virtual void addRef()
+        {
+        }
+        virtual void removeRef()
+        {
+        }
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            iface = NULL;
+            if (uuid == PVUuid(PVMF_JITTERBUFFERNODE_EXTENSIONINTERFACE_UUID))
+            {
+                if (!iExtensionInterface)
+                {
+                    PVMFJitterBufferNodeAllocator alloc;
+                    int32 err;
+                    OsclAny*ptr = NULL;
+                    OSCL_TRY(err,
+                             ptr = alloc.ALLOCATE(sizeof(PVMFJitterBufferExtensionInterfaceImpl));
+                            );
+                    if (err != OsclErrNone || !ptr)
+                    {
+                        PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::queryInterface: Error - Out of memory"));
+                        OSCL_LEAVE(OsclErrNoMemory);
+                    }
+                    iExtensionInterface =
+                        OSCL_PLACEMENT_NEW(ptr, PVMFJitterBufferExtensionInterfaceImpl(this));
+                }
+                return (iExtensionInterface->queryInterface(uuid, iface));
+            }
+            else
+            {
+                return false;
+            }
+        }
+        virtual bool PrepareForPlaylistSwitch();
+
     private:
+        bool RTCPByeRcvd();
         //from OsclActiveObject
         void Run();
         void DoCancel();
@@ -247,6 +309,8 @@
         PVLogger *iClockLogger;
         PVLogger *iClockLoggerSessionDuration;
         PVLogger *iClockLoggerRebuff;
+        PVLogger *iJBEventsClockLogger;
+        PVLogger *iRTCPAVSyncLogger;
         uint32 iStreamID;
 
         PVMFJitterBufferExtensionInterfaceImpl *iExtensionInterface;
@@ -254,14 +318,15 @@
         /*
          * Jitter buffer related params
          */
-        OsclClock *iClientPlayBackClock;
-        OsclClock *iEstimatedServerClock;
-        OsclTimebase_Tickcount iEstimatedServerClockTimeBase;
+        PVMFMediaClock *iClientPlayBackClock;
+        PVMFMediaClock *iEstimatedServerClock;
+        PVMFTimebase_Tickcount iEstimatedServerClockTimeBase;
 
-        uint32    iJitterBufferDurationInMilliSeconds;
         uint32    iJitterBufferUnderFlowThresholdInMilliSeconds;
         uint32    iPlayBackThresholdInMilliSeconds;
+        uint32    iEstimatedServerKeepAheadInMilliSeconds;
         bool      oDelayEstablished;
+        bool      iOverflowFlag;
 
         PVMFJBCommandContext iInternalCmdPool[PVMF_JITTER_BUFFER_INTERNAL_CMDQ_SIZE];
 
@@ -320,10 +385,40 @@
         void SetState(TPVMFNodeInterfaceState);
 
         void CleanUp();
-        void setClientPlayBackClock(OsclClock* clientClock)
+        void setClientPlayBackClock(PVMFMediaClock* clientClock)
         {
+            //remove ourself as observer of old clock, if any.
+            if (iClientPlayBackClockNotificationsInf && iClientPlayBackClock)
+            {
+                iClientPlayBackClockNotificationsInf->RemoveClockStateObserver(*this);
+                iClientPlayBackClock->DestroyMediaClockNotificationsInterface(iClientPlayBackClockNotificationsInf);
+                iClientPlayBackClockNotificationsInf = NULL;
+            }
+
             iClientPlayBackClock = clientClock;
-            iClientPlayBackClock->SetClockStateObserver(*this);
+            if (iClientPlayBackClock)
+            {
+                PVMFStatus status = iClientPlayBackClock->ConstructMediaClockNotificationsInterface(iClientPlayBackClockNotificationsInf, *this);
+                if (PVMFSuccess != status || !iClientPlayBackClockNotificationsInf)
+                {
+                    iClientPlayBackClockNotificationsInf = NULL;
+                    OSCL_ASSERT(false);
+                }
+            }
+
+            //set ourself as observer of new clock.
+            if (iClientPlayBackClockNotificationsInf)
+                iClientPlayBackClockNotificationsInf->SetClockStateObserver(*this);
+        }
+
+        void setMaxInactivityDurationForMediaInMs(uint32 duration)
+        {
+            iMaxInactivityDurationForMediaInMs = duration;
+        }
+
+        void getMaxInactivityDurationForMediaInMs(uint32& duration)
+        {
+            duration = iMaxInactivityDurationForMediaInMs;
         }
 
         friend class PVMFJitterBufferPort;
@@ -345,6 +440,7 @@
         bool PrepareForRepositioning(bool oUseExpectedClientClockVal = false,
                                      uint32 aExpectedClientClockVal = 0);
         bool ClearJitterBuffer(PVMFPortInterface* aPort, uint32 aSeqNum);
+        void FlushJitterBuffer();
         bool pauseEstimatedServerClock()
         {
             if (iEstimatedServerClock)
@@ -362,10 +458,7 @@
                 PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::StartEstimatedServerClock"));
                 iEstimatedServerClock->Start();
             }
-            if (iJitterBufferDurationTimer)
-            {
-                iJitterBufferDurationTimer->Start();
-            }
+            RequestEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
             StartOutputPorts();
             return true;
         }
@@ -386,6 +479,8 @@
                 PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJitterBufferNode::NotifyAutoResumeComplete"));
                 PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::NotifyAutoResumeComplete"));
                 iEstimatedServerClock->Start();
+                /* NotifyAutoResumeComplete() is only called in case of HTTP streaming,
+                   therefore EstimatedServerClock has to be paused just after it is started */
                 iEstimatedServerClock->Pause();
             }
             return true;
@@ -419,6 +514,7 @@
                               uint32 aSeqNumBase,
                               bool   aRTPTimeBasePresent,
                               uint32 aRTPTimeBase,
+                              bool   aNPTTimeBasePresent,
                               uint32 aNPTInMS,
                               bool oPlayAfterASeek = false);
         bool setPortRTCPParams(PVMFPortInterface* aPort,
@@ -432,13 +528,6 @@
                                     OSCL_String& aTransportType);
         bool PurgeElementsWithNPTLessThan(NptTimeFormat &aNPTTime);
 
-        bool iBroadCastSession;
-        void SetBroadCastSession()
-        {
-            iBroadCastSession = true;
-        };
-
-
         void setPlayBackThresholdInMilliSeconds(uint32 threshold)
         {
             iPlayBackThresholdInMilliSeconds = threshold;
@@ -456,15 +545,7 @@
         }
         void setJitterBufferDurationInMilliSeconds(uint32 duration)
         {
-            if ((iInterfaceState == EPVMFNodePrepared) ||
-                    (duration > iJitterBufferDurationInMilliSeconds))  // only update to higher value than the default
-            {
-                iJitterBufferDurationInMilliSeconds = duration;
-            }
-            if (iJitterBufferDurationTimer != NULL)
-            {
-                iJitterBufferDurationTimer->setJitterBufferDurationInMS(iJitterBufferDurationInMilliSeconds);
-            }
+            iJitterBufferDurationInMilliSeconds = duration;
         }
         void getJitterBufferDurationInMilliSeconds(uint32& duration)
         {
@@ -473,26 +554,56 @@
 
         PVMFStatus HasSessionDurationExpired(bool& aExpired)
         {
-            aExpired = oSessionDurationExpired;
+            aExpired = false;
+            if (oSessionDurationExpired)
+            {
+                aExpired = true;
+                return PVMFSuccess;
+            }
+
+            Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+            for (it = iPortParamsQueue.begin();
+                    it != iPortParamsQueue.end();
+                    it++)
+            {
+                if (PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK == it->tag)
+                {
+                    if (it->iRTCPStats.oRTCPByeRecvd)
+                    {
+                        aExpired = true;
+                    }
+                    else
+                    {
+                        aExpired = false;
+                        return PVMFSuccess;
+                    }
+                }
+            }
+            oSessionDurationExpired = aExpired;
             return PVMFSuccess;
         }
 
+
         void SetSharedBufferResizeParams(uint32 maxNumResizes, uint32 resizeSize);
         void GetSharedBufferResizeParams(uint32& maxNumResizes, uint32& resizeSize);
 
+        void SetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32 aSize, uint32 aResizeSize, uint32 aMaxNumResizes, uint32 aExpectedNumberOfBlocksPerBuffer);
+        void GetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32& aSize, uint32& aResizeSize, uint32& aMaxNumResizes, uint32& aExpectedNumberOfBlocksPerBuffer) const;
+
         PVMFPortInterface* getPortCounterpart(PVMFPortInterface* aPort);
         bool CheckForSpaceInJitterBuffer(PVMFPortInterface* aPort);
         PVMFStatus CheckForHighWaterMark(PVMFPortInterface* aPort, bool& aHighWaterMarkReached);
         PVMFStatus CheckForLowWaterMark(PVMFPortInterface* aPort, bool& aLowWaterMarkReached);
         PVMFStatus RequestMemCallBackForAutoResume(PVMFPortInterface* aPort);
-        void freechunkavailable(OsclAny* aContextData);
+        void freeblockavailable(OsclAny* aContextData);
+        void freememoryavailable(OsclAny* aContextData);
         void chunkdeallocated(OsclAny* aContextData);
         bool RegisterDataPacket(PVMFPortInterface* aPort,
                                 PVMFJitterBuffer* aJitterBuffer,
                                 PVMFSharedMediaDataPtr& aDataPacket);
         PVMFJitterBuffer* findJitterBuffer(PVMFPortInterface* aPort);
         PVMFPortInterface* findPortForJitterBuffer(PVMFJitterBuffer*);
-        bool IsJitterBufferReady(PVMFJitterBufferPortParams*);
+        bool IsJitterBufferReady(PVMFJitterBufferPortParams*, uint32& aClockDiff);
         PVMFStatus SendData(PVMFPortInterface*);
         PVMFStatus CheckJitterBufferEmpty(bool& oEmpty);
         void JitterBufferFreeSpaceAvailable(OsclAny* aContext);
@@ -508,13 +619,10 @@
         bool  oSessionDurationExpired;
         bool  oStopOutputPorts;
         PVMFTimestamp getActualMediaDataTSAfterSeek();
-        /* Timer for buffering status */
-        OsclTimer<PVMFJitterBufferNodeAllocator>* iBufferingStatusTimer;
-        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+        PVMFTimestamp getMaxMediaDataTS();
         PVMFStatus CheckForEOS();
         PVMFStatus GenerateAndSendEOSCommand(PVMFPortInterface* aPort);
         PVMFStatus NotifyOutOfBandEOS();
-
         PVMFStatus SendBOSMessage(uint32 aStramID);
         bool QueueBOSCommand(PVMFPortInterface* aPort);
 
@@ -559,15 +667,8 @@
         PVMFStatus ComposeAndSendRateAdaptationFeedBackPacket(PVMFJitterBufferPortParams*&,
                 PVMFJitterBufferPortParams*&);
 
-        OsclClock *iRTCPClock;
-        OsclTimebase_Tickcount iRTCPClockTimeBase;
-
-        /*
-         * InActivity Timer Releated
-         */
-        PvmfJBInactivityTimer* iRemoteInactivityTimer;
-        uint32 iRemoteMaxInactivityDurationInMS;
-        void PVMFJBInactivityTimerEvent();
+        PVMFMediaClock *iRTCPClock;
+        PVMFTimebase_Tickcount iRTCPClockTimeBase;
 
         /*
          * Session Duration timer related
@@ -578,12 +679,6 @@
         void PVMFJBSessionDurationTimerEvent();
         void ComputeCurrentSessionDurationMonitoringInterval();
 
-        /*
-         * Jitter Buffer Duration timer related
-         */
-        PvmfJBJitterBufferDurationTimer* iJitterBufferDurationTimer;
-        void PVMFJBJitterBufferDurationTimerEvent();
-
         /* firewall packet related */
         void DisableFireWallPackets()
         {
@@ -592,24 +687,20 @@
 
         PVMFStatus CreateFireWallPacketMemAllocators(PVMFJitterBufferPortParams*);
         PVMFStatus DestroyFireWallPacketMemAllocators(PVMFJitterBufferPortParams*);
-        PvmfFirewallPacketTimer* iFireWallPacketTimer;
 
         PVMFJitterBufferFireWallPacketInfo iFireWallPacketInfo;
         bool iDisableFireWallPackets;
 
-        void PvmfFirewallPacketTimerEvent();
         PVMFStatus SendFireWallPackets();
+
+        bool Allocate(PVMFJitterBufferPortParams* it, PVMFSharedMediaDataPtr& fireWallPkt, OsclSharedPtr<PVMFMediaDataImpl>& mediaDataImpl, const int size);
+
         PVMFStatus ResetFireWallPacketInfoAndResend();
         void CheckForFireWallRecv(bool &aComplete);
         void CheckForFireWallPacketAttempts(bool &aComplete);
         PVMFStatus DecodeFireWallPackets(PVMFSharedMediaDataPtr aPacket,
                                          PVMFJitterBufferPortParams* aPortParamsPtr);
 
-        /* HTTP Streaming Related */
-        PVMFSMSharedBufferAllocWithReSize* iBufferAlloc;
-        OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> CreateResizablePortAllocator(uint32 aSize,
-                OSCL_String& aName);
-
         /* Bitstream thinning releated */
         void UpdateRebufferingStats(PVMFEventType aEventType);
         uint32 iNumUnderFlow;
@@ -631,11 +722,26 @@
         void LogPortDiagnostics();
 
         /* resizable reallocator configuration */
+        uint32 iJitterBufferSz;
         uint iMaxNumBufferResizes;
         uint iBufferResizeSize;
 
+        void SetJitterBufferSize(uint32 aBufferSz);
+        void GetJitterBufferSize(uint32& aBufferSz) const;
+        void SetJitterBufferChunkAllocator(OsclMemPoolResizableAllocator* aDataBufferAllocator, const PVMFPortInterface* aPort);
+
+        // Broadcast related
+        inline void SetBroadCastSession()
+        {
+            iBroadCastSession = true;
+        };
+
+        bool ProcessRTCPSRforAVSync();
+        bool iRTCPBcastAVSyncProcessed;
+        bool iBroadCastSession;
+
         /*
-        	"hasAudioRTCP" and "hasVideoRTCP" are fundamentally different than
+        "hasAudioRTCP" and "hasVideoRTCP" are fundamentally different than
         PVMFJitterBufferPortParams::iRTCPStats.oSRRecvd because the former
         indicates if the port exists at all, and the latter indicate if
         sender reports were received.  This distinction is important when the
@@ -645,12 +751,69 @@
         bool hasAudioRTCP;
         bool hasVideoRTCP;
         bool gotRTCPReports;
+        uint32 prevMinPercentOccupancy;
+        uint32 consecutiveLowBufferCount;
 
         //These arrays map a steamID (VID or AUD) to an RTCP or RTP port index.
         uint32 RTCPPortIndex [NUM_PVMF_STREAM_TYPES];
         uint32 InputPortIndex[NUM_PVMF_STREAM_TYPES];
-};
+        ////////////
+        PVMFMediaClock * iNonDecreasingClock;
+        PVMFMediaClockNotificationsInterface *iNonDecreasingClockNotificationsInf;
 
+        PVMFMediaClockNotificationsInterface *iClientPlayBackClockNotificationsInf;
+        PVMFMediaClockNotificationsInterface *iEstimatedClockNotificationsInf;
+
+
+        //Request callback contexts
+        PVMFMediaClockNotificationsIntfContext	iNonDecClkNotificationsInfContext;
+        PVMFMediaClockNotificationsIntfContext	iClientPlayBkClkNotificationsInfContext;
+        PVMFMediaClockNotificationsIntfContext	iEstimatedClockNotificationsInfContext;
+
+        PVMFTimebase_Tickcount iNonDecreasingClockTimeBase;
+
+        uint32 iMaxInactivityDurationForMediaInMs;
+        uint32 iIncomingMediaInactivityDurationCallBkId;
+        bool   iIncomingMediaInactivityDurationCallBkPending;
+
+        uint32 iBufferingStatusIntervalInMs;
+        uint32 iNotifyBufferingStatusCallBkId;
+        bool   iNotifyBufferingStatusCallBkPending;
+
+        uint32 iJitterBufferDurationInMilliSeconds;
+        uint32 iJitterBufferDurationCallBkId;
+        bool   iJitterBufferDurationCallBkPending;
+
+        uint32 iMonitorReBufferingCallBkId;
+        bool   iMonitorReBufferingCallBkPending;
+
+        uint32 iSendFirewallPacketCallBkId;
+        bool   iSendFirewallPacketCallBkPending;
+
+        enum JB_NOTIFY_CALLBACK
+        {
+            JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED,
+            JB_NOTIFY_REPORT_BUFFERING_STATUS,
+            JB_BUFFERING_DURATION_COMPLETE,
+            JB_MONITOR_REBUFFERING,
+            JB_NOTIFY_SEND_FIREWALL_PACKET,
+            JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE  //OOO->Out Of Order
+        };
+
+        bool RequestEventCallBack(JB_NOTIFY_CALLBACK aEventType, uint32 aDelay = 0, OsclAny* aContext = NULL);
+        bool RequestCallBack(PVMFMediaClockNotificationsInterface *& aEventNotificationInterface, uint32 aDelay, uint32& aCallBkId, bool& aCallBackStatusPending, OsclAny* aContext = NULL);
+        void CancelEventCallBack(JB_NOTIFY_CALLBACK aEventType, OsclAny* aContext = NULL);
+        void CancelCallBack(PVMFMediaClockNotificationsInterface *& aEventNotificationInterface, uint32& aCallBkId, bool& aCallBackStatusPending);
+        bool IsCallbackPending(JB_NOTIFY_CALLBACK aEventType, OsclAny* aContext = NULL);
+        void ProcessCallBack(uint32, PVTimeComparisonUtils::MediaTimeStatus, uint32, const OsclAny*, PVMFStatus);
+
+        void HandleEvent_IncomingMediaInactivityDurationExpired();
+        void HandleEvent_NotifyReportBufferingStatus();
+        void HandleEvent_JitterBufferBufferingDurationComplete();
+        void HandleEvent_MonitorReBuffering();
+        void HandleEvent_NotifySendFirewallPacket();
+        void HandleEvent_NotifyWaitForOOOPacketComplete(OsclAny* aContext);
+};
 #endif
 
 
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_port.h b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_port.h
index b227bc0..97ccd50 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_port.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_jitter_buffer_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
  * -------------------------------------------------------------------
  */
 /**
- * @file pvmf_jitter_buffer_port.h
- */
+* @file pvmf_jitter_buffer_port.h
+*/
 #ifndef PVMF_JITTER_BUFFER_PORT_H_INCLUDED
 #define PVMF_JITTER_BUFFER_PORT_H_INCLUDED
 
@@ -107,6 +107,7 @@
             iMediaDataAlloc = NULL;
             iMediaDataImplAlloc = NULL;
             iMediaMsgAlloc = NULL;
+            iBufferAlloc = NULL;
             oFireWallPacketRecvd = false;
             iFireWallPacketCount = 0;
             SSRC = 0;
@@ -123,6 +124,9 @@
 
             RtcpBwConfigured = false;
             eTransportType = PVMF_JITTER_BUFFER_PORT_TRANSPORT_TYPE_UNKNOWN;
+
+            iWaitForOOOPacketCallBkId = 0;
+            iWaitForOOOPacketCallBkPending = false;
         };
 
         ~PVMFJitterBufferPortParams()
@@ -140,12 +144,44 @@
             bTransportHeaderPreParsed = false;
             RtcpBwConfigured = false;
             avg_rtcp_size = 0.0;
+            iJitterBufferMemPoolInfo.Init();
         };
 
         int32                       id;
         PVMFJitterBufferNodePortTag tag;
         PVMFPortInterface* iPort;
         PVMFJitterBuffer*  iJitterBuffer;
+        class JitterBufferMemPoolInfo
+        {
+            public:
+                JitterBufferMemPoolInfo(): iSize(0), iResizeSize(0), iMaxNumResizes(0), iExpectedNumberOfBlocksPerBuffer(0) {}
+                void Init(uint32 aSize = 0, uint32 aExpectedNumberOfBlocksPerBuffer = 0, uint32 aResizeSize = 0, uint32 aMaxNumResizes = 0)
+                {
+                    iSize = aSize;
+                    iResizeSize = aResizeSize;
+                    iMaxNumResizes = aMaxNumResizes;
+                    iExpectedNumberOfBlocksPerBuffer = aExpectedNumberOfBlocksPerBuffer;
+                }
+                uint32 iSize;
+                uint32 iResizeSize;
+                uint32 iMaxNumResizes;
+                uint32 iExpectedNumberOfBlocksPerBuffer;
+        };
+        JitterBufferMemPoolInfo iJitterBufferMemPoolInfo;
+
+        void SetJitterBufferMemPoolInfo(uint32 aSize, uint32 aResizeSize, uint32 aMaxNumResizes, uint32 aExpectedNumberOfBlocksPerBuffer)
+        {
+            iJitterBufferMemPoolInfo.Init(aSize, aResizeSize, aMaxNumResizes, aExpectedNumberOfBlocksPerBuffer);
+        }
+
+        void GetJitterBufferMemPoolInfo(uint32& aSize, uint32& aResizeSize, uint32& aMaxNumResizes, uint32& aExpectedNumberOfBlocksPerBuffer) const
+        {
+            aSize = iJitterBufferMemPoolInfo.iSize;
+            aResizeSize = iJitterBufferMemPoolInfo.iResizeSize;
+            aMaxNumResizes = iJitterBufferMemPoolInfo.iMaxNumResizes;
+            aExpectedNumberOfBlocksPerBuffer = iJitterBufferMemPoolInfo.iExpectedNumberOfBlocksPerBuffer;
+        }
+
         uint32             timeScale;
         uint32             bitrate;
         MediaClockConverter mediaClockConverter;
@@ -180,6 +216,7 @@
         PVMFSimpleMediaBufferCombinedAlloc* iMediaDataImplAlloc;
         /* Memory pool for simple media data */
         OsclMemPoolFixedChunkAllocator *iMediaMsgAlloc;
+        OsclMemPoolResizableAllocator* iBufferAlloc;
         bool oFireWallPacketRecvd;
         uint32 iFireWallPacketCount;
         uint32 SSRC;
@@ -194,6 +231,10 @@
         float avg_rtcp_size;
         uint32 iRTCPIntervalInMicroSeconds;
         PvmfRtcpTimer* iRTCPTimer;
+        //There may be OOO packets in the jitter buffer associated with the port.
+        //We wait for some time for the missing packet before forwarding the available packet out of thr Jitter Buffer
+        uint32 iWaitForOOOPacketCallBkId;
+        bool   iWaitForOOOPacketCallBkPending;
 
 };
 
@@ -301,10 +342,6 @@
             return 0;
         }
 
-        void createPortAllocators(OSCL_String& aMimeType, uint32 aSizeInBytes);
-        void createPortAllocators(OSCL_String& aMimeType, uint32 aSizeInBytes,
-                                  uint maxNumResizes, uint resizeSize);
-
         OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> getPortDataAlloc()
         {
             return iPortDataAlloc;
@@ -333,7 +370,6 @@
         // Parameters of port paired with current port (e.g. iPortCounterpart)
         PVMFJitterBufferPortParams* iCounterpartPortParams;
 
-
         //overrides from PVMFPortInterface
         PVMFStatus QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg);
         bool IsOutgoingQueueBusy();
@@ -344,11 +380,6 @@
         void pvmiSetPortAllocatorSync(PvmiCapabilityAndConfig *aPort,
                                       const char* aFormatValType);
 
-        void createSocketDataAllocReSize(OSCL_String& aMimeType, int32 size,
-                                         bool userParams = false,
-                                         uint maxNumResizes = 0,
-                                         uint resizeSize = 0);
-
         PVMFSocketBufferAllocator* iBufferNoResizeAlloc;
         PVMFSMSharedBufferAllocWithReSize* iBufferAlloc;
         OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> iPortDataAlloc;
diff --git a/nodes/streaming/jitterbuffernode/include/pvmf_rtcp_timer.h b/nodes/streaming/jitterbuffernode/include/pvmf_rtcp_timer.h
index a21021c..3493ef2 100644
--- a/nodes/streaming/jitterbuffernode/include/pvmf_rtcp_timer.h
+++ b/nodes/streaming/jitterbuffernode/include/pvmf_rtcp_timer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,10 +56,18 @@
 {
     public:
         PVMFRTCPMemPool(uint32 aNumRTCPBufs = DEFAULT_RTCP_MEM_POOL_BUFFERS)
-                : iMediaDataMemPool(aNumRTCPBufs, PVMF_MEDIA_DATA_CLASS_SIZE)
         {
+            iMediaDataMemPool = NULL;
+            iMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (aNumRTCPBufs, PVMF_MEDIA_DATA_CLASS_SIZE));
         }
 
+        ~PVMFRTCPMemPool()
+        {
+            if (iMediaDataMemPool)
+            {
+                iMediaDataMemPool->removeRef();
+            }
+        }
         OsclSharedPtr<PVMFMediaDataImpl> getMediaDataImpl(uint32 size)
         {
             return (iRTCPRRMsgBufAlloc->createSharedBuffer(size));
@@ -67,7 +75,7 @@
 
         OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> iRTCPRRMsgBufAlloc;
         /* Memory pool for media data objects */
-        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
+        OsclMemPoolFixedChunkAllocator* iMediaDataMemPool;
 };
 
 class PVMFRTCPStats
@@ -80,7 +88,7 @@
             lastSenderReportTS = 0;
             lastSenderReportRecvTime = 0;
             packetLossUptoThisRR = 0;
-            maxSeqNumRecievedUptoThisRR = 0;
+            maxSeqNumReceivedUptoThisRR = 0;
             lastRRGenTime = 0;
             oSRRecvd = false;
             oRTCPByeRecvd = false;
@@ -93,7 +101,7 @@
             lastSenderReportTS = aSrc.lastSenderReportTS;
             lastSenderReportRecvTime = aSrc.lastSenderReportRecvTime;
             packetLossUptoThisRR = aSrc.packetLossUptoThisRR;
-            maxSeqNumRecievedUptoThisRR = aSrc.maxSeqNumRecievedUptoThisRR;
+            maxSeqNumReceivedUptoThisRR = aSrc.maxSeqNumReceivedUptoThisRR;
             lastRRGenTime = aSrc.lastRRGenTime;
             oSRRecvd = aSrc.oSRRecvd;
             oRTCPByeRecvd = aSrc.oRTCPByeRecvd;
@@ -108,7 +116,7 @@
                 lastSenderReportTS = a.lastSenderReportTS;
                 lastSenderReportRecvTime = a.lastSenderReportRecvTime;
                 packetLossUptoThisRR = a.packetLossUptoThisRR;
-                maxSeqNumRecievedUptoThisRR = a.maxSeqNumRecievedUptoThisRR;
+                maxSeqNumReceivedUptoThisRR = a.maxSeqNumReceivedUptoThisRR;
                 lastRRGenTime = a.lastRRGenTime;
                 oSRRecvd = a.oSRRecvd;
                 oRTCPByeRecvd = a.oRTCPByeRecvd;
@@ -122,7 +130,7 @@
         uint32	lastSenderReportTS;
         uint64	lastSenderReportRecvTime;
         int32	packetLossUptoThisRR;
-        int32   maxSeqNumRecievedUptoThisRR;
+        int32   maxSeqNumReceivedUptoThisRR;
         uint64	lastRRGenTime;
         bool    oSRRecvd;
         bool    oRTCPByeRecvd;
diff --git a/nodes/streaming/jitterbuffernode/src/pvmf_jb_inactivity_timer.cpp b/nodes/streaming/jitterbuffernode/src/pvmf_jb_inactivity_timer.cpp
index d863a8e..0c8ca96 100644
--- a/nodes/streaming/jitterbuffernode/src/pvmf_jb_inactivity_timer.cpp
+++ b/nodes/streaming/jitterbuffernode/src/pvmf_jb_inactivity_timer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,77 +27,6 @@
 #endif
 
 ////////////////////////////////////////////////////////////////////////////
-PvmfJBInactivityTimer::PvmfJBInactivityTimer(PvmfJBInactivityTimerObserver* aObserver)
-        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmfJBInactivityTimer"),
-        iInactivityDurationInMS(DEFAULT_MAX_INACTIVITY_DURATION_IN_MS),
-        iObserver(aObserver),
-        iStarted(false)
-{
-    iLogger = PVLogger::GetLoggerObject("PvmfJBInactivityTimer");
-    AddToScheduler();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfJBInactivityTimer::~PvmfJBInactivityTimer()
-{
-    Stop();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfJBInactivityTimer::Start()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBInactivityTimer::Start"));
-    if (iInactivityDurationInMS > 0)
-    {
-        RunIfNotReady(iInactivityDurationInMS*1000);
-        iStarted = true;
-        return PVMFSuccess;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfJBInactivityTimer::setMaxInactivityDurationInMS(uint32 duration)
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBInactivityTimer::setMaxInactivityDurationInMS"));
-    iInactivityDurationInMS = duration;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfJBInactivityTimer::Stop()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBInactivityTimer::Stop"));
-    Cancel();
-    iStarted = false;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfJBInactivityTimer::Run()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBInactivityTimer::Run"));
-
-    if (!iStarted)
-        return;
-
-    if (!iObserver)
-    {
-        PVMF_JBNODE_LOGERROR((0, "PvmfJBInactivityTimer::Run: Error - Observer not set"));
-        return;
-    }
-
-    iObserver->PVMFJBInactivityTimerEvent();
-    /*
-     * Do not reschudule the AO here. Observer would reschedule this AO
-     * once it is done processing the timer event.
-     */
-}
-
-////////////////////////////////////////////////////////////////////////////
 PvmfJBSessionDurationTimer::PvmfJBSessionDurationTimer(PvmfJBSessionDurationTimerObserver* aObserver)
         : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmfJBSessionDurationTimer"),
         iCurrentMonitoringIntervalInMS(0),
@@ -133,21 +62,23 @@
     {
         PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::Start - SessionDurationInMS = %d", iSessionDurationInMS));
         iClock.Start();
-        uint64 timebase64 = 0;
+        uint32 timebase32 = 0;
         iTimerStartTimeInMS = 0;
         iMonitoringIntervalElapsed = 0;
-        iClock.GetCurrentTime64(iTimerStartTimeInMS, OSCLCLOCK_MSEC, timebase64);
+        bool overflowFlag = false;
+        iClock.GetCurrentTime32(iTimerStartTimeInMS, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
         /* Compute expected estimated serv clock value when duration expires */
         if (iEstimatedServerClock != NULL)
         {
             iExpectedEstimatedServClockValAtSessionEnd = iEstimatedServClockValAtLastCancel;
-            uint32 currEstServClk32 = Oscl_Int64_Utils::get_uint64_lower32(iExpectedEstimatedServClockValAtSessionEnd);
+            uint32 currEstServClk32;
+            currEstServClk32 = iExpectedEstimatedServClockValAtSessionEnd;
             PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::Start - CurrEstServClock  = %d", currEstServClk32));
-            uint64 remainingSessionDuration64 = 0;
-            Oscl_Int64_Utils::set_uint64(remainingSessionDuration64, 0, (iSessionDurationInMS - iElapsedSessionDurationInMS));
-            iExpectedEstimatedServClockValAtSessionEnd += remainingSessionDuration64;
-            uint32 eVal32 = Oscl_Int64_Utils::get_uint64_lower32(iExpectedEstimatedServClockValAtSessionEnd);
-            PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::Start - ExpectedEstimatedServClockValAtSessionEnd = %d", eVal32));
+            uint32 remainingSessionDuration32 = 0;
+            remainingSessionDuration32 = iSessionDurationInMS - iElapsedSessionDurationInMS;
+            iExpectedEstimatedServClockValAtSessionEnd += remainingSessionDuration32;
+
+            PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::Start - ExpectedEstimatedServClockValAtSessionEnd = %d", iExpectedEstimatedServClockValAtSessionEnd));
         }
         RunIfNotReady(iCurrentMonitoringIntervalInMS*1000);
         iStarted = true;
@@ -186,18 +117,20 @@
 {
     PVMF_JBNODE_LOGINFO((0, "PvmfJBSessionDurationTimer::Cancel"));
     iStarted = false;
-    uint64 timebase64 = 0;
-    uint64 cancelTime = 0;
-    iClock.GetCurrentTime64(cancelTime, OSCLCLOCK_MSEC, timebase64);
+    uint32 timebase32 = 0;
+    uint32 cancelTime = 0;
+    bool overflowFlag = false;
+    iClock.GetCurrentTime32(cancelTime, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     iMonitoringIntervalElapsed = (cancelTime - iTimerStartTimeInMS);
     iEstimatedServClockValAtLastCancel = 0;
     if (iEstimatedServerClock != NULL)
     {
-        uint64 timebase64 = 0;
-        iEstimatedServerClock->GetCurrentTime64(iEstimatedServClockValAtLastCancel, OSCLCLOCK_MSEC, timebase64);
+        uint32 timebase32 = 0;
+        iEstimatedServerClock->GetCurrentTime32(iEstimatedServClockValAtLastCancel, overflowFlag,
+                                                PVMF_MEDIA_CLOCK_MSEC, timebase32);
     }
-    uint32 eVal32 = Oscl_Int64_Utils::get_uint64_lower32(iEstimatedServClockValAtLastCancel);
-    PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::Cancel - EstimatedServClockValAtLastCancel = %d", eVal32));
+
+    PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::Cancel - EstimatedServClockValAtLastCancel = %d", iEstimatedServClockValAtLastCancel));
     iClock.Stop();
     iTimerStartTimeInMS = 0;
     OsclTimerObject::Cancel();
@@ -212,9 +145,12 @@
      */
     if (iEstimatedServerClock != NULL)
     {
-        uint64 timebase64 = 0;
-        uint64 estServClock = 0;
-        iEstimatedServerClock->GetCurrentTime64(estServClock, OSCLCLOCK_MSEC, timebase64);
+        uint32 timebase32 = 0;
+        uint32 estServClock = 0;
+        bool overflowFlag = false;
+
+        iEstimatedServerClock->GetCurrentTime32(estServClock, overflowFlag,
+                                                PVMF_MEDIA_CLOCK_MSEC, timebase32);
         PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::EstimatedServerClockUpdated - CurrEstServClock = %2d", estServClock));
         PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PvmfJBSessionDurationTimer::EstimatedServerClockUpdated - ExpectedEstServClock = %2d", iExpectedEstimatedServClockValAtSessionEnd));
         if (estServClock >= iExpectedEstimatedServClockValAtSessionEnd)
@@ -239,9 +175,11 @@
         return;
     }
 
-    uint64 timebase64 = 0;
-    uint64 cancelTime = 0;
-    iClock.GetCurrentTime64(cancelTime, OSCLCLOCK_MSEC, timebase64);
+    uint32 timebase32 = 0;
+    uint32 cancelTime = 0;
+    bool overflowFlag = false;
+
+    iClock.GetCurrentTime32(cancelTime, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     iMonitoringIntervalElapsed = (cancelTime - iTimerStartTimeInMS);
     iClock.Stop();
     iTimerStartTimeInMS = 0;
@@ -252,202 +190,3 @@
      */
 }
 
-////////////////////////////////////////////////////////////////////////////
-PvmfJBJitterBufferDurationTimer::PvmfJBJitterBufferDurationTimer(PvmfJBJitterBufferDurationTimerObserver* aObserver)
-        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmfJBJitterBufferDurationTimer"),
-        iJitterBufferDurationInMS(0),
-        iObserver(aObserver),
-        iStarted(false)
-{
-    iLogger = PVLogger::GetLoggerObject("PvmfJBJitterBufferDurationTimer");
-    AddToScheduler();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfJBJitterBufferDurationTimer::~PvmfJBJitterBufferDurationTimer()
-{
-    Stop();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfJBJitterBufferDurationTimer::Start()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBJitterBufferDurationTimer::Start"));
-    if (iJitterBufferDurationInMS > 0)
-    {
-        RunIfNotReady(iJitterBufferDurationInMS*1000);
-        uint32 startTime = 0;
-
-        // setup timer
-        iRunClock.Stop();
-        bool result = iRunClock.SetStartTime32(startTime, OSCLCLOCK_USEC);
-        OSCL_ASSERT(result);
-        result = iRunClock.Start();
-        OSCL_ASSERT(result);
-
-        iStarted = true;
-        return PVMFSuccess;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfJBJitterBufferDurationTimer::setJitterBufferDurationInMS(uint32 duration)
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBSessionDurationTimer::setJitterBufferDurationInMS"));
-
-    if (iStarted)
-    {
-        // we're running... we can only DECREASE the jitter buffer value
-        if (duration > iJitterBufferDurationInMS)
-        {
-            PVMF_JBNODE_LOGINFO(
-                (0, "PvmfJBSessionDurationTimer::setJitterBufferDurationInMS: "
-                 "Attempting to increase timer value while running. %d to %d ms.",
-                 iJitterBufferDurationInMS, duration));
-
-            return PVMFFailure;
-        }
-
-        // get the current time in us
-        uint32 currtime;
-        bool overflow = false;
-        iRunClock.GetCurrentTime32(currtime, overflow, OSCLCLOCK_USEC);
-        OSCL_ASSERT(!overflow);  // if the time elapsed is > 32bits, something is wrong
-
-        // compare against the new duration
-        uint32 durationUs = duration * 1000; // save a multiply
-        if (durationUs > currtime)
-        {
-            // set a new Run for the outstanding balance
-            Cancel();
-            RunIfNotReady(durationUs - currtime);
-        }
-        else
-        {
-            // the new duration has already elapsed - schedule a Run immediately
-            RunIfNotReady();
-        }
-    }
-
-    // save the new duration
-    iJitterBufferDurationInMS = duration;
-
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfJBJitterBufferDurationTimer::Stop()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBJitterBufferDurationTimer::Stop"));
-    Cancel();
-
-    if (iStarted)
-    {
-        bool result = iRunClock.Stop();
-        OSCL_UNUSED_ARG(result);
-        OSCL_ASSERT(result);
-    }
-
-    iStarted = false;
-    iJitterBufferDurationInMS = 0;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfJBJitterBufferDurationTimer::Run()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfJBJitterBufferDurationTimer::Run"));
-
-    if (!iStarted)
-        return;
-
-    if (!iObserver)
-    {
-        PVMF_JBNODE_LOGERROR((0, "PvmfJBJitterBufferDurationTimer::Run: Error - Observer not set"));
-        return;
-    }
-
-    bool result;
-    result = iRunClock.Stop();
-    OSCL_ASSERT(result);
-    iStarted = false;
-
-    iObserver->PVMFJBJitterBufferDurationTimerEvent();
-    /*
-     * Do not reschudule the AO here. Observer would reschedule this AO
-     * once it is done processing the timer event.
-     */
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfFirewallPacketTimer::PvmfFirewallPacketTimer(PvmfFirewallPacketTimerObserver* aObserver)
-        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmfFirewallPacketTimer"),
-        iFirewallPacketRecvTimeOutInMS(0),
-        iObserver(aObserver),
-        iStarted(false)
-{
-    iLogger = PVLogger::GetLoggerObject("PvmfFirewallPacketTimer");
-    AddToScheduler();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PvmfFirewallPacketTimer::~PvmfFirewallPacketTimer()
-{
-    Stop();
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfFirewallPacketTimer::Start()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfFirewallPacketTimer::Start"));
-    iStarted = true;
-    if (iFirewallPacketRecvTimeOutInMS > 0)
-    {
-        RunIfNotReady(iFirewallPacketRecvTimeOutInMS*1000);
-    }
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfFirewallPacketTimer::setFirewallPacketRecvTimeOutInMS(uint32 aRecvTimeOut)
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfFirewallPacketTimer::setFirewallPacketRecvTimeOutInMS"));
-    iFirewallPacketRecvTimeOutInMS = aRecvTimeOut;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-PVMFStatus PvmfFirewallPacketTimer::Stop()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfFirewallPacketTimer::Stop"));
-    Cancel();
-    iStarted = false;
-    iFirewallPacketRecvTimeOutInMS = 0;
-    return PVMFSuccess;
-}
-
-////////////////////////////////////////////////////////////////////////////
-void PvmfFirewallPacketTimer::Run()
-{
-    PVMF_JBNODE_LOGINFO((0, "PvmfFirewallPacketTimer::Run"));
-
-    if (!iStarted)
-        return;
-
-    if (!iObserver)
-    {
-        PVMF_JBNODE_LOGERROR((0, "PvmfFirewallPacketTimer::Run: Error - Observer not set"));
-        return;
-    }
-
-    iObserver->PvmfFirewallPacketTimerEvent();
-    /*
-     * Do not reschudule the AO here. Observer would reschedule this AO
-     * once it is done processing the timer event.
-     */
-}
-
diff --git a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_extension_interface.cpp b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_extension_interface.cpp
index b6fd005..c8a364e 100644
--- a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_extension_interface.cpp
+++ b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_extension_interface.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -80,12 +80,36 @@
 }
 
 OSCL_EXPORT_REF
-void PVMFJitterBufferExtensionInterfaceImpl::setClientPlayBackClock(OsclClock* clientClock)
+void PVMFJitterBufferExtensionInterfaceImpl::setEarlyDecodingTimeInMilliSeconds(uint32 duration)
+{
+    OSCL_UNUSED_ARG(duration);
+}
+
+OSCL_EXPORT_REF
+void PVMFJitterBufferExtensionInterfaceImpl::setBurstThreshold(float burstThreshold)
+{
+    OSCL_UNUSED_ARG(burstThreshold);
+}
+
+OSCL_EXPORT_REF
+void PVMFJitterBufferExtensionInterfaceImpl::setClientPlayBackClock(PVMFMediaClock* clientClock)
 {
     iContainer->setClientPlayBackClock(clientClock);
 }
 
 OSCL_EXPORT_REF
+void PVMFJitterBufferExtensionInterfaceImpl::setMaxInactivityDurationForMediaInMs(uint32 duration)
+{
+    iContainer->setMaxInactivityDurationForMediaInMs(duration);
+}
+
+OSCL_EXPORT_REF
+void PVMFJitterBufferExtensionInterfaceImpl::getMaxInactivityDurationForMediaInMs(uint32& duration)
+{
+    iContainer->getMaxInactivityDurationForMediaInMs(duration);
+}
+
+OSCL_EXPORT_REF
 void PVMFJitterBufferExtensionInterfaceImpl::setRTCPIntervalInMicroSecs(uint32 aRTCPInterval)
 {
     iContainer->setRTCPIntervalInMicroSecs(aRTCPInterval);
@@ -123,6 +147,7 @@
         uint32 aSeqNumBase,
         bool   aRTPTimeBasePresent,
         uint32 aRTPTimeBase,
+        bool   aNPTTimeBasePresent,
         uint32 aNPTInMS,
         bool oPlayAfterASeek)
 {
@@ -131,6 +156,7 @@
                                          aSeqNumBase,
                                          aRTPTimeBasePresent,
                                          aRTPTimeBase,
+                                         aNPTTimeBasePresent,
                                          aNPTInMS,
                                          oPlayAfterASeek));
 }
@@ -150,6 +176,12 @@
     return (iContainer->getActualMediaDataTSAfterSeek());
 }
 
+OSCL_EXPORT_REF
+PVMFTimestamp PVMFJitterBufferExtensionInterfaceImpl::getMaxMediaDataTS()
+{
+    return (iContainer->getMaxMediaDataTS());
+}
+
 OSCL_EXPORT_REF PVMFStatus
 PVMFJitterBufferExtensionInterfaceImpl::setServerInfo(PVMFJitterBufferFireWallPacketInfo& aServerInfo)
 {
@@ -168,12 +200,6 @@
     return (iContainer->SendBOSMessage(aStreamID));
 }
 
-OSCL_EXPORT_REF OsclSharedPtr<PVMFSharedSocketDataBufferAlloc>
-PVMFJitterBufferExtensionInterfaceImpl::CreateResizablePortAllocator(uint32 aSize, OSCL_String& aName)
-{
-    return (iContainer->CreateResizablePortAllocator(aSize, aName));
-}
-
 OSCL_EXPORT_REF void
 PVMFJitterBufferExtensionInterfaceImpl::SetSharedBufferResizeParams(uint32 maxNumResizes, uint32 resizeSize)
 {
@@ -185,12 +211,19 @@
 {
     iContainer->GetSharedBufferResizeParams(maxNumResizes, resizeSize);
 }
+
 OSCL_EXPORT_REF bool
 PVMFJitterBufferExtensionInterfaceImpl::ClearJitterBuffer(PVMFPortInterface* aPort, uint32 aSeqNum)
 {
     return (iContainer->ClearJitterBuffer(aPort, aSeqNum));
 }
 
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::FlushJitterBuffer()
+{
+    iContainer->FlushJitterBuffer();
+}
+
 OSCL_EXPORT_REF bool
 PVMFJitterBufferExtensionInterfaceImpl::NotifyAutoPauseComplete()
 {
@@ -230,18 +263,43 @@
 {
     iContainer->DisableFireWallPackets();
 }
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::StartOutputPorts()
+{
+    iContainer->StartOutputPorts();
+}
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::StopOutputPorts()
+{
+    iContainer->StopOutputPorts();
+}
 
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::UpdateJitterBufferState()
+{
+    iContainer->UpdateJitterBufferState();
+}
 
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::SetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32 aSize, uint32 aResizeSize, uint32 aMaxNumResizes, uint32 aExpectedNumberOfBlocksPerBuffer)
+{
+    iContainer->SetJitterBufferMemPoolInfo(aPort, aSize, aResizeSize, aMaxNumResizes, aExpectedNumberOfBlocksPerBuffer);
+}
 
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::GetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32& aSize, uint32& aResizeSize, uint32& aMaxNumResizes, uint32& aExpectedNumberOfBlocksPerBuffer) const
+{
+    iContainer->GetJitterBufferMemPoolInfo(aPort, aSize, aResizeSize, aMaxNumResizes, aExpectedNumberOfBlocksPerBuffer);
+}
 
+OSCL_EXPORT_REF void
+PVMFJitterBufferExtensionInterfaceImpl::SetJitterBufferChunkAllocator(OsclMemPoolResizableAllocator* aDataBufferAllocator, const PVMFPortInterface* aPort)
+{
+    iContainer->SetJitterBufferChunkAllocator(aDataBufferAllocator, aPort);
+}
 
-
-
-
-
-
-
-
-
-
-
+OSCL_EXPORT_REF bool
+PVMFJitterBufferExtensionInterfaceImpl::PrepareForPlaylistSwitch()
+{
+    return (iContainer->PrepareForPlaylistSwitch());
+}
diff --git a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_impl.cpp b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_impl.cpp
index 9b18e88..9cf47a3 100644
--- a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_impl.cpp
+++ b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,10 +77,19 @@
     iPrevPacketTS = 0;
     iPrevPacketRecvTime = 0;
 
+    iPlayListRTPTimeBaseSet = false;
+    iPlayListRTPTimeBase = 0;
+
+    isPrevNptTimeSet = false;
+    isPrevRtpTimeSet = false;
+    iPrevNptTimeInRTPTimeScale = 0;
+    iPrevRtpTimeBase = 0;
+
     iLogger = PVLogger::GetLoggerObject("JitterBuffer");
     iDataPathLoggerIn = PVLogger::GetLoggerObject("datapath.sourcenode.jitterbuffer.in");
     iDataPathLoggerOut = PVLogger::GetLoggerObject("datapath.sourcenode.jitterbuffer.out");
     iClockLogger = PVLogger::GetLoggerObject("clock.jitterbuffer");
+    iClockLoggerRebuff = PVLogger::GetLoggerObject("clock.jitterbuffernode.rebuffer");
 
     iHeaderFormat = PVMF_JITTER_BUFFER_TRANSPORT_HEADER_FORMAT_UNKNOWN;
     iSeqNum = 0;
@@ -94,8 +103,8 @@
     }
     iBroadCastSession = false;
 
-    OsclExclusivePtr<OsclClock> arrivalClockAutoPtr;
-    PVMF_JITTER_BUFFER_NEW(NULL, OsclClock, (), iPacketArrivalClock);
+    OsclExclusivePtr<PVMFMediaClock> arrivalClockAutoPtr;
+    PVMF_JITTER_BUFFER_NEW(NULL, PVMFMediaClock, (), iPacketArrivalClock);
     arrivalClockAutoPtr.set(iPacketArrivalClock);
 
     uint32 numNodes = 0;
@@ -168,11 +177,12 @@
     iDataPathLoggerIn = NULL;
     iDataPathLoggerOut = NULL;
     iClockLogger = NULL;
+    iClockLoggerRebuff = NULL;
     iPacketArrivalClock->Stop();
     iServerClockUpdateNotificationObserver = NULL;
 
     PVMF_JITTER_BUFFER_TEMPLATED_DELETE(NULL, PVMFDynamicCircularArray<PVMFJitterBufferNodeAllocator>, PVMFDynamicCircularArray, iJitterBuffer);
-    PVMF_JITTER_BUFFER_DELETE(NULL, OsclClock, iPacketArrivalClock);
+    PVMF_JITTER_BUFFER_DELETE(NULL, PVMFMediaClock, iPacketArrivalClock);
 
     if (iInPlaceProcessing == false)
     {
@@ -202,12 +212,21 @@
     iJitterBuffer->ResetJitterBufferStats();
     oEOS = false;
     iRTPInfoParamsVec.clear();
-    seqNumLock = false;
+    iPlayListRTPTimeBaseSet = false;
+    iPlayListRTPTimeBase = 0;
+    if (iHeaderFormat != PVMF_JITTER_BUFFER_TRANSPORT_HEADER_ASF)
+    {
+        seqNumLock = false;
+    }
     iMonotonicTimeStamp = 0;
     iPrevPacketTS = 0;
     iPrevTSOut = 0;
     iSeqNum = 0;
     iMaxAdjustedRTPTS = 0;
+    isPrevNptTimeSet = false;
+    iPrevNptTimeInRTPTimeScale = 0;
+    isPrevRtpTimeSet = false;
+    iPrevRtpTimeBase = 0;
     UpdateEstimatedServerClockDiscrete(true);
     iFirstASFPacketAfterRepos = true;
 }
@@ -238,7 +257,7 @@
             status = iJitterBuffer->addElement(dataPacket, iFirstSeqNum);
             if (status == PVMF_JITTER_BUFFER_ADD_ELEM_SUCCESS)
             {
-                PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::addPacket: MimeType=%s TS=%d, SEQNUM= %d",
+                PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::addPacket: MimeType=%s TS=%u, SEQNUM= %d",
                                                iMimeType.get_cstr(), dataPacket->getTimestamp(), dataPacket->getSeqNum()));
 
                 if (iRTPInfoParamsVec.size() > 0)
@@ -251,8 +270,20 @@
                     ComputeMaxAdjustedRTPTS();
                 }
             }
+            else if (status == PVMF_JITTER_BUFFER_ADD_ELEM_ERR_LATE_PACKET)
+            {
+                PVMF_JBNODE_LOGDATATRAFFIC_IN_E((0, "PVMFJitterBufferImpl::addPacket - Late: MimeType=%s TS=%d, SEQNUM= %d",
+                                                 iMimeType.get_cstr(), dataPacket->getTimestamp(), dataPacket->getSeqNum()));
+            }
+            else if (status == PVMF_JITTER_BUFFER_ADD_ELEM_PACKET_OVERWRITE)
+            {
+                PVMF_JBNODE_LOGDATATRAFFIC_IN_E((0, "PVMFJitterBufferImpl::addPacket - OverWrite: MimeType=%s TS=%d, SEQNUM= %d",
+                                                 iMimeType.get_cstr(), dataPacket->getTimestamp(), dataPacket->getSeqNum()));
+            }
             else if (status == PVMF_JITTER_BUFFER_ADD_ELEM_UNEXPECTED_DATA)
             {
+                PVMF_JBNODE_LOGDATATRAFFIC_IN_E((0, "PVMFJitterBufferImpl::addPacket - Unexpected: MimeType=%s TS=%d, SEQNUM= %d",
+                                                 iMimeType.get_cstr(), dataPacket->getTimestamp(), dataPacket->getSeqNum()));
                 return PVMF_JITTER_BUFFER_ADD_PKT_UNEXPECTED_DATA;
             }
 
@@ -270,7 +301,7 @@
         // Add packet to temporary array
         iFirstDataPackets.push_back(dataPacket);
 
-        const uint cPktNeededForVote = 2;
+        const uint cPktNeededForVote = 5;
         if (iFirstDataPackets.size() < cPktNeededForVote)
             return PVMF_JITTER_BUFFER_ADD_PKT_SUCCESS;
 
@@ -348,6 +379,11 @@
                 iFirstSeqNum = (it->seqNumBaseSet) ? it->seqNum : my_ssrc[first_ssrc_index][2];
                 seqLockTimeStamp = (it->rtpTimeBaseSet) ? it->rtpTime : my_ssrc[first_ssrc_index][3];
             }
+            else
+            {
+                iFirstSeqNum = my_ssrc[first_ssrc_index][2];
+                seqLockTimeStamp = my_ssrc[first_ssrc_index][3];
+            }
             // iFirstSeqNum must be initialized when we come here
             iJitterBuffer->setFirstSeqNumAdded(iFirstSeqNum);
             CheckForRTPTimeAndRTPSeqNumberBase();
@@ -453,15 +489,39 @@
     }
 }
 
+PVMFTimestamp PVMFJitterBufferImpl::peekMaxElementTimeStamp()
+{
+    if (iJitterBuffer->getNumElements() > 0)
+    {
+        PVMFTimestamp currTS;
+        PVMFTimestamp maxTS;
+        PVMFTimestamp prevTS;
+        uint32 aSeqNum;
+        iJitterBuffer->peekNextElementTimeStamp(currTS, aSeqNum);
+        DeterminePrevTimeStampPeek(aSeqNum, prevTS);
+        iJitterBuffer->peekMaxElementTimeStamp(maxTS, aSeqNum);
+        uint64 ts64 = iMonotonicTimeStamp;
+        ts64 += (maxTS - prevTS);
+        PVMFTimestamp adjTS =
+            (PVMFTimestamp)(Oscl_Int64_Utils::get_uint64_lower32(ts64));
+        return (adjTS);
+    }
+    else
+    {
+        PVMFTimestamp adjTS =
+            (PVMFTimestamp)(Oscl_Int64_Utils::get_uint64_lower32(iMonotonicTimeStamp));
+        return (adjTS);
+    }
+}
+
 void PVMFJitterBufferImpl::UpdateInterArrivalJitter(PVMFTimestamp currPacketTS)
 {
     /* D(i-1,i) = (RecvT(i) - RTP_TS(i)) -
     			  (RecvT(i-1) - RTP_TS(i-1)) */
-    uint64 currPacketRecvTime;
-    iPacketArrivalClock->GetCurrentTime64(currPacketRecvTime,
-                                          OSCLCLOCK_MSEC);
-    uint32 currPacketRecvTime32 =
-        Oscl_Int64_Utils::get_uint64_lower32(currPacketRecvTime);
+    uint32 currPacketRecvTime32;
+    bool overflowFlag = false;
+    iPacketArrivalClock->GetCurrentTime32(currPacketRecvTime32, overflowFlag,
+                                          PVMF_MEDIA_CLOCK_MSEC);
 
     int32 ts_diff = currPacketTS - iPrevPacketTS;
     int32 arrival_diff = currPacketRecvTime32 - iPrevPacketRecvTime;
@@ -615,11 +675,11 @@
     if (iInPlaceProcessing == false)
     {
         OsclSharedPtr<PVMFMediaDataImpl> mediaDataOut;
-        int32 err;
-        OSCL_TRY(err,
-                 mediaDataOut = iMediaDataGroupAlloc->allocate());
+        PVMFStatus status;
 
-        if (err != OsclErrNone)
+        status = Allocate(mediaDataOut);
+
+        if (status == false)
         {
             PVMF_JBNODE_LOGERROR((0, "0x%x PVMFJitterBufferImpl::ParseRTPHeader: Jitter Buffer Full", this));
             return false;
@@ -635,16 +695,17 @@
         if (mbit == 1) markerInfo |= PVMF_MEDIA_DATA_MARKER_INFO_M_BIT;
         mediaDataOut->setMarkerInfo(markerInfo);
 
-        OSCL_TRY(err,
-                 dataPacket = PVMFMediaData::createMediaData(mediaDataOut,
-                              iMediaMsgMemPool););
+        bool retVal;
 
-        if (err != OsclErrNone)
+        retVal = CreateMediaData(dataPacket, mediaDataOut);
+
+        if (retVal == false)
         {
             PVMF_JBNODE_LOGERROR((0, "0x%x PVMFJitterBufferImpl::ParseRTPHeader: Jitter Buffer Full", this));
             return false;
         }
 
+
         dataPacket->setTimestamp(rtpTimeStamp);
         dataPacket->setStreamID(SSRC);
         dataPacket->setSeqNum(seqNum);
@@ -664,12 +725,49 @@
         rtpPacket->setSeqNum(seqNum);
     }
 
-    PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::ParseRTPHeader: SSRC=%d, rtpSeqNum=%d, rtpTs=%d, rtpPacketLen=%d",
+    PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::ParseRTPHeader: SSRC=%u, rtpSeqNum=%d, rtpTs=%u, rtpPacketLen=%d",
                                    SSRC, seqNum, rtpTimeStamp, rtpPacketLen));
 
     return true;
 }
 
+bool PVMFJitterBufferImpl::CreateMediaData(PVMFSharedMediaDataPtr& dataPacket, OsclSharedPtr<PVMFMediaDataImpl>& mediaDataOut)
+{
+    int32 err;
+
+    OSCL_TRY(err,
+             dataPacket = PVMFMediaData::createMediaData(mediaDataOut,
+                          iMediaMsgMemPool););
+
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+
+    return true;
+}
+
+
+bool PVMFJitterBufferImpl::Allocate(OsclSharedPtr<PVMFMediaDataImpl>& mediaDataOut)
+{
+    int32 err;
+    OSCL_TRY(err,
+             mediaDataOut = iMediaDataGroupAlloc->allocate());
+
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+
+    // If there is no memory left return false
+    if (mediaDataOut.GetRep() == NULL)
+    {
+        return false;
+    }
+
+    return true;
+}
+
 
 void PVMFJitterBufferImpl::DeterminePrevTimeStampPeek(uint32 aSeqNum,
         PVMFTimestamp& aPrevTS)
@@ -738,10 +836,41 @@
         }
         if (rtpInfoParams->seqNum > iPrevSeqNumBaseOut)
         {
+            /* We need to adjust iMonotonicTimeStamp as well for resume */
+            if (rtpInfoParams->isPlayAfterPause && rtpInfoParams->nptTimeBaseSet && isPrevNptTimeSet && isPrevRtpTimeSet)
+            {
+                uint64 CurrNptTime, PrevNptTime;
+                Oscl_Int64_Utils::set_uint64(CurrNptTime, 0, rtpInfoParams->nptTimeInRTPTimeScale);
+                Oscl_Int64_Utils::set_uint64(PrevNptTime, 0, iPrevNptTimeInRTPTimeScale + iPrevTSOut - iPrevRtpTimeBase);
+                iMonotonicTimeStamp = iMonotonicTimeStamp + CurrNptTime - PrevNptTime;
+                PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::DeterminePrevTimeStamp: TS adjustment for resume"
+                                     "nptTimeInRTPTimeScale=%d, iPrevNptTimeInRTPTimeScale=%d, iPrevRtpTimeBase=%d, iPrevTSOut=%d", rtpInfoParams->nptTimeInRTPTimeScale, iPrevNptTimeInRTPTimeScale, iPrevRtpTimeBase, iPrevTSOut));
+            }
+            if (rtpInfoParams->nptTimeBaseSet)
+            {
+                iPrevNptTimeInRTPTimeScale = rtpInfoParams->nptTimeInRTPTimeScale;
+                isPrevNptTimeSet = true;
+            }
+            else
+            {
+                isPrevNptTimeSet = false;
+            }
+            if (rtpInfoParams->rtpTimeBaseSet)
+            {
+                iPrevRtpTimeBase = rtpInfoParams->rtpTime;
+                isPrevRtpTimeSet = true;
+            }
+            else
+            {
+                isPrevRtpTimeSet = false;
+            }
+            PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::DeterminePrevTimeStamp: TS update for "
+                                 "iPrevNptTimeInRTPTimeScale=%d, iPrevRtpTimeBase=%d", rtpInfoParams->nptTimeInRTPTimeScale, rtpInfoParams->rtpTime));
             iPrevSeqNumBaseOut = rtpInfoParams->seqNum;
             iPrevTSOut = rtpInfoParams->rtpTime;
         }
-        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::DeterminePrevTimeStamp: RTPInfoSeqNum=%d, iPrevSeqNumBaseOut=%d, iPrevTSOut=%d", rtpInfoParams->seqNum, iPrevSeqNumBaseOut, iPrevTSOut));
+        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::DeterminePrevTimeStamp: RTPInfoSeqNum=%d, iPrevSeqNumBaseOut=%d, iPrevTSOut=%u",
+                             rtpInfoParams->seqNum, iPrevSeqNumBaseOut, iPrevTSOut));
     }
 }
 
@@ -770,7 +899,7 @@
     iMaxAdjustedRTPTS += (aTS - iPrevAdjustedRTPTS);
     iPrevAdjustedRTPTS = aTS;
 
-    PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::ComputeMaxAdjustedRTPTS - maxTimeStampRegistered=%d, iPrevAdjustedRTPTS=%d, iMaxAdjustedRTPTS=%d, Mime=%s",
+    PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::ComputeMaxAdjustedRTPTS - maxTimeStampRegistered=%u, iPrevAdjustedRTPTS=%u, iMaxAdjustedRTPTS=%u, Mime=%s",
                          aTS, iPrevAdjustedRTPTS, iMaxAdjustedRTPTS, iMimeType.get_cstr()));
 
     UpdateEstimatedServerClock();
@@ -780,7 +909,7 @@
 PVMFJitterBufferImpl::PurgeElementsWithSeqNumsLessThan(uint32 aSeqNum,
         uint32 aPlayerClockMS)
 {
-    iJitterBuffer->PurgeElementsWithSeqNumsLessThan(aSeqNum);
+    iJitterBuffer->PurgeElementsWithSeqNumsLessThan(aSeqNum, iPrevSeqNumBaseOut);
 
     {
         iMaxAdjustedRTPTS =
@@ -790,7 +919,9 @@
          * at a later point, via the "AdjustRTPTimeStamp" API call from
          * jitter buffer node.
          */
+        OSCL_UNUSED_ARG(aPlayerClockMS);
     }
+
     PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::PurgeElementsWithSeqNumsLessThan - SeqNum=%d",
                                    aSeqNum));
 }
@@ -798,23 +929,33 @@
 void
 PVMFJitterBufferImpl::PurgeElementsWithTimestampLessThan(PVMFTimestamp aTS)
 {
-    PVMFRTPInfoParams* rtpInfoParams = FindRTPInfoParams(0x80000000);
-    PVMFTimestamp rtpTS = rtpInfoParams->rtpTime + aTS;
+    PVMFTimestamp rtpTS;
+    if (iPlayListRTPTimeBaseSet)
+    {
+        rtpTS = iPlayListRTPTimeBase + aTS;
+    }
+    else
+    {
+        rtpTS = aTS;
+    }
+
     iJitterBuffer->PurgeElementsWithTimestampLessThan(rtpTS);
     iMaxAdjustedRTPTS = aTS;
+    //iPrevAdjustedRTPTS = rtpTS;
     UpdateEstimatedServerClock(true);
-    iMonotonicTimeStamp += (rtpTS - iPrevTSOut);
+    iMonotonicTimeStamp = aTS;
     iPrevTSOut = rtpTS;
-    PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::PurgeElementsWithTimestampLessThan - ntpTS=%d, rtpTS=%d",
+    PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "PVMFJitterBufferImpl::PurgeElementsWithTimestampLessThan - ntpTS=%u, rtpTS=%u",
                                    aTS, rtpTS));
 }
 
 void PVMFJitterBufferImpl::UpdateEstimatedServerClock(bool oFreshStart)
 {
     uint32 rtpTSInMS;
-    uint64 currentTime64 = 0;
-    uint64 currentTimeBase64 = 0;
-    uint64 adjustTime64 = 0;
+    uint32 currentTime32 = 0;
+    uint32 currentTimeBase32 = 0;
+    uint32 adjustTime32 = 0;
+    bool overflowFlag = false;
 
     if (oFreshStart)
     {
@@ -822,38 +963,60 @@
         iEstServClockMediaClockConvertor.set_clock(iMaxAdjustedRTPTS, in_wrap_count);
         rtpTSInMS = iEstServClockMediaClockConvertor.get_converted_ts(1000);
         iEstimatedServerClock->Stop();
+
         iEstimatedServerClock->SetStartTime32(rtpTSInMS,
-                                              OSCLCLOCK_MSEC);
+                                              PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
         iEstimatedServerClock->Start();
-        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - Setting start time - MaxAdjustedRTPTS=%d, StartTime=%d",
+        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - Setting start time - MaxAdjustedRTPTS=%u, StartTime=%d",
                               iMaxAdjustedRTPTS, rtpTSInMS));
     }
     else
     {
         iEstServClockMediaClockConvertor.update_clock(iMaxAdjustedRTPTS);
         rtpTSInMS = iEstServClockMediaClockConvertor.get_converted_ts(1000);
-        Oscl_Int64_Utils::set_uint64(adjustTime64, 0, rtpTSInMS);
-        iEstimatedServerClock->GetCurrentTime64(currentTime64,
-                                                OSCLCLOCK_MSEC,
-                                                currentTimeBase64);
+        adjustTime32 = rtpTSInMS;
+        bool overflowFlag = false;
+        iEstimatedServerClock->GetCurrentTime32(currentTime32, overflowFlag,
+                                                PVMF_MEDIA_CLOCK_MSEC,
+                                                currentTimeBase32);
+        if (iHeaderFormat == PVMF_JITTER_BUFFER_TRANSPORT_HEADER_ASF)
         {
-            iEstimatedServerClock->AdjustClockTime64(currentTime64,
-                    currentTimeBase64,
-                    adjustTime64,
-                    OSCLCLOCK_MSEC);
+            if (currentTime32 > adjustTime32)
+            {
+                iEstimatedServerClock->Stop();
+                iEstimatedServerClock->SetStartTime32(adjustTime32, PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
+                iEstimatedServerClock->Start();
+            }
+            else
+            {
+
+                iEstimatedServerClock->AdjustClockTime32(currentTime32,
+                        currentTimeBase32,
+                        adjustTime32,
+                        PVMF_MEDIA_CLOCK_MSEC,
+                        overflowFlag);
+            }
         }
-        iEstimatedServerClock->GetCurrentTime64(currentTime64,
-                                                OSCLCLOCK_MSEC,
-                                                currentTimeBase64);
+        else
+        {
+            iEstimatedServerClock->AdjustClockTime32(currentTime32,
+                    currentTimeBase32,
+                    adjustTime32,
+                    PVMF_MEDIA_CLOCK_MSEC,
+                    overflowFlag);
+        }
+        iEstimatedServerClock->GetCurrentTime32(currentTime32, overflowFlag,
+                                                PVMF_MEDIA_CLOCK_MSEC,
+                                                currentTimeBase32);
 
         PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - Mime=%s",
                              iMimeType.get_cstr()));
-        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - EstServClock=%2d",
-                             currentTime64));
-        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - RTPTime64=%2d",
-                             adjustTime64));
-        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - Adjusting Clock - iMaxAdjustedRTPTS=%d, currentTimeBase64=%2d",
-                             iMaxAdjustedRTPTS, currentTimeBase64));
+        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - EstServClock=%d",
+                             currentTime32));
+        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - RTPTime32=%u",
+                             adjustTime32));
+        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - Adjusting Clock - iMaxAdjustedRTPTS=%u, currentTimeBase32=%d",
+                             iMaxAdjustedRTPTS, currentTimeBase32));
     }
     if (iServerClockUpdateNotificationObserver != NULL)
     {
@@ -864,9 +1027,10 @@
 void PVMFJitterBufferImpl::UpdateEstimatedServerClockDiscrete(bool oFreshStart)
 {
     uint32 rtpTSInMS;
-    uint64 currentTime64 = 0;
-    uint64 currentTimeBase64 = 0;
-    uint64 adjustTime64 = 0;
+    uint32 currentTime32 = 0;
+    uint32 currentTimeBase32 = 0;
+    uint32 adjustTime32 = 0;
+    bool overflowFlag = false;
 
     if (oFreshStart)
     {
@@ -875,7 +1039,7 @@
         rtpTSInMS = iEstServClockMediaClockConvertor.get_converted_ts(1000);
         iEstimatedServerClock->Stop();
         iEstimatedServerClock->SetStartTime32(rtpTSInMS,
-                                              OSCLCLOCK_MSEC);
+                                              PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
         iEstimatedServerClock->Start();
         iEstimatedServerClock->Pause();
         PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClock - Setting start time - MaxAdjustedRTPTS=%d, StartTime=%d",
@@ -885,25 +1049,25 @@
     {
         iEstServClockMediaClockConvertor.update_clock(iMaxAdjustedRTPTS);
         rtpTSInMS = iEstServClockMediaClockConvertor.get_converted_ts(1000);
-        Oscl_Int64_Utils::set_uint64(adjustTime64, 0, rtpTSInMS);
-        iEstimatedServerClock->GetCurrentTime64(currentTime64,
-                                                OSCLCLOCK_MSEC,
-                                                currentTimeBase64);
+        adjustTime32 = rtpTSInMS;
+        iEstimatedServerClock->GetCurrentTime32(currentTime32, overflowFlag,
+                                                PVMF_MEDIA_CLOCK_MSEC,
+                                                currentTimeBase32);
         iEstimatedServerClock->Stop();
-        iEstimatedServerClock->SetStartTime64(adjustTime64, OSCLCLOCK_MSEC);
+        iEstimatedServerClock->SetStartTime32(adjustTime32, PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
         iEstimatedServerClock->Start();
         iEstimatedServerClock->Pause();
-        iEstimatedServerClock->GetCurrentTime64(currentTime64,
-                                                OSCLCLOCK_MSEC,
-                                                currentTimeBase64);
+        iEstimatedServerClock->GetCurrentTime32(currentTime32, overflowFlag,
+                                                PVMF_MEDIA_CLOCK_MSEC,
+                                                currentTimeBase32);
         PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClockDiscrete - Mime=%s",
                              iMimeType.get_cstr()));
         PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClockDiscrete - EstServClock=%2d",
-                             currentTime64));
+                             currentTime32));
         PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClockDiscrete - RTPTime64=%2d",
-                             adjustTime64));
-        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClockDiscrete - Adjusting Clock - iMaxAdjustedRTPTS=%d, currentTimeBase64=%2d",
-                             iMaxAdjustedRTPTS, currentTimeBase64));
+                             adjustTime32));
+        PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferImpl::UpdateEstimatedServerClockDiscrete - Adjusting Clock - iMaxAdjustedRTPTS=%d, currentTimeBase32=%2d",
+                             iMaxAdjustedRTPTS, currentTimeBase32));
     }
     if (iServerClockUpdateNotificationObserver != NULL)
     {
diff --git a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_node.cpp b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_node.cpp
index 2d4bff9..8914c81 100644
--- a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_node.cpp
+++ b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
 #ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
 #include "oscl_exclusive_ptr.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef __MEDIA_CLOCK_CONVERTER_H
 #include "media_clock_converter.h"
@@ -102,7 +102,6 @@
 OSCL_EXPORT_REF PVMFJitterBufferNode::PVMFJitterBufferNode(int32 aPriority)
         : OsclActiveObject(aPriority, "JitterBufferNode")
 {
-    iBroadCastSession = false;
     iStreamID = 0;
     iLogger = NULL;
     iDataPathLogger = NULL;
@@ -112,13 +111,37 @@
     iClockLoggerSessionDuration = NULL;
     iClockLoggerRebuff = NULL;
     iDiagnosticsLogger = NULL;
+    iJBEventsClockLogger = NULL;
     iExtensionInterface = NULL;
     iClientPlayBackClock = NULL;
+    iClientPlayBackClockNotificationsInf = NULL;
     iEstimatedServerClock = NULL;
+    iNonDecreasingClock = NULL;
+    iNonDecreasingClockNotificationsInf = NULL;
+
+    iIncomingMediaInactivityDurationCallBkId = 0;
+    iIncomingMediaInactivityDurationCallBkPending = false;
+
+    iNotifyBufferingStatusCallBkId = 0;
+    iNotifyBufferingStatusCallBkPending = false;
+
+    iJitterBufferDurationCallBkId = 0;
+    iJitterBufferDurationCallBkPending = false;
+
+    iMonitorReBufferingCallBkId = 0;
+    iMonitorReBufferingCallBkPending = false;
+
+    iSendFirewallPacketCallBkId = 0;
+    iSendFirewallPacketCallBkPending = false;
+
+
     iRTCPClock = NULL;
+    iMaxInactivityDurationForMediaInMs = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
     iJitterBufferDurationInMilliSeconds = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
     iJitterBufferUnderFlowThresholdInMilliSeconds = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
     iPlayBackThresholdInMilliSeconds = DEFAULT_PLAY_BACK_THRESHOLD_IN_MS;
+    iEstimatedServerKeepAheadInMilliSeconds = DEFAULT_ESTIMATED_SERVER_KEEPAHEAD_FOR_OOO_SYNC_IN_MS;
+
     oDelayEstablished = false;
     oSessionDurationExpired = false;
     oStopOutputPorts = true;
@@ -130,9 +153,6 @@
     iPlayingAfterSeek = false;
     iJitterBufferState = PVMF_JITTER_BUFFER_READY;
     iJitterDelayPercent = 0;
-    iJitterBufferDurationTimer = NULL;
-    iBufferingStatusTimer = NULL;
-    iFireWallPacketTimer = NULL;
     iDisableFireWallPackets = false;
 
     iNumUnderFlow = 0;
@@ -141,19 +161,24 @@
     iStartBufferingTickCount = 0;
     iPrevBufferingStartPacketTs = 0;
     iThinningIntervalMS = 0;
-    iBufferAlloc = NULL;
 
+    iExtensionInterface = NULL;
     iNumRunL = 0;
+    iOverflowFlag = false;
 
-    hasAudioRTCP = false;
-    hasVideoRTCP = false;
-    gotRTCPReports = false;
 
-    int32 err;
+    iBroadCastSession = false;
+    iRTCPBcastAVSyncProcessed = false;
+
+    iBufferingStatusIntervalInMs =
+        (PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_CYCLES * 1000) / PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_FREQUENCY;
 
     iMaxNumBufferResizes = DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES;
     iBufferResizeSize = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
 
+    prevMinPercentOccupancy = 100;
+    consecutiveLowBufferCount = 0;
+    int32 err = OsclErrNone;
     OSCL_TRY(err,
              /*
               * Create the input command queue.  Use a reserve to avoid lots of
@@ -171,71 +196,69 @@
              /* Create the port vector */
              iPortVector.Construct(PVMF_JITTER_BUFFER_NODE_PORT_VECTOR_RESERVE);
 
-             OsclExclusivePtr<OsclClock> estServClockAutoPtr;
-             OsclExclusivePtr<OsclClock> rtcpClockAutoPtr;
+             OsclExclusivePtr<PVMFMediaClock> estServClockAutoPtr;
+             OsclExclusivePtr<PVMFMediaClock> rtcpClockAutoPtr;
              OsclExclusivePtr<PvmfRtcpTimer> rtcpTimerAutoPtr;
-             OsclExclusivePtr<PvmfJBInactivityTimer> inactivityTimerAutoPtr;
              OsclExclusivePtr<PvmfJBSessionDurationTimer> sessionDurationTimerAutoPtr;
-             OsclExclusivePtr<PvmfJBJitterBufferDurationTimer> jitterBufferDurationTimerAutoPtr;
              typedef OsclTimer<PVMFJitterBufferNodeAllocator> osclTimerType;
-             OsclExclusivePtr<osclTimerType> bufferingStatusTimerAutoPtr;
-             OsclExclusivePtr<PvmfFirewallPacketTimer> firewallPacketTimerAutoPtr;
 
-             PVMF_JITTER_BUFFER_NEW(NULL, OsclClock, (), iEstimatedServerClock);
+             PVMF_JITTER_BUFFER_NEW(NULL, PVMFMediaClock, (), iEstimatedServerClock);
              estServClockAutoPtr.set(iEstimatedServerClock);
              iEstimatedServerClock->SetClockTimebase(iEstimatedServerClockTimeBase);
 
+             PVMF_JITTER_BUFFER_NEW(NULL, PVMFMediaClock, (), iNonDecreasingClock);
+             iNonDecreasingClock->SetClockTimebase(iNonDecreasingClockTimeBase);
 
-             PVMF_JITTER_BUFFER_NEW(NULL, OsclClock, (), iRTCPClock);
+             PVMF_JITTER_BUFFER_NEW(NULL, PVMFMediaClock, (), iRTCPClock);
              rtcpClockAutoPtr.set(iRTCPClock);
              iRTCPClock->SetClockTimebase(iRTCPClockTimeBase);
-
-             PVMF_JITTER_BUFFER_NEW(NULL, PvmfJBInactivityTimer, (this), iRemoteInactivityTimer);
-             inactivityTimerAutoPtr.set(iRemoteInactivityTimer);
-
              PVMF_JITTER_BUFFER_NEW(NULL, PvmfJBSessionDurationTimer, (this), iSessionDurationTimer);
              sessionDurationTimerAutoPtr.set(iSessionDurationTimer);
              iSessionDurationTimer->SetEstimatedServerClock(iEstimatedServerClock);
 
-             PVMF_JITTER_BUFFER_NEW(NULL, PvmfJBJitterBufferDurationTimer, (this), iJitterBufferDurationTimer);
-             jitterBufferDurationTimerAutoPtr.set(iJitterBufferDurationTimer);
-             iJitterBufferDurationTimer->setJitterBufferDurationInMS(iJitterBufferDurationInMilliSeconds);
+             if (iEstimatedServerClock)
+{
+    PVMFStatus status = iEstimatedServerClock->ConstructMediaClockNotificationsInterface(iEstimatedClockNotificationsInf, *this);
+        if (PVMFSuccess != status || !iEstimatedClockNotificationsInf)
+        {
+            iEstimatedClockNotificationsInf = NULL;
+            OSCL_ASSERT(false);
+        }
+    }
 
-             /*
-              * Set the node capability data.
-              * This node can support an unlimited number of ports.
-              */
-             iCapability.iCanSupportMultipleInputPorts = true;
-             iCapability.iCanSupportMultipleOutputPorts = true;
-             iCapability.iHasMaxNumberOfPorts = false;
-             iCapability.iMaxNumberOfPorts = 0;//no maximum
-             iCapability.iInputFormatCapability.push_back(PVMF_RTP);
-             iCapability.iOutputFormatCapability.push_back(PVMF_RTP);
+    /*Construct the event clock notification intf, and start the event clock*/
+    if (iNonDecreasingClock)
+{
+    iNonDecreasingClock->ConstructMediaClockNotificationsInterface(iNonDecreasingClockNotificationsInf, *this);
+        if (NULL == iNonDecreasingClockNotificationsInf)
+        {
+            OSCL_ASSERT(false);
+        }
+        uint32 start = 0;
+        iNonDecreasingClock->Stop();
+        bool overflowFlag = false;
+        iNonDecreasingClock->SetStartTime32(start, PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
+        iNonDecreasingClock->Start();
+    }
 
-             PVMF_JITTER_BUFFER_NEW(NULL,
-                                    OsclTimer<PVMFJitterBufferNodeAllocator>,
-                                    ("PVMFJitterBufferBufferingStatusTimer"),
-                                    iBufferingStatusTimer);
+    /*
+     * Set the node capability data.
+     * This node can support an unlimited number of ports.
+     */
+    iCapability.iCanSupportMultipleInputPorts = true;
+    iCapability.iCanSupportMultipleOutputPorts = true;
+    iCapability.iHasMaxNumberOfPorts = false;
+    iCapability.iMaxNumberOfPorts = 0;//no maximum
+    iCapability.iInputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_RTP));
+    iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_RTP));
 
-             iBufferingStatusTimer->SetObserver(this);
-             /* Milli Sec resolution */
-             iBufferingStatusTimer->SetFrequency(PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_FREQUENCY);
-             bufferingStatusTimerAutoPtr.set(iBufferingStatusTimer);
+    // seed the random number generator
+    iRandGen.Seed(RTCP_RAND_SEED);
 
-             PVMF_JITTER_BUFFER_NEW(NULL, PvmfFirewallPacketTimer, (this), iFireWallPacketTimer);
-             firewallPacketTimerAutoPtr.set(iFireWallPacketTimer);
-
-             // seed the random number generator
-             iRandGen.Seed(RTCP_RAND_SEED);
-
-             estServClockAutoPtr.release();
-             rtcpClockAutoPtr.release();
-             rtcpTimerAutoPtr.release();
-             inactivityTimerAutoPtr.release();
-             sessionDurationTimerAutoPtr.release();
-             jitterBufferDurationTimerAutoPtr.release();
-             bufferingStatusTimerAutoPtr.release();
-             firewallPacketTimerAutoPtr.release();
+    estServClockAutoPtr.release();
+    rtcpClockAutoPtr.release();
+    rtcpTimerAutoPtr.release();
+    sessionDurationTimerAutoPtr.release();
             );
 
     if (err != OsclErrNone)
@@ -243,6 +266,7 @@
         CleanUp();
         OSCL_LEAVE(err);
     }
+
 }
 
 void PVMFJitterBufferNode::CleanUp()
@@ -267,19 +291,23 @@
     if (IsAdded())
         RemoveFromScheduler();
 
-    /* Cleanup allocated interfaces */
     if (iExtensionInterface)
     {
-        /*
-         * clear the interface container
-         * the interface can't function without the node
-         */
-        iExtensionInterface->iContainer = NULL;
         iExtensionInterface->removeRef();
     }
 
     iUseSessionDurationTimerForEOS = true;
 
+    for (uint32 i = 0; i < iPortParamsQueue.size(); i++)
+    {
+        if (iPortParamsQueue[i].iBufferAlloc != NULL)
+        {
+            iPortParamsQueue[i].iBufferAlloc->CancelFreeMemoryAvailableCallback();
+            iPortParamsQueue[i].iBufferAlloc->removeRef();
+            iPortParamsQueue[i].iBufferAlloc = NULL;
+        }
+    }
+
     /* Cleanup allocated ports */
     while (!iPortVector.empty())
     {
@@ -290,6 +318,7 @@
                 it != iPortParamsQueue.end();
                 it++)
         {
+            CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
             if (it->iPort == iPortVector.front())
             {
                 if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
@@ -326,34 +355,42 @@
         CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
     }
 
-    PVMF_JITTER_BUFFER_DELETE(NULL, PvmfJBInactivityTimer, iRemoteInactivityTimer);
+
+    CancelEventCallBack(JB_MONITOR_REBUFFERING);
+    CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
     PVMF_JITTER_BUFFER_DELETE(NULL, PvmfJBSessionDurationTimer, iSessionDurationTimer);
-    PVMF_JITTER_BUFFER_DELETE(NULL, PvmfJBJitterBufferDurationTimer, iJitterBufferDurationTimer);
-    PVMF_JITTER_BUFFER_DELETE(NULL, OsclClock, iEstimatedServerClock);
-    PVMF_JITTER_BUFFER_DELETE(NULL, OsclClock, iRTCPClock);
-    PVMF_JITTER_BUFFER_DELETE(NULL, PvmfFirewallPacketTimer, iFireWallPacketTimer);
+    PVMF_JITTER_BUFFER_DELETE(NULL, PVMFMediaClock, iRTCPClock);
+    CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
+    CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
 
-    if (iBufferingStatusTimer)
+
+    if ((NULL != iClientPlayBackClock) && (NULL != iClientPlayBackClockNotificationsInf))
     {
-        iBufferingStatusTimer->Clear();
+        iClientPlayBackClockNotificationsInf->RemoveClockStateObserver(*this);
+        iClientPlayBackClock->DestroyMediaClockNotificationsInterface(iClientPlayBackClockNotificationsInf);
+        iClientPlayBackClockNotificationsInf = NULL;
     }
-    PVMF_JITTER_BUFFER_TEMPLATED_DELETE(NULL, OsclTimer<PVMFJitterBufferNodeAllocator>, OsclTimer, iBufferingStatusTimer);
 
-    if (iBufferAlloc != NULL)
+    if (NULL != iNonDecreasingClock)
     {
-        iBufferAlloc->CancelDeallocationNotifications();
-        iBufferAlloc->CancelFreeChunkAvailableCallback();
-        iBufferAlloc->DecrementKeepAliveCount();
-        if (iBufferAlloc->getNumOutStandingBuffers() == 0)
+        if (NULL != iNonDecreasingClockNotificationsInf)
         {
-            OSCL_DELETE((iBufferAlloc));
+            iNonDecreasingClock->DestroyMediaClockNotificationsInterface(iNonDecreasingClockNotificationsInf);
+            iNonDecreasingClockNotificationsInf = NULL;
         }
-        iBufferAlloc = NULL;
+        PVMF_JITTER_BUFFER_DELETE(NULL, PVMFMediaClock, iNonDecreasingClock);
+        iNonDecreasingClock = NULL;
     }
 
-    if (NULL != iClientPlayBackClock)
+    if (NULL != iEstimatedServerClock)
     {
-        iClientPlayBackClock->RemoveClockStateObserver(*this);
+        if (NULL != iEstimatedClockNotificationsInf)
+        {
+            iEstimatedServerClock->DestroyMediaClockNotificationsInterface(iEstimatedClockNotificationsInf);
+            iEstimatedClockNotificationsInf = NULL;
+        }
+        PVMF_JITTER_BUFFER_DELETE(NULL, PVMFMediaClock, iEstimatedServerClock);
+        iEstimatedServerClock = NULL;
     }
 }
 
@@ -385,6 +422,8 @@
             iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.streamingmanager");
             iDataPathLoggerFlowCtrl = PVLogger::GetLoggerObject("datapath.sourcenode.jitterbuffer.flowctrl");
             iDataPathLoggerRTCP = PVLogger::GetLoggerObject("datapath.sourcenode.jitterbuffer.rtcp");
+            iJBEventsClockLogger = PVLogger::GetLoggerObject("jitterbuffernode.eventsclock");
+            iRTCPAVSyncLogger = PVLogger::GetLoggerObject("jitterbuffernode.rtcpavsync");
             iDiagnosticsLogged = false;
             SetState(EPVMFNodeIdle);
             status = PVMFSuccess;
@@ -394,6 +433,7 @@
             status = PVMFErrInvalidState;
             break;
     }
+
     return status;
 }
 
@@ -409,10 +449,7 @@
         case EPVMFNodeIdle:
         {
             /* Cancel any outstanding timers */
-            if (iRemoteInactivityTimer)
-            {
-                iRemoteInactivityTimer->Cancel();
-            }
+            CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
             if (iSessionDurationTimer)
             {
                 iSessionDurationTimer->Cancel();
@@ -428,16 +465,11 @@
                     if (it->iRTCPTimer != NULL)
                         it->iRTCPTimer->Cancel();
                 }
+                CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
             }
-
-            if (iBufferingStatusTimer)
-            {
-                iBufferingStatusTimer->Clear();
-            }
-            if (iFireWallPacketTimer)
-            {
-                iFireWallPacketTimer->Cancel();
-            }
+            CancelEventCallBack(JB_MONITOR_REBUFFERING);
+            CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
+            CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
             if (IsAdded())
             {
                 RemoveFromScheduler();
@@ -475,7 +507,7 @@
 }
 
 /**
- * retrive a port iterator.
+ * retrieve a port iterator.
  */
 OSCL_EXPORT_REF PVMFPortIter* PVMFJitterBufferNode::GetPorts(const PVMFPortFilter* aFilter)
 {
@@ -901,6 +933,8 @@
         PVMFStatus aStatus,
         OsclAny* aEventData)
 {
+    OSCL_UNUSED_ARG(aEventData);
+
     PVMF_JBNODE_LOGINFO((0, "JitterBufferNode:InternalCommandComplete Id %d Cmd %d Status %d Context %d Data %d"
                          , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
 
@@ -940,7 +974,7 @@
  */
 void PVMFJitterBufferNode::DoReset(PVMFJitterBufferNodeCommand& aCmd)
 {
-    PVMF_JBNODE_LOGINFO((0, "JitterBufferNode:DoReset"));
+    PVMF_JBNODE_LOGERROR((0, "JitterBufferNode:DoReset %d", iInterfaceState));
 
     LogSessionDiagnostics();
 
@@ -950,8 +984,8 @@
         case EPVMFNodeStarted:
         case EPVMFNodePaused:
         {
-            /* Stop inactivity timer */
-            iRemoteInactivityTimer->Stop();
+            CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+            CancelEventCallBack(JB_MONITOR_REBUFFERING);
             /* Stop session duration timer */
             iSessionDurationTimer->Stop();
             /* Stop RTCP Timer */
@@ -965,10 +999,10 @@
                     if (it->iRTCPTimer != NULL)
                         it->iRTCPTimer->Stop();
                 }
+                CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
             }
 
-            /* Stop Firewall Packet Timer */
-            iFireWallPacketTimer->Stop();
+            CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
             /* Pause Estimated Server Clock */
             PVMFStatus aStatus = PVMFSuccess;
             if (iEstimatedServerClock)
@@ -1017,22 +1051,13 @@
         case EPVMFNodeError:
         {
             /* Stop Estimated Server Clock */
-            PVMFStatus aStatus = PVMFSuccess;
             if (iEstimatedServerClock)
             {
-                if (!(iEstimatedServerClock->Stop()))
-                {
-                    aStatus = PVMFFailure;
-                    PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::DoReset: Error - iEstimatedServerClock->Stop failed"));
-                }
+                iEstimatedServerClock->Stop();
             }
             if (iRTCPClock)
             {
-                if (!(iRTCPClock->Stop()))
-                {
-                    aStatus = PVMFFailure;
-                    PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::DoReset: Error - iRTCPClock->Stop failed"));
-                }
+                iRTCPClock->Stop();
             }
             /* delete all ports and notify observer */
             while (!iPortVector.empty())
@@ -1040,6 +1065,16 @@
                 iPortVector.Erase(&iPortVector.front());
             }
 
+            for (uint32 i = 0; i < iPortParamsQueue.size(); i++)
+            {
+                if (iPortParamsQueue[i].iBufferAlloc != NULL)
+                {
+                    iPortParamsQueue[i].iBufferAlloc->CancelFreeMemoryAvailableCallback();
+                    iPortParamsQueue[i].iBufferAlloc->removeRef();
+                    iPortParamsQueue[i].iBufferAlloc = NULL;
+                }
+            }
+
             /* delete port params */
             Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
             while (!iPortParamsQueue.empty())
@@ -1063,25 +1098,10 @@
             /* restore original port vector reserve */
             iPortVector.Reconstruct();
             iUseSessionDurationTimerForEOS = true;
-
-            if (iBufferAlloc != NULL)
-            {
-                iBufferAlloc->CancelDeallocationNotifications();
-                iBufferAlloc->CancelFreeChunkAvailableCallback();
-                iBufferAlloc->DecrementKeepAliveCount();
-                if (iBufferAlloc->getNumOutStandingBuffers() == 0)
-                {
-                    OSCL_DELETE((iBufferAlloc));
-                }
-                iBufferAlloc = NULL;
-            }
-
-            /* logoff & go back to Created state */
             SetState(EPVMFNodeIdle);
-            PVMFStatus status = ThreadLogoff();
-
-            CommandComplete(iInputCommands, aCmd, status);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
         }
+        iNonDecreasingClock->Stop();
         break;
 
         default:
@@ -1150,10 +1170,14 @@
             iExtensionInterface =
                 OSCL_PLACEMENT_NEW(ptr, PVMFJitterBufferExtensionInterfaceImpl(this));
         }
-        /* add a reference each time we hand out the interface pointer.*/
-        iExtensionInterface->addRef();
-        *ptr = (PVInterface*)iExtensionInterface;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        if (iExtensionInterface->queryInterface(*uuid, *ptr))
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        }
+        else
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+        }
     }
     else
     {
@@ -1176,16 +1200,6 @@
     OSCL_String* mimetype;
     aCmd.PVMFJitterBufferNodeCommandBase::Parse(tag, mimetype);
 
-    //Only the specified mime types here will get their timebases
-    //adjusted when the first sender reports come in.
-    PVMFStreamType portType = PVMF_STREAM_TYPE_UNKNOWN;
-    if (!oscl_CIstrcmp(mimetype->get_cstr(), "RTP/H264"))
-        portType = PVMF_STREAM_TYPE_VIDEO;
-    else if (!oscl_CIstrcmp(mimetype->get_cstr(), "RTP/mpeg4-generic"))
-        portType = PVMF_STREAM_TYPE_AUDIO;
-    else
-        portType = PVMF_STREAM_TYPE_UNKNOWN;
-
     PVMFJitterBufferPortParams portParams;
     /*
      * Input ports have tags: 0, 3, 6, ...
@@ -1202,30 +1216,11 @@
         {
             portParams.tag = PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK;
             PVMF_JITTER_BUFFER_NEW(NULL, PvmfRtcpTimer, (this), (portParams.iRTCPTimer));
-
-            RTCPPortIndex[portType] = iPortParamsQueue.size();
-
-            switch (portType)
-            {
-                case PVMF_STREAM_TYPE_AUDIO:
-                    hasAudioRTCP = true;
-                    break;
-
-                case PVMF_STREAM_TYPE_VIDEO:
-                    hasVideoRTCP = true;
-                    break;
-
-                case PVMF_STREAM_TYPE_UNKNOWN:
-                default:
-                    break;
-            }
         }
     }
     else
     {
         portParams.tag = PVMF_JITTER_BUFFER_PORT_TYPE_INPUT;
-
-        InputPortIndex[portType] = iPortParamsQueue.size();
     }
 
     //set port name for datapath logging.
@@ -1237,9 +1232,11 @@
             break;
         case PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK:
             //don't log this port for now...
+            //portname="JitterBufFeedback";
             break;
         case PVMF_JITTER_BUFFER_PORT_TYPE_INPUT:
             //don't log this port for now...
+            //portname="JitterBufIn";
             break;
         default:
             break;
@@ -1361,8 +1358,11 @@
     /*This node supports release port from any state*/
 
     /* Find the port in the port vector */
-    PVMFJitterBufferPort* port;
-    aCmd.PVMFJitterBufferNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* p = NULL;
+    aCmd.PVMFJitterBufferNodeCommandBase::Parse(p);
+
+    PVMFJitterBufferPort* port = (PVMFJitterBufferPort*)p;
+
     PVMFJitterBufferPort** portPtr = iPortVector.FindByValue(port);
     if (portPtr)
     {
@@ -1418,6 +1418,11 @@
              * this node doesn't need to do anything to get ready
              * to prepare.
              */
+            if (PVMFMediaClock::RUNNING != iNonDecreasingClock->GetState())
+            {
+                iNonDecreasingClock->Start(); //JB node may would have been paused -> reset -> Init
+            }
+
             SetState(EPVMFNodeInitialized);
             CommandComplete(iInputCommands, aCmd, PVMFSuccess);
             break;
@@ -1474,7 +1479,8 @@
             {
                 uint32 start = 0;
                 iEstimatedServerClock->Stop();
-                iEstimatedServerClock->SetStartTime32(start, OSCLCLOCK_MSEC);
+                bool overflowFlag = false;
+                iEstimatedServerClock->SetStartTime32(start, PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
             }
             if (iDisableFireWallPackets == false)
             {
@@ -1504,7 +1510,7 @@
     PVMFJitterBufferNodeCommand cmd = iCurrentCommand.front();
     if (iDisableFireWallPackets == false)
     {
-        iFireWallPacketTimer->Cancel();
+        CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
 
         bool oFireWallPacketExchangeComplete = true;
         Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
@@ -1552,7 +1558,7 @@
 
 void PVMFJitterBufferNode::CancelPrepare()
 {
-    iFireWallPacketTimer->Cancel();
+    CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
     PVMFJitterBufferNodeCommand cmd = iCurrentCommand.front();
     CommandComplete(cmd, PVMFErrCancelled);
     iCurrentCommand.Erase(&iCurrentCommand.front());
@@ -1571,6 +1577,10 @@
         case EPVMFNodePrepared:
         case EPVMFNodePaused:
         {
+            if (PVMFMediaClock::RUNNING != iNonDecreasingClock->GetState())
+            {
+                iNonDecreasingClock->Start();
+            }
             /* Diagnostic logging */
             iDiagnosticsLogged = false;
             /* If auto paused, implies jitter buffer is not empty */
@@ -1578,23 +1588,34 @@
             {
                 if (oSessionDurationExpired == false)
                 {
-                    /* Start remote inactivity timer */
-                    iRemoteInactivityTimer->Start();
+                    RequestEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
                     StartEstimatedServerClock();
 
                 }
                 /* Start RTCP Clock */
                 iRTCPClock->Start();
+
+                if (iInterfaceState == EPVMFNodePaused)
+                {
+                    if (iDisableFireWallPackets == false)
+                    {
+                        uint32 currticks = OsclTickCount::TickCount();
+                        uint32 startTime = OsclTickCount::TicksToMsec(currticks);
+                        uint32 diff = (startTime - iPauseTime);
+                        if (diff > PVMF_JITTER_BUFFER_NODE_FIREWALL_PKT_DEFAULT_PAUSE_DURATION_IN_MS)
+                        {
+                            ResetFireWallPacketInfoAndResend();
+                        }
+                    }
+                }
+
                 if ((oDelayEstablished == false) ||
                         (iJitterBufferState == PVMF_JITTER_BUFFER_IN_TRANSITION))
                 {
                     /* Counter for intelligent streaming is reset at Start or setPlaybackRange*/
                     iNumUnderFlow = 0;
                     /* Start Buffering Status Timer */
-                    iBufferingStatusTimer->Request(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID,
-                                                   0,
-                                                   PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_CYCLES,
-                                                   this);
+                    RequestEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
                     /*
                      * Move start to current msg queue where it would stay
                      * jitter buffer is full.
@@ -1606,19 +1627,6 @@
                 else
                 {
                     /* Just resuming from a paused state with enough data in jitter buffer */
-                    if (iInterfaceState == EPVMFNodePaused)
-                    {
-                        if (iDisableFireWallPackets == false)
-                        {
-                            uint32 currticks = OsclTickCount::TickCount();
-                            uint32 startTime = OsclTickCount::TicksToMsec(currticks);
-                            uint32 diff = (startTime - iPauseTime);
-                            if (diff > PVMF_JITTER_BUFFER_NODE_FIREWALL_PKT_DEFAULT_PAUSE_DURATION_IN_MS)
-                            {
-                                ResetFireWallPacketInfoAndResend();
-                            }
-                        }
-                    }
                     oStartPending = false;
                     SetState(EPVMFNodeStarted);
                     /* Enable Output Ports */
@@ -1706,12 +1714,9 @@
 
 void PVMFJitterBufferNode::CancelStart()
 {
-    /* Cancel Jitterbuffer duration timer */
-    iJitterBufferDurationTimer->Cancel();
-    /* Cancel Buffering status timer */
-    iBufferingStatusTimer->Cancel(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID);
-    /* Stop inactivity timer */
-    iRemoteInactivityTimer->Stop();
+    CancelEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
+    CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
+    CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
     /* Stop session duration timer */
     iSessionDurationTimer->Stop();
     /* Stop RTCP Timer */
@@ -1727,8 +1732,7 @@
         }
     }
 
-    /* Stop Firewall Packet Timer */
-    iFireWallPacketTimer->Stop();
+    CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
     /* Pause Estimated Server Clock */
     if (iEstimatedServerClock)
     {
@@ -1759,8 +1763,7 @@
         case EPVMFNodeStarted:
         case EPVMFNodePaused:
         {
-            /* Stop inactivity timer */
-            iRemoteInactivityTimer->Stop();
+            CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
             /* Stop session duration timer */
             iSessionDurationTimer->Stop();
             /* Stop RTCP Timer */
@@ -1774,9 +1777,10 @@
                     if (it->iRTCPTimer != NULL)
                         it->iRTCPTimer->Stop();
                 }
+                CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
+                it->iRTCPStats.oRTCPByeRecvd = false;
             }
-            /* Stop Firewall Packet Timer */
-            iFireWallPacketTimer->Stop();
+            CancelEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
             /* Pause Estimated Server Clock */
             PVMFStatus aStatus = PVMFSuccess;
             if (iEstimatedServerClock)
@@ -1820,6 +1824,7 @@
             }
             CommandComplete(iInputCommands, aCmd, aStatus);
         }
+        iNonDecreasingClock->Stop();
         break;
 
         default:
@@ -1903,10 +1908,16 @@
             pauseEstimatedServerClock();
             /* Cancel session duration timer */
             iSessionDurationTimer->Cancel();
-            /* Cancel the inactivity timer */
-            iRemoteInactivityTimer->Stop();
-            /*Cancel Buffering Status Timer*/
-            iBufferingStatusTimer->Cancel(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID);
+            CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+            CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
+            Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+            for (it = iPortParamsQueue.begin();
+                    it != iPortParamsQueue.end();
+                    it++)
+            {
+                CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
+            }
+            iNonDecreasingClock->Pause();
             CommandComplete(iInputCommands, aCmd, PVMFSuccess);
         }
         break;
@@ -2212,8 +2223,9 @@
                 /*
                  * Get RTCP Recv Time in milliseconds
                  */
-                uint64 srRecvTime;
-                iRTCPClock->GetCurrentTime64(srRecvTime, OSCLCLOCK_MSEC);
+                uint32 srRecvTime;
+                bool overflowFlag = false;
+                iRTCPClock->GetCurrentTime32(srRecvTime, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
 
                 aPortParamsPtr->iRTCPStats.lastSenderReportRecvTime = srRecvTime;
 
@@ -2222,132 +2234,17 @@
                     (((uint64)rtcpSR.NTP_timestamp_high) << 32) + (uint64)rtcpSR.NTP_timestamp_low;
                 aPortParamsPtr->iRTCPStats.lastSenderReportRTP = rtcpSR.RTP_timestamp;
 
-                // Check if sender reports have been received for
-                // both audio and video streams.  If so, set up
-                // the Jitter Buffer timing parameters.
-
-                // If we only have one track, skip the A/V offset calculations
-                // If we are still waiting for reports from one or more RTCP ports...
-                if (hasAudioRTCP && hasVideoRTCP && !gotRTCPReports)
+                if (iBroadCastSession && !iRTCPBcastAVSyncProcessed)
                 {
-                    uint32 audioInputPortIndex = InputPortIndex[PVMF_STREAM_TYPE_AUDIO];
-                    uint32 videoInputPortIndex = InputPortIndex[PVMF_STREAM_TYPE_VIDEO];
-                    uint32 audioRTCPPortIndex  = RTCPPortIndex[PVMF_STREAM_TYPE_AUDIO];
-                    uint32 videoRTCPPortIndex  = RTCPPortIndex[PVMF_STREAM_TYPE_VIDEO];
-                    // Check to see if we've received an RTCP SR for both the audio and video ports
-                    if ((iPortParamsQueue[videoRTCPPortIndex].iRTCPStats.lastSenderReportRecvTime != (uint64)0) &&
-                            (iPortParamsQueue[audioRTCPPortIndex].iRTCPStats.lastSenderReportRecvTime != (uint64)0))
+                    bool ret = ProcessRTCPSRforAVSync();
+                    if (ret == false)
                     {
-                        //If we have received the first RTP packets, go ahead and calculate the A/V sync.
-                        //Otherwise, try again later (on the next RTCP report).
-                        if ((iPortParamsQueue[videoInputPortIndex].iJitterBuffer->GetRTPTimeStampOffset() != 0) &&
-                                (iPortParamsQueue[audioInputPortIndex].iJitterBuffer->GetRTPTimeStampOffset() != 0))
-                        {
-                            uint64 initNTP;
-                            uint64 deltaNTP;
-                            uint32 deltaNTP32;
-                            uint32 deltaRTP;
-                            uint64 deltaRTP64;
-                            uint32 firstTS[NUM_PVMF_STREAM_TYPES];
-                            uint32 SR_RTP[NUM_PVMF_STREAM_TYPES];
-                            uint64 SR_NTP[NUM_PVMF_STREAM_TYPES];
-                            uint32 RTPTB[NUM_PVMF_STREAM_TYPES];
-                            uint32 timescale;
-
-                            //Get the timestamps from the first packets on the RTP input ports.
-                            firstTS[PVMF_STREAM_TYPE_AUDIO] = iPortParamsQueue[audioInputPortIndex].iJitterBuffer->GetRTPTimeStampOffset();
-                            firstTS[PVMF_STREAM_TYPE_VIDEO] = iPortParamsQueue[videoInputPortIndex].iJitterBuffer->GetRTPTimeStampOffset();
-
-                            // Get the timestamps from the RTCP SRs
-                            SR_RTP[PVMF_STREAM_TYPE_AUDIO] = iPortParamsQueue[audioRTCPPortIndex].iRTCPStats.lastSenderReportRTP;
-                            SR_NTP[PVMF_STREAM_TYPE_AUDIO] = iPortParamsQueue[audioRTCPPortIndex].iRTCPStats.lastSenderReportNTP;
-                            SR_RTP[PVMF_STREAM_TYPE_VIDEO] = iPortParamsQueue[videoRTCPPortIndex].iRTCPStats.lastSenderReportRTP;
-                            SR_NTP[PVMF_STREAM_TYPE_VIDEO] = iPortParamsQueue[videoRTCPPortIndex].iRTCPStats.lastSenderReportNTP;
-
-                            // Use the audio RTCP SR to calculate an NTP time for the
-                            // first audio packet received
-                            timescale = iPortParamsQueue[audioInputPortIndex].timeScale;
-
-                            if (SR_RTP[PVMF_STREAM_TYPE_AUDIO] > firstTS[PVMF_STREAM_TYPE_AUDIO])
-                            {
-                                deltaRTP = SR_RTP[PVMF_STREAM_TYPE_AUDIO] - firstTS[PVMF_STREAM_TYPE_AUDIO];
-                                deltaRTP64 = ((uint64) deltaRTP / (uint64)timescale) << 32;
-                                deltaRTP64 += ((uint64) deltaRTP % (uint64)timescale) * (uint64)0xFFFFFFFF / (uint64)timescale;
-                                initNTP = SR_NTP[PVMF_STREAM_TYPE_AUDIO] - deltaRTP64;
-                            }
-                            else
-                            {
-                                deltaRTP = firstTS[PVMF_STREAM_TYPE_AUDIO] - SR_RTP[PVMF_STREAM_TYPE_AUDIO];
-                                deltaRTP64 = ((uint64) deltaRTP / (uint64)timescale) << 32;
-                                deltaRTP64 += ((uint64) deltaRTP % (uint64)timescale) * (uint64)0xFFFFFFFF / (uint64)timescale;
-                                initNTP = SR_NTP[PVMF_STREAM_TYPE_AUDIO] + deltaRTP64;
-                            }
-
-                            // Now use the video RTCP SR to calculate the video RTP timestamp
-                            // that corresponds to this NTP time
-                            timescale = iPortParamsQueue[videoInputPortIndex].timeScale;
-
-                            if (SR_NTP[PVMF_STREAM_TYPE_VIDEO] > initNTP)
-                            {
-                                deltaNTP = SR_NTP[PVMF_STREAM_TYPE_VIDEO] - initNTP;
-                                // Convert to RTP timescale units
-                                deltaNTP32 = ((deltaNTP * (uint64)timescale) + (uint64)0x80000000) >> 32;
-                                RTPTB[PVMF_STREAM_TYPE_VIDEO] = SR_RTP[PVMF_STREAM_TYPE_VIDEO] - deltaNTP32;
-                            }
-                            else
-                            {
-                                deltaNTP = initNTP - SR_NTP[PVMF_STREAM_TYPE_VIDEO];
-                                // Convert to RTP timescale units
-                                deltaNTP32 = ((deltaNTP * (uint64)timescale) + (uint64)0x80000000) >> 32;
-                                RTPTB[PVMF_STREAM_TYPE_VIDEO] = SR_RTP[PVMF_STREAM_TYPE_VIDEO] + deltaNTP32;
-                            }
-
-                            // Since audio is the reference track, we just set the timebase to the
-                            // first received packet
-                            RTPTB[PVMF_STREAM_TYPE_AUDIO] = firstTS[PVMF_STREAM_TYPE_AUDIO];
-
-#ifdef DEBUG_RTCP
-                            {
-                                for (uint32 p = PVMF_STREAM_TYPE_AUDIO; p <= PVMF_STREAM_TYPE_VIDEO; p++)
-                                {
-                                    int32 delta = (int32)(RTPTB[p] - firstTS[p]);
-                                    delta *= 1000;
-                                    delta /= (int32)iPortParamsQueue[InputPortIndex[p]].timeScale;
-
-                                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                                                    (0,
-                                                     "Stream %d: timeScale=%uHz firstTS=%u RTCP.RTP=%u RTCP.NTP=%u.%06u newTB=%u delta=%dms\n",
-                                                     p,
-                                                     iPortParamsQueue[InputPortIndex[p]].timeScale,
-                                                     firstTS[p],
-                                                     SR_RTP[p],
-                                                     (uint32)(SR_NTP[p] >> 32),
-                                                     (uint32)(((((uint64)((uint32)(SR_NTP[p]) & 0xffffffff)) * (uint64)1000000) + (uint64)500000) >> 32),
-                                                     RTPTB[p],
-                                                     delta
-                                                    )
-                                                   );
-                                }
-                            }
-#endif
-
-                            //Purge old video data that we don't need to render.
-                            iPortParamsQueue[videoInputPortIndex].iJitterBuffer->PurgeElementsWithTimestampLessThan(RTPTB[PVMF_STREAM_TYPE_VIDEO]);
-
-#ifndef AVSYNC_DISABLE_RTCP_PROCESSING
-                            //Only adjust the timebase if the sender reports have valid wall clock values.
-                            if ((SR_NTP[PVMF_STREAM_TYPE_AUDIO] != (uint64)0)
-                                    && (SR_NTP[PVMF_STREAM_TYPE_VIDEO] != (uint64)0))
-                            {
-                                //Only adjust the video input port.
-                                iPortParamsQueue[videoInputPortIndex].iJitterBuffer->SetRTPTimeStampOffset(RTPTB[PVMF_STREAM_TYPE_VIDEO]);
-                            }
-#endif
-
-                            gotRTCPReports = true;
-                        }
+                        // No need to return error as perhaps there's not enough information yet
+                        // to attempt a/v sync
+                        return PVMFSuccess;
                     }
                 }
+
             }
 
             //If the RTCP type is BYE, set the end-of-stream flag.
@@ -2355,6 +2252,42 @@
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFJitterBufferNode::ProcessIncomingRTCPReport - BYE"));
 
+                PVMF_JBNODE_LOG_RTCP_ERR((0, "RTCP_BYE_RECVD: Mime=%s", aPortParamsPtr->iMimeType.get_cstr()));
+
+                //for live streams, treat RTCP BYE as EOS
+                if (iPlayStopTimeAvailable == false)
+                {
+                    PVMF_JBNODE_LOGDATATRAFFIC_IN((0, "USING RTCP_BYE TO TRIGGER EOS: Mime=%s", aPortParamsPtr->iMimeType.get_cstr()));
+                    PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "USING RTCP_BYE TO TRIGGER EOS: Mime=%s", aPortParamsPtr->iMimeType.get_cstr()));
+                    PVMF_JBNODE_LOG_RTCP_ERR((0, "USING RTCP_BYE TO TRIGGER EOS: Mime=%s", aPortParamsPtr->iMimeType.get_cstr()));
+                    oSessionDurationExpired = true;
+                    CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+                    /* Cancel clock update notifications */
+                    Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+                    for (it = iPortParamsQueue.begin(); it != iPortParamsQueue.end(); it++)
+                    {
+                        CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
+                        if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+                        {
+                            if (it->iJitterBuffer != NULL)
+                            {
+                                it->iJitterBuffer->CancelServerClockNotificationUpdates();
+                            }
+                            else
+                            {
+                                OSCL_ASSERT(false);
+                            }
+                        }
+                    }
+                    /* Pause Estimated server clock & RTCP Clock */
+                    iEstimatedServerClock->Pause();
+                    iRTCPClock->Pause();
+                    if (IsAdded())
+                    {
+                        RunIfNotReady();
+                    }
+                }
+
                 retval = rtcpDec.DecodeBYE(array_of_packets[ii], rtcpBye);
                 if (RTCP_Decoder::FAIL == retval)
                 {
@@ -2379,6 +2312,7 @@
                                         (OsclAny*)(inputPortParamsPtr->iMimeType.get_cstr()),
                                         &eventuuid,
                                         &infocode);
+                        PVMF_JBNODE_LOG_RTCP_ERR((0, "RTCP_BYE_PROCESSED: Mime=%s", aPortParamsPtr->iMimeType.get_cstr()));
                     }
                 }
             }
@@ -2434,17 +2368,17 @@
     reportBlock->sourceSSRC = sourceSSRC32;
 
     /* Compute packet loss fraction */
-    if (aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumRecievedUptoThisRR == 0)
+    if (aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumReceivedUptoThisRR == 0)
     {
-        aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumRecievedUptoThisRR =
+        aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumReceivedUptoThisRR =
             jbStats.seqNumBase;
     }
     if (jbStats.maxSeqNumReceived -
-            aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumRecievedUptoThisRR)
+            aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumReceivedUptoThisRR)
     {
         reportBlock->fractionLost =
             (int8)(((jbStats.totalPacketsLost - aFeedBackPortParamsPtr->iRTCPStats.packetLossUptoThisRR) * 256) /
-                   (jbStats.maxSeqNumReceived - aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumRecievedUptoThisRR));
+                   (jbStats.maxSeqNumReceived - aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumReceivedUptoThisRR));
     }
     else
     {
@@ -2458,17 +2392,18 @@
 
     if (aFeedBackPortParamsPtr->iRTCPStats.oSRRecvd)
     {
-        uint64 currRRGenTime;
-        iRTCPClock->GetCurrentTime64(currRRGenTime, OSCLCLOCK_MSEC);
+        uint32 currRRGenTime;
+        bool overflowFlag = false;
 
-        uint64 lastSenderReportRecvTime =
-            aFeedBackPortParamsPtr->iRTCPStats.lastSenderReportRecvTime;
+        iRTCPClock->GetCurrentTime32(currRRGenTime, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
 
-        uint64 delaySinceLastSR64 =
+        uint32 lastSenderReportRecvTime = (uint32)
+                                          aFeedBackPortParamsPtr->iRTCPStats.lastSenderReportRecvTime;
+
+        uint32 delaySinceLastSR64 =
             (currRRGenTime - lastSenderReportRecvTime);
 
-        uint32 delaySinceLastSR32 =
-            Oscl_Int64_Utils::get_uint64_lower32(delaySinceLastSR64);
+        uint32 delaySinceLastSR32 = delaySinceLastSR64;
 
         reportBlock->delaySinceLastSR = (delaySinceLastSR32 << 16) / 1000;
 
@@ -2476,7 +2411,7 @@
     }
 
     /* Update variables for the next RR cycle */
-    aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumRecievedUptoThisRR =
+    aFeedBackPortParamsPtr->iRTCPStats.maxSeqNumReceivedUptoThisRR =
         jbStats.maxSeqNumReceived;
     aFeedBackPortParamsPtr->iRTCPStats.packetLossUptoThisRR =
         jbStats.totalPacketsLost;
@@ -2486,12 +2421,16 @@
     PVMFSharedMediaDataPtr rtcpOut;
     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
     PVMFRTCPMemPool* rtcpBufAlloc = aFeedBackPortParamsPtr->iRTCPTimer->getRTCPBuffAlloc();
+    if (!rtcpBufAlloc->iMediaDataMemPool)
+    {
+        return PVMFErrNoMemory;
+    }
     int32 err;
 
     OSCL_TRY(err,
              mediaDataImpl = rtcpBufAlloc->getMediaDataImpl(MAX_RTCP_BLOCK_SIZE);
              rtcpOut = PVMFMediaData::createMediaData(mediaDataImpl,
-                       &(rtcpBufAlloc->iMediaDataMemPool));
+                       (rtcpBufAlloc->iMediaDataMemPool));
             );
 
     if (err != OsclErrNone)
@@ -2511,10 +2450,10 @@
 
     PVMF_JBNODE_LOG_RTCP((0, "RTCP_PKT: Mime=%s, MaxSNRecvd=%d, MaxTSRecvd=%d, MaxSNRet=%d, MaxTSRet=%d", aInputPortParamsPtr->iMimeType.get_cstr(), jbStats.maxSeqNumReceived, jbStats.maxTimeStampRegistered, jbStats.lastRetrievedSeqNum, jbStats.maxTimeStampRetrieved));
     /*
-     * If Rate Adaptation is enabled send NADU APP packet,
+     * If Rate Adaptation is enabled and we have received some RTP packets, then send NADU APP packet,
      * if frequency criteria is met
      */
-    if (aInputPortParamsPtr->oRateAdaptation)
+    if (aInputPortParamsPtr->oRateAdaptation && (jbStats.totalNumPacketsReceived > 0))
     {
         aInputPortParamsPtr->iRateAdaptationRTCPRRCount++;
         if (aInputPortParamsPtr->iRateAdaptationRTCPRRCount ==
@@ -2525,37 +2464,43 @@
             App.subtype = RTCP_NADU_APP_SUBTYPE;
             App.pss0_app_data.sourcessrc = sourceSSRC32;
             PVMFTimestamp converted_ts = 0;
-            PVMFTimestamp tsOfNextPacketToBeDecoded = jbStats.maxTimeStampRetrievedWithoutRTPOffset;
+            //set playoutdelay to 0xffff by default, if JB is empty we will use this
+            uint32 diff32 = RTCP_NADU_APP_DEFAULT_PLAYOUT_DELAY;
+            uint32 clientClock32 = 0;
+            uint32 timebase32 = 0;
+            bool overflowFlag = false;
+
+            if (iClientPlayBackClock != NULL)
+                iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag,
+                                                       PVMF_MEDIA_CLOCK_MSEC,
+                                                       timebase32);
             if (jbStats.currentOccupancy > 0)
             {
+                PVMFTimestamp tsOfNextPacketToBeDecoded = jbStats.maxTimeStampRetrievedWithoutRTPOffset;
                 tsOfNextPacketToBeDecoded =
                     aInputPortParamsPtr->iJitterBuffer->peekNextElementTimeStamp();
+
+                uint32 in_wrap_count = 0;
+                /*
+                 * Convert Time stamp to milliseconds
+                 */
+                aInputPortParamsPtr->mediaClockConverter.set_clock(tsOfNextPacketToBeDecoded, in_wrap_count);
+                converted_ts =
+                    aInputPortParamsPtr->mediaClockConverter.get_converted_ts(1000);
+
+                //ts should be ahead of clock
+                //if not we are falling behind on one track, so set playout delay to zero
+                diff32 = 0;
+                bool clkEarly =
+                    PVTimeComparisonUtils::IsEarlier(clientClock32,
+                                                     converted_ts,
+                                                     diff32);
+                if (clkEarly == false)
+                {
+                    diff32 = 0;
+                }
             }
-
-            uint32 in_wrap_count = 0;
-            /*
-             * Convert Time stamp to milliseconds
-             */
-            aInputPortParamsPtr->mediaClockConverter.set_clock(tsOfNextPacketToBeDecoded, in_wrap_count);
-            converted_ts =
-                aInputPortParamsPtr->mediaClockConverter.get_converted_ts(1000);
-
-
-            uint64 timebase64 = 0;
-            uint64 clientClock64 = 0;
-            if (iClientPlayBackClock != NULL)
-                iClientPlayBackClock->GetCurrentTime64(clientClock64,
-                                                       OSCLCLOCK_MSEC,
-                                                       timebase64);
-            uint32 diff32 = converted_ts -
-                            Oscl_Int64_Utils::get_uint64_lower32(clientClock64);
-
-            //set playoutdelay to 0xffff whenever we go into rebuffering
-            if (oDelayEstablished == false)
-            {
-                diff32 = RTCP_NADU_APP_DEFAULT_PLAYOUT_DELAY;
-            }
-            PVMF_JBNODE_LOG_RTCP((0, "RTCP_PKT: Mime=%s, RTP_TS=%d, C_CLOCK=%d, DIFF=%d, RE-BUF=%d", aInputPortParamsPtr->iMimeType.get_cstr(), converted_ts, Oscl_Int64_Utils::get_uint64_lower32(clientClock64), diff32, oDelayEstablished));
+            PVMF_JBNODE_LOG_RTCP((0, "RTCP_PKT: Mime=%s, RTP_TS=%d, C_CLOCK=%d, DIFF=%d, RE-BUF=%d", aInputPortParamsPtr->iMimeType.get_cstr(), converted_ts, clientClock32, diff32, oDelayEstablished));
             App.pss0_app_data.playoutdelayinms = (uint16)diff32;
             App.pss0_app_data.nsn = (jbStats.lastRetrievedSeqNum + 1);
             if (0 == jbStats.lastRetrievedSeqNum)
@@ -2563,8 +2508,7 @@
                 App.pss0_app_data.nsn = jbStats.seqNumBase;
             }
             App.pss0_app_data.nun = RTCP_NADU_APP_DEFAULT_NUN;
-            PVMFJitterBufferPort* jbPort =
-                OSCL_STATIC_CAST(PVMFJitterBufferPort*, aInputPortParamsPtr->iPort);
+
             uint32 fbsInBytes = 0;
             if (jbStats.packetSizeInBytesLeftInBuffer < aInputPortParamsPtr->iRateAdaptationFreeBufferSpaceInBytes)
             {
@@ -2613,6 +2557,241 @@
     return status;
 }
 
+bool PVMFJitterBufferNode::ProcessRTCPSRforAVSync()
+{
+    // The following criteria must hold before the RTCP SRs can be processed for a/v sync
+    // a) The Jitter Buffers of all tracks have received at least one packet
+    // b) At least one RTCP report has been received for each track
+    // c) The wall clock value of the RTCP SRs is not zero
+
+    // temporary vectors to save the indexes of rtcp and input ports
+    Oscl_Vector<uint32, PVMFJitterBufferNodeAllocator> indexesRTCPPort;
+    Oscl_Vector<uint32, PVMFJitterBufferNodeAllocator> indexesInputPort;
+
+    // Check the criteria
+    for (uint32 ii = 0; ii < iPortParamsQueue.size(); ii++)
+    {
+        PVMFJitterBufferPortParams& portParams = iPortParamsQueue[ii];
+        if (portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+        {
+            // make sure the JB has received data
+            uint32 tsOffset = 0;
+            if (portParams.iJitterBuffer->GetRTPTimeStampOffset(tsOffset) == false)
+                return false;
+
+            // Save the index for later processing
+            int32 err = OsclErrNone;
+            OSCL_TRY(err, indexesInputPort.push_back(ii));
+            if (err != OsclErrNone)
+                return false;
+        }
+        else
+            if (portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
+            {
+                // make sure we have an RTCP report available
+                if (portParams.iRTCPStats.lastSenderReportRecvTime == OSCL_STATIC_CAST(uint64, 0))
+                    return false;
+
+                // RTCP SR must have valid clock wall vale
+                if (portParams.iRTCPStats.lastSenderReportNTP == OSCL_STATIC_CAST(uint64, 0))
+                    return false;
+
+                // Save the index for later processing
+                int32 err = OsclErrNone;
+                OSCL_TRY(err, indexesRTCPPort.push_back(ii));
+                if (err != OsclErrNone)
+                    return false;
+
+            }
+    }
+
+    // for each feedback port there must be an input port
+    OSCL_ASSERT(indexesRTCPPort.size() == indexesInputPort.size());
+
+    // temporary vector to save the calculated init ntp for each track
+    Oscl_Vector<uint64, PVMFJitterBufferNodeAllocator> initNtpTracks;
+
+    // temporary vector to save the calculated rtp timebase of each track
+    Oscl_Vector<uint32, PVMFJitterBufferNodeAllocator> RTPTBArray;
+
+    // Initialize temporary vectors
+    int32 err = OsclErrNone;
+    OSCL_TRY(err, initNtpTracks.reserve(indexesRTCPPort.size()));
+    if (err != OsclErrNone)
+        return false;
+
+    OSCL_TRY(err, RTPTBArray.push_back(indexesRTCPPort.size()));
+    if (err != OsclErrNone)
+        return false;
+
+    for (uint32 tt = 0; tt < indexesRTCPPort.size(); tt++)
+    {
+        initNtpTracks.push_back(0);
+        RTPTBArray.push_back(0);
+    }
+
+
+    // Find the track whose first rtp packet correspond to the smallest NTP
+    uint32 lowestNTPIndex = 0;
+    uint64 lowestNTP = 0;
+    for (uint32 jj = 0; jj < indexesRTCPPort.size(); jj++)
+    {
+        PVMFJitterBufferPortParams& inputPortParams = iPortParamsQueue[indexesInputPort[jj]];
+        PVMFJitterBufferPortParams& rtcpPortParams = iPortParamsQueue[indexesRTCPPort[jj]];
+
+        uint32 firstRTP;
+        inputPortParams.iJitterBuffer->GetRTPTimeStampOffset(firstRTP);
+        uint32 timescale = inputPortParams.timeScale;
+        uint32 srRTP = rtcpPortParams.iRTCPStats.lastSenderReportRTP;
+        uint64 srNTP = rtcpPortParams.iRTCPStats.lastSenderReportNTP;
+
+        uint32 deltaRTP = 0;
+        if (srRTP >= firstRTP)
+        {
+            deltaRTP = srRTP - firstRTP;
+        }
+        else
+        {
+            deltaRTP = firstRTP - srRTP;
+        }
+
+        uint64 deltaRTPInNTPFormat = ((uint64) deltaRTP / (uint64)timescale) << 32;
+        deltaRTPInNTPFormat += ((uint64) deltaRTP % (uint64)timescale) * (uint64)0xFFFFFFFF / (uint64)timescale;
+
+        uint64 initNTP = 0;
+        if (srRTP >= firstRTP)
+        {
+            initNTP = srNTP - deltaRTPInNTPFormat;
+        }
+        else
+        {
+            initNTP = srNTP + deltaRTPInNTPFormat;
+        }
+
+
+        if (jj == 0)
+        {
+            lowestNTPIndex = jj;
+            lowestNTP = initNTP;
+        }
+        else
+            if (initNTP < lowestNTP)
+            {
+                lowestNTPIndex = jj;
+                lowestNTP = initNTP;
+            }
+
+        // Save the reference ntp value
+        initNtpTracks[jj] = initNTP;
+
+        PVMF_JBNODE_LOG_RTCP_AVSYNC((0,
+                                     "PVMFJitterBufferNode::ProcessRTCPSRforAVSync(): srRTP=%d, firstRTP=%d, timescale=%d srNTPHigh=0x%x, srNTPLow=0x%x initNTPHigh=0x%x initNTPLow=0x%x deltaRTPHigh=0x%x deltaRTPLow=0x%x",
+                                     srRTP, firstRTP, timescale, Oscl_Int64_Utils::get_uint64_upper32(srNTP), Oscl_Int64_Utils::get_uint64_lower32(srNTP),
+                                     Oscl_Int64_Utils::get_uint64_upper32(initNTP), Oscl_Int64_Utils::get_uint64_lower32(initNTP),
+                                     Oscl_Int64_Utils::get_uint64_upper32(deltaRTPInNTPFormat), Oscl_Int64_Utils::get_uint64_lower32(deltaRTPInNTPFormat)));
+
+    }
+
+
+    // Calculate the new timebase for all tracks
+    for (uint32 kk = 0; kk < indexesRTCPPort.size(); kk++)
+    {
+        PVMFJitterBufferPortParams& inputPortParams = iPortParamsQueue[indexesInputPort[kk]];
+        uint32 firstRTP;
+        inputPortParams.iJitterBuffer->GetRTPTimeStampOffset(firstRTP);
+
+        if (kk == lowestNTPIndex)
+        {
+            // Just set the RTP TB to the first rtp packet
+            RTPTBArray[kk] = firstRTP;
+        }
+        else
+        {
+            uint64 initNTP = initNtpTracks[kk];
+            uint32 timescale = inputPortParams.timeScale;
+
+            OSCL_ASSERT(lowestNTP <= initNTP);
+
+            uint64 deltaNTP = initNTP - lowestNTP;
+            uint32 deltaNTPInRTPUnits = ((deltaNTP * (uint64)timescale) + (uint64)0x80000000) >> 32;
+            uint32 rtpTimeBase = firstRTP - deltaNTPInRTPUnits;
+            RTPTBArray[kk] = rtpTimeBase;
+        }
+    }
+
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
+    // Log parameters
+    for (uint32 mm = 0; mm < indexesRTCPPort.size(); mm++)
+    {
+        PVMFJitterBufferPortParams& inputPortParams = iPortParamsQueue[indexesInputPort[mm]];
+        PVMFJitterBufferPortParams& rtcpPortParams = iPortParamsQueue[indexesRTCPPort[mm]];
+
+        uint32 firstRTP;
+        inputPortParams.iJitterBuffer->GetRTPTimeStampOffset(firstRTP);
+        uint32 timescale = inputPortParams.timeScale;
+        uint32 srRTP = rtcpPortParams.iRTCPStats.lastSenderReportRTP;
+        uint64 srNTP = rtcpPortParams.iRTCPStats.lastSenderReportNTP;
+        int32 delta = ((firstRTP - RTPTBArray[mm]) * 1000) / timescale;
+        uint32 srNTPHigh = Oscl_Int64_Utils::get_uint64_upper32(srNTP);
+        srNTP = srNTP & uint64(0xffffffff);
+        srNTP *= uint64(1000000);
+        srNTP += uint64(500000);
+        srNTP = srNTP / uint64(0xffffffff);
+        uint32 srNTPLow = Oscl_Int64_Utils::get_uint64_lower32(srNTP);
+
+        PVMF_JBNODE_LOG_RTCP_AVSYNC((0,
+                                     "Stream %d: mime=%s timeScale=%uHz firstTS=%u RTCP.RTP=%u RTCP.NTP=%u.%06u newTB=%u delta=%dms\n",
+                                     mm,
+                                     inputPortParams.iMimeType.get_cstr(),
+                                     timescale,
+                                     firstRTP,
+                                     srRTP,
+                                     srNTPHigh,
+                                     srNTPLow,
+                                     RTPTBArray[mm],
+                                     delta
+                                    )
+                                   );
+
+    }
+#endif
+
+    // Adjust the RTP TB
+    for (uint32 ll = 0; ll < indexesInputPort.size(); ll++)
+    {
+        PVMFJitterBufferPortParams& inputPortParams = iPortParamsQueue[indexesInputPort[ll]];
+        inputPortParams.iJitterBuffer->SetRTPTimeStampOffset(RTPTBArray[ll]);
+    }
+
+    //Notify SM plugin that RTP TB data is available for PVR purposes
+    // No need to create a public class to publish the format of the information sent in this event
+    // Just define this structure internally. The only client of this event is the SM broadcast
+    // plugin, so it's the only component that needs to be aware of this format
+    struct RTPTBInfoEventData
+    {
+        const PvmfMimeString* mimeType;
+        uint32 rtpTB;
+    };
+
+    for (uint32 nn = 0; nn < indexesInputPort.size(); nn++)
+    {
+        PVMFJitterBufferPortParams& inputPortParams = iPortParamsQueue[indexesInputPort[nn]];
+        RTPTBInfoEventData infoData;
+        infoData.mimeType = &(inputPortParams.iMimeType);
+        infoData.rtpTB = RTPTBArray[nn];
+        ReportInfoEvent(PVMFJitterBufferNodeRTCPDataProcessed, (OsclAny*)(&infoData));
+    }
+
+
+
+
+    iRTCPBcastAVSyncProcessed = true;
+    return true;
+}
+
+
+
+
 /////////////////////////////////////////////////////
 // Event reporting routines.
 /////////////////////////////////////////////////////
@@ -2627,8 +2806,8 @@
         PVUuid* aEventUUID,
         int32* aEventCode)
 {
-    PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferNode:NodeErrorEvent Type %d Data %d"
-                         , aEventType, aEventData));
+    PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode:NodeErrorEvent Type %d Data %d"
+                          , aEventType, aEventData));
 
     if (aEventUUID && aEventCode)
     {
@@ -2774,6 +2953,28 @@
             //nothing needed.
             break;
 
+        case PVMF_PORT_ACTIVITY_DISCONNECT:
+        {
+            /*
+             * flush the associated jitter buffer if a port is disconnected.
+             */
+            if (portParamsPtr->iJitterBuffer != NULL)
+            {
+                PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJitterBufferNode::HandlePortActivity - CancelDeallocationNotifications"));
+                for (uint32 i = 0; i < iPortParamsQueue.size(); i++)
+                {
+                    if (iPortParamsQueue[i].iBufferAlloc != NULL)
+                    {
+                        iPortParamsQueue[i].iBufferAlloc->CancelFreeMemoryAvailableCallback();
+                        iPortParamsQueue[i].iBufferAlloc->removeRef();
+                        iPortParamsQueue[i].iBufferAlloc = NULL;
+                    }
+                }
+                portParamsPtr->iJitterBuffer->FlushJitterBuffer();
+            }
+        }
+        break;
+
         case PVMF_PORT_ACTIVITY_OUTGOING_MSG:
         {
             if (portParamsPtr->oProcessOutgoingMessages)
@@ -3013,6 +3214,8 @@
 
         case PVMF_JITTER_BUFFER_PORT_TYPE_INPUT:
         {
+            PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferNode::ProcessPortActivity: input port- aPortParams->oProcessIncomingMessages %d aPortParams->iPort->IncomingMsgQueueSize()  %d" ,
+                                 aPortParams->oProcessIncomingMessages, aPortParams->iPort->IncomingMsgQueueSize()));
             if ((aPortParams->oProcessIncomingMessages) &&
                     (aPortParams->iPort->IncomingMsgQueueSize() > 0))
             {
@@ -3028,6 +3231,9 @@
 
         case PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK:
         {
+            PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferNode::ProcessPortActivity: - aPortParams->oProcessIncomingMessages %d aPortParams->iPort->IncomingMsgQueueSize()  %d" ,
+                                 aPortParams->oProcessIncomingMessages, aPortParams->iPort->IncomingMsgQueueSize()));
+
             if ((aPortParams->oProcessIncomingMessages) &&
                     (aPortParams->iPort->IncomingMsgQueueSize() > 0))
             {
@@ -3081,10 +3287,8 @@
 
     if (aPortParams->oMonitorForRemoteActivity == true)
     {
-        /* Cancel and reschedule in the inactivity timer */
-        iRemoteInactivityTimer->Cancel();
-        uint32 inactivityDurationInMS = iRemoteInactivityTimer->getMaxInactivityDurationInMS();
-        iRemoteInactivityTimer->RunIfNotReady(inactivityDurationInMS*1000);
+        CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+        RequestEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
     }
 
     switch (aPortParams->tag)
@@ -3106,7 +3310,7 @@
             if (!CheckForSpaceInJitterBuffer(aPort))
             {
                 aPortParams->oProcessIncomingMessages = false;
-                jitterBuffer->NotifyFreeSpaceAvailable(OSCL_STATIC_CAST(PVMFJitterBufferObserver*, this),
+                jitterBuffer->NotifyFreeSpaceAvailable(this,
                                                        OSCL_STATIC_CAST(OsclAny*, aPort));
                 int32 infocode = PVMFJitterBufferNodeJitterBufferFull;
                 ReportInfoEvent(PVMFInfoOverflow, (OsclAny*)(aPort), &eventuuid, &infocode);
@@ -3221,12 +3425,13 @@
             {
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
                 PVMFJitterBufferStats stats = jitterBuffer->getJitterBufferStats();
-                uint64 timebase64 = 0;
-                uint64 estServerClock = 0;
-                uint64 clientClock = 0;
-                iEstimatedServerClock->GetCurrentTime64(estServerClock, OSCLCLOCK_MSEC, timebase64);
+                uint32 timebase32 = 0;
+                uint32 estServerClock = 0;
+                uint32 clientClock = 0;
+                bool overflowFlag = false;
+                iEstimatedServerClock->GetCurrentTime32(estServerClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                 if (iClientPlayBackClock != NULL)
-                    iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_MSEC, timebase64);
+                    iClientPlayBackClock->GetCurrentTime32(clientClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 #endif
                 PVMFSharedMediaDataPtr inputDataPacket;
                 convertToPVMFMediaData(inputDataPacket, aMsg);
@@ -3282,7 +3487,6 @@
                         mediaDataIn->getMediaFragmentSize(i, fragsize);
                         if (fragsize > RTP_FIXED_HEADER_SIZE)
                         {
-
                             if (inputDataPacket->getNumFragments() > 1)
                             {
                                 if (aPortParams->oInPlaceProcessing == true)
@@ -3328,7 +3532,7 @@
                                     }
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
                                     PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJBNode::ProcessIncomingMsgRTP:"
-                                                                         "MaxSNReg=%d, MaxTSReg=%d, LastSNRet=%d, LastTSRet=%d, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
+                                                                         "MaxSNReg=%d, MaxTSReg=%u, LastSNRet=%d, LastTSRet=%u, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
                                                                          stats.maxSeqNumRegistered, stats.maxTimeStampRegistered,
                                                                          stats.lastRetrievedSeqNum, stats.maxTimeStampRetrieved,
                                                                          (stats.maxSeqNumRegistered - stats.lastRetrievedSeqNum),
@@ -3350,7 +3554,7 @@
                                     }
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
                                     PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJBNode::ProcessIncomingMsgRTP:"
-                                                                         "MaxSNReg=%d, MaxTSReg=%d, LastSNRet=%d, LastTSRet=%d, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
+                                                                         "MaxSNReg=%d, MaxTSReg=%u, LastSNRet=%d, LastTSRet=%u, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
                                                                          stats.maxSeqNumRegistered, stats.maxTimeStampRegistered,
                                                                          stats.lastRetrievedSeqNum, stats.maxTimeStampRetrieved,
                                                                          (stats.maxSeqNumRegistered - stats.lastRetrievedSeqNum),
@@ -3460,19 +3664,49 @@
 
 bool PVMFJitterBufferNode::CheckForPortRescheduling()
 {
+    //This method is only called from JB Node AO's Run.
+    //Purpose of this method is to determine whether the node
+    //needs scheduling based on any outstanding port activities
+    //Here is the scheduling criteria for different port types:
+    //a) PVMF_JITTER_BUFFER_PORT_TYPE_INPUT - If there are incoming
+    //msgs waiting in incoming msg queue then node needs scheduling,
+    //as long oProcessIncomingMessages is true. This boolean stays true
+    //as long we can register packets in JB. If JB is full this boolean
+    //is made false (when CheckForSpaceInJitterBuffer() returns false)
+    //and is once again made true in JitterBufferFreeSpaceAvailable() callback.
+    //We also use the input port briefly as a bidirectional port in case of
+    //RTSP streaming to do firewall packet exchange. So if there are outgoing
+    //msgs and oProcessOutgoingMessages is true then node needs scheduling.
+    //b) PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT - As long as:
+    //	- there are msgs in outgoing queue
+    //	- oProcessOutgoingMessages is true
+    //	- and as long as there is data in JB and we are not in buffering
+    //then node needs scheduling.
+    //c) PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK - As long as:
+    //	- there are msgs in incoming queue and oProcessIncomingMessages is true
+    //	- there are msgs in outgoing queue and oProcessOutgoingMessages is true
     uint32 i;
     for (i = 0; i < iPortVector.size(); i++)
     {
         PVMFJitterBufferPortParams* portContainerPtr = iPortVector[i]->iPortParams;
-
         if (portContainerPtr == NULL)
         {
             PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::CheckForPortRescheduling: Error - GetPortContainer failed"));
             return false;
         }
-
         if (portContainerPtr->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
         {
+            if (portContainerPtr->iPort->IncomingMsgQueueSize() > 0)
+            {
+                if (portContainerPtr->oProcessIncomingMessages)
+                {
+                    /*
+                     * Found a port that has outstanding activity and
+                     * is not busy.
+                     */
+                    return true;
+                }
+            }
             if (portContainerPtr->iPort->OutgoingMsgQueueSize() > 0)
             {
                 if (portContainerPtr->oProcessOutgoingMessages)
@@ -3489,13 +3723,36 @@
         {
             PVMFJitterBufferPort* jbPort =
                 OSCL_STATIC_CAST(PVMFJitterBufferPort*, portContainerPtr->iPort);
-
-            if ((portContainerPtr->iPort->IncomingMsgQueueSize() > 0) ||
-                    (portContainerPtr->iPort->OutgoingMsgQueueSize() > 0) ||
+            if ((portContainerPtr->iPort->OutgoingMsgQueueSize() > 0) ||
                     ((jbPort->iCounterpartPortParams->oJitterBufferEmpty == false) &&
-                     (oDelayEstablished == true)))
+                     (oDelayEstablished == true) && !IsCallbackPending(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, jbPort->iCounterpartPortParams)))
             {
-                if (portContainerPtr->oProcessOutgoingMessages && (oStopOutputPorts == false))
+                if ((portContainerPtr->oProcessOutgoingMessages) && (oStopOutputPorts == false))
+                {
+                    /*
+                     * Found a port that has outstanding activity and
+                     * is not busy.
+                     */
+                    return true;
+                }
+            }
+        }
+        else if (portContainerPtr->tag == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
+        {
+            if (portContainerPtr->iPort->IncomingMsgQueueSize() > 0)
+            {
+                if (portContainerPtr->oProcessIncomingMessages)
+                {
+                    /*
+                     * Found a port that has outstanding activity and
+                     * is not busy.
+                     */
+                    return true;
+                }
+            }
+            if (portContainerPtr->iPort->OutgoingMsgQueueSize() > 0)
+            {
+                if (portContainerPtr->oProcessOutgoingMessages)
                 {
                     /*
                      * Found a port that has outstanding activity and
@@ -3522,7 +3779,7 @@
 
         if (!getPortContainer(iPortVector[i], portContainerPtr))
         {
-            PVMF_JBNODE_LOGERROR((0, "0x%x PVMFJitterBufferNode::CheckForPortRescheduling: Error - GetPortContainer failed", this));
+            PVMF_JBNODE_LOGERROR((0, "0x%x PVMFJitterBufferNode::CheckForPortActivityQueues: Error - GetPortContainer failed", this));
             return false;
         }
 
@@ -3627,7 +3884,7 @@
          * data, and we need to make sure we send out the remaining
          * jitter buffer contents onward.
          */
-        if (oSessionDurationExpired)
+        if (oSessionDurationExpired || RTCPByeRcvd())
         {
             Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
             for (it = iPortParamsQueue.begin();
@@ -3703,6 +3960,23 @@
     return;
 }
 
+bool PVMFJitterBufferNode::RTCPByeRcvd()
+{
+    bool retval = false;
+    Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+    for (it = iPortParamsQueue.begin();
+            it != iPortParamsQueue.end();
+            it++)
+    {
+        if (it->iRTCPStats.oRTCPByeRecvd)
+        {
+            retval = true;
+            break;
+        }
+    }
+    return retval;
+}
+
 void PVMFJitterBufferNode::DoCancel()
 {
     /*
@@ -3747,6 +4021,7 @@
                                     bool aUserSpecifiedBuffParams,
                                     uint aMaxNumBuffResizes, uint aBuffResizeSize)
 {
+    OSCL_UNUSED_ARG(aUserSpecifiedBuffParams);
     uint32 i;
     for (i = 0; i < iPortParamsQueue.size(); i++)
     {
@@ -3760,9 +4035,7 @@
             portParams.iTrackConfig = aConfig;
             portParams.oRateAdaptation = aRateAdaptation;
             portParams.iRateAdaptationFeedBackFrequency = aRateAdaptationFeedBackFrequency;
-            /* Create Port Allocators */
-            PVMFJitterBufferPort* jbPort =
-                OSCL_STATIC_CAST(PVMFJitterBufferPort*, aPort);
+
             /* Compute buffer size based on bitrate and jitter duration*/
             uint32 sizeInBytes = 0;
             if (((int32)iJitterBufferDurationInMilliSeconds > 0) &&
@@ -3779,19 +4052,9 @@
                 sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);
             }
 
-            // the port allocators are required iff the node-level buffer
-            // allocator was not already created
-            if (this->iBufferAlloc == NULL)
+            if ((portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) || (portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK))
             {
-                if (aUserSpecifiedBuffParams)
-                {
-                    jbPort->createPortAllocators(portParams.iMimeType, sizeInBytes,
-                                                 aMaxNumBuffResizes, aBuffResizeSize);
-                }
-                else
-                {
-                    jbPort->createPortAllocators(portParams.iMimeType, sizeInBytes);
-                }
+                portParams.SetJitterBufferMemPoolInfo(sizeInBytes, aBuffResizeSize, aMaxNumBuffResizes, 3000);
             }
 
             portParams.iRateAdaptationFreeBufferSpaceInBytes = sizeInBytes;
@@ -3844,31 +4107,32 @@
             {
                 if (it->iJitterBuffer != NULL)
                 {
-                    uint64 timebase64 = 0;
-                    uint64 clientClock64 = 0;
+                    uint32 timebase32 = 0;
+                    uint32 clientClock32 = 0;
+                    bool overflowFlag = false;
                     if (iClientPlayBackClock != NULL)
-                        iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                        iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                    uint64 serverClock64 = 0;
-                    iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+                    uint32 serverClock32 = 0;
+                    iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::ClearJitterBuffer - Purging Upto SeqNum =%d", aSeqNum));
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::ClearJitterBuffer - Before Purge - EstServClock=%d",
-                                                 Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                                 serverClock32));
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::ClearJitterBuffer - Before Purge - ClientClock=%d",
-                                                 Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                 clientClock32));
 #endif
 
                     it->iJitterBuffer->PurgeElementsWithSeqNumsLessThan(aSeqNum,
-                            Oscl_Int64_Utils::get_uint64_lower32(clientClock64));
+                            clientClock32);
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                    timebase64 = 0;
-                    serverClock64 = 0;
-                    iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+                    timebase32 = 0;
+                    serverClock32 = 0;
+                    iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::ClearJitterBuffer - After Purge - EstServClock=%d",
-                                                 Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                                 serverClock32));
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::ClearJitterBuffer - After Purge - ClientClock=%d",
-                                                 Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                 clientClock32));
 #endif
                     it->iJitterBuffer->SetEOS(false);
                     /*
@@ -3894,6 +4158,7 @@
                                        uint32 aSeqNumBase,
                                        bool   aRTPTimeBasePresent,
                                        uint32 aRTPTimeBase,
+                                       bool   aNPTTimeBasePresent,
                                        uint32 aNPTInMS,
                                        bool oPlayAfterASeek)
 {
@@ -3926,35 +4191,37 @@
                     rtpInfoParams.seqNum = aSeqNumBase;
                     rtpInfoParams.rtpTimeBaseSet = aRTPTimeBasePresent;
                     rtpInfoParams.rtpTime = aRTPTimeBase;
+                    rtpInfoParams.nptTimeBaseSet = aNPTTimeBasePresent;
                     rtpInfoParams.nptTimeInMS = aNPTInMS;
                     rtpInfoParams.rtpTimeScale = portParams.timeScale;
-                    portParams.iJitterBuffer->setRTPInfoParams(rtpInfoParams);
+                    portParams.iJitterBuffer->setRTPInfoParams(rtpInfoParams, oPlayAfterASeek);
                     /* In case this is after a reposition purge the jitter buffer */
                     if (oPlayAfterASeek)
                     {
-                        uint64 timebase64 = 0;
-                        uint64 clientClock64 = 0;
+                        uint32 timebase32 = 0;
+                        uint32 clientClock32 = 0;
+                        bool overflowFlag = false;
                         if (iClientPlayBackClock != NULL)
-                            iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                            iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                        uint64 serverClock64 = 0;
-                        iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+                        uint32 serverClock32 = 0;
+                        iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                         PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::setPortRTPParams - Purging Upto SeqNum =%d", aSeqNumBase));
                         PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::setPortRTPParams - Before Purge - EstServClock=%d",
-                                                     Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                                     serverClock32));
                         PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::setPortRTPParams - Before Purge - ClientClock=%d",
-                                                     Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                     clientClock32));
 #endif
                         portParams.iJitterBuffer->PurgeElementsWithSeqNumsLessThan(aSeqNumBase,
-                                Oscl_Int64_Utils::get_uint64_lower32(clientClock64));
+                                clientClock32);
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                        timebase64 = 0;
-                        serverClock64 = 0;
-                        iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+                        timebase32 = 0;
+                        serverClock32 = 0;
+                        iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                         PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::setPortRTPParams - After Purge - EstServClock=%d",
-                                                     Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                                     serverClock32));
                         PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::setPortRTPParams - After Purge - ClientClock=%d",
-                                                     Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                     clientClock32));
 #endif
                         /*
                          * Since we flushed the jitter buffer, set it to ready state,
@@ -4055,7 +4322,7 @@
         {
             PVMF_JBNODE_LOG_FW((0, "PVMFJitterBufferNode::setServerInfo: Fw Pkt Exchange Start - PVMF_JB_FW_PKT_FORMAT_PV"));
         }
-        iFireWallPacketTimer->Start();
+        RequestEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET);
         PVMFStatus status = SendFireWallPackets();
         if (status != PVMFSuccess)
         {
@@ -4274,19 +4541,19 @@
                     UpdateRebufferingStats(PVMFInfoDataReady);
                     ReportInfoEvent(PVMFInfoDataReady);
                     ReportInfoEvent(PVMFInfoBufferingComplete);
-                    /* Cancel Buffering status timer */
-                    iBufferingStatusTimer->Cancel(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID);
+                    CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                    uint64 timebase64 = 0;
-                    uint64 clientClock64 = 0;
-                    uint64 serverClock64 = 0;
+                    uint32 timebase32 = 0;
+                    uint32 clientClock32 = 0;
+                    uint32 serverClock32 = 0;
+                    bool overflowFlag = false;
                     if (iClientPlayBackClock != NULL)
-                        iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
-                    iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+                        iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+                    iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::RegisterDataPacket - Time Delay Established - EstServClock=%d",
-                                                 Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                                 serverClock32));
                     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::RegisterDataPacket - Time Delay Established - ClientClock=%d",
-                                                 Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                 clientClock32));
 #endif
                 }
                 iJitterDelayPercent = 100;
@@ -4306,8 +4573,9 @@
 }
 
 bool
-PVMFJitterBufferNode::IsJitterBufferReady(PVMFJitterBufferPortParams* aPortParams)
+PVMFJitterBufferNode::IsJitterBufferReady(PVMFJitterBufferPortParams* aPortParams, uint32& aClockDiff)
 {
+    aClockDiff = iJitterBufferDurationInMilliSeconds;
     PVMFJitterBuffer* aJitterBuffer = aPortParams->iJitterBuffer;
     if (iJitterBufferState == PVMF_JITTER_BUFFER_IN_TRANSITION)
     {
@@ -4341,22 +4609,25 @@
         }
     }
 
-    uint64 timebase64 = 0;
-    uint64 estServerClock = 0;
-    uint64 clientClock = 0;
+    uint32 timebase32 = 0;
+    uint32 estServerClock = 0;
+    uint32 clientClock = 0;
+    bool overflowFlag = false;
+    uint32 minPercentOccupancy = 100;
+
     /*
      * Get current estimated server clock in milliseconds
      */
-    iEstimatedServerClock->GetCurrentTime64(estServerClock, OSCLCLOCK_USEC, timebase64);
+    iEstimatedServerClock->GetCurrentTime32(estServerClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 
     /*
      * Get current client playback clock in milliseconds
      */
     if (iClientPlayBackClock != NULL)
-        iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_USEC, timebase64);
+        iClientPlayBackClock->GetCurrentTime32(clientClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 
-    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - EstServClock=%2d", estServerClock));
-    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - ClientClock=%2d", clientClock));
+    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - EstServClock=%d", estServerClock));
+    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - ClientClock=%d", clientClock));
 
     if (oSessionDurationExpired)
     {
@@ -4376,10 +4647,9 @@
             ReportInfoEvent(PVMFInfoBufferingStatus);
             ReportInfoEvent(PVMFInfoDataReady);
             ReportInfoEvent(PVMFInfoBufferingComplete);
-            /* Cancel Buffering status timer */
-            iBufferingStatusTimer->Cancel(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID);
+            CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
             PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Cancelling Jitter Buffer Duration Timer"));
-            iJitterBufferDurationTimer->Cancel();
+            CancelEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
         }
         oDelayEstablished = true;
     }
@@ -4390,16 +4660,14 @@
             /* Could happen during repositioning */
             if (oDelayEstablished == true)
             {
+                aClockDiff = 0;
                 oDelayEstablished = false;
                 iJitterDelayPercent = 0;
                 /* Start timer */
-                iBufferingStatusTimer->Request(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID,
-                                               0,
-                                               PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_CYCLES,
-                                               this);
+                RequestEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
 
                 PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Starting Jitter Buffer Duration Timer"));
-                iJitterBufferDurationTimer->Start();
+                RequestEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
 
                 if (oStartPending == false)
                 {
@@ -4412,109 +4680,150 @@
                     ReportInfoEvent(PVMFInfoBufferingStart);
                     ReportInfoEvent(PVMFInfoBufferingStatus);
                 }
-                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - EstServClock=%2d", estServerClock));
-                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - ClientClock=%2d", clientClock));
+                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - EstServClock=%d",
+                                      Oscl_Int64_Utils::get_uint64_lower32(estServerClock)));
+                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - ClientClock=%d",
+                                      Oscl_Int64_Utils::get_uint64_lower32(clientClock)));
                 PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Estimated Serv Clock Less Than ClientClock!!!!"));
                 PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - EstServClock=%d",
-                                             Oscl_Int64_Utils::get_uint64_lower32(estServerClock) / 1000));
+                                             Oscl_Int64_Utils::get_uint64_lower32(estServerClock)));
                 PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Check - ClientClock=%d",
-                                             Oscl_Int64_Utils::get_uint64_lower32(clientClock) / 1000));
+                                             Oscl_Int64_Utils::get_uint64_lower32(clientClock)));
                 PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Estimated Serv Clock Less Than ClientClock!!!!"));
             }
             return oDelayEstablished;
         }
 
 
-        uint64 diff64 = estServerClock - clientClock;
-        uint32 diff32 = Oscl_Int64_Utils::get_uint64_lower32(diff64);
-        uint32 diff32ms = diff32 / 1000;
-        if (diff32ms >= iJitterBufferDurationInMilliSeconds)
-        {
-            if (oDelayEstablished == false && aJitterBuffer->CheckNumElements() == true)
+        uint32 diff32ms = estServerClock - clientClock;
+        aClockDiff = diff32ms;
+            if (diff32ms >= iJitterBufferDurationInMilliSeconds)
             {
-                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Cancelling Jitter Buffer Duration Timer"));
-                iJitterBufferDurationTimer->Cancel();
-                /* Coming out of rebuffering */
-                UpdateRebufferingStats(PVMFInfoDataReady);
-                iJitterDelayPercent = 100;
-                ReportInfoEvent(PVMFInfoBufferingStatus);
-                ReportInfoEvent(PVMFInfoDataReady);
-                ReportInfoEvent(PVMFInfoBufferingComplete);
-                /* Cancel Buffering status timer */
-                iBufferingStatusTimer->Cancel(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID);
-                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - EstServClock=%2d", estServerClock));
-                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - ClientClock=%2d",  clientClock));
-                PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - EstServClock=%d",
-                                             Oscl_Int64_Utils::get_uint64_lower32(estServerClock) / 1000));
-                PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - ClientClock=%d",
-                                             Oscl_Int64_Utils::get_uint64_lower32(clientClock) / 1000));
-                if (iUseSessionDurationTimerForEOS == true)
+                for (uint32 i = 0; i < iPortParamsQueue.size(); i++)
                 {
-                    ComputeCurrentSessionDurationMonitoringInterval();
-                    iSessionDurationTimer->Start();
+                    PVMFJitterBufferPortParams portParams = iPortParamsQueue[i];
+
+                    if (portParams.iBufferAlloc != NULL)
+                    {
+                        uint32 largestContiguousFreeBlockSize = portParams.iBufferAlloc->getLargestContiguousFreeBlockSize();
+                        uint32 jbSize = portParams.iBufferAlloc->getBufferSize();
+                        if ((largestContiguousFreeBlockSize*100 / jbSize) < minPercentOccupancy)
+                        {
+                            minPercentOccupancy = (uint32)(largestContiguousFreeBlockSize * 100 / jbSize);
+                        }
+                    }
+                }
+
+                if ((prevMinPercentOccupancy < MIN_PERCENT_OCCUPANCY_THRESHOLD) && (minPercentOccupancy < MIN_PERCENT_OCCUPANCY_THRESHOLD))
+                {
+                    consecutiveLowBufferCount++;
                 }
                 else
                 {
-                    iSessionDurationTimer->Stop();
+                    consecutiveLowBufferCount = 0;
                 }
-                oDelayEstablished = true;
-            }
-            iJitterDelayPercent = 100;
-        }
-        else
-        {
-            /*
-             * Update the buffering percent - to be used while sending buffering
-             * status events, in case we go into rebuffering or if we are in buffering
-             * state.
-             */
-            iJitterDelayPercent = ((diff32ms * 100) / iJitterBufferDurationInMilliSeconds);
-            if (oDelayEstablished == true)
-            {
-                if (diff32ms <= iJitterBufferUnderFlowThresholdInMilliSeconds)
+                prevMinPercentOccupancy = minPercentOccupancy;
+                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - minPercentOccupancy=%d, consecutiveLowBufferCount=%d",
+                                      minPercentOccupancy,
+                                      consecutiveLowBufferCount));
+
+
+                if ((diff32ms > JITTER_BUFFER_DURATION_MULTIPLIER_THRESHOLD*iJitterBufferDurationInMilliSeconds) && !iOverflowFlag && (consecutiveLowBufferCount > CONSECUTIVE_LOW_BUFFER_COUNT_THRESHOLD))
                 {
-                    /* Implies that we are going into rebuffering */
-                    if (oSessionDurationExpired == false)
-                    {
-                        oDelayEstablished = false;
-                        /* Start timer */
-                        iBufferingStatusTimer->Request(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID,
-                                                       0,
-                                                       PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_CYCLES,
-                                                       this);
-
-                        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Starting Jitter Buffer Duration Timer"));
-                        iJitterBufferDurationTimer->Start();
-
-                        /* Supress underflow if start pending */
-                        if (oStartPending == false)
-                        {
-                            /* Cancel session duration timer while rebuffering */
-                            PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::IsJitterBufferReady - Going into Rebuffering - Cancelling Session Duration Timer"));
-                            iSessionDurationTimer->Cancel();
-
-                            UpdateRebufferingStats(PVMFInfoUnderflow);
-                            ReportInfoEvent(PVMFInfoUnderflow);
-                            ReportInfoEvent(PVMFInfoBufferingStart);
-                            ReportInfoEvent(PVMFInfoBufferingStatus);
-
-                            PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - EstServClock=%2d", estServerClock));
-                            PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - ClientClock=%2d",  clientClock));
-                            PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady: Jitter Delay not met"));
-                            PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - EstServClock=%d",
-                                                         Oscl_Int64_Utils::get_uint64_lower32(estServerClock) / 1000));
-                            PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - ClientClock=%d",
-                                                         Oscl_Int64_Utils::get_uint64_lower32(clientClock) / 1000));
-
-                            if (iClientPlayBackClock != NULL)
-                                iClientPlayBackClock->Pause();
-                        }
-                    }
-                    /* we are past the end of the clip, no more rebuffering */
+                    iOverflowFlag = true;
+                    ReportInfoEvent(PVMFInfoSourceOverflow);
+                    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady reporting PVMFInfoSourceOverflow"));
                 }
+                if (oDelayEstablished == false && aJitterBuffer->CheckNumElements() == true)
+                {
+                    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Cancelling Jitter Buffer Duration Timer"));
+                    oDelayEstablished = true;
+                    CancelEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
+                    /* Coming out of rebuffering */
+                    UpdateRebufferingStats(PVMFInfoDataReady);
+                    iJitterDelayPercent = 100;
+                    ReportInfoEvent(PVMFInfoBufferingStatus);
+                    ReportInfoEvent(PVMFInfoDataReady);
+                    ReportInfoEvent(PVMFInfoBufferingComplete);
+                    CancelEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
+                    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - EstServClock=%d", estServerClock));
+                    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - ClientClock=%d",  clientClock));
+                    PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - EstServClock=%d",
+                                                 estServerClock));
+                    PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Established - ClientClock=%d",
+                                                 clientClock));
+                    if (iUseSessionDurationTimerForEOS == true)
+                    {
+                        ComputeCurrentSessionDurationMonitoringInterval();
+                        iSessionDurationTimer->Start();
+                    }
+                    else
+                    {
+                        iSessionDurationTimer->Stop();
+                    }
+                }
+                else if (oDelayEstablished == false && aJitterBuffer->CheckNumElements() == false)
+                {
+                    iJitterDelayPercent = 0;
+                }
+                else
+                    iJitterDelayPercent = 100;
             }
-            PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady: Delay Percent = %d", iJitterDelayPercent));
-        }
+            else
+            {
+                /*
+                 * Update the buffering percent - to be used while sending buffering
+                 * status events, in case we go into rebuffering or if we are in buffering
+                 * state.
+                 */
+                iJitterDelayPercent = ((diff32ms * 100) / iJitterBufferDurationInMilliSeconds);
+                if (oDelayEstablished == true)
+                {
+                    if (diff32ms <= iJitterBufferUnderFlowThresholdInMilliSeconds)
+                    {
+                        /* Implies that we are going into rebuffering */
+                        if (oSessionDurationExpired == false)
+                        {
+                            oDelayEstablished = false;
+                            /* Start timer */
+                            RequestEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
+
+                            PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Starting Jitter Buffer Duration Timer"));
+                            RequestEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
+
+                            /* Supress underflow if start pending */
+                            if (oStartPending == false)
+                            {
+                                /* Cancel session duration timer while rebuffering */
+                                PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::IsJitterBufferReady - Going into Rebuffering - Cancelling Session Duration Timer"));
+                                iSessionDurationTimer->Cancel();
+
+                                UpdateRebufferingStats(PVMFInfoUnderflow);
+                                ReportInfoEvent(PVMFInfoUnderflow);
+                                ReportInfoEvent(PVMFInfoBufferingStart);
+                                ReportInfoEvent(PVMFInfoBufferingStatus);
+
+                                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - EstServClock=%d", estServerClock));
+                                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - ClientClock=%d",  clientClock));
+                                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady: Jitter Delay not met"));
+                                PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - EstServClock=%d",
+                                                             estServerClock));
+                                PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::IsJitterBufferReady - Time Delay Violated - ClientClock=%d",
+                                                             clientClock));
+
+                                if (iClientPlayBackClock != NULL)
+                                    iClientPlayBackClock->Pause();
+                            }
+                        }
+                        /* we are past the end of the clip, no more rebuffering */
+                    }
+                }
+                if (oDelayEstablished == false && aJitterBuffer->CheckNumElements() == false)
+                {
+                    iJitterDelayPercent = 0;
+                }
+                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::IsJitterBufferReady: Delay Percent = %d", iJitterDelayPercent));
+            }
         /* if we are not rebuffering check for flow control */
         PVMFPortInterface* aPort = findPortForJitterBuffer(aJitterBuffer);
         if (aPort != NULL)
@@ -4542,16 +4851,10 @@
                             if (it->oMonitorForRemoteActivity == false)
                             {
                                 it->oMonitorForRemoteActivity = true;
-                                /* Cancel and reschedule in the inactivity timer */
-                                iRemoteInactivityTimer->Cancel();
-                                uint32 inactivityDurationInMS = iRemoteInactivityTimer->getMaxInactivityDurationInMS();
-                                iRemoteInactivityTimer->RunIfNotReady(inactivityDurationInMS*1000);
+                                CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+                                RequestEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
                             }
                         }
-                        if (iBufferAlloc != NULL)
-                        {
-                            iBufferAlloc->CancelFreeChunkAvailableCallback();
-                        }
                         ReportInfoEvent(PVMFJitterBufferNodeJitterBufferLowWaterMarkReached);
                         PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E((0, "PVMFJitterBufferNode::IsJitterBufferReady: Sending Auto Resume"));
                     }
@@ -4574,18 +4877,21 @@
 PVMFStatus
 PVMFJitterBufferNode::SendData(PVMFPortInterface* aPort)
 {
+
     PVMFJitterBufferPort* jbPort =
         OSCL_STATIC_CAST(PVMFJitterBufferPort*, aPort);
     PVMFPortInterface* outputPort = jbPort->iPortCounterpart;
     PVMFJitterBufferPortParams* portParamsPtr = jbPort->iPortParams;
     PVMFJitterBufferPortParams* outPortParamsPtr = jbPort->iCounterpartPortParams;
     PVMFJitterBuffer* jitterBuffer = portParamsPtr->iJitterBuffer;
+
     if (jitterBuffer == NULL)
     {
         return PVMFFailure;
     }
 
-    bool oJitterBufferReady = IsJitterBufferReady(portParamsPtr);
+    uint32 clockDiff = 0;
+    bool oJitterBufferReady = IsJitterBufferReady(portParamsPtr, clockDiff);
     if (oJitterBufferReady == false)
     {
         /* Jitter Buffer not ready - dont send data */
@@ -4605,24 +4911,25 @@
         {
             /* Cant send */
             outPortParamsPtr->oProcessOutgoingMessages = false;
-            PVMF_JBNODE_LOGDATATRAFFIC((0, "PVMFJitterBufferNode::SendData: Output Queue Busy - Mime=%s", outPortParamsPtr->iMimeType.get_cstr()));
+            PVMF_JBNODE_LOGDATATRAFFIC((0, "PVMFJitterBufferNode::SendData: Output Queue Busy %x outport - Mime=%s", outputPort, outPortParamsPtr->iMimeType.get_cstr()));
             return PVMFErrBusy;
         }
 
         PVMFSharedMediaDataPtr mediaOut;
         PVMFSharedMediaMsgPtr mediaOutMsg;
-
         /* Check if there are any pending media commands */
         if (jitterBuffer->CheckForPendingCommands(mediaOutMsg) == true)
         {
             PVMFStatus status = outputPort->QueueOutgoingMsg(mediaOutMsg);
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-            uint64 timebase64 = 0;
-            uint64 clientClock64 = 0;
+            uint32 timebase32 = 0;
+            uint32 clientClock32 = 0;
+            bool overflowFlag = false;
+
             if (iClientPlayBackClock != NULL)
-                iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
             PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::SendData: Media Command Sent, Mime=%s, CmdId=%d, TS=%d, SEQNUM= %d, ClientClock= %2d",
-                                            portParamsPtr->iMimeType.get_cstr(), mediaOutMsg->getFormatID(), mediaOutMsg->getTimestamp(), mediaOutMsg->getSeqNum(), clientClock64));
+                                            portParamsPtr->iMimeType.get_cstr(), mediaOutMsg->getFormatID(), mediaOutMsg->getTimestamp(), mediaOutMsg->getSeqNum(), clientClock32));
 #endif
             if (status != PVMFSuccess)
             {
@@ -4632,34 +4939,63 @@
         }
 
         PVMFJitterBufferStats stats = jitterBuffer->getJitterBufferStats();
+
         if (stats.currentOccupancy > 0)
         {
             portParamsPtr->oJitterBufferEmpty = false;
-
-            if (iBufferAlloc != NULL)
-            {
-                iBufferAlloc->CancelDeallocationNotifications();
-            }
-
             PVMFTimestamp ts;
             uint32 converted_ts;
             uint32 in_wrap_count = 0;
+            /*
+            * Check and see if the current read position is pointing
+            * to a hole in the jitter buffer due to packet loss
+            */
+            if (jitterBuffer->CheckCurrentReadPosition() == false)
             {
-//This option disables playback until the A/V Sync is complete.
-//This feature is incomplete as it lacks a time-out mechanism.
-//An alternative may be to increase the jitter buffer size.
-#ifdef AVSYNC_WAIT_FOR_RTCP_SENDER_REPORTS
-                //Only need to wait for A/V sync if we have both audio and video RTCP ports.
-                if (hasAudioRTCP && hasVideoRTCP && !gotRTCPReports)
-                {
-                    //Wait for RTCP Sender Reports to arrive before outputting
-                    //packets.
-                    return PVMFErrBusy;
-                }
-#endif
+                /*
+                 * Peek Next timestamp
+                 */
+                ts = jitterBuffer->peekNextElementTimeStamp();
 
-                mediaOut = jitterBuffer->retrievePacket();
+                /*
+                 * Convert Time stamp to milliseconds
+                 */
+                portParamsPtr->mediaClockConverter.set_clock(ts, in_wrap_count);
+                converted_ts =
+                    portParamsPtr->mediaClockConverter.get_converted_ts(1000);
+                /*
+                 * Get current client playback clock in milliseconds
+                 */
+                uint32 clientClock;
+                bool overflowFlag = false;
+                if (iClientPlayBackClock != NULL)
+                    iClientPlayBackClock->GetCurrentTime32(clientClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+
+
+                uint32 estimatedServClock = 0;
+                overflowFlag = false;
+                iEstimatedServerClock->GetCurrentTime32(estimatedServClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+                uint32 delta = 0;
+                if (!oSessionDurationExpired && (PVTimeComparisonUtils::IsEarlier(estimatedServClock, converted_ts + iEstimatedServerKeepAheadInMilliSeconds, delta) && (delta > 0)))
+                {
+                    //hold the available data packet, and wait for hole in the JB due to OOO packet to be filled
+                    if (!IsCallbackPending(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, portParamsPtr))
+                    {
+                        PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::SendData Detected Hole in JB PeekTs[%d] clientClock[%d] , ClientClockState [%d], estimatedServClock[%d], EstimatedServClockState[%d], oSessionDurationExpired[%d] MimeStr[%s]", converted_ts, clientClock, iClientPlayBackClock->GetState(), estimatedServClock, iEstimatedServerClock->GetState(), oSessionDurationExpired, portParamsPtr->iMimeType.get_cstr()));
+                        RequestEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE , delta, portParamsPtr);
+                    }
+                    return PVMFErrNotReady;
+                }
             }
+
+            //Cancel pending sequencing OOO packet callback (if any)
+            if (IsCallbackPending(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, portParamsPtr))
+            {
+                CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, portParamsPtr);
+            }
+
+            mediaOut = jitterBuffer->retrievePacket();
+
             PVMFStatus status = PVMFSuccess;
             if (mediaOut.GetRep() != NULL)
             {
@@ -4674,12 +5010,13 @@
                 status = outputPort->QueueOutgoingMsg(mediaOutMsg);
 
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                uint64 timebase64 = 0;
-                uint64 clientClock64 = 0;
-                uint64 serverClock64 = 0;
+                uint32 timebase32 = 0;
+                uint32 clientClock32 = 0;
+                uint32 serverClock32 = 0;
+                bool overflowFlag = false;
                 if (iClientPlayBackClock != NULL)
-                    iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
-                iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+                    iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+                iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                 outPortParamsPtr->iLastMsgTimeStamp = converted_ts;
 
                 //PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::SendData: EstServClock= %2d", serverClock64));
@@ -4688,15 +5025,15 @@
                                                 mediaOutMsg->getStreamID(),
                                                 mediaOutMsg->getTimestamp(),
                                                 mediaOutMsg->getSeqNum(),
-                                                clientClock64));
+                                                clientClock32));
 
                 PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJBNode::SendData:"
-                                                     "MaxSNReg=%d, MaxTSReg=%d, LastSNRet=%d, LastTSRet=%d, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
+                                                     "MaxSNReg=%d, MaxTSReg=%u, LastSNRet=%d, LastTSRet=%u, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
                                                      stats.maxSeqNumRegistered, stats.maxTimeStampRegistered,
                                                      stats.lastRetrievedSeqNum, stats.maxTimeStampRetrieved,
                                                      (stats.maxSeqNumRegistered - stats.lastRetrievedSeqNum),
-                                                     Oscl_Int64_Utils::get_uint64_lower32(serverClock64),
-                                                     Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                     serverClock32,
+                                                     clientClock32));
 #endif
 
                 if (status != PVMFSuccess)
@@ -4713,9 +5050,14 @@
              * the delay criteria has not been violated. There is no data
              * to send, but that is alright.
              */
-            PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::SendData: Jitter Buffer Empty - Mime=%s", portParamsPtr->iMimeType.get_cstr()));
+            //PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::SendData: Jitter Buffer Empty - Mime=%s", portParamsPtr->iMimeType.get_cstr()));
             portParamsPtr->oJitterBufferEmpty = true;
 
+            if ((iMonitorReBufferingCallBkPending == false) && (oSessionDurationExpired == false))
+            {
+                RequestEventCallBack(JB_MONITOR_REBUFFERING, (clockDiff - iJitterBufferUnderFlowThresholdInMilliSeconds));
+            }
+
             if (oAutoPause == false)
             {
             }
@@ -4727,17 +5069,13 @@
             PVMFStatus status = CheckForLowWaterMark(aPort, lowWaterMarkReached);
             if ((status == PVMFSuccess) && (lowWaterMarkReached == true))
             {
-                if (iBufferAlloc != NULL)
-                {
-                    iBufferAlloc->CancelFreeChunkAvailableCallback();
-                }
                 ReportInfoEvent(PVMFJitterBufferNodeJitterBufferLowWaterMarkReached);
                 PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E((0, "PVMFJitterBufferNode::SendData: Sending Auto Resume - Mime=%s", portParamsPtr->iMimeType.get_cstr()));
             }
             return PVMFSuccess;
         }
         //reevalute jitter
-        oJitterBufferReady = IsJitterBufferReady(portParamsPtr);
+        oJitterBufferReady = IsJitterBufferReady(portParamsPtr, clockDiff);
         if (oJitterBufferReady == false)
         {
             /* Jitter Buffer not ready - dont send data */
@@ -4762,53 +5100,62 @@
     {
         if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
         {
-            if (it->oJitterBufferEmpty == false)
+            if (it->oJitterBufferEmpty == true)
             {
-                oEmpty = false;
-                return PVMFSuccess;
+                oEmpty = true;
             }
         }
     }
-    oEmpty = true;
+
     return PVMFSuccess;
 }
 
 PVMFStatus PVMFJitterBufferNode::CheckForEOS()
 {
-    /*
-     * Checks to see if all jitter buffers are empty. If they are
-     * then it would stop scheduling the jitter buffer node, so generate
-     * EOS.
-     */
     Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
-    for (it = iPortParamsQueue.begin();
-            it != iPortParamsQueue.end();
-            it++)
-    {
-        if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
-        {
-            if (it->oJitterBufferEmpty == false)
-            {
-                return PVMFErrBusy;
-            }
-        }
-    }
-    /*
-     * Implies that all jitter buffers are empty
-     */
     PVMFStatus status = PVMFSuccess;
     for (it = iPortParamsQueue.begin();
             it != iPortParamsQueue.end();
             it++)
     {
-        if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+        if ((PVMF_JITTER_BUFFER_PORT_TYPE_INPUT == it->tag) && (it->oJitterBufferEmpty) && (!it->oEOSReached) && oSessionDurationExpired)
         {
+            PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::CheckForEOS: Mime is %s" , it->iMimeType.get_cstr()));
             status = GenerateAndSendEOSCommand(it->iPort);
         }
+        else if ((PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK == it->tag) && (it->iRTCPStats.oRTCPByeRecvd) && (!oSessionDurationExpired))
+        {
+            //look for corresponding input port for the feedback port on which RTCP bye is received.
+            PVMFJitterBufferPortParams* inputPortParam = NULL;
+            LocateInputPortForFeedBackPort(it, inputPortParam);
+            if (inputPortParam->oJitterBufferEmpty && (!inputPortParam->oEOSReached))
+            {
+                PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::CheckForEOS: Mime is %s" , it->iMimeType.get_cstr()));
+                GenerateAndSendEOSCommand(inputPortParam->iPort);
+            }
+        }
     }
+
+    //Check if EOS is send on all the input ports...
+    bool bEOSSendOnAllInputPorts = true;
+    for (it = iPortParamsQueue.begin();
+            it != iPortParamsQueue.end();
+            it++)
+    {
+        if ((PVMF_JITTER_BUFFER_PORT_TYPE_INPUT == it->tag) && (!it->oEOSReached))
+            bEOSSendOnAllInputPorts = false;
+    }
+
+    if (bEOSSendOnAllInputPorts)
+    {
+        oStopOutputPorts = true;
+        oSessionDurationExpired  = true;
+    }
+
     return status;
 }
 
+
 bool
 PVMFJitterBufferNode::setPlayRange(int32 aStartTimeInMS,
                                    int32 aStopTimeInMS,
@@ -4833,6 +5180,10 @@
         {
             /* Start RTCP Timer */
             ActivateTimer(it);
+            if (oPlayAfterASeek)
+            {
+                it->iRTCPStats.oRTCPByeRecvd = false;
+            }
         }
         if (oPlayAfterASeek)
         {
@@ -4847,9 +5198,9 @@
     if (iPlayStopTimeAvailable == true)
     {
         /* Start Session Duration Timer only if stop duration is set */
-        iSessionDurationTimer->Stop();
-        if (iUseSessionDurationTimerForEOS == true)
+        if ((iUseSessionDurationTimerForEOS == true) && (!oSessionDurationExpired || (oPlayAfterASeek)))
         {
+            iSessionDurationTimer->Stop();
             oSessionDurationExpired = false;
             iSessionDurationTimer->setSessionDurationInMS(((iPlayStopTimeInMS - iPlayStartTimeInMS) + PVMF_EOS_TIMER_GAURD_BAND_IN_MS));
             ComputeCurrentSessionDurationMonitoringInterval();
@@ -4857,6 +5208,7 @@
         }
         // Only at Prepare state, this API is called by streaming manager node
         // We set thinning interval in here
+#if 1
         //thinning timer value depends on clip duration
         uint32 duration = iPlayStopTimeInMS - iPlayStartTimeInMS;
         if (duration < PVMF_JITTER_BUFFER_NODE_THINNING_MIN_DURATION_MS)
@@ -4873,6 +5225,11 @@
         //in case of live streaming, hard-coded value is set
         iThinningIntervalMS = PVMF_JITTER_BUFFER_NODE_THINNING_LIVE_INTERVAL_MS;
     }
+#else
+    }
+    //thinning timer value is hard-corded for any cases
+    iThinningIntervalMS = 15 * 1000;
+#endif
 
     return true;
 }
@@ -4921,69 +5278,54 @@
 
     OSCL_ASSERT(it != iPortParamsQueue.end());
 
-    // timer reconsideration
-    uint32 timer = CalcRtcpInterval(it);
-    if (timer > it->iRTCPIntervalInMicroSeconds)
+    if (it->iRTCPStats.oRTCPByeRecvd == false)
     {
-        it->iRTCPTimer->RunIfNotReady(timer - it->iRTCPIntervalInMicroSeconds);
-        it->iRTCPIntervalInMicroSeconds = timer;
-        return;
-    }
-    else
-    {
-        GenerateRTCPRR(it);
+        // timer reconsideration
+        uint32 timer = CalcRtcpInterval(it);
+        if (timer > it->iRTCPIntervalInMicroSeconds)
+        {
+            it->iRTCPTimer->RunIfNotReady(timer - it->iRTCPIntervalInMicroSeconds);
+            it->iRTCPIntervalInMicroSeconds = timer;
+            return;
+        }
+        else
+        {
+            GenerateRTCPRR(it);
+        }
     }
 }
 
-/*
- * Called by PvmfJBInactivityTimer on inactivity timer expiry
- */
-void PVMFJitterBufferNode::PVMFJBInactivityTimerEvent()
-{
-    PVUuid eventuuid = PVMFJitterBufferNodeEventTypeUUID;
-    int32 errcode = PVMFJitterBufferNodeRemoteInactivityTimerExpired;
-    /*
-     * If start is pending, this means that inactivity timer expired
-     * during the buffering state. Send start failure, else send the
-     * info event
-     */
-    if (iCurrentCommand.size() > 0)
-    {
-        PVMFJitterBufferNodeCommand cmd = iCurrentCommand.front();
-        CommandComplete(cmd, PVMFFailure, NULL, &eventuuid, &errcode);
-        /* Erase the command from the current queue */
-        iCurrentCommand.Erase(&iCurrentCommand.front());
-    }
-    else
-    {
-        ReportErrorEvent(PVMFErrTimeout, NULL, &eventuuid, &errcode);
-    }
-    return;
-}
 
 /*
  * Called by PvmfJBSessionDurationTimer on session duration timer expiry
  */
 void PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent()
 {
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent ---------------"));
     PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent - Session Duration Timer Expired"));
     PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent - Session Duration Timer Expired"));
     /* Check if the estimated server clock is past the expected value */
-    uint64 expectedEstServClockVal =
+    uint32 expectedEstServClockVal =
         iSessionDurationTimer->GetExpectedEstimatedServClockValAtSessionEnd();
-    uint64 timebase64 = 0;
-    uint64 estServClock = 0;
-    iEstimatedServerClock->GetCurrentTime64(estServClock, OSCLCLOCK_MSEC, timebase64);
+    uint32 timebase32 = 0;
+    uint32 estServClock = 0;
+    bool overflowFlag = false;
+
+    iEstimatedServerClock->GetCurrentTime32(estServClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent - CurrEstServClock = %2d", estServClock));
     PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent - ExpectedEstServClock = %2d", expectedEstServClockVal));
     if (estServClock >= expectedEstServClockVal)
     {
+        PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent estServClock[%d] expectedEstServClockVal[%d]", estServClock, expectedEstServClockVal));
         PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent - Session Duration Has Elapsed"));
         oSessionDurationExpired = true;
+        CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
         /* Cancel clock update notifications */
         Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
         for (it = iPortParamsQueue.begin(); it != iPortParamsQueue.end(); it++)
         {
+            CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
+
             if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
             {
                 if (it->iJitterBuffer != NULL)
@@ -5023,6 +5365,7 @@
                 interval = PVMF_JITTER_BUFFER_NODE_SESSION_DURATION_MONITORING_INTERVAL_MAX_IN_MS;
             }
             iSessionDurationTimer->setCurrentMonitoringIntervalInMS(interval);
+            iSessionDurationTimer->ResetEstimatedServClockValAtLastCancel();
             PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::PVMFJBSessionDurationTimerEvent - TotalDuration=%d, ElapsedDuration=%d, CurrMonitoringInterval=%d", totalSessionDuration, elapsedSessionDurationInMS, interval));
         }
         else
@@ -5066,12 +5409,27 @@
 
 PVMFStatus PVMFJitterBufferNode::NotifyOutOfBandEOS()
 {
-    if (iJitterBufferState != PVMF_JITTER_BUFFER_IN_TRANSITION)
+    // Ignore Out Of Band EOS for any Non Live stream
+    if (iPlayStopTimeAvailable == false)
     {
-        oSessionDurationExpired = true;
-        iSessionDurationTimer->Cancel();
-        PVMF_JBNODE_LOGDATATRAFFIC((0, "PVMFJitterBufferNode::NotifyOutOfBandEOS - Out Of Band EOS Recvd"));
-        PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::NotifyOutOfBandEOS - Out Of Band EOS Recvd"));
+        if (iJitterBufferState != PVMF_JITTER_BUFFER_IN_TRANSITION)
+        {
+            oSessionDurationExpired = true;
+            CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+            Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+            for (it = iPortParamsQueue.begin(); it != iPortParamsQueue.end(); it++)
+            {
+                CancelEventCallBack(JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE, it);
+            }
+            iSessionDurationTimer->Cancel();
+            PVMF_JBNODE_LOGDATATRAFFIC((0, "PVMFJitterBufferNode::NotifyOutOfBandEOS - Out Of Band EOS Recvd"));
+            PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::NotifyOutOfBandEOS - Out Of Band EOS Recvd"));
+        }
+        else
+        {
+            PVMF_JBNODE_LOGDATATRAFFIC((0, "PVMFJitterBufferNode::NotifyOutOfBandEOS - Ignoring Out Of Band EOS in Transition State"));
+            PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::NotifyOutOfBandEOS - Ignoring Out Of Band EOS in Transition State"));
+        }
     }
     else
     {
@@ -5098,52 +5456,6 @@
     return PVMFSuccess;
 }
 
-/*
- * Buffering status event timer
- */
-void PVMFJitterBufferNode::TimeoutOccurred(int32 timerID,
-        int32 timeoutInfo)
-{
-    OSCL_UNUSED_ARG(timeoutInfo);
-
-    if (timerID == PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID)
-    {
-        if (oDelayEstablished == false)
-        {
-            /*
-             * Check to see if the session duration has expired
-             */
-            if (oSessionDurationExpired)
-            {
-                PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::TimeoutOccurred - Session Duration Expired"));
-                /* Force out of rebuffering */
-                Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
-                for (it = iPortParamsQueue.begin();
-                        it != iPortParamsQueue.end();
-                        it++)
-                {
-                    if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
-                    {
-                        SendData(it->iPort);
-                    }
-                }
-                if (IsAdded())
-                {
-                    RunIfNotReady();
-                }
-            }
-            else
-            {
-                ReportInfoEvent(PVMFInfoBufferingStatus);
-                iBufferingStatusTimer->Request(PVMF_JITTER_BUFFER_BUFFERING_STATUS_TIMER_ID,
-                                               0,
-                                               PVMF_JITTER_BUFFER_BUFFERING_STATUS_EVENT_CYCLES,
-                                               this);
-            }
-        }
-    }
-}
-
 bool PVMFJitterBufferNode::QueueBOSCommand(PVMFPortInterface* aPort)
 {
     PVMFPortInterface* outputPort = getPortCounterpart(aPort);
@@ -5205,7 +5517,6 @@
     /* Set EOS on jitter buffer so that we dont register any more packets */
     if (portParams->iJitterBuffer->GetEOS() == false)
     {
-        oStopOutputPorts = true;
         portParams->iJitterBuffer->SetEOS(true);
         PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: EOS Set On Jitter Buffer - MimeType=%s", portParams->iMimeType.get_cstr()));
         PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: EOS Set On Jitter Buffer - MimeType=%s", portParams->iMimeType.get_cstr()));
@@ -5243,61 +5554,39 @@
                 PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: Error - output queue busy"));
                 return status;
             }
-            uint64 timebase64 = 0;
-            uint64 clientClock64 = 0;
+            uint32 timebase32 = 0;
+            uint32 clientClock32 = 0;
+            bool overflowFlag = false;
             if (iClientPlayBackClock != NULL)
-                iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
-            timebase64 = 0;
-            uint64 estServClock64 = 0;
-            iEstimatedServerClock->GetCurrentTime64(estServClock64, OSCLCLOCK_MSEC, timebase64);
+                iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+            timebase32 = 0;
+            uint32 estServClock32 = 0;
+            iEstimatedServerClock->GetCurrentTime32(estServClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
             PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: MimeType=%s, StreamID=%d",
                                             portParams->iMimeType.get_cstr(),
                                             msg->getStreamID()));
             PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: ClientClock=%d",
-                                            Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                            clientClock32));
             PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: EstServClock=%d",
-                                            Oscl_Int64_Utils::get_uint64_lower32(estServClock64)));
+                                            estServClock32));
             PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: MimeType=%s, StreamID=%d",
                                                    portParams->iMimeType.get_cstr(),
                                                    msg->getStreamID()));
             PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: ClientClock=%d",
-                                                   Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                   clientClock32));
             PVMF_JBNODE_LOGCLOCK_SESSION_DURATION((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand: EstServClock=%d",
-                                                   Oscl_Int64_Utils::get_uint64_lower32(estServClock64)));
+                                                   estServClock32));
             portParams->oEOSReached = true;
             return (status);
         }
+        else
+        {
+            PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferNode::GenerateAndSendEOSCommand - EOS already sent..."));
+        }
     }
     return PVMFSuccess;
 }
 
-void PVMFJitterBufferNode::PVMFJBJitterBufferDurationTimerEvent()
-{
-    PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::PVMFJBJitterBufferDurationTimerEvent - Recvd"));
-    if (oDelayEstablished == false)
-    {
-        iJitterBufferDurationTimer->Start();
-
-        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::PVMFJBJitterBufferDurationTimerEvent - Trying To Force Out of Buffering"));
-        /* Force out of buffering */
-        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::PVMFJBJitterBufferDurationTimerEvent - Jitter Buffer Duration Expired"));
-        Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
-        for (it = iPortParamsQueue.begin();
-                it != iPortParamsQueue.end();
-                it++)
-        {
-            if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
-            {
-                SendData(it->iPort);
-            }
-        }
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-}
-
 PVMFStatus
 PVMFJitterBufferNode::DestroyFireWallPacketMemAllocators(PVMFJitterBufferPortParams* aPortParams)
 {
@@ -5380,28 +5669,6 @@
     return PVMFSuccess;
 }
 
-void PVMFJitterBufferNode::PvmfFirewallPacketTimerEvent()
-{
-    PVMF_JBNODE_LOG_FW((0, "PVMFJitterBufferNode::PvmfFirewallPacketTimerEvent"));
-    bool oComplete = false;
-    CheckForFireWallPacketAttempts(oComplete);
-    if (oComplete == false)
-    {
-        SendFireWallPackets();
-    }
-    else
-    {
-        PVMF_JBNODE_LOG_FW((0, "PVMFJitterBufferNode::PvmfFirewallPacketTimerEvent - FW Pkt Exchange Complete"));
-        if (iInterfaceState == EPVMFNodeInitialized)
-        {
-            /* We are past max num attempts */
-            OSCL_ASSERT(!iCurrentCommand.empty());
-            OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_JITTER_BUFFER_NODE_PREPARE);
-            CompletePrepare();
-        }
-    }
-}
-
 void PVMFJitterBufferNode::CheckForFireWallRecv(bool &aComplete)
 {
     Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
@@ -5474,17 +5741,13 @@
                     {
                         PVMFSharedMediaDataPtr fireWallPkt;
                         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
-                        int32 err;
+                        bool retval;
 
                         if (iFireWallPacketInfo.iFormat == PVMF_JB_FW_PKT_FORMAT_PV)
                         {
-                            OSCL_TRY(err,
-                                     mediaDataImpl = it->iMediaDataImplAlloc->allocate(PVMF_JITTER_BUFFER_NODE_MAX_FIREWALL_PKT_SIZE);
-                                     fireWallPkt = PVMFMediaData::createMediaData(mediaDataImpl,
-                                                   it->iMediaMsgAlloc);
-                                    );
+                            retval = Allocate(it, fireWallPkt, mediaDataImpl, PVMF_JITTER_BUFFER_NODE_MAX_FIREWALL_PKT_SIZE);
 
-                            if (err != OsclErrNone)
+                            if (retval == false)
                             {
                                 return PVMFErrNoMemory;
                             }
@@ -5506,13 +5769,9 @@
                         }
                         else
                         {
-                            OSCL_TRY(err,
-                                     mediaDataImpl = it->iMediaDataImplAlloc->allocate(PVMF_JITTER_BUFFER_NODE_MAX_RTP_FIREWALL_PKT_SIZE);
-                                     fireWallPkt = PVMFMediaData::createMediaData(mediaDataImpl,
-                                                   it->iMediaMsgAlloc);
-                                    );
+                            retval = Allocate(it, fireWallPkt, mediaDataImpl, PVMF_JITTER_BUFFER_NODE_MAX_RTP_FIREWALL_PKT_SIZE);
 
-                            if (err != OsclErrNone)
+                            if (retval == false)
                             {
                                 return PVMFErrNoMemory;
                             }
@@ -5583,16 +5842,13 @@
                 {
                     PVMFSharedMediaDataPtr fireWallPkt;
                     OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
-                    int32 err;
+                    bool retval;
+
                     if (iFireWallPacketInfo.iFormat == PVMF_JB_FW_PKT_FORMAT_PV)
                     {
-                        OSCL_TRY(err,
-                                 mediaDataImpl = it->iMediaDataImplAlloc->allocate(PVMF_JITTER_BUFFER_NODE_MAX_FIREWALL_PKT_SIZE);
-                                 fireWallPkt = PVMFMediaData::createMediaData(mediaDataImpl,
-                                               it->iMediaMsgAlloc);
-                                );
+                        retval = Allocate(it, fireWallPkt, mediaDataImpl, PVMF_JITTER_BUFFER_NODE_MAX_FIREWALL_PKT_SIZE);
 
-                        if (err != OsclErrNone)
+                        if (retval == false)
                         {
                             return PVMFErrNoMemory;
                         }
@@ -5614,13 +5870,9 @@
                     }
                     else
                     {
-                        OSCL_TRY(err,
-                                 mediaDataImpl = it->iMediaDataImplAlloc->allocate(PVMF_JITTER_BUFFER_NODE_MAX_RTP_FIREWALL_PKT_SIZE);
-                                 fireWallPkt = PVMFMediaData::createMediaData(mediaDataImpl,
-                                               it->iMediaMsgAlloc);
-                                );
+                        retval = Allocate(it, fireWallPkt, mediaDataImpl, PVMF_JITTER_BUFFER_NODE_MAX_RTP_FIREWALL_PKT_SIZE);
 
-                        if (err != OsclErrNone)
+                        if (retval == false)
                         {
                             return PVMFErrNoMemory;
                         }
@@ -5669,10 +5921,28 @@
     PVMF_JBNODE_LOG_FW((0, "PVMFJitterBufferNode::SendFireWallPackets: Scheduling FW Timer - Val = %d ms",
                         iFireWallPacketInfo.iServerRoundTripDelayInMS));
     /* Reschedule the firewall timer for the next interval */
-    iFireWallPacketTimer->RunIfNotReady(iFireWallPacketInfo.iServerRoundTripDelayInMS*1000);
+    RequestEventCallBack(JB_NOTIFY_SEND_FIREWALL_PACKET, iFireWallPacketInfo.iServerRoundTripDelayInMS);
     return PVMFSuccess;
 }
 
+bool PVMFJitterBufferNode::Allocate(PVMFJitterBufferPortParams* it, PVMFSharedMediaDataPtr& fireWallPkt, OsclSharedPtr<PVMFMediaDataImpl>& mediaDataImpl, const int size)
+{
+    int32 err;
+    OSCL_TRY(err,
+             mediaDataImpl = it->iMediaDataImplAlloc->allocate(size);
+             fireWallPkt = PVMFMediaData::createMediaData(mediaDataImpl,
+                           it->iMediaMsgAlloc);
+            );
+
+
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+    return true;
+}
+
+
 PVMFStatus PVMFJitterBufferNode::DecodeFireWallPackets(PVMFSharedMediaDataPtr aPacket,
         PVMFJitterBufferPortParams* aPortParamsPtr)
 {
@@ -5719,35 +5989,6 @@
     return PVMFSuccess;
 }
 
-OsclSharedPtr<PVMFSharedSocketDataBufferAlloc>
-PVMFJitterBufferNode::CreateResizablePortAllocator(uint32 aSize, OSCL_String& aName)
-{
-    uint8* my_ptr;
-    OsclRefCounter* my_refcnt;
-    OsclMemAllocator my_alloc;
-    PVMFSharedSocketDataBufferAlloc *alloc_ptr = NULL;
-
-    uint aligned_socket_alloc_size =
-        oscl_mem_aligned_size(sizeof(PVMFSMSharedBufferAllocWithReSize));
-
-    uint aligned_refcnt_size =
-        oscl_mem_aligned_size(sizeof(OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>));
-
-    my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size +
-                                        aligned_socket_alloc_size);
-
-    my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>(my_ptr));
-    my_ptr += aligned_refcnt_size;
-
-    iBufferAlloc = new PVMFSMSharedBufferAllocWithReSize(aSize, aName.get_cstr(),
-            iMaxNumBufferResizes,
-            iBufferResizeSize);
-
-    alloc_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSharedSocketDataBufferAlloc(iBufferAlloc));
-    OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> shared_alloc(alloc_ptr, my_refcnt);
-    return (shared_alloc);
-}
-
 void PVMFJitterBufferNode::SetSharedBufferResizeParams(uint32 maxNumResizes,
         uint32 resizeSize)
 {
@@ -5866,12 +6107,20 @@
     return PVMFErrArgument;
 }
 
-void PVMFJitterBufferNode::freechunkavailable(OsclAny* aContextData)
+void PVMFJitterBufferNode::freeblockavailable(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    //should never get here
+    OSCL_ASSERT(false);
+}
+
+void PVMFJitterBufferNode::freememoryavailable(OsclAny* aContextData)
 {
     OSCL_UNUSED_ARG(aContextData);
     if (oAutoPause == true)
     {
         PVMFJitterBufferStats stats;
+        oscl_memset(&stats, '0', sizeof(stats));
         oAutoPause = false;
         Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
         for (it = iPortParamsQueue.begin();
@@ -5881,46 +6130,33 @@
             if (it->oMonitorForRemoteActivity == false)
             {
                 it->oMonitorForRemoteActivity = true;
-                /* Cancel and reschedule in the inactivity timer */
-                iRemoteInactivityTimer->Cancel();
-                uint32 inactivityDurationInMS = iRemoteInactivityTimer->getMaxInactivityDurationInMS();
-                iRemoteInactivityTimer->RunIfNotReady(inactivityDurationInMS*1000);
+                CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+                RequestEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
             }
             if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
             {
                 stats = it->iJitterBuffer->getJitterBufferStats();
             }
         }
-        if (iBufferAlloc != NULL)
-        {
-            iBufferAlloc->CancelFreeChunkAvailableCallback();
-        }
         ReportInfoEvent(PVMFJitterBufferNodeJitterBufferLowWaterMarkReached);
-        PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E((0, "PVMFJitterBufferNode::freechunkavailable: Sending Auto Resume"));
+        PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E((0, "PVMFJitterBufferNode::freememoryavailable: Sending Auto Resume"));
 
-        // just for logging
-        uint32 availableSpace = iBufferAlloc->getTrueBufferSpace();
-        uint32 totalBufferSize = iBufferAlloc->getTotalBufferSize();
-        uint32 curroccupancy = (totalBufferSize - availableSpace);
-        uint32 lowWaterMark = (uint32)(totalBufferSize * DEFAULT_JITTER_BUFFER_LOW_WATER_MARK);
-
-        PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E((0, "PVMFJBNode::freechunkavailable: Auto Resume"
-                                               "Total=%d, Curr=%d, Avail=%d, LowM=%d",
-                                               totalBufferSize, curroccupancy, availableSpace, lowWaterMark));
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-        uint64 timebase64 = 0;
-        uint64 estServerClock = 0;
-        uint64 clientClock = 0;
-        iEstimatedServerClock->GetCurrentTime64(estServerClock, OSCLCLOCK_MSEC, timebase64);
+        uint32 timebase32 = 0;
+        uint32 estServerClock = 0;
+        uint32 clientClock = 0;
+        bool overflowFlag = false;
+        iEstimatedServerClock->GetCurrentTime32(estServerClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
         if (iClientPlayBackClock != NULL)
-            iClientPlayBackClock->GetCurrentTime64(clientClock, OSCLCLOCK_MSEC, timebase64);
-        PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJBNode::freechunkavailable - Auto Resume:"
-                                             "MaxSNReg=%d, MaxTSReg=%d, LastSNRet=%d, LastTSRet=%d, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
+            iClientPlayBackClock->GetCurrentTime32(clientClock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+
+        PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFJBNode::freememoryavailable - Auto Resume:"
+                                             "MaxSNReg=%d, MaxTSReg=%u, LastSNRet=%d, LastTSRet=%u, NumMsgsInJB=%d, ServClk=%d, PlyClk=%d",
                                              stats.maxSeqNumRegistered, stats.maxTimeStampRegistered,
                                              stats.lastRetrievedSeqNum, stats.maxTimeStampRetrieved,
                                              (stats.maxSeqNumRegistered - stats.lastRetrievedSeqNum),
-                                             Oscl_Int64_Utils::get_uint64_lower32(estServerClock),
-                                             Oscl_Int64_Utils::get_uint64_lower32(clientClock)));
+                                             estServerClock,
+                                             clientClock));
 #endif
     }
 }
@@ -5962,16 +6198,10 @@
                 if (it->oMonitorForRemoteActivity == false)
                 {
                     it->oMonitorForRemoteActivity = true;
-                    /* Cancel and reschedule in the inactivity timer */
-                    iRemoteInactivityTimer->Cancel();
-                    uint32 inactivityDurationInMS = iRemoteInactivityTimer->getMaxInactivityDurationInMS();
-                    iRemoteInactivityTimer->RunIfNotReady(inactivityDurationInMS*1000);
+                    CancelEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
+                    RequestEventCallBack(JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED);
                 }
             }
-            if (iBufferAlloc != NULL)
-            {
-                iBufferAlloc->CancelFreeChunkAvailableCallback();
-            }
             ReportInfoEvent(PVMFJitterBufferNodeJitterBufferLowWaterMarkReached);
             PVMF_JBNODE_LOGDATATRAFFIC_FLOWCTRL_E((0, "PVMFJitterBufferNode::UpdateRebufferingStats: Sending Auto Resume"));
         }
@@ -6005,21 +6235,20 @@
                     uint32 max_ts_ret = jbStats.maxTimeStampRetrieved;
                     it->mediaClockConverter.set_clock(max_ts_ret, in_wrap_count);
 
-                    uint64 currentTime64 = 0;
-                    uint64 currentTimeBase64 = 0;
-                    iEstimatedServerClock->GetCurrentTime64(currentTime64,
-                                                            OSCLCLOCK_MSEC,
-                                                            currentTimeBase64);
-
+                    uint32 currentTime32 = 0;
+                    uint32 currentTimeBase32 = 0;
+                    bool overflowFlag = false;
+                    iEstimatedServerClock->GetCurrentTime32(currentTime32,
+                                                            overflowFlag,
+                                                            PVMF_MEDIA_CLOCK_MSEC,
+                                                            currentTimeBase32);
+                    uint32 bitrate32 = 0;
                     uint32 totalNumBytesRecvd = jbStats.totalNumBytesRecvd;
-                    uint64 bytesRecvd64 = 0;
-                    Oscl_Int64_Utils::set_uint64(bytesRecvd64, 0, totalNumBytesRecvd);
-                    uint64 byteRate = 0;
-                    if (Oscl_Int64_Utils::get_uint64_lower32(currentTime64) != 0)
+                    if (currentTime32 != 0)
                     {
-                        byteRate = (bytesRecvd64 / currentTime64);
+                        bitrate32 = (totalNumBytesRecvd / currentTime32);
                     }
-                    uint32 bitrate32 = Oscl_Int64_Utils::get_uint64_lower32(byteRate);
+
                     bitrate32 *= 8;
 
                     PVMF_JBNODE_LOGDIAGNOSTICS((0, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"));
@@ -6172,21 +6401,47 @@
                  */
                 oDelayEstablished = false;
                 iJitterBufferState = PVMF_JITTER_BUFFER_READY;
+                if (iOverflowFlag)
+                {
+                    iOverflowFlag = false;
+                }
             }
         }
     }
     return true;
 }
 
+void PVMFJitterBufferNode::NotificationsInterfaceDestroyed()
+{
+}
+
+void PVMFJitterBufferNode::FlushJitterBuffer()
+{
+
+    for (uint32 i = 0; i < iPortParamsQueue.size(); i++)
+    {
+        PVMFJitterBufferPortParams portParams = iPortParamsQueue[i];
+        if (portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+        {
+            if (portParams.iJitterBuffer != NULL)
+            {
+                portParams.iJitterBuffer->FlushJitterBuffer();
+            }
+        }
+    }
+
+}
+
 void PVMFJitterBufferNode::ClockStateUpdated()
 {
+    PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::ClockStateUpdated - iClientPlayBackClock[%d]", iClientPlayBackClock->GetState()));
     if (!oDelayEstablished)
     {
         // Don't let anyone start the clock while
         // we're rebuffering
         if (iClientPlayBackClock != NULL)
         {
-            if (iClientPlayBackClock->GetState() == OsclClock::RUNNING)
+            if (iClientPlayBackClock->GetState() == PVMFMediaClock::RUNNING)
             {
                 PVMF_JBNODE_LOGERROR((0, "PVMFJitterBufferNode::ClockStateUpdated - Clock was started during rebuffering.  Pausing..."));
                 iClientPlayBackClock->Pause();
@@ -6217,17 +6472,18 @@
 bool PVMFJitterBufferNode::PrepareForRepositioning(bool oUseExpectedClientClockVal,
         uint32 aExpectedClientClockVal)
 {
+    bool overflowFlag = false;
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-    uint64 timebase64 = 0;
-    uint64 clientClock64 = 0;
-    uint64 serverClock64 = 0;
+    uint32 timebase32 = 0;
+    uint32 clientClock32 = 0;
+    uint32 serverClock32 = 0;
     if (iClientPlayBackClock != NULL)
-        iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
-    iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+        iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+    iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::PrepareForRepositioning - Before - EstServClock=%d",
-                                 Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                 serverClock32));
     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::PrepareForRepositioning - Before - ClientClock=%d",
-                                 Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                 clientClock32));
 #endif
     oAutoPause = false;
     iJitterBufferState = PVMF_JITTER_BUFFER_IN_TRANSITION;
@@ -6245,7 +6501,7 @@
     {
         iClientPlayBackClock->Stop();
         iClientPlayBackClock->SetStartTime32(ts,
-                                             OSCLCLOCK_MSEC);
+                                             PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
     }
 
     // Reset the following flags for the new repositioning
@@ -6253,19 +6509,603 @@
     oDelayEstablished = false;
 
 
+    Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+    for (it = iPortParamsQueue.begin();
+            it != iPortParamsQueue.end();
+            it++)
+    {
+        if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+        {
+            it->iJitterBuffer->SetEOS(false);
+        }
+        if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
+        {
+            it->iRTCPStats.oRTCPByeRecvd = false;
+        }
+    }
+
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-    timebase64 = 0;
-    clientClock64 = 0;
-    serverClock64 = 0;
+    timebase32 = 0;
+    clientClock32 = 0;
+    serverClock32 = 0;
+    overflowFlag = false;
     if (iClientPlayBackClock != NULL)
-        iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
-    iEstimatedServerClock->GetCurrentTime64(serverClock64, OSCLCLOCK_MSEC, timebase64);
+        iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
+    iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::PrepareForRepositioning - After - EstServClock=%d",
-                                 Oscl_Int64_Utils::get_uint64_lower32(serverClock64)));
+                                 serverClock32));
     PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::PrepareForRepositioning - After - ClientClock=%d",
-                                 Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                 clientClock32));
 #endif
     return true;
 }
 
+// Need to set jb state to ready when handing 404, 415 response
+void PVMFJitterBufferNode::UpdateJitterBufferState()
+{
+    iJitterBufferState = PVMF_JITTER_BUFFER_READY;
+    oDelayEstablished = true;
+}
+
+bool PVMFJitterBufferNode::RequestEventCallBack(JB_NOTIFY_CALLBACK aEventType, uint32 aDelay, OsclAny* aContext)
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "[0x%x]PVMFJitterBufferNode::RequestEventCallBack In aEventType[%d], aDelay[%d] aContext[0x%x]", this, aEventType, aDelay, aContext));
+
+    if (PVMFMediaClock::RUNNING != iNonDecreasingClock->GetState())
+    {
+        PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::RequestEventCallBack - Skipping registering callback - iInterfaceState[%d]", iInterfaceState));
+        return false;
+    }
+
+    uint32* callBackId = 0;
+    bool*  callBackPending = NULL;
+    uint32 intervalToRequestCallBack = 0;
+    PVMFMediaClockNotificationsInterface *eventNotificationsInf = NULL;
+
+    PVMFMediaClockNotificationsIntfContext	*eventClockNotificationIntfContext = NULL;
+    switch (aEventType)
+    {
+        case JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED:
+        {
+            callBackId = &iIncomingMediaInactivityDurationCallBkId;
+            callBackPending = &iIncomingMediaInactivityDurationCallBkPending;
+            intervalToRequestCallBack = iMaxInactivityDurationForMediaInMs;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+            iNonDecClkNotificationsInfContext.SetContext(eventNotificationsInf, aContext);
+            eventClockNotificationIntfContext = &iNonDecClkNotificationsInfContext;
+        }
+        break;
+        case JB_NOTIFY_REPORT_BUFFERING_STATUS:
+        {
+            callBackId = &iNotifyBufferingStatusCallBkId;
+            callBackPending = &iNotifyBufferingStatusCallBkPending;
+            intervalToRequestCallBack = iBufferingStatusIntervalInMs;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+            iNonDecClkNotificationsInfContext.SetContext(eventNotificationsInf, aContext);
+            eventClockNotificationIntfContext = &iNonDecClkNotificationsInfContext;
+        }
+        break;
+        case JB_BUFFERING_DURATION_COMPLETE:
+        {
+            callBackId = &iJitterBufferDurationCallBkId;
+            callBackPending = &iJitterBufferDurationCallBkPending;
+            intervalToRequestCallBack = iJitterBufferDurationInMilliSeconds;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+            iNonDecClkNotificationsInfContext.SetContext(eventNotificationsInf, aContext);
+            eventClockNotificationIntfContext = &iNonDecClkNotificationsInfContext;
+        }
+        break;
+        case JB_MONITOR_REBUFFERING:
+        {
+            //Playback clock is started and stopped outside the scope of this module.
+            //Therefore, check state of the clock state before requesting the callback
+            if (PVMFMediaClock::RUNNING != iClientPlayBackClock->GetState())
+            {
+                return false;
+            }
+            callBackId = &iMonitorReBufferingCallBkId;
+            callBackPending = &iMonitorReBufferingCallBkPending;
+            eventNotificationsInf = iClientPlayBackClockNotificationsInf;
+            iClientPlayBkClkNotificationsInfContext.SetContext(eventNotificationsInf, aContext);
+            eventClockNotificationIntfContext = &iClientPlayBkClkNotificationsInfContext;
+        }
+        break;
+        case JB_NOTIFY_SEND_FIREWALL_PACKET:
+        {
+            callBackId = &iSendFirewallPacketCallBkId;
+            callBackPending = &iSendFirewallPacketCallBkPending;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+            iNonDecClkNotificationsInfContext.SetContext(eventNotificationsInf, aContext);
+            eventClockNotificationIntfContext = &iNonDecClkNotificationsInfContext;
+        }
+        break;
+        case JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE:
+        {
+            PVMFJitterBufferPortParams * portParams = OSCL_REINTERPRET_CAST(PVMFJitterBufferPortParams *, aContext);
+            callBackId = &(portParams->iWaitForOOOPacketCallBkId);
+            callBackPending = &(portParams->iWaitForOOOPacketCallBkPending);
+            eventNotificationsInf = iEstimatedClockNotificationsInf;
+            iEstimatedClockNotificationsInfContext.SetContext(eventNotificationsInf, aContext);
+            eventClockNotificationIntfContext = &iEstimatedClockNotificationsInfContext;
+            PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::RequestEventCallBack Set Callback for sending OOO data aDelay [%d] aContext[0x%x]", aDelay, aContext));
+        }
+        break;
+        default:
+            OSCL_ASSERT(false);
+    }
+
+    if (*callBackPending)
+    {
+        CancelCallBack(eventNotificationsInf, *callBackId, *callBackPending);
+        *callBackPending = false;
+    }
+
+    if (aDelay)
+    {
+        intervalToRequestCallBack = aDelay;
+    }
+
+    return RequestCallBack(eventNotificationsInf, intervalToRequestCallBack, *callBackId, *callBackPending, eventClockNotificationIntfContext);
+}
+
+bool PVMFJitterBufferNode::RequestCallBack(PVMFMediaClockNotificationsInterface *& aEventNotificationInterface, uint32 aDelay, uint32& aCallBkId, bool& aCallBackStatusPending, OsclAny* aContext)
+{
+    const int32 toleranceWndForCallback = 0;
+    bool retval = false;
+    CancelCallBack(aEventNotificationInterface, aCallBkId, aCallBackStatusPending);
+    if (aDelay > 0 && aEventNotificationInterface)
+    {
+
+        PVMFStatus status = aEventNotificationInterface->SetCallbackDeltaTime(aDelay, //delta time in clock when callBack should be called
+                            toleranceWndForCallback,
+                            this, //observer object to be called on timeout
+                            false, //no threadLock
+                            aContext, //no context
+                            aCallBkId); //ID used to identify the timer for cancellation
+        if (PVMFSuccess != status)
+        {
+            aCallBackStatusPending = false;
+            OSCL_ASSERT(false);
+        }
+        else
+        {
+            aCallBackStatusPending = true;
+            retval = true;
+        }
+    }
+    if (aContext)
+    {
+        PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::RequestCallBack callbackId[%d] aContext[0x%x]", aCallBkId, aContext));
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::RequestCallBack Out aDelay[%d], aCallBkId[%d] aCallBackStatusPending[%d]", aDelay, aCallBkId, aCallBackStatusPending));
+    return retval;
+}
+
+void PVMFJitterBufferNode::CancelEventCallBack(JB_NOTIFY_CALLBACK aEventType, OsclAny* aContext)
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "[0x%x]PVMFJitterBufferNode::CancelEventCallBack In - Event Type[%d] ", this, aEventType));
+    uint32 callBackId = 0;
+    bool*  callBackPending = NULL;
+    PVMFMediaClockNotificationsInterface *eventNotificationsInf = NULL;
+    switch (aEventType)
+    {
+        case JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED:
+        {
+            callBackId = iIncomingMediaInactivityDurationCallBkId;
+            callBackPending = &iIncomingMediaInactivityDurationCallBkPending;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+        }
+        break;
+        case JB_NOTIFY_REPORT_BUFFERING_STATUS:
+        {
+            callBackId = iNotifyBufferingStatusCallBkId;
+            callBackPending = &iNotifyBufferingStatusCallBkPending;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+        }
+        break;
+        case JB_BUFFERING_DURATION_COMPLETE:
+        {
+            callBackId = iJitterBufferDurationCallBkId;
+            callBackPending = &iJitterBufferDurationCallBkPending;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+        }
+        break;
+        case JB_MONITOR_REBUFFERING:
+        {
+            callBackId = iMonitorReBufferingCallBkId;
+            callBackPending = &iMonitorReBufferingCallBkPending;
+            eventNotificationsInf = iClientPlayBackClockNotificationsInf;
+        }
+        break;
+        case JB_NOTIFY_SEND_FIREWALL_PACKET:
+        {
+            callBackId = iSendFirewallPacketCallBkId;
+            callBackPending = &iSendFirewallPacketCallBkPending;
+            eventNotificationsInf = iNonDecreasingClockNotificationsInf;
+        }
+        break;
+        case JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE:
+        {
+            if (aContext)
+            {
+                PVMFJitterBufferPortParams * portParams = OSCL_REINTERPRET_CAST(PVMFJitterBufferPortParams *, aContext);
+                callBackId = portParams->iWaitForOOOPacketCallBkId;
+                callBackPending = &(portParams->iWaitForOOOPacketCallBkPending);
+                PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::CancelEventCallBack cancelling Callback for sending OOO data callBackId[%d] , aContext[0x%x]", callBackId, aContext));
+            }
+            eventNotificationsInf = iEstimatedClockNotificationsInf;
+        }
+        break;
+        default:
+            OSCL_ASSERT(false);
+    }
+    CancelCallBack(eventNotificationsInf, callBackId, *callBackPending);
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::CancelEventCallBack Out - Event Type[%d] CallBackId [%d]", aEventType, callBackId));
+}
+
+void PVMFJitterBufferNode::CancelCallBack(PVMFMediaClockNotificationsInterface *& aEventNotificationInterface, uint32& aCallBkId, bool& aCallBackStatusPending)
+{
+    if (aCallBackStatusPending && aEventNotificationInterface)
+    {
+        aEventNotificationInterface->CancelCallback(aCallBkId, false);
+        aCallBackStatusPending = false;
+    }
+}
+
+bool PVMFJitterBufferNode::IsCallbackPending(JB_NOTIFY_CALLBACK aEventType, OsclAny* aContext)
+{
+    bool*  callBackPending = NULL;
+    PVMFJitterBufferPortParams* portParams = OSCL_REINTERPRET_CAST(PVMFJitterBufferPortParams*, aContext);
+    switch (aEventType)
+    {
+        case JB_INCOMING_MEDIA_INACTIVITY_DURATION_EXPIRED:
+        {
+            callBackPending = &iIncomingMediaInactivityDurationCallBkPending;
+        }
+        break;
+        case JB_NOTIFY_REPORT_BUFFERING_STATUS:
+        {
+            callBackPending = &iNotifyBufferingStatusCallBkPending;
+        }
+        break;
+        case JB_BUFFERING_DURATION_COMPLETE:
+        {
+            callBackPending = &iJitterBufferDurationCallBkPending;
+        }
+        break;
+        case JB_MONITOR_REBUFFERING:
+        {
+            callBackPending = &iMonitorReBufferingCallBkPending;
+        }
+        break;
+        case JB_NOTIFY_SEND_FIREWALL_PACKET:
+        {
+            callBackPending = &iSendFirewallPacketCallBkPending;
+        }
+        break;
+        case JB_NOTIFY_WAIT_FOR_OOO_PACKET_COMPLETE:
+        {
+            callBackPending = &(portParams->iWaitForOOOPacketCallBkPending);
+        }
+        break;
+        default:
+            OSCL_ASSERT(false);
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::IsCallbackPending - Event Type[%d] CallBackPending [%d] aContext[0x%x]", aEventType, *callBackPending, aContext));
+    return *callBackPending;
+}
+
+void PVMFJitterBufferNode::ProcessCallBack(uint32 aCallBackID,
+        PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy,
+        uint32 aDelta,
+        const OsclAny* aContextData,
+        PVMFStatus aStatus)
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::ProcessCallBack In CallBackId [%d] aDelta[%d]", aCallBackID, aDelta));
+    OSCL_UNUSED_ARG(aDelta);
+    OSCL_UNUSED_ARG(aStatus);
+    OSCL_UNUSED_ARG(aTimerAccuracy);
+
+    PVMFMediaClockNotificationsIntfContext *clockNotificationIntfContext = OSCL_REINTERPRET_CAST(PVMFMediaClockNotificationsIntfContext*, aContextData);
+    if (aCallBackID == iIncomingMediaInactivityDurationCallBkId && (clockNotificationIntfContext->GetMediaClockNotificationsInterface() == iNonDecreasingClockNotificationsInf))
+    {
+        iIncomingMediaInactivityDurationCallBkPending = false;
+        HandleEvent_IncomingMediaInactivityDurationExpired();
+    }
+    if (aCallBackID == iNotifyBufferingStatusCallBkId && (clockNotificationIntfContext->GetMediaClockNotificationsInterface() == iNonDecreasingClockNotificationsInf))
+    {
+        iNotifyBufferingStatusCallBkPending = false;
+        HandleEvent_NotifyReportBufferingStatus();
+    }
+    if (aCallBackID == iJitterBufferDurationCallBkId && (clockNotificationIntfContext->GetMediaClockNotificationsInterface() == iNonDecreasingClockNotificationsInf))
+    {
+        iJitterBufferDurationCallBkPending = false;
+        HandleEvent_JitterBufferBufferingDurationComplete();
+    }
+    if (aCallBackID == iMonitorReBufferingCallBkId && (clockNotificationIntfContext->GetMediaClockNotificationsInterface() == iClientPlayBackClockNotificationsInf))
+    {
+        iMonitorReBufferingCallBkPending = false;
+        HandleEvent_MonitorReBuffering();
+    }
+    if (aCallBackID == iSendFirewallPacketCallBkId && (clockNotificationIntfContext->GetMediaClockNotificationsInterface() == iNonDecreasingClockNotificationsInf))
+    {
+        iSendFirewallPacketCallBkPending = false;
+        HandleEvent_NotifySendFirewallPacket();
+    }
+    if (clockNotificationIntfContext->GetContextData())
+    {
+        PVMFJitterBufferPortParams * portParams = NULL;
+        portParams  = OSCL_REINTERPRET_CAST(PVMFJitterBufferPortParams*, clockNotificationIntfContext->GetContextData());
+        if (aCallBackID == portParams->iWaitForOOOPacketCallBkId && (clockNotificationIntfContext->GetMediaClockNotificationsInterface() == iEstimatedClockNotificationsInf))
+        {
+            portParams->iWaitForOOOPacketCallBkPending = false;
+            HandleEvent_NotifyWaitForOOOPacketComplete(portParams);
+        }
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::ProcessCallBack Out"));
+}
+
+void PVMFJitterBufferNode::HandleEvent_IncomingMediaInactivityDurationExpired()
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_IncomingMediaInactivityDurationExpired In"));
+    PVUuid eventuuid = PVMFJitterBufferNodeEventTypeUUID;
+    int32 errcode = PVMFJitterBufferNodeRemoteInactivityTimerExpired;
+
+    if (iCurrentCommand.size() > 0)
+    {
+        PVMFJitterBufferNodeCommand cmd = iCurrentCommand.front();
+        CommandComplete(cmd, PVMFFailure, NULL, &eventuuid, &errcode);
+        iCurrentCommand.Erase(&iCurrentCommand.front());
+    }
+    else
+    {
+        ReportInfoEvent(PVMFErrTimeout, NULL, &eventuuid, &errcode);
+        oSessionDurationExpired = true;
+
+        Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+        for (it = iPortParamsQueue.begin();
+                it != iPortParamsQueue.end();
+                it++)
+        {
+            if ((it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT))
+            {
+                it->oUpStreamEOSRecvd = true;
+            }
+        }
+
+        iSessionDurationTimer->Stop();
+        if (IsAdded())
+            RunIfNotReady();
+    }
+
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_IncomingMediaInactivityDurationExpired Out"));
+}
+
+void PVMFJitterBufferNode::HandleEvent_NotifyReportBufferingStatus()
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_NotifyReportBufferingStatus In"));
+    if (oDelayEstablished == false)
+    {
+        /*
+         * Check to see if the session duration has expired
+         */
+        if (oSessionDurationExpired)
+        {
+            PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::TimeoutOccurred - Session Duration Expired"));
+            /* Force out of rebuffering */
+            Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+            for (it = iPortParamsQueue.begin();
+                    it != iPortParamsQueue.end();
+                    it++)
+            {
+                if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+                {
+                    SendData(it->iPort);
+                }
+            }
+            if (IsAdded())
+            {
+                RunIfNotReady();
+            }
+        }
+        else
+        {
+            ReportInfoEvent(PVMFInfoBufferingStatus);
+            RequestEventCallBack(JB_NOTIFY_REPORT_BUFFERING_STATUS);
+        }
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_NotifyReportBufferingStatus Out"));
+}
+
+void PVMFJitterBufferNode::HandleEvent_JitterBufferBufferingDurationComplete()
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_JitterBufferBufferingDurationComplete In"));
+    if (oDelayEstablished == false)
+    {
+        RequestEventCallBack(JB_BUFFERING_DURATION_COMPLETE);
+
+        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::HandleEvent_JitterBufferBufferingDurationComplete - Trying To Force Out of Buffering"));
+        /* Force out of buffering */
+        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::HandleEvent_JitterBufferBufferingDurationComplete - Jitter Buffer Duration Expired"));
+        Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+        for (it = iPortParamsQueue.begin();
+                it != iPortParamsQueue.end();
+                it++)
+        {
+            if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+            {
+                SendData(it->iPort);
+            }
+        }
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_JitterBufferBufferingDurationComplete Out"));
+}
+
+void PVMFJitterBufferNode::HandleEvent_MonitorReBuffering()
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_MonitorReBuffering In"));
+    if (oDelayEstablished == true)
+    {
+        PVMF_JBNODE_LOGCLOCK((0, "PVMFJitterBufferNode::PVMFJBJitterBufferDurationTimerEvent - Trying To Force ReBuffering"));
+        Oscl_Vector<PVMFJitterBufferPortParams, PVMFJitterBufferNodeAllocator>::iterator it;
+        for (it = iPortParamsQueue.begin();
+                it != iPortParamsQueue.end();
+                it++)
+        {
+            if (it->tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+            {
+                SendData(it->iPort);
+            }
+        }
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_MonitorReBuffering Out"));
+}
+
+void PVMFJitterBufferNode::HandleEvent_NotifySendFirewallPacket()
+{
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_NotifySendFirewallPacket In"));
+    bool oComplete = false;
+    CheckForFireWallPacketAttempts(oComplete);
+    if (oComplete == false)
+    {
+        SendFireWallPackets();
+    }
+    else
+    {
+        PVMF_JBNODE_LOG_FW((0, "PVMFJitterBufferNode::PvmfFirewallPacketTimerEvent - FW Pkt Exchange Complete"));
+        if (iInterfaceState == EPVMFNodeInitialized)
+        {
+            /* We are past max num attempts */
+            OSCL_ASSERT(!iCurrentCommand.empty());
+            OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_JITTER_BUFFER_NODE_PREPARE);
+            CompletePrepare();
+        }
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_NotifySendFirewallPacket Out"));
+}
+
+void PVMFJitterBufferNode::HandleEvent_NotifyWaitForOOOPacketComplete(OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_NotifyWaitForOOOPacketComplete In iInterfaceState[%d]", iInterfaceState));
+    //Wake up the AO to send data to the connected node
+    PVMF_JBNODE_LOGDATATRAFFIC_OUT((0, "PVMFJitterBufferNode::HandleEvent_NotifyWaitForOOOPacketComplete Sending OOO data %x", aContext));
+    if (IsAdded())
+    {
+        RunIfNotReady();
+    }
+    PVMF_JBNODE_LOG_EVENTS_CLOCK((0, "PVMFJitterBufferNode::HandleEvent_NotifyWaitForOOOPacketComplete Out"));
+}
+
+void PVMFJitterBufferNode::SetJitterBufferSize(uint32 aBufferSz)
+{
+    iJitterBufferSz = aBufferSz;
+}
+
+void PVMFJitterBufferNode::GetJitterBufferSize(uint32& aBufferSz) const
+{
+    aBufferSz = iJitterBufferSz;
+}
+
+void PVMFJitterBufferNode::SetJitterBufferChunkAllocator(OsclMemPoolResizableAllocator* aDataBufferAllocator, const PVMFPortInterface* aPort)
+{
+    for (uint32 i = 0; i < iPortParamsQueue.size(); i++)
+    {
+        if (iPortParamsQueue[i].iPort == aPort)
+        {
+            iPortParamsQueue[i].iBufferAlloc = aDataBufferAllocator;
+            aDataBufferAllocator->addRef();
+        }
+    }
+}
+
+void PVMFJitterBufferNode::SetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32 aSize, uint32 aResizeSize, uint32 aMaxNumResizes, uint32 aExpectedNumberOfBlocksPerBuffer)
+{
+    PVMFJitterBufferPort* port = OSCL_STATIC_CAST(PVMFJitterBufferPort*, aPort);
+    port->iPortParams->SetJitterBufferMemPoolInfo(aSize, aResizeSize, aMaxNumResizes, aExpectedNumberOfBlocksPerBuffer);
+
+}
+
+void PVMFJitterBufferNode::GetJitterBufferMemPoolInfo(const PvmfPortBaseImpl* aPort, uint32& aSize, uint32& aResizeSize, uint32& aMaxNumResizes, uint32& aExpectedNumberOfBlocksPerBuffer) const
+{
+    PVMFJitterBufferPort* port = OSCL_STATIC_CAST(PVMFJitterBufferPort*, aPort);
+    port->iPortParams->GetJitterBufferMemPoolInfo(aSize, aResizeSize, aMaxNumResizes, aExpectedNumberOfBlocksPerBuffer);
+}
+
+/* computes the max next ts of all tracks */
+PVMFTimestamp PVMFJitterBufferNode::getMaxMediaDataTS()
+{
+    PVMFTimestamp mediaTS = 0;
+    uint32 in_wrap_count = 0;
+    uint32 i;
+
+    for (i = 0; i < iPortParamsQueue.size(); i++)
+    {
+        PVMFJitterBufferPortParams portParams = iPortParamsQueue[i];
+
+        if (portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+        {
+            if (portParams.iJitterBuffer != NULL)
+            {
+                PVMFTimestamp ts =
+                    portParams.iJitterBuffer->peekMaxElementTimeStamp();
+                /*
+                 * Convert Time stamp to milliseconds
+                 */
+                portParams.mediaClockConverter.set_clock(ts, in_wrap_count);
+                PVMFTimestamp converted_ts =
+                    portParams.mediaClockConverter.get_converted_ts(1000);
+                if (converted_ts > mediaTS)
+                {
+                    mediaTS = converted_ts;
+                }
+            }
+        }
+    }
+    for (i = 0; i < iPortParamsQueue.size(); i++)
+    {
+        PVMFJitterBufferPortParams portParams = iPortParamsQueue[i];
+
+        if (portParams.tag == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+        {
+            if (portParams.eTransportType != PVMF_JITTER_BUFFER_PORT_TRANSPORT_TYPE_ASF)
+            {
+                if (portParams.iJitterBuffer != NULL)
+                {
+                    portParams.iJitterBuffer->SetAdjustedTSInMS(mediaTS);
+                }
+            }
+        }
+    }
+    return mediaTS;
+}
+
+bool PVMFJitterBufferNode::PrepareForPlaylistSwitch()
+{
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
+    uint32 clientClock32 = 0;
+    uint32 serverClock32 = 0;
+    bool overflowFlag = false;
+    if (iClientPlayBackClock != NULL)
+        iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+    iEstimatedServerClock->GetCurrentTime32(serverClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+    PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::PrepareForPlaylistSwitch - Before - EstServClock=%d",
+                                 serverClock32));
+    PVMF_JBNODE_LOGCLOCK_REBUFF((0, "PVMFJitterBufferNode::PrepareForPlaylistSwitch - Before - ClientClock=%d",
+                                 clientClock32));
+#endif
+    oAutoPause = false;
+    iJitterBufferState = PVMF_JITTER_BUFFER_IN_TRANSITION;
+    iClientPlayBackClock->Pause();
+
+    return true;
+}
 
diff --git a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_port.cpp b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_port.cpp
index 6ed13ba..d4c562e 100644
--- a/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_port.cpp
+++ b/nodes/streaming/jitterbuffernode/src/pvmf_jitter_buffer_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFJitterBufferPort::PVMFJitterBufferPort(int32 aTag, PVMFNodeInterface* aNode, const char*name)
         : PvmfPortBaseImpl(aTag, aNode, name)
-        , iFormat(PVMF_FORMAT_UNKNOWN)
+        , iFormat(PVMF_MIME_FORMAT_UNKNOWN)
 {
     iJitterBufferNode = OSCL_STATIC_CAST(PVMFJitterBufferNode*, aNode);
     Construct();
@@ -68,7 +68,7 @@
         , uint32 aOutReserve
         , uint32 aOutThreshold, const char*name)
         : PvmfPortBaseImpl(aTag, aNode, aInCapacity, aInReserve, aInThreshold, aOutCapacity, aOutReserve, aOutThreshold, name)
-        , iFormat(PVMF_FORMAT_UNKNOWN)
+        , iFormat(PVMF_MIME_FORMAT_UNKNOWN)
 {
     iJitterBufferNode = OSCL_STATIC_CAST(PVMFJitterBufferNode*, aNode);
     Construct();
@@ -150,10 +150,9 @@
     if ((iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) ||
             (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK))
     {
-        PvmiCapabilityAndConfig *config;
-
-        aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                              (OsclAny*&)config);
+        OsclAny* temp = NULL;
+        aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+        PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
         if (config != NULL)
         {
@@ -161,9 +160,9 @@
                                      PVMF_JITTER_BUFFER_PORT_SPECIFIC_ALLOCATOR_VALTYPE);
 
             int numKvp = 0;
-            PvmiKvp* kvpPtr;
+            PvmiKvp* kvpPtr = NULL;
             PVMFStatus status =
-                config->getParametersSync(NULL, PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_KEY, kvpPtr, numKvp, NULL);
+                config->getParametersSync(NULL, (char*)PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_KEY, kvpPtr, numKvp, NULL);
             if (status == PVMFSuccess)
             {
                 iInPlaceDataProcessing = kvpPtr[0].value.bool_value;
@@ -193,6 +192,10 @@
         int& num_parameter_elements,
         PvmiCapabilityContext aContext)
 {
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+    OSCL_UNUSED_ARG(aContext);
+
     PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferPort::getParametersSync: aSession=0x%x, aIdentifier=%s, aParameters=0x%x, num_parameters_elements=%d, aContext=0x%x",
                          aSession, aIdentifier, aParameters, num_parameter_elements, aContext));
 
@@ -227,6 +230,8 @@
         PvmiKvp* aParameters,
         int num_elements)
 {
+    OSCL_UNUSED_ARG(aSession);
+
     PVMF_JBNODE_LOGINFO((0, "PVMFJitterBufferPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
                          aSession, aParameters, num_elements));
 
@@ -266,105 +271,6 @@
     return PVMFErrNotSupported;
 }
 
-void PVMFJitterBufferPort::createPortAllocators(OSCL_String& aMimeType, uint32 aSizeInBytes)
-{
-    if ((iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) ||
-            (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK))
-    {
-        int32 size = (int32)aSizeInBytes;
-        createSocketDataAllocReSize(aMimeType, size);
-    }
-}
-
-void PVMFJitterBufferPort::createPortAllocators(OSCL_String& aMimeType, uint32 aSizeInBytes,
-        uint maxNumResizes, uint resizeSize)
-{
-    if ((iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) ||
-            (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK))
-    {
-        int32 size = (int32)aSizeInBytes;
-        createSocketDataAllocReSize(aMimeType, size, true, maxNumResizes, resizeSize);
-    }
-}
-
-void PVMFJitterBufferPort::createSocketDataAllocReSize(OSCL_String& aMimeType,
-        int32 aSize, bool userParams,
-        uint maxNumResizes,
-        uint resizeSize)
-{
-    uint8* my_ptr;
-    OsclRefCounter* my_refcnt;
-    OsclMemAllocator my_alloc;
-    PVMFSharedSocketDataBufferAlloc *alloc_ptr = NULL;
-
-    uint aligned_socket_alloc_size =
-        oscl_mem_aligned_size(sizeof(PVMFSMSharedBufferAllocWithReSize));
-
-    uint aligned_refcnt_size =
-        oscl_mem_aligned_size(sizeof(OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>));
-
-    my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size +
-                                        aligned_socket_alloc_size);
-
-    my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA<PVMFSharedSocketDataBufferAllocCleanupSA>(my_ptr));
-    my_ptr += aligned_refcnt_size;
-
-#if (PMVF_JITTER_BUFFER_NODE_USE_NO_RESIZE_ALLOC)
-    if (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
-    {
-        iBufferNoResizeAlloc =
-            new PVMFSocketBufferAllocator(PVMF_JB_NO_RESIZE_ALLOC_NUM_CHUNKS_RTP,
-                                          PVMF_JB_NO_RESIZE_ALLOC_CHUNK_SIZE);
-    }
-    else if (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
-    {
-        iBufferNoResizeAlloc =
-            new PVMFSocketBufferAllocator(PVMF_JB_NO_RESIZE_ALLOC_NUM_CHUNKS_FB,
-                                          PVMF_JB_NO_RESIZE_ALLOC_CHUNK_SIZE);
-    }
-
-    Oscl_DefAlloc* alloc = OSCL_STATIC_CAST(Oscl_DefAlloc*, iBufferNoResizeAlloc);
-    alloc_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSharedSocketDataBufferAlloc(alloc));
-#else
-    if (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
-    {
-        if (aSize <= 0)
-        {
-            aSize = DEFAULT_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
-        }
-        if (userParams)
-        {
-            iBufferAlloc = new PVMFSMSharedBufferAllocWithReSize(aSize, aMimeType.get_cstr(),
-                    maxNumResizes, resizeSize);
-        }
-        else
-        {
-            iBufferAlloc =  new PVMFSMSharedBufferAllocWithReSize(aSize, aMimeType.get_cstr());
-        }
-    }
-    else if (iPortType == PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
-    {
-        if (userParams)
-        {
-            iBufferAlloc = new PVMFSMSharedBufferAllocWithReSize(DEFAULT_RTCP_SOCKET_MEM_POOL_SIZE_IN_BYTES,
-                    "PVMFJitterBufferPortFeedBack",
-                    maxNumResizes, resizeSize);
-        }
-        else
-        {
-            iBufferAlloc = new PVMFSMSharedBufferAllocWithReSize(DEFAULT_RTCP_SOCKET_MEM_POOL_SIZE_IN_BYTES,
-                    "PVMFJitterBufferPortFeedBack");
-        }
-    }
-
-
-    alloc_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSharedSocketDataBufferAlloc(iBufferAlloc));
-#endif
-    OsclSharedPtr<PVMFSharedSocketDataBufferAlloc> shared_alloc(alloc_ptr, my_refcnt);
-
-    iPortDataAlloc = shared_alloc;
-}
-
 void
 PVMFJitterBufferPort::pvmiSetPortAllocatorSync(PvmiCapabilityAndConfig *aPort,
         const char* aFormatValType)
diff --git a/nodes/streaming/jitterbuffernode/src/pvmf_rtcp_timer.cpp b/nodes/streaming/jitterbuffernode/src/pvmf_rtcp_timer.cpp
index ce3841f..efa0c38 100644
--- a/nodes/streaming/jitterbuffernode/src/pvmf_rtcp_timer.cpp
+++ b/nodes/streaming/jitterbuffernode/src/pvmf_rtcp_timer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/medialayernode/Android.mk b/nodes/streaming/medialayernode/Android.mk
index b82fc48..235bbc7 100644
--- a/nodes/streaming/medialayernode/Android.mk
+++ b/nodes/streaming/medialayernode/Android.mk
@@ -3,37 +3,40 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_medialayer_node.cpp \
-	src/pvmf_medialayer_port.cpp
+ 	src/pvmf_medialayer_port.cpp
+
+
+LOCAL_MODULE := libpvmedialayernode
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
 
-LOCAL_MODULE := libpvmediaplayernode
+LOCAL_STATIC_LIBRARIES := 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/streaming/medialayernode/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/src \
-	$(PV_TOP)//nodes/streaming/medialayernode/../common/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../config/opencore \
-	$(PV_TOP)//nodes/streaming/medialayernode/../streamingmanager/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../protocols/sdp/common/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../baselibs/gen_data_structures/src \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../protocols/rtp_payload_parser/rfc_3016/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../protocols/rtp_payload_parser/rfc_3984/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../protocols/rtp_payload_parser/rfc_3267/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../protocols/rtp_payload_parser/rfc_2429/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../fileformats/asf/parser/include \
-	$(PV_TOP)//nodes/streaming/medialayernode/../../../pvmi/content_policy_manager/plugins/common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/streaming/medialayernode/src \
+ 	$(PV_TOP)/nodes/streaming/medialayernode/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/include \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3016/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3984/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3267/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_2429/include \
+ 	$(PV_TOP)/fileformats/asf/parser/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/common/include \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/config/3gpp \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_medialayer_node.h \
-	include/pvmf_medialayer_port.h \
-	include/pvmf_ml_eos_timer.h
+ 	include/pvmf_medialayer_port.h \
+ 	include/pvmf_ml_eos_timer.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/streaming/medialayernode/build/make/local.mk b/nodes/streaming/medialayernode/build/make/local.mk
new file mode 100644
index 0000000..9655a17
--- /dev/null
+++ b/nodes/streaming/medialayernode/build/make/local.mk
@@ -0,0 +1,29 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmedialayernode
+
+
+
+
+
+XINCDIRS += ../../../common/include ../../../streamingmanager/include ../../../../../protocols/sdp/common/include ../../../../../baselibs/gen_data_structures/src ../../../../../protocols/rtp_payload_parser/rfc_3016/include ../../../../../protocols/rtp_payload_parser/rfc_3984/include ../../../../../protocols/rtp_payload_parser/rfc_3267/include ../../../../../protocols/rtp_payload_parser/rfc_2429/include ../../../../../fileformats/asf/parser/include ../../../../../pvmi/content_policy_manager/plugins/common/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_medialayer_node.cpp \
+       pvmf_medialayer_port.cpp
+
+HDRS := pvmf_medialayer_node.h \
+		pvmf_medialayer_port.h \
+		pvmf_ml_eos_timer.h
+
+include $(MK)/library.mk
+
diff --git a/nodes/streaming/medialayernode/build/make/makefile b/nodes/streaming/medialayernode/build/make/makefile
deleted file mode 100644
index b1283c4..0000000
--- a/nodes/streaming/medialayernode/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmediaplayernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += c
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../common/include -I ../../../config/opencore -I ../../../streamingmanager/include -I ../../../../../protocols/sdp/common/include -I ../../../../../baselibs/gen_data_structures/src -I ../../../../../protocols/rtp_payload_parser/rfc_3016/include -I ../../../../../protocols/rtp_payload_parser/rfc_3984/include -I ../../../../../protocols/rtp_payload_parser/rfc_3267/include -I ../../../../../protocols/rtp_payload_parser/rfc_2429/include -I ../../../../../fileformats/asf/parser/include -I ../../../../../pvmi/content_policy_manager/plugins/common/include
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pvmf_medialayer_node.cpp \
-       pvmf_medialayer_port.cpp
-
-HDRS =  pvmf_medialayer_node.h \
-		pvmf_medialayer_port.h \
-		pvmf_ml_eos_timer.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/streaming/medialayernode/build/make/ml_rtsp.mk b/nodes/streaming/medialayernode/build/make/ml_rtsp.mk
new file mode 100644
index 0000000..5e10b6a
--- /dev/null
+++ b/nodes/streaming/medialayernode/build/make/ml_rtsp.mk
@@ -0,0 +1,3 @@
+
+XINCDIRS += -I ../../../streamingmanager/config/3gpp
+
diff --git a/nodes/streaming/medialayernode/include/pvmf_medialayer_node.h b/nodes/streaming/medialayernode/include/pvmf_medialayer_node.h
index f22ffe3..d6496f5 100644
--- a/nodes/streaming/medialayernode/include/pvmf_medialayer_node.h
+++ b/nodes/streaming/medialayernode/include/pvmf_medialayer_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,8 +30,8 @@
 #ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
 #include "oscl_exclusive_ptr.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef PVLOGGER_H_INCLUDED
 #include "pvlogger.h"
@@ -155,7 +155,8 @@
         OSCL_IMPORT_REF virtual PVMFStatus setPayloadParserRegistry(PayloadParserRegistry*) = 0;
         OSCL_IMPORT_REF virtual PVMFStatus setPortDataLogging(bool logEnable, OSCL_String* logPath = NULL) = 0;
         OSCL_IMPORT_REF virtual bool setPlayRange(int32 aStartTimeInMS,
-                int32 aStopTimeInMS) = 0;
+                int32 aStopTimeInMS,
+                bool oRepositioning = false) = 0;
         OSCL_IMPORT_REF virtual bool setPortMediaParams(PVMFPortInterface* aPort,
                 OsclRefCounterMemFrag& aConfig,
                 mediaInfo* aMediaInfo = NULL) = 0;
@@ -170,7 +171,7 @@
         OSCL_IMPORT_REF virtual void setInPortReposFlag(PVMFPortInterface* aPort, uint32 aSeekTimeInMS = 0) = 0;
         OSCL_IMPORT_REF virtual uint32 getMaxOutPortTimestamp(PVMFPortInterface* aPort,
                 bool oPeek = false) = 0;
-        OSCL_IMPORT_REF virtual bool setClientPlayBackClock(OsclClock* aClientPlayBackClock) = 0;
+        OSCL_IMPORT_REF virtual bool setClientPlayBackClock(PVMFMediaClock* aClientPlayBackClock) = 0;
         OSCL_IMPORT_REF virtual void addRef() = 0;
         OSCL_IMPORT_REF virtual void removeRef() = 0;
         OSCL_IMPORT_REF virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
@@ -200,7 +201,7 @@
 
         virtual PVMFStatus setPortDataLogging(bool logEnable, OSCL_String* logPath = NULL);
 
-        virtual bool setClientPlayBackClock(OsclClock* aClientPlayBackClock);
+        virtual bool setClientPlayBackClock(PVMFMediaClock* aClientPlayBackClock);
 
         void addRef()
         {
@@ -214,6 +215,7 @@
         {
             if (uuid == Uuid())
             {
+                addRef();
                 iface = this;
                 return true;
             }
@@ -225,7 +227,8 @@
         }
 
         bool setPlayRange(int32 aStartTimeInMS,
-                          int32 aStopTimeInMS);
+                          int32 aStopTimeInMS,
+                          bool oRepositioning = false);
 
         bool setPortMediaParams(PVMFPortInterface* aPort,
                                 OsclRefCounterMemFrag& aConfig,
@@ -250,7 +253,8 @@
 
 class PVLogger;
 
-class PVMFMediaLayerNode : public PVMFNodeInterface,
+class PVMFMediaLayerNode : public PVInterface,
+            public PVMFNodeInterface,
             public OsclActiveObject,
             public PVMFNodeErrorEventObserver,
             public PVMFNodeInfoEventObserver,
@@ -338,6 +342,40 @@
         //callback from the port when memory is available in the rtp
         //payload parser.
         void freechunkavailable(PVMFPortInterface*);
+        virtual void addRef()
+        {
+        }
+        virtual void removeRef()
+        {
+        }
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            iface = NULL;
+            if (uuid == PVUuid(PVMF_MEDIALAYERNODE_EXTENSIONINTERFACE_UUID))
+            {
+                if (!iExtensionInterface)
+                {
+                    PVMFMediaLayerNodeAllocator alloc;
+                    int32 err;
+                    OsclAny*ptr = NULL;
+                    OSCL_TRY(err,
+                             ptr = alloc.ALLOCATE(sizeof(PVMFMediaLayerNodeExtensionInterfaceImpl));
+                            );
+                    if (err != OsclErrNone || !ptr)
+                    {
+                        PVMF_MLNODE_LOGERROR((0, "PVMFMediaLayerNode::queryInterface: Error - Out of memory"));
+                        OSCL_LEAVE(OsclErrNoMemory);
+                    }
+                    iExtensionInterface =
+                        OSCL_PLACEMENT_NEW(ptr, PVMFMediaLayerNodeExtensionInterfaceImpl(this));
+                }
+                return (iExtensionInterface->queryInterface(uuid, iface));
+            }
+            else
+            {
+                return false;
+            }
+        }
 
     private:
         /* from OsclActiveObject */
@@ -363,6 +401,11 @@
         PVMFStatus dispatchAccessUnits(PVMFMediaLayerPortContainer* pinputPort,
                                        PVMFMediaLayerPortContainer* poutPort);
 
+        bool Allocate(OsclSharedPtr<PVMFMediaDataImpl>& mediaDataImplOut, PVMFMediaLayerPortContainer* poutPort);
+        bool Allocate(OsclAny*& ptr);
+        bool Push(PVMFMediaLayerPortContainer portParams);
+        bool AddPort(PVMFMediaLayerPort* port);
+
         /**
          * Process an outgoing message of a the specified port by sending the message to
          * the receiving side.
@@ -498,10 +541,11 @@
 
         bool CheckForEOS();
         bool setPlayRange(int32 aStartTimeInMS,
-                          int32 aStopTimeInMS);
+                          int32 aStopTimeInMS,
+                          bool oRepositioning = false);
 
-        OsclClock* iClientPlayBackClock;
-        bool setClientPlayBackClock(OsclClock* aClientPlayBackClock)
+        PVMFMediaClock* iClientPlayBackClock;
+        bool setClientPlayBackClock(PVMFMediaClock* aClientPlayBackClock)
         {
             iClientPlayBackClock = aClientPlayBackClock;
             return true;
diff --git a/nodes/streaming/medialayernode/include/pvmf_medialayer_port.h b/nodes/streaming/medialayernode/include/pvmf_medialayer_port.h
index 3f0f281..190fd54 100644
--- a/nodes/streaming/medialayernode/include/pvmf_medialayer_port.h
+++ b/nodes/streaming/medialayernode/include/pvmf_medialayer_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/medialayernode/include/pvmf_ml_eos_timer.h b/nodes/streaming/medialayernode/include/pvmf_ml_eos_timer.h
index eb70e1f..b756f51 100644
--- a/nodes/streaming/medialayernode/include/pvmf_ml_eos_timer.h
+++ b/nodes/streaming/medialayernode/include/pvmf_ml_eos_timer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/medialayernode/src/pvmf_medialayer_node.cpp b/nodes/streaming/medialayernode/src/pvmf_medialayer_node.cpp
index 0e9919c..1646292 100644
--- a/nodes/streaming/medialayernode/src/pvmf_medialayer_node.cpp
+++ b/nodes/streaming/medialayernode/src/pvmf_medialayer_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@
     iReposTime = 0;
     preroll64 = 0;
     iStreamID = 0;
-
+    iExtensionInterface = NULL;
     iNumRunL = 0;
     iDiagnosticsLogged = false;
 
@@ -115,12 +115,14 @@
              iCapability.iHasMaxNumberOfPorts = false;
              iCapability.iMaxNumberOfPorts = 0; /* no maximum */
 
-             iCapability.iInputFormatCapability.push_back(PVMF_RTP);
-             iCapability.iOutputFormatCapability.push_back(PVMF_M4V);
-             iCapability.iOutputFormatCapability.push_back(PVMF_AMR_IETF);
+             iCapability.iInputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_RTP));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_M4V));
+             iCapability.iOutputFormatCapability.push_back(PVMFFormatType(PVMF_MIME_AMR_IETF));
 
             );
 
+
+
     if (err != OsclErrNone)
     {
         //if a leave happened, cleanup and re-throw the error
@@ -140,6 +142,10 @@
     LogSessionDiagnostics();
 
     Cancel();
+    if (iExtensionInterface)
+    {
+        iExtensionInterface->removeRef();
+    }
 
     /* delete related decryption */
     iDecryptionInterface = NULL;
@@ -151,17 +157,6 @@
     if (IsAdded())
         RemoveFromScheduler();
 
-    if (iExtensionInterface)
-    {
-        /*
-         * clear the interface container
-         * the interface can't function without the node
-         */
-        iExtensionInterface->iContainer = NULL;
-        iExtensionInterface->removeRef();
-    }
-
-
     /*
      * Cleanup allocated ports
      * The port vector is self-deleting, but we want to notify
@@ -310,7 +305,7 @@
 }
 
 /**
- * retrive a port iterator.
+ * retrieve a port iterator.
  */
 OSCL_EXPORT_REF
 PVMFPortIter* PVMFMediaLayerNode::GetPorts(const PVMFPortFilter* aFilter)
@@ -782,11 +777,8 @@
             /* restore original port vector reserve */
             iPortVector.Reconstruct();
 
-            /* logoff & go back to Created state */
             SetState(EPVMFNodeIdle);
-            PVMFStatus status = ThreadLogoff();
-
-            CommandComplete(iInputCommands, aCmd, status);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
         }
         break;
 
@@ -855,10 +847,15 @@
             iExtensionInterface =
                 OSCL_PLACEMENT_NEW(ptr, PVMFMediaLayerNodeExtensionInterfaceImpl(this));
         }
-        /* add a reference each time we hand out the interface pointer.*/
-        iExtensionInterface->addRef();
-        *ptr = (PVInterface*)iExtensionInterface;
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+
+        if (iExtensionInterface->queryInterface(*uuid, *ptr))
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        }
+        else
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+        }
     }
     else
     {
@@ -882,9 +879,11 @@
 
     /* Allocate a new port */
     OsclAny *ptr = NULL;
-    int32 err;
-    OSCL_TRY(err, ptr = iPortVector.Allocate(););
-    if (err != OsclErrNone || !ptr)
+    bool retVal;
+
+    retVal = Allocate(ptr);
+
+    if (retVal == false || !ptr)
     {
         PVMF_MLNODE_LOGERROR((0, "PVMFMediaLayerNode::DoRequestPort: Error - iPortVector Out of memory"));
         CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
@@ -987,8 +986,9 @@
 
         // add the output port to the queue
         int newIndex = iPortParamsQueue.size();
-        OSCL_TRY(err, iPortParamsQueue.push_back(portParams););
-        if (err != OsclErrNone)
+
+        retVal = Push(portParams);
+        if (retVal == false)
         {
             PVMF_MLNODE_LOGERROR((0, "0x%x PVMFMediaLayerNode::DoRequestPort: Error - iPortParamsQueue.push_back() failed", this));
             CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
@@ -1057,8 +1057,8 @@
             portParams.iPortLogger->AddAppender(portParams.iBinAppenderPtr);
         }
 
-        OSCL_TRY(err, iPortParamsQueue.push_back(portParams););
-        if (err != OsclErrNone)
+        retVal = Push(portParams);
+        if (retVal == false)
         {
             PVMF_MLNODE_LOGERROR((0, "0x%x PVMFMediaLayerNode::DoRequestPort: Error - iPortParamsQueue.push_back() failed", this));
             CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
@@ -1067,8 +1067,9 @@
     }
 
     /* Add the port to the port vector. */
-    OSCL_TRY(err, iPortVector.AddL(port););
-    if (err != OsclErrNone)
+    retVal = AddPort(port);
+
+    if (retVal == false)
     {
         CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
         portAutoPtr.release();
@@ -1081,8 +1082,38 @@
     CommandComplete(iInputCommands, aCmd, PVMFSuccess, (OsclAny*)port);
 }
 
+bool PVMFMediaLayerNode::Allocate(OsclAny*& ptr)
+{
+    int32 err;
+    OSCL_TRY(err, ptr = iPortVector.Allocate(););
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+    return true;
+}
 
+bool PVMFMediaLayerNode::Push(PVMFMediaLayerPortContainer portParams)
+{
+    int32 err;
+    OSCL_TRY(err, iPortParamsQueue.push_back(portParams););
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+    return true;
+}
 
+bool PVMFMediaLayerNode::AddPort(PVMFMediaLayerPort* port)
+{
+    int32 err;
+    OSCL_TRY(err, iPortVector.AddL(port););
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+    return true;
+}
 /**
  * Called by the command handler AO to do the port release
  */
@@ -1091,8 +1122,10 @@
     /* This node supports release port from any state */
 
     /* Find the port in the port vector */
-    PVMFMediaLayerPort* port;
-    aCmd.PVMFMediaLayerNodeCommandBase::Parse((PVMFPortInterface*&)port);
+    PVMFPortInterface* p = NULL;
+    aCmd.PVMFMediaLayerNodeCommandBase::Parse(p);
+
+    PVMFMediaLayerPort* port = (PVMFMediaLayerPort*)p;
 
     PVMFMediaLayerPort** portPtr = iPortVector.FindByValue(port);
     if (portPtr)
@@ -1445,8 +1478,8 @@
         PVUuid* aEventUUID,
         int32* aEventCode)
 {
-    PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerNode:NodeErrorEvent Type %d Data %d"
-                         , aEventType, aEventData));
+    PVMF_MLNODE_LOGERROR((0, "PVMFMediaLayerNode:NodeErrorEvent Type %d Data %d"
+                          , aEventType, aEventData));
 
     if (aEventUUID && aEventCode)
     {
@@ -1779,7 +1812,10 @@
                         }
                         PVMF_MLNODE_LOGDATATRAFFIC_FLOWCTRL((0, "PVMFMediaLayerNode::HPA: Connected port busy - Stop Input - Mime=%s",
                                                              inPortContainerPtr->iMimeType.get_cstr()));
-                        inPortContainerPtr->oProcessIncomingMessages = false;
+                        if (checkOutputPortsBusy(inPortContainerPtr))
+                        {
+                            inPortContainerPtr->oProcessIncomingMessages = false;
+                        }
                     }
                     else
                     {
@@ -1951,11 +1987,9 @@
     if (checkOutputPortsBusy(pinputPort))
     {
         PVUuid eventuuid = PVMFMediaLayerNodeEventTypeUUID;
-        int32  infoCode = PVMFMediaLayerNodeExcercisingPortFlowControl;
+
         PVMF_MLNODE_LOGDATATRAFFIC_FLOWCTRL((0,
                                              "PVMFMediaLayerNode::ProcessIncomingMsg: Cant Send Data - Output Queue Busy"));
-        ReportInfoEvent(PVMFInfoOverflow,
-                        (OsclAny*)(&(pinputPort->iMimeType)), &eventuuid, &infoCode);
         /*
          * Processing will resume when we get outgoing queue ready notification
          * in the port activity
@@ -1989,7 +2023,7 @@
         {
             PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerNode::ProcessIncomingMsg() Detect EOS message"));
 
-            //EOS msg is recieved. Before sending EOS, we send left payload msgs.
+            //EOS msg is received. Before sending EOS, we send left payload msgs.
             bool IsAccessUnitsEmpty = false;
             status = checkPortCounterpartAccessUnitQueue(pinputPort, &IsAccessUnitsEmpty);
             if (status != PVMFSuccess)
@@ -2053,7 +2087,7 @@
             {
                 PVMFMediaLayerPortContainer* poutPort = &this->iPortParamsQueue[pinputPort->vCounterPorts[i]];
                 // set BOS Timestamp to last media ts sent on this port
-                msgIn->setTimestamp(poutPort->iPrevMsgTimeStamp);
+                msgIn->setTimestamp(poutPort->iContinuousTimeStamp);
                 status = poutPort->iPort->QueueOutgoingMsg(msgIn);
 
                 if (status != PVMFSuccess)
@@ -2066,15 +2100,17 @@
                 else
                 {
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                    uint64 timebase64 = 0;
-                    uint64 clientClock64 = 0;
-                    iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                    uint32 timebase32 = 0;
+                    uint32 clientClock32 = 0;
+                    bool overflowFlag = false;
+                    iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag,
+                                                           PVMF_MEDIA_CLOCK_MSEC, timebase32);
                     PVMF_MLNODE_LOGDATATRAFFIC_OUT((0,
                                                     "PVMFMediaLayerNode::ProcessInputMsg_OneToN: Sending BOS - MimeType=%s Clock=%d",
-                                                    poutPort->iMimeType.get_cstr(), Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                    poutPort->iMimeType.get_cstr(), clientClock32));
                     PVMF_MLNODE_LOG_REPOS((0,
                                            "PVMFMediaLayerNode::ProcessInputMsg_OneToN: Sending BOS - MimeType=%s Clock=%d",
-                                           poutPort->iMimeType.get_cstr(), Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                           poutPort->iMimeType.get_cstr(), clientClock32));
 #endif
                 }
             }
@@ -2111,14 +2147,16 @@
                     else
                     {
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                        uint64 timebase64 = 0;
-                        uint64 clientClock64 = 0;
-                        iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                        uint32 timebase32 = 0;
+                        uint32 clientClock32 = 0;
+                        bool overflowFlag = false;
+                        iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag,
+                                                               PVMF_MEDIA_CLOCK_MSEC, timebase32);
                         PVMF_MLNODE_LOGDATATRAFFIC_OUT((0,
                                                         "PVMFMediaLayerNode::ProcessInputMsg_OneToN: Sending EOS - MimeType=%s, StreamId=%d, Clock=%d",
                                                         pinputPort->iMimeType.get_cstr(),
                                                         msgIn->getStreamID(),
-                                                        Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                        clientClock32));
 #endif
                     }
                 }
@@ -2144,12 +2182,13 @@
                 {
                     poutPort->iReConfig = false;
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                    uint64 timebase64 = 0;
-                    uint64 clientClock64 = 0;
-                    iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                    uint32 timebase32 = 0;
+                    uint32 clientClock32 = 0;
+                    bool overflowFlag = false;
+                    iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                     PVMF_MLNODE_LOGDATATRAFFIC_OUT((0,
                                                     "PVMFMediaLayerNode::ProcessInputMsg_OneToN: Sending MediaCmd - CmdId=%d, MimeType=%s Clock=%2d",
-                                                    msgFormatID, pinputPort->iMimeType.get_cstr(), Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                    msgFormatID, pinputPort->iMimeType.get_cstr(), clientClock32));
 #endif
                 }
             }
@@ -2221,12 +2260,13 @@
         inputDataSize += memFrag.getMemFragSize();
     }
 
-    uint64 timebase64 = 0;
-    uint64 clientClock64 = 0;
-    iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+    uint32 timebase32 = 0;
+    uint32 clientClock32 = 0;
+    bool overflowFlag = false;
+    iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
     PVMF_MLNODE_LOGDATATRAFFIC_IN((0,
                                    "PVMFMediaLayerNode::ProcessInputMsg_OneToN - Input: MimeType=%s, TS=%d, SEQNUM=%d, SIZE=%d, Clock=%d",
-                                   pinputPort->iMimeType.get_cstr(), msgIn->getTimestamp(), msgIn->getSeqNum(), inputDataSize, Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                   pinputPort->iMimeType.get_cstr(), msgIn->getTimestamp(), msgIn->getSeqNum(), inputDataSize, clientClock32));
 #endif
 
     PVMFMediaLayerPortContainer* poutPort = NULL;
@@ -2276,7 +2316,6 @@
 
 PVMFStatus PVMFMediaLayerNode::sendAccessUnits(PVMFMediaLayerPortContainer* pinputPort)
 {
-    bool isOneToN = pinputPort->iIsOneToN;
 
     PVMFStatus status = PVMFSuccess;
     bool checkAccessUnitsSize = false;
@@ -2357,7 +2396,6 @@
 PVMFStatus PVMFMediaLayerNode::dispatchAccessUnits(PVMFMediaLayerPortContainer* pinputPort,
         PVMFMediaLayerPortContainer* poutPort)
 {
-    bool isOneToN = pinputPort->iIsOneToN;
     PVMFStatus status = PVMFSuccess;
     //
     // send each access unit to its respective port
@@ -2386,10 +2424,10 @@
 
         // retrieve a data implementation
         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
-        int32 err;
-        OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err, mediaDataImplOut = poutPort->ipFragGroupAllocator->allocate());
-        OSCL_ASSERT(err == OsclErrNone); // we just checked that a message is available
-        if (err != OsclErrNone)
+        bool retVal;
+        retVal = Allocate(mediaDataImplOut, poutPort);
+
+        if (retVal == false)
         {
             status = PVMFErrNoMemory;
             break;
@@ -2419,12 +2457,13 @@
                     poutPort->oReconfigId = 0;
                     poutPort->oMsgReconfig.Unbind();
 #if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-                    uint64 timebase64 = 0;
-                    uint64 clientClock64 = 0;
-                    iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+                    uint32 timebase32 = 0;
+                    uint32 clientClock32 = 0;
+                    bool overflowFlag = false;
+                    iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
                     PVMF_MLNODE_LOGDATATRAFFIC_OUT((0,
                                                     "PVMFMediaLayerNode::dispatchAccessUnits: Sending ReConfig - MimeType=%s Clock=%2d",
-                                                    poutPort->iMimeType.get_cstr(), Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                                    poutPort->iMimeType.get_cstr(), clientClock32));
 #endif
                 }
             }
@@ -2471,7 +2510,10 @@
         newMsgHeader.format_id = pinputPort->iCurrFormatId;
         PVMFSharedMediaDataPtr mediaDataOut =
             PVMFMediaData::createMediaData(mediaDataImplOut, &newMsgHeader);
-
+        /*
+         * Could happen during bitstream switching,
+         * asf payload parser starts seq num for each stream from zero
+         */
         if (it->sequence < poutPort->iPrevMsgSeqNum)
         {
             poutPort->iPrevMsgSeqNum++;
@@ -2520,7 +2562,7 @@
                 }
 
                 bool oDecryptRet =
-                    iDecryptionInterface->DecryptAccessUnit((uint8*&)(srcPtr),
+                    iDecryptionInterface->DecryptAccessUnit(srcPtr,
                                                             totalPayloadSize);
                 srcDrmPtr = srcPtr;
                 for (uint32 j = 0; j < num; j++)
@@ -2580,9 +2622,10 @@
                 LogMediaData(mediaDataOut, pinputPort->iPort);
             }
 
-            uint64 timebase64 = 0;
-            uint64 clientClock64 = 0;
-            iClientPlayBackClock->GetCurrentTime64(clientClock64, OSCLCLOCK_MSEC, timebase64);
+            uint32 timebase32 = 0;
+            uint32 clientClock32 = 0;
+            bool overflowFlag = false;
+            iClientPlayBackClock->GetCurrentTime32(clientClock32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, timebase32);
 
             /* Get size for log purposes */
             uint32 numFrags = mediaDataOut->getNumFragments();
@@ -2600,7 +2643,7 @@
                                             size, msgOut->getTimestamp(), msgOut->getSeqNum(),
                                             (mediaDataOut->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_M_BIT),
                                             (mediaDataOut->getMarkerInfo() & PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT),
-                                            Oscl_Int64_Utils::get_uint64_lower32(clientClock64)));
+                                            clientClock32));
 #endif
         }
     }
@@ -2613,6 +2656,19 @@
     return status;
 }
 
+bool PVMFMediaLayerNode::Allocate(OsclSharedPtr<PVMFMediaDataImpl>& mediaDataImplOut, PVMFMediaLayerPortContainer* poutPort)
+{
+    int32 err;
+    OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err, mediaDataImplOut = poutPort->ipFragGroupAllocator->allocate());
+    OSCL_ASSERT(err == OsclErrNone); // we just checked that a message is available
+
+    if (err != OsclErrNone)
+    {
+        return false;
+    }
+    return true;
+}
+
 bool PVMFMediaLayerNode::checkOutputPortsBusy(PVMFMediaLayerPortContainer* pinputPort)
 {
     OSCL_ASSERT(pinputPort->tag == PVMF_MEDIALAYER_PORT_TYPE_INPUT);
@@ -3113,6 +3169,9 @@
         uint32 aPreroll,
         bool aLiveStream)
 {
+    OSCL_UNUSED_ARG(streamid);
+    OSCL_UNUSED_ARG(aPreroll);
+    OSCL_UNUSED_ARG(aLiveStream);
     PVMFMediaLayerPortContainer* outPort = NULL;
     int id;
 
@@ -3324,13 +3383,19 @@
 }
 
 bool PVMFMediaLayerNode::setPlayRange(int32 aStartTimeInMS,
-                                      int32 aStopTimeInMS)
+                                      int32 aStopTimeInMS,
+                                      bool oRepositioning)
 {
     iPlayStartTime = aStartTimeInMS;
     iPlayStopTime = aStopTimeInMS;
     Oscl_Vector<PVMFMediaLayerPortContainer, PVMFMediaLayerNodeAllocator>::iterator it;
     for (it = iPortParamsQueue.begin(); it != iPortParamsQueue.end(); it++)
     {
+        if (oRepositioning)
+        {
+            it->iPort->ClearMsgQueues();
+        }
+
         if (it->tag == PVMF_MEDIALAYER_PORT_TYPE_INPUT)
             it->oEOSReached = false;
     }
@@ -3438,13 +3503,14 @@
 
 bool
 PVMFMediaLayerNodeExtensionInterfaceImpl::setPlayRange(int32 aStartTimeInMS,
-        int32 aStopTimeInMS)
+        int32 aStopTimeInMS,
+        bool oRepositioning)
 {
-    return (iContainer->setPlayRange(aStartTimeInMS, aStopTimeInMS));
+    return (iContainer->setPlayRange(aStartTimeInMS, aStopTimeInMS, oRepositioning));
 }
 
 bool
-PVMFMediaLayerNodeExtensionInterfaceImpl::setClientPlayBackClock(OsclClock* aClientPlayBackClock)
+PVMFMediaLayerNodeExtensionInterfaceImpl::setClientPlayBackClock(PVMFMediaClock* aClientPlayBackClock)
 {
     return (iContainer->setClientPlayBackClock(aClientPlayBackClock));
 }
diff --git a/nodes/streaming/medialayernode/src/pvmf_medialayer_port.cpp b/nodes/streaming/medialayernode/src/pvmf_medialayer_port.cpp
index 5b08bfd..df8a8e7 100644
--- a/nodes/streaming/medialayernode/src/pvmf_medialayer_port.cpp
+++ b/nodes/streaming/medialayernode/src/pvmf_medialayer_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,10 +118,9 @@
 
     if (iPortType == PVMF_MEDIALAYER_PORT_TYPE_OUTPUT)
     {
-        PvmiCapabilityAndConfig *config;
-
-        aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                              (OsclAny*&)config);
+        OsclAny* temp = NULL;
+        aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+        PvmiCapabilityAndConfig *config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
         if (config != NULL)
         {
@@ -160,6 +159,9 @@
         int& num_parameter_elements,
         PvmiCapabilityContext aContext)
 {
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+
     PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::getParametersSync: aSession=0x%x, aIdentifier=%s, aParameters=0x%x, num_parameters_elements=%d, aContext=0x%x",
                          aSession, aIdentifier, aParameters, num_parameter_elements, aContext));
 
@@ -186,6 +188,9 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PVMFMediaLayerPort::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
 {
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(num_elements);
+
     PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
                          aSession, aParameters, num_elements));
 
@@ -204,6 +209,12 @@
         int num_elements,
         PvmiKvp * & aRet_kvp)
 {
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(aRet_kvp);
+
+
     PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::getParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d, aRet_kvp=0x%x",
                          aSession, aParameters, num_elements, aRet_kvp));
 
@@ -213,6 +224,11 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PVMFMediaLayerPort::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
 {
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+
+
     PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::verifyParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d",
                          aSession, aParameters, num_elements));
 
@@ -300,9 +316,9 @@
      * Create PvmiKvp for capability settings
      */
     PVMFStatus status = PVMFErrNotSupported;
-    PvmiCapabilityAndConfig *capConfig;
-    iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                   (OsclAny*&)capConfig);
+    OsclAny* temp = NULL;
+    iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
+    PvmiCapabilityAndConfig *capConfig = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, temp);
 
     if (capConfig != NULL)
     {
@@ -465,6 +481,23 @@
         PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::QueueOutgoingMsg: Connected Port Incoming queue in busy / flushing state - Attempting to Q in output port's outgoing msg q"));
         return (PvmfPortBaseImpl::QueueOutgoingMsg(aMsg));
     }
+    // In case there are data pending in iOutgoingQueue, we should try sending them first.
+    if (!iOutgoingQueue.iQ.empty())
+    {
+        PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::QueueOutgoingMsg: send pending data first"));
+        PVMFStatus status = PvmfPortBaseImpl::Send();
+        if (status != PVMFSuccess)
+        {
+            PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::QueueOutgoingMsg: send pending data not success status = %d:", status));
+            return status;
+        }
+        else if (cpPort->iIncomingQueue.iBusy)
+        {
+            PVMF_MLNODE_LOGINFO((0, "PVMFMediaLayerPort::QueueOutgoingMsg: Connected Port Incoming queue in busy / flushing state after sending pending data - Attempting to Q in output port's outgoing msg q"));
+            return (PvmfPortBaseImpl::QueueOutgoingMsg(aMsg));
+        }
+    }
+
 
     // Add message to outgoing queue and notify the node of the activity
     // There is no need to trap the push_back, since it cannot leave in this usage
diff --git a/nodes/streaming/streamingmanager/Android.mk b/nodes/streaming/streamingmanager/Android.mk
index 2d3e7db..0e2b872 100644
--- a/nodes/streaming/streamingmanager/Android.mk
+++ b/nodes/streaming/streamingmanager/Android.mk
@@ -3,41 +3,57 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_sm_node_factory.cpp \
-	src/pvmf_streaming_manager_extension_interface.cpp \
-	src/pvmf_streaming_manager_node.cpp \
-	src/pvmf_streaming_manager_asf_nosupport.cpp \
-	src/pvmf_streaming_manager_real_nosupport.cpp \
-	src/pvmf_streaming_manager_cpm_support.cpp \
-	src/../config/3gpp/streamingmanager_payloadparser_registry.cpp
+ 	src/pvmf_streaming_manager_node.cpp \
+ 	src/../config/3gpp/pvmf_sm_fsp_registry.cpp \
+ 	src/../plugins/common/src/pvmf_sm_fsp_base_impl.cpp \
+ 	src/../plugins/common/src/pvmf_sm_fsp_base_cpm_support.cpp \
+ 	src/../plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_node_factory.cpp \
+ 	src/../plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.cpp
+
+
+LOCAL_MODULE := libpvstreamingmanagernode
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
 
-LOCAL_MODULE := libpvstreamingmanagernode_3gpp
+LOCAL_STATIC_LIBRARIES := 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//nodes/streaming/streamingmanager/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/src \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../common/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../config/opencore \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../jitterbuffernode/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../jitterbuffernode/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../medialayernode/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../../../protocols/rtp/src \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../../common/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../../../protocols/sdp/common/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../../../pvmi/content_policy_manager/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../../../pvmi/content_policy_manager/plugins/common/include \
-	$(PV_TOP)//nodes/streaming/streamingmanager/../../../protocols/rtp_payload_parser/rfc_3640/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/nodes/streaming/streamingmanager/src \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_TOP)/nodes/streaming/jitterbuffernode/include \
+ 	$(PV_TOP)/nodes/streaming/jitterbuffernode/include \
+ 	$(PV_TOP)/nodes/streaming/medialayernode/include \
+ 	$(PV_TOP)/protocols/rtp/src \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_TOP)/fileformats/asf/parser/include \
+ 	$(PV_TOP)/fileformats/rmff_type_specific_parser/src \
+ 	$(PV_TOP)/protocols/rdt_parser/realchallenge/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/common/include \
+ 	$(PV_TOP)/nodes/pvrtppacketsourcenode/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3640/include \
+ 	$(PV_TOP)/nodes/pvpvr/include \
+ 	$(PV_TOP)/nodes/pvpvr/src \
+ 	$(PV_TOP)/nodes/pvpvrnode/include \
+ 	$(PV_TOP)/nodes/pvpvrnode/src \
+ 	$(PV_TOP)/fileformats/pvr/composer/include \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/plugins/common/include \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/config/3gpp \
+ 	$(PV_TOP)/protocols/rtsp_client_engine/src \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/plugins/rtspunicast/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_sm_node_events.h \
-	include/pvmf_sm_node_factory.h
+ 	include/pvmf_sm_node_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/nodes/streaming/streamingmanager/build/linux_3gpp/makefile b/nodes/streaming/streamingmanager/build/linux_3gpp/makefile
deleted file mode 100644
index 2b69160..0000000
--- a/nodes/streaming/streamingmanager/build/linux_3gpp/makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvstreamingmanagernode_3gpp
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += \
-	-I../../../common/include \
-	-I ../../../config/opencore \
-	-I ../../../jitterbuffernode/include \
-	-I ../../../jitterbuffernode/include \
-	-I ../../../medialayernode/include \
-	-I ../../../../../protocols/rtp/src \
-	-I ../../../../common/include \
-	-I ../../../../../protocols/sdp/common/include \
-	-I ../../../../../pvmi/content_policy_manager/include \
-	-I ../../../../../pvmi/content_policy_manager/plugins/common/include \
-	-I../../../../../protocols/rtp_payload_parser/rfc_3640/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pvmf_sm_node_factory.cpp \
-	pvmf_streaming_manager_extension_interface.cpp \
-	pvmf_streaming_manager_node.cpp \
-	pvmf_streaming_manager_asf_nosupport.cpp \
-	pvmf_streaming_manager_real_nosupport.cpp \
-	pvmf_streaming_manager_cpm_support.cpp \
-        ../config/3gpp/streamingmanager_payloadparser_registry.cpp
-
-HDRS =  pvmf_sm_node_events.h \
-	pvmf_sm_node_factory.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/streaming/streamingmanager/build/make/makefile b/nodes/streaming/streamingmanager/build/make/makefile
deleted file mode 100644
index 697bd97..0000000
--- a/nodes/streaming/streamingmanager/build/make/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvstreamingmanagernode
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../../common/include -I../../../jitterbuffernode/include -I../../../jitterbuffernode/include -I../../../medialayernode/include -I../../../../../protocols/rtp/src -I../../../../common/include -I../../../../../protocols/sdp/common/include -I../../../../../fileformats/asf/parser/include -I../../../../../fileformats/rmff_type_specific_parser/src -I../../../../../protocols/rdt_parser/realchallenge/include -I../../../../../pvmi/content_policy_manager/include -I../../../../../pvmi/content_policy_manager/plugins/common/include -I../../../../../nodes/pvrtppacketsourcenode/include -I../../../../../pvmi/pvmf/include -I../../../../../protocols/rtp_payload_parser/rfc_3640/include
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pvmf_sm_node_factory.cpp \
-	pvmf_streaming_manager_extension_interface.cpp \
-	pvmf_streaming_manager_node.cpp \
-	pvmf_streaming_manager_asf_support.cpp \
-	pvmf_streaming_manager_real_support.cpp \
-	pvmf_streaming_manager_cpm_support.cpp \
-	../config/default/streamingmanager_payloadparser_registry.cpp      
-
-HDRS =  pvmf_sm_node_events.h \
-	pvmf_sm_node_factory.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/nodes/streaming/streamingmanager/build/make_segments/3gpp.mk b/nodes/streaming/streamingmanager/build/make_segments/3gpp.mk
new file mode 100644
index 0000000..9811c56
--- /dev/null
+++ b/nodes/streaming/streamingmanager/build/make_segments/3gpp.mk
@@ -0,0 +1,7 @@
+
+#FSP Base
+XINCDIRS += -I../../config/3gpp
+
+SRCS += ../config/3gpp/pvmf_sm_fsp_registry.cpp
+SRCS += ../plugins/common/src/pvmf_sm_fsp_base_impl.cpp
+SRCS += ../plugins/common/src/pvmf_sm_fsp_base_cpm_support.cpp
diff --git a/nodes/streaming/streamingmanager/build/make_segments/local.mk b/nodes/streaming/streamingmanager/build/make_segments/local.mk
new file mode 100644
index 0000000..f636774
--- /dev/null
+++ b/nodes/streaming/streamingmanager/build/make_segments/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvstreamingmanagernode
+
+
+
+
+XINCDIRS += ../../../common/include ../../../jitterbuffernode/include ../../../jitterbuffernode/include ../../../medialayernode/include ../../../../../protocols/rtp/src ../../../../common/include ../../../../../protocols/sdp/common/include ../../../../../fileformats/asf/parser/include ../../../../../fileformats/rmff_type_specific_parser/src ../../../../../protocols/rdt_parser/realchallenge/include ../../../../../pvmi/content_policy_manager/include ../../../../../pvmi/content_policy_manager/plugins/common/include ../../../../../nodes/pvrtppacketsourcenode/include ../../../../../pvmi/pvmf/include ../../../../../protocols/rtp_payload_parser/rfc_3640/include ../../../../../nodes/pvpvr/include ../../../../../nodes/pvpvr/src ../../../../../nodes/pvpvrnode/include ../../../../../nodes/pvpvrnode/src ../../../../../fileformats/pvr/composer/include
+XINCDIRS += ../../plugins/common/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_sm_node_factory.cpp 
+SRCS +=	pvmf_streaming_manager_node.cpp 		
+
+HDRS := pvmf_sm_node_events.h \
+	pvmf_sm_node_factory.h
+
+
+# include $(call process_include_list,$(LOCAL_PATH),$(STREAMING_PLUGINS))
+
+include $(MK)/library.mk
+
diff --git a/nodes/streaming/streamingmanager/build/make_segments/rtspunicast.mk b/nodes/streaming/streamingmanager/build/make_segments/rtspunicast.mk
new file mode 100644
index 0000000..859c5d7
--- /dev/null
+++ b/nodes/streaming/streamingmanager/build/make_segments/rtspunicast.mk
@@ -0,0 +1,7 @@
+#RTSP Unicast Plugin
+
+XINCDIRS += -I../../../../../protocols/rtsp_client_engine/src
+XINCDIRS += -I../../plugins/rtspunicast/include
+
+SRCS += ../plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_node_factory.cpp
+SRCS += ../plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.cpp
diff --git a/nodes/streaming/streamingmanager/config/3gpp/pvmf_sm_config.h b/nodes/streaming/streamingmanager/config/3gpp/pvmf_sm_config.h
new file mode 100644
index 0000000..f612549
--- /dev/null
+++ b/nodes/streaming/streamingmanager/config/3gpp/pvmf_sm_config.h
@@ -0,0 +1,31 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+//     SM C O N F I G   ( O P E N  C O R E  C O N F I G   I N F O )
+
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+#ifndef PVMF_SM_CONFIG_H_INCLUDED
+#define PVMF_SM_CONFIG_H_INCLUDED
+
+#define	PVMF_SM_HAS_WINDOWS_MEDIA_SUPPORT		0
+#define	PVMF_SM_HAS_REAL_MEDIA_SUPPORT			0
+#define	PVMF_SM_HAS_PV_PLAYLIST_SUPPORT 		0
+
+#endif // PVMF_SM_CONFIG_H_INCLUDED
diff --git a/nodes/streaming/streamingmanager/config/3gpp/pvmf_sm_fsp_registry.cpp b/nodes/streaming/streamingmanager/config/3gpp/pvmf_sm_fsp_registry.cpp
new file mode 100644
index 0000000..41be511
--- /dev/null
+++ b/nodes/streaming/streamingmanager/config/3gpp/pvmf_sm_fsp_registry.cpp
@@ -0,0 +1,141 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_REGISTRY_H
+#include "pvmf_sm_fsp_registry.h"
+#endif
+
+#ifndef PVMF_SM_RTSP_UNICAST_NODE_FACTORY_H_INCLUDED
+#include "pvmf_sm_rtsp_unicast_node_factory.h"
+#endif
+
+PVMFSMFSPRegistry::PVMFSMFSPRegistry()
+{
+    PVMFSMFSPInfo fspInfo;
+    iType.reserve(10);
+
+    fspInfo.iSourceFormatTypes.clear();
+    fspInfo.iSourceFormatTypes.push_back(PVMF_MIME_DATA_SOURCE_RTSP_URL);
+    fspInfo.iSourceFormatTypes.push_back(PVMF_MIME_DATA_SOURCE_SDP_FILE);
+    fspInfo.iSMFSPUUID = KPVMFSMRTSPUnicastNodeUuid;
+    fspInfo.iSMFSPCreateFunc = PVMFSMRTSPUnicastNodeFactory::CreateSMRTSPUnicastNodeFactory;
+    fspInfo.iSMFSPReleaseFunc = PVMFSMRTSPUnicastNodeFactory::DeleteSMRTSPUnicastNodeFactory;
+    iType.push_back(fspInfo);
+}
+
+PVMFSMFSPRegistry::~PVMFSMFSPRegistry()
+{
+    iType.clear();
+}
+
+PVMFStatus PVMFSMFSPRegistry::QueryRegistry(PVMFFormatType& aInputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids)
+{
+    uint32 SearchCount = 0;
+    bool matchfound = false;
+
+    // Find all nodes that support the specified src format
+    while (SearchCount < iType.size())
+    {
+        uint32 inputsearchcount = 0;
+        while (inputsearchcount < iType[SearchCount].iSourceFormatTypes.size())
+        {
+            // Check if the input format matches
+            if (iType[SearchCount].iSourceFormatTypes[inputsearchcount] == aInputType)
+            {
+                // Set the the input flag to true since we found the match in the search
+                matchfound = true;
+                break;
+            }
+            inputsearchcount++;
+        }
+        if (matchfound)
+            break;
+        SearchCount++;
+    }
+
+    if (matchfound)
+    {
+        aUuids.push_back(iType[SearchCount].iSMFSPUUID);
+        matchfound = true;
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+PVMFSMFSPBaseNode* PVMFSMFSPRegistry::CreateSMFSP(PVUuid& aUuid)
+{
+    bool iFoundFlag = false;
+    uint32 FSPSearchCount = 0;
+
+    while (FSPSearchCount < iType.size())
+    {
+        //Search if the UUID's will match
+        if (iType[FSPSearchCount].iSMFSPUUID == aUuid)
+        {
+            //Since the UUID's match set the flag to true
+            iFoundFlag = true;
+            break;
+        }
+
+        FSPSearchCount++;
+
+    }
+
+    if (iFoundFlag)
+    {
+        //Call the appropriate Node creation function & return Node pointer
+        return (*(iType[FSPSearchCount].iSMFSPCreateFunc))(OsclActiveObject::EPriorityNominal);
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+bool PVMFSMFSPRegistry::ReleaseSMFSP(PVUuid& aUuid, PVMFSMFSPBaseNode *aSMFSP)
+{
+    bool iFoundFlag = false;
+    uint32 FSPSearchCount = 0;
+
+    while (FSPSearchCount < iType.size())
+    {
+        //Search if the UUID's will match
+        if (iType[FSPSearchCount].iSMFSPUUID == aUuid)
+        {
+            //Since the UUID's match set the flag to true
+            iFoundFlag = true;
+            break;
+        }
+
+        FSPSearchCount++;
+
+    }
+
+    if (iFoundFlag)
+    {
+        //Call the appropriate Node creation function
+        bool del_stat = (*(iType[FSPSearchCount].iSMFSPReleaseFunc))(aSMFSP);
+        return del_stat;
+    }
+    return false;
+}
+
+
+
diff --git a/nodes/streaming/streamingmanager/config/3gpp/streamingmanager_payloadparser_registry.cpp b/nodes/streaming/streamingmanager/config/3gpp/streamingmanager_payloadparser_registry.cpp
index 6df8b2e..f36e0a6 100644
--- a/nodes/streaming/streamingmanager/config/3gpp/streamingmanager_payloadparser_registry.cpp
+++ b/nodes/streaming/streamingmanager/config/3gpp/streamingmanager_payloadparser_registry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/nodes/streaming/streamingmanager/config/default/streamingmanager_payloadparser_registry.cpp b/nodes/streaming/streamingmanager/config/default/streamingmanager_payloadparser_registry.cpp
deleted file mode 100644
index 236f302..0000000
--- a/nodes/streaming/streamingmanager/config/default/streamingmanager_payloadparser_registry.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED
-#include "pvmf_streaming_manager_internal.h"
-#endif
-#ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
-#include "pvmf_streaming_manager_node.h"
-#endif
-#ifndef AMR_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "amr_payload_parser_factory.h"
-#endif
-#ifndef ASF_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "asf_payload_parser_factory.h"
-#endif
-#ifndef H263_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "h263_payload_parser_factory.h"
-#endif
-#ifndef H264_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "h264_payload_parser_factory.h"
-#endif
-#ifndef M4V_AUDIO_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "m4v_audio_payload_parser_factory.h"
-#endif
-#ifndef M4V_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "m4v_payload_parser_factory.h"
-#endif
-#ifndef REALAUDIO_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "realaudio_payload_parser_factory.h"
-#endif
-#ifndef REALVIDEO_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "realvideo_payload_parser_factory.h"
-#endif
-#ifndef PAYLOAD_PARSER_REGISTRY_H_INCLUDED
-#include "payload_parser_registry.h"
-#endif
-#ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
-#include "pvmf_medialayer_node.h"
-#endif
-#ifndef RFC3640_PAYLOAD_PARSER_FACTORY_H_INCLUDED
-#include "rfc3640_payload_parser_factory.h"
-#endif
-
-void PVMFStreamingManagerNode::PopulatePayloadParserRegistry()
-{
-    PayloadParserRegistry* registry =
-        PayloadParserRegistry::GetPayloadParserRegistry();
-    OSCL_ASSERT(registry == NULL);
-    PayloadParserRegistry::Init();
-    registry = PayloadParserRegistry::GetPayloadParserRegistry();
-
-    StrPtrLen aac_latm("audio/MP4A-LATM");
-    StrPtrLen amr("audio/AMR");
-    StrPtrLen amrwb("audio/AMR-WB");
-    StrPtrLen h263_old("video/H263-1998");
-    StrPtrLen h263("video/H263-2000");
-    StrPtrLen m4v("video/MP4V-ES");
-    StrPtrLen h264("video/H264");
-    StrPtrLen asf("asf");
-    StrPtrLen rma(PVMF_MIME_REAL_AUDIO);
-    StrPtrLen rmv(PVMF_MIME_REAL_VIDEO);
-    StrPtrLen mp4a(PVMF_MIME_MPEG4_AUDIO);
-    StrPtrLen rfc3640("audio/mpeg4-generic");
-
-
-
-    IPayloadParserFactory* m4vP = OSCL_NEW(M4VPayloadParserFactory, ());
-    IPayloadParserFactory* aacP = OSCL_NEW(M4VAudioPayloadParserFactory, ());
-    IPayloadParserFactory* amrP = OSCL_NEW(AmrPayloadParserFactory, ());
-    IPayloadParserFactory* h263P = OSCL_NEW(H263PayloadParserFactory, ());
-    IPayloadParserFactory* h264P = OSCL_NEW(H264PayloadParserFactory, ());
-    IPayloadParserFactory* asfP = OSCL_NEW(AsfPayloadParserFactory, ());
-    IPayloadParserFactory* realAP = OSCL_NEW(RealAudioPayloadParserFactory, ());
-    IPayloadParserFactory* realVP = OSCL_NEW(RealVideoPayloadParserFactory, ());
-    IPayloadParserFactory* amrwbP = OSCL_NEW(AmrPayloadParserFactory, ());
-    IPayloadParserFactory* rfc3640P = OSCL_NEW(RFC3640PayloadParserFactory, ());
-
-    registry->addPayloadParserFactoryToRegistry(m4v, m4vP);
-    registry->addPayloadParserFactoryToRegistry(h264, h264P);
-    registry->addPayloadParserFactoryToRegistry(aac_latm, aacP);
-    registry->addPayloadParserFactoryToRegistry(mp4a, aacP);
-    registry->addPayloadParserFactoryToRegistry(amr, amrP);
-    registry->addPayloadParserFactoryToRegistry(amrwb, amrwbP);
-    registry->addPayloadParserFactoryToRegistry(h263_old, h263P);
-    registry->addPayloadParserFactoryToRegistry(h263, h263P);
-    registry->addPayloadParserFactoryToRegistry(asf, asfP);
-    registry->addPayloadParserFactoryToRegistry(rma, realAP);
-    registry->addPayloadParserFactoryToRegistry(rmv, realVP);
-    registry->addPayloadParserFactoryToRegistry(rfc3640,  rfc3640P);
-
-
-    // pass the registry to the media layer node
-    PVMFSMNodeContainer* iMediaLayerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-        (PVMFMediaLayerNodeExtensionInterface*)(iMediaLayerNodeContainer->iExtensions[0]);
-    mlExtIntf->setPayloadParserRegistry(registry);
-
-}
-
-void PVMFStreamingManagerNode::destroyPayloadParserRegistry()
-{
-    StrPtrLen aac_latm("audio/MP4A-LATM");
-    StrPtrLen amr("audio/AMR");
-    StrPtrLen amrwb("audio/AMR-WB");
-    StrPtrLen h263("video/H263-2000");
-    StrPtrLen m4v("video/MP4V-ES");
-    StrPtrLen h264("video/H264");
-    StrPtrLen asf("asf");
-    StrPtrLen rma(PVMF_MIME_REAL_AUDIO);
-    StrPtrLen rmv(PVMF_MIME_REAL_VIDEO);
-    StrPtrLen rfc3640("audio/mpeg4-generic");
-
-    PayloadParserRegistry* registry =
-        PayloadParserRegistry::GetPayloadParserRegistry();
-    if (registry == NULL) return;
-
-    OsclMemoryFragment memFrag;
-
-    memFrag.ptr = (OsclAny*)(m4v.c_str());
-    memFrag.len = (uint32)m4v.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(h264.c_str());
-    memFrag.len = (uint32)h264.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(aac_latm.c_str());
-    memFrag.len = (uint32)aac_latm.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(amr.c_str());
-    memFrag.len = (uint32)amr.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(amrwb.c_str());
-    memFrag.len = (uint32)amrwb.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(h263.c_str());
-    memFrag.len = (uint32)h263.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(asf.c_str());
-    memFrag.len = (uint32)asf.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(rma.c_str());
-    memFrag.len = (uint32)rma.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(rmv.c_str());
-    memFrag.len = (uint32)rmv.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    memFrag.ptr = (OsclAny*)(rfc3640.c_str());
-    memFrag.len = (uint32)rfc3640.size();
-    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
-
-    PayloadParserRegistry::Cleanup();
-}
diff --git a/nodes/streaming/streamingmanager/include/pvmf_sm_capconfig.h b/nodes/streaming/streamingmanager/include/pvmf_sm_capconfig.h
deleted file mode 100644
index 0ecfb16..0000000
--- a/nodes/streaming/streamingmanager/include/pvmf_sm_capconfig.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-///////////////////////////////////////////////////////////////////////////////
-//
-// Capability and config interface related constants and definitions
-//   - based on pv_player_engine.h
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef PVMF_SM_CAPCONFIG_H_INCLUDED
-#define PVMF_SM_CAPCONFIG_H_INCLUDED
-
-
-struct StreamingManagerKeyStringData
-{
-    char iString[64];
-    PvmiKvpType iType;
-    PvmiKvpValueType iValueType;
-};
-
-
-// The number of characters to allocate for the key string
-#define SMCONFIG_KEYSTRING_SIZE 128
-
-#endif
-
-
diff --git a/nodes/streaming/streamingmanager/include/pvmf_sm_node_events.h b/nodes/streaming/streamingmanager/include/pvmf_sm_node_events.h
index 9494de8..3125dee 100644
--- a/nodes/streaming/streamingmanager/include/pvmf_sm_node_events.h
+++ b/nodes/streaming/streamingmanager/include/pvmf_sm_node_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
 typedef enum
 {
     PVMFStreamingManagerNodeInfoEventStart = 8192,
+    PVMFStreamingManagerNodeInfoLaunchURL,
     PVMFStreamingManagerNodeInfoEventEnd
 } PVMFStreamingManagerNodeInfoEventType;
 
@@ -74,6 +75,7 @@
     PVMFJitterBufferNodeJitterBufferLowWaterMarkReached,
     PVMFJitterBufferNodeJitterBufferHighWaterMarkReached,
     PVMFJitterBufferNodeStreamThinningRecommended,
+    PVMFJitterBufferNodeRTCPDataProcessed,
     PVMFJitterBufferNodeInfoEventEnd
 } PVMFJitterBufferNodeInfoEventType;
 
diff --git a/nodes/streaming/streamingmanager/include/pvmf_sm_node_factory.h b/nodes/streaming/streamingmanager/include/pvmf_sm_node_factory.h
index db8d125..42ddb4d 100644
--- a/nodes/streaming/streamingmanager/include/pvmf_sm_node_factory.h
+++ b/nodes/streaming/streamingmanager/include/pvmf_sm_node_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,6 +65,8 @@
         OSCL_IMPORT_REF static bool DeleteStreamingManagerNode(PVMFNodeInterface* aNode);
 };
 
+const int PVMFFSPNotCreated = -1;
+
 #endif
 
 
diff --git a/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_cmds.h b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_cmds.h
new file mode 100644
index 0000000..92cc240
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_cmds.h
@@ -0,0 +1,202 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_BASE_CMDS_H_INCLUDED
+#define PVMF_SM_FSP_BASE_CMDS_H_INCLUDED
+
+#define PVMF_SM_FSP_SOCKET_NODE_COMMAND_START              1000
+#define PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START  2000
+#define PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START 3000
+#define PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START              4000
+#define PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_COMMAND_START  5000
+#define PVMF_SM_FSP_RTPPACKETSOURCE_NODE_COMMAND_START     6000
+#define PVMF_SM_FSP_PVR_NODE_COMMAND_START				   7000
+#define PVMF_SM_FSP_NODE_COMMAND_ID_START				  10000
+
+#define PVMF_SM_FSP_VECTOR_RESERVE							 10
+#define PVMF_SMFSP_INTERNAL_CMDQ_SIZE		                 40
+
+///////////////////////////////////////////////
+//IDs for all of the asynchronous node commands.
+///////////////////////////////////////////////
+enum TPVMFSMFSPBaseNodeCommand
+{
+    /* node interface commands*/
+    PVMF_SMFSP_NODE_QUERYUUID = PVMF_GENERIC_NODE_QUERYUUID,
+    PVMF_SMFSP_NODE_QUERYINTERFACE,
+    PVMF_SMFSP_NODE_REQUESTPORT,
+    PVMF_SMFSP_NODE_RELEASEPORT,
+    PVMF_SMFSP_NODE_INIT,
+    PVMF_SMFSP_NODE_PREPARE,
+    PVMF_SMFSP_NODE_START,
+    PVMF_SMFSP_NODE_STOP,
+    PVMF_SMFSP_NODE_FLUSH,
+    PVMF_SMFSP_NODE_PAUSE,
+    PVMF_SMFSP_NODE_RESET,
+    PVMF_SMFSP_NODE_CANCELALLCOMMANDS,
+    PVMF_SMFSP_NODE_CANCELCOMMAND,
+
+    /* add extention interface commands */
+    PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION = PVMF_GENERIC_NODE_COMMAND_LAST + 1,
+    PVMF_SMFSP_NODE_QUERY_DATASOURCE_POSITION,
+    PVMF_SMFSP_NODE_SET_DATASOURCE_RATE,
+    PVMF_SMFSP_NODE_GETNODEMETADATAKEYS,
+    PVMF_SMFSP_NODE_GETNODEMETADATAVALUES,
+    PVMF_SMFSP_NODE_GET_LICENSE_W, //have both ascii and unicode version
+    PVMF_SMFSP_NODE_GET_LICENSE,
+    PVMF_SMFSP_NODE_CANCEL_GET_LICENSE,
+    PVMF_SMFSP_NODE_CAPCONFIG_SETPARAMS,
+    PVMF_SMFSP_NODE_EXTENSION_INTERFACE_COMMAND_LAST,
+
+    /* add commands which are internal to the implementation of Streaming Node and are common for are types of feature specific plugins*/
+    PVMF_SMFSP_NODE_CONSTRUCT_SESSION = PVMF_SMFSP_NODE_EXTENSION_INTERFACE_COMMAND_LAST + 1,	//to construct the graph
+    PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR,
+    PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+    PVMF_SMFSP_NODE_COMMAND_LAST
+};
+
+enum TPVMFSMFSPChildNodeTag
+{
+    PVMF_SM_FSP_NODE_UNKNOWN = 0,
+    PVMF_SM_FSP_SOCKET_NODE = 1,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE = 2,
+    PVMF_SM_FSP_JITTER_BUFFER_NODE = 3,
+    PVMF_SM_FSP_MEDIA_LAYER_NODE = 4,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_NODE = 5,
+    PVMF_SM_FSP_RTPPACKETSOURCE_NODE = 6,
+    PVMF_SM_FSP_PVR_NODE = 7,
+    PVMF_SM_FSP_LAST_CHILD_NODE
+};
+
+#define PVMF_SM_FSP_NODE_INTERNAL_QUERY_UUID_CMD_OFFSET       0
+#define PVMF_SM_FSP_NODE_INTERNAL_QUERY_INTERFACE_CMD_OFFSET  1
+#define PVMF_SM_FSP_NODE_INTERNAL_INIT_CMD_OFFSET             2
+#define PVMF_SM_FSP_NODE_INTERNAL_PREPARE_CMD_OFFSET          3
+#define PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET            4
+#define PVMF_SM_FSP_NODE_INTERNAL_STOP_CMD_OFFSET             5
+#define PVMF_SM_FSP_NODE_INTERNAL_FLUSH_CMD_OFFSET            6
+#define PVMF_SM_FSP_NODE_INTERNAL_PAUSE_CMD_OFFSET            7
+#define PVMF_SM_FSP_NODE_INTERNAL_RESET_CMD_OFFSET            8
+#define PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET         9
+#define PVMF_SM_FSP_NODE_INTERNAL_RELEASE_PORT_OFFSET         10
+#define PVMF_SM_FSP_NODE_INTERNAL_CANCEL_ALL_OFFSET           11
+#define PVMF_SM_FSP_NODE_INTERNAL_SEEK_OFFSET                 12
+#define PVMF_SM_FSP_NODE_INTERNAL_STREAM_SWITCH_CMD_OFFSET    13
+#define PVMF_SM_FSP_NODE_INTERNAL_PLAYLIST_PLAY_CMD_OFFSET    14
+
+enum TPVMFStreamingManagerInternalCommands
+{
+    PVMF_SM_FSP_INTERNAL_COMMAND_NONE = 0,
+
+    PVMF_SM_FSP_SOCKET_NODE_QUERY_UUID = 1000,
+    PVMF_SM_FSP_SOCKET_NODE_QUERY_INTERFACE = 1001,
+    PVMF_SM_FSP_SOCKET_NODE_INIT = 1002,
+    PVMF_SM_FSP_SOCKET_NODE_PREPARE = 1003,
+    PVMF_SM_FSP_SOCKET_NODE_START = 1004,
+    PVMF_SM_FSP_SOCKET_NODE_STOP = 1005,
+    PVMF_SM_FSP_SOCKET_NODE_FLUSH = 1006,
+    PVMF_SM_FSP_SOCKET_NODE_PAUSE = 1007,
+    PVMF_SM_FSP_SOCKET_NODE_RESET = 1008,
+    PVMF_SM_FSP_SOCKET_NODE_REQUEST_PORT = 1009,
+    PVMF_SM_FSP_SOCKET_NODE_RELEASE_PORT = 1010,
+    PVMF_SM_FSP_SOCKET_NODE_CANCEL_ALL_COMMANDS = 1011,
+
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_QUERY_UUID = 2000,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_QUERY_INTERFACE = 2001,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_INIT = 2002,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PREPARE = 2003,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_START = 2004,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_STOP = 2005,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_FLUSH = 2006,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PAUSE = 2007,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_RESET = 2008,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_REQUEST_PORT = 2009,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_RELEASE_PORT = 2010,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_CANCEL_ALL_COMMANDS = 2011,
+    PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PLAYLIST_PLAY = 2014,
+
+    PVMF_SM_FSP_JITTER_BUFFER_QUERY_UUID = 3000,
+    PVMF_SM_FSP_JITTER_BUFFER_QUERY_INTERFACE = 3001,
+    PVMF_SM_FSP_JITTER_BUFFER_INIT = 3002,
+    PVMF_SM_FSP_JITTER_BUFFER_PREPARE = 3003,
+    PVMF_SM_FSP_JITTER_BUFFER_START = 3004,
+    PVMF_SM_FSP_JITTER_BUFFER_STOP = 3005,
+    PVMF_SM_FSP_JITTER_BUFFER_FLUSH = 3006,
+    PVMF_SM_FSP_JITTER_BUFFER_PAUSE = 3007,
+    PVMF_SM_FSP_JITTER_BUFFER_RESET = 3008,
+    PVMF_SM_FSP_JITTER_BUFFER_REQUEST_PORT = 3009,
+    PVMF_SM_FSP_JITTER_BUFFER_RELEASE_PORT = 3010,
+    PVMF_SM_FSP_JITTER_BUFFER_CANCEL_ALL_COMMANDS = 3011,
+
+    PVMF_SM_FSP_MEDIA_LAYER_QUERY_UUID = 4000,
+    PVMF_SM_FSP_MEDIA_LAYER_QUERY_INTERFACE = 4001,
+    PVMF_SM_FSP_MEDIA_LAYER_INIT = 4002,
+    PVMF_SM_FSP_MEDIA_LAYER_PREPARE = 4003,
+    PVMF_SM_FSP_MEDIA_LAYER_START = 4004,
+    PVMF_SM_FSP_MEDIA_LAYER_STOP = 4005,
+    PVMF_SM_FSP_MEDIA_LAYER_FLUSH = 4006,
+    PVMF_SM_FSP_MEDIA_LAYER_PAUSE = 4007,
+    PVMF_SM_FSP_MEDIA_LAYER_RESET = 4008,
+    PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT = 4009,
+    PVMF_SM_FSP_MEDIA_LAYER_RELEASE_PORT = 4010,
+    PVMF_SM_FSP_MEDIA_LAYER_CANCEL_ALL_COMMANDS = 4011,
+
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_QUERY_UUID = 5000,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_QUERY_INTERFACE = 5001,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_INIT = 5002,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_PREPARE = 5003,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_START = 5004,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_STOP = 5005,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_FLUSH = 5006,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_PAUSE = 5007,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_RESET = 5008,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_REQUEST_PORT = 5009,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_RELEASE_PORT = 5010,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_CANCEL_ALL_COMMANDS = 5011,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_SEEK = 5012,
+    PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_STREAM_SWITCH = 5013,
+
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_QUERY_UUID = 6000,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_QUERY_INTERFACE = 6001,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_INIT = 6002,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_PREPARE = 6003,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_START = 6004,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_STOP = 6005,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_FLUSH = 6006,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_PAUSE = 6007,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_RESET = 6008,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_REQUEST_PORT = 6009,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_RELEASE_PORT = 6010,
+    PVMF_SM_FSP_RTP_PACKET_SOURCE_NODE_CANCEL_ALL_COMMANDS = 6011,
+
+    PVMF_SM_FSP_PVR_NODE_QUERY_UUID = 7000,
+    PVMF_SM_FSP_PVR_NODE_QUERY_INTERFACE = 7001,
+    PVMF_SM_FSP_PVR_NODE_INIT = 7002,
+    PVMF_SM_FSP_PVR_NODE_PREPARE = 7003,
+    PVMF_SM_FSP_PVR_NODE_START = 7004,
+    PVMF_SM_FSP_PVR_NODE_STOP = 7005,
+    PVMF_SM_FSP_PVR_NODE_FLUSH = 7006,
+    PVMF_SM_FSP_PVR_NODE_PAUSE = 7007,
+    PVMF_SM_FSP_PVR_NODE_RESET = 7008,
+    PVMF_SM_FSP_PVR_NODE_REQUEST_PORT = 7009,
+    PVMF_SM_FSP_PVR_NODE_RELEASE_PORT = 7010,
+    PVMF_SM_FSP_PVR_NODE_CANCEL_ALL_COMMANDS = 7011,
+
+    PVMF_SM_FSP_INTERNAL_COMMAND_LAST = 7999
+};
+#endif
+
diff --git a/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_impl.h b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_impl.h
new file mode 100644
index 0000000..040d74c
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_impl.h
@@ -0,0 +1,607 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#define PVMF_SM_FSP_BASE_IMPL_H
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED
+#include "pvmf_data_source_init_extension.h"
+#endif
+
+#ifndef PVMF_TRACK_SELECTION_EXTENSION_H_INCLUDED
+#include "pvmf_track_selection_extension.h"
+#endif
+
+#ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
+#include "pvmf_data_source_playback_control.h"
+#endif
+
+#ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
+#include "pvmf_meta_data_extension.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
+
+#ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED
+#include "pvmf_cpmplugin_license_interface.h"
+#endif
+
+#ifndef CPM_H_INCLUDED
+#include "cpm.h"
+#endif
+
+#ifndef PVMF_STREAMING_DATA_SOURCE_H_INCLUDED
+#include "pvmf_streaming_data_source.h"
+#endif
+
+#ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
+#include "pvmf_source_context_data.h"
+#endif
+
+#ifndef PVMF_SM_FSP_BASE_CMDS_H_INCLUDED
+#include "pvmf_sm_fsp_base_cmds.h"
+#endif
+
+#ifndef PVMF_SM_FSP_BASE_TYPES_H_INCLUDED
+#include "pvmf_sm_fsp_base_types.h"
+#endif
+
+
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
+#include "pvmf_sm_fsp_base_metadata.h"
+#endif
+
+#define PVMF_SM_FSP_BASE_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_STACK_TRACE,m);
+#define PVMF_SM_FSP_BASE_LOGDEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_DEBUG,m);
+#define PVMF_SM_FSP_BASE_LOGERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_ERR,m);
+#define PVMF_SM_FSP_BASE_LOGCMDSEQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iCommandSeqLogger,PVLOGMSG_STACK_TRACE,m);
+
+#define PVMF_SM_ERRHANDLER_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_STACK_TRACE,m);
+#define PVMF_SM_ERRHANDLER_LOGDEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m);
+#define PVMF_SM_ERRHANDLER_LOGERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_ERR,m);
+#define PVMF_SM_ERRHANDLER_LOGCMDSEQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_STACK_TRACE,m);
+
+class PVMFSMSessionMetaDataInfo;
+class PVMFSMFSPChildNodeErrorHandler;
+#define PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE 40
+
+class PVMFSMFSPBaseNode : public PVMFNodeInterface,
+            public OsclActiveObject,
+            public PvmiCapabilityAndConfig,
+            public PVMFDataSourceInitializationExtensionInterface,
+            public PVMFTrackSelectionExtensionInterface,
+            public PvmfDataSourcePlaybackControlInterface,
+            public PVMFMetadataExtensionInterface,
+            public PVMFCPMPluginLicenseInterface,
+            public PVMFNodeErrorEventObserver,
+            public PVMFNodeInfoEventObserver,
+            public PVMFNodeCmdStatusObserver,
+            public PVMFCPMStatusObserver
+{
+        friend class PVMFSMFSPChildNodeErrorHandler;
+    public:
+        OSCL_IMPORT_REF virtual ~PVMFSMFSPBaseNode();
+
+        /* From PVMFNodeInterface */
+        OSCL_IMPORT_REF PVMFStatus ThreadLogon();
+        OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+
+        //Added overload of Connect
+        //Connects PVMFSMFSPBaseNode to the StreamingManagerNode
+        OSCL_IMPORT_REF PVMFSessionId Connect(const PVMFNodeSession &iUpstreamSession);
+
+
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+
+        //Deprecated.Will cause assertion failure
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId,
+                                                const PvmfMimeString& aMimeType,
+                                                Oscl_Vector< PVUuid, OsclMemAllocator >& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+
+        //Synchronous add-ons only for quering PVMFDataSourceInitializationExtensionInterface
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId,
+                int32 aPortTag,
+                const PvmfMimeString* aPortConfig = NULL,
+                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId,
+                PVMFPortInterface& aPort,
+                const OsclAny* aContext = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId,
+                                           const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId,
+                                              const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId,
+                                            const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId,
+                                           const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId,
+                                            const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId,
+                                            const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId,
+                                            const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId,
+                const OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId,
+                PVMFCommandId aCmdId,
+                const OsclAny* aContextData = NULL);
+
+        /* From PVMFPortActivityHandler */
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+
+        /* From PvmiCapabilityAndConfig */
+        virtual PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
+                PvmiKvp* aParameters,
+                int num_elements,
+                PvmiKvp*& aRet_kvp,
+                OsclAny* context = NULL);
+
+        //Pure virtual(s) from following classes should be implemented in feature specific derived classes
+        //(i)	 PVMFDataSourceInitializationExtensionInterface
+        //(ii)   PVMFTrackSelectionExtensionInterface
+
+        /* From PvmfDataSourcePlaybackControlInterface */
+        virtual PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId,
+                PVMFTimestamp aTargetNPT,
+                PVMFTimestamp& aActualNPT,
+                PVMFTimestamp& aActualMediaDataTS,
+                bool aSeekToSyncPoint = true,
+                uint32 aStreamID = 0,
+                OsclAny* aContext = NULL);
+
+        virtual PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId,
+                PVMFDataSourcePositionParams& aPVMFDataSourcePositionParams,
+                OsclAny* aContext = NULL);
+
+        virtual PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId,
+                PVMFTimestamp aTargetNPT,
+                PVMFTimestamp& aActualNPT,
+                bool aSeekToSyncPoint = true,
+                OsclAny* aContext = NULL);
+        virtual PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId,
+                PVMFTimestamp aTargetNPT,
+                PVMFTimestamp& aSyncBeforeTargetNPT,
+                PVMFTimestamp& aSyncAfterTargetNPT,
+                OsclAny* aContext = NULL,
+                bool aSeekToSyncPoint = true);
+        virtual PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId,
+                                                int32 aRate,
+                                                PVMFTimebase* aTimebase = NULL,
+                                                OsclAny* aContext = NULL);
+        //PvmfDataSourcePlaybackControlInterface::ComputeSkipTimeStamp is not supported
+        //in all streaming formats. So not overriding
+        //the base implementataion of returning PVMFErrNotSupported. FSP plugins can override
+        //if they so choose.
+
+        /* From PVMFMetadataExtensionInterface */
+        virtual uint32 GetNumMetadataKeysBase(char* aQueryKeyString = NULL);
+        virtual uint32 GetNumMetadataValuesBase(PVMFMetadataList& aKeyList);
+        virtual PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId,
+                PVMFMetadataList& aKeyList,
+                uint32 aStartingKeyIndex,
+                int32 aMaxKeyEntries = -1,
+                char* aQueryKeyString = NULL,
+                const OsclAny* aContextData = NULL);
+        virtual PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId,
+                PVMFMetadataList& aKeyList,
+                Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+                uint32 aStartingValueIndex,
+                int32 aMaxValueEntries = -1,
+                const OsclAny* aContextData = NULL);
+        PVMFStatus ReleaseNodeMetadataKeysBase(PVMFMetadataList& aKeyList,
+                                               uint32 aStartingKeyIndex,
+                                               uint32 aEndKeyIndex);
+        PVMFStatus ReleaseNodeMetadataValuesBase(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+                uint32 aStartingValueIndex,
+                uint32 aEndValueIndex);
+
+        /* From PVMFCPMPluginLicenseInterface */
+        virtual PVMFStatus GetLicenseURL(PVMFSessionId aSessionId,
+                                         OSCL_wString& aContentName,
+                                         OSCL_wString& aLicenseURL);
+        virtual PVMFStatus GetLicenseURL(PVMFSessionId aSessionId,
+                                         OSCL_String&  aContentName,
+                                         OSCL_String&  aLicenseURL);
+        virtual PVMFCommandId GetLicense(PVMFSessionId aSessionId
+                                         , OSCL_wString& aContentName
+                                         , OsclAny* aLicenseData = NULL
+                                                                   , uint32 aDataSize = 0
+                                                                                        , int32 aTimeoutMsec = (-1)
+                                                                                                               , OsclAny* aContext = NULL);
+        virtual PVMFCommandId GetLicense(PVMFSessionId aSessionId
+                                         , OSCL_String&  aContentName
+                                         , OsclAny* aLicenseData = NULL
+                                                                   , uint32 aDataSize = 0
+                                                                                        , int32 aTimeoutMsec = (-1)
+                                                                                                               , OsclAny* aContext = NULL);
+        virtual PVMFCommandId CancelGetLicense(PVMFSessionId aSessionId
+                                               , PVMFCommandId aCmdId
+                                               , OsclAny* aContext = NULL);
+        virtual PVMFStatus GetLicenseStatus(PVMFCPMLicenseStatus& aStatus);
+
+        /* From PVMFNodeErrorEventObserver */
+        virtual void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
+
+        //Pure virtual(s) from following classes should be implemented in feature specific derived classes
+        //(i)	 PVMFNodeInfoEventObserver
+        //(ii)   PVMFNodeCmdStatusObserver
+
+        //For streaming of protected content PVMFCPM plugin is required.
+        //Response of async commands executed on PVMFCPM will be notified by callback to func CPMCommandCompleted
+        virtual void CPMCommandCompleted(const PVMFCmdResp& aResponse);
+    protected:
+        PVMFSMFSPBaseNode(int32 aPriority);
+        //Second Phase ctor for allocating mem on heap
+        void Construct();
+
+        //Pure virtuals to be implemented in the derived classes
+        virtual bool ProcessCommand(PVMFSMFSPBaseNodeCommand&) = 0;	//FSP concrete implementation need to implement it.
+        virtual bool IsFSPInternalCmd(PVMFCommandId aId) = 0;
+        virtual void PopulateDRMInfo() = 0;
+        virtual bool RequestUsageComplete() = 0;
+
+        //For processing command Queues
+        void MoveCmdToCurrentQueue(PVMFSMFSPBaseNodeCommand& aCmd);
+        void MoveCmdToCancelQueue(PVMFSMFSPBaseNodeCommand& aCmd);
+        void MoveErrHandlingCmdToCurErrHandlingQ(PVMFSMFSPBaseNodeCommand& aCmd);
+
+        virtual PVMFCommandId QueueCommandL(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFCommandId QueueErrHandlingCommandL(PVMFSMFSPBaseNodeCommand& aCmd);
+
+        //Functions for reporting error event, info event and command completion
+        virtual void CommandComplete(PVMFFSPNodeCmdQ&,
+                                     PVMFSMFSPBaseNodeCommand&,
+                                     PVMFStatus,
+                                     OsclAny* aData = NULL,
+                                     PVUuid* aEventUUID = NULL,
+                                     int32* aEventCode = NULL,
+                                     PVInterface* aExtMsg = NULL,
+                                     uint32 aEventDataLen = 0);
+
+        void ReportErrorEvent(PVMFEventType aEventType,
+                              OsclAny* aEventData = NULL,
+                              PVUuid* aEventUUID = NULL,
+                              int32* aEventCode = NULL);
+        void ReportInfoEvent(PVMFEventType aEventType,
+                             OsclAny* aEventData = NULL,
+                             PVUuid* aEventUUID = NULL,
+                             int32* aEventCode = NULL);
+
+        //Utiliy funcions for internal commands handling
+        PVMFSMFSPCommandContext* RequestNewInternalCmd();
+        virtual void InternalCommandComplete(PVMFFSPNodeCmdQ&,
+                                             PVMFSMFSPBaseNodeCommand&,
+                                             PVMFStatus,
+                                             OsclAny* aData = NULL,
+                                             PVUuid* aEventUUID = NULL,
+                                             int32* aEventCode = NULL,
+                                             PVInterface* aExtMsg = NULL);
+        void ResetNodeContainerCmdState();
+
+        //Utility funct that can be called by derived class to populate available keys based on iMetaDataInfo
+        void PopulateAvailableMetadataKeys();
+
+        //PVMFNodeInterface
+        //To process Cancel command & CancelAll command
+        /**
+        * Assumption: When this function is called, cancel all command is present in the input Q.
+        *             Cancellion of the API's will be attempted till the point CancelAllCommand is issued.
+        *			  No attempt will be made to cancel any of the async command that are queued after
+        *			  making call to CancelAllCommand.
+        * Command completion status values:
+        *			  PVMFErrNoMemory, PVMFSuccess, PVMFFailure
+        */
+        virtual void DoCancelAllCommands(PVMFSMFSPBaseNodeCommand&);
+        void DoCancelAllPendingCommands(PVMFSMFSPBaseNodeCommand& aCmd);
+        void DoResetDueToErr(PVMFSMFSPBaseNodeCommand& aCmd);
+
+        /**
+        * Assumption: When this function is called, cancel all command is present in the input Q.
+        *             Cancellion of the API's will be attempted till the point CancelAllCommand is issued.
+        *			  No attempt will be made to cancel any of the async command that are queued after
+        *			  making call to CancelAllCommand.
+        * Command completion status values:
+        *			  PVMFErrNoMemory, PVMFSuccess, PVMFFailure
+        */
+        virtual void DoCancelCommand(PVMFSMFSPBaseNodeCommand&);
+
+        //Functions used to check if cancelcommand/cancelallcommand is complete
+        virtual void CompleteChildNodesCmdCancellation();
+        virtual bool CheckChildrenNodesCancelAll();
+
+        //To process Reset command
+        virtual void DoReset(PVMFSMFSPBaseNodeCommand&);
+        virtual void CompleteReset();
+        virtual bool CheckChildrenNodesReset();
+        void CompleteResetDueToErr();
+
+        //To process Flush command
+        virtual void DoFlush(PVMFSMFSPBaseNodeCommand&);
+        virtual void CompleteFlush();
+        virtual bool CheckChildrenNodesFlush();
+        virtual bool FlushPending();
+
+        //PVMFMetadataExtensionInterface
+        PVMFStatus DoGetMetadataKeysBase(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFStatus CompleteGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFStatus DoGetMetadataValuesBase(PVMFSMFSPBaseNodeCommand& aCmd);
+
+
+        PVMFStatus DoGetLicense(PVMFSMFSPBaseNodeCommand& aCmd,
+                                bool aWideCharVersion = false);
+        void DoCancelGetLicense(PVMFSMFSPBaseNodeCommand& aCmd);
+
+        void CompleteGetLicense();
+
+        //CPM related functions
+        void InitCPM();
+        void OpenCPMSession();
+        void CPMRegisterContent();
+        bool GetCPMContentAccessFactory();
+        bool GetCPMMetaDataExtensionInterface();
+        void GetCPMLicenseInterface();
+        void GetCPMCapConfigInterface();
+        bool SetCPMKvps();
+        void RequestUsage();
+        void SendUsageComplete();
+        void CloseCPMSession();
+        void ResetCPM();
+        void GetCPMMetaDataKeys();
+        void GetCPMMetaDataValues();
+        void CompleteGetMetaDataValues();
+        void CompleteDRMInit();
+
+        PVMFStatus CheckCPMCommandCompleteStatus(PVMFCommandId aID, PVMFStatus aStatus);
+
+        void GetActualMediaTSAfterSeek();
+        virtual bool IsFatalErrorEvent(const PVMFEventType& event);
+        PVMFSMFSPChildNodeContainer* getChildNodeContainer(int32 tag);
+        virtual void ResetNodeParams(bool aReleaseMemmory = true);
+
+        uint32	iNoOfValuesIteratedForValueVect;
+        uint32	iNoOfValuesPushedInValueVect;
+
+        PVMFNodeCapability iCapability;
+
+        bool iRepositioning;
+        PVMFTimestamp iRepositionRequestedStartNPTInMS;
+        PVMFTimestamp iActualRepositionStartNPTInMS;
+        PVMFTimestamp* iActualRepositionStartNPTInMSPtr;
+        PVMFTimestamp iActualMediaDataTS;
+        PVMFTimestamp* iActualMediaDataTSPtr;
+        bool iJumpToIFrame;
+
+
+        /* Session start & stop times */
+        uint32 iSessionStartTime;
+        uint32 iSessionStopTime;
+        bool   iSessionStopTimeAvailable;
+        bool   iSessionSeekAvailable;
+
+        bool iPlaylistPlayInProgress;
+
+        PVMFDataSourcePositionParams* iPVMFDataSourcePositionParamsPtr;
+        uint32 iStreamID;
+        bool iPlayListRepositioning;
+        bool iPlayListRepositioningSupported;
+        bool iGraphConstructComplete;
+        bool iGraphConnectComplete;
+        uint32 iNumRequestPortsPending;
+        uint32 iTotalNumRequestPortsComplete;
+        //Filled on completion of init
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iCPMMetadataKeys;
+        PVMFSMSessionMetaDataInfo* iMetaDataInfo;
+
+        PVMFStatus GetIndexParamValues(char* aString, uint32& aStartIndex, uint32& aEndIndex);
+        PVMFStatus GetMaxSizeValue(char* aString, uint32& aMaxSize);
+        PVMFStatus GetTruncateFlagValue(char* aString, uint32& aTruncateFlag);
+
+        //CPM related
+        bool iPreviewMode;
+        bool iUseCPMPluginRegistry;
+        bool iDRMResetPending;
+        bool iCPMInitPending;
+        uint32 maxPacketSize;
+        uint32 iPVMFStreamingManagerNodeMetadataValueCount;
+        PVMFStreamingDataSource iCPMSourceData;
+        PVMFSourceContextData iSourceContextData;
+        bool iSourceContextDataValid;
+        PVMFCPM* iCPM;
+        PVMFSessionId iCPMSessionID;
+        PVMFCPMContentType iCPMContentType;
+        PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
+        PVMFCPMPluginAccessUnitDecryptionInterface* iDecryptionInterface;
+        PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
+        PVInterface* iCPMLicenseInterfacePVI;
+        PvmiCapabilityAndConfig* iCPMCapConfigInterface;
+        PVInterface* iCPMCapConfigInterfacePVI;
+        PVMFSMNodeKVPStore iCPMKvpStore;
+        PvmiKvp iRequestedUsage;
+        PvmiKvp iApprovedUsage;
+        PvmiKvp iAuthorizationDataKvp;
+        PVMFCPMUsageID iUsageID;
+        PVMFCommandId iCPMInitCmdId;
+        PVMFCommandId iCPMOpenSessionCmdId;
+        PVMFCommandId iCPMRegisterContentCmdId;
+        PVMFCommandId iCPMRequestUsageId;
+        PVMFCommandId iCPMUsageCompleteCmdId;
+        PVMFCommandId iCPMCloseSessionCmdId;
+        PVMFCommandId iCPMResetCmdId;
+        PVMFCommandId iCPMGetMetaDataKeysCmdId;
+        PVMFCommandId iCPMGetMetaDataValuesCmdId;
+        PVMFCommandId iCPMGetLicenseInterfaceCmdId;
+        PVMFCommandId iCPMGetLicenseCmdId;
+        PVMFCommandId iCPMGetCapConfigCmdId;
+        PVMFCommandId iCPMCancelGetLicenseCmdId;
+        PVMFStatus iCPMRequestUsageCommandStatus;
+
+        PVMFFSPNodeCmdQ iInputCommands;
+        PVMFFSPNodeCmdQ iCurrentCommand;
+        PVMFFSPNodeCmdQ iCancelCommand;
+        PVMFFSPNodeCmdQ iErrHandlingCommandQ;
+        PVMFFSPNodeCmdQ iCurrErrHandlingCommand;
+
+        PVMFSMFSPCommandContext iInternalCmdPool[PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE];
+
+        PVMFSMFSPChildNodeContainerVector  iFSPChildNodeContainerVec;
+        PVMFSMFSPSessionSourceInfo* iSessionSourceInfo;
+
+        PVLogger *iCommandSeqLogger;
+        PVLogger *iLogger;
+        PVLogger * iSMBaseLogger;
+
+        //For Error handling
+        void HandleError(const PVMFCmdResp& aResponse);
+        void ErrHandlingComplete(const PVMFSMFSPBaseNodeCommand* aErroneousCmd = NULL);
+
+        //For pushing data to vect
+        PVMFStatus PushKeyToMetadataList(PVMFMetadataList* aMetaDataListPtr, const OSCL_HeapString<OsclMemAllocator> & aKey)const;
+        PVMFStatus PushKVPToMetadataValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, const PvmiKvp& aKVP)const;
+        PVMFStatus SetCPMKvp(PvmiKvp& aKVP);
+        void CleanUp();
+        uint8* GetMemoryChunk(OsclMemAllocDestructDealloc<uint8>& aAllocator, const uint32 aChunkSize)
+        {
+            int32 leaveCode = 0;
+            uint8* memChunk = NULL;
+            OSCL_TRY(leaveCode,
+                     memChunk = OSCL_STATIC_CAST(uint8*, aAllocator.ALLOCATE(aChunkSize)));
+            if (leaveCode != OsclErrNone)
+            {
+                PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::GetMemoryChunk - Error Memory Allocation failed"));
+            }
+            return memChunk;
+        }
+
+        bool SupressInfoEvent();
+
+
+    private:
+        PVMFSMFSPChildNodeErrorHandler* iChildNodeErrHandler;
+        OSCL_IMPORT_REF PVMFSessionId Connect(const PVMFNodeSessionInfo &aSessionInfo);
+        /* From OsclActiveObject */
+        void Run();
+        void DoCancel();
+
+        void CleanupCPMdata();
+        void CreateCommandQueues();
+        virtual bool IsInternalCmd(PVMFCommandId aId);
+
+        void ResetCPMParams(bool aReleaseMem = true);
+        bool ErrorHandlingRequired(PVMFStatus aStatus);
+
+        //CPM related
+        PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
+};
+
+//This class does error handling only for the errors issued by child nodes of SM node.
+//For handling errors generated by CPM plugin we rely on engine to do err handling.
+class PVMFSMFSPChildNodeErrorHandler
+{
+    public:
+        PVMFSMFSPChildNodeErrorHandler(PVMFSMFSPBaseNode * aFSPBaseNode): iCmdResponse(NULL)
+                , iAsyncEvent(NULL)
+                , iErroneousCmdResponse(NULL)
+                , iErrCmd(NULL)
+                , iErrSource(SMFSP_ERR_SOURCE_INDETERMINATE)
+                , iState(SMFSP_ERRHANDLER_IDLE)
+                , iSMFSPNode(aFSPBaseNode)
+                , iLogger(NULL)
+        {
+
+        }
+
+        void Construct()
+        {
+            iLogger = PVLogger::GetLoggerObject("PVMFSMFSPChildNodeErrorHandler");
+        }
+        static PVMFSMFSPChildNodeErrorHandler* CreateErrHandler(PVMFSMFSPBaseNode* aFSPBaseNode);
+        static void DeleteErrHandler(PVMFSMFSPChildNodeErrorHandler*& aErrHandler);
+        void InitiateErrorHandling(const PVMFCmdResp& aCmdResponse);
+        void InitiateErrorHandling(const PVMFAsyncEvent& aAsyncEvent);
+        void CompleteErrorHandling(const PVMFCmdResp& aResponse);
+        bool IsErrorHandlingComplete() const
+        {
+            return (SMFSP_ERRHANDLER_IDLE == iState);
+        }
+        void Reset();
+        const PVMFCmdResp* GetErroneousCmdResponse();
+        const PVMFAsyncEvent* GetAsyncErrEvent();
+        void ErrHandlingCommandComplete(PVMFFSPNodeCmdQ&,
+                                        PVMFSMFSPBaseNodeCommand&,
+                                        PVMFStatus,
+                                        OsclAny* aData = NULL,
+                                        PVUuid* aEventUUID = NULL,
+                                        int32* aEventCode = NULL,
+                                        PVInterface* aExtMsg = NULL);
+    private:
+        void SaveErrorInfo(const PVMFCmdResp& aCmdResponse);
+        void SaveErrorInfo(const PVMFAsyncEvent& aAsyncEvent);
+        void PerformErrorHandling();
+        void ContinueChildNodesCmdCancellation();
+        void CompleteChildNodesCmdCancellationDueToErr();
+        void CompleteChildNodesResetDueToError();
+
+        enum SMFSPErrorSource
+        {
+            SMFSP_ERR_SOURCE_INDETERMINATE,
+            SMFSP_ERR_SOURCE_EVENT,
+            SMFSP_ERR_SOURCE_NODE_CMD_COMPLETION
+        };
+
+        enum SMFSPChildNodeErrorHandlerState
+        {
+            SMFSP_ERRHANDLER_IDLE,
+            SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_COMPLETION,	//when er occurs for cancel command we do not queue cancel due to err
+            SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_DUE_TO_ERR_COMPLETION,
+            SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION
+        };
+
+        PVMFCmdResp *iCmdResponse;
+        PVMFAsyncEvent *iAsyncEvent;
+        PVMFCmdResp *iErroneousCmdResponse;
+        PVMFSMFSPBaseNodeCommand* iErrCmd;
+        SMFSPErrorSource iErrSource;
+        SMFSPChildNodeErrorHandlerState iState;
+        PVMFSMFSPBaseNode * iSMFSPNode;
+        PVLogger *iLogger;
+};
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_metadata.h b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_metadata.h
new file mode 100644
index 0000000..aaedcec
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_metadata.h
@@ -0,0 +1,317 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
+#define PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
+
+#ifndef COMMONINFO_H
+#include "common_info.h"
+#endif
+
+// Number of metadata keys supported in this node.
+#define PVMFSTREAMINGMGRNODE_NUM_METADATAKEYS 16
+// Constant character strings for metadata keys
+//Common to all streaming sessions
+static const char PVMFSTREAMINGMGRNODE_ALBUM_KEY[] = "album";
+static const char PVMFSTREAMINGMGRNODE_AUTHOR_KEY[] = "author";
+static const char PVMFSTREAMINGMGRNODE_ARTIST_KEY[] = "artist";
+static const char PVMFSTREAMINGMGRNODE_TITLE_KEY[] = "title";
+static const char PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY[] = "description";
+static const char PVMFSTREAMINGMGRNODE_RATING_KEY[] = "rating";
+static const char PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY[] = "copyright";
+static const char PVMFSTREAMINGMGRNODE_GENRE_KEY[] = "genre";
+static const char PVMFSTREAMINGMGRNODE_LYRICS_KEY[] = "lyrics";
+static const char PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY[] = "classification";
+static const char PVMFSTREAMINGMGRNODE_KEYWORDS_KEY[] = "keywords";
+static const char PVMFSTREAMINGMGRNODE_LOCATION_KEY[] = "location;format=3GPP_LOCATION";
+static const char PVMFSTREAMINGMGRNODE_DURATION_KEY[] = "duration";
+static const char PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY[] = "num-tracks";
+static const char PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY[] = "random-access-denied";
+static const char PVMFSTREAMINGMGRNODE_YEAR_KEY[] = "year";
+static const char PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY[] = "graphic/num-frames;format=APIC";
+static const char PVMFSTREAMINGMGRNODE_GRAPHICS_KEY[] = "graphic;format=APIC";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY[] = "track-info/type";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY[] = "track-info/duration";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY[] = "track-info/selected";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY[] = "track-info/video/width";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY[] = "track-info/video/height";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY[] = "track-info/sample-rate";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY[] = "track-info/audio/channels";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY[] = "track-info/audio/bits-per-sample";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY[] = "track-info/track-id";
+
+static const char PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY[] = "clip-type";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY[] = "track-info/frame-rate";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY[] = "track-info/codec-name";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY[] = "track-info/codec-description";
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY[] = "track-info/codec-specific-info";
+
+//PVMF_DRM_INFO_IS_PROTECTED_QUERY
+
+//Extended metadata [FF specific]
+
+//Streaming specific metadata keys
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY[] = "track-info/bit-rate";			//RTSP Specific
+static const char PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY[] = "pause-denied";						//RTSP Unicast Specific
+static const char PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY[] = "track-info/max-bitrate";	//HTTP streaming Specific
+
+///////////////////////////////////////////////////////////////////////////////
+static const char PVMFSTREAMINGMGRNODE_SEMICOLON[] = ";";
+static const char PVMFSTREAMINGMGRNODE_TIMESCALE[] = "timescale=";
+static const char PVMFSTREAMINGMGRNODE_INDEX[] = "index=";
+static const char PVMFSTREAMINGMGRNODE_MAXSIZE[] = "maxsize=";
+static const char PVMFSTREAMINGMGRNODE_REQSIZE[] = "reqsize=";
+static const char PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG[] = "truncate=";
+
+static const unsigned int RELIABLE_BURST_PVSS_VER = 5; /* It was found that only PVSS version 5 does reliable burst streaming */
+
+///////////////////////////////////////////////////////////////////////////////
+//Datastructures to store metadata info
+///////////////////////////////////////////////////////////////////////////////
+class PVMFSMTrackMetaDataInfo
+{
+    public:
+        PVMFSMTrackMetaDataInfo()
+        {
+            iTrackDurationAvailable = false;
+            iTrackDuration = 0;
+            iTrackDurationTimeScale = 0;
+            iTrackBitRate = 0;
+            iTrackMaxBitRate = 0;
+            iTrackSelected = false;
+            iTrackID = iTrackID;
+            iCodecName = NULL;
+            iCodecDescription = NULL;
+            iTrackWidth = 0;
+            iTrackHeight = 0;
+            iVideoFrameRate = 0;
+            iAudioSampleRate = 0;
+            iAudioNumChannels = 0;
+            iAudioBitsPerSample = 0;
+        };
+
+        PVMFSMTrackMetaDataInfo(const PVMFSMTrackMetaDataInfo& a)
+        {
+            iTrackDurationAvailable = a.iTrackDurationAvailable;
+            iTrackDuration = a.iTrackDuration;
+            iTrackDurationTimeScale = a.iTrackDurationTimeScale;
+            iMimeType = a.iMimeType;
+            iTrackBitRate = a.iTrackBitRate;
+            iTrackMaxBitRate = a.iTrackMaxBitRate;
+            iTrackSelected = a.iTrackSelected;
+            iTrackID = a.iTrackID;
+            iCodecName = a.iCodecName;
+            iCodecDescription = a.iCodecDescription;
+            iCodecSpecificInfo = a.iCodecSpecificInfo;
+            iTrackWidth = a.iTrackWidth;
+            iTrackHeight = a.iTrackHeight;
+            iVideoFrameRate = a.iVideoFrameRate;
+            iAudioSampleRate = a.iAudioSampleRate;
+            iAudioNumChannels = a.iAudioNumChannels;
+            iAudioBitsPerSample = a.iAudioBitsPerSample;
+        };
+
+        PVMFSMTrackMetaDataInfo& operator=(const PVMFSMTrackMetaDataInfo& a)
+        {
+            if (&a != this)
+            {
+                iTrackDurationAvailable = a.iTrackDurationAvailable;
+                iTrackDuration = a.iTrackDuration;
+                iTrackDurationTimeScale = a.iTrackDurationTimeScale;
+                iMimeType = a.iMimeType;
+                iTrackBitRate = a.iTrackBitRate;
+                iTrackMaxBitRate = a.iTrackMaxBitRate;
+                iTrackSelected = a.iTrackSelected;
+                iTrackID = a.iTrackID;
+                iCodecName = a.iCodecName;
+                iCodecDescription = a.iCodecDescription;
+                iCodecSpecificInfo = a.iCodecSpecificInfo;
+                iTrackWidth = a.iTrackWidth;
+                iTrackHeight = a.iTrackHeight;
+                iVideoFrameRate = a.iVideoFrameRate;
+                iAudioSampleRate = a.iAudioSampleRate;
+                iAudioNumChannels = a.iAudioNumChannels;
+                iAudioBitsPerSample = a.iAudioBitsPerSample;
+            }
+            return (*this);
+        };
+
+        bool   iTrackDurationAvailable;
+        uint64 iTrackDuration;
+        uint64 iTrackDurationTimeScale;
+        OSCL_HeapString<OsclMemAllocator> iMimeType;
+        uint32 iTrackBitRate;
+        uint32 iTrackMaxBitRate;
+        bool   iTrackSelected;
+        uint32 iTrackID;
+        OSCL_wHeapString<OsclMemAllocator> iCodecName;
+        OSCL_wHeapString<OsclMemAllocator> iCodecDescription;
+        uint32 iTrackWidth;
+        uint32 iTrackHeight;
+        uint32 iVideoFrameRate;
+        uint32 iAudioSampleRate;
+        uint32 iAudioNumChannels;
+        uint32 iAudioBitsPerSample;
+        OsclRefCounterMemFrag iCodecSpecificInfo;
+};
+
+class PVMFSMSessionMetaDataInfo
+{
+    public:
+        PVMFSMSessionMetaDataInfo()
+        {
+            Reset();
+        };
+
+        void Reset()
+        {
+            iMetadataAvailable = false;
+            iTitlePresent = false;
+            iDescriptionPresent = false;
+            iCopyRightPresent = false;
+            iPerformerPresent = false;
+            iAuthorPresent = false;
+            iGenrePresent = false;
+            iRatingPresent = false;
+            iClassificationPresent = false;
+            iKeyWordsPresent = false;
+            iLocationPresent = false;
+            iLyricsPresent = false;
+            iWMPicturePresent = false;
+            iAlbumPresent = false;
+
+            iIsTitleUnicode = false;
+            iIsDescriptionUnicode = false;
+            iIsCopyRightUnicode = false;
+            iIsPerformerUnicode = false;
+            iIsAuthorUnicode = false;
+            iIsGenreUnicode = false;
+            iIsRatingUnicode = false;
+            iIsClassificationUnicode = false;
+            iIsKeyWordsUnicode = false;
+            iIsLocationUnicode = false;
+            iIsLyricsUnicode = false;
+            iIsAlbumUnicode = false;
+
+            iSessionDurationAvailable = false;
+            iSessionDuration = 0;
+            iSessionDurationTimeScale = 0;
+            iNumTracks = 0;
+            iRandomAccessDenied = false;
+            iNumWMPicture = 0;
+
+            iExtendedMetaDataDescriptorCount = 0;
+            iExtendedMetaDataNameVec.clear();
+            iExtendedMetaDataValueTypeVec.clear();
+            iExtendedMetaDataValueLenVec.clear();
+            iExtendedMetaDataIndexVec.clear();
+
+            iTrackMetaDataInfoVec.clear();
+
+            iNumKeyWords = 0;
+            iYear = 0;
+        };
+
+        PVMFSMTrackMetaDataInfo* getTrackMetaDataInfo(uint32 aId)
+        {
+            Oscl_Vector<PVMFSMTrackMetaDataInfo, OsclMemAllocator>::iterator it;
+            for (it = iTrackMetaDataInfoVec.begin(); it != iTrackMetaDataInfoVec.end(); it++)
+            {
+                if (it->iTrackID == aId)
+                {
+                    return (it);
+                }
+            }
+            return NULL;
+        };
+
+        bool iTitlePresent;
+        bool iDescriptionPresent;
+        bool iCopyRightPresent;
+        bool iPerformerPresent;
+        bool iAuthorPresent;
+        bool iGenrePresent;
+        bool iRatingPresent;
+        bool iClassificationPresent;
+        bool iKeyWordsPresent;
+        bool iLocationPresent;
+        bool iLyricsPresent;
+        bool iWMPicturePresent;
+        bool iAlbumPresent;
+
+        bool iIsTitleUnicode;
+        bool iIsDescriptionUnicode;
+        bool iIsCopyRightUnicode;
+        bool iIsPerformerUnicode;
+        bool iIsAuthorUnicode;
+        bool iIsGenreUnicode;
+        bool iIsRatingUnicode;
+        bool iIsClassificationUnicode;
+        bool iIsKeyWordsUnicode;
+        bool iIsLocationUnicode;
+        bool iIsLyricsUnicode;
+        bool iIsAlbumUnicode;
+        uint32 iNumWMPicture;
+
+        OSCL_HeapString<OsclMemAllocator> iTitle;
+        OSCL_HeapString<OsclMemAllocator> iDescription;
+        OSCL_HeapString<OsclMemAllocator> iCopyright;
+        OSCL_HeapString<OsclMemAllocator> iPerformer;
+        OSCL_HeapString<OsclMemAllocator> iAuthor;
+        OSCL_HeapString<OsclMemAllocator> iGenre;
+        OSCL_HeapString<OsclMemAllocator> iRating;
+        OSCL_HeapString<OsclMemAllocator> iClassification;
+        uint32 iNumKeyWords;
+        OSCL_HeapString<OsclMemAllocator> iKeyWords[MAX_ASSET_INFO_KEYWORDS];
+        OSCL_HeapString<OsclMemAllocator> iLyrics;
+        OSCL_HeapString<OsclMemAllocator> iAlbum;
+
+        OSCL_wHeapString<OsclMemAllocator> iTitleUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iDescriptionUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iCopyrightUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iPerformerUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iAuthorUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iGenreUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iRatingUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iClassificationUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iKeyWordUnicode[MAX_ASSET_INFO_KEYWORDS];
+        OSCL_wHeapString<OsclMemAllocator> iLyricsUnicode;
+        OSCL_wHeapString<OsclMemAllocator> iAlbumUnicode;
+
+        uint32 iYear;
+        bool   iSessionDurationAvailable;
+        uint64 iSessionDuration;
+        uint64 iSessionDurationTimeScale;
+        uint32 iNumTracks;
+        bool   iRandomAccessDenied;
+        PvmfAssetInfo3GPPLocationStruct iLocationStruct;
+
+        Oscl_Vector<PVMFSMTrackMetaDataInfo, OsclMemAllocator> iTrackMetaDataInfoVec;
+
+        uint32 iExtendedMetaDataDescriptorCount;
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iExtendedMetaDataNameVec;
+        Oscl_Vector<uint16, OsclMemAllocator> iExtendedMetaDataValueTypeVec;
+        Oscl_Vector<uint32, OsclMemAllocator> iExtendedMetaDataValueLenVec;
+        Oscl_Vector<uint32, OsclMemAllocator> iExtendedMetaDataIndexVec;
+        Oscl_Vector<uint32, OsclMemAllocator> iWMPictureIndexVec;
+
+        bool iMetadataAvailable;
+};
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_types.h b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_types.h
new file mode 100644
index 0000000..9b23790
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_base_types.h
@@ -0,0 +1,567 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_BASE_TYPES_H_INCLUDED
+#define PVMF_SM_FSP_BASE_TYPES_H_INCLUDED
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+class PVMFDataSourcePositionParams;
+class PVMFTimebase;
+/*
+ * Structure to contain a node and all ports and extensions associated to it
+ */
+enum PVMFSMFSPChildNodeCmdState
+{
+    PVMFSMFSP_NODE_CMD_IDLE,
+    PVMFSMFSP_NODE_CMD_PENDING,
+    PVMFSMFSP_NODE_CMD_CANCEL_PENDING
+};
+
+typedef PVMFGenericNodeCommand <OsclMemAllocator> PVMFSMFSPBaseNodeCommandBase;
+class PVMFSMFSPBaseNodeCommand : public PVMFSMFSPBaseNodeCommandBase
+{
+    public:
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       int32 arg1,
+                       int32 arg2,
+                       int32& arg3,
+                       const OsclAny*aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)arg1;
+            iParam2 = (OsclAny*)arg2;
+            iParam3 = (OsclAny*) & arg3;
+        }
+
+        void Parse(int32&arg1, int32&arg2, int32*&arg3)
+        {
+            arg1 = (int32)iParam1;
+            arg2 = (int32)iParam2;
+            arg3 = (int32*)iParam3;
+        }
+
+        /* Constructor and parser for SetDataSourcePosition */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       PVMFTimestamp aTargetNPT,
+                       PVMFTimestamp* aActualNPT,
+                       PVMFTimestamp* aActualMediaDataTS,
+                       bool aSeekToSyncPoint,
+                       uint32 aStreamID,
+                       const OsclAny*aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aTargetNPT;
+            iParam2 = (OsclAny*)aActualNPT;
+            iParam3 = (OsclAny*)aActualMediaDataTS;
+            iParam4 = (OsclAny*)aSeekToSyncPoint;
+            iParam5 = (OsclAny*)aStreamID;
+        }
+
+        void Parse(PVMFTimestamp& aTargetNPT,
+                   PVMFTimestamp* &aActualNPT,
+                   PVMFTimestamp* &aActualMediaDataTS,
+                   bool& aSeekToSyncPoint,
+                   uint32& aStreamID)
+        {
+            aTargetNPT = (PVMFTimestamp)iParam1;
+            aActualNPT = (PVMFTimestamp*)iParam2;
+            aActualMediaDataTS = (PVMFTimestamp*)iParam3;
+            aSeekToSyncPoint = (iParam4 ? true : false);
+            aStreamID = (uint32)iParam5;
+        }
+
+        /* Constructor and parser for SetDataSourcePosition - Playlist */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       PVMFDataSourcePositionParams* aParams,
+                       const OsclAny*aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aParams;
+            iParam2 = NULL;
+            iParam3 = NULL;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        }
+
+        void Parse(PVMFDataSourcePositionParams*& aParams)
+        {
+            aParams = (PVMFDataSourcePositionParams*)iParam1;
+        }
+
+
+        /* Constructor and parser for QueryDataSourcePosition */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       PVMFTimestamp aTargetNPT,
+                       PVMFTimestamp* aActualNPT,
+                       bool aSeekToSyncPoint,
+                       const OsclAny*aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aTargetNPT;
+            iParam2 = (OsclAny*)aActualNPT;
+            iParam3 = (OsclAny*)aSeekToSyncPoint;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        }
+
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       PVMFTimestamp aTargetNPT,
+                       PVMFTimestamp* aSeekPointBeforeTargetNPT,
+                       PVMFTimestamp* aSeekPointAfterTargetNPT,
+                       const OsclAny*aContext,
+                       bool aSeekToSyncPoint
+                      )
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aTargetNPT;
+            iParam3 = (OsclAny*)aSeekToSyncPoint;
+            iParam4 = aSeekPointBeforeTargetNPT;
+            iParam5 = aSeekPointAfterTargetNPT;
+        }
+
+        void Parse(PVMFTimestamp& aTargetNPT,
+                   PVMFTimestamp* &aActualNPT,
+                   bool& aSeekToSyncPoint)
+        {
+            aTargetNPT = (PVMFTimestamp)iParam1;
+            aActualNPT = (PVMFTimestamp*)iParam2;
+            aSeekToSyncPoint = (iParam3 ? true : false);
+        }
+
+        void Parse(PVMFTimestamp& aTargetNPT,
+                   PVMFTimestamp*& aSeekPointBeforeTargetNPT,
+                   bool& aSeekToSyncPoint,
+                   PVMFTimestamp*& aSeekPointAfterTargetNPT)
+
+        {
+            aTargetNPT = (PVMFTimestamp)iParam1;
+            aSeekToSyncPoint = (iParam3) ? true : false;
+            aSeekPointBeforeTargetNPT = (PVMFTimestamp*)iParam4;
+            aSeekPointAfterTargetNPT = (PVMFTimestamp*)iParam5;
+        }
+
+
+        /* Constructor and parser for SetDataSourceRate */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       int32 aRate,
+                       PVMFTimebase* aTimebase,
+                       const OsclAny* aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aRate;
+            iParam2 = (OsclAny*)aTimebase;
+            iParam3 = NULL;
+            iParam4 = NULL;
+            iParam5 = NULL;
+        };
+
+        void Parse(int32& aRate, PVMFTimebase*& aTimebase)
+        {
+            aRate = (int32)iParam1;
+            aTimebase = (PVMFTimebase*)iParam2;
+        }
+
+        /* Constructor and parser for GetNodeMetadataKeys */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       PVMFMetadataList& aKeyList,
+                       int32 aStartingIndex,
+                       int32 aMaxEntries,
+                       char* aQueryKey,
+                       const OsclAny* aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*) & aKeyList;
+            iParam2 = (OsclAny*)aStartingIndex;
+            iParam3 = (OsclAny*)aMaxEntries;
+            if (aQueryKey)
+            {
+                /*allocate a copy of the query key string */
+                Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
+                iParam4 = str.ALLOC_AND_CONSTRUCT(aQueryKey);
+            }
+        }
+
+        void Parse(PVMFMetadataList*& MetaDataListPtr,
+                   uint32 &aStartingIndex,
+                   int32 &aMaxEntries,
+                   char*& aQueryKey)
+        {
+            MetaDataListPtr = (PVMFMetadataList*)iParam1;
+            aStartingIndex = (uint32)iParam2;
+            aMaxEntries = (int32)iParam3;
+            aQueryKey = NULL;
+            if (iParam4)
+            {
+                OSCL_HeapString<OsclMemAllocator>* keystring =
+                    (OSCL_HeapString<OsclMemAllocator>*)iParam4;
+                aQueryKey = keystring->get_str();
+            }
+        }
+
+        /* Constructor and parser for GetNodeMetadataValue */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       PVMFMetadataList& aKeyList,
+                       Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+                       uint32 aStartIndex,
+                       int32 aMaxEntries,
+                       const OsclAny* aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*) & aKeyList;
+            iParam2 = (OsclAny*) & aValueList;
+            iParam3 = (OsclAny*)aStartIndex;
+            iParam4 = (OsclAny*)aMaxEntries;
+
+        }
+
+        void Parse(PVMFMetadataList* &aKeyList,
+                   Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList,
+                   uint32 &aStartingIndex,
+                   int32 &aMaxEntries)
+        {
+            aKeyList = (PVMFMetadataList*)iParam1;
+            aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
+            aStartingIndex = (uint32)iParam3;
+            aMaxEntries = (int32)iParam4;
+        }
+
+        /* Constructor and parser for GetLicenseW */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       OSCL_wString& aContentName,
+                       OsclAny* aLicenseData,
+                       uint32 aDataSize,
+                       int32 aTimeoutMsec,
+                       const OsclAny* aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*) & aContentName;
+            iParam2 = (OsclAny*)aLicenseData;
+            iParam3 = (OsclAny*)aDataSize;
+            iParam4 = (OsclAny*)aTimeoutMsec;
+            iParam5 = NULL;
+        }
+
+        void Parse(OSCL_wString*& aContentName,
+                   OsclAny*& aLicenseData,
+                   uint32& aDataSize,
+                   int32& aTimeoutMsec)
+        {
+            aContentName = (OSCL_wString*)iParam1;
+            aLicenseData = (PVMFTimestamp*)iParam2;
+            aDataSize = (uint32)iParam3;
+            aTimeoutMsec = (int32)iParam4;
+        }
+
+        /* Constructor and parser for GetLicense */
+        void Construct(PVMFSessionId s,
+                       int32 cmd,
+                       OSCL_String& aContentName,
+                       OsclAny* aLicenseData,
+                       uint32 aDataSize,
+                       int32 aTimeoutMsec,
+                       const OsclAny*aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*) & aContentName;
+            iParam2 = (OsclAny*)aLicenseData;
+            iParam3 = (OsclAny*)aDataSize;
+            iParam4 = (OsclAny*)aTimeoutMsec;
+            iParam5 = NULL;
+        };
+        void Parse(OSCL_String*& aContentName,
+                   OsclAny*& aLicenseData,
+                   uint32& aDataSize,
+                   int32& aTimeoutMsec)
+        {
+            aContentName = (OSCL_String*)iParam1;
+            aLicenseData = (PVMFTimestamp*)iParam2;
+            aDataSize = (uint32)iParam3;
+            aTimeoutMsec = (int32)iParam4;
+        }
+
+        /* Constructor and parser for setParametersAsync */
+        void Construct(PVMFSessionId s, int32 cmd, PvmiMIOSession aSession,
+                       PvmiKvp* aParameters, int num_elements,
+                       PvmiKvp*& aRet_kvp, OsclAny* aContext)
+        {
+            PVMFSMFSPBaseNodeCommandBase::Construct(s, cmd, aContext);
+            iParam1 = (OsclAny*)aSession;
+            iParam2 = (OsclAny*)aParameters;
+            iParam3 = (OsclAny*)num_elements;
+            iParam4 = (OsclAny*) & aRet_kvp;
+        }
+        void Parse(PvmiMIOSession& aSession, PvmiKvp*& aParameters,
+                   int &num_elements, PvmiKvp** &ppRet_kvp)
+        {
+            aSession = (PvmiMIOSession)iParam1;
+            aParameters = (PvmiKvp*)iParam2;
+            num_elements = (int)iParam3;
+            ppRet_kvp = (PvmiKvp**)iParam4;
+        }
+
+        virtual bool hipri()
+        {
+            return ((PVMF_GENERIC_NODE_CANCELALLCOMMANDS == iCmd)
+                    || (PVMF_GENERIC_NODE_CANCELCOMMAND == iCmd));
+        }
+        /* need to overlaod the base Copy routine to copy metadata key */
+        void Copy(const PVMFGenericNodeCommand<OsclMemAllocator>& aCmd);
+
+        /* need to overlaod the base Destroy routine to cleanup metadata key */
+        void Destroy();
+};
+
+class PVMFSMFSPChildNodeContainer
+{
+    public:
+        PVMFSMFSPChildNodeContainer()
+        {
+            commandStartOffset = 0;
+            iNode = NULL;
+            iNodeTag = 0;
+            iSessionId = 0;
+            iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            iNumRequestPortsPending = 0;
+            iAutoPaused = false;
+        };
+
+        PVMFSMFSPChildNodeContainer(const PVMFSMFSPChildNodeContainer& aNodeContainer)
+        {
+            commandStartOffset = aNodeContainer.commandStartOffset;
+            iNode = aNodeContainer.iNode;
+            iNodeTag = aNodeContainer.iNodeTag;
+            iSessionId = aNodeContainer.iSessionId;
+            iNodeCmdState = aNodeContainer.iNodeCmdState;
+            iNumRequestPortsPending = aNodeContainer.iNumRequestPortsPending;
+            iAutoPaused = aNodeContainer.iAutoPaused;
+            iInputPorts = aNodeContainer.iInputPorts;
+            iOutputPorts = aNodeContainer.iOutputPorts;
+            iFeedBackPorts = aNodeContainer.iFeedBackPorts;
+            iExtensions = aNodeContainer.iExtensions;
+            iExtensionUuids = aNodeContainer.iExtensionUuids;
+        }
+
+        PVMFSMFSPChildNodeContainer& operator=(const PVMFSMFSPChildNodeContainer& aNodeContainer)
+        {
+            if (&aNodeContainer != this)
+            {
+                commandStartOffset = aNodeContainer.commandStartOffset;
+                iNode = aNodeContainer.iNode;
+                iNodeTag = aNodeContainer.iNodeTag;
+                iSessionId = aNodeContainer.iSessionId;
+                iNodeCmdState = aNodeContainer.iNodeCmdState;
+                iNumRequestPortsPending = aNodeContainer.iNumRequestPortsPending;
+                iAutoPaused = aNodeContainer.iAutoPaused;
+                iInputPorts = aNodeContainer.iInputPorts;
+                iOutputPorts = aNodeContainer.iOutputPorts;
+                iFeedBackPorts = aNodeContainer.iFeedBackPorts;
+                iExtensions = aNodeContainer.iExtensions;
+                iExtensionUuids = aNodeContainer.iExtensionUuids;
+            }
+            return *this;
+        }
+
+        virtual ~PVMFSMFSPChildNodeContainer() {};
+
+        void Reset()
+        {
+            commandStartOffset = 0;
+            iNode = NULL;
+            iNodeTag = 0;
+            iSessionId = 0;
+            iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            iNumRequestPortsPending = 0;
+            iAutoPaused = false;
+            iInputPorts.clear();
+            iOutputPorts.clear();
+            iFeedBackPorts.clear();
+            for (uint32 i = 0; i < iExtensions.size(); i++)
+            {
+                iExtensions[i]->removeRef();
+            }
+            iExtensions.clear();
+            iExtensionUuids.clear();
+        }
+
+
+        int32				commandStartOffset;
+        PVMFNodeInterface*	iNode;
+        int32				iNodeTag;
+        PVMFSessionId		iSessionId;
+        PVMFSMFSPChildNodeCmdState  iNodeCmdState;
+        int32				iNumRequestPortsPending;
+        bool				iAutoPaused;
+        Oscl_Vector<PVMFPortInterface*, OsclMemAllocator> iInputPorts;
+        Oscl_Vector<PVMFPortInterface*, OsclMemAllocator> iOutputPorts;
+        Oscl_Vector<PVMFPortInterface*, OsclMemAllocator> iFeedBackPorts;
+        Oscl_Vector<PVInterface*, OsclMemAllocator>		  iExtensions;
+        Oscl_Vector<PVUuid, OsclMemAllocator>			  iExtensionUuids;
+
+};
+
+typedef Oscl_Vector<PVMFSMFSPChildNodeContainer, OsclMemAllocator> PVMFSMFSPChildNodeContainerVector;
+
+typedef PVMFNodeCommandQueue<PVMFSMFSPBaseNodeCommand, OsclMemAllocator> PVMFFSPNodeCmdQ;
+
+typedef struct tagPVMFSMFSPPortContext
+{
+    tagPVMFSMFSPPortContext()
+    {
+        trackID = 0;
+        portTag = 0;
+    }
+    uint32 trackID;
+    uint32 portTag;
+} PVMFSMFSPPortContext;
+
+class PVMFSMFSPCommandContext
+{
+    public:
+        PVMFSMFSPCommandContext()
+        {
+            oInternalCmd = false;
+            parentCmd = 0;
+            cmd = 0;
+            oFree = true;
+        };
+
+        bool oInternalCmd;
+        int32 parentCmd;
+        int32 cmd;
+        bool  oFree;
+        PVMFSMFSPPortContext portContext;
+};
+
+class PVMFSMFSPSessionSourceInfo
+{
+    public:
+        PVMFSMFSPSessionSourceInfo()
+        {
+            Reset();
+        }
+
+        void Reset()
+        {
+            iDRMProtected = false;
+            _sessionType = PVMF_MIME_FORMAT_UNKNOWN;
+            _sourceData = NULL;
+            _sessionURL = NULL;
+        }
+
+        bool iDRMProtected;
+        PVMFFormatType _sessionType;
+        OsclAny*    _sourceData;
+        OSCL_wHeapString<OsclMemAllocator>    _sessionURL;
+
+};
+
+/*
+*  class for saving kvps for CPM
+*/
+typedef Oscl_Vector<PvmiKvp, OsclMemAllocator> PVMFKvpVector;
+class PVMFSMNodeKVPStore
+{
+    public:
+        // add kvp string with W-string value
+        PVMFStatus addKVPString(const char* aKeyTypeString, OSCL_wString& aValString);
+        // add kvp string with normal string value
+        PVMFStatus addKVPString(const char* aKeyTypeString, const char* aValString);
+        // add kvp string with normal uint32 value
+        PVMFStatus addKVPuint32Value(const char* aKeyTypeString, uint32 aValue);
+
+        // get the vector for the all constructed KVPs
+        PVMFKvpVector* getKVPStore()
+        {
+            return &iKvpVector;
+        }
+
+        // check emptiness of the store
+        bool isEmpty() const
+        {
+            return iKvpVector.empty();
+        }
+
+        // release memory for all the constructed KVPs and clear the vector
+        void destroy()
+        {
+            releaseMemory();
+            clear();
+        }
+
+        // constructor and destructor
+        PVMFSMNodeKVPStore()
+        {
+            clear();
+        }
+        ~PVMFSMNodeKVPStore()
+        {
+            destroy();
+        }
+
+    private:
+        enum KVPValueTypeForMemoryRelease
+        {
+            KVPValueTypeForMemoryRelease_NoInterest = 0,
+            KVPValueTypeForMemoryRelease_String,
+            KVPValueTypeForMemoryRelease_WString
+        };
+
+        void clear()
+        {
+            iKvpVector.clear();
+            iKVPValueTypeForMemoryRelease.clear();
+        }
+        void releaseMemory();
+        PVMFStatus pushKVPToVector(const PvmiKvp&, const KVPValueTypeForMemoryRelease&);
+
+    private:
+        PVMFKvpVector iKvpVector;
+        Oscl_Vector<uint32, OsclMemAllocator> iKVPValueTypeForMemoryRelease;
+};
+
+template <class T> class PVMFSMSharedPtrAlloc: public OsclDestructDealloc
+{
+    public:
+        T* allocate()
+        {
+            OsclMemAllocator alloc;
+            T* ptr = OSCL_PLACEMENT_NEW(alloc.allocate(sizeof(T)), T());
+            return ptr;
+        }
+
+        virtual void destruct_and_dealloc(OsclAny* ptr)
+        {
+            T* tptr ;
+            tptr = reinterpret_cast<T*>(ptr);
+            tptr->~T();
+            OsclMemAllocator alloc;
+            alloc.deallocate(ptr);
+        }
+};
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_pvr_base_impl.h b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_pvr_base_impl.h
new file mode 100644
index 0000000..ae0ee28
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_pvr_base_impl.h
@@ -0,0 +1,366 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_PVR_BASE_IMPL_H
+#define PVMF_SM_FSP_PVR_BASE_IMPL_H
+
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#include "pvmf_sm_fsp_base_impl.h"
+#endif
+
+#ifndef __SDP_INFO_H__
+#include "sdp_info.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PVMF_SM_FSP_PVR_CAPANDCONFIG_H
+#include "pvmf_sm_fsp_pvr_capandconfig.h"
+#endif
+
+#ifndef PVMF_JITTER_BUFFER_PORT_H_INCLUDED
+#include "pvmf_jitter_buffer_port.h"
+#endif
+
+#ifndef PVMF_DATA_SOURCE_PACKETSOURCE_H_INCLUDED
+#include "pvmf_data_source_packetsource.h"
+#endif
+
+#define PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_STACK_TRACE,m);
+#define PVMF_SM_FSP_PVR_BASE_LOGDEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_DEBUG,m);
+#define PVMF_SM_FSP_PVR_BASE_LOGERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_ERR,m);
+#define PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iCommandSeqLogger,PVLOGMSG_STACK_TRACE,m);
+#define PVMF_SM_FSP_PVR_BASE_LOGINFO(m) PVMF_SM_FSP_PVR_BASE_LOGINFOMED(m)
+#define PVMF_SM_FSP_PVR_BASE_LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
+#define PVMF_SM_FSP_PVR_BASE_LOGCOMMANDREPOS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m);
+
+class PVMFPVRBaseTrackInfo
+{
+    public:
+        PVMFPVRBaseTrackInfo()
+        {
+            trackID = 0;
+            rdtStreamID = 0;
+            portTag = 0;
+            bitRate = 0;
+            trackTimeScale = 1;
+            iNetworkNodePort = NULL;
+            iJitterBufferInputPort = NULL;
+            iJitterBufferOutputPort = NULL;
+            iMediaLayerInputPort = NULL;
+            iMediaLayerOutputPort = NULL;
+            iJitterBufferRTCPPort = NULL;
+            iNetworkNodeRTCPPort = NULL;
+            iSessionControllerOutputPort = NULL;
+            iSessionControllerFeedbackPort = NULL;
+            iRTPSocketID = 0;
+            iRTCPSocketID = 0;
+            iRateAdaptation = false;
+            iRateAdaptationFeedBackFrequency = 0;
+            iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            iRTCPBwSpecified = false;
+            iTrackDisable = false;
+            iPVRNodeInputPort = NULL;
+            iPVRNodeOutputPort = NULL;
+            iPVRNodeRTCPPort = NULL;
+        };
+
+        PVMFPVRBaseTrackInfo(const PVMFPVRBaseTrackInfo& a)
+        {
+            trackID = a.trackID;
+            rdtStreamID = a.rdtStreamID;
+            portTag = a.portTag;
+            bitRate = a.bitRate;
+            trackTimeScale = a.trackTimeScale;
+            iTrackConfig = a.iTrackConfig;
+            iTransportType = a.iTransportType;
+            iFormatType = a.iFormatType;
+            iMimeType = a.iMimeType;
+            iNetworkNodePort = a.iNetworkNodePort;
+            iJitterBufferInputPort = a.iJitterBufferInputPort;
+            iJitterBufferOutputPort = a.iJitterBufferOutputPort;
+            iMediaLayerInputPort = a.iMediaLayerInputPort;
+            iMediaLayerOutputPort = a.iMediaLayerOutputPort;
+            iJitterBufferRTCPPort = a.iJitterBufferRTCPPort;
+            iNetworkNodeRTCPPort = a.iNetworkNodeRTCPPort;
+            iSessionControllerOutputPort = a.iSessionControllerOutputPort;
+            iSessionControllerFeedbackPort = a.iSessionControllerFeedbackPort;
+            iRTPSocketID = a.iRTPSocketID;
+            iRTCPSocketID = a.iRTCPSocketID;
+            iRateAdaptation = a.iRateAdaptation;
+            iRateAdaptationFeedBackFrequency = a.iRateAdaptationFeedBackFrequency;
+            iRTCPBwSpecified = a.iRTCPBwSpecified;
+            iTrackDisable = a.iTrackDisable;
+            iRR = a.iRR;
+            iRS = a.iRS;
+            iPVRNodeInputPort = a.iPVRNodeInputPort;
+            iPVRNodeOutputPort = a.iPVRNodeOutputPort;
+            iPVRNodeRTCPPort = a.iPVRNodeRTCPPort;
+
+        };
+
+        PVMFPVRBaseTrackInfo& operator=(const PVMFPVRBaseTrackInfo& a)
+        {
+            if (&a != this)
+            {
+                trackID = a.trackID;
+                rdtStreamID = a.rdtStreamID;
+                portTag = a.portTag;
+                bitRate = a.bitRate;
+                trackTimeScale = a.trackTimeScale;
+                iTrackConfig = a.iTrackConfig;
+                iTransportType = a.iTransportType;
+                iFormatType = a.iFormatType;
+                iMimeType = a.iMimeType;
+                iNetworkNodePort = a.iNetworkNodePort;
+                iJitterBufferInputPort = a.iJitterBufferInputPort;
+                iJitterBufferOutputPort = a.iJitterBufferOutputPort;
+                iMediaLayerInputPort = a.iMediaLayerInputPort;
+                iMediaLayerOutputPort = a.iMediaLayerOutputPort;
+                iJitterBufferRTCPPort = a.iJitterBufferRTCPPort;
+                iNetworkNodeRTCPPort = a.iNetworkNodeRTCPPort;
+                iSessionControllerOutputPort = a.iSessionControllerOutputPort;
+                iSessionControllerFeedbackPort = a.iSessionControllerFeedbackPort;
+                iRTPSocketID = a.iRTPSocketID;
+                iRTCPSocketID = a.iRTCPSocketID;
+                iRateAdaptation = a.iRateAdaptation;
+                iRateAdaptationFeedBackFrequency = a.iRateAdaptationFeedBackFrequency;
+                iRTCPBwSpecified = a.iRTCPBwSpecified;
+                iTrackDisable = a.iTrackDisable;
+                iRR = a.iRR;
+                iRS = a.iRS;
+                iPVRNodeInputPort = a.iPVRNodeInputPort;
+                iPVRNodeOutputPort = a.iPVRNodeOutputPort;
+                iPVRNodeRTCPPort = a.iPVRNodeRTCPPort;
+
+            }
+            return *this;
+        };
+
+        virtual ~PVMFPVRBaseTrackInfo() {};
+
+        uint32 trackID;
+        uint32 rdtStreamID;
+        uint32 portTag;
+        uint32 bitRate;
+        uint32 trackTimeScale;
+        OsclRefCounterMemFrag iTrackConfig;
+        OSCL_HeapString<OsclMemAllocator> iTransportType;
+        PVMFFormatType iFormatType;
+        OSCL_HeapString<OsclMemAllocator> iMimeType;
+        PVMFPortInterface* iNetworkNodePort;
+        PVMFPortInterface* iJitterBufferInputPort;
+        PVMFPortInterface* iJitterBufferOutputPort;
+        PVMFPortInterface* iMediaLayerInputPort;
+        PVMFPortInterface* iMediaLayerOutputPort;
+        PVMFPortInterface* iJitterBufferRTCPPort;
+        PVMFPortInterface* iNetworkNodeRTCPPort;
+        PVMFPortInterface* iSessionControllerOutputPort;
+        PVMFPortInterface* iSessionControllerFeedbackPort;
+
+        uint32 iRTPSocketID;
+        uint32 iRTCPSocketID;
+        bool   iRateAdaptation;
+        uint32 iRateAdaptationFeedBackFrequency;
+
+        // RTCP bandwidth related
+        bool   iRTCPBwSpecified;
+        uint32 iRR;
+        uint32 iRS;
+
+        // PVR Related
+        PVMFPortInterface* iPVRNodeInputPort;
+        PVMFPortInterface* iPVRNodeOutputPort;
+        PVMFPortInterface* iPVRNodeRTCPPort;
+
+        //Check track disable or not
+        bool iTrackDisable;
+
+
+};
+typedef Oscl_Vector<PVMFPVRBaseTrackInfo, OsclMemAllocator> PVMFPVRBaseTrackInfoVector;
+
+class PVMFPVRExtInterface;
+
+// This is a base class for plugins: PVR File Playback, Broadcast PVR, and Unicast + PVR
+class PVMFSMFSPPVRBase : public PVMFSMFSPBaseNode
+{
+    public:
+        PVMFSMFSPPVRBase(int32 aPriority);
+        // Pure Virtual functions. Implementations are done in the plugins: PVR File Playback, Broadcast, and Unicast + PVR
+        virtual void CompleteGraphConstruct() = 0;
+        virtual void CompletePause() = 0;
+        virtual void CompleteInit() = 0;
+        virtual	void CompleteStart() = 0;
+        virtual void CreateChildNodes() = 0;
+        virtual void DestroyChildNodes() = 0;
+        virtual PVMFStatus DoGraphConstruct() = 0;
+        virtual void DoSetDataSourcePosition(PVMFSMFSPBaseNodeCommand&) = 0;
+        virtual void DoSetDataSourcePositionPlayList(PVMFSMFSPBaseNodeCommand&) = 0;
+
+        virtual void HandleChildNodeCommandCompletion(const PVMFCmdResp& , bool&) = 0;
+
+        virtual void HandleJitterBufferCommandCompleted(const PVMFCmdResp&, bool& aPerformErrHandling) = 0;
+
+        virtual PVMFStatus InitMetaData() = 0;
+        virtual PVMFStatus ProcessSDP() = 0;
+
+        virtual PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL,
+                PVMFFormatType& aSourceFormat,
+                OsclAny* aSourceData) = 0;
+
+        virtual PVMFStatus DoPreInit(PVMFSMFSPBaseNodeCommand& aCmd) = 0;
+        virtual void DoInit(PVMFSMFSPBaseNodeCommand&) = 0;
+        virtual void DoPause(PVMFSMFSPBaseNodeCommand&) = 0;
+        virtual void DoStart(PVMFSMFSPBaseNodeCommand&) = 0;
+        virtual void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent) = 0;
+        virtual void QueryChildNodesExtentionInterface() = 0;
+        virtual	PVMFStatus VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set) = 0;
+        virtual bool GraphConnect() = 0;
+
+        // These functions are common to the plugins: PVR File Playback, Broadcast PVR, and Unicast + PVR
+
+        void BypassError();
+        bool CheckChildrenNodesInit();
+        bool CheckChildrenNodesPause();
+        bool CheckChildrenNodesPrepare();
+        bool CheckChildrenNodesStart();
+        bool CheckChildrenNodesStop();
+        void CleanUp();
+        void PopulatePayloadParserRegistry();
+        void ResetNodeParams(bool aReleaseMemory = true);
+
+        void CompletePrepare();
+
+        void CompleteStop();
+        PVMFStatus ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+                                        PVMFTimestamp aActualNPT,
+                                        PVMFTimestamp aActualMediaDataTS,
+                                        PVMFTimestamp& aSkipTimeStamp,
+                                        PVMFTimestamp& aStartNPT);
+        PVMFStatus ConnectPortPairs(PVMFPortInterface* aPort1, PVMFPortInterface* aPort2);
+        void Construct();
+        virtual void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        virtual void DeleteContext(PvmiMIOSession aSession,
+                                   PvmiCapabilityContext& aContext);
+        void DestroyPayloadParserRegistry();
+        PVMFCommandId DoGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFCommandId DoGetMetadataValues(PVMFSMFSPBaseNodeCommand& aCmd);
+
+
+        void DoPrepare(PVMFSMFSPBaseNodeCommand&);
+        void DoQueryDataSourcePosition(PVMFSMFSPBaseNodeCommand&);
+
+
+        void DoReleasePort(PVMFSMFSPBaseNodeCommand&);
+        void DoRequestPort(PVMFSMFSPBaseNodeCommand&);
+
+        void DoStop(PVMFSMFSPBaseNodeCommand&);
+        PVMFPVRBaseTrackInfo* FindTrackInfo(uint32 tag);
+        void GetAcutalMediaTSAfterSeek();
+        virtual uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        virtual PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
+        virtual uint32 GetNumMetadataKeys(char* aQueryKeyString = NULL);
+        virtual uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
+        virtual PVMFStatus getParametersSync(PvmiMIOSession aSession,
+                                             PvmiKeyType aIdentifier,
+                                             PvmiKvp*& aParameters,
+                                             int& aNumParamElements,
+                                             PvmiCapabilityContext aContext);
+        virtual PVMFStatus GetPVRPluginSpecificValues(PVMFSMFSPBaseNodeCommand& aCmd);
+
+        void HandleMediaLayerCommandCompleted(const PVMFCmdResp&, bool& aPerformErrHandling);
+
+        bool IsFSPInternalCmd(PVMFCommandId aId);
+        virtual void NodeCommandCompleted(const PVMFCmdResp& aResponse);
+        PVMFStatus PopulateAvailableMetadataKeys();
+        virtual void PopulateDRMInfo();
+        bool PopulateTrackInfoVec();
+        virtual bool ProcessCommand(PVMFSMFSPBaseNodeCommand&);
+
+        void ReleaseChildNodesExtentionInterface();
+        virtual PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
+                uint32 aStartingKeyIndex,
+                uint32 aEndKeyIndex);
+        virtual PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+                uint32 aStartingValueIndex,
+                uint32 aEndValueIndex);
+        virtual PVMFStatus releaseParameters(PvmiMIOSession aSession,
+                                             PvmiKvp* aParameters,
+                                             int num_elements);
+
+        bool RequestJitterBufferPorts(int32 portType, uint32 &numPortsRequested);
+        bool RequestMediaLayerPorts(int32 portType, uint32& numPortsRequested);
+
+
+        void ResetStopCompleteParams();
+        virtual PVMFStatus SelectTracks(PVMFMediaPresentationInfo& aInfo);
+        virtual PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        virtual void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                                          PvmiKvp* aParameters, int num_parameter_elements);
+        virtual PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
+        void setJitterBufferDurationInMilliSeconds(uint32 duration);
+        virtual void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        virtual void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                       int num_elements, PvmiKvp * & aRet_kvp);
+
+        virtual PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
+                                                PvmiKvp* aParameters,
+                                                int num_elements);
+        bool SkipThisNodeResume(int32 aNodeTag);
+        bool SkipThisNodePause(int32 aNodeTag);
+        void SetPVRTrackParams(uint32 aMediaTrackId, const PvmfMimeString* aMimeType,
+                               uint32 aTimescale, uint32 aBitrate);
+        void SetPVRTrackRTPParams(const PvmfMimeString* aMimeType, bool   aSeqNumBasePresent,
+                                  uint32 aSeqNumBase, bool   aRTPTimeBasePresent,
+                                  uint32 aRTPTimeBase, uint32 aNPTInMS);
+        void SetPVRSdpText(OsclRefCounterMemFrag& aSDPText);
+        uint32 GetJitterBufferMemPoolSize(PVMFJitterBufferNodePortTag aJBNodePortTag, PVMFPVRBaseTrackInfo& aRTSPPlusPVRTrackInfo);
+        bool SetPVRPlaybackRange();
+        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
+                                      int32 aIndex, PvmiKvpAttr reqattr);
+        void DoQueryInterface(PVMFSMFSPBaseNodeCommand&);
+
+    protected:
+        virtual bool RequestUsageComplete()
+        {
+            return true;
+        };
+
+    protected:
+
+        PVMFPVRBaseTrackInfoVector	iTrackInfoVec;
+        OsclSharedPtr<SDPInfo> iSdpInfo;
+
+        uint32 iJitterBufferDurationInMilliSeconds;
+
+        PVMFMediaPresentationInfo iCompleteMediaPresetationInfo;
+        PVMFMediaPresentationInfo iSelectedMediaPresetationInfo;
+        bool iPVREnabled;
+        bool iOutOfBandEOS;
+        PVMFPVRExtInterface* iPVRExtInterface;
+        PVMFPVRControl* iPVRControl;
+        PVInterface* iPVRQueryInterface;
+        bool oAutoReposition;
+        bool iJumpingToLive;
+
+};
+
+
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_registry_interface.h b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_registry_interface.h
new file mode 100644
index 0000000..d90e70f
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/include/pvmf_sm_fsp_registry_interface.h
@@ -0,0 +1,167 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *  @file pv_player_node_registry.h
+ *  @brief PVPlayerNodeRegistry maintains a list of nodes available which is queryable. The utility
+ *   also allows the node specified by PVUuid to be created and returned
+ *
+ */
+
+
+#ifndef PVMF_SM_FSP_REGISTRY_INTERFACE_H_INCLUDED
+#define PVMF_SM_FSP_REGISTRY_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#include "pvmf_sm_fsp_base_impl.h"
+#endif
+
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#define PVMF_MIME_DATA_SOURCE_PVR_FILEPLAYBACK		"X-PVMF-DATA-SRC-PVR-FILEPLAYBACK"
+#define PVMF_MIME_DATA_SOURCE_RTSP_TUNNELLING		"X-PVMF-DATA-SRC-RTSP-TUNNELLING"
+#define PVMF_MIME_DATA_SOURCE_RTSP_BROADCAST			"X-PVMF-DATA-SRC-RTSP-BROADCAST"
+#define PVMF_MIME_DATA_SOURCE_RTSP_UNICAST_PLUS_PVR  "X-PVMF-DATA-SRC-RTSP-UNICAST-PLUS-PVR"
+
+
+// FORWARD DECLARATION
+class OsclSharedLibrary;
+
+
+// CLASS DECLARATION
+/**
+ * PVMFFSPInfo is a class which will maintain feature specific plugin info
+ **/
+class PVMFSMFSPInfo
+{
+    public:
+        /**
+         * Object Constructor function
+         **/
+        PVMFSMFSPInfo()
+        {
+#ifdef USE_LOADABLE_MODULES
+            iSharedLibrary    = NULL;
+            iSMFSPCreateFunc  = NULL;
+            iSMFSPReleaseFunc = NULL;
+#endif
+        }
+
+        /**
+         * Copy Constructor function
+         **/
+        PVMFSMFSPInfo(const PVMFSMFSPInfo& aInfo)
+        {
+            iSMFSPUUID = aInfo.iSMFSPUUID;
+            iSMFSPCreateFunc = aInfo.iSMFSPCreateFunc;
+            iSMFSPReleaseFunc = aInfo.iSMFSPReleaseFunc;
+            iSourceFormatTypes = aInfo.iSourceFormatTypes;
+            iSharedLibrary = aInfo.iSharedLibrary;
+        }
+
+        /**
+         * Object destructor function
+         **/
+        ~PVMFSMFSPInfo()
+        {
+        }
+
+        PVUuid iSMFSPUUID;
+        PVMFSMFSPBaseNode*(*iSMFSPCreateFunc)(int32);
+        bool (*iSMFSPReleaseFunc)(PVMFSMFSPBaseNode *);
+        Oscl_Vector<PVMFFormatType, OsclMemAllocator> iSourceFormatTypes;
+        OsclSharedLibrary* iSharedLibrary;
+};
+
+
+class PVMFFSPRegistryInterface
+{
+    public:
+        /**
+         * The QueryRegistry for PVMFFSPRegistry. Used mainly for Seaching of the UUID
+         * whether it is available or not & returns Success if it is found else failure.
+         *
+         * @param aInputType Input Format Type
+         *
+         * @param aOutputType Output Format Type
+         *
+         * @param aUuids Reference to the UUID registered
+         *
+         * @returns Success or Failure
+         **/
+        virtual PVMFStatus QueryRegistry(PVMFFormatType& aInputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids) = 0;
+
+        /**
+         * The CreateNode for PVMFFSPRegistry. Used mainly for creating a FSP.
+         *
+         * @param aUuid UUID returned by the QueryRegistry
+         *
+         * @returns a pointer to node
+         **/
+        virtual PVMFSMFSPBaseNode* CreateSMFSP(PVUuid& aUuid) = 0;
+
+        /**
+         * The ReleaseNode for PVMFFSPRegistry. Used for releasing a node.
+         *
+         * @param aUuid UUID recorded at the time of creation of the node.
+         *
+         * @param Pointer to the node to be released
+         *
+         * @returns True or False
+         **/
+        virtual bool ReleaseSMFSP(PVUuid& aUuid, PVMFSMFSPBaseNode *aSMFSP) = 0;
+
+        /**
+         * The RegisterNode for PVMFFSPRegistry. Used for registering nodes through the SMFSPInfo object.
+         *
+         * @param aSMFSPInfo SMFSPInfo object passed to the regisry class. This contains all fsps that need to be registered.
+         *
+         **/
+        virtual void RegisterSMFSP(const PVMFSMFSPInfo& aSMFSPInfo) = 0;
+
+#ifdef USE_LOADABLE_MODULES
+        /**
+         * The UnregisterFSP for PVMFFSPRegistry. Used for unregistering nodes through the FSPInfo object.
+         *
+         * @param aSMFSPInfo SMFSPInfo object passed to the regisry class. This contains all fsps that need to be unregistered.
+         *
+         **/
+        virtual void UnregisterSMFSP(const PVMFSMFSPInfo& aSMFSPInfo) = 0;
+#endif
+};
+
+#endif // PVMF_SM_FSP_REGISTRY_INTERFACE_H_INCLUDED
+
+
diff --git a/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_base_cpm_support.cpp b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_base_cpm_support.cpp
new file mode 100644
index 0000000..ecdbf98
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_base_cpm_support.cpp
@@ -0,0 +1,643 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#include "pvmf_sm_fsp_base_impl.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
+#include "pvmf_streaming_manager_node.h"
+#endif
+#ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
+#include "pvmf_media_presentation_info.h"
+#endif
+#ifndef PVMF_STREAMING_DATA_SOURCE_H_INCLUDED
+#include "pvmf_streaming_data_source.h"
+#endif
+
+#define PVMF_STREAMING_MANAGER_NODE_MAX_CPM_METADATA_KEYS 256
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of PVMFCPMPluginLicenseInterface
+///////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFSMFSPBaseNode::GetLicenseURL(PVMFSessionId aSessionId,
+        OSCL_wString& aContentName,
+        OSCL_wString& aLicenseURL)
+{
+    OSCL_UNUSED_ARG(aSessionId);
+    OSCL_UNUSED_ARG(aContentName);
+    OSCL_UNUSED_ARG(aLicenseURL);
+    //must use Async method.
+    PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::GetLicenseURL - Error Not Supported"));
+    return PVMFErrNotSupported;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::GetLicenseURL(PVMFSessionId aSessionId,
+        OSCL_String&  aContentName,
+        OSCL_String&  aLicenseURL)
+{
+    OSCL_UNUSED_ARG(aSessionId);
+    OSCL_UNUSED_ARG(aContentName);
+    OSCL_UNUSED_ARG(aLicenseURL);
+    //must use Async method.
+    PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::GetLicenseURL - Error Not Supported"));
+    return PVMFErrNotSupported;
+}
+
+/**
+ * Queue an asynchronous node command - GetLicense(Unicode)
+ */
+PVMFCommandId PVMFSMFSPBaseNode::GetLicense(PVMFSessionId aSessionId
+        , OSCL_wString& aContentName
+        , OsclAny* aLicenseData
+        , uint32 aDataSize
+        , int32 aTimeoutMsec
+        , OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetLicense - Unicode Variant Called"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_GET_LICENSE_W,
+                                            aContentName,
+                                            aLicenseData,
+                                            aDataSize,
+                                            aTimeoutMsec,
+                                            aContext);
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - GetLicense(ASCII)
+ */
+PVMFCommandId PVMFSMFSPBaseNode::GetLicense(PVMFSessionId aSessionId
+        , OSCL_String&  aContentName
+        , OsclAny* aLicenseData
+        , uint32 aDataSize
+        , int32 aTimeoutMsec
+        , OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetLicense - called"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_GET_LICENSE,
+                                            aContentName,
+                                            aLicenseData,
+                                            aDataSize,
+                                            aTimeoutMsec,
+                                            aContext);
+    return QueueCommandL(cmd);
+
+}
+
+/**
+ * Queue an asynchronous node command - CancelGetLicense
+ */
+PVMFCommandId PVMFSMFSPBaseNode::CancelGetLicense(PVMFSessionId aSessionId
+        , PVMFCommandId aCmdId
+        , OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CancelGetLicense - called"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSessionId,
+            PVMF_SMFSP_NODE_CANCEL_GET_LICENSE,
+            aCmdId,
+            aContext);
+    return QueueCommandL(cmd);
+}
+
+PVMFStatus PVMFSMFSPBaseNode::GetLicenseStatus(PVMFCPMLicenseStatus& aStatus)
+{
+    if (iCPMLicenseInterface)
+        return iCPMLicenseInterface->GetLicenseStatus(aStatus);
+    return PVMFFailure;
+}
+
+void PVMFSMFSPBaseNode::InitCPM()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::InitCPM() In"));
+
+    iCPMInitCmdId = iCPM->Init();
+}
+
+void PVMFSMFSPBaseNode::OpenCPMSession()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::OpenCPMSession() In"));
+
+    iCPMOpenSessionCmdId = iCPM->OpenSession(iCPMSessionID);
+}
+
+void PVMFSMFSPBaseNode::CPMRegisterContent()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CPMRegisterContent() In"));
+
+    if (iSourceContextDataValid)
+    {
+        iCPMRegisterContentCmdId = iCPM->RegisterContent(iCPMSessionID,
+                                   iSessionSourceInfo->_sessionURL,
+                                   iSessionSourceInfo->_sessionType,
+                                   (OsclAny*) & iSourceContextData);
+    }
+    else
+    {
+        iCPMRegisterContentCmdId = iCPM->RegisterContent(iCPMSessionID,
+                                   iSessionSourceInfo->_sessionURL,
+                                   iSessionSourceInfo->_sessionType,
+                                   (OsclAny*) & iCPMSourceData);
+    }
+}
+
+void PVMFSMFSPBaseNode::GetCPMLicenseInterface()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetCPMLicenseInterface() In"));
+
+    iCPMLicenseInterfacePVI = NULL;
+    iCPMGetLicenseInterfaceCmdId =
+        iCPM->QueryInterface(iCPMSessionID,
+                             PVMFCPMPluginLicenseInterfaceUuid,
+                             iCPMLicenseInterfacePVI);
+}
+
+void PVMFSMFSPBaseNode::GetCPMCapConfigInterface()
+{
+    iCPMCapConfigInterfacePVI = NULL;
+    iCPMGetCapConfigCmdId =
+        iCPM->QueryInterface(iCPMSessionID,
+                             PVMI_CAPABILITY_AND_CONFIG_PVUUID,
+                             iCPMCapConfigInterfacePVI);
+}
+
+
+bool PVMFSMFSPBaseNode::GetCPMContentAccessFactory()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetCPMContentAccessFactory() In"));
+
+    PVMFStatus status = iCPM->GetContentAccessFactory(iCPMSessionID,
+                        iCPMContentAccessFactory);
+    if (status != PVMFSuccess)
+    {
+        return false;
+    }
+    return true;
+}
+
+bool PVMFSMFSPBaseNode::GetCPMMetaDataExtensionInterface()
+{
+    PVInterface* temp = NULL;
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetCPMMetaDataExtensionInterface() In"));
+
+    bool retVal =
+        iCPM->queryInterface(KPVMFMetadataExtensionUuid, temp);
+    iCPMMetaDataExtensionInterface = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, temp);
+
+    return retVal;
+}
+
+void PVMFSMFSPBaseNode::RequestUsage()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::RequestUsage() In"));
+    iCPMRequestUsageId = iCPM->ApproveUsage(iCPMSessionID,
+                                            iRequestedUsage,
+                                            iApprovedUsage,
+                                            iAuthorizationDataKvp,
+                                            iUsageID,
+                                            iCPMContentAccessFactory);
+}
+
+void PVMFSMFSPBaseNode::SendUsageComplete()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SendUsageComplete() In"));
+
+    iCPMUsageCompleteCmdId = iCPM->UsageComplete(iCPMSessionID, iUsageID);
+}
+
+void PVMFSMFSPBaseNode::CloseCPMSession()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CloseCPMSession() In"));
+
+    iCPMCloseSessionCmdId = iCPM->CloseSession(iCPMSessionID);
+}
+
+void PVMFSMFSPBaseNode::ResetCPM()
+{
+    iCPMResetCmdId = iCPM->Reset();
+}
+
+void PVMFSMFSPBaseNode::GetCPMMetaDataKeys()
+{
+    if (iCPMMetaDataExtensionInterface != NULL)
+    {
+        iCPMMetadataKeys.clear();
+        iCPMGetMetaDataKeysCmdId =
+            iCPMMetaDataExtensionInterface->GetNodeMetadataKeys(iCPMSessionID,
+                    iCPMMetadataKeys,
+                    0,
+                    PVMF_STREAMING_MANAGER_NODE_MAX_CPM_METADATA_KEYS);
+    }
+}
+
+PVMFStatus
+PVMFSMFSPBaseNode::CheckCPMCommandCompleteStatus(PVMFCommandId aID,
+        PVMFStatus aStatus)
+{
+    PVMFStatus status = aStatus;
+    if (aID == iCPMGetLicenseInterfaceCmdId)
+    {
+        if (aStatus == PVMFErrNotSupported)
+        {
+            /* License Interface is Optional */
+            status = PVMFSuccess;
+        }
+    }
+
+    if ((status != PVMFSuccess))
+    {
+        OSCL_ASSERT(aID != iCPMResetCmdId);
+        if (iCurrErrHandlingCommand.size() > 0)
+        {
+            if (PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR == iCurrErrHandlingCommand.front().iCmd)
+            {
+
+                //skip to next step, cpm cleanup steps are not coupled so moving to next step even if
+                //some of inbetween step fails may not be harmful
+                status = PVMFSuccess;
+            }
+        }
+    }
+
+    return status;
+}
+
+void PVMFSMFSPBaseNode::CPMCommandCompleted(const PVMFCmdResp& aResponse)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CPMCommandCompleted() In"));
+
+    PVMFCommandId id = aResponse.GetCmdId();
+    PVMFStatus status =
+        CheckCPMCommandCompleteStatus(id, aResponse.GetCmdStatus());
+
+    if (id == iCPMCancelGetLicenseCmdId)
+    {
+        /*
+         * if this command is CancelGetLicense, we will return success or fail here.
+         */
+        OSCL_ASSERT(!iCancelCommand.empty());
+        CommandComplete(iCancelCommand,
+                        iCancelCommand.front(),
+                        status);
+        return;
+    }
+    else
+    {
+        /*
+         * if there was any pending cancel, we just ignore CPM process.
+         */
+        if (iCurrentCommand.empty() && iCurrErrHandlingCommand.empty())
+        {
+            return;
+        }
+        if (!iCancelCommand.empty())
+        {
+            if (iCancelCommand.front().iCmd != PVMF_SMFSP_NODE_CANCEL_GET_LICENSE)
+                return;
+        }
+    }
+
+    if (status != PVMFSuccess)
+    {
+        if (id == iCPMRequestUsageId)
+        {
+            /*
+             * Only when PVMFErrLicenseRequired is replied for license authentication,
+             * Set iCPMInitPending into true.
+             */
+            if (aResponse.GetCmdStatus() == PVMFErrLicenseRequired)
+                iCPMInitPending = true;
+        }
+        CommandComplete(iCurrentCommand,
+                        iCurrentCommand.front(),
+                        aResponse.GetCmdStatus(),
+                        NULL,
+                        NULL,
+                        NULL,
+                        aResponse.GetEventExtensionInterface());
+
+    }
+    else
+    {
+        /*
+         * process the response, and issue the next command in
+         * the sequence.
+         */
+
+        if (id == iCPMInitCmdId)
+        {
+            OpenCPMSession();
+        }
+        else if (id == iCPMOpenSessionCmdId)
+        {
+            CPMRegisterContent();
+        }
+        else if (id == iCPMRegisterContentCmdId)
+        {
+            GetCPMCapConfigInterface();
+        }
+        else if (id == iCPMGetCapConfigCmdId)
+        {
+            iCPMCapConfigInterface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, iCPMCapConfigInterfacePVI);
+            iCPMCapConfigInterfacePVI = NULL;
+            // got capConfig interface, set kvps for CPM plugins
+            if (!SetCPMKvps()) return;
+            GetCPMLicenseInterface();
+        }
+        else if (id == iCPMGetLicenseInterfaceCmdId)
+        {
+            iCPMLicenseInterface = OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, iCPMLicenseInterfacePVI);
+            iCPMLicenseInterfacePVI = NULL;
+            iCPMContentType = iCPM->GetCPMContentType(iCPMSessionID);
+            OSCL_ASSERT(iCPMContentType == PVMF_CPM_FORMAT_ACCESS_BEFORE_AUTHORIZE);
+            GetCPMContentAccessFactory();
+            GetCPMMetaDataExtensionInterface();
+            RequestUsage();
+        }
+        else if (id == iCPMRequestUsageId)
+        {
+            OSCL_ASSERT(iCPMContentType == PVMF_CPM_FORMAT_ACCESS_BEFORE_AUTHORIZE);
+            /* End of Node Init sequence. */
+            OSCL_ASSERT(!iCurrentCommand.empty());
+            OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_SMFSP_NODE_INIT);
+            CompleteDRMInit();
+        }
+        else if (id == iCPMGetMetaDataKeysCmdId)
+        {
+            /* End of GetNodeMetaDataKeys */
+            PVMFStatus status =
+                CompleteGetMetadataKeys(iCurrentCommand.front());
+            CommandComplete(iCurrentCommand,
+                            iCurrentCommand.front(),
+                            status);
+        }
+        else if (id == iCPMUsageCompleteCmdId)
+        {
+            if (iDecryptionInterface != NULL)
+            {
+                iDecryptionInterface->Reset();
+                /* Remove the decrpytion interface */
+                PVUuid uuid = PVMFCPMPluginDecryptionInterfaceUuid;
+                iCPMContentAccessFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iDecryptionInterface);
+                iDecryptionInterface = NULL;
+            }
+            CloseCPMSession();
+        }
+        else if (id == iCPMCloseSessionCmdId)
+        {
+            ResetCPM();
+        }
+        else if (id == iCPMResetCmdId)
+        {
+            if (EPVMFNodeError != iInterfaceState)
+            {
+                /* End of Node Reset sequence */
+                OSCL_ASSERT(!iCurrentCommand.empty());
+                OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_SMFSP_NODE_RESET);
+                iDRMResetPending = false;
+                CompleteReset();
+            }
+            else
+            {
+                /* End of Node Reset sequence */
+                OSCL_ASSERT(!iCurrErrHandlingCommand.empty());
+                OSCL_ASSERT(PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR == iCurrErrHandlingCommand.front().iCmd);
+                iDRMResetPending = false;
+                HandleError(aResponse);
+            }
+        }
+        else if (id == iCPMGetMetaDataValuesCmdId)
+        {
+            /* End of GetNodeMetaDataValues */
+            OSCL_ASSERT(!iCurrentCommand.empty());
+            OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_SMFSP_NODE_GETNODEMETADATAVALUES);
+            CompleteGetMetaDataValues();
+        }
+        else if (id == iCPMGetLicenseCmdId)
+        {
+            CompleteGetLicense();
+        }
+        else
+        {
+            /* Unknown cmd ?? - error */
+            CommandComplete(iCurrentCommand,
+                            iCurrentCommand.front(),
+                            PVMFFailure);
+        }
+    }
+}
+
+void PVMFSMFSPBaseNode::CompleteGetMetaDataValues()
+{
+    CommandComplete(iCurrentCommand,
+                    iCurrentCommand.front(),
+                    PVMFSuccess);
+}
+
+void PVMFSMFSPBaseNode::CompleteDRMInit()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteDRMInit - In"));
+    if (iApprovedUsage.value.uint32_value !=
+            iRequestedUsage.value.uint32_value)
+    {
+        CommandComplete(iCurrentCommand,
+                        iCurrentCommand.front(),
+                        PVMFErrAccessDenied,
+                        NULL, NULL, NULL);
+        return;
+    }
+    //If protected content, get the decryption interface, if the intent is play
+    if (iCPMSourceData.iIntent & BITMASK_PVMF_SOURCE_INTENT_PLAY)
+    {
+        PVUuid uuid = PVMFCPMPluginDecryptionInterfaceUuid;
+        PVInterface* intf =
+            iCPMContentAccessFactory->CreatePVMFCPMPluginAccessInterface(uuid);
+        PVMFCPMPluginAccessInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFCPMPluginAccessInterface*, intf);
+        iDecryptionInterface = OSCL_STATIC_CAST(PVMFCPMPluginAccessUnitDecryptionInterface*, interimPtr);
+        if (iDecryptionInterface == NULL)
+        {
+            CommandComplete(iCurrentCommand,
+                            iCurrentCommand.front(),
+                            PVMFErrAccessDenied);
+            return;
+        }
+        iDecryptionInterface->Init();
+
+        RequestUsageComplete();
+    }
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteDRMInit Success"));
+    //License authentication was successfull. Init is completed at protected clip
+    SetState(EPVMFNodeInitialized);
+    CommandComplete(iCurrentCommand,
+                    iCurrentCommand.front(),
+                    PVMFSuccess);
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteDRMInit - Out"));
+    return;
+}
+
+bool PVMFSMFSPBaseNode::SetCPMKvps()
+{
+    if (iCPMCapConfigInterface && !iCPMKvpStore.isEmpty())
+    {
+        PVMFKvpVector *aVector = iCPMKvpStore.getKVPStore();
+        for (uint32 i = 0; i < aVector->size(); i++)
+        {
+            if (PVMFSuccess != SetCPMKvp((*aVector)[i]))
+            {
+                CommandComplete(iCurrentCommand,
+                                iCurrentCommand.front(),
+                                PVMFFailure);
+                iCPMKvpStore.destroy();
+                return false;
+            }
+        }
+        iCPMKvpStore.destroy();
+    }
+    return true;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::SetCPMKvp(PvmiKvp& aKVP)
+{
+    PVMFStatus status = PVMFSuccess;
+    PvmiKvp *aErrorKVP = NULL;
+    int32 leavecode = 0;
+    OSCL_TRY(leavecode, iCPMCapConfigInterface->setParametersSync(NULL, &aKVP, 1, aErrorKVP));
+    OSCL_FIRST_CATCH_ANY(leavecode,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPBaseNode::PushKeyToMetadataList - Memory allocation failure when copying metadata key"));
+                         status = leavecode);
+    return status;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::DoGetLicense(PVMFSMFSPBaseNodeCommand& aCmd,
+        bool aWideCharVersion)
+{
+    if (iCPMLicenseInterface == NULL)
+    {
+        return PVMFErrNotSupported;
+    }
+
+    if (aWideCharVersion == true)
+    {
+
+        OSCL_wString* contentName = NULL;
+        OsclAny* data = NULL;
+        uint32 dataSize = 0;
+        int32 timeoutMsec = 0;
+        aCmd.PVMFSMFSPBaseNodeCommand::Parse(contentName,
+                                             data,
+                                             dataSize,
+                                             timeoutMsec);
+        iCPMGetLicenseCmdId =
+            iCPMLicenseInterface->GetLicense(iCPMSessionID,
+                                             *contentName,
+                                             data,
+                                             dataSize,
+                                             timeoutMsec);
+    }
+    else
+    {
+        OSCL_String* contentName = NULL;
+        OsclAny* data = NULL;
+        uint32 dataSize = 0;
+        int32 timeoutMsec = 0;
+        aCmd.PVMFSMFSPBaseNodeCommand::Parse(contentName,
+                                             data,
+                                             dataSize,
+                                             timeoutMsec);
+        iCPMGetLicenseCmdId =
+            iCPMLicenseInterface->GetLicense(iCPMSessionID,
+                                             *contentName,
+                                             data,
+                                             dataSize,
+                                             timeoutMsec);
+    }
+    return PVMFPending;
+}
+
+void PVMFSMFSPBaseNode::CompleteGetLicense()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteGetLicense - called"));
+    CommandComplete(iCurrentCommand,
+                    iCurrentCommand.front(),
+                    PVMFSuccess);
+}
+
+void PVMFSMFSPBaseNode::DoCancelGetLicense(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoCancelGetLicense() Called"));
+    PVMFStatus status = PVMFErrArgument;
+
+    if (iCPMLicenseInterface == NULL)
+    {
+        status = PVMFErrNotSupported;
+    }
+    else
+    {
+        /* extract the command ID from the parameters.*/
+        PVMFCommandId id;
+        aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(id);
+
+        /* first check "current" command if any */
+        PVMFSMFSPBaseNodeCommand* cmd = iCurrentCommand.FindById(id);
+        if (cmd)
+        {
+            if (cmd->iCmd == PVMF_SMFSP_NODE_GET_LICENSE_W || cmd->iCmd == PVMF_SMFSP_NODE_GET_LICENSE)
+            {
+                iCPMCancelGetLicenseCmdId =
+                    iCPMLicenseInterface->CancelGetLicense(iCPMSessionID, iCPMGetLicenseCmdId);
+
+                /*
+                 * the queued commands are all asynchronous commands to the
+                 * CPM module. CancelGetLicense can cancel only for GetLicense cmd.
+                 * We need to wait CPMCommandCompleted.
+                 */
+                MoveCmdToCancelQueue(aCmd);
+                return;
+            }
+        }
+
+        /*
+         * next check input queue.
+         * start at element 1 since this cancel command is element 0.
+         */
+        cmd = iInputCommands.FindById(id, 1);
+        if (cmd)
+        {
+            if (cmd->iCmd == PVMF_SMFSP_NODE_GET_LICENSE_W || cmd->iCmd == PVMF_SMFSP_NODE_GET_LICENSE)
+            {
+                /* cancel the queued command */
+                CommandComplete(iInputCommands, *cmd, PVMFErrCancelled, NULL, NULL);
+                // report cancel success
+                CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+                return;
+            }
+        }
+    }
+    /* if we get here the command isn't queued so the cancel fails */
+    CommandComplete(iInputCommands, aCmd, status);
+    return;
+}
diff --git a/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_base_impl.cpp b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_base_impl.cpp
new file mode 100644
index 0000000..3b434ee
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_base_impl.cpp
@@ -0,0 +1,5500 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#include "pvmf_sm_fsp_base_impl.h"
+#endif
+
+#ifndef PVMF_BASIC_ERRORINFOMESSAGE_H_INCLUDED
+#include "pvmf_basic_errorinfomessage.h"
+#endif
+
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef PVMI_KVP_UTIL_H_INCLUDED
+#include "pvmi_kvp_util.h"
+#endif
+
+#ifndef PVMI_DRM_KVP_H_INCLUDED
+#include "pvmi_drm_kvp.h"
+#endif
+
+#ifndef PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
+#include "pvmf_sm_fsp_base_metadata.h"
+#endif
+
+#ifndef OSCL_SNPRINTF_H_INCLUDED
+#include "oscl_snprintf.h"
+#endif
+
+//////////////////////////////////////////////////
+// Node Constructor & Destructor
+//////////////////////////////////////////////////
+
+PVMFSMFSPBaseNode::PVMFSMFSPBaseNode(int32 aPriority): OsclActiveObject(aPriority, "PVMFSMFSPBaseNode")
+        , iPlayListRepositioningSupported(false)
+        , iMetaDataInfo(NULL)
+        , iUseCPMPluginRegistry(false)
+        , iSMBaseLogger(NULL)
+        , iChildNodeErrHandler(NULL)
+{
+    ResetNodeParams(false);
+    iCPM = NULL;
+}
+
+void PVMFSMFSPBaseNode::Construct()
+{
+    CreateCommandQueues();
+    iSessionSourceInfo = OSCL_NEW(PVMFSMFSPSessionSourceInfo, ());
+    iMetaDataInfo = OSCL_NEW(PVMFSMSessionMetaDataInfo, ());
+    iChildNodeErrHandler = PVMFSMFSPChildNodeErrorHandler::CreateErrHandler(this);
+}
+
+void PVMFSMFSPBaseNode::CreateCommandQueues()
+{
+    int32 err;
+    OSCL_TRY(err,
+             /*
+              * Create the input command queue.  Use a reserve to avoid lots of
+              * dynamic memory allocation.
+              */
+             iInputCommands.Construct(PVMF_SM_FSP_NODE_COMMAND_ID_START,
+                                      PVMF_SM_FSP_VECTOR_RESERVE);
+
+             /*
+              * Create the "current command" queue.  It will only contain one
+              * command at a time, so use a reserve of 1.
+              */
+             iCurrentCommand.Construct(0, 1);
+
+             /*
+              * Create the "cancel command" queue.  It will only contain one
+              * command at a time, so use a reserve of 1.
+              */
+             iCancelCommand.Construct(0, 1);
+
+             iErrHandlingCommandQ.Construct(0, 2);
+            );
+    if (err != OsclErrNone)
+    {
+        CleanUp();
+        OSCL_LEAVE(err);
+    }
+}
+
+PVMFSMFSPBaseNode::~PVMFSMFSPBaseNode()
+{
+    if (IsAdded())
+    {
+        Cancel();
+        RemoveFromScheduler();
+    }
+    CleanUp();
+}
+
+void PVMFSMFSPBaseNode::CleanUp()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CleanUp - In"));
+    ResetNodeParams();
+    if (iCPM != NULL)
+    {
+        iCPM->ThreadLogoff();
+        PVMFCPMFactory::DestroyContentPolicyManager(iCPM);
+        iCPM = NULL;
+    }
+    PVMFSMFSPChildNodeErrorHandler::DeleteErrHandler(iChildNodeErrHandler);
+    iChildNodeErrHandler = NULL;
+    iFSPChildNodeContainerVec.clear();
+    OSCL_DELETE(iMetaDataInfo);
+    OSCL_DELETE(iSessionSourceInfo);
+    iErrHandlingCommandQ.clear();
+    iCancelCommand.clear();
+    iCurrentCommand.clear();
+    iInputCommands.clear();
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CleanUp - Out"));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of virtuals declared in PVMFNodeInterface
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * Do thread-specific node creation and go to "Idle" state.
+ */
+PVMFStatus PVMFSMFSPBaseNode::ThreadLogon()
+{
+    PVMFStatus status = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeCreated:
+        {
+            if (!IsAdded())
+                AddToScheduler();
+            iCommandSeqLogger = PVLogger::GetLoggerObject("pvplayercmdseq.streamingmanager");
+            iSMBaseLogger = PVLogger::GetLoggerObject("PVMFSMFSPBaseNode");
+            /*
+             * Call thread logon for all the children nodes
+             */
+            for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+            {
+                if (iFSPChildNodeContainerVec[i].iNode->ThreadLogon() != PVMFSuccess)
+                {
+                    PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode - Child Node:ThreadLogon Failed, Node Tag %d", iFSPChildNodeContainerVec[i].iNodeTag));
+                    status = PVMFFailure;
+                    break;
+                }
+            }
+            if (PVMFSuccess == status)
+            {
+                PVMF_SM_FSP_BASE_LOGDEBUG((0, "PVMFSMFSPBaseNode::ThreadLogon() - State - EPVMFNodeIdle"));
+                SetState(EPVMFNodeIdle);
+            }
+        }
+        break;
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::ThreadLogon - Out %d status", status));
+    return (status);
+}
+
+/**
+ * Do thread-specific node cleanup and go to "Created" state.
+ */
+PVMFStatus PVMFSMFSPBaseNode::ThreadLogoff()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::ThreadLogoff - In"));
+
+    PVMFStatus status = PVMFSuccess;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        {
+            /* Reset the metadata key list */
+            /* Clean up CPM related variables */
+            /* Call thread logoff for all the children nodes */
+            for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+            {
+                PVMFNodeInterface* node = iFSPChildNodeContainerVec[i].iNode;
+                if (node->GetState() != EPVMFNodeCreated)
+                {
+                    if ((status = node->ThreadLogoff()) != PVMFSuccess)
+                    {
+                        PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode - Child Node:ThreadLogoff Failed, Node Tag %d status %d", iFSPChildNodeContainerVec[i].iNodeTag, status));
+                    }
+                }
+            }
+            ResetNodeParams();
+            SetState(EPVMFNodeCreated);
+            PVMF_SM_FSP_BASE_LOGDEBUG((0, "PVMFSMFSPBaseNode::ThreadLogoff() - State - EPVMFNodeIdle"));
+            iSMBaseLogger = NULL;
+            iLogger = NULL;
+            if (IsAdded())
+                RemoveFromScheduler();
+        }
+        break;
+
+        case EPVMFNodeCreated:
+            status = PVMFSuccess;
+            break;
+
+        default:
+            status = PVMFErrInvalidState;
+            break;
+    }
+    return (status);
+}
+
+/**
+ * Makes session with PVMFSMFSPBaseNode node.
+ * The purpose of this node(or of the concrete implementation of the node
+ * derived from this node) is to handle most of the commands, which otherwise
+ * would have been handled by the source node or various extension interfaces
+ * that would have been exposed by it [PVMFStreamingManagerNode].
+ * SM node and FSP will handle the command in mutually exclusive manner.
+ * Whatever command will be issued to source node. Firstly, Streaming Manager Node
+ * will try to service it. If SM node could not service it, it will route the
+ * command to the FSP.
+ * In order to send the response of the command completion (of the command
+ * serviced by the FSP) directly to the node connected to the SM Node,
+ * observer and the session id of the session for both the SM Node
+ * and the FSP should be same.
+ */
+PVMFSessionId PVMFSMFSPBaseNode::Connect(const PVMFNodeSessionInfo &aSessionInfo)
+{
+    OSCL_UNUSED_ARG(aSessionInfo);
+    OSCL_ASSERT(false);
+    return 0;
+}
+
+OSCL_EXPORT_REF PVMFSessionId PVMFSMFSPBaseNode::Connect(const PVMFNodeSession &aUpstreamSession)
+{
+    PVMFNodeSession session;
+    session.iId = aUpstreamSession.iId;
+    session.iInfo = aUpstreamSession.iInfo;
+    iSessions.push_back(session);
+    return session.iId;
+}
+
+/**
+ * retrieve node capabilities.
+ */
+PVMFStatus PVMFSMFSPBaseNode::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode:GetCapability"));
+    aNodeCapability = iCapability;
+    return PVMFSuccess;
+}
+
+/**
+ * retrive a port iterator.
+ */
+PVMFPortIter* PVMFSMFSPBaseNode::GetPorts(const PVMFPortFilter* aFilter)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode:GetPorts"));
+    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
+    return NULL;
+}
+
+//Implementation of Synchronous Commands
+
+/**
+ * Provides interface with uuid PVMF_DATA_SOURCE_INIT_INTERFACE_UUID to the caller
+*/
+bool PVMFSMFSPBaseNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::queryInterface - In"));
+
+    if (uuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)
+    {
+        iface = OSCL_STATIC_CAST(PVMFDataSourceInitializationExtensionInterface*, this);
+    }
+    else
+    {
+        PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::queryInterface() please call async version for this UUID."));
+        return false;
+    }
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::queryInterface - Out"));
+    return true;
+}
+
+//Asynchronous commands
+/**
+ * Queue an asynchronous QueryUUID command
+ * QueryUUID for the streaming manager node is not complete until QueryUUIDs
+ * are complete for all the children node (viz. session controller, jitter buffer
+ * controller etc)
+ */
+PVMFCommandId PVMFSMFSPBaseNode::QueryUUID(PVMFSessionId aSession
+        , const PvmfMimeString& aMimeType
+        , Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids
+        , bool aExactUuidsOnly
+        , const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aUuids);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+    OSCL_UNUSED_ARG(aContext);
+    PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::QueryUUID - Error not expected"));
+    OSCL_ASSERT(false);
+    return 0;
+}
+
+/**
+ * Queue an asynchronous node command QueryInterface
+ */
+PVMFCommandId PVMFSMFSPBaseNode::QueryInterface(PVMFSessionId aSession
+        , const PVUuid& aUuid
+        , PVInterface*& aInterfacePtr
+        , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::QueryInterface - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::QueryInterface - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - RequestPort
+ */
+PVMFCommandId PVMFSMFSPBaseNode::RequestPort(PVMFSessionId aSession
+        , int32 aPortTag
+        , const PvmfMimeString* aPortConfig
+        , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::RequestPort - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession,
+            PVMF_SMFSP_NODE_REQUESTPORT,
+            aPortTag,
+            aPortConfig,
+            aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::RequestPort - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - ReleasePort
+ */
+PVMFCommandId PVMFSMFSPBaseNode::ReleasePort(PVMFSessionId aSession
+        , PVMFPortInterface& aPort
+        , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::ReleasePort - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_RELEASEPORT, aPort, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::ReleasePort - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - Init
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Init(PVMFSessionId aSession, const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Init - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_INIT, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Init - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - Prepare
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Prepare(PVMFSessionId aSession
+        , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Prepare - In"));
+    /* Queue an internal command for Graph construct */
+    PVMFSMFSPBaseNodeCommand cmdGC;
+    cmdGC.PVMFSMFSPBaseNodeCommandBase::Construct(aSession,
+            PVMF_SMFSP_NODE_CONSTRUCT_SESSION,
+            NULL);
+
+    QueueCommandL(cmdGC);
+
+    PVMFSMFSPBaseNodeCommand cmdPrep;
+    cmdPrep.PVMFSMFSPBaseNodeCommandBase::Construct(aSession,
+            PVMF_SMFSP_NODE_PREPARE,
+            aContext);
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Prepare - Out"));
+    return QueueCommandL(cmdPrep);
+}
+
+/**
+ * Queue an asynchronous node command - Start
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Start(PVMFSessionId aSession
+                                       , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Start - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_START, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Start - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - Stop
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Stop(PVMFSessionId aSession
+                                      , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Stop - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_STOP, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Stop - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - Flush
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Flush(PVMFSessionId aSession
+                                       , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Flush - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_FLUSH, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Flush - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - Pause
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Pause(PVMFSessionId aSession
+                                       , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Pause - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_PAUSE, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Pause - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - Reset
+ */
+PVMFCommandId PVMFSMFSPBaseNode::Reset(PVMFSessionId aSession
+                                       , const OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Reset - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_RESET, aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::Reset - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - CancelAllCommands
+ */
+PVMFCommandId PVMFSMFSPBaseNode::CancelAllCommands(PVMFSessionId aSession
+        , const OsclAny* aContextData)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode:CancelAllCommands"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_CANCELALLCOMMANDS, aContextData);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CancelAllCommands - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - CancelCommand
+ */
+PVMFCommandId PVMFSMFSPBaseNode::CancelCommand(PVMFSessionId aSession
+        , PVMFCommandId aCmdId
+        , const OsclAny* aContextData)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode:CancelCommand CommandId [%d]", aCmdId));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommandBase::Construct(aSession, PVMF_SMFSP_NODE_CANCELCOMMAND, aCmdId, aContextData);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CancelCommand - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ *Implementation of HandlePortActivity
+ */
+void PVMFSMFSPBaseNode::HandlePortActivity(const PVMFPortActivity& aActivity)
+{
+    OSCL_UNUSED_ARG(aActivity);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode:HandlePortActivity - Not Implemented"));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Implementation of virtuals from OsclActiveObject
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMFSPBaseNode::Run()
+{
+    if (EPVMFNodeError == iInterfaceState)
+    {
+        if (!iErrHandlingCommandQ.empty())
+        {
+            if (ProcessCommand(iErrHandlingCommandQ.front()))
+            {
+                /*
+                 * re-schedule if more commands to do
+                 * and node isn't reset.
+                 */
+                if (!iErrHandlingCommandQ.empty() && iInterfaceState != EPVMFNodeCreated)
+                {
+                    if (IsAdded())
+                    {
+                        RunIfNotReady();
+                    }
+                }
+                return;
+            }
+        }
+        return;
+    }
+    /* Process commands */
+    if (!iInputCommands.empty())
+    {
+        if (ProcessCommand(iInputCommands.front()))
+        {
+            /*
+             * re-schedule if more commands to do
+             * and node isn't reset.
+             */
+            if (!iInputCommands.empty() && iInterfaceState != EPVMFNodeCreated)
+            {
+                if (IsAdded())
+                {
+                    RunIfNotReady();
+                }
+            }
+            return;
+        }
+    }
+
+    /*
+     * If we get here we did not process any commands.
+     * Check for completion of a flush command...
+     */
+    if (FlushPending())
+    {
+        /*
+         * Flush is complete.  Go to initialized state.
+         */
+        SetState(EPVMFNodeInitialized);
+        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+}
+
+void PVMFSMFSPBaseNode::DoCancel()
+{
+    /* the base class cancel operation is sufficient */
+    OsclActiveObject::DoCancel();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implemenataion fo pure virtual asyn calls from PvmiCapabilityAndConfig
+///////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PVMFSMFSPBaseNode::setParametersAsync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements,
+        PvmiKvp*& aRet_kvp,
+        OsclAny* context)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::setParametersAsync - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(0,
+                                            PVMF_SMFSP_NODE_CAPCONFIG_SETPARAMS,
+                                            aSession, aParameters, num_elements, aRet_kvp, context);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::setParametersAsync - Out"));
+    return QueueCommandL(cmd);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of PvmfDataSourcePlaybackControlInterface's async pure virtual func
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * Queue an asynchronous node command - SetDataSourcePosition
+ */
+PVMFCommandId PVMFSMFSPBaseNode::SetDataSourcePosition(PVMFSessionId aSessionId,
+        PVMFTimestamp aTargetNPT,
+        PVMFTimestamp& aActualNPT,
+        PVMFTimestamp& aActualMediaDataTS,
+        bool aSeekToSyncPoint,
+        uint32 aStreamID,
+        OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SetDataSourcePosition - In"));
+
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION,
+                                            aTargetNPT,
+                                            &aActualNPT,
+                                            &aActualMediaDataTS,
+                                            aSeekToSyncPoint,
+                                            aStreamID,
+                                            aContext);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SetDataSourcePosition - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - SetDataSourcePosition (if supported)
+ */
+PVMFCommandId PVMFSMFSPBaseNode::SetDataSourcePosition(PVMFSessionId aSessionId,
+        PVMFDataSourcePositionParams& aPVMFDataSourcePositionParams,
+        OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SetDataSourcePosition - Playlist In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    if (iPlayListRepositioningSupported)
+    {
+        cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                                PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION,
+                                                &aPVMFDataSourcePositionParams,
+                                                aContext);
+        iPlayListRepositioning = true;
+    }
+    else
+    {
+        PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::SetDataSourcePosition - PlayList - Not Supported for non RTSP"));
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SetDataSourcePosition - Playlist Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - QueryDataSourcePosition
+ */
+PVMFCommandId PVMFSMFSPBaseNode::QueryDataSourcePosition(PVMFSessionId aSessionId,
+        PVMFTimestamp aTargetNPT,
+        PVMFTimestamp& aActualNPT,
+        bool aSeekToSyncPoint,
+        OsclAny* aContext
+                                                        )
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::QueryDataSourcePosition - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_QUERY_DATASOURCE_POSITION,
+                                            aTargetNPT,
+                                            &aActualNPT,
+                                            aSeekToSyncPoint,
+                                            aContext);
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::QueryDataSourcePosition - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - QueryDataSourcePosition
+ */
+PVMFCommandId PVMFSMFSPBaseNode::QueryDataSourcePosition(PVMFSessionId aSessionId,
+        PVMFTimestamp aTargetNPT,
+        PVMFTimestamp& aSyncBeforeTargetNPT,
+        PVMFTimestamp& aSyncAfterTargetNPT,
+        OsclAny* aContext,
+        bool aSeekToSyncPoint
+                                                        )
+{
+    // This is only to comply the interface file change due to Mp4 parser node.
+    // Actual testing/supportfs will be done here if required.
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::QueryDataSourcePosition - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_QUERY_DATASOURCE_POSITION,
+                                            aTargetNPT,
+                                            &aSyncBeforeTargetNPT,
+                                            &aSyncAfterTargetNPT,
+                                            aContext,
+                                            aSeekToSyncPoint);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::QueryDataSourcePosition - Out"));
+    return QueueCommandL(cmd);
+}
+
+/**
+ * Queue an asynchronous node command - SetDataSourceRate (if supported)
+ */
+PVMFCommandId PVMFSMFSPBaseNode::SetDataSourceRate(PVMFSessionId aSessionId,
+        int32 aRate,
+        PVMFTimebase* aTimebase,
+        OsclAny* aContext)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SetDataSourceRate - In"));
+    OSCL_UNUSED_ARG(aSessionId);
+    OSCL_UNUSED_ARG(aRate);
+    OSCL_UNUSED_ARG(aTimebase);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::SetDataSourceRate - Out"));
+    return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of virtuals declared in PVMFMetadataExtensionInterface
+///////////////////////////////////////////////////////////////////////////////
+uint32 PVMFSMFSPBaseNode::GetNumMetadataKeysBase(char* aQueryKeyString)
+{
+    uint32 num_entries = 0;
+
+    if (aQueryKeyString == NULL)
+    {
+        // No query key so just return all the available keys
+        num_entries = iAvailableMetadataKeys.size();
+    }
+    else
+    {
+        // Determine the number of metadata keys based on the query key string provided
+        uint32 i;
+        for (i = 0; i < iAvailableMetadataKeys.size(); i++)
+        {
+            // Check if the key matches the query key
+            if (pv_mime_strcmp(iAvailableMetadataKeys[i].get_cstr(), aQueryKeyString) >= 0)
+            {
+                num_entries++;
+            }
+        }
+    }
+
+    if ((iCPMMetaDataExtensionInterface != NULL) && (iSessionSourceInfo->iDRMProtected  == true))
+    {
+        num_entries +=
+            iCPMMetaDataExtensionInterface->GetNumMetadataKeys(aQueryKeyString);
+    }
+
+    return num_entries;
+}
+
+uint32 PVMFSMFSPBaseNode::GetNumMetadataValuesBase(PVMFMetadataList& aKeyList)
+{
+
+    uint32 numkeys = aKeyList.size();
+
+    if ((numkeys == 0) || !(iMetaDataInfo->iMetadataAvailable))
+    {
+        return 0;
+    }
+
+    // Get Num Tracks
+    uint32 numtracks = iMetaDataInfo->iNumTracks;
+
+    uint32 numvalentries = 0;
+    for (uint32 lcv = 0; lcv < numkeys; lcv++)
+    {
+        if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_ALBUM_KEY) == 0 &&
+                iMetaDataInfo->iAlbumPresent)
+        {
+            // Album
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_AUTHOR_KEY) == 0 &&
+                 iMetaDataInfo->iAuthorPresent)
+        {
+            // Author
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_ARTIST_KEY) == 0 &&
+                 iMetaDataInfo->iPerformerPresent)
+        {
+            // Artist/performer
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TITLE_KEY) == 0 &&
+                 iMetaDataInfo->iTitlePresent)
+        {
+            // Title
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY) == 0 &&
+                 iMetaDataInfo->iDescriptionPresent)
+        {
+            // Description
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RATING_KEY) == 0 &&
+                 iMetaDataInfo->iRatingPresent)
+        {
+            // Rating
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY) == 0 &&
+                 iMetaDataInfo->iCopyRightPresent)
+        {
+            // Copyright
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_GENRE_KEY) == 0 &&
+                 iMetaDataInfo->iGenrePresent)
+        {
+            // Genre
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LYRICS_KEY) == 0 &&
+                 iMetaDataInfo->iLyricsPresent)
+        {
+            // Lyrics
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY) == 0 &&
+                 iMetaDataInfo->iClassificationPresent)
+        {
+            // Classification
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_KEYWORDS_KEY) == 0 &&
+                 iMetaDataInfo->iKeyWordsPresent)
+        {
+            // Keywords
+            // Increment the counter for the number of values found so far
+            numvalentries += iMetaDataInfo->iNumKeyWords;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LOCATION_KEY) == 0 &&
+                 iMetaDataInfo->iLocationPresent)
+        {
+            // Location
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DURATION_KEY) == 0)
+        {
+            // Session Duration
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY) == 0 &&
+                 numtracks > 0)
+        {
+            // Number of tracks
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY) == 0)
+        {
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_YEAR_KEY) == 0)
+        {
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY) == 0 &&
+                 iMetaDataInfo->iWMPicturePresent)
+        {
+            // Num Picture
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_GRAPHICS_KEY) == 0 &&
+                 iMetaDataInfo->iWMPicturePresent)
+        {
+            // Picture
+            // Increment the counter for the number of values found so far
+            uint32 startindex = 0;
+            const uint32 numPictures = iMetaDataInfo->iWMPictureIndexVec.size();
+            uint32 endindex = numPictures - 1;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+
+            /* Validate the indices */
+            if (startindex > endindex || startindex >= numPictures || endindex >= numPictures)
+            {
+                continue;
+            }
+
+            // Increment the counter for the number of values found so far
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY) != NULL)
+        {
+            // Track type
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = numtracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
+            {
+                continue;
+            }
+
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackMetaDataInfo.iMimeType.get_cstr())
+                    {
+                        numvalentries ++;
+                    }
+                }
+            }
+
+        }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY) != NULL)
+        {
+            // Track duration
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = numtracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
+            {
+                continue;
+            }
+
+            // Increment the counter for the number of values found so far
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY) != NULL)
+        {
+            // Track selected
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = numtracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
+            {
+                continue;
+            }
+            // Increment the counter for the number of values found so far
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY) == 0)
+        {
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY) != NULL))
+        {
+            /*
+             * Codec Name
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackMetaDataInfo.iCodecName.get_size() > 0)
+                    {
+                        ++numvalentries;
+                    }
+                }
+            }
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackInfo.iCodecDescription.get_size() > 0)
+                    {
+                        ++numvalentries;
+                    }
+                }
+            }
+        }
+        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY) != NULL))
+        {
+            /*
+             * Codec Description
+             * Determine the index requested.
+             */
+            uint32 startindex = 0;
+            uint32 endindex   = 0;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(),
+                                             PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if ((startindex > endindex) ||
+                    (startindex >= (uint32)numtracks) ||
+                    (endindex >= (uint32)numtracks))
+            {
+                continue;
+            }
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackInfo.iCodecSpecificInfo.getMemFragPtr())
+                    {
+                        ++numvalentries;
+                    }
+                }
+            }
+        }
+        else if ((oscl_strcmp(aKeyList[lcv].get_cstr(), PVMF_DRM_INFO_IS_PROTECTED_QUERY) == 0)
+                 && ((iUseCPMPluginRegistry == false) || (iSessionSourceInfo->iDRMProtected == false)))
+        {
+            /*
+             * is-protected
+             * Increment the counter for the number of values found so far
+             */
+            ++numvalentries;
+        }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY) != NULL)
+        {
+            // Track bitrate
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = numtracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
+            {
+                continue;
+            }
+            // Increment the counter for the number of values found so far
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY) != NULL)
+        {
+            ++numvalentries;
+        }
+        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY) != NULL)
+        {
+            // Track bitrate
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = numtracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
+            {
+                continue;
+            }
+
+            // Increment the counter for the number of values found so far
+            numvalentries += (endindex + 1 - startindex);
+        }
+        else
+        {
+            /* Check the extended meta data list */
+            for (uint32 i = 0; i < iMetaDataInfo->iExtendedMetaDataNameVec.size(); i++)
+            {
+                OSCL_HeapString<OsclMemAllocator> extMetaDataName =
+                    iMetaDataInfo->iExtendedMetaDataNameVec[i];
+                if (oscl_strcmp(aKeyList[lcv].get_cstr(), extMetaDataName.get_cstr()) == 0)
+                {
+                    /*
+                     * Increment the counter for the number of values found so far
+                     */
+                    ++numvalentries;
+                }
+            }
+        }
+    }
+    if ((iCPMMetaDataExtensionInterface != NULL) &&
+            (iSessionSourceInfo->iDRMProtected  == true))
+    {
+        numvalentries +=
+            iCPMMetaDataExtensionInterface->GetNumMetadataValues(aKeyList);
+    }
+
+    return numvalentries; // Number of elements
+}
+
+PVMFCommandId PVMFSMFSPBaseNode::GetNodeMetadataKeys(PVMFSessionId aSessionId,
+        PVMFMetadataList& aKeyList,
+        uint32 aStartingKeyIndex,
+        int32 aMaxKeyEntries,
+        char* aQueryKeyString,
+        const OsclAny* aContextData)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetNodeMetadataKeys - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_GETNODEMETADATAKEYS,
+                                            aKeyList,
+                                            aStartingKeyIndex,
+                                            aMaxKeyEntries,
+                                            aQueryKeyString,
+                                            aContextData);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetNodeMetadataKeys - Out"));
+    return QueueCommandL(cmd);
+}
+
+PVMFCommandId PVMFSMFSPBaseNode::GetNodeMetadataValues(PVMFSessionId aSessionId,
+        PVMFMetadataList& aKeyList,
+        Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+        uint32 aStartingValueIndex,
+        int32 aMaxValueEntries,
+        const OsclAny* aContextData)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetNodeMetadataValues - In"));
+    PVMFSMFSPBaseNodeCommand cmd;
+    cmd.PVMFSMFSPBaseNodeCommand::Construct(aSessionId,
+                                            PVMF_SMFSP_NODE_GETNODEMETADATAVALUES,
+                                            aKeyList,
+                                            aValueList,
+                                            aStartingValueIndex,
+                                            aMaxValueEntries,
+                                            aContextData);
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::GetNodeMetadataValues - Out"));
+    return QueueCommandL(cmd);
+}
+
+PVMFStatus PVMFSMFSPBaseNode::ReleaseNodeMetadataKeysBase(PVMFMetadataList& aKeyList,
+        uint32 aStartingKeyIndex,
+        uint32 aEndKeyIndex)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ReleaseNodeMetadataKeys() called"));
+    OSCL_UNUSED_ARG(aKeyList);
+    OSCL_UNUSED_ARG(aStartingKeyIndex);
+    OSCL_UNUSED_ARG(aEndKeyIndex);
+    //nothing needed-- there's no dynamic allocation in this node's key list
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::ReleaseNodeMetadataValuesBase(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+        uint32 aStartingValueIndex,
+        uint32 aEndValueIndex)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ReleaseNodeMetadataValues() called"));
+
+    if (aStartingValueIndex > aEndValueIndex || aValueList.size() == 0)
+    {
+        PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ReleaseNodeMetadataValues() Invalid start/end index"));
+        return PVMFErrArgument;
+    }
+
+    //Only CPM related metadata is retrived. Then this one should be 0.
+    if (iPVMFStreamingManagerNodeMetadataValueCount == 0) return PVMFSuccess;
+
+    //To remove madatada related with un-drm value
+    aEndValueIndex = iPVMFStreamingManagerNodeMetadataValueCount - 1;
+    if (aEndValueIndex >= aValueList.size())
+    {
+        aEndValueIndex = aValueList.size() - 1;
+    }
+
+    for (uint32 i = aStartingValueIndex; i <= aEndValueIndex; i++)
+    {
+        if (aValueList[i].key != NULL)
+        {
+            switch (GetValTypeFromKeyString(aValueList[i].key))
+            {
+                case PVMI_KVPVALTYPE_WCHARPTR:
+                    if (aValueList[i].value.pWChar_value != NULL)
+                    {
+                        OSCL_ARRAY_DELETE(aValueList[i].value.pWChar_value);
+                        aValueList[i].value.pWChar_value = NULL;
+                    }
+                    break;
+
+                case PVMI_KVPVALTYPE_CHARPTR:
+                    if (aValueList[i].value.pChar_value != NULL)
+                    {
+                        OSCL_ARRAY_DELETE(aValueList[i].value.pChar_value);
+                        aValueList[i].value.pChar_value = NULL;
+                    }
+                    break;
+
+                case PVMI_KVPVALTYPE_UINT8PTR:
+                    if (aValueList[i].value.pUint8_value != NULL)
+                    {
+                        OSCL_ARRAY_DELETE(aValueList[i].value.pUint8_value);
+                        aValueList[i].value.pUint8_value = NULL;
+                    }
+                    break;
+
+                case PVMI_KVPVALTYPE_UINT32:
+                case PVMI_KVPVALTYPE_FLOAT:
+                case PVMI_KVPVALTYPE_BOOL:
+                    // No need to free memory for this valtype
+                    break;
+
+                case PVMI_KVPVALTYPE_KSV:
+                {
+                    //PVMFSTREAMINGMGRNODE_GRAPHICS_KEY value need to be freed in derived class (cos alocation also took there)
+                }
+                break;
+
+                default:
+                    // Should not get a value that wasn't created from this node
+                    OSCL_ASSERT(false);
+                    break;
+            }
+
+            OSCL_ARRAY_DELETE(aValueList[i].key);
+            aValueList[i].key = NULL;
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of virtuals declared in PVMFNodeErrorEventObserver
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMFSPBaseNode::HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::HandleNodeErrorEvent - In iInterfaceState[%d]", iInterfaceState));
+    //If node is already in error state, then dont propagate the err event up and ignore it
+    if (EPVMFNodeError == iInterfaceState)
+    {
+        return;
+    }
+    //check if the err event is fatal err event (requires err handling to be done)
+    //if yes, then move the node in err state and propagate the err event up ONLY after completion of err handling
+    if (IsFatalErrorEvent(aEvent.GetEventType()))
+    {
+        PVMF_SM_FSP_BASE_LOGDEBUG((0, "PVMFSMFSPBaseNode::HandleNodeErrorEvent - Fatal Error"));
+        //Do we have a pending command in current command Q/Cancel Q
+
+        if (EPVMFNodeError != iInterfaceState)
+        {
+            SetState(EPVMFNodeError);
+            iChildNodeErrHandler->InitiateErrorHandling(aEvent);
+        }
+    }
+    return;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of some asyn functions of PVMFNodeInterface serviced in the
+//base class
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMFSPBaseNode::DoCancelAllCommands(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoCancelAllCommands In"));
+
+    //first cancel the current command if any
+    if (iCurrentCommand.size() > 0)
+    {
+        PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoCancelAllCommands iCurrentCommand.size()>0"));
+        {
+            //We wipe all node cmd states, since we are no longer going to care about cmd completes
+            //coming from nodes for anything other than cancelall
+            ResetNodeContainerCmdState();
+            for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+            {
+                PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                if (internalCmd != NULL)
+                {
+                    internalCmd->cmd =
+                        iFSPChildNodeContainerVec[i].commandStartOffset +
+                        PVMF_SM_FSP_NODE_INTERNAL_CANCEL_ALL_OFFSET;
+                    internalCmd->parentCmd = PVMF_SMFSP_NODE_CANCELALLCOMMANDS;
+                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+                    PVMFNodeInterface* iNode = iFSPChildNodeContainerVec[i].iNode;
+                    iNode->CancelAllCommands(iFSPChildNodeContainerVec[i].iSessionId, cmdContextData);
+                    iFSPChildNodeContainerVec[i].iNodeCmdState = PVMFSMFSP_NODE_CMD_CANCEL_PENDING;
+                }
+                else
+                {
+                    PVMF_SM_FSP_BASE_LOGERR((0, "PVMFStreamingManagerNode:DoCancelAllCommands:RequestNewInternalCmd - Failed"));
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                    return;
+                }
+            }
+        }
+        MoveCmdToCancelQueue(aCmd);
+    }
+    else
+    {
+        //Assumptions:
+        //Command in front of input Q is cancel command.
+        //None of other commands in the input queue is hipri cmd, and hence are store in the order of their cmd id's
+        //All commands in the input Q with command id < command id of the cancel command need to be completed
+        //with cancelled status.
+        const int32 cancelCmdId = iInputCommands.front().iId;
+        const int32 inputCmndsSz = iInputCommands.size();
+        for (int ii = inputCmndsSz - 1; ii > 0 ; ii--) //we dont want to process element at index 0 (being cancel command)
+        {
+            if (iInputCommands[ii].iId < cancelCmdId)
+            {
+                if (IsInternalCmd(iInputCommands[ii].iCmd))
+                {
+                    InternalCommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+                }
+                else
+                {
+                    CommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+                }
+            }
+        }
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess); //complete the cancel all command
+    }
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoCancelAllCommands Out"));
+}
+
+void PVMFSMFSPBaseNode::DoCancelAllPendingCommands(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoCancelAllPendingCommands In"));
+    //First cancel the current command if any...
+    if (iCurrentCommand.size() > 0)
+    {
+        PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoCancelAllPendingCommands iCurrentCommand.size()>0"));
+        {
+            for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+            {
+                if (iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+                {
+                    PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                    if (internalCmd != NULL)
+                    {
+                        internalCmd->cmd =
+                            iFSPChildNodeContainerVec[i].commandStartOffset +
+                            PVMF_SM_FSP_NODE_INTERNAL_CANCEL_ALL_OFFSET;
+                        internalCmd->parentCmd = PVMF_SMFSP_NODE_CANCELALLCOMMANDS;
+                        OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+                        PVMFNodeInterface* iNode = iFSPChildNodeContainerVec[i].iNode;
+                        iNode->CancelAllCommands(iFSPChildNodeContainerVec[i].iSessionId, cmdContextData);
+                        iFSPChildNodeContainerVec[i].iNodeCmdState = PVMFSMFSP_NODE_CMD_CANCEL_PENDING;
+                    }
+                    else
+                    {
+                        PVMF_SM_FSP_BASE_LOGERR((0, "PVMFStreamingManagerNode:DoCancelAllPendingCommands:RequestNewInternalCmd - Failed"));
+                        CommandComplete(iErrHandlingCommandQ, aCmd, PVMFErrNoMemory);
+                        return;
+                    }
+                }
+            }
+        }
+        MoveErrHandlingCmdToCurErrHandlingQ(aCmd);
+    }
+    else
+    {
+        iChildNodeErrHandler->ErrHandlingCommandComplete(iErrHandlingCommandQ, aCmd, PVMFSuccess);
+    }
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoCancelAllPendingCommands Out"));
+}
+
+void PVMFSMFSPBaseNode::DoResetDueToErr(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoResetDueToErr - In"));
+    /* this node allows a reset from any state, as long as the AO is in scheduler queue */
+    OSCL_ASSERT(IsAdded());
+    /*
+     * Reset for streaming manager cannot be completed unless
+     * Reset for all the children nodes are complete
+     */
+    if ((iCPM) && (iSessionSourceInfo->iDRMProtected == true) && iDRMResetPending == false)
+    {
+        iDRMResetPending = true;
+        SendUsageComplete();
+    }
+
+
+    PVMFSMFSPChildNodeContainerVector::iterator it;
+    for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+    {
+        PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+        if (internalCmd != NULL)
+        {
+            internalCmd->cmd =
+                it->commandStartOffset +
+                PVMF_SM_FSP_NODE_INTERNAL_RESET_CMD_OFFSET;
+            internalCmd->parentCmd = aCmd.iCmd;
+            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+            PVMFNodeInterface* iNode = it->iNode;
+            iNode->Reset(it->iSessionId, cmdContextData);
+            it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+        }
+        else
+        {
+            PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode:DoReset:RequestNewInternalCmd - Failed"));
+            CommandComplete(iErrHandlingCommandQ, aCmd, PVMFErrNoMemory);
+            return;
+        }
+    }
+    MoveErrHandlingCmdToCurErrHandlingQ(aCmd);
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoResetDueToErr - Out"));
+}
+
+void PVMFSMFSPBaseNode::CompleteChildNodesCmdCancellation()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteCancelAll - In"));
+    if (CheckChildrenNodesCancelAll())
+    {
+        if (PVMF_SMFSP_NODE_CANCELALLCOMMANDS == iCancelCommand.front().iCmd)
+        {
+            /*
+             * CancelAllCommands is issued by upper layer
+             */
+            if (!iCurrentCommand.empty())
+            {
+                if (IsInternalCmd(iCurrentCommand.front().iCmd) == false)
+                {
+                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                }
+                else
+                {
+                    InternalCommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                }
+            }
+
+            //Assumptions:
+            //Command in front of cancel Q is cancelall command.
+            //None of commands in the input queue is hipri cmd, and hence are store in the order of their cmd id's
+            //All commands in the input Q with command id < command id of the cancel command need to be completed
+            //with cancelled status.
+            const int32 cancelCmdId = iCancelCommand.front().iId;
+            const int32 inputCmndsSz = iInputCommands.size();
+            for (int ii = inputCmndsSz - 1; ii >= 0 ; ii--)
+            {
+                if (iInputCommands[ii].iId < cancelCmdId)
+                {
+                    if (IsInternalCmd(iInputCommands[ii].iCmd))
+                    {
+                        InternalCommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+                    }
+                    else
+                    {
+                        CommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+                    }
+                }
+            }
+
+            /* finally send command complete for the cancel all command */
+            PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteCancelAll - CancelAllCommands complete"));
+            CommandComplete(iCancelCommand,
+                            iCancelCommand.front(),
+                            PVMFSuccess);
+        }
+        else if (PVMF_SMFSP_NODE_CANCELCOMMAND == iCancelCommand.front().iCmd)
+        {
+            if (!iCurrentCommand.empty())
+            {
+                if (IsInternalCmd(iCurrentCommand.front().iCmd) == false)
+                {
+                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                }
+                else
+                {
+                    InternalCommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                }
+            }
+            /* end command complete for the cancel all command */
+            PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteCancelAll - CancelCmd complete"));
+            CommandComplete(iCancelCommand,
+                            iCancelCommand.front(),
+                            PVMFSuccess);
+        }
+    }
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteCancelAll - Out"));
+    return;
+}
+
+bool PVMFSMFSPBaseNode::CheckChildrenNodesCancelAll()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+void PVMFSMFSPBaseNode::DoCancelCommand(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    //todo:need to implement
+    OSCL_UNUSED_ARG(aCmd);
+    OSCL_ASSERT(false);
+}
+
+/**
+ * Called by the command handler AO to do the node Reset.
+ */
+void PVMFSMFSPBaseNode::DoReset(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoReset - In"));
+    /* this node allows a reset from any state, as long as the AO is in scheduler queue */
+    OSCL_ASSERT(IsAdded());
+    /*
+     * Reset for streaming manager cannot be completed unless
+     * Reset for all the children nodes are complete
+     */
+    if ((iCPM) && (iSessionSourceInfo->iDRMProtected == true) && iDRMResetPending == false)
+    {
+        iDRMResetPending = true;
+        SendUsageComplete();
+    }
+
+    bool childNodeResetPending = false;
+    PVMFSMFSPChildNodeContainerVector::iterator it;
+    for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+    {
+        if (EPVMFNodeCreated != it->iNode->GetState())
+        {
+            PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+            if (internalCmd != NULL)
+            {
+                internalCmd->cmd =
+                    it->commandStartOffset +
+                    PVMF_SM_FSP_NODE_INTERNAL_RESET_CMD_OFFSET;
+                internalCmd->parentCmd = aCmd.iCmd;
+                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+                PVMFNodeInterface* iNode = it->iNode;
+                iNode->Reset(it->iSessionId, cmdContextData);
+                childNodeResetPending = true;
+                it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+            }
+            else
+            {
+                PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode:DoReset:RequestNewInternalCmd - Failed"));
+                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                return;
+            }
+        }
+    }
+
+    if (iDRMResetPending || childNodeResetPending)
+        MoveCmdToCurrentQueue(aCmd);
+    else
+    {
+        PVMFStatus status = ThreadLogoff();
+        CommandComplete(iInputCommands, aCmd, status);
+    }
+
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoReset - Out"));
+}
+
+
+
+void PVMFSMFSPBaseNode::CompleteReset()
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteReset - In"));
+    if (CheckChildrenNodesReset() && iDRMResetPending == false)
+    {
+        ResetNodeContainerCmdState();
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            /* Indicates that the init for Children Nodes was successfull */
+            /* At protected clip, Reset CPM also was successfull */
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if (aCmd.iCmd == PVMF_SMFSP_NODE_RESET)
+            {
+                /* logoff & go back to Created state */
+                SetState(EPVMFNodeIdle);
+                /* Reset Params */
+                ResetNodeParams();
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+    }
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::CompleteReset - Out"));
+    return;
+}
+
+void PVMFSMFSPBaseNode::CompleteResetDueToErr()
+{
+    ResetNodeContainerCmdState();
+    //check the state of the child nodes
+    bool childNodesResetSucccessful = true;
+
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        TPVMFNodeInterfaceState childNodeState = iFSPChildNodeContainerVec[i].iNode->GetState();
+        if ((childNodeState != EPVMFNodeIdle) && (childNodeState != EPVMFNodeCreated))
+        {
+            childNodesResetSucccessful = false;
+            break;
+        }
+    }
+
+    if (childNodesResetSucccessful)
+    {
+        SetState(EPVMFNodeIdle);
+        /* Reset Params */
+        ResetNodeParams();
+    }
+    else
+    {
+        OSCL_ASSERT(false);
+    }
+}
+
+bool PVMFSMFSPBaseNode::CheckChildrenNodesReset()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+void PVMFSMFSPBaseNode::DoFlush(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoFlush - In"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        {
+            /*
+             * Flush for streaming manager cannot be completed unless
+             * Flush for all the children nodes are complete
+             */
+            PVMFSMFSPChildNodeContainerVector::iterator it;
+            for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+            {
+                PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                if (internalCmd != NULL)
+                {
+                    internalCmd->cmd =
+                        it->commandStartOffset +
+                        PVMF_SM_FSP_NODE_INTERNAL_FLUSH_CMD_OFFSET;
+                    internalCmd->parentCmd = aCmd.iCmd;
+
+                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                    PVMFNodeInterface* iNode = it->iNode;
+
+                    iNode->Flush(it->iSessionId, cmdContextData);
+                    it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                }
+                else
+                {
+                    PVMF_SM_FSP_BASE_LOGERR((0, "StreamingManagerNode:DoFlush:RequestNewInternalCmd - Failed"));
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                    return;
+                }
+            }
+            MoveCmdToCurrentQueue(aCmd);
+            /*
+             * Notify all ports to suspend their input - TBD
+             */
+            /*
+             * If the node is not running we need to wakeup the
+             * AO to further complete the flush, which means all
+             * port activity needs to be completed.
+             */
+            if (IsAdded())
+            {
+                RunIfNotReady();
+            }
+        }
+        break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoFlush - Out"));
+}
+
+void PVMFSMFSPBaseNode::CompleteFlush()
+{
+    /*
+    * If the node is not running we need to wakeup the
+    * AO to further complete the flush, which means all
+    * port activity needs to be completed.
+    */
+    if (iInterfaceState != EPVMFNodeStarted)
+    {
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+    return;
+}
+
+bool PVMFSMFSPBaseNode::CheckChildrenNodesFlush()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+/**
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of virtuals declared in PVMFSMFSPBaseNode
+///////////////////////////////////////////////////////////////////////////////
+*/
+
+void PVMFSMFSPBaseNode::ReportInfoEvent(PVMFEventType aEventType,
+                                        OsclAny* aEventData,
+                                        PVUuid* aEventUUID,
+                                        int32* aEventCode)
+
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::NodeInfoEvent Type %d Data %d"
+                                    , aEventType, aEventData));
+
+    if (aEventUUID && aEventCode)
+    {
+        PVMFBasicErrorInfoMessage* eventmsg =
+            OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        PVMFAsyncEvent asyncevent(PVMFInfoEvent,
+                                  aEventType,
+                                  NULL,
+                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
+                                  aEventData,
+                                  NULL,
+                                  0);
+        PVMFNodeInterface::ReportInfoEvent(asyncevent);
+        eventmsg->removeRef();
+    }
+    else
+    {
+        PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
+    }
+}
+
+
+void PVMFSMFSPBaseNode::CommandComplete(PVMFFSPNodeCmdQ& aCmdQ,
+                                        PVMFSMFSPBaseNodeCommand& aCmd,
+                                        PVMFStatus aStatus,
+                                        OsclAny* aEventData,
+                                        PVUuid* aEventUUID,
+                                        int32* aEventCode,
+                                        PVInterface* aExtMsg,
+                                        uint32 aEventDataLen)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
+                                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    PVInterface* extif = NULL;
+    PVMFBasicErrorInfoMessage* errormsg = NULL;
+    if (aExtMsg)
+    {
+        extif = aExtMsg;
+    }
+    else if (aEventUUID && aEventCode)
+    {
+        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
+    }
+
+    /* create response */
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
+    if (aEventDataLen != 0)
+    {
+        resp.SetEventDataLen(aEventDataLen);
+    }
+
+    if (ErrorHandlingRequired(aStatus))
+    {
+        HandleError(resp);
+        if (errormsg)
+        {
+            errormsg->removeRef();
+        }
+        return;
+    }
+
+    PVMFSessionId session = aCmd.iSession;
+
+    /* Erase the command from the queue */
+    aCmdQ.Erase(&aCmd);
+
+    /* Report completion to the session observer */
+    ReportCmdCompleteEvent(session, resp);
+
+    if (errormsg)
+    {
+        errormsg->removeRef();
+    }
+
+    /* Reschedule AO if input command queue is not empty */
+    if (!iInputCommands.empty() && IsAdded())
+    {
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+}
+
+void PVMFSMFSPBaseNode::InternalCommandComplete(PVMFFSPNodeCmdQ& aCmdQ,
+        PVMFSMFSPBaseNodeCommand& aCmd,
+        PVMFStatus aStatus,
+        OsclAny* aEventData,
+        PVUuid* aEventUUID,
+        int32* aEventCode,
+        PVInterface* aExtMsg)
+{
+    PVMF_SM_FSP_BASE_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode:CommandComplete Id %d Cmd %d Status %d Context %x"
+                                    , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext));
+
+    PVInterface* extif = NULL;
+    PVMFBasicErrorInfoMessage* errormsg = NULL;
+    if (aExtMsg)
+    {
+        extif = aExtMsg;
+    }
+    else if (aEventUUID && aEventCode)
+    {
+        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
+    }
+
+    /* create response */
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
+
+    if (ErrorHandlingRequired(aStatus))
+    {
+        HandleError(resp);
+        if (errormsg)
+        {
+            errormsg->removeRef();
+        }
+        return;
+    }
+
+
+    /* Erase the command from the queue */
+    aCmdQ.Erase(&aCmd);
+
+    /* Reschedule AO if input command queue is not empty */
+    if (!iInputCommands.empty() && IsAdded())
+    {
+        if (IsAdded())
+        {
+            RunIfNotReady();
+        }
+    }
+
+}
+
+
+
+
+/**
+//////////////////////////////////////////////////
+// Utility functions
+//////////////////////////////////////////////////
+*/
+
+bool PVMFSMFSPBaseNode::IsInternalCmd(PVMFCommandId aId)
+{
+    if ((PVMF_SMFSP_NODE_CONSTRUCT_SESSION == aId) || (PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR == aId) ||
+            IsFSPInternalCmd(aId))
+    {
+        return true;
+    }
+    return false;
+}
+
+bool PVMFSMFSPBaseNode::IsFatalErrorEvent(const PVMFEventType& event)
+{
+    bool retval = false;
+    switch (event)
+    {
+        case PVMFErrCorrupt:
+        case PVMFErrOverflow:
+        case PVMFErrResource:
+        case PVMFErrProcessing:
+        case PVMFErrUnderflow:
+        case PVMFErrNoResources:
+        case PVMFErrResourceConfiguration:
+        case PVMFErrTimeout:
+        case PVMFErrNoMemory:
+        case PVMFFailure:
+            retval = true;
+            break;
+        default:
+            retval = false;
+    }
+    return retval;
+}
+
+bool PVMFSMFSPBaseNode::ErrorHandlingRequired(PVMFStatus aStatus)
+{
+    if ((EPVMFNodeIdle != iInterfaceState) && (PVMFSuccess != aStatus) && (PVMFErrCancelled != aStatus) && (PVMFErrLicenseRequired != aStatus) && (PVMFErrNotSupported != aStatus) && (PVMFErrArgument != aStatus))
+    {
+        return true;
+    }
+    return false;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::GetIndexParamValues(char* aString, uint32& aStartIndex, uint32& aEndIndex)
+{
+    // This parses a string of the form "index=N1...N2" and extracts the integers N1 and N2.
+    // If string is of the format "index=N1" then N2=N1
+
+    if (aString == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    // Go to end of "index="
+    char* n1string = aString + 6;
+
+    PV_atoi(n1string, 'd', oscl_strlen(n1string), aStartIndex);
+
+    char* n2string = OSCL_CONST_CAST(char*, oscl_strstr(aString, _STRLIT_CHAR("...")));
+
+    if (n2string == NULL)
+    {
+        aEndIndex = aStartIndex;
+    }
+    else
+    {
+        // Go to end of "index=N1..."
+        n2string += 3;
+
+        PV_atoi(n2string, 'd', oscl_strlen(n2string), aEndIndex);
+    }
+
+    return PVMFSuccess;
+}
+
+/**
+//A routine to tell if a flush operation is in progress.
+*/
+bool PVMFSMFSPBaseNode::FlushPending()
+{
+    if ((iCurrentCommand.size() > 0) &&
+            (iCurrentCommand.front().iCmd == PVMF_SMFSP_NODE_FLUSH) &&
+            (CheckChildrenNodesFlush() == false))
+    {
+        return true;
+    }
+    return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+PVMFSMFSPCommandContext* PVMFSMFSPBaseNode::RequestNewInternalCmd()
+{
+    int32 i = 0;
+    /* Search for the next free node command in the pool */
+    while (i < PVMF_SMFSP_INTERNAL_CMDQ_SIZE)
+    {
+        if (iInternalCmdPool[i].oFree)
+        {
+            iInternalCmdPool[i].oFree = false;
+            return &(iInternalCmdPool[i]);
+        }
+        ++i;
+    }
+    /* Free one not found so return NULL */
+    return NULL;
+}
+
+void PVMFSMFSPBaseNode::ResetNodeContainerCmdState()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        iFSPChildNodeContainerVec[i].iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+    }
+}
+
+PVMFSMFSPChildNodeContainer* PVMFSMFSPBaseNode::getChildNodeContainer(int32 tag)
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeTag == tag)
+        {
+            return (&(iFSPChildNodeContainerVec[i]));
+        }
+    }
+    return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Command Q processing functions
+///////////////////////////////////////////////////////////////////////////////
+//For processing command Queues
+void PVMFSMFSPBaseNode::MoveCmdToCurrentQueue(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    int32 err;
+    OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
+    if (err != OsclErrNone)
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+        return;
+    }
+    iInputCommands.Erase(&aCmd);
+    return;
+}
+
+void PVMFSMFSPBaseNode::MoveCmdToCancelQueue(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    /*
+     * note: the StoreL cannot fail since the queue is never more than 1 deep
+     * and we reserved space.
+     */
+    iCancelCommand.StoreL(aCmd);
+    iInputCommands.Erase(&aCmd);
+    return;
+}
+
+void PVMFSMFSPBaseNode::MoveErrHandlingCmdToCurErrHandlingQ(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    iCurrErrHandlingCommand.StoreL(aCmd);
+    iErrHandlingCommandQ.Erase(&aCmd);
+    return;
+}
+
+/**
+ * This routine is called by various command APIs to queue an
+ * asynchronous command for processing by the command handler AO.
+ * This function may leave if the command can't be queued due to
+ * memory allocation failure.
+ */
+PVMFCommandId PVMFSMFSPBaseNode::QueueCommandL(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMFCommandId id = -1;
+    id = iInputCommands.AddL(aCmd);
+    PVMF_SM_FSP_BASE_LOGCMDSEQ((0, "Added command [%d] to Q, PVMFCommandId returned [%d]", aCmd.iCmd, id));
+    if (IsAdded())
+    {
+        //wakeup the AO
+        RunIfNotReady();
+    }
+    else
+    {
+        PVMF_SM_FSP_BASE_LOGERR((0, "AO not in queueu while attempting to add command [%d] to Q, PVMFCommandId returned [%d]", aCmd.iCmd, id));
+    }
+    return id;
+}
+
+/**
+ * This routine is called by various command APIs to queue an
+ * asynchronous command for processing by the command handler AO.
+ * This function may leave if the command can't be queued due to
+ * memory allocation failure.
+ */
+PVMFCommandId PVMFSMFSPBaseNode::QueueErrHandlingCommandL(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMFCommandId id = -1;
+    id = iErrHandlingCommandQ.AddL(aCmd);
+    PVMF_SM_FSP_BASE_LOGCMDSEQ((0, "Added command [%d] to Q, PVMFCommandId returned [%d]", aCmd.iCmd, id));
+    if (IsAdded())
+    {
+        //wakeup the AO
+        RunIfNotReady();
+    }
+    else
+    {
+        PVMF_SM_FSP_BASE_LOGERR((0, "AO not in queueu while attempting to add command [%d] to Q, PVMFCommandId returned [%d]", aCmd.iCmd, id));
+    }
+    return id;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Command Completion/Error event notification/Info event notification functions
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMFSPBaseNodeCommand::Copy(const PVMFGenericNodeCommand<OsclMemAllocator>& aCmd)
+{
+    PVMFGenericNodeCommand<OsclMemAllocator>::Copy(aCmd);
+    switch (aCmd.iCmd)
+    {
+        case PVMF_SMFSP_NODE_GETNODEMETADATAKEYS:
+            if (aCmd.iParam4)
+            {
+                /* copy the allocated string */
+                OSCL_HeapString<OsclMemAllocator>* aStr =
+                    (OSCL_HeapString<OsclMemAllocator>*)aCmd.iParam4;
+                Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
+                iParam4 = str.ALLOC_AND_CONSTRUCT(*aStr);
+            }
+            break;
+        default:
+            break;
+    }
+}
+
+/* need to overlaod the base Destroy routine to cleanup metadata key */
+void PVMFSMFSPBaseNodeCommand::Destroy()
+{
+    PVMFGenericNodeCommand<OsclMemAllocator>::Destroy();
+    switch (iCmd)
+    {
+        case PVMF_SMFSP_NODE_GETNODEMETADATAKEYS:
+            if (iParam4)
+            {
+                /* cleanup the allocated string */
+                Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
+                str.destruct_and_dealloc(iParam4);
+            }
+            break;
+        default:
+            break;
+    }
+}
+
+/* Called during a Reset */
+void PVMFSMFSPBaseNode::ResetNodeParams(bool aReleaseMem)
+{
+    //This function will reset the member variables to their initial values.
+    //except command queues
+    //This function intentionally does not reset the command queues.
+    //Reason:This func may be called in response to handle some asyn command(say Reset).
+    //So the command will be in the some of the Q. Reporting command completion for
+    //non existing command in Q will result in segmentation fault.
+
+    iCapability.iCanSupportMultipleInputPorts = false;
+    iCapability.iCanSupportMultipleOutputPorts = true;
+    iCapability.iHasMaxNumberOfPorts = false;
+    iCapability.iMaxNumberOfPorts = 0;
+
+    iRepositioning = false;
+    iPlaylistPlayInProgress = false;
+    iRepositionRequestedStartNPTInMS = 0;
+    iActualRepositionStartNPTInMS = 0;
+    iActualRepositionStartNPTInMSPtr = NULL;
+    iActualMediaDataTS = 0;
+    iActualMediaDataTSPtr = NULL;
+    iJumpToIFrame = false;
+
+    iSessionStartTime = 0;
+    iSessionStopTime = 0;
+    iSessionStopTimeAvailable = true;
+    iSessionSeekAvailable = false;
+
+    iPVMFDataSourcePositionParamsPtr = NULL;
+    iStreamID = 0;
+    iPlayListRepositioning = false;
+
+    iNoOfValuesPushedInValueVect = 0;
+
+    iNumRequestPortsPending = 0;
+    iTotalNumRequestPortsComplete = 0;
+    iGraphConstructComplete = false;
+    iGraphConnectComplete = false;
+
+    iAvailableMetadataKeys.clear();
+    iCPMMetadataKeys.clear();
+
+    if (iMetaDataInfo)
+        iMetaDataInfo->Reset();
+
+    //CPM related
+    ResetCPMParams(aReleaseMem);
+    for (int32 i = 0; i < PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE; i++)
+    {
+        iInternalCmdPool[i].cmd = PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE;
+        iInternalCmdPool[i].oFree = true;
+    }
+
+    PVMFSMFSPChildNodeContainerVector::iterator it;
+    for (it = iFSPChildNodeContainerVec.begin();
+            it != iFSPChildNodeContainerVec.end();
+            it++)
+    {
+        it->iInputPorts.clear();
+        it->iOutputPorts.clear();
+        it->iFeedBackPorts.clear();
+    }
+}
+
+void PVMFSMFSPBaseNode::ResetCPMParams(bool aReleaseMem)
+{
+    if (aReleaseMem)
+    {
+        if (iCPMContentAccessFactory != NULL)
+        {
+            if (iDecryptionInterface != NULL)
+            {
+                iDecryptionInterface->Reset();
+                /* Remove the decrpytion interface */
+                PVUuid uuid = PVMFCPMPluginDecryptionInterfaceUuid;
+                iCPMContentAccessFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iDecryptionInterface);
+                iDecryptionInterface = NULL;
+            }
+            iCPMContentAccessFactory->removeRef();
+            iCPMContentAccessFactory = NULL;
+        }
+
+        if (iRequestedUsage.key)
+        {
+            OSCL_ARRAY_DELETE(iRequestedUsage.key);
+            iRequestedUsage.key = NULL;
+        }
+
+        if (iApprovedUsage.key)
+        {
+            OSCL_ARRAY_DELETE(iApprovedUsage.key);
+            iApprovedUsage.key = NULL;
+        }
+
+        if (iAuthorizationDataKvp.key)
+        {
+            OSCL_ARRAY_DELETE(iAuthorizationDataKvp.key);
+            iAuthorizationDataKvp.key = NULL;
+        }
+    }
+    iCPMMetadataKeys.clear();
+    iPreviewMode = false;
+    iUseCPMPluginRegistry =	false;
+    iDRMResetPending = false;
+    iCPMInitPending = false;
+    maxPacketSize = 0;
+    iPVMFStreamingManagerNodeMetadataValueCount = 0;
+
+    iCPMSourceData.iRefCounter = 0;
+    iCPMSourceData.iUseCPMPluginRegistry = false;
+    iCPMSourceData.iFileHandle	= NULL;
+    iCPMSourceData.iStreamStatsLoggingURL = _STRLIT("");
+    iCPMSourceData.iPreviewMode = false;
+    iCPMSourceData.iIntent = BITMASK_PVMF_SOURCE_INTENT_PLAY;
+    iCPMSourceData.iProxyName = _STRLIT("");
+    iCPMSourceData.iProxyPort = 0;
+    PVMFSourceContextData tmpObj;
+    iSourceContextData = tmpObj;
+    iSourceContextDataValid = false;
+    iCPMSessionID = 0xFFFFFFFF;
+    iCPMContentType = PVMF_CPM_CONTENT_FORMAT_UNKNOWN;
+    iCPMContentAccessFactory = NULL;
+    iDecryptionInterface = NULL;
+    iCPMLicenseInterface = NULL;
+    iCPMLicenseInterfacePVI = NULL;
+    iCPMCapConfigInterface = NULL;
+    iCPMCapConfigInterfacePVI = NULL;
+    iCPMMetaDataExtensionInterface = NULL;
+    iCPMKvpStore.destroy();
+    iRequestedUsage.key = NULL;
+    iApprovedUsage.key = NULL;
+    iAuthorizationDataKvp.key = NULL;
+    iUsageID = 0;
+    iCPMRequestUsageCommandStatus = 0;
+
+    iCPMInitCmdId = 0;
+    iCPMOpenSessionCmdId = 0;
+    iCPMRegisterContentCmdId = 0;
+    iCPMRequestUsageId = 0;
+    iCPMUsageCompleteCmdId = 0;
+    iCPMCloseSessionCmdId = 0;
+    iCPMResetCmdId = 0;
+    iCPMGetMetaDataKeysCmdId = 0;
+    iCPMGetMetaDataValuesCmdId = 0;
+    iCPMGetLicenseInterfaceCmdId = 0;
+    iCPMGetLicenseCmdId = 0;
+    iCPMGetCapConfigCmdId = 0;
+    iCPMCancelGetLicenseCmdId = 0;
+}
+
+void PVMFSMFSPBaseNode::PopulateAvailableMetadataKeys()
+{
+    iAvailableMetadataKeys.clear();
+
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode,
+             iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_DURATION_KEY);
+             if (iMetaDataInfo->iAlbumPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_ALBUM_KEY);
+    }
+    if (iMetaDataInfo->iAuthorPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_AUTHOR_KEY);
+    }
+    if (iMetaDataInfo->iPerformerPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_ARTIST_KEY);
+    }
+    if (iMetaDataInfo->iTitlePresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_TITLE_KEY);
+    }
+    if (iMetaDataInfo->iDescriptionPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY);
+    }
+    if (iMetaDataInfo->iRatingPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_RATING_KEY);
+    }
+    if (iMetaDataInfo->iCopyRightPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY);
+    }
+    if (iMetaDataInfo->iGenrePresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_GENRE_KEY);
+    }
+    if (iMetaDataInfo->iLyricsPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_LYRICS_KEY);
+    }
+    if (iMetaDataInfo->iClassificationPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY);
+    }
+    if (iMetaDataInfo->iKeyWordsPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_KEYWORDS_KEY);
+    }
+    if (iMetaDataInfo->iLocationPresent)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_LOCATION_KEY);
+    }
+    if (iMetaDataInfo->iNumTracks > 0)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY);
+
+        // Create the parameter string for the index range
+        char indexparam[18];
+        oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo->iNumTracks - 1));
+        indexparam[17] = NULL_TERM_CHAR;
+
+        bool valueAvailableForKey = false;
+        {
+            for (uint32 i = 0; i < (iMetaDataInfo->iNumTracks - 1); i++)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackMetaDataInfo.iMimeType.get_cstr())
+                    {
+                        valueAvailableForKey = true;
+                        break;
+                    }
+                }
+            }
+        }
+        if (valueAvailableForKey)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+
+        iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY);
+        iAvailableMetadataKeys[0] += indexparam;
+
+        iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY);
+        iAvailableMetadataKeys[0] += indexparam;
+
+        valueAvailableForKey = false;
+        {
+            for (uint32 i = 0; i < (iMetaDataInfo->iNumTracks - 1); i++)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackMetaDataInfo.iCodecName.get_size() > 0)
+                    {
+                        valueAvailableForKey = true;
+                        break;
+                    }
+                }
+            }
+        }
+        if (valueAvailableForKey)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+
+        valueAvailableForKey = false;
+        {
+            for (uint32 i = 0; i < (iMetaDataInfo->iNumTracks - 1); i++)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackMetaDataInfo.iCodecDescription.get_size() > 0)
+                    {
+                        valueAvailableForKey = true;
+                        break;
+                    }
+                }
+            }
+        }
+        if (valueAvailableForKey)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+
+        valueAvailableForKey = false;
+        {
+            for (uint32 i = 0; i < (iMetaDataInfo->iNumTracks - 1); i++)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    if (trackMetaDataInfo.iCodecSpecificInfo.getMemFragPtr())
+                    {
+                        valueAvailableForKey = true;
+                        break;
+                    }
+                }
+            }
+        }
+        if (valueAvailableForKey)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+
+        iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY);
+        iAvailableMetadataKeys[0] += indexparam;
+    }
+
+    if (iMetaDataInfo->iYear)
+{
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_YEAR_KEY);
+    }
+    if (iMetaDataInfo->iWMPicturePresent)
+{
+    iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY);
+    }
+    if (iMetaDataInfo->iWMPicturePresent)
+{
+    // Create the parameter string for the index range
+    char indexparam[18];
+        oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo->iWMPictureIndexVec.size() - 1));
+        indexparam[17] = NULL_TERM_CHAR;
+        iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_GRAPHICS_KEY);
+        iAvailableMetadataKeys[0] += indexparam;
+    }
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY);
+
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY);
+
+    if ((iUseCPMPluginRegistry == false) || (iSessionSourceInfo->iDRMProtected == false))
+{
+    iAvailableMetadataKeys.push_back(PVMF_DRM_INFO_IS_PROTECTED_QUERY);
+    }
+    uint32 i = 0;
+    for (i = 0; i < iMetaDataInfo->iTrackMetaDataInfoVec.size(); i++)
+{
+    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+        char indexparam[18];
+        oscl_snprintf(indexparam, 18, ";index=%d", (i));
+        indexparam[17] = NULL_TERM_CHAR;
+
+        if (trackMetaDataInfo.iTrackWidth > 0)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+        if (trackMetaDataInfo.iTrackHeight > 0)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+        if (trackMetaDataInfo.iVideoFrameRate > 0)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+        if (trackMetaDataInfo.iAudioSampleRate > 0)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+        if (trackMetaDataInfo.iAudioNumChannels > 0)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+        if (trackMetaDataInfo.iAudioBitsPerSample > 0)
+        {
+            iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY);
+            iAvailableMetadataKeys[0] += indexparam;
+        }
+    }
+            );
+    if (leavecode != OsclErrNone)
+    {
+        OSCL_LEAVE(leavecode);
+    }
+}
+
+PVMFStatus PVMFSMFSPBaseNode::DoGetMetadataKeysBase(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    if (!iMetaDataInfo->iMetadataAvailable)
+    {
+        return PVMFErrInvalidState;
+    }
+
+    iCPMMetadataKeys.clear();
+    /* Get Metadata keys from CPM for protected content only */
+    if ((iCPMMetaDataExtensionInterface != NULL) &&
+            (iSessionSourceInfo->iDRMProtected == true))
+    {
+        GetCPMMetaDataKeys();
+        return PVMFPending;
+    }
+
+    return (CompleteGetMetadataKeys(aCmd));
+}
+
+PVMFStatus PVMFSMFSPBaseNode::CompleteGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMFMetadataList* keylistptr = NULL;
+    uint32 starting_index;
+    int32 max_entries;
+    char* query_key = NULL;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
+
+    // Check parameters
+    if (keylistptr == NULL)
+    {
+        // The list pointer is invalid
+        return PVMFErrArgument;
+    }
+
+    if ((starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
+    {
+        // Invalid starting index and/or max entries
+        return PVMFErrArgument;
+    }
+
+    // Copy the requested keys
+    uint32 num_entries = 0;
+    int32 num_added = 0;
+    uint32 lcv = 0;
+    for (lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
+    {
+        if (query_key == NULL)
+        {
+            // No query key so this key is counted
+            ++num_entries;
+            if (num_entries > starting_index)
+            {
+                // Past the starting index so copy the key
+                PVMFStatus status = PushKeyToMetadataList(keylistptr, iAvailableMetadataKeys[lcv]);
+                if (PVMFSuccess == status)
+                    num_added++;
+                else
+                    return status;
+            }
+        }
+        else
+        {
+            // Check if the key matche the query key
+            if (pv_mime_strcmp(iAvailableMetadataKeys[lcv].get_cstr(), query_key) >= 0)
+            {
+                // This key is counted
+                ++num_entries;
+                if (num_entries > starting_index)
+                {
+                    PVMFStatus status = PushKeyToMetadataList(keylistptr, iAvailableMetadataKeys[lcv]);
+                    if (PVMFSuccess == status)
+                        num_added++;
+                    else
+                        return status;
+                }
+            }
+        }
+    }
+    for (lcv = 0; lcv < iCPMMetadataKeys.size(); lcv++)
+    {
+        if (query_key == NULL)
+        {
+            /* No query key so this key is counted */
+            ++num_entries;
+            if (num_entries > (uint32)starting_index)
+            {
+                PVMFStatus status = PushKeyToMetadataList(keylistptr, iCPMMetadataKeys[lcv]);
+                if (PVMFSuccess == status)
+                    num_added++;
+                else
+                    return status;
+            }
+        }
+        else
+        {
+            /* Check if the key matches the query key */
+            if (pv_mime_strcmp(iCPMMetadataKeys[lcv].get_cstr(), query_key) >= 0)
+            {
+                /* This key is counted */
+                ++num_entries;
+                if (num_entries > (uint32)starting_index)
+                {
+                    PVMFStatus status = PushKeyToMetadataList(keylistptr, iCPMMetadataKeys[lcv]);
+                    if (PVMFSuccess == status)
+                        num_added++;
+                    else
+                        return status;
+                }
+            }
+        }
+        // Check if max number of entries have been copied
+        if (max_entries > 0 && num_added >= max_entries)
+        {
+            break;
+        }
+    }
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::PushKeyToMetadataList(PVMFMetadataList* aMetaDataListPtr, const OSCL_HeapString<OsclMemAllocator> & aKey)const
+{
+    PVMFStatus status = PVMFSuccess;
+    if (aMetaDataListPtr)
+    {
+        int32 leavecode = 0;
+        OSCL_TRY(leavecode, aMetaDataListPtr->push_back(aKey));
+        OSCL_FIRST_CATCH_ANY(leavecode,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPBaseNode::PushKeyToMetadataList - Memory allocation failure when copying metadata key"));
+                             status = PVMFErrNoMemory);
+    }
+    else
+        status = PVMFErrArgument;
+    return status;
+
+}
+
+PVMFStatus PVMFSMFSPBaseNode::DoGetMetadataValuesBase(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::DoGetMetadataValues() In"));
+
+    if (!iMetaDataInfo->iMetadataAvailable)
+    {
+        return PVMFErrInvalidState;
+    }
+
+    PVMFMetadataList* keylistptr = NULL;
+    Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
+    uint32 starting_index;
+    int32 max_entries;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
+
+    // Check the parameters
+    if (keylistptr == NULL || valuelistptr == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    uint32 numkeys = keylistptr->size();
+
+    if (numkeys <= 0 || max_entries == 0)
+    {
+        // Don't do anything
+        return PVMFErrArgument;
+    }
+
+    uint32 numvalentries = iNoOfValuesIteratedForValueVect;
+    int32 numentriesadded = iNoOfValuesPushedInValueVect;
+    for (uint32 lcv = 0; lcv < numkeys; lcv++)
+    {
+        int32 leavecode = 0;
+        PvmiKvp KeyVal;
+        KeyVal.key = NULL;
+        KeyVal.value.pWChar_value = NULL;
+        KeyVal.value.pChar_value = NULL;
+
+        if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_ALBUM_KEY) == 0 &&
+                iMetaDataInfo->iAlbumPresent)
+        {
+            // Album
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsAuthorUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_ALBUM_KEY,
+                             iMetaDataInfo->iAlbum.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_ALBUM_KEY,
+                             iMetaDataInfo->iAlbumUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_AUTHOR_KEY) == 0 &&
+                 iMetaDataInfo->iAuthorPresent)
+        {
+            // Author
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsAuthorUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_AUTHOR_KEY,
+                             iMetaDataInfo->iAuthor.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_AUTHOR_KEY,
+                             iMetaDataInfo->iAuthorUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_ARTIST_KEY) == 0 &&
+                 iMetaDataInfo->iPerformerPresent)
+        {
+            // Artist/performer
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsPerformerUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_ARTIST_KEY,
+                             iMetaDataInfo->iPerformer.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_ARTIST_KEY,
+                             iMetaDataInfo->iPerformerUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TITLE_KEY) == 0 &&
+                 iMetaDataInfo->iTitlePresent)
+        {
+            // Title
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsTitleUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_TITLE_KEY,
+                             iMetaDataInfo->iTitle.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_TITLE_KEY,
+                             iMetaDataInfo->iTitleUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY) == 0 &&
+                 iMetaDataInfo->iDescriptionPresent)
+        {
+            // Description
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsDescriptionUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY,
+                             iMetaDataInfo->iDescription.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY,
+                             iMetaDataInfo->iDescriptionUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RATING_KEY) == 0 &&
+                 iMetaDataInfo->iRatingPresent)
+        {
+            // Rating
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsRatingUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_RATING_KEY,
+                             iMetaDataInfo->iRating.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_RATING_KEY,
+                             iMetaDataInfo->iRatingUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY) == 0 &&
+                 iMetaDataInfo->iCopyRightPresent)
+        {
+            // Copyright
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsCopyRightUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY,
+                             iMetaDataInfo->iCopyright.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY,
+                             iMetaDataInfo->iCopyrightUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_GENRE_KEY) == 0 &&
+                 iMetaDataInfo->iGenrePresent)
+        {
+            // Genre
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsGenreUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_GENRE_KEY,
+                             iMetaDataInfo->iGenre.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_GENRE_KEY,
+                             iMetaDataInfo->iGenreUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LYRICS_KEY) == 0 &&
+                 iMetaDataInfo->iLyricsPresent)
+        {
+            // Lyrics
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsLyricsUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_LYRICS_KEY,
+                             iMetaDataInfo->iLyrics.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_LYRICS_KEY,
+                             iMetaDataInfo->iLyricsUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY) == 0 &&
+                 iMetaDataInfo->iClassificationPresent)
+        {
+            // Classification
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval;
+                if (iMetaDataInfo->iIsClassificationUnicode == false)
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY,
+                             iMetaDataInfo->iClassification.get_cstr());
+                }
+                else
+                {
+                    retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(KeyVal,
+                             PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY,
+                             iMetaDataInfo->iClassificationUnicode);
+                }
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_KEYWORDS_KEY) == 0 &&
+                 iMetaDataInfo->iKeyWordsPresent)
+        {
+            for (uint32 i = 0; i < iMetaDataInfo->iNumKeyWords; i++)
+            {
+                // Keywords
+                // Increment the counter for the number of values found so far
+                PvmiKvp keywordKVP;
+                keywordKVP.key = NULL;
+
+                if (iMetaDataInfo->iIsKeyWordsUnicode)
+                {
+                    if (iMetaDataInfo->iKeyWordUnicode[i].get_cstr())
+                    {
+                        ++numvalentries;
+                    }
+                }
+                else
+                {
+                    if (iMetaDataInfo->iKeyWords[i].get_cstr())
+                    {
+                        ++numvalentries;
+                    }
+                }
+
+                // Create a value entry if past the starting index
+                if (numvalentries > starting_index)
+                {
+                    PVMFStatus retval;
+                    KeyVal.value.pChar_value = NULL;
+                    KeyVal.value.pWChar_value = NULL;
+                    if (iMetaDataInfo->iIsKeyWordsUnicode == false)
+                    {
+                        retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(keywordKVP,
+                                 PVMFSTREAMINGMGRNODE_KEYWORDS_KEY,
+                                 iMetaDataInfo->iKeyWords[i].get_cstr());
+                    }
+                    else
+                    {
+                        retval = PVMFCreateKVPUtils::CreateKVPForWStringValue(keywordKVP,
+                                 PVMFSTREAMINGMGRNODE_KEYWORDS_KEY,
+                                 iMetaDataInfo->iKeyWordUnicode[i]);
+                    }
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                    if (keywordKVP.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, keywordKVP))
+                        {
+                            if (keywordKVP.value.pChar_value != NULL)
+                            {
+                                OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
+                                keywordKVP.value.pChar_value = NULL;
+                            }
+                            if (keywordKVP.value.pWChar_value != NULL)
+                            {
+                                OSCL_ARRAY_DELETE(KeyVal.value.pWChar_value);
+                                keywordKVP.value.pChar_value = NULL;
+                            }
+                            OSCL_ARRAY_DELETE(keywordKVP.key);
+                            keywordKVP.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LOCATION_KEY) == 0 &&
+                 iMetaDataInfo->iLocationPresent)
+        {
+            // Location - Valid only for RTSP Streaming
+            // Increment the counter for the number of values found so far
+
+            ++numvalentries;
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                //memory for this struct is owned in SDP parser lib
+                PVMFStatus retval;
+                retval = PVMFCreateKVPUtils::CreateKVPForKSVValue(KeyVal,
+                         PVMFSTREAMINGMGRNODE_LOCATION_KEY,
+                         (OsclAny*)(&(iMetaDataInfo->iLocationStruct)));
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DURATION_KEY) == 0)
+        {
+            // Session Duration
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                if (iMetaDataInfo->iSessionDurationAvailable == true)
+                {
+                    uint32 duration = Oscl_Int64_Utils::get_uint64_lower32(iMetaDataInfo->iSessionDuration);
+                    char timescalestr[20];
+                    oscl_snprintf(timescalestr, 20, ";%s%d", PVMFSTREAMINGMGRNODE_TIMESCALE, iMetaDataInfo->iSessionDurationTimeScale);
+                    timescalestr[19] = NULL_TERM_CHAR;
+                    PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                                        PVMFSTREAMINGMGRNODE_DURATION_KEY,
+                                        duration,
+                                        timescalestr);
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                }
+                else
+                {
+                    OSCL_StackString<32> unknownDuration(_STRLIT_CHAR("unknown"));
+                    PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                                        PVMFSTREAMINGMGRNODE_DURATION_KEY,
+                                        unknownDuration.get_cstr());
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY) == 0 &&
+                 iMetaDataInfo->iNumTracks > 0)
+        {
+            // Number of tracks
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                                    PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY,
+                                    iMetaDataInfo->iNumTracks);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY) == 0)
+        {
+            // random access
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForBoolValue(KeyVal,
+                                    PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY,
+                                    iMetaDataInfo->iRandomAccessDenied);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_YEAR_KEY) == 0 &&
+                 iMetaDataInfo->iYear)
+        {
+            // Year
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                                    PVMFSTREAMINGMGRNODE_YEAR_KEY,
+                                    iMetaDataInfo->iYear);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY) == 0 &&
+                 iMetaDataInfo->iWMPicturePresent)
+        {
+            /*
+             * Num Picture
+             * Increment the counter for the number of values found so far
+             */
+            ++numvalentries;
+
+            /* Create a value entry if past the starting index */
+            if (numvalentries > (uint32)starting_index)
+            {
+                PVMFStatus retval =
+                    PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
+                            PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY,
+                            iMetaDataInfo->iNumWMPicture,
+                            NULL);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        //value of Graphics key to be provided by FSP
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY) != NULL)
+        {
+            // Track type
+
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex   = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+                    trackkvp.value.pChar_value = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    const char* mimeType = trackMetaDataInfo.iMimeType.get_cstr();
+                    if (mimeType)
+                    {
+                        ++numvalentries;
+                    }
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+                        retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY,
+                                 mimeType,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        leavecode = 0;
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            if (trackkvp.value.pChar_value != NULL)
+                            {
+                                OSCL_ARRAY_DELETE(trackkvp.value.pChar_value);
+                                trackkvp.value.pChar_value = NULL;
+                            }
+
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY) != NULL)
+        {
+            // Track duration
+
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        if (trackMetaDataInfo.iTrackDurationAvailable == true)
+                        {
+                            char indextimescaleparam[36];
+                            oscl_snprintf(indextimescaleparam, 36, ";%s%d;%s%d", PVMFSTREAMINGMGRNODE_INDEX, i, PVMFSTREAMINGMGRNODE_TIMESCALE, trackMetaDataInfo.iTrackDurationTimeScale);
+                            indextimescaleparam[35] = NULL_TERM_CHAR;
+
+                            uint32 trackduration =
+                                Oscl_Int64_Utils::get_uint64_lower32(trackMetaDataInfo.iTrackDuration);
+                            retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                     PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY,
+                                     trackduration,
+                                     indextimescaleparam);
+                        }
+                        else
+                        {
+                            char indextimescaleparam[36];
+                            oscl_snprintf(indextimescaleparam, 36, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                            indextimescaleparam[35] = NULL_TERM_CHAR;
+
+                            OSCL_StackString<32> unknownDuration(_STRLIT_CHAR("unknown"));
+                            PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForCharStringValue(trackkvp,
+                                                PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY,
+                                                unknownDuration.get_cstr(),
+                                                indextimescaleparam);
+                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                            {
+                                break;
+                            }
+                        }
+
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY) != NULL)
+        {
+            // Track bitrate
+
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        bool selected = trackMetaDataInfo.iTrackSelected;
+                        retval = PVMFCreateKVPUtils::CreateKVPForBoolValue(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY,
+                                 selected,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY) != NULL)
+        {
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY,
+                                 trackMetaDataInfo.iTrackWidth,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY) != NULL)
+        {
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY,
+                                 trackMetaDataInfo.iTrackHeight,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY) != NULL)
+        {
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY,
+                                 trackMetaDataInfo.iAudioSampleRate,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY) != NULL)
+        {
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY,
+                                 trackMetaDataInfo.iAudioNumChannels,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY) != NULL)
+        {
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY,
+                                 trackMetaDataInfo.iAudioBitsPerSample,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY) != NULL)
+        {
+            /* Codec Description */
+            /* Determine the index requested. Default to all tracks */
+            uint32 startindex = 0;
+            uint32 endindex = (uint32)iMetaDataInfo->iNumTracks - 1;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+            /* Return a KVP for each index */
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+                    /* Increment the counter for the number of values found so far */
+                    ++numvalentries;
+                    /* Add the value entry if past the starting index */
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > (uint32)starting_index)
+                    {
+                        char indexparam[29];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY,
+                                 trackInfo.iTrackID,
+                                 indexparam);
+                    }
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY) == 0)
+        {
+            /*
+             * Clip Type
+             * Increment the counter for the number of values found so far
+             */
+            ++numvalentries;
+
+            /* Create a value entry if past the starting index */
+            if (numvalentries > (uint32)starting_index)
+            {
+                uint32 len = 0;
+                char* clipType = NULL;
+                len = oscl_strlen("streaming");
+                clipType = OSCL_ARRAY_NEW(char, len + 1);
+                oscl_memset(clipType, 0, len + 1);
+                oscl_strncpy(clipType, ("streaming"), len);
+                PVMFStatus retval =
+                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
+                            PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY,
+                            clipType);
+
+                OSCL_ARRAY_DELETE(clipType);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY) != NULL)
+        {
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY,
+                                 trackMetaDataInfo.iVideoFrameRate,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY) != NULL)
+        {
+            /* Codec Name */
+            /* Determine the index requested. Default to all tracks */
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+            /* Return a KVP for each index */
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+                    /* Increment the counter for the number of values found so far */
+                    if (trackMetaDataInfo.iCodecName.get_size() > 0)
+                    {
+                        ++numvalentries;
+                    }
+                    /* Add the value entry if past the starting index */
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > (uint32)starting_index)
+                    {
+                        char indexparam[29];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+                        char* maxsizestr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_MAXSIZE));
+                        char* truncatestr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG));
+                        uint32 maxSize = 0xFFFFFFFF;
+                        if (maxsizestr != NULL)
+                        {
+                            if (GetMaxSizeValue(maxsizestr, maxSize) != PVMFSuccess)
+                            {
+                                break;
+                            }
+                        }
+
+                        uint32 truncateFlag = true;
+
+                        if (truncatestr != NULL)
+                        {
+                            if (GetTruncateFlagValue(truncatestr, truncateFlag) != PVMFSuccess)
+                            {
+                                break;
+                            }
+                        }
+
+                        uint32 codecNameLen = trackMetaDataInfo.iCodecName.get_size();
+                        char maxsizemessage[13];
+                        maxsizemessage[0] = '\0';
+                        if (maxSize < codecNameLen)
+
+                        {
+                            if (!truncateFlag)
+                            {
+                                oscl_snprintf(maxsizemessage, 13, ";%s%d", PVMFSTREAMINGMGRNODE_REQSIZE, codecNameLen);
+                                oscl_strncat(indexparam, maxsizemessage, oscl_strlen(maxsizemessage));
+                            }
+                        }
+
+                        retval =
+                            PVMFCreateKVPUtils::CreateKVPForWStringValue(trackkvp,
+                                    PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY,
+                                    (trackMetaDataInfo.iCodecName),
+                                    indexparam, maxSize, truncateFlag);
+                    }
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY) != NULL)
+        {
+            /* Codec Description */
+            /* Determine the index requested. Default to all tracks */
+            uint32 startindex = 0;
+            uint32 endindex = (uint32)iMetaDataInfo->iNumTracks - 1;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+            /* Return a KVP for each index */
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+                    /* Increment the counter for the number of values found so far */
+                    if (trackInfo.iCodecDescription.get_size() > 0)
+                    {
+                        ++numvalentries;
+                    }
+                    /* Add the value entry if past the starting index */
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > (uint32)starting_index)
+                    {
+                        char indexparam[29];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+                        char* maxsizestr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_MAXSIZE));
+                        char* truncatestr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG));
+                        uint32 maxSize = 0xFFFFFFFF;
+                        if (maxsizestr != NULL)
+                        {
+                            if (GetMaxSizeValue(maxsizestr, maxSize) != PVMFSuccess)
+                            {
+                                break;
+                            }
+                        }
+
+                        uint32 truncateFlag = true;
+
+                        if (truncatestr != NULL)
+                        {
+                            if (GetTruncateFlagValue(truncatestr, truncateFlag) != PVMFSuccess)
+                            {
+                                break;
+                            }
+                        }
+
+                        uint32 codecDescLen = trackInfo.iCodecDescription.get_size();
+                        char maxsizemessage[13];
+                        maxsizemessage[0] = '\0';
+                        if (maxSize < codecDescLen)
+                        {
+                            if (!truncateFlag)
+                            {
+                                oscl_snprintf(maxsizemessage, 13, ";%s%d", PVMFSTREAMINGMGRNODE_REQSIZE, codecDescLen);
+                                oscl_strncat(indexparam, maxsizemessage, oscl_strlen(maxsizemessage));
+                            }
+                        }
+
+                        retval =
+                            PVMFCreateKVPUtils::CreateKVPForWStringValue(trackkvp,
+                                    PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY,
+                                    (trackInfo.iCodecDescription),
+                                    indexparam, maxSize, truncateFlag);
+                    }
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY) != NULL)
+        {
+            /* Codec Description */
+            /* Determine the index requested. Default to all tracks */
+            uint32 startindex = 0;
+            uint32 endindex = (uint32)iMetaDataInfo->iNumTracks - 1;
+            /* Check if the index parameter is present */
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                /* Retrieve the index values */
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            /* Validate the indices */
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+            /* Return a KVP for each index */
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+                    /* Increment the counter for the number of values found so far */
+                    if ((uint8*)(trackInfo.iCodecSpecificInfo.getMemFragPtr()))
+                    {
+                        ++numvalentries;
+                    }
+                    /* Add the value entry if past the starting index */
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > (uint32)starting_index)
+                    {
+                        char indexparam[29];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+                        retval =
+                            PVMFCreateKVPUtils::CreateKVPForByteArrayValue(trackkvp,
+                                    PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY,
+                                    (uint8*)(trackInfo.iCodecSpecificInfo.getMemFragPtr()),
+                                    (uint32)trackInfo.iCodecSpecificInfo.getMemFragSize()
+                                    , indexparam);
+                    }
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if ((oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMF_DRM_INFO_IS_PROTECTED_QUERY) == 0)
+                 && ((iUseCPMPluginRegistry == false) || (iSessionSourceInfo->iDRMProtected == false)))
+        {
+            /*
+             * is-protected
+             * Increment the counter for the number of values found so far
+             */
+            ++numvalentries;
+
+            /* Create a value entry if past the starting index */
+            if (numvalentries > (uint32)starting_index)
+            {
+                PVMFStatus retval =
+                    PVMFCreateKVPUtils::CreateKVPForBoolValue(KeyVal,
+                            PVMF_DRM_INFO_IS_PROTECTED_QUERY,
+                            iSessionSourceInfo->iDRMProtected,
+                            NULL);
+
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY) != NULL)
+        {
+            // Track bitrate
+
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+
+                    // Increment the counter for the number of values found so far
+                    ++numvalentries;
+                    // Add the value entry if past the starting index
+                    PVMFStatus retval = PVMFErrArgument;
+                    if (numvalentries > starting_index)
+                    {
+                        char indexparam[16];
+                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                        indexparam[15] = NULL_TERM_CHAR;
+
+                        uint32 trackbitrate = trackMetaDataInfo.iTrackBitRate;
+                        retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                 PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY,
+                                 trackbitrate,
+                                 indexparam);
+                    }
+
+                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                    {
+                        break;
+                    }
+
+                    if (trackkvp.key != NULL)
+                    {
+                        if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                        {
+                            OSCL_ARRAY_DELETE(trackkvp.key);
+                            trackkvp.key = NULL;
+                        }
+                        else
+                        {
+                            // Increment the value list entry counter
+                            ++numentriesadded;
+                        }
+
+                        // Check if the max number of value entries were added
+                        if (max_entries > 0 && numentriesadded >= max_entries)
+                        {
+                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                            return PVMFSuccess;
+                        }
+                    }
+                }
+            }
+        }
+        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY) != NULL)
+        {
+            // Track bitrate
+
+            // Determine the index requested. Default to all tracks
+            uint32 startindex = 0;
+            uint32 endindex = iMetaDataInfo->iNumTracks - 1;
+            // Check if the index parameter is present
+            char* indexstr = OSCL_CONST_CAST(char*, oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX));
+            if (indexstr != NULL)
+            {
+                // Retrieve the index values
+                GetIndexParamValues(indexstr, startindex, endindex);
+            }
+            // Validate the indices
+            if (startindex > endindex || startindex >= iMetaDataInfo->iNumTracks || endindex >= iMetaDataInfo->iNumTracks)
+            {
+                continue;
+            }
+
+            // Return a KVP for each index
+            for (uint32 i = startindex; i <= endindex; ++i)
+            {
+                if (i < iMetaDataInfo->iTrackMetaDataInfoVec.size())
+                {
+                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo->iTrackMetaDataInfoVec[i];
+
+                    PvmiKvp trackkvp;
+                    trackkvp.key = NULL;
+                    uint32 trackbitrate = trackMetaDataInfo.iTrackMaxBitRate;
+                    if (trackbitrate > 0)
+                    {
+                        // Increment the counter for the number of values found so far
+                        ++numvalentries;
+                        // Add the value entry if past the starting index
+                        PVMFStatus retval = PVMFErrArgument;
+                        if (numvalentries > starting_index)
+                        {
+                            char indexparam[16];
+                            oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
+                            indexparam[15] = NULL_TERM_CHAR;
+                            retval = PVMFCreateKVPUtils::CreateKVPForUInt32Value(trackkvp,
+                                     PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY,
+                                     trackbitrate,
+                                     indexparam);
+                        }
+
+                        if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                        {
+                            break;
+                        }
+
+                        if (trackkvp.key != NULL)
+                        {
+                            if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, trackkvp))
+                            {
+                                OSCL_ARRAY_DELETE(trackkvp.key);
+                                trackkvp.key = NULL;
+                            }
+                            else
+                            {
+                                // Increment the value list entry counter
+                                ++numentriesadded;
+                            }
+
+                            // Check if the max number of value entries were added
+                            if (max_entries > 0 && numentriesadded >= max_entries)
+                            {
+                                iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+                                return PVMFSuccess;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+//Check with FSP
+        // Add the KVP to the list if the key string was created
+        if (KeyVal.key != NULL)
+        {
+            if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, KeyVal))
+            {
+                switch (GetValTypeFromKeyString(KeyVal.key))
+                {
+                    case PVMI_KVPVALTYPE_CHARPTR:
+                        if (KeyVal.value.pChar_value != NULL)
+                        {
+                            OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
+                            KeyVal.value.pChar_value = NULL;
+                        }
+                        break;
+
+                    default:
+                        // Add more case statements if other value types are returned
+                        break;
+                }
+
+                OSCL_ARRAY_DELETE(KeyVal.key);
+                KeyVal.key = NULL;
+            }
+            else
+            {
+                // Increment the counter for number of value entries added to the list
+                ++numentriesadded;
+            }
+
+            // Check if the max number of value entries were added
+            if (max_entries > 0 && numentriesadded >= max_entries)
+            {
+                // Maximum number of values added so break out of the loop
+                break;
+            }
+        }
+    }
+
+    iNoOfValuesPushedInValueVect = numentriesadded;
+    iNoOfValuesIteratedForValueVect = numvalentries;
+    iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+
+
+    if ((iCPMMetaDataExtensionInterface != NULL) &&
+            (iSessionSourceInfo->iDRMProtected  == true))
+    {
+        if (OSCL_STATIC_CAST(int32, iNoOfValuesPushedInValueVect) < max_entries)
+        {
+            uint32 cpmStartingIndex = 0;
+            uint32 cpmMaxEntries = max_entries - iNoOfValuesPushedInValueVect;
+
+            if (iNoOfValuesIteratedForValueVect >= starting_index)
+            {
+                cpmStartingIndex = 0;
+            }
+            else
+            {
+                cpmStartingIndex = starting_index - iNoOfValuesIteratedForValueVect;
+            }
+            iCPMGetMetaDataValuesCmdId =
+                iCPMMetaDataExtensionInterface->GetNodeMetadataValues(iCPMSessionID,
+                        (*keylistptr),
+                        (*valuelistptr),
+                        cpmStartingIndex,
+                        cpmMaxEntries
+                                                                     );
+            return PVMFPending;
+        }
+    }
+
+
+
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::PushKVPToMetadataValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, const PvmiKvp& aKVP)const
+{
+    PVMFStatus status = PVMFSuccess;
+    if (aValueList)
+    {
+        int32 leavecode = 0;
+        OSCL_TRY(leavecode, aValueList->push_back(aKVP));
+        OSCL_FIRST_CATCH_ANY(leavecode,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPBaseNode::PushKeyToMetadataList - Memory allocation failure when copying metadata key"));
+                             status = PVMFErrNoMemory);
+    }
+    else
+        status = PVMFErrArgument;
+    return status;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::GetMaxSizeValue(char* aString, uint32& aMaxSize)
+{
+    aMaxSize = 0xFFFFFFFF;
+    /*
+     * This parses a string of the form "maxsize=N1" and extracts the integer N1.
+     */
+    if (aString == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    /* Go to end of "maxsize=" */
+    char* n1string = aString + 8;
+    char* truncatestr = OSCL_CONST_CAST(char*, oscl_strstr(n1string, PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG));
+
+    uint32 maxsizelen = 0;
+
+    if (truncatestr != NULL)
+    {
+        maxsizelen = oscl_strlen(n1string) - (oscl_strlen(truncatestr) + 1);
+        n1string[maxsizelen] = '\0';
+    }
+
+    if (PV_atoi(n1string, 'd', oscl_strlen(n1string), aMaxSize))
+    {
+        return PVMFSuccess;
+    }
+    return PVMFFailure;
+}
+
+PVMFStatus PVMFSMFSPBaseNode::GetTruncateFlagValue(char* aString, uint32& aTruncateFlag)
+{
+    aTruncateFlag = 0;
+    /*
+     * This parses a string of the form "truncate=N1" and extracts the integer N1.
+     */
+    if (aString == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    /* Go to end of "truncate=" */
+    char* n1string = aString + 9;
+
+    if (!oscl_strcmp(n1string, "true"))
+    {
+        aTruncateFlag = true;
+    }
+    else if (!oscl_strcmp(n1string, "false"))
+    {
+        aTruncateFlag = false;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+    return PVMFSuccess;
+
+}
+
+void PVMFSMFSPBaseNode::HandleError(const PVMFCmdResp& aResponse)
+{
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+    if (EPVMFNodeError != iInterfaceState)
+    {
+        if (cmdContextData)	//It may be possible that cmdContextData == NULL for internal commands
+        {
+            OSCL_ASSERT(cmdContextData->parentCmd != PVMF_SMFSP_NODE_RESET);
+        }
+        SetState(EPVMFNodeError);
+        iChildNodeErrHandler->InitiateErrorHandling(aResponse);
+    }
+    else
+    {
+        iChildNodeErrHandler->CompleteErrorHandling(aResponse);
+    }
+}
+
+void PVMFSMFSPBaseNode::ErrHandlingComplete(const PVMFSMFSPBaseNodeCommand* aErroneousCmd)
+{
+    OSCL_ASSERT(iChildNodeErrHandler);
+    if (!iChildNodeErrHandler)
+    {
+        PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::ErrHandlingComplete Error - iChildNodeErrHandler not available"));
+        return;
+    }
+    if (aErroneousCmd)
+    {
+        const PVMFCmdResp* const cmdResponse = iChildNodeErrHandler->GetErroneousCmdResponse();
+        OSCL_ASSERT(cmdResponse);
+        if (!cmdResponse)
+        {
+            PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::ErrHandlingComplete Error - Command Response not available"));
+            return;
+        }
+
+
+        if (iCancelCommand.size() > 0)
+        {
+            //We got err during cancel command
+            if (PVMF_SMFSP_NODE_CANCELALLCOMMANDS == iCancelCommand.front().iCmd)
+            {
+                if (!iCurrentCommand.empty())
+                {
+                    if (IsInternalCmd(iCurrentCommand.front().iCmd) == false)
+                    {
+                        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                    }
+                    else
+                    {
+                        InternalCommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                    }
+                }
+
+                //Assumptions:
+                //Command in front of cancel Q is cancel command.
+                //None of commands in the input queue is hipri cmd, and hence are store in the order of their cmd id's
+                //All commands in the input Q with command id < command id of the cancel command need to be completed
+                //with cancelled status.
+                const int32 cancelCmdId = iCancelCommand.front().iId;
+                const int32 inputCmndsSz = iInputCommands.size();
+                for (int ii = inputCmndsSz - 1; ii >= 0 ; ii--)
+                {
+                    if (iInputCommands[ii].iId < cancelCmdId)
+                    {
+                        if (IsInternalCmd(iInputCommands[ii].iCmd))
+                        {
+                            InternalCommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+                        }
+                        else
+                        {
+                            CommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+                        }
+                    }
+                }
+                /* finally send command complete for the cancel all command */
+                PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::CompleteCancelAll - CancelAllCommands complete error"));
+                bool eventDataLenAvailable = false;
+                uint32 eventDataLength = 0;
+                cmdResponse->GetEventDataLen(eventDataLenAvailable, eventDataLength);
+                CommandComplete(iCancelCommand, iCancelCommand.front(), cmdResponse->GetCmdStatus(), cmdResponse->GetEventData(), NULL, NULL, cmdResponse->GetEventExtensionInterface(), eventDataLenAvailable ? eventDataLength : 0);
+            }
+            else if (PVMF_SMFSP_NODE_CANCELCOMMAND == iCancelCommand.front().iCmd)
+            {
+                if (!iCurrentCommand.empty())
+                {
+                    if (IsInternalCmd(iCurrentCommand.front().iCmd) == false)
+                    {
+                        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                    }
+                    else
+                    {
+                        InternalCommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
+                    }
+                }
+                /* end command complete for the cancel all command */
+                PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::CompleteCancelAll - CancelCmd complete error"));
+                bool eventDataLenAvailable = false;
+                uint32 eventDataLength = 0;
+                cmdResponse->GetEventDataLen(eventDataLenAvailable, eventDataLength);
+                CommandComplete(iCancelCommand, iCancelCommand.front(), PVMFFailure, cmdResponse->GetEventData(), NULL, NULL, cmdResponse->GetEventExtensionInterface(), eventDataLenAvailable ? eventDataLength : 0);
+            }
+            else
+            {
+                //Only commands in cancel Q can be cancel command/cancelall command,or some command entertained by CPM plugin.
+                //Err handling logic is done only for the child nodes of the  SM node, CPM plugin is not handled by current err handling logic
+                OSCL_ASSERT(false);
+            }
+        }
+        else
+        {
+            //We got err during command other than cancel command
+            //Command may be present in input command Q/current command Q
+            if (iCurrentCommand.size() > 0)
+            {
+                if (IsInternalCmd(iCurrentCommand.front().iCmd))
+                {
+                    //aErroneousCmd
+                    //We do not use the event data of cmd response and asyn event , becuas ewe cache the response/event and hence data may be dangling when we attempt to use it after caching.
+                    InternalCommandComplete(iCurrentCommand, iCurrentCommand.front(), cmdResponse->GetCmdStatus(), NULL, NULL, NULL, cmdResponse->GetEventExtensionInterface());
+                }
+                else
+                {
+                    bool eventDataLenAvailable = false;
+                    uint32 eventDataLength = 0;
+                    cmdResponse->GetEventDataLen(eventDataLenAvailable, eventDataLength);
+                    CommandComplete(iCurrentCommand, iCurrentCommand.front(), cmdResponse->GetCmdStatus(), cmdResponse->GetEventData(), NULL, NULL, cmdResponse->GetEventExtensionInterface(), eventDataLenAvailable ? eventDataLength : 0);
+                }
+            }
+            else
+            {
+                if (IsInternalCmd(iInputCommands.front().iCmd))
+                {
+                    //aErroneousCmd
+                    //We do not use the event data of cmd response and asyn event , becuas ewe cache the response/event and hence data may be dangling when we attempt to use it after caching.
+                    InternalCommandComplete(iInputCommands, iInputCommands.front(), cmdResponse->GetCmdStatus(), NULL, NULL, NULL, cmdResponse->GetEventExtensionInterface());
+                }
+                else
+                {
+                    bool eventDataLenAvailable = false;
+                    uint32 eventDataLength = 0;
+                    cmdResponse->GetEventDataLen(eventDataLenAvailable, eventDataLength);
+                    CommandComplete(iInputCommands, iInputCommands.front(), cmdResponse->GetCmdStatus(), cmdResponse->GetEventData(), NULL, NULL, cmdResponse->GetEventExtensionInterface(), eventDataLenAvailable ? eventDataLength : 0);
+                }
+            }
+        }
+    }
+    else
+    {
+        OSCL_ASSERT(iChildNodeErrHandler->GetAsyncErrEvent());
+        if (!iChildNodeErrHandler->GetAsyncErrEvent())
+            return;
+        else
+        {
+            PVMFAsyncEvent event = OSCL_CONST_CAST(PVMFAsyncEvent, *(iChildNodeErrHandler->GetAsyncErrEvent()));
+            PVMFNodeInterface::ReportErrorEvent(event);
+        }
+    }
+    iChildNodeErrHandler->Reset();
+    //remove commands from the input command Q
+    const int32 inputCmndsSz = iInputCommands.size();
+    if (inputCmndsSz > 0 && (!iInputCommands[0].hipri()))	//For command at index 0 is hipri, let the command complete asynchronously in next AO cycles.
+    {
+        for (int ii = 0; ii < inputCmndsSz ; ii++)
+        {
+            if (iInputCommands[ii].iCmd !=  PVMF_SMFSP_NODE_RESET)
+            {
+                if (IsInternalCmd(iInputCommands[ii].iCmd))
+                {
+                    InternalCommandComplete(iInputCommands, iInputCommands[ii], PVMFFailure);
+                }
+                else
+                {
+                    CommandComplete(iInputCommands, iInputCommands[ii], PVMFFailure);
+                }
+            }
+            else
+                break;
+        }
+    }
+    if (IsAdded())
+    {
+        RunIfNotReady();
+    }
+
+}
+
+bool PVMFSMFSPBaseNode::SupressInfoEvent()
+{
+    if ((iInterfaceState == EPVMFNodeError) ||
+            (!iCancelCommand.empty() || (iCurrentCommand.front().iCmd == PVMF_SMFSP_NODE_RESET)))
+    {
+        return true;
+    }
+    return false;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//PVMFSMFSPChildNodeErrorHandler
+///////////////////////////////////////////////////////////////////////////////
+PVMFSMFSPChildNodeErrorHandler* PVMFSMFSPChildNodeErrorHandler::CreateErrHandler(PVMFSMFSPBaseNode* aFSPBaseNode)
+{
+    PVMFSMFSPChildNodeErrorHandler* errHandler = NULL;
+    int32 err;
+    OSCL_TRY(err,
+             errHandler = OSCL_NEW(PVMFSMFSPChildNodeErrorHandler, (aFSPBaseNode));
+             errHandler->Construct();
+            );
+    return errHandler;
+}
+
+void PVMFSMFSPChildNodeErrorHandler::DeleteErrHandler(PVMFSMFSPChildNodeErrorHandler*& aErrHandler)
+{
+    if (aErrHandler)
+        OSCL_DELETE(aErrHandler);
+    aErrHandler = NULL;
+}
+
+void PVMFSMFSPChildNodeErrorHandler::InitiateErrorHandling(const PVMFCmdResp& aCmdResponse)
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::InitiateErrorHandling In CmdId [%d]", aCmdResponse.GetCmdId()));
+    iCmdResponse = NULL;
+    SaveErrorInfo(aCmdResponse);
+    PerformErrorHandling();
+}
+
+void PVMFSMFSPChildNodeErrorHandler::InitiateErrorHandling(const PVMFAsyncEvent& aAsyncEvent)
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::InitiateErrorHandling In Event [%d]", aAsyncEvent.GetEventType()));
+    iAsyncEvent = NULL;
+    SaveErrorInfo(aAsyncEvent);
+    PerformErrorHandling();
+}
+
+void PVMFSMFSPChildNodeErrorHandler::CompleteErrorHandling(const PVMFCmdResp& aResponse)	//called by NodeCommandCompleted
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::CompleteErrorHandling In CmdId [%d] ErrHandlerState [%d]", aResponse.GetCmdId(), iState));
+    OSCL_UNUSED_ARG(aResponse);
+
+    switch (iState)
+    {
+        case SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_COMPLETION:
+        {
+            ContinueChildNodesCmdCancellation();
+        }
+        case SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_DUE_TO_ERR_COMPLETION:
+        {
+            CompleteChildNodesCmdCancellationDueToErr();
+        }
+        break;
+        case SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION:
+        {
+            OSCL_ASSERT(aResponse.GetCmdStatus() != PVMFFailure);
+            CompleteChildNodesResetDueToError();
+        }
+        break;
+        default:
+            OSCL_ASSERT(false);
+    }
+}
+
+void PVMFSMFSPChildNodeErrorHandler::Reset()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::Reset"));
+    bool eventDataLenAvailable = false;
+    uint32 eventDataLen = 0;
+    if (SMFSP_ERR_SOURCE_EVENT == iErrSource)
+    {
+        iAsyncEvent->GetEventDataLen(eventDataLenAvailable, eventDataLen);
+        if (iAsyncEvent)
+        {
+            if (eventDataLenAvailable)
+            {
+                OSCL_ARRAY_DELETE(OSCL_STATIC_CAST(octet*, iAsyncEvent->GetEventData()));
+            }
+            if (iAsyncEvent->GetEventExtensionInterface())
+                iAsyncEvent->GetEventExtensionInterface()->removeRef();
+            OSCL_DELETE(iAsyncEvent);
+            iAsyncEvent = NULL;
+        }
+    }
+    if (SMFSP_ERR_SOURCE_NODE_CMD_COMPLETION == iErrSource)
+    {
+        iCmdResponse->GetEventDataLen(eventDataLenAvailable, eventDataLen);
+        if (iCmdResponse)
+        {
+            if (eventDataLenAvailable)
+            {
+                OSCL_ARRAY_DELETE(OSCL_STATIC_CAST(octet*, iCmdResponse->GetEventData()));
+            }
+            if (iCmdResponse->GetEventExtensionInterface())
+                iCmdResponse->GetEventExtensionInterface()->removeRef();
+            OSCL_DELETE(iCmdResponse);
+            iCmdResponse = NULL;
+        }
+    }
+    iErrCmd = NULL;
+    if (iErroneousCmdResponse)
+        OSCL_DELETE(iErroneousCmdResponse);
+    iErrSource = SMFSP_ERR_SOURCE_INDETERMINATE;
+    iState = SMFSP_ERRHANDLER_IDLE;
+}
+
+const PVMFCmdResp* PVMFSMFSPChildNodeErrorHandler::GetErroneousCmdResponse()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::GetErroneousCmdResponse [%x]", iErrCmd));
+    if (iErrCmd)
+        return iErroneousCmdResponse;
+    else
+        return NULL;
+}
+
+const PVMFAsyncEvent* PVMFSMFSPChildNodeErrorHandler::GetAsyncErrEvent()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::GetAsyncErrEvent [%x]", iAsyncEvent));
+    if (SMFSP_ERR_SOURCE_EVENT == iErrSource)
+        return iAsyncEvent;
+    else
+        return NULL;
+}
+
+
+void PVMFSMFSPChildNodeErrorHandler::SaveErrorInfo(const PVMFCmdResp& aCmdResponse)
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::SaveErrorInfo - ErrSource is Command Completion"));
+    iErrSource = SMFSP_ERR_SOURCE_NODE_CMD_COMPLETION;
+    if (!iCmdResponse)	//make deep copy of aCmdResponse, may be we can use the response info to persist event data too
+    {
+        bool eventDataLenAvailable = false;
+        uint32 eventDataLen = 0;
+        octet* eventData = OSCL_STATIC_CAST(octet*, aCmdResponse.GetEventData());
+        aCmdResponse.GetEventDataLen(eventDataLenAvailable, eventDataLen);
+        if (eventDataLenAvailable)
+        {
+            eventData = OSCL_ARRAY_NEW(octet, eventDataLen);
+            oscl_memcpy(eventData, aCmdResponse.GetEventData(), eventDataLen);
+            iCmdResponse = OSCL_NEW(PVMFCmdResp , (aCmdResponse.GetCmdId(), aCmdResponse.GetContext(), aCmdResponse.GetCmdStatus(), aCmdResponse.GetEventExtensionInterface(), eventData));
+            iCmdResponse->SetEventDataLen(eventDataLen);
+        }
+        else
+            iCmdResponse = OSCL_NEW(PVMFCmdResp , (aCmdResponse.GetCmdId(), aCmdResponse.GetContext(), aCmdResponse.GetCmdStatus(), aCmdResponse.GetEventExtensionInterface(), eventData));
+        if (iCmdResponse->GetEventExtensionInterface())
+            iCmdResponse->GetEventExtensionInterface()->addRef();
+    }
+}
+
+void PVMFSMFSPChildNodeErrorHandler::SaveErrorInfo(const PVMFAsyncEvent& aAsyncEvent)
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::SaveErrorInfo - ErrSource is Event"));
+    iErrSource = SMFSP_ERR_SOURCE_EVENT;
+    if (!iAsyncEvent) //make deep copy of aAsyncEvent, may be we can use the event info to persist event data too
+    {
+        bool eventDataLenAvailable = false;
+        uint32 eventDataLen = 0;
+        octet* eventData = OSCL_STATIC_CAST(octet*, aAsyncEvent.GetEventData());
+        aAsyncEvent.GetEventDataLen(eventDataLenAvailable, eventDataLen);
+        if (eventDataLenAvailable)
+        {
+            eventData = OSCL_ARRAY_NEW(octet, eventDataLen);
+            oscl_memcpy(eventData, aAsyncEvent.GetEventData(), eventDataLen);
+            iAsyncEvent = OSCL_NEW(PVMFAsyncEvent, (OSCL_CONST_CAST(PVMFAsyncEvent&, aAsyncEvent).IsA(), aAsyncEvent.GetEventType(), OSCL_CONST_CAST(OsclAny*, (aAsyncEvent.GetContext())), aAsyncEvent.GetEventExtensionInterface(), eventData, aAsyncEvent.GetLocalBuffer(), aAsyncEvent.GetLocalBufferSize()));
+            iAsyncEvent->SetEventDataLen(eventDataLen);
+        }
+        else
+            iAsyncEvent = OSCL_NEW(PVMFAsyncEvent, (OSCL_CONST_CAST(PVMFAsyncEvent&, aAsyncEvent).IsA(), aAsyncEvent.GetEventType(), OSCL_CONST_CAST(OsclAny*, (aAsyncEvent.GetContext())), aAsyncEvent.GetEventExtensionInterface(), eventData, aAsyncEvent.GetLocalBuffer(), aAsyncEvent.GetLocalBufferSize()));
+        if (iAsyncEvent->GetEventExtensionInterface())
+            iAsyncEvent->GetEventExtensionInterface()->addRef();
+    }
+}
+
+void PVMFSMFSPChildNodeErrorHandler::PerformErrorHandling()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::PerformErrorHandling In"));
+    // Three Cases:
+    //Case 1: There is some comand in the command Q that was being processed and error occurs
+    //queue cancelduetoerr and cancelduetoreset in the error Q.
+    //Let the canceduetoerr and resetduetoerr complete
+    //Complete the pending command with error info
+
+    //Case 2:There is some comand in the command Q that was being cancelled and error occurred while cancellation
+    //Let the cancel complete but do not report comepltion to observer of SM node.
+    //Queue the Resetduetoerr.
+    //Complete resetduetoerr and notify current command's completion to the obs of the SM node
+    //If the cancel command is CancelAll, notify command completion of all teh command in the input command Q, with command id < cmdid of cancelall
+    //Notify command completion of cance/cancelall to the obs of the SM node
+
+
+    //Case 3: There is no command in the current command Q and error was notified via error event
+    //queue resetduetoerr in the error Q.
+    //Let the resetduetoerr complete
+    //Report err event to observer
+
+    if (iSMFSPNode->iCancelCommand.size() > 0)
+    {
+        iErrCmd = &(iSMFSPNode->iCancelCommand.front());
+    }
+    else if (iSMFSPNode->iCurrentCommand.size() > 0)
+    {
+        iErrCmd = &(iSMFSPNode->iCurrentCommand.front());
+    }
+
+    if ((iErrSource == SMFSP_ERR_SOURCE_NODE_CMD_COMPLETION) && (NULL == iErrCmd))
+    {
+        iErrCmd = &(iSMFSPNode->iInputCommands.front());
+    }
+
+    if (iErrCmd)
+    {
+        bool eventDataLenAvailable = false;
+        uint32 eventDataLength = 0;
+        if (SMFSP_ERR_SOURCE_EVENT == iErrSource)
+        {
+            iErroneousCmdResponse = OSCL_NEW(PVMFCmdResp, (iErrCmd->iId, iAsyncEvent->GetContext(), PVMFFailure, iAsyncEvent->GetEventExtensionInterface(), iAsyncEvent->GetEventData()));
+            iAsyncEvent->GetEventDataLen(eventDataLenAvailable, eventDataLength);
+            if (eventDataLenAvailable)
+                iErroneousCmdResponse->SetEventDataLen(eventDataLength);
+        }
+        else
+        {
+            iErroneousCmdResponse = OSCL_NEW(PVMFCmdResp , (iCmdResponse->GetCmdId(), iCmdResponse->GetContext(), iCmdResponse->GetCmdStatus(), iCmdResponse->GetEventExtensionInterface(), iCmdResponse->GetEventData()));
+            iCmdResponse->GetEventDataLen(eventDataLenAvailable, eventDataLength);
+            if (eventDataLenAvailable)
+                iErroneousCmdResponse->SetEventDataLen(eventDataLength);
+        }
+
+        //Do we have any pending command with any of the child node?
+        bool hasPendingChildNodeCmd = false;
+        for (uint32 i = 0; i < iSMFSPNode->iFSPChildNodeContainerVec.size(); i++)
+        {
+            if (iSMFSPNode->iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+            {
+                hasPendingChildNodeCmd = true;
+                break;
+            }
+        }
+        if ((PVMF_SMFSP_NODE_CANCELALLCOMMANDS == iErrCmd->iCmd) || (PVMF_SMFSP_NODE_CANCELCOMMAND == iErrCmd->iCmd))
+        {
+            if (hasPendingChildNodeCmd)
+                iState = SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_COMPLETION;
+            else
+            {
+                PVMFSessionId s = 0;
+                PVMFSMFSPBaseNodeCommand cmdResetDueToErr;
+                cmdResetDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                        PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+                        NULL);
+                iSMFSPNode->QueueErrHandlingCommandL(cmdResetDueToErr);
+                iState = SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION;
+            }
+
+        }
+        else
+        {
+            if (hasPendingChildNodeCmd)
+            {
+                PVMFSessionId s = 0;
+                PVMFSMFSPBaseNodeCommand cmdCancelPendingCmdDueToErr;
+                cmdCancelPendingCmdDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                        PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR,
+                        NULL);
+                iSMFSPNode->QueueErrHandlingCommandL(cmdCancelPendingCmdDueToErr);
+                iState = SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_DUE_TO_ERR_COMPLETION;
+            }
+            else
+            {
+                PVMFSessionId s = 0;
+                PVMFSMFSPBaseNodeCommand cmdResetDueToErr;
+                cmdResetDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                        PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+                        NULL);
+                iSMFSPNode->QueueErrHandlingCommandL(cmdResetDueToErr);
+                iState = SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION;
+            }
+        }
+    }
+    else
+    {
+        PVMFSessionId s = 0;
+        PVMFSMFSPBaseNodeCommand cmdResetDueToErr;
+        cmdResetDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+                NULL);
+        iSMFSPNode->QueueErrHandlingCommandL(cmdResetDueToErr);
+        iState = SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION;
+    }
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::PerformErrorHandling Out iErrCmd - [%x] iState [%d]", iErrCmd, iState));
+}
+
+void PVMFSMFSPChildNodeErrorHandler::ContinueChildNodesCmdCancellation()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::ContinueChildNodesCmdCancellation In"));
+    if (iSMFSPNode->CheckChildrenNodesCancelAll())
+    {
+        PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::ContinueChildNodesCmdCancellation - Q Reset Due To Err"));
+        PVMFSessionId s = 0;
+        PVMFSMFSPBaseNodeCommand cmdResetDueToErr;
+        cmdResetDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+                NULL);
+        iSMFSPNode->QueueErrHandlingCommandL(cmdResetDueToErr);
+        iState = SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION;
+    }
+}
+
+void PVMFSMFSPChildNodeErrorHandler::CompleteChildNodesCmdCancellationDueToErr()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::CompleteChildNodesCmdCancellationDueToErr In"));
+    if (iSMFSPNode->CheckChildrenNodesCancelAll())
+    {
+        //There are two possible cases:
+        //- Before command for cancellation due to error could even be queued up, all the pending commands got completed.
+        //- Cancel due to error got completed
+        if ((iSMFSPNode->iErrHandlingCommandQ.size() > 0) && (PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR == iSMFSPNode->iErrHandlingCommandQ.front().iCmd))
+        {
+            iSMFSPNode->iErrHandlingCommandQ.Erase(&iSMFSPNode->iErrHandlingCommandQ.front());
+            PVMFSessionId s = 0;
+            PVMFSMFSPBaseNodeCommand cmdResetDueToErr;
+            cmdResetDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                    PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+                    NULL);
+            iSMFSPNode->QueueErrHandlingCommandL(cmdResetDueToErr);
+            iState = SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION;
+        }
+        else
+        {
+            PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::CompleteChildNodesCmdCancellationDueToErr- Cancellation complete"));
+            OSCL_ASSERT(iSMFSPNode->iCurrErrHandlingCommand.size() > 0 && (PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR == iSMFSPNode->iCurrErrHandlingCommand.front().iCmd));
+            ErrHandlingCommandComplete(iSMFSPNode->iCurrErrHandlingCommand, iSMFSPNode->iCurrErrHandlingCommand.front(), PVMFSuccess);
+        }
+    }
+    return;
+}
+
+void PVMFSMFSPChildNodeErrorHandler::CompleteChildNodesResetDueToError()
+{
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::CompleteChildNodesResetDueToErrorIn"));
+    if (iSMFSPNode->CheckChildrenNodesReset() && iSMFSPNode->iDRMResetPending == false)
+    {
+        PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::CompleteChildNodesResetDueToErrorIn - Restting Child Nodes complete %d", iSMFSPNode->iDRMResetPending));
+        OSCL_ASSERT(iSMFSPNode->iCurrErrHandlingCommand.size() > 0 && (iSMFSPNode->iCurrErrHandlingCommand.front().iCmd == PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR));
+        ErrHandlingCommandComplete(iSMFSPNode->iCurrErrHandlingCommand, iSMFSPNode->iCurrErrHandlingCommand.front(), PVMFSuccess);
+    }
+}
+
+
+void PVMFSMFSPChildNodeErrorHandler::ErrHandlingCommandComplete(PVMFFSPNodeCmdQ& aCmdQ,
+        PVMFSMFSPBaseNodeCommand& aCmd,
+        PVMFStatus aStatus,
+        OsclAny* aData,
+        PVUuid* aEventUUID,
+        int32* aEventCode,
+        PVInterface* aExtMsg)
+{
+    OSCL_UNUSED_ARG(aStatus);
+    OSCL_UNUSED_ARG(aData);
+    OSCL_UNUSED_ARG(aEventUUID);
+    OSCL_UNUSED_ARG(aEventCode);
+    OSCL_UNUSED_ARG(aExtMsg);
+
+    PVMF_SM_ERRHANDLER_LOGSTACKTRACE((0, "PVMFSMFSPChildNodeErrorHandler::ErrHandlingCommandComplete In iCmd[%d]", aCmd.iCmd));
+    switch (aCmd.iCmd)
+    {
+        case PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR:
+        {
+            PVMF_SM_ERRHANDLER_LOGDEBUG((0, "PVMFSMFSPChildNodeErrorHandler::ErrHandlingCommandComplete Queing Reset Due To Err"));
+            PVMFSessionId s = 0;
+            PVMFSMFSPBaseNodeCommand cmdResetDueToErr;
+            cmdResetDueToErr.PVMFSMFSPBaseNodeCommandBase::Construct(s,
+                    PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR,
+                    NULL);
+            iSMFSPNode->QueueErrHandlingCommandL(cmdResetDueToErr);
+            iState = SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION;
+        }
+        break;
+        case PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR:
+        {
+            PVMF_SM_ERRHANDLER_LOGDEBUG((0, "PVMFSMFSPChildNodeErrorHandler::ErrHandlingCommandComplete - Reset Due To Err completed"));
+
+            //Do command completion or notify err event
+            iState = SMFSP_ERRHANDLER_IDLE;	//error handling complete
+            iSMFSPNode->CompleteResetDueToErr();
+            iSMFSPNode->ErrHandlingComplete(iErrCmd);
+        }
+        break;
+    }
+
+    /* Erase the command from the queue */
+    aCmdQ.Erase(&aCmd);
+
+    /* Reschedule AO if input command queue is not empty */
+    if (!iSMFSPNode->iErrHandlingCommandQ.empty() && iSMFSPNode->IsAdded())
+    {
+        iSMFSPNode->RunIfNotReady();
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//PVMFSMNodeKVPStore
+///////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFSMNodeKVPStore::addKVPString(const char* aKeyTypeString, OSCL_wString& aValString)
+{
+    PvmiKvp aKeyVal;
+    aKeyVal.key = NULL;
+    PVMFStatus status = PVMFCreateKVPUtils::CreateKVPForWStringValue(aKeyVal, aKeyTypeString, aValString);
+    if (status != PVMFSuccess) return status;
+    KVPValueTypeForMemoryRelease valType = KVPValueTypeForMemoryRelease_WString;
+    return pushKVPToVector(aKeyVal, valType);
+}
+
+// add kvp string with normal string value
+PVMFStatus PVMFSMNodeKVPStore::addKVPString(const char* aKeyTypeString, const char* aValString)
+{
+    PvmiKvp aKeyVal;
+    aKeyVal.key = NULL;
+    PVMFStatus status = PVMFCreateKVPUtils::CreateKVPForCharStringValue(aKeyVal, aKeyTypeString, aValString);
+    if (status != PVMFSuccess) return status;
+    KVPValueTypeForMemoryRelease valType = KVPValueTypeForMemoryRelease_String;
+    return pushKVPToVector(aKeyVal, valType);
+}
+
+void PVMFSMNodeKVPStore::releaseMemory()
+{
+    OSCL_ASSERT(iKvpVector.size() == iKVPValueTypeForMemoryRelease.size());
+
+    for (uint32 i = 0; i < iKvpVector.size(); i++)
+    {
+        if (iKvpVector[i].key) OSCL_ARRAY_DELETE(iKvpVector[i].key);
+
+        // release memory for appropriate types of KVP value
+        if ((KVPValueTypeForMemoryRelease)iKVPValueTypeForMemoryRelease[i] == KVPValueTypeForMemoryRelease_WString &&
+                iKvpVector[i].value.pWChar_value) OSCL_ARRAY_DELETE(iKvpVector[i].value.pWChar_value);
+        if ((KVPValueTypeForMemoryRelease)iKVPValueTypeForMemoryRelease[i] == KVPValueTypeForMemoryRelease_String &&
+                iKvpVector[i].value.pChar_value) OSCL_ARRAY_DELETE(iKvpVector[i].value.pChar_value);
+    }
+}
+
+PVMFStatus PVMFSMNodeKVPStore::addKVPuint32Value(const char* aKeyTypeString, uint32 aValue)
+{
+    PvmiKvp aKeyVal;
+    aKeyVal.key = NULL;
+    PVMFStatus status = PVMFCreateKVPUtils::CreateKVPForUInt32Value(aKeyVal, aKeyTypeString, aValue);
+    if (status != PVMFSuccess) return status;
+    KVPValueTypeForMemoryRelease valType = KVPValueTypeForMemoryRelease_NoInterest;
+    return pushKVPToVector(aKeyVal, valType);
+}
+
+PVMFStatus PVMFSMNodeKVPStore::pushKVPToVector(const PvmiKvp& aKeyVal, const KVPValueTypeForMemoryRelease& aValueTypeForMemoryRelease)
+{
+    int32 err = 0;
+    OSCL_TRY(err,
+             iKvpVector.push_back(aKeyVal);
+             iKVPValueTypeForMemoryRelease.push_back(OSCL_STATIC_CAST(uint32, aValueTypeForMemoryRelease));
+            );
+    return (err == 0 ? PVMFSuccess : PVMFErrNoMemory);
+}
+
diff --git a/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_pvr_base_impl.cpp b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_pvr_base_impl.cpp
new file mode 100644
index 0000000..fdb1baa
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_pvr_base_impl.cpp
@@ -0,0 +1,3013 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_PVR_BASE_IMPL_H
+#include "pvmf_sm_fsp_pvr_base_impl.h"
+#endif
+
+#ifndef PVMF_JITTER_BUFFER_NODE_H_INCLUDED
+#include "pvmf_jitter_buffer_node.h"
+#endif
+
+#ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
+#include "pvmf_medialayer_node.h"
+#endif
+
+#ifndef OSCL_SNPRINTF_H_INCLUDED
+#include "oscl_snprintf.h"
+#endif
+
+#ifndef AMR_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "amr_payload_parser_factory.h"
+#endif
+
+#ifndef H263_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "h263_payload_parser_factory.h"
+#endif
+
+#ifndef H264_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "h264_payload_parser_factory.h"
+#endif
+
+#ifndef ASF_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "asf_payload_parser_factory.h"
+#endif
+
+#ifndef M4V_AUDIO_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "m4v_audio_payload_parser_factory.h"
+#endif
+
+#ifndef M4V_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "m4v_payload_parser_factory.h"
+#endif
+
+#ifndef PAYLOAD_PARSER_REGISTRY_H_INCLUDED
+#include "payload_parser_registry.h"
+#endif
+
+#ifndef RFC3640_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "rfc3640_payload_parser_factory.h"
+#endif
+
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef PVMI_KVP_UTIL_H_INCLUDED
+#include "pvmi_kvp_util.h"
+#endif
+
+#ifndef PVMI_DRM_KVP_H_INCLUDED
+#include "pvmi_drm_kvp.h"
+#endif
+
+#ifndef PVRTSP_CLIENT_ENGINE_NODE_H
+#include "pvrtsp_client_engine_node.h"
+#endif
+
+#ifndef SDP_PARSER_H
+#include "sdp_parser.h"
+#endif
+
+#ifndef PVMF_PVR_NODE_H_INCLUDED
+#include "pvmf_pvr_node.h"
+#endif
+
+#ifndef PVMF_SOCKET_NODE_H_INCLUDED
+#include "pvmf_socket_node.h"
+#endif
+
+#ifndef PVMF_RTSP_ENGINE_NODE_FACTORY_H_INCLUDED
+#include "pvrtsp_client_engine_factory.h"
+#endif
+
+
+
+PVMFSMFSPPVRBase::PVMFSMFSPPVRBase(int32 aPriority) : PVMFSMFSPBaseNode(aPriority)
+{
+}
+
+
+void PVMFSMFSPPVRBase::BypassError()
+{
+    int32 localMode = 0;
+    if (iPVMFDataSourcePositionParamsPtr != NULL)
+    {
+        localMode = iPVMFDataSourcePositionParamsPtr->iMode;
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::BypassError() - In"));
+    if (CheckChildrenNodesStart())
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand aCmd = iCurrentCommand.front();
+            if ((aCmd.iCmd == PVMF_SMFSP_NODE_START) ||
+                    (aCmd.iCmd == PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION))
+            {
+                if (iRepositioning)
+                {
+                    PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::BypassError() - InRepos"));
+                    iRepositioning = false;
+                    iPlayListRepositioning = false;
+                    iPVMFDataSourcePositionParamsPtr = NULL;
+                    PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
+                        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                    OSCL_ASSERT(jitterBufferNodeContainer);
+                    if (!jitterBufferNodeContainer)
+                        return;
+
+                    PVMFJitterBufferExtensionInterface* jbExtIntf =
+                        (PVMFJitterBufferExtensionInterface*)
+                        (jitterBufferNodeContainer->iExtensions[0]);
+
+                    OSCL_ASSERT(jbExtIntf);
+                    if (!jbExtIntf)
+                        return;
+
+                    /* Set jitter buffer state to ready */
+                    jbExtIntf->UpdateJitterBufferState();
+                }
+                if ((localMode == 0) || (localMode == -1))
+                {
+                    SetState(EPVMFNodeStarted);
+                    if (IsAdded())
+                    {
+                        /* wakeup the AO */
+                        RunIfNotReady();
+                    }
+                    PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::BypassError() - InLocalMode"));
+                    RunIfNotReady();
+                }
+                CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess, NULL, NULL, NULL);
+
+            }
+        }
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::BypassError() - Out"));
+    return;
+}
+
+bool PVMFSMFSPPVRBase::CheckChildrenNodesInit()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool PVMFSMFSPPVRBase::CheckChildrenNodesPause()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE
+                && iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool PVMFSMFSPPVRBase::CheckChildrenNodesPrepare()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool PVMFSMFSPPVRBase::CheckChildrenNodesStart()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool PVMFSMFSPPVRBase::CheckChildrenNodesStop()
+{
+
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+
+    return true;
+}
+
+void PVMFSMFSPPVRBase::CleanUp()
+{
+    ReleaseChildNodesExtentionInterface();
+    DestroyChildNodes();
+    DestroyPayloadParserRegistry();
+    ResetNodeParams();
+    iLogger = NULL;
+}
+
+void PVMFSMFSPPVRBase::ResetNodeParams(bool aReleaseMemory)
+{
+    iPVREnabled = false;
+    if (aReleaseMemory)
+    {
+        if (iPVRExtInterface)
+            iPVRExtInterface->removeRef();
+        //PVR interface is pointing to interface available in nodeconatiner for PVR. So, dont relase it, just make it null, it will be released in func ReleaseChildNodesExtentionInterface
+        iPVRQueryInterface	= NULL;
+        if (iPVRControl)
+        {
+            ;	//todo release the pvr control???
+        }
+    }
+    iPVRExtInterface = NULL;
+    iPVRQueryInterface = NULL;
+    iPVRControl = NULL;
+    iTrackInfoVec.clear();
+    PVMFSMFSPBaseNode::ResetNodeParams(aReleaseMemory);
+}
+
+
+
+void PVMFSMFSPPVRBase::CompletePrepare()
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::CompletePrepare() - In"));
+    if ((CheckChildrenNodesPrepare()) && (iGraphConstructComplete))
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if (aCmd.iCmd == PVMF_SMFSP_NODE_PREPARE)
+            {
+                SetState(EPVMFNodePrepared);
+                PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::Prepare() - CmdComplete - PVMFSuccess"));
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::CompletePrepare() - Out"));
+    return;
+}
+
+void PVMFSMFSPPVRBase::CompleteStop()
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::CompleteStop() - In"));
+    if (CheckChildrenNodesStop())
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if (aCmd.iCmd == PVMF_SMFSP_NODE_STOP)
+            {
+                /* transition to Prepared state */
+                ResetStopCompleteParams();
+                SetState(EPVMFNodePrepared);
+                PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::Stop() - CmdComplete - PVMFSuccess"));
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::CompleteStop() - Out"));
+    return;
+}
+
+PVMFStatus PVMFSMFSPPVRBase::ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+        PVMFTimestamp aActualNPT,
+        PVMFTimestamp aActualMediaDataTS,
+        PVMFTimestamp& aSkipTimeStamp,
+        PVMFTimestamp& aStartNPT)
+{
+    //for RTSP streaming we always start playback from aActualNPT
+    //by defintion aActualMediaDataTS is the timestamp that corresponds
+    //to aActualNPT
+    OSCL_UNUSED_ARG(aTargetNPT);
+    OSCL_UNUSED_ARG(aSkipTimeStamp);
+    OSCL_UNUSED_ARG(aStartNPT);
+    aSkipTimeStamp = aActualMediaDataTS;
+    aStartNPT = aActualNPT;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMFSPPVRBase::ConnectPortPairs(PVMFPortInterface* aPort1,
+        PVMFPortInterface* aPort2)
+{
+    PVMFStatus status;
+
+    status = aPort1->Connect(aPort2);
+
+    if (status != PVMFSuccess)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "StreamingManagerNode:ConnectPortPairs - Connect Failed"));
+        return status;
+    }
+
+    return status;
+}
+
+void PVMFSMFSPPVRBase::Construct()
+{
+    PVMFSMFSPBaseNode::Construct();
+    int32 err;
+    OSCL_TRY(err,
+             iLogger = PVLogger::GetLoggerObject("PVMFSMPVRFilePlaybackNode");
+             iAvailableMetadataKeys.reserve(PVMFSTREAMINGMGRNODE_NUM_METADATAKEYS);
+             iAvailableMetadataKeys.clear();
+             CreateChildNodes();
+             QueryChildNodesExtentionInterface();
+             // create the payload parser registry
+             PopulatePayloadParserRegistry();
+             // pass the payload parser registry on to the media layer node
+             PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+                 getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+             OSCL_ASSERT(iMediaLayerNodeContainer);
+             PVMFMediaLayerNodeExtensionInterface* mlExtIntf = NULL;
+             if (iMediaLayerNodeContainer)
+             mlExtIntf = (PVMFMediaLayerNodeExtensionInterface*)(iMediaLayerNodeContainer->iExtensions[0]);
+             if (mlExtIntf)
+                 mlExtIntf->setPayloadParserRegistry(PayloadParserRegistry::GetPayloadParserRegistry());
+                );
+    if (err != OsclErrNone)
+    {
+        PVMFSMFSPBaseNode::CleanUp();
+        OSCL_LEAVE(err);
+    }
+
+}
+
+void PVMFSMFSPPVRBase::PopulatePayloadParserRegistry()
+{
+    PayloadParserRegistry* registry =
+        PayloadParserRegistry::GetPayloadParserRegistry();
+    OSCL_ASSERT(registry == NULL);
+    PayloadParserRegistry::Init();
+    registry = PayloadParserRegistry::GetPayloadParserRegistry();
+
+    StrPtrLen aac_latm("audio/MP4A-LATM");
+    StrPtrLen amr("audio/AMR");
+    StrPtrLen amrwb("audio/AMR-WB");
+    StrPtrLen h263_old("video/H263-1998");
+    StrPtrLen h263("video/H263-2000");
+    StrPtrLen m4v("video/MP4V-ES");
+    StrPtrLen h264("video/H264");
+    StrPtrLen mp4a(PVMF_MIME_MPEG4_AUDIO);
+    StrPtrLen rfc3640("audio/mpeg4-generic");
+
+    IPayloadParserFactory* m4vP = OSCL_NEW(M4VPayloadParserFactory, ());
+    IPayloadParserFactory* aacP = OSCL_NEW(M4VAudioPayloadParserFactory, ());
+    IPayloadParserFactory* amrP = OSCL_NEW(AmrPayloadParserFactory, ());
+    IPayloadParserFactory* h263P = OSCL_NEW(H263PayloadParserFactory, ());
+    IPayloadParserFactory* h264P = OSCL_NEW(H264PayloadParserFactory, ());
+    IPayloadParserFactory* amrwbP = OSCL_NEW(AmrPayloadParserFactory, ());
+    IPayloadParserFactory* rfc3640P = OSCL_NEW(RFC3640PayloadParserFactory, ());
+
+    registry->addPayloadParserFactoryToRegistry(m4v, m4vP);
+    registry->addPayloadParserFactoryToRegistry(h264, h264P);
+    registry->addPayloadParserFactoryToRegistry(aac_latm, aacP);
+    registry->addPayloadParserFactoryToRegistry(mp4a, aacP);
+    registry->addPayloadParserFactoryToRegistry(amr, amrP);
+    registry->addPayloadParserFactoryToRegistry(amrwb, amrwbP);
+    registry->addPayloadParserFactoryToRegistry(h263_old, h263P);
+    registry->addPayloadParserFactoryToRegistry(h263, h263P);
+    registry->addPayloadParserFactoryToRegistry(rfc3640,  rfc3640P);
+}
+
+
+void PVMFSMFSPPVRBase::createContext(PvmiMIOSession aSession,
+                                     PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // not supported
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+void PVMFSMFSPPVRBase::DeleteContext(PvmiMIOSession aSession,
+                                     PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // not supported
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+void PVMFSMFSPPVRBase::DestroyPayloadParserRegistry()
+{
+    StrPtrLen aac_latm("audio/MP4A-LATM");
+    StrPtrLen amr("audio/AMR");
+    StrPtrLen amrwb("audio/AMR-WB");
+    StrPtrLen h263("video/H263-2000");
+    StrPtrLen m4v("video/MP4V-ES");
+    StrPtrLen h264("video/H264");
+    StrPtrLen rfc3640("audio/mpeg4-generic");
+
+    PayloadParserRegistry* registry =
+        PayloadParserRegistry::GetPayloadParserRegistry();
+    if (registry == NULL) return;
+
+    OsclMemoryFragment memFrag;
+
+    memFrag.ptr = (OsclAny*)(m4v.c_str());
+    memFrag.len = (uint32)m4v.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h264.c_str());
+    memFrag.len = (uint32)h264.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(aac_latm.c_str());
+    memFrag.len = (uint32)aac_latm.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amr.c_str());
+    memFrag.len = (uint32)amr.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amrwb.c_str());
+    memFrag.len = (uint32)amrwb.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h263.c_str());
+    memFrag.len = (uint32)h263.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(rfc3640.c_str());
+    memFrag.len = (uint32)rfc3640.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    PayloadParserRegistry::Cleanup();
+}
+
+PVMFCommandId PVMFSMFSPPVRBase::DoGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    return DoGetMetadataKeysBase(aCmd);
+}
+
+PVMFCommandId PVMFSMFSPPVRBase::DoGetMetadataValues(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    iNoOfValuesIteratedForValueVect = 0;
+    iNoOfValuesPushedInValueVect = 0;
+    PVMFStatus retval = GetPVRPluginSpecificValues(aCmd);
+    if (PVMFSuccess != retval)
+        return retval;
+    return DoGetMetadataValuesBase(aCmd);
+}
+
+void PVMFSMFSPPVRBase::DoPrepare(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoPrepare - In"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        {
+            if (iGraphConstructComplete)
+            {
+                /*
+                 * Connect the graph here. This is needed since we would send firewall packets
+                 * as part of Prepare.
+                 */
+                if (GraphConnect() == false)
+                {
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:DoPrepare - GraphConnect Failed"));
+                    SetState(EPVMFNodeError);
+                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+                    int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
+                    CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
+                    return;
+                }
+
+                /*
+                 * Prepare for streaming manager cannot be completed unless Prepare
+                 * for all the children nodes are complete
+                 */
+                PVMFSMFSPChildNodeContainerVector::iterator it;
+                for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+                {
+                    PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                    if (internalCmd != NULL)
+                    {
+                        internalCmd->cmd =
+                            it->commandStartOffset +
+                            PVMF_SM_FSP_NODE_INTERNAL_PREPARE_CMD_OFFSET;
+                        internalCmd->parentCmd = aCmd.iCmd;
+
+                        OsclAny *cmdContextData =
+                            OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                        PVMFNodeInterface* iNode = it->iNode;
+
+                        iNode->Prepare(it->iSessionId, cmdContextData);
+                        it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                    }
+                    else
+                    {
+                        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:DoPrepare:RequestNewInternalCmd - Failed"));
+                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                        return;
+                    }
+                }
+
+                MoveCmdToCurrentQueue(aCmd);
+            }
+            else
+            {
+                /* Graph construction not complete, so cant prep */
+                PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:DoPrepare Failed - Incomplete Graph"));
+                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            }
+        }
+        break;
+
+        default:
+            PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:DoPrepare Failed - Invalid State"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoPrepare - Out"));
+}
+
+void PVMFSMFSPPVRBase::DoQueryDataSourcePosition(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoQueryDataSourcePosition - In"));
+
+    PVMFTimestamp repositionrequestedstartnptinms = 0;
+    PVMFTimestamp* actualrepositionstartnptinmsptr = NULL;
+    bool seektosyncpoint = false;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(repositionrequestedstartnptinms,
+                                         actualrepositionstartnptinmsptr,
+                                         seektosyncpoint);
+
+    if (actualrepositionstartnptinmsptr == NULL)
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+        return;
+    }
+    *actualrepositionstartnptinmsptr = 0;
+
+    // This query is not supported for streaming sessions
+    CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoQueryDataSourcePosition - Out"));
+    return;
+}
+
+void PVMFSMFSPPVRBase::DoReleasePort(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoReleasePort - In"));
+    /*
+     * Since the streaming manager does not have ports of its own,
+     * a release port command typically translates to disconnecting
+     * the underlying media layer port.
+     */
+    PVMFPortInterface* port;
+    aCmd.PVMFSMFSPBaseNodeCommandBase::Parse((PVMFPortInterface*&)port);
+
+    /*
+     * Find TrackInfo that corresponds to the Media Layer Output port
+     * on which the current relase is being called.
+     */
+    PVMFPVRBaseTrackInfoVector::iterator it;
+    PVMFPVRBaseTrackInfo* trackInfo = NULL;
+
+    for (it = iTrackInfoVec.begin();
+            it != iTrackInfoVec.end();
+            it++)
+    {
+        if (it->iMediaLayerOutputPort == port)
+        {
+            trackInfo = it;
+            break;
+        }
+    }
+
+    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+    if (trackInfo == NULL)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::ReleasePort() - CmdFailed - PVMFErrArgument"));
+        /* invalid port */
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMPVRFilePlaybackNode::DoReleasePort Failed - Invalid Port"));
+        int32 errcode = PVMFStreamingManagerNodeErrorInvalidPort;
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
+        return;
+    }
+    PVMFStatus status = it->iMediaLayerOutputPort->Disconnect();
+
+    if (status != PVMFSuccess)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::DoReleasePort Success"));
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::DoReleasePort Failed"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrPortProcessing);
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoReleasePort - Out"));
+}
+
+PVMFPVRBaseTrackInfo* PVMFSMFSPPVRBase::FindTrackInfo(uint32 atrackID)
+{
+    PVMFPVRBaseTrackInfoVector::iterator it;
+
+    for (it = iTrackInfoVec.begin();
+            it != iTrackInfoVec.end();
+            it++)
+    {
+        if (it->trackID == atrackID)
+        {
+            return (it);
+        }
+    }
+    return NULL;
+}
+
+void PVMFSMFSPPVRBase::DoRequestPort(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoRequestPort - In"));
+    /*
+     * This node supports port request only after the graph
+     * has been fully constructed
+     */
+    if (iGraphConstructComplete)
+    {
+        /*
+         * retrieve port tag
+         */
+        OSCL_String* mimetype;
+        int32 tag;
+        aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(tag, mimetype);
+        /*
+         * Do not Allocate a new port. RTSP unicast node treats the output
+         * port from the media layer as its own output port. Find the media
+         * layer output port corresponding to the input mimetype and hand the
+         * same out
+         */
+        PVMFPVRBaseTrackInfo* trackInfo = FindTrackInfo(tag);
+
+        PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+        int32 errcode = PVMFStreamingManagerNodeErrorInvalidRequestPortTag;
+
+        if (trackInfo == NULL)
+        {
+            PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::DoRequestPort: FindTrackInfo failed"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
+            return;
+        }
+        if (trackInfo->iMediaLayerOutputPort == NULL)
+        {
+            PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::DoRequestPort: iMediaLayerOutputPort NULL"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
+            return;
+        }
+        PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::DoRequestPort() - CmdComplete - PVMFSuccess"));
+        /*
+         * Return the port pointer to the caller.
+         */
+        CommandComplete(iInputCommands,
+                        aCmd,
+                        PVMFSuccess,
+                        (OsclAny*)(trackInfo->iMediaLayerOutputPort));
+
+        PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::DoRequestPort Success"));
+    }
+    else
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::RequestPort() - CmdFailed - PVMFErrInvalidState"));
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::DoRequestPort Failed - InvalidState"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoRequestPort - Out"));
+}
+
+void PVMFSMFSPPVRBase::DoStop(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoStop - In"));
+    iStreamID = 0;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        {
+            /*
+             * Stop for streaming manager cannot be completed unless
+             * Stop for all the children nodes are complete
+             */
+            PVMFSMFSPChildNodeContainerVector::iterator it;
+            for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+            {
+                PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                if (internalCmd != NULL)
+                {
+                    internalCmd->cmd =
+                        it->commandStartOffset +
+                        PVMF_SM_FSP_NODE_INTERNAL_STOP_CMD_OFFSET;
+                    internalCmd->parentCmd = aCmd.iCmd;
+
+                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                    PVMFNodeInterface* iNode = it->iNode;
+
+                    iNode->Stop(it->iSessionId, cmdContextData);
+                    it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                }
+                else
+                {
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:DoStop:RequestNewInternalCmd - Failed"));
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                    return;
+                }
+            }
+            MoveCmdToCurrentQueue(aCmd);
+        }
+        break;
+
+        default:
+            PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::DoStop Failure - Invalid State"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoStop - Out"));
+}
+
+void PVMFSMFSPPVRBase::GetAcutalMediaTSAfterSeek()
+{
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+        (PVMFMediaLayerNodeExtensionInterface*)
+        (iMediaLayerNodeContainer->iExtensions[0]);
+    if (mlExtIntf == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+            (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+    {
+
+        iActualMediaDataTS = jbExtIntf->getActualMediaDataTSAfterSeek();
+        if (iActualMediaDataTSPtr != NULL)
+        {
+            *iActualMediaDataTSPtr = iActualMediaDataTS;
+            PVMF_SM_FSP_PVR_BASE_LOGCOMMANDREPOS((0, "PVMFSMFSPPVRBase::GetAcutalMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
+                                                  iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
+        }
+        if (iPVMFDataSourcePositionParamsPtr != NULL)
+        {
+            iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS = iActualMediaDataTS;
+            PVMF_SM_FSP_PVR_BASE_LOGCOMMANDREPOS((0, "PVMFSMFSPPVRBase::GetAcutalMediaTSAfterSeek - ActualMediaDataTS=%d",
+                                                  iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS));
+        }
+    }
+}
+
+uint32 PVMFSMFSPPVRBase::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    OSCL_UNUSED_ARG(aSession);
+    return 0;
+}
+
+PVMFStatus PVMFSMFSPPVRBase::GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo)
+{
+    SDPInfo* sdpInfo = iSdpInfo.GetRep();
+
+    /* Get SDP Session Info */
+    sessionDescription* sessionInfo = sdpInfo->getSessionInfo();
+
+    RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
+
+    int32 sessionStartTime = 0, sessionStopTime = 0;
+
+    sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
+
+    int32 duration_msec = (sessionStopTime - sessionStartTime);
+
+    uint64 duration64;
+    Oscl_Int64_Utils::set_uint64(duration64, 0, (uint32)duration_msec);
+
+    if (sessionRange->end_is_set == true)
+    {
+        aInfo.setDurationValue(duration64);
+        aInfo.setDurationTimeScale(1000);
+    }
+    else
+    {
+        aInfo.SetDurationAvailable(false);
+    }
+
+    aInfo.setSeekableFlag((!(sessionInfo->getRandomAccessDenied())));
+
+    int32 numTracks = sdpInfo->getNumMediaObjects();
+
+    SDPAltGroupType sdpAltGroupType = sessionInfo->getSDPAltGroupType();
+
+    PVMF_TRACK_INFO_TRACK_ALTERNATE_TYPE altType = PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED;
+
+    if (sdpAltGroupType == SDP_ALT_GROUP_LANGUAGE)
+    {
+        altType = PVMF_TRACK_ALTERNATE_TYPE_LANGUAGE;
+    }
+    else if (sdpAltGroupType == SDP_ALT_GROUP_BANDWIDTH)
+    {
+        altType = PVMF_TRACK_ALTERNATE_TYPE_BANDWIDTH;
+    }
+
+    for (int32 i = 0; i < numTracks; i++)
+    {
+        /*
+         * Get the vector of mediaInfo as there can
+         * alternates for each track
+         */
+        Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
+            sdpInfo->getMediaInfo(i);
+
+        uint32 minfoVecLen = mediaInfoVec.size();
+
+        for (uint32 j = 0; j < minfoVecLen; j++)
+        {
+            mediaInfo* mInfo = mediaInfoVec[j];
+
+            if (mInfo == NULL)
+            {
+                return PVMFFailure;
+            }
+
+            RtspRangeType *mediaRange = mInfo->getRtspRange();
+
+            int32 mediaStartTime = 0, mediaStopTime = 0;
+
+            mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
+            int32 mediaDuration_ms = mediaStopTime - mediaStartTime;
+            uint64 mediaDuration64;
+            Oscl_Int64_Utils::set_uint64(mediaDuration64, 0, (uint32)mediaDuration_ms);
+
+            PVMFTrackInfo trackInfo;
+
+            Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
+            payloadVector = mInfo->getPayloadSpecificInfoVector();
+
+            if (payloadVector.size() == 0)
+            {
+                return PVMFFailure;
+            }
+            /*
+             * There can be multiple payloads per media segment.
+             * We only support one for now, so
+             * use just the first payload
+             */
+            PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
+
+            // set config for later
+            int32 configSize = payloadInfo->configSize;
+            OsclAny* config = payloadInfo->configHeader.GetRep();
+
+            OSCL_StackString<256> mimeString;
+            const char* mimeType = mInfo->getMIMEType();
+            mimeString += mimeType;
+
+            trackInfo.setTrackMimeType(mimeString);
+
+            uint32 trackID = mInfo->getMediaInfoID();
+
+            trackInfo.setTrackID(trackID);
+            trackInfo.setPortTag(trackID);
+
+            trackInfo.setTrackBitRate(mInfo->getBitrate());
+
+            if (mediaRange->end_is_set == true)
+            {
+                trackInfo.setTrackDurationValue(mediaDuration64);
+            }
+            else
+            {
+                trackInfo.SetDurationAvailable(false);
+            }
+
+            if ((configSize > 0) && (config != NULL))
+            {
+                OsclMemAllocDestructDealloc<uint8> my_alloc;
+                OsclRefCounter* my_refcnt;
+                uint aligned_refcnt_size =
+                    oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+
+                uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
+                if (!my_ptr)
+                    return false;
+
+                my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
+                my_ptr += aligned_refcnt_size;
+
+                OsclMemoryFragment memfrag;
+                memfrag.len = (uint32)configSize;
+                memfrag.ptr = my_ptr;
+
+                oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
+
+                OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
+                trackInfo.setTrackConfigInfo(tmpRefcntMemFrag);
+            }
+
+            int32 dependsOnTrackID = mInfo->getDependsOnTrackID();
+
+            if (dependsOnTrackID != -1)
+            {
+                trackInfo.setDependsOn();
+                mediaInfo* baseMediaInfo = sdpInfo->getMediaInfoBasedOnDependsOnID(dependsOnTrackID);
+                if (baseMediaInfo == NULL)
+                {
+                    return PVMFFailure;
+                }
+                trackInfo.addDependsOnTrackID(baseMediaInfo->getMediaInfoID());
+            }
+
+            if (altType != PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED)
+            {
+                /* Expose alternate track ids */
+                trackInfo.setTrackAlternates(altType);
+                for (uint32 k = 0; k < minfoVecLen; k++)
+                {
+                    mediaInfo* mInfo = mediaInfoVec[k];
+                    if (mInfo == NULL)
+                    {
+                        return PVMFFailure;
+                    }
+                    uint32 altID = mInfo->getMediaInfoID();
+                    if (altID != trackID)
+                    {
+                        trackInfo.addAlternateTrackID((int32)altID);
+                    }
+                }
+            }
+            aInfo.addTrackInfo(trackInfo);
+        }
+    }
+    iCompleteMediaPresetationInfo = aInfo;
+    return PVMFSuccess;
+}
+
+uint32 PVMFSMFSPPVRBase::GetNumMetadataKeys(char* aQueryKeyString)
+{
+    //Metadata is avaialable in three forms
+    //1. Metadata common to streaming of all type of payloads and FF specific metadata
+    //2. Streaming specific metadata
+    //3. CPM metadata
+    //First two types are avaiable in iAvailableMetaDatakeys vector
+    //Third type can be had from metadataextension interface
+    //base class considers count of all of these
+    return PVMFSMFSPBaseNode::GetNumMetadataKeysBase(aQueryKeyString);
+}
+
+uint32 PVMFSMFSPPVRBase::GetNumMetadataValues(PVMFMetadataList& aKeyList)
+{
+    //Metadata is avaialable in three forms
+    //1. Metadata common to streaming of all type of payloads and FF specific metadata
+    //2. Streaming specific metadata
+    //3. CPM metadata
+    //First two types are avaiable in iAvailableMetaDatakeys vector
+    //Third type can be had from metadataextension interface
+    //Base class considers count of all of these
+    return PVMFSMFSPBaseNode::GetNumMetadataValuesBase(aKeyList);
+}
+
+PVMFStatus PVMFSMFSPPVRBase::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters, int& aNumParamElements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+
+    // Initialize the output parameters
+    aNumParamElements = 0;
+    aParameters = NULL;
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aIdentifier);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aIdentifier, compstr);
+
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+    {
+        // First component should be "x-pvmf" and there must
+        // be at least two components to go past x-pvmf
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::getParametersSync() Invalid key string"));
+        return PVMFErrArgument;
+    }
+
+    // Retrieve the second component from the key string
+    pv_mime_string_extract_type(1, aIdentifier, compstr);
+
+    // Check if it is key string for streaming manager
+    if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) < 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::getParametersSync() Unsupported key"));
+        return PVMFFailure;
+    }
+
+
+    if (compcount == 2)
+    {
+        // Since key is "x-pvmf/net" return all
+        // nodes available at this level. Ignore attribute
+        // since capability is only allowed
+
+        // Allocate memory for the KVP list
+        aParameters = (PvmiKvp*)oscl_malloc(StreamingManagerConfig_NumBaseKeys * sizeof(PvmiKvp));
+        if (aParameters == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::getParametersSync() Memory allocation for KVP failed"));
+            return PVMFErrNoMemory;
+        }
+        oscl_memset(aParameters, 0, StreamingManagerConfig_NumBaseKeys*sizeof(PvmiKvp));
+        // Allocate memory for the key strings in each KVP
+        PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(StreamingManagerConfig_NumBaseKeys * SMCONFIG_KEYSTRING_SIZE * sizeof(char));
+        if (memblock == NULL)
+        {
+            oscl_free(aParameters);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::getParametersSync() Memory allocation for key string failed"));
+            return PVMFErrNoMemory;
+        }
+        oscl_strset(memblock, 0, StreamingManagerConfig_NumBaseKeys*SMCONFIG_KEYSTRING_SIZE*sizeof(char));
+        // Assign the key string buffer to each KVP
+        uint32 j;
+        for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
+        {
+            aParameters[j].key = memblock + (j * SMCONFIG_KEYSTRING_SIZE);
+        }
+        // Copy the requested info
+        for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
+        {
+            oscl_strncat(aParameters[j].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
+            oscl_strncat(aParameters[j].key, StreamingManagerConfig_BaseKeys[j].iString, oscl_strlen(StreamingManagerConfig_BaseKeys[j].iString));
+            oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";type="), 6);
+            switch (StreamingManagerConfig_BaseKeys[j].iType)
+            {
+                case PVMI_KVPTYPE_AGGREGATE:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_AGGREGATE_STRING), oscl_strlen(PVMI_KVPTYPE_AGGREGATE_STRING));
+                    break;
+
+                case PVMI_KVPTYPE_POINTER:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_POINTER_STRING), oscl_strlen(PVMI_KVPTYPE_POINTER_STRING));
+                    break;
+
+                case PVMI_KVPTYPE_VALUE:
+                default:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_VALUE_STRING), oscl_strlen(PVMI_KVPTYPE_VALUE_STRING));
+                    break;
+            }
+            oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";valtype="), 9);
+            switch (StreamingManagerConfig_BaseKeys[j].iValueType)
+            {
+                case PVMI_KVPVALTYPE_RANGE_INT32:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_KSV:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_CHARPTR:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_BOOL:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_UINT32:
+                default:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
+                    break;
+            }
+            aParameters[j].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
+        }
+
+        aNumParamElements = StreamingManagerConfig_NumBaseKeys;
+    }
+    else if (compcount == 3)
+    {
+        pv_mime_string_extract_type(2, aIdentifier, compstr);
+
+        // Determine what is requested
+        PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
+        if (reqattr == PVMI_KVPATTR_UNKNOWN)
+        {
+            reqattr = PVMI_KVPATTR_CUR;
+        }
+        uint i;
+        for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
+        {
+            if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
+            {
+                break;
+            }
+        }
+
+        if (i == StreamingManagerConfig_NumBaseKeys)
+        {
+            // no match found
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMFSPPVRBase:getParametersSync() Unsupported key"));
+            return PVMFErrArgument;
+        }
+
+        PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, i, reqattr);
+        if (retval != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMFSPPVRBase::getParametersSync() "
+                             "Retrieving streaming manager parameter failed"));
+            return retval;
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::getParametersSync() Unsupported key"));
+        return PVMFErrArgument;
+    }
+
+    return PVMFSuccess;
+}
+
+
+void PVMFSMFSPPVRBase::HandleMediaLayerCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
+{
+    aPerformErrHandling = false;
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+    cmdContextData->oFree = true;
+
+    PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::HandleMediaLayerCommandCompleted In - cmd [%d] iMediaLayerNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iMediaLayerNodeContainer->iNodeCmdState, iInterfaceState));
+
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_MEDIA_LAYER_QUERY_UUID);
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_MEDIA_LAYER_QUERY_INTERFACE);
+    if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+    {
+        if (cmdContextData->cmd == PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT)
+        {
+            //This is last of the request ports
+            OSCL_ASSERT(iMediaLayerNodeContainer->iNumRequestPortsPending > 0);
+            if (--iMediaLayerNodeContainer->iNumRequestPortsPending == 0)
+            {
+                iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            }
+        }
+        else
+        {
+            iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+    }
+    else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+    {
+        if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
+        {
+            iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+        else
+        {
+            PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::HandleMediaLayerCommandCompleted cmd completion for cmd other than cancel during cancellation"));
+            //if cancel is pending and if the parent cmd is not cancel then this is
+            //is most likely the cmd that is being cancelled.
+            //we ignore cmd completes from child nodes if cancel is pending
+            //we simply wait on cancel complete and cancel the pending cmd
+            return;
+        }
+    }
+    else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::HandleMediaLayerCommandCompleted container in IDLE state already"));
+        /*
+         * This is to handle a usecase where a node reports cmd complete for cancelall first
+         * and then reports cmd complete on the cmd that was meant to be cancelled.
+         * There are two possible scenarios that could arise based on this:
+         * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
+         * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
+         * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
+         * ii) SM node is still waiting on some other child nodes to complete cancelall.
+         * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
+         * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
+         * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
+         * Or this is the case of node reporting cmd complete multiple times for a cmd, which
+         * also can be ignored
+         */
+        return;
+    }
+
+    if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
+    {
+        aPerformErrHandling = true;
+        return;
+    }
+
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        if (aResponse.GetCmdStatus() != PVMFErrCancelled)
+        {
+            aPerformErrHandling = true;
+        }
+
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::HandleMediaLayerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
+        if (IsBusy())
+        {
+            Cancel();
+            RunIfNotReady();
+        }
+        return;
+    }
+
+    switch (cmdContextData->cmd)
+    {
+        case PVMF_SM_FSP_MEDIA_LAYER_INIT:
+            CompleteInit();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_PREPARE:
+            CompletePrepare();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_START:
+        {
+            CompleteStart();
+        }
+        break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_STOP:
+        {
+            CompleteStop();
+        }
+        break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_FLUSH:
+            CompleteFlush();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_PAUSE:
+            CompletePause();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_RESET:
+            CompleteReset();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT:
+        {
+            PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+                (PVMFMediaLayerNodeExtensionInterface*)
+                (iMediaLayerNodeContainer->iExtensions[0]);
+
+            if (mlExtIntf == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+
+            /*
+             * Save the port in TrackInfo
+             */
+            PVMFPVRBaseTrackInfo* trackInfo =
+                FindTrackInfo(cmdContextData->portContext.trackID);
+
+            PVMFPortInterface* port =
+                (PVMFPortInterface*)aResponse.GetEventData();
+            OSCL_ASSERT(trackInfo && port);
+            if (!trackInfo || !port)
+                return;
+
+            if (cmdContextData->portContext.portTag ==
+                    PVMF_MEDIALAYER_PORT_TYPE_INPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iMediaLayerInputPort = port;
+                iMediaLayerNodeContainer->iInputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_MEDIALAYER_PORT_TYPE_OUTPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iMediaLayerOutputPort = port;
+                iMediaLayerNodeContainer->iOutputPorts.push_back(port);
+                uint32 preroll32 = 0;
+                bool live = false;
+                mlExtIntf->setOutPortStreamParams(port,
+                                                  cmdContextData->portContext.trackID,
+                                                  preroll32,
+                                                  live);
+            }
+            mediaInfo* mInfo = NULL;
+
+            SDPInfo* sdpInfo = iSdpInfo.GetRep();
+            if (sdpInfo == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+            if (trackInfo)
+            {
+                mInfo = sdpInfo->getMediaInfoBasedOnID(trackInfo->trackID);
+                mlExtIntf->setPortMediaParams(port, trackInfo->iTrackConfig, mInfo);
+            }
+            CompleteGraphConstruct();
+        }
+        break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_CANCEL_ALL_COMMANDS:
+        {
+            CompleteChildNodesCmdCancellation();
+        }
+        break;
+
+        default:
+            break;
+    }
+    return;
+}
+
+bool PVMFSMFSPPVRBase::IsFSPInternalCmd(PVMFCommandId aId)
+{
+    OSCL_UNUSED_ARG(aId);
+    return false;
+}
+
+void PVMFSMFSPPVRBase::NodeCommandCompleted(const PVMFCmdResp& aResponse)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::NodeCommandCompleted"));
+    bool performErrHandling = false;
+    HandleChildNodeCommandCompletion(aResponse, performErrHandling);
+    PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::NodeCommandCompleted - performErrHandling[%d]", performErrHandling));
+
+    if (performErrHandling == true)
+    {
+        HandleError(aResponse);
+    }
+
+    return;
+}
+
+PVMFStatus PVMFSMFSPPVRBase::PopulateAvailableMetadataKeys()
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode,
+             PVMFSMFSPBaseNode::PopulateAvailableMetadataKeys();
+
+             //Add feature specific streaming metadata keys
+             // Create the parameter string for the index range
+             if (iMetaDataInfo->iNumTracks > 0)
+{
+    char indexparam[18];
+        oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo->iNumTracks - 1));
+        indexparam[17] = NULL_TERM_CHAR;
+
+        iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY);
+        iAvailableMetadataKeys[0] += indexparam;
+    }
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY);
+            );
+
+    if (leavecode != OsclErrNone)
+        return leavecode;
+    else
+        return PVMFSuccess;
+}
+
+void PVMFSMFSPPVRBase::PopulateDRMInfo()
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::PopulateDRMInfo() In"));
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::PopulateDRMInfo() - CPM not supported yet"));
+}
+
+bool PVMFSMFSPPVRBase::PopulateTrackInfoVec()
+{
+    if (iSelectedMediaPresetationInfo.getNumTracks() == 0)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:PopulateTrackInfoVec - Selected Track List Empty"));
+        return false;
+    }
+
+    /*
+     * Get selected tracks
+     */
+
+    int32 numTracks = iSdpInfo->getNumMediaObjects();
+
+    if (numTracks > 0)
+    {
+        for (int32 i = 0; i < numTracks; i++)
+        {
+            /*
+             * Get the vector of mediaInfo as there can
+             * alternates for each track
+             */
+            Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
+                iSdpInfo->getMediaInfo(i);
+
+            uint32 minfoVecLen = mediaInfoVec.size();
+            for (uint32 j = 0; j < minfoVecLen; j++)
+            {
+                mediaInfo* mInfo = mediaInfoVec[j];
+
+                if (mInfo == NULL)
+                {
+                    return false;
+                }
+
+                if (mInfo->getSelect())
+                {
+                    PVMFPVRBaseTrackInfo trackInfo;
+
+                    trackInfo.trackID = mInfo->getMediaInfoID();
+                    trackInfo.iTransportType += _STRLIT_CHAR("RTP");
+
+                    Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
+                    payloadVector = mInfo->getPayloadSpecificInfoVector();
+
+                    if (payloadVector.size() == 0)
+                    {
+                        return false;
+                    }
+                    /*
+                     * There can be multiple payloads per media segment.
+                     * We only support one for now, so
+                     * use just the first payload
+                     */
+                    PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
+                    trackInfo.trackTimeScale = payloadInfo->sampleRate;
+
+                    // set config for later
+                    int32 configSize = payloadInfo->configSize;
+                    OsclAny* config = payloadInfo->configHeader.GetRep();
+
+                    const char* mimeType = mInfo->getMIMEType();
+                    trackInfo.iMimeType += mimeType;
+                    trackInfo.portTag = mInfo->getMediaInfoID();
+                    trackInfo.bitRate = mInfo->getBitrate();
+                    if (mInfo->getReportFrequency() > 0)
+                    {
+                        trackInfo.iRateAdaptation = true;
+                        trackInfo.iRateAdaptationFeedBackFrequency =
+                            mInfo->getReportFrequency();
+                    }
+
+                    if ((mInfo->getRTCPReceiverBitRate() >= 0) &&
+                            (mInfo->getRTCPSenderBitRate() >= 0))
+                    {
+                        trackInfo.iRR = mInfo->getRTCPReceiverBitRate();
+                        trackInfo.iRS = mInfo->getRTCPSenderBitRate();
+                        trackInfo.iRTCPBwSpecified = true;
+                    }
+
+                    if ((configSize > 0) && (config != NULL))
+                    {
+                        OsclMemAllocDestructDealloc<uint8> my_alloc;
+                        OsclRefCounter* my_refcnt;
+                        uint aligned_refcnt_size =
+                            oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+
+                        uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
+                        if (!my_ptr)
+                            return false;
+
+                        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
+                        my_ptr += aligned_refcnt_size;
+
+                        OsclMemoryFragment memfrag;
+                        memfrag.len = (uint32)configSize;
+                        memfrag.ptr = my_ptr;
+
+                        oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
+
+                        OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
+                        trackInfo.iTrackConfig = tmpRefcntMemFrag;
+                    }
+                    iTrackInfoVec.push_back(trackInfo);
+                }
+            }
+        }
+    }
+    else
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:PopulateTrackInfoVec - Selected Track List Empty"));
+        return false;
+    }
+
+    return true;
+}
+
+bool PVMFSMFSPPVRBase::ProcessCommand(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    if (EPVMFNodeError == iInterfaceState)
+    {
+        if (iCurrErrHandlingCommand.size() > 0)
+        {
+            return false;
+        }
+        switch (aCmd.iCmd)
+        {
+            case PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR:
+                DoCancelAllPendingCommands(aCmd);
+                break;
+            case PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR:
+                DoResetDueToErr(aCmd);
+                break;
+        }
+
+        return true;
+    }
+
+
+    /*
+     * normally this node will not start processing one command
+     * until the prior one is finished.  However, a hi priority
+     * command such as Cancel must be able to interrupt a command
+     * in progress.
+     */
+    if ((iCurrentCommand.size() > 0 && !aCmd.hipri()
+            && aCmd.iCmd != PVMF_SMFSP_NODE_CANCEL_GET_LICENSE)
+            || iCancelCommand.size() > 0)
+        return false;
+
+    OSCL_ASSERT(aCmd.iCmd != PVMF_SMFSP_NODE_QUERYUUID);
+    OSCL_ASSERT(aCmd.iCmd != PVMF_SMFSP_NODE_SET_DATASOURCE_RATE);
+    switch (aCmd.iCmd)
+    {
+            /* node interface commands */
+        case PVMF_SMFSP_NODE_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_INIT:
+            DoInit(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_PREPARE:
+            DoPrepare(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_START:
+            DoStart(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_STOP:
+            DoStop(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_FLUSH:
+            DoFlush(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_PAUSE:
+            DoPause(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_RESET:
+            DoReset(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_CANCELALLCOMMANDS:
+            DoCancelAllCommands(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_CANCELCOMMAND:
+            DoCancelCommand(aCmd);
+            break;
+
+            /* add extention interface commands */
+        case PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION:
+            if (iPlayListRepositioning == true)
+            {
+                DoSetDataSourcePositionPlayList(aCmd);
+            }
+            else
+            {
+                DoSetDataSourcePosition(aCmd);
+            }
+            break;
+
+        case PVMF_SMFSP_NODE_QUERY_DATASOURCE_POSITION:
+            DoQueryDataSourcePosition(aCmd);
+            break;
+
+        case PVMF_SMFSP_NODE_GETNODEMETADATAKEYS:
+        {
+            PVMFStatus status = DoGetMetadataKeys(aCmd);
+            if (status != PVMFPending)
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+            else
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_GETNODEMETADATAVALUES:
+        {
+            PVMFStatus status = DoGetMetadataValues(aCmd);
+            if (status != PVMFPending)
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+            else
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_GET_LICENSE_W:
+        {
+            PVMFStatus status = DoGetLicense(aCmd, true);
+            if (status == PVMFPending)
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+            else
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_GET_LICENSE:
+        {
+            PVMFStatus status = DoGetLicense(aCmd);
+            if (status == PVMFPending)
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+            else
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_CANCEL_GET_LICENSE:
+            DoCancelGetLicense(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_CAPCONFIG_SETPARAMS:
+        {
+            PvmiMIOSession session;
+            PvmiKvp* aParameters;
+            int num_elements;
+            PvmiKvp** ppRet_kvp;
+            aCmd.Parse(session, aParameters, num_elements, ppRet_kvp);
+            setParametersSync(NULL, aParameters, num_elements, *ppRet_kvp);
+            ciObserver->SignalEvent(aCmd.iId);
+        }
+        break;
+
+        /* internal commands common to all types of streaming*/
+        case PVMF_SMFSP_NODE_CONSTRUCT_SESSION:	//to construct the graph
+        {
+            PVMFStatus status = DoGraphConstruct();
+            if (status != PVMFPending)
+            {
+                InternalCommandComplete(iInputCommands, aCmd, status);
+            }
+            else
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+        }
+        break;
+
+        /* unknown commands */
+        default:
+            /* unknown command type */
+            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+            break;
+    }
+    return true;
+}
+
+void PVMFSMFSPPVRBase::ReleaseChildNodesExtentionInterface()
+{
+    uint32 i, j;
+    for (i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        for (j = 0; j < iFSPChildNodeContainerVec[i].iExtensions.size(); j++)
+        {
+            PVInterface* extIntf = iFSPChildNodeContainerVec[i].iExtensions[j];
+            extIntf->removeRef();
+            extIntf = NULL;
+        }
+        iFSPChildNodeContainerVec[i].iExtensions.clear();
+    }
+}
+
+PVMFStatus PVMFSMFSPPVRBase::ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
+        uint32 aStartingKeyIndex,
+        uint32 aEndKeyIndex)
+{
+    //no allocation for any keys took in derived class so just calling base class release functions
+    return ReleaseNodeMetadataKeysBase(aKeyList, aStartingKeyIndex, aEndKeyIndex);
+}
+
+PVMFStatus PVMFSMFSPPVRBase::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+        uint32 aStartingValueIndex,
+        uint32 aEndValueIndex)
+{
+    return ReleaseNodeMetadataValuesBase(aValueList, aStartingValueIndex, aEndValueIndex);
+}
+
+PVMFStatus PVMFSMFSPPVRBase::releaseParameters(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMFSPPVRBase::releaseParameters() In"));
+
+    if (aParameters == NULL || num_elements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMFSPPVRBase::releaseParameters() KVP list is NULL or number of elements is 0"));
+        return PVMFErrArgument;
+    }
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aParameters[0].key);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
+
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+    {
+        // First component should be "x-pvmf" and there must
+        // be at least two components to go past x-pvmf
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMFSPPVRBase::releaseParameters() Unsupported key"));
+        return PVMFErrArgument;
+    }
+
+    // Retrieve the second component from the key string
+    pv_mime_string_extract_type(1, aParameters[0].key, compstr);
+
+    // Assume all the parameters come from the same component so the base components are the same
+    if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
+    {
+        // Go through each KVP and release memory for value if allocated from heap
+        for (int32 i = 0; i < num_elements; ++i)
+        {
+            // Next check if it is a value type that allocated memory
+            PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[i].key);
+            if (kvptype == PVMI_KVPTYPE_VALUE || kvptype == PVMI_KVPTYPE_UNKNOWN)
+            {
+                PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[i].key);
+                if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFSMFSPPVRBase::releaseParameters() Valtype not specified in key string"));
+                    return PVMFErrArgument;
+                }
+
+                if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.pChar_value);
+                    aParameters[i].value.pChar_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_WCHARPTR && aParameters[i].value.pWChar_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.pWChar_value);
+                    aParameters[i].value.pWChar_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.pChar_value);
+                    aParameters[i].value.pChar_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_KSV && aParameters[i].value.key_specific_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.key_specific_value);
+                    aParameters[i].value.key_specific_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_INT32 && aParameters[i].value.key_specific_value != NULL)
+                {
+                    range_int32* ri32 = (range_int32*)aParameters[i].value.key_specific_value;
+                    aParameters[i].value.key_specific_value = NULL;
+                    oscl_free(ri32);
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_UINT32 && aParameters[i].value.key_specific_value != NULL)
+                {
+                    range_uint32* rui32 = (range_uint32*)aParameters[i].value.key_specific_value;
+                    aParameters[i].value.key_specific_value = NULL;
+                    oscl_free(rui32);
+                }
+            }
+        }
+
+        oscl_free(aParameters[0].key);
+
+        // Free memory for the parameter list
+        oscl_free(aParameters);
+        aParameters = NULL;
+    }
+    else
+    {
+        // Unknown key string
+        return PVMFErrArgument;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMFSPPVRBase::releaseParameters() Out"));
+    return PVMFSuccess;
+}
+
+bool PVMFSMFSPPVRBase::RequestJitterBufferPorts(int32 portType,
+        uint32 &numPortsRequested)
+{
+    PVMFSMFSPChildNodeContainer* nodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+
+    if (nodeContainer == NULL)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:RequestJitterBufferPorts - getChildNodeContainer Failed"));
+        return false;
+    }
+
+    numPortsRequested = 0;
+    /*
+     * Request port - all jitter buffer input ports
+     * are even numbered and output and rtcp ports are odd numbered
+     */
+    int32 portTagStart = portType;
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+            || (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+       )
+    {
+        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+        {
+            PVMFPVRBaseTrackInfo trackInfo = iTrackInfoVec[i];
+
+            PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+            if (internalCmd != NULL)
+            {
+                internalCmd->cmd =
+                    nodeContainer->commandStartOffset +
+                    PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
+                internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
+                internalCmd->portContext.trackID = trackInfo.trackID;
+                internalCmd->portContext.portTag = portType;
+
+                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                PVMFNodeInterface* iNode = nodeContainer->iNode;
+
+                OSCL_StackString<32> portConfig = trackInfo.iTransportType;
+                portConfig += _STRLIT_CHAR("/");
+                portConfig += trackInfo.iMimeType;
+                iNode->RequestPort(nodeContainer->iSessionId,
+                                   portTagStart,
+                                   &(portConfig),
+                                   cmdContextData);
+                numPortsRequested++;
+                nodeContainer->iNumRequestPortsPending++;
+                nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+            }
+            else
+            {
+                PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:RequestJitterBufferPorts - RequestNewInternalCmd Failed"));
+                return false;
+            }
+            portTagStart += 3;
+        }
+        return true;
+    }
+    return false;
+}
+
+bool PVMFSMFSPPVRBase::RequestMediaLayerPorts(int32 portType,
+        uint32& numPortsRequested)
+{
+    PVMFSMFSPChildNodeContainer* nodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+
+    if (nodeContainer == NULL)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:RequestMediaLayerPorts - getChildNodeContainer Failed"));
+        return false;
+    }
+
+    numPortsRequested = 0;
+    /*
+     * Request port - all media layer input ports
+     * are even numbered and output are odd numbered
+     */
+    int32 portTagStart = portType;
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+            || (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+       )
+    {
+        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+        {
+            PVMFPVRBaseTrackInfo trackInfo = iTrackInfoVec[i];
+
+            PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+            if (internalCmd != NULL)
+            {
+                internalCmd->cmd =
+                    nodeContainer->commandStartOffset +
+                    PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
+                internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
+                internalCmd->portContext.trackID = trackInfo.trackID;
+                internalCmd->portContext.portTag = portType;
+
+                OsclAny *cmdContextData =
+                    OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                PVMFNodeInterface* iNode = nodeContainer->iNode;
+
+                iNode->RequestPort(nodeContainer->iSessionId,
+                                   portTagStart,
+                                   &(trackInfo.iMimeType),
+                                   cmdContextData);
+                numPortsRequested++;
+                nodeContainer->iNumRequestPortsPending++;
+                nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+            }
+            else
+            {
+                PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:RequestMediaLayerPorts - RequestNewInternalCmd Failed"));
+                return false;
+            }
+            portTagStart += 2;
+        }
+
+        return true;
+    }
+
+    //error
+    return false;
+}
+
+void PVMFSMFSPPVRBase::ResetStopCompleteParams()
+{
+    iPlaylistPlayInProgress = false;
+    iRepositionRequestedStartNPTInMS = 0;
+}
+
+PVMFStatus PVMFSMFSPPVRBase::SelectTracks(PVMFMediaPresentationInfo& aInfo)
+{
+    SDPInfo* sdpInfo = iSdpInfo.GetRep();
+    if (sdpInfo == NULL)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:SelectTracks - SDP Not Available"));
+        return PVMFErrArgument;
+    }
+
+    int32 numTracks = aInfo.getNumTracks();
+
+    for (int32 i = 0; i < numTracks; i++)
+    {
+        PVMFTrackInfo* trackInfo = aInfo.getTrackInfo(i);
+
+        uint32 trackID = trackInfo->getTrackID();
+
+        mediaInfo* mInfo =
+            sdpInfo->getMediaInfoBasedOnID(trackID);
+
+        if (mInfo == NULL)
+        {
+            PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase:SelectTracks - Invalid SDP TrackID"));
+            return PVMFErrArgument;
+        }
+
+        mInfo->setSelect();
+
+        /* Set selected field in meta info */
+        Oscl_Vector<PVMFSMTrackMetaDataInfo, OsclMemAllocator>::iterator it;
+        for (it = iMetaDataInfo->iTrackMetaDataInfoVec.begin(); it != iMetaDataInfo->iTrackMetaDataInfoVec.end(); it++)
+        {
+            if (it->iTrackID == trackID)
+            {
+                it->iTrackSelected = true;
+            }
+        }
+    }
+
+    iSelectedMediaPresetationInfo = aInfo;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMFSPPVRBase::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
+{
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return PVMFFailure;
+    }
+
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    jbExtIntf->setClientPlayBackClock(aClientClock);
+
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return  PVMFFailure;
+    }
+
+    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+        (PVMFMediaLayerNodeExtensionInterface*)
+        (iMediaLayerNodeContainer->iExtensions[0]);
+
+    mlExtIntf->setClientPlayBackClock(aClientClock);
+
+    return PVMFSuccess;
+}
+
+void PVMFSMFSPPVRBase::setContextParameters(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext,
+        PvmiKvp* aParameters,
+        int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+    // not supported
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+PVMFStatus PVMFSMFSPPVRBase::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
+{
+    OSCL_UNUSED_ARG(aClientClock);
+    return PVMFErrNotSupported;
+}
+
+void PVMFSMFSPPVRBase::setJitterBufferDurationInMilliSeconds(uint32 duration)
+{
+    iJitterBufferDurationInMilliSeconds = duration;
+}
+
+void PVMFSMFSPPVRBase::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    ciObserver = aObserver;
+}
+
+void PVMFSMFSPPVRBase::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+        int num_elements, PvmiKvp* &aRet_kvp)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    if (aParameters == NULL || num_elements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMFSPPVRBase::setParametersSync() KVP list is NULL or number of elements is 0"));
+        return;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMFSPPVRBase::setParametersSync() In"));
+
+
+    // Go through each parameter
+    for (int paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+        {
+            // First component should be "x-pvmf" and there must
+            // be at least two components to go past x-pvmf
+            aRet_kvp = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMFSPPVRBase::setParametersSync() Unsupported key"));
+            return;
+        }
+
+        // Retrieve the second component from the key string
+        pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
+
+        // First check if it is key string for the streaming manager
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
+        {
+            if (compcount == 3)
+            {
+                pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
+                uint i;
+                for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
+                {
+                    if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
+                    {
+                        break;
+                    }
+                }
+
+                if (StreamingManagerConfig_NumBaseKeys == i)
+                {
+                    // invalid third component
+                    aRet_kvp = &aParameters[paramind];
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFSMFSPPVRBase::setParametersSync() Unsupported key"));
+                    return;
+                }
+
+                // Verify and set the passed-in setting
+                PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], true);
+                if (retval != PVMFSuccess)
+                {
+                    aRet_kvp = &aParameters[paramind];
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFSMFSPPVRBase::setParametersSync() Setting "
+                                     "parameter %d failed", paramind));
+                    return;
+                }
+            }
+            else
+            {
+                // Do not support more than 3 components right now
+                aRet_kvp = &aParameters[paramind];
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFSMFSPPVRBase::setParametersSync() Unsupported key"));
+                return;
+            }
+        }
+        else
+        {
+            // Unknown key string
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMFSPPVRBase::setParametersSync() Unsupported key"));
+            return;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMFSPPVRBase::setParametersSync() Out"));
+}
+
+PVMFStatus PVMFSMFSPPVRBase::verifyParametersSync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMFSPPVRBase::verifyParametersSync() In"));
+
+    if (aParameters == NULL || num_elements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMFSPPVRBase::verifyParametersSync() Passed in parameter invalid"));
+        return PVMFErrArgument;
+    }
+
+    // Go through each parameter and verify
+    for (int32 paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+        {
+            // First component should be "x-pvmf" and there must
+            // be at least two components to go past x-pvmf
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::verifyParametersSync() Unsupported key"));
+            return PVMFErrArgument;
+        }
+
+        // Retrieve the second component from the key string
+        pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
+
+        // First check if it is key string for this node
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0) && (compcount == 3))
+        {
+            pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
+            uint i;
+            for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
+            {
+                if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
+                {
+                    break;
+                }
+            }
+
+            if (StreamingManagerConfig_NumBaseKeys == i)
+            {
+                return PVMFErrArgument;
+            }
+
+            // Verify the passed-in player setting
+            PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], false);
+            if (retval != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMFSPPVRBase::DoCapConfigVerifyParameters() Verifying parameter %d failed", paramind));
+                return retval;
+            }
+        }
+        else
+        {
+            // Unknown key string
+            return PVMFErrArgument;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFSMFSPPVRBase::DoCapConfigVerifyParameters() Out"));
+    return PVMFSuccess;
+}
+
+
+bool PVMFSMFSPPVRBase::SkipThisNodeResume(int32 aNodeTag)
+{
+    if (iPVREnabled)
+    {
+        if ((aNodeTag == PVMF_SM_FSP_SOCKET_NODE)
+                || (aNodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE))
+        {
+            // SocketNode and Rtsp Engine were not paused
+            return true;
+        }
+    }
+
+    return false;
+}
+
+bool PVMFSMFSPPVRBase::SkipThisNodePause(int32 aNodeTag)
+{
+    if (iPVREnabled)
+    {
+        if ((aNodeTag == PVMF_SM_FSP_SOCKET_NODE)
+                || (aNodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE))
+        {
+            // SocketNode and Rtsp Engine were not paused
+            return true;
+        }
+    }
+
+    return false;
+
+}
+
+void PVMFSMFSPPVRBase::SetPVRTrackParams(uint32 aMediaTrackId, const PvmfMimeString* aMimeType,
+        uint32 aTimescale, uint32 aBitrate)
+{
+    // If PVR is enabled, pass the track information to the extension interface
+    if (iPVREnabled)
+    {
+        OSCL_ASSERT(iPVRExtInterface != NULL);
+        iPVRExtInterface->setTrackParams(aMediaTrackId, aMimeType, aTimescale,
+                                         aBitrate);
+    }
+}
+
+void PVMFSMFSPPVRBase::SetPVRTrackRTPParams(const PvmfMimeString* aMimeType,
+        bool   aSeqNumBasePresent, uint32 aSeqNumBase, bool   aRTPTimeBasePresent,
+        uint32 aRTPTimeBase, uint32 aNPTInMS)
+{
+    if (iPVREnabled)
+    {
+        OSCL_ASSERT(iPVRExtInterface != NULL);
+        iPVRExtInterface->setTrackRTPParams(aMimeType,
+                                            aSeqNumBasePresent,
+                                            aSeqNumBase,
+                                            aRTPTimeBasePresent,
+                                            aRTPTimeBase,
+                                            aNPTInMS);
+    }
+}
+
+void PVMFSMFSPPVRBase::SetPVRSdpText(OsclRefCounterMemFrag& aSDPText)
+{
+    if (iPVREnabled)
+    {
+        // For PVR, make sure we pass the sdp text
+        OSCL_ASSERT(iPVRExtInterface != NULL);
+        iPVRExtInterface->SetSdpText(aSDPText);
+    }
+}
+
+//Compute Jitter buffer mem pool size
+uint32 PVMFSMFSPPVRBase::GetJitterBufferMemPoolSize(PVMFJitterBufferNodePortTag aJBNodePortTag, PVMFPVRBaseTrackInfo& aRTSPTrackInfo)
+{
+    uint32 sizeInBytes = 0;
+    uint32 byteRate = (aRTSPTrackInfo.bitRate) / 8;
+    uint32 overhead = (byteRate * PVMF_JITTER_BUFFER_NODE_MEM_POOL_OVERHEAD) / 100;
+    uint32 jitterBufferDuration;
+
+    PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (jitterBufferNodeContainer == NULL)
+    {
+        OSCL_ASSERT(false);
+        return false;
+    }
+
+    PVMFJitterBufferExtensionInterface* jbExtIntf = OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions[0]);
+    if (jbExtIntf == NULL)
+    {
+        OSCL_ASSERT(false);
+        return sizeInBytes;
+    }
+
+    jbExtIntf->getJitterBufferDurationInMilliSeconds(jitterBufferDuration);
+    uint32 durationInSec = jitterBufferDuration / 1000;
+    switch (aJBNodePortTag)
+    {
+        case PVMF_JITTER_BUFFER_PORT_TYPE_INPUT:
+        {
+            if (durationInSec > 0)
+            {
+                sizeInBytes = ((byteRate + overhead) * durationInSec);
+                if (sizeInBytes < MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES)
+                {
+                    sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
+                }
+                sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);		//MAX_SOCKET_BUFFER_SIZE equals to SNODE_UDP_MULTI_MAX_BYTES_PER_RECV + MAX_UDP_PACKET_SIZE used in socket node
+            }
+
+        }
+        break;
+        case PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK:
+        {
+            if (durationInSec > 0)
+            {
+                sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
+                sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);		//MAX_SOCKET_BUFFER_SIZE equals to SNODE_UDP_MULTI_MAX_BYTES_PER_RECV + MAX_UDP_PACKET_SIZE used in socket node
+            }
+        }
+        break;
+        default:
+            sizeInBytes = 0;
+    }
+    return sizeInBytes;
+}
+
+bool PVMFSMFSPPVRBase::SetPVRPlaybackRange()
+{
+    // Send the repositioning point to PVR Extension Interface
+    OSCL_ASSERT(iPVRExtInterface != NULL);
+    if (iPVRExtInterface->SetDataSourcePosition(iRepositionRequestedStartNPTInMS) != PVMFSuccess)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "StreamingManagerNode:DoRepositioningStart - SetRequestPlayRange Failed for PVR"));
+        return false;
+    }
+
+    return true;
+}
+
+
+PVMFStatus PVMFSMFSPPVRBase::GetConfigParameter(PvmiKvp*& aParameters,
+        int& aNumParamElements,
+        int32 aIndex, PvmiKvpAttr reqattr)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGINFO((0, "PVMFSMFSPPVRBase::GetConfigParameter() In"));
+
+    aNumParamElements = 0;
+
+    // Allocate memory for the KVP
+    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
+    if (aParameters == NULL)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() Memory allocation for KVP failed"));
+        return PVMFErrNoMemory;
+    }
+    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
+
+    // Allocate memory for the key string in KVP
+    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(SMCONFIG_KEYSTRING_SIZE * sizeof(char));
+    if (memblock == NULL)
+    {
+        oscl_free(aParameters);
+        PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() Memory allocation for key string failed"));
+        return PVMFErrNoMemory;
+    }
+    oscl_strset(memblock, 0, SMCONFIG_KEYSTRING_SIZE*sizeof(char));
+
+    // Assign the key string buffer to KVP
+    aParameters[0].key = memblock;
+
+    // Copy the key string
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
+    oscl_strncat(aParameters[0].key, StreamingManagerConfig_BaseKeys[aIndex].iString,
+                 oscl_strlen(StreamingManagerConfig_BaseKeys[aIndex].iString));
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
+    switch (StreamingManagerConfig_BaseKeys[aIndex].iValueType)
+    {
+        case PVMI_KVPVALTYPE_RANGE_INT32:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_KSV:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_CHARPTR:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_WCHARPTR:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_WCHARPTR_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_BOOL:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_UINT32:
+        default:
+            if (reqattr == PVMI_KVPATTR_CAP)
+            {
+                oscl_strncat(aParameters[0].key,
+                             _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING),
+                             oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
+            }
+            else
+            {
+                oscl_strncat(aParameters[0].key,
+                             _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING),
+                             oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
+            }
+            break;
+    }
+    aParameters[0].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
+
+    // Copy the requested info
+    switch (aIndex)
+    {
+        case BASEKEY_DELAY:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                if (jbExtIntf)
+                    jbExtIntf->getJitterBufferDurationInMilliSeconds(aParameters[0].value.uint32_value);
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                 "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_JITTER_BUFFER_DURATION_IN_MS;
+                rui32->max = MAX_JITTER_BUFFER_DURATION_IN_MS;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_JITTERBUFFER_NUMRESIZE:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                uint32 numResize, resizeSize;
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
+                aParameters[0].value.uint32_value = numResize;
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                 "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_NUM_SOCKETMEMPOOL_RESIZES;
+                rui32->max = MAX_NUM_SOCKETMEMPOOL_RESIZES;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_JITTERBUFFER_RESIZESIZE:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                uint32 numResize, resizeSize;
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
+                aParameters[0].value.uint32_value = resizeSize;
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                 "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+                rui32->max = MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                uint32 inactivityDuration = 0;
+                jbExtIntf->getMaxInactivityDurationForMediaInMs(inactivityDuration);
+                aParameters[0].value.uint32_value = inactivityDuration;
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                 "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = 0;
+                rui32->max = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                aParameters[0].value.pWChar_value = NULL;
+                /* As of now just RTSP node supports an external config of user agent */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+
+                    OSCL_wHeapString<OsclMemAllocator> userAgent;
+                    if (rtspExtIntf->GetUserAgent(userAgent) == PVMFSuccess)
+                    {
+                        // Return current value
+                        oscl_wchar* ptr = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (userAgent.get_size()));
+                        if (ptr)
+                        {
+                            oscl_memcpy(ptr, userAgent.get_cstr(), userAgent.get_size());
+                            aParameters[0].value.pWChar_value = ptr;
+                        }
+                        else
+                        {
+                            oscl_free(aParameters[0].key);
+                            oscl_free(aParameters);
+                            PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                         "Memory allocation for user agent failed"));
+                            return PVMFErrNoMemory;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                // Return capability - no concept of capability for user agent
+                // do nothing
+            }
+            break;
+        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL:
+        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
+                {
+                    aParameters[0].value.uint32_value = PVRTSPENGINENODE_DEFAULT_KEEP_ALIVE_INTERVAL;
+                }
+                else
+                {
+                    aParameters[0].value.bool_value = false;
+                }
+                /* As of now just RTSP node supports an external config of user agent */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+                    uint32 timeout;
+                    bool okeepalivemethod;
+                    bool okeepaliveinplay;
+                    rtspExtIntf->GetKeepAliveMethod((int32&)timeout, okeepalivemethod, okeepaliveinplay);
+                    if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
+                    {
+                        aParameters[0].value.uint32_value = timeout;
+                    }
+                    else
+                    {
+                        aParameters[0].value.bool_value = okeepaliveinplay;
+                    }
+                }
+            }
+            else
+            {
+                // Return capability - no concept of capability for keep alive interval
+                // do nothing
+            }
+            break;
+        case BASEKEY_REBUFFERING_THRESHOLD:
+        {
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->getJitterBufferRebufferingThresholdInMilliSeconds(aParameters[0].value.uint32_value);
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                 "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
+                rui32->max = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+        }
+        break;
+        case BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT:
+        {
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                /* As of now just RTSP node supports an external config of RTSP time out */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+                    int32 timeout;
+                    rtspExtIntf->GetRTSPTimeOut(timeout);
+                    aParameters[0].value.uint32_value = OSCL_STATIC_CAST(uint32, timeout);
+                }
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_FSP_PVR_BASE_LOGERR((0, "PVMFSMFSPPVRBase::GetConfigParameter() "
+                                                 "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC;
+                rui32->max = MAX_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+        }
+        break;
+        case BASEKEY_DISABLE_FIREWALL_PACKETS:
+        {
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                aParameters[0].value.bool_value = false;
+            }
+        }
+        break;
+
+        default:
+            // Invalid index
+            oscl_free(aParameters[0].key);
+            oscl_free(aParameters);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlayerParameter() Invalid index to player parameter"));
+            return PVMFErrArgument;
+    }
+
+    aNumParamElements = 1;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetPlayerParameter() Out"));
+    return PVMFSuccess;
+}
+
+void PVMFSMFSPPVRBase::DoQueryInterface(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoQueryInterface - In"));
+
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(uuid, ptr);
+
+    *ptr = NULL;
+
+    if (*uuid == PVMF_TRACK_SELECTION_INTERFACE_UUID)
+    {
+        PVMFTrackSelectionExtensionInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFTrackSelectionExtensionInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)
+    {
+        PVMFDataSourceInitializationExtensionInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFDataSourceInitializationExtensionInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PvmfDataSourcePlaybackControlUuid)
+    {
+        PvmfDataSourcePlaybackControlInterface* interimPtr =
+            OSCL_STATIC_CAST(PvmfDataSourcePlaybackControlInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == KPVMFMetadataExtensionUuid)
+    {
+        PVMFMetadataExtensionInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        PvmiCapabilityAndConfig* interimPtr =
+            OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMFCPMPluginLicenseInterfaceUuid)
+    {
+        PVMFCPMPluginLicenseInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMF_DATA_SOURCE_PACKETSOURCE_INTERFACE_UUID)
+    {
+        PVMFDataSourcePacketSourceInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFDataSourcePacketSourceInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else
+    {
+        *ptr = NULL;
+    }
+    if (*ptr)
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::QueryInterface() - CmdComplete - PVMFSuccess"));
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        PVMF_SM_FSP_PVR_BASE_LOGCMDSEQ((0, "PVMFSMFSPPVRBase::QueryInterface() - CmdFailed - PVMFErrNotSupported"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+    }
+
+    PVMF_SM_FSP_PVR_BASE_LOGSTACKTRACE((0, "PVMFSMFSPPVRBase::DoQueryInterface - Out"));
+    return;
+}
+
+
+PVMFStatus PVMFSMFSPPVRBase::GetPVRPluginSpecificValues(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMFMetadataList* keylistptr = NULL;
+    Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
+    uint32 starting_index;
+    int32 max_entries;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
+
+    // Check the parameters
+    if (keylistptr == NULL || valuelistptr == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    uint32 numkeys = keylistptr->size();
+
+    if (numkeys <= 0 || max_entries == 0)
+    {
+        // Don't do anything
+        return PVMFErrArgument;
+    }
+
+    uint32 numvalentries = 0;
+    int32 numentriesadded = 0;
+
+    for (uint32 lcv = 0; lcv < numkeys; lcv++)
+    {
+        PvmiKvp KeyVal;
+        KeyVal.key = NULL;
+        KeyVal.value.pWChar_value = NULL;
+        KeyVal.value.pChar_value = NULL;
+
+        if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY) != NULL)
+        {
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                // check if duration is available first
+                bool keyValue = iMetaDataInfo->iSessionDurationAvailable ? false : true;
+                if (keyValue == true)
+                    keyValue = !iPVREnabled;
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForBoolValue(KeyVal,
+                                    PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY,
+                                    keyValue);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+
+        /* Check if the max number of value entries were added */
+        if (max_entries > 0 && numentriesadded >= max_entries)
+        {
+            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+            return PVMFSuccess;
+        }
+
+        // Add the KVP to the list if the key string was created
+        if (KeyVal.key != NULL)
+        {
+            if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, KeyVal))
+            {
+                switch (GetValTypeFromKeyString(KeyVal.key))
+                {
+                    case PVMI_KVPVALTYPE_CHARPTR:
+                        if (KeyVal.value.pChar_value != NULL)
+                        {
+                            OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
+                            KeyVal.value.pChar_value = NULL;
+                        }
+                        break;
+
+                    default:
+                        // Add more case statements if other value types are returned
+                        break;
+                }
+
+                OSCL_ARRAY_DELETE(KeyVal.key);
+                KeyVal.key = NULL;
+            }
+            else
+            {
+                // Increment the counter for number of value entries added to the list
+                ++numentriesadded;
+            }
+
+            // Check if the max number of value entries were added
+            if (max_entries > 0 && numentriesadded >= max_entries)
+            {
+                // Maximum number of values added so break out of the loop
+                break;
+            }
+        }
+    }
+
+    iNoOfValuesIteratedForValueVect = numvalentries;
+    iNoOfValuesPushedInValueVect = numentriesadded;
+
+    iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+    return PVMFSuccess;
+}
+
diff --git a/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_pvr_capandconfig.h b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_pvr_capandconfig.h
new file mode 100644
index 0000000..b95eeb4
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/common/src/pvmf_sm_fsp_pvr_capandconfig.h
@@ -0,0 +1,78 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_PVR_CAPANDCONFIG_H
+#define PVMF_SM_FSP_PVR_CAPANDCONFIG_H
+///////////////////////////////////////////////////////////////////////////////
+//
+// Capability and config interface related constants and definitions
+//   - based on pv_player_engine.h
+//
+///////////////////////////////////////////////////////////////////////////////
+struct StreamingManagerKeyStringData
+{
+    char iString[64];
+    PvmiKvpType iType;
+    PvmiKvpValueType iValueType;
+};
+// The number of characters to allocate for the key string
+#define SMCONFIG_KEYSTRING_SIZE 128
+
+static const StreamingManagerKeyStringData StreamingManagerConfig_BaseKeys[] =
+{
+    {"delay", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"jitterBufferNumResize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"jitterBufferResizeSize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"jitterbuffer-inactivity-duration", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"user-agent", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_WCHARPTR},
+    {"keep-alive-interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"keep-alive-during-play", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
+    {"rtsp-timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"rebuffering-threshold", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"disable-firewall-packets", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
+    {"early-decoding-time", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"burst-threshold", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_FLOAT}
+};
+
+static const uint StreamingManagerConfig_NumBaseKeys =
+    (sizeof(StreamingManagerConfig_BaseKeys) /
+     sizeof(StreamingManagerKeyStringData));
+
+enum BaseKeys_IndexMapType
+{
+    BASEKEY_DELAY = 0,
+    BASEKEY_JITTERBUFFER_NUMRESIZE,
+    BASEKEY_JITTERBUFFER_RESIZESIZE,
+    BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION,
+    BASEKEY_SESSION_CONTROLLER_USER_AGENT,
+    BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL,
+    BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY,
+    BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT,
+    BASEKEY_REBUFFERING_THRESHOLD,
+    BASEKEY_DISABLE_FIREWALL_PACKETS,
+    BASEKEY_EARLY_DECODING_TIME,
+    BASEKEY_BURST_THRESHOLD
+};
+
+typedef struct tagPVMFSMClientParams
+{
+    OSCL_wHeapString<OsclMemAllocator> _userAgent;
+    OSCL_wHeapString<OsclMemAllocator> _userNetwork;
+    OSCL_wHeapString<OsclMemAllocator> _deviceInfo;
+} PVMFSMClientParams;
+
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/rtspunicast/include/pvmf_sm_rtsp_unicast_node_factory.h b/nodes/streaming/streamingmanager/plugins/rtspunicast/include/pvmf_sm_rtsp_unicast_node_factory.h
new file mode 100644
index 0000000..0c213e3
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/rtspunicast/include/pvmf_sm_rtsp_unicast_node_factory.h
@@ -0,0 +1,72 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_RTSP_UNICAST_NODE_FACTORY_H_INCLUDED
+#define PVMF_SM_RTSP_UNICAST_NODE_FACTORY_H_INCLUDED
+
+#ifndef PVMF_EVENT_HANDLING_H_INCLUDED
+#include "pvmf_event_handling.h"
+#endif
+
+/* Forward declaration */
+class PVMFSMFSPBaseNode;
+
+#define KPVMFSMRTSPUnicastNodeUuid PVUuid(0x45ac6dcd,0x2ccf,0x4b0a,0x9c,0xc5,0x8a,0xf7,0x06,0x54,0xde,0x48)
+
+/**
+ * PVMFStreamingManagerNodeFactory Class
+ *
+ * PVMFStreamingManagerNodeFactory class is a singleton class
+ * which instantiates and provides access to PVMF streaming manager node.
+ * It returns a PVMFNodeInterface reference, the interface class of the
+ * PVMFStreamingManagerNode.
+ *
+ * The client is expected to contain and maintain a pointer to the instance
+ * created while the node is active.
+ */
+
+class PVMFSMRTSPUnicastNodeFactory
+{
+    public:
+        /**
+         * Creates an instance of a PVMFSMRTSPUnicastNode.
+         * If the creation fails, this function will leave.
+         *
+         * @param priority for the underlying node active object
+         *
+         * @returns A pointer to an instance of PVMFSMRTSPUnicastNode
+         * as PVMFSMFSPBaseNode reference or leaves if instantiation fails
+         **/
+        OSCL_IMPORT_REF static PVMFSMFSPBaseNode* CreateSMRTSPUnicastNodeFactory(int32 aPriority);
+
+        /**
+         * Deletes an instance of PVMFSMRTSPUnicastNode
+         * and reclaims all allocated resources.  An instance can be deleted
+         * only in the created state. An attempt to delete in any other state
+         * will result returning false
+         *
+         * @param aNode The PVMFSMFSPBaseNode instance to be deleted
+         * @returns bool
+         *  true: node was in created state
+         *	false: either node was not in created state or deletion failed
+         **/
+        OSCL_IMPORT_REF static bool DeleteSMRTSPUnicastNodeFactory(PVMFSMFSPBaseNode* aNode);
+};
+
+#endif
+
+
diff --git a/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.cpp b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.cpp
new file mode 100644
index 0000000..8286f7b
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.cpp
@@ -0,0 +1,6465 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_RTSP_UNICAST_H
+#include "pvmf_sm_fsp_rtsp_unicast.h"
+#endif
+
+#ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
+#include "oscl_exclusive_ptr.h"
+#endif
+
+#ifndef PVMF_SOCKET_NODE_H_INCLUDED
+#include "pvmf_socket_node.h"
+#endif
+#ifndef PVMF_RTSP_ENGINE_NODE_FACTORY_H_INCLUDED
+#include "pvrtsp_client_engine_factory.h"
+#endif
+#ifndef PVMF_JITTER_BUFFER_NODE_H_INCLUDED
+#include "pvmf_jitter_buffer_node.h"
+#endif
+#ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
+#include "pvmf_medialayer_node.h"
+#endif
+#ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_H_INCLUDED
+#include "pvrtspenginenodeextensioninterface.h"
+#endif
+#ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
+#include "pvmf_media_presentation_info.h"
+#endif
+
+#ifndef PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
+#include "pvmf_sm_fsp_base_metadata.h"
+#endif
+
+#ifndef SDP_PARSER_H
+#include "sdp_parser.h"
+#endif
+
+#ifndef OSCL_SNPRINTF_H_INCLUDED
+#include "oscl_snprintf.h"
+#endif
+
+#ifndef AMR_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "amr_payload_parser_factory.h"
+#endif
+#ifndef H263_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "h263_payload_parser_factory.h"
+#endif
+#ifndef H264_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "h264_payload_parser_factory.h"
+#endif
+#ifndef M4V_AUDIO_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "m4v_audio_payload_parser_factory.h"
+#endif
+#ifndef M4V_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "m4v_payload_parser_factory.h"
+#endif
+#ifndef PAYLOAD_PARSER_REGISTRY_H_INCLUDED
+#include "payload_parser_registry.h"
+#endif
+#ifndef RFC3640_PAYLOAD_PARSER_FACTORY_H_INCLUDED
+#include "rfc3640_payload_parser_factory.h"
+#endif
+
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef PVMI_KVP_UTIL_H_INCLUDED
+#include "pvmi_kvp_util.h"
+#endif
+
+#ifndef PVMI_DRM_KVP_H_INCLUDED
+#include "pvmi_drm_kvp.h"
+#endif
+
+
+#ifndef PVRTSP_CLIENT_ENGINE_NODE_H
+#include "pvrtsp_client_engine_node.h"
+#endif
+
+#ifndef PVMF_SM_RTSP_UNICAST_CAPANDCONFIG_H
+#include "pvmf_sm_rtsp_unicast_capandconfig.h"
+#endif
+
+#ifndef SDP_MEDIA_PARSER_REGISTRY_POPULATOR
+#include "sdp_mediaparser_registry_populator.h"
+#endif
+
+/**
+///////////////////////////////////////////////////////////////////////////////
+// Node Constructor & Destructor
+///////////////////////////////////////////////////////////////////////////////
+*/
+PVMFSMRTSPUnicastNode * PVMFSMRTSPUnicastNode::New(int32 aPriority)
+{
+    PVMFSMRTSPUnicastNode * rtspUnicastNode = OSCL_NEW(PVMFSMRTSPUnicastNode, (aPriority));
+    if (rtspUnicastNode)
+    {
+        rtspUnicastNode->Construct();
+    }
+    return rtspUnicastNode;
+}
+
+PVMFSMRTSPUnicastNode::PVMFSMRTSPUnicastNode(int32 aPriority): PVMFSMFSPBaseNode(aPriority)
+{
+    iJitterBufferDurationInMilliSeconds = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
+    oAutoReposition = false;
+    iPauseDenied	= false;
+    ResetNodeParams(false);
+}
+
+PVMFSMRTSPUnicastNode::~PVMFSMRTSPUnicastNode()
+{
+    CleanUp();
+}
+
+void PVMFSMRTSPUnicastNode::Construct()
+{
+    PVMFSMFSPBaseNode::Construct();
+    int32 err;
+    OSCL_TRY(err,
+             iLogger = PVLogger::GetLoggerObject("PVMFSMRTSPUnicastNode");
+             iAvailableMetadataKeys.reserve(PVMFSTREAMINGMGRNODE_NUM_METADATAKEYS);
+             iAvailableMetadataKeys.clear();
+             // create the payload parser registry
+             PopulatePayloadParserRegistry();
+             CreateChildNodes();
+             QueryChildNodesExtentionInterface();
+             // pass the payload parser registry on to the media layer node
+             PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+                 getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+             OSCL_ASSERT(iMediaLayerNodeContainer);
+             PVMFMediaLayerNodeExtensionInterface* mlExtIntf = NULL;
+             if (iMediaLayerNodeContainer)
+             mlExtIntf = (PVMFMediaLayerNodeExtensionInterface*)(iMediaLayerNodeContainer->iExtensions[0]);
+             if (mlExtIntf)
+                 mlExtIntf->setPayloadParserRegistry(PayloadParserRegistry::GetPayloadParserRegistry());
+                );
+    if (err != OsclErrNone)
+    {
+        CleanUp();
+        OSCL_LEAVE(err);
+    }
+
+}
+
+void PVMFSMRTSPUnicastNode::CreateChildNodes()
+{
+    /*
+     * Create Socket Node
+     */
+    OsclExclusivePtr<PVMFNodeInterface> socketNodeAutoPtr;
+    PVMFNodeInterface* iSocketNode;
+    iSocketNode = OSCL_NEW(PVMFSocketNode, (OsclActiveObject::EPriorityNominal));
+    socketNodeAutoPtr.set(iSocketNode);
+
+    PVMFSMFSPChildNodeContainer sSocketNodeContainer;
+
+    PVMFNodeSessionInfo socketNodeSession(this,
+                                          this,
+                                          OSCL_REINTERPRET_CAST(OsclAny*,
+                                                                iSocketNode),
+                                          this,
+                                          OSCL_REINTERPRET_CAST(OsclAny*,
+                                                                iSocketNode));
+
+    sSocketNodeContainer.iNode = iSocketNode;
+    sSocketNodeContainer.iSessionId =
+        iSocketNode->Connect(socketNodeSession);
+    sSocketNodeContainer.iNodeTag =
+        PVMF_SM_FSP_SOCKET_NODE;
+    sSocketNodeContainer.commandStartOffset =
+        PVMF_SM_FSP_SOCKET_NODE_COMMAND_START;
+    /* Push back the known UUID in case there are no queries */
+    PVUuid uuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID);
+    sSocketNodeContainer.iExtensionUuids.push_back(uuid);
+    iFSPChildNodeContainerVec.push_back(sSocketNodeContainer);
+
+    /*
+     * Create Session Controller Node
+     */
+    OsclExclusivePtr<PVMFNodeInterface> sessionControllerAutoPtr;
+    //PVMFNodeInterface* iSessionControllerNode = OSCL_NEW(PVRTSPEngineNode, (OsclActiveObject::EPriorityNominal));
+    PVMFNodeInterface* iSessionControllerNode = PVMFRrtspEngineNodeFactory::CreatePVMFRtspEngineNode(OsclActiveObject::EPriorityNominal);
+    sessionControllerAutoPtr.set(iSessionControllerNode);
+
+    PVMFSMFSPChildNodeContainer sSessionControllerNodeContainer;
+
+    PVMFNodeSessionInfo sessionControllerSession(this,
+            this,
+            OSCL_REINTERPRET_CAST(OsclAny*,
+                                  iSessionControllerNode),
+            this,
+            OSCL_REINTERPRET_CAST(OsclAny*,
+                                  iSessionControllerNode));
+
+    sSessionControllerNodeContainer.iNode = iSessionControllerNode;
+    sSessionControllerNodeContainer.iSessionId =
+        iSessionControllerNode->Connect(sessionControllerSession);
+    sSessionControllerNodeContainer.iNodeTag =
+        PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE;
+    sSessionControllerNodeContainer.commandStartOffset =
+        PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START;
+    /* Push back the known UUID in case there are no queries */
+    sSessionControllerNodeContainer.iExtensionUuids.push_back(KPVRTSPEngineNodeExtensionUuid);
+    iFSPChildNodeContainerVec.push_back(sSessionControllerNodeContainer);
+
+
+    /*
+     * Create jitter buffer node
+     */
+    OsclExclusivePtr<PVMFNodeInterface> jitterBufferNodeAutoPtr;
+    PVMFNodeInterface* iJitterBufferNode;
+    iJitterBufferNode = OSCL_NEW(PVMFJitterBufferNode, (OsclActiveObject::EPriorityNominal));
+
+    jitterBufferNodeAutoPtr.set(iJitterBufferNode);
+
+    PVMFSMFSPChildNodeContainer sJitterBufferNodeContainer;
+
+    PVMFNodeSessionInfo jitterBufferSession(this,
+                                            this,
+                                            OSCL_REINTERPRET_CAST(OsclAny*,
+                                                                  iJitterBufferNode),
+                                            this,
+                                            OSCL_REINTERPRET_CAST(OsclAny*,
+                                                                  iJitterBufferNode));
+
+    sJitterBufferNodeContainer.iNode = iJitterBufferNode;
+    sJitterBufferNodeContainer.iSessionId =
+        iJitterBufferNode->Connect(jitterBufferSession);
+    sJitterBufferNodeContainer.iNodeTag =
+        PVMF_SM_FSP_JITTER_BUFFER_NODE;
+    sJitterBufferNodeContainer.commandStartOffset =
+        PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START;
+    /* Push back the known UUID in case there are no queries */
+    sJitterBufferNodeContainer.iExtensionUuids.push_back(PVMF_JITTERBUFFERNODE_EXTENSIONINTERFACE_UUID);
+    iFSPChildNodeContainerVec.push_back(sJitterBufferNodeContainer);
+
+
+    /*
+     * Create media layer node
+     */
+    OsclExclusivePtr<PVMFNodeInterface> mediaLayerNodeAutoPtr;
+    PVMFNodeInterface* iMediaLayerNode;
+    iMediaLayerNode = OSCL_NEW(PVMFMediaLayerNode, (OsclActiveObject::EPriorityNominal));
+
+    mediaLayerNodeAutoPtr.set(iMediaLayerNode);
+
+    PVMFSMFSPChildNodeContainer sMediaLayerNodeContainer;
+
+    PVMFNodeSessionInfo mediaLayerSession(this,
+                                          this,
+                                          OSCL_REINTERPRET_CAST(OsclAny*,
+                                                                iMediaLayerNode),
+                                          this,
+                                          OSCL_REINTERPRET_CAST(OsclAny*,
+                                                                iMediaLayerNode));
+
+    sMediaLayerNodeContainer.iNode = iMediaLayerNode;
+    sMediaLayerNodeContainer.iSessionId =
+        iMediaLayerNode->Connect(mediaLayerSession);
+    sMediaLayerNodeContainer.iNodeTag =
+        PVMF_SM_FSP_MEDIA_LAYER_NODE;
+    sMediaLayerNodeContainer.commandStartOffset =
+        PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START;
+    /* Push back the known UUID in case there are no queries */
+    sMediaLayerNodeContainer.iExtensionUuids.push_back(PVMF_MEDIALAYERNODE_EXTENSIONINTERFACE_UUID);
+    iFSPChildNodeContainerVec.push_back(sMediaLayerNodeContainer);
+
+    sessionControllerAutoPtr.release();
+    socketNodeAutoPtr.release();
+    jitterBufferNodeAutoPtr.release();
+    mediaLayerNodeAutoPtr.release();
+}
+
+void PVMFSMRTSPUnicastNode::DestroyChildNodes()
+{
+    uint32 i, j;
+    for (i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        for (j = 0; j < iFSPChildNodeContainerVec[i].iExtensions.size(); j++)
+        {
+            PVInterface* extIntf = iFSPChildNodeContainerVec[i].iExtensions[j];
+            extIntf->removeRef();
+        }
+
+        if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_SOCKET_NODE)
+        {
+            OSCL_DELETE(OSCL_STATIC_CAST(PVMFSocketNode*, iFSPChildNodeContainerVec[i].iNode));
+        }
+        else if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE)
+        {
+            PVMFRrtspEngineNodeFactory::DeletePVMFRtspEngineNode(iFSPChildNodeContainerVec[i].iNode);
+        }
+        else if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_JITTER_BUFFER_NODE)
+        {
+            OSCL_DELETE(OSCL_STATIC_CAST(PVMFJitterBufferNode*, iFSPChildNodeContainerVec[i].iNode));
+        }
+        else if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_MEDIA_LAYER_NODE)
+        {
+            OSCL_DELETE(OSCL_STATIC_CAST(PVMFMediaLayerNode*, iFSPChildNodeContainerVec[i].iNode));
+        }
+        iFSPChildNodeContainerVec[i].iNode = NULL;
+    }
+
+    iFSPChildNodeContainerVec.clear();
+}
+
+void PVMFSMRTSPUnicastNode::PopulatePayloadParserRegistry()
+{
+    PayloadParserRegistry* registry =
+        PayloadParserRegistry::GetPayloadParserRegistry();
+    OSCL_ASSERT(registry == NULL);
+    PayloadParserRegistry::Init();
+    registry = PayloadParserRegistry::GetPayloadParserRegistry();
+
+    StrPtrLen aac_latm("audio/MP4A-LATM");
+    StrPtrLen amr("audio/AMR");
+    StrPtrLen amrwb("audio/AMR-WB");
+    StrPtrLen h263_old("video/H263-1998");
+    StrPtrLen h263("video/H263-2000");
+    StrPtrLen m4v("video/MP4V-ES");
+    StrPtrLen h264("video/H264");
+    StrPtrLen mp4a(PVMF_MIME_MPEG4_AUDIO);
+    StrPtrLen rfc3640("audio/mpeg4-generic");
+
+    IPayloadParserFactory* m4vP = OSCL_NEW(M4VPayloadParserFactory, ());
+    IPayloadParserFactory* aacP = OSCL_NEW(M4VAudioPayloadParserFactory, ());
+    IPayloadParserFactory* amrP = OSCL_NEW(AmrPayloadParserFactory, ());
+    IPayloadParserFactory* h263P = OSCL_NEW(H263PayloadParserFactory, ());
+    IPayloadParserFactory* h264P = OSCL_NEW(H264PayloadParserFactory, ());
+    IPayloadParserFactory* amrwbP = OSCL_NEW(AmrPayloadParserFactory, ());
+    IPayloadParserFactory* rfc3640P = OSCL_NEW(RFC3640PayloadParserFactory, ());
+
+    registry->addPayloadParserFactoryToRegistry(m4v, m4vP);
+    registry->addPayloadParserFactoryToRegistry(h264, h264P);
+    registry->addPayloadParserFactoryToRegistry(aac_latm, aacP);
+    registry->addPayloadParserFactoryToRegistry(mp4a, aacP);
+    registry->addPayloadParserFactoryToRegistry(amr, amrP);
+    registry->addPayloadParserFactoryToRegistry(amrwb, amrwbP);
+    registry->addPayloadParserFactoryToRegistry(h263_old, h263P);
+    registry->addPayloadParserFactoryToRegistry(h263, h263P);
+    registry->addPayloadParserFactoryToRegistry(rfc3640,  rfc3640P);
+}
+
+void PVMFSMRTSPUnicastNode::DestroyPayloadParserRegistry()
+{
+    StrPtrLen aac_latm("audio/MP4A-LATM");
+    StrPtrLen amr("audio/AMR");
+    StrPtrLen amrwb("audio/AMR-WB");
+    StrPtrLen h263("video/H263-2000");
+    StrPtrLen m4v("video/MP4V-ES");
+    StrPtrLen h264("video/H264");
+    StrPtrLen rfc3640("audio/mpeg4-generic");
+
+    PayloadParserRegistry* registry =
+        PayloadParserRegistry::GetPayloadParserRegistry();
+    if (registry == NULL) return;
+
+    OsclMemoryFragment memFrag;
+
+    memFrag.ptr = (OsclAny*)(m4v.c_str());
+    memFrag.len = (uint32)m4v.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h264.c_str());
+    memFrag.len = (uint32)h264.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(aac_latm.c_str());
+    memFrag.len = (uint32)aac_latm.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amr.c_str());
+    memFrag.len = (uint32)amr.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amrwb.c_str());
+    memFrag.len = (uint32)amrwb.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h263.c_str());
+    memFrag.len = (uint32)h263.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(rfc3640.c_str());
+    memFrag.len = (uint32)rfc3640.size();
+    OSCL_DELETE(registry->lookupPayloadParserFactory(memFrag));
+
+    PayloadParserRegistry::Cleanup();
+}
+
+void PVMFSMRTSPUnicastNode::QueryChildNodesExtentionInterface()
+{
+    PVMFSMFSPChildNodeContainerVector::iterator it;
+    for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+    {
+        //we dont use dynamic cast for cross cast.. because some compilers may not support it, and to avoid
+        //run time overheads.... So, we need to explicitly downcast the pvmfnodeinterface ptr to its
+        //concrete implementation and then, upcast it into required PVInterface class
+
+        PVInterface * interfacePtr = NULL;
+        switch (it->iNodeTag)
+        {
+            case PVMF_SM_FSP_SOCKET_NODE:
+            {
+                PVMFSocketNode * tmpPtr = OSCL_STATIC_CAST(PVMFSocketNode *, it->iNode);
+                interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
+            }
+            break;
+            case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE:
+            {
+                PVRTSPEngineNode * tmpPtr = OSCL_STATIC_CAST(PVRTSPEngineNode *, it->iNode);
+                interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
+            }
+            break;
+            case PVMF_SM_FSP_JITTER_BUFFER_NODE:
+            {
+                PVMFJitterBufferNode * tmpPtr = OSCL_STATIC_CAST(PVMFJitterBufferNode *, it->iNode);
+                interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
+            }
+            break;
+            case PVMF_SM_FSP_MEDIA_LAYER_NODE:
+            {
+                PVMFMediaLayerNode * tmpPtr = OSCL_STATIC_CAST(PVMFMediaLayerNode *, it->iNode);
+                interfacePtr = OSCL_STATIC_CAST(PVInterface*, tmpPtr);
+            }
+            break;
+        }
+
+        PVInterface* extensionIntfPtr = NULL;
+        bool retval = interfacePtr->queryInterface(it->iExtensionUuids.front(), extensionIntfPtr);
+        if (retval && extensionIntfPtr)
+        {
+            it->iExtensions.push_back(extensionIntfPtr);
+        }
+    }
+}
+
+/**
+ * Called by the command handler AO to process a command from
+ * the input queue.
+ * Return true if a command was processed, false if the command
+ * processor is busy and can't process another command now.
+ */
+bool PVMFSMRTSPUnicastNode::ProcessCommand(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    if (EPVMFNodeError == iInterfaceState)
+    {
+        if (iCurrErrHandlingCommand.size() > 0)
+        {
+            return false;
+        }
+        switch (aCmd.iCmd)
+        {
+            case PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR:
+                DoCancelAllPendingCommands(aCmd);
+                break;
+            case PVMF_SMFSP_NODE_RESET_DUE_TO_ERROR:
+                DoResetDueToErr(aCmd);
+                break;
+        }
+
+        return true;
+    }
+    /*
+     * normally this node will not start processing one command
+     * until the prior one is finished.  However, a hi priority
+     * command such as Cancel must be able to interrupt a command
+     * in progress.
+     */
+    if ((iCurrentCommand.size() > 0 && !aCmd.hipri()
+            && aCmd.iCmd != PVMF_SMFSP_NODE_CANCEL_GET_LICENSE)
+            || iCancelCommand.size() > 0)
+        return false;
+
+    OSCL_ASSERT(PVMF_SMFSP_NODE_QUERYUUID != aCmd.iCmd);
+    OSCL_ASSERT(PVMF_SMFSP_NODE_SET_DATASOURCE_RATE != aCmd.iCmd);
+    switch (aCmd.iCmd)
+    {
+            /* node interface commands */
+        case PVMF_SMFSP_NODE_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_INIT:
+            DoInit(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_PREPARE:
+            DoPrepare(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_START:
+            DoStart(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_STOP:
+            DoStop(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_FLUSH:
+            DoFlush(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_PAUSE:
+            if (iPauseDenied)
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+            }
+            else
+            {
+                DoPause(aCmd);
+            }
+            break;
+        case PVMF_SMFSP_NODE_RESET:
+            DoReset(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_CANCELALLCOMMANDS:
+            DoCancelAllCommands(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_CANCELCOMMAND:
+            DoCancelCommand(aCmd);
+            break;
+
+            /* add extention interface commands */
+        case PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION:
+            OSCL_ASSERT(iPlayListRepositioning != true);
+            if (!oAutoReposition)
+            {
+                DoSetDataSourcePosition(aCmd);
+            }
+            else
+            {
+                DoSetDataSourcePositionOverflow(aCmd);
+            }
+            break;
+
+        case PVMF_SMFSP_NODE_QUERY_DATASOURCE_POSITION:
+            DoQueryDataSourcePosition(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_SET_DATASOURCE_RATE:
+
+            break;
+        case PVMF_SMFSP_NODE_GETNODEMETADATAKEYS:
+        {
+            PVMFStatus status = DoGetMetadataKeys(aCmd);
+            if (status != PVMFPending)
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+            else
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_GETNODEMETADATAVALUES:
+        {
+            PVMFStatus status = DoGetMetadataValues(aCmd);
+            if (status != PVMFPending)
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+            else
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_GET_LICENSE_W:
+        {
+            PVMFStatus status = DoGetLicense(aCmd, true);
+            if (status == PVMFPending)
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+            else
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_GET_LICENSE:
+        {
+            PVMFStatus status = DoGetLicense(aCmd);
+            if (status == PVMFPending)
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+            else
+            {
+                CommandComplete(iInputCommands, aCmd, status);
+            }
+        }
+        break;
+        case PVMF_SMFSP_NODE_CANCEL_GET_LICENSE:
+            DoCancelGetLicense(aCmd);
+            break;
+        case PVMF_SMFSP_NODE_CAPCONFIG_SETPARAMS:
+        {
+            PvmiMIOSession session;
+            PvmiKvp* aParameters;
+            int num_elements;
+            PvmiKvp** ppRet_kvp;
+            aCmd.Parse(session, aParameters, num_elements, ppRet_kvp);
+            setParametersSync(NULL, aParameters, num_elements, *ppRet_kvp);
+            ciObserver->SignalEvent(aCmd.iId);
+        }
+        break;
+
+        /* internal commands common to all types of streaming*/
+        case PVMF_SMFSP_NODE_CONSTRUCT_SESSION:	//to construct the graph
+        {
+            PVMFStatus status = DoGraphConstruct();
+            if (status != PVMFPending)
+            {
+                InternalCommandComplete(iInputCommands, aCmd, status);
+            }
+            else
+            {
+                MoveCmdToCurrentQueue(aCmd);
+            }
+        }
+        break;
+
+        /* internal commands specific to rtsp unicast streaming*/
+
+        /* unknown commands */
+        default:
+            /* unknown command type */
+            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+            break;
+    }
+    return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Node command servicing functions queued in input command Q by base class
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMRTSPUnicastNode::DoQueryInterface(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryInterface - In"));
+
+    PVUuid* uuid;
+    PVInterface** ptr;
+    aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(uuid, ptr);
+
+    *ptr = NULL;
+
+    if (*uuid == PVMF_TRACK_SELECTION_INTERFACE_UUID)
+    {
+        PVMFTrackSelectionExtensionInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFTrackSelectionExtensionInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)
+    {
+        PVMFDataSourceInitializationExtensionInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFDataSourceInitializationExtensionInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PvmfDataSourcePlaybackControlUuid)
+    {
+        PvmfDataSourcePlaybackControlInterface* interimPtr =
+            OSCL_STATIC_CAST(PvmfDataSourcePlaybackControlInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == KPVMFMetadataExtensionUuid)
+    {
+        PVMFMetadataExtensionInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        PvmiCapabilityAndConfig* interimPtr =
+            OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else if (*uuid == PVMFCPMPluginLicenseInterfaceUuid)
+    {
+        PVMFCPMPluginLicenseInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, this);
+        *ptr = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+    }
+    else
+    {
+        *ptr = NULL;
+    }
+
+    if (*ptr)
+    {
+        PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::QueryInterface() - CmdComplete - PVMFSuccess"));
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::QueryInterface() - CmdFailed - PVMFErrNotSupported"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+    }
+
+
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryInterface - Out"));
+    return;
+}
+
+void PVMFSMRTSPUnicastNode::DoInit(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoInit - In"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeIdle:
+        {
+            /*
+             * At first Init, PVMFErrLicesneRequest is replied from Janus.
+             * Then iCPMInitPending is set into true.
+             * If second Init is called, just to check license authentication is required.
+             */
+            if (iCPMInitPending)
+            {
+                MoveCmdToCurrentQueue(aCmd);
+                if (iSessionSourceInfo->iDRMProtected == true && iCPM)
+                {
+                    RequestUsage();
+                    return;
+                }
+                else
+                {
+                    CommandComplete(iCurrentCommand,
+                                    iCurrentCommand.front(),
+                                    PVMFFailure,
+                                    NULL, NULL, NULL);
+                    return;
+                }
+            }
+            else
+            {
+                /* An asynchronous method that prepare's the node for init */
+                PVMFStatus status = DoPreInit(aCmd);
+                if (status == PVMFSuccess)
+                {
+                    /*
+                     * Init for streaming manager cannot be completed unless Init
+                     * for all the children nodes are complete
+                     */
+                    PVMFSMFSPChildNodeContainerVector::iterator it;
+                    for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+                    {
+                        PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                        if (internalCmd != NULL)
+                        {
+                            internalCmd->cmd =
+                                it->commandStartOffset +
+                                PVMF_SM_FSP_NODE_INTERNAL_INIT_CMD_OFFSET;
+                            internalCmd->parentCmd = aCmd.iCmd;
+
+                            OsclAny *cmdContextData =
+                                OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                            PVMFNodeInterface* iNode = it->iNode;
+
+                            iNode->Init(it->iSessionId, cmdContextData);
+                            it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                        }
+                        else
+                        {
+                            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoInit:RequestNewInternalCmd - Failed"));
+                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                            return;
+                        }
+                    }
+                    MoveCmdToCurrentQueue(aCmd);
+                }
+                else if (status == PVMFPending)
+                {
+                    MoveCmdToCurrentQueue(aCmd);
+                }
+                else
+                {
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoInit: DoPreInit() - Failed"));
+                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+                    int32 errcode = PVMFStreamingManagerNodeErrorParseSDPFailed;
+                    CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
+                    return;
+                }
+            }
+        }
+        break;
+
+        default:
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoInit Failed - Invalid State"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+        }
+        break;
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoInit - Out"));
+}
+
+/**
+ * Call by DoInit as a prep step
+ */
+PVMFStatus PVMFSMRTSPUnicastNode::DoPreInit(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    OSCL_UNUSED_ARG(aCmd);
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPreInit - In"));
+    PVMFStatus status = PVMFSuccess;
+
+    if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+    {
+        status = ProcessSDP();
+        if (status != PVMFSuccess)
+        {
+            PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPreInit - Out, status=%d", status));
+            return status;
+        }
+
+        // ClipEndURL found - let UI know about this
+        if (iSdpInfo->getSessionInfo()->getEndOfClipAction() == LAUNCH_URL)
+        {
+            PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+            int32 infocode = PVMFStreamingManagerNodeInfoLaunchURL;
+            ReportInfoEvent(PVMFInfoRemoteSourceNotification, (OsclAny*)(iSdpInfo->getSessionInfo()->getLaunchURL()), &eventuuid, &infocode);
+        }
+
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return PVMFFailure;
+        }
+
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+
+        /*
+         * This vector is intentionally left uninitialized.
+         * Streaming manager does not have any track selection info
+         * at this stage. "SetSDPInfo" would be called again before
+         * prepare complete to set up all the selected tracks. This
+         * call is needed here to indicate to Session Controller node
+         * that it is NOT a RTSP URL based session
+         */
+        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
+
+        status = rtspExtIntf->SetSDPInfo(iSdpInfo,
+                                         aSelectedStream);
+        if (status != PVMFSuccess)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoPreInit - SetSDPInfo Failed"));
+        }
+
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPreInit - Out"));
+    return status;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::ProcessSDP()
+{
+    PVMFStatus status;
+    OsclRefCounterMemFrag iSDPText;
+
+    if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+    {
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return PVMFFailure;
+        }
+
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+
+        status = rtspExtIntf->GetSDP(iSDPText);
+
+        if (status != PVMFSuccess)
+        {
+            return status;
+        }
+    }
+    else if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+    {
+        /* Parse SDP file contents into a buffer */
+        Oscl_FileServer fileServ;
+        Oscl_File osclFile;
+        fileServ.Connect();
+        PVMFSourceContextData* atempData = (PVMFSourceContextData*)iSessionSourceInfo->_sourceData;
+        if (atempData && atempData->CommonData() && atempData->CommonData()->iFileHandle)
+        {
+            OsclFileHandle* tempHandle = atempData ->CommonData()->iFileHandle;
+            osclFile.SetFileHandle(tempHandle);
+        }
+
+        if (osclFile.Open(iSessionSourceInfo->_sessionURL.get_cstr(),
+                          Oscl_File::MODE_READ,
+                          fileServ) != 0)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Unable to open SDP file"));
+            return PVMFFailure;
+        }
+
+        /* Get File Size */
+        osclFile.Seek(0, Oscl_File::SEEKEND);
+        int32 fileSize = osclFile.Tell();
+        osclFile.Seek(0, Oscl_File::SEEKSET);
+
+        if (fileSize <= 0)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Corrupt SDP file"));
+            return PVMFFailure;
+        }
+
+        OsclMemAllocDestructDealloc<uint8> my_alloc;
+        OsclRefCounter* my_refcnt;
+        uint aligned_refcnt_size =
+            oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+        /*
+         * To acct for null char, as SDP buffer is treated akin to a string by the
+         * SDP parser lib.
+         */
+        uint allocsize = oscl_mem_aligned_size(aligned_refcnt_size + fileSize + 2);
+        uint8* my_ptr = GetMemoryChunk(my_alloc, allocsize);
+        if (!my_ptr)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Unable to process SDP file"));
+            return PVMFFailure;
+        }
+
+        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
+        my_ptr += aligned_refcnt_size;
+
+        OsclMemoryFragment memfrag;
+        memfrag.len = fileSize;
+        memfrag.ptr = my_ptr;
+
+        OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
+        iSDPText = tmpRefcntMemFrag;
+
+        osclFile.Read(memfrag.ptr, 1, fileSize);
+
+        osclFile.Close();
+        fileServ.Close();
+    }
+
+    PVMFSMSharedPtrAlloc<SDPInfo> sdpAlloc;
+    SDPInfo* sdpInfo = sdpAlloc.allocate();
+
+    SDP_Parser *sdpParser;
+
+    SDPMediaParserRegistry* sdpParserReg = SDPMediaParserRegistryPopulater::PopulateRegistry();
+    sdpParser = OSCL_NEW(SDP_Parser, (sdpParserReg));
+
+    int32 sdpRetVal =
+        sdpParser->parseSDP((const char*)(iSDPText.getMemFragPtr()),
+                            iSDPText.getMemFragSize(),
+                            sdpInfo);
+
+    // save the SDP file name - the packet source node will need this
+    sdpInfo->setSDPFilename(iSessionSourceInfo->_sessionURL);
+
+    OSCL_DELETE(sdpParser);
+    SDPMediaParserRegistryPopulater::CleanupRegistry(sdpParserReg);
+
+    OsclRefCounterSA< PVMFSMSharedPtrAlloc<SDPInfo> > *refcnt =
+        new OsclRefCounterSA< PVMFSMSharedPtrAlloc<SDPInfo> >(sdpInfo);
+
+    OsclSharedPtr<SDPInfo> sharedSDPInfo(sdpInfo, refcnt);
+
+    if (sdpRetVal != SDP_SUCCESS)
+    {
+        return PVMFFailure;
+    }
+
+    iSdpInfo = sharedSDPInfo;
+
+    return PVMFSuccess;
+}
+
+//Compute Jitter buffer mem pool size
+uint32 PVMFSMRTSPUnicastNode::GetJitterBufferMemPoolSize(PVMFJitterBufferNodePortTag aJBNodePortTag, PVMFRTSPTrackInfo& aRTSPTrackInfo)
+{
+    uint32 sizeInBytes = 0;
+    uint32 byteRate = (aRTSPTrackInfo.bitRate) / 8;
+    uint32 overhead = (byteRate * PVMF_JITTER_BUFFER_NODE_MEM_POOL_OVERHEAD) / 100;
+    uint32 jitterBufferDuration;
+
+    PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (jitterBufferNodeContainer == NULL)
+    {
+        OSCL_ASSERT(false);
+        return false;
+    }
+
+    PVMFJitterBufferExtensionInterface* jbExtIntf = OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions[0]);
+    if (jbExtIntf == NULL)
+    {
+        OSCL_ASSERT(false);
+        return sizeInBytes;
+    }
+
+    jbExtIntf->getJitterBufferDurationInMilliSeconds(jitterBufferDuration);
+    uint32 durationInSec = jitterBufferDuration / 1000;
+    switch (aJBNodePortTag)
+    {
+        case PVMF_JITTER_BUFFER_PORT_TYPE_INPUT:
+        {
+            if (durationInSec > 0)
+            {
+                sizeInBytes = ((byteRate + overhead) * durationInSec);
+                if (sizeInBytes < MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES)
+                {
+                    sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
+                }
+                sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);		//eq. to SNODE_UDP_MULTI_MAX_BYTES_PER_RECV + MAX_UDP_PACKET_SIZE used in socket node
+            }
+
+        }
+        break;
+        case PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK:
+        {
+            if (durationInSec > 0)
+            {
+                sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
+                sizeInBytes += (2 * MAX_SOCKET_BUFFER_SIZE);		//eq. to SNODE_UDP_MULTI_MAX_BYTES_PER_RECV + MAX_UDP_PACKET_SIZE used in socket node
+            }
+        }
+        break;
+        default:
+            sizeInBytes = 0;
+    }
+    return sizeInBytes;
+}
+
+/**
+ * Called as a pre step for prepare
+ */
+PVMFStatus PVMFSMRTSPUnicastNode::DoGraphConstruct()
+{
+    /*
+     * Session source info must have been set
+     */
+    if (iSessionSourceInfo->_sessionType == PVMF_MIME_FORMAT_UNKNOWN)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GraphConstruct - Invalid Session Type %s", iSessionSourceInfo->_sessionType.getMIMEStrPtr()));
+        return PVMFFailure;
+    }
+    if (!PopulateTrackInfoVec())
+    {
+        return PVMFFailure;
+    }
+
+    if (ConstructGraphFor3GPPUDPStreaming())
+    {
+        if (iTotalNumRequestPortsComplete == iNumRequestPortsPending)
+            return PVMFSuccess;
+        else
+            return PVMFPending;
+
+    }
+    else
+        return PVMFFailure;
+}
+
+bool PVMFSMRTSPUnicastNode::PopulateTrackInfoVec()
+{
+    if (iSelectedMediaPresetationInfo.getNumTracks() == 0)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:PopulateTrackInfoVec - Selected Track List Empty"));
+        return false;
+    }
+
+    /*
+     * Get selected tracks
+     */
+
+    int32 numTracks = iSdpInfo->getNumMediaObjects();
+
+    if (numTracks > 0)
+    {
+        for (int32 i = 0; i < numTracks; i++)
+        {
+            /*
+             * Get the vector of mediaInfo as there can
+             * alternates for each track
+             */
+            Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
+                iSdpInfo->getMediaInfo(i);
+
+            uint32 minfoVecLen = mediaInfoVec.size();
+            for (uint32 j = 0; j < minfoVecLen; j++)
+            {
+                mediaInfo* mInfo = mediaInfoVec[j];
+
+                if (mInfo == NULL)
+                {
+                    return false;
+                }
+
+                if (mInfo->getSelect())
+                {
+                    PVMFRTSPTrackInfo trackInfo;
+                    trackInfo.iTransportType += _STRLIT_CHAR("RTP");
+                    trackInfo.trackID = mInfo->getMediaInfoID();
+
+                    Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
+                    payloadVector = mInfo->getPayloadSpecificInfoVector();
+
+                    if (payloadVector.size() == 0)
+                    {
+                        return false;
+                    }
+                    /*
+                     * There can be multiple payloads per media segment.
+                     * We only support one for now, so
+                     * use just the first payload
+                     */
+                    PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
+                    trackInfo.trackTimeScale = payloadInfo->sampleRate;
+
+                    // set config for later
+                    int32 configSize = payloadInfo->configSize;
+                    OsclAny* config = payloadInfo->configHeader.GetRep();
+
+                    const char* mimeType = mInfo->getMIMEType();
+                    trackInfo.iMimeType += mimeType;
+
+                    trackInfo.portTag = mInfo->getMediaInfoID();
+                    trackInfo.bitRate = mInfo->getBitrate();
+                    if (mInfo->getReportFrequency() > 0)
+                    {
+                        trackInfo.iRateAdaptation = true;
+                        trackInfo.iRateAdaptationFeedBackFrequency =
+                            mInfo->getReportFrequency();
+                    }
+
+                    if ((mInfo->getRTCPReceiverBitRate() >= 0) &&
+                            (mInfo->getRTCPSenderBitRate() >= 0))
+                    {
+                        trackInfo.iRR = mInfo->getRTCPReceiverBitRate();
+                        trackInfo.iRS = mInfo->getRTCPSenderBitRate();
+                        trackInfo.iRTCPBwSpecified = true;
+                    }
+
+                    if ((configSize > 0) && (config != NULL))
+                    {
+                        OsclMemAllocDestructDealloc<uint8> my_alloc;
+                        OsclRefCounter* my_refcnt;
+                        uint aligned_refcnt_size =
+                            oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+
+                        uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
+                        if (!my_ptr)
+                            return false;
+
+                        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
+                        my_ptr += aligned_refcnt_size;
+
+                        OsclMemoryFragment memfrag;
+                        memfrag.len = (uint32)configSize;
+                        memfrag.ptr = my_ptr;
+
+                        oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
+
+                        OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
+                        trackInfo.iTrackConfig = tmpRefcntMemFrag;
+                    }
+                    iTrackInfoVec.push_back(trackInfo);
+                }
+            }
+        }
+    }
+    else
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:PopulateTrackInfoVec - Selected Track List Empty"));
+        return false;
+    }
+
+    return true;
+}
+
+bool PVMFSMRTSPUnicastNode::ConstructGraphFor3GPPUDPStreaming()
+{
+    uint32 numPortsRequested = 0;
+
+    /*
+     * Reserve UDP socket pairs
+     */
+    if (!ReserveSockets())
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - ReserveSockets() Failed"));
+        return false;
+    }
+
+    /*
+     * Request data UDP ports
+     */
+    if (!RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SOURCE,
+                                 numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SOURCE) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    /*
+     * Request feedback (RTCP) UDP ports
+     */
+    if (!RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SINK,
+                                 numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SINK) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT,
+                                  numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT,
+                                  numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK,
+                                  numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT,
+                                numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT,
+                                numPortsRequested))
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT) Failed"));
+        return false;
+    }
+    iNumRequestPortsPending += numPortsRequested;
+
+    return true;
+}
+
+bool PVMFSMRTSPUnicastNode::ReserveSockets()
+{
+    uint32 sockid = 0;
+    char portConfigBuf[64];
+    oscl_memset((OsclAny*)portConfigBuf, 0, 64);
+    oscl_snprintf(portConfigBuf, 64, "%d", sockid);
+    OSCL_StackString<128> portConfig("UDP");
+    portConfig += _STRLIT_CHAR("/remote_address=0.0.0.0");
+    portConfig += _STRLIT_CHAR(";client_port=");
+    portConfig += portConfigBuf;
+
+    PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
+    if (iSocketNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return false;
+    }
+    PVMFSocketNodeExtensionInterface* snExtIntf =
+        (PVMFSocketNodeExtensionInterface*)
+        (iSocketNodeContainer->iExtensions[0]);
+
+    PVMFRTSPTrackInfoVector::iterator it;
+    uint32 startPortNum = 0;
+    {
+        TimeValue current_time;
+        current_time.set_to_current_time();
+        uint32 my_seed = current_time.get_sec();
+
+        OsclRand random_num;
+        random_num.Seed(my_seed);
+        int32 first = random_num.Rand();
+        uint32 myport = (first & 0x1FFF) + 0x2000;	//start from 8192
+        startPortNum = (myport >> 1) << 1;	//start from even
+    }
+
+    for (it = iTrackInfoVec.begin();
+            it != iTrackInfoVec.end();
+            it++)
+    {
+        OSCL_StackString<128> portConfigWithMime;
+        portConfigWithMime += portConfig;
+        portConfigWithMime += _STRLIT_CHAR(";mime=");
+        portConfigWithMime += it->iMimeType;
+
+        PVMFStatus status = snExtIntf->AllocateConsecutivePorts(&portConfigWithMime,
+                            it->iRTPSocketID,
+                            it->iRTCPSocketID, startPortNum);
+        if (status != PVMFSuccess)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool PVMFSMRTSPUnicastNode::RequestNetworkNodePorts(int32 portTag,
+        uint32& numPortsRequested)
+{
+    numPortsRequested = 0;
+
+    PVMFSMFSPChildNodeContainer* nodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
+
+    if (nodeContainer == NULL)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:RequestNetworkNodePorts - getChildNodeContainer Failed"));
+        return false;
+    }
+
+    for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+    {
+        PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
+
+        PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+        if (internalCmd != NULL)
+        {
+            internalCmd->cmd =
+                nodeContainer->commandStartOffset +
+                PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
+            internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
+            internalCmd->portContext.trackID = trackInfo.trackID;
+            internalCmd->portContext.portTag = portTag;
+
+            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+            PVMFNodeInterface* iNode = nodeContainer->iNode;
+
+            uint32 sockid = 0;
+            bool oRTCP = false;
+
+            if (portTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
+            {
+                sockid = trackInfo.iRTPSocketID;
+            }
+            else if (portTag == PVMF_SOCKET_NODE_PORT_TYPE_SINK)
+            {
+                sockid = trackInfo.iRTCPSocketID;
+                oRTCP = true;
+            }
+
+            char portConfigBuf[64];
+            oscl_memset((OsclAny*)portConfigBuf, 0, 64);
+            oscl_snprintf(portConfigBuf, 64, "%d", sockid);
+            OSCL_StackString<128> portConfig("UDP");
+            portConfig += _STRLIT_CHAR("/remote_address=0.0.0.0");
+            portConfig += _STRLIT_CHAR(";client_port=");
+            portConfig += portConfigBuf;
+            portConfig += _STRLIT_CHAR(";mime=");
+            portConfig += trackInfo.iMimeType.get_cstr();
+            if (oRTCP == true)
+            {
+                portConfig += _STRLIT_CHAR("/rtcp");
+            }
+            else
+            {
+                portConfig += _STRLIT_CHAR("/rtp");
+            }
+
+            iNode->RequestPort(nodeContainer->iSessionId,
+                               internalCmd->portContext.portTag,
+                               &portConfig,
+                               cmdContextData);
+            numPortsRequested++;
+            nodeContainer->iNumRequestPortsPending++;
+            nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:RequestNetworkNodePorts - RequestNewInternalCmd Failed"));
+            return false;
+        }
+    }
+    return true;
+}
+
+bool PVMFSMRTSPUnicastNode::RequestJitterBufferPorts(int32 portType,
+        uint32 &numPortsRequested)
+{
+    PVMFSMFSPChildNodeContainer* nodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+
+    if (nodeContainer == NULL)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:RequestJitterBufferPorts - getChildNodeContainer Failed"));
+        return false;
+    }
+
+    numPortsRequested = 0;
+    /*
+     * Request port - all jitter buffer input ports
+     * are even numbered and output and rtcp ports are odd numbered
+     */
+    int32 portTagStart = portType;
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+            || (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+       )
+    {
+        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+        {
+            PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
+
+            PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+            if (internalCmd != NULL)
+            {
+                internalCmd->cmd =
+                    nodeContainer->commandStartOffset +
+                    PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
+                internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
+                internalCmd->portContext.trackID = trackInfo.trackID;
+                internalCmd->portContext.portTag = portType;
+
+                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                PVMFNodeInterface* iNode = nodeContainer->iNode;
+
+                OSCL_StackString<32> portConfig = trackInfo.iTransportType;
+                portConfig += _STRLIT_CHAR("/");
+                portConfig += trackInfo.iMimeType;
+                iNode->RequestPort(nodeContainer->iSessionId,
+                                   portTagStart,
+                                   &(portConfig),
+                                   cmdContextData);
+                numPortsRequested++;
+                nodeContainer->iNumRequestPortsPending++;
+                nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+            }
+            else
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:RequestJitterBufferPorts - RequestNewInternalCmd Failed"));
+                return false;
+            }
+            portTagStart += 3;
+        }
+        return true;
+    }
+    return false;
+}
+
+bool PVMFSMRTSPUnicastNode::RequestMediaLayerPorts(int32 portType,
+        uint32& numPortsRequested)
+{
+    PVMFSMFSPChildNodeContainer* nodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+
+    if (nodeContainer == NULL)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:RequestMediaLayerPorts - getChildNodeContainer Failed"));
+        return false;
+    }
+
+    numPortsRequested = 0;
+    /*
+     * Request port - all media layer input ports
+     * are even numbered and output are odd numbered
+     */
+    int32 portTagStart = portType;
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL)
+            || (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+       )
+    {
+        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+        {
+            PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
+
+            PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+            if (internalCmd != NULL)
+            {
+                internalCmd->cmd =
+                    nodeContainer->commandStartOffset +
+                    PVMF_SM_FSP_NODE_INTERNAL_REQUEST_PORT_OFFSET;
+                internalCmd->parentCmd = PVMF_SMFSP_NODE_CONSTRUCT_SESSION;
+                internalCmd->portContext.trackID = trackInfo.trackID;
+                internalCmd->portContext.portTag = portType;
+
+                OsclAny *cmdContextData =
+                    OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                PVMFNodeInterface* iNode = nodeContainer->iNode;
+
+                iNode->RequestPort(nodeContainer->iSessionId,
+                                   portTagStart,
+                                   &(trackInfo.iMimeType),
+                                   cmdContextData);
+                numPortsRequested++;
+                nodeContainer->iNumRequestPortsPending++;
+                nodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+            }
+            else
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:RequestMediaLayerPorts - RequestNewInternalCmd Failed"));
+                return false;
+            }
+            portTagStart += 2;
+        }
+
+        return true;
+    }
+
+    //error
+    return false;
+}
+
+void PVMFSMRTSPUnicastNode::DoPrepare(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPrepare - In"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        {
+            if (iGraphConstructComplete)
+            {
+                /*
+                 * Connect the graph here. This is needed since we would send firewall packets
+                 * as part of Prepare.
+                 */
+                if (GraphConnect() == false)
+                {
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare - GraphConnect Failed"));
+                    SetState(EPVMFNodeError);
+                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+                    int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
+                    CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
+                    return;
+                }
+
+                /*
+                 * Prepare for streaming manager cannot be completed unless Prepare
+                 * for all the children nodes are complete
+                 */
+                PVMFSMFSPChildNodeContainerVector::iterator it;
+                for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+                {
+                    PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                    if (internalCmd != NULL)
+                    {
+                        internalCmd->cmd =
+                            it->commandStartOffset +
+                            PVMF_SM_FSP_NODE_INTERNAL_PREPARE_CMD_OFFSET;
+                        internalCmd->parentCmd = aCmd.iCmd;
+
+                        OsclAny *cmdContextData =
+                            OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                        PVMFNodeInterface* iNode = it->iNode;
+
+                        iNode->Prepare(it->iSessionId, cmdContextData);
+                        it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                    }
+                    else
+                    {
+                        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare:RequestNewInternalCmd - Failed"));
+                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                        return;
+                    }
+                }
+
+                MoveCmdToCurrentQueue(aCmd);
+            }
+            else
+            {
+                /* Graph construction not complete, so cant prep */
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare Failed - Incomplete Graph"));
+                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            }
+        }
+        break;
+
+        default:
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPrepare Failed - Invalid State"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPrepare - Out"));
+}
+
+bool PVMFSMRTSPUnicastNode::GraphConnect()
+{
+    if (iGraphConnectComplete == false)
+    {
+        /*
+         * Go over the track list and connect:
+         * network_node_port -> jitter_buffer_node_input_port;
+         * jitter_buffer_node_output_port -> media_layer_input_port
+         */
+        PVMFStatus status;
+        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+        {
+            PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
+
+            if ((trackInfo.iNetworkNodePort == NULL) ||
+                    (trackInfo.iNetworkNodeRTCPPort == NULL) ||
+                    (trackInfo.iJitterBufferInputPort == NULL) ||
+                    (trackInfo.iJitterBufferOutputPort == NULL) ||
+                    (trackInfo.iJitterBufferRTCPPort == NULL) ||
+                    (trackInfo.iMediaLayerInputPort == NULL) ||
+                    (trackInfo.iMediaLayerOutputPort == NULL))
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:GraphConnectFor3GPPUDPStreaming - Invalid Ports"));
+                return false;
+            }
+
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnect - Track MimeType %s", trackInfo.iMimeType.get_cstr()));
+
+            /* connect network_node_port <-> jitter_buffer_node_input_port */
+            status = ConnectPortPairs(trackInfo.iJitterBufferInputPort,
+                                      trackInfo.iNetworkNodePort);
+
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - Connected Network - JB Input"));
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkPort=0x%x - JBInputPort=0x%x", trackInfo.iNetworkNodePort, trackInfo.iJitterBufferInputPort));
+
+            if (status != PVMFSuccess)
+            {
+                return false;
+            }
+
+            /*
+             * connect jitter_buffer_node_output_port <->
+             * media_layer_input_port
+             */
+            status = ConnectPortPairs(trackInfo.iJitterBufferOutputPort,
+                                      trackInfo.iMediaLayerInputPort);
+
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - JB Output - ML Input"));
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - JB Output=0x%x - ML Input=0x%x", trackInfo.iJitterBufferOutputPort, trackInfo.iMediaLayerInputPort));
+
+            if (status != PVMFSuccess)
+            {
+                return false;
+            }
+
+            /*
+             * connect network_rtcp_port <-> jitter_buffer_rtcp_port
+             */
+            status = ConnectPortPairs(trackInfo.iJitterBufferRTCPPort,
+                                      trackInfo.iNetworkNodeRTCPPort);
+
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort - JBRTCPPort"));
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort=0x%x - JBRTCPPort=0x%x", trackInfo.iNetworkNodeRTCPPort, trackInfo.iJitterBufferRTCPPort));
+
+            if (status != PVMFSuccess)
+            {
+                return false;
+            }
+        }
+        iGraphConnectComplete = true;
+    }
+    return true;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::ConnectPortPairs(PVMFPortInterface* aPort1,
+        PVMFPortInterface* aPort2)
+{
+    PVMFStatus status;
+
+    status = aPort1->Connect(aPort2);
+
+    if (status != PVMFSuccess)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:ConnectPortPairs - Connect Failed"));
+        return status;
+    }
+
+    return status;
+}
+
+void PVMFSMRTSPUnicastNode::DoRequestPort(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoRequestPort - In"));
+    /*
+     * This node supports port request only after the graph
+     * has been fully constructed
+     */
+    if (iGraphConstructComplete)
+    {
+        /*
+         * retrieve port tag
+         */
+        OSCL_String* mimetype;
+        int32 tag;
+        aCmd.PVMFSMFSPBaseNodeCommandBase::Parse(tag, mimetype);
+        /*
+         * Do not Allocate a new port. RTSP unicast node treats the output
+         * port from the media layer as its own output port. Find the media
+         * layer output port corresponding to the input mimetype and hand the
+         * same out
+         */
+        PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(tag);
+
+        PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+        int32 errcode = PVMFStreamingManagerNodeErrorInvalidRequestPortTag;
+
+        if (trackInfo == NULL)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoRequestPort: FindTrackInfo failed"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
+            return;
+        }
+        if (trackInfo->iMediaLayerOutputPort == NULL)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoRequestPort: iMediaLayerOutputPort NULL"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
+            return;
+        }
+        PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::DoRequestPort() - CmdComplete - PVMFSuccess"));
+        /*
+         * Return the port pointer to the caller.
+         */
+        CommandComplete(iInputCommands,
+                        aCmd,
+                        PVMFSuccess,
+                        (OsclAny*)(trackInfo->iMediaLayerOutputPort));
+
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::DoRequestPort Success"));
+    }
+    else
+    {
+        PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::RequestPort() - CmdFailed - PVMFErrInvalidState"));
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoRequestPort Failed - InvalidState"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoRequestPort - Out"));
+}
+
+void PVMFSMRTSPUnicastNode::DoReleasePort(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoReleasePort - In"));
+    /*
+     * Since the streaming manager does not have ports of its own,
+     * a release port command typically translates to disconnecting
+     * the underlying media layer port.
+     */
+    PVMFPortInterface* port;
+    aCmd.PVMFSMFSPBaseNodeCommandBase::Parse((PVMFPortInterface*&)port);
+
+    /*
+     * Find TrackInfo that corresponds to the Media Layer Output port
+     * on which the current relase is being called.
+     */
+    PVMFRTSPTrackInfoVector::iterator it;
+    PVMFRTSPTrackInfo* trackInfo = NULL;
+
+    for (it = iTrackInfoVec.begin();
+            it != iTrackInfoVec.end();
+            it++)
+    {
+        if (it->iMediaLayerOutputPort == port)
+        {
+            trackInfo = it;
+            break;
+        }
+    }
+
+    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+    if (trackInfo == NULL)
+    {
+        PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::ReleasePort() - CmdFailed - PVMFErrArgument"));
+        /* invalid port */
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoReleasePort Failed - Invalid Port"));
+        int32 errcode = PVMFStreamingManagerNodeErrorInvalidPort;
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
+        return;
+    }
+    PVMFStatus status = it->iMediaLayerOutputPort->Disconnect();
+
+    if (status != PVMFSuccess)
+    {
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::DoReleasePort Success"));
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    }
+    else
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoReleasePort Failed"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrPortProcessing);
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoReleasePort - Out"));
+}
+
+void PVMFSMRTSPUnicastNode::DoStart(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStart - In"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodePrepared:
+        {
+            /*
+             * Connect the graph if not already connected. Usually the graph is
+             * disconnected as part of Stop. In case we are doing a start after
+             * stop, we would need to connect the graph again.
+             */
+            if (GraphConnect() == false)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:CompleteStart - GraphConnect Failed"));
+                SetState(EPVMFNodeError);
+                PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+                int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
+                CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
+                return;
+            }
+
+            bool isSessionDurationExpired = false;
+
+            PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (jitterBufferNodeContainer)
+            {
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
+                if (jbExtIntf)
+                    jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
+            }
+
+            PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+            if (sessionControllerNodeContainer)
+            {
+                PVRTSPEngineNodeExtensionInterface*	rtspExtIntf =
+                    OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
+                if (rtspExtIntf)
+                    rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
+            }
+
+            /*
+             * Start for streaming manager cannot be completed unless
+             * Start for all the children nodes are complete
+             */
+            PVMFSMFSPChildNodeContainerVector::iterator it;
+            for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+            {
+                PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                if (internalCmd != NULL)
+                {
+                    internalCmd->cmd =
+                        it->commandStartOffset +
+                        PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET;
+                    internalCmd->parentCmd = aCmd.iCmd;
+
+                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                    PVMFNodeInterface* iNode = it->iNode;
+
+                    iNode->Start(it->iSessionId, cmdContextData);
+                    it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                }
+                else
+                {
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoStart:RequestNewInternalCmd - Failed"));
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                    return;
+                }
+            }
+
+            MoveCmdToCurrentQueue(aCmd);
+        }
+        break;
+
+        /*
+         * GraphConnect() not needed if starting from a paused state
+         */
+        case EPVMFNodePaused:
+        {
+            bool isSessionDurationExpired = false;
+
+            PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (jitterBufferNodeContainer)
+            {
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
+                if (jbExtIntf)
+                    jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
+            }
+
+            PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+            if (sessionControllerNodeContainer)
+            {
+                PVRTSPEngineNodeExtensionInterface*	rtspExtIntf =
+                    OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
+                if (rtspExtIntf)
+                    rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
+            }
+            /*
+             * Start for streaming manager cannot be completed unless
+             * Start for all the children nodes are complete
+             */
+            PVMFSMFSPChildNodeContainerVector::iterator it;
+            for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+            {
+                if (it->iAutoPaused == false)
+                {
+                    PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                    if (internalCmd != NULL)
+                    {
+                        internalCmd->cmd =
+                            it->commandStartOffset +
+                            PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET;
+                        internalCmd->parentCmd = aCmd.iCmd;
+
+                        OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                        PVMFNodeInterface* iNode = it->iNode;
+
+                        iNode->Start(it->iSessionId, cmdContextData);
+                        it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                    }
+                    else
+                    {
+                        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoStart:RequestNewInternalCmd - Failed"));
+                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                        return;
+                    }
+                }
+            }
+            MoveCmdToCurrentQueue(aCmd);
+        }
+        break;
+
+        case EPVMFNodeStarted:
+            //Ignore start if already started
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStart - Out"));
+}
+
+void PVMFSMRTSPUnicastNode::DoStop(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStop - In"));
+    iStreamID = 0;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+        {
+            /*
+             * Stop for streaming manager cannot be completed unless
+             * Stop for all the children nodes are complete
+             */
+            PVMFSMFSPChildNodeContainerVector::iterator it;
+            for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+            {
+                PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                if (internalCmd != NULL)
+                {
+                    internalCmd->cmd =
+                        it->commandStartOffset +
+                        PVMF_SM_FSP_NODE_INTERNAL_STOP_CMD_OFFSET;
+                    internalCmd->parentCmd = aCmd.iCmd;
+
+                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                    PVMFNodeInterface* iNode = it->iNode;
+
+                    iNode->Stop(it->iSessionId, cmdContextData);
+                    it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                }
+                else
+                {
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoStop:RequestNewInternalCmd - Failed"));
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                    return;
+                }
+            }
+            MoveCmdToCurrentQueue(aCmd);
+        }
+        break;
+
+        default:
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::DoStop Failure - Invalid State"));
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoStop - Out"));
+}
+
+void PVMFSMRTSPUnicastNode::DoPause(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPause - In"));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        {
+            bool isSessionDurationExpired = false;
+
+            PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (jitterBufferNodeContainer)
+            {
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
+                if (jbExtIntf)
+                    jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
+            }
+
+            PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+            if (sessionControllerNodeContainer)
+            {
+                PVRTSPEngineNodeExtensionInterface*	rtspExtIntf =
+                    OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
+                if (rtspExtIntf)
+                    rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
+            }
+
+            PVMFSMFSPChildNodeContainerVector::iterator it;
+            for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+            {
+                /*
+                 * Pause only if not already paused - could happen that
+                 * some of the nodes could be paused due to flow control
+                 */
+                if ((it->iNode->GetState()) != EPVMFNodePaused)
+                {
+                    PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+                    if (internalCmd != NULL)
+                    {
+                        internalCmd->cmd =
+                            it->commandStartOffset +
+                            PVMF_SM_FSP_NODE_INTERNAL_PAUSE_CMD_OFFSET;
+                        internalCmd->parentCmd = aCmd.iCmd;
+
+                        OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                        PVMFNodeInterface* iNode = it->iNode;
+
+                        iNode->Pause(it->iSessionId, cmdContextData);
+                        it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+                    }
+                    else
+                    {
+                        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoPause:RequestNewInternalCmd - Failed"));
+                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                        return;
+                    }
+                }
+            }
+            MoveCmdToCurrentQueue(aCmd);
+        }
+        break;
+        default:
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            break;
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoPause - Out"));
+    return;
+}
+
+PVMFRTSPTrackInfo* PVMFSMRTSPUnicastNode::FindTrackInfo(uint32 atrackID)
+{
+    PVMFRTSPTrackInfoVector::iterator it;
+
+    for (it = iTrackInfoVec.begin();
+            it != iTrackInfoVec.end();
+            it++)
+    {
+        if (it->trackID == atrackID)
+        {
+            return (it);
+        }
+    }
+    return NULL;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implemenation of pure virtuals from PvmiCapabilityAndConfig interface
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMRTSPUnicastNode::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    ciObserver = aObserver;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters, int& aNumParamElements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+
+    // Initialize the output parameters
+    aNumParamElements = 0;
+    aParameters = NULL;
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aIdentifier);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aIdentifier, compstr);
+
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+    {
+        // First component should be "x-pvmf" and there must
+        // be at least two components to go past x-pvmf
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Invalid key string"));
+        return PVMFErrArgument;
+    }
+
+    // Retrieve the second component from the key string
+    pv_mime_string_extract_type(1, aIdentifier, compstr);
+
+    // Check if it is key string for streaming manager
+    if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) < 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Unsupported key"));
+        return PVMFFailure;
+    }
+
+
+    if (compcount == 2)
+    {
+        // Since key is "x-pvmf/net" return all
+        // nodes available at this level. Ignore attribute
+        // since capability is only allowed
+
+        // Allocate memory for the KVP list
+        aParameters = (PvmiKvp*)oscl_malloc(StreamingManagerConfig_NumBaseKeys * sizeof(PvmiKvp));
+        if (aParameters == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Memory allocation for KVP failed"));
+            return PVMFErrNoMemory;
+        }
+        oscl_memset(aParameters, 0, StreamingManagerConfig_NumBaseKeys*sizeof(PvmiKvp));
+        // Allocate memory for the key strings in each KVP
+        PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(StreamingManagerConfig_NumBaseKeys * SMCONFIG_KEYSTRING_SIZE * sizeof(char));
+        if (memblock == NULL)
+        {
+            oscl_free(aParameters);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Memory allocation for key string failed"));
+            return PVMFErrNoMemory;
+        }
+        oscl_strset(memblock, 0, StreamingManagerConfig_NumBaseKeys*SMCONFIG_KEYSTRING_SIZE*sizeof(char));
+        // Assign the key string buffer to each KVP
+        uint32 j;
+        for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
+        {
+            aParameters[j].key = memblock + (j * SMCONFIG_KEYSTRING_SIZE);
+        }
+        // Copy the requested info
+        for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
+        {
+            oscl_strncat(aParameters[j].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
+            oscl_strncat(aParameters[j].key, StreamingManagerConfig_BaseKeys[j].iString, oscl_strlen(StreamingManagerConfig_BaseKeys[j].iString));
+            oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";type="), 6);
+            switch (StreamingManagerConfig_BaseKeys[j].iType)
+            {
+                case PVMI_KVPTYPE_AGGREGATE:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_AGGREGATE_STRING), oscl_strlen(PVMI_KVPTYPE_AGGREGATE_STRING));
+                    break;
+
+                case PVMI_KVPTYPE_POINTER:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_POINTER_STRING), oscl_strlen(PVMI_KVPTYPE_POINTER_STRING));
+                    break;
+
+                case PVMI_KVPTYPE_VALUE:
+                default:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_VALUE_STRING), oscl_strlen(PVMI_KVPTYPE_VALUE_STRING));
+                    break;
+            }
+            oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";valtype="), 9);
+            switch (StreamingManagerConfig_BaseKeys[j].iValueType)
+            {
+                case PVMI_KVPVALTYPE_RANGE_INT32:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_KSV:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_CHARPTR:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_BOOL:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
+                    break;
+
+                case PVMI_KVPVALTYPE_UINT32:
+                default:
+                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
+                    break;
+            }
+            aParameters[j].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
+        }
+
+        aNumParamElements = StreamingManagerConfig_NumBaseKeys;
+    }
+    else if (compcount == 3)
+    {
+        pv_mime_string_extract_type(2, aIdentifier, compstr);
+
+        // Determine what is requested
+        PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
+        if (reqattr == PVMI_KVPATTR_UNKNOWN)
+        {
+            reqattr = PVMI_KVPATTR_CUR;
+        }
+        uint i;
+        for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
+        {
+            if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
+            {
+                break;
+            }
+        }
+
+        if (i == StreamingManagerConfig_NumBaseKeys)
+        {
+            // no match found
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMRTSPUnicastNode::getParametersSync() Unsupported key"));
+            return PVMFErrNoMemory;
+        }
+
+#if 0
+        // Return the requested info
+        oscl_free(aParameters);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMRTSPUnicastNode::getParametersSync() Memory allocation for key string failed"));
+        return PVMFErrNoMemory;
+#endif
+        PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, i, reqattr);
+        if (retval != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMRTSPUnicastNode::getParametersSync() "
+                             "Retrieving streaming manager parameter failed"));
+            return retval;
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSMRTSPUnicastNode::getParametersSync() Unsupported key"));
+        return PVMFErrArgument;
+    }
+
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::GetConfigParameter(PvmiKvp*& aParameters,
+        int& aNumParamElements,
+        int32 aIndex, PvmiKvpAttr reqattr)
+{
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() In"));
+
+    aNumParamElements = 0;
+
+    // Allocate memory for the KVP
+    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
+    if (aParameters == NULL)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() Memory allocation for KVP failed"));
+        return PVMFErrNoMemory;
+    }
+    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
+
+    // Allocate memory for the key string in KVP
+    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(SMCONFIG_KEYSTRING_SIZE * sizeof(char));
+    if (memblock == NULL)
+    {
+        oscl_free(aParameters);
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() Memory allocation for key string failed"));
+        return PVMFErrNoMemory;
+    }
+    oscl_strset(memblock, 0, SMCONFIG_KEYSTRING_SIZE*sizeof(char));
+
+    // Assign the key string buffer to KVP
+    aParameters[0].key = memblock;
+
+    // Copy the key string
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
+    oscl_strncat(aParameters[0].key, StreamingManagerConfig_BaseKeys[aIndex].iString,
+                 oscl_strlen(StreamingManagerConfig_BaseKeys[aIndex].iString));
+    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
+    switch (StreamingManagerConfig_BaseKeys[aIndex].iValueType)
+    {
+        case PVMI_KVPVALTYPE_RANGE_INT32:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_KSV:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_CHARPTR:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_WCHARPTR:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_WCHARPTR_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_BOOL:
+            oscl_strncat(aParameters[0].key,
+                         _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING),
+                         oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
+            break;
+
+        case PVMI_KVPVALTYPE_UINT32:
+        default:
+            if (reqattr == PVMI_KVPATTR_CAP)
+            {
+                oscl_strncat(aParameters[0].key,
+                             _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING),
+                             oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
+            }
+            else
+            {
+                oscl_strncat(aParameters[0].key,
+                             _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING),
+                             oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
+            }
+            break;
+    }
+    aParameters[0].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
+
+    // Copy the requested info
+    switch (aIndex)
+    {
+        case BASEKEY_DELAY:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->getJitterBufferDurationInMilliSeconds(aParameters[0].value.uint32_value);
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
+                                           "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_JITTER_BUFFER_DURATION_IN_MS;
+                rui32->max = MAX_JITTER_BUFFER_DURATION_IN_MS;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_REBUFFERING_THRESHOLD:
+        {
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->getJitterBufferRebufferingThresholdInMilliSeconds(aParameters[0].value.uint32_value);
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
+                                           "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
+                rui32->max = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+        }
+        break;
+        case BASEKEY_JITTERBUFFER_NUMRESIZE:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                uint32 numResize, resizeSize;
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
+                aParameters[0].value.uint32_value = numResize;
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
+                                           "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_NUM_SOCKETMEMPOOL_RESIZES;
+                rui32->max = MAX_NUM_SOCKETMEMPOOL_RESIZES;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_JITTERBUFFER_RESIZESIZE:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                uint32 numResize, resizeSize;
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
+                aParameters[0].value.uint32_value = resizeSize;
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
+                                           "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+                rui32->max = MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION:
+            if (reqattr == PVMI_KVPATTR_CUR)
+            {
+                // Return current value
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                uint32 inactivityDuration = 0;
+                if (jbExtIntf)
+                {
+                    jbExtIntf->getMaxInactivityDurationForMediaInMs(inactivityDuration);
+                }
+                aParameters[0].value.uint32_value = inactivityDuration;
+            }
+            else if (reqattr == PVMI_KVPATTR_DEF)
+            {
+                // Return default
+                aParameters[0].value.uint32_value = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
+                                           "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = 0;
+                rui32->max = DEFAULT_MAX_INACTIVITY_DURATION_IN_MS;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+            break;
+        case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                aParameters[0].value.pWChar_value = NULL;
+                /* As of now just RTSP node supports an external config of user agent */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+
+                    OSCL_wHeapString<OsclMemAllocator> userAgent;
+                    if (rtspExtIntf->GetUserAgent(userAgent) == PVMFSuccess)
+                    {
+                        // Return current value
+                        oscl_wchar* ptr = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (userAgent.get_size()));
+                        if (ptr)
+                        {
+                            oscl_memcpy(ptr, userAgent.get_cstr(), userAgent.get_size());
+                            aParameters[0].value.pWChar_value = ptr;
+                        }
+                        else
+                        {
+                            oscl_free(aParameters[0].key);
+                            oscl_free(aParameters);
+                            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::GetConfigParameter() "
+                                                   "Memory allocation for user agent failed"));
+                            return PVMFErrNoMemory;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                // Return capability - no concept of capability for user agent
+                // do nothing
+            }
+            break;
+        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL:
+        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
+                {
+                    aParameters[0].value.uint32_value = PVRTSPENGINENODE_DEFAULT_KEEP_ALIVE_INTERVAL;
+                }
+                else
+                {
+                    aParameters[0].value.bool_value = false;
+                }
+                /* As of now just RTSP node supports an external config of user agent */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+                    uint32 timeout;
+                    bool okeepalivemethod;
+                    bool okeepaliveinplay;
+                    rtspExtIntf->GetKeepAliveMethod((int32&)timeout, okeepalivemethod, okeepaliveinplay);
+                    if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
+                    {
+                        aParameters[0].value.uint32_value = timeout;
+                    }
+                    else
+                    {
+                        aParameters[0].value.bool_value = okeepaliveinplay;
+                    }
+                }
+            }
+            else
+            {
+                // Return capability - no concept of capability for keep alive interval
+                // do nothing
+            }
+            break;
+
+        case BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT:
+        {
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                /* As of now just RTSP node supports an external config of RTSP time out */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+                    int32 timeout;
+                    rtspExtIntf->GetRTSPTimeOut(timeout);
+                    aParameters[0].value.uint32_value = OSCL_STATIC_CAST(uint32, timeout);
+                }
+            }
+            else
+            {
+                // Return capability
+                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
+                if (rui32 == NULL)
+                {
+                    oscl_free(aParameters[0].key);
+                    oscl_free(aParameters);
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastPlusPVRNode::GetConfigParameter() "
+                                           "Memory allocation for range uint32 failed"));
+                    return PVMFErrNoMemory;
+                }
+                rui32->min = MIN_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC;
+                rui32->max = MAX_RTSP_SERVER_INACTIVITY_TIMEOUT_IN_SEC;
+                aParameters[0].value.key_specific_value = (void*)rui32;
+            }
+        }
+        break;
+        case BASEKEY_DISABLE_FIREWALL_PACKETS:
+        {
+            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
+            {
+                aParameters[0].value.bool_value = false;
+            }
+        }
+        break;
+
+
+        default:
+            // Invalid index
+            oscl_free(aParameters[0].key);
+            oscl_free(aParameters);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlayerParameter() Invalid index to player parameter"));
+            return PVMFErrArgument;
+    }
+
+    aNumParamElements = 1;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetPlayerParameter() Out"));
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::releaseParameters(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMRTSPUnicastNode::releaseParameters() In"));
+
+    if (aParameters == NULL || num_elements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMRTSPUnicastNode::releaseParameters() KVP list is NULL or number of elements is 0"));
+        return PVMFErrArgument;
+    }
+
+    // Count the number of components and parameters in the key
+    int compcount = pv_mime_string_compcnt(aParameters[0].key);
+    // Retrieve the first component from the key string
+    char* compstr = NULL;
+    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
+
+    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+    {
+        // First component should be "x-pvmf" and there must
+        // be at least two components to go past x-pvmf
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMRTSPUnicastNode::releaseParameters() Unsupported key"));
+        return PVMFErrArgument;
+    }
+
+    // Retrieve the second component from the key string
+    pv_mime_string_extract_type(1, aParameters[0].key, compstr);
+
+    // Assume all the parameters come from the same component so the base components are the same
+    if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
+    {
+        // Go through each KVP and release memory for value if allocated from heap
+        for (int32 i = 0; i < num_elements; ++i)
+        {
+            // Next check if it is a value type that allocated memory
+            PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[i].key);
+            if (kvptype == PVMI_KVPTYPE_VALUE || kvptype == PVMI_KVPTYPE_UNKNOWN)
+            {
+                PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[i].key);
+                if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFSMRTSPUnicastNode::releaseParameters() Valtype not specified in key string"));
+                    return PVMFErrArgument;
+                }
+
+                if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.pChar_value);
+                    aParameters[i].value.pChar_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_WCHARPTR && aParameters[i].value.pWChar_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.pWChar_value);
+                    aParameters[i].value.pWChar_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.pChar_value);
+                    aParameters[i].value.pChar_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_KSV && aParameters[i].value.key_specific_value != NULL)
+                {
+                    oscl_free(aParameters[i].value.key_specific_value);
+                    aParameters[i].value.key_specific_value = NULL;
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_INT32 && aParameters[i].value.key_specific_value != NULL)
+                {
+                    range_int32* ri32 = (range_int32*)aParameters[i].value.key_specific_value;
+                    aParameters[i].value.key_specific_value = NULL;
+                    oscl_free(ri32);
+                }
+                else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_UINT32 && aParameters[i].value.key_specific_value != NULL)
+                {
+                    range_uint32* rui32 = (range_uint32*)aParameters[i].value.key_specific_value;
+                    aParameters[i].value.key_specific_value = NULL;
+                    oscl_free(rui32);
+                }
+            }
+        }
+
+        oscl_free(aParameters[0].key);
+
+        // Free memory for the parameter list
+        oscl_free(aParameters);
+        aParameters = NULL;
+    }
+    else
+    {
+        // Unknown key string
+        return PVMFErrArgument;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMRTSPUnicastNode::releaseParameters() Out"));
+    return PVMFSuccess;
+}
+
+void PVMFSMRTSPUnicastNode::createContext(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // not supported
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+void PVMFSMRTSPUnicastNode::setContextParameters(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext,
+        PvmiKvp* aParameters,
+        int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+    // not supported
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+void PVMFSMRTSPUnicastNode::DeleteContext(PvmiMIOSession aSession,
+        PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    // not supported
+    OSCL_LEAVE(PVMFErrNotSupported);
+}
+
+void PVMFSMRTSPUnicastNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+        int num_elements, PvmiKvp* &aRet_kvp)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMRTSPUnicastNode::setParametersSync() In"));
+
+
+    // Go through each parameter
+    for (int paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+        {
+            // First component should be "x-pvmf" and there must
+            // be at least two components to go past x-pvmf
+            aRet_kvp = &aParameters[paramind];
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
+            return;
+        }
+
+        // Retrieve the second component from the key string
+        pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
+
+        // First check if it is key string for the streaming manager
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
+        {
+            if (compcount == 3)
+            {
+                pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
+                uint i;
+                for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
+                {
+                    if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
+                    {
+                        break;
+                    }
+                }
+
+                if (StreamingManagerConfig_NumBaseKeys == i)
+                {
+                    // invalid third component
+                    aRet_kvp = &aParameters[paramind];
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
+                    return;
+                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                                (0, "PVMFSMRTSPUnicastNode::setParametersSync() key str %s", compstr));
+                // Verify and set the passed-in setting
+                PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], true);
+                if (retval != PVMFSuccess)
+                {
+                    aRet_kvp = &aParameters[paramind];
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFSMRTSPUnicastNode::setParametersSync() Setting "
+                                     "parameter %d failed", paramind));
+                    return;
+                }
+            }
+            else
+            {
+                // Do not support more than 3 components right now
+                aRet_kvp = &aParameters[paramind];
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
+                return;
+            }
+        }
+        else
+        {
+            // Unknown key string
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVMFSMRTSPUnicastNode::setParametersSync() Unsupported key"));
+            return;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMRTSPUnicastNode::setParametersSync() Out"));
+}
+
+
+
+uint32 PVMFSMRTSPUnicastNode::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    OSCL_UNUSED_ARG(aSession);
+    return 0;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::verifyParametersSync(PvmiMIOSession aSession,
+        PvmiKvp* aParameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMRTSPUnicastNode::verifyParametersSync() In"));
+
+    if (aParameters == NULL || num_elements < 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PVMFSMRTSPUnicastNode::verifyParametersSync() Passed in parameter invalid"));
+        return PVMFErrArgument;
+    }
+
+    // Go through each parameter and verify
+    for (int32 paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Count the number of components and parameters in the key
+        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
+        {
+            // First component should be "x-pvmf" and there must
+            // be at least two components to go past x-pvmf
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::verifyParametersSync() Unsupported key"));
+            return PVMFErrArgument;
+        }
+
+        // Retrieve the second component from the key string
+        pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
+
+        // First check if it is key string for this node
+        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0) && (compcount == 3))
+        {
+            pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
+            uint i;
+            for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
+            {
+                if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
+                {
+                    break;
+                }
+            }
+
+            if (StreamingManagerConfig_NumBaseKeys == i)
+            {
+                return PVMFErrArgument;
+            }
+
+            // Verify the passed-in player setting
+            PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], false);
+            if (retval != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCapConfigVerifyParameters() Verifying parameter %d failed", paramind));
+                return retval;
+            }
+        }
+        else
+        {
+            // Unknown key string
+            return PVMFErrArgument;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCapConfigVerifyParameters() Out"));
+    return PVMFSuccess;
+}
+
+
+
+PVMFStatus PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() In index[%d]", index));
+
+    // Determine the valtype
+    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
+    if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
+                               "Valtype in key string unknown"));
+        return PVMFErrArgument;
+    }
+
+    // Verify the valtype
+    if (keyvaltype != StreamingManagerConfig_BaseKeys[index].iValueType)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
+                               "Valtype does not match for key"));
+        return PVMFErrArgument;
+    }
+
+    switch (index)
+    {
+        case BASEKEY_DELAY:
+        {
+            uint32  rebuffThreshold = 0;
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            OSCL_ASSERT(iJitterBufferNodeContainer);
+            if (!iJitterBufferNodeContainer)
+                return PVMFFailure;
+            PVMFJitterBufferExtensionInterface* jbExtIntf = NULL;
+            if (iJitterBufferNodeContainer)
+                jbExtIntf = (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+            if (jbExtIntf)
+                jbExtIntf->getJitterBufferRebufferingThresholdInMilliSeconds(rebuffThreshold);
+            if (!jbExtIntf)
+                return PVMFFailure;
+            // Validate
+            if ((aParameter.value.uint32_value < MIN_JITTER_BUFFER_DURATION_IN_MS) ||
+                    (aParameter.value.uint32_value > MAX_JITTER_BUFFER_DURATION_IN_MS) ||
+                    (aParameter.value.uint32_value < rebuffThreshold))
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
+                                       "Trying to set delay to 0"));
+                return PVMFErrArgument;
+            }
+            if (set)
+            {
+                // save value locally
+                setJitterBufferDurationInMilliSeconds(aParameter.value.uint32_value);
+                // pass the value on to the jitter buffer node
+                jbExtIntf->setJitterBufferDurationInMilliSeconds(aParameter.value.uint32_value);
+            }
+        }
+        break;
+        case BASEKEY_REBUFFERING_THRESHOLD:
+        {
+            uint32 jbDuration = 0;
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            OSCL_ASSERT(iJitterBufferNodeContainer);
+            if (!iJitterBufferNodeContainer)
+                return PVMFFailure;
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+            jbExtIntf->getJitterBufferDurationInMilliSeconds(jbDuration);
+            // Validate
+            if (aParameter.value.uint32_value >= jbDuration)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
+                                       "Trying to set rebuffering threshold greater than equal to jitter buffer duration"));
+                return PVMFErrArgument;
+            }
+            if (set)
+            {
+                // pass the value on to the jitter buffer node
+                jbExtIntf->setJitterBufferRebufferingThresholdInMilliSeconds(aParameter.value.uint32_value);
+            }
+        }
+        break;
+        case BASEKEY_JITTERBUFFER_NUMRESIZE:
+        {
+            if (set)
+            {
+                // retrieve and update
+                uint32 numResize, resizeSize;
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
+                jbExtIntf->SetSharedBufferResizeParams(aParameter.value.uint32_value, resizeSize);
+            }
+        }
+        break;
+        case BASEKEY_JITTERBUFFER_RESIZESIZE:
+        {
+            if (set)
+            {
+                // retrieve and update
+                uint32 numResize, resizeSize;
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
+                jbExtIntf->SetSharedBufferResizeParams(numResize, aParameter.value.uint32_value);
+            }
+        }
+        break;
+        case BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION:
+        {
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            OSCL_ASSERT(iJitterBufferNodeContainer);
+            if (!iJitterBufferNodeContainer)
+                return PVMFFailure;
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+            OSCL_ASSERT(jbExtIntf);
+            if (!jbExtIntf)
+                return PVMFFailure;
+            //validate input value...
+            if (aParameter.value.uint32_value > DEFAULT_MAX_INACTIVITY_DURATION_IN_MS)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() "
+                                       "Trying to set max inactivity duration greater than allowed inactivity duration"));
+                return PVMFErrArgument;
+            }
+            if (set)
+            {
+                //update the maximum alloyed delay for the incoming msg at input port of JB node
+                jbExtIntf->setMaxInactivityDurationForMediaInMs(aParameter.value.uint32_value);
+            }
+        }
+        break;
+        case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
+        {
+            if (set)
+            {
+                // user agent update
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer = NULL;
+                iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                OSCL_wHeapString<OsclMemAllocator> userAgent;
+                OSCL_wHeapString<OsclMemAllocator> dummy;
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+
+                    userAgent = aParameter.value.pWChar_value;
+                    rtspExtIntf->SetClientParameters(userAgent, dummy, dummy);
+                }
+                // save user-agent kvp for cpm
+                if (iCPM)
+                {
+                    PVMFStatus status = iCPMKvpStore.addKVPString(aParameter.key, userAgent);
+                    if (status != PVMFSuccess) return status;
+                }
+
+            }
+        }
+        break;
+
+        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
+        {
+            if (set)
+            {
+                // keep-alive during play update
+                /* As of now just RTSP node supports an external config of keep-alive during play */
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+                    rtspExtIntf->SetKeepAliveMethod_keep_alive_in_play(aParameter.value.bool_value);
+                }
+            }
+        }
+        break;
+
+        case BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT:
+        {
+            if (set)
+            {
+                PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT "));
+                // RTSP response waiting time out
+                PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                if (iSessionControllerNodeContainer != NULL)
+                {
+                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                        (PVRTSPEngineNodeExtensionInterface*)
+                        (iSessionControllerNodeContainer->iExtensions[0]);
+                    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT rtspExtIntf%x", rtspExtIntf));
+                    rtspExtIntf->SetRTSPTimeOut(aParameter.value.uint32_value);
+                }
+                PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::VerifyAndSetConfigParameter() BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT Done"));
+            }
+        }
+        break;
+
+        case BASEKEY_DISABLE_FIREWALL_PACKETS:
+        {
+            if (set)
+            {
+                PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                    getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                OSCL_ASSERT(iJitterBufferNodeContainer);
+                if (!iJitterBufferNodeContainer)
+                    return PVMFFailure;
+                PVMFJitterBufferExtensionInterface* jbExtIntf =
+                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
+                OSCL_ASSERT(jbExtIntf);
+                if (!jbExtIntf)
+                    return PVMFFailure;
+                jbExtIntf->DisableFireWallPackets();
+            }
+        }
+        break;
+
+        default:
+            return PVMFErrNotSupported;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVMFSMRTSPUnicastNode::VerifyAndSetPlayerParameter() Out"));
+
+    return PVMFSuccess;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Implemenation of PVMFDataSourceInitializationExtensionInterface interface
+///////////////////////////////////////////////////////////////////////////////
+
+PVMFStatus PVMFSMRTSPUnicastNode::SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData)
+{
+    //To set proxy server info with the session controller node
+    if (aSourceData != NULL)
+    {
+        PVInterface* pvInterface = OSCL_STATIC_CAST(PVInterface*, aSourceData);
+        PVInterface* sourceDataContext = NULL;
+        PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
+        if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
+        {
+            if (sourceDataContext)
+            {
+                PVInterface* streamingDataContext = NULL;
+                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
+
+                if (sourceDataContext->queryInterface(streamingContextUuid, streamingDataContext))
+                {
+                    if (streamingDataContext)
+                    {
+                        PVMFSourceContextDataStreaming* sContext =
+                            OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, streamingDataContext);
+                        if (sContext->iProxyName.get_size() > 0)
+                        {
+                            PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer = NULL;
+                            iSessionControllerNodeContainer = getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+                            if (iSessionControllerNodeContainer)
+                            {
+                                PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+                                    (PVRTSPEngineNodeExtensionInterface*)(iSessionControllerNodeContainer->iExtensions[0]);
+                                if (rtspExtIntf)
+                                {	//the proxyname doesn't need to be unicode
+                                    OsclMemAllocator alloc;
+                                    char *buf = (char*)alloc.allocate(sContext->iProxyName.get_size() + 1);
+                                    if (!buf)
+                                        return PVMFErrNoMemory;
+                                    uint32 size = oscl_UnicodeToUTF8(sContext->iProxyName.get_cstr(), sContext->iProxyName.get_size(), buf, sContext->iProxyName.get_size() + 1);
+                                    if (size == 0)
+                                    {
+                                        alloc.deallocate(buf);
+                                        return PVMFErrNoMemory;
+                                    }
+
+                                    OSCL_FastString myProxyName(buf, size);
+
+                                    rtspExtIntf->SetRtspProxy(myProxyName, sContext->iProxyPort);
+                                    alloc.deallocate(buf);
+                                }
+                            }
+                        }
+                    }
+                }
+
+            }
+        }
+    }
+    //to check if we should use CPM plugin?
+    if (aSourceData)
+    {
+        PVInterface* pvInterface =
+            OSCL_STATIC_CAST(PVInterface*, aSourceData);
+        PVInterface* streamingDataSrc = NULL;
+        PVUuid streamingDataSrcUuid(PVMF_STREAMING_DATASOURCE_UUID);
+        if (pvInterface->queryInterface(streamingDataSrcUuid, streamingDataSrc))
+        {
+            PVMFStreamingDataSource* opaqueData =
+                OSCL_STATIC_CAST(PVMFStreamingDataSource*, streamingDataSrc);
+            iPreviewMode = opaqueData->iPreviewMode;
+            iUseCPMPluginRegistry = opaqueData->iUseCPMPluginRegistry;
+            iCPMSourceData.iPreviewMode = iPreviewMode;
+            iCPMSourceData.iIntent = opaqueData->iIntent;
+        }
+        else
+        {
+            PVInterface* sourceDataContext = NULL;
+            PVInterface* commonDataContext = NULL;
+            PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
+            PVUuid commonContextUuid(PVMF_SOURCE_CONTEXT_DATA_COMMON_UUID);
+            if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
+            {
+                if (sourceDataContext->queryInterface(commonContextUuid, commonDataContext))
+                {
+                    PVMFSourceContextDataCommon* cContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextDataCommon*, commonDataContext);
+                    iPreviewMode = cContext->iPreviewMode;
+                    iUseCPMPluginRegistry = cContext->iUseCPMPluginRegistry;
+                    PVMFSourceContextData* sContext =
+                        OSCL_STATIC_CAST(PVMFSourceContextData*, sourceDataContext);
+                    iSourceContextData = *sContext;
+                    iSourceContextDataValid = true;
+                }
+            }
+        }
+    }
+    /*
+     * If a CPM flag is provided in the source data, then
+     * create a CPM object here...
+     */
+    if (iUseCPMPluginRegistry)
+    {
+        //cleanup any prior instance
+        if (iCPM)
+        {
+            iCPM->ThreadLogoff();
+            PVMFCPMFactory::DestroyContentPolicyManager(iCPM);
+            iCPM = NULL;
+        }
+        iCPM = PVMFCPMFactory::CreateContentPolicyManager(*this);
+        iCPM->ThreadLogon();
+    }
+
+    //to set the sessionsource info and configure session controller node [RTSP client], with the session type
+    if ((aSourceFormat == PVMF_MIME_DATA_SOURCE_RTSP_URL))
+    {
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return PVMFFailure;
+        }
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+
+        iSessionSourceInfo->_sessionType = aSourceFormat;
+        iSessionSourceInfo->_sessionURL  = aSourceURL;
+        rtspExtIntf->SetStreamingType(PVRTSP_3GPP_UDP);
+        return (rtspExtIntf->SetSessionURL(iSessionSourceInfo->_sessionURL));
+    }
+    else if (aSourceFormat == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+    {
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return PVMFFailure;
+        }
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+        // right now, PVMF_MIME_DATA_SOURCE_SDP_FILE => non-interleaved RTSP
+        rtspExtIntf->SetStreamingType(PVRTSP_3GPP_UDP);
+        iSessionSourceInfo->_sessionType = aSourceFormat;
+        iSessionSourceInfo->_sessionURL  = aSourceURL;
+        iSessionSourceInfo->_sourceData = aSourceData;
+
+        return PVMFSuccess;
+    }
+    else
+        return PVMFErrNotSupported;
+
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
+{
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return PVMFFailure;
+    }
+
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    jbExtIntf->setClientPlayBackClock(aClientClock);
+
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return PVMFFailure;
+    }
+
+    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+        (PVMFMediaLayerNodeExtensionInterface*)
+        (iMediaLayerNodeContainer->iExtensions[0]);
+
+    mlExtIntf->setClientPlayBackClock(aClientClock);
+
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
+{
+    OSCL_UNUSED_ARG(aClientClock);
+    return PVMFErrNotSupported;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of PVMFTrackSelectionExtensionInterface
+///////////////////////////////////////////////////////////////////////////////
+PVMFStatus PVMFSMRTSPUnicastNode::GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo)
+{
+    SDPInfo* sdpInfo = iSdpInfo.GetRep();
+
+    /* Get SDP Session Info */
+    sessionDescription* sessionInfo = sdpInfo->getSessionInfo();
+
+    RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
+
+    int32 sessionStartTime = 0, sessionStopTime = 0;
+
+    sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
+
+    int32 duration_msec = (sessionStopTime - sessionStartTime);
+
+    uint64 duration64;
+    Oscl_Int64_Utils::set_uint64(duration64, 0, (uint32)duration_msec);
+
+    if (sessionRange->end_is_set == true)
+    {
+        aInfo.setDurationValue(duration64);
+        aInfo.setDurationTimeScale(1000);
+    }
+    else
+    {
+        aInfo.SetDurationAvailable(false);
+    }
+
+    aInfo.setSeekableFlag((!(sessionInfo->getRandomAccessDenied())));
+
+    int32 numTracks = sdpInfo->getNumMediaObjects();
+
+    SDPAltGroupType sdpAltGroupType = sessionInfo->getSDPAltGroupType();
+
+    PVMF_TRACK_INFO_TRACK_ALTERNATE_TYPE iAltType = PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED;
+
+    if (sdpAltGroupType == SDP_ALT_GROUP_LANGUAGE)
+    {
+        iAltType = PVMF_TRACK_ALTERNATE_TYPE_LANGUAGE;
+    }
+    else if (sdpAltGroupType == SDP_ALT_GROUP_BANDWIDTH)
+    {
+        iAltType = PVMF_TRACK_ALTERNATE_TYPE_BANDWIDTH;
+    }
+
+    for (int32 i = 0; i < numTracks; i++)
+    {
+        /*
+         * Get the vector of mediaInfo as there can
+         * alternates for each track
+         */
+        Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
+            sdpInfo->getMediaInfo(i);
+
+        uint32 minfoVecLen = mediaInfoVec.size();
+
+        for (uint32 j = 0; j < minfoVecLen; j++)
+        {
+            mediaInfo* mInfo = mediaInfoVec[j];
+
+            if (mInfo == NULL)
+            {
+                return PVMFFailure;
+            }
+
+            RtspRangeType *mediaRange = mInfo->getRtspRange();
+
+            int32 mediaStartTime = 0, mediaStopTime = 0;
+
+            mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
+            int32 mediaDuration_ms = mediaStopTime - mediaStartTime;
+            uint64 mediaDuration64;
+            Oscl_Int64_Utils::set_uint64(mediaDuration64, 0, (uint32)mediaDuration_ms);
+
+            PVMFTrackInfo trackInfo;
+
+            Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
+            payloadVector = mInfo->getPayloadSpecificInfoVector();
+
+            if (payloadVector.size() == 0)
+            {
+                return false;
+            }
+            /*
+             * There can be multiple payloads per media segment.
+             * We only support one for now, so
+             * use just the first payload
+             */
+            PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
+
+            // set config for later
+            int32 configSize = payloadInfo->configSize;
+            OsclAny* config = payloadInfo->configHeader.GetRep();
+
+            OSCL_StackString<256> mimeString;
+            const char* mimeType = mInfo->getMIMEType();
+            mimeString += mimeType;
+            trackInfo.setTrackMimeType(mimeString);
+
+            uint32 trackID = mInfo->getMediaInfoID();
+
+            trackInfo.setTrackID(trackID);
+            trackInfo.setPortTag(trackID);
+
+            trackInfo.setTrackBitRate(mInfo->getBitrate());
+
+            if (mediaRange->end_is_set == true)
+            {
+                trackInfo.setTrackDurationValue(mediaDuration64);
+            }
+            else
+            {
+                trackInfo.SetDurationAvailable(false);
+            }
+
+            if ((configSize > 0) && (config != NULL))
+            {
+                OsclMemAllocDestructDealloc<uint8> my_alloc;
+                OsclRefCounter* my_refcnt;
+                uint aligned_refcnt_size =
+                    oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+
+                uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
+                if (!my_ptr)
+                    return PVMFFailure;
+
+                my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
+                my_ptr += aligned_refcnt_size;
+
+                OsclMemoryFragment memfrag;
+                memfrag.len = (uint32)configSize;
+                memfrag.ptr = my_ptr;
+
+                oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
+
+                OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
+                trackInfo.setTrackConfigInfo(tmpRefcntMemFrag);
+            }
+
+            int32 dependsOnTrackID = mInfo->getDependsOnTrackID();
+
+            if (dependsOnTrackID != -1)
+            {
+                trackInfo.setDependsOn();
+                mediaInfo* baseMediaInfo = sdpInfo->getMediaInfoBasedOnDependsOnID(dependsOnTrackID);
+                if (baseMediaInfo == NULL)
+                {
+                    return PVMFFailure;
+                }
+                trackInfo.addDependsOnTrackID(baseMediaInfo->getMediaInfoID());
+            }
+
+            if (iAltType != PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED)
+            {
+                /* Expose alternate track ids */
+                trackInfo.setTrackAlternates(iAltType);
+                for (uint32 k = 0; k < minfoVecLen; k++)
+                {
+                    mediaInfo* mInfo = mediaInfoVec[k];
+                    if (mInfo == NULL)
+                    {
+                        return PVMFFailure;
+                    }
+                    uint32 altID = mInfo->getMediaInfoID();
+                    if (altID != trackID)
+                    {
+                        trackInfo.addAlternateTrackID((int32)altID);
+                    }
+                }
+            }
+            aInfo.addTrackInfo(trackInfo);
+        }
+    }
+    iCompleteMediaPresetationInfo = aInfo;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::SelectTracks(PVMFMediaPresentationInfo& aInfo)
+{
+    SDPInfo* sdpInfo = iSdpInfo.GetRep();
+    if (sdpInfo == NULL)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SelectTracks - SDP Not Available"));
+        return PVMFErrArgument;
+    }
+
+    int32 numTracks = aInfo.getNumTracks();
+
+    for (int32 i = 0; i < numTracks; i++)
+    {
+        PVMFTrackInfo* trackInfo = aInfo.getTrackInfo(i);
+
+        uint32 trackID = trackInfo->getTrackID();
+
+        mediaInfo* mInfo =
+            sdpInfo->getMediaInfoBasedOnID(trackID);
+
+        if (mInfo == NULL)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SelectTracks - Invalid SDP TrackID"));
+            return PVMFErrArgument;
+        }
+
+        mInfo->setSelect();
+
+        /* Set selected field in meta info */
+        Oscl_Vector<PVMFSMTrackMetaDataInfo, OsclMemAllocator>::iterator it;
+        for (it = iMetaDataInfo->iTrackMetaDataInfoVec.begin(); it != iMetaDataInfo->iTrackMetaDataInfoVec.end(); it++)
+        {
+            if (it->iTrackID == trackID)
+            {
+                it->iTrackSelected = true;
+            }
+        }
+    }
+    iSelectedMediaPresetationInfo = aInfo;
+    return PVMFSuccess;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of PVMFMetadataExtensionInterface
+///////////////////////////////////////////////////////////////////////////////
+uint32 PVMFSMRTSPUnicastNode::GetNumMetadataKeys(char* aQueryKeyString)
+{
+    //Metadata is avaialable in three forms
+    //1. Metadata common to streaming of all type of payloads and FF specific metadata
+    //2. Streaming specific metadata
+    //3. CPM metadata
+    //First two types are avaiable in iAvailableMetaDatakeys vector
+    //Third type can be had from metadataextension interface
+    //base class considers count of all of these
+    return PVMFSMFSPBaseNode::GetNumMetadataKeysBase(aQueryKeyString);
+}
+
+uint32 PVMFSMRTSPUnicastNode::GetNumMetadataValues(PVMFMetadataList& aKeyList)
+{
+    //Metadata is avaialable in three forms
+    //1. Metadata common to streaming of all type of payloads and FF specific metadata
+    //2. Streaming specific metadata
+    //3. CPM metadata
+    //First two types are avaiable in iAvailableMetaDatakeys vector
+    //Third type can be had from metadataextension interface
+    //Base class considers count of all of these
+    return PVMFSMFSPBaseNode::GetNumMetadataValuesBase(aKeyList);
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::DoGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    return DoGetMetadataKeysBase(aCmd);
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::GetRTSPPluginSpecificValues(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMFMetadataList* keylistptr = NULL;
+    Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
+    uint32 starting_index;
+    int32 max_entries;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
+
+    // Check the parameters
+    if (keylistptr == NULL || valuelistptr == NULL)
+    {
+        return PVMFErrArgument;
+    }
+
+    uint32 numkeys = keylistptr->size();
+
+    if (numkeys <= 0 || max_entries == 0)
+    {
+        // Don't do anything
+        return PVMFErrArgument;
+    }
+
+    uint32 numvalentries = 0;
+    int32 numentriesadded = 0;
+
+    for (uint32 lcv = 0; lcv < numkeys; lcv++)
+    {
+        PvmiKvp KeyVal;
+        KeyVal.key = NULL;
+        KeyVal.value.pWChar_value = NULL;
+        KeyVal.value.pChar_value = NULL;
+
+        if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY) != NULL)
+        {
+            // Increment the counter for the number of values found so far
+            ++numvalentries;
+            // Create a value entry if past the starting index
+            if (numvalentries > starting_index)
+            {
+                PVMFStatus retval = PVMFCreateKVPUtils::CreateKVPForBoolValue(KeyVal,
+                                    PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY,
+                                    iPauseDenied);
+                if (retval != PVMFSuccess && retval != PVMFErrArgument)
+                {
+                    break;
+                }
+            }
+        }
+
+        /* Check if the max number of value entries were added */
+        if (max_entries > 0 && numentriesadded >= max_entries)
+        {
+            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+            return PVMFSuccess;
+        }
+
+        // Add the KVP to the list if the key string was created
+        if (KeyVal.key != NULL)
+        {
+            if (PVMFSuccess != PushKVPToMetadataValueList(valuelistptr, KeyVal))
+            {
+                switch (GetValTypeFromKeyString(KeyVal.key))
+                {
+                    case PVMI_KVPVALTYPE_CHARPTR:
+                        if (KeyVal.value.pChar_value != NULL)
+                        {
+                            OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
+                            KeyVal.value.pChar_value = NULL;
+                        }
+                        break;
+
+                    default:
+                        // Add more case statements if other value types are returned
+                        break;
+                }
+
+                OSCL_ARRAY_DELETE(KeyVal.key);
+                KeyVal.key = NULL;
+            }
+            else
+            {
+                // Increment the counter for number of value entries added to the list
+                ++numentriesadded;
+            }
+
+            // Check if the max number of value entries were added
+            if (max_entries > 0 && numentriesadded >= max_entries)
+            {
+                // Maximum number of values added so break out of the loop
+                break;
+            }
+        }
+    }
+
+    iNoOfValuesIteratedForValueVect = numvalentries;
+    iNoOfValuesPushedInValueVect = numentriesadded;
+
+    iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::DoGetMetadataValues(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    iNoOfValuesIteratedForValueVect = 0;
+    iNoOfValuesPushedInValueVect = 0;
+    PVMFStatus retval = GetRTSPPluginSpecificValues(aCmd);
+    if (PVMFSuccess != retval)
+        return retval;
+    return DoGetMetadataValuesBase(aCmd);
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
+        uint32 aStartingKeyIndex,
+        uint32 aEndKeyIndex)
+{
+    //no allocation for any keys took in derived class so just calling base class release functions
+    return ReleaseNodeMetadataKeysBase(aKeyList, aStartingKeyIndex, aEndKeyIndex);
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+        uint32 aStartingValueIndex,
+        uint32 aEndValueIndex)
+{
+    //no allocation for any value in kvp took in derived class so just calling base class release functions
+    return ReleaseNodeMetadataValuesBase(aValueList, aStartingValueIndex, aEndValueIndex);
+}
+
+void PVMFSMRTSPUnicastNode::DoSetDataSourcePosition(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMFSPBaseNodeCommand::DoSetDataSourcePosition - In"));
+
+    iActualRepositionStartNPTInMSPtr = NULL;
+    iActualMediaDataTSPtr = NULL;
+    iPVMFDataSourcePositionParamsPtr = NULL;
+    iJumpToIFrame = false;
+    uint32 streamID = 0;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(iRepositionRequestedStartNPTInMS,
+                                         iActualRepositionStartNPTInMSPtr,
+                                         iActualMediaDataTSPtr,
+                                         iJumpToIFrame,
+                                         streamID);
+
+    PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFSMFSPBaseNodeCommand::DoSetDataSourcePosition - TargetNPT = %d", iRepositionRequestedStartNPTInMS));
+
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    *iActualRepositionStartNPTInMSPtr = 0;
+    *iActualMediaDataTSPtr = 0;
+
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+            (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+    {
+        if (iInterfaceState == EPVMFNodePrepared)
+        {
+            iStreamID = streamID;
+            jbExtIntf->SendBOSMessage(iStreamID);
+
+            bool oRandAccessDenied = true;
+
+            sessionDescription* sessionInfo =
+                iSdpInfo->getSessionInfo();
+            oRandAccessDenied = sessionInfo->getRandomAccessDenied();
+
+            if ((oRandAccessDenied == true) ||
+                    (iSessionStopTimeAvailable == false) ||
+                    (((int32)iRepositionRequestedStartNPTInMS < (int32)iSessionStartTime) ||
+                     ((int32)iRepositionRequestedStartNPTInMS >= (int32)iSessionStopTime)))
+            {
+                if (iRepositionRequestedStartNPTInMS == 0)
+                {
+                    /* Implies that we are repositioning to zero, which is not a invalid request
+                     * so dont send PVMFErrNotSupported
+                     */
+                }
+                else
+                {
+                    /*
+                     * Implies an open ended session or invalid request time
+                     * - no pause or reposition
+                     */
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+                    return;
+                }
+            }
+
+            /*
+             * SetDataSource from a prepared state could mean two things:
+             *	- In Play-Stop-Play usecase engine does a SetDataSourcePosition
+             *    to get the start media TS to set its playback clock
+             *  - Engine is trying to do a play with a non-zero start offset
+             */
+            if (iRepositionRequestedStartNPTInMS < iSessionStopTime && iRepositionRequestedStartNPTInMS != iSessionStartTime)
+            {
+                // we need to use part of the logic of repositioning to start
+                // streaming from a non-zero offset. Enabled only for 3gpp streaming
+                iRepositioning = true;
+                /* Start the nodes */
+                PVMFStatus status = DoRepositioningStart3GPPStreaming();
+                if (PVMFSuccess != status)
+                {
+                    CommandComplete(iInputCommands, aCmd, status);
+                    return;
+                }
+
+                MoveCmdToCurrentQueue(aCmd);
+                return;
+            }
+
+            GetActualMediaTSAfterSeek();
+            PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::SetDataSourcePosition() - CmdComplete"));
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        }
+        else if ((iInterfaceState == EPVMFNodeStarted) || (iInterfaceState == EPVMFNodePaused))
+        {
+            bool oRandAccessDenied = true;
+
+            sessionDescription* sessionInfo =
+                iSdpInfo->getSessionInfo();
+            oRandAccessDenied = sessionInfo->getRandomAccessDenied();
+
+
+            if (!CanPerformRepositioning(oRandAccessDenied))
+            {
+                CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+                return;
+            }
+
+            iStreamID = streamID;
+            jbExtIntf->SendBOSMessage(iStreamID);
+
+            iRepositioning = true;
+
+            /* Put the jitter buffer into a state of transition */
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (iJitterBufferNodeContainer == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)
+                (iJitterBufferNodeContainer->iExtensions[0]);
+            jbExtIntf->PrepareForRepositioning();
+
+            /* If node is running, pause first */
+            if (iInterfaceState == EPVMFNodeStarted)
+            {
+                if (!DoRepositioningPause3GPPStreaming())
+                {
+                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
+                }
+            }
+            /* If already paused do not pause */
+            else if (iInterfaceState == EPVMFNodePaused)
+            {
+                PVMFStatus status = DoRepositioningStart3GPPStreaming();
+                if (PVMFSuccess != status)
+                {
+                    CommandComplete(iInputCommands, aCmd, status);
+                }
+            }
+            MoveCmdToCurrentQueue(aCmd);
+        }
+        else
+        {
+            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+            return;
+        }
+    }
+    else
+    {
+        PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::SetDataSourcePosition() - Cmd Failed - PVMFErrArgument"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+        return;
+    }
+    return;
+}
+
+
+
+void PVMFSMRTSPUnicastNode::DoQueryDataSourcePosition(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryDataSourcePosition - In"));
+
+    PVMFTimestamp repositionrequestedstartnptinms = 0;
+    PVMFTimestamp* actualrepositionstartnptinmsptr = NULL;
+    bool seektosyncpoint = false;
+
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(repositionrequestedstartnptinms,
+                                         actualrepositionstartnptinmsptr,
+                                         seektosyncpoint);
+
+    if (actualrepositionstartnptinmsptr == NULL)
+    {
+        CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
+        return;
+    }
+    *actualrepositionstartnptinmsptr = 0;
+
+    // This query is not supported for streaming sessions
+    CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::DoQueryDataSourcePosition - Out"));
+    return;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+        PVMFTimestamp aActualNPT,
+        PVMFTimestamp aActualMediaDataTS,
+        PVMFTimestamp& aSkipTimeStamp,
+        PVMFTimestamp& aStartNPT)
+{
+    //for RTSP streaming we always start playback from aActualNPT
+    //by defintion aActualMediaDataTS is the timestamp that corresponds
+    //to aActualNPT
+    OSCL_UNUSED_ARG(aTargetNPT);
+    OSCL_UNUSED_ARG(aSkipTimeStamp);
+    OSCL_UNUSED_ARG(aStartNPT);
+    aSkipTimeStamp = aActualMediaDataTS;
+    aStartNPT = aActualNPT;
+    return PVMFSuccess;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implementation of the virtual function declared in PVMFNodeCmdStatusObserver
+///////////////////////////////////////////////////////////////////////////////
+void PVMFSMRTSPUnicastNode::NodeCommandCompleted(const PVMFCmdResp& aResponse)
+{
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::NodeCommandCompleted"));
+    bool performErrHandling = false;
+    HandleChildNodeCommandCompletion(aResponse, performErrHandling);
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::NodeCommandCompleted - performErrHandling[%d]", performErrHandling));
+
+    if (performErrHandling == true)
+    {
+        HandleError(aResponse);
+    }
+
+    return;
+}
+
+/**
+retval: true - perform error handling based on response (if needed)
+retval: false - do not perform error handling.Concrete implemenbtation of the FSP will take care of error handling
+*/
+void PVMFSMRTSPUnicastNode::HandleChildNodeCommandCompletion(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
+{
+    aPerformErrHandling = true;
+
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode:HandleChildNodeCommandCompletion: %d", cmdContextData->cmd));
+
+    if ((cmdContextData->cmd >=
+            PVMF_SM_FSP_SOCKET_NODE_COMMAND_START) &&
+            (cmdContextData->cmd <
+             PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START))
+
+    {
+        HandleSocketNodeCommandCompleted(aResponse, aPerformErrHandling);
+    }
+    else if ((cmdContextData->cmd >=
+              PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_COMMAND_START) &&
+             (cmdContextData->cmd <
+              PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START))
+
+    {
+        HandleRTSPSessionControllerCommandCompleted(aResponse, aPerformErrHandling);
+    }
+    else if ((cmdContextData->cmd >=
+              PVMF_SM_FSP_JITTER_BUFFER_CONTROLLER_COMMAND_START) &&
+             (cmdContextData->cmd <
+              PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START))
+
+    {
+        HandleJitterBufferCommandCompleted(aResponse, aPerformErrHandling);
+    }
+    else if ((cmdContextData->cmd >=
+              PVMF_SM_FSP_MEDIA_LAYER_COMMAND_START) &&
+             (cmdContextData->cmd <
+              PVMF_SM_FSP_HTTP_SESSION_CONTROLLER_COMMAND_START))
+
+    {
+        HandleMediaLayerCommandCompleted(aResponse, aPerformErrHandling);
+    }
+    else
+    {
+        OSCL_ASSERT(false);
+    }
+
+}
+
+void PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
+{
+    aPerformErrHandling = false;
+
+    PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
+    if (iSocketNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+    cmdContextData->oFree = true;
+
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted In - cmd [%d] iSocketNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iSocketNodeContainer->iNodeCmdState, iInterfaceState));
+
+    //RTSPUNICAST plugin uses sync version of QueryInterface to get xtension interface of its various child nodes
+    //Also RTSPUNICAST plugin doesn t call QueryUUID on child node.
+    //So, command completion of async version of QueryUUID and QueryInterface from child node not expected.
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_SOCKET_NODE_QUERY_UUID);
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_SOCKET_NODE_QUERY_INTERFACE);
+
+
+
+    if (iSocketNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+    {
+        if (cmdContextData->cmd == PVMF_SM_FSP_SOCKET_NODE_REQUEST_PORT)
+        {
+            //This is last of the request ports
+            OSCL_ASSERT(iSocketNodeContainer->iNumRequestPortsPending > 0);
+            if (--iSocketNodeContainer->iNumRequestPortsPending == 0)
+            {
+                iSocketNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            }
+        }
+        else
+        {
+            iSocketNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+    }
+    else if (iSocketNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+    {
+        if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
+        {
+            iSocketNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted cmd completion for cmd other than cancel during cancellation"));
+
+            //if cancel is pending and if the parent cmd is not cancel then this is
+            //is most likely the cmd that is being cancelled.
+            //we ignore cmd completes from child nodes if cancel is pending
+            //we simply wait on cancel complete and cancel the pending cmd
+            return;
+        }
+    }
+    else if (iSocketNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
+    {
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted Nodecontainer state IDLE already!!!!!"));
+        /*
+         * This is to handle a usecase where a node reports cmd complete for cancelall first
+         * and then reports cmd complete on the cmd that was meant to be cancelled.
+         * There are two possible scenarios that could arise based on this:
+         * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
+         * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
+         * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
+         * ii) SM node is still waiting on some other child nodes to complete cancelall.
+         * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
+         * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
+         * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
+         * Or this is the case of node reporting cmd complete multiple times for a cmd, which
+         * also can be ignored
+         */
+        return;
+    }
+
+    if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
+    {
+        aPerformErrHandling = true;
+        return;
+    }
+
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        if (aResponse.GetCmdStatus() != PVMFErrCancelled)
+        {
+            aPerformErrHandling = true;
+        }
+
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleSocketNodeCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
+        if (IsBusy())
+        {
+            Cancel();
+            RunIfNotReady();
+        }
+        return;
+    }
+
+    switch (cmdContextData->cmd)
+    {
+        case PVMF_SM_FSP_SOCKET_NODE_INIT:
+        {
+            CompleteInit();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_PREPARE:
+        {
+            CompletePrepare();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_START:
+        {
+            CompleteStart();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_STOP:
+        {
+            CompleteStop();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_FLUSH:
+        {
+            CompleteFlush();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_PAUSE:
+        {
+            CompletePause();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_RESET:
+        {
+            CompleteReset();
+        }
+        break;
+
+        case PVMF_SM_FSP_SOCKET_NODE_REQUEST_PORT:
+        {
+            PVMFPortInterface* port =
+                (PVMFPortInterface*)aResponse.GetEventData();
+
+            /*
+             * Save the port in TrackInfo
+             */
+            PVMFRTSPTrackInfo* trackInfo =
+                FindTrackInfo(cmdContextData->portContext.trackID);
+            OSCL_ASSERT(trackInfo);
+            if (!trackInfo)
+                return;
+            if (cmdContextData->portContext.portTag ==
+                    PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
+            {
+                if (trackInfo)
+                    trackInfo->iNetworkNodePort = port;
+                iSocketNodeContainer->iOutputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_SOCKET_NODE_PORT_TYPE_SINK)
+            {
+                if (trackInfo)
+                    trackInfo->iNetworkNodeRTCPPort = port;
+                iSocketNodeContainer->iInputPorts.push_back(port);
+            }
+            CompleteGraphConstruct();
+        }
+        break;
+        case PVMF_SM_FSP_SOCKET_NODE_CANCEL_ALL_COMMANDS:
+        {
+            CompleteChildNodesCmdCancellation();
+        }
+        break;
+
+        default:
+            break;
+    }
+    return;
+}
+
+void PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted(const PVMFCmdResp& aResponse,
+        bool& aPerformErrHandling)
+{
+    aPerformErrHandling = false;
+
+    PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+    if (iSessionControllerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+    cmdContextData->oFree = true;
+
+
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted In - cmd [%d] iSessionControllerNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iSessionControllerNodeContainer->iNodeCmdState, iInterfaceState));
+
+    //RTSPPLUSUNICAST plugin uses sync version of QueryInterface to get xtension interface of its various child nodes
+    //Also RTSPPLUSUNICAST plugin doesn t call QueryUUID on child node.
+    //So, command completion of async version of QueryUUID and QueryInterface from child node not expected.
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_QUERY_UUID);
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_QUERY_INTERFACE);
+
+    if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+    {
+        if (cmdContextData->cmd == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_REQUEST_PORT)
+        {
+            //This is last of the request ports
+            OSCL_ASSERT(iSessionControllerNodeContainer->iNumRequestPortsPending > 0);
+            if (--iSessionControllerNodeContainer->iNumRequestPortsPending == 0)
+            {
+                iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            }
+        }
+        else
+        {
+            iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+    }
+    else if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+    {
+        if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
+        {
+            iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted cmd completion for cmd other than cancel during cancellation"));
+
+            //if cancel is pending and if the parent cmd is not cancel then this is
+            //is most likely the cmd that is being cancelled.
+            //we ignore cmd completes from child nodes if cancel is pending
+            //we simply wait on cancel complete and cancel the pending cmd
+            return;
+        }
+    }
+    else if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
+    {
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted Container in IDLE state already"));
+        /*
+         * This is to handle a usecase where a node reports cmd complete for cancelall first
+         * and then reports cmd complete on the cmd that was meant to be cancelled.
+         * There are two possible scenarios that could arise based on this:
+         * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
+         * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
+         * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
+         * ii) SM node is still waiting on some other child nodes to complete cancelall.
+         * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
+         * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
+         * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
+         * Or this is the case of node reporting cmd complete multiple times for a cmd, which
+         * also can be ignored
+         */
+        return;
+    }
+
+    if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
+    {
+        aPerformErrHandling = true;
+        return;
+    }
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        if (aResponse.GetCmdStatus() != PVMFErrCancelled)
+        {
+            aPerformErrHandling = true;
+        }
+        if ((cmdContextData->cmd == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PAUSE) ||
+                (cmdContextData->cmd == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_STOP))
+        {
+            /*
+             * Check if it is a pause/stop  failure - suppress pause/stop failures if they
+             * happen after a session is complete
+             */
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (iJitterBufferNodeContainer == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)
+                (iJitterBufferNodeContainer->iExtensions[0]);
+            bool oSessionExpired = false;
+            jbExtIntf->HasSessionDurationExpired(oSessionExpired);
+            if (oSessionExpired == true)
+            {
+                aPerformErrHandling = false;
+            }
+        }
+        /* if a failure has been overridden just fall thru */
+        if (aPerformErrHandling == true)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleRTSPSessionControllerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
+            if (IsBusy())
+            {
+                Cancel();
+                RunIfNotReady();
+            }
+            return;
+        }
+    }
+
+    switch (cmdContextData->cmd)
+    {
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_INIT:
+            CompleteInit();
+            break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PREPARE:
+        {
+            /* Complete set up of feedback channels */
+            CompleteFeedBackPortsSetup();
+            /*
+             * Send start complete params to child nodes
+             * viz. SSRC etc
+             */
+            SendSessionControlPrepareCompleteParams();
+            CompletePrepare();
+        }
+        break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_START:
+        {
+            /*
+             * Send start complete params to child nodes
+             * viz. actual play range, rtp info params etc
+             */
+            SendSessionControlStartCompleteParams();
+            /* We should resume output of JB has it been paused */
+            for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+            {
+                if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_JITTER_BUFFER_NODE &&
+                        iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
+                {
+                    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+                    if (iJitterBufferNodeContainer == NULL)
+                    {
+                        OSCL_LEAVE(OsclErrBadHandle);
+                        return;
+                    }
+                    PVMFJitterBufferExtensionInterface* jbExtIntf =
+                        (PVMFJitterBufferExtensionInterface*)(iJitterBufferNodeContainer->iExtensions[0]);
+                    jbExtIntf->StartOutputPorts();
+                }
+            }
+            CompleteStart();
+        }
+        break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_STOP:
+        {
+            CompleteStop();
+        }
+        break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_FLUSH:
+            CompleteFlush();
+            break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_PAUSE:
+        {
+            CompletePause();
+        }
+        break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_RESET:
+            CompleteReset();
+            break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_REQUEST_PORT:
+        {
+            /*
+             * Save the port in TrackInfo
+             */
+            PVMFRTSPTrackInfo* trackInfo =
+                FindTrackInfo(cmdContextData->portContext.trackID);
+            OSCL_ASSERT(trackInfo);
+
+            PVMFPortInterface* port =
+                (PVMFPortInterface*)aResponse.GetEventData();
+
+            if (cmdContextData->portContext.portTag ==
+                    PVMF_RTSP_NODE_PORT_TYPE_OUTPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iSessionControllerOutputPort = port;
+                iSessionControllerNodeContainer->iOutputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_RTSP_NODE_PORT_TYPE_INPUT)
+            {
+                iSessionControllerNodeContainer->iInputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_RTSP_NODE_PORT_TYPE_INPUT_OUTPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iSessionControllerFeedbackPort = port;
+                iSessionControllerNodeContainer->iFeedBackPorts.push_back(port);
+            }
+            CompleteGraphConstruct();
+        }
+        break;
+
+        case PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_CANCEL_ALL_COMMANDS:
+        {
+            CompleteChildNodesCmdCancellation();
+        }
+        break;
+
+        default:
+            break;
+    }
+    return;
+}
+
+void PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
+{
+    aPerformErrHandling = false;
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+    cmdContextData->oFree = true;
+
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted In - cmd [%d] iJitterBufferNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iJitterBufferNodeContainer->iNodeCmdState, iInterfaceState));
+
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_JITTER_BUFFER_QUERY_UUID);
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_JITTER_BUFFER_QUERY_INTERFACE);
+
+
+    if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+    {
+        if (cmdContextData->cmd == PVMF_SM_FSP_JITTER_BUFFER_REQUEST_PORT)
+        {
+            //This is last of the request ports
+            OSCL_ASSERT(iJitterBufferNodeContainer->iNumRequestPortsPending > 0);
+            if (--iJitterBufferNodeContainer->iNumRequestPortsPending == 0)
+            {
+                iJitterBufferNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            }
+        }
+        else
+        {
+            iJitterBufferNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+    }
+    else if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+    {
+        if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
+        {
+            iJitterBufferNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted cmd completion for cmd other than cancel during cancellation"));
+            //if cancel is pending and if the parent cmd is not cancel then this is
+            //is most likely the cmd that is being cancelled.
+            //we ignore cmd completes from child nodes if cancel is pending
+            //we simply wait on cancel complete and cancel the pending cmd
+            return;
+        }
+    }
+    else if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
+    {
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted cmd container in IDLE state already"));
+        /*
+         * This is to handle a usecase where a node reports cmd complete for cancelall first
+         * and then reports cmd complete on the cmd that was meant to be cancelled.
+         * There are two possible scenarios that could arise based on this:
+         * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
+         * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
+         * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
+         * ii) SM node is still waiting on some other child nodes to complete cancelall.
+         * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
+         * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
+         * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
+         * Or this is the case of node reporting cmd complete multiple times for a cmd, which
+         * also can be ignored
+         */
+        return;
+    }
+
+    if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
+    {
+        aPerformErrHandling = true;
+        return;
+    }
+
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        if (aResponse.GetCmdStatus() != PVMFErrCancelled)
+        {
+            aPerformErrHandling = true;
+        }
+
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
+        if (IsBusy())
+        {
+            Cancel();
+            RunIfNotReady();
+        }
+        return;
+    }
+
+    switch (cmdContextData->cmd)
+    {
+        case PVMF_SM_FSP_JITTER_BUFFER_INIT:
+        {
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)
+                (iJitterBufferNodeContainer->iExtensions[0]);
+            if (jbExtIntf == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+            bool disableFireWallPackets = true;
+            if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+                    (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+            {
+
+
+                //do not disable fw pkts run time
+                //apps can still disable it compile time or using KVP
+                //for UDP sessions ofcourse
+                disableFireWallPackets = false;
+
+            }
+            CompleteInit();
+        }
+        break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_PREPARE:
+            CompletePrepare();
+            break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_START:
+        {
+            /* If start has been cancelled wait for cancel success */
+            if (aResponse.GetCmdStatus() != PVMFErrCancelled)
+            {
+                /* We need to pause output of JB before RTSP response is received */
+                for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+                {
+                    if (iFSPChildNodeContainerVec[i].iNodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE &&
+                            iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+                    {
+                        PVMFJitterBufferExtensionInterface* jbExtIntf =
+                            (PVMFJitterBufferExtensionInterface*)(iJitterBufferNodeContainer->iExtensions[0]);
+                        jbExtIntf->StopOutputPorts();
+                        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleJitterBufferCommandCompleted - StopOutputPorts()"));
+                    }
+                }
+                CompleteStart();
+            }
+        }
+        break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_STOP:
+        {
+            CompleteStop();
+        }
+        break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_FLUSH:
+            CompleteFlush();
+            break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_PAUSE:
+            CompletePause();
+            break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_RESET:
+            CompleteReset();
+            break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_REQUEST_PORT:
+        {
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)
+                (iJitterBufferNodeContainer->iExtensions[0]);
+
+            if (jbExtIntf == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+
+            /*
+             * Save the port in TrackInfo
+             */
+            PVMFRTSPTrackInfo* trackInfo =
+                FindTrackInfo(cmdContextData->portContext.trackID);
+
+            OSCL_ASSERT(trackInfo);
+
+            PVMFPortInterface* port =
+                (PVMFPortInterface*)aResponse.GetEventData();
+
+            uint32 bitrate = 0;
+
+            if (cmdContextData->portContext.portTag ==
+                    PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
+            {
+                if (trackInfo)
+                {
+                    bitrate = trackInfo->bitRate;
+                    trackInfo->iJitterBufferInputPort = port;
+                }
+                iJitterBufferNodeContainer->iInputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iJitterBufferOutputPort = port;
+                iJitterBufferNodeContainer->iOutputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
+            {
+                iJitterBufferNodeContainer->iFeedBackPorts.push_back(port);
+                if (trackInfo)
+                {
+                    trackInfo->iJitterBufferRTCPPort = port;
+                    if (trackInfo->iRTCPBwSpecified)
+                    {
+                        jbExtIntf->setPortRTCPParams(port, iTrackInfoVec.size(), trackInfo->iRR, trackInfo->iRS);
+                    }
+                }
+
+            }
+            jbExtIntf->setPortParams(port,
+                                     trackInfo->trackTimeScale,
+                                     bitrate,
+                                     trackInfo->iTrackConfig,
+                                     trackInfo->iRateAdaptation,
+                                     trackInfo->iRateAdaptationFeedBackFrequency);
+            CompleteGraphConstruct();
+        }
+        break;
+
+        case PVMF_SM_FSP_JITTER_BUFFER_CANCEL_ALL_COMMANDS:
+        {
+            CompleteChildNodesCmdCancellation();
+        }
+        break;
+
+        default:
+            break;
+    }
+    return;
+}
+
+void PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted(const PVMFCmdResp& aResponse, bool& aPerformErrHandling)
+{
+    aPerformErrHandling = false;
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+
+    PVMFSMFSPCommandContext *cmdContextData =
+        OSCL_REINTERPRET_CAST(PVMFSMFSPCommandContext*, aResponse.GetContext());
+    cmdContextData->oFree = true;
+
+    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted In - cmd [%d] iMediaLayerNodeContainer->iNodeCmdState [%d] iInterfaceState[%d]", cmdContextData->cmd, iMediaLayerNodeContainer->iNodeCmdState, iInterfaceState));
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_MEDIA_LAYER_QUERY_UUID);
+    OSCL_ASSERT(cmdContextData->cmd != PVMF_SM_FSP_MEDIA_LAYER_QUERY_INTERFACE);
+
+    if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+    {
+        if (cmdContextData->cmd == PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT)
+        {
+            //This is last of the request ports
+            OSCL_ASSERT(iMediaLayerNodeContainer->iNumRequestPortsPending > 0);
+            if (--iMediaLayerNodeContainer->iNumRequestPortsPending == 0)
+            {
+                iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            }
+        }
+        else
+        {
+            iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+    }
+    else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+    {
+        if ((cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELALLCOMMANDS) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCELCOMMAND) || (cmdContextData->parentCmd == PVMF_SMFSP_NODE_CANCEL_DUE_TO_ERROR))
+        {
+            iMediaLayerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted cmd completion for cmd other than cancel during cancellation"));
+            //if cancel is pending and if the parent cmd is not cancel then this is
+            //is most likely the cmd that is being cancelled.
+            //we ignore cmd completes from child nodes if cancel is pending
+            //we simply wait on cancel complete and cancel the pending cmd
+            return;
+        }
+    }
+    else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSMFSP_NODE_CMD_IDLE)
+    {
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted container in IDLE state already"));
+        /*
+         * This is to handle a usecase where a node reports cmd complete for cancelall first
+         * and then reports cmd complete on the cmd that was meant to be cancelled.
+         * There are two possible scenarios that could arise based on this:
+         * i) SM node has reported cmd complete on both canceall and the cmd meant to be cancelled
+         * to engine by the time cmd complete on the cmd that was meant to be cancelled arrives
+         * from the child node. In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_NO_PENDING.
+         * ii) SM node is still waiting on some other child nodes to complete cancelall.
+         * In this case iNodeCmdState would be PVMFSMFSP_NODE_CMD_IDLE.
+         * In either case iNodeCmdState cannot be PVMFSMFSP_NODE_CMD_PENDING or PVMFSMFSP_NODE_CMD_IDLE
+         * (recall that we call ResetNodeContainerCmdState  prior to issuing cancelall)
+         * Or this is the case of node reporting cmd complete multiple times for a cmd, which
+         * also can be ignored
+         */
+        return;
+    }
+    if (EPVMFNodeError == iInterfaceState)//If interface is in err state, let the err handler do processing
+    {
+        aPerformErrHandling = true;
+        return;
+    }
+
+    if (aResponse.GetCmdStatus() != PVMFSuccess)
+    {
+        if (aResponse.GetCmdStatus() != PVMFErrCancelled)
+        {
+            aPerformErrHandling = true;
+        }
+
+        PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleMediaLayerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
+        if (IsBusy())
+        {
+            Cancel();
+            RunIfNotReady();
+        }
+        return;
+    }
+
+    switch (cmdContextData->cmd)
+    {
+        case PVMF_SM_FSP_MEDIA_LAYER_INIT:
+            CompleteInit();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_PREPARE:
+            CompletePrepare();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_START:
+        {
+            CompleteStart();
+        }
+        break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_STOP:
+        {
+            CompleteStop();
+        }
+        break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_FLUSH:
+            CompleteFlush();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_PAUSE:
+            CompletePause();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_RESET:
+            CompleteReset();
+            break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_REQUEST_PORT:
+        {
+            PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+                (PVMFMediaLayerNodeExtensionInterface*)
+                (iMediaLayerNodeContainer->iExtensions[0]);
+
+            if (mlExtIntf == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+
+            /*
+             * Save the port in TrackInfo
+             */
+            PVMFRTSPTrackInfo* trackInfo =
+                FindTrackInfo(cmdContextData->portContext.trackID);
+
+            PVMFPortInterface* port =
+                (PVMFPortInterface*)aResponse.GetEventData();
+            OSCL_ASSERT(trackInfo && port);
+
+            if (cmdContextData->portContext.portTag ==
+                    PVMF_MEDIALAYER_PORT_TYPE_INPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iMediaLayerInputPort = port;
+                iMediaLayerNodeContainer->iInputPorts.push_back(port);
+            }
+            else if (cmdContextData->portContext.portTag ==
+                     PVMF_MEDIALAYER_PORT_TYPE_OUTPUT)
+            {
+                if (trackInfo)
+                    trackInfo->iMediaLayerOutputPort = port;
+                iMediaLayerNodeContainer->iOutputPorts.push_back(port);
+                uint32 preroll32 = 0;
+                const bool live = false;
+                mlExtIntf->setOutPortStreamParams(port,
+                                                  cmdContextData->portContext.trackID,
+                                                  preroll32,
+                                                  live);
+            }
+            mediaInfo* mInfo = NULL;
+
+            SDPInfo* sdpInfo = iSdpInfo.GetRep();
+            if (sdpInfo == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+            if (trackInfo)
+                mInfo = sdpInfo->getMediaInfoBasedOnID(trackInfo->trackID);
+            mlExtIntf->setPortMediaParams(port, trackInfo->iTrackConfig, mInfo);
+            CompleteGraphConstruct();
+        }
+        break;
+
+        case PVMF_SM_FSP_MEDIA_LAYER_CANCEL_ALL_COMMANDS:
+        {
+            CompleteChildNodesCmdCancellation();
+        }
+        break;
+
+        default:
+            break;
+    }
+    return;
+}
+
+void PVMFSMRTSPUnicastNode::CompleteInit()
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteInit - In"));
+    if (CheckChildrenNodesInit())
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if (aCmd.iCmd == PVMF_SMFSP_NODE_INIT)
+            {
+                PVMFStatus status = PVMFSuccess;
+
+                if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL))
+                {
+                    status = ProcessSDP();
+                }
+
+                if (status == PVMFSuccess)
+                {
+                    status = InitMetaData();
+                    if (status == PVMFSuccess)
+                    {
+                        if (iSessionSourceInfo->iDRMProtected == true)
+                        {
+                            PopulateDRMInfo();
+                            //This clip is protected clip
+                            if (iCPM)
+                            {
+                                /*
+                                 * Go thru CPM commands before parsing the file in case
+                                 * of a new source file.
+                                 * - Init CPM
+                                 * - Open Session
+                                 * - Register Content
+                                 * - Get Content Type
+                                 * - Approve Usage
+                                 * In case the source file has already been parsed skip to
+                                 * - Approve Usage
+                                 */
+                                InitCPM();
+                                return;
+                            }
+                            else
+                            {
+                                PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Init() - CmdComplete - PVMFErrArgument"));
+                                CommandComplete(iCurrentCommand,
+                                                iCurrentCommand.front(),
+                                                PVMFErrArgument,
+                                                NULL, NULL, NULL);
+                                return;
+                            }
+                        }
+                    }
+                    else
+                    {
+                        PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteInit - InitMetaData fail"));
+                    }
+
+                    PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Init() - CmdComplete - PVMFSuccess"));
+                    //Init is completed at unprotected clip
+                    SetState(EPVMFNodeInitialized);
+                    PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode::CompleteInit Success"));
+                    CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+                }
+                else
+                {
+                    PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Init() - Cmd Failed - PVMFStreamingManagerNodeErrorParseSDPFailed"));
+                    PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::CompleteInit Failure"));
+                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
+                    int32 errcode = PVMFStreamingManagerNodeErrorParseSDPFailed;
+                    CommandComplete(iCurrentCommand, aCmd, status, NULL, &eventuuid, &errcode);
+                }
+            }
+        }
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompleteInit - Out"));
+    return;
+}
+
+bool PVMFSMRTSPUnicastNode::CheckChildrenNodesInit()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::InitMetaData()
+{
+    // Clear out the existing key list
+    iAvailableMetadataKeys.clear();
+    iCPMMetadataKeys.clear();
+
+    // Get the SDP info
+    SDPInfo* sdpInfo = iSdpInfo.GetRep();
+    if (sdpInfo == NULL)
+    {
+        return PVMFErrInvalidState;
+    }
+    // Get Asset Info
+    sessionDescription* sessionInfo = sdpInfo->getSessionInfo();
+    if (sessionInfo != NULL)
+    {
+        iMetaDataInfo->iRandomAccessDenied = sessionInfo->getRandomAccessDenied();
+
+        AssetInfoType assetInfo = sessionInfo->getAssetInfo();
+
+        iMetaDataInfo->iTitlePresent = assetInfo.oTitlePresent;
+        iMetaDataInfo->iDescriptionPresent = assetInfo.oDescriptionPresent;
+        iMetaDataInfo->iCopyRightPresent = assetInfo.oCopyRightPresent;
+        iMetaDataInfo->iPerformerPresent = assetInfo.oPerformerPresent;
+        iMetaDataInfo->iAuthorPresent = assetInfo.oAuthorPresent;
+        iMetaDataInfo->iGenrePresent = assetInfo.oGenrePresent;
+        iMetaDataInfo->iRatingPresent = assetInfo.oRatingPresent;
+        iMetaDataInfo->iClassificationPresent = assetInfo.oClassificationPresent;
+        iMetaDataInfo->iKeyWordsPresent = assetInfo.oKeyWordsPresent;
+        iMetaDataInfo->iLocationPresent = assetInfo.oLocationPresent;
+        iMetaDataInfo->iAlbumPresent = assetInfo.oAlbumPresent;
+
+        if (iMetaDataInfo->iTitlePresent)
+        {
+            iMetaDataInfo->iTitle = assetInfo.Box[AssetInfoType::TITLE];
+        }
+        if (iMetaDataInfo->iDescriptionPresent)
+        {
+            iMetaDataInfo->iDescription = assetInfo.Box[AssetInfoType::DESCRIPTION];
+        }
+        if (iMetaDataInfo->iCopyRightPresent)
+        {
+            iMetaDataInfo->iCopyright = assetInfo.Box[AssetInfoType::COPYRIGHT];
+        }
+        if (iMetaDataInfo->iPerformerPresent)
+        {
+            iMetaDataInfo->iPerformer = assetInfo.Box[AssetInfoType::PERFORMER];
+        }
+        if (iMetaDataInfo->iAuthorPresent)
+        {
+            iMetaDataInfo->iAuthor = assetInfo.Box[AssetInfoType::AUTHOR];
+        }
+        if (iMetaDataInfo->iRatingPresent)
+        {
+            iMetaDataInfo->iRating = assetInfo.Box[AssetInfoType::RATING];
+        }
+        if (iMetaDataInfo->iClassificationPresent)
+        {
+            iMetaDataInfo->iClassification = assetInfo.Box[AssetInfoType::CLASSIFICATION];
+        }
+        if (iMetaDataInfo->iKeyWordsPresent)
+        {
+            iMetaDataInfo->iNumKeyWords = assetInfo.iNumKeyWords;
+            for (uint32 i = 0; i < iMetaDataInfo->iNumKeyWords; i++)
+            {
+                iMetaDataInfo->iKeyWords[i] = assetInfo.KeyWords[i];
+            }
+        }
+        if (iMetaDataInfo->iLocationPresent)
+        {
+            iMetaDataInfo->iLocationStruct = assetInfo.iLocationStruct;
+        }
+        if (iMetaDataInfo->iAlbumPresent)
+        {
+            iMetaDataInfo->iAlbum = assetInfo.Box[AssetInfoType::ALBUM];
+        }
+        if (assetInfo.iRecordingYear)
+        {
+            iMetaDataInfo->iYear = assetInfo.iRecordingYear;
+        }
+
+        RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
+        if (sessionRange->end_is_set == true)
+        {
+            iMetaDataInfo->iSessionDurationAvailable = true;
+
+            int32 sessionStartTime = 0, sessionStopTime = 0;
+            sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
+            uint32 duration = 0;
+            if (sessionStopTime > sessionStartTime && sessionStartTime >= 0)
+            {
+                duration = (uint32)(sessionStopTime - sessionStartTime);
+            }
+            Oscl_Int64_Utils::set_uint64(iMetaDataInfo->iSessionDuration, 0, duration);
+            iMetaDataInfo->iSessionDurationTimeScale = 1000;
+        }
+
+        iPauseDenied = iMetaDataInfo->iSessionDurationAvailable ? false : true;
+
+    }
+
+    iMetaDataInfo->iNumTracks = sdpInfo->getNumMediaObjects();
+
+    for (uint32 i = 0; i < iMetaDataInfo->iNumTracks; i++)
+    {
+        Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec = sdpInfo->getMediaInfo(i);
+        for (uint32 j = 0; j < mediaInfoVec.size(); ++j)
+        {
+            mediaInfo* mInfo = mediaInfoVec[j];
+            if (mInfo != NULL)
+            {
+                PVMFSMTrackMetaDataInfo trackMetaDataInfo;
+
+                trackMetaDataInfo.iTrackID = mInfo->getMediaInfoID();
+                const char* mimeType = mInfo->getMIMEType();
+                OSCL_StackString<32> realAudio(_STRLIT_CHAR("realaudio"));
+                OSCL_StackString<32> realVideo(_STRLIT_CHAR("realvideo"));
+                OSCL_StackString<32> h263(_STRLIT_CHAR("H263"));
+                if (oscl_strstr(mimeType, realAudio.get_cstr()) != NULL)
+                {
+                    trackMetaDataInfo.iMimeType = PVMF_MIME_REAL_AUDIO;
+                }
+                else if (oscl_strstr(mimeType, realVideo.get_cstr()) != NULL)
+                {
+                    trackMetaDataInfo.iMimeType = PVMF_MIME_REAL_VIDEO;
+                }
+                else
+                {
+                    trackMetaDataInfo.iMimeType += mimeType;
+                }
+
+                Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
+                payloadVector = mInfo->getPayloadSpecificInfoVector();
+                if (payloadVector.size() != 0)
+                {
+                    /*
+                     * There can be multiple payloads per media segment.
+                     * We only support one for now, so
+                     * use just the first payload
+                     */
+                    PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
+                    if (oscl_strstr(mimeType, h263.get_cstr()) != NULL)
+                    {
+                        H263PayloadSpecificInfoType* h263PayloadInfo =
+                            OSCL_STATIC_CAST(H263PayloadSpecificInfoType*, payloadInfo);
+                        trackMetaDataInfo.iTrackWidth = h263PayloadInfo->getFrameWidth();
+                        trackMetaDataInfo.iTrackHeight = h263PayloadInfo->getFrameHeight();
+                    }
+
+                    int32 configSize = payloadInfo->configSize;
+                    OsclAny* config = payloadInfo->configHeader.GetRep();
+
+                    if ((configSize > 0) && (config != NULL))
+                    {
+                        OsclMemAllocDestructDealloc<uint8> my_alloc;
+                        OsclRefCounter* my_refcnt;
+                        uint aligned_refcnt_size =
+                            oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
+
+                        uint8* my_ptr = GetMemoryChunk(my_alloc, aligned_refcnt_size + configSize);
+                        if (!my_ptr)
+                            return PVMFErrResource;
+
+                        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
+                        my_ptr += aligned_refcnt_size;
+
+                        OsclMemoryFragment memfrag;
+                        memfrag.len = (uint32)configSize;
+                        memfrag.ptr = my_ptr;
+
+                        oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
+
+                        OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
+                        trackMetaDataInfo.iCodecSpecificInfo = tmpRefcntMemFrag;
+                    }
+                }
+
+                trackMetaDataInfo.iTrackBitRate = (uint32)(mInfo->getBitrate());
+
+                RtspRangeType *mediaRange = mInfo->getRtspRange();
+                if (mediaRange->end_is_set == true)
+                {
+                    int32 mediaStartTime = 0, mediaStopTime = 0;
+                    mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
+                    uint32 trackduration = 0;
+                    if (mediaStopTime > mediaStartTime && mediaStartTime >= 0)
+                    {
+                        trackduration = (uint32)(mediaStopTime - mediaStartTime);
+                    }
+                    uint64 trackduration64 = 0;
+                    Oscl_Int64_Utils::set_uint64(trackduration64, 0, trackduration);
+                    trackMetaDataInfo.iTrackDuration = trackduration64;
+                    trackMetaDataInfo.iTrackDurationTimeScale = 1000;
+                    trackMetaDataInfo.iTrackDurationAvailable = true;
+                }
+                else
+                {
+                    trackMetaDataInfo.iTrackDurationAvailable = false;
+                }
+                iMetaDataInfo->iTrackMetaDataInfoVec.push_back(trackMetaDataInfo);
+            }
+        }
+    }
+
+    PVMFStatus status = PopulateAvailableMetadataKeys();
+    if (PVMFSuccess != status)
+    {
+        return status;
+    }
+    iMetaDataInfo->iMetadataAvailable = true;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::PopulateAvailableMetadataKeys()
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode,
+             PVMFSMFSPBaseNode::PopulateAvailableMetadataKeys();
+
+             //Add feature specific streaming metadata keys
+             // Create the parameter string for the index range
+             if (iMetaDataInfo->iNumTracks > 0)
+{
+    char indexparam[18];
+        oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo->iNumTracks - 1));
+        indexparam[17] = NULL_TERM_CHAR;
+
+        iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY);
+        iAvailableMetadataKeys[0] += indexparam;
+    }
+    iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_PAUSE_DENIED_KEY);
+            );
+    if (leavecode != OsclErrNone)
+        return leavecode;
+    else
+        return PVMFSuccess;
+}
+
+void PVMFSMRTSPUnicastNode::CompletePrepare()
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompletePrepare - In"));
+    if ((CheckChildrenNodesPrepare()) && (iGraphConstructComplete))
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if (aCmd.iCmd == PVMF_SMFSP_NODE_PREPARE)
+            {
+                SetState(EPVMFNodePrepared);
+                PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Prepare() - CmdComplete - PVMFSuccess"));
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompletePrepare - Out"));
+    return;
+}
+
+bool PVMFSMRTSPUnicastNode::CheckChildrenNodesPrepare()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+void PVMFSMRTSPUnicastNode::CompleteStart()
+{
+    int32 localMode = 0;
+
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStart - In"));
+    if (CheckChildrenNodesStart())
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if ((aCmd.iCmd == PVMF_SMFSP_NODE_START) ||
+                    (aCmd.iCmd == PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION))
+            {
+                if (iRepositioning)
+                {
+                    PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::SetDataSourcePosition() - CmdComplete - PMVFSuccess"));
+                    iRepositioning = false;
+                    iPlayListRepositioning = false;
+
+                    if ((localMode == 0) || (localMode == -1))
+                    {
+                        GetActualMediaTSAfterSeek();
+                    }
+                    iPVMFDataSourcePositionParamsPtr = NULL;
+                }
+                if ((localMode == 0) || (localMode == -1))
+                {
+                    SetState(EPVMFNodeStarted);
+                    if (IsAdded())
+                    {
+                        /* wakeup the AO */
+                        RunIfNotReady();
+                    }
+                    PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Start() - CmdComplete - PMVFSuccess"));
+                }
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStart - Out"));
+    return;
+}
+
+bool PVMFSMRTSPUnicastNode::CheckChildrenNodesStart()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState == PVMFSMFSP_NODE_CMD_PENDING)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+void PVMFSMRTSPUnicastNode::GetActualMediaTSAfterSeek()
+{
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+        (PVMFMediaLayerNodeExtensionInterface*)
+        (iMediaLayerNodeContainer->iExtensions[0]);
+    if (mlExtIntf == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return;
+    }
+    iActualMediaDataTS = jbExtIntf->getActualMediaDataTSAfterSeek();
+    if (iActualMediaDataTSPtr != NULL)
+    {
+        *iActualMediaDataTSPtr = iActualMediaDataTS;
+        PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFPVMFSMRTSPUnicastNode::GetActualMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
+                                        iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
+    }
+}
+
+void PVMFSMRTSPUnicastNode::CompleteStop()
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStop - In"));
+    if (CheckChildrenNodesStop())
+    {
+        if (!iCurrentCommand.empty() && iCancelCommand.empty())
+        {
+            PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+            if (aCmd.iCmd == PVMF_SMFSP_NODE_STOP)
+            {
+                /* transition to Prepared state */
+                ResetStopCompleteParams();
+                SetState(EPVMFNodePrepared);
+                PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFSMRTSPUnicastNode::Stop() - CmdComplete - PVMFSuccess"));
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::CompleteStop - Out"));
+    return;
+}
+
+void PVMFSMRTSPUnicastNode::ResetStopCompleteParams()
+{
+    iPlaylistPlayInProgress = false;
+    iRepositionRequestedStartNPTInMS = 0;
+}
+
+void PVMFSMRTSPUnicastNode::CompletePause()
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompletePause - In"));
+    if (CheckChildrenNodesPause())
+    {
+        SetState(EPVMFNodePaused);
+        if (iRepositioning)
+        {
+            OSCL_ASSERT((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+                        (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE));
+            /*
+             * Pause request generated by a reposition command
+             * complete. Issue a start.
+             */
+            if (iPVMFDataSourcePositionParamsPtr == NULL)
+            {
+                DoRepositioningStart3GPPStreaming();
+            }
+        }
+        else
+        {
+            if (!iCurrentCommand.empty() && iCancelCommand.empty())
+            {
+                PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+                PVMF_SM_RTSP_LOG_COMMAND_SEQ((0, "PVMFPVMFSMRTSPUnicastNode::Pause() - CmdComplete - PVMFSuccess"));
+                CommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+            }
+        }
+
+    }
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFPVMFSMRTSPUnicastNode::CompletePause - Out"));
+    return;
+}
+
+bool PVMFSMRTSPUnicastNode::CheckChildrenNodesPause()
+{
+    for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+    {
+        if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE
+                && iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_CANCEL_PENDING)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+/*
+ * Called by the call back routine whenever a "RequestPort" call
+ * completes successfully.
+ */
+void PVMFSMRTSPUnicastNode::CompleteGraphConstruct()
+{
+    iTotalNumRequestPortsComplete++;
+    /*
+     * Once all port requests are complete, connect the graph
+     */
+    if (iTotalNumRequestPortsComplete == iNumRequestPortsPending)
+    {
+        PVMFSMFSPBaseNodeCommand& aCmd = iCurrentCommand.front();
+        if (!SendSessionSourceInfoToSessionController())
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:CompleteGraphConstruct - SendSessionSourceInfoToSessionController Failed"));
+            InternalCommandComplete(iCurrentCommand, aCmd, PVMFFailure);
+        }
+        else
+        {
+            iGraphConstructComplete = true;
+            PVMFSMFSPChildNodeContainer* socketNodeContainer = getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
+            PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer = getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if ((socketNodeContainer == NULL) || (jitterBufferNodeContainer == NULL))
+            {
+                OSCL_ASSERT(false);
+                return;
+            }
+
+            PVMFJitterBufferExtensionInterface* jbExtIntf = OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions[0]);
+            PVMFSocketNodeExtensionInterface* socketExtnIntf =  OSCL_STATIC_CAST(PVMFSocketNodeExtensionInterface*, socketNodeContainer->iExtensions[0]);
+
+            OSCL_ASSERT(jbExtIntf && socketExtnIntf);
+            if (!jbExtIntf || !socketExtnIntf)
+                return;
+
+            //For RTSP based streamings, we want the mempools to get resized
+            //For input port, get the value from Jitter Buffer Node
+            uint32 resizeSizeInputPort = 0;
+            uint32 numResizeInputPort = 0;
+            jbExtIntf->GetSharedBufferResizeParams(numResizeInputPort, resizeSizeInputPort);
+            //For feedback port we use the const initialized to a configurable macro
+            const uint32 resizeSizeFeedbackPort = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_FEEDBACK_PORT;
+            const uint32 numResizeFeedbackPort = 1;
+
+            //For every track
+            //Decide the size of the shared buffer to be allocated at socket node for receiving
+            //RTP packets [Input port]
+            //Receiving the response of RTCP reports send by JB [Feedback Port]
+
+            for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+            {
+                PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
+                uint32 bufferSzForRTPPackets = GetJitterBufferMemPoolSize(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT, iTrackInfoVec[i]);
+                uint32 bufferSzForRTCPResponse = GetJitterBufferMemPoolSize(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK, iTrackInfoVec[i]);
+
+                //Set with the socket node
+                OsclMemPoolResizableAllocator* socketAlloc = socketExtnIntf->CreateSharedBuffer(trackInfo.iNetworkNodePort, bufferSzForRTPPackets, DEFAULT_NUM_MEDIA_MSGS_IN_JITTER_BUFFER, resizeSizeInputPort, numResizeInputPort);
+                jbExtIntf->SetJitterBufferChunkAllocator(socketAlloc, trackInfo.iJitterBufferInputPort);
+                const uint32 numMemChunksForRTCPMemPool = bufferSzForRTCPResponse / MAX_SOCKET_BUFFER_SIZE;
+                socketExtnIntf->CreateSharedBuffer(trackInfo.iNetworkNodeRTCPPort, bufferSzForRTCPResponse, numMemChunksForRTCPMemPool, resizeSizeFeedbackPort, numResizeFeedbackPort);
+            }
+            InternalCommandComplete(iCurrentCommand, aCmd, PVMFSuccess);
+        }
+    }
+}
+
+/*
+ * Called when all port requests are complete, in order to send the
+ * UDP port information to RTSP
+ */
+bool PVMFSMRTSPUnicastNode::SendSessionSourceInfoToSessionController()
+{
+    if (((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+            (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE)))
+    {
+        PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
+        if (iSocketNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return false;
+        }
+
+        PVMFSocketNode* socketNode =
+            (PVMFSocketNode*)(iSocketNodeContainer->iNode);
+
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return false;
+        }
+
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+
+        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
+
+        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
+        {
+            PVMFRTSPTrackInfo trackInfo = iTrackInfoVec[i];
+
+            OsclNetworkAddress localAdd;
+            OsclNetworkAddress remoteAdd;
+            StreamInfo sInfo;
+
+            sInfo.iSDPStreamId = trackInfo.trackID;
+
+
+            if (trackInfo.iNetworkNodePort == NULL)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:SendSessionSourceInfoToSessionController - Invalid Port"));
+                return false;
+            }
+
+            socketNode->GetPortConfig(*trackInfo.iNetworkNodePort,
+                                      localAdd,
+                                      remoteAdd);
+
+            sInfo.iCliRTPPort = localAdd.port;
+
+            socketNode->GetPortConfig(*trackInfo.iNetworkNodeRTCPPort,
+                                      localAdd,
+                                      remoteAdd);
+
+            sInfo.iCliRTCPPort = localAdd.port;
+
+
+            /* Set Rate Adaptation parameters */
+            sInfo.b3gppAdaptationIsSet = false;
+            if (trackInfo.iRateAdaptation)
+            {
+                sInfo.b3gppAdaptationIsSet = true;
+                /* Compute buffer size based on bitrate and jitter duration*/
+                uint32 sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
+                if (((int32)iJitterBufferDurationInMilliSeconds > 0) &&
+                        ((int32)trackInfo.bitRate > 0))
+                {
+                    uint32 byteRate = trackInfo.bitRate / 8;
+                    uint32 overhead = (byteRate * PVMF_JITTER_BUFFER_NODE_MEM_POOL_OVERHEAD) / 100;
+                    uint32 durationInSec = iJitterBufferDurationInMilliSeconds / 1000;
+                    sizeInBytes = ((byteRate + overhead) * durationInSec);
+                    if (sizeInBytes < MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES)
+                    {
+                        sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
+                    }
+                    sizeInBytes += 2 * MAX_SOCKET_BUFFER_SIZE;
+                }
+                sInfo.iBufSize = sizeInBytes;
+                sInfo.iTargetTime = iJitterBufferDurationInMilliSeconds;
+            }
+            aSelectedStream.push_back(sInfo);
+        }
+
+        if (rtspExtIntf->SetSDPInfo(iSdpInfo,
+                                    aSelectedStream) != PVMFSuccess)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:SendSessionSourceInfoToSessionController - SetSDPInfo Failed"));
+            return false;
+        }
+
+        /* Set play range from SDP */
+        sessionDescription* sessionInfo = iSdpInfo->getSessionInfo();
+        RtspRangeType *rtspRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
+        rtspRange->convertToMilliSec((int32&)iSessionStartTime, (int32&)iSessionStopTime);
+
+        if (rtspRange->end_is_set == false)
+        {
+            iSessionStopTime = 0xFFFFFFFF;
+            iSessionStopTimeAvailable = false;
+        }
+
+        if ((rtspRange->format != RtspRangeType::INVALID_RANGE) &&
+                (rtspRange->start_is_set != false))
+        {
+            if (rtspExtIntf->SetRequestPlayRange(*rtspRange) != PVMFSuccess)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:SendRequestPlayRangeToSessionController - SetRequestPlayRange Failed"));
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implemenation of pure virtuals from PVMFSMFSPBaseNode
+///////////////////////////////////////////////////////////////////////////////
+bool PVMFSMRTSPUnicastNode::IsFSPInternalCmd(PVMFCommandId aId)
+{
+    OSCL_UNUSED_ARG(aId);
+    return false;
+}
+
+void PVMFSMRTSPUnicastNode::addRef()
+{
+}
+
+void PVMFSMRTSPUnicastNode::removeRef()
+{
+}
+
+void PVMFSMRTSPUnicastNode::setJitterBufferDurationInMilliSeconds(uint32 duration)
+{
+    iJitterBufferDurationInMilliSeconds = duration;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::DoRepositioningStart3GPPStreaming()
+{
+    PVMFStatus status = SetRTSPPlaybackRange();
+    if (PVMFSuccess != status)
+    {
+        return status;
+    }
+
+    bool isSessionDurationExpired = false;
+
+    PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (jitterBufferNodeContainer)
+    {
+        PVMFJitterBufferExtensionInterface* jbExtIntf =
+            OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
+        if (jbExtIntf)
+            jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
+    }
+
+    PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+    if (sessionControllerNodeContainer)
+    {
+        PVRTSPEngineNodeExtensionInterface*	rtspExtIntf =
+            OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
+        if (rtspExtIntf)
+            rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
+    }
+
+    PVMFSMFSPChildNodeContainerVector::iterator it;
+    for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+    {
+        PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+        if (internalCmd != NULL)
+        {
+            internalCmd->cmd =
+                it->commandStartOffset +
+                PVMF_SM_FSP_NODE_INTERNAL_START_CMD_OFFSET;
+            internalCmd->parentCmd = PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION;
+
+            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+            PVMFNodeInterface* iNode = it->iNode;
+
+            iNode->Start(it->iSessionId, cmdContextData);
+            it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoRepositioningStart:RequestNewInternalCmd - Failed"));
+            status = PVMFErrNoMemory;
+        }
+    }
+    return status;
+}
+
+PVMFStatus PVMFSMRTSPUnicastNode::SetRTSPPlaybackRange()
+{
+    PVMFStatus status = PVMFSuccess;
+
+    /* Set Requested Play Range */
+    PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+
+    if (iSessionControllerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return false;
+    }
+
+    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+        (PVRTSPEngineNodeExtensionInterface*)
+        (iSessionControllerNodeContainer->iExtensions[0]);
+
+    RtspRangeType rtspRange;
+    rtspRange.format = RtspRangeType::NPT_RANGE;
+    rtspRange.start_is_set = true;
+    rtspRange.npt_start.npt_format = NptTimeFormat::NPT_SEC;
+    rtspRange.npt_start.npt_sec.sec = iRepositionRequestedStartNPTInMS / 1000;
+    rtspRange.npt_start.npt_sec.milli_sec =
+        (iRepositionRequestedStartNPTInMS - ((iRepositionRequestedStartNPTInMS / 1000) * 1000));
+    rtspRange.end_is_set = true;
+    rtspRange.npt_end.npt_format = NptTimeFormat::NPT_SEC;
+    rtspRange.npt_end.npt_sec.sec = iSessionStopTime / 1000;
+    rtspRange.npt_end.npt_sec.milli_sec =
+        (iSessionStopTime - ((iSessionStopTime / 1000) * 1000));
+
+    status = rtspExtIntf->SetRequestPlayRange(rtspRange);
+    if (PVMFSuccess != status)
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SetRTSPPlaybackRange() - SetRequestPlayRange Failed"));
+    }
+
+    return status;
+}
+
+bool PVMFSMRTSPUnicastNode::DoRepositioningPause3GPPStreaming()
+{
+    PVMFSMFSPChildNodeContainerVector::iterator it;
+
+    bool isSessionDurationExpired = false;
+
+    PVMFSMFSPChildNodeContainer* jitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (jitterBufferNodeContainer)
+    {
+        PVMFJitterBufferExtensionInterface* jbExtIntf =
+            OSCL_STATIC_CAST(PVMFJitterBufferExtensionInterface*, jitterBufferNodeContainer->iExtensions.front());
+        if (jbExtIntf)
+            jbExtIntf->HasSessionDurationExpired(isSessionDurationExpired);
+    }
+
+    PVMFSMFSPChildNodeContainer *sessionControllerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+    if (sessionControllerNodeContainer)
+    {
+        PVRTSPEngineNodeExtensionInterface*	rtspExtIntf =
+            OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, sessionControllerNodeContainer->iExtensions.front());
+        if (rtspExtIntf)
+            rtspExtIntf->UpdateSessionCompletionStatus(isSessionDurationExpired);
+    }
+
+    for (it = iFSPChildNodeContainerVec.begin(); it != iFSPChildNodeContainerVec.end(); it++)
+    {
+        int32 nodeTag = it->iNodeTag;
+        //if pv playlist rp, don't pause
+        if ((nodeTag == PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE) ||
+                (nodeTag == PVMF_SM_FSP_MEDIA_LAYER_NODE) ||
+                (nodeTag == PVMF_SM_FSP_JITTER_BUFFER_NODE) ||
+                (nodeTag == PVMF_SM_FSP_SOCKET_NODE))
+        {
+            PVMFSMFSPCommandContext* internalCmd = RequestNewInternalCmd();
+            if (internalCmd != NULL)
+            {
+                internalCmd->cmd =
+                    it->commandStartOffset +
+                    PVMF_SM_FSP_NODE_INTERNAL_PAUSE_CMD_OFFSET;
+                internalCmd->parentCmd = PVMF_SMFSP_NODE_SET_DATASOURCE_POSITION;
+
+                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+
+                PVMFNodeInterface* iNode = it->iNode;
+
+                iNode->Pause(it->iSessionId, cmdContextData);
+                it->iNodeCmdState = PVMFSMFSP_NODE_CMD_PENDING;
+            }
+            else
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode:DoRepositioningPause:RequestNewInternalCmd - Failed"));
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+bool PVMFSMRTSPUnicastNode::CompleteFeedBackPortsSetup()
+{
+    PVMFSMFSPChildNodeContainer* iSocketNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_SOCKET_NODE);
+    if (iSocketNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return false;
+    }
+
+    PVMFSocketNode* socketNode =
+        (PVMFSocketNode*)(iSocketNodeContainer->iNode);
+
+    PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+
+    if (iSessionControllerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return false;
+    }
+
+    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+        (PVRTSPEngineNodeExtensionInterface*)
+        (iSessionControllerNodeContainer->iExtensions[0]);
+
+    Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
+
+    if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
+    {
+        OSCL_LEAVE(OsclErrGeneral);
+    }
+
+    for (uint32 i = 0; i < aSelectedStream.size(); i++)
+    {
+        StreamInfo streamInfo = aSelectedStream[i];
+
+        PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
+
+        if (trackInfo == NULL)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - FindTrackInfo Failed"));
+            return false;
+        }
+
+        if (trackInfo->iNetworkNodeRTCPPort == NULL)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - Invalid RTCP Port"));
+            return false;
+        }
+
+        OsclNetworkAddress localAddRTCP;
+        OsclNetworkAddress remoteAddRTCP;
+
+        localAddRTCP.port = streamInfo.iCliRTCPPort;
+        remoteAddRTCP.port = streamInfo.iSerRTCPPort;
+        remoteAddRTCP.ipAddr = streamInfo.iSerIpAddr;
+
+        socketNode->SetPortConfig(*(trackInfo->iNetworkNodeRTCPPort),
+                                  localAddRTCP,
+                                  remoteAddRTCP);
+
+        if (trackInfo->iNetworkNodePort == NULL)
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - Invalid RTP Port"));
+            return false;
+        }
+
+        OsclNetworkAddress localAddRTP;
+        OsclNetworkAddress remoteAddRTP;
+
+        localAddRTP.port = streamInfo.iCliRTPPort;
+        remoteAddRTP.port = streamInfo.iSerRTPPort;
+        remoteAddRTP.ipAddr = streamInfo.iSerIpAddr;
+
+        socketNode->SetPortConfig(*(trackInfo->iNetworkNodePort),
+                                  localAddRTP,
+                                  remoteAddRTP);
+
+    }
+
+    return true;
+}
+
+bool
+PVMFSMRTSPUnicastNode::SendSessionControlPrepareCompleteParams()
+{
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+            (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+    {
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return false;
+        }
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+
+        PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+        if (iJitterBufferNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return false;
+        }
+        PVMFJitterBufferExtensionInterface* jbExtIntf =
+            (PVMFJitterBufferExtensionInterface*)
+            (iJitterBufferNodeContainer->iExtensions[0]);
+
+        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
+
+        if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
+        {
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+
+        for (uint32 i = 0; i < aSelectedStream.size(); i++)
+        {
+            StreamInfo streamInfo = aSelectedStream[i];
+
+            PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
+
+            if (trackInfo == NULL)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendSessionControlPrepareCompleteParams - FindTrackInfo Failed"));
+                return false;
+            }
+
+            if (trackInfo->iJitterBufferInputPort == NULL)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendSessionControlPrepareCompleteParams - Invalid Port"));
+                return false;
+            }
+
+            if (streamInfo.ssrcIsSet)
+            {
+                jbExtIntf->setPortSSRC(trackInfo->iJitterBufferInputPort,
+                                       streamInfo.iSSRC);
+            }
+        }
+
+        /* Set server info */
+        PVRTSPEngineNodeServerInfo rtspServerInfo;
+        PVMFJitterBufferFireWallPacketInfo fireWallPktInfo;
+
+        rtspExtIntf->GetServerInfo(rtspServerInfo);
+
+        if (rtspServerInfo.iIsPVServer)
+        {
+            fireWallPktInfo.iFormat = PVMF_JB_FW_PKT_FORMAT_PV;
+        }
+        fireWallPktInfo.iServerRoundTripDelayInMS = rtspServerInfo.iRoundTripDelayInMS;
+
+        if (0 == fireWallPktInfo.iServerRoundTripDelayInMS)
+        {
+            fireWallPktInfo.iServerRoundTripDelayInMS = PVMF_JITTER_BUFFER_NODE_FIREWALL_PKT_DEFAULT_SERVER_RESPONSE_TIMEOUT_IN_MS;
+        }
+
+        fireWallPktInfo.iNumAttempts = PVMF_JITTER_BUFFER_NODE_DEFAULT_FIREWALL_PKT_ATTEMPTS;
+
+        jbExtIntf->setServerInfo(fireWallPktInfo);
+    }
+    return true;
+}
+
+bool PVMFSMRTSPUnicastNode::SendSessionControlStartCompleteParams()
+{
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (iJitterBufferNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return false;
+    }
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+    if (iMediaLayerNodeContainer == NULL)
+    {
+        OSCL_LEAVE(OsclErrBadHandle);
+        return false;
+    }
+    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+        (PVMFMediaLayerNodeExtensionInterface*)
+        (iMediaLayerNodeContainer->iExtensions[0]);
+
+    bool end_is_set = true;
+    int32 startTime = 0;
+    int32 stopTime  = 0;
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+            (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+    {
+        PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+        if (iSessionControllerNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return false;
+        }
+        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
+            (PVRTSPEngineNodeExtensionInterface*)
+            (iSessionControllerNodeContainer->iExtensions[0]);
+
+        /* Get Actual Play Range */
+        RtspRangeType rangeType;
+        if (rtspExtIntf->GetActualPlayRange(rangeType) != PVMFSuccess)
+        {
+            return false;
+        }
+
+        rangeType.convertToMilliSec(startTime, stopTime);
+
+        /* Use from SDP if not set */
+        end_is_set = rangeType.end_is_set;
+        if (end_is_set == false)
+        {
+            stopTime = iSessionStopTime;
+        }
+
+        if (iRepositioning)
+        {
+            iActualRepositionStartNPTInMS = startTime;
+            if (iActualRepositionStartNPTInMSPtr != NULL)
+            {
+                *iActualRepositionStartNPTInMSPtr = startTime;
+            }
+        }
+
+        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
+
+        if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
+        {
+            OSCL_LEAVE(OsclErrGeneral);
+        }
+
+        for (uint32 i = 0; i < aSelectedStream.size(); i++)
+        {
+            StreamInfo streamInfo = aSelectedStream[i];
+
+            PVMFRTSPTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
+
+            if (trackInfo == NULL)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendStartCompleteSessionControlParams - FindTrackInfo Failed"));
+                return false;
+            }
+
+            if (trackInfo->iJitterBufferInputPort == NULL)
+            {
+                PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:SendStartCompleteSessionControlParams - Invalid Port"));
+                return false;
+            }
+
+            if (streamInfo.seqIsSet != true)
+            {
+                streamInfo.seqIsSet = false;
+                streamInfo.seq = 0;
+            }
+            if (streamInfo.rtptimeIsSet != true)
+            {
+                streamInfo.rtptimeIsSet = false;
+                streamInfo.rtptime = 0;
+            }
+            jbExtIntf->setPortRTPParams(trackInfo->iJitterBufferInputPort,
+                                        streamInfo.seqIsSet,
+                                        streamInfo.seq,
+                                        streamInfo.rtptimeIsSet,
+                                        streamInfo.rtptime,
+                                        rangeType.start_is_set,
+                                        startTime,
+                                        iRepositioning);
+
+        }
+    }
+
+
+    /* Send actual stop time to Jitter Buffer */
+    if (jbExtIntf->setPlayRange(startTime,
+                                stopTime,
+                                iRepositioning,
+                                end_is_set) != true)
+    {
+        return false;
+    }
+
+    if (mlExtIntf->setPlayRange(startTime, stopTime, iRepositioning) != true)
+    {
+        return false;
+    }
+    return true;
+}
+
+void PVMFSMRTSPUnicastNode::HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent)
+{
+    if (SupressInfoEvent())
+    {
+        PVMF_SM_RTSP_LOGINFO((0, "PVMFSMRTSPUnicastNode:HandleNodeInformationalEvent Supress info event %u", aEvent.GetEventType()));
+        return;
+    }
+
+    PVMFAsyncEvent event = OSCL_CONST_CAST(PVMFAsyncEvent, aEvent);
+    PVMFEventType infoEvent = aEvent.GetEventType();
+    if (infoEvent == PVMFInfoEndOfData)
+    {
+        /* Notify jitter buffer */
+        PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+        if (iJitterBufferNodeContainer == NULL)
+        {
+            OSCL_LEAVE(OsclErrBadHandle);
+            return;
+        }
+        PVMFJitterBufferExtensionInterface* jbExtIntf =
+            (PVMFJitterBufferExtensionInterface*)
+            (iJitterBufferNodeContainer->iExtensions[0]);
+        jbExtIntf->NotifyOutOfBandEOS();
+    }
+    else if (infoEvent == PVMFInfoPlayListClipTransition)
+    {
+        if (iPlaylistPlayInProgress)
+        {
+            iPlaylistPlayInProgress = false;
+            PVMFSMFSPChildNodeContainer* iSessionControllerNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_RTSP_SESSION_CONTROLLER_NODE);
+            if (iSessionControllerNodeContainer == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (iJitterBufferNodeContainer == NULL)
+            {
+                OSCL_LEAVE(OsclErrBadHandle);
+                return;
+            }
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)
+                (iJitterBufferNodeContainer->iExtensions[0]);
+
+            PVMFRTSPClientEngineNodePlaylistInfoType *myType = (PVMFRTSPClientEngineNodePlaylistInfoType*)(aEvent.GetEventData());
+            if (myType == NULL)
+            {//hang?
+                PVMF_SM_RTSP_LOGERROR((0, "PVMFSMRTSPUnicastNode::HandleNodeInformationalEvent - PVMFInfoPlayListClipTransition No event data - context=0x%x, event data=0x%x", aEvent.GetContext(), aEvent.GetEventData()));
+                if (IsBusy())
+                {
+                    Cancel();
+                    RunIfNotReady();
+                }
+                return;
+            }
+
+            NptTimeFormat npt_start;
+            npt_start.npt_format = NptTimeFormat::NPT_SEC;
+            npt_start.npt_sec.sec = myType->iPlaylistNPTSec;
+            npt_start.npt_sec.milli_sec = myType->iPlaylistNPTMillsec;
+
+            jbExtIntf->PurgeElementsWithNPTLessThan(npt_start);
+            iSessionControllerNodeContainer->iNodeCmdState = PVMFSMFSP_NODE_CMD_IDLE;
+            CompleteStart();
+
+        }
+
+        PVMFNodeInterface::ReportInfoEvent(event);
+    }
+    else if (infoEvent == PVMFInfoSourceOverflow)
+    {
+        /* Make note of the overflow */
+        oAutoReposition = true;
+        PVMFNodeInterface::ReportInfoEvent(event);
+    }
+    else
+    {
+        /* Just pass the info event up */
+        PVMFNodeInterface::ReportInfoEvent(event);
+    }
+}
+bool PVMFSMRTSPUnicastNode::CanPerformRepositioning(bool aRandAccessDenied)
+{
+
+    if ((aRandAccessDenied == true) ||
+            (iSessionStopTimeAvailable == false) ||
+            (((int32)iRepositionRequestedStartNPTInMS < (int32)iSessionStartTime) ||
+             ((int32)iRepositionRequestedStartNPTInMS > (int32)iSessionStopTime)))
+    {
+        /*
+         * Implies an open ended session or invalid request time
+         * - no pause or reposition
+         */
+        return false;
+
+    }
+    return true;
+
+}
+
+bool
+PVMFSMRTSPUnicastNode::CheckChildrenNodesStop()
+{
+
+    {
+        for (uint32 i = 0; i < iFSPChildNodeContainerVec.size(); i++)
+        {
+            if (iFSPChildNodeContainerVec[i].iNodeCmdState != PVMFSMFSP_NODE_CMD_IDLE)
+            {
+                return false;
+            }
+        }
+    }
+    return true;
+}
+
+void PVMFSMRTSPUnicastNode::CleanUp()
+{
+    DestroyChildNodes();
+    DestroyPayloadParserRegistry();
+    ResetNodeParams();
+    iLogger = NULL;
+}
+
+void PVMFSMRTSPUnicastNode::PopulateDRMInfo()
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::PopulateDRMInfo() In"));
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFSMRTSPUnicastNode::PopulateDRMInfo() - CPM not supported yet"));
+}
+
+void PVMFSMRTSPUnicastNode::ResetNodeParams(bool aReleaseMemmory)
+{
+    iTrackInfoVec.clear();
+    iSdpInfo.Unbind();
+    PVMFSMFSPBaseNode::ResetNodeParams(aReleaseMemmory);
+}
+
+void PVMFSMRTSPUnicastNode::GetMaxMediaTS()
+{
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+
+    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    PVMFSMFSPChildNodeContainer* iMediaLayerNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_MEDIA_LAYER_NODE);
+    if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
+    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
+        (PVMFMediaLayerNodeExtensionInterface*)
+        (iMediaLayerNodeContainer->iExtensions[0]);
+    if (mlExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
+    PVMFPortInterface* mlInPort = iMediaLayerNodeContainer->iInputPorts[0];
+
+    if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+            (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+    {
+        iActualMediaDataTS = jbExtIntf->getMaxMediaDataTS();
+        if (iActualMediaDataTSPtr != NULL)
+        {
+            *iActualMediaDataTSPtr = iActualMediaDataTS;
+            PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetActualMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
+                                            iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
+        }
+        if (iPVMFDataSourcePositionParamsPtr != NULL)
+        {
+            iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS = iActualMediaDataTS;
+            PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetActualMediaTSAfterSeek - ActualMediaDataTS=%d",
+                                            iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS));
+        }
+    }
+    else if (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+    {
+        iActualRepositionStartNPTInMS = jbExtIntf->getActualMediaDataTSAfterSeek();
+        *iActualRepositionStartNPTInMSPtr = iActualRepositionStartNPTInMS;
+        iActualMediaDataTS = mlExtIntf->getMaxOutPortTimestamp(mlInPort);
+        *iActualMediaDataTSPtr = iActualMediaDataTS;
+        PVMF_SM_RTSP_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetActualMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
+                                        iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
+    }
+}
+
+
+void PVMFSMRTSPUnicastNode::DoSetDataSourcePositionOverflow(PVMFSMFSPBaseNodeCommand& aCmd)
+{
+    PVMF_SM_RTSP_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoSetDataSourcePositionOverflow - In"));
+
+    iActualRepositionStartNPTInMSPtr = NULL;
+    iActualMediaDataTSPtr = NULL;
+    iPVMFDataSourcePositionParamsPtr = NULL;
+    iJumpToIFrame = false;
+    PVMFTimestamp aTargetNPT;
+    bool aSeekToSyncPoint;
+    aCmd.PVMFSMFSPBaseNodeCommand::Parse(aTargetNPT,
+                                         iActualRepositionStartNPTInMSPtr,
+                                         iActualMediaDataTSPtr,
+                                         aSeekToSyncPoint,
+                                         iStreamID);
+
+    PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+        getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
+    PVMFJitterBufferExtensionInterface* jbExtIntf =
+        (PVMFJitterBufferExtensionInterface*)
+        (iJitterBufferNodeContainer->iExtensions[0]);
+
+    jbExtIntf->SendBOSMessage(iStreamID);
+    oAutoReposition = false;
+
+    if (iInterfaceState == EPVMFNodeStarted)
+    {
+        bool oRandAccessDenied = false;
+
+        if ((iSessionSourceInfo->_sessionType != PVMF_MIME_DATA_SOURCE_RTSP_URL) &&
+                (iSessionSourceInfo->_sessionType != PVMF_MIME_DATA_SOURCE_SDP_FILE))
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid Session Type"));
+            oRandAccessDenied = true;
+        }
+
+        if (oRandAccessDenied == true)
+        {
+            /*
+            * Implies an open ended session or invalid request time
+            * - no pause or reposition
+            	*/
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid Args"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+            return;
+        }
+
+        /* Put the jitter buffer into a state of transition - only if the playlist switch mode is 0*/
+
+        PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+            getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
+        PVMFJitterBufferExtensionInterface* jbExtIntf =
+            (PVMFJitterBufferExtensionInterface*)
+            (iJitterBufferNodeContainer->iExtensions[0]);
+        jbExtIntf->PrepareForRepositioning();
+        if ((iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_RTSP_URL) ||
+                (iSessionSourceInfo->_sessionType == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+        {
+            // Purge JB at this point
+            GetMaxMediaTS();
+            *iActualMediaDataTSPtr = iActualMediaDataTS;
+            PVMFSMFSPChildNodeContainer* iJitterBufferNodeContainer =
+                getChildNodeContainer(PVMF_SM_FSP_JITTER_BUFFER_NODE);
+            if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
+            PVMFJitterBufferExtensionInterface* jbExtIntf =
+                (PVMFJitterBufferExtensionInterface*)
+                (iJitterBufferNodeContainer->iExtensions[0]);
+
+            // Convert iActualMediaDataTS to NPT time format
+            NptTimeFormat npt_start;
+            npt_start.npt_format = NptTimeFormat::NPT_SEC;
+            npt_start.npt_sec.sec = iActualMediaDataTS / 1000;
+            npt_start.npt_sec.milli_sec = iActualMediaDataTS - 1000 * (iActualMediaDataTS / 1000);
+
+            jbExtIntf->PurgeElementsWithNPTLessThan(npt_start);
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+        }
+        else
+        {
+            PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid Session Type"));
+            CommandComplete(iInputCommands, aCmd, PVMFFailure);
+        }
+    }
+    else
+    {
+        PVMF_SM_RTSP_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePositionOverflow - Invalid State"));
+        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
+    }
+    return;
+}
diff --git a/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.h b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.h
new file mode 100644
index 0000000..2b9536c
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_fsp_rtsp_unicast.h
@@ -0,0 +1,377 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_RTSP_UNICAST_H
+#define PVMF_SM_FSP_RTSP_UNICAST_H
+
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#include "pvmf_sm_fsp_base_impl.h"
+#endif
+
+#ifndef __SDP_INFO_H__
+#include "sdp_info.h"
+#endif
+
+#ifndef PVMF_STREAMING_REAL_INTERFACES_INCLUDED
+#include "pvmf_streaming_real_interfaces.h"
+#endif
+
+#ifndef PAYLOAD_PARSER_H_INCLUDED
+#include "payload_parser.h"
+#endif
+
+#ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
+#include "pvmf_media_presentation_info.h"
+#endif
+
+#ifndef PVMF_JITTER_BUFFER_PORT_H_INCLUDED
+#include "pvmf_jitter_buffer_port.h"
+#endif
+/**
+ * Macros for calling PVLogger
+ */
+#define PVMF_SM_RTSP_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define PVMF_SM_RTSP_LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_NOTICE,m);
+#define PVMF_SM_RTSP_LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
+#define PVMF_SM_RTSP_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_STACK_TRACE,m);
+#define PVMF_SM_RTSP_LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m);
+#define PVMF_SM_RTSP_LOGINFO(m) PVMF_SM_RTSP_LOGINFOMED(m)
+#define PVMF_SM_RTSP_LOG_COMMAND_SEQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iCommandSeqLogger,PVLOGMSG_DEBUG,m);
+#define PVMF_SM_RTSP_LOG_COMMAND_REPOS(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m);
+
+/*
+ * Track related structures
+ */
+class PVMFRTSPTrackInfo
+{
+    public:
+        PVMFRTSPTrackInfo()
+        {
+            trackID = 0;
+            rdtStreamID = 0;
+            portTag = 0;
+            bitRate = 0;
+            trackTimeScale = 1;
+            iNetworkNodePort = NULL;
+            iJitterBufferInputPort = NULL;
+            iJitterBufferOutputPort = NULL;
+            iMediaLayerInputPort = NULL;
+            iMediaLayerOutputPort = NULL;
+            iJitterBufferRTCPPort = NULL;
+            iNetworkNodeRTCPPort = NULL;
+            iSessionControllerOutputPort = NULL;
+            iSessionControllerFeedbackPort = NULL;
+            iRTPSocketID = 0;
+            iRTCPSocketID = 0;
+            iRateAdaptation = false;
+            iRateAdaptationFeedBackFrequency = 0;
+            iFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+            iRTCPBwSpecified = false;
+            iTrackDisable = false;
+        };
+
+        PVMFRTSPTrackInfo(const PVMFRTSPTrackInfo& a)
+        {
+            trackID = a.trackID;
+            rdtStreamID = a.rdtStreamID;
+            portTag = a.portTag;
+            bitRate = a.bitRate;
+            trackTimeScale = a.trackTimeScale;
+            iTrackConfig = a.iTrackConfig;
+            iTransportType = a.iTransportType;
+            iFormatType = a.iFormatType;
+            iMimeType = a.iMimeType;
+            iNetworkNodePort = a.iNetworkNodePort;
+            iJitterBufferInputPort = a.iJitterBufferInputPort;
+            iJitterBufferOutputPort = a.iJitterBufferOutputPort;
+            iMediaLayerInputPort = a.iMediaLayerInputPort;
+            iMediaLayerOutputPort = a.iMediaLayerOutputPort;
+            iJitterBufferRTCPPort = a.iJitterBufferRTCPPort;
+            iNetworkNodeRTCPPort = a.iNetworkNodeRTCPPort;
+            iSessionControllerOutputPort = a.iSessionControllerOutputPort;
+            iSessionControllerFeedbackPort = a.iSessionControllerFeedbackPort;
+            iRTPSocketID = a.iRTPSocketID;
+            iRTCPSocketID = a.iRTCPSocketID;
+            iRateAdaptation = a.iRateAdaptation;
+            iRateAdaptationFeedBackFrequency = a.iRateAdaptationFeedBackFrequency;
+            iRTCPBwSpecified = a.iRTCPBwSpecified;
+            iTrackDisable = a.iTrackDisable;
+            iRR = a.iRR;
+            iRS = a.iRS;
+
+        };
+
+        PVMFRTSPTrackInfo& operator=(const PVMFRTSPTrackInfo& a)
+        {
+            if (&a != this)
+            {
+                trackID = a.trackID;
+                rdtStreamID = a.rdtStreamID;
+                portTag = a.portTag;
+                bitRate = a.bitRate;
+                trackTimeScale = a.trackTimeScale;
+                iTrackConfig = a.iTrackConfig;
+                iTransportType = a.iTransportType;
+                iFormatType = a.iFormatType;
+                iMimeType = a.iMimeType;
+                iNetworkNodePort = a.iNetworkNodePort;
+                iJitterBufferInputPort = a.iJitterBufferInputPort;
+                iJitterBufferOutputPort = a.iJitterBufferOutputPort;
+                iMediaLayerInputPort = a.iMediaLayerInputPort;
+                iMediaLayerOutputPort = a.iMediaLayerOutputPort;
+                iJitterBufferRTCPPort = a.iJitterBufferRTCPPort;
+                iNetworkNodeRTCPPort = a.iNetworkNodeRTCPPort;
+                iSessionControllerOutputPort = a.iSessionControllerOutputPort;
+                iSessionControllerFeedbackPort = a.iSessionControllerFeedbackPort;
+                iRTPSocketID = a.iRTPSocketID;
+                iRTCPSocketID = a.iRTCPSocketID;
+                iRateAdaptation = a.iRateAdaptation;
+                iRateAdaptationFeedBackFrequency = a.iRateAdaptationFeedBackFrequency;
+                iRTCPBwSpecified = a.iRTCPBwSpecified;
+                iTrackDisable = a.iTrackDisable;
+                iRR = a.iRR;
+                iRS = a.iRS;
+
+            }
+            return *this;
+        };
+
+        virtual ~PVMFRTSPTrackInfo() {};
+
+        uint32 trackID;
+        uint32 rdtStreamID;
+        uint32 portTag;
+        uint32 bitRate;
+        uint32 trackTimeScale;
+        OsclRefCounterMemFrag iTrackConfig;
+        OSCL_HeapString<OsclMemAllocator> iTransportType;
+        PVMFFormatType iFormatType;
+        OSCL_HeapString<OsclMemAllocator> iMimeType;
+        PVMFPortInterface* iNetworkNodePort;
+        PVMFPortInterface* iJitterBufferInputPort;
+        PVMFPortInterface* iJitterBufferOutputPort;
+        PVMFPortInterface* iMediaLayerInputPort;
+        PVMFPortInterface* iMediaLayerOutputPort;
+        PVMFPortInterface* iJitterBufferRTCPPort;
+        PVMFPortInterface* iNetworkNodeRTCPPort;
+        PVMFPortInterface* iSessionControllerOutputPort;
+        PVMFPortInterface* iSessionControllerFeedbackPort;
+
+        uint32 iRTPSocketID;
+        uint32 iRTCPSocketID;
+        bool   iRateAdaptation;
+        uint32 iRateAdaptationFeedBackFrequency;
+
+        // RTCP bandwidth related
+        bool   iRTCPBwSpecified;
+        uint32 iRR;
+        uint32 iRS;
+
+        //Check track disable or not
+        bool iTrackDisable;
+
+
+};
+typedef Oscl_Vector<PVMFRTSPTrackInfo, OsclMemAllocator> PVMFRTSPTrackInfoVector;
+
+class PVMFSMRTSPUnicastNode: public PVMFSMFSPBaseNode
+{
+    public:
+        static PVMFSMRTSPUnicastNode* New(int32 aPriority);
+        virtual ~PVMFSMRTSPUnicastNode();
+
+
+        //Function to handle command completion from child nodes
+        /* From PVMFNodeCmdStatusObserver */
+        virtual void NodeCommandCompleted(const PVMFCmdResp& aResponse);
+
+        /* From PVMFDataSourceInitializationExtensionInterface */
+        virtual PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL,
+                PVMFFormatType& aSourceFormat,
+                OsclAny* aSourceData);
+        virtual PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        virtual PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
+
+        /* From PVMFTrackSelectionExtensionInterface */
+        virtual PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
+        virtual PVMFStatus SelectTracks(PVMFMediaPresentationInfo& aInfo);
+
+        /* From PVMFMetadataExtensionInterface */
+        virtual uint32 GetNumMetadataKeys(char* aQueryKeyString = NULL);
+        virtual uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
+        PVMFStatus DoGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFStatus DoGetMetadataValues(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFStatus GetRTSPPluginSpecificValues(PVMFSMFSPBaseNodeCommand& aCmd);
+        virtual PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
+                uint32 aStartingKeyIndex,
+                uint32 aEndKeyIndex);
+        virtual PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
+                uint32 aStartingValueIndex,
+                uint32 aEndValueIndex);
+
+        virtual void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        virtual PVMFStatus getParametersSync(PvmiMIOSession aSession,
+                                             PvmiKeyType aIdentifier,
+                                             PvmiKvp*& aParameters,
+                                             int& aNumParamElements,
+                                             PvmiCapabilityContext aContext);
+        virtual PVMFStatus releaseParameters(PvmiMIOSession aSession,
+                                             PvmiKvp* aParameters,
+                                             int num_elements);
+
+        virtual void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        virtual void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                                          PvmiKvp* aParameters, int num_parameter_elements);
+        virtual void DeleteContext(PvmiMIOSession aSession,
+                                   PvmiCapabilityContext& aContext);
+        virtual void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                       int num_elements, PvmiKvp * & aRet_kvp);
+        virtual uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        virtual PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
+                                                PvmiKvp* aParameters,
+                                                int num_elements);
+        /**/
+        virtual void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent);
+        PVMFStatus ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+                                        PVMFTimestamp aActualNPT,
+                                        PVMFTimestamp aActualMediaDataTS,
+                                        PVMFTimestamp& aSkipTimeStamp,
+                                        PVMFTimestamp& aStartNPT);
+    private:
+        PVMFSMRTSPUnicastNode(int32 aPriority);
+        void Construct();
+        void CreateCommandQueues();
+        void CreateChildNodes();
+        void DestroyChildNodes();
+        void CleanUp();
+
+        virtual bool ProcessCommand(PVMFSMFSPBaseNodeCommand&);
+
+        //Functions to service commands queued up in input command Q by base class
+        //node commands
+        void DoQueryInterface(PVMFSMFSPBaseNodeCommand&);
+        void DoRequestPort(PVMFSMFSPBaseNodeCommand&);
+        void DoReleasePort(PVMFSMFSPBaseNodeCommand&);
+        void DoInit(PVMFSMFSPBaseNodeCommand&);
+        void DoPrepare(PVMFSMFSPBaseNodeCommand&);
+        void DoStart(PVMFSMFSPBaseNodeCommand&);
+        void DoStop(PVMFSMFSPBaseNodeCommand&);
+        void DoPause(PVMFSMFSPBaseNodeCommand&);
+
+
+        void DoSetDataSourcePosition(PVMFSMFSPBaseNodeCommand&);
+        void DoSetDataSourcePositionPlayList(PVMFSMFSPBaseNodeCommand&);
+        void DoQueryDataSourcePosition(PVMFSMFSPBaseNodeCommand&);
+        void DoSetDataSourcePositionOverflow(PVMFSMFSPBaseNodeCommand&);
+
+        bool CompleteFeedBackPortsSetup();
+        bool SendSessionControlPrepareCompleteParams();
+        bool SendSessionControlStartCompleteParams();
+
+        void GetActualMediaTSAfterSeek();
+        void GetMaxMediaTS();
+
+        void ResetStopCompleteParams();
+
+        void QueryChildNodesExtentionInterface();
+
+        //RequestPort
+        PVMFRTSPTrackInfo* FindTrackInfo(uint32 tag);
+
+        //Init
+        PVMFStatus DoPreInit(PVMFSMFSPBaseNodeCommand& aCmd);
+        PVMFStatus ProcessSDP();
+        PVMFStatus PopulateAvailableMetadataKeys();
+        virtual bool RequestUsageComplete()
+        {
+            return true;
+        }
+
+        //Compute Jitter buffer mem pool size
+        uint32 GetJitterBufferMemPoolSize(PVMFJitterBufferNodePortTag aJBNodePortTag, PVMFRTSPTrackInfo& aRTSPTrackInfo);
+
+        //Graph Construction
+        PVMFStatus DoGraphConstruct();
+        bool GraphConnect();
+        bool ReserveSockets();
+        bool RequestNetworkNodePorts(int32 portTag, uint32& numPortsRequested);
+        bool RequestJitterBufferPorts(int32 portType, uint32 &numPortsRequested);
+        bool RequestMediaLayerPorts(int32 portType, uint32& numPortsRequested);
+        bool SendSessionSourceInfoToSessionController();
+        bool PopulateTrackInfoVec();
+        PVMFStatus ConnectPortPairs(PVMFPortInterface* aPort1, PVMFPortInterface* aPort2);
+        bool ConstructGraphFor3GPPUDPStreaming();
+        void CompleteGraphConstruct();
+        PVMFStatus  InitMetaData();
+        virtual void PopulateDRMInfo();
+
+        void DoSetDataSourcePosition();
+        bool DoRepositioningPause3GPPStreaming();
+        PVMFStatus DoRepositioningStart3GPPStreaming();
+        bool DoRepositioningStart3GPPPlayListStreamingDuringPlay();
+        bool DoRepositioningStart3GPPPlayListStreaming();
+
+
+        PVMFStatus SetRTSPPlaybackRange();
+        bool CanPerformRepositioning(bool aRandAccessDenied);
+
+        void HandleChildNodeCommandCompletion(const PVMFCmdResp& , bool&);
+
+        void CompleteInit();
+        bool CheckChildrenNodesInit();
+
+        void CompletePrepare();
+        bool CheckChildrenNodesPrepare();
+
+        void CompleteStart();
+        bool CheckChildrenNodesStart();
+
+        void CompleteStop();
+        bool CheckChildrenNodesStop();
+
+        void CompletePause();
+        bool CheckChildrenNodesPause();
+
+        //For parsing the possible payloads received by streaming protocols
+        void PopulatePayloadParserRegistry();
+        void DestroyPayloadParserRegistry();
+
+        void HandleSocketNodeCommandCompleted(const PVMFCmdResp&, bool& aPerformErrHandling);
+        void HandleRTSPSessionControllerCommandCompleted(const PVMFCmdResp&, bool& aPerformErrHandling);
+        void HandleJitterBufferCommandCompleted(const PVMFCmdResp&, bool& aPerformErrHandling);
+        void HandleMediaLayerCommandCompleted(const PVMFCmdResp&, bool& aPerformErrHandling);
+        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
+                                      int32 aIndex, PvmiKvpAttr reqattr);
+        PVMFStatus VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set);
+        void setJitterBufferDurationInMilliSeconds(uint32 duration);
+        bool IsFSPInternalCmd(PVMFCommandId aId);
+        void addRef();
+        void removeRef();
+        void ResetNodeParams(bool aReleaseMemmory = true);
+
+
+        uint32 iJitterBufferDurationInMilliSeconds;
+
+        PVMFMediaPresentationInfo iCompleteMediaPresetationInfo;
+        PVMFMediaPresentationInfo iSelectedMediaPresetationInfo;
+
+        PVMFRTSPTrackInfoVector	iTrackInfoVec;
+        OsclSharedPtr<SDPInfo> iSdpInfo;
+        bool oAutoReposition;
+        bool iPauseDenied;	//For live streaming sessions, pause is denied.
+};
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_capandconfig.h b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_capandconfig.h
new file mode 100644
index 0000000..0e3dd0d
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_capandconfig.h
@@ -0,0 +1,74 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_RTSP_UNICAST_CAPANDCONFIG_H
+#define PVMF_SM_RTSP_UNICAST_CAPANDCONFIG_H
+///////////////////////////////////////////////////////////////////////////////
+//
+// Capability and config interface related constants and definitions
+//   - based on pv_player_engine.h
+//
+///////////////////////////////////////////////////////////////////////////////
+struct StreamingManagerKeyStringData
+{
+    char iString[64];
+    PvmiKvpType iType;
+    PvmiKvpValueType iValueType;
+};
+// The number of characters to allocate for the key string
+#define SMCONFIG_KEYSTRING_SIZE 128
+
+static const StreamingManagerKeyStringData StreamingManagerConfig_BaseKeys[] =
+{
+    {"delay", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"jitterBufferNumResize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"jitterBufferResizeSize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"jitterbuffer-inactivity-duration", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"user-agent", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_WCHARPTR},
+    {"keep-alive-interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"keep-alive-during-play", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
+    {"rtsp-timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"rebuffering-threshold", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
+    {"disable-firewall-packets", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
+};
+
+static const uint StreamingManagerConfig_NumBaseKeys =
+    (sizeof(StreamingManagerConfig_BaseKeys) /
+     sizeof(StreamingManagerKeyStringData));
+
+enum BaseKeys_IndexMapType
+{
+    BASEKEY_DELAY = 0,
+    BASEKEY_JITTERBUFFER_NUMRESIZE,
+    BASEKEY_JITTERBUFFER_RESIZESIZE,
+    BASEKEY_JITTERBUFFER_MAX_INACTIVITY_DURATION,
+    BASEKEY_SESSION_CONTROLLER_USER_AGENT,
+    BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL,
+    BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY,
+    BASEKEY_SESSION_CONTROLLER_RTSP_TIMEOUT,
+    BASEKEY_REBUFFERING_THRESHOLD,
+    BASEKEY_DISABLE_FIREWALL_PACKETS
+};
+
+typedef struct tagPVMFSMClientParams
+{
+    OSCL_wHeapString<OsclMemAllocator> _userAgent;
+    OSCL_wHeapString<OsclMemAllocator> _userNetwork;
+    OSCL_wHeapString<OsclMemAllocator> _deviceInfo;
+} PVMFSMClientParams;
+
+#endif
diff --git a/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_node_factory.cpp b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_node_factory.cpp
new file mode 100644
index 0000000..abd6baa
--- /dev/null
+++ b/nodes/streaming/streamingmanager/plugins/rtspunicast/src/pvmf_sm_rtsp_unicast_node_factory.cpp
@@ -0,0 +1,60 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef OSCL_EXCEPTION_H_INCLUDED
+#include "oscl_exception.h"
+#endif
+#ifndef PVMF_SM_RTSP_UNICAST_NODE_FACTORY_H_INCLUDED
+#include "pvmf_sm_rtsp_unicast_node_factory.h"
+#endif
+
+#ifndef PVMF_SM_FSP_RTSP_UNICAST_H
+#include "pvmf_sm_fsp_rtsp_unicast.h"
+#endif
+
+OSCL_EXPORT_REF PVMFSMFSPBaseNode*
+PVMFSMRTSPUnicastNodeFactory::CreateSMRTSPUnicastNodeFactory(int32 aPriority)
+{
+    PVMFSMFSPBaseNode* smRtspUnicastNode = NULL;
+    int32 err;
+    OSCL_TRY(err,
+
+             smRtspUnicastNode = PVMFSMRTSPUnicastNode::New(aPriority);
+            );
+
+    if (err != OsclErrNone)
+    {
+        OSCL_LEAVE(err);
+    }
+
+    return (smRtspUnicastNode);
+}
+
+OSCL_EXPORT_REF bool PVMFSMRTSPUnicastNodeFactory::DeleteSMRTSPUnicastNodeFactory(PVMFSMFSPBaseNode* aSMFSPNode)
+{
+
+    bool retval = false;
+
+    if (aSMFSPNode)
+    {
+        OSCL_DELETE(aSMFSPNode);
+        aSMFSPNode = NULL;
+        retval = true;
+    }
+
+    return retval;
+}
diff --git a/nodes/streaming/streamingmanager/src/pvmf_sm_fsp_registry.h b/nodes/streaming/streamingmanager/src/pvmf_sm_fsp_registry.h
new file mode 100644
index 0000000..c0e51fa
--- /dev/null
+++ b/nodes/streaming/streamingmanager/src/pvmf_sm_fsp_registry.h
@@ -0,0 +1,120 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_SM_FSP_REGISTRY_H
+#define PVMF_SM_FSP_REGISTRY_H
+#ifndef PVMF_SM_FSP_REGISTRY_INTERFACE_H_INCLUDED
+#include "pvmf_sm_fsp_registry_interface.h"
+#endif
+// CLASS DECLARATION
+/**
+ * PVMFSMFSPRegistry maintains a list of fsps available which is queryable.
+ * The utility also allows the fsp specified by PVUuid to be created and returned
+ **/
+class PVMFSMFSPRegistry : public PVMFFSPRegistryInterface
+{
+    public:
+        /**
+         * Object Constructor function
+         **/
+        PVMFSMFSPRegistry();
+
+        /**
+         * The QueryRegistry for PVMFSMFSPRegistry. Used mainly for Seaching of the UUID
+         * whether it is available or not & returns Success if it is found else failure.
+         *
+         * @param aInputType Input Format Type
+         *
+         * @param aOutputType Output Format Type
+         *
+         * @param aUuids Reference to the UUID registered
+         *
+         * @returns Success or Failure
+         **/
+        virtual PVMFStatus QueryRegistry(PVMFFormatType& aInputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids);
+
+        /**
+         * The CreateSMFSP for PVMFSMFSPRegistry. Used mainly for creating a SMFSP.
+         *
+         * @param aUuid UUID returned by the QueryRegistry
+         *
+         * @returns a pointer to SMFSP
+         **/
+        virtual PVMFSMFSPBaseNode* CreateSMFSP(PVUuid& aUuid);
+
+        /**
+         * The ReleaseSMFSP for PVMFSMFSPRegistry. Used for releasing a SMFSP.
+         *
+         * @param aUuid UUID recorded at the time of creation of the SMFSP.
+         *
+         * @param Pointer to the SMFSP to be released
+         *
+         * @returns True or False
+         **/
+        virtual bool ReleaseSMFSP(PVUuid& aUuid, PVMFSMFSPBaseNode *aSMFSP);
+
+#ifdef USE_LOADABLE_MODULES
+        /**
+         * The RegisterSMFSP for PVMFSMFSPRegistry. Used for registering SMFSPs through the SMFSPInfo object.
+         *
+         * @param aSMFSPInfo SMFSPInfo object passed to the regisry class. This contains all SMFSPs that need to be registered.
+         *
+         **/
+        virtual void RegisterSMFSP(const PVMFSMFSPInfo& aSMFSPInfo)
+        {
+            iType.push_back(aSMFSPInfo);
+        };
+
+        /**
+         * UnregisterSMFSP for PVMFSMFSPRegistry. Used to remove SMFSPs from dynamic registry.
+         *
+         * @param aSMFSPInfo SMFSPInfo object passed to the regisry class. This contains all SMFSPs that need to be unregistered.
+          *
+         **/
+        virtual void UnregisterSMFSP(const PVMFSMFSPInfo& aSMFSPInfo)
+        {
+            OSCL_UNUSED_ARG(aSMFSPInfo);
+            // do nothing
+        };
+#else
+        /**
+         * The RegisterSMFSP for PVMFSMFSPRegistry. Used for registering SMFSPs through the SMFSPInfo object.
+         *
+         * @param aSMFSPInfo SMFSPInfo object passed to the regisry class. This contains all SMFSPs that need to be registered.
+         *
+         **/
+        virtual void RegisterSMFSP(const PVMFSMFSPInfo& aSMFSPInfo) {};
+
+        /**
+         * The PopulateRegistry for PVMFSMFSPRegistry. Populates the registry by retrieving all the information for SMFSP.
+         * @param aConfigFilePath File path for the Configuration file which stores the mapping
+         *  between OsclUuids and SharedLibrary path names
+         *
+         **/
+        virtual void PopulateRegistry(const OSCL_String& aConfigFilePath) {};
+#endif
+
+        /**
+         * Object destructor function
+         **/
+        virtual ~PVMFSMFSPRegistry();
+
+    private:
+        Oscl_Vector<PVMFSMFSPInfo, OsclMemAllocator> iType;
+
+};
+#endif
diff --git a/nodes/streaming/streamingmanager/src/pvmf_sm_node_factory.cpp b/nodes/streaming/streamingmanager/src/pvmf_sm_node_factory.cpp
index 9c0c89a..043118e 100644
--- a/nodes/streaming/streamingmanager/src/pvmf_sm_node_factory.cpp
+++ b/nodes/streaming/streamingmanager/src/pvmf_sm_node_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,9 +27,7 @@
 #ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
 #include "pvmf_streaming_manager_node.h"
 #endif
-#ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED
-#include "pvmf_streaming_manager_internal.h"
-#endif
+
 
 OSCL_EXPORT_REF PVMFNodeInterface*
 PVMFStreamingManagerNodeFactory::CreateStreamingManagerNode(int32 aPriority)
@@ -42,7 +40,7 @@
              /*
               * Create Streaming Manager Node
               */
-             streamingManagerNode = OSCL_NEW(PVMFStreamingManagerNode, (aPriority));
+             streamingManagerNode = PVMFStreamingManagerNode::New(aPriority);
             );
 
     if (err != OsclErrNone)
@@ -54,10 +52,22 @@
 
 OSCL_EXPORT_REF bool PVMFStreamingManagerNodeFactory::DeleteStreamingManagerNode(PVMFNodeInterface* aNode)
 {
+    bool retval = false;
+
     if (aNode)
     {
         OSCL_DELETE(aNode);
-        return true;
+        retval = true;
+        aNode = NULL;
     }
-    return false;
+
+    /*if(EPVMFNodeIdle == aNode->GetState())
+    {
+    	if(aNode)
+    	{
+    		OSCL_DELETE(aNode);
+    		retval = true;
+    	}
+    }*/
+    return retval;
 }
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_asf_nosupport.cpp b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_asf_nosupport.cpp
deleted file mode 100644
index 5c68cee..0000000
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_asf_nosupport.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED
-#include "pvmf_streaming_manager_internal.h"
-#endif
-
-#ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
-#include "pvmf_streaming_manager_node.h"
-#endif
-
-StreamAsfHeader::~StreamAsfHeader()
-{
-}
-
-bool PVMFStreamingManagerNode::IsAsfStreamingSupported()
-{
-    return false;
-}
-
-void PVMFStreamingManagerNode::Asf_CompletePreInit()
-{
-}
-
-bool PVMFStreamingManagerNode::Asf_PopulateTrackInfoVec()
-{
-    return false;
-}
-
-bool PVMFStreamingManagerNode::Asf_SetSocketNodePortAllocator()
-{
-    return false;
-}
-
-PVMFStatus PVMFStreamingManagerNode::Asf_RecognizeAndProcessHeader()
-{
-    return PVMFFailure;
-}
-
-PVMFStatus PVMFStreamingManagerNode::Asf_GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo)
-{
-    OSCL_UNUSED_ARG(aInfo);
-    return PVMFFailure;
-}
-
-PVMFStatus PVMFStreamingManagerNode::Asf_SelectTracks(PVMFMediaPresentationInfo& aInfo, PVMFSessionId s)
-{
-    OSCL_UNUSED_ARG(aInfo);
-    OSCL_UNUSED_ARG(s);
-    return PVMFFailure;
-}
-
-PVMFStatus PVMFStreamingManagerNode::Asf_InitMetaData()
-{
-    return PVMFFailure;
-}
-
-bool PVMFStreamingManagerNode::Asf_Doprepare(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    OSCL_UNUSED_ARG(aCmd);
-    return false;
-}
-
-void PVMFStreamingManagerNode::Asf_PopulateDRMInfo()
-{
-}
-
-PVMFStatus PVMFStreamingManagerNode::Asf_GetExtendedMetaData(PvmiKvp& KeyVal, uint32 aIndex)
-{
-    OSCL_UNUSED_ARG(KeyVal);
-    OSCL_UNUSED_ARG(aIndex);
-    return PVMFErrNotSupported;
-}
-
-PVMFStatus PVMFStreamingManagerNode::Asf_ConvertWMPictureToAPIC(PvmfApicStruct*& aAPICStruct,
-        bool* aImageTooBig,
-        uint32 aMaxSize,
-        uint32* aImageSize,
-        uint32 aPicIndex,
-        uint32 aMetadataindex)
-{
-    OSCL_UNUSED_ARG(aAPICStruct);
-    OSCL_UNUSED_ARG(aImageTooBig);
-    OSCL_UNUSED_ARG(aMaxSize);
-    OSCL_UNUSED_ARG(aImageSize);
-    OSCL_UNUSED_ARG(aPicIndex);
-    OSCL_UNUSED_ARG(aMetadataindex);
-
-    return false;
-}
-
-void PVMFStreamingManagerNode::Asf_DeleteAPICStruct(PvmfApicStruct*& aAPICStruct)
-{
-    OSCL_UNUSED_ARG(aAPICStruct);
-}
-
-
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_cpm_support.cpp b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_cpm_support.cpp
deleted file mode 100644
index 39f9fc1..0000000
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_cpm_support.cpp
+++ /dev/null
@@ -1,668 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED
-#include "pvmf_streaming_manager_internal.h"
-#endif
-#ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
-#include "pvmf_streaming_manager_node.h"
-#endif
-#ifndef PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
-#include "pvmf_protocol_engine_node_extension.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef PVMF_SM_TUNABLES_H_INCLUDED
-#include "pvmf_sm_tunables.h"
-#endif
-#ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
-#include "pvmf_streaming_manager_node.h"
-#endif
-#ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED
-#include "pvmf_streaming_manager_internal.h"
-#endif
-#ifndef PVMF_SOCKET_NODE_H_INCLUDED
-#include "pvmf_socket_node.h"
-#endif
-#ifndef PVMF_JITTER_BUFFER_NODE_H_INCLUDED
-#include "pvmf_jitter_buffer_node.h"
-#endif
-#ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
-#include "pvmf_medialayer_node.h"
-#endif
-#ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
-#include "pvmf_media_presentation_info.h"
-#endif
-#ifndef PVMF_PROTOCOLENGINE_FACTORY_H_INCLUDED
-#include "pvmf_protocol_engine_factory.h"
-#endif
-#ifndef PVMF_PROTOCOLENGINE_DEFS_H_INCLUDED
-#include "pvmf_protocol_engine_defs.h"
-#endif
-#ifndef PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
-#include "pvmf_protocol_engine_node_extension.h"
-#endif
-#ifndef PVMF_STREAMING_DATA_SOURCE_H_INCLUDED
-#include "pvmf_streaming_data_source.h"
-#endif
-
-
-void PVMFStreamingManagerNode::InitCPM()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::InitCPM() In"));
-
-    iCPMInitCmdId = iCPM->Init();
-}
-
-void PVMFStreamingManagerNode::OpenCPMSession()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::OpenCPMSession() In"));
-
-    iCPMOpenSessionCmdId = iCPM->OpenSession(iCPMSessionID);
-}
-
-void PVMFStreamingManagerNode::CPMRegisterContent()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CPMRegisterContent() In"));
-
-    if (iSourceContextDataValid)
-    {
-        iCPMRegisterContentCmdId = iCPM->RegisterContent(iCPMSessionID,
-                                   iSessionSourceInfo->_sessionURL,
-                                   iSessionSourceInfo->_sessionType,
-                                   (OsclAny*) & iSourceContextData);
-    }
-    else
-    {
-        iCPMRegisterContentCmdId = iCPM->RegisterContent(iCPMSessionID,
-                                   iSessionSourceInfo->_sessionURL,
-                                   iSessionSourceInfo->_sessionType,
-                                   (OsclAny*) & iCPMSourceData);
-    }
-}
-
-void PVMFStreamingManagerNode::GetCPMLicenseInterface()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetCPMLicenseInterface() In"));
-
-    iCPMGetLicenseInterfaceCmdId =
-        iCPM->QueryInterface(iCPMSessionID,
-                             PVMFCPMPluginLicenseInterfaceUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMLicenseInterface));
-}
-
-void PVMFStreamingManagerNode::GetCPMCapConfigInterface()
-{
-    iCPMGetCapConfigCmdId =
-        iCPM->QueryInterface(iCPMSessionID,
-                             PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMCapConfigInterface));
-}
-
-
-bool PVMFStreamingManagerNode::GetCPMContentAccessFactory()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetCPMContentAccessFactory() In"));
-
-    PVMFStatus status = iCPM->GetContentAccessFactory(iCPMSessionID,
-                        iCPMContentAccessFactory);
-    if (status != PVMFSuccess)
-    {
-        return false;
-    }
-    return true;
-}
-
-bool PVMFStreamingManagerNode::GetCPMMetaDataExtensionInterface()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetCPMMetaDataExtensionInterface() In"));
-
-    bool retVal =
-        iCPM->queryInterface(KPVMFMetadataExtensionUuid,
-                             OSCL_STATIC_CAST(PVInterface*&, iCPMMetaDataExtensionInterface));
-    return retVal;
-}
-
-void PVMFStreamingManagerNode::RequestUsage()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::RequestUsage() In"));
-
-    PopulateDRMInfo();
-    iCPMRequestUsageId = iCPM->ApproveUsage(iCPMSessionID,
-                                            iRequestedUsage,
-                                            iApprovedUsage,
-                                            iAuthorizationDataKvp,
-                                            iUsageID,
-                                            iCPMContentAccessFactory);
-}
-
-void PVMFStreamingManagerNode::PopulateDRMInfo()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::PopulateDRMInfo() In"));
-
-    OSCL_ASSERT(iSessionSourceInfo->_sessionType ==
-                PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-
-    Asf_PopulateDRMInfo();
-}
-
-void PVMFStreamingManagerNode::SendUsageComplete()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SendUsageComplete() In"));
-
-    iCPMUsageCompleteCmdId = iCPM->UsageComplete(iCPMSessionID, iUsageID);
-}
-
-void PVMFStreamingManagerNode::CloseCPMSession()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CloseCPMSession() In"));
-
-    iCPMCloseSessionCmdId = iCPM->CloseSession(iCPMSessionID);
-}
-
-void PVMFStreamingManagerNode::ResetCPM()
-{
-    iCPMResetCmdId = iCPM->Reset();
-}
-
-void PVMFStreamingManagerNode::GetCPMMetaDataKeys()
-{
-    if (iCPMMetaDataExtensionInterface != NULL)
-    {
-        iCPMMetadataKeys.clear();
-        iCPMGetMetaDataKeysCmdId =
-            iCPMMetaDataExtensionInterface->GetNodeMetadataKeys(iCPMSessionID,
-                    iCPMMetadataKeys,
-                    0,
-                    PVMF_STREAMING_MANAGER_NODE_MAX_CPM_METADATA_KEYS);
-    }
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::CheckCPMCommandCompleteStatus(PVMFCommandId aID,
-        PVMFStatus aStatus)
-{
-    PVMFStatus status = aStatus;
-    if (aID == iCPMGetLicenseInterfaceCmdId)
-    {
-        if (aStatus == PVMFErrNotSupported)
-        {
-            /* License Interface is Optional */
-            status = PVMFSuccess;
-        }
-    }
-    return status;
-}
-
-void PVMFStreamingManagerNode::CPMCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CPMCommandCompleted() In"));
-
-    PVMFCommandId id = aResponse.GetCmdId();
-    PVMFStatus status =
-        CheckCPMCommandCompleteStatus(id, aResponse.GetCmdStatus());
-
-    if (id == iCPMCancelGetLicenseCmdId)
-    {
-        /*
-         * if this command is CancelGetLicense, we will return success or fail here.
-         */
-        OSCL_ASSERT(!iCancelCommand.empty());
-        CommandComplete(iCancelCommand,
-                        iCancelCommand.front(),
-                        status);
-        return;
-    }
-    else
-    {
-        /*
-         * if there was any pending cancel, we just ignore CPM process.
-         */
-        if (iCurrentCommand.empty())
-        {
-            return;
-        }
-        if (!iCancelCommand.empty())
-        {
-            if (iCancelCommand.front().iCmd != PVMF_STREAMING_MANAGER_NODE_CANCEL_GET_LICENSE)
-                return;
-        }
-    }
-
-    if (status != PVMFSuccess)
-    {
-        /*
-         * If any command fails, the sequence fails.
-         */
-        if (iCurrentCommand.front().iCmd == PVMF_STREAMING_MANAGER_NODE_RESET)
-        {
-            iDRMResetPending = false;
-            PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode:CPMCommandCompleted: - Reset Error on ID=%d", id));
-            if (iErrorDuringProcess == SM_NO_ERROR)
-            {
-                if (iErrorResponseInf != NULL)
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::CPMCommandCompleted - iErrorResponseInf is not NULL"));
-                    OSCL_ASSERT(false);
-                }
-                if (aResponse.GetEventExtensionInterface())
-                {
-                    iErrorResponseInf = aResponse.GetEventExtensionInterface();
-                    iErrorResponseInf->addRef();
-                }
-                iErrorDuringProcess = SM_NODE_COMMAND_COMPLETION;
-            }
-            else
-            {
-                PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode:CPMCommandCompleted: - CancelAllCommands already Queued"));
-            }
-            CompleteReset();
-        }
-        else
-        {
-            if (id == iCPMRequestUsageId)
-            {
-                /*
-                 * Only when PVMFErrLicenseRequired is replied for license authentication,
-                 * Set iCPMInitPending into true.
-                 */
-                if (aResponse.GetCmdStatus() == PVMFErrLicenseRequired)
-                    iCPMInitPending = true;
-            }
-            CommandComplete(iCurrentCommand,
-                            iCurrentCommand.front(),
-                            aResponse.GetCmdStatus(),
-                            NULL,
-                            NULL,
-                            NULL,
-                            aResponse.GetEventExtensionInterface());
-        }
-    }
-    else
-    {
-        /*
-         * process the response, and issue the next command in
-         * the sequence.
-         */
-
-        if (id == iCPMInitCmdId)
-        {
-            OpenCPMSession();
-        }
-        else if (id == iCPMOpenSessionCmdId)
-        {
-            CPMRegisterContent();
-        }
-        else if (id == iCPMRegisterContentCmdId)
-        {
-            GetCPMCapConfigInterface();
-        }
-        else if (id == iCPMGetCapConfigCmdId)
-        {
-            // got capConfig interface, set kvps for CPM plugins
-            if (!SetCPMKvps()) return;
-            GetCPMLicenseInterface();
-        }
-        else if (id == iCPMGetLicenseInterfaceCmdId)
-        {
-            iCPMContentType = iCPM->GetCPMContentType(iCPMSessionID);
-            if (iCPMContentType == PVMF_CPM_FORMAT_ACCESS_BEFORE_AUTHORIZE)
-            {
-                GetCPMContentAccessFactory();
-                GetCPMMetaDataExtensionInterface();
-                RequestUsage();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::CPMCommandCompleted() Unknown CPM format type"));
-                /* Protected but Unknown format ?? */
-                OSCL_ASSERT(false);
-
-            }
-        }
-        else if (id == iCPMRequestUsageId)
-        {
-            if (iCPMContentType == PVMF_CPM_FORMAT_ACCESS_BEFORE_AUTHORIZE)
-            {
-                /* End of Node Init sequence. */
-                OSCL_ASSERT(!iCurrentCommand.empty());
-                OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_STREAMING_MANAGER_NODE_INIT);
-                CompleteDRMInit();
-            }
-            else
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::CPMCommandCompleted() Unknown CPM format type"));
-                /* Unknown format - should never get here */
-                OSCL_ASSERT(false);
-            }
-        }
-        else if (id == iCPMGetMetaDataKeysCmdId)
-        {
-            /* End of GetNodeMetaDataKeys */
-            PVMFStatus status =
-                CompleteGetMetadataKeys(iCurrentCommand.front());
-            CommandComplete(iCurrentCommand,
-                            iCurrentCommand.front(),
-                            status,
-                            NULL,
-                            NULL,
-                            NULL,
-                            NULL);
-        }
-        else if (id == iCPMUsageCompleteCmdId)
-        {
-            if (iDecryptionInterface != NULL)
-            {
-                iDecryptionInterface->Reset();
-                /* Remove the decrpytion interface */
-                PVUuid uuid = PVMFCPMPluginDecryptionInterfaceUuid;
-                iCPMContentAccessFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iDecryptionInterface);
-                iDecryptionInterface = NULL;
-            }
-            CloseCPMSession();
-        }
-        else if (id == iCPMCloseSessionCmdId)
-        {
-            ResetCPM();
-        }
-        else if (id == iCPMResetCmdId)
-        {
-            /* End of Node Reset sequence */
-            OSCL_ASSERT(!iCurrentCommand.empty());
-            OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_STREAMING_MANAGER_NODE_RESET);
-            iDRMResetPending = false;
-            CompleteReset();
-        }
-        else if (id == iCPMGetMetaDataValuesCmdId)
-        {
-            /* End of GetNodeMetaDataValues */
-            OSCL_ASSERT(!iCurrentCommand.empty());
-            OSCL_ASSERT(iCurrentCommand.front().iCmd == PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAVALUES);
-            CompleteGetMetaDataValues();
-        }
-        else if (id == iCPMGetLicenseCmdId)
-        {
-            CompleteGetLicense();
-        }
-        else
-        {
-            /* Unknown cmd ?? - error */
-            CommandComplete(iCurrentCommand,
-                            iCurrentCommand.front(),
-                            PVMFFailure);
-        }
-    }
-}
-
-void PVMFStreamingManagerNode::CompleteGetMetaDataValues()
-{
-    CommandComplete(iCurrentCommand,
-                    iCurrentCommand.front(),
-                    PVMFSuccess);
-}
-
-void PVMFStreamingManagerNode::CompleteDRMInit()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteDRMInit - In"));
-    if (iApprovedUsage.value.uint32_value !=
-            iRequestedUsage.value.uint32_value)
-    {
-        CommandComplete(iCurrentCommand,
-                        iCurrentCommand.front(),
-                        PVMFErrAccessDenied,
-                        NULL, NULL, NULL);
-        return;
-    }
-    /* If protected content, get the decryption interface, if the intent is play */
-    if (iCPMSourceData.iIntent & BITMASK_PVMF_SOURCE_INTENT_PLAY)
-    {
-        PVMFSMNodeContainer* iMediaLayerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-        if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-            (PVMFMediaLayerNodeExtensionInterface*)
-            (iMediaLayerNodeContainer->iExtensions[0]);
-
-        PVUuid uuid = PVMFCPMPluginDecryptionInterfaceUuid;
-        PVInterface* intf =
-            iCPMContentAccessFactory->CreatePVMFCPMPluginAccessInterface(uuid);
-        PVMFCPMPluginAccessInterface* interimPtr =
-            OSCL_STATIC_CAST(PVMFCPMPluginAccessInterface*, intf);
-        iDecryptionInterface = OSCL_STATIC_CAST(PVMFCPMPluginAccessUnitDecryptionInterface*, interimPtr);
-        if (iDecryptionInterface == NULL)
-        {
-            CommandComplete(iCurrentCommand,
-                            iCurrentCommand.front(),
-                            PVMFErrAccessDenied,
-                            NULL, NULL, NULL);
-            return;
-        }
-        iDecryptionInterface->Init();
-        mlExtIntf->setDRMDecryptionInterface(maxPacketSize, iDecryptionInterface);
-    }
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteDRMInit Success"));
-    //License authentication was successfull. Init is completed at protected clip
-    SetState(EPVMFNodeInitialized);
-    CommandComplete(iCurrentCommand,
-                    iCurrentCommand.front(),
-                    PVMFSuccess);
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteDRMInit - Out"));
-    return;
-}
-
-bool PVMFStreamingManagerNode::SetCPMKvps()
-{
-    if (iCPMCapConfigInterface && !iCPMKvpStore.isEmpty())
-    {
-        PVMFKvpVector *aVector = iCPMKvpStore.getKVPStore();
-        PvmiKvp *aErrorKVP = NULL;
-        int32 err = 0;
-        for (uint32 i = 0; i < aVector->size(); i++)
-        {
-            OSCL_TRY(err, iCPMCapConfigInterface->setParametersSync(NULL, &((*aVector)[i]), 1, aErrorKVP));
-            if (err)
-            {
-                CommandComplete(iCurrentCommand,
-                                iCurrentCommand.front(),
-                                PVMFFailure);
-                iCPMKvpStore.destroy();
-                return false;
-            }
-        }
-        iCPMKvpStore.destroy();
-    }
-    return true;
-}
-PVMFCommandId
-PVMFStreamingManagerNode::GetLicense(PVMFSessionId aSessionId,
-                                     OSCL_wString& aContentName,
-                                     OsclAny* aData,
-                                     uint32 aDataSize,
-                                     int32 aTimeoutMsec,
-                                     const OsclAny* aContextData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetLicense - Wide called"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_GET_LICENSE_W,
-            aContentName,
-            aData,
-            aDataSize,
-            aTimeoutMsec,
-            aContextData);
-    return QueueCommandL(cmd);
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::GetLicense(PVMFSessionId aSessionId,
-                                     OSCL_String&  aContentName,
-                                     OsclAny* aData,
-                                     uint32 aDataSize,
-                                     int32 aTimeoutMsec,
-                                     const OsclAny* aContextData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetLicense - called"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_GET_LICENSE,
-            aContentName,
-            aData,
-            aDataSize,
-            aTimeoutMsec,
-            aContextData);
-    return QueueCommandL(cmd);
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::CancelGetLicense(PVMFSessionId aSessionId
-        , PVMFCommandId aCmdId
-        , OsclAny* aContextData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CancelGetLicense - called"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_CANCEL_GET_LICENSE,
-            aCmdId,
-            aContextData);
-    return QueueCommandL(cmd);
-}
-
-PVMFStatus PVMFStreamingManagerNode::GetLicenseStatus(
-    PVMFCPMLicenseStatus& aStatus)
-{
-    if (iCPMLicenseInterface)
-        return iCPMLicenseInterface->GetLicenseStatus(aStatus);
-    return PVMFFailure;
-}
-
-PVMFStatus PVMFStreamingManagerNode::DoGetLicense(PVMFStreamingManagerNodeCommand& aCmd,
-        bool aWideCharVersion)
-{
-    if (iCPMLicenseInterface == NULL)
-    {
-        return PVMFErrNotSupported;
-    }
-
-    if (aWideCharVersion == true)
-    {
-
-        OSCL_wString* contentName = NULL;
-        OsclAny* data = NULL;
-        uint32 dataSize = 0;
-        int32 timeoutMsec = 0;
-        aCmd.PVMFStreamingManagerNodeCommand::Parse(contentName,
-                data,
-                dataSize,
-                timeoutMsec);
-        iCPMGetLicenseCmdId =
-            iCPMLicenseInterface->GetLicense(iCPMSessionID,
-                                             *contentName,
-                                             data,
-                                             dataSize,
-                                             timeoutMsec);
-    }
-    else
-    {
-        OSCL_String* contentName = NULL;
-        OsclAny* data = NULL;
-        uint32 dataSize = 0;
-        int32 timeoutMsec = 0;
-        aCmd.PVMFStreamingManagerNodeCommand::Parse(contentName,
-                data,
-                dataSize,
-                timeoutMsec);
-        iCPMGetLicenseCmdId =
-            iCPMLicenseInterface->GetLicense(iCPMSessionID,
-                                             *contentName,
-                                             data,
-                                             dataSize,
-                                             timeoutMsec);
-    }
-    return PVMFPending;
-}
-
-void PVMFStreamingManagerNode::CompleteGetLicense()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteGetLicense - called"));
-    CommandComplete(iCurrentCommand,
-                    iCurrentCommand.front(),
-                    PVMFSuccess,
-                    NULL,
-                    NULL,
-                    NULL,
-                    NULL);
-}
-
-void PVMFStreamingManagerNode::DoCancelGetLicense(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoCancelGetLicense() Called"));
-    PVMFStatus status = PVMFErrArgument;
-
-    if (iCPMLicenseInterface == NULL)
-    {
-        status = PVMFErrNotSupported;
-    }
-    else
-    {
-        /* extract the command ID from the parameters.*/
-        PVMFCommandId id;
-        aCmd.PVMFStreamingManagerNodeCommandBase::Parse(id);
-
-        /* first check "current" command if any */
-        PVMFStreamingManagerNodeCommand* cmd = iCurrentCommand.FindById(id);
-        if (cmd)
-        {
-            if (cmd->iCmd == PVMF_STREAMING_MANAGER_NODE_GET_LICENSE_W || cmd->iCmd == PVMF_STREAMING_MANAGER_NODE_GET_LICENSE)
-            {
-                iCPMCancelGetLicenseCmdId =
-                    iCPMLicenseInterface->CancelGetLicense(iCPMSessionID, iCPMGetLicenseCmdId);
-
-                /*
-                 * the queued commands are all asynchronous commands to the
-                 * CPM module. CancelGetLicense can cancel only for GetLicense cmd.
-                 * We need to wait CPMCommandCompleted.
-                 */
-                MoveCmdToCancelQueue(aCmd);
-                return;
-            }
-        }
-
-        /*
-         * next check input queue.
-         * start at element 1 since this cancel command is element 0.
-         */
-        cmd = iInputCommands.FindById(id, 1);
-        if (cmd)
-        {
-            if (cmd->iCmd == PVMF_STREAMING_MANAGER_NODE_GET_LICENSE_W || cmd->iCmd == PVMF_STREAMING_MANAGER_NODE_GET_LICENSE)
-            {
-                /* cancel the queued command */
-                CommandComplete(iInputCommands, *cmd, PVMFErrCancelled, NULL, NULL);
-                /* report cancel success */
-                CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-                return;
-            }
-        }
-    }
-    /* if we get here the command isn't queued so the cancel fails */
-    CommandComplete(iInputCommands, aCmd, status);
-    return;
-}
-
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_ext_interface.h b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_ext_interface.h
index b4ad208..82271be 100644
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_ext_interface.h
+++ b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_ext_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,8 @@
 #ifndef OSCL_BASE_H_INCLUDED
 #include "oscl_base.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
 #include "oscl_string_containers.h"
@@ -42,9 +42,6 @@
 #ifndef SDP_INFO_H_INCLUDED
 #include "sdp_info.h"
 #endif
-#ifndef PVMF_SM_CONFIG_H_INCLUDED
-#include "pvmf_sm_config.h"
-#endif
 
 typedef struct tagPVMFSMClientParams
 {
@@ -89,8 +86,8 @@
         OSCL_IMPORT_REF virtual PVMFStatus resetJitterBuffer() = 0;
         OSCL_IMPORT_REF virtual PVMFStatus setPayloadParserRegistry(PayloadParserRegistry*) = 0;
 
-        OSCL_IMPORT_REF virtual PVMFStatus setDataPortLogging(bool logEnable,
-                OSCL_String* logPath = NULL) = 0;
+        OSCL_IMPORT_REF virtual PVMFStatus setDataPortLogging(bool logEnable, OSCL_String* logPath = NULL) = 0;
+        OSCL_IMPORT_REF virtual PVMFStatus switchStreams(uint32 aSrcStreamID, uint32 aDestStreamID) = 0;
 
         OSCL_IMPORT_REF virtual void addRef() = 0;
         OSCL_IMPORT_REF virtual void removeRef() = 0;
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_extension_interface.cpp b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_extension_interface.cpp
index 07ee85d..6300ab9 100644
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_extension_interface.cpp
+++ b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_extension_interface.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,9 +36,6 @@
 #ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
 #include "pvmf_medialayer_node.h"
 #endif
-#ifndef PVMF_SM_CONFIG_H_INCLUDED
-#include "pvmf_sm_config.h"
-#endif
 
 /**
  * Macros for calling PVLogger
@@ -148,6 +145,13 @@
 }
 
 OSCL_EXPORT_REF PVMFStatus
+PVMFStreamingManagerExtensionInterfaceImpl::setPacketSourceInterface(PVMFPacketSource* aPacketSource)
+{
+    iPacketSource = aPacketSource;
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFStatus
 PVMFStreamingManagerExtensionInterfaceImpl::setDataPortLogging(bool logEnable,
         OSCL_String* logPath)
 {
@@ -163,6 +167,11 @@
     return (mlExtIntf->setPortDataLogging(logEnable, logPath));
 }
 
+OSCL_EXPORT_REF PVMFStatus
+PVMFStreamingManagerExtensionInterfaceImpl::switchStreams(uint32 aSrcStreamID, uint32 aDestStreamID)
+{
+    return (iContainer->switchStreams(aSrcStreamID, aDestStreamID));
+}
 
 OSCL_EXPORT_REF PVMFStatus
 PVMFStreamingManagerExtensionInterfaceImpl::SetSourceInitializationData(OSCL_wString& aSourceURL,
@@ -175,7 +184,7 @@
 }
 
 OSCL_EXPORT_REF PVMFStatus
-PVMFStreamingManagerExtensionInterfaceImpl::SetClientPlayBackClock(OsclClock* clientClock)
+PVMFStreamingManagerExtensionInterfaceImpl::SetClientPlayBackClock(PVMFMediaClock* clientClock)
 {
     PVMFSMNodeContainer* iJitterBufferNodeContainer =
         iContainer->getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
@@ -203,7 +212,7 @@
 }
 
 OSCL_EXPORT_REF PVMFStatus
-PVMFStreamingManagerExtensionInterfaceImpl::SetEstimatedServerClock(OsclClock* aClientClock)
+PVMFStreamingManagerExtensionInterfaceImpl::SetEstimatedServerClock(PVMFMediaClock* aClientClock)
 {
     OSCL_UNUSED_ARG(aClientClock);
     return PVMFErrNotSupported;
@@ -255,6 +264,13 @@
         iface = OSCL_STATIC_CAST(PVInterface*, interimPtr);
         return true;
     }
+    else if (uuid == PVMF_DATA_SOURCE_PACKETSOURCE_INTERFACE_UUID)
+    {
+        PVMFDataSourcePacketSourceInterface* interimPtr =
+            OSCL_STATIC_CAST(PVMFDataSourcePacketSourceInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, interimPtr);
+        return true;
+    }
     else if (uuid == PvmfDataSourcePlaybackControlUuid)
     {
         PvmfDataSourcePlaybackControlInterface* interimPtr =
@@ -351,15 +367,30 @@
 OSCL_EXPORT_REF PVMFCommandId
 PVMFStreamingManagerExtensionInterfaceImpl::SetDataSourceRate(PVMFSessionId aSessionId,
         int32 aRate,
-        OsclTimebase* aTimebase,
+        PVMFTimebase* aTimebase,
         OsclAny* aContext)
 {
+
     return (iContainer->SetDataSourceRate(aSessionId,
                                           aRate,
                                           aTimebase,
                                           aContext));
 }
 
+OSCL_EXPORT_REF PVMFStatus
+PVMFStreamingManagerExtensionInterfaceImpl::ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+        PVMFTimestamp aActualNPT,
+        PVMFTimestamp aActualMediaDataTS,
+        PVMFTimestamp& aSkipTimeStamp,
+        PVMFTimestamp& aStartNPT)
+{
+    return (iContainer->ComputeSkipTimeStamp(aTargetNPT,
+            aActualNPT,
+            aActualMediaDataTS,
+            aSkipTimeStamp,
+            aStartNPT));
+}
+
 OSCL_EXPORT_REF uint32
 PVMFStreamingManagerExtensionInterfaceImpl::GetNumMetadataKeys(char* query_key)
 {
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_internal.h b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_internal.h
index f2660a4..d6b9b0d 100644
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_internal.h
+++ b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,9 +54,6 @@
 #ifndef SDP_INFO_H_INCLUDED
 #include "sdp_info.h"
 #endif
-#ifndef PVMF_SM_CONFIG_H_INCLUDED
-#include "pvmf_sm_config.h"
-#endif
 #ifndef PVMF_SM_TUNABLES_H_INCLUDED
 #include "pvmf_sm_tunables.h"
 #endif
@@ -66,6 +63,9 @@
 #ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED
 #include "pvmf_cpmplugin_license_interface.h"
 #endif
+#ifndef PVMF_DATA_SOURCE_PACKETSOURCE_H_INCLUDED
+#include "pvmf_data_source_packetsource.h"
+#endif
 /**
  * Macros for calling PVLogger
  */
@@ -90,7 +90,7 @@
 
 #define PVMF_STREAMING_MANAGER_TEMPLATED_DELETE(auditCB, T, Tsimple, ptr)\
 {\
-	OSCL_TEMPLATED_DELETE(ptr, T, Tsimple);\
+	OSCL_DELETE(ptr);\
 }
 
 #define PV_STREAMING_MANAGER_ARRAY_NEW(auditCB, T, count, ptr)\
@@ -172,6 +172,7 @@
     PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE = 4,
     PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE = 5,
     PVMF_STREAMING_MANAGER_RTPPACKETSOURCE_NODE = 6,
+    PVMF_STREAMING_MANAGER_PVR_NODE = 7,
     PVMF_STREAMING_MANAGER_LAST_CHILD_NODE
 };
 
@@ -182,6 +183,7 @@
 #define PVMF_STREAMING_MANAGER_MEDIA_LAYER_COMMAND_START              4000
 #define PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_COMMAND_START  5000
 #define PVMF_STREAMING_MANAGER_RTPPACKETSOURCE_NODE_COMMAND_START     6000
+#define PVMF_STREAMING_MANAGER_PVR_NODE_COMMAND_START     7000
 
 #define PVMF_STREAMING_MANAGER_NODE_INTERNAL_QUERY_UUID_CMD_OFFSET       0
 #define PVMF_STREAMING_MANAGER_NODE_INTERNAL_QUERY_INTERFACE_CMD_OFFSET  1
@@ -284,11 +286,60 @@
     PVMF_STREAMING_MANAGER_RTP_PACKET_SOURCE_NODE_RELEASE_PORT = 6010,
     PVMF_STREAMING_MANAGER_RTP_PACKET_SOURCE_NODE_CANCEL_ALL_COMMANDS = 6011,
 
-    PVMF_STREAMING_MANAGER_INTERNAL_COMMAND_LAST = 6999
+    PVMF_STREAMING_MANAGER_PVR_NODE_QUERY_UUID = 7000,
+    PVMF_STREAMING_MANAGER_PVR_NODE_QUERY_INTERFACE = 7001,
+    PVMF_STREAMING_MANAGER_PVR_NODE_INIT = 7002,
+    PVMF_STREAMING_MANAGER_PVR_NODE_PREPARE = 7003,
+    PVMF_STREAMING_MANAGER_PVR_NODE_START = 7004,
+    PVMF_STREAMING_MANAGER_PVR_NODE_STOP = 7005,
+    PVMF_STREAMING_MANAGER_PVR_NODE_FLUSH = 7006,
+    PVMF_STREAMING_MANAGER_PVR_NODE_PAUSE = 7007,
+    PVMF_STREAMING_MANAGER_PVR_NODE_RESET = 7008,
+    PVMF_STREAMING_MANAGER_PVR_NODE_REQUEST_PORT = 7009,
+    PVMF_STREAMING_MANAGER_PVR_NODE_RELEASE_PORT = 7010,
+    PVMF_STREAMING_MANAGER_PVR_NODE_CANCEL_ALL_COMMANDS = 7011,
+
+    PVMF_STREAMING_MANAGER_INTERNAL_COMMAND_LAST = 7999
+
 };
 
+static const char PVMFSTREAMINGMGRNODE_JANUS_AUTH_DATA_V2_HEADER[] = "V2 ASF header";
+static const char PVMFSTREAMINGMGRNODE_JANUS_AUTH_DATA_V1_HEADER[] = "V1 ASF header";
 #define PVMF_STREAMING_MANAGER_NODE_MAX_CPM_METADATA_KEYS 256
 
+class PVMFSMASFHeaderInfo
+{
+    public:
+        PVMFSMASFHeaderInfo()
+        {
+            iASFHeaderObject    = NULL;
+            iASFFileSize        = 0;
+            iASFFileDuration    = 0;
+            iASFPreRollDuration = 0;
+            iASFBroadCastFlag   = 0;
+            iASFStreamRate      = PVMF_STREAMING_MAANGER_NODE_DEFAULT_STREAM_SPEED;
+            iASFDRMProtected	= false;
+        };
+
+        virtual ~PVMFSMASFHeaderInfo()
+        {
+            if (iASFHeaderObject != NULL)
+            {
+                PVMF_STREAMING_MANAGER_DELETE(NULL,
+                                              StreamAsfHeader,
+                                              iASFHeaderObject);
+                iASFHeaderObject = NULL;
+            }
+        };
+
+        StreamAsfHeader*      iASFHeaderObject;
+        uint64        iASFFileSize;
+        uint64        iASFFileDuration;
+        uint64        iASFPreRollDuration;
+        uint8         iASFBroadCastFlag;
+        uint32        iASFStreamRate;
+        bool		  iASFDRMProtected;
+};
 
 class PVMFSMSessionSourceInfo
 {
@@ -305,6 +356,7 @@
         OsclSharedPtr<SDPInfo> _sdpInfo;
         OsclAny*    _sourceData;
         bool iRTSPTunnelling;
+        PVMFSMASFHeaderInfo iASFHeaderInfo;
 };
 
 //implementation class for extension interface
@@ -318,7 +370,8 @@
             public PvmfDataSourcePlaybackControlInterface,
             public PVMFMetadataExtensionInterface,
             public PvmiCapabilityAndConfig,
-            public PVMFCPMPluginLicenseInterface
+            public PVMFCPMPluginLicenseInterface,
+            public PVMFDataSourcePacketSourceInterface
 {
     public:
         PVMFStreamingManagerExtensionInterfaceImpl(PVMFStreamingManagerNode*,
@@ -331,8 +384,8 @@
         OSCL_IMPORT_REF PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL,
                 PVMFFormatType& aSourceFormat,
                 OsclAny* aSourceData);
-        OSCL_IMPORT_REF PVMFStatus SetClientPlayBackClock(OsclClock* aClientClock);
-        OSCL_IMPORT_REF PVMFStatus SetEstimatedServerClock(OsclClock* aClientClock);
+        OSCL_IMPORT_REF PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        OSCL_IMPORT_REF PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
 
         /*
          * From PVMFTrackSelectionExtensionInterface
@@ -349,8 +402,9 @@
         OSCL_IMPORT_REF PVMFStatus setJitterBufferParams(PVMFSMJitterBufferParmas* jitterBufferParams);
         OSCL_IMPORT_REF PVMFStatus resetJitterBuffer();
         OSCL_IMPORT_REF PVMFStatus setPayloadParserRegistry(PayloadParserRegistry*);
-        OSCL_IMPORT_REF PVMFStatus setDataPortLogging(bool logEnable,
-                OSCL_String* logPath = NULL);
+        OSCL_IMPORT_REF PVMFStatus setDataPortLogging(bool logEnable, OSCL_String* logPath = NULL);
+        OSCL_IMPORT_REF PVMFStatus switchStreams(uint32 aSrcStreamID, uint32 aDestStreamID);
+
         /*
          * From PvmfDataSourcePlaybackControlInterface
          */
@@ -377,8 +431,13 @@
                 bool aSeekToSyncPoint = true);
         OSCL_IMPORT_REF PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId,
                 int32 aRate,
-                OsclTimebase* aTimebase = NULL,
+                PVMFTimebase* aTimebase = NULL,
                 OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFStatus ComputeSkipTimeStamp(PVMFTimestamp aTargetNPT,
+                PVMFTimestamp aActualNPT,
+                PVMFTimestamp aActualMediaDataTS,
+                PVMFTimestamp& aSkipTimeStamp,
+                PVMFTimestamp& aStartNPT);
 
         /*
          * From PVMFMetadataExtensionInterface
@@ -513,11 +572,16 @@
         OSCL_IMPORT_REF void removeRef();
         OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
 
+        /*
+         * From PVMFDataSourcePacketSourceInterface
+         */
+        OSCL_IMPORT_REF PVMFStatus setPacketSourceInterface(PVMFPacketSource* aPacketSource);
 
     private:
         PVMFSessionId iSessionId;
         PVMFStreamingManagerNode *iContainer;
         friend class PVMFStreamingManagerNode;
+        PVMFPacketSource *iPacketSource;
 };
 
 #endif
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.cpp b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.cpp
index 58c2bed..f6dc947 100644
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.cpp
+++ b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,332 +15,63 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-#ifndef OSCL_SNPRINTF_H_INCLUDED
-#include "oscl_snprintf.h"
-#endif
-#ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
-#include "oscl_exclusive_ptr.h"
-#endif
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-#ifndef OSCL_MIME_STRING_UTILS_H
-#include "pv_mime_string_utils.h"
-#endif
-#ifndef PVMF_SM_NODE_FACTORY_H_INCLUDED
-#include "pvmf_sm_node_factory.h"
-#endif
-#ifndef PVMF_SM_TUNABLES_H_INCLUDED
-#include "pvmf_sm_tunables.h"
-#endif
 #ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
 #include "pvmf_streaming_manager_node.h"
 #endif
-#ifndef PVMF_STREAMING_MANAGER_INTERNAL_H_INCLUDED
-#include "pvmf_streaming_manager_internal.h"
+
+#ifndef PV_INTERFACE_H
+#include "pv_interface.h"
 #endif
-#ifndef PVMF_SM_CAPCONFIG_H_INCLUDED
-#include "pvmf_sm_capconfig.h"
+
+#ifndef PVMF_SM_FSP_REGISTRY_H
+#include "pvmf_sm_fsp_registry.h"
 #endif
-#ifndef PVMF_SOCKET_NODE_H_INCLUDED
-#include "pvmf_socket_node.h"
-#endif
-#ifndef PVMF_RTSP_ENGINE_NODE_FACTORY_H_INCLUDED
-#include "pvrtsp_client_engine_factory.h"
-#endif
-#ifndef PVMF_JITTER_BUFFER_NODE_H_INCLUDED
-#include "pvmf_jitter_buffer_node.h"
-#endif
-#ifndef PVMF_MEDIALAYER_NODE_H_INCLUDED
-#include "pvmf_medialayer_node.h"
-#endif
-#ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_H_INCLUDED
-#include "pvrtspenginenodeextensioninterface.h"
-#endif
-#ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
-#include "pvmf_media_presentation_info.h"
-#endif
-#ifndef SDP_PARSER_H
-#include "sdp_parser.h"
-#endif
+
 #ifndef PVMF_BASIC_ERRORINFOMESSAGE_H_INCLUDED
 #include "pvmf_basic_errorinfomessage.h"
 #endif
-#ifndef PVMF_ERRORINFOMESSAGE_EXTENSION_H_INCLUDED
-#include "pvmf_errorinfomessage_extension.h"
+
+#ifndef PVMF_SM_FSP_REGISTRY_H
+#include "pvmf_sm_fsp_registry.h"
 #endif
-#ifndef OSCL_STRING_UTILS_H_INCLUDED
-#include "oscl_string_utils.h"
-#endif
-#ifndef PVMI_KVP_UTIL_H_INCLUDED
-#include "pvmi_kvp_util.h"
-#endif
+
 #ifndef OSCL_DLL_H_INCLUDED
 #include "oscl_dll.h"
 #endif
-#ifndef PVMF_PROTOCOLENGINE_FACTORY_H_INCLUDED
-#include "pvmf_protocol_engine_factory.h"
-#endif
-#ifndef PVMF_PROTOCOLENGINE_DEFS_H_INCLUDED
-#include "pvmf_protocol_engine_defs.h"
-#endif
-#ifndef PVMFPROTOCOLENGINENODE_EXTENSION_H_INCLUDED
-#include "pvmf_protocol_engine_node_extension.h"
-#endif
-#ifndef PVMF_STREAMING_ASF_INTERFACES_INCLUDED
-#include "pvmf_streaming_asf_interfaces.h"
-#endif
-#ifndef PVMI_DRM_KVP_H_INCLUDED
-#include "pvmi_drm_kvp.h"
-#endif
 
-#ifndef OSCL_UTF8CONV_H
-#include "oscl_utf8conv.h"
-#endif
-#ifndef PVMF_SM_CONFIG_H_INCLUDED
-#include "pvmf_sm_config.h"
-#endif
-
-// Define entry point for this DLL
+//////////////////////////////////////////////////////////////////////
+//To make this module as DLL we need to define entry point for the DLL
+//////////////////////////////////////////////////////////////////////
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
 
-// Number of metadata keys supported in this node.
-#define PVMFSTREAMINGMGRNODE_NUM_METADATAKEYS 16
-// Constant character strings for metadata keys
-static const char PVMFSTREAMINGMGRNODE_AUTHOR_KEY[] = "author";
-static const char PVMFSTREAMINGMGRNODE_ARTIST_KEY[] = "artist";
-static const char PVMFSTREAMINGMGRNODE_TITLE_KEY[] = "title";
-static const char PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY[] = "description";
-static const char PVMFSTREAMINGMGRNODE_RATING_KEY[] = "rating";
-static const char PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY[] = "copyright";
-static const char PVMFSTREAMINGMGRNODE_GENRE_KEY[] = "genre";
-static const char PVMFSTREAMINGMGRNODE_LYRICS_KEY[] = "lyrics";
-static const char PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY[] = "classification";
-static const char PVMFSTREAMINGMGRNODE_KEYWORDS_KEY[] = "keywords";
-static const char PVMFSTREAMINGMGRNODE_LOCATION_KEY[] = "location";
-static const char PVMFSTREAMINGMGRNODE_DURATION_KEY[] = "duration";
-static const char PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY[] = "num-tracks";
-static const char PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY[] = "random-access-denied";
-static const char PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY[] = "graphic/num-frames;format=APIC";
-static const char PVMFSTREAMINGMGRNODE_GRAPHICS_KEY[] = "graphic;format=APIC";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY[] = "track-info/type";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY[] = "track-info/duration";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY[] = "track-info/bit-rate";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY[] = "track-info/max-bitrate";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY[] = "track-info/selected";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY[] = "track-info/video/width";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY[] = "track-info/video/height";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY[] = "track-info/sample-rate";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY[] = "track-info/audio/channels";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY[] = "track-info/audio/bits-per-sample";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY[] = "track-info/track-id";
-
-static const char PVMFSTREAMINGMGRNODE_SEMICOLON[] = ";";
-static const char PVMFSTREAMINGMGRNODE_TIMESCALE[] = "timescale=";
-static const char PVMFSTREAMINGMGRNODE_INDEX[] = "index=";
-static const char PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY[] = "clip-type";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY[] = "track-info/frame-rate";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY[] = "track-info/codec-name";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY[] = "track-info/codec-description";
-static const char PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY[] = "track-info/codec-specific-info";
-
-static const char PVMFSTREAMINGMGRNODE_MAXSIZE[] = "maxsize=";
-static const char PVMFSTREAMINGMGRNODE_REQSIZE[] = "reqsize=";
-static const char PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG[] = "truncate=";
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// Capability and config interface related constants and definitions
-//   - based on pv_player_engine.h
-//
-///////////////////////////////////////////////////////////////////////////////
-
-static const StreamingManagerKeyStringData StreamingManagerConfig_BaseKeys[] =
-{
-    {"delay", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"jitterBufferNumResize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"jitterBufferResizeSize", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"user-agent", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_WCHARPTR},
-    {"keep-alive-interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"keep-alive-during-play", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
-    {"switch-streams", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
-    {"speed", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"http-version", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
-    {"num-redirect-attempts", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"protocol-extension-header", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
-    {"http-timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"http-streaming-logging-timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"x-str-header", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
-    {"max-streaming-asf-header-size", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"max-tcp-recv-buffer-size", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"rebuffering-threshold", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"accel-bitrate", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"accel-duration", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
-    {"disable-firewall-packets", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
-};
-
-static const uint StreamingManagerConfig_NumBaseKeys =
-    (sizeof(StreamingManagerConfig_BaseKeys) /
-     sizeof(StreamingManagerKeyStringData));
-
-enum BaseKeys_IndexMapType
-{
-    BASEKEY_DELAY = 0,
-    BASEKEY_JITTERBUFFER_NUMRESIZE,
-    BASEKEY_JITTERBUFFER_RESIZESIZE,
-    BASEKEY_SESSION_CONTROLLER_USER_AGENT,
-    BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL,
-    BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY,
-    BASEKEY_STREAMING_MGR_SWITCH_STREAMS,
-    BASEKEY_STREAMING_SPEED,
-    BASEKEY_HTTP_VERSION,
-    BASEKEY_NUM_REDIRECT_ATTEMPTS,
-    BASEKEY_PROTOCOL_EXTENSION_HEADER,
-    BASEKEY_SESSION_CONTROLLER_HTTP_TIMEOUT,
-    BASEKEY_SESSION_CONTROLLER_HTTP_STREAMING_LOGGING_TIMEOUT,
-    BASEKEY_SESSION_CONTROLLER_XSTR_HTTP_HEADER,
-    BASEKEY_MAX_STREAMING_ASF_HEADER_SIZE,
-    BASEKEY_MAX_TCP_RECV_BUFFER_SIZE,
-    BASEKEY_REBUFFERING_THRESHOLD,
-    BASEKEY_ACCEL_BITRATE,
-    BASEKEY_ACCEL_DURATION,
-    BASEKEY_DISABLE_FIREWALL_PACKETS
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-void
-PVMFStreamingManagerNodeCommand::Copy(const PVMFGenericNodeCommand<OsclMemAllocator>& aCmd)
-{
-    PVMFGenericNodeCommand<OsclMemAllocator>::Copy(aCmd);
-    switch (aCmd.iCmd)
-    {
-        case PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAKEYS:
-            if (aCmd.iParam4)
-            {
-                /* copy the allocated string */
-                OSCL_HeapString<OsclMemAllocator>* aStr =
-                    (OSCL_HeapString<OsclMemAllocator>*)aCmd.iParam4;
-                Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
-                iParam4 = str.ALLOC_AND_CONSTRUCT(*aStr);
-            }
-            break;
-        default:
-            break;
-    }
-}
-
-/* need to overlaod the base Destroy routine to cleanup metadata key */
-void PVMFStreamingManagerNodeCommand::Destroy()
-{
-    PVMFGenericNodeCommand<OsclMemAllocator>::Destroy();
-    switch (iCmd)
-    {
-        case PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAKEYS:
-            if (iParam4)
-            {
-                /* cleanup the allocated string */
-                Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
-                str.destruct_and_dealloc(iParam4);
-            }
-            break;
-        default:
-            break;
-    }
-}
-
-/**
 //////////////////////////////////////////////////
 // Node Constructor & Destructor
 //////////////////////////////////////////////////
-*/
 
-OSCL_EXPORT_REF PVMFStreamingManagerNode::PVMFStreamingManagerNode(int32 aPriority)
-        : OsclActiveObject(aPriority, "StreamingManagerNode")
+
+PVMFStreamingManagerNode* PVMFStreamingManagerNode::New(int32 aPriority)
 {
-    iLogger = NULL;
-    iCmdSeqLogger = NULL;
-    iReposLogger = NULL;
+    PVMFStreamingManagerNode* smNode = NULL;
+    smNode = OSCL_NEW(PVMFStreamingManagerNode, (aPriority));
+    if (smNode)
+    {
+        smNode->Construct();
+    }
+    return smNode;
+}
 
-    iLogger = PVLogger::GetLoggerObject("StreamingManagerNode");
+OSCL_EXPORT_REF PVMFStreamingManagerNode::PVMFStreamingManagerNode(int32 aPriority):
+        OsclActiveObject(aPriority, "StreamingManagerNode"),
+        iSMFSPRegistry(NULL),
+        iSMFSPlugin(NULL),
+        iLogger(NULL)
+{
+    iFSPDataSourceInitializationIntf = NULL;
+}
 
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::PVMFStreamingManagerNode - In"));
-
-    iExtensionInterface = NULL;
-    iExtensionInterfacePlaceholder = NULL;
-    iQueryUUIDComplete = false;
-    iQueryInterfaceComplete = false;
-    iTotalNumRequestPortsComplete = 0;
-    iNumRequestPortsPending = 0;
-    iTotalNumInitPhaseRequestPortsComplete = 0;
-    iTotalNumInitPhaseRequestPortsPending = 0;
-    oGraphConstructComplete = false;
-    oGraphConnectComplete = false;
-    iSessionStartTime = 0;
-    iSessionStopTime = 0;
-    iSessionStopTimeAvailable = true;
-    iSessionSeekAvailable = true;
-    oRepositioning = false;
-    oPlayListRepositioning = false;
-    iRepositionRequestedStartNPTInMS = 0;
-    iActualRepositionStartNPTInMS = 0;
-    iActualMediaDataTS = 0;
-    iActualRepositionStartNPTInMSPtr = NULL;
-    iActualMediaDataTSPtr = NULL;
-    iPVMFDataSourcePositionParamsPtr = NULL;
-    iJumpToIFrame = false;
-    iJitterBufferDurationInMilliSeconds = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
-    iAutoPausePending = false;
-    iAutoResumePending = 0;
-    iAutoPaused = false;
-    iStreamThinningInProgress = false;
-    iPlaylistPlayInProgress = false;
-    iSwitchStreamIFrameVideo = false;
-    iErrorDuringProcess = SM_NO_ERROR;
-    iErrorResponseInf = NULL;
-    iCmdErrStatus = PVMFFailure;
-    iEventData = NULL;
-
-    ibRdtTransport = false;
-    ibCloaking = false;
-
-    ipRealChallengeGen = NULL;
-    ipRdtParser = NULL;
-
-    iStreamID = 0;
-
-    iSourceContextDataValid    = false;
-    iUseCPMPluginRegistry      = false;
-    iPreviewMode               = false;
-    iDRMResetPending		   = false;
-    iCPMInitPending            = false;
-    maxPacketSize			   = 0;
-    iPVMFStreamingManagerNodeMetadataValueCount = 0;
-    iCPMMetaDataExtensionInterface = NULL;
-    iCPMLicenseInterface           = NULL;
-    iCPMGetMetaDataKeysCmdId       = 0;
-    iCPMGetMetaDataValuesCmdId     = 0;
-    iCPMGetLicenseInterfaceCmdId   = 0;
-    iCPMGetLicenseCmdId			   = 0;
-    iCPMCancelGetLicenseCmdId	   = 0;
-    iCPM                       = NULL;
-    iCPMSessionID              = 0xFFFFFFFF;
-    iCPMContentType            = PVMF_CPM_CONTENT_FORMAT_UNKNOWN;
-    iCPMContentAccessFactory   = NULL;
-    iDecryptionInterface       = NULL;
-    iCPMInitCmdId              = 0;
-    iCPMOpenSessionCmdId       = 0;
-    iCPMRegisterContentCmdId   = 0;
-    iCPMRequestUsageId         = 0;
-    iCPMUsageCompleteCmdId     = 0;
-    iCPMCloseSessionCmdId      = 0;
-    iCPMResetCmdId             = 0;
-    iRequestedUsage.key        = NULL;
-    iApprovedUsage.key         = NULL;
-    iAuthorizationDataKvp.key  = NULL;
-    CleanupCPMdata();
-
+void PVMFStreamingManagerNode::Construct()
+{
     int32 err;
     OSCL_TRY(err,
              /*
@@ -349,437 +80,49 @@
               */
              iInputCommands.Construct(PVMF_STREAMING_MANAGER_NODE_COMMAND_ID_START,
                                       PVMF_STREAMING_MANAGER_VECTOR_RESERVE);
-
-             /*
-              * Create the "current command" queue.  It will only contain one
-              * command at a time, so use a reserve of 1.
-              */
-             iCurrentCommand.Construct(0, 1);
-
-             /*
-              * Create the "cancel command" queue.  It will only contain one
-              * command at a time, so use a reserve of 1.
-              */
-             iCancelCommand.Construct(0, 1);
-
-             /*
-              * Set the node capability data.
-              * This node can support an unlimited number of ports.
-              */
-             iCapability.iCanSupportMultipleInputPorts = false;
-             iCapability.iCanSupportMultipleOutputPorts = true;
-             iCapability.iHasMaxNumberOfPorts = false;
-             iCapability.iMaxNumberOfPorts = 0;//no maximum
-
-             PVMF_STREAMING_MANAGER_NEW(NULL,
-                                        PVMFSMSessionSourceInfo,
-                                        (),
-                                        iSessionSourceInfo);
-
-             /*
-              * Create Socket Node
-              */
-             OsclExclusivePtr<PVMFNodeInterface> socketNodeAutoPtr;
-             PVMFNodeInterface* iSocketNode;
-             PVMF_STREAMING_MANAGER_NEW(NULL,
-                                        PVMFSocketNode,
-                                        (OsclActiveObject::EPriorityNominal),
-                                        iSocketNode);
-             socketNodeAutoPtr.set(iSocketNode);
-
-             PVMFSMNodeContainer sSocketNodeContainer;
-
-             PVMFNodeSessionInfo socketNodeSession(this,
-                                                   this,
-                                                   OSCL_REINTERPRET_CAST(OsclAny*,
-                                                                         iSocketNode),
-                                                   this,
-                                                   OSCL_REINTERPRET_CAST(OsclAny*,
-                                                                         iSocketNode));
-
-             sSocketNodeContainer.iNode = iSocketNode;
-             sSocketNodeContainer.iSessionId =
-                 iSocketNode->Connect(socketNodeSession);
-             sSocketNodeContainer.iNodeTag =
-                 PVMF_STREAMING_MANAGER_SOCKET_NODE;
-             sSocketNodeContainer.commandStartOffset =
-                 PVMF_STREAMING_MANAGER_SOCKET_NODE_COMMAND_START;
-             /* Push back the known UUID in case there are no queries */
-             PVUuid uuid(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_UUID);
-             sSocketNodeContainer.iExtensionUuids.push_back(uuid);
-             iNodeContainerVec.push_back(sSocketNodeContainer);
-
-             /*
-              * Create Session Controller Node
-              */
-             OsclExclusivePtr<PVMFNodeInterface> sessionControllerAutoPtr;
-             PVMFNodeInterface* iSessionControllerNode = PVMFRrtspEngineNodeFactory::CreatePVMFRtspEngineNode(OsclActiveObject::EPriorityNominal);
-             sessionControllerAutoPtr.set(iSessionControllerNode);
-
-             PVMFSMNodeContainer sSessionControllerNodeContainer;
-
-             PVMFNodeSessionInfo sessionControllerSession(this,
-                     this,
-                     OSCL_REINTERPRET_CAST(OsclAny*,
-                                           iSessionControllerNode),
-                     this,
-                     OSCL_REINTERPRET_CAST(OsclAny*,
-                                           iSessionControllerNode));
-
-             sSessionControllerNodeContainer.iNode = iSessionControllerNode;
-             sSessionControllerNodeContainer.iSessionId =
-                 iSessionControllerNode->Connect(sessionControllerSession);
-             sSessionControllerNodeContainer.iNodeTag =
-                 PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE;
-             sSessionControllerNodeContainer.commandStartOffset =
-                 PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_COMMAND_START;
-             /* Push back the known UUID in case there are no queries */
-             sSessionControllerNodeContainer.iExtensionUuids.push_back(KPVRTSPEngineNodeExtensionUuid);
-             iNodeContainerVec.push_back(sSessionControllerNodeContainer);
-
-             /*
-              * Create jitter buffer node
-              */
-             OsclExclusivePtr<PVMFNodeInterface> jitterBufferNodeAutoPtr;
-             PVMFNodeInterface* iJitterBufferNode;
-             PVMF_STREAMING_MANAGER_NEW(NULL,
-                                        PVMFJitterBufferNode,
-                                        (OsclActiveObject::EPriorityNominal),
-                                        iJitterBufferNode);
-             jitterBufferNodeAutoPtr.set(iJitterBufferNode);
-
-             PVMFSMNodeContainer sJitterBufferNodeContainer;
-
-             PVMFNodeSessionInfo jitterBufferSession(this,
-                                                     this,
-                                                     OSCL_REINTERPRET_CAST(OsclAny*,
-                                                                           iJitterBufferNode),
-                                                     this,
-                                                     OSCL_REINTERPRET_CAST(OsclAny*,
-                                                                           iJitterBufferNode));
-
-             sJitterBufferNodeContainer.iNode = iJitterBufferNode;
-             sJitterBufferNodeContainer.iSessionId =
-                 iJitterBufferNode->Connect(jitterBufferSession);
-             sJitterBufferNodeContainer.iNodeTag =
-                 PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE;
-             sJitterBufferNodeContainer.commandStartOffset =
-                 PVMF_STREAMING_MANAGER_JITTER_BUFFER_CONTROLLER_COMMAND_START;
-             /* Push back the known UUID in case there are no queries */
-             sJitterBufferNodeContainer.iExtensionUuids.push_back(PVMF_JITTERBUFFERNODE_EXTENSIONINTERFACE_UUID);
-             iNodeContainerVec.push_back(sJitterBufferNodeContainer);
-
-             /*
-              * Create media layer node
-              */
-             OsclExclusivePtr<PVMFNodeInterface> mediaLayerNodeAutoPtr;
-             PVMFNodeInterface* iMediaLayerNode;
-             PVMF_STREAMING_MANAGER_NEW(NULL,
-                                        PVMFMediaLayerNode,
-                                        (OsclActiveObject::EPriorityNominal),
-                                        iMediaLayerNode);
-             mediaLayerNodeAutoPtr.set(iMediaLayerNode);
-
-             PVMFSMNodeContainer sMediaLayerNodeContainer;
-
-             PVMFNodeSessionInfo mediaLayerSession(this,
-                                                   this,
-                                                   OSCL_REINTERPRET_CAST(OsclAny*,
-                                                                         iMediaLayerNode),
-                                                   this,
-                                                   OSCL_REINTERPRET_CAST(OsclAny*,
-                                                                         iMediaLayerNode));
-
-             sMediaLayerNodeContainer.iNode = iMediaLayerNode;
-             sMediaLayerNodeContainer.iSessionId =
-                 iMediaLayerNode->Connect(mediaLayerSession);
-             sMediaLayerNodeContainer.iNodeTag =
-                 PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE;
-             sMediaLayerNodeContainer.commandStartOffset =
-                 PVMF_STREAMING_MANAGER_MEDIA_LAYER_COMMAND_START;
-             /* Push back the known UUID in case there are no queries */
-             sMediaLayerNodeContainer.iExtensionUuids.push_back(PVMF_MEDIALAYERNODE_EXTENSIONINTERFACE_UUID);
-             iNodeContainerVec.push_back(sMediaLayerNodeContainer);
-
-             for (int32 i = 0; i < PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE; i++)
-{
-    iInternalCmdPool[i].cmd = PVMF_STREAMING_MANAGER_INTERNAL_COMMAND_NONE;
-        iInternalCmdPool[i].oFree = true;
-    }
-
-    sessionControllerAutoPtr.release();
-    socketNodeAutoPtr.release();
-    jitterBufferNodeAutoPtr.release();
-    mediaLayerNodeAutoPtr.release();
-
-    // Allocate memory for metadata key list
-    iAvailableMetadataKeys.reserve(PVMFSTREAMINGMGRNODE_NUM_METADATAKEYS);
-    iAvailableMetadataKeys.clear();
+             iSMFSPRegistry = OSCL_NEW(PVMFSMFSPRegistry, ());
             );
-    if (err != OsclErrNone)
-    {
-        CleanUp();
-        OSCL_LEAVE(err);
-    }
 
     if (err != OsclErrNone)
     {
-        CleanUp();
         OSCL_LEAVE(err);
     }
-
-    if (err != OsclErrNone)
-    {
-        CleanUp();
-        OSCL_LEAVE(err);
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::PVMFStreamingManagerNode - Out"));
-}
-
-void PVMFStreamingManagerNode::CleanUp()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CleanUp - In"));
-
-    /*
-     * if a leave happened, cleanup and re-throw the error
-     */
-    iInputCommands.clear();
-    iCurrentCommand.clear();
-
-    PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                  PVMFSMSessionSourceInfo,
-                                  iSessionSourceInfo);
-    /*
-     * Clean up all children nodes
-     */
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_SOCKET_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFSocketNode,
-                                          ((PVMFSocketNode*)(iNodeContainerVec[i].iNode)));
-        }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE)
-        {
-            PVMFRrtspEngineNodeFactory::DeletePVMFRtspEngineNode(iNodeContainerVec[i].iNode);
-            iNodeContainerVec[i].iNode = NULL;
-        }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFJitterBufferNode,
-                                          ((PVMFJitterBufferNode*)(iNodeContainerVec[i].iNode)));
-        }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFMediaLayerNode,
-                                          ((PVMFMediaLayerNode*)(iNodeContainerVec[i].iNode)));
-        }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_RTPPACKETSOURCE_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFMediaLayerNode,
-                                          ((PVMFMediaLayerNode*)(iNodeContainerVec[i].iNode)));
-        }
-
-    }
-    iNodeContainerVec.clear();
-    iCapability.iInputFormatCapability.clear();
-    iCapability.iOutputFormatCapability.clear();
-    OSCL_CLEANUP_BASE_CLASS(PVMFNodeInterface);
-    OSCL_CLEANUP_BASE_CLASS(OsclActiveObject);
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CleanUp - Out"));
-    return;
 }
 
 OSCL_EXPORT_REF PVMFStreamingManagerNode::~PVMFStreamingManagerNode()
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::~PVMFStreamingManagerNode - In"));
 
-    Cancel();
-
-    /* Reset the metadata key list */
-    /* Clean up CPM related variables */
-    CleanupCPMdata();
-    /*Cleanup CPM instance*/
-    if (iCPM != NULL)
+    if (iSMFSPlugin)
     {
-        iCPM->ThreadLogoff();
-        PVMFCPMFactory::DestroyContentPolicyManager(iCPM);
-        iCPM = NULL;
-    }
-
-    /* thread logoff */
-    if (IsAdded())
-        RemoveFromScheduler();
-
-    /* Cleanup any old key */
-    if (iRequestedUsage.key)
-    {
-        OSCL_ARRAY_DELETE(iRequestedUsage.key);
-        iRequestedUsage.key = NULL;
-    }
-
-    if (iApprovedUsage.key)
-    {
-        OSCL_ARRAY_DELETE(iApprovedUsage.key);
-        iApprovedUsage.key = NULL;
-    }
-
-    if (iAuthorizationDataKvp.key)
-    {
-        OSCL_ARRAY_DELETE(iAuthorizationDataKvp.key);
-        iAuthorizationDataKvp.key = NULL;
-    }
-
-    /* Cleanup allocated interfaces */
-    if (iExtensionInterface)
-    {
-        /*
-         * clear the interface container
-         * the interface can't function without the node.
-         */
-        iExtensionInterface->iContainer = NULL;
-        iExtensionInterface->removeRef();
-    }
-
-    /*
-     * Cleanup commands
-     * The command queues are self-deleting, but we want to
-     * notify the observer of unprocessed commands.
-     */
-    while (iCurrentCommand.size() > 0)
-    {
-        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
-    }
-    while (iInputCommands.size() > 0)
-    {
-        CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
-    }
-
-    PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                  PVMFSMSessionSourceInfo,
-                                  iSessionSourceInfo);
-
-    /*
-     * Clean up all children nodes & interfaces
-     */
-    uint32 i, j;
-    for (i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        for (j = 0; j < iNodeContainerVec[i].iExtensions.size(); j++)
+        if (iSMFSPRegistry)
         {
-            PVInterface* extIntf = iNodeContainerVec[i].iExtensions[j];
-            extIntf->removeRef();
-        }
+            if (iFSPDataSourceInitializationIntf)
+            {
+                iFSPDataSourceInitializationIntf->removeRef();
+                iFSPDataSourceInitializationIntf = NULL;
+            }
 
-        if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_SOCKET_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFSocketNode,
-                                          ((PVMFSocketNode*)(iNodeContainerVec[i].iNode)));
+            bool retval = iSMFSPRegistry->ReleaseSMFSP(iFSPUuid, iSMFSPlugin);
+            if (false == retval)
+            {
+                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::~PVMFStreamingManagerNode - Error FSP could not be deleted "));
+            }
+            iSMFSPlugin = NULL;
         }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE)
-        {
-            PVMFRrtspEngineNodeFactory::DeletePVMFRtspEngineNode(iNodeContainerVec[i].iNode);
-            iNodeContainerVec[i].iNode = NULL;
-        }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFJitterBufferNode,
-                                          ((PVMFJitterBufferNode*)(iNodeContainerVec[i].iNode)));
-        }
-        else if (iNodeContainerVec[i].iNodeTag == PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE)
-        {
-            PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                          PVMFMediaLayerNode,
-                                          ((PVMFMediaLayerNode*)(iNodeContainerVec[i].iNode)));
-        }
-
     }
-    iNodeContainerVec.clear();
+    if (iSMFSPRegistry)
+    {
+        OSCL_DELETE(iSMFSPRegistry);
+        iSMFSPRegistry = NULL;
+    }
 
-    // destroy the payload parser registry
-    destroyPayloadParserRegistry();
-
+    iLogger = NULL;
 
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::~PVMFStreamingManagerNode - Out"));
 }
 
-void PVMFStreamingManagerNode::CleanupCPMdata()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CleanupCPMdata() Called"));
-
-    /* Clean up CPM related variables */
-    iSourceContextDataValid = false;
-    iUseCPMPluginRegistry   = false;
-    if (iCPMContentAccessFactory != NULL)
-    {
-        if (iDecryptionInterface != NULL)
-        {
-            iDecryptionInterface->Reset();
-            /* Remove the decrpytion interface */
-            PVUuid uuid = PVMFCPMPluginDecryptionInterfaceUuid;
-            iCPMContentAccessFactory->DestroyPVMFCPMPluginAccessInterface(uuid, iDecryptionInterface);
-            iDecryptionInterface = NULL;
-        }
-        iCPMContentAccessFactory->removeRef();
-        iCPMContentAccessFactory = NULL;
-    }
-    iCPMContentType = PVMF_CPM_CONTENT_FORMAT_UNKNOWN;
-    iPreviewMode = false;
-    iCPMInitPending = false;
-    iCPMMetadataKeys.clear();
-}
-
-/* Called during a Reset */
-void PVMFStreamingManagerNode::ResetNodeParams()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ResetNodeParams - In"));
-
-    iTotalNumRequestPortsComplete = 0;
-    iNumRequestPortsPending = 0;
-    iTotalNumInitPhaseRequestPortsComplete = 0;
-    iTotalNumInitPhaseRequestPortsPending = 0;
-    oGraphConstructComplete = false;
-    oGraphConnectComplete = false;
-    iAutoPausePending = false;
-    iAutoResumePending = 0;
-    iAutoPaused = false;
-    iStreamThinningInProgress = false;
-    iPlaylistPlayInProgress = false;
-    iSwitchStreamIFrameVideo = false;
-
-    iMetaDataInfo.Reset();
-    iTrackInfoVec.clear();
-
-    PVMFSMNodeContainerVector::iterator it;
-    for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-    {
-        it->Reset();
-    }
-
-    /* Delete current session info and recreate a new one */
-    PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                  PVMFSMSessionSourceInfo,
-                                  iSessionSourceInfo);
-    iSessionSourceInfo = NULL;
-
-    PVMF_STREAMING_MANAGER_NEW(NULL,
-                               PVMFSMSessionSourceInfo,
-                               (),
-                               iSessionSourceInfo);
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ResetNodeParams - Out"));
-}
-
-/**
- * Do thread-specific node creation and go to "Idle" state.
- */
+/* PVMFNodeInterface's virtual functions implemenation*/
 OSCL_EXPORT_REF PVMFStatus PVMFStreamingManagerNode::ThreadLogon()
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ThreadLogon - In"));
@@ -791,83 +134,49 @@
         {
             if (!IsAdded())
                 AddToScheduler();
-
-            iCmdSeqLogger = PVLogger::GetLoggerObject("pvplayercmdseq.streamingmanager");
-            iReposLogger = PVLogger::GetLoggerObject("pvplayerrepos.sourcenode.streamingmanager");
-
-            /*
-             * Call thread logon for all the children nodes
-             */
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                if (iNodeContainerVec[i].iNode->ThreadLogon() != PVMFSuccess)
-                {
-                    PVMF_SM_LOGERROR((0, "StreamingManagerNode - Child Node:ThreadLogon Failed, Node Tag %d", iNodeContainerVec[i].iNodeTag));
-                    status = PVMFFailure;
-                }
-            }
-            if (status == PVMFSuccess)
-            {
-                PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::ThreadLogon() - State - EPVMFNodeIdle"));
-                SetState(EPVMFNodeIdle);
-            }
+            iLogger = PVLogger::GetLoggerObject("PVMFStreamingManagerNode");
+            SetState(EPVMFNodeIdle);
         }
         break;
         default:
             status = PVMFErrInvalidState;
             break;
     }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ThreadLogon - Out"));
+
+    if (PVMFSuccess == status && iSMFSPlugin)
+    {
+        status = iSMFSPlugin->ThreadLogon();
+    }
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ThreadLogon - Out status[%d]", status));
     return (status);
 }
 
-/**
- * Do thread-specific node cleanup and go to "Created" state.
- */
 OSCL_EXPORT_REF PVMFStatus PVMFStreamingManagerNode::ThreadLogoff()
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ThreadLogoff - In"));
 
+
     PVMFStatus status = PVMFSuccess;
+
+    if (iSMFSPlugin)
+    {
+        status = iSMFSPlugin->ThreadLogoff();
+        OSCL_ASSERT(PVMFFailure != status);
+        if (PVMFSuccess != status)
+        {
+            return status;
+        }
+    }
+
     switch (iInterfaceState)
     {
         case EPVMFNodeIdle:
         {
-            /* Reset the metadata key list */
-            /* Clean up CPM related variables */
-            CleanupCPMdata();
-
+            iLogger = NULL;
             if (IsAdded())
                 RemoveFromScheduler();
-            iLogger = NULL;
-            iCmdSeqLogger = NULL;
-            iReposLogger = NULL;
-
-            /*
-             * Call thread logon for all the children nodes
-             */
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                PVMFNodeInterface* node = iNodeContainerVec[i].iNode;
-                if (node->GetState() != EPVMFNodeCreated)
-                {
-                    if (node->ThreadLogoff() != PVMFSuccess)
-                    {
-                        PVMF_SM_LOGERROR((0, "StreamingManagerNode - Child Node:ThreadLogoff Failed, Node Tag %d", iNodeContainerVec[i].iNodeTag));
-                        status = PVMFFailure;
-                    }
-                }
-            }
-            if (status == PVMFSuccess)
-            {
-                SetState(EPVMFNodeCreated);
-                PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::ThreadLogoff() - State - EPVMFNodeIdle"));
-            }
-            else
-            {
-                SetState(EPVMFNodeError);
-                PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::ThreadLogoff() - State - EPVMFNodeError"));
-            }
+            SetState(EPVMFNodeCreated);
         }
         break;
 
@@ -879,1985 +188,476 @@
             status = PVMFErrInvalidState;
             break;
     }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ThreadLogoff - Out"));
-    return (status);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ThreadLogoff - Out status[%d]", status));
+    return status;
 }
 
-/**
- * retrieve node capabilities.
- */
+PVMFSessionId PVMFStreamingManagerNode::Connect(const PVMFNodeSessionInfo &aSession)
+{
+    iUpstreamSession.iId = PVMFNodeInterface::Connect(aSession);
+    iUpstreamSession.iInfo =  aSession;
+    if (iSMFSPlugin)
+    {
+        iSMFSPlugin->Connect(iUpstreamSession);
+    }
+    return iUpstreamSession.iId;
+}
+
+PVMFStatus PVMFStreamingManagerNode::Disconnect(PVMFSessionId aSessionId)
+{
+    if (iSMFSPlugin)
+        iSMFSPlugin->Disconnect(aSessionId);
+    return PVMFNodeInterface::Disconnect(aSessionId);
+}
+
 OSCL_EXPORT_REF PVMFStatus PVMFStreamingManagerNode::GetCapability(PVMFNodeCapability& aNodeCapability)
 {
-    PVMF_SM_LOGINFO((0, "StreamingManagerNode:GetCapability"));
-    aNodeCapability = iCapability;
-    return PVMFSuccess;
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetCapability - In"));
+
+    PVMFStatus status = PVMFSuccess;
+    if (iSMFSPlugin)
+    {
+        status = iSMFSPlugin->GetCapability(aNodeCapability);
+    }
+    else
+    {
+        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetCapability - Error iSMFSPlugin 0x%x, ", iSMFSPlugin));
+        status = PVMFFailure;
+    }
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetCapability - Out status[%d]", status));
+    return status;
 }
 
-/**
- * retrive a port iterator.
- */
 OSCL_EXPORT_REF PVMFPortIter* PVMFStreamingManagerNode::GetPorts(const PVMFPortFilter* aFilter)
 {
-    PVMF_SM_LOGINFO((0, "StreamingManagerNode:GetPorts"));
-    OSCL_UNUSED_ARG(aFilter);//port filter is not implemented.
-    return NULL;
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetPorts - In"));
+
+    PVMFPortIter* portIter = NULL;
+    if (iSMFSPlugin)
+    {
+        portIter = iSMFSPlugin->GetPorts(aFilter);
+    }
+    else
+    {
+        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetPorts - Error iSMFSPlugin 0x%x", iSMFSPlugin));
+    }
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetPorts - Out portIter[0x%x]", portIter));
+    return portIter;
 }
 
-/**
- * Queue an asynchronous QueryUUID command
- * QueryUUID for the streaming manager node is not complete until QueryUUIDs
- * are complete for all the children node (viz. session controller, jitter buffer
- * controller etc)
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::QueryUUID(PVMFSessionId s, const PvmfMimeString& aMimeType,
-        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::QueryUUID(PVMFSessionId aSessId,
+        const PvmfMimeString& aMimeType,
+        Oscl_Vector< PVUuid, OsclMemAllocator >& aUuids,
         bool aExactUuidsOnly,
         const OsclAny* aContext)
 {
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryUUID - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_QUERYUUID, aMimeType, aUuids, aExactUuidsOnly, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryUUID - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::QueryUUID() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::QueryUUID - Error Deprecated Interface - Call Not Expected"));
+    OSCL_UNUSED_ARG(aSessId);
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aUuids);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+    OSCL_UNUSED_ARG(aContext);
+    //We dont expect the user of streaming manager node to call QueryUUID, this API is deprecated for SM node.
+    OSCL_LEAVE(OsclErrNotSupported);
+    return 0;
 }
 
-/**
- * Called by the command handler AO to do the Query UUID
- */
-void PVMFStreamingManagerNode::DoQueryUuid(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryUuid - In"));
-    if (iQueryUUIDComplete == false)
-    {
-        /*
-         * QueryUUID for streaming manager cannot be completed unless
-         * QueryUUID for all the children nodes are complete
-         */
-
-        PVMFSMCommandContext* internalCmd = NULL;
-        OsclAny *cmdContextData  = NULL;
-        /*
-         * QueryUUID from socket node
-         */
-        OSCL_StackString<50> socketNodeExtMimeType(PVMF_SOCKET_NODE_EXTENSION_INTERFACE_MIMETYPE);
-
-        internalCmd = RequestNewInternalCmd();
-        if (internalCmd == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoQueryUuid:RequestNewInternalCmd - Failed"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-            return;
-        }
-        internalCmd->cmd = PVMF_STREAMING_MANAGER_SOCKET_NODE_QUERY_UUID;
-        internalCmd->parentCmd = aCmd.iCmd;
-        cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-        PVMFSMNodeContainer* iSocketNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-        if (iSocketNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFNodeInterface* iSocketNode = iSocketNodeContainer->iNode;
-
-        iSocketNode->QueryUUID(iSocketNodeContainer->iSessionId,
-                               socketNodeExtMimeType,
-                               iSocketNodeContainer->iExtensionUuids,
-                               true,
-                               cmdContextData);
-        iSocketNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-
-        /*
-         * QueryUUID from rtsp session controller
-         */
-        OSCL_StackString<50> sessionControllerExtMimeType(PVMF_RTSPENGINENODE_CUSTOM1_MIMETYPE);
-
-        internalCmd = RequestNewInternalCmd();
-        if (internalCmd == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoQueryUuid:RequestNewInternalCmd - Failed"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-            return;
-        }
-        internalCmd->cmd = PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_QUERY_UUID;
-        internalCmd->parentCmd = aCmd.iCmd;
-        cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFNodeInterface* iSessionControllerNode = iSessionControllerNodeContainer->iNode;
-
-        iSessionControllerNode->QueryUUID(iSessionControllerNodeContainer->iSessionId,
-                                          sessionControllerExtMimeType,
-                                          iSessionControllerNodeContainer->iExtensionUuids,
-                                          true,
-                                          cmdContextData);
-        iSessionControllerNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-
-        /*
-         * QueryUUID from jitter buffer node
-         */
-        OSCL_StackString<50> jitterBufferExtMimeType(PVMF_JITTERBUFFER_CUSTOMINTERFACE_MIMETYPE);
-
-        internalCmd = RequestNewInternalCmd();
-        if (internalCmd == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoQueryUuid:RequestNewInternalCmd - Failed"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-            return;
-        }
-        internalCmd->cmd = PVMF_STREAMING_MANAGER_JITTER_BUFFER_QUERY_UUID;
-        internalCmd->parentCmd = aCmd.iCmd;
-        cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-        PVMFSMNodeContainer* iJitterBufferNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFNodeInterface* iJitterBufferNode = iJitterBufferNodeContainer->iNode;
-
-        iJitterBufferNode->QueryUUID(iJitterBufferNodeContainer->iSessionId,
-                                     jitterBufferExtMimeType,
-                                     iJitterBufferNodeContainer->iExtensionUuids,
-                                     true,
-                                     cmdContextData);
-        iJitterBufferNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-
-        /*
-         * QueryUUID from media layer node
-         */
-        OSCL_StackString<50> mediaLayerExtMimeType(PVMF_MEDIALAYER_CUSTOMINTERFACE_MIMETYPE);
-
-        internalCmd = RequestNewInternalCmd();
-        if (internalCmd == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoQueryUuid:RequestNewInternalCmd - Failed"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-            return;
-        }
-        internalCmd->cmd = PVMF_STREAMING_MANAGER_MEDIA_LAYER_QUERY_UUID;
-        internalCmd->parentCmd = aCmd.iCmd;
-        cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-        PVMFSMNodeContainer* iMediaLayerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-        if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFNodeInterface* iMediaLayerNode = iMediaLayerNodeContainer->iNode;
-
-        iMediaLayerNode->QueryUUID(iMediaLayerNodeContainer->iSessionId,
-                                   mediaLayerExtMimeType,
-                                   iMediaLayerNodeContainer->iExtensionUuids,
-                                   true,
-                                   cmdContextData);
-        iMediaLayerNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-        /*
-         * QueryUUID from HTTP PE node
-         */
-        OSCL_StackString<50> httpNodeExtMimeType(PVMF_PROTOCOL_ENGINE_MSHTTP_STREAMING_EXTENSION_MIMETYPE);
-
-        internalCmd = RequestNewInternalCmd();
-        if (internalCmd == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoQueryUuid:RequestNewInternalCmd - Failed"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-            return;
-        }
-        internalCmd->cmd = PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_QUERY_UUID;
-        internalCmd->parentCmd = aCmd.iCmd;
-        cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-        PVMFSMNodeContainer* iHTTPNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE);
-        if (iHTTPNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFNodeInterface* iHTTPNode = iHTTPNodeContainer->iNode;
-
-        iHTTPNode->QueryUUID(iHTTPNodeContainer->iSessionId,
-                             httpNodeExtMimeType,
-                             iHTTPNodeContainer->iExtensionUuids,
-                             true,
-                             cmdContextData);
-        iHTTPNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-
-        /*
-         * This node supports Query UUID from any state
-         * Query UUID is asynchronous. move the command from
-         * the input command queue to the current command, where
-         * it will remain until the Query UUID completes.
-         */
-        MoveCmdToCurrentQueue(aCmd);
-    }
-    else if (iQueryUUIDComplete == true)
-    {
-        /*
-         * We have already queried the child nodes for UUID
-         */
-        MoveCmdToCurrentQueue(aCmd);
-        CompleteQueryUuid();
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryUuid - Out"));
-    return;
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesQueryUuid()
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-        {
-            return false;
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteQueryUuid()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteQueryUuid - In"));
-    if (CheckChildrenNodesQueryUuid() || iQueryUUIDComplete == true)
-    {
-        PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-
-        OSCL_String* mimetype;
-        Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
-        bool exactmatch;
-        aCmd.PVMFStreamingManagerNodeCommandBase::Parse(mimetype, uuidvec, exactmatch);
-
-        /*
-         * Try to match the input mimetype against any of
-         * the custom interfaces for this node
-         * Match against extension interface...
-         * also match against base mimetypes for extension interface,
-         * unless exactmatch is set.
-         */
-        if (*mimetype == PVMF_STREAMINGMANAGER_CUSTOMINTERFACE_MIMETYPE)
-        {
-            PVUuid uuid(PVMF_STREAMINGMANAGERNODE_EXTENSIONINTERFACE_UUID);
-            uuidvec->push_back(uuid);
-        }
-        else if (*mimetype == PVMF_DATA_SOURCE_INIT_INTERFACE_MIMETYPE)
-        {
-            PVUuid uuid(PVMF_DATA_SOURCE_INIT_INTERFACE_UUID);
-            uuidvec->push_back(uuid);
-        }
-        else if (*mimetype == PVMF_TRACK_SELECTION_INTERFACE_MIMETYPE)
-        {
-            PVUuid uuid(PVMF_TRACK_SELECTION_INTERFACE_UUID);
-            uuidvec->push_back(uuid);
-        }
-        else if (*mimetype == PVMF_DATA_SOURCE_PLAYBACK_CONTROL_INTERFACE_MIMETYPE)
-        {
-            PVUuid uuid(PvmfDataSourcePlaybackControlUuid);
-            uuidvec->push_back(uuid);
-        }
-        else if (*mimetype == PVMF_META_DATA_EXTENSION_INTERFACE_MIMETYPE)
-        {
-            PVUuid uuid(KPVMFMetadataExtensionUuid);
-            uuidvec->push_back(uuid);
-        }
-
-        PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::QueryUUID() - CmdComplete - PVMFSuccess"));
-        iQueryUUIDComplete = true;
-
-        CommandComplete(aCmd, PVMFSuccess);
-        /* Erase the command from the current queue */
-        iCurrentCommand.Erase(&iCurrentCommand.front());
-        PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode::QueryUuid Complete"));
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteQueryUuid - Out"));
-}
-
-/**
- * Queue an asynchronous node command QueryInterface
- */
-OSCL_EXPORT_REF PVMFCommandId
-PVMFStreamingManagerNode::QueryInterface(PVMFSessionId s,
-        const PVUuid& aUuid,
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::QueryInterface(PVMFSessionId aSessId, const PVUuid& aUuid,
         PVInterface*& aInterfacePtr,
         const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryInterface - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryInterface - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::QueryInterface() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    //Check if we can handle this API in this node itself
+    PVInterface* ifptr = NULL;
+    if (queryInterface(aUuid, ifptr) == false)
+    {
+        if (!iSMFSPlugin)
+            OSCL_LEAVE(OsclErrInvalidState);
+        return 	iSMFSPlugin->QueryInterface(aSessId, aUuid, aInterfacePtr, aContext);
+    }
+    else
+    {
+        PVMFStreamingManagerNodeCommand cmd;
+        cmd.Construct(aSessId, PVMF_STREAMING_MANAGER_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext);
+        PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryInterface - Out"));
+        return QueueCommandL(cmd);
+    }
 }
 
-/**
- * Called by the command handler AO to do the Query Interface.
- */
-void PVMFStreamingManagerNode::DoQueryInterface(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryInterface - In"));
-    if (iQueryInterfaceComplete == false)
-    {
-        /*
-         * QueryInterface for streaming manager cannot be completed unless
-         * QueryInterface for all the children nodes are complete
-         */
-        for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-        {
-            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-            if (internalCmd != NULL)
-            {
-                internalCmd->cmd =
-                    iNodeContainerVec[i].commandStartOffset +
-                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_QUERY_INTERFACE_CMD_OFFSET;
-                internalCmd->parentCmd = aCmd.iCmd;
-
-                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                iNode->QueryInterface(iNodeContainerVec[i].iSessionId,
-                                      iNodeContainerVec[i].iExtensionUuids.front(),
-                                      iExtensionInterfacePlaceholder,
-                                      cmdContextData);
-                iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoQueryInterface:RequestNewInternalCmd - Failed"));
-                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                return;
-            }
-        }
-        /*
-         * This node supports QueryInterface from any state
-         * QueryInterface is asynchronous. move the command from
-         * the input command queue to the current command, where
-         * it will remain until the QueryInterface completes.
-         */
-        MoveCmdToCurrentQueue(aCmd);
-    }
-    else if (iQueryInterfaceComplete == true)
-    {
-        /*
-         * We have already queried the child nodes for interface
-         */
-        MoveCmdToCurrentQueue(aCmd);
-        CompleteQueryInterface();
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryInterface - Out"));
-    return;
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesQueryInterface()
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-        {
-            return false;
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteQueryInterface()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteQueryInterface - In"));
-    if (CheckChildrenNodesQueryInterface() || iQueryInterfaceComplete == true)
-    {
-        PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-
-        PVUuid* uuid;
-        PVInterface** ptr;
-        aCmd.PVMFStreamingManagerNodeCommandBase::Parse(uuid, ptr);
-
-        if ((*uuid == PVUuid(PVMF_STREAMINGMANAGERNODE_EXTENSIONINTERFACE_UUID)) ||
-                (*uuid == PVUuid(PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)) ||
-                (*uuid == PVUuid(PVMF_TRACK_SELECTION_INTERFACE_UUID)) ||
-                (*uuid == PVUuid(PvmfDataSourcePlaybackControlUuid)) ||
-                (*uuid == PVUuid(KPVMFMetadataExtensionUuid)) ||
-                (*uuid == PVUuid(PVMI_CAPABILITY_AND_CONFIG_PVUUID)) ||
-                (*uuid == PVUuid(PVMFCPMPluginLicenseInterfaceUuid)))
-        {
-            if (!iExtensionInterface)
-            {
-                PVMFStreamingManagerNodeAllocator alloc;
-                int32 err;
-                OsclAny*ptr = NULL;
-                OSCL_TRY(err,
-                         ptr = alloc.ALLOCATE(sizeof(PVMFStreamingManagerExtensionInterfaceImpl));
-                        );
-                if (err != OsclErrNone || !ptr)
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode CompleteQueryInterface Failed"));
-                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                    return;
-                }
-                iExtensionInterface =
-                    new(ptr) PVMFStreamingManagerExtensionInterfaceImpl(this,
-                            aCmd.iSession);
-            }
-
-            iQueryInterfaceComplete = true;
-            iExtensionInterface->queryInterface(*uuid, *ptr);
-            iExtensionInterface->addRef();
-            PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::QueryInterface() - CmdComplete - PVMFSuccess"));
-            CommandComplete(aCmd, PVMFSuccess);
-            /* Erase the command from the current queue */
-            iCurrentCommand.Erase(&iCurrentCommand.front());
-
-            PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode CompleteQueryInterface Success"));
-        }
-        else
-        {
-            PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::QueryInterface() - CmdFailed - PVMFErrNotSupported"));
-            //not supported
-            *ptr = NULL;
-            CommandComplete(aCmd, PVMFErrNotSupported);
-            /* Erase the command from the current queue */
-            iCurrentCommand.Erase(&iCurrentCommand.front());
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteQueryInterface - Out"));
-}
-
-/**
- * Queue an asynchronous node command - RequestPort
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::RequestPort(PVMFSessionId s,
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::RequestPort(PVMFSessionId aSessId,
         int32 aPortTag,
         const PvmfMimeString* aPortConfig,
         const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::RequestPort - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s,
-            PVMF_STREAMING_MANAGER_NODE_REQUESTPORT,
-            aPortTag,
-            aPortConfig,
-            aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::RequestPort - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::RequestPort() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
+
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->RequestPort(aSessId, aPortTag, aPortConfig, aContext);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::RequestPort - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Called by the command handler AO to do the port request
- */
-void PVMFStreamingManagerNode::DoRequestPort(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoRequestPort - In"));
-    /*
-     * This node supports port request only after the graph
-     * has been fully constructed
-     */
-    if (oGraphConstructComplete)
-    {
-        /*
-         * retrieve port tag
-         */
-        OSCL_String* mimetype;
-        int32 tag;
-        aCmd.PVMFStreamingManagerNodeCommandBase::Parse(tag, mimetype);
-        /*
-         * Do not Allocate a new port. Streaming manager treats the output
-         * port from the media layer as its own output port. Find the media
-         * layer output port corresponding to the input mimetype and hand the
-         * same out
-         */
-        PVMFSMTrackInfo* trackInfo = FindTrackInfo(tag);
-
-        PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
-        int32 errcode = PVMFStreamingManagerNodeErrorInvalidRequestPortTag;
-
-        if (trackInfo == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoRequestPort: FindTrackInfo failed"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
-            return;
-        }
-        if (trackInfo->iMediaLayerOutputPort == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoRequestPort: iMediaLayerOutputPort NULL"));
-            CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
-            return;
-        }
-        PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::RequestPort() - CmdComplete - PVMFSuccess"));
-        /*
-         * Return the port pointer to the caller.
-         */
-        CommandComplete(iInputCommands,
-                        aCmd,
-                        PVMFSuccess,
-                        (OsclAny*)(trackInfo->iMediaLayerOutputPort));
-
-        PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode::DoRequestPort Success"));
-    }
-    else
-    {
-        PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::RequestPort() - CmdFailed - PVMFErrInvalidState"));
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoRequestPort Failed - InvalidState"));
-        CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoRequestPort - Out"));
-}
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::ReleasePort(PVMFSessionId s, PVMFPortInterface& aPort, const OsclAny* aContext)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::ReleasePort(PVMFSessionId aSessId,
+        PVMFPortInterface& aPort,
+        const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ReleasePort - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_RELEASEPORT, aPort, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ReleasePort - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::ReleasePort() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
+
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->ReleasePort(aSessId, aPort, aContext);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ReleasePort - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Called by the command handler AO to do the port release
- */
-void PVMFStreamingManagerNode::DoReleasePort(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoReleasePort - In"));
-    /*
-     * Since the streaming manager does not have ports of its own,
-     * a release port command typically translates to disconnecting
-     * the underlying media layer port.
-     */
-    PVMFPortInterface* port;
-    aCmd.PVMFStreamingManagerNodeCommandBase::Parse((PVMFPortInterface*&)port);
-
-    /*
-     * Find TrackInfo that corresponds to the Media Layer Output port
-     * on which the current relase is being called.
-     */
-    PVMFSMTrackInfoVector::iterator it;
-    PVMFSMTrackInfo* trackInfo = NULL;
-
-    for (it = iTrackInfoVec.begin();
-            it != iTrackInfoVec.end();
-            it++)
-    {
-        if (it->iMediaLayerOutputPort == port)
-        {
-            trackInfo = it;
-            break;
-        }
-    }
-
-    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
-    if (trackInfo == NULL)
-    {
-        PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::ReleasePort() - CmdFailed - PVMFErrArgument"));
-        /* invalid port */
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoReleasePort Failed - Invalid Port"));
-        int32 errcode = PVMFStreamingManagerNodeErrorInvalidPort;
-        CommandComplete(iInputCommands, aCmd, PVMFErrArgument, NULL, &eventuuid, &errcode);
-        return;
-    }
-    PVMFStatus status = it->iMediaLayerOutputPort->Disconnect();
-
-    if (status != PVMFSuccess)
-    {
-        PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode::DoReleasePort Success"));
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    else
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoReleasePort Failed"));
-        CommandComplete(iInputCommands, aCmd, PVMFErrPortProcessing);
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoReleasePort - Out"));
-}
-
-/**
- * Queue an asynchronous node command - Init
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Init(PVMFSessionId s, const OsclAny* aContext)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Init(PVMFSessionId aSessId,
+        const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Init - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_INIT, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Init - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Init() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
+
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->Init(aSessId, aContext);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Init - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Call by DoInit as a prep step
- */
-PVMFStatus PVMFStreamingManagerNode::DoPreInit(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoPreInit - In"));
-    PVMFStatus status = PVMFSuccess;
-
-    if (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE)
-    {
-    }
-    else if (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE)
-    {
-        status = ProcessSDP();
-        if (status == PVMFSuccess)
-        {
-            PVMFSMNodeContainer* iSessionControllerNodeContainer =
-                getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-
-            if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-            PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                (PVRTSPEngineNodeExtensionInterface*)
-                (iSessionControllerNodeContainer->iExtensions[0]);
-
-            /*
-             * This vector is intentionally left uninitialized.
-             * Streaming manager does not have any track selection info
-             * at this stage. "SetSDPInfo" would be called again before
-             * prepare complete to set up all the selected tracks. This
-             * call is needed here to indicate to Session Controller node
-             * that it is NOT a RTSP URL based session
-             */
-            Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
-
-            status = rtspExtIntf->SetSDPInfo(iSessionSourceInfo->_sdpInfo,
-                                             aSelectedStream);
-            if (status != PVMFSuccess)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoPreInit - SetSDPInfo Failed"));
-            }
-        }
-        else
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoPreInit - ProcessSDP Failed"));
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoPreInit - Out"));
-    return status;
-}
-
-void PVMFStreamingManagerNode::CompletePreInit()
-{
-    OSCL_ASSERT(iSessionSourceInfo->_sessionType ==
-                PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-
-    Asf_CompletePreInit();
-}
-
-/**
- * Called by the command handler AO to do the node Init
- */
-void PVMFStreamingManagerNode::DoInit(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoInit - In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeIdle:
-        {
-            /*
-             * At first Init, PVMFErrLicneseRequest is replied from Janus.
-             * Then iCPMInitPending is set into true.
-             * If second Init is called, just to check license authentication is required.
-             */
-            if (iCPMInitPending == true)
-            {
-                MoveCmdToCurrentQueue(aCmd);
-                {
-                    CommandComplete(iCurrentCommand,
-                                    iCurrentCommand.front(),
-                                    PVMFFailure,
-                                    NULL, NULL, NULL);
-                    return;
-                }
-            }
-            else
-            {
-                /* An asynchronous method that prepare's the node for init */
-                PVMFStatus status = DoPreInit(aCmd);
-
-                DeleteUnusedSessionControllerNode();
-
-                if (status == PVMFSuccess)
-                {
-                    /*
-                     * Init for streaming manager cannot be completed unless Init
-                     * for all the children nodes are complete
-                     */
-                    PVMFSMNodeContainerVector::iterator it;
-                    for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-                    {
-                        {
-                            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                            if (internalCmd != NULL)
-                            {
-                                internalCmd->cmd =
-                                    it->commandStartOffset +
-                                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_INIT_CMD_OFFSET;
-                                internalCmd->parentCmd = aCmd.iCmd;
-
-                                OsclAny *cmdContextData =
-                                    OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                                PVMFNodeInterface* iNode = it->iNode;
-
-                                iNode->Init(it->iSessionId, cmdContextData);
-                                it->iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                            }
-                            else
-                            {
-                                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoInit:RequestNewInternalCmd - Failed"));
-                                CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                                return;
-                            }
-                        }
-                    }
-                    MoveCmdToCurrentQueue(aCmd);
-                }
-                else if (status == PVMFPending)
-                {
-                    MoveCmdToCurrentQueue(aCmd);
-                }
-                else
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoInit: DoPreInit() - Failed"));
-                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
-                    int32 errcode = PVMFStreamingManagerNodeErrorParseSDPFailed;
-                    CommandComplete(iInputCommands, aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
-                    return;
-                }
-            }
-        }
-        break;
-
-        default:
-        {
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoInit Failed - Invalid State"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-        }
-        break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoInit - Out"));
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesInit()
-{
-    {
-        for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-        {
-            if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-            {
-                return false;
-            }
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteInit()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteInit - In"));
-    if (CheckChildrenNodesInit() && iErrorDuringProcess == SM_NO_ERROR)
-    {
-        if (!iCurrentCommand.empty() && iCancelCommand.empty())
-        {
-            PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-            if (aCmd.iCmd == PVMF_STREAMING_MANAGER_NODE_INIT)
-            {
-                // create and pass the payload parser registry on to the media layer node
-                PopulatePayloadParserRegistry();
-
-                PVMFStatus status = PVMFSuccess;
-
-                if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL))
-                {
-                    status = ProcessSDP();
-                }
-                if (status == PVMFSuccess)
-                {
-                    status = InitMetaData();
-                    if (status == PVMFSuccess)
-                    {
-                    }
-                    else
-                    {
-                        PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteInit - InitMetaData fail"));
-                    }
-
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Init() - CmdComplete - PVMFSuccess"));
-                    //Init is completed at unprotected clip
-                    SetState(EPVMFNodeInitialized);
-                    PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode::CompleteInit Success"));
-                    CommandComplete(aCmd, PVMFSuccess);
-                }
-                else
-                {
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Init() - Cmd Failed - PVMFStreamingManagerNodeErrorParseSDPFailed"));
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::CompleteInit Failure"));
-                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
-                    int32 errcode = PVMFStreamingManagerNodeErrorParseSDPFailed;
-                    CommandComplete(aCmd, status, NULL, &eventuuid, &errcode);
-                }
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteInit - Out"));
-    return;
-}
-
-/**
- * Queue an asynchronous node command - Prepare
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Prepare(PVMFSessionId s,
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Prepare(PVMFSessionId aSessId,
         const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Prepare - In"));
-    /* Queue an internal command for Graph construct */
-    PVMFStreamingManagerNodeCommand cmdGC;
-    cmdGC.PVMFStreamingManagerNodeCommandBase::Construct(s,
-            PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION,
-            NULL);
 
-    QueueCommandL(cmdGC);
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
 
-    PVMFStreamingManagerNodeCommand cmdPrep;
-    cmdPrep.PVMFStreamingManagerNodeCommandBase::Construct(s,
-            PVMF_STREAMING_MANAGER_NODE_PREPARE,
-            aContext);
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->Prepare(aSessId, aContext);
 
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Prepare - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Prepare() - Cmd Recvd"));
-    return QueueCommandL(cmdPrep);
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Prepare - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Called by the command handler AO to do the node Prepare
- */
-void PVMFStreamingManagerNode::DoPrepare(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoPrepare - In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeInitialized:
-        {
-            if (oGraphConstructComplete)
-            {
-                /*
-                 * Connect the graph here. This is needed since we would send firewall packets
-                 * as part of Prepare.
-                 */
-                if (GraphConnect() == false)
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoPrepare - GraphConnect Failed"));
-                    SetState(EPVMFNodeError);
-                    PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
-                    int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
-                    CommandComplete(aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
-                    return;
-                }
-                {
-                    /*
-                     * Prepare for streaming manager cannot be completed unless Prepare
-                     * for all the children nodes are complete
-                     */
-                    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-                    {
-                        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                        if (internalCmd != NULL)
-                        {
-                            internalCmd->cmd =
-                                iNodeContainerVec[i].commandStartOffset +
-                                PVMF_STREAMING_MANAGER_NODE_INTERNAL_PREPARE_CMD_OFFSET;
-                            internalCmd->parentCmd = aCmd.iCmd;
-
-                            OsclAny *cmdContextData =
-                                OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                            PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                            iNode->Prepare(iNodeContainerVec[i].iSessionId, cmdContextData);
-                            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                        }
-                        else
-                        {
-                            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoPrepare:RequestNewInternalCmd - Failed"));
-                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
-                        }
-                    }
-                }
-                MoveCmdToCurrentQueue(aCmd);
-            }
-            else
-            {
-                /* Graph construction not complete, so cant prep */
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoPrepare Failed - Incomplete Graph"));
-                CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            }
-        }
-        break;
-
-        default:
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoPrepare Failed - Invalid State"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoPrepare - Out"));
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesPrepare()
-{
-    {
-        for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-        {
-            if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-            {
-                return false;
-            }
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompletePrepare()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompletePrepare - In"));
-    if ((CheckChildrenNodesPrepare()) && (oGraphConstructComplete) && iErrorDuringProcess == SM_NO_ERROR)
-    {
-        if (!iCurrentCommand.empty() && iCancelCommand.empty())
-        {
-            PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-            if (aCmd.iCmd == PVMF_STREAMING_MANAGER_NODE_PREPARE)
-            {
-                SetState(EPVMFNodePrepared);
-                PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Prepare() - CmdComplete - PVMFSuccess"));
-                CommandComplete(aCmd, PVMFSuccess);
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompletePrepare - Out"));
-    return;
-}
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Start(PVMFSessionId s, const OsclAny* aContext)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Start(PVMFSessionId aSessId,
+        const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Start - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_START, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Start - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Start() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
+
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->Start(aSessId, aContext);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Start - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Called by the command handler AO to do the node Start
- */
-void PVMFStreamingManagerNode::DoStart(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoStart - In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodePrepared:
-        {
-            /*
-             * Connect the graph if not already connected. Usually the graph is
-             * disconnected as part of Stop. In case we are doing a start after
-             * stop, we would need to connect the graph again.
-             */
-            if (GraphConnect() == false)
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:CompleteStart - GraphConnect Failed"));
-                SetState(EPVMFNodeError);
-                PVUuid eventuuid = PVMFStreamingManagerNodeEventTypeUUID;
-                int32 errcode = PVMFStreamingManagerNodeGraphConnectFailed;
-                CommandComplete(aCmd, PVMFFailure, NULL, &eventuuid, &errcode);
-                return;
-            }
-            /*
-             * Start for streaming manager cannot be completed unless
-             * Start for all the children nodes are complete
-             */
-            {
-                if (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE)
-                {
-                    uint32 duration = 2000;
-                    PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                    PVMFJitterBufferExtensionInterface* jbExtIntf =
-                        (PVMFJitterBufferExtensionInterface*)
-                        (iJitterBufferNodeContainer->iExtensions[0]);
-
-                    /* Set jitter buffer duration */
-                    jbExtIntf->setJitterBufferDurationInMilliSeconds(duration);
-                }
-                /*
-                 * Start for streaming manager cannot be completed unless
-                 * Start for all the children nodes are complete
-                 */
-                for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-                {
-                    PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                    if (internalCmd != NULL)
-                    {
-                        internalCmd->cmd =
-                            iNodeContainerVec[i].commandStartOffset +
-                            PVMF_STREAMING_MANAGER_NODE_INTERNAL_START_CMD_OFFSET;
-                        internalCmd->parentCmd = aCmd.iCmd;
-
-                        OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                        PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                        iNode->Start(iNodeContainerVec[i].iSessionId, cmdContextData);
-                        iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                    }
-                    else
-                    {
-                        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoStart:RequestNewInternalCmd - Failed"));
-                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                        return;
-                    }
-                }
-            }
-            MoveCmdToCurrentQueue(aCmd);
-        }
-        break;
-
-        /*
-         * GraphConnect() not needed if starting from a paused state
-         */
-        case EPVMFNodePaused:
-        {
-            /*
-             * Start for streaming manager cannot be completed unless
-             * Start for all the children nodes are complete
-             */
-            {
-                for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-                {
-                    if (iNodeContainerVec[i].iAutoPaused == false)
-                    {
-                        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                        if (internalCmd != NULL)
-                        {
-                            internalCmd->cmd =
-                                iNodeContainerVec[i].commandStartOffset +
-                                PVMF_STREAMING_MANAGER_NODE_INTERNAL_START_CMD_OFFSET;
-                            internalCmd->parentCmd = aCmd.iCmd;
-
-                            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                            PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                            iNode->Start(iNodeContainerVec[i].iSessionId, cmdContextData);
-                            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                        }
-                        else
-                        {
-                            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoStart:RequestNewInternalCmd - Failed"));
-                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
-                        }
-                    }
-                }
-            }
-            MoveCmdToCurrentQueue(aCmd);
-        }
-        break;
-
-        case EPVMFNodeStarted:
-            //Ignore start if already started
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoStart - Out"));
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesStart()
-{
-    {
-        for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-        {
-            PVMFSMNodeCmdState tmp = iNodeContainerVec[i].iNodeCmdState;
-            uint32 tag = iNodeContainerVec[i].iNodeTag;
-            if (iNodeContainerVec[i].iNodeCmdState == PVMFSM_NODE_CMD_PENDING)
-            {
-                return false;
-            }
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteStart()
-{
-    int32 localMode = 0;
-    if (iPVMFDataSourcePositionParamsPtr != NULL)
-    {
-        localMode = iPVMFDataSourcePositionParamsPtr->iMode;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteStart - In"));
-    if (CheckChildrenNodesStart() && iErrorDuringProcess == SM_NO_ERROR)
-    {
-        if (!iCurrentCommand.empty() && iCancelCommand.empty())
-        {
-            PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-            if ((aCmd.iCmd == PVMF_STREAMING_MANAGER_NODE_START) ||
-                    (aCmd.iCmd == PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION))
-            {
-                if (oRepositioning)
-                {
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::SetDataSourcePosition() - CmdComplete - PMVFSuccess"));
-                    oRepositioning = false;
-                    oPlayListRepositioning = false;
-
-                    if ((localMode == 0) || (localMode == -1))
-                    {
-                        GetAcutalMediaTSAfterSeek();
-                    }
-
-                    iPVMFDataSourcePositionParamsPtr = NULL;
-                }
-                if ((iAutoResumePending == 2) && (iAutoPaused == true))
-                {
-                    iAutoResumePending = 1;
-                    /* internal command - session id does not matter */
-                    PVMFSessionId s = 0;
-                    PVMFStreamingManagerNodeCommand cmdAutoResume;
-                    cmdAutoResume.PVMFStreamingManagerNodeCommandBase::Construct(s,
-                            PVMF_STREAMING_MANAGER_NODE_AUTO_RESUME,
-                            NULL);
-                    QueueCommandL(cmdAutoResume);
-                    PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:CompleteStart: - AutoResume Queued"));
-                }
-                if ((localMode == 0) || (localMode == -1))
-                {
-                    SetState(EPVMFNodeStarted);
-                    if (IsAdded())
-                    {
-                        /* wakeup the AO */
-                        RunIfNotReady();
-                    }
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Start() - CmdComplete - PMVFSuccess"));
-                }
-                CommandComplete(aCmd, PVMFSuccess);
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteStart - Out"));
-    return;
-}
-
-/**
- * Called by the command handler AO to do the Auto Resume
- */
-void PVMFStreamingManagerNode::DoAutoResume(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoAutoResume - In"));
-
-    if (iSessionStopTimeAvailable == false)
-    {
-        /* Implies an open ended session - no pause or reposition */
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoAutoResume in live  - PVMFErrNotSupported"));
-        InternalCommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
-        return;
-    }
-
-    bool oCmdSent = false;
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        {
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                /* We only pause session controller and socket nodes in auto-pause */
-                int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-                PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                if ((nodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE) ||
-                        (nodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE))
-                {
-                    if (iNode->GetState() != EPVMFNodeStarted)
-                    {
-                        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                        if (internalCmd != NULL)
-                        {
-                            internalCmd->cmd =
-                                iNodeContainerVec[i].commandStartOffset +
-                                PVMF_STREAMING_MANAGER_NODE_INTERNAL_START_CMD_OFFSET;
-                            internalCmd->parentCmd = aCmd.iCmd;
-
-                            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-                            iNode->Start(iNodeContainerVec[i].iSessionId, cmdContextData);
-                            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                            oCmdSent = true;
-                        }
-                        else
-                        {
-                            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoAutoResume:RequestNewInternalCmd - Failed"));
-                            InternalCommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
-                        }
-                    }
-                }
-            }
-            if (oCmdSent)
-            {
-                MoveCmdToCurrentQueue(aCmd);
-                PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoResume: - Start Sent"));
-            }
-            else
-            {
-                iAutoResumePending = 0;
-                InternalCommandComplete(iInputCommands, aCmd, PVMFSuccess);
-                PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoResume: - Done"));
-            }
-        }
-        break;
-
-        case EPVMFNodePaused:
-        {
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-                if (nodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE)
-                {
-                    iNodeContainerVec[i].iAutoPaused = false;
-                }
-            }
-            iAutoResumePending = 0;
-            InternalCommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoResume in EPVMFNodePaused: - Done"));
-        }
-        break;
-        default:
-        {
-            iAutoResumePending = 0;
-            InternalCommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-        }
-        break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoAutoResume - Out"));
-    return;
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesAutoResume()
-{
-    PVMFSMNodeContainerVector::iterator it;
-    for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-    {
-        int32 nodeTag = it->iNodeTag;
-        if ((nodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE))
-        {
-            if (it->iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE
-                    && it->iNodeCmdState != PVMFSM_NODE_CMD_NO_PENDING)
-            {
-                return false;
-            }
-            else
-            {
-                it->iAutoPaused = false;
-            }
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteAutoResume()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteAutoResume - In"));
-    if (CheckChildrenNodesAutoResume() && iErrorDuringProcess == SM_NO_ERROR)
-    {
-        iAutoResumePending = 0;
-        iAutoPaused = false;
-        /* Notify jitter buffer so that it may pause its estimated server clock */
-        PVMFSMNodeContainer* iJitterBufferNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFJitterBufferExtensionInterface* jbExtIntf =
-            (PVMFJitterBufferExtensionInterface*)
-            (iJitterBufferNodeContainer->iExtensions[0]);
-        if (jbExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        jbExtIntf->NotifyAutoResumeComplete();
-
-        PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-        InternalCommandComplete(aCmd, PVMFSuccess);
-        /* Erase the command from the current queue */
-        iCurrentCommand.Erase(&iCurrentCommand.front());
-        PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoResume: - Done"));
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteAutoResume - Out"));
-    return;
-}
-
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Stop(PVMFSessionId s, const OsclAny* aContext)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Stop(PVMFSessionId aSessId,
+        const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Stop - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_STOP, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Stop - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Stop() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
+
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->Stop(aSessId, aContext);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Stop - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Called by the command handler AO to do the node Stop
- */
-void PVMFStreamingManagerNode::DoStop(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoStop - In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        {
-            {
-                /*
-                 * Stop for streaming manager cannot be completed unless
-                 * Stop for all the children nodes are complete
-                 */
-                for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-                {
-                    PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                    if (internalCmd != NULL)
-                    {
-                        internalCmd->cmd =
-                            iNodeContainerVec[i].commandStartOffset +
-                            PVMF_STREAMING_MANAGER_NODE_INTERNAL_STOP_CMD_OFFSET;
-                        internalCmd->parentCmd = aCmd.iCmd;
-
-                        OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                        PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                        iNode->Stop(iNodeContainerVec[i].iSessionId, cmdContextData);
-                        iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                    }
-                    else
-                    {
-                        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoStop:RequestNewInternalCmd - Failed"));
-                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                        return;
-                    }
-                }
-            }
-            MoveCmdToCurrentQueue(aCmd);
-        }
-        break;
-
-        default:
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoStop Failure - Invalid State"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoStop - Out"));
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesStop()
-{
-    {
-        for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-        {
-            if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-            {
-                return false;
-            }
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteStop()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteStop - In"));
-    if (CheckChildrenNodesStop() && iErrorDuringProcess == SM_NO_ERROR)
-    {
-        if (!iCurrentCommand.empty() && iCancelCommand.empty())
-        {
-            PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-            if (aCmd.iCmd == PVMF_STREAMING_MANAGER_NODE_STOP)
-            {
-                /* transition to Prepared state */
-                ResetStopCompleteParams();
-                SetState(EPVMFNodePrepared);
-                PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Stop() - CmdComplete - PVMFSuccess"));
-                CommandComplete(aCmd, PVMFSuccess);
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteStop - Out"));
-    return;
-}
-
-void PVMFStreamingManagerNode::ResetStopCompleteParams()
-{
-    iStreamThinningInProgress = false;
-    iPlaylistPlayInProgress = false;
-    iSwitchStreamIFrameVideo = false;
-    iRepositionRequestedStartNPTInMS = 0;
-}
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Flush(PVMFSessionId s, const OsclAny* aContext)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Flush(PVMFSessionId aSessId,
+        const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Flush - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_FLUSH, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Flush - Out"));
-    return QueueCommandL(cmd);
-}
-/**
- * Called by the command handler AO to do the node Flush
- */
-void PVMFStreamingManagerNode::DoFlush(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoFlush - In"));
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        {
-            /*
-             * Flush for streaming manager cannot be completed unless
-             * Flush for all the children nodes are complete
-             */
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                if (internalCmd != NULL)
-                {
-                    internalCmd->cmd =
-                        iNodeContainerVec[i].commandStartOffset +
-                        PVMF_STREAMING_MANAGER_NODE_INTERNAL_FLUSH_CMD_OFFSET;
-                    internalCmd->parentCmd = aCmd.iCmd;
 
-                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
 
-                    PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->Flush(aSessId, aContext);
 
-                    iNode->Flush(iNodeContainerVec[i].iSessionId, cmdContextData);
-                    iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                }
-                else
-                {
-                    PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoFlush:RequestNewInternalCmd - Failed"));
-                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                    return;
-                }
-            }
-            MoveCmdToCurrentQueue(aCmd);
-            /*
-             * Notify all ports to suspend their input - TBD
-             */
-            /*
-             * If the node is not running we need to wakeup the
-             * AO to further complete the flush, which means all
-             * port activity needs to be completed.
-             */
-            if (IsAdded())
-            {
-                RunIfNotReady();
-            }
-        }
-        break;
-
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoFlush - Out"));
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Flush - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesFlush()
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-        {
-            return false;
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteFlush()
-{
-    /*
-     * If the node is not running we need to wakeup the
-     * AO to further complete the flush, which means all
-     * port activity needs to be completed.
-     */
-    if (iInterfaceState != EPVMFNodeStarted)
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    return;
-}
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Pause(PVMFSessionId s, const OsclAny* aContext)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Pause(PVMFSessionId aSessId,
+        const OsclAny* aContext)
 {
     PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Pause - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_PAUSE, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Pause - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Pause() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+
+    if (!iSMFSPlugin)
+        OSCL_LEAVE(OsclErrInvalidState);
+
+    PVMFCommandId cmdId = 0;
+    cmdId = iSMFSPlugin->Pause(aSessId, aContext);
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Pause - Out cmdId[%d]", cmdId));
+    return cmdId;
 }
 
-/**
- * Called by the command handler AO to do the node Pause
- */
-void PVMFStreamingManagerNode::DoPause(PVMFStreamingManagerNodeCommand& aCmd)
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Reset(PVMFSessionId aSessId,
+        const OsclAny* aContext)
 {
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoPause - In"));
-    switch (iInterfaceState)
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Reset - In"));
+
+    PVMFCommandId cmdId = 0;
+    if (iSMFSPlugin)
     {
-        case EPVMFNodeStarted:
+        cmdId = iSMFSPlugin->Reset(aSessId, aContext);
+    }
+    else
+    {
+        PVMFStreamingManagerNodeCommand cmd;
+        cmd.Construct(aSessId, PVMF_STREAMING_MANAGER_NODE_RESET, aContext);
+        cmdId = QueueCommandL(cmd);
+    }
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Reset - Out cmdId[%d]", cmdId));
+    return cmdId;
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::CancelAllCommands(PVMFSessionId aSessId,
+        const OsclAny* aContextData)
+{
+    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CancelAllCommands"));
+
+    PVMFCommandId cmdId = 0;
+    if (iSMFSPlugin)
+    {
+        cmdId = iSMFSPlugin->CancelAllCommands(aSessId, aContextData);
+    }
+    else
+    {
+        PVMFStreamingManagerNodeCommand cmd;
+        cmd.Construct(aSessId, PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS, aContextData);
+        cmdId = QueueCommandL(cmd);
+    }
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CancelAllCommands() - Out cmdId[%d]", cmdId));
+    return cmdId;
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::CancelCommand(PVMFSessionId aSessId,
+        PVMFCommandId aCmdId,
+        const OsclAny* aContextData)
+{
+    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CancelCommand with id %d", aCmdId));
+
+    PVMFCommandId cmdId = 0;
+    if (iSMFSPlugin)
+    {
+        cmdId = iSMFSPlugin->CancelCommand(aSessId, aCmdId, aContextData);
+    }
+    else
+    {
+        PVMFStreamingManagerNodeCommand cmd;
+        cmd.Construct(aSessId, PVMF_STREAMING_MANAGER_NODE_CANCELCOMMAND, aContextData);
+        cmdId = QueueCommandL(cmd);
+    }
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CancelCommand() - Out cmdId[%d]", cmdId));
+    return cmdId;
+}
+
+/* PVMFPortActivityHandler's virtual functions implemenation */
+void PVMFStreamingManagerNode::HandlePortActivity(const PVMFPortActivity& aActivity)
+{
+    //this node just acts as a proxy and does'nt has any port of its own, So, this func will never be called
+    OSCL_UNUSED_ARG(aActivity);
+    OSCL_ASSERT(false);
+}
+
+/* PVMFDataSourceInitializationExtensionInterface's virtual functions implemenation */
+PVMFStatus PVMFStreamingManagerNode::SetSourceInitializationData(OSCL_wString& aSourceURL,
+        PVMFFormatType& aSourceFormat,
+        OsclAny* aSourceData)
+{
+    PVMFStatus status = PVMFFailure;
+    //we may have the sequence like
+    //Reset->queryinterface(PVMFDataSourceInitializationExtensionInterface)->PVMFDataSourceInitializationExtensionInterface::SetSourceInitializationData
+    //Hence, we cannot rule out the possibility of FSP plugin already being created or multiple calls to
+    //PVMFDataSourceInitializationExtensionInterface::SetSourceInitializationData
+    if (iSMFSPlugin)
+    {
+        if (iSMFSPRegistry)
         {
+            if (iFSPDataSourceInitializationIntf)
             {
-                for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
+                iFSPDataSourceInitializationIntf->removeRef();
+                iFSPDataSourceInitializationIntf = NULL;
+            }
+            OSCL_ASSERT(iSMFSPRegistry->ReleaseSMFSP(iFSPUuid, iSMFSPlugin));
+            iSMFSPlugin = NULL;
+        }
+    }
+
+    PVMFFormatType fspSrcFormat = aSourceFormat;
+    //Check if tunelling plugin is to be instantiated?
+    if (aSourceFormat == PVMF_MIME_DATA_SOURCE_RTSP_URL)//check for SDP files too???
+    {
+        OSCL_wStackString<8> rtsptScheme(_STRLIT_WCHAR("rtspt"));
+        if (oscl_strncmp(rtsptScheme.get_cstr(), aSourceURL.get_cstr(), 5) == 0)
+        {
+            fspSrcFormat = PVMF_MIME_DATA_SOURCE_RTSP_TUNNELLING;
+        }
+    }
+    if (fspSrcFormat != PVMF_MIME_DATA_SOURCE_RTSP_TUNNELLING) //Check if [RTSPUnicast and PVR]/[RTSPBroadcast and/or PVR] feature is required
+    {
+        if (aSourceData)
+        {
+            PVInterface* pvInterface = OSCL_STATIC_CAST(PVInterface*, aSourceData);
+            PVInterface* sourceDataContext = NULL;
+            PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
+            if (pvInterface)
+            {
+                if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
                 {
-                    /*
-                     * Pause only if not already paused - could happen that
-                     * some of the nodes could be paused due to flow control
-                     */
-                    if ((iNodeContainerVec[i].iNode->GetState()) != EPVMFNodePaused)
+                    if (sourceDataContext)
                     {
-                        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                        if (internalCmd != NULL)
+                        PVInterface* packetSourceContextData = NULL;
+                        PVUuid packetSourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_PACKETSOURCE_UUID); //Check for Broadcast Plugin
+
+                        PVInterface* pvrDataContext = NULL;
+                        PVUuid pvrContextUuid(PVMF_SOURCE_CONTEXT_DATA_PVR_UUID); //Check for RTSP Unicast + PVR plugin
+
+                        PVInterface* pvrFilePlaybackContextData = NULL;
+                        PVUuid pvrFileContextUuid(PVMF_SOURCE_CONTEXT_DATA_PVRLOCALPLAYBACK_UUID); //Check for PVR FilePlayback Plugin
+
+                        if (sourceDataContext->queryInterface(packetSourceContextUuid, packetSourceContextData))
                         {
-                            internalCmd->cmd =
-                                iNodeContainerVec[i].commandStartOffset +
-                                PVMF_STREAMING_MANAGER_NODE_INTERNAL_PAUSE_CMD_OFFSET;
-                            internalCmd->parentCmd = aCmd.iCmd;
-
-                            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                            PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                            iNode->Pause(iNodeContainerVec[i].iSessionId, cmdContextData);
-                            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
+                            if (packetSourceContextData)
+                            {
+                                //Broadcast is to be enabled
+                                if ((aSourceFormat == PVMF_MIME_DATA_SOURCE_RTSP_URL) || (aSourceFormat == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+                                {
+                                    OSCL_ASSERT(fspSrcFormat == aSourceFormat);
+                                    fspSrcFormat = PVMF_MIME_DATA_SOURCE_RTSP_BROADCAST;
+                                }
+                                packetSourceContextData->removeRef();
+                            }
                         }
-                        else
+
+                        else if (sourceDataContext->queryInterface(pvrFileContextUuid, pvrFilePlaybackContextData))
                         {
-                            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoPause:RequestNewInternalCmd - Failed"));
-                            CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
+                            if (pvrFilePlaybackContextData)
+                            {
+                                //PVR File Playback Pluign enable
+                                if (aSourceFormat == PVMF_MIME_DATA_SOURCE_SDP_FILE)
+                                {
+                                    OSCL_ASSERT(fspSrcFormat == aSourceFormat);
+                                    fspSrcFormat = PVMF_MIME_DATA_SOURCE_PVR_FILEPLAYBACK;
+                                }
+                                pvrFilePlaybackContextData->removeRef();
+                            }
                         }
+
+                        else if (sourceDataContext->queryInterface(pvrContextUuid, pvrDataContext))
+                        {
+
+                            if (pvrDataContext)
+                            {
+                                //PVR is to be enabled.
+                                //set fsp src format type
+                                if ((aSourceFormat == PVMF_MIME_DATA_SOURCE_RTSP_URL) || (aSourceFormat == PVMF_MIME_DATA_SOURCE_SDP_FILE))
+                                {
+                                    OSCL_ASSERT(fspSrcFormat == aSourceFormat);
+                                    fspSrcFormat = PVMF_MIME_DATA_SOURCE_RTSP_UNICAST_PLUS_PVR;
+                                }
+                                pvrDataContext->removeRef();
+                            }
+
+                        }
+                        sourceDataContext->removeRef();
+
                     }
                 }
             }
-            MoveCmdToCurrentQueue(aCmd);
-        }
-        break;
-        default:
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoPause - Out"));
-    return;
-}
 
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesPause()
-{
-    {
-        for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-        {
-            if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE
-                    && iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_NO_PENDING)
-            {
-                return false;
-            }
         }
     }
-    ResetNodeContainerCmdState();
-    return true;
-}
 
-void PVMFStreamingManagerNode::CompletePause()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompletePause - In"));
-    if (CheckChildrenNodesPause() && iErrorDuringProcess == SM_NO_ERROR)
+    Oscl_Vector<PVUuid, OsclMemAllocator> srcNodeUuidVec;
+    if (PVMFSuccess == iSMFSPRegistry->QueryRegistry(fspSrcFormat, srcNodeUuidVec))
     {
-        SetState(EPVMFNodePaused);
-        if (oRepositioning)
+        iFSPUuid = srcNodeUuidVec.front();
+        iSMFSPlugin = iSMFSPRegistry->CreateSMFSP(iFSPUuid);
+        //(ii)threadlogon to FSP
+        iSMFSPlugin->ThreadLogon();
+        //(iii)connect to it, make sure datasource initialization interface is present
+        PVMFSessionId sessID = iSMFSPlugin->Connect(iUpstreamSession);
+        PVInterface* temp = NULL;
+        PVMFStatus statusQ = PVMFFailure;
+
+        statusQ = iSMFSPlugin->queryInterface(PVMF_DATA_SOURCE_INIT_INTERFACE_UUID, temp);
+        iFSPDataSourceInitializationIntf = OSCL_STATIC_CAST(PVMFDataSourceInitializationExtensionInterface*, temp);
+
+        if ((statusQ == PVMFSuccess) && (iFSPDataSourceInitializationIntf != NULL))
         {
-            if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-                    (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-            {
-                /*
-                 * Pause request generated by a reposition command
-                 * complete. Issue a start.
-                 */
-                if (iPVMFDataSourcePositionParamsPtr == NULL)
-                {
-                    DoRepositioningStart3GPPStreaming();
-                }
-            }
+            status = iFSPDataSourceInitializationIntf->SetSourceInitializationData(aSourceURL, aSourceFormat, aSourceData);
         }
         else
         {
-            if (!iCurrentCommand.empty() && iCancelCommand.empty())
-            {
-                PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-                PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Pause() - CmdComplete - PVMFSuccess"));
-                CommandComplete(aCmd, PVMFSuccess);
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
+            iSMFSPlugin->Disconnect(sessID);
+            iSMFSPlugin->ThreadLogoff();
+            iSMFSPRegistry->ReleaseSMFSP(iFSPUuid, iSMFSPlugin);
+            iSMFSPlugin = NULL;
+            PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetSourceInitializationData() - Destructed FSP "));
         }
-
     }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompletePause - Out"));
-    return;
+
+    return status;
 }
 
-/**
- * Called by the command handler AO to do the Auto Pause
- */
-void PVMFStreamingManagerNode::DoAutoPause(PVMFStreamingManagerNodeCommand& aCmd)
+PVMFStatus PVMFStreamingManagerNode::SetClientPlayBackClock(PVMFMediaClock* aClientClock)
 {
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoAutoPause - In"));
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetClientPlayBackClock - In"));
 
-    if (iSessionStopTimeAvailable == false)
+    PVMFStatus status = PVMFSuccess;
+    if (iFSPDataSourceInitializationIntf)
     {
-        /* Implies an open ended session - no pause or reposition */
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoAutoPause in live  - PVMFErrNotSupported"));
-        InternalCommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
-        return;
+        status = iFSPDataSourceInitializationIntf->SetClientPlayBackClock(aClientClock);
     }
-    bool oCmdSent = false;
-    switch (iInterfaceState)
+    else
     {
-        case EPVMFNodeStarted:
-        {
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                /* We only pause session controller and socket nodes in auto-pause */
-                int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-                PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                if ((nodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE) ||
-                        (nodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE))
-                {
-                    if (iNode->GetState() != EPVMFNodePaused)
-                    {
-                        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                        if (internalCmd != NULL)
-                        {
-                            internalCmd->cmd =
-                                iNodeContainerVec[i].commandStartOffset +
-                                PVMF_STREAMING_MANAGER_NODE_INTERNAL_PAUSE_CMD_OFFSET;
-                            internalCmd->parentCmd = aCmd.iCmd;
-
-                            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-                            iNode->Pause(iNodeContainerVec[i].iSessionId, cmdContextData);
-                            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                            oCmdSent = true;
-                        }
-                        else
-                        {
-                            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoAutoPause:RequestNewInternalCmd - Failed"));
-                            InternalCommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                            return;
-                        }
-                    }
-                }
-            }
-            if (oCmdSent == true)
-            {
-                MoveCmdToCurrentQueue(aCmd);
-                PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoPause: - Pause Sent"));
-            }
-            else
-            {
-                iAutoPausePending = false;
-                InternalCommandComplete(iInputCommands, aCmd, PVMFSuccess);
-                PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoPause: - Done"));
-            }
-        }
-        break;
-        case EPVMFNodePaused:
-        {
-            /*
-             * If state is EPVMFNodePaused when Highwatermark event is reported, we ignore this event.
-             * But if Highwatermark event is reported while pause cmd is pending,
-             * we call DoAutoPause and JB node expect SM node go to autopause. So we set iAutoPaused to true.
-             */
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-                if (nodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE)
-                {
-                    iNodeContainerVec[i].iAutoPaused = true;
-                }
-            }
-            iAutoPausePending = false;
-            iAutoPaused = true;
-
-            InternalCommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoPause in EPVMFNodePaused: - Done"));
-        }
-        break;
-        default:
-        {
-            iAutoPausePending = false;
-            InternalCommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-        }
-        break;
+        status = PVMFFailure;
     }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoAutoPause - Out"));
-    return;
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetClientPlayBackClock - Out status [%d]", status));
+    return status;
 }
 
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesAutoPause()
+PVMFStatus PVMFStreamingManagerNode::SetEstimatedServerClock(PVMFMediaClock* aEstimatedServerClock)
 {
-    PVMFSMNodeContainerVector::iterator it;
-    for (it = iNodeContainerVec.begin(); it !=  iNodeContainerVec.end(); it++)
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetEstimatedServerClock - In"));
+
+    PVMFStatus status = PVMFSuccess;
+    if (iFSPDataSourceInitializationIntf)
     {
-        int32 nodeTag = it->iNodeTag;
-        if ((nodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE))
-        {
-            if (it->iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE
-                    && it->iNodeCmdState != PVMFSM_NODE_CMD_NO_PENDING)
-            {
-                return false;
-            }
-            else
-            {
-                it->iAutoPaused = true;
-            }
-        }
+        status = iFSPDataSourceInitializationIntf->SetEstimatedServerClock(aEstimatedServerClock);
     }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteAutoPause()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteAutoPause - In"));
-    if (CheckChildrenNodesAutoPause() && iErrorDuringProcess == SM_NO_ERROR)
+    else
     {
-        iAutoPausePending = false;
-        iAutoPaused = true;
-        /* Notify jitter buffer so that it may pause its estimated server clock */
-        PVMFSMNodeContainer* iJitterBufferNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFJitterBufferExtensionInterface* jbExtIntf =
-            (PVMFJitterBufferExtensionInterface*)
-            (iJitterBufferNodeContainer->iExtensions[0]);
-        if (jbExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        jbExtIntf->NotifyAutoPauseComplete();
-
-        PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-        InternalCommandComplete(aCmd, PVMFSuccess);
-        /* Erase the command from the current queue */
-        iCurrentCommand.Erase(&iCurrentCommand.front());
-        PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:DoAutoPause: - Done"));
+        status = PVMFFailure;
     }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteAutoPause - Out"));
-    return;
-}
 
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::Reset(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Reset - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_RESET, aContext);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Reset - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Reset() - Cmd Recvd"));
-    return QueueCommandL(cmd);
-}
-
-/**
- * Called by the command handler AO to do the node Reset.
- */
-void PVMFStreamingManagerNode::DoReset(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoReset - In"));
-    /* this node allows a reset from any idle or error state */
-    switch (iInterfaceState)
-    {
-        case EPVMFNodeCreated:
-        case EPVMFNodeIdle:
-        case EPVMFNodeInitialized:
-        case EPVMFNodePrepared:
-        case EPVMFNodeStarted:
-        case EPVMFNodePaused:
-        case EPVMFNodeError:
-        {
-            /*
-             * Reset for streaming manager cannot be completed unless
-             * Reset for all the children nodes are complete
-             */
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                if (internalCmd != NULL)
-                {
-                    internalCmd->cmd =
-                        iNodeContainerVec[i].commandStartOffset +
-                        PVMF_STREAMING_MANAGER_NODE_INTERNAL_RESET_CMD_OFFSET;
-                    internalCmd->parentCmd = aCmd.iCmd;
-
-                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                    PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                    iNode->Reset(iNodeContainerVec[i].iSessionId, cmdContextData);
-                    iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-                }
-                else
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoReset:RequestNewInternalCmd - Failed"));
-                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                    return;
-                }
-            }
-            MoveCmdToCurrentQueue(aCmd);
-        }
-        break;
-
-        default:
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::DoReset Failure - Invalid State"));
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            break;
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoReset - Out"));
-}
-
-bool
-PVMFStreamingManagerNode::CheckChildrenNodesReset()
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_COMPLETE)
-        {
-            return false;
-        }
-    }
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteReset()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteReset - In"));
-    if (CheckChildrenNodesReset() && iDRMResetPending == false)
-    {
-        ResetNodeContainerCmdState();
-        if (!iCurrentCommand.empty() && iCancelCommand.empty())
-        {
-            /* Indicates that the init for Children Nodes was successfull */
-            /* At protected clip, Reset CPM also was successfull */
-            PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-            if (aCmd.iCmd == PVMF_STREAMING_MANAGER_NODE_RESET)
-            {
-
-                /* Reset Params */
-                ResetNodeParams();
-
-                /* Reset the metadata key list */
-                /* Clean up CPM related variables */
-                CleanupCPMdata();
-
-                /* logoff & go back to Created state */
-                SetState(EPVMFNodeIdle);
-                PVMFStatus status = ThreadLogoff();
-
-                if (iErrorDuringProcess == SM_NO_ERROR)
-                {
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::Reset() - CmdComplete - Status=%d", status));
-                    CommandComplete(aCmd, status);
-                }
-                else
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::CompleteReset -- CPM Reset error"));
-                    CommandComplete(aCmd, PVMFFailure, iErrorResponseInf);
-
-                    if (iErrorResponseInf != NULL)
-                    {
-                        iErrorResponseInf->removeRef();
-                        iErrorResponseInf = NULL;
-                    }
-                    iErrorDuringProcess = SM_NO_ERROR;
-                }
-
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-                // destroy the payload parser registry
-                destroyPayloadParserRegistry();
-            }
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteReset - Out"));
-    return;
-}
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::CancelAllCommands(PVMFSessionId s, const OsclAny* aContext)
-{
-    PVMF_SM_LOGINFO((0, "StreamingManagerNode:CancelAllCommands"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS, aContext);
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::CancelAllCommands() - Cmd Recvd"));
-    return QueueCommandL(cmd);
-}
-
-/**
- * Queue an asynchronous node command
- */
-OSCL_EXPORT_REF PVMFCommandId PVMFStreamingManagerNode::CancelCommand(PVMFSessionId s, PVMFCommandId aCmdId, const OsclAny* aContext)
-{
-    PVMF_SM_LOGINFO((0, "StreamingManagerNode:CancelCommand"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommandBase::Construct(s, PVMF_STREAMING_MANAGER_NODE_CANCELCOMMAND, aCmdId, aContext);
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::CancelCommand() - Cmd Recvd"));
-    return QueueCommandL(cmd);
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetEstimatedServerClock - Out status [%d]", status));
+    return status;
 }
 
 /**
@@ -2879,818 +679,11 @@
     }
     return id;
 }
-/**
- * Called by the command handler AO to process a command from
- * the input queue.
- * Return true if a command was processed, false if the command
- * processor is busy and can't process another command now.
- */
-bool PVMFStreamingManagerNode::ProcessCommand(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    /*
-     * normally this node will not start processing one command
-     * until the prior one is finished.  However, a hi priority
-     * command such as Cancel must be able to interrupt a command
-     * in progress.
-     */
-    if ((iCurrentCommand.size() > 0 && !aCmd.hipri()
-            && aCmd.iCmd != PVMF_STREAMING_MANAGER_NODE_CANCEL_GET_LICENSE)
-            || iCancelCommand.size() > 0)
-        return false;
 
-    switch (aCmd.iCmd)
-    {
-        case PVMF_STREAMING_MANAGER_NODE_QUERYUUID:
-            DoQueryUuid(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_QUERYINTERFACE:
-            DoQueryInterface(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_REQUESTPORT:
-            DoRequestPort(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_RELEASEPORT:
-            DoReleasePort(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_INIT:
-            DoInit(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_PREPARE:
-            DoPrepare(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_START:
-            DoStart(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_STOP:
-            DoStop(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_FLUSH:
-            DoFlush(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_PAUSE:
-            DoPause(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_RESET:
-            DoReset(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS:
-            DoCancelAllCommands(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_CANCELCOMMAND:
-            DoCancelCommand(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION:
-        {
-            if (!GraphConstruct())
-            {
-                InternalCommandComplete(iInputCommands,
-                                        aCmd,
-                                        PVMFFailure);
-            }
-            else
-            {
-                /*
-                 * Move it to current command queue where it would
-                 * stay until "GraphConstruct" is complete
-                 */
-                MoveCmdToCurrentQueue(aCmd);
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION:
-        {
-            {
-                DoSetDataSourcePosition(aCmd);
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_NODE_QUERY_DATASOURCE_POSITION:
-            DoQueryDataSourcePosition(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAKEYS:
-        {
-            PVMFStatus status = DoGetMetadataKeys(aCmd);
-            if (status != PVMFPending)
-            {
-                CommandComplete(iInputCommands, aCmd, status);
-            }
-            else
-            {
-                MoveCmdToCurrentQueue(aCmd);
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAVALUES:
-        {
-            PVMFStatus status = DoGetMetadataValues(aCmd);
-            if (status != PVMFPending)
-            {
-                CommandComplete(iInputCommands, aCmd, status);
-            }
-            else
-            {
-                MoveCmdToCurrentQueue(aCmd);
-            }
-        }
-        break;
-        case PVMF_STREAMING_MANAGER_NODE_CAPCONFIG_SETPARAMS:
-        {
-            PvmiMIOSession session;
-            PvmiKvp* aParameters;
-            int num_elements;
-            PvmiKvp** ppRet_kvp;
-            aCmd.Parse(session, aParameters, num_elements, ppRet_kvp);
-            setParametersSync(NULL, aParameters, num_elements, *ppRet_kvp);
-            ciObserver->SignalEvent(aCmd.iId);
-        }
-
-        case PVMF_STREAMING_MANAGER_NODE_AUTO_PAUSE:
-            DoAutoPause(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_AUTO_RESUME:
-            DoAutoResume(aCmd);
-            break;
-
-        case PVMF_STREAMING_MANAGER_NODE_GET_LICENSE_W:
-        {
-            PVMFStatus status = DoGetLicense(aCmd, true);
-            if (status == PVMFPending)
-            {
-                MoveCmdToCurrentQueue(aCmd);
-            }
-            else
-            {
-                CommandComplete(iInputCommands, aCmd, status);
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_NODE_GET_LICENSE:
-        {
-            PVMFStatus status = DoGetLicense(aCmd);
-            if (status == PVMFPending)
-            {
-                MoveCmdToCurrentQueue(aCmd);
-            }
-            else
-            {
-                CommandComplete(iInputCommands, aCmd, status);
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_NODE_CANCEL_GET_LICENSE:
-            DoCancelGetLicense(aCmd);
-            break;
-
-        default:
-            /* unknown command type */
-            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
-            break;
-    }
-
-    return true;
-}
-
-/**
- * The various command handlers call this when a command is complete.
- */
-void PVMFStreamingManagerNode::CommandComplete(PVMFStreamingManagerNodeCmdQ& aCmdQ,
-        PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        OsclAny* aEventData,
-        PVUuid* aEventUUID,
-        int32* aEventCode,
-        PVInterface* aExtMsg)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    PVInterface* extif = NULL;
-    PVMFBasicErrorInfoMessage* errormsg = NULL;
-    if (aExtMsg)
-    {
-        extif = aExtMsg;
-    }
-    else if (aEventUUID && aEventCode)
-    {
-        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
-    }
-
-    /* create response */
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
-    PVMFSessionId session = aCmd.iSession;
-
-    /* Erase the command from the queue */
-    aCmdQ.Erase(&aCmd);
-
-    /* Report completion to the session observer */
-    ReportCmdCompleteEvent(session, resp);
-
-    if (errormsg)
-    {
-        errormsg->removeRef();
-    }
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other error implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-void PVMFStreamingManagerNode::CommandComplete(PVMFStreamingManagerNodeCmdQ& aCmdQ,
-        PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        OsclAny* aEventData,
-        PVUuid* aEventUUID,
-        int32* aEventCode)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    PVInterface* extif = NULL;
-    PVMFBasicErrorInfoMessage* errormsg = NULL;
-    if (aEventUUID && aEventCode)
-    {
-        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
-    }
-
-    /* create response */
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
-    PVMFSessionId session = aCmd.iSession;
-
-    /* Erase the command from the queue */
-    aCmdQ.Erase(&aCmd);
-
-    /* Report completion to the session observer */
-    ReportCmdCompleteEvent(session, resp);
-
-    if (errormsg)
-    {
-        errormsg->removeRef();
-    }
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty() && IsAdded())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other error implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-void PVMFStreamingManagerNode::CommandComplete(PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        OsclAny* aEventData,
-        PVUuid* aEventUUID,
-        int32* aEventCode)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    PVInterface* extif = NULL;
-    PVMFBasicErrorInfoMessage* errormsg = NULL;
-    if (aEventUUID && aEventCode)
-    {
-        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
-    }
-
-    /* create response */
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
-    PVMFSessionId session = aCmd.iSession;
-
-    /* Report completion to the session observer */
-    ReportCmdCompleteEvent(session, resp);
-
-    if (errormsg)
-    {
-        errormsg->removeRef();
-    }
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other status implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-/**
- * The various command handlers call this when a command is complete.
- */
-void PVMFStreamingManagerNode::CommandComplete(PVMFStreamingManagerNodeCmdQ& aCmdQ,
-        PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        PVInterface* aErrorExtIntf)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext));
-
-    /* create response */
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aErrorExtIntf, NULL);
-    PVMFSessionId session = aCmd.iSession;
-
-    /* Erase the command from the queue */
-    aCmdQ.Erase(&aCmd);
-
-    /* Report completion to the session observer */
-    ReportCmdCompleteEvent(session, resp);
-
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other error implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-void PVMFStreamingManagerNode::CommandComplete(PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        PVInterface* aErrorExtIntf,
-        OsclAny* aData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext));
-
-    /* create response */
-    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aErrorExtIntf, aData);
-    PVMFSessionId session = aCmd.iSession;
-
-    /* Report completion to the session observer */
-    ReportCmdCompleteEvent(session, resp);
-
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other status implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-/**
- * The various command handlers call this when an internal command is complete.
- * Does not report events to the observer
- */
-void
-PVMFStreamingManagerNode::InternalCommandComplete(PVMFStreamingManagerNodeCmdQ& aCmdQ,
-        PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        OsclAny* aEventData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    /* Erase the command from the queue */
-    aCmdQ.Erase(&aCmd);
-
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other status implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-void
-PVMFStreamingManagerNode::InternalCommandComplete(PVMFStreamingManagerNodeCommand& aCmd,
-        PVMFStatus aStatus,
-        OsclAny* aEventData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
-                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
-
-    /* Reschedule AO if input command queue is not empty */
-    if (!iInputCommands.empty())
-    {
-        if (IsAdded())
-        {
-            RunIfNotReady();
-        }
-    }
-    /*
-     * Transition to error state in case of select errors only, viz.
-     * PVMFFailure, PVMFErrNoMemory, PVMFErrNoResources
-     * Any other status implies that the node is probably in a recoverable
-     * state
-     */
-    if (IsFatalErrorEvent(aStatus))
-    {
-        SetState(EPVMFNodeError);
-    }
-}
-
-/**
-//A routine to tell if a flush operation is in progress.
-*/
-bool PVMFStreamingManagerNode::FlushPending()
-{
-    if ((iCurrentCommand.size() > 0) &&
-            (iCurrentCommand.front().iCmd == PVMF_STREAMING_MANAGER_NODE_FLUSH) &&
-            (CheckChildrenNodesFlush() == false))
-    {
-        return true;
-    }
-    return false;
-}
-
-/**
-//Called by the command handler AO to do the Cancel All
-*/
-void PVMFStreamingManagerNode::DoCancelAllCommands(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::DoCancelAllCommands In"));
-    //first cancel the current command if any
-    if (iCurrentCommand.size() > 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::DoCancelAllCommands iCurrentCommand.size()>0"));
-        /*
-         * As of now we only allow cancelling the start command. Also only jitter buffer start
-         * needs to be cancelled. Rest of the nodes dont do anything in start.
-         */
-        {
-            ResetNodeContainerCmdState();
-            for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-            {
-                PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-                if (internalCmd != NULL)
-                {
-                    internalCmd->cmd =
-                        iNodeContainerVec[i].commandStartOffset +
-                        PVMF_STREAMING_MANAGER_NODE_INTERNAL_CANCEL_ALL_OFFSET;
-                    internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS;
-
-                    OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                    PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                    iNode->CancelAllCommands(iNodeContainerVec[i].iSessionId, cmdContextData);
-                    iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_CANCEL_PENDING;
-                }
-                else
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoCancelAllCommands:RequestNewInternalCmd - Failed"));
-                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                    return;
-                }
-            }
-            /* Wait for jitter buffer cancel all to complete */
-            /* If current command is not start then just wait for current command to complete */
-        }
-        MoveCmdToCancelQueue(aCmd);
-    }
-    else
-    {
-        //no current command - just cancel all queued commands, if any
-        {
-            //start at element 1 since this cancel command is element 0.
-            while (iInputCommands.size() > 1)
-            {
-                if (IsInternalCmd(iInputCommands.front().iCmd) == false)
-                {
-                    CommandComplete(iInputCommands.front(), PVMFErrCancelled);
-                }
-                /* Erase the command from the input queue */
-                iInputCommands.Erase(&iInputCommands.front());
-            }
-        }
-
-        //finally, report cancel complete.
-        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-    }
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::DoCancelAllCommands Out"));
-}
-
-bool PVMFStreamingManagerNode::CheckChildrenNodesCancelAll()
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeCmdState != PVMFSM_NODE_CMD_CANCEL_COMPLETE)
-        {
-            return false;
-        }
-    }
-    ResetNodeContainerCmdState();
-    return true;
-}
-
-void PVMFStreamingManagerNode::CompleteCancelAll()
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteCancelAll - In"));
-    if (CheckChildrenNodesCancelAll())
-    {
-        if (iCancelCommand.front().iContext)
-        {
-            /*
-             * CancelAllCommands is issued by upper layer
-             */
-            PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::CancelCommand() - CmdComplete - PVMFErrCancelled"));
-            if (!iCurrentCommand.empty())
-            {
-                //not need to send commandcmp during GraphConstruct
-                if (IsInternalCmd(iCurrentCommand.front().iCmd) == false)
-                {
-                    CommandComplete(iCurrentCommand.front(), PVMFErrCancelled);
-                }
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
-
-            /*
-             * cancel all queued commands, if any
-             */
-            while (iInputCommands.size() > 0)
-            {
-                if (IsInternalCmd(iInputCommands.front().iCmd) == false)
-                    CommandComplete(iInputCommands, iInputCommands.front(), PVMFErrCancelled);
-            }
-            /* finally send command complete for the cancel all command */
-            if (iErrorDuringProcess == SM_NO_ERROR)
-            {
-                PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteCancelAll - CancelAllCommands complete"));
-                CommandComplete(iCancelCommand,
-                                iCancelCommand.front(),
-                                PVMFSuccess);
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::CompleteCancelAll - CancelAllCommands complete error"));
-                CommandComplete(iCancelCommand, iCancelCommand.front(), PVMFFailure, iErrorResponseInf);
-
-                if (iErrorResponseInf != NULL)
-                {
-                    iErrorResponseInf->removeRef();
-                    iErrorResponseInf = NULL;
-                }
-                iErrorDuringProcess = SM_NO_ERROR;
-            }
-        }
-        else
-        {
-            /*
-             * CancelAllCommands is issued due to error
-             */
-            if (iCurrentCommand.front().iCmd == PVMF_STREAMING_MANAGER_NODE_RESET)
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::CompleteCancelAll Shound not issue CancelAllCommands durint Reset"));
-                OSCL_ASSERT(false);
-            }
-            PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::CompleteCancelAll() due to error - CmdComplete"));
-            /* Erase the command from the cancel queue */
-            iCancelCommand.Erase(&iCancelCommand.front());
-            if (!iCurrentCommand.empty())
-            {
-                /*
-                 * not need to send commandcmp for internal purpose
-                 */
-                if (IsInternalCmd(iCurrentCommand.front().iCmd) == false)
-                {
-                    CommandComplete(iCurrentCommand.front(), iCmdErrStatus, iErrorResponseInf, iEventData);
-                }
-                if (iErrorResponseInf != NULL)
-                {
-                    iErrorResponseInf->removeRef();
-                    iErrorResponseInf = NULL;
-                }
-                iCmdErrStatus = PVMFFailure;
-                iEventData = NULL;
-
-                /* Erase the command from the current queue */
-                iCurrentCommand.Erase(&iCurrentCommand.front());
-            }
-
-            /*
-             * cancel all queued commands, if any
-             */
-            if (iErrorDuringProcess == SM_NODE_COMMAND_COMPLETION)
-            {
-                while (iInputCommands.size() > 0)
-                {
-                    if (IsInternalCmd(iInputCommands.front().iCmd) == false)
-                    {
-                        CommandComplete(iInputCommands.front(), PVMFErrCancelled);
-                    }
-                    /* Erase the command from the input queue */
-                    iInputCommands.Erase(&iInputCommands.front());
-                }
-            }
-            iErrorDuringProcess = SM_NO_ERROR;
-        }
-    }
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::CompleteCancelAll - Out"));
-    return;
-}
-
-/**
-//Called by the command handler AO to do the Cancel single command
-*/
-void PVMFStreamingManagerNode::DoCancelCommand(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    //extract the command ID from the parameters.
-    PVMFCommandId id;
-    aCmd.PVMFStreamingManagerNodeCommandBase::Parse(id);
-
-    //first check "current" command if any
-    {
-        PVMFStreamingManagerNodeCommand* cmd = iCurrentCommand.FindById(id);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iCurrentCommand, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //next check input queue.
-    {
-        //start at element 1 since this cancel command is element 0.
-        PVMFStreamingManagerNodeCommand* cmd = iInputCommands.FindById(id, 1);
-        if (cmd)
-        {
-            //cancel the queued command
-            CommandComplete(iInputCommands, *cmd, PVMFErrCancelled);
-            //report cancel success
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-            return;
-        }
-    }
-    //if we get here the command isn't queued so the cancel fails.
-    CommandComplete(iInputCommands, aCmd, PVMFFailure);
-}
-
-/////////////////////////////////////////////////////
-// Event reporting routines.
-/////////////////////////////////////////////////////
-void PVMFStreamingManagerNode::SetState(TPVMFNodeInterfaceState s)
-{
-    PVMF_SM_LOGINFO((0, "StreamingManagerNode:SetState %d", s));
-    PVMFNodeInterface::SetState(s);
-}
-
-void PVMFStreamingManagerNode::ReportErrorEvent(PVMFEventType aEventType,
-        OsclAny* aEventData,
-        PVUuid* aEventUUID,
-        int32* aEventCode)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:NodeErrorEvent Type %d Data %d"
-                           , aEventType, aEventData));
-
-    if (aEventUUID && aEventCode)
-    {
-        PVMFBasicErrorInfoMessage* eventmsg =
-            OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        PVMFAsyncEvent asyncevent(PVMFErrorEvent,
-                                  aEventType,
-                                  NULL,
-                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
-                                  aEventData,
-                                  NULL,
-                                  0);
-        PVMFNodeInterface::ReportErrorEvent(asyncevent);
-        eventmsg->removeRef();
-    }
-    else
-    {
-        PVMFNodeInterface::ReportErrorEvent(aEventType, aEventData);
-    }
-}
-
-void PVMFStreamingManagerNode::ReportInfoEvent(PVMFEventType aEventType,
-        OsclAny* aEventData,
-        PVUuid* aEventUUID,
-        int32* aEventCode)
-
-{
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:NodeInfoEvent Type %d Data %d"
-                           , aEventType, aEventData));
-
-    if (aEventUUID && aEventCode)
-    {
-        PVMFBasicErrorInfoMessage* eventmsg =
-            OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
-        PVMFAsyncEvent asyncevent(PVMFInfoEvent,
-                                  aEventType,
-                                  NULL,
-                                  OSCL_STATIC_CAST(PVInterface*, eventmsg),
-                                  aEventData,
-                                  NULL,
-                                  0);
-        PVMFNodeInterface::ReportInfoEvent(asyncevent);
-        eventmsg->removeRef();
-    }
-    else
-    {
-        PVMFNodeInterface::ReportInfoEvent(aEventType, aEventData);
-    }
-}
-
-void
-PVMFStreamingManagerNode::HandlePortActivity(const PVMFPortActivity& aActivity)
-{
-    OSCL_UNUSED_ARG(aActivity);
-    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:HandlePortActivity - Not Implemented"));
-}
-
-/**
- * Active object implementation
- * The AO will either process one command or service one connected
- * port per call.  It will re-schedule itself and run continuously
- * until it runs out of things to do.
- */
+/* From OsclActiveObject */
 void PVMFStreamingManagerNode::Run()
 {
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Run - In"));
     /* Process commands */
     if (!iInputCommands.empty())
     {
@@ -3711,17 +704,103 @@
         }
     }
 
-    /*
-     * If we get here we did not process any commands.
-     * Check for completion of a flush command...
-     */
-    if (FlushPending())
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::Run - Out"));
+}
+
+void PVMFStreamingManagerNode::DoCancel()
+{
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoCancel - In"));
+    /* the base class cancel operation is sufficient */
+    OsclActiveObject::DoCancel();
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoCancel - Out"));
+}
+
+bool PVMFStreamingManagerNode::ProcessCommand(PVMFStreamingManagerNodeCommand& aCmd)
+{
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::ProcessCommand - In"));
+    //Because all the commands are processed in one AO cycle. So, there's no need for current command Q/Cancel command Q.
+
+    switch (aCmd.iCmd)
     {
-        /*
-         * Flush is complete.  Go to initialized state.
-         */
-        SetState(EPVMFNodeInitialized);
-        CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFSuccess);
+        case PVMF_STREAMING_MANAGER_NODE_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+
+        case PVMF_STREAMING_MANAGER_NODE_RESET:
+            ThreadLogoff();
+            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+            break;
+
+        case PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS:
+            DoCancelAllCommands(aCmd);
+            break;
+
+        case PVMF_STREAMING_MANAGER_NODE_CANCELCOMMAND:
+            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+            break;
+
+        default:
+            /* unknown command type */
+            CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
+            break;
+    }
+    return true;
+}
+
+bool PVMFStreamingManagerNode::DoCancelAllCommands(PVMFStreamingManagerNodeCommand& aCmd)
+{
+    const int32 cancelCmdId = iInputCommands.front().iId;
+    const int32 inputCmndsSz = iInputCommands.size();
+
+    for (int ii = inputCmndsSz - 1; ii > 0 ; ii--) //we dont want to process element at index 0 (being cancel command)
+    {
+        if (iInputCommands[ii].iId < cancelCmdId)
+        {
+            CommandComplete(iInputCommands, iInputCommands[ii], PVMFErrCancelled);
+        }
+    }
+    CommandComplete(iInputCommands, aCmd, PVMFSuccess); //complete the cancel all command
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFSMFSPBaseNode::DoCancelAllCommands Out"));
+    return true;
+}
+
+void PVMFStreamingManagerNode::CommandComplete(PVMFStreamingManagerNodeCmdQ& aCmdQ,
+        PVMFStreamingManagerNodeCommand& aCmd,
+        PVMFStatus aStatus,
+        OsclAny* aEventData,
+        PVUuid* aEventUUID,
+        int32* aEventCode)
+{
+    PVMF_SM_LOGSTACKTRACE((0, "StreamingManagerNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
+                           , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    PVInterface* extif = NULL;
+    PVMFBasicErrorInfoMessage* errormsg = NULL;
+    if (aEventUUID && aEventCode)
+    {
+        errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
+        extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
+    }
+
+    /* create response */
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    /* Erase the command from the queue */
+    aCmdQ.Erase(&aCmd);
+
+    /* Report completion to the session observer */
+    ReportCmdCompleteEvent(session, resp);
+
+    if (errormsg)
+    {
+        errormsg->removeRef();
+    }
+
+    /* Reschedule AO if input command queue is not empty */
+    if (!iInputCommands.empty() && IsAdded())
+    {
         if (IsAdded())
         {
             RunIfNotReady();
@@ -3729,8041 +808,61 @@
     }
 }
 
-void PVMFStreamingManagerNode::DoCancel()
+void PVMFStreamingManagerNode::DoQueryInterface(PVMFStreamingManagerNodeCommand& aCmd)
 {
-    /* the base class cancel operation is sufficient */
-    OsclActiveObject::DoCancel();
-}
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryInterface - In"));
 
-void
-PVMFStreamingManagerNode::NodeCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode::NodeCommandCompleted"));
-
-    bool oResponseOverRide = false;
-
-    PVMFSMCommandContext *cmdContextData =
-        OSCL_REINTERPRET_CAST(PVMFSMCommandContext*, aResponse.GetContext());
-
-    PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:NodeCommandCompleted: %d", cmdContextData->cmd));
-
-    if ((cmdContextData->cmd >=
-            PVMF_STREAMING_MANAGER_SOCKET_NODE_COMMAND_START) &&
-            (cmdContextData->cmd <
-             PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_COMMAND_START))
-
+    PVUuid* uuid;
+    PVInterface** ifptr;
+    aCmd.Parse(uuid, ifptr);
+    if (ifptr == NULL)
     {
-        HandleSocketNodeCommandCompleted(aResponse);
-    }
-    else if ((cmdContextData->cmd >=
-              PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_COMMAND_START) &&
-             (cmdContextData->cmd <
-              PVMF_STREAMING_MANAGER_JITTER_BUFFER_CONTROLLER_COMMAND_START))
-
-    {
-        HandleRTSPSessionControllerCommandCompleted(aResponse, oResponseOverRide);
-    }
-    else if ((cmdContextData->cmd >=
-              PVMF_STREAMING_MANAGER_JITTER_BUFFER_CONTROLLER_COMMAND_START) &&
-             (cmdContextData->cmd <
-              PVMF_STREAMING_MANAGER_MEDIA_LAYER_COMMAND_START))
-
-    {
-        HandleJitterBufferCommandCompleted(aResponse);
-    }
-    else if ((cmdContextData->cmd >=
-              PVMF_STREAMING_MANAGER_MEDIA_LAYER_COMMAND_START) &&
-             (cmdContextData->cmd <
-              PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_COMMAND_START))
-
-    {
-        HandleMediaLayerCommandCompleted(aResponse);
-    }
-    else if (cmdContextData->cmd >=
-             PVMF_STREAMING_MANAGER_RTPPACKETSOURCE_NODE_COMMAND_START)
-    {
-    }
-
-    if ((aResponse.GetCmdStatus() != PVMFSuccess) &&
-            (aResponse.GetCmdStatus() != PVMFErrCancelled) &&
-            (oResponseOverRide == false))
-    {
-        if (iCancelCommand.size() > 0)
-        {
-            if (cmdContextData->parentCmd == PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS)
-            {
-                /*
-                 * During CancelAllComands, error happen from child node.
-                 * Then we save this err and after all current cmd is canceled in child node, we send this err code.
-                 * If CancelAllCommands is issued by internal error handling, iErrorDuringProcess should be true.
-                 */
-                if (iErrorDuringProcess == SM_NO_ERROR)
-                {
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode:NodeCommandCompleted: - Reset Error during CancelAll"));
-                    if (iErrorResponseInf != NULL)
-                    {
-                        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::NodeCommandCompleted - iErrorResponseInf is not NULL"));
-                        OSCL_ASSERT(false);
-                    }
-                    /*
-                     * Only first error msg from cancelall completion in child node is stored.
-                     */
-                    if (aResponse.GetEventExtensionInterface())
-                    {
-                        iErrorResponseInf = aResponse.GetEventExtensionInterface();
-                        iErrorResponseInf->addRef();
-                    }
-                    iErrorDuringProcess = SM_NODE_COMMAND_COMPLETION;
-                }
-                CompleteCancelAll();
-            }
-            /*
-             * If Error is recieved for Current Cmd during cancelling, we just ignore.
-             */
-        }
-        else if (iCurrentCommand.size() > 0)
-        {
-            /*
-             * If error is recieved while current cmd is ongoing, we save this error code and issue CancelAllCommands.
-             * After all current cmd is canceled in child node,
-             * we send this error code if current cmd is not internal use.
-             */
-            if (iErrorDuringProcess == SM_NO_ERROR)
-            {
-                if (iErrorResponseInf != NULL)
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::NodeCommandCompleted - iErrorResponseInf is not NULL"));
-                    OSCL_ASSERT(false);
-                }
-                if (aResponse.GetEventExtensionInterface())
-                {
-                    iErrorResponseInf = aResponse.GetEventExtensionInterface();
-                    iErrorResponseInf->addRef();
-                }
-                iCmdErrStatus = aResponse.GetCmdStatus();
-                iEventData = aResponse.GetEventData();
-                iErrorDuringProcess = SM_NODE_COMMAND_COMPLETION;
-
-                /*
-                 * We don't interupt any Reset cmd for child node.
-                 * After all Reset cmd is completed in child node, we send this error.
-                 */
-                if (cmdContextData->parentCmd != PVMF_STREAMING_MANAGER_NODE_RESET)
-                {
-                    PVMFSessionId s = 0;
-                    PVMFStreamingManagerNodeCommand cmdCancelPendingCmd;
-                    cmdCancelPendingCmd.PVMFStreamingManagerNodeCommandBase::Construct(s,
-                            PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS,
-                            NULL);
-                    QueueCommandL(cmdCancelPendingCmd);
-                    PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:NodeCommandCompleted: - CancelAllCommands Queued"));
-
-                    ResetNodeContainerCmdState();
-                }
-            }
-            else
-            {
-                PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:NodeCommandCompleted: - CancelAllCommands already Queued"));
-            }
-        }
-    }
-    return;
-}
-
-void
-PVMFStreamingManagerNode::HandleSocketNodeCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    PVMFSMNodeContainer* iSocketNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-    if (iSocketNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVMFSMCommandContext *cmdContextData =
-        OSCL_REINTERPRET_CAST(PVMFSMCommandContext*, aResponse.GetContext());
-
-    if (iSocketNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_PENDING)
-    {
-        iSocketNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_COMPLETE;
-    }
-    else if (iSocketNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_CANCEL_PENDING)
-    {
-        if (cmdContextData->parentCmd == PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS)
-            iSocketNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_CANCEL_COMPLETE;
-    }
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::HandleSocketNodeCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
-        if (IsBusy())
-        {
-            Cancel();
-            RunIfNotReady();
-        }
-        return;
-    }
-    cmdContextData->oFree = true;
-
-    switch (cmdContextData->cmd)
-    {
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_QUERY_UUID:
-            CompleteQueryUuid();
-            break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_QUERY_INTERFACE:
-        {
-            if (iExtensionInterfacePlaceholder == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            iSocketNodeContainer->iExtensions.push_back(iExtensionInterfacePlaceholder);
-            CompleteQueryInterface();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_INIT:
-        {
-            {
-                CompleteInit();
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_PREPARE:
-        {
-            {
-                CompletePrepare();
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_START:
-        {
-            {
-                {
-                    CompleteStart();
-                }
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_STOP:
-        {
-            CompleteStop();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_FLUSH:
-            CompleteFlush();
-            break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_PAUSE:
-        {
-            {
-                CompletePause();
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_RESET:
-            CompleteReset();
-            break;
-
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_REQUEST_PORT:
-        {
-            PVMFPortInterface* port =
-                (PVMFPortInterface*)aResponse.GetEventData();
-            {
-                /*
-                 * Save the port in TrackInfo
-                 */
-                PVMFSMTrackInfo* trackInfo =
-                    FindTrackInfo(cmdContextData->portContext.trackID);
-
-                if (cmdContextData->portContext.portTag ==
-                        PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
-                {
-                    trackInfo->iNetworkNodePort = port;
-                    iSocketNodeContainer->iOutputPorts.push_back(port);
-                }
-                else if (cmdContextData->portContext.portTag ==
-                         PVMF_SOCKET_NODE_PORT_TYPE_SINK)
-                {
-                    trackInfo->iNetworkNodeRTCPPort = port;
-                    iSocketNodeContainer->iInputPorts.push_back(port);
-                }
-                CompleteGraphConstruct();
-            }
-        }
-        break;
-        case PVMF_STREAMING_MANAGER_SOCKET_NODE_CANCEL_ALL_COMMANDS:
-        {
-            CompleteCancelAll();
-        }
-        break;
-
-        default:
-            break;
-    }
-    return;
-}
-
-void
-PVMFStreamingManagerNode::HandleRTSPSessionControllerCommandCompleted(const PVMFCmdResp& aResponse,
-        bool& aResponseOverRide)
-{
-    aResponseOverRide = false;
-
-    PVMFSMNodeContainer* iSessionControllerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-    if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVMFSMCommandContext *cmdContextData =
-        OSCL_REINTERPRET_CAST(PVMFSMCommandContext*, aResponse.GetContext());
-
-    if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_PENDING)
-    {
-        iSessionControllerNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_COMPLETE;
-    }
-    else if (iSessionControllerNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_CANCEL_PENDING)
-    {
-        if (cmdContextData->parentCmd == PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS)
-            iSessionControllerNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_CANCEL_COMPLETE;
-    }
-
-    cmdContextData->oFree = true;
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        if (cmdContextData->cmd == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_PAUSE)
-        {
-            /*
-             * Check if it is a pause failure - suppress pause failures if they
-             * happen after a session is complete
-             */
-            PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-            if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            PVMFJitterBufferExtensionInterface* jbExtIntf =
-                (PVMFJitterBufferExtensionInterface*)
-                (iJitterBufferNodeContainer->iExtensions[0]);
-            bool oSessionExpired = false;
-            jbExtIntf->HasSessionDurationExpired(oSessionExpired);
-            if (oSessionExpired == true)
-            {
-                aResponseOverRide = true;
-            }
-        }
-        /* if a failure has been overridden just fall thru */
-        if (aResponseOverRide == false)
-        {
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::HandleRTSPSessionControllerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
-            if (IsBusy())
-            {
-                Cancel();
-                RunIfNotReady();
-            }
-            return;
-        }
-    }
-
-    switch (cmdContextData->cmd)
-    {
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_QUERY_UUID:
-            CompleteQueryUuid();
-            break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_QUERY_INTERFACE:
-        {
-            if (iExtensionInterfacePlaceholder == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            iSessionControllerNodeContainer->iExtensions.push_back(iExtensionInterfacePlaceholder);
-            CompleteQueryInterface();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_INIT:
-            CompleteInit();
-            break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_PREPARE:
-        {
-            if (iSessionSourceInfo->iRTSPTunnelling == false)
-            {
-                /* Complete set up of feedback channels */
-                CompleteFeedBackPortsSetup();
-            }
-            /*
-             * Send start complete params to child nodes
-             * viz. SSRC etc
-             */
-            SendSessionControlPrepareCompleteParams();
-            CompletePrepare();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_START:
-        {
-            {
-                /*
-                 * Send start complete params to child nodes
-                 * viz. actual play range, rtp info params etc
-                 */
-                SendSessionControlStartCompleteParams();
-                CompleteStart();
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_STOP:
-        {
-            CompleteStop();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_FLUSH:
-            CompleteFlush();
-            break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_PAUSE:
-        {
-            {
-                CompletePause();
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_RESET:
-            CompleteReset();
-            break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_REQUEST_PORT:
-        {
-            /*
-             * Save the port in TrackInfo
-             */
-            PVMFSMTrackInfo* trackInfo =
-                FindTrackInfo(cmdContextData->portContext.trackID);
-
-            PVMFPortInterface* port =
-                (PVMFPortInterface*)aResponse.GetEventData();
-
-            if (cmdContextData->portContext.portTag ==
-                    PVMF_RTSP_NODE_PORT_TYPE_OUTPUT)
-            {
-                trackInfo->iSessionControllerOutputPort = port;
-                iSessionControllerNodeContainer->iOutputPorts.push_back(port);
-
-            }
-            else if (cmdContextData->portContext.portTag ==
-                     PVMF_RTSP_NODE_PORT_TYPE_INPUT)
-            {
-                iSessionControllerNodeContainer->iInputPorts.push_back(port);
-            }
-            else if (cmdContextData->portContext.portTag ==
-                     PVMF_RTSP_NODE_PORT_TYPE_INPUT_OUTPUT)
-            {
-                trackInfo->iSessionControllerFeedbackPort = port;
-                iSessionControllerNodeContainer->iFeedBackPorts.push_back(port);
-            }
-            CompleteGraphConstruct();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_CANCEL_ALL_COMMANDS:
-        {
-            CompleteCancelAll();
-        }
-        break;
-
-        default:
-            break;
-    }
-    return;
-}
-
-void
-PVMFStreamingManagerNode::HandleJitterBufferCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    PVMFSMNodeContainer* iJitterBufferNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVMFSMCommandContext *cmdContextData =
-        OSCL_REINTERPRET_CAST(PVMFSMCommandContext*, aResponse.GetContext());
-
-    if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_PENDING)
-    {
-        iJitterBufferNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_COMPLETE;
-    }
-    else if (iJitterBufferNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_CANCEL_PENDING)
-    {
-        if (cmdContextData->parentCmd == PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS)
-            iJitterBufferNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_CANCEL_COMPLETE;
-    }
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::HandleJitterBufferCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
-        if (IsBusy())
-        {
-            Cancel();
-            RunIfNotReady();
-        }
-        return;
-    }
-
-    cmdContextData->oFree = true;
-
-    switch (cmdContextData->cmd)
-    {
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_QUERY_UUID:
-            CompleteQueryUuid();
-            break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_QUERY_INTERFACE:
-        {
-            if (iExtensionInterfacePlaceholder == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            iJitterBufferNodeContainer->iExtensions.push_back(iExtensionInterfacePlaceholder);
-            CompleteQueryInterface();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_INIT:
-        {
-            PVMFJitterBufferExtensionInterface* jbExtIntf =
-                (PVMFJitterBufferExtensionInterface*)
-                (iJitterBufferNodeContainer->iExtensions[0]);
-            if (jbExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            if (IsRTPPacketSourcePresent())
-            {
-                jbExtIntf->SetBroadCastSession();
-            }
-            bool disableFireWallPackets = true;
-            if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-                    (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-            {
-                if (iSessionSourceInfo->iRTSPTunnelling == false)
-                {
-                    //do not disable fw pkts run time
-                    //apps can still disable it compile time or using KVP
-                    //for UDP sessions ofcourse
-                    disableFireWallPackets = false;
-                }
-            }
-            if (disableFireWallPackets == true)
-            {
-                jbExtIntf->DisableFireWallPackets();
-            }
-            CompleteInit();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_PREPARE:
-            CompletePrepare();
-            break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_START:
-        {
-            /* If start has been cancelled wait for cancel success */
-            if (aResponse.GetCmdStatus() != PVMFErrCancelled)
-            {
-                CompleteStart();
-            }
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_STOP:
-        {
-            CompleteStop();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_FLUSH:
-            CompleteFlush();
-            break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_PAUSE:
-            CompletePause();
-            break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_RESET:
-            CompleteReset();
-            break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_REQUEST_PORT:
-        {
-            PVMFJitterBufferExtensionInterface* jbExtIntf =
-                (PVMFJitterBufferExtensionInterface*)
-                (iJitterBufferNodeContainer->iExtensions[0]);
-
-            if (jbExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-            /*
-             * Save the port in TrackInfo
-             */
-            PVMFSMTrackInfo* trackInfo =
-                FindTrackInfo(cmdContextData->portContext.trackID);
-
-            PVMFPortInterface* port =
-                (PVMFPortInterface*)aResponse.GetEventData();
-
-            uint32 bitrate = 0;
-
-            if (cmdContextData->portContext.portTag ==
-                    PVMF_JITTER_BUFFER_PORT_TYPE_INPUT)
-            {
-                bitrate = trackInfo->bitRate;
-                trackInfo->iJitterBufferInputPort = port;
-                iJitterBufferNodeContainer->iInputPorts.push_back(port);
-            }
-            else if (cmdContextData->portContext.portTag ==
-                     PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT)
-            {
-                trackInfo->iJitterBufferOutputPort = port;
-                iJitterBufferNodeContainer->iOutputPorts.push_back(port);
-            }
-            else if (cmdContextData->portContext.portTag ==
-                     PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK)
-            {
-                trackInfo->iJitterBufferRTCPPort = port;
-                iJitterBufferNodeContainer->iFeedBackPorts.push_back(port);
-
-                //if RTP packet source is present, it implies a DVBH session
-                //and we disable RTCP RRs for DVB sessions
-                if (IsRTPPacketSourcePresent())
-                {
-                    //The packet source does not process RTCP reader reports.
-                    //So, disable them by setting the RR bandwidth to zero.
-                    //The RS bandwidth is set to the RFC default of 800 bps but
-                    //actual bandwidth is allocated by the fraction RS/(RR+RS), so
-                    //the number used for RS in this case is arbitrary because
-                    //sender reports will get 100% of the RTCP bandwidth as RS/RS = 100%.
-                    jbExtIntf->setPortRTCPParams(port,
-                                                 iTrackInfoVec.size(),
-                                                 0,
-                                                 800);
-                }
-                else
-                {
-                    if (trackInfo->iRTCPBwSpecified)
-                    {
-                        jbExtIntf->setPortRTCPParams(port, iTrackInfoVec.size(), trackInfo->iRR, trackInfo->iRS);
-                    }
-                }
-            }
-            jbExtIntf->setPortParams(port,
-                                     trackInfo->trackTimeScale,
-                                     bitrate,
-                                     trackInfo->iTrackConfig,
-                                     trackInfo->iRateAdaptation,
-                                     trackInfo->iRateAdaptationFeedBackFrequency);
-            CompleteGraphConstruct();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_JITTER_BUFFER_CANCEL_ALL_COMMANDS:
-        {
-            CompleteCancelAll();
-        }
-        break;
-
-        default:
-            break;
-    }
-    return;
-}
-
-void
-PVMFStreamingManagerNode::HandleMediaLayerCommandCompleted(const PVMFCmdResp& aResponse)
-{
-    PVMFSMNodeContainer* iMediaLayerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-    if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVMFSMCommandContext *cmdContextData =
-        OSCL_REINTERPRET_CAST(PVMFSMCommandContext*, aResponse.GetContext());
-
-    if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_PENDING)
-    {
-        iMediaLayerNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_COMPLETE;
-    }
-    else if (iMediaLayerNodeContainer->iNodeCmdState == PVMFSM_NODE_CMD_CANCEL_PENDING)
-    {
-        if (cmdContextData->parentCmd == PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS)
-            iMediaLayerNodeContainer->iNodeCmdState = PVMFSM_NODE_CMD_CANCEL_COMPLETE;
-    }
-
-    if (aResponse.GetCmdStatus() != PVMFSuccess)
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::HandleMediaLayerCommandCompleted - Command failed - context=0x%x, status=0x%x", aResponse.GetContext(), aResponse.GetCmdStatus()));
-        if (IsBusy())
-        {
-            Cancel();
-            RunIfNotReady();
-        }
-        return;
-    }
-
-    cmdContextData->oFree = true;
-
-    switch (cmdContextData->cmd)
-    {
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_QUERY_UUID:
-            CompleteQueryUuid();
-            break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_QUERY_INTERFACE:
-        {
-            if (iExtensionInterfacePlaceholder == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            iMediaLayerNodeContainer->iExtensions.push_back(iExtensionInterfacePlaceholder);
-            CompleteQueryInterface();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_INIT:
-            CompleteInit();
-            break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_PREPARE:
-            CompletePrepare();
-            break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_START:
-        {
-            CompleteStart();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_STOP:
-        {
-            CompleteStop();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_FLUSH:
-            CompleteFlush();
-            break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_PAUSE:
-            CompletePause();
-            break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_RESET:
-            CompleteReset();
-            break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_REQUEST_PORT:
-        {
-            PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-                (PVMFMediaLayerNodeExtensionInterface*)
-                (iMediaLayerNodeContainer->iExtensions[0]);
-
-            if (mlExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-            /*
-             * Save the port in TrackInfo
-             */
-            PVMFSMTrackInfo* trackInfo =
-                FindTrackInfo(cmdContextData->portContext.trackID);
-
-            PVMFPortInterface* port =
-                (PVMFPortInterface*)aResponse.GetEventData();
-
-            if (cmdContextData->portContext.portTag ==
-                    PVMF_MEDIALAYER_PORT_TYPE_INPUT)
-            {
-                trackInfo->iMediaLayerInputPort = port;
-                iMediaLayerNodeContainer->iInputPorts.push_back(port);
-            }
-            else if (cmdContextData->portContext.portTag ==
-                     PVMF_MEDIALAYER_PORT_TYPE_OUTPUT)
-            {
-                trackInfo->iMediaLayerOutputPort = port;
-                iMediaLayerNodeContainer->iOutputPorts.push_back(port);
-            }
-            mediaInfo* mInfo = NULL;
-            if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-                    (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-                    (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-            {
-                SDPInfo* sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-                if (sdpInfo == NULL) OSCL_LEAVE(OsclErrBadHandle);
-                mInfo = sdpInfo->getMediaInfoBasedOnID(trackInfo->trackID);
-            }
-            mlExtIntf->setPortMediaParams(port, trackInfo->iTrackConfig, mInfo);
-            CompleteGraphConstruct();
-        }
-        break;
-
-        case PVMF_STREAMING_MANAGER_MEDIA_LAYER_CANCEL_ALL_COMMANDS:
-        {
-            CompleteCancelAll();
-        }
-        break;
-
-        default:
-            break;
-    }
-    return;
-}
-
-bool PVMFStreamingManagerNode::IsFatalErrorEvent(const PVMFEventType& event)
-{
-    bool retval = false;
-    switch (event)
-    {
-        case PVMFErrCorrupt:
-        case PVMFErrOverflow:
-        case PVMFErrResource:
-        case PVMFErrProcessing:
-        case PVMFErrUnderflow:
-        case PVMFErrNoResources:
-        case PVMFErrResourceConfiguration:
-        case PVMFErrTimeout:
-        case PVMFErrNoMemory:
-        case PVMFFailure:
-            retval = true;
-            break;
-        default:
-            retval = false;
-    }
-    return retval;
-}
-
-void
-PVMFStreamingManagerNode::HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::HandleNodeErrorEvent - In iCancelCommand.empty() [%d] current command id[%d] event type [%d]", iCancelCommand.empty(), iCurrentCommand.front().iCmd, aEvent.GetEventType()));
-
-    //Check if fatal error occurred, then we may need to enque the cancelallcommand due to error
-    if (IsFatalErrorEvent(aEvent.GetEventType())
-            && !iCurrentCommand.empty()
-            && iCancelCommand.empty())
-    {
-        if ((IsInternalCmd(iCurrentCommand.front().iCmd) == true))
-        {
-            /*
-             * cancel all queued commands, if any
-             */
-            while (iInputCommands.size() > 0)
-            {
-                if (IsInternalCmd(iInputCommands.front().iCmd) == false)
-                {
-                    CommandComplete(iInputCommands.front(), PVMFErrCancelled);
-                }
-                /* Erase the command from the input queue */
-                iInputCommands.Erase(&iInputCommands.front());
-            }
-
-            /*
-             * After the completion of the cancel due to error, we will complete the current command in which failure occurred.
-             */
-            iErrorDuringProcess = SM_ERROR_EVENT;
-            PVMFSessionId s = 0;
-            PVMFStreamingManagerNodeCommand cmdCancelPendingCmd;
-            cmdCancelPendingCmd.PVMFStreamingManagerNodeCommandBase::Construct(s,
-                    PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS,
-                    NULL);
-            QueueCommandL(cmdCancelPendingCmd);
-            PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode:HandleNodeErrorEvent: - CancelAllCommands Queued"));
-        }
-    }
-    //just pass the error event up
-    PVMFAsyncEvent event = OSCL_CONST_CAST(PVMFAsyncEvent, aEvent);
-    PVMFNodeInterface::ReportErrorEvent(event);
-
-    return;
-}
-
-void
-PVMFStreamingManagerNode::HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent)
-{
-    PVMFAsyncEvent event = OSCL_CONST_CAST(PVMFAsyncEvent, aEvent);
-    PVMFEventType infoEvent = aEvent.GetEventType();
-    if (infoEvent == PVMFInfoEndOfData)
-    {
-        /* Notify jitter buffer */
-        PVMFSMNodeContainer* iJitterBufferNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFJitterBufferExtensionInterface* jbExtIntf =
-            (PVMFJitterBufferExtensionInterface*)
-            (iJitterBufferNodeContainer->iExtensions[0]);
-        jbExtIntf->NotifyOutOfBandEOS();
-    }
-    else
-    {
-        /* Just pass the info event up */
-        PVMFNodeInterface::ReportInfoEvent(event);
-    }
-}
-
-PVMFSMCommandContext* PVMFStreamingManagerNode::RequestNewInternalCmd()
-{
-    int32 i = 0;
-    /* Search for the next free node command in the pool */
-    while (i < PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE)
-    {
-        if (iInternalCmdPool[i].oFree)
-        {
-            iInternalCmdPool[i].oFree = false;
-            return &(iInternalCmdPool[i]);
-        }
-        ++i;
-    }
-    /* Free one not found so return NULL */
-    return NULL;
-}
-
-void
-PVMFStreamingManagerNode::MoveCmdToCurrentQueue(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    int32 err;
-    OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
-    if (err != OsclErrNone)
-    {
-        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-        return;
-    }
-    iInputCommands.Erase(&aCmd);
-    return;
-}
-
-void
-PVMFStreamingManagerNode::MoveCmdToCancelQueue(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    /*
-     * note: the StoreL cannot fail since the queue is never more than 1 deep
-     * and we reserved space.
-     */
-    iCancelCommand.StoreL(aCmd);
-    iInputCommands.Erase(&aCmd);
-    return;
-}
-
-PVMFSMNodeContainer*
-PVMFStreamingManagerNode::getNodeContainer(int32 tag)
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeTag == tag)
-        {
-            return (&(iNodeContainerVec[i]));
-        }
-    }
-    return NULL;
-}
-
-bool PVMFStreamingManagerNode::PopulateTrackInfoVec()
-{
-    if (iSelectedMediaPresetationInfo.getNumTracks() == 0)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:PopulateTrackInfoVec - Selected Track List Empty"));
-        return false;
-    }
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        /*
-         * Get selected tracks
-         */
-        SDPInfo* sdpInfo = iSessionSourceInfo->_sdpInfo;
-
-        int32 numTracks = sdpInfo->getNumMediaObjects();
-
-        if (numTracks > 0)
-        {
-            for (int32 i = 0; i < numTracks; i++)
-            {
-                /*
-                 * Get the vector of mediaInfo as there can
-                 * alternates for each track
-                 */
-                Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
-                    sdpInfo->getMediaInfo(i);
-
-                uint32 minfoVecLen = mediaInfoVec.size();
-                for (uint32 j = 0; j < minfoVecLen; j++)
-                {
-                    mediaInfo* mInfo = mediaInfoVec[j];
-
-                    if (mInfo == NULL)
-                    {
-                        return false;
-                    }
-
-                    if (mInfo->getSelect())
-                    {
-                        PVMFSMTrackInfo trackInfo;
-
-                        {
-                            trackInfo.iTransportType += _STRLIT_CHAR("RTP");
-                        }
-
-                        trackInfo.trackID = mInfo->getMediaInfoID();
-
-                        Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
-                        payloadVector = mInfo->getPayloadSpecificInfoVector();
-
-                        if (payloadVector.size() == 0)
-                        {
-                            return false;
-                        }
-                        /*
-                         * There can be multiple payloads per media segment.
-                         * We only support one for now, so
-                         * use just the first payload
-                         */
-                        PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
-                        trackInfo.trackTimeScale = payloadInfo->sampleRate;
-
-                        // set config for later
-                        int32 configSize = payloadInfo->configSize;
-                        OsclAny* config = payloadInfo->configHeader.GetRep();
-
-                        const char* mimeType = mInfo->getMIMEType();
-                        OSCL_StackString<32> h263(_STRLIT_CHAR("H263"));
-                        {
-                            trackInfo.iMimeType += mimeType;
-                        }
-
-                        trackInfo.portTag = mInfo->getMediaInfoID();
-                        trackInfo.bitRate = mInfo->getBitrate();
-                        if (mInfo->getReportFrequency() > 0)
-                        {
-                            trackInfo.iRateAdaptation = true;
-                            trackInfo.iRateAdaptationFeedBackFrequency =
-                                mInfo->getReportFrequency();
-                        }
-
-                        if ((mInfo->getRTCPReceiverBitRate() >= 0) &&
-                                (mInfo->getRTCPSenderBitRate() >= 0))
-                        {
-                            trackInfo.iRR = mInfo->getRTCPReceiverBitRate();
-                            trackInfo.iRS = mInfo->getRTCPSenderBitRate();
-                            trackInfo.iRTCPBwSpecified = true;
-                        }
-
-                        if ((configSize > 0) && (config != NULL))
-                        {
-                            OsclMemAllocDestructDealloc<uint8> my_alloc;
-                            OsclRefCounter* my_refcnt;
-                            uint aligned_refcnt_size =
-                                oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
-
-                            uint8* my_ptr = NULL;
-                            int32 errcode = 0;
-                            OSCL_TRY(errcode, my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size + configSize));
-
-                            my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
-                            my_ptr += aligned_refcnt_size;
-
-                            OsclMemoryFragment memfrag;
-                            memfrag.len = (uint32)configSize;
-                            memfrag.ptr = my_ptr;
-
-                            oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
-
-                            OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
-                            trackInfo.iTrackConfig = tmpRefcntMemFrag;
-                        }
-                        iTrackInfoVec.push_back(trackInfo);
-                    }
-                }
-            }
-        }
-        else
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:PopulateTrackInfoVec - Selected Track List Empty"));
-            return false;
-        }
-    }
-    return true;
-}
-
-PVMFSMTrackInfo*
-PVMFStreamingManagerNode::FindTrackInfo(uint32 trackID)
-{
-    PVMFSMTrackInfoVector::iterator it;
-
-    for (it = iTrackInfoVec.begin();
-            it != iTrackInfoVec.end();
-            it++)
-    {
-        if (it->trackID == trackID)
-        {
-            return (it);
-        }
-    }
-    return NULL;
-}
-
-PVMFSMTrackInfo*
-PVMFStreamingManagerNode::FindTrackInfo(PvmfMimeString* trackMimeType)
-{
-    PVMFSMTrackInfoVector::iterator it;
-
-    for (it = iTrackInfoVec.begin();
-            it != iTrackInfoVec.end();
-            it++)
-    {
-        if (!(oscl_CIstrcmp(it->iMimeType.get_cstr(),
-                            trackMimeType->get_cstr())))
-        {
-            return (it);
-        }
-    }
-    return NULL;
-}
-
-bool PVMFStreamingManagerNode::ReserveSockets()
-{
-    uint32 sockid = 0;
-    char portConfigBuf[64];
-    oscl_memset((OsclAny*)portConfigBuf, 0, 64);
-    oscl_snprintf(portConfigBuf, 64, "%d", sockid);
-    OSCL_StackString<128> portConfig("UDP");
-    portConfig += _STRLIT_CHAR("/remote_address=0.0.0.0");
-    portConfig += _STRLIT_CHAR(";client_port=");
-    portConfig += portConfigBuf;
-
-    PVMFSMNodeContainer* iSocketNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-    if (iSocketNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFSocketNode* socketNode =
-        (PVMFSocketNode*)(iSocketNodeContainer->iNode);
-    PVMFSMTrackInfoVector::iterator it;
-    uint32 startPortNum = 0;
-    {
-        TimeValue current_time;
-        current_time.set_to_current_time();
-        uint32 my_seed = current_time.get_sec();
-
-        OsclRand random_num;
-        random_num.Seed(my_seed);
-        int32 first = random_num.Rand();
-        uint32 myport = (first & 0x1FFF) + 0x2000;	//start from 8192
-        startPortNum = (myport >> 1) << 1;	//start from even
-    }
-
-    for (it = iTrackInfoVec.begin();
-            it != iTrackInfoVec.end();
-            it++)
-    {
-        OSCL_StackString<128> portConfigWithMime;
-        portConfigWithMime += portConfig;
-        portConfigWithMime += _STRLIT_CHAR(";mime=");
-        portConfigWithMime += it->iMimeType;
-
-        PVMFStatus status = socketNode->AllocateConsecutivePorts(&portConfigWithMime,
-                            it->iRTPSocketID,
-                            it->iRTCPSocketID, startPortNum);
-        if (status != PVMFSuccess)
-        {
-            return false;
-        }
-    }
-    return true;
-}
-
-bool PVMFStreamingManagerNode::RequestNetworkNodePorts(int32 portTag,
-        uint32& numPortsRequested)
-{
-    numPortsRequested = 0;
-
-    PVMFSMNodeContainer* nodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-
-    if (nodeContainer == NULL)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestNetworkNodePorts - getNodeContainer Failed"));
-        return false;
-    }
-
-    for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-    {
-        PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-        if (internalCmd != NULL)
-        {
-            internalCmd->cmd =
-                nodeContainer->commandStartOffset +
-                PVMF_STREAMING_MANAGER_NODE_INTERNAL_REQUEST_PORT_OFFSET;
-            internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION;
-            internalCmd->portContext.trackID = trackInfo.trackID;
-            internalCmd->portContext.portTag = portTag;
-
-            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-            PVMFNodeInterface* iNode = nodeContainer->iNode;
-
-            uint32 sockid = 0;
-            bool oRTCP = false;
-
-            if (portTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
-            {
-                sockid = trackInfo.iRTPSocketID;
-            }
-            else if (portTag == PVMF_SOCKET_NODE_PORT_TYPE_SINK)
-            {
-                sockid = trackInfo.iRTCPSocketID;
-                oRTCP = true;
-            }
-
-            char portConfigBuf[64];
-            oscl_memset((OsclAny*)portConfigBuf, 0, 64);
-            oscl_snprintf(portConfigBuf, 64, "%d", sockid);
-            OSCL_StackString<128> portConfig("UDP");
-            portConfig += _STRLIT_CHAR("/remote_address=0.0.0.0");
-            portConfig += _STRLIT_CHAR(";client_port=");
-            portConfig += portConfigBuf;
-            portConfig += _STRLIT_CHAR(";mime=");
-            portConfig += trackInfo.iMimeType.get_cstr();
-            if (oRTCP == true)
-            {
-                portConfig += _STRLIT_CHAR("/rtp");
-            }
-            else
-            {
-                portConfig += _STRLIT_CHAR("/rtcp");
-            }
-
-            iNode->RequestPort(nodeContainer->iSessionId,
-                               internalCmd->portContext.portTag,
-                               &portConfig,
-                               cmdContextData);
-            numPortsRequested++;
-        }
-        else
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestNetworkNodePorts - RequestNewInternalCmd Failed"));
-            return false;
-        }
-    }
-    return true;
-}
-
-bool PVMFStreamingManagerNode::RequestRTSPNodePorts(int32 portTag,
-        uint32& numPortsRequested)
-{
-    numPortsRequested = 0;
-
-    PVMFSMNodeContainer* nodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-
-    if (nodeContainer == NULL)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestNetworkNodePorts - getNodeContainer Failed"));
-        return false;
-    }
-
-    for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-    {
-        PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-        if (internalCmd != NULL)
-        {
-            internalCmd->cmd =
-                nodeContainer->commandStartOffset +
-                PVMF_STREAMING_MANAGER_NODE_INTERNAL_REQUEST_PORT_OFFSET;
-            internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION;
-            internalCmd->portContext.trackID = trackInfo.trackID;
-            internalCmd->portContext.portTag = portTag;
-
-            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-            PVMFNodeInterface* iNode = nodeContainer->iNode;
-
-            char portConfigBuf[64];
-            oscl_memset((OsclAny*)portConfigBuf, 0, 64);
-            oscl_snprintf(portConfigBuf, 64, "sdpTrackIndex=%d", trackInfo.trackID);
-            OSCL_StackString<128> portConfig;
-            portConfig += portConfigBuf;
-
-            if (portTag == PVMF_RTSP_NODE_PORT_TYPE_OUTPUT)
-            {
-                portConfig += _STRLIT_CHAR("/media");
-            }
-            if (portTag == PVMF_RTSP_NODE_PORT_TYPE_INPUT_OUTPUT)
-            {
-                portConfig += _STRLIT_CHAR("/feedback");
-            }
-
-            iNode->RequestPort(nodeContainer->iSessionId,
-                               internalCmd->portContext.portTag,
-                               &portConfig,
-                               cmdContextData);
-            numPortsRequested++;
-        }
-        else
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestNetworkNodePorts - RequestNewInternalCmd Failed"));
-            return false;
-        }
-    }
-    return true;
-}
-
-bool
-PVMFStreamingManagerNode::RequestJitterBufferPorts(int32 portType,
-        uint32 &numPortsRequested)
-{
-    PVMFSMNodeContainer* nodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-
-    if (nodeContainer == NULL)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestJitterBufferPorts - getNodeContainer Failed"));
-        return false;
-    }
-
-    numPortsRequested = 0;
-    /*
-     * Request port - all jitter buffer input ports
-     * are even numbered and output and rtcp ports are odd numbered
-     */
-    int32 portTagStart = portType;
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-        {
-            PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-            if (internalCmd != NULL)
-            {
-                internalCmd->cmd =
-                    nodeContainer->commandStartOffset +
-                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_REQUEST_PORT_OFFSET;
-                internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION;
-                internalCmd->portContext.trackID = trackInfo.trackID;
-                internalCmd->portContext.portTag = portType;
-
-                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                PVMFNodeInterface* iNode = nodeContainer->iNode;
-
-                OSCL_StackString<32> portConfig = trackInfo.iTransportType;
-                portConfig += _STRLIT_CHAR("/");
-                portConfig += trackInfo.iMimeType;
-                iNode->RequestPort(nodeContainer->iSessionId,
-                                   portTagStart,
-                                   &(portConfig),
-                                   cmdContextData);
-                numPortsRequested++;
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestJitterBufferPorts - RequestNewInternalCmd Failed"));
-                return false;
-            }
-            portTagStart += 3;
-        }
-        return true;
-    }
-    // error
-    return false;
-}
-
-bool
-PVMFStreamingManagerNode::RequestMediaLayerPorts(int32 portType,
-        uint32& numPortsRequested)
-{
-    PVMFSMNodeContainer* nodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-
-    if (nodeContainer == NULL)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestMediaLayerPorts - getNodeContainer Failed"));
-        return false;
-    }
-
-    numPortsRequested = 0;
-    /*
-     * Request port - all media layer input ports
-     * are even numbered and output are odd numbered
-     */
-    int32 portTagStart = portType;
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-        {
-            PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-            if (internalCmd != NULL)
-            {
-                internalCmd->cmd =
-                    nodeContainer->commandStartOffset +
-                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_REQUEST_PORT_OFFSET;
-                internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION;
-                internalCmd->portContext.trackID = trackInfo.trackID;
-                internalCmd->portContext.portTag = portType;
-
-                OsclAny *cmdContextData =
-                    OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                PVMFNodeInterface* iNode = nodeContainer->iNode;
-
-                iNode->RequestPort(nodeContainer->iSessionId,
-                                   portTagStart,
-                                   &(trackInfo.iMimeType),
-                                   cmdContextData);
-                numPortsRequested++;
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:RequestMediaLayerPorts - RequestNewInternalCmd Failed"));
-                return false;
-            }
-            portTagStart += 2;
-        }
-
-        return true;
-    }
-    //error
-    return false;
-}
-
-bool PVMFStreamingManagerNode::ConstructGraphFor3GPPUDPStreaming()
-{
-    uint32 numPortsRequested = 0;
-
-    /*
-     * Reserve UDP socket pairs
-     */
-    if (!ReserveSockets())
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - ReserveSockets() Failed"));
-        return false;
-    }
-
-    /*
-     * Request data UDP ports
-     */
-    if (!RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SOURCE,
-                                 numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SOURCE) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    /*
-     * Request feedback (RTCP) UDP ports
-     */
-    if (!RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SINK,
-                                 numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestNetworkNodePorts(PVMF_SOCKET_NODE_PORT_TYPE_SINK) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT,
-                                  numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT,
-                                  numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK,
-                                  numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT,
-                                numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT,
-                                numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPUDPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    return true;
-}
-
-bool PVMFStreamingManagerNode::ConstructGraphFor3GPPTCPStreaming()
-{
-    uint32 numPortsRequested = 0;
-
-    /*
-     * Request media ports
-     */
-    if (!RequestRTSPNodePorts(PVMF_RTSP_NODE_PORT_TYPE_OUTPUT,
-                              numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestRTSPNodePorts(PVMF_RTSP_NODE_PORT_TYPE_OUTPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    /*
-     * Request feedback (RTCP) ports
-     */
-    if (!RequestRTSPNodePorts(PVMF_RTSP_NODE_PORT_TYPE_INPUT_OUTPUT,
-                              numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestRTSPNodePorts(PVMF_RTSP_NODE_PORT_TYPE_INPUT_OUTPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT,
-                                  numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_INPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT,
-                                  numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_OUTPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK,
-                                  numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestJitterBufferPorts(PVMF_JITTER_BUFFER_PORT_TYPE_FEEDBACK) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT,
-                                numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_INPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    if (!RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT,
-                                numPortsRequested))
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConstructGraphFor3GPPTCPStreaming - RequestMediaLayerPorts(PVMF_MEDIALAYER_PORT_TYPE_OUTPUT) Failed"));
-        return false;
-    }
-    iNumRequestPortsPending += numPortsRequested;
-
-    return true;
-}
-
-
-bool
-PVMFStreamingManagerNode::GraphConstruct()
-{
-    /*
-     * Session source info must have been set
-     */
-    if (iSessionSourceInfo->_sessionType == PVMF_FORMAT_UNKNOWN)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:GraphConstruct - Invalid Session Type"));
-        return false;
-    }
-
-    if (!PopulateTrackInfoVec())
-    {
-        return false;
-    }
-
-    if (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE)
-    {
-    }
-    else if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-             (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        if (iSessionSourceInfo->iRTSPTunnelling == true)
-        {
-            return (ConstructGraphFor3GPPTCPStreaming());
-        }
-        else
-        {
-            return (ConstructGraphFor3GPPUDPStreaming());
-        }
-    }
-    //error
-    return false;
-}
-
-/*
- * Called by the call back routine whenever a "RequestPort" call
- * completes successfully.
- */
-void PVMFStreamingManagerNode::CompleteGraphConstruct()
-{
-    iTotalNumRequestPortsComplete++;
-    /*
-     * Once all port requests are complete, connect the graph
-     */
-    if (iTotalNumRequestPortsComplete == iNumRequestPortsPending)
-    {
-        PVMFStreamingManagerNodeCommand aCmd = iCurrentCommand.front();
-        if (!SendSessionSourceInfoToSessionController())
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:CompleteGraphConstruct - SendSessionSourceInfoToSessionController Failed"));
-            InternalCommandComplete(aCmd, PVMFFailure);
-            iCurrentCommand.Erase(&iCurrentCommand.front());
-        }
-        else
-        {
-            oGraphConstructComplete = true;
-            InternalCommandComplete(aCmd, PVMFSuccess);
-            /* Erase the command from the current queue */
-            iCurrentCommand.Erase(&iCurrentCommand.front());
-        }
-    }
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::ConnectPortPairs(PVMFPortInterface* aPort1,
-        PVMFPortInterface* aPort2)
-{
-    PVMFStatus status;
-
-    status = aPort1->Connect(aPort2);
-
-    if (status != PVMFSuccess)
-    {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:ConnectPortPairs - Connect Failed"));
-        return status;
-    }
-
-    return status;
-}
-
-bool PVMFStreamingManagerNode::GraphConnectFor3GPPUDPStreaming()
-{
-    if (oGraphConnectComplete == false)
-    {
-        /*
-         * Go over the track list and connect:
-         * network_node_port -> jitter_buffer_node_input_port;
-         * jitter_buffer_node_output_port -> media_layer_input_port
-         */
-        PVMFStatus status;
-        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-        {
-            PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-            if ((trackInfo.iNetworkNodePort == NULL) ||
-                    (trackInfo.iNetworkNodeRTCPPort == NULL) ||
-                    (trackInfo.iJitterBufferInputPort == NULL) ||
-                    (trackInfo.iJitterBufferOutputPort == NULL) ||
-                    (trackInfo.iJitterBufferRTCPPort == NULL) ||
-                    (trackInfo.iMediaLayerInputPort == NULL) ||
-                    (trackInfo.iMediaLayerOutputPort == NULL))
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:GraphConnectFor3GPPUDPStreaming - Invalid Ports"));
-                return false;
-            }
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnect - Track MimeType %s", trackInfo.iMimeType.get_cstr()));
-
-            /* connect network_node_port <-> jitter_buffer_node_input_port */
-            status = ConnectPortPairs(trackInfo.iJitterBufferInputPort,
-                                      trackInfo.iNetworkNodePort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - Connected Network - JB Input"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkPort=0x%x - JBInputPort=0x%x", trackInfo.iNetworkNodePort, trackInfo.iJitterBufferInputPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-            /*
-             * connect jitter_buffer_node_output_port <->
-             * media_layer_input_port
-             */
-            status = ConnectPortPairs(trackInfo.iJitterBufferOutputPort,
-                                      trackInfo.iMediaLayerInputPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - JB Output - ML Input"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - JB Output=0x%x - ML Input=0x%x", trackInfo.iJitterBufferOutputPort, trackInfo.iMediaLayerInputPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-            /*
-             * connect network_rtcp_port <-> jitter_buffer_rtcp_port
-             */
-            status = ConnectPortPairs(trackInfo.iJitterBufferRTCPPort,
-                                      trackInfo.iNetworkNodeRTCPPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort - JBRTCPPort"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort=0x%x - JBRTCPPort=0x%x", trackInfo.iNetworkNodeRTCPPort, trackInfo.iJitterBufferRTCPPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-        }
-        oGraphConnectComplete = true;
-    }
-    return true;
-}
-
-bool PVMFStreamingManagerNode::GraphConnectForRTPPacketSource()
-{
-    if (oGraphConnectComplete == false)
-    {
-        /*
-         * Go over the track list and connect:
-         * network_node_port -> jitter_buffer_node_input_port;
-         * jitter_buffer_node_output_port -> media_layer_input_port
-         */
-        PVMFStatus status;
-        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-        {
-            PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-            if ((trackInfo.iNetworkNodePort == NULL) ||
-                    (trackInfo.iJitterBufferInputPort == NULL) ||
-                    (trackInfo.iJitterBufferOutputPort == NULL) ||
-                    (trackInfo.iMediaLayerInputPort == NULL) ||
-                    (trackInfo.iMediaLayerOutputPort == NULL))
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:GraphConnectForRTPPacketSource - Invalid Ports"));
-                return false;
-            }
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnect - Track MimeType %s", trackInfo.iMimeType.get_cstr()));
-
-            /* connect network_node_port <-> jitter_buffer_node_input_port */
-            status = ConnectPortPairs(trackInfo.iJitterBufferInputPort,
-                                      trackInfo.iNetworkNodePort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectForRTPPacketSource - Connected Network - JB Input"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectForRTPPacketSource - NetworkPort=0x%x - JBInputPort=0x%x", trackInfo.iNetworkNodePort, trackInfo.iJitterBufferInputPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-            /*
-             * connect jitter_buffer_node_output_port <->
-             * media_layer_input_port
-             */
-            status = ConnectPortPairs(trackInfo.iJitterBufferOutputPort,
-                                      trackInfo.iMediaLayerInputPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectForRTPPacketSource - JB Output - ML Input"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectForRTPPacketSource - JB Output=0x%x - ML Input=0x%x", trackInfo.iJitterBufferOutputPort, trackInfo.iMediaLayerInputPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-            /*
-             * connect network_rtcp_port <-> jitter_buffer_rtcp_port
-             */
-            status = ConnectPortPairs(trackInfo.iJitterBufferRTCPPort,
-                                      trackInfo.iNetworkNodeRTCPPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort - JBRTCPPort"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPUDPStreaming - NetworkRTCPPort=0x%x - JBRTCPPort=0x%x", trackInfo.iNetworkNodeRTCPPort, trackInfo.iJitterBufferRTCPPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-        }
-        oGraphConnectComplete = true;
-    }
-    return true;
-}
-
-
-bool PVMFStreamingManagerNode::GraphConnectFor3GPPTCPStreaming()
-{
-    if (oGraphConnectComplete == false)
-    {
-        /*
-         * Go over the track list and connect:
-         * network_node_port -> jitter_buffer_node_input_port;
-         * jitter_buffer_node_output_port -> media_layer_input_port
-         */
-        PVMFStatus status;
-        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-        {
-            PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-            if ((trackInfo.iSessionControllerOutputPort == NULL) ||
-                    (trackInfo.iSessionControllerFeedbackPort == NULL) ||
-                    (trackInfo.iJitterBufferInputPort == NULL) ||
-                    (trackInfo.iJitterBufferOutputPort == NULL) ||
-                    (trackInfo.iJitterBufferRTCPPort == NULL) ||
-                    (trackInfo.iMediaLayerInputPort == NULL) ||
-                    (trackInfo.iMediaLayerOutputPort == NULL))
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:GraphConnectFor3GPPTCPStreaming - Invalid Ports"));
-                return false;
-            }
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - Track MimeType %s", trackInfo.iMimeType.get_cstr()));
-
-            /* connect sessioncontroller_node_output_port <-> jitter_buffer_node_input_port */
-            status = ConnectPortPairs(trackInfo.iJitterBufferInputPort,
-                                      trackInfo.iSessionControllerOutputPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - Connected SessionController Output - JB Input"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - SessionControllerPort=0x%x - JBInputPort=0x%x", trackInfo.iSessionControllerOutputPort, trackInfo.iJitterBufferInputPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-            /*
-             * connect jitter_buffer_node_output_port <->
-             * media_layer_input_port
-             */
-            status = ConnectPortPairs(trackInfo.iJitterBufferOutputPort,
-                                      trackInfo.iMediaLayerInputPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - JB Output - ML Input"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - JB Output=0x%x - ML Input=0x%x", trackInfo.iJitterBufferOutputPort, trackInfo.iMediaLayerInputPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-
-            /*
-             * connect sessioncontroller_node_feedback_port <-> jitter_buffer_rtcp_port
-             */
-            status = ConnectPortPairs(trackInfo.iJitterBufferRTCPPort,
-                                      trackInfo.iSessionControllerFeedbackPort);
-
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - SessionControllerFeedbackPort - JBRTCPPort"));
-            PVMF_SM_LOGINFO((0, "PVMFSM:GraphConnectFor3GPPTCPStreaming - SessionControllerFeedbackPort=0x%x - JBRTCPPort=0x%x", trackInfo.iSessionControllerFeedbackPort, trackInfo.iJitterBufferRTCPPort));
-
-            if (status != PVMFSuccess)
-            {
-                return false;
-            }
-        }
-        oGraphConnectComplete = true;
-    }
-    return true;
-}
-
-
-/*
- * Called by command handler AO once all request ports are complete
- */
-bool PVMFStreamingManagerNode::GraphConnect()
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        if (iSessionSourceInfo->iRTSPTunnelling == true)
-        {
-            return (GraphConnectFor3GPPTCPStreaming());
-        }
-        else
-        {
-            return (GraphConnectFor3GPPUDPStreaming());
-        }
-    }
-    else if (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE)
-    {
-        return (GraphConnectForRTPPacketSource());
-    }
-
-    //error
-    return false;
-}
-
-
-/*
- * Called when all port requests are complete, in order to send the
- * UDP port information to RTSP
- */
-bool
-PVMFStreamingManagerNode::SendSessionSourceInfoToSessionController()
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        PVMFSMNodeContainer* iSocketNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-        if (iSocketNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-        PVMFSocketNode* socketNode =
-            (PVMFSocketNode*)(iSocketNodeContainer->iNode);
-
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
-
-        for (uint32 i = 0; i < iTrackInfoVec.size(); i++)
-        {
-            PVMFSMTrackInfo trackInfo = iTrackInfoVec[i];
-
-            OsclNetworkAddress localAdd;
-            OsclNetworkAddress remoteAdd;
-            StreamInfo sInfo;
-
-            sInfo.iSDPStreamId = trackInfo.trackID;
-
-            if (iSessionSourceInfo->iRTSPTunnelling == false)
-            {
-                if (trackInfo.iNetworkNodePort == NULL)
-                {
-                    PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendSessionSourceInfoToSessionController - Invalid Port"));
-                    return false;
-                }
-
-                socketNode->GetPortConfig(*trackInfo.iNetworkNodePort,
-                                          localAdd,
-                                          remoteAdd);
-
-                sInfo.iCliRTPPort = localAdd.port;
-
-                socketNode->GetPortConfig(*trackInfo.iNetworkNodeRTCPPort,
-                                          localAdd,
-                                          remoteAdd);
-
-                sInfo.iCliRTCPPort = localAdd.port;
-            }
-
-            /* Set Rate Adaptation parameters */
-            sInfo.b3gppAdaptationIsSet = false;
-            if (trackInfo.iRateAdaptation)
-            {
-                sInfo.b3gppAdaptationIsSet = true;
-                /* Compute buffer size based on bitrate and jitter duration*/
-                uint32 sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
-                if (((int32)iJitterBufferDurationInMilliSeconds > 0) &&
-                        ((int32)trackInfo.bitRate > 0))
-                {
-                    uint32 byteRate = trackInfo.bitRate / 8;
-                    uint32 overhead = (byteRate * PVMF_JITTER_BUFFER_NODE_MEM_POOL_OVERHEAD) / 100;
-                    uint32 durationInSec = iJitterBufferDurationInMilliSeconds / 1000;
-                    sizeInBytes = ((byteRate + overhead) * durationInSec);
-                    if (sizeInBytes < MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES)
-                    {
-                        sizeInBytes = MIN_RTP_SOCKET_MEM_POOL_SIZE_IN_BYTES;
-                    }
-                    sizeInBytes += 2 * MAX_SOCKET_BUFFER_SIZE;
-                }
-                sInfo.iBufSize = sizeInBytes;
-                sInfo.iTargetTime = iJitterBufferDurationInMilliSeconds;
-            }
-            aSelectedStream.push_back(sInfo);
-        }
-
-        if (rtspExtIntf->SetSDPInfo(iSessionSourceInfo->_sdpInfo,
-                                    aSelectedStream) != PVMFSuccess)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendSessionSourceInfoToSessionController - SetSDPInfo Failed"));
-            return false;
-        }
-
-        /* Set play range from SDP */
-        sessionDescription* sessionInfo = iSessionSourceInfo->_sdpInfo->getSessionInfo();
-        RtspRangeType *rtspRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
-        rtspRange->convertToMilliSec((int32&)iSessionStartTime, (int32&)iSessionStopTime);
-
-        if (rtspRange->end_is_set == false)
-        {
-            iSessionStopTime = -1;
-            iSessionStopTimeAvailable = false;
-        }
-
-        if ((rtspRange->format != RtspRangeType::INVALID_RANGE) &&
-                (rtspRange->start_is_set != false))
-        {
-            if (rtspExtIntf->SetRequestPlayRange(*rtspRange) != PVMFSuccess)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendRequestPlayRangeToSessionController - SetRequestPlayRange Failed"));
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-bool
-PVMFStreamingManagerNode::SendSessionControlPrepareCompleteParams()
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        PVMFSMNodeContainer* iJitterBufferNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFJitterBufferExtensionInterface* jbExtIntf =
-            (PVMFJitterBufferExtensionInterface*)
-            (iJitterBufferNodeContainer->iExtensions[0]);
-
-        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
-
-        if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
-        {
-            OSCL_LEAVE(OsclErrGeneral);
-        }
-
-        for (uint32 i = 0; i < aSelectedStream.size(); i++)
-        {
-            StreamInfo streamInfo = aSelectedStream[i];
-
-            PVMFSMTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
-
-            if (trackInfo == NULL)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendSessionControlPrepareCompleteParams - FindTrackInfo Failed"));
-                return false;
-            }
-
-            if (trackInfo->iJitterBufferInputPort == NULL)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendSessionControlPrepareCompleteParams - Invalid Port"));
-                return false;
-            }
-
-            if (streamInfo.ssrcIsSet)
-            {
-                jbExtIntf->setPortSSRC(trackInfo->iJitterBufferInputPort,
-                                       streamInfo.iSSRC);
-            }
-        }
-
-        /* Set server info */
-        PVRTSPEngineNodeServerInfo rtspServerInfo;
-        PVMFJitterBufferFireWallPacketInfo fireWallPktInfo;
-
-        rtspExtIntf->GetServerInfo(rtspServerInfo);
-
-        if (rtspServerInfo.iIsPVServer)
-        {
-            fireWallPktInfo.iFormat = PVMF_JB_FW_PKT_FORMAT_PV;
-        }
-        fireWallPktInfo.iServerRoundTripDelayInMS = rtspServerInfo.iRoundTripDelayInMS;
-        fireWallPktInfo.iNumAttempts = PVMF_JITTER_BUFFER_NODE_DEFAULT_FIREWALL_PKT_ATTEMPTS;
-
-        jbExtIntf->setServerInfo(fireWallPktInfo);
-    }
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL))
-    {
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        PVMFSMNodeContainer* iJitterBufferNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-        if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVMFJitterBufferExtensionInterface* jbExtIntf =
-            (PVMFJitterBufferExtensionInterface*)
-            (iJitterBufferNodeContainer->iExtensions[0]);
-
-    }
-    return true;
-}
-
-bool
-PVMFStreamingManagerNode::SendSessionControlStartCompleteParams()
-{
-    PVMFSMNodeContainer* iJitterBufferNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFJitterBufferExtensionInterface* jbExtIntf =
-        (PVMFJitterBufferExtensionInterface*)
-        (iJitterBufferNodeContainer->iExtensions[0]);
-
-    PVMFSMNodeContainer* iMediaLayerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-    if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-        (PVMFMediaLayerNodeExtensionInterface*)
-        (iMediaLayerNodeContainer->iExtensions[0]);
-
-    bool end_is_set = true;
-    int32 startTime = 0;
-    int32 stopTime  = 0;
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        /* Get Actual Play Range */
-        RtspRangeType rangeType;
-        if (rtspExtIntf->GetActualPlayRange(rangeType) != PVMFSuccess)
-        {
-            return false;
-        }
-
-        rangeType.convertToMilliSec(startTime, stopTime);
-
-        /* Use from SDP if not set */
-        end_is_set = rangeType.end_is_set;
-        if (end_is_set == false)
-        {
-            stopTime = iSessionStopTime;
-        }
-
-        if (oRepositioning)
-        {
-            iActualRepositionStartNPTInMS = startTime;
-            if (iActualRepositionStartNPTInMSPtr != NULL)
-            {
-                *iActualRepositionStartNPTInMSPtr = startTime;
-            }
-            if (iPVMFDataSourcePositionParamsPtr != NULL)
-            {
-                iPVMFDataSourcePositionParamsPtr->iActualNPT = startTime;
-            }
-        }
-
-        Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
-
-        if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
-        {
-            OSCL_LEAVE(OsclErrGeneral);
-        }
-
-        for (uint32 i = 0; i < aSelectedStream.size(); i++)
-        {
-            StreamInfo streamInfo = aSelectedStream[i];
-
-            PVMFSMTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
-
-            if (trackInfo == NULL)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendStartCompleteSessionControlParams - FindTrackInfo Failed"));
-                return false;
-            }
-
-            if (trackInfo->iJitterBufferInputPort == NULL)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:SendStartCompleteSessionControlParams - Invalid Port"));
-                return false;
-            }
-
-            if (streamInfo.seqIsSet != true)
-            {
-                streamInfo.seqIsSet = false;
-                streamInfo.seq = 0;
-            }
-            if (streamInfo.rtptimeIsSet != true)
-            {
-                streamInfo.rtptimeIsSet = false;
-                streamInfo.rtptime = 0;
-            }
-            jbExtIntf->setPortRTPParams(trackInfo->iJitterBufferInputPort,
-                                        streamInfo.seqIsSet,
-                                        streamInfo.seq,
-                                        streamInfo.rtptimeIsSet,
-                                        streamInfo.rtptime,
-                                        startTime,
-                                        oRepositioning);
-
-        }
-    }
-    /* Send actual stop time to Jitter Buffer */
-    if (jbExtIntf->setPlayRange(startTime,
-                                stopTime,
-                                oRepositioning,
-                                end_is_set) != true)
-    {
-        return false;
-    }
-
-    if (mlExtIntf->setPlayRange(startTime, stopTime) != true)
-    {
-        return false;
-    }
-    return true;
-}
-
-bool
-PVMFStreamingManagerNode::SendPacketSourceStartCompleteParams()
-{
-    PVMFSMNodeContainer* iJitterBufferNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFJitterBufferExtensionInterface* jbExtIntf =
-        (PVMFJitterBufferExtensionInterface*)
-        (iJitterBufferNodeContainer->iExtensions[0]);
-
-    PVMFSMNodeContainer* iMediaLayerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-    if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-        (PVMFMediaLayerNodeExtensionInterface*)
-        (iMediaLayerNodeContainer->iExtensions[0]);
-
-    bool end_is_set = true;
-    int32 startTime = 0;
-    int32 stopTime  = 0;
-
-    /* Get Actual Play Range */
-    RtspRangeType rangeType;
-    rangeType.convertToMilliSec(startTime, stopTime);
-
-    /* Use from SDP if not set */
-    end_is_set = false;
-    stopTime = -1;
-
-    PVMFSMTrackInfoVector::iterator it;
-
-    for (it = iTrackInfoVec.begin();
-            it != iTrackInfoVec.end();
-            it++)
-    {
-        StreamInfo streamInfo;
-
-        streamInfo.seqIsSet = false;
-        streamInfo.seq = 0;
-
-        streamInfo.rtptimeIsSet = false;
-        streamInfo.rtptime = 0;
-        jbExtIntf->setPortRTPParams(it->iJitterBufferInputPort,
-                                    streamInfo.seqIsSet,
-                                    streamInfo.seq,
-                                    streamInfo.rtptimeIsSet,
-                                    streamInfo.rtptime,
-                                    startTime,
-                                    oRepositioning);
-
-    }
-
-    /* Send actual stop time to Jitter Buffer */
-    if (jbExtIntf->setPlayRange(startTime, stopTime, false, end_is_set) != true)
-    {
-        return false;
-    }
-
-    if (mlExtIntf->setPlayRange(startTime, stopTime) != true)
-    {
-        return false;
-    }
-    return true;
-}
-
-
-bool
-PVMFStreamingManagerNode::CompleteFeedBackPortsSetup()
-{
-    PVMFSMNodeContainer* iSocketNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-    if (iSocketNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVMFSocketNode* socketNode =
-        (PVMFSocketNode*)(iSocketNodeContainer->iNode);
-
-    PVMFSMNodeContainer* iSessionControllerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-
-    if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-        (PVRTSPEngineNodeExtensionInterface*)
-        (iSessionControllerNodeContainer->iExtensions[0]);
-
-    Oscl_Vector<StreamInfo, OsclMemAllocator> aSelectedStream;
-
-    if (rtspExtIntf->GetStreamInfo(aSelectedStream) != PVMFSuccess)
-    {
-        OSCL_LEAVE(OsclErrGeneral);
-    }
-
-    for (uint32 i = 0; i < aSelectedStream.size(); i++)
-    {
-        StreamInfo streamInfo = aSelectedStream[i];
-
-        PVMFSMTrackInfo* trackInfo = FindTrackInfo(streamInfo.iSDPStreamId);
-
-        if (trackInfo == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - FindTrackInfo Failed"));
-            return false;
-        }
-
-        if (trackInfo->iNetworkNodeRTCPPort == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - Invalid RTCP Port"));
-            return false;
-        }
-
-        OsclNetworkAddress localAddRTCP;
-        OsclNetworkAddress remoteAddRTCP;
-
-        localAddRTCP.port = streamInfo.iCliRTCPPort;
-        remoteAddRTCP.port = streamInfo.iSerRTCPPort;
-        remoteAddRTCP.ipAddr = streamInfo.iSerIpAddr;
-
-        socketNode->SetPortConfig(*(trackInfo->iNetworkNodeRTCPPort),
-                                  localAddRTCP,
-                                  remoteAddRTCP);
-
-        if (trackInfo->iNetworkNodePort == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:CompleteFeedBackPortsSetup - Invalid RTP Port"));
-            return false;
-        }
-
-        OsclNetworkAddress localAddRTP;
-        OsclNetworkAddress remoteAddRTP;
-
-        localAddRTP.port = streamInfo.iCliRTPPort;
-        remoteAddRTP.port = streamInfo.iSerRTPPort;
-        remoteAddRTP.ipAddr = streamInfo.iSerIpAddr;
-
-        socketNode->SetPortConfig(*(trackInfo->iNetworkNodePort),
-                                  localAddRTP,
-                                  remoteAddRTP);
-
-    }
-
-    return true;
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::DeleteUnusedSessionControllerNode()
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        /* Delete HTTP PE Node */
-        PVMFSMNodeContainerVector::iterator it;
-        for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-        {
-            if (it->iNodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE)
-            {
-                for (uint32 j = 0; j < it->iExtensions.size(); j++)
-                {
-                    PVInterface* extIntf = it->iExtensions[j];
-                    extIntf->removeRef();
-                }
-                PVMFProtocolEngineNodeFactory::DeletePVMFProtocolEngineNode(it->iNode);
-                it->iNode = NULL;
-                iNodeContainerVec.erase(it);
-                break;
-            }
-        }
-    }
-    DeleteUnusedNodes();
-
-    return PVMFSuccess;
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::DeleteUnusedNodes()
-{
-    if (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE)
-    {
-        PVMFSMNodeContainerVector::iterator it;
-        for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-        {
-            /* Delete Unused Socket Node */
-            if (it->iNodeTag == PVMF_STREAMING_MANAGER_SOCKET_NODE)
-            {
-                for (uint32 j = 0; j < it->iExtensions.size(); j++)
-                {
-                    PVInterface* extIntf = it->iExtensions[j];
-                    extIntf->removeRef();
-                }
-                PVMF_STREAMING_MANAGER_DELETE(NULL,
-                                              PVMFSocketNode,
-                                              ((PVMFSocketNode*)(it->iNode)));
-                it->iNode = NULL;
-                iNodeContainerVec.erase(it);
-                break;
-            }
-        }
-        for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-        {
-            /* Delete Unused RTSP Session Controller Node */
-            if (it->iNodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE)
-            {
-                for (uint32 j = 0; j < it->iExtensions.size(); j++)
-                {
-                    PVInterface* extIntf = it->iExtensions[j];
-                    extIntf->removeRef();
-                }
-                PVMFRrtspEngineNodeFactory::DeletePVMFRtspEngineNode(it->iNode);
-                it->iNode = NULL;
-                iNodeContainerVec.erase(it);
-                break;
-            }
-        }
-        for (it = iNodeContainerVec.begin(); it != iNodeContainerVec.end(); it++)
-        {
-            /* Delete Unused HTTP Session Controller Node */
-            if (it->iNodeTag == PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE)
-            {
-                for (uint32 j = 0; j < it->iExtensions.size(); j++)
-                {
-                    PVInterface* extIntf = it->iExtensions[j];
-                    extIntf->removeRef();
-                }
-                PVMFProtocolEngineNodeFactory::DeletePVMFProtocolEngineNode(it->iNode);
-                it->iNode = NULL;
-                iNodeContainerVec.erase(it);
-                break;
-            }
-        }
-    }
-    else
-    {
-    }
-    return PVMFSuccess;
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::setSessionSourceInfo(OSCL_wString& aSourceURL,
-        PVMFFormatType aSourceFormatType,
-        OsclAny* aSourceData)
-{
-
-    if (((aSourceFormatType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (aSourceFormatType == PVMF_DATA_SOURCE_SDP_FILE)) && (aSourceData != NULL))
-    {
-        PVInterface* pvInterface = OSCL_STATIC_CAST(PVInterface*, aSourceData);
-
-        PVInterface* sourceDataContext = NULL;
-        PVUuid sourceContextUuid(PVMF_SOURCE_CONTEXT_DATA_UUID);
-        if (pvInterface->queryInterface(sourceContextUuid, sourceDataContext))
-        {
-            if (sourceDataContext)
-            {
-                PVInterface* streamingDataContext = NULL;
-                PVUuid streamingContextUuid(PVMF_SOURCE_CONTEXT_DATA_STREAMING_UUID);
-
-                if (sourceDataContext->queryInterface(streamingContextUuid, streamingDataContext))
-                {
-                    if (streamingDataContext)
-                    {
-                        PVMFSourceContextDataStreaming* sContext =
-                            OSCL_STATIC_CAST(PVMFSourceContextDataStreaming*, streamingDataContext);
-                        if (sContext->iProxyName.get_size() > 0)
-                        {
-                            PVMFSMNodeContainer* iSessionControllerNodeContainer = NULL;
-                            iSessionControllerNodeContainer = getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                            if (iSessionControllerNodeContainer)
-                            {
-                                PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                                    (PVRTSPEngineNodeExtensionInterface*)(iSessionControllerNodeContainer->iExtensions[0]);
-                                if (rtspExtIntf)
-                                {//the proxyname doesn't need to be unicode
-                                    OsclMemAllocator alloc;
-                                    char *buf = (char*)alloc.allocate(sContext->iProxyName.get_size() + 1);
-                                    if (!buf)
-                                        return PVMFErrNoMemory;
-                                    uint32 size = oscl_UnicodeToUTF8(sContext->iProxyName.get_cstr(), sContext->iProxyName.get_size(), buf, sContext->iProxyName.get_size() + 1);
-                                    if (size == 0)
-                                    {
-                                        alloc.deallocate(buf);
-                                        return PVMFErrNoMemory;
-                                    }
-
-                                    OSCL_FastString myProxyName(buf, size);
-
-                                    rtspExtIntf->SetRtspProxy(myProxyName, sContext->iProxyPort);
-                                    alloc.deallocate(buf);
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    if ((aSourceFormatType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (aSourceFormatType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL))
-    {
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        OSCL_wStackString<8> rtspScheme(_STRLIT_WCHAR("rtsp"));
-        OSCL_wStackString<8> rtsptScheme(_STRLIT_WCHAR("rtspt"));
-        OSCL_wStackString<8> schemeDelimiter(_STRLIT_WCHAR("://"));
-        oscl_wchar* actualURL = NULL;
-        if (oscl_strncmp(rtsptScheme.get_cstr(), aSourceURL.get_cstr(), 5) == 0)
-        {
-            iSessionSourceInfo->iRTSPTunnelling = true;
-            actualURL = oscl_strstr(aSourceURL.get_cstr(), schemeDelimiter.get_cstr());
-            if (actualURL == NULL)
-            {
-                return PVMFErrArgument;
-            }
-            //skip over ://
-            actualURL += schemeDelimiter.get_size();
-            iSessionSourceInfo->_sessionType = aSourceFormatType;
-            iSessionSourceInfo->_sessionURL  += rtspScheme.get_str();
-            iSessionSourceInfo->_sessionURL  += schemeDelimiter.get_str();
-            iSessionSourceInfo->_sessionURL  += actualURL;
-        }
-        else
-        {
-            iSessionSourceInfo->_sessionType = aSourceFormatType;
-            iSessionSourceInfo->_sessionURL  = aSourceURL;
-        }
-
-        if (iSessionSourceInfo->iRTSPTunnelling == true)
-        {
-            rtspExtIntf->SetStreamingType(PVRTSP_3GPP_TCP);
-        }
-        else
-        {
-            /* default to UDP */
-            rtspExtIntf->SetStreamingType(PVRTSP_3GPP_UDP);
-        }
-
-        return (rtspExtIntf->SetSessionURL(iSessionSourceInfo->_sessionURL));
-    }
-    else if (aSourceFormatType == PVMF_DATA_SOURCE_SDP_FILE)
-    {
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        iSessionSourceInfo->_sessionType = aSourceFormatType;
-        iSessionSourceInfo->_sessionURL  = aSourceURL;
-
-        rtspExtIntf->SetStreamingType(PVRTSP_3GPP_UDP);
-
-        return PVMFSuccess;
-    }
-    else if (aSourceFormatType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE)
-    {
-        iSessionSourceInfo->_sessionType = aSourceFormatType;
-        iSessionSourceInfo->_sessionURL  = aSourceURL;
-        return PVMFSuccess;
-    }
-    return PVMFErrNotSupported;
-}
-
-PVMFStatus PVMFStreamingManagerNode::ProcessSDP()
-{
-    PVMFStatus status;
-    OsclRefCounterMemFrag iSDPText;
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL))
-    {
-        PVMFSMNodeContainer* iSessionControllerNodeContainer =
-            getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-
-        if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-        PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-            (PVRTSPEngineNodeExtensionInterface*)
-            (iSessionControllerNodeContainer->iExtensions[0]);
-
-        status = rtspExtIntf->GetSDP(iSDPText);
-
-        if (status != PVMFSuccess)
-        {
-            return status;
-        }
-    }
-    else if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-             (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        /* Parse SDP file contents into a buffer */
-        Oscl_FileServer fileServ;
-        Oscl_File osclFile;
-        fileServ.Connect();
-
-        if (osclFile.Open(iSessionSourceInfo->_sessionURL.get_cstr(),
-                          Oscl_File::MODE_READ,
-                          fileServ) != 0)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Unable to open SDP file"));
-            return PVMFFailure;
-        }
-
-        /* Get File Size */
-        osclFile.Seek(0, Oscl_File::SEEKEND);
-        int32 fileSize = osclFile.Tell();
-        osclFile.Seek(0, Oscl_File::SEEKSET);
-
-        if (fileSize <= 0)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Corrupt SDP file"));
-            return PVMFFailure;
-        }
-
-        OsclMemAllocDestructDealloc<uint8> my_alloc;
-        OsclRefCounter* my_refcnt;
-        uint aligned_refcnt_size =
-            oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
-        uint8* my_ptr = NULL;
-        int32 errcode = 0;
-        /*
-         * To acct for null char, as SDP buffer is treated akin to a string by the
-         * SDP parser lib.
-         */
-        uint allocsize = oscl_mem_aligned_size(aligned_refcnt_size + fileSize + 2);
-        OSCL_TRY(errcode, my_ptr = (uint8*) my_alloc.ALLOCATE(allocsize));
-
-        if (errcode != OsclErrNone)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:ProcessSDP - Unable to process SDP file"));
-            return PVMFFailure;
-        }
-
-        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
-        my_ptr += aligned_refcnt_size;
-
-        OsclMemoryFragment memfrag;
-        memfrag.len = fileSize;
-        memfrag.ptr = my_ptr;
-
-        OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
-        iSDPText = tmpRefcntMemFrag;
-
-        osclFile.Read(memfrag.ptr, 1, fileSize);
-
-        osclFile.Close();
-        fileServ.Close();
-
-    }
-
-    PVMFSMSharedPtrAlloc<SDPInfo> sdpAlloc;
-    SDPInfo* sdpInfo = sdpAlloc.allocate();
-
-    SDP_Parser *sdpParser;
-
-    PVMF_STREAMING_MANAGER_NEW(NULL, SDP_Parser, (), sdpParser);
-
-    int32 sdpRetVal =
-        sdpParser->parseSDP((const char*)(iSDPText.getMemFragPtr()),
-                            iSDPText.getMemFragSize(),
-                            sdpInfo);
-
-    // save the SDP file name - the packet source node will need this
-    sdpInfo->setSDPFilename(iSessionSourceInfo->_sessionURL);
-
-    PVMF_STREAMING_MANAGER_DELETE(NULL, SDP_Parser, sdpParser);
-
-    OsclRefCounterSA< PVMFSMSharedPtrAlloc<SDPInfo> > *refcnt =
-        new OsclRefCounterSA< PVMFSMSharedPtrAlloc<SDPInfo> >(sdpInfo);
-
-    OsclSharedPtr<SDPInfo> sharedSDPInfo(sdpInfo, refcnt);
-
-    if (sdpRetVal != SDP_SUCCESS)
-    {
-        return PVMFFailure;
-    }
-
-    iSessionSourceInfo->_sdpInfo = sharedSDPInfo;
-
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::RecognizeAndProcessHeader()
-{
-    OSCL_ASSERT(iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL);
-
-    return Asf_RecognizeAndProcessHeader();
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo)
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        SDPInfo* sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-
-        /* Get SDP Session Info */
-        sessionDescription* sessionInfo = sdpInfo->getSessionInfo();
-
-        RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
-
-        int32 sessionStartTime = 0, sessionStopTime = 0;
-
-        sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
-
-        int32 duration_msec = (sessionStopTime - sessionStartTime);
-
-        uint64 duration64;
-        Oscl_Int64_Utils::set_uint64(duration64, 0, (uint32)duration_msec);
-
-        if (sessionRange->end_is_set == true)
-        {
-            aInfo.setDurationValue(duration64);
-            aInfo.setDurationTimeScale(1000);
-        }
-        else
-        {
-            aInfo.SetDurationAvailable(false);
-        }
-
-        aInfo.setSeekableFlag((!(sessionInfo->getRandomAccessDenied())));
-
-        int32 numTracks = sdpInfo->getNumMediaObjects();
-
-        SDPAltGroupType sdpAltGroupType = sessionInfo->getSDPAltGroupType();
-
-        PVMF_TRACK_INFO_TRACK_ALTERNATE_TYPE iAltType = PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED;
-
-        if (sdpAltGroupType == SDP_ALT_GROUP_LANGUAGE)
-        {
-            iAltType = PVMF_TRACK_ALTERNATE_TYPE_LANGUAGE;
-        }
-        else if (sdpAltGroupType == SDP_ALT_GROUP_BANDWIDTH)
-        {
-            iAltType = PVMF_TRACK_ALTERNATE_TYPE_BANDWIDTH;
-        }
-
-        for (int32 i = 0; i < numTracks; i++)
-        {
-            /*
-             * Get the vector of mediaInfo as there can
-             * alternates for each track
-             */
-            Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec =
-                sdpInfo->getMediaInfo(i);
-
-            uint32 minfoVecLen = mediaInfoVec.size();
-
-            for (uint32 j = 0; j < minfoVecLen; j++)
-            {
-                mediaInfo* mInfo = mediaInfoVec[j];
-
-                if (mInfo == NULL)
-                {
-                    return PVMFFailure;
-                }
-
-                RtspRangeType *mediaRange = mInfo->getRtspRange();
-
-                int32 mediaStartTime = 0, mediaStopTime = 0;
-
-                mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
-                int32 mediaDuration_ms = mediaStopTime - mediaStartTime;
-                uint64 mediaDuration64;
-                Oscl_Int64_Utils::set_uint64(mediaDuration64, 0, (uint32)mediaDuration_ms);
-
-                PVMFTrackInfo trackInfo;
-
-                Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
-                payloadVector = mInfo->getPayloadSpecificInfoVector();
-
-                if (payloadVector.size() == 0)
-                {
-                    return false;
-                }
-                /*
-                 * There can be multiple payloads per media segment.
-                 * We only support one for now, so
-                 * use just the first payload
-                 */
-                PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
-
-                // set config for later
-                int32 configSize = payloadInfo->configSize;
-                OsclAny* config = payloadInfo->configHeader.GetRep();
-
-                OSCL_StackString<256> mimeString;
-                const char* mimeType = mInfo->getMIMEType();
-                {
-                    mimeString += mimeType;
-                }
-                trackInfo.setTrackMimeType(mimeString);
-
-                uint32 trackID = mInfo->getMediaInfoID();
-
-                trackInfo.setTrackID(trackID);
-                trackInfo.setPortTag(trackID);
-
-                trackInfo.setTrackBitRate(mInfo->getBitrate());
-
-                if (mediaRange->end_is_set == true)
-                {
-                    trackInfo.setTrackDurationValue(mediaDuration64);
-                }
-                else
-                {
-                    trackInfo.SetDurationAvailable(false);
-                }
-
-                if ((configSize > 0) && (config != NULL))
-                {
-                    OsclMemAllocDestructDealloc<uint8> my_alloc;
-                    OsclRefCounter* my_refcnt;
-                    uint aligned_refcnt_size =
-                        oscl_mem_aligned_size(sizeof(OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >));
-
-                    uint8* my_ptr = NULL;
-                    int32 errcode = 0;
-                    OSCL_TRY(errcode, my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size + configSize));
-
-                    my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA< OsclMemAllocDestructDealloc<uint8> >(my_ptr));
-                    my_ptr += aligned_refcnt_size;
-
-                    OsclMemoryFragment memfrag;
-                    memfrag.len = (uint32)configSize;
-                    memfrag.ptr = my_ptr;
-
-                    oscl_memcpy((void*)(memfrag.ptr), (const void*)config, memfrag.len);
-
-                    OsclRefCounterMemFrag tmpRefcntMemFrag(memfrag, my_refcnt, memfrag.len);
-                    trackInfo.setTrackConfigInfo(tmpRefcntMemFrag);
-                }
-
-                int32 dependsOnTrackID = mInfo->getDependsOnTrackID();
-
-                if (dependsOnTrackID != -1)
-                {
-                    trackInfo.setDependsOn();
-                    mediaInfo* baseMediaInfo = sdpInfo->getMediaInfoBasedOnDependsOnID(dependsOnTrackID);
-                    if (baseMediaInfo == NULL)
-                    {
-                        return PVMFFailure;
-                    }
-                    trackInfo.addDependsOnTrackID(baseMediaInfo->getMediaInfoID());
-                }
-
-                if (iAltType != PVMF_TRACK_ALTERNATE_TYPE_UNDEFINED)
-                {
-                    /* Expose alternate track ids */
-                    trackInfo.setTrackAlternates(iAltType);
-                    for (uint32 k = 0; k < minfoVecLen; k++)
-                    {
-                        mediaInfo* mInfo = mediaInfoVec[k];
-                        if (mInfo == NULL)
-                        {
-                            return PVMFFailure;
-                        }
-                        uint32 altID = mInfo->getMediaInfoID();
-                        if (altID != trackID)
-                        {
-                            trackInfo.addAlternateTrackID((int32)altID);
-                        }
-                    }
-                }
-                aInfo.addTrackInfo(trackInfo);
-            }
-        }
-        iCompleteMediaPresetationInfo = aInfo;
-        return PVMFSuccess;
-    }
-    return PVMFErrNotSupported;
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::SelectTracks(PVMFMediaPresentationInfo& aInfo,
-                                       PVMFSessionId s)
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        SDPInfo* sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-        if (sdpInfo == NULL)
-        {
-            PVMF_SM_LOGERROR((0, "StreamingManagerNode:SelectTracks - SDP Not Available"));
-            return PVMFErrArgument;
-        }
-
-        int32 numTracks = aInfo.getNumTracks();
-
-        for (int32 i = 0; i < numTracks; i++)
-        {
-            PVMFTrackInfo* trackInfo = aInfo.getTrackInfo(i);
-
-            uint32 trackID = trackInfo->getTrackID();
-
-            mediaInfo* mInfo =
-                sdpInfo->getMediaInfoBasedOnID(trackID);
-
-            if (mInfo == NULL)
-            {
-                PVMF_SM_LOGERROR((0, "StreamingManagerNode:SelectTracks - Invalid SDP TrackID"));
-                return PVMFErrArgument;
-            }
-
-            mInfo->setSelect();
-
-            /* Set selected field in meta info */
-            Oscl_Vector<PVMFSMTrackMetaDataInfo, PVMFStreamingManagerNodeAllocator>::iterator it;
-            for (it = iMetaDataInfo.iTrackMetaDataInfoVec.begin(); it != iMetaDataInfo.iTrackMetaDataInfoVec.end(); it++)
-            {
-                if (it->iTrackID == trackID)
-                {
-                    it->iTrackSelected = true;
-                }
-            }
-        }
-        iSelectedMediaPresetationInfo = aInfo;
-        return PVMFSuccess;
-    }
-    return PVMFErrNotSupported;
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::SetDataSourcePosition(PVMFSessionId aSessionId,
-        PVMFTimestamp aTargetNPT,
-        PVMFTimestamp& aActualNPT,
-        PVMFTimestamp& aActualMediaDataTS,
-        bool aJumpToIFrame,
-        uint32 aStreamID,
-        OsclAny* aContext)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetDataSourcePosition - In"));
-
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION,
-            aTargetNPT,
-            &aActualNPT,
-            &aActualMediaDataTS,
-            aJumpToIFrame,
-            aStreamID,
-            aContext);
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::SetDataSourcePosition - Out"));
-    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::SetDataSourcePosition() - Cmd Recvd"));
-    return QueueCommandL(cmd);
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::SetDataSourcePosition(PVMFSessionId aSessionId,
-        PVMFDataSourcePositionParams& aPVMFDataSourcePositionParams,
-        OsclAny* aContext)
-{
-    PVMFStreamingManagerNodeCommand cmd;
-    return QueueCommandL(cmd);
-}
-
-
-void PVMFStreamingManagerNode::DoSetDataSourcePosition(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoSetDataSourcePosition - In"));
-
-    iActualRepositionStartNPTInMSPtr = NULL;
-    iActualMediaDataTSPtr = NULL;
-    iPVMFDataSourcePositionParamsPtr = NULL;
-    iJumpToIFrame = false;
-    uint32 streamID = 0;
-
-    aCmd.PVMFStreamingManagerNodeCommand::Parse(iRepositionRequestedStartNPTInMS,
-            iActualRepositionStartNPTInMSPtr,
-            iActualMediaDataTSPtr,
-            iJumpToIFrame,
-            streamID);
-
-    PVMF_SM_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::DoSetDataSourcePosition - TargetNPT = %d", iRepositionRequestedStartNPTInMS));
-
-    PVMFSMNodeContainer* iJitterBufferNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFJitterBufferExtensionInterface* jbExtIntf =
-        (PVMFJitterBufferExtensionInterface*)
-        (iJitterBufferNodeContainer->iExtensions[0]);
-    bool retVal = false;
-
-    // duplicate bos has been received
-    // dont perform reposition at source node
-    if (iStreamID == streamID)	retVal = true; // data is already present in the graph
-
-    iStreamID = streamID;
-    jbExtIntf->SendBOSMessage(iStreamID);
-
-
-    *iActualRepositionStartNPTInMSPtr = 0;
-    *iActualMediaDataTSPtr = 0;
-
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        if (iInterfaceState == EPVMFNodePrepared)
-        {
-            /*
-             * SetDataSource from a prepared state could mean two things:
-             *	- In Play-Stop-Play usecase engine does a SetDataSourcePosition
-             *    to get the start media TS to set its playback clock
-             *  - Engine is trying to do a play with a non-zero start offset
-             */
-            if (iRepositionRequestedStartNPTInMS < iSessionStopTime && iRepositionRequestedStartNPTInMS != iSessionStartTime)
-            {
-
-                /* Set Requested Play Range */
-                PVMFSMNodeContainer* iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-                PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                    (PVRTSPEngineNodeExtensionInterface*)
-                    (iSessionControllerNodeContainer->iExtensions[0]);
-
-                RtspRangeType rtspRange;
-                rtspRange.format = RtspRangeType::NPT_RANGE;
-                rtspRange.start_is_set = true;
-                rtspRange.npt_start.npt_format = NptTimeFormat::NPT_SEC;
-                rtspRange.npt_start.npt_sec.sec = iRepositionRequestedStartNPTInMS / 1000;
-                rtspRange.npt_start.npt_sec.milli_sec =
-                    (iRepositionRequestedStartNPTInMS - ((iRepositionRequestedStartNPTInMS / 1000) * 1000));
-                rtspRange.end_is_set = true;
-                rtspRange.npt_end.npt_format = NptTimeFormat::NPT_SEC;
-                rtspRange.npt_end.npt_sec.sec = iSessionStopTime / 1000;
-                rtspRange.npt_end.npt_sec.milli_sec =
-                    (iSessionStopTime - ((iSessionStopTime / 1000) * 1000));
-
-                if (rtspExtIntf->SetRequestPlayRange(rtspRange) != PVMFSuccess)
-                {
-                    PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoSetDataSourcePosition - SetRequestPlayRange Failed"));
-                    PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::SetDataSourcePosition() - Cmd Failed - PVMFFailure"));
-                    CommandComplete(iInputCommands, aCmd, PVMFFailure);
-                    return;
-                }
-
-                // we need to use part of the logic of repositioning to start
-                // streaming from a non-zero offset. Enabled only for 3gpp streaming
-                if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-                        (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-                {
-                    oRepositioning = true;
-                    /* Start the nodes */
-                    if (!DoRepositioningStart3GPPStreaming())
-                    {
-                        CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                        return;
-                    }
-
-                    MoveCmdToCurrentQueue(aCmd);
-                    return;
-                }
-            }
-
-            GetAcutalMediaTSAfterSeek();
-            PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::SetDataSourcePosition() - CmdComplete"));
-            CommandComplete(iInputCommands, aCmd, PVMFSuccess);
-        }
-        else if ((iInterfaceState == EPVMFNodeStarted) || (iInterfaceState == EPVMFNodePaused))
-        {
-            bool oRandAccessDenied = true;
-
-            sessionDescription* sessionInfo =
-                iSessionSourceInfo->_sdpInfo->getSessionInfo();
-            oRandAccessDenied = sessionInfo->getRandomAccessDenied();
-
-
-            if ((oRandAccessDenied == true) ||
-                    (iSessionStopTimeAvailable == false) ||
-                    (((int32)iRepositionRequestedStartNPTInMS < (int32)iSessionStartTime) ||
-                     ((int32)iRepositionRequestedStartNPTInMS >= (int32)iSessionStopTime)))
-            {
-                /*
-                 * Implies an open ended session or invalid request time
-                 * - no pause or reposition
-                 */
-                CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
-                return;
-            }
-
-            oRepositioning = true;
-
-            /* Put the jitter buffer into a state of transition */
-            PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-            if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-            PVMFJitterBufferExtensionInterface* jbExtIntf =
-                (PVMFJitterBufferExtensionInterface*)
-                (iJitterBufferNodeContainer->iExtensions[0]);
-            jbExtIntf->PrepareForRepositioning();
-
-            /* If node is running, pause first */
-            if (iInterfaceState == EPVMFNodeStarted)
-            {
-                if (!DoRepositioningPause3GPPStreaming())
-                {
-                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                }
-            }
-            /* If already paused do not pause */
-            else if (iInterfaceState == EPVMFNodePaused)
-            {
-                /* Start the nodes */
-                if (!DoRepositioningStart3GPPStreaming())
-                {
-                    CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
-                }
-            }
-            MoveCmdToCurrentQueue(aCmd);
-        }
-        else
-        {
-            CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
-            return;
-        }
-    }
-    else
-    {
-        PVMF_SM_LOG_COMMAND_SEQ((0, "PVMFStreamingManagerNode::SetDataSourcePosition() - Cmd Failed - PVMFErrArgument"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::DoQueryInterface() Passed in parameter invalid."));
         CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
         return;
     }
-    return;
-}
 
-bool PVMFStreamingManagerNode::DoRepositioningPause3GPPStreaming()
-{
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
+    if (queryInterface(*uuid, *ifptr) == false)
     {
-        int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-
-        if ((nodeTag == PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_SOCKET_NODE))
-        {
-            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-            if (internalCmd != NULL)
-            {
-                internalCmd->cmd =
-                    iNodeContainerVec[i].commandStartOffset +
-                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_PAUSE_CMD_OFFSET;
-                internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION;
-
-                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                iNode->Pause(iNodeContainerVec[i].iSessionId, cmdContextData);
-                iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoRepositioningPause:RequestNewInternalCmd - Failed"));
-                return false;
-            }
-        }
+        CommandComplete(iInputCommands, aCmd, PVMFFailure);
     }
-    return true;
-}
-
-bool PVMFStreamingManagerNode::DoRepositioningPauseMSHTTPStreaming()
-{
-    /* Pause session controller */
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
+    else
     {
-        int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-        if ((nodeTag == PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE))
-        {
-            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-            if (internalCmd != NULL)
-            {
-                internalCmd->cmd =
-                    iNodeContainerVec[i].commandStartOffset +
-                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_PAUSE_CMD_OFFSET;
-                internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION;
-
-                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                iNode->Pause(iNodeContainerVec[i].iSessionId, cmdContextData);
-                iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoRepositioningPause:RequestNewInternalCmd - Failed"));
-                return false;
-            }
-        }
+        (*ifptr)->addRef();
+        CommandComplete(iInputCommands, aCmd, PVMFSuccess);
     }
-    return true;
+
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryInterface - Out"));
 }
 
-
-bool PVMFStreamingManagerNode::DoRepositioningStart3GPPStreaming()
+bool PVMFStreamingManagerNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
 {
-    /* Set Requested Play Range */
-    PVMFSMNodeContainer* iSessionControllerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::queryInterface - In"));
 
-    if (iSessionControllerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-        (PVRTSPEngineNodeExtensionInterface*)
-        (iSessionControllerNodeContainer->iExtensions[0]);
-
-    RtspRangeType rtspRange;
-    rtspRange.format = RtspRangeType::NPT_RANGE;
-    rtspRange.start_is_set = true;
-    rtspRange.npt_start.npt_format = NptTimeFormat::NPT_SEC;
-    rtspRange.npt_start.npt_sec.sec = iRepositionRequestedStartNPTInMS / 1000;
-    rtspRange.npt_start.npt_sec.milli_sec =
-        (iRepositionRequestedStartNPTInMS - ((iRepositionRequestedStartNPTInMS / 1000) * 1000));
-    rtspRange.end_is_set = true;
-    rtspRange.npt_end.npt_format = NptTimeFormat::NPT_SEC;
-    rtspRange.npt_end.npt_sec.sec = iSessionStopTime / 1000;
-    rtspRange.npt_end.npt_sec.milli_sec =
-        (iSessionStopTime - ((iSessionStopTime / 1000) * 1000));
-
-    if (rtspExtIntf->SetRequestPlayRange(rtspRange) != PVMFSuccess)
+    if (uuid == PVMF_DATA_SOURCE_INIT_INTERFACE_UUID)
     {
-        PVMF_SM_LOGERROR((0, "StreamingManagerNode:DoRepositioningStart - SetRequestPlayRange Failed"));
+        iface = OSCL_STATIC_CAST(PVInterface*, this);
+    }
+    else
+    {
+        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::queryInterface() Unsupported interface UUID."));
         return false;
     }
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-        if (internalCmd != NULL)
-        {
-            internalCmd->cmd =
-                iNodeContainerVec[i].commandStartOffset +
-                PVMF_STREAMING_MANAGER_NODE_INTERNAL_START_CMD_OFFSET;
-            internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION;
 
-            OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-            PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-            iNode->Start(iNodeContainerVec[i].iSessionId, cmdContextData);
-            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-        }
-        else
-        {
-            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoRepositioningStart:RequestNewInternalCmd - Failed"));
-            return false;
-        }
-    }
+    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::queryInterface - Out"));
     return true;
 }
 
-
-bool PVMFStreamingManagerNode::DoRepositioningStartMSHTTPStreaming()
+//Streaming Source node implements all the interfaces in the Streaming Manager
+//Node or FSP, So they are created and destroyed with the creation/destruction
+//of StreamingManager Node/FSP. Hence addref and removeref doesn't really do
+//any thing..
+void PVMFStreamingManagerNode::addRef()
 {
-    PVMFSMNodeContainer* iMediaLayerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-    if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-        (PVMFMediaLayerNodeExtensionInterface*)
-        (iMediaLayerNodeContainer->iExtensions[0]);
-    if (mlExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-
-    PVMFPortInterface* mlInPort = iMediaLayerNodeContainer->iInputPorts[0];
-    mlExtIntf->setInPortReposFlag(mlInPort);
-
-    //Check Track Config. If error is detected, MediaLayer send EOS.
-    PVMFSMTrackInfoVector::iterator it;
-    for (it = iTrackInfoVec.begin(); it != iTrackInfoVec.end(); it++)
-    {
-        if (it->iTrackDisable == true)
-            mlExtIntf->setTrackDisable(it->iMediaLayerOutputPort);
-    }
-
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        int32 nodeTag = iNodeContainerVec[i].iNodeTag;
-
-        if ((nodeTag == PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE) ||
-                (nodeTag == PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE) ||
-                (iInterfaceState == EPVMFNodePrepared && nodeTag != PVMF_STREAMING_MANAGER_SOCKET_NODE))
-        {
-            PVMFSMCommandContext* internalCmd = RequestNewInternalCmd();
-            if (internalCmd != NULL)
-            {
-                internalCmd->cmd =
-                    iNodeContainerVec[i].commandStartOffset +
-                    PVMF_STREAMING_MANAGER_NODE_INTERNAL_START_CMD_OFFSET;
-                internalCmd->parentCmd = PVMF_STREAMING_MANAGER_NODE_SET_DATASOURCE_POSITION;
-
-                OsclAny *cmdContextData = OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
-                PVMFNodeInterface* iNode = iNodeContainerVec[i].iNode;
-
-                iNode->Start(iNodeContainerVec[i].iSessionId, cmdContextData);
-                iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_PENDING;
-            }
-            else
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode:DoRepositioningStartMSHTTPStreaming:RequestNewInternalCmd - Failed"));
-                return false;
-            }
-        }
-    }
-    return true;
-}
-
-void PVMFStreamingManagerNode::GetAcutalMediaTSAfterSeek()
-{
-    PVMFSMNodeContainer* iJitterBufferNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-    if (iJitterBufferNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFJitterBufferExtensionInterface* jbExtIntf =
-        (PVMFJitterBufferExtensionInterface*)
-        (iJitterBufferNodeContainer->iExtensions[0]);
-
-    PVMFSMNodeContainer* iMediaLayerNodeContainer =
-        getNodeContainer(PVMF_STREAMING_MANAGER_MEDIA_LAYER_NODE);
-    if (iMediaLayerNodeContainer == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFMediaLayerNodeExtensionInterface* mlExtIntf =
-        (PVMFMediaLayerNodeExtensionInterface*)
-        (iMediaLayerNodeContainer->iExtensions[0]);
-    if (mlExtIntf == NULL) OSCL_LEAVE(OsclErrBadHandle);
-    PVMFPortInterface* mlInPort = iMediaLayerNodeContainer->iInputPorts[0];
-
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-    {
-        iActualMediaDataTS = jbExtIntf->getActualMediaDataTSAfterSeek();
-        if (iActualMediaDataTSPtr != NULL)
-        {
-            *iActualMediaDataTSPtr = iActualMediaDataTS;
-            PVMF_SM_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetAcutalMediaTSAfterSeek - TargetNPT = %d, ActualNPT=%d, ActualMediaDataTS=%d",
-                                       iRepositionRequestedStartNPTInMS, *iActualRepositionStartNPTInMSPtr, *iActualMediaDataTSPtr));
-        }
-        if (iPVMFDataSourcePositionParamsPtr != NULL)
-        {
-            iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS = iActualMediaDataTS;
-            PVMF_SM_LOG_COMMAND_REPOS((0, "PVMFStreamingManagerNode::GetAcutalMediaTSAfterSeek - ActualMediaDataTS=%d",
-                                       iPVMFDataSourcePositionParamsPtr->iActualMediaDataTS));
-        }
-    }
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::QueryDataSourcePosition(PVMFSessionId aSessionId,
-        PVMFTimestamp aTargetNPT,
-        PVMFTimestamp& aActualNPT,
-        bool aSeekToSyncPoint,
-        OsclAny* aContext)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryDataSourcePosition - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_QUERY_DATASOURCE_POSITION,
-            aTargetNPT,
-            &aActualNPT,
-            aSeekToSyncPoint,
-            aContext);
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryDataSourcePosition - Out"));
-    return QueueCommandL(cmd);
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::QueryDataSourcePosition(PVMFSessionId aSessionId,
-        PVMFTimestamp aTargetNPT,
-        PVMFTimestamp& aSeekPointBeforeTargetNPT,
-        PVMFTimestamp& aSeekPointAfterTargetNPT,
-        OsclAny* aContext,
-        bool aSeekToSyncPoint)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryDataSourcePosition - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_QUERY_DATASOURCE_POSITION,
-            aTargetNPT,
-            &aSeekPointBeforeTargetNPT,
-            &aSeekPointAfterTargetNPT,
-            aContext,
-            aSeekToSyncPoint);
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::QueryDataSourcePosition - Out"));
-    return QueueCommandL(cmd);
-}
-
-void PVMFStreamingManagerNode::DoQueryDataSourcePosition(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryDataSourcePosition - In"));
-
-    PVMFTimestamp repositionrequestedstartnptinms = 0;
-    PVMFTimestamp* actualrepositionstartnptinmsptr = NULL;
-    bool seektosyncpoint = false;
-
-    aCmd.PVMFStreamingManagerNodeCommand::Parse(repositionrequestedstartnptinms,
-            actualrepositionstartnptinmsptr,
-            seektosyncpoint);
-
-    if (actualrepositionstartnptinmsptr == NULL)
-    {
-        CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
-        return;
-    }
-    *actualrepositionstartnptinmsptr = 0;
-
-    // This query is not supported for streaming sessions
-    CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::DoQueryDataSourcePosition - Out"));
-    return;
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::SetDataSourceRate(PVMFSessionId aSessionId,
-        int32 aRate,
-        OsclTimebase* aTimebase,
-        OsclAny* aContext)
-{
-    OSCL_UNUSED_ARG(aSessionId);
-    OSCL_UNUSED_ARG(aRate);
-    OSCL_UNUSED_ARG(aTimebase);
-    OSCL_UNUSED_ARG(aContext);
-
-    OSCL_LEAVE(OsclErrNotSupported);
-    return 0;
-}
-
-void PVMFStreamingManagerNode::DoSetDataSourceRate(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
-}
-
-uint32
-PVMFStreamingManagerNode::GetNumMetadataKeys(char* aQueryKeyString)
-{
-    uint32 num_entries = 0;
-
-    if (aQueryKeyString == NULL)
-    {
-        // No query key so just return all the available keys
-        num_entries = iAvailableMetadataKeys.size();
-    }
-    else
-    {
-        // Determine the number of metadata keys based on the query key string provided
-        uint32 i;
-        for (i = 0; i < iAvailableMetadataKeys.size(); i++)
-        {
-            // Check if the key matches the query key
-            if (pv_mime_strcmp(iAvailableMetadataKeys[i].get_cstr(), aQueryKeyString) >= 0)
-            {
-                num_entries++;
-            }
-        }
-        for (i = 0; i < iCPMMetadataKeys.size(); i++)
-        {
-            /* Check if the key matches the query key */
-            if (pv_mime_strcmp(iCPMMetadataKeys[i].get_cstr(),
-                               aQueryKeyString) >= 0)
-            {
-                num_entries++;
-            }
-        }
-    }
-    return num_entries;
-}
-
-uint32
-PVMFStreamingManagerNode::GetNumMetadataValues(PVMFMetadataList& aKeyList)
-{
-    uint32 numkeys = aKeyList.size();
-
-    if (numkeys == 0)
-    {
-        return 0;
-    }
-
-    SDPInfo* sdpInfo = NULL;
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-        if (sdpInfo == NULL)
-        {
-            return 0;
-        }
-    }
-    // Get Num Tracks
-    uint32 numtracks = iMetaDataInfo.iNumTracks;
-
-    uint32 numvalentries = 0;
-    for (uint32 lcv = 0; lcv < numkeys; lcv++)
-    {
-        if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_AUTHOR_KEY) == 0 &&
-                iMetaDataInfo.iAuthorPresent)
-        {
-            // Author
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_ARTIST_KEY) == 0 &&
-                 iMetaDataInfo.iPerformerPresent)
-        {
-            // Artist/performer
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TITLE_KEY) == 0 &&
-                 iMetaDataInfo.iTitlePresent)
-        {
-            // Title
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY) == 0 &&
-                 iMetaDataInfo.iDescriptionPresent)
-        {
-            // Description
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RATING_KEY) == 0 &&
-                 iMetaDataInfo.iRatingPresent)
-        {
-            // Rating
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY) == 0 &&
-                 iMetaDataInfo.iCopyRightPresent)
-        {
-            // Copyright
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_GENRE_KEY) == 0 &&
-                 iMetaDataInfo.iGenrePresent)
-        {
-            // Genre
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LYRICS_KEY) == 0 &&
-                 iMetaDataInfo.iLyricsPresent)
-        {
-            // Lyrics
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY) == 0 &&
-                 iMetaDataInfo.iWMPicturePresent)
-        {
-            // Num Picture
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_GRAPHICS_KEY) == 0 &&
-                 iMetaDataInfo.iWMPicturePresent)
-        {
-            // Picture
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY) == 0 &&
-                 iMetaDataInfo.iClassificationPresent)
-        {
-            // Classification
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_KEYWORDS_KEY) == 0 &&
-                 iMetaDataInfo.iKeyWordsPresent)
-        {
-            // Keywords
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LOCATION_KEY) == 0 &&
-                 iMetaDataInfo.iLocationPresent)
-        {
-            // Location
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DURATION_KEY) == 0)
-        {
-            // Session Duration
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY) == 0 &&
-                 numtracks > 0)
-        {
-            // Number of tracks
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY) == 0)
-        {
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strcmp(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY) == 0)
-        {
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-        }
-        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY) != NULL)
-        {
-            // Track type
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = numtracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
-            {
-                continue;
-            }
-            // Increment the counter for the number of values found so far
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY) != NULL)
-        {
-            // Track duration
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = numtracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
-            {
-                continue;
-            }
-
-            // Increment the counter for the number of values found so far
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY) != NULL)
-        {
-            // Track bitrate
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = numtracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
-            {
-                continue;
-            }
-            // Increment the counter for the number of values found so far
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY) != NULL)
-        {
-            // Track bitrate
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = numtracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
-            {
-                continue;
-            }
-            // Increment the counter for the number of values found so far
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if (oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY) != NULL)
-        {
-            // Track selected
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = numtracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= (uint32)numtracks || endindex >= (uint32)numtracks)
-            {
-                continue;
-            }
-            // Increment the counter for the number of values found so far
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY) != NULL))
-        {
-            /*
-             * Codec Name
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else if ((oscl_strstr(aKeyList[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY) != NULL))
-        {
-            /*
-             * Codec Description
-             * Determine the index requested.
-             */
-            uint32 startindex = 0;
-            uint32 endindex   = 0;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr(aKeyList[lcv].get_cstr(),
-                                         PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if ((startindex > endindex) ||
-                    (startindex >= (uint32)numtracks) ||
-                    (endindex >= (uint32)numtracks))
-            {
-                continue;
-            }
-            numvalentries += (endindex + 1 - startindex);
-        }
-        else
-        {
-            /* Check the extended meta data list */
-            for (uint32 i = 0; i < iMetaDataInfo.iExtendedMetaDataNameVec.size(); i++)
-            {
-                OSCL_HeapString<PVMFStreamingManagerNodeAllocator> extMetaDataName =
-                    iMetaDataInfo.iExtendedMetaDataNameVec[i];
-                if (oscl_strcmp(aKeyList[lcv].get_cstr(), extMetaDataName.get_cstr()) == 0)
-                {
-                    /*
-                     * Increment the counter for the number of values found so far
-                     */
-                    ++numvalentries;
-                }
-            }
-        }
-    }
-    return numvalentries; // Number of elements
-}
-
-PVMFStatus PVMFStreamingManagerNode::InitMetaData()
-{
-    // Init Metadata
-    {
-        // Clear out the existing key list
-        iAvailableMetadataKeys.clear();
-        iCPMMetadataKeys.clear();
-
-        int32 leavecode = 0;
-
-        if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-                (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) ||
-                (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-                (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-        {
-            // Get the SDP info
-            SDPInfo* sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-            if (sdpInfo == NULL)
-            {
-                return PVMFErrInvalidState;
-            }
-
-            // Get Asset Info
-            sessionDescription* sessionInfo = sdpInfo->getSessionInfo();
-            if (sessionInfo != NULL)
-            {
-                iMetaDataInfo.iRandomAccessDenied = sessionInfo->getRandomAccessDenied();
-
-                AssetInfoType assetInfo = sessionInfo->getAssetInfo();
-
-                iMetaDataInfo.iTitlePresent = assetInfo.oTitlePresent;
-                iMetaDataInfo.iDescriptionPresent = assetInfo.oDescriptionPresent;
-                iMetaDataInfo.iCopyRightPresent = assetInfo.oCopyRightPresent;
-                iMetaDataInfo.iPerformerPresent = assetInfo.oPerformerPresent;
-                iMetaDataInfo.iAuthorPresent = assetInfo.oAuthorPresent;
-                iMetaDataInfo.iGenrePresent = assetInfo.oGenrePresent;
-                iMetaDataInfo.iRatingPresent = assetInfo.oRatingPresent;
-                iMetaDataInfo.iClassificationPresent = assetInfo.oClassificationPresent;
-                iMetaDataInfo.iKeyWordsPresent = assetInfo.oKeyWordsPresent;
-                iMetaDataInfo.iLocationPresent = assetInfo.oLocationPresent;
-
-                if (iMetaDataInfo.iTitlePresent)
-                {
-                    iMetaDataInfo.iTitle = assetInfo.Box[AssetInfoType::TITLE];
-                }
-                if (iMetaDataInfo.iDescriptionPresent)
-                {
-                    iMetaDataInfo.iDescription = assetInfo.Box[AssetInfoType::DESCRIPTION];
-                }
-                if (iMetaDataInfo.iCopyRightPresent)
-                {
-                    iMetaDataInfo.iCopyright = assetInfo.Box[AssetInfoType::COPYRIGHT];
-                }
-                if (iMetaDataInfo.iPerformerPresent)
-                {
-                    iMetaDataInfo.iPerformer = assetInfo.Box[AssetInfoType::PERFORMER];
-                }
-                if (iMetaDataInfo.iAuthorPresent)
-                {
-                    iMetaDataInfo.iAuthor = assetInfo.Box[AssetInfoType::AUTHOR];
-                }
-                if (iMetaDataInfo.iRatingPresent)
-                {
-                    iMetaDataInfo.iRating = assetInfo.Box[AssetInfoType::RATING];
-                }
-                if (iMetaDataInfo.iClassificationPresent)
-                {
-                    iMetaDataInfo.iClassification = assetInfo.Box[AssetInfoType::CLASSIFICATION];
-                }
-                if (iMetaDataInfo.iKeyWordsPresent)
-                {
-                    iMetaDataInfo.iKeyWords = assetInfo.Box[AssetInfoType::KEYWORDS];
-                }
-                if (iMetaDataInfo.iLocationPresent)
-                {
-                    iMetaDataInfo.iLocation = assetInfo.Box[AssetInfoType::LOCATION];
-                }
-
-                RtspRangeType *sessionRange = OSCL_CONST_CAST(RtspRangeType*, (sessionInfo->getRange()));
-                if (sessionRange->end_is_set == true)
-                {
-                    iMetaDataInfo.iSessionDurationAvailable = true;
-
-                    int32 sessionStartTime = 0, sessionStopTime = 0;
-                    sessionRange->convertToMilliSec(sessionStartTime, sessionStopTime);
-                    uint32 duration = 0;
-                    if (sessionStopTime > sessionStartTime && sessionStartTime >= 0)
-                    {
-                        duration = (uint32)(sessionStopTime - sessionStartTime);
-                    }
-                    Oscl_Int64_Utils::set_uint64(iMetaDataInfo.iSessionDuration, 0, duration);
-                    iMetaDataInfo.iSessionDurationTimeScale = 1000;
-                }
-
-            }
-            iMetaDataInfo.iNumTracks = sdpInfo->getNumMediaObjects();
-
-            for (uint32 i = 0; i < iMetaDataInfo.iNumTracks; i++)
-            {
-                Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec = sdpInfo->getMediaInfo(i);
-                for (uint32 j = 0; j < mediaInfoVec.size(); ++j)
-                {
-                    mediaInfo* mInfo = mediaInfoVec[j];
-                    if (mInfo != NULL)
-                    {
-                        PVMFSMTrackMetaDataInfo trackMetaDataInfo;
-
-                        trackMetaDataInfo.iTrackID = mInfo->getMediaInfoID();
-                        const char* mimeType = mInfo->getMIMEType();
-                        OSCL_StackString<32> h263(_STRLIT_CHAR("H263"));
-                        {
-                            trackMetaDataInfo.iMimeType += mimeType;
-                        }
-
-                        Oscl_Vector<PayloadSpecificInfoTypeBase*, SDPParserAlloc> payloadVector;
-                        payloadVector = mInfo->getPayloadSpecificInfoVector();
-                        if (payloadVector.size() != 0)
-                        {
-                            /*
-                             * There can be multiple payloads per media segment.
-                             * We only support one for now, so
-                             * use just the first payload
-                             */
-                            PayloadSpecificInfoTypeBase* payloadInfo = payloadVector[0];
-                            if (oscl_strstr(mimeType, h263.get_cstr()) != NULL)
-                            {
-                                H263PayloadSpecificInfoType* h263PayloadInfo =
-                                    OSCL_STATIC_CAST(H263PayloadSpecificInfoType*, payloadInfo);
-                                trackMetaDataInfo.iTrackWidth = h263PayloadInfo->getFrameWidth();
-                                trackMetaDataInfo.iTrackHeight = h263PayloadInfo->getFrameHeight();
-                            }
-                        }
-
-                        trackMetaDataInfo.iTrackBitRate = (uint32)(mInfo->getBitrate());
-
-                        RtspRangeType *mediaRange = mInfo->getRtspRange();
-                        if (mediaRange->end_is_set == true)
-                        {
-                            int32 mediaStartTime = 0, mediaStopTime = 0;
-                            mediaRange->convertToMilliSec(mediaStartTime, mediaStopTime);
-                            uint32 trackduration = 0;
-                            if (mediaStopTime > mediaStartTime && mediaStartTime >= 0)
-                            {
-                                trackduration = (uint32)(mediaStopTime - mediaStartTime);
-                            }
-                            uint64 trackduration64 = 0;
-                            Oscl_Int64_Utils::set_uint64(trackduration64, 0, trackduration);
-                            trackMetaDataInfo.iTrackDuration = trackduration64;
-                            trackMetaDataInfo.iTrackDurationTimeScale = 1000;
-                            trackMetaDataInfo.iTrackDurationAvailable = true;
-                        }
-                        else
-                        {
-                            trackMetaDataInfo.iTrackDurationAvailable = false;
-                        }
-                        iMetaDataInfo.iTrackMetaDataInfoVec.push_back(trackMetaDataInfo);
-                    }
-                }
-            }
-        }
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_DURATION_KEY));
-
-        if (iMetaDataInfo.iTitlePresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_TITLE_KEY));
-        }
-        if (iMetaDataInfo.iDescriptionPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY));
-        }
-        if (iMetaDataInfo.iCopyRightPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY));
-        }
-        if (iMetaDataInfo.iPerformerPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_ARTIST_KEY));
-        }
-        if (iMetaDataInfo.iAuthorPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_AUTHOR_KEY));
-        }
-        if (iMetaDataInfo.iGenrePresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_GENRE_KEY));
-        }
-        if (iMetaDataInfo.iLyricsPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_LYRICS_KEY));
-        }
-        if (iMetaDataInfo.iWMPicturePresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY));
-        }
-        if (iMetaDataInfo.iWMPicturePresent)
-        {
-            // Create the parameter string for the index range
-            char indexparam[18];
-            oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo.iWMPictureIndexVec.size() - 1));
-            indexparam[17] = NULL_TERM_CHAR;
-
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_GRAPHICS_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-        }
-        if (iMetaDataInfo.iRatingPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_RATING_KEY));
-        }
-        if (iMetaDataInfo.iClassificationPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY));
-        }
-        if (iMetaDataInfo.iKeyWordsPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_KEYWORDS_KEY));
-        }
-        if (iMetaDataInfo.iLocationPresent)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_LOCATION_KEY));
-        }
-
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY));
-
-        leavecode = 0;
-        OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY));
-
-        if (iMetaDataInfo.iNumTracks > 0)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY));
-
-            // Create the parameter string for the index range
-            char indexparam[18];
-            oscl_snprintf(indexparam, 18, ";index=0...%d", (iMetaDataInfo.iNumTracks - 1));
-            indexparam[17] = NULL_TERM_CHAR;
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            leavecode = 0;
-            OSCL_TRY(leavecode,
-                     iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY);
-                     iAvailableMetadataKeys[0] += indexparam;);
-
-            if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-                    (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) ||
-                    (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE))
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-        }
-
-        uint32 i;
-        for (i = 0; i < iMetaDataInfo.iExtendedMetaDataDescriptorCount; i++)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, iAvailableMetadataKeys.push_back(iMetaDataInfo.iExtendedMetaDataNameVec[i]));
-        }
-
-        for (i = 0; i < iMetaDataInfo.iTrackMetaDataInfoVec.size(); i++)
-        {
-            PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-            char indexparam[18];
-            oscl_snprintf(indexparam, 18, ";index=%d", (i));
-            indexparam[17] = NULL;
-
-            if (trackMetaDataInfo.iTrackWidth > 0)
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-            if (trackMetaDataInfo.iTrackHeight > 0)
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-            if (trackMetaDataInfo.iVideoFrameRate > 0)
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-            if (trackMetaDataInfo.iAudioSampleRate > 0)
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-            if (trackMetaDataInfo.iAudioNumChannels > 0)
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-            if (trackMetaDataInfo.iAudioBitsPerSample > 0)
-            {
-                leavecode = 0;
-                OSCL_TRY(leavecode,
-                         iAvailableMetadataKeys.push_front(PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY);
-                         iAvailableMetadataKeys[0] += indexparam;);
-            }
-        }
-        return PVMFSuccess;
-    }
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::DoGetMetadataKeys(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        SDPInfo* sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-        if (sdpInfo == NULL)
-        {
-            return PVMFErrInvalidState;
-        }
-    }
-    return (CompleteGetMetadataKeys(aCmd));
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::CompleteGetMetadataKeys(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVMFMetadataList* keylistptr = NULL;
-    uint32 starting_index;
-    int32 max_entries;
-    char* query_key = NULL;
-
-    aCmd.PVMFStreamingManagerNodeCommand::Parse(keylistptr, starting_index, max_entries, query_key);
-
-    // Check parameters
-    if (keylistptr == NULL)
-    {
-        // The list pointer is invalid
-        return PVMFErrArgument;
-    }
-
-    if ((starting_index > (iAvailableMetadataKeys.size() - 1)) || max_entries == 0)
-    {
-        // Invalid starting index and/or max entries
-        return PVMFErrArgument;
-    }
-
-    // Copy the requested keys
-    uint32 num_entries = 0;
-    int32 num_added = 0;
-    int32 leavecode = 0;
-    uint32 lcv = 0;
-    for (lcv = 0; lcv < iAvailableMetadataKeys.size(); lcv++)
-    {
-        if (query_key == NULL)
-        {
-            // No query key so this key is counted
-            ++num_entries;
-            if (num_entries > starting_index)
-            {
-                // Past the starting index so copy the key
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::DoGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
-                num_added++;
-            }
-        }
-        else
-        {
-            // Check if the key matche the query key
-            if (pv_mime_strcmp(iAvailableMetadataKeys[lcv].get_cstr(), query_key) >= 0)
-            {
-                // This key is counted
-                ++num_entries;
-                if (num_entries > starting_index)
-                {
-                    // Past the starting index so copy the key
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::DoGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
-                    num_added++;
-                }
-            }
-        }
-    }
-    for (lcv = 0; lcv < iCPMMetadataKeys.size(); lcv++)
-    {
-        if (query_key == NULL)
-        {
-            /* No query key so this key is counted */
-            ++num_entries;
-            if (num_entries > (uint32)starting_index)
-            {
-                /* Past the starting index so copy the key */
-                leavecode = 0;
-                OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                OSCL_FIRST_CATCH_ANY(leavecode,
-                                     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                     return PVMFErrNoMemory);
-                num_added++;
-            }
-        }
-        else
-        {
-            /* Check if the key matches the query key */
-            if (pv_mime_strcmp(iCPMMetadataKeys[lcv].get_cstr(), query_key) >= 0)
-            {
-                /* This key is counted */
-                ++num_entries;
-                if (num_entries > (uint32)starting_index)
-                {
-                    /* Past the starting index so copy the key */
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(iCPMMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::CompleteGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
-                    num_added++;
-                }
-            }
-        }
-        // Check if max number of entries have been copied
-        if (max_entries > 0 && num_added >= max_entries)
-        {
-            break;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::GetIndexParamValues(char* aString, uint32& aStartIndex, uint32& aEndIndex)
-{
-    // This parses a string of the form "index=N1...N2" and extracts the integers N1 and N2.
-    // If string is of the format "index=N1" then N2=N1
-
-    if (aString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    // Go to end of "index="
-    char* n1string = aString + 6;
-
-    PV_atoi(n1string, 'd', oscl_strlen(n1string), aStartIndex);
-
-    char* n2string = oscl_strstr(aString, _STRLIT_CHAR("..."));
-
-    if (n2string == NULL)
-    {
-        aEndIndex = aStartIndex;
-    }
-    else
-    {
-        // Go to end of "index=N1..."
-        n2string += 3;
-
-        PV_atoi(n2string, 'd', oscl_strlen(n2string), aEndIndex);
-    }
-
-    return PVMFSuccess;
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::DoGetMetadataValues(PVMFStreamingManagerNodeCommand& aCmd)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::DoGetMetadataValues() In"));
-
-    SDPInfo* sdpInfo = NULL;
-    if ((iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTSP_URL) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_SDP_FILE) ||
-            (iSessionSourceInfo->_sessionType == PVMF_DATA_SOURCE_RTP_PACKET_SOURCE))
-    {
-        sdpInfo = iSessionSourceInfo->_sdpInfo.GetRep();
-        if (sdpInfo == NULL)
-        {
-            return PVMFErrInvalidState;
-        }
-    }
-    PVMFMetadataList* keylistptr = NULL;
-    Oscl_Vector<PvmiKvp, OsclMemAllocator>* valuelistptr = NULL;
-    uint32 starting_index;
-    int32 max_entries;
-
-    aCmd.PVMFStreamingManagerNodeCommand::Parse(keylistptr, valuelistptr, starting_index, max_entries);
-
-    // Check the parameters
-    if (keylistptr == NULL || valuelistptr == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    uint32 numkeys = keylistptr->size();
-
-    if (starting_index > (numkeys - 1) || numkeys <= 0 || max_entries == 0)
-    {
-        // Don't do anything
-        return PVMFErrArgument;
-    }
-
-    uint32 numvalentries = 0;
-    int32 numentriesadded = 0;
-    for (uint32 lcv = 0; lcv < numkeys; lcv++)
-    {
-        int32 leavecode = 0;
-        PvmiKvp KeyVal;
-        KeyVal.key = NULL;
-        KeyVal.value.pWChar_value = NULL;
-        KeyVal.value.pChar_value = NULL;
-
-        if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_AUTHOR_KEY) == 0 &&
-                iMetaDataInfo.iAuthorPresent)
-        {
-            // Author
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsAuthorUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_AUTHOR_KEY,
-                                                         iMetaDataInfo.iAuthor.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_AUTHOR_KEY,
-                             iMetaDataInfo.iAuthorUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_ARTIST_KEY) == 0 &&
-                 iMetaDataInfo.iPerformerPresent)
-        {
-            // Artist/performer
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsPerformerUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_ARTIST_KEY,
-                                                         iMetaDataInfo.iPerformer.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_ARTIST_KEY,
-                             iMetaDataInfo.iPerformerUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TITLE_KEY) == 0 &&
-                 iMetaDataInfo.iTitlePresent)
-        {
-            // Title
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsTitleUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_TITLE_KEY,
-                                                         iMetaDataInfo.iTitle.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_TITLE_KEY,
-                             iMetaDataInfo.iTitleUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY) == 0 &&
-                 iMetaDataInfo.iDescriptionPresent)
-        {
-            // Description
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsDescriptionUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY,
-                                                         iMetaDataInfo.iDescription.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_DESCRIPTION_KEY,
-                             iMetaDataInfo.iDescriptionUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RATING_KEY) == 0 &&
-                 iMetaDataInfo.iRatingPresent)
-        {
-            // Rating
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsRatingUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_RATING_KEY,
-                                                         iMetaDataInfo.iRating.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_RATING_KEY,
-                             iMetaDataInfo.iRatingUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY) == 0 &&
-                 iMetaDataInfo.iCopyRightPresent)
-        {
-            // Copyright
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsCopyRightUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY,
-                                                         iMetaDataInfo.iCopyright.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_COPYRIGHT_KEY,
-                             iMetaDataInfo.iCopyrightUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_GENRE_KEY) == 0 &&
-                 iMetaDataInfo.iGenrePresent)
-        {
-            // Genre
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsGenreUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_GENRE_KEY,
-                                                         iMetaDataInfo.iGenre.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_GENRE_KEY,
-                             iMetaDataInfo.iGenreUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LYRICS_KEY) == 0 &&
-                 iMetaDataInfo.iLyricsPresent)
-        {
-            // Lyrics
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsLyricsUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_LYRICS_KEY,
-                                                         iMetaDataInfo.iLyrics.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_LYRICS_KEY,
-                             iMetaDataInfo.iLyricsUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY) == 0 &&
-                 iMetaDataInfo.iWMPicturePresent)
-        {
-            /*
-             * Num Picture
-             * Increment the counter for the number of values found so far
-             */
-            ++numvalentries;
-
-            /* Create a value entry if past the starting index */
-            if (numvalentries > (uint32)starting_index)
-            {
-                PVMFStatus retval =
-                    PVMFCreateKVPUtils::CreateKVPForUInt32Value(KeyVal,
-                            PVMFSTREAMINGMGRNODE_NUM_GRAPHICS_KEY,
-                            iMetaDataInfo.iNumWMPicture,
-                            NULL);
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY) == 0 &&
-                 iMetaDataInfo.iClassificationPresent)
-        {
-            // Classification
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsClassificationUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY,
-                                                         iMetaDataInfo.iClassification.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_CLASSIFICATION_KEY,
-                             iMetaDataInfo.iClassificationUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_KEYWORDS_KEY) == 0 &&
-                 iMetaDataInfo.iKeyWordsPresent)
-        {
-            // Keywords
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsKeyWordsUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_KEYWORDS_KEY,
-                                                         iMetaDataInfo.iKeyWords.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_KEYWORDS_KEY,
-                             iMetaDataInfo.iKeyWordUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_LOCATION_KEY) == 0 &&
-                 iMetaDataInfo.iLocationPresent)
-        {
-            // Location
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval;
-                if (iMetaDataInfo.iIsLocationUnicode == false)
-                {
-                    retval = CreateKVPForCharStringValue(KeyVal,
-                                                         PVMFSTREAMINGMGRNODE_LOCATION_KEY,
-                                                         iMetaDataInfo.iLocation.get_cstr());
-                }
-                else
-                {
-                    retval = CreateKVPForWideCharStringValue(KeyVal,
-                             PVMFSTREAMINGMGRNODE_LOCATION_KEY,
-                             iMetaDataInfo.iLocationUnicode.get_cstr());
-                }
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_DURATION_KEY) == 0)
-        {
-            // Session Duration
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                if (iMetaDataInfo.iSessionDurationAvailable == true)
-                {
-                    uint32 duration = Oscl_Int64_Utils::get_uint64_lower32(iMetaDataInfo.iSessionDuration);
-                    char timescalestr[20];
-                    oscl_snprintf(timescalestr, 20, ";%s%d", PVMFSTREAMINGMGRNODE_TIMESCALE, iMetaDataInfo.iSessionDurationTimeScale);
-                    timescalestr[19] = NULL_TERM_CHAR;
-                    PVMFStatus retval = CreateKVPForUInt32Value(KeyVal,
-                                        PVMFSTREAMINGMGRNODE_DURATION_KEY,
-                                        duration,
-                                        timescalestr);
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-                }
-                else
-                {
-                    OSCL_StackString<32> unknownDuration(_STRLIT_CHAR("unknown"));
-                    PVMFStatus retval = CreateKVPForCharStringValue(KeyVal,
-                                        PVMFSTREAMINGMGRNODE_DURATION_KEY,
-                                        unknownDuration.get_cstr());
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY) == 0 &&
-                 iMetaDataInfo.iNumTracks > 0)
-        {
-            // Number of tracks
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval = CreateKVPForUInt32Value(KeyVal,
-                                    PVMFSTREAMINGMGRNODE_NUMTRACKS_KEY,
-                                    iMetaDataInfo.iNumTracks);
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY) == 0)
-        {
-            // random access
-            // Increment the counter for the number of values found so far
-            ++numvalentries;
-
-            // Create a value entry if past the starting index
-            if (numvalentries > starting_index)
-            {
-                PVMFStatus retval = CreateKVPForBoolValue(KeyVal,
-                                    PVMFSTREAMINGMGRNODE_RANDOM_ACCESS_DENIED_KEY,
-                                    iMetaDataInfo.iRandomAccessDenied);
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-            }
-        }
-        else if (oscl_strcmp((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY) == 0)
-        {
-            /*
-             * Clip Type
-             * Increment the counter for the number of values found so far
-             */
-            ++numvalentries;
-
-            /* Create a value entry if past the starting index */
-            if (numvalentries > (uint32)starting_index)
-            {
-                uint32 len = 0;
-                char* clipType = NULL;
-                len = oscl_strlen("streaming");
-                clipType = OSCL_ARRAY_NEW(char, len + 1);
-                oscl_memset(clipType, 0, len + 1);
-                oscl_strncpy(clipType, ("streaming"), len);
-                PVMFStatus retval =
-                    PVMFCreateKVPUtils::CreateKVPForCharStringValue(KeyVal,
-                            PVMFSTREAMINGMGRNODE_CLIP_TYPE_KEY,
-                            clipType);
-
-                OSCL_ARRAY_DELETE(clipType);
-                if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                {
-                    break;
-                }
-
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY) != NULL)
-        {
-            // Track type
-
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex   = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-                    trackkvp.value.pChar_value = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL_TERM_CHAR;
-
-                        const char* mimeType = trackMetaDataInfo.iMimeType.get_cstr();
-                        retval = CreateKVPForCharStringValue(trackkvp,
-                                                             PVMFSTREAMINGMGRNODE_TRACKINFO_TYPE_KEY,
-                                                             mimeType,
-                                                             indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            if (trackkvp.value.pChar_value != NULL)
-                            {
-                                OSCL_ARRAY_DELETE(trackkvp.value.pChar_value);
-                                trackkvp.value.pChar_value = NULL;
-                            }
-
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY) != NULL)
-        {
-            // Track duration
-
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        if (trackMetaDataInfo.iTrackDurationAvailable == true)
-                        {
-                            char indextimescaleparam[36];
-                            oscl_snprintf(indextimescaleparam, 36, ";%s%d;%s%d", PVMFSTREAMINGMGRNODE_INDEX, i, PVMFSTREAMINGMGRNODE_TIMESCALE, trackMetaDataInfo.iTrackDurationTimeScale);
-                            indextimescaleparam[35] = NULL_TERM_CHAR;
-
-                            uint32 trackduration =
-                                Oscl_Int64_Utils::get_uint64_lower32(trackMetaDataInfo.iTrackDuration);
-                            retval = CreateKVPForUInt32Value(trackkvp,
-                                                             PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY,
-                                                             trackduration,
-                                                             indextimescaleparam);
-                        }
-                        else
-                        {
-                            char indextimescaleparam[36];
-                            oscl_snprintf(indextimescaleparam, 36, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                            indextimescaleparam[35] = NULL_TERM_CHAR;
-
-                            OSCL_StackString<32> unknownDuration(_STRLIT_CHAR("unknown"));
-                            PVMFStatus retval = CreateKVPForCharStringValue(trackkvp,
-                                                PVMFSTREAMINGMGRNODE_TRACKINFO_DURATION_KEY,
-                                                unknownDuration.get_cstr(),
-                                                indextimescaleparam);
-                            if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                            {
-                                break;
-                            }
-                        }
-
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY) != NULL)
-        {
-            // Track bitrate
-
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL_TERM_CHAR;
-
-                        uint32 trackbitrate = trackMetaDataInfo.iTrackBitRate;
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_BITRATE_KEY,
-                                                         trackbitrate,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY) != NULL)
-        {
-            // Track bitrate
-
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL_TERM_CHAR;
-
-                        uint32 trackbitrate = trackMetaDataInfo.iTrackMaxBitRate;
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_MAX_BITRATE_KEY,
-                                                         trackbitrate,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY) != NULL)
-        {
-            // Track bitrate
-
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-
-                        indexparam[15] = NULL_TERM_CHAR;
-
-                        bool selected = trackMetaDataInfo.iTrackSelected;
-                        retval = CreateKVPForBoolValue(trackkvp,
-                                                       PVMFSTREAMINGMGRNODE_TRACKINFO_SELECTED_KEY,
-                                                       selected,
-                                                       indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY) != NULL)
-        {
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL;
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_WIDTH_KEY,
-                                                         trackMetaDataInfo.iTrackWidth,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY) != NULL)
-        {
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL;
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_HEIGHT_KEY,
-                                                         trackMetaDataInfo.iTrackHeight,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY) != NULL)
-        {
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL;
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_FRAME_RATE_KEY,
-                                                         trackMetaDataInfo.iVideoFrameRate,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY) != NULL)
-        {
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL;
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_SAMPLERATE_KEY,
-                                                         trackMetaDataInfo.iAudioSampleRate,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY) != NULL)
-        {
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL;
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_NUMCHANNELS_KEY,
-                                                         trackMetaDataInfo.iAudioNumChannels,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY) != NULL)
-        {
-            // Determine the index requested. Default to all tracks
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            // Check if the index parameter is present
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                // Retrieve the index values
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            // Validate the indices
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-
-            // Return a KVP for each index
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-
-                    // Increment the counter for the number of values found so far
-                    ++numvalentries;
-                    // Add the value entry if past the starting index
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > starting_index)
-                    {
-                        char indexparam[16];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-                        indexparam[15] = NULL;
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_AUDIO_BITS_PER_SAMPLE_KEY,
-                                                         trackMetaDataInfo.iAudioBitsPerSample,
-                                                         indexparam);
-                    }
-
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY) != NULL)
-        {
-            /* Codec Name */
-            /* Determine the index requested. Default to all tracks */
-            uint32 startindex = 0;
-            uint32 endindex = iMetaDataInfo.iNumTracks - 1;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-            /* Return a KVP for each index */
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-
-                    PVMFSMTrackMetaDataInfo trackMetaDataInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-                    /* Increment the counter for the number of values found so far */
-                    ++numvalentries;
-                    /* Add the value entry if past the starting index */
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > (uint32)starting_index)
-                    {
-                        char indexparam[29];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-
-                        char* maxsizestr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_MAXSIZE);
-                        char* truncatestr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG);
-                        uint32 maxSize = 0xFFFFFFFF;
-                        if (maxsizestr != NULL)
-                        {
-                            if (GetMaxSizeValue(maxsizestr, maxSize) != PVMFSuccess)
-                            {
-                                break;
-                            }
-                        }
-
-                        uint32 truncateFlag = true;
-
-                        if (truncatestr != NULL)
-                        {
-                            if (GetTruncateFlagValue(truncatestr, truncateFlag) != PVMFSuccess)
-                            {
-                                break;
-                            }
-                        }
-
-                        uint32 codecNameLen = trackMetaDataInfo.iCodecName.get_size();
-                        char maxsizemessage[13];
-                        maxsizemessage[0] = '\0';
-                        if (maxSize < codecNameLen)
-
-                        {
-                            if (!truncateFlag)
-                            {
-                                oscl_snprintf(maxsizemessage, 13, ";%s%d", PVMFSTREAMINGMGRNODE_REQSIZE, codecNameLen);
-                                oscl_strncat(indexparam, maxsizemessage, oscl_strlen(maxsizemessage));
-                            }
-                        }
-
-                        retval =
-                            PVMFCreateKVPUtils::CreateKVPForWStringValue(trackkvp,
-                                    PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_NAME_KEY,
-                                    (trackMetaDataInfo.iCodecName),
-                                    indexparam, maxSize, truncateFlag);
-                    }
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY) != NULL)
-        {
-            /* Codec Description */
-            /* Determine the index requested. Default to all tracks */
-            uint32 startindex = 0;
-            uint32 endindex = (uint32)iMetaDataInfo.iNumTracks - 1;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-            /* Return a KVP for each index */
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-                    /* Increment the counter for the number of values found so far */
-                    ++numvalentries;
-                    /* Add the value entry if past the starting index */
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > (uint32)starting_index)
-                    {
-                        char indexparam[29];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-
-                        char* maxsizestr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_MAXSIZE);
-                        char* truncatestr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG);
-                        uint32 maxSize = 0xFFFFFFFF;
-                        if (maxsizestr != NULL)
-                        {
-                            if (GetMaxSizeValue(maxsizestr, maxSize) != PVMFSuccess)
-                            {
-                                break;
-                            }
-                        }
-
-                        uint32 truncateFlag = true;
-
-                        if (truncatestr != NULL)
-                        {
-                            if (GetTruncateFlagValue(truncatestr, truncateFlag) != PVMFSuccess)
-                            {
-                                break;
-                            }
-                        }
-
-                        uint32 codecDescLen = trackInfo.iCodecDescription.get_size();
-                        char maxsizemessage[13];
-                        maxsizemessage[0] = '\0';
-                        if (maxSize < codecDescLen)
-                        {
-                            if (!truncateFlag)
-                            {
-                                oscl_snprintf(maxsizemessage, 13, ";%s%d", PVMFSTREAMINGMGRNODE_REQSIZE, codecDescLen);
-                                oscl_strncat(indexparam, maxsizemessage, oscl_strlen(maxsizemessage));
-                            }
-                        }
-
-                        retval =
-                            PVMFCreateKVPUtils::CreateKVPForWStringValue(trackkvp,
-                                    PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DESCRIPTION_KEY,
-                                    (trackInfo.iCodecDescription),
-                                    indexparam, maxSize, truncateFlag);
-                    }
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY) != NULL)
-        {
-            /* Codec Description */
-            /* Determine the index requested. Default to all tracks */
-            uint32 startindex = 0;
-            uint32 endindex = (uint32)iMetaDataInfo.iNumTracks - 1;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-            /* Return a KVP for each index */
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-                    /* Increment the counter for the number of values found so far */
-                    ++numvalentries;
-                    /* Add the value entry if past the starting index */
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > (uint32)starting_index)
-                    {
-                        char indexparam[29];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-
-                        retval =
-                            PVMFCreateKVPUtils::CreateKVPForByteArrayValue(trackkvp,
-                                    PVMFSTREAMINGMGRNODE_TRACKINFO_CODEC_DATA_KEY,
-                                    (uint8*)(trackInfo.iCodecSpecificInfo.getMemFragPtr()),
-                                    (uint32)trackInfo.iCodecSpecificInfo.getMemFragSize()
-                                    , indexparam);
-                    }
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        else if (oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY) != NULL)
-        {
-            /* Codec Description */
-            /* Determine the index requested. Default to all tracks */
-            uint32 startindex = 0;
-            uint32 endindex = (uint32)iMetaDataInfo.iNumTracks - 1;
-            /* Check if the index parameter is present */
-            char* indexstr = oscl_strstr((*keylistptr)[lcv].get_cstr(), PVMFSTREAMINGMGRNODE_INDEX);
-            if (indexstr != NULL)
-            {
-                /* Retrieve the index values */
-                GetIndexParamValues(indexstr, startindex, endindex);
-            }
-            /* Validate the indices */
-            if (startindex > endindex || startindex >= iMetaDataInfo.iNumTracks || endindex >= iMetaDataInfo.iNumTracks)
-            {
-                continue;
-            }
-            /* Return a KVP for each index */
-            for (uint32 i = startindex; i <= endindex; ++i)
-            {
-                if (i < iMetaDataInfo.iTrackMetaDataInfoVec.size())
-                {
-                    PVMFSMTrackMetaDataInfo trackInfo = iMetaDataInfo.iTrackMetaDataInfoVec[i];
-                    PvmiKvp trackkvp;
-                    trackkvp.key = NULL;
-                    /* Increment the counter for the number of values found so far */
-                    ++numvalentries;
-                    /* Add the value entry if past the starting index */
-                    PVMFStatus retval = PVMFErrArgument;
-                    if (numvalentries > (uint32)starting_index)
-                    {
-                        char indexparam[29];
-                        oscl_snprintf(indexparam, 16, ";%s%d", PVMFSTREAMINGMGRNODE_INDEX, i);
-
-                        retval = CreateKVPForUInt32Value(trackkvp,
-                                                         PVMFSTREAMINGMGRNODE_TRACKINFO_TRACKID_KEY,
-                                                         trackInfo.iTrackID,
-                                                         indexparam);
-                    }
-                    if (retval != PVMFSuccess && retval != PVMFErrArgument)
-                    {
-                        break;
-                    }
-                    if (trackkvp.key != NULL)
-                    {
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, (*valuelistptr).push_back(trackkvp));
-                        if (leavecode != 0)
-                        {
-                            OSCL_ARRAY_DELETE(trackkvp.key);
-                            trackkvp.key = NULL;
-                        }
-                        else
-                        {
-                            // Increment the value list entry counter
-                            ++numentriesadded;
-                        }
-
-                        // Check if the max number of value entries were added
-                        if (max_entries > 0 && numentriesadded >= max_entries)
-                        {
-                            iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-                            return PVMFSuccess;
-                        }
-                    }
-                }
-            }
-        }
-        // Add the KVP to the list if the key string was created
-        if (KeyVal.key != NULL)
-        {
-            leavecode = 0;
-            OSCL_TRY(leavecode, (*valuelistptr).push_back(KeyVal));
-            if (leavecode != 0)
-            {
-                switch (GetValTypeFromKeyString(KeyVal.key))
-                {
-                    case PVMI_KVPVALTYPE_CHARPTR:
-                        if (KeyVal.value.pChar_value != NULL)
-                        {
-                            OSCL_ARRAY_DELETE(KeyVal.value.pChar_value);
-                            KeyVal.value.pChar_value = NULL;
-                        }
-                        break;
-
-                    default:
-                        // Add more case statements if other value types are returned
-                        break;
-                }
-
-                OSCL_ARRAY_DELETE(KeyVal.key);
-                KeyVal.key = NULL;
-            }
-            else
-            {
-                // Increment the counter for number of value entries added to the list
-                ++numentriesadded;
-            }
-
-            // Check if the max number of value entries were added
-            if (max_entries > 0 && numentriesadded >= max_entries)
-            {
-                // Maximum number of values added so break out of the loop
-                break;
-            }
-        }
-    }
-
-    iPVMFStreamingManagerNodeMetadataValueCount = (*valuelistptr).size();
-
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::CreateKVPForCharStringValue(PvmiKvp& aKeyVal, const char* aKeyTypeString, const char* aValString, char* aMiscKeyParam)
-{
-    // Check parameters
-    if (aKeyVal.key != NULL || aKeyTypeString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    // Determine the length of strings
-    uint32 keylen = oscl_strlen(aKeyTypeString) + 1; // for key string and ";"
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR) + 1; // for "char*" and NULL terminator
-    if (aMiscKeyParam)
-    {
-        keylen += oscl_strlen(aMiscKeyParam);
-    }
-
-    uint32 valuelen = oscl_strlen(aValString) + 1;
-
-    // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-             aKeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
-            );
-
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMFSTREAMINGMGRNODE_SEMICOLON, oscl_strlen(PVMFSTREAMINGMGRNODE_SEMICOLON));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = NULL_TERM_CHAR;
-        // Copy the value
-        oscl_strncpy(aKeyVal.value.pChar_value, aValString, valuelen);
-        aKeyVal.value.pChar_value[valuelen-1] = NULL_TERM_CHAR;
-        // Set the length and capacity
-        aKeyVal.length = valuelen;
-        aKeyVal.capacity = valuelen;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pChar_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pChar_value);
-        }
-
-        return PVMFErrNoMemory;
-    }
-
-    return PVMFSuccess;
-}
-
-
-PVMFStatus PVMFStreamingManagerNode::CreateKVPForWideCharStringValue(PvmiKvp& aKeyVal, const char* aKeyTypeString, const oscl_wchar* aValString, char* aMiscKeyParam)
-{
-    // Check parameters
-    if (aKeyVal.key != NULL || aKeyTypeString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    // Determine the length of strings
-    uint32 keylen = oscl_strlen(aKeyTypeString) + 1; // for key string and ";"
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR) + 1; // for "wchar*" and NULL terminator
-    if (aMiscKeyParam)
-    {
-        keylen += oscl_strlen(aMiscKeyParam);
-    }
-
-    uint32 valuelen = oscl_strlen(aValString) + 1;
-
-    // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-             aKeyVal.value.pWChar_value = OSCL_ARRAY_NEW(oscl_wchar, valuelen);
-            );
-
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMFSTREAMINGMGRNODE_SEMICOLON, oscl_strlen(PVMFSTREAMINGMGRNODE_SEMICOLON));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = NULL_TERM_CHAR;
-        // Copy the value
-        oscl_strncpy(aKeyVal.value.pWChar_value, aValString, valuelen);
-        aKeyVal.value.pWChar_value[valuelen-1] = NULL_TERM_CHAR;
-        // Set the length and capacity
-        aKeyVal.length = valuelen;
-        aKeyVal.capacity = valuelen;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pChar_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pWChar_value);
-        }
-
-        return PVMFErrNoMemory;
-    }
-
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::CreateKVPForUInt32Value(PvmiKvp& aKeyVal, const char* aKeyTypeString, uint32& aValueUInt32, char* aMiscKeyParam)
-{
-    // Check parameters
-    if (aKeyVal.key != NULL || aKeyTypeString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    // Determine the length of strings
-    uint32 keylen = oscl_strlen(aKeyTypeString) + 1; // for key string and ";"
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR) + 1; // for "uint32" and NULL terminator
-    if (aMiscKeyParam)
-    {
-        keylen += oscl_strlen(aMiscKeyParam);
-    }
-
-    // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-            );
-
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMFSTREAMINGMGRNODE_SEMICOLON, oscl_strlen(PVMFSTREAMINGMGRNODE_SEMICOLON));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = NULL_TERM_CHAR;
-        // Copy the value
-        aKeyVal.value.uint32_value = aValueUInt32;
-        // Set the length and capacity
-        aKeyVal.length = 1;
-        aKeyVal.capacity = 1;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-
-        return PVMFErrNoMemory;
-    }
-
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::CreateKVPForBoolValue(PvmiKvp& aKeyVal, const char* aKeyTypeString, bool& aValueBool, char* aMiscKeyParam)
-{
-    // Check parameters
-    if (aKeyVal.key != NULL || aKeyTypeString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    // Determine the length of strings
-    uint32 keylen = oscl_strlen(aKeyTypeString) + 1; // for key string and ";"
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR); // for "valtype="
-    keylen += oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR) + 1; // for "bool" and NULL terminator
-    if (aMiscKeyParam)
-    {
-        keylen += oscl_strlen(aMiscKeyParam);
-    }
-
-    // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-            );
-
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMFSTREAMINGMGRNODE_SEMICOLON, oscl_strlen(PVMFSTREAMINGMGRNODE_SEMICOLON));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = NULL_TERM_CHAR;
-        // Copy the value
-        aKeyVal.value.bool_value = aValueBool;
-        // Set the length and capacity
-        aKeyVal.length = 1;
-        aKeyVal.capacity = 1;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-
-        return PVMFErrNoMemory;
-    }
-
-    return PVMFSuccess;
-}
-
-
-PVMFCommandId
-PVMFStreamingManagerNode::GetNodeMetadataKeys(PVMFSessionId aSessionId,
-        PVMFMetadataList& aKeyList,
-        uint32 starting_index,
-        int32 max_entries,
-        char* query_key,
-        const OsclAny* aContextData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetNodeMetadataKeys - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAKEYS,
-            aKeyList,
-            starting_index,
-            max_entries,
-            query_key,
-            aContextData);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetNodeMetadataKeys - Out"));
-    return QueueCommandL(cmd);
-}
-
-PVMFCommandId
-PVMFStreamingManagerNode::GetNodeMetadataValues(PVMFSessionId aSessionId,
-        PVMFMetadataList& aKeyList,
-        Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
-        uint32 starting_index,
-        int32 max_entries,
-        const OsclAny* aContextData)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetNodeMetadataValues - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(aSessionId,
-            PVMF_STREAMING_MANAGER_NODE_GETNODEMETADATAVALUES,
-            aKeyList,
-            aValueList,
-            starting_index,
-            max_entries,
-            aContextData);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::GetNodeMetadataValues - Out"));
-    return QueueCommandL(cmd);
-}
-
-// From PVMFMetadataExtensionInterface
-PVMFStatus PVMFStreamingManagerNode::ReleaseNodeMetadataKeys(PVMFMetadataList& ,
-        uint32 ,
-        uint32)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::ReleaseNodeMetadataKeys() called"));
-    //nothing needed-- there's no dynamic allocation in this node's key list
-    return PVMFSuccess;
-}
-
-// From PVMFMetadataExtensionInterface
-PVMFStatus PVMFStreamingManagerNode::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
-        uint32 start,
-        uint32 end)
-{
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFStreamingManagerNode::ReleaseNodeMetadataValues() called"));
-
-    if (start > end || aValueList.size() == 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::ReleaseNodeMetadataValues() Invalid start/end index"));
-        return PVMFErrArgument;
-    }
-
-    //Only CPM related metadata is retrived. Then this one should be 0.
-    if (iPVMFStreamingManagerNodeMetadataValueCount == 0) return PVMFSuccess;
-
-    //To remove madatada related with un-drm value
-    end = iPVMFStreamingManagerNodeMetadataValueCount - 1;
-    if (end >= aValueList.size())
-    {
-        end = aValueList.size() - 1;
-    }
-
-    for (uint32 i = start; i <= end; i++)
-    {
-        if (aValueList[i].key != NULL)
-        {
-            switch (GetValTypeFromKeyString(aValueList[i].key))
-            {
-                case PVMI_KVPVALTYPE_WCHARPTR:
-                    if (aValueList[i].value.pWChar_value != NULL)
-                    {
-                        OSCL_ARRAY_DELETE(aValueList[i].value.pWChar_value);
-                        aValueList[i].value.pWChar_value = NULL;
-                    }
-                    break;
-
-                case PVMI_KVPVALTYPE_CHARPTR:
-                    if (aValueList[i].value.pChar_value != NULL)
-                    {
-                        OSCL_ARRAY_DELETE(aValueList[i].value.pChar_value);
-                        aValueList[i].value.pChar_value = NULL;
-                    }
-                    break;
-
-                case PVMI_KVPVALTYPE_UINT8PTR:
-                    if (aValueList[i].value.pUint8_value != NULL)
-                    {
-                        OSCL_ARRAY_DELETE(aValueList[i].value.pUint8_value);
-                        aValueList[i].value.pUint8_value = NULL;
-                    }
-                    break;
-
-                case PVMI_KVPVALTYPE_UINT32:
-                case PVMI_KVPVALTYPE_FLOAT:
-                case PVMI_KVPVALTYPE_BOOL:
-                    // No need to free memory for this valtype
-                    break;
-
-                default:
-                    // Should not get a value that wasn't created from this node
-                    OSCL_ASSERT(false);
-                    break;
-            }
-
-            OSCL_ARRAY_DELETE(aValueList[i].key);
-            aValueList[i].key = NULL;
-        }
-    }
-
-    return PVMFSuccess;
-}
-
-
-
-
-PVMFStatus PVMFStreamingManagerNode::getParametersSync(
-    PvmiMIOSession aSession, PvmiKeyType aIdentifier,
-    PvmiKvp*& aParameters, int& aNumParamElements,
-    PvmiCapabilityContext aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // Initialize the output parameters
-    aNumParamElements = 0;
-    aParameters = NULL;
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aIdentifier);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aIdentifier, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
-    {
-        // First component should be "x-pvmf" and there must
-        // be at least two components to go past x-pvmf
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::getParametersSync() Invalid key string"));
-        return PVMFErrArgument;
-    }
-
-    // Retrieve the second component from the key string
-    pv_mime_string_extract_type(1, aIdentifier, compstr);
-
-    // Check if it is key string for streaming manager
-    if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) < 0)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::getParametersSync() Unsupported key"));
-        return PVMFFailure;
-    }
-
-
-    if (compcount == 2)
-    {
-        // Since key is "x-pvmf/net" return all
-        // nodes available at this level. Ignore attribute
-        // since capability is only allowed
-
-        // Allocate memory for the KVP list
-        aParameters = (PvmiKvp*)oscl_malloc(StreamingManagerConfig_NumBaseKeys * sizeof(PvmiKvp));
-        if (aParameters == NULL)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::getParametersSync() Memory allocation for KVP failed"));
-            return PVMFErrNoMemory;
-        }
-        oscl_memset(aParameters, 0, StreamingManagerConfig_NumBaseKeys*sizeof(PvmiKvp));
-        // Allocate memory for the key strings in each KVP
-        PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(StreamingManagerConfig_NumBaseKeys * SMCONFIG_KEYSTRING_SIZE * sizeof(char));
-        if (memblock == NULL)
-        {
-            oscl_free(aParameters);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::getParametersSync() Memory allocation for key string failed"));
-            return PVMFErrNoMemory;
-        }
-        oscl_strset(memblock, 0, StreamingManagerConfig_NumBaseKeys*SMCONFIG_KEYSTRING_SIZE*sizeof(char));
-        // Assign the key string buffer to each KVP
-        uint32 j;
-        for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
-        {
-            aParameters[j].key = memblock + (j * SMCONFIG_KEYSTRING_SIZE);
-        }
-        // Copy the requested info
-        for (j = 0; j < StreamingManagerConfig_NumBaseKeys; ++j)
-        {
-            oscl_strncat(aParameters[j].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
-            oscl_strncat(aParameters[j].key, StreamingManagerConfig_BaseKeys[j].iString, oscl_strlen(StreamingManagerConfig_BaseKeys[j].iString));
-            oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";type="), 6);
-            switch (StreamingManagerConfig_BaseKeys[j].iType)
-            {
-                case PVMI_KVPTYPE_AGGREGATE:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_AGGREGATE_STRING), oscl_strlen(PVMI_KVPTYPE_AGGREGATE_STRING));
-                    break;
-
-                case PVMI_KVPTYPE_POINTER:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_POINTER_STRING), oscl_strlen(PVMI_KVPTYPE_POINTER_STRING));
-                    break;
-
-                case PVMI_KVPTYPE_VALUE:
-                default:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPTYPE_VALUE_STRING), oscl_strlen(PVMI_KVPTYPE_VALUE_STRING));
-                    break;
-            }
-            oscl_strncat(aParameters[j].key, _STRLIT_CHAR(";valtype="), 9);
-            switch (StreamingManagerConfig_BaseKeys[j].iValueType)
-            {
-                case PVMI_KVPVALTYPE_RANGE_INT32:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
-                    break;
-
-                case PVMI_KVPVALTYPE_KSV:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-                    break;
-
-                case PVMI_KVPVALTYPE_CHARPTR:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
-                    break;
-
-                case PVMI_KVPVALTYPE_BOOL:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
-                    break;
-
-                case PVMI_KVPVALTYPE_UINT32:
-                default:
-                    oscl_strncat(aParameters[j].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
-                    break;
-            }
-            aParameters[j].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
-        }
-
-        aNumParamElements = StreamingManagerConfig_NumBaseKeys;
-    }
-    else if (compcount == 3)
-    {
-        pv_mime_string_extract_type(2, aIdentifier, compstr);
-
-        // Determine what is requested
-        PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
-        if (reqattr == PVMI_KVPATTR_UNKNOWN)
-        {
-            reqattr = PVMI_KVPATTR_CUR;
-        }
-        uint i;
-        for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
-        {
-            if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
-            {
-                break;
-            }
-        }
-
-        if (i == StreamingManagerConfig_NumBaseKeys)
-        {
-            // no match found
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFStreamingManagerNode::getParametersSync() Unsupported key"));
-            return PVMFErrNoMemory;
-        }
-
-        PVMFStatus retval = GetConfigParameter(aParameters, aNumParamElements, i, reqattr);
-        if (retval != PVMFSuccess)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFStreamingManagerNode::getParametersSync() "
-                             "Retrieving streaming manager parameter failed"));
-            return retval;
-        }
-    }
-    else
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFStreamingManagerNode::getParametersSync() Unsupported key"));
-        return PVMFErrArgument;
-    }
-
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::releaseParameters(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int num_elements)
-{
-    OSCL_UNUSED_ARG(aSession);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFStreamingManagerNode::releaseParameters() In"));
-
-    if (aParameters == NULL || num_elements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMFStreamingManagerNode::releaseParameters() KVP list is NULL or number of elements is 0"));
-        return PVMFErrArgument;
-    }
-
-    // Count the number of components and parameters in the key
-    int compcount = pv_mime_string_compcnt(aParameters[0].key);
-    // Retrieve the first component from the key string
-    char* compstr = NULL;
-    pv_mime_string_extract_type(0, aParameters[0].key, compstr);
-
-    if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
-    {
-        // First component should be "x-pvmf" and there must
-        // be at least two components to go past x-pvmf
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMFStreamingManagerNode::releaseParameters() Unsupported key"));
-        return PVMFErrArgument;
-    }
-
-    // Retrieve the second component from the key string
-    pv_mime_string_extract_type(1, aParameters[0].key, compstr);
-
-    // Assume all the parameters come from the same component so the base components are the same
-    if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
-    {
-        // Go through each KVP and release memory for value if allocated from heap
-        for (int32 i = 0; i < num_elements; ++i)
-        {
-            // Next check if it is a value type that allocated memory
-            PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[i].key);
-            if (kvptype == PVMI_KVPTYPE_VALUE || kvptype == PVMI_KVPTYPE_UNKNOWN)
-            {
-                PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[i].key);
-                if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
-                {
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFStreamingManagerNode::releaseParameters() Valtype not specified in key string"));
-                    return PVMFErrArgument;
-                }
-
-                if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
-                {
-                    oscl_free(aParameters[i].value.pChar_value);
-                    aParameters[i].value.pChar_value = NULL;
-                }
-                else if (keyvaltype == PVMI_KVPVALTYPE_WCHARPTR && aParameters[i].value.pWChar_value != NULL)
-                {
-                    oscl_free(aParameters[i].value.pWChar_value);
-                    aParameters[i].value.pWChar_value = NULL;
-                }
-                else if (keyvaltype == PVMI_KVPVALTYPE_CHARPTR && aParameters[i].value.pChar_value != NULL)
-                {
-                    oscl_free(aParameters[i].value.pChar_value);
-                    aParameters[i].value.pChar_value = NULL;
-                }
-                else if (keyvaltype == PVMI_KVPVALTYPE_KSV && aParameters[i].value.key_specific_value != NULL)
-                {
-                    oscl_free(aParameters[i].value.key_specific_value);
-                    aParameters[i].value.key_specific_value = NULL;
-                }
-                else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_INT32 && aParameters[i].value.key_specific_value != NULL)
-                {
-                    range_int32* ri32 = (range_int32*)aParameters[i].value.key_specific_value;
-                    aParameters[i].value.key_specific_value = NULL;
-                    oscl_free(ri32);
-                }
-                else if (keyvaltype == PVMI_KVPVALTYPE_RANGE_UINT32 && aParameters[i].value.key_specific_value != NULL)
-                {
-                    range_uint32* rui32 = (range_uint32*)aParameters[i].value.key_specific_value;
-                    aParameters[i].value.key_specific_value = NULL;
-                    oscl_free(rui32);
-                }
-            }
-        }
-
-        oscl_free(aParameters[0].key);
-
-        // Free memory for the parameter list
-        oscl_free(aParameters);
-        aParameters = NULL;
-    }
-    else
-    {
-        // Unknown key string
-        return PVMFErrArgument;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFStreamingManagerNode::releaseParameters() Out"));
-    return PVMFSuccess;
-}
-
-void PVMFStreamingManagerNode::createContext(PvmiMIOSession aSession,
-        PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFStreamingManagerNode::setContextParameters(PvmiMIOSession aSession,
-        PvmiCapabilityContext& aContext,
-        PvmiKvp* aParameters,
-        int num_parameter_elements)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(num_parameter_elements);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFStreamingManagerNode::DeleteContext(PvmiMIOSession aSession,
-        PvmiCapabilityContext& aContext)
-{
-    OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aContext);
-    // not supported
-    OSCL_LEAVE(PVMFErrNotSupported);
-}
-
-void PVMFStreamingManagerNode::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-        int num_elements, PvmiKvp* &aRet_kvp)
-{
-    OSCL_UNUSED_ARG(aSession);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFStreamingManagerNode::setParametersSync() In"));
-
-
-    // Go through each parameter
-    for (int paramind = 0; paramind < num_elements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
-        {
-            // First component should be "x-pvmf" and there must
-            // be at least two components to go past x-pvmf
-            aRet_kvp = &aParameters[paramind];
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFStreamingManagerNode::setParametersSync() Unsupported key"));
-            return;
-        }
-
-        // Retrieve the second component from the key string
-        pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
-
-        // First check if it is key string for the streaming manager
-        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0)
-        {
-            if (compcount == 3)
-            {
-                pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
-                uint i;
-                for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
-                {
-                    if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
-                    {
-                        break;
-                    }
-                }
-
-                if (StreamingManagerConfig_NumBaseKeys == i)
-                {
-                    // invalid third component
-                    aRet_kvp = &aParameters[paramind];
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFStreamingManagerNode::setParametersSync() Unsupported key"));
-                    return;
-                }
-
-                // Verify and set the passed-in setting
-                PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], true);
-                if (retval != PVMFSuccess)
-                {
-                    aRet_kvp = &aParameters[paramind];
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                    (0, "PVMFStreamingManagerNode::setParametersSync() Setting "
-                                     "parameter %d failed", paramind));
-                    return;
-                }
-            }
-            else
-            {
-                // Do not support more than 3 components right now
-                aRet_kvp = &aParameters[paramind];
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PVMFStreamingManagerNode::setParametersSync() Unsupported key"));
-                return;
-            }
-        }
-        else
-        {
-            // Unknown key string
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PVMFStreamingManagerNode::setParametersSync() Unsupported key"));
-            return;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFStreamingManagerNode::setParametersSync() Out"));
-}
-
-PVMFCommandId PVMFStreamingManagerNode::setParametersAsync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int num_elements,
-        PvmiKvp*& aRet_kvp,
-        OsclAny* context)
-{
-
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::setParametersAsync - In"));
-    PVMFStreamingManagerNodeCommand cmd;
-    cmd.PVMFStreamingManagerNodeCommand::Construct(0,
-            PVMF_STREAMING_MANAGER_NODE_CAPCONFIG_SETPARAMS,
-            aSession, aParameters, num_elements, aRet_kvp, context);
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::setParametersAsync - Out"));
-    return QueueCommandL(cmd);
-}
-
-uint32 PVMFStreamingManagerNode::getCapabilityMetric(PvmiMIOSession aSession)
-{
-    OSCL_UNUSED_ARG(aSession);
-    return 0;
-}
-
-PVMFStatus PVMFStreamingManagerNode::verifyParametersSync(PvmiMIOSession aSession,
-        PvmiKvp* aParameters,
-        int num_elements)
-{
-    OSCL_UNUSED_ARG(aSession);
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFStreamingManagerNode::verifyParametersSync() In"));
-
-    if (aParameters == NULL || num_elements < 1)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
-                        (0, "PVMFStreamingManagerNode::verifyParametersSync() Passed in parameter invalid"));
-        return PVMFErrArgument;
-    }
-
-    // Go through each parameter and verify
-    for (int32 paramind = 0; paramind < num_elements; ++paramind)
-    {
-        // Count the number of components and parameters in the key
-        int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
-        // Retrieve the first component from the key string
-        char* compstr = NULL;
-        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
-
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf")) < 0) || compcount < 2)
-        {
-            // First component should be "x-pvmf" and there must
-            // be at least two components to go past x-pvmf
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::verifyParametersSync() Unsupported key"));
-            return PVMFErrArgument;
-        }
-
-        // Retrieve the second component from the key string
-        pv_mime_string_extract_type(1, aParameters[paramind].key, compstr);
-
-        // First check if it is key string for this node
-        if ((pv_mime_strcmp(compstr, _STRLIT_CHAR("net")) >= 0) && (compcount == 3))
-        {
-            pv_mime_string_extract_type(2, aParameters[paramind].key, compstr);
-            uint i;
-            for (i = 0; i < StreamingManagerConfig_NumBaseKeys; i++)
-            {
-                if (pv_mime_strcmp(compstr, (char*)(StreamingManagerConfig_BaseKeys[i].iString)) >= 0)
-                {
-                    break;
-                }
-            }
-
-            if (StreamingManagerConfig_NumBaseKeys == i)
-            {
-                return PVMFErrArgument;
-            }
-
-            // Verify the passed-in player setting
-            PVMFStatus retval = VerifyAndSetConfigParameter(i, aParameters[paramind], false);
-            if (retval != PVMFSuccess)
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoCapConfigVerifyParameters() Verifying parameter %d failed", paramind));
-                return retval;
-            }
-        }
-        else
-        {
-            // Unknown key string
-            return PVMFErrArgument;
-        }
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoCapConfigVerifyParameters() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::GetConfigParameter(PvmiKvp*& aParameters,
-        int& aNumParamElements,
-        int32 aIndex, PvmiKvpAttr reqattr)
-{
-    PVMF_SM_LOGINFO((0, "PVMFStreamingManagerNode::GetConfigParameter() In"));
-
-    aNumParamElements = 0;
-
-    // Allocate memory for the KVP
-    aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
-    if (aParameters == NULL)
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() Memory allocation for KVP failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_memset(aParameters, 0, sizeof(PvmiKvp));
-
-    // Allocate memory for the key string in KVP
-    PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(SMCONFIG_KEYSTRING_SIZE * sizeof(char));
-    if (memblock == NULL)
-    {
-        oscl_free(aParameters);
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() Memory allocation for key string failed"));
-        return PVMFErrNoMemory;
-    }
-    oscl_strset(memblock, 0, SMCONFIG_KEYSTRING_SIZE*sizeof(char));
-
-    // Assign the key string buffer to KVP
-    aParameters[0].key = memblock;
-
-    // Copy the key string
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/net/"), 17);
-    oscl_strncat(aParameters[0].key, StreamingManagerConfig_BaseKeys[aIndex].iString,
-                 oscl_strlen(StreamingManagerConfig_BaseKeys[aIndex].iString));
-    oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
-    switch (StreamingManagerConfig_BaseKeys[aIndex].iValueType)
-    {
-        case PVMI_KVPVALTYPE_RANGE_INT32:
-            oscl_strncat(aParameters[0].key,
-                         _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING),
-                         oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_KSV:
-            oscl_strncat(aParameters[0].key,
-                         _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING),
-                         oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_CHARPTR:
-            oscl_strncat(aParameters[0].key,
-                         _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING),
-                         oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_WCHARPTR:
-            oscl_strncat(aParameters[0].key,
-                         _STRLIT_CHAR(PVMI_KVPVALTYPE_WCHARPTR_STRING),
-                         oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_BOOL:
-            oscl_strncat(aParameters[0].key,
-                         _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING),
-                         oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
-            break;
-
-        case PVMI_KVPVALTYPE_UINT32:
-        default:
-            if (reqattr == PVMI_KVPATTR_CAP)
-            {
-                oscl_strncat(aParameters[0].key,
-                             _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING),
-                             oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
-            }
-            else
-            {
-                oscl_strncat(aParameters[0].key,
-                             _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING),
-                             oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
-            }
-            break;
-    }
-    aParameters[0].key[SMCONFIG_KEYSTRING_SIZE-1] = 0;
-
-    // Copy the requested info
-    switch (aIndex)
-    {
-        case BASEKEY_DELAY:
-            if (reqattr == PVMI_KVPATTR_CUR)
-            {
-                // Return current value
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->getJitterBufferDurationInMilliSeconds(aParameters[0].value.uint32_value);
-            }
-            else if (reqattr == PVMI_KVPATTR_DEF)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_DURATION_IN_MS;
-            }
-            else
-            {
-                // Return capability
-                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
-                if (rui32 == NULL)
-                {
-                    oscl_free(aParameters[0].key);
-                    oscl_free(aParameters);
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() "
-                                      "Memory allocation for range uint32 failed"));
-                    return PVMFErrNoMemory;
-                }
-                rui32->min = MIN_JITTER_BUFFER_DURATION_IN_MS;
-                rui32->max = MAX_JITTER_BUFFER_DURATION_IN_MS;
-                aParameters[0].value.key_specific_value = (void*)rui32;
-            }
-            break;
-        case BASEKEY_REBUFFERING_THRESHOLD:
-        {
-            if (reqattr == PVMI_KVPATTR_CUR)
-            {
-                // Return current value
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->getJitterBufferRebufferingThresholdInMilliSeconds(aParameters[0].value.uint32_value);
-            }
-            else if (reqattr == PVMI_KVPATTR_DEF)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
-            }
-            else
-            {
-                // Return capability
-                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
-                if (rui32 == NULL)
-                {
-                    oscl_free(aParameters[0].key);
-                    oscl_free(aParameters);
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() "
-                                      "Memory allocation for range uint32 failed"));
-                    return PVMFErrNoMemory;
-                }
-                rui32->min = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
-                rui32->max = DEFAULT_JITTER_BUFFER_UNDERFLOW_THRESHOLD_IN_MS;
-                aParameters[0].value.key_specific_value = (void*)rui32;
-            }
-        }
-        break;
-        case BASEKEY_JITTERBUFFER_NUMRESIZE:
-            if (reqattr == PVMI_KVPATTR_CUR)
-            {
-                // Return current value
-                uint32 numResize, resizeSize;
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
-                aParameters[0].value.uint32_value = numResize;
-            }
-            else if (reqattr == PVMI_KVPATTR_DEF)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = DEFAULT_MAX_NUM_SOCKETMEMPOOL_RESIZES;
-            }
-            else
-            {
-                // Return capability
-                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
-                if (rui32 == NULL)
-                {
-                    oscl_free(aParameters[0].key);
-                    oscl_free(aParameters);
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() "
-                                      "Memory allocation for range uint32 failed"));
-                    return PVMFErrNoMemory;
-                }
-                rui32->min = MIN_NUM_SOCKETMEMPOOL_RESIZES;
-                rui32->max = MAX_NUM_SOCKETMEMPOOL_RESIZES;
-                aParameters[0].value.key_specific_value = (void*)rui32;
-            }
-            break;
-        case BASEKEY_JITTERBUFFER_RESIZESIZE:
-            if (reqattr == PVMI_KVPATTR_CUR)
-            {
-                // Return current value
-                uint32 numResize, resizeSize;
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
-                aParameters[0].value.uint32_value = resizeSize;
-            }
-            else if (reqattr == PVMI_KVPATTR_DEF)
-            {
-                // Return default
-                aParameters[0].value.uint32_value = DEFAULT_MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
-            }
-            else
-            {
-                // Return capability
-                range_uint32* rui32 = (range_uint32*)oscl_malloc(sizeof(range_uint32));
-                if (rui32 == NULL)
-                {
-                    oscl_free(aParameters[0].key);
-                    oscl_free(aParameters);
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() "
-                                      "Memory allocation for range uint32 failed"));
-                    return PVMFErrNoMemory;
-                }
-                rui32->min = MIN_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
-                rui32->max = MAX_SOCKETMEMPOOL_RESIZELEN_INPUT_PORT;
-                aParameters[0].value.key_specific_value = (void*)rui32;
-            }
-            break;
-        case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
-            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-            {
-                aParameters[0].value.pWChar_value = NULL;
-                /* As of now just RTSP node supports an external config of user agent */
-                PVMFSMNodeContainer* iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                        (PVRTSPEngineNodeExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-
-                    OSCL_wHeapString<OsclMemAllocator> userAgent;
-                    if (rtspExtIntf->GetUserAgent(userAgent) == PVMFSuccess)
-                    {
-                        // Return current value
-                        oscl_wchar* ptr = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (userAgent.get_size()));
-                        if (ptr)
-                        {
-                            oscl_memcpy(ptr, userAgent.get_cstr(), userAgent.get_size());
-                            aParameters[0].value.pWChar_value = ptr;
-                        }
-                        else
-                        {
-                            oscl_free(aParameters[0].key);
-                            oscl_free(aParameters);
-                            PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter() "
-                                              "Memory allocation for user agent failed"));
-                            return PVMFErrNoMemory;
-                        }
-                    }
-                }
-            }
-            else
-            {
-                // Return capability - no concept of capability for user agent
-                // do nothing
-            }
-            break;
-        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL:
-        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
-            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-            {
-                if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
-                {
-                    aParameters[0].value.uint32_value = PVRTSPENGINENODE_DEFAULT_KEEP_ALIVE_INTERVAL;
-                }
-                else
-                {
-                    aParameters[0].value.bool_value = false;
-                }
-                /* As of now just RTSP node supports an external config of user agent */
-                PVMFSMNodeContainer* iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                        (PVRTSPEngineNodeExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-                    uint32 timeout;
-                    bool okeepalivemethod;
-                    bool okeepaliveinplay;
-                    rtspExtIntf->GetKeepAliveMethod((int32&)timeout, okeepalivemethod, okeepaliveinplay);
-                    if (aIndex == BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL)
-                    {
-                        aParameters[0].value.uint32_value = timeout;
-                    }
-                    else
-                    {
-                        aParameters[0].value.bool_value = okeepaliveinplay;
-                    }
-                }
-            }
-            else
-            {
-                // Return capability - no concept of capability for keep alive interval
-                // do nothing
-            }
-            break;
-
-        case BASEKEY_STREAMING_MGR_SWITCH_STREAMS:
-            /* Do nothing - things like current, default, and capability do not make sense here */
-            break;
-
-        case BASEKEY_STREAMING_SPEED:
-        {
-            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-            {
-                {
-                    aParameters[0].value.uint32_value = 1;
-                }
-            }
-            else
-            {
-                // Return capability - no concept of capability for streaming speed
-                // do nothing
-            }
-        }
-        break;
-
-        case BASEKEY_HTTP_VERSION:
-        {
-            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-            {
-                {
-                    oscl_free(aParameters[0].key);
-                    oscl_free(aParameters);
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::GetConfigParameter - HTTP Version Not Supported"));
-                    return PVMFErrArgument;
-                }
-            }
-            else
-            {
-                // Return capability - no concept of capability for http version
-                // do nothing
-            }
-        }
-        break;
-
-        case BASEKEY_NUM_REDIRECT_ATTEMPTS:
-        {
-            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-            {
-                {
-                    //seems like there is no reasonable default here ??
-                    aParameters[0].value.uint32_value = 0;
-                }
-            }
-            else
-            {
-                // Return capability - no concept of capability for num redirect attempts
-                // do nothing
-            }
-        }
-        break;
-
-        case BASEKEY_PROTOCOL_EXTENSION_HEADER:
-            /* Do nothing - things like current, default, and capability do not make sense here */
-            break;
-
-        case BASEKEY_SESSION_CONTROLLER_HTTP_TIMEOUT:
-            break;
-
-        case BASEKEY_SESSION_CONTROLLER_HTTP_STREAMING_LOGGING_TIMEOUT:
-            break;
-
-        case BASEKEY_ACCEL_BITRATE:
-            /* Do nothing - things like current, default, and capability do not make sense here */
-            break;
-
-        case BASEKEY_ACCEL_DURATION:
-            /* Do nothing - things like current, default, and capability do not make sense here */
-            break;
-        case BASEKEY_MAX_TCP_RECV_BUFFER_SIZE:
-        {
-            if (IsHttpExtensionHeaderValid(aParameters[0]))
-            {
-                PVMFSMNodeContainer* iSocketNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-                if (iSocketNodeContainer != NULL)
-                {
-                    PVMFSocketNode* socketNode =
-                        (PVMFSocketNode*)(iSocketNodeContainer->iNode);
-                    if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-                    {
-                        uint32 size = 0;
-                        socketNode->GetMaxTCPRecvBufferSize(size);
-                        aParameters[0].value.uint32_value = size;
-                    }
-                }
-            }
-        }
-        break;
-
-        case BASEKEY_DISABLE_FIREWALL_PACKETS:
-        {
-            if ((reqattr == PVMI_KVPATTR_CUR) || (reqattr == PVMI_KVPATTR_DEF))
-            {
-                aParameters[0].value.bool_value = false;
-            }
-        }
-        break;
-
-        default:
-            // Invalid index
-            oscl_free(aParameters[0].key);
-            oscl_free(aParameters);
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerEngine::DoGetPlayerParameter() Invalid index to player parameter"));
-            return PVMFErrArgument;
-    }
-
-    aNumParamElements = 1;
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerEngine::DoGetPlayerParameter() Out"));
-    return PVMFSuccess;
-}
-
-PVMFStatus PVMFStreamingManagerNode::VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set)
-{
-    PVMF_SM_LOGSTACKTRACE((0, "PVMFStreamingManagerNode::VerifyAndSetConfigParameter() In"));
-
-    // Determine the valtype
-    PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
-    if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::VerifyAndSetConfigParameter() "
-                          "Valtype in key string unknown"));
-        return PVMFErrArgument;
-    }
-
-    // Verify the valtype
-    if (keyvaltype != StreamingManagerConfig_BaseKeys[index].iValueType)
-    {
-        PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::VerifyAndSetConfigParameter() "
-                          "Valtype does not match for key"));
-        return PVMFErrArgument;
-    }
-
-    switch (index)
-    {
-        case BASEKEY_DELAY:
-        {
-            // Validate
-            if ((aParameter.value.uint32_value < MIN_JITTER_BUFFER_DURATION_IN_MS) ||
-                    (aParameter.value.uint32_value > MAX_JITTER_BUFFER_DURATION_IN_MS))
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::VerifyAndSetConfigParameter() "
-                                  "Trying to set delay to 0"));
-                return PVMFErrArgument;
-            }
-
-            if (set)
-            {
-                // save value locally
-                setJitterBufferDurationInMilliSeconds(aParameter.value.uint32_value);
-
-                // pass the value on to the jitter buffer node
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->setJitterBufferDurationInMilliSeconds(aParameter.value.uint32_value);
-            }
-        }
-        break;
-        case BASEKEY_REBUFFERING_THRESHOLD:
-        {
-            uint32 jbDuration = 0;
-            PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-            PVMFJitterBufferExtensionInterface* jbExtIntf =
-                (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-            jbExtIntf->getJitterBufferDurationInMilliSeconds(jbDuration);
-            // Validate
-            if (aParameter.value.uint32_value >= jbDuration)
-            {
-                PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::VerifyAndSetConfigParameter() "
-                                  "Trying to set rebuffering threshold greater than equal to jitter buffer duration"));
-                return PVMFErrArgument;
-            }
-            if (set)
-            {
-                // pass the value on to the jitter buffer node
-                jbExtIntf->setJitterBufferRebufferingThresholdInMilliSeconds(aParameter.value.uint32_value);
-            }
-        }
-        break;
-        case BASEKEY_JITTERBUFFER_NUMRESIZE:
-        {
-            if (set)
-            {
-                // retrieve and update
-                uint32 numResize, resizeSize;
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
-                jbExtIntf->SetSharedBufferResizeParams(aParameter.value.uint32_value, resizeSize);
-            }
-        }
-        break;
-        case BASEKEY_JITTERBUFFER_RESIZESIZE:
-        {
-            if (set)
-            {
-                // retrieve and update
-                uint32 numResize, resizeSize;
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->GetSharedBufferResizeParams(numResize, resizeSize);
-                jbExtIntf->SetSharedBufferResizeParams(numResize, aParameter.value.uint32_value);
-            }
-        }
-        break;
-        case BASEKEY_SESSION_CONTROLLER_USER_AGENT:
-        {
-            if (set)
-            {
-                // user agent update
-                PVMFSMNodeContainer* iSessionControllerNodeContainer = NULL;
-                iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                        (PVRTSPEngineNodeExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-
-                    OSCL_wHeapString<OsclMemAllocator> userAgent;
-                    OSCL_wHeapString<OsclMemAllocator> dummy;
-                    userAgent = aParameter.value.pWChar_value;
-                    rtspExtIntf->SetClientParameters(userAgent, dummy, dummy);
-                }
-                iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE);
-                OSCL_wHeapString<OsclMemAllocator> userAgent = aParameter.value.pWChar_value;
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface* httpExtIntf =
-                        (PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-
-                    httpExtIntf->SetUserAgent(userAgent);
-                }
-                // save user-agent kvp for cpm
-                if (iCPM)
-                {
-                    PVMFStatus status = iCPMKvpStore.addKVPString(aParameter.key, userAgent);
-                    if (status != PVMFSuccess) return status;
-                }
-
-            }
-        }
-        break;
-
-        case BASEKEY_HTTP_VERSION:
-        {
-            if (set)
-            {
-                PVMFSMNodeContainer* iSessionControllerNodeContainer = NULL;
-                iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVMF_SM_LOGERROR((0, "PVMFStreamingManagerNode::VerifyAndSetConfigParameter() "
-                                      "Setting HTTP Protocol Version Not supported"));
-                    return PVMFErrNotSupported;
-                }
-            }
-        }
-        break;
-
-        case BASEKEY_NUM_REDIRECT_ATTEMPTS:
-        {
-            if (set)
-            {
-                if (IsHttpExtensionHeaderValid(aParameter))
-                {
-                    PVMFSMNodeContainer* iSessionControllerNodeContainer = NULL;
-                    iSessionControllerNodeContainer =
-                        getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                    if (iSessionControllerNodeContainer != NULL)
-                    {
-                        //do nothing for now - till RTSP node has an api to set this
-                    }
-                    iSessionControllerNodeContainer =
-                        getNodeContainer(PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE);
-                    if (iSessionControllerNodeContainer != NULL)
-                    {
-                        PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface* httpExtIntf =
-                            (PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface*)
-                            (iSessionControllerNodeContainer->iExtensions[0]);
-
-                        httpExtIntf->SetNumRedirectTrials(aParameter.value.uint32_value);
-                    }
-                }
-                else
-                {
-                    OSCL_StackString<32> dlamode(_STRLIT_CHAR("mode=dla"));
-                    bool isDlaMode  = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), dlamode.get_cstr())  != NULL);
-                    if (isDlaMode)
-                    {
-                        if (iCPM)
-                        {
-                            PVMFStatus status = iCPMKvpStore.addKVPuint32Value(aParameter.key, aParameter.value.uint32_value);
-                            if (status != PVMFSuccess)
-                                return status;
-                        }
-                    }
-                }
-            }
-        }
-        break;
-
-        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_INTERVAL:
-        {
-            if (set)
-            {
-                // user agent update
-                /* As of now just RTSP node supports an external config of user agent */
-                PVMFSMNodeContainer* iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                        (PVRTSPEngineNodeExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-                    rtspExtIntf->SetKeepAliveMethod_timeout(aParameter.value.uint32_value);
-                }
-                iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_HTTP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface* httpExtIntf =
-                        (PVMFProtocolEngineNodeMSHTTPStreamingExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-                    httpExtIntf->SetKeepAliveTimeout(aParameter.value.uint32_value);
-                }
-
-            }
-        }
-        break;
-
-        case BASEKEY_SESSION_CONTROLLER_KEEP_ALIVE_DURING_PLAY:
-        {
-            if (set)
-            {
-                // keep-alive during play update
-                /* As of now just RTSP node supports an external config of keep-alive during play */
-                PVMFSMNodeContainer* iSessionControllerNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_RTSP_SESSION_CONTROLLER_NODE);
-                if (iSessionControllerNodeContainer != NULL)
-                {
-                    PVRTSPEngineNodeExtensionInterface* rtspExtIntf =
-                        (PVRTSPEngineNodeExtensionInterface*)
-                        (iSessionControllerNodeContainer->iExtensions[0]);
-                    rtspExtIntf->SetKeepAliveMethod_keep_alive_in_play(aParameter.value.bool_value);
-                }
-            }
-        }
-        break;
-
-
-
-        case BASEKEY_MAX_TCP_RECV_BUFFER_SIZE:
-        {
-            if (IsHttpExtensionHeaderValid(aParameter))
-            {
-                if (set)
-                {
-                    PVMFSMNodeContainer* iSocketNodeContainer =
-                        getNodeContainer(PVMF_STREAMING_MANAGER_SOCKET_NODE);
-                    if (iSocketNodeContainer != NULL)
-                    {
-                        PVMFSocketNode* socketNode =
-                            (PVMFSocketNode*)(iSocketNodeContainer->iNode);
-                        socketNode->SetMaxTCPRecvBufferSize(aParameter.value.uint32_value);
-                    }
-                }
-            }
-        }
-        break;
-
-        case BASEKEY_DISABLE_FIREWALL_PACKETS:
-        {
-            if (set)
-            {
-                PVMFSMNodeContainer* iJitterBufferNodeContainer =
-                    getNodeContainer(PVMF_STREAMING_MANAGER_JITTER_BUFFER_NODE);
-                PVMFJitterBufferExtensionInterface* jbExtIntf =
-                    (PVMFJitterBufferExtensionInterface*)iJitterBufferNodeContainer->iExtensions[0];
-                jbExtIntf->DisableFireWallPackets();
-            }
-        }
-        break;
-
-        default:
-            return PVMFErrNotSupported;
-    }
-
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
-                    (0, "PVMFStreamingManagerNode::VerifyAndSetPlayerParameter() Out"));
-
-    return PVMFSuccess;
-}
-
-// remove the ending ';', ',' or ' ' and calulate value length
-uint32 PVMFStreamingManagerNode::getItemLen(char *ptrItemStart, char *ptrItemEnd)
-{
-    char *ptr = ptrItemEnd - 1;
-    uint32 itemLen = ptr - ptrItemStart;
-    for (uint32 i = 0; i < itemLen; i++)
-    {
-        if (*ptr == ';' || *ptr == ',' || *ptr == ' ') --ptr;
-        else break;
-    }
-    itemLen = ptr - ptrItemStart + 1;
-    return itemLen;
-}
-
-
-bool PVMFStreamingManagerNode::IsInternalCmd(PVMFCommandId aId)
-{
-    if ((aId == PVMF_STREAMING_MANAGER_NODE_CONSTRUCT_SESSION) ||
-            (aId == PVMF_STREAMING_MANAGER_NODE_AUTO_PAUSE) ||
-            (aId == PVMF_STREAMING_MANAGER_NODE_AUTO_RESUME) ||
-            (aId == PVMF_STREAMING_MANAGER_NODE_THIN_STREAM))
-    {
-        return true;
-    }
-    return false;
-}
-
-bool PVMFStreamingManagerNode::IsHttpExtensionHeaderValid(PvmiKvp &aParameter)
-{
-    OSCL_StackString<32> downloadMode(_STRLIT_CHAR("mode=download"));
-    OSCL_StackString<32> streamingMode(_STRLIT_CHAR("mode=streaming"));
-    OSCL_StackString<32> dlaMode(_STRLIT_CHAR("mode=dla"));
-
-    bool isDownloadMode  = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), downloadMode.get_cstr())  != NULL);
-    bool isStreamingMode = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), streamingMode.get_cstr()) != NULL);
-    bool isDlaMode = (oscl_strstr(OSCL_CONST_CAST(char*, aParameter.key), dlaMode.get_cstr()) != NULL);
-
-
-    // download mode only would fail, streaming mode specified or not specified will be viewed as true
-    if (isDownloadMode && !isStreamingMode) return false;
-
-    // dla mode only would fail, streaming mode specified or not specified will be viewed as true
-    if (isDlaMode && !isStreamingMode) return false;
-
-
-    return true;
-}
-
-
-
-
-PVMFStatus
-PVMFStreamingManagerNode::GetMaxSizeValue(char* aString, uint32& aMaxSize)
-{
-    aMaxSize = 0xFFFFFFFF;
-    /*
-     * This parses a string of the form "maxsize=N1" and extracts the integer N1.
-     */
-    if (aString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    /* Go to end of "maxsize=" */
-    char* n1string = aString + 8;
-    char* truncatestr = oscl_strstr(n1string, PVMFSTREAMINGMGRNODE_TRUNCATE_FLAG);
-
-    uint32 maxsizelen = 0;
-
-    if (truncatestr != NULL)
-    {
-        maxsizelen = oscl_strlen(n1string) - (oscl_strlen(truncatestr) + 1);
-        n1string[maxsizelen] = '\0';
-    }
-
-    if (PV_atoi(n1string, 'd', oscl_strlen(n1string), aMaxSize))
-    {
-        return PVMFSuccess;
-    }
-    return PVMFFailure;
-}
-
-PVMFStatus
-PVMFStreamingManagerNode::GetTruncateFlagValue(char* aString, uint32& aTruncateFlag)
-{
-    aTruncateFlag = 0;
-    /*
-     * This parses a string of the form "truncate=N1" and extracts the integer N1.
-     */
-    if (aString == NULL)
-    {
-        return PVMFErrArgument;
-    }
-
-    /* Go to end of "truncate=" */
-    char* n1string = aString + 9;
-
-    if (!oscl_strcmp(n1string, "true"))
-    {
-        aTruncateFlag = true;
-    }
-    else if (!oscl_strcmp(n1string, "false"))
-    {
-        aTruncateFlag = false;
-    }
-    else
-    {
-        return PVMFFailure;
-    }
-    return PVMFSuccess;
 
 }
 
-
-
-
-
-void
-PVMFStreamingManagerNode::ResetNodeContainerCmdState()
+void PVMFStreamingManagerNode::removeRef()
 {
-    for (uint32 i = 0; i < iNodeContainerVec.size(); i++)
-    {
-        if (iNodeContainerVec[i].iNodeCmdState == PVMFSM_NODE_CMD_COMPLETE)
-        {
-            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_NO_PENDING;
-        }
-        else if (iNodeContainerVec[i].iNodeCmdState == PVMFSM_NODE_CMD_CANCEL_PENDING)
-        {
-            iNodeContainerVec[i].iNodeCmdState = PVMFSM_NODE_CMD_CANCEL_COMPLETE;
-        }
-    }
+
 }
-
-//////////////////// PVMFSMNodeKVPStore Implementation /////////////////////////////////////////////////////////
-
-// add kvp string with W-string value
-PVMFStatus PVMFSMNodeKVPStore::addKVPString(const char* aKeyTypeString, OSCL_wString& aValString)
-{
-    PvmiKvp aKeyVal;
-    aKeyVal.key = NULL;
-    PVMFStatus status = PVMFCreateKVPUtils::CreateKVPForWStringValue(aKeyVal, aKeyTypeString, aValString);
-    if (status != PVMFSuccess) return status;
-
-    int32 err = 0;
-    OSCL_TRY(err,
-             iKvpVector.push_back(aKeyVal);
-             KVPValueTypeForMemoryRelease valType = KVPValueTypeForMemoryRelease_WString;
-             iKVPValueTypeForMemoryRelease.push_back((uint32)valType);
-            );
-    return (err == 0 ? PVMFSuccess : PVMFErrNoMemory);
-}
-
-// add kvp string with normal string value
-PVMFStatus PVMFSMNodeKVPStore::addKVPString(const char* aKeyTypeString, const char* aValString)
-{
-    PvmiKvp aKeyVal;
-    aKeyVal.key = NULL;
-    PVMFStatus status = PVMFCreateKVPUtils::CreateKVPForCharStringValue(aKeyVal, aKeyTypeString, aValString);
-    if (status != PVMFSuccess) return status;
-
-    int32 err = 0;
-    OSCL_TRY(err,
-             iKvpVector.push_back(aKeyVal);
-             KVPValueTypeForMemoryRelease valType = KVPValueTypeForMemoryRelease_String;
-             iKVPValueTypeForMemoryRelease.push_back((uint32)valType);
-            );
-    return (err == 0 ? PVMFSuccess : PVMFErrNoMemory);
-}
-
-void PVMFSMNodeKVPStore::releaseMemory()
-{
-    OSCL_ASSERT(iKvpVector.size() == iKVPValueTypeForMemoryRelease.size());
-
-    for (uint32 i = 0; i < iKvpVector.size(); i++)
-    {
-        if (iKvpVector[i].key) OSCL_ARRAY_DELETE(iKvpVector[i].key);
-
-        // release memory for appropriate types of KVP value
-        if ((KVPValueTypeForMemoryRelease)iKVPValueTypeForMemoryRelease[i] == KVPValueTypeForMemoryRelease_WString &&
-                iKvpVector[i].value.pWChar_value) OSCL_ARRAY_DELETE(iKvpVector[i].value.pWChar_value);
-        if ((KVPValueTypeForMemoryRelease)iKVPValueTypeForMemoryRelease[i] == KVPValueTypeForMemoryRelease_String &&
-                iKvpVector[i].value.pChar_value) OSCL_ARRAY_DELETE(iKvpVector[i].value.pChar_value);
-    }
-}
-
-
-
-PVMFStatus PVMFSMNodeKVPStore::addKVPuint32Value(const char* aKeyTypeString, uint32 aValue)
-{
-    PvmiKvp aKeyVal;
-    aKeyVal.key = NULL;
-    PVMFStatus status = PVMFCreateKVPUtils::CreateKVPForUInt32Value(aKeyVal, aKeyTypeString, aValue);
-    if (status != PVMFSuccess) return status;
-
-    int32 err = 0;
-    OSCL_TRY(err,
-             iKvpVector.push_back(aKeyVal);
-             KVPValueTypeForMemoryRelease valType = KVPValueTypeForMemoryRelease_NoInterest;
-             iKVPValueTypeForMemoryRelease.push_back((uint32)valType);
-            );
-    return (err == 0 ? PVMFSuccess : PVMFErrNoMemory);
-}
-
-//Check for RTP packet source
-bool
-PVMFStreamingManagerNode::IsRTPPacketSourcePresent()
-{
-    return false;
-}
-
-
-
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.h b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.h
index 62b1541..b6fa7ac 100644
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.h
+++ b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,984 +18,77 @@
 #ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
 #define PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
 
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
-#include "oscl_string_containers.h"
-#endif
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
-#include "oscl_mem_mempool.h"
-#endif
-#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
-#include "oscl_scheduler_ao.h"
-#endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
-#endif
-#ifndef PVMF_NODE_UTILS_H_INCLUDED
-#include "pvmf_node_utils.h"
-#endif
-#ifndef PVMF_MEDIA_DATA_H_INCLUDED
-#include "pvmf_media_data.h"
-#endif
 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
 #include "pvmf_node_interface.h"
 #endif
-#ifndef PVMF_META_DATA_H_INCLUDED
-#include "pvmf_meta_data_types.h"
-#endif
-#ifndef PVMI_KVP_INCLUDED
-#include "pvmi_kvp.h"
-#endif
-#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
-#include "pvmi_config_and_capability.h"
-#endif
-#ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
-#include "pvmf_media_presentation_info.h"
-#endif
-#ifndef PVMF_STREAMING_REAL_INTERFACES_INCLUDED
-#include "pvmf_streaming_real_interfaces.h"
-#endif
-#ifndef MEDIAINFO_H
-#include "media_info.h"
-#endif
-#ifndef PAYLOAD_PARSER_H_INCLUDED
-#include "payload_parser.h"
-#endif
-#ifndef CPM_H_INCLUDED
-#include "cpm.h"
-#endif
-#ifndef PVMF_CPMPLUGIN_ACCESS_INTERFACE_H_INCLUDED
-#include "pvmf_cpmplugin_access_interface.h"
-#endif
-#ifndef PVMF_LOCAL_DATA_SOURCE_H_INCLUDED
-#include "pvmf_streaming_data_source.h"
-#endif
-#ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
-#include "pvmf_source_context_data.h"
-#endif
-#ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
-#include "pvmf_meta_data_extension.h"
-#endif
-#ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED
-#include "pvmf_cpmplugin_license_interface.h"
-#endif
-#ifndef PVMF_SM_CONFIG_H_INCLUDED
-#include "pvmf_sm_config.h"
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
 #endif
 
-class PVLogger;
-class PVMFStreamingManagerExtensionInterfaceImpl;
-class PVMFSMSessionSourceInfo;
-class rm_mediaInfo;
-class PVMFDataSourcePositionParams;
+#ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED
+#include "pvmf_data_source_init_extension.h"
+#endif
 
-/* memory allocator type for this node */
-typedef OsclMemAllocator PVMFStreamingManagerNodeAllocator;
+#ifndef PVMF_SM_FSP_BASE_IMPL_H
+#include "pvmf_sm_fsp_base_impl.h"
+#endif
 
-/*
- * Node command type & command proc related data structures
- */
-#define PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE 40
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
 
-typedef PVMFGenericNodeCommand < PVMFStreamingManagerNodeAllocator > PVMFStreamingManagerNodeCommandBase;
-class PVMFStreamingManagerNodeCommand : public PVMFStreamingManagerNodeCommandBase
+class PVMFSMFSPRegistry;
+
+//Logging macros
+#define PVMF_SM_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
+#define PVMF_SM_LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_NOTICE,m);
+#define PVMF_SM_LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m);
+#define PVMF_SM_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_STACK_TRACE,m);
+
+typedef PVMFGenericNodeCommand <OsclMemAllocator> PVMFStreamingManagerNodeCommand;
+typedef PVMFNodeCommandQueue<PVMFStreamingManagerNodeCommand, OsclMemAllocator> PVMFStreamingManagerNodeCmdQ;
+
+/* Default vector reserve size */
+#define PVMF_STREAMING_MANAGER_NODE_COMMAND_ID_START	9000
+#define PVMF_STREAMING_MANAGER_VECTOR_RESERVE 10
+
+///////////////////////////////////////////////
+//IDs for all of the asynchronous node commands.
+///////////////////////////////////////////////
+enum TPVMFStreamingManagerNodeCommand
 {
-    public:
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       int32 arg1,
-                       int32 arg2,
-                       int32& arg3,
-                       const OsclAny*aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)arg1;
-            iParam2 = (OsclAny*)arg2;
-            iParam3 = (OsclAny*) & arg3;
-        };
-
-        void Parse(int32&arg1, int32&arg2, int32*&arg3)
-        {
-            arg1 = (int32)iParam1;
-            arg2 = (int32)iParam2;
-            arg3 = (int32*)iParam3;
-        };
-
-        /* Constructor and parser for SetDataSourcePosition */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       PVMFTimestamp aTargetNPT,
-                       PVMFTimestamp* aActualNPT,
-                       PVMFTimestamp* aActualMediaDataTS,
-                       bool aSeekToSyncPoint,
-                       uint32 aStreamID,
-                       const OsclAny*aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aTargetNPT;
-            iParam2 = (OsclAny*)aActualNPT;
-            iParam3 = (OsclAny*)aActualMediaDataTS;
-            iParam4 = (OsclAny*)aSeekToSyncPoint;
-            iParam5 = (OsclAny*)aStreamID;
-        };
-
-        void Parse(PVMFTimestamp& aTargetNPT,
-                   PVMFTimestamp* &aActualNPT,
-                   PVMFTimestamp* &aActualMediaDataTS,
-                   bool& aSeekToSyncPoint,
-                   uint32& aStreamID)
-        {
-            aTargetNPT = (PVMFTimestamp)iParam1;
-            aActualNPT = (PVMFTimestamp*)iParam2;
-            aActualMediaDataTS = (PVMFTimestamp*)iParam3;
-            aSeekToSyncPoint = (iParam4 ? true : false);
-            aStreamID = (uint32)iParam5;
-        };
-
-        /* Constructor and parser for SetDataSourcePosition - Playlist */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       PVMFDataSourcePositionParams* aParams,
-                       const OsclAny*aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aParams;
-            iParam2 = NULL;
-            iParam3 = NULL;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        };
-
-        void Parse(PVMFDataSourcePositionParams*& aParams)
-        {
-            aParams = (PVMFDataSourcePositionParams*)iParam1;
-        };
-
-
-        /* Constructor and parser for QueryDataSourcePosition */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       PVMFTimestamp aTargetNPT,
-                       PVMFTimestamp* aActualNPT,
-                       bool aSeekToSyncPoint,
-                       const OsclAny*aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aTargetNPT;
-            iParam2 = (OsclAny*)aActualNPT;
-            iParam3 = (OsclAny*)aSeekToSyncPoint;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        };
-
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       PVMFTimestamp aTargetNPT,
-                       PVMFTimestamp* aSeekPointBeforeTargetNPT,
-                       PVMFTimestamp* aSeekPointAfterTargetNPT,
-                       const OsclAny*aContext,
-                       bool aSeekToSyncPoint
-                      )
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aTargetNPT;
-            iParam3 = (OsclAny*)aSeekToSyncPoint;
-            iParam4 = aSeekPointBeforeTargetNPT;
-            iParam5 = aSeekPointAfterTargetNPT;
-        };
-
-        void Parse(PVMFTimestamp& aTargetNPT,
-                   PVMFTimestamp* &aActualNPT,
-                   bool& aSeekToSyncPoint)
-        {
-            aTargetNPT = (PVMFTimestamp)iParam1;
-            aActualNPT = (PVMFTimestamp*)iParam2;
-            aSeekToSyncPoint = (iParam3 ? true : false);
-        };
-
-        void Parse(PVMFTimestamp& aTargetNPT,
-                   PVMFTimestamp*& aSeekPointBeforeTargetNPT,
-                   bool& aSeekToSyncPoint,
-                   PVMFTimestamp*& aSeekPointAfterTargetNPT)
-
-        {
-            aTargetNPT = (PVMFTimestamp)iParam1;
-            aSeekToSyncPoint = (iParam3) ? true : false;
-            aSeekPointBeforeTargetNPT = (PVMFTimestamp*)iParam4;
-            aSeekPointAfterTargetNPT = (PVMFTimestamp*)iParam5;
-        }
-
-
-        /* Constructor and parser for SetDataSourceRate */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       int32 aRate,
-                       OsclTimebase* aTimebase,
-                       const OsclAny* aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aRate;
-            iParam2 = (OsclAny*)aTimebase;
-            iParam3 = NULL;
-            iParam4 = NULL;
-            iParam5 = NULL;
-        };
-
-        void Parse(int32& aRate, OsclTimebase*& aTimebase)
-        {
-            aRate = (int32)iParam1;
-            aTimebase = (OsclTimebase*)iParam2;
-        }
-
-        /* Constructor and parser for GetNodeMetadataKeys */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       PVMFMetadataList& aKeyList,
-                       int32 aStartingIndex,
-                       int32 aMaxEntries,
-                       char* aQueryKey,
-                       const OsclAny* aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*) & aKeyList;
-            iParam2 = (OsclAny*)aStartingIndex;
-            iParam3 = (OsclAny*)aMaxEntries;
-            if (aQueryKey)
-            {
-                /*allocate a copy of the query key string */
-                Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
-                iParam4 = str.ALLOC_AND_CONSTRUCT(aQueryKey);
-            }
-        }
-
-        void Parse(PVMFMetadataList*& MetaDataListPtr,
-                   uint32 &aStartingIndex,
-                   int32 &aMaxEntries,
-                   char*& aQueryKey)
-        {
-            MetaDataListPtr = (PVMFMetadataList*)iParam1;
-            aStartingIndex = (uint32)iParam2;
-            aMaxEntries = (int32)iParam3;
-            aQueryKey = NULL;
-            if (iParam4)
-            {
-                OSCL_HeapString<OsclMemAllocator>* keystring =
-                    (OSCL_HeapString<OsclMemAllocator>*)iParam4;
-                aQueryKey = keystring->get_str();
-            }
-        }
-
-        /* Constructor and parser for GetNodeMetadataValue */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       PVMFMetadataList& aKeyList,
-                       Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
-                       uint32 aStartIndex,
-                       int32 aMaxEntries,
-                       const OsclAny* aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*) & aKeyList;
-            iParam2 = (OsclAny*) & aValueList;
-            iParam3 = (OsclAny*)aStartIndex;
-            iParam4 = (OsclAny*)aMaxEntries;
-
-        }
-
-        void Parse(PVMFMetadataList* &aKeyList,
-                   Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList,
-                   uint32 &aStartingIndex,
-                   int32 &aMaxEntries)
-        {
-            aKeyList = (PVMFMetadataList*)iParam1;
-            aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
-            aStartingIndex = (uint32)iParam3;
-            aMaxEntries = (int32)iParam4;
-        }
-
-        /* Constructor and parser for GetLicenseW */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       OSCL_wString& aContentName,
-                       OsclAny* aLicenseData,
-                       uint32 aDataSize,
-                       int32 aTimeoutMsec,
-                       const OsclAny* aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*) & aContentName;
-            iParam2 = (OsclAny*)aLicenseData;
-            iParam3 = (OsclAny*)aDataSize;
-            iParam4 = (OsclAny*)aTimeoutMsec;
-            iParam5 = NULL;
-        }
-
-        void Parse(OSCL_wString*& aContentName,
-                   OsclAny*& aLicenseData,
-                   uint32& aDataSize,
-                   int32& aTimeoutMsec)
-        {
-            aContentName = (OSCL_wString*)iParam1;
-            aLicenseData = (PVMFTimestamp*)iParam2;
-            aDataSize = (uint32)iParam3;
-            aTimeoutMsec = (int32)iParam4;
-        }
-
-        /* Constructor and parser for GetLicense */
-        void Construct(PVMFSessionId s,
-                       int32 cmd,
-                       OSCL_String& aContentName,
-                       OsclAny* aLicenseData,
-                       uint32 aDataSize,
-                       int32 aTimeoutMsec,
-                       const OsclAny*aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*) & aContentName;
-            iParam2 = (OsclAny*)aLicenseData;
-            iParam3 = (OsclAny*)aDataSize;
-            iParam4 = (OsclAny*)aTimeoutMsec;
-            iParam5 = NULL;
-        };
-        void Parse(OSCL_String*& aContentName,
-                   OsclAny*& aLicenseData,
-                   uint32& aDataSize,
-                   int32& aTimeoutMsec)
-        {
-            aContentName = (OSCL_String*)iParam1;
-            aLicenseData = (PVMFTimestamp*)iParam2;
-            aDataSize = (uint32)iParam3;
-            aTimeoutMsec = (int32)iParam4;
-        }
-
-        /* Constructor and parser for setParametersAsync */
-        void Construct(PVMFSessionId s, int32 cmd, PvmiMIOSession aSession,
-                       PvmiKvp* aParameters, int num_elements,
-                       PvmiKvp*& aRet_kvp, OsclAny* aContext)
-        {
-            PVMFStreamingManagerNodeCommandBase::Construct(s, cmd, aContext);
-            iParam1 = (OsclAny*)aSession;
-            iParam2 = (OsclAny*)aParameters;
-            iParam3 = (OsclAny*)num_elements;
-            iParam4 = (OsclAny*) & aRet_kvp;
-        }
-        void Parse(PvmiMIOSession& aSession, PvmiKvp*& aParameters,
-                   int &num_elements, PvmiKvp** &ppRet_kvp)
-        {
-            aSession = (PvmiMIOSession)iParam1;
-            aParameters = (PvmiKvp*)iParam2;
-            num_elements = (int)iParam3;
-            ppRet_kvp = (PvmiKvp**)iParam4;
-        }
-
-        /* need to overlaod the base Copy routine to copy metadata key */
-        void Copy(const PVMFGenericNodeCommand<OsclMemAllocator>& aCmd);
-
-        /* need to overlaod the base Destroy routine to cleanup metadata key */
-        void Destroy();
+    PVMF_STREAMING_MANAGER_NODE_QUERYINTERFACE = PVMF_GENERIC_NODE_QUERYINTERFACE,
+    PVMF_STREAMING_MANAGER_NODE_RESET = PVMF_GENERIC_NODE_RESET,
+    PVMF_STREAMING_MANAGER_NODE_CANCELALLCOMMANDS = PVMF_GENERIC_NODE_CANCELALLCOMMANDS,
+    PVMF_STREAMING_MANAGER_NODE_CANCELCOMMAND = PVMF_GENERIC_NODE_CANCELCOMMAND,
+    PVMF_STREAMING_MANAGER_NODE_COMMAND_LAST
 };
 
-typedef PVMFNodeCommandQueue<PVMFStreamingManagerNodeCommand, PVMFStreamingManagerNodeAllocator> PVMFStreamingManagerNodeCmdQ;
-
-typedef struct tagPVMFSMPortContext
-{
-    uint32 trackID;
-    uint32 portTag;
-} PVMFSMPortContext;
-
-class PVMFSMCommandContext
-{
-    public:
-        PVMFSMCommandContext()
-        {
-            parentCmd = 0;
-            cmd = 0;
-            oFree = true;
-            portContext.trackID = 0;
-            portContext.portTag = 0;
-            oInternalCmd = false;
-        };
-
-        bool oInternalCmd;
-        int32 parentCmd;
-        int32 cmd;
-        bool  oFree;
-        PVMFSMPortContext portContext;
-};
-
-class PVMFSMTrackMetaDataInfo
-{
-    public:
-        PVMFSMTrackMetaDataInfo()
-        {
-            iTrackDurationAvailable = false;
-            iTrackDuration = 0;
-            iTrackDurationTimeScale = 0;
-            iTrackBitRate = 0;
-            iTrackMaxBitRate = 0;
-            iTrackSelected = false;
-            iTrackID = iTrackID;
-            iCodecName = NULL;
-            iCodecDescription = NULL;
-            iTrackWidth = 0;
-            iTrackHeight = 0;
-            iVideoFrameRate = 0;
-            iAudioSampleRate = 0;
-            iAudioNumChannels = 0;
-            iAudioBitsPerSample = 0;
-        };
-
-        PVMFSMTrackMetaDataInfo(const PVMFSMTrackMetaDataInfo& a)
-        {
-            iTrackDurationAvailable = a.iTrackDurationAvailable;
-            iTrackDuration = a.iTrackDuration;
-            iTrackDurationTimeScale = a.iTrackDurationTimeScale;
-            iMimeType = a.iMimeType;
-            iTrackBitRate = a.iTrackBitRate;
-            iTrackMaxBitRate = a.iTrackMaxBitRate;
-            iTrackSelected = a.iTrackSelected;
-            iTrackID = a.iTrackID;
-            iCodecName = a.iCodecName;
-            iCodecDescription = a.iCodecDescription;
-            iCodecSpecificInfo = a.iCodecSpecificInfo;
-            iTrackWidth = a.iTrackWidth;
-            iTrackHeight = a.iTrackHeight;
-            iVideoFrameRate = a.iVideoFrameRate;
-            iAudioSampleRate = a.iAudioSampleRate;
-            iAudioNumChannels = a.iAudioNumChannels;
-            iAudioBitsPerSample = a.iAudioBitsPerSample;
-        };
-
-        PVMFSMTrackMetaDataInfo& operator=(const PVMFSMTrackMetaDataInfo& a)
-        {
-            if (&a != this)
-            {
-                iTrackDurationAvailable = a.iTrackDurationAvailable;
-                iTrackDuration = a.iTrackDuration;
-                iTrackDurationTimeScale = a.iTrackDurationTimeScale;
-                iMimeType = a.iMimeType;
-                iTrackBitRate = a.iTrackBitRate;
-                iTrackMaxBitRate = a.iTrackMaxBitRate;
-                iTrackSelected = a.iTrackSelected;
-                iTrackID = a.iTrackID;
-                iCodecName = a.iCodecName;
-                iCodecDescription = a.iCodecDescription;
-                iCodecSpecificInfo = a.iCodecSpecificInfo;
-                iTrackWidth = a.iTrackWidth;
-                iTrackHeight = a.iTrackHeight;
-                iVideoFrameRate = a.iVideoFrameRate;
-                iAudioSampleRate = a.iAudioSampleRate;
-                iAudioNumChannels = a.iAudioNumChannels;
-                iAudioBitsPerSample = a.iAudioBitsPerSample;
-            }
-            return (*this);
-        };
-
-        bool   iTrackDurationAvailable;
-        uint64 iTrackDuration;
-        uint64 iTrackDurationTimeScale;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iMimeType;
-        uint32 iTrackBitRate;
-        uint32 iTrackMaxBitRate;
-        bool   iTrackSelected;
-        uint32 iTrackID;
-        OSCL_wHeapString<OsclMemAllocator> iCodecName;
-        OSCL_wHeapString<OsclMemAllocator> iCodecDescription;
-        uint32 iTrackWidth;
-        uint32 iTrackHeight;
-        uint32 iVideoFrameRate;
-        uint32 iAudioSampleRate;
-        uint32 iAudioNumChannels;
-        uint32 iAudioBitsPerSample;
-        OsclRefCounterMemFrag iCodecSpecificInfo;
-};
-
-class PVMFSMSessionMetaDataInfo
-{
-    public:
-        PVMFSMSessionMetaDataInfo()
-        {
-            iTitlePresent = false;
-            iDescriptionPresent = false;
-            iCopyRightPresent = false;
-            iPerformerPresent = false;
-            iAuthorPresent = false;
-            iGenrePresent = false;
-            iRatingPresent = false;
-            iClassificationPresent = false;
-            iKeyWordsPresent = false;
-            iLocationPresent = false;
-            iLyricsPresent = false;
-            iWMPicturePresent = false;
-
-            iIsTitleUnicode = false;
-            iIsDescriptionUnicode = false;
-            iIsCopyRightUnicode = false;
-            iIsPerformerUnicode = false;
-            iIsAuthorUnicode = false;
-            iIsGenreUnicode = false;
-            iIsRatingUnicode = false;
-            iIsClassificationUnicode = false;
-            iIsKeyWordsUnicode = false;
-            iIsLocationUnicode = false;
-            iIsLyricsUnicode = false;
-
-            iSessionDuration = 0;
-            iSessionDurationTimeScale = 0;
-            iNumTracks = 0;
-            iSessionDurationAvailable = false;
-            iSessionDuration = 0;
-            iSessionDurationTimeScale = 0;
-            iNumTracks = 0;
-            iRandomAccessDenied = false;
-            iNumWMPicture = 0;
-
-            iExtendedMetaDataDescriptorCount = 0;
-        };
-
-        void Reset()
-        {
-            iTitlePresent = false;
-            iDescriptionPresent = false;
-            iCopyRightPresent = false;
-            iPerformerPresent = false;
-            iAuthorPresent = false;
-            iGenrePresent = false;
-            iRatingPresent = false;
-            iClassificationPresent = false;
-            iKeyWordsPresent = false;
-            iLocationPresent = false;
-            iLyricsPresent = false;
-            iWMPicturePresent = false;
-
-            iIsTitleUnicode = false;
-            iIsDescriptionUnicode = false;
-            iIsCopyRightUnicode = false;
-            iIsPerformerUnicode = false;
-            iIsAuthorUnicode = false;
-            iIsGenreUnicode = false;
-            iIsRatingUnicode = false;
-            iIsClassificationUnicode = false;
-            iIsKeyWordsUnicode = false;
-            iIsLocationUnicode = false;
-            iIsLyricsUnicode = false;
-
-            iSessionDurationAvailable = false;
-            iSessionDuration = 0;
-            iSessionDurationTimeScale = 0;
-            iNumTracks = 0;
-            iRandomAccessDenied = false;
-            iNumWMPicture = 0;
-
-            iExtendedMetaDataNameVec.clear();
-            iExtendedMetaDataValueTypeVec.clear();
-            iExtendedMetaDataValueLenVec.clear();
-            iExtendedMetaDataIndexVec.clear();
-
-            iTrackMetaDataInfoVec.clear();
-        };
-
-        PVMFSMTrackMetaDataInfo* getTrackMetaDataInfo(uint32 aId)
-        {
-            Oscl_Vector<PVMFSMTrackMetaDataInfo, PVMFStreamingManagerNodeAllocator>::iterator it;
-            for (it = iTrackMetaDataInfoVec.begin(); it != iTrackMetaDataInfoVec.end(); it++)
-            {
-                if (it->iTrackID == aId)
-                {
-                    return (it);
-                }
-            }
-            return NULL;
-        };
-
-        bool iTitlePresent;
-        bool iDescriptionPresent;
-        bool iCopyRightPresent;
-        bool iPerformerPresent;
-        bool iAuthorPresent;
-        bool iGenrePresent;
-        bool iRatingPresent;
-        bool iClassificationPresent;
-        bool iKeyWordsPresent;
-        bool iLocationPresent;
-        bool iLyricsPresent;
-        bool iWMPicturePresent;
-
-        bool iIsTitleUnicode;
-        bool iIsDescriptionUnicode;
-        bool iIsCopyRightUnicode;
-        bool iIsPerformerUnicode;
-        bool iIsAuthorUnicode;
-        bool iIsGenreUnicode;
-        bool iIsRatingUnicode;
-        bool iIsClassificationUnicode;
-        bool iIsKeyWordsUnicode;
-        bool iIsLocationUnicode;
-        bool iIsLyricsUnicode;
-        uint32 iNumWMPicture;
-
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iTitle;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iDescription;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iCopyright;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iPerformer;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iAuthor;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iGenre;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iRating;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iClassification;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iKeyWords;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iLocation;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iLyrics;
-
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iTitleUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iDescriptionUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iCopyrightUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iPerformerUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iAuthorUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iGenreUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iRatingUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iClassificationUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iKeyWordUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iLocationUnicode;
-        OSCL_wHeapString<PVMFStreamingManagerNodeAllocator> iLyricsUnicode;
-
-        bool   iSessionDurationAvailable;
-        uint64 iSessionDuration;
-        uint64 iSessionDurationTimeScale;
-        uint32 iNumTracks;
-        bool   iRandomAccessDenied;
-
-        Oscl_Vector<PVMFSMTrackMetaDataInfo, PVMFStreamingManagerNodeAllocator> iTrackMetaDataInfoVec;
-
-        uint32 iExtendedMetaDataDescriptorCount;
-        Oscl_Vector<OSCL_HeapString<PVMFStreamingManagerNodeAllocator>, PVMFStreamingManagerNodeAllocator> iExtendedMetaDataNameVec;
-        Oscl_Vector<uint16, PVMFStreamingManagerNodeAllocator> iExtendedMetaDataValueTypeVec;
-        Oscl_Vector<uint32, PVMFStreamingManagerNodeAllocator> iExtendedMetaDataValueLenVec;
-        Oscl_Vector<uint32, PVMFStreamingManagerNodeAllocator> iExtendedMetaDataIndexVec;
-        Oscl_Vector<uint32, PVMFStreamingManagerNodeAllocator> iWMPictureIndexVec;
-};
-
-
-/*
- * Structure to contain a node and all ports and extensions associated to it
- */
-enum PVMFSMNodeCmdState
-{
-    PVMFSM_NODE_CMD_PENDING,
-    PVMFSM_NODE_CMD_COMPLETE,
-    PVMFSM_NODE_CMD_NO_PENDING,
-    PVMFSM_NODE_CMD_CANCEL_PENDING,
-    PVMFSM_NODE_CMD_CANCEL_COMPLETE
-};
-
-class PVMFSMNodeContainer
-{
-    public:
-        PVMFSMNodeContainer()
-        {
-            iAutoPaused = false;
-            iNodeCmdState = PVMFSM_NODE_CMD_NO_PENDING;
-        };
-
-        PVMFSMNodeContainer(const PVMFSMNodeContainer& inContainer)
-        {
-            commandStartOffset = inContainer.commandStartOffset;
-            iNode = inContainer.iNode;
-            iSessionId = inContainer.iSessionId;
-            iNodeTag = inContainer.iNodeTag;
-            iInputPorts = inContainer.iInputPorts;
-            iOutputPorts = inContainer.iOutputPorts;
-            iFeedBackPorts = inContainer.iFeedBackPorts;
-            iExtensions = inContainer.iExtensions;
-            iExtensionUuids = inContainer.iExtensionUuids;
-            iAutoPaused = inContainer.iAutoPaused;
-            iNodeCmdState = inContainer.iNodeCmdState;
-        }
-
-        PVMFSMNodeContainer& operator=(const PVMFSMNodeContainer& inContainer)
-        {
-            if (&inContainer != this)
-            {
-                commandStartOffset = inContainer.commandStartOffset;
-                iNode = inContainer.iNode;
-                iSessionId = inContainer.iSessionId;
-                iNodeTag = inContainer.iNodeTag;
-                iInputPorts = inContainer.iInputPorts;
-                iOutputPorts = inContainer.iOutputPorts;
-                iFeedBackPorts = inContainer.iFeedBackPorts;
-                iExtensions = inContainer.iExtensions;
-                iExtensionUuids = inContainer.iExtensionUuids;
-                iAutoPaused = inContainer.iAutoPaused;
-                iNodeCmdState = inContainer.iNodeCmdState;
-            }
-            return *this;
-        }
-
-        virtual ~PVMFSMNodeContainer() {};
-
-        void Reset()
-        {
-            iInputPorts.clear();
-            iOutputPorts.clear();
-            iFeedBackPorts.clear();
-            for (uint32 i = 0; i < iExtensions.size(); i++)
-            {
-                iExtensions[i]->removeRef();
-            }
-            iExtensions.clear();
-            iExtensionUuids.clear();
-            iAutoPaused = false;
-        }
-
-        int32         commandStartOffset;
-        PVMFNodeInterface* iNode;
-        PVMFSessionId iSessionId;
-        int32         iNodeTag;
-        Oscl_Vector<PVMFPortInterface*, PVMFStreamingManagerNodeAllocator> iInputPorts;
-        Oscl_Vector<PVMFPortInterface*, PVMFStreamingManagerNodeAllocator> iOutputPorts;
-        Oscl_Vector<PVMFPortInterface*, PVMFStreamingManagerNodeAllocator> iFeedBackPorts;
-        Oscl_Vector<PVInterface*, PVMFStreamingManagerNodeAllocator> iExtensions;
-        Oscl_Vector<PVUuid, PVMFStreamingManagerNodeAllocator> iExtensionUuids;
-        bool iAutoPaused;
-
-        PVMFSMNodeCmdState iNodeCmdState;
-
-};
-typedef Oscl_Vector<PVMFSMNodeContainer, PVMFStreamingManagerNodeAllocator> PVMFSMNodeContainerVector;
-
-/*
- * Track related structures
- */
-class PVMFSMTrackInfo
-{
-    public:
-        PVMFSMTrackInfo()
-        {
-            trackID = 0;
-            rdtStreamID = 0;
-            portTag = 0;
-            bitRate = 0;
-            trackTimeScale = 1;
-            iNetworkNodePort = NULL;
-            iJitterBufferInputPort = NULL;
-            iJitterBufferOutputPort = NULL;
-            iMediaLayerInputPort = NULL;
-            iMediaLayerOutputPort = NULL;
-            iJitterBufferRTCPPort = NULL;
-            iNetworkNodeRTCPPort = NULL;
-            iSessionControllerOutputPort = NULL;
-            iSessionControllerFeedbackPort = NULL;
-            iRTPSocketID = 0;
-            iRTCPSocketID = 0;
-            iRateAdaptation = false;
-            iRateAdaptationFeedBackFrequency = 0;
-            iFormatType = PVMF_FORMAT_UNKNOWN;
-            iBitStreamSwitchingInProgress = false;
-            iNewTrackID = 0;
-            iRTCPBwSpecified = false;
-            iTrackDisable = false;
-        };
-
-        PVMFSMTrackInfo(const PVMFSMTrackInfo& a)
-        {
-            trackID = a.trackID;
-            rdtStreamID = a.rdtStreamID;
-            portTag = a.portTag;
-            bitRate = a.bitRate;
-            trackTimeScale = a.trackTimeScale;
-            iTrackConfig = a.iTrackConfig;
-            iTransportType = a.iTransportType;
-            iFormatType = a.iFormatType;
-            iMimeType = a.iMimeType;
-            iNetworkNodePort = a.iNetworkNodePort;
-            iJitterBufferInputPort = a.iJitterBufferInputPort;
-            iJitterBufferOutputPort = a.iJitterBufferOutputPort;
-            iMediaLayerInputPort = a.iMediaLayerInputPort;
-            iMediaLayerOutputPort = a.iMediaLayerOutputPort;
-            iJitterBufferRTCPPort = a.iJitterBufferRTCPPort;
-            iNetworkNodeRTCPPort = a.iNetworkNodeRTCPPort;
-            iSessionControllerOutputPort = a.iSessionControllerOutputPort;
-            iSessionControllerFeedbackPort = a.iSessionControllerFeedbackPort;
-            iRTPSocketID = a.iRTPSocketID;
-            iRTCPSocketID = a.iRTCPSocketID;
-            iRateAdaptation = a.iRateAdaptation;
-            iRateAdaptationFeedBackFrequency = a.iRateAdaptationFeedBackFrequency;
-            iBitStreamSwitchingInProgress = a.iBitStreamSwitchingInProgress;
-            iNewTrackID = a.iNewTrackID;
-            iRTCPBwSpecified = a.iRTCPBwSpecified;
-            iTrackDisable = a.iTrackDisable;
-            iRR = a.iRR;
-            iRS = a.iRS;
-
-        };
-
-        PVMFSMTrackInfo& operator=(const PVMFSMTrackInfo& a)
-        {
-            if (&a != this)
-            {
-                trackID = a.trackID;
-                rdtStreamID = a.rdtStreamID;
-                portTag = a.portTag;
-                bitRate = a.bitRate;
-                trackTimeScale = a.trackTimeScale;
-                iTrackConfig = a.iTrackConfig;
-                iTransportType = a.iTransportType;
-                iFormatType = a.iFormatType;
-                iMimeType = a.iMimeType;
-                iNetworkNodePort = a.iNetworkNodePort;
-                iJitterBufferInputPort = a.iJitterBufferInputPort;
-                iJitterBufferOutputPort = a.iJitterBufferOutputPort;
-                iMediaLayerInputPort = a.iMediaLayerInputPort;
-                iMediaLayerOutputPort = a.iMediaLayerOutputPort;
-                iJitterBufferRTCPPort = a.iJitterBufferRTCPPort;
-                iNetworkNodeRTCPPort = a.iNetworkNodeRTCPPort;
-                iSessionControllerOutputPort = a.iSessionControllerOutputPort;
-                iSessionControllerFeedbackPort = a.iSessionControllerFeedbackPort;
-                iRTPSocketID = a.iRTPSocketID;
-                iRTCPSocketID = a.iRTCPSocketID;
-                iRateAdaptation = a.iRateAdaptation;
-                iRateAdaptationFeedBackFrequency = a.iRateAdaptationFeedBackFrequency;
-                iBitStreamSwitchingInProgress = a.iBitStreamSwitchingInProgress;
-                iNewTrackID = a.iNewTrackID;
-                iRTCPBwSpecified = a.iRTCPBwSpecified;
-                iTrackDisable = a.iTrackDisable;
-                iRR = a.iRR;
-                iRS = a.iRS;
-
-            }
-            return *this;
-        };
-
-        virtual ~PVMFSMTrackInfo() {};
-
-        uint32 trackID;
-        uint32 rdtStreamID;
-        uint32 portTag;
-        uint32 bitRate;
-        uint32 trackTimeScale;
-        OsclRefCounterMemFrag iTrackConfig;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iTransportType;
-        PVMFFormatType iFormatType;
-        OSCL_HeapString<PVMFStreamingManagerNodeAllocator> iMimeType;
-        PVMFPortInterface* iNetworkNodePort;
-        PVMFPortInterface* iJitterBufferInputPort;
-        PVMFPortInterface* iJitterBufferOutputPort;
-        PVMFPortInterface* iMediaLayerInputPort;
-        PVMFPortInterface* iMediaLayerOutputPort;
-        PVMFPortInterface* iJitterBufferRTCPPort;
-        PVMFPortInterface* iNetworkNodeRTCPPort;
-        PVMFPortInterface* iSessionControllerOutputPort;
-        PVMFPortInterface* iSessionControllerFeedbackPort;
-        uint32 iRTPSocketID;
-        uint32 iRTCPSocketID;
-        bool   iRateAdaptation;
-        uint32 iRateAdaptationFeedBackFrequency;
-
-        // RTCP bandwidth related
-        bool   iRTCPBwSpecified;
-        uint32 iRR;
-        uint32 iRS;
-
-        /* Bitstream switching related */
-        bool iBitStreamSwitchingInProgress;
-        uint32 iNewTrackID;
-
-        //Check track disable or not
-        bool iTrackDisable;
-
-
-};
-typedef Oscl_Vector<PVMFSMTrackInfo, PVMFStreamingManagerNodeAllocator> PVMFSMTrackInfoVector;
-
-/*
-*  class for saving kvps for CPM
-*/
-typedef Oscl_Vector<PvmiKvp, PVMFStreamingManagerNodeAllocator> PVMFKvpVector;
-
-class PVMFSMNodeKVPStore
-{
-    public:
-        // add kvp string with W-string value
-        PVMFStatus addKVPString(const char* aKeyTypeString, OSCL_wString& aValString);
-        // add kvp string with normal string value
-        PVMFStatus addKVPString(const char* aKeyTypeString, const char* aValString);
-        // add kvp string with normal uint32 value
-        PVMFStatus addKVPuint32Value(const char* aKeyTypeString, uint32 aValue);
-
-        // get the vector for the all constructed KVPs
-        PVMFKvpVector* getKVPStore()
-        {
-            return &iKvpVector;
-        }
-
-        // check emptiness of the store
-        bool isEmpty() const
-        {
-            return iKvpVector.empty();
-        }
-
-        // release memory for all the constructed KVPs and clear the vector
-        void destroy()
-        {
-            releaseMemory();
-            clear();
-        }
-
-        // constructor and destructor
-        PVMFSMNodeKVPStore()
-        {
-            clear();
-        }
-        ~PVMFSMNodeKVPStore()
-        {
-            destroy();
-        }
-
-    private:
-        enum KVPValueTypeForMemoryRelease
-        {
-            KVPValueTypeForMemoryRelease_NoInterest = 0,
-            KVPValueTypeForMemoryRelease_String,
-            KVPValueTypeForMemoryRelease_WString
-        };
-
-        void clear()
-        {
-            iKvpVector.clear();
-            iKVPValueTypeForMemoryRelease.clear();
-        }
-        void releaseMemory();
-
-    private:
-        PVMFKvpVector iKvpVector;
-        Oscl_Vector<uint32, PVMFStreamingManagerNodeAllocator> iKVPValueTypeForMemoryRelease;
-};
-
-
 class PVMFStreamingManagerNode : public PVMFNodeInterface,
             public OsclActiveObject,
-            public PVMFNodeErrorEventObserver,
-            public PVMFNodeInfoEventObserver,
-            public PVMFNodeCmdStatusObserver,
-            public PvmiCapabilityAndConfig,
-            public PVMFCPMStatusObserver
+            public PVMFDataSourceInitializationExtensionInterface
 {
     public:
-        OSCL_IMPORT_REF PVMFStreamingManagerNode(int32 aPriority);
+        OSCL_IMPORT_REF static PVMFStreamingManagerNode* New(int32 aPriority);
         OSCL_IMPORT_REF virtual ~PVMFStreamingManagerNode();
 
-        //from PVMFNodeInterface
+        /* From PVMFNodeInterface */
         OSCL_IMPORT_REF PVMFStatus ThreadLogon();
         OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
+        virtual PVMFSessionId Connect(const PVMFNodeSessionInfo &aSession);
+        virtual PVMFStatus Disconnect(PVMFSessionId aSessionId);
+        virtual TPVMFNodeInterfaceState GetState()
+        {
+            if (iSMFSPlugin)
+                return iSMFSPlugin->GetState();
+            return PVMFNodeInterface::GetState();
+        }
         OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
         OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
         OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId,
                                                 const PvmfMimeString& aMimeType,
-                                                Oscl_Vector< PVUuid, PVMFStreamingManagerNodeAllocator >& aUuids,
+                                                Oscl_Vector< PVUuid, OsclMemAllocator >& aUuids,
                                                 bool aExactUuidsOnly = false,
                                                 const OsclAny* aContext = NULL);
         OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
@@ -1028,575 +121,45 @@
                 PVMFCommandId aCmdId,
                 const OsclAny* aContextData = NULL);
 
-        /**
-         * Handle an error event that has been generated.
-         *
-         * @param "aEvent" "The event to be handled."
-         */
-        virtual void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
-        /**
-         * Handle an informational event that has been generated.
-         *
-         * @param "aEvent" "The event to be handled."
-         */
-        virtual void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent);
-        /**
-         * Handle an event that has been generated.
-         *
-         * @param "aResponse"	"The response to a previously issued command."
-         */
-        virtual void NodeCommandCompleted(const PVMFCmdResp& aResponse);
-
-        /* from PVMFPortActivityHandler */
+        /* From PVMFPortActivityHandler */
         void HandlePortActivity(const PVMFPortActivity& aActivity);
 
-        PVMFSMNodeContainer* getNodeContainer(int32 tag);
-
-
-        //// capability and config interface
-
-        virtual void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
-        {
-            ciObserver = aObserver;
-        }
-
-        virtual PVMFStatus getParametersSync(PvmiMIOSession aSession,
-                                             PvmiKeyType aIdentifier,
-                                             PvmiKvp*& aParameters,
-                                             int& aNumParamElements,
-                                             PvmiCapabilityContext aContext);
-        virtual PVMFStatus releaseParameters(PvmiMIOSession aSession,
-                                             PvmiKvp* aParameters,
-                                             int num_elements);
-        virtual void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
-        virtual void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
-                                          PvmiKvp* aParameters, int num_parameter_elements);
-        virtual void DeleteContext(PvmiMIOSession aSession,
-                                   PvmiCapabilityContext& aContext);
-        virtual void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
-                                       int num_elements, PvmiKvp * & aRet_kvp);
-        virtual PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
-                PvmiKvp* aParameters,
-                int num_elements,
-                PvmiKvp*& aRet_kvp,
-                OsclAny* context = NULL);
-        virtual uint32 getCapabilityMetric(PvmiMIOSession aSession);
-        virtual PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
-                                                PvmiKvp* aParameters,
-                                                int num_elements);
-        /* From PVMFCPMStatusObserver */
-        void CPMCommandCompleted(const PVMFCmdResp& aResponse);
-
+        /* From PVMFDataSourceInitializationExtensionInterface */
+        virtual PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL,
+                PVMFFormatType& aSourceFormat,
+                OsclAny* aSourceData);
+        virtual PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
+        virtual PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
     private:
-        //from OsclActiveObject
+        /* From OsclActiveObject */
         void Run();
         void DoCancel();
+        void Construct();
+        void addRef();
+        void removeRef();
 
-        PVMFStreamingManagerNodeCmdQ iInputCommands;
-        PVMFStreamingManagerNodeCmdQ iCurrentCommand;
-        PVMFStreamingManagerNodeCmdQ iCancelCommand;
-        PVMFNodeCapability iCapability;
-        PVLogger *iLogger;
-        PVLogger *iCmdSeqLogger;
-        PVLogger *iReposLogger;
-
-        PVInterface* iExtensionInterfacePlaceholder;
-        PVMFStreamingManagerExtensionInterfaceImpl *iExtensionInterface;
-
-        PVMFSMNodeContainerVector  iNodeContainerVec;
-        bool iQueryUUIDComplete;
-        bool iQueryInterfaceComplete;
-
-        uint32 iNumChildNodesQueryUUIDPending;
-        uint32 iNumChildNodesQueryUUIDComplete;
-        uint32 iNumChildNodesQueryInterfacePending;
-        uint32 iNumChildNodesQueryInterfaceComplete;
-
-        int32 iNumChildNodesStartPending;
-        int32 iNumChildNodesStopPending;
-        bool iSendBOS;
-        uint32 iStreamID;
-
-        uint32 iNumCancelAllCommandsIssued;
-        uint32 iNumCancelAllCommandsComplete;
-
-
-
-        PVMFSMSessionSourceInfo *iSessionSourceInfo;
-        PVMFStatus setSessionSourceInfo(OSCL_wString&,
-                                        PVMFFormatType,
-                                        OsclAny*);
-
-        PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
-        PVMFStatus SelectTracks(PVMFMediaPresentationInfo&, PVMFSessionId);
-        PVMFMediaPresentationInfo iCompleteMediaPresetationInfo;
-        PVMFMediaPresentationInfo iSelectedMediaPresetationInfo;
-
-        PVMFSMTrackInfoVector iTrackInfoVec;
-        uint32 iTotalNumRequestPortsComplete;
-        uint32 iNumRequestPortsPending;
-        uint32 iTotalNumReleasePortsComplete;
-        uint32 iNumReleasePortsPending;
-        /* Init phase port requests */
-        uint32 iTotalNumInitPhaseRequestPortsComplete;
-        uint32 iTotalNumInitPhaseRequestPortsPending;
-        bool PopulateTrackInfoVec();
-        PVMFSMTrackInfo* FindTrackInfo(uint32 trackID);
-        PVMFSMTrackInfo* FindTrackInfo(OSCL_String* trackMimeType);
-        uint32 iJitterBufferDurationInMilliSeconds;
-        void setJitterBufferDurationInMilliSeconds(uint32 duration)
-        {
-            iJitterBufferDurationInMilliSeconds = duration;
-        }
-
-
-        /* Command processing */
-        PVMFSMCommandContext iInternalCmdPool[PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE];
-
-        PVMFCommandId QueueCommandL(PVMFStreamingManagerNodeCommand&);
+        OSCL_IMPORT_REF PVMFStreamingManagerNode(int32 aPriority);
         bool ProcessCommand(PVMFStreamingManagerNodeCommand&);
+        PVMFCommandId QueueCommandL(PVMFStreamingManagerNodeCommand&);
+
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        void DoQueryInterface(PVMFStreamingManagerNodeCommand&);
+        bool DoCancelAllCommands(PVMFStreamingManagerNodeCommand& aCmdQ);
         void CommandComplete(PVMFStreamingManagerNodeCmdQ& aCmdQ,
                              PVMFStreamingManagerNodeCommand& aCmd,
                              PVMFStatus aStatus,
-                             OsclAny* aEventData,
-                             PVUuid* aEventUUID,
-                             int32* aEventCode,
-                             PVInterface* aExtMsg);
-        void CommandComplete(PVMFStreamingManagerNodeCmdQ&,
-                             PVMFStreamingManagerNodeCommand&,
-                             PVMFStatus,
-                             OsclAny* aData = NULL,
-                             PVUuid* aEventUUID = NULL,
-                             int32* aEventCode = NULL);
-        void CommandComplete(PVMFStreamingManagerNodeCommand&,
-                             PVMFStatus,
-                             OsclAny* aData = NULL,
-                             PVUuid* aEventUUID = NULL,
-                             int32* aEventCode = NULL);
-        void CommandComplete(PVMFStreamingManagerNodeCmdQ&,
-                             PVMFStreamingManagerNodeCommand&,
-                             PVMFStatus,
-                             PVInterface* aErrorExtIntf);
-        void CommandComplete(PVMFStreamingManagerNodeCommand&,
-                             PVMFStatus,
-                             PVInterface* aErrorExtIntf,
-                             OsclAny* aData = NULL);
-        void InternalCommandComplete(PVMFStreamingManagerNodeCmdQ&,
-                                     PVMFStreamingManagerNodeCommand&,
-                                     PVMFStatus,
-                                     OsclAny* aData = NULL);
-        void InternalCommandComplete(PVMFStreamingManagerNodeCommand&,
-                                     PVMFStatus,
-                                     OsclAny* aData = NULL);
-
-
-        void DoQueryUuid(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesQueryUuid();
-        void CompleteQueryUuid();
-
-        void DoQueryInterface(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesQueryInterface();
-        void CompleteQueryInterface();
-
-        void DoRequestPort(PVMFStreamingManagerNodeCommand&);
-        void DoReleasePort(PVMFStreamingManagerNodeCommand&);
-
-        PVMFStatus DeleteUnusedSessionControllerNode();
-        PVMFStatus DeleteUnusedNodes();
-
-        PVMFStatus DoPreInit(PVMFStreamingManagerNodeCommand& aCmd);
-        void CompletePreInit();
-        void DoInit(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesInit();
-        void CompleteInit();
-        void PopulatePayloadParserRegistry();
-        void destroyPayloadParserRegistry();
-        PVMFStatus ProcessSDP();
-        PVMFStatus RecognizeAndProcessHeader();
-
-        void DoPrepare(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesPrepare();
-        bool SendSessionControlPrepareCompleteParams();
-        void CompletePrepare();
-
-        void DoStart(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesStart();
-        bool CompleteFeedBackPortsSetup();
-        bool SendSessionControlStartCompleteParams();
-        bool SendPacketSourceStartCompleteParams();
-        void CompleteStart();
-
-        void DoStop(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesStop();
-        void CompleteStop();
-        void ResetStopCompleteParams();
-
-        void DoFlush(PVMFStreamingManagerNodeCommand&);
-        bool FlushPending();
-        bool CheckChildrenNodesFlush();
-        void CompleteFlush();
-
-        void DoPause(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesPause();
-        void CompletePause();
-
-        void DoReset(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesReset();
-        void CompleteReset();
-        void ResetNodeParams();
-
-        void DoAutoPause(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesAutoPause();
-        void CompleteAutoPause();
-
-        void DoAutoResume(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesAutoResume();
-        void CompleteAutoResume();
-
-        void DoCancelAllCommands(PVMFStreamingManagerNodeCommand&);
-        bool CheckChildrenNodesCancelAll();
-        void CompleteCancelAll();
-
-        void DoCancelCommand(PVMFStreamingManagerNodeCommand&);
-
-        bool oGraphConstructComplete;
-        bool GraphConstruct();
-        bool ConstructGraphFor3GPPUDPStreaming();
-        bool ConstructGraphFor3GPPTCPStreaming();
-        bool SetSocketNodePortAllocator();
-        bool ConstructGraphForMSHTTPStreaming();
-        void CompleteGraphConstruct();
-        bool ReserveSockets();
-        bool RequestNetworkNodePorts(int32, uint32&);
-        bool RequestRTSPNodePorts(int32, uint32&);
-        bool RequestJitterBufferPorts(int32, uint32&);
-        bool RequestMediaLayerPorts(int32, uint32&);
-        bool RequestRtpPacketSourcePorts(int32, uint32&);
-        bool oGraphConnectComplete;
-        bool GraphConnectFor3GPPUDPStreaming();
-        bool GraphConnectFor3GPPTCPStreaming();
-        bool GraphConnectForMSHTTPStreaming();
-        bool GraphConnectForRTPPacketSource();
-        bool GraphConnect();
-        PVMFStatus ConnectPortPairs(PVMFPortInterface*, PVMFPortInterface*);
-        bool SendSessionSourceInfoToSessionController();
-        void ResetNodeContainerCmdState();
-        enum SMErrorEventSource
-        {
-            SM_NO_ERROR,
-            SM_NODE_COMMAND_COMPLETION,
-            SM_ERROR_EVENT
-        };
-        SMErrorEventSource iErrorDuringProcess;
-
-        /* Event reporting */
-        void ReportErrorEvent(PVMFEventType aEventType,
-                              OsclAny* aEventData = NULL,
-                              PVUuid* aEventUUID = NULL,
-                              int32* aEventCode = NULL);
-        void ReportInfoEvent(PVMFEventType aEventType,
                              OsclAny* aEventData = NULL,
                              PVUuid* aEventUUID = NULL,
                              int32* aEventCode = NULL);
-        void SetState(TPVMFNodeInterfaceState);
 
-        void CleanUp();
-        void MoveCmdToCurrentQueue(PVMFStreamingManagerNodeCommand& aCmd);
-        void MoveCmdToCancelQueue(PVMFStreamingManagerNodeCommand& aCmd);
-        PVMFSMCommandContext* RequestNewInternalCmd();
+        PVMFStreamingManagerNodeCmdQ iInputCommands;
 
-        /*
-         * Internal command handlers
-         */
-        void HandleRTSPSessionControllerCommandCompleted(const PVMFCmdResp& aResponse,
-                bool& aResponseOverRide);
-        void HandleSocketNodeCommandCompleted(const PVMFCmdResp& aResponse);
-        void HandleJitterBufferCommandCompleted(const PVMFCmdResp& aResponse);
-        void HandleMediaLayerCommandCompleted(const PVMFCmdResp& aResponse);
-
-        void HandleRtpPacketSourceCommandCompleted(const PVMFCmdResp& aResponse);
-        bool ConstructGraphForRTPPacketSource();
-
-        /* Session start & stop times */
-        uint32 iSessionStartTime;
-        uint32 iSessionStopTime;
-        bool   iSessionStopTimeAvailable;
-        bool   iSessionSeekAvailable;
-
-        /* Reposition related */
-        bool oRepositioning;
-        PVMFTimestamp iRepositionRequestedStartNPTInMS;
-        PVMFTimestamp iActualRepositionStartNPTInMS;
-        PVMFTimestamp* iActualRepositionStartNPTInMSPtr;
-        PVMFTimestamp iActualMediaDataTS;
-        PVMFTimestamp* iActualMediaDataTSPtr;
-        bool iJumpToIFrame;
-        PVMFDataSourcePositionParams* iPVMFDataSourcePositionParamsPtr;
-        bool oPlayListRepositioning;
-
-        PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId,
-                                            PVMFTimestamp aTargetNPT,
-                                            PVMFTimestamp& aActualNPT,
-                                            PVMFTimestamp& aActualMediaDataTS,
-                                            bool aSeekToSyncPoint = true,
-                                            uint32 aStreamID = 0,
-                                            OsclAny* aContext = false);
-        PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId,
-                                            PVMFDataSourcePositionParams& aPVMFDataSourcePositionParams,
-                                            OsclAny* aContext = false);
-        void DoSetDataSourcePosition(PVMFStreamingManagerNodeCommand&);
-        void DoSetDataSourcePositionPlayList(PVMFStreamingManagerNodeCommand&);
-        bool DoRepositioningPause3GPPStreaming();
-        bool DoRepositioningPauseMSHTTPStreaming();
-        bool DoRepositioningStart3GPPStreaming();
-        bool DoRepositioningStart3GPPPlayListStreaming();
-        bool DoRepositioningStart3GPPPlayListStreamingDuringPlay();
-        bool DoRepositioningStartMSHTTPStreaming();
-        bool DoSessionControllerSeek();
-        void GetAcutalMediaTSAfterSeek();
-        PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId,
-                                              PVMFTimestamp aTargetNPT,
-                                              PVMFTimestamp& aActualNPT,
-                                              bool aSeekToSyncPoint = true,
-                                              OsclAny* aContext = false);
-
-        PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId,
-                                              PVMFTimestamp aTargetNPT,
-                                              PVMFTimestamp& aSeekPointBeforeTargetNPT,
-                                              PVMFTimestamp& aSeekPointAfterTargetNPT,
-                                              OsclAny* aContext = NULL,
-                                              bool aSeekToSyncPoint = true);
-
-        void DoQueryDataSourcePosition(PVMFStreamingManagerNodeCommand&);
-        PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId,
-                                        int32 aRate,
-                                        OsclTimebase* aTimebase = NULL,
-                                        OsclAny* aContext = NULL);
-        void DoSetDataSourceRate(PVMFStreamingManagerNodeCommand&);
-        /* HTTP Streaming reposition related */
-        uint32 iFirstSeqNumAfterSeek;
-
-        /*
-         * Meta data related
-         */
-        PVMFSMSessionMetaDataInfo iMetaDataInfo;
-        uint32 GetNumMetadataKeys(char* aQueryKeyString = NULL);
-        uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
-        PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId,
-                                          PVMFMetadataList& aKeyList,
-                                          uint32 aStartingKeyIndex,
-                                          int32 aMaxKeyEntries,
-                                          char* aQueryKeyString = NULL,
-                                          const OsclAny* aContextData = NULL);
-        PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId,
-                                            PVMFMetadataList& aKeyList,
-                                            Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
-                                            uint32 aStartingValueIndex,
-                                            int32 aMaxValueEntries,
-                                            const OsclAny* aContextData = NULL);
-        PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
-                                           uint32 aStartingKeyIndex,
-                                           uint32 aEndKeyIndex);
-        PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
-                                             uint32 aStartingValueIndex,
-                                             uint32 aEndValueIndex);
-
-
-        PVMFStatus DoGetMetadataKeys(PVMFStreamingManagerNodeCommand& aCmd);
-        PVMFStatus DoGetMetadataValues(PVMFStreamingManagerNodeCommand& aCmd);
-
-        PVMFStatus InitMetaData();
-        PVMFStatus GetIndexParamValues(char* aString, uint32& aStartIndex, uint32& aEndIndex);
-        PVMFStatus CreateKVPForCharStringValue(PvmiKvp& aKeyVal,
-                                               const char* aKeyTypeString,
-                                               const char* aValString,
-                                               char* aMiscKeyParam = NULL);
-        PVMFStatus CreateKVPForWideCharStringValue(PvmiKvp& aKeyVal,
-                const char* aKeyTypeString,
-                const oscl_wchar* aValString,
-                char* aMiscKeyParam = NULL);
-        PVMFStatus CreateKVPForUInt32Value(PvmiKvp& aKeyVal,
-                                           const char* aKeyTypeString,
-                                           uint32& aValueUInt32,
-                                           char* aMiscKeyParam = NULL);
-        PVMFStatus CreateKVPForBoolValue(PvmiKvp& aKeyVal,
-                                         const char* aKeyTypeString,
-                                         bool& aValueBool,
-                                         char* aMiscKeyParam = NULL);
-
-        // remove the ending ';', ',' or ' ' and calulate value length
-        // for protocol extension header kvp handling
-        uint32 getItemLen(char *ptrValueStart, char *ptrValueEnd);
-
-
-        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
-        Oscl_Vector<OSCL_HeapString<PVMFStreamingManagerNodeAllocator>, PVMFStreamingManagerNodeAllocator> iCPMMetadataKeys;
-
-        /* Auto pause / Auto resume related */
-        bool iAutoPausePending;
-        int32 iAutoResumePending;
-        bool iAutoPaused;
-
-        /* Stream Thinning related */
-        bool iStreamThinningInProgress;
-        bool iPlaylistPlayInProgress;
-        uint32 iStreamThinningRequestTime;
-        uint32 iFirstSeqNumberAfterSwitch;
-
-        PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
-                                      int32 aIndex, PvmiKvpAttr reqattr);
-        PVMFStatus VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set);
-
-        int    iNumJittBufferGrowParamsSet;
-        uint32 iJitterBufferNumGrows;
-        uint32 iJitterBufferGrowSize;
-        bool ibCloaking;
-        bool iSwitchStreamIFrameVideo;
-
-        friend class PVMFStreamingManagerExtensionInterfaceImpl;
-
-        bool ibRdtTransport;
-
-        bool IsInternalCmd(PVMFCommandId aId);
-
-        void Asf_CompletePreInit();
-        bool Asf_PopulateTrackInfoVec();
-        bool Asf_SetSocketNodePortAllocator();
-        PVMFStatus Asf_RecognizeAndProcessHeader();
-        PVMFStatus Asf_GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
-        PVMFStatus Asf_SelectTracks(PVMFMediaPresentationInfo&, PVMFSessionId);
-        PVMFStatus Asf_InitMetaData();
-        PVMFStatus Asf_GetExtendedMetaData(PvmiKvp& KeyVal, uint32 aIndex);
-        bool IsAsfStreamingSupported();
-        bool Asf_Doprepare(PVMFStreamingManagerNodeCommand& aCmd);
-        void Asf_PopulateDRMInfo();
-        PVMFStatus Asf_ConvertWMPictureToAPIC(PvmfApicStruct*& aAPICStruct,
-                                              bool* aImageTooBig,
-                                              uint32 aMaxSize,
-                                              uint32* aImageSize,
-                                              uint32 aPicIndex,
-                                              uint32 aMetadataindex);
-        void Asf_DeleteAPICStruct(PvmfApicStruct*& aAPICStruct);
-
-        PVMFStatus GetMaxSizeValue(char* aString, uint32& aMaxSize);
-        PVMFStatus GetTruncateFlagValue(char* aString, uint32& aTruncateFlag);
-
-        IRealChallengeGen* ipRealChallengeGen;
-        IPayloadParser*    ipRdtParser;
-
-        bool GetRealAudioMimeType(rm_mediaInfo* pinfo, OSCL_String& mime,
-                                  OsclMemoryFragment* paacConfig);
-        void CreateRealStreamingObjects();
-        void DestroyRealStreamingObjects();
-        bool IsRealStreamingSupported();
-
-        //// cpm related
-        bool iPreviewMode;
-        bool iUseCPMPluginRegistry;
-        bool iDRMResetPending;
-        bool iCPMInitPending;
-        uint32 maxPacketSize;
-        uint32 iPVMFStreamingManagerNodeMetadataValueCount;
-        PVMFStreamingDataSource iCPMSourceData;
-        PVMFSourceContextData iSourceContextData;
-        bool iSourceContextDataValid;
-        PVMFCPM* iCPM;
-        PVMFSessionId iCPMSessionID;
-        PVMFCPMContentType iCPMContentType;
-        PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
-        PVMFCPMPluginAccessUnitDecryptionInterface* iDecryptionInterface;
-        PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
-        PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
-        PvmiCapabilityAndConfig* iCPMCapConfigInterface;
-        PVMFSMNodeKVPStore iCPMKvpStore;
-        PvmiKvp iRequestedUsage;
-        PvmiKvp iApprovedUsage;
-        PvmiKvp iAuthorizationDataKvp;
-        PVMFCPMUsageID iUsageID;
-        PVMFCommandId iCPMInitCmdId;
-        PVMFCommandId iCPMOpenSessionCmdId;
-        PVMFCommandId iCPMRegisterContentCmdId;
-        PVMFCommandId iCPMRequestUsageId;
-        PVMFCommandId iCPMUsageCompleteCmdId;
-        PVMFCommandId iCPMCloseSessionCmdId;
-        PVMFCommandId iCPMResetCmdId;
-        PVMFCommandId iCPMGetMetaDataKeysCmdId;
-        PVMFCommandId iCPMGetMetaDataValuesCmdId;
-        PVMFCommandId iCPMGetLicenseInterfaceCmdId;
-        PVMFCommandId iCPMGetLicenseCmdId;
-        PVMFCommandId iCPMGetCapConfigCmdId;
-        PVMFCommandId iCPMCancelGetLicenseCmdId;
-        PVMFStatus iCPMRequestUsageCommandStatus;
-
-        class V1Header
-        {
-            public:
-                uint8* iKeyID; 	//Array of bytes that contains the KeyID from the V1 ASF header object.
-                uint32 iKeyIDSize; //count of bytes in iKeyID;
-                uint8* iSecretData; //Array of bytes that contains the SecretData from the V1 ASF header
-                uint32 iSecretDataSize;//count of bytes in iSecretData;
-                uint8* iURL; //Array of bytes that contains the license acquisition URL from the V1 ASF header
-                uint32 iURLSize;//Count of bytes in iURL
-        };
-        V1Header iV1Header;
-        void InitCPM();
-        void OpenCPMSession();
-        void CPMRegisterContent();
-        bool GetCPMContentAccessFactory();
-        bool GetCPMMetaDataExtensionInterface();
-        void GetCPMLicenseInterface();
-        void GetCPMCapConfigInterface();
-        bool SetCPMKvps();
-        void RequestUsage();
-        void SendUsageComplete();
-        void CloseCPMSession();
-        void ResetCPM();
-        void PopulateDRMInfo();
-        void GetCPMMetaDataKeys();
-        void GetCPMMetaDataValues();
-        void CompleteGetMetaDataValues();
-        void CompleteDRMInit();
-        void CleanupCPMdata();
-        PVMFStatus CompleteGetMetadataKeys(PVMFStreamingManagerNodeCommand& aCmd);
-        PVMFStatus CheckCPMCommandCompleteStatus(PVMFCommandId aID, PVMFStatus aStatus);
-
-        PVMFCommandId GetLicense(PVMFSessionId aSessionId,
-                                 OSCL_wString& aContentName,
-                                 OsclAny* aData,
-                                 uint32 aDataSize,
-                                 int32 aTimeoutMsec,
-                                 const OsclAny* aContextData = NULL) ;
-
-        PVMFCommandId GetLicense(PVMFSessionId aSessionId,
-                                 OSCL_String&  aContentName,
-                                 OsclAny* aData,
-                                 uint32 aDataSize,
-                                 int32 aTimeoutMsec,
-                                 const OsclAny* aContextData = NULL);
-
-        PVMFCommandId CancelGetLicense(PVMFSessionId aSessionId
-                                       , PVMFCommandId aCmdId
-                                       , OsclAny* aContextData = NULL);
-
-        PVMFStatus GetLicenseStatus(PVMFCPMLicenseStatus& aStatus) ;
-
-        PVMFStatus DoGetLicense(PVMFStreamingManagerNodeCommand& aCmd,
-                                bool aWideCharVersion = false);
-        void DoCancelGetLicense(PVMFStreamingManagerNodeCommand& aCmd);
-
-        void CompleteGetLicense();
-
-        // for HTTP extension header kvp parsing
-        bool IsHttpExtensionHeaderValid(PvmiKvp &aParameter);
-
-        //Check for RTP packet source
-        bool IsRTPPacketSourcePresent();
-
-        // for error completion while current cmd is ongoing
-        PVInterface* iErrorResponseInf;
-        PVMFStatus  iCmdErrStatus;
-        OsclAny*	iEventData;
-        bool IsFatalErrorEvent(const PVMFEventType& event);
+        PVMFDataSourceInitializationExtensionInterface* iFSPDataSourceInitializationIntf;
+        PVMFSMFSPRegistry* iSMFSPRegistry;
+        PVMFSMFSPBaseNode* iSMFSPlugin;
+        PVUuid			iFSPUuid;
+        PVMFNodeSession iUpstreamSession;
+        PVLogger * iLogger;
 };
 
 #endif
diff --git a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_real_nosupport.cpp b/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_real_nosupport.cpp
deleted file mode 100644
index 83f9df1..0000000
--- a/nodes/streaming/streamingmanager/src/pvmf_streaming_manager_real_nosupport.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVMF_STREAMING_MANAGER_NODE_H_INCLUDED
-#include "pvmf_streaming_manager_node.h"
-#endif
-#ifndef SDP_PARSER_H
-#include "sdp_parser.h"
-#endif
-
-bool PVMFStreamingManagerNode::GetRealAudioMimeType(
-    rm_mediaInfo* pinfo,
-    OSCL_String& mime,
-    OsclMemoryFragment* paacConfig)
-{
-    OSCL_UNUSED_ARG(pinfo);
-    OSCL_UNUSED_ARG(mime);
-    OSCL_UNUSED_ARG(paacConfig);
-
-    return false;  // not supported
-}
-
-void PVMFStreamingManagerNode::CreateRealStreamingObjects()
-{
-    ipRealChallengeGen = NULL;
-    ipRdtParser = NULL;
-}
-
-void PVMFStreamingManagerNode::DestroyRealStreamingObjects()
-{
-}
-
-bool PVMFStreamingManagerNode::IsRealStreamingSupported()
-{
-    return false;
-}
diff --git a/oscl/cleanup b/oscl/cleanup
deleted file mode 100644
index 062d346..0000000
--- a/oscl/cleanup
+++ /dev/null
@@ -1,29 +0,0 @@
-# makefiles, etc.
-
-echo Cleaning up build environment ...
-
-unsetenv CCASE_MAKE_COMPAT
-unsetenv PROJECT
-unsetenv SDK_LOCAL
-unsetenv VOB_BASE_DIR
-unsetenv PV_TOP
-
-set arch_bin_path = `$MK/../bin/archtype`
-if ( -x /icl-tools/bin/$arch_bin_path/utok ) then 
-   set path = (`/icl-tools/bin/$arch_bin_path/utok -s \  -d ./$arch_bin_path  $path`)
-endif
-unset arch_bin_path
-
-if ( -f ./cleanup.extras ) then
-  echo File cleanup.extras found, sourcing ...
-  source ./cleanup.extras 
-else
-  echo File cleanup.extras not found, skipping
-endif
-
-unsetenv MK
-
-# Rehash
-#
-rehash
-rehash
diff --git a/oscl/cleanup.ksh b/oscl/cleanup.ksh
deleted file mode 100644
index 63396f9..0000000
--- a/oscl/cleanup.ksh
+++ /dev/null
@@ -1,25 +0,0 @@
-# makefiles, etc.
-
-echo Cleaning up build environment ...
-
-unset CCASE_MAKE_COMPAT
-unset PROJECT
-unset SDK_LOCAL
-unset VOB_BASE_DIR
-unset PV_TOP
-
-if [[ "${MK}" != "" ]]; then
-	typeset arch_bin_path=`$MK/../bin/archtype`
-	if [ -x /icl-tools/bin/$arch_bin_path/utok ]; then 
-   	export PATH=`/icl-tools/bin/$arch_bin_path/utok -s \  -d ./$arch_bin_path  $PATH`
-	fi
-fi
-
-if [ -f ./cleanup.extras.ksh ]; then
-  echo File cleanup.extras.ksh found, sourcing ...
-  . ./cleanup.extras.ksh 
-else
-  echo File cleanup.extras.ksh not found, skipping
-fi
-
-unset MK
diff --git a/oscl/local.mk b/oscl/local.mk
new file mode 100644
index 0000000..e062335
--- /dev/null
+++ b/oscl/local.mk
@@ -0,0 +1,30 @@
+LOCAL_PATH := $(call get_makefile_dir)
+
+# save off the local_path because it will be overwritten 
+# by other includes
+#SRC_ROOT := $(LOCAL_PATH)
+
+
+LOCAL_MAKEFILES_LIST := \
+$(SRC_ROOT)/oscl/oscl/osclbase/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclerror/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclmemory/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclutil/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclproc/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclio/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclregserv/build/make/local.mk \
+$(SRC_ROOT)/oscl/oscl/osclregcli/build/make/local.mk \
+$(SRC_ROOT)/oscl/pvlogger/build/make/local.mk
+
+ifeq ($(USE_LOADABLE_MODULES),y)
+  LOCAL_MAKEFILES_LIST += $(SRC_ROOT)/oscl/oscl/oscllib/build/make/local.mk 
+endif
+
+include $(MK)/intermediate_level.mk
+
+doc_target := oscl
+doc_title := "OSCL API"
+doc_paths := "$(SRC_ROOT)/oscl/oscl/config/shared $(SRC_ROOT)/oscl/oscl/config/$(BUILD_ARCH) $(SRC_ROOT)/oscl/oscl/osclbase $(SRC_ROOT)/oscl/oscl/osclerror $(SRC_ROOT)/oscl/oscl/osclio $(SRC_ROOT)/oscl/oscl/osclmemory $(SRC_ROOT)/oscl/oscl/osclproc $(SRC_ROOT)/oscl/oscl/osclregcli $(SRC_ROOT)/oscl/oscl/osclregserv $(SRC_ROOT)/oscl/oscl/osclutil" 
+doc_version := $(OSCL_VERSION)
+
+include $(MK)/doc.mk
diff --git a/oscl/makefile b/oscl/makefile
deleted file mode 100755
index 34f641c..0000000
--- a/oscl/makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-
-
-LIBDIRS = \
-        oscl \
-        pvlogger/build/make \
-        unit_test/build/make \
-	../codecs_v2/colorconvert/build/make \
-        ../baselibs/pv_mime_utils/build/make \
-	../pvmi/pvmf/build/make \
-        ../nodes/common/build/make \
-	../pvmi/media_io/pvmiofileoutput/build/make \
-	../pvmi/media_io/pvomaplinuxvideofb/build/make
-
-include $(MK)/recursive.mk
diff --git a/oscl/makefile.pv b/oscl/makefile.pv
deleted file mode 100644
index 97e708f..0000000
--- a/oscl/makefile.pv
+++ /dev/null
@@ -1,18 +0,0 @@
-
-# This file, "makefile.pv", is supposed to specify the compiler flags
-# necessary to build the project - be that a library, an executable, or a
-# bigger system.
-#
-# Unless something really extraordinary is necessary, the default settings
-# should suffice; hence, one include should be enough. If, however, it is not
-# enough, this file should still be included and the appropriate variables
-# modified, so that there is a way to change every library/project's build
-# environment from one place.
-# 
-# Namely, this file contains preprocessor, compiler and linker flags,
-# including paths, but not including build elements.
-#
-#
-
-include $(VOB_BASE_DIR)/tools_v2/build/defaults/makefile.pv.mk
-
diff --git a/oscl/oscl/config/linux/osclconfig.h b/oscl/oscl/config/linux/osclconfig.h
index 2ed4421..435f507 100644
--- a/oscl/oscl/config/linux/osclconfig.h
+++ b/oscl/oscl/config/linux/osclconfig.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,6 +92,7 @@
 //set this to 1 to enable OSCL_ASSERT in release builds.
 #define OSCL_ASSERT_ALWAYS 0
 
+
 // check all osclconfig required macros are defined
 #include "osclconfig_check.h"
 
diff --git a/oscl/oscl/config/linux/osclconfig_compiler_warnings.h b/oscl/oscl/config/linux/osclconfig_compiler_warnings.h
index ea1dce5..563346b 100644
--- a/oscl/oscl/config/linux/osclconfig_compiler_warnings.h
+++ b/oscl/oscl/config/linux/osclconfig_compiler_warnings.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/linux/osclconfig_error.h b/oscl/oscl/config/linux/osclconfig_error.h
index 4770dd4..beab268 100644
--- a/oscl/oscl/config/linux/osclconfig_error.h
+++ b/oscl/oscl/config/linux/osclconfig_error.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,9 +36,10 @@
 #include "osclconfig.h"
 #endif
 
-
-
-
+#define OSCL_HAS_EXCEPTIONS                     1
+#define OSCL_HAS_ERRNO_H		                1
+#define OSCL_HAS_SYMBIAN_ERRORTRAP      0
+#define OSCL_HAS_SETJMP_H 1
 
 // system header files
 #include <setjmp.h>
diff --git a/oscl/oscl/config/linux/osclconfig_io.h b/oscl/oscl/config/linux/osclconfig_io.h
index 074810c..dc9a13d 100644
--- a/oscl/oscl/config/linux/osclconfig_io.h
+++ b/oscl/oscl/config/linux/osclconfig_io.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,18 +53,19 @@
 
 
 //For File I/O
-
-
-
-
+#define OSCL_HAS_GLOB 1
+#define OSCL_HAS_ANSI_FILE_IO_SUPPORT 1
+#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0
+#define OSCL_HAS_NATIVE_FILE_CACHE_ENABLE 1
 #define OSCL_FILE_BUFFER_MAX_SIZE	32768
-
+#define OSCL_HAS_PV_FILE_CACHE	1
 
 //For Sockets
-
-
-
-
+#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0
+#define OSCL_HAS_SYMBIAN_DNS_SERVER 0
+#define OSCL_HAS_BERKELEY_SOCKETS 1
+#define OSCL_HAS_SOCKET_SUPPORT 1
+#define OSCL_HAS_SELECTABLE_PIPES 1
 
 //basic socket types
 typedef int TOsclSocket;
@@ -91,7 +92,9 @@
 	if (!ok)err=errno
 
 #define OsclBind(s,addr,ok,err)\
-	    ok=(bind(s,(sockaddr*)&addr,sizeof(addr))!=(-1));\
+    TOsclSockAddr* tmpadr = &addr;\
+    sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
+	ok=(bind(s,sadr,sizeof(addr))!=(-1));\
         if (!ok)err=errno
 
 #define OsclJoin(s,addr,ok,err)\
@@ -106,10 +109,10 @@
 	ok=(listen(iSocket,qSize)!=(-1));\
 	if (!ok)err=errno
 
-#define OsclAccept(s,accept_s,ok,err)\
+#define OsclAccept(s,accept_s,ok,err,wouldblock)\
 	accept_s=accept(s,NULL,NULL);\
 	ok=(accept_s!=(-1));\
-	if (!ok)err=errno
+	if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}
 
 #define OsclSetNonBlocking(s,ok,err)\
 	ok=(fcntl(s,F_SETFL,O_NONBLOCK)!=(-1));\
@@ -125,7 +128,9 @@
 	if (!ok)err=errno
 
 #define OsclSendTo(s,buf,len,addr,ok,err,nbytes,wouldblock)\
-	nbytes=sendto(s,(const void*)(buf),(size_t)(len),0,(const struct sockaddr*)&addr,(socklen_t)sizeof(addr));\
+    TOsclSockAddr* tmpadr = &addr;\
+    sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
+	nbytes=sendto(s,buf,(size_t)(len),0,sadr,(socklen_t)sizeof(addr));\
 	ok=(nbytes!=(-1));\
 	if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}
 
@@ -139,7 +144,9 @@
 	if (!ok)err=errno
 
 #define OsclConnect(s,addr,ok,err,wouldblock)\
-	ok=(connect(s,(sockaddr*)&addr,sizeof(addr))!=(-1));\
+    TOsclSockAddr* tmpadr = &addr;\
+    sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
+	ok=(connect(s,sadr,sizeof(addr))!=(-1));\
 	if (!ok){err=errno;wouldblock=(err==EINPROGRESS);}
 
 #define OsclGetAsyncSockErr(s,ok,err)\
diff --git a/oscl/oscl/config/linux/osclconfig_lib.h b/oscl/oscl/config/linux/osclconfig_lib.h
new file mode 100644
index 0000000..7cd43eb
--- /dev/null
+++ b/oscl/oscl/config/linux/osclconfig_lib.h
@@ -0,0 +1,58 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+//     O S C L C O N F I G _ L I B  ( P L A T F O R M   C O N F I G   I N F O )
+
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+
+/*! \file osclconfig_lib.h
+    \brief This file contains configuration information for the ANSI build.
+
+*/
+
+#ifndef OSCLCONFIG_LIB_H_INCLUDED
+#define OSCLCONFIG_LIB_H_INCLUDED
+
+
+//Set this to 1 to indicate this platform has oscllib support
+#define OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT	1
+#define PV_RUNTIME_LIB_FILENAME_EXTENSION "so"
+
+//Set this to 1 to enable looking for debug versions of libraries.
+//Use #ifndef to allow the compiler setting to override this definition
+#ifndef OSCL_LIB_READ_DEBUG_LIBS
+#if defined(NDEBUG)
+#define OSCL_LIB_READ_DEBUG_LIBS 0
+#else
+#define OSCL_LIB_READ_DEBUG_LIBS 1
+#endif
+#endif
+
+// The path recursively from which the config files are picked up
+#ifndef PV_DYNAMIC_LOADING_CONFIG_FILE_PATH
+#define PV_DYNAMIC_LOADING_CONFIG_FILE_PATH "./"
+#endif
+
+// check all osclconfig required macros are defined
+#include "osclconfig_lib_check.h"
+
+#endif // OSCLCONFIG_LIB_H_INCLUDED
+
diff --git a/oscl/oscl/config/linux/osclconfig_memory.h b/oscl/oscl/config/linux/osclconfig_memory.h
index b28458a..8675bda 100644
--- a/oscl/oscl/config/linux/osclconfig_memory.h
+++ b/oscl/oscl/config/linux/osclconfig_memory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -82,6 +82,9 @@
 #define OSCL_HAS_HEAP_BASE_SUPPORT 1
 
 
+#define OSCL_HAS_SYMBIAN_MEMORY_FUNCS 0
+
+
 #include "osclconfig_memory_check.h"
 
 
diff --git a/oscl/oscl/config/linux/osclconfig_proc.h b/oscl/oscl/config/linux/osclconfig_proc.h
index 5539be1..87a5bdb 100644
--- a/oscl/oscl/config/linux/osclconfig_proc.h
+++ b/oscl/oscl/config/linux/osclconfig_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/linux/osclconfig_time.h b/oscl/oscl/config/linux/osclconfig_time.h
index b4fdddb..92e8ec2 100644
--- a/oscl/oscl/config/linux/osclconfig_time.h
+++ b/oscl/oscl/config/linux/osclconfig_time.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,9 @@
 
 
 
+#define OSCL_HAS_UNIX_TIME_FUNCS        1
+
+
 typedef struct timeval OsclBasicTimeStruct;
 typedef tm      OsclBasicDateTimeStruct;
 
diff --git a/oscl/oscl/config/linux/osclconfig_util.h b/oscl/oscl/config/linux/osclconfig_util.h
index a66772d..2fd28de 100644
--- a/oscl/oscl/config/linux/osclconfig_util.h
+++ b/oscl/oscl/config/linux/osclconfig_util.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,11 +26,9 @@
 #include <time.h>	  // OSCL clock
 #include <sys/time.h> // timeval
 
-#ifndef OSCL_CLOCK_HAS_DRIFT_CORRECTION
 #define OSCL_CLOCK_HAS_DRIFT_CORRECTION 0
-#endif
-
-
+#define OSCL_HAS_SYMBIAN_TIMERS 0
+#define OSCL_HAS_SYMBIAN_MATH   0
 
 #define OSCL_RAND_MAX           RAND_MAX
 
diff --git a/oscl/oscl/config/linux_nj/osclconfig.h b/oscl/oscl/config/linux_nj/osclconfig.h
index 08dcf70..f4a0520 100644
--- a/oscl/oscl/config/linux_nj/osclconfig.h
+++ b/oscl/oscl/config/linux_nj/osclconfig.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,9 +35,8 @@
 #include <dirent.h>
 #include <dlfcn.h>
 
-
-
-#define HAS_OSCL_LIB_SUPPORT 1
+#define OSCL_HAS_NJ_SUPPORT 1
+#define OSCL_HAS_NJ_FILE_IO_SUPPORT 1
 
 // include common include for determining sizes from limits.h
 #include "osclconfig_limits_typedefs.h"
@@ -84,6 +83,7 @@
 //set this to 1 to enable OSCL_ASSERT in release builds.
 #define OSCL_ASSERT_ALWAYS 0
 
+
 // check all osclconfig required macros are defined
 #include "osclconfig_check.h"
 
diff --git a/oscl/oscl/config/linux_nj/osclconfig_compiler_warnings.h b/oscl/oscl/config/linux_nj/osclconfig_compiler_warnings.h
index 28443aa..1d53085 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_compiler_warnings.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_compiler_warnings.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/linux_nj/osclconfig_error.h b/oscl/oscl/config/linux_nj/osclconfig_error.h
index 4770dd4..beab268 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_error.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_error.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,9 +36,10 @@
 #include "osclconfig.h"
 #endif
 
-
-
-
+#define OSCL_HAS_EXCEPTIONS                     1
+#define OSCL_HAS_ERRNO_H		                1
+#define OSCL_HAS_SYMBIAN_ERRORTRAP      0
+#define OSCL_HAS_SETJMP_H 1
 
 // system header files
 #include <setjmp.h>
diff --git a/oscl/oscl/config/linux_nj/osclconfig_io.h b/oscl/oscl/config/linux_nj/osclconfig_io.h
index e328448..740996a 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_io.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_io.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,10 @@
 #include "osclconfig.h"
 #endif
 
+#if (OSCL_HAS_NJ_SUPPORT) && (ENABLE_MEMORY_PLAYBACK)
+#include <media/MediaPlayerInterface.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -50,21 +54,28 @@
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <errno.h>
+#include <sys/vfs.h>
+#include <dirent.h>
 //#include <glob.h>
+#if (OSCL_HAS_ANSI_STDLIB_SUPPORT)
+#if (OSCL_HAS_UNIX_SUPPORT)
 #include <sys/stat.h>
+#endif
+#endif
 
 //For File I/O
-
-
-
-
+#define OSCL_HAS_GLOB 0
+#define OSCL_HAS_ANSI_FILE_IO_SUPPORT 1
+#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0
+#define OSCL_HAS_NATIVE_FILE_CACHE_ENABLE 1
 #define OSCL_FILE_BUFFER_MAX_SIZE	32768
-
+#define OSCL_HAS_PV_FILE_CACHE	0
 
 //For Sockets
-
-
-
+#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0
+#define OSCL_HAS_SYMBIAN_DNS_SERVER 0
+#define OSCL_HAS_BERKELEY_SOCKETS 1
+#define OSCL_HAS_SOCKET_SUPPORT 1
 
 //basic socket types
 typedef int TOsclSocket;
@@ -91,17 +102,31 @@
         if (!ok)err=errno
 
 #define OsclBind(s,addr,ok,err)\
-	ok=(bind(s,(sockaddr*)&addr,sizeof(addr))!=(-1));\
+    TOsclSockAddr* tmpadr = &addr;\
+    sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
+	ok=(bind(s,sadr,sizeof(addr))!=(-1));\
 	if (!ok)err=errno
 
+#define OsclJoin(s,addr,ok,err)\
+{\
+		struct ip_mreq mreq; \
+            void* p = &addr; \
+	    ok=(bind(s,(sockaddr*)p,sizeof(addr))!=(-1));\
+        mreq.imr_multiaddr.s_addr = addr.sin_addr.s_addr ; \
+        mreq.imr_interface.s_addr = htonl(INADDR_ANY); \
+        ok=(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(struct ip_mreq))!=(-1)); \
+        if (!ok)err=errno;\
+}
+
+
 #define OsclListen(s,size,ok,err)\
 	ok=(listen(iSocket,qSize)!=(-1));\
 	if (!ok)err=errno
 
-#define OsclAccept(s,accept_s,ok,err)\
+#define OsclAccept(s,accept_s,ok,err,wouldblock)\
 	accept_s=accept(s,NULL,NULL);\
 	ok=(accept_s!=(-1));\
-	if (!ok)err=errno
+	if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}
 
 #define OsclSetNonBlocking(s,ok,err)\
 	ok=(fcntl(s,F_SETFL,O_NONBLOCK)!=(-1));\
@@ -117,7 +142,9 @@
 	if (!ok)err=errno
 
 #define OsclSendTo(s,buf,len,addr,ok,err,nbytes,wouldblock)\
-	nbytes=sendto(s,(const void*)(buf),(size_t)(len),0,(const struct sockaddr*)&addr,(socklen_t)sizeof(addr));\
+    TOsclSockAddr* tmpadr = &addr;\
+    sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
+	nbytes=sendto(s,(const void*)(buf),(size_t)(len),0,sadr,(socklen_t)sizeof(addr));\
 	ok=(nbytes!=(-1));\
 	if (!ok){err=errno;wouldblock=(err==EAGAIN||err==EWOULDBLOCK);}
 
@@ -131,7 +158,9 @@
 	if (!ok)err=errno
 
 #define OsclConnect(s,addr,ok,err,wouldblock)\
-	ok=(connect(s,(sockaddr*)&addr,sizeof(addr))!=(-1));\
+    TOsclSockAddr* tmpadr = &addr;\
+    sockaddr* sadr = OSCL_STATIC_CAST(sockaddr*, tmpadr);\
+	ok=(connect(s,sadr,sizeof(addr))!=(-1));\
 	if (!ok){err=errno;wouldblock=(err==EINPROGRESS);}
 
 #define OsclGetAsyncSockErr(s,ok,err)\
@@ -154,9 +183,13 @@
 	if (!ok){err=errno;wouldblock=(err==EAGAIN);}
 
 #define OsclRecvFrom(s,buf,len,paddr,paddrlen,ok,err,nbytes,wouldblock)\
-	nbytes=recvfrom(s,(void*)(buf),(size_t)(len),0,(struct sockaddr*)paddr,paddrlen);\
+{\
+void* p=paddr;\
+nbytes=recvfrom(s,(void*)(buf),(size_t)(len),0,(struct sockaddr*)p,paddrlen);\
 	ok=(nbytes!=(-1));\
-	if (!ok){err=errno;wouldblock=(err==EAGAIN);}
+	if (!ok){err=errno;wouldblock=(err==EAGAIN);}\
+}
+
 
 #define OsclSocketSelect(nfds,rd,wr,ex,timeout,ok,err,nhandles)\
 	nhandles=select(nfds,&rd,&wr,&ex,&timeout);\
diff --git a/oscl/oscl/config/linux_nj/osclconfig_lib.h b/oscl/oscl/config/linux_nj/osclconfig_lib.h
new file mode 100644
index 0000000..da17c93
--- /dev/null
+++ b/oscl/oscl/config/linux_nj/osclconfig_lib.h
@@ -0,0 +1,63 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+//     O S C L C O N F I G _ L I B  ( P L A T F O R M   C O N F I G   I N F O )
+
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+
+/*! \file osclconfig_lib.h
+    \brief This file contains configuration information for the ANSI build.
+
+*/
+
+#ifndef OSCLCONFIG_LIB_H_INCLUDED
+#define OSCLCONFIG_LIB_H_INCLUDED
+
+
+
+//Set this to 1 to indicate this platform has oscllib support
+#define OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT	1
+#define PV_RUNTIME_LIB_FILENAME_EXTENSION "so"
+
+//Set this to 1 to enable looking for debug versions of libraries.
+//Use #ifndef to allow the compiler setting to override this definition
+#ifndef OSCL_LIB_READ_DEBUG_LIBS
+#if defined(NDEBUG)
+#define OSCL_LIB_READ_DEBUG_LIBS 0
+#else
+#define OSCL_LIB_READ_DEBUG_LIBS 1
+#endif
+#endif
+
+// The path recursively from which the config files are picked up
+#ifndef PV_DYNAMIC_LOADING_CONFIG_FILE_PATH
+#ifdef ANDROID
+#define PV_DYNAMIC_LOADING_CONFIG_FILE_PATH "/system/etc"
+#else
+#define PV_DYNAMIC_LOADING_CONFIG_FILE_PATH "./"
+#endif
+#endif
+
+// check all osclconfig required macros are defined
+#include "osclconfig_lib_check.h"
+
+#endif // OSCLCONFIG_LIB_H_INCLUDED
+
diff --git a/oscl/oscl/config/linux_nj/osclconfig_memory.h b/oscl/oscl/config/linux_nj/osclconfig_memory.h
index ed655ab..58ed3c1 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_memory.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_memory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -82,6 +82,8 @@
 //OSCL_HAS_HEAP_BASE_SUPPORT - Enables or disables overloaded memory operators in HeapBase class
 #define OSCL_HAS_HEAP_BASE_SUPPORT 1
 
+#define OSCL_HAS_SYMBIAN_MEMORY_FUNCS 0
+
 
 #include "osclconfig_memory_check.h"
 
diff --git a/oscl/oscl/config/linux_nj/osclconfig_proc.h b/oscl/oscl/config/linux_nj/osclconfig_proc.h
index 1383fcc..84c755c 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_proc.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_proc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,5 @@
 
 #include "osclconfig_proc_check.h"
 
-#include <sys/prctl.h>
-#define OSCL_SET_THREAD_NAME(name) prctl(PR_SET_NAME,(unsigned long)name,0,0,0)
 
 #endif
diff --git a/oscl/oscl/config/linux_nj/osclconfig_proc_unix_nj.h b/oscl/oscl/config/linux_nj/osclconfig_proc_unix_nj.h
index 24acbde..0b2d14d 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_proc_unix_nj.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_proc_unix_nj.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,14 +31,18 @@
 #ifndef OSCLCONFIG_PROC_UNIX_NJ_H_INCLUDED
 #define OSCLCONFIG_PROC_UNIX_NJ_H_INCLUDED
 
+#define OSCL_HAS_SYMBIAN_SCHEDULER 0
 
+#define OSCL_HAS_THREAD_SUPPORT 1
+#define OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT 0
 
 //semaphore with advanced realtime features incl. timed wait.
+#define OSCL_HAS_SEM_TIMEDWAIT_SUPPORT 0
 //#include <time.h>
 //#include <semaphore.h>
 
 //pthreads
-
+#define OSCL_HAS_PTHREAD_SUPPORT 1
 #include <pthread.h>
 #include <errno.h>
 #include <signal.h>
diff --git a/oscl/oscl/config/linux_nj/osclconfig_time.h b/oscl/oscl/config/linux_nj/osclconfig_time.h
index b4fdddb..92e8ec2 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_time.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_time.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,9 @@
 
 
 
+#define OSCL_HAS_UNIX_TIME_FUNCS        1
+
+
 typedef struct timeval OsclBasicTimeStruct;
 typedef tm      OsclBasicDateTimeStruct;
 
diff --git a/oscl/oscl/config/linux_nj/osclconfig_unix_nj.h b/oscl/oscl/config/linux_nj/osclconfig_unix_nj.h
index 966742a..751ffb1 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_unix_nj.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_unix_nj.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -52,22 +52,22 @@
 
 #define OSCL_DISABLE_INLINES                0
 
+#define OSCL_HAS_ANSI_STDLIB_SUPPORT        1
+#define OSCL_HAS_ANSI_MATH_SUPPORT          1
+#define OSCL_HAS_GLOBAL_VARIABLE_SUPPORT    1
+#define OSCL_HAS_ANSI_STRING_SUPPORT        1
+#define OSCL_HAS_ANSI_WIDE_STRING_SUPPORT   0
+#define OSCL_HAS_ANSI_STDIO_SUPPORT         1
 
-
-
-
-
-
-#ifndef OSCL_MEMFRAG_PTR_BEFORE_LEN
 #define OSCL_MEMFRAG_PTR_BEFORE_LEN         1
-#endif
 
-
-
+#define OSCL_HAS_UNIX_SUPPORT               1
+#define OSCL_HAS_MSWIN_SUPPORT              0
+#define OSCL_HAS_SYMBIAN_SUPPORT            0
 
 // 64-bit int
-
-
+#define OSCL_HAS_NATIVE_INT64_TYPE 1
+#define OSCL_HAS_NATIVE_UINT64_TYPE 1
 #define OSCL_NATIVE_INT64_TYPE     int64_t
 #define OSCL_NATIVE_UINT64_TYPE    uint64_t
 #define INT64(x) x##LL
@@ -76,25 +76,27 @@
 #define UINT64_HILO(high,low) ((((high##ULL))<<32)|low)
 
 // character set.
-
+#define OSCL_HAS_UNICODE_SUPPORT            1
 #define OSCL_NATIVE_WCHAR_TYPE wchar_t
+#if (OSCL_HAS_UNICODE_SUPPORT)
 #define _STRLIT(x) L ## x
+#else
+#define _STRLIT(x) x
+#endif
 #define _STRLIT_CHAR(x) x
 #define _STRLIT_WCHAR(x) L ## x
 
 // Thread-local storage.  Unix has keyed TLS.
-
+#define OSCL_HAS_TLS_SUPPORT    1
 #define OSCL_TLS_IS_KEYED 1
 typedef pthread_key_t TOsclTlsKey ;
 #define OSCL_TLS_KEY_CREATE_FUNC(key) (pthread_key_create(&key,NULL)==0)
 #define OSCL_TLS_KEY_DELETE_FUNC(key) pthread_key_delete(key)
 #define OSCL_TLS_STORE_FUNC(key,ptr) (pthread_setspecific(key,(const void*)ptr)==0)
 #define OSCL_TLS_GET_FUNC(key) pthread_getspecific(key)
-typedef pthread_t TOsclTlsThreadId;
-#define OSCL_TLS_THREAD_ID_FUNC() pthread_self()
-#define OSCL_TLS_THREAD_ID_EQUAL(t1,t2) (pthread_equal(t1,t2)!=0)
 
 //Basic lock
+#define OSCL_HAS_BASIC_LOCK 1
 #include <pthread.h>
 typedef pthread_mutex_t TOsclBasicLockObject;
 
diff --git a/oscl/oscl/config/linux_nj/osclconfig_util.h b/oscl/oscl/config/linux_nj/osclconfig_util.h
index 91ff109..2fd28de 100644
--- a/oscl/oscl/config/linux_nj/osclconfig_util.h
+++ b/oscl/oscl/config/linux_nj/osclconfig_util.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,8 +27,8 @@
 #include <sys/time.h> // timeval
 
 #define OSCL_CLOCK_HAS_DRIFT_CORRECTION 0
-
-
+#define OSCL_HAS_SYMBIAN_TIMERS 0
+#define OSCL_HAS_SYMBIAN_MATH   0
 
 #define OSCL_RAND_MAX           RAND_MAX
 
diff --git a/oscl/oscl/config/shared/osclconfig_ansi_memory.h b/oscl/oscl/config/shared/osclconfig_ansi_memory.h
index 61db53d..fb53ea1 100644
--- a/oscl/oscl/config/shared/osclconfig_ansi_memory.h
+++ b/oscl/oscl/config/shared/osclconfig_ansi_memory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
 
 #include <memory.h>
 typedef size_t oscl_memsize_t;
+#define OSCL_HAS_ANSI_MEMORY_FUNCS 1
 
 
 #endif
diff --git a/oscl/oscl/config/shared/osclconfig_check.h b/oscl/oscl/config/shared/osclconfig_check.h
index 2c61398..e16d092 100644
--- a/oscl/oscl/config/shared/osclconfig_check.h
+++ b/oscl/oscl/config/shared/osclconfig_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,9 +54,41 @@
 #error "ERROR: OSCL_DISABLE_INLINES has to be defined to either 1 or 0."
 #endif
 
+/**
+\def OSCL_HAS_ANSI_STDLIB_SUPPORT macro should be set to 1 if
+the target compiler supports ANSI C standard lib functions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_STDLIB_SUPPORT
+#error "ERROR: OSCL_HAS_ANSI_STDLIB_SUPPORT has to be defined to either 1 or 0."
+#endif
 
+/**
+\def OSCL_HAS_ANSI_STDIO_SUPPORT macro should be set to 1 if
+the target compiler supports ANSI C standard I/O functions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_STDIO_SUPPORT
+#error "ERROR: OSCL_HAS_ANSI_STDIO_SUPPORT has to be defined to either 1 or 0."
+#endif
 
+/**
+\def OSCL_HAS_ANSI_STRING_SUPPORT macro should be set to 1 if
+the target compiler supports ANSI C standard string functions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_STRING_SUPPORT
+#error "ERROR: OSCL_HAS_ANSI_STRING_SUPPORT has to be defined to either 1 or 0."
+#endif
 
+/**
+\def OSCL_HAS_UNICODE_SUPPORT macro should be set to 1 if
+the target platform has a native 16-bit (wide) character type.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_UNICODE_SUPPORT
+#error "ERROR: OSCL_HAS_UNICODE_SUPPORT has to be defined to either 1 or 0."
+#endif
 
 /**
 \def _STRLIT macro should be set to an expression to convert
@@ -85,7 +117,7 @@
 appropriate for the platform.
 Otherwise it should be set to 0.
 */
-#if !defined(_STRLIT_WCHAR)
+#if (OSCL_HAS_UNICODE_SUPPORT) && !defined(_STRLIT_WCHAR)
 #error "ERROR: _STRLIT_WCHAR has to be defined"
 #endif
 
@@ -95,12 +127,36 @@
 the native wide character type for the platform.
 Otherwise it should be set to 0.
 */
-#if !defined(OSCL_NATIVE_WCHAR_TYPE)
+#if (OSCL_HAS_UNICODE_SUPPORT) && !defined(OSCL_NATIVE_WCHAR_TYPE)
 #error "ERROR: OSCL_NATIVE_WCHAR_TYPE has to be defined."
 #endif
 
+/**
+\def OSCL_HAS_MSWIN_SUPPORT macro should be set to 1 if
+the target platform supports the Win32 API.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_MSWIN_SUPPORT
+#error "ERROR: OSCL_HAS_MSWIN_SUPPORT has to be defined to either 1 or 0"
+#endif
 
+/**
+\def OSCL_HAS_MSWIN_SUPPORT macro should be set to 1 if
+the target platform supports the Unix API.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_UNIX_SUPPORT
+#error "ERROR: OSCL_HAS_UNIX_SUPPORT has to be defined to either 1 or 0."
+#endif
 
+/**
+\def OSCL_HAS_SYMBIAN_SUPPORT macro should be set to 1 if
+the target platform supports the Symbian API.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_SUPPORT
+#error "ERROR: OSCL_HAS_SYMBIAN_SUPPORT has to be defined to either 1 or 0"
+#endif
 
 /**
 \def OSCL_INTEGERS_WORD_ALIGNED macro should be set to 1 if
@@ -140,6 +196,26 @@
 #error "ERROR: either OSCL_BYTE_ORDER_LITTLE_ENDIAN or else OSCL_BYTE_ORDER_BIG_ENDIAN must be 1."
 #endif
 
+/**
+\def OSCL_HAS_GLOBAL_VARIABLE_SUPPORT macro should be set to 1 if
+the target platform allows global variable definitions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_GLOBAL_VARIABLE_SUPPORT
+#error "ERROR: OSCL_HAS_GLOBAL_VARIABLE_SUPPORT has to be defined to either 1 or 0."
+#endif
+
+/**
+\def When OSCL_HAS_GLOBAL_VARIABLE_SUPPORT is 0, OSCL_HAS_PARTIAL_GLOBAL_VARIABLE_SUPPORT
+macro should be set to 1 if the target platform allows global variable definitions within
+the Oscl base library.
+Otherwise it should be set to 0.
+*/
+#if !(OSCL_HAS_GLOBAL_VARIABLE_SUPPORT)
+#ifndef OSCL_HAS_PARTIAL_GLOBAL_VARIABLE_SUPPORT
+#error "ERROR: OSCL_HAS_PARTIAL_GLOBAL_VARIABLE_SUPPORT has to be defined to either 1 or 0."
+#endif
+#endif
 
 /**
 Note: only one byte order mode can be defined per platform.
@@ -148,73 +224,113 @@
 #error "ERROR: Multiple selection for OSCL_BYTE_ORDER."
 #endif
 
+/**
+\def OSCL_HAS_ANSI_STRING_SUPPORT macro should be set to 1 if
+the target platform supports C standard string functions (string.h).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_STRING_SUPPORT
+#error "ERROR: OSCL_HAS_ANSI_STRING_SUPPORT has to be defined to either 1 or 0."
+#endif
 
+/**
+\def OSCL_HAS_NATIVE_INT64_TYPE has to be defined to either 1 or 0.
+*/
+#ifndef OSCL_HAS_NATIVE_INT64_TYPE
+#error "ERROR: OSCL_HAS_NATIVE_INT64_TYPE has to be defined to either 1 or 0."
+#endif
 
+/**
+\def OSCL_HAS_NATIVE_UINT64_TYPE has to be defined to either 1 or 0.
+*/
+#ifndef OSCL_HAS_NATIVE_UINT64_TYPE
+#error "ERROR: OSCL_HAS_NATIVE_UINT64_TYPE has to be defined to either 1 or 0."
+#endif
 
 /**
 \def When OSCL_HAS_NATIVE_INT64_TYPE is 1,
 OSCL_NATIVE_INT64_TYPE has to be defined to the native
 signed 64-bit integer type.
 */
+#if OSCL_HAS_NATIVE_INT64_TYPE
 #ifndef OSCL_NATIVE_INT64_TYPE
 #error "ERROR: OSCL_NATIVE_INT64_TYPE has to be defined."
 #endif
+#endif
 
 /**
 \def When OSCL_HAS_NATIVE_UINT64_TYPE is 1,
 OSCL_NATIVE_UINT64_TYPE has to be defined to the native
 unsigned 64-bit integer type.
 */
+#if OSCL_HAS_NATIVE_UINT64_TYPE
 #ifndef OSCL_NATIVE_UINT64_TYPE
 #error "ERROR: OSCL_NATIVE_UINT64_TYPE has to be defined."
 #endif
+#endif
 
 /**
 \def When OSCL_HAS_NATIVE_INT64_TYPE is 1,
 INT64(x) has to be defined to the expression for a signed
 64-bit literal.
 */
+#if OSCL_HAS_NATIVE_INT64_TYPE
 #ifndef INT64
 #error "ERROR: INT64(x) has to be defined."
 #endif
+#endif
 
 /**
 \def When OSCL_HAS_NATIVE_UINT64_TYPE is 1,
 INT64(x) has to be defined to the expression for a signed
 64-bit literal.
 */
+#if OSCL_HAS_NATIVE_UINT64_TYPE
 #ifndef UINT64
 #error "ERROR: UINT64(x) has to be defined."
 #endif
+#endif
 
 /**
 \def When OSCL_HAS_NATIVE_INT64_TYPE is 1,
 INT64_HILO(high,low) has to be defined to an expression
 to create a signed 64-bit integer from 2 32-bit integers.
 */
+#if OSCL_HAS_NATIVE_INT64_TYPE
 #ifndef INT64_HILO
 #error "ERROR: INT64_HILO(high,low) has to be defined."
 #endif
+#endif
 
 /**
 \def When OSCL_HAS_NATIVE_UINT64_TYPE is 1,
 UINT64_HILO(high,low) has to be defined to an expression
 to create an unsigned 64-bit integer from 2 32-bit integers.
 */
+#if OSCL_HAS_NATIVE_UINT64_TYPE
 #ifndef UINT64_HILO
 #error "ERROR: UINT64_HILO(high,low) has to be defined."
 #endif
+#endif
 
-#ifndef OSCL_MEMFRAG_PTR_BEFORE_LEN
 /**
 \def OSCL_MEMFRAG_PTR_BEFORE_LEN macro should be set to 1 if
 memory fragements data structures, such as used by sendmsg
 (i.e., the iovec data structures), should use ptr before length.
 Otherwise it should be set to 0.
 */
+#ifndef OSCL_MEMFRAG_PTR_BEFORE_LEN
 #error "ERROR: OSCL_MEMFRAG_PTR_BEFORE_LEN has to be defined to either 0 or 1"
 #endif
 
+/**
+\def OSCL_HAS_TLS_SUPPORT macro should be set to 1 if
+the target platform has thread-local storage functions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_TLS_SUPPORT
+#error "ERROR: OSCL_HAS_TLS_SUPPORT has to be defined to either 1 or 0"
+#endif
 
 /**
 \def OSCL_TLS_IS_KEYED macro should be set to 1 if
@@ -268,29 +384,6 @@
 #error "ERROR: OSCL_TLS_KEY_DELETE_FUNC has to be defined"
 #endif
 
-/**
-When OSCL_TLS_IS_KEYED==1,
-\def OSCL_TLS_THREAD_ID_FUNC macro should be set to an expression that
-returns a unique thread ID.
-Alternately,
-\def OSCL_TLS_THREAD_ID_FUNC_EXPR macro should be set to an expression that
-returns a unique thread ID and evaluates to true if successful.
-The macro takes one output parameter of type TOsclTlsThreadId.
-*/
-#if (OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_THREAD_ID_FUNC) && !defined(OSCL_TLS_THREAD_ID_FUNC_EXPR)
-#error "ERROR: Either OSCL_TLS_THREAD_ID_FUNC or OSCL_TLS_THREAD_ID_FUNC_EXPR has to be defined"
-#endif
-
-/**
-When OSCL_TLS_IS_KEYED==1,
-\def OSCL_TLS_THREAD_ID_EQUAL macro should be set to an expression that
-compares 2 thread IDs and returns true if they are equal, false if not equal.
-The macro takes 2 input paramers (id1, id2)
-*/
-#if (OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_THREAD_ID_EQUAL)
-#error "ERROR: OSCL_TLS_THREAD_ID_EQUAL has to be defined"
-#endif
-
 
 /**
 When OSCL_TLS_IS_KEYED==0,
@@ -298,7 +391,7 @@
 set the TLS value and evalutes to true on success, false on failure.
 The macro takes 1 input parameter (ptr).
 */
-#if ! OSCL_TLS_IS_KEYED && !defined(OSCL_TLS_STORE_FUNC)
+#if (OSCL_HAS_TLS_SUPPORT) && !(OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_STORE_FUNC)
 #error "ERROR: OSCL_TLS_STORE_FUNC has to be defined"
 #endif
 
@@ -307,11 +400,20 @@
 \def OSCL_TLS_GET_FUNC macro should be set to an expression that
 returns the TLS value.
 */
-#if ! OSCL_TLS_IS_KEYED && !defined(OSCL_TLS_GET_FUNC)
+#if (OSCL_HAS_TLS_SUPPORT) && !(OSCL_TLS_IS_KEYED) && !defined(OSCL_TLS_GET_FUNC)
 #error "ERROR: OSCL_TLS_GET_FUNC has to be defined"
 #endif
 
 /**
+OSCL_HAS_BASIC_LOCK should be set to 1 if the platform has basic lock support.
+*/
+#if !defined(OSCL_HAS_BASIC_LOCK )
+#error "ERROR: OSCL_HAS_BASIC_LOCK must be defined to 0 or 1"
+#endif
+
+
+/**
+When OSCL_HAS_BASIC_LOCK is 1,
 type TOsclBasicLockObject should be defined as the type used as
 a mutex object or handle on the target platform.  It can
 be either typedef'd as a C-compilable type or can be #defined.
@@ -319,7 +421,7 @@
 typedef pthread_mutex_t TOsclBasicLockObject;
 #define TOsclBasicLockObject RMutex
 */
-#if !defined(TOsclBasicLockObject)
+#if (OSCL_HAS_BASIC_LOCK) && !defined(TOsclBasicLockObject)
 typedef TOsclBasicLockObject __verify__TOsclBasicLockObject__defined__;
 #endif
 
diff --git a/oscl/oscl/config/shared/osclconfig_error_check.h b/oscl/oscl/config/shared/osclconfig_error_check.h
index f4c99f0..301181e 100644
--- a/oscl/oscl/config/shared/osclconfig_error_check.h
+++ b/oscl/oscl/config/shared/osclconfig_error_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,9 +20,42 @@
 #define OSCLCONFIG_ERROR_CHECK_H_INCLUDED
 
 
+/**
+OSCL_HAS_EXCEPTIONS macro should be set to 1 if
+the target platform supports C++ exceptions (throw, catch).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_EXCEPTIONS
+#error "ERROR: OSCL_HAS_EXCEPTIONS has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_EXCEPTIONS macro should be set to 1 if
+the target platform supports the POSIX-compliant errno.h header file.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ERRNO_H
+#error "ERROR: OSCL_HAS_ERRNO_H has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SYMBIAN_ERRORTRAP macro should be set to 1 if
+the target platform has Symbian leave, trap, and cleanup stack support.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_ERRORTRAP
+#error "ERROR: OSCL_HAS_SYMBIAN_ERRORTRAP has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SETJMP_H macro should be set to 1 if
+the target platform supports the setjmp.h header file including
+the setjmp and longjmp functions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SETJMP_H
+#error "ERROR: OSCL_HAS_SETJMP_H has to be defined to either 1 or 0"
+#endif
 
 
 #endif //OSCLCONFIG_ERROR_CHECK_H_INCLUDED
diff --git a/oscl/oscl/config/shared/osclconfig_global_new_delete.h b/oscl/oscl/config/shared/osclconfig_global_new_delete.h
index 94309a9..d3d0112 100644
--- a/oscl/oscl/config/shared/osclconfig_global_new_delete.h
+++ b/oscl/oscl/config/shared/osclconfig_global_new_delete.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/shared/osclconfig_global_placement_new.h b/oscl/oscl/config/shared/osclconfig_global_placement_new.h
index 7df7780..539b0be 100644
--- a/oscl/oscl/config/shared/osclconfig_global_placement_new.h
+++ b/oscl/oscl/config/shared/osclconfig_global_placement_new.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/shared/osclconfig_io_check.h b/oscl/oscl/config/shared/osclconfig_io_check.h
index f1c082d..500c347 100644
--- a/oscl/oscl/config/shared/osclconfig_io_check.h
+++ b/oscl/oscl/config/shared/osclconfig_io_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,12 +18,55 @@
 #ifndef OSCLCONFIG_IO_CHECK_H_INCLUDED
 #define OSCLCONFIG_IO_CHECK_H_INCLUDED
 
+/**
+OSCL_HAS_ANSI_FILE_IO_SUPPORT macro should be set to 1 if
+the target platform supports the ANSI C file I/O functions (fopen, fread, etc).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_FILE_IO_SUPPORT
+#error "ERROR: OSCL_HAS_ANSI_FILE_IO_SUPPORT has to be defined to either 1 or 0"
+#endif
+
+/**
+OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION macro should be set to 1 if
+the target platform supports the Symbian file I/O functions (RFile, RFs).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION
+#error "ERROR: OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION has to be defined to either 1 or 0"
+#endif
+
+/**
+On Symbian platforms only:
+OSCL_HAS_NATIVE_DUPLICATE_FILE_HANDLE  macro should be set to 1 if
+the target platform supports the Symbian file I/O function RFile::Duplicate.
+Otherwise it should be set to 0.
+*/
+#if (OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION)
+#ifndef OSCL_HAS_NATIVE_DUPLICATE_FILE_HANDLE
+#error "ERROR: OSCL_HAS_NATIVE_DUPLICATE_FILE_HANDLE has to be defined to either 1 or 0"
+#endif
+#endif
 
 
+/**
+OSCL_HAS_NATIVE_FILE_CACHE_ENABLE macro should be set to 1 if
+the target platform includes native file cache capability.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_NATIVE_FILE_CACHE_ENABLE
+#error "ERROR: OSCL_HAS_NATIVE_FILE_CACHE_ENABLE has to be defined to either 1 or 0"
+#endif
 
 
-
-
+/**
+OSCL_HAS_PV_FILE_CACHE macro should be set to 1 if
+the target platform includes PV file cache capability.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_PV_FILE_CACHE
+#error "ERROR: OSCL_HAS_PV_FILE_CACHE has to be defined to either 1 or 0"
+#endif
 
 /**
 OSCL_FILE_BUFFER_MAX_SIZE macro should be set to
@@ -34,28 +77,67 @@
 #error "ERROR: OSCL_FILE_BUFFER_MAX_SIZE has to be defined to a numeric value"
 #endif
 
+/**
+OSCL_HAS_SOCKET_SUPPORT macro should be set to 1 if
+the target platform supports sockets of any type.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SOCKET_SUPPORT
+#error "ERROR: OSCL_HAS_SOCKET_SUPPORT has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SYMBIAN_SOCKET_SERVER macro should be set to
+1 if the platform supports Symbian socket API (RSocket, RSocketServ).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_SOCKET_SERVER
+#error "ERROR: OSCL_HAS_SYMBIAN_SOCKET_SERVER has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SYMBIAN_DNS_SERVER macro should be set to
+1 if the platform supports Symbian Host Resolver API (RHostResolver).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_DNS_SERVER
+#error "ERROR: OSCL_HAS_SYMBIAN_DNS_SERVER has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_BERKELEY_SOCKETS macro should be set to
+1 if the platform supports Berkeley style socket API, including
+non-blocking I/O and a 'select' call.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_BERKELEY_SOCKETS
+#error "ERROR: OSCL_HAS_BERKELEY_SOCKETS has to be defined to either 1 or 0"
+#endif
 
 /**
 For platforms with Berkeley type sockets,
 TOsclSocket typedef should be set to platform native socket type.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 typedef TOsclSocket __TOsclSocketCheck___;
+#endif
 
 /**
 For platforms with Berkeley type sockets,
 TOsclSockAddr typedef should be set to platform native socket address type.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 typedef TOsclSockAddr __TOsclSockAddrCheck___;
+#endif
 
 /**
 For platforms with Berkeley type sockets,
 TOsclSockAddrLen typedef should be set to platform native socket address
 length type.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 typedef TOsclSockAddrLen __TOsclSockAddrLenCheck___;
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -67,9 +149,11 @@
 On failure, 'ok' must be set to false and 'err' must be set
 to the bind error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclBind
 #error "ERROR: OsclBind(s,addr,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -82,23 +166,29 @@
 On failure, 'ok' must be set to false and 'err' must be set
 to the listen error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclListen
 #error "ERROR: OsclListen(s,size,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
-OsclAccept(s,accept_s,ok,err) must be defined to
-an expression that does an accept call and sets 'ok' and 'err'
-to indicate the result.
+OsclAccept(s,accept_s,ok,err,wouldblock) must be defined to
+an expression that does an accept call and sets 'ok', 'err',
+and 'wouldblock' to indicate the result.
 's' and 'accept_s' are the socket and accept socket args to the
 accept call.
 On success, 'ok' must be set to true.
 On failure, 'ok' must be set to false and 'err' must be set
-to the accept error.
+to the accept error.  Additionally 'wouldblock' must be set to true
+if the error code indicates that the socket is non-blocking and
+would block, or to false otherwise.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclAccept
-#error "ERROR: OsclAccept(s,accept_s,ok,err) has to be defined"
+#error "ERROR: OsclAccept(s,accept_s,ok,err,wouldblock) has to be defined"
+#endif
 #endif
 
 /**
@@ -110,9 +200,11 @@
 On failure, 'ok' must be set to false and 'err' must be set
 to the error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSetNonBlocking
 #error "ERROR: OsclSetNonBlocking(s,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -125,9 +217,11 @@
 On failure, 'ok' must be set to false and 'err' must be set
 to the shutdown error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclShutdown
 #error "ERROR: OsclShutdown(s,how,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -140,9 +234,11 @@
 On failure, 'ok' must be set to false and 'err' must be set
 to the socket error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSocket
 #error "ERROR: OsclSocket(s,fam,type,prot,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -158,9 +254,11 @@
 if the error code indicates that the socket is non-blocking and
 would block, or to false otherwise.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSendTo
 #error "ERROR: OsclSendTo(s,buf,len,flags,addr,ok,err,nbytes,wouldblock) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -175,9 +273,11 @@
 if the error code indicates that the socket is non-blocking and
 would block, or to false otherwise.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSend
 #error "ERROR: OsclSend(s,buf,len,ok,err,nbytes,wouldblock) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -188,9 +288,11 @@
 On failure, 'ok' must be set to false and 'err' must be set
 to the close error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclCloseSocket
 #error "ERROR: OsclCloseSocket(s,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -204,9 +306,11 @@
 if the error code indicates that the socket is non-blocking and
 would block, or to false otherwise.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclConnect
 #error "ERROR: OsclConnect(s,addr,ok,err,wouldblock) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -225,9 +329,11 @@
 the error.  If the connect error is not obtained, 'ok' is set false
 and 'err' is the error code from the attempt.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclConnectComplete
 #error "ERROR: OsclConnectComplete(s,wset,eset,success,fail,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -242,9 +348,11 @@
 if the error code indicates that the socket is non-blocking and
 would block, or to false otherwise.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclRecv
 #error "ERROR: OsclRecv(s,buf,len,ok,err,nbytes,wouldblock) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -259,9 +367,11 @@
 if the error code indicates that the socket is non-blocking and
 would block, or to false otherwise.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclRecvFrom
 #error "ERROR: OsclRecvFrom(s,buf,len,paddr,paddrlen,ok,err,nbytes,wouldblock) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -275,9 +385,11 @@
 On failure, 'ok' must be set to false 'err' must be set
 to the select error.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSocketSelect
 #error "ERROR: OsclSocketSelect(nfds,rd,wr,ex,timeout,ok,err,nhandles) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -287,9 +399,11 @@
 On success, 'ok' must be set to true.
 On failure, 'ok' must be set to false.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSocketStartup
 #error "ERROR: OsclSocketStartup(ok) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -299,9 +413,11 @@
 On success, 'ok' must be set to true.
 On failure, 'ok' must be set to false.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclSocketCleanup
 #error "ERROR: OsclSocketCleanup(ok) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -314,15 +430,19 @@
 On failure, 'ok' must be set false and 'err' must be set to the
 error from the getsockopt call.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclGetAsyncSockErr
 #error "ERROR: OsclGetAsyncSockErr(s,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
 TOsclHostent typedef should be set to platform native hostent type.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 typedef TOsclHostent __TOsclHostentCheck___;
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -335,9 +455,11 @@
 On failure, 'ok' must be set false and 'err' must be set to the
 error from the gethostbyname call.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclGethostbyname
 #error "ERROR: OsclGethostbyname(name,hostent,ok,err) has to be defined"
 #endif
+#endif
 
 /**
 For platforms with Berkeley type sockets,
@@ -348,9 +470,11 @@
 'dottedaddr' is a char* output containing the dotted address,
 and 'ok' is a bool that should be set true on success, false on failure.
 */
+#if OSCL_HAS_BERKELEY_SOCKETS
 #ifndef OsclGetDottedAddr
 #error "ERROR: OsclGetDottedAddr(hostent,dottedaddr,ok) has to be defined"
 #endif
+#endif
 
 
 /**
@@ -358,9 +482,25 @@
 used with the select() system call the following 3 macros must be defined
 */
 
+#if OSCL_HAS_SELECTABLE_PIPES
+#ifndef OsclPipe
+#error "ERROR: OsclPipe(pipearray) has to be defined"
+#endif
+#endif
 
+#if OSCL_HAS_SELECTABLE_PIPES
+#ifndef OsclReadFD
+#error "ERROR: OsclReadFD(fd,buffer,cnt) has to be defined"
+#endif
+#endif
 
+#if OSCL_HAS_SELECTABLE_PIPES
+#ifndef OsclWriteFD
+#error "ERROR: OsclWriteFD(fd,buffer,cnt) has to be defined"
+#endif
+#endif
 
+#if OSCL_HAS_SOCKET_SUPPORT
 /**
 OsclValidInetAddr must be defined to a boolean expression to
 evaluate whether an address is proper IP4 format.
@@ -369,7 +509,9 @@
 #ifndef OsclValidInetAddr
 #error "ERROR: OsclValidInetAddr(addr) must be defined"
 #endif
+#endif
 
+#if OSCL_HAS_SOCKET_SUPPORT
 /**
 OSCL_SD_RECEIVE, OSCL_SD_SEND, and OSCL_SD_BOTH must be defined to
 the platform-specific socket shutdown codes.
@@ -383,7 +525,9 @@
 #ifndef OSCL_SD_BOTH
 #error "ERROR: OSCL_SD_BOTH has to be defined"
 #endif
+#endif
 
+#if OSCL_HAS_SOCKET_SUPPORT
 /**
 OSCL_AF_INET must be defined to the platform-specific
 network address family codes for INET.
@@ -391,7 +535,9 @@
 #ifndef OSCL_AF_INET
 #error "ERROR: OSCL_AF_INET has to be defined"
 #endif
+#endif
 
+#if OSCL_HAS_SOCKET_SUPPORT
 /**
 OSCL_SOCK_STREAM and OSCL_SOCK_DATAGRAM must be defined to
 the platform-specific socket type codes.
@@ -402,7 +548,9 @@
 #ifndef OSCL_SOCK_DATAGRAM
 #error "ERROR: OSCL_SOCK_DATAGRAM has to be defined"
 #endif
+#endif
 
+#if OSCL_HAS_SOCKET_SUPPORT
 /**
 OSCL_IPPROTO_TCP and OSCL_IPPROTO_UDP must be defined to
 the platform-specific IP protocol codes.
@@ -413,6 +561,7 @@
 #ifndef OSCL_IPPROTO_UDP
 #error "ERROR: OSCL_IPPROTO_UDP has to be defined"
 #endif
+#endif
 
 
 #endif // OSCLCONFIG_IO_CHECK_H_INCLUDED
diff --git a/oscl/oscl/config/shared/osclconfig_ix86.h b/oscl/oscl/config/shared/osclconfig_ix86.h
index 9d18441..87d7afb 100644
--- a/oscl/oscl/config/shared/osclconfig_ix86.h
+++ b/oscl/oscl/config/shared/osclconfig_ix86.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/shared/osclconfig_lib_check.h b/oscl/oscl/config/shared/osclconfig_lib_check.h
new file mode 100644
index 0000000..894451b
--- /dev/null
+++ b/oscl/oscl/config/shared/osclconfig_lib_check.h
@@ -0,0 +1,69 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef OSCLCONFIG_LIB_CHECK_H_INCLUDED
+#define OSCLCONFIG_LIB_CHECK_H_INCLUDED
+
+/*! \addtogroup osclconfig OSCL config
+ *
+ * @{
+ */
+
+
+
+/**
+OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT should be set to 1 if the platform has basic explicit runtime DLL loading support.
+*/
+#if !defined(OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT )
+#error "ERROR: OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT must be defined to 0 or 1"
+#endif
+
+#if(OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT)
+/**
+** When OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT is 1,
+** OSCL_LIB_READ_DEBUG_LIBS should be set to 0 or 1.  Set to 1 to enable loading
+** debug versions of libs.
+*/
+#if !defined(OSCL_LIB_READ_DEBUG_LIBS)
+#error "ERROR: OSCL_LIB_READ_DEBUG_LIBS must be defined to 0 or 1"
+#endif
+
+/*
+** When OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT is 1,
+** PV_DYNAMIC_LOADING_CONFIG_FILE_PATH should be set.
+*/
+#if !defined(PV_DYNAMIC_LOADING_CONFIG_FILE_PATH)
+#error "ERROR: PV_DYNAMIC_LOADING_CONFIG_FILE_PATH must be set to a path where the config files are expected to be present"
+#endif
+
+/*
+** When OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT is 1,
+** PV_RUNTIME_LIB_FILENAME_EXTENSION should be set.
+*/
+#if !defined(PV_RUNTIME_LIB_FILENAME_EXTENSION)
+#error "ERROR: PV_RUNTIME_LIB_FILENAME_EXTENSION must be specified for use as the dynamic library file extension"
+#endif
+
+#endif // OSCL_HAS_RUNTIME_LIB_LOADING_SUPPORT
+
+
+/*! @} */
+
+#endif // OSCLCONFIG_LIB_CHECK_H_INCLUDED
+
+
diff --git a/oscl/oscl/config/shared/osclconfig_limits_typedefs.h b/oscl/oscl/config/shared/osclconfig_limits_typedefs.h
index 30b1357..4ce355d 100644
--- a/oscl/oscl/config/shared/osclconfig_limits_typedefs.h
+++ b/oscl/oscl/config/shared/osclconfig_limits_typedefs.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/config/shared/osclconfig_memory_check.h b/oscl/oscl/config/shared/osclconfig_memory_check.h
index 945d4e2..8903111 100644
--- a/oscl/oscl/config/shared/osclconfig_memory_check.h
+++ b/oscl/oscl/config/shared/osclconfig_memory_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,23 @@
 #error "ERROR: OSCL_BYPASS_MEMMGT has to be defined to either 1 or 0"
 #endif
 
+/**
+OSCL_HAS_ANSI_MEMORY_FUNCS macro should be set to 1 if
+the target platform supports ANSI C memory functions (malloc, free, etc).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_MEMORY_FUNCS
+#error "ERROR: OSCL_HAS_ANSI_MEMORY_FUNCS has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SYMBIAN_MEMORY_FUNCS macro should be set to 1 if
+the target platform supports Symbian memory functions User::Alloc, User::Free, etc.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_MEMORY_FUNCS
+#error "ERROR: OSCL_HAS_SYMBIAN_MEMORY_FUNCS has to be defined to either 1 or 0"
+#endif
 
 /*
  * OSCL_HAS_HEAP_BASE_SUPPORT macro should be set to 1 for the
diff --git a/oscl/oscl/config/shared/osclconfig_no_os.h b/oscl/oscl/config/shared/osclconfig_no_os.h
index be4c31a..86e7c92 100644
--- a/oscl/oscl/config/shared/osclconfig_no_os.h
+++ b/oscl/oscl/config/shared/osclconfig_no_os.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,31 +27,39 @@
 //a file to turn off ALL os-specific switches.
 
 //osclconfig
-
-
-
-
-
+#define OSCL_HAS_UNIX_SUPPORT               0
+#define OSCL_HAS_MSWIN_SUPPORT              0
+#define OSCL_HAS_MSWIN_PARTIAL_SUPPORT      0
+#define OSCL_HAS_SYMBIAN_SUPPORT            0
+#define OSCL_HAS_SAVAJE_SUPPORT             0
+#define OSCL_HAS_PV_C_OS_SUPPORT            0
 
 //osclconfig_error
+#define OSCL_HAS_SYMBIAN_ERRORTRAP 0
 
 //osclconfig_memory
-
+#define OSCL_HAS_SYMBIAN_MEMORY_FUNCS 0
+#define OSCL_HAS_PV_C_OS_API_MEMORY_FUNCS 0
 
 //osclconfig_time
-
+#define OSCL_HAS_PV_C_OS_TIME_FUNCS 0
+#define OSCL_HAS_UNIX_TIME_FUNCS    0
 
 //osclconfig_util
-
+#define OSCL_HAS_SYMBIAN_TIMERS 0
+#define OSCL_HAS_SYMBIAN_MATH   0
 
 //osclconfig_proc
-
-
+#define OSCL_HAS_SYMBIAN_SCHEDULER 0
+#define OSCL_HAS_SEM_TIMEDWAIT_SUPPORT 0
+#define OSCL_HAS_PTHREAD_SUPPORT 0
 
 //osclconfig_io
-
-
-
+#define OSCL_HAS_SYMBIAN_COMPATIBLE_IO_FUNCTION 0
+#define OSCL_HAS_SAVAJE_IO_SUPPORT 0
+#define OSCL_HAS_SYMBIAN_SOCKET_SERVER 0
+#define OSCL_HAS_SYMBIAN_DNS_SERVER 0
+#define OSCL_HAS_BERKELEY_SOCKETS 0
 
 
 /*! @} */
diff --git a/oscl/oscl/config/shared/osclconfig_proc_check.h b/oscl/oscl/config/shared/osclconfig_proc_check.h
index d36666f..0cba8f2 100644
--- a/oscl/oscl/config/shared/osclconfig_proc_check.h
+++ b/oscl/oscl/config/shared/osclconfig_proc_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,9 +19,51 @@
 #ifndef OSCLCONFIG_PROC_CHECK_H_INCLUDED
 #define OSCLCONFIG_PROC_CHECK_H_INCLUDED
 
+/**
+OSCL_HAS_THREAD_SUPPORT macro should be set to 1 if
+the target platform supports threads.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_THREAD_SUPPORT
+#error "ERROR: OSCL_HAS_THREAD_SUPPORT has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT macro should be set to 1 if
+the target platform supports non-pre-emptive threads.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT
+#error "ERROR: OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SYMBIAN_SCHEDULER macro should be set to 1 if
+the target platform supports Symbian active object scheduler.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_SCHEDULER
+#error "ERROR: OSCL_HAS_SYMBIAN_SCHEDULER has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SEM_TIMEDWAIT_SUPPORT macro should be set to 1 if
+the target platform supports POSIX-compliant semaphores (semaphore.h)
+with advanced realtime features including sem_timedwait.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SEM_TIMEDWAIT_SUPPORT
+#error "ERROR: OSCL_HAS_SEM_TIMEDWAIT_SUPPORT has to be defined to either 1 or 0"
+#endif
+
+/**
+OSCL_HAS_PTHREAD_SUPPORT macro should be set to 1 if
+the target platform supports POSIX-compliand pthreads (pthread.h).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_PTHREAD_SUPPORT
+#error "ERROR: OSCL_HAS_PTHREAD_SUPPORT has to be defined to either 1 or 0"
+#endif
 
 /**
 type TOsclThreadId should be defined as the type used as
diff --git a/oscl/oscl/config/shared/osclconfig_proc_unix_common.h b/oscl/oscl/config/shared/osclconfig_proc_unix_common.h
index 2917533..104a2cc 100644
--- a/oscl/oscl/config/shared/osclconfig_proc_unix_common.h
+++ b/oscl/oscl/config/shared/osclconfig_proc_unix_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,15 +31,18 @@
 #ifndef OSCLCONFIG_PROC_UNIX_COMMON_H_INCLUDED
 #define OSCLCONFIG_PROC_UNIX_COMMON_H_INCLUDED
 
+#define OSCL_HAS_SYMBIAN_SCHEDULER 0
 
+#define OSCL_HAS_THREAD_SUPPORT 1
+#define OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT 0
 
 //semaphore with advanced realtime features incl. timed wait.
-
+#define OSCL_HAS_SEM_TIMEDWAIT_SUPPORT 1
 #include <time.h>
 #include <semaphore.h>
 
 //pthreads
-
+#define OSCL_HAS_PTHREAD_SUPPORT 1
 #include <pthread.h>
 #include <errno.h>
 
diff --git a/oscl/oscl/config/shared/osclconfig_time_check.h b/oscl/oscl/config/shared/osclconfig_time_check.h
index b8906f8..8cdf0ab 100644
--- a/oscl/oscl/config/shared/osclconfig_time_check.h
+++ b/oscl/oscl/config/shared/osclconfig_time_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,14 @@
 #define OSCLCONFIG_TIME_CHECK_H_INCLUDED
 
 
+/**
+OSCL_HAS_UNIX_TIME_FUNCS macro should be set to 1 if
+the target platform supports unix time of day functions.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_UNIX_TIME_FUNCS
+#error "ERROR: OSCL_HAS_UNIX_TIME_FUNCS has to be defined to either 1 or 0"
+#endif
 
 /**
 OsclBasicTimeStruct type should be defined to the platform-specific
diff --git a/oscl/oscl/config/shared/osclconfig_unix_common.h b/oscl/oscl/config/shared/osclconfig_unix_common.h
index 85388b0..6b9e6ca 100644
--- a/oscl/oscl/config/shared/osclconfig_unix_common.h
+++ b/oscl/oscl/config/shared/osclconfig_unix_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,26 +50,24 @@
 #endif
 #include <math.h>
 
-#ifndef OSCL_DISABLE_INLINES
 #define OSCL_DISABLE_INLINES                0
-#endif
 
+#define OSCL_HAS_ANSI_STDLIB_SUPPORT        1
+#define OSCL_HAS_ANSI_MATH_SUPPORT          1
+#define OSCL_HAS_GLOBAL_VARIABLE_SUPPORT    1
+#define OSCL_HAS_ANSI_STRING_SUPPORT        1
+#define OSCL_HAS_ANSI_WIDE_STRING_SUPPORT   1
+#define OSCL_HAS_ANSI_STDIO_SUPPORT         1
 
-
-
-
-
-
-#ifndef OSCL_MEMFRAG_PTR_BEFORE_LEN
 #define OSCL_MEMFRAG_PTR_BEFORE_LEN         1
-#endif
 
-
-
+#define OSCL_HAS_UNIX_SUPPORT               1
+#define OSCL_HAS_MSWIN_SUPPORT              0
+#define OSCL_HAS_SYMBIAN_SUPPORT            0
 
 // 64-bit int
-
-
+#define OSCL_HAS_NATIVE_INT64_TYPE 1
+#define OSCL_HAS_NATIVE_UINT64_TYPE 1
 #define OSCL_NATIVE_INT64_TYPE     int64_t
 #define OSCL_NATIVE_UINT64_TYPE    uint64_t
 #define INT64(x) x##LL
@@ -78,28 +76,27 @@
 #define UINT64_HILO(high,low) ((((high##ULL))<<32)|low)
 
 // character set.
-
+#define OSCL_HAS_UNICODE_SUPPORT            1
 #define OSCL_NATIVE_WCHAR_TYPE wchar_t
+#if (OSCL_HAS_UNICODE_SUPPORT)
 #define _STRLIT(x) L ## x
+#else
+#define _STRLIT(x) x
+#endif
 #define _STRLIT_CHAR(x) x
 #define _STRLIT_WCHAR(x) L ## x
 
 // Thread-local storage.  Unix has keyed TLS.
-
-#ifndef OSCL_TLS_IS_KEYED
+#define OSCL_HAS_TLS_SUPPORT    1
 #define OSCL_TLS_IS_KEYED 1
-#endif
-
 typedef pthread_key_t TOsclTlsKey ;
 #define OSCL_TLS_KEY_CREATE_FUNC(key) (pthread_key_create(&key,NULL)==0)
 #define OSCL_TLS_KEY_DELETE_FUNC(key) pthread_key_delete(key)
 #define OSCL_TLS_STORE_FUNC(key,ptr) (pthread_setspecific(key,(const void*)ptr)==0)
 #define OSCL_TLS_GET_FUNC(key) pthread_getspecific(key)
-typedef pthread_t TOsclTlsThreadId;
-#define OSCL_TLS_THREAD_ID_FUNC() pthread_self()
-#define OSCL_TLS_THREAD_ID_EQUAL(t1,t2) (pthread_equal(t1,t2)!=0)
 
 //Basic lock
+#define OSCL_HAS_BASIC_LOCK 1
 #include <pthread.h>
 typedef pthread_mutex_t TOsclBasicLockObject;
 
diff --git a/oscl/oscl/config/shared/osclconfig_util_check.h b/oscl/oscl/config/shared/osclconfig_util_check.h
index 22cf9ee..f615c4a 100644
--- a/oscl/oscl/config/shared/osclconfig_util_check.h
+++ b/oscl/oscl/config/shared/osclconfig_util_check.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,8 +18,32 @@
 #ifndef OSCLCONFIG_UTIL_CHECK_H_INCLUDED
 #define OSCLCONFIG_UTIL_CHECK_H_INCLUDED
 
+/**
+OSCL_HAS_SYMBIAN_TIMERS macro should be set to 1 if
+the target platform supports Symbian timers (RTimer).
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_TIMERS
+#error "ERROR: OSCL_HAS_SYMBIAN_TIMERS has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_SYMBIAN_MATH macro should be set to 1 if
+the target platform supports Symbian <e32math.h> features.
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_SYMBIAN_MATH
+#error "ERROR: OSCL_HAS_SYMBIAN_MATH has to be defined to either 1 or 0"
+#endif
 
+/**
+OSCL_HAS_ANSI_MATH_SUPPORT macro should be set to 1 if
+the target platform supports the ANSI C math functions (math.h)
+Otherwise it should be set to 0.
+*/
+#ifndef OSCL_HAS_ANSI_MATH_SUPPORT
+#error "ERROR: OSCL_HAS_ANSI_MATH_SUPPORT has to be defined to either 1 or 0"
+#endif
 
 /**
 OSCL_CLOCK_HAS_DRIFT_CORRECTION macro should be set to 1 if the target platform
diff --git a/oscl/oscl/makefile b/oscl/oscl/makefile
deleted file mode 100755
index 4186b5f..0000000
--- a/oscl/oscl/makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-LIBDIRS = \
-	osclbase/build/make \
-	osclerror/build/make \
-	osclmemory/build/make \
-	osclutil/build/make \
-	osclproc/build/make \
-	../pvlogger/build/make \
-	osclio/build/make \
-	osclregserv/build/make \
-	osclregcli/build/make
-
-TESTDIRS = \
-	osclbase/test/build/make \
-	osclerror/test/build/make \
-	osclmemory/test/build/make \
-	osclutil/test/build/make \
-	osclproc/test/build/make \
-	../pvlogger/test/build/make \
-	osclio/test/build/make  \
-	osclregcli/test/build/make
-
-
-ifeq ($(UNITTEST),1)
-LIBDIRS += \
-	../unit_test/build/make 
-endif
-
-include $(MK)/recursive.mk
-
-doc:
-	 perl $(VOB_BASE_DIR)/tools_v2/build/document/bin/doc_build.bat --doctype oscl --title "OSCL API" --path "$(VOB_BASE_DIR)/oscl/oscl" --filetype "mainpage *.h readme.txt" --exclude_pattern "*/test/* */obsolete/* */doxydir/*" -ver $(OSCL_VERSION)
-
-
-
-
diff --git a/oscl/oscl/makefile.pv b/oscl/oscl/makefile.pv
deleted file mode 100644
index 2a69db9..0000000
--- a/oscl/oscl/makefile.pv
+++ /dev/null
@@ -1,18 +0,0 @@
-
-# This file, "makefile.pv", is supposed to specify the compiler flags
-# necessary to build the project - be that a library, an executable, or a
-# bigger system.
-#
-# Unless something really extraordinary is necessary, the default settings
-# should suffice; hence, one include should be enough. If, however, it is not
-# enough, this file should still be included and the appropriate variables
-# modified, so that there is a way to change every library/project's build
-# environment from one place.
-# 
-# Namely, this file contains preprocessor, compiler and linker flags,
-# including paths, but not including build elements.
-#
-#
-
-include $(VOB_BASE_DIR)/tools/build/defaults/makefile.pv.mk
-
diff --git a/oscl/oscl/osclbase/Android.mk b/oscl/oscl/osclbase/Android.mk
index 867db09..94b6be6 100644
--- a/oscl/oscl/osclbase/Android.mk
+++ b/oscl/oscl/osclbase/Android.mk
@@ -3,69 +3,78 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_time.cpp \
-	src/oscl_assert.cpp \
-	src/oscl_byte_order.cpp \
-	src/oscl_tree.cpp \
-	src/oscl_tagtree.cpp \
-	src/oscl_stdstring.cpp \
-	src/oscl_string_utils.cpp \
-	src/oscl_int64_utils.cpp \
-	src/oscl_base.cpp \
-	src/oscl_tls.cpp \
-	src/oscl_mem_basic_functions.cpp \
-	src/oscl_singleton.cpp \
-	src/oscl_vector.cpp \
-	src/oscl_queue.cpp \
-	src/oscl_linked_list.cpp
-
+ 	src/oscl_assert.cpp \
+ 	src/oscl_byte_order.cpp \
+ 	src/oscl_tree.cpp \
+ 	src/oscl_tagtree.cpp \
+ 	src/oscl_stdstring.cpp \
+ 	src/oscl_string_utils.cpp \
+ 	src/oscl_int64_utils.cpp \
+ 	src/oscl_base.cpp \
+ 	src/oscl_tls.cpp \
+ 	src/oscl_mem_basic_functions.cpp \
+ 	src/oscl_singleton.cpp \
+ 	src/oscl_vector.cpp \
+ 	src/oscl_queue.cpp \
+ 	src/oscl_linked_list.cpp \
+ 	src/pvlogger.cpp \
+ 	src/pvlogger_c.cpp
 
 
 LOCAL_MODULE := libosclbase
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclbase/src \
-	$(PV_TOP)//oscl/oscl/osclbase/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclbase/src \
+ 	$(PV_TOP)/oscl/oscl/osclbase/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_assert.h \
-	src/oscl_base.h \
-	src/oscl_base_alloc.h \
-	src/oscl_base_macros.h \
-	src/oscl_byte_order.h \
-	src/oscl_defalloc.h \
-	src/oscl_dll.h \
-	src/oscl_exclusive_ptr.h \
-	src/oscl_int64_utils.h \
-	src/oscl_mem_inst.h \
-	src/oscl_mem_basic_functions.h \
-	src/oscl_mem_basic_functions.inl \
-	src/oscl_linked_list.h \
-	src/oscl_lock_base.h \
-	src/oscl_map.h \
-	src/oscl_opaque_type.h \
-	src/oscl_queue.h \
-	src/oscl_refcounter.h \
-	src/oscl_refcounter_memfrag.h \
-	src/oscl_shared_ptr.h \
-	src/oscl_stdstring.h \
-	src/oscl_string_utils.h \
-	src/oscl_tagtree.h \
-	src/oscl_time.h \
-	src/oscl_tls.h \
-	src/oscl_tree.h \
-	src/oscl_types.h \
-	src/oscl_uuid.h \
-	src/oscl_vector.h \
-	src/oscl_singleton.h \
-	src/oscl_assert.inl \
-	src/oscl_byte_order.inl \
-	src/oscl_time.inl
+ 	src/oscl_base.h \
+ 	src/oscl_base_alloc.h \
+ 	src/oscl_base_macros.h \
+ 	src/oscl_byte_order.h \
+ 	src/oscl_defalloc.h \
+ 	src/oscl_dll.h \
+ 	src/oscl_exclusive_ptr.h \
+ 	src/oscl_int64_utils.h \
+ 	src/oscl_mem_inst.h \
+ 	src/oscl_mem_basic_functions.h \
+ 	src/oscl_mem_basic_functions.inl \
+ 	src/oscl_linked_list.h \
+ 	src/oscl_lock_base.h \
+ 	src/oscl_map.h \
+ 	src/oscl_opaque_type.h \
+ 	src/oscl_queue.h \
+ 	src/oscl_refcounter.h \
+ 	src/oscl_refcounter_memfrag.h \
+ 	src/oscl_shared_ptr.h \
+ 	src/oscl_stdstring.h \
+ 	src/oscl_string_utils.h \
+ 	src/oscl_tagtree.h \
+ 	src/oscl_time.h \
+ 	src/oscl_tls.h \
+ 	src/oscl_tree.h \
+ 	src/oscl_types.h \
+ 	src/oscl_uuid.h \
+ 	src/oscl_vector.h \
+ 	src/oscl_singleton.h \
+ 	src/oscl_assert.inl \
+ 	src/oscl_byte_order.inl \
+ 	src/oscl_time.inl \
+ 	src/pvlogger.h \
+ 	src/pvlogger_c.h \
+ 	src/pvlogger_registry.h \
+ 	src/pvlogger_accessories.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclbase/build/make/local.mk b/oscl/oscl/osclbase/build/make/local.mk
new file mode 100644
index 0000000..2b68f0e
--- /dev/null
+++ b/oscl/oscl/osclbase/build/make/local.mk
@@ -0,0 +1,75 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+
+TARGET := osclbase
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS :=	oscl_time.cpp \
+	oscl_assert.cpp \
+	oscl_byte_order.cpp \
+	oscl_tree.cpp \
+	oscl_tagtree.cpp \
+	oscl_stdstring.cpp \
+	oscl_string_utils.cpp \
+	oscl_int64_utils.cpp \
+	oscl_base.cpp \
+	oscl_tls.cpp \
+	oscl_mem_basic_functions.cpp \
+	oscl_singleton.cpp \
+	oscl_vector.cpp \
+	oscl_queue.cpp \
+	oscl_linked_list.cpp \
+	pvlogger.cpp \
+	pvlogger_c.cpp
+
+
+HDRS :=	oscl_assert.h \
+	oscl_base.h \
+	oscl_base_alloc.h \
+	oscl_base_macros.h \
+	oscl_byte_order.h \
+	oscl_defalloc.h \
+	oscl_dll.h \
+	oscl_exclusive_ptr.h \
+	oscl_int64_utils.h \
+	oscl_mem_inst.h \
+	oscl_mem_basic_functions.h \
+	oscl_mem_basic_functions.inl \
+	oscl_linked_list.h \
+	oscl_lock_base.h \
+	oscl_map.h \
+	oscl_opaque_type.h \
+	oscl_queue.h \
+	oscl_refcounter.h \
+	oscl_refcounter_memfrag.h \
+	oscl_shared_ptr.h \
+	oscl_stdstring.h \
+	oscl_string_utils.h \
+	oscl_tagtree.h \
+	oscl_time.h \
+	oscl_tls.h \
+	oscl_tree.h \
+	oscl_types.h \
+	oscl_uuid.h \
+	oscl_vector.h \
+	oscl_singleton.h \
+	oscl_assert.inl \
+	oscl_byte_order.inl \
+	oscl_time.inl \
+	pvlogger.h \
+	pvlogger_c.h \
+	pvlogger_registry.h \
+	pvlogger_accessories.h
+
+
+include $(MK)/library.mk
diff --git a/oscl/oscl/osclbase/build/make/makefile b/oscl/oscl/osclbase/build/make/makefile
deleted file mode 100644
index f340717..0000000
--- a/oscl/oscl/osclbase/build/make/makefile
+++ /dev/null
@@ -1,113 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclbase
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	oscl_time.cpp \
-	oscl_assert.cpp \
-	oscl_byte_order.cpp \
-	oscl_tree.cpp \
-	oscl_tagtree.cpp \
-	oscl_stdstring.cpp \
-	oscl_string_utils.cpp \
-	oscl_int64_utils.cpp \
-	oscl_base.cpp \
-	oscl_tls.cpp \
-	oscl_mem_basic_functions.cpp \
-	oscl_singleton.cpp \
-	oscl_vector.cpp \
-	oscl_queue.cpp \
-	oscl_linked_list.cpp
-#\
-#oscl_mem_basic_functions.cpp
-
-
-HDRS =	oscl_assert.h \
-	oscl_base.h \
-	oscl_base_alloc.h \
-	oscl_base_macros.h \
-	oscl_byte_order.h \
-	oscl_defalloc.h \
-	oscl_dll.h \
-	oscl_exclusive_ptr.h \
-	oscl_int64_utils.h \
-	oscl_mem_inst.h \
-	oscl_mem_basic_functions.h \
-	oscl_mem_basic_functions.inl \
-	oscl_linked_list.h \
-	oscl_lock_base.h \
-	oscl_map.h \
-	oscl_opaque_type.h \
-	oscl_queue.h \
-	oscl_refcounter.h \
-	oscl_refcounter_memfrag.h \
-	oscl_shared_ptr.h \
-	oscl_stdstring.h \
-	oscl_string_utils.h \
-	oscl_tagtree.h \
-	oscl_time.h \
-	oscl_tls.h \
-	oscl_tree.h \
-	oscl_types.h \
-	oscl_uuid.h \
-	oscl_vector.h \
-	oscl_singleton.h \
-	oscl_assert.inl \
-	oscl_byte_order.inl \
-	oscl_time.inl 
-
-#\
-#	oscl_mem_basic_functions.h
-#\
-#	oscl_mem_basic_functions.inl
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/oscl/oscl/osclbase/src/oscl_assert.cpp b/oscl/oscl/osclbase/src/oscl_assert.cpp
index 58c1853..e0cc9e7 100644
--- a/oscl/oscl/osclbase/src/oscl_assert.cpp
+++ b/oscl/oscl/osclbase/src/oscl_assert.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,15 +22,38 @@
 #include "oscl_assert.inl"
 #endif
 
+#include "pvlogger.h"
+
 OSCL_EXPORT_REF void OSCL_Assert(const char *expression, const char *filename, int line_number)
 {
-    //log the assertion...
+#if(OSCL_HAS_ERROR_HOOK)
+    //If there's an error hook installed, just log and jump there.
+    //This is mainly for unit test support, but conceivably some platform
+    //might also have an error hook.
+    int32 error;
+    OsclAny* ptr = OsclTLSRegistry::getInstance(OSCL_TLS_ID_ERRORHOOK, error);
+    if (ptr)
+    {
+        //log the assertion.
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, PVLogger::GetLoggerObject("OSCL_Assert"), PVLOGMSG_EMERG
+                        , (0, "Assertion failure for: %s, at %s:%d", expression, filename, line_number));
+        //jump to the error hook
+        longjmp(*((jmp_buf*)ptr), -1);
+    }
+#endif
+
+    //Print to standard debug output...
 
 
     //default
     fprintf(stderr, "Assertion failure for: %s, at %s:%d\n", expression, filename, line_number);
 
 
+    //log the assertion.
+    //this is risky if OsclBase is un-initialized, so do it last.
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, PVLogger::GetLoggerObject("OSCL_Assert"), PVLOGMSG_EMERG
+                    , (0, "Assertion failure for: %s, at %s:%d", expression, filename, line_number));
+
     // ...then abort
     _OSCL_Abort();
 }
diff --git a/oscl/oscl/osclbase/src/oscl_assert.h b/oscl/oscl/osclbase/src/oscl_assert.h
index 25db0d6..098d2e5 100644
--- a/oscl/oscl/osclbase/src/oscl_assert.h
+++ b/oscl/oscl/osclbase/src/oscl_assert.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_assert.inl b/oscl/oscl/osclbase/src/oscl_assert.inl
index 19f7e90..1c24a24 100644
--- a/oscl/oscl/osclbase/src/oscl_assert.inl
+++ b/oscl/oscl/osclbase/src/oscl_assert.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,16 +15,11 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-
-#ifndef LOG_TAG
-#define LOG_TAG "OpenCore"
+#if(OSCL_HAS_ERROR_HOOK)
+#include "oscl_tls.h"
 #endif
 
-#include <utils/Log.h>
-
 OSCL_COND_EXPORT_REF OSCL_INLINE void _OSCL_Abort()
 {
-    // cause a segfault
-    LOGV("_OSCL_Abort");
-    *(char*) 0 = 0;
+    abort();
 }
diff --git a/oscl/oscl/osclbase/src/oscl_base.cpp b/oscl/oscl/osclbase/src/oscl_base.cpp
index 7212d68..b338a26 100644
--- a/oscl/oscl/osclbase/src/oscl_base.cpp
+++ b/oscl/oscl/osclbase/src/oscl_base.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -86,6 +86,7 @@
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
 
+#if(OSCL_HAS_BASIC_LOCK)
 //
 // _OsclBasicLock
 //
@@ -131,5 +132,7 @@
         iError = result;
 
 }
+#endif //OSCL_HAS_BASIC_LOCK
+
 
 
diff --git a/oscl/oscl/osclbase/src/oscl_base.h b/oscl/oscl/osclbase/src/oscl_base.h
index 6119fc4..79b565f 100644
--- a/oscl/oscl/osclbase/src/oscl_base.h
+++ b/oscl/oscl/osclbase/src/oscl_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,8 +40,17 @@
 #include "oscl_types.h"
 #include "osclconfig_check.h"
 
+#ifdef USE_CML2_CONFIG
+#include "pv_config.h"
+#endif
+
+//singleton support derives from global var support.
+#define OSCL_HAS_SINGLETON_SUPPORT 1
+
 #ifdef __cplusplus
 
+class OsclLockBase;
+
 class OsclBase
 {
     public:
@@ -50,6 +59,13 @@
          * OsclBase must be initialized before any OsclBase
          * functionality can be used.
          *
+         * Note: The first call to OsclBase::Init will initialize
+         *  the thread lock that is used to avoid thread contention
+         *  for process scope singleton access.  The last call to
+         *  OsclBase::Cleanup will cleanup the thread lock.
+         *  Case should be taken to avoid possible thread contention
+         *  on the first Init and the last Cleanup call.
+         *
          * @return 0 on success
          */
         OSCL_IMPORT_REF static int32 Init();
@@ -84,6 +100,7 @@
  * OsclTLSRegistry and OsclSingleton.
  * Higher-level code should use OsclMutex instead.
  */
+#if (OSCL_HAS_BASIC_LOCK)
 class _OsclBasicLock : public OsclLockBase
 {
     public:
@@ -120,6 +137,9 @@
         TOsclBasicLockObject    ObjLock;
 
 };
+#else
+typedef OsclNullLock _OsclBasicLock;
+#endif
 
 #else
 
diff --git a/oscl/oscl/osclbase/src/oscl_base_alloc.h b/oscl/oscl/osclbase/src/oscl_base_alloc.h
index 4984ebc..9f315ea 100644
--- a/oscl/oscl/osclbase/src/oscl_base_alloc.h
+++ b/oscl/oscl/osclbase/src/oscl_base_alloc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_base_macros.h b/oscl/oscl/osclbase/src/oscl_base_macros.h
index 256b2ec..935374d 100644
--- a/oscl/oscl/osclbase/src/oscl_base_macros.h
+++ b/oscl/oscl/osclbase/src/oscl_base_macros.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@
  *   OSCL_ASSERT and thus unreferenced in release mode
  * OSCL_UNUSED_RETURN(val) provides a "return" of a value, in places
  *   which will not actually be executed, such as after an
- *   OSCL_LEAVE or Thread::exit or PANIC.  The value needs to
+ *   OSCL_LEAVE or Thread::exit or abort.  The value needs to
  *   be of an appropriate type for the current function, though
  *   zero will usually suffice.  Note that OSCL_UNUSED_RETURN
  *   will not be necessary for 'void' functions, as there is no
diff --git a/oscl/oscl/osclbase/src/oscl_byte_order.cpp b/oscl/oscl/osclbase/src/oscl_byte_order.cpp
index 06dce28..759956e 100644
--- a/oscl/oscl/osclbase/src/oscl_byte_order.cpp
+++ b/oscl/oscl/osclbase/src/oscl_byte_order.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_byte_order.h b/oscl/oscl/osclbase/src/oscl_byte_order.h
index 697e83d..12f53f2 100644
--- a/oscl/oscl/osclbase/src/oscl_byte_order.h
+++ b/oscl/oscl/osclbase/src/oscl_byte_order.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_byte_order.inl b/oscl/oscl/osclbase/src/oscl_byte_order.inl
index 2acac01..76eaed9 100644
--- a/oscl/oscl/osclbase/src/oscl_byte_order.inl
+++ b/oscl/oscl/osclbase/src/oscl_byte_order.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_defalloc.h b/oscl/oscl/osclbase/src/oscl_defalloc.h
index 998dc80..089d608 100644
--- a/oscl/oscl/osclbase/src/oscl_defalloc.h
+++ b/oscl/oscl/osclbase/src/oscl_defalloc.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_dll.h b/oscl/oscl/osclbase/src/oscl_dll.h
index b1bb14e..50b30fd 100644
--- a/oscl/oscl/osclbase/src/oscl_dll.h
+++ b/oscl/oscl/osclbase/src/oscl_dll.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h b/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h
index 58f9fc1..e3ffd86 100644
--- a/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h
+++ b/oscl/oscl/osclbase/src/oscl_exclusive_ptr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -121,7 +121,8 @@
         */
         virtual ~OsclExclusivePtr()
         {
-            delete _Ptr;
+            if (_Ptr)
+                delete _Ptr;
         }
 
         /**
@@ -259,7 +260,8 @@
         */
         virtual ~OsclExclusiveArrayPtr()
         {
-            delete [] _Ptr;
+            if (_Ptr)
+                delete [] _Ptr;
         }
 
         /**
diff --git a/oscl/oscl/osclbase/src/oscl_int64_utils.cpp b/oscl/oscl/osclbase/src/oscl_int64_utils.cpp
index 883cf84..3163640 100644
--- a/oscl/oscl/osclbase/src/oscl_int64_utils.cpp
+++ b/oscl/oscl/osclbase/src/oscl_int64_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_int64_utils.h b/oscl/oscl/osclbase/src/oscl_int64_utils.h
index ac8994b..ea897f1 100644
--- a/oscl/oscl/osclbase/src/oscl_int64_utils.h
+++ b/oscl/oscl/osclbase/src/oscl_int64_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_linked_list.cpp b/oscl/oscl/osclbase/src/oscl_linked_list.cpp
index 2e1feac..6674978 100644
--- a/oscl/oscl/osclbase/src/oscl_linked_list.cpp
+++ b/oscl/oscl/osclbase/src/oscl_linked_list.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_linked_list.h b/oscl/oscl/osclbase/src/oscl_linked_list.h
index cb97d37..9e7a1ad 100644
--- a/oscl/oscl/osclbase/src/oscl_linked_list.h
+++ b/oscl/oscl/osclbase/src/oscl_linked_list.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_lock_base.h b/oscl/oscl/osclbase/src/oscl_lock_base.h
index a502049..99d17d7 100644
--- a/oscl/oscl/osclbase/src/oscl_lock_base.h
+++ b/oscl/oscl/osclbase/src/oscl_lock_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_map.h b/oscl/oscl/osclbase/src/oscl_map.h
index d122d0a..ffda878 100644
--- a/oscl/oscl/osclbase/src/oscl_map.h
+++ b/oscl/oscl/osclbase/src/oscl_map.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp b/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp
index 4e8fb9d..ede227a 100644
--- a/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp
+++ b/oscl/oscl/osclbase/src/oscl_mem_basic_functions.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h b/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h
index fe4ecca..5353b3c 100644
--- a/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h
+++ b/oscl/oscl/osclbase/src/oscl_mem_basic_functions.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl b/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl
index 0294734..ebfeec3 100644
--- a/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl
+++ b/oscl/oscl/osclbase/src/oscl_mem_basic_functions.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_mem_inst.h b/oscl/oscl/osclbase/src/oscl_mem_inst.h
index f3a41a7..78bc9c6 100644
--- a/oscl/oscl/osclbase/src/oscl_mem_inst.h
+++ b/oscl/oscl/osclbase/src/oscl_mem_inst.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_opaque_type.h b/oscl/oscl/osclbase/src/oscl_opaque_type.h
index 9125d07..5319898 100644
--- a/oscl/oscl/osclbase/src/oscl_opaque_type.h
+++ b/oscl/oscl/osclbase/src/oscl_opaque_type.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_queue.cpp b/oscl/oscl/osclbase/src/oscl_queue.cpp
index 1127387..a223c35 100644
--- a/oscl/oscl/osclbase/src/oscl_queue.cpp
+++ b/oscl/oscl/osclbase/src/oscl_queue.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_queue.h b/oscl/oscl/osclbase/src/oscl_queue.h
index bc8282e..f68d40c 100644
--- a/oscl/oscl/osclbase/src/oscl_queue.h
+++ b/oscl/oscl/osclbase/src/oscl_queue.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_refcounter.h b/oscl/oscl/osclbase/src/oscl_refcounter.h
index 34dc17a..a58d397 100644
--- a/oscl/oscl/osclbase/src/oscl_refcounter.h
+++ b/oscl/oscl/osclbase/src/oscl_refcounter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h b/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h
index 62607d0..4871ac5 100644
--- a/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h
+++ b/oscl/oscl/osclbase/src/oscl_refcounter_memfrag.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_shared_ptr.h b/oscl/oscl/osclbase/src/oscl_shared_ptr.h
index a3c7d86..d2b0a2c 100644
--- a/oscl/oscl/osclbase/src/oscl_shared_ptr.h
+++ b/oscl/oscl/osclbase/src/oscl_shared_ptr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_singleton.cpp b/oscl/oscl/osclbase/src/oscl_singleton.cpp
index af1d669..310b02e 100644
--- a/oscl/oscl/osclbase/src/oscl_singleton.cpp
+++ b/oscl/oscl/osclbase/src/oscl_singleton.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,9 +48,9 @@
     }
 
     //increment the ref count on each init.
-    iSingletonTable->iLock.Lock();
+    iSingletonTable->iTableLock.Lock();
     iSingletonTable->iRefCount++;
-    iSingletonTable->iLock.Unlock();
+    iSingletonTable->iTableLock.Unlock();
 }
 
 OSCL_EXPORT_REF void OsclSingletonRegistry::cleanup(Oscl_DefAlloc &alloc, int32 &aError)
@@ -63,19 +63,19 @@
     }
 
     //decrement the ref count and cleanup when it reaches zero.
-    iSingletonTable->iLock.Lock();
+    iSingletonTable->iTableLock.Lock();
     iSingletonTable->iRefCount--;
     if (iSingletonTable->iRefCount == 0)
     {
         //cleanup
-        iSingletonTable->iLock.Unlock();
+        iSingletonTable->iTableLock.Unlock();
         iSingletonTable->~SingletonTable();
         alloc.deallocate(iSingletonTable);
         iSingletonTable = NULL;
     }
     else
     {
-        iSingletonTable->iLock.Unlock();
+        iSingletonTable->iTableLock.Unlock();
     }
 }
 
@@ -90,9 +90,9 @@
         return NULL;
     }
 
-    iSingletonTable->iLock.Lock();
+    iSingletonTable->iSingletonLocks[ID].Lock();
     OsclAny* value = iSingletonTable->iSingletons[ID];
-    iSingletonTable->iLock.Unlock();
+    iSingletonTable->iSingletonLocks[ID].Unlock();
 
     return value;
 }
@@ -108,9 +108,46 @@
         return;
     }
 
-    iSingletonTable->iLock.Lock();
+    iSingletonTable->iSingletonLocks[ID].Lock();
     iSingletonTable->iSingletons[ID] = ptr;
-    iSingletonTable->iLock.Unlock();
+    iSingletonTable->iSingletonLocks[ID].Unlock();
+}
+
+OSCL_EXPORT_REF OsclAny* OsclSingletonRegistry::lockAndGetInstance(uint32 ID, int32 &aError)
+{
+    OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST);
+
+    aError = 0;
+
+    if (!iSingletonTable)
+    {
+        aError = EPVErrorBaseNotInstalled;//no table!
+        return NULL;
+    }
+
+    iSingletonTable->iSingletonLocks[ID].Lock();
+    OsclAny* value = iSingletonTable->iSingletons[ID];
+    //leave it locked.
+
+    return value;
+}
+
+OSCL_EXPORT_REF void OsclSingletonRegistry::registerInstanceAndUnlock(OsclAny* ptr, uint32 ID, int32 &aError)
+{
+    OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST);
+
+    aError = 0;
+
+    if (!iSingletonTable)
+    {
+        aError = EPVErrorBaseNotInstalled;//no table!
+        return;
+    }
+
+    //assume it's already locked.
+
+    iSingletonTable->iSingletons[ID] = ptr;
+    iSingletonTable->iSingletonLocks[ID].Unlock();
 }
 
 #endif //OSCL_HAS_SINGLETON_SUPPORT
diff --git a/oscl/oscl/osclbase/src/oscl_singleton.h b/oscl/oscl/osclbase/src/oscl_singleton.h
index f8c414d..ec3a293 100644
--- a/oscl/oscl/osclbase/src/oscl_singleton.h
+++ b/oscl/oscl/osclbase/src/oscl_singleton.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,7 +61,10 @@
 const uint32 OSCL_SINGLETON_ID_CPM_PLUGIN     =  7;
 const uint32 OSCL_SINGLETON_ID_PVMFRECOGNIZER =  8;
 const uint32 OSCL_SINGLETON_ID_OSCLREGISTRY   =  9;
-const uint32 OSCL_SINGLETON_ID_LAST           = 10;
+const uint32 OSCL_SINGLETON_ID_OMX            = 10;
+const uint32 OSCL_SINGLETON_ID_OMXMASTERCORE  = 11;
+const uint32 OSCL_SINGLETON_ID_TICKCOUNT      = 12;
+const uint32 OSCL_SINGLETON_ID_LAST           = 13;
 
 
 class OsclSingletonRegistry
@@ -70,18 +73,39 @@
         /*
         ** Get an entry
         ** @param ID: identifier
-        ** @param error (output) 0 for success or an error from TPVBasePanicEnum
+        ** @param error (output) 0 for success or an error from TPVBaseErrorEnum
         ** @returns: the entry value
         */
         OSCL_IMPORT_REF static OsclAny* getInstance(uint32 ID, int32 &error);
         /*
         ** Set an entry
         ** @param ID: identifier
-        ** @param error (output) 0 for success or an error from TPVBasePanicEnum
+        ** @param error (output) 0 for success or an error from TPVBaseErrorEnum
         ** @returns: the entry value
         */
         OSCL_IMPORT_REF static void registerInstance(OsclAny* ptr, uint32 ID, int32 &error);
 
+        /*
+        //These two APIs can be used to do "test and set" operations on a singleton.
+        //Be sure to always call both APIs to avoid deadlock.
+        */
+
+        /*
+        * Return the current value of the singleton and leave the singleton table locked
+        * on return.
+        * @param ID the singleton ID
+        ** @param error (output) 0 for success or an error from TPVBaseErrorEnum
+        * @returns the singleton value.
+        */
+        OSCL_IMPORT_REF static OsclAny* lockAndGetInstance(uint32 ID, int32& error);
+        /*
+        * Set the value of the singleton.  Assume the singleton table is locked on entry.
+        * @param ptr the singleton value
+        * @param ID the singleton ID
+        ** @param error (output) 0 for success or an error from TPVBaseErrorEnum
+        */
+        OSCL_IMPORT_REF static void registerInstanceAndUnlock(OsclAny* ptr, uint32 ID, int32& error);
+
     private:
         OsclSingletonRegistry()
         {}
@@ -102,9 +126,10 @@
                     for (uint32 i = 0;i < OSCL_SINGLETON_ID_LAST;i++)
                         iSingletons[i] = NULL;
                 }
-                _OsclBasicLock iLock;
+                _OsclBasicLock iTableLock;
                 uint32 iRefCount;
                 OsclAny* iSingletons[OSCL_SINGLETON_ID_LAST];
+                _OsclBasicLock iSingletonLocks[OSCL_SINGLETON_ID_LAST];
         };
         //The singleton table is a global variable.
         static SingletonTable* iSingletonTable;
@@ -121,10 +146,13 @@
 
     protected:
         T* _Ptr;
-        int32 _error;
 
     public:
-        OsclSingleton(): _Ptr(OSCL_STATIC_CAST(T*, Registry::getInstance(ID, _error))) {};
+        OsclSingleton()
+        {
+            int32 err;
+            _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err));
+        }
 
         ~OsclSingleton() {};
 
@@ -161,7 +189,8 @@
         */
         bool set()
         {
-            _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, _error));
+            int32 err;
+            _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err));
             return (_Ptr ? true : false);
         }
 
diff --git a/oscl/oscl/osclbase/src/oscl_stdstring.cpp b/oscl/oscl/osclbase/src/oscl_stdstring.cpp
index 277fe52..8174a7a 100644
--- a/oscl/oscl/osclbase/src/oscl_stdstring.cpp
+++ b/oscl/oscl/osclbase/src/oscl_stdstring.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -109,32 +109,100 @@
     return dest;
 }
 
-OSCL_EXPORT_REF char* oscl_strchr(const char *str, int32 c)
+OSCL_EXPORT_REF const char* oscl_strchr(const char *str, int32 c)
 {
-    while (*str != '\0')
+    if (str)
     {
-        if (*str == c)
+        while (*str != '\0')
         {
-            return (char *)str;
+            if (*str == (char)c)
+                return str;
+            str++;
         }
-        str++;
+        if (*str == (char)c)
+            return str;
     }
     return NULL;
 }
 
-OSCL_EXPORT_REF oscl_wchar* oscl_strchr(const oscl_wchar *str, int32 c)
+OSCL_EXPORT_REF char* oscl_strchr(char *str, int32 c)
 {
-    while (*str != '\0')
+    return (char*)oscl_strchr((const char*)str, c);
+}
+
+OSCL_EXPORT_REF const oscl_wchar* oscl_strchr(const oscl_wchar *str, int32 c)
+{
+    if (str)
     {
-        if ((int32)*str == c)
+        while (*str != '\0')
         {
-            return (oscl_wchar *)str;
+            if (*str == (oscl_wchar)c)
+                return str;
+            str++;
         }
-        str++;
+        if (*str == (oscl_wchar)c)
+            return str;
     }
     return NULL;
 }
 
+OSCL_EXPORT_REF oscl_wchar* oscl_strchr(oscl_wchar *str, int32 c)
+{
+    return (oscl_wchar*)oscl_strchr((const oscl_wchar*)str, c);
+}
+
+OSCL_EXPORT_REF const char* oscl_strrchr(const char *str, int32 c)
+{
+    if (!str)
+        return NULL;
+
+    const char*start = str;
+
+    while (*str != '\0')
+        str++;
+
+    while (str >= start)
+    {
+        if (*str == (char)c)
+            return str;
+        if (str == start)
+            return NULL;
+        str--;
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF char* oscl_strrchr(char *str, int32 c)
+{
+    return (char*)oscl_strrchr((const char*)str, c);
+}
+
+OSCL_EXPORT_REF const oscl_wchar* oscl_strrchr(const oscl_wchar *str, int32 c)
+{
+    if (!str)
+        return NULL;
+
+    const oscl_wchar*start = str;
+
+    while (*str != '\0')
+        str++;
+
+    while (str >= start)
+    {
+        if (*str == (oscl_wchar)c)
+            return str;
+        if (str == start)
+            return NULL;
+        str--;
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF oscl_wchar* oscl_strrchr(oscl_wchar *str, int32 c)
+{
+    return (oscl_wchar*)oscl_strrchr((const oscl_wchar*)str, c);
+}
+
 OSCL_EXPORT_REF char* oscl_strset(char* dest, char val, uint32 count)
 {
     for (uint32 ii = 0; ii < count; ii++)
@@ -217,18 +285,42 @@
         return car;
 }
 
-OSCL_EXPORT_REF  char* oscl_strstr(const char* str1,  const char* str2)
+OSCL_EXPORT_REF  const char* oscl_strstr(const char* str1,  const char* str2)
+{
+    return (const char*)strstr(str1, str2);
+}
+
+OSCL_EXPORT_REF  char* oscl_strstr(char* str1,  const char* str2)
 {
     return (char*)strstr(str1, str2);
 }
 
-OSCL_EXPORT_REF  oscl_wchar* oscl_strstr(const oscl_wchar* str1,  const oscl_wchar* str2)
+OSCL_EXPORT_REF  const oscl_wchar* oscl_strstr(const oscl_wchar* str1,  const oscl_wchar* str2)
 {
-    int size = oscl_strlen(str1);
-    oscl_wchar* p = (oscl_wchar*) str1;
-    while ((*p != '\0') && (size >= (int) oscl_strlen(str2)))
+    uint32 size = oscl_strlen(str1);
+    uint32 size2 = oscl_strlen(str2);
+    const oscl_wchar* p = (oscl_wchar*) str1;
+    while ((*p != '\0') && (size >= size2))
     {
-        if (!oscl_strncmp(p, str2, oscl_strlen(str2)))
+        if (!oscl_strncmp(p, str2, size2))
+            return p;
+        else
+        {
+            p += 1;
+            size -= 1;
+        }
+    }
+    return 0;
+}
+
+OSCL_EXPORT_REF  oscl_wchar* oscl_strstr(oscl_wchar* str1,  const oscl_wchar* str2)
+{
+    uint32 size = oscl_strlen(str1);
+    uint32 size2 = oscl_strlen(str2);
+    oscl_wchar* p = (oscl_wchar*) str1;
+    while ((*p != '\0') && (size >= size2))
+    {
+        if (!oscl_strncmp(p, str2, size2))
             return p;
         else
         {
diff --git a/oscl/oscl/osclbase/src/oscl_stdstring.h b/oscl/oscl/osclbase/src/oscl_stdstring.h
index 0f7e48f..3621117 100644
--- a/oscl/oscl/osclbase/src/oscl_stdstring.h
+++ b/oscl/oscl/osclbase/src/oscl_stdstring.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -195,6 +195,18 @@
  */
 OSCL_IMPORT_REF oscl_wchar* oscl_strncat(oscl_wchar* dest, const oscl_wchar* src, uint32 count);
 
+/**
+ * Finds the first occurrence of c in string, or it
+ * returns NULL if c is not found. The null-terminating
+ * character is included in the search.
+ *
+ * @param str    null terminated source string
+ * @param c      character to search for
+ *
+ * @return
+ */
+OSCL_IMPORT_REF const char* oscl_strchr(const char *str, int32 c);
+OSCL_IMPORT_REF char* oscl_strchr(char *str, int32 c);
 
 /**
  * Finds the first occurrence of c in string, or it
@@ -206,10 +218,11 @@
  *
  * @return
  */
-OSCL_IMPORT_REF char* oscl_strchr(const char *str, int32 c);
+OSCL_IMPORT_REF const oscl_wchar* oscl_strchr(const oscl_wchar *str, int32 c);
+OSCL_IMPORT_REF oscl_wchar* oscl_strchr(oscl_wchar *str, int32 c);
 
 /**
- * Finds the first occurrence of c in string, or it
+ * Finds the last occurrence of c in string, or it
  * returns NULL if c is not found. The null-terminating
  * character is included in the search.
  *
@@ -218,7 +231,10 @@
  *
  * @return
  */
-OSCL_IMPORT_REF oscl_wchar* oscl_strchr(const oscl_wchar *str, int32 c);
+OSCL_IMPORT_REF const char* oscl_strrchr(const char *str, int32 c);
+OSCL_IMPORT_REF char* oscl_strrchr(char *str, int32 c);
+OSCL_IMPORT_REF const oscl_wchar* oscl_strrchr(const oscl_wchar *str, int32 c);
+OSCL_IMPORT_REF oscl_wchar* oscl_strrchr(oscl_wchar *str, int32 c);
 
 /**
  * Sets the characters of a string to a specified character
@@ -342,7 +358,8 @@
  *
  * @return    pointer to the begining of sub-string.
  */
-OSCL_IMPORT_REF char* oscl_strstr(const char* str1, const char* str2);
+OSCL_IMPORT_REF const char* oscl_strstr(const char* str1, const char* str2);
+OSCL_IMPORT_REF char* oscl_strstr(char* str1, const char* str2);
 
 
 /**
@@ -353,7 +370,8 @@
  *
  * @return    pointer to the begining of sub-string.
  */
-OSCL_IMPORT_REF oscl_wchar* oscl_strstr(const oscl_wchar* str1, const oscl_wchar* str2);
+OSCL_IMPORT_REF const oscl_wchar* oscl_strstr(const oscl_wchar* str1, const oscl_wchar* str2);
+OSCL_IMPORT_REF oscl_wchar* oscl_strstr(oscl_wchar* str1, const oscl_wchar* str2);
 
 
 /**
diff --git a/oscl/oscl/osclbase/src/oscl_string_utils.cpp b/oscl/oscl/osclbase/src/oscl_string_utils.cpp
index e9fd0e4..4cadf8c 100644
--- a/oscl/oscl/osclbase/src/oscl_string_utils.cpp
+++ b/oscl/oscl/osclbase/src/oscl_string_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_string_utils.h b/oscl/oscl/osclbase/src/oscl_string_utils.h
index 9899d70..4f85d9f 100644
--- a/oscl/oscl/osclbase/src/oscl_string_utils.h
+++ b/oscl/oscl/osclbase/src/oscl_string_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_tagtree.cpp b/oscl/oscl/osclbase/src/oscl_tagtree.cpp
index 809791f..190b0b0 100644
--- a/oscl/oscl/osclbase/src/oscl_tagtree.cpp
+++ b/oscl/oscl/osclbase/src/oscl_tagtree.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_tagtree.h b/oscl/oscl/osclbase/src/oscl_tagtree.h
index 6805193..242f8d5 100644
--- a/oscl/oscl/osclbase/src/oscl_tagtree.h
+++ b/oscl/oscl/osclbase/src/oscl_tagtree.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_time.cpp b/oscl/oscl/osclbase/src/oscl_time.cpp
index be62ab7..a9eeae4 100644
--- a/oscl/oscl/osclbase/src/oscl_time.cpp
+++ b/oscl/oscl/osclbase/src/oscl_time.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_time.h b/oscl/oscl/osclbase/src/oscl_time.h
index b2f8236..13807eb 100644
--- a/oscl/oscl/osclbase/src/oscl_time.h
+++ b/oscl/oscl/osclbase/src/oscl_time.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_time.inl b/oscl/oscl/osclbase/src/oscl_time.inl
index 6ae1894..c439622 100644
--- a/oscl/oscl/osclbase/src/oscl_time.inl
+++ b/oscl/oscl/osclbase/src/oscl_time.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_tls.cpp b/oscl/oscl/osclbase/src/oscl_tls.cpp
index 4feb834..42379e1 100644
--- a/oscl/oscl/osclbase/src/oscl_tls.cpp
+++ b/oscl/oscl/osclbase/src/oscl_tls.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,9 @@
 #include "oscl_tls.h"
 #include "oscl_assert.h"
 
+//Use a magic number to help detect un-initialized TLS.
+#define OSCL_TLS_MAGIC_NUMBER 0x8765abcd
+#define OSCL_TLS_REGISTRY_VALID(reg) (reg!=0 && reg[OSCL_TLS_ID_MAGICNUM]==(OsclAny*)OSCL_TLS_MAGIC_NUMBER)
 
 OSCL_EXPORT_REF void TLSStorageOps::save_registry(TOsclTlsKey* key, OsclAny* ptr, int32 &aError)
 {
@@ -55,139 +58,10 @@
 
 #if (OSCL_TLS_IS_KEYED)
 
-//Global lookup table for Tls Keys.
-//There's one entry per thread.  Thread ID is used to lookup the key.
-OsclTLSRegistry::TlsKeyTable* OsclTLSRegistry::iTlsKeyTable = NULL;
+//Global var for Tls Key.
+OsclTLSRegistry::TlsKey* OsclTLSRegistry::iTlsKey = NULL;
 
 
-void OsclTLSRegistry::GetThreadId(TOsclTlsThreadId &threadId, int32 &aError)
-//Get thread ID of current thread.
-{
-    aError = 0;
-#if defined OSCL_TLS_THREAD_ID_FUNC
-
-    threadId = OSCL_TLS_THREAD_ID_FUNC();
-
-#elif defined OSCL_TLS_THREAD_ID_FUNC_EXPR
-
-    if (!OSCL_TLS_THREAD_ID_FUNC_EXPR(threadId))
-        aError = EPVErrorBaseSystemCallFailed;
-
-#else
-#error No Thread ID Function!
-#endif
-}
-
-TOsclTlsKey* OsclTLSRegistry::LookupTlsKey(int32 &aError)
-//Lookup Tls Key for current thread.
-{
-    aError = 0;
-
-    if (!iTlsKeyTable)
-    {
-        aError = EPVErrorBaseNotInstalled;//No table!
-        return NULL;
-    }
-
-    //Get the thread ID.
-    TOsclTlsThreadId threadId;
-    GetThreadId(threadId, aError);
-    if (aError)
-        return NULL;
-
-    //Search the Tls Key Table for this thread's entry.
-    iTlsKeyTable->iLock.Lock();
-    for (uint32 i = 0;i < OSCL_TLS_MAX_THREADS;i++)
-    {
-        if (OSCL_TLS_THREAD_ID_EQUAL(iTlsKeyTable->iKeys[i].iThreadId, threadId))
-        {
-            //found it!
-            iTlsKeyTable->iLock.Unlock();
-            return iTlsKeyTable->iKeys[i].iTlsKey;
-        }
-    }
-    iTlsKeyTable->iLock.Unlock();
-
-    return NULL;
-}
-
-bool OsclTLSRegistry::SaveTlsKey(TOsclTlsKey* aKey, int32 &aError)
-//Save Tls key in table.
-{
-    OSCL_ASSERT(aKey);
-
-    aError = 0;
-
-    if (!iTlsKeyTable)
-    {
-        aError = EPVErrorBaseNotInstalled;//No table!
-        return false;
-    }
-
-    bool saved = false;
-    iTlsKeyTable->iLock.Lock();
-    for (uint32 i = 0;i < OSCL_TLS_MAX_THREADS;i++)
-    {
-        if (iTlsKeyTable->iKeys[i].iTlsKey == NULL)
-        {
-            //found an empty entry.
-            iTlsKeyTable->iKeys[i].iTlsKey = aKey;
-            GetThreadId(iTlsKeyTable->iKeys[i].iThreadId, aError);
-            if (aError)
-                break;//can't get thread ID.
-            iTlsKeyTable->iNumKeys++;
-            saved = true;
-            break;
-        }
-    }
-    iTlsKeyTable->iLock.Unlock();
-    return saved;
-}
-
-bool OsclTLSRegistry::RemoveTlsKey(Oscl_DefAlloc& alloc, TOsclTlsKey * aKey, int32& aError)
-//Remove Tls key from table
-{
-    OSCL_ASSERT(aKey);
-
-    aError = 0;
-
-    bool found = false;
-
-    if (!iTlsKeyTable)
-    {
-        aError = EPVErrorBaseNotInstalled;
-        return found;
-    }
-
-    iTlsKeyTable->iLock.Lock();
-    for (uint32 i = 0;i < OSCL_TLS_MAX_THREADS;i++)
-    {
-        if (iTlsKeyTable->iKeys[i].iTlsKey == aKey)
-        {
-            //found it.
-            found = true;
-            iTlsKeyTable->iKeys[i].iTlsKey = NULL;
-            iTlsKeyTable->iNumKeys--;
-            break;
-        }
-    }
-
-    //Cleanup the table when it's empty
-    if (iTlsKeyTable->iNumKeys == 0)
-    {
-        iTlsKeyTable->iLock.Unlock();
-        iTlsKeyTable->~TlsKeyTable();
-        alloc.deallocate(iTlsKeyTable);
-        iTlsKeyTable = NULL;
-    }
-    else
-    {
-        iTlsKeyTable->iLock.Unlock();
-    }
-
-    return found;
-}
-
 #endif //OSCL_TLS_IS_KEYED
 
 
@@ -201,58 +75,46 @@
     //Allocate the table on the first init call.
     //Note there's some risk of thread contention here, since
     //the thread lock is not available until after this step.
-    if (!iTlsKeyTable)
+    if (!iTlsKey)
     {
-        OsclAny* table = alloc.allocate(sizeof(TlsKeyTable));
-        if (table)
-        {
-            iTlsKeyTable = new(table) TlsKeyTable();
-        }
-        else
+        OsclAny* table = alloc.allocate(sizeof(TlsKey));
+        if (!table)
         {
             aError = EPVErrorBaseOutOfMemory;
             return;
         }
+
+        //allocate space for key
+        pkey = (TOsclTlsKey*)alloc.allocate(sizeof(TOsclTlsKey));
+        if (!pkey)
+        {
+            aError = EPVErrorBaseOutOfMemory;
+            alloc.deallocate(table);
+            return;
+        }
+
+        //create key for this thread.
+        if (!OSCL_TLS_KEY_CREATE_FUNC(*pkey))
+        {
+            aError = EPVErrorBaseSystemCallFailed;
+            alloc.deallocate(pkey);
+            alloc.deallocate(table);
+            return;
+        }
+
+        iTlsKey = new(table) TlsKey();
+        iTlsKey->iLock.Lock();
+        iTlsKey->iRefCnt++;
+        iTlsKey->iOsclTlsKey = pkey;
+        iTlsKey->iLock.Unlock();
     }
-
-    //allocate a tls Key for this thread and add
-    //to table.
-
-    if (LookupTlsKey(aError) != NULL)
+    else
     {
-        aError = EPVErrorBaseAlreadyInstalled;
-        return;
+        iTlsKey->iLock.Lock();
+        iTlsKey->iRefCnt++;
+        pkey = iTlsKey->iOsclTlsKey;
+        iTlsKey->iLock.Unlock();
     }
-    if (aError)
-        return;//error in looking up TLS key.
-
-    //allocate space for key
-    pkey = (TOsclTlsKey*)alloc.allocate(sizeof(TOsclTlsKey));
-    if (!pkey)
-    {
-        aError = EPVErrorBaseOutOfMemory;
-        return;
-    }
-
-    //create key for this thread.
-    if (!OSCL_TLS_KEY_CREATE_FUNC(*pkey))
-    {
-        alloc.deallocate(pkey);
-        aError = EPVErrorBaseSystemCallFailed;
-        return;
-    }
-
-    //save in table.
-    if (!SaveTlsKey(pkey, aError))
-    {
-        //failed!
-        OSCL_TLS_KEY_DELETE_FUNC(*pkey);
-        alloc.deallocate(pkey);
-        aError = EPVErrorBaseTooManyThreads;//can't save key
-        return;
-    }
-    if (aError)
-        return;//error in SaveTlsKey
 
 #endif
 
@@ -268,6 +130,8 @@
     // initialize all TLSs to 0
     for (uint32 ii = 0; ii < OSCL_TLS_MAX_SLOTS; ii++)
         registry[ii] = 0;
+    // initialize the magic number
+    registry[OSCL_TLS_ID_MAGICNUM] = (OsclAny*)OSCL_TLS_MAGIC_NUMBER;
 
     // save it away
     TLSStorageOps::save_registry(pkey, registry, aError);
@@ -279,19 +143,17 @@
     aError = 0;
 
 #if (OSCL_TLS_IS_KEYED)
-    pkey = LookupTlsKey(aError);
-    if (!pkey)
+    if (!iTlsKey)
     {
         aError = EPVErrorBaseNotInstalled;//No key!
         return;
     }
-    if (aError)
-        return;//error in LookupTlsKey
+    pkey = iTlsKey->iOsclTlsKey;
 #endif
 
     //Cleanup this thread's registry
     registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey));
-    if (registry == 0)
+    if (!OSCL_TLS_REGISTRY_VALID(registry))
     {
         aError = EPVErrorBaseNotInstalled;//No registry!
         return;
@@ -304,18 +166,24 @@
 
 #if (OSCL_TLS_IS_KEYED)
 
-    //Remove Tls key for this thread.
-    bool ok = RemoveTlsKey(alloc, pkey, aError);
-    if (aError)
-        return;
+    //Remove Tls key
 
-    OSCL_ASSERT(ok);//key must be in table since we just looked it up
-    OSCL_UNUSED_ARG(ok);
-
-    //Deallocate key.
-    OSCL_TLS_KEY_DELETE_FUNC(*pkey);
-    alloc.deallocate(pkey);
-
+    iTlsKey->iLock.Lock();
+    iTlsKey->iRefCnt--;
+    if (iTlsKey->iRefCnt == 0)
+    {
+        //Deallocate key.
+        OSCL_TLS_KEY_DELETE_FUNC(*pkey);
+        alloc.deallocate(pkey);
+        iTlsKey->iLock.Unlock();
+        iTlsKey->~TlsKey();
+        alloc.deallocate(iTlsKey);
+        iTlsKey = NULL;
+    }
+    else
+    {
+        iTlsKey->iLock.Unlock();
+    }
 #endif
 }
 
@@ -328,18 +196,16 @@
     TOsclTlsKey* pkey = NULL;
 
 #if (OSCL_TLS_IS_KEYED)
-    pkey = LookupTlsKey(aError);
-    if (!pkey)
+    if (!iTlsKey)
     {
-        aError = EPVErrorBaseNotInstalled;//No key!
+        aError = EPVErrorBaseNotInstalled;//No table!
         return NULL;
     }
-    if (aError)
-        return NULL;//error in LookupTlsKey
+    pkey = iTlsKey->iOsclTlsKey;
 #endif
 
     registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey));
-    if (registry == 0)
+    if (!OSCL_TLS_REGISTRY_VALID(registry))
     {
         aError = EPVErrorBaseNotInstalled;//No registry!
         return NULL;
@@ -356,18 +222,16 @@
     TOsclTlsKey *pkey = NULL;
 
 #if (OSCL_TLS_IS_KEYED)
-    pkey = LookupTlsKey(aError);
-    if (!pkey)
+    if (!iTlsKey)
     {
-        aError = EPVErrorBaseNotInstalled;//No key!
-        return;
+        aError = EPVErrorBaseNotInstalled;//No table!
+        return ;
     }
-    if (aError)
-        return;//error in LookupTlsKey
+    pkey = iTlsKey->iOsclTlsKey;
 #endif
 
     registry_pointer_type registry = OSCL_STATIC_CAST(registry_pointer_type , TLSStorageOps::get_registry(pkey));
-    if (registry == 0)
+    if (!OSCL_TLS_REGISTRY_VALID(registry))
     {
         aError = EPVErrorBaseNotInstalled;//no registry!
         return;
diff --git a/oscl/oscl/osclbase/src/oscl_tls.h b/oscl/oscl/osclbase/src/oscl_tls.h
index cb300da..0416caf 100644
--- a/oscl/oscl/osclbase/src/oscl_tls.h
+++ b/oscl/oscl/osclbase/src/oscl_tls.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,10 +51,6 @@
 #if (OSCL_TLS_IS_KEYED)
 
 //Keyed TLS requires global variable support
-
-//Maximum number of thread slots for keyed TLS.
-#define OSCL_TLS_MAX_THREADS 128
-
 #else
 
 //unused value.
@@ -64,18 +60,19 @@
 
 
 // list of TLS objects
-const uint32 OSCL_TLS_ID_OSCLMEM        = 0;
-const uint32 OSCL_TLS_ID_PVLOGGER       = 1;
-const uint32 OSCL_TLS_ID_TEST           = 2;
-const uint32 OSCL_TLS_ID_PVSCHEDULER    = 3;
-const uint32 OSCL_TLS_ID_PVERRORTRAP    = 4;
-const uint32 OSCL_TLS_ID_SDPMEDIAPARSER = 5;
-const uint32 OSCL_TLS_ID_PAYLOADPARSER  = 6;
-const uint32 OSCL_TLS_ID_PVMFRECOGNIZER = 7;
-const uint32 OSCL_TLS_ID_WMDRM = 8;
-const uint32 OSCL_TLS_ID_OSCLREGISTRY = 9;
-const uint32 OSCL_TLS_ID_SQLITE3        = 10;
-const uint32 OSCL_TLS_ID_BASE_LAST      = 10; // should always equal the largest ID defined here
+const uint32 OSCL_TLS_ID_MAGICNUM       = 0;
+const uint32 OSCL_TLS_ID_ERRORHOOK      = 1;
+const uint32 OSCL_TLS_ID_PVLOGGER       = 2;
+const uint32 OSCL_TLS_ID_TEST           = 3;
+const uint32 OSCL_TLS_ID_PVSCHEDULER    = 4;
+const uint32 OSCL_TLS_ID_PVERRORTRAP    = 5;
+const uint32 OSCL_TLS_ID_SDPMEDIAPARSER = 6;
+const uint32 OSCL_TLS_ID_PAYLOADPARSER  = 7;
+const uint32 OSCL_TLS_ID_PVMFRECOGNIZER = 8;
+const uint32 OSCL_TLS_ID_WMDRM          = 9;
+const uint32 OSCL_TLS_ID_OSCLREGISTRY   = 10;
+const uint32 OSCL_TLS_ID_SQLITE3        = 11;
+const uint32 OSCL_TLS_ID_BASE_LAST      = 11; // should always equal the largest ID defined here
 
 #define OSCL_TLS_BASE_SLOTS OSCL_TLS_ID_BASE_LAST +1
 
@@ -84,8 +81,7 @@
 #define OSCL_TLS_EXTERNAL_SLOTS 0
 #endif
 
-//#define OSCL_TLS_MAX_SLOTS ( OSCL_TLS_BASE_SLOTS + OSCL_TLS_EXTERNAL_SLOTS)
-#define OSCL_TLS_MAX_SLOTS 64
+#define OSCL_TLS_MAX_SLOTS ( OSCL_TLS_BASE_SLOTS + OSCL_TLS_EXTERNAL_SLOTS)
 
 class TLSStorageOps
 {
@@ -100,14 +96,14 @@
         /*
         ** Get an entry
         ** @param ID: identifier
-        ** @param error (output) 0 for success or an error from TPVBasePanicEnum
+        ** @param error (output) 0 for success or an error from TPVBaseErrorEnum
         ** @returns: the entry value
         */
         OSCL_IMPORT_REF static OsclAny* getInstance(uint32 ID, int32 &error);
         /*
         ** Set an entry
         ** @param ID: identifier
-        ** @param error (output) 0 for success or an error from TPVBasePanicEnum
+        ** @param error (output) 0 for success or an error from TPVBaseErrorEnum
         ** @returns: the entry value
         */
         OSCL_IMPORT_REF static void registerInstance(OsclAny* ptr, uint32 ID, int32 &error);
@@ -119,31 +115,18 @@
         typedef registry_type* registry_pointer_type;
 
 #if ( OSCL_TLS_IS_KEYED)
-        class TKeyItem
+        class TlsKey
         {
             public:
-                TKeyItem(): iTlsKey(NULL), iThreadId(0)
-                {}
-                TOsclTlsKey *iTlsKey;
-                TOsclTlsThreadId iThreadId;
-        };
-        class TlsKeyTable
-        {
-            public:
-                TlsKeyTable(): iNumKeys(0)
+                TlsKey(): iRefCnt(0), iOsclTlsKey(NULL)
                 {}
                 _OsclBasicLock iLock;
-                uint32 iNumKeys;
-                TKeyItem iKeys[OSCL_TLS_MAX_THREADS];
+                uint32 iRefCnt;
+                TOsclTlsKey *iOsclTlsKey;
         };
 
-        //The key table is a global variable.
-        static TlsKeyTable* iTlsKeyTable;
-
-        static void GetThreadId(TOsclTlsThreadId &threadId, int32&);
-        static TOsclTlsKey* LookupTlsKey(int32&);
-        static bool SaveTlsKey(TOsclTlsKey* key, int32&);
-        static bool RemoveTlsKey(Oscl_DefAlloc& alloc, TOsclTlsKey* key, int32&);
+        //The key is a global variable.
+        static TlsKey* iTlsKey;
 #endif
 
     private:
@@ -164,10 +147,13 @@
 
     protected:
         T* _Ptr;
-        int32 _error;
 
     public:
-        OsclTLS(): _Ptr(OSCL_STATIC_CAST(T*, Registry::getInstance(ID, _error))) {};
+        OsclTLS()
+        {
+            int32 err;
+            _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err));
+        }
 
         ~OsclTLS() {};
 
@@ -204,7 +190,8 @@
         */
         bool set()
         {
-            _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, _error));
+            int32 err;
+            _Ptr = OSCL_STATIC_CAST(T*, Registry::getInstance(ID, err));
             return (_Ptr ? true : false);
         }
 
diff --git a/oscl/oscl/osclbase/src/oscl_tree.cpp b/oscl/oscl/osclbase/src/oscl_tree.cpp
index 0ade080..a1c9454 100644
--- a/oscl/oscl/osclbase/src/oscl_tree.cpp
+++ b/oscl/oscl/osclbase/src/oscl_tree.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_tree.h b/oscl/oscl/osclbase/src/oscl_tree.h
index 29ee4f9..e5c10d6 100644
--- a/oscl/oscl/osclbase/src/oscl_tree.h
+++ b/oscl/oscl/osclbase/src/oscl_tree.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -682,18 +682,26 @@
         }
 
     private:
+        // this helper function performs a downcast from base_link_type& to link_type&
+        // under C99 (gcc 3.x) this breaks aliasing rules so we have to go via a void** instead
+        inline static link_type& cast_to_link_type(base_link_type &node)
+        {
+            void** ptr = (void**) & node;
+            link_type* base = (link_type*) ptr;
+            return *base;
+        }
 
         link_type& root() const
         {
-            return (link_type&)header->parent;
+            return cast_to_link_type(header->parent);
         }
         link_type& leftmost() const
         {
-            return (link_type&)header->left;
+            return cast_to_link_type(header->left);
         }
         link_type& rightmost() const
         {
-            return (link_type&)header->right;
+            return cast_to_link_type(header->right);
         }
 
         const Key& key(link_type x) const
@@ -706,15 +714,15 @@
         }
         static link_type& left(link_type x)
         {
-            return (link_type&)(x->left);
+            return cast_to_link_type(x->left);
         }
         static link_type& right(link_type x)
         {
-            return (link_type&)(x->right);
+            return cast_to_link_type(x->right);
         }
         static link_type& parent(link_type x)
         {
-            return (link_type&)(x->parent);
+            return cast_to_link_type(x->parent);
         }
 
         const Key& key(base_link_type x) const
@@ -727,15 +735,15 @@
         }
         static link_type& left(base_link_type x)
         {
-            return (link_type&)(x->left);
+            return cast_to_link_type(x->left);
         }
         static link_type& right(base_link_type x)
         {
-            return (link_type&)(x->right);
+            return cast_to_link_type(x->right);
         }
         static link_type& parent(base_link_type x)
         {
-            return (link_type&)(x->parent);
+            return cast_to_link_type(x->parent);
         }
 
         static link_type minimum(link_type x)
@@ -874,3 +882,4 @@
 
 
 #endif
+
diff --git a/oscl/oscl/osclbase/src/oscl_types.h b/oscl/oscl/osclbase/src/oscl_types.h
index 9bf34e0..b61d809 100644
--- a/oscl/oscl/osclbase/src/oscl_types.h
+++ b/oscl/oscl/osclbase/src/oscl_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclbase/src/oscl_uuid.h b/oscl/oscl/osclbase/src/oscl_uuid.h
index 6de87c0..81e1186 100644
--- a/oscl/oscl/osclbase/src/oscl_uuid.h
+++ b/oscl/oscl/osclbase/src/oscl_uuid.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,18 +28,14 @@
 #include "oscl_base.h"
 #endif
 
-#ifdef __cplusplus
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-#else
 #ifndef OSCL_MEM_BASIC_FUNCTIONS_H
 #include "oscl_mem_basic_functions.h"
 #endif
-#endif
+
 #ifndef OSCL_STRING_UTILS_H
 #include "oscl_string_utils.h"
 #endif
+
 #ifndef OSCL_STDSTRING_H_INCLUDED
 #include "oscl_stdstring.h"
 #endif
diff --git a/oscl/oscl/osclbase/src/oscl_vector.cpp b/oscl/oscl/osclbase/src/oscl_vector.cpp
index 803546a..f235fc0 100644
--- a/oscl/oscl/osclbase/src/oscl_vector.cpp
+++ b/oscl/oscl/osclbase/src/oscl_vector.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -116,6 +116,30 @@
     pOpaqueType->construct(begin(), x);
 }
 
+OSCL_EXPORT_REF OsclAny* Oscl_Vector_Base::insert(OsclAny* pos, const OsclAny* x)
+{
+    OSCL_ASSERT(x);
+    if (numelems == bufsize)
+    {
+        uint32 new_bufsize = (bufsize) ? 2 * bufsize : 2;
+        OsclAny* oldPtr = elems;
+        reserve(new_bufsize);
+        int32 diff = ((char*)elems) - ((char*)oldPtr);
+        pos = (OsclAny*)(((char*)pos) + diff);
+    }
+    OsclAny* ptr = increment_T(elems, numelems);
+    while (ptr > pos)
+    {
+        OsclAny* previous = increment_T(ptr, -1);
+        pOpaqueType->construct(ptr, previous);
+        pOpaqueType->destroy(previous);
+        ptr = previous;
+    }
+    numelems++;
+    pOpaqueType->construct(pos, x);
+    return pos;
+}
+
 OSCL_EXPORT_REF OsclAny* Oscl_Vector_Base::erase(OsclAny* pos)
 {
     //note: use move instead of copy here since we assume
diff --git a/oscl/oscl/osclbase/src/oscl_vector.h b/oscl/oscl/osclbase/src/oscl_vector.h
index 0265825..2a4cca7 100644
--- a/oscl/oscl/osclbase/src/oscl_vector.h
+++ b/oscl/oscl/osclbase/src/oscl_vector.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -137,11 +137,18 @@
         OSCL_IMPORT_REF void push_front(const OsclAny* x) ;
 
         /**
-         * Erases the element pointed to by iterator pos.
-         * Erasing an element invalidates all iterators pointing to elements
-         * following the deletion point.
-         * @param pos iterator at erase position
+         * Inserts a new element at a specific position.
+         * @param pos iterator at insert position.
+         * @param x pointer to new element
          */
+        OSCL_IMPORT_REF OsclAny* insert(OsclAny* pos, const OsclAny* x);
+
+        /**
+          * Erases the element pointed to by iterator pos.
+          * Erasing an element invalidates all iterators pointing to elements
+          * following the deletion point.
+          * @param pos iterator at erase position
+          */
         OSCL_IMPORT_REF OsclAny* erase(OsclAny* pos) ;
 
         /**
@@ -299,6 +306,16 @@
         }
 
         /**
+         * Inserts a new element before the one at pos.
+         * @param pos position at which to insert the new element.
+         * @param x new element
+         */
+        iterator insert(iterator pos, const T& x)
+        {
+            return (iterator)Oscl_Vector_Base::insert(pos, &x);
+        }
+
+        /**
          * Returns the n'th element.
          * @param n element position to return
          */
@@ -353,6 +370,7 @@
          */
         void pop_back()
         {
+            OSCL_ASSERT(numelems);
             numelems--;
             destroy(end());
         }
@@ -419,7 +437,8 @@
         //from Oscl_Opaque_Type_Alloc
         OsclAny* allocate(const uint32 size)
         {
-            return defAlloc.ALLOCATE(size);
+            //prevent zero-size allocations since some allocators don't handle this
+            return (size) ? defAlloc.ALLOCATE(size) : NULL;
         }
 
         //from Oscl_Opaque_Type_Alloc
diff --git a/oscl/oscl/osclbase/src/pvlogger.cpp b/oscl/oscl/osclbase/src/pvlogger.cpp
new file mode 100644
index 0000000..2117750
--- /dev/null
+++ b/oscl/oscl/osclbase/src/pvlogger.cpp
@@ -0,0 +1,491 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvlogger.h"
+#include "pvlogger_registry.h"
+#include "pvlogger_accessories.h"
+#include "oscl_dll.h"
+#include "oscl_stdstring.h"
+
+
+#ifndef OSCL_COMBINED_DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+#endif
+
+#if(PVLOGGER_ENABLE)
+const char rootTag[] = "";
+
+//use the TLS registry, or the singleton registry if no TLS.
+//Note: singleton registry only works for single-threaded scenarios,
+//since this implementation assumes a per-thread registry.
+#include "oscl_base.h"
+#include "oscl_tls.h"
+#define PVLOGGER_REGISTRY OsclTLSRegistry
+#define PVLOGGER_REGISTRY_ID OSCL_TLS_ID_PVLOGGER
+#define PVLOGGER_REGISTRY_WRAPPER OsclTLS
+
+#endif //PVLOGGER_ENABLE
+
+OSCL_EXPORT_REF void PVLogger::Init()
+{
+#if(PVLOGGER_ENABLE)
+    alloc_type alloc;
+    OsclAny* ptr = alloc.allocate(sizeof(PVLoggerRegistry));
+    if (ptr)
+    {
+        PVLoggerRegistry *pvlogreg = new(ptr) PVLoggerRegistry();
+        int32 err;
+        PVLOGGER_REGISTRY::registerInstance(pvlogreg, PVLOGGER_REGISTRY_ID, err);
+    }
+#endif
+}
+
+OSCL_EXPORT_REF void PVLogger::Cleanup()
+{
+#if(PVLOGGER_ENABLE)
+    int32 err;
+    PVLoggerRegistry *pvlogreg = OSCL_STATIC_CAST(PVLoggerRegistry*, PVLOGGER_REGISTRY::getInstance(PVLOGGER_REGISTRY_ID, err));
+    if (pvlogreg)
+    {
+        pvlogreg->~PVLoggerRegistry();
+        alloc_type alloc;
+        alloc.deallocate(pvlogreg);
+        PVLOGGER_REGISTRY::registerInstance(NULL, PVLOGGER_REGISTRY_ID, err);
+    }
+#endif
+}
+
+OSCL_EXPORT_REF PVLogger* PVLogger::GetLoggerObject(const char* inputTag)
+{
+#if(PVLOGGER_ENABLE)
+    PVLoggerRegistry* registry = PVLoggerRegistry::GetPVLoggerRegistry();
+    return (registry) ? registry->GetPVLoggerObject(inputTag) : NULL;
+#else
+    OSCL_UNUSED_ARG(inputTag);
+    return NULL;
+#endif
+}
+
+OSCL_EXPORT_REF void PVLogger::SetLogLevelAndPropagate(log_level_type level)
+{
+#if(PVLOGGER_ENABLE)
+    _level = level;
+    PVLoggerRegistry::GetPVLoggerRegistry()->SetNodeLogLevelExplicit(_tag, level);
+#else
+    OSCL_UNUSED_ARG(level);
+#endif
+}
+
+OSCL_EXPORT_REF bool PVLogger::IsActive(log_level_type level)
+{
+#if(PVLOGGER_ENABLE)
+    _lastMsgLevel = level;
+
+    if (_level == PVLOGGER_LEVEL_UNINTIALIZED)
+    {
+        if (_parentLogger != NULL)
+        {
+            return(_parentLogger->IsActive(level));
+        }
+        else
+        {
+            /*
+             * We are the root node, as every node other
+             * than root MUST have a parent. If the root's
+             * log level is uninitialized, then we do not
+             * log anything
+             */
+            return false;
+        }
+    }
+    if (level <= _level)
+    {
+        return true;
+    }
+#else
+    OSCL_UNUSED_ARG(level);
+#endif
+    return false;
+}
+
+OSCL_EXPORT_REF void PVLogger::LogMsgStringV(message_id_type msgID, const char * fmt, va_list arguments)
+{
+#if(PVLOGGER_ENABLE)
+    filter_status_type msgStatus = FilterMsg(msgID);
+
+    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
+    {
+        //Log msg to the current node
+        LogMsg(msgID, fmt, arguments);
+    }
+
+    if ((_parentLogger != NULL) && (_oAppenderInheritance))
+    {
+        //Pass the msg to the parent
+        _parentLogger->LogMsgStringV(msgID, fmt, arguments);
+    }
+#else
+    OSCL_UNUSED_ARG(msgID);
+    OSCL_UNUSED_ARG(fmt);
+    OSCL_UNUSED_ARG(arguments);
+#endif
+    return;
+}
+
+OSCL_EXPORT_REF void PVLogger::LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments)
+{
+#if(PVLOGGER_ENABLE)
+    filter_status_type msgStatus = FilterMsg(msgID);
+
+    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
+    {
+        //Log msg to the current node
+        LogMsg(msgID, numPairs, arguments);
+    }
+
+    if ((_parentLogger != NULL) && (_oAppenderInheritance))
+    {
+        //Pass the msg to the parent
+        _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);
+
+    }
+#else
+    OSCL_UNUSED_ARG(msgID);
+    OSCL_UNUSED_ARG(numPairs);
+    OSCL_UNUSED_ARG(arguments);
+#endif
+    return;
+}
+
+OSCL_EXPORT_REF void PVLogger::LogMsgString(message_id_type msgID, const char * fmt, ...)
+{
+#if(PVLOGGER_ENABLE)
+    va_list arguments;
+    va_start(arguments, fmt);
+
+    filter_status_type msgStatus = FilterMsg(msgID);
+
+    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
+    {
+        LogMsg(msgID, fmt, arguments);
+    }
+
+    if ((_parentLogger != NULL) && (_oAppenderInheritance))
+    {
+        //Pass the msg to the parent
+        _parentLogger->LogMsgStringV(msgID, fmt, arguments);
+    }
+#else
+    OSCL_UNUSED_ARG(msgID);
+    OSCL_UNUSED_ARG(fmt);
+#endif
+    return;
+}
+
+OSCL_EXPORT_REF void PVLogger::LogMsgBuffers(message_id_type msgID, int32 numPairs, ...)
+{
+#if(PVLOGGER_ENABLE)
+    va_list arguments;
+    va_start(arguments, numPairs);
+
+    filter_status_type msgStatus = FilterMsg(msgID);
+
+    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
+    {
+        LogMsg(msgID, numPairs, arguments);
+    }
+
+    if ((_parentLogger != NULL) && (_oAppenderInheritance))
+    {
+        //Pass the msg to the parent
+        _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);
+    }
+#else
+    OSCL_UNUSED_ARG(msgID);
+    OSCL_UNUSED_ARG(numPairs);
+#endif
+    return;
+}
+
+OSCL_EXPORT_REF PVLogger::PVLogger(const char* inputTag, log_level_type level, bool oAppenderInheritance)
+{
+#if(PVLOGGER_ENABLE)
+    _tag = _tagAllocator.ALLOCATE(oscl_strlen(inputTag) + 1);
+
+    oscl_strncpy(_tag, inputTag, (oscl_strlen(inputTag) + 1));
+
+    _parentLogger = NULL;
+    _oAppenderInheritance = oAppenderInheritance;
+    _level = level;
+    _lastMsgLevel = PVLOGGER_LEVEL_UNINTIALIZED;
+#else
+    OSCL_UNUSED_ARG(inputTag);
+    OSCL_UNUSED_ARG(level);
+    OSCL_UNUSED_ARG(oAppenderInheritance);
+#endif
+    return;
+}
+
+#if(PVLOGGER_ENABLE)
+PVLogger::filter_status_type PVLogger::FilterMsg(message_id_type msgID)
+{
+    uint32 j;
+
+    if (_pMsgFilterVec.size() > 0)
+    {
+        for (j = 0; j < _pMsgFilterVec.size(); j++)
+        {
+            PVLoggerFilter *msgFilter = _pMsgFilterVec[j];
+
+            filter_status_type msgStatus = msgFilter->FilterString(_tag, msgID, _level);
+
+            if (msgStatus != PVLOGGER_FILTER_NEUTRAL)
+            {
+                return msgStatus;
+            }
+        }
+    }
+    /*
+     * Either All filters returned neutral => Accept msg
+     * or No msg filters => All msgs accepted by default
+     */
+    return(PVLOGGER_FILTER_ACCEPT);
+}
+
+void PVLogger::LogMsg(message_id_type msgID, const char *fmt, va_list arguments)
+{
+    uint32 i;
+
+    for (i = 0; i < _pOwnAppenderVec.size(); i++)
+    {
+        PVLoggerAppender *appender = _pOwnAppenderVec[i];
+        appender->AppendString(msgID, fmt, arguments);
+    }
+    return;
+}
+
+void PVLogger::LogMsg(message_id_type msgID, int32 numPairs, va_list arguments)
+{
+    uint32 i;
+
+    for (i = 0; i < _pOwnAppenderVec.size(); i++)
+    {
+        PVLoggerAppender *appender = _pOwnAppenderVec[i];
+        appender->AppendBuffers(msgID, numPairs, arguments);
+    }
+    return;
+}
+#endif //PVLOGGER_ENABLE
+
+OSCL_EXPORT_REF PVLoggerRegistry* PVLoggerRegistry::GetPVLoggerRegistry()
+{
+#if(PVLOGGER_ENABLE)
+    PVLOGGER_REGISTRY_WRAPPER< PVLoggerRegistry, PVLOGGER_REGISTRY_ID > pvLogRegSng;
+    return &(*pvLogRegSng);
+#else
+    return NULL;
+#endif
+}
+
+
+OSCL_EXPORT_REF PVLoggerRegistry::PVLoggerRegistry()
+{
+#if(PVLOGGER_ENABLE)
+    /*
+     * Create the root logger node, by default turn off logging
+     * for the root node
+     */
+    OsclAny* ptr = _pvloggerAlloc.allocate(sizeof(PVLogger));
+    if (ptr)
+    {
+        PVLogger *logger = new(ptr) PVLogger(rootTag, PVLOGGER_LEVEL_UNINTIALIZED, true);
+
+        // add logger to the tag tree
+        _loggerTree[OSCL_CONST_CAST(char*,(rootTag))] = logger;
+    }
+#endif
+};
+
+OSCL_EXPORT_REF PVLoggerRegistry::~PVLoggerRegistry()
+{
+#if(PVLOGGER_ENABLE)
+    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter;
+
+    for (iter = _loggerTree.begin();
+            iter != _loggerTree.end(); iter++)
+    {
+        PVLogger* logger = iter->value;
+        logger->~PVLogger();
+        _pvloggerAlloc.deallocate(logger);
+    }
+#endif
+}
+
+OSCL_EXPORT_REF PVLogger *PVLoggerRegistry::GetPVLoggerObject(const char* tagIn)
+{
+#if(PVLOGGER_ENABLE)
+    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter =
+        _loggerTree.find(OSCL_CONST_CAST(char*, (tagIn)));
+
+    if (iter != _loggerTree.end())
+    {
+        PVLogger* logger = iter->value;
+        return(logger);
+    }
+    else
+    {
+        /* creates a new logger object */
+        PVLogger *logger = NULL;
+        logger = CreatePVLogger(tagIn, PVLOGGER_LEVEL_UNINTIALIZED, true);
+        return(logger);
+    }
+#else
+    OSCL_UNUSED_ARG(tagIn);
+    return NULL;
+#endif
+}
+
+OSCL_EXPORT_REF PVLogger *PVLoggerRegistry::CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance)
+{
+#if(PVLOGGER_ENABLE)
+    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter;
+
+    /* If the input tag already exists in the tagtree, it should have a pointer value of NULL */
+    OSCL_ASSERT((_loggerTree.find(OSCL_CONST_CAST(char* const&, (tagIn))) == _loggerTree.end()) ||
+                (_loggerTree.find(OSCL_CONST_CAST(char* const&, (tagIn))))->value == 0);
+
+    OsclAny* ptr = _pvloggerAlloc.allocate(sizeof(PVLogger));
+    if (!ptr)
+        return NULL;//fail gracefully
+
+    PVLogger *logger = new(ptr) PVLogger(tagIn, level, oAppenderInheritance);
+
+    // add logger to the tag tree
+    _loggerTree[OSCL_CONST_CAST(char*,(tagIn))] = logger;
+
+    // how many levels deep is the node we just inserted?
+    iter = _loggerTree.find(OSCL_CONST_CAST(char*, (tagIn)));
+    uint32 depth = iter->depth();
+
+    // the tag tree will automatically create the parent, grandparent, etc.
+    // make sure each ancestor's stats node is initialized, i.e. initialize each ancestor
+    // until you reach one that is already initialized.
+    Oscl_TagTree<PVLogger*, alloc_type>::node_ptr parent = iter->parent;
+
+    uint32 ii = 0;
+
+    for (ii = 0; ii < depth; ii++)
+    {
+        OSCL_ASSERT(parent != 0);
+
+        // if initialized then we're done
+        PVLogger* tmpPVLoggerNode = parent->value;
+
+        if (tmpPVLoggerNode != NULL)
+        {
+            break;
+        }
+
+        // create new Logger node, for tag use the tag created
+        // by the tag tree, for level use PV_LOG_LEVEL_UNINTIALIZED
+        // for oAppenderInheritance use true
+        OsclAny* ptr = _pvloggerAlloc.allocate(sizeof(PVLogger));
+        if (ptr)
+        {
+            tmpPVLoggerNode = new(ptr) PVLogger(parent->tag.tag, PVLOGGER_LEVEL_UNINTIALIZED, true);
+
+            // Add logger to tag tree
+            parent->value = tmpPVLoggerNode;
+
+            parent = parent->parent;
+        }
+    }
+
+    //Inherit the log level for the newly created node.
+    logger->SetLogLevel(level);
+
+    parent = iter->parent;
+    OSCL_ASSERT(parent != NULL);
+    //Set the parent of the newly created node
+    logger->SetParent(parent->value);
+
+    //Set the parent of the other nodes up the tree
+    for (ii = 0; ii < depth - 1; ii++)
+    {
+
+        PVLogger* tmpPVLoggerNode = parent->value;
+
+        parent = parent->parent;
+        OSCL_ASSERT(parent != NULL);
+
+        //Set the parent for the node
+        tmpPVLoggerNode->SetParent(parent->value);
+
+    }
+
+    return(logger);
+#else
+    OSCL_UNUSED_ARG(tagIn);
+    OSCL_UNUSED_ARG(level);
+    OSCL_UNUSED_ARG(oAppenderInheritance);
+    return NULL;
+#endif
+};
+
+OSCL_EXPORT_REF bool PVLoggerRegistry::SetNodeLogLevelExplicit(char* tagIn,
+        log_level_type level)
+{
+#if(PVLOGGER_ENABLE)
+    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter;
+
+    iter = _loggerTree.find(tagIn);
+
+    if (iter != _loggerTree.end())
+    {
+        Oscl_TagTree<PVLogger*, alloc_type>::node_type* currNode = &(*iter);
+
+        SetNodeLogLevelExplicit(currNode, level);
+
+        return true;
+    }
+#else
+    OSCL_UNUSED_ARG(tagIn);
+    OSCL_UNUSED_ARG(level);
+#endif
+    return false;
+
+}
+
+OSCL_EXPORT_REF void PVLoggerRegistry::SetNodeLogLevelExplicit(Oscl_TagTree<PVLogger*, alloc_type>::node_type* node,
+        log_level_type level)
+{
+#if(PVLOGGER_ENABLE)
+    uint32 num_children = node->children.size();
+
+    for (uint32 i = 0; i < num_children; i++)
+    {
+        Oscl_TagTree<PVLogger*, alloc_type>::node_ptr child = (node->children)[i];
+
+        PVLogger* tmpPVLoggerNode = child->value;
+        tmpPVLoggerNode->SetLogLevel(level);
+        SetNodeLogLevelExplicit(child, level);
+    }
+#else
+    OSCL_UNUSED_ARG(node);
+    OSCL_UNUSED_ARG(level);
+#endif
+};
diff --git a/oscl/oscl/osclbase/src/pvlogger.h b/oscl/oscl/osclbase/src/pvlogger.h
new file mode 100644
index 0000000..b7cf0c8
--- /dev/null
+++ b/oscl/oscl/osclbase/src/pvlogger.h
@@ -0,0 +1,724 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/*! \file pvlogger.h
+    \brief This file contains basic logger interfaces for common use across platforms.
+
+    This is the main entry point header file for the logger library.  It should be
+    the only one users directly include.
+*/
+
+#ifndef PVLOGGER_H_INCLUDED
+#define PVLOGGER_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_DEFALLOC_H_INCLUDED
+#include "oscl_defalloc.h"
+#endif
+
+#ifndef OSCL_SHARED_PTR_H
+#include "oscl_shared_ptr.h"
+#endif
+
+#ifndef OSCL_BASE_ALLOC_H_INCLUDED
+#include "oscl_base_alloc.h"
+#endif
+
+
+const int32 PVLOGGER_LEVEL_UNINTIALIZED = -1;
+
+
+
+////////////////////////////////////////////
+// The instrumentation layer allows groups
+// of messages to be compiled in or out of
+// the code based on a build-time parameter.
+/////////////////////////////////////////////
+
+/**
+ * Release Layer
+ *
+ * The release layer should only be used for messages that
+ * should remain in the final release. In certain cases all
+ * messaging may be disabled depending on customer requirements.
+ * However, when allowed the release layer should contain
+ * information that will be useful diagnosing problems in a
+ * released product (perhaps after entering a diagnostic mode),
+ * but with absolutely minimal performance impact when disabled
+ * at runtime.
+ */
+#define PVLOGMSG_INST_REL   0
+/**
+ * Profile Layer
+ *
+ * The profile layer is used for messages and information
+ * related to messuring and reporting performance-related
+ * information.
+ */
+#define PVLOGMSG_INST_PROF  1
+/**
+ * High Level Debug Layer
+ *
+ * This layer should contain messages that have very minimal
+ * impact on performance, but are at lower level (i.e., provide
+ * more information) than would be appropriate in a shipping
+ * product. The messages are probably used to gather information
+ * and validate proper functionality at a high level as might
+ * be appropriate for IOT, stress testing, or QA testing.
+ */
+#define PVLOGMSG_INST_HLDBG 2
+/**
+ * Mid Level Debug Layer
+ *
+ * This layer should contain messages that are useful in the
+ * middle stages of the development cycle where major components
+ * are being integrated. The components themselves should
+ * already be well-tested so the emphasis is on interfaces
+ * between these components and integration testing. Messages
+ * at this layer may have some performance impact.
+ */
+#define PVLOGMSG_INST_MLDBG 3
+/**
+ * Low Level Debug Layer
+ *
+ * This layer should contain messages for early functional
+ * testing. The messages are typically at a very low-level
+ * and allow testing the functionality of individual modules
+ * and components. Messages at this layer will typically have
+ * a performance impact (sometimes significant) due to the
+ * fact that they are at such a low level.
+ */
+#define PVLOGMSG_INST_LLDBG 4
+
+/*
+** Default logger instrumentation level.  To override this
+** setting, define PVLOGGER_INST_LEVEL in the osclconfig.h file.
+** Possible values and the resulting intrumentation:
+**
+**  PVLOGGER_INST_LEVEL 0 : No logging.  All logging statements compiled out.
+**  PVLOGGER_INST_LEVEL 1 : Release level only.
+**  PVLOGGER_INST_LEVEL 2 : Release level + profile level
+**  PVLOGGER_INST_LEVEL 3 : Release level + profile level + high-level debug
+**  PVLOGGER_INST_LEVEL 4 : Release level + profile level + high-level debug + mid-level debug
+**  PVLOGGER_INST_LEVEL 5 & above : Release level + profile level + high-level debug
+**                            + mid-level debug + low-level debug
+*/
+#ifndef PVLOGGER_INST_LEVEL
+#if defined(NDEBUG)
+/* Release mode-- No logging */
+#define PVLOGGER_INST_LEVEL 0
+#else
+/* Debug mode-- Complete logging */
+#define PVLOGGER_INST_LEVEL 5
+#endif
+#endif
+
+
+#if (PVLOGGER_INST_LEVEL<1)
+
+/*
+** Disable and compile-out all logging
+*/
+#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOG_USE_ONLY(x)
+
+#else //PVLOGGER_INST_LEVEL
+
+/*
+** Internal use macros that make the logging calls to PVLogger.
+*/
+#define _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)\
+{\
+    if (LOGGER)\
+    {\
+        if (LOGGER->IsActive(LEVEL))\
+        {\
+            LOGGER->LogMsgString MESSAGE;\
+        }\
+    }\
+}
+
+#define _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)\
+{\
+    if (LOGGER)\
+    {\
+        if (LOGGER->IsActive(LEVEL))\
+        {\
+            LOGGER->LogMsgStringV MESSAGE;\
+        }\
+    }\
+}
+
+#define _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) \
+{\
+    if (LOGGER)\
+    {\
+    	if (LOGGER->IsActive(LEVEL))\
+    	{\
+    		LOGGER->LogMsgBuffers MESSAGE;\
+    	}\
+    }\
+}
+
+#define _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) \
+{\
+    if (LOGGER)\
+    {\
+    	if (LOGGER->IsActive(LEVEL))\
+    	{\
+    		LOGGER->LogMsgBuffersV MESSAGE;\
+    	}\
+    }\
+}
+
+/*
+** In case some compilers cannot support the instrumentation-level macros,
+** they can be disabled by defining PVLOGGER_INST_LEVEL_SUPPORT to 0
+** in their osclconfig.h.  If instrumentation level is not supported, then
+** all instrumentation levels will be compiled in.
+**
+** If PVLOGGER_INST_LEVEL_SUPPORT is not defined, the default is set here to allow
+** compile-time instrumentation level support.
+*/
+#ifndef PVLOGGER_INST_LEVEL_SUPPORT
+#define PVLOGGER_INST_LEVEL_SUPPORT 1
+#endif
+
+#if !(PVLOGGER_INST_LEVEL_SUPPORT)
+
+/*
+** A set of logging macros that ignore the instrumentation level.
+** All instrumentation levels will be compiled in.
+*/
+#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
+
+#else //PVLOGGER_INST_LEVEL_SUPPORT
+
+/*
+** This set of macros compiles the logging statements in or out based on the instrumtation
+** level.
+*/
+
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_REL)
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
+#else
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#endif
+
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_PROF)
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
+#else
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#endif
+
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_HLDBG)
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
+#else
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#endif
+
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_MLDBG)
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_V_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
+#else
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_V_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#endif
+
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
+#else
+#define PVLOGGER_LOGMSG_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
+#endif
+
+
+/**
+ * This is the text based API to log messages
+ *
+ * @param IL		Instrumentation level.
+ * @param LOGGER	Pointer to the logger object, that acts as the logging
+ *					control/interface point
+ * @param LEVEL		Log level of the message
+ * @param MESSAGE	Log Message which includes the message id, and any kind
+ *					of formatting information
+ *
+ * Example Usage:
+ * PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger_1, PVLOGMSG_WARNING, (13, "Test Messsage to Node 1\n"));
+ *	-This message of log level PVLOGMSG_WARNING, and has a message id of 13
+ */
+#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGMSG_ ## IL (LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGMSG_V_ ## IL (LOGGER, LEVEL, MESSAGE)
+
+/**
+ * This is a binary API to log messages
+ *
+ * @param IL		Instrumentation level.
+ * @param LOGGER	Pointer to the logger object, that acts as the logging
+ *					control/interface point
+ * @param LEVEL		Log level of the message
+ * @param MESSAGE	Log Message which includes the message id, and message
+ *                  buffers that need to be logged.
+ *
+ * Example Usage:
+ * PVLOGGER_LOGBIN (PVLOGMSG_INST_LLDBG, logger_1, PVLOGMSG_WARNING, (10, 3, msgBuf1Size, msgBuf1,
+ *                                                            msgBuf2Size, msgBuf2,
+ *											                  msgBuf3Size, msgBuf3));
+ *
+ *	-This message contains THREE (ptr_len, ptr) pairs.
+ *   Log level of this msg is PVLOGMSG_WARNING,
+ *   message id is 10.
+ */
+#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGBIN_ ## IL (LOGGER, LEVEL, MESSAGE)
+#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGBIN_V_ ## IL (LOGGER, LEVEL, MESSAGE)
+
+#endif //PVLOGGER_INST_LEVEL_SUPPORT
+
+/**
+ * Used to compile in/out lines of code that are used only
+ * for PVLogger macros.
+ *
+ * This code will be removed at compile time when PVLogger
+ * is disabled, i.e. Release mode.  So do not put in any
+ * code that is necessary for correct functionality of the module
+ */
+#define PVLOGGER_LOG_USE_ONLY(x) x
+
+#endif // PVLOGGER_INST_LEVEL
+
+/**
+ * In case logging is compiled out, there is no need to compile
+ * the logger runtime code either.
+ */
+#ifndef PVLOGGER_ENABLE
+#if (PVLOGGER_INST_LEVEL<1)
+#define PVLOGGER_ENABLE 0
+#else
+#define PVLOGGER_ENABLE 1
+#endif
+#endif
+
+/**
+ * Class: PVLogger
+ *
+ * Each logger instance is associated with a unique tag. PVLoggerRegistry
+ * class, maintains a repository of all the loggers, along with their
+ * associated tags. Each logger has an associated list of appenders. Appenders
+ * are entities that act as a sink for all the incoming messages. They could be
+ * file appenders, serial port appenders, buffer appenders etc. Each logger
+ * also has a list of message filters. These filters remove any unwanted messages
+ * from the output.
+ */
+class PVLoggerAppender;
+class PVLoggerFilter;
+class PVLogger
+{
+    public:
+
+        typedef int32 log_level_type;
+        typedef int32 message_id_type;
+        typedef int32 filter_status_type;
+        typedef _OsclBasicAllocator alloc_type;
+
+        /**
+         * PVLogger needs to be initialized once per thread.  This
+         * creates the PVLogger singleton that is used throughout
+         * the duration of the thread.  Initialization must occur
+         * before the first message is logged.
+         *
+         * @exception leaves if out of memory
+         */
+        OSCL_IMPORT_REF static void Init();
+
+
+        /**
+         * Frees the PVLogger singleton used by the current thread.
+         * This must be called before thread exit.  No messages
+         * can be logged after cleanup.
+         *
+         * @return
+         */
+        OSCL_IMPORT_REF static void Cleanup();
+
+        /**
+         * This is a factory method to create a log control point, with a
+         * certain input tag. There is a central registry of all the loggers,
+         * with their corresponding tags, called PV Logger Registry. In case
+         * the logger with the specified tag exists in the global registry, it
+         * is returned, else a new one is created and a pointer to the same is
+         * returend.
+         *
+         * @param inputTag   logger tag, viz. "x.y.z"
+         * @param level      log level associated with the logging control point
+         *                   (All messages with log levels less than equal to the
+         *                    log level of the control point would be logged)
+         *
+         * @param oAppenderInheritance
+         *
+         * @return PVLogger* Pointer to the logging control point
+         *
+         * @exception leaves if out of memory
+         */
+
+        OSCL_IMPORT_REF static PVLogger *GetLoggerObject(const char* inputTag);
+
+        /**
+         * This method is used to set the log level of a control point.
+         *
+         * @param level      log level associated with the logging control point
+         *
+         * @return           NONE
+         */
+        void SetLogLevel(log_level_type level)
+        {
+#if(PVLOGGER_ENABLE)
+            _level = level;
+#else
+            OSCL_UNUSED_ARG(level);
+#endif
+        }
+
+        /**
+         * This method is used to set the log level of a control point, as well as
+         * to propagate the level to all the descendants of this control point.
+         *
+         * @param level      log level associated with the logging control point
+         *
+         * @return           NONE
+         */
+        OSCL_IMPORT_REF void SetLogLevelAndPropagate(log_level_type level);
+
+        /**
+         * This method returns the log level of a control point. This could either
+         * have been set explicitly by the user (at the time of creation or later)
+         * or could have been inherited from one of its ancestors.
+         *
+         * @return           log level associated with the logging control point
+         */
+        log_level_type GetLogLevel()
+        {
+#if(PVLOGGER_ENABLE)
+            return(_level);
+#else
+            return 0;
+#endif
+        }
+
+        /**
+         * This method disables appender inheritance for the logging control point
+         *
+         */
+        void DisableAppenderInheritance()
+        {
+#if(PVLOGGER_ENABLE)
+            _oAppenderInheritance = false;
+#endif
+        }
+
+        /**
+         * This method adds an appender to the logging control point. Each logger
+         * maintains a list of appenders. Any msg to a logger if deemed active is
+         * logged to all the appenders.
+         *
+         * @param appender   pointer to the appender to add
+         *
+         * @return           NONE
+         *
+         * @exception        leaves if out of memory
+         */
+        void AddAppender(OsclSharedPtr<PVLoggerAppender> &appender)
+        {
+#if(PVLOGGER_ENABLE)
+            _pOwnAppenderVec.push_back(appender);
+#else
+            OSCL_UNUSED_ARG(appender);
+#endif
+        }
+
+        /**
+         * This method removes an appender from the logging control point. Each logger
+         * maintains a list of appenders. Any msg to a logger if deemed active is
+         * logged to all the appenders.
+         *
+         * @param appender   pointer to the appender to delete
+         *
+         * @return           NONE
+         */
+        void RemoveAppender(OsclSharedPtr<PVLoggerAppender> &appender)
+        {
+#if(PVLOGGER_ENABLE)
+            for (Oscl_Vector<OsclSharedPtr<PVLoggerAppender>, alloc_type>::iterator it = _pOwnAppenderVec.begin();
+                    it != _pOwnAppenderVec.end();
+                    it++)
+            {
+                if ((*it).GetRep() == appender.GetRep())
+                {
+                    _pOwnAppenderVec.erase(it);
+                    break;
+                }
+            }
+#else
+            OSCL_UNUSED_ARG(appender);
+#endif
+        }
+
+        /**
+         * This method adds a message filter to the logging control point. Each logger
+         * maintains a list of filters. Any msg to a logger if deemed active is
+         * passed through the msg filters prior to logging.
+         *
+         * @param msgFilter   pointer to the filter to add
+         *
+         * @return           NONE
+         *
+         * @exception        leaves if out of memory
+         */
+        void AddFilter(OsclSharedPtr<PVLoggerFilter> &filter)
+        {
+#if(PVLOGGER_ENABLE)
+            _pMsgFilterVec.push_back(filter);
+#else
+            OSCL_UNUSED_ARG(filter);
+#endif
+        };
+
+        /**
+         * This method returns the number of appenders attached to the logging control point.
+         */
+        uint32 GetNumAppenders()
+        {
+#if(PVLOGGER_ENABLE)
+            return(_pOwnAppenderVec.size());
+#else
+            return 0;
+#endif
+        }
+
+        /**
+         * This method determines if a msg passed to the logging control point is active
+         * or not. Only messages that are deemed active are logged. Messages are considered
+         * not active if any of the following criteria are met:
+         *		- All logging is disabled at this logging control point
+         *      - If all the log levels, leading upto the root log point are uninitialized
+         *      - If the log level of the incoming message is LESS THAN that of the active
+         *        log level of the logging control point.
+         *
+         * @return           BOOL
+         */
+        OSCL_IMPORT_REF bool IsActive(log_level_type level);
+
+        /**
+         * This method logs formatted text msg to all the appenders, after running thrrough
+         * the message filters. After logging the message to the appenders attached to the
+         * current control point, the message is passed up to the parent node, only if
+         * appender inheritance is enabled.
+         *
+         *
+         * @param msgID      Message ID, that is unique to a message
+         * @param fmt        format string, similar to one taken by printf
+         * @param arguments  Variable list of arguments
+         *
+         * @return           NONE
+         */
+        OSCL_IMPORT_REF void LogMsgStringV(message_id_type msgID, const char * fmt, va_list arguments);
+
+        /**
+         * This method logs opaque data buffers to all the appenders, after running thrrough
+         * the message filters. After logging the message to the appenders attached to the
+         * current control point, the message is passed up to the parent node, only if
+         * appender inheritance is enabled.
+         *
+         *
+         * @param msgID      Message ID, that is unique to a message
+         * @param numPairs   Number of (ptr_len, ptr) pairs
+         * @param arguments  Variable list of arguments
+         *
+         * @return           NONE
+         */
+        OSCL_IMPORT_REF void LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments);
+
+        /**
+         * This method logs formatted text msg to all the appenders, after running thrrough
+         * the message filters. After logging the message to the appenders attached to the
+         * current control point, the message is passed up to the parent node, only if
+         * appender inheritance is enabled.
+         *
+         *
+         * @param msgID      Message ID, that is unique to a message
+         * @param fmt        format string, similar to one taken by printf
+         * @param arguments  Variable list of arguments
+         *
+         * @return           NONE
+         */
+        OSCL_IMPORT_REF void LogMsgString(message_id_type msgID, const char * fmt, ...);
+
+        /**
+         * This method logs opaque data buffers to all the appenders, after running thrrough
+         * the message filters. After logging the message to the appenders attached to the
+         * current control point, the message is passed up to the parent node, only if
+         * appender inheritance is enabled.
+         *
+         *
+         * @param msgID      Message ID, that is unique to a message
+         * @param numPairs   Number of (ptr_len, ptr) pairs
+         * @param arguments  Variable list of arguments
+         *
+         * @return           NONE
+         */
+        OSCL_IMPORT_REF void LogMsgBuffers(message_id_type msgID, int32 numPairs, ...);
+
+        /**
+         * Logger Constructor
+         *
+         *
+         * @param tag                     Logger tag, unique to a logging control point
+         * @param level                   Active Log level of the logger
+         * @param oAppenderInheritance
+         *
+         * @return                        NONE
+         */
+        OSCL_IMPORT_REF PVLogger(const char* inputTag, log_level_type level, bool oAppenderInheritance);
+
+        virtual ~PVLogger()
+        {
+#if(PVLOGGER_ENABLE)
+            _tagAllocator.deallocate(_tag);
+#endif
+        }
+
+#if(PVLOGGER_ENABLE)
+    protected:
+        friend class PVLoggerRegistry;
+        void SetParent(PVLogger *parentLogger)
+        {
+            _parentLogger = parentLogger;
+        }
+        PVLogger *GetParent()
+        {
+            return(_parentLogger);
+        }
+
+    private:
+        filter_status_type FilterMsg(message_id_type msgID);
+        void LogMsg(message_id_type msgID, const char *fmt, va_list arguments);
+        void LogMsg(message_id_type msgID, int32 numPairs, va_list arguments);
+
+        char* _tag;
+        log_level_type _level;
+        log_level_type _lastMsgLevel;
+        bool _oAppenderInheritance;
+
+        PVLogger *_parentLogger;
+        Oscl_TAlloc<char, alloc_type> _tagAllocator;
+
+        Oscl_Vector<OsclSharedPtr<PVLoggerFilter>, alloc_type> _pMsgFilterVec;
+        Oscl_Vector<OsclSharedPtr<PVLoggerAppender>, alloc_type>  _pOwnAppenderVec;
+#endif //PVLOGGER_ENABLE
+};
+
+//////////////////////////////////////
+// log message levels
+//////////////////////////////////////
+
+/**
+ * system is unusable
+ */
+const PVLogger::log_level_type PVLOGMSG_EMERG   = 0;
+/**
+ * action must be taken immediately
+ */
+const PVLogger::log_level_type PVLOGMSG_ALERT   = 1;
+/**
+ * critical conditions
+ */
+const PVLogger::log_level_type PVLOGMSG_CRIT    = 2;
+/**
+ * error conditions
+ */
+const PVLogger::log_level_type PVLOGMSG_ERR     = 3;
+/**
+ * warning conditions
+ */
+const PVLogger::log_level_type PVLOGMSG_WARNING = 4;
+/**
+ * normal but significant condition
+ */
+const PVLogger::log_level_type PVLOGMSG_NOTICE  = 5;
+/**
+ * informational
+ */
+const PVLogger::log_level_type PVLOGMSG_INFO    = 6;
+/**
+ * function enter and exit
+ */
+const PVLogger::log_level_type PVLOGMSG_STACK_TRACE = 7;
+/**
+ * debug-level messages
+ */
+const PVLogger::log_level_type PVLOGMSG_DEBUG   = 8;
+
+///////////////////////////////////
+// do not use these levels
+// for backward compatibility only
+///////////////////////////////////
+const PVLogger::log_level_type PVLOGMSG_FATAL_ERROR    = PVLOGMSG_EMERG;
+const PVLogger::log_level_type PVLOGMSG_NONFATAL_ERROR = PVLOGMSG_ERR;
+const PVLogger::log_level_type PVLOGMSG_STATISTIC      = PVLOGMSG_INFO;
+const PVLogger::log_level_type PVLOGMSG_VERBOSE        = PVLOGMSG_DEBUG;
+
+#endif // PVLOGGER_H_INCLUDED
diff --git a/oscl/oscl/osclbase/src/pvlogger_accessories.h b/oscl/oscl/osclbase/src/pvlogger_accessories.h
new file mode 100644
index 0000000..e856353
--- /dev/null
+++ b/oscl/oscl/osclbase/src/pvlogger_accessories.h
@@ -0,0 +1,129 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVLOGGER_ACCESSORIES_H_INCLUDED
+#define PVLOGGER_ACCESSORIES_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+/**
+ * Base class for all message formatters. This class defines the interface to
+ * the message formatter. There are two kinds of msg formatting APIs, one to
+ * format text messages, and other to format opaque message buffers.
+ */
+class PVLoggerLayout
+{
+    public:
+        typedef PVLogger::message_id_type message_id_type;
+
+        virtual ~PVLoggerLayout() {}
+
+        /**
+         * Formats the string and copies it to the given buffer.
+         *
+         * @return The length of the string not including the trailing '\0'
+         */
+        virtual int32 FormatString(char* formatBuf, int32 formatBufSize,
+                                   message_id_type msgID, const char * fmt,
+                                   va_list va) = 0;
+
+        /**
+         * Formats the data and copies it to the given buffer.
+         *
+         * @return The length of the buffer used.
+         */
+        virtual int32 FormatOpaqueMessage(char* formatBuf, int32 formatBufSize,
+                                          message_id_type msgID, int32 numPairs,
+                                          va_list va) = 0;
+};
+
+/**
+ * Base class for all message filters. This class defines the interface to
+ * the message filters. There are two kinds of msg filtering APIs, one to
+ * filter text messages, and other to filter opaque message buffers.
+ */
+class PVLoggerFilter
+{
+    public:
+        virtual ~PVLoggerFilter() {}
+
+        typedef PVLogger::message_id_type message_id_type;
+        typedef PVLogger::log_level_type log_level_type;
+        typedef PVLogger::filter_status_type filter_status_type;
+
+        virtual filter_status_type FilterString(char* tag, message_id_type msgID, log_level_type level) = 0;
+        virtual filter_status_type FilterOpaqueMessge(char* tag, message_id_type msgID, log_level_type level) = 0;
+};
+
+const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_ACCEPT = 1;
+const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_REJECT = 2;
+const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_NEUTRAL = 3;
+
+/**
+ * Example filter that allows all messages to be logged.
+ */
+class AllPassFilter : public PVLoggerFilter
+{
+    public:
+        typedef PVLoggerFilter::message_id_type message_id_type;
+        typedef PVLoggerFilter::log_level_type log_level_type;
+        typedef PVLoggerFilter::filter_status_type filter_status_type;
+
+        AllPassFilter() {};
+        virtual ~AllPassFilter() {};
+
+        filter_status_type FilterString(char* tag, message_id_type msgID, log_level_type level)
+        {
+            OSCL_UNUSED_ARG(tag);
+            OSCL_UNUSED_ARG(msgID);
+            OSCL_UNUSED_ARG(level);
+            return (PVLOGGER_FILTER_ACCEPT);
+        };
+        filter_status_type FilterOpaqueMessge(char* tag, message_id_type msgID, log_level_type level)
+        {
+            OSCL_UNUSED_ARG(tag);
+            OSCL_UNUSED_ARG(msgID);
+            OSCL_UNUSED_ARG(level);
+            return (PVLOGGER_FILTER_ACCEPT);
+        };
+};
+
+/**
+ * Base class for all message appenders. This class defines the interface to
+ * the message appenders. There are two kinds of msg appender APIs, one to
+ * append text messages, and other to append opaque message buffers.
+ */
+class PVLoggerAppender
+{
+    public:
+        typedef PVLogger::message_id_type message_id_type;
+
+        virtual ~PVLoggerAppender() {}
+
+        virtual void AppendString(message_id_type msgID, const char *fmt, va_list va) = 0;
+        virtual void AppendBuffers(message_id_type msgID, int32 numPairs, va_list va) = 0;
+};
+
+
+#endif
+
diff --git a/oscl/oscl/osclbase/src/pvlogger_c.cpp b/oscl/oscl/osclbase/src/pvlogger_c.cpp
new file mode 100644
index 0000000..618f59a
--- /dev/null
+++ b/oscl/oscl/osclbase/src/pvlogger_c.cpp
@@ -0,0 +1,48 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "pvlogger.h"
+#include "pvlogger_c.h"
+
+
+
+//C-callable version of PVLogger::GetLoggerObject
+OSCL_EXPORT_REF void* pvLogger_GetLoggerObject(const char* tag)
+{
+    return PVLogger::GetLoggerObject(tag);
+}
+
+//C-callable version of PVLogger::IsActive
+OSCL_EXPORT_REF int pvLogger_IsActive(void* logger, int log_level)
+{
+    if (logger)
+        return (int)((PVLogger*)logger)->IsActive(log_level);
+    return 0;
+}
+
+//C-callable version of PVLogger::LogMsgString
+OSCL_EXPORT_REF void pvLogger_LogMsgString(void* logger, int msgID, const char * fmt, ...)
+{
+    if (logger)
+    {
+        va_list arguments;
+        va_start(arguments, fmt);
+
+        ((PVLogger*)logger)->LogMsgStringV(msgID, fmt, arguments);
+    }
+}
diff --git a/oscl/oscl/osclbase/src/pvlogger_c.h b/oscl/oscl/osclbase/src/pvlogger_c.h
new file mode 100644
index 0000000..73adee5
--- /dev/null
+++ b/oscl/oscl/osclbase/src/pvlogger_c.h
@@ -0,0 +1,93 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/*! \file pvlogger_c.h
+    \brief This file contains basic logger interfaces for common use across platforms.
+	   C-callable version
+
+    This is the main entry point header file for the logger library.  It should be
+    the only one users directly include.
+*/
+
+#ifndef PVLOGGER_C_H_INCLUDED
+#define PVLOGGER_C_H_INCLUDED
+
+#include "osclconfig.h"
+
+#ifndef OSCL_IMPORT_REF
+#define OSCL_IMPORT_REF
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+//C-callable logging routines.
+    OSCL_IMPORT_REF void* pvLogger_GetLoggerObject(const char* tag);
+    OSCL_IMPORT_REF int pvLogger_IsActive(void* logger, int log_level);
+    OSCL_IMPORT_REF void pvLogger_LogMsgString(void* logger, int msgID, const char * fmt, ...);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+//Logging instrumentation level default.  To change this for a project, add a definition of
+//PVLOGGER_C_INST_LEVEL to the osclconfig.h file.  This default sets level to none for release
+//mode, full logging for debug build.
+
+#ifndef PVLOGGER_C_INST_LEVEL
+#if defined(NDEBUG)
+#define PVLOGGER_C_INST_LEVEL 0
+#else
+#define PVLOGGER_C_INST_LEVEL 5
+#endif
+#endif
+
+//Instrumentation levels.
+#define PVLOGMSG_C_INST_REL   0
+#define PVLOGMSG_C_INST_PROF  1
+#define PVLOGMSG_C_INST_HLDBG 2
+#define PVLOGMSG_C_INST_MLDBG 3
+#define PVLOGMSG_C_INST_LLDBG 4
+
+//Logging levels
+#define PVLOGMSG_C_EMERG 0
+#define PVLOGMSG_C_ALERT 1
+#define PVLOGMSG_C_CRIT 2
+#define PVLOGMSG_C_ERR 3
+#define PVLOGMSG_C_WARNING 4
+#define PVLOGMSG_C_NOTICE 5
+#define PVLOGMSG_C_INFO 6
+#define PVLOGMSG_C_STACK_TRACE 7
+#define PVLOGMSG_C_STACK_DEBUG 8
+
+/*
+//Example Usage:
+
+#if (PVLOGGER_C_INST_LEVEL > PVLOGMSG_C_INST_LLDBG)
+			if(pvLogger_IsActive(logger ,PVLOGMSG_C_ERR))
+				pvLogger_LogMsgString( logger ,  0 ,"Some message, value %d", intvalue );
+
+#endif
+*/
+
+
+
+#endif // PVLOGGER_C_H_INCLUDED
diff --git a/oscl/oscl/osclbase/src/pvlogger_registry.h b/oscl/oscl/osclbase/src/pvlogger_registry.h
new file mode 100644
index 0000000..fbacec0
--- /dev/null
+++ b/oscl/oscl/osclbase/src/pvlogger_registry.h
@@ -0,0 +1,123 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVLOGGER_REGISTRY_H_INCLUDED
+#define PVLOGGER_REGISTRY_H_INCLUDED
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef OSCL_TAGTREE_H_INCLUDED
+#include "oscl_tagtree.h"
+#endif
+
+/**
+ * Class: PVLoggerRegistry
+ *
+ * PVLoggerRegistry class, maintains a repository of all the loggers, along with
+ * their associated tags, in a tag tree. Any request for a log control point is
+ * serviced by this class.
+ *
+ * Memory Ownership: Creates log control points for each tag, and holds these
+ * pointers in the tag tree. PVLogger registry is responsible for calling the
+ * destructor on each of these loggers.
+ *
+ */
+
+class PVLoggerRegistry
+{
+    public:
+
+        typedef PVLogger::log_level_type log_level_type;
+        typedef PVLogger::alloc_type alloc_type;
+
+        /**
+         * Get the logger registry.  There is only one logger
+         * registry instance per thread.
+         */
+        OSCL_IMPORT_REF static PVLoggerRegistry* GetPVLoggerRegistry();
+
+        /**
+         * PVLoggerRegistry Constructor
+         *
+         */
+        OSCL_IMPORT_REF PVLoggerRegistry();
+
+        /**
+         * PVLoggerRegistry Destructor
+         *
+         */
+        OSCL_IMPORT_REF virtual ~PVLoggerRegistry();
+
+        /**
+         * PVLoggerRegistry method to get access to a logging control point, associated with
+         * a tag. In case the logger for this tag does not exist, it is created afresh, else
+         * pointer to the existing one is returned.
+         *
+         * @param inputTag   logger tag, viz. "x.y.z"
+         * @param level      log level associated with the logging control point
+         *
+         * @param oAppenderInheritance
+         *
+         * @return PVLogger<Alloc, TheLock>* Pointer to the logging control point
+         */
+        OSCL_IMPORT_REF PVLogger *GetPVLoggerObject(const char* tagIn);
+
+        /**
+         * This method creates a log control point, with specified tag, and level
+         *
+         * @param inputTag   logger tag, viz. "x.y.z"
+         * @param level      log level associated with the logging control point
+         *
+         * @param oAppenderInheritance
+         *
+         * @return PVLogger<alloc_type, TheLock>* Pointer to the logging control point
+         */
+        OSCL_IMPORT_REF PVLogger *CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance);
+
+        /**
+         * This method propagates the log level to all the descendents of the node,
+         * with a specified tag.
+         *
+         * @param tagIn      logger tag, viz. "x.y.z"
+         * @param level      log level associated with the logging control point
+         *
+         * @return           true on success, else false.
+         */
+        OSCL_IMPORT_REF bool SetNodeLogLevelExplicit(char* tagIn, log_level_type level);
+
+        /**
+         * This method recursively propagates the log level to all the descendents,
+         * of a node.
+         *
+         * @param node       Node ptr, associated with a logger, from the tag tree.
+         * @param level      log level associated with the logging control point
+         *
+         * @return           NONE
+         */
+        OSCL_IMPORT_REF void SetNodeLogLevelExplicit(Oscl_TagTree<PVLogger*, alloc_type>::node_type* node, log_level_type level);
+
+    private:
+#if (PVLOGGER_ENABLE)
+        Oscl_TAlloc<PVLogger, alloc_type> _pvloggerAlloc;
+        Oscl_TagTree<PVLogger*, alloc_type> _loggerTree;
+#endif
+};
+
+#endif // PVLOGGER_REGISTRY_H_INCLUDED
+
diff --git a/oscl/oscl/osclerror/Android.mk b/oscl/oscl/osclerror/Android.mk
index 6584ae4..3cc191f 100644
--- a/oscl/oscl/osclerror/Android.mk
+++ b/oscl/oscl/osclerror/Android.mk
@@ -3,44 +3,45 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_errno.cpp \
-	src/oscl_error.cpp \
-	src/oscl_error_imp_jumps.cpp \
-	src/oscl_mempool_allocator.cpp \
-	src/oscl_error_trapcleanup.cpp \
-	src/oscl_heapbase.cpp
-
+ 	src/oscl_error.cpp \
+ 	src/oscl_error_imp_jumps.cpp \
+ 	src/oscl_mempool_allocator.cpp \
+ 	src/oscl_error_trapcleanup.cpp \
+ 	src/oscl_heapbase.cpp
 
 
 LOCAL_MODULE := libosclerror
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclerror/src \
-	$(PV_TOP)//oscl/oscl/osclerror/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclerror/src \
+ 	$(PV_TOP)/oscl/oscl/osclerror/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_errno.h \
-	src/oscl_error_allocator.h \
-	src/oscl_error_codes.h \
-	src/oscl_error.h \
-	src/oscl_error_imp_cppexceptions.h \
-	src/oscl_error_imp_fatalerror.h \
-	src/oscl_error_imp.h \
-	src/oscl_error_imp_jumps.h \
-	src/oscl_error_panic.h \
-	src/oscl_mempool_allocator.h \
-	src/oscl_error_trapcleanup.h \
-	src/oscl_exception.h \
-	src/oscl_heapbase.h \
-	src/oscl_namestring.h \
-	src/oscl_execpanic.h \
-	src/oscl_errno.inl \
-	src/oscl_heapbase.inl
+ 	src/oscl_error_allocator.h \
+ 	src/oscl_error_codes.h \
+ 	src/oscl_error.h \
+ 	src/oscl_error_imp_cppexceptions.h \
+ 	src/oscl_error_imp_fatalerror.h \
+ 	src/oscl_error_imp.h \
+ 	src/oscl_error_imp_jumps.h \
+ 	src/oscl_mempool_allocator.h \
+ 	src/oscl_error_trapcleanup.h \
+ 	src/oscl_exception.h \
+ 	src/oscl_heapbase.h \
+ 	src/oscl_namestring.h \
+ 	src/oscl_errno.inl \
+ 	src/oscl_heapbase.inl
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclerror/build/make/local.mk b/oscl/oscl/osclerror/build/make/local.mk
new file mode 100644
index 0000000..569a7db
--- /dev/null
+++ b/oscl/oscl/osclerror/build/make/local.mk
@@ -0,0 +1,76 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+TARGET = osclerror
+
+# Use XCFLAGS to add extra compiler directives for the C compiler
+# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
+# unless you're sure you want to override the project defaults.
+# Please include a comment if you do this.
+#
+# XCFLAGS += 
+
+# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
+# See notes above regarding overriding project defaults.
+#
+# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
+# for other include directories, but please only do this if absolutely
+# necessary -- let the makefile system find the include directories if 
+# possible.
+# See notes above regarding overriding project defaults.
+#
+# XCPPFLAGS +=  
+
+# Use XINCDIRS for extra include directories. These should be proceeded 
+# with "-I" just as they would be when passing to the compiler.
+#
+# XINCDIRS += 
+
+
+# Use XLIBDIRS for extra library directories. These should be proceeded 
+# with "-L" just as they would be when passing to the linker. 
+# Used for building executables.
+#
+# XLIBDIRS += 
+
+# Use XLDFLAGS for extra linker directives.
+# Used for building executables.
+#
+# XLDFLAGS += 
+
+SRCDIR = ../../src
+INCSRCDIR = ../../src
+
+SRCS =  oscl_errno.cpp \
+	oscl_error.cpp \
+	oscl_error_imp_jumps.cpp \
+	oscl_mempool_allocator.cpp \
+	oscl_error_trapcleanup.cpp \
+	oscl_heapbase.cpp
+
+HDRS =  oscl_errno.h \
+	oscl_error_allocator.h \
+	oscl_error_codes.h \
+	oscl_error.h \
+	oscl_error_imp_cppexceptions.h \
+	oscl_error_imp_fatalerror.h \
+	oscl_error_imp.h \
+	oscl_error_imp_jumps.h \
+	oscl_mempool_allocator.h \
+	oscl_error_trapcleanup.h \
+	oscl_exception.h \
+	oscl_heapbase.h \
+	oscl_namestring.h \
+	oscl_errno.inl \
+	oscl_heapbase.inl
+
+
+include $(MK)/library.mk
+
diff --git a/oscl/oscl/osclerror/build/make/makefile b/oscl/oscl/osclerror/build/make/makefile
deleted file mode 100644
index c523c8d..0000000
--- a/oscl/oscl/osclerror/build/make/makefile
+++ /dev/null
@@ -1,80 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclerror
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS += 
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  oscl_errno.cpp \
-	oscl_error.cpp \
-	oscl_error_imp_jumps.cpp \
-	oscl_mempool_allocator.cpp \
-	oscl_error_trapcleanup.cpp \
-	oscl_heapbase.cpp
-
-HDRS =  oscl_errno.h \
-	oscl_error_allocator.h \
-	oscl_error_codes.h \
-	oscl_error.h \
-	oscl_error_imp_cppexceptions.h \
-	oscl_error_imp_fatalerror.h \
-	oscl_error_imp.h \
-	oscl_error_imp_jumps.h \
-	oscl_error_panic.h \
-	oscl_mempool_allocator.h \
-	oscl_error_trapcleanup.h \
-	oscl_exception.h \
-	oscl_heapbase.h \
-	oscl_namestring.h \
-	oscl_execpanic.h \
-	oscl_errno.inl \
-	oscl_heapbase.inl
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/oscl/oscl/osclerror/src/oscl_errno.cpp b/oscl/oscl/osclerror/src/oscl_errno.cpp
index e99eae1..ae42b63 100644
--- a/oscl/oscl/osclerror/src/oscl_errno.cpp
+++ b/oscl/oscl/osclerror/src/oscl_errno.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_errno.h b/oscl/oscl/osclerror/src/oscl_errno.h
index 2e021c3..2ef091b 100644
--- a/oscl/oscl/osclerror/src/oscl_errno.h
+++ b/oscl/oscl/osclerror/src/oscl_errno.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_errno.inl b/oscl/oscl/osclerror/src/oscl_errno.inl
index 11ace3e..c5ce65c 100644
--- a/oscl/oscl/osclerror/src/oscl_errno.inl
+++ b/oscl/oscl/osclerror/src/oscl_errno.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_error.cpp b/oscl/oscl/osclerror/src/oscl_error.cpp
index cfb3af1..91892a8 100644
--- a/oscl/oscl/osclerror/src/oscl_error.cpp
+++ b/oscl/oscl/osclerror/src/oscl_error.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 #include "oscl_error_trapcleanup.h"
 #include "oscl_error_imp.h"
 #include "oscl_heapbase.h"
+#include "pvlogger.h"
 
 //
 // OsclErrorTrap
@@ -82,7 +83,7 @@
 //
 // OsclError
 //
-OSCL_EXPORT_REF void OsclError::PushL(OsclHeapBase * aPtr)
+OSCL_EXPORT_REF void OsclError::PushL(_OsclHeapBase * aPtr)
 {
     OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap();
     if (!trap)
@@ -164,13 +165,18 @@
 
 OSCL_EXPORT_REF void OsclError::Leave(int32 aReason)
 {
+    //log the leave
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, PVLogger::GetLoggerObject("OsclError"), PVLOGMSG_ERR
+                    , (0, "OsclError::Leave! reason %d", aReason));
+
+
     //set the global leave code if errortrap is installed.
-    //rememeber it may not be installed under symbian GUI
-    //so be tolerant.
     OsclErrorTrapImp *errortrap = OsclErrorTrapImp::GetErrorTrap();
     if (errortrap)
+    {
+        OSCL_ASSERT(!errortrap->iLeave);//to avoid infinite recursion
         errortrap->iLeave = aReason;
-
+    }
 
     //Process the cleanup stack.
     if (errortrap)
@@ -191,33 +197,7 @@
         Leave(aReason);
 }
 
-/*Leave this out until logger is moved to oscl base.
-#include "pvlogger.h"
-#define LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m);
-*/
 
-OSCL_EXPORT_REF void OsclError::Panic(const char acategory[], int32 areason)
-{
-    //the application will exit.  Log to stderr because pvlogger is not
-    //available in this library.
-    fprintf(stderr, "OsclError::Panic!! Category %s reason %d\n", acategory, areason);
-
-    //set the global panic info if errortrap is installed.  remember it may
-    //not be installed under symbian GUI so be tolerant.
-    int32 error;
-    OsclErrorTrapImp *errortrap = OsclErrorTrapImp::GetErrorTrap(error);
-    if (errortrap)
-    {
-        //to avoid infinite recursion, check whether we're already
-        //doing a panic for the current trap level.
-        if (errortrap->iPanic.iReason != OsclErrNone)
-            return;
-        errortrap->iPanic.iReason = areason;
-        errortrap->iPanic.iCategory.Set(acategory);
-    }
-
-    PVError_DoPanic();
-}
 
 
 
diff --git a/oscl/oscl/osclerror/src/oscl_error.h b/oscl/oscl/osclerror/src/oscl_error.h
index 94b0c50..7dfb2e1 100644
--- a/oscl/oscl/osclerror/src/oscl_error.h
+++ b/oscl/oscl/osclerror/src/oscl_error.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,10 +43,6 @@
 #include "oscl_defalloc.h"
 #endif
 
-#ifndef OSCL_EXECPANIC_H_INCLUDED
-#include "oscl_execpanic.h"
-#endif
-
 #ifndef OSCL_ERROR_CODES_H_INCLUDED
 #include "oscl_error_codes.h"
 #endif
@@ -74,7 +70,7 @@
         OSCL_IMPORT_REF static int32 Cleanup();
         /**
          * Get the ErrorTrapImp for the current thread.
-         * Panics on error.
+         * Leaves on error.
          */
         OSCL_IMPORT_REF static OsclErrorTrapImp* GetErrorTrapImp();
 };
@@ -90,9 +86,9 @@
         //Cleanup stack operations.
         */
 
-        /** Push an OsclHeapBase item onto the cleanup stack.
+        /** Push an _OsclHeapBase item onto the cleanup stack.
         */
-        OSCL_IMPORT_REF static void PushL(OsclHeapBase * aPtr);
+        OSCL_IMPORT_REF static void PushL(_OsclHeapBase * aPtr);
 
         /** Push an OsclAny item onto the cleanup stack.
         */
@@ -137,16 +133,6 @@
         */
         OSCL_IMPORT_REF static void LeaveIfError(int32 aReason);
 
-        /** Generate a panic, using the given category and reason.
-        ** A panic is a fatal error, and differs from a leave in
-        ** that there is no cleanup stack processing, and the panic
-        ** can only be caught at the application level.  On Symbian,
-        ** the panic will be caught by the UI framework.  On non-Symbian,
-        ** the application can use the OSCL_PANIC_TRAP macro to catch the
-        ** panic.
-        */
-        OSCL_IMPORT_REF static void Panic(const char aCategory[], int32 aReason);
-
 };
 
 /** Cleanup Stack user macros
@@ -170,6 +156,8 @@
     ,/*EPVErrorBaseOutOfMemory=3*/OsclErrNoMemory
     ,/*EPVErrorBaseSystemCallFailed=4*/OsclErrSystemCallFailed
     ,/*EPVErrorBaseTooManyThreads=5*/0
+    ,/*EPVErrorBaseNotSupported=6*/OsclErrNotSupported
+    ,/*EPVErrorBaseNotReady=7*/OsclErrNotReady
 };
 
 #include "oscl_singleton.h"
@@ -182,7 +170,7 @@
         ** Get an entry
         ** @param ID: identifier
         ** @returns: the entry value
-        ** @exception: panics on error.
+        ** @exception: leaves on error.
         */
         static OsclAny* getInstance(uint32 ID)
         {
@@ -200,7 +188,7 @@
         ** Set an entry
         ** @param ID: identifier
         ** @returns: the entry value
-        ** @exception: panics on error.
+        ** @exception: leaves on error.
         */
         static void registerInstance(OsclAny* ptr, uint32 ID)
         {
@@ -223,7 +211,7 @@
         * on return.
         * @param ID the singleton ID
         * @returns the singleton value.
-        ** @exception: panics on error.
+        ** @exception: leaves on error.
         */
         static OsclAny* lockAndGetInstance(uint32 ID)
         {
@@ -241,7 +229,7 @@
         * Set the value of the singleton.  Assume the singleton table is locked on entry.
         * @param ptr the singleton value
         * @param ID the singleton ID
-        ** @exception: panics on error.
+        ** @exception: leaves on error.
         */
         static void registerInstanceAndUnlock(OsclAny* ptr, uint32 ID)
         {
@@ -321,7 +309,7 @@
         ** Get an entry
         ** @param ID: identifier
         ** @returns: the entry value
-        ** @exception: panics on error.
+        ** @exception: leaves on error.
         */
         static OsclAny* getInstance(uint32 ID)
         {
@@ -338,7 +326,7 @@
         ** Set an entry
         ** @param ID: identifier
         ** @returns: the entry value
-        ** @exception: panics on error.
+        ** @exception: leaves on error.
         */
         static void registerInstance(OsclAny* ptr, uint32 ID)
         {
diff --git a/oscl/oscl/osclerror/src/oscl_error_allocator.h b/oscl/oscl/osclerror/src/oscl_error_allocator.h
index 6f25f66..6efc2ad 100644
--- a/oscl/oscl/osclerror/src/oscl_error_allocator.h
+++ b/oscl/oscl/osclerror/src/oscl_error_allocator.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_error_codes.h b/oscl/oscl/osclerror/src/oscl_error_codes.h
index 8afb44c..f2b58d5 100644
--- a/oscl/oscl/osclerror/src/oscl_error_codes.h
+++ b/oscl/oscl/osclerror/src/oscl_error_codes.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,8 @@
 #define OsclErrNotInstalled 115
 #define OsclErrAlreadyInstalled 116
 #define OsclErrSystemCallFailed 117
+#define OsclErrNoHandler 118
+#define OsclErrThreadContextIncorrect 119
 
 /** For backward compatibility with old definitions
 */
diff --git a/oscl/oscl/osclerror/src/oscl_error_imp.h b/oscl/oscl/osclerror/src/oscl_error_imp.h
index ece6152..0d26381 100644
--- a/oscl/oscl/osclerror/src/oscl_error_imp.h
+++ b/oscl/oscl/osclerror/src/oscl_error_imp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@
 #include "osclconfig_error.h"
 #endif
 
-/** Internal leave/trap/panic implementation.
+/** Internal leave/trap implementation.
 */
 
 //This selects the type of implementation
@@ -54,7 +54,7 @@
 */
 
 /**
-//include the internal leave/trap/panic implementation macros.
+//include the internal leave/trap implementation macros.
 */
 #if defined( PVERROR_IMP_JUMPS)
 #include "oscl_error_imp_jumps.h"
@@ -63,16 +63,9 @@
 #elif defined(PVERROR_IMP_FATAL_ERROR)
 #include "oscl_error_imp_fatalerror.h"
 #else
-#error No leave/panic implementation!
+#error No leave implementation!
 #endif
 
-/** Option to enable the trap level check.
-** When enabled, the cleanup stack will generate
-** panics for any Push operation outside a Trap.
-** Symbian generates these panics, but they're optional
-** on non-Symbian.
-*/
-#undef PVERROR_TRAP_LEVEL_CHECKS
 
 
 
diff --git a/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h b/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h
index da2f3c2..4368ac2 100644
--- a/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h
+++ b/oscl/oscl/osclerror/src/oscl_error_imp_cppexceptions.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
 
 
 /** \file oscl_error_imp_cppexceptions.h
-    \brief Implementation File for Leave and Panic using C++ exceptions.
+    \brief Implementation File for Leave using C++ exceptions.
 */
 
 #ifndef OSCL_ERROR_IMP_CPPEXCEPTIONS_H_INCLUDED
@@ -39,27 +39,21 @@
 #include "oscl_error_trapcleanup.h"
 #endif
 
-//Implementation file for Leave and Panic using C++ exceptions.
+//Implementation file for Leave using C++ exceptions.
 
-//This is a full implementation of Leave and Panic.
+//This is a full implementation of Leave.
 
 class internalLeave
 {
     public:
         int a;
 };
-class internalPanic
-{
-    public:
-        int b;
-};
 
-//Leave and Panic throw C++ exceptions.
+//Leave throws C++ exceptions.
 #define PVError_DoLeave() internalLeave __ilv;__ilv.a=0;throw(__ilv)
-#define PVError_DoPanic() internalPanic __ipn;__ipn.b=0;throw(__ipn)
 
 
-//_PV_TRAP catches Leaves but allows panics to bubble.
+//_PV_TRAP catches Leaves.
 //_r is the leave code, _s are statements to execute
 #define _PV_TRAP(__r,__s)\
 	__r=OsclErrNone;\
@@ -69,12 +63,10 @@
 		try{__s;}\
 		catch(internalLeave __lv)\
 		{__lv.a=__r=__tr->iLeave;}\
-		catch(internalPanic __pn)\
-		{__tr->UnTrap();throw(__pn);}\
 		__tr->UnTrap();}\
 	}
 
-//_PV_TRAP_NO_TLS catches Leaves but allows panics to bubble.
+//_PV_TRAP_NO_TLS catches Leaves.
 //_r is the leave code, _s are statements to execute
 #define _PV_TRAP_NO_TLS(__trapimp,__r,__s)\
 	__r=OsclErrNone;\
@@ -84,24 +76,6 @@
 		try{__s;}\
 		catch(internalLeave __lv)\
 		{__lv.a=__r=__tr->iLeave;}\
-		catch(internalPanic __pn)\
-		{__tr->UnTrap();throw(__pn);}\
-		__tr->UnTrap();}\
-	}
-
-//_PV_TRAP_ALL catches Leaves and panics.
-//_r is leave code, _p is TPVErrorPanic, _s is statements to execute.
-#define _PV_TRAP_ALL(__r,__p,__s)\
-	__r=OsclErrNone;\
-	__p.iReason=OsclErrNone;\
-	{\
-		OsclErrorTrapImp* __tr=OsclErrorTrapImp::Trap();\
-		if(!__tr){__s;}else{\
-		try{__s;}\
-		catch(internalLeave __lv)\
-		{__lv.a=__r=__tr->iLeave;}\
-		catch(internalPanic __pn)\
-		{__pn.b=__p.iReason=__tr->iPanic.iReason;__p.iCategory.Set(__tr->iPanic.iCategory.Str());}\
 		__tr->UnTrap();}\
 	}
 
diff --git a/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h b/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h
index 966f914..03636dc 100644
--- a/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h
+++ b/oscl/oscl/osclerror/src/oscl_error_imp_fatalerror.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,25 +29,24 @@
 
 
 /** \file oscl_error_imp_fatalerror.h
-    \brief Implementation File for Leave and Panic using system fatal error.
+    \brief Implementation File for Leave using system fatal error.
 */
 
 #ifndef OSCL_ERROR_IMP_FATALERROR_H_INCLUDED
 #define OSCL_ERROR_IMP_FATALERROR_H_INCLUDED
 
-// Implementation File for Leave and Panic using system fatal error.
+// Implementation File for Leave using system fatal error.
 
 //Fatal error implementation for compilers without C++ exceptions.
-//This implementation is very limited.  Leave and Panic conditions
+//This implementation is very limited.  Leave conditions
 //just cause fatal program errors.  There is no way to catch or trap
-//any Leave or Panic.
+//any Leave.
 #ifndef OSCL_ASSERT_H_INCLUDED
 #include "oscl_assert.h"
 #endif
 
-//Leave and Panic just call a system fatal error.
+//Leave just calls a system fatal error.
 #define PVError_DoLeave() _OSCL_Abort()
-#define PVError_DoPanic() _OSCL_Abort()
 
 //_PV_TRAP
 //_r is leave code, _s is statements.
@@ -67,17 +66,6 @@
 	__r=OsclErrNone;\
 	{__s;}
 
-//_PV_TRAP_ALL
-//_r is leave code, _p is TPVErrorPanic,
-//_s is statements.
-//this macro isn't really functional since any
-//leave will abort the program, but it's needed
-//to compile.
-#define _PV_TRAP_ALL(__r,__p,__s) \
-	__r=OsclErrNone;\
-	__p.iReason=OsclErrNone;\
-	{__s;}
-
 
 
 #endif // OSCL_ERROR_IMP_FATALERROR_H_INCLUDED
diff --git a/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp b/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp
index f90dd35..92ee0c8 100644
--- a/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp
+++ b/oscl/oscl/osclerror/src/oscl_error_imp_jumps.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
     OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap(error);
     if (!trap)
     {
-        //Note: you can't panic here, since panic would
+        //Note: you can't leave here, since leave would
         //invoke this routine again.  It is not safe to return
         //either, because calling code is expecting an execution
         //end.
diff --git a/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h b/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h
index 817b3c9..a85abf1 100644
--- a/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h
+++ b/oscl/oscl/osclerror/src/oscl_error_imp_jumps.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
 
 
 /** \file oscl_error_imp_jumps.h
-    \brief Implemenation of Leave and Panic using Setjmp / Longjmp.
+    \brief Implemenation of using Setjmp / Longjmp.
 */
 
 #ifndef OSCL_ERROR_IMP_JUMPS_H_INCLUDED
@@ -42,7 +42,7 @@
 #include "oscl_assert.h"
 #endif
 
-// Implemenation of Leave and Panic using Setjmp / Longjmp.
+// Implemenation of Leave using Setjmp / Longjmp.
 
 //ANSI setjmp/longjmp implementation.  This is needed on any OS
 //that does not support C++ exceptions.  This is a complete implementation.
@@ -60,9 +60,6 @@
 #ifndef OSCL_ERROR_H_INCLUDED
 #include "oscl_error.h"
 #endif
-#ifndef OSCL_EXECPANIC_H_INCLUDED
-#include "oscl_execpanic.h"
-#endif
 
 class Oscl_DefAlloc;
 
@@ -82,7 +79,7 @@
         {
             if (!Top())
             {
-                //Note: you can't panic here, since panic would
+                //Note: you can't leave here, since leave would
                 //invoke this routine again.  It is not safe to return
                 //either, because calling code is expecting an execution
                 //end.
@@ -109,18 +106,14 @@
 
         void PushMark()
         {
-            if (iJumpIndex == (OSCL_JUMP_MAX_JUMP_MARKS - 1))
-                PV_EXECPANIC(ETrapNoFreeSlotItem);//jump stack is full!
-            else
-                iJumpIndex++;
+            OSCL_ASSERT(iJumpIndex < (OSCL_JUMP_MAX_JUMP_MARKS - 1));//jump stack is full!
+            iJumpIndex++;
         }
 
         void PopMark()
         {
-            if (iJumpIndex < 0)
-                PV_EXECPANIC(ETrapPopUnderflow);
-            else
-                iJumpIndex--;
+            OSCL_ASSERT(iJumpIndex >= 0);//jump stack is empty!
+            iJumpIndex--;
         }
 
         jmp_buf iJumpArray[OSCL_JUMP_MAX_JUMP_MARKS];
@@ -134,13 +127,11 @@
 
 //internal jump type codes.
 #define internalLeave (-1)
-#define internalPanic (-2)
 
-//Leave and Panic use the OsclJump methods
+//Leave uses the OsclJump methods
 #define PVError_DoLeave() OsclJump::StaticJump(internalLeave)
-#define PVError_DoPanic() OsclJump::StaticJump(internalPanic)
 
-//_PV_TRAP macro catches leaves but allows panics to bubble
+//_PV_TRAP macro catches leaves.
 //_r is leave code, _s is statements to execute.
 #define _PV_TRAP(__r,__s)\
 	__r=OsclErrNone;\
@@ -152,8 +143,6 @@
 		{__s;}\
 		else if (__tr==internalLeave)\
 		{__r=__trap->iLeave;}\
-		else if (__tr==internalPanic)\
-		{__trap->UnTrap();__trap->iJumpData->Jump(__tr);}\
 		__trap->UnTrap();}\
 	}
 
@@ -169,29 +158,9 @@
 		{__s;}\
 		else if (__tr==internalLeave)\
 		{__r=__trap->iLeave;}\
-		else if (__tr==internalPanic)\
-		{__trap->UnTrap();__trap->iJumpData->Jump(__tr);}\
 		__trap->UnTrap();}\
 	}
 
-//_PV_TRAP_ALL macro catches leaves and panics.
-//_r is leave code, _p is TPVErrorPanic,
-//_s is statements to execute.
-#define _PV_TRAP_ALL(__r,__p,__s)\
-	__r=OsclErrNone;\
-	__p.iReason=OsclErrNone;\
-	{\
-		OsclErrorTrapImp* __trap=OsclErrorTrapImp::Trap();\
-		if(!__trap){__s;}else{\
-		int __tr=setjmp(*(__trap->iJumpData->Top()));\
-		if (__tr==0)\
-		{__s;}\
-		else if (__tr==internalLeave)\
-		{__r=__trap->iLeave;}\
-		else if (__tr==internalPanic)\
-		{__p.iReason=__trap->iPanic.iReason;__p.iCategory.Set(__trap->iPanic.iCategory.Str());}\
-		__trap->UnTrap();}\
-	}
 
 #endif // OSCL_ERROR_IMP_JUMPS_H_INCLUDED
 
diff --git a/oscl/oscl/osclerror/src/oscl_error_panic.h b/oscl/oscl/osclerror/src/oscl_error_panic.h
deleted file mode 100644
index ed091d4..0000000
--- a/oscl/oscl/osclerror/src/oscl_error_panic.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//               O S C L _ E R R O R _ P A N I C
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-/*! \addtogroup osclerror OSCL Error
- *
- * @{
- */
-
-/** \file oscl_error_panic.h
-    \brief Defines a way to cause a panic (i.e., terminate execution)
-*/
-
-
-#ifndef OSCL_ERROR_PANIC_H_INCLUDED
-#define OSCL_ERROR_PANIC_H_INCLUDED
-
-#ifndef OSCL_NAMESTRING_H_INCLUDED
-#include "oscl_namestring.h"
-#endif
-
-#ifndef OSCL_ERROR_H_INCLUDED
-#include "oscl_error.h"
-#endif
-
-//! Use this macro to cause a Panic. It terminates the execution of the current active function
-/*!
-   \param oscl_panic_status is an integer panic code
-   \param oscl_panic_category is a const char [] parameter that tells
-   the panic category.  The panic category should be no longer than PVPANICCATLEN or else
-   it may be truncated.
-*/
-#define OSCL_PANIC(oscl_panic_status,oscl_panic_category) OsclError::Panic(oscl_panic_status,oscl_panic_category)
-
-//Panic Error Class
-
-#define PVPANICCATLEN 16
-
-class TPVErrorPanic
-{
-    public:
-        TPVErrorPanic(): iReason(0)
-        {}
-        int32 iReason;
-        OsclNameString<PVPANICCATLEN> iCategory;
-};
-
-#include "oscl_error_imp.h"
-
-//! Use this macro to trap a thread Panic.
-//!	It will also trap any leave.
-//! A panic is a fatal error and does not provide
-//! any memory cleanup.  The application should terminate
-//! any panicked thread.
-/*!
-   \param _leave_code is an integer variable that will receive the
-   leave code, or zero if no leave occurs.
-   \param _panic_code is a TPVErrorPanic variable that will receive the
-   panic.  If no panic occurs, the iReason member will be zero.
-   \param _statements is a statement or block of statements to execute
-   under the trap handler.
-*/
-#define OSCL_PANIC_TRAP(_leave_code,_panic,_statements) _PV_TRAP_ALL(_leave_code,_panic,_statements)
-
-
-
-#endif
-
-/*! @} */
-
diff --git a/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp b/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp
index 3093478..76d8c5c 100644
--- a/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp
+++ b/oscl/oscl/osclerror/src/oscl_error_trapcleanup.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 #include "oscl_error_trapcleanup.h"
 #include "oscl_assert.h"
+#include "oscl_error_codes.h"
 
 
 OsclErrorTrapImp::OsclErrorTrapImp(Oscl_DefAlloc *alloc, int32 &aError)
@@ -49,8 +50,6 @@
         iTrapStack = new(ptr) OsclTrapStack(iAlloc);
     }
     iLeave = OsclErrNone;
-    iPanic.iReason = OsclErrNone;
-    iPanic.iCategory.Set("");
 }
 
 
@@ -71,8 +70,6 @@
 }
 
 
-#include "oscl_execpanic.h"
-
 OSCL_EXPORT_REF OsclErrorTrapImp * OsclErrorTrapImp::Trap()
 //static function to enter a trap level.
 {
@@ -81,7 +78,6 @@
     if (!trap)
         return NULL;//trap is non-functional.
     trap->iLeave = OsclErrNone;
-    trap->iPanic.iReason = OsclErrNone;
     trap->iTrapStack->Trap();
 #if defined(PVERROR_IMP_JUMPS)
     trap->iJumpData->PushMark();
@@ -101,7 +97,6 @@
     if (!trap)
         return NULL;//trap is non-functional.
     trap->iLeave = OsclErrNone;
-    trap->iPanic.iReason = OsclErrNone;
     trap->iTrapStack->Trap();
 #if defined(PVERROR_IMP_JUMPS)
     trap->iJumpData->PushMark();
@@ -111,15 +106,17 @@
 
 OSCL_EXPORT_REF void OsclErrorTrapImp::UnTrap()
 {
+    //clear the global leave code
+    iLeave = 0;
+
     bool notempty = iTrapStack->UnTrap();
+    OSCL_UNUSED_ARG(notempty);
 
 #if defined(PVERROR_IMP_JUMPS)
     iJumpData->PopMark();
 #endif
 
-    if (notempty)
-        PV_EXECPANIC(ETrapLevelNotEmpty);
-
+    OSCL_ASSERT(!notempty);//ETrapLevelNotEmpty
 }
 
 ///////////////
@@ -139,8 +136,7 @@
 //leave the current trap by popping the trap stack.
 {
     //check for untrap without corresponding trap.
-    if (!TrapTop())
-        PV_EXECPANIC(ETrapLevelUnderflow);
+    OSCL_ASSERT(TrapTop());//ETrapLevelUnderflow
 
     //make sure all cleanup items in this level have
     //been popped.
@@ -173,9 +169,14 @@
         PopTrap();
 }
 
-void OsclTrapStack::PushL(OsclHeapBase *aCBase)
+void OsclTrapStack::PushL(_OsclHeapBase *aCBase)
 //Push a CBase item onto the cleanup stack
 {
+    //Note: on Symbian you get a panic for doing
+    //a push outside any TRAP statement, so generate an
+    //error here also.
+    OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero
+
     OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem));
     OsclError::LeaveIfNull(ptr);
     OsclTrapStackItem * item = new(ptr) OsclTrapStackItem(aCBase);
@@ -185,6 +186,11 @@
 void OsclTrapStack::PushL(OsclAny *aTAny)
 //Push a nonOsclTrapStackCBase item onto the cleanup stack
 {
+    //Note: on Symbian you get a panic for doing
+    //a push outside any TRAP statement, so generate an
+    //error here also.
+    OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero
+
     OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem));
     OsclError::LeaveIfNull(ptr);
     OsclTrapStackItem *item = new(ptr) OsclTrapStackItem(aTAny);
@@ -201,6 +207,11 @@
 
 void OsclTrapStack::PushL(OsclTrapItem anItem)
 {
+    //Note: on Symbian you get a panic for doing
+    //a push outside any TRAP statement, so generate an
+    //error here also.
+    OSCL_ASSERT(TrapTop());//ETrapPushAtLevelZero
+
     OsclAny* ptr = iAlloc->ALLOCATE(sizeof(OsclTrapStackItem));
     OsclError::LeaveIfNull(ptr);
     OsclTrapStackItem *item = new(ptr) OsclTrapStackItem(anItem);
@@ -210,14 +221,6 @@
 void OsclTrapStack::Push(OsclTrapStackItem *aItem)
 //push the given item onto the stack.
 {
-#ifdef PVERROR_TRAP_LEVEL_CHECKS
-    //Note: on Symbian you get this panic for doing
-    //a push outside any TRAP statement.  The panic
-    //is optional on non-Symbian.
-    if (!iTrapTop)
-        PV_EXECPANIC(ETrapPushAtLevelZero);
-#endif
-
     if (aItem)
     {
         aItem->iNext = iTop;
@@ -229,12 +232,11 @@
 //pop the stack.
 {
     if (!iTop)
-        PV_EXECPANIC(ETrapPopUnderflow);
+        OsclError::Leave(OsclErrUnderflow);//ETrapPopUnderflow
 
     //check for a pop beyond the current trap level
-    if (TrapTop()
-            && iTop->iTAny == TrapTop()->iTAny)
-        PV_EXECPANIC(ETrapPopAcrossLevels);
+    if (TrapTop() && iTop->iTAny == TrapTop()->iTAny)
+        OsclError::Leave(OsclErrUnderflow);//ETrapPopAcrossLevels
 
     OsclTrapStackItem *next = iTop->iNext;
     iTop->~OsclTrapStackItem();
@@ -245,8 +247,7 @@
 inline void OsclTrapStack::PopTrap()
 //pop the trap mark stack.
 {
-    if (!TrapTop())
-        PV_EXECPANIC(ETrapPopUnderflow);
+    OSCL_ASSERT(TrapTop());//ETrapPopUnderflow
 
     //call destructor on the item in-place
     TrapTop()->~OsclTrapStackItem();
@@ -256,8 +257,7 @@
 
 void OsclTrapStack::Pop(int32 aCount)
 {
-    if (aCount < 0)
-        PV_EXECPANIC(ETrapPopCountNegative);
+    OSCL_ASSERT(aCount >= 0);//ETrapPopCountNegative
     for (int i = 0;i < aCount;i++)
         Pop();
 }
@@ -265,13 +265,10 @@
 void OsclTrapStack::PopDealloc()
 {
     if (!iTop)
-        PV_EXECPANIC(ETrapPopUnderflow);
+        OsclError::Leave(OsclErrUnderflow);//ETrapPopUnderflow;
 
-    //do this check before the destroy, to avoid
-    //corrupting the stack when the panic happens.
-    if (TrapTop()
-            && iTop->iTAny == TrapTop()->iTAny)
-        PV_EXECPANIC(ETrapPopAcrossLevels);
+    if (TrapTop() && iTop->iTAny == TrapTop()->iTAny)
+        OsclError::Leave(OsclErrUnderflow);//ETrapPopAcrossLevels;
 
     if (iTop->iCBase)
     {
@@ -305,11 +302,7 @@
 //for the current trap level.
 {
     //check for a leave outside any trap.
-    if (!TrapTop())
-    {
-        PV_EXECPANIC(ETrapLevelUnderflow);
-        return;
-    }
+    OSCL_ASSERT(TrapTop());//ETrapLevelUnderflow
 
     while (iTop && iTop->iTAny != TrapTop()->iTAny)
         PopDealloc();
diff --git a/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h b/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h
index c585eb1..0a15664 100644
--- a/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h
+++ b/oscl/oscl/osclerror/src/oscl_error_trapcleanup.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@
 {
     public:
         OsclTrapStackItem() {}
-        OsclTrapStackItem(OsclHeapBase *aCBase)
+        OsclTrapStackItem(_OsclHeapBase *aCBase)
         {
             iCBase = aCBase;
             iTAny = (OsclAny*)aCBase;
@@ -75,7 +75,7 @@
             iTrapOperation = aItem.iOperation;
             iNext = NULL;
         }
-        OsclHeapBase *iCBase;
+        _OsclHeapBase *iCBase;
         OsclAny *iTAny;
         OsclTrapOperation iTrapOperation;
         OsclTrapStackItem *iNext;
@@ -114,7 +114,7 @@
         inline bool UnTrap();
 
         //Cleanup stack APIs
-        void PushL(OsclHeapBase *aCBase);
+        void PushL(_OsclHeapBase *aCBase);
         void PushL(OsclAny *aTAny);
         void PushL(OsclTrapItem anItem);
         void Push(OsclTrapStackItem *aItem);
@@ -156,36 +156,31 @@
 
         void pushTrapIndex()
         {
-            if (iTrapTopIndex == (OSCL_MAX_TRAP_LEVELS - 1))
-                PV_EXECPANIC(ETrapNoFreeSlotItem);//stack is full.
-            else
-                iTrapTopIndex++;
+            OSCL_ASSERT(iTrapTopIndex < (OSCL_MAX_TRAP_LEVELS - 1));//stack overflow
+            iTrapTopIndex++;
         }
 
         void popTrapIndex()
         {
-            if (iTrapTopIndex < 0)
-                PV_EXECPANIC(ETrapPopUnderflow);
-            else
-                iTrapTopIndex--;
+            OSCL_ASSERT(iTrapTopIndex >= 0);//stack underflow
+            iTrapTopIndex--;
         }
 };
 
 
 
-#ifndef OSCL_ERROR_PANIC_H_INCLUDED
-#include "oscl_error_panic.h"
-#endif
-
 #ifndef OSCL_BASE_ALLOC_H_INCLUDED
 #include "oscl_base_alloc.h"
 #endif
 
 //For non-symbian, the error trap stack must be in a global registry.
 //
-//use TLS registry unless it's not available, then
+//Use TLS registry unless it's not available, then
 //use singleton.
+//Note: singleton-based registry only works for single-threaded
+//scenarios because this implementation assumes a per-thread registry.
 #include "oscl_tls.h"
+#include "oscl_singleton.h"
 #define PVERRORTRAP_REGISTRY_ID OSCL_TLS_ID_PVERRORTRAP
 #define PVERRORTRAP_REGISTRY OsclTLSRegistry
 
@@ -205,8 +200,7 @@
         OsclJump *iJumpData;
 #endif
 
-        //Global leave/panic info.
-        TPVErrorPanic iPanic;
+        //Global leave info.
         int32 iLeave;
 
     public:
@@ -232,15 +226,12 @@
         }
         static OsclErrorTrapImp* GetErrorTrap()
         //static function to get currently installed error trap
-        //for this thread.  panics on error.
+        //for this thread.  returns NULL on error.
         {
             int32 error;
             OsclErrorTrapImp* current = GetErrorTrap(error);
             if (error)
-            {
-                OSCL_ASSERT(0);
                 return NULL;
-            }
             return current;
         }
 
diff --git a/oscl/oscl/osclerror/src/oscl_exception.h b/oscl/oscl/osclerror/src/oscl_exception.h
index 9c8bd39..e5c34ad 100644
--- a/oscl/oscl/osclerror/src/oscl_exception.h
+++ b/oscl/oscl/osclerror/src/oscl_exception.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_execpanic.h b/oscl/oscl/osclerror/src/oscl_execpanic.h
deleted file mode 100644
index 95dac78..0000000
--- a/oscl/oscl/osclerror/src/oscl_execpanic.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/** \file oscl_execpanic.h
-    \brief Definition of ExecutionObject/Scheduler panic codes.
-*/
-#ifndef OSCL_EXECPANIC_H_INCLUDED
-#define OSCL_EXECPANIC_H_INCLUDED
-
-#ifndef OSCLCONFIG_ERROR_H_INCLUDED
-#include "osclconfig_error.h"
-#endif
-
-
-/**
-//ExecutionObject Panic codes for category "PVEXEC"
-*/
-enum OsclExecPanic
-{
-    EExecStillReadyOnDestruct = 40, //
-    EExecAlreadyAdded = 41, //
-    EExecAlreadyActive = 42, //
-    //EExecSchedulerAlreadyExists=43,
-    //EExecSchedulerDoesNotExist=44,
-    //EExecTooManyStops=45,
-    EExecStrayEvent = 46,
-    EExecObjectLeave = 47,
-    EExecNull = 48, //
-    EExecNotAdded = 49, //
-
-    ETrapPopAcrossLevels = 63, //
-    ETrapPopUnderflow = 64, //
-    ETrapLevelUnderflow = 65, //
-    ETrapPushAtLevelZero = 66,
-    //ETrapNoCleanupOperation=67,
-    ETrapNoFreeSlotItem = 68,
-    //ETrapNoHandlerInstalled=69,
-    ETrapPopCountNegative = 70, //
-    ETrapLevelNotEmpty = 71, //
-};
-
-#define PV_EXECPANIC(x) OsclError::Panic("PVEXEC",x)
-
-
-#endif
-
diff --git a/oscl/oscl/osclerror/src/oscl_heapbase.cpp b/oscl/oscl/osclerror/src/oscl_heapbase.cpp
index 1c80e3f..cd7cafc 100644
--- a/oscl/oscl/osclerror/src/oscl_heapbase.cpp
+++ b/oscl/oscl/osclerror/src/oscl_heapbase.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_heapbase.h b/oscl/oscl/osclerror/src/oscl_heapbase.h
index fc9b945..1c3223e 100644
--- a/oscl/oscl/osclerror/src/oscl_heapbase.h
+++ b/oscl/oscl/osclerror/src/oscl_heapbase.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,21 +43,21 @@
 #endif
 
 /**
-//OsclHeapBase is used as the base for cleanup stack
+//_OsclHeapBase is used as the base for cleanup stack
 //items with virtual destructor.
 */
 
 
-class OsclHeapBase
+class _OsclHeapBase
 {
     public:
-        virtual ~OsclHeapBase() {}
+        virtual ~_OsclHeapBase() {}
 
     protected:
-        OsclHeapBase() {}
-        OsclHeapBase(const OsclHeapBase&) {}
+        _OsclHeapBase() {}
+        _OsclHeapBase(const _OsclHeapBase&) {}
     private:
-        OsclHeapBase& operator=(const OsclHeapBase&);
+        _OsclHeapBase& operator=(const _OsclHeapBase&);
         friend class PVCleanupStack;
 };
 
diff --git a/oscl/oscl/osclerror/src/oscl_heapbase.inl b/oscl/oscl/osclerror/src/oscl_heapbase.inl
index d5372ee..b00af4f 100644
--- a/oscl/oscl/osclerror/src/oscl_heapbase.inl
+++ b/oscl/oscl/osclerror/src/oscl_heapbase.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_mem_align.h b/oscl/oscl/osclerror/src/oscl_mem_align.h
index d7bb59f..32554f0 100644
--- a/oscl/oscl/osclerror/src/oscl_mem_align.h
+++ b/oscl/oscl/osclerror/src/oscl_mem_align.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_mem_align.inl b/oscl/oscl/osclerror/src/oscl_mem_align.inl
index c30777e..de767a7 100644
--- a/oscl/oscl/osclerror/src/oscl_mem_align.inl
+++ b/oscl/oscl/osclerror/src/oscl_mem_align.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_mempool_allocator.cpp b/oscl/oscl/osclerror/src/oscl_mempool_allocator.cpp
index 6a22a9e..b766fa0 100644
--- a/oscl/oscl/osclerror/src/oscl_mempool_allocator.cpp
+++ b/oscl/oscl/osclerror/src/oscl_mempool_allocator.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_mempool_allocator.h b/oscl/oscl/osclerror/src/oscl_mempool_allocator.h
index 6782f0e..8a433df 100644
--- a/oscl/oscl/osclerror/src/oscl_mempool_allocator.h
+++ b/oscl/oscl/osclerror/src/oscl_mempool_allocator.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclerror/src/oscl_namestring.h b/oscl/oscl/osclerror/src/oscl_namestring.h
index 26fd507..6a38d7f 100644
--- a/oscl/oscl/osclerror/src/oscl_namestring.h
+++ b/oscl/oscl/osclerror/src/oscl_namestring.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/Android.mk b/oscl/oscl/osclio/Android.mk
index dd32fb5..838b94d 100644
--- a/oscl/oscl/osclio/Android.mk
+++ b/oscl/oscl/osclio/Android.mk
@@ -3,65 +3,69 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_dns.cpp \
-	src/oscl_dns_gethostbyname.cpp \
-	src/oscl_dns_imp_base.cpp \
-	src/oscl_dns_imp_pv.cpp \
-	src/oscl_dns_method.cpp \
-	src/oscl_dns_param.cpp \
-	src/oscl_dns_request.cpp \
-	src/oscl_file_async_read.cpp \
-	src/oscl_file_cache.cpp \
-	src/oscl_file_dir_utils.cpp \
-	src/oscl_file_find.cpp \
-	src/oscl_file_io.cpp \
-	src/oscl_file_native.cpp \
-	src/oscl_file_server.cpp \
-	src/oscl_file_stats.cpp \
-	src/oscl_ip_socket.cpp \
-	src/oscl_socket.cpp \
-	src/oscl_socket_accept.cpp \
-	src/oscl_socket_bind.cpp \
-	src/oscl_socket_connect.cpp \
-	src/oscl_socket_imp_base.cpp \
-	src/oscl_socket_imp_pv.cpp \
-	src/oscl_socket_imp_serv.cpp \
-	src/oscl_socket_listen.cpp \
-	src/oscl_socket_method.cpp \
-	src/oscl_socket_recv.cpp \
-	src/oscl_socket_recv_from.cpp \
-	src/oscl_socket_request.cpp \
-	src/oscl_socket_send.cpp \
-	src/oscl_socket_send_to.cpp \
-	src/oscl_socket_serv_imp_pv.cpp \
-	src/oscl_socket_serv_imp_reqlist.cpp \
-	src/oscl_socket_shutdown.cpp \
-	src/oscl_socket_stats.cpp \
-	src/oscl_tcp_socket.cpp \
-	src/oscl_udp_socket.cpp
-
+ 	src/oscl_dns_gethostbyname.cpp \
+ 	src/oscl_dns_imp_base.cpp \
+ 	src/oscl_dns_imp_pv.cpp \
+ 	src/oscl_dns_method.cpp \
+ 	src/oscl_dns_param.cpp \
+ 	src/oscl_dns_request.cpp \
+ 	src/oscl_file_async_read.cpp \
+ 	src/oscl_file_cache.cpp \
+ 	src/oscl_file_dir_utils.cpp \
+ 	src/oscl_file_find.cpp \
+ 	src/oscl_file_io.cpp \
+ 	src/oscl_file_native.cpp \
+ 	src/oscl_file_server.cpp \
+ 	src/oscl_file_stats.cpp \
+ 	src/oscl_ip_socket.cpp \
+ 	src/oscl_socket.cpp \
+ 	src/oscl_socket_accept.cpp \
+ 	src/oscl_socket_bind.cpp \
+ 	src/oscl_socket_connect.cpp \
+ 	src/oscl_socket_imp_base.cpp \
+ 	src/oscl_socket_imp_pv.cpp \
+ 	src/oscl_socket_imp_serv.cpp \
+ 	src/oscl_socket_listen.cpp \
+ 	src/oscl_socket_method.cpp \
+ 	src/oscl_socket_recv.cpp \
+ 	src/oscl_socket_recv_from.cpp \
+ 	src/oscl_socket_request.cpp \
+ 	src/oscl_socket_send.cpp \
+ 	src/oscl_socket_send_to.cpp \
+ 	src/oscl_socket_serv_imp_pv.cpp \
+ 	src/oscl_socket_serv_imp_reqlist.cpp \
+ 	src/oscl_socket_shutdown.cpp \
+ 	src/oscl_socket_stats.cpp \
+ 	src/oscl_tcp_socket.cpp \
+ 	src/oscl_udp_socket.cpp
 
 
 LOCAL_MODULE := libosclio
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclio/src \
-	$(PV_TOP)//oscl/oscl/osclio/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclio/src \
+ 	$(PV_TOP)/oscl/oscl/osclio/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_file_dir_utils.h \
-	src/oscl_file_find.h \
-	src/oscl_file_handle.h \
-	src/oscl_file_io.h \
-	src/oscl_file_server.h \
-	src/oscl_socket.h \
-	src/oscl_socket_types.h \
-	src/oscl_dns.h
+ 	src/oscl_file_find.h \
+ 	src/oscl_file_handle.h \
+ 	src/oscl_file_io.h \
+ 	src/oscl_file_server.h \
+ 	src/oscl_socket.h \
+ 	src/oscl_socket_types.h \
+ 	src/oscl_dns.h \
+ 	src/oscl_file_types.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclio/build/make/local.mk b/oscl/oscl/osclio/build/make/local.mk
new file mode 100644
index 0000000..1b5836b
--- /dev/null
+++ b/oscl/oscl/osclio/build/make/local.mk
@@ -0,0 +1,63 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := osclio
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS :=	oscl_dns.cpp \
+	oscl_dns_gethostbyname.cpp \
+	oscl_dns_imp_base.cpp \
+	oscl_dns_imp_pv.cpp \
+	oscl_dns_method.cpp \
+	oscl_dns_param.cpp \
+	oscl_dns_request.cpp \
+	oscl_file_async_read.cpp \
+	oscl_file_cache.cpp \
+	oscl_file_dir_utils.cpp \
+	oscl_file_find.cpp \
+	oscl_file_io.cpp \
+	oscl_file_native.cpp \
+	oscl_file_server.cpp \
+	oscl_file_stats.cpp \
+	oscl_ip_socket.cpp \
+	oscl_socket.cpp \
+	oscl_socket_accept.cpp \
+	oscl_socket_bind.cpp \
+	oscl_socket_connect.cpp \
+	oscl_socket_imp_base.cpp \
+	oscl_socket_imp_pv.cpp \
+	oscl_socket_imp_serv.cpp \
+	oscl_socket_listen.cpp \
+	oscl_socket_method.cpp \
+	oscl_socket_recv.cpp \
+	oscl_socket_recv_from.cpp \
+	oscl_socket_request.cpp \
+	oscl_socket_send.cpp \
+	oscl_socket_send_to.cpp \
+	oscl_socket_serv_imp_pv.cpp \
+	oscl_socket_serv_imp_reqlist.cpp \
+	oscl_socket_shutdown.cpp \
+	oscl_socket_stats.cpp \
+	oscl_tcp_socket.cpp \
+	oscl_udp_socket.cpp
+
+
+HDRS := oscl_file_dir_utils.h \
+	oscl_file_find.h \
+	oscl_file_handle.h \
+	oscl_file_io.h \
+	oscl_file_server.h \
+	oscl_socket.h \
+	oscl_socket_types.h \
+	oscl_dns.h \
+	oscl_file_types.h
+
+include $(MK)/library.mk
diff --git a/oscl/oscl/osclio/build/make/makefile b/oscl/oscl/osclio/build/make/makefile
deleted file mode 100644
index 9c472e1..0000000
--- a/oscl/oscl/osclio/build/make/makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclio
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	oscl_dns.cpp \
-	oscl_dns_gethostbyname.cpp \
-	oscl_dns_imp_base.cpp \
-	oscl_dns_imp_pv.cpp \
-	oscl_dns_method.cpp \
-	oscl_dns_param.cpp \
-	oscl_dns_request.cpp \
-	oscl_file_async_read.cpp \
-	oscl_file_cache.cpp \
-	oscl_file_dir_utils.cpp \
-	oscl_file_find.cpp \
-	oscl_file_io.cpp \
-	oscl_file_native.cpp \
-	oscl_file_server.cpp \
-	oscl_file_stats.cpp \
-	oscl_ip_socket.cpp \
-	oscl_socket.cpp \
-	oscl_socket_accept.cpp \
-	oscl_socket_bind.cpp \
-	oscl_socket_connect.cpp \
-	oscl_socket_imp_base.cpp \
-	oscl_socket_imp_pv.cpp \
-	oscl_socket_imp_serv.cpp \
-	oscl_socket_listen.cpp \
-	oscl_socket_method.cpp \
-	oscl_socket_recv.cpp \
-	oscl_socket_recv_from.cpp \
-	oscl_socket_request.cpp \
-	oscl_socket_send.cpp \
-	oscl_socket_send_to.cpp \
-	oscl_socket_serv_imp_pv.cpp \
-	oscl_socket_serv_imp_reqlist.cpp \
-	oscl_socket_shutdown.cpp \
-	oscl_socket_stats.cpp \
-	oscl_tcp_socket.cpp \
-	oscl_udp_socket.cpp
-
-
-HDRS =  oscl_file_dir_utils.h \
-	oscl_file_find.h \
-	oscl_file_handle.h \
-	oscl_file_io.h \
-	oscl_file_server.h \
-	oscl_socket.h \
-	oscl_socket_types.h \
-    oscl_dns.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/oscl/oscl/osclio/src/oscl_dns.cpp b/oscl/oscl/osclio/src/oscl_dns.cpp
index af24b6f..a4dbe3c 100644
--- a/oscl/oscl/osclio/src/oscl_dns.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns.h b/oscl/oscl/osclio/src/oscl_dns.h
index 36188be..5a3dd9f 100644
--- a/oscl/oscl/osclio/src/oscl_dns.h
+++ b/oscl/oscl/osclio/src/oscl_dns.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -94,7 +94,7 @@
 /**
 * The DNS class
 */
-class OsclDNS: public OsclHeapBase
+class OsclDNS: public HeapBase
 {
     public:
         /**
diff --git a/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp b/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp
index 3347fcd..bf43e8b 100644
--- a/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns_gethostbyname.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h b/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h
index 5ee97f0..906e8f4 100644
--- a/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h
+++ b/oscl/oscl/osclio/src/oscl_dns_gethostbyname.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_imp.h b/oscl/oscl/osclio/src/oscl_dns_imp.h
index a41cdcd..138b7e8 100644
--- a/oscl/oscl/osclio/src/oscl_dns_imp.h
+++ b/oscl/oscl/osclio/src/oscl_dns_imp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp b/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp
index e069b63..184baed 100644
--- a/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns_imp_base.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_imp_base.h b/oscl/oscl/osclio/src/oscl_dns_imp_base.h
index 2285fd5..a14cd61 100644
--- a/oscl/oscl/osclio/src/oscl_dns_imp_base.h
+++ b/oscl/oscl/osclio/src/oscl_dns_imp_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp b/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp
index 3cb2e5f..2a9a78d 100644
--- a/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns_imp_pv.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_imp_pv.h b/oscl/oscl/osclio/src/oscl_dns_imp_pv.h
index 3544567..603df75 100644
--- a/oscl/oscl/osclio/src/oscl_dns_imp_pv.h
+++ b/oscl/oscl/osclio/src/oscl_dns_imp_pv.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_method.cpp b/oscl/oscl/osclio/src/oscl_dns_method.cpp
index 029fc67..70e507f 100644
--- a/oscl/oscl/osclio/src/oscl_dns_method.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns_method.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_method.h b/oscl/oscl/osclio/src/oscl_dns_method.h
index ecc0c40..b8f81b4 100644
--- a/oscl/oscl/osclio/src/oscl_dns_method.h
+++ b/oscl/oscl/osclio/src/oscl_dns_method.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_param.cpp b/oscl/oscl/osclio/src/oscl_dns_param.cpp
index 8e46bc2..4ece6bf 100644
--- a/oscl/oscl/osclio/src/oscl_dns_param.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns_param.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_param.h b/oscl/oscl/osclio/src/oscl_dns_param.h
index 318a24a..4d0c17a 100644
--- a/oscl/oscl/osclio/src/oscl_dns_param.h
+++ b/oscl/oscl/osclio/src/oscl_dns_param.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_request.cpp b/oscl/oscl/osclio/src/oscl_dns_request.cpp
index 7949ddb..fe455ce 100644
--- a/oscl/oscl/osclio/src/oscl_dns_request.cpp
+++ b/oscl/oscl/osclio/src/oscl_dns_request.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_request.h b/oscl/oscl/osclio/src/oscl_dns_request.h
index 4db49a4..a03bdbe 100644
--- a/oscl/oscl/osclio/src/oscl_dns_request.h
+++ b/oscl/oscl/osclio/src/oscl_dns_request.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_dns_tuneables.h b/oscl/oscl/osclio/src/oscl_dns_tuneables.h
index f11d6ef..b65f502 100644
--- a/oscl/oscl/osclio/src/oscl_dns_tuneables.h
+++ b/oscl/oscl/osclio/src/oscl_dns_tuneables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_async_read.cpp b/oscl/oscl/osclio/src/oscl_file_async_read.cpp
index 03c99c7..361e597 100644
--- a/oscl/oscl/osclio/src/oscl_file_async_read.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_async_read.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -120,7 +120,6 @@
 
     if (iNativeFileDuplicate)
     {
-        iNativeFileDuplicate->Close();
         OSCL_DELETE(iNativeFileDuplicate);
     }
 
@@ -146,6 +145,8 @@
 {
     iLogger = aLogger;
 
+    iNumOfRun = 0;
+    iNumOfRunErr = 0;
     iHasNativeAsyncRead = iNativeFile.HasAsyncRead();
 
     // Init thread state tracking variable(s)
@@ -454,6 +455,7 @@
         int32 ret = iNativeFileDuplicate->Seek(aOffset, Oscl_File::SEEKSET);
         if (ret != 0)
         {
+            // This is not good
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                             (0, "OsclAsyncFile(0x%x)::doRead Seek Failed returned %d offset %d", this, ret, aOffset));
             return 0;
@@ -853,10 +855,12 @@
 //The AO is invoked when the asynchronous Read request is complete.
 void OsclAsyncFile::Run()
 {
+    iNumOfRun++;
     if (iStatus != OSCL_REQUEST_ERR_NONE)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                         (0, "OsclAsyncFile(0x%x)::Run Error!!!", this));
+        iNumOfRunErr++;
         return;
     }
 
@@ -914,6 +918,25 @@
     StartNextRead(posToReadFrom);
 }
 
+void OsclAsyncFile::DoCancel()
+{
+    if (!iHasNativeAsyncRead)
+    {
+        if (iAsyncReadThreadState == EAsyncReadNotActive)
+        {
+            //in case thread exited with some request active, this will
+            //complete it
+            OsclActiveObject::DoCancel();
+        }
+        else
+        {
+            //in this case, thread is active.  since there's no way to
+            //interrupt the thread's blocking read call, just do nothing
+            //here, then scheduler will wait on request completion.
+        }
+    }
+}
+
 void OsclAsyncFile::StartNextRead(int32 aPosToReadFrom)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
@@ -1008,13 +1031,15 @@
 
     if (iHasNativeAsyncRead)
     {
+        //Activate the AO that will handle read completion.
+        PendForExec();
+
         //Start the native async read operation
-        if (iNativeFile.ReadAsync(iReadPtr.Ptr(), 1, iKAsyncReadBufferSize, StatusRef()) == 0)
-        {
-            PendForExec();
-            //the AO will run when read is complete.
-        }
-        //else ignore errors.
+        int32 result = iNativeFile.ReadAsync(iReadPtr.Ptr(), 1, iKAsyncReadBufferSize, StatusRef());
+
+        //if it failed to start, then cancel the request with an error.
+        if (result != 0)
+            PendComplete(OSCL_REQUEST_ERR_GENERAL);
     }
     else
     {
@@ -1141,9 +1166,7 @@
     //note: we assume the read requests are nicely serialized here,
     //so there's no handling for overlapping requests.
 
-    //normally we would activate the AO after issuing the request, but
-    //in this implementation, the request may complete at any time once
-    //we signal the semaphore, so to be safe, activate the AO first.
+    //Activate the AO that will wait on read completion.
     PendForExec();
 
     //wake up the thread
diff --git a/oscl/oscl/osclio/src/oscl_file_async_read.h b/oscl/oscl/osclio/src/oscl_file_async_read.h
index d04ef2c..74fa2c2 100644
--- a/oscl/oscl/osclio/src/oscl_file_async_read.h
+++ b/oscl/oscl/osclio/src/oscl_file_async_read.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,12 +43,12 @@
 class OsclNativeFile;
 
 //non-modifiable buffer pointer container
-class OsclPtrC: public OsclHeapBase
+class OsclPtrC: public HeapBase
 {
     public:
         OsclPtrC(const uint8* ptr, int32 len, int32 max): iPtr(ptr), iMaxLength(max), iLength(len)
         {}
-        OsclPtrC(const OsclPtrC& d): OsclHeapBase(d), iPtr(d.iPtr), iMaxLength(d.iMaxLength), iLength(d.iLength)
+        OsclPtrC(const OsclPtrC& d): HeapBase(d), iPtr(d.iPtr), iMaxLength(d.iMaxLength), iLength(d.iLength)
         {}
         const uint8* Ptr()
         {
@@ -100,12 +100,12 @@
 };
 
 //modifiable buffer pointer container
-class OsclPtr: public OsclHeapBase
+class OsclPtr: public HeapBase
 {
     public:
         OsclPtr(uint8* ptr, int32& len, int32 max): iPtr(ptr), iMaxLength(max), iLength(len)
         {}
-        OsclPtr(const OsclPtr& d): OsclHeapBase(d), iPtr(d.iPtr), iMaxLength(d.iMaxLength), iLength(d.iLength)
+        OsclPtr(const OsclPtr& d): HeapBase(d), iPtr(d.iPtr), iMaxLength(d.iMaxLength), iLength(d.iLength)
         {}
         uint8* Ptr()
         {
@@ -149,7 +149,7 @@
 };
 
 //buffer container that allocates from the heap
-class OsclBuf: public OsclHeapBase
+class OsclBuf: public HeapBase
 {
     public:
         static OsclBuf* NewL(int32 size)
@@ -204,7 +204,7 @@
 ** consecutive areas of the file.  This allows for some seeking without requiring
 ** a full flush & refill each time.
 */
-class OsclAsyncFileBuffer: public OsclHeapBase
+class OsclAsyncFileBuffer: public HeapBase
 {
     public:
         static OsclAsyncFileBuffer* NewL(int32 aBufferSize, int32 aId);
@@ -297,6 +297,7 @@
     private:
         //From OsclActiveObject
         void Run();
+        void DoCancel();
 
     public:
         ////////////////////////
@@ -448,6 +449,10 @@
         // Request an async read.
         void StartNonNativeAsyncRead();
 
+    public:
+        // for test&stat
+        uint32 iNumOfRun;
+        uint32 iNumOfRunErr;
 };
 
 #endif
diff --git a/oscl/oscl/osclio/src/oscl_file_cache.cpp b/oscl/oscl/osclio/src/oscl_file_cache.cpp
index c7e1c48..5ec28fc 100644
--- a/oscl/oscl/osclio/src/oscl_file_cache.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_cache.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -313,7 +313,6 @@
     }
 
     //return number of whole elements written.
-    // PNSC-106: Fix division of 0 problem if size is 0
     return (size) ? ((size*numelements - bytesToWrite) / size) : 0;
 
 }
diff --git a/oscl/oscl/osclio/src/oscl_file_cache.h b/oscl/oscl/osclio/src/oscl_file_cache.h
index 5b637da..f8a6912 100644
--- a/oscl/oscl/osclio/src/oscl_file_cache.h
+++ b/oscl/oscl/osclio/src/oscl_file_cache.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp b/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp
index 031f7ce..d61ec75 100644
--- a/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_dir_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,15 +19,36 @@
     \brief This file contains file io APIs
 */
 
+#ifndef OSCL_FILE_DIR_UTILS_H_INCLUDED
 #include "oscl_file_dir_utils.h"
+#endif
+#ifndef OSCL_FILE_TYPES_H_INCLUDED
 #include "oscl_file_types.h"
+#endif
+#ifndef OSCL_UTF8CONV_H
 #include "oscl_utf8conv.h"
+#endif
+#ifndef OSCL_STDSTRING_H_INCLUDED
 #include "oscl_stdstring.h"
+#endif
+#ifndef OSCL_INT64_UTILS_H_INCLUDED
 #include "oscl_int64_utils.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
 #include "oscl_file_io.h"
+#endif
+#ifndef OSCLCONFIG_ERROR_H_INCLUDED
 #include "osclconfig_error.h"
+#endif
+#ifndef OSCL_FILE_DIR_UTILS_H_INCLUDED
 #include "oscl_file_dir_utils.h"
+#endif
+#ifndef OSCL_MEM_BASIC_FUNCTIONS_H
 #include "oscl_mem_basic_functions.h"
+#endif
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(char *path, uint32 size)
 {
@@ -82,65 +103,168 @@
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const char *path)
 {
-    OSCL_UNUSED_ARG(stats);
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    struct statfs fs_stats;
+    if (statfs(path, &fs_stats) == 0)
+    {
+        stats->freebytes = fs_stats.f_bsize * fs_stats.f_bfree;
+        stats->totalbytes = fs_stats.f_bsize * fs_stats.f_blocks;
+        return OSCL_FILEMGMT_E_OK;
+    }
+    return OSCL_FILEMGMT_E_UNKNOWN;
+
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const oscl_wchar *path)
 {
-    OSCL_UNUSED_ARG(stats);
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    char convpathname[OSCL_IO_FILENAME_MAXLEN];
+    if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) &&
+            oscl_strlen(path) != 0
+       )
+    {
+        return OSCL_FILEMGMT_E_PATH_TOO_LONG;
+    }
+    return oscl_statfs(stats, convpathname);
+
 }
 
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const oscl_wchar *path)
 {
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    char convpathname[OSCL_IO_FILENAME_MAXLEN];
+    if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) &&
+            oscl_strlen(path) != 0)
+    {
+        return OSCL_FILEMGMT_E_PATH_TOO_LONG;
+    }
+    return oscl_mkdir(convpathname);
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const char *path)
 {
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    if (mkdir(path, 0775) == 0)
+    {
+        return OSCL_FILEMGMT_E_OK;
+    }
+    else
+    {
+        switch (errno)
+        {
+            case EPERM:
+            case EACCES:
+                return OSCL_FILEMGMT_E_PERMISSION_DENIED;
+                break;
+            case EEXIST:
+                return OSCL_FILEMGMT_E_ALREADY_EXISTS;
+                break;
+            case ENOENT:
+            case ENOTDIR:
+                return OSCL_FILEMGMT_E_PATH_NOT_FOUND;
+            default:
+                break;
+        }
+    }
+    return OSCL_FILEMGMT_E_UNKNOWN;
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const oscl_wchar *path)
 {
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    char convpathname[OSCL_IO_FILENAME_MAXLEN];
+    if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) &&
+            oscl_strlen(path) != 0)
+    {
+        return OSCL_FILEMGMT_E_PATH_TOO_LONG;
+    }
+    return oscl_rmdir(convpathname);
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const char *path)
 {
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    if (rmdir(path) == 0)
+    {
+        return OSCL_FILEMGMT_E_OK;
+    }
+    else
+    {
+        switch (errno)
+        {
+            case EPERM:
+                return OSCL_FILEMGMT_E_PERMISSION_DENIED;
+            case ENOENT:
+            case ENOTDIR:
+                return OSCL_FILEMGMT_E_PATH_NOT_FOUND;
+            case ENOTEMPTY:
+                return OSCL_FILEMGMT_E_NOT_EMPTY;
+            default:
+                break;
+        }
+    }
+    return OSCL_FILEMGMT_E_UNKNOWN;
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const oscl_wchar *path)
 {
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    char convpathname[OSCL_IO_FILENAME_MAXLEN];
+    if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) &&
+            oscl_strlen(path) != 0)
+    {
+        return OSCL_FILEMGMT_E_PATH_TOO_LONG;
+    }
+    return oscl_chdir(convpathname);
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const char *path)
 {
-    OSCL_UNUSED_ARG(path);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    if (chdir(path) == 0)
+    {
+        return OSCL_FILEMGMT_E_OK;
+    }
+    else
+    {
+        switch (errno)
+        {
+            case ENOENT:
+            case ENOTDIR:
+                return OSCL_FILEMGMT_E_PATH_NOT_FOUND;
+            case EACCES:
+                return OSCL_FILEMGMT_E_PERMISSION_DENIED;
+            default:
+                break;
+        }
+    }
+    return OSCL_FILEMGMT_E_UNKNOWN;
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const oscl_wchar *oldpath, const oscl_wchar *newpath)
 {
-    OSCL_UNUSED_ARG(oldpath);
-    OSCL_UNUSED_ARG(newpath);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    char oldconvpathname[OSCL_IO_FILENAME_MAXLEN];
+    char newconvpathname[OSCL_IO_FILENAME_MAXLEN];
+    if (0 == oscl_UnicodeToUTF8(oldpath, oscl_strlen(oldpath), oldconvpathname, OSCL_IO_FILENAME_MAXLEN) ||
+            0 == oscl_UnicodeToUTF8(newpath, oscl_strlen(newpath), newconvpathname, OSCL_IO_FILENAME_MAXLEN))
+    {
+        return OSCL_FILEMGMT_E_PATH_TOO_LONG;
+    }
+    return oscl_rename(oldconvpathname, newconvpathname);
 }
 
 OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const char *oldpath, const char *newpath)
 {
-    OSCL_UNUSED_ARG(oldpath);
-    OSCL_UNUSED_ARG(newpath);
-    return OSCL_FILEMGMT_E_NOT_IMPLEMENTED;
+    if (rename(oldpath, newpath) == 0)
+    {
+        return OSCL_FILEMGMT_E_OK;
+    }
+    else
+    {
+        switch (errno)
+        {
+            case EISDIR:
+            case EEXIST:
+            case ENOTEMPTY:
+                return OSCL_FILEMGMT_E_ALREADY_EXISTS;
+            case ENOTDIR:
+                return OSCL_FILEMGMT_E_PATH_NOT_FOUND;
+            default:
+                break;
+        }
+    }
+    return OSCL_FILEMGMT_E_UNKNOWN;
 }
diff --git a/oscl/oscl/osclio/src/oscl_file_dir_utils.h b/oscl/oscl/osclio/src/oscl_file_dir_utils.h
index 2d3b8e7..fa531fa 100644
--- a/oscl/oscl/osclio/src/oscl_file_dir_utils.h
+++ b/oscl/oscl/osclio/src/oscl_file_dir_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_find.cpp b/oscl/oscl/osclio/src/oscl_file_find.cpp
index 2554ea7..a6100d2 100644
--- a/oscl/oscl/osclio/src/oscl_file_find.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_find.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,10 +23,33 @@
 #include "oscl_file_types.h"
 #include "oscl_utf8conv.h"
 #include "oscl_stdstring.h"
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
 
 OSCL_EXPORT_REF Oscl_FileFind::Oscl_FileFind()
 {
-    lastError = Oscl_FileFind::E_NOT_IMPLEMENTED;
+#if   (OSCL_HAS_GLOB)
+    count = 0;
+    haveGlob = false;
+    lastError = Oscl_FileFind::E_OK;
+#else
+#define OSCL_FILEFIND_NUMBER_OF_FILES_ENTRY 256
+
+    count = 0;
+    int err = 0;
+    haveGlob = false;
+    OSCL_TRY(err,
+             iDirEntVec.reserve(OSCL_FILEFIND_NUMBER_OF_FILES_ENTRY);
+            );
+    if (err)
+    {
+        iDirEntVec.clear();
+        OSCL_LEAVE(err);
+        lastError = Oscl_FileFind::E_OTHER;
+    }
+    lastError = Oscl_FileFind::E_OK;
+#endif
     type = Oscl_FileFind::INVALID_TYPE;
 }
 
@@ -35,48 +58,411 @@
     Close();
 }
 
+static bool oscl_strglob(const char *str, const char *p);
 OSCL_EXPORT_REF const char *Oscl_FileFind::FindFirst(const char *directory, const char *pattern, char *buf, uint32 buflen)
 {
     const char *def_pattern = "*";
-
+    lastError = Oscl_FileFind::E_OK;
+    type = Oscl_FileFind::INVALID_TYPE;
+    if (directory == NULL || buf == NULL || buflen <= 0)
+    {
+        lastError = E_INVALID_ARG;
+        return NULL;
+    }
     if (pattern == NULL) pattern = def_pattern;
 
-    OSCL_UNUSED_ARG(directory);
-    OSCL_UNUSED_ARG(buf);
-    OSCL_UNUSED_ARG(buflen);
-    return NULL;
+#if   (OSCL_HAS_GLOB)
+    int retval;
+    char path[OSCL_IO_FILENAME_MAXLEN];
+    lastError = Oscl_FileFind::E_OK;
 
+    if (haveGlob || !directory || !buf || buflen <= 0)
+    {
+        lastError = (haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+
+    if ((oscl_strlen(directory) + oscl_strlen(pattern) + 1) > OSCL_IO_FILENAME_MAXLEN)
+    {
+        lastError = Oscl_FileFind::E_PATH_TOO_LONG;
+        return NULL;
+    }
+
+    path[0] = '\0';
+    if (oscl_strlen(directory) > 0)
+    {
+        oscl_strcat(path, directory);
+
+        // Check whether path ends with delimiter
+        int32 pathLength = oscl_strlen(path);
+        bool appendPathDelimiter = true;
+        if (pathLength >= 1)
+        {
+            if (oscl_strncmp((path + pathLength - 1/*length of path delimiter is 1*/),
+                             OSCL_FILE_CHAR_PATH_DELIMITER, 1) == 0)
+            {
+                // path ends with delimiter
+                appendPathDelimiter = false;
+            }
+        }
+
+        if (appendPathDelimiter)
+        {
+            oscl_strcat(path, OSCL_FILE_CHAR_PATH_DELIMITER);
+        }
+        oscl_strcat(path, pattern);
+    }
+    else
+    {
+        oscl_strcat(path, pattern);
+    }
+
+    if ((retval = glob(path, GLOB_ERR | GLOB_NOSORT , NULL, &hFind)) == 0)
+    {
+        haveGlob = true;
+        if (hFind.gl_pathc > 0)
+        {
+            if (strlen(hFind.gl_pathv[count]) >= buflen)
+            {
+                lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+                return NULL;
+            }
+            oscl_strncpy(buf, hFind.gl_pathv[count++], buflen);
+            struct stat statbuf;
+            if (stat(buf, &statbuf) == 0)
+            {
+                type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE;
+            }
+            else
+            {
+                type = FILE_TYPE;
+            }
+            return buf;
+        }
+        else
+        {
+            Close();
+        }
+    }
+    else
+    {
+        if (GLOB_NOMATCH == retval)
+        {
+            lastError = Oscl_FileFind::E_NO_MATCH;
+        }
+        else if (GLOB_ABORTED)
+        {
+            lastError = Oscl_FileFind::E_PATH_NOT_FOUND;
+        }
+        else
+        {
+            lastError = Oscl_FileFind::E_OTHER;
+        }
+        return NULL;
+    }
+
+#else
+    // support linux having no glob.h support in glob pattern matching
+    DIR* pDir;
+    struct dirent* pEnt;
+    uint32 itr = 0;
+    struct stat statbuf;
+    if (haveGlob || !directory || !buf || buflen <= 0)
+    {
+        lastError = (haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+    if (oscl_strlen(directory) > 0)
+    {
+        pDir = opendir(directory);
+    }
+    else
+    {
+        // empty directory, replaced with searching current dir
+        // make the behavior consistent with the glob-based implementation
+        OSCL_HeapString<OsclMemAllocator> curpath(".");
+        curpath += OSCL_FILE_CHAR_PATH_DELIMITER;
+        pDir = opendir(curpath.get_cstr());
+    }
+    if (pDir == NULL)
+    {
+
+        lastError = Oscl_FileFind::E_PATH_NOT_FOUND;
+        return NULL;
+    }
+    // parsing thru dirent structure
+    while ((pEnt = readdir(pDir)) != NULL)
+    {
+        if (oscl_strglob(pEnt->d_name, pattern) &&
+                oscl_strcmp(pEnt->d_name, ".") &&
+                oscl_strcmp(pEnt->d_name, ".."))	// excluded out '.' and '..' from readdir
+        {	// pattern matched
+            iDirEntVec.push_back(pEnt->d_name);
+            // d_type is not all available on all lunix system, using stat() instead
+            if (itr == 0)
+            {
+                if (strlen(pEnt->d_name) >= buflen)
+                {
+                    lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+                    return NULL;
+                }
+                // need to return the first found element
+                oscl_strncpy(buf, pEnt->d_name, buflen);
+                if (stat(pEnt->d_name, &statbuf) == 0)
+                {
+                    type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE;
+                }
+                else
+                {
+                    type = FILE_TYPE;
+                }
+            }
+            itr++;
+        }
+    }
+    closedir(pDir);
+    if (iDirEntVec.size())
+    {
+        haveGlob = true;
+        count = 1; // advance to next element, used for findnext()
+        return iDirEntVec[0].get_str();
+    }
+    lastError = Oscl_FileFind::E_NO_MATCH;
+#endif
+    return NULL;
 }
 
 OSCL_EXPORT_REF const oscl_wchar *Oscl_FileFind::FindFirst(const oscl_wchar *directory, const oscl_wchar *pattern, oscl_wchar *buf, uint32 buflen)
 {
     const oscl_wchar *def_pattern = _STRLIT_WCHAR("*");
+    lastError = Oscl_FileFind::E_OK;
+    type = Oscl_FileFind::INVALID_TYPE;
+    if (directory == NULL || buf == NULL || buflen <= 0)
+    {
+        lastError = E_INVALID_ARG;
+        return NULL;
+    }
 
     if (pattern == NULL) pattern = def_pattern;
 
-    OSCL_UNUSED_ARG(directory);
-    OSCL_UNUSED_ARG(buf);
-    OSCL_UNUSED_ARG(buflen);
+#if   (OSCL_HAS_GLOB)
+    char convpattern[OSCL_IO_EXTENSION_MAXLEN];
+    char convdir[OSCL_IO_FILENAME_MAXLEN];
+    char utf8buf[OSCL_IO_FILENAME_MAXLEN];
+    const char *retval;
+
+    if (haveGlob || !directory || !buf || buflen <= 0)
+    {
+        lastError = (haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+
+    if ((0 == oscl_UnicodeToUTF8(directory, oscl_strlen(directory), convdir, OSCL_IO_FILENAME_MAXLEN)
+            && oscl_strlen(directory))
+            || (0 == oscl_UnicodeToUTF8(pattern, oscl_strlen(pattern), convpattern, OSCL_IO_EXTENSION_MAXLEN)
+                && oscl_strlen(pattern)))
+    {
+        lastError = Oscl_FileFind::E_PATH_TOO_LONG;
+        return NULL;
+    }
+
+    retval = FindFirst(convdir, convpattern, utf8buf, OSCL_IO_FILENAME_MAXLEN);
+
+    if (retval != NULL)
+    {
+        if (0 == oscl_UTF8ToUnicode(retval, oscl_strlen(retval), buf, buflen) && oscl_strlen(retval))
+        {
+            lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+            return NULL;
+        }
+        return buf;
+    }
+#else
+    char convpattern[OSCL_IO_EXTENSION_MAXLEN];
+    char convdir[OSCL_IO_FILENAME_MAXLEN];
+    char utf8buf[OSCL_IO_FILENAME_MAXLEN];
+    const char *retval;
+
+    if (haveGlob || !directory || !buf || buflen <= 0)
+    {
+        lastError = (haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+    if ((0 == oscl_UnicodeToUTF8(directory, oscl_strlen(directory), convdir, OSCL_IO_FILENAME_MAXLEN) &&
+            oscl_strlen(directory) != 0) ||
+            (0 == oscl_UnicodeToUTF8(pattern, oscl_strlen(pattern), convpattern, OSCL_IO_EXTENSION_MAXLEN) &&
+             oscl_strlen(pattern) != 0))
+    {
+        lastError = Oscl_FileFind::E_PATH_TOO_LONG;
+        return NULL;
+    }
+
+    retval = FindFirst(convdir, convpattern, utf8buf, OSCL_IO_FILENAME_MAXLEN);
+
+    if (retval != NULL)
+    {
+        if (0 == oscl_UTF8ToUnicode(retval, oscl_strlen(retval), buf, buflen) && oscl_strlen(retval))
+        {
+            lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+            return NULL;
+        }
+        return buf;
+    }
+#endif
 
     return NULL;
 }
 
 OSCL_EXPORT_REF char *Oscl_FileFind::FindNext(char *buf, uint32 buflen)
 {
-    OSCL_UNUSED_ARG(buf);
-    OSCL_UNUSED_ARG(buflen);
+    lastError = Oscl_FileFind::E_OK;
+    type = Oscl_FileFind::INVALID_TYPE;
+#if   (OSCL_HAS_GLOB)
+    if (!haveGlob || !buf || buflen <= 0)
+    {
+        lastError = (!haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+    if (count >= hFind.gl_pathc)
+    {
+        lastError = Oscl_FileFind::E_PATH_NOT_FOUND;
+        return NULL;
+    }
+    if (oscl_strlen(hFind.gl_pathv[count]) >= buflen)
+    {
+        lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+        return NULL;
+    }
+    else
+    {
+        oscl_strncpy(buf, hFind.gl_pathv[count++], buflen);
+        struct stat statbuf;
+        if (stat(buf, &statbuf) == 0)
+        {
+            type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE;
+        }
+        else
+        {
+            type = FILE_TYPE;
+        }
+        return buf;
+    }
+#else
+    if (!haveGlob || !buf || buflen <= 0)
+    {
+        lastError = (!haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+    if (count >= iDirEntVec.size())
+    {
+        lastError = Oscl_FileFind::E_PATH_NOT_FOUND;
+        return NULL;
+    }
+    if (oscl_strlen(iDirEntVec[count].get_cstr()) > buflen)
+    {
+        lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+    }
+    else
+    {
+        oscl_strncpy(buf, iDirEntVec[count++].get_cstr(), buflen);
+        struct stat statbuf;
+        if (stat(buf, &statbuf) == 0)
+        {
+            type = (S_ISDIR(statbuf.st_mode)) ? DIR_TYPE : FILE_TYPE;
+        }
+        else
+        {
+            type = FILE_TYPE;
+        }
+        return buf;
+    }
+#endif
     return NULL;
 }
 
 OSCL_EXPORT_REF oscl_wchar *Oscl_FileFind::FindNext(oscl_wchar *buf, uint32 buflen)
 {
-    OSCL_UNUSED_ARG(buf);
-    OSCL_UNUSED_ARG(buflen);
+    lastError = Oscl_FileFind::E_OK;
+    type = Oscl_FileFind::INVALID_TYPE;
+#if   (OSCL_HAS_GLOB)
+    char utf8buf[OSCL_IO_FILENAME_MAXLEN];
+    char *retval;
+
+    if (!haveGlob || !buf || buflen <= 0)
+    {
+        lastError = (!haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+
+    retval = FindNext(utf8buf, OSCL_IO_FILENAME_MAXLEN);
+
+    if (retval != NULL)
+    {
+        if (0 == oscl_UTF8ToUnicode(retval, oscl_strlen(retval), buf, buflen) && oscl_strlen(retval))
+        {
+            lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+            return NULL;
+        }
+        return buf;
+    }
+#else
+    char utf8buf[OSCL_IO_FILENAME_MAXLEN];
+    char *retval;
+    if (!haveGlob || !buf || buflen <= 0)
+    {
+        lastError = (!haveGlob) ?
+                    Oscl_FileFind::E_INVALID_STATE :
+                    Oscl_FileFind::E_INVALID_ARG;
+        return NULL;
+    }
+    if (count >= iDirEntVec.size())
+    {
+        lastError = Oscl_FileFind::E_PATH_NOT_FOUND;
+        return NULL;
+    }
+    retval = FindNext(utf8buf, OSCL_IO_FILENAME_MAXLEN);
+
+    if (retval != NULL)
+    {
+        if (0 == oscl_UTF8ToUnicode(retval, oscl_strlen(retval), buf, buflen))
+        {
+            lastError = Oscl_FileFind::E_BUFFER_TOO_SMALL;
+            return NULL;
+        }
+        return buf;
+    }
+#endif
     return NULL;
 }
 
 OSCL_EXPORT_REF void Oscl_FileFind::Close()
 {
+#if   (OSCL_HAS_GLOB)
+    if (haveGlob)
+        globfree(&hFind);
+    haveGlob = false;
+    count = 0;
+    lastError = Oscl_FileFind::E_OK;
+#else
+    iDirEntVec.clear();
+    count = 0;
+    haveGlob = false;
+    lastError = Oscl_FileFind::E_OK;
+#endif
 }
 
 OSCL_EXPORT_REF Oscl_FileFind::element_type Oscl_FileFind::GetElementType()
@@ -89,4 +475,119 @@
     return lastError;
 }
 
+// globmatch matches pattern strings p from str, follows linux glob.c man spec.
+static bool oscl_strglob(const char *str, const char *p)
+{
+#define NEGATE	'^'			/* std cset negation char */
+    int negate;
+    int match;
+    int c;
+
+    while (*p)
+    {
+        if (!*str && *p != '*')
+            return false;
+
+        switch (c = *p++)
+        {
+
+            case '*':
+                while (*p == '*')
+                    p++;
+
+                if (!*p)
+                    return true;
+
+                if (*p != '?' && *p != '[' && *p != '\\')
+                    while (*str && *p != *str)
+                        str++;
+
+                while (*str)
+                {
+                    if (oscl_strglob(str, p))
+                        return true;
+                    str++;
+                }
+                return false;
+
+            case '?':
+                if (*str)
+                    break;
+                return false;
+                /*
+                 * set specification is inclusive, that is [a-z] is a, z and
+                 * everything in between. this means [z-a] may be interpreted
+                 * as a set that contains z, a and nothing in between.
+                 */
+            case '[':
+                if (*p != NEGATE)
+                    negate = false;
+                else
+                {
+                    negate = true;
+                    p++;
+                }
+
+                match = false;
+
+                while (!match && (c = *p++))
+                {
+                    if (!*p)
+                        return false;
+                    if (*p == '-')  	/* c-c */
+                    {
+                        if (!*++p)
+                            return false;
+                        if (*p != ']')
+                        {
+                            if (*str == c || *str == *p ||
+                                    (*str > c && *str < *p))
+                                match = true;
+                        }
+                        else  		/* c-] */
+                        {
+                            if (*str >= c)
+                                match = true;
+                            break;
+                        }
+                    }
+                    else  			/* cc or c] */
+                    {
+                        if (c == *str)
+                            match = true;
+                        if (*p != ']')
+                        {
+                            if (*p == *str)
+                                match = true;
+                        }
+                        else
+                            break;
+                    }
+                }
+
+                if (negate == match)
+                    return false;
+                /*
+                 * if there is a match, skip past the cset and continue on
+                 */
+                while (*p && *p != ']')
+                    p++;
+                if (!*p++)
+                    return false;
+                break;
+
+            case '\\':
+                if (*p)
+                    c = *p++;
+            default:
+                if (c != *str)
+                    return false;
+                break;
+
+        }
+        str++;
+    }
+
+    return !*str;
+}
 
diff --git a/oscl/oscl/osclio/src/oscl_file_find.h b/oscl/oscl/osclio/src/oscl_file_find.h
index ccdc050..94b84e5 100644
--- a/oscl/oscl/osclio/src/oscl_file_find.h
+++ b/oscl/oscl/osclio/src/oscl_file_find.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,6 +47,14 @@
 #ifndef OSCL_MEM_H_INCLUDED
 #include "oscl_mem.h"
 #endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
 /**
  * Oscl_FileFind class defines the generic way of finding filesystem elements that match a pattern  within a directory
  */
@@ -148,6 +156,15 @@
 
     private:
 
+#if   (OSCL_HAS_GLOB)
+        glob_t hFind;
+        size_t count;
+        bool haveGlob;
+#else
+        size_t count;
+        bool haveGlob;
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iDirEntVec;
+#endif
         error_type lastError;
         element_type type;
 
diff --git a/oscl/oscl/osclio/src/oscl_file_handle.h b/oscl/oscl/osclio/src/oscl_file_handle.h
index 106fc46..3c2fe53 100644
--- a/oscl/oscl/osclio/src/oscl_file_handle.h
+++ b/oscl/oscl/osclio/src/oscl_file_handle.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_io.cpp b/oscl/oscl/osclio/src/oscl_file_io.cpp
index a848aa6..81202a2 100644
--- a/oscl/oscl/osclio/src/oscl_file_io.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_io.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,13 +75,13 @@
 
     SetNativeAccessMode(ESymbianAccessMode_RfileBuf);
 
-#if defined(OSCL_FILE_BUFFER_MAX_SIZE)
+#if defined(OSCL_FILE_BUFFER_MAX_SIZE) 
     //native buffer size defaults to max buffer size
 
     SetNativeBufferSize(OSCL_FILE_BUFFER_MAX_SIZE);
 #endif
 
-#if defined(OSCL_ASYNC_READ_BUFFER_SIZE)
+#if defined(OSCL_ASYNC_READ_BUFFER_SIZE) 
     // enable async file read operation
 
     SetAsyncReadBufferSize(OSCL_ASYNC_READ_BUFFER_SIZE);
@@ -164,6 +164,7 @@
 {
     //just save the value now-- it will take effect on the next open.
     iAsyncReadBufferSize = aSize;
+
 }
 
 OSCL_EXPORT_REF void Oscl_File::SetLoggingEnable(bool aEnable)
@@ -335,12 +336,18 @@
                         (0, "Oscl_File(0x%x)::Open IN name '%s' mode %d serv 0x%x", this, str.get_cstr(), mode, &fileserv));
     }
 
+    int32 result = (-1);
+    // assertion on null file pointer
+    if (!filename)
+    {
+        OSCL_ASSERT(0);
+        return result;
+    }
+
     uint32 ticks = 0;
     if (iFileStats)
         iFileStats->Start(ticks);
 
-    int32 result = (-1);
-
     //protect against duplicate open calls
     if (iIsOpen)
         goto ErrorExit;
@@ -389,12 +396,18 @@
                         (0, "Oscl_File(0x%x)::Open IN name '%s' mode %d serv 0x%x", this, filename, mode, &fileserv));
     }
 
+    int32 result = (-1);
+    // assertion on null file pointer
+    if (!filename)
+    {
+        OSCL_ASSERT(0);
+        return result;
+    }
+
     uint32 ticks = 0;
     if (iFileStats)
         iFileStats->Start(ticks);
 
-    int32 result = (-1);
-
     //protect against duplicate open calls
     if (iIsOpen)
         goto ErrorExit;
@@ -628,38 +641,6 @@
     return result;
 }
 
-OSCL_EXPORT_REF int32 Oscl_File::SetSize(uint32 size)
-{
-    if (iLogger)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "Oscl_File(0x%x)::SetSize IN", this));
-    }
-
-    uint32 ticks = 0;
-    if (iFileStats)
-        iFileStats->Start(ticks);
-
-    int32 result = (-1);
-
-    if (iIsOpen)
-    {
-        result = CallNativeSetSize(size);
-    }
-
-    if (iFileStats
-            && result == 0)
-        iFileStats->End(EOsclFileOp_SetSize, ticks);
-
-    if (iLogger)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
-                        (0, "Oscl_File(0x%x)::SetSize OUT result %d", this, result));
-    }
-    return result;
-}
-
-
 OSCL_EXPORT_REF int32 Oscl_File::Flush()
 {
     if (iLogger)
@@ -1008,36 +989,6 @@
     return result;
 }
 
-int32  Oscl_File::CallNativeSetSize(uint32 size)
-{
-    if (iNativeLogger)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG,
-                        (0, "OsclNativeFile(0x%x)::SetSize IN", this));
-    }
-
-    uint32 ticks = 0;
-    if (iFileStats)
-        iFileStats->Start(ticks);
-
-    int32 result = (-1);
-
-    if (iNativeFile)
-        result = iNativeFile->SetSize(size);
-
-    if (iFileStats
-            && result == 0)
-        iFileStats->End(EOsclFileOp_NativeSetSize, ticks);
-
-    if (iNativeLogger)
-    {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iNativeLogger, PVLOGMSG_DEBUG,
-                        (0, "OsclNativeFile(0x%x)::SetSize OUT result %d", this, result));
-    }
-
-    return result;
-}
-
 
 int32  Oscl_File::CallNativeFlush()
 {
@@ -1178,3 +1129,20 @@
 
     return result;
 }
+
+OSCL_EXPORT_REF uint32 Oscl_File::GetAsyncFileNumOfRun()
+{
+    if (iAsyncFile)
+        return iAsyncFile->iNumOfRun;
+    else
+        return 0;
+}
+
+OSCL_EXPORT_REF uint32 Oscl_File::GetAsyncFileNumOfRunError()
+{
+    if (iAsyncFile)
+        return iAsyncFile->iNumOfRunErr;
+    else
+        return 0;
+}
+
diff --git a/oscl/oscl/osclio/src/oscl_file_io.h b/oscl/oscl/osclio/src/oscl_file_io.h
index 329fd0f..47679ac 100644
--- a/oscl/oscl/osclio/src/oscl_file_io.h
+++ b/oscl/oscl/osclio/src/oscl_file_io.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -332,17 +332,6 @@
          */
         OSCL_IMPORT_REF int32 Flush();
 
-        /**
-         * The File SetSize operation
-         * If the file has been opened for writing
-         * This sets the size of the file.  The file pointer position
-         * is unchanged unless the pointers position is greated than
-         * the new filesize.
-         *
-         * @return returns 0 if successful, and a non-zero value otherwise
-         */
-        OSCL_IMPORT_REF int32 SetSize(uint32 size);
-
 
         /**
          * The File EOF(end of file) operation
@@ -402,6 +391,8 @@
 
     private:
         friend class OsclFileCache;
+        friend class asyncfilereadwrite_test;
+        friend class asyncfilereadcancel_test;
 
         void Construct();
         void OldCacheDefaults();
@@ -455,7 +446,6 @@
         uint32 CallNativeRead(OsclAny *buffer, uint32 size, uint32 numelements);
         uint32 CallNativeWrite(const OsclAny *buffer, uint32 size, uint32 numelements);
         int32  CallNativeSeek(int32 offset, Oscl_File::seek_type origin);
-        int32  CallNativeSetSize(uint32 size);
         int32  CallNativeTell();
         int32  CallNativeFlush();
         int32  CallNativeEndOfFile();
@@ -463,6 +453,8 @@
         int32 CallNativeClose();
         uint32 CallNativeMode();
         int32 CallNativeGetError();
+        OSCL_IMPORT_REF uint32 GetAsyncFileNumOfRun();
+        OSCL_IMPORT_REF uint32 GetAsyncFileNumOfRunError();
 
 };
 
diff --git a/oscl/oscl/osclio/src/oscl_file_native.cpp b/oscl/oscl/osclio/src/oscl_file_native.cpp
index 7817c0a..bff9d3c 100644
--- a/oscl/oscl/osclio/src/oscl_file_native.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_native.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,17 +24,12 @@
 #include "oscl_utf8conv.h"
 #include "oscl_int64_utils.h"
 
-#ifdef ENABLE_MEMORY_PLAYBACK
-#undef LOG_TAG
-#define LOG_TAG "OsclNativeFile"
-#include <utils/Log.h>
-#endif
 #include "oscl_mem.h"
 #include "oscl_file_types.h"
 #include "oscl_file_handle.h"
 
 
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
 pthread_key_t osclfilenativesigbuskey;
 
 /*
@@ -72,7 +67,6 @@
 
     if (existinghandler == NULL || handler == NULL)
 {
-        LOGE("logic error");
         return;
     }
 
@@ -112,7 +106,6 @@
         }
         h = h->next;
     }
-    LOGE("couldn't find handler for address %p\n", faultaddr);
     return NULL;
 }
 #endif // ENABLE_MEMORY_PLAYBACK
@@ -123,7 +116,7 @@
     iMode = 0;
 
     iFile = 0;
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
     membase = NULL;
 #endif
 
@@ -164,6 +157,8 @@
         OSCL_UNUSED_ARG(fileserv);
         OSCL_UNUSED_ARG(params);
 
+        if (*filename == '\0') return -1; // Null string not supported in fopen, error out
+
         char openmode[4];
         uint32 index = 0;
 
@@ -226,7 +221,7 @@
         {
             return -1;
         }
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
         void* base;
         long long offset;
         long long len;
@@ -270,6 +265,8 @@
         OSCL_UNUSED_ARG(fileserv);
         OSCL_UNUSED_ARG(params);
 
+        if (*filename == '\0') return -1; // Null string not supported in fopen, error out
+
         char openmode[4];
         uint32 index = 0;
 
@@ -312,7 +309,7 @@
         }
 
         openmode[index++] = '\0';
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
         void* base;
         long long offset;
         long long len;
@@ -375,7 +372,7 @@
             closeret = fclose(iFile);
             iFile = NULL;
         }
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
         else if (membase != NULL)
         {
             membase = NULL;
@@ -392,16 +389,14 @@
     return closeret;
 }
 
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
 int OsclNativeFile::sigbushandlerfunc(siginfo_t *info, struct mediasigbushandler *data)
 {
     char *faultaddr = (char*) info->si_addr;
-    LOGE("read fault at %p\n", faultaddr);
 
     struct mediasigbushandler *h = getspecificforfaultaddr(faultaddr);
     if (h == NULL)
     {
-        LOGE("No handler for fault range.");
         return -1;
     }
     else
@@ -415,7 +410,6 @@
         void * bar = mmap(pageaddr, pagesize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0);
         if (bar == MAP_FAILED)
         {
-            LOGE("couldn't map zero page at %p: %s", pageaddr, strerror(errno));
             return -1;
         }
     }
@@ -425,7 +419,7 @@
 
 uint32 OsclNativeFile::Read(OsclAny *buffer, uint32 size, uint32 numelements)
 {
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
     if (membase)
     {
         int req = size * numelements;
@@ -438,7 +432,6 @@
         memcpy(buffer, ((char*)membase) + memoffset + mempos, req);
         if (memcpyfailed)
         {
-            LOGE("got bus error while reading");
             return 0;
         }
         mempos += req;
@@ -466,6 +459,10 @@
     return -1;//not supported
 }
 
+void OsclNativeFile::ReadAsyncCancel()
+{
+}
+
 uint32 OsclNativeFile::GetReadAsyncNumElements()
 {
     return 0;//not supported
@@ -475,7 +472,7 @@
 
 uint32 OsclNativeFile::Write(const OsclAny *buffer, uint32 size, uint32 numelements)
 {
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
     if (membase)
         return 0;
 #endif
@@ -490,13 +487,16 @@
 {
 
     {
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
         if (membase)
         {
             int newpos = mempos;
-            if (origin == Oscl_File::SEEKCUR) newpos = mempos + offset;
-            else if (origin == Oscl_File::SEEKSET) newpos = offset;
-            else if (origin == Oscl_File::SEEKEND) newpos = memlen + offset;
+            if (origin == Oscl_File::SEEKCUR)
+                newpos = mempos + offset;
+            else if (origin == Oscl_File::SEEKSET)
+                newpos = offset;
+            else if (origin == Oscl_File::SEEKEND)
+                newpos = memlen + offset;
             if (newpos < 0)
                 return EINVAL;
             if (newpos > memlen) // is this valid?
@@ -509,9 +509,12 @@
         {
             int32 seekmode = SEEK_CUR;
 
-            if	(origin == Oscl_File::SEEKCUR) seekmode = SEEK_CUR;
-            else if (origin == Oscl_File::SEEKSET) seekmode = SEEK_SET;
-            else if (origin == Oscl_File::SEEKEND) seekmode = SEEK_END;
+            if (origin == Oscl_File::SEEKCUR)
+                seekmode = SEEK_CUR;
+            else if (origin == Oscl_File::SEEKSET)
+                seekmode = SEEK_SET;
+            else if (origin == Oscl_File::SEEKEND)
+                seekmode = SEEK_END;
 
             return fseek(iFile, offset, seekmode);
         }
@@ -519,22 +522,21 @@
     return -1;
 }
 
-int32 OsclNativeFile::SetSize(uint32 size)
-{
-    OSCL_UNUSED_ARG(size);
-    return -1;
-}
-
 
 int32 OsclNativeFile::Tell()
 {
-#ifdef ENABLE_MEMORY_PLAYBACK
+    int32 result = -1;
+#if ENABLE_MEMORY_PLAYBACK
     if (membase)
-        return mempos;
+    {
+        result = mempos;
+    }
 #endif
     if (iFile)
-        return ftell(iFile);
-    return -1;
+    {
+        result = ftell(iFile);
+    }
+    return result;
 }
 
 
@@ -542,7 +544,7 @@
 int32 OsclNativeFile::Flush()
 {
 
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
     if (membase)
         return 0;
 #endif
@@ -556,7 +558,7 @@
 int32 OsclNativeFile::EndOfFile()
 {
 
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
     if (membase)
         return mempos >= memlen;
 #endif
@@ -568,7 +570,7 @@
 
 int32 OsclNativeFile::GetError()
 {
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
     if (membase)
         return 0;
 #endif
diff --git a/oscl/oscl/osclio/src/oscl_file_native.h b/oscl/oscl/osclio/src/oscl_file_native.h
index b1ca763..cc9d482 100644
--- a/oscl/oscl/osclio/src/oscl_file_native.h
+++ b/oscl/oscl/osclio/src/oscl_file_native.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,9 +56,6 @@
 #include "oscl_file_types.h"
 #endif
 
-#ifdef ENABLE_MEMORY_PLAYBACK
-#include <media/MediaPlayerInterface.h>
-#endif
 
 /**
  * OsclNativeFileIO defines the native file operations that must be implemented
@@ -90,7 +87,6 @@
         int32  EndOfFile();
         int32 Size();
         int32 Close();
-        int32 SetSize(uint32 size);
 
         //query for current open mode.
         uint32 Mode()
@@ -120,6 +116,10 @@
         ** @returns: true if async read is supported natively.
         **/
         bool HasAsyncRead();
+        /*!
+        ** Cancel any pending async read.
+        **/
+        void ReadAsyncCancel();
 
     private:
 
@@ -131,7 +131,7 @@
 
         //native file object.
         FILE* iFile;
-#ifdef ENABLE_MEMORY_PLAYBACK
+#if ENABLE_MEMORY_PLAYBACK
         static int sigbushandlerfunc(siginfo_t *, struct mediasigbushandler *);
         // memory block
         void* membase;
diff --git a/oscl/oscl/osclio/src/oscl_file_server.cpp b/oscl/oscl/osclio/src/oscl_file_server.cpp
index 9d4b0ea..6c89813 100644
--- a/oscl/oscl/osclio/src/oscl_file_server.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_server.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_server.h b/oscl/oscl/osclio/src/oscl_file_server.h
index 069a5a0..801679a 100644
--- a/oscl/oscl/osclio/src/oscl_file_server.h
+++ b/oscl/oscl/osclio/src/oscl_file_server.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_stats.cpp b/oscl/oscl/osclio/src/oscl_file_stats.cpp
index 02e526a..9f9030d 100644
--- a/oscl/oscl/osclio/src/oscl_file_stats.cpp
+++ b/oscl/oscl/osclio/src/oscl_file_stats.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_file_stats.h b/oscl/oscl/osclio/src/oscl_file_stats.h
index 50209fd..ceaaa0c 100644
--- a/oscl/oscl/osclio/src/oscl_file_stats.h
+++ b/oscl/oscl/osclio/src/oscl_file_stats.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,7 +61,6 @@
     , EOsclFileOp_Size
     , EOsclFileOp_Flush
     , EOsclFileOp_EndOfFile
-    , EOsclFileOp_SetSize
     , EOsclFileOp_NativeOpen
     , EOsclFileOp_NativeClose
     , EOsclFileOp_NativeRead
@@ -71,7 +70,6 @@
     , EOsclFileOp_NativeSize
     , EOsclFileOp_NativeFlush
     , EOsclFileOp_NativeEndOfFile
-    , EOsclFileOp_NativeSetSize
     , EOsclFileOp_Last
 };
 static const char* const TOsclFileOpStr[] =
diff --git a/oscl/oscl/osclio/src/oscl_file_types.h b/oscl/oscl/osclio/src/oscl_file_types.h
index 07417c7..a7c172d 100644
--- a/oscl/oscl/osclio/src/oscl_file_types.h
+++ b/oscl/oscl/osclio/src/oscl_file_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_ip_socket.cpp b/oscl/oscl/osclio/src/oscl_ip_socket.cpp
index 9f14e19..d1e48df 100644
--- a/oscl/oscl/osclio/src/oscl_ip_socket.cpp
+++ b/oscl/oscl/osclio/src/oscl_ip_socket.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,6 +61,16 @@
     }
 }
 
+int32 OsclIPSocketI::SetRecvBufferSize(uint32 size)
+{
+    if (iSocket)
+    {
+        return iSocket->SetRecvBufferSize(size);
+    }
+    return OsclErrGeneral;
+}
+
+
 
 
 
diff --git a/oscl/oscl/osclio/src/oscl_ip_socket.h b/oscl/oscl/osclio/src/oscl_ip_socket.h
index 32a39c1..7ac7225 100644
--- a/oscl/oscl/osclio/src/oscl_ip_socket.h
+++ b/oscl/oscl/osclio/src/oscl_ip_socket.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@
         //Synchronous methods.
         int32 Bind(OsclNetworkAddress& aAddress);
         int32 Join(OsclNetworkAddress& aAddress);
+        int32 SetRecvBufferSize(uint32 size);
         virtual int32 Close() = 0;
         virtual uint8 *GetRecvData(int32 *aLength) = 0;
         virtual uint8 *GetSendData(int32 *aLength) = 0;
@@ -78,3 +79,4 @@
 
 #endif
 
+
diff --git a/oscl/oscl/osclio/src/oscl_socket.cpp b/oscl/oscl/osclio/src/oscl_socket.cpp
index a92a57d..1cbc765 100644
--- a/oscl/oscl/osclio/src/oscl_socket.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -145,6 +145,11 @@
     iUDPSocket->CancelRecvFrom();
 }
 
+OSCL_EXPORT_REF int32 OsclUDPSocket::SetRecvBufferSize(uint32 size)
+{
+    return iUDPSocket->SetRecvBufferSize(size);
+}
+
 OSCL_EXPORT_REF OsclTCPSocket *OsclTCPSocket::NewL(Oscl_DefAlloc &alloc,
         OsclSocketServ& aServ,
         OsclSocketObserver *aObserver,
@@ -296,3 +301,4 @@
 
 
 
+
diff --git a/oscl/oscl/osclio/src/oscl_socket.h b/oscl/oscl/osclio/src/oscl_socket.h
index 7d06fc2..1940187 100644
--- a/oscl/oscl/osclio/src/oscl_socket.h
+++ b/oscl/oscl/osclio/src/oscl_socket.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@
 */
 class OsclSocketServI;
 
-class OsclSocketServ : public OsclHeapBase
+class OsclSocketServ : public HeapBase
 {
     public:
         /**
@@ -121,7 +121,7 @@
 * The UDP Socket class
 */
 
-class OsclUDPSocket : public OsclHeapBase
+class OsclUDPSocket : public HeapBase
 {
     public:
         /**
@@ -179,6 +179,7 @@
          * @param aAddress: Bind address.
          * @return Returns OsclErrNone for success, or a
          *   platform-specific error code.
+         * May throw an OsclErrNotSupported Exception
         */
         OSCL_IMPORT_REF int32 Join(OsclNetworkAddress& aAddress);
 
@@ -303,6 +304,17 @@
         */
         OSCL_IMPORT_REF void CancelRecvFrom();
 
+        /**
+         * Set the buffer size of the socket
+         * This is a synchronous method.
+         * @param size: buffer size
+         * @return Returns OsclErrNone for success, or a
+         *   platform-specific error code.
+         * May throw an OsclErrNotSupported Exception.
+        */
+
+        OSCL_IMPORT_REF int32 SetRecvBufferSize(uint32 size);
+
     private:
         OsclUDPSocket(Oscl_DefAlloc &alloc): iUDPSocket(NULL), iAlloc(alloc) {}
         OsclUDPSocketI *iUDPSocket;
@@ -315,7 +327,7 @@
 * The TCP Socket class
 */
 
-class OsclTCPSocket : public OsclHeapBase
+class OsclTCPSocket : public HeapBase
 {
     public:
         /**
@@ -604,3 +616,4 @@
 
 #endif
 
+
diff --git a/oscl/oscl/osclio/src/oscl_socket_accept.cpp b/oscl/oscl/osclio/src/oscl_socket_accept.cpp
index 369db42..f2d6ba5 100644
--- a/oscl/oscl/osclio/src/oscl_socket_accept.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_accept.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_accept.h b/oscl/oscl/osclio/src/oscl_socket_accept.h
index ece47e4..dafa5b9 100644
--- a/oscl/oscl/osclio/src/oscl_socket_accept.h
+++ b/oscl/oscl/osclio/src/oscl_socket_accept.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_bind.cpp b/oscl/oscl/osclio/src/oscl_socket_bind.cpp
index c1bf0ab..72ebb0f 100644
--- a/oscl/oscl/osclio/src/oscl_socket_bind.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_bind.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_bind.h b/oscl/oscl/osclio/src/oscl_socket_bind.h
index 44bf4c2..e9479c0 100644
--- a/oscl/oscl/osclio/src/oscl_socket_bind.h
+++ b/oscl/oscl/osclio/src/oscl_socket_bind.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_connect.cpp b/oscl/oscl/osclio/src/oscl_socket_connect.cpp
index e7f09ca..1fc7f02 100644
--- a/oscl/oscl/osclio/src/oscl_socket_connect.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_connect.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_connect.h b/oscl/oscl/osclio/src/oscl_socket_connect.h
index ef2354b..0ab54a9 100644
--- a/oscl/oscl/osclio/src/oscl_socket_connect.h
+++ b/oscl/oscl/osclio/src/oscl_socket_connect.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_imp.h b/oscl/oscl/osclio/src/oscl_socket_imp.h
index fbe16e3..43c2158 100644
--- a/oscl/oscl/osclio/src/oscl_socket_imp.h
+++ b/oscl/oscl/osclio/src/oscl_socket_imp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp b/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp
index 2633ac7..a8f5e05 100644
--- a/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_imp_base.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_imp_base.h b/oscl/oscl/osclio/src/oscl_socket_imp_base.h
index 9f01202..4066242 100644
--- a/oscl/oscl/osclio/src/oscl_socket_imp_base.h
+++ b/oscl/oscl/osclio/src/oscl_socket_imp_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp b/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp
index 56aa9f1..e2ec86a 100644
--- a/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_imp_pv.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -122,7 +122,8 @@
     return OsclErrNone;
 #else
     OSCL_UNUSED_ARG(anAddr);
-    return PVSOCK_ERR_NOT_IMPLEMENTED;
+    OSCL_LEAVE(OsclErrNotSupported);
+    return 0;
 #endif
 }
 
@@ -147,6 +148,22 @@
 #endif
 }
 
+int32 OsclSocketI::SetRecvBufferSize(uint32 size)
+{
+#ifdef OsclSetRecvBufferSize
+    int err;
+    int ok;
+    OsclSetRecvBufferSize(iSocket, size, ok, err);
+    if (!ok)
+        return err;
+    return OsclErrNone;
+#else
+    OSCL_UNUSED_ARG(size);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return 0;
+#endif
+}
+
 inline void OsclSocketI::Send(SendParam &param, OsclSocketRequestAO& ao)
 {
     if (!IsReady(ao))
@@ -411,3 +428,4 @@
 
 
 
+
diff --git a/oscl/oscl/osclio/src/oscl_socket_imp_pv.h b/oscl/oscl/osclio/src/oscl_socket_imp_pv.h
index baa8936..453b687 100644
--- a/oscl/oscl/osclio/src/oscl_socket_imp_pv.h
+++ b/oscl/oscl/osclio/src/oscl_socket_imp_pv.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,6 +56,7 @@
         int32 Join(OsclNetworkAddress& anAddr);
         int32 Close();
         int32 Listen(uint32 qSize);
+        int32 SetRecvBufferSize(uint32 size);
 
         //asynchronous methods.
 
@@ -106,7 +107,6 @@
         static bool MakeAddr(OsclNetworkAddress& in, TOsclSockAddr& addr);
         static void MakeAddr(TOsclSockAddr& in, OsclNetworkAddress& addr);
 
-#ifdef OsclSocketSelect
         //routines to handle each type of socket request under the
         //server thread.
         void ProcessConnect(OsclSocketServRequestQElem*);
@@ -116,7 +116,6 @@
         void ProcessRecvFrom(OsclSocketServRequestQElem*);
         void ProcessSend(OsclSocketServRequestQElem*);
         void ProcessRecv(OsclSocketServRequestQElem*);
-#endif //osclsocketselect
 
     private:
         bool iSocketValid;
@@ -160,3 +159,4 @@
 
 
 
+
diff --git a/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp b/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp
index fc3f63c..783409c 100644
--- a/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_imp_serv.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,16 +66,16 @@
  */
 void OsclSocketI::ProcessConnect(OsclSocketServRequestQElem* aElem)
 {
-    bool select = false;
+    bool iscomplete = false;
     int sockerr = 0;
     int32 complete = 0;
     OsclSocketRequest *req = aElem->iSocketRequest;
-    ConnectParam *param = (ConnectParam*)req->iParam;
-    if (param->iConnecting)
+    if (aElem->iSelect)
     {
         //check for completion by examining
         //writeset and exceptset
         bool ok, success, fail;
+#if (PV_SOCKET_SERVER_SELECT)
         OsclConnectComplete(iSocket,
                             iSocketServ->iWriteset,
                             iSocketServ->iExceptset,
@@ -83,6 +83,45 @@
                             fail,
                             ok,
                             sockerr);
+#else
+        //since there was no select call we have to do it now.
+        fd_set readset, writeset, exceptset;
+        FD_ZERO(&writeset);
+        FD_ZERO(&readset);
+        FD_ZERO(&exceptset);
+        FD_SET(iSocket, &writeset);
+        FD_SET(iSocket, &exceptset);
+        timeval timeout;
+        timeout.tv_sec = 0;
+        timeout.tv_usec = 0;
+        int nfds = iSocket + 1;
+        int serverr;
+        int nhandles;
+        OsclSocketSelect(nfds, readset, writeset, exceptset, timeout, ok, serverr, nhandles);
+        if (!ok)
+        {
+            //select failed.
+            sockerr = serverr;
+            complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
+        }
+        else if (!nhandles)
+        {
+            //keep waiting.
+            success = fail = false;
+        }
+        else
+        {
+            //examine results
+            OsclConnectComplete(iSocket,
+                                writeset,
+                                exceptset,
+                                success,
+                                fail,
+                                ok,
+                                sockerr);
+        }
+#endif
 
         if (success)
         {
@@ -91,6 +130,7 @@
 
             iSocketConnected = true;
             complete = OSCL_REQUEST_ERR_NONE;
+            iscomplete = true;
         }
         else if (fail)
         {
@@ -98,17 +138,18 @@
             ADD_STATS(req->iParam->iFxn, EOsclSocket_Except);
 
             complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
         }
         else
         {
             //keep waiting
-            select = true;
             ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
         }
     }
     else
     {
         //Start connecting
+        ConnectParam *param = (ConnectParam*)req->iParam;
         TOsclSockAddr addr;
         MakeAddr(param->iAddr, addr);
         bool ok, wouldblock;
@@ -120,13 +161,13 @@
             {
                 //we expect a non-blocking socket to return an error...
                 //start monitoring the writeset and exceptset.
-                param->iConnecting = true;
-                select = true;
+                aElem->iSelect = (OSCL_WRITESET_FLAG | OSCL_EXCEPTSET_FLAG);
             }
             else
             {
                 //connect error.
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
             }
         }
         else
@@ -134,15 +175,15 @@
             //Finished.
             iSocketConnected = true;
             complete = OSCL_REQUEST_ERR_NONE;
+            iscomplete = true;
         }
     }
 
     //either keep monitoring activity, or complete the request.
-    if (select)
+    if (!iscomplete)
     {
         LOGSERV((0, "OsclSocketI::ProcessConnect (0x%x) select=true", this));
-        // Set the write and except bits to notify the caller
-        aElem->iSelect |= (OSCL_WRITESET_FLAG | OSCL_EXCEPTSET_FLAG);
+        OSCL_ASSERT(aElem->iSelect);//should have bits set.
     }
     else
     {
@@ -199,17 +240,27 @@
  */
 void OsclSocketI::ProcessAccept(OsclSocketServRequestQElem* aElem)
 {
-    bool select = false;
+    bool iscomplete = false;
     int sockerr = 0;
     int32 complete = 0;
     OsclSocketRequest *req = aElem->iSocketRequest;
-    AcceptParam* param = (AcceptParam*)req->iParam;
-    if (!param->iBlankSocket)
+    if (!aElem->iSelect)
     {
-        //bad request.
-        complete = OSCL_REQUEST_ERR_GENERAL;
-        sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
+        //start monitoring.
+        AcceptParam* param = (AcceptParam*)req->iParam;
+        if (!param->iBlankSocket)
+        {
+            //bad request.
+            complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
+            sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
+        }
+        else
+        {
+            aElem->iSelect = (OSCL_READSET_FLAG | OSCL_EXCEPTSET_FLAG);
+        }
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else if (FD_ISSET(iSocket, &iSocketServ->iExceptset))
     {
         ADD_STATS(req->iParam->iFxn, EOsclSocket_Except);
@@ -217,20 +268,39 @@
         bool ok;
         OsclGetAsyncSockErr(iSocket, ok, sockerr);
         complete = OSCL_REQUEST_ERR_GENERAL;
+        iscomplete = true;
     }
     else if (FD_ISSET(iSocket, &iSocketServ->iReadset))
     {
         //socket is readable, we can do an accept call now.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_Readable);
-
+#else
+    {
+        //try the accept.
+#endif
         TOsclSocket acceptsock;
-        bool ok;
+        bool ok, wouldblock;
         ADD_STATS(req->iParam->iFxn, EOsclSocket_OS);
-        OsclAccept(iSocket, acceptsock, ok, sockerr);
+        OsclAccept(iSocket, acceptsock, ok, sockerr, wouldblock);
         if (!ok)
         {
-            //accept error
-            complete = OSCL_REQUEST_ERR_GENERAL;
+            if (wouldblock)
+            {
+#if (PV_SOCKET_SERVER_SELECT)
+                //we don't expect wouldblock when socket is readable.
+                complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
+#else
+                //keep waiting for socket to be readable.
+                ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
+#endif
+            }
+            else
+            {
+                //accept error
+                complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
+            }
         }
         else
         {
@@ -240,32 +310,35 @@
             {
                 OsclCloseSocket(acceptsock, ok, sockerr);
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
             }
             else
             {
                 //Save the accept socket in the blank socket that was provided
                 //in the Accept command.
+                AcceptParam* param = (AcceptParam*)req->iParam;
                 param->iBlankSocket->iSocket = acceptsock;
                 //the blank socket is now valid and connected.
                 param->iBlankSocket->InitSocket(true);
                 param->iBlankSocket->iSocketConnected = true;
                 complete = OSCL_REQUEST_ERR_NONE;
+                iscomplete = true;
             }
         }
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else
     {
         //keep waiting for socket to be readable.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
-        select = true;
     }
+#endif
 
     //either keep monitoring activity, or complete the request.
-    if (select)
+    if (!iscomplete)
     {
         LOGSERV((0, "OsclSocketI::ProcessAccept (0x%x) select=true", this));
-        // Set the read and except bits to notify the caller
-        aElem->iSelect |= (OSCL_READSET_FLAG | OSCL_EXCEPTSET_FLAG);
+        OSCL_ASSERT(aElem->iSelect);
     }
     else
     {
@@ -286,30 +359,37 @@
  */
 void OsclSocketI::ProcessSend(OsclSocketServRequestQElem* aElem)
 {
-    bool select = false;
+    bool iscomplete = false;
     int32 complete = 0;
     int sockerr = 0;
     OsclSocketRequest *req = aElem->iSocketRequest;
-    SendParam *param = (SendParam*)req->iParam;
-    if (!param->iBufSend.iPtr)
+    if (!aElem->iSelect)
     {
-        //bad request
-        complete = OSCL_REQUEST_ERR_GENERAL;
-        sockerr = PVSOCK_ERR_BAD_PARAM;
+        //start monitoring.
+        //don't monitor exceptset b/c windows reports some false errors.
+        SendParam *param = (SendParam*)req->iParam;
+        if (!param->iBufSend.iPtr)
+        {
+            //bad request
+            complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
+            sockerr = PVSOCK_ERR_BAD_PARAM;
+        }
+        else
+        {
+            aElem->iSelect = (OSCL_WRITESET_FLAG);
+        }
     }
-    else if (FD_ISSET(iSocket, &iSocketServ->iExceptset))
-    {
-        ADD_STATS(req->iParam->iFxn, EOsclSocket_Except);
-
-        bool ok;
-        OsclGetAsyncSockErr(iSocket, ok, sockerr);
-        complete = OSCL_REQUEST_ERR_GENERAL;
-    }
+#if (PV_SOCKET_SERVER_SELECT)
     else if (FD_ISSET(iSocket, &iSocketServ->iWriteset))
     {
         //socket is writable, send data
         ADD_STATS(req->iParam->iFxn, EOsclSocket_Writable);
-
+#else
+    {
+        //go ahead and try to send
+#endif
+        SendParam *param = (SendParam*)req->iParam;
         int nbytes;
         bool ok, wouldblock;
         ADD_STATS(req->iParam->iFxn, EOsclSocket_OS);
@@ -328,12 +408,13 @@
             {
                 //non-blocking sockets return this when there's no receiver.
                 //just keep waiting.
-                select = true;
+                ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
             }
             else
             {
                 //send error
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
             }
         }
         else
@@ -348,33 +429,35 @@
             {
                 //all data sent.
                 complete = OSCL_REQUEST_ERR_NONE;
+                iscomplete = true;
             }
             else if (nbytes == 0)
             {
                 //connection closed
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
                 //(sockerr will be zero in this case.)
             }
             else
             {
                 //keep sending data.
-                select = true;
+                ;
             }
         }
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else
     {
         //keep waiting for socket to be writable.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
-        select = true;
     }
+#endif
 
     //either keep monitoring activity, or complete the request.
-    if (select)
+    if (!iscomplete)
     {
         LOGSERV((0, "OsclSocketI::ProcessSend (0x%x) select=true", this));
-        // Set the write and except bits to notify the caller
-        aElem->iSelect |= (OSCL_WRITESET_FLAG | OSCL_EXCEPTSET_FLAG);
+        OSCL_ASSERT(aElem->iSelect);
     }
     else
     {
@@ -395,39 +478,37 @@
  */
 void OsclSocketI::ProcessSendTo(OsclSocketServRequestQElem* aElem)
 {
-    bool select = false;
+    bool iscomplete = false;
     int32 complete = 0;
     int sockerr = 0;
     OsclSocketRequest *req = aElem->iSocketRequest;
-    SendToParam *param = (SendToParam*)req->iParam;
-    if (!param->iBufSend.iPtr)
+    if (!aElem->iSelect)
     {
-        //bad request
-        complete = OSCL_REQUEST_ERR_GENERAL;
-        sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
-    }
-    else if (FD_ISSET(iSocket, &iSocketServ->iExceptset))
-    {
-        bool ok;
-        int sockerr;
-        OsclGetAsyncSockErr(iSocket, ok, sockerr);
-        if (ok)
+        //start monitoring.  don't monitor exceptset b/c windows reports some false errors.
+        SendToParam *param = (SendToParam*)req->iParam;
+        if (!param->iBufSend.iPtr)
         {
-            ADD_STATSP(req->iParam->iFxn, EOsclSocket_Except, sockerr);
+            //bad request
+            complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
+            sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
         }
         else
         {
-            ADD_STATS(req->iParam->iFxn, EOsclSocket_Except);
+            aElem->iSelect = (OSCL_WRITESET_FLAG);
         }
-        //Note: Windows reports some false errors here, so
-        //any exceptset flags are ignored.
-        select = true;
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else if (FD_ISSET(iSocket, &iSocketServ->iWriteset))
     {
         //socket is writable, send data
         ADD_STATS(req->iParam->iFxn, EOsclSocket_Writable);
+#else
+    {
+        //go ahead and try to send
+#endif
 
+        SendToParam *param = (SendToParam*)req->iParam;
         int nbytes;
         bool wouldblock, ok;
         TOsclSockAddr toaddr;
@@ -448,12 +529,13 @@
             {
                 //nonblocking socket returns this error
                 //just keep waiting
-                select = true;
+                ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
             }
             else
             {
                 //sendto error
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
             }
         }
         else
@@ -468,33 +550,35 @@
             {
                 //all data sent.
                 complete = OSCL_REQUEST_ERR_NONE;
+                iscomplete = true;
             }
             else if (nbytes == 0)
             {
                 //connection closed
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
                 //(sockerr will be zero in this case)
             }
             else
             {
                 //keep sending data.
-                select = true;
+                ;
             }
         }
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else
     {
         //keep waiting for socket to be writable.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
-        select = true;
     }
+#endif
 
     //either keep monitoring activity, or complete the request.
-    if (select)
+    if (!iscomplete)
     {
         LOGSERV((0, "OsclSocketI::ProcessSendTo (0x%x) select=true", this));
-        // Set the write and except bits to notify the caller
-        aElem->iSelect |= (OSCL_WRITESET_FLAG | OSCL_EXCEPTSET_FLAG);
+        OSCL_ASSERT(aElem->iSelect);
     }
     else
     {
@@ -515,39 +599,36 @@
  */
 void OsclSocketI::ProcessRecv(OsclSocketServRequestQElem* aElem)
 {
-    bool select = false;
+    bool iscomplete = false;
     int sockerr = 0;
     int32 complete = 0;
     OsclSocketRequest *req = aElem->iSocketRequest;
-    RecvParam* param = (RecvParam*)req->iParam;
-    if (!param->iBufRecv.iPtr)
+    if (!aElem->iSelect)
     {
-        //bad request.
-        complete = OSCL_REQUEST_ERR_GENERAL;
-        sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
-    }
-    else if (FD_ISSET(iSocket, &iSocketServ->iExceptset))
-    {
-        bool ok;
-        int sockerr;
-        OsclGetAsyncSockErr(iSocket, ok, sockerr);
-        if (ok)
+        //start monitoring.  don't monitor exceptset b/c windows reports some false errors.
+        RecvParam* param = (RecvParam*)req->iParam;
+        if (!param->iBufRecv.iPtr)
         {
-            ADD_STATSP(req->iParam->iFxn, EOsclSocket_Except, sockerr);
+            //bad request.
+            complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
+            sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
         }
         else
         {
-            ADD_STATS(req->iParam->iFxn, EOsclSocket_Except);
+            aElem->iSelect = (OSCL_READSET_FLAG);
         }
-        //Note: Windows reports some false errors here, so
-        //any exceptset flags are ignored.
-        select = true;
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else if (FD_ISSET(iSocket, &iSocketServ->iReadset))
     {
         //socket is readable, get data.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_Readable);
-
+#else
+    {
+        //try to read
+#endif
+        RecvParam* param = (RecvParam*)req->iParam;
         int nbytes;
         bool ok, wouldblock;
         ADD_STATS(req->iParam->iFxn, EOsclSocket_OS);
@@ -567,12 +648,13 @@
                 //nonblocking sockets return this when there's no
                 //data.
                 //keep waiting for data.
-                select = true;
+                ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
             }
             else
             {
                 //recv error
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
             }
         }
         else if (nbytes > 0)
@@ -583,27 +665,29 @@
             param->iBufRecv.iLen += nbytes;
 
             complete = OSCL_REQUEST_ERR_NONE;
+            iscomplete = true;
         }
         else
         {
             //this usually means connection was closed.
             complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
             //(sockerr will be zero in this case)
         }
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else
     {
         //keep waiting for socket to be readable.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
-        select = true;
     }
+#endif
 
     //either keep monitoring activity, or complete the request.
-    if (select)
+    if (!iscomplete)
     {
         LOGSERV((0, "OsclSocketI::ProcessRecv (0x%x) select=true", this));
-        // Set the read and except bits to notify the caller
-        aElem->iSelect |= (OSCL_READSET_FLAG | OSCL_EXCEPTSET_FLAG);
+        OSCL_ASSERT(aElem->iSelect);
     }
     else
     {
@@ -624,45 +708,46 @@
  */
 void OsclSocketI::ProcessRecvFrom(OsclSocketServRequestQElem* aElem)
 {
-    bool select = false;
+    bool iscomplete = false;
     int sockerr = 0;
     int32 complete = 0;
     OsclSocketRequest *req = aElem->iSocketRequest;
-    RecvFromParam* param = (RecvFromParam*)req->iParam;
-    if (!param->iBufRecv.iPtr)
+    if (!aElem->iSelect)
     {
-        //bad request.
-        complete = OSCL_REQUEST_ERR_GENERAL;
-        sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
-    }
-    else if (FD_ISSET(iSocket, &iSocketServ->iExceptset))
-    {
-        bool ok;
-        int sockerr;
-        OsclGetAsyncSockErr(iSocket, ok, sockerr);
-        if (ok)
+        //start monitoring.  don't monitor exceptset b/c windows reports some false errors.
+        RecvFromParam* param = (RecvFromParam*)req->iParam;
+        if (!param->iBufRecv.iPtr)
         {
-            ADD_STATSP(req->iParam->iFxn, EOsclSocket_Except, sockerr);
+            //bad request.
+            complete = OSCL_REQUEST_ERR_GENERAL;
+            iscomplete = true;
+            sockerr = PVSOCK_ERR_BAD_PARAM;//unexpected
         }
         else
         {
-            ADD_STATS(req->iParam->iFxn, EOsclSocket_Except);
+            aElem->iSelect = (OSCL_READSET_FLAG);
         }
-        //Note: Windows reports some false errors here, so
-        //any exceptset flags are ignored.
-        select = true;
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else if (FD_ISSET(iSocket, &iSocketServ->iReadset))
     {
         //socket is readable, get data.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_Readable);
+#else
+    {
+        //try the read
+#endif
 
+        //we loop through multiple "recvfrom" calls and stop when
+        //either a byte limit is reached or else no more data is available
+        //without waiting.
         bool loop;
         uint32 loopcount;
         for (loop = true, loopcount = 0;loop;loopcount++)
         {
             loop = false;
 
+            RecvFromParam* param = (RecvFromParam*)req->iParam;
             int nbytes;
             bool ok, wouldblock;
             TOsclSockAddr sourceaddr;
@@ -688,19 +773,20 @@
                     if (loopcount == 0)
                     {
                         //keep waiting for data.
-                        select = true;
+                        ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
                     }
                     else
                     {
-                        //if we already got some data, we don't
-                        //wait for more, even in multi-recv mode.
+                        //if we already got some data, don't wait for more.
                         complete = OSCL_REQUEST_ERR_NONE;
+                        iscomplete = true;
                     }
                 }
                 else
                 {
                     //recvfrom error
                     complete = OSCL_REQUEST_ERR_GENERAL;
+                    iscomplete = true;
                 }
             }
             else if (nbytes > 0)
@@ -731,29 +817,31 @@
                 else
                 {
                     complete = OSCL_REQUEST_ERR_NONE;
+                    iscomplete = true;
                 }
             }
             else
             {
                 //this usually means connection was closed.
                 complete = OSCL_REQUEST_ERR_GENERAL;
+                iscomplete = true;
                 //(sockerr will be zero in this case)
             }
         }//for loop
     }
+#if (PV_SOCKET_SERVER_SELECT)
     else
     {
         //keep waiting for socket to be readable.
         ADD_STATS(req->iParam->iFxn, EOsclSocket_ServPoll);
-        select = true;
     }
+#endif
 
     //either keep monitoring activity, or complete the request.
-    if (select)
+    if (!iscomplete)
     {
         LOGSERV((0, "OsclSocketI::ProcessRecvFrom (0x%x) select=true", this));
-        // Set the read and except bits to notify the caller
-        aElem->iSelect |= (OSCL_READSET_FLAG | OSCL_EXCEPTSET_FLAG);
+        OSCL_ASSERT(aElem->iSelect);
     }
     else
     {
diff --git a/oscl/oscl/osclio/src/oscl_socket_listen.cpp b/oscl/oscl/osclio/src/oscl_socket_listen.cpp
index 7049784..e0d4651 100644
--- a/oscl/oscl/osclio/src/oscl_socket_listen.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_listen.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_listen.h b/oscl/oscl/osclio/src/oscl_socket_listen.h
index 3c8f29b..cd503c3 100644
--- a/oscl/oscl/osclio/src/oscl_socket_listen.h
+++ b/oscl/oscl/osclio/src/oscl_socket_listen.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_method.cpp b/oscl/oscl/osclio/src/oscl_socket_method.cpp
index 6683187..1a6688c 100644
--- a/oscl/oscl/osclio/src/oscl_socket_method.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_method.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_method.h b/oscl/oscl/osclio/src/oscl_socket_method.h
index fb36cdc..4264110 100644
--- a/oscl/oscl/osclio/src/oscl_socket_method.h
+++ b/oscl/oscl/osclio/src/oscl_socket_method.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_recv.cpp b/oscl/oscl/osclio/src/oscl_socket_recv.cpp
index d8ed8dc..b51a013 100644
--- a/oscl/oscl/osclio/src/oscl_socket_recv.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_recv.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_recv.h b/oscl/oscl/osclio/src/oscl_socket_recv.h
index d973118..191d734 100644
--- a/oscl/oscl/osclio/src/oscl_socket_recv.h
+++ b/oscl/oscl/osclio/src/oscl_socket_recv.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp b/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp
index 91f1b6f..50d5571 100644
--- a/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_recv_from.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_recv_from.h b/oscl/oscl/osclio/src/oscl_socket_recv_from.h
index 4d0bdac..0b351a6 100644
--- a/oscl/oscl/osclio/src/oscl_socket_recv_from.h
+++ b/oscl/oscl/osclio/src/oscl_socket_recv_from.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_request.cpp b/oscl/oscl/osclio/src/oscl_socket_request.cpp
index 112953e..912ae92 100644
--- a/oscl/oscl/osclio/src/oscl_socket_request.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_request.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_request.h b/oscl/oscl/osclio/src/oscl_socket_request.h
index 5c9005d..48c0975 100644
--- a/oscl/oscl/osclio/src/oscl_socket_request.h
+++ b/oscl/oscl/osclio/src/oscl_socket_request.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -176,10 +176,8 @@
         ConnectParam(OsclNetworkAddress& anAddr)
                 : SocketRequestParam(EPVSocketConnect)
                 , iAddr(anAddr)
-                , iConnecting(false)
         {}
         OsclNetworkAddress iAddr;
-        bool iConnecting;//used in processing the request.
 } ;
 
 class AcceptParam: public SocketRequestParam
diff --git a/oscl/oscl/osclio/src/oscl_socket_send.cpp b/oscl/oscl/osclio/src/oscl_socket_send.cpp
index 68abed3..1649b76 100644
--- a/oscl/oscl/osclio/src/oscl_socket_send.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_send.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_send.h b/oscl/oscl/osclio/src/oscl_socket_send.h
index aea9ca3..1d4c300 100644
--- a/oscl/oscl/osclio/src/oscl_socket_send.h
+++ b/oscl/oscl/osclio/src/oscl_socket_send.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_send_to.cpp b/oscl/oscl/osclio/src/oscl_socket_send_to.cpp
index 1df108f..97d19dc 100644
--- a/oscl/oscl/osclio/src/oscl_socket_send_to.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_send_to.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_send_to.h b/oscl/oscl/osclio/src/oscl_socket_send_to.h
index f2cb38c..825b285 100644
--- a/oscl/oscl/osclio/src/oscl_socket_send_to.h
+++ b/oscl/oscl/osclio/src/oscl_socket_send_to.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_serv_imp.h b/oscl/oscl/osclio/src/oscl_socket_serv_imp.h
index 868fa9b..fff0cfa 100644
--- a/oscl/oscl/osclio/src/oscl_socket_serv_imp.h
+++ b/oscl/oscl/osclio/src/oscl_socket_serv_imp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h b/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h
index 74c767a..4eb1f86 100644
--- a/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h
+++ b/oscl/oscl/osclio/src/oscl_socket_serv_imp_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp b/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp
index 9fb5495..62ded53 100644
--- a/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -56,6 +56,7 @@
 #endif//PV_OSCL_SOCKET_STATS_LOGGING
 
 
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
 //
 //OsclSocketServI::LoopbackSocket
 //
@@ -124,7 +125,7 @@
 
     //let's test a send & recv here just to be extra sure
     //the loopsock is usable.
-    char tmpBuf[2] = {0, 0};
+    const char tmpBuf[2] = {0, 0};
     int nbytes;
     bool wouldblock;
     wouldblock = false;
@@ -228,7 +229,7 @@
     }
 }
 
-void OsclSocketServI::LoopbackSocket::ProcessSelect(bool aSelect, TOsclSocket& maxsocket)
+void OsclSocketServI::LoopbackSocket::ProcessSelect(TOsclSocket& maxsocket)
 //Do the necessary select loop processing to keep
 //the loopback socket going.
 {
@@ -236,7 +237,7 @@
         return;
 
     //Monitor this socket whenever we will be doing a select.
-    if (aSelect)
+    if (maxsocket)
     {
         FD_SET(iSocket, &iContainer->iReadset);
         if (iSocket > maxsocket)
@@ -255,11 +256,225 @@
     bool wouldblock, ok;
     OsclSendTo(iSocket, tmpBuf, 1, iAddr, ok, err, nbytes, wouldblock);
 
-    if (!ok)
-    {//the select call will hang forever, so just go ahead and panic now.
-        OsclError::Panic("OSCLSOCK", 1);
-    }
+    //if send failed, the select call will hang forever, so just go ahead and abort now.
+    OSCL_ASSERT(ok);
 }
+#endif //#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
+
+// Socket server stats for winmobile perf investigation.
+#if (PV_SOCKET_SERVI_STATS)
+
+//breakdown of time in the Session
+enum TServiSessionStats
+{
+    EServiSession_All
+    , EServiSession_Last
+};
+
+//breakdown of time in the Run() call
+enum TServiRunStats
+{
+    EServiRun_Proc = EServiSession_Last
+    , EServiRun_Select
+    , EServiRun_Reschedule
+    , EServiRun_Last
+};
+//breakdown of time in the ProcessSocketRequests call
+enum TServiProcStats
+{
+    EServiProc_Queue = EServiRun_Last
+    , EServiProc_Loop
+    , EServiProc_Fdset
+    , EServiProc_Last
+};
+//breakdown of time in the ProcessXXX calls in ProcessSocketRequests
+enum TServiProcLoopStats
+{
+    EServiProcLoop_Cancel = EServiProc_Last
+    , EServiProcLoop_Closed
+    , EServiProcLoop_Connect
+    , EServiProcLoop_Accept
+    , EServiProcLoop_Shutdown
+    , EServiProcLoop_Recv
+    , EServiProcLoop_Send
+    , EServiProcLoop_RecvFrom
+    , EServiProcLoop_SendTo
+    , EServiProcLoop_Last
+};
+static const char* const TServiStr[] =
+{
+    "EServiSession_All"
+    , "EServiRun_Proc"
+    , "EServiRun_Select"
+    , "EServiRun_Reschedule"
+    , "EServiProc_Queue"
+    , "EServiProc_Loop"
+    , "EServiProc_Fdset"
+    , "EServiProcLoop_Cancel"
+    , "EServiProcLoop_Closed"
+    , "EServiProcLoop_Connect"
+    , "EServiProcLoop_Accept"
+    , "EServiProcLoop_Shutdown"
+    , "EServiProcLoop_Recv"
+    , "EServiProcLoop_Send"
+    , "EServiProcLoop_RecvFrom"
+    , "EServiProcLoop_SendTo"
+};
+
+
+#define PV_SERVI_STATS_SIZE (EServiProcLoop_Last)
+#include "oscl_int64_utils.h"
+
+class PVServiStats
+{
+    public:
+        //use oscl tick count
+        typedef uint32 TPVTick;
+        const char* Tickstr()
+        {
+            return "Ticks";
+        }
+        void settick(TPVTick &tick)
+        {
+            tick = OsclTickCount::TickCount();
+        }
+        int64 tickint(TPVTick& tick)
+        {
+            return tick;
+        }
+
+        PVServiStats(): iCount(0), iRunningTotal(0)
+        {}
+        ~PVServiStats()
+        {}
+
+        uint32 iCount;
+        int64 iRunningTotal;
+
+        TPVTick _start;
+
+        //start an interval
+        void Start()
+        {
+            settick(_start);
+        }
+
+        //end an interval
+        void End()
+        {
+            TPVTick now;
+            settick(now);
+            int32 delta = tickint(now) - tickint(_start);
+            //winmobile clock sometimes goes backward so treat any negative delta as zero.
+            if (delta > 0)
+                iRunningTotal += delta;
+            iCount++;
+        }
+        //end a long interval
+        void LongEnd()
+        {
+            TPVTick now;
+            settick(now);
+            int64 delta = tickint(now) - tickint(_start);
+            //winmobile clock sometimes goes backward so treat any negative delta as zero.
+            if (delta > 0)
+                iRunningTotal += delta;
+            iCount++;
+        }
+
+        static PVServiStats* Create()
+        {
+            _OsclBasicAllocator alloc;
+            OsclAny* ptr = alloc.allocate(PV_SERVI_STATS_SIZE * sizeof(PVServiStats));
+            PVServiStats* ptr2 = (PVServiStats*)ptr;
+            for (uint32 i = 0;i < PV_SERVI_STATS_SIZE;i++)
+            {
+                new(ptr2++) PVServiStats();
+            }
+            return (PVServiStats*)ptr;
+        }
+
+        static void Destroy(PVServiStats* aStats)
+        {
+            if (aStats)
+            {
+                _OsclBasicAllocator alloc;
+                //don't bother with destructor since it's empty.
+                alloc.deallocate(aStats);
+            }
+        }
+
+        void ShowStats(PVLogger* logger, int32 aIndex, PVServiStats& aInterval)
+        {
+            if (!iCount)
+                return;//don't print any that didn't run
+            if (aInterval.iRunningTotal == (int64)0)
+                return;//to avoid div by zero
+
+            float percent = 100.0 * iRunningTotal / aInterval.iRunningTotal;
+            int32 fraction = (int32)percent;
+            float decimal = percent - fraction;
+            decimal *= 100.0;
+
+            //print results
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO
+                            , (0, "  TIME PERCENT %d.%02d, Interval '%s', Count %d, TotalTicks Hi,Lo (0x%x,0x%08x)"
+                               , (int32)percent, (int32)decimal
+                               , TServiStr[aIndex]
+                               , iCount
+                               , Oscl_Int64_Utils::get_int64_upper32(iRunningTotal)
+                               , Oscl_Int64_Utils::get_int64_lower32(iRunningTotal)
+                              ));
+        }
+
+        static void ShowSummaryStats(PVServiStats* aArray)
+        {
+            //lump this logging with Oscl scheduler perf logging.
+            uint32 index = 0;
+            PVLogger* logger = PVLogger::GetLoggerObject("OsclSchedulerPerfStats");
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "Session Breakdown:"));
+            while (index < EServiSession_Last)
+            {
+                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
+                index++;
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "Run Breakdown:"));
+            while (index < EServiRun_Last)
+            {
+                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
+                index++;
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "ProcessRequests Breakdown:"));
+            while (index < EServiProc_Last)
+            {
+                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
+                index++;
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO, (0, "ProcessRequests Loop Breakdown:"));
+            while (index < EServiProcLoop_Last)
+            {
+                aArray[index].ShowStats(logger, index, aArray[EServiSession_All]);
+                index++;
+            }
+        }
+};
+#define START_SERVI_STATS(x) iServiStats[x].Start()
+#define END_SERVI_STATS(x) iServiStats[x].End()
+#define LONG_END_SERVI_STATS(x) iServiStats[x].LongEnd()
+//2nd level of detail-- switched off for now.
+#define START_SERVI_STATS2(x) iServiStats[x].Start()
+#define END_SERVI_STATS2(x) iServiStats[x].End()
+#else
+#define START_SERVI_STATS(x)
+#define END_SERVI_STATS(x)
+#define LONG_END_SERVI_STATS(x)
+#define START_SERVI_STATS2(x)
+#define END_SERVI_STATS2(x)
+#endif //PV_SOCKET_SERVI_STATS
 
 //
 //OsclSocketServI-- PV implementation
@@ -307,6 +522,11 @@
 {
     CONSTRUCT_STATS(this);
 
+#if (PV_SOCKET_SERVI_STATS)
+    iServiStats = PVServiStats::Create();
+    START_SERVI_STATS(EServiSession_All);
+#endif
+
     //Connect to Oscl socket server
 
     OSCL_UNUSED_ARG(aMessageSlots);
@@ -355,7 +575,9 @@
         StopServImp();
     }
 
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
     iLoopbackSocket.Cleanup();
+#endif
 
 #ifdef OsclSocketCleanup
     //close the socket system
@@ -367,6 +589,16 @@
 #endif//OsclSocketCleanup
 
     DUMP_STATS;
+
+#if (PV_SOCKET_SERVI_STATS)
+    if (iServiStats)
+    {
+        LONG_END_SERVI_STATS(EServiSession_All);
+        PVServiStats::ShowSummaryStats(iServiStats);
+        PVServiStats::Destroy(iServiStats);
+        iServiStats = NULL;
+    }
+#endif
 }
 
 bool OsclSocketServI::IsServerThread()
@@ -380,33 +612,46 @@
 #endif
 }
 
-#ifdef OsclSocketSelect
 /**
  * Process all active socket requests.
  *
  * This is called under the server thread or server AO.
  *
- * @param aSelect(output): True if we need to do another Select call.
- * @param aNfds(output): Value = 1 + maximum socket handle for all sockets
+ * @param aNhandles(input/output): nHandles returned by last Select call.
+ * @param aNfds(output): Value = 1+maximum socket handle for all sockets
  *    that we are monitoring with the select call.
  */
-void OsclSocketServI::ProcessSocketRequests(bool &aSelect, int &aNfds)
+#if PV_SOCKET_SERVER_SELECT
+void OsclSocketServI::ProcessSocketRequests(int& aNhandles, int &aNfds)
+#else
+void OsclSocketServI::ProcessSocketRequests()
+#endif
 {
     //process all active requests
 
-    aSelect = false;
+#if PV_SOCKET_SERVER_SELECT
+    //keep track of max socket handle to monitor.
     TOsclSocket maxsocket = 0;
     aNfds = (int)maxsocket + 1;
 
+    //save input handle count, then clear it until the next select operation.
+    int nhandles = aNhandles;
+    aNhandles = 0;
+#endif
+
     // Pick up new requests from the app thread.
+    START_SERVI_STATS2(EServiProc_Queue);
     iSockServRequestList.Lock();
     {
         iSockServRequestList.GetNewRequests();
 
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
         //flush any data on the loopback socket.
         iLoopbackSocket.Read();
+#endif
     }
     iSockServRequestList.Unlock();
+    END_SERVI_STATS2(EServiProc_Queue);
 
     if (iSockServRequestList.iActiveRequests.empty())
     {
@@ -415,6 +660,7 @@
     }
 
     //Make a pass through the open request list and cancel or process each request.
+    START_SERVI_STATS2(EServiProc_Loop);
     uint32 i;
     for (i = 0;i < iSockServRequestList.iActiveRequests.size();i++)
     {
@@ -423,50 +669,74 @@
         if (elem->iCancel)
         {
             //Request was canceled
+            START_SERVI_STATS2(EServiProcLoop_Cancel);
             elem->iSocketRequest->Complete(elem, OSCL_REQUEST_ERR_CANCEL);
+            END_SERVI_STATS2(EServiProcLoop_Cancel);
         }
         else if (!IsServConnected())
         {
             //Server died or was closed.
+            START_SERVI_STATS2(EServiProcLoop_Closed);
             elem->iSocketRequest->Complete(elem, OSCL_REQUEST_ERR_GENERAL
                                            , (iServError) ? iServError : PVSOCK_ERR_SERV_NOT_CONNECTED);
+            END_SERVI_STATS2(EServiProcLoop_Closed);
         }
+#if PV_SOCKET_SERVER_SELECT
+        else if (nhandles == 0 && elem->iSelect)
+        {
+            //we're monitoring this socket but there is no current
+            //socket activity-- just keep waiting.
+            ;
+        }
+#endif
         else
         {
             //These routines will start the request, or else process
             //the results of prior select call, and also set the select
             //flags for the next call.
 
-            elem->iSelect = 0;
-
             switch (elem->iSocketRequest->Fxn())
             {
                 case EPVSocketShutdown:
+                    START_SERVI_STATS2(EServiProcLoop_Shutdown);
                     elem->iSocketRequest->iSocketI->ProcessShutdown(elem);
+                    END_SERVI_STATS2(EServiProcLoop_Shutdown);
                     break;
 
                 case EPVSocketConnect:
+                    START_SERVI_STATS2(EServiProcLoop_Connect);
                     elem->iSocketRequest->iSocketI->ProcessConnect(elem);
+                    END_SERVI_STATS2(EServiProcLoop_Connect);
                     break;
 
                 case EPVSocketAccept:
+                    START_SERVI_STATS2(EServiProcLoop_Accept);
                     elem->iSocketRequest->iSocketI->ProcessAccept(elem);
+                    END_SERVI_STATS2(EServiProcLoop_Accept);
                     break;
 
                 case EPVSocketSend:
+                    START_SERVI_STATS2(EServiProcLoop_Send);
                     elem->iSocketRequest->iSocketI->ProcessSend(elem);
+                    END_SERVI_STATS2(EServiProcLoop_Send);
                     break;
 
                 case EPVSocketSendTo:
+                    START_SERVI_STATS2(EServiProcLoop_SendTo);
                     elem->iSocketRequest->iSocketI->ProcessSendTo(elem);
+                    END_SERVI_STATS2(EServiProcLoop_SendTo);
                     break;
 
                 case EPVSocketRecv:
+                    START_SERVI_STATS2(EServiProcLoop_Recv);
                     elem->iSocketRequest->iSocketI->ProcessRecv(elem);
+                    END_SERVI_STATS2(EServiProcLoop_Recv);
                     break;
 
                 case EPVSocketRecvFrom:
+                    START_SERVI_STATS2(EServiProcLoop_RecvFrom);
                     elem->iSocketRequest->iSocketI->ProcessRecvFrom(elem);
+                    END_SERVI_STATS2(EServiProcLoop_RecvFrom);
                     break;
 
                 default:
@@ -475,11 +745,15 @@
             }
         }
     }
+    END_SERVI_STATS2(EServiProc_Loop);
 
     //Zero out any old select set
+    START_SERVI_STATS2(EServiProc_Fdset);
+#if PV_SOCKET_SERVER_SELECT
     FD_ZERO(&iReadset);
     FD_ZERO(&iWriteset);
     FD_ZERO(&iExceptset);
+#endif
     LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Clearing select set"));
 
     //Now make a pass to either delete the request or collate the select flags.
@@ -492,13 +766,11 @@
             //request is still active
             i++;
 
+#if PV_SOCKET_SERVER_SELECT
             if (elem->iSelect > 0)
             {
                 //Need to do a select call for this socket
 
-                if (!aSelect)
-                    aSelect = true;
-
                 TOsclSocket osock = elem->iSocketRequest->iSocketI->Socket();
 
                 if (osock > maxsocket)
@@ -531,6 +803,7 @@
                     LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Setting Exceptset for %d", osock));
                 }
             }
+#endif
         }
         else
         {
@@ -538,17 +811,24 @@
             iSockServRequestList.iActiveRequests.erase(elem);
         }
     }
+    END_SERVI_STATS2(EServiProc_Fdset);
 
-    //also monitor the loopback socket if we're going to call select.
-    iLoopbackSocket.ProcessSelect(aSelect, maxsocket);
-
-    if (aSelect)
+#if PV_SOCKET_SERVER_SELECT
+    if (maxsocket)
     {
-        aNfds = (int)(maxsocket + 1);
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
+        //also monitor the loopback socket if we're going to call select.
+        iLoopbackSocket.ProcessSelect(maxsocket);
+#endif
+
+        //set Nfds to 1+maxsocket handle.
+        aNfds = (int)maxsocket + 1;
     }
-    LOGSERV((0, "OsclSocketServI::ProcessSocketRequests Select %d, NFDS %d", aSelect, aNfds));
+
+    LOGSERV((0, "OsclSocketServI::ProcessSocketRequests NFDS %d", aNfds));
+#endif
+
 }
-#endif //OsclSocketSelect
 
 void OsclSocketServI::ServerEntry()
 //Server entry processing
@@ -560,7 +840,7 @@
 
     iSockServRequestList.Open(this);
 
-#ifdef OsclSocketSelect
+#if PV_SOCKET_SERVER_SELECT
     FD_ZERO(&iReadset);
     FD_ZERO(&iWriteset);
     FD_ZERO(&iExceptset);
@@ -576,21 +856,25 @@
         iServState = OsclSocketServI::ESocketServ_Idle;
     }
 
-#ifdef OsclSocketSelect
     //Go through the active requests one last time.
     //All the requests will complete with errors
     //since the server is no longer connected.
-    bool doSelect;
+#if PV_SOCKET_SERVER_SELECT
     int nfds;
-    ProcessSocketRequests(doSelect, nfds);
+    int nhandles = 0;
+    ProcessSocketRequests(nhandles, nfds);
+#else
+    ProcessSocketRequests();
+#endif
 
     iSockServRequestList.Close();
 
     //make sure sets are clear so resources get cleaned up.
+#if PV_SOCKET_SERVER_SELECT
     FD_ZERO(&iReadset);
     FD_ZERO(&iWriteset);
     FD_ZERO(&iExceptset);
-#endif//OsclSocketSelect
+#endif
 }
 
 void OsclSocketServI::ConstructServImp()
@@ -620,7 +904,9 @@
 #if(PV_SOCKET_SERVER_IS_THREAD)
 
     //setup the loopback socket and/or polling interval.
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
     iLoopbackSocket.iEnable = false;
+#endif
     iSelectPollIntervalMsec = 0;
 
     //check the select timeout in the configuration.
@@ -629,11 +915,15 @@
     {
         //non-polling option selected.
         //create the select cancel pipe.
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
         iLoopbackSocket.Init(this);
 
         //if loopback socket isn't available, we must poll.
         if (!iLoopbackSocket.iEnable)
+#endif
+        {
             iSelectPollIntervalMsec = 10;
+        }
     }
     else
     {
@@ -664,12 +954,18 @@
 
     //Socket server AO startup.
 
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
     iLoopbackSocket.iEnable = false;
+#endif
 
     ServerEntry();
 
     if (!IsAdded())
     {
+#if PV_SOCKET_SERVER_SELECT
+        iNhandles = 0;
+        iNfds = 0;
+#endif
         AddToScheduler();
     }
     return OsclErrNone;
@@ -723,13 +1019,6 @@
 
     ServerEntry();
 
-#ifndef OsclSocketSelect
-    //no implementation!
-    iServState = OsclSocketServI::ESocketServ_Error;
-    iStart.Signal();
-    return;
-#else
-
     //Let server know thread is started and ready to
     //process requests.
     iStart.Signal();
@@ -737,17 +1026,17 @@
     //create select timeout structure
     timeval timeout;
 
-    bool doSelect, ok;
+    bool ok;
     int nfds;
     int nhandles = 0;
 
     while (!iClose)
     {
-        //process active requests.
-        ProcessSocketRequests(doSelect, nfds);
+        //process new requests and new socket activity on existing requests.
+        ProcessSocketRequests(nhandles, nfds);
 
         //Make the select call if needed.
-        if (doSelect)
+        if (nfds > 1)
         {
             //Set the fixed timeout.  The select call may update this value
             //so it needs to be set on each call.
@@ -794,8 +1083,6 @@
 
     ServerExit();
 
-#endif //OsclSocketSelect
-
     //signal close complete to caller...
     if (iClose)
     {
@@ -909,79 +1196,109 @@
 #else//PV_SOCKET_SERVER_IS_THREAD
 //Non-threaded section
 
-
 void OsclSocketServI::Run()
 //Socket server AO
 {
-    int nhandles = 0;
-    bool doSelect = false;;
+#if !PV_SOCKET_SERVER_SELECT
+    //non-select-loop implementation.
 
-#ifdef OsclSocketSelect
-    int nfds;
+    //Process active requests.
+    START_SERVI_STATS(EServiRun_Proc);
+    ProcessSocketRequests();
+    END_SERVI_STATS(EServiRun_Proc);
 
-    //process active requests.
-    ProcessSocketRequests(doSelect, nfds);
-
-    //Make the select call if needed.
-    if (doSelect)
+    //Re-schedule
+    START_SERVI_STATS(EServiRun_Reschedule);
+    if (!iSockServRequestList.iActiveRequests.empty())
     {
-        // Reset the flag
-        doSelect = false;
+        // Re-schedule after a delay for continued monitoring
+        // of active requests.
+        // Note: new requests will interrupt this polling interval
+        // and schedule ASAP.
+        ADD_STATS(EOsclSocketServ_SelectReschedulePoll);
+        RunIfNotReady(1000*PV_SOCKET_SERVER_AO_INTERVAL_MSEC);
+    }
+    END_SERVI_STATS(EServiRun_Reschedule);
 
-        //use a delay of zero since we're essentially polling for socket activity.
-        timeval timeout;
-        timeout.tv_sec = 0;
-        timeout.tv_usec = 0;
-        bool ok;
-        OsclSocketSelect(nfds, iReadset, iWriteset, iExceptset, timeout, ok, iServError, nhandles);
-        if (!ok)
-        {
-            //a select error is fatal.
-            StopServImp();//stop the AO
-            iServState = OsclSocketServI::ESocketServ_Error;
-            return;
-        }
+#else
+    //select loop implementation.
 
-        if (nhandles)
-        {
-            ADD_STATS(EOsclSocketServ_SelectActivity);
-        }
-        else
-        {
-            ADD_STATS(EOsclSocketServ_SelectNoActivity);
-        }
+    //loop 2x so we can complete some requests in one call.
+    for (uint32 i = 0;i < 2;i++)
+    {
+        //Process active requests.
+        START_SERVI_STATS(EServiRun_Proc);
+        ProcessSocketRequests(iNhandles, iNfds);
+        END_SERVI_STATS(EServiRun_Proc);
 
-        if (nhandles > 0)
+        //Make the select call if needed.
+        if (iNfds > 1)
         {
-            // Select() call reported a request was completed so complete the socket request
-            ProcessSocketRequests(doSelect, nfds);
+            START_SERVI_STATS(EServiRun_Select);
+            //use a delay of zero since we're essentially polling for socket activity.
+            //note the select call may update this value so it must be set prior to each call.
+            timeval timeout;
+            timeout.tv_sec = 0;
+            timeout.tv_usec = 0;
+            bool ok;
+            OsclSocketSelect(iNfds, iReadset, iWriteset, iExceptset, timeout, ok, iServError, iNhandles);
+            END_SERVI_STATS(EServiRun_Select);
+            if (!ok)
+            {
+                //a select error is fatal.
+                StopServImp();//stop the AO
+                iServState = OsclSocketServI::ESocketServ_Error;
+                return;
+            }
+
+            if (iNhandles)
+            {
+                ADD_STATS(EOsclSocketServ_SelectActivity);
+            }
+            else
+            {
+                ADD_STATS(EOsclSocketServ_SelectNoActivity);
+            }
         }
     }
 
-#else
-    OsclError::Panic("OSCLSOCK", 1);//no implementation.
-#endif //OsclSocketSelect
-
-    // Re-schedule as long as there are requests and waiting for
-    // select() to report a request is complete
+    //Re-schedule
+    START_SERVI_STATS(EServiRun_Reschedule);
     if (!iSockServRequestList.iActiveRequests.empty())
     {
-        if (doSelect)
+        if (iNhandles)
         {
-            // Requests were processed and there are still requests waiting
-            // for select() to report a request is complete so check again
-            // as possible as.
+            // Re-schedule ASAP when we have socket activity.
             ADD_STATS(EOsclSocketServ_SelectRescheduleAsap);
             RunIfNotReady();
         }
         else
         {
-            // The select() call did not report any completion so check again
-            // afte the specified interval
+            // Re-schedule after a delay for continued monitoring
+            // of active requests.
+            // Note: new requests will interrupt this polling interval
+            // and schedule ASAP.
             ADD_STATS(EOsclSocketServ_SelectReschedulePoll);
             RunIfNotReady(1000*PV_SOCKET_SERVER_AO_INTERVAL_MSEC);
         }
     }
+    END_SERVI_STATS(EServiRun_Reschedule);
+
+#endif //PV_SOCKET_SERVER_SELECT
+}
+
+//re-schedule the AO when a new request comes in.
+void OsclSocketServI::WakeupAO()
+{
+    if (IsAdded())
+    {
+        // To avoid waiting for the polling period to expire,
+        // cancel and activate for immediate run
+        if (IsBusy())
+            Cancel();
+
+        RunIfNotReady();
+    }
 }
 
 
diff --git a/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h b/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h
index ef37226..eead931 100644
--- a/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h
+++ b/oscl/oscl/osclio/src/oscl_socket_serv_imp_pv.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,11 +34,12 @@
 #include "oscl_scheduler_ao.h"
 #endif
 
+class PVServiStats;
 
 /** PV socket server implementation
 */
 #if (PV_SOCKET_SERVER_IS_THREAD)
-class OsclSocketServI: public OsclHeapBase, public OsclSocketServIBase
+class OsclSocketServI: public HeapBase, public OsclSocketServIBase
 #else
 class OsclSocketServI: public OsclTimerObject, public OsclSocketServIBase
 #endif
@@ -60,6 +61,7 @@
         //socket request list.
         OsclSocketServRequestList iSockServRequestList;
 
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
         //blocking select wakeup feature
         class LoopbackSocket
         {
@@ -71,7 +73,7 @@
                 }
                 bool iEnable;
                 void Read();
-                void ProcessSelect(bool, TOsclSocket&);
+                void ProcessSelect(TOsclSocket&);
                 void Init(OsclSocketServI* aContainer);
                 void Cleanup();
                 void Write();
@@ -84,12 +86,15 @@
                 OsclSocketServI* iContainer;
         };
         LoopbackSocket iLoopbackSocket;
+#endif
         uint32 iSelectPollIntervalMsec;
 
         void WakeupBlockingSelect()
         {
+#if PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
             if (iLoopbackSocket.iEnable)
                 iLoopbackSocket.Write();
+#endif
         }
 
         int32 StartServImp();
@@ -112,18 +117,23 @@
 #else
         //for AO implemenation.
         void Run();
+        void WakeupAO();
+#if PV_SOCKET_SERVER_SELECT
+        int iNhandles;
+        int iNfds;
+#endif
 #endif
 
-
-#ifdef OsclSocketSelect
+#if PV_SOCKET_SERVER_SELECT
         //select flags.
         fd_set iReadset, iWriteset, iExceptset;
-
-        void ProcessSocketRequests(bool &select, int &n);
+        void ProcessSocketRequests(int &, int &n);
+#else
+        void ProcessSocketRequests();
+#endif
 
         friend class OsclSocketServRequestList;
         friend class LoopbackSocket;
-#endif
 
         friend class OsclTCPSocketI;
         friend class OsclUDPSocketI;
@@ -132,6 +142,8 @@
         friend class OsclSocketRequest;
         friend class OsclSocketServ;
 
+        PVServiStats* iServiStats;
+
 };
 
 /** A bitmask for socket select operations
diff --git a/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp b/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp
index 627bf7f..f007c87 100644
--- a/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,14 +84,12 @@
     //may need to interrupt a blocking select call
     iContainer->WakeupBlockingSelect();
 #else
-#ifdef OsclSocketSelect
     //for AO implementation, call the request processing routine
     //so that the request will get canceled.
-    bool doSelect;
-    int nfds;
-    iContainer->ProcessSocketRequests(doSelect, nfds);
+#if PV_SOCKET_SERVER_SELECT
+    iContainer->ProcessSocketRequests(iContainer->iNhandles, iContainer->iNfds);
 #else
-    OsclError::Panic("OSCLSOCK", 1);//no implementation.
+    iContainer->ProcessSocketRequests();
 #endif
 #endif
 }
@@ -133,16 +131,7 @@
     iSem.Signal();
 #else
     //wakeup the AO.
-    if (iContainer->IsAdded())
-    {
-        // To avoid waiting for the polling period to expire,
-        // cancel and activate for immediate run
-        if (iContainer->IsBusy())
-        {
-            iContainer->Cancel();
-        }
-        iContainer->RunIfNotReady();
-    }
+    iContainer->WakeupAO();
 #endif
 }
 
diff --git a/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h b/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h
index 39bbd34..7e6c56e 100644
--- a/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h
+++ b/oscl/oscl/osclio/src/oscl_socket_serv_imp_reqlist.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp b/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp
index 5a3436e..acce4aa 100644
--- a/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_shutdown.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_shutdown.h b/oscl/oscl/osclio/src/oscl_socket_shutdown.h
index 9cdc2f9..38f3f0e 100644
--- a/oscl/oscl/osclio/src/oscl_socket_shutdown.h
+++ b/oscl/oscl/osclio/src/oscl_socket_shutdown.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_stats.cpp b/oscl/oscl/osclio/src/oscl_socket_stats.cpp
index b14796f..bca87e1 100644
--- a/oscl/oscl/osclio/src/oscl_socket_stats.cpp
+++ b/oscl/oscl/osclio/src/oscl_socket_stats.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_stats.h b/oscl/oscl/osclio/src/oscl_socket_stats.h
index 6fa55dc..8c91231 100644
--- a/oscl/oscl/osclio/src/oscl_socket_stats.h
+++ b/oscl/oscl/osclio/src/oscl_socket_stats.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_socket_tuneables.h b/oscl/oscl/osclio/src/oscl_socket_tuneables.h
index cf873b6..0aa2c91 100644
--- a/oscl/oscl/osclio/src/oscl_socket_tuneables.h
+++ b/oscl/oscl/osclio/src/oscl_socket_tuneables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,6 +66,22 @@
 #endif
 
 /*!
+** PV_SOCKET_SERVER_SELECT chooses whether to use "select" call or not.
+** In threaded mode, select call is required and is forced to "1".
+** In AO mode, "select" call is an option that defaults to "0".
+** Avoiding any "select" call was found to greatly reduce CPU usage
+** on WinMobile devices.
+*/
+#if PV_SOCKET_SERVER_IS_THREAD
+#undef PV_SOCKET_SERVER_SELECT
+#define PV_SOCKET_SERVER_SELECT 1
+#else
+#ifndef PV_SOCKET_SERVER_SELECT
+#define PV_SOCKET_SERVER_SELECT 0
+#endif
+#endif
+
+/*!
 ** PV_SOCKET_SERVER_THREAD_PRIORITY sets the priority of the PV socket
 ** server thread.
 */
@@ -78,7 +94,7 @@
 ** in the PV socket server thread for the polling select loop implementation.
 ** When the timeout is -1, the select call will block forever waiting on a new request
 ** and will use a loopback socket to signal a new request.
-** Note: if infinite wait is selected, but loopback socket cannot be created at runtime,
+** Note: if infinite wait is selected, but loopback socket is not available,
 ** the implementation will poll at 10 msec intervals.
 */
 #ifndef PV_SOCKET_SERVER_SELECT_TIMEOUT_MSEC
@@ -88,20 +104,24 @@
 /*!
 ** PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET enables the feature to wakeup the select
 ** call by writing to a loopback socket each time a new request comes in.
-** This option only applies when using the polling select loop implementation.
-** When using the blocking select loop, loopback socket will always be used and
-** this setting will be ignored.
+** This option is required to support the blocking select loop option of threaded
+** server mode.  This option is forced to "0" in AO mode.
 */
+#if PV_SOCKET_SERVER_IS_THREAD
 #ifndef PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
 #define PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET 1
 #endif
+#else
+#undef PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET
+#define PV_SOCKET_SERVER_SELECT_LOOPBACK_SOCKET 0
+#endif
 
 /*!
 ** PV_SOCKET_SERVER_AO_PRIORITY sets priority of the PV socket server
 ** AO for non-threaded implementations.
 */
 #ifndef PV_SOCKET_SERVER_AO_PRIORITY
-#define PV_SOCKET_SERVER_AO_PRIORITY OsclActiveObject::EPriorityNominal
+#define PV_SOCKET_SERVER_AO_PRIORITY (OsclActiveObject::EPriorityNominal)
 #endif
 
 /*!
@@ -109,7 +129,7 @@
 ** of the PV socket server AO for non-threaded implementations.
 */
 #ifndef PV_SOCKET_SERVER_AO_INTERVAL_MSEC
-#define PV_SOCKET_SERVER_AO_INTERVAL_MSEC 10
+#define PV_SOCKET_SERVER_AO_INTERVAL_MSEC 5
 #endif
 
 /*!
@@ -139,6 +159,19 @@
 #define PV_OSCL_SOCKET_1MB_RECV_BUF 0
 #endif
 
+/*!
+** For detailed performance breakdown of time spend in OsclSocketServI AO.
+** Output is logged under "OsclSchedulerPerfStats" node.  Should be off in
+** production code.  This option is forced to "0" in threaded mode.
+*/
+#if PV_SOCKET_SERVER_IS_THREAD
+#undef PV_SOCKET_SERVI_STATS
+#define PV_SOCKET_SERVI_STATS 0
+#else
+#ifndef PV_SOCKET_SERVI_STATS
+#define PV_SOCKET_SERVI_STATS 0
+#endif
+#endif
 
 #endif//PV_SOCKET_SERVER
 
diff --git a/oscl/oscl/osclio/src/oscl_socket_types.h b/oscl/oscl/osclio/src/oscl_socket_types.h
index 26e7075..97434ae 100644
--- a/oscl/oscl/osclio/src/oscl_socket_types.h
+++ b/oscl/oscl/osclio/src/oscl_socket_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_tcp_socket.cpp b/oscl/oscl/osclio/src/oscl_tcp_socket.cpp
index b335907..c750b55 100644
--- a/oscl/oscl/osclio/src/oscl_tcp_socket.cpp
+++ b/oscl/oscl/osclio/src/oscl_tcp_socket.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_tcp_socket.h b/oscl/oscl/osclio/src/oscl_tcp_socket.h
index 5645791..ac36ad6 100644
--- a/oscl/oscl/osclio/src/oscl_tcp_socket.h
+++ b/oscl/oscl/osclio/src/oscl_tcp_socket.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_udp_socket.cpp b/oscl/oscl/osclio/src/oscl_udp_socket.cpp
index 85cb4b1..2148011 100644
--- a/oscl/oscl/osclio/src/oscl_udp_socket.cpp
+++ b/oscl/oscl/osclio/src/oscl_udp_socket.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclio/src/oscl_udp_socket.h b/oscl/oscl/osclio/src/oscl_udp_socket.h
index 0efc693..ddbf18a 100644
--- a/oscl/oscl/osclio/src/oscl_udp_socket.h
+++ b/oscl/oscl/osclio/src/oscl_udp_socket.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/oscllib/Android.mk b/oscl/oscl/oscllib/Android.mk
index c645a81..5c6f5b5 100644
--- a/oscl/oscl/oscllib/Android.mk
+++ b/oscl/oscl/oscllib/Android.mk
@@ -3,28 +3,33 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_shared_library.cpp \
-	src/oscl_library_list.cpp
-
+ 	src/oscl_configfile_list.cpp \
+ 	src/oscl_library_list.cpp
 
 
 LOCAL_MODULE := liboscllib
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/oscllib/src \
-	$(PV_TOP)//oscl/oscl/oscllib/src \
-	$(PV_TOP)//oscl/oscl/oscllib/../osclio/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/oscllib/src \
+ 	$(PV_TOP)/oscl/oscl/oscllib/src \
+ 	$(PV_TOP)/oscl/oscl/osclio/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_shared_lib_interface.h \
-	src/oscl_shared_library.h \
-	src/oscl_library_common.h \
-	src/oscl_library_list.h
+ 	src/oscl_shared_library.h \
+ 	src/oscl_library_common.h \
+ 	src/oscl_configfile_list.h \
+ 	src/oscl_library_list.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/oscllib/build/make/local.mk b/oscl/oscl/oscllib/build/make/local.mk
new file mode 100644
index 0000000..a3b232a
--- /dev/null
+++ b/oscl/oscl/oscllib/build/make/local.mk
@@ -0,0 +1,29 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+TARGET := oscllib
+
+XINCDIRS := ../../../osclio/src
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+# compose final src list for actual build
+SRCS :=	oscl_shared_library.cpp \
+	oscl_configfile_list.cpp \
+	oscl_library_list.cpp
+
+HDRS :=	oscl_shared_lib_interface.h \
+	oscl_shared_library.h \
+	oscl_library_common.h \
+	oscl_configfile_list.h \
+	oscl_library_list.h
+
+
+include $(MK)/library.mk
diff --git a/oscl/oscl/oscllib/build/make/makefile b/oscl/oscl/oscllib/build/make/makefile
deleted file mode 100644
index 0642371..0000000
--- a/oscl/oscl/oscllib/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = oscllib
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-XINCDIRS += -I../../../osclio/src
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	oscl_shared_library.cpp \
-		oscl_library_list.cpp
-
-HDRS =	oscl_shared_lib_interface.h \
-		oscl_shared_library.h \
-		oscl_library_common.h \
-		oscl_library_list.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/oscl/oscl/oscllib/src/oscl_configfile_list.cpp b/oscl/oscl/oscllib/src/oscl_configfile_list.cpp
new file mode 100644
index 0000000..9288d88
--- /dev/null
+++ b/oscl/oscl/oscllib/src/oscl_configfile_list.cpp
@@ -0,0 +1,218 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_configfile_list.h"
+#include "oscl_string.h"
+#include "oscl_file_io.h"
+#include "oscl_file_find.h"
+#include "oscl_file_types.h"
+#include "pvlogger.h"
+#include "oscl_uuid.h"
+
+#define CONFIG_FILE_EXTENSION "*.cfg"
+#define OSCL_NUMBER_OF_CONFIG_FILES	16
+
+OSCL_EXPORT_REF	OsclLibStatus OsclLibraryUtil::SetupLibraryEnv(const char* aEnvName, const char* aEnvValue)
+{
+    // currently only MSWIN is supported;
+    // Linux is not implemented since its library search path needs to be set at compilation time
+    OsclLibStatus aStatus = OsclLibSuccess;
+
+    OSCL_UNUSED_ARG(aEnvName);
+    OSCL_UNUSED_ARG(aEnvValue);
+    aStatus = OsclLibNotSupported;
+    return aStatus;
+}
+
+
+OSCL_EXPORT_REF OsclConfigFileList::OsclConfigFileList()
+{
+    ipLogger = PVLogger::GetLoggerObject("oscllib");
+#if OSCL_LIBRARY_PERF_LOGGING
+    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.osclconfigfilelist");
+    iCfgFileNum = 0;
+#endif
+    int32 err = 0;
+    OSCL_TRY(err,
+             iCfgList.reserve(OSCL_NUMBER_OF_CONFIG_FILES);
+            );
+    if (err)
+    {
+        iCfgList.clear();
+        OSCL_LEAVE(err);
+    }
+}
+
+OSCL_EXPORT_REF OsclConfigFileList::~OsclConfigFileList()
+{
+    ipLogger = NULL;
+#if OSCL_LIBRARY_PERF_LOGGING
+    iDiagnosticsLogger = NULL;
+#endif
+    iCfgList.clear();
+}
+
+// This method finds all files with extention .cfg in given directory
+// using oscl_file_find and stores in a vector in iCfgList
+// each cfg in iCfgList stored with whole pathname
+// @Return: OsclLibSuccess if any config file found, OsclLibNotFound if not any, OsclLibFail otherwise
+
+OSCL_EXPORT_REF OsclLibStatus OsclConfigFileList::Populate(const OSCL_String& aConfigFileDir, OsclConfigFileList::SortType aSortType)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
+                    (0, "OsclConfigFileList::Populate '%s' IN", aConfigFileDir.get_cstr()));
+#if OSCL_LIBRARY_PERF_LOGGING
+    TICK starttime;
+    SET_TICK(starttime);
+    iCfgFileNum = 0;
+#endif
+    Oscl_FileFind aCfgFind;
+    OsclLibStatus status = OsclLibSuccess;
+
+    char* strbuf = (char*)_oscl_malloc(OSCL_IO_FILENAME_MAXLEN * sizeof(char));
+    if (NULL == strbuf)
+    {
+        return OsclLibOutOfMemory;
+    }
+
+    bool adddelimiter = false;
+
+    if (aConfigFileDir.get_size()
+            && oscl_strncmp((aConfigFileDir.get_str() + (aConfigFileDir.get_size() - 1)/*length of path delimiter is 1*/),
+                            OSCL_FILE_CHAR_PATH_DELIMITER, 1) != 0)
+    {
+        adddelimiter = true;
+    }
+
+    if (NULL == aCfgFind.FindFirst(aConfigFileDir.get_str(), CONFIG_FILE_EXTENSION, strbuf, OSCL_IO_FILENAME_MAXLEN))
+    {
+        _oscl_free(strbuf);
+        strbuf = NULL;
+        if (Oscl_FileFind::E_NO_MATCH == aCfgFind.GetLastError())
+        {
+            status = OsclLibNotFound;
+        }
+        else
+        {
+            iCfgList.clear();
+            return OsclLibFail;
+        }
+    }
+    else
+    {
+        OSCL_HeapString<OsclMemAllocator> file(strbuf);
+        OSCL_HeapString<OsclMemAllocator> cfg;
+        //On some OS we get entire path & filename from FindFirst, on others we just get filename.
+        //Accommodate both until result is standardized.
+        bool isfullpath = (oscl_strstr(file.get_cstr(), OSCL_FILE_CHAR_PATH_DELIMITER) != NULL);
+        if (!isfullpath)
+        {
+            cfg += aConfigFileDir;
+            if (adddelimiter)
+            {
+                cfg += OSCL_FILE_CHAR_PATH_DELIMITER;
+            }
+        }
+        cfg += strbuf;
+        iCfgList.push_front(cfg.get_str());
+#if OSCL_LIBRARY_PERF_LOGGING
+        iCfgFileNum++;
+#endif
+        // found first config file, continue until Oscl_FileFind::E_NO_MATCH
+        while (aCfgFind.FindNext(strbuf, OSCL_IO_FILENAME_MAXLEN) && Oscl_FileFind::E_NO_MATCH != aCfgFind.GetLastError())
+        {
+            cfg = "";
+            if (!isfullpath)
+            {
+                cfg += aConfigFileDir;
+                if (adddelimiter)
+                {
+                    cfg += OSCL_FILE_CHAR_PATH_DELIMITER;
+                }
+            }
+            cfg += strbuf;
+            iCfgList.push_back(cfg.get_str());
+#if OSCL_LIBRARY_PERF_LOGGING
+            iCfgFileNum++;
+#endif
+        }
+#if OSCL_LIBRARY_PERF_LOGGING
+        uint32 difftime;
+        DIFF_TICK(starttime, difftime);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                        (0, "OsclConfigFileList::Populate - Searching path %s ...", aConfigFileDir.get_cstr()));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                        (0, "                                   Time taken = %d ticks", difftime));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                        (0, "                                   Number of config files found = %d", iCfgFileNum));
+#endif
+    }
+    _oscl_free(strbuf);
+    // error if there's none config file found and loaded in the vector,
+    if (iCfgList.size() <= 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
+                        (0, "OsclConfigFileList::Populate, Didn't find any config file in %s", aConfigFileDir.get_str()));
+        status = OsclLibNotFound;
+    }
+    // Sort the list if requested
+    else if (aSortType != OsclConfigFileList::ENoSort)
+    {
+        Sort();
+    }
+
+    return status;
+}
+
+OSCL_EXPORT_REF uint32 OsclConfigFileList::Size()
+{
+    return iCfgList.size();
+}
+
+OSCL_EXPORT_REF const OSCL_String& OsclConfigFileList::GetConfigfileAt(uint32 n)
+{
+    return iCfgList[n];
+}
+
+void OsclConfigFileList::Sort()
+{
+    uint32 numConfigs = Size();
+    uint32 ii = 0;
+    bool swapped = false;
+
+    // Bubblesort iCfgList - As long as there aren't very many config files
+    // in the list, efficiency shouldn't be an issue. If the list gets to be
+    // too large (100+) then a new sort algorithm should be used.
+    do
+    {
+        swapped = false;
+        for (ii = 0; ii < numConfigs - 1; ii++)
+        {
+            if (oscl_strncmp(iCfgList[ii].get_cstr(),
+                             iCfgList[ii + 1].get_cstr(),
+                             oscl_strlen(iCfgList[ii].get_cstr())) > 0)
+            {
+                OSCL_StackString<OSCL_IO_FILENAME_MAXLEN> temp = iCfgList[ii];
+                iCfgList[ii] = iCfgList[ii + 1];
+                iCfgList[ii + 1] = temp;
+                swapped = true;
+            }
+        }
+    }
+    while (swapped);
+}
+
diff --git a/oscl/oscl/oscllib/src/oscl_configfile_list.h b/oscl/oscl/oscllib/src/oscl_configfile_list.h
new file mode 100644
index 0000000..c62ce44
--- /dev/null
+++ b/oscl/oscl/oscllib/src/oscl_configfile_list.h
@@ -0,0 +1,120 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef OSCL_CONFIGFILE_LIST_H_INCLUDED
+#define OSCL_CONFIGFILE_LIST_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_LIBRARY_COMMON_H_INCLUDED
+#include "oscl_library_common.h"
+#endif
+
+struct OsclUuid;
+class PVLogger;
+
+/**
+* OsclConfigFileList contains the list of .cfg files found from a given directory
+**/
+class OsclConfigFileList
+{
+    public:
+        enum SortType
+        {
+            ESortByName = 0,
+            ENoSort
+        };
+
+        /**
+         * Default object Constructor function
+         **/
+        OSCL_IMPORT_REF OsclConfigFileList();
+
+        /**
+         * Object destructor function
+         **/
+        OSCL_IMPORT_REF ~OsclConfigFileList();
+
+        /**
+         * Populate the list for the given directory.
+         *
+         * @param aConfigFileDir - directory path of the .cfg files; path can trail with or without delimiter (path prefix, e.g. '\')
+         * @param aSortType - Define type type of sort, if any, for the config file list. Default is not sorted
+         *
+         * @returns OsclLibStatus about whether the config file vector got populated or not
+         **/
+        OSCL_IMPORT_REF OsclLibStatus Populate(const OSCL_String& aConfigFileDir,
+                                               OsclConfigFileList::SortType aSortType = ENoSort);
+
+        /**
+        * Get the number of config file in the list.
+        *
+        * @returns Number of config file in list.
+        */
+        OSCL_IMPORT_REF uint32 Size();
+
+        /**
+         * Returns the n'th element.
+         * @param n element position to return
+         * @returns the reference to the config file name stored in the iCfgList vector
+         */
+        OSCL_IMPORT_REF const OSCL_String& GetConfigfileAt(uint32 n);
+
+
+    private:
+        Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iCfgList;
+        PVLogger* ipLogger;
+#if OSCL_LIBRARY_PERF_LOGGING
+        PVLogger* iDiagnosticsLogger;
+        uint32 iCfgFileNum;
+#endif
+
+        /**
+         * Sort iCfgList by name
+         */
+        void Sort(void);
+};
+
+/**
+* OsclLibraryUtil is mainly used by test app to setup library search path
+**/
+class OsclLibraryUtil
+{
+    public:
+        /**
+         * static api sets, appends, or unset aDir to system PATH environment as the lib search folder
+         *
+         * @param aEnvName - environment name to be set or unset
+         * @param aEnvValue - environment value of the aEnvName to be set or unset
+         *
+         * @returns OsclLibStatus
+         **/
+        OSCL_IMPORT_REF	static OsclLibStatus SetupLibraryEnv(const char* aEnvName, const char* aEnvValue);
+};
+
+#endif //OSCL_LIBRARY_LIST_H_INCLUDED
+
diff --git a/oscl/oscl/oscllib/src/oscl_library_common.h b/oscl/oscl/oscllib/src/oscl_library_common.h
index 371362d..711c008 100644
--- a/oscl/oscl/oscllib/src/oscl_library_common.h
+++ b/oscl/oscl/oscllib/src/oscl_library_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,34 @@
 #ifndef OSCL_LIBRARY_COMMON_H_INCLUDED
 #define OSCL_LIBRARY_COMMON_H_INCLUDED
 
+#include "oscl_tickcount.h"
+
+
 typedef int32 OsclLibStatus;
-const OsclLibStatus OsclLibFail = 1;
 const OsclLibStatus OsclLibSuccess = 0;
+const OsclLibStatus OsclLibFail = 1;
+const OsclLibStatus OsclLibNotFound = 2;
+const OsclLibStatus OsclLibOutOfMemory = 3;
+const OsclLibStatus OsclLibNotSupported = 4;
+const OsclLibStatus OsclLibNotLoaded = 5;
+
+#ifndef OSCL_LIBRARY_PERF_LOGGING
+//defaults for cases where the flag is not defined in the osclconfig_lib.h
+#if defined( NDEBUG)||(OSCL_RELEASE_BUILD)
+//for release builds
+#define OSCL_LIBRARY_PERF_LOGGING 0
+#else
+//for debug builds
+#define OSCL_LIBRARY_PERF_LOGGING 1
+#endif
+#endif
+
+
+#if OSCL_LIBRARY_PERF_LOGGING
+#define TICK uint32
+#define SET_TICK(tick1) tick1 = OsclTickCount::TickCount()
+#define DIFF_TICK(tick1,diff) TICK tick2; SET_TICK(tick2);diff = tick2 - tick1
+#endif
 
 #endif //OSCL_LIBRARY_COMMON_H_INCLUDED
 
diff --git a/oscl/oscl/oscllib/src/oscl_library_list.cpp b/oscl/oscl/oscllib/src/oscl_library_list.cpp
index dd5a71d..2904a35 100644
--- a/oscl/oscl/oscllib/src/oscl_library_list.cpp
+++ b/oscl/oscl/oscllib/src/oscl_library_list.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,11 @@
 OSCL_EXPORT_REF OsclLibraryList::OsclLibraryList()
 {
     ipLogger = PVLogger::GetLoggerObject("oscllib");
+#if OSCL_LIBRARY_PERF_LOGGING
+    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.oscllibrarylist");
+    iLinesRead = 0;
+    iLibHit = 0;
+#endif
     int32 err = 0;
     OSCL_TRY(err,
              iLibList.reserve(OSCL_NUMBER_OF_SHARED_LIBS);
@@ -49,41 +54,58 @@
 
 OSCL_EXPORT_REF OsclLibraryList::~OsclLibraryList()
 {
+#if OSCL_LIBRARY_PERF_LOGGING
+    iDiagnosticsLogger = NULL;
+#endif
     ipLogger = NULL;
     iLibList.clear();
 }
 
-//This method actually parses through the dll config file, retrieving the paths,
-//of dlls which implement a specific OsclUuid
-OSCL_EXPORT_REF OsclLibStatus OsclLibraryList::Populate(const OsclUuid& aInterfaceId, const OSCL_String& aConfigFilePath)
+//  This method actually parses through a dll config file, retrieving the paths
+// of dlls which implement a specific OsclUuid
+OSCL_EXPORT_REF OsclLibStatus OsclLibraryList::Populate(const OsclUuid& aInterfaceId, const OSCL_String& aConfigFile)
 {
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
+                    (0, "OsclLibraryList::Populate '%s' IN", aConfigFile.get_cstr()));
+
     // Open config file
     Oscl_FileServer fileserver;
     if (0 != fileserver.Connect())
     {
         // Failed to connect to file server, return failure
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_ERR,
-                        (0, "OsclLibraryList::Populate - Unable to connect to fileserver\n"));
+                        (0, "OsclLibraryList::Populate - Unable to connect to fileserver"));
         return OsclLibFail;
     }
     Oscl_File configFile;
-    if (0 != configFile.Open(aConfigFilePath.get_cstr(), Oscl_File::MODE_READ, fileserver))
+    if (0 != configFile.Open(aConfigFile.get_cstr(), Oscl_File::MODE_READ, fileserver))
     {
         // Failed to open config file, return failure
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_ERR,
-                        (0, "OsclLibraryList::Populate - Unable to open configFile %s\n", aConfigFilePath.get_cstr()));
+                        (0, "OsclLibraryList::Populate - Unable to open configFile %s", aConfigFile.get_cstr()));
         return OsclLibFail;
     }
 
+#if OSCL_LIBRARY_PERF_LOGGING
+    // Start collecting stats for current config file
+    iLinesRead = 0;
+    iLibHit = 0;
+    TICK starttime;
+    SET_TICK(starttime);
+#endif
+
     // Read in a byte at a time
     uint8 buf[1];
     while (1 == configFile.Read(buf, 1, 1))
     {
         if (HASH == buf[0])
         {
+#if OSCL_LIBRARY_PERF_LOGGING
+            iLinesRead++;
+#endif
             // Ignore comments - begin with '#'
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                            (0, "OsclLibraryList::Populate - Found a comment, skipping\n"));
+                            (0, "OsclLibraryList::Populate - Found a comment, skipping"));
             // Advance to end of line
             while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE)
             {
@@ -97,7 +119,7 @@
             int i = 0;
             uuidBuf[i++] = buf[0];
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                            (0, "OsclLibraryList::Populate - Found a (, reading uuid\n"));
+                            (0, "OsclLibraryList::Populate - Found a (, reading uuid"));
             // Read a character at a time - stop if newline or eof is reached or buffer is filled
             while (i < BUFFER_SIZE && 1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE)
             {
@@ -107,18 +129,22 @@
                     break;
                 }
             }
+            uuidBuf[i] = '\0';
             if (NEWLINE == buf[0])
             {
+#if OSCL_LIBRARY_PERF_LOGGING
+                iLinesRead++;
+#endif
                 // Reached the end of line but did not find the closing parentheses
                 // Skip this malformed line
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                (0, "OsclLibraryList::Populate - incomplete uuid, skipping line\n"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING,
+                                (0, "OsclLibraryList::Populate - incomplete uuid, skipping line"));
             }
             else if (BUFFER_SIZE == i && CLOSE_PAREN != buf[0])
             {
                 // Buffer is filled but did not reach the end of UUID - skip this malformed line
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                (0, "OsclLibraryList::Populate - uuid too long, skipping line\n"));
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING,
+                                (0, "OsclLibraryList::Populate - uuid too long, skipping line"));
                 // Advance to end of line
                 while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE)
                 {
@@ -128,7 +154,6 @@
             else
             {
                 // Create an instance of OsclUuid
-                uuidBuf[i] = '\0';
                 OsclUuid tempUuidStr((char*)uuidBuf);
                 if (tempUuidStr == aInterfaceId)
                 {
@@ -153,9 +178,12 @@
                     }
                     if (!(commaFound && quoteFound) || NEWLINE == buf[0])
                     {
+#if OSCL_LIBRARY_PERF_LOGGING
+                        iLinesRead++;
+#endif
                         // Did not find both ',' and '"' - Skip this malformed line
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                        (0, "OsclLibraryList::Populate - missing ' or \", skipping line\n"));
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING,
+                                        (0, "OsclLibraryList::Populate - missing ' or \", skipping line"));
                     }
                     else
                     {
@@ -169,16 +197,22 @@
                         }
                         if (NEWLINE == buf[0])
                         {
+#if OSCL_LIBRARY_PERF_LOGGING
+                            iLinesRead++;
+#endif
                             // Reached the end of line but did not find the closing quote
                             // Skip this malformed line
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                            (0, "OsclLibraryList::Populate - incomplete path, skipping line\n"));
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING,
+                                            (0, "OsclLibraryList::Populate - incomplete path, skipping line"));
                         }
                         else if ((BUFFER_SIZE - 1) == i && QUOTE != buf[0])
                         {
                             // Buffer is filled but did not reach the end of path - skip this malformed line
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                            (0, "OsclLibraryList::Populate - path too long, skipping line\n"));
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_WARNING,
+                                            (0, "OsclLibraryList::Populate - path too long, skipping line"));
+#if OSCL_LIBRARY_PERF_LOGGING
+                            iLinesRead++;
+#endif
                             // Advance to end of line
                             while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE)
                             {
@@ -189,19 +223,26 @@
                         {
                             // Read in the path, end with terminating character
                             pathBuf[i] = NULL_TERM_CHAR;
-                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                            (0, "OsclLibraryList::Populate - found a match, adding to list: %s\n",
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_INFO,
+                                            (0, "OsclLibraryList::Populate - found a match, adding to list: %s",
                                              (char*)pathBuf));
                             // Add path to library list
                             iLibList.push_back((char*)pathBuf);
+#if OSCL_LIBRARY_PERF_LOGGING
+                            iLibHit++;
+                            iLinesRead++;
+#endif
                         }
                     }
                 }
                 else
                 {
                     // The UUID from this line does not match aInterfaceId - Advance to end of line
-                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG,
-                                    (0, "OsclLibraryList::Populate - uuid not a match, skipping line\n"));
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_INFO,
+                                    (0, "OsclLibraryList::Populate - uuid not a match, skipping line"));
+#if OSCL_LIBRARY_PERF_LOGGING
+                    iLinesRead++;
+#endif
                     while (1 == configFile.Read(buf, 1, 1) && buf[0] != NEWLINE)
                     {
                         // ignore
@@ -212,6 +253,20 @@
         // else continue on to next byte
     };
 
+#if OSCL_LIBRARY_PERF_LOGGING
+    // End stats for current config file
+    uint32 difftime;
+    DIFF_TICK(starttime, difftime);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                    (0, "OsclLibraryList::Populate - Parsing configFile %s ...", aConfigFile.get_cstr()));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                    (0, "                                   Time taken = %d ticks", difftime));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                    (0, "                                   Lines read = %d", iLinesRead));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                    (0, "                                   Libraries found = %d", iLibHit));
+#endif
+
     //If there's atleast one library path name loaded in the vector,
     //it means the parsing is successful for at least a particular OsclUuid
 
diff --git a/oscl/oscl/oscllib/src/oscl_library_list.h b/oscl/oscl/oscllib/src/oscl_library_list.h
index bf920e0..831384c 100644
--- a/oscl/oscl/oscllib/src/oscl_library_list.h
+++ b/oscl/oscl/oscllib/src/oscl_library_list.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,11 +57,11 @@
          * Populate the list for the given interface ID.
          *
          * @param aInterfaceId ID to find the list of libraries for.
-         * @param aConfigFilePath - Location of the DLL Config file
+         * @param aConfigFile - DLL Config file
          *
          * @returns OsclLibStatus about whether the librarylist vector got populated or not
          **/
-        OSCL_IMPORT_REF OsclLibStatus Populate(const OsclUuid& aInterfaceId, const OSCL_String& aConfigFilePath);
+        OSCL_IMPORT_REF OsclLibStatus Populate(const OsclUuid& aInterfaceId, const OSCL_String& aConfigFile);
 
         /**
         * Get the number of libraries in the list.
@@ -80,6 +80,11 @@
     private:
         Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iLibList;
         PVLogger* ipLogger;
+#if OSCL_LIBRARY_PERF_LOGGING
+        PVLogger* iDiagnosticsLogger;
+        uint32 iLibHit;
+        uint32 iLinesRead;
+#endif
 };
 
 #endif //OSCL_LIBRARY_LIST_H_INCLUDED
diff --git a/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h b/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h
index f586d7c..772a9f6 100644
--- a/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h
+++ b/oscl/oscl/oscllib/src/oscl_shared_lib_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/oscllib/src/oscl_shared_library.cpp b/oscl/oscl/oscllib/src/oscl_shared_library.cpp
index 0858de2..58629ca 100644
--- a/oscl/oscl/oscllib/src/oscl_shared_library.cpp
+++ b/oscl/oscl/oscllib/src/oscl_shared_library.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#include "osclconfig_lib.h"
 #include "oscl_shared_library.h"
 #include "oscl_string.h"
 #include "pvlogger.h"
@@ -24,13 +25,18 @@
 
 #define BUFFER_SIZE 256
 
-typedef void* (*GetInterface_t)();
-
+typedef OsclSharedLibraryInterface*(*PVGetInterface_t)();
+typedef void (*PVReleaseInterface_t)(OsclSharedLibraryInterface*);
 
 OSCL_EXPORT_REF OsclSharedLibrary::OsclSharedLibrary()
 {
     ipLogger = PVLogger::GetLoggerObject("oscllib");
-
+#if OSCL_LIBRARY_PERF_LOGGING
+    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.osclsharedlibrary");
+    iLibCount = 0;
+    iLibLoadTime = 0;
+#endif
+    pSharedLibInterface = NULL;
     iRefCount = 0;
     ipHandle = NULL;
 
@@ -39,14 +45,25 @@
 OSCL_EXPORT_REF OsclSharedLibrary::OsclSharedLibrary(const OSCL_String& aPath)
 {
     ipLogger = PVLogger::GetLoggerObject("oscllib");
+#if OSCL_LIBRARY_PERF_LOGGING
+    iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.oscllib.osclsharedlibrary");
+    iLibCount = 0;
+    iLibLoadTime = 0;
+#endif
+    pSharedLibInterface = NULL;
 
     iRefCount = 0;
     ipHandle = NULL;
-    iLibPath.set(aPath.get_cstr(), oscl_strlen(aPath.get_cstr()));
+    iLibPath = aPath;
 }
 
 OSCL_EXPORT_REF OsclSharedLibrary::~OsclSharedLibrary()
 {
+#if OSCL_LIBRARY_PERF_LOGGING
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                    (0, "OsclSharedLibrary - Loading %d libraries took %d ticks ...", iLibCount, iLibLoadTime));
+    iDiagnosticsLogger = NULL;
+#endif
     ipLogger = NULL;
 
     if (NULL != ipHandle)
@@ -57,36 +74,125 @@
 
 OSCL_EXPORT_REF OsclLibStatus OsclSharedLibrary::LoadLib(const OSCL_String& aPath)
 {
-    iLibPath.set(aPath.get_cstr(), oscl_strlen(aPath.get_cstr()));
-
-    // Clear any errors
-    dlerror();
-    // Open the library
-    void* library = dlopen(aPath.get_cstr(), RTLD_NOW);
-    // dlopen() returns NULL if there were any issues opening the library
-    if (NULL == library)
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib %s IN", aPath.get_cstr()));
+#if OSCL_LIBRARY_PERF_LOGGING
+    iLibCount++;
+    TICK starttime;
+    SET_TICK(starttime);
+#endif
+    iLibPath = aPath;
+    // First look for debug version of the library ending with _debug
+    int32 dotpos = aPath.get_size() - 1;
+    while (dotpos >= 0)
     {
-        // check for errors
-        const char* pErr = dlerror();
-        if (NULL == pErr)
+        if (aPath[dotpos] == '.')
+            break;
+        dotpos--;
+    }
+    if (dotpos >= 0 && dotpos != (int32)(aPath.get_size() - 1))
+    {   // extension exists
+#if OSCL_LIB_READ_DEBUG_LIBS
+        OSCL_HeapString<OsclMemAllocator> path1(aPath.get_cstr(), dotpos);
+        OSCL_HeapString<OsclMemAllocator> debugPath(path1);
+        debugPath += "_debug";
+        debugPath += (aPath.get_cstr() + dotpos);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib looking for Debug lib %s", debugPath.get_cstr()));
+        // Open the library
+        if (OsclLibSuccess == loadlibrary(debugPath))
         {
-            // No error reported, but no handle to the library
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
-                            (0, "OsclLib::LoadLibrary: Error opening "
-                             "library (%s) but no error reported\n",
-                             aPath.get_cstr(), pErr));
+#if OSCL_LIBRARY_PERF_LOGGING
+            DIFF_TICK(starttime, delta);
+            iLibLoadTime += delta;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                            (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta));
+#endif
+            return OsclLibSuccess;  // debug dll loaded successfully
         }
-        else
+        // _debug load failed, try original
+#endif
+        if (OsclLibSuccess ==  loadlibrary(aPath))
         {
-            // Error reported
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
-                            (0, "OsclLib::LoadLibrary: Error opening "
-                             "library (%s): %s\n", aPath.get_cstr(), pErr));
+#if OSCL_LIBRARY_PERF_LOGGING
+            DIFF_TICK(starttime, delta);
+            iLibLoadTime += delta;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                            (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", aPath.get_cstr(), delta));
+#endif
+            return OsclLibSuccess;
         }
         return OsclLibFail;
     }
-    ipHandle = library;
-    return OsclLibSuccess;
+    else if (dotpos == (int32)(aPath.get_size() - 1))
+    {   // libname ended with "." no extension
+        OSCL_HeapString<OsclMemAllocator> path1(aPath.get_cstr(), dotpos);
+        OSCL_HeapString<OsclMemAllocator> debugPath(path1);
+#if OSCL_LIB_READ_DEBUG_LIBS
+        debugPath += "_debug.";
+        debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib looking for Debug lib %s", debugPath.get_cstr()));
+        // Open the library
+        if (OsclLibSuccess == loadlibrary(debugPath))
+        {
+#if OSCL_LIBRARY_PERF_LOGGING
+            DIFF_TICK(starttime, delta);
+            iLibLoadTime += delta;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                            (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta));
+#endif
+            return OsclLibSuccess;  // debug dll loaded successfully
+        }
+        // _debug load failed, try original
+        debugPath = path1;
+#endif
+        debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION;
+        if (OsclLibSuccess ==  loadlibrary(debugPath))
+        {
+#if OSCL_LIBRARY_PERF_LOGGING
+            DIFF_TICK(starttime, delta);
+            iLibLoadTime += delta;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                            (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta));
+#endif
+            return OsclLibSuccess;
+        }
+        return OsclLibFail;
+    }
+    else    // libname without extension
+    {
+        OSCL_HeapString<OsclMemAllocator> path1(aPath.get_cstr());
+        OSCL_HeapString<OsclMemAllocator> debugPath(path1);
+#if OSCL_LIB_READ_DEBUG_LIBS
+        debugPath += "_debug.";
+        debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::LoadLib looking for Debug lib %s", debugPath.get_cstr()));
+        // Open the library
+        if (OsclLibSuccess == loadlibrary(debugPath))
+        {
+#if OSCL_LIBRARY_PERF_LOGGING
+            DIFF_TICK(starttime, delta);
+            iLibLoadTime += delta;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                            (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta));
+#endif
+            return OsclLibSuccess;  // debug dll loaded successfully
+        }
+        // _debug load failed, try original
+        debugPath = path1;
+#endif
+        debugPath += ".";
+        debugPath += PV_RUNTIME_LIB_FILENAME_EXTENSION;
+        if (OsclLibSuccess ==  loadlibrary(debugPath))
+        {
+#if OSCL_LIBRARY_PERF_LOGGING
+            DIFF_TICK(starttime, delta);
+            iLibLoadTime += delta;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iDiagnosticsLogger, PVLOGMSG_INFO,
+                            (0, "OsclSharedLibrary - Loading library %s took %d ticks ...", debugPath.get_cstr(), delta));
+#endif
+            return OsclLibSuccess;
+        }
+        return OsclLibFail;
+    }
 
 }
 
@@ -97,24 +203,23 @@
 
 OSCL_EXPORT_REF void OsclSharedLibrary::SetLibPath(const OSCL_String& aPath)
 {
-    iLibPath.set(aPath.get_cstr(), oscl_strlen(aPath.get_cstr()));
+    iLibPath = aPath;
 }
 
 OSCL_EXPORT_REF OsclLibStatus OsclSharedLibrary::QueryInterface(const OsclUuid& aInterfaceId,
         OsclAny*& aInterfacePtr)
 {
-    OsclSharedLibraryInterface *pSharedLibInterface = NULL;
     aInterfacePtr = NULL;
-    // Look up the GetInterface method
+    // Look up the PVGetInterface method
     if (NULL == ipHandle)
     {
-        return OsclLibFail;
+        return OsclLibNotLoaded;
     }
-    GetInterface_t GetInterface =
-        (GetInterface_t)dlsym(ipHandle, "GetInterface");
+    PVGetInterface_t getInterface =
+        (PVGetInterface_t)dlsym(ipHandle, "PVGetInterface");
     // dlsym() returns NULL if there were any issues getting the
     // address of the symbol
-    if (NULL == GetInterface)
+    if (NULL == getInterface)
     {
         // check for errors
         const char* pErr = dlerror();
@@ -122,21 +227,25 @@
         {
             // No error reported, but no symbol was found
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO,
-                            (0, "OsclLib::QueryInterface: Could not access GetInterface "
-                             "symbol in library but no error reported\n"));
+                            (0, "OsclLib::QueryInterface: Could not access PVGetInterface "
+                             "symbol in library but no error reported"));
         }
         else
         {
             // Error reported
             PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO,
-                            (0, "OsclLib::QueryInterface: Could not access GetInterface "
-                             "symbol in library: %s\n", pErr));
+                            (0, "OsclLib::QueryInterface: Could not access PVGetInterface "
+                             "symbol in library: %s", pErr));
         }
         return OsclLibFail;
     }
 
-    // Get the OsclSharedLibraryInterface
-    pSharedLibInterface = (OsclSharedLibraryInterface*)GetInterface();
+    // Get the OsclSharedLibraryInterface if needed.  There can be multiple calls
+    // to query interface so check whether the interface has already been fetched.
+    if (!pSharedLibInterface)
+    {
+        pSharedLibInterface = (OsclSharedLibraryInterface*)getInterface();
+    }
     if (NULL == pSharedLibInterface)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO,
@@ -161,29 +270,57 @@
     {
         return OsclLibFail;
     }
+    if (pSharedLibInterface)
+    {
+        PVReleaseInterface_t releaseInterface =
+            (PVReleaseInterface_t)dlsym(ipHandle, "PVReleaseInterface");
+        // dlsym() returns NULL if there were any issues getting the
+        // address of the symbol
+        if (NULL == releaseInterface)
+        {
+            // check for errors
+            const char* pErr = dlerror();
+            if (NULL == pErr)
+            {
+                // No error reported, but no symbol was found
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO,
+                                (0, "OsclLib::Close: Could not access PVReleaseInterface "
+                                 "symbol in library but no error reported"));
+            }
+            else
+            {
+                // Error reported
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_INFO,
+                                (0, "OsclLib::Close: Could not access PVReleaseInterface "
+                                 "symbol in library: %s", pErr));
+            }
+            return OsclLibFail;
+        }
+        releaseInterface(pSharedLibInterface);
+        pSharedLibInterface = NULL;
+    }
 
-    if (NULL == ipHandle)
+    if (ipHandle)
     {
-        return OsclLibFail;
-    }
-    if (0 != dlclose(ipHandle))
-    {
-        // dlclose() returns non-zero value if close failed, check for errors
-        const char* pErr = dlerror();
-        if (NULL != pErr)
+        if (0 != dlclose(ipHandle))
         {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
-                            (0, "OsclSharedLibrary::Close: Error closing library: %s\n", pErr));
+            // dlclose() returns non-zero value if close failed, check for errors
+            const char* pErr = dlerror();
+            if (NULL != pErr)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
+                                (0, "OsclSharedLibrary::Close: Error closing library: %s", pErr));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
+                                (0, "OsclSharedLibrary::Close: Error closing library, no error reported"
+                                 ""));
+            }
+            return OsclLibFail;
         }
-        else
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
-                            (0, "OsclSharedLibrary::Close: Error closing library, no error reported"
-                             "\n"));
-        }
-        return OsclLibFail;
+        ipHandle = NULL;
     }
-    ipHandle = NULL;
     return OsclLibSuccess;
 }
 
@@ -197,3 +334,111 @@
     --iRefCount;
 }
 
+//
+//OsclSharedLibraryList
+//
+#include "oscl_configfile_list.h"
+#include "oscl_library_list.h"
+
+OSCL_EXPORT_REF OsclSharedLibraryList::OsclSharedLibraryList()
+{
+    iLogger = PVLogger::GetLoggerObject("oscllib");
+}
+
+OSCL_EXPORT_REF OsclSharedLibraryList::~OsclSharedLibraryList()
+{
+    CloseAll();
+}
+/*
+** Give a config file path, search all config files for libraries that
+** support the given interface ID.
+*/
+OSCL_EXPORT_REF void OsclSharedLibraryList::Populate(const OSCL_String& aPath, const OsclUuid& aInterfaceId)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
+                    (0, "OsclSharedLibraryList::Populate '%s' IN", aPath.get_cstr()));
+
+    iInterfaceId = aInterfaceId;
+    OsclConfigFileList configFileList;
+    configFileList.Populate(aPath);
+    for (uint32 i = 0;i < configFileList.Size();i++)
+    {
+        OsclLibraryList libList;
+        libList.Populate(aInterfaceId, configFileList.GetConfigfileAt(i));
+        for (uint32 j = 0;j < libList.Size();j++)
+        {
+            OsclSharedLibrary* sharedLib = OSCL_NEW(OsclSharedLibrary, (libList.GetLibraryPathAt(j)));
+            iList.push_back(sharedLib);
+        }
+    }
+}
+
+/*
+** Query interface for the given library.
+*/
+OSCL_EXPORT_REF OsclLibStatus OsclSharedLibraryList::QueryInterfaceAt(uint32 aIndex, OsclAny*& aInterfacePtr)
+{
+    aInterfacePtr = NULL;
+    OsclLibStatus status = OsclLibFail;
+
+    if (aIndex < iList.size())
+    {
+        status = iList[aIndex]->QueryInterface(iInterfaceId, aInterfacePtr);
+        //Load lib if needed & repeat the query.
+        if (status == OsclLibNotLoaded)
+        {
+            status = iList[aIndex]->LoadLib();
+            if (status == OsclLibSuccess)
+                status = iList[aIndex]->QueryInterface(iInterfaceId, aInterfacePtr);
+        }
+    }
+    return status;
+}
+
+/*
+** Close all open libraries
+*/
+OSCL_EXPORT_REF void OsclSharedLibraryList::CloseAll()
+{
+    while (!iList.empty())
+    {
+        iList.front()->Close();
+        OSCL_DELETE(iList.front());
+        iList.erase(&iList.front());
+    }
+}
+
+OsclLibStatus OsclSharedLibrary::loadlibrary(const OSCL_String& alib)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, ipLogger, PVLOGMSG_DEBUG, (0, "OsclSharedLibrary::loadlibrary %s IN", alib.get_cstr()));
+    // Clear any errors
+    dlerror();
+    // Open the library
+    void* library = dlopen(alib.get_cstr(), RTLD_NOW);
+    // dlopen() returns NULL if there were any issues opening the library
+    if (NULL == library)
+    {
+        // check for errors
+        const char* pErr = dlerror();
+        if (NULL == pErr)
+        {
+            // No error reported, but no handle to the library
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
+                            (0, "OsclLib::loadlibrary: Error opening "
+                             "library (%s) but no error reported",
+                             alib.get_cstr(), pErr));
+        }
+        else
+        {
+            // Error reported
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, ipLogger, PVLOGMSG_WARNING,
+                            (0, "OsclLib::loadlibrary: Error opening "
+                             "library (%s): %s", alib.get_cstr(), pErr));
+        }
+        return OsclLibFail;
+    }
+    ipHandle = library;
+    return OsclLibSuccess;
+
+}
+
diff --git a/oscl/oscl/oscllib/src/oscl_shared_library.h b/oscl/oscl/oscllib/src/oscl_shared_library.h
index f43466e..510355c 100644
--- a/oscl/oscl/oscllib/src/oscl_shared_library.h
+++ b/oscl/oscl/oscllib/src/oscl_shared_library.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,10 @@
 #ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
 #define OSCL_SHARED_LIBRARY_H_INCLUDED
 
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
 #include "oscl_string_containers.h"
 #endif
@@ -113,10 +117,63 @@
         OSCL_IMPORT_REF void RemoveRef();
 
     private:
+        OsclLibStatus loadlibrary(const OSCL_String& alib);
+
         PVLogger* ipLogger;
         int32 iRefCount;
+        OsclSharedLibraryInterface *pSharedLibInterface;
+#if OSCL_LIBRARY_PERF_LOGGING
+        PVLogger* iDiagnosticsLogger;
+        uint32 iLibCount;
+        uint32 iLibLoadTime;
+        uint32 delta;
+#endif
         void* ipHandle;
         OSCL_HeapString<OsclMemAllocator> iLibPath;
+        bool iLoaded;
+};
+
+#include "oscl_vector.h"
+
+/*
+** OsclSharedLibraryList is a handy class for locating and using libraries that support
+** a given interface.
+*/
+class OsclSharedLibraryList
+{
+    public:
+        OSCL_IMPORT_REF OsclSharedLibraryList();
+        OSCL_IMPORT_REF ~OsclSharedLibraryList();
+
+        /*
+        ** Give a config file directory, locate all the libraries that support the given
+        ** interface ID.  For each library, create a shared library object for it and add
+        ** it to the list.
+        */
+        OSCL_IMPORT_REF void Populate(const OSCL_String& aPath, const OsclUuid& aInterfaceId);
+
+        /*
+        ** Return the size of the list
+        */
+        uint32 Size()
+        {
+            return iList.size();
+        }
+
+        /*
+        ** Query interface for the given library.  This will load the library if needed.
+        */
+        OSCL_IMPORT_REF OsclLibStatus QueryInterfaceAt(uint32 aIndex, OsclAny*& aInterfacePtr);
+
+        /*
+        ** Close all open libraries and clear the list.
+        */
+        OSCL_IMPORT_REF void CloseAll();
+
+    private:
+        Oscl_Vector<OsclSharedLibrary*, OsclMemAllocator> iList;
+        OsclUuid iInterfaceId;
+        PVLogger* iLogger;
 };
 
 #endif //OSCL_SHARED_LIBRARY_H_INCLUDED
diff --git a/oscl/oscl/osclmemory/Android.mk b/oscl/oscl/osclmemory/Android.mk
index 390f011..39f2ca2 100644
--- a/oscl/oscl/osclmemory/Android.mk
+++ b/oscl/oscl/osclmemory/Android.mk
@@ -3,30 +3,33 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_mem.cpp \
-	src/oscl_mem_imp.cpp \
-	src/oscl_mem_audit.cpp \
-	src/oscl_mem_mempool.cpp
-
+ 	src/oscl_mem_imp.cpp \
+ 	src/oscl_mem_audit.cpp \
+ 	src/oscl_mem_mempool.cpp
 
 
 LOCAL_MODULE := libosclmemory
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclmemory/src \
-	$(PV_TOP)//oscl/oscl/osclmemory/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclmemory/src \
+ 	$(PV_TOP)/oscl/oscl/osclmemory/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_mem.h \
-	src/oscl_mem_audit.h \
-	src/oscl_mem_auto_ptr.h \
-	src/oscl_mem_mempool.h \
-	src/oscl_mem.inl
+ 	src/oscl_mem_audit.h \
+ 	src/oscl_mem_auto_ptr.h \
+ 	src/oscl_mem_mempool.h \
+ 	src/oscl_mem.inl
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclmemory/build/make/local.mk b/oscl/oscl/osclmemory/build/make/local.mk
new file mode 100644
index 0000000..e9c11db
--- /dev/null
+++ b/oscl/oscl/osclmemory/build/make/local.mk
@@ -0,0 +1,27 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+TARGET := osclmemory
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS :=  oscl_mem.cpp \
+	oscl_mem_imp.cpp \
+	oscl_mem_audit.cpp \
+	oscl_mem_mempool.cpp
+
+HDRS :=  oscl_mem.h \
+	oscl_mem_audit.h \
+	oscl_mem_auto_ptr.h \
+	oscl_mem_mempool.h \
+	oscl_mem.inl 
+
+include $(MK)/library.mk
+
diff --git a/oscl/oscl/osclmemory/build/make/makefile b/oscl/oscl/osclmemory/build/make/makefile
deleted file mode 100644
index f0f9723..0000000
--- a/oscl/oscl/osclmemory/build/make/makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclmemory
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-#XINCDIRS += -I../../osclBase/src -I../../osclUtil/src 
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  oscl_mem.cpp \
-	oscl_mem_imp.cpp \
-	oscl_mem_audit.cpp \
-	oscl_mem_mempool.cpp
-
-HDRS =  oscl_mem.h \
-	oscl_mem_audit.h \
-	oscl_mem_auto_ptr.h \
-	oscl_mem_mempool.h \
-	oscl_mem.inl 
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/oscl/oscl/osclmemory/src/oscl_mem.cpp b/oscl/oscl/osclmemory/src/oscl_mem.cpp
index cc3822c..48cd05b 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem.cpp
+++ b/oscl/oscl/osclmemory/src/oscl_mem.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclmemory/src/oscl_mem.h b/oscl/oscl/osclmemory/src/oscl_mem.h
index b59fea0..9c19816 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem.h
+++ b/oscl/oscl/osclmemory/src/oscl_mem.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,6 +70,10 @@
 #include "oscl_mem_inst.h"
 #endif
 
+#ifndef OSCL_HEAPBASE_H_INCLUDED
+#include "oscl_heapbase.h"
+#endif
+
 //Default for OSCL_HAS_GLOBAL_NEW_DELETE in case it is *not* defined
 //in the osclconfig_memory.h
 #ifndef OSCL_HAS_GLOBAL_NEW_DELETE
@@ -94,18 +98,19 @@
         **      If no lock is provided, the memory manager will not be thread-safe.
         ** @exception: Leaves on error
         */
-        OSCL_IMPORT_REF static void Init(OsclLockBase* lock = NULL);
+        OSCL_IMPORT_REF static void Init();
 
         /** Per-thread cleanup of Oscl Memory
         ** @exception: Leaves on error;
         */
         OSCL_IMPORT_REF static void Cleanup();
 
-        /* API to obtain the Lock - needed for thread-safe operation when other threads are created */
-        OSCL_IMPORT_REF static OsclLockBase *GetLock();
-
 };
 
+/*
+** Choose whether to use per-thread or singleton registry for auditing
+*/
+#include "oscl_base.h"
 
 /*
 ** Audit control block
@@ -124,12 +129,10 @@
     public:
         const OsclMemStatsNode* pStatsNode;
         OsclMemAudit *pAudit;
-        OsclLockBase *pLock;
 
         OsclAuditCB() :
                 pStatsNode(NULL),
-                pAudit(NULL) ,
-                pLock(NULL)
+                pAudit(NULL)
         {}
 
         OsclAuditCB(const OsclMemStatsNode* myStatsNode,
@@ -630,16 +633,6 @@
     if(ptr){delete(ptr);}\
 }
 
-/**
- * Oscl "delete" operator.
- *
- * @param ptr pointer to memory block previously allocated with OSCL_NEW
- *
- * @return void
- */
-#define OSCL_TEMPLATED_DELETE(ptr, T, Tsimple) {\
-    if(ptr){delete(ptr);}\
-}
 
 /** *******************************************************
  * Macros for array new/delete with memory management.
@@ -923,7 +916,7 @@
         /**
          * creates the global audit object
          */
-        static void createGlobalMemAuditObject(OsclLockBase*);
+        static void createGlobalMemAuditObject();
 
         /**
          * deletes the global audit object
@@ -938,29 +931,33 @@
 *
 * HeapBase has overloaded new and delete operators.
 *
+* Derived from _OsclHeapBase providing CBase* alike pointer and virtual destructor for cleanupstack
+* to Push and Pop for cleanup when leave occurs.
+*
 * HeapBase has a virtual destructor which calls the destructor of all the derived classes.
 */
 
-class HeapBase
+class HeapBase : public _OsclHeapBase
 {
     public:
 #if (OSCL_HAS_HEAP_BASE_SUPPORT)
 
+#if(!OSCL_BYPASS_MEMMGT)
         static void* operator new(size_t aSize, const char *aFile = NULL, const int aLine = 0)
         {
-#if(!OSCL_BYPASS_MEMMGT)
 #if(PVMEM_INST_LEVEL>0)
             //in case NULL is passed in, record this file & line #
             if (!aFile)
                 return _oscl_default_audit_new(aSize, __FILE__, __LINE__);
 #endif
             return _oscl_default_audit_new(aSize, aFile, aLine);
-#else
-            OSCL_UNUSED_ARG(aFile);
-            OSCL_UNUSED_ARG(aLine);
-            return _oscl_default_new(aSize);
-#endif
         }
+#else
+        static void* operator new(size_t aSize)
+        {
+            return _oscl_default_new(aSize);
+        }
+#endif
 
         static void* operator new[](size_t aSize)
         {
diff --git a/oscl/oscl/osclmemory/src/oscl_mem.inl b/oscl/oscl/osclmemory/src/oscl_mem.inl
index ac118a9..4dcd304 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem.inl
+++ b/oscl/oscl/osclmemory/src/oscl_mem.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp b/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp
index 21e85ea..ff6b9c3 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp
+++ b/oscl/oscl/osclmemory/src/oscl_mem_audit.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1068,9 +1068,9 @@
         static_cast<MM_AllocBlockFence*>(static_cast<void*>(pMem +
                                          CONTROL_HEADER_SIZE));
     status = fence->check_fence();
-    OSCL_ASSERT(status);
     if (!status)
     {
+        OSCL_ASSERT(status);
         return status;
     }
 
@@ -1080,9 +1080,9 @@
                                          BLOCK_HDR_SIZE
                                          + size));
     status = fence->check_fence();
-    OSCL_ASSERT(status);
     if (!status)
     {
+        OSCL_ASSERT(status);
         return status;
     }
 #endif
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_audit.h b/oscl/oscl/osclmemory/src/oscl_mem_audit.h
index 973cb9a..42d4822 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_audit.h
+++ b/oscl/oscl/osclmemory/src/oscl_mem_audit.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -778,16 +778,15 @@
         /**
         *	Constructor, create the root node in statistics table
         */
-        OsclMemAudit(OsclLockBase *lock)
+        OsclMemAudit()
         {
             void * p = _oscl_malloc(sizeof(MM_Audit_Imp));
             OsclError::LeaveIfNull(p);
 
             // this will invoke system placement new operator
             _pMM_Audit_Imp = OSCL_PLACEMENT_NEW(p, MM_Audit_Imp());
-            iLock = lock;
-            if (!iLock)
-                iLock = &iNullLock;
+            iLock = &iSingletonLock;
+            iRefCount = 1;
         };
 
         /**
@@ -1115,6 +1114,15 @@
             iLock->Unlock();
         };
 
+        int32 MM_GetRefCount()
+        {
+            int32 count;
+            iLock->Lock();
+            count = iRefCount;
+            iLock->Unlock();
+            return count;
+        }
+
         /**
         *	API to obtain mem lock ptr
         *
@@ -1260,12 +1268,15 @@
         * The following are private data members
         */
 
-        /**
-        *  Use OSCL thread version
-        */
-        OsclLockBase *iLock;
         MM_Audit_Imp *_pMM_Audit_Imp;
-        OsclNullLock iNullLock;//default
+        OsclLockBase *iLock;
+
+        /**
+        *  Use OSCL singleton version
+        */
+        _OsclBasicLock iSingletonLock;
+        int32 iRefCount;
+        friend class OsclMemGlobalAuditObject;
 
 };
 #endif
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h b/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h
index 8eaff47..ad1cc0e 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h
+++ b/oscl/oscl/osclmemory/src/oscl_mem_audit_internals.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h b/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h
index 696c662..82f6925 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h
+++ b/oscl/oscl/osclmemory/src/oscl_mem_auto_ptr.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp b/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp
index 12c9004..e313523 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp
+++ b/oscl/oscl/osclmemory/src/oscl_mem_imp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,12 +27,10 @@
 //////////////////////
 
 
-OSCL_EXPORT_REF void OsclMem::Init(OsclLockBase*lock)
+OSCL_EXPORT_REF void OsclMem::Init()
 {
 #if(!OSCL_BYPASS_MEMMGT)
-    OsclMemGlobalAuditObject::createGlobalMemAuditObject(lock);
-#else
-    OSCL_UNUSED_ARG(lock);
+    OsclMemGlobalAuditObject::createGlobalMemAuditObject();
 #endif
 }
 
@@ -63,64 +61,55 @@
 
 #include "oscl_mem_audit.h"
 
-// the version of GetLock() for !OSCL_BYPASS_MEMMGT returns the actual lock (even though the lock itself
-//	could be NULL
-// the version of GetLock() for OSCL_BYPASS_MEMMGT always returns NULL
-OSCL_EXPORT_REF OsclLockBase* OsclMem::GetLock()
-{
+#include "oscl_singleton.h"
 
-    OsclMemGlobalAuditObject::audit_type* audit = OsclMemGlobalAuditObject::getGlobalMemAuditObject();
-
-    return audit->GetLock();
-}
 //////////////////////
 // OsclMemGlobalAuditObject
 //////////////////////
 
-//Note: The memory stats are maintained in each thread, although
-// allocation and deallocation can occur in different threads.
-
-//Need an appropriate registry
-#include "oscl_error.h"
-// TLS registry is available, use it
-#define PVMEM_REGISTRY OsclTLSRegistryEx
-#define PVMEM_REGISTRY_ID OSCL_TLS_ID_OSCLMEM
-
-
 OSCL_EXPORT_REF OsclMemGlobalAuditObject::audit_type* OsclMemGlobalAuditObject::getGlobalMemAuditObject()
 {
-    return (audit_type*)PVMEM_REGISTRY::getInstance(PVMEM_REGISTRY_ID);
+    return (audit_type*)OsclSingletonRegistryEx::getInstance(OSCL_SINGLETON_ID_OSCLMEM);
 }
 
-void OsclMemGlobalAuditObject::createGlobalMemAuditObject(OsclLockBase *lock)
+void OsclMemGlobalAuditObject::createGlobalMemAuditObject()
 {
-    //make sure OsclMem is only initilized once per thread.
-    if (getGlobalMemAuditObject() != NULL)
+    audit_type* audit = (audit_type*)OsclSingletonRegistryEx::lockAndGetInstance(OSCL_SINGLETON_ID_OSCLMEM);
+    if (audit)
     {
-        OsclError::Leave(OsclErrAlreadyInstalled);
-        return;
+        audit->iRefCount++;
     }
-    OsclAny *ptr = _oscl_malloc(sizeof(audit_type));
-    if (!ptr)
+    else
     {
-        OsclError::Leave(OsclErrNoMemory);
-        return;
+        OsclAny *ptr = _oscl_malloc(sizeof(audit_type));
+        if (!ptr)
+        {
+            OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM);
+            OsclError::Leave(OsclErrNoMemory);
+            return;
+        }
+        audit = OSCL_PLACEMENT_NEW(ptr, audit_type());
     }
-    audit_type *audit = OSCL_PLACEMENT_NEW(ptr, audit_type(lock));
-    PVMEM_REGISTRY::registerInstance(audit, PVMEM_REGISTRY_ID);
+    OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM);
 }
 
 void OsclMemGlobalAuditObject::deleteGlobalMemAuditObject()
 {
-    audit_type *audit = getGlobalMemAuditObject();
+    audit_type* audit = (audit_type*)OsclSingletonRegistryEx::lockAndGetInstance(OSCL_SINGLETON_ID_OSCLMEM);
     if (!audit)
     {
+        OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM);
         OsclError::Leave(OsclErrNotInstalled);
         return;
     }
-    audit->~OsclMemAudit();
-    _oscl_free(audit);
-    PVMEM_REGISTRY::registerInstance(NULL, PVMEM_REGISTRY_ID);
+    audit->iRefCount--;
+    if (audit->iRefCount == 0)
+    {
+        audit->~OsclMemAudit();
+        _oscl_free(audit);
+        audit = NULL;
+    }
+    OsclSingletonRegistryEx::registerInstanceAndUnlock(audit, OSCL_SINGLETON_ID_OSCLMEM);
 }
 
 //////////////////////
@@ -252,14 +241,6 @@
     return pTmp;
 }
 
-// the version of GetLock() for !OSCL_BYPASS_MEMMGT returns the actual lock (even though the lock itself
-//	could be NULL
-// the version of GetLock() for OSCL_BYPASS_MEMMGT always returns NULL
-OSCL_EXPORT_REF OsclLockBase* OsclMem::GetLock()
-{
-    return NULL;
-}
-
 #endif //OSCL_BYPASS_MEMMGT
 
 
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp b/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp
index 864f71d..239943d 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp
+++ b/oscl/oscl/osclmemory/src/oscl_mem_mempool.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,7 +27,8 @@
         iMemPoolAllocator(gen_alloc), iMemPool(NULL),
         iCheckNextAvailableFreeChunk(false), iObserver(NULL),
         iNextAvailableContextData(NULL),
-        iRefCount(1)
+        iRefCount(1),
+        iEnableNullPtrReturn(false)
 {
     iNumChunk = numchunk;
     iChunkSize = chunksize;
@@ -43,6 +44,11 @@
     }
 }
 
+OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::enablenullpointerreturn()
+{
+    iEnableNullPtrReturn = true;
+}
+
 OSCL_EXPORT_REF void OsclMemPoolFixedChunkAllocator::addRef()
 {
     // Just increment the ref count
@@ -94,8 +100,14 @@
     if (iFreeMemChunkList.empty())
     {
         // No free chunk is available
-        OSCL_LEAVE(OsclErrNoResources);
-        // OSCL_UNUSED_RETURN(NULL);	This statement was removed to avoid compiler warning for Unreachable Code
+        if (iEnableNullPtrReturn)
+        {
+            return NULL;
+        }
+        else
+        {
+            OSCL_LEAVE(OsclErrNoResources);
+        }
     }
 
     // Return the next available chunk from the pool
@@ -178,7 +190,7 @@
     }
     else
     {
-        OSCL_TRY(leavecode, iMemPool = OSCL_MALLOC(iNumChunk * iChunkSizeMemAligned));
+        iMemPool = OSCL_MALLOC(iNumChunk * iChunkSizeMemAligned);
     }
 
     if (leavecode || iMemPool == NULL)
@@ -250,10 +262,16 @@
         iRequestedNextAvailableSize(0),
         iNextAvailableContextData(NULL),
         iObserver(NULL),
-        iRefCount(1)
+        iCheckFreeMemoryAvailable(false),
+        iRequestedAvailableFreeMemSize(0),
+        iFreeMemContextData(NULL),
+        iFreeMemPoolObserver(NULL),
+        iRefCount(1),
+        iEnableNullPtrReturn(false)
 {
     OSCL_ASSERT(aMemPoolBufferSize > OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE);
 
+    iMaxNewMemPoolBufferSz = 0;
     // Calculate and save the mem aligned size of buffer and block info header structures
     iBufferInfoAlignedSize = oscl_mem_aligned_size(sizeof(MemPoolBufferInfo));
     iBlockInfoAlignedSize = oscl_mem_aligned_size(sizeof(MemPoolBlockInfo));
@@ -282,6 +300,10 @@
     addnewmempoolbuffer(buffersize);
 }
 
+OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::enablenullpointerreturn()
+{
+    iEnableNullPtrReturn = true;
+}
 
 OSCL_EXPORT_REF OsclAny* OsclMemPoolResizableAllocator::allocate(const uint32 aNumBytes)
 {
@@ -298,6 +320,22 @@
     freeblock = findfreeblock(alignednumbytes + iBlockInfoAlignedSize);
     if (freeblock == NULL)
     {
+        //We could not find the new buffer, the only way we can allocate the chunk is by allocating newmempool buffer
+        //Validate is size is less than the regrow size.
+        if (iMemPoolBufferNumLimit > 0 && iMaxNewMemPoolBufferSz > 0 && iMaxNewMemPoolBufferSz < alignednumbytes)
+        {
+            //cannot create the new buffer
+            if (iEnableNullPtrReturn)
+            {
+                return NULL;
+            }
+            else
+            {
+                // Leave with resource limitation
+                OSCL_LEAVE(OsclErrNoResources);
+            }
+
+        }
         // Check if the requested size is bigger than the specified buffer size
         if (alignednumbytes > iMemPoolBufferSize)
         {
@@ -333,9 +371,15 @@
                 // Need to leave and return if empty buffer not found
                 if (!emptybufferfound)
                 {
-                    // Leave with resource limitation
-                    OSCL_LEAVE(OsclErrNoResources);
-                    // OSCL_UNUSED_RETURN(NULL);	This statement was removed to avoid compiler warning for Unreachable Code
+                    if (iEnableNullPtrReturn)
+                    {
+                        return NULL;
+                    }
+                    else
+                    {
+                        // Leave with resource limitation
+                        OSCL_LEAVE(OsclErrNoResources);
+                    }
                 }
 
                 // Continue on to create a new buffer
@@ -365,9 +409,15 @@
             // Check if another buffer can be created
             if (iMemPoolBufferNumLimit > 0 && iMemPoolBufferList.size() >= iMemPoolBufferNumLimit)
             {
-                // Cannot so leave with resource limitation
-                OSCL_LEAVE(OsclErrNoResources);
-                // OSCL_UNUSED_RETURN(NULL);	This statement was removed to avoid compiler warning for Unreachable Code
+                if (iEnableNullPtrReturn)
+                {
+                    return NULL;
+                }
+                else
+                {
+                    // Leave with resource limitation
+                    OSCL_LEAVE(OsclErrNoResources);
+                }
             }
 
             // Determine the size of memory pool buffer and create one
@@ -486,6 +536,30 @@
             }
         }
     }
+    if (iCheckFreeMemoryAvailable)
+    {
+        if (iRequestedAvailableFreeMemSize == 0)
+        {
+            // No so just make the callback
+            iCheckFreeMemoryAvailable = false;
+            if (iFreeMemPoolObserver)
+            {
+                iFreeMemPoolObserver->freememoryavailable(iFreeMemContextData);
+            }
+        }
+        else
+        {
+            // Check if the requested size is available now
+            if (getAvailableSize() >= iRequestedAvailableFreeMemSize)
+            {
+                iCheckFreeMemoryAvailable = false;
+                if (iFreeMemPoolObserver)
+                {
+                    iFreeMemPoolObserver->freememoryavailable(iFreeMemContextData);
+                }
+            }
+        }
+    }
 
     // Decrement the refcount since deallocating succeeded
     removeRef();
@@ -568,6 +642,23 @@
     iNextAvailableContextData = NULL;
 }
 
+OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::notifyfreememoryavailable(OsclMemPoolResizableAllocatorMemoryObserver& aObserver, uint32 aRequestedSize, OsclAny* aContextData)
+{
+    // Save the parameters for the next deallocate() call
+    iCheckFreeMemoryAvailable = true;
+    iFreeMemPoolObserver = &aObserver;
+    iRequestedAvailableFreeMemSize = oscl_mem_aligned_size(aRequestedSize);
+    iFreeMemContextData = aContextData;
+}
+
+OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::CancelFreeMemoryAvailableCallback()
+{
+    iCheckFreeMemoryAvailable = false;
+    iFreeMemPoolObserver = NULL;
+    iRequestedAvailableFreeMemSize = 0;
+    iFreeMemContextData = NULL;
+}
+
 OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::addRef()
 {
     // Just increment the ref count
@@ -630,6 +721,7 @@
     newbufferinfo->iBufferSize = aBufferAlignedSize;
     newbufferinfo->iNumOutstanding = 0;
     newbufferinfo->iNextFreeBlock = (MemPoolBlockInfo*)(newbufferinfo->iStartAddr);
+    newbufferinfo->iAllocatedSz = 0;
     newbufferinfo->iBufferPostFence = OSCLMEMPOOLRESIZABLEALLOCATOR_POSTFENCE_PATTERN;
 
     // Put in one free block in the new buffer
@@ -749,6 +841,8 @@
     aBlockPtr.iNextFreeBlock = NULL;
     aBlockPtr.iPrevFreeBlock = NULL;
 
+    aBlockPtr.iParentBuffer->iAllocatedSz += aBlockPtr.iBlockSize;
+
     // Resize the block if too large
     uint32 extraspace = aBlockPtr.iBlockSize - iBlockInfoAlignedSize - aNumAlignedBytes;
     if (extraspace > (iBlockInfoAlignedSize + OSCLMEMPOOLRESIZABLEALLOCATOR_MIN_BUFFERSIZE))
@@ -759,7 +853,6 @@
 #if OSCL_MEM_FILL_WITH_PATTERN
     oscl_memset(aBlockPtr.iBlockBuffer, 0x55, (aBlockPtr.iBlockSize - iBlockInfoAlignedSize));
 #endif
-
     return aBlockPtr.iBlockBuffer;
 }
 
@@ -792,6 +885,7 @@
         bufferinfo->iNextFreeBlock = &aBlockPtr;
         aBlockPtr.iNextFreeBlock = NULL;
         aBlockPtr.iPrevFreeBlock = NULL;
+        aBlockPtr.iParentBuffer->iAllocatedSz -= aBlockPtr.iBlockSize;
         return;
     }
     else if (leftblockinfo != NULL && rightblockinfo == NULL)
@@ -843,9 +937,7 @@
         aBlockPtr.iPrevFreeBlock = leftblockinfo;
         aBlockPtr.iNextFreeBlock = rightblockinfo;
     }
-
-
-
+    aBlockPtr.iParentBuffer->iAllocatedSz -= aBlockPtr.iBlockSize;
 
     // Merge the newly freed block with neighbors if contiguous
     // Check which neighbors are contiguous in memory space
@@ -987,3 +1079,133 @@
 
     return true;
 }
+
+
+OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getBufferSize() const
+{
+    if (iMemPoolBufferNumLimit == 0)
+        OSCL_LEAVE(OsclErrNotSupported);
+
+    uint32 bufferSize = 0;
+    for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i)
+    {
+        MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i];
+        bufferSize += getMemPoolBufferSize(bufferinfo);
+    }
+
+    return bufferSize;
+}
+
+OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getAllocatedSize() const
+{
+    //const uint32 expectedNumBlocksPerBuffer = iExpectedNumBlocksPerBuffer > 0 ? iExpectedNumBlocksPerBuffer : OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER;
+    uint32 allocatedSz = 0;
+    for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i)
+    {
+        MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i];
+        allocatedSz += getMemPoolBufferAllocatedSize(bufferinfo);
+    }
+    return allocatedSz;
+}
+
+OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getAvailableSize() const
+{
+    if (iMemPoolBufferNumLimit == 0)
+        OSCL_LEAVE(OsclErrNotSupported);
+
+    uint32 availableSize = 0;
+    for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i)
+    {
+        MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i];
+        uint32 memPoolBufferAvailableSz = 0;
+        memPoolBufferAvailableSz = (getMemPoolBufferSize(bufferinfo) - getMemPoolBufferAllocatedSize(bufferinfo));
+        availableSize += memPoolBufferAvailableSz;
+    }
+
+    return availableSize;
+}
+
+OSCL_EXPORT_REF uint32 OsclMemPoolResizableAllocator::getLargestContiguousFreeBlockSize() const
+{
+    uint32 blockSz = 0;
+
+    if (iMemPoolBufferNumLimit > 0)
+    {
+        for (uint32 i = 0; i < iMemPoolBufferList.size(); ++i)
+        {
+            MemPoolBufferInfo* bufferinfo = iMemPoolBufferList[i];
+            if (bufferinfo)
+            {
+                MemPoolBlockInfo* blockinfo = bufferinfo->iNextFreeBlock;
+                while (blockinfo != NULL)
+                {
+                    if (blockinfo->iBlockSize > blockSz) blockSz = blockinfo->iBlockSize;
+                    blockinfo = blockinfo->iNextFreeBlock;
+                }
+            }
+        }
+    }
+    else
+        OSCL_LEAVE(OsclErrNotSupported);
+
+    if (blockSz > iBlockInfoAlignedSize) blockSz -= iBlockInfoAlignedSize;
+    else blockSz = 0;
+
+    return blockSz;
+}
+
+OSCL_EXPORT_REF bool OsclMemPoolResizableAllocator::setMaxSzForNewMemPoolBuffer(uint32 aMaxNewMemPoolBufferSz)
+{
+    bool retval = true;
+    if (iMemPoolBufferNumLimit > 0)
+        iMaxNewMemPoolBufferSz = aMaxNewMemPoolBufferSz;
+    else
+        retval = false;
+    return retval;
+}
+
+uint32 OsclMemPoolResizableAllocator::getMemPoolBufferSize(MemPoolBufferInfo* aBufferInfo) const
+{
+    uint32 memPoolBufferSz = 0;
+
+    if (aBufferInfo)
+        memPoolBufferSz = aBufferInfo->iBufferSize;
+
+    return memPoolBufferSz;
+}
+
+uint32 OsclMemPoolResizableAllocator::getMemPoolBufferAllocatedSize(MemPoolBufferInfo* aBufferInfo) const
+{
+    return aBufferInfo->iAllocatedSz;
+    /*
+    uint32 allocatedSz = 0;
+    const uint32 expectedNumBlocksPerBuffer = iExpectedNumBlocksPerBuffer > 0 ? iExpectedNumBlocksPerBuffer : OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER;
+
+    if (aBufferInfo)
+    {
+        if (aBufferInfo->iNumOutstanding > expectedNumBlocksPerBuffer)
+        {
+            allocatedSz = (aBufferInfo->iAllocatedSz - (expectedNumBlocksPerBuffer * iBlockInfoAlignedSize));
+        }
+        else
+        {
+            allocatedSz = (aBufferInfo->iAllocatedSz - (aBufferInfo->iNumOutstanding * iBlockInfoAlignedSize));
+        }
+    }
+    return allocatedSz;
+    */
+}
+
+uint32 OsclMemPoolResizableAllocator::memoryPoolBufferMgmtOverhead() const
+{
+    uint32 overheadBytes = iBufferInfoAlignedSize;
+    if (iExpectedNumBlocksPerBuffer > 0)
+    {
+        overheadBytes += (iExpectedNumBlocksPerBuffer * iBlockInfoAlignedSize);
+    }
+    else
+    {
+        overheadBytes += (OSCLMEMPOOLRESIZABLEALLOCATOR_DEFAULT_NUMBLOCKPERBUFFER * iBlockInfoAlignedSize);
+    }
+    return overheadBytes;
+}
diff --git a/oscl/oscl/osclmemory/src/oscl_mem_mempool.h b/oscl/oscl/osclmemory/src/oscl_mem_mempool.h
index 4a7d521..8d1b524 100644
--- a/oscl/oscl/osclmemory/src/oscl_mem_mempool.h
+++ b/oscl/oscl/osclmemory/src/oscl_mem_mempool.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -76,12 +76,23 @@
           */
         OSCL_IMPORT_REF OsclMemPoolFixedChunkAllocator(const uint32 numchunk = 1, const uint32 chunksize = 0, Oscl_DefAlloc* gen_alloc = NULL);
 
+        /** This API will disable exceptions in case the memory pool runs out of memory
+          * Instead of doing "OSCL_LEAVE(OsclErrNoResources)" allocate API will return
+          * NULL.
+          *
+          * @return void
+          *
+          */
+        OSCL_IMPORT_REF virtual void enablenullpointerreturn();
+
         /** The destructor for the memory pool
           */
         OSCL_IMPORT_REF virtual ~OsclMemPoolFixedChunkAllocator();
 
-        /** This API throws an exception when n is greater than the fixed chunk size or there are no free chunk available in the pool.
-          * If the memory pool hasn't been created yet, the pool will be created with chunk size equal to n so n must be greater than 0. Exception will be thrown if memory allocation for the memory pool fails.
+        /** This API throws an exception when n is greater than the fixed chunk size or there are no free chunk available in the pool,
+          * if "enablenullpointerreturn" has not been called.
+          * If the memory pool hasn't been created yet, the pool will be created with chunk size equal to n so n must be greater than 0.
+          * Exception will be thrown if memory allocation for the memory pool fails.
           *
           * @return pointer to available chunk from memory pool
           *
@@ -143,6 +154,7 @@
         OsclAny* iNextAvailableContextData;
 
         int32 iRefCount;
+        bool iEnableNullPtrReturn;
 };
 
 
@@ -162,6 +174,12 @@
         virtual ~OsclMemPoolResizableAllocatorObserver() {}
 };
 
+class OsclMemPoolResizableAllocatorMemoryObserver
+{
+    public:
+        virtual void freememoryavailable(OsclAny* aContextData) = 0;
+        virtual ~OsclMemPoolResizableAllocatorMemoryObserver() {}
+};
 
 class OsclMemPoolResizableAllocator : public Oscl_DefAlloc
 {
@@ -180,9 +198,18 @@
           */
         OSCL_IMPORT_REF OsclMemPoolResizableAllocator(uint32 aMemPoolBufferSize, uint32 aMemPoolBufferNumLimit = 0, uint32 aExpectedNumBlocksPerBuffer = 0, Oscl_DefAlloc* gen_alloc = NULL);
 
+        /** This API will disable exceptions in case the memory pool runs out of memory
+          * Instead of doing "OSCL_LEAVE(OsclErrNoResources)" allocate API will return
+          * NULL.
+          *
+          * @return void
+          *
+          */
+        OSCL_IMPORT_REF virtual void enablenullpointerreturn();
+
         /** Allocates a block from the memory pool that is at least in size requested
-          * This API throws an exception if there isn't enough memory for the requested amount in the pool
-          * or if the extra pool buffer cannot be allocated.
+          * This API throws an exception if there isn't enough memory (if "enablenullpointerreturn" has not been called)
+          * for the requested amount in the pool or if the extra pool buffer cannot be allocated.
           *
           * @return Pointer to memory buffer from memory pool
           *
@@ -211,6 +238,25 @@
           */
         OSCL_IMPORT_REF virtual bool trim(OsclAny* aPtr, uint32 aBytesToFree);
 
+        /** Returns the size of the buffer <including the overhead bytes that may be allocated by the allocater>
+          */
+        OSCL_IMPORT_REF uint32 getBufferSize() const;
+
+        /** Returns the number of bytes allocated from the buffer<including the overhead bytes that may be
+          * allocated by the allocater to keep track of the chunks allocated>
+          */
+        OSCL_IMPORT_REF virtual uint32 getAllocatedSize() const;
+
+        /** Returns the number of bytes available with the buffer
+          */
+        OSCL_IMPORT_REF virtual uint32 getAvailableSize() const;
+
+        /** Returns the size of the largest available chunk in the memory.
+          */
+        OSCL_IMPORT_REF virtual uint32 getLargestContiguousFreeBlockSize() const;
+
+        OSCL_IMPORT_REF virtual bool setMaxSzForNewMemPoolBuffer(uint32 aMaxNewMemPoolBufferSz);
+
         /** This API will set the flag to send a callback via specified observer object when the
           * next memory block is deallocated by deallocate() call. If the optional requested size
           * parameter is set, the callback is sent when a free memory space of requested size becomes available.
@@ -231,6 +277,9 @@
           */
         OSCL_IMPORT_REF virtual void CancelFreeChunkAvailableCallback();
 
+        OSCL_IMPORT_REF virtual void notifyfreememoryavailable(OsclMemPoolResizableAllocatorMemoryObserver& aObserver, uint32 aRequestedSize = 0, OsclAny* aContextData = NULL);
+        OSCL_IMPORT_REF void CancelFreeMemoryAvailableCallback();
+
         /** Increments the reference count for this memory pool allocator
           *
           * @return void
@@ -257,6 +306,7 @@
             uint32 iBufferSize;			// Total size of the memory pool buffer including the buffer info header
             uint32 iNumOutstanding;		// Number of outstanding blocks from this memory pool buffer
             MemPoolBlockInfo* iNextFreeBlock; // Pointer to the next free memory block
+            uint32 iAllocatedSz;		//Number of butes allocated from the mempool
             uint32 iBufferPostFence;	// Post-fence to check for memory corruption
         };
 
@@ -287,6 +337,7 @@
         uint32 iMemPoolBufferSize;
         uint32 iMemPoolBufferNumLimit;
         uint32 iExpectedNumBlocksPerBuffer;
+        uint32 iMaxNewMemPoolBufferSz;
         Oscl_DefAlloc* iMemPoolBufferAllocator;
         Oscl_Vector<MemPoolBufferInfo*, OsclMemAllocator> iMemPoolBufferList;
 
@@ -298,7 +349,19 @@
         OsclAny* iNextAvailableContextData;
         OsclMemPoolResizableAllocatorObserver* iObserver;
 
+        bool iCheckFreeMemoryAvailable;
+        uint32  iRequestedAvailableFreeMemSize;
+        OsclAny* iFreeMemContextData;
+        OsclMemPoolResizableAllocatorMemoryObserver* iFreeMemPoolObserver;
+
         int32 iRefCount;
+        bool iEnableNullPtrReturn;
+        //To compute the size of the buffer, excluding the extra memory in the buffer for its management
+        uint32 getMemPoolBufferSize(MemPoolBufferInfo* aBufferInfo) const;
+        //To compute the number of bytes allocated from the buffer
+        uint32 getMemPoolBufferAllocatedSize(MemPoolBufferInfo* aBufferInfo) const;
+        //To compute the addition bytes which were allocated while createing the memory pool for the buffer.
+        uint32 memoryPoolBufferMgmtOverhead() const;
 };
 
 #endif
diff --git a/oscl/oscl/osclproc/Android.mk b/oscl/oscl/osclproc/Android.mk
index e571e30..47a0a20 100644
--- a/oscl/oscl/osclproc/Android.mk
+++ b/oscl/oscl/osclproc/Android.mk
@@ -3,49 +3,53 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_execschedulerbase.cpp \
-	src/oscl_scheduler.cpp \
-	src/oscl_scheduler_ao.cpp \
-	src/oscl_scheduler_threadcontext.cpp \
-	src/oscl_double_list.cpp \
-	src/oscl_timer.cpp \
-	src/oscl_timerbase.cpp \
-	src/oscl_mutex.cpp \
-	src/oscl_semaphore.cpp \
-	src/oscl_thread.cpp \
-	src/oscl_init.cpp
-
+ 	src/oscl_scheduler.cpp \
+ 	src/oscl_scheduler_ao.cpp \
+ 	src/oscl_scheduler_readyq.cpp \
+ 	src/oscl_scheduler_threadcontext.cpp \
+ 	src/oscl_double_list.cpp \
+ 	src/oscl_timer.cpp \
+ 	src/oscl_timerbase.cpp \
+ 	src/oscl_mutex.cpp \
+ 	src/oscl_semaphore.cpp \
+ 	src/oscl_thread.cpp \
+ 	src/oscl_init.cpp
 
 
 LOCAL_MODULE := libosclproc
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclproc/src \
-	$(PV_TOP)//oscl/oscl/osclproc/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclproc/src \
+ 	$(PV_TOP)/oscl/oscl/osclproc/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_aostatus.h \
-	src/oscl_aostatus.inl \
-	src/oscl_scheduler.h \
-	src/oscl_scheduler_aobase.h \
-	src/oscl_scheduler_ao.h \
-	src/oscl_scheduler_readyq.h \
-	src/oscl_scheduler_threadcontext.h \
-	src/oscl_scheduler_types.h \
-	src/oscl_scheduler_tuneables.h \
-	src/oscl_double_list.h \
-	src/oscl_double_list.inl \
-	src/oscl_timer.h \
-	src/oscl_mutex.h \
-	src/oscl_semaphore.h \
-	src/oscl_thread.h \
-	src/oscl_procstatus.h \
-	src/oscl_init.h
+ 	src/oscl_aostatus.inl \
+ 	src/oscl_scheduler.h \
+ 	src/oscl_scheduler_aobase.h \
+ 	src/oscl_scheduler_ao.h \
+ 	src/oscl_scheduler_readyq.h \
+ 	src/oscl_scheduler_threadcontext.h \
+ 	src/oscl_scheduler_types.h \
+ 	src/oscl_scheduler_tuneables.h \
+ 	src/oscl_double_list.h \
+ 	src/oscl_double_list.inl \
+ 	src/oscl_timer.h \
+ 	src/oscl_mutex.h \
+ 	src/oscl_semaphore.h \
+ 	src/oscl_thread.h \
+ 	src/oscl_procstatus.h \
+ 	src/oscl_init.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclproc/build/make/local.mk b/oscl/oscl/osclproc/build/make/local.mk
new file mode 100644
index 0000000..3cd4b73
--- /dev/null
+++ b/oscl/oscl/osclproc/build/make/local.mk
@@ -0,0 +1,46 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := osclproc
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := oscl_execschedulerbase.cpp \
+        oscl_scheduler.cpp \
+        oscl_scheduler_ao.cpp \
+        oscl_scheduler_readyq.cpp \
+        oscl_scheduler_threadcontext.cpp \
+        oscl_double_list.cpp \
+        oscl_timer.cpp \
+        oscl_timerbase.cpp \
+        oscl_mutex.cpp \
+        oscl_semaphore.cpp \
+        oscl_thread.cpp \
+        oscl_init.cpp
+
+HDRS := oscl_aostatus.h \
+        oscl_aostatus.inl \
+        oscl_scheduler.h \
+        oscl_scheduler_aobase.h \
+        oscl_scheduler_ao.h \
+        oscl_scheduler_readyq.h \
+        oscl_scheduler_threadcontext.h \
+        oscl_scheduler_types.h \
+        oscl_scheduler_tuneables.h \
+        oscl_double_list.h \
+        oscl_double_list.inl \
+        oscl_timer.h \
+        oscl_mutex.h \
+        oscl_semaphore.h \
+        oscl_thread.h \
+        oscl_procstatus.h \
+        oscl_init.h
+
+include $(MK)/library.mk
+
diff --git a/oscl/oscl/osclproc/build/make/makefile b/oscl/oscl/osclproc/build/make/makefile
deleted file mode 100644
index 0ff871b..0000000
--- a/oscl/oscl/osclproc/build/make/makefile
+++ /dev/null
@@ -1,81 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclproc
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-#XINCDIRS += -I../../../osclbase/src -I../../../osclutil/src -I../../../osclmemory/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  oscl_execschedulerbase.cpp \
-	oscl_scheduler.cpp \
-	oscl_scheduler_ao.cpp \
-	oscl_scheduler_threadcontext.cpp \
-	oscl_double_list.cpp \
-	oscl_timer.cpp \
-	oscl_timerbase.cpp \
-	oscl_mutex.cpp \
-	oscl_semaphore.cpp \
-	oscl_thread.cpp \
-	oscl_init.cpp
-
-HDRS = oscl_aostatus.h \
-	oscl_aostatus.inl \
-	oscl_scheduler.h \
-	oscl_scheduler_aobase.h \
-	oscl_scheduler_ao.h \
-	oscl_scheduler_readyq.h \
-	oscl_scheduler_threadcontext.h \
-	oscl_scheduler_types.h \
-	oscl_scheduler_tuneables.h \
-	oscl_double_list.h \
-	oscl_double_list.inl \
-	oscl_timer.h \
-	oscl_mutex.h \
-	oscl_semaphore.h \
-	oscl_thread.h \
-	oscl_procstatus.h \
-	oscl_init.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/oscl/oscl/osclproc/src/oscl_aostatus.h b/oscl/oscl/osclproc/src/oscl_aostatus.h
index ab17502..15d7941 100644
--- a/oscl/oscl/osclproc/src/oscl_aostatus.h
+++ b/oscl/oscl/osclproc/src/oscl_aostatus.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,10 +36,6 @@
 #include "oscl_base.h"
 #endif
 
-#ifndef OSCL_EXECPANIC_H_INCLUDED
-#include "oscl_execpanic.h"
-#endif
-
 //Request status values.  These are negative so that
 //they won't conflict with system error codes.
 const int32 OSCL_REQUEST_ERR_NONE = 0;
diff --git a/oscl/oscl/osclproc/src/oscl_aostatus.inl b/oscl/oscl/osclproc/src/oscl_aostatus.inl
index c3644b4..71683fb 100644
--- a/oscl/oscl/osclproc/src/oscl_aostatus.inl
+++ b/oscl/oscl/osclproc/src/oscl_aostatus.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_double_list.cpp b/oscl/oscl/osclproc/src/oscl_double_list.cpp
index 50696de..59ba9c2 100644
--- a/oscl/oscl/osclproc/src/oscl_double_list.cpp
+++ b/oscl/oscl/osclproc/src/oscl_double_list.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_double_list.h b/oscl/oscl/osclproc/src/oscl_double_list.h
index 2d5abce..48fcd99 100644
--- a/oscl/oscl/osclproc/src/oscl_double_list.h
+++ b/oscl/oscl/osclproc/src/oscl_double_list.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_double_list.inl b/oscl/oscl/osclproc/src/oscl_double_list.inl
index b1ea075..70fb84d 100644
--- a/oscl/oscl/osclproc/src/oscl_double_list.inl
+++ b/oscl/oscl/osclproc/src/oscl_double_list.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp b/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp
index 18d0f8c..68d17bf 100644
--- a/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp
+++ b/oscl/oscl/osclproc/src/oscl_execschedulerbase.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@
 #include "oscl_scheduler.h"
 #include "oscl_error.h"
 #include "oscl_error_imp.h"
-#include "oscl_execpanic.h"
 
 OsclExecSchedulerBase::OsclExecSchedulerBase()
 //constructor
@@ -40,8 +39,8 @@
 //virtual method--default error handler.
 {
     OSCL_UNUSED_ARG(anError);
-    //"The default method raised E32User Cbase 47 panic
-    PV_EXECPANIC(EExecObjectLeave);
+    //"The default method raises E32User Cbase 47 panic
+    OsclError::Leave(OsclErrNoHandler);//EExecObjectLeave
 }
 
 void OsclExecSchedulerBase::OnStarting()
diff --git a/oscl/oscl/osclproc/src/oscl_init.cpp b/oscl/oscl/osclproc/src/oscl_init.cpp
index 34da3bc..91b6703 100644
--- a/oscl/oscl/osclproc/src/oscl_init.cpp
+++ b/oscl/oscl/osclproc/src/oscl_init.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
 #include "oscl_mem.h"
 #include "oscl_scheduler.h"
 #include "oscl_error.h"
-#include "oscl_error_panic.h"
 #include "pvlogger.h"
 
 static void _OsclInit2(const OsclSelect &aSelect)
@@ -29,7 +28,7 @@
 {
     if (aSelect.iOsclMemory)
     {
-        OsclMem::Init(aSelect.iMemLock);
+        OsclMem::Init();
     }
     if (aSelect.iOsclLogger)
     {
@@ -45,19 +44,17 @@
 }
 
 //need this routine to avoid a longjmp clobber warning.
-static void _OsclInit2(int32 &aErr, TPVErrorPanic &aPanic, const OsclSelect &aSelect)
+static void _OsclInit2(int32 &aErr, const OsclSelect &aSelect)
 {
-    OSCL_PANIC_TRAP(aErr, aPanic, _OsclInit2(aSelect););
+    OSCL_TRY(aErr, _OsclInit2(aSelect););
 }
 
 OSCL_EXPORT_REF void OsclInit::Init(
     int32 &err
-    , TPVErrorPanic &panic
     , const OsclSelect *p
 )
 {
     err = OsclErrNone;
-    panic.iReason = OsclErrNone;
 
     //Use default parameters if none were input.
     OsclSelect defaultselect;
@@ -92,7 +89,7 @@
     //Do remaining init under a trap, if available.
     if (trapit)
     {
-        _OsclInit2(err, panic, *select);
+        _OsclInit2(err, *select);
     }
     else
     {
@@ -102,14 +99,14 @@
 
 
 //Note: need these routines to avoid longjmp clobber warnings from some compilers.
-static void _OsclSchedulerCleanup(int32 &aErr, TPVErrorPanic& aPanic)
+static void _OsclSchedulerCleanup(int32 &aErr)
 {
-    OSCL_PANIC_TRAP(aErr, aPanic, OsclScheduler::Cleanup(););
+    OSCL_TRY(aErr, OsclScheduler::Cleanup(););
 }
 
-static void _OsclLoggerCleanup(int32 &aErr, TPVErrorPanic& aPanic)
+static void _OsclLoggerCleanup(int32 &aErr)
 {
-    OSCL_PANIC_TRAP(aErr, aPanic, PVLogger::Cleanup(););
+    OSCL_TRY(aErr, PVLogger::Cleanup(););
 }
 
 #include "oscl_mem_audit.h"
@@ -124,7 +121,8 @@
         //Check for memory leaks before cleaning up OsclMem.
         OsclAuditCB auditCB;
         OsclMemInit(auditCB);
-        if (auditCB.pAudit)
+        if (auditCB.pAudit
+                && auditCB.pAudit->MM_GetRefCount() == 1)
         {
             MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
             if (stats)
@@ -155,7 +153,7 @@
                     fprintf(aFile, "  fileName %s\n", info[i].fileName);
                     fprintf(aFile, "  lineNo %d\n", info[i].lineNo);
                     fprintf(aFile, "  size %d\n", info[i].size);
-                    fprintf(aFile, "  pMemBlock 0x%x\n", info[i].pMemBlock);
+                    fprintf(aFile, "  pMemBlock 0x%x\n", (uint32)info[i].pMemBlock);
                     fprintf(aFile, "  tag %s\n", info[i].tag);
                 }
                 auditCB.pAudit->MM_ReleaseAllocNodeInfo(info);
@@ -166,46 +164,42 @@
     OsclMem::Cleanup();
 }
 
-static void _OsclMemCleanup(int32 &aErr, TPVErrorPanic& aPanic, FILE* aFile)
+static void _OsclMemCleanup(int32 &aErr, FILE* aFile)
 {
-    OSCL_PANIC_TRAP(aErr, aPanic, _OsclMemCleanup(aFile););
+    OSCL_TRY(aErr, _OsclMemCleanup(aFile););
 }
 
-OSCL_EXPORT_REF void OsclInit::Cleanup(int32 &aErr, TPVErrorPanic& aPanic, const OsclSelect *p)
+OSCL_EXPORT_REF void OsclInit::Cleanup(int32 &aErr, const OsclSelect *p)
 {
-    int32 err = OsclErrNone;
-    TPVErrorPanic panic;
+    aErr = OsclErrNone;
+
     //Use default parameters if none were input.
     OsclSelect defaultselect;
     const OsclSelect* select = (p) ? p : &defaultselect;
 
     //Note: we continue cleanup despite errors and return the last error encoutered.
 
+    int32 err;
+
     if (select->iOsclScheduler)
     {
-        _OsclSchedulerCleanup(err, panic);
+        _OsclSchedulerCleanup(err);
         if (err)
             aErr = err;
-        if (panic.iReason)
-            aPanic = panic;
     }
 
     if (select->iOsclLogger)
     {
-        _OsclLoggerCleanup(err, panic);
+        _OsclLoggerCleanup(err);
         if (err)
             aErr = err;
-        if (panic.iReason)
-            aPanic = panic;
     }
 
     if (select->iOsclMemory)
     {
-        _OsclMemCleanup(err, panic, select->iOutputFile);
+        _OsclMemCleanup(err, select->iOutputFile);
         if (err)
             aErr = err;
-        if (panic.iReason)
-            aPanic = panic;
     }
 
     if (select->iOsclErrorTrap)
diff --git a/oscl/oscl/osclproc/src/oscl_init.h b/oscl/oscl/osclproc/src/oscl_init.h
index 51e0349..bc8ff44 100644
--- a/oscl/oscl/osclproc/src/oscl_init.h
+++ b/oscl/oscl/osclproc/src/oscl_init.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,9 +37,7 @@
 //For logging memory leaks, this module relies directly on fprintf to FILE.
 #include <stdio.h>
 
-class OsclLockBase;
 class Oscl_DefAlloc;
-class TPVErrorPanic;
 
 /**
 * Oscl Module selection and Init/Cleanup options.
@@ -54,7 +52,6 @@
                 , iOsclLogger(true)
                 , iOsclScheduler(true)
                 , iErrAlloc(NULL)
-                , iMemLock(NULL)
                 , iSchedulerAlloc(NULL)
                 , iSchedulerName(NULL)
                 , iSchedulerReserve(10)
@@ -64,7 +61,6 @@
 
         //this constructor is mainly for back-compatibility with the old OsclInit argument list.
         OsclSelect(Oscl_DefAlloc* erralloc
-                   , OsclLockBase* lock
                    , Oscl_DefAlloc* schedalloc
                    , const char*name
                    , int32 reserve = 10
@@ -76,7 +72,6 @@
                 , iOsclLogger(true)
                 , iOsclScheduler(true)
                 , iErrAlloc(erralloc)
-                , iMemLock(lock)
                 , iSchedulerAlloc(schedalloc)
                 , iSchedulerName(name)
                 , iSchedulerReserve(reserve)
@@ -91,9 +86,6 @@
         bool iOsclScheduler;    //Init/Cleanup OsclScheduler?
 
         Oscl_DefAlloc *iErrAlloc; //Allocator for OsclErrorTrap::Init
-
-        OsclLockBase*iMemLock; //Lock for OsclMem::Init
-
         Oscl_DefAlloc *iSchedulerAlloc; //Allocator for OsclScheduler::Init
         const char *iSchedulerName;     //Name for OsclScheduler::Init
         int32 iSchedulerReserve;        //Queue reserve for OsclScheduler::Init
@@ -114,8 +106,6 @@
          *
          * @param err: (output) error code of any leave that occurs in
          *   initialization.
-         * @param panic: (output) will contain any panic that occurs
-         *   during initialization.
          *
          * @param config: (input param) optional set of initialization parameters.
          *   If null, then full initialization with default parameters will be performed.
@@ -123,7 +113,6 @@
          */
         OSCL_IMPORT_REF static void Init(
             int32& aError
-            , TPVErrorPanic& aPanic
             , const OsclSelect *aSelect = NULL
         );
 
@@ -132,8 +121,6 @@
          *
          * @param err: (output) error code of any leave that occurs in
          *   initialization.
-         * @param panic: (output) will contain any panic that occurs
-         *   during initialization.
          * @param config: (input param) optional set of initialization parameters.
          *   If null, then full initialization with default parameters will be performed.
          *   For proper cleanup, the parameters should match the ones used during
@@ -142,7 +129,6 @@
          */
         OSCL_IMPORT_REF static void Cleanup(
             int32& aError
-            , TPVErrorPanic& aPanic
             , const OsclSelect *aSelect = NULL
         );
 };
diff --git a/oscl/oscl/osclproc/src/oscl_mutex.cpp b/oscl/oscl/osclproc/src/oscl_mutex.cpp
index 8a26488..d961ed5 100644
--- a/oscl/oscl/osclproc/src/oscl_mutex.cpp
+++ b/oscl/oscl/osclproc/src/oscl_mutex.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_mutex.h b/oscl/oscl/osclproc/src/oscl_mutex.h
index 60df89c..ce7a263 100644
--- a/oscl/oscl/osclproc/src/oscl_mutex.h
+++ b/oscl/oscl/osclproc/src/oscl_mutex.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
 #include "oscl_lock_base.h"
 #endif
 
+
 /**
  * Class OsclMutex
  */
@@ -135,9 +136,151 @@
 
 };
 
-#ifndef OSCL_LOCK_BASE_H_INCLUDED
-#include "oscl_lock_base.h"
+/**
+ * Class OsclNoYieldMutex can be used in use cases where there will be
+ * no CPU-yielding operation done while the Mutex is locked.
+ *
+ * CPU-yielding operations include OsclMutex::Lock, OsclSemphore::Wait,
+ * OsclThread::Sleep, and OsclBrewThreadUtil::BThreadYield.
+ *
+ * The behavior of OsclNoYieldMutex depends on whether the threading model
+ * is pre-emptive or not.  When threading is pre-emptive, it is identical
+ * to OsclMutex.  When threading is non-pre-emptive, it is a NO-OP.
+ *
+ * An example of this type of use case is for simple data protection.
+ *
+ */
+#if !OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT
+//In pre-emptive threading, OsclNoYieldMutex is identical to OsclMutex
+typedef OsclMutex OsclNoYieldMutex;
+#else
+//In non-pre-emptive threading, OsclNoYieldMutex is a NO-OP.
+class OsclNoYieldMutex : public OsclLockBase
+{
+    public:
+
+        /**
+         * Class constructor
+         */
+        OsclNoYieldMutex()
+        {
+#ifndef NDEBUG
+            iNumLock = 0;
+            bCreated = false;
 #endif
+        }
+
+        /**
+         * Class destructor
+         */
+        virtual ~OsclNoYieldMutex()
+        {}
+
+        /**
+         * Creates the Mutex
+         *
+         * @param No input arguments
+         *
+         * @return Returns the Error whether it is success or failure.
+         * Incase of failure it will return what is the specific error
+         */
+        OsclProcStatus::eOsclProcError Create(void)
+        {
+#ifndef NDEBUG
+            if (bCreated)
+                return OsclProcStatus::INVALID_OPERATION_ERROR;
+            bCreated = true;
+#endif
+            return OsclProcStatus::SUCCESS_ERROR;
+        }
+
+
+        /**
+         * Locks the Mutex
+         *
+         * @param It wont take any parameters
+         *
+         * @return Returns nothing
+         */
+        void Lock()
+        {
+#ifndef NDEBUG
+            OSCL_ASSERT(bCreated);
+            OSCL_ASSERT(iNumLock == 0);//detect deadlock condition.
+            iNumLock++;
+#endif
+        }
+
+        /**
+         * Try to lock the mutex,if the Mutex is already locked calling thread
+         * immediately returns with out blocking
+         * @param It wont take any parameters
+         *
+         * @return Returns SUCCESS_ERROR if the mutex was acquired,
+         * MUTEX_LOCKED_ERROR if the mutex cannot be acquired without waiting,
+         * or an error code if the operation failed.
+         * Note: this function may not be supported on all platforms, and
+         * may return NOT_IMPLEMENTED.
+         */
+        OsclProcStatus::eOsclProcError TryLock()
+        {
+#ifndef NDEBUG
+            if (!bCreated)
+                return OsclProcStatus::INVALID_OPERATION_ERROR;
+            if (iNumLock)
+                return OsclProcStatus::MUTEX_LOCKED_ERROR;
+            else
+                Lock();
+            return OsclProcStatus::SUCCESS_ERROR;
+#endif
+        }
+
+
+        /**
+         * Releases the Mutex
+         *
+         * @param It wont take any parameters
+         *
+         * @return Returns nothing
+         */
+        void Unlock()
+        {
+#ifndef NDEBUG
+            OSCL_ASSERT(bCreated);
+            OSCL_ASSERT(iNumLock);
+            if (iNumLock > 0)
+                iNumLock--;
+#endif
+        }
+
+
+        /**
+         * Closes the Mutex
+         *
+         * @param It wont take any prameters
+         *
+         * @return Returns the Error whether it is success or failure.
+         * Incase of failure it will return what is the specific error
+         */
+        OsclProcStatus::eOsclProcError Close(void)
+        {
+#ifndef NDEBUG
+            if (!bCreated)
+                return OsclProcStatus::INVALID_OPERATION_ERROR;
+            bCreated = false;
+#endif
+            return OsclProcStatus::SUCCESS_ERROR;
+        }
+
+    private:
+
+#ifndef NDEBUG
+        uint32 iNumLock;
+        bool bCreated;
+#endif
+
+};
+#endif //OSCL_HAS_NON_PREEMPTIVE_THREAD_SUPPORT
 
 /**
 ** An implementation of OsclLockBase using a mutex
diff --git a/oscl/oscl/osclproc/src/oscl_procstatus.h b/oscl/oscl/osclproc/src/oscl_procstatus.h
index c32e955..ee8eecf 100644
--- a/oscl/oscl/osclproc/src/oscl_procstatus.h
+++ b/oscl/oscl/osclproc/src/oscl_procstatus.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -107,6 +107,7 @@
             WAIT_ABANDONED_ERROR,//thread terminated while waiting
             WAIT_TIMEOUT_ERROR, //timed wait expired without acquiring
             SEM_NOT_SIGNALED_ERROR, //trywait returned without acquiring
+            PSHARED_ATTRIBUTE_SETTING_ERROR,   // Error at setting pthread attributes
             NOT_IMPLEMENTED //function not implemented on this platform.
         } ;
 
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler.cpp b/oscl/oscl/osclproc/src/oscl_scheduler.cpp
index 30b222f..4885c46 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler.cpp
+++ b/oscl/oscl/osclproc/src/oscl_scheduler.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,13 +31,13 @@
 #define OSCL_DISABLE_WARNING_CONDITIONAL_IS_CONSTANT
 #include "osclconfig_compiler_warnings.h"
 
+
 #include "oscl_scheduler_tuneables.h"
 
-#if(PV_SCHED_LOG_Q)
-#define LOGQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m);
-#else
-#define LOGQ(m)
-#endif
+
+/////////////////////////////////////
+// Logger Macros
+/////////////////////////////////////
 
 //LOGERROR is for scheduler errors.
 //This logging also goes to stderr on platforms with ANSI stdio.
@@ -58,25 +58,28 @@
 #define LOGPERF2(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF,iLogger,LOGPERF2_LEVEL,m);
 //max perf log string length
 #define LOGPERFMAXSTR 64
-//runtime check for whether perf logging level is enabled.
-#define DO_LOGPERF (iLogger->GetLogLevel()<0||iLogger->GetLogLevel()>=LOGPERF_LEVEL)
+#define RESET_LOG_PERF(m)\
+	ResetLogPerf();\
+	LOGPERF(m);
 #else
 #define LOGSTATS(m)
 #define LOGPERF(m)
 #define LOGPERF2(m)
 #define LOGPERFMAXSTR 64
-#define DO_LOGPERF (0)
+#define RESET_LOG_PERF(m)
 #endif//(PV_SCHED_ENABLE_PERF_LOGGING)
 
+/////////////////////////////////////
+// DLL Entry
+/////////////////////////////////////
 #ifndef OSCL_COMBINED_DLL
 #include "oscl_dll.h"
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 #endif
 
-//
+/////////////////////////////////////
 // OsclScheduler
-//
-
+/////////////////////////////////////
 
 OSCL_EXPORT_REF void OsclScheduler::Init(const char *name, Oscl_DefAlloc *alloc, int nreserve)
 //Init the scheduler for this thread.
@@ -86,50 +89,65 @@
              OsclExecScheduler *sched = OsclExecScheduler::NewL(name, alloc, nreserve);
              sched->InstallScheduler(););
     if (err != OsclErrNone)
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 }
 
 
+
 OSCL_EXPORT_REF void OsclScheduler::Cleanup()
 //Cleanup the scheduler for this thread.
 {
     OsclExecSchedulerCommonBase *sched = OsclExecSchedulerCommonBase::GetScheduler();
     if (!sched)
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
     sched->UninstallScheduler();
     Oscl_DefAlloc *alloc = sched->iAlloc;
     sched->~OsclExecSchedulerCommonBase();
     alloc->deallocate(sched);
 }
 
-//
+/////////////////////////////////////
 // OsclExecSchedulerCommonBase
-//
+/////////////////////////////////////
 
-//
+/////////////////////////////////////
 // OsclExecScheduler
-//
+/////////////////////////////////////
 
 //use the TLS registry, or the singleton registry if no TLS.
+//Note: singleton registry only works for single-threaded
+//scenarios, since this implementation assumes a per-thread registry.
 #include "oscl_error.h"
 #define PVSCHEDULER_REGISTRY OsclTLSRegistryEx
 #define PVSCHEDULER_REGISTRY_ID OSCL_TLS_ID_PVSCHEDULER
 
+
+/////////////////////////////////////
 //For AO statistics.
+/////////////////////////////////////
+
 #if !(PV_SCHED_ENABLE_AO_STATS)
 //no stats
 #define PVTICK uint32
+#define PVTICK_INT uint32
+#define INIT_TICK(tick)
 #define SET_TICK(tick)
 #define GET_TICKFREQ(tick)
 #define TICK_INT(tick1)
 #define TICKSTR ""
+#define TICK_INT_STR ""
+#define TICK_INT_EXPR(x)
 #else
 //else use the oscl timer.
 #define PVTICK uint32
+#define PVTICK_INT uint32
+#define INIT_TICK(tick) tick=0
 #define SET_TICK(tick) tick=OsclTickCount::TickCount()
 #define GET_TICKFREQ(tick) tick=OsclTickCount::TickCountFrequency()
 #define TICK_INT(tick1) tick1
 #define TICKSTR "Ticks"
+#define TICK_INT_STR "%u"
+#define TICK_INT_EXPR(x) x
 #endif
 
 #if !(PV_SCHED_ENABLE_AO_STATS)
@@ -140,20 +158,20 @@
 #else
 #define DIFF_TICK(tick1,diff) PVTICK _now;SET_TICK(_now);diff=TICK_INT(_now)-TICK_INT(tick1)
 #define UPDATE_RUNERROR_TIME(stats,delta)\
-		if(stats->i64Valid) stats->i64TotalTicksInRunL+=delta;\
-		else stats->iTotalTicksInRunL+=delta;\
+		if(stats->i64Valid) stats->i64TotalTicksInRun+=delta;\
+		else stats->iTotalTicksInRun+=delta;\
+		if(delta>stats->iMaxTicksInRun) stats->iMaxTicksInRun=delta;\
 		stats->iNumRunError++
 #define UPDATE_RUNL_TIME(stats,delta)\
-		if(stats->i64Valid) stats->i64TotalTicksInRunL+=delta;\
-		else stats->iTotalTicksInRunL+=delta;\
+		if(stats->i64Valid) stats->i64TotalTicksInRun+=delta;\
+		else stats->iTotalTicksInRun+=delta;\
+		if(delta>stats->iMaxTicksInRun) stats->iMaxTicksInRun=delta;\
 		stats->iNumRun++;
 #define UPDATE_LEAVE_CODE(stats,err)if (err!=OsclErrNone)stats->iLeave=err
 #endif
 
 #if (PV_SCHED_ENABLE_LOOP_STATS)
-#define DECLARE_LOOP_STATS\
-		int64 loopdelta = 0;\
-		PVTICK looptime;
+#define DECLARE_LOOP_STATS int64 loopdelta = 0; PVTICK looptime;
 
 #define START_LOOP_STATS(stats)SET_TICK(looptime);
 
@@ -164,8 +182,8 @@
 #define END_LOOP_STATS(stats)\
 		{\
 			DIFF_TICK(looptime,loopdelta);\
-			if(stats->i64Valid) stats->i64TotalTicksInRunL+=loopdelta;\
-			else stats->iTotalTicksInRunL+=loopdelta;\
+			if(stats->i64Valid) stats->i64TotalTicksInRun+=loopdelta;\
+			else stats->iTotalTicksInRun+=Oscl_Int64_Utils::get_int64_lower32(loopdelta);\
 			stats->iNumRun++;\
 			LOGPERF((0,"PVSCHED: Run %d %s AO %s",(int32)loopdelta,TICKSTR,stats->iAOName.get_cstr()));\
 		}
@@ -174,17 +192,19 @@
 		if (rc<1)\
 		{\
 			DIFF_TICK(looptime,loopdelta);\
-			if(stats->i64Valid) stats->i64TotalTicksInRunL+=loopdelta;\
-			else stats->iTotalTicksInRunL+=loopdelta;\
+			if(stats->i64Valid) stats->i64TotalTicksInRun+=loopdelta;\
+			else stats->iTotalTicksInRun+=Oscl_Int64_Utils::get_int64_lower32(loopdelta);\
 			stats->iNumRun++;\
 			LOGPERF((0,"PVSCHED: Run %d %s AO %s",(int32)loopdelta,TICKSTR,stats->iAOName.get_cstr()));\
 		}
+
 #else
 #define DECLARE_LOOP_STATS
 #define START_LOOP_STATS(stats)
 #define START_WAIT_LOOP_STATS(rc,stats)
 #define END_LOOP_STATS(stats)
 #define END_WAIT_LOOP_STATS(rc,stats)
+
 #endif
 
 #if(PV_SCHED_ENABLE_PERF_LOGGING)
@@ -215,7 +235,6 @@
         iLogPerfIndentStr[iLogPerfIndentStrLen] = '\0';
     }
 }
-//end perf logging.
 #endif//(PV_SCHED_ENABLE_PERF_LOGGING)
 
 OsclExecSchedulerCommonBase* OsclExecSchedulerCommonBase::GetScheduler()
@@ -269,7 +288,7 @@
     //make sure scheduler is not currently installed in
     //any thread.
     if (IsInstalled())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotStopped);
+        OsclError::Leave(OsclErrInvalidState);//scheduler not stopped
 
     if (iStopper)
     {
@@ -293,7 +312,6 @@
     iLogPerfIndentStr = NULL;
     iLogPerfTotal = 0;
 #endif
-    iCallback = NULL;
 }
 
 OsclExecScheduler::OsclExecScheduler(Oscl_DefAlloc *alloc)
@@ -310,45 +328,8 @@
     iStopper = new(ptr) PVSchedulerStopper;
 
 #if(PV_SCHED_ENABLE_AO_STATS)
-    //create a placeholder for summary stats for
-    //all AOs that are not PVActiveBase.
-    for (uint32 i = 0;i < EOtherExecStats_Last;i++)
-        iOtherExecStats[i] = NULL;
-
-    ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
-    OsclError::LeaveIfNull(ptr);
-    iOtherExecStats[EOtherExecStats_NativeOS] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_TotalNativeOS", NULL));
-    //init the stat queue offset.
-    {
-        int offset = (int) & (iOtherExecStats[EOtherExecStats_NativeOS])->iPVStatQLink - (int)(iOtherExecStats[EOtherExecStats_NativeOS]);
-        iPVStatQ.SetOffset(offset);
-    }
-
-#if(PV_SCHED_ENABLE_LOOP_STATS)
-    //create nodes for summary stats for scheduler loop time
-
-    ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
-    OsclError::LeaveIfNull(ptr);
-    iOtherExecStats[EOtherExecStats_LockTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_LockTime", NULL));
-
-    ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
-    OsclError::LeaveIfNull(ptr);
-    iOtherExecStats[EOtherExecStats_QueueTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_QueueTime", NULL));
-
-    ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
-    OsclError::LeaveIfNull(ptr);
-    iOtherExecStats[EOtherExecStats_WaitTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_WaitTime", NULL));
+    ConstructStatQ();
 #endif
-    //add the non-AO stats nodes to the stat Q.
-    {
-        for (uint32 i = 0;i < EOtherExecStats_Last;i++)
-        {
-            if (iOtherExecStats[i])
-                iPVStatQ.InsertTail(*iOtherExecStats[i]);
-        }
-    }
-
-#endif //PV_SCHED_ENABLE_AO_STATS
 
     InitExecQ(nreserve);
 
@@ -356,13 +337,11 @@
     iNativeMode = false;
     iName.Set(name);
     iLogger = PVLogger::GetLoggerObject("pvscheduler");
+
 #if (PV_SCHED_ENABLE_PERF_LOGGING)
-    if (DO_LOGPERF)
-    {
-        iLogPerfIndentStr = (char*)_oscl_malloc(LOGPERFMAXSTR + 1);
-        OsclError::LeaveIfNull(iLogPerfIndentStr);
-        ResetLogPerf();
-    }
+    iLogPerfIndentStr = (char*)_oscl_malloc(LOGPERFMAXSTR + 1);
+    OsclError::LeaveIfNull(iLogPerfIndentStr);
+    ResetLogPerf();
 #endif
 }
 
@@ -376,10 +355,10 @@
     //make sure this scheduler is not installed in
     //any thread.
     if (IsInstalled())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerAlreadyInstalled);
+        OsclError::Leave(OsclErrAlreadyInstalled);
     //make sure no scheduler is installed in this thread.
     if (GetScheduler())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerAlreadyInstalled);
+        OsclError::Leave(OsclErrAlreadyInstalled);
 
     SetScheduler(this);
 
@@ -387,28 +366,25 @@
 
     iErrorTrapImp = OsclErrorTrap::GetErrorTrapImp();
     if (!iErrorTrapImp)
-        PV_SCHEDULERPANIC(EPVPanicErrorTrapNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);//error trap not installed.
 
     if (iStopperCrit.Create() != OsclProcStatus::SUCCESS_ERROR)
-        PV_SCHEDULERPANIC(EPVPanicMutexError);
+        OsclError::Leave(OsclErrSystemCallFailed);//mutex error
 
     iResumeSem.Create();
     iDoStop = iDoSuspend = iSuspended = false;
 
-    iReadyQ.Open();
+    iReadyQ.ThreadLogon();
 
     LOGNOTICE((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Installed", iName.Str(), PVThreadContext::Id()));
 
 #if (PV_SCHED_ENABLE_PERF_LOGGING)
-    if (DO_LOGPERF)
-    {//print tick frequencies that will show up in the perf log.
-        PVTICK f;
-        GET_TICKFREQ(f);
-        LOGPERF((0, "PVSCHED: %s frequency %u", TICKSTR, TICK_INT(f)));
-        uint32 freq = OsclTickCount::TickCountFrequency();
-        LOGPERF((0, "PVSCHED: %s frequency %u", "Ticks", freq));
-        OSCL_UNUSED_ARG(freq);
-    }
+    //print tick frequencies that will show up in the perf log.
+    PVTICK f;
+    GET_TICKFREQ(f);
+    PVTICK_INT tickint = TICK_INT(f);
+    LOGPERF((0, "PVSCHED: %s frequency %s", TICKSTR, TICK_INT_STR, TICK_INT_EXPR(tickint)));
+    OSCL_UNUSED_ARG(tickint);
 #endif
 }
 
@@ -417,20 +393,20 @@
     //make sure this scheduler is currently installed in
     //this thread.
     if (!IsInstalled() || GetScheduler() != this)
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 
 
     if (iBlockingMode)
     {
-        //in case a thread panic happened, go ahead and end
+        //in case a thread error happened, go ahead and end
         //scheduling.
         OsclErrorTrapImp *trap = OsclErrorTrapImp::GetErrorTrap();
         if (trap
-                && trap->iPanic.iReason != OsclErrNone)
+                && trap->iLeave != OsclErrNone)
             EndScheduling();
-        //make sure scheduler is stopped.  If not, panic instead.
+        //make sure scheduler is stopped.  If not, leave instead.
         if (IsStarted())
-            PV_SCHEDULERPANIC(EPVPanicSchedulerNotStopped);
+            OsclError::Leave(OsclErrInvalidState);//scheduler not stopped
     }
     else if (IsStarted())
     {
@@ -450,9 +426,9 @@
 #endif
 
     if (iStopperCrit.Close() != OsclProcStatus::SUCCESS_ERROR)
-        PV_SCHEDULERPANIC(EPVPanicMutexError);
+        OsclError::Leave(OsclErrSystemCallFailed);//mutex error
 
-    iReadyQ.Close();
+    iReadyQ.ThreadLogoff();
     iResumeSem.Close();
 
     LOGNOTICE((0, "PVSCHED:Scheduler '%s', Thread 0x%x: Uninstalled", iName.Str(), PVThreadContext::Id()));
@@ -482,11 +458,11 @@
 {
     //make sure scheduler is installed...
     if (!IsInstalled() || GetScheduler() != this)
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 
     //make sure scheduler is idle...
     if (IsStarted())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotStopped);
+        OsclError::Leave(OsclErrInvalidState);
 
     iBlockingMode = blocking;
     iNativeMode = native;
@@ -526,6 +502,55 @@
 }
 
 #if(PV_SCHED_ENABLE_AO_STATS)
+void OsclExecSchedulerCommonBase::ConstructStatQ()
+{
+    //create a placeholder for summary stats for
+    //all AOs that are not PVActiveBase.
+    for (uint32 i = 0;i < EOtherExecStats_Last;i++)
+        iOtherExecStats[i] = NULL;
+
+    OsclAny* ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
+    OsclError::LeaveIfNull(ptr);
+    iOtherExecStats[EOtherExecStats_NativeOS] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_TotalNativeOS", NULL));
+    //init the stat queue offset.
+    {
+        int offset = (int) & (iOtherExecStats[EOtherExecStats_NativeOS])->iPVStatQLink - (int)(iOtherExecStats[EOtherExecStats_NativeOS]);
+        iPVStatQ.SetOffset(offset);
+    }
+
+#if(PV_SCHED_ENABLE_LOOP_STATS)
+    //create nodes for summary stats for scheduler loop time
+
+    ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
+    OsclError::LeaveIfNull(ptr);
+    iOtherExecStats[EOtherExecStats_QueueTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_QueueTime", NULL));
+
+    ptr = iAlloc->ALLOCATE(sizeof(PVActiveStats));
+    OsclError::LeaveIfNull(ptr);
+    iOtherExecStats[EOtherExecStats_WaitTime] = OSCL_PLACEMENT_NEW(ptr, PVActiveStats(this, "Sched_WaitTime", NULL));
+
+#endif
+    //add the non-AO stats nodes to the stat Q.
+    {
+        for (uint32 i = 0;i < EOtherExecStats_Last;i++)
+        {
+            if (iOtherExecStats[i])
+                iPVStatQ.InsertTail(*iOtherExecStats[i]);
+        }
+    }
+}
+
+void OsclExecSchedulerCommonBase::CleanupStatQ()
+{
+    while (!iPVStatQ.IsEmpty())
+    {
+        PVActiveStats* first = iPVStatQ.Head();
+        first->iPVStatQLink.Remove();
+        first->~PVActiveStats();
+        first->iScheduler->iAlloc->deallocate(first);
+    }
+}
+
 void OsclExecSchedulerCommonBase::ShowStats(PVActiveStats *active)
 //static routine to print stats for a PV AO.
 {
@@ -539,13 +564,16 @@
     PVLogger* iLogger = PVLogger::GetLoggerObject("pvscheduler");
     if (active->i64Valid)
     {
-        int64 avgTicksPerRunL = (active->iNumRun == 0) ? 0 : active->i64TotalTicksInRunL / (int64)active->iNumRun;
-        LOGSTATS((0, "PVSCHED:Scheduler '%s', AO '%s': NumRunL %d, AvgTicksPerRunL (hi,lo) (0x%x,0x%08x) Units %s, NumCancel %d, NumError %d, LeaveCode %d"
+        int64 avgTicksPerRun = (active->iNumRun == 0) ? 0 : active->i64TotalTicksInRun / (int64)active->iNumRun;
+
+        LOGSTATS((0, "PVSCHED:Scheduler '%s', AO '%s': Pri %d NumRun %d, MaxTicksInRun 0x%x, AvgTicksPerRun (hi,lo) (0x%x,0x%08x) Units %s, NumCancel %d, NumError %d, LeaveCode %d"
                   , active->iScheduler->iName.Str()
                   , active->iAOName.get_cstr()
+                  , active->iPriority
                   , active->iNumRun
-                  , Oscl_Int64_Utils::get_int64_upper32(avgTicksPerRunL)
-                  , Oscl_Int64_Utils::get_int64_lower32(avgTicksPerRunL)
+                  , active->iMaxTicksInRun
+                  , Oscl_Int64_Utils::get_int64_upper32(avgTicksPerRun)
+                  , Oscl_Int64_Utils::get_int64_lower32(avgTicksPerRun)
                   , TICKSTR
                   , active->iNumCancel
                   , active->iNumRunError
@@ -554,12 +582,14 @@
     }
     else
     {
-        uint32 avgTicksPerRunL = (active->iNumRun == 0) ? 0 : active->iTotalTicksInRunL / active->iNumRun;
-        LOGSTATS((0, "PVSCHED:Scheduler '%s', AO '%s': NumRunL %d, AvgTicksPerRunL %d Units %s, NumCancel %d, NumError %d, LeaveCode %d"
+        uint32 avgTicksPerRun = (active->iNumRun == 0) ? 0 : active->iTotalTicksInRun / active->iNumRun;
+        LOGSTATS((0, "PVSCHED:Scheduler '%s', AO '%s': Pri %d NumRun %d, MaxTicksInRun %d, AvgTicksPerRun %d Units %s, NumCancel %d, NumError %d, LeaveCode %d"
                   , active->iScheduler->iName.Str()
                   , active->iAOName.get_cstr()
+                  , active->iPriority
                   , active->iNumRun
-                  , avgTicksPerRunL
+                  , active->iMaxTicksInRun
+                  , avgTicksPerRun
                   , TICKSTR
                   , active->iNumCancel
                   , active->iNumRunError
@@ -584,13 +614,13 @@
     //calculate percent of the total time that was spent in this AO.
     if (active->i64Valid)
     {
-        active->iPercent = 100.0 * active->i64TotalTicksInRunL / total;
-        aGrandTotal += active->i64TotalTicksInRunL;
+        active->iPercent = 100.0 * active->i64TotalTicksInRun / total;
+        aGrandTotal += active->i64TotalTicksInRun;
     }
     else
     {
-        active->iPercent = 100.0 * active->iTotalTicksInRunL / total;
-        aGrandTotal += active->iTotalTicksInRunL;
+        active->iPercent = 100.0 * active->iTotalTicksInRun / total;
+        aGrandTotal += active->iTotalTicksInRun;
     }
     aTotalPercent += active->iPercent;
 
@@ -602,12 +632,14 @@
     if (active->i64Valid)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO
-                        , (0, "  TIME PERCENT %d.%02d, AO '%s', NumRunL %d, TotalTicksInRunL Hi,Lo (0x%x,0x%08x), NumCancel %d, NumError %d, LeaveCode %d, NumInstance %d"
+                        , (0, "  TIME PERCENT %d.%02d, AO '%s', Pri %d NumRun %d, MaxTicksInRun 0x%x, TotalTicksInRun Hi,Lo (0x%x,0x%08x), NumCancel %d, NumError %d, LeaveCode %d, NumInstance %d"
                            , (int32)active->iPercent, (int32)decimal
                            , active->iAOName.get_cstr()
+                           , active->iPriority
                            , active->iNumRun
-                           , Oscl_Int64_Utils::get_int64_upper32(active->i64TotalTicksInRunL)
-                           , Oscl_Int64_Utils::get_int64_lower32(active->i64TotalTicksInRunL)
+                           , active->iMaxTicksInRun
+                           , Oscl_Int64_Utils::get_int64_upper32(active->i64TotalTicksInRun)
+                           , Oscl_Int64_Utils::get_int64_lower32(active->i64TotalTicksInRun)
                            , active->iNumCancel
                            , active->iNumRunError
                            , active->iLeave
@@ -617,11 +649,13 @@
     else
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO
-                        , (0, "  TIME PERCENT %d.%02d, AO '%s', NumRunL %d, TotalTicksInRunL 0x%x, NumCancel %d, NumError %d, LeaveCode %d, NumInstance %d"
+                        , (0, "  TIME PERCENT %d.%02d, AO '%s', Pri %d NumRun %d, MaxTicksInRun 0x%x, TotalTicksInRun 0x%x, NumCancel %d, NumError %d, LeaveCode %d, NumInstance %d"
                            , (int32)active->iPercent, (int32)decimal
                            , active->iAOName.get_cstr()
+                           , active->iPriority
                            , active->iNumRun
-                           , (int32)active->iTotalTicksInRunL
+                           , active->iMaxTicksInRun
+                           , (int32)active->iTotalTicksInRun
                            , active->iNumCancel
                            , active->iNumRunError
                            , active->iLeave
@@ -711,13 +745,20 @@
     decimal *= 100.0;
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO,
-                    (0, "   Total Time (hi,lo): (0x%x,0x%08x) Units: %s", Oscl_Int64_Utils::get_int64_upper32(total), Oscl_Int64_Utils::get_int64_lower32(total), TICKSTR)
+                    (0, "  Total Time (hi,lo): (0x%x,0x%08x) Units: %s", Oscl_Int64_Utils::get_int64_upper32(total), Oscl_Int64_Utils::get_int64_lower32(total), TICKSTR)
                    )
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO,
-                    (0, "   Total Time Accounted (hi,lo): (0x%x,0x%08x) Units: %s", Oscl_Int64_Utils::get_int64_upper32(iGrandTotalTicks), Oscl_Int64_Utils::get_int64_lower32(iGrandTotalTicks), TICKSTR)
+                    (0, "  Total Time Accounted (hi,lo): (0x%x,0x%08x) Units: %s", Oscl_Int64_Utils::get_int64_upper32(iGrandTotalTicks), Oscl_Int64_Utils::get_int64_lower32(iGrandTotalTicks), TICKSTR)
                    )
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO,
-                    (0, "   Total Percent Accounted: %d.%02d", (int32)iTotalPercent, (int32)decimal)
+                    (0, "  Total Percent Accounted: %d.%02d", (int32)iTotalPercent, (int32)decimal)
+                   )
+
+    PVTICK f;
+    GET_TICKFREQ(f);
+    PVTICK_INT tickint = TICK_INT(f);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO,
+                    (0, "  Tick Units: %s Frequency: %s", TICKSTR, TICK_INT_STR, TICK_INT_EXPR(tickint))
                    )
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, logger, PVLOGMSG_INFO,
@@ -728,8 +769,6 @@
 #endif //PV_SCHED_ENABLE_AO_STATS
 
 
-
-
 void OsclExecSchedulerCommonBase::Error(int32 anError) const
 //call this when any AO leaves and its error handler does not handle the error.
 {
@@ -740,7 +779,6 @@
     OsclError::Leave(anError);
 }
 
-
 OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::StartScheduler(OsclSemaphore *aSignal)
 //blocking call to start PV scheduler.
 //Will leave if any AO leaves.
@@ -765,12 +803,11 @@
 
 }
 
-
 OSCL_EXPORT_REF void OsclExecSchedulerCommonBase::StartNativeScheduler()
 //blocking call to start native scheduler.
 //Will leave if any AO leaves.
 {
-    PV_SCHEDULERPANIC(EPVPanicNativeSchedulerError);
+    OsclError::Leave(OsclErrNotSupported);//native scheduler not supported.
 }
 
 //scheduler stopper request status codes.
@@ -782,7 +819,7 @@
 //any thread can use this to stop the blocking scheduler.
 {
     if (!IsInstalled())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 
     if (!iBlockingMode)
         OsclError::Leave(OsclErrNotReady);
@@ -807,7 +844,7 @@
 //any thread can use this to suspend the blocking scheduler.
 {
     if (!IsInstalled())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 
     if (iNativeMode)
         OsclError::Leave(OsclErrNotSupported);
@@ -829,7 +866,7 @@
 //any thread can use this to resume the blocking scheduler.
 {
     if (!IsInstalled())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 
     if (iDoSuspend || iSuspended)
     {
@@ -851,13 +888,13 @@
 
     //make sure this scheduler is installed.
     if (!IsInstalled())
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 
 #if !(OSCL_RELEASE_BUILD)  && !defined(NDEBUG)
     //make sure this scheduler is really installed in this
     //thread.
     if (GetScheduler() != this)
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
 #endif
 
     //start scheduling if needed.
@@ -866,7 +903,7 @@
         BeginScheduling(false, false);//nonblocking, non-native
     }
     else if (iBlockingMode || iNativeMode)
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotStopped);
+        OsclError::Leave(OsclErrInvalidState);//not stopped
 
     //Process timers.  All ready timers will get
     //moved to the ready queue.
@@ -877,9 +914,7 @@
     for (int32 count = 0;count < aCount;)
     {
         //find highest pri ready AO.
-        iReadyQ.Lock();
         PVActiveBase* pvactive = iReadyQ.PopTop();
-        iReadyQ.Unlock();
         if (pvactive)
         {
             //run it
@@ -902,29 +937,11 @@
 OSCL_EXPORT_REF void OsclExecScheduler::RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext)
 {
     //Update the callback pointers.
-
-    //Use the ready Q lock to avoid thread contention over
-    //callback pointer.
-    iReadyQ.Lock();
-    int32 depth = iReadyQ.Depth();
-    if (depth && aCallback)
-    {
-        //need to callback now!
-        iCallback = NULL;
-        aCallback->OsclSchedulerReadyCallback(aCallbackContext);
-    }
-    else
-    {
-        //save the new pointers.  Callback will happen when timer Q or ready Q is
-        //updated.
-        iCallback = aCallback;
-        iCallbackContext = aCallbackContext;
-    }
-    iReadyQ.Unlock();
+    iReadyQ.RegisterForCallback(aCallback, aCallbackContext);
 }
 
 ////////////////////////////////////////
-// Queue management
+// Queue Management
 ////////////////////////////////////////
 
 
@@ -940,19 +957,6 @@
     return NULL;
 }
 
-#if(PV_SCHED_ENABLE_AO_STATS)
-void OsclExecSchedulerCommonBase::CleanupStatQ()
-{
-    while (!iPVStatQ.IsEmpty())
-    {
-        PVActiveStats* first = iPVStatQ.Head();
-        first->iPVStatQLink.Remove();
-        first->~PVActiveStats();
-        first->iScheduler->iAlloc->deallocate(first);
-    }
-}
-#endif
-
 void OsclExecSchedulerCommonBase::CleanupExecQ()
 {
     //Cleanup timers.
@@ -962,40 +966,34 @@
             top->RemoveFromScheduler();
     }
     //Cleanup ready AOs.
-    iReadyQ.Lock();
     PVActiveBase* top = iReadyQ.Top();
-    iReadyQ.Unlock();
     while (top)
     {
         top->RemoveFromScheduler();
-        iReadyQ.Lock();
         top = iReadyQ.Top();
-        iReadyQ.Unlock();
     }
 }
 
 void OsclExecSchedulerCommonBase::InitExecQ(int nreserve)
 //init the pvactive queues.
 {
-    iExecTimerQ.Init(nreserve, "ExecTimerQ");
-    iReadyQ.Init(nreserve, "ReadyQ");
+    iExecTimerQ.Construct(nreserve);
+    iReadyQ.Construct(nreserve);
 }
 
 ////////////////////////////////////////
-// Ready queue management.
+// Non-Symbian queue management
 ////////////////////////////////////////
 
-
 void OsclExecSchedulerCommonBase::AddToExecTimerQ(PVActiveBase* anActive, uint32 aDelayMicrosec)
 //timer implementation.
 //Add an AO to the pending timer queue.
 {
-    if (!anActive)
-        PV_EXECPANIC(EExecNull);
+    OSCL_ASSERT(anActive);//EExecNull
 
     //make sure this AO is not already added.
-    if (OsclReadyQ::IsInAny(anActive))
-        PV_EXECPANIC(EExecAlreadyAdded);
+    if (anActive->IsInAnyQ())
+        OsclError::Leave(OsclErrInvalidState);//EExecAlreadyAdded
 
     //Set time in ticks when AO should run.
 
@@ -1018,23 +1016,15 @@
                   , timenow));
     }
 
-    //queue with timer sort
-    iExecTimerQ.Add(anActive, true);
+    //queue it
+    iExecTimerQ.Add(anActive);
 
     //if this AO is in the front of the queue now, we need to do a
     //callback, because the shortest delay interval has changed.
-    if (iCallback
+    if (iReadyQ.Callback()
             && anActive == iExecTimerQ.Top())
     {
-        //must use the lock when updating callback pointer.
-        iReadyQ.Lock();
-        OsclSchedulerObserver* callback = iCallback;
-        iCallback = NULL;
-        iReadyQ.Unlock();
-        //callback needs to happen outside the lock, to allow code
-        //to register for additional callback.
-        if (callback)
-            callback->OsclSchedulerTimerCallback(iCallbackContext, aDelayMicrosec / 1000);
+        iReadyQ.TimerCallback(aDelayMicrosec);
     }
 }
 
@@ -1142,370 +1132,25 @@
     return NULL;//no pending timers.
 }
 
-//scheduler has an allocator but there's no way to use
-//it here since this allocator must be a template argument
-//to oscl priority queue.
-OsclAny* OsclReadyAlloc::allocate_fl(const uint32 size, const char * file_name, const int line_num)
-{
-    OsclAny*p = iBasicAlloc.allocate_fl(size, file_name, line_num);
-    OsclError::LeaveIfNull(p);
-    return p;
-}
-OsclAny* OsclReadyAlloc::allocate(const uint32 size)
-{
-    OsclAny*p = iBasicAlloc.ALLOCATE(size);
-    OsclError::LeaveIfNull(p);
-    return p;
-}
-void OsclReadyAlloc::deallocate(OsclAny* p)
-{
-    iBasicAlloc.deallocate(p);
-}
-
-//evalute "priority of a is less than priority of b"
-int OsclReadyCompare::compare(TOsclReady& a, TOsclReady& b) const
-{
-    if (a->iPVReadyQLink.iTimerSort)
-    {
-        //first sort: by time to run.  Earlier "time to run" has precedence.
-        if (a->iPVReadyQLink.iTimeToRunTicks != b->iPVReadyQLink.iTimeToRunTicks)
-        {
-            //calculate a>b, taking possible rollover into account.
-            uint32 delta = b->iPVReadyQLink.iTimeToRunTicks - a->iPVReadyQLink.iTimeToRunTicks;
-            return (delta > OsclExecScheduler::iTimeCompareThreshold);
-        }
-    }
-
-    //second sort: by AO priority.  Higher priority has precedence.
-    if (a->iPVReadyQLink.iAOPriority != b->iPVReadyQLink.iAOPriority)
-        return (a->iPVReadyQLink.iAOPriority < b->iPVReadyQLink.iAOPriority);
-
-    //if there was a priority tie, impose a FIFO order.
-
-//This section allows switching between "fair scheduling" and linear
-//behavior.  We always use fair scheduling, but for testing it can be helpful to
-//swap in the linear behavior.
-#if PV_SCHED_FAIR_SCHEDULING
-    //third sort: by FIFO order, to create fair scheduling.
-    //AOs that have been queued the longest have precedence.
-    return (a->iPVReadyQLink.iSeqNum >= b->iPVReadyQLink.iSeqNum);
-#else
-    //third sort: by the order when AO was added to scheduler, to simulate
-    //Symbian native ActiveScheduler behavior.
-    //AOs that were added earlier have precedence.
-    return (a->iAddedNum > b->iAddedNum);
-#endif
-//End fair scheduling option.
-}
-
-
-void OsclReadyQ::Init(int nreserve, const char* name)
-{
-    iSeqNumCounter = 0;
-    if (nreserve > 0)
-        c.reserve(nreserve);
-    iName = name;
-    iLogger = PVLogger::GetLoggerObject(name);
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Init", iName.get_cstr()));
-}
-
-void OsclReadyQ::Print()
-{
-#if(PV_SCHED_LOG_Q)
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Size %d", iName.get_cstr(), size()));
-    for (uint32 i = 0;i < size();i++)
-    {
-        PVActiveBase* elem = vec()[i];
-        LOGQ((0, " '%s' addr 0x%x pri %d active %d status %d TimeQueued %d"
-              , elem->iName.Str()
-              , elem
-              , elem->iPVReadyQLink.iAOPriority
-              , elem->iBusy
-              , elem->iStatus
-              , elem->iPVReadyQLink.iTimeQueuedTicks
-             ));
-        LOGQ((0, "    TimeToRunTicks %d TimerSort %d SeqNum %d IsIn 0x%x"
-              , elem->iPVReadyQLink.iTimeToRunTicks
-              , elem->iPVReadyQLink.iTimerSort
-              , elem->iPVReadyQLink.iSeqNum
-              , elem->iPVReadyQLink.iIsIn
-             ));
-        if (elem->iStats.iEnable)
-        {
-            LOGQ((0, "    NumRunL %d Leave %d NumCancel %d"
-                  , elem->iStats.iNumRun
-                  , elem->iStats.iLeave
-                  , elem->iStats.iNumCancel
-                 ));
-        }
-    }
-#endif
-}
-
-void OsclReadyQ::Open()
-{
-    iSem.Create();
-    iCrit.Create();
-}
-
-void OsclReadyQ::Close()
-{
-    iSem.Close();
-    iCrit.Close();
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Close", iName.get_cstr()));
-    iLogger = NULL;
-}
-
-void OsclReadyQ::Lock()
-{
-    iCrit.Lock();
-}
-
-void OsclReadyQ::Unlock()
-{
-    iCrit.Unlock();
-}
-
-void OsclReadyQ::Wait()
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Wait IN", iName.get_cstr()));
-    iSem.Wait();
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Wait OUT", iName.get_cstr()));
-}
-
-bool OsclReadyQ::Wait(uint32 timeout)
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Wait %d IN", iName.get_cstr(), timeout));
-    bool ok = (iSem.Wait(timeout) == OsclProcStatus::WAIT_TIMEOUT_ERROR);
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Wait %d OUT returning ok=%d", iName.get_cstr(), timeout, ok));
-    return ok;
-}
-
-void OsclReadyQ::Signal(uint32 count)
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Signal %d IN", iName.get_cstr(), count));
-    for (uint32 i = 0;i < count;i++)
-        iSem.Signal();
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Signal %d OUT", iName.get_cstr(), count));
-}
-
-void OsclReadyQ::Clear()
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Clear IN", iName.get_cstr()));
-    for (PVActiveBase *elem = PopTop();elem;elem = PopTop())
-        ;
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Clear OUT", iName.get_cstr()));
-}
-
-bool OsclReadyQ::IsIn(TOsclReady b)
-//tell if elemement is in this q.
-{
-    return (b->iPVReadyQLink.iIsIn == this);
-}
-
-bool OsclReadyQ::IsInMT(TOsclReady b)
-//tell if elemement is in this q, with thread lock.
-{
-    Lock();
-    bool val = (b->iPVReadyQLink.iIsIn == this);
-    Unlock();
-    return val;
-}
-
-bool OsclReadyQ::IsInAny(TOsclReady b)
-//tell if elemement is in any q.
-{
-    return (b->iPVReadyQLink.iIsIn != NULL);
-}
-
-PVActiveBase* OsclReadyQ::PopTop()
-//deque and return highest pri element.
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) PopTop IN", iName.get_cstr()));
-
-    PVActiveBase*top = Top();
-    if (top)
-        Pop(top);
-
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) PopTop top= 0x%x", iName.get_cstr(), top));
-    if (top)
-    {
-        LOGQ((0, "PVSCHED:OsclReadyQ(%s) PopTop returning AO 0x%x '%s'", iName.get_cstr(), top, top->iName.Str()));
-        OSCL_ASSERT(!IsInAny(top));
-    }
-
-    return top;
-}
-
-PVActiveBase* OsclReadyQ::Top()
-//return highest pri element without removing.
-{
-    if (size() > 0)
-        return top();
-    return NULL;
-}
-
-void OsclReadyQ::Pop(TOsclReady b)
-//remove queue top.
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Pop '%s' IN", iName.get_cstr(), b->iName.Str()));
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(b == Top());
-    OSCL_ASSERT(size() > 0);
-#endif
-
-    b->iPVReadyQLink.iIsIn = NULL;
-
-#if(PV_SCHED_CHECK_Q)
-    uint32 n = size();
-#endif
-
-    pop();
-
-#if(PV_SCHED_LOG_Q)
-    Print();
-#endif
-
-    iSem.Wait();//won't block, just decrementing the sem.
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(size() == n - 1);
-#endif
-
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Pop '%s' OUT", iName.get_cstr(), b->iName.Str()));
-}
-
-void OsclReadyQ::Remove(TOsclReady a)
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Remove '%s' addr 0x%x IN"
-          , iName.get_cstr(), a->iName.Str(), a));
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(IsIn(a));
-    OSCL_ASSERT(size() > 0);
-    uint32 n = size();
-#endif
-
-    a->iPVReadyQLink.iIsIn = NULL;
-
-    int32 nfound = remove(a);
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(nfound == 1);
-#endif
-
-#if(PV_SCHED_LOG_Q)
-    Print();
-#endif
-
-    if (nfound > 0)
-        iSem.Wait();//won't block, just decrementing the sem.
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(size() == n - 1);
-#endif
-
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Remove '%s' OUT", iName.get_cstr(), a->iName.Str()));
-
-}
-
-void OsclReadyQ::Add(TOsclReady b, bool timersort)
-{
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Add IN AO '%s' timer %d seqnum %d", iName.get_cstr()
-          , b->iName.Str(), timersort, iSeqNum + 1));
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(!IsInAny(b));
-#endif
-
-    b->iPVReadyQLink.iTimerSort = timersort;
-    b->iPVReadyQLink.iIsIn = this;
-    b->iPVReadyQLink.iTimeQueuedTicks = OsclTickCount::TickCount();
-    //inc the sequence num for the FIFO sort.
-    b->iPVReadyQLink.iSeqNum = ++iSeqNumCounter;
-
-#if(PV_SCHED_CHECK_Q)
-    uint32 n = size();
-#endif
-
-    push(b);
-
-#if(PV_SCHED_LOG_Q)
-    Print();
-#endif
-
-    iSem.Signal();
-
-#if(PV_SCHED_CHECK_Q)
-    OSCL_ASSERT(size() == n + 1);
-#endif
-
-    LOGQ((0, "PVSCHED:OsclReadyQ(%s) Add OUT", iName.get_cstr()));
-}
-
-uint32 OsclReadyQ::Depth()
-{
-    return size();
-}
-
-
-////////////////////////////////////////
-// request handling
-////////////////////////////////////////
-
-
 void OsclExecSchedulerCommonBase::PendComplete(PVActiveBase *pvbase, int32 aReason, TPVThreadContext aThreadContext)
 //complete a request for this scheduler.
 //Calling context can be any thread.
 {
+    //During timer cancellation, the AO may still be in the ExecTimerQ.
+    //Remove it now, since it won't get removed by the scheduler loop.
+    //Check thread context first, to accessing timer queue from out-of-thread.
     if (aThreadContext == EPVThreadContext_InThread)
     {
         LOGPERF2((0, "PVSCHED: %s AO %s Request complete", iLogPerfIndentStr, pvbase->iName.Str()));
 
-        //for timer cancellation, the AO may still be queued at
-        //this point, so remove it.
-        //check thread context first so we don't try to access
-        //timer Q from out-of-thread.
         if (iExecTimerQ.IsIn(pvbase))
             iExecTimerQ.Remove(pvbase);
     }
 
-    iReadyQ.Lock();
+    //Pass this to the ReadyQ so it can do appropriate queue locks
+    int32 err = iReadyQ.PendComplete(pvbase, aReason);
 
-    //make sure this AO is not already queued.
-    if (OsclReadyQ::IsInAny(pvbase))
-    {
-        iReadyQ.Unlock();
-        PV_EXECPANIC(EExecAlreadyAdded);
-        return;
-    }
-
-    //make sure the AO has a request active
-    if (!pvbase->iBusy
-            || pvbase->iStatus != OSCL_REQUEST_PENDING)
-    {
-        iReadyQ.Unlock();
-        PV_EXECPANIC(EExecStrayEvent);
-        return;
-    }
-
-    //add to ready queue with priority sort.
-    iReadyQ.Add(pvbase, false);
-
-    //update the AO status
-    pvbase->iStatus = aReason;
-
-    //make scheduler callback if needed.
-    //note: this needs to happen under the lock since we're updating
-    //the callback pointer.
-    if (iCallback)
-    {
-        iCallback->OsclSchedulerReadyCallback(iCallbackContext);
-        iCallback = NULL;
-    }
-
-    iReadyQ.Unlock();
+    OsclError::LeaveIfError(err);
 }
 
 void OsclExecSchedulerCommonBase::RequestCanceled(PVActiveBase* pvbase)
@@ -1513,71 +1158,52 @@
     LOGPERF2((0, "PVSCHED: %s AO %s Request canceled", iLogPerfIndentStr, pvbase->iName.Str()));
 
     //This gets called right after the AO's DoCancel was
-    //called.
-    //Calling context is always in-thread.
+    //called.  It must wait on the request to cancel, and remove it
+    //from the ready Q.
+
+    //Calling context is always in-thread, since Cancel context is always
+    //in-thread.
 
     //See if the request was completed by the DoCancel.
-    bool complete = iReadyQ.IsInMT(pvbase);
+    bool complete = iReadyQ.IsIn(pvbase);
+
+    DECLARE_LOOP_STATS;
 
     if (!complete)
     {
         //If request is still pending after DoCancel is called, it
         //means some other thread will complete the request cancellation.
-        //If the AO does not have a proper DoCancel, this will hang up.
+        //If the AO does not have a proper DoCancel, this wait will hang up.
 
-#if (PV_SCHED_PERF_LOGGING)
-        uint32 time = 0;
+        //reset the perf indent when scheduler gives up CPU...
+        RESET_LOG_PERF((0, "PVSCHED: Waiting on cancel... AO '%s'", pvbase->iName.Str()));
+
+#if (PV_SCHED_ENABLE_PERF_LOGGING)
+        uint32 ticks = OsclTickCount::TickCount();
 #endif
-        int32 nwait = 0;
-        while (!complete)
-        {
-#if (PV_SCHED_PERF_LOGGING)
-            if (nwait == 0)
-            {
-                if (DO_LOGPERF)
-                {
-                    //reset the perf indent when scheduler gives up CPU...
-                    ResetLogPerf();
-                    LOGPERF((0, "PVSCHED: Waiting on cancel... AO '%s'", pvbase->iName.Str()));
-                    time = OsclTickCount::TickCount();
-                }
-            }
+        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
+        int32 err = iReadyQ.WaitForRequestComplete(pvbase);
+        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
+
+#if (PV_SCHED_ENABLE_PERF_LOGGING)
+        LOGPERF((0, "PVSCHED: ...Cancel took %d Ticks", OsclTickCount::TickCount() - ticks));
 #endif
-            //Wait on some request to complete.
-            iReadyQ.Wait();
-            nwait++;
 
-            //Some request was complete but it might not be this one, so
-            //check again.
-            complete = iReadyQ.IsInMT(pvbase);
-        }
-
-        //Restore the request semaphore value since we decremented it without
-        //removing anything from the ReadyQ.
-        if (nwait > 0)
-        {
-            iReadyQ.Signal(nwait);
-        }
-
-#if (PV_SCHED_PERF_LOGGING)
-        if (DO_LOGPERF)
-        {
-            uint32 delta = OsclTickCount::TickCount() - time;
-            LOGPERF((0, "PVSCHED: ...Cancel took %d Ticks", delta));
-        }
-#endif
+        OsclError::LeaveIfError(err);
     }
 
     //Set request idle and remove from ready Q.
     //The AO will not run
     pvbase->iBusy = false;
-    iReadyQ.Lock();
+
+    START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
     iReadyQ.Remove(pvbase);
-    iReadyQ.Unlock();
+    END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
 }
 
 
 
+
 ////////////////////////////////////////
 // PV Scheduling Loop Implementation
 ////////////////////////////////////////
@@ -1593,13 +1219,12 @@
 
     //start stats
 #if (PV_SCHED_ENABLE_AO_STATS)
-    PVActiveStats* pvstats = pvactive->iPVActiveStats;
-    uint32 delta = 0;
-    PVTICK time;
-    time = 0;
+    iPVStats = pvactive->iPVActiveStats;//save value now since it may change in the Run call.
+    iDelta = 0;
+    INIT_TICK(iTime);
 #endif
 
-    SET_TICK(time);
+    SET_TICK(iTime);
 
     //Call the Run under a trap harness.
     //Pass the ErrorTrapImp pointer to reduce overhead of the Try call.
@@ -1608,31 +1233,28 @@
     OSCL_TRY_NO_TLS(iErrorTrapImp, err, pvactive->Run(););
 
     //end stats
-    DIFF_TICK(time, delta);
-    UPDATE_RUNL_TIME(pvstats, delta);
-    UPDATE_LEAVE_CODE(pvstats, err);
+    DIFF_TICK(iTime, iDelta);
+    UPDATE_RUNL_TIME(iPVStats, iDelta);
+    UPDATE_LEAVE_CODE(iPVStats, err);
 
 #if(PV_SCHED_ENABLE_PERF_LOGGING)
     //show AO time.
-    if (DO_LOGPERF)
-    {
-        IncLogPerf(delta);
-        LOGPERF((0, "PVSCHED: %s Run %d %s AO %s", iLogPerfIndentStr, (int32)delta, TICKSTR, pvactive->iName.Str()));
-    }
+    IncLogPerf(iDelta);
+    LOGPERF((0, "PVSCHED: %s Run %d %s AO %s", iLogPerfIndentStr, (int32)iDelta, TICKSTR, pvactive->iName.Str()));
 #endif
 
     //check for a leave in the Run...
     if (err != OsclErrNone)
     {
         //start stats
-        SET_TICK(time);
+        SET_TICK(iTime);
 
         //call the AO error handler
         err = pvactive->RunError(err);
 
         //end stats
-        DIFF_TICK(time, delta);
-        UPDATE_RUNERROR_TIME(pvstats, delta);
+        DIFF_TICK(iTime, iDelta);
+        UPDATE_RUNERROR_TIME(iPVStats, iDelta);
 
         //If the AO did not handle the error, indicated by returning
         //ErrNone, then call the scheduler error handler.
@@ -1648,6 +1270,7 @@
             Error(err);
         }
     }
+
 }
 
 
@@ -1656,96 +1279,21 @@
 //Will leave if any AO leaves.
 {
 
+    PVActiveBase* pvactive;
+
+
     while (!iDoStop)
     {
-        DECLARE_LOOP_STATS;
-
-
-
-        //First process timers.
-        //All ready timers will get moved to the run Q.
-        uint32 waitTicks;
-
-        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
-        PVActiveBase* pvtimer = UpdateTimers(waitTicks);
-        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
-
-        //now find the highest priority ready AO.
-
-        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_LockTime]);
-        iReadyQ.Lock();
-        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_LockTime]);
-
-        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
-        PVActiveBase* pvactive = iReadyQ.PopTop();
-        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
-
-        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_LockTime]);
-        iReadyQ.Unlock();
-        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_LockTime]);
-
+        //Get the next AO to run.  This call may block until an AO is ready.
+        pvactive = WaitForReadyAO();
 
         if (pvactive)
         {
-            //Run this AO.
             CallRunExec(pvactive);
-
         }
-        else //nothing is ready.
+        else
         {
-            //We have to wait on either a timer interval to expire,
-            //or a request to be completed by some other thread.
-            if (pvtimer)
-            {
-#if (PV_SCHED_ENABLE_PERF_LOGGING)
-                //reset the perf logging indent each time scheduler gives up CPU.
-                ResetLogPerf();
-                LOGPERF((0, "PVSCHED: Waiting on timer... Ticks %d AO %s", waitTicks, pvtimer->iName.Str()));
-#endif
-
-                START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
-
-                //Wait on shortest timer expiration or a new request.
-                if (iReadyQ.Wait(OsclTickCount::TicksToMsec(waitTicks)))
-                {
-                    END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
-
-                    //Timeout.
-                    //It's time to complete this timer's request and run it.
-                    //There's no need to move it to the ReadyQ, just run it.
-                    pvtimer->iStatus = OSCL_REQUEST_ERR_NONE;
-                    //it's the top of the queue so we can remove it with Pop.
-                    START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
-                    iExecTimerQ.Pop(pvtimer);
-                    END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
-                    CallRunExec(pvtimer);
-                }
-                else //another thread completed a request during the wait.
-                {
-                    //restore request sem since we didn't run the AO yet.
-                    iReadyQ.Signal();
-
-                    END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
-
-                }
-            }
-            else //nothing ready and no timers pending.
-            {
-#if (PV_SCHED_ENABLE_PERF_LOGGING)
-                //reset the perf logging indent each time scheduler gives up CPU.
-                ResetLogPerf();
-                LOGPERF((0, "PVSCHED: Waiting on any request..."));
-#endif
-
-                START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
-
-                //this will block until a request is completed by another thread.
-                iReadyQ.Wait();
-                //restore request sem since we didn't run the AO yet.
-                iReadyQ.Signal();
-
-                END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
-            }
+            OsclError::Leave(OsclErrCorrupt);//EExecStrayEvent
         }
 
         //check for a suspend signal..
@@ -1760,12 +1308,82 @@
     }//while !dostop
 
     iDoStop = false;
-
 }
 
 
+PVActiveBase* OsclExecSchedulerCommonBase::WaitForReadyAO()
+//Find the next AO to run-- non-Symbian version.
+{
+    DECLARE_LOOP_STATS;
+
+    //First process timers.
+    //All ready timers will get moved to the run Q.
+    uint32 waitTicks;
+    START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
+    PVActiveBase* pvtimer = UpdateTimers(waitTicks);
+    END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
+
+    //Check for a ready AO.
+    START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
+    PVActiveBase* pvactive = iReadyQ.PopTop();
+    END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
+
+    if (pvactive)
+    {
+        //An AO is ready.
+        return pvactive;
+    }
+    else if (pvtimer)
+    {
+        //No AO is ready, but at least one timer is pending.
+        //Wait on shortest timer expiration or a new request.
+
+        //reset the perf logging indent each time scheduler gives up CPU.
+        RESET_LOG_PERF((0, "PVSCHED: Waiting on timer... Ticks %d AO %s", waitTicks, pvtimer->iName.Str()));
+
+        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
+        pvactive = iReadyQ.WaitAndPopTop(OsclTickCount::TicksToMsec(waitTicks));
+        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
+
+        if (pvactive)
+        {
+            //Another AO's request completed while we were waiting.
+            //Run that one instead of the timer.
+            return pvactive;
+        }
+        else
+        {
+            //It's time to complete this timer's request and run it.
+            //To save overhead, don't move it to the ReadyQ, just pop it
+            //from its current location on the top of the timer queue.
+
+            pvtimer->iStatus = OSCL_REQUEST_ERR_NONE;
+
+            START_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
+            iExecTimerQ.Pop(pvtimer);
+            END_LOOP_STATS(iOtherExecStats[EOtherExecStats_QueueTime]);
+
+            return pvtimer;
+        }
+    }
+    else
+    {
+        //Nothing is ready and no timer is pending.
+        //Wait on a request to be completed by another thread.
+
+        //reset the perf logging indent each time scheduler gives up CPU.
+        RESET_LOG_PERF((0, "PVSCHED: Waiting on any request..."));
+
+        START_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
+        pvactive = iReadyQ.WaitAndPopTop();
+        END_LOOP_STATS(iOtherExecStats[EOtherExecStats_WaitTime]);
+
+        return pvactive;
+    }
+}
+
 ////////////////////////////////////////
-// PVSchedulerStopper Implementation
+// PVSchedulerStopper
 ////////////////////////////////////////
 PVSchedulerStopper::PVSchedulerStopper()
         : OsclActiveObject((int32)OsclActiveObject::EPriorityHighest, "Stopper")
@@ -1808,6 +1426,9 @@
     }
 }
 
+////////////////////////////////////////
+// Symbian Coe Scheduler
+////////////////////////////////////////
 
 
 
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler.h b/oscl/oscl/osclproc/src/oscl_scheduler.h
index c02e378..6d4b75a 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -91,31 +91,6 @@
         OSCL_IMPORT_REF static void Cleanup();
 };
 
-/**
- * Panics generated by PV Scheduler, with
- * panic category "PVSCHED"
- */
-enum TPVSchedulerPanicEnum
-{
-    //to avoid confusion with EExecPanic, start at 90.
-    EPVPanicSchedulerNotInstalled = 90
-    , EPVPanicSchedulerAlreadyInstalled = 91
-    , EPVPanicSchedulerNotStopped = 92
-    , EPVPanicThreadContextUnknown = 93
-    , EPVPanicThreadContextIncorrect = 94
-    , EPVPanicThreadContextError = 95
-    , EPVPanicCActiveClassMismatch = 96
-    , EPVPanicCActiveSchedulerClassMismatch = 97
-    , EPVPanicTRequestStatusClassMismatch = 98
-    , EPVPanicTickCountPeriodZero = 99
-    , EPVPanicNativeSchedulerError = 100
-    , EPVPanicMutexError = 101
-    , EPVPanicBadRequestStatus = 102
-    , EPVPanicBadDoCancel = 103
-    , EPVPanicNotSupported = 104
-    , EPVPanicReleaseNotAvailable = 105
-    , EPVPanicErrorTrapNotInstalled = 106
-};
 
 /**
  * PV Scheduler class
@@ -253,7 +228,7 @@
         //Stopper AO is a special PV AO used to implement
         //the StopScheduler and SuspendScheduler functions.
         PVSchedulerStopper *iStopper;
-        OsclMutex iStopperCrit;
+        OsclNoYieldMutex iStopperCrit;
 
         //Scheduler thread context
         PVThreadContext iThreadContext;
@@ -269,13 +244,12 @@
 
         OsclErrorTrapImp* iErrorTrapImp;
 
-
         //Ready AO queue.  The AOs in this queue are ready to run.
         OsclReadyQ iReadyQ;
 
         //Pending Timer AO queue.  The AOs in this queue are OsclTimerObjects
         //and have a timeout pending.
-        OsclReadyQ iExecTimerQ;
+        OsclTimerQ iExecTimerQ;
         void AddToExecTimerQ(PVActiveBase *active, uint32);
 
         void PendComplete(PVActiveBase *, int32 aReason, TPVThreadContext aContext);
@@ -284,10 +258,11 @@
         //Scheduling loop implementation.
         PVActiveBase* UpdateTimers(uint32 &aDelay);
         PVActiveBase* UpdateTimersMsec(uint32 &aDelay);
+        PVActiveBase* WaitForReadyAO();
         void CallRunExec(PVActiveBase*);
 
         static const uint32 iTimeCompareThreshold;
-        friend class OsclReadyCompare;
+        friend class OsclTimerCompare;
         friend class OsclReadyQ;
 
         friend class OsclError;
@@ -302,12 +277,13 @@
         enum TOtherExecStats
         {
             EOtherExecStats_WaitTime //scheduler wait time
-            , EOtherExecStats_LockTime //scheduler queue lock wait time
             , EOtherExecStats_QueueTime //scheduler queue operation time
-            , EOtherExecStats_NativeOS //symbian native ExecObjs, not added by PV code (symbian only)
+            , EOtherExecStats_NativeOS //time in symbian native ExecObjs, not added by PV code (symbian only)
+            , EOtherExecStats_ReleaseTime //thread release time (Brew only)
             , EOtherExecStats_Last
         };
         PVActiveStats* iOtherExecStats[EOtherExecStats_Last];//placeholder for stats of all ExecObjs.
+        void ConstructStatQ();
         void BeginStats();
         void EndStats();
         static void ShowStats(PVActiveStats *active);
@@ -317,7 +293,10 @@
         int64 iGrandTotalTicks;
         float iTotalPercent;
         friend class PVActiveStats;
-#endif
+        uint32 iTime;
+        int32 iDelta;
+        PVActiveStats* iPVStats;
+#endif //PV_SCHED_ENABLE_AO_STATS
 
         //Queue utils.
         PVActiveBase *FindPVBase(PVActiveBase *active, OsclDoubleList<PVActiveBase> &);
@@ -344,11 +323,6 @@
         friend class PVActiveBase;
         friend class PVSchedulerStopper;
 
-        //for non-blocking mode with callbacks
-        OsclSchedulerObserver* iCallback;
-        OsclAny* iCallbackContext;
-
-
 
         friend class OsclExecScheduler;
 };
@@ -384,7 +358,7 @@
          *   first of the pending timer objects will be ready to run, in milliseconds.
          *
          * Note: On Symbian, non-blocking mode is not supported and this call will
-         *  raise a panic.
+         *  leave.
          *
          */
         OSCL_IMPORT_REF void RunSchedulerNonBlocking(int32 aTargetCount, int32 &aReady, uint32 &aDelayMsec);
@@ -394,7 +368,7 @@
          * again.
          *
          * Note: On Symbian, non-blocking mode is not supported and this call will
-         *  raise a panic.
+         *  leave.
          */
         OSCL_IMPORT_REF void RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext);
 
@@ -424,11 +398,6 @@
         void Run();
 };
 
-/**
- * Internal-use macros to generate panics.
- */
-#define PV_SCHEDULERPANIC(x) OsclError::Panic("PVSCHED",x)
-
 
 #endif
 
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp b/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp
index e5102db..6c1d581 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_ao.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@
 PVActiveBase::~PVActiveBase()
 {
     if (iBusy)
-        PV_EXECPANIC(EExecStillReadyOnDestruct);
+        OsclError::Leave(OsclErrInvalidState);//EExecStillReadyOnDestruct
 }
 
 #if(PV_SCHED_ENABLE_AO_STATS)
@@ -62,13 +62,15 @@
 
     iNumRun = 0;
     iNumRunError = 0;
-    iTotalTicksInRunL = 0;
+    iMaxTicksInRun = 0;
+    iTotalTicksInRun = 0;
     i64Valid = true;//make 64-bit the default.
-    i64TotalTicksInRunL = 0;
+    i64TotalTicksInRun = 0;
     iPercent = 0.0;
     iLeave = OsclErrNone;
     iNumCancel = 0;
     iNumInstances = 1;
+    iPriority = (aActiveBase) ? aActiveBase->iPVReadyQLink.iAOPriority : 0;
 }
 PVActiveStats::~PVActiveStats()
 {
@@ -82,9 +84,9 @@
 {
     iNumRun += aStats.iNumRun;
     iNumRunError += aStats.iNumRunError;
-    iTotalTicksInRunL += aStats.iTotalTicksInRunL;
+    iTotalTicksInRun += aStats.iTotalTicksInRun;
     OSCL_ASSERT(i64Valid == aStats.i64Valid);
-    i64TotalTicksInRunL += aStats.i64TotalTicksInRunL;
+    i64TotalTicksInRun += aStats.i64TotalTicksInRun;
     iNumCancel += aStats.iNumCancel;
     if (aStats.iLeave != OsclErrNone)
         iLeave = aStats.iLeave;
@@ -153,14 +155,14 @@
 //activation that is common to both timers and non-timers.
 {
 
-    //generate standard symbian panics.
+    //mimic standard symbian panics.
     if (iBusy)
-        PV_EXECPANIC(EExecAlreadyActive);
+        OsclError::Leave(OsclErrInvalidState);//EExecAlreadyActive
     if (!iThreadContext.iOpen)
-        PV_EXECPANIC(EExecNotAdded);
+        OsclError::Leave(OsclErrInvalidState);//EExecNotAdded
 
 #if PV_SCHED_ENABLE_THREAD_CONTEXT_CHECKS
-    PVThreadContext::PanicIfWrongThread(iThreadContext);
+    PVThreadContext::LeaveIfWrongThread(iThreadContext);
 #endif
 
     iBusy = true;
@@ -170,7 +172,7 @@
 
 }
 
-bool PVActiveBase::IsAdded() const
+OSCL_EXPORT_REF bool PVActiveBase::IsAdded() const
 {
     return iThreadContext.iOpen;
 }
@@ -183,7 +185,7 @@
 #if PV_SCHED_ENABLE_THREAD_CONTEXT_CHECKS
         //require same thread context for cancel calls,
         //since we'll be calling the DoCancel routine.
-        PVThreadContext::PanicIfWrongThread(iThreadContext);
+        PVThreadContext::LeaveIfWrongThread(iThreadContext);
 #endif
 
         //call the cancel handler-- this should
@@ -207,8 +209,7 @@
 /////////////////////
 
 OSCL_EXPORT_REF OsclActiveObject::OsclActiveObject(int32 aPriority, const char name[]):
-        PVActiveBase(name, aPriority),
-        OsclActiveObj()
+        PVActiveBase(name, aPriority)
 {
     iStatus = OSCL_REQUEST_ERR_NONE;
 }
@@ -321,7 +322,6 @@
 
 OSCL_EXPORT_REF OsclTimerObject::OsclTimerObject(int32 aPriority, const char name[]):
         PVActiveBase(name, aPriority)
-        , OsclTimerBase()
 {
     SetStatus(OSCL_REQUEST_ERR_NONE);
 }
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_ao.h b/oscl/oscl/osclproc/src/oscl_scheduler_ao.h
index 7ac07b9..fe00b9c 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_ao.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_ao.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,9 +47,9 @@
  * This AO can be used across threads, i.e. the request
  * can be activated in one thread and completed in another.
  */
-class OsclActiveObject: public HeapBase
-            , public PVActiveBase
-            , public OsclActiveObj
+class OsclActiveObject:
+            public HeapBase,
+            public PVActiveBase
 {
     public:
         /**
@@ -97,7 +97,7 @@
         /**
          * Set object ready for this AO,
          * additionally sets the request status to OSCL_REQUEST_PENDING.
-         * Will panic if the request is already readied,
+         * Will leave if the request is already readied,
          * or the execution object is not added to any scheduler,
          * or the calling thread context does not match
          * the scheduler thread.
@@ -120,7 +120,7 @@
         /**
          * Complete the active request for the AO.
          * This API is thread-safe.
-         * If the request is not pending, this call will panic.
+         * If the request is not pending, this call will leave.
          * @param aStatus: request completion status.
          */
         OSCL_IMPORT_REF void PendComplete(int32 aStatus);
@@ -132,7 +132,7 @@
 
         /**
          * Remove this AO from its scheduler.
-         * Will panic if the calling thread context does
+         * Will leave if the calling thread context does
          * not match the scheduling thread.
          * Cancels any readied request before removing.
          */
@@ -142,7 +142,7 @@
         /**
          * Complete this AO's request immediately.
          * If the AO is already active, this will do nothing.
-         * Will panic if the AO is not acced to any scheduler,
+         * Will leave if the AO is not acced to any scheduler,
          * or if the calling thread context does not match the
          * scheduling thread.
          */
@@ -204,7 +204,6 @@
  */
 class OsclTimerObject: public HeapBase
             , public PVActiveBase
-            , public OsclTimerBase
 {
     public:
         /**
@@ -227,7 +226,7 @@
 
         /**
          * Remove this AO from its scheduler.
-         * Will panic if the calling thread context does
+         * Will leave if the calling thread context does
          * not match the scheduling thread.
          * Cancels any pending request before removing.
          */
@@ -241,7 +240,7 @@
         * status OSCL_REQUEST_ERR_NONE.
         * Must be called from the same thread in which the
         * active object is scheduled.
-        * Will panic if the request is already readied, the object
+        * Will leave if the request is already readied, the object
         * is not added to any scheduler, or the calling thread
         * does not match the scheduling thread.
         * @param anInterval: timeout interval in microseconds.
@@ -260,7 +259,7 @@
 
         /**
          * Set request ready for this AO.
-         * Will panic if the request is already readied,
+         * Will leave if the request is already readied,
          * or the exec object is not added to any scheduler,
          * or the calling thread context does not match
          * the scheduler thread.
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h b/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h
index 5e42532..eab0cf2 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_aobase.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -91,11 +91,12 @@
 
         uint32 iNumRun;//how many Run calls
         uint32 iNumRunError;//how many RunError calls
+        int32 iMaxTicksInRun;//max time in any one Run call
 
-        uint32 iTotalTicksInRunL;
+        uint32 iTotalTicksInRun;
 
         bool i64Valid;//use 64-bit stats instead of 32-bit
-        int64 i64TotalTicksInRunL;//avg number of clock ticks per Run
+        int64 i64TotalTicksInRun;//avg number of clock ticks per Run
 
         //for internal computation-- percent of total time in this Run
         float iPercent;
@@ -104,6 +105,7 @@
         uint32 iNumCancel;//how many DoCancel calls.
 
         uint32 iNumInstances;//number of scheduler instances of this AO.
+        int32 iPriority;//scheduler priority
 
         friend class PVActiveBase;
         friend class OsclExecScheduler;
@@ -159,11 +161,19 @@
         */
 
         /*
-        ** Queue link for scheduler iActiveTimerQ or iReadyQ.
+        ** Queue link for scheduler iExecTimerQ or iReadyQ.
         */
         TReadyQueLink iPVReadyQLink;
 
         /*
+        ** Return true if this AO is in any queue.
+        */
+        bool IsInAnyQ()
+        {
+            return(iPVReadyQLink.iIsIn != NULL);
+        }
+
+        /*
         ** The executing flag is set whenever a request is active (pending
         ** or complete).  The AO is de-activated by scheduler just before
         ** calling the Run.
@@ -247,7 +257,7 @@
         void RemoveFromScheduler();
         void Destroy();
         void Activate();
-        bool IsAdded()const;
+        OSCL_IMPORT_REF bool IsAdded()const;
         void Cancel();
 
         friend class OsclSchedulerCommonBase;
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_readyq.cpp b/oscl/oscl/osclproc/src/oscl_scheduler_readyq.cpp
new file mode 100644
index 0000000..74ab5a8
--- /dev/null
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_readyq.cpp
@@ -0,0 +1,415 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+
+#include "oscl_scheduler_readyq.h"
+
+
+#include "oscl_scheduler_ao.h"
+#include "oscl_scheduler.h"
+#include "oscl_tickcount.h"
+#include "oscl_scheduler_tuneables.h"
+
+////////////////////////////////////////
+// Ready Queue & Timer Queue Support
+////////////////////////////////////////
+
+//scheduler has an allocator but there's no way to use
+//it here since this allocator must be a template argument
+//to oscl priority queue.
+OsclAny* OsclReadyAlloc::allocate_fl(const uint32 size, const char * file_name, const int line_num)
+{
+    OsclAny*p = iBasicAlloc.allocate_fl(size, file_name, line_num);
+    OsclError::LeaveIfNull(p);
+    return p;
+}
+OsclAny* OsclReadyAlloc::allocate(const uint32 size)
+{
+    OsclAny*p = iBasicAlloc.ALLOCATE(size);
+    OsclError::LeaveIfNull(p);
+    return p;
+}
+void OsclReadyAlloc::deallocate(OsclAny* p)
+{
+    iBasicAlloc.deallocate(p);
+}
+
+//evalute "priority of a is less than priority of b"
+int OsclTimerCompare::compare(TOsclReady& a, TOsclReady& b)
+{
+    //Sort by time to run.  Earlier "time to run" has precedence.
+    if (a->iPVReadyQLink.iTimeToRunTicks != b->iPVReadyQLink.iTimeToRunTicks)
+    {
+        //calculate a>b, taking possible rollover into account.
+        uint32 delta = b->iPVReadyQLink.iTimeToRunTicks - a->iPVReadyQLink.iTimeToRunTicks;
+        return (delta > OsclExecScheduler::iTimeCompareThreshold);
+    }
+
+    //Now sort by priority
+    return OsclReadyCompare::compare(a, b);
+}
+
+//evalute "priority of a is less than priority of b"
+int OsclReadyCompare::compare(TOsclReady& a, TOsclReady& b)
+{
+    //Sort by AO priority.  Higher priority has precedence.
+    if (a->iPVReadyQLink.iAOPriority != b->iPVReadyQLink.iAOPriority)
+        return (a->iPVReadyQLink.iAOPriority < b->iPVReadyQLink.iAOPriority);
+
+    //if there was a priority tie, impose a FIFO order.
+
+    //This section allows switching between "fair scheduling" and linear
+    //behavior.  We always use fair scheduling, but for testing it can be helpful to
+    //swap in the linear behavior.
+#if PV_SCHED_FAIR_SCHEDULING
+    //Sort by FIFO order, to create fair scheduling.
+    //AOs that have been queued the longest have precedence.
+    return (a->iPVReadyQLink.iSeqNum >= b->iPVReadyQLink.iSeqNum);
+#else
+    //Sort by the order when AO was added to scheduler, to simulate
+    //Symbian native ActiveScheduler behavior.
+    //AOs that were added earlier have precedence.
+    return (a->iAddedNum > b->iAddedNum);
+#endif
+
+}
+
+////////////////////////////////////////
+//OsclReadyQ
+////////////////////////////////////////
+void OsclReadyQ::Construct(int nreserve)
+{
+    iSeqNumCounter = 0;
+    if (nreserve > 0)
+        c.reserve(nreserve);
+    iCallback = NULL;
+}
+
+void OsclReadyQ::ThreadLogon()
+{
+    iSem.Create();
+    iCrit.Create();
+}
+
+void OsclReadyQ::ThreadLogoff()
+{
+    iSem.Close();
+    iCrit.Close();
+}
+
+//
+//Note: all semaphore errors are fatal, since they can cause
+// scheduler to spin or hang.
+//
+
+PVActiveBase* OsclReadyQ::WaitAndPopTop()
+//block until an AO is ready and pop the highest pri AO.
+{
+    switch (iSem.Wait())
+    {
+        case OsclProcStatus::SUCCESS_ERROR:
+            return PopTopAfterWait();
+
+        default:
+            OsclError::Leave(OsclErrSystemCallFailed);
+            return NULL;
+    }
+}
+
+PVActiveBase* OsclReadyQ::WaitAndPopTop(uint32 aTimeoutVal)
+//block until an AO is ready or timeout is reached.
+{
+    switch (iSem.Wait(aTimeoutVal))
+    {
+        case OsclProcStatus::WAIT_TIMEOUT_ERROR:
+            //timeout reached, no AO ready.
+            return NULL;
+
+        case OsclProcStatus::SUCCESS_ERROR:
+            //an AO is ready-- pop it.
+            return PopTopAfterWait();
+
+        default:
+            //no timeout and no AO.
+            OsclError::Leave(OsclErrSystemCallFailed);
+            return NULL;
+    }
+}
+
+bool OsclReadyQ::IsIn(TOsclReady b)
+//tell if elemement is in this q
+{
+    iCrit.Lock();
+    bool isin = (b->iPVReadyQLink.iIsIn == this);
+    iCrit.Unlock();
+    return isin;
+}
+
+PVActiveBase* OsclReadyQ::PopTop()
+//deque and return highest pri element.
+{
+    iCrit.Lock();
+
+    PVActiveBase*elem = (size() > 0) ? top() : NULL;
+    if (elem)
+    {
+        elem->iPVReadyQLink.iIsIn = NULL;
+
+        pop();
+
+        //this call won't block-- it will just decrement the sem.
+        if (iSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
+            OsclError::Leave(OsclErrSystemCallFailed);
+    }
+
+    iCrit.Unlock();
+    return elem;
+}
+
+PVActiveBase* OsclReadyQ::PopTopAfterWait()
+//deque and return highest pri element.  used when we have
+//already done a sem wait prior to this call, so there is no sem
+//decrement here.
+{
+    iCrit.Lock();
+
+    PVActiveBase*elem = (size() > 0) ? top() : NULL;
+
+    if (elem)
+    {
+        elem->iPVReadyQLink.iIsIn = NULL;
+        pop();
+    }
+    else
+    {//there should always be an element available after a sem wait.
+        OSCL_ASSERT(0);
+    }
+
+    iCrit.Unlock();
+
+    return elem;
+}
+
+PVActiveBase* OsclReadyQ::Top()
+//return highest pri element without removing.
+{
+    iCrit.Lock();
+    PVActiveBase* elem = (size() > 0) ? top() : NULL;
+    iCrit.Unlock();
+    return elem;
+}
+
+void OsclReadyQ::Remove(TOsclReady a)
+//remove the given element
+{
+    iCrit.Lock();
+
+    a->iPVReadyQLink.iIsIn = NULL;
+
+    int32 nfound = remove(a);
+
+    if (nfound > 0)
+    {
+        //this call won't block-- it will just decrement the sem.
+        if (iSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
+            OsclError::Leave(OsclErrSystemCallFailed);
+    }
+
+    iCrit.Unlock();
+}
+
+int32 OsclReadyQ::PendComplete(PVActiveBase *pvbase, int32 aReason)
+//Complete an AO request
+{
+    iCrit.Lock();
+
+    //make sure this AO is not already queued.
+    int32 err;
+    if (pvbase->IsInAnyQ())
+    {
+        err = OsclErrInvalidState;//EExecAlreadyAdded
+    }
+    //make sure the AO has a request active
+    else if (!pvbase->iBusy
+             || pvbase->iStatus != OSCL_REQUEST_PENDING)
+    {
+        err = OsclErrCorrupt;//EExecStrayEvent;
+    }
+    else
+    {
+        //Add to pri queue
+        pvbase->iPVReadyQLink.iIsIn = this;
+        pvbase->iPVReadyQLink.iTimeQueuedTicks = OsclTickCount::TickCount();
+        pvbase->iPVReadyQLink.iSeqNum = ++iSeqNumCounter;//for the FIFO sort
+        push(pvbase);
+
+        //increment the sem
+        if (iSem.Signal() != OsclProcStatus::SUCCESS_ERROR)
+        {
+            err = OsclErrSystemCallFailed;
+        }
+        else
+        {
+            //update the AO status
+            pvbase->iStatus = aReason;
+
+            //make scheduler callback if needed.
+            //note: this needs to happen under the lock since we're updating
+            //the callback pointer.
+            if (iCallback)
+            {
+                iCallback->OsclSchedulerReadyCallback(iCallbackContext);
+                iCallback = NULL;
+            }
+            err = OsclErrNone;
+        }
+    }
+
+    iCrit.Unlock();
+    return err;
+}
+
+int32 OsclReadyQ::WaitForRequestComplete(PVActiveBase* pvbase)
+//Wait on a particular request to complete
+{
+    int32 nwait = 0;//count the number of request sem waits.
+
+    for (bool complete = false;!complete;)
+    {
+        //Wait on any request to complete.
+        if (iSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
+            return OsclErrSystemCallFailed;
+
+        nwait++;
+
+        //Some request was complete but it might not be the one of interest,
+        //so check for completion again.
+        complete = IsIn(pvbase);
+    }
+
+    //Restore the request semaphore value since we may have decremented it without
+    //removing anything from the ReadyQ.
+    while (nwait > 0)
+    {
+        if (iSem.Signal() != OsclProcStatus::SUCCESS_ERROR)
+            return OsclErrSystemCallFailed;
+
+        nwait--;
+    }
+
+    return OsclErrNone;
+}
+
+void OsclReadyQ::RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext)
+{
+    //Use the Q lock to avoid thread contention over
+    //callback pointer.
+    iCrit.Lock();
+
+    //Callback right away if ready Q is non-empty.
+    if (size() && aCallback)
+    {
+        iCallback = NULL;
+        aCallback->OsclSchedulerReadyCallback(aCallbackContext);
+    }
+    else
+    {
+        //save the new pointers.  Callback will happen when timer Q or ready Q is
+        //updated.
+        iCallback = aCallback;
+        iCallbackContext = aCallbackContext;
+    }
+    iCrit.Unlock();
+}
+
+void OsclReadyQ::TimerCallback(uint32 aDelayMicrosec)
+//Inform scheduler observer of a change in the shortest timer interval
+{
+    //lock when updating callback pointer.
+    iCrit.Lock();
+    OsclSchedulerObserver* callback = iCallback;
+    iCallback = NULL;
+    iCrit.Unlock();
+
+    //Timer callback happens outside the lock, to allow code
+    //to register for additional callback.
+    if (callback)
+        callback->OsclSchedulerTimerCallback(iCallbackContext, aDelayMicrosec / 1000);
+}
+
+////////////////////////////////////////
+//OsclTimerQ
+////////////////////////////////////////
+void OsclTimerQ::Construct(int nreserve)
+{
+    iSeqNumCounter = 0;
+    if (nreserve > 0)
+        c.reserve(nreserve);
+}
+
+bool OsclTimerQ::IsIn(TOsclReady b)
+//tell if element is in this q
+{
+    return (b->iPVReadyQLink.iIsIn == this);
+}
+
+PVActiveBase* OsclTimerQ::PopTop()
+//deque and return highest pri element.
+{
+    PVActiveBase*elem = (size() > 0) ? top() : NULL;
+    if (elem)
+        Pop(elem);
+
+    return elem;
+}
+
+PVActiveBase* OsclTimerQ::Top()
+//return highest pri element without removing.
+{
+    return (size() > 0) ? top() : NULL;
+}
+
+void OsclTimerQ::Pop(TOsclReady b)
+//remove queue top.
+{
+    b->iPVReadyQLink.iIsIn = NULL;
+    pop();
+}
+
+void OsclTimerQ::Remove(TOsclReady a)
+{
+    a->iPVReadyQLink.iIsIn = NULL;
+    remove(a);
+}
+
+void OsclTimerQ::Add(TOsclReady b)
+{
+    b->iPVReadyQLink.iIsIn = this;
+    b->iPVReadyQLink.iTimeQueuedTicks = OsclTickCount::TickCount();
+    b->iPVReadyQLink.iSeqNum = ++iSeqNumCounter;//for the FIFO sort
+
+    push(b);
+}
+
+
+
+
+
+
+
+
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h b/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h
index c9ca5de..5a9835b 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_readyq.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -74,54 +74,94 @@
 class OsclReadyCompare
 {
     public:
-        int compare(TOsclReady& a, TOsclReady& b) const ;
+        static int compare(TOsclReady& a, TOsclReady& b) ;
+};
+class OsclTimerCompare
+{
+    public:
+        static int compare(TOsclReady& a, TOsclReady& b) ;
 };
 
-/**This is a thread-safe priority queue for holding the
+/** This is a thread-safe priority queue for holding the
     active objects that are ready to run.
+	This queue also contains the request semaphore and the
+	queue observer callback logic.
 */
 class PVLogger;
+class OsclSchedulerObserver;
 class OsclReadyQ
             : public OsclPriorityQueue<TOsclReady, OsclReadyAlloc, Oscl_Vector<TOsclReady, OsclReadyAlloc>, OsclReadyCompare>
 {
     public:
-        void Init(int, const char*);
-        void Clear();
-        void Add(TOsclReady, bool);
+        void Construct(int);
+        void ThreadLogon();
+        void ThreadLogoff();
+
         void Remove(TOsclReady);
+
+        bool IsIn(TOsclReady);
+
+        uint32 Depth()
+        {
+            return size();
+        }
+
         TOsclReady PopTop();
         TOsclReady Top();
-        void Pop(TOsclReady);
-        bool IsIn(TOsclReady);
-        bool IsInMT(TOsclReady);
-        static bool IsInAny(TOsclReady);
-        uint32 Depth();
-        void Open();
-        void Close();
-        void Lock();
-        void Unlock();
-        void Wait();
-        bool Wait(uint32);
-        void Signal(uint32 = 1);
-        void Print();
+
+        TOsclReady WaitAndPopTop();
+        TOsclReady WaitAndPopTop(uint32);
+
+        int32 PendComplete(PVActiveBase *pvbase, int32 aReason);
+        int32 WaitForRequestComplete(PVActiveBase*);
+
+        //For non-blocking scheduler observer support
+        void RegisterForCallback(OsclSchedulerObserver* aCallback, OsclAny* aCallbackContext);
+        void TimerCallback(uint32 aDelayMicrosec);
+        OsclSchedulerObserver* Callback()
+        {
+            return iCallback;
+        }
+
     private:
+        TOsclReady PopTopAfterWait();
+
         //mutex for thread protection
-        OsclMutex iCrit;
+        OsclNoYieldMutex iCrit;
 
         //this semaphore tracks the queue size.  it is used to
         //regulate the scheduling loop when running in blocking mode.
         OsclSemaphore iSem;
 
-        PVLogger* iLogger;
-        OSCL_HeapString<OsclMemAllocator> iName;
-
         //a sequence number needed to maintain FIFO sorting order in oscl pri queue.
         uint32 iSeqNumCounter;
 
+        //For non-blocking scheduler observer support
+        OsclSchedulerObserver* iCallback;
+        OsclAny* iCallbackContext;
 };
 
-/** This class defines the queue link.  Each AO contains its own
-     queue link object.
+/*
+** A non-thread-safe queue for holding pending timers.
+*/
+class OsclTimerQ
+            : public OsclPriorityQueue<TOsclReady, OsclReadyAlloc, Oscl_Vector<TOsclReady, OsclReadyAlloc>, OsclTimerCompare>
+{
+    public:
+        void Construct(int);
+        void Add(TOsclReady);
+        void Remove(TOsclReady);
+        TOsclReady PopTop();
+        TOsclReady Top();
+        void Pop(TOsclReady);
+        bool IsIn(TOsclReady);
+    private:
+        //a sequence number needed to maintain FIFO sorting order in oscl pri queue.
+        uint32 iSeqNumCounter;
+};
+
+/** This class defines the queue link, which is common to both ready Q and timer Q.
+    Each AO contains its own queue link object.
 */
 class TReadyQueLink
 {
@@ -130,19 +170,15 @@
         {
             iAOPriority = 0;
             iTimeToRunTicks = 0;
-            iTimerSort = false;
             iSeqNum = 0;
             iIsIn = NULL;
         }
 
         int32 iAOPriority;//scheduling priority
-        uint32 iTimeToRunTicks;//for active timers, this
-        //is the time to run in ticks.
+        uint32 iTimeToRunTicks;//for timers, this is the time to run in ticks.
         uint32 iTimeQueuedTicks;//the time when the AO was queued, in ticks.
-        bool iTimerSort;//sort by time, then priority.
         uint32 iSeqNum;//sequence number for oscl pri queue.
-        static int compare(TReadyQueLink& a, TReadyQueLink &b);//for oscl pri queue.
-        OsclReadyQ* iIsIn;//pointer to the queue we're in.
+        OsclAny* iIsIn;//pointer to the queue we're in, cast as a void*
 
 };
 
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp b/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp
index ccb3532..18adc93 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,11 +34,11 @@
 {
 }
 
-void PVThreadContext::PanicIfWrongThread(PVThreadContext &a)
+void PVThreadContext::LeaveIfWrongThread(PVThreadContext &a)
 //static routine to verify thread context.
 {
     if (!a.IsSameThreadContext())
-        PV_SCHEDULERPANIC(EPVPanicThreadContextIncorrect);
+        OsclError::Leave(OsclErrThreadContextIncorrect);
 }
 
 OSCL_EXPORT_REF bool PVThreadContext::IsSameThreadContext()
@@ -51,7 +51,7 @@
     TOsclThreadId id;
     int32 result = OsclThread::GetId(id);
     if (result != OsclProcStatus::SUCCESS_ERROR)
-        PV_SCHEDULERPANIC(EPVPanicThreadContextError);
+        OsclError::Leave(OsclErrSystemCallFailed);
 
     return OsclThread::CompareId(id, iThreadId);
 }
@@ -61,7 +61,7 @@
     //Save thread ID.
     int32 result = OsclThread::GetId(iThreadId);
     if (result != OsclProcStatus::SUCCESS_ERROR)
-        PV_SCHEDULERPANIC(EPVPanicThreadContextError);
+        OsclError::Leave(OsclErrSystemCallFailed);
 
 
     //Set current thread scheduler.
@@ -70,7 +70,7 @@
     if (!iScheduler)
     {
         //There must be a pv scheduler.
-        PV_SCHEDULERPANIC(EPVPanicSchedulerNotInstalled);
+        OsclError::Leave(OsclErrNotInstalled);
     }
 
     iOpen = true;
@@ -82,15 +82,14 @@
     iOpen = false;
 }
 
-
 void PVThreadContext::PendComplete(PVActiveBase *pvbase, int32 aReason, TPVThreadContext aCallingContext)
 {
     //request can be completed from any thread.
     if (!iOpen)
-        PV_SCHEDULERPANIC(EPVPanicThreadContextUnknown);
+        OsclError::Leave(OsclErrInvalidState);//thread context unknown
     //status can be anything but 'pending'
     if (aReason == OSCL_REQUEST_PENDING)
-        PV_SCHEDULERPANIC(EPVPanicBadRequestStatus);
+        OsclError::Leave(OsclErrInvalidState);//bad request status
 
 
     //use PV scheduler mechanism to complete requests.
@@ -109,7 +108,7 @@
     TOsclThreadId id;
     int32 result = OsclThread::GetId(id);
     if (result != OsclProcStatus::SUCCESS_ERROR)
-        PV_SCHEDULERPANIC(EPVPanicThreadContextError);
+        OsclError::Leave(OsclErrSystemCallFailed);
     return (uint32)id;
 }
 
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h b/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h
index 81bee4e..27b6900 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_threadcontext.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,7 @@
 */
 class OsclExecSchedulerCommonBase;
 class PVActiveBase;
+class OsclBrewThreadYield;
 class PVThreadContext
 {
     public:
@@ -92,10 +93,10 @@
     private:
 
         /**
-        //panic if caller's thread doesn't match
+        //leave if caller's thread doesn't match
         //given thread.
         */
-        static void PanicIfWrongThread(PVThreadContext &a);
+        static void LeaveIfWrongThread(PVThreadContext &a);
 
 
         bool iOpen;
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h b/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h
index 0986e41..1de3518 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_tuneables.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -109,10 +109,6 @@
 //swap in the symbian native behavior.
 #define PV_SCHED_FAIR_SCHEDULING 1
 
-//Set this to 1 to enable some debugging code in the symbian coe scheduler.
-//Should be 0 in production code.
-#define PV_SCHED_DEBUG_REPLACE 0
-
 //OSCL_PERF_SUMMARY_LOGGING is a master switch to configure scheduler
 //for full performance data gathering with minimal summary logging at
 //the end.  The data gathering is fairly expensive so should only be
diff --git a/oscl/oscl/osclproc/src/oscl_scheduler_types.h b/oscl/oscl/osclproc/src/oscl_scheduler_types.h
index 0e14e92..976f72a 100644
--- a/oscl/oscl/osclproc/src/oscl_scheduler_types.h
+++ b/oscl/oscl/osclproc/src/oscl_scheduler_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,10 +41,6 @@
 #include "osclconfig_proc.h"
 #endif
 
-#ifndef OSCL_EXECPANIC_H_INCLUDED
-#include "oscl_execpanic.h"
-#endif
-
 
 //Non-Symbian
 
@@ -56,26 +52,12 @@
 #include "oscl_heapbase.h"
 #endif
 
-/*
-** OsclExecBase is the base class for OsclActiveObject.
-** On non-symbian, PVActiveBase implements the AO, so
-** nothing is really needed here.
-*/
-typedef OsclHeapBase OsclActiveObj;
-
-/*
-** OsclTimerBase is the base class for OsclTimerObject.
-** On non-symbian, PVActiveBase implements the AO, so
-** nothing is really needed here.
-*/
-typedef OsclHeapBase OsclTimerBase;
-
 
 /** OsclActiveSchedulerBase is the base for OsclExecScheduler.
   The non-Symbian OsclActiveSchedulerBase class is functionally similar to
   a subset of Symbian CActiveScheduler class.
 */
-class OsclExecSchedulerBase : public OsclHeapBase
+class OsclExecSchedulerBase : public _OsclHeapBase
 {
     private:
         virtual void Error(int32 anError) const;
diff --git a/oscl/oscl/osclproc/src/oscl_semaphore.cpp b/oscl/oscl/osclproc/src/oscl_semaphore.cpp
index fa8c247..5849664 100644
--- a/oscl/oscl/osclproc/src/oscl_semaphore.cpp
+++ b/oscl/oscl/osclproc/src/oscl_semaphore.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,8 @@
 
 // Implementation file for OSCL Semaphores
 #include "oscl_semaphore.h"
+#include "oscl_assert.h"
+
 
 
 // Class contructor
@@ -40,6 +42,8 @@
 
 OSCL_EXPORT_REF OsclSemaphore::~OsclSemaphore()
 {
+    //make sure it was closed
+    OSCL_ASSERT(!bCreated);
 }
 
 
@@ -107,17 +111,17 @@
     if (res != 0)
         return OsclProcStatus::OTHER_ERROR;
     while (iCount == 0 && res == 0)
-    {	// wait till the semaphore is signaled
+    {   // wait till the semaphore is signaled
         // or an error has occurred
         res = pthread_cond_wait(&ObjCondition, &ObjMutex);
     }
     if (res == 0)
-    {	// signaled
+    {   // signaled
         iCount--;
     }
     pthread_mutex_unlock(&ObjMutex);
     if (res != 0)
-    {	// error occurred
+    {   // error occurred
         // invalid condition or mutex
         return OsclProcStatus::OTHER_ERROR;
     }
@@ -179,21 +183,21 @@
     getAbsTime(abs, timeout_msec);
 
     while ((iCount == 0) && (res == 0))
-    {	// wait till semaphore is signaled
+    {   // wait till semaphore is signaled
         // or time runs out
         res = pthread_cond_timedwait(&ObjCondition, &ObjMutex, &abs);
     }
     if (res == 0)
-    {	// signalied
+    {   // signalied
         iCount--;
     }
     pthread_mutex_unlock(&ObjMutex);
     if (res == ETIMEDOUT)
-    {	// timeour occurred
+    {   // timeour occurred
         return OsclProcStatus::WAIT_TIMEOUT_ERROR;
     }
     else if (res != 0)
-    {	// error occurred
+    {   // error occurred
         return OsclProcStatus::OTHER_ERROR;
     }
     return OsclProcStatus::SUCCESS_ERROR;
diff --git a/oscl/oscl/osclproc/src/oscl_semaphore.h b/oscl/oscl/osclproc/src/oscl_semaphore.h
index 07858a0..d54f1a3 100644
--- a/oscl/oscl/osclproc/src/oscl_semaphore.h
+++ b/oscl/oscl/osclproc/src/oscl_semaphore.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,8 +36,6 @@
 #include "osclconfig_proc.h"
 #endif
 
-
-
 #ifndef OSCL_THREAD_H_INCLUDED
 #include "oscl_thread.h"
 #endif
diff --git a/oscl/oscl/osclproc/src/oscl_thread.cpp b/oscl/oscl/osclproc/src/oscl_thread.cpp
index 798ee4d..f1f1bf2 100644
--- a/oscl/oscl/osclproc/src/oscl_thread.cpp
+++ b/oscl/oscl/osclproc/src/oscl_thread.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,10 +92,20 @@
     }
     pthread_attr_t attr;
     pthread_attr_init(&attr);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
     if (stack_size != 0)
         pthread_attr_setstacksize(&attr, stack_size);
 
+    // Default detachstate attribute to PTHREAD_CREATE_DETACHED state
+    int detach_ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    switch (detach_ret)
+    {
+        case 0:	// successful, continue thread creation
+            break;
+        case EINVAL:
+        default:
+            return OsclProcStatus::PSHARED_ATTRIBUTE_SETTING_ERROR;
+    }
+
     int result = pthread_create(
                      (pthread_t*) & ObjThread,
                      &attr,
diff --git a/oscl/oscl/osclproc/src/oscl_thread.h b/oscl/oscl/osclproc/src/oscl_thread.h
index 2b173c4..3b181ce 100644
--- a/oscl/oscl/osclproc/src/oscl_thread.h
+++ b/oscl/oscl/osclproc/src/oscl_thread.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_timer.cpp b/oscl/oscl/osclproc/src/oscl_timer.cpp
index 6316e05..03c2a86 100644
--- a/oscl/oscl/osclproc/src/oscl_timer.cpp
+++ b/oscl/oscl/osclproc/src/oscl_timer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_timer.h b/oscl/oscl/osclproc/src/oscl_timer.h
index d2226e3..6203216 100644
--- a/oscl/oscl/osclproc/src/oscl_timer.h
+++ b/oscl/oscl/osclproc/src/oscl_timer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclproc/src/oscl_timerbase.cpp b/oscl/oscl/osclproc/src/oscl_timerbase.cpp
index 8e351de..12a8ce2 100644
--- a/oscl/oscl/osclproc/src/oscl_timerbase.cpp
+++ b/oscl/oscl/osclproc/src/oscl_timerbase.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregcli/Android.mk b/oscl/oscl/osclregcli/Android.mk
index 1d29eea..9e0f7c5 100644
--- a/oscl/oscl/osclregcli/Android.mk
+++ b/oscl/oscl/osclregcli/Android.mk
@@ -3,27 +3,30 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_registry_access_client.cpp \
-	src/oscl_registry_client.cpp \
-	src/oscl_registry_client_impl.cpp
-
+ 	src/oscl_registry_client.cpp \
+ 	src/oscl_registry_client_impl.cpp
 
 
 LOCAL_MODULE := libosclregcli
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclregcli/src \
-	$(PV_TOP)//oscl/oscl/osclregcli/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclregcli/src \
+ 	$(PV_TOP)/oscl/oscl/osclregcli/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_registry_access_client.h \
-	src/oscl_registry_client.h \
-	src/oscl_registry_types.h
+ 	src/oscl_registry_client.h \
+ 	src/oscl_registry_types.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclregcli/build/make/local.mk b/oscl/oscl/osclregcli/build/make/local.mk
new file mode 100644
index 0000000..bcc0e3e
--- /dev/null
+++ b/oscl/oscl/osclregcli/build/make/local.mk
@@ -0,0 +1,23 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := osclregcli
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := oscl_registry_access_client.cpp \
+	oscl_registry_client.cpp \
+	oscl_registry_client_impl.cpp
+
+
+HDRS := oscl_registry_access_client.h \
+	oscl_registry_client.h \
+	oscl_registry_types.h
+
+include $(MK)/library.mk
diff --git a/oscl/oscl/osclregcli/build/make/makefile b/oscl/oscl/osclregcli/build/make/makefile
deleted file mode 100644
index b588b1d..0000000
--- a/oscl/oscl/osclregcli/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclregcli
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-#XINCDIRS += -I../../../osclbase/src -I../../../osclutil/src -I../../../osclmemory/src
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  oscl_registry_access_client.cpp \
-	oscl_registry_client.cpp \
-	oscl_registry_client_impl.cpp
-
-
-HDRS =  oscl_registry_access_client.h \
-	oscl_registry_client.h \
-	oscl_registry_types.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp b/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp
index 4e358a9..9b886be 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp
+++ b/oscl/oscl/osclregcli/src/oscl_registry_access_client.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_access_client.h b/oscl/oscl/osclregcli/src/oscl_registry_access_client.h
index f2de2d3..d50d6d9 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_access_client.h
+++ b/oscl/oscl/osclregcli/src/oscl_registry_access_client.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_client.cpp b/oscl/oscl/osclregcli/src/oscl_registry_client.cpp
index c96303d..9a8432b 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_client.cpp
+++ b/oscl/oscl/osclregcli/src/oscl_registry_client.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_client.h b/oscl/oscl/osclregcli/src/oscl_registry_client.h
index 4f64820..7910e9f 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_client.h
+++ b/oscl/oscl/osclregcli/src/oscl_registry_client.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp b/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp
index 9a3d76b..40a2a2f 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp
+++ b/oscl/oscl/osclregcli/src/oscl_registry_client_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,15 +16,23 @@
  * -------------------------------------------------------------------
  */
 
-
+#include "oscl_base.h"
 #include "oscl_registry_client_impl.h"
 
 #include "oscl_error_codes.h"
 
 #include "osclconfig_proc.h"
+#if (OSCL_HAS_SINGLETON_SUPPORT)
+//1st choice implementation-- uses Oscl Singleton
 
 //nothing needed.  client goes directly to server impl.
 
+#else //OSCL_HAS_ ...
+//3rd choice implementation
+
+//non-functional stubs are implemented in the header-- nothing needed here.
+
+#endif //oscl config
 
 
 
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h b/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h
index fd59632..f4bd7c3 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h
+++ b/oscl/oscl/osclregcli/src/oscl_registry_client_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,10 @@
 #ifndef OSCL_REGISTRY_CLIENT_IMPL_H_INCLUDED
 #define OSCL_REGISTRY_CLIENT_IMPL_H_INCLUDED
 
+#include "oscl_base.h"
 #include "osclconfig_proc.h"
+#if (OSCL_HAS_SINGLETON_SUPPORT)
+//1st choice implementation-- uses Oscl singleton
 
 #include "oscl_registry_serv_impl_global.h"
 
@@ -50,6 +53,48 @@
 {
 };
 
+#else //OSCL_HAS_ ...
+//3rd choice implementation -- Non-functional stubs.
+
+#include "oscl_vector.h"
+#include "oscl_string.h"
+#include "oscl_registry_types.h"
+
+class OsclRegistryClientImpl
+{
+    protected:
+
+        int32 Connect()
+        {
+            return OsclErrNotSupported;
+        }
+        void Close() {}
+
+        int32 Register(OSCL_String& , OsclComponentFactory)
+        {
+            return OsclErrNotSupported;
+        }
+        int32 UnRegister(OSCL_String&)
+        {
+            return OsclErrNotSupported;
+        }
+
+        //for access client.
+        OsclComponentFactory GetFactory(OSCL_String&)
+        {
+            return NULL;
+        }
+        void GetFactories(OSCL_String& , Oscl_Vector<OsclRegistryAccessElement, OsclMemAllocator>&) {}
+
+        friend class OsclRegistryClient;
+        friend class OsclRegistryAccessClient;
+};
+
+class OsclRegistryAccessClientImpl: public OsclRegistryClientImpl
+{
+};
+
+#endif //OSCL_HAS_ ...
 
 
 //TLS-based registry
diff --git a/oscl/oscl/osclregcli/src/oscl_registry_types.h b/oscl/oscl/osclregcli/src/oscl_registry_types.h
index f966118..89820a9 100644
--- a/oscl/oscl/osclregcli/src/oscl_registry_types.h
+++ b/oscl/oscl/osclregcli/src/oscl_registry_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregserv/Android.mk b/oscl/oscl/osclregserv/Android.mk
index fc817a8..315e907 100644
--- a/oscl/oscl/osclregserv/Android.mk
+++ b/oscl/oscl/osclregserv/Android.mk
@@ -3,27 +3,30 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_registry_serv_impl.cpp \
-	src/oscl_registry_serv_impl_global.cpp \
-	src/oscl_registry_serv_impl_tls.cpp
-
+ 	src/oscl_registry_serv_impl_global.cpp \
+ 	src/oscl_registry_serv_impl_tls.cpp
 
 
 LOCAL_MODULE := libosclregserv
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclregserv/src \
-	$(PV_TOP)//oscl/oscl/osclregserv/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclregserv/src \
+ 	$(PV_TOP)/oscl/oscl/osclregserv/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_registry_serv_impl.h \
-	src/oscl_registry_serv_impl_global.h \
-	src/oscl_registry_serv_impl_tls.h
+ 	src/oscl_registry_serv_impl_global.h \
+ 	src/oscl_registry_serv_impl_tls.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclregserv/build/make/local.mk b/oscl/oscl/osclregserv/build/make/local.mk
new file mode 100644
index 0000000..b327e48
--- /dev/null
+++ b/oscl/oscl/osclregserv/build/make/local.mk
@@ -0,0 +1,23 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := osclregserv
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := oscl_registry_serv_impl.cpp \
+	oscl_registry_serv_impl_global.cpp \
+	oscl_registry_serv_impl_tls.cpp
+
+
+HDRS := oscl_registry_serv_impl.h \
+	oscl_registry_serv_impl_global.h \
+	oscl_registry_serv_impl_tls.h
+
+include $(MK)/library.mk
diff --git a/oscl/oscl/osclregserv/build/make/makefile b/oscl/oscl/osclregserv/build/make/makefile
deleted file mode 100644
index df619e7..0000000
--- a/oscl/oscl/osclregserv/build/make/makefile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclregserv
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-#XINCDIRS += -I../../../osclbase/src -I../../../osclutil/src -I../../../osclmemory/src
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  oscl_registry_serv_impl.cpp \
-	oscl_registry_serv_impl_global.cpp \
-	oscl_registry_serv_impl_tls.cpp
-
-
-HDRS =  oscl_registry_serv_impl.h \
-	oscl_registry_serv_impl_global.h \
-	oscl_registry_serv_impl_tls.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp
index edfaefb..0cdedb9 100644
--- a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp
+++ b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
     if (iId)
     {
         OSCL_HeapString<OsclMemAllocator>* id = (OSCL_HeapString<OsclMemAllocator>*)iId;
-        OSCL_TEMPLATED_DELETE(id, OSCL_HeapString<OsclMemAllocator>, OSCL_HeapString);
+        OSCL_DELETE(id);
     }
 }
 
@@ -55,7 +55,7 @@
     if (iId)
     {
         OSCL_HeapString<OsclMemAllocator>* id = (OSCL_HeapString<OsclMemAllocator>*)iId;
-        OSCL_TEMPLATED_DELETE(id, OSCL_HeapString<OsclMemAllocator>, OSCL_HeapString);
+        OSCL_DELETE(id);
         iId = NULL;
     }
     iId = OSCL_NEW(OSCL_HeapString<OsclMemAllocator>, (*src.iId));
diff --git a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h
index 30312a1..17f1aed 100644
--- a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h
+++ b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
 #ifndef OSCL_REGISTRY_SERV_IMPL_H_INCLUDED
 #define OSCL_REGISTRY_SERV_IMPL_H_INCLUDED
 
+#include "oscl_base.h"
 #include "osclconfig_proc.h"
 
 #include "oscl_registry_types.h"
diff --git a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp
index 85f6293..ce2a128 100644
--- a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp
+++ b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,54 +19,47 @@
 #include "oscl_registry_serv_impl_global.h"
 
 #include "osclconfig_proc.h"
+#include "oscl_base.h"
+#if (OSCL_HAS_SINGLETON_SUPPORT)
 
 //Global variable implementation.
-OsclComponentRegistry* gOsclComponentRegistry;
 
-static int calls = 0;
+#include "oscl_singleton.h"
+#include "oscl_registry_serv_impl.h"
+
+OsclComponentRegistry* OsclRegistryServImpl::GetOsclComponentRegistry()
+{
+    return (OsclComponentRegistry*)OsclSingletonRegistryEx::getInstance(OSCL_SINGLETON_ID_OSCLREGISTRY);
+}
 
 OsclRegistryServImpl::OsclRegistryServImpl()
 {
-    if (calls == 0)
-    {
-        gOsclComponentRegistry = new OsclComponentRegistry();
-    }
-
-    calls++;
-
-    iOsclComponentRegistry = gOsclComponentRegistry;
-
     iIsOpen = false;
 }
 
 OsclRegistryServImpl::~OsclRegistryServImpl()
 {
     if (iIsOpen)
-    {
         Close();
-    }
-
-    calls--;
-
-    if (calls == 0)
-    {
-        if (iOsclComponentRegistry)
-        {
-            delete iOsclComponentRegistry;
-            iOsclComponentRegistry = 0;
-            gOsclComponentRegistry = 0;
-        }
-    }
 }
 
 int32 OsclRegistryServImpl::Connect()
 {
     if (iIsOpen)
-    {
         return OsclErrInvalidState;
+    //Create the registry on the first session.
+    if (!GetOsclComponentRegistry())
+    {
+        OsclComponentRegistry* reg = NULL;
+        int32 err;
+        OSCL_TRY(err, reg = OSCL_NEW(OsclComponentRegistry, ()));
+        if (err != OsclErrNone)
+            return err;
+
+        OsclSingletonRegistryEx::registerInstance(reg, OSCL_SINGLETON_ID_OSCLREGISTRY);
     }
     iIsOpen = true;
-    iOsclComponentRegistry->OpenSession();
+    GetOsclComponentRegistry()->OpenSession();
     return OsclErrNone;
 }
 
@@ -77,15 +70,21 @@
     {
         //unregister all comps that were registered by this session
         for (uint32 i = 0;i < iIdVec.size();i++)
-            iOsclComponentRegistry->Unregister(iIdVec[i]);
+            GetOsclComponentRegistry()->Unregister(iIdVec[i]);
         //clear our comp list.
         iIdVec.destroy();
     }
 
     if (iIsOpen)
     {
-        iOsclComponentRegistry->CloseSession();
+        GetOsclComponentRegistry()->CloseSession();
         iIsOpen = false;
+        //Delete the registry when the session count goes to zero.
+        if (GetOsclComponentRegistry()->iNumSessions == 0)
+        {
+            OSCL_DELETE(GetOsclComponentRegistry());
+            OsclSingletonRegistryEx::registerInstance(NULL, OSCL_SINGLETON_ID_OSCLREGISTRY);
+        }
     }
 }
 
@@ -100,7 +99,7 @@
         return err;
 
     uint32 id;
-    int32 result = iOsclComponentRegistry->Register(id, aComp, aFac);
+    int32 result = GetOsclComponentRegistry()->Register(id, aComp, aFac);
 
     //save all comp IDs in our session data
     if (result == OsclErrNone)
@@ -114,7 +113,7 @@
     if (!IsOpen())
         return OsclErrInvalidState;
 
-    return iOsclComponentRegistry->Unregister(aComp);
+    return GetOsclComponentRegistry()->Unregister(aComp);
 }
 
 OsclComponentFactory OsclRegistryServImpl::GetFactory(OSCL_String& aComp)
@@ -124,7 +123,7 @@
         return NULL;
     }
 
-    return iOsclComponentRegistry->FindExact(aComp);
+    return GetOsclComponentRegistry()->FindExact(aComp);
 }
 
 void OsclRegistryServImpl::GetFactories(OSCL_String& aReg, Oscl_Vector<OsclRegistryAccessElement, OsclMemAllocator>& aVec)
@@ -132,9 +131,10 @@
     if (!IsOpen())
         return;
 
-    iOsclComponentRegistry->FindHierarchical(aReg, aVec);
+    GetOsclComponentRegistry()->FindHierarchical(aReg, aVec);
 }
 
+#endif //oscl config
 
 
 
diff --git a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h
index 9eb0dc7..f03d466 100644
--- a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h
+++ b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_global.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,6 +37,8 @@
 #define OSCL_REGISTRY_SERV_IMPL_GLOBAL_H_INCLUDED
 
 #include "osclconfig_proc.h"
+#include "oscl_base.h"
+#if (OSCL_HAS_SINGLETON_SUPPORT)
 
 #include "oscl_registry_serv_impl.h"
 #include "oscl_registry_types.h"
@@ -72,12 +74,13 @@
         }
         bool iIsOpen;
         //server data.
-        OsclComponentRegistry* iOsclComponentRegistry;
+        OsclComponentRegistry* GetOsclComponentRegistry();
         //session data.
         Oscl_Vector<uint32, OsclMemAllocator> iIdVec;
 
 };
 
+#endif //oscl config
 
 #endif //OSCL_REGISTRY_IMPL_GLOBAL_H_INCLUDED
 /*! @} */
diff --git a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp
index 4b9b7bf..ceb72a6 100644
--- a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp
+++ b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h
index 1627c2c..365bced 100644
--- a/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h
+++ b/oscl/oscl/osclregserv/src/oscl_registry_serv_impl_tls.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/Android.mk b/oscl/oscl/osclutil/Android.mk
index 7f81e4d..e07aa1d 100644
--- a/oscl/oscl/osclutil/Android.mk
+++ b/oscl/oscl/osclutil/Android.mk
@@ -3,56 +3,57 @@
 
 LOCAL_SRC_FILES := \
 	src/oscl_bin_stream.cpp \
-	src/oscl_string.cpp \
-	src/oscl_string_containers.cpp \
-	src/oscl_str_ptr_len.cpp \
-	src/oscl_string_utf8.cpp \
-	src/oscl_tickcount.cpp \
-	src/oscl_utf8conv.cpp \
-	src/oscl_snprintf.cpp \
-	src/oscl_clock.cpp \
-	src/oscl_math.cpp \
-	src/oscl_rand.cpp \
-	src/oscl_string_uri.cpp \
-	src/oscl_string_xml.cpp \
-	src/oscl_priqueue.cpp
-
+ 	src/oscl_string.cpp \
+ 	src/oscl_string_containers.cpp \
+ 	src/oscl_str_ptr_len.cpp \
+ 	src/oscl_string_utf8.cpp \
+ 	src/oscl_tickcount.cpp \
+ 	src/oscl_utf8conv.cpp \
+ 	src/oscl_snprintf.cpp \
+ 	src/oscl_math.cpp \
+ 	src/oscl_rand.cpp \
+ 	src/oscl_string_uri.cpp \
+ 	src/oscl_string_xml.cpp \
+ 	src/oscl_priqueue.cpp
 
 
 LOCAL_MODULE := libosclutil
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/oscl/osclutil/src \
-	$(PV_TOP)//oscl/oscl/osclutil/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/oscl/osclutil/src \
+ 	$(PV_TOP)/oscl/oscl/osclutil/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/oscl_bin_stream.h \
-	src/oscl_bin_stream.inl \
-	src/oscl_media_data.h \
-	src/oscl_media_status.h \
-	src/oscl_priqueue.h \
-	src/oscl_rand.h \
-	src/oscl_rand.inl \
-	src/oscl_snprintf.h \
-	src/oscl_string.h \
-	src/oscl_string_containers.h \
-	src/oscl_string_rep.h \
-	src/oscl_string_utf8.h \
-	src/oscl_str_ptr_len.h \
-	src/oscl_tickcount.h \
-	src/oscl_tickcount.inl \
-	src/oscl_utf8conv.h \
-	src/oscl_clock.h \
-	src/oscl_math.h \
-	src/oscl_math.inl \
-	src/oscl_string_uri.h \
-	src/oscl_string_xml.h
+ 	src/oscl_bin_stream.inl \
+ 	src/oscl_media_data.h \
+ 	src/oscl_media_status.h \
+ 	src/oscl_priqueue.h \
+ 	src/oscl_rand.h \
+ 	src/oscl_rand.inl \
+ 	src/oscl_snprintf.h \
+ 	src/oscl_string.h \
+ 	src/oscl_string_containers.h \
+ 	src/oscl_string_rep.h \
+ 	src/oscl_string_utf8.h \
+ 	src/oscl_str_ptr_len.h \
+ 	src/oscl_tickcount.h \
+ 	src/oscl_tickcount.inl \
+ 	src/oscl_utf8conv.h \
+ 	src/oscl_math.h \
+ 	src/oscl_math.inl \
+ 	src/oscl_string_uri.h \
+ 	src/oscl_string_xml.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/oscl/osclutil/build/make/local.mk b/oscl/oscl/osclutil/build/make/local.mk
new file mode 100644
index 0000000..ae2a4a4
--- /dev/null
+++ b/oscl/oscl/osclutil/build/make/local.mk
@@ -0,0 +1,54 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+TARGET := osclutil
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+
+SRCS :=  oscl_bin_stream.cpp \
+	oscl_string.cpp \
+	oscl_string_containers.cpp \
+	oscl_str_ptr_len.cpp \
+	oscl_string_utf8.cpp \
+	oscl_tickcount.cpp \
+	oscl_utf8conv.cpp \
+	oscl_snprintf.cpp \
+	oscl_math.cpp \
+	oscl_rand.cpp \
+	oscl_string_uri.cpp \
+	oscl_string_xml.cpp \
+	oscl_priqueue.cpp
+
+
+HDRS :=  oscl_bin_stream.h \
+	oscl_bin_stream.inl \
+	oscl_media_data.h \
+	oscl_media_status.h \
+	oscl_priqueue.h \
+	oscl_rand.h \
+	oscl_rand.inl \
+	oscl_snprintf.h \
+	oscl_string.h \
+	oscl_string_containers.h \
+	oscl_string_rep.h \
+	oscl_string_utf8.h \
+	oscl_str_ptr_len.h \
+	oscl_tickcount.h \
+	oscl_tickcount.inl \
+	oscl_utf8conv.h \
+	oscl_math.h \
+	oscl_math.inl \
+	oscl_string_uri.h \
+	oscl_string_xml.h
+
+include $(MK)/library.mk
+
+
diff --git a/oscl/oscl/osclutil/build/make/makefile b/oscl/oscl/osclutil/build/make/makefile
deleted file mode 100644
index 853caf6..0000000
--- a/oscl/oscl/osclutil/build/make/makefile
+++ /dev/null
@@ -1,92 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = osclutil
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.  # See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-#XINCDIRS += -I../../../osclmemory/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-
-SRCS =  oscl_bin_stream.cpp \
-	oscl_string.cpp \
-	oscl_string_containers.cpp \
-	oscl_str_ptr_len.cpp \
-	oscl_string_utf8.cpp \
-	oscl_tickcount.cpp \
-	oscl_utf8conv.cpp \
-	oscl_snprintf.cpp \
-	oscl_clock.cpp \
-	oscl_math.cpp \
-	oscl_rand.cpp \
-	oscl_string_uri.cpp \
-	oscl_string_xml.cpp \
-	oscl_priqueue.cpp
-
-
-HDRS =  oscl_bin_stream.h \
-	oscl_bin_stream.inl \
-	oscl_media_data.h \
-	oscl_media_status.h \
-	oscl_priqueue.h \
-	oscl_rand.h \
-	oscl_rand.inl \
-	oscl_snprintf.h \
-	oscl_string.h \
-	oscl_string_containers.h \
-	oscl_string_rep.h \
-	oscl_string_utf8.h \
-	oscl_str_ptr_len.h \
-	oscl_tickcount.h \
-	oscl_tickcount.inl \
-	oscl_utf8conv.h \
-	oscl_clock.h \
-	oscl_math.h \
-	oscl_math.inl \
-	oscl_string_uri.h \
-	oscl_string_xml.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
-
diff --git a/oscl/oscl/osclutil/src/oscl_bin_stream.cpp b/oscl/oscl/osclutil/src/oscl_bin_stream.cpp
index 03a0136..87e5d82 100644
--- a/oscl/oscl/osclutil/src/oscl_bin_stream.cpp
+++ b/oscl/oscl/osclutil/src/oscl_bin_stream.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_bin_stream.h b/oscl/oscl/osclutil/src/oscl_bin_stream.h
index 8b29574..4c5b4c0 100644
--- a/oscl/oscl/osclutil/src/oscl_bin_stream.h
+++ b/oscl/oscl/osclutil/src/oscl_bin_stream.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_bin_stream.inl b/oscl/oscl/osclutil/src/oscl_bin_stream.inl
index 96a3421..bcd29bb 100644
--- a/oscl/oscl/osclutil/src/oscl_bin_stream.inl
+++ b/oscl/oscl/osclutil/src/oscl_bin_stream.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_clock.cpp b/oscl/oscl/osclutil/src/oscl_clock.cpp
index 77d49e2..32554f0 100644
--- a/oscl/oscl/osclutil/src/oscl_clock.cpp
+++ b/oscl/oscl/osclutil/src/oscl_clock.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,517 +15,3 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-//               O S C L _ C L O C K   C L A S S
-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-#include "oscl_clock.h"
-
-OSCL_EXPORT_REF OsclClock::OsclClock() :
-        iState(STOPPED),
-        iClockTimebase(NULL)
-{
-    iLatestRunningClockTime = 0;
-    iLatestRunningTimebaseTime = 0;
-    iStartClockTime = 0;
-    iPauseClockTime = 0;
-    iLastAdjustTimebaseTime = 0;
-    iAdjustmentTimebaseTime = 0;
-}
-
-
-OSCL_EXPORT_REF OsclClock::~OsclClock()
-{
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::SetClockTimebase(OsclTimebase& aTimebase)
-{
-    // Clock timebase can only be set during stopped or paused states
-    if (iState == RUNNING)
-    {
-        return false;
-    }
-
-    // Save the clock timebase object pointer
-    iClockTimebase = &aTimebase;
-
-    //If this is a counting timebase, then set the timebase
-    //observer to this clock, so that we'll get the count update
-    //notices.
-    if (aTimebase.GetCountTimebase())
-        aTimebase.GetCountTimebase()->SetClockObserver(this);
-
-    //Notify observers that the timebase is updated.
-    ClockTimebaseUpdated();
-
-    return true;
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::Start()
-{
-    // Can only start from stopped or paused states
-    if (iState == RUNNING)
-    {
-        return false;
-    }
-
-    // Retrieve the current time value from the clock timebase
-    uint64 tbval = 0;
-    if (iClockTimebase != NULL)
-    {
-        iClockTimebase->GetCurrentTime64(tbval, OSCLCLOCK_USEC);
-    }
-
-    // Save the clock timebase value to the appropriate
-    // variable and update the iLatest... values.
-    if (iState == STOPPED)
-    {
-        // Starting from stop
-        UpdateLatestTimes(iStartClockTime, tbval);
-    }
-    else
-    {
-        // Resuming from pause
-        UpdateLatestTimes(iPauseClockTime, tbval);
-    }
-
-    // Change to running state
-    SetClockState(RUNNING);
-    return true;
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::Pause()
-{
-    // Can only pause during running state
-    if (iState != RUNNING)
-    {
-        return false;
-    }
-
-    // Save the current time
-    uint64 tbval = 0;
-    GetCurrentTime64(iPauseClockTime, OSCLCLOCK_USEC, tbval);
-    UpdateLatestTimes(iPauseClockTime, tbval);
-
-    // Change to paused state
-    SetClockState(PAUSED);
-    return true;
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::Stop()
-{
-    // Can only stop when running or paused
-    if (iState == STOPPED)
-    {
-        return false;
-    }
-
-    // Reset the time values
-    uint64 tmp = 0;
-    UpdateLatestTimes(tmp, tmp);
-    iStartClockTime = tmp;
-    iPauseClockTime = tmp;
-    iLastAdjustTimebaseTime = tmp;
-    iAdjustmentTimebaseTime = tmp;
-
-    // Change to stopped state
-    SetClockState(STOPPED);
-    return true;
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::SetStartTime32(uint32& aTime, OsclClock_TimeUnits aUnits)
-{
-    // Use the 64bit version to set the start time
-    uint64 time64 = 0;
-    Oscl_Int64_Utils::set_uint64(time64, 0, aTime);
-    return SetStartTime64(time64, aUnits);
-}
-
-
-OSCL_EXPORT_REF void OsclClock::GetStartTime32(uint32& aTime, bool& aOverflow, OsclClock_TimeUnits aUnits)
-{
-    // Use the 64-bit version to get the start time
-    // Check for value overflow as well
-    uint64 time64 = 0;
-    GetStartTime64(time64, aUnits);
-    aTime = Oscl_Int64_Utils::get_uint64_lower32(time64);
-    aOverflow = (Oscl_Int64_Utils::get_uint64_upper32(time64) > 0 ? true : false);
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::SetStartTime64(uint64& aTime, OsclClock_TimeUnits aUnits)
-{
-    // Can only set start time while stopped
-    if (iState != STOPPED)
-    {
-        return false;
-    }
-
-    // Convert to usec and set the start time
-    ToUSec(aTime, aUnits, iStartClockTime);
-
-    return true;
-}
-
-
-OSCL_EXPORT_REF void OsclClock::GetStartTime64(uint64& aTime, OsclClock_TimeUnits aUnits)
-{
-    // Convert to the requested time units and return the start time
-    FromUSec(iStartClockTime, aTime, aUnits);
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::AdjustClockTime32(uint32& aClockTime, uint64& aTimebaseTime, uint32& aAdjustedTime, OsclClock_TimeUnits aUnits)
-{
-    // Use the 64bit version to adjust the clock
-    uint64 clocktime64 = 0;
-    Oscl_Int64_Utils::set_uint64(clocktime64, 0, aClockTime);
-    uint64 adjusttime64 = 0;
-    Oscl_Int64_Utils::set_uint64(adjusttime64, 0, aAdjustedTime);
-    return AdjustClockTime64(clocktime64, aTimebaseTime, adjusttime64, aUnits);
-}
-
-
-OSCL_EXPORT_REF bool OsclClock::AdjustClockTime64(uint64& aClockTime, uint64& aTimebaseTime, uint64& aAdjustedTime, OsclClock_TimeUnits aUnits)
-{
-    // Clock can only be adjusted when it is running
-    if (iState != RUNNING)
-    {
-        return false;
-    }
-
-    // Check if the adjustment's observed time is later than the last one
-    if (aTimebaseTime < iLastAdjustTimebaseTime)
-    {
-        // Old data so don't use it for adjustment
-        return false;
-    }
-
-    // Convert the observed clock and adjustment time to usec so it can be compared
-    uint64 adjusttime, clocktime;
-    ToUSec(aClockTime, aUnits, clocktime);
-    ToUSec(aAdjustedTime, aUnits, adjusttime);
-
-    // Make sure the adjustment's clock and timebase times are before current time
-    uint64 currenttime = 0;
-    uint64 tbval = 0;
-
-    // Get the current timebase time
-    if (iClockTimebase)
-    {
-        iClockTimebase->GetCurrentTime64(tbval, OSCLCLOCK_USEC);
-    }
-    // Get the current clock time
-    GetCurrentTime64(currenttime, OSCLCLOCK_USEC);
-
-    if (aTimebaseTime > tbval)
-    {
-        // Observed timebase time cannot be later than the current timebase time
-        return false;
-    }
-
-    if (clocktime > currenttime)
-    {
-        // Observed clock time cannot be later than the current clock time
-        return false;
-    }
-
-    // Make the adjustment
-    return AdjustClock(clocktime, aTimebaseTime, adjusttime, currenttime, tbval);
-}
-
-
-OSCL_EXPORT_REF void OsclClock::GetTimebaseResolution(uint32& aResolution)
-{
-    if (iClockTimebase)
-    {
-        // Retrieve the resolution from the timebase being used
-        iClockTimebase->GetTimebaseResolution(aResolution);
-    }
-    else
-    {
-        // No timebase so set to 0
-        aResolution = 0;
-    }
-}
-
-
-OSCL_EXPORT_REF void OsclClock::GetCurrentTime64(uint64& aClockTime, OsclClock_TimeUnits aUnits)
-{
-    // Use the base class version
-    OsclTimebase::GetCurrentTime64(aClockTime, aUnits);
-}
-
-
-OSCL_EXPORT_REF void OsclClock::GetCurrentTime64(uint64& aClockTime, OsclClock_TimeUnits aUnits, uint64& aTimebaseTime)
-{
-    // Get and return the current timebase value
-    uint64 tbval = 0;
-    if (iClockTimebase)
-    {
-        iClockTimebase->GetCurrentTime64(tbval, OSCLCLOCK_USEC);
-    }
-    aTimebaseTime = tbval;
-
-    // Determine and return the current clock time
-    if (iState == STOPPED)
-    {
-        // Return the specified start time
-        FromUSec(iStartClockTime, aClockTime, aUnits);
-    }
-    else if (iState == PAUSED)
-    {
-        // Returned the paused time
-        FromUSec(iPauseClockTime, aClockTime, aUnits);
-    }
-    else
-    {
-        // Running state
-        uint64 currenttime;
-
-        // Determine current clock time including any adjustment
-        GetAdjustedRunningClockTime(currenttime, tbval);
-
-        // Convert to requested time units
-        FromUSec(currenttime, aClockTime, aUnits);
-    }
-}
-
-OSCL_EXPORT_REF void OsclClock::SetClockObserver(OsclClockObserver& aObserver)
-{
-    iClockObservers.push_back(&aObserver);
-}
-
-OSCL_EXPORT_REF void OsclClock::RemoveClockObserver(OsclClockObserver& aObserver)
-{
-    for (uint32 i = 0;i < iClockObservers.size();i++)
-    {
-        if (iClockObservers[i] == &aObserver)
-            iClockObservers.erase(&iClockObservers[i]);
-    }
-}
-
-OSCL_EXPORT_REF void OsclClock::SetClockStateObserver(OsclClockStateObserver& aObserver)
-{
-    iClockStateObservers.push_back(&aObserver);
-}
-
-OSCL_EXPORT_REF void OsclClock::RemoveClockStateObserver(OsclClockStateObserver& aObserver)
-{
-    for (uint32 i = 0;i < iClockStateObservers.size();i++)
-    {
-        if (iClockStateObservers[i] == &aObserver)
-            iClockStateObservers.erase(&iClockStateObservers[i]);
-    }
-}
-
-void OsclClock::SetClockState(OsclClockState aState)
-{
-    // Change the clock state
-    iState = aState;
-    // Notify observers
-    for (uint32 i = 0;i < iClockStateObservers.size();i++)
-        iClockStateObservers[i]->ClockStateUpdated();
-}
-
-void OsclClock::UpdateLatestTimes(uint64& aTime, uint64& aTimebaseVal)
-{
-    // Set the latest time values
-    iLatestRunningClockTime = aTime;
-    iLatestRunningTimebaseTime = aTimebaseVal;
-}
-
-#define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA
-#include "osclconfig_compiler_warnings.h"
-
-void OsclClock::ToUSec(uint64& aSrcVal, OsclClock_TimeUnits aSrcUnits, uint64& aUSecVal)
-{
-    uint64 multconst = UINT64_HILO(0, 1);
-
-    // Determine the multiplier constant for the specified units
-    switch (aSrcUnits)
-    {
-        case OSCLCLOCK_MSEC:
-            multconst = UINT64_HILO(0, 1000);
-            break;
-
-        case OSCLCLOCK_SEC:
-            multconst = UINT64_HILO(0, 1000000);
-            break;
-
-        case OSCLCLOCK_MIN:
-            multconst = UINT64_HILO(0, 60000000);
-            break;
-
-        case OSCLCLOCK_HOUR:
-            multconst = UINT64_HILO(0, OSCL_UNSIGNED_CONST(3600000000));
-            break;
-
-        case OSCLCLOCK_DAY:
-            multconst = UINT64_HILO(0x14, 0x1DD76000);
-            break;
-
-        case OSCLCLOCK_USEC:
-        default:
-            break;
-    }
-
-    // Convert value to usec
-    if (multconst != (UINT64_HILO(0, 1)))
-    {
-        aUSecVal = aSrcVal * multconst;
-    }
-    else
-    {
-        aUSecVal = aSrcVal;
-    }
-}
-
-
-void OsclClock::FromUSec(uint64& aUSecVal, uint64& aDstVal, OsclClock_TimeUnits aDstUnits)
-{
-    uint64 divconst = UINT64_HILO(0, 1);
-
-    // Determine the divider constant for the specified units
-    switch (aDstUnits)
-    {
-        case OSCLCLOCK_MSEC:
-            divconst = UINT64_HILO(0, 1000);
-            break;
-
-        case OSCLCLOCK_SEC:
-            divconst = UINT64_HILO(0, 1000000);
-            break;
-
-        case OSCLCLOCK_MIN:
-            divconst = UINT64_HILO(0, 60000000);
-            break;
-
-        case OSCLCLOCK_HOUR:
-            divconst = UINT64_HILO(0, OSCL_UNSIGNED_CONST(3600000000));
-            break;
-
-        case OSCLCLOCK_DAY:
-            divconst = UINT64_HILO(0x14, 0x1DD76000);
-            break;
-
-        case OSCLCLOCK_USEC:
-        default:
-            break;
-    }
-
-    // Convert usec val to specified units
-    if (divconst != (UINT64_HILO(0, 1)))
-    {
-        aDstVal = aUSecVal / divconst;
-    }
-    else
-    {
-        aDstVal = aUSecVal;
-    }
-}
-
-
-bool OsclClock::AdjustClock(uint64& aObsTime, uint64& aObsTimebase, uint64& aAdjTime,
-                            uint64& aCurrentTime, uint64& aCurrentTimebase)
-{
-    // In this implementation, don't allow adjustments to be made with
-    // data older than when the last adjustment was made
-    if (aObsTimebase < iAdjustmentTimebaseTime)
-    {
-        return false;
-    }
-
-    // Make the adjustment
-    if (aAdjTime > aObsTime)
-    {
-        // Adjusted time is ahead so move ahead
-
-        // Save the observed timebase time of the adjusted time
-        iLastAdjustTimebaseTime = aObsTimebase;
-        UpdateLatestTimes(aAdjTime, aObsTimebase);
-
-        // Set the latest adjustment time as the current timebase time
-        iAdjustmentTimebaseTime = aCurrentTimebase;
-    }
-    else if (aAdjTime < aObsTime)
-    {
-        // Adjusted time is before the current time
-
-        // Save the observed timebase time of the adjusted time
-        iLastAdjustTimebaseTime = aObsTimebase;
-
-        // Set the latest clock time to the current clock time
-        // Set the latest timebase time to (current timebase time) + ((observed clock time) - (adjusted time))
-        uint64 offsettbtime = 0;
-        offsettbtime = aCurrentTimebase;
-        offsettbtime += (aObsTime - aAdjTime);
-        UpdateLatestTimes(aCurrentTime, offsettbtime);
-
-        // Set the latest adjustment time to the current timebase time without offset
-        // to allow the adjustment even before previous adjustment delta has elapsed.
-        iAdjustmentTimebaseTime = aCurrentTimebase;
-    }
-    else
-    {
-        // Since there is no adjustment, do nothing
-    }
-
-    ClockAdjusted();
-    return true;
-}
-
-
-void OsclClock::GetAdjustedRunningClockTime(uint64& aDstTime, uint64& aTimebaseVal)
-{
-    // Current time is (latest clock time)+(current timebase time - latest timebase time)
-    aDstTime = iLatestRunningClockTime;
-
-    // If backward adjustment occurs, iLatestRunningTimebaseTime might be greater than
-    // the current value. To avoid negative values and clock going back, only
-    // add the diff if current timebase value is greater. This makes the clock "freeze" until
-    // the difference has elapsed
-    if (aTimebaseVal > iLatestRunningTimebaseTime)
-    {
-        aDstTime += (aTimebaseVal - iLatestRunningTimebaseTime);
-    }
-}
-
-void OsclClock::ClockCountUpdated()
-{
-    //notify all observers that the clock count was updated.
-    for (uint32 i = 0;i < iClockObservers.size();i++)
-        iClockObservers[i]->ClockCountUpdated();
-}
-
-void OsclClock::ClockAdjusted()
-{
-    //notify all observers that the clock was adjusted
-    for (uint32 i = 0;i < iClockObservers.size();i++)
-        iClockObservers[i]->ClockAdjusted();
-}
-
-void OsclClock::ClockTimebaseUpdated()
-{
-    //notify all observers that the clock timebase was updated.
-    for (uint32 i = 0;i < iClockObservers.size();i++)
-    {
-        OsclClockObserver* obs = iClockObservers[i];
-        obs->ClockTimebaseUpdated();
-    }
-    //reset timebase history.
-    iLastAdjustTimebaseTime = 0;
-    iAdjustmentTimebaseTime = 0;
-}
-
-
diff --git a/oscl/oscl/osclutil/src/oscl_clock.h b/oscl/oscl/osclutil/src/oscl_clock.h
deleted file mode 100644
index 2f5667a..0000000
--- a/oscl/oscl/osclutil/src/oscl_clock.h
+++ /dev/null
@@ -1,667 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-//				 O S C L _ C L O C K	C L A S S
-//	  This file contains a general clock class and utils
-//	  needed for multimedia softwares
-// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
-/*! \addtogroup osclutil OSCL Util
- *
- * @{
- */
-
-
-/*!
- * \file oscl_clock.h
- * \brief Provides a time clock that can be paused and resumed,
- *	  set the start time, adjusted based on outside source feedback,
- *    and accepts user specified source for the free running clock.
- */
-
-#ifndef OSCL_CLOCK_H_INCLUDED
-#define OSCL_CLOCK_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef OSCL_TICKCOUNT_H_INCLUDED
-#include "oscl_tickcount.h"
-#endif
-
-#ifndef OSCL_INT64_UTILS_H_INCLUDED
-#include "oscl_int64_utils.h"
-#endif
-
-#ifndef OSCL_VECTOR_H_INCLUDED
-#include "oscl_vector.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-/*
- * Enum for the time units used in OSCL Clock
- */
-enum OsclClock_TimeUnits
-{
-    OSCLCLOCK_USEC	= 0,
-    OSCLCLOCK_MSEC	= 1,
-    OSCLCLOCK_SEC	= 2,
-    OSCLCLOCK_MIN	= 3,
-    OSCLCLOCK_HOUR	= 4,
-    OSCLCLOCK_DAY	= 5
-};
-
-/**
-	OsclClockObserver is an observer class for OsclClock.  Modules
-	can optionally register themselves as clock observers.  There
-	can be multiple observers for a single clock.
-*/
-class OsclClockObserver
-{
-    public:
-        /*
-        ** This event happens when the timebase for this clock
-        ** has been updated
-        */
-        virtual void ClockTimebaseUpdated() = 0;
-        /*
-        ** This event happens for counting timebases only, when the
-        ** count has been updated.
-        */
-        virtual void ClockCountUpdated() = 0;
-        /*
-        ** This event happens when the clock has been adjusted
-        */
-        virtual void ClockAdjusted() = 0;
-
-        virtual ~OsclClockObserver() {}
-};
-
-/**
-	OsclClockStateObserver is an observer class for OsclClock.  Modules
-	can optionally register themselves as clock state observers.  There
-	can be multiple observers for a single clock.
-*/
-class OsclClockStateObserver
-{
-    public:
-        /*
-        ** This event happens when the clock state has changed.
-        */
-        virtual void ClockStateUpdated() = 0;
-
-        virtual ~OsclClockStateObserver() {}
-};
-
-/**
-	OsclCountTimebase is an extension to the standard timebase to allow
-	controlled stepping rather than continuous flow timebase.
-*/
-class OsclCountTimebase
-{
-    public:
-        /*
-        ** Set a new value for the count.  Will trigger a ClockCountUpdated callback
-        ** to all observers of the clock in which this timebase resides.
-        ** @param aCount (input): the new count
-        */
-        virtual void SetCount(int64 aCount) = 0;
-        /*
-        ** Read current value of the count.
-        ** @param aCount (output): the current count
-        */
-        virtual void GetCount(int64& aCount) = 0;
-
-        virtual ~OsclCountTimebase() {}
-    private:
-        /*
-        ** Each OsclCountTimebase will be contained within an OsclClock
-        ** class.  That OsclClock instance will set itself as the observer of
-        ** the OsclCountTimebase.  To get notices from the timebase, modules
-        ** can register through the SetClockObserver method of the OsclClock.
-        */
-        friend class OsclClock;
-        virtual void SetClockObserver(OsclClockObserver* aObserver) = 0;
-};
-
-/**
-	OsclTimebase is a base class to obtain the timebase clock time.
-	Common source of the timebase clock is the system tickcount which is implemented
-	as OsclTimebase_Tickcount further below. OsclTimebase is expected to return the time
-	in units of microseconds even if the timebase itself does not have the resolution of microseconds.
-*/
-class OsclTimebase
-{
-    public:
-        /**
-            Virtual destructor for OsclTimebase
-        */
-        virtual ~OsclTimebase() {}
-
-        /**
-        	Returns the timebase clock's smallest time resolution in microseconds
-        	@param aResolution: unsigned 32-bit value for the clock resolution
-        */
-        virtual void GetTimebaseResolution(uint32& aResolution) = 0;
-
-        /**
-        	Returns the current clock time as unsigned 64-bit integer object in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to return the current time
-        	@param aUnits: the requested time units for aTime
-        */
-        virtual void GetCurrentTime64(uint64& aTime, OsclClock_TimeUnits aUnits)
-        {
-            // Call the version that returns the timebase time as well to get current time
-            uint64 tmp64 = 0;
-            GetCurrentTime64(aTime, aUnits, tmp64);
-        }
-
-        /**
-        	Returns the current timebase time as unsigned 64-bit integer object in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to return the current time
-        	@param aUnits: the requested time units for aTime
-        	@param aTimebaseTime: a reference to an unsigned 64-bit integer to return the timebase time
-        */
-        virtual void GetCurrentTime64(uint64& aTime, OsclClock_TimeUnits aUnits, uint64& aTimebaseTime) = 0;
-
-        /**
-        	Returns the current timebase time as unsigned 32-bit integer in the specified time units
-        	@param aTime: a reference to an unsigned 32-bit integer to return the current time
-        	@param aOverflow: a reference to a flag which is set if time value cannot fit in unsigned 32-bit integer
-        	@param aUnits: the requested time units for aTime
-        */
-        virtual void GetCurrentTime32(uint32& aTime, bool& aOverflow, OsclClock_TimeUnits aUnits)
-        {
-            // Use the 64-bit version to get the current time
-            // Check for value overflow as well
-            uint64 time64 = 0;
-            GetCurrentTime64(time64, aUnits);
-            aTime = Oscl_Int64_Utils::get_uint64_lower32(time64);
-            aOverflow = (Oscl_Int64_Utils::get_uint64_upper32(time64) > 0 ? true : false);
-        }
-
-        /**
-        	Returns a pointer to the OsclCountTimebase class instance, if
-        	this timebase supports OsclCountTimebase.
-        	@return pointer to OsclCountTimebase implementation, or NULL if not supported.
-        */
-        virtual OsclCountTimebase* GetCountTimebase() = 0;
-
-};
-
-
-
-class OsclClock : public OsclTimebase, public OsclClockObserver
-{
-    public:
-        /**
-        	The default constructor initializes the clock to 0 and goes to STOPPED state
-        */
-        OSCL_IMPORT_REF OsclClock();
-
-        /**
-        	The default destructor
-        */
-        OSCL_IMPORT_REF ~OsclClock();
-
-        /**
-        	Sets the timebase to use for this clock.
-        	Will trigger an ClockTimebaseUpdated notice to all observers of this clock.
-        	The clock timebase can only be set while in STOPPED and PAUSED states.
-        	Returns true if the new clock timebase has been accepted, false otherwise
-        	@param aTimebase: a reference to an OsclTimebase-derived object
-        */
-        OSCL_IMPORT_REF bool SetClockTimebase(OsclTimebase& aTimebase);
-
-
-        /**
-        	Starts the clock from the start time or
-        	resumes the clock from the last paused time. Clock goes to RUNNING state.
-        	Returns true if the clock is resumed or started, false otherwise
-        */
-        OSCL_IMPORT_REF bool Start();
-
-        /**
-        	Pauses the running clock. Saves the clock time when pausing as the
-        	paused time. Clock goes to PAUSED state.
-        	Returns true if the clock is paused, false otherwise
-        */
-        OSCL_IMPORT_REF bool Pause();
-
-        /**
-        	Stops the running or paused clock and start time is reset to 0. Clock goes to STOPPED state.
-        	Returns true if the clock is stopped, false otherwise
-        */
-        OSCL_IMPORT_REF bool Stop();
-
-
-        /**
-            Sets the starting clock time with unsigned 32-bit integer in the specified time
-        	units while in STOPPED state.
-        	Returns true if the start time has been set, false otherwise
-        	@param aTime: a reference to an unsigned 32-bit integer to set the start time
-        	@param aUnits: the time units of aTime
-        */
-        OSCL_IMPORT_REF bool SetStartTime32(uint32& aTime, OsclClock_TimeUnits aUnits);
-
-        /**
-            Gets the starting clock time as an unsigned 32-bit integer in the specified time units
-        	@param aTime: a reference to an unsigned 32-bit integer to copy the start time
-        	@param aOverflow: a reference to a flag which is set if time value cannot fit in unsigned 32-bit integer
-        	@param aUnits: the requested time units for aTime
-        */
-        OSCL_IMPORT_REF void GetStartTime32(uint32& aTime, bool& aOverflow, OsclClock_TimeUnits aUnits);
-
-        /**
-            Sets the starting clock time with unsigned 64-bit integer in the specified time
-        	units while in STOPPED state.
-        	Returns true if the start time has been set, false otherwise
-        	@param aTime: a reference to an unsigned 64-bit integer to set the start time
-        	@param aUnits: the time units of aTime
-        */
-        OSCL_IMPORT_REF bool SetStartTime64(uint64& aTime, OsclClock_TimeUnits aUnits);
-
-        /**
-            Gets the starting clock time as an unsigned 64-bit integer in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to copy the start time
-        	@param aUnits: the requested time units for aTime
-        */
-        OSCL_IMPORT_REF void GetStartTime64(uint64& aTime, OsclClock_TimeUnits aUnits);
-
-        /**
-            Adjusts the clock time with unsigned 32-bit integer in the specified time
-        	units while in RUNNING state.
-        	Returns true if the clock time has been adjusted, false otherwise
-        	@param aClockTime: a reference to an unsigned 32-bit integer to the observation clock time
-        	@param aTimebaseTime: a reference to an unsigned 64-bit integer to the observation timebase time
-        	@param aAdjustedTime: a reference to an unsigned 32-bit integer to the adjusted clock time
-        	@param aUnits: the time units of aClockTime and aAdjustedTime
-        */
-        OSCL_IMPORT_REF bool AdjustClockTime32(uint32& aClockTime, uint64& aTimebaseTime, uint32& aAdjustedTime, OsclClock_TimeUnits aUnits);
-
-        /**
-            Adjusts the clock time with unsigned 64-bit integer in the specified time
-        	units while in RUNNING state.
-        	Returns true if the clock time has been adjusted, false otherwise
-        	@param aClockTime: a reference to an unsigned 64-bit integer to the observation clock time
-        	@param aTimebaseTime: a reference to an unsigned 64-bit integer to the observation timebase time
-        	@param aAdjustedTime: a reference to an unsigned 64-bit integer to the adjusted clock time
-        	@param aUnits: the time units of aClockTime and aAdjustedTime
-        */
-        OSCL_IMPORT_REF bool AdjustClockTime64(uint64& aClockTime, uint64& aTimebaseTime, uint64& aAdjustedTime, OsclClock_TimeUnits aUnits);
-
-        // From OsclTimebase
-        /** Returns the clock's smallest time resolution in microseconds
-        	@param aResolution: unsigned 32-bit value for the clock resolution
-        */
-        OSCL_IMPORT_REF void GetTimebaseResolution(uint32& aResolution);
-
-        /**
-        	Returns the current clock time as unsigned 64-bit integer object in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to return the current time
-        	@param aUnits: the requested time units for aTime
-        */
-        OSCL_IMPORT_REF void GetCurrentTime64(uint64& aClockTime, OsclClock_TimeUnits aUnits);
-
-        /**
-        	Returns the current clock time as unsigned 64-bit integer object in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to return the current time
-        	@param aUnits: the requested time units for aTime
-        	@param aTimebaseTime: a reference to an unsigned 64-bit integer to return the timebase time
-        */
-        OSCL_IMPORT_REF void GetCurrentTime64(uint64& aClockTime, OsclClock_TimeUnits aUnits, uint64& aTimebaseTime);
-
-        /**
-        	Sets an observer for this clock.  May leave if memory allocation fails.
-        	@param aObserver: the observer implemenation
-        */
-        OSCL_IMPORT_REF void SetClockObserver(OsclClockObserver& aObserver);
-
-        /**
-        	Removes an observer for this clock.  If the observer is not registered, this
-        	call does nothing.
-        	@param aObserver: the observer implemenation
-        */
-        OSCL_IMPORT_REF void RemoveClockObserver(OsclClockObserver& aObserver);
-
-        /**
-        	Sets an observer for this clock.  May leave if memory allocation fails.
-        	@param aObserver: the observer implemenation
-        */
-        OSCL_IMPORT_REF void SetClockStateObserver(OsclClockStateObserver& aObserver);
-        /**
-        	Removes an observer for this clock.  If the observer is not registered, this
-        	call does nothing.
-        	@param aObserver: the observer implemenation
-        */
-        OSCL_IMPORT_REF void RemoveClockStateObserver(OsclClockStateObserver& aObserver);
-
-        /*
-         * Enum for OsclClock's internal states
-         */
-        enum OsclClockState
-        {
-            STOPPED,
-            RUNNING,
-            PAUSED
-        };
-
-        OsclClockState GetState()
-        {
-            return iState;
-        }
-
-        /**
-        	Retreive the OsclCountTimebase implementation from this clock's timebase,
-        	or NULL if the timebase is not a counted timebase.
-        	@return the OsclCountTimebase, or NULL.
-        */
-        OsclCountTimebase* GetCountTimebase()
-        {
-            if (iClockTimebase)
-                return iClockTimebase->GetCountTimebase();
-            return NULL;
-        }
-
-
-    protected:
-
-        /**
-            Changes the clock's state to the specified state
-        	@param aState: the new state to change to
-        */
-        void SetClockState(OsclClockState aState);
-        /**
-            Updates the iLatestTime and iLatestSourceVal to specified values
-        	@param aTime: the new iLatestTime value to change to
-        	@param aSourceVal: the new iLatestSourceVal value to change to
-        */
-        void UpdateLatestTimes(uint64& aTime, uint64& aSourceVal);
-        /**
-            Converts a time value in the specified time units to microseconds
-        	@param aSrcVal: unsigned 64-bit time value in units specified by aSrcUnits
-        	@param aSrcUnits: time units of aSrcVal
-        	@param aUSecVal: reference to unsigned 64-bit integer to store the microsecond time value
-        */
-        void ToUSec(uint64& aSrcVal, OsclClock_TimeUnits aSrcUnits, uint64& aUSecVal);
-        /**
-            Converts a microsecond time value to the specified time units
-        	@param aUSecVal: unsigned 64-bit integer in microsecond time value
-        	@param aDstVal: reference to unsigned 64-bit integer which will contain aUSecVal in the
-        	specified aDstUnits time units
-        	@param aDstUnits: requested time units for aDstVal
-        */
-        void FromUSec(uint64& aUSecVal, uint64& aDstVal, OsclClock_TimeUnits aDstUnits);
-
-        /**
-        	Updates the internal clock parameters based on the adjustment information provided.
-        	This function can be overridden in the derived classes to allow variety in the adjustment algorithm
-        	@param aObsTime: unsigned 64-bit integer in microsecond for the observed clock time
-        	@param aObsTimebase: unsigned 64-bit integer in microsecond for the observed timebase time
-        	@param aAdjTime: unsigned 64-bit integer in microsecond for the adjusted clock time
-        	@param aCurrentTime: unsigned 64-bit integer in microsecond for the current clock time
-        	@param aCurrentTimebase: unsigned 64-bit integer in microsecond for the current timebase time
-        */
-        virtual bool AdjustClock(uint64& aObsTime, uint64& aObsTimebase, uint64& aAdjTime,
-                                 uint64& aCurrentTime, uint64& aCurrentTimebase);
-
-        /**
-        	Returns the adjusted current clock time when the clock is running
-        	This function can be overridden in the derived classes to allow variety in the adjustment algorithm
-        	@param aDstTime: unsigned 64-bit integer in microseconds to output the adjusted current clock time
-        	@param aTimebaseVal: unsigned 64-bit integer in microseconds of the current timebase time
-        */
-        virtual void GetAdjustedRunningClockTime(uint64& aDstTime, uint64& aTimebaseVal);
-
-        // Clock time is stored as unsigned 64-bit value in microseconds
-        // Timebase time is stored as unsigned 64-bit value in microseconds
-        uint64 iLatestRunningClockTime;     // Last reference clock time due to starting/resuming, pausing, and adjustment
-        uint64 iLatestRunningTimebaseTime;  // Timebase time corresponding to the latest running clock time
-        uint64 iStartClockTime;				// Starting clock time. Set by the SetStartTime...() APIs
-        uint64 iPauseClockTime;				// Clock time when Pause() API is called.
-        uint64 iLastAdjustTimebaseTime;		// The observed timebase time corresponding to the adjusted time passed in
-        uint64 iAdjustmentTimebaseTime;		// The timebase time of the last successful AdjustClockTime...() call
-
-        OsclClockState iState;					// Internal state of the clock
-
-        OsclTimebase* iClockTimebase;			// Pointer to this clock's timebase
-
-        //vector of clock observers.
-        Oscl_Vector<OsclClockObserver*, OsclMemAllocator> iClockObservers;
-        Oscl_Vector<OsclClockStateObserver*, OsclMemAllocator> iClockStateObservers;
-
-        //from OsclClockObserver, for callbacks from an OsclCountTimebase.
-        void ClockCountUpdated();
-        void ClockTimebaseUpdated();
-        void ClockAdjusted();
-};
-
-
-#define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA
-#include "osclconfig_compiler_warnings.h"
-
-/**
-	OsclTimebase_Tickcount is OsclTimebase-derived class which uses
-	the OSCL's system tickcount as the timebase. This class is provided
-	as the default OsclTimebase that is available on any platform with OSCL support.
-*/
-class OsclTimebase_Tickcount : public OsclTimebase
-{
-    public:
-        /**
-        	Constructor. Retrieves the constant to convert OSCL tickcount value to microseconds
-        */
-        OsclTimebase_Tickcount()
-        {
-            Oscl_Int64_Utils::set_uint64(iMicrosecPerTick, 0, OsclTickCount::TickCountPeriod());
-            iTickcountHCounter = 0;
-            iPrevTickcount = 0;
-        }
-
-        /**
-        	Destructor
-        */
-        ~OsclTimebase_Tickcount()
-        {
-        }
-
-        // From OsclTimebase
-        /**
-        	Returns the OSCL tickcount's time resolution in microseconds
-            Implementation of virtual function from OsclTimebase
-        	@param aResolution: On function completion, contains OSCL tickcount resolution
-        */
-        void GetTimebaseResolution(uint32& aResolution)
-        {
-            aResolution = Oscl_Int64_Utils::get_uint64_lower32(iMicrosecPerTick);
-        }
-
-        /**
-        	Returns the current clock time as unsigned 64-bit integer object in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to return the current time
-        	@param aUnits: the requested time units for aTime
-        	@param aTimebaseTime: a reference to an unsigned 64-bit integer to return the timebase time
-        */
-        void GetCurrentTime64(uint64& aTime, OsclClock_TimeUnits aUnits, uint64& aTimebaseTime)
-        {
-            // Check to see if the tickcount wrapped around
-            uint32 currenttickcount = OsclTickCount::TickCount();
-            if (iPrevTickcount > currenttickcount)
-            {
-                ++iTickcountHCounter;
-            }
-
-            // Set the time and convert to microseconds
-            Oscl_Int64_Utils::set_uint64(aTime, iTickcountHCounter, currenttickcount);
-            aTimebaseTime = aTime;
-            aTime *= iMicrosecPerTick;
-
-            // Determine the divider constant for the specified units
-            uint64 divconst = UINT64_HILO(0, 1);
-            switch (aUnits)
-            {
-                case OSCLCLOCK_MSEC:
-                    divconst = UINT64_HILO(0, 1000);
-                    break;
-
-                case OSCLCLOCK_SEC:
-                    divconst = UINT64_HILO(0, 1000000);
-                    break;
-
-                case OSCLCLOCK_MIN:
-                    divconst = UINT64_HILO(0, 60000000);
-                    break;
-
-                case OSCLCLOCK_HOUR:
-                    divconst = UINT64_HILO(0, OSCL_UNSIGNED_CONST(0xD693A400));
-                    break;
-
-                case OSCLCLOCK_DAY:
-                    divconst = UINT64_HILO(0x14, 0x1DD76000);
-                    break;
-
-                case OSCLCLOCK_USEC:
-                default:
-                    break;
-            }
-
-            // Convert usec val to specified units
-            if (divconst != (UINT64_HILO(0, 1)))
-            {
-                aTime /= divconst;
-            }
-
-            // Save the current tickcount for next comparison
-            iPrevTickcount = currenttickcount;
-        }
-
-        OsclCountTimebase* GetCountTimebase()
-        {
-            return NULL;
-        }
-
-    protected:
-        uint64 iMicrosecPerTick;
-        uint32 iTickcountHCounter;
-        uint32 iPrevTickcount;
-
-};
-
-/**
-	OsclTimebase_Counter is OsclTimebase-derived class that can be used to
-	implement a simple count-based timebase.
-*/
-class OsclTimebase_Count : public OsclTimebase, public OsclCountTimebase
-{
-    public:
-        /**
-        	Constructor.
-        */
-        OsclTimebase_Count()
-        {
-            iCurrentCount = 0;
-            iObserver = NULL;
-        }
-
-        /**
-        	Destructor
-        */
-        ~OsclTimebase_Count()
-        {
-        }
-
-        // From OsclTimebase
-        /**
-        	Returns the OSCL tickcount's time resolution in microseconds
-            Implementation of virtual function from OsclTimebase
-        	@param aResolution: On function completion, contains OSCL tickcount resolution
-        */
-        void GetTimebaseResolution(uint32& aResolution)
-        {
-            aResolution = 0;//not meaningful for a count-based timebase.
-        }
-
-        /**
-        	Returns the current clock time as unsigned 64-bit integer object in the specified time units
-        	@param aTime: a reference to an unsigned 64-bit integer to return the current time
-        	@param aUnits: the requested time units for aTime
-        	@param aTimebaseTime: a reference to an unsigned 64-bit integer to return the timebase time
-        */
-        void GetCurrentTime64(uint64& aTime, OsclClock_TimeUnits aUnits, uint64& aTimebaseTime)
-        {
-            //not meaningful for a count-based timebase.
-            OSCL_UNUSED_ARG(aUnits);
-            aTime = 0;
-            aTimebaseTime = 0;
-        }
-
-        /**
-        	Returns the OsclCountTimebase implementation pointer
-        */
-        OsclCountTimebase* GetCountTimebase()
-        {
-            return this;
-        }
-
-        //From OsclCountTimebase
-        /**
-        	Used to adjust the current count.
-        	@param aCount (input): new count value.
-        */
-        void SetCount(int64 aCount)
-        {
-            iCurrentCount = aCount;
-            if (iObserver)
-            {
-                iObserver->ClockCountUpdated();
-            }
-        }
-
-        /**
-        	Used to retreive the current count.
-        	@param aCount (output): new count value.
-        */
-        void GetCount(int64& aCount)
-        {
-            aCount = iCurrentCount;
-        }
-
-
-    protected:
-        int64 iCurrentCount;
-        OsclClockObserver* iObserver;
-
-    private:
-        friend class OsclClock;
-        //From OsclCountTimebase
-        void SetClockObserver(OsclClockObserver* aObserver)
-        {
-            iObserver = aObserver;
-        }
-
-};
-
-
-#endif // OSCL_CLOCK_H_INCLUDED
-
-
diff --git a/oscl/oscl/osclutil/src/oscl_math.cpp b/oscl/oscl/osclutil/src/oscl_math.cpp
index 9ec48fa..16ab22e 100644
--- a/oscl/oscl/osclutil/src/oscl_math.cpp
+++ b/oscl/oscl/osclutil/src/oscl_math.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_math.h b/oscl/oscl/osclutil/src/oscl_math.h
index f4826f1..20f0229 100644
--- a/oscl/oscl/osclutil/src/oscl_math.h
+++ b/oscl/oscl/osclutil/src/oscl_math.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_math.inl b/oscl/oscl/osclutil/src/oscl_math.inl
index e11c5c9..a93143e 100644
--- a/oscl/oscl/osclutil/src/oscl_math.inl
+++ b/oscl/oscl/osclutil/src/oscl_math.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_media_data.h b/oscl/oscl/osclutil/src/oscl_media_data.h
index 1022fda..ccc3048 100644
--- a/oscl/oscl/osclutil/src/oscl_media_data.h
+++ b/oscl/oscl/osclutil/src/oscl_media_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_media_status.h b/oscl/oscl/osclutil/src/oscl_media_status.h
index 0d34472..9297e68 100644
--- a/oscl/oscl/osclutil/src/oscl_media_status.h
+++ b/oscl/oscl/osclutil/src/oscl_media_status.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_priqueue.cpp b/oscl/oscl/osclutil/src/oscl_priqueue.cpp
index f6f0cb4..08d33f4 100644
--- a/oscl/oscl/osclutil/src/oscl_priqueue.cpp
+++ b/oscl/oscl/osclutil/src/oscl_priqueue.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -112,15 +112,18 @@
     OsclAny* pos = find_heap(input, pVec->begin(), pVec->end());
     if (pos)
     {
-        // Move the element of interest to end of tree and remove
-        pop_heap(pos, pVec->end());
-        pVec->pop_back();
-        // Re-sort all elements beyond the removed element.
-        OsclAny* endpos = pVec->increment_T(pos, 1);
-        while (endpos <= pVec->end())
+        if (pVec->increment_T(pos, 1) == pVec->end())
         {
-            push_heap(pVec->begin(), endpos);
-            endpos = pVec->increment_T(endpos, 1);
+            // It's the last element-- just remove it without any re-ordering.
+            pVec->pop_back();
+        }
+        else
+        {
+            // Move the element to the end & remove.
+            pop_heap(pos, pVec->end());
+            pVec->pop_back();
+            // Re-order the front part of the queue.
+            push_heap(pVec->begin(), pVec->increment_T(pos, 1));
         }
         return 1;
     }
diff --git a/oscl/oscl/osclutil/src/oscl_priqueue.h b/oscl/oscl/osclutil/src/oscl_priqueue.h
index ebe991b..93edfbb 100644
--- a/oscl/oscl/osclutil/src/oscl_priqueue.h
+++ b/oscl/oscl/osclutil/src/oscl_priqueue.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -138,6 +138,10 @@
         {
             return c.front();
         };
+        const Container & vec()
+        {
+            return c;
+        }
 
         void push(const value_type& input)
         {
@@ -206,11 +210,6 @@
             return -1;//ok
         }
 
-        //a debug routine for direct access to the contents of the Oscl_Vector.
-        const Container & vec()
-        {
-            return c;
-        }
         friend class oscl_priqueue_test;
 
         //from Oscl_Opaque_Type_Compare
diff --git a/oscl/oscl/osclutil/src/oscl_rand.cpp b/oscl/oscl/osclutil/src/oscl_rand.cpp
index 79a72cd..54fb425 100644
--- a/oscl/oscl/osclutil/src/oscl_rand.cpp
+++ b/oscl/oscl/osclutil/src/oscl_rand.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_rand.h b/oscl/oscl/osclutil/src/oscl_rand.h
index 3790d2e..28e818b 100644
--- a/oscl/oscl/osclutil/src/oscl_rand.h
+++ b/oscl/oscl/osclutil/src/oscl_rand.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_rand.inl b/oscl/oscl/osclutil/src/oscl_rand.inl
index ae1beb7..220afce 100644
--- a/oscl/oscl/osclutil/src/oscl_rand.inl
+++ b/oscl/oscl/osclutil/src/oscl_rand.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_snprintf.cpp b/oscl/oscl/osclutil/src/oscl_snprintf.cpp
index b86d95d..78c87e7 100644
--- a/oscl/oscl/osclutil/src/oscl_snprintf.cpp
+++ b/oscl/oscl/osclutil/src/oscl_snprintf.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -362,6 +362,48 @@
 
 
 
+//An implementation of swprintf for platforms that have native sprintf, but not swprintf.
+//Note this routine converts input oscl_wchar strings to single-wide without any
+//Unicode-to-UTF8 conversion.  This is sufficient for the usage in this module, since
+//we know that format strings are ASCII character only, and there are no string arguments
+//in the argument list passed to this routine.
+static int32 oscl_default_swprintf(oscl_wchar *buffer, int32 bufferlen, const oscl_wchar *format, ...)
+{
+    OSCL_UNUSED_ARG(bufferlen);
+
+    int32 result;
+    int32 nformat = oscl_strlen(format);
+    char* sformat = (char*)format;
+    char* sbuffer = (char*)buffer;
+
+    //Compress the format-string to single-wide.
+    int32 i;
+    for (i = 0;i < nformat;i++)
+        sformat[i] = (char)format[i];
+    sformat[nformat] = '\0';
+
+    va_list args;
+    va_start(args, format);
+    result = vsprintf(sbuffer, sformat, args);
+    va_end(args);
+
+    //Restore the original format string.  Probably unnecessary.
+    oscl_wchar* oformat = (oscl_wchar*)format;
+    oformat[nformat] = '\0';
+    for (i = 0;i < nformat;i++)
+        oformat[nformat-i-1] = (oscl_wchar)sformat[nformat-i-1];
+
+    //Stretch the result string from single-wide to wide.
+    int32 nsbuffer = oscl_strlen(sbuffer);
+    buffer[nsbuffer] = '\0';
+    for (i = 0;i < nsbuffer;i++)
+        buffer[nsbuffer-i-1] = (oscl_wchar)sbuffer[nsbuffer-i-1];
+
+    return result;
+}
+
+OSCL_IMPORT_REF int32 oscl_UnicodeToUTF8(const oscl_wchar *input, int32 inLength, char *output, int32 outLength);
+
 OsclAny * oscl_memchr(const OsclAny * str, int32 c, int32 count)
 {
     uint8* p = (uint8 *)str;
@@ -1662,7 +1704,7 @@
                         f[f_l++] = '\0';
                         if (fmt_spec == 'p')
                         {
-                            OSCL_ASSERT(false);//non-functional-- no swprintf
+                            str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, ptr_arg);
                         }
                         else if (fmt_spec == 'd')    /* signed */
                         {
@@ -1670,16 +1712,16 @@
                             {
                                 case '\0':
                                 case 'h':
-                                    OSCL_ASSERT(false);//non-functional-- no swprintf
+                                    str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, int_arg);
                                     break;
 
                                 case 'l':
-                                    OSCL_ASSERT(false);//non-functional-- no swprintf
+                                    str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, long_arg);
                                     break;
 
 #ifdef SNPRINTF_LONGLONG_SUPPORT
                                 case '2':
-                                    OSCL_ASSERT(false);//non-functional-- no swprintf
+                                    str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, long_long_arg);
                                     break;
 #endif //snprintf_longlong_support
 
@@ -1691,16 +1733,16 @@
                             {
                                 case '\0':
                                 case 'h':
-                                    OSCL_ASSERT(false);//non-functional-- no swprintf
+                                    str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, uint_arg);
                                     break;
 
                                 case 'l':
-                                    OSCL_ASSERT(false);//non-functional-- no swprintf
+                                    str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, ulong_arg);
                                     break;
 
 #ifdef SNPRINTF_LONGLONG_SUPPORT
                                 case '2':
-                                    OSCL_ASSERT(false);//non-functional-- no swprintf
+                                    str_arg_l += oscl_default_swprintf(tmp + str_arg_l, NUMERIC_CONV_BUF_SIZE - str_arg_l, f, ulong_long_arg);
                                     break;
 #endif //snprintf_longlong_support
 
diff --git a/oscl/oscl/osclutil/src/oscl_snprintf.h b/oscl/oscl/osclutil/src/oscl_snprintf.h
index eda9e50..d9923aa 100644
--- a/oscl/oscl/osclutil/src/oscl_snprintf.h
+++ b/oscl/oscl/osclutil/src/oscl_snprintf.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp b/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp
index f3d5ded..68be82f 100644
--- a/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp
+++ b/oscl/oscl/osclutil/src/oscl_str_ptr_len.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_str_ptr_len.h b/oscl/oscl/osclutil/src/oscl_str_ptr_len.h
index 8bc8ab8..a1d34d9 100644
--- a/oscl/oscl/osclutil/src/oscl_str_ptr_len.h
+++ b/oscl/oscl/osclutil/src/oscl_str_ptr_len.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string.cpp b/oscl/oscl/osclutil/src/oscl_string.cpp
index 383eafc..028bd3d 100644
--- a/oscl/oscl/osclutil/src/oscl_string.cpp
+++ b/oscl/oscl/osclutil/src/oscl_string.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string.h b/oscl/oscl/osclutil/src/oscl_string.h
index 27501a0..a171a02 100644
--- a/oscl/oscl/osclutil/src/oscl_string.h
+++ b/oscl/oscl/osclutil/src/oscl_string.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_containers.cpp b/oscl/oscl/osclutil/src/oscl_string_containers.cpp
index a994ee7..326138a 100644
--- a/oscl/oscl/osclutil/src/oscl_string_containers.cpp
+++ b/oscl/oscl/osclutil/src/oscl_string_containers.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_containers.h b/oscl/oscl/osclutil/src/oscl_string_containers.h
index bcb3e14..77e6f8f 100644
--- a/oscl/oscl/osclutil/src/oscl_string_containers.h
+++ b/oscl/oscl/osclutil/src/oscl_string_containers.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_rep.h b/oscl/oscl/osclutil/src/oscl_string_rep.h
index ebba138..16858d4 100644
--- a/oscl/oscl/osclutil/src/oscl_string_rep.h
+++ b/oscl/oscl/osclutil/src/oscl_string_rep.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_uri.cpp b/oscl/oscl/osclutil/src/oscl_string_uri.cpp
index 70e5349..eaa9b7f 100644
--- a/oscl/oscl/osclutil/src/oscl_string_uri.cpp
+++ b/oscl/oscl/osclutil/src/oscl_string_uri.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_uri.h b/oscl/oscl/osclutil/src/oscl_string_uri.h
index df02d11..7c2b931 100644
--- a/oscl/oscl/osclutil/src/oscl_string_uri.h
+++ b/oscl/oscl/osclutil/src/oscl_string_uri.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_utf8.cpp b/oscl/oscl/osclutil/src/oscl_string_utf8.cpp
index e53b45d..b01f746 100644
--- a/oscl/oscl/osclutil/src/oscl_string_utf8.cpp
+++ b/oscl/oscl/osclutil/src/oscl_string_utf8.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_utf8.h b/oscl/oscl/osclutil/src/oscl_string_utf8.h
index 2483882..d76b81c 100644
--- a/oscl/oscl/osclutil/src/oscl_string_utf8.h
+++ b/oscl/oscl/osclutil/src/oscl_string_utf8.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_xml.cpp b/oscl/oscl/osclutil/src/oscl_string_xml.cpp
index bcf8542..93a9f96 100644
--- a/oscl/oscl/osclutil/src/oscl_string_xml.cpp
+++ b/oscl/oscl/osclutil/src/oscl_string_xml.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_string_xml.h b/oscl/oscl/osclutil/src/oscl_string_xml.h
index 7debaac..608f166 100644
--- a/oscl/oscl/osclutil/src/oscl_string_xml.h
+++ b/oscl/oscl/osclutil/src/oscl_string_xml.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_tickcount.cpp b/oscl/oscl/osclutil/src/oscl_tickcount.cpp
index 2b6be6b..278ef46 100644
--- a/oscl/oscl/osclutil/src/oscl_tickcount.cpp
+++ b/oscl/oscl/osclutil/src/oscl_tickcount.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_tickcount.h b/oscl/oscl/osclutil/src/oscl_tickcount.h
index 4d2fca9..3618d3d 100644
--- a/oscl/oscl/osclutil/src/oscl_tickcount.h
+++ b/oscl/oscl/osclutil/src/oscl_tickcount.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/oscl/osclutil/src/oscl_tickcount.inl b/oscl/oscl/osclutil/src/oscl_tickcount.inl
index c3abbe1..4238010 100644
--- a/oscl/oscl/osclutil/src/oscl_tickcount.inl
+++ b/oscl/oscl/osclutil/src/oscl_tickcount.inl
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,10 @@
 #include "osclconfig.h"
 #endif
 
+#ifndef OSCL_SINGLETON_H_INCLUDED
+#include "oscl_singleton.h"
+#endif
+
 
 //See if the gettimeofday implementation is available.
 //It relies on timeval and global variables...
@@ -46,6 +50,11 @@
 {
 #if   PV_USE_GETTIMEOFDAY
 #define ROLLBACK_THRESHOLD 0x80000000
+    // lock this function against other threads changing the static variables
+    // ignore return value and error code
+    int32 errorCode = 0;
+    OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_TICKCOUNT, errorCode);
+
     struct timeval tv;
 
     static struct timeval stv = {0, 0};
@@ -65,6 +74,7 @@
         clk_val = prev_val;
     }
     prev_val = clk_val;
+    OsclSingletonRegistry::registerInstanceAndUnlock(0, OSCL_SINGLETON_ID_TICKCOUNT, errorCode);
 
     return clk_val;
 
diff --git a/oscl/oscl/osclutil/src/oscl_utf8conv.cpp b/oscl/oscl/osclutil/src/oscl_utf8conv.cpp
index e5f0c60..ba71549 100644
--- a/oscl/oscl/osclutil/src/oscl_utf8conv.cpp
+++ b/oscl/oscl/osclutil/src/oscl_utf8conv.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -81,7 +81,7 @@
 
     if (nDestLen <= 0)
     {
-        // We cannot append terminate string for this case.
+        // We cannot append terminate 0 at this case.
         return 0; /* ERROR_INSUFFICIENT_BUFFER */
     }
 
@@ -171,6 +171,12 @@
     int32 i = 0;
     int32 i_cur_output = 0;
 
+    if (nDestLen <= 0)
+    {
+        // We cannot append terminate 0 at this case.
+        return 0; /* ERROR_INSUFFICIENT_BUFFER */
+    }
+
     unsigned char *pszSrc = (unsigned char *)szSrc;  /* cast to avoid signed/unsigned promomtion problems */
     while (i < nSrcLen)
     {
@@ -185,6 +191,7 @@
             }
             else
             {
+                strDest[i_cur_output] = 0; /* Terminate string */
                 return 0; /* ERROR_INSUFFICIENT_BUFFER */
             }
         }
@@ -198,6 +205,7 @@
             }
             else
             {
+                strDest[i_cur_output] = 0; /* Terminate string */
                 return 0; /* ERROR_INSUFFICIENT_BUFFER */
             }
         }
@@ -210,6 +218,7 @@
             }
             else
             {
+                strDest[i_cur_output] = 0; /* Terminate string */
                 return 0; /* ERROR_INSUFFICIENT_BUFFER */
             }
         }
diff --git a/oscl/oscl/osclutil/src/oscl_utf8conv.h b/oscl/oscl/osclutil/src/oscl_utf8conv.h
index d97fbf7..121bb15 100644
--- a/oscl/oscl/osclutil/src/oscl_utf8conv.h
+++ b/oscl/oscl/osclutil/src/oscl_utf8conv.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
 
 
 /** \file oscl_utf8conv.h
-    \brief Utilities to convert unicode to utf8.
+    \brief Utilities to convert unicode to utf8 and vice versa
 */
 
 
@@ -56,44 +56,54 @@
 #include "oscl_base.h"
 #endif
 
-/**********************************************************************************/
-/*                                                                                */
-/* Function:     oscl_UnicodeToUTF8                                                    */
-/* Description:  Convert UTF8 byte sequence to Unicode string		    	  */
-/*                                                                                */
-/* Parameters:   szSrc - UTF8 byte sequence to be converted			  */
-/*				 nSrcLen - Length of szSrc                        */
-/*               strDest - unicode char buffer for				  */
-/*               nDestLen - size (in characters) of buffer			  */
-/*										  */
-/* Returns:      On success, the number of characters in the destination buffer   */
-/*               0 on failure due to insufficient buffer size			  */
-/*                                                                                */
-/* History:      Created  {DATE]  {BY} {NAME} {PRODUCT REV}                       */
-/*               Modified {DATE]  {BY} {NAME} {PRODUCT REV}                       */
-/*                                                                                */
-/**********************************************************************************/
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Function prototypes
+/*!
+	\brief Convert UTF8 byte sequence to Unicode string
+
+	       The function converts UTF8 byte sequence (or ASCII sequence) to Unicode string.
+		   The length of input UTF8 byte sequence is specified. It stops at two conditions:
+		   (A) Whole input UTF8 byte sequence is successfully converted.
+		   (B) Output buferr is not enough for output, or parse error.
+		   In case of (A), it adds a terminated '\0' at the end of the output Unicode string,
+		   and returns length of the output Unicode string(without counting terminated '\0').
+		   In case of (B), it converts as much as possible to the output buffer and adds a terminated '\0'
+		   at the end of the output Unicode string"(no '\0' added if outLength is less than or
+		   equal to 0, return 0)", and returns 0.
+
+	\param input            Ptr to an input UTF8 byte sequence. '\0' termanation is not neccesary.
+	\param inLength         The length of the input UTF8 byte sequence, without counting terminated '\0'(if any).
+	\param output           Ptr to an output buffer which output Unicode string is written in.
+	\param outLength        The size of output buffer, also the maximum number of oscl_wchar could be written in.
+	\return                 Length of output (excludes '\0') : completely converts all input string and appends '\0' to output;
+	                        0 : insufficient buffer or error in conversion
+*/
 
 OSCL_IMPORT_REF int32 oscl_UTF8ToUnicode(const char *input, int32 inLength, oscl_wchar *output, int32 outLength);
 
 
-/**********************************************************************************/
-/*                                                                                */
-/* Function:     oscl_UnicodeToUTF8                                                    */
-/* Description:  Convert Unicode string to UTF8 byte sequence		    	  */
-/*                                                                                *//*                                                                                */
-/* Parameters:   szSrc - Unicode string to be converted				  */
-/*				 nSrcLen - Length of szSrc                        */
-/*               strDest - char buffer for UTF8 text				  */
-/*               nDestLen - size (in characters) of buffer			  */
-/*										  */
-/* Returns:      On success, the number of bytes in the destination buffer        */
-/*               0 on failure due to insufficient buffer size			  */
-/*                                                                                */
-/* History:      Created  {DATE]  {BY} {NAME} {PRODUCT REV}                       */
-/*               Modified {DATE]  {BY} {NAME} {PRODUCT REV}                       */
-/*                                                                                */
-/**********************************************************************************/
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// Function prototypes
+/*!
+	\brief Convert Unicode string to UTF8 byte sequence
+
+	       The function converts Unicode string to UTF8 byte sequence.
+		   The length of input Unicode string is specified. It stops at two conditions:
+		   (A) Whole input Unicode string is successfully converted.
+		   (B) Destination buferr is not enough for output.
+		   In case of (A), it adds a terminated '\0' at the end of the output UTF8 byte sequence.
+		   and returns length of the output UTF8 byte sequence(without counting terminated '\0').
+		   In case of (B), it converts as much as possible to the output buffer and adds a terminated '\0'
+		   at the end of the output UTF8 byte sequence"(no '\0' added if outLength is less than or
+		   equal to 0, return 0)", and returns 0.
+
+	\param input            Ptr to an input Unicode string. '\0' termanation is not neccesary.
+	\param inLength         The length of the input Unicode string, without counting terminated '\0'(if any).
+	\param output           Ptr to an output buffer which output UTF8 byte sequence is written in.
+	\param outLength        The size of output buffer, also the maximum number of char could be written in.
+	\return	                length of output (excludes '\0') : completely converts all input string and appends '\0' to output;
+	                        0 : insufficient buffer or error in conversion
+*/
 
 OSCL_IMPORT_REF int32 oscl_UnicodeToUTF8(const oscl_wchar *input, int32 inLength, char *output, int32 outLength);
 
diff --git a/oscl/pvlogger/Android.mk b/oscl/pvlogger/Android.mk
index db21ef4..4007cbb 100644
--- a/oscl/pvlogger/Android.mk
+++ b/oscl/pvlogger/Android.mk
@@ -2,31 +2,30 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvlogger.cpp \
-	src/pvlogger_c.cpp
+ 	
 
 
 
-LOCAL_MODULE := libpvlogger
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/pvlogger/src \
-	$(PV_TOP)//oscl/pvlogger/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/pvlogger/src \
+ 	$(PV_TOP)/oscl/pvlogger/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	src/pvlogger.h \
-	src/pvlogger_c.h \
-	src/pvlogger_accessories.h \
 	src/pvlogger_stderr_appender.h \
-	src/pvlogger_file_appender.h \
-	src/pvlogger_mem_appender.h \
-	src/pvlogger_time_and_id_layout.h
+ 	src/pvlogger_file_appender.h \
+ 	src/pvlogger_mem_appender.h \
+ 	src/pvlogger_time_and_id_layout.h
 
-include $(BUILD_STATIC_LIBRARY)
-
+include $(BUILD_COPY_HEADERS)
diff --git a/oscl/pvlogger/build/make/local.mk b/oscl/pvlogger/build/make/local.mk
new file mode 100644
index 0000000..0eb7100
--- /dev/null
+++ b/oscl/pvlogger/build/make/local.mk
@@ -0,0 +1,24 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := 
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+# compose final src list for actual build
+SRCS :=	
+
+HDRS := pvlogger_stderr_appender.h \
+	pvlogger_file_appender.h \
+	pvlogger_mem_appender.h \
+	pvlogger_time_and_id_layout.h
+
+
+include $(MK)/library.mk
+
diff --git a/oscl/pvlogger/build/make/makefile b/oscl/pvlogger/build/make/makefile
deleted file mode 100644
index 16dfc36..0000000
--- a/oscl/pvlogger/build/make/makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvlogger
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	pvlogger.cpp \
-	pvlogger_c.cpp
-
-HDRS =  pvlogger.h \
-		pvlogger_c.h \
-		pvlogger_accessories.h \
-		pvlogger_stderr_appender.h \
-		pvlogger_file_appender.h \
-		pvlogger_mem_appender.h \
-		pvlogger_time_and_id_layout.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/oscl/pvlogger/src/pvlogger.cpp b/oscl/pvlogger/src/pvlogger.cpp
deleted file mode 100644
index edf0124..0000000
--- a/oscl/pvlogger/src/pvlogger.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvlogger.h"
-#include "pvlogger_registry.h"
-#include "pvlogger_accessories.h"
-#include "oscl_dll.h"
-#include "oscl_stdstring.h"
-#include "oscl_error.h"
-
-
-#ifndef OSCL_COMBINED_DLL
-OSCL_DLL_ENTRY_POINT_DEFAULT()
-#endif
-
-#if(PVLOGGER_ENABLE)
-const char rootTag[] = "";
-
-//use the TLS registry, or the singleton registry if no TLS.
-#include "oscl_error.h"
-#define PVLOGGER_REGISTRY OsclTLSRegistryEx
-#define PVLOGGER_REGISTRY_ID OSCL_TLS_ID_PVLOGGER
-#define PVLOGGER_REGISTRY_WRAPPER OsclTLSEx
-
-#endif //PVLOGGER_ENABLE
-
-OSCL_EXPORT_REF void PVLogger::Init()
-{
-#if(PVLOGGER_ENABLE)
-    Oscl_TAlloc<PVLoggerRegistry, alloc_type> talloc;
-    PVLoggerRegistry *pvlogreg = OSCL_ALLOC_NEW(talloc, PVLoggerRegistry, ());
-
-    PVLOGGER_REGISTRY::registerInstance(pvlogreg, PVLOGGER_REGISTRY_ID);
-#endif
-}
-
-OSCL_EXPORT_REF void PVLogger::Cleanup()
-{
-#if(PVLOGGER_ENABLE)
-    PVLoggerRegistry *pvlogreg = OSCL_STATIC_CAST(PVLoggerRegistry*, PVLOGGER_REGISTRY::getInstance(PVLOGGER_REGISTRY_ID));
-
-    Oscl_TAlloc<PVLoggerRegistry, OsclMemAllocator> talloc;
-    OSCL_ALLOC_DELETE(pvlogreg, talloc, PVLoggerRegistry);
-
-    PVLOGGER_REGISTRY::registerInstance(NULL, PVLOGGER_REGISTRY_ID);
-#endif
-}
-
-OSCL_EXPORT_REF PVLogger* PVLogger::GetLoggerObject(const char* inputTag)
-{
-#if(PVLOGGER_ENABLE)
-    return(PVLoggerRegistry::GetPVLoggerRegistry()->GetPVLoggerObject(inputTag));
-#else
-    OSCL_UNUSED_ARG(inputTag);
-    return NULL;
-#endif
-}
-
-OSCL_EXPORT_REF void PVLogger::SetLogLevelAndPropagate(log_level_type level)
-{
-#if(PVLOGGER_ENABLE)
-    _level = level;
-    PVLoggerRegistry::GetPVLoggerRegistry()->SetNodeLogLevelExplicit(_tag, level);
-#else
-    OSCL_UNUSED_ARG(level);
-#endif
-}
-
-OSCL_EXPORT_REF bool PVLogger::IsActive(log_level_type level)
-{
-#if(PVLOGGER_ENABLE)
-    _lastMsgLevel = level;
-
-    if (_level == PVLOGGER_LEVEL_UNINTIALIZED)
-    {
-        if (_parentLogger != NULL)
-        {
-            return(_parentLogger->IsActive(level));
-        }
-        else
-        {
-            /*
-             * We are the root node, as every node other
-             * than root MUST have a parent. If the root's
-             * log level is uninitialized, then we do not
-             * log anything
-             */
-            return false;
-        }
-    }
-    if (level <= _level)
-    {
-        return true;
-    }
-#else
-    OSCL_UNUSED_ARG(level);
-#endif
-    return false;
-}
-
-OSCL_EXPORT_REF void PVLogger::LogMsgStringV(message_id_type msgID, const char * fmt, va_list arguments)
-{
-#if(PVLOGGER_ENABLE)
-    filter_status_type msgStatus = FilterMsg(msgID);
-
-    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
-    {
-        //Log msg to the current node
-        LogMsg(msgID, fmt, arguments);
-    }
-
-    if ((_parentLogger != NULL) && (_oAppenderInheritance))
-    {
-        //Pass the msg to the parent
-        _parentLogger->LogMsgStringV(msgID, fmt, arguments);
-    }
-#else
-    OSCL_UNUSED_ARG(msgID);
-    OSCL_UNUSED_ARG(fmt);
-    OSCL_UNUSED_ARG(arguments);
-#endif
-    return;
-}
-
-OSCL_EXPORT_REF void PVLogger::LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments)
-{
-#if(PVLOGGER_ENABLE)
-    filter_status_type msgStatus = FilterMsg(msgID);
-
-    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
-    {
-        //Log msg to the current node
-        LogMsg(msgID, numPairs, arguments);
-    }
-
-    if ((_parentLogger != NULL) && (_oAppenderInheritance))
-    {
-        //Pass the msg to the parent
-        _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);
-
-    }
-#else
-    OSCL_UNUSED_ARG(msgID);
-    OSCL_UNUSED_ARG(numPairs);
-    OSCL_UNUSED_ARG(arguments);
-#endif
-    return;
-}
-
-OSCL_EXPORT_REF void PVLogger::LogMsgString(message_id_type msgID, const char * fmt, ...)
-{
-#if(PVLOGGER_ENABLE)
-    va_list arguments;
-    va_start(arguments, fmt);
-
-    filter_status_type msgStatus = FilterMsg(msgID);
-
-    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
-    {
-        LogMsg(msgID, fmt, arguments);
-    }
-
-    if ((_parentLogger != NULL) && (_oAppenderInheritance))
-    {
-        //Pass the msg to the parent
-        _parentLogger->LogMsgStringV(msgID, fmt, arguments);
-    }
-#else
-    OSCL_UNUSED_ARG(msgID);
-    OSCL_UNUSED_ARG(fmt);
-#endif
-    return;
-}
-
-OSCL_EXPORT_REF void PVLogger::LogMsgBuffers(message_id_type msgID, int32 numPairs, ...)
-{
-#if(PVLOGGER_ENABLE)
-    va_list arguments;
-    va_start(arguments, numPairs);
-
-    filter_status_type msgStatus = FilterMsg(msgID);
-
-    if (msgStatus == PVLOGGER_FILTER_ACCEPT)
-    {
-        LogMsg(msgID, numPairs, arguments);
-    }
-
-    if ((_parentLogger != NULL) && (_oAppenderInheritance))
-    {
-        //Pass the msg to the parent
-        _parentLogger->LogMsgBuffersV(msgID, numPairs, arguments);
-    }
-#else
-    OSCL_UNUSED_ARG(msgID);
-    OSCL_UNUSED_ARG(numPairs);
-#endif
-    return;
-}
-
-OSCL_EXPORT_REF PVLogger::PVLogger(const char* inputTag, log_level_type level, bool oAppenderInheritance)
-{
-#if(PVLOGGER_ENABLE)
-    _tag = _tagAllocator.ALLOCATE(oscl_strlen(inputTag) + 1);
-
-    oscl_strncpy(_tag, inputTag, (oscl_strlen(inputTag) + 1));
-
-    _parentLogger = NULL;
-    _oAppenderInheritance = oAppenderInheritance;
-    _level = level;
-    _lastMsgLevel = PVLOGGER_LEVEL_UNINTIALIZED;
-#else
-    OSCL_UNUSED_ARG(inputTag);
-    OSCL_UNUSED_ARG(level);
-    OSCL_UNUSED_ARG(oAppenderInheritance);
-#endif
-    return;
-}
-
-#if(PVLOGGER_ENABLE)
-PVLogger::filter_status_type PVLogger::FilterMsg(message_id_type msgID)
-{
-    uint32 j;
-
-    if (_pMsgFilterVec.size() > 0)
-    {
-        for (j = 0; j < _pMsgFilterVec.size(); j++)
-        {
-            PVLoggerFilter *msgFilter = _pMsgFilterVec[j];
-
-            filter_status_type msgStatus = msgFilter->FilterString(_tag, msgID, _level);
-
-            if (msgStatus != PVLOGGER_FILTER_NEUTRAL)
-            {
-                return msgStatus;
-            }
-        }
-    }
-    /*
-     * Either All filters returned neutral => Accept msg
-     * or No msg filters => All msgs accepted by default
-     */
-    return(PVLOGGER_FILTER_ACCEPT);
-}
-
-void PVLogger::LogMsg(message_id_type msgID, const char *fmt, va_list arguments)
-{
-    uint32 i;
-
-    for (i = 0; i < _pOwnAppenderVec.size(); i++)
-    {
-        PVLoggerAppender *appender = _pOwnAppenderVec[i];
-        appender->AppendString(msgID, fmt, arguments);
-    }
-    return;
-}
-
-void PVLogger::LogMsg(message_id_type msgID, int32 numPairs, va_list arguments)
-{
-    uint32 i;
-
-    for (i = 0; i < _pOwnAppenderVec.size(); i++)
-    {
-        PVLoggerAppender *appender = _pOwnAppenderVec[i];
-        appender->AppendBuffers(msgID, numPairs, arguments);
-    }
-    return;
-}
-#endif //PVLOGGER_ENABLE
-
-OSCL_EXPORT_REF PVLoggerRegistry* PVLoggerRegistry::GetPVLoggerRegistry()
-{
-#if(PVLOGGER_ENABLE)
-    PVLOGGER_REGISTRY_WRAPPER< PVLoggerRegistry, PVLOGGER_REGISTRY_ID > pvLogRegSng;
-    return &(*pvLogRegSng);
-#else
-    return NULL;
-#endif
-}
-
-
-OSCL_EXPORT_REF PVLoggerRegistry::PVLoggerRegistry()
-{
-#if(PVLOGGER_ENABLE)
-    /*
-     * Create the root logger node, by default turn off logging
-     * for the root node
-     */
-    PVLogger *logger = OSCL_ALLOC_NEW(_pvloggerAlloc, PVLogger, (rootTag, PVLOGGER_LEVEL_UNINTIALIZED, true));
-
-    // add logger to the tag tree
-    _loggerTree[OSCL_CONST_CAST(char*,(rootTag))] = logger;
-#endif
-};
-
-OSCL_EXPORT_REF PVLoggerRegistry::~PVLoggerRegistry()
-{
-#if(PVLOGGER_ENABLE)
-    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter;
-
-    for (iter = _loggerTree.begin();
-            iter != _loggerTree.end(); iter++)
-    {
-        PVLogger* logger = iter->value;
-        OSCL_ALLOC_DELETE(logger, _pvloggerAlloc, PVLogger);
-    }
-#endif
-}
-
-OSCL_EXPORT_REF PVLogger *PVLoggerRegistry::GetPVLoggerObject(const char* tagIn)
-{
-#if(PVLOGGER_ENABLE)
-    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter =
-        _loggerTree.find(OSCL_CONST_CAST(char*, (tagIn)));
-
-    if (iter != _loggerTree.end())
-    {
-        PVLogger* logger = iter->value;
-        return(logger);
-    }
-    else
-    {
-        /* creates a new logger object */
-        PVLogger *logger = NULL;
-        int32 leave_code = 0;
-        OSCL_TRY(leave_code, logger = CreatePVLogger(tagIn, PVLOGGER_LEVEL_UNINTIALIZED, true));
-        OSCL_FIRST_CATCH_ANY(leave_code, logger = NULL);
-
-        return(logger);
-    }
-#else
-    OSCL_UNUSED_ARG(tagIn);
-    return NULL;
-#endif
-}
-
-OSCL_EXPORT_REF PVLogger *PVLoggerRegistry::CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance)
-{
-#if(PVLOGGER_ENABLE)
-    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter;
-
-    /* If the input tag already exists in the tagtree, it should have a pointer value of NULL */
-    OSCL_ASSERT((_loggerTree.find(OSCL_CONST_CAST(char* const&, (tagIn))) == _loggerTree.end()) ||
-                (_loggerTree.find(OSCL_CONST_CAST(char* const&, (tagIn))))->value == 0);
-
-    PVLogger *logger = OSCL_ALLOC_NEW(_pvloggerAlloc, PVLogger, (tagIn, level, oAppenderInheritance));
-
-    // add logger to the tag tree
-    _loggerTree[OSCL_CONST_CAST(char*,(tagIn))] = logger;
-
-    // how many levels deep is the node we just inserted?
-    iter = _loggerTree.find(OSCL_CONST_CAST(char*, (tagIn)));
-    uint32 depth = iter->depth();
-
-    // the tag tree will automatically create the parent, grandparent, etc.
-    // make sure each ancestor's stats node is initialized, i.e. initialize each ancestor
-    // until you reach one that is already initialized.
-    Oscl_TagTree<PVLogger*, alloc_type>::node_ptr parent = iter->parent;
-
-    uint32 ii = 0;
-
-    for (ii = 0; ii < depth; ii++)
-    {
-        OSCL_ASSERT(parent != 0);
-
-        // if initialized then we're done
-        PVLogger* tmpPVLoggerNode = parent->value;
-
-        if (tmpPVLoggerNode != NULL)
-        {
-            break;
-        }
-
-        // create new Logger node, for tag use the tag created
-        // by the tag tree, for level use PV_LOG_LEVEL_UNINTIALIZED
-        // for oAppenderInheritance use true
-        tmpPVLoggerNode = OSCL_ALLOC_NEW(_pvloggerAlloc, PVLogger, (parent->tag.tag, PVLOGGER_LEVEL_UNINTIALIZED, true));
-
-        // Add logger to tag tree
-        parent->value = tmpPVLoggerNode;
-
-        parent = parent->parent;
-    }
-
-    //Inherit the log level for the newly created node.
-    logger->SetLogLevel(level);
-
-    parent = iter->parent;
-    OSCL_ASSERT(parent != NULL);
-    //Set the parent of the newly created node
-    logger->SetParent(parent->value);
-
-    //Set the parent of the other nodes up the tree
-    for (ii = 0; ii < depth - 1; ii++)
-    {
-
-        PVLogger* tmpPVLoggerNode = parent->value;
-
-        parent = parent->parent;
-        OSCL_ASSERT(parent != NULL);
-
-        //Set the parent for the node
-        tmpPVLoggerNode->SetParent(parent->value);
-
-    }
-
-    return(logger);
-#else
-    OSCL_UNUSED_ARG(tagIn);
-    OSCL_UNUSED_ARG(level);
-    OSCL_UNUSED_ARG(oAppenderInheritance);
-    return NULL;
-#endif
-};
-
-OSCL_EXPORT_REF bool PVLoggerRegistry::SetNodeLogLevelExplicit(char* tagIn,
-        log_level_type level)
-{
-#if(PVLOGGER_ENABLE)
-    Oscl_TagTree<PVLogger*, alloc_type>::iterator iter;
-
-    iter = _loggerTree.find(tagIn);
-
-    if (iter != _loggerTree.end())
-    {
-        Oscl_TagTree<PVLogger*, alloc_type>::node_type* currNode = &(*iter);
-
-        SetNodeLogLevelExplicit(currNode, level);
-
-        return true;
-    }
-#else
-    OSCL_UNUSED_ARG(tagIn);
-    OSCL_UNUSED_ARG(level);
-#endif
-    return false;
-
-}
-
-OSCL_EXPORT_REF void PVLoggerRegistry::SetNodeLogLevelExplicit(Oscl_TagTree<PVLogger*, alloc_type>::node_type* node,
-        log_level_type level)
-{
-#if(PVLOGGER_ENABLE)
-    uint32 num_children = node->children.size();
-
-    for (uint32 i = 0; i < num_children; i++)
-    {
-        Oscl_TagTree<PVLogger*, alloc_type>::node_ptr child = (node->children)[i];
-
-        PVLogger* tmpPVLoggerNode = child->value;
-        tmpPVLoggerNode->SetLogLevel(level);
-        SetNodeLogLevelExplicit(child, level);
-    }
-#else
-    OSCL_UNUSED_ARG(node);
-    OSCL_UNUSED_ARG(level);
-#endif
-};
diff --git a/oscl/pvlogger/src/pvlogger.h b/oscl/pvlogger/src/pvlogger.h
deleted file mode 100644
index a0cf691..0000000
--- a/oscl/pvlogger/src/pvlogger.h
+++ /dev/null
@@ -1,726 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-/*! \file pvlogger.h
-    \brief This file contains basic logger interfaces for common use across platforms.
-
-    This is the main entry point header file for the logger library.  It should be
-    the only one users directly include.
-*/
-
-#ifndef PVLOGGER_H_INCLUDED
-#define PVLOGGER_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef OSCL_VECTOR_H_INCLUDED
-#include "oscl_vector.h"
-#endif
-
-#ifndef OSCL_DEFALLOC_H_INCLUDED
-#include "oscl_defalloc.h"
-#endif
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-#ifndef OSCL_SHARED_PTR_H
-#include "oscl_shared_ptr.h"
-#endif
-
-
-const int32 PVLOGGER_LEVEL_UNINTIALIZED = -1;
-
-
-
-////////////////////////////////////////////
-// The instrumentation layer allows groups
-// of messages to be compiled in or out of
-// the code based on a build-time parameter.
-/////////////////////////////////////////////
-
-/**
- * Release Layer
- *
- * The release layer should only be used for messages that
- * should remain in the final release. In certain cases all
- * messaging may be disabled depending on customer requirements.
- * However, when allowed the release layer should contain
- * information that will be useful diagnosing problems in a
- * released product (perhaps after entering a diagnostic mode),
- * but with absolutely minimal performance impact when disabled
- * at runtime.
- */
-#define PVLOGMSG_INST_REL   0
-/**
- * Profile Layer
- *
- * The profile layer is used for messages and information
- * related to messuring and reporting performance-related
- * information.
- */
-#define PVLOGMSG_INST_PROF  1
-/**
- * High Level Debug Layer
- *
- * This layer should contain messages that have very minimal
- * impact on performance, but are at lower level (i.e., provide
- * more information) than would be appropriate in a shipping
- * product. The messages are probably used to gather information
- * and validate proper functionality at a high level as might
- * be appropriate for IOT, stress testing, or QA testing.
- */
-#define PVLOGMSG_INST_HLDBG 2
-/**
- * Mid Level Debug Layer
- *
- * This layer should contain messages that are useful in the
- * middle stages of the development cycle where major components
- * are being integrated. The components themselves should
- * already be well-tested so the emphasis is on interfaces
- * between these components and integration testing. Messages
- * at this layer may have some performance impact.
- */
-#define PVLOGMSG_INST_MLDBG 3
-/**
- * Low Level Debug Layer
- *
- * This layer should contain messages for early functional
- * testing. The messages are typically at a very low-level
- * and allow testing the functionality of individual modules
- * and components. Messages at this layer will typically have
- * a performance impact (sometimes significant) due to the
- * fact that they are at such a low level.
- */
-#define PVLOGMSG_INST_LLDBG 4
-
-/*
-** Default logger instrumentation level.  To override this
-** setting, define PVLOGGER_INST_LEVEL in the osclconfig.h file.
-** Possible values and the resulting intrumentation:
-**
-**  PVLOGGER_INST_LEVEL 0 : No logging.  All logging statements compiled out.
-**  PVLOGGER_INST_LEVEL 1 : Release level only.
-**  PVLOGGER_INST_LEVEL 2 : Release level + profile level
-**  PVLOGGER_INST_LEVEL 3 : Release level + profile level + high-level debug
-**  PVLOGGER_INST_LEVEL 4 : Release level + profile level + high-level debug + mid-level debug
-**  PVLOGGER_INST_LEVEL 5 & above : Release level + profile level + high-level debug
-**                            + mid-level debug + low-level debug
-*/
-#ifndef PVLOGGER_INST_LEVEL
-#if defined(NDEBUG)
-/* Release mode-- No logging */
-#define PVLOGGER_INST_LEVEL 0
-#else
-/* Debug mode-- Complete logging */
-#define PVLOGGER_INST_LEVEL 5
-#endif
-#endif
-
-
-#if (PVLOGGER_INST_LEVEL<1)
-
-/*
-** Disable and compile-out all logging
-*/
-#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOG_USE_ONLY(x)
-
-#else //PVLOGGER_INST_LEVEL
-
-/*
-** Internal use macros that make the logging calls to PVLogger.
-*/
-#define _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)\
-{\
-    if (LOGGER)\
-    {\
-        if (LOGGER->IsActive(LEVEL))\
-        {\
-            LOGGER->LogMsgString MESSAGE;\
-        }\
-    }\
-}
-
-#define _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)\
-{\
-    if (LOGGER)\
-    {\
-        if (LOGGER->IsActive(LEVEL))\
-        {\
-            LOGGER->LogMsgStringV MESSAGE;\
-        }\
-    }\
-}
-
-#define _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE) \
-{\
-    if (LOGGER)\
-    {\
-    	if (LOGGER->IsActive(LEVEL))\
-    	{\
-    		LOGGER->LogMsgBuffers MESSAGE;\
-    	}\
-    }\
-}
-
-#define _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE) \
-{\
-    if (LOGGER)\
-    {\
-    	if (LOGGER->IsActive(LEVEL))\
-    	{\
-    		LOGGER->LogMsgBuffersV MESSAGE;\
-    	}\
-    }\
-}
-
-/*
-** In case some compilers cannot support the instrumentation-level macros,
-** they can be disabled by defining PVLOGGER_INST_LEVEL_SUPPORT to 0
-** in their osclconfig.h.  If instrumentation level is not supported, then
-** all instrumentation levels will be compiled in.
-**
-** If PVLOGGER_INST_LEVEL_SUPPORT is not defined, the default is set here to allow
-** compile-time instrumentation level support.
-*/
-#ifndef PVLOGGER_INST_LEVEL_SUPPORT
-#define PVLOGGER_INST_LEVEL_SUPPORT 1
-#endif
-
-#if !(PVLOGGER_INST_LEVEL_SUPPORT)
-
-/*
-** A set of logging macros that ignore the instrumentation level.
-** All instrumentation levels will be compiled in.
-*/
-#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
-
-#else //PVLOGGER_INST_LEVEL_SUPPORT
-
-/*
-** This set of macros compiles the logging statements in or out based on the instrumtation
-** level.
-*/
-
-#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_REL)
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
-#else
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_REL(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#endif
-
-#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_PROF)
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
-#else
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_PROF(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#endif
-
-#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_HLDBG)
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
-#else
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_HLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#endif
-
-#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_MLDBG)
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_V_INST_MLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
-#else
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_V_INST_MLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#endif
-
-#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGMSG_V(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN(LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) _PVLOGGER_LOGBIN_V(LOGGER, LEVEL, MESSAGE)
-#else
-#define PVLOGGER_LOGMSG_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGMSG_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#define PVLOGGER_LOGBIN_V_PVLOGMSG_INST_LLDBG(LOGGER, LEVEL, MESSAGE) OSCL_UNUSED_ARG(LOGGER);
-#endif
-
-
-/**
- * This is the text based API to log messages
- *
- * @param IL		Instrumentation level.
- * @param LOGGER	Pointer to the logger object, that acts as the logging
- *					control/interface point
- * @param LEVEL		Log level of the message
- * @param MESSAGE	Log Message which includes the message id, and any kind
- *					of formatting information
- *
- * Example Usage:
- * PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger_1, PVLOGMSG_WARNING, (13, "Test Messsage to Node 1\n"));
- *	-This message of log level PVLOGMSG_WARNING, and has a message id of 13
- */
-#define PVLOGGER_LOGMSG(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGMSG_ ## IL (LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGMSG_V(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGMSG_V_ ## IL (LOGGER, LEVEL, MESSAGE)
-
-/**
- * This is a binary API to log messages
- *
- * @param IL		Instrumentation level.
- * @param LOGGER	Pointer to the logger object, that acts as the logging
- *					control/interface point
- * @param LEVEL		Log level of the message
- * @param MESSAGE	Log Message which includes the message id, and message
- *                  buffers that need to be logged.
- *
- * Example Usage:
- * PVLOGGER_LOGBIN (PVLOGMSG_INST_LLDBG, logger_1, PVLOGMSG_WARNING, (10, 3, msgBuf1Size, msgBuf1,
- *                                                            msgBuf2Size, msgBuf2,
- *											                  msgBuf3Size, msgBuf3));
- *
- *	-This message contains THREE (ptr_len, ptr) pairs.
- *   Log level of this msg is PVLOGMSG_WARNING,
- *   message id is 10.
- */
-#define PVLOGGER_LOGBIN(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGBIN_ ## IL (LOGGER, LEVEL, MESSAGE)
-#define PVLOGGER_LOGBIN_V(IL, LOGGER, LEVEL, MESSAGE) PVLOGGER_LOGBIN_V_ ## IL (LOGGER, LEVEL, MESSAGE)
-
-#endif //PVLOGGER_INST_LEVEL_SUPPORT
-
-/**
- * Used to compile in/out lines of code that are used only
- * for PVLogger macros.
- *
- * This code will be removed at compile time when PVLogger
- * is disabled, i.e. Release mode.  So do not put in any
- * code that is necessary for correct functionality of the module
- */
-#define PVLOGGER_LOG_USE_ONLY(x) x
-
-#endif // PVLOGGER_INST_LEVEL
-
-/**
- * In case logging is compiled out, there is no need to compile
- * the logger runtime code either.
- */
-#ifndef PVLOGGER_ENABLE
-#if (PVLOGGER_INST_LEVEL<1)
-#define PVLOGGER_ENABLE 0
-#else
-#define PVLOGGER_ENABLE 1
-#endif
-#endif
-
-/**
- * Class: PVLogger
- *
- * Each logger instance is associated with a unique tag. PVLoggerRegistry
- * class, maintains a repository of all the loggers, along with their
- * associated tags. Each logger has an associated list of appenders. Appenders
- * are entities that act as a sink for all the incoming messages. They could be
- * file appenders, serial port appenders, buffer appenders etc. Each logger
- * also has a list of message filters. These filters remove any unwanted messages
- * from the output.
- */
-class PVLoggerAppender;
-class PVLoggerFilter;
-class PVLogger
-{
-    public:
-
-        typedef int32 log_level_type;
-        typedef int32 message_id_type;
-        typedef int32 filter_status_type;
-        typedef OsclMemAllocator alloc_type;
-
-        /**
-         * PVLogger needs to be initialized once per thread.  This
-         * creates the PVLogger singleton that is used throughout
-         * the duration of the thread.  Initialization must occur
-         * before the first message is logged.
-         *
-         * @exception leaves if out of memory
-         */
-        OSCL_IMPORT_REF static void Init();
-
-
-        /**
-         * Frees the PVLogger singleton used by the current thread.
-         * This must be called before thread exit.  No messages
-         * can be logged after cleanup.
-         *
-         * @return
-         */
-        OSCL_IMPORT_REF static void Cleanup();
-
-        /**
-         * This is a factory method to create a log control point, with a
-         * certain input tag. There is a central registry of all the loggers,
-         * with their corresponding tags, called PV Logger Registry. In case
-         * the logger with the specified tag exists in the global registry, it
-         * is returned, else a new one is created and a pointer to the same is
-         * returend.
-         *
-         * @param inputTag   logger tag, viz. "x.y.z"
-         * @param level      log level associated with the logging control point
-         *                   (All messages with log levels less than equal to the
-         *                    log level of the control point would be logged)
-         *
-         * @param oAppenderInheritance
-         *
-         * @return PVLogger* Pointer to the logging control point
-         *
-         * @exception leaves if out of memory
-         */
-
-        OSCL_IMPORT_REF static PVLogger *GetLoggerObject(const char* inputTag);
-
-        /**
-         * This method is used to set the log level of a control point.
-         *
-         * @param level      log level associated with the logging control point
-         *
-         * @return           NONE
-         */
-        void SetLogLevel(log_level_type level)
-        {
-#if(PVLOGGER_ENABLE)
-            _level = level;
-#else
-            OSCL_UNUSED_ARG(level);
-#endif
-        }
-
-        /**
-         * This method is used to set the log level of a control point, as well as
-         * to propagate the level to all the descendants of this control point.
-         *
-         * @param level      log level associated with the logging control point
-         *
-         * @return           NONE
-         */
-        OSCL_IMPORT_REF void SetLogLevelAndPropagate(log_level_type level);
-
-        /**
-         * This method returns the log level of a control point. This could either
-         * have been set explicitly by the user (at the time of creation or later)
-         * or could have been inherited from one of its ancestors.
-         *
-         * @return           log level associated with the logging control point
-         */
-        log_level_type GetLogLevel()
-        {
-#if(PVLOGGER_ENABLE)
-            return(_level);
-#else
-            return 0;
-#endif
-        }
-
-        /**
-         * This method disables appender inheritance for the logging control point
-         *
-         */
-        void DisableAppenderInheritance()
-        {
-#if(PVLOGGER_ENABLE)
-            _oAppenderInheritance = false;
-#endif
-        }
-
-        /**
-         * This method adds an appender to the logging control point. Each logger
-         * maintains a list of appenders. Any msg to a logger if deemed active is
-         * logged to all the appenders.
-         *
-         * @param appender   pointer to the appender to add
-         *
-         * @return           NONE
-         *
-         * @exception        leaves if out of memory
-         */
-        void AddAppender(OsclSharedPtr<PVLoggerAppender> &appender)
-        {
-#if(PVLOGGER_ENABLE)
-            int32 leave_code = 0;
-            OSCL_TRY(leave_code, _pOwnAppenderVec.push_back(appender));
-#else
-            OSCL_UNUSED_ARG(appender);
-#endif
-        }
-
-        /**
-         * This method removes an appender from the logging control point. Each logger
-         * maintains a list of appenders. Any msg to a logger if deemed active is
-         * logged to all the appenders.
-         *
-         * @param appender   pointer to the appender to delete
-         *
-         * @return           NONE
-         */
-        void RemoveAppender(OsclSharedPtr<PVLoggerAppender> &appender)
-        {
-#if(PVLOGGER_ENABLE)
-            for (Oscl_Vector<OsclSharedPtr<PVLoggerAppender>, alloc_type>::iterator it = _pOwnAppenderVec.begin();
-                    it != _pOwnAppenderVec.end();
-                    it++)
-            {
-                if ((*it).GetRep() == appender.GetRep())
-                {
-                    _pOwnAppenderVec.erase(it);
-                    break;
-                }
-            }
-#else
-            OSCL_UNUSED_ARG(appender);
-#endif
-        }
-
-        /**
-         * This method adds a message filter to the logging control point. Each logger
-         * maintains a list of filters. Any msg to a logger if deemed active is
-         * passed through the msg filters prior to logging.
-         *
-         * @param msgFilter   pointer to the filter to add
-         *
-         * @return           NONE
-         *
-         * @exception        leaves if out of memory
-         */
-        void AddFilter(OsclSharedPtr<PVLoggerFilter> &filter)
-        {
-#if(PVLOGGER_ENABLE)
-            int32 leave_code = 0;
-            OSCL_TRY(leave_code, _pMsgFilterVec.push_back(filter));
-#else
-            OSCL_UNUSED_ARG(filter);
-#endif
-        };
-
-        /**
-         * This method returns the number of appenders attached to the logging control point.
-         */
-        uint32 GetNumAppenders()
-        {
-#if(PVLOGGER_ENABLE)
-            return(_pOwnAppenderVec.size());
-#else
-            return 0;
-#endif
-        }
-
-        /**
-         * This method determines if a msg passed to the logging control point is active
-         * or not. Only messages that are deemed active are logged. Messages are considered
-         * not active if any of the following criteria are met:
-         *		- All logging is disabled at this logging control point
-         *      - If all the log levels, leading upto the root log point are uninitialized
-         *      - If the log level of the incoming message is LESS THAN that of the active
-         *        log level of the logging control point.
-         *
-         * @return           BOOL
-         */
-        OSCL_IMPORT_REF bool IsActive(log_level_type level);
-
-        /**
-         * This method logs formatted text msg to all the appenders, after running thrrough
-         * the message filters. After logging the message to the appenders attached to the
-         * current control point, the message is passed up to the parent node, only if
-         * appender inheritance is enabled.
-         *
-         *
-         * @param msgID      Message ID, that is unique to a message
-         * @param fmt        format string, similar to one taken by printf
-         * @param arguments  Variable list of arguments
-         *
-         * @return           NONE
-         */
-        OSCL_IMPORT_REF void LogMsgStringV(message_id_type msgID, const char * fmt, va_list arguments);
-
-        /**
-         * This method logs opaque data buffers to all the appenders, after running thrrough
-         * the message filters. After logging the message to the appenders attached to the
-         * current control point, the message is passed up to the parent node, only if
-         * appender inheritance is enabled.
-         *
-         *
-         * @param msgID      Message ID, that is unique to a message
-         * @param numPairs   Number of (ptr_len, ptr) pairs
-         * @param arguments  Variable list of arguments
-         *
-         * @return           NONE
-         */
-        OSCL_IMPORT_REF void LogMsgBuffersV(message_id_type msgID, int32 numPairs, va_list arguments);
-
-        /**
-         * This method logs formatted text msg to all the appenders, after running thrrough
-         * the message filters. After logging the message to the appenders attached to the
-         * current control point, the message is passed up to the parent node, only if
-         * appender inheritance is enabled.
-         *
-         *
-         * @param msgID      Message ID, that is unique to a message
-         * @param fmt        format string, similar to one taken by printf
-         * @param arguments  Variable list of arguments
-         *
-         * @return           NONE
-         */
-        OSCL_IMPORT_REF void LogMsgString(message_id_type msgID, const char * fmt, ...);
-
-        /**
-         * This method logs opaque data buffers to all the appenders, after running thrrough
-         * the message filters. After logging the message to the appenders attached to the
-         * current control point, the message is passed up to the parent node, only if
-         * appender inheritance is enabled.
-         *
-         *
-         * @param msgID      Message ID, that is unique to a message
-         * @param numPairs   Number of (ptr_len, ptr) pairs
-         * @param arguments  Variable list of arguments
-         *
-         * @return           NONE
-         */
-        OSCL_IMPORT_REF void LogMsgBuffers(message_id_type msgID, int32 numPairs, ...);
-
-        /**
-         * Logger Constructor
-         *
-         *
-         * @param tag                     Logger tag, unique to a logging control point
-         * @param level                   Active Log level of the logger
-         * @param oAppenderInheritance
-         *
-         * @return                        NONE
-         */
-        OSCL_IMPORT_REF PVLogger(const char* inputTag, log_level_type level, bool oAppenderInheritance);
-
-        virtual ~PVLogger()
-        {
-#if(PVLOGGER_ENABLE)
-            _tagAllocator.deallocate(_tag);
-#endif
-        }
-
-#if(PVLOGGER_ENABLE)
-    protected:
-        friend class PVLoggerRegistry;
-        void SetParent(PVLogger *parentLogger)
-        {
-            _parentLogger = parentLogger;
-        }
-        PVLogger *GetParent()
-        {
-            return(_parentLogger);
-        }
-
-    private:
-        filter_status_type FilterMsg(message_id_type msgID);
-        void LogMsg(message_id_type msgID, const char *fmt, va_list arguments);
-        void LogMsg(message_id_type msgID, int32 numPairs, va_list arguments);
-
-        char* _tag;
-        log_level_type _level;
-        log_level_type _lastMsgLevel;
-        bool _oAppenderInheritance;
-
-        PVLogger *_parentLogger;
-        Oscl_TAlloc<char, alloc_type> _tagAllocator;
-
-        Oscl_Vector<OsclSharedPtr<PVLoggerFilter>, alloc_type> _pMsgFilterVec;
-        Oscl_Vector<OsclSharedPtr<PVLoggerAppender>, alloc_type>  _pOwnAppenderVec;
-#endif //PVLOGGER_ENABLE
-};
-
-//////////////////////////////////////
-// log message levels
-//////////////////////////////////////
-
-/**
- * system is unusable
- */
-const PVLogger::log_level_type PVLOGMSG_EMERG   = 0;
-/**
- * action must be taken immediately
- */
-const PVLogger::log_level_type PVLOGMSG_ALERT   = 1;
-/**
- * critical conditions
- */
-const PVLogger::log_level_type PVLOGMSG_CRIT    = 2;
-/**
- * error conditions
- */
-const PVLogger::log_level_type PVLOGMSG_ERR     = 3;
-/**
- * warning conditions
- */
-const PVLogger::log_level_type PVLOGMSG_WARNING = 4;
-/**
- * normal but significant condition
- */
-const PVLogger::log_level_type PVLOGMSG_NOTICE  = 5;
-/**
- * informational
- */
-const PVLogger::log_level_type PVLOGMSG_INFO    = 6;
-/**
- * function enter and exit
- */
-const PVLogger::log_level_type PVLOGMSG_STACK_TRACE = 7;
-/**
- * debug-level messages
- */
-const PVLogger::log_level_type PVLOGMSG_DEBUG   = 8;
-
-///////////////////////////////////
-// do not use these levels
-// for backward compatibility only
-///////////////////////////////////
-const PVLogger::log_level_type PVLOGMSG_FATAL_ERROR    = PVLOGMSG_EMERG;
-const PVLogger::log_level_type PVLOGMSG_NONFATAL_ERROR = PVLOGMSG_ERR;
-const PVLogger::log_level_type PVLOGMSG_STATISTIC      = PVLOGMSG_INFO;
-const PVLogger::log_level_type PVLOGMSG_VERBOSE        = PVLOGMSG_DEBUG;
-
-#endif // PVLOGGER_H_INCLUDED
diff --git a/oscl/pvlogger/src/pvlogger_accessories.h b/oscl/pvlogger/src/pvlogger_accessories.h
deleted file mode 100644
index 5b8bbd2..0000000
--- a/oscl/pvlogger/src/pvlogger_accessories.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVLOGGER_ACCESSORIES_H_INCLUDED
-#define PVLOGGER_ACCESSORIES_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-/**
- * Base class for all message formatters. This class defines the interface to
- * the message formatter. There are two kinds of msg formatting APIs, one to
- * format text messages, and other to format opaque message buffers.
- */
-class PVLoggerLayout
-{
-    public:
-        typedef PVLogger::message_id_type message_id_type;
-
-        virtual ~PVLoggerLayout() {}
-
-        /**
-         * Formats the string and copies it to the given buffer.
-         *
-         * @return The length of the string not including the trailing '\0'
-         */
-        virtual int32 FormatString(char* formatBuf, int32 formatBufSize,
-                                   message_id_type msgID, const char * fmt,
-                                   va_list va) = 0;
-
-        /**
-         * Formats the data and copies it to the given buffer.
-         *
-         * @return The length of the buffer used.
-         */
-        virtual int32 FormatOpaqueMessage(char* formatBuf, int32 formatBufSize,
-                                          message_id_type msgID, int32 numPairs,
-                                          va_list va) = 0;
-};
-
-/**
- * Base class for all message filters. This class defines the interface to
- * the message filters. There are two kinds of msg filtering APIs, one to
- * filter text messages, and other to filter opaque message buffers.
- */
-class PVLoggerFilter
-{
-    public:
-        virtual ~PVLoggerFilter() {}
-
-        typedef PVLogger::message_id_type message_id_type;
-        typedef PVLogger::log_level_type log_level_type;
-        typedef PVLogger::filter_status_type filter_status_type;
-
-        virtual filter_status_type FilterString(char* tag, message_id_type msgID, log_level_type level) = 0;
-        virtual filter_status_type FilterOpaqueMessge(char* tag, message_id_type msgID, log_level_type level) = 0;
-};
-
-const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_ACCEPT = 1;
-const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_REJECT = 2;
-const PVLoggerFilter::filter_status_type PVLOGGER_FILTER_NEUTRAL = 3;
-
-/**
- * Example filter that allows all messages to be logged.
- */
-class AllPassFilter : public PVLoggerFilter
-{
-    public:
-        typedef PVLoggerFilter::message_id_type message_id_type;
-        typedef PVLoggerFilter::log_level_type log_level_type;
-        typedef PVLoggerFilter::filter_status_type filter_status_type;
-
-        AllPassFilter() {};
-        virtual ~AllPassFilter() {};
-
-        filter_status_type FilterString(char* tag, message_id_type msgID, log_level_type level)
-        {
-            OSCL_UNUSED_ARG(tag);
-            OSCL_UNUSED_ARG(msgID);
-            OSCL_UNUSED_ARG(level);
-            return (PVLOGGER_FILTER_ACCEPT);
-        };
-        filter_status_type FilterOpaqueMessge(char* tag, message_id_type msgID, log_level_type level)
-        {
-            OSCL_UNUSED_ARG(tag);
-            OSCL_UNUSED_ARG(msgID);
-            OSCL_UNUSED_ARG(level);
-            return (PVLOGGER_FILTER_ACCEPT);
-        };
-};
-
-/**
- * Base class for all message appenders. This class defines the interface to
- * the message appenders. There are two kinds of msg appender APIs, one to
- * append text messages, and other to append opaque message buffers.
- */
-class PVLoggerAppender
-{
-    public:
-        typedef PVLogger::message_id_type message_id_type;
-
-        virtual ~PVLoggerAppender() {}
-
-        virtual void AppendString(message_id_type msgID, const char *fmt, va_list va) = 0;
-        virtual void AppendBuffers(message_id_type msgID, int32 numPairs, va_list va) = 0;
-};
-
-
-#endif
-
diff --git a/oscl/pvlogger/src/pvlogger_c.cpp b/oscl/pvlogger/src/pvlogger_c.cpp
deleted file mode 100644
index d515609..0000000
--- a/oscl/pvlogger/src/pvlogger_c.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-#include "pvlogger.h"
-#include "pvlogger_c.h"
-
-
-
-//C-callable version of PVLogger::GetLoggerObject
-OSCL_EXPORT_REF void* pvLogger_GetLoggerObject(const char* tag)
-{
-    return PVLogger::GetLoggerObject(tag);
-}
-
-//C-callable version of PVLogger::IsActive
-OSCL_EXPORT_REF int pvLogger_IsActive(void* logger, int log_level)
-{
-    if (logger)
-        return (int)((PVLogger*)logger)->IsActive(log_level);
-    return 0;
-}
-
-//C-callable version of PVLogger::LogMsgString
-OSCL_EXPORT_REF void pvLogger_LogMsgString(void* logger, int msgID, const char * fmt, ...)
-{
-    if (logger)
-    {
-        va_list arguments;
-        va_start(arguments, fmt);
-
-        ((PVLogger*)logger)->LogMsgStringV(msgID, fmt, arguments);
-    }
-}
diff --git a/oscl/pvlogger/src/pvlogger_c.h b/oscl/pvlogger/src/pvlogger_c.h
deleted file mode 100644
index 34a9875..0000000
--- a/oscl/pvlogger/src/pvlogger_c.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-
-/*! \file pvlogger_c.h
-    \brief This file contains basic logger interfaces for common use across platforms.
-	   C-callable version
-
-    This is the main entry point header file for the logger library.  It should be
-    the only one users directly include.
-*/
-
-#ifndef PVLOGGER_C_H_INCLUDED
-#define PVLOGGER_C_H_INCLUDED
-
-#include "osclconfig.h"
-
-#ifndef OSCL_IMPORT_REF
-#define OSCL_IMPORT_REF
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-//C-callable logging routines.
-    OSCL_IMPORT_REF void* pvLogger_GetLoggerObject(const char* tag);
-    OSCL_IMPORT_REF int pvLogger_IsActive(void* logger, int log_level);
-    OSCL_IMPORT_REF void pvLogger_LogMsgString(void* logger, int msgID, const char * fmt, ...);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-//Logging instrumentation level default.  To change this for a project, add a definition of
-//PVLOGGER_C_INST_LEVEL to the osclconfig.h file.  This default sets level to none for release
-//mode, full logging for debug build.
-
-#ifndef PVLOGGER_C_INST_LEVEL
-#if defined(NDEBUG)
-#define PVLOGGER_C_INST_LEVEL 0
-#else
-#define PVLOGGER_C_INST_LEVEL 5
-#endif
-#endif
-
-//Instrumentation levels.
-#define PVLOGMSG_C_INST_REL   0
-#define PVLOGMSG_C_INST_PROF  1
-#define PVLOGMSG_C_INST_HLDBG 2
-#define PVLOGMSG_C_INST_MLDBG 3
-#define PVLOGMSG_C_INST_LLDBG 4
-
-//Logging levels
-#define PVLOGMSG_C_EMERG 0
-#define PVLOGMSG_C_ALERT 1
-#define PVLOGMSG_C_CRIT 2
-#define PVLOGMSG_C_ERR 3
-#define PVLOGMSG_C_WARNING 4
-#define PVLOGMSG_C_NOTICE 5
-#define PVLOGMSG_C_INFO 6
-#define PVLOGMSG_C_STACK_TRACE 7
-#define PVLOGMSG_C_STACK_DEBUG 8
-
-/*
-//Example Usage:
-
-#if (PVLOGGER_C_INST_LEVEL > PVLOGMSG_C_INST_LLDBG)
-			if(pvLogger_IsActive(logger ,PVLOGMSG_C_ERR))
-				pvLogger_LogMsgString( logger ,  0 ,"Some message, value %d", intvalue );
-
-#endif
-*/
-
-
-
-#endif // PVLOGGER_C_H_INCLUDED
diff --git a/oscl/pvlogger/src/pvlogger_file_appender.h b/oscl/pvlogger/src/pvlogger_file_appender.h
index a2e4fff..ea7938f 100644
--- a/oscl/pvlogger/src/pvlogger_file_appender.h
+++ b/oscl/pvlogger/src/pvlogger_file_appender.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
     public:
         typedef PVLoggerAppender::message_id_type message_id_type;
 
-        static TextFileAppender<Layout, LayoutBufferSize, Lock>* CreateAppender(OSCL_TCHAR * filename, uint32 cacheSize = 0)
+        static TextFileAppender<Layout, LayoutBufferSize, Lock>* CreateAppender(const OSCL_TCHAR * filename, uint32 cacheSize = 0)
         {
 
             TextFileAppender<Layout, LayoutBufferSize, Lock> * appender = new TextFileAppender<Layout, LayoutBufferSize, Lock>();
diff --git a/oscl/pvlogger/src/pvlogger_mem_appender.h b/oscl/pvlogger/src/pvlogger_mem_appender.h
index 1d1bbc0..afd0d22 100644
--- a/oscl/pvlogger/src/pvlogger_mem_appender.h
+++ b/oscl/pvlogger/src/pvlogger_mem_appender.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/pvlogger/src/pvlogger_registry.h b/oscl/pvlogger/src/pvlogger_registry.h
deleted file mode 100644
index 5d11a56..0000000
--- a/oscl/pvlogger/src/pvlogger_registry.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#ifndef PVLOGGER_REGISTRY_H_INCLUDED
-#define PVLOGGER_REGISTRY_H_INCLUDED
-
-#ifndef PVLOGGER_H_INCLUDED
-#include "pvlogger.h"
-#endif
-
-#ifndef OSCL_TAGTREE_H_INCLUDED
-#include "oscl_tagtree.h"
-#endif
-
-/**
- * Class: PVLoggerRegistry
- *
- * PVLoggerRegistry class, maintains a repository of all the loggers, along with
- * their associated tags, in a tag tree. Any request for a log control point is
- * serviced by this class.
- *
- * Memory Ownership: Creates log control points for each tag, and holds these
- * pointers in the tag tree. PVLogger registry is responsible for calling the
- * destructor on each of these loggers.
- *
- */
-
-class PVLoggerRegistry
-{
-    public:
-
-        typedef PVLogger::log_level_type log_level_type;
-        typedef PVLogger::alloc_type alloc_type;
-
-        /**
-         * Get the logger registry.  There is only one logger
-         * registry instance per thread.
-         */
-        OSCL_IMPORT_REF static PVLoggerRegistry* GetPVLoggerRegistry();
-
-        /**
-         * PVLoggerRegistry Constructor
-         *
-         */
-        OSCL_IMPORT_REF PVLoggerRegistry();
-
-        /**
-         * PVLoggerRegistry Destructor
-         *
-         */
-        OSCL_IMPORT_REF virtual ~PVLoggerRegistry();
-
-        /**
-         * PVLoggerRegistry method to get access to a logging control point, associated with
-         * a tag. In case the logger for this tag does not exist, it is created afresh, else
-         * pointer to the existing one is returned.
-         *
-         * @param inputTag   logger tag, viz. "x.y.z"
-         * @param level      log level associated with the logging control point
-         *
-         * @param oAppenderInheritance
-         *
-         * @return PVLogger<Alloc, TheLock>* Pointer to the logging control point
-         */
-        OSCL_IMPORT_REF PVLogger *GetPVLoggerObject(const char* tagIn);
-
-        /**
-         * This method creates a log control point, with specified tag, and level
-         *
-         * @param inputTag   logger tag, viz. "x.y.z"
-         * @param level      log level associated with the logging control point
-         *
-         * @param oAppenderInheritance
-         *
-         * @return PVLogger<alloc_type, TheLock>* Pointer to the logging control point
-         */
-        OSCL_IMPORT_REF PVLogger *CreatePVLogger(const char* tagIn, log_level_type level, bool oAppenderInheritance);
-
-        /**
-         * This method propagates the log level to all the descendents of the node,
-         * with a specified tag.
-         *
-         * @param tagIn      logger tag, viz. "x.y.z"
-         * @param level      log level associated with the logging control point
-         *
-         * @return           true on success, else false.
-         */
-        OSCL_IMPORT_REF bool SetNodeLogLevelExplicit(char* tagIn, log_level_type level);
-
-        /**
-         * This method recursively propagates the log level to all the descendents,
-         * of a node.
-         *
-         * @param node       Node ptr, associated with a logger, from the tag tree.
-         * @param level      log level associated with the logging control point
-         *
-         * @return           NONE
-         */
-        OSCL_IMPORT_REF void SetNodeLogLevelExplicit(Oscl_TagTree<PVLogger*, alloc_type>::node_type* node, log_level_type level);
-
-    private:
-#if (PVLOGGER_ENABLE)
-        Oscl_TAlloc<PVLogger, alloc_type> _pvloggerAlloc;
-        Oscl_TagTree<PVLogger*, alloc_type> _loggerTree;
-#endif
-};
-
-#endif // PVLOGGER_REGISTRY_H_INCLUDED
-
diff --git a/oscl/pvlogger/src/pvlogger_stderr_appender.h b/oscl/pvlogger/src/pvlogger_stderr_appender.h
index 84f1939..ea16dc5 100644
--- a/oscl/pvlogger/src/pvlogger_stderr_appender.h
+++ b/oscl/pvlogger/src/pvlogger_stderr_appender.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,9 @@
 #ifndef OSCLCONFIG_UTIL_H_INCLUDED
 #include "osclconfig_util.h"
 #endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
 
 /**
  * Class: StdErrAppender
@@ -65,7 +68,7 @@
             size = _layout.FormatString(stringbuf, LayoutBufferSize, msgID, fmt, va);
 
             {
-                fprintf(stderr, stringbuf);
+                fprintf(stderr, "%s", stringbuf);
                 fprintf(stderr, "\n");
             }
 
diff --git a/oscl/pvlogger/src/pvlogger_time_and_id_layout.h b/oscl/pvlogger/src/pvlogger_time_and_id_layout.h
index defdd3d..a408375 100644
--- a/oscl/pvlogger/src/pvlogger_time_and_id_layout.h
+++ b/oscl/pvlogger/src/pvlogger_time_and_id_layout.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@
 #include "oscl_thread.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef OSCL_TICKCOUNT_H_INCLUDED
+#include "oscl_tickcount.h"
 #endif
 
 #define OSCLCLOCKUNIT_SEC = 2
@@ -48,8 +48,11 @@
 class TimeAndIdLayout : public PVLoggerLayout
 {
     public:
-        TimeAndIdLayout() {};
-        virtual ~TimeAndIdLayout() {};
+        TimeAndIdLayout()
+        {
+            iTickBase = OsclTickCount::TickCount();
+        }
+        virtual ~TimeAndIdLayout() {}
 
         typedef PVLoggerLayout::message_id_type message_id_type;
 
@@ -58,17 +61,14 @@
         {
             int32 msgLen = 0;
             int32 remBufSpace = formatBufSize;
-            uint64 aTime = 0;
-            OsclClock_TimeUnits aUnits = OSCLCLOCK_MSEC;
-            uint64 aTimebaseTime = 0;
-            iCurrentClockTime.GetCurrentTime64(aTime, aUnits, aTimebaseTime);
+            uint32 msec = OsclTickCount::TicksToMsec(OsclTickCount::TickCount() - iTickBase);
 
             OSCL_UNUSED_ARG(msgID);
 
             TOsclThreadId threadId;
             OsclThread::GetId(threadId);
 
-            msgLen += oscl_snprintf(formatBuf, remBufSpace, "PVLOG:TID(0x%x):Time=%d:", (uint32)threadId, Oscl_Int64_Utils::get_uint64_lower32(aTime));
+            msgLen += oscl_snprintf(formatBuf, remBufSpace, "PVLOG:TID(0x%x):Time=%d:", (uint32)threadId, msec);
 
             if (msgLen > formatBufSize) return (formatBufSize);
 
@@ -93,7 +93,7 @@
             return 0;
         }
     private:
-        OsclTimebase_Tickcount iCurrentClockTime;
+        uint32 iTickBase;
 
 };
 
diff --git a/oscl/setup b/oscl/setup
deleted file mode 100644
index c4170f0..0000000
--- a/oscl/setup
+++ /dev/null
@@ -1,76 +0,0 @@
-
-echo Setting up build environment with default configuration ...
-echo Using $PWD as top directory ...
-
-# Set the PV_TOP
-#
-setenv PV_TOP $PWD
-echo Set PV_TOP to $PV_TOP ...
-
-# Setup environment for necessary for the
-# makefiles, etc.
-
-# Only set the VOB_BASE_DIR if it is not already set.
-# In this case, set it based on the first argument if it is present
-# and otherwise default to /vobs.
-if (! $?VOB_BASE_DIR) then
-   if ($# >= 1) then 
-     setenv VOB_BASE_DIR $1 
-   else 
-     setenv VOB_BASE_DIR /vobs
-   endif
-   echo Set VOB_BASE_DIR to $VOB_BASE_DIR ...
-else
-   echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
-endif
-
-# SDK_LOCAL is the local staging area (i.e., view private) for private
-# builds and installs of the corelibs libraries.  The path should be 
-# relative to VOB_BASE_DIR.  Set to a default value if it is not set 
-if (! $?SDK_LOCAL) then
-  setenv SDK_LOCAL $PV_TOP
-  echo Set SDK_LOCAL to $SDK_LOCAL ...
-else
-  echo SDK_LOCAL already defined as $SDK_LOCAL
-endif
-
-setenv PROJECT $PV_TOP
-echo Set PROJECT to $PROJECT ...
-
-setenv MK $VOB_BASE_DIR/tools_v2/build/make
-echo Set MK to $MK ...
-
-setenv CCASE_MAKE_COMPAT gnu
-echo Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ...
-
-if (! -f $MK/../bin/archtype) then
-   echo "Error. Cannot find archtype script $MK/../bin/archtype."
-endif
-
-set arch_bin_path = `$MK/../bin/archtype`
-set extern_tools_path = $VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
-if ( -x /icl-tools/bin/$arch_bin_path/utok ) then
-  set path = (`/icl-tools/bin/$arch_bin_path/utok -s \  ./$arch_bin_path $extern_tools_path $path`)
-else 
-  set path = (./$arch_bin_path  $extern_tools_path $path)
-endif
-unset arch_bin_path
-unset extern_tools_path
-
-if ( -f ./setup.extras ) then
-  echo File setup.extras found, sourcing ...
-  source ./setup.extras
-else
-  echo File setup.extras not found, skipping ...
-endif
-
-# Rehash
-#
-rehash
-rehash
-
-# Finita
-#
-echo 
-echo Environment is ready if no errors reported
-echo 
diff --git a/oscl/setup.ksh b/oscl/setup.ksh
deleted file mode 100644
index 76e0110..0000000
--- a/oscl/setup.ksh
+++ /dev/null
@@ -1,68 +0,0 @@
-echo Setting up build environment with default configuration ...
-echo Using $PWD as top directory ...
-
-# Set the PV_TOP
-#
-export PV_TOP=$PWD
-echo Set PV_TOP to $PV_TOP ...
-
-# Setup environment for necessary for the
-# makefiles, etc.
-
-# Only set the VOB_BASE_DIR if it is not already set.
-# In this case, set it based on the first argument if it is present
-# and otherwise default to /vobs.
-if [[ -z $VOB_BASE_DIR ]]; then
-   if [[ $# -ge 1 ]]; then 
-     export VOB_BASE_DIR="$1"
-   else 
-     export VOB_BASE_DIR="/vobs"
-   fi
-   echo "Set VOB_BASE_DIR to $VOB_BASE_DIR ..."
-else
-   echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
-fi
-
-# SDK_LOCAL is the local staging area (i.e., view private) for private
-# builds and installs of the corelibs libraries.  The path should be 
-# relative to VOB_BASE_DIR.  Set to a default value if it is not set 
-if [[ -z $SDK_LOCAL ]]; then
-  export SDK_LOCAL=$PV_TOP
-  echo "Set SDK_LOCAL to $SDK_LOCAL ..."
-else
-  echo "SDK_LOCAL already defined as $SDK_LOCAL"
-fi
-
-export PROJECT=$PV_TOP
-echo "Set PROJECT to $PROJECT ..."
-
-export MK="$VOB_BASE_DIR/tools_v2/build/make"
-echo "Set MK to $MK ..."
-
-export CCASE_MAKE_COMPAT="gnu"
-echo "Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ..."
-
-if [[ ! -f "$MK/../bin/archtype" ]];  then
-  echo "Error. Cannot find archtype script $MK/../bin/archtype."
-fi
-
-export arch_bin_path=`$MK/../bin/archtype`
-export extern_tools_path=$VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
-if [[ -x /icl-tools/bin/$arch_bin_path/utok ]]; then
-  export PATH=$PATH:`/icl-tools/bin/$arch_bin_path/utok -s \  ./$arch_bin_path  $extern_tools_path $PATH`
-else
-  export PATH=./$arch_bin_path:$extern_tools_path:$PATH
-fi
-export arch_bin_path=
-export extern_tools_path=
-
-if [[ -f ./setup.extras.ksh ]]; then
-   echo File setup.extras.ksh found, sourcing ...
-   . ./setup.extras.ksh
-else
-   echo File setup.extras not found, skipping ...
-fi 
-
-echo 
-echo Environment is ready if no errors reported
-echo
diff --git a/oscl/unit_test/Android.mk b/oscl/unit_test/Android.mk
index 41d6cba..6e72d34 100644
--- a/oscl/unit_test/Android.mk
+++ b/oscl/unit_test/Android.mk
@@ -3,36 +3,39 @@
 
 LOCAL_SRC_FILES := \
 	src/test_case.cpp \
-	src/test_problem.cpp \
-	src/test_result.cpp \
-	src/text_test_interpreter.cpp \
-	src/unit_test_main.cpp \
-	src/unit_test_args.cpp
-
+ 	src/test_problem.cpp \
+ 	src/test_result.cpp \
+ 	src/text_test_interpreter.cpp \
+ 	src/unit_test_main.cpp \
+ 	src/unit_test_args.cpp
 
 
 LOCAL_MODULE := libunit_test
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//oscl/unit_test/src \
-	$(PV_TOP)//oscl/unit_test/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/oscl/unit_test/src \
+ 	$(PV_TOP)/oscl/unit_test/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/stringable.h \
-	src/test_case.h \
-	src/test_problem.h \
-	src/test_result.h \
-	src/text_test_interpreter.h \
-	src/unit_test_common.h \
-	src/unit_test_local_string.h \
-	src/unit_test_args.h \
-	src/unit_test_vector.h
+ 	src/test_case.h \
+ 	src/test_problem.h \
+ 	src/test_result.h \
+ 	src/text_test_interpreter.h \
+ 	src/unit_test_common.h \
+ 	src/unit_test_local_string.h \
+ 	src/unit_test_args.h \
+ 	src/unit_test_vector.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/oscl/unit_test/build/make/local.mk b/oscl/unit_test/build/make/local.mk
new file mode 100644
index 0000000..5a6a060
--- /dev/null
+++ b/oscl/unit_test/build/make/local.mk
@@ -0,0 +1,34 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := unit_test
+
+XCXXFLAGS := $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := test_case.cpp \
+	test_problem.cpp \
+	test_result.cpp \
+	text_test_interpreter.cpp \
+        unit_test_main.cpp \
+	unit_test_args.cpp
+
+HDRS := stringable.h \
+	test_case.h \
+	test_problem.h \
+	test_result.h \
+	text_test_interpreter.h \
+	unit_test_common.h \
+	unit_test_local_string.h \
+	unit_test_args.h \
+	unit_test_vector.h 
+
+include $(MK)/library.mk
+
+
+
diff --git a/oscl/unit_test/build/make/makefile b/oscl/unit_test/build/make/makefile
deleted file mode 100644
index f37c0d2..0000000
--- a/oscl/unit_test/build/make/makefile
+++ /dev/null
@@ -1,70 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = unit_test
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS += 
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  test_case.cpp \
-	test_problem.cpp \
-	test_result.cpp \
-	text_test_interpreter.cpp \
-        unit_test_main.cpp \
-	unit_test_args.cpp
-
-HDRS =  stringable.h \
-	test_case.h \
-	test_problem.h \
-	test_result.h \
-	text_test_interpreter.h \
-	unit_test_common.h \
-	unit_test_local_string.h \
-	unit_test_args.h \
-	unit_test_vector.h 
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
-
diff --git a/oscl/unit_test/src/stringable.h b/oscl/unit_test/src/stringable.h
index bd47422..9f9f16a 100644
--- a/oscl/unit_test/src/stringable.h
+++ b/oscl/unit_test/src/stringable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/test_case.cpp b/oscl/unit_test/src/test_case.cpp
index 4039152..3ea360b 100644
--- a/oscl/unit_test/src/test_case.cpp
+++ b/oscl/unit_test/src/test_case.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/test_case.h b/oscl/unit_test/src/test_case.h
index 2c5205e..5ac0343 100644
--- a/oscl/unit_test/src/test_case.h
+++ b/oscl/unit_test/src/test_case.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/test_problem.cpp b/oscl/unit_test/src/test_problem.cpp
index 0f92896..46a98cd 100644
--- a/oscl/unit_test/src/test_problem.cpp
+++ b/oscl/unit_test/src/test_problem.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/test_problem.h b/oscl/unit_test/src/test_problem.h
index a45d876..96c9b9f 100644
--- a/oscl/unit_test/src/test_problem.h
+++ b/oscl/unit_test/src/test_problem.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/test_result.cpp b/oscl/unit_test/src/test_result.cpp
index d4186b7..5a0a18e 100644
--- a/oscl/unit_test/src/test_result.cpp
+++ b/oscl/unit_test/src/test_result.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/test_result.h b/oscl/unit_test/src/test_result.h
index e454846..6a16921 100644
--- a/oscl/unit_test/src/test_result.h
+++ b/oscl/unit_test/src/test_result.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/text_test_interpreter.cpp b/oscl/unit_test/src/text_test_interpreter.cpp
index 558195c..dfa5d7a 100644
--- a/oscl/unit_test/src/text_test_interpreter.cpp
+++ b/oscl/unit_test/src/text_test_interpreter.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/text_test_interpreter.h b/oscl/unit_test/src/text_test_interpreter.h
index 65d979d..46dd382 100644
--- a/oscl/unit_test/src/text_test_interpreter.h
+++ b/oscl/unit_test/src/text_test_interpreter.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/unit_test_args.cpp b/oscl/unit_test/src/unit_test_args.cpp
index b694c99..6c4f06f 100644
--- a/oscl/unit_test/src/unit_test_args.cpp
+++ b/oscl/unit_test/src/unit_test_args.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/unit_test_args.h b/oscl/unit_test/src/unit_test_args.h
index d0b9139..e04eed5 100644
--- a/oscl/unit_test/src/unit_test_args.h
+++ b/oscl/unit_test/src/unit_test_args.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/unit_test_common.h b/oscl/unit_test/src/unit_test_common.h
index 6d080ce..916c1bd 100644
--- a/oscl/unit_test/src/unit_test_common.h
+++ b/oscl/unit_test/src/unit_test_common.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/unit_test_local_string.h b/oscl/unit_test/src/unit_test_local_string.h
index 8a72062..027093a 100644
--- a/oscl/unit_test/src/unit_test_local_string.h
+++ b/oscl/unit_test/src/unit_test_local_string.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/src/unit_test_main.cpp b/oscl/unit_test/src/unit_test_main.cpp
index 69577c2..1383e76 100644
--- a/oscl/unit_test/src/unit_test_main.cpp
+++ b/oscl/unit_test/src/unit_test_main.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,21 @@
     cmd_line_linux command_line;
     command_line_ptr = &command_line;
 
+    // remove leading and trailing quotation marks
+    for (int i = 0; i < argc; ++i)
+    {
+        // skip ',`," at start
+        if (argv[i][0] == '"' || argv[i][0] == '\'' || argv[i][0] == '`')
+            argv[i] += 1;
+        size_t strEnd = _strlen(argv[i]);
+        if (strEnd > 0)
+        {
+            strEnd -= 1; // last char
+            if (argv[i][strEnd] == '"' || argv[i][strEnd] == '\'' || argv[i][strEnd] == '`')
+                argv[i][strEnd] = 0;
+        }
+    }
+
 
     if (argc > 1)
     {
diff --git a/oscl/unit_test/src/unit_test_vector.h b/oscl/unit_test/src/unit_test_vector.h
index e4fc919..5dba2f5 100644
--- a/oscl/unit_test/src/unit_test_vector.h
+++ b/oscl/unit_test/src/unit_test_vector.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/oscl/unit_test/test/src/point.h b/oscl/unit_test/test/src/point.h
new file mode 100644
index 0000000..bccdca2
--- /dev/null
+++ b/oscl/unit_test/test/src/point.h
@@ -0,0 +1,115 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef POINT_H
+#define POINT_H
+
+#ifndef STRINGABLE_H
+#include "stringable.h"
+#endif
+#include <stdio.h>
+
+//@doc
+
+
+//@class a simple 2-d point class.  This is used for graphics placement, etc.
+template < class T > class point : public stringable
+{
+        //@access public data members
+    public:
+        typedef point < T > t_point;
+        //@cmember the x coordinate of the point
+        T x;
+        //@cmember the y coordinate of the point
+        T y;
+        //@access public methods
+    public:
+        //@cmember default constructor
+        point(void): x(0), y(0)
+        {
+        };
+        //@cmember copy constructor
+        point(const t_point & rhs): x(rhs.x), y(rhs.y)
+        {
+        };
+        //@cmember specific constructor
+        point(const T & new_x, const T & new_y): x(new_x), y(new_y)
+        {
+        };
+        //@cmember equality comparison operator
+        bool operator == (const t_point & rhs) const
+        {
+            return ((x == rhs.x) && (y == rhs.y));
+        };
+        //@cmember inequality comparison operator
+        bool operator != (const t_point & rhs) const
+        {
+            return !((*this) == rhs);
+        };
+        //@cmember adds a point to this point
+        t_point & operator += (const t_point & rhs)
+        {
+            x += rhs.x;
+            y += rhs.y;
+            return (*this);
+        };
+        //@cmember subtracts a point from this point
+        t_point & operator -= (const t_point & rhs)
+        {
+            x -= rhs.x;
+            y -= rhs.y;
+            return (*this);
+        };
+        //@cmember adds two points
+        t_point operator + (const t_point & rhs) const
+        {
+            return t_point(x + rhs.x, y + rhs.y);
+        };
+        //@cmember subtracts two points
+        t_point operator - (const t_point & rhs) const
+        {
+            return t_point(x - rhs.x, y - rhs.y);
+        };
+        //@cmember equals operator
+        t_point & operator = (const t_point & rhs)
+        {
+            x = rhs.x; //should be x;
+            y = rhs.y;
+            return (*this);
+        };
+        //@cmember returns a string representing the point -- note: uses sprintf(); only works correctly for int points
+        //just here to demonstrate to_string
+        virtual std::string to_string(void) const
+        {
+            std::string Result = "(";
+            char temp[100];
+            sprintf(temp, "%d", x);
+            Result.append(temp);
+            Result.append(", ");
+            sprintf(temp, "%d", y);
+            Result.append(temp);
+            Result.append(")");
+            return Result;
+        };
+};
+
+//@type int_point | commonly used element: a <c point> made up of ints
+typedef point < int >int_point;
+
+
+#endif
+
diff --git a/oscl/unit_test/test/src/test_case_point.cpp b/oscl/unit_test/test/src/test_case_point.cpp
new file mode 100644
index 0000000..299822b
--- /dev/null
+++ b/oscl/unit_test/test/src/test_case_point.cpp
@@ -0,0 +1,161 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "test_case_point.h"
+
+
+
+class default_constructor_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point;
+            test_is_equal(test_point, int_point(0, 0));
+        }
+};
+
+class specific_constructor_test : public point_test
+{
+        virtual void test(void)
+        {
+            test_is_equal(top_left_point, int_point(1, 2));
+        }
+};
+
+class copy_constructor_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point(top_left_point);
+            test_is_equal(test_point, int_point(1, 2));
+        }
+};
+
+class equality_operator_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_equal_point(1, 2);
+            test_is_true(top_left_point == top_left_point);
+            test_is_true(top_left_point == test_equal_point);
+        }
+};
+
+class inequality_operator_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point first_equal_point(1, 9);
+            int_point second_equal_point(9, 2);
+            test_is_true(top_left_point != first_equal_point);
+            test_is_true(top_left_point != second_equal_point);
+            test_is_true(top_left_point != bottom_right_point);
+        }
+};
+
+class self_addition_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point(10, 20);
+            test_point += top_left_point;
+            test_is_equal(test_point, int_point(11, 22));
+        }
+};
+
+class self_subtraction_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point(10, 20);
+            test_point -= top_left_point;
+            test_is_equal(test_point, int_point(9, 18));
+        }
+};
+
+class addition_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point = top_left_point + bottom_right_point;
+            test_is_equal(test_point, int_point(4, 6));
+        }
+};
+
+class subtraction_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point = top_left_point - bottom_right_point;
+            test_is_equal(test_point, int_point(-2, -2));
+        }
+};
+
+class copy_operator_test : public point_test
+{
+        virtual void test(void)
+        {
+            int_point test_point;
+            test_point = top_left_point;
+            test_is_equal(test_point, top_left_point);
+        }
+};
+
+class cmd_args_test : public point_test
+{
+    public:
+        cmd_args_test(char** args_list, int args_count)
+        {
+            SetArgs(args_list);
+            SetArgsCount(args_count);
+        }
+        virtual void test(void)
+        {
+            int i;
+            for (i = 0; i < iArgsCount; i++)
+            {
+                printf("Input Argument %d is %s \r\n", i, iInputArgs[i]);
+            }
+        }
+};
+
+
+point_test_suite::point_test_suite(char** args_list, int args_count) :
+        test_case()
+{
+    SetArgs(args_list);
+    SetArgsCount(args_count);
+
+    adopt_test_case(new default_constructor_test);
+    adopt_test_case(new specific_constructor_test);
+    adopt_test_case(new copy_constructor_test);
+    adopt_test_case(new equality_operator_test);
+    adopt_test_case(new inequality_operator_test);
+    adopt_test_case(new self_addition_test);
+    adopt_test_case(new self_subtraction_test);
+    adopt_test_case(new addition_test);
+    adopt_test_case(new subtraction_test);
+    adopt_test_case(new copy_operator_test);
+    adopt_test_case(new cmd_args_test(GetArgs(), GetArgsCount()));
+}
+
+void
+point_test::set_up(void)
+{
+    top_left_point = int_point(1, 2);
+    bottom_right_point = int_point(3, 4);
+}
diff --git a/oscl/unit_test/test/src/test_case_point.h b/oscl/unit_test/test/src/test_case_point.h
new file mode 100644
index 0000000..8031706
--- /dev/null
+++ b/oscl/unit_test/test/src/test_case_point.h
@@ -0,0 +1,45 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TEST_POINT_H
+#define TEST_POINT_H
+
+#ifndef TEST_CASE_H
+#include "test_case.h"
+#endif
+#ifndef POINT_H
+#include "point.h"
+#endif
+
+class point_test : public test_case
+{
+    protected:
+        int_point top_left_point;
+        int_point bottom_right_point;
+    public:
+        virtual void set_up(void);
+};
+
+class point_test_suite : public test_case
+{
+    public:
+        point_test_suite(void);
+        point_test_suite(char**, int);
+
+};
+
+#endif
diff --git a/oscl/unit_test/test/src/test_point.cpp b/oscl/unit_test/test/src/test_point.cpp
new file mode 100644
index 0000000..4f69f4b
--- /dev/null
+++ b/oscl/unit_test/test/src/test_point.cpp
@@ -0,0 +1,32 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "osclconfig.h"
+#include "test_case_point.h"
+#include "text_test_interpreter.h"
+
+#include <iostream>
+
+int
+int local_main(FILE* filehandle, cmd_line* command_line)
+{
+    point_test_suite pnt_test(argv, argc);
+    pnt_test.run_test();
+    text_test_interpreter interpreter;
+
+    std::cout << interpreter.interpretation(pnt_test.last_result());
+}
diff --git a/protocols/http_parcom/Android.mk b/protocols/http_parcom/Android.mk
index 507b112..e556837 100644
--- a/protocols/http_parcom/Android.mk
+++ b/protocols/http_parcom/Android.mk
@@ -3,27 +3,30 @@
 
 LOCAL_SRC_FILES := \
 	src/http_composer.cpp \
-	src/http_parser.cpp \
-	src/string_keyvalue_store.cpp
-
+ 	src/http_parser.cpp \
+ 	src/string_keyvalue_store.cpp
 
 
 LOCAL_MODULE := libpv_http_parcom
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/http_parcom/include \
-	$(PV_TOP)//protocols/http_parcom/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/protocols/http_parcom/src \
+ 	$(PV_TOP)/protocols/http_parcom/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/http_composer.h \
-	include/http_parser.h \
-	include/http_parser_external.h
+ 	include/http_parser.h \
+ 	include/http_parser_external.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/http_parcom/build/make/local.mk b/protocols/http_parcom/build/make/local.mk
new file mode 100644
index 0000000..29bca07
--- /dev/null
+++ b/protocols/http_parcom/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv_http_parcom
+
+
+
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := http_composer.cpp \
+	http_parser.cpp \
+	string_keyvalue_store.cpp
+
+HDRS := http_composer.h \
+	http_parser.h \
+	http_parser_external.h
+
+include $(MK)/library.mk
+
+
+
diff --git a/protocols/http_parcom/build/make/makefile b/protocols/http_parcom/build/make/makefile
deleted file mode 100644
index 71b98ff..0000000
--- a/protocols/http_parcom/build/make/makefile
+++ /dev/null
@@ -1,64 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pv_http_parcom
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-# XINCDIRS += 
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = 	http_composer.cpp \
-	http_parser.cpp \
-	string_keyvalue_store.cpp
-
-HDRS =  http_composer.h \
-	http_parser.h \
-	http_parser_external.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
-
-
diff --git a/protocols/http_parcom/include/http_composer.h b/protocols/http_parcom/include/http_composer.h
index 6ed1efa..a23fb11 100644
--- a/protocols/http_parcom/include/http_composer.h
+++ b/protocols/http_parcom/include/http_composer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -72,7 +72,7 @@
          * Set URI. Note that composer doesn't do any memory allocation and memory copy for the input URI, and just save the pointer
          * for the URI string. So it is composer user's reponsiblity to keep URI valid during request composing.
          */
-        void setURI(const StrPtrLen aURI);
+        OSCL_IMPORT_REF void setURI(const StrPtrLen aURI);
 
         /**
          * set/remove a standard field or add a new extension field for the headers
diff --git a/protocols/http_parcom/include/http_parser.h b/protocols/http_parcom/include/http_parser.h
index 2e01487..f7815bb 100644
--- a/protocols/http_parcom/include/http_parser.h
+++ b/protocols/http_parcom/include/http_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -104,7 +104,7 @@
         OSCL_IMPORT_REF uint32 getTotalFieldsInHeader();
         // get a list of all field keys inside the header
         OSCL_IMPORT_REF uint32 getFieldKeyListInHeader(StrPtrLen *&aFieldKeyList);
-        // get the field value with the given field key, which can be retrived from getFieldKeyListInHeader()
+        // get the field value with the given field key, which can be retrieved from getFieldKeyListInHeader()
         // There could be a case where one field key correponds to multiple field values, so input argument "index" is for
         // getting which value for the given field key
         OSCL_IMPORT_REF bool getField(const StrCSumPtrLen &aNewFieldName, StrPtrLen &aNewFieldValue, const uint32 index = 0);
diff --git a/protocols/http_parcom/include/http_parser_external.h b/protocols/http_parcom/include/http_parser_external.h
index c61c1e1..c4a4218 100644
--- a/protocols/http_parcom/include/http_parser_external.h
+++ b/protocols/http_parcom/include/http_parser_external.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/http_parcom/src/http_composer.cpp b/protocols/http_parcom/src/http_composer.cpp
index 004df5f..77bcbe7 100644
--- a/protocols/http_parcom/src/http_composer.cpp
+++ b/protocols/http_parcom/src/http_composer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -81,10 +81,10 @@
     iURI = aURI;
 
     // get relative URI
-    char *aServerAddPtr = oscl_strstr(((char*)aURI.c_str()), "//");
+    const char *aServerAddPtr = oscl_strstr(((char*)aURI.c_str()), "//");
     if (!aServerAddPtr) return;
     aServerAddPtr += 2;
-    char *aRelativeUriPtr = oscl_strstr(aServerAddPtr, "/");
+    const char *aRelativeUriPtr = oscl_strstr(aServerAddPtr, "/");
     if (!aRelativeUriPtr) return;
     iRelativeURI = StrPtrLen(aRelativeUriPtr);
 }
diff --git a/protocols/http_parcom/src/http_parcom_internal.h b/protocols/http_parcom/src/http_parcom_internal.h
index 965237b..e9a161f 100644
--- a/protocols/http_parcom/src/http_parcom_internal.h
+++ b/protocols/http_parcom/src/http_parcom_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/http_parcom/src/http_parser.cpp b/protocols/http_parcom/src/http_parser.cpp
index 73ced0d..832ff28 100644
--- a/protocols/http_parcom/src/http_parser.cpp
+++ b/protocols/http_parcom/src/http_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -895,7 +895,7 @@
 
 // return value: 0 normal,
 //				 1 end of header,
-//				 2 ignore (for CRLF, to handle CRLF split into seperate fragments)
+//				 2 ignore (for CRLF, to handle CRLF split into separate fragments)
 //				-1 error
 int32 HTTPParserBaseObject::parseNextValueItem(HTTPMemoryFragment &aInputDataStream, char *&valueItemPtr, uint32 &valueItemLength, const bool isKeyItem)
 {
diff --git a/protocols/http_parcom/src/http_parser_internal.h b/protocols/http_parcom/src/http_parser_internal.h
index 979d170..4930d67 100644
--- a/protocols/http_parcom/src/http_parser_internal.h
+++ b/protocols/http_parcom/src/http_parser_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -496,7 +496,7 @@
         bool needSkipCRLF()
         {
             // iPrevCRLF&0x3!=0x3 means iPrevCRLF hasn't got complete CRLF (i.e.both CR and LF)
-            return (iNumChunks == 0 && (iPrevCRLF&0x3 != 0x3));
+            return ((iNumChunks == 0) && ((iPrevCRLF&0x3) != 0x3));
         }
 
         int32 parseChunkHeader(HTTPParserInput &aParserInput);
diff --git a/protocols/http_parcom/src/oscl_variablesize_mem_pool.h b/protocols/http_parcom/src/oscl_variablesize_mem_pool.h
index 486798b..2af1874 100644
--- a/protocols/http_parcom/src/oscl_variablesize_mem_pool.h
+++ b/protocols/http_parcom/src/oscl_variablesize_mem_pool.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -316,6 +316,13 @@
             return true;
         }
 
+        int32 PushMemChunkToChunkVector(OsclMemoryFragment* aMemChunk)
+        {
+            int32 leavecode = OsclErrNone;
+            OSCL_TRY(leavecode, iUsedMemChunkList.push_back(*aMemChunk));
+            return leavecode;
+        }
+
         OsclAny* doAllocate(const uint32 n)
         {
             OsclMemoryFragment memChunk;
@@ -331,8 +338,7 @@
             }
 
             // insert the removed segment into the iUsedMemChunkList if there is
-            int32 err = 0;
-            OSCL_TRY(err, iUsedMemChunkList.push_back(*pMemChunk));
+            int32 err = PushMemChunkToChunkVector(pMemChunk);
             if (err)
             {
                 OSCL_LEAVE(OsclErrNoMemory);
diff --git a/protocols/http_parcom/src/string_keyvalue_store.cpp b/protocols/http_parcom/src/string_keyvalue_store.cpp
index a1074af..709bcb4 100644
--- a/protocols/http_parcom/src/string_keyvalue_store.cpp
+++ b/protocols/http_parcom/src/string_keyvalue_store.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/http_parcom/src/string_keyvalue_store.h b/protocols/http_parcom/src/string_keyvalue_store.h
index 46d8630..f9c1747 100644
--- a/protocols/http_parcom/src/string_keyvalue_store.h
+++ b/protocols/http_parcom/src/string_keyvalue_store.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -206,7 +206,7 @@
         {
             return iTotalKeyValueLength;
         }
-        // aListSize=0 means retrives whatever the library has
+        // aListSize=0 means retrieves whatever the library has
         // return the actual list size
         uint32 getCurrentKeyList(StrPtrLen *&aFieldKeyList, const uint32 aListSize = 0);
         bool getValueByKey(const StrCSumPtrLen &aKey, StrPtrLen &aValue, const uint32 index = 0);
diff --git a/protocols/rtp/Android.mk b/protocols/rtp/Android.mk
index b022b81..aacd8c6 100644
--- a/protocols/rtp/Android.mk
+++ b/protocols/rtp/Android.mk
@@ -3,41 +3,33 @@
 
 LOCAL_SRC_FILES := \
 	src/rtcp.cpp \
-	src/rtcp_decoder.cpp \
-	src/rtcp_encoder.cpp \
-	src/rtp_decode.cpp \
-	src/rtp_encode.cpp \
-	src/rtp_packet.cpp \
-	src/rtp_packet_impl.cpp \
-	src/rtp_payload.cpp
-
+ 	src/rtcp_decoder.cpp \
+ 	src/rtcp_encoder.cpp
 
 
 LOCAL_MODULE := librtprtcp
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/rtp/src \
-	$(PV_TOP)//protocols/rtp/src \
-	$(PV_TOP)//protocols/rtp/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/protocols/rtp/src \
+ 	$(PV_TOP)/protocols/rtp/src \
+ 	$(PV_TOP)/protocols/rtp/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/rtprtcp.h \
-	src/rtcp.h \
-	src/rtcp_decoder.h \
-	src/rtcp_encoder.h \
-	src/rtcp_constants.h \
-	src/rtp_decode.h \
-	src/rtp_encode.h \
-	src/rtp.h \
-	src/rtp_packet.h \
-	src/rtp_packet_impl.h \
-	src/rtp_payload.h
+ 	src/rtcp.h \
+ 	src/rtcp_decoder.h \
+ 	src/rtcp_encoder.h \
+ 	src/rtcp_constants.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/rtp/build/make/local.mk b/protocols/rtp/build/make/local.mk
new file mode 100644
index 0000000..bb2ba2f
--- /dev/null
+++ b/protocols/rtp/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := rtprtcp
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += ../../include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := rtcp.cpp \
+	rtcp_decoder.cpp \
+	rtcp_encoder.cpp
+
+HDRS := rtprtcp.h \
+	rtcp.h \
+	rtcp_decoder.h \
+	rtcp_encoder.h \
+	rtcp_constants.h
+
+include $(MK)/library.mk
+
diff --git a/protocols/rtp/build/make/makefile b/protocols/rtp/build/make/makefile
deleted file mode 100644
index 7312d89..0000000
--- a/protocols/rtp/build/make/makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = rtprtcp
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS += 
-XINCDIRS += -I../../include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-SRCS =  rtcp.cpp \
-	rtcp_decoder.cpp \
-	rtcp_encoder.cpp \
-	rtp_decode.cpp \
-	rtp_encode.cpp \
-	rtp_packet.cpp \
-	rtp_packet_impl.cpp \
-	rtp_payload.cpp
-
-#INCSRCDIR=../include
-HDRS =  rtprtcp.h \
-	rtcp.h \
-	rtcp_decoder.h \
-	rtcp_encoder.h \
-	rtcp_constants.h \
-	rtp_decode.h \
-	rtp_encode.h \
-	rtp.h \
-	rtp_packet.h \
-	rtp_packet_impl.h \
-	rtp_payload.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
diff --git a/protocols/rtp/src/rtcp.cpp b/protocols/rtp/src/rtcp.cpp
index 8c2d4f2..431854d 100644
--- a/protocols/rtp/src/rtcp.cpp
+++ b/protocols/rtp/src/rtcp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtcp.h b/protocols/rtp/src/rtcp.h
index 99b7461..6b0aedd 100644
--- a/protocols/rtp/src/rtcp.h
+++ b/protocols/rtp/src/rtcp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtcp_constants.h b/protocols/rtp/src/rtcp_constants.h
index e76bb78..a21e42d 100644
--- a/protocols/rtp/src/rtcp_constants.h
+++ b/protocols/rtp/src/rtcp_constants.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtcp_decoder.cpp b/protocols/rtp/src/rtcp_decoder.cpp
index 8ad13a2..a7d45e4 100644
--- a/protocols/rtp/src/rtcp_decoder.cpp
+++ b/protocols/rtp/src/rtcp_decoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtcp_decoder.h b/protocols/rtp/src/rtcp_decoder.h
index 63f50e4..54526e4 100644
--- a/protocols/rtp/src/rtcp_decoder.h
+++ b/protocols/rtp/src/rtcp_decoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtcp_encoder.cpp b/protocols/rtp/src/rtcp_encoder.cpp
index 01d951b..5656a07 100644
--- a/protocols/rtp/src/rtcp_encoder.cpp
+++ b/protocols/rtp/src/rtcp_encoder.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtcp_encoder.h b/protocols/rtp/src/rtcp_encoder.h
index 18abef2..a2abaa2 100644
--- a/protocols/rtp/src/rtcp_encoder.h
+++ b/protocols/rtp/src/rtcp_encoder.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp/src/rtp.h b/protocols/rtp/src/rtp.h
deleted file mode 100644
index 51c3ec9..0000000
--- a/protocols/rtp/src/rtp.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*                                                                               */
-/*********************************************************************************/
-
-/*
-**   File:   rtp.h
-**
-**   Description:
-**      This module defines the RTP class. This is the base class common to the
-**      encode and decode RTP classes. Please refer to the RTP/RTCP design document
-**      for details.
-*/
-
-#ifndef   RTP_H
-#define   RTP_H
-#include "rtprtcp.h"
-
-#define RTP_HEADER_SIZE		12
-#define RTP_CSRC_COUNT_MASK 0x0f
-#define RTP_MARKER_FLAG_POSITION 7
-#define RTP_PAYLOAD_TYPE_MASK 0x7f
-#define RTP_SEQ_NUM_MASK 0x00ff
-const int16 RTP_EXT_FLAG_BIT_POSITION = 4;
-
-
-class RTP_Base
-{
-    public:
-        typedef enum
-        {
-            RTP_OK = 0,
-            RTP_NOT_SUPPORTED = -1,
-            RTP_INDEX_OUT_OF_RANGE = -2,
-            RTP_GENERAL_ERROR = -3
-        } RtpStatus;
-
-        RTP_Base(const RtpSsrc ssrc = 0,
-                 const uint8 version = DEFAULT_RTPRTCP_VERSION) :
-                SSRC(ssrc),
-                rtpVersion(version)
-        {};
-
-        virtual ~RTP_Base() {};
-
-        RtpStatus GetSSRC(RtpSsrc& returnSSRC)
-        {
-            returnSSRC = SSRC;
-            return RTP_OK;
-        }
-
-        void SetSSRC(const RtpSsrc& in_SSRC)
-        {
-            SSRC = in_SSRC;
-        };
-        // void SetITS(const RtpTimeStamp& ITS) {timeStampOffset = ITS;};
-        // void SetISN(const RtpSeqType& ISN) {seqNumOffset = ISN;};
-
-    protected:
-        RtpSsrc SSRC; // synchronization source ID of the caller or
-        // expected synchronization source ID of the
-        // RTP sender
-        // RtpSeqType  seqNumOffset;
-        // RtpTimeStamp  timeStampOffset;
-        uint8 rtpVersion;
-
-};
-
-#endif
diff --git a/protocols/rtp/src/rtp_decode.cpp b/protocols/rtp/src/rtp_decode.cpp
deleted file mode 100644
index b3efea2..0000000
--- a/protocols/rtp/src/rtp_decode.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*                                                                               */
-/*********************************************************************************/
-
-/*
-**   File:   rtp_decode.h
-**
-**   Description:
-**      This module defines the RTP Decode class. This class is used to decode
-**      RTP header. Please refer to the RTP/RTCP design document for details.
-*/
-
-#include <stdlib.h>
-#include <math.h>
-#include "rtp_decode.h"
-
-RTP_Decode::RTP_Decode(const RtpSsrc expected_ssrc,
-                       const uint8 version)
-        : RTP_Base(expected_ssrc, version)
-{
-    savedNumCSRC = 0;
-    savedRtpMsgPtr = NULL;
-    savedRtpMsgSize = 0;
-    savedRtpExtPtr = NULL;
-    savedRtpExtSize = 0;
-}
-
-RTP_Decode::~RTP_Decode()
-{}
-
-RTP_Base::RtpStatus RTP_Decode::decode(const uint8* msg, uint16 size,
-                                       RtpSsrc& ssrc, RtpTimeStamp & timestamp,
-                                       RtpSeqType & seq_num, bool & marker_flag,
-                                       bool & extension_flag,  RtpPayloadType & payload_type,
-                                       uint8* & payload_ptr, uint16 & payload_size,
-                                       uint8 & num_of_csrc
-                                      )
-{
-    OSCL_UNUSED_ARG(extension_flag);
-
-    uint8 tempChar;
-    uint8 rcvdVersion;
-    int pad_bit;
-    int ext_bit;
-    uint8 pad_bytes = 0;
-    uint16 ext_size = 0;
-
-
-
-    // Reset saved Message pointers
-    savedNumCSRC = 0;
-    savedRtpMsgPtr = NULL;
-    savedRtpMsgSize = 0;
-    savedRtpExtPtr = NULL;
-    savedRtpExtSize = 0;
-
-    OsclBinIStreamBigEndian inStream;
-    inStream.Attach((void *)msg, size);
-
-    inStream >> tempChar;
-    rcvdVersion = tempChar >> RTPRTCP_VERSION_BIT_POSITION;
-    pad_bit = (tempChar >> RTPRTCP_PAD_FLAG_BIT_POSITION) & 0x1;
-    ext_bit = (tempChar >> RTP_EXT_FLAG_BIT_POSITION) & 0x1;
-    num_of_csrc = tempChar & RTP_CSRC_COUNT_MASK;
-
-    inStream >> tempChar;
-    if (tempChar >> RTP_MARKER_FLAG_POSITION)
-        marker_flag = true;
-    else
-        marker_flag = false;
-    payload_type = tempChar & RTP_PAYLOAD_TYPE_MASK;
-
-    inStream >> seq_num;
-    inStream >> timestamp;
-    inStream >> ssrc;
-
-    if (rcvdVersion != rtpVersion)
-        return RTP_NOT_SUPPORTED;
-
-
-    if (ext_bit)
-    {
-        const int RTP_EXT_TYPE_BYTES = 2;
-        const int RTP_EXT_HDR_WORDS = 1;
-        const int RTP_EXT_LEN_TO_BYTES = 4;
-        inStream.Seek(RTP_HEADER_SIZE + (num_of_csrc * NUM_BYTES_IN_UINT_32) + RTP_EXT_TYPE_BYTES);
-        inStream >> ext_size;
-
-
-        // add the size of the extension header (in 32-bit words)
-        ext_size += RTP_EXT_HDR_WORDS;
-
-        // Save pointer to extension information in case the caller decides to
-        // retrieve it. Pointer is valid only until
-        // the next call to decode is made
-        savedRtpExtPtr = const_cast<uint8 *>(msg + RTP_HEADER_SIZE + (num_of_csrc * NUM_BYTES_IN_UINT_32));
-        savedRtpExtSize = ext_size;
-
-        // convert size to bytes
-        ext_size *= RTP_EXT_LEN_TO_BYTES;
-    }
-
-    if (pad_bit)
-    {
-        // figure how many pad bytes there are
-        inStream.Seek(size - 1);
-        inStream >> pad_bytes;
-    }
-
-    payload_size = size - RTP_HEADER_SIZE - (num_of_csrc * NUM_BYTES_IN_UINT_32) - pad_bytes - ext_size;
-
-    // Skip the CSRCs and any extensions
-    payload_ptr = const_cast<uint8 *>(msg + RTP_HEADER_SIZE + (num_of_csrc * NUM_BYTES_IN_UINT_32) + ext_size);
-
-    // Save pointer to message in case the caller decides to
-    // retrieve the CSRCs. Pointer is valid only until
-    // the next call to decode is made
-    if (num_of_csrc > 0)
-    {
-        savedNumCSRC = num_of_csrc;
-        savedRtpMsgPtr = const_cast<uint8 *>(msg);
-        savedRtpMsgSize = size;
-    }
-
-    return RTP_OK;
-}
-
-
-int RTP_Decode::getExt(uint32 * const Ext_buffer, int max_words)
-{ // number of 32-bit words in the extension
-
-    int words_to_copy = (savedRtpExtSize < max_words) ? savedRtpExtSize : max_words;
-    int cnt = 0;
-
-    if (savedRtpExtPtr != NULL && savedRtpExtSize > 0)
-    {
-        const int RTP_EXT_BYTES_PER_WORD = 4;
-        OsclBinIStreamBigEndian inStream;
-        inStream.Attach((void *)savedRtpExtPtr, savedRtpExtSize*RTP_EXT_BYTES_PER_WORD);
-
-        for (cnt = 0 ; cnt < words_to_copy; ++cnt)
-        {
-            inStream >> Ext_buffer[cnt];
-        }
-    }
-
-    return cnt;
-
-}
-
-int RTP_Decode::getCSRCs(uint32 * const CSRC_buffer)
-{
-    int cnt = 0;
-    if ((savedRtpMsgPtr != NULL) && savedRtpMsgSize > RTP_HEADER_SIZE)
-    {
-        OsclBinIStreamBigEndian inStream;
-        inStream.Attach((void *)savedRtpMsgPtr, savedRtpMsgSize);
-
-        // Seek to first CSRC
-        inStream.seekFromCurrentPosition(RTP_HEADER_SIZE);
-
-        for (cnt = 0;cnt < savedNumCSRC ; ++cnt)
-        {
-            inStream >> CSRC_buffer[cnt];
-        }
-    }
-
-    return cnt;
-}
diff --git a/protocols/rtp/src/rtp_decode.h b/protocols/rtp/src/rtp_decode.h
deleted file mode 100644
index 788d811..0000000
--- a/protocols/rtp/src/rtp_decode.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*                                                                               */
-/*********************************************************************************/
-
-/*
-**   File:   rtp_decode.h
-**
-**   Description:
-**      This module defines the RTP Decode class. This class is used to decode the
-**      RTP header. Please refer to the RTP/RTCP design document for details.
-*/
-#ifndef   RTP_DECODE_H
-#define   RTP_DECODE_H
-
-#include "rtp.h"
-#include "oscl_bin_stream.h"
-
-class RTP_Decode : public RTP_Base
-{
-    public:
-        RTP_Decode(const RtpSsrc expected_ssrc = 0,
-                   const uint8 version = DEFAULT_RTPRTCP_VERSION);
-        ~RTP_Decode();
-    public:
-        RtpStatus decode(const uint8 * msg,
-                         const uint16 size,
-                         RtpSsrc& ssrc,
-                         RtpTimeStamp & timestamp,
-                         RtpSeqType & seq_num,
-                         bool & marker_flag,
-                         bool & extension_flag,
-                         RtpPayloadType & payload_type,
-                         uint8 * & payload_ptr,
-                         uint16 & payload_size,
-                         uint8 & num_of_csrc);
-
-        int getExtSize()
-        {
-            return savedRtpExtSize;    // number of 32-bit words in the extension
-        }
-
-        int getExt(uint32 * const Ext_buffer, int max_words); // get up to max_words from the extension
-
-        int getCSRCs(uint32 * const CSRC_buffer);
-
-    private:
-        // Pointer to RTP message which
-        // is used in case CSRCs are found
-        // and maybe retrieved by the caller
-        // later
-        uint16  savedRtpMsgSize;
-        uint8*  savedRtpMsgPtr;
-        uint8   savedNumCSRC;
-        uint16  savedRtpExtSize;
-        uint8*  savedRtpExtPtr;
-};
-
-#endif
-
diff --git a/protocols/rtp/src/rtp_encode.cpp b/protocols/rtp/src/rtp_encode.cpp
deleted file mode 100644
index e2b757c..0000000
--- a/protocols/rtp/src/rtp_encode.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*                                                                               */
-/*********************************************************************************/
-
-/*
-**   File:   rtp_encode.cpp
-**
-**   Description:
-**      This module defines the RTP Encode class. This class is used to encode
-**      RTP header. Please refer to the RTP/RTCP design document for details.
-*/
-
-#include <stdlib.h>
-#include <math.h>
-#include "rtp_encode.h"
-
-OSCL_EXPORT_REF
-RTP_Encode::RTP_Encode(const RtpSsrc ssrc,
-                       const RtpSeqType seq_offset,
-                       const RtpTimeStamp ts_offset,
-                       const RtpPayloadType in_payload_type,
-                       const uint8 version)
-        : RTP_Base(ssrc, version)
-{
-    payload_type = in_payload_type;
-    currSeqNum = seq_offset;
-    currRtpTS = ts_offset;
-}
-
-OSCL_EXPORT_REF
-RTP_Encode::~RTP_Encode()
-{}
-
-OSCL_EXPORT_REF
-RTP_Base::RtpStatus RTP_Encode::stuffHeaderInMemory(const uint32 timestamp,
-        const bool marker_flag,
-        uint8 * rtp_header_ptr
-                                                   )
-{
-    // User needs to allocate memory
-    if (!rtp_header_ptr)
-        return RTP_GENERAL_ERROR;
-
-    // Okay to assume caller has allocated enough memory for header?
-    outStream.Attach((void *)rtp_header_ptr, RTP_HEADER_SIZE);
-
-    // Write version and csrc count
-    uint8 tempChar = rtpVersion << RTPRTCP_VERSION_BIT_POSITION;
-    outStream << tempChar;
-
-    // Write marker flag and payload type
-    tempChar = (marker_flag << RTP_MARKER_FLAG_POSITION) | (payload_type & RTP_PAYLOAD_TYPE_MASK);
-    outStream << tempChar;
-
-    // Write sequence number
-    outStream << currSeqNum;
-
-    // Write timestamp
-    // RtpTimeStamp currTimeStamp = timestamp;
-    currRtpTS = timestamp; // keep internal state updated;
-    outStream << timestamp;
-
-    // Write SSRC
-    outStream << SSRC;
-
-    // Increment sequence number
-    ++currSeqNum;
-
-    return RTP_OK;
-}
-
diff --git a/protocols/rtp/src/rtp_encode.h b/protocols/rtp/src/rtp_encode.h
deleted file mode 100644
index e5988d1..0000000
--- a/protocols/rtp/src/rtp_encode.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*                                                                               */
-/*********************************************************************************/
-
-/*
-**   File:   rtp_encode.h
-**
-**   Description:
-**      This module defines the RTP Encode class. This class is used to encode
-**      RTP header. Please refer to the RTP/RTCP design document for details.
-*/
-#ifndef   RTP_ENCODE_H
-#define   RTP_ENCODE_H
-
-#include "rtp.h"
-#include "oscl_bin_stream.h"
-
-class RTP_Encode : public RTP_Base
-{
-    public:
-        OSCL_IMPORT_REF RTP_Encode(const RtpSsrc SSRC,
-                                   const RtpSeqType init_seq_offset,
-                                   const RtpTimeStamp init_ts_offset,
-                                   const RtpPayloadType in_payload_type,
-                                   const uint8 version = DEFAULT_RTPRTCP_VERSION);
-
-        OSCL_IMPORT_REF ~RTP_Encode();
-        OSCL_IMPORT_REF RtpStatus stuffHeaderInMemory(const RtpTimeStamp timestamp,
-                const bool marker_flag,
-                uint8 * rtp_header_ptr
-                                                     );
-        OSCL_IMPORT_REF void setPayloadType(const RtpPayloadType new_payload_type)
-        {
-            payload_type = new_payload_type;
-        };
-
-        OSCL_IMPORT_REF void setSeqNum(const RtpSeqType seq)
-        {
-            currSeqNum = seq;
-        };
-        OSCL_IMPORT_REF RtpSeqType getSeqNum()
-        {
-            return currSeqNum;
-        };
-    private:
-        OsclBinOStreamBigEndian outStream;
-        RtpSeqType   currSeqNum;
-        RtpTimeStamp currRtpTS;
-        RtpPayloadType payload_type;
-};
-
-#endif
diff --git a/protocols/rtp/src/rtp_packet.cpp b/protocols/rtp/src/rtp_packet.cpp
deleted file mode 100644
index 64a94c5..0000000
--- a/protocols/rtp/src/rtp_packet.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-
-
-#include "rtp_packet.h"
-#include "rtp_packet_impl.h"
-
-OSCL_EXPORT_REF
-RTPPacket::RTPPacket(RTPImplAllocator* in_alloc, void * hint)
-{
-    alloc = in_alloc;
-    rep = in_alloc->allocate(hint);
-}
-
-OSCL_EXPORT_REF
-RTPPacket::~RTPPacket()
-{
-    alloc->deallocate(rep);
-}
-
-OSCL_EXPORT_REF
-BufferFragment * RTPPacket::GetRTPHeader()
-{
-    return rep->GetRTPHeader();
-};
-
-OSCL_EXPORT_REF
-BufferFragment * RTPPacket::GetFragments()
-{
-    return rep->GetFragments();
-};
-
-MediaStatusClass::status_t RTPPacket::AddRTPFrag(const BufferFragment& frag, BufferState* buffer_state,
-        int32 location_offset)
-{
-    return rep->AddRTPFrag(frag, buffer_state, location_offset);
-}
-
-OSCL_EXPORT_REF MediaStatusClass::status_t RTPPacket::AddLocalRTPFrag(BufferFragment& fragment, int32 location_offset)
-{
-    return rep->AddLocalRTPFrag(fragment, location_offset);
-}
-
-
-OSCL_EXPORT_REF
-MediaStatusClass::status_t RTPPacket::GetLocalFragment(BufferFragment& fragment)
-{
-    return rep->GetLocalFragment(fragment);
-}
-
-OSCL_EXPORT_REF
-int RTPPacket::GetAvailableBufferSize()
-{
-    return rep->GetAvailableBufferSize();
-}
-
-void RTPPacket::Clear()
-{
-    rep->Clear();
-}
-
-MediaTimestamp RTPPacket::GetTimestamp()
-{
-    return rep->GetHdrTimestamp();
-};
-
-RtpSeqType RTPPacket::GetSN()
-{
-    return rep->GetSN();
-}
-
-MediaTimestamp RTPPacket::GetTimestampMS()
-{
-    return rep->GetTimestamp();
-}
-
-OSCL_EXPORT_REF
-void RTPPacket::SetTimestamp(MediaTimestamp& rtp_timestamp)
-{
-    rep->SetTimestamp(rtp_timestamp);
-}
-
-OSCL_EXPORT_REF
-void RTPPacket::SetTimestampMS(MediaTimestamp& rtp_timestamp)
-{
-    rep->SetTimestamp(rtp_timestamp);
-}
-
-
-OSCL_EXPORT_REF
-MediaStatusClass::status_t RTPPacket::AddAU(const AccessUnit *au)
-{
-    return rep->AddAU(au);
-}
-
-OSCL_EXPORT_REF
-uint32 RTPPacket::GetLength() const
-{
-    return rep->GetLength();
-}
-
-OSCL_EXPORT_REF
-void RTPPacket::AppendNext(RTPPacket *next_ptr)
-{
-    rep->AppendNext(next_ptr);
-}
-
-OSCL_EXPORT_REF
-RTPPacket* RTPPacket::GetNext() const
-{
-    return rep->GetNext();
-}
-
-OSCL_EXPORT_REF
-int32 RTPPacket::GetNumFrags() const
-{
-    return rep->GetNumFrags();
-}
-
-OSCL_EXPORT_REF
-int32 RTPPacket::GetMaxFrags() const
-{
-    return rep->GetMaxFrags();
-}
-
-OSCL_EXPORT_REF
-int RTPPacket::GetMediaSize() const
-{
-    return rep->GetMediaSize();
-}
-
-
-void RTPPacket::SetFreeBufferStatesWhenDone()
-{
-    rep->SetFreeBufferStatesWhenDone();
-}
-
-
-const uint8 RTP_MBIT_MASK = 0x01 << RTP_MARKER_FLAG_POSITION;
-void RTPPacket::SetMBit(const bool flag)
-{
-    BufferFragment * hdrFrag = GetRTPHeader();
-    uint8 tmpOctet = *(((uint8 *) hdrFrag->ptr) + 1);
-    if (flag && hdrFrag->ptr)
-    {
-        tmpOctet |= RTP_MBIT_MASK;
-    }
-    else
-    {
-        tmpOctet &= (~RTP_MBIT_MASK);
-    }
-    oscl_memcpy(((uint8 *) hdrFrag->ptr) + 1, &tmpOctet, sizeof(uint8));
-}
diff --git a/protocols/rtp/src/rtp_packet.h b/protocols/rtp/src/rtp_packet.h
deleted file mode 100644
index 433b482..0000000
--- a/protocols/rtp/src/rtp_packet.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-#ifndef RTP_PACKET_H
-#define RTP_PACKET_H
-
-
-#ifdef PV_OS_ZREX
-#include "zrex_os.h"
-#endif
-
-#include "oscl_media_data.h"
-#include "oscl_media_status.h"
-
-#include "access_unit.h"
-#include "rtp.h"
-
-
-// Constants controlling the size of the RTP packet container
-const int RTP_PACKET_MAX_FRAGMENTS = 30;
-const int RTP_PACKET_IMMEDIATE_DATA = 1500;
-const int DEF_RTP_MAX_PACKET_SIZE = 1024;
-
-class RTPPacketImplementation;
-typedef MemAllocator<RTPPacketImplementation> RTPImplAllocator;
-
-
-
-class RTPPacket
-{
-
-    public:
-
-
-        OSCL_IMPORT_REF RTPPacket(RTPImplAllocator* alloc, void * hint = 0);
-        OSCL_IMPORT_REF ~RTPPacket();
-
-        OSCL_IMPORT_REF MediaStatusClass::status_t AddRTPFrag(const BufferFragment& frag, BufferState* buffer_state,
-                int32 location_offset = APPEND_MEDIA_AT_END);
-        void Clear();
-
-        OSCL_IMPORT_REF BufferFragment * GetRTPHeader();
-
-        OSCL_IMPORT_REF BufferFragment * GetFragments();
-
-        OSCL_IMPORT_REF MediaStatusClass::status_t GetLocalFragment(BufferFragment& fragment);
-
-        OSCL_IMPORT_REF MediaStatusClass::status_t AddLocalRTPFrag(BufferFragment& fragment, int32 location_offset = APPEND_MEDIA_AT_END);
-
-        OSCL_IMPORT_REF MediaStatusClass::status_t AddAU(const AccessUnit* au);
-
-        OSCL_IMPORT_REF int GetAvailableBufferSize();
-
-        MediaTimestamp GetTimestamp();  // this method gets timestamp from header
-        RtpSeqType GetSN();              // gets Seq Num from header
-        MediaTimestamp GetTimestampMS();  // this method gets timestamp from member variable based on serverRealTimeClock
-
-        OSCL_IMPORT_REF void SetTimestamp(MediaTimestamp& rtp_timestamp);
-        OSCL_IMPORT_REF void SetTimestampMS(MediaTimestamp& rtp_timestamp);
-
-        OSCL_IMPORT_REF int32 GetNumFrags() const;
-        OSCL_IMPORT_REF int32 GetMaxFrags() const;
-        OSCL_IMPORT_REF uint32 GetLength() const;
-
-
-        OSCL_IMPORT_REF int GetMediaSize() const;
-
-        OSCL_IMPORT_REF void AppendNext(RTPPacket *next_ptr);
-
-        OSCL_IMPORT_REF RTPPacket* GetNext() const;
-
-        void SetFreeBufferStatesWhenDone();
-
-        void SetMBit(const bool flag);
-    private:
-        RTPImplAllocator * alloc;
-        RTPPacketImplementation *rep;
-
-
-
-};
-
-typedef MemAllocator<RTPPacket> RTPPacketAlloc;
-
-
-
-
-#endif
diff --git a/protocols/rtp/src/rtp_packet_impl.cpp b/protocols/rtp/src/rtp_packet_impl.cpp
deleted file mode 100644
index 41755eb..0000000
--- a/protocols/rtp/src/rtp_packet_impl.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "rtp_packet_impl.h"
-
-
-/* **********************************************
- *
- *  NOTE: Throughout this implementation, fragment number 0
- *  is reserved for the RTP Header.
- *
- * **********************************************/
-
-OSCL_EXPORT_REF
-RTPPacketImplementation::RTPPacketImplementation()
-        : free_buffer_states_when_done(false)
-{
-    // the default constructor for BufFragGroup takes care of other things
-    timestamp = 0;
-
-    num_fragments = 1;
-
-
-    fragments[0].ptr = localbuf;
-    length = fragments[0].len = RTP_HEADER_SIZE;
-    available_localbuf -= RTP_HEADER_SIZE;
-    buffer_states[0] = NULL;
-}
-
-
-RTPPacketImplementation::~RTPPacketImplementation()
-{
-    // decrement the ref count on all buffers
-    for (uint ii = 0; ii < num_fragments; ++ii)
-    {
-        if (buffer_states[ii])
-        {
-            buffer_states[ii]->decrement_refcnt();
-
-            if (free_buffer_states_when_done)
-            {
-                if (buffer_states[ii]->get_refcount() == 0)
-                {
-                    OSCL_DELETE(buffer_states[ii]);
-                    buffer_states[ii] = NULL;
-                }
-            }
-        }
-    }
-}
-
-
-MediaStatusClass::status_t RTPPacketImplementation::AddRTPFrag(const BufferFragment& frag, BufferState* buffer_state,
-        int32 location_offset)
-{
-    location_offset = (location_offset >= 0) ? location_offset + 1 : location_offset;
-    return AddFragment(frag, buffer_state, location_offset);
-}
-
-MediaStatusClass::status_t RTPPacketImplementation::AddLocalRTPFrag(const BufferFragment& frag, int32 location_offset)
-{
-    location_offset = (location_offset >= 0) ? location_offset + 1 : location_offset;
-    return AddLocalFragment(frag, location_offset);
-}
-
-MediaStatusClass::status_t RTPPacketImplementation::AddAU(const AccessUnit* au)
-{
-
-    if (!au)
-    {
-        return MediaStatusClass::NULL_INPUT;
-    }
-
-    // determine the number of access unit fragments and the total length
-    int32 au_frags = au->GetNumFrags();
-    BufferFragment frag;
-    BufferState* state_ptr;
-    MediaStatusClass::status_t status;
-
-    for (int ii = 0; ii < au_frags; ++ii)
-    {
-        au->GetMediaFragment(ii, frag, state_ptr);
-        if (frag.ptr == NULL || frag.len == 0)
-        {
-            continue;
-        }
-
-        if (!state_ptr)
-        {
-            // check if it is local
-            if (au->IsLocalData(frag))
-            {
-                // add as a local fragment
-                if ((status = AddLocalFragment(frag, APPEND_MEDIA_AT_END)) !=
-                        MediaStatusClass::BFG_SUCCESS)
-                {
-                    return status;
-                }
-                continue;
-            }
-        }
-
-        // add as a regular fragment
-        if ((status = AddFragment(frag, state_ptr, APPEND_MEDIA_AT_END)) !=
-                MediaStatusClass::BFG_SUCCESS)
-        {
-            return status;
-        }
-
-    }
-
-    return MediaStatusClass::BFG_SUCCESS;
-}
-
-const MediaTimestamp INVALID_TIMESTAMP = 0xFFFFFFFF;
-MediaTimestamp RTPPacketImplementation::GetHdrTimestamp()
-{
-    BufferFragment * hdr = GetRTPHeader();
-
-    if (NULL == hdr || NULL == hdr->ptr)
-        return 0xffff;
-
-    return * ((uint32 *) hdr->ptr + 1);
-}
-
diff --git a/protocols/rtp/src/rtp_packet_impl.h b/protocols/rtp/src/rtp_packet_impl.h
deleted file mode 100644
index ca698c0..0000000
--- a/protocols/rtp/src/rtp_packet_impl.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-#ifndef RTP_PACKET_IMPL_H
-#define RTP_PACKET_IMPL_H
-
-#include <stdlib.h>
-
-#ifdef PV_OS_ZREX
-#include "zrex_os.h"
-#endif
-
-#include "oscl_media_data.h"
-#include "oscl_media_status.h"
-
-#include "rtp_packet.h"
-//#include "pvserver_tunable.h"
-#include "access_unit.h"
-
-#include "rtp.h"
-
-#ifndef OSCL_MEM_H_INCLUDED
-#include "oscl_mem.h"
-#endif
-
-class RTPPacketImplementation : public MediaData<RTPPacket, RTP_PACKET_MAX_FRAGMENTS, RTP_PACKET_IMMEDIATE_DATA>
-{
-
-    public:
-        OSCL_IMPORT_REF // \todo: Check whether this is needed
-        RTPPacketImplementation();
-        virtual ~RTPPacketImplementation();
-
-        MediaStatusClass::status_t AddRTPFrag(const BufferFragment& frag, BufferState* buffer_state,
-                                              int32 location_offset);
-
-        MediaStatusClass::status_t AddLocalRTPFrag(const BufferFragment& frag, int32 location_offset);
-
-        BufferFragment * GetFragments()
-        {
-            return fragments;
-        };
-
-        BufferFragment * GetRTPHeader()
-        {
-            return fragments;
-        };
-
-        MediaStatusClass::status_t AddAU(const AccessUnit* au);
-
-        int GetMediaSize()
-        {
-            return (GetLength() - GetRTPHeader()->len);
-        }
-
-        MediaTimestamp GetHdrTimestamp();
-
-        RtpSeqType GetSN()
-        {
-            BufferFragment * hdr = GetRTPHeader();
-
-            if (NULL == hdr || NULL == hdr->ptr)
-                return 0xff;
-
-            return ((* ((uint32 *) hdr->ptr)) & RTP_SEQ_NUM_MASK);
-        }
-
-        void SetFreeBufferStatesWhenDone()
-        {
-            free_buffer_states_when_done = true;
-        }
-
-    private:
-
-        bool free_buffer_states_when_done;
-
-};
-
-
-class DefaultRTPPacketAlloc : public RTPPacketAlloc
-{
-    public:
-        DefaultRTPPacketAlloc(RTPImplAllocator * impl_alloc)
-        {
-            rtp_impl_alloc = impl_alloc;
-            num_freed = num_allocated = 0;
-        };
-
-        int get_num_allocated()
-        {
-            return num_allocated;
-        }
-        int get_num_freed()
-        {
-            return num_freed;
-        }
-
-        //
-        // The following will allocate a buffer to hold both RTPPacket object and the
-        // correspondign RTPPacketImplementation object.
-        //
-
-        // WINCE doesn't seem to support placement new in 3.0 so we are using plain old new and delete for now.
-        virtual RTPPacket* allocate(void * hint = 0, const int num_reserved_frags = 1)
-        {
-            num_allocated++;
-            return OSCL_NEW(RTPPacket, (rtp_impl_alloc, 0));
-        }
-
-        virtual void deallocate(RTPPacket* packet)
-        {
-            OSCL_DELETE(packet);
-            num_freed ++;
-        }
-    private:
-        RTPImplAllocator * rtp_impl_alloc;
-        int num_allocated;
-        int num_freed;
-};
-
-class DefaultRTPImplAllocator : public RTPImplAllocator
-{
-
-    public:
-
-        virtual RTPPacketImplementation * allocate(void * hint, const int num_reserved_frags = 1)
-        {
-            return new RTPPacketImplementation;
-        }
-
-        virtual void deallocate(pointer rtp_impl)
-        {
-            // do nothing: recall it was a placement new;
-            OSCL_DELETE(rtp_impl);
-        }
-
-
-};
-
-
-
-#endif
diff --git a/protocols/rtp/src/rtp_payload.cpp b/protocols/rtp/src/rtp_payload.cpp
deleted file mode 100644
index 95f6b95..0000000
--- a/protocols/rtp/src/rtp_payload.cpp
+++ /dev/null
@@ -1,752 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-//-*- c++ -*-
-//#include <stdio.h>
-
-#include "rtp_payload.h"
-#include "access_unit_impl.h"
-#include "au_utils.h"
-
-const int NUM_BITS_RESYNC_MARKER = 17;
-
-OSCL_EXPORT_REF RTPPacket * RtpPayloadHandler :: pack
-(const GAU* gau,
- int & n,  // n is the number of AUs processed
- RtpPayloadStatus & status_code)
-{
-    OSCL_UNUSED_ARG(n);
-
-    int num_aus = 0;
-    RTPPacket * rtp_packet_chain = NULL;
-    MediaStatusClass::status_t media_status;
-    DefaultAUImplAllocator * au_impl_alloc = new DefaultAUImplAllocator;
-
-    const AccessUnit * input_AU_chain =  Gau2AU(gau, au_impl_alloc, media_status);
-
-    rtp_packet_chain = packAU(input_AU_chain, num_aus, status_code);
-
-    // free the access units
-    const AccessUnit* au = input_AU_chain, *au_next = NULL;
-    while (au)
-    {
-        au_next = au->GetNext();
-        OSCL_DELETE(au);
-        au = au_next;
-    }
-    OSCL_DELETE(au_impl_alloc);
-    return rtp_packet_chain;
-}
-
-
-//
-// The following method searches backwards in the memory fragment group for a pattern, starting
-// from (starting_index, starting_frag_offset). If pattern is found, last_frag_index points to the
-// fragment containing the found pattern, and last_frag_offset is the pattern's offset.
-//
-// If no pattern is found between starting_index and (starting_index + search_range),
-// last_frag_index will be set to the index of the fragment containing
-// (starting_index + search_range); last_byte_offset will be set accordingly, too.
-//
-// It returns true if pattern is found, or boundary is reached.
-// Note:
-//    The pattern is assumed to start at beginning of some byte, but may have non-integral number of bytes.
-//
-bool SearchableRtpPayloadHandler::search_backwards_for_bit_pattern
-(
-    const AccessUnit & currentAU,
-    const uint16 starting_index,
-    const uint16 starting_frag_offset,
-    const int search_range,
-    const octet * pattern,
-    const uint16 num_bits,
-    uint16 & last_frag_index,
-    uint16 & last_byte_offset
-)
-{
-    int idx;
-    int offset;
-    octet * ptr;
-
-    idx = starting_index;
-    offset = starting_frag_offset;
-    bool boundaryReached;
-    if (!currentAU.seek(idx, offset, ptr, boundaryReached, search_range) && (NULL == ptr))
-    {
-        // UNCOND_LOGMSG(ERR_WARNING, ("currentAU.seek returned error. Some states are corrupted\n"));
-        return true;
-    }
-    if (boundaryReached)
-    {
-        last_frag_index = currentAU.GetNumFrags() - 1;
-        last_byte_offset = (uint16)(currentAU.GetMediaFragment(last_frag_index))->len;
-        return true;
-    }
-
-    last_frag_index = idx;
-    last_byte_offset = offset;
-
-    octet *tmp_ptr;
-    //
-    // The following is a sequential search scheme with a persistent state across subsequent
-    // invocations of the routine
-    //
-#define WITH_STATE 1
-#ifdef WITH_STATE
-    int match_state = num_bits / 8; // force all bits in pattern to be checked;
-    if (num_bits % 8)
-        match_state++;
-    while (0 != (match_state = currentAU.match_bit_pattern_with_state(idx, offset, pattern, (uint8) num_bits, match_state)))
-    {
-        // printf("\n\n Got match_state %d, idx %d, offset %d\n", match_state, idx, offset);
-        currentAU.seek(idx, offset, tmp_ptr, boundaryReached, -1*match_state);
-        if (boundaryReached)
-        {
-            //  last_frag_index = idx;
-            //      last_byte_offset = offset;
-            return true;
-        }
-
-//      if (idx <= 0 && offset <= 0) {
-        if (idx <= starting_index && offset <= starting_frag_offset)
-        {
-            // printf("back to begining idx <= 0 offset <= 0\n");
-            return true;
-        }
-
-    };
-#else
-    while (! currentAU.match_bit_pattern_no_state(idx, offset, pattern, num_bits))
-    {
-        // printf("Search backwards for pattern: trying to match pattern at offset = %d\n", offset);
-        if (!currentAU.seek(idx, offset, tmp_ptr, boundaryReached, -1))
-        {
-            // printf("Error encountered during seek \n");
-            return true;
-        };
-
-        if (!idx && !offset)
-        {
-//        printf("back to begining idx = offset = 0\n");
-            // last_frag_index = last_byte_offset = 0;
-            return true;
-        }
-
-        if (boundaryReached)
-        {
-            // last_frag_index = idx;
-            // last_byte_offset = offset;
-            return true;
-        }
-    };
-#endif
-
-    // printf("matched at idx = %d, offset = %d\n", idx, offset);
-    last_frag_index = idx;
-    last_byte_offset = offset;
-
-    return true;
-}
-
-OSCL_EXPORT_REF
-VariableAuSizePacketizer::
-VariableAuSizePacketizer(const RtpSsrc ssrc,
-                         const RtpPayloadType pt,
-                         RTPPacketAlloc * rtpAlloc,
-                         AccessUnitAlloc * accessUnitAlloc,
-                         const RtpSeqType init_seq_offset,
-                         const MediaTimestamp init_ts_offset,
-                         const int max_pckt_size,
-                         const int input_sample_rate,
-                         const int output_sample_rate,
-                         const bool mustSearchStartCode)
-        : SearchableRtpPayloadHandler(ssrc, pt, rtpAlloc, accessUnitAlloc, init_seq_offset, init_ts_offset, max_pckt_size),
-        needToSearchForStartCode(mustSearchStartCode),
-        packet_list_tail(NULL),
-        list_of_packets_to_send(NULL)
-{
-    resync_marker[0] = 0x00;
-    resync_marker[1] = 0x00;
-    resync_marker[2] = 0x80;
-    resync_marker[3] = 0x00;
-    uint32 inputSamplingRate;
-    if (input_sample_rate > 0)
-    {
-        inputSamplingRate = input_sample_rate;
-    }
-    else
-    {
-        //    int generate_a_log_here;
-        inputSamplingRate = DEF_INPUT_SAMPLING_RATE;
-    }
-
-    if (output_sample_rate > 0)
-    {
-        requiredOutputSamplingRate = output_sample_rate;
-    }
-    else
-    {
-        requiredOutputSamplingRate = inputSamplingRate;
-    }
-
-    init_timescale_conversion(inputSamplingRate, requiredOutputSamplingRate);
-
-    config_au_flag = false;
-};
-
-//uint8 VariableAuSizePacketizer::resync_marker[4] = {0x00, 0x00, 0x80, 0x00};
-
-
-MediaStatusClass::status_t VariableAuSizePacketizer::AddAU(const AccessUnit * au)
-{
-    if (!au)
-    {
-        //printf("Error: AddAU: au is NULL\n");
-        return MediaStatusClass::NULL_INPUT;
-    }
-
-    if (NULL == current_packet_ptr)
-    {
-        return MediaStatusClass::INTERNAL_ERROR;  //
-    }
-
-    // determine the number of access unit fragments and the total length
-    int32 au_frags = au->GetNumFrags();
-    BufferFragment tmp_fragment, frag, firstFrag;
-    BufferFragment* headerFrag;
-    BufferState* state_ptr;
-    MediaStatusClass::status_t status;
-    uint8 resync_marker[4] = {0x00, 0x00, 0x80, 0x00};
-
-    au->GetMediaFragment(0, firstFrag, state_ptr);
-    tmp_fragment.ptr = firstFrag.ptr;
-    tmp_fragment.len = firstFrag.len;
-    if (current_packet_ptr->GetMediaSize() == Rfc2429_PAYLOAD_HDR_SIZE)
-    {
-        headerFrag = &current_packet_ptr->GetFragments()[1]; // the first fragment is RTP header, the 2nd is Payload hdr
-        // set payload header
-        if ((oscl_memcmp(firstFrag.ptr, resync_marker, 2)) == 0 && ((uint8*)firstFrag.ptr)[2] & 0x80)
-        {
-            // its a start code. set the P bit
-            ((uint8*)headerFrag->ptr)[0] = 0x04;
-
-            // This format doesn't work on HP, because, strictly
-            // speaking, the left side is not a modifiable lvalue.
-            // ((uint8*)tmp_fragment.ptr)+=2;
-            // so, we do this:
-            tmp_fragment.ptr = ((uint8*)tmp_fragment.ptr) + 2;
-            tmp_fragment.len -= 2;
-        }
-    }
-    // check if it is local
-    if (au->IsLocalData(firstFrag))
-    {
-        // add as a local fragment
-        if ((status = current_packet_ptr->AddLocalRTPFrag(tmp_fragment, APPEND_MEDIA_AT_END)) != MediaStatusClass::BFG_SUCCESS)
-        {
-            return status;
-        }
-    }
-    else
-    {
-        // add as a regular fragment
-        if ((status = current_packet_ptr->AddRTPFrag(tmp_fragment, state_ptr, APPEND_MEDIA_AT_END)) != MediaStatusClass::BFG_SUCCESS)
-        {
-            return status;
-        }
-    }
-
-    for (int ii = 1; ii < au_frags; ++ii)
-    {
-        au->GetMediaFragment(ii, frag, state_ptr);
-        if (frag.ptr == NULL || frag.len == 0)
-        {
-            continue;
-        }
-
-        if (!state_ptr)
-        {
-            // check if it is local
-            if (au->IsLocalData(frag))
-            {
-                // add as a local fragment
-                if ((status = current_packet_ptr->AddLocalRTPFrag(frag, APPEND_MEDIA_AT_END)) !=
-                        MediaStatusClass::BFG_SUCCESS)
-                {
-                    return status;
-                }
-                continue;
-            }
-        }
-
-        // add as a regular fragment
-        if ((status = current_packet_ptr->AddRTPFrag(frag, state_ptr, APPEND_MEDIA_AT_END)) !=
-                MediaStatusClass::BFG_SUCCESS)
-        {
-            return status;
-        }
-    }
-
-    return MediaStatusClass::BFG_SUCCESS;
-}
-;  // AddAU
-
-
-RTPPacket * VariableAuSizePacketizer::getNewRtpPacket(const bool isRfc2429, RtpPayloadStatus & status_code)
-{
-    RTPPacket * new_packet_ptr = rtp_alloc->allocate();
-
-    if (NULL == new_packet_ptr)
-    {
-        // UNCOND_LOGMSG(ERR_ERROR, ("Packet allocation error. \n"));
-        return NULL;
-    }
-
-    if (isRfc2429)
-    {
-        // allocate payload header fragment
-        payload_header_fragment.len = Rfc2429_PAYLOAD_HDR_SIZE;
-        if (new_packet_ptr->GetLocalFragment(payload_header_fragment) != MediaStatusClass::BFG_SUCCESS)
-        {
-            //printf("error: failed to get local frag for ph \n");
-            status_code = MEM_ALLOC_FAILURE;
-            return NULL;
-        }
-        // set the header bytes to 0's
-        ((uint8*)payload_header_fragment.ptr)[0] = ((uint8*)payload_header_fragment.ptr)[1] = 0;
-
-        MediaStatusClass::status_t status;
-
-        if ((status = new_packet_ptr->AddLocalRTPFrag(payload_header_fragment, APPEND_MEDIA_AT_END)) !=
-                MediaStatusClass::BFG_SUCCESS)
-        {
-            status_code = ERROR_ADDING_TO_PACKET;
-            return NULL;
-        }
-        else
-        {
-            return new_packet_ptr;
-        }
-    }
-    else    // not Rfc2429, hence no payload header
-    {
-        return new_packet_ptr;
-    }
-}
-
-//
-// packAU returns the chain of RTP packets ready to be sent
-//
-OSCL_EXPORT_REF
-RTPPacket* VariableAuSizePacketizer::packAU(const AccessUnit * input_AU_chain,
-        const bool isRfc2429,
-        int & num_AU_processed,
-        RtpPayloadStatus & status_code)
-{
-#ifdef DEBUG_VOP_START_CODE
-    if (GetCurrentSeqNum() >= 15)
-    {
-        int tbd = 1;
-    }
-    else
-    {
-        //	printf ("PackAU: seq num is: %d\n", GetCurrentSeqNum());
-    }
-#endif
-
-    RTPPacket * tmp_packet_chain = NULL;
-    const AccessUnit * currentAU = input_AU_chain;
-    num_AU_processed = 0;
-    int k;
-    uint16 num_packets_made = 0; // was m: num of packets
-    MediaTimestamp rtp_timestamp;
-    status_code = RPH_SUCCESS;
-    bool mtbFlag = false;
-    packet_list_tail = list_of_packets_to_send = NULL;
-
-    { // base layer
-        while (currentAU)
-        {
-            rtp_timestamp = currentAU->GetTimestamp();
-            if (!isRfc2429)
-            {
-                // BufferFragment *tmp_buf = currentAU->GetCodecInfo();
-                // void *tmp_ptr = currentAU->GetCodecInfo()->ptr;
-                if (currentAU->GetCodecInfo() && currentAU->GetCodecInfo()->ptr &&
-                        ((* (uint32 *) currentAU->GetCodecInfo()->ptr) & 0x00010000))
-                    mtbFlag	= true;
-                else
-                    mtbFlag = false;
-
-                if (mtbFlag && !config_au_flag)
-                {
-
-#ifdef DEBUG_MTB
-//				printf("Found a positive MTB flag at seq num = %d\n", GetCurrentSeqNum());
-#endif
-                    // start a new packet if the AU has an MTB
-                    if (current_packet_ptr && current_packet_ptr->GetMediaSize() > 0)
-                    {
-                        num_packets_made++;
-                        this->closeCurrentPacket(current_packet_ptr,
-                                                 packet_list_tail,
-                                                 list_of_packets_to_send
-                                                );
-                    }
-                }
-                else
-                {
-#ifdef DEBUG_MTB
-                    //		printf("Found a negative MTB flag at seq num = %d\n", GetCurrentSeqNum());
-#endif
-                }
-            };
-
-
-            uint32 new_media_size = currentAU->GetLength();
-            if (config_au_flag && current_packet_ptr) // treat config_au as part of the first data AU
-                new_media_size += current_packet_ptr->GetMediaSize();
-
-            //      if (currentAU->GetLength() > (uint32) max_packet_size) {
-            if (new_media_size > (uint32) max_packet_size)
-            {
-                // if necessary, close the current packet
-                if (current_packet_ptr &&
-                        current_packet_ptr->GetMediaSize() > 0  &&
-                        !config_au_flag)
-                {
-                    num_packets_made++;
-                    this->closeCurrentPacket(current_packet_ptr,
-                                             packet_list_tail,
-                                             list_of_packets_to_send
-                                            );
-                }
-
-                // Try to break AU just before resync_marker
-                // This involves a pretty expensive search process
-                uint8 num_bits = NUM_BITS_RESYNC_MARKER;
-
-                rtp_timestamp = currentAU->GetTimestamp();
-
-                uint16 last_byte_offset;
-
-                uint16 last_frag_index;
-
-                uint16 starting_index = 0;
-                uint16 starting_frag_offset = 0;
-
-                //        uint16 num_of_fragments_in_AU = currentAU->GetNumFragments();
-                //  uint16 k; // stores the number of fragments in next packet
-
-                int32 num_bytes_left_in_AU = (int32) currentAU->GetLength();
-                int32 adjusted_max_packet_size; // used in seeking
-
-                //  printf("in the begining, num_bytes_left_in_AU is %d\n", num_bytes_left_in_AU);
-                while (num_bytes_left_in_AU > 0)
-                {
-                    if (NULL == current_packet_ptr)
-                    {
-                        current_packet_ptr = this->getNewRtpPacket(isRfc2429, status_code);
-                        if (NULL == current_packet_ptr)
-                        {
-                            tmp_packet_chain = list_of_packets_to_send;
-                            list_of_packets_to_send = NULL;
-                            packet_list_tail = NULL;
-                            return tmp_packet_chain;
-                        }
-                    }
-
-                    if (config_au_flag)
-                        adjusted_max_packet_size = max_packet_size - current_packet_ptr->GetMediaSize();
-                    else
-                        adjusted_max_packet_size = max_packet_size;
-
-                    if (needToSearchForStartCode)
-                    {
-                        //
-                        // The following search routine will return the position of the resync_marker;
-                        // If no resync_marker is found between starting_p and (starting_p + max_packet_size),
-                        // last_frag_index will be set to the index of the fragment containing
-                        // (starting_index + max_packet_size); last_frag_size will be set accordingly, too.
-                        //
-                        this->search_backwards_for_bit_pattern
-                        (*currentAU,
-                         starting_index,
-                         starting_frag_offset,
-                         adjusted_max_packet_size - sizeof(resync_marker),
-                         (octet *) & resync_marker,
-                         num_bits,
-                         last_frag_index,
-                         last_byte_offset
-                        );
-                    }
-                    else    // no need to search for start code
-                    {
-                        bool boundaryReached;
-                        int last_frag_index = starting_index;
-                        int last_byte_offset = starting_frag_offset;
-                        octet * tmp_ptr;  // should i inistialize tmp_ptr? No!
-                        boundaryReached = false;
-                        if (!currentAU->seek(last_frag_index, last_byte_offset, tmp_ptr, boundaryReached, adjusted_max_packet_size - sizeof(resync_marker)))
-                        {
-                            // printf("VariableAuSizePacketizer::packetAU(): currentAU.seek returned error. Some states are corrupted\n");
-                            return NULL;
-                        }
-
-                        if (boundaryReached)
-                        {
-                            last_frag_index = currentAU->GetNumFrags() - 1;
-                            last_byte_offset = (currentAU->GetMediaFragment(last_frag_index))->len;
-                        }
-                    }
-
-
-                    //     printf("\n\nreturned from search_backwards_for_bit_pattern()\n");
-                    BufferFragment tmp_fragment;
-                    BufferState * tmp_buf_state;
-                    currentAU->GetMediaFragment(starting_index, tmp_fragment, tmp_buf_state);
-                    tmp_fragment.ptr = (uint8 *)tmp_fragment.ptr + starting_frag_offset;
-                    if (starting_index == last_frag_index)
-                    {
-                        tmp_fragment.len = last_byte_offset - starting_frag_offset;
-                    }
-                    else
-                    {
-                        tmp_fragment.len += starting_frag_offset;
-                    }
-
-                    if (tmp_fragment.len <= 0)
-                    {
-                        // UNCOND_LOGMSG(ERR_ERROR, ("tmp_fragment.size = %d < 0. Force it to zero \n", tmp_fragment.len));
-                        tmp_fragment.len = 0;
-                    }
-
-                    num_bytes_left_in_AU -= tmp_fragment.len;
-
-                    // printf("When numPacketCreated = %d, Breaking a big AU of size %d, num_bytes_left_in_AU is %ld, config_au_flag is %d\n", num_packets_made, currentAU->GetLength(), num_bytes_left_in_AU, config_au_flag );
-
-                    if (isRfc2429 && starting_index == 0 &&
-                            starting_frag_offset == 0 &&
-                            tmp_fragment.len >= 3)
-                    {
-                        // set the h.263 payload header
-                        if ((oscl_memcmp(tmp_fragment.ptr, resync_marker, 2)) == 0 &&
-                                ((uint8*)tmp_fragment.ptr)[2] & 0x80)
-                        {
-                            BufferFragment*  headerFrag = &current_packet_ptr->GetFragments()[1];
-                            // its a start code. set the P bit
-                            ((uint8*)headerFrag->ptr)[0] = 0x04;
-
-                            // This format doesn't work on HP, because, strictly
-                            // speaking, the left side is not a modifiable lvalue.
-                            // ((uint8*)tmp_fragment.ptr)+=2;
-                            // so, we do this:
-                            tmp_fragment.ptr = ((uint8*)tmp_fragment.ptr) + 2;
-                            tmp_fragment.len -= 2;
-                        }
-                    } // end isRfc2429
-
-                    /*printf("When m = %d, Breaking a big AU of size %d, num_bytes_left_in_AU is %d, this payload size is now %d\n",m, currentAU->GetLength(),
-                    num_bytes_left_in_AU, payload_size);*/
-
-                    current_packet_ptr->AddRTPFrag(tmp_fragment, tmp_buf_state);
-
-                    if (last_frag_index > starting_index)
-                    {
-                        k = last_frag_index - starting_index + 1;
-
-                        for (int ii = 1; ii < k - 1; ii++)
-                        {
-                            currentAU->GetMediaFragment(starting_index + ii, tmp_fragment, tmp_buf_state);
-                            current_packet_ptr->AddRTPFrag(tmp_fragment, tmp_buf_state);
-                            num_bytes_left_in_AU -= tmp_fragment.len;
-                        }
-
-                        if (last_frag_index > starting_index && last_byte_offset > 0)
-                        {
-                            currentAU->GetMediaFragment(last_frag_index, tmp_fragment, tmp_buf_state);
-                            tmp_fragment.len = last_byte_offset;
-                            num_bytes_left_in_AU -= tmp_fragment.len;
-                            current_packet_ptr->AddRTPFrag(tmp_fragment, tmp_buf_state);
-                        }
-                    }
-
-                    starting_index = last_frag_index;
-                    starting_frag_offset = last_byte_offset;
-
-                    // num_bytes_left_in_AU -= current_packet_ptr->GetMediaSize(); this logic erroneously counted H263 header bytes
-
-                    //printf("Closing a packet with payload size = %d, , num_bytes_left_in_AU = %d\n", current_packet_ptr->GetMediaSize(), num_bytes_left_in_AU);
-
-                    // current_packet_ptr->SetTimestamp(rtp_timestamp);
-                    if (!config_au_flag)
-                    {
-                        if (num_bytes_left_in_AU <= 0)
-                        {
-                            this->StuffRtpHeaderNRtpRtc(current_packet_ptr,
-                                                        rtp_timestamp,
-                                                        true); // MBIT is 1
-                        }
-                        else
-                        {
-                            this->StuffRtpHeaderNRtpRtc(current_packet_ptr,
-                                                        rtp_timestamp,
-                                                        false); // MBIT is 0
-                        }
-                    }
-                    else
-                    {
-                        if (num_bytes_left_in_AU <= 0)
-                        {
-                            current_packet_ptr->SetMBit(true);
-                        }
-                        else
-                        {
-                            current_packet_ptr->SetMBit(false);
-                        }
-                        current_packet_ptr->SetTimestamp(rtp_timestamp);
-                    }
-                    num_packets_made++;
-                    this->closeCurrentPacket(current_packet_ptr,
-                                             packet_list_tail,
-                                             list_of_packets_to_send
-                                            );
-
-                    if (config_au_flag)
-                        config_au_flag = false;
-                }      // while loop
-            }
-            else   // no need to fragment the AU
-            {
-                // put AU in current RTP packet
-                if (config_au_flag && current_packet_ptr)
-                {
-                    /*
-                    this->StuffRtpHeaderNRtpRtc(current_packet_ptr,
-                    						  rtp_timestamp,
-                    						  true
-                    						  ); // MBIT is 1
-                    */
-                    current_packet_ptr->SetMBit(true);
-
-                    config_au_flag = false;
-                }
-
-                if (current_packet_ptr)
-                {
-                    if (((uint32) max_packet_size - current_packet_ptr->GetMediaSize()) < currentAU->GetLength())
-                    {
-                        num_packets_made++;
-                        this->closeCurrentPacket(current_packet_ptr,
-                                                 packet_list_tail,
-                                                 list_of_packets_to_send);
-                    }
-                }
-
-
-                if (NULL == current_packet_ptr)
-                {
-                    current_packet_ptr = this->getNewRtpPacket(isRfc2429, status_code);
-
-                    if (NULL == current_packet_ptr)
-                    {
-                        tmp_packet_chain = list_of_packets_to_send;
-                        list_of_packets_to_send = NULL;
-                        packet_list_tail = NULL;
-                        return tmp_packet_chain;
-                    }
-
-                    this->StuffRtpHeaderNRtpRtc(current_packet_ptr,
-                                                rtp_timestamp,
-                                                true); // MBIT is 1
-                }
-                if (isRfc2429)
-                {
-                    this->AddAU(currentAU);
-                }
-                else
-                {
-                    current_packet_ptr->AddAU(currentAU);
-                }
-            }// AU size is less than max packet size
-
-            num_AU_processed++;   // increment the number of AU's processed
-            currentAU = currentAU->GetNext();
-            if (config_au_flag)
-                config_au_flag = false;
-        } // while (currentAU != NULL)
-    } // else (is_base_layer == true)
-
-    // when only one packect is made, Ling
-    if (list_of_packets_to_send == 0 && current_packet_ptr != 0)
-    {
-        num_packets_made++;
-        this->closeCurrentPacket(current_packet_ptr,
-                                 packet_list_tail,
-                                 list_of_packets_to_send);
-    }
-
-    tmp_packet_chain = list_of_packets_to_send;
-    list_of_packets_to_send = NULL;
-    packet_list_tail = NULL;
-    return tmp_packet_chain;
-};
-
-
-#if 0
-// need a single routine to dynamically load packers
-RtpPayloadHandler * maker_of_rtp_packer
-(RTPPacketAlloc * rtpAlloc,
- AccessUnitAlloc * accessUnitAlloc,
- const uint16 max_pckt_size
-)
-{
-    return new Rfc3016VideoPacker(rtpAlloc,
-                                  accessUnitAlloc,
-                                  max_pckt_size);
-}
-#endif
-
-OSCL_EXPORT_REF
-RtpPayloadHandler::RtpPayloadStatus  RtpPayloadHandler :: packConfigAU(const AccessUnit * config_au)
-{
-
-    if (NULL != current_packet_ptr)
-    {
-        return CONFIG_HEADER_MUST_START_A_PACKET;
-    }
-
-
-    current_packet_ptr = rtp_alloc->allocate();
-
-    if (NULL == current_packet_ptr)
-    {
-
-        return MEM_ALLOC_FAILURE ;
-    }
-
-    this->StuffRtpHeaderNRtpRtc(current_packet_ptr,
-                                config_au->GetTimestamp(),
-                                false); // MBIT is 0
-
-    current_packet_ptr->AddAU(config_au);
-
-    this->config_au_flag = true;
-
-    return RPH_SUCCESS;
-
-}
diff --git a/protocols/rtp/src/rtp_payload.h b/protocols/rtp/src/rtp_payload.h
deleted file mode 100644
index 002afa6..0000000
--- a/protocols/rtp/src/rtp_payload.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-// -*- c++ -*-
-#ifndef __RTP_PAYLOAD_H
-#define __RTP_PAYLOAD_H
-#if defined(PV_OS_UNIX)
-#include <dlfcn.h>
-#endif
-
-#ifdef PV_OS_ZREX
-#include "zrex_os.h"
-#endif
-
-#include "oscl_string.h"
-
-#include "oscl_media_data.h"
-#include "media_clock_converter.h"
-
-#include "access_unit.h"
-#include "rtp_packet.h"
-#include "rtp_encode.h"
-#include "pv_gau.h"
-#include "oscl_time.h"
-
-/* - - - - - - - - - - - - - - - -  -- - - - - - -  - - - - - - - - - - - - - -*/
-/* --------  Constants ----------------------*/
-const int INVALID_SAMPLING_RATE = 0;
-const int DEF_INPUT_SAMPLING_RATE = 1000;
-
-#define DEF_TOC_CHUNK_SIZE 10
-
-typedef int * (* malloc_function_ptr_t)(const size_t size);
-
-/** @name RtpPayloadHandler packs a chain of AccessUnit into the payload of one or more RTP packets.
-    One instance of this class is associated with one streaming client session.
-*/
-
-class RtpPayloadHandler
-{
-    public:
-        typedef enum
-        {
-            RPH_SUCCESS = 0,
-            BAD_INPUT_FORMAT = 1,
-            MEM_ALLOC_FAILURE = 2,
-            MEDIA_DATA_ERROR = 3,
-            TOO_BIG_FOR_PACKET = 4,
-            ERROR_ADDING_TO_PACKET = 5,
-            ERROR_GETTING_LOCAL_BUFFER = 6,
-            CONFIG_HEADER_MUST_START_A_PACKET = 7
-        } RtpPayloadStatus;
-
-
-
-        //
-        // Method "pack" returns a pointer to RTPPacket which links to other RTPPackets via next pointer.
-        // It also updates a status code.
-        //
-        OSCL_IMPORT_REF virtual RTPPacket * pack(const GAU * gau,
-                int& out_number_processed,
-                RtpPayloadStatus & status_code);
-
-        virtual RTPPacket * packAU(const AccessUnit * input_AU_chain,
-                                   int& out_number_processed,
-                                   RtpPayloadStatus & status_code) = 0;
-
-        virtual RTPPacket* flush(RtpPayloadStatus & status_code) = 0;
-
-        inline void set_max_packet_size(const uint16 n)
-        {
-            max_packet_size = n;
-        };
-        inline void set_payload_type(const uint8 in_PT)
-        {
-            rtp_encoder.setPayloadType(in_PT);
-        };
-        inline void set_rtp_seqnum(const RtpSeqType n)
-        {
-            rtp_encoder.setSeqNum(n);
-        };
-        inline void set_rtp_timestamp(const MediaTimestamp t)
-        {
-            currRtpTime = t;
-        };
-        void set_SSRC(const RtpSsrc n)
-        {
-            rtp_encoder.SetSSRC(n);
-        };
-
-
-        inline void set_malloc_function_ptr(malloc_function_ptr_t fn)
-        {
-            malloc_fn_ptr = fn;
-        };
-
-        RtpPayloadHandler(const RtpSsrc ssrc,
-                          const RtpPayloadType pt,
-                          RTPPacketAlloc * rtpAlloc = NULL,
-                          AccessUnitAlloc * accessUnitAlloc = NULL,
-                          const RtpSeqType init_seq_offset = 0,
-                          const MediaTimestamp init_ts_offset = 0,
-                          const uint16 max_pckt_size = DEF_RTP_MAX_PACKET_SIZE
-                         ) :
-
-                rtp_encoder(ssrc, init_seq_offset, init_ts_offset,  pt)
-        {
-            rtp_alloc = rtpAlloc;
-            access_unit_alloc = accessUnitAlloc;
-            max_packet_size = max_pckt_size;
-
-            requiredOutputSamplingRate = INVALID_SAMPLING_RATE;
-
-            rtpRtcOffset = 0;
-
-            init_rtp_ts_offset = init_ts_offset;
-            currRtpTime = init_ts_offset;
-
-            config_au_flag = false;
-            current_packet_ptr = NULL;
-        };
-
-        virtual ~RtpPayloadHandler()
-        {
-        };
-
-        void setInputSamplingRate(const int inputRate)
-        {
-            if (inputRate > 0)
-                media_clock_converter.set_timescale(inputRate);
-        }
-
-
-        // the following should be overloaded by derived classes
-        inline virtual int getRequiredRTPSamplingRate()
-        {
-            return INVALID_SAMPLING_RATE;
-        }
-
-        void setRtpRtcOffset(const MediaTimestamp offset)
-        {
-            rtpRtcOffset = offset;
-        }
-
-        void OpenPlayRange(const MediaTimestamp start_timeMS)
-        {
-            media_clock_converter.set_clock_other_timescale(start_timeMS, 1000);
-
-        }
-        void ClosePlayRange(const MediaTimestamp stop_timeMS)
-        {
-            uint32 timediff =
-                media_clock_converter.get_timediff_and_update_clock(stop_timeMS, 1000,
-                        requiredOutputSamplingRate);
-            currRtpTime += timediff;
-
-        }
-
-        MediaTimestamp GetCurrentRtpTS()
-        {
-            return currRtpTime;
-        };
-        RtpSeqType GetCurrentSeqNum()
-        {
-            return rtp_encoder.getSeqNum();
-        };
-
-        MediaTimestamp elapsedTime2RtpTS(const MediaTimestamp init_rtp_ts,  // RTP TS at begining of play session
-                                         const TimeValue elapsedTime)
-        {
-            MediaTimestamp tmp = init_rtp_ts;
-            tmp += elapsedTime.to_msec() * (uint32)(requiredOutputSamplingRate / 1000);
-            return tmp;
-        }
-
-        OSCL_IMPORT_REF virtual RtpPayloadStatus packConfigAU(const AccessUnit * config_au);
-
-    protected:
-        //
-        // call this if output rate is fixed. For example, for AMR/EVRC, output has to be 8K Hz
-        void init_with_input_sampling_rate(const int input_sample_rate)
-        {
-            uint32 inputSamplingRate;
-            if (input_sample_rate > 0)
-            {
-                inputSamplingRate = input_sample_rate;
-            }
-            else
-            {
-                inputSamplingRate = DEF_INPUT_SAMPLING_RATE;
-                //      int look_here_to_generate_error_log;
-            }
-
-            media_clock_converter.set_timescale(inputSamplingRate);
-
-        }
-
-        //
-        // call this if output rate is not fixed. For example, for RFC3016, output does not have to be 90000
-        void init_timescale_conversion(const int input_sample_rate,
-                                       const int output_sample_rate)
-        {
-            uint32 inputSamplingRate;
-            // if (inputSamplingRate > 0) {
-            if (input_sample_rate > 0)
-            {
-                inputSamplingRate = input_sample_rate;
-            }
-            else
-            {
-                //      int generate_a_log_here;
-                inputSamplingRate = DEF_INPUT_SAMPLING_RATE;
-            }
-
-            if (output_sample_rate > 0)
-            {
-                requiredOutputSamplingRate = output_sample_rate;
-            }
-            else
-            {
-                requiredOutputSamplingRate = inputSamplingRate;
-            }
-
-            media_clock_converter.set_timescale(inputSamplingRate);
-        }
-
-        void StuffRtpHeaderNRtpRtc
-        (
-            RTPPacket * packet,
-            const MediaTimestamp normalPlayTime, // from AU
-            const bool MBit
-        )
-        {
-            BufferFragment * rtp_header = packet->GetRTPHeader();
-            uint32 timediff =
-                media_clock_converter.get_timediff_and_update_clock(normalPlayTime,
-                        requiredOutputSamplingRate);
-
-            /* printf("Normal play time = %ld, timediff = %ld, currRtpTime = %ld\n",
-               normalPlayTime, timediff, currRtpTime); */
-            currRtpTime += timediff;
-
-            rtp_encoder.stuffHeaderInMemory(currRtpTime, MBit, (uint8 *)rtp_header->ptr);
-
-            // SetTimestamp in RTPPacket as well, after adding the RTP_RTC offset
-            RtpTimeStamp tsMS = media_clock_converter.get_converted_ts(1000);
-            tsMS += rtpRtcOffset;
-            packet->SetTimestamp(tsMS);
-        }
-
-        RTP_Encode rtp_encoder;
-        uint16 max_packet_size;
-
-        // MediaTimestamp timestamp_offset;
-        MediaTimestamp rtpRtcOffset; // RTP Real Time Clock offset at the begining of "play" command
-
-        // uint16 next_seqnum;
-
-        AccessUnitAlloc      * access_unit_alloc;
-        RTPPacketAlloc     * rtp_alloc;
-        malloc_function_ptr_t malloc_fn_ptr;
-
-        uint32 requiredOutputSamplingRate;  // as required by RFCs. For instance, AMR RFC requires 8K sampling rate
-
-
-
-        MediaClockConverter media_clock_converter;  // current normal play time in inputSamplingRate
-
-        MediaTimestamp init_rtp_ts_offset;
-
-        MediaTimestamp currRtpTime;
-
-        bool config_au_flag;
-        RTPPacket * current_packet_ptr;
-};
-
-typedef RtpPayloadHandler * (* maker_of_rtp_payload_module_t)();
-
-class SearchableRtpPayloadHandler : public RtpPayloadHandler
-{
-    public:
-        SearchableRtpPayloadHandler(const RtpSsrc ssrc,
-                                    const RtpPayloadType pt,
-                                    RTPPacketAlloc * rtpAlloc = NULL,
-                                    AccessUnitAlloc * accessUnitAlloc = NULL,
-                                    const RtpSeqType init_seq_offset = 0,
-                                    const MediaTimestamp init_ts_offset = 0,
-                                    const uint16 max_pckt_size = DEF_RTP_MAX_PACKET_SIZE) :
-                RtpPayloadHandler(ssrc, pt, rtpAlloc, accessUnitAlloc, init_seq_offset, init_ts_offset, max_pckt_size)
-        {};
-
-        virtual RTPPacket * packAU(const AccessUnit * input_AU_chain,
-                                   int& out_number_processed,
-                                   RtpPayloadStatus & status_code) = 0;
-
-
-        virtual RTPPacket * flush(RtpPayloadStatus & status_code) = 0;
-
-    protected:
-
-        //
-        // The following method searches backwards in the memory fragment group for a pattern, starting
-        // from (starting_index, starting_frag_offset). If pattern is found, last_frag_index points to the
-        // fragment containing the found pattern, and last_byte_offset is the pattern's offset.
-        //
-        // If no pattern is found between starting_index and (starting_index + max_packet_size),
-        // last_frag_index will be set to the index of the fragment containing
-        // (starting_index + max_packet_size); last_byte_offset will be set accordingly, too.
-        //
-        // It returns the number of fragments between starting_index and last_frag_index.
-        // Note:
-        //    The pattern is assumed to start at beginning of some byte, but may have non-integral number of bytes.
-        //
-        bool search_backwards_for_bit_pattern
-        (
-            const AccessUnit & currentAU,
-            const uint16 starting_index,
-            const uint16 starting_frag_offset,
-            const int max_packet_size,
-            const octet * pattern,
-            const uint16 num_bits,
-            uint16 & last_frag_index,
-            uint16 & last_byte_offset
-        );
-};
-
-const int DEFAULT_IETF_VIDEO_SAMPLING_RATE = 90000;  // in HZ
-const int DEFAULT_PVA_VIDEO_INPUT_SAMPLING_RATE = 1000;  // in HZ
-const int Rfc2429_PAYLOAD_HDR_SIZE = 2;
-
-class VariableAuSizePacketizer : public SearchableRtpPayloadHandler
-{
-    public:
-        OSCL_IMPORT_REF
-        VariableAuSizePacketizer(const RtpSsrc ssrc,
-                                 const RtpPayloadType pt,
-                                 RTPPacketAlloc * rtpAlloc,
-                                 AccessUnitAlloc * accessUnitAlloc = NULL,
-                                 const RtpSeqType init_seq_offset = 0,
-                                 const MediaTimestamp init_ts_offset = 0,
-                                 const int max_pckt_size = DEF_RTP_MAX_PACKET_SIZE,
-                                 const int input_sample_rate = DEFAULT_PVA_VIDEO_INPUT_SAMPLING_RATE,
-                                 const int output_sample_rate = DEFAULT_IETF_VIDEO_SAMPLING_RATE,
-                                 const bool mustSearchStartCode = true);
-
-        virtual RTPPacket * packAU(const AccessUnit * input_AU_chain,
-                                   int& out_number_processed,
-                                   RtpPayloadStatus & status_code) = 0;
-
-
-
-        virtual RTPPacket * flush(RtpPayloadStatus & status_code)
-        {
-            RTPPacket * packetPtr;
-            status_code = RtpPayloadHandler::RPH_SUCCESS;
-            if (!list_of_packets_to_send)
-            {
-                if (!current_packet_ptr)
-                {
-                    packetPtr = NULL;
-                }
-                else if (current_packet_ptr->GetMediaSize() > 0)   // this is the only packet created
-                {
-                    packetPtr = current_packet_ptr;
-                    current_packet_ptr = NULL;
-                }
-                else
-                {
-                    packetPtr = NULL;
-                }
-            }
-            else
-            {
-                if (NULL != current_packet_ptr)
-                {
-                    if (current_packet_ptr->GetMediaSize() > 0)
-                    {
-                        packet_list_tail->AppendNext(current_packet_ptr);
-                        packet_list_tail = current_packet_ptr;
-                    }
-                }
-                packetPtr = list_of_packets_to_send;
-                list_of_packets_to_send = NULL;
-                packet_list_tail = NULL;
-                current_packet_ptr = NULL;
-            }
-            return packetPtr;
-        };
-
-        void closeCurrentPacket(
-            RTPPacket * & current_packet_ptr,
-            RTPPacket * & packet_list_tail,
-            RTPPacket * & packet_list_head
-        );
-
-        OSCL_IMPORT_REF RTPPacket * packAU(const AccessUnit * input_AU_chain,
-                                           const bool isRfc2429,
-                                           int& out_number_processed,
-                                           RtpPayloadStatus & status_code);
-
-
-    protected:
-
-
-        RTPPacket * getNewRtpPacket(const bool isRfc2429, RtpPayloadStatus & status_code);
-        MediaStatusClass::status_t AddAU(const AccessUnit * au);
-
-        bool needToSearchForStartCode;
-        bool needToChopTwoBytesFromStartCode;
-        // static
-        uint8 resync_marker[4];
-
-
-        RTPPacket * packet_list_tail;
-        RTPPacket * list_of_packets_to_send;
-
-        // only useful for Rfc2429 at the present, TZ Setp. 2001
-        BufferFragment payload_header_fragment;
-}; // VariableAuSizePacketizer
-
-
-inline void VariableAuSizePacketizer :: closeCurrentPacket
-(
-    RTPPacket * & current_packet_ptr,
-    RTPPacket * & packet_list_tail,
-    RTPPacket * & packet_list_head
-)
-{
-    if (!packet_list_head)   // this is the first packet created
-    {
-        packet_list_tail = packet_list_head = current_packet_ptr;
-
-    }
-    else
-    {
-        packet_list_tail->AppendNext(current_packet_ptr);
-        packet_list_tail = current_packet_ptr;
-    }
-
-    current_packet_ptr = NULL;
-};
-
-#endif  // __RTP_PAYLOAD_H
diff --git a/protocols/rtp/src/rtprtcp.h b/protocols/rtp/src/rtprtcp.h
index a23c8de..a6cc8af 100644
--- a/protocols/rtp/src/rtprtcp.h
+++ b/protocols/rtp/src/rtprtcp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/Android.mk b/protocols/rtp_payload_parser/Android.mk
index 4aca2c9..3c4b45c 100644
--- a/protocols/rtp_payload_parser/Android.mk
+++ b/protocols/rtp_payload_parser/Android.mk
@@ -2,63 +2,72 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/../rfc_2429/src/h263_payload_parser.cpp \
-	src/../rfc_2429/src/h263_payload_parser_factory.cpp \
-	src/../rfc_3016/src/m4v_payload_parser.cpp \
-	src/../rfc_3016/src/m4v_payload_parser_factory.cpp \
-	src/../rfc_3016/src/m4v_audio_payload_parser.cpp \
-	src/../rfc_3016/src/m4v_audio_payload_parser_factory.cpp \
-	src/../rfc_3267/src/bit_util.cpp \
-	src/../rfc_3267/src/amr_payload_parser.cpp \
-	src/../rfc_3267/src/amr_payload_parser_factory.cpp \
-	src/../rfc_3984/src/h264_payload_parser.cpp \
-	src/../rfc_3984/src/h264_payload_parser_factory.cpp \
-	src/../rfc_3640/src/rfc3640_payload_parser_factory.cpp \
-	src/../rfc_3640/src/rfc3640_payload_parser.cpp \
-	src/sequence_gen.cpp
+	src/rtp_payload_parser_base.cpp \
+ 	src/sequence_gen.cpp \
+ 	src/../rfc_2429/src/h263_payload_parser.cpp \
+ 	src/../rfc_2429/src/h263_payload_parser_factory.cpp \
+ 	src/../rfc_3016/src/m4v_payload_parser.cpp \
+ 	src/../rfc_3016/src/m4v_payload_parser_factory.cpp \
+ 	src/../rfc_3016/src/m4v_audio_payload_parser.cpp \
+ 	src/../rfc_3016/src/m4v_audio_payload_parser_factory.cpp \
+ 	src/../rfc_3267/src/bit_util.cpp \
+ 	src/../rfc_3267/src/amr_payload_parser.cpp \
+ 	src/../rfc_3267/src/amr_payload_parser_factory.cpp \
+ 	src/../rfc_3640/src/rfc3640_payload_parser_factory.cpp \
+ 	src/../rfc_3640/src/rfc3640_payload_parser.cpp \
+ 	src/../rfc_3984/src/h264_payload_parser.cpp \
+ 	src/../rfc_3984/src/h264_payload_parser_factory.cpp
+
+
+LOCAL_MODULE := librtppayloadparser
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
 
-LOCAL_MODULE := librtppayloadparser_3gpp
+LOCAL_STATIC_LIBRARIES := 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/rtp_payload_parser/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/src \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_3016/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_3267/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_3016/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_2429/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_3984/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_3984/src \
-	$(PV_TOP)//protocols/rtp_payload_parser/rfc_3640/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/../../pvmi/pvmf/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/../../protocols/sdp/common/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/../../baselibs/gen_data_structures/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/protocols/rtp_payload_parser/src \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3016/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3267/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3016/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_2429/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3984/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/asf/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3984/src \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/realmedia/include \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/rfc_3640/include \
+ 	$(PV_TOP)/fileformats/asf/parser/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/pvmi/realaudio_deinterleaver/include \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_TOP)/fileformats/rmff_type_specific_data_parser/src \
+ 	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/bit_util.h \
-	include/payload_parser.h \
-	include/payload_parser_factory.h \
-	include/payload_parser_registry.h \
-	include/../rfc_2429/include/h263_payload_parser.h \
-	include/../rfc_2429/include/h263_payload_parser_factory.h \
-	include/../rfc_3016/include/m4v_payload_parser.h \
-	include/../rfc_3016/include/m4v_payload_parser_factory.h \
-	include/../rfc_3016/include/m4v_audio_payload_parser.h \
-	include/../rfc_3016/include/m4v_audio_payload_parser_factory.h \
-	include/../rfc_3267/include/amr_payload_parser.h \
-	include/../rfc_3267/include/amr_payload_parser_factory.h \
-	include/../rfc_3984/include/h264_payload_parser.h \
-	include/../rfc_3984/include/h264_payload_parser_factory.h \
-	include/../rfc_3640/include/rfc3640_payload_parser.h \
-	include/../rfc_3640/include/rfc3640_payload_parser_factory.h \
-	include/sequence_gen.h
+ 	include/payload_parser.h \
+ 	include/payload_parser_factory.h \
+ 	include/payload_parser_registry.h \
+ 	include/sequence_gen.h \
+ 	include/../rfc_2429/include/h263_payload_parser.h \
+ 	include/../rfc_2429/include/h263_payload_parser_factory.h \
+ 	include/../rfc_3016/include/m4v_payload_parser.h \
+ 	include/../rfc_3016/include/m4v_payload_parser_factory.h \
+ 	include/../rfc_3016/include/m4v_audio_payload_parser.h \
+ 	include/../rfc_3016/include/m4v_audio_payload_parser_factory.h \
+ 	include/../rfc_3267/include/amr_payload_parser.h \
+ 	include/../rfc_3267/include/amr_payload_parser_factory.h \
+ 	include/../rfc_3640/include/rfc3640_payload_parser.h \
+ 	include/../rfc_3640/include/rfc3640_payload_parser_factory.h \
+ 	include/../rfc_3984/include/h264_payload_parser.h \
+ 	include/../rfc_3984/include/h264_payload_parser_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/rtp_payload_parser/build/linux_3gpp/local.mk b/protocols/rtp_payload_parser/build/linux_3gpp/local.mk
new file mode 100644
index 0000000..e248da5
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/linux_3gpp/local.mk
@@ -0,0 +1,54 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := rtppayloadparser_3gpp
+
+
+
+
+XINCDIRS +=  ../../rfc_3016/include  ../../rfc_3267/include  ../../rfc_3016/include  ../../rfc_2429/include  ../../rfc_3984/include  ../../rfc_3984/src  ../../rfc_3640/include 
+XINCDIRS += ../../../../pvmi/pvmf/include ../../../../protocols/sdp/common/include  ../../../../baselibs/gen_data_structures/src 
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := ../rfc_2429/src/h263_payload_parser.cpp \
+	../rfc_2429/src/h263_payload_parser_factory.cpp \
+	../rfc_3016/src/m4v_payload_parser.cpp \
+	../rfc_3016/src/m4v_payload_parser_factory.cpp \
+	../rfc_3016/src/m4v_audio_payload_parser.cpp \
+	../rfc_3016/src/m4v_audio_payload_parser_factory.cpp \
+	../rfc_3267/src/bit_util.cpp \
+	../rfc_3267/src/amr_payload_parser.cpp \
+	../rfc_3267/src/amr_payload_parser_factory.cpp \
+	../rfc_3984/src/h264_payload_parser.cpp \
+	../rfc_3984/src/h264_payload_parser_factory.cpp \
+	../rfc_3640/src/rfc3640_payload_parser_factory.cpp \
+	../rfc_3640/src/rfc3640_payload_parser.cpp \
+	 sequence_gen.cpp
+
+HDRS := bit_util.h \
+	payload_parser.h \
+	payload_parser_factory.h \
+	payload_parser_registry.h \
+	../rfc_2429/include/h263_payload_parser.h \
+	../rfc_2429/include/h263_payload_parser_factory.h \
+	../rfc_3016/include/m4v_payload_parser.h \
+	../rfc_3016/include/m4v_payload_parser_factory.h \
+	../rfc_3016/include/m4v_audio_payload_parser.h \
+	../rfc_3016/include/m4v_audio_payload_parser_factory.h \
+	../rfc_3267/include/amr_payload_parser.h \
+	../rfc_3267/include/amr_payload_parser_factory.h \
+	../rfc_3984/include/h264_payload_parser.h \
+	../rfc_3984/include/h264_payload_parser_factory.h \
+	../rfc_3640/include/rfc3640_payload_parser.h \
+	../rfc_3640/include/rfc3640_payload_parser_factory.h \
+	sequence_gen.h
+
+include $(MK)/library.mk
+
diff --git a/protocols/rtp_payload_parser/build/linux_3gpp/makefile b/protocols/rtp_payload_parser/build/linux_3gpp/makefile
deleted file mode 100644
index 35e3f1e..0000000
--- a/protocols/rtp_payload_parser/build/linux_3gpp/makefile
+++ /dev/null
@@ -1,86 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = rtppayloadparser_3gpp
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../rfc_3016/include -I ../../rfc_3267/include -I ../../rfc_3016/include -I ../../rfc_2429/include -I ../../rfc_3984/include -I ../../rfc_3984/src -I ../../rfc_3640/include 
-XINCDIRS += -I../../../../pvmi/pvmf/include -I../../../../protocols/sdp/common/include -I ../../../../baselibs/gen_data_structures/src 
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	../rfc_2429/src/h263_payload_parser.cpp \
-	../rfc_2429/src/h263_payload_parser_factory.cpp \
-	../rfc_3016/src/m4v_payload_parser.cpp \
-	../rfc_3016/src/m4v_payload_parser_factory.cpp \
-	../rfc_3016/src/m4v_audio_payload_parser.cpp \
-	../rfc_3016/src/m4v_audio_payload_parser_factory.cpp \
-	../rfc_3267/src/bit_util.cpp \
-	../rfc_3267/src/amr_payload_parser.cpp \
-	../rfc_3267/src/amr_payload_parser_factory.cpp \
-	../rfc_3984/src/h264_payload_parser.cpp \
-	../rfc_3984/src/h264_payload_parser_factory.cpp \
-	../rfc_3640/src/rfc3640_payload_parser_factory.cpp \
-	../rfc_3640/src/rfc3640_payload_parser.cpp \
-	 sequence_gen.cpp
-
-HDRS =  bit_util.h \
-	payload_parser.h \
-	payload_parser_factory.h \
-	payload_parser_registry.h \
-	../rfc_2429/include/h263_payload_parser.h \
-	../rfc_2429/include/h263_payload_parser_factory.h \
-	../rfc_3016/include/m4v_payload_parser.h \
-	../rfc_3016/include/m4v_payload_parser_factory.h \
-	../rfc_3016/include/m4v_audio_payload_parser.h \
-	../rfc_3016/include/m4v_audio_payload_parser_factory.h \
-	../rfc_3267/include/amr_payload_parser.h \
-	../rfc_3267/include/amr_payload_parser_factory.h \
-	../rfc_3984/include/h264_payload_parser.h \
-	../rfc_3984/include/h264_payload_parser_factory.h \
-	../rfc_3640/include/rfc3640_payload_parser.h \
-	../rfc_3640/include/rfc3640_payload_parser_factory.h \
-	sequence_gen.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/protocols/rtp_payload_parser/build/make/local.mk b/protocols/rtp_payload_parser/build/make/local.mk
new file mode 100644
index 0000000..f52a2be
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/make/local.mk
@@ -0,0 +1,32 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := rtppayloadparser
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../rfc_3016/include  ../../rfc_3267/include  ../../rfc_3016/include  ../../rfc_2429/include  ../../rfc_3984/include  ../../asf/include  ../../rfc_3984/src  ../../realmedia/include  ../../rfc_3640/include
+XINCDIRS += ../../../../fileformats/asf/parser/include/ ../../../../pvmi/pvmf/include ../../../../pvmi/realaudio_deinterleaver/include ../../../../protocols/sdp/common/include ../../../../fileformats/rmff_type_specific_data_parser/src ../../../../baselibs/gen_data_structures/src
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := rtp_payload_parser_base.cpp \
+	sequence_gen.cpp
+
+
+HDRS := bit_util.h \
+	payload_parser.h \
+	payload_parser_factory.h \
+	payload_parser_registry.h \
+	sequence_gen.h
+
+include $(MK)/library.mk
+
diff --git a/protocols/rtp_payload_parser/build/make/rfc_2429.mk b/protocols/rtp_payload_parser/build/make/rfc_2429.mk
new file mode 100644
index 0000000..e337221
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/make/rfc_2429.mk
@@ -0,0 +1,11 @@
+
+# Makefile segment for RFC 2429
+
+SRCS += \
+	../rfc_2429/src/h263_payload_parser.cpp \
+	../rfc_2429/src/h263_payload_parser_factory.cpp
+
+HDRS += \
+	../rfc_2429/include/h263_payload_parser.h \
+	../rfc_2429/include/h263_payload_parser_factory.h 
+
diff --git a/protocols/rtp_payload_parser/build/make/rfc_3016.mk b/protocols/rtp_payload_parser/build/make/rfc_3016.mk
new file mode 100644
index 0000000..3c296e5
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/make/rfc_3016.mk
@@ -0,0 +1,14 @@
+# Makefile segment for RFC 3016
+
+SRCS += \
+	../rfc_3016/src/m4v_payload_parser.cpp \
+	../rfc_3016/src/m4v_payload_parser_factory.cpp \
+	../rfc_3016/src/m4v_audio_payload_parser.cpp \
+	../rfc_3016/src/m4v_audio_payload_parser_factory.cpp
+
+HDRS += \
+	../rfc_3016/include/m4v_payload_parser.h \
+	../rfc_3016/include/m4v_payload_parser_factory.h \
+	../rfc_3016/include/m4v_audio_payload_parser.h \
+	../rfc_3016/include/m4v_audio_payload_parser_factory.h
+
diff --git a/protocols/rtp_payload_parser/build/make/rfc_3267.mk b/protocols/rtp_payload_parser/build/make/rfc_3267.mk
new file mode 100644
index 0000000..a02faf5
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/make/rfc_3267.mk
@@ -0,0 +1,11 @@
+# Makefile for RFC 3267
+
+SRCS += \
+	../rfc_3267/src/bit_util.cpp \
+	../rfc_3267/src/amr_payload_parser.cpp \
+	../rfc_3267/src/amr_payload_parser_factory.cpp
+
+HDRS += \
+	../rfc_3267/include/amr_payload_parser.h \
+	../rfc_3267/include/amr_payload_parser_factory.h
+
diff --git a/protocols/rtp_payload_parser/build/make/rfc_3640.mk b/protocols/rtp_payload_parser/build/make/rfc_3640.mk
new file mode 100644
index 0000000..e78ea8b
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/make/rfc_3640.mk
@@ -0,0 +1,11 @@
+# Makefile segment for RFC 3640
+
+SRCS += \
+	../rfc_3640/src/rfc3640_payload_parser_factory.cpp \
+	../rfc_3640/src/rfc3640_payload_parser.cpp
+
+HDRS += \
+	../rfc_3640/include/rfc3640_payload_parser.h \
+	../rfc_3640/include/rfc3640_payload_parser_factory.h
+
+
diff --git a/protocols/rtp_payload_parser/build/make/rfc_3984.mk b/protocols/rtp_payload_parser/build/make/rfc_3984.mk
new file mode 100644
index 0000000..d4ff7e7
--- /dev/null
+++ b/protocols/rtp_payload_parser/build/make/rfc_3984.mk
@@ -0,0 +1,11 @@
+# Makefile segment for RFC 3984
+
+SRCS += \
+	../rfc_3984/src/h264_payload_parser.cpp \
+	../rfc_3984/src/h264_payload_parser_factory.cpp
+
+HDRS += \
+	../rfc_3984/include/h264_payload_parser.h \
+	../rfc_3984/include/h264_payload_parser_factory.h
+
+
diff --git a/protocols/rtp_payload_parser/include/bit_util.h b/protocols/rtp_payload_parser/include/bit_util.h
index 6f442b7..dea208c 100644
--- a/protocols/rtp_payload_parser/include/bit_util.h
+++ b/protocols/rtp_payload_parser/include/bit_util.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/payload_parser.h b/protocols/rtp_payload_parser/include/payload_parser.h
index 9f6fdbd..004da3e 100644
--- a/protocols/rtp_payload_parser/include/payload_parser.h
+++ b/protocols/rtp_payload_parser/include/payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/payload_parser_factory.h b/protocols/rtp_payload_parser/include/payload_parser_factory.h
index 69caffb..d4be43c 100644
--- a/protocols/rtp_payload_parser/include/payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/include/payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/payload_parser_registry.h b/protocols/rtp_payload_parser/include/payload_parser_registry.h
index 731c89b..8fa5fff 100644
--- a/protocols/rtp_payload_parser/include/payload_parser_registry.h
+++ b/protocols/rtp_payload_parser/include/payload_parser_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,8 @@
 #include "payload_parser_factory.h"
 
 //use the TLS registry, or the singleton registry if no TLS.
+//Note: singleton registry only works in single-threaded scenarios, since this
+//implementation assumes a per-thread registry.
 #include "oscl_error.h"
 #define PAYLOADPARSER_REGISTRY OsclTLSRegistryEx
 #define PAYLOADPARSER_REGISTRY_ID OSCL_TLS_ID_PAYLOADPARSER
@@ -112,7 +114,7 @@
             OsclMemAllocator, MimeStringCompare >::iterator it;
             it = iRegistry.find(mimeString);
 
-            /* This check is necessary for ADS1.2 compiler*/
+            /* This check is necessary for the ADS1.2 compiler*/
             if (!(it == iRegistry.end()))
             {
                 return (((*it).second));
diff --git a/protocols/rtp_payload_parser/include/rtp_payload_parser_base.h b/protocols/rtp_payload_parser/include/rtp_payload_parser_base.h
index b40f27d..a8443ee 100644
--- a/protocols/rtp_payload_parser/include/rtp_payload_parser_base.h
+++ b/protocols/rtp_payload_parser/include/rtp_payload_parser_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/rtp_payload_parser_include.h b/protocols/rtp_payload_parser/include/rtp_payload_parser_include.h
index f0c5846..e0ec669 100644
--- a/protocols/rtp_payload_parser/include/rtp_payload_parser_include.h
+++ b/protocols/rtp_payload_parser/include/rtp_payload_parser_include.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/rtp_payloadparser_factory_base.h b/protocols/rtp_payload_parser/include/rtp_payloadparser_factory_base.h
index 4fdeee3..f57645d 100644
--- a/protocols/rtp_payload_parser/include/rtp_payloadparser_factory_base.h
+++ b/protocols/rtp_payload_parser/include/rtp_payloadparser_factory_base.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/rtp_payloadparser_registry.h b/protocols/rtp_payload_parser/include/rtp_payloadparser_registry.h
index 1aec24d..d52fda7 100644
--- a/protocols/rtp_payload_parser/include/rtp_payloadparser_registry.h
+++ b/protocols/rtp_payload_parser/include/rtp_payloadparser_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/rtppp_media_frag_group.h b/protocols/rtp_payload_parser/include/rtppp_media_frag_group.h
index b0cd0cd..b1bc146 100644
--- a/protocols/rtp_payload_parser/include/rtppp_media_frag_group.h
+++ b/protocols/rtp_payload_parser/include/rtppp_media_frag_group.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/include/sequence_gen.h b/protocols/rtp_payload_parser/include/sequence_gen.h
index 602e4db..7e32993 100644
--- a/protocols/rtp_payload_parser/include/sequence_gen.h
+++ b/protocols/rtp_payload_parser/include/sequence_gen.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_2429/doc/TestCases.doc b/protocols/rtp_payload_parser/rfc_2429/doc/TestCases.doc
deleted file mode 100644
index 41e5476..0000000
--- a/protocols/rtp_payload_parser/rfc_2429/doc/TestCases.doc
+++ /dev/null
Binary files differ
diff --git a/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser.h b/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser.h
index 0c741d7..7686630 100644
--- a/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser.h
+++ b/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser_factory.h b/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser_factory.h
index b3fc283..4fcd6d3 100644
--- a/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/rfc_2429/include/h263_payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser.cpp b/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser.cpp
index f47c2c9..4f6a5b0 100644
--- a/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser.cpp
+++ b/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -69,7 +69,7 @@
 {
     //	H263 Payload Header Masks
     static const uint8 RR = 0xF8;	//	Reserved Bits Mask
-    static const uint8 Pbit = 0x04;	//	Picture Start bit mask
+    static const uint8 Pbit = 0x04;	//	Picture or GOB Start bit mask
     static const uint8 Vbit = 0x02;	//	VRC mask
 
     bool bPBit;	    //	indicates whether picture start code is present or not
@@ -90,11 +90,26 @@
     //check for VRC
     bVBit = (*vb & Vbit) > 0;
 
+    // 1st bit of PLEN in the 1st byte of the payload header
+    uint8 plenHI = (*vb & 0x01);
+    // the next 5 bits of PLEN in the 2nd byte of the payload header
+    uint8 plenLow = (*(vb + 1) & 0xF8);
+
+    // reconstruct PLEN
+    uint16 plen = (((uint16)plenHI << 8) + plenLow) >> 3;
 
     Payload output;
 
-    if (bPBit) // Picture start code present
+    if (bPBit) // Picture or GOB start code present
     {
+        if (plen > 0) // If extra picture header presents in the midlle of the frame
+        {
+            // skip the extra picture header from the payload
+            vb += plen;
+            // start the output payload from offset plen
+            input += plen;
+        }
+
         // we need to prepend the payload with two zero bytes
 
         if (bVBit) // VRC Header present - payload starts at 1
diff --git a/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser_factory.cpp b/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser_factory.cpp
index a391573..78b5283 100644
--- a/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser_factory.cpp
+++ b/protocols/rtp_payload_parser/rfc_2429/src/h263_payload_parser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser.h b/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser.h
index a99e24f..dfc4d67 100644
--- a/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser.h
+++ b/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser_factory.h b/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser_factory.h
index 674beb3..afc1fc4 100644
--- a/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/rfc_3016/include/m4v_audio_payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser.h b/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser.h
index ad6c30d..cf52107 100644
--- a/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser.h
+++ b/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser_factory.h b/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser_factory.h
index 0c99ae8..cf6faea 100644
--- a/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/rfc_3016/include/m4v_payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser.cpp b/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser.cpp
index 87680a7..319305a 100644
--- a/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser.cpp
+++ b/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser_factory.cpp b/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser_factory.cpp
index 6c64387..aa7eea4 100644
--- a/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser_factory.cpp
+++ b/protocols/rtp_payload_parser/rfc_3016/src/m4v_audio_payload_parser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser.cpp b/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser.cpp
index e153df9..884bd0c 100644
--- a/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser.cpp
+++ b/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser_factory.cpp b/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser_factory.cpp
index 07652a9..3deba72 100644
--- a/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser_factory.cpp
+++ b/protocols/rtp_payload_parser/rfc_3016/src/m4v_payload_parser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser.h b/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser.h
index 2e3b248..f8bd575 100644
--- a/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser.h
+++ b/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser_factory.h b/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser_factory.h
index eef6208..1c64c1a 100644
--- a/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/rfc_3267/include/amr_payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser.cpp b/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser.cpp
index e5c4d11..982666c 100644
--- a/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser.cpp
+++ b/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser_factory.cpp b/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser_factory.cpp
index 6544cd6..ad98cd6 100644
--- a/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser_factory.cpp
+++ b/protocols/rtp_payload_parser/rfc_3267/src/amr_payload_parser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3267/src/bit_util.cpp b/protocols/rtp_payload_parser/rfc_3267/src/bit_util.cpp
index 042f8d1..c82673c 100644
--- a/protocols/rtp_payload_parser/rfc_3267/src/bit_util.cpp
+++ b/protocols/rtp_payload_parser/rfc_3267/src/bit_util.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser.h b/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser.h
index c3c7d97..fcf362e 100644
--- a/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser.h
+++ b/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser_factory.h b/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser_factory.h
index d19fa15..3bb59d6 100644
--- a/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/rfc_3640/include/rfc3640_payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser.cpp b/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser.cpp
index 6c1aaa3..1e28104 100644
--- a/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser.cpp
+++ b/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -66,7 +66,6 @@
 
 OSCL_EXPORT_REF RFC3640PayloadParser::~RFC3640PayloadParser()
 {
-
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -85,7 +84,7 @@
     rfc3640_mediaInfo *r3640m = OSCL_STATIC_CAST(rfc3640_mediaInfo *, config);
     bool retVal = false;
 
-    // \todo: Implement other modes (such as CELP-cbr, CELP-vbr, AAC-lbr, etc...).
+    //TODO: Implement other modes (such as CELP-cbr, CELP-vbr, AAC-lbr, etc...).
     sizeLength             = r3640PayloadInfo->getSizeLength();
     indexLength            = r3640PayloadInfo->getIndexLength();
     indexDeltaLength       = r3640PayloadInfo->getIndexDeltaLength();
@@ -94,7 +93,7 @@
     randomAccessIndication = false;
 
     //We support AAC-hbr mode only.
-    if (!oscl_strcmp(r3640m->getMode(), "AAC-hbr"))
+    if (!oscl_strncmp(r3640m->getMode(), "AAC-hbr", oscl_strlen("AAC-hbr")))
     {
         headersPresent         = true;
         headersLength          = AAC_HBR_HEADERSLENGTH_DEFAULT_VALUE;
@@ -132,7 +131,7 @@
     //should be const functions so this casting away constness is not necessary.
     Payload& input = const_cast<Payload&>(inputPacket);
 
-    // \todo: Implement AU de-interleaving
+    //@TODO: Implement AU de-interleaving
 
     Payload out;
 
@@ -141,18 +140,28 @@
     out.randAccessPt = inputPacket.randAccessPt;
     out.sequence     = inputPacket.sequence + 1;
     out.timestamp    = inputPacket.timestamp;
+    //Creating a boolean for checking whether RFC3640_ONE_FRAGMENT_PER_MEDIA_MSG is defined or not
+    bool rfc3640_one_fragement_per_media	 = false;
 
-    //Loop through all of the packets.
-    for (uint32 fragmentNumber = 0; fragmentNumber < inputPacket.vfragments.size(); fragmentNumber++)
-    {
-        //
-        // Strip RFC 3640 header section and auxiliary section.
-        //
+#ifndef RFC3640_ONE_FRAGMENT_PER_MEDIA_MSG
+    rfc3640_one_fragement_per_media = true;
+#endif
 
-        //Establish a pointer to the payload fragment for iterating past the
-        //header and aux section.
-        BitStreamParser fragment((uint8*)input.vfragments[fragmentNumber].getMemFragPtr(),
-                                 input.vfragments[fragmentNumber].getMemFragSize());
+    // Many functions calls inside this for loop may Leave because of an
+    // overflow.
+    int32 err;
+    OSCL_TRY(err,
+             //Loop through all of the packets.
+             for (uint32 fragmentNumber = 0; fragmentNumber < inputPacket.vfragments.size(); fragmentNumber++)
+{
+    //
+    // Strip RFC 3640 header section and auxiliary section.
+    //
+
+    //Establish a pointer to the payload fragment for iterating past the
+    //header and aux section.
+    BitStreamParser fragment((uint8*)input.vfragments[fragmentNumber].getMemFragPtr(),
+                             input.vfragments[fragmentNumber].getMemFragSize());
 
         //In some cases, such as with fixed-length AUs, the header is not present.
         //Only process the header if it is present.
@@ -229,33 +238,38 @@
                 }
             }
 
-#ifndef RFC3640_ONE_FRAGMENT_PER_MEDIA_MSG
-            // At this time the decoder cannot handle multiple fragments.
-            OsclMemoryFragment memfrag;
-            //memfrag.ptr = NULL; //Unknown at this time.
-            memfrag.len = size;
-            input.vfragments[fragmentNumber].getRefCounter()->addRef();
-            OsclRefCounterMemFrag refCntMemFrag(memfrag,
-                                                input.vfragments[fragmentNumber].getRefCounter(),
-                                                memfrag.len);
-            out.vfragments.push_back(refCntMemFrag);
-#else
-            // Instead of creating multiple fragments, point to the first fragment, but
-            // increment the size field to span all access units. The decoder is still
-            // getting multiple frames in memory, but the data structure makes it appear as just one.
-            // This only works for non-interleaved access units & can only be a temporary solution
-            if (accessUnits == 0)
+
+            if (rfc3640_one_fragement_per_media == true)
             {
+                // At this time the decoder cannot handle multiple fragments.
+
                 OsclMemoryFragment memfrag;
-                memfrag.ptr = (uint8*)(input.vfragments[fragmentNumber].getMemFragPtr()) + (headersLength / 8);
-                memfrag.len = input.vfragments[fragmentNumber].getMemFragSize() - (headersLength / 8);
+                //memfrag.ptr = NULL; //Unknown at this time.
+                memfrag.len = size;
                 input.vfragments[fragmentNumber].getRefCounter()->addRef();
                 OsclRefCounterMemFrag refCntMemFrag(memfrag,
                                                     input.vfragments[fragmentNumber].getRefCounter(),
                                                     memfrag.len);
                 out.vfragments.push_back(refCntMemFrag);
             }
-#endif
+            else
+            {
+                // Instead of creating multiple fragments, point to the first fragment, but
+                // increment the size field to span all access units. The decoder is still
+                // getting multiple frames in memory, but the data structure makes it appear as just one.
+                // This only works for non-interleaved access units & can only be a temporary solution
+                if (accessUnits == 0)
+                {
+                    OsclMemoryFragment memfrag;
+                    memfrag.ptr = (uint8*)(input.vfragments[fragmentNumber].getMemFragPtr()) + (headersLength / 8);
+                    memfrag.len = input.vfragments[fragmentNumber].getMemFragSize() - (headersLength / 8);
+                    input.vfragments[fragmentNumber].getRefCounter()->addRef();
+                    OsclRefCounterMemFrag refCntMemFrag(memfrag,
+                                                        input.vfragments[fragmentNumber].getRefCounter(),
+                                                        memfrag.len);
+                    out.vfragments.push_back(refCntMemFrag);
+                }
+            }
 
             accessUnits++;
         }
@@ -282,19 +296,26 @@
             }
         }
 
-#ifndef RFC3640_ONE_FRAGMENT_PER_MEDIA_MSG
-        //Update the fragment pointers with real values now that we have
-        //parsed the headers.
-        //The output vector may contain fragments from previous runs, so
-        //start with the last fragments that we pushed on the back of the vector.
-        for (uint32 i = (out.vfragments.size() - accessUnits); i < out.vfragments.size(); i++)
+        if (rfc3640_one_fragement_per_media == true)
         {
-            out.vfragments[i].getMemFrag().ptr = fragment.GetBytePos();
-            fragment.NextBits(out.vfragments[i].getMemFrag().len * BITS_PER_BYTE);
+            //Update the fragment pointers with real values now that we have
+            //parsed the headers.
+            //The output vector may contain fragments from previous runs, so
+            //start with the last fragments that we pushed on the back of the vector.
+            for (uint32 i = (out.vfragments.size() - accessUnits); i < out.vfragments.size(); i++)
+            {
+                out.vfragments[i].getMemFrag().ptr = fragment.GetBytePos();
+                fragment.NextBits(out.vfragments[i].getMemFrag().len * BITS_PER_BYTE);
+            }
         }
-#endif
-    }
 
+    }
+            ); // End of OSCL_TRY
+
+    if (err != OsclErrNone)
+    {
+        return PayloadParserStatus_Failure;
+    }
     vParsedPayloads.push_back(out);
 
     return PayloadParserStatus_Success;
diff --git a/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser_factory.cpp b/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser_factory.cpp
index 465d73b..7e62735 100644
--- a/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser_factory.cpp
+++ b/protocols/rtp_payload_parser/rfc_3640/src/rfc3640_payload_parser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser.h b/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser.h
index 9ad102d..339e291 100644
--- a/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser.h
+++ b/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_factory.h b/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_factory.h
index 028768e..2805558 100644
--- a/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_factory.h
+++ b/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_macros.h b/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_macros.h
index 196bc6b..be81713 100644
--- a/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_macros.h
+++ b/protocols/rtp_payload_parser/rfc_3984/include/h264_payload_parser_macros.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser.cpp b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser.cpp
index 71cc7c1..80ce21d 100644
--- a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser.cpp
+++ b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -451,12 +451,14 @@
 {
     // construct output memory fragment
     OsclRefCounterMemFrag memFragOut(aIn.vfragments[0]);
+    uint8* memfrag = NULL;
 
     // Get the actual memory frag pointer and length
     PayloadParserStatus ret_val =
         getMemFragPtrLen(const_cast<IPayloadParser::Payload&>(aIn).vfragments[0],
-                         nal_type, (uint8*&)memFragOut.getMemFrag().ptr,
+                         nal_type, memfrag,
                          memFragOut.getMemFrag().len, rtp_payload_ptr_offset);
+    memFragOut.getMemFrag().ptr = (OsclAny*)memfrag;
     if (ret_val != PayloadParserStatus_Success) return ret_val;
 
     // add the memory fragment into media data imp object
diff --git a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_factory.cpp b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_factory.cpp
index 35aca4c..8276a47 100644
--- a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_factory.cpp
+++ b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_interleave_mode.h b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_interleave_mode.h
index 9faa814..2fa4278 100644
--- a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_interleave_mode.h
+++ b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_interleave_mode.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,6 +61,7 @@
         //would be needed if code called "remove".
         bool operator==(const PVH264PayLoadOutputMediaData& x)const
         {
+            OSCL_UNUSED_ARG(&x);
             OSCL_ASSERT(0);
             return false;
         }
diff --git a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_utility.h b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_utility.h
index 6435407..364de56 100644
--- a/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_utility.h
+++ b/protocols/rtp_payload_parser/rfc_3984/src/h264_payload_parser_utility.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/src/rtp_payload_parser_base.cpp b/protocols/rtp_payload_parser/src/rtp_payload_parser_base.cpp
new file mode 100644
index 0000000..b08d2fd
--- /dev/null
+++ b/protocols/rtp_payload_parser/src/rtp_payload_parser_base.cpp
@@ -0,0 +1,25 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
diff --git a/protocols/rtp_payload_parser/src/sequence_gen.cpp b/protocols/rtp_payload_parser/src/sequence_gen.cpp
index 4946eb0..5b1cf21 100644
--- a/protocols/rtp_payload_parser/src/sequence_gen.cpp
+++ b/protocols/rtp_payload_parser/src/sequence_gen.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/util/Android.mk b/protocols/rtp_payload_parser/util/Android.mk
deleted file mode 100644
index 55f69d2..0000000
--- a/protocols/rtp_payload_parser/util/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-	src/latmpayloadparser.cpp
-
-
-
-LOCAL_MODULE := libpvlatmpayloadparser
-
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/src \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/../../../codecs_v2/audio/aac/dec/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/../../../codecs_v2/audio/aac/dec/src \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/../../../baselibs/gen_data_structures/src \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/../../sdp/common/include \
-	$(PV_TOP)//protocols/rtp_payload_parser/util/../../../pvmi/pvmf/include \
-	$(PV_INCLUDES) 
-
-
-LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
-LOCAL_COPY_HEADERS := \
-	include/latmpayloadparser.h
-
-include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/rtp_payload_parser/util/build/Android.mk b/protocols/rtp_payload_parser/util/build/Android.mk
new file mode 100644
index 0000000..0b98f80
--- /dev/null
+++ b/protocols/rtp_payload_parser/util/build/Android.mk
@@ -0,0 +1,33 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	../src/latmpayloadparser.cpp
+
+
+LOCAL_MODULE := libpvlatmpayloadparser
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/protocols/rtp_payload_parser/util/src \
+ 	$(PV_TOP)/protocols/rtp_payload_parser/util/include \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/include \
+ 	$(PV_TOP)/codecs_v2/audio/aac/dec/src \
+ 	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	../include/latmpayloadparser.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/protocols/rtp_payload_parser/util/build/latmparser/make/local.mk b/protocols/rtp_payload_parser/util/build/latmparser/make/local.mk
new file mode 100644
index 0000000..d700228
--- /dev/null
+++ b/protocols/rtp_payload_parser/util/build/latmparser/make/local.mk
@@ -0,0 +1,29 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvlatmpayloadparser
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../../../../../codecs_v2/audio/aac/dec/include  ../../../../../../codecs_v2/audio/aac/dec/src  ../../../../../../baselibs/gen_data_structures/src  ../../../../../sdp/common/include  ../../../../../../pvmi/pvmf/include
+
+
+
+
+
+
+SRCDIR := ../../../src
+INCSRCDIR := ../../../include
+
+SRCS := latmpayloadparser.cpp
+
+HDRS := latmpayloadparser.h
+
+
+
+include $(MK)/library.mk
diff --git a/protocols/rtp_payload_parser/util/build/latmparser/make/makefile b/protocols/rtp_payload_parser/util/build/latmparser/make/makefile
deleted file mode 100644
index db81d4b..0000000
--- a/protocols/rtp_payload_parser/util/build/latmparser/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvlatmpayloadparser
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../../../../codecs_v2/audio/aac/dec/include -I ../../../../../../codecs_v2/audio/aac/dec/src -I ../../../../../../baselibs/gen_data_structures/src -I ../../../../../sdp/common/include -I ../../../../../../pvmi/pvmf/include
-
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../../src
-INCSRCDIR = ../../../include
-
-# compose final src list for actual build
-SRCS =	latmpayloadparser.cpp
-
-HDRS =  latmpayloadparser.h
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/protocols/rtp_payload_parser/util/doc/payload_parser_test.doc b/protocols/rtp_payload_parser/util/doc/payload_parser_test.doc
deleted file mode 100644
index be354bc..0000000
--- a/protocols/rtp_payload_parser/util/doc/payload_parser_test.doc
+++ /dev/null
Binary files differ
diff --git a/protocols/rtp_payload_parser/util/include/file_converter_unit_test.h b/protocols/rtp_payload_parser/util/include/file_converter_unit_test.h
index ddd1a74..999c76b 100644
--- a/protocols/rtp_payload_parser/util/include/file_converter_unit_test.h
+++ b/protocols/rtp_payload_parser/util/include/file_converter_unit_test.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtp_payload_parser/util/include/latmpayloadparser.h b/protocols/rtp_payload_parser/util/include/latmpayloadparser.h
index 8504f36..cfa6c82 100644
--- a/protocols/rtp_payload_parser/util/include/latmpayloadparser.h
+++ b/protocols/rtp_payload_parser/util/include/latmpayloadparser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
 /*		RTP packet payload parser.                                          */
 /*																			*/
 /*	Rev:   0.2																*/
-/*	Created: Apr. 26, 2001												    */
 /*	=====================================================================	*/
 /*																			*/
 /*	Revision History:														*/
@@ -120,11 +119,14 @@
         {
             return mediaDataOut;
         }
+        OSCL_IMPORT_REF uint8 compose(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit);
 
 
     private:
         uint8 composeSingleFrame(PVMFSharedMediaDataPtr&);
         uint8 composeMultipleFrame(PVMFSharedMediaDataPtr&);
+        uint8 composeSingleFrame(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit);
+        uint8 composeMultipleFrame(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit);
 
 
     private:
diff --git a/protocols/rtp_payload_parser/util/output/pv_rtp.bin b/protocols/rtp_payload_parser/util/output/pv_rtp.bin
old mode 100755
new mode 100644
Binary files differ
diff --git a/protocols/rtp_payload_parser/util/src/latmpayloadparser.cpp b/protocols/rtp_payload_parser/util/src/latmpayloadparser.cpp
index 6b4ba28..312e9e9 100644
--- a/protocols/rtp_payload_parser/util/src/latmpayloadparser.cpp
+++ b/protocols/rtp_payload_parser/util/src/latmpayloadparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,7 +26,9 @@
 #endif
 
 #define MAX_NUM_COMPOSITE_FRAMES            32
-#define PVLATMPARSER_MEDIADATA_POOLNUM      10
+/* Mempool size of latm parser should be at least 1 more than OMX component
+   mempool size, which is 10 */
+#define PVLATMPARSER_MEDIADATA_POOLNUM      12
 #define PVLATMPARSER_LATMDATA_CHUNKSIZE     1536*10 // 10 maximum aac frames
 #define PVLATMPARSER_MEDIADATA_CHUNKSIZE    128
 
@@ -58,7 +60,7 @@
         iLATMDataMemPool(PVLATMPARSER_MEDIADATA_POOLNUM, PVLATMPARSER_LATMDATA_CHUNKSIZE),
         iMediaDataMemPool(PVLATMPARSER_MEDIADATA_POOLNUM, PVLATMPARSER_MEDIADATA_CHUNKSIZE),
         sMC(NULL),
-        // used only for composemultipleframe, allow at least 10 AAC frames
+        // used only for composemultipleframe, allow at least 4 AAC frames
         currSize(PVLATMPARSER_LATMDATA_CHUNKSIZE),
         firstPacket(true),
         dropFrames(false),
@@ -70,7 +72,7 @@
     multiFrameBuf = (uint8 *) oscl_calloc(currSize, sizeof(uint8));
 
     // calculate a max frame size to check if the latm parser gets out of sync
-    maxFrameSize = currSize; // currently allows 10 max length case AAC frames
+    maxFrameSize = currSize; // currently allows 4 max length case AAC frames
 
     iOsclErrorTrapImp = OsclErrorTrap::GetErrorTrapImp();
 }
@@ -100,7 +102,6 @@
 
 /* ======================================================================== */
 /*  Function : compose()                                                    */
-/*  Date     : 04/03/2002                                                   */
 /*  Purpose  : parse AAC LATM payload                                       */
 /*  In/out   :                                                              */
 /*  Return   :                                                              */
@@ -231,9 +232,126 @@
     return retVal;
 }
 
+OSCL_EXPORT_REF uint8 PV_LATM_Parser::compose(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit)
+{
+    uint8 retVal = 0;
+
+    // Don't need the ref to iMediaData so unbind it
+    mediaDataOut.Unbind();
+
+    int errcode = 0;
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
+    OSCL_TRY_NO_TLS(iOsclErrorTrapImp, errcode, mediaDataImpl = iMediaDataSimpleAlloc.allocate(aDataLen));
+    OSCL_FIRST_CATCH_ANY(errcode, return FRAME_OUTPUTNOTAVAILABLE);
+
+    errcode = 0;
+    OSCL_TRY_NO_TLS(iOsclErrorTrapImp, errcode, mediaDataOut = PVMFMediaData::createMediaData(mediaDataImpl, &iMediaDataMemPool));
+    OSCL_FIRST_CATCH_ANY(errcode, return FRAME_OUTPUTNOTAVAILABLE);
+
+    OsclRefCounterMemFrag memFragOut;
+    mediaDataOut->getMediaFragment(0, memFragOut);
+
+    /*
+     *  Latch for very first packet, sequence number is not established yet.
+     */
+
+    if (!firstPacket)
+    {
+        if ((aSeqNum - last_sequence_num) > 1)    /* detect any gap in sequence */
+        {
+            // means we missed an RTP packet.
+            dropFrames = true;
+        }
+    }
+    else
+    {
+        firstPacket = false;
+    }
+
+    last_timestamp = aTimestamp;
+    last_sequence_num = aSeqNum;
+    last_mbit = aMbit;
+
+    if (dropFrames)
+    {
+        if (last_mbit)
+        {
+            /*
+             *  try to recover packet as sequencing was broken, new packet could be valid
+             *  it is possible that the received packet contains a complete audioMuxElement()
+             *  so try to retrieve it.
+             */
+
+            dropFrames = false;
+        }
+        else
+        {
+
+            /*
+             *  we are in the middle of a spread audioMuxElement(), or faulty rtp header
+             *  return error
+             */
+
+            framesize = 0;
+            frameNum = 0;
+            bytesRead = 0;
+            compositenumframes = 0;
+
+            /*
+             *  Drop frame as we are not certain if it is a valid frame
+             */
+            memFragOut.getMemFrag().len = 0;
+            mediaDataOut->setMediaFragFilledLen(0, 0);
+
+            firstBlock = true; // set for next call
+            return FRAME_ERROR;
+        }
+    }
+
+
+    if (sMC->numSubFrames > 0 || (sMC->cpresent == 1 && ((*aData) & (0x80))))
+    {
+        // this is a less efficient version that must be used when you know an AudioMuxElement has
+        // more than one subFrame -- I also added the case where the StreamMuxConfig is inline
+        // The reason for this is that the StreamMuxConfig can be possibly large and there is no
+        // way to know its size without parsing it. (the problem is it can straddle an RTP boundary)
+        // it is less efficient because it composes the AudioMuxElement in a separate buffer (one
+        // oscl_memcpy() per rtp packet) then parses it (one oscl_memcpy() per audio frame to the output
+        // buffer (newpkt->outptr)) when it gets a whole AudioMuxElement.
+        // The function below does a oscl_memcpy() directly into the output buffer
+        // note, composeMultipleFrame will also work for the simple case in case there is another reason
+        // to have to use it..
+
+        retVal = composeMultipleFrame(aData, aDataLen, aTimestamp, aSeqNum, aMbit);
+    }
+    else
+    {
+        // this is an efficient version that can be used when you know an AudioMuxElement has
+        // only one subFrame
+        retVal = composeSingleFrame(aData, aDataLen, aTimestamp, aSeqNum, aMbit);
+    }
+
+    // set this to drop frames in the future -- till we find another marker bit
+    if (retVal == FRAME_ERROR)
+    {
+        dropFrames = true;
+
+        framesize = 0;
+        frameNum = 0;
+        bytesRead = 0;
+        compositenumframes = 0;
+
+        //changed
+        memFragOut.getMemFrag().len = 0;
+        mediaDataOut->setMediaFragFilledLen(0, 0);
+
+        firstBlock = true; // set for next call
+
+    }
+    return retVal;
+}
 /* ======================================================================== */
 /*  Function : composeSingleFrame()                                         */
-/*  Date     : 04/03/2002                                                   */
 /*  Purpose  : parse AAC LATM payload                                       */
 /*  In/out   :                                                              */
 /*  Return   :                                                              */
@@ -391,7 +509,6 @@
 
 /* ======================================================================== */
 /*  Function : composeMulitpleFrame()                                       */
-/*  Date     : 04/03/2002                                                   */
 /*  Purpose  : parse AAC LATM payload                                       */
 /*  In/out   :                                                              */
 /*  Return   :                                                              */
@@ -927,6 +1044,245 @@
     ascAutoPtr.release();
     return ASCPtr;
 }
+uint8 PV_LATM_Parser::composeSingleFrame(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit)
+{
+    int32 tmp = 0;
+
+    // pool made for output data
+    OsclRefCounterMemFrag memFragOut;
+    mediaDataOut->getMediaFragment(0, memFragOut);
+
+    //uint8 * myData = newpkt->data;
+    uint8 * myData = aData;
+
+    /*
+     *  Total Payload length, in bytes, includes
+     *      length of the AudioMuxElement()
+     *      AudioMuxElement()
+     *      Other data (for RF3016 not supported)
+     */
+    int32 pktsize = aDataLen;
+
+    int32 m_bit = aMbit;
+
+    /*
+     *  All streams have same time framing (there is only one stream anyway)
+     */
+    if (firstBlock)
+    {
+        /*
+         *  AudioMuxElement() fits in a single rtp packet or this is the first
+         *  block of an AudioMuxElement() spread accross more than one rtp packet
+         */
+
+
+        int32 bUsed = 0;
+
+        /*
+         *      PayLoadlenghtInfo( )
+         */
+
+        do
+        {
+            tmp = *(myData++);      /* get payload lenght  8-bit in bytes */
+            framesize += tmp;
+            bUsed++;
+        }
+        while (tmp == 0xff);      /* 0xff is the escape sequence for values bigger than 255 */
+
+
+        /*
+         *      PayLoadMux( )
+         */
+
+        bytesRead = (pktsize - bUsed);
+
+        // framesize must be equal to the bytesRead if mbit is 1
+        // or greater than bytesRead if mbit is 0
+        if ((m_bit && framesize != bytesRead && !sMC->otherDataPresent) ||
+                (!m_bit && framesize < bytesRead && !sMC->otherDataPresent))
+        {
+            // to update number of bytes copied
+            memFragOut.getMemFrag().len = 0;
+            mediaDataOut->setMediaFragFilledLen(0, 0);
+            bytesRead = 0;
+
+            return FRAME_ERROR;
+        }
+
+        oscl_memcpy((uint8*)memFragOut.getMemFrag().ptr, myData, bytesRead); //ptr +1 changed
+
+        if (sMC->otherDataPresent)
+        {
+            ;   /* dont' care at this point, no MUX other than aac supported */
+        }
+
+    }
+    else
+    {
+        /*
+         *  We have an AudioMuxElement() spread accross more than one rtp packet
+         */
+        if ((m_bit && framesize != pktsize + (bytesRead - 1) && !sMC->otherDataPresent) /* last block */ ||
+                (!m_bit && framesize <  pktsize + (bytesRead - 1) && !sMC->otherDataPresent) /* intermediate block */)
+        {
+
+            // to update number of bytes copied
+            memFragOut.getMemFrag().len = 0;
+            mediaDataOut->setMediaFragFilledLen(0, 0);
+
+            return FRAME_ERROR;
+        }
+
+        /*
+         *  Accumulate  blocks until the full frame is complete
+         */
+        oscl_memcpy((uint8*)memFragOut.getMemFrag().ptr + bytesRead, myData, pktsize);
+        bytesRead += pktsize;
+    }
+
+
+    // to update number of bytes copied
+    memFragOut.getMemFrag().len = bytesRead;
+    mediaDataOut->setMediaFragFilledLen(0, bytesRead);
+    mediaDataOut->setSeqNum(aSeqNum);
+    mediaDataOut->setTimestamp(aTimestamp);
+
+
+    firstBlock = false;     /* we already processed the first block, so this should be false  */
+
+    if (m_bit)              /* check if it is a complete packet (m bit ==1) */
+    {
+        firstBlock = true;  /* if m-bit is "1", then the farme fits in a block or this was the last
+                               block of the frame, set for next call */
+        framesize = 0;
+        frameNum = 0;
+        bytesRead = 0;
+        compositenumframes = 0;
+    }
+    else
+    {
+        /*
+         *  We have an AudioMuxElement() spread accross more than one rtp packet
+         */
+        compositenumframes++;
+
+        if (compositenumframes < MAX_NUM_COMPOSITE_FRAMES)
+        {
+            // this is not yet a finished packet
+            return FRAME_INCOMPLETE;
+        }
+        else
+        {
+            return FRAME_ERROR;
+        }
+
+    }
+    return FRAME_COMPLETE;
+}
+
+
+
+uint8 PV_LATM_Parser::composeMultipleFrame(uint8* aData, uint32 aDataLen, uint32 aTimestamp, uint32 aSeqNum, uint32 aMbit)
+{
+
+    uint32 tmp;
+    uint8 * myData;
+    uint32 i;
+
+    int32 pktsize = aDataLen;
+    // pool made for output data
+    OsclRefCounterMemFrag memFragOut;
+    mediaDataOut->getMediaFragment(0, memFragOut);
+    // make sure we have enough memory to hold the data
+    if (bytesRead + pktsize > currSize)
+    {
+        uint8 * tempPtr = (uint8*) oscl_calloc(bytesRead + pktsize, sizeof(uint8));
+        if (tempPtr == NULL)
+        {
+            // memory problem?
+            return FRAME_ERROR;
+        }
+        currSize = bytesRead + pktsize;
+        oscl_memcpy(tempPtr, multiFrameBuf, bytesRead);
+        oscl_free(multiFrameBuf);
+        multiFrameBuf = tempPtr;
+    }
+
+    oscl_memcpy(multiFrameBuf + bytesRead, aData, pktsize);
+
+    bytesRead += pktsize;
+    //newpkt->frame_size = bytesRead;
+
+    // to update number of bytes copied
+    memFragOut.getMemFrag().len = bytesRead;
+    mediaDataOut->setMediaFragFilledLen(0, bytesRead);
+    mediaDataOut->setSeqNum(aSeqNum);
+    mediaDataOut->setTimestamp(aTimestamp);
+
+    if (aMbit)
+    {
+        // means this is the last packet for this audioMuxElement
+
+        myData = multiFrameBuf;
+
+        uint32 outPtrPos = 0;
+        for (i = 0;i <= sMC->numSubFrames;i++)
+        {
+            framesize = 0;
+            do
+            {
+                tmp = *(myData);
+                framesize += tmp;
+            }
+            while (*(myData++) == 0xff);
+
+            //int32 bUsed = (framesize/255)+1; // 0-254: 1, 255-511: 2 ...
+            // do a check on the last one
+            if (i == sMC->numSubFrames && !sMC->otherDataPresent)
+            {
+                if (framesize != bytesRead - (myData - multiFrameBuf))
+                {
+                    // to update number of bytes copied
+                    memFragOut.getMemFrag().len = 0;
+                    mediaDataOut->setMediaFragFilledLen(0, 0);
+
+                    return FRAME_INCOMPLETE;
+                }
+            }
+            oscl_memcpy((uint8*)memFragOut.getMemFrag().ptr + outPtrPos, myData, framesize);
+            myData += framesize;
+            outPtrPos += framesize;
+        }
+
+
+
+        // to update number of bytes copied
+        memFragOut.getMemFrag().len = outPtrPos;
+        mediaDataOut->setMediaFragFilledLen(0, outPtrPos);
+
+        bytesRead = 0;
+        framesize = 0;
+        compositenumframes = 0;
+
+    }
+    else
+    {
+        compositenumframes++;
+
+        if (compositenumframes < MAX_NUM_COMPOSITE_FRAMES)
+        {
+            return FRAME_INCOMPLETE;
+        }
+        else
+        {
+            return FRAME_ERROR;
+        }
+
+    }
+
+    return FRAME_COMPLETE;
+}
 
 uint32 BufferShowBits(uint8 *inbuf, uint32 pos1, uint32 pos2)
 {
diff --git a/protocols/rtsp_client_engine/Android.mk b/protocols/rtsp_client_engine/Android.mk
index 051b4ea..60a0d00 100644
--- a/protocols/rtsp_client_engine/Android.mk
+++ b/protocols/rtsp_client_engine/Android.mk
@@ -2,41 +2,44 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvrtsp_client_engine_node.cpp\
-	src/pvrtsp_client_engine_utils.cpp\
-	src/pvrtsp_client_engine_factory.cpp\
-	src/pvrtsp_client_engine_port.cpp
+	src/pvrtsp_client_engine_node.cpp \
+ 	src/pvrtspenginenodeextensioninterface_impl.cpp \
+ 	src/pvrtsp_client_engine_utils.cpp \
+ 	src/pvrtsp_client_engine_factory.cpp \
+ 	src/pvrtsp_client_engine_port.cpp
+
+
+LOCAL_MODULE := libpvrtsp_cli_eng_node
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
 
-LOCAL_MODULE := libpvrtsp_cli_eng_node_3gpp
+LOCAL_STATIC_LIBRARIES := 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/rtsp_client_engine/inc \
-	$(PV_TOP)//protocols/rtsp_client_engine/src \
-	$(PV_TOP)//protocols/rtsp_client_engine/../../nodes/streaming/config/opencore \
-	$(PV_TOP)//protocols/rtsp_client_engine/../rtsp_parcom/src \
-	$(PV_TOP)//protocols/rtsp_client_engine/../rtp/src \
-	$(PV_TOP)//protocols/rtsp_client_engine/../../baselibs/gen_data_structures/src \
-	$(PV_TOP)//protocols/rtsp_client_engine/../sdp/common/include \
-	$(PV_TOP)//protocols/rtsp_client_engine/../../nodes/streaming/streamingmanager/include \
-	$(PV_TOP)//protocols/rtsp_client_engine/../../baselibs/pvcrypto/src \
-	$(PV_TOP)//protocols/rtsp_client_engine/../rdt_parser/include \
-	$(PV_TOP)//protocols/rtsp_client_engine/../../nodes/streaming/common/include \
-	$(PV_TOP)//protocols/rtsp_client_engine/../../engines/player/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/protocols/rtsp_client_engine/src \
+ 	$(PV_TOP)/protocols/rtsp_client_engine/inc \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/config/3gpp \
+ 	$(PV_TOP)/protocols/rtsp_parcom/src \
+ 	$(PV_TOP)/protocols/rtp/src \
+ 	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_TOP)/nodes/streaming/streamingmanager/include \
+ 	$(PV_TOP)/baselibs/pvcrypto/src \
+ 	$(PV_TOP)/protocols/rdt_parser/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	inc/pvrtsp_client_engine_node.h\
-	inc/pvrtspenginenodeextensioninterface.h\
-	inc/pvrtsp_client_engine_utils.h\
-	inc/pvrtsp_client_engine_factory.h\
-	inc/pvrtsp_client_engine_error_code.h
+	inc/pvrtsp_client_engine_node.h \
+ 	inc/pvrtspenginenodeextensioninterface.h \
+ 	inc/pvrtsp_client_engine_utils.h \
+ 	inc/pvrtsp_client_engine_factory.h \
+ 	inc/pvrtsp_client_engine_error_code.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/rtsp_client_engine/build/make_3gpp/makefile b/protocols/rtsp_client_engine/build/make_3gpp/makefile
deleted file mode 100644
index 8658652..0000000
--- a/protocols/rtsp_client_engine/build/make_3gpp/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvrtsp_cli_eng_node_3gpp
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-XINCDIRS += -I../../../../nodes/streaming/config/opencore -I../../../rtsp_parcom/src  -I../../../rtp/src  -I../../../../baselibs/gen_data_structures/src -I ../../../sdp/common/include -I../../../../nodes/streaming/streamingmanager/include -I../../../../baselibs/pvcrypto/src -I../../../rdt_parser/include -I../../../../nodes/streaming/common/include -I../../../../engines/player/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../inc
-
-# compose final src list for actual build
-SRCS = pvrtsp_client_engine_node.cpp\
-	pvrtsp_client_engine_utils.cpp\
-	pvrtsp_client_engine_factory.cpp\
-	pvrtsp_client_engine_port.cpp
-
-HDRS = pvrtsp_client_engine_node.h\
-	pvrtspenginenodeextensioninterface.h\
-	pvrtsp_client_engine_utils.h\
-	pvrtsp_client_engine_factory.h\
-	pvrtsp_client_engine_error_code.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/protocols/rtsp_client_engine/build_opencore/make/local.mk b/protocols/rtsp_client_engine/build_opencore/make/local.mk
new file mode 100644
index 0000000..28da228
--- /dev/null
+++ b/protocols/rtsp_client_engine/build_opencore/make/local.mk
@@ -0,0 +1,34 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvrtsp_cli_eng_node
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../../../nodes/streaming/streamingmanager/config/3gpp ../../../rtsp_parcom/src ../../../rtp/src ../../../../baselibs/gen_data_structures/src  ../../../sdp/common/include ../../../../nodes/streaming/streamingmanager/include ../../../../baselibs/pvcrypto/src ../../../rdt_parser/include ../../../../nodes/streaming/common/include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../inc
+
+SRCS := pvrtsp_client_engine_node.cpp\
+	pvrtspenginenodeextensioninterface_impl.cpp \
+	pvrtsp_client_engine_utils.cpp\
+	pvrtsp_client_engine_factory.cpp\
+	pvrtsp_client_engine_port.cpp
+
+HDRS := pvrtsp_client_engine_node.h\
+	pvrtspenginenodeextensioninterface.h\
+	pvrtsp_client_engine_utils.h\
+	pvrtsp_client_engine_factory.h\
+	pvrtsp_client_engine_error_code.h
+
+
+
+include $(MK)/library.mk
diff --git a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_error_code.h b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_error_code.h
index 8649239..30df00e 100644
--- a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_error_code.h
+++ b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_error_code.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_factory.h b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_factory.h
index a51935a..a74edfc 100644
--- a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_factory.h
+++ b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_node.h b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_node.h
index f6c3a05..4c5fe0c 100644
--- a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_node.h
+++ b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_node.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,8 +51,8 @@
 #include "oscl_string_containers.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #ifndef OSCL_TIMER_H_INCLUDED
@@ -118,6 +118,11 @@
 #ifndef PAYLOAD_PARSER_H_INCLUDED
 #include "payload_parser.h"
 #endif
+
+#ifndef PVMF_SM_CONFIG_H_INCLUDED
+#include "pvmf_sm_config.h"
+#endif
+
 //Default vector reserve size
 #define PVMF_RTSP_ENGINE_NODE_COMMAND_VECTOR_RESERVE 10
 
@@ -209,7 +214,7 @@
         bool getStateFlag;			    //Used to ensure that the PE's main loop has been called
         bool pvServerIsSetFlag; 		    //Used to indicate if we are streaming from PVServer or not
         bool tSIDIsSetFlag;			    //Used to send session id from second SETUP request
-
+        uint32 iServerVersionNumber;    // Version number of PVSS
         int32 prerollDuration;                  //Saves the jitter buffer size
 
         int32 fwp_counter;			    //Id of the first returned firewall packet
@@ -217,7 +222,6 @@
         uint32 roundTripDelay;                   //Saves the round trip delay for a DESCRIBE request
         uint64 clientServerDelay;                //Saves the client server delay during a DESCRIBE request
 
-        bool imperialPlusServerFlag;            //Used to indicate if the server is 3.1 or not
         bool pipeLineFlag;                      //Used to indicate a pipe lined request
 
         OSCL_HeapString<PVRTSPEngineNodeAllocator>	iUserAgent;
@@ -233,15 +237,22 @@
 
         enum PVRTSPStreamingType iStreamingType;
 
+        bool									   iSessionCompleted;
+        void UpdateSessionCompletionStatus(bool aSessionCompleted)
+        {
+            iSessionCompleted = aSessionCompleted;
+        }
 
     public:
         SessionInfo():
+                iProxyPort(0),
                 bExternalSDP(false),
                 pvServerIsSetFlag(false),
+                iServerVersionNumber(0),
                 roundTripDelay(0),
-                iProxyPort(0)
+                iSessionCompleted(false)
         {
-            iUserAgent += _STRLIT_CHAR("PVCore/05.02.00.00");
+            iUserAgent += _STRLIT_CHAR("PVPlayer4.0");
             iReqPlayRange.format = RtspRangeType::INVALID_RANGE;
         };
 
@@ -261,6 +272,7 @@
 enum TPVMFRtspNodeCommand //TPVMFGenericNodeCommand
 {
     PVMF_RTSP_NODE_ERROR_RECOVERY = PVMF_GENERIC_NODE_COMMAND_LAST + 1
+    , PVMF_RTSP_NODE_CANCELALLRESET
 };
 class PVRTSPEngineCommand: public PVRTSPEngineCommandBase
 {
@@ -363,14 +375,10 @@
         Oscl_File iGetPostCorrelationFile;
 };
 
-#ifndef PVMF_STREAM
-#define PVMF_STREAM                       1410
-#endif
-
 class PVRTSPEngineNode
-            : public PVMFNodeInterface,
-            public OsclTimerObject, //OsclActiveObject??
-            public PVRTSPEngineNodeExtensionInterface,
+            : public PVInterface,
+            public PVMFNodeInterface,
+            public OsclTimerObject,
             public OsclSocketObserver,
             public OsclDNSObserver,
             public OsclTimerObserver,
@@ -575,6 +583,9 @@
         OSCL_IMPORT_REF virtual PVMFStatus GetKeepAliveMethod(int32 &aTimeout, bool &aUseSetParameter, bool &aKeepAliveInPlay);
 
 
+        OSCL_IMPORT_REF virtual PVMFStatus GetRTSPTimeOut(int32 &aTimeout);
+        OSCL_IMPORT_REF virtual PVMFStatus SetRTSPTimeOut(int32 aTimeout);
+
         //************ end PVRTSPEngineNodeExtensionInterface
 
         //************ begin OsclTimerObserver
@@ -592,6 +603,16 @@
         void freechunkavailable(OsclAny*);
         //************ end OsclMemPoolFixedChunkAllocatorObserver
 
+        void UpdateSessionCompletionStatus(bool aSessionCompleted)
+        {
+            iSessionInfo.iSessionCompleted = aSessionCompleted;
+        }
+
+        bool IsSessionCompleted() const
+        {
+            return iSessionInfo.iSessionCompleted;
+        }
+
         typedef struct _SocketEvent
         {
             int32			iSockId;
@@ -634,7 +655,7 @@
         }iState;
 
     private:
-
+        OsclSharedPtr<PVMFMediaDataImpl> AllocateMediaData(int32& errCode);
         Oscl_Vector<SocketEvent, PVRTSPEngineNodeAllocator> iSocketEventQueue;
 
         PVRTSPEngineNodeAllocator iAlloc;
@@ -642,9 +663,85 @@
         PVMFCommandId iCurrentCmdId;
 
         OsclSocketServ	*iSockServ;
-        //OsclTCPSocket *iRTSPSocket, *iGetSocket, *iPostSocket;
-        OsclTCPSocket *iSendSocket, *iRecvSocket;
-        OsclDNS *iDNS;
+
+//note: this class is for internal use only, but must be public to avoid ADS v1.2 compile error.
+    public:
+        //To keep track of current socket op
+        class SocketState
+        {
+            public:
+                SocketState()
+                        : iPending(false)
+                        , iCanceled(false)
+                {}
+                bool iPending;
+                bool iCanceled;
+                void Reset()
+                {
+                    iPending = iCanceled = false;
+                }
+        };
+
+    private:
+
+        //Container for a TCP socket that can connect, send, & recv.
+        class SocketContainer
+        {
+            public:
+                SocketContainer(): iSocket(NULL)
+                {}
+                OsclTCPSocket* iSocket;
+                SocketState iConnectState;
+                SocketState iSendState;
+                SocketState iRecvState;
+                SocketState iShutdownState;
+                void Reset(OsclTCPSocket* aSock)
+                {
+                    iSocket = aSock;
+                    iConnectState.Reset();
+                    iSendState.Reset();
+                    iRecvState.Reset();
+                    iShutdownState.Reset();
+                }
+                bool IsBusy()
+                {
+                    return iSocket
+                           && (iConnectState.iPending
+                               || iSendState.iPending
+                               || iRecvState.iPending
+                               || iShutdownState.iPending);
+                }
+        };
+        class DnsContainer
+        {
+            public:
+                DnsContainer(): iDns(NULL)
+                {}
+                OsclDNS* iDns;
+                SocketState iState;
+                bool IsBusy()
+                {
+                    return (iDns
+                            && iState.iPending);
+                }
+        };
+        void SetSendPending(SocketContainer&);
+        void SetRecvPending(SocketContainer&);
+
+        SocketContainer iSendSocket, iRecvSocket;
+        DnsContainer iDNS;
+
+        //To keep track of socket reset sequence.
+        enum TSocketCleanupState
+        {
+            ESocketCleanup_Idle
+            , ESocketCleanup_CancelCurrentOp
+            , ESocketCleanup_WaitOnCancel
+            , ESocketCleanup_Shutdown
+            , ESocketCleanup_WaitOnShutdown
+            , ESocketCleanup_Delete
+        };
+        TSocketCleanupState iSocketCleanupState;
 
         //only for http cloaking, string to store the text to send until send completes
         OSCL_HeapString<PVRTSPEngineNodeAllocator> iRecvChannelMsg, iSendChannelMsg;
@@ -670,13 +767,15 @@
         PVMFSharedMediaDataPtr	iEmbeddedDataPtr;
         // Reference counter for extension
         uint32 iExtensionRefCount;
+        uint32 iNumRedirectTrials;
 
         //socket server will callback even if Cancel() is called
         //most likely this is the case for OsclDNS as well
         //But this is NOT the case for OsclTimer
-        uint32	iNumOfCallback;
+        uint32	iNumHostCallback, iNumConnectCallback, iNumSendCallback, iNumRecvCallback;
         int BASE_REQUEST_ID;
-        int REQ_SEND_SOCKET_ID, REQ_RECV_SOCKET_ID;
+        static const int REQ_SEND_SOCKET_ID;
+        static const int REQ_RECV_SOCKET_ID;
         int REQ_TIMER_WATCHDOG_ID, REQ_TIMER_KEEPALIVE_ID;
         int REQ_DNS_LOOKUP_ID;
 
@@ -685,9 +784,11 @@
 
         //these three are in milliseconds
         const int TIMEOUT_CONNECT_AND_DNS_LOOKUP, TIMEOUT_SEND, TIMEOUT_RECV;
+        const int TIMEOUT_SHUTDOWN;
 
         //these two are in seconds
-        const int TIMEOUT_WATCHDOG;
+        int TIMEOUT_WATCHDOG;
+        const int TIMEOUT_WATCHDOG_TEARDOWN;
         int TIMEOUT_KEEPALIVE;
         const int RECOMMENDED_RTP_BLOCK_SIZE;
 
@@ -749,7 +850,7 @@
         PVMFSimpleMediaBufferCombinedAlloc *iMediaDataImplAlloc;
 
         /* Round trip delay calculation */
-        OsclTimebase_Tickcount iRoundTripClockTimeBase;
+        PVMFTimebase_Tickcount iRoundTripClockTimeBase;
 
         int32	iErrorRecoveryAttempt;
 
@@ -764,10 +865,8 @@
         virtual void Run();
         virtual OsclLeaveCode RunError(OsclLeaveCode aError);
 
-        void deleteSocket(OsclTCPSocket *&aTcpSock);
-
-        PVMFStatus sendSocketOutgoingMsg(OsclTCPSocket &aSock, RTSPOutgoingMessage &aMsg);
-        PVMFStatus sendSocketOutgoingMsg(OsclTCPSocket &aSock, const uint8* aSendBuf, uint32 aSendLen);
+        PVMFStatus sendSocketOutgoingMsg(SocketContainer &aSock, RTSPOutgoingMessage &aMsg);
+        PVMFStatus sendSocketOutgoingMsg(SocketContainer &aSock, const uint8* aSendBuf, uint32 aSendLen);
 
         void ChangeExternalState(TPVMFNodeInterfaceState aNewState);
 
@@ -795,6 +894,7 @@
         PVMFStatus DoErrorRecovery(PVRTSPEngineCommand &aCmd);
 
         PVMFStatus DoRequestPort(PVRTSPEngineCommand &aCmd, PVMFRTSPPort* &aPort);
+        PVMFStatus DoAddPort(int32 id, bool isMedia, int32 tag, PVMFRTSPPort* &aPort);
         PVMFStatus DoReleasePort(PVRTSPEngineCommand &aCmd);
 
         bool FlushPending();
@@ -856,10 +956,7 @@
         //allocate aReqBufSize memory for iEmbeddedData
         bool PrepareEmbeddedDataMemory(uint32 aReqBufSize, OsclMemoryFragment &);
         bool DispatchEmbeddedData(uint32 aChannelID);
-
-
-        ///// private members added for real support (by randeep)
-
+        // private members added for real support
         bool ibIsRealRDT;
 
         // realchallenge1 string returned by OPTIONS request
@@ -882,13 +979,14 @@
         bool ibBlockedOnFragGroups;
         //bool simpleHttpParser(const uint8 *aBuf, int32 &aLen, bool &aIsStatus200);
 
-        void resetSocket(void);
+        PVMFStatus resetSocket(bool aImmediate = false);
         void clearOutgoingMsgQueue(void);
         void partialResetSessionInfo(void);
 
         bool clearEventQueue(void);
 
         void ResetSessionInfo(void);
+        PVRTSPEngineNodeExtensionInterface* iExtensionInterface;
 };
 
 #endif //PVRTSP_CLIENT_ENGINE_NODE_H
diff --git a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_utils.h b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_utils.h
index 41273ac..01515db 100644
--- a/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_utils.h
+++ b/protocols/rtsp_client_engine/inc/pvrtsp_client_engine_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_client_engine/inc/pvrtspenginenodeextensioninterface.h b/protocols/rtsp_client_engine/inc/pvrtspenginenodeextensioninterface.h
index 6db5796..ab5d015 100644
--- a/protocols/rtsp_client_engine/inc/pvrtspenginenodeextensioninterface.h
+++ b/protocols/rtsp_client_engine/inc/pvrtspenginenodeextensioninterface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,6 +42,14 @@
 #include "payload_parser.h"
 #endif
 
+#ifndef PVMF_EVENT_HANDLING_H_INCLUDED
+#include "pvmf_event_handling.h"
+#endif
+
+#ifndef PVMF_SM_CONFIG_H_INCLUDED
+#include "pvmf_sm_config.h"
+#endif
+
 // UUID for the extension interface
 #define KPVRTSPEngineNodeExtensionUuid  PVUuid(0x00000000,0x0000,0x4887,0xB1,0x0B,0x7E,0xE6,0x48,0x47,0xB2,0x05)
 
@@ -111,6 +119,7 @@
         {
             iIsPVServer = false;
             iRoundTripDelayInMS = 0;
+            iServerVersionNumber = 0;
         }
 
         virtual ~PVRTSPEngineNodeServerInfo()
@@ -120,13 +129,20 @@
         bool iIsPVServer;
         uint32 iRoundTripDelayInMS;
         OSCL_HeapString<OsclMemAllocator> iServerName;
+        uint32 	iServerVersionNumber;
 };
 
 #define PVRTSPENGINENODE_DEFAULT_KEEP_ALIVE_INTERVAL 55
+#define PVRTSPENGINENODE_DEFAULT_RTSP_INACTIVITY_TIMER 15
+#define PVRTSPENGINENODE_DEFAULT_NUMBER_OF_REDIRECT_TRIALS 1
+
+//Forward Declarations
+class PVMFPortInterface;
 
 class PVRTSPEngineNodeExtensionInterface : public PVInterface
 {
     public:
+        virtual ~PVRTSPEngineNodeExtensionInterface() {}
         //**********begin PVInterface
         OSCL_IMPORT_REF virtual void addRef() = 0;
         OSCL_IMPORT_REF virtual void removeRef() = 0;
@@ -200,6 +216,9 @@
         *
         */
 
+        OSCL_IMPORT_REF virtual PVMFStatus GetRTSPTimeOut(int32 &aTimeout) = 0;
+        OSCL_IMPORT_REF virtual PVMFStatus SetRTSPTimeOut(int32 aTimeout) = 0;
+        OSCL_IMPORT_REF virtual void UpdateSessionCompletionStatus(bool aSessionCompleted) = 0;
 };
 
 #endif //PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_H_INCLUDED
diff --git a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_factory.cpp b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_factory.cpp
index 24b8b2e..d97826a 100644
--- a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_factory.cpp
+++ b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,10 +20,17 @@
  * @brief Singleton factory for PVRTSPEngineNode
  */
 
+#ifndef OSCL_BASE_H_INCLUDED
 #include "oscl_base.h"
-#include "oscl_error_codes.h"
-#include "oscl_exception.h"
+#endif
 
+#ifndef OSCL_ERROR_CODES_H_INCLUDED
+#include "oscl_error_codes.h"
+#endif
+
+#ifndef OSCL_EXCEPTION_H_INCLUDED
+#include "oscl_exception.h"
+#endif
 
 #ifndef PVRTSP_CLIENT_ENGINE_NODE_H
 #include "pvrtsp_client_engine_node.h"
diff --git a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_node.cpp b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_node.cpp
index 262bd6e..ae30f06 100644
--- a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_node.cpp
+++ b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_node.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -71,11 +71,23 @@
 #include "base64_codec.h"
 #endif
 
+#ifndef PV_STRING_URI_H_INCLUDE
+#include "pv_string_uri.h"
+#endif
+
+#ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_IMPL_H_INCLUDED
+#include "pvrtspenginenodeextensioninterface_impl.h"
+#endif
+
+/*
 #ifndef PV_PLAYER_SDKINFO_H_INCLUDED	//\engines\player\src\pv_player_sdkinfo.h
 #include "pv_player_sdkinfo.h"
 #endif
+*/
 ////////////////////////////////////////////////////////////////////////////////
 
+const int PVRTSPEngineNode::REQ_SEND_SOCKET_ID = 1;
+const int PVRTSPEngineNode::REQ_RECV_SOCKET_ID = 2;
 
 
 OSCL_EXPORT_REF PVRTSPEngineNode::PVRTSPEngineNode(int32 aPriority) :
@@ -83,9 +95,7 @@
         iState(PVRTSP_ENGINE_NODE_STATE_IDLE),
         iCurrentCmdId(0),
         iSockServ(NULL),
-        iSendSocket(NULL),
-        iRecvSocket(NULL),
-        iDNS(NULL),
+        iSocketCleanupState(ESocketCleanup_Idle),
         iRTSPParser(NULL),
         iRTSPParserState(RTSPParser::WAITING_FOR_DATA),
         iOutgoingSeq(0),
@@ -94,10 +104,12 @@
         iTheBusyPort(NULL),
         iLogger(NULL),
         iExtensionRefCount(0),
-        iNumOfCallback(0),
+        iNumRedirectTrials(PVRTSPENGINENODE_DEFAULT_NUMBER_OF_REDIRECT_TRIALS),
+        iNumHostCallback(0),
+        iNumConnectCallback(0),
+        iNumSendCallback(0),
+        iNumRecvCallback(0),
         BASE_REQUEST_ID(0),
-        REQ_SEND_SOCKET_ID(0),
-        REQ_RECV_SOCKET_ID(0),
         REQ_TIMER_WATCHDOG_ID(0),
         REQ_TIMER_KEEPALIVE_ID(0),
         REQ_DNS_LOOKUP_ID(0),
@@ -106,7 +118,9 @@
         TIMEOUT_CONNECT_AND_DNS_LOOKUP(30000),
         TIMEOUT_SEND(3000),
         TIMEOUT_RECV(-1),
+        TIMEOUT_SHUTDOWN(30000),
         TIMEOUT_WATCHDOG(20),
+        TIMEOUT_WATCHDOG_TEARDOWN(2),
         TIMEOUT_KEEPALIVE(PVRTSPENGINENODE_DEFAULT_KEEP_ALIVE_INTERVAL),
         RECOMMENDED_RTP_BLOCK_SIZE(1400),
         setupTrackIndex(0),
@@ -126,8 +140,8 @@
         ipRdtParser(NULL),
         ipFragGroupAllocator(NULL),
         ipFragGroupMemPool(NULL),
-        ibBlockedOnFragGroups(false)
-
+        ibBlockedOnFragGroups(false),
+        iExtensionInterface(NULL)
 {
     int32 err;
     OSCL_TRY(err,
@@ -149,8 +163,6 @@
              iCapability.iCanSupportMultipleOutputPorts = false;
              iCapability.iHasMaxNumberOfPorts = true;
              iCapability.iMaxNumberOfPorts = 1;
-             iCapability.iInputFormatCapability.push_back(PVMF_STREAM);
-             iCapability.iOutputFormatCapability.push_back(PVMF_STREAM);
 
              iEntityMemFrag.len = 0;
              iEntityMemFrag.ptr = NULL;
@@ -168,6 +180,7 @@
              iMediaDataResizableAlloc = OSCL_NEW(OsclMemPoolResizableAllocator, (RECOMMENDED_RTP_BLOCK_SIZE));
              OsclError::LeaveIfNull(iMediaDataResizableAlloc);
 
+
              iMediaDataImplAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iMediaDataResizableAlloc));;
              OsclError::LeaveIfNull(iMediaDataImplAlloc);
 
@@ -194,9 +207,14 @@
 {
     Cancel();
 
+    if (iExtensionInterface)
+    {
+        iExtensionInterface->removeRef();
+    }
+
     if (iWatchdogTimer)
     {
-        OSCL_TEMPLATED_DELETE(iWatchdogTimer, OsclTimer<PVRTSPEngineNodeAllocator>, OsclTimer);
+        OSCL_DELETE(iWatchdogTimer);
         iWatchdogTimer = NULL;
     }
 
@@ -236,15 +254,16 @@
         iMediaDataResizableAlloc->removeRef();
     }
 
-    if (iDNS)
-    {
-        iDNS->~OsclDNS();
-        iAlloc.deallocate(iDNS);
-        iDNS = NULL;
-    }
-
     clearOutgoingMsgQueue();
-    resetSocket();
+
+    resetSocket(true);
+
+    if (iDNS.iDns)
+    {
+        iDNS.iDns->~OsclDNS();
+        iAlloc.deallocate(iDNS.iDns);
+        iDNS.iDns = NULL;
+    }
 
     if (iSockServ)
     {
@@ -255,8 +274,7 @@
     }
 
     if (ipFragGroupAllocator != NULL)
-        OSCL_TEMPLATED_DELETE(ipFragGroupAllocator, PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>,
-                              PVMFMediaFragGroupCombinedAlloc);
+        OSCL_DELETE(ipFragGroupAllocator);
     if (ipFragGroupMemPool != NULL)
         OSCL_DELETE(ipFragGroupMemPool);
 
@@ -337,25 +355,41 @@
 
 OSCL_EXPORT_REF void PVRTSPEngineNode::addRef()
 {
-    ++iExtensionRefCount;
+
 }
 
 OSCL_EXPORT_REF void PVRTSPEngineNode::removeRef()
 {
-    --iExtensionRefCount;
+
 }
 
 OSCL_EXPORT_REF bool PVRTSPEngineNode::queryInterface(const PVUuid& uuid, PVInterface*& iface)
 {
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::QueryInterface() In iExtensionInterface %x", iExtensionInterface));
+    iface = NULL;
     if (uuid == KPVRTSPEngineNodeExtensionUuid)
     {
-        PVRTSPEngineNodeExtensionInterface* myInterface = OSCL_STATIC_CAST(PVRTSPEngineNodeExtensionInterface*, this);
-        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
-        ++iExtensionRefCount;
-        return true;
+        if (!iExtensionInterface)
+        {
+            iExtensionInterface = OSCL_NEW(PVRTSPEngineNodeExtensionInterfaceImpl, (this));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::QueryInterface() iExtensionInterface %x", iExtensionInterface));
+        }
+        if (iExtensionInterface)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::QueryInterface() Interface existing iExtensionInterface %x", iExtensionInterface));
+            return (iExtensionInterface->queryInterface(uuid, iface));
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::queryInterface()- ERROR No memory"));
+            OSCL_LEAVE(OsclErrNoMemory);
+            return false;
+        }
     }
-
-    return false;
+    else
+    {
+        return false;
+    }
 }
 
 OSCL_EXPORT_REF PVMFCommandId PVRTSPEngineNode::QueryInterface(PVMFSessionId aSession
@@ -497,19 +531,6 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::SetSessionURL() called"));
     if (iInterfaceState == EPVMFNodeIdle)
     {
-        //If proxy is in use, both the name and the port have to be set before SetSessionURL
-        if (iSessionInfo.iProxyName.get_size())
-        {
-            if (0 == iSessionInfo.iProxyPort)
-            {
-                return false;
-            }
-        }
-        else if (0 != iSessionInfo.iProxyPort)
-        {
-            return false;
-        }
-
         if (parseURL(aURL))
         {
             iSessionInfo.bExternalSDP = false;
@@ -523,17 +544,21 @@
 OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNode::SetRtspProxy(OSCL_String& aRtspProxyName, uint32 aRtspProxyPort)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::SetRtspProxy() aRtspProxy %s %d", aRtspProxyName.get_cstr(), aRtspProxyPort));
-    iSessionInfo.iProxyName = "";
-    iSessionInfo.iProxyPort = 0;
-    if (iInterfaceState == EPVMFNodeIdle)
+
+    //If proxy is in use, both the name and the port have to be set.
+    if ((0 == aRtspProxyName.get_size())
+            || (0 == aRtspProxyPort)
+            || (iInterfaceState != EPVMFNodeIdle))
+    {
+        return PVMFFailure;
+    }
+
     {
         iSessionInfo.iProxyName = aRtspProxyName;
         iSessionInfo.iProxyPort = aRtspProxyPort;
 
-        iSessionInfo.iSrvAdd.port = iSessionInfo.iProxyPort;
         return PVMFSuccess;
     }
-    return PVMFFailure;
 }
 OSCL_EXPORT_REF  PVMFStatus PVRTSPEngineNode::GetRtspProxy(OSCL_String& aRtspProxyName, uint32& aRtspProxyPort)
 {
@@ -570,8 +595,17 @@
         if (iSessionInfo.bExternalSDP)
         {
             //set the server address
-            const char *tmp = (aSDPinfo->getSessionInfo())->getControlURL();
-            if (!parseURL(tmp))
+            const char *servURL = (aSDPinfo->getSessionInfo())->getControlURL();
+            uint32 servURLLen = oscl_strlen(servURL);
+            if (servURLLen >= iRTSPEngTmpBuf.len)
+            {
+                //we do not support URLs larger than RTSP_MAX_FULL_REQUEST_SIZE
+                //iRTSPEngTmpBuf.len is initialized to RTSP_MAX_FULL_REQUEST_SIZE
+                return PVMFFailure;
+            }
+            oscl_memset(iRTSPEngTmpBuf.ptr, 0, iRTSPEngTmpBuf.len);
+            oscl_strncpy((mbchar*)iRTSPEngTmpBuf.ptr, servURL, servURLLen);
+            if (!parseURL((mbchar*)iRTSPEngTmpBuf.ptr))
             {
                 return PVMFFailure;
             }
@@ -592,6 +626,7 @@
     aServerInfo.iServerName = iSessionInfo.iServerName;
     aServerInfo.iIsPVServer = iSessionInfo.pvServerIsSetFlag;
     aServerInfo.iRoundTripDelayInMS = iSessionInfo.roundTripDelay;
+    aServerInfo.iServerVersionNumber = iSessionInfo.iServerVersionNumber;
     return PVMFSuccess;
 }
 
@@ -656,12 +691,10 @@
             return PVMFFailure;
         }
         //\engines\player\src\pv_player_sdkinfo.h
-        // Use the sdkinfo label from pv_player_sdkinfo.h for the base and
-        // then append anything set from above
-        //
-        // @todo Still need to account for Windows Media streaming.
-        iSessionInfo.iUserAgent = PVPLAYER_ENGINE_SDKINFO_LABEL;
-        iSessionInfo.iUserAgent += (char*)tmpBuf;
+        //#define PVPLAYER_ENGINE_SDKINFO_LABEL "PVPLAYER 04.07.00.01"
+        //iSessionInfo.iUserAgent = PVPLAYER_ENGINE_SDKINFO_LABEL;
+        //iSessionInfo.iUserAgent += (char*)tmpBuf;
+        iSessionInfo.iUserAgent = (char*)tmpBuf;
     }
 
     if (aUserNetwork.get_size() > 0)
@@ -827,14 +860,56 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::HandleSocketEvent() In aId=%d, aFxn=%d, aEvent=%d, aError=%d", aId, aFxn, aEvent, aError));
 
-    iNumOfCallback--;
+    //update socket container state.
+    //note we only update iRecvSocket container when it's a unique socket.
+    SocketContainer* container;
+    switch (aId)
+    {
+        case REQ_RECV_SOCKET_ID:
+            container = &iRecvSocket;
+            break;
+        case REQ_SEND_SOCKET_ID:
+            container = &iSendSocket;
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::HandleSocketEvent() ERROR invalid aId=%d", aId));
+            return;
+    }
+    //clear the appropriate cmd pending & canceled flags.
+    switch (aFxn)
+    {
+        case EPVSocketConnect:
+            container->iConnectState.Reset();
+            OSCL_ASSERT(iNumConnectCallback > 0);
+            iNumConnectCallback--;
+            break;
+        case EPVSocketRecv:
+            container->iRecvState.Reset();
+            OSCL_ASSERT(iNumRecvCallback > 0);
+            iNumRecvCallback--;
+            break;
+        case EPVSocketSend:
+            container->iSendState.Reset();
+            OSCL_ASSERT(iNumSendCallback > 0);
+            iNumSendCallback--;
+            break;
+        case EPVSocketShutdown:
+            container->iShutdownState.Reset();
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::HandleSocketEvent() ERROR invalid aFxn=%d", aFxn));
+            return;
+    }
+
     if (!IsAdded())
     {//prevent the leave 49. should never get here
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::HandleSocketEvent() ERROR line %d", __LINE__));
         return;
     }
-    if ((aId != REQ_SEND_SOCKET_ID) && (aId != REQ_RECV_SOCKET_ID) && (PVRTSP_ENGINE_NODE_STATE_WAIT_CALLBACK == iState))
-    {//waiting for the callback to finish the Stop() or Reset()
+
+    //For socket cleanup sequence including Stop & Reset command
+    if (iSocketCleanupState != ESocketCleanup_Idle)
+    {
         RunIfNotReady();
         return;
     }
@@ -852,7 +927,7 @@
         if (EPVSocketSuccess == aEvent)
         {
             int32 incomingMessageLen;
-            uint8* recvData = iRecvSocket->GetRecvData(&incomingMessageLen);
+            uint8* recvData = iRecvSocket.iSocket->GetRecvData(&incomingMessageLen);
             OSCL_UNUSED_ARG(recvData);
 
 #ifdef MY_RTSP_DEBUG
@@ -891,7 +966,7 @@
         {//there is one resp waiting on queue because there was a send() pending
             bSrvRespPending = false;
 
-            if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *iSrvResponse))
+            if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *iSrvResponse))
             {
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::HandleSocketEvent() sendSocketOutgoingMsg() error"));
             }
@@ -920,16 +995,27 @@
 //************ begin OsclDNSObserver
 OSCL_EXPORT_REF void PVRTSPEngineNode::HandleDNSEvent(int32 aId, TPVDNSFxn aFxn, TPVDNSEvent aEvent, int32 aError)
 {
+    OSCL_UNUSED_ARG(aEvent);
+
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::HandleDNSEvent() In aId=%d, aFxn=%d, aEvent=%d, aError=%d", aId, aFxn, aEvent, aError));
 
-    iNumOfCallback--;
+    //clear the cmd Pending and Canceled flags
+    iDNS.iState.Reset();
+
+    if (aFxn == EPVDNSGetHostByName)
+    {
+        OSCL_ASSERT(iNumHostCallback > 0);
+        iNumHostCallback--;
+    }
     if (!IsAdded())
     {//prevent the leave 49. should never get here
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::HandleSocketEvent() ERROR line %d", __LINE__));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::HandleDNSEvent() ERROR line %d", __LINE__));
         return;
     }
-    if ((aId != REQ_DNS_LOOKUP_ID) && (PVRTSP_ENGINE_NODE_STATE_WAIT_CALLBACK == iState))
-    {//waiting for the callback to finish the Stop() or Reset()
+
+    //For socket cleanup sequence including Stop & Reset command
+    if (iSocketCleanupState != ESocketCleanup_Idle)
+    {
         RunIfNotReady();
         return;
     }
@@ -966,6 +1052,13 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::Run() In"));
 
+    //Drive the reset sequence
+    if (iSocketCleanupState != ESocketCleanup_Idle)
+    {
+        if (resetSocket() == PVMFPending)
+            return;//keep waiting on callbacks.
+    }
+
     //Process commands.
     if (iPendingCmdQueue.size() > 0)
     {
@@ -1032,7 +1125,7 @@
                     ReportInfoEvent(PVMFInfoErrorHandlingStart);
                     partialResetSessionInfo();
                     clearOutgoingMsgQueue();
-                    resetSocket();
+                    PVMFStatus status = resetSocket();
 
                     PVRTSPEngineCommand cmd;
                     //const OsclAny* aContext = OSCL_STATIC_CAST(OsclAny*, errorContext);
@@ -1041,7 +1134,8 @@
                     cmd.iParam1 = OSCL_STATIC_CAST(OsclAny*, errorContext);
 
                     iRunningCmdQueue.AddL(cmd);
-                    RunIfNotReady();
+                    if (status != PVMFPending)
+                        RunIfNotReady();
                 }
             }
         }
@@ -1066,10 +1160,6 @@
         for (uint32 i = 0;i < iPortVector.size();i++)
             iPortVector[i]->ResumeInput();
         CommandComplete(iRunningCmdQueue, iRunningCmdQueue.front(), PVMFSuccess);
-        if (!iCancelCmdQueue.empty())
-        {
-            CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
-        }
         RunIfNotReady();
     }
 
@@ -1081,6 +1171,7 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::Run() Out"));
 }
 
+
 /**
 //A routine to tell if a flush operation is in progress.
 */
@@ -1168,27 +1259,22 @@
 bool PVRTSPEngineNode::ProcessCommand(PVRTSPEngineCommand& aInCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::ProcessCommand() in"));
-    //normally this node will not start processing one command
-    //until the prior one is finished.  However, a hi priority
-    //command such as Cancel must be able to interrupt a command
-    //in progress.
-    /*
-    int32 tmpCmd = aCmd.iCmd;
-    if(iRunningCmdQueue.size()>0 && !aCmd.hipri())
-    {
-    	tmpCmd = iRunningCmdQueue.front().iCmd;
-    }
 
-    switch(tmpCmd)
-    	*/
+    //don't interrupt a cancel command
+    if (!iCancelCmdQueue.empty())
+        return false;
+    if (!iRunningCmdQueue.empty()
+            && iRunningCmdQueue.front().iCmd == PVMF_RTSP_NODE_CANCELALLRESET)
+        return false;
 
+    //don't interrupt a running command unless this is hi-priority command
+    //such as a cancel.
     if (iRunningCmdQueue.size() > 0 && !aInCmd.hipri())
         return false;
 
     {
-        //the Init is asynchronous.  move the command from
-        //the pending command queue to the running command queue, where
-        //it will remain until the flush completes.
+        //move the command from the pending command queue to the
+        //running command queue, where it will remain until it completes.
         int32 err;
         OSCL_TRY(err, iRunningCmdQueue.StoreL(aInCmd););
 
@@ -1275,6 +1361,7 @@
             break;
 
         case PVMF_GENERIC_NODE_RESET:
+        case PVMF_RTSP_NODE_CANCELALLRESET:
             iRet = DoResetNode(aCmd);
             if (iRet != PVMFPending)
             {
@@ -1284,13 +1371,7 @@
                 partialResetSessionInfo();
                 ResetSessionInfo();
                 clearOutgoingMsgQueue();
-                resetSocket();
-
-                if (iRet == PVMFSuccess)
-                {
-                    ChangeExternalState(EPVMFNodeIdle);
-                }
-                iRet = ThreadLogoff();
+                iRet = resetSocket();
             }
             break;
 
@@ -1315,10 +1396,6 @@
             {
                 //Return the port pointer to the caller.
                 CommandComplete(iRunningCmdQueue, aCmd, iRet, (OsclAny*)aPort);
-                if (!iCancelCmdQueue.empty())
-                {
-                    CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
-                }
                 return iRet;
             }
         }
@@ -1336,8 +1413,9 @@
                 {//retry
                     partialResetSessionInfo();
                     clearOutgoingMsgQueue();
-                    resetSocket();
-                    RunIfNotReady();
+                    iRet = resetSocket();
+                    if (iRet != PVMFPending)
+                        RunIfNotReady();
                     return PVMFPending;
                 }
 
@@ -1417,6 +1495,7 @@
                     OSCL_TRY(err, errorContext = OSCL_NEW(PVRTSPErrorContext, ()));
                     if (err || (errorContext ==  NULL))
                     {
+                        iRet = PVMFFailure; // reinitialized since it may be clobbered by OSCL_TRY()
                         ChangeExternalState(EPVMFNodeError);
                     }
                     else
@@ -1426,7 +1505,8 @@
                         ReportInfoEvent(PVMFInfoErrorHandlingStart);
                         partialResetSessionInfo();
                         clearOutgoingMsgQueue();
-                        resetSocket();
+                        PVMFStatus status = resetSocket();
+
                         iState = PVRTSP_ENGINE_NODE_STATE_IDLE;
 
                         PVRTSPEngineCommand cmd;
@@ -1436,8 +1516,9 @@
                         cmd.iParam1 = OSCL_STATIC_CAST(OsclAny*, errorContext);
 
                         iRunningCmdQueue.AddL(cmd);
-                        RunIfNotReady();
 
+                        if (status != PVMFPending)
+                            RunIfNotReady();
                         return PVMFPending;
                     }
                 }
@@ -1445,20 +1526,12 @@
             if (iCurrentErrorCode != PVMFRTSPClientEngineNodeErrorEventStart)
             {
                 CommandComplete(iRunningCmdQueue, aCmd, iRet, NULL, &iEventUUID, &iCurrentErrorCode);
-                if (!iCancelCmdQueue.empty())
-                {
-                    CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
-                }
                 /* Reset error code */
                 iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorEventStart;
                 return iRet;
             }
         }
         CommandComplete(iRunningCmdQueue, aCmd, iRet);
-        if (!iCancelCmdQueue.empty())
-        {
-            CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
-        }
     }
     return iRet;
 }
@@ -1478,6 +1551,42 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
                     , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
 
+    //Do special handling of some commands.
+    switch (aCmd.iCmd)
+    {
+
+        case PVMF_RTSP_NODE_CANCELALLRESET:
+            //restore command ID
+            aCmd.iCmd = PVMF_GENERIC_NODE_CANCELALLCOMMANDS;
+            break;
+
+        case PVMF_GENERIC_NODE_RESET:
+            if (aStatus == PVMFSuccess)
+                ChangeExternalState(EPVMFNodeIdle);
+            ThreadLogoff();
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+            //Add a reset sequence to the end of "Cancel all" processing, in order to
+            //satisfy the expectation of streaming manager node.
+        {
+            //change the command type to "cancelallreset"
+            aCmd.iCmd = PVMF_RTSP_NODE_CANCELALLRESET;
+            //move command from cancel command queue to running command queue
+            //if necessary.  we do this because this node is only setup to
+            //continue processing commands in the running queue.
+            if (&aCmdQ == &iCancelCmdQueue)
+            {
+                iRunningCmdQueue.StoreL(aCmd);
+                aCmdQ.Erase(&aCmd);
+            }
+            RunIfNotReady();
+            return;
+        }
+        default:
+            break;
+    }
+
     PVInterface* extif = NULL;
     PVMFBasicErrorInfoMessage* errormsg = NULL;
     if (aEventUUID && aEventCode)
@@ -1500,6 +1609,14 @@
     {
         errormsg->removeRef();
     }
+
+    //There may be a cancel command that was just waiting on the running command to finish.
+    //If so, complete the cancel command now.
+    if (&aCmdQ == &iRunningCmdQueue
+            && !iCancelCmdQueue.empty())
+    {
+        CommandComplete(iCancelCmdQueue, iCancelCmdQueue.front(), PVMFSuccess);
+    }
 }
 
 // Handle command and data events
@@ -1512,6 +1629,7 @@
     //wakeup the AO
     RunIfNotReady();
 
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::AddCmdToQueue() Cmd Id %d", id));
     return id;
 }
 
@@ -1589,34 +1707,43 @@
             iRTSPParser->flush();
 
             // 1. Do DNS look up if needed.
-            if (OsclValidInetAddr(iSessionInfo.iProxyName.get_cstr()))
+            OSCL_HeapString<PVRTSPEngineNodeAllocator> endPointName = iSessionInfo.iServerName;
+            if (iSessionInfo.iProxyName.get_size())
+            {
+                iSessionInfo.iSrvAdd.port = iSessionInfo.iProxyPort;
+                endPointName = iSessionInfo.iProxyName;
+            }
+
+            if (OsclValidInetAddr(endPointName.get_cstr()))
             {//ip address
-                iSessionInfo.iSrvAdd.ipAddr.Set(iSessionInfo.iProxyName.get_cstr());
+                iSessionInfo.iSrvAdd.ipAddr.Set(endPointName.get_cstr());
                 ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_CONNECT);
                 RunIfNotReady();
             }
             else
             {//dns lookup
-                if (NULL == iDNS)
+                if (NULL == iDNS.iDns)
                 {
                     REQ_DNS_LOOKUP_ID =  ++BASE_REQUEST_ID;
-                    iDNS = OsclDNS::NewL(iAlloc, *iSockServ, *this, REQ_DNS_LOOKUP_ID);
+                    iDNS.iDns = OsclDNS::NewL(iAlloc, *iSockServ, *this, REQ_DNS_LOOKUP_ID);
                 }
-                if (iDNS == NULL)
+                if (iDNS.iDns == NULL)
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorDNSLookUpError;
                     iRet =  PVMFFailure;
                     break;
                 }
+                iDNS.iState.Reset();
 
                 iSessionInfo.iSrvAdd.ipAddr.Set("");
-                if (EPVDNSPending != iDNS->GetHostByName(iSessionInfo.iProxyName.get_str(), iSessionInfo.iSrvAdd, TIMEOUT_CONNECT_AND_DNS_LOOKUP))
+                if (EPVDNSPending != iDNS.iDns->GetHostByName(endPointName.get_str(), iSessionInfo.iSrvAdd, TIMEOUT_CONNECT_AND_DNS_LOOKUP))
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorDNSLookUpError;
                     iRet =  PVMFFailure;
                     break;
                 }
-                iNumOfCallback++;
+                iDNS.iState.iPending = true;
+                iNumHostCallback++;
                 ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_DNS_RESOLVING);
             }
             break;
@@ -1639,28 +1766,35 @@
                 break;
             }
             {
-                REQ_SEND_SOCKET_ID = BASE_REQUEST_ID++;
+                //Allocate 1 TCP socket and set both iSendSocket and iRecvSocket to that socket.
+                //Note: in this case we only track the status in the "send" container since
+                //it's really only one socket.
                 int32 err;
-                //OSCL_TRY(err,iSendSocket=OsclTCPSocket::NewL(iAlloc,*iSockServ,this,REQ_SEND_SOCKET_ID););
-                OSCL_TRY(err, iSendSocket = iRecvSocket = OsclTCPSocket::NewL(iAlloc, *iSockServ, this, REQ_SEND_SOCKET_ID););
-                if (err || (iSendSocket ==  NULL))
+                OsclTCPSocket *sock = NULL;
+                OSCL_TRY(err, sock = OsclTCPSocket::NewL(iAlloc, *iSockServ, this, REQ_SEND_SOCKET_ID););
+                if (err || (sock ==  NULL))
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorRTSPSocketCreateError;
                     iRet =  PVMFFailure;
                     break;
                 }
+                iRecvSocket.Reset(sock);
+                iSendSocket.Reset(sock);
 
                 //proxy support
                 //OSCL_StackString<64> tmpServerName = _STRLIT_CHAR("172.16.2.145");
                 //iSessionInfo.iSrvAdd.ipAddr.Set( tmpServerName.get_cstr() );
 
-                if (iSendSocket->Connect(iSessionInfo.iSrvAdd, TIMEOUT_CONNECT_AND_DNS_LOOKUP) != EPVSocketPending)
+                TPVSocketEvent sendConnect = iSendSocket.iSocket->Connect(iSessionInfo.iSrvAdd, TIMEOUT_CONNECT_AND_DNS_LOOKUP);
+                if (sendConnect == EPVSocketPending)
+                    iSendSocket.iConnectState.iPending = true;
+                if (sendConnect != EPVSocketPending)
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorRTSPSocketConnectError;
                     iRet =  PVMFFailure;
                     break;
                 }
-                iNumOfCallback++;
+                iNumConnectCallback++;
             }
 
             ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_CONNECTING);
@@ -1795,7 +1929,7 @@
                     break;
                 }
 
-                if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+                if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
                     OSCL_DELETE(tmpOutgoingMsg);
@@ -1868,7 +2002,7 @@
                     break;
                 }
 
-                if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+                if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
                     OSCL_DELETE(tmpOutgoingMsg);
@@ -2147,8 +2281,7 @@
                 }
                 setupTrackIndex ++;
 
-                if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
-                    //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+                if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
                 {
                     /* need to pop the msg based on cseq, NOT necessarily the early ones,
                     although YES in this case.
@@ -2204,16 +2337,26 @@
 
 bool PVRTSPEngineNode::parseURL(const char *aUrl)
 {
+    /* Input: absolute URI
+     * Output: iSessionInfo.iSessionURL, iSessionInfo.iServerName, and iSessionInfo.iSrvAdd.port
+     * Connection end point is always iSrvAdd
+     * if no proxy is used, iSrvAdd.ipAddr is ip of iServerName and iSrvAdd.port is the server port.
+     * Both derived from an absolute url.
+     * if proxy is used, iSrvAdd is iProxyName:iProxyPort.
+     */
     if (aUrl == NULL)
     {
         return false;
     }
 
+    uint32 aURLMaxOutLength;
+    PVStringUri::PersentageToEscapedEncoding((mbchar*) aUrl, aURLMaxOutLength);
+    PVStringUri::IllegalCharactersToEscapedEncoding((mbchar*) aUrl, aURLMaxOutLength);
+
     iSessionInfo.iSessionURL = ((mbchar*)aUrl);
     OSCL_HeapString<PVRTSPEngineNodeAllocator> tmpURL = ((mbchar*)aUrl);
 
-    mbchar *server_ip_ptr, *clip_name, *server_port_ptr;
-    server_ip_ptr = oscl_strstr(((mbchar*)tmpURL.get_cstr()), "//");
+    mbchar *server_ip_ptr = OSCL_CONST_CAST(mbchar*, oscl_strstr(((mbchar*)tmpURL.get_cstr()), "//"));
     if (server_ip_ptr == NULL)
     {
         return false;
@@ -2221,9 +2364,9 @@
 
     server_ip_ptr += 2;
 
-    /* Locate the IP address. */
-    server_port_ptr = oscl_strstr(server_ip_ptr, ":");
-    clip_name = oscl_strstr(server_ip_ptr, "/");
+    /* Locate the server name. */
+    mbchar *server_port_ptr = OSCL_CONST_CAST(mbchar*, oscl_strstr(server_ip_ptr, ":"));
+    mbchar *clip_name = OSCL_CONST_CAST(mbchar*, oscl_strstr(server_ip_ptr, "/"));
     if (clip_name != NULL)
     {
         *clip_name++ = '\0';
@@ -2244,15 +2387,6 @@
     OSCL_HeapString<PVRTSPEngineNodeAllocator> tmpServerName(server_ip_ptr, oscl_strlen(server_ip_ptr));
     iSessionInfo.iServerName = tmpServerName;
 
-    if (iSessionInfo.iProxyName.get_size() == 0)
-    {
-        iSessionInfo.iProxyName = tmpServerName;
-    }
-    else
-    {
-        iSessionInfo.iSrvAdd.port = iSessionInfo.iProxyPort;
-    }
-
 //iSessionInfo.iSrvAdd.port = 20080;
 //iSessionInfo.iServerName = "172.16.2.42";
 
@@ -2381,9 +2515,9 @@
     }
 
     iSessionInfo.clientServerDelay = 0;
-    uint64 timebase64 = 0;
-    uint64 clock = 0;
-    iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
+    uint32 clock = 0;
+    bool overflowFlag = false;
+    iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
     iSessionInfo.clientServerDelay = clock;
 
     //iSessionInfo.composedMessage = iMsg.retrieveComposedBuffer();
@@ -2446,8 +2580,7 @@
 
     if (bNoSendPending)// bSrvRespPending
     {
-        if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *iSrvResponse))
-            //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *iSrvResponse))
+        if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *iSrvResponse))
         {
             /* need to pop the msg based on cseq, NOT necessarily the early ones,
             although YES in this case.
@@ -2534,8 +2667,7 @@
 
     if (bNoSendPending)// bSrvRespPending
     {
-        if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *iSrvResponse))
-            //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *iSrvResponse))
+        if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *iSrvResponse))
         {
             /* need to pop the msg based on cseq, NOT necessarily the early ones,
             although YES in this case.
@@ -2559,6 +2691,7 @@
     }
 
     PVMFStatus tmpRet = PVMFSuccess;
+    OSCL_UNUSED_ARG(aEntityMemFrag);
     return tmpRet;
 }
 
@@ -2568,6 +2701,14 @@
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::DoStartNode() In"));
     OSCL_UNUSED_ARG(aCmd);
 
+    //If session is completed, then do not send the play command to the server..
+    if (IsSessionCompleted() && !bRepositioning)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::DoStartNode() Skipping sending play 'cos of session expiry"));
+        ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_PLAY_DONE);
+        return PVMFSuccess;
+    }
+
     if (iInterfaceState != EPVMFNodePrepared &&
             iInterfaceState != EPVMFNodePaused)
     {
@@ -2608,8 +2749,7 @@
                 break;
             }
 
-            if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
-                //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+            if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
             {
                 iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
                 OSCL_DELETE(tmpOutgoingMsg);
@@ -2617,9 +2757,12 @@
                 break;
             }
 
+            bNoSendPending = false;
             iOutgoingMsgQueue.push(tmpOutgoingMsg);
 
             ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_WAIT_PLAY);
+            //setup the watch dog for server response
+            iWatchdogTimer->Request(REQ_TIMER_WATCHDOG_ID, 0, TIMEOUT_WATCHDOG);
             RunIfNotReady();
             break;
         }
@@ -2875,9 +3018,9 @@
     }
 
     iSessionInfo.clientServerDelay = 0;
-    uint64 timebase64 = 0;
-    uint64 clock = 0;
-    iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
+    uint32 clock = 0;
+    bool overflowFlag = false;
+    iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
     iSessionInfo.clientServerDelay = clock;
 
     return PVMFSuccess;
@@ -2972,9 +3115,9 @@
     //iSessionInfo.composedMessage = aMsg.retrieveComposedBuffer();
 
     iSessionInfo.clientServerDelay = 0;
-    uint64 timebase64 = 0;
-    uint64 clock = 0;
-    iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
+    uint32 clock = 0;
+    bool overflowFlag = false;
+    iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
     iSessionInfo.clientServerDelay = clock;
 
     return PVMFSuccess;
@@ -3011,9 +3154,9 @@
     }
 
     iSessionInfo.clientServerDelay = 0;
-    uint64 timebase64 = 0;
-    uint64 clock = 0;
-    iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
+    uint32 clock = 0;
+    bool overflowFlag = false;
+    iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
     iSessionInfo.clientServerDelay = clock;
 
     return PVMFSuccess;
@@ -3029,6 +3172,9 @@
     aMsg.cseq = iOutgoingSeq++;
     aMsg.cseqIsSet = true;
 
+    aMsg.userAgent = iSessionInfo.iUserAgent.get_cstr();
+    aMsg.userAgentIsSet = true;
+
     if (iSessionInfo.iSID.get_size())
     {
         aMsg.sessionId.setPtrLen(iSessionInfo.iSID.get_cstr(), iSessionInfo.iSID.get_size());
@@ -3049,9 +3195,9 @@
     }
 
     iSessionInfo.clientServerDelay = 0;
-    uint64 timebase64 = 0;
-    uint64 clock = 0;
-    iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
+    uint32 clock = 0;
+    bool overflowFlag = false;
+    iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
     iSessionInfo.clientServerDelay = clock;
 
     return PVMFSuccess;
@@ -3219,7 +3365,7 @@
     if ((aMsg.sessionIdIsSet) && (iSessionInfo.iSID.get_size() == 0))
     {
         //because the RTSP parser just gives "d2ecb87b0816b4a;timeout=60"
-        char *timeout_location = oscl_strstr(aMsg.sessionId.c_str(), ";timeout");
+        char *timeout_location = OSCL_CONST_CAST(char*, oscl_strstr(aMsg.sessionId.c_str(), ";timeout"));
         if (NULL != timeout_location)
         {
             OSCL_HeapString<PVRTSPEngineNodeAllocator> tmpSID(aMsg.sessionId.c_str(), timeout_location - aMsg.sessionId.c_str());
@@ -3270,22 +3416,26 @@
             iSessionInfo.pvServerIsSetFlag = false;
         }
     }
-
     /*
-    if( !oscl_strncmp( aMsg.queryField(server)->getPtr(), PipelineServer, oscl_strlen(PipelineServer)) )
+     * Check for PVServer version number
+     */
+    if (NULL != serverTag)
     {
-    pSessionInfo->imperialPlusServerFlag = true;
-    if( pSessionInfo->composedData->method != METHOD_DESCRIBE ){
-    pSessionInfo->pipeLineFlag = true;
+        if (iSessionInfo.pvServerIsSetFlag)
+        {
+            OSCL_StackString<8> pvServerVersionNumberLocator(_STRLIT_CHAR("/"));
+            const char *versionNumberLocation = oscl_strstr(serverTag->c_str(), pvServerVersionNumberLocator.get_cstr());
+            if (NULL != versionNumberLocation)
+            {
+                uint32 versionNumber = 0;
+                if (PV_atoi(versionNumberLocation + 1, 'd', 1, versionNumber))
+                {
+                    iSessionInfo.iServerVersionNumber = versionNumber;
+                }
+            }
+        }
     }
-    }
-    if( !oscl_strncmp( aMsg.queryField(server)->getPtr(), PVConnect, oscl_strlen(PVConnect)) )
-    {
-    pvConnectFlag = true;
-    pmb->setPVConnectFlag(true);
-    }
-    }
-    */
+
     return PVMFSuccess;
 }
 
@@ -3375,12 +3525,12 @@
                             //between "RTP/AVP/UDP" or "x-pn-tng/tcp"; and for "x-pn-tng/tcp",
                             //we only do http cloaking. 06/03/21
                             ibIsRealRDT = false;
-                            if ((iIncomingMsg.transport[0].protocol != RtspTransport::RTP_PROTOCOL)
-                                    || (iIncomingMsg.transport[0].profile != RtspTransport::AVP_PROFILE))
-                            {//PVMFRTSPClientEngineNodeErrorUnsupportedTransport
-                                iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorMalformedRTSPMessage;
-                                return PVMFFailure;
-                            }
+                                if ((iIncomingMsg.transport[0].protocol != RtspTransport::RTP_PROTOCOL)
+                                        || (iIncomingMsg.transport[0].profile != RtspTransport::AVP_PROFILE))
+                                {//PVMFRTSPClientEngineNodeErrorUnsupportedTransport
+                                    iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorMalformedRTSPMessage;
+                                    return PVMFFailure;
+                                }
                         }
 
                         iSessionInfo.iSelectedStream[i].ssrcIsSet = iIncomingMsg.transport[0].ssrcIsSet;
@@ -3434,10 +3584,10 @@
                 iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorMissingSessionIdInServerResponse;
                 return PVMFFailure;
             }
-            uint64 timebase64 = 0;
-            uint64 clock = 0;
-            iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
-            clock -= iSessionInfo.clientServerDelay;
+            uint32 clock = 0;
+            bool overflowFlag = false;
+            iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+            clock -= (uint32)iSessionInfo.clientServerDelay;
             iSessionInfo.clientServerDelay = clock;
             iSessionInfo.roundTripDelay =
                 Oscl_Int64_Utils::get_uint64_lower32(iSessionInfo.clientServerDelay);
@@ -3499,10 +3649,10 @@
                     iSessionInfo.iSelectedStream[i].iSerIpAddr.Set(iSessionInfo.iSrvAdd.ipAddr.Str());
                 }
             }
-            uint64 timebase64 = 0;
-            uint64 clock = 0;
-            iRoundTripClockTimeBase.GetCurrentTime64(clock, OSCLCLOCK_MSEC, timebase64);
-            clock -= iSessionInfo.clientServerDelay;
+            uint32 clock = 0;
+            bool overflowFlag = false;
+            iRoundTripClockTimeBase.GetCurrentTime32(clock, overflowFlag, PVMF_MEDIA_CLOCK_MSEC);
+            clock -= (uint32)iSessionInfo.clientServerDelay;
             iSessionInfo.clientServerDelay = clock;
             iSessionInfo.roundTripDelay =
                 Oscl_Int64_Utils::get_uint64_lower32(iSessionInfo.clientServerDelay);
@@ -3537,11 +3687,30 @@
                 return PVMFFailure;
             }
         }
-        iErrorRecoveryAttempt = 1; //only use error recovery for redirect
+        else
+        {
+            return PVMFFailure;   //If Location is not present in response
+        }
+        iErrorRecoveryAttempt = iNumRedirectTrials-- ? 1 : 0;
+        if (iErrorRecoveryAttempt == 0)
+        {
+            iCurrentErrorCode = infocode; // Send error to application
+            return PVMFFailure;
+        }
         return PVMFInfoRemoteSourceNotification;
     }
     else
     {
+        if (tmpOutgoingMsg)
+        {
+            if (tmpOutgoingMsg->method == METHOD_OPTIONS)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::processIncomingMessage() OPTIONS ERROR %d Line %d", iIncomingMsg.statusCode, __LINE__));
+                OSCL_DELETE(tmpOutgoingMsg);
+                return iOutgoingMsgQueue.empty() ? PVMFSuccess : PVMFPending;
+            }
+        }
+
         //error
         MapRTSPCodeToEventCode(iIncomingMsg.statusCode, iCurrentErrorCode);
         OSCL_DELETE(tmpOutgoingMsg);
@@ -3728,6 +3897,14 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::DoPauseNode() In"));
 
+    //If session is completed, then do not send the pause command to the server..
+    if (IsSessionCompleted())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::DoPauseNode() Skipping sending pause 'cos of session expiry"));
+        ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_PAUSE_DONE);
+        return PVMFSuccess;
+    }
+
     if (iInterfaceState != EPVMFNodeStarted)
     {
         return PVMFErrInvalidState;
@@ -3741,6 +3918,10 @@
 
     if ((iInterfaceState != EPVMFNodeStarted) && (iInterfaceState != EPVMFNodePaused))
     {
+        if (iInterfaceState == EPVMFNodeError)
+        {
+            return PVMFSuccess;
+        }
         return PVMFErrInvalidState;
     }
     return SendRtspTeardown(aCmd);
@@ -3776,8 +3957,7 @@
                     return  PVMFFailure;
                 }
 
-                if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
-                    //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+                if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
                 {
                     /* need to pop the msg based on cseq, NOT necessarily the early ones,
                     although YES in this case.
@@ -3894,8 +4074,7 @@
                     OSCL_DELETE(tmpOutgoingMsg);
                     return  PVMFFailure;
                 }
-                if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
-                    //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+                if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
                 {
                     iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
                     OSCL_DELETE(tmpOutgoingMsg);
@@ -3907,7 +4086,7 @@
                 }
 
                 //setup the watchdog for server response
-                iWatchdogTimer->Request(REQ_TIMER_WATCHDOG_ID, 0, TIMEOUT_WATCHDOG);
+                iWatchdogTimer->Request(REQ_TIMER_WATCHDOG_ID, 0, TIMEOUT_WATCHDOG_TEARDOWN);
 
                 bNoSendPending = false;
                 iOutgoingMsgQueue.push(tmpOutgoingMsg);
@@ -3917,7 +4096,8 @@
         }
 
         case PVRTSP_ENGINE_NODE_STATE_WAIT_CALLBACK:
-            if (iNumOfCallback == 0)
+            if ((iNumHostCallback + iNumConnectCallback + iNumSendCallback + iNumRecvCallback) == 0
+                    && resetSocket() != PVMFPending)
             {
                 iRet = PVMFSuccess;
                 ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_CONNECT);
@@ -3938,23 +4118,14 @@
             clearOutgoingMsgQueue();
             iSocketEventQueue.clear();
 
-            if (iSendSocket)
-            {
-                iSendSocket->CancelRecv();
-                iSendSocket->CancelSend();
-            }
-            if (iRecvSocket)
-            {
-                iRecvSocket->CancelRecv();
-                iRecvSocket->CancelSend();
-            }
-            REQ_RECV_SOCKET_ID = REQ_SEND_SOCKET_ID = 0;
+            PVMFStatus status = resetSocket();
 
             iWatchdogTimer->Cancel(REQ_TIMER_WATCHDOG_ID);
             iWatchdogTimer->Cancel(REQ_TIMER_KEEPALIVE_ID);
             REQ_TIMER_WATCHDOG_ID = REQ_TIMER_KEEPALIVE_ID = 0;
 
-            if (iNumOfCallback == 0)
+            if ((iNumHostCallback + iNumConnectCallback + iNumSendCallback + iNumRecvCallback) == 0
+                    && status != PVMFPending)
             {
                 iRet = PVMFSuccess;
                 ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_CONNECT);
@@ -4004,12 +4175,30 @@
     PVInterface** ptr;
     aCmd.PVRTSPEngineCommandBase::Parse(uuid, ptr);
 
-    //if (*uuid==PVUuid(KPVRTSPEngineNodeExtensionUuid))
     if (*uuid == KPVRTSPEngineNodeExtensionUuid)
     {
-        addRef();
-        *ptr = this;
-        return PVMFSuccess;
+        if (!iExtensionInterface)
+        {
+            iExtensionInterface = OSCL_NEW(PVRTSPEngineNodeExtensionInterfaceImpl, (this));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PVRTSPEngineNode:DoQueryInterface iExtensionInterface %x "
+                             , iExtensionInterface));
+        }
+        if (iExtensionInterface)
+        {
+            if (iExtensionInterface->queryInterface(*uuid, *ptr))
+            {
+                return PVMFSuccess;
+            }
+            else
+            {
+                return PVMFErrNotSupported;
+            }
+        }
+        else
+        {
+            return PVMFErrNoMemory;
+        }
     }
     else
     {//not supported
@@ -4023,7 +4212,7 @@
                                         PVUuid* aEventUUID,
                                         int32* aEventCode)
 {
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                     (0, "PVRTSPEngineNode:NodeErrorEvent Type %d Data %d"
                      , aEventType, aEventData));
 
@@ -4203,8 +4392,7 @@
                 //iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorRTSPComposeStopRequestError;
                 return;
             }
-            if (PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
-                //if( PVMFSuccess != sendSocketOutgoingMsg(*iSendSocket, *tmpOutgoingMsg))
+            if (PVMFSuccess != sendSocketOutgoingMsg(iSendSocket, *tmpOutgoingMsg))
             {
                 iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
                 OSCL_DELETE(tmpOutgoingMsg);
@@ -4229,6 +4417,8 @@
     aMsg.method = iKeepAliveMethod;
     aMsg.cseq = iOutgoingSeq++;
     aMsg.cseqIsSet = true;
+    aMsg.userAgent = iSessionInfo.iUserAgent.get_cstr();
+    aMsg.userAgentIsSet = true;
 
     if (iSessionInfo.iSID.get_size())
     {
@@ -4302,6 +4492,22 @@
     return PVMFSuccess;
 }
 
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNode::GetRTSPTimeOut(int32 &aTimeout)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::GetRTSPTimeOut() In"));
+
+    aTimeout = TIMEOUT_WATCHDOG;
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNode::SetRTSPTimeOut(int32 aTimeout)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::SetRTSPTimeOut() In"));
+
+    TIMEOUT_WATCHDOG = aTimeout;
+    return PVMFSuccess;
+}
+
 PVMFStatus PVRTSPEngineNode::DoRequestPort(PVRTSPEngineCommand &aCmd, PVMFRTSPPort* &aPort)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::DoRequestPort() In"));
@@ -4322,13 +4528,15 @@
     }
 
     //portconfig should be "sdpTrackIndex=5/media" or "sdpTrackIndex=5/feedback"
+
+
     bool bIsMedia = true;
     OSCL_StackString<128> IsMedia("/media");
-    char *tmpCh = oscl_strstr(head, IsMedia.get_cstr());
+    char *tmpCh = OSCL_CONST_CAST(char*, oscl_strstr(head, IsMedia.get_cstr()));
     if (!tmpCh)
     {
         OSCL_StackString<128> IsFeedback("/feedback");
-        tmpCh = oscl_strstr(head, IsFeedback.get_cstr());
+        tmpCh = OSCL_CONST_CAST(char*, oscl_strstr(head, IsFeedback.get_cstr()));
         if (!tmpCh)
         {
             return PVMFErrArgument;
@@ -4337,7 +4545,7 @@
     }
     *tmpCh = '\0';	//set the delimiter for atoi
     OSCL_StackString<128> sdpTrackIndex("sdpTrackIndex=");
-    tmpCh = oscl_strstr(head, sdpTrackIndex.get_cstr());
+    tmpCh = OSCL_CONST_CAST(char*, oscl_strstr(head, sdpTrackIndex.get_cstr()));
     if (!tmpCh)
     {
         return PVMFErrArgument;
@@ -4356,19 +4564,27 @@
         return PVMFErrArgument;//invalide portconfig.
     }
 
+    // statements were moved to sep. function to  remove compiler warnings caused by OSCL_TRY()
+    return DoAddPort(tmpId, bIsMedia, tag, aPort);
+}
 
-    int32 leavecode = 0;
+
+PVMFStatus PVRTSPEngineNode::DoAddPort(int32 id, bool isMedia, int32 tag, PVMFRTSPPort* &aPort)
+{
+    int32 leavecode;
+
     OSCL_TRY(leavecode,
-             aPort = OSCL_STATIC_CAST(PVMFRTSPPort*, OSCL_NEW(PVMFRTSPPort, (tmpId, bIsMedia, tag, this)));
+             aPort = OSCL_STATIC_CAST(PVMFRTSPPort*, OSCL_NEW(PVMFRTSPPort, (id, isMedia, tag, this)));
+             iPortVector.AddL(aPort);
             );
-    if (leavecode || aPort == NULL)
-    {//error
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::DoRequestPort() new port fail ERROR leavecode=%d Ln %d", leavecode, __LINE__));
-        return PVMFErrNoMemory;
-    }
-    OSCL_TRY(leavecode, iPortVector.AddL(aPort););
+
     if (leavecode != OsclErrNone)
     {
+        if (NULL == aPort)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::DoAddPort() new port fail ERROR leavecode=%d Ln %d", leavecode, __LINE__));
+        }
+
         return PVMFErrNoMemory;
     }
 
@@ -4490,7 +4706,6 @@
         return true;
     }
 
-
     uint32 i = 0;
     for (i = 0; i < vRdtPackets.size(); i++)
     {
@@ -4509,7 +4724,7 @@
 
         OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
         int32 err;
-        OSCL_TRY(err, mediaDataImplOut = ipFragGroupAllocator->allocate());
+        mediaDataImplOut = AllocateMediaData(err);
         OSCL_ASSERT(err == OsclErrNone); // we just checked that a message is available
         if (err != OsclErrNone)
         {
@@ -4567,6 +4782,7 @@
 
     return true;
 }
+
 PVMFStatus PVRTSPEngineNode::DoFlush(PVRTSPEngineCommand& aCmd)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::DoFlush() In"));
@@ -4589,7 +4805,7 @@
     return PVMFPending;
 }
 
-PVMFStatus PVRTSPEngineNode::sendSocketOutgoingMsg(OsclTCPSocket &aSock, RTSPOutgoingMessage &aMsg)
+PVMFStatus PVRTSPEngineNode::sendSocketOutgoingMsg(SocketContainer &aSock, RTSPOutgoingMessage &aMsg)
 {
     StrPtrLen *tmpStrPtrLen = aMsg.retrieveComposedBuffer();
     if (NULL == tmpStrPtrLen)
@@ -4599,47 +4815,35 @@
         return  PVMFFailure;
     }
     //PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"C ---> S\n%s", tmpStrPtrLen->c_str()));
-    //if( aSock->Send(REINTERPRET_CAST(const uint8*, tmpStrPtrLen->c_str()), tmpStrPtrLen->length(), TIMEOUT_SEND) != EPVSocketPending  )
-    if (aSock.Send((const uint8*)tmpStrPtrLen->c_str(), tmpStrPtrLen->length(), TIMEOUT_SEND) != EPVSocketPending)
+    if (aSock.iSocket->Send((const uint8*)tmpStrPtrLen->c_str(), tmpStrPtrLen->length(), TIMEOUT_SEND) != EPVSocketPending)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::sendSocketOutgoingMsg() Send() ERROR, line %d", __LINE__));
         iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
         return PVMFFailure;
     }
-    iNumOfCallback++;
+    SetSendPending(aSock);
+    iNumSendCallback++;
     return PVMFSuccess;
 }
 
-PVMFStatus PVRTSPEngineNode::sendSocketOutgoingMsg(OsclTCPSocket &aSock, const uint8* aSendBuf, uint32 aSendLen)
+PVMFStatus PVRTSPEngineNode::sendSocketOutgoingMsg(SocketContainer &aSock, const uint8* aSendBuf, uint32 aSendLen)
 {
-    if (aSock.Send(aSendBuf, aSendLen, TIMEOUT_SEND) != EPVSocketPending)
+    if (aSock.iSocket->Send(aSendBuf, aSendLen, TIMEOUT_SEND) != EPVSocketPending)
     {
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::sendSocketOutgoingMsg() Send() ERROR, line %d", __LINE__));
         iCurrentErrorCode = PVMFRTSPClientEngineNodeErrorSocketSendError;
         return PVMFFailure;
     }
-    iNumOfCallback++;
+    SetSendPending(aSock);
+    iNumSendCallback++;
     return PVMFSuccess;
 }
 
-void PVRTSPEngineNode::deleteSocket(OsclTCPSocket *&aTcpSock)
-{
-    if (aTcpSock)
-    {
-        aTcpSock->CancelRecv();
-        aTcpSock->CancelSend();
-        aTcpSock->Close();
-        aTcpSock->~OsclTCPSocket();
-        iAlloc.deallocate(aTcpSock);
-        aTcpSock = NULL;
-    }
-}
-
 //drive the parser, return true if there is a pending event
 bool PVRTSPEngineNode::rtspParserLoop(void)
 {
     if ((iRTSPParser == NULL) || (NULL != iTheBusyPort)
-            || (iRecvSocket == NULL) || (EPVMFNodeError == iInterfaceState))
+            || (iRecvSocket.iSocket == NULL) || (EPVMFNodeError == iInterfaceState))
     {
         return false;
     }
@@ -4660,7 +4864,7 @@
                     const StrPtrLen *tmpbuf = iRTSPParser->getDataBufferSpec();
                     if (tmpbuf)	// unlikely to fail, err rtn from getDataBufferSpec
                     {
-                        tmpEvent = iRecvSocket->Recv((uint8*)tmpbuf->c_str(), tmpbuf->length(), TIMEOUT_RECV);
+                        tmpEvent = iRecvSocket.iSocket->Recv((uint8*)tmpbuf->c_str(), tmpbuf->length(), TIMEOUT_RECV);
                     }
                     if (tmpEvent != EPVSocketPending)
                     {
@@ -4671,7 +4875,8 @@
                     }
                     else
                     {
-                        iNumOfCallback++;
+                        SetRecvPending(iRecvSocket);
+                        iNumRecvCallback++;
                     }
                     bNoRecvPending = false;
                 }
@@ -4817,13 +5022,11 @@
     PVMFStatus myRet = PVMFPending;
 
     {
-        if ((PVRTSP_ENGINE_NODE_STATE_IDLE <= iState)
-                && (PVRTSP_ENGINE_NODE_STATE_DESCRIBE_DONE > iState))
+        if (PVRTSP_ENGINE_NODE_STATE_DESCRIBE_DONE > iState)
         {
             myRet = SendRtspDescribe(aCmd);
         }
-        else if ((PVRTSP_ENGINE_NODE_STATE_DESCRIBE_DONE <= iState)
-                 && (PVRTSP_ENGINE_NODE_STATE_SETUP_DONE > iState))
+        else if (PVRTSP_ENGINE_NODE_STATE_SETUP_DONE > iState)
         {
             myRet = SendRtspSetup(aCmd);
             if (myRet == PVMFSuccess)
@@ -4861,15 +5064,344 @@
     return PVMFPending;
 }
 
-void PVRTSPEngineNode::resetSocket(void)
+
+//This routine is called repeatedly to drive the socket cleanup sequence.
+// Step 1: Cancel DNS & socket operations & wait on completion
+// Step 2: Shutdown sockets & wait on completion
+// Step 3: Delete sockets
+//
+// If "Immediate" is set we just delete sockets without shutdown sequence.
+PVMFStatus PVRTSPEngineNode::resetSocket(bool aImmediate)
 {
-    deleteSocket(iSendSocket);
-    iRecvSocket = NULL;
+    //Make sure things aren't already cleaned up.
+    if (!iDNS.IsBusy()
+            && !iSendSocket.iSocket
+            && !iRecvSocket.iSocket)
+    {
+        //Nothing to do!
+        if (iLogger)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Nothing to do!"));
+        }
+        return PVMFSuccess;
+    }
 
-    REQ_RECV_SOCKET_ID = REQ_SEND_SOCKET_ID = 0;
-    bNoSendPending = bNoRecvPending = false;
+    if (aImmediate)
+    {
+        //force immediate cleanup, for use in destructor where we can't wait
+        //on any async ops.
 
-    ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_IDLE);
+        //see if we have one socket or two.
+        bool oneSocket = (iSendSocket.iSocket == iRecvSocket.iSocket);
+        if (iSendSocket.iSocket)
+        {
+            iSendSocket.iSocket->~OsclTCPSocket();
+            iAlloc.deallocate(iSendSocket.iSocket);
+            iSendSocket.iSocket = NULL;
+        }
+        if (iRecvSocket.iSocket)
+        {
+            //guard against duplicate destroy/free
+            if (!oneSocket)
+            {
+                iRecvSocket.iSocket->~OsclTCPSocket();
+                iAlloc.deallocate(iRecvSocket.iSocket);
+            }
+            iRecvSocket.iSocket = NULL;
+        }
+        return PVMFSuccess;
+    }
+
+    bool waitOnAsyncOp = false;
+    while (!waitOnAsyncOp)
+    {
+        switch (iSocketCleanupState)
+        {
+            case ESocketCleanup_Idle:
+                //Start a new sequence.
+                iSocketCleanupState = ESocketCleanup_CancelCurrentOp;
+                break;
+
+            case ESocketCleanup_CancelCurrentOp:
+                //Step 1: Cancel current operations
+
+                //Cancel ops on DNS
+                if (iDNS.iDns)
+                {
+                    if (iDNS.iState.iPending
+                            && !iDNS.iState.iCanceled)
+                    {
+                        iDNS.iDns->CancelGetHostByName();
+                        iDNS.iState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel GetHostByName"));
+                        }
+                    }
+                }
+
+                //Cancel ops on send socket.
+                if (iSendSocket.iSocket)
+                {
+                    if (iSendSocket.iConnectState.iPending
+                            && !iSendSocket.iConnectState.iCanceled)
+                    {
+                        iSendSocket.iSocket->CancelConnect();
+                        iSendSocket.iConnectState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel Connect"));
+                        }
+                    }
+                    if (iSendSocket.iSendState.iPending
+                            && !iSendSocket.iSendState.iCanceled)
+                    {
+                        iSendSocket.iSocket->CancelSend();
+                        iSendSocket.iSendState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel Send"));
+                        }
+                    }
+                    if (iSendSocket.iRecvState.iPending
+                            && !iSendSocket.iRecvState.iCanceled)
+                    {
+                        iSendSocket.iSocket->CancelRecv();
+                        iSendSocket.iRecvState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel Recv"));
+                        }
+                    }
+                    OSCL_ASSERT(!iSendSocket.iShutdownState.iPending);
+                }
+
+                //Cancel ops on recv socket only when it's
+                //a unique socket.
+                if (iRecvSocket.iSocket
+                        && iRecvSocket.iSocket != iSendSocket.iSocket)
+                {
+                    if (iRecvSocket.iConnectState.iPending
+                            && !iRecvSocket.iConnectState.iCanceled)
+                    {
+                        iRecvSocket.iSocket->CancelConnect();
+                        iRecvSocket.iConnectState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel Connect (recv sock)"));
+                        }
+                    }
+                    if (iRecvSocket.iSendState.iPending
+                            && !iRecvSocket.iSendState.iCanceled)
+                    {
+                        iRecvSocket.iSocket->CancelSend();
+                        iRecvSocket.iSendState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel Send (recv sock)"));
+                        }
+                    }
+                    if (iRecvSocket.iRecvState.iPending
+                            && !iRecvSocket.iRecvState.iCanceled)
+                    {
+                        iRecvSocket.iSocket->CancelRecv();
+                        iRecvSocket.iRecvState.iCanceled = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Cancel Recv (recv sock)"));
+                        }
+                    }
+                    OSCL_ASSERT(!iRecvSocket.iShutdownState.iPending);
+                }
+
+                if (iDNS.IsBusy()
+                        || iSendSocket.IsBusy()
+                        || iRecvSocket.IsBusy())
+                {
+                    waitOnAsyncOp = true;
+                }
+
+                //Either go to wait state or continue to Step 2.
+                if (waitOnAsyncOp)
+                    iSocketCleanupState = ESocketCleanup_WaitOnCancel;
+                else
+                    iSocketCleanupState = ESocketCleanup_Shutdown;
+                break;
+
+            case ESocketCleanup_WaitOnCancel:
+                //Wait on cancel completion for all.
+
+                if (iDNS.IsBusy()
+                        || iSendSocket.IsBusy()
+                        || iRecvSocket.IsBusy())
+                {
+                    waitOnAsyncOp = true;
+                }
+
+                if (!waitOnAsyncOp)
+                    iSocketCleanupState = ESocketCleanup_Shutdown;
+                break;
+
+            case ESocketCleanup_Shutdown:
+                //Step 2: shutdown both sockets
+
+                if (iDNS.iDns)
+                {
+                    OSCL_ASSERT(!iDNS.IsBusy());
+                }
+
+                if (iSendSocket.iSocket)
+                {
+                    OSCL_ASSERT(!iSendSocket.IsBusy());
+
+                    if (iSendSocket.iSocket->Shutdown(EPVSocketBothShutdown, TIMEOUT_SHUTDOWN) == EPVSocketPending)
+                    {
+                        iSendSocket.iShutdownState.iPending = true;
+                        waitOnAsyncOp = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Shutdown"));
+                        }
+                    }
+                    //else shutdown failed, ignore & continue
+                    else
+                    {
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Shutdown Failed"));
+                        }
+                    }
+                }
+
+                //shutown recv socket only when it's a unique socket.
+                if (iRecvSocket.iSocket
+                        && iRecvSocket.iSocket != iSendSocket.iSocket)
+                {
+                    OSCL_ASSERT(!iRecvSocket.IsBusy());
+
+                    if (iRecvSocket.iSocket->Shutdown(EPVSocketBothShutdown, TIMEOUT_SHUTDOWN) == EPVSocketPending)
+                    {
+                        iRecvSocket.iShutdownState.iPending = true;
+                        waitOnAsyncOp = true;
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Shutdown (recv sock)"));
+                        }
+                    }
+                    //else shutdown failed, ignore & continue
+                    else
+                    {
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Shutdown Failed (recv sock)"));
+                        }
+                    }
+                }
+
+                //Either go to wait state or continue to Step 3.
+                if (waitOnAsyncOp)
+                    iSocketCleanupState = ESocketCleanup_WaitOnShutdown;
+                else
+                    iSocketCleanupState = ESocketCleanup_Delete;
+                break;
+
+            case ESocketCleanup_WaitOnShutdown:
+                //Wait on shutdown completion for both sockets.
+
+                if (iSendSocket.IsBusy()
+                        || iRecvSocket.IsBusy())
+                {
+                    waitOnAsyncOp = true;
+                }
+
+                if (!waitOnAsyncOp)
+                    iSocketCleanupState = ESocketCleanup_Delete;
+                break;
+
+            case ESocketCleanup_Delete:
+                // Step 3: Delete sockets
+
+                // Note: we assume this calling context is not the socket callback, so
+                // it's safe to delete the OsclSocket object here.
+
+            {
+                //see if we have one socket or two.
+                bool oneSocket = (iSendSocket.iSocket == iRecvSocket.iSocket);
+                if (iSendSocket.iSocket)
+                {
+                    OSCL_ASSERT(!iSendSocket.IsBusy());
+                    if (iLogger)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Delete TCP"));
+                    }
+                    iSendSocket.iSocket->~OsclTCPSocket();
+                    iAlloc.deallocate(iSendSocket.iSocket);
+                    iSendSocket.iSocket = NULL;
+                }
+                if (iRecvSocket.iSocket)
+                {
+                    OSCL_ASSERT(!iRecvSocket.IsBusy());
+                    //guard against duplicate destroy/free
+                    if (!oneSocket)
+                    {
+                        if (iLogger)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Delete TCP (recv sock)"));
+                        }
+                        iRecvSocket.iSocket->~OsclTCPSocket();
+                        iAlloc.deallocate(iRecvSocket.iSocket);
+                    }
+                    iRecvSocket.iSocket = NULL;
+                }
+
+                bNoSendPending = bNoRecvPending = false;
+
+                ChangeInternalState(PVRTSP_ENGINE_NODE_STATE_IDLE);
+            }
+            iSocketCleanupState = ESocketCleanup_Idle;
+            if (iLogger)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRTSPEngineNode::resetSocket() Done!"));
+            }
+            return PVMFSuccess; //Done!
+
+            default:
+                OSCL_ASSERT(0);
+                break;
+        }
+    }
+
+    return (waitOnAsyncOp) ? PVMFPending : PVMFSuccess;
+}
+
+void PVRTSPEngineNode::SetSendPending(SocketContainer& aSock)
+{
+    //Set "send pending" condition on a socket container.
+    //update recv socket container only when we have a unique recv socket,
+    //otherwise update send socket container.
+    if (aSock.iSocket == iRecvSocket.iSocket
+            && iRecvSocket.iSocket != iSendSocket.iSocket)
+        iRecvSocket.iSendState.iPending = true;
+    else
+    {
+        iSendSocket.iSendState.iPending = true;
+        OSCL_ASSERT(aSock.iSocket == iSendSocket.iSocket);
+    }
+}
+
+void PVRTSPEngineNode::SetRecvPending(SocketContainer& aSock)
+{
+    //Set "recv pending" condition on a socket container.
+    //update recv socket container only when we have a unique recv socket,
+    //otherwise update send socket container.
+    if (aSock.iSocket == iRecvSocket.iSocket
+            && iRecvSocket.iSocket != iSendSocket.iSocket)
+        iRecvSocket.iRecvState.iPending = true;
+    else
+    {
+        iSendSocket.iRecvState.iPending = true;
+        OSCL_ASSERT(aSock.iSocket == iSendSocket.iSocket);
+    }
 }
 
 OsclLeaveCode PVRTSPEngineNode::RunError(OsclLeaveCode aError)
@@ -4930,8 +5462,11 @@
         iSocketEventQueue.erase(&iSocketEventQueue.front());
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVRTSPEngineNode::clearEventQueue() In iFxn=%d iSockEvent=%d iSockError=%d ", tmpSockEvent.iSockFxn, tmpSockEvent.iSockEvent, tmpSockEvent.iSockError));
 
-        myRet = (myRet && (tmpSockEvent.iSockEvent == EPVSocketSuccess));
-        //iSocketEventQueue.clear();
+        if (tmpSockEvent.iSockEvent != EPVSocketSuccess)
+        {
+            myRet = false;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR, (0, "PVRTSPEngineNode::clearEventQueue() Socket Error"));
+        }
     }
 
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO, (0, "PVRTSPEngineNode::clearEventQueue() Out myRet=%d ", myRet));
@@ -5050,3 +5585,10 @@
     iRunningCmdQueue.Erase(&aCmd);
 }
 
+
+OsclSharedPtr<PVMFMediaDataImpl> PVRTSPEngineNode::AllocateMediaData(int32& errCode)
+{
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImplOut;
+    OSCL_TRY(errCode, mediaDataImplOut = ipFragGroupAllocator->allocate());
+    return mediaDataImplOut;
+}
diff --git a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.cpp b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.cpp
index 23cfbc1..10543e8 100644
--- a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.cpp
+++ b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,14 +70,18 @@
 bool PVMFRTSPPort::IsFormatSupported(PVMFFormatType aFmt)
 {
 //	return (aFmt==PVMF_INET_UDP)||(aFmt==PVMF_INET_TCP);
-    return (aFmt == PVMF_INET_TCP);
+    if (aFmt == PVMF_MIME_INET_TCP)
+    {
+        return true;
+    }
+    return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////
 void PVMFRTSPPort::FormatUpdated()
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO
-                    , (0, "PVMFRTSPPort::FormatUpdated %d", iFormat));
+                    , (0, "PVMFRTSPPort::FormatUpdated %s", iFormat.getMIMEStrPtr()));
 }
 
 void PVMFRTSPPort::setParametersSync(PvmiMIOSession aSession,
@@ -85,6 +89,7 @@
                                      int num_elements,
                                      PvmiKvp * & aRet_kvp)
 {
+    OSCL_UNUSED_ARG(aSession);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFRTSPPort::getParametersSync: aSession=0x%x, aParameters=0x%x, num_elements=%d, aRet_kvp=0x%x",
                     aSession, aParameters, num_elements, aRet_kvp));
 
@@ -131,6 +136,7 @@
         PvmiKvp* aParameters,
         int num_elements)
 {
+    OSCL_UNUSED_ARG(aSession);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFRTSPPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
                     aSession, aParameters, num_elements));
 
diff --git a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.h b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.h
index cc966eb..e49e467 100644
--- a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.h
+++ b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_port.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_utils.cpp b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_utils.cpp
index 8112a87..42d6516 100644
--- a/protocols/rtsp_client_engine/src/pvrtsp_client_engine_utils.cpp
+++ b/protocols/rtsp_client_engine/src/pvrtsp_client_engine_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,8 +36,6 @@
         {
             int len = oscl_strlen(baseURL);
             oscl_strncpy(copyOfBaseURL, baseURL, (len + 1));
-            //JJ 12/04/06
-            //dropTextAfterLastSlash(copyOfBaseURL);
             if ((copyOfBaseURL[len-1] != '/') && (len > 0))
             {
                 copyOfBaseURL[len] = '/';
@@ -57,8 +55,6 @@
         case REPLACE_PATH:
         {
             oscl_strncpy(copyOfBaseURL, baseURL, (oscl_strlen(baseURL) + 1));
-            //JJ 12/04/06
-            //dropTextAfterFirstSlash(copyOfBaseURL);
             if (completeURLLen <= (oscl_strlen(copyOfBaseURL) + oscl_strlen(relativeURL)))
             {
                 OSCL_ARRAY_DELETE(copyOfBaseURL);
@@ -195,9 +191,7 @@
 #ifndef OSCL_TIME_H_INCLUDED
 #include "oscl_time.h"
 #endif
-#if (!defined(MD5_H) && defined(SDK_HAS_REAL_HTTP_CLOAKING_SUPPORT))
-#include "md5.h"
-#endif
+
 #ifndef OSCL_SNPRINTF_H_INCLUDED
 #include "oscl_snprintf.h"
 #endif
@@ -207,43 +201,7 @@
 
 bool generatePseudoUUID(OSCL_String& aUUID)
 {
-#ifdef SDK_HAS_REAL_HTTP_CLOAKING_SUPPORT
-    //6e31c837-b458-4c27-b290-73805cb08da1
-    TimeValue current_time;
-    current_time.set_to_current_time();
-
-    uint32 seed_1 = current_time.get_sec();
-    uint32 seed_2 = current_time.get_usec();
-
-    MD5 myMD5;
-    myMD5.add((const  uint8 *)(&seed_1), sizeof(seed_1));
-    myMD5.add((const  uint8 *)(&seed_2), sizeof(seed_2));
-
-    MD5OctetHashValue md5output;
-    myMD5.compute_hash(md5output);
-
-    const int MAX_UUID_BUFSIZE = 64;
-    char buffer[MAX_UUID_BUFSIZE+1];
-
-    {
-        const char hex[] = "0123456789abcdef";
-        char *ptr = buffer;
-
-        for (uint32 i = 0, j = 0; i < 16; i++)
-        {
-            ptr[j++] = hex[md5output.hash_array[i] >> 4];
-            ptr[j++] = hex[md5output.hash_array[i] & 0x0f];
-
-            if ((j == 8) || (j == 13) || (j == 18) || (j == 23))
-                ptr[j++] = '-';
-
-            ptr[j] = '\0';
-        }
-    }
-    aUUID = buffer;
-#else
     aUUID = NULL;
-#endif
     return true;
 }
 
diff --git a/protocols/rtsp_client_engine/src/pvrtspenginenodeextensioninterface_impl.cpp b/protocols/rtsp_client_engine/src/pvrtspenginenodeextensioninterface_impl.cpp
new file mode 100644
index 0000000..fbe5d96
--- /dev/null
+++ b/protocols/rtsp_client_engine/src/pvrtspenginenodeextensioninterface_impl.cpp
@@ -0,0 +1,193 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_IMPL_H_INCLUDED
+#include "pvrtspenginenodeextensioninterface_impl.h"
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+//Interface ctor and dtor
+///////////////////////////////////////////////////////////////////////////////
+PVRTSPEngineNodeExtensionInterfaceImpl::PVRTSPEngineNodeExtensionInterfaceImpl(PVRTSPEngineNode* aContainer): PVInterfaceImpl<PVRTSPEngineNodeAllocator>(KPVRTSPEngineNodeExtensionUuid), iContainer(aContainer)
+{
+}
+
+PVRTSPEngineNodeExtensionInterfaceImpl::~PVRTSPEngineNodeExtensionInterfaceImpl()
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implemenatation of virtuals declared in class PVInterface
+///////////////////////////////////////////////////////////////////////////////
+void PVRTSPEngineNodeExtensionInterfaceImpl::addRef()
+{
+    PVInterfaceImpl<PVRTSPEngineNodeAllocator>::addRef();
+}
+
+void PVRTSPEngineNodeExtensionInterfaceImpl::removeRef()
+{
+    PVInterfaceImpl<PVRTSPEngineNodeAllocator>::removeRef();
+}
+
+bool PVRTSPEngineNodeExtensionInterfaceImpl::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == Uuid())
+    {
+        addRef();
+        iface = this;
+        return true;
+    }
+    else
+    {
+        iface = NULL;
+        return false;
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//Implemenatation of virtuals exposed by  PVRTSPEngineNodeExtensionInterface
+///////////////////////////////////////////////////////////////////////////////
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetStreamingType(PVRTSPStreamingType aType)
+{
+    return iContainer->SetStreamingType(aType);
+}
+
+//Either SetSessionURL() or  SetSDPInfo() must be called before Init()
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetSessionURL(OSCL_wString& aURL)
+{
+    return iContainer->SetSessionURL(aURL);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetSDP(OsclRefCounterMemFrag& aSDPBuf)
+{
+    return iContainer->GetSDP(aSDPBuf);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetRtspProxy(OSCL_String& aRtspProxyName, uint32 aRtspProxyPort)
+{
+    return iContainer->SetRtspProxy(aRtspProxyName, aRtspProxyPort);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetRtspProxy(OSCL_String& aRtspProxyName, uint32& aRtspProxyPort)
+{
+    return iContainer->GetRtspProxy(aRtspProxyName, aRtspProxyPort);
+}
+
+OSCL_EXPORT_REF bool PVRTSPEngineNodeExtensionInterfaceImpl::IsRdtTransport()
+{
+    return iContainer->IsRdtTransport();
+}
+
+OSCL_EXPORT_REF void PVRTSPEngineNodeExtensionInterfaceImpl::SetPortRdtStreamId(PVMFPortInterface* pPort, int iRdtStreamId)
+{
+    iContainer->SetPortRdtStreamId(pPort, iRdtStreamId);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetSDPInfo(OsclSharedPtr<SDPInfo>& aSDPinfo, Oscl_Vector<StreamInfo, OsclMemAllocator> &aSelectedStream)
+{
+    return iContainer->SetSDPInfo(aSDPinfo, aSelectedStream);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetServerInfo(PVRTSPEngineNodeServerInfo& aServerInfo)
+{
+    return iContainer->GetServerInfo(aServerInfo);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetStreamInfo(Oscl_Vector<StreamInfo, OsclMemAllocator> &aSelectedStream)
+{
+    return iContainer->GetStreamInfo(aSelectedStream);
+}
+
+OSCL_EXPORT_REF void PVRTSPEngineNodeExtensionInterfaceImpl::SetRealChallengeCalculator(IRealChallengeGen* pChallengeCalc)
+{
+    iContainer->SetRealChallengeCalculator(pChallengeCalc);
+}
+
+OSCL_EXPORT_REF void PVRTSPEngineNodeExtensionInterfaceImpl::SetRdtParser(IPayloadParser* pRdtParser)
+{
+    iContainer->SetRdtParser(pRdtParser);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetRequestPlayRange(const RtspRangeType& aRange)
+{
+    return iContainer->SetRequestPlayRange(aRange);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetActualPlayRange(RtspRangeType& aRange)
+{
+    return iContainer->GetActualPlayRange(aRange);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetUserAgent(OSCL_wString& aUserAgent)
+{
+    return iContainer->GetUserAgent(aUserAgent);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetClientParameters(OSCL_wString& aUserAgent,
+        OSCL_wString&  aUserNetwork,
+        OSCL_wString&  aDeviceInfo)
+{
+    return iContainer->SetClientParameters(aUserAgent, aUserNetwork, aDeviceInfo);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetAuthenticationParameters(OSCL_wString& aUserID,
+        OSCL_wString& aAuthentication,
+        OSCL_wString& aExpiration,
+        OSCL_wString& aApplicationSpecificString,
+        OSCL_wString& aVerification,
+        OSCL_wString& aSignature)
+{
+    return iContainer->SetAuthenticationParameters(aUserID, aAuthentication, aExpiration, aApplicationSpecificString, aVerification, aSignature);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetKeepAliveMethod_timeout(int32 aTimeout)
+{
+    return iContainer->SetKeepAliveMethod_timeout(aTimeout);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetKeepAliveMethod_use_SET_PARAMETER(bool aUseSetParameter)
+{
+    return iContainer->SetKeepAliveMethod_use_SET_PARAMETER(aUseSetParameter);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetKeepAliveMethod_keep_alive_in_play(bool aKeepAliveInPlay)
+{
+    return iContainer->SetKeepAliveMethod_keep_alive_in_play(aKeepAliveInPlay);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetKeepAliveMethod(int32 &aTimeout, bool &aUseSetParameter, bool &aKeepAliveInPlay)
+{
+    return iContainer->GetKeepAliveMethod(aTimeout, aUseSetParameter, aKeepAliveInPlay);
+}
+
+
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::GetRTSPTimeOut(int32 &aTimeout)
+{
+    return iContainer->GetRTSPTimeOut(aTimeout);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVRTSPEngineNodeExtensionInterfaceImpl::SetRTSPTimeOut(int32 aTimeout)
+{
+    return iContainer->SetRTSPTimeOut(aTimeout);
+}
+
+OSCL_EXPORT_REF void PVRTSPEngineNodeExtensionInterfaceImpl::UpdateSessionCompletionStatus(bool aSessionCompleted)
+{
+    iContainer->UpdateSessionCompletionStatus(aSessionCompleted);
+}
diff --git a/protocols/rtsp_client_engine/src/pvrtspenginenodeextensioninterface_impl.h b/protocols/rtsp_client_engine/src/pvrtspenginenodeextensioninterface_impl.h
new file mode 100644
index 0000000..a07c29f
--- /dev/null
+++ b/protocols/rtsp_client_engine/src/pvrtspenginenodeextensioninterface_impl.h
@@ -0,0 +1,118 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_IMPL_H_INCLUDED
+#define PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_IMPL_H_INCLUDED
+
+#ifndef PVRTSP_ENGINE_NODE_EXTENSION_INTERFACE_H_INCLUDED
+#include "pvrtspenginenodeextensioninterface.h"
+#endif
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+#ifndef PVRTSP_CLIENT_ENGINE_NODE_H
+#include "pvrtsp_client_engine_node.h"
+#endif
+
+class PVRTSPEngineNodeExtensionInterfaceImpl : public PVInterfaceImpl<PVRTSPEngineNodeAllocator>,
+            public PVRTSPEngineNodeExtensionInterface
+{
+    public:
+        ~PVRTSPEngineNodeExtensionInterfaceImpl();
+        PVRTSPEngineNodeExtensionInterfaceImpl(PVRTSPEngineNode* aContainer);
+
+        //**********begin PVInterface
+        OSCL_IMPORT_REF virtual void addRef();
+        OSCL_IMPORT_REF virtual void removeRef();
+        OSCL_IMPORT_REF virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+        //**********end PVInterface
+
+        OSCL_IMPORT_REF virtual PVMFStatus SetStreamingType(PVRTSPStreamingType aType = PVRTSP_3GPP_UDP);
+
+        //Either SetSessionURL() or  SetSDPInfo() must be called before Init()
+        OSCL_IMPORT_REF virtual PVMFStatus SetSessionURL(OSCL_wString& aURL) ;
+        OSCL_IMPORT_REF virtual PVMFStatus GetSDP(OsclRefCounterMemFrag& aSDPBuf) ;
+
+        OSCL_IMPORT_REF virtual PVMFStatus SetRtspProxy(OSCL_String& aRtspProxyName, uint32 aRtspProxyPort) ;
+        OSCL_IMPORT_REF virtual PVMFStatus GetRtspProxy(OSCL_String& aRtspProxyName, uint32& aRtspProxyPort) ;
+
+        // to be called before init
+        OSCL_IMPORT_REF virtual bool IsRdtTransport() ;
+
+        OSCL_IMPORT_REF virtual void SetPortRdtStreamId(PVMFPortInterface* pPort,
+                int iRdtStreamId) ;
+
+        OSCL_IMPORT_REF virtual PVMFStatus SetSDPInfo(OsclSharedPtr<SDPInfo>& aSDPinfo, Oscl_Vector<StreamInfo, OsclMemAllocator> &aSelectedStream);
+        OSCL_IMPORT_REF virtual PVMFStatus GetServerInfo(PVRTSPEngineNodeServerInfo& aServerInfo);
+        OSCL_IMPORT_REF virtual PVMFStatus GetStreamInfo(Oscl_Vector<StreamInfo, OsclMemAllocator> &aSelectedStream);
+
+
+        // API to pass in Real related parameters
+        OSCL_IMPORT_REF virtual void SetRealChallengeCalculator(IRealChallengeGen* pChallengeCalc);
+        OSCL_IMPORT_REF virtual void SetRdtParser(IPayloadParser* pRdtParser);
+
+        //One of these must be called before Start()
+        OSCL_IMPORT_REF virtual PVMFStatus SetRequestPlayRange(const RtspRangeType& aRange);
+        OSCL_IMPORT_REF virtual PVMFStatus GetActualPlayRange(RtspRangeType& aRange);
+
+
+        OSCL_IMPORT_REF virtual PVMFStatus GetUserAgent(OSCL_wString& aUserAgent) ;
+
+        OSCL_IMPORT_REF virtual PVMFStatus SetClientParameters(OSCL_wString& aUserAgent,
+                OSCL_wString&  aUserNetwork,
+                OSCL_wString&  aDeviceInfo);
+
+        OSCL_IMPORT_REF virtual PVMFStatus SetAuthenticationParameters(OSCL_wString& aUserID,
+                OSCL_wString& aAuthentication,
+                OSCL_wString& aExpiration,
+                OSCL_wString& aApplicationSpecificString,
+                OSCL_wString& aVerification,
+                OSCL_wString& aSignature);
+        //OSCL_IMPORT_REF virtual PVMFStatus SetTimeout(uint32 aTimeout);
+        //OSCL_IMPORT_REF virtual PVMFStatus GetTimeout(uint32& aTimeout);
+
+        /**
+         * This API is to set the keep-alive mechanism for rtsp client.
+         *
+         * @param aTimeout The interval in milliseconds of sending the RTSP keep-alive commands.
+         *	0 to use server defined timeout value.
+         * @param aUseSetParameter true to use SET_PARAMETER; false to use OPTIONS
+         * @param aKeepAliveInPlay Turns on/off the sending RTSP keep-alive commands during PLAY
+         * @returns Completion status
+         */
+        //OSCL_IMPORT_REF virtual PVMFStatus SetKeepAliveMethod(int32 aTimeout=0, bool aUseSetParameter=false, bool aKeepAliveInPlay=false);
+        OSCL_IMPORT_REF virtual PVMFStatus SetKeepAliveMethod_timeout(int32 aTimeout = 0);
+        OSCL_IMPORT_REF virtual PVMFStatus SetKeepAliveMethod_use_SET_PARAMETER(bool aUseSetParameter = false);
+        OSCL_IMPORT_REF virtual PVMFStatus SetKeepAliveMethod_keep_alive_in_play(bool aKeepAliveInPlay = false);
+
+        OSCL_IMPORT_REF virtual PVMFStatus GetKeepAliveMethod(int32 &aTimeout, bool &aUseSetParameter, bool &aKeepAliveInPlay);
+
+
+
+        OSCL_IMPORT_REF virtual PVMFStatus GetRTSPTimeOut(int32 &aTimeout);
+        OSCL_IMPORT_REF virtual PVMFStatus SetRTSPTimeOut(int32 aTimeout);
+
+        OSCL_IMPORT_REF virtual void UpdateSessionCompletionStatus(bool aSessionCompleted);
+    private:
+        PVRTSPEngineNode* iContainer;
+
+};
+
+#endif
+
diff --git a/protocols/rtsp_parcom/Android.mk b/protocols/rtsp_parcom/Android.mk
index b62d8c6..fa00c93 100644
--- a/protocols/rtsp_parcom/Android.mk
+++ b/protocols/rtsp_parcom/Android.mk
@@ -3,34 +3,37 @@
 
 LOCAL_SRC_FILES := \
 	src/rtsp_par_com_outgoing_message.cpp \
-	src/rtsp_parser.cpp \
-	src/rtsp_par_com_incoming_message.cpp \
-	src/rtsp_par_com_message.cpp
-
+ 	src/rtsp_parser.cpp \
+ 	src/rtsp_par_com_incoming_message.cpp \
+ 	src/rtsp_par_com_message.cpp
 
 
 LOCAL_MODULE := libpv_rtsp_parcom
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/rtsp_parcom/src \
-	$(PV_TOP)//protocols/rtsp_parcom/src \
-	$(PV_TOP)//protocols/rtsp_parcom/../rtp/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/protocols/rtsp_parcom/src \
+ 	$(PV_TOP)/protocols/rtsp_parcom/src \
+ 	$(PV_TOP)/protocols/rtp/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/rtsp_par_com_constants.h \
-	src/rtsp_par_com_tunable.h \
-	src/rtsp_par_com.h \
-	src/rtsp_parser.h \
-	src/rtsp_par_com_basic_ds.h \
-	src/rtsp_session_types.h \
-	src/rtsp_par_com_message.h \
-	src/rtsp_transport.h
+ 	src/rtsp_par_com_tunable.h \
+ 	src/rtsp_par_com.h \
+ 	src/rtsp_parser.h \
+ 	src/rtsp_par_com_basic_ds.h \
+ 	src/rtsp_session_types.h \
+ 	src/rtsp_par_com_message.h \
+ 	src/rtsp_transport.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/rtsp_parcom/build/make/local.mk b/protocols/rtsp_parcom/build/make/local.mk
new file mode 100644
index 0000000..e054478
--- /dev/null
+++ b/protocols/rtsp_parcom/build/make/local.mk
@@ -0,0 +1,37 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv_rtsp_parcom
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../../rtp/src
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := rtsp_par_com_outgoing_message.cpp \
+	rtsp_parser.cpp \
+	rtsp_par_com_incoming_message.cpp \
+	rtsp_par_com_message.cpp 
+
+HDRS := rtsp_par_com_constants.h \
+	rtsp_par_com_tunable.h \
+	rtsp_par_com.h \
+	rtsp_parser.h \
+	rtsp_par_com_basic_ds.h \
+	rtsp_session_types.h \
+	rtsp_par_com_message.h \
+	rtsp_transport.h
+
+include $(MK)/library.mk
+
diff --git a/protocols/rtsp_parcom/build/make/makefile b/protocols/rtsp_parcom/build/make/makefile
deleted file mode 100644
index 2874365..0000000
--- a/protocols/rtsp_parcom/build/make/makefile
+++ /dev/null
@@ -1,68 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pv_rtsp_parcom
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../rtp/src
-
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS = rtsp_par_com_outgoing_message.cpp \
-	rtsp_parser.cpp \
-	rtsp_par_com_incoming_message.cpp \
-	rtsp_par_com_message.cpp 
-
-HDRS =  rtsp_par_com_constants.h \
-	rtsp_par_com_tunable.h \
-	rtsp_par_com.h \
-	rtsp_parser.h \
-	rtsp_par_com_basic_ds.h \
-	rtsp_session_types.h \
-	rtsp_par_com_message.h \
-	rtsp_transport.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/protocols/rtsp_parcom/src/makefile b/protocols/rtsp_parcom/src/makefile
deleted file mode 100755
index 8a42ed4..0000000
--- a/protocols/rtsp_parcom/src/makefile
+++ /dev/null
@@ -1,68 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = rtsp_parcom
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# XINCDIRS += 
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCS =  rtsp_par_com_message.cpp \
-        rtsp_par_com_outgoing_message.cpp \
-        rtsp_par_com_incoming_message.cpp \
-        rtsp_parser.cpp \
-        rtsp_embedded_rtp.cpp \
-
-
-HDRS =  rtsp_par_com.h \
-        rtsp_par_com_basic_ds.h \
-        rtsp_par_com_constants.h \
-        rtsp_par_com_message.h \
-        rtsp_par_com_tunable.h \
-        rtsp_parser.h \
-        rtsp_transport.h \
-        rtsp_embedded_rtp.h \
-		rtsp_session_types.h \
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
-
-
diff --git a/protocols/rtsp_parcom/src/rtsp_embedded_rtp.cpp b/protocols/rtsp_parcom/src/rtsp_embedded_rtp.cpp
index 61a5cf8..575f6dc 100644
--- a/protocols/rtsp_parcom/src/rtsp_embedded_rtp.cpp
+++ b/protocols/rtsp_parcom/src/rtsp_embedded_rtp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_embedded_rtp.h b/protocols/rtsp_parcom/src/rtsp_embedded_rtp.h
index 02f2265..38f6a71 100644
--- a/protocols/rtsp_parcom/src/rtsp_embedded_rtp.h
+++ b/protocols/rtsp_parcom/src/rtsp_embedded_rtp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com.h b/protocols/rtsp_parcom/src/rtsp_par_com.h
index 1b6c9d5..3a0ef45 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com.h
+++ b/protocols/rtsp_parcom/src/rtsp_par_com.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_basic_ds.h b/protocols/rtsp_parcom/src/rtsp_par_com_basic_ds.h
index 2bcb392..f97d18d 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_basic_ds.h
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_basic_ds.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_constants.h b/protocols/rtsp_parcom/src/rtsp_par_com_constants.h
index be94bf8..44df2b3 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_constants.h
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_constants.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_incoming_message.cpp b/protocols/rtsp_parcom/src/rtsp_par_com_incoming_message.cpp
index 4c76a8d..6c80313 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_incoming_message.cpp
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_incoming_message.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
 
     char * endOfString;
 
-    // All righty, the first thing to do is to parse the status line;
+    // The first thing to do is to parse the status line;
     // the rest of the parsing (regular fields) can be parsed out by
     // parseNextPortion() method, since it has to know how to do that anyway.
     // We also have to find out if Content-length is there, etc.
@@ -142,7 +142,7 @@
                     wordCountTrigger = true;
                 }
                 else
-                { // nah, still a word
+                { // still a word
                 }
                 break;
             }
@@ -179,8 +179,6 @@
         // most probably the message was too big to handle, but parser still
         // created a message hoping that at least something can be found...
         //
-        // anyway, we don't deal with incomplete status lines
-        //
 
         amMalformed = RTSPErrorSyntax;
 
@@ -217,7 +215,7 @@
             &&	('/' == *(wordPtr[0] + 4))
        )
     {
-        // it's got to be a response
+        // it has to be a response
         //
         msgType = RTSPResponseMsg;
         rtspVersionString = firstWordPLSS;
@@ -441,7 +439,7 @@
         // extra URI validation
         {
             if (1 == originalURI.length())
-            { // it better be a star
+            { // Is it a star
                 if (CHAR_STAR != originalURI.c_str()[0])
                 {
                     amMalformed = RTSPErrorSyntax;
@@ -905,7 +903,7 @@
 void
 RTSPIncomingMessage::parseOneTransportEntry(char*& trans, char *final_end)
 {
-    char *startPtr, *endPtr, *nxtPtr;
+    const char *startPtr, *endPtr, *nxtPtr;
     char *transSepPtr;
 
 
@@ -946,19 +944,19 @@
 
 
     // see if there is a tranport list separator
-    transSepPtr = oscl_strstr(startPtr, ",");
+    transSepPtr = OSCL_CONST_CAST(char*, oscl_strstr(startPtr, ","));
     if (transSepPtr)
     {
 
-        char *quotePtr = oscl_strstr(startPtr, "\"");
+        const char *quotePtr = oscl_strstr(startPtr, "\"");
         if (quotePtr && quotePtr < transSepPtr)
         {
             // this may be a comma in the mode list -- so find the end of the mode list
-            char *quote_end = oscl_strstr(quotePtr + 1, "\"");
+            const char *quote_end = oscl_strstr(quotePtr + 1, "\"");
             if (quote_end)
             {
                 // look for another comma
-                if (NULL != (transSepPtr = oscl_strstr(quote_end, ",")))
+                if (NULL != (transSepPtr = OSCL_CONST_CAST(char*, oscl_strstr(quote_end, ","))))
                 {
                     // temporarily write a terminator to separate the transport specs.
                     *transSepPtr = '\0';
@@ -1008,7 +1006,7 @@
 
         // look for either the '/' or ';' separators
         endPtr = oscl_strstr(startPtr, "/");
-        char *endPtr2 = oscl_strstr(startPtr, ";");
+        const char *endPtr2 = oscl_strstr(startPtr, ";");
 
         if (!endPtr)
         {
@@ -1078,7 +1076,7 @@
 
         char *sepPtr;
         // find the next separator
-        if (NULL == (endPtr = sepPtr = oscl_strstr(startPtr, ";")))
+        if (NULL == (sepPtr = (char*)(endPtr = oscl_strstr(startPtr, ";"))))
         {
             endPtr = final_end;
         }
@@ -1107,7 +1105,7 @@
                                destination_str_len))
         {
             nxtPtr = startPtr + destination_str_len;
-            char *curEndPtr = oscl_strstr(nxtPtr, "=");
+            char *curEndPtr = OSCL_CONST_CAST(char*, oscl_strstr(nxtPtr, "="));
             if (curEndPtr)
             {
                 nxtPtr = curEndPtr + 1;
@@ -1116,7 +1114,7 @@
                 for (; nxtPtr < endPtr && ((*nxtPtr >= 0x09 && *nxtPtr <= 0x0D) || *nxtPtr == 0x20); ++nxtPtr);
 
                 // now find the end
-                for (curEndPtr = nxtPtr; curEndPtr < endPtr && !((*curEndPtr >= 0x09 && *curEndPtr <= 0x0D) || *curEndPtr == 0x20);
+                for (curEndPtr = (char*)nxtPtr; curEndPtr < endPtr && !((*curEndPtr >= 0x09 && *curEndPtr <= 0x0D) || *curEndPtr == 0x20);
                         ++curEndPtr);
 
                 if (curEndPtr - nxtPtr > 0)
@@ -1142,7 +1140,7 @@
         {
             int tmp;
             nxtPtr = startPtr + interleaved_str_len;
-            char *curEndPtr = oscl_strstr(nxtPtr, "-");
+            char *curEndPtr = OSCL_CONST_CAST(char*, oscl_strstr(nxtPtr, "-"));
             if (curEndPtr) *curEndPtr = '\0';
             uint32 atoi_tmp;
             PV_atoi(nxtPtr, 'd', atoi_tmp);
@@ -1196,7 +1194,7 @@
             int tmp;
             uint32 atoi_tmp;
             nxtPtr = startPtr + client_port_str_len;
-            char *curEndPtr = oscl_strstr(nxtPtr, "-");
+            char *curEndPtr = OSCL_CONST_CAST(char*, oscl_strstr(nxtPtr, "-"));
             if (curEndPtr) *curEndPtr = '\0';
             PV_atoi(nxtPtr, 'd', atoi_tmp);
             tmp = atoi_tmp;
@@ -1249,7 +1247,7 @@
             int tmp;
             uint32 atoi_tmp;
             nxtPtr = startPtr + server_port_str_len;
-            char *curEndPtr = oscl_strstr(nxtPtr, "-");
+            char *curEndPtr = OSCL_CONST_CAST(char*, oscl_strstr(nxtPtr, "-"));
             if (curEndPtr) *curEndPtr = '\0';
             PV_atoi(nxtPtr, 'd', atoi_tmp);
             tmp = atoi_tmp;
@@ -1322,11 +1320,11 @@
             nxtPtr = startPtr + mode_str_len;
             rtspTrans->modeIsSet = true;
             char *quotePtr = NULL;
-            char *wordEndPtr;
+            const char *wordEndPtr;
             if (*nxtPtr == '\"')
             {
                 ++nxtPtr;
-                if (NULL != (quotePtr = oscl_strstr(nxtPtr, "\"")))
+                if (NULL != (quotePtr = OSCL_CONST_CAST(char*, oscl_strstr(nxtPtr, "\""))))
                 {
                     *quotePtr = '\0';
                 }
@@ -1360,7 +1358,7 @@
             int tmp;
             uint32 atoi_tmp;
             nxtPtr = startPtr + port_str_len;
-            char *curEndPtr = oscl_strstr(nxtPtr, "-");
+            char *curEndPtr = OSCL_CONST_CAST(char*, oscl_strstr(nxtPtr, "-"));
             if (curEndPtr) *curEndPtr = '\0';
             PV_atoi(nxtPtr, 'd', atoi_tmp);
             tmp = atoi_tmp;
@@ -1614,13 +1612,8 @@
                     && ('e' == (subFieldName[6] | OSCL_ASCII_CASE_MAGIC_BIT))
                )
             {
-                /*
-                 *Change from using atoi to PV_atoi. This is needed to
-                 *handle really large rtptimes from the server.
-                 */
                 uint32 rtptime = 0;
                 PV_atoi((separator + 1), 'd', rtptime);
-//          rtpInfo[ numOfRtpInfoEntries-1 ].rtptime = atoi( separator+1 );
                 rtpInfo[ numOfRtpInfoEntries-1 ].rtptime = rtptime;
                 rtpInfo[ numOfRtpInfoEntries-1 ].rtptimeIsSet = true;
             }
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_message.cpp b/protocols/rtsp_parcom/src/rtsp_par_com_message.cpp
index 3de6939..f2515cb 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_message.cpp
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_message.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_message.h b/protocols/rtsp_parcom/src/rtsp_par_com_message.h
index c374b32..cef2f8b 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_message.h
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_message.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_outgoing_message.cpp b/protocols/rtsp_parcom/src/rtsp_par_com_outgoing_message.cpp
index d97a6a0..7f27661 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_outgoing_message.cpp
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_outgoing_message.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -447,7 +447,7 @@
             // okay, it's a normal request
 
             // do the method
-            if (method < 0 || method >= METHOD_NUM_ENTRIES)
+            if (method >= METHOD_NUM_ENTRIES)
             { // method unknown
                 return false;
             }
diff --git a/protocols/rtsp_parcom/src/rtsp_par_com_tunable.h b/protocols/rtsp_parcom/src/rtsp_par_com_tunable.h
index f944762..ecd1f53 100644
--- a/protocols/rtsp_parcom/src/rtsp_par_com_tunable.h
+++ b/protocols/rtsp_parcom/src/rtsp_par_com_tunable.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_parser.cpp b/protocols/rtsp_parcom/src/rtsp_parser.cpp
index 84eba5e..6c6a005 100644
--- a/protocols/rtsp_parcom/src/rtsp_parser.cpp
+++ b/protocols/rtsp_parcom/src/rtsp_parser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -206,7 +206,6 @@
             break;
 
         case IS_WAITING_FOR_EMBEDDED_DATA_MEMORY:
-            // nothing to do
             break;
 
         case IS_SKIPPING_OVER_EMBEDDED_DATA:
@@ -218,7 +217,6 @@
             break;
 
         case IS_CONTINUING_TO_FILL_OUT_EMBEDDED_DATA:
-            // nothing to do
             break;
 
 
@@ -260,7 +258,7 @@
     else if (internalState == IS_CONTINUING_TO_FILL_OUT_ENTITY_BODY
              ||	internalState == IS_CONTINUING_TO_FILL_OUT_EMBEDDED_DATA
             )
-    { // now things get interesting
+    {
 
         // the whole entity body arithmetic is done here, not in
         // registerDataWritten(), so here it comes
@@ -314,16 +312,16 @@
 
     bool  shouldMoveOverToBeginning = false;
 
-    // now, it's either a binary data thing, or a regular message thing
+    // now, it's either a binary data thing, or a regular message
     if (CHAR_DOLLAR == *mainBufferEntry)
-    { // interesting, could be it
+    {
 
         if (mainBufferSpace - mainBufferEntry < 4)
         { // not a complete message
             shouldMoveOverToBeginning = true;
         }
         else
-        { // it is a complete thing!
+        { // it is a complete thing
             requestStruct->msgType = RTSPRequestMsg;
             requestStruct->method = METHOD_BINARY_DATA;
 
@@ -414,7 +412,6 @@
                 uint32 atoi_tmp;
                 PV_atoi(cl, 'd', atoi_tmp);
                 ebFullSizeExpected = atoi_tmp;
-//        fflush(stdout);
             }
 
             // now, on with the moving around ...
@@ -439,7 +436,7 @@
             }
             else
             {
-                // everything is peachy
+                // everything is ok
 
                 oscl_memcpy(requestStruct->secondaryBuffer, mainBufferEntry,
                             newMessageSize);
@@ -474,7 +471,7 @@
         if (RTSP_PARSER_BUFFER_SIZE == sizeUsedSoFar)
         {	// we hit the parser's buffer size
             internalState = IS_START_LOOKING_FOR_RESYNC;
-            continueProcessing();   // xxx
+            continueProcessing();
 
             return;
         }
diff --git a/protocols/rtsp_parcom/src/rtsp_parser.h b/protocols/rtsp_parcom/src/rtsp_parser.h
index 96c05f4..b4ec603 100644
--- a/protocols/rtsp_parcom/src/rtsp_parser.h
+++ b/protocols/rtsp_parcom/src/rtsp_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_session_types.h b/protocols/rtsp_parcom/src/rtsp_session_types.h
index 56a9776..9d569e9 100644
--- a/protocols/rtsp_parcom/src/rtsp_session_types.h
+++ b/protocols/rtsp_parcom/src/rtsp_session_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/rtsp_parcom/src/rtsp_transport.h b/protocols/rtsp_parcom/src/rtsp_transport.h
index a4a428d..71fe48c 100644
--- a/protocols/rtsp_parcom/src/rtsp_transport.h
+++ b/protocols/rtsp_parcom/src/rtsp_transport.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,20 +15,11 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*                                                                               */
-/*********************************************************************************/
-
-
 #ifndef RTSP_TRANSPORT_H
 #define RTSP_TRANSPORT_H
 
-// - - Inclusion - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-//#include "oscl_types.h"
 #include "oscl_base.h"
 #include "rtsp_session_types.h"
-//#include "pv_rtp.h"
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
 
 struct RtspTransport
 {
diff --git a/protocols/sdp/common/Android.mk b/protocols/sdp/common/Android.mk
new file mode 100644
index 0000000..e272581
--- /dev/null
+++ b/protocols/sdp/common/Android.mk
@@ -0,0 +1,57 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	
+
+
+
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/protocols/sdp/common/build/make \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/aac_media_info.h \
+ 	include/aac_payload_info.h \
+ 	include/amr_media_info.h \
+ 	include/amr_payload_info.h \
+ 	include/asf_media_info.h \
+ 	include/common_info.h \
+ 	include/h263_media_info.h \
+ 	include/h263_payload_info.h \
+ 	include/h264_media_info.h \
+ 	include/h264_payload_info.h \
+ 	include/m4v_media_info.h \
+ 	include/m4v_payload_info.h \
+ 	include/media_info.h \
+ 	include/payload_info.h \
+ 	include/pcma_media_info.h \
+ 	include/pcma_payload_info.h \
+ 	include/pcmu_media_info.h \
+ 	include/pcmu_payload_info.h \
+ 	include/pv_oscl.h \
+ 	include/rfc3640_media_info.h \
+ 	include/rfc3640_payload_info.h \
+ 	include/rm_media_info.h \
+ 	include/rm_payload_info.h \
+ 	include/sdp_error.h \
+ 	include/sdp_info_comparison.h \
+ 	include/sdp_info.h \
+ 	include/sdp_memory.h \
+ 	include/sdp_return_code.h \
+ 	include/session_info.h \
+ 	include/still_image_media_info.h
+
+include $(BUILD_COPY_HEADERS)
diff --git a/protocols/sdp/common/build/make/local.mk b/protocols/sdp/common/build/make/local.mk
new file mode 100644
index 0000000..04e812a
--- /dev/null
+++ b/protocols/sdp/common/build/make/local.mk
@@ -0,0 +1,45 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+
+TARGET := 
+INCSRCDIR := ../../include
+
+HDRS := \
+	aac_media_info.h \
+	aac_payload_info.h \
+	amr_media_info.h \
+	amr_payload_info.h \
+	asf_media_info.h \
+	common_info.h \
+	h263_media_info.h \
+	h263_payload_info.h \
+	h264_media_info.h \
+	h264_payload_info.h \
+	m4v_media_info.h \
+	m4v_payload_info.h \
+	media_info.h \
+	payload_info.h \
+	pcma_media_info.h \
+	pcma_payload_info.h \
+	pcmu_media_info.h \
+	pcmu_payload_info.h \
+	pv_oscl.h \
+        rfc3640_media_info.h \
+        rfc3640_payload_info.h \
+	rm_media_info.h \
+	rm_payload_info.h \
+	sdp_error.h \
+	sdp_info_comparison.h \
+	sdp_info.h \
+	sdp_memory.h \
+	sdp_return_code.h \
+	session_info.h \
+	still_image_media_info.h
+
+
+
+include $(MK)/library.mk
diff --git a/protocols/sdp/common/build/make/makefile b/protocols/sdp/common/build/make/makefile
deleted file mode 100644
index a34238e..0000000
--- a/protocols/sdp/common/build/make/makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-
-# leave the target blank to indicate that 
-# we just installing headers here
-TARGET =
-
-INCSRCDIR = ../../include
-
-HDRS =  \
-	aac_media_info.h \
-	aac_payload_info.h \
-	amr_media_info.h \
-	amr_payload_info.h \
-	asf_media_info.h \
-	common_info.h \
-	evrc_media_info.h \
-	evrc_payload_info.h \
-	h263_media_info.h \
-	h263_payload_info.h \
-	h264_media_info.h \
-	h264_payload_info.h \
-	m4v_media_info.h \
-	m4v_payload_info.h \
-	media_info.h \
-	payload_info.h \
-	pcma_media_info.h \
-	pcma_payload_info.h \
-	pcmu_media_info.h \
-	pcmu_payload_info.h \
-	pv_oscl.h \
-        rfc3640_media_info.h \
-        rfc3640_payload_info.h \
-	rm_media_info.h \
-	rm_payload_info.h \
-	sdp_error.h \
-	sdp_info_comparison.h \
-	sdp_info.h \
-	sdp_memory.h \
-	sdp_return_code.h \
-	session_info.h \
-	still_image_media_info.h
-
-
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/protocols/sdp/common/include/aac_media_info.h b/protocols/sdp/common/include/aac_media_info.h
index 180e7e0..1c0140d 100644
--- a/protocols/sdp/common/include/aac_media_info.h
+++ b/protocols/sdp/common/include/aac_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: aac_mediaInfo.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 05/24/01														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef AAC_MEDIAINFO_H
 #define AAC_MEDIAINFO_H
@@ -46,116 +29,28 @@
 // file into each of the media elements...
 
 
-// this is a structure i need to hold information used in demultiplexing
-typedef struct _streamMuxConfig
-{
-    bool cpresent;
-    unsigned int audioMuxVersion;
-    unsigned int allStreamsSameTimeFraming;
-    unsigned int numSubFrames;
-    unsigned int frameLengthType;  // pretty sure this has to be 0 for LC or LTP
-    unsigned int bufferFullness;
-    bool otherDataPresent;
-    unsigned int otherDataLenBits;
-    bool crcCheckPresent;
-    unsigned char crcCheckSum;
-
-    unsigned int audioObjectType;
-    unsigned int samplingFrequency;
-    unsigned int channelConfiguration;
-
-    // include this because the payload parser may need to deal with inline
-    // audioSpecificConfigs and if it is the same as the current one, we dont
-    // want to reset the decoder to the same settings..
-    unsigned char * audioSpecificConfigPtr;
-    unsigned int audioSpecificConfigSize;
-
-    unsigned char ** audioSpecificConfigPtrPtr;
-    unsigned int * audioSpecificConfigSizePtr;
-
-    unsigned int parseResult;
-}streamMuxConfig;
-
 
 class aac_mediaInfo : public mediaInfo
 {
     private:
         int profileLevelID;
         OSCL_HeapString<SDPParserAlloc> lang;
-        unsigned char *audioSpecificConfigPtr;
-        int audioSpecificConfigSize;
-        streamMuxConfig * sMC;
         int numSampleEntries;
 
     public:
         aac_mediaInfo()
         {
             lang = NULL;
-            audioSpecificConfigSize = 0;
-            audioSpecificConfigPtr = NULL;
-            sMC = (streamMuxConfig *) oscl_calloc(1, sizeof(streamMuxConfig));
-            if (sMC != NULL)
-            {
-                sMC->audioSpecificConfigSize = 0;
-                sMC->audioSpecificConfigPtr = NULL;
-                sMC->audioSpecificConfigPtrPtr = &(sMC->audioSpecificConfigPtr);
-                sMC->audioSpecificConfigSizePtr = &(sMC->audioSpecificConfigSize);
-            }
             profileLevelID = -1;
         };
         aac_mediaInfo(const aac_mediaInfo & pSource) : mediaInfo(pSource)
         {
             setLang(pSource.lang);
             setProfileLevelID(pSource.profileLevelID);
-            sMC = (streamMuxConfig *) oscl_calloc(1, sizeof(streamMuxConfig));
-
-            if (sMC != NULL)
-            {
-
-                sMC->audioMuxVersion = pSource.sMC->audioMuxVersion;
-                sMC->allStreamsSameTimeFraming = pSource.sMC->allStreamsSameTimeFraming;
-                sMC->numSubFrames = pSource.sMC->numSubFrames;
-                sMC->frameLengthType = pSource.sMC->frameLengthType;
-                sMC->bufferFullness = pSource.sMC->bufferFullness;
-                sMC->otherDataPresent = pSource.sMC->otherDataPresent;
-                sMC->otherDataLenBits = pSource.sMC->otherDataLenBits;
-                sMC->crcCheckPresent = pSource.sMC->crcCheckPresent;
-                sMC->crcCheckSum = pSource.sMC->crcCheckSum;
-                sMC->audioSpecificConfigSize = pSource.sMC->audioSpecificConfigSize;
-                if (sMC->audioSpecificConfigSize != 0)
-                {
-                    sMC->audioSpecificConfigPtr = (unsigned char*) oscl_calloc(pSource.sMC->audioSpecificConfigSize, sizeof(unsigned char));
-                    if (sMC->audioSpecificConfigPtr != NULL)
-                    {
-                        oscl_memcpy(sMC->audioSpecificConfigPtr, pSource.sMC->audioSpecificConfigPtr, pSource.sMC->audioSpecificConfigSize);
-                    }
-                }
-
-                sMC->audioSpecificConfigPtrPtr = &(sMC->audioSpecificConfigPtr);
-                sMC->audioSpecificConfigSizePtr = &(sMC->audioSpecificConfigSize);
-                audioSpecificConfigSize = pSource.audioSpecificConfigSize;
-                audioSpecificConfigPtr = sMC->audioSpecificConfigPtr;
-
-            }
         }
 
         ~aac_mediaInfo()
         {
-            if (sMC != NULL)
-            {
-                if (sMC->audioSpecificConfigPtr != NULL)
-                {
-                    oscl_free(sMC->audioSpecificConfigPtr);
-                    sMC->audioSpecificConfigPtr = audioSpecificConfigPtr = NULL;
-                }
-                oscl_free(sMC);
-                sMC = NULL;
-            }
-            if (audioSpecificConfigPtr != NULL)
-            {
-                oscl_free(audioSpecificConfigPtr);
-                audioSpecificConfigPtr = NULL;
-            }
         };
         inline void setLang(char* language)
         {
@@ -174,13 +69,6 @@
             profileLevelID = pID;
         };
 
-        inline void setAudioSpecificConfig(unsigned char* ASCPtr, int ASCLen)
-        {
-            audioSpecificConfigPtr = ASCPtr;
-            audioSpecificConfigSize = ASCLen;
-            sMC->audioSpecificConfigPtr = audioSpecificConfigPtr;
-            sMC->audioSpecificConfigSize = audioSpecificConfigSize;
-        };
         inline void setNumSampleEntries(int inNumSampleEntries)
         {
             numSampleEntries = inNumSampleEntries;
@@ -195,16 +83,6 @@
         {
             return profileLevelID;
         };
-
-        inline const unsigned char *getAudioSpecificConfig(int*size)
-        {
-            *size = *(sMC->audioSpecificConfigSizePtr);
-            return *(sMC->audioSpecificConfigPtrPtr);
-        };
-        inline const void *getStreamMuxConfig()
-        {
-            return sMC;
-        };
         inline int getNumSampleEntries()
         {
             return numSampleEntries;
diff --git a/protocols/sdp/common/include/aac_payload_info.h b/protocols/sdp/common/include/aac_payload_info.h
index eae3f61..fb49b81 100644
--- a/protocols/sdp/common/include/aac_payload_info.h
+++ b/protocols/sdp/common/include/aac_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: aac_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef AAC_PAYLOAD_INFO_H
 #define AAC_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/amr_media_info.h b/protocols/sdp/common/include/amr_media_info.h
index c37f52e..1c6f088 100644
--- a/protocols/sdp/common/include/amr_media_info.h
+++ b/protocols/sdp/common/include/amr_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: amr_mediaInfo.h													*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef AMR_MEDIAINFO_H
 #define AMR_MEDIAINFO_H
diff --git a/protocols/sdp/common/include/amr_payload_info.h b/protocols/sdp/common/include/amr_payload_info.h
index 0a06bb8..c49d017 100644
--- a/protocols/sdp/common/include/amr_payload_info.h
+++ b/protocols/sdp/common/include/amr_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: amr_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef AMR_PAYLOAD_INFO_H
 #define AMR_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/asf_media_info.h b/protocols/sdp/common/include/asf_media_info.h
new file mode 100644
index 0000000..e4b3e7c
--- /dev/null
+++ b/protocols/sdp/common/include/asf_media_info.h
@@ -0,0 +1,178 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef ASF_MEDIAINFO_H
+#define ASF_MEDIAINFO_H
+
+#include "sdp_memory.h"
+#include "media_info.h"
+
+// NOTE.... this information really needs to exist for only one media object...
+// i.e., there is no reason to have arrays of these fields, since we have one of these
+// mediaInfo elements for each media object... the trick is how to get these from the SDP
+// file into each of the media elements...
+
+class asf_mediaInfo : public mediaInfo
+{
+    private:
+
+        //int profileLevelID;
+        OSCL_HeapString<SDPParserAlloc> lang;
+        unsigned char *asfHeaderPtr;
+        int asfHeaderSize;
+
+        //for both audio and video
+        unsigned char *decoderSpecificInfo;
+        int decoderSpecificInfoSize;
+        //unsigned char *VOLHeaderPtr;
+        //int VOLHeaderSize;
+        int streamID;
+        int streamBitrate;
+        //int numSampleEntries;
+
+    public:
+        asf_mediaInfo()
+        {
+            lang = NULL;
+            asfHeaderSize = 0;
+            asfHeaderPtr = NULL;
+            decoderSpecificInfoSize = 0;
+            decoderSpecificInfo = NULL;
+            //VOLHeaderSize = 0;
+            //VOLHeaderPtr = NULL;
+            streamBitrate = 0;
+            //profileLevelID = -1;
+        };
+        asf_mediaInfo(const asf_mediaInfo & pSource) : mediaInfo(pSource)
+        {
+            setLang(pSource.lang);
+            //setProfileLevelID(pSource.profileLevelID);
+            asfHeaderSize = pSource.asfHeaderSize;
+            decoderSpecificInfoSize = pSource.decoderSpecificInfoSize;
+            //VOLHeaderSize = pSource.VOLHeaderSize;
+
+        };
+
+        ~asf_mediaInfo()
+        {
+            if (asfHeaderPtr != NULL)
+            {
+                oscl_free(asfHeaderPtr);
+                asfHeaderPtr = NULL;
+            }
+            if (decoderSpecificInfo != NULL)
+            {
+//            oscl_free(decoderSpecificInfo); //added
+                decoderSpecificInfo = NULL;
+            }
+            /*
+            if(VOLHeaderPtr!=NULL) {
+                oscl_free(VOLHeaderPtr);
+                VOLHeaderPtr = NULL;
+            }
+            */
+        };
+        inline void setLang(char* language)
+        {
+            lang = language;
+        };
+        inline void setLang(const OSCL_HeapString<SDPParserAlloc>& language)
+        {
+            lang = language;
+        };
+        /*
+        inline void setProfileLevelID(int pID)
+        {
+        	profileLevelID = pID;
+        };
+        */
+        inline void setStreamID(int ID)
+        {
+            streamID = ID;
+        };
+        inline void setStreamBitrate(int bitrate)
+        {
+            streamBitrate = bitrate;
+        };
+        inline void setAsfHeader(unsigned char* ASCPtr, int ASCLen)
+        {
+            asfHeaderPtr = ASCPtr;
+            asfHeaderSize = ASCLen;
+        };
+
+        inline void setDecoderSpecificInfo(unsigned char* ASCPtr, int ASCLen)
+        {
+            decoderSpecificInfo = ASCPtr;
+            decoderSpecificInfoSize = ASCLen;
+        };
+
+        /*
+        inline void setVOLHeader(unsigned char* ASCPtr, int ASCLen)
+        {
+            VOLHeaderPtr = ASCPtr;
+            VOLHeaderSize = ASCLen;
+        };
+        */
+        inline int GetTotalStringLength()
+        {
+            int size = 0;
+            size += mediaInfo::GetTotalStringLength();
+            if (lang.get_size() > 0)
+            {
+                size += oscl_strlen("a=lang:") + lang.get_size() + SDP_CR_LF;
+            }
+            return size;
+        }
+        inline const char *getLang()
+        {
+            return lang.get_cstr();
+        };
+//	inline int getProfileLevelID(){return profileLevelID;};
+
+        inline const unsigned char *getAsfHeader(int*size)
+        {
+            return 0;
+        };
+
+        inline int getVOLLength()
+        {
+            //	return VOLHeaderSize;
+            return 	decoderSpecificInfoSize;
+        };
+
+        inline unsigned char *getVOLHeader()
+        {
+            return decoderSpecificInfo;
+            //return VOLHeaderPtr;
+        };
+
+        inline const unsigned char *getAudioSpecificConfig(int*size)
+        {
+            *size = decoderSpecificInfoSize;
+            return decoderSpecificInfo;
+        };
+
+        inline int getStreamID()
+        {
+            return streamID;
+        };
+        inline int getStreamBitrate()
+        {
+            return streamBitrate;
+        };
+};
+#endif
diff --git a/protocols/sdp/common/include/common_info.h b/protocols/sdp/common/include/common_info.h
index c5c1c14..598892d 100644
--- a/protocols/sdp/common/include/common_info.h
+++ b/protocols/sdp/common/include/common_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,13 +24,15 @@
 #include "oscl_types.h"
 #include "oscl_string_containers.h"
 #include "sdp_memory.h"
-
+#include "pvmi_kvp.h"
 
 #define MAX_METRICS_NAME	7
-#define ASSET_NAME_SIZE		11
+#define ASSET_NAME_SIZE		13
 #define MAX_ALTERNATIVES	16
 #define ALT_SIZE			128
 
+
+//code in basemediainfoparser.cpp depends on FIRST_STATIC_PAYLOAD == 0
 #define FIRST_STATIC_PAYLOAD 0
 #define LAST_STATIC_PAYLOAD 33
 
@@ -75,6 +77,8 @@
 
 };
 
+#define MAX_ASSET_INFO_KEYWORDS 256
+
 class AssetInfoType
 {
     public:
@@ -90,27 +94,76 @@
             CLASSIFICATION = 7,
             KEYWORDS = 8,
             LOCATION = 9,
-            ASSET_EXTENTION = 10
+            ALBUM = 10,
+            RECORDINGYEAR = 11,
+            ASSET_EXTENTION = 12
         };
 
         AssetInfoType()
         {
+            ResetAssetInfoType();
+        };
+
+        void ResetAssetInfoType()
+        {
+            URL = NULL;
+            int ii;
+            for (ii = 0;ii < ASSET_NAME_SIZE;ii++)
+            {
+                Box[ii] = NULL;
+            }
             oTitlePresent = false;
             oDescriptionPresent = false;
             oCopyRightPresent = false;
             oPerformerPresent = false;
             oAuthorPresent = false;
-            oGenrePresent = false;
-            oRatingPresent = false;
+            oGenrePresent  = false;
+            oRatingPresent  = false;
             oClassificationPresent = false;
             oKeyWordsPresent = false;
+            iNumKeyWords = 0;
+            for (ii = 0;ii < MAX_ASSET_INFO_KEYWORDS; ii++)
+            {
+                KeyWords[ii] = NULL;
+            }
             oLocationPresent = false;
+            oAlbumPresent = false;
+            oRecordingYearPresent = false;
             oAssetExtensionPresent = false;
+            iRecordingYear = 0;
+            CleanUp();
         };
 
+        void CleanUp()
+        {
+            if (iLocationStruct._location_name != NULL)
+            {
+                oscl_free(iLocationStruct._location_name);
+                iLocationStruct._location_name = NULL;
+            }
+            if (iLocationStruct._astronomical_body != NULL)
+            {
+                oscl_free(iLocationStruct._astronomical_body);
+                iLocationStruct._astronomical_body = NULL;
+            }
+            if (iLocationStruct._additional_notes != NULL)
+            {
+                oscl_free(iLocationStruct._additional_notes);
+                iLocationStruct._additional_notes = NULL;
+            }
+        };
+
+        AssetInfoType& operator=(const AssetInfoType& a)
+        {
+            if (&a != this)
+            {
+                MyCopy(a);
+            }
+            return *this;
+        }
+
         OSCL_HeapString<SDPParserAlloc> URL;
         OSCL_HeapString<SDPParserAlloc> Box[ASSET_NAME_SIZE];
-
         bool oTitlePresent;
         bool oDescriptionPresent;
         bool oCopyRightPresent;
@@ -120,8 +173,45 @@
         bool oRatingPresent;
         bool oClassificationPresent;
         bool oKeyWordsPresent;
+        uint32 iNumKeyWords;
+        OSCL_HeapString<SDPParserAlloc> KeyWords[MAX_ASSET_INFO_KEYWORDS];
         bool oLocationPresent;
+        bool oAlbumPresent;
         bool oAssetExtensionPresent;
+        bool oRecordingYearPresent;
+        uint16 iRecordingYear;
+        PvmfAssetInfo3GPPLocationStruct iLocationStruct;
+
+    private:
+        void MyCopy(const AssetInfoType&a)
+        {
+            URL = a.URL;
+            int ii = 0;
+            for (ii = 0;ii < ASSET_NAME_SIZE; ii++)
+            {
+                Box[ii] = a.Box[ii];
+            }
+            oTitlePresent = a.oTitlePresent;
+            oDescriptionPresent = a.oDescriptionPresent;
+            oCopyRightPresent = a.oCopyRightPresent;
+            oPerformerPresent = a.oPerformerPresent;
+            oAuthorPresent = a.oAuthorPresent;
+            oGenrePresent  = a.oGenrePresent;
+            oRatingPresent  = a.oRatingPresent;
+            oClassificationPresent = a.oClassificationPresent;
+            oKeyWordsPresent = a.oKeyWordsPresent;
+            iNumKeyWords = a.iNumKeyWords;
+            for (ii = 0;ii < MAX_ASSET_INFO_KEYWORDS; ii++)
+            {
+                KeyWords[ii] = a.KeyWords[ii];
+            }
+            oLocationPresent = a.oLocationPresent;
+            oAlbumPresent = a.oAlbumPresent;
+            oRecordingYearPresent = a.oRecordingYearPresent;
+            iRecordingYear = a.iRecordingYear;
+            oAssetExtensionPresent = a.oAssetExtensionPresent;
+            iLocationStruct = a.iLocationStruct;
+        }
 };
 
 
diff --git a/protocols/sdp/common/include/evrc_media_info.h b/protocols/sdp/common/include/evrc_media_info.h
deleted file mode 100644
index 11d59cd..0000000
--- a/protocols/sdp/common/include/evrc_media_info.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: evrc_mediaInfo.h													*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
-
-#ifndef EVRC_MEDIAINFO_H
-#define EVRC_MEDIAINFO_H
-
-#include "sdp_memory.h"
-#include "media_info.h"
-
-struct EVRCfmtpInfoType
-{
-    uint32 payloadNumber;
-    int maximumFrames;
-    int maximumBundle;
-    int packetTime;
-};
-
-class evrc_mediaInfo : public mediaInfo
-{
-    private:
-
-
-        OSCL_HeapString<SDPParserAlloc> lang;
-    public:
-        evrc_mediaInfo()
-        {
-            mediaInfo();
-            lang = NULL;
-        };
-
-        evrc_mediaInfo(const evrc_mediaInfo& pSource) : mediaInfo(pSource)
-        {
-
-            setLang(pSource.lang);
-        }
-
-        ~evrc_mediaInfo() {};
-
-        inline void setLang(char* lan)
-        {
-            lang = lan;
-        };
-        inline void setLang(const OSCL_HeapString<SDPParserAlloc>& lan)
-        {
-            lang = lan;
-        };
-        inline void setLang(const OsclMemoryFragment memFrag)
-        {
-            lang.set((const char*)(memFrag.ptr), memFrag.len);
-        };
-
-        inline const char *getLang()
-        {
-            return lang.get_cstr();
-        };
-
-};
-
-#endif
diff --git a/protocols/sdp/common/include/evrc_payload_info.h b/protocols/sdp/common/include/evrc_payload_info.h
deleted file mode 100644
index 641a78c..0000000
--- a/protocols/sdp/common/include/evrc_payload_info.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: evrc_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
-
-#ifndef EVRC_PAYLOAD_INFO_H
-#define EVRC_PAYLOAD_INFO_H
-
-#include "payload_info.h"
-
-#define PVMF_SDP_DEFAULT_EVRC_SAMPLE_RATE 8000
-
-class EvrcPayloadSpecificInfoType : public PayloadSpecificInfoTypeBase
-{
-    public:
-        EvrcPayloadSpecificInfoType(int payload)
-        {
-            payloadNumber = payload;
-
-            evrc_maximumBundle = -1;
-            evrc_maximumFrames = -1;
-            evrc_packetTime = -1;
-            frameWidth = -1;
-            frameHeight = -1;
-        };
-
-        inline void setMaximumFrames(int mFrames)
-        {
-            evrc_maximumFrames = mFrames;
-        };
-
-        inline void setMaximumBundle(int mBundle)
-        {
-            evrc_maximumBundle = mBundle;
-        };
-
-        inline void setPacketTime(int pTime)
-        {
-            evrc_packetTime = pTime;
-        };
-
-        inline void setFrameWidth(int fWidth)
-        {
-            frameWidth = fWidth;
-        };
-        inline void setFrameHeight(int fHeight)
-        {
-            frameHeight = fHeight;
-        };
-
-        inline int getFrameWidth()
-        {
-            return frameWidth;
-        }
-
-        inline int getFrameHeight()
-        {
-            return frameHeight;
-        }
-
-
-    private:
-        int evrc_maximumFrames;
-        int evrc_maximumBundle;
-        int evrc_packetTime;
-        int frameWidth;
-        int frameHeight;
-};
-
-#endif
diff --git a/protocols/sdp/common/include/h263_media_info.h b/protocols/sdp/common/include/h263_media_info.h
index b6b7b36..08615a0 100644
--- a/protocols/sdp/common/include/h263_media_info.h
+++ b/protocols/sdp/common/include/h263_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: h263_mediaInfo.h													*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef H263_MEDIAINFO_H
 #define H263_MEDIAINFO_H
diff --git a/protocols/sdp/common/include/h263_payload_info.h b/protocols/sdp/common/include/h263_payload_info.h
index 1471381..d3acaad 100644
--- a/protocols/sdp/common/include/h263_payload_info.h
+++ b/protocols/sdp/common/include/h263_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: h263_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef H263_PAYLOAD_INFO_H
 #define H263_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/h264_media_info.h b/protocols/sdp/common/include/h264_media_info.h
index 748b3b1..0b56dbc 100644
--- a/protocols/sdp/common/include/h264_media_info.h
+++ b/protocols/sdp/common/include/h264_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/sdp/common/include/h264_payload_info.h b/protocols/sdp/common/include/h264_payload_info.h
index 21c286d..022e635 100644
--- a/protocols/sdp/common/include/h264_payload_info.h
+++ b/protocols/sdp/common/include/h264_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: h264_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef H264_PAYLOAD_INFO_H
 #define H264_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/m4v_media_info.h b/protocols/sdp/common/include/m4v_media_info.h
index d3710f9..9f802b3 100644
--- a/protocols/sdp/common/include/m4v_media_info.h
+++ b/protocols/sdp/common/include/m4v_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: m4v_mediaInfo.h													*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef M4V_MEDIAINFO_H
 #define M4V_MEDIAINFO_H
diff --git a/protocols/sdp/common/include/m4v_payload_info.h b/protocols/sdp/common/include/m4v_payload_info.h
index baeafd9..8721622 100644
--- a/protocols/sdp/common/include/m4v_payload_info.h
+++ b/protocols/sdp/common/include/m4v_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: m4v_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef M4V_PAYLOAD_INFO_H
 #define M4V_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/media_info.h b/protocols/sdp/common/include/media_info.h
index 9480907..cd4a87c 100644
--- a/protocols/sdp/common/include/media_info.h
+++ b/protocols/sdp/common/include/media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: MediaInfo.h														                            */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef MEDIAINFO_H
 #define MEDIAINFO_H
@@ -51,7 +34,6 @@
 #include "pcma_payload_info.h"
 #include "h263_payload_info.h"
 #include "h264_payload_info.h"
-#include "evrc_payload_info.h"
 #include "m4v_payload_info.h"
 #include "rfc3640_payload_info.h"
 
@@ -105,7 +87,6 @@
         int BWtias;
         RtspRangeType range;
 
-        uint16 contentVersion; //Implement set and get functions.
 
         int parameter_size;
         OSCL_HeapString<SDPParserAlloc> dependsonURL;
@@ -151,7 +132,6 @@
             rtcpBWSender = -1;
             rtcpBWReceiver = -1;
             BWtias = 0;
-            contentVersion = 0;
             allowRecord = false;
             select = false;
             parameter_size = 0;
@@ -217,6 +197,7 @@
                 payloadSpecificInfoVector[ii]->~PayloadSpecificInfoTypeBase();
                 dealloc(payloadSpecificInfoVector[ii]);
             }
+            assetInfo.CleanUp();
         };
 
         void *alloc(const int size)
@@ -389,10 +370,6 @@
         {
             mediaInfoID = id;
         };
-        inline void setContentVersion(uint16 cv)
-        {
-            contentVersion = cv;
-        };
 
         inline void setAllowRecord(bool allrec)
         {
@@ -451,13 +428,8 @@
         }
         inline void setAssetInfo(const AssetInfoType &ainfo)
         {
-            if (ainfo.URL.get_size() > 0)
-                assetInfo.URL = ainfo.URL;
-
-            for (int ii = 0; ii < ASSET_NAME_SIZE; ii++)
-                assetInfo.Box[ii] = ainfo.Box[ii];
+            assetInfo = ainfo;
         }
-
         inline void setCNetworkType(char *nType)
         {
             connectInfo.connectionNetworkType = nType;
@@ -788,11 +760,7 @@
         {
             return allowRecord;
         };
-        inline virtual void getContentVersion(uint8 & major_version, uint8 & minor_version)
-        {
-            major_version = (uint8)((contentVersion & 0xff00) >> 8);
-            minor_version = (uint8)(contentVersion & 0x00ff);
-        };
+
         inline bool getRandomAccessDenied()
         {
             return randomAccessDenied;
@@ -929,7 +897,6 @@
 
             setControlTrackID(pSource.controlURLTrackID);
             setMediaInfoID(pSource.mediaInfoID);
-            setContentVersion(pSource.contentVersion);
             setAllowRecord(pSource.allowRecord);
             setRange(pSource.range);
 
@@ -1000,7 +967,6 @@
                 setNumOfChannelsForPayloads(pSource.payloadSpecificInfoVector);
 
                 setControlTrackID(pSource.controlURLTrackID);
-                setContentVersion(pSource.contentVersion);
                 setAllowRecord(pSource.allowRecord);
                 setRange(pSource.range);
                 if (pSource.select == true)
diff --git a/protocols/sdp/common/include/payload_info.h b/protocols/sdp/common/include/payload_info.h
index 1b37538..b90e14b 100644
--- a/protocols/sdp/common/include/payload_info.h
+++ b/protocols/sdp/common/include/payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef PAYLOAD_INFO_H
 #define PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/pcma_media_info.h b/protocols/sdp/common/include/pcma_media_info.h
index b3e4430..b764787 100644
--- a/protocols/sdp/common/include/pcma_media_info.h
+++ b/protocols/sdp/common/include/pcma_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
 /*	=====================================================================	*/
 /*	File: pcma_mediaInfo.h													*/
 /*	Description:															*/
@@ -29,6 +28,7 @@
 /*																			*/
 /*	Rev:																	*/
 /*	Date:																	*/
+/*	Author:																	*/
 /*	Description:															*/
 /*																			*/
 /* //////////////////////////////////////////////////////////////////////// */
diff --git a/protocols/sdp/common/include/pcma_payload_info.h b/protocols/sdp/common/include/pcma_payload_info.h
index f7d953c..a74a855 100644
--- a/protocols/sdp/common/include/pcma_payload_info.h
+++ b/protocols/sdp/common/include/pcma_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: pcma_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef PCMA_PAYLOAD_INFO_H
 #define PCMA_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/pcmu_media_info.h b/protocols/sdp/common/include/pcmu_media_info.h
index ce7633c..16364eb 100644
--- a/protocols/sdp/common/include/pcmu_media_info.h
+++ b/protocols/sdp/common/include/pcmu_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
 /*	=====================================================================	*/
 /*	File: pcmu_mediaInfo.h													*/
 /*	Description:															*/
@@ -29,6 +28,7 @@
 /*																			*/
 /*	Rev:																	*/
 /*	Date:																	*/
+/*	Author:																	*/
 /*	Description:															*/
 /*																			*/
 /* //////////////////////////////////////////////////////////////////////// */
diff --git a/protocols/sdp/common/include/pcmu_payload_info.h b/protocols/sdp/common/include/pcmu_payload_info.h
index 1ba4ef6..3d99b76 100644
--- a/protocols/sdp/common/include/pcmu_payload_info.h
+++ b/protocols/sdp/common/include/pcmu_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                  */
-/*	=====================================================================	*/
-/*	File: pcmu_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/04/06														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef PCMU_PAYLOAD_INFO_H
 #define PCMU_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/pv_oscl.h b/protocols/sdp/common/include/pv_oscl.h
index b3c3d26..dd4fda6 100644
--- a/protocols/sdp/common/include/pv_oscl.h
+++ b/protocols/sdp/common/include/pv_oscl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: PVOscl.h															*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef PV_OSCL_H
 #define PV_OSCL_H
diff --git a/protocols/sdp/common/include/rfc3640_media_info.h b/protocols/sdp/common/include/rfc3640_media_info.h
index 86b47f0..2063058 100644
--- a/protocols/sdp/common/include/rfc3640_media_info.h
+++ b/protocols/sdp/common/include/rfc3640_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/* //////////////////////////////////////////////////////////////////////// */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: rfc3640_mediaInfo.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created:05/17/07														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef RFC3640_MEDIAINFO_H_INCLUDED
 #define RFC3640_MEDIAINFO_H_INCLUDED
diff --git a/protocols/sdp/common/include/rfc3640_payload_info.h b/protocols/sdp/common/include/rfc3640_payload_info.h
index ed31e6d..88860d2 100644
--- a/protocols/sdp/common/include/rfc3640_payload_info.h
+++ b/protocols/sdp/common/include/rfc3640_payload_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/* /////////////////////////////////////////////////////////////////////// */
-/*                                        																*/
-/*	=====================================================================	*/
-/*	File: rfc3640_payload_info.h													                        */
-/*	Description:															                            */
-/*																			                                  */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Created: 04/27/07														                          */
-/*	=====================================================================	*/
-/*																			                                  */
-/*	Revision History:														                          */
-/*																			                                  */
-/*	Rev:																	                                */
-/*	Date:																	                                */
-/*	Description:															                            */
-/*																			                                  */
-/* /////////////////////////////////////////////////////////////////////// */
 
 #ifndef RFC3640_PAYLOAD_INFO_H
 #define RFC3640_PAYLOAD_INFO_H
diff --git a/protocols/sdp/common/include/rm_media_info.h b/protocols/sdp/common/include/rm_media_info.h
new file mode 100644
index 0000000..e29066f
--- /dev/null
+++ b/protocols/sdp/common/include/rm_media_info.h
@@ -0,0 +1,294 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef RM_MEDIAINFO_H
+#define RM_MEDIAINFO_H
+#include "media_info.h"
+
+class rm_mediaInfo : public mediaInfo
+{
+    private:
+        /* RM Related */
+        NptTimeFormat rm_length;
+        OSCL_HeapString<SDPParserAlloc> rm_mimetype;
+        int rm_StreamId;
+        int rm_AvgBitRate;
+        int rm_AvgPacketSize;
+        int rm_EndOneRuleEndAll;
+        int rm_MaxBitRate;
+        int rm_MaxPacketSize;
+        int rm_Preroll;
+        int rm_ActualPreroll;
+        int rm_EndTime;
+        OSCL_HeapString<SDPParserAlloc> rm_Flags;
+        OSCL_HeapString<SDPParserAlloc> rm_ASMRuleBook;
+        OSCL_HeapString<SDPParserAlloc> rm_intrinsicDurationType;
+        OSCL_HeapString<SDPParserAlloc> rm_StreamName;
+        //In real media SDP, decoder specific info is present as a separate SDP field called OpaqueData.
+        //It is not stored as a part of config field of a=fmtp.
+        OsclSharedPtr<uint8> rm_decoderSpecificdata;
+        uint32 rm_decoderSpecificdataSize;
+
+    public:
+        rm_mediaInfo()
+        {
+            rm_StreamId = 0;
+            rm_AvgBitRate = 0;
+            rm_AvgPacketSize = 0;
+            rm_EndOneRuleEndAll = 0;
+            rm_MaxBitRate = 0;
+            rm_MaxPacketSize = 0;
+            rm_Preroll = 0;
+            rm_ActualPreroll = 0;
+            rm_EndTime = 0;
+            rm_decoderSpecificdataSize = 0;
+        };
+
+        rm_mediaInfo(const rm_mediaInfo &pSource) : mediaInfo(pSource)
+        {
+            setRMLength(pSource.rm_length);
+        }
+
+        const rm_mediaInfo & operator=(const rm_mediaInfo &pSource)
+        {
+            if (&pSource != this)
+            {
+                setRMLength(pSource.rm_length);
+            }
+
+            return pSource;
+        }
+
+        ~rm_mediaInfo() {};
+
+        inline void setRMMimeType(const char* MType)
+        {
+            rm_mimetype = MType;
+        };
+
+        inline void setRMMimeType(const OSCL_HeapString<SDPParserAlloc>& MType)
+        {
+            rm_mimetype = MType;
+        };
+
+        inline void setRMMimeType(const OsclMemoryFragment memFrag)
+        {
+            rm_mimetype.set((const char*)(memFrag.ptr), memFrag.len);
+        };
+
+        inline void setRMLength(const NptTimeFormat& in_range)
+        {
+            rm_length = in_range;
+        };
+
+        inline OSCL_HeapString<SDPParserAlloc> getRMMimeType()
+        {
+            return rm_mimetype;
+        };
+
+        inline void setRealStreamId(int streamid)
+        {
+            rm_StreamId = streamid;
+        };
+
+        inline int getRealStreamId()
+        {
+            return rm_StreamId;
+        };
+
+        inline void setAvgBitRate(int min_bit_rate)
+        {
+            rm_AvgBitRate = min_bit_rate;
+        };
+
+        inline int getAvgBitRate()
+        {
+            return	rm_AvgBitRate;
+        };
+
+        inline void setAvgPacketSize(int pack_sz)
+        {
+            rm_AvgPacketSize = pack_sz;
+        };
+        inline int getAvgPacketSize()
+        {
+            return	rm_AvgPacketSize;
+        };
+        inline void setMaxBitRate(int max_bit_rate)
+        {
+            rm_MaxBitRate = max_bit_rate;
+        };
+        inline int getMaxBitRate()
+        {
+            return	rm_MaxBitRate;
+        };
+
+        inline void setMaxPacketSize(int max_pack_sz)
+        {
+            rm_MaxPacketSize = max_pack_sz;
+        };
+        inline int getMaxPacketSize()
+        {
+            return	rm_MaxPacketSize;
+        };
+
+        inline void setPreroll(int preroll)
+        {
+            rm_Preroll = preroll;
+        };
+        inline int getPreroll()
+        {
+            return	rm_Preroll;
+        };
+        inline void setActualPreroll(int acpreroll)
+        {
+            rm_ActualPreroll = acpreroll;
+        };
+
+        inline int getActualPreroll()
+        {
+            return	rm_ActualPreroll;
+        };
+
+        inline void setEndTime(int endtime)
+        {
+            rm_EndTime = endtime;
+        };
+
+        inline int getEndTime()
+        {
+            return	rm_EndTime;
+        };
+        inline void setEndOneRuleEndAll(int endrule)
+        {
+            rm_EndOneRuleEndAll = endrule;
+        };
+
+        inline int getEndOneRuleEndAll()
+        {
+            return	rm_EndOneRuleEndAll;
+        };
+
+        inline void setRMFlags(const char* flag)
+        {
+            rm_Flags = flag;
+        };
+
+        inline void setRMFlags(const OSCL_HeapString<SDPParserAlloc>& flag)
+        {
+            rm_Flags = flag;
+        };
+
+        inline void setRMFlags(const OsclMemoryFragment memFrag)
+        {
+            rm_Flags.set((const char*)(memFrag.ptr), memFrag.len);
+        };
+
+        inline OSCL_HeapString<SDPParserAlloc> getRMFlags()
+        {
+            return rm_Flags;
+        };
+        inline void setASMRuleBook(const char* asmRule)
+        {
+            rm_ASMRuleBook = asmRule;
+        };
+
+        inline void setASMRuleBook(const OSCL_HeapString<SDPParserAlloc>& asmRule)
+        {
+            rm_ASMRuleBook = asmRule;
+        };
+
+        inline void setASMRuleBook(const OsclMemoryFragment memFrag)
+        {
+            rm_ASMRuleBook.set((const char*)(memFrag.ptr), memFrag.len);
+        };
+
+        inline OSCL_HeapString<SDPParserAlloc> getASMRuleBook()
+        {
+            return rm_ASMRuleBook;
+        };
+        inline void setintrinsicDurationType(const char* intrinsicDuration)
+        {
+            rm_intrinsicDurationType = intrinsicDuration;
+        };
+
+        inline void setintrinsicDurationType(const OSCL_HeapString<SDPParserAlloc>& intrinsicDuration)
+        {
+            rm_intrinsicDurationType = intrinsicDuration;
+        };
+
+        inline void setintrinsicDurationType(const OsclMemoryFragment memFrag)
+        {
+            rm_intrinsicDurationType.set((const char*)(memFrag.ptr), memFrag.len);
+        };
+
+        inline OSCL_HeapString<SDPParserAlloc> getintrinsicDurationType()
+        {
+            return rm_intrinsicDurationType;
+        };
+
+        inline void setStreamName(const char* stream)
+        {
+            rm_StreamName = stream;
+        };
+
+        inline void setStreamName(const OSCL_HeapString<SDPParserAlloc>& stream)
+        {
+            rm_StreamName = stream;
+        };
+
+        inline void setStreamName(const OsclMemoryFragment memFrag)
+        {
+            rm_StreamName.set((const char*)(memFrag.ptr), memFrag.len);
+        };
+
+        inline OSCL_HeapString<SDPParserAlloc> getStreamName()
+        {
+            return rm_StreamName;
+        };
+
+        inline void setRMDecoderSpecificInfo(OsclSharedPtr<uint8> Info)
+        {
+            rm_decoderSpecificdata = Info;
+        }
+
+        inline OsclSharedPtr<uint8> getRMDecoderSpecificInfo()
+        {
+            return rm_decoderSpecificdata;
+        }
+
+        inline void setRMDecoderSpecificInfoSize(uint32 size)
+        {
+            rm_decoderSpecificdataSize = size;
+        }
+
+        inline uint32 getRMDecoderSpecificInfoSize()
+        {
+            return rm_decoderSpecificdataSize;
+        }
+
+        inline NptTimeFormat *getRMLength()
+        {
+            return &rm_length;
+        };
+
+
+};
+
+#endif
+
+
diff --git a/protocols/sdp/common/include/rm_payload_info.h b/protocols/sdp/common/include/rm_payload_info.h
new file mode 100644
index 0000000..6b947f4
--- /dev/null
+++ b/protocols/sdp/common/include/rm_payload_info.h
@@ -0,0 +1,34 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+
+#ifndef RM_PAYLOAD_INFO_H
+#define RM_PAYLOAD_INFO_H
+
+#include "payload_info.h"
+
+class RmPayloadSpecificInfoType : public PayloadSpecificInfoTypeBase
+{
+    public:
+        RmPayloadSpecificInfoType(int payload)
+        {
+            payloadNumber = payload;
+        };
+};
+
+#endif
diff --git a/protocols/sdp/common/include/sdp_error.h b/protocols/sdp/common/include/sdp_error.h
index f161edc..3da8ea3 100644
--- a/protocols/sdp/common/include/sdp_error.h
+++ b/protocols/sdp/common/include/sdp_error.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,42 +18,7 @@
 #ifndef __SDP_ERROR_H__
 #define __SDP_ERROR_H__
 
-/*======================================================================
-FILE:                 SDPError.h
 
-SERVICES:             SDP Composer Error Interface Class
-
-GENERAL DESCRIPTION:  Provides the local interface to the SDP composition
-					  utility.
-
-
-PUBLIC CLASSES:       None
-
-INITIALIZATION AND SEQUENCING REQUIREMENTS:
-                      None.
-
-     -------------------------------------------------------------------
-                    SDP Composer Error interface class
-     -------------------------------------------------------------------
-
-======================================================================*/
-
-
-//======================================================================
-//   INCLUDES AND VARIABLE DEFINITIONS
-//======================================================================
-
-//----------------------------------------------------------------------
-// Include Files
-//----------------------------------------------------------------------
-
-//----------------------------------------------------------------------
-// Global Constant Declarations
-//----------------------------------------------------------------------
-
-//----------------------------------------------------------------------
-// Global Type Declarations
-//----------------------------------------------------------------------
 typedef enum
 {
     SDP_SUCCESS,
diff --git a/protocols/sdp/common/include/sdp_info.h b/protocols/sdp/common/include/sdp_info.h
index 4639550..d716168 100644
--- a/protocols/sdp/common/include/sdp_info.h
+++ b/protocols/sdp/common/include/sdp_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 #include "media_info.h"
 #include "aac_media_info.h"
 #include "amr_media_info.h"
-#include "evrc_media_info.h"
 #include "m4v_media_info.h"
 #include "rfc3640_media_info.h"
 #include "h263_media_info.h"
@@ -67,439 +66,64 @@
 class SDPInfo
 {
     public:
-        SDPInfo()
-        {
-            registrar_locally_allocated = false;
-            reg = NULL;
-            numMediaObjects = 0;
-            iMediaObjectIndex = 0;
-            segmentCount = 0;
-            for (int ii = 0; ii < MAX_SEGMENTS; ii++)
-            {
-                segmentInfo[ii].segmentActive = true;
-                segmentInfo[ii].segmentPayloadOrderPref = false;
-            }
-        }
-
-        SDPInfo(const SDPInfo &sourceSdpInfo)
-        {
-            registrar_locally_allocated = false;
-            reg = NULL;
-            numMediaObjects = 0;
-            iMediaObjectIndex = 0;
-            segmentCount = sourceSdpInfo.segmentCount;
-            for (int jj = 0; jj < MAX_SEGMENTS; jj++)
-            {
-                segmentInfo[jj] = sourceSdpInfo.segmentInfo[jj];
-            }
-
-            session_info = sourceSdpInfo.session_info;
-            bool alternateMedia;
-            for (int ii = 0; ii < sourceSdpInfo.numMediaObjects; ii++)
-            {
-                for (int ss = 0; ss < (int)pMediaInfo[ii].size(); ss++)
-                {
-                    const char *MIMEType = (sourceSdpInfo.pMediaInfo[ii][ss])->getMIMEType();
-                    if (!oscl_strncmp(MIMEType, "AAC", oscl_strlen("AAC")) || !oscl_strncmp(MIMEType, "MP4A-LATM", oscl_strlen("MP4A-LATM")))
-                    {
-                        aac_mediaInfo *pSourceAAC = (aac_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        //void *memory = alloc(sizeof(aac_mediaInfo) + pSourceAAC->getDecoderSpecificInfoSize());
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(aac_mediaInfo), alternateMedia);
-                        aac_mediaInfo *pAAC = OSCL_PLACEMENT_NEW(memory, aac_mediaInfo());
-                        //	unsigned char *decSpecificInfo = (unsigned char *)(memory) + sizeof(aac_mediaInfo);
-                        //	pAAC->setDecoderSpecificInfo(decSpecificInfo, pSourceAAC->getDecoderSpecificInfoSize());
-                        *pAAC = *pSourceAAC;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "AMR", oscl_strlen("AMR")))
-                    {
-                        amr_mediaInfo *pSourceAMR = (amr_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(amr_mediaInfo), alternateMedia);
-                        amr_mediaInfo *pAMR = OSCL_PLACEMENT_NEW(memory, amr_mediaInfo());
-                        *pAMR = *pSourceAMR;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "EVRC", oscl_strlen("EVRC")))
-                    {
-                        evrc_mediaInfo *pSourceEVRC = (evrc_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(evrc_mediaInfo), alternateMedia);
-                        evrc_mediaInfo *pEVRC = OSCL_PLACEMENT_NEW(memory, evrc_mediaInfo());
-                        *pEVRC = *pSourceEVRC;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "MP4V-ES", oscl_strlen("MP4V-ES")))
-                    {
-                        m4v_mediaInfo *pSourceM4V = (m4v_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-                        void *memory = alloc(sizeof(m4v_mediaInfo), alternateMedia);
-                        m4v_mediaInfo *pM4V = OSCL_PLACEMENT_NEW(memory, m4v_mediaInfo());
-                        *pM4V = *pSourceM4V;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "H263-1998", oscl_strlen("H263-1998")))
-                    {
-                        h263_mediaInfo *pSourceH263 = (h263_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(h263_mediaInfo), alternateMedia);
-                        h263_mediaInfo *pH263 = OSCL_PLACEMENT_NEW(memory, h263_mediaInfo());
-                        *pH263 = *pSourceH263;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "H263-2000", oscl_strlen("H263-2000")))
-                    {
-                        h263_mediaInfo *pSourceH263 = (h263_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(h263_mediaInfo), alternateMedia);
-                        h263_mediaInfo *pH263 = OSCL_PLACEMENT_NEW(memory, h263_mediaInfo());
-                        *pH263 = *pSourceH263;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "PVMP4V-ES", oscl_strlen("PVMP4V-ES")))
-                    {
-                        m4v_mediaInfo *pSourceM4V = (m4v_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(m4v_mediaInfo), alternateMedia);
-                        m4v_mediaInfo *pM4V = OSCL_PLACEMENT_NEW(memory, m4v_mediaInfo());
-                        (mediaInfo)*pM4V = (mediaInfo) * pSourceM4V;
-                        *pM4V = *pSourceM4V;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "mpeg4-generic", oscl_strlen("mpeg4-generic")))
-                    {
-                        rfc3640_mediaInfo *pSourceRFC3640 = (rfc3640_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(rfc3640_mediaInfo), alternateMedia);
-                        rfc3640_mediaInfo *pRFC3640 = OSCL_PLACEMENT_NEW(memory, rfc3640_mediaInfo());
-                        (mediaInfo)*pRFC3640 = (mediaInfo) * pSourceRFC3640;
-                        *pRFC3640 = *pSourceRFC3640;
-                    }
-                    else if (!oscl_strncmp(MIMEType, "X-MP4V-IMAGE", oscl_strlen("X-MP4V-IMAGE")))
-                    {
-                        still_image_mediaInfo *pSourceImage = (still_image_mediaInfo*)sourceSdpInfo.pMediaInfo[ii][ss];
-                        if (ss == 0)
-                            alternateMedia = false;
-                        else
-                            alternateMedia = true;
-
-                        void *memory = alloc(sizeof(still_image_mediaInfo), alternateMedia);
-                        still_image_mediaInfo *pImage = OSCL_PLACEMENT_NEW(memory, still_image_mediaInfo());
-                        *pImage = *pSourceImage;
-                    }
-
-                }
-            }
-        }
-
-        ~SDPInfo()
-        {
-            int ii = 0;
-            int ss = 0;
-            for (ii = 0; ii < numMediaObjects; ii++)
-            {
-                for (ss = 0; ss < (int)pMediaInfo[ii].size();ss++)
-                {
-                    pMediaInfo[ii][ss]->~mediaInfo();
-                    dealloc(pMediaInfo[ii][ss]);
-                }
-            }
-            numMediaObjects = 0;
-
-        }
-
-        sessionDescription *getSessionInfo()
-        {
-            return &session_info;
-        };
-        Oscl_Vector<mediaInfo *, SDPParserAlloc> getMediaInfo(int Object)
-        {
-            if ((Object >= 0) && (Object < MAX_MEDIA_OBJECTS))
-            {
-                return pMediaInfo[Object];
-            }
-            else
-            {
-                return 0;
-            }
-        };
-        Oscl_Vector<mediaInfo *, SDPParserAlloc> *getMediaArray()
-        {
-            return pMediaInfo;
-        };
-        int getNumMediaObjects()
-        {
-            return numMediaObjects;
-        };
-        inline void dealloc(void *ptr)
-        {
-            oscl_free(ptr);
-        };
-
-        mediaInfo* getMediaInfoBasedOnID(uint32 trackID)
-        {
-            int numObjects = getNumMediaObjects();
-
-            for (int i = 0; i < numObjects; i++)
-            {
-                Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec;
-                mediaInfoVec = getMediaInfo(i);
-
-                for (uint32 j = 0; j < mediaInfoVec.size(); j++)
-                {
-                    mediaInfo* minfo = mediaInfoVec[j];
-
-                    if (minfo != NULL)
-                    {
-                        if (minfo->getMediaInfoID() == trackID)
-                        {
-                            return minfo;
-                        }
-                    }
-                }
-            }
-            return NULL;
-        }
-
-        mediaInfo* getMediaInfoBasedOnDependsOnID(uint32 trackID)
-        {
-            if (trackID == 0)
-            {
-                return NULL;
-            }
-
-            int numObjects = getNumMediaObjects();
-
-            for (int i = 0; i < numObjects; i++)
-            {
-                Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec;
-                mediaInfoVec = getMediaInfo(i);
-
-                for (uint32 j = 0; j < mediaInfoVec.size(); j++)
-                {
-                    mediaInfo* minfo = mediaInfoVec[j];
-
-                    if (minfo != NULL)
-                    {
-                        if ((uint32)(minfo->getControlTrackID()) == trackID)
-                        {
-                            return minfo;
-                        }
-                    }
-                }
-            }
-            return NULL;
-        }
-
-
-        void *alloc(const int size, bool alternateMedia)
-        {
-            OSCL_UNUSED_ARG(alternateMedia);
-
-            if (numMediaObjects < MAX_MEDIA_OBJECTS)
-            {
-                void *mem = oscl_malloc(size * sizeof(char));
-                if (mem != NULL)
-                {
-                    iMediaObjectIndex++;
-                    pMediaInfo[numMediaObjects].push_back((mediaInfo *)mem);
-                }
-                return mem;
-            }
-            else
-            {
-                return NULL;
-            }
-        }
-
-        void IncrementAlternateMediaInfoVectorIndex()
-        {
-            pMediaInfo[numMediaObjects][0]->setSegmentNumber(segmentCount);
-            numMediaObjects++;
-        }
-
-        void copyFmDefMedia(mediaInfo *media)
-        {
-            *media = *pMediaInfo[numMediaObjects][0];
-        }
-
-        inline void reset()
-        {
-            session_info.resetSessionDescription();
-            int ii = 0;
-            int ss = 0;
-            for (ii = 0; ii < numMediaObjects; ii++)
-            {
-                for (ss = 0; ss < (int)pMediaInfo[ii].size(); ss++)
-                {
-                    pMediaInfo[ii][ss]->~mediaInfo();
-                    dealloc(pMediaInfo[ii][ss]);
-                }
-            }
-            numMediaObjects = 0;
-        }
-
-        inline uint32 getMediaObjectIndex()
-        {
-            return iMediaObjectIndex;
-        }
-
-        bool getMediaInfoInSegment(int segment, Oscl_Vector< mediaInfo *, SDPParserAlloc>& segmentMediaInfo)
-        {
-            if (segmentCount == 0)
-                return false;
-            for (int ii = 0; ii < numMediaObjects; ii++)
-            {
-                if (pMediaInfo[ii][0]->getSegmentNumber() == (uint)segment)
-                {
-                    segmentMediaInfo.push_back(pMediaInfo[ii][0]);
-                }
-            }
-            return true;
-        }
-
-        void setSegmentCount(int count)
-        {
-            segmentCount = count;
-        }
-
-        int getSegmentCount()
-        {
-            return segmentCount;
-        }
-
-        bool setSegmentActive(int segment, bool status)
-        {
-            if (segment <= segmentCount)
-            {
-                segmentInfo[segment].segmentActive = status;
-                return true;
-            }
-            else
-                return false;
-        }
-
-        bool isSegmentActive(int segment)
-        {
-            if (segment <= segmentCount)
-                return segmentInfo[segment].segmentActive;
-            else
-                return false;
-        }
-
-        bool setSegmentPayloadOrderPref(int segment, int* payloadArray, int len)
-        {
-            segmentInfo[segment].segmentPayloadOrderPref = false;
-            if (segment <= segmentCount)
-            {
-                Oscl_Vector< mediaInfo *, SDPParserAlloc> segmentMediaInfo;
-                if (getMediaInfoInSegment(segment, segmentMediaInfo) == true)
-                {
-                    for (int ii = 0; ii < len; ii++)
-                    {
-                        for (uint32 jj = 0; jj < segmentMediaInfo.size(); jj++)
-                        {
-                            if (segmentMediaInfo[jj]->getPayloadSpecificInfoVector()[0]->getPayloadNumber() == (uint32)payloadArray[ii])
-                            {
-                                segmentMediaInfo[jj]->setPayloadPreference(ii);
-                                break;
-                            }
-                        }
-                    }
-                }
-            }
-            else
-                return false;
-            segmentInfo[segment].segmentPayloadOrderPref = true;
-            return true;
-        }
-
-        bool isPayloadOrderPreferenceSet(int segment)
-        {
-            if (segment <= segmentCount)
-                return segmentInfo[segment].segmentPayloadOrderPref;
-            else
-                return false;
-        }
-
-        mediaInfo* getPreferedMediaInfo(int segment)
-        {
-            mediaInfo* media = NULL;
-            Oscl_Vector< mediaInfo *, SDPParserAlloc> segmentMediaInfo;
-            if (getMediaInfoInSegment(segment, segmentMediaInfo) == true)
-            {
-                for (uint32 jj = 0; jj < segmentMediaInfo.size(); jj++)
-                {
-                    if (segmentMediaInfo[jj]->isMatched() == true)
-                    {
-                        media = segmentMediaInfo[jj];
-                        break;
-                    }
-                }
-            }
-            return media;
-        }
-
-        int getPreferedPayloadNumber(int segment)
-        {
-            int payload = -1;
-            Oscl_Vector< mediaInfo *, SDPParserAlloc> segmentMediaInfo;
-            if (getMediaInfoInSegment(segment, segmentMediaInfo) == true)
-            {
-                for (uint32 jj = 0; jj < segmentMediaInfo.size(); jj++)
-                {
-                    if (segmentMediaInfo[jj]->isMatched() == true)
-                    {
-                        payload = segmentMediaInfo[jj]->getPayloadSpecificInfoVector()[0]->getPayloadNumber();
-                        break;
-                    }
-                }
-            }
-            return payload;
-        }
-
-        const oscl_wchar *getSdpFilename(uint32 &retsize)
-        {
-            retsize = SdpFilename.get_size();
-            return SdpFilename.get_cstr();
-        }
-
-        void setSDPFilename(OSCL_wString& aURL)
-        {
-            SdpFilename = aURL;
-        }
-
+        OSCL_IMPORT_REF
+        SDPInfo();
+        OSCL_IMPORT_REF
+        SDPInfo(const SDPInfo &sourceSdpInfo);
+        OSCL_IMPORT_REF
+        ~SDPInfo();
+        OSCL_IMPORT_REF
+        void freeLastMediaInfoObject(void);
+        OSCL_IMPORT_REF
+        sessionDescription *getSessionInfo();
+        OSCL_IMPORT_REF
+        Oscl_Vector<mediaInfo *, SDPParserAlloc> getMediaInfo(int Object);
+        OSCL_IMPORT_REF
+        Oscl_Vector<mediaInfo *, SDPParserAlloc> *getMediaArray();
+        OSCL_IMPORT_REF
+        int getNumMediaObjects();
+        OSCL_IMPORT_REF
+        void dealloc(void *ptr);
+        OSCL_IMPORT_REF
+        mediaInfo* getMediaInfoBasedOnID(uint32 trackID);
+        OSCL_IMPORT_REF
+        mediaInfo* getMediaInfoBasedOnDependsOnID(uint32 trackID);
+        OSCL_IMPORT_REF
+        void *alloc(const int size, bool alternateMedia);
+        OSCL_IMPORT_REF
+        void IncrementAlternateMediaInfoVectorIndex();
+        OSCL_IMPORT_REF
+        void copyFmDefMedia(mediaInfo *media);
+        OSCL_IMPORT_REF
+        void reset();
+        OSCL_IMPORT_REF
+        uint32 getMediaObjectIndex();
+        OSCL_IMPORT_REF
+        bool getMediaInfoInSegment(int segment, Oscl_Vector< mediaInfo *, SDPParserAlloc>& segmentMediaInfo);
+        OSCL_IMPORT_REF
+        void setSegmentCount(int count);
+        OSCL_IMPORT_REF
+        int getSegmentCount();
+        OSCL_IMPORT_REF
+        bool setSegmentActive(int segment, bool status);
+        OSCL_IMPORT_REF
+        bool isSegmentActive(int segment);
+        OSCL_IMPORT_REF
+        bool setSegmentPayloadOrderPref(int segment, int* payloadArray, int len);
+        OSCL_IMPORT_REF
+        bool isPayloadOrderPreferenceSet(int segment);
+        OSCL_IMPORT_REF
+        mediaInfo* getPreferedMediaInfo(int segment);
+        OSCL_IMPORT_REF
+        int getPreferedPayloadNumber(int segment);
+        OSCL_IMPORT_REF
+        const oscl_wchar *getSdpFilename(uint32 &retsize);
+        OSCL_IMPORT_REF
+        void setSDPFilename(OSCL_wString& aURL);
     private:
         sessionDescription session_info;
         Oscl_Vector< mediaInfo *, SDPParserAlloc> pMediaInfo[MAX_MEDIA_OBJECTS];
         int numMediaObjects;
-        registrar *reg;
-        bool registrar_locally_allocated;
         uint32 iMediaObjectIndex;
         int segmentCount;
         segmentSpecific segmentInfo[MAX_SEGMENTS];
diff --git a/protocols/sdp/common/include/sdp_info_comparison.h b/protocols/sdp/common/include/sdp_info_comparison.h
index 39e9a9a..96e78f8 100644
--- a/protocols/sdp/common/include/sdp_info_comparison.h
+++ b/protocols/sdp/common/include/sdp_info_comparison.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/sdp/common/include/sdp_memory.h b/protocols/sdp/common/include/sdp_memory.h
index a47afb9..ee417f4 100644
--- a/protocols/sdp/common/include/sdp_memory.h
+++ b/protocols/sdp/common/include/sdp_memory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*                                      */
-/*  ===================================================================== */
-/*  File: SDPMemory.h                           */
-/*  Description:                              */
-/*                                      */
-/*                                      */
-/*  Rev:                                  */
-/*  Created: 05/24/01                           */
-/*  ===================================================================== */
-/*                                      */
-/*  Revision History:                           */
-/*                                      */
-/*  Rev:                                  */
-/*  Date:                                 */
-/*  Description:                              */
-/*                                      */
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef SDP_MEMORY_H
 #define SDP_MEMORY_H
diff --git a/protocols/sdp/common/include/sdp_return_code.h b/protocols/sdp/common/include/sdp_return_code.h
index 32dd845..8d122db 100644
--- a/protocols/sdp/common/include/sdp_return_code.h
+++ b/protocols/sdp/common/include/sdp_return_code.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: SDPReturnCode.h													*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef SDP_RETURN_CODE_H
 #define SDP_RETURN_CODE_H
diff --git a/protocols/sdp/common/include/session_info.h b/protocols/sdp/common/include/session_info.h
index 1ad7cdd..d2fa142 100644
--- a/protocols/sdp/common/include/session_info.h
+++ b/protocols/sdp/common/include/session_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: sessionInfo.h														*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef SESSION_INFO_H
 #define SESSION_INFO_H
@@ -124,8 +107,6 @@
         VideoOnlyStatus videoOnlyAllowed;
         OSCL_HeapString<SDPParserAlloc> controlURL;
 
-        uint16 contentVersion;
-
         OSCL_HeapString<SDPParserAlloc> creationDate;
 
         OSCL_HeapString<SDPParserAlloc> eTag;
@@ -192,6 +173,7 @@
         {
             OSCL_DELETE(asfHeaderPtr);
             asfHeaderPtr = NULL;
+            assetInfo.CleanUp();
         };
 
         // added for RM
@@ -513,10 +495,6 @@
         {
             connectInfo.connectionAddress.set((const char*)(memFrag.ptr), memFrag.len);
         };
-        inline void setContentVersion(uint16 cVersion)
-        {
-            contentVersion = cVersion;
-        };
 
         inline void setCreationDate(char *cDate)
         {
@@ -746,39 +724,7 @@
 
         inline void setAssetInfo(const AssetInfoType &ainfo)
         {
-            if (ainfo.URL == NULL) {}
-            else
-                assetInfo.URL = ainfo.URL;
-
-            for (int ii = 0;ii < ASSET_NAME_SIZE; ii++)
-            {
-                if (ainfo.Box[ii] == NULL) {}
-                else
-                    assetInfo.Box[ii] = ainfo.Box[ii];
-            }
-
-            if (ainfo.oTitlePresent)
-                assetInfo.oTitlePresent = ainfo.oTitlePresent;
-            if (ainfo.oDescriptionPresent)
-                assetInfo.oDescriptionPresent = ainfo.oDescriptionPresent;
-            if (ainfo.oCopyRightPresent)
-                assetInfo.oCopyRightPresent = ainfo.oCopyRightPresent;
-            if (ainfo.oPerformerPresent)
-                assetInfo.oPerformerPresent = ainfo.oPerformerPresent;
-            if (ainfo.oAuthorPresent)
-                assetInfo.oAuthorPresent = ainfo.oAuthorPresent;
-            if (ainfo.oGenrePresent)
-                assetInfo.oGenrePresent  = ainfo.oGenrePresent;
-            if (ainfo.oRatingPresent)
-                assetInfo.oRatingPresent  = ainfo.oRatingPresent;
-            if (ainfo.oClassificationPresent)
-                assetInfo.oClassificationPresent = ainfo.oClassificationPresent;
-            if (ainfo.oKeyWordsPresent)
-                assetInfo.oKeyWordsPresent = ainfo.oKeyWordsPresent;
-            if (ainfo.oLocationPresent)
-                assetInfo.oLocationPresent = ainfo.oLocationPresent;
-            if (ainfo.oAssetExtensionPresent)
-                assetInfo.oAssetExtensionPresent = ainfo.oAssetExtensionPresent;
+            assetInfo = ainfo;
         };
 
         inline SDPAltGroupType getSDPAltGroupType()
@@ -1035,11 +981,7 @@
         {
             return creationDate.get_cstr();
         }
-        inline void getContentVersion(uint8 & major_version, uint8 & minor_version)
-        {
-            major_version = (uint8)((contentVersion & 0xff00) >> 8);
-            minor_version = (uint8)(contentVersion & 0x00ff);
-        }
+
 
 
         inline const char *getETag()
@@ -1176,7 +1118,7 @@
         }
         //End additions
 
-        //Additions for asf streaming, 12/27/02
+        //Additions for asf streaming
         inline void setAsfHeader(unsigned char* ASCPtr, int ASCLen)
         {
             asfHeaderPtr = ASCPtr;
@@ -1247,9 +1189,6 @@
             connectInfo.connectionNetworkType = "IP";
             connectInfo.connectionAddress = "0.0.0.0";
             connectInfo.connectionAddressType = "IP4";
-            contentVersion = 0;
-            //Commenting out the default value for the creation date.
-            //creationDate = "20000101T000000.000Z";
 
             //    securityFlag = 0;
             pauseDenied = false;
@@ -1257,7 +1196,6 @@
             randomFiller = NULL;
             digitalSignature = NULL;
             launchURL = NULL;
-            //Commenting out default value for endOfClip field.
             //Added new enum state.
             endOfClip = DO_NOTHING;
             appSpecificString = NULL;
@@ -1283,23 +1221,7 @@
             intKeyRightIssuerURI = NULL;
             sdpAuthTag = NULL;
 
-            assetInfo.URL = NULL;
-            int ii;
-            for (ii = 0;ii < ASSET_NAME_SIZE;ii++)
-            {
-                assetInfo.Box[ii] = NULL;
-            }
-            assetInfo.oTitlePresent = false;
-            assetInfo.oDescriptionPresent = false;
-            assetInfo.oCopyRightPresent = false;
-            assetInfo.oPerformerPresent = false;
-            assetInfo.oAuthorPresent = false;
-            assetInfo.oGenrePresent  = false;
-            assetInfo.oRatingPresent  = false;
-            assetInfo.oClassificationPresent = false;
-            assetInfo.oKeyWordsPresent = false;
-            assetInfo.oLocationPresent = false;
-            assetInfo.oAssetExtensionPresent = false;
+            assetInfo.ResetAssetInfoType();
 
             iSDPAltGroupType = SDP_ALT_GROUP_NONE;
             altGroupBW = NULL;
@@ -1353,12 +1275,6 @@
             setCAddressType(connection.connectionAddressType);
             setCAddress(connection.connectionAddress);
 
-            uint8 majorVersion, minorVersion;
-            ((sessionDescription)sourceSessionDescription).getContentVersion(majorVersion, minorVersion);
-            uint16 cVersion = (uint16) majorVersion;
-            cVersion <<= 8;
-            cVersion |= (uint16) minorVersion;
-            setContentVersion(cVersion);
             setCreationDate(((sessionDescription)sourceSessionDescription).getCreationDate());
             setRandomAccessDenied(((sessionDescription)sourceSessionDescription).getRandomAccessDenied());
             setETag(((sessionDescription)sourceSessionDescription).getETag());
@@ -1377,7 +1293,7 @@
             setRTCPSenderBitRate(((sessionDescription)sourceSessionDescription).getRTCPBWSender());
             setRTCPReceiverBitRate(((sessionDescription)sourceSessionDescription).getRTCPBWReceiver());
             setBWtias(((sessionDescription)sourceSessionDescription).getBWtias());
-            //Additions for asf streaming, 12/27/02
+            //Additions for asf streaming
             setAsfHeader(((sessionDescription)sourceSessionDescription).getAsfHeader(), ((sessionDescription)sourceSessionDescription).getAsfHeaderSize()) ;
             setAsfTrue(((sessionDescription)sourceSessionDescription).getAsfTrue());
 
@@ -1405,92 +1321,67 @@
 
         const sessionDescription &operator=(const sessionDescription & sourceSessionDescription)
         {
-            setProtocolVersion(((sessionDescription)sourceSessionDescription).getProtocolVersion());
-            setSessionName(((sessionDescription)sourceSessionDescription).getSessionName());
-            setSessionInformation(((sessionDescription)sourceSessionDescription).getSessionInformation());
-            setVersion(((sessionDescription)sourceSessionDescription).getVersion());
-            setAuthor(((sessionDescription)sourceSessionDescription).getAuthor());
-            setCopyright(((sessionDescription)sourceSessionDescription).getCopyright());
-            setRating(((sessionDescription)sourceSessionDescription).getRating());
-            uint64 start, stop;
-            ((sessionDescription)sourceSessionDescription).getStartStopTimes(&start, &stop);
-            setSessionStartTime(start);
-            setSessionStopTime(stop);
+            protocolVersion = sourceSessionDescription.protocolVersion;
+            sessionName = sourceSessionDescription.sessionName;
+            sessionInformation = sourceSessionDescription.sessionInformation;
+            version = sourceSessionDescription.version;
+            author = sourceSessionDescription.author;
+            copyright = sourceSessionDescription.copyright;
+            rating = sourceSessionDescription.rating;
+            sessionStartTime = sourceSessionDescription.sessionStartTime.get_value();
+            sessionStopTime = sourceSessionDescription.sessionStopTime.get_value();
 
-            setRepeatInterval(((sessionDescription)sourceSessionDescription).getSessionRepeatInterval());
-            setActiveDuration(((sessionDescription)sourceSessionDescription).getSessionActiveDuration());
-            setOffsetVector(((sessionDescription)sourceSessionDescription).getRepeatTimeOffsetVectors());
+            repeatInterval = sourceSessionDescription.repeatInterval;
+            activeDuration = sourceSessionDescription.activeDuration;
+            listOfOffsetsFromStartTime = sourceSessionDescription.listOfOffsetsFromStartTime;
 
-            setRange(*((sessionDescription)sourceSessionDescription).getRange());
-            setWmfVersion(((sessionDescription)sourceSessionDescription).getWmfVersion());
-            setAllowRecord(((sessionDescription)sourceSessionDescription).getAllowRecord());
-            setVideoOnlyAllowed(((sessionDescription)sourceSessionDescription).getVideoOnlyAllowed());
-            setControlURL(((sessionDescription)sourceSessionDescription).getControlURL());
-
-            originatorInfo originator;
-            ((sessionDescription)sourceSessionDescription).getOriginator(&originator);
-            setOUsername(originator.originatorUsername);
-            //Check the following 2 fields for validity
-            setOSessionID(originator.originatorSessionID);
-            setOVersion(originator.originatorVersion);
-            setONetworkType(originator.originatorNetworkType);
-            setOAddressType(originator.originatorAddressType);
-            setOAddress(originator.originatorAddress);
-
-            connectionInfo connection;
-            ((sessionDescription)sourceSessionDescription).getConnectionInformation(&connection);
-            setCNetworkType(connection.connectionNetworkType);
-            setCAddressType(connection.connectionAddressType);
-            setCAddress(connection.connectionAddress);
-
-            uint8 majorVersion, minorVersion;
-            ((sessionDescription)sourceSessionDescription).getContentVersion(majorVersion, minorVersion);
-            uint16 cVersion = (uint16) majorVersion;
-            cVersion <<= 8;
-            cVersion |= (uint16) minorVersion;
-            setContentVersion(cVersion);
-            setCreationDate(((sessionDescription)sourceSessionDescription).getCreationDate());
-            setRandomAccessDenied(((sessionDescription)sourceSessionDescription).getRandomAccessDenied());
-            setETag(((sessionDescription)sourceSessionDescription).getETag());
-            setRandomFiller(((sessionDescription)sourceSessionDescription).getRandomFiller());
-            setDigitalSignature(((sessionDescription)sourceSessionDescription).getDigitalSignature());
-            setLaunchURL(((sessionDescription)sourceSessionDescription).getLaunchURL());
-            setEndOfClipAction(((sessionDescription)sourceSessionDescription).getEndOfClipAction());
-            setAppSpecificString(((sessionDescription)sourceSessionDescription).getAppSpecificString());
-            setExpiryDate(((sessionDescription)sourceSessionDescription).getExpiryDate());
-            setPauseDenied(((sessionDescription)sourceSessionDescription).getPauseDenied());
-            setEmail(((sessionDescription)sourceSessionDescription).getEmail());
-            setPhoneNumber(((sessionDescription)sourceSessionDescription).getPhoneNumber());
-            setEncryptionKey(((sessionDescription)sourceSessionDescription).getEncryptionKey());
-
-            setBitrate(((sessionDescription)sourceSessionDescription).getBitRate());
-            setRTCPSenderBitRate(((sessionDescription)sourceSessionDescription).getRTCPBWSender());
-            setRTCPReceiverBitRate(((sessionDescription)sourceSessionDescription).getRTCPBWReceiver());
-            setBWtias(((sessionDescription)sourceSessionDescription).getBWtias());
-            //Additions for asf streaming, 12/27/02
-            setAsfHeader(((sessionDescription)sourceSessionDescription).getAsfHeader(), ((sessionDescription)sourceSessionDescription).getAsfHeaderSize()) ;
-            setAsfTrue(((sessionDescription)sourceSessionDescription).getAsfTrue());
-
-            setQoEMetrics(sourceSessionDescription.qoeMetrics);
-
-            setKeyMethod(sourceSessionDescription.intKeyMethod);
-
-            setKeyData(sourceSessionDescription.intKeyData);
-
-            setKeyContentIdURI(sourceSessionDescription.intKeyContentIdURI);
-
-            setKeyRightIssuerURI(sourceSessionDescription.intKeyRightIssuerURI);
-
-            setAssetInfo(((sessionDescription)sourceSessionDescription).getAssetInfo());
-
-            setSdpAuthTag(((sessionDescription)sourceSessionDescription).getSdpAuthTag());
-
-            setSDPAltGroupType(((sessionDescription)sourceSessionDescription).getSDPAltGroupType());
-            setAltGroupBW(((sessionDescription)sourceSessionDescription).getAltGroupBW());
-            setAltGroupLANG(((sessionDescription)sourceSessionDescription).getAltGroupLANG());
-
-            setCFieldStatus(((sessionDescription)sourceSessionDescription).getCFieldStatus());
-            setMaxprate(((sessionDescription)sourceSessionDescription).getMaxprate());
+            session_range = sourceSessionDescription.session_range;
+            wmfVersion = sourceSessionDescription.wmfVersion;
+            allowRecord = sourceSessionDescription.allowRecord;
+            videoOnlyAllowed = sourceSessionDescription.videoOnlyAllowed;
+            controlURL = sourceSessionDescription.controlURL;
+            origInfo.originatorUsername = sourceSessionDescription.origInfo.originatorUsername;
+            origInfo.originatorSessionID = sourceSessionDescription.origInfo.originatorSessionID;
+            origInfo.originatorVersion = sourceSessionDescription.origInfo.originatorVersion;
+            origInfo.originatorNetworkType = sourceSessionDescription.origInfo.originatorNetworkType;
+            origInfo.originatorAddressType = sourceSessionDescription.origInfo.originatorAddressType;
+            origInfo.originatorAddress = sourceSessionDescription.origInfo.originatorAddress;
+            connectInfo.connectionNetworkType = sourceSessionDescription.connectInfo.connectionNetworkType;
+            connectInfo.connectionAddressType = sourceSessionDescription.connectInfo.connectionAddressType;
+            connectInfo.connectionAddress = sourceSessionDescription.connectInfo.connectionAddress;
+            creationDate = sourceSessionDescription.creationDate;
+            randomAccessDenied = sourceSessionDescription.randomAccessDenied;
+            eTag = 	sourceSessionDescription.eTag;
+            randomFiller = sourceSessionDescription.randomFiller;
+            digitalSignature = sourceSessionDescription.digitalSignature;
+            launchURL = sourceSessionDescription.launchURL;
+            endOfClip = sourceSessionDescription.endOfClip;
+            appSpecificString = sourceSessionDescription.appSpecificString;
+            expiryDate = sourceSessionDescription.expiryDate;
+            pauseDenied = sourceSessionDescription.pauseDenied;
+            email = sourceSessionDescription.email;
+            phoneNumber = sourceSessionDescription.phoneNumber;
+            encryptionKey = sourceSessionDescription.encryptionKey;
+            bitrate = sourceSessionDescription.bitrate;
+            rtcpBWSender = 	sourceSessionDescription.rtcpBWSender;
+            rtcpBWReceiver = sourceSessionDescription.rtcpBWReceiver;
+            BWtias = sourceSessionDescription.BWtias;
+            asfHeaderPtr = sourceSessionDescription.asfHeaderPtr;
+            asfHeaderSize = sourceSessionDescription.asfHeaderSize;
+            asfTrue = sourceSessionDescription.asfTrue;
+            qoeMetrics = sourceSessionDescription.qoeMetrics;
+            Keywords = 	sourceSessionDescription.Keywords;
+            intKeyData = sourceSessionDescription.intKeyData;
+            intKeyContentIdURI = sourceSessionDescription.intKeyContentIdURI;
+            intKeyRightIssuerURI = sourceSessionDescription.intKeyRightIssuerURI;
+            assetInfo = sourceSessionDescription.assetInfo;
+            sdpAuthTag = sourceSessionDescription.sdpAuthTag;
+            iSDPAltGroupType = sourceSessionDescription.iSDPAltGroupType;
+            c_field_found = sourceSessionDescription.c_field_found;
+            maxprate = sourceSessionDescription.maxprate;
+            altGroupBW = sourceSessionDescription.altGroupBW;
+            altGroupLANG = sourceSessionDescription.altGroupLANG;
+            iSDPAltGroupType = sourceSessionDescription.iSDPAltGroupType;
             return *this;
         }
 
diff --git a/protocols/sdp/common/include/still_image_media_info.h b/protocols/sdp/common/include/still_image_media_info.h
index f22fb99..d975d1a 100644
--- a/protocols/sdp/common/include/still_image_media_info.h
+++ b/protocols/sdp/common/include/still_image_media_info.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: still_image_mediaInfo.h											*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef STILL_IMAGE_MEDIAINFO_H
 #define STILL_IMAGE_MEDIAINFO_H
diff --git a/protocols/sdp/parser/Android.mk b/protocols/sdp/parser/Android.mk
index 6c64829..d6799e9 100644
--- a/protocols/sdp/parser/Android.mk
+++ b/protocols/sdp/parser/Android.mk
@@ -2,54 +2,58 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/aacmediainfoparser.cpp\
-	src/amrmediainfoparser.cpp\
-	src/sdp_mediaparser_factory.cpp\
-	src/sdpparser.cpp\
-	src/basemediainfoparser.cpp\
-	src/sdp_parsing_utils.cpp\
-	src/evrcmediainfoparser.cpp\
-	src/sessioninfoparser.cpp\
-	src/h263mediainfoparser.cpp\
-	src/rfc3640mediainfoparser.cpp\
-	src/h264mediainfoparser.cpp\
-	src/still_imagemediainfoparser.cpp\
-	src/m4vmediainfoparser.cpp\
-	src/pcmamediainfoparser.cpp \
-	src/pcmumediainfoparser.cpp
-
+	src/aacmediainfoparser.cpp \
+ 	src/amrmediainfoparser.cpp \
+ 	src/sdp_mediaparser_factory.cpp \
+ 	src/sdpparser.cpp \
+ 	src/sdp_info.cpp \
+ 	src/basemediainfoparser.cpp \
+ 	src/sdp_parsing_utils.cpp \
+ 	src/sessioninfoparser.cpp \
+ 	src/h263mediainfoparser.cpp \
+ 	src/rfc3640mediainfoparser.cpp \
+ 	src/h264mediainfoparser.cpp \
+ 	src/still_imagemediainfoparser.cpp \
+ 	src/m4vmediainfoparser.cpp \
+ 	src/pcmamediainfoparser.cpp \
+ 	src/pcmumediainfoparser.cpp \
+ 	src/sdp_mediaparser_registry_populator.cpp
 
 
 LOCAL_MODULE := libpvsdpparser
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//protocols/sdp/parser/include \
-	$(PV_TOP)//protocols/sdp/parser/src \
-	$(PV_TOP)//protocols/sdp/parser/../common/include \
-	$(PV_TOP)//protocols/sdp/parser/../../../baselibs/gen_data_structures/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/protocols/sdp/parser/src \
+ 	$(PV_TOP)/protocols/sdp/parser/include \
+ 	$(PV_TOP)/protocols/sdp/common/include \
+ 	$(PV_TOP)/baselibs/gen_data_structures/src \
+ 	$(PV_TOP)/protocols/sdp/parser/config/opencore \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/aac_media_info_parser.h\
-	include/sdp_mediaparser_factory.h\
-	include/amr_media_info_parser.h\
-	include/sdp_mediaparser_registry.h\
-	include/asf_media_info_parser.h\
-	include/sdp_parser.h\
-	include/base_media_info_parser.h\
-	include/sdp_parsing_utils.h\
-	include/evrc_media_info_parser.h\
-	include/session_info_parser.h\
-	include/h263_media_info_parser.h\
-	include/rfc3640_media_info_parser.h\
-	include/h264_media_info_parser.h\
-	include/still_image_media_info_parser.h\
-	include/m4v_media_info_parser.h
+	include/aac_media_info_parser.h \
+ 	include/sdp_mediaparser_factory.h \
+ 	include/amr_media_info_parser.h \
+ 	include/sdp_mediaparser_registry.h \
+ 	include/sdp_parser.h \
+ 	include/base_media_info_parser.h \
+ 	include/sdp_parsing_utils.h \
+ 	include/session_info_parser.h \
+ 	include/h263_media_info_parser.h \
+ 	include/rfc3640_media_info_parser.h \
+ 	include/h264_media_info_parser.h \
+ 	include/still_image_media_info_parser.h \
+ 	include/m4v_media_info_parser.h \
+ 	include/sdp_mediaparser_registry_populator.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/protocols/sdp/parser/build/cml2/rules.cml b/protocols/sdp/parser/build/cml2/rules.cml
new file mode 100644
index 0000000..09979f9
--- /dev/null
+++ b/protocols/sdp/parser/build/cml2/rules.cml
@@ -0,0 +1,16 @@
+# sdpparser
+source "symbols.cml"
+
+menu sdpparser_plugins_menu	#sdpparser
+	sdp_default?
+	sdp_opencore?
+require sdp_default==y implies sdp_opencore==n 
+require sdp_opencore==y implies sdp_default==n 
+
+#Derive Parser configuration
+derive sdp_parser_mksegment_default from sdp_default==y or sdp_default==m			? "sdp_default.mk" : ""
+derive sdp_parser_mksegment_opencore from sdp_opencore==y or sdp_opencore==m			? "sdp_opencore.mk":""
+
+#Here, we combine the list of all the symbols for possible makefiles.
+derive pvsdpparser_plugins from sdp_parser_mksegment_default.sdp_parser_mksegment_opencore
+
diff --git a/protocols/sdp/parser/build/cml2/start.cml b/protocols/sdp/parser/build/cml2/start.cml
new file mode 100644
index 0000000..72572cc
--- /dev/null
+++ b/protocols/sdp/parser/build/cml2/start.cml
@@ -0,0 +1,2 @@
+start sdpparser_plugins_menu
+source "rules.cml"
diff --git a/protocols/sdp/parser/build/cml2/symbols.cml b/protocols/sdp/parser/build/cml2/symbols.cml
new file mode 100644
index 0000000..177ea41
--- /dev/null
+++ b/protocols/sdp/parser/build/cml2/symbols.cml
@@ -0,0 +1,4 @@
+symbols
+sdpparser_plugins_menu          'Menu for configuring SDPParser' 
+sdp_default				  'Default Configuration - Includes RealMedia Support'	
+sdp_opencore                    'Open Core Configuration' 
diff --git a/protocols/sdp/parser/build/make/local.mk b/protocols/sdp/parser/build/make/local.mk
new file mode 100644
index 0000000..7e93412
--- /dev/null
+++ b/protocols/sdp/parser/build/make/local.mk
@@ -0,0 +1,50 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvsdpparser
+
+
+
+
+XINCDIRS += ../../../common/include  ../../../../../baselibs/gen_data_structures/src
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := aacmediainfoparser.cpp\
+	amrmediainfoparser.cpp\
+	sdp_mediaparser_factory.cpp\
+	sdpparser.cpp\
+	sdp_info.cpp\
+	basemediainfoparser.cpp\
+	sdp_parsing_utils.cpp\
+	sessioninfoparser.cpp\
+	h263mediainfoparser.cpp\
+	rfc3640mediainfoparser.cpp\
+	h264mediainfoparser.cpp\
+	still_imagemediainfoparser.cpp\
+	m4vmediainfoparser.cpp\
+	pcmamediainfoparser.cpp\
+	pcmumediainfoparser.cpp
+
+HDRS := aac_media_info_parser.h\
+	sdp_mediaparser_factory.h\
+	amr_media_info_parser.h\
+	sdp_mediaparser_registry.h\
+	sdp_parser.h\
+	base_media_info_parser.h\
+	sdp_parsing_utils.h\
+	session_info_parser.h\
+	h263_media_info_parser.h\
+	rfc3640_media_info_parser.h\
+	h264_media_info_parser.h\
+	still_image_media_info_parser.h\
+	m4v_media_info_parser.h\
+	sdp_mediaparser_registry_populator.h
+
+include $(MK)/library.mk
diff --git a/protocols/sdp/parser/build/make/makefile b/protocols/sdp/parser/build/make/makefile
deleted file mode 100644
index 85c939c..0000000
--- a/protocols/sdp/parser/build/make/makefile
+++ /dev/null
@@ -1,86 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvsdpparser
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-XINCDIRS += -I../../../common/include -I ../../../../../baselibs/gen_data_structures/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = aacmediainfoparser.cpp\
-	amrmediainfoparser.cpp\
-	sdp_mediaparser_factory.cpp\
-	sdpparser.cpp\
-	basemediainfoparser.cpp\
-	sdp_parsing_utils.cpp\
-	evrcmediainfoparser.cpp\
-	sessioninfoparser.cpp\
-	h263mediainfoparser.cpp\
-	rfc3640mediainfoparser.cpp\
-	h264mediainfoparser.cpp\
-	still_imagemediainfoparser.cpp\
-	m4vmediainfoparser.cpp\
-	pcmamediainfoparser.cpp \
-	pcmumediainfoparser.cpp
-	
-
-HDRS = aac_media_info_parser.h\
-	sdp_mediaparser_factory.h\
-	amr_media_info_parser.h\
-	sdp_mediaparser_registry.h\
-	asf_media_info_parser.h\
-	sdp_parser.h\
-	base_media_info_parser.h\
-	sdp_parsing_utils.h\
-	evrc_media_info_parser.h\
-	session_info_parser.h\
-	h263_media_info_parser.h\
-	rfc3640_media_info_parser.h\
-	h264_media_info_parser.h\
-	still_image_media_info_parser.h\
-	m4v_media_info_parser.h
-	
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/protocols/sdp/parser/build/make/sdp_opencore.mk b/protocols/sdp/parser/build/make/sdp_opencore.mk
new file mode 100644
index 0000000..f7046c7
--- /dev/null
+++ b/protocols/sdp/parser/build/make/sdp_opencore.mk
@@ -0,0 +1,5 @@
+
+# Makefile segment for SDP-OPENCORE CONFIG
+#
+XINCDIRS += -I../../config/opencore
+SRCS += sdp_mediaparser_registry_populator.cpp 
diff --git a/protocols/sdp/parser/config/opencore/sdpparser_config.h b/protocols/sdp/parser/config/opencore/sdpparser_config.h
new file mode 100644
index 0000000..305d722
--- /dev/null
+++ b/protocols/sdp/parser/config/opencore/sdpparser_config.h
@@ -0,0 +1,27 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+// Tunables to signify if the support for real media is to be supported
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
+#ifndef SDPPARSER_CONFIG_H_INCLUDED
+#define SDPPARSER_CONFIG_H_INCLUDED
+
+#define	SDPPARSER_HAS_REAL_MEDIA_SUPPORT			0
+
+#endif // SDPPARSER_CONFIG_H_INCLUDED
diff --git a/protocols/sdp/parser/include/aac_media_info_parser.h b/protocols/sdp/parser/include/aac_media_info_parser.h
index c19f7e1..3bb7153 100644
--- a/protocols/sdp/parser/include/aac_media_info_parser.h
+++ b/protocols/sdp/parser/include/aac_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: aacMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef AAC_MEDIAINFO_PARSER_H
 #define AAC_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/amr_media_info_parser.h b/protocols/sdp/parser/include/amr_media_info_parser.h
index f1fd46d..18e9251 100644
--- a/protocols/sdp/parser/include/amr_media_info_parser.h
+++ b/protocols/sdp/parser/include/amr_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: amrMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef AMR_MEDIAINFO_PARSER_H
 #define AMR_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/asf_media_info_parser.h b/protocols/sdp/parser/include/asf_media_info_parser.h
deleted file mode 100644
index e98d80c..0000000
--- a/protocols/sdp/parser/include/asf_media_info_parser.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: asfMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 12/20/02														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
-
-#ifndef ASF_MEDIAINFO_PARSER_H
-#define ASF_MEDIAINFO_PARSER_H
-#include "base_media_info_parser.h"
-#include "asf_media_info.h"
-
-SDP_ERROR_CODE asfMediaInfoParser(const char *buff, const int index, SDPInfo *sdp);
-uint32		getTypeSpecificDataLength(HeaderObject  *_pHeaderObject, uint8 streamNumber);
-uint8*		getTypeSpecificData(HeaderObject  *_pHeaderObject, uint8 streamNumber) ;
-#endif //ASF_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/base_media_info_parser.h b/protocols/sdp/parser/include/base_media_info_parser.h
index 227d099..ae1a08d 100644
--- a/protocols/sdp/parser/include/base_media_info_parser.h
+++ b/protocols/sdp/parser/include/base_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: baseMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef BASE_MEDIAINFO_PARSER_H
 #define BASE_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/evrc_media_info_parser.h b/protocols/sdp/parser/include/evrc_media_info_parser.h
deleted file mode 100644
index 79deae2..0000000
--- a/protocols/sdp/parser/include/evrc_media_info_parser.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: evrcMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
-
-#ifndef EVRC_MEDIAINFO_PARSER_H
-#define EVRC_MEDIAINFO_PARSER_H
-#include "base_media_info_parser.h"
-#include "evrc_media_info.h"
-
-SDP_ERROR_CODE evrcMediaInfoParser(const char *, const int, SDPInfo *);
-
-class SDPEVRCMediaInfoParser : public SDPBaseMediaInfoParser
-{
-    public:
-        SDPEVRCMediaInfoParser() {};
-        virtual ~SDPEVRCMediaInfoParser() {};
-        SDP_ERROR_CODE parseMediaInfo(const char *buff, const int index, SDPInfo *sdp,
-                                      payloadVector payload_vec, bool isSipSdp, int alt_id = 0, bool alt_def_id = false);
-};
-
-#endif //EVRC_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/h263_media_info_parser.h b/protocols/sdp/parser/include/h263_media_info_parser.h
index b1f1356..82b26be 100644
--- a/protocols/sdp/parser/include/h263_media_info_parser.h
+++ b/protocols/sdp/parser/include/h263_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: h263MediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef H263_MEDIAINFO_PARSER_H
 #define H263_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/h264_media_info_parser.h b/protocols/sdp/parser/include/h264_media_info_parser.h
index 7d3c16c..45cf3ee 100644
--- a/protocols/sdp/parser/include/h264_media_info_parser.h
+++ b/protocols/sdp/parser/include/h264_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/sdp/parser/include/m4v_media_info_parser.h b/protocols/sdp/parser/include/m4v_media_info_parser.h
index 2f486aa..24487e2 100644
--- a/protocols/sdp/parser/include/m4v_media_info_parser.h
+++ b/protocols/sdp/parser/include/m4v_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: m4vMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef M4V_MEDIAINFO_PARSER_H
 #define M4V_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/pcma_media_info_parser.h b/protocols/sdp/parser/include/pcma_media_info_parser.h
index 363b1f3..919e011 100644
--- a/protocols/sdp/parser/include/pcma_media_info_parser.h
+++ b/protocols/sdp/parser/include/pcma_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: pcma_media_info_parser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 01/18/06														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef PCMA_MEDIAINFO_PARSER_H
 #define PCMA_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/pcmu_media_info_parser.h b/protocols/sdp/parser/include/pcmu_media_info_parser.h
index 5a15a62..ee7f11e 100644
--- a/protocols/sdp/parser/include/pcmu_media_info_parser.h
+++ b/protocols/sdp/parser/include/pcmu_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,7 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: pcmu_media_info_parser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 01/18/06														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
+
 
 #ifndef PCMU_MEDIAINFO_PARSER_H
 #define PCMU_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/rfc3640_media_info_parser.h b/protocols/sdp/parser/include/rfc3640_media_info_parser.h
index 9dd9be0..f91999e 100644
--- a/protocols/sdp/parser/include/rfc3640_media_info_parser.h
+++ b/protocols/sdp/parser/include/rfc3640_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/* //////////////////////////////////////////////////////////////////////// */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: m4vMediaInfoParser.h												*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created:04/26/07														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef RFC3640_MEDIAINFO_PARSER_H_INCLUDED
 #define RFC3640_MEDIAINFO_PARSER_H_INCLUDED
diff --git a/protocols/sdp/parser/include/rm_media_info_parser.h b/protocols/sdp/parser/include/rm_media_info_parser.h
new file mode 100644
index 0000000..b34c8a4
--- /dev/null
+++ b/protocols/sdp/parser/include/rm_media_info_parser.h
@@ -0,0 +1,37 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef RM_MEDIAINFO_PARSER_H
+#define RM_MEDIAINFO_PARSER_H
+#include "base_media_info_parser.h"
+#include "m4v_media_info.h"
+
+SDP_ERROR_CODE rmMediaInfoParser(const char *, const int , SDPInfo *);
+class SDPMediaParserFactory;
+class SDPRMMediaInfoParser : public SDPBaseMediaInfoParser
+{
+    public:
+        SDPRMMediaInfoParser() {};
+        virtual ~SDPRMMediaInfoParser() {};
+        SDP_ERROR_CODE parseMediaInfo(const char *buff, const int index, SDPInfo *sdp,
+                                      payloadVector payload_vec, bool isSipSdp, int alt_id = 0, bool alt_def_id = false);
+        SDP_ERROR_CODE parseRMLength(const char* sptr1, const char *end_ptr_str, NptTimeFormat& length);
+        const char *   parse_range_integer(const char *start, const char *end,
+                                           int max_digits, char *sep, uint32& value);
+};
+
+#endif //RM_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/sdp_mediaparser_factory.h b/protocols/sdp/parser/include/sdp_mediaparser_factory.h
index 610d363..8881fe1 100644
--- a/protocols/sdp/parser/include/sdp_mediaparser_factory.h
+++ b/protocols/sdp/parser/include/sdp_mediaparser_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,15 +29,6 @@
         virtual void destruct_and_dealloc(OsclAny* ptr);
 };
 
-class SDPEVRCMediaParserFactory : public SDPMediaParserFactory
-{
-    public:
-        virtual ~SDPEVRCMediaParserFactory() {}
-    private:
-        virtual SDPBaseMediaInfoParser* createSDPMediaParserInstance();
-        virtual void destruct_and_dealloc(OsclAny* ptr);
-};
-
 class SDPAACMediaParserFactory : public SDPMediaParserFactory
 {
     public:
@@ -47,15 +38,6 @@
         virtual void destruct_and_dealloc(OsclAny* ptr);
 };
 
-class SDPASFMediaParserFactory : public SDPMediaParserFactory
-{
-    public:
-        virtual ~SDPASFMediaParserFactory() {}
-    private:
-        virtual SDPBaseMediaInfoParser* createSDPMediaParserInstance();
-        virtual void destruct_and_dealloc(OsclAny* ptr);
-};
-
 class SDPH263MediaParserFactory : public SDPMediaParserFactory
 {
     public:
@@ -98,7 +80,6 @@
         virtual void destruct_and_dealloc(OsclAny* ptr);
 };
 
-
 class SDPPCMAMediaParserFactory : public SDPMediaParserFactory
 {
     public:
diff --git a/protocols/sdp/parser/include/sdp_mediaparser_registry.h b/protocols/sdp/parser/include/sdp_mediaparser_registry.h
index afb5d5f..0723943 100644
--- a/protocols/sdp/parser/include/sdp_mediaparser_registry.h
+++ b/protocols/sdp/parser/include/sdp_mediaparser_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/sdp/parser/include/sdp_mediaparser_registry_populator.h b/protocols/sdp/parser/include/sdp_mediaparser_registry_populator.h
new file mode 100644
index 0000000..7128b40
--- /dev/null
+++ b/protocols/sdp/parser/include/sdp_mediaparser_registry_populator.h
@@ -0,0 +1,27 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef SDP_MEDIA_PARSER_REGISTRY_POPULATOR
+#define SDP_MEDIA_PARSER_REGISTRY_POPULATOR
+#include "sdp_mediaparser_registry.h"
+class SDPMediaParserRegistryPopulater
+{
+    public:
+        static OSCL_IMPORT_REF SDPMediaParserRegistry* PopulateRegistry();
+        static OSCL_IMPORT_REF void CleanupRegistry(SDPMediaParserRegistry*& aMediaParserRegistry);
+};
+#endif
diff --git a/protocols/sdp/parser/include/sdp_parser.h b/protocols/sdp/parser/include/sdp_parser.h
index 7365410..25b184d 100644
--- a/protocols/sdp/parser/include/sdp_parser.h
+++ b/protocols/sdp/parser/include/sdp_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*									                                        */
-/*   =====================================================================  */
-/*	File: SDPParser.h						                                */
-/*	Description:							                                */
-/*									                                        */
-/*									                                        */
-/*	Rev:								                                    */
-/*	Created: 05/24/01						                                */
-/*   =====================================================================  */
-/*									                                        */
-/*	Revision History:						                                */
-/*									                                        */
-/*	Rev:								                                    */
-/*	Date:								                                    */
-/*	Description:							                                */
-/*									                                        */
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef SDP_PARSER_H
 #define SDP_PARSER_H
@@ -71,21 +54,15 @@
     mbchar movieName[MAX_STRING_LEN];
     mbchar creationDate[MAX_STRING_LEN];
     playTime duration;
-    uint8 majorVersion;
-    uint8 minorVersion;
 }movieInfo;
 
 class SDP_Parser
 {
     private:
         PVLogger* iLogger;
-        registrar *reg;
-        SDPMediaParserRegistry *_pSDPMediaParserRegistry;
+        SDPMediaParserRegistry *& _pSDPMediaParserRegistry;
         int mediaArrayIndex;
-        bool registrar_locally_allocated;
         SDP_ERROR_CODE(*sessionParser)(const char *sdp_text, int length, SDPInfo& sdp);	/*Used to parse session information*/
-        bool memflag;
-        bool localRegAllocation;
         bool applicationFlag;
 
         bool parse_rtpmap(const char *start, const char *end, int& rtp_payload,
@@ -96,27 +73,11 @@
 
         //  void print_memfrag(MemoryFragment& memfrag);
         int convertToMilliSec(RtspRangeType range , int &startTime, int &stopTime);
-
-        SDPAMRMediaParserFactory        *_pAMRMediaParserFactory;
-        SDPEVRCMediaParserFactory       *_pEVRCMediaParserFactory;
-        SDPAACMediaParserFactory        *_pAACMediaParserFactory;
-        SDPASFMediaParserFactory        *_pASFMediaParserFactory;
-        SDPH263MediaParserFactory       *_pH263MediaParserFactory;
-        SDPMPEG4MediaParserFactory      *_pMPEG4MediaParserFactory;
-        SDPRFC3640MediaParserFactory     *_pRFC3640MediaParserFactory;
-        SDPStillImageMediaParserFactory *_pStillImageMediaParserFactory;
-        SDPH264MediaParserFactory       *_pH264MediaParserFactory;
-        SDPPCMAMediaParserFactory       *_pPCMAMediaParserFactory;
-        SDPPCMUMediaParserFactory       *_pPCMUMediaParserFactory;
-
         bool isSipSdp;
     public:
 
         OSCL_IMPORT_REF
-        SDP_Parser(bool sipSdp = false);
-
-        OSCL_IMPORT_REF
-        SDP_Parser(SDPMediaParserRegistry *regTable, bool sipSdp = false);
+        SDP_Parser(SDPMediaParserRegistry*& regTable, bool sipSdp = false);
 
         OSCL_IMPORT_REF
         ~SDP_Parser();
@@ -135,5 +96,6 @@
 
         OSCL_IMPORT_REF
         bool allocateRegistrar();                       //Used to allocate new parser.
+
 };
 #endif
diff --git a/protocols/sdp/parser/include/sdp_parsing_utils.h b/protocols/sdp/parser/include/sdp_parsing_utils.h
index 07b22bf..1a0aac6 100644
--- a/protocols/sdp/parser/include/sdp_parsing_utils.h
+++ b/protocols/sdp/parser/include/sdp_parsing_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,12 @@
 bool sdp_decodebase64(uint8* aInBuf, uint32 aInBufLen,
                       uint8* aOutBuf, uint32& aOutBufLen, uint32 aMaxOutBufLen);
 
+void pvSDPParserGetAssetInfoLanguageCode(uint16 langcode, char* LangCode);
+
+bool pvSDPParserParse3GPPAssetInfoLocation(AssetInfoType& aInfo,
+        uint8* aBuf,
+        uint32 aBufSize);
+
 #endif
 
 
diff --git a/protocols/sdp/parser/include/session_info_parser.h b/protocols/sdp/parser/include/session_info_parser.h
index 665e809..bcb3aa5 100644
--- a/protocols/sdp/parser/include/session_info_parser.h
+++ b/protocols/sdp/parser/include/session_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: sessionMediaInfoParser.h											*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef SESSIONINFO_PARSER_H
 #define SESSIONINFO_PARSER_H
diff --git a/protocols/sdp/parser/include/still_image_media_info_parser.h b/protocols/sdp/parser/include/still_image_media_info_parser.h
index f027957..e4c1d9b 100644
--- a/protocols/sdp/parser/include/still_image_media_info_parser.h
+++ b/protocols/sdp/parser/include/still_image_media_info_parser.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			*/
-/*	=====================================================================	*/
-/*	File: still_imageMediaInfoParser.h										*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 05/24/01														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
 
 #ifndef STILL_IMAGE_MEDIAINFO_PARSER_H
 #define STILL_IMAGE_MEDIAINFO_PARSER_H
diff --git a/protocols/sdp/parser/src/aacmediainfoparser.cpp b/protocols/sdp/parser/src/aacmediainfoparser.cpp
index 9472079..0e32245 100644
--- a/protocols/sdp/parser/src/aacmediainfoparser.cpp
+++ b/protocols/sdp/parser/src/aacmediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,38 +15,18 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: aacMediaInfoParser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "aac_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* aacA,int index)			    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses AAC text and fills out the aac media structure		    */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
-SDPAACMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
+SDPAACMediaInfoParser::parseMediaInfo(const char *buff,
+                                      const int index,
+                                      SDPInfo *sdp,
+                                      payloadVector payload_vec,
+                                      bool isSipSdp,
+                                      int alt_id,
+                                      bool alt_def_id)
 {
     const char *current_start = buff; //Pointer to the beginning of the media text
     const char *end = buff + index;   //Pointer to the end of the media text
diff --git a/protocols/sdp/parser/src/amrmediainfoparser.cpp b/protocols/sdp/parser/src/amrmediainfoparser.cpp
index 6329942..99631ba 100644
--- a/protocols/sdp/parser/src/amrmediainfoparser.cpp
+++ b/protocols/sdp/parser/src/amrmediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,38 +15,18 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: amrMediaInfoParser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "amr_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* amrA,int index)			    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses AMR text and fills out the amr media structure		    */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
-SDPAMRMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
+SDPAMRMediaInfoParser::parseMediaInfo(const char *buff,
+                                      const int index,
+                                      SDPInfo *sdp,
+                                      payloadVector payload_vec,
+                                      bool isSipSdp,
+                                      int alt_id,
+                                      bool alt_def_id)
 {
 
     const char *current_start = buff; //Pointer to the beginning of the media text
@@ -237,6 +217,7 @@
                                 if (!oscl_strncmp(temp, "robust-sorting", oscl_strlen("robust-sorting")))
                                 {
 
+
                                     //We need to make sure that we do not read beyond valid memory
                                     if ((line_end_ptr - temp) >= (int)oscl_strlen("robust-sorting=0"))
                                     {
diff --git a/protocols/sdp/parser/src/basemediainfoparser.cpp b/protocols/sdp/parser/src/basemediainfoparser.cpp
index cd7641f..e59f58b 100644
--- a/protocols/sdp/parser/src/basemediainfoparser.cpp
+++ b/protocols/sdp/parser/src/basemediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,43 +15,34 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*                                                                          */
-/*  =====================================================================   */
-/*  File: baseMediaInfoParser.cpp                                           */
-/*  Description:                                                            */
-/*                                                                          */
-/*                                                                          */
-/*  Rev:                                                                    */
-/*  Created: 05/24/01                                                       */
-/*  =====================================================================   */
-/*                                                                          */
-/*  Revision History:                                                       */
-/*                                                                          */
-/*  Rev:                                                                    */
-/*  Date:                                                                   */
-/*  Description:                                                            */
-/*                                                                          */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "base_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 #include "rtsp_range_utils.h"
 
 
-/* ======================================================================== */
-/*  Function : parsePayload(char *buff, mediaInfo* mediaStr,int index)      */
-/*  Date     : 05/24/2001                                                   */
-/*  Purpose  : Parses generic media text and fills out the media structure  */
-/*  In/out   :                                                              */
-/*  Return   :                                                              */
-/*  Modified :                                                              */
-/* ======================================================================== */
-SDP_ERROR_CODE
-SDPBaseMediaInfoParser::baseMediaInfoParser(const char* buff, mediaInfo* mediaStr, const int index, const int alt_id, bool alt_def_id, bool isSipSdp)
+/* Function to allocate temporary buffer, OSCL_TRY() put here to avoid     */
+/* compiler warnings                                                       */
+static void newTmpBuf(uint32 len, char** buf)
+{
+    int32 err;
+    *buf = NULL;
 
-//SDP_ERROR_CODE baseMediaInfoParser::parsePayload(const char* buff, mediaInfo*
-//                                                 mediaStr,const int index)
+    OSCL_TRY(err, *buf = OSCL_ARRAY_NEW(char, len));
+
+    if (err != OsclErrNone)
+    {
+        *buf = NULL;
+    }
+}
+
+SDP_ERROR_CODE
+SDPBaseMediaInfoParser::baseMediaInfoParser(const char* buff,
+        mediaInfo* mediaStr,
+        const int index,
+        const int alt_id,
+        bool alt_def_id,
+        bool isSipSdp)
 {
     const char *current_start = buff; //Pointer to the beginning of the media text
     const char *end = buff + index;   //Pointer to the end of the media text
@@ -258,8 +249,10 @@
                             {
                                 if (payloadNumber == mediaStr->getPayloadSpecificInfoVector()[ii]->getPayloadNumber())
                                 {
-                                    if (payloadNumber >= FIRST_STATIC_PAYLOAD &&
-                                            payloadNumber <= LAST_STATIC_PAYLOAD)
+                                    // check if (FIRST_STATIC_PAYLOAD <= payloadNumber <= LAST_STATIC_PAYLOAD)
+                                    // since payloadNumber is unsigned and FIRST_STATIC_PAYLOAD == 0, only the upper
+                                    // boundary needs to be checked. Adding the lower boundary causes compiler warning.
+                                    if (payloadNumber <= LAST_STATIC_PAYLOAD)
                                         a_rtpmap_found = true;
                                 }
                             }
@@ -373,17 +366,18 @@
                         //For eg. earlier we have MIME type "AMR" and according to standard it should be
                         //like "audio/AMR". so tho whole logic implements the same.
                         uint32  tempBufLen = 0;
-                        int32 err = 0;
                         char *tmpBuf = NULL;
                         const char SDP_NULL[] = "\0";
 
                         tempBufLen = oscl_strlen(mediaStr->getType()) + (tmp_end_ptr - sptr1) + 2;
 
-                        OSCL_TRY(err, tmpBuf = OSCL_ARRAY_NEW(char, tempBufLen));
-                        if ((err != OsclErrNone) || (tmpBuf == NULL))
+                        // "OSCL_TRY(err, OSCL_ARRAY_NEW(char, tempBufLen)" is in separate function to avoid warnings
+                        newTmpBuf(tempBufLen, &tmpBuf);
+                        if (NULL == tmpBuf)
                         {
                             return SDP_NO_MEMORY;
                         }
+
                         oscl_strncpy(tmpBuf, mediaStr->getType(), (oscl_strlen(mediaStr->getType()) + 1));
                         oscl_strcat(tmpBuf, SDP_FWD_SLASH);
                         oscl_strncat(tmpBuf, sptr1, (tmp_end_ptr - sptr1));
@@ -500,24 +494,6 @@
                         }
                         parseRtspRange(sptr1, line_end_ptr - sptr1, *(mediaStr->getRtspRange()));
                     }
-                    if (!oscl_strncmp(line_start_ptr, "a=content_version:", oscl_strlen("a=content_version:")))
-                    {
-                        sptr1 = line_start_ptr + oscl_strlen("a=content_version:");
-                        sptr1 = skip_whitespace(sptr1, line_end_ptr);
-                        if (sptr1 >= line_end_ptr)
-                        {
-                            PVMF_SDP_PARSER_LOGERROR((0, "SDPBaseMediaInfoParser::parseMediaInfo - Bad a=content_version line format"));
-                            return SDP_BAD_MEDIA_FORMAT;
-                        }
-                        double cv;
-                        if (!PV_atof(sptr1, line_end_ptr - sptr1, (OsclFloat&)cv))
-                            return SDP_BAD_MEDIA_FORMAT;
-                        uint16 major_version, minor_version;
-                        major_version = (int16)cv;
-                        minor_version = (int16)((cv - (double)major_version) * 10.0);
-                        uint16 contentVers = (uint16)((major_version << 8) | minor_version);
-                        mediaStr->setContentVersion(contentVers);
-                    }
                     if (!oscl_strncmp(line_start_ptr, "a=depends_on:", oscl_strlen("a=depends_on:")))
                     {
                         sptr1 = line_start_ptr + oscl_strlen("a=depends_on:");
@@ -945,7 +921,6 @@
                     memFrag.len = (eptr - sptr);
                     mediaStr->setCNetworkType(memFrag);
 
-
                     // get the address type
                     sptr = skip_whitespace(eptr, line_end_ptr);
                     if (sptr >= line_end_ptr)
@@ -964,7 +939,6 @@
                     memFrag.len = (eptr - sptr);
                     mediaStr->setCAddressType(memFrag);
 
-
                     // get the address
                     sptr = skip_whitespace(eptr, line_end_ptr);
                     if (sptr >= line_end_ptr)
@@ -982,8 +956,8 @@
                     memFrag.ptr = (void*)sptr;
                     memFrag.len = (eptr - sptr);
                     mediaStr->setCAddress(memFrag);
-
-                    if (oscl_strstr(sptr, "IP4"))
+                    uint32 len = OSCL_MIN((uint32)(eptr - sptr), oscl_strlen("IP4"));
+                    if (oscl_strncmp(sptr, "IP4", len) == 0)
                     {
                         uint32 address;
                         const char *addrend = sptr;
@@ -1037,8 +1011,10 @@
                             return SDP_BAD_SESSION_FORMAT;
                         }
                     }
-                    else if (oscl_strstr(sptr, "IP6"))
-                    {//TBD
+                    //use "len" here since "IP4" and "IP6" have same lengths
+                    else if (oscl_strncmp(sptr, "IP6", len) == 0)
+                    {
+                        //TBD
                     }
                     break;
                 }
@@ -1084,7 +1060,7 @@
     /*
      * cannot assume that range is always going to be set at media level
      */
-    if (isSipSdp && (a_rtpmap_found) || (!alt_def_id && alt_id))
+    if ((isSipSdp && a_rtpmap_found) || (!alt_def_id && alt_id))
         return SDP_SUCCESS;
     else if ((a_rtpmap_found && a_control_found) || (!alt_def_id && alt_id) || (a_control_set))
         return SDP_SUCCESS;
diff --git a/protocols/sdp/parser/src/evrcmediainfoparser.cpp b/protocols/sdp/parser/src/evrcmediainfoparser.cpp
index 331c28f..ed7ec1c 100644
--- a/protocols/sdp/parser/src/evrcmediainfoparser.cpp
+++ b/protocols/sdp/parser/src/evrcmediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,36 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: evrcMediaInfoParser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "evrc_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* evrcA,int index)			    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses EVRC text and fills out the evrc media structure		  */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
 SDPEVRCMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
diff --git a/protocols/sdp/parser/src/h263mediainfoparser.cpp b/protocols/sdp/parser/src/h263mediainfoparser.cpp
index 0eb0dfb..8be40b1 100644
--- a/protocols/sdp/parser/src/h263mediainfoparser.cpp
+++ b/protocols/sdp/parser/src/h263mediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,36 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: h263MediaInfoParser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "h263_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* h263V,int index)			    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses H263 text and fills out the h263 media structure		  */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
 SDPH263MediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
diff --git a/protocols/sdp/parser/src/h264mediainfoparser.cpp b/protocols/sdp/parser/src/h264mediainfoparser.cpp
index a20fe40..3dd06bc 100644
--- a/protocols/sdp/parser/src/h264mediainfoparser.cpp
+++ b/protocols/sdp/parser/src/h264mediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/protocols/sdp/parser/src/m4vmediainfoparser.cpp b/protocols/sdp/parser/src/m4vmediainfoparser.cpp
index efa79c2..adcf524 100644
--- a/protocols/sdp/parser/src/m4vmediainfoparser.cpp
+++ b/protocols/sdp/parser/src/m4vmediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,36 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: m4vMediaInfoParser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "m4v_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* m4Video,int index)		    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses M4V text and fills out the m4v media structure		    */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
 SDPMPEG4MediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
diff --git a/protocols/sdp/parser/src/pcmamediainfoparser.cpp b/protocols/sdp/parser/src/pcmamediainfoparser.cpp
index ba90543..9b43544 100644
--- a/protocols/sdp/parser/src/pcmamediainfoparser.cpp
+++ b/protocols/sdp/parser/src/pcmamediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,35 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: pcmamediainfoparser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 01/18/06														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
 #include "pcma_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* pcmaA,int index)			    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses PCMA text and fills out the pcma media structure		    */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
 SDPPCMAMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
diff --git a/protocols/sdp/parser/src/pcmumediainfoparser.cpp b/protocols/sdp/parser/src/pcmumediainfoparser.cpp
index a13e200..e70e5e8 100644
--- a/protocols/sdp/parser/src/pcmumediainfoparser.cpp
+++ b/protocols/sdp/parser/src/pcmumediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,35 +15,10 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: pcmamediainfoparser.cpp											                      */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 01/18/06														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
 #include "pcmu_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 
-/* ======================================================================== */
-/*	Function : parsePayload(char *buff, mediaInfo* pcmuA,int index)			    */
-/*	Date     : 05/24/2001													                          */
-/*	Purpose  : Parses PCMA text and fills out the pcmu media structure		    */
-/*	In/out   :																                              */
-/*	Return   :																                              */
-/*	Modified :																                              */
-/* ======================================================================== */
 SDP_ERROR_CODE
 SDPPCMUMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
diff --git a/protocols/sdp/parser/src/rfc3640mediainfoparser.cpp b/protocols/sdp/parser/src/rfc3640mediainfoparser.cpp
index e99f873..788469e 100644
--- a/protocols/sdp/parser/src/rfc3640mediainfoparser.cpp
+++ b/protocols/sdp/parser/src/rfc3640mediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,37 +15,11 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/* //////////////////////////////////////////////////////////////////////// */
-/*	=====================================================================   */
-/*	File: rfc3640MediaInfoParser.cpp										*/
-/*	Description:															*/
-/*																			*/
-/*																			*/
-/*	Rev:																	*/
-/*	Created: 04/26/07														*/
-/*	=====================================================================	*/
-/*																			*/
-/*	Revision History:														*/
-/*																			*/
-/*	Rev:																	*/
-/*	Date:																	*/
-/*	Description:															*/
-/*																			*/
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "rfc3640_media_info_parser.h"
 #include "oscl_string_utils.h"
 #include "oscl_string_containers.h"
 #include "sdp_error.h"
 
-/* ======================================================================== */
-/*	Function : parseMediaInfo		                                        */
-/*	Date     : 04/26/2007													*/
-/*	Purpose  : Parses rfc3640 text and fills out the rfc3640 media structure*/
-/*	In/out   :																*/
-/*	Return   :																*/
-/*	Modified :																*/
-/* ======================================================================== */
 SDP_ERROR_CODE
 SDPRFC3640MediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
@@ -60,7 +34,7 @@
     bool indexDeltaLength_found_in_fmtp = false;
     SDPAllocDestructDealloc<uint8> SDP_alloc;
     int strmType = 5;
-    OsclMemoryFragment modeMemFrag;
+    OsclMemoryFragment modeMemFrag = {NULL, 0};
     int decLength = 0;
 
 
@@ -152,7 +126,6 @@
                         }
                         modeMemFrag.ptr = (void*)temp;
                         modeMemFrag.len = (tmp_end_line - temp);
-
                     }
 
                     if (tmp_end_line != line_end_ptr) temp = tmp_end_line + 1;
@@ -177,6 +150,12 @@
         return SDP_BAD_MEDIA_FORMAT;
     }
 
+    if (NULL == modeMemFrag.ptr)
+    {
+        PVMF_SDP_PARSER_LOGERROR((0, "SDPRFC3640MediaInfoParser::parseMediaInfo - Bad a=fmtp line format - No mode field"));
+        return SDP_BAD_MEDIA_FMTP;
+    }
+
     if (VOLLength < 0)
     {
         VOLLength = 0;
diff --git a/protocols/sdp/parser/src/sdp_info.cpp b/protocols/sdp/parser/src/sdp_info.cpp
new file mode 100644
index 0000000..15f5d04
--- /dev/null
+++ b/protocols/sdp/parser/src/sdp_info.cpp
@@ -0,0 +1,466 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef __SDP_INFO_H__
+#include "sdp_info.h"
+#endif
+
+#ifndef SDPPARSER_CONFIG_H_INCLUDED
+#include "sdpparser_config.h"
+#endif
+
+#ifndef SDPPARSER_HAS_REAL_MEDIA_SUPPORT
+#error "sdp config file missing"
+#endif
+
+#if SDPPARSER_HAS_REAL_MEDIA_SUPPORT
+#ifndef RM_MEDIAINFO_H
+#include "rm_media_info.h"
+#endif
+#endif
+
+
+OSCL_EXPORT_REF
+SDPInfo::SDPInfo()
+{
+    numMediaObjects = 0;
+    iMediaObjectIndex = 0;
+    segmentCount = 0;
+    for (int ii = 0; ii < MAX_SEGMENTS; ii++)
+    {
+        segmentInfo[ii].segmentActive = true;
+        segmentInfo[ii].segmentPayloadOrderPref = false;
+    }
+}
+
+OSCL_EXPORT_REF
+SDPInfo::SDPInfo(const SDPInfo &sourceSdpInfo)
+{
+    //expecting the = oper of sessionDescription to be overloaded
+    session_info = sourceSdpInfo.session_info;
+    SdpFilename = sourceSdpInfo.SdpFilename;
+    segmentCount = sourceSdpInfo.segmentCount;
+    iMediaObjectIndex = sourceSdpInfo.iMediaObjectIndex;
+    numMediaObjects = sourceSdpInfo.numMediaObjects;
+
+    for (int jj = 0; jj < MAX_SEGMENTS; jj++)
+    {
+        segmentInfo[jj] = sourceSdpInfo.segmentInfo[jj];
+    }
+
+    for (int ii = 0; ii < MAX_MEDIA_OBJECTS; ii++)
+    {
+        Oscl_Vector< mediaInfo *, SDPParserAlloc>& destMediaInfoVect = pMediaInfo[ii];
+        const Oscl_Vector< mediaInfo *, SDPParserAlloc>& srcMediaInfoVect = sourceSdpInfo.pMediaInfo[ii];
+        const int32 srcMediaInfoVectSz = srcMediaInfoVect.size();
+        for (int ss = 0; ss < srcMediaInfoVectSz; ss++)
+        {
+            mediaInfo* destMediaInfo = NULL;
+            const char *mimeType = srcMediaInfoVect[ss]->getMIMEType();
+            bool alternateMedia = (0 == ss) ? false : true;
+
+            if (!oscl_strncmp(mimeType, "AAC", oscl_strlen("AAC")) || !oscl_strncmp(mimeType, "MP4A-LATM", oscl_strlen("MP4A-LATM")))
+            {
+                aac_mediaInfo *pSourceAAC = OSCL_REINTERPRET_CAST(aac_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(aac_mediaInfo), alternateMedia);
+                aac_mediaInfo *pAAC = OSCL_PLACEMENT_NEW(memory, aac_mediaInfo());
+                *pAAC = *pSourceAAC;
+                destMediaInfo = pAAC;
+            }
+            else if (!oscl_strncmp(mimeType, "AMR", oscl_strlen("AMR")))
+            {
+                amr_mediaInfo *pSourceAMR = OSCL_REINTERPRET_CAST(amr_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(amr_mediaInfo), alternateMedia);
+                amr_mediaInfo *pAMR = OSCL_PLACEMENT_NEW(memory, amr_mediaInfo());
+                *pAMR = *pSourceAMR;
+                destMediaInfo = pAMR;
+            }
+            else if (!oscl_strncmp(mimeType, "MP4V-ES", oscl_strlen("MP4V-ES")))
+            {
+                m4v_mediaInfo *pSourceM4V = OSCL_REINTERPRET_CAST(m4v_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(m4v_mediaInfo), alternateMedia);
+                m4v_mediaInfo *pM4V = OSCL_PLACEMENT_NEW(memory, m4v_mediaInfo());
+                *pM4V = *pSourceM4V;
+                destMediaInfo = pM4V;
+            }
+            else if (!oscl_strncmp(mimeType, "H263-1998", oscl_strlen("H263-1998")) || !oscl_strncmp(mimeType, "H263-2000", oscl_strlen("H263-2000")))
+            {
+                h263_mediaInfo *pSourceH263 = OSCL_REINTERPRET_CAST(h263_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(h263_mediaInfo), alternateMedia);
+                h263_mediaInfo *pH263 = OSCL_PLACEMENT_NEW(memory, h263_mediaInfo());
+                *pH263 = *pSourceH263;
+                destMediaInfo = pH263;
+            }
+            else if (!oscl_strncmp(mimeType, "PVMP4V-ES", oscl_strlen("PVMP4V-ES")))
+            {
+                m4v_mediaInfo *pSourceM4V = OSCL_REINTERPRET_CAST(m4v_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(m4v_mediaInfo), alternateMedia);
+                m4v_mediaInfo *pM4V = OSCL_PLACEMENT_NEW(memory, m4v_mediaInfo());
+                *pM4V = *pSourceM4V;
+                destMediaInfo = pM4V;
+            }
+            else if (!oscl_strncmp(mimeType, "mpeg4-generic", oscl_strlen("mpeg4-generic")))
+            {
+                rfc3640_mediaInfo *pSourceRFC3640 = OSCL_REINTERPRET_CAST(rfc3640_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(rfc3640_mediaInfo), alternateMedia);
+                rfc3640_mediaInfo *pRFC3640 = OSCL_PLACEMENT_NEW(memory, rfc3640_mediaInfo());
+                *pRFC3640 = *pSourceRFC3640;
+                destMediaInfo = pRFC3640;
+            }
+            else if (!oscl_strncmp(mimeType, "X-MP4V-IMAGE", oscl_strlen("X-MP4V-IMAGE")))
+            {
+                still_image_mediaInfo *pSourceImage = OSCL_REINTERPRET_CAST(still_image_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(still_image_mediaInfo), alternateMedia);
+                still_image_mediaInfo *pImage = OSCL_PLACEMENT_NEW(memory, still_image_mediaInfo());
+                *pImage = *pSourceImage;
+                destMediaInfo = pImage;
+            }
+#if SDPPARSER_HAS_REAL_MEDIA_SUPPORT
+            else if (!oscl_strncmp(mimeType, "x-pn-realaudio", oscl_strlen("x-pn-realaudio")) || !oscl_strncmp(mimeType, "x-pn-realvideo", oscl_strlen("x-pn-realvideo")))
+            {
+                rm_mediaInfo *rmSource = OSCL_REINTERPRET_CAST(rm_mediaInfo*, srcMediaInfoVect[ss]);
+                void *memory = alloc(sizeof(rm_mediaInfo), alternateMedia);
+                rm_mediaInfo *prm = OSCL_PLACEMENT_NEW(memory, rm_mediaInfo());
+                *prm = *rmSource;
+                destMediaInfo = prm;
+            }
+#endif
+            if (destMediaInfo)
+                destMediaInfoVect.push_back(destMediaInfo);
+        }
+    }
+}
+
+
+OSCL_EXPORT_REF
+SDPInfo::~SDPInfo()
+{
+    int ii = 0;
+    int ss = 0;
+    for (ii = 0; ii < numMediaObjects; ii++)
+    {
+        for (ss = 0; ss < (int)pMediaInfo[ii].size();ss++)
+        {
+            pMediaInfo[ii][ss]->~mediaInfo();
+            dealloc(pMediaInfo[ii][ss]);
+        }
+    }
+    numMediaObjects = 0;
+
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::freeLastMediaInfoObject(void)
+{
+    if (numMediaObjects < 0)
+    {
+        return;
+    }
+
+    for (int ss = 0; ss < (int)pMediaInfo[numMediaObjects].size();ss++)
+    {
+        pMediaInfo[numMediaObjects][ss]->~mediaInfo();
+        dealloc(pMediaInfo[numMediaObjects][ss]);
+    }
+}
+
+OSCL_EXPORT_REF
+sessionDescription* SDPInfo::getSessionInfo()
+{
+    return &session_info;
+}
+
+OSCL_EXPORT_REF
+Oscl_Vector<mediaInfo *, SDPParserAlloc> SDPInfo::getMediaInfo(int Object)
+{
+    if ((Object >= 0) && (Object < MAX_MEDIA_OBJECTS))
+    {
+        return pMediaInfo[Object];
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+OSCL_EXPORT_REF
+Oscl_Vector<mediaInfo *, SDPParserAlloc> * SDPInfo::getMediaArray()
+{
+    return pMediaInfo;
+}
+
+OSCL_EXPORT_REF
+int SDPInfo::getNumMediaObjects()
+{
+    return numMediaObjects;
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::dealloc(void *ptr)
+{
+    oscl_free(ptr);
+}
+
+OSCL_EXPORT_REF
+mediaInfo* SDPInfo::getMediaInfoBasedOnID(uint32 trackID)
+{
+    int numObjects = getNumMediaObjects();
+
+    for (int i = 0; i < numObjects; i++)
+    {
+        Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec;
+        mediaInfoVec = getMediaInfo(i);
+
+        for (uint32 j = 0; j < mediaInfoVec.size(); j++)
+        {
+            mediaInfo* minfo = mediaInfoVec[j];
+
+            if (minfo != NULL)
+            {
+                if (minfo->getMediaInfoID() == trackID)
+                {
+                    return minfo;
+                }
+            }
+        }
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF
+mediaInfo* SDPInfo::getMediaInfoBasedOnDependsOnID(uint32 trackID)
+{
+    if (trackID == 0)
+    {
+        return NULL;
+    }
+
+    int numObjects = getNumMediaObjects();
+
+    for (int i = 0; i < numObjects; i++)
+    {
+        Oscl_Vector<mediaInfo*, SDPParserAlloc> mediaInfoVec;
+        mediaInfoVec = getMediaInfo(i);
+
+        for (uint32 j = 0; j < mediaInfoVec.size(); j++)
+        {
+            mediaInfo* minfo = mediaInfoVec[j];
+
+            if (minfo != NULL)
+            {
+                if ((uint32)(minfo->getControlTrackID()) == trackID)
+                {
+                    return minfo;
+                }
+            }
+        }
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF
+void * SDPInfo::alloc(const int size, bool alternateMedia)
+{
+    OSCL_UNUSED_ARG(alternateMedia);
+
+    if (numMediaObjects < MAX_MEDIA_OBJECTS)
+    {
+        void *mem = oscl_malloc(size * sizeof(char));
+        if (mem != NULL)
+        {
+            iMediaObjectIndex++;
+            pMediaInfo[numMediaObjects].push_back((mediaInfo *)mem);
+        }
+        return mem;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::IncrementAlternateMediaInfoVectorIndex()
+{
+    pMediaInfo[numMediaObjects][0]->setSegmentNumber(segmentCount);
+    numMediaObjects++;
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::copyFmDefMedia(mediaInfo *media)
+{
+    *media = *pMediaInfo[numMediaObjects][0];
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::reset()
+{
+    session_info.resetSessionDescription();
+    int ii = 0;
+    int ss = 0;
+    for (ii = 0; ii < numMediaObjects; ii++)
+    {
+        for (ss = 0; ss < (int)pMediaInfo[ii].size(); ss++)
+        {
+            pMediaInfo[ii][ss]->~mediaInfo();
+            dealloc(pMediaInfo[ii][ss]);
+        }
+    }
+    numMediaObjects = 0;
+}
+
+OSCL_EXPORT_REF
+uint32 SDPInfo::getMediaObjectIndex()
+{
+    return iMediaObjectIndex;
+}
+
+OSCL_EXPORT_REF
+bool SDPInfo::getMediaInfoInSegment(int segment, Oscl_Vector< mediaInfo *, SDPParserAlloc>& segmentMediaInfo)
+{
+    if (segmentCount == 0)
+        return false;
+    for (int ii = 0; ii < numMediaObjects; ii++)
+    {
+        if (pMediaInfo[ii][0]->getSegmentNumber() == (uint)segment)
+        {
+            segmentMediaInfo.push_back(pMediaInfo[ii][0]);
+        }
+    }
+    return true;
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::setSegmentCount(int count)
+{
+    segmentCount = count;
+}
+
+OSCL_EXPORT_REF
+int SDPInfo::getSegmentCount()
+{
+    return segmentCount;
+}
+
+OSCL_EXPORT_REF
+bool SDPInfo::setSegmentActive(int segment, bool status)
+{
+    if (segment <= segmentCount)
+    {
+        segmentInfo[segment].segmentActive = status;
+        return true;
+    }
+    else
+        return false;
+}
+
+OSCL_EXPORT_REF
+bool SDPInfo::isSegmentActive(int segment)
+{
+    if (segment <= segmentCount)
+        return segmentInfo[segment].segmentActive;
+    else
+        return false;
+}
+
+OSCL_EXPORT_REF
+bool SDPInfo::setSegmentPayloadOrderPref(int segment, int* payloadArray, int len)
+{
+    segmentInfo[segment].segmentPayloadOrderPref = false;
+    if (segment <= segmentCount)
+    {
+        Oscl_Vector< mediaInfo *, SDPParserAlloc> segmentMediaInfo;
+        if (getMediaInfoInSegment(segment, segmentMediaInfo) == true)
+        {
+            for (int ii = 0; ii < len; ii++)
+            {
+                for (uint32 jj = 0; jj < segmentMediaInfo.size(); jj++)
+                {
+                    if (segmentMediaInfo[jj]->getPayloadSpecificInfoVector()[0]->getPayloadNumber() == (uint32)payloadArray[ii])
+                    {
+                        segmentMediaInfo[jj]->setPayloadPreference(ii);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+    else
+        return false;
+    segmentInfo[segment].segmentPayloadOrderPref = true;
+    return true;
+}
+
+OSCL_EXPORT_REF
+bool SDPInfo::isPayloadOrderPreferenceSet(int segment)
+{
+    if (segment <= segmentCount)
+        return segmentInfo[segment].segmentPayloadOrderPref;
+    else
+        return false;
+}
+
+OSCL_EXPORT_REF
+mediaInfo* SDPInfo::getPreferedMediaInfo(int segment)
+{
+    mediaInfo* media = NULL;
+    Oscl_Vector< mediaInfo *, SDPParserAlloc> segmentMediaInfo;
+    if (getMediaInfoInSegment(segment, segmentMediaInfo) == true)
+    {
+        for (uint32 jj = 0; jj < segmentMediaInfo.size(); jj++)
+        {
+            if (segmentMediaInfo[jj]->isMatched() == true)
+            {
+                media = segmentMediaInfo[jj];
+                break;
+            }
+        }
+    }
+    return media;
+}
+
+OSCL_EXPORT_REF
+int SDPInfo::getPreferedPayloadNumber(int segment)
+{
+    int payload = -1;
+    Oscl_Vector< mediaInfo *, SDPParserAlloc> segmentMediaInfo;
+    if (getMediaInfoInSegment(segment, segmentMediaInfo) == true)
+    {
+        for (uint32 jj = 0; jj < segmentMediaInfo.size(); jj++)
+        {
+            if (segmentMediaInfo[jj]->isMatched() == true)
+            {
+                payload = segmentMediaInfo[jj]->getPayloadSpecificInfoVector()[0]->getPayloadNumber();
+                break;
+            }
+        }
+    }
+    return payload;
+}
+
+OSCL_EXPORT_REF
+const oscl_wchar * SDPInfo::getSdpFilename(uint32 &retsize)
+{
+    retsize = SdpFilename.get_size();
+    return SdpFilename.get_cstr();
+}
+
+OSCL_EXPORT_REF
+void SDPInfo::setSDPFilename(OSCL_wString& aURL)
+{
+    SdpFilename = aURL;
+}
diff --git a/protocols/sdp/parser/src/sdp_mediaparser_factory.cpp b/protocols/sdp/parser/src/sdp_mediaparser_factory.cpp
index 16b8d1d..7dc7b69 100644
--- a/protocols/sdp/parser/src/sdp_mediaparser_factory.cpp
+++ b/protocols/sdp/parser/src/sdp_mediaparser_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
 #include "sdp_mediaparser_factory.h"
 #include "aac_media_info_parser.h"
 #include "amr_media_info_parser.h"
-#include "evrc_media_info_parser.h"
 #include "h263_media_info_parser.h"
 #include "h264_media_info_parser.h"
 #include "m4v_media_info_parser.h"
@@ -41,19 +40,6 @@
 }
 
 SDPBaseMediaInfoParser*
-SDPEVRCMediaParserFactory::createSDPMediaParserInstance()
-{
-    SDPEVRCMediaInfoParser* parser = OSCL_NEW(SDPEVRCMediaInfoParser, ());
-    return (parser);
-}
-
-void
-SDPEVRCMediaParserFactory::destruct_and_dealloc(OsclAny* ptr)
-{
-    OSCL_UNUSED_ARG(ptr); // line added to remove warning "unreferenced formal parameter"
-}
-
-SDPBaseMediaInfoParser*
 SDPAACMediaParserFactory::createSDPMediaParserInstance()
 {
     SDPAACMediaInfoParser* parser = OSCL_NEW(SDPAACMediaInfoParser, ());
@@ -67,18 +53,6 @@
 }
 
 SDPBaseMediaInfoParser*
-SDPASFMediaParserFactory::createSDPMediaParserInstance()
-{
-    return NULL;
-}
-
-void
-SDPASFMediaParserFactory::destruct_and_dealloc(OsclAny* ptr)
-{
-    OSCL_UNUSED_ARG(ptr); // line added to remove warning "unreferenced formal parameter"
-}
-
-SDPBaseMediaInfoParser*
 SDPH263MediaParserFactory::createSDPMediaParserInstance()
 {
     SDPH263MediaInfoParser* parser = OSCL_NEW(SDPH263MediaInfoParser, ());
@@ -143,7 +117,6 @@
     OSCL_UNUSED_ARG(ptr); // line added to remove warning "unreferenced formal parameter"
 }
 
-
 SDPBaseMediaInfoParser*
 SDPPCMAMediaParserFactory::createSDPMediaParserInstance()
 {
diff --git a/protocols/sdp/parser/src/sdp_mediaparser_registry_populator.cpp b/protocols/sdp/parser/src/sdp_mediaparser_registry_populator.cpp
new file mode 100644
index 0000000..b234878
--- /dev/null
+++ b/protocols/sdp/parser/src/sdp_mediaparser_registry_populator.cpp
@@ -0,0 +1,136 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef SDP_MEDIA_PARSER_REGISTRY_FACTORY
+#include "sdp_mediaparser_registry_populator.h"
+#endif
+
+#ifndef SDP_MEDIAPARSER_FACTORY_H
+#include "sdp_mediaparser_factory.h"
+#endif
+
+SDPMediaParserRegistry* SDPMediaParserRegistryPopulater::PopulateRegistry()
+{
+    SDPMediaParserRegistry* sdpMediaParserRegistry = NULL;
+    StrPtrLen aac_latm("MP4A-LATM");
+    StrPtrLen aac("AAC");
+    StrPtrLen amr("AMR");
+    StrPtrLen amrwb("AMR-WB");
+    StrPtrLen h263_old("H263-1998");
+    StrPtrLen h263("H263-2000");
+    StrPtrLen m4v("MP4V-ES");
+    StrPtrLen author_m4v("PVMP4V-ES");
+    StrPtrLen still("X-MP4V-IMAGE");
+    StrPtrLen h264("H264");
+    StrPtrLen pcma("PCMA");
+    StrPtrLen pcmu("PCMU");
+    StrPtrLen rfc3640("mpeg4-generic");
+
+    SDPMediaParserRegistry::Init();
+
+    sdpMediaParserRegistry =
+        SDPMediaParserRegistry::GetSDPMediaParserRegistry();
+
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(aac_latm, OSCL_NEW(SDPAACMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(aac, OSCL_NEW(SDPAACMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(amr, OSCL_NEW(SDPAMRMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(amrwb, OSCL_NEW(SDPAMRMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(h263_old, OSCL_NEW(SDPH263MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(h263, OSCL_NEW(SDPH263MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(m4v, OSCL_NEW(SDPMPEG4MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(author_m4v, OSCL_NEW(SDPMPEG4MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(still, OSCL_NEW(SDPStillImageMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(h264, OSCL_NEW(SDPH264MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(pcma, OSCL_NEW(SDPPCMAMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(pcmu, OSCL_NEW(SDPPCMUMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(rfc3640, OSCL_NEW(SDPRFC3640MediaParserFactory, ()));
+
+    return sdpMediaParserRegistry;
+}
+
+void SDPMediaParserRegistryPopulater::CleanupRegistry(SDPMediaParserRegistry*& aMediaParserRegistry)
+{
+    StrPtrLen rfc3640("mpeg4-generic");
+    StrPtrLen pcmu("PCMU");
+    StrPtrLen pcma("PCMA");
+    StrPtrLen h264("H264");
+    StrPtrLen still("X-MP4V-IMAGE");
+    StrPtrLen author_m4v("PVMP4V-ES");
+    StrPtrLen m4v("MP4V-ES");
+    StrPtrLen h263("H263-2000");
+    StrPtrLen h263_old("H263-1998");
+    StrPtrLen amrwb("AMR-WB");
+    StrPtrLen amr("AMR");
+    StrPtrLen aac("AAC");
+    StrPtrLen aac_latm("MP4A-LATM");
+
+    OsclMemoryFragment memFrag;
+
+    memFrag.ptr = (OsclAny*)(rfc3640.c_str());
+    memFrag.len = (uint32)rfc3640.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(pcmu.c_str());
+    memFrag.len = (uint32)pcmu.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(pcma.c_str());
+    memFrag.len = (uint32)pcma.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h264.c_str());
+    memFrag.len = (uint32)h264.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(still.c_str());
+    memFrag.len = (uint32)still.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(author_m4v.c_str());
+    memFrag.len = (uint32)author_m4v.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(m4v.c_str());
+    memFrag.len = (uint32)m4v.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h263.c_str());
+    memFrag.len = (uint32)h263.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h263_old.c_str());
+    memFrag.len = (uint32)h263_old.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amrwb.c_str());
+    memFrag.len = (uint32)amrwb.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amr.c_str());
+    memFrag.len = (uint32)amr.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(aac.c_str());
+    memFrag.len = (uint32)aac.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(aac_latm.c_str());
+    memFrag.len = (uint32)aac_latm.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    SDPMediaParserRegistry::Cleanup();
+}
diff --git a/protocols/sdp/parser/src/sdp_mediaparser_registry_populator_pvaddon_incl.cpp b/protocols/sdp/parser/src/sdp_mediaparser_registry_populator_pvaddon_incl.cpp
new file mode 100644
index 0000000..269b1de
--- /dev/null
+++ b/protocols/sdp/parser/src/sdp_mediaparser_registry_populator_pvaddon_incl.cpp
@@ -0,0 +1,181 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef _SDP_MEDIA_PARSER_REGISTRY_FACTORY_
+#include "sdp_mediaparser_registry_populator.h"
+#endif
+
+#ifndef SDP_MEDIAPARSER_FACTORY_H
+#include "sdp_mediaparser_factory.h"
+#endif
+
+#ifndef RM_MEDIAINFO_PARSER_H
+#include "rm_media_info_parser.h"
+#endif
+
+class SDPRMMediaParserFactory : public SDPMediaParserFactory
+{
+    public:
+        virtual ~SDPRMMediaParserFactory() {}
+    private:
+        virtual SDPBaseMediaInfoParser* createSDPMediaParserInstance();
+        virtual void destruct_and_dealloc(OsclAny* ptr);
+};
+
+SDPBaseMediaInfoParser*
+SDPRMMediaParserFactory::createSDPMediaParserInstance()
+{
+    SDPRMMediaInfoParser* parser = OSCL_NEW(SDPRMMediaInfoParser, ());
+    return (parser);
+
+}
+
+void
+SDPRMMediaParserFactory::destruct_and_dealloc(OsclAny* ptr)
+{
+    OSCL_UNUSED_ARG(ptr); // line added to remove warning "unreferenced formal parameter"
+}
+
+OSCL_EXPORT_REF
+SDPMediaParserRegistry* SDPMediaParserRegistryPopulater::PopulateRegistry()
+{
+    SDPMediaParserRegistry* sdpMediaParserRegistry = NULL;
+    StrPtrLen aac_latm("MP4A-LATM");
+    StrPtrLen aac("AAC");
+    StrPtrLen amr("AMR");
+    StrPtrLen amrwb("AMR-WB");
+    StrPtrLen h263_old("H263-1998");
+    StrPtrLen h263("H263-2000");
+    StrPtrLen m4v("MP4V-ES");
+    StrPtrLen author_m4v("PVMP4V-ES");
+    StrPtrLen still("X-MP4V-IMAGE");
+    StrPtrLen h264("H264");
+    StrPtrLen rmA("x-pn-realaudio");
+    StrPtrLen rmV("x-pn-realvideo");
+    StrPtrLen pcma("PCMA");
+    StrPtrLen pcmu("PCMU");
+    StrPtrLen rfc3640("mpeg4-generic");
+
+    SDPMediaParserRegistry::Init();
+
+    sdpMediaParserRegistry =
+        SDPMediaParserRegistry::GetSDPMediaParserRegistry();
+
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(aac_latm, OSCL_NEW(SDPAACMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(aac, OSCL_NEW(SDPAACMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(amr, OSCL_NEW(SDPAMRMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(amrwb, OSCL_NEW(SDPAMRMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(h263_old, OSCL_NEW(SDPH263MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(h263, OSCL_NEW(SDPH263MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(m4v, OSCL_NEW(SDPMPEG4MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(author_m4v, OSCL_NEW(SDPMPEG4MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(still, OSCL_NEW(SDPStillImageMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(h264, OSCL_NEW(SDPH264MediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(rmA, OSCL_NEW(SDPRMMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(rmV, OSCL_NEW(SDPRMMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(pcma, OSCL_NEW(SDPPCMAMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(pcmu, OSCL_NEW(SDPPCMUMediaParserFactory, ()));
+    sdpMediaParserRegistry->addMediaParserFactoryToRegistry(rfc3640, OSCL_NEW(SDPRFC3640MediaParserFactory, ()));
+
+    return sdpMediaParserRegistry;
+}
+
+OSCL_EXPORT_REF
+void SDPMediaParserRegistryPopulater::CleanupRegistry(SDPMediaParserRegistry*& aMediaParserRegistry)
+{
+    StrPtrLen rfc3640("mpeg4-generic");
+    StrPtrLen pcmu("PCMU");
+    StrPtrLen pcma("PCMA");
+    StrPtrLen rmV("x-pn-realvideo");
+    StrPtrLen rmA("x-pn-realaudio");
+    StrPtrLen h264("H264");
+    StrPtrLen still("X-MP4V-IMAGE");
+    StrPtrLen author_m4v("PVMP4V-ES");
+    StrPtrLen m4v("MP4V-ES");
+    StrPtrLen h263("H263-2000");
+    StrPtrLen h263_old("H263-1998");
+    StrPtrLen amrwb("AMR-WB");
+    StrPtrLen amr("AMR");
+    StrPtrLen aac("AAC");
+    StrPtrLen aac_latm("MP4A-LATM");
+
+    OsclMemoryFragment memFrag;
+
+    memFrag.ptr = (OsclAny*)(rfc3640.c_str());
+    memFrag.len = (uint32)rfc3640.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(pcmu.c_str());
+    memFrag.len = (uint32)pcmu.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(pcma.c_str());
+    memFrag.len = (uint32)pcma.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(rmV.c_str());
+    memFrag.len = (uint32)rmV.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(rmA.c_str());
+    memFrag.len = (uint32)rmA.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h264.c_str());
+    memFrag.len = (uint32)h264.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(still.c_str());
+    memFrag.len = (uint32)still.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(author_m4v.c_str());
+    memFrag.len = (uint32)author_m4v.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(m4v.c_str());
+    memFrag.len = (uint32)m4v.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h263.c_str());
+    memFrag.len = (uint32)h263.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(h263_old.c_str());
+    memFrag.len = (uint32)h263_old.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amrwb.c_str());
+    memFrag.len = (uint32)amrwb.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(amr.c_str());
+    memFrag.len = (uint32)amr.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(aac.c_str());
+    memFrag.len = (uint32)aac.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    memFrag.ptr = (OsclAny*)(aac_latm.c_str());
+    memFrag.len = (uint32)aac_latm.size();
+    OSCL_DELETE(aMediaParserRegistry->lookupSDPMediaParserFactory(memFrag));
+
+    SDPMediaParserRegistry::Cleanup();
+}
+
+
diff --git a/protocols/sdp/parser/src/sdp_parsing_utils.cpp b/protocols/sdp/parser/src/sdp_parsing_utils.cpp
index de1300e..b564275 100644
--- a/protocols/sdp/parser/src/sdp_parsing_utils.cpp
+++ b/protocols/sdp/parser/src/sdp_parsing_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,17 @@
 #include "rtsp_range_utils.h"
 #include "oscl_str_ptr_len.h"
 #include "oscl_stdstring.h"
+#include "sdp_parsing_utils.h"
+#include "oscl_utf8conv.h"
+#include "oscl_snprintf.h"
+#include "oscl_bin_stream.h"
+
+#define BYTE_ORDER_MASK 0xFEFF
+static const char PVSDPMETADATA_LANG_CODE[] = ";iso-639-2-lang=";
+static const char PVSDPMETADATA_RATING_ENTITY[] = ";rating-entity=";
+static const char PVSDPMETADATA_RATING_CRITERIA[] = ";rating-criteria=";
+static const char PVSDPMETADATA_CLASSIFICATION_ENTITY[] = ";classification-entity=";
+static const char PVSDPMETADATA_CLASSFICATION_TABLE[] = ";classification-table=";
 
 bool get_next_line(const char *start_ptr, const char * end_ptr,
                    const char *& line_start,
@@ -38,6 +49,98 @@
 
 }
 
+bool sdp_decodebase64(uint8* aInBuf, uint32 aInBufLen,
+                      uint8* aOutBuf, uint32& aOutBufLen, uint32 aMaxOutBufLen)
+{
+    oscl_memset(aOutBuf, 0, aMaxOutBufLen);
+    aOutBufLen = 0;
+
+    int i;
+    uint8 dtable[256];
+
+    for (i = 0;i < 255;i++)
+    {
+        dtable[i] = 0x80;
+    }
+    for (i = 'A';i <= 'I';i++)
+    {
+        dtable[i] = 0 + (i - 'A');
+    }
+    for (i = 'J';i <= 'R';i++)
+    {
+        dtable[i] = 9 + (i - 'J');
+    }
+    for (i = 'S';i <= 'Z';i++)
+    {
+        dtable[i] = 18 + (i - 'S');
+    }
+    for (i = 'a';i <= 'i';i++)
+    {
+        dtable[i] = 26 + (i - 'a');
+    }
+    for (i = 'j';i <= 'r';i++)
+    {
+        dtable[i] = 35 + (i - 'j');
+    }
+    for (i = 's';i <= 'z';i++)
+    {
+        dtable[i] = 44 + (i - 's');
+    }
+    for (i = '0';i <= '9';i++)
+    {
+        dtable[i] = 52 + (i - '0');
+    }
+    dtable[(int)'+'] = 62;
+    dtable[(int)'/'] = 63;
+    dtable[(int)'='] = 0;
+
+    uint32 read_count = 0;
+    uint32 write_count = 0;
+    while (read_count < aInBufLen)
+    {
+        uint8 a[4], b[4], o[3];
+
+        for (i = 0;i < 4;i++)
+        {
+            uint8 c = *(aInBuf++);
+            read_count++;
+
+            if (read_count > aInBufLen)
+            {
+                //Input incomplete
+                return false;
+            }
+            if (dtable[(int)c]&0x80)
+            {
+                //Illegal character in
+                //return false;
+                i--;
+                continue;
+            }
+            a[i] = (uint8)c;
+            b[i] = (uint8)dtable[(int)c];
+        }
+        o[0] = (b[0] << 2) | (b[1] >> 4);
+        o[1] = (b[1] << 4) | (b[2] >> 2);
+        o[2] = (b[2] << 6) | b[3];
+        i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
+        oscl_memcpy(aOutBuf, o, i);
+        aOutBuf += i;
+        write_count += i;
+        if (write_count > aMaxOutBufLen)
+        {
+            return false;
+        }
+        if (i < 3)
+        {
+            break;
+        }
+    }
+    aOutBufLen = write_count;
+    return true;
+}
+
+
 bool parseQoEMetrics(const char *start_ptr, const char *end_ptr, QoEMetricsType &qoeMetrics)
 {
     const char *sptr = start_ptr;
@@ -195,13 +298,13 @@
         }
         else
         {
-            if (NULL != oscl_strstr(sptr, "."))	//if floating point number
+            uint32 len = OSCL_MIN((uint32)(eptr - sptr), oscl_strlen("."));
+            if (oscl_strncmp(sptr, ".", len) == 0)	//if floating point number
             {
                 if (!PV_atof(sptr, (int)(eptr - sptr), qoeMetrics.paramExtFdigit))
                     return false;
                 qoeMetrics.paramFmt = QoEMetricsType::FDIGIT;
             }
-
             else	    		// hex digit
             {
                 uint32 temp;
@@ -224,6 +327,165 @@
 
 }
 
+void pvSDPParserGetAssetInfoLanguageCode(uint16 langcode, char* LangCode)
+{
+    //ISO-639-2/T 3-char Lang Code
+    oscl_memset(LangCode, 0, 4);
+    LangCode[0] = 0x60 + ((langcode >> 10) & 0x1F);
+    LangCode[1] = 0x60 + ((langcode >> 5) & 0x1F);
+    LangCode[2] = 0x60 + ((langcode) & 0x1F);
+}
+
+bool pvSDPParserParse3GPPAssetInfoLocation(AssetInfoType& ainfo,
+        uint8* aBuf,
+        uint32 aBufSize)
+{
+    uint32 count = 0;
+    uint16 lang = *aBuf++;
+    lang = ((lang << 8) | (*aBuf++));
+    count += 2;
+    uint16 byteOrderMask = 0;
+    byteOrderMask = *aBuf;
+    byteOrderMask =
+        ((byteOrderMask << 8) | (*(aBuf + 1)));
+    if (byteOrderMask == BYTE_ORDER_MASK)
+    {
+        aBuf += 2;
+        uint32 index = 0;
+        uint8 firstbyte = aBuf[index];
+        uint8 secondbyte = aBuf[index++];
+        oscl_wchar wc = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+        bool nextChar = (wc == 0) ? false : true;
+        while (nextChar && (index < aBufSize))
+        {
+            firstbyte = aBuf[index];
+            secondbyte = aBuf[index++];
+            wc = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+            nextChar = (wc == 0) ? false : true;
+        }
+        ainfo.iLocationStruct._location_name =
+            (oscl_wchar*)(oscl_malloc(sizeof(oscl_wchar) * (index + 1)));
+        if (ainfo.iLocationStruct._location_name == NULL) return false;
+        oscl_memcpy(ainfo.iLocationStruct._location_name, aBuf, (index*2));
+    }
+    else
+    {
+        uint32 index = 0;
+        bool nextChar = (aBuf[index] == 0) ? false : true;
+        while (nextChar && (index < aBufSize))
+        {
+            index++;
+            nextChar = (aBuf[index] == 0) ? false : true;
+        }
+        oscl_wchar* unicodeBuf = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (index + 1));
+        if (unicodeBuf == NULL) return false;
+        oscl_UTF8ToUnicode((char*)aBuf,
+                           index,
+                           unicodeBuf,
+                           index + 1);
+        ainfo.iLocationStruct._location_name = unicodeBuf;
+    }
+    ainfo.iLocationStruct._role = *aBuf++;
+    uint32 i;
+    ainfo.iLocationStruct._longitude = 0;
+    for (i = 0; i < 4; i++)
+    {
+        ainfo.iLocationStruct._longitude |= *aBuf++;
+    }
+    ainfo.iLocationStruct._latitude = 0;
+    for (i = 0; i < 4; i++)
+    {
+        ainfo.iLocationStruct._latitude |= *aBuf++;
+    }
+    ainfo.iLocationStruct._altitude = 0;
+    for (i = 0; i < 4; i++)
+    {
+        ainfo.iLocationStruct._altitude |= *aBuf++;
+    }
+    byteOrderMask = *aBuf;
+    byteOrderMask =
+        ((byteOrderMask << 8) | (*(aBuf + 1)));
+    if (byteOrderMask == BYTE_ORDER_MASK)
+    {
+        aBuf += 2;
+        uint32 index = 0;
+        uint8 firstbyte = aBuf[index];
+        uint8 secondbyte = aBuf[index++];
+        oscl_wchar wc = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+        bool nextChar = (wc == 0) ? false : true;
+        while (nextChar && (index < aBufSize))
+        {
+            firstbyte = aBuf[index];
+            secondbyte = aBuf[index++];
+            wc = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+            nextChar = (wc == 0) ? false : true;
+        }
+        ainfo.iLocationStruct._astronomical_body =
+            (oscl_wchar*)(oscl_malloc(sizeof(oscl_wchar) * (index + 1)));
+        if (ainfo.iLocationStruct._astronomical_body == NULL) return false;
+        oscl_memcpy(ainfo.iLocationStruct._astronomical_body, aBuf, (index*2));
+    }
+    else
+    {
+        uint32 index = 0;
+        bool nextChar = (aBuf[index] == 0) ? false : true;
+        while (nextChar && (index < aBufSize))
+        {
+            index++;
+            nextChar = (aBuf[index] == 0) ? false : true;
+        }
+        oscl_wchar* unicodeBuf = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (index + 1));
+        if (unicodeBuf == NULL) return false;
+        oscl_UTF8ToUnicode((char*)aBuf,
+                           index,
+                           unicodeBuf,
+                           index + 1);
+        ainfo.iLocationStruct._astronomical_body = unicodeBuf;
+    }
+    byteOrderMask = *aBuf;
+    byteOrderMask =
+        ((byteOrderMask << 8) | (*(aBuf + 1)));
+    if (byteOrderMask == BYTE_ORDER_MASK)
+    {
+        aBuf += 2;
+        uint32 index = 0;
+        uint8 firstbyte = aBuf[index];
+        uint8 secondbyte = aBuf[index++];
+        oscl_wchar wc = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+        bool nextChar = (wc == 0) ? false : true;
+        while (nextChar && (index < aBufSize))
+        {
+            firstbyte = aBuf[index];
+            secondbyte = aBuf[index++];
+            wc = (uint16)(firstbyte << 8 | (uint16) secondbyte);
+            nextChar = (wc == 0) ? false : true;
+        }
+        ainfo.iLocationStruct._additional_notes =
+            (oscl_wchar*)(oscl_malloc(sizeof(oscl_wchar) * index));
+        if (ainfo.iLocationStruct._additional_notes == NULL) return false;
+        oscl_memcpy(ainfo.iLocationStruct._additional_notes, aBuf, (index*2));
+    }
+    else
+    {
+        uint32 index = 0;
+        bool nextChar = (aBuf[index] == 0) ? false : true;
+        while (nextChar && (index < aBufSize))
+        {
+            index++;
+            nextChar = (aBuf[index] == 0) ? false : true;
+        }
+        oscl_wchar* unicodeBuf = (oscl_wchar*)oscl_malloc(sizeof(oscl_wchar) * (index + 1));
+        if (unicodeBuf == NULL) return false;
+        oscl_UTF8ToUnicode((char*)aBuf,
+                           index,
+                           unicodeBuf,
+                           index + 1);
+        ainfo.iLocationStruct._additional_notes = unicodeBuf;
+    }
+    return true;
+}
+
+
 bool parseAssetInfo(const char *sptr, const char *line_end_ptr, AssetInfoType &ainfo)
 {
     const char *eptr = sptr;
@@ -232,98 +494,116 @@
     while (eptr < line_end_ptr)
     {
         sptr = skip_whitespace(sptr, line_end_ptr);
-        if (oscl_strncmp(sptr, "{", 1))
+        if (oscl_CIstrncmp(sptr, "{", 1))
             return false;
         sptr = sptr + 1;
         sptr = skip_whitespace(sptr, line_end_ptr);
         if (sptr > line_end_ptr)
             return false;
 
-        if (!oscl_strncmp(sptr, "url=", oscl_strlen("url=")))
+        if (!oscl_CIstrncmp(sptr, "url=", oscl_strlen("url=")))
         {
             sptr = sptr + oscl_strlen("url=");
             sptr = skip_whitespace(sptr, line_end_ptr);
             if (sptr > line_end_ptr)
                 return false;
+            if (!oscl_CIstrncmp(sptr, "\"", 1))
+            {
+                sptr = sptr + 1;
+                sptr = skip_whitespace(sptr, line_end_ptr);
+                if (sptr > line_end_ptr)
+                    return false;
+                eptr = sptr;
 
-            if (oscl_strncmp(sptr, "\"", 1))
-                return false;
-            sptr = sptr + 1;
-            sptr = skip_whitespace(sptr, line_end_ptr);
-            if (sptr > line_end_ptr)
-                return false;
-            eptr = sptr;
+                for (; *eptr != '"'; ++eptr);
 
-            for (; *eptr != '"'; ++eptr);
+                ainfo.URL.set((const char *)sptr, (eptr - sptr));
+            }
+            else
+            {
+                eptr = sptr;
 
-            ainfo.URL.set((const char *)sptr, (eptr - sptr));
+                for (; *eptr != '}'; ++eptr);
 
+                ainfo.URL.set((const char *)sptr, (eptr - sptr));
+            }
             return true;
 
         }
 
-
-        if (!oscl_strncmp(sptr, "Title=", oscl_strlen("Title=")))
+        if (!oscl_CIstrncmp(sptr, "Title=", oscl_strlen("Title=")))
         {
             sptr = sptr + oscl_strlen("Title=");
             assetbox = (int) AssetInfoType::TITLE;
             ainfo.oTitlePresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Description=", oscl_strlen("Description=")))
+        else if (!oscl_CIstrncmp(sptr, "Description=", oscl_strlen("Description=")))
         {
             sptr = sptr + oscl_strlen("Description=");
             assetbox = (int) AssetInfoType::DESCRIPTION;
             ainfo.oDescriptionPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Copyright=", oscl_strlen("Copyright=")))
+        else if (!oscl_CIstrncmp(sptr, "Copyright=", oscl_strlen("Copyright=")))
         {
             sptr = sptr + oscl_strlen("Copyright=");
             assetbox = (int) AssetInfoType::COPYRIGHT;
             ainfo.oCopyRightPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Performer=", oscl_strlen("Performer=")))
+        else if (!oscl_CIstrncmp(sptr, "Performer=", oscl_strlen("Performer=")))
         {
             sptr = sptr + oscl_strlen("Performer=");
             assetbox = (int) AssetInfoType::PERFORMER;
             ainfo.oPerformerPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Author=", oscl_strlen("Author=")))
+        else if (!oscl_CIstrncmp(sptr, "Author=", oscl_strlen("Author=")))
         {
             sptr = sptr + oscl_strlen("Author=");
             assetbox = (int) AssetInfoType::AUTHOR;
             ainfo.oAuthorPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Genre=", oscl_strlen("Genre=")))
+        else if (!oscl_CIstrncmp(sptr, "Genre=", oscl_strlen("Genre=")))
         {
             sptr = sptr + oscl_strlen("Genre=");
             assetbox = (int) AssetInfoType::GENRE;
             ainfo.oGenrePresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Rating=", oscl_strlen("Rating=")))
+        else if (!oscl_CIstrncmp(sptr, "Rating=", oscl_strlen("Rating=")))
         {
             sptr = sptr + oscl_strlen("Rating=");
             assetbox = (int) AssetInfoType::RATING;
             ainfo.oRatingPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Classification=", oscl_strlen("Classification=")))
+        else if (!oscl_CIstrncmp(sptr, "Classification=", oscl_strlen("Classification=")))
         {
             sptr = sptr + oscl_strlen("Classification=");
             assetbox = (int) AssetInfoType::CLASSIFICATION;
             ainfo.oClassificationPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Keywords=", oscl_strlen("Keywords=")))
+        else if (!oscl_CIstrncmp(sptr, "Keywords=", oscl_strlen("Keywords=")))
         {
             sptr = sptr + oscl_strlen("Keywords=");
             assetbox = (int) AssetInfoType::KEYWORDS;
             ainfo.oKeyWordsPresent = true;
         }
-        else if (!oscl_strncmp(sptr, "Location=", oscl_strlen("Location=")))
+        else if (!oscl_CIstrncmp(sptr, "Location=", oscl_strlen("Location=")))
         {
             sptr = sptr + oscl_strlen("Location=");
             assetbox = (int) AssetInfoType::LOCATION;
             ainfo.oLocationPresent = true;
         }
-        else// if(!oscl_strncmp(sptr, "asset-extention=", oscl_strlen("asset-extention=")))
+        else if (!oscl_CIstrncmp(sptr, "Album=", oscl_strlen("Album=")))
+        {
+            sptr = sptr + oscl_strlen("Album=");
+            assetbox = (int) AssetInfoType::ALBUM;
+            ainfo.oAlbumPresent = true;
+        }
+        else if (!oscl_CIstrncmp(sptr, "RecordingYear=", oscl_strlen("RecordingYear=")))
+        {
+            sptr = sptr + oscl_strlen("RecordingYear=");
+            assetbox = (int) AssetInfoType::RECORDINGYEAR;
+            ainfo.oRecordingYearPresent = true;
+        }
+        else// if(!oscl_CIstrncmp(sptr, "asset-extention=", oscl_strlen("asset-extention=")))
         {//asset-extension ignore for now
             //sptr = sptr + oscl_strlen("asset-extention=");
             assetbox = (int) AssetInfoType::ASSET_EXTENTION;
@@ -340,8 +620,201 @@
                 return false;
         }
 
-        ainfo.Box[assetbox].set((const char *)sptr, (eptr - sptr));
-
+        {
+            //(here sptr is the complete value of base64 encoded metadata)
+            uint8* inBuf = (uint8*)sptr;
+            //(length of base64 encode metadata value)
+            uint32 inBufLen = (eptr - sptr);
+            //(string to collect the base64 decoded data)
+            uint8* outBuf = (uint8*)oscl_malloc(inBufLen);
+            if (outBuf != NULL)
+            {
+                //(max length of the base64 decoded data)
+                uint32 maxoutBuflen = inBufLen;
+                uint32 outBuflen = 0;
+                sdp_decodebase64(inBuf, inBufLen, outBuf, outBuflen, maxoutBuflen);
+                //4 bytes size, 4 bytes fourcc, 4 bytes flags
+                uint32 assetinfoatomoffset = 12;
+                if (outBuflen > assetinfoatomoffset)
+                {
+                    uint8* buf = outBuf + assetinfoatomoffset;
+                    if ((assetbox == AssetInfoType::TITLE) ||
+                            (assetbox == AssetInfoType::DESCRIPTION) ||
+                            (assetbox == AssetInfoType::COPYRIGHT) ||
+                            (assetbox == AssetInfoType::PERFORMER) ||
+                            (assetbox == AssetInfoType::AUTHOR) ||
+                            (assetbox == AssetInfoType::GENRE) ||
+                            (assetbox == AssetInfoType::ALBUM) ||
+                            (assetbox == AssetInfoType::RATING) ||
+                            (assetbox == AssetInfoType::CLASSIFICATION))
+                    {
+                        char rating_entity[21];
+                        char rating_criteria[21];
+                        if (assetbox == AssetInfoType::RATING)
+                        {
+                            oscl_snprintf(rating_entity,
+                                          oscl_strlen(PVSDPMETADATA_RATING_ENTITY) + 4,
+                                          "%s%s",
+                                          PVSDPMETADATA_RATING_ENTITY, buf);
+                            buf += 4;
+                            rating_entity[20] = '\0';
+                            oscl_snprintf(rating_criteria,
+                                          oscl_strlen(PVSDPMETADATA_RATING_CRITERIA) + 4,
+                                          "%s%s",
+                                          PVSDPMETADATA_RATING_CRITERIA, buf);
+                            buf += 4;
+                            rating_criteria[20] = '\0';
+                        }
+                        char classification_entity[26];
+                        char classification_table[26];
+                        if (assetbox == AssetInfoType::CLASSIFICATION)
+                        {
+                            oscl_snprintf(classification_entity,
+                                          oscl_strlen(PVSDPMETADATA_CLASSIFICATION_ENTITY) + 4,
+                                          "%s%s",
+                                          PVSDPMETADATA_CLASSIFICATION_ENTITY, buf);
+                            buf += 4;
+                            classification_entity[25] = '\0';
+                            oscl_snprintf(classification_table,
+                                          oscl_strlen(PVSDPMETADATA_CLASSFICATION_TABLE) + 2,
+                                          "%s%s",
+                                          PVSDPMETADATA_CLASSFICATION_TABLE, buf);
+                            buf += 2;
+                            classification_table[25] = '\0';
+                        }
+                        uint16 lang = *buf++;
+                        lang = ((lang << 8) | (*buf++));
+                        char LangCode[4];
+                        pvSDPParserGetAssetInfoLanguageCode(lang, LangCode);
+                        char lang_param[21];
+                        oscl_snprintf(lang_param,
+                                      oscl_strlen(PVSDPMETADATA_LANG_CODE) + 4,
+                                      "%s%s", PVSDPMETADATA_LANG_CODE, LangCode);
+                        lang_param[20] = '\0';
+                        uint16 byteOrderMask = *buf;
+                        byteOrderMask =
+                            ((byteOrderMask << 8) | (*(buf + 1)));
+                        if (byteOrderMask == BYTE_ORDER_MASK)
+                        {
+                            buf += 2;
+                            OsclBinIStreamBigEndian datastream;
+                            datastream.Attach((void *)(buf), (outBuflen - assetinfoatomoffset - 2));
+                            //(string to collect the utf8 data)
+                            uint8* utf8Buf = (uint8*)oscl_malloc(inBufLen);
+                            oscl_memset(utf8Buf, 0, inBufLen);
+                            int32 unicodebuflen = (int32)((outBuflen - assetinfoatomoffset - 2) / 2);
+                            oscl_wchar* unicodeBuf = (oscl_wchar*)oscl_malloc((unicodebuflen + 1) * sizeof(oscl_wchar));
+                            oscl_memset(unicodeBuf, 0, (unicodebuflen + 1)*sizeof(oscl_wchar));
+                            for (int32 i = 0; i < unicodebuflen; i++)
+                            {
+                                uint16 temp = 0;
+                                datastream >> temp;
+                                unicodeBuf[i] = (uint16)(temp);
+                            }
+                            oscl_UnicodeToUTF8(unicodeBuf,
+                                               unicodebuflen,
+                                               (char*)utf8Buf,
+                                               inBufLen);
+                            ainfo.Box[assetbox].set((const char *)(utf8Buf),
+                                                    oscl_strlen((const char*)utf8Buf));
+                            oscl_free(utf8Buf);
+                            oscl_free(unicodeBuf);
+                        }
+                        else
+                        {
+                            ainfo.Box[assetbox].set((const char *)(buf),
+                                                    (outBuflen - assetinfoatomoffset));
+                        }
+                        ainfo.Box[assetbox] += lang_param;
+                        if (assetbox == AssetInfoType::RATING)
+                        {
+                            ainfo.Box[assetbox] += rating_entity;
+                            ainfo.Box[assetbox] += rating_criteria;
+                        }
+                        else if (assetbox == AssetInfoType::CLASSIFICATION)
+                        {
+                            ainfo.Box[assetbox] += classification_entity;
+                            ainfo.Box[assetbox] += classification_table;
+                        }
+                    }
+                    else if (assetbox == AssetInfoType::RECORDINGYEAR)
+                    {
+                        ainfo.iRecordingYear = 0;
+                        ainfo.iRecordingYear = *buf++;
+                        ainfo.iRecordingYear = ((ainfo.iRecordingYear << 8) | (*buf++));
+                    }
+                    else if (assetbox == AssetInfoType::KEYWORDS)
+                    {
+                        uint16 lang = *buf++;
+                        lang = ((lang << 8) | (*buf++));
+                        char LangCode[4];
+                        pvSDPParserGetAssetInfoLanguageCode(lang, LangCode);
+                        char lang_param[21];
+                        oscl_snprintf(lang_param,
+                                      oscl_strlen(PVSDPMETADATA_LANG_CODE) + 4,
+                                      "%s%s", PVSDPMETADATA_LANG_CODE, LangCode);
+                        lang_param[20] = '\0';
+                        ainfo.iNumKeyWords = (uint32)(*buf++);
+                        for (uint32 i = 0; i < ainfo.iNumKeyWords; i++)
+                        {
+                            OSCL_HeapString<OsclMemAllocator> keyWordString;
+                            uint32 keywordsize = (uint32)(*buf++);
+                            uint16 byteOrderMask = *buf;
+                            byteOrderMask =
+                                ((byteOrderMask << 8) | (*(buf + 1)));
+                            if (byteOrderMask == BYTE_ORDER_MASK)
+                            {
+                                buf += 2;
+                                keywordsize -= 2;
+                                OsclBinIStreamBigEndian datastream;
+                                datastream.Attach((void *)(buf), keywordsize);
+                                //(string to collect the utf8 data)
+                                uint8* utf8Buf = (uint8*)oscl_malloc(keywordsize);
+                                oscl_memset(utf8Buf, 0, keywordsize);
+                                int32 unicodebuflen = (int32)((keywordsize) / 2);
+                                oscl_wchar* unicodeBuf = (oscl_wchar*)oscl_malloc((unicodebuflen + 1) * sizeof(oscl_wchar));
+                                oscl_memset(unicodeBuf, 0, (unicodebuflen + 1)*sizeof(oscl_wchar));
+                                for (int32 i = 0; i < unicodebuflen; i++)
+                                {
+                                    uint16 temp = 0;
+                                    datastream >> temp;
+                                    unicodeBuf[i] = (uint16)(temp);
+                                }
+                                oscl_UnicodeToUTF8(unicodeBuf,
+                                                   unicodebuflen,
+                                                   (char*)utf8Buf,
+                                                   inBufLen);
+                                keyWordString.set((const char *)(utf8Buf),
+                                                  oscl_strlen((const char*)utf8Buf));
+                                oscl_free(utf8Buf);
+                                oscl_free(unicodeBuf);
+                                buf += keywordsize;
+                            }
+                            else
+                            {
+                                keyWordString.set((const char *)(buf), keywordsize);
+                                buf += keywordsize;
+                            }
+                            keyWordString += lang_param;
+                            ainfo.KeyWords[i] = keyWordString;
+                        }
+                    }
+                    else if (assetbox == AssetInfoType::LOCATION)
+                    {
+                        if (pvSDPParserParse3GPPAssetInfoLocation(ainfo, buf, outBuflen) != true)
+                        {
+                            return false;
+                        }
+                    }
+                    else
+                    {
+                        ainfo.Box[assetbox].set((const char *)(buf),
+                                                (outBuflen - assetinfoatomoffset));
+                    }
+                }
+                oscl_free(outBuf);
+            }
+        }
         eptr = eptr + 1;
         sptr = eptr + 1;
     }
@@ -349,94 +822,4 @@
     return true;
 }
 
-bool sdp_decodebase64(uint8* aInBuf, uint32 aInBufLen,
-                      uint8* aOutBuf, uint32& aOutBufLen, uint32 aMaxOutBufLen)
-{
-    oscl_memset(aOutBuf, 0, aMaxOutBufLen);
-    aOutBufLen = 0;
-
-    int i;
-    uint8 dtable[256];
-
-    for (i = 0;i < 255;i++)
-    {
-        dtable[i] = 0x80;
-    }
-    for (i = 'A';i <= 'I';i++)
-    {
-        dtable[i] = 0 + (i - 'A');
-    }
-    for (i = 'J';i <= 'R';i++)
-    {
-        dtable[i] = 9 + (i - 'J');
-    }
-    for (i = 'S';i <= 'Z';i++)
-    {
-        dtable[i] = 18 + (i - 'S');
-    }
-    for (i = 'a';i <= 'i';i++)
-    {
-        dtable[i] = 26 + (i - 'a');
-    }
-    for (i = 'j';i <= 'r';i++)
-    {
-        dtable[i] = 35 + (i - 'j');
-    }
-    for (i = 's';i <= 'z';i++)
-    {
-        dtable[i] = 44 + (i - 's');
-    }
-    for (i = '0';i <= '9';i++)
-    {
-        dtable[i] = 52 + (i - '0');
-    }
-    dtable[(int)'+'] = 62;
-    dtable[(int)'/'] = 63;
-    dtable[(int)'='] = 0;
-
-    uint32 read_count = 0;
-    uint32 write_count = 0;
-    while (read_count < aInBufLen)
-    {
-        uint8 a[4], b[4], o[3];
-
-        for (i = 0;i < 4;i++)
-        {
-            uint8 c = *(aInBuf++);
-            read_count++;
-
-            if (read_count > aInBufLen)
-            {
-                //Input incomplete
-                return false;
-            }
-            if (dtable[(int)c]&0x80)
-            {
-                //Illegal character in
-                //return false;
-                i--;
-                continue;
-            }
-            a[i] = (uint8)c;
-            b[i] = (uint8)dtable[(int)c];
-        }
-        o[0] = (b[0] << 2) | (b[1] >> 4);
-        o[1] = (b[1] << 4) | (b[2] >> 2);
-        o[2] = (b[2] << 6) | b[3];
-        i = a[2] == '=' ? 1 : (a[3] == '=' ? 2 : 3);
-        oscl_memcpy(aOutBuf, o, i);
-        aOutBuf += i;
-        write_count += i;
-        if (write_count > aMaxOutBufLen)
-        {
-            return false;
-        }
-        if (i < 3)
-        {
-            break;
-        }
-    }
-    aOutBufLen = write_count;
-    return true;
-}
 
diff --git a/protocols/sdp/parser/src/sdpparser.cpp b/protocols/sdp/parser/src/sdpparser.cpp
index 2c40865..6dbc371 100644
--- a/protocols/sdp/parser/src/sdpparser.cpp
+++ b/protocols/sdp/parser/src/sdpparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*									    */
-/*   =====================================================================  */
-/*	File: SDPParser.cpp						    */
-/*	Description:							    */
-/*									    */
-/*									    */
-/*	Rev:								    */
-/*	Created: 05/24/01						    */
-/*   =====================================================================  */
-/*									    */
-/*	Revision History:						    */
-/*									    */
-/*	Rev:								    */
-/*	Date:								    */
-/*	Description:							    */
-/*									    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "sdp_parser.h"
 #include "sdp_mediaparser_registry.h"
 #include "oscl_string_utils.h"
@@ -41,7 +23,6 @@
 #include "base_media_info_parser.h"
 #include "aac_media_info_parser.h"
 #include "amr_media_info_parser.h"
-#include "evrc_media_info_parser.h"
 #include "h263_media_info_parser.h"
 #include "m4v_media_info_parser.h"
 #include "still_image_media_info_parser.h"
@@ -57,131 +38,19 @@
     Oscl_Vector<int, SDPParserAlloc> payload_no;
 };
 
-
-/* ======================================================================== */
-/*	Function : SDP_Parser(table * _pSDPMediaParserRegistry,mediaInfo** mediaData,
-sessionDescription* sessionData, SDPMemory *pMemory)    */
-/*	Date     : 05/24/2001						    */
-/*	Purpose  : Constructor for the SDP_Parser class			    */
-/*	In/out   :							    */
-/*	Return   :							    */
-/*	Modified :							    */
-/* ======================================================================== */
-
-OSCL_EXPORT_REF SDP_Parser::SDP_Parser(bool sipSdp):
+OSCL_EXPORT_REF SDP_Parser::SDP_Parser(SDPMediaParserRegistry*& regTable, bool sipSdp):
         iLogger(NULL),
-        reg(NULL),
-        _pSDPMediaParserRegistry(NULL),
+        _pSDPMediaParserRegistry(regTable),
         mediaArrayIndex(0),
-        registrar_locally_allocated(false),
-        memflag(false),
-        localRegAllocation(false),
         applicationFlag(false),
-        _pAMRMediaParserFactory(NULL),
-        _pEVRCMediaParserFactory(NULL),
-        _pAACMediaParserFactory(NULL),
-        _pASFMediaParserFactory(NULL),
-        _pH263MediaParserFactory(NULL),
-        _pMPEG4MediaParserFactory(NULL),
-        _pStillImageMediaParserFactory(NULL),
-        _pH264MediaParserFactory(NULL),
-        _pPCMAMediaParserFactory(NULL),
-        _pPCMUMediaParserFactory(NULL),
-        _pRFC3640MediaParserFactory(NULL),
         isSipSdp(sipSdp)
 {
     iLogger = PVLogger::GetLoggerObject("SDP_Parser");
 }
 
 
-OSCL_EXPORT_REF SDP_Parser::SDP_Parser(SDPMediaParserRegistry *regTable, bool sipSdp):
-        iLogger(NULL),
-        reg(NULL),
-        _pSDPMediaParserRegistry(NULL),
-        mediaArrayIndex(0),
-        registrar_locally_allocated(false),
-        memflag(false),
-        localRegAllocation(false),
-        applicationFlag(false),
-        _pAMRMediaParserFactory(NULL),
-        _pEVRCMediaParserFactory(NULL),
-        _pAACMediaParserFactory(NULL),
-        _pASFMediaParserFactory(NULL),
-        _pH263MediaParserFactory(NULL),
-        _pMPEG4MediaParserFactory(NULL),
-        _pStillImageMediaParserFactory(NULL),
-        _pH264MediaParserFactory(NULL),
-        _pPCMAMediaParserFactory(NULL),
-        _pPCMUMediaParserFactory(NULL),
-        _pRFC3640MediaParserFactory(NULL),
-
-        isSipSdp(sipSdp)
-{
-    if (regTable != NULL)
-    {
-        _pSDPMediaParserRegistry = regTable;
-    }
-    else
-    {
-        _pSDPMediaParserRegistry = NULL;
-    }
-    iLogger = PVLogger::GetLoggerObject("SDP_Parser");
-}
-
-
 OSCL_EXPORT_REF SDP_Parser::~SDP_Parser()
 {
-    iLogger = NULL;
-    if (registrar_locally_allocated == true)
-    {
-        SDPMediaParserRegistry::Cleanup();
-    }
-    if (_pAMRMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pAMRMediaParserFactory));
-    }
-    if (_pEVRCMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pEVRCMediaParserFactory));
-    }
-    if (_pAACMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pAACMediaParserFactory));
-    }
-    if (_pASFMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pASFMediaParserFactory));
-    }
-    if (_pH263MediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pH263MediaParserFactory));
-    }
-    if (_pMPEG4MediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pMPEG4MediaParserFactory));
-    }
-    if (_pStillImageMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pStillImageMediaParserFactory));
-    }
-    if (_pH264MediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pH264MediaParserFactory));
-    }
-    if (_pPCMAMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pPCMAMediaParserFactory));
-    }
-    if (_pPCMUMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pPCMUMediaParserFactory));
-    }
-    if (_pPCMUMediaParserFactory != NULL)
-    {
-        OSCL_DELETE((_pRFC3640MediaParserFactory));
-    }
-
-
 }
 
 bool SDP_Parser::parse_rtpmap(const char *start, const char *end, int& rtp_payload,
@@ -339,7 +208,8 @@
         }
         else
         {
-            if (!oscl_strstr(start, "IMAGE"))
+            uint32 len = OSCL_MIN((uint32)(eptr - start), oscl_strlen("IMAGE"));
+            if (!oscl_strncmp(start, "IMAGE", len))
             {
                 applicationFlag = true;
             }
@@ -359,15 +229,6 @@
 
 }
 
-
-/* ================================================================================= */
-/*	Function : parseSDP(char *sdpText) 											 	 */
-/*	Date     : 05/24/2001															 */
-/*	Purpose  : Parses SDP text														 */
-/*	In/out   :																		 */
-/*	Return   :																		 */
-/*	Modified :																		 */
-/* ================================================================================= */
 OSCL_EXPORT_REF
 SDP_ERROR_CODE SDP_Parser::parseSDP(const char *sdpText, int text_length, SDPInfo *sdp)
 {
@@ -809,23 +670,6 @@
                     SDPBaseMediaInfoParser *mediaParser;
                     SDP_ERROR_CODE retval;
 
-                    if (_pSDPMediaParserRegistry == NULL)
-                    {
-                        if (allocateRegistrar() == false)
-                        {
-                            PVMF_SDP_PARSER_LOGERROR((0, "SDP_Parser::parseSDP - allocateRegistrar failed"));
-                            return SDP_FAILURE;
-                        }
-                        else
-                        {
-                            if (_pSDPMediaParserRegistry == NULL)
-                            {
-                                PVMF_SDP_PARSER_LOGERROR((0, "SDP_Parser::parseSDP - No SDP MediaParser Registry"));
-                                return SDP_FAILURE;
-                            }
-                        }
-                    }
-
                     for (uint32 kk = 0; kk < mime_payload_pair_vector.size(); kk++)
                     {
                         encoding_name = mime_payload_pair_vector[kk].mime;
@@ -854,6 +698,7 @@
                                         OSCL_StackString<8> mime((const char*)(encoding_name.ptr), encoding_name.len);
                                         PVMF_SDP_PARSER_LOGERROR((0, "SDP_Parser::parseSDP - Parsing m= section failed, mime=%s", mime.get_cstr()));
                                         OSCL_DELETE((mediaParser));
+                                        sdp->freeLastMediaInfoObject();
                                         return retval;
                                     }
 
@@ -866,9 +711,9 @@
                                     OSCL_StackString<8> mime((const char*)(encoding_name.ptr), encoding_name.len);
                                     PVMF_SDP_PARSER_LOGERROR((0, "SDP_Parser::parseSDP - Parsing m= section failed, mime=%s", mime.get_cstr()));
                                     OSCL_DELETE((mediaParser));
+                                    sdp->freeLastMediaInfoObject();
                                     return retval;
                                 }
-
                             }
                             sdp->IncrementAlternateMediaInfoVectorIndex();
                             OSCL_DELETE((mediaParser));
@@ -972,71 +817,6 @@
     return SDP_SUCCESS;
 }
 
-OSCL_EXPORT_REF bool
-SDP_Parser::allocateRegistrar()
-{
-    if (_pSDPMediaParserRegistry == NULL)
-    {
-        //Please update the #define MAX_CODEC_MODE_LIST 11 in "sdp_error.h"
-        //before registerSDPParser() for any new MIME type
-        StrPtrLen aac_latm("MP4A-LATM");
-        StrPtrLen aac("AAC");
-        StrPtrLen amr("AMR");
-        StrPtrLen amrwb("AMR-WB");
-        StrPtrLen evrc("EVRC");
-        StrPtrLen h263_old("H263-1998");
-        StrPtrLen h263("H263-2000");
-        StrPtrLen m4v("MP4V-ES");
-        StrPtrLen author_m4v("PVMP4V-ES");
-        StrPtrLen still("X-MP4V-IMAGE");
-        StrPtrLen asf("ASF");
-        StrPtrLen h264("H264");
-        StrPtrLen pcma("PCMA");
-        StrPtrLen pcmu("PCMU");
-        StrPtrLen rfc3640("mpeg4-generic");
-
-        _pAMRMediaParserFactory = OSCL_NEW(SDPAMRMediaParserFactory, ());
-        _pEVRCMediaParserFactory = OSCL_NEW(SDPEVRCMediaParserFactory, ());
-        _pAACMediaParserFactory = OSCL_NEW(SDPAACMediaParserFactory, ());
-        _pASFMediaParserFactory = OSCL_NEW(SDPASFMediaParserFactory, ());
-        _pH263MediaParserFactory = OSCL_NEW(SDPH263MediaParserFactory, ());
-        _pMPEG4MediaParserFactory = OSCL_NEW(SDPMPEG4MediaParserFactory, ());
-        _pStillImageMediaParserFactory = OSCL_NEW(SDPStillImageMediaParserFactory, ());
-        _pH264MediaParserFactory = OSCL_NEW(SDPH264MediaParserFactory, ());
-        _pPCMAMediaParserFactory = OSCL_NEW(SDPPCMAMediaParserFactory, ());
-        _pPCMUMediaParserFactory = OSCL_NEW(SDPPCMUMediaParserFactory, ());
-        _pRFC3640MediaParserFactory = OSCL_NEW(SDPRFC3640MediaParserFactory, ());
-
-        SDPMediaParserRegistry::Init();
-
-        _pSDPMediaParserRegistry =
-            SDPMediaParserRegistry::GetSDPMediaParserRegistry();
-
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(aac_latm, _pAACMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(aac, _pAACMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(amr, _pAMRMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(amrwb, _pAMRMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(evrc, _pEVRCMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(h263_old, _pH263MediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(h263, _pH263MediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(m4v, _pMPEG4MediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(author_m4v, _pMPEG4MediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(still, _pStillImageMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(asf, _pASFMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(h264, _pH264MediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(pcma, _pPCMAMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(pcmu, _pPCMUMediaParserFactory);
-        _pSDPMediaParserRegistry->addMediaParserFactoryToRegistry(rfc3640, _pRFC3640MediaParserFactory);
-
-        registrar_locally_allocated = true;
-        return true;
-    }
-    else
-    {
-        return false;
-    }
-}
-
 OSCL_EXPORT_REF SDP_ERROR_CODE
 SDP_Parser::parseSDPDownload(const char *sdpText,
                              int length,
@@ -1084,8 +864,7 @@
 
         /*Get start stop times*/
         convertToMilliSec(*sdp->getSessionInfo()->getRange(), mv->duration.startTime, mv->duration.stopTime);
-        /*Get content version*/
-        sdp->getSessionInfo()->getContentVersion(mv->majorVersion, mv->minorVersion);
+
         /*Get MIMEType and other track info*/
         for (int ii = 0; ii < mv->trackCount; ii++)
         {
@@ -1128,7 +907,6 @@
                 }
             }
             mv->TrackArray[ii].trackID = track;
-            minfo->getContentVersion(mv->TrackArray[ii].majorVersion, mv->TrackArray[ii].minorVersion);
         }
     }
     return SDP_SUCCESS;
diff --git a/protocols/sdp/parser/src/sessioninfoparser.cpp b/protocols/sdp/parser/src/sessioninfoparser.cpp
index e45fb74..20af053 100644
--- a/protocols/sdp/parser/src/sessioninfoparser.cpp
+++ b/protocols/sdp/parser/src/sessioninfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,23 +15,6 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*									    */
-/*   =====================================================================  */
-/*	File: sessionInfoParser.cpp					    */
-/*	Description:							    */
-/*									    */
-/*									    */
-/*	Rev:								    */
-/*	Created: 05/24/01						    */
-/*   =====================================================================  */
-/*									    */
-/*	Revision History:						    */
-/*									    */
-/*	Rev:								    */
-/*	Date:								    */
-/*	Description:							    */
-/*									    */
-/* //////////////////////////////////////////////////////////////////////// */
 
 #include "session_info_parser.h"
 #include "oscl_string_utils.h"
@@ -41,15 +24,7 @@
 #include "rtsp_range_utils.h"
 #include "oscl_string_containers.h"
 
-/* ========================================================================== */
-/*	Function : parsePayload(char *buff,int index,
-sessionDescription *session) */
-/*	Date     : 05/24/2001													  */
-/*	Purpose  : Parses session text and fills out the session structure		  */
-/*	In/out   :																  */
-/*	Return   :																  */
-/*	Modified :																  */
-/* ========================================================================== */
+
 SDP_ERROR_CODE parseSDPSessionInfo(const char *sdp_text, int length, SDPInfo *sdp)
 {
 
@@ -80,7 +55,6 @@
     StrPtrLen allowrecord("a=X-allowrecord");
     StrPtrLen random_access("a=random_access_denied");
     StrPtrLen control("a=control:");
-    StrPtrLen content_version("a=content_version:");
     StrPtrLen creation_date("a=creation_date:");
     StrPtrLen video_only_allowed_true("a=video_only_allowed:true");
     StrPtrLen video_only_allowed_false("a=video_only_allowed:false");
@@ -427,13 +401,14 @@
                 memFrag.ptr = (void*)sptr;
                 memFrag.len = (eptr - sptr);
                 session->setCAddressType(memFrag);
-
-
-                if (oscl_strstr(sptr, "IP6"))
-                {//TBD
+                uint32 len = OSCL_MIN((uint32)(eptr - sptr), oscl_strlen("IP6"));
+                if (oscl_strncmp(sptr, "IP6", len) == 0)
+                {
+                    //TBD
                     break;
                 }
 
+
                 // get the address
                 sptr = skip_whitespace(eptr, line_end_ptr);
                 if (sptr >= line_end_ptr)
@@ -1022,49 +997,6 @@
                     a_control_found = true;
 
                 }
-                else if (!oscl_strncmp(line_start_ptr, content_version.c_str(),
-                                       content_version.length()))
-                {
-
-                    sptr = skip_whitespace(line_start_ptr + content_version.length(),
-                                           line_end_ptr);
-                    if (sptr >= line_end_ptr)
-                    {
-                        return SDP_BAD_SESSION_FORMAT;
-                    }
-
-                    // skip to the first "."
-                    for (eptr = sptr; eptr < line_end_ptr && *eptr != '.'; ++eptr);
-
-                    uint32 major_version, minor_version = 0;
-                    if (PV_atoi(sptr, 'd', (eptr - sptr), major_version) == false)
-                    {
-                        return SDP_BAD_SESSION_FORMAT;
-                    }
-
-                    if (*eptr == '.')
-                    {
-
-                        sptr = skip_whitespace(eptr + 1,
-                                               line_end_ptr);
-                        eptr = skip_to_whitespace(sptr, line_end_ptr);
-                        if (eptr <= sptr)
-                        {
-                            return SDP_BAD_SESSION_FORMAT;
-                        }
-
-                        if (PV_atoi(sptr, 'd', (eptr - sptr), minor_version) == false)
-                        {
-                            return SDP_BAD_SESSION_FORMAT;
-                        }
-
-                    }
-
-                    uint16 content_version = (uint16)((major_version << 8) | minor_version);
-
-                    session->setContentVersion(content_version);
-
-                }
 
                 else if (!oscl_strncmp(line_start_ptr, creation_date.c_str(),
                                        creation_date.length()))
diff --git a/protocols/sdp/parser/src/still_imagemediainfoparser.cpp b/protocols/sdp/parser/src/still_imagemediainfoparser.cpp
index f39e298..8b42172 100644
--- a/protocols/sdp/parser/src/still_imagemediainfoparser.cpp
+++ b/protocols/sdp/parser/src/still_imagemediainfoparser.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,35 +15,9 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
-/*																			                                    */
-/*	=====================================================================	  */
-/*	File: still_imageMediaInfoParser.cpp									                  */
-/*	Description:															                              */
-/*																			                                    */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Created: 05/24/01														                            */
-/*	=====================================================================	  */
-/*																			                                    */
-/*	Revision History:														                            */
-/*																			                                    */
-/*	Rev:																	                                  */
-/*	Date:																	                                  */
-/*	Description:															                              */
-/*																			                                    */
-/* //////////////////////////////////////////////////////////////////////// */
-
 #include "still_image_media_info_parser.h"
 #include "oscl_string_utils.h"
 
-/* ========================================================================== */
-/*	Function : parsePayload(char *buff,mediaInfo* still_imageI,int index)	    */
-/*	Date     : 05/24/2001													                            */
-/*	Purpose  : Parses still image text and fills out the still image structure*/
-/*	In/out   :																                                */
-/*	Return   :																                                */
-/*	Modified :																                                */
-/* ========================================================================== */
 SDP_ERROR_CODE
 SDPStillImageMediaInfoParser::parseMediaInfo(const char *buff, const int index, SDPInfo *sdp, payloadVector payload_vec, bool isSipSdp, int alt_id, bool alt_def_id)
 {
diff --git a/protocols/systems/3g-324m_pvterminal/Android.mk b/protocols/systems/3g-324m_pvterminal/Android.mk
new file mode 100644
index 0000000..83276d6
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/Android.mk
@@ -0,0 +1,100 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	./common/src/pvt_common.cpp \
+ 	./common/src/h324utils.cpp \
+ 	./h223/src/adaptationlayer.cpp \
+ 	./h223/src/cpvh223multiplex.cpp \
+ 	./h223/src/h223api.cpp \
+ 	./h223/src/h223types.cpp \
+ 	./h223/src/level0.cpp \
+ 	./h223/src/level1.cpp \
+ 	./h223/src/level2.cpp \
+ 	./h223/src/logicalchannel.cpp \
+ 	./h223/src/lowerlayer.cpp \
+ 	./h223/src/muxtbl.cpp \
+ 	./h324/tsc/src/tscmain.cpp \
+ 	./h324/tsc/src/tsc_blc.cpp \
+ 	./h324/tsc/src/tsc_capability.cpp \
+ 	./h324/tsc/src/tsc_ce.cpp \
+ 	./h324/tsc/src/tsc_channelcontrol.cpp \
+ 	./h324/tsc/src/tsc_clc.cpp \
+ 	./h324/tsc/src/tsc_command.cpp \
+ 	./h324/tsc/src/tsc_component.cpp \
+ 	./h324/tsc/src/tsc_eventreceive.cpp \
+ 	./h324/tsc/src/tsc_h324m_config.cpp \
+ 	./h324/tsc/src/tsc_indication.cpp \
+ 	./h324/tsc/src/tsc_lc.cpp \
+ 	./h324/tsc/src/tsc_msd.cpp \
+ 	./h324/tsc/src/tsc_mt.cpp \
+ 	./h324/tsc/src/tsc_node_interface.cpp \
+ 	./h324/tsc/src/tsc_rme.cpp \
+ 	./h324/tsc/src/tsc_statemanager.cpp \
+ 	./h324/tsc/src/tsc_sub.cpp \
+ 	./h324/tsc/src/tschandling.cpp \
+ 	./h324/tsc/src/tscsrpbuffer.cpp \
+ 	./h324/srp/src/srp.cpp \
+ 	./h245/per/src/per.cpp \
+ 	./h245/per/src/genericper.cpp \
+ 	./h245/per/src/analyzeper.cpp \
+ 	./h245/per/src/h245_analysis.cpp \
+ 	./h245/per/src/h245_encoder.cpp \
+ 	./h245/per/src/h245_decoder.cpp \
+ 	./h245/per/src/h245_deleter.cpp \
+ 	./h245/per/src/h245_copier.cpp \
+ 	./h245/se/src/annex.cpp \
+ 	./h245/se/src/blc.cpp \
+ 	./h245/se/src/clc.cpp \
+ 	./h245/se/src/lc.cpp \
+ 	./h245/se/src/lcblccmn.cpp \
+ 	./h245/se/src/ml.cpp \
+ 	./h245/se/src/mr.cpp \
+ 	./h245/se/src/mt.cpp \
+ 	./h245/se/src/rme.cpp \
+ 	./h245/se/src/rtd.cpp \
+ 	./h245/se/src/se.cpp \
+ 	./h245/se/src/sebase.cpp \
+ 	./h324/tsc/src/tsc_componentregistry.cpp
+
+
+LOCAL_MODULE := libpv324m
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/protocols/systems/3g-324m_pvterminal \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h223/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h245/cmn/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h245/per/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h245/se/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h324/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h324/srp/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/h324/tsc/include \
+ 	$(PV_TOP)/protocols/systems/3g-324m_pvterminal/common/include \
+ 	$(PV_TOP)/protocols/systems/common/include \
+ 	$(PV_TOP)/engines/common/include \
+ 	$(PV_TOP)/protocols/systems/tools/general/common/include \
+ 	$(PV_TOP)/nodes/streaming/common/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	./h324/tsc/include/tsc_h324m_config_interface.h \
+ 	./common/include/pv_2way_h324m_interface.h \
+ 	./common/include/pv_2way_h324m_types.h \
+ 	./common/include/pvt_common.h \
+ 	./h245/cmn/include/h245def.h \
+ 	./h245/per/include/per_common.h \
+ 	./h245/per/include/analyzeper.h \
+ 	./h245/per/include/genericper.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/protocols/systems/3g-324m_pvterminal/build/make/default_support.mk b/protocols/systems/3g-324m_pvterminal/build/make/default_support.mk
new file mode 100644
index 0000000..db0390a
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/build/make/default_support.mk
@@ -0,0 +1,3 @@
+#This fragmented makefile contains the source file required for building without value adds
+
+SRCS += h324/tsc/src/tsc_componentregistry.cpp 
\ No newline at end of file
diff --git a/protocols/systems/3g-324m_pvterminal/build/make/local.mk b/protocols/systems/3g-324m_pvterminal/build/make/local.mk
new file mode 100644
index 0000000..5150890
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/build/make/local.mk
@@ -0,0 +1,90 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pv324m
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../h223/include  ../../h245/cmn/include  ../../h245/per/include  ../../h245/se/include  ../../h324/include  ../../h324/srp/include  ../../h324/tsc/include  ../../common/include  ../../../common/include  ../../../../../engines/common/include  ../../../tools/general/common/include  ../../../../../nodes/streaming/common/include
+
+
+
+SRCDIR := ../../.
+INCSRCDIR := ../../.
+
+
+SRCS += common/src/pvt_common.cpp \
+	common/src/h324utils.cpp \
+	h223/src/adaptationlayer.cpp \
+	h223/src/cpvh223multiplex.cpp \
+	h223/src/h223api.cpp \
+	h223/src/h223types.cpp \
+	h223/src/level0.cpp \
+	h223/src/level1.cpp \
+	h223/src/level2.cpp \
+	h223/src/logicalchannel.cpp \
+	h223/src/lowerlayer.cpp \
+	h223/src/muxtbl.cpp \
+	h324/tsc/src/tscmain.cpp \
+	h324/tsc/src/tsc_blc.cpp \
+	h324/tsc/src/tsc_capability.cpp \
+	h324/tsc/src/tsc_ce.cpp \
+	h324/tsc/src/tsc_channelcontrol.cpp \
+	h324/tsc/src/tsc_clc.cpp \
+	h324/tsc/src/tsc_command.cpp \
+	h324/tsc/src/tsc_component.cpp \
+	h324/tsc/src/tsc_eventreceive.cpp \
+	h324/tsc/src/tsc_h324m_config.cpp \
+	h324/tsc/src/tsc_indication.cpp \
+	h324/tsc/src/tsc_lc.cpp \
+	h324/tsc/src/tsc_msd.cpp \
+	h324/tsc/src/tsc_mt.cpp \
+	h324/tsc/src/tsc_node_interface.cpp \
+	h324/tsc/src/tsc_rme.cpp \
+	h324/tsc/src/tsc_statemanager.cpp \
+	h324/tsc/src/tsc_sub.cpp \
+	h324/tsc/src/tschandling.cpp \
+	h324/tsc/src/tscsrpbuffer.cpp \
+	h324/srp/src/srp.cpp \
+	h245/per/src/per.cpp \
+	h245/per/src/genericper.cpp \
+	h245/per/src/analyzeper.cpp \
+	h245/per/src/h245_analysis.cpp \
+	h245/per/src/h245_encoder.cpp \
+	h245/per/src/h245_decoder.cpp \
+	h245/per/src/h245_deleter.cpp \
+	h245/per/src/h245_copier.cpp \
+	h245/se/src/annex.cpp \
+	h245/se/src/blc.cpp \
+	h245/se/src/clc.cpp \
+	h245/se/src/lc.cpp \
+	h245/se/src/lcblccmn.cpp \
+	h245/se/src/ml.cpp \
+	h245/se/src/mr.cpp \
+	h245/se/src/mt.cpp \
+	h245/se/src/rme.cpp \
+	h245/se/src/rtd.cpp \
+	h245/se/src/se.cpp \
+	h245/se/src/sebase.cpp
+
+
+HDRS := h324/tsc/include/tsc_h324m_config_interface.h \
+	common/include/pv_2way_h324m_interface.h \
+	common/include/pv_2way_h324m_types.h \
+	common/include/pvt_common.h \
+        h245/cmn/include/h245def.h \
+        h245/per/include/per_common.h \
+        h245/per/include/analyzeper.h \
+        h245/per/include/genericper.h 
+
+ifeq ($(USING_MONA),1)
+HDRS += h324/tsc/mona/include/mona_extension_interface.h 
+endif 
+
+include $(MK)/library.mk
+
diff --git a/protocols/systems/3g-324m_pvterminal/common/include/h223_api.h b/protocols/systems/3g-324m_pvterminal/common/include/h223_api.h
new file mode 100644
index 0000000..a9e785c
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/include/h223_api.h
@@ -0,0 +1,56 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+/*****************************************************************************/
+
+/*  file name            : tscmain.h                                         */
+
+/*  file contents        :                                                   */
+
+/*  draw                 : '96.10.09                                         */
+
+/*---------------------------------------------------------------------------*/
+
+/*  amendment                                                                */
+
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+
+/*****************************************************************************/
+
+#if !defined (H223_API_H)
+#define H223_API_H
+
+#include "oscl_types.h"
+#include "cpvh223multiplex.h"
+
+OSCL_IMPORT_REF CPVH223Multiplex* AllocateH223Mux(TPVLoopbackMode aLoopbackMode);
+OSCL_IMPORT_REF void DeallocateH223Mux(CPVH223Multiplex* h223mux);
+
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/common/include/h223types.h b/protocols/systems/3g-324m_pvterminal/common/include/h223types.h
new file mode 100644
index 0000000..173bed5
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/include/h223types.h
@@ -0,0 +1,361 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef	_h223types_H
+#define _h223types_H
+
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "pvt_events.h"
+#include "pvt_params.h"
+#include "h245pri.h"
+#include "h245_deleter.h"
+#include "h245_copier.h"
+
+#ifndef OSCL_SHARED_PTR_H_INCLUDED
+#include "oscl_shared_ptr.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#include "oscl_map.h"
+#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
+#include "pvmf_media_data_impl.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#define MAX_LCNS 5
+#define FIRST_NULL_LCN 1000
+#define MAX_SEGMENTABLE_LCN_NUM 2
+
+#define H223_MAX_MUX_PDU_SIZE 512
+#define H223_MAX_MUX_PDU_SIZE_LEVEL2 255
+#define H223_MAX_DEMUX_PDU_SIZE 1024
+#define H223_DEF_PDU_SIZE 240
+
+#define H223Error_t int
+typedef H223Error_t H223Ret_t;
+#define H223_OK 0
+#define H223_ERROR 1
+#define H223_ERROR_OUT_OF_MEMORY 2
+#define H223_ERROR_OUT_OF_DEMUX_MEMORY 3
+#define H223_INSUFFICIENT_DATA 4
+#define H223_ERROR_BUFFER_SZ 5
+#define H223_STATE_BUSY 6
+#define H223_ERROR_INVALID_LCN 7
+#define H223_ERROR_MAX_LCNS 8
+#define H223_ERROR_INVALID_PARAM 9
+
+#define	NO_ERR	    0
+#define	CRC_ERR	    1
+#define	SN_ERR	    2
+#define H223_RC_UCF 1
+#define H223_RC_FINITE 0
+#define H223_MUXTYPE_LCN 0
+#define H223_MUXTYPE_SEL 1
+
+#define MAX_H223_PDU_PACKETS_PER_SEND 20
+#define MAX_FRAGMENTS_PER_H223_PDU_PACKET 10
+#define H223_MAX_PDU_SIZE 254
+#define H223_MIN_PDU_SIZE 80
+#define H223_DEFAULT_PDU_SIZE 160
+#define H223_MIN_SEGMENTABLE_PAYLOAD_SIZE 80
+#define H223_DEFAULT_MT_SN -1
+#define H223_DEFAULT_MT_NUM 0
+
+class CPVMultiplexDescriptor : public CPVParam
+{
+    public:
+        CPVMultiplexDescriptor(PS_MuxDescriptor desc, bool delete_multiplexEntryDescriptors = false)
+                : descriptor(desc), iDelete_multiplexEntryDescriptors(delete_multiplexEntryDescriptors) {}
+        ~CPVMultiplexDescriptor()
+        {
+            if (descriptor)
+            {
+                if (descriptor->size_of_multiplexEntryDescriptors)
+                {
+                    for (int i = 0; i < descriptor->size_of_multiplexEntryDescriptors; i++)
+                    {
+                        Delete_MultiplexEntryDescriptor(&descriptor->multiplexEntryDescriptors[i]);
+                    }
+                    if (iDelete_multiplexEntryDescriptors)
+                    {
+                        OSCL_DEFAULT_FREE(descriptor->multiplexEntryDescriptors);
+                        descriptor->multiplexEntryDescriptors = NULL;
+                    }
+                }
+                OSCL_DEFAULT_FREE(descriptor);
+                descriptor = NULL;
+            }
+        }
+        CPVParam* Copy()
+        {
+            return NULL;
+        }
+
+        PS_MuxDescriptor GetDescriptor()
+        {
+            return descriptor;
+        }
+        PS_MuxDescriptor descriptor;
+        bool iDelete_multiplexEntryDescriptors;
+};
+
+class H223ChannelParam : public CPVChannelParam
+{
+    public:
+        H223ChannelParam(TPVChannelId id, PS_H223LogicalChannelParameters lcp, PS_DataType dt);
+        H223ChannelParam(TPVChannelId id,
+                         PS_H223LogicalChannelParameters lcp,
+                         unsigned bitrate,
+                         unsigned sample_interval);
+
+        H223ChannelParam(const H223ChannelParam & that);
+        ~H223ChannelParam();
+        H223ChannelParam& operator =(const H223ChannelParam& that);
+
+        void SetLcnParams(PS_H223LogicalChannelParameters lcp);
+
+        void SetDataType(PS_DataType dt);
+
+        void Clear();
+
+        PS_H223LogicalChannelParameters GetLcnParams();
+
+        PS_DataType GetDataType();
+
+        void SetChannelId(TPVChannelId id);
+
+        TPVChannelId GetChannelId();
+        unsigned GetBitrate();
+        unsigned GetSampleInterval();
+        unsigned GetFormatSpecificInfo(uint8*& fsi);
+    private:
+        TPVChannelId lcn;
+        PS_H223LogicalChannelParameters pH223Lcp;
+        PS_DataType pDataType;
+        unsigned bitrate;
+        unsigned sample_interval;
+};
+
+enum OlcState
+{
+    OLC_IDLE = 0x1,
+    OLC_PENDING = 0x2,
+    OLC_ESTABLISHED = 0x4,
+    OLC_CLOSING = 0x8,
+    OLC_CLOSED = 0x10,
+    OLC_STATE_UNKNOWN = 0x1F
+};
+
+enum MtState
+{
+    MT_IDLE = 0x1,
+    MT_PENDING = 0x2,
+    MT_COMPLETE = 0x4,
+    MT_RELEASING = 0x8,
+    MT_RELEASED = 0x10,
+    MT_STATE_UNKNOWN = 0x1F
+};
+
+class OlcParam
+{
+    public:
+        static OlcParam* NewL(TPVDirection dir, TPVChannelId iId, H223ChannelParam* forward_params, H223ChannelParam* reverse_params = NULL);
+        ~OlcParam();
+        void SetState(OlcState state);
+
+        TPVDirection GetDirection();
+        TPVChannelId GetChannelId();
+        OlcState GetState();
+        TPVDirectionality GetDirectionality();
+        H223ChannelParam* GetForwardParams();
+        H223ChannelParam* GetReverseParams();
+        void SetMtState(MtState state);
+        MtState GetMtState();
+        void SetMtSn(int32 sn);
+        int32 GetMtSn()const;
+        void SetMtNum(uint32 num);
+        uint32 GetMtNum()const;
+        void SetReplacementFor(TPVChannelId id);
+        TPVChannelId GetReplacementFor();
+        void InitOlc(TPVDirection dir,
+                     TPVChannelId id,
+                     PS_DataType dt,
+                     PS_H223LogicalChannelParameters lcp,
+                     TPVChannelId idRvs = CHANNEL_ID_UNKNOWN,
+                     PS_DataType dtRvs = NULL,
+                     PS_H223LogicalChannelParameters lcpRvs = NULL);
+        bool IsMyType(int type)
+        {
+            return type == iMyType;
+        }
+        friend class OlcList;
+    protected:
+        OlcParam();
+        void Set(TPVDirection dir, TPVChannelId iId, H223ChannelParam* forward_params, H223ChannelParam* reverse_params);
+        int iMyType;
+
+    private:
+        TPVDirection iDir;
+        TPVChannelId iId;
+        OlcState iState;
+        H223ChannelParam* iForwardParams;
+        H223ChannelParam* iReverseParams;
+        MtState iMtState;
+        int32 iMtSn; /* while Pending, it is >0 */
+        uint32 iMtNum; /* Is valid while pending and established */
+        TPVChannelId iReplacementForChannelId;
+};
+
+class OlcKey
+{
+    public:
+        OlcKey(): iDir(PV_DIRECTION_BOTH), iId(0) {}
+        OlcKey(TPVDirection dir, TPVChannelId id) : iDir(dir), iId(id) {}
+        TPVDirection iDir;
+        TPVChannelId iId;
+};
+
+inline int operator < (const OlcKey& a, const OlcKey& b)
+{
+    if (a.iDir == b.iDir)
+    {
+        return (a.iId < b.iId);
+    }
+    return (a.iDir < b.iDir);
+}
+
+class OlcList:  public Oscl_Map<OlcKey, OlcParam*, OsclMemAllocator>
+{
+    public:
+        OlcList();
+        ~OlcList();
+        unsigned FindCodecs(TPVDirection dir,
+                            PV2WayMediaType media_type,
+                            unsigned states,
+                            TPVDirection owner,
+                            Oscl_Vector<OlcFormatInfo, OsclMemAllocator>& list);
+        bool FindCodec(TPVDirection dir,
+                       PV2WayMediaType media_type,
+                       unsigned states,
+                       TPVDirection owner,
+                       OlcFormatInfo& info);
+        unsigned FindOutgoingOlcsByMtState(unsigned states,
+                                           Oscl_Vector<OlcParam*, OsclMemAllocator>& list);
+
+        bool IsSymmetric(PV2WayMediaType media_type,
+                         unsigned outgoing_states,
+                         unsigned incoming_states);
+        bool IsSymmetric(PV2WayMediaType media_type,
+                         TPVDirection out_owner,
+                         unsigned outgoing_states,
+                         TPVDirection in_owner,
+                         unsigned incoming_states);
+        void Clear();
+
+        bool HasOlcs(TPVDirection dir,
+                     PV2WayMediaType media_type,
+                     unsigned states);
+        bool HasOlc(TPVDirection dir, TPVChannelId lcn);
+        bool HasOlc(TPVDirection dir, TPVChannelId lcn, unsigned state);
+        void SetCurrLcn(TPVChannelId aCurLcn);
+        TPVChannelId GetNextAvailLcn();
+        unsigned FindOlcs(TPVDirection dir,
+                          PV2WayMediaType media_type,
+                          unsigned states,
+                          Oscl_Vector<OlcParam*, OsclMemAllocator>& list);
+        OlcParam* FindOlc(TPVDirection dir,
+                          PV2WayMediaType media_type,
+                          unsigned states);
+        OlcParam* FindOlcGivenChannel(TPVDirection dir, TPVChannelId lcn);
+
+        OlcParam* FindOlcByMtSn(uint32 sn);
+
+        void AppendOlc(OlcParam* param,
+                       TPVDirection dir,
+                       TPVChannelId id);
+
+        OlcParam* AppendOlc(TPVDirection dir,
+                            TPVChannelId id,
+                            PS_DataType dt,
+                            PS_H223LogicalChannelParameters lcp,
+                            TPVChannelId idRvs = CHANNEL_ID_UNKNOWN,
+                            PS_DataType dtRvs = NULL,
+                            PS_H223LogicalChannelParameters lcpRvs = NULL);
+
+
+    private:
+        TPVChannelId iCurLcn;
+};
+
+
+class TPVMuxDescriptorSlot
+{
+    public:
+        unsigned lcn;
+        unsigned min_size;
+        unsigned max_size;
+        int is_fit(unsigned that_lcn, unsigned size);
+};
+
+typedef Oscl_Map<unsigned , TPVMuxDescriptorSlot, PoolMemAlloc_OsclMemAllocator_10> TPVMuxDescriptorSlotList;
+
+class CPVMultiplexEntryDescriptor
+{
+    public:
+        OSCL_IMPORT_REF static CPVMultiplexEntryDescriptor* NewL(PS_MultiplexEntryDescriptor descriptor, unsigned max_pdu_size);
+        OSCL_IMPORT_REF CPVMultiplexEntryDescriptor(const CPVMultiplexEntryDescriptor& that);
+        OSCL_IMPORT_REF ~CPVMultiplexEntryDescriptor();
+        OSCL_IMPORT_REF unsigned NumLcns();
+        OSCL_IMPORT_REF int FindLcn(uint16 channel_id, uint16 len, TPVMuxDescriptorSlot& slot_info);
+        OSCL_IMPORT_REF PS_MultiplexEntryDescriptor GetH245descriptor();
+    private:
+        CPVMultiplexEntryDescriptor();
+        void ConstructL(PS_MultiplexEntryDescriptor descriptor, unsigned max_pdu_size);
+
+        unsigned FindLcns(
+            PS_MultiplexElement pElement,
+            int ListSize,
+            int max_size,
+            TPVMuxDescriptorSlotList& lcns,
+            int* sublelement_size);
+
+        PS_MultiplexEntryDescriptor iDescriptor;
+        unsigned iMaxPduSize;
+        TPVMuxDescriptorSlotList iLcns;
+};
+
+class CPVMultiplexEntryDescriptorVector : public Oscl_Vector<CPVMultiplexEntryDescriptor*, OsclMemAllocator>
+{
+    public:
+        OSCL_IMPORT_REF CPVMultiplexEntryDescriptorVector();
+        OSCL_IMPORT_REF CPVMultiplexEntryDescriptorVector(const CPVMultiplexEntryDescriptorVector& that);
+        OSCL_IMPORT_REF ~CPVMultiplexEntryDescriptorVector();
+        OSCL_IMPORT_REF void Clear();
+};
+
+typedef PoolMemAlloc<8> PoolMemAlloc_OsclMemAllocator_8;
+typedef PoolMemAlloc<MAX_H223_PDU_PACKETS_PER_SEND, 512> PoolMemAlloc_OsclMemAllocator_MAX_H223_PDU_PACKETS_PER_SEND;
+typedef Oscl_Vector<OsclSharedPtr<PVMFMediaDataImpl>, OsclMemAllocator> MuxPduPacketList;
+
+
+#endif	/* _h223api_H */
diff --git a/protocols/systems/3g-324m_pvterminal/common/include/h324utils.h b/protocols/systems/3g-324m_pvterminal/common/include/h324utils.h
new file mode 100644
index 0000000..c6fb632
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/include/h324utils.h
@@ -0,0 +1,216 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef	_h324utils_h
+#define _h324utils_h
+#include "pvt_params.h"
+#include "h245def.h"
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#include "pvt_common.h"
+
+#define MAX_NUM_SIMULTANEOUS_CAPABILITIES 31
+#define MAX_CONFIG_INFO_SIZE 128
+#define MAX_H264_FORMAT_SPECIFIC_INFO_LEN 128
+#define DEF_AL3_SEND_BUFFER_SIZE 1024
+
+/* Generic logger macros for using across the protocol stack node */
+#define PVMF_INCOMING_VIDEO_LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iIncomingVideoLogger,PVLOGMSG_INFO,m);
+#define PVMF_INCOMING_AUDIO_LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iIncomingAudioLogger,PVLOGMSG_INFO,m);
+#define PVMF_OUTGOING_AUDIO_LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iOutgoingAudioLogger,PVLOGMSG_INFO,m);
+#define PVMF_OUTGOING_VIDEO_LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iOutgoingVideoLogger,PVLOGMSG_INFO,m);
+
+
+#define PV2WAY_FILLER_FSI_LEN 9
+#define PV2WAY_FILLER_FSI {1,2,3,4,5,6,7,8,9}
+
+
+/* Allocator for TSC */
+class PVMFTscAlloc : public Oscl_DefAlloc
+{
+    public:
+        void* allocate(const uint32 size)
+        {
+            void* tmp = (void*)oscl_malloc(size);
+            return tmp;
+        }
+
+        void deallocate(void* p)
+        {
+            oscl_free(p);
+        }
+};
+
+/* Removed C Linkage - Glk - Due to overloaded fxns
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+  */
+struct MultiplexCapabilityInfo
+{
+    bool iAllowAl1Video;
+    bool iAllowAl2Video;
+    bool iAllowAl3Video;
+    bool iAllowAl1Audio;
+    bool iAllowAl2Audio;
+    bool iAllowAl3Audio;
+    unsigned iMaximumAl2SDUSize;
+    unsigned iMaximumAl3SDUSize;
+};
+
+typedef struct S_CapabilityIdentifierStandard
+{
+    uint8 reserved1;
+    uint8 itu; /* 0 = t */
+    uint8 spec_type; /* 0==recommendation */
+    uint8 series_letter; /* h = 8 */
+    uint32 spec_number; /* 245,241 etc */
+    uint8 data[4];
+}* PS_CapabilityIdentifierStandard;
+
+
+PVAudTypeSimple_t GetSimpleAudioType(PVAudType_t);
+
+PVCodecType_t GetCodecType(PS_DataType pDataType);
+PV2WayMediaType GetMediaType(PS_DataType pDataType);
+PVCodecType_t GetVidCodecTypeFromVideoCapability(PS_VideoCapability capability);
+PVCodecType_t GetVidCodecTypeFromCapabilityIdentifier(S_CapabilityIdentifierStandard& identifier);
+PVCodecType_t GetAudCodecTypeFrom245Index(int32 index);
+PVCodecType_t GetAudCodecType(PS_GenericCapability audio_capability);
+PVCodecType_t GetAudCodecType(PS_AudioCapability audio_capability);
+PVCodecType_t GetUiCodecTypeFrom245Index(int32 index);
+void GetCodecInfo(PS_Capability capability, CodecCapabilityInfo& info);
+ErrorProtectionLevel_t GetEpl(uint16 al_index);
+void printBuffer(PVLogger* logger, const uint8* buffer, uint16 len);
+unsigned GetFormatSpecificInfo(PS_DataType pDataType, uint8*& fsi);
+PS_Capability LookupCapability(PS_TerminalCapabilitySet pTcs, uint16 cap_entry_num);
+bool IsTransmitOnlyAltCapSet(PS_TerminalCapabilitySet pTcs, PS_AlternativeCapabilitySet pAltCapSet);
+PVMFStatus VerifyCodecs(PS_TerminalCapabilitySet pTcs,
+                        Oscl_Vector<OlcFormatInfo, OsclMemAllocator> codecs,
+                        PVLogger *logger);
+PVMFStatus GetCodecCapInfo(PVCodecType_t codec,
+                           PS_TerminalCapabilitySet pTcs,
+                           CodecCapabilityInfo& codec_info,
+                           PVLogger *logger);
+uint32 CheckAltCapSet(PS_AlternativeCapabilitySet pAltCapSet, uint32 entry);
+PS_TerminalCapabilitySet GenerateTcs(MultiplexCapabilityInfo& mux_cap_info,
+                                     Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& outgoing_codecs,
+                                     Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& incoming_codecs);
+void FillCapabilityTableEntry(PS_CapabilityTableEntry, CodecCapabilityInfo& codec_info, uint32 entry_num);
+void FillCapability(CodecCapabilityInfo& codec_info, PS_Capability capability);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_Capability capability);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_GenericCapability capability);
+void FillVideoCapability(VideoCodecCapabilityInfo& codec_info, PS_VideoCapability video_capability);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_VideoCapability capability);
+void FillAudioCapability(CodecCapabilityInfo& codec_info, PS_AudioCapability audio_capability);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_AudioCapability capability);
+void FillH263Capability(VideoCodecCapabilityInfo& video_codec_info, PS_H263VideoCapability h263caps);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_H263VideoCapability capability);
+void FillG723Capability(PS_G7231 g723caps);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_G7231 capability);
+void FillAmrCapability(PS_GenericCapability amrCaps);
+CodecCapabilityInfo* GetCodecCapabilityInfoAmr(PS_GenericCapability capability);
+#if 0
+void FillH264Capability(VideoCodecCapabilityInfo& video_codec_info, PS_GenericCapability h264caps, bool includeCsi);
+#endif
+CodecCapabilityInfo* GetCodecCapabilityInfoAvc(PS_GenericCapability capability);
+#if 0
+void ParseH264Capability(PS_GenericCapability h264caps, CPvtAvcCapability& h264Capability);
+#endif
+void FillM4vCapability(VideoCodecCapabilityInfo& video_codec_info, PS_GenericCapability m4vcaps);
+CodecCapabilityInfo* GetCodecCapabilityInfoMpeg4(PS_GenericCapability capability);
+void FillUserInputCapability(CodecCapabilityInfo& codec_info, PS_UserInputCapability userinputCaps);
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_UserInputCapability capability);
+void ParseCapabilityIdentifierStandard(uint8* octet_string, uint16 octet_string_len, S_CapabilityIdentifierStandard& capabilityIdentifier);
+unsigned GetMaxFrameRate(PS_DataType pDataType);
+unsigned GetMaxFrameRate_H263(PS_H263VideoCapability h263caps);
+unsigned GetMaxFrameRate_M4V(PS_GenericCapability m4vcaps);
+unsigned GetMaxFrameRate_AVC(PS_GenericCapability avcCaps);
+unsigned GetMaxBitrate(PS_DataType pDataType);
+unsigned GetVideoFrameSize(PS_DataType pDataType, bool width);
+unsigned GetVideoFrameSize_H263(PS_H263VideoCapability h263caps, bool width);
+unsigned GetVideoFrameSize_M4V(PS_GenericCapability m4vcaps , bool width);
+
+bool FindCodecForMediaType(PV2WayMediaType media, Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>&list, int* index);
+bool IsSupported(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& list, PV2WayMediaType media, CodecCapabilityInfo& codec_info, int*index);
+CodecCapabilityInfo* IsSupported(CodecCapabilityInfo* codecInfo,
+                                 Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& list);
+bool IsResolutionSupported(const PVMFVideoResolution& resolution, const Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& resolutions);
+unsigned GetSampleInterval(PS_DataType pDataType);
+bool PVCheckSH(uint8 *ptr, int32 size);
+
+PS_H223LogicalChannelParameters
+GetH223LogicalChannelParameters(uint8 al_index,
+                                bool segmentable,
+                                uint32 al_specific = 0);
+/** Returns 1 if only one media type is present in the ACS.
+   Returns 2 if there are more than one media type
+   **/
+uint16 GetCodecCapabilityInfo(PS_TerminalCapabilitySet pTcs,
+                              PS_AlternativeCapabilitySet pAcs,
+                              Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& in_codecs_acs);
+void Deallocate(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& cci);
+PVMFStatus SetFormatSpecificInfo(PS_DataType pDataType, uint8* fsi, uint32 fsi_len);
+uint32 SetFillerFsi(uint8* dest, uint32 dest_len);
+bool IsFillerFsi(uint8* fsi, uint32 fsi_len);
+
+/*
+#ifdef __cplusplus
+}
+#endif*/
+
+#define LOG_STATISTICS
+
+#if defined(LOG_STATISTICS)
+#define PV_STAT_SET(a, b)\
+a  = b;
+#else
+#define PV_STAT_SET(a, b)
+#endif
+
+#if defined(LOG_STATISTICS)
+#define PV_STAT_INCR(a, b)\
+a  += b;
+#else
+#define PV_STAT_INCR(a, b)
+#endif
+
+#if defined(LOG_STATISTICS)
+#define PV_STAT_INCR_COND(a, b, c)\
+if(c){\
+	a  += b;\
+}
+#else
+#define PV_STAT_INCR_COND(a, b, c)
+#endif
+
+#if defined(LOG_STATISTICS)
+#define PV_STAT_SET_TIME(a, cond)\
+{\
+if(cond == 0){\
+	TimeValue timenow;\
+	a = timenow;\
+}\
+}
+#else
+#define PV_STAT_SET_TIME(a, cond)
+#endif
+
+#endif	/* _h324utils_h */
diff --git a/protocols/systems/3g-324m_pvterminal/common/include/pv_2way_h324m_interface.h b/protocols/systems/3g-324m_pvterminal/common/include/pv_2way_h324m_interface.h
new file mode 100644
index 0000000..496aee3
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/include/pv_2way_h324m_interface.h
@@ -0,0 +1,446 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
+#define TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVT_COMMON_H_INCLUDED
+#include "pv_2way_h324m_types.h"
+#endif
+
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+
+#define PVH324MConfigUuid PVUuid(0x2b0b54e2,0x7079,0x46c6,0xb2,0x3e,0x04,0xff,0xd3,0x0e,0x14,0x36)
+
+
+/**
+ * H324MConfigInterface Class
+ *
+ * H324MConfigInterface provides H.324m specific configuration APIs.
+ **/
+class H324MConfigInterface : public PVInterface
+{
+    public:
+        /**
+         * This API allows the user to specify separate observers for the 324m interface.  Otherwise, the default
+         * observers will be used
+         *
+         * @param aObserver        the observer for command status and for unsolicited informational events
+         **/
+        virtual void SetObservers(PVCommandStatusObserver* aCmdStatusObserver,
+                                  PVInformationalEventObserver* aInfoEventObserver,
+                                  PVErrorEventObserver* aErrorEventObserver) = 0;
+
+        /**
+         * This API allows the user to specify the starting H223 multiplex level
+         *
+         * @param aLevel
+         *			The starting H223 multiplex level.  Note that the final level that is neotiated will depend
+         *          on the starting level of the peer
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetMultiplexLevel(PVH223Level aLevel,
+                                              OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify maximum outgoing sdu sizes for each adaptation layer
+         *
+         * @param aLayer
+         *			The h223 adaptation layer type
+         * @param aSize
+         *			The sdu size
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetMaxSduSize(PVH223AdaptationLayer aLayer,
+                                          int32 aSize,
+                                          OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify maximum incoming sdu sizes for each adaptation layer.  This is indicated
+         * to the peer via the TCS
+         *
+         * @param aLayer
+         *			The h223 adaptation layer type
+         * @param aSize
+         *			The sdu size
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetMaxSduSizeR(PVH223AdaptationLayer aLayer,
+                                           int32 aSize,
+                                           OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify the configuration for outgoing AL channels
+         *
+         * @param aMediaTypes
+         *          Media types for which configuration is being specified
+         * @param aConfig
+         *			Adaptation Layer configuration
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetOutgoingChannelConfiguration(int32 aMediaTypes,
+                PVH223AlConfig* aConfig,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify the configuration for incoming channels
+         *
+         * @param iAudioAdaptationLayers
+         *          The allowable adaptation layers for incoming audio channels specified as a bitarray
+         * @param iVideoAdaptationLayers
+         *          The allowable adaptation layers for incoming video channels specified as a bitarray
+         * @param iDataAdaptationLayers
+         *          The allowable adaptation layers for incoming data channels specified as a bitarray
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetIncomingChannelConfiguration(uint32 iAudioAdaptationLayers,
+                uint32 iVideoAdaptationLayers,
+                uint32 iDataAdaptationLayers,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to limit the size of the outgoing h223 pdus
+         *
+         * @param aMaxPduSize
+         *			The max pdu size
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetMaxPduSize(int32 aMaxPduSize,
+                                          OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify the terminal type that is advertized to the peer.  This can be used to
+         * force the local terminal to be master/slave when communicating with a peer 324m terminal for testing purposes.
+         *
+         * @param aTerminalType The terminal type
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetTerminalType(uint8 aTerminalType,
+                                            OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify whether Request Multiplex Entry is sent to the remote terminal after TCS
+         *
+         * @param aSendRme If true, RME is sent to the peer after TCS
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SendRme(OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API causes a maxMuxPduSize request to be sent to the remote terminal if set to a valid value (64 - 255).
+        	   This is done after TCS if the remote terminal supports the maxMuxPduCapability
+         *
+         * @param aRequestMaxMuxPduSize The max mux pdu size
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetMaxMuxPduSize(int32 aRequestMaxMuxPduSize,
+                                             OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API sets the max ccsrl sdu size
+         *
+         * @param aMaxCcsrlSduSize The max ccsrl sdu size
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetMaxMuxCcsrlSduSize(int32 aMaxCcsrlSduSize,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API may be called only after the media source has been successfully added
+         * to the pv2way engine.  It causes the 2way engine to immediately send out a fast update frame
+         * specific to the media type identified by the aTrack parameter.
+         * @param aChannelId
+         *         The identifier for the track
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+
+         * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVCommandId FastUpdate(PVChannelId aChannelId,
+                                       OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Sends a Round Trip Determination message to the peer and indicates the round trip delay to the caller
+         * on completion of the command.  The round trip delay is stored in 4 bytes in the local buffer of the completion event
+         * in network byte order.
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SendRtd(OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Sets the vendor identification data.  This does not cause the stack to issue a vendor identifiation request.
+         * Set to NULL to disable sending vendor id.  If set to a valid parameter before Connect, it will cause the stack
+         * to automatically send it along with the TCS message.
+         * @param cc
+         *         T35 Country code
+         * @param ext
+         *         T35 Extension
+         * @param mc
+         *         T35 Manufacturer code
+         * @param aProduct
+         *         Product number
+         * @param aVersion
+         *         Version number
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetVendor(uint8 cc, uint8 ext, uint32 mc,
+                                      const uint8* aProduct, uint16 aProductLen,
+                                      const uint8* aVersion, uint16 aVersionLen,
+                                      OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Sends an end session command to the peer.  Only to be used for testing purposes.
+         *
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SendEndSession(OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Sets the disconnect timeout interval.
+         *
+         * @param aTimeout The timeout value in seconds
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SetEndSessionTimeout(uint32 aTimeout,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Sets an H.324 timer/counter value.  This should be called before ConnectL is invoked.
+         * The  supported timers are:
+         *		T106	Master Slave Determination (in units of 1s)
+         *		T101	Capability Exchange (in units of 1s)
+         *		T103	Uni-directional and Bi-directional Logical Channel Signalling (in units of 1s)
+         *		T108	Close Logical Channel (in units of 1s)
+         *		T104	H.223 Multiplex Table (in units of 1s)
+         *		T109	Mode Request (in units of 1s)
+         *		T105	Round Trip Delay (in units of 1s)
+         *		T107	Request Multiplex Entry (in units of 100ms)
+         *      T401    SRP retransmission (in units of 100ms)
+         * The supported counters are:
+         *      N100	H245 (TCS, MSD)
+         *      N401    SRP retransmission
+         * @param aTimerCounter
+         *         Identifies whether a timer or counter is being set.
+         * @param aSeries
+         *         Identifies the H.324 timer/counter series.
+         * @param aSeriesOffset
+         *         Specifies the offset within a particular series.
+         *         E.g.
+         *              aTimerCounter=EH324Timer, aSeries=1, aSeriesOffset=1 indicates T101.
+         *              aTimerCounter=EH324Timer, aSeries=4, aSeriesOffset=1 indicates T401.
+         *              aTimerCounter=EH324Counter, aSeries=4, aSeriesOffset=1 indicates T401.
+         * @param aValue
+         *         The new value for the H.324 timer/counter
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         **/
+        virtual PVCommandId SetTimerCounter(PVH324TimerCounter aTimerCounter,
+                                            uint8 aSeries, uint32 aSeriesOffset,
+                                            uint32 aValue,
+                                            OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to specify the supported resolutions for video for transmit and receive.
+         *
+         * @param aDirection
+         *         The direction (Tx/Rx) for which the capability is specified.
+         * @param aResolutions
+         *         An array of resolutions.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         **/
+        virtual PVCommandId SetVideoResolutions(PVDirection aDirection,
+                                                Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+                                                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to send the vendor id info to the peer.
+         * Note:  Calling this API during call-setup negotiations can affect the time for
+         * call-setup adversely.
+         *
+         **/
+        virtual PVCommandId SendVendorId(OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to send a videoTemporalSpatialTradeOff command to the peer.
+         * It is a request to the remote encoder to adjust its encoding in accordance with the tradeoff value.
+         * A value of 0 indicates a high spatial resolution and a value of 31 indicates a high frame rate.
+         * The values from 0 to 31 indicate monotonically a higher frame rate. Actual values do not correspond
+         * to precise values of spatial resolution or frame rate.
+         *
+         **/
+        virtual PVCommandId SendVideoTemporalSpatialTradeoffCommand(PVChannelId aLogicalChannel,
+                uint8 aTradeoff,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to send a videoTemporalSpatialTradeOff command to the peer.
+         * It is an indication to the remote decoder that the local encoder has adjusted its encoding parameters
+         * according to the tradeoff value.
+         * A value of 0 indicates a high spatial resolution and a value of 31 indicates a high frame rate.
+         * The values from 0 to 31 indicate monotonically a higher frame rate. Actual values do not correspond
+         * to precise values of spatial resolution or frame rate.
+         *
+         **/
+        virtual PVCommandId SendVideoTemporalSpatialTradeoffIndication(PVChannelId aLogicalChannel,
+                uint8 aTradeoff,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * This API allows the user to send a SkewIndication to the peer.
+         * Skew is measured in milliseconds, and indicates the maximum number of milliseconds that the data on
+         * logicalChannel2 is delayed from the data on logicalChannel1 as delivered to the network transport.
+         *
+         **/
+        virtual PVCommandId SendSkewIndication(PVChannelId aLogicalChannel1,
+                                               PVChannelId aLogicalChannel2,
+                                               uint16 aSkew,
+                                               OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to configure the logical channel buffer sizes for incoming
+        * and outgoing logical channels.
+         * @param aDirection
+         *         The direction (Rx or Tx).
+         * @param aBufferingMs
+         *         The amount of buffering in milliseconds.
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+        **/
+        virtual PVCommandId SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                uint32 aOutBufferingMs,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Causes the pv2way to send the specified user input to the remote terminal using
+         * control channel.  The user input can be either DTMF ot Alphanumeric
+         * @param user_input A pointer to either CPVUserInputDtmf or CPVUserInputAlphanumeric
+         * @param aContextData
+         *         Optional opaque data that will be passed back to the user with the command response
+         *
+         * @returns A unique command id for asynchronous completion
+         **/
+        virtual PVCommandId SendUserInput(CPVUserInput* user_input,
+                                          OsclAny* aContextData = NULL) = 0;
+
+};
+
+/**
+ * PVH324MIndicationType enum
+ *
+ *  Enumeration of unsolicited H324m specific indications from pv2way.
+ *
+ **/
+enum PVH324MIndicationType
+{
+    /**
+     * Indicates the receipt of a videoSpatialTemporalTradeoff command from the peer.
+     * The first 2 bytes of the event local buffer indicate the logical channel (network byte order) and the 3rd
+     * byte indicates the tradeoff value.
+     *
+     **/
+    PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND,
+    /**
+     * Indicates the receipt of a videoSpatialTemporalTradeoff indication from the peer.
+     * The first 2 bytes of the event local buffer indicate the logical channel (network byte order) and the 3rd
+     * byte indicates the tradeoff value.
+     *
+     **/
+    PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION,
+    /**
+     * Indicates a fast update message from the remote terminal.  The first two bytes of the
+     * local buffer encode the logical channel number in network byte order.
+     *
+     **/
+    PV_INDICATION_FAST_UPDATE,
+    /**
+     * Indicates an incoming RTD command.
+     *
+     **/
+    PV_INDICATION_RTD,
+    /**
+     * Indicates an incoming request multiplex entry command.
+     *
+     **/
+    PV_INDICATION_RME,
+    /**
+     * Indicates an incoming vendor id indication message.
+     *
+     **/
+    PV_INDICATION_VENDOR_ID,
+    /**
+     * Indicates the receipt of user input capability from the remote terminal.  The local buffer
+     * contains the indices of the user input formats supported by the peer.
+     *
+     **/
+    PV_INDICATION_USER_INPUT_CAPABILITY,
+    /**
+     * Indicates the receipt of user input from the remote terminal.  The derived class
+     * contains the actual user input sequences received.
+     *
+     **/
+    PV_INDICATION_USER_INPUT,
+    /**
+     * Indicates the receipt of a an h223SkewIndication indication from the peer.
+     * The first 2 bytes of the event local buffer indicate the first logical channel, the 3rd and
+     * 4th bytes the second logical channel and the 5th and 6th bytes the value of the skew in milliseconds.
+     * All values are in network byte order.
+     *
+     **/
+    PV_INDICATION_SKEW
+};
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/common/include/pv_2way_h324m_types.h b/protocols/systems/3g-324m_pvterminal/common/include/pv_2way_h324m_types.h
new file mode 100644
index 0000000..d6b3956
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/include/pv_2way_h324m_types.h
@@ -0,0 +1,197 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PV_2WAY_H324M_TYPES_H_INCLUDED
+#define PV_2WAY_H324M_TYPES_H_INCLUDED
+
+#ifndef PV_2WAY_BASIC_TYPES_H_INCLUDED
+#include "pv_2way_basic_types.h"
+#endif
+
+// MACROS
+/** The maximum number of supported formats for user input **/
+#define PV_2WAY_MAX_USER_INPUT_FORMATS 4
+/** The maximum skew that can be taken into account for both outgoing and incoming sides **/
+#define PV_2WAY_MAX_SKEW_MS 1000
+
+/**
+ * TPVPostDisconnectOption Enum
+ *
+ * TPVPostDisconnectOption emumerates the mode the peer wants to transition to after the disconnect
+ **/
+typedef enum TPVPostDisconnectOption
+{
+    EDisconnectLine,
+    EAnalogueTelephony
+}PV2WayPostDisconnectOption;
+
+
+/**
+TPVUserInputType enum
+Enumeration of user input types
+**/
+typedef enum TPVUserInputType
+{
+    EAlphanumeric = 0,
+    EDtmf,
+}PV2WayUserInputType;
+
+/**
+ * PV2Way324InitInfo Class
+ *
+ * PV2Way324InitInfo implements the PV2Way324InitInfo interface
+ * and is used for 324M specific initialization.
+ *
+ **/
+
+class PV2Way324InitInfo : public PV2WayInitInfo
+{
+    public:
+        /**
+         * Retrieves the class name
+         *
+         * @param aClassName
+         *         A reference to an OSCL_wString, which is to hold the subclass
+         *          name, this class will assign the string "CPV2Way324InitInfo"
+         * @returns void
+         **/
+        virtual void GetInitInfoClassName(OSCL_wString &aClassName)
+        {
+            aClassName = _STRLIT_WCHAR("CPV2Way324InitInfo");
+        }
+        PV2Way324InitInfo() : PV2WayInitInfo(), iMultiplexingDelayMs(0) {};
+        virtual ~PV2Way324InitInfo() {};
+
+        /**
+        *  The Multiplexing delay in Milliseconds
+        **/
+        uint16 iMultiplexingDelayMs;
+};
+
+
+/**
+ * PV2Way324ConnectOptions Class
+ *
+ * PV2Way324ConnectOptions implements the PV2WayConnectOptions interface
+ * and is used for 324M specific initialization.
+ *
+ **/
+class PV2Way324ConnectOptions : public PV2WayConnectOptions
+{
+    public:
+        /**
+         * Constructor
+         * @param disconnectTimeout
+         *         The interval to wait after initiating a disconnect before stopping signalling
+         *
+         **/
+        PV2Way324ConnectOptions(uint32 aDisconnectTimeoutInterval)
+                : iDisconnectTimeoutInterval(aDisconnectTimeoutInterval) {}
+
+        PV2Way324ConnectOptions() : PV2WayConnectOptions(), iDisconnectTimeoutInterval(0) {};
+        virtual ~PV2Way324ConnectOptions() {};
+
+        /**
+         * Retrieves the class name
+         *
+         * @param aClassName
+         *         A reference to an OSCL_wString, which is to hold the subclass
+         *          name, this class will assign the string "CPV2Way324ConnectInfo"
+         * @returns void
+         **/
+        virtual void GetConnectInfoClassName(OSCL_wString &aClassName)
+        {
+            aClassName = _STRLIT_WCHAR("PV2Way324ConnectOptions");
+        }
+
+        /**
+        * The disconnect timeout interval in units of 100ms
+        **/
+        uint32 iDisconnectTimeoutInterval;
+};
+
+/**
+ * PVH223AlConfig class
+ *
+ * This is the base class for H.223 Adaptation Layer configuration
+ *
+ **/
+class PVH223AlConfig
+{
+    public:
+        enum PVH223AlIndex
+        {
+            PVH223_AL1 = 1,
+            PVH223_AL2 = 2,
+            PVH223_AL3 = 4
+        };
+        virtual PVH223AlIndex IsA() const = 0;
+};
+
+
+/**
+ * PVH223Al1Config class
+ *
+ * This class defines configuration information for H.223 Adaptation Layer 1
+ *
+ **/
+class PVH223Al1Config : public PVH223AlConfig
+{
+    public:
+        PVH223AlIndex IsA()const
+        {
+            return PVH223_AL1;
+        }
+
+        bool iFramed;
+};
+
+/**
+ * PVH223Al2Config class
+ *
+ * This class defines configuration information for H.223 Adaptation Layer 2
+ *
+ **/
+class PVH223Al2Config : public PVH223AlConfig
+{
+    public:
+        PVH223AlIndex IsA()const
+        {
+            return PVH223_AL2;
+        }
+
+        bool iUseSequenceNumbers;
+};
+
+/**
+ * PVH223Al3Config class
+ *
+ * This class defines configuration information for H.223 Adaptation Layer 3
+ *
+ **/
+class PVH223Al3Config : public PVH223AlConfig
+{
+    public:
+        PVH223AlIndex IsA()const
+        {
+            return PVH223_AL3;
+        }
+
+        uint32 iControlFieldOctets;
+        uint32 iSendBufferSize;
+};
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/common/include/pvt_common.h b/protocols/systems/3g-324m_pvterminal/common/include/pvt_common.h
new file mode 100644
index 0000000..4cad745
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/include/pvt_common.h
@@ -0,0 +1,1283 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef PVT_COMMON_H_INCLUDED
+#define PVT_COMMON_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_DEFALLOC_H_INCLUDED
+#include "oscl_defalloc.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+#ifndef OSCL_SHARED_PTR_H_INCLUDED
+#include "oscl_shared_ptr.h"
+#endif
+
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+
+#ifndef PVT_2WAY_BASIC_TYPES_H_INCLUDED
+#include "pv_2way_basic_types.h"
+#endif
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#ifndef PVMF_RETURN_CODES_H
+#include "pvmf_return_codes.h"
+#endif
+
+#ifndef PVMF_VIDEO_H_INCLUDED
+#include "pvmf_video.h"
+#endif
+
+#ifndef PVMF_TIMESTAMP_H_INCLUDED
+#include "pvmf_timestamp.h"
+#endif
+
+#ifndef PV_INTERFACE_H
+#include "pv_interface.h"
+#endif
+
+#ifndef PV_2WAY_H324M_TYPES_H_INCLUDED
+#include "pv_2way_h324m_types.h"
+#endif
+
+#include "h245def.h"
+
+#define REVERSE_DIR(dir) (TPVDirection)(PV_DIRECTION_BOTH-dir)
+
+typedef int TPVStatusCode;
+
+/**
+ * TPV2wayDirectionality Enum
+ *
+ * TPV2wayDirectionality enum is used to convey the directionality of a pv2way track
+ **/
+enum TPV2wayDirectionality
+{
+    EPvtUnidirectional = 1,
+    EPvtBiDirectional
+};
+
+
+typedef enum
+{
+    PV_MUX_COMPONENT_MUX,
+    PV_MUX_COMPONENT_LOGICAL_CHANNEL,
+} TPVMuxComponent;
+
+/**
+Enumeration of format types
+**/
+typedef enum
+{
+    PV_INVALID_CODEC_TYPE,
+    PV_AUD_TYPE_G723 = 1,
+    PV_AUD_TYPE_GSM,
+    PV_VID_TYPE_H263 = 20,
+    PV_VID_TYPE_MPEG4,
+    PV_VID_TYPE_H264,
+    PV_UI_BASIC_STRING = 40,
+    PV_UI_IA5_STRING,
+    PV_UI_GENERAL_STRING,
+    PV_UI_DTMF,
+    PV_CODEC_TYPE_NONE = 99
+}PVCodecType_t;
+
+typedef uint32 TPVChannelId;
+#define CHANNEL_ID_UNKNOWN 0xFFFFFFFF
+#define CHANNEL_ID_DEFAULT 0xFFFFFFFF
+
+/*********************************/
+/* H324 System Definition Value	 */
+/*********************************/
+//#define	OK	    1
+#define NG	    0
+#define	ON	    1
+#define OFF	    0
+#define PVT_NOT_SET (-1)
+
+const int KPVDefaultVideoBitRate = 42000; // bits/s
+const int KPVDefaultFrameRate = 5;	 // frames/s
+const int KPVDefaultIFrameInterval = 10000;  // s
+const int KPVDefaultIFrameRequestInterval = 10000;  // s
+
+
+typedef bool TPVRemoteTerminalType; /* same = true, other = false */
+
+enum TPVTerminalIdentifier
+{
+    EPVT_NONE = 0,
+    EPVT_LOCAL = 1,
+    EPVT_REMOTE = 2,
+    EPVT_BOTH = 3,
+    EPVT_TERMINAL_IDENTIFIER_MAX = EPVT_BOTH + 1
+};
+
+enum TPVDirectionality
+{
+    EPVT_UNI_DIRECTIONAL = 1,
+    EPVT_BI_DIRECTIONAL
+};
+
+enum TPVChannelSegmentableType
+{
+    NONSEGMENTABLE = 0,
+    SEGMENTABLE
+};
+
+
+typedef enum
+{
+    EPVT_Failed = 0,
+    EPVT_Success,
+    EPVT_Pending,
+
+    EPVT_ErrorBusy = 0x03000000,
+    //Terminal busy
+    EPVT_ErrorNotImplemented,
+    //feature or command is not implemented.
+    EPVT_ErrorInvalidParameter,
+    //invalid parameter in the command
+    EPVT_ErrorInvalidCodecType,
+    // invalid codec type specified in the command
+    EPVT_ErrorInvalidState,
+    //command is not valid for the current authoring state.
+    EPVT_ErrorNoMemory,
+    //system dynamic memory error
+    EPVT_ErrorLocalCapability,
+    // We cant handle it
+    EPVT_ErrorRemoteCapability,
+    // the other terminal cant handle it
+    EPVT_ErrorRemoteRejected,
+    // The remote terminal rejected it
+    EPVT_Timeout,
+    // No response received from the remote terminal
+    EPVT_FailedToInitialize,
+    // The specified component failed to initialize properly
+    EPVT_FailedToSetup,
+    // Could not setup the specified components with the specified parameters
+    EPVT_FailedToNegotiate,
+    // Failed to negotiate a set of parameters with the remote terminal
+    EPVT_ErrorRemoteDisconnected
+    // remote terminal disconnected while establishing connection
+} TPVTReturnStatus;
+
+
+enum TPVSeverity
+{
+    PVT_INFORMATIONAL = 0,
+    PVT_WARNING,
+    PVT_ERROR
+};
+
+typedef enum
+{
+    E_EP_LOW = 1,
+    E_EP_MEDIUM,
+    E_EP_HIGH
+}ErrorProtectionLevel_t;
+
+
+// Used to convey audio type down (App->324)
+typedef enum
+{
+    PV_AUD_TYPE_GSM_475 = 1,
+    PV_AUD_TYPE_GSM_515,
+    PV_AUD_TYPE_GSM_590,
+    PV_AUD_TYPE_GSM_670,
+    PV_AUD_TYPE_GSM_740,
+    PV_AUD_TYPE_GSM_795,
+    PV_AUD_TYPE_GSM_102,
+    PV_AUD_TYPE_GSM_122,
+    PV_AUD_TYPE_G723_53,
+    PV_AUD_TYPE_G723_63,
+    PV_AUD_TYPE_NONE = 99
+}PVAudType_t;
+
+
+const PVCodecType_t PV_VID_TYPE_NONE = PV_CODEC_TYPE_NONE ;
+const PVCodecType_t PV_SIMPLE_AUD_TYPE_NONE = PV_CODEC_TYPE_NONE ;
+
+typedef PVCodecType_t PVAudTypeSimple_t;
+
+// Used to convey video type (up or down)
+typedef PVCodecType_t PVVidType_t;
+
+/**
+CPVParam class
+Base class for audio/video/mux parameters
+**/
+class CPVParam
+{
+    public:
+        CPVParam() {}
+        virtual ~CPVParam() {}
+        virtual CPVParam* Copy() = 0;
+};
+
+class CPVMediaParam : public CPVParam
+{
+    public:
+        OSCL_IMPORT_REF CPVMediaParam(PVCodecType_t aCodecType = PV_CODEC_TYPE_NONE);
+        virtual ~CPVMediaParam();
+        virtual PV2WayMediaType GetMediaType() = 0;
+        OSCL_IMPORT_REF PVCodecType_t GetCodecType();
+    private:
+        PVCodecType_t iCodecType;
+};
+
+
+
+class CPVAudioParam : public CPVMediaParam
+{
+    public:
+        OSCL_IMPORT_REF CPVParam* Copy();
+        OSCL_IMPORT_REF PV2WayMediaType GetMediaType();
+    protected:
+        CPVAudioParam(PVCodecType_t aCodecType = PV_CODEC_TYPE_NONE);
+    private:
+};
+
+class CPVVideoParam : public CPVMediaParam
+{
+    public:
+        OSCL_IMPORT_REF ~CPVVideoParam();
+
+        OSCL_IMPORT_REF PV2WayMediaType GetMediaType();
+
+        OSCL_IMPORT_REF CPVParam* Copy();
+
+        OSCL_IMPORT_REF uint16 GetWidth();
+
+        OSCL_IMPORT_REF uint16 GetHeight();
+    protected:
+        CPVVideoParam(uint16 aWidth, uint16 aHeight, PVCodecType_t aCodecType = PV_CODEC_TYPE_NONE);
+    private:
+        uint16 iWidth;
+        uint16 iHeight;
+};
+
+
+class CPVAMRAudioParam : public CPVAudioParam
+{
+    public:
+        OSCL_IMPORT_REF CPVAMRAudioParam();
+        OSCL_IMPORT_REF ~CPVAMRAudioParam();
+};
+
+class CPVG723AudioParam : public CPVAudioParam
+{
+    public:
+        OSCL_IMPORT_REF CPVG723AudioParam();
+        OSCL_IMPORT_REF ~CPVG723AudioParam();
+};
+
+class CPVH263VideoParam : public CPVVideoParam
+{
+    public:
+        OSCL_IMPORT_REF CPVH263VideoParam(uint16 w, uint16 h);
+        OSCL_IMPORT_REF ~CPVH263VideoParam();
+};
+
+
+class CPVM4vVideoParam : public CPVVideoParam
+{
+    public:
+        OSCL_IMPORT_REF CPVM4vVideoParam(uint16 w, uint16 h, uint16 sz, uint8 *cfg);
+
+        OSCL_IMPORT_REF ~CPVM4vVideoParam();
+
+        OSCL_IMPORT_REF OsclAny Set(uint16 config_sz, uint8* cfg);
+
+        OSCL_IMPORT_REF uint16 GetDecoderConfigSize();
+
+        OSCL_IMPORT_REF uint8 *GetDecoderConfig();
+
+        OSCL_IMPORT_REF CPVParam* Copy();
+
+    private:
+        uint16 iSz;
+        uint8 *iCfg;
+};
+
+class CPVTrackInfo
+{
+    public:
+        virtual ~CPVTrackInfo() {}
+        virtual TPVDirection GetDirection() = 0;
+        virtual TPVChannelId GetChannelId() = 0;
+        virtual TPVDirectionality GetDirectionality() = 0;
+        virtual int GetNumSduSizes() = 0;
+        virtual int GetSduSize(int index = 0) = 0;
+        virtual int* GetSduSizes() = 0;
+        virtual CPVMediaParam* GetMediaParam() = 0;
+        virtual CPVTrackInfo* Copy() = 0;
+//	friend bool operator== (CPVTrackInfo &a, CPVTrackInfo &b);
+};
+
+OSCL_IMPORT_REF bool operator==(CPVTrackInfo &a, CPVTrackInfo &b);
+
+class CPvtMediaCapability
+{
+    public:
+        CPvtMediaCapability(PVMFFormatType format_type, uint32 bitrate = 0, bool aMandatory = false)
+                : iFormatType(format_type), iBitrate(bitrate), iMandatory(aMandatory) {}
+        virtual ~CPvtMediaCapability() {}
+        virtual PVMFFormatType GetFormatType()const
+        {
+            return iFormatType;
+        }
+        virtual uint32 GetBitrate()const
+        {
+            return iBitrate;
+        }
+        virtual bool IsMandatory() const
+        {
+            return iMandatory;
+        }
+
+        PVMFFormatType iFormatType;
+        uint32 iBitrate;
+        bool iMandatory;
+};
+
+class CPvtAudioCapability : public CPvtMediaCapability
+{
+    public:
+        CPvtAudioCapability(PVMFFormatType format_type, uint32 bitrate = 0, bool aMandatory = false)
+                : CPvtMediaCapability(format_type, bitrate, aMandatory) {}
+        ~CPvtAudioCapability() {}
+};
+
+#define PV2WAY_MAX_AMR_NB_BITRATE 12200
+class CPvtAmrNbCapability : public CPvtAudioCapability
+{
+    public:
+        CPvtAmrNbCapability(uint32 bitrate = 0)
+                : CPvtAudioCapability(PVMF_MIME_AMR_IF2, PV2WAY_MAX_AMR_NB_BITRATE, true)
+        {
+            OSCL_UNUSED_ARG(bitrate);
+            OSCL_UNUSED_ARG(bitrate);
+        }
+};
+
+
+class CPvtVideoCapability : public CPvtMediaCapability
+{
+    public:
+        CPvtVideoCapability(PVMFFormatType format_type, uint32 bitrate = 0, bool aMandatory = false)
+                : CPvtMediaCapability(format_type, bitrate, aMandatory) {}
+        virtual ~CPvtVideoCapability() {	}
+        PVMFFormatType GetFormatType()const
+        {
+            return iFormatType;
+        }
+        uint32 GetBitrate()const
+        {
+            return iBitrate;
+        }
+        virtual PVMFVideoResolution* GetMaxResolution(uint32& frame_rate) = 0;
+        virtual void SetMaxResolution(uint32 width, uint32 height, uint32 frame_rate) = 0;
+        virtual uint16 Getfsi(uint8*& aDecoderConfig) = 0;
+
+
+};
+
+class CPvtMpeg4Capability : public CPvtVideoCapability
+{
+    public:
+        CPvtMpeg4Capability(uint32 bitrate = 0) : CPvtVideoCapability(PVMF_MIME_M4V, bitrate, false), iDecoderConfig(NULL)
+        {
+            iProfile = -1;
+            iLevel = -1;
+            iDecoderConfigLen = 0;
+            iVideoResolution = OSCL_NEW(PVMFVideoResolution, (0, 0));
+            iGenericCapability = NULL;
+            iFrameRate = 0;
+
+        }
+        ~CPvtMpeg4Capability()
+        {
+            if (iDecoderConfig)
+            {
+                OSCL_DEFAULT_FREE(iDecoderConfig);
+            }
+            if (iVideoResolution)
+            {
+                OSCL_DELETE(iVideoResolution);
+                iVideoResolution = NULL;
+            }
+        }
+
+        void SetMaxResolution(uint32 width, uint32 height, uint32 frame_rate)
+        {
+            iVideoResolution->width = (uint16)width;
+            iVideoResolution->height = (uint16)height;
+            iFrameRate = frame_rate;
+        }
+
+        PVMFVideoResolution* GetMaxResolution(uint32& frame_rate)
+        {
+            frame_rate = iFrameRate;
+            return iVideoResolution;
+        }
+
+        uint16 Getfsi(uint8*& aDecoderConfig)
+        {
+            aDecoderConfig = iDecoderConfig;
+            return iDecoderConfigLen;
+        }
+
+
+
+        int32 iProfile;
+        int32 iLevel;
+        uint8* iDecoderConfig;
+        uint16 iDecoderConfigLen;
+        PS_GenericCapability iGenericCapability;
+        PVMFVideoResolution *iVideoResolution;
+        uint32 iFrameRate;
+};
+
+class CPvtH263Capability : public CPvtVideoCapability
+{
+    public:
+        CPvtH263Capability(uint32 bitrate = 0) : CPvtVideoCapability(PVMF_MIME_H2632000, bitrate, true)
+        {
+            iVideoResolution = OSCL_NEW(PVMFVideoResolution, (0, 0));
+            iH263VideoCapability = NULL;
+            iFrameRate = 0;
+        }
+        ~CPvtH263Capability()
+        {
+            if (iVideoResolution)
+                OSCL_DELETE(iVideoResolution);
+        }
+
+
+        void SetMaxResolution(uint32 width, uint32 height, uint32 frame_rate)
+        {
+            iVideoResolution->width = (uint16)width;
+            iVideoResolution->height = (uint16)height;
+            iFrameRate = frame_rate;
+
+        }
+
+        PVMFVideoResolution* GetMaxResolution(uint32& frame_rate)
+        {
+
+            frame_rate = iFrameRate;
+            return iVideoResolution;
+        }
+        uint16 Getfsi(uint8*& aDecoderConfig)
+        {
+            OSCL_UNUSED_ARG(aDecoderConfig);
+            return 0;
+        }
+
+
+        PVMFVideoResolution *iVideoResolution;
+        uint32 iFrameRate;
+        PS_H263VideoCapability iH263VideoCapability;
+};
+
+#if 0
+class CPvtAvcCapability : public CPvtMediaCapability
+{
+    public:
+        CPvtAvcCapability(uint32 bitrate = 0) : CPvtMediaCapability(PVMF_AVC, bitrate), iDecoderConfig(NULL)
+        {
+            iProfile = -1;
+            iLevel = -1;
+            iCustomMaxMBPS = -1;
+            iCustomMaxFS = -1;
+            iCustomMaxDPB = -1;
+            iCustomMaxBRandCPB = -1;
+            iMaxStaticMBPS = -1;
+            iMaxRcmdNalUnitSize = 0;
+            iMaxNalUnitSize = 0;
+            iDecoderConfigLen = 0;
+        }
+        ~CPvtAvcCapability()
+        {
+            if (iDecoderConfig)
+            {
+                OSCL_DEFAULT_FREE(iDecoderConfig);
+            }
+        }
+        int32 iProfile;
+        int32 iLevel;
+        int32 iCustomMaxMBPS;
+        int32 iCustomMaxFS;
+        int32 iCustomMaxDPB;
+        int32 iCustomMaxBRandCPB;
+        int32 iMaxStaticMBPS;
+        uint32 iMaxRcmdNalUnitSize;
+        uint32 iMaxNalUnitSize;
+        uint8* iDecoderConfig;
+        uint16 iDecoderConfigLen;
+};
+#endif
+
+class CPvtTerminalCapability
+{
+    public:
+        CPvtTerminalCapability(Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator>& capability_items):
+                iCapabilityItems(capability_items)
+        {
+        }
+        ~CPvtTerminalCapability()
+        {
+            for (uint16 i = 0;i < iCapabilityItems.size();i++)
+                OSCL_DELETE(iCapabilityItems[i]);
+        }
+        uint16 GetNumCapabilityItems()const
+        {
+            return (uint16)iCapabilityItems.size();
+        }
+        CPvtMediaCapability* GetCapabilityItem(uint16 index)
+        {
+            return iCapabilityItems[index];
+        }
+    private:
+        Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator> iCapabilityItems;
+};
+
+/**
+ CPVUserInput class
+Base class for User Input mesages
+**/
+class CPVUserInput
+{
+    public:
+        /**
+         * Virtual destructor
+         **/
+        virtual ~CPVUserInput() {};
+        /**
+         * Virtual function to return the user input type
+         **/
+        virtual TPVUserInputType GetType() = 0;
+
+        /**
+         * Virtual function to return a copy of self
+         **/
+        virtual CPVUserInput* Copy() = 0;
+};
+class CPVUserInputDtmf : public HeapBase, public CPVUserInput
+{
+    public:
+        OSCL_IMPORT_REF CPVUserInputDtmf(uint8 input, bool update, uint16 duration = 0);
+
+        OSCL_IMPORT_REF TPVUserInputType GetType();
+
+        OSCL_IMPORT_REF uint8 GetInput();
+
+        OSCL_IMPORT_REF bool IsUpdate();
+
+        OSCL_IMPORT_REF uint16 GetDuration();
+
+        OSCL_IMPORT_REF CPVUserInput* Copy();
+    private:
+        uint8 iInput;
+        bool iIsUpdate;
+        uint16 iDuration;
+};
+
+class CPVUserInputAlphanumeric : public HeapBase, public CPVUserInput
+{
+    public:
+        OSCL_IMPORT_REF CPVUserInputAlphanumeric(uint8* input, uint16 len);
+        OSCL_IMPORT_REF ~CPVUserInputAlphanumeric();
+        OSCL_IMPORT_REF TPVUserInputType GetType();
+        OSCL_IMPORT_REF uint8* GetInput();
+        OSCL_IMPORT_REF uint16 GetLength();
+        OSCL_IMPORT_REF CPVUserInput* Copy();
+    protected:
+        uint8* iInput;  /* We own the memory*/
+        uint16 iLength;        /* length of the string */
+};
+
+
+typedef enum
+{
+    EObjectIdentifier,
+    EH221NonStandard
+} TPVH245VendorType;
+
+class TPVH245Vendor
+{
+    public:
+        virtual ~TPVH245Vendor() {}
+        virtual TPVH245VendorType GetVendorType() = 0;
+        virtual TPVH245Vendor* Copy() = 0;
+};
+
+class TPVH245VendorObjectIdentifier : public TPVH245Vendor
+{
+    public:
+        OSCL_IMPORT_REF TPVH245VendorObjectIdentifier(uint8* vendor, uint16 vendorLength);
+        OSCL_IMPORT_REF ~TPVH245VendorObjectIdentifier();
+        OSCL_IMPORT_REF TPVH245VendorType GetVendorType();
+        OSCL_IMPORT_REF uint8* GetVendor(uint16* length);
+        OSCL_IMPORT_REF TPVH245Vendor* Copy();
+
+    protected:
+        uint8* iVendor;
+        uint16 iVendorLength;
+};
+
+class TPVVendorH221NonStandard : public TPVH245Vendor
+{
+    public:
+        OSCL_IMPORT_REF TPVVendorH221NonStandard(uint8 t35countryCode, uint8 t35extension, uint32 manufacturerCode);
+        OSCL_IMPORT_REF ~TPVVendorH221NonStandard();
+        OSCL_IMPORT_REF TPVH245VendorType GetVendorType();
+        OSCL_IMPORT_REF TPVH245Vendor* Copy();
+        OSCL_IMPORT_REF uint8 GetT35CountryCode();
+        OSCL_IMPORT_REF uint8 GetT35Extension();
+        OSCL_IMPORT_REF uint32 GetManufacturerCode();
+    private:
+        uint8 iT35CountryCode; /* INTEGER (0..255) */
+        uint8 iT35Extension; /* INTEGER (0..255) */
+        uint32 iManufacturerCode; /* INTEGER (0..65535) */
+};
+
+// Vendor identification classes
+class TPVVendorIdentification
+{
+    public:
+        OSCL_IMPORT_REF TPVVendorIdentification();
+        OSCL_IMPORT_REF TPVVendorIdentification(TPVH245Vendor* vendor,
+                                                uint8* pn, uint16 pn_len,
+                                                uint8* vn, uint16 vn_len);
+        OSCL_IMPORT_REF ~TPVVendorIdentification();
+        TPVH245Vendor* iVendor;
+        uint8* iProductNumber;
+        uint16 iProductNumberLen;
+        uint8* iVersionNumber;
+        uint16 iVersionNumberLen;
+};
+
+typedef uint16 TPVTerminalEvent;
+
+typedef enum
+{
+    H324_INITIALIZED,
+    H245_CE_STARTED,
+    H245_CE_RECEIVED,
+    H245_CE_COMPLETED,
+    H245_CE_ERROR,
+    H245_MSD_STARTED,
+    H245_MSD_RECEIVED,
+    H245_MSD_COMPLETED,
+    H245_MSD_ERROR,
+    H245_MT_STARTED,
+    H245_MT_RECEIVED,
+    H245_MT_SEND_COMPLETED,
+    H245_MT_ERROR,
+    H245_OLC_STARTED,
+    H245_OLC_RECEIVED,
+    H245_OLC_COMPLETED,
+    H245_OLC_ERROR,
+    H245_OBLC_STARTED,
+    H245_OBLC_RECEIVED,
+    H245_OBLC_COMPLETED,
+    H245_OBLC_ERROR,
+    H245_RTD_STARTED,
+    H245_RTD_RECEIVED,
+    H245_RTD_COMPLETED,
+    H245_RTD_ERROR,
+    H245_END_SESSION_STARTED,
+    H245_END_SESSION_RECEIVED,
+
+    SRP_TIMEOUT = H245_END_SESSION_RECEIVED + 20,
+    SRP_MAX_RETRIES,
+    SRP_CRC_ERROR,
+    AUDIO_ERROR_RATE
+} TPVH324mEvent;
+
+class CPvtDiagnosticIndication
+{
+    public:
+        OSCL_IMPORT_REF CPvtDiagnosticIndication(TPVTerminalEvent aEvent, int aParam1, int aParam2, int aParam3) ;
+
+        OSCL_IMPORT_REF ~CPvtDiagnosticIndication();
+        TPVTerminalEvent iEvent;
+        int iParam1;
+        int iParam2;
+        int iParam3;
+};
+
+typedef int TPVLogLevel;
+
+typedef enum
+{
+    PV_START_LOG,
+    PV_STOP_LOG,
+} TPVLogEvent;
+
+typedef enum
+{
+    LOG_NONE =               0x00000000,
+    LOG_ALL =                0xFFFFFFFF,
+    ENGINE_MODULE =          0x00000001,
+    TSC_MODULE =             0x00000002,
+    H223_MODULE =            0x00000004,
+    VID_DEC_MODULE =         0x00000020,
+    AUD_DEC_MODULE =         0x00000040,
+    VID_ENC_MODULE =         0x00000080,
+    AUD_ENC_MODULE =         0x00000100,
+    SYS_TOOLS_MODULE =       0x00000008,
+    H223_IN_BITSTREAM =      0x00000200,
+    H223_OUT_BITSTREAM =     0x00000400,
+    IN_CONTROL_BITSTREAM =   0x00000800,
+    OUT_CONTROL_BITSTREAM =  0x00001000,
+    IN_AUD_BISTREAM =        0x00002000,
+    OUT_AUD_BITSREAM =       0x00004000,
+    IN_VID_BITSTREAM =       0x00008000,
+    OUT_VID_BITSTREAM =      0x00010000
+} TPVLogComponent;
+
+#define PARAM_DEFAULT -1
+typedef enum
+{
+    MUX_GENERIC = 0,
+    MUX_H223,
+    MUX_RTP
+} TPVMuxType;
+
+class CPVGenericMuxParam : public CPVParam
+{
+    public:
+        OSCL_IMPORT_REF CPVGenericMuxParam(TPVMuxType aType = MUX_GENERIC);
+        OSCL_IMPORT_REF TPVMuxType GetMuxType();
+        OSCL_IMPORT_REF virtual CPVParam* Copy();
+        OSCL_IMPORT_REF virtual OsclAny Copy(CPVGenericMuxParam* param);
+
+        int16 discard_corrupt_video;
+        uint32 max_discard_video_sdu_size;
+        uint32 err_rate_threshold_to_req_I_frame;
+        uint32 audio_err_rate_update_interval;
+        uint32 audio_encode_frame_delay;
+        uint32 audio_decode_frame_delay;
+    protected:
+        TPVMuxType iMuxType;
+};
+
+#define MAX_H223_LEVELS 5
+typedef enum
+{
+    H223_LEVEL0 = 0,
+    H223_LEVEL1,
+    H223_LEVEL1_DF, /* Double flag */
+    H223_LEVEL2,
+    H223_LEVEL2_OH, /* Optional header */
+    H223_LEVEL3,
+    H223_LEVEL_UNKNOWN
+} TPVH223Level;
+
+typedef enum
+{
+    H223_PDU_SIMPLE, /* Audio only, Video only, Control only  */
+    H223_PDU_COMBINED /* A+V */
+} TPVH223MuxPduType;
+
+typedef enum
+{
+    H223_IDLE_SYNC_NONE = 0,
+    H223_IDLE_SYNC_OCTET, /* Idle sync is a repeatition of a particular octet - 0, 1, F etc */
+    H223_IDLE_SYNC_FLAGS /* Idle sync is a repeatition of flags of the current level */
+} TPVH223MuxIdleSyncType;
+
+
+class CPVH223MuxParam : public CPVGenericMuxParam
+{
+    public:
+        OSCL_IMPORT_REF CPVH223MuxParam();
+        OSCL_IMPORT_REF ~CPVH223MuxParam();
+
+        OSCL_IMPORT_REF CPVParam* Copy();
+        int iBitrate;
+        TPVH223Level iLevel;
+        int16 iMaxAl1SduSize;
+        int16 iMaxAl2SduSize;
+        int16 iMaxAl3SduSize;
+        int16 iMaxAl1SduSizeR;
+        int16 iMaxAl2SduSizeR;
+        int16 iMaxAl3SduSizeR;
+        bool iParseOnResyncMarkers;
+        TPVH223MuxPduType iOutgoingPduType; /* The pdu type for outgoing packets.  */
+        int16 iMaxPduSize; /* Limits the max outgoing pdu size */
+        TPVH223MuxIdleSyncType iIdleSyncType;
+        uint8 iIdleSyncByte; /* Specify when using H223_IDLE_SYNC_OCTET */
+    protected:
+};
+
+class CPVH245Param : public CPVParam
+{
+    public:
+        OSCL_IMPORT_REF CPVH245Param();
+        OSCL_IMPORT_REF CPVParam* Copy();
+};
+
+class CPVSrpParam : public CPVParam
+{
+    public:
+        OSCL_IMPORT_REF CPVSrpParam();
+        OSCL_IMPORT_REF CPVParam* Copy();
+};
+
+class CPVTerminalParam : public CPVParam
+{
+    public:
+        OSCL_IMPORT_REF CPVTerminalParam(CPVGenericMuxParam* muxParam = NULL);
+        OSCL_IMPORT_REF CPVTerminalParam(CPVTerminalParam& that);
+        virtual ~CPVTerminalParam();
+        virtual TPVTerminalType GetTerminalType() = 0;
+        OSCL_IMPORT_REF CPVParam* Copy(CPVTerminalParam* param);
+        OSCL_IMPORT_REF OsclAny SetMuxParam(CPVGenericMuxParam* muxParam);
+        OSCL_IMPORT_REF CPVGenericMuxParam* GetMuxParam();
+    protected:
+        CPVGenericMuxParam* iMuxParam;
+};
+
+/* MasterSlaveDetermination Decision */
+typedef enum
+{
+    PVT_SLAVE = 0,
+    PVT_MSD_INDETERMINATE = 128,
+    PVT_MASTER = 255
+} TPVMasterSlave;
+
+typedef enum
+{
+    PVT_AL1,
+    PVT_AL2,
+    PVT_AL3,
+    PVT_AL_UNKNOWN
+}TPVAdaptationLayer;
+
+OSCL_IMPORT_REF int IndexForAdaptationLayer(TPVAdaptationLayer al);
+OSCL_IMPORT_REF TPVAdaptationLayer AdaptationLayerForIndex(int al_index);
+OSCL_IMPORT_REF ErrorProtectionLevel_t EplForAdaptationLayer(TPVAdaptationLayer al);
+
+class CPVH324MParam : public CPVTerminalParam
+{
+    public:
+        OSCL_IMPORT_REF CPVH324MParam(CPVH223MuxParam* h223param = NULL);
+        OSCL_IMPORT_REF CPVH324MParam(const CPVH324MParam& that);
+        OSCL_IMPORT_REF ~CPVH324MParam();
+        OSCL_IMPORT_REF TPVTerminalType GetTerminalType();
+        OSCL_IMPORT_REF CPVParam* Copy();
+        OSCL_IMPORT_REF OsclAny SetH223Param(CPVH223MuxParam* h223Param);
+        OSCL_IMPORT_REF CPVH223MuxParam* GetH223Param();
+        OSCL_IMPORT_REF OsclAny SetSRPParam(CPVSrpParam* srpParam);
+        OSCL_IMPORT_REF OsclAny SetH245Param(CPVH245Param* h245Param);
+
+        bool iAllowAl1Video;		/* Local terminal */
+        bool iAllowAl2Video;		/* Local terminal */
+        bool iAllowAl3Video;		/*   (These are sent in outgoing CE) */
+        /* The above flags determine if support for the layers will be indicate in the
+           TSC.  The following  determine if they will be used or not */
+        bool iUseAl1Video;
+        bool iUseAl2Video;
+        bool iUseAl3Video;
+        TPVAdaptationLayer iVideoLayer;			/* Layer to use, decided by local terminal */
+        TPVAdaptationLayer iForceVideoLayerIfMaster;			/* Force the terminal to use this layer - for testing purposes */
+        TPVAdaptationLayer iForceVideoLayerIfSlave;			/* Force the terminal to use this layer - for testing purposes */
+        TPVMasterSlave iMasterSlave;
+        bool iSpecifyReceiveAndTransmitCapability;
+        bool iSendRme; /* Send Request Multiplex Entry to the remote terminal */
+        bool iSkipMsd; /* 1 = Skip MSD */
+        uint16 iRequestMaxMuxPduSize; /* Requests maxMuxPduSize to the remote terminal if > 0.  This is done after TCS
+												 if the remote terminal supports the maxMuxPduCapability */
+        CPVH245Param* iH245Param;
+        CPVSrpParam* iSrpParam;
+};
+
+class TPVVideoEncoderParam
+{
+    public:
+        OSCL_IMPORT_REF TPVVideoEncoderParam();
+
+        int video_bitrate;
+        PVCodecType_t codec;
+        int16 video_frame_rate;
+        int16 air;
+        int16 intra_refresh;
+        int16 data_partitioning;
+        int16 advanced;
+        int16 use_gov;
+        int16 rvlc;
+        int16 use_resync;
+        int16 use_hec;
+        int16 use_gobsync;
+        int16 vos;
+        int16 ref_frame_rate;
+        int16 orig_frameskip;
+        int16 chosen_frame_skip;
+        int16 qp;
+        int16 qpi;
+        int cam_low_light_mode;
+        int cam_saturation_level;
+        int cam_contrast_level;
+        int cam_edge_enhance;
+        int cam_brightness;
+        int deblocking_filter;
+        int prefilter;
+        int prefilter_coeff1;
+        int prefilter_coeff2;
+        int prefilter_coeff3;
+        int buffer_backlog;
+        int16 qp_max;
+        int16 qp_min;
+        int16 qp_delta_frame;
+        int16 qp_delta_slice;
+        int	  iframe_interval;
+        int   iframe_request_interval;
+
+    public:
+};
+
+typedef enum
+{
+    PV_PANIC_ON_ERROR =		0x0001,
+    PV_RELEASE_ON_ERROR =	0x0002,
+    PV_RESYNC_ON_ERROR =		0x0003
+} TPVGCErrorHandleMode;
+
+class CPVTerminalStatistics
+{
+
+};
+
+class CPVH324TerminalStatistics : public CPVTerminalStatistics
+{
+
+};
+
+OSCL_IMPORT_REF PVMFFormatType PVCodecTypeToPVMFFormatType(PVCodecType_t aCodecType);
+OSCL_IMPORT_REF PVCodecType_t PVMFFormatTypeToPVCodecType(PVMFFormatType aFormatType);
+OSCL_IMPORT_REF PV2WayMediaType PVMFFormatTypeToPVMediaType(PVMFFormatType aFormatType);
+
+#define min2(a, b) ((a > b) ? b : a)
+
+#define __STR2__(x) #x
+#define __STR1__(x) __STR2__(x)
+#define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "
+
+class BasicAlloc : public Oscl_DefAlloc
+{
+    public:
+        void* allocate(const uint32 size)
+        {
+            void* tmp = (void*)OSCL_DEFAULT_MALLOC(size);
+            OSCL_ASSERT(tmp != 0);
+            return tmp;
+        }
+        void deallocate(void* p)
+        {
+            OSCL_DEFAULT_FREE(p);
+        }
+};
+
+typedef enum
+{
+    PV_H324COMPONENT_H245_USER,
+    PV_H324COMPONENT_H245,
+    PV_H324COMPONENT_SRP,
+    PV_H324COMPONENT_H223
+}TPVH324Component;
+
+const PVMFStatus PV2WayH324ErrorStatusStart = (-10600);
+const PVMFStatus PV2WayH324ErrorSymmetryViolation = PV2WayH324ErrorStatusStart;
+
+class CodecCapabilityInfo
+{
+    public:
+        OSCL_IMPORT_REF CodecCapabilityInfo();
+        virtual ~CodecCapabilityInfo() {}
+        OSCL_IMPORT_REF virtual CodecCapabilityInfo* Copy();
+        PVCodecType_t codec;
+        TPVDirection dir;
+        uint32 max_bitrate;
+        uint32 min_sample_size;
+        uint32 max_sample_size;
+};
+
+class VideoCodecCapabilityInfo : public CodecCapabilityInfo
+{
+    public:
+        OSCL_IMPORT_REF VideoCodecCapabilityInfo();
+        ~VideoCodecCapabilityInfo()
+        {
+            if (codec_specific_info)
+            {
+                OSCL_DEFAULT_FREE(codec_specific_info);
+            }
+        }
+        OSCL_IMPORT_REF CodecCapabilityInfo* Copy();
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator> resolutions;
+        uint8* codec_specific_info;
+        uint16 codec_specific_info_len;
+};
+
+
+typedef enum
+{
+    APP,
+    ENG
+}TPVPriority;
+
+class FormatCapabilityInfo
+{
+    public:
+        FormatCapabilityInfo() : id(CHANNEL_ID_UNKNOWN),
+                format(PVMF_MIME_FORMAT_UNKNOWN),
+                dir(PV_DIRECTION_NONE),
+                bitrate(0),
+                min_sample_size(0),
+                max_sample_size(0),
+                capabilities(1),
+                fsi(NULL), fsi_len(0) {}
+        FormatCapabilityInfo(PVMFFormatType aFormat,
+                             TPVDirection aDir,
+                             uint32 aCapabilities)
+                : format(aFormat),
+                dir(aDir),
+                bitrate(0),
+                min_sample_size(0),
+                max_sample_size(0),
+                capabilities(aCapabilities),
+                fsi(NULL), fsi_len(0) {}
+        ~FormatCapabilityInfo()
+        {
+            if (fsi)
+            {
+                OSCL_DEFAULT_FREE(fsi);
+                fsi = NULL;
+            }
+        }
+        TPVChannelId id;
+        PVMFFormatType format;
+        TPVDirection dir;
+        uint32 bitrate;
+        uint32 min_sample_size;
+        uint32 max_sample_size;
+        uint32 capabilities; // additional capabilities
+        uint8* fsi;
+        uint32 fsi_len;
+        /* Enum for Priority */
+        TPVPriority iPriority;
+};
+
+class H324ChannelParameters
+{
+    public:
+        OSCL_IMPORT_REF H324ChannelParameters(TPVDirection dir, PVMFFormatType mediaType, unsigned bandwidth);
+        OSCL_IMPORT_REF H324ChannelParameters(const H324ChannelParameters& that);
+        OSCL_IMPORT_REF ~H324ChannelParameters();
+        OSCL_IMPORT_REF void SetCodecs(Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& codecs);
+        OSCL_IMPORT_REF Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* GetCodecs();
+
+        OSCL_IMPORT_REF PV2WayMediaType GetMediaType();
+        OSCL_IMPORT_REF unsigned GetBandwidth();
+    private:
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* iCodecs;
+        unsigned iBandwidth;
+};
+
+typedef enum
+{
+    EH324Timer,
+    EH324Counter
+}TPVH324TimerCounter;
+
+
+#define PVH324MLogicalChannelInfoUuid PVUuid(0x200306a0,0xffab,0x11d9,0xba,0x43,0x00,0x02,0xa5,0xd5,0xc5,0x1b)
+/* Base class for media logical channels */
+class LogicalChannelInfo
+{
+    public:
+        virtual ~LogicalChannelInfo() {}
+
+        virtual TPVDirection GetDirection() = 0;
+
+        virtual TPVChannelId GetLogicalChannelNumber() = 0;
+
+        virtual uint32 GetSduSize() = 0;
+
+        virtual bool IsSegmentable() = 0;
+
+        virtual uint32 GetBitrate() = 0;
+
+        virtual uint32 GetSampleInterval() = 0;
+
+        virtual const uint8* GetFormatSpecificInfo(uint32* format_specific_info_len) = 0;
+
+        virtual PVMFTimestamp GetLastSduTimestamp() = 0;
+
+        virtual PVMFFormatType GetFormatType() = 0;
+
+};
+
+#define PV_H324_MUX_INPUT_FORMATS "x-pvmf/multiplexed/input_formats"
+#define PV_H324_MUX_INPUT_FORMATS_VALTYPE "x-pvmf/multiplexed/formattype;valtype=int32"
+#define PV_H324_MUX_OUTPUT_FORMATS "x-pvmf/multiplexed/output_formats"
+#define PV_H324_MUX_OUTPUT_FORMATS_VALTYPE "x-pvmf/multiplexed/formattype;valtype=int32"
+
+#define PV_H324_VIDEO_INPUT_FORMATS "x-pvmf/video/decode/input_formats"
+#define PV_H324_VIDEO_INPUT_FORMATS_VALTYPE "x-pvmf/video/decode/formattype;valtype=int32"
+#define PV_H324_AUDIO_INPUT_FORMATS "x-pvmf/audio/decode/input_formats"
+#define PV_H324_AUDIO_INPUT_FORMATS_VALTYPE "x-pvmf/audio/decode/formattype;valtype=int32"
+
+#define PV_H324_VIDEO_OUTPUT_FORMATS "x-pvmf/video/encode/output_formats"
+#define PV_H324_VIDEO_OUTPUT_FORMATS_VALTYPE "x-pvmf/video/encode/formattype;valtype=int32"
+#define PV_H324_AUDIO_OUTPUT_FORMATS "x-pvmf/audio/encode/output_formats"
+#define PV_H324_AUDIO_OUTPUT_FORMATS_VALTYPE "x-pvmf/audio/encode/formattype;valtype=int32"
+
+OSCL_IMPORT_REF const char* GetFormatsString(TPVDirection aDir, PV2WayMediaType aMediaType);
+OSCL_IMPORT_REF const char* GetFormatsValtypeString(TPVDirection aDir, PV2WayMediaType aMediaType);
+
+template<class elementalClass>
+class Basic2WayDestructDealloc : public OsclDestructDealloc
+{
+    public:
+        virtual void destruct_and_dealloc(OsclAny *ptr)
+        {
+            OSCL_DEFAULT_FREE(ptr);
+        }
+};
+
+OSCL_IMPORT_REF void GetSampleSize(PVMFFormatType aFormatType, uint32* aMin, uint32* aMax);
+
+/**
+ * CPV2WayM4VConfigInfo Class
+ *
+ * The CPV2WayM4VConfigInfo class contains configuration information for an M4V encoder.  This information can be used to configure a encoded source or sink.
+ **/
+
+class CPV2WayM4VConfigInfo
+{
+    public:
+        CPV2WayM4VConfigInfo() : m4v_VOLHeaderSize(0), frameWidth(176), frameHeight(144), frameRate(5), profileLevelID(0) {};
+
+        CPV2WayM4VConfigInfo(OsclSharedPtr<uint8> am4v_VOLHeader,
+                             uint32 am4v_VOLHeaderSize,
+                             int aframeWidth,
+                             int aframeHeight,
+                             int aprofileLevelID,
+                             int aframeRate)
+        {
+            m4v_VOLHeader.Bind(am4v_VOLHeader);
+            m4v_VOLHeaderSize = am4v_VOLHeaderSize;
+            frameWidth = aframeWidth;
+            frameHeight = aframeHeight;
+            profileLevelID = aprofileLevelID;
+            frameRate = aframeRate;
+        }
+
+
+        CPV2WayM4VConfigInfo & operator=(const CPV2WayM4VConfigInfo& aInfo)
+        {
+            m4v_VOLHeader.Bind(aInfo.m4v_VOLHeader);
+            m4v_VOLHeaderSize = aInfo.m4v_VOLHeaderSize;
+            frameWidth = aInfo.frameWidth;
+            frameHeight = aInfo.frameHeight;
+            frameRate = aInfo.frameRate;
+            profileLevelID = aInfo.profileLevelID;
+            return *this;
+        }
+
+
+        OsclSharedPtr<uint8> m4v_VOLHeader;
+        uint32 m4v_VOLHeaderSize;
+        int frameWidth;
+        int frameHeight;
+        int frameRate;
+        int profileLevelID;
+
+};
+
+/**
+ * CPV2WayH263ConfigInfo Class
+ *
+ * The CPV2WayH263ConfigInfo class contains configuration information for an H263 encoder.  This information can be used to configure a encoded source or sink.
+ **/
+
+class CPV2WayH263ConfigInfo
+{
+    public:
+        CPV2WayH263ConfigInfo() : profile(0), level(10), frameWidth(176), frameHeight(144), frameRate(5) {};
+
+        CPV2WayH263ConfigInfo & operator=(const CPV2WayH263ConfigInfo& aInfo)
+        {
+            profile = aInfo.profile;
+            level = aInfo.level;
+            frameWidth = aInfo.frameWidth;
+            frameHeight = aInfo.frameHeight;
+            frameRate = aInfo.frameRate;
+            return *this;
+        }
+
+
+        int profile;
+        int level;
+        int frameWidth;
+        int frameHeight;
+        int frameRate;
+};
+
+
+class OlcFormatInfo
+{
+    public:
+        OlcFormatInfo() : iId(CHANNEL_ID_UNKNOWN),
+                iCodec(PV_CODEC_TYPE_NONE),
+                isSymmetric(true) {}
+        TPVChannelId iId;
+        PVCodecType_t iCodec;
+        bool isSymmetric;
+};
+
+template < uint32 numchunk, uint32 chunksize = 0 >
+class PoolMemAlloc : public OsclMemPoolFixedChunkAllocator
+{
+    public:
+        PoolMemAlloc(): OsclMemPoolFixedChunkAllocator(numchunk, chunksize) {}
+};
+typedef PoolMemAlloc<10> PoolMemAlloc_OsclMemAllocator_10;
+
+#define PORT_TYPE_FOR_DIRECTION(dir) ((dir == OUTGOING) ? EPVInputPort : EPVOutputPort)
+OSCL_IMPORT_REF PV2WayMediaType GetMediaType(PVCodecType_t codec);
+OSCL_IMPORT_REF void GetSampleSize(PVMFFormatType aFormatType, uint32* aMin, uint32* aMax);
+OSCL_IMPORT_REF bool CodecRequiresFsi(PVCodecType_t codec);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/common/src/h324utils.cpp b/protocols/systems/3g-324m_pvterminal/common/src/h324utils.cpp
new file mode 100644
index 0000000..1f2bee5
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/src/h324utils.cpp
@@ -0,0 +1,1716 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "h324utils.h"
+#include "oscl_dll.h"
+#include "oscl_map.h"
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+static const uint32 g_num_ones[] =
+{
+    /* 0 -  0000 0000 */0, 1, 1, 2, 1, 2, 2, 3,
+    /* 8 -  0000 1000 */1, 2, 2, 3, 2, 3, 3, 4,
+    /*16 -  0001 0000 */1, 2, 2, 3, 2, 3, 3, 4,
+    /*24 -  0001 1000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*32 -  0010 0000 */1, 2, 2, 3, 2, 3, 3, 4,
+    /*40 -  0010 1000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*48 -  0011 0000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*56 -  0011 1000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*64 -  0100 0000 */1, 2, 2, 3, 2, 3, 3, 4,
+    /*72 -  0100 1000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*80 -  0101 0000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*88 -  0101 1000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*96 -  0110 0000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*104 - 0110 1000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*112 - 0111 0000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*120 - 0111 1000 */4, 5, 5, 6, 5, 6, 6, 7,
+    /*128 - 1000 0000 */1, 2, 2, 3, 2, 3, 3, 4,
+    /*136 - 1000 1000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*144 - 1001 0000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*152 - 1001 1000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*160 - 1010 0000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*168 - 1010 1000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*176 - 1011 0000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*184 - 1011 1000 */4, 5, 5, 6, 5, 6, 6, 7,
+    /*192 - 1100 0000 */2, 3, 3, 4, 3, 4, 4, 5,
+    /*200 - 1100 1000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*208 - 1101 0000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*216 - 1101 1000 */4, 5, 5, 6, 5, 6, 6, 7,
+    /*224 - 1110 0000 */3, 4, 4, 5, 4, 5, 5, 6,
+    /*232 - 1110 1000 */4, 5, 5, 6, 5, 6, 6, 7,
+    /*240 - 1111 0000 */4, 5, 5, 6, 5, 6, 6, 7,
+    /*248 - 1111 1000 */5, 6, 6, 7, 6, 7, 7, 8
+};
+
+PVCodecType_t GetVidCodecTypeFromVideoCapability(PS_VideoCapability capability)
+{
+    switch (capability->index)
+    {
+        case 3:
+            return PV_VID_TYPE_H263;
+        case 5:
+        {
+            if (capability->genericVideoCapability->capabilityIdentifier.index == 0)
+            {
+                S_CapabilityIdentifierStandard capabilityIdentifierStandardInfo;
+                ParseCapabilityIdentifierStandard(
+                    capability->genericVideoCapability->capabilityIdentifier.standard->data,
+                    capability->genericVideoCapability->capabilityIdentifier.standard->size,
+                    capabilityIdentifierStandardInfo);
+                return GetVidCodecTypeFromCapabilityIdentifier(
+                           capabilityIdentifierStandardInfo);
+            }
+        }
+        default:
+            break;
+    }
+    return PV_CODEC_TYPE_NONE;
+}
+
+PVCodecType_t GetVidCodecTypeFromCapabilityIdentifier(S_CapabilityIdentifierStandard& identifier)
+{
+    if (identifier.itu != 0 ||
+            identifier.spec_type != 0 ||
+            identifier.series_letter != 8)
+        return PV_CODEC_TYPE_NONE;
+    if (identifier.spec_number == 245)
+    {
+        if (identifier.data[0] == 1 && // generic capabilty
+                identifier.data[1] == 0 && // video
+                identifier.data[2] == 0) // 14496-2
+        {
+            return PV_VID_TYPE_MPEG4;
+        }
+    }
+    return PV_CODEC_TYPE_NONE;
+}
+
+PVCodecType_t GetAudCodecTypeFrom245Index(int32 index)
+{
+    switch (index)
+    {
+        case 8:
+            return PV_AUD_TYPE_G723;
+        default:
+            break;
+    }
+    return PV_CODEC_TYPE_NONE;
+};
+
+PVCodecType_t GetAudCodecType(PS_GenericCapability audio_capability)
+{
+    S_CapabilityIdentifierStandard capabilityIdentifierStandardInfo;
+    ParseCapabilityIdentifierStandard(
+        audio_capability->capabilityIdentifier.standard->data,
+        audio_capability->capabilityIdentifier.standard->size,
+        capabilityIdentifierStandardInfo);
+    if (capabilityIdentifierStandardInfo.itu != 0 ||
+            capabilityIdentifierStandardInfo.spec_type != 0 ||
+            capabilityIdentifierStandardInfo.series_letter != 8)
+    {
+        return PV_CODEC_TYPE_NONE;
+    }
+    if (capabilityIdentifierStandardInfo.spec_number != 245 ||
+            capabilityIdentifierStandardInfo.data[0] != 1 || // generic capability
+            capabilityIdentifierStandardInfo.data[1] != 1 || // AUDIO capability
+            capabilityIdentifierStandardInfo.data[2] != 1)  // AMR capability
+    {
+        return PV_CODEC_TYPE_NONE;
+    }
+    return PV_AUD_TYPE_GSM;
+};
+
+PVCodecType_t GetAudCodecType(PS_AudioCapability audio_capability)
+{
+    if (audio_capability->index == 20)
+    {
+        return GetAudCodecType(audio_capability->genericAudioCapability);
+    }
+    return GetAudCodecTypeFrom245Index(audio_capability->index);
+}
+
+PVCodecType_t GetUiCodecTypeFrom245Index(int32 index)
+{
+    switch (index)
+    {
+        case 1:
+            return PV_UI_BASIC_STRING;
+        case 2:
+            return PV_UI_IA5_STRING;
+        case 3:
+            return PV_UI_GENERAL_STRING;
+        case 4:
+            return PV_UI_DTMF;
+        default:
+            break;
+    }
+    return PV_CODEC_TYPE_NONE;
+}
+
+void GetCodecInfo(PS_Capability capability, CodecCapabilityInfo& info)
+{
+    info.codec = PV_CODEC_TYPE_NONE;
+    switch (capability->index)
+    {
+        case 1:
+            info.dir = INCOMING;
+            info.codec = GetVidCodecTypeFromVideoCapability(
+                             capability->receiveVideoCapability);
+            break;
+        case 2:
+            info.dir = OUTGOING;
+            info.codec = GetVidCodecTypeFromVideoCapability(
+                             capability->transmitVideoCapability);
+            break;
+        case 3:
+            info.dir = PV_DIRECTION_BOTH;
+            info.codec = GetVidCodecTypeFromVideoCapability(
+                             capability->receiveAndTransmitVideoCapability);
+            break;
+        case 4:
+            info.dir = INCOMING;
+            info.codec = GetAudCodecType(capability->receiveAudioCapability);
+            break;
+        case 5:
+            info.dir = OUTGOING;
+            info.codec = GetAudCodecType(capability->transmitAudioCapability);
+            break;
+        case 6:
+            info.dir = PV_DIRECTION_BOTH;
+            info.codec = GetAudCodecType(
+                             capability->receiveAndTransmitAudioCapability);
+            break;
+        case 15:
+            info.dir = INCOMING;
+            info.codec = GetUiCodecTypeFrom245Index(
+                             capability->receiveUserInputCapability->index);
+            break;
+        case 16:
+            info.dir = OUTGOING;
+            info.codec = GetUiCodecTypeFrom245Index(
+                             capability->transmitUserInputCapability->index);
+            break;
+        case 17:
+            info.dir = PV_DIRECTION_BOTH;
+            info.codec = GetUiCodecTypeFrom245Index(
+                             capability->receiveAndTransmitUserInputCapability->index);
+            break;
+        default:
+            break;
+    }
+}
+
+void FillCapability(CodecCapabilityInfo& codec_info,
+                    PS_Capability capability)
+{
+    PV2WayMediaType media_type = GetMediaType(codec_info.codec);
+    switch (media_type)
+    {
+        case PV_VIDEO:
+        {
+            PS_VideoCapability video_capability =
+                (PS_VideoCapability)OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            oscl_memset(video_capability, 0, sizeof(S_VideoCapability));
+
+            if (codec_info.dir == INCOMING)
+            {
+                capability->index = 1;
+                capability->receiveVideoCapability = video_capability;
+            }
+            else if (codec_info.dir == OUTGOING)
+            {
+                capability->index = 2;
+                capability->transmitVideoCapability = video_capability;
+            }
+            else
+            {
+                capability->index = 3;
+                capability->receiveAndTransmitVideoCapability =
+                    video_capability;
+            }
+            FillVideoCapability((VideoCodecCapabilityInfo&)codec_info,
+                                video_capability);
+        }
+        break;
+        case PV_AUDIO:
+        {
+            PS_AudioCapability audio_capability =
+                (PS_AudioCapability)OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            oscl_memset(audio_capability, 0, sizeof(S_AudioCapability));
+
+            if (codec_info.dir == INCOMING)
+            {
+                capability->index = 4;
+                capability->receiveAudioCapability = audio_capability;
+            }
+            else if (codec_info.dir == OUTGOING)
+            {
+                capability->index = 5;
+                capability->transmitAudioCapability = audio_capability;
+            }
+            else
+            {
+                capability->index = 6;
+                capability->receiveAndTransmitAudioCapability = audio_capability;
+            }
+            FillAudioCapability(codec_info, audio_capability);
+        }
+        break;
+        case PV_USER_INPUT:
+        {
+            PS_UserInputCapability userinput_capability =
+                (PS_UserInputCapability)OSCL_DEFAULT_MALLOC(sizeof(S_UserInputCapability));
+            oscl_memset(userinput_capability, 0, sizeof(S_UserInputCapability));
+            if (codec_info.dir == INCOMING)
+            {
+                capability->index = 15;
+                capability->receiveUserInputCapability = userinput_capability;
+            }
+            else if (codec_info.dir == OUTGOING)
+            {
+                capability->index = 16;
+                capability->transmitUserInputCapability = userinput_capability;
+            }
+            else
+            {
+                capability->index = 15;
+                capability->receiveAndTransmitUserInputCapability = userinput_capability;
+            }
+            FillUserInputCapability(codec_info, userinput_capability);
+        }
+        break;
+        default:
+            break;
+    }
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_Capability capability)
+{
+    CodecCapabilityInfo* ret = NULL;
+    TPVDirection dir = PV_DIRECTION_BOTH;
+    switch (capability->index)
+    {
+        case 1:
+            ret = GetCodecCapabilityInfo(capability->receiveVideoCapability);
+            dir = INCOMING;
+            break;
+        case 2:
+            ret = GetCodecCapabilityInfo(capability->transmitVideoCapability);
+            dir = OUTGOING;
+            break;
+        case 3:
+            ret = GetCodecCapabilityInfo(
+                      capability->receiveAndTransmitVideoCapability);
+            dir = PV_DIRECTION_BOTH;
+            break;
+        case 4:
+            ret = GetCodecCapabilityInfo(capability->receiveAudioCapability);
+            dir = INCOMING;
+            break;
+        case 5:
+            ret = GetCodecCapabilityInfo(capability->transmitAudioCapability);
+            dir = OUTGOING;
+            break;
+        case 6:
+            ret = GetCodecCapabilityInfo(
+                      capability->receiveAndTransmitAudioCapability);
+            dir = PV_DIRECTION_BOTH;
+            break;
+        case 15:
+            ret = GetCodecCapabilityInfo(capability->receiveUserInputCapability);
+            dir = INCOMING;
+            break;
+        case 16:
+            ret = GetCodecCapabilityInfo(
+                      capability->transmitUserInputCapability);
+            dir = OUTGOING;
+            break;
+        case 17:
+            ret = GetCodecCapabilityInfo(
+                      capability->receiveAndTransmitUserInputCapability);
+            dir =  PV_DIRECTION_BOTH;
+            break;
+        default:
+            break;
+    }
+    if (ret)
+    {
+        ret->dir = dir;
+    }
+    return ret;
+}
+
+
+void FillVideoCapability(VideoCodecCapabilityInfo& video_codec_info,
+                         PS_VideoCapability video_capability)
+{
+    switch (video_codec_info.codec)
+    {
+        case PV_VID_TYPE_H263:
+            video_capability->index = 3;
+            video_capability->h263VideoCapability =
+                (PS_H263VideoCapability)OSCL_DEFAULT_MALLOC(
+                    sizeof(S_H263VideoCapability));
+            oscl_memset(video_capability->h263VideoCapability,
+                        0, sizeof(S_H263VideoCapability));
+            FillH263Capability(video_codec_info,
+                               video_capability->h263VideoCapability);
+            break;
+        case PV_VID_TYPE_MPEG4:
+            video_capability->index = 5;
+            video_capability->genericVideoCapability =
+                (PS_GenericCapability)OSCL_DEFAULT_MALLOC(
+                    sizeof(S_GenericCapability));
+            oscl_memset(video_capability->genericVideoCapability,
+                        0, sizeof(S_GenericCapability));
+            FillM4vCapability(video_codec_info,
+                              video_capability->genericVideoCapability);
+            break;
+        default:
+            break;
+    }
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_VideoCapability capability)
+{
+    switch (capability->index)
+    {
+        case 3:
+            return GetCodecCapabilityInfo(capability->h263VideoCapability);
+        case 5:
+            return GetCodecCapabilityInfo(capability->genericVideoCapability);
+        default:
+            break;
+    }
+    return NULL;
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_GenericCapability capability)
+{
+    if (capability->capabilityIdentifier.index != 0)
+        return NULL;
+    S_CapabilityIdentifierStandard capabilityIdentifierStandardInfo;
+    ParseCapabilityIdentifierStandard(
+        capability->capabilityIdentifier.standard->data,
+        capability->capabilityIdentifier.standard->size,
+        capabilityIdentifierStandardInfo);
+    PVCodecType_t codec_type
+    = GetVidCodecTypeFromCapabilityIdentifier(capabilityIdentifierStandardInfo);
+    switch (codec_type)
+    {
+        case PV_VID_TYPE_MPEG4:
+            return GetCodecCapabilityInfoMpeg4(capability);
+        default:
+            break;
+    }
+    return NULL;
+}
+
+void FillM4vCapability(VideoCodecCapabilityInfo& video_codec_info,
+                       PS_GenericCapability m4vcaps)
+{
+    OSCL_UNUSED_ARG(video_codec_info);
+    // x15 is a set of 1 GenericParameter(s)
+    unsigned num_generic_parameters = 1;
+    PS_GenericParameter x15 = (PS_GenericParameter)OSCL_DEFAULT_MALLOC(num_generic_parameters *
+                              sizeof(S_GenericParameter));
+    oscl_memset(x15, 0, num_generic_parameters * sizeof(S_GenericParameter));
+
+    // x13 is a GenericCapability (SEQUENCE)
+    PS_CapabilityIdentifier x14 = &m4vcaps->capabilityIdentifier;
+    m4vcaps->option_of_maxBitRate = ON;
+    m4vcaps->maxBitRate = 521;
+    m4vcaps->option_of_collapsing = OFF;
+    m4vcaps->option_of_nonCollapsing = ON;
+    m4vcaps->size_of_nonCollapsing = 1;
+    m4vcaps->nonCollapsing = x15;
+    m4vcaps->option_of_nonCollapsingRaw = OFF;
+    m4vcaps->option_of_transport = OFF;
+
+    // x14 is a CapabilityIdentifier (CHOICE)
+    x14->index = 0;
+
+    PS_OBJECTIDENT objident = (PS_OBJECTIDENT)OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+    oscl_memset(objident, 0, sizeof(S_OBJECTIDENT));
+    x14->standard = objident;
+    x14->standard->size = 7;
+    x14->standard->data = (uint8*)OSCL_DEFAULT_MALLOC(x14->standard->size);
+    x14->standard->data[0] = 0x00;
+    x14->standard->data[1] = 0x08;
+    x14->standard->data[2] = 0x81;
+    x14->standard->data[3] = 0x75;
+    x14->standard->data[4] = 0x01;
+    x14->standard->data[5] = 0x00;
+    x14->standard->data[6] = 0x00;
+
+    // x15[0] is a GenericParameter (SEQUENCE)
+    PS_ParameterIdentifier x16 = &x15[0].parameterIdentifier;
+    PS_ParameterValue x17 = &x15[0].parameterValue;
+    x15[0].option_of_supersedes = OFF;
+
+    // x16 is a ParameterIdentifier (CHOICE)
+    x16->index = 0;
+    x16->standard = 0;
+
+    // x17 is a ParameterValue (CHOICE)
+    x17->index = 3;
+    x17->unsignedMax = 8;  // Value changed from 3 to 8.  (RAN - PandL)
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfoMpeg4(PS_GenericCapability mpeg4caps)
+{
+    VideoCodecCapabilityInfo* cci = new VideoCodecCapabilityInfo();
+    cci->codec = PV_VID_TYPE_MPEG4;
+    cci->max_bitrate = mpeg4caps->maxBitRate;
+    return cci;
+}
+
+void FillH263Capability(VideoCodecCapabilityInfo& video_codec_info,
+                        PS_H263VideoCapability h263caps)
+{
+    if (IsResolutionSupported(PVMF_RESOLUTION_SQCIF,
+                              video_codec_info.resolutions))
+    {
+        h263caps->option_of_sqcifMPI = ON;
+        h263caps->sqcifMPI = 2;
+    }
+    if (IsResolutionSupported(PVMF_RESOLUTION_QCIF,
+                              video_codec_info.resolutions))
+    {
+        h263caps->option_of_qcifMPI = ON;
+        h263caps->qcifMPI = 2;
+    }
+    if (IsResolutionSupported(PVMF_RESOLUTION_CIF,
+                              video_codec_info.resolutions))
+    {
+        h263caps->option_of_cifMPI = ON;
+        h263caps->cifMPI = 2;
+    }
+    if (IsResolutionSupported(PVMF_RESOLUTION_4CIF,
+                              video_codec_info.resolutions))
+    {
+        h263caps->option_of_cif4MPI = ON;
+        h263caps->cif4MPI = 2;
+    }
+    if (IsResolutionSupported(PVMF_RESOLUTION_16CIF,
+                              video_codec_info.resolutions))
+    {
+        h263caps->option_of_cif16MPI = ON;
+        h263caps->cif16MPI = 2;
+    }
+    h263caps->maxBitRate = 521;
+    h263caps->unrestrictedVector = OFF;
+    h263caps->arithmeticCoding = OFF;
+    h263caps->advancedPrediction = OFF;
+    h263caps->pbFrames = OFF;
+    h263caps->temporalSpatialTradeOffCapability = ON;
+    h263caps->option_of_hrd_B = OFF;
+    h263caps->option_of_bppMaxKb = OFF;
+    h263caps->option_of_slowSqcifMPI = OFF;
+    h263caps->option_of_slowQcifMPI = OFF;
+    h263caps->option_of_slowCifMPI = OFF;
+    h263caps->option_of_slowCif4MPI = OFF;
+    h263caps->option_of_slowCif16MPI = OFF;
+    h263caps->option_of_errorCompensation = ON;
+    h263caps->errorCompensation = OFF;
+    h263caps->option_of_enhancementLayerInfo = OFF;
+    h263caps->option_of_h263Options = OFF;
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_H263VideoCapability h263caps)
+{
+    VideoCodecCapabilityInfo* cci = new VideoCodecCapabilityInfo();
+    cci->codec = PV_VID_TYPE_H263;
+    cci->max_bitrate = h263caps->maxBitRate;
+
+    if (h263caps->option_of_sqcifMPI == ON && h263caps->sqcifMPI)
+    {
+        PVMFVideoResolutionRange range_sqcif(PVMF_RESOLUTION_SQCIF,
+                                             PVMF_RESOLUTION_SQCIF);
+        cci->resolutions.push_back(range_sqcif);
+    }
+    if (h263caps->option_of_qcifMPI == ON && h263caps->qcifMPI)
+    {
+        PVMFVideoResolutionRange range_qcif(PVMF_RESOLUTION_QCIF,
+                                            PVMF_RESOLUTION_QCIF);
+        cci->resolutions.push_back(range_qcif);
+    }
+    if (h263caps->option_of_cifMPI == ON && h263caps->cifMPI)
+    {
+        PVMFVideoResolutionRange range_cif(PVMF_RESOLUTION_CIF,
+                                           PVMF_RESOLUTION_CIF);
+        cci->resolutions.push_back(range_cif);
+    }
+    if (h263caps->option_of_cif4MPI == ON && h263caps->cif4MPI)
+    {
+        PVMFVideoResolutionRange range_4cif(PVMF_RESOLUTION_4CIF,
+                                            PVMF_RESOLUTION_4CIF);
+        cci->resolutions.push_back(range_4cif);
+    }
+    if (h263caps->option_of_cif16MPI == ON && h263caps->cif16MPI)
+    {
+        PVMFVideoResolutionRange range_16cif(PVMF_RESOLUTION_16CIF,
+                                             PVMF_RESOLUTION_16CIF);
+        cci->resolutions.push_back(range_16cif);
+    }
+    return cci;
+}
+
+void FillAudioCapability(CodecCapabilityInfo& codec_info,
+                         PS_AudioCapability audio_capability)
+{
+    switch (codec_info.codec)
+    {
+        case PV_AUD_TYPE_GSM:
+            audio_capability->index = 20;
+            audio_capability->genericAudioCapability =
+                (PS_GenericCapability)OSCL_DEFAULT_MALLOC(
+                    sizeof(S_GenericCapability));
+            FillAmrCapability(audio_capability->genericAudioCapability);
+            break;
+        case PV_AUD_TYPE_G723:
+            audio_capability->index = 8;
+            audio_capability->g7231 = (PS_G7231)OSCL_DEFAULT_MALLOC(
+                                          sizeof(S_G7231));
+            FillG723Capability(audio_capability->g7231);
+            break;
+        default:
+            break;
+    }
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_AudioCapability audio_capability)
+{
+    switch (audio_capability->index)
+    {
+        case 8:
+            return GetCodecCapabilityInfo(audio_capability->g7231);
+        case 20:
+            return GetCodecCapabilityInfoAmr(
+                       audio_capability->genericAudioCapability);
+        default:
+            break;
+    }
+    return NULL;
+}
+
+void FillG723Capability(PS_G7231 g723caps)
+{
+    g723caps->maxAl_sduAudioFrames = 1;
+    g723caps->silenceSuppression = OFF;
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_G7231 g723caps)
+{
+    OSCL_UNUSED_ARG(g723caps);
+    CodecCapabilityInfo* cci = new CodecCapabilityInfo();
+    cci->codec = PV_AUD_TYPE_G723;
+    cci->max_bitrate = 6300;
+    return cci;
+}
+
+void FillAmrCapability(PS_GenericCapability amrCaps)
+{
+    unsigned sizeof_generic_params = 1;
+    PS_GenericParameter x25 =
+        (PS_GenericParameter)OSCL_DEFAULT_MALLOC(sizeof_generic_params *
+                sizeof(S_GenericParameter));
+    oscl_memset(x25, 0, sizeof_generic_params * sizeof(S_GenericParameter));
+
+    // x23 is a GenericCapability (SEQUENCE)
+    PS_CapabilityIdentifier x24 = &amrCaps->capabilityIdentifier;
+    amrCaps->option_of_maxBitRate = ON;
+    amrCaps->maxBitRate = 122;
+    amrCaps->option_of_collapsing = ON;
+    amrCaps->size_of_collapsing = 1;
+    amrCaps->collapsing = x25;
+    amrCaps->option_of_nonCollapsing = OFF;
+    amrCaps->option_of_nonCollapsingRaw = OFF;
+    amrCaps->option_of_transport = OFF;
+
+    // x24 is a CapabilityIdentifier (CHOICE)
+    x24->index = 0;
+    // ----------- Define protocolID --------------
+    PS_OBJECTIDENT objident2 = (PS_OBJECTIDENT)OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+    oscl_memset(objident2, 0, sizeof(S_OBJECTIDENT));
+
+    x24->standard = objident2;
+    x24->standard->size = 7;
+    x24->standard->data = (uint8*)OSCL_DEFAULT_MALLOC(x24->standard->size);
+    x24->standard->data[0] = 0x00;
+    x24->standard->data[1] = 0x08;
+    x24->standard->data[2] = 0x81;
+    x24->standard->data[3] = 0x75;
+    x24->standard->data[4] = 0x01;
+    x24->standard->data[5] = 0x01;
+    x24->standard->data[6] = 0x01;
+    // ----------- End protocolID -----------------
+
+    // x25 is a set of 1 GenericParameter(s)
+
+    // x25[0] is a GenericParameter (SEQUENCE)
+    PS_ParameterIdentifier x26 = &x25[0].parameterIdentifier;
+    PS_ParameterValue x27 = &x25[0].parameterValue;
+    x25[0].option_of_supersedes = OFF;
+
+    // x26 is a ParameterIdentifier (CHOICE)
+    x26->index = 0;
+    x26->standard = 0;
+
+    /* x27 is a ParameterValue (CHOICE) */
+    x27->index = 2;
+    x27->unsignedMin = 1;
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfoAmr(PS_GenericCapability amrCaps)
+{
+    CodecCapabilityInfo* cci = new CodecCapabilityInfo();
+    cci->codec = PV_AUD_TYPE_GSM;
+    cci->max_bitrate = amrCaps->maxBitRate;
+    return cci;
+}
+
+void FillUserInputCapability(CodecCapabilityInfo& codec_info,
+                             PS_UserInputCapability userinputCaps)
+{
+    switch (codec_info.codec)
+    {
+        case PV_UI_BASIC_STRING:
+            userinputCaps->index = 1;
+            break;
+        case PV_UI_IA5_STRING:
+            userinputCaps->index = 2;
+            break;
+        case PV_UI_GENERAL_STRING:
+            userinputCaps->index = 3;
+            break;
+        case PV_UI_DTMF:
+            userinputCaps->index = 4;
+            break;
+        default:
+            break;
+    }
+}
+
+CodecCapabilityInfo* GetCodecCapabilityInfo(PS_UserInputCapability uiCaps)
+{
+    CodecCapabilityInfo* cci = new CodecCapabilityInfo();
+    switch (uiCaps->index)
+    {
+        case 1:
+            cci->codec = PV_UI_BASIC_STRING;
+            break;
+        case 2:
+            cci->codec = PV_UI_IA5_STRING;
+            break;
+        case 3:
+            cci->codec = PV_UI_GENERAL_STRING;
+            break;
+        case 4:
+            cci->codec = PV_UI_DTMF;
+            break;
+    }
+    cci->max_bitrate = 0;
+    return cci;
+}
+
+void ParseCapabilityIdentifierStandard(uint8* octet_string,
+                                       uint16 octet_string_len,
+                                       S_CapabilityIdentifierStandard& capabilityIdentifier)
+{
+    oscl_memset(&capabilityIdentifier, 0,
+                sizeof(S_CapabilityIdentifierStandard));
+    if (octet_string_len < 6)
+        return;
+    capabilityIdentifier.spec_type = (uint8)(octet_string[0] % 10);
+    capabilityIdentifier.itu = (uint8)((octet_string[0] -
+                                        capabilityIdentifier.spec_type) / 40);
+    capabilityIdentifier.series_letter = octet_string[1];
+    capabilityIdentifier.spec_number = 0;
+    unsigned pos = 2;
+    do
+    {
+        capabilityIdentifier.spec_number =
+            capabilityIdentifier.spec_number << 7 | (octet_string[pos] & 0x7F);
+    }
+    while ((octet_string[pos++]&0x80) && (pos < octet_string_len));
+    unsigned tmp_pos = 0;
+    while (pos < octet_string_len)
+    {
+        capabilityIdentifier.data[tmp_pos++] = octet_string[pos++];
+    }
+}
+
+bool PVCheckSH(uint8 *ptr, int32 size)
+{
+    int count = 0;
+    int32 i = size - 4;
+
+    if (size < 0)
+    {
+        return false;
+    }
+    while (i--)
+    {
+        if ((count > 1) && (ptr[0] == 0x01) && (ptr[1] & 0xF0) == 0x20)
+        {
+            return false;
+        }
+
+        if (*ptr++)
+            count = 0;
+        else
+            count++;
+    }
+    return true;  // SH switch to h263
+}
+
+PVCodecType_t GetCodecType(PS_DataType pDataType)
+{
+    PVCodecType_t codecIndex = PV_INVALID_CODEC_TYPE;
+    if (!pDataType)
+        return PV_CODEC_TYPE_NONE;
+
+    if (pDataType->index == 1)
+    {  // null data
+        codecIndex = PV_CODEC_TYPE_NONE;  // No codec
+    }
+    else if (pDataType->index == 2)
+    {  // videoData
+        if (pDataType->videoData->index == 3)
+        {  // H263VideoCapability
+            codecIndex = PV_VID_TYPE_H263;
+        }
+        else if (pDataType->videoData->index == 5)
+        {  // GenericVideoCapability
+            codecIndex = GetVidCodecTypeFromVideoCapability(pDataType->videoData);
+        }
+    }
+    else if (pDataType->index == 3)
+    {  // audioData
+        if (pDataType->audioData->index == 8)
+        {  // G.723
+            codecIndex = PV_AUD_TYPE_G723;
+        }
+        else if (pDataType->audioData->index == 20)
+        {  // GenericAudioCapability
+            S_CapabilityIdentifierStandard capabilityIdentifierStandardInfo;
+            ParseCapabilityIdentifierStandard(
+                pDataType->audioData->genericAudioCapability->capabilityIdentifier.standard->data,
+                pDataType->audioData->genericAudioCapability->capabilityIdentifier.standard->size,
+                capabilityIdentifierStandardInfo);
+            if (capabilityIdentifierStandardInfo.itu != 0 ||
+                    capabilityIdentifierStandardInfo.spec_type != 0 ||
+                    capabilityIdentifierStandardInfo.series_letter != 8)
+            {
+                return PV_CODEC_TYPE_NONE;
+            }
+            if (capabilityIdentifierStandardInfo.spec_number != 245 ||
+                    capabilityIdentifierStandardInfo.data[0] != 1 || // generic capability
+                    capabilityIdentifierStandardInfo.data[1] != 1 || // AUDIO capability
+                    capabilityIdentifierStandardInfo.data[2] != 1)  // AMR capability
+            {
+                return PV_CODEC_TYPE_NONE;
+            }
+            codecIndex = PV_AUD_TYPE_GSM;
+        }
+    }
+    return codecIndex;
+}
+
+PV2WayMediaType GetMediaType(PS_DataType pDataType)
+{
+    PV2WayMediaType mediaType = PV_MEDIA_NONE;
+    if (!pDataType)
+        return mediaType;
+
+    if (pDataType->index == 2)
+    {  // videoData
+        mediaType = PV_VIDEO;
+    }
+    else if (pDataType->index == 3)
+    {  // audioData
+        mediaType = PV_AUDIO;
+    }
+    return mediaType;
+}
+
+// =======================================================
+// GetSimpleAudioType()						(RAN-32K)
+//
+// This routine takes the value from p324->GetAudioType()
+//   (an H324AudType_t enum) and maps it onto a
+//   simpler, reduced codec type space (an H324AudTypeSimple_t
+//   enum).  This is a convenience for the H.245 routines
+//   which don't need to know the audio rate.
+// =======================================================
+PVAudTypeSimple_t GetSimpleAudioType(PVAudType_t audio)
+{
+    if ((audio >= PV_AUD_TYPE_GSM_475) &&
+            (audio <= PV_AUD_TYPE_GSM_122))
+    {
+        return PV_AUD_TYPE_GSM;
+    }
+    else if (audio == PV_AUD_TYPE_G723_53 ||
+             audio == PV_AUD_TYPE_G723_63)
+    {
+        return PV_AUD_TYPE_G723;
+    }
+    else
+        return PV_SIMPLE_AUD_TYPE_NONE;
+}
+
+ErrorProtectionLevel_t GetEpl(uint16 al_index)
+{
+    switch (al_index)
+    {
+        case 1:
+        case 2:
+            return E_EP_LOW;
+        case 3:
+        case 4:
+            return E_EP_MEDIUM;
+        case 5:
+            return E_EP_HIGH;
+        default:
+            return E_EP_LOW;
+    }
+}
+
+void printBuffer(PVLogger* logger,
+                 const uint8* buffer,
+                 uint16 len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                    (0, "printBuffer(%d)", len));
+
+    const uint16 roundto = 10;
+    int32 cpylen = len + roundto - (len + roundto) % roundto;
+    uint8* cpy = (uint8*)OSCL_DEFAULT_MALLOC(cpylen);
+    uint8* cpysave = cpy;
+    oscl_memset(cpy, 0, cpylen);
+    oscl_memcpy(cpy, buffer, len);
+    int loops = cpylen / roundto;
+    for (uint16 num = 0; num < loops; ++num)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                        (0,
+                         "bytes(%d) %x %x %x %x %x %x %x %x %x %x",
+                         num, cpy[0], cpy[1], cpy[2], cpy[3], cpy[4], cpy[5],
+                         cpy[6], cpy[7], cpy[8], cpy[9]));
+        cpy += roundto;
+    }
+    OSCL_DEFAULT_FREE(cpysave);
+}
+
+unsigned GetFormatSpecificInfo(PS_DataType dataType,
+                               uint8*& fsi)
+{
+    uint32 size = 0;
+    PS_GenericParameter parameter_list = NULL, parameter = NULL;
+    PS_OCTETSTRING config = NULL;
+    unsigned ret = 0;
+    fsi = NULL;
+
+    if (!dataType ||
+            (dataType->index != 2) ||				// videoData
+            (dataType->videoData->index != 5))	// genericVideoCapability
+        return ret;
+
+    if (dataType->videoData->genericVideoCapability->option_of_nonCollapsing)
+    {
+        size =
+            dataType->videoData->genericVideoCapability->size_of_nonCollapsing;
+        parameter_list =
+            dataType->videoData->genericVideoCapability->nonCollapsing;
+    }
+    else if (dataType->videoData->genericVideoCapability->option_of_collapsing)
+    {
+        size =
+            dataType->videoData->genericVideoCapability->size_of_collapsing;
+        parameter_list =
+            dataType->videoData->genericVideoCapability->collapsing;
+    }
+    if (size == 0 || parameter_list == NULL)
+        return ret;
+
+    for (uint32 ii = 0; ii < size; ++ii)
+    {
+        parameter = parameter_list + ii;
+        if ((parameter->parameterIdentifier.index == 0) &&	// standard
+                (parameter->parameterValue.index == 6)) // OctetString
+        {
+            config = parameter->parameterValue.octetString;
+        }
+    }
+
+    if (config != NULL)
+    {		// Found valid decoderConfig
+        ret = config->size;
+        fsi = config->data;
+    }
+    return ret;
+}
+
+PS_Capability LookupCapability(PS_TerminalCapabilitySet pTcs,
+                               uint16 cap_entry_num)
+{
+    if (!(pTcs->option_of_capabilityTable &&
+            pTcs->option_of_capabilityDescriptors))
+    {
+        return NULL;
+    }
+    for (unsigned cap_entry = 0;
+            cap_entry < pTcs->size_of_capabilityTable;
+            ++cap_entry)
+    {
+        PS_CapabilityTableEntry pCapEntry = pTcs->capabilityTable + cap_entry;
+        if (pCapEntry->option_of_capability &&
+                pCapEntry->capabilityTableEntryNumber == cap_entry_num)
+        {
+            return &pCapEntry->capability;
+        }
+    }
+    return NULL;
+}
+
+bool IsTransmitOnlyAltCapSet(PS_TerminalCapabilitySet pTcs,
+                             PS_AlternativeCapabilitySet pAltCapSet)
+{
+    for (uint32 ii = 0;ii < pAltCapSet->size; ++ii)
+    {
+        uint32 entry = pAltCapSet->item[ii];
+        PS_Capability pCapability = LookupCapability(pTcs,
+                                    OSCL_STATIC_CAST(uint16, entry));
+        if (pCapability != NULL &&
+                pCapability->index != 2 &&
+                pCapability->index != 5)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+// =======================================================
+// VerifyCodecs()							(RAN-32K)
+//
+// This routine checks an outgoing audio/video combination
+//   against the capabilities of the remote terminal.
+// Note:
+//   audio, video are 'Simple' tags for outgoing codecs.
+//   pTcs  = Pointer to received TerminalCapabilitySet
+// The routine returns nonzero if the codec combo is OK.
+// =======================================================
+PVMFStatus VerifyCodecs(PS_TerminalCapabilitySet pTcs,
+                        Oscl_Vector<OlcFormatInfo, OsclMemAllocator> codecs,
+                        PVLogger *logger)
+{
+    PS_CapabilityTableEntry pCapEntry = NULL;
+    PS_CapabilityDescriptor pCapDesc = NULL;
+    PS_AlternativeCapabilitySet pAltCapSet = NULL;
+    unsigned num_codecs = codecs.size();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                    (0, "VerifyCodecs(%d)", num_codecs));
+
+    if (!(pTcs->option_of_capabilityTable &&
+            pTcs->option_of_capabilityDescriptors))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_WARNING,
+                        (0,
+                         "VerifyCodecs - No capabilities option_of_capabilityTable=%d,option_of_capabilityDescriptors=%d",
+                         pTcs->option_of_capabilityTable,
+                         pTcs->option_of_capabilityDescriptors));
+        return PVMFErrNotSupported;
+    }
+
+    Oscl_Map<PVCodecType_t, uint32, OsclMemAllocator> codec_capentry_map;
+
+    // verify if all the codecs are supported individually
+    for (unsigned codec_num = 0; codec_num < codecs.size(); ++codec_num)
+    {
+        bool codec_verified = false;
+        OlcFormatInfo& codec_info = codecs[codec_num];
+        bool is_symmetric = codec_info.isSymmetric;
+        if (codec_info.iCodec == PV_CODEC_TYPE_NONE)
+        {
+            num_codecs--;
+            continue;
+        }
+        for (unsigned cap_entry = 0;
+                cap_entry < pTcs->size_of_capabilityTable;
+                ++cap_entry)
+        {
+            pCapEntry = pTcs->capabilityTable + cap_entry;
+            if (pCapEntry->option_of_capability)
+            {
+                CodecCapabilityInfo cap_info;
+                GetCodecInfo(&pCapEntry->capability, cap_info);
+                if (((cap_info.dir == INCOMING) ||
+                        (cap_info.dir == PV_DIRECTION_BOTH && is_symmetric)) &&
+                        (codec_info.iCodec == cap_info.codec))
+                {
+                    codec_verified = true;
+                    codec_capentry_map.insert(
+                        Oscl_Map<PVCodecType_t, uint32, OsclMemAllocator>::value_type(
+                            codec_info.iCodec, pCapEntry->capabilityTableEntryNumber));
+                    break;
+                }
+            }
+        }
+        if (!codec_verified)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_WARNING,
+                            (0, "VerifyCodecs Codec not present in cap table(%d)",
+                             codec_info.iCodec));
+            return PVMFErrNotSupported;
+        }
+    }
+
+    if (num_codecs == 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                        (0, "VerifyCodecs - single codec ok.  No combo check reqd"));
+        return PVMFSuccess;
+    }
+
+    for (uint32 ii = 0; ii < pTcs->size_of_capabilityDescriptors; ++ii)
+    {
+        pCapDesc = pTcs->capabilityDescriptors + ii;
+        OSCL_ASSERT(pCapDesc->size_of_simultaneousCapabilities <=
+                    MAX_NUM_SIMULTANEOUS_CAPABILITIES);
+        // For each codec, create a bitwise OR of all
+        // the simultaneous cap entries that include it
+        Oscl_Map<PVCodecType_t, uint32, OsclMemAllocator> sim_caps_for_codec;
+        uint32 numValidAltCapSets = 0;
+        for (uint32 jj = 0; jj < pCapDesc->size_of_simultaneousCapabilities; ++jj)
+        {
+            // Does codec exist in this altCapSet?
+            pAltCapSet = pCapDesc->simultaneousCapabilities + jj;
+
+            if (IsTransmitOnlyAltCapSet(pTcs, pAltCapSet)) continue;
+
+            for (unsigned codec_num = 0; codec_num < codecs.size(); codec_num++)
+            {
+                OlcFormatInfo& codec_info = codecs[codec_num];
+                if (codec_info.iCodec != PV_CODEC_TYPE_NONE &&
+                        CheckAltCapSet(pAltCapSet,
+                                       codec_capentry_map[codec_info.iCodec]))
+                {
+                    uint32 mask = 1 << numValidAltCapSets;
+                    uint32 val = 0;
+                    Oscl_Map<PVCodecType_t, uint32, OsclMemAllocator>::iterator iter =
+                        sim_caps_for_codec.find(codec_info.iCodec);
+                    if (iter != sim_caps_for_codec.end())
+                        val = (*iter).second;
+                    val |= mask;
+                    sim_caps_for_codec[codec_info.iCodec] = val;
+                }
+            }
+            numValidAltCapSets++;
+        }
+        int32 sum = 0;
+        Oscl_Map<PVCodecType_t, uint32, OsclMemAllocator>::iterator iter =
+            sim_caps_for_codec.begin();
+        if (sim_caps_for_codec.size() < num_codecs)
+            continue;
+        uint16 num_unsupported_codecs = 0;
+        while (iter != sim_caps_for_codec.end())
+        {
+            if ((*iter).second == 0)
+                num_unsupported_codecs++;
+            sum |= (*iter++).second;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                        (0,
+                         "VerifyCodecs TSC verified vs codecs sum(%d) num_codecs(%d),num_unsupported_codecs(%d)",
+                         sum, num_codecs, num_unsupported_codecs));
+        if (num_unsupported_codecs == 0 && (g_num_ones[sum] >= num_codecs))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                            (0, "VerifyCodecs TSC verified vs codecs successfully"));
+            // Found match
+            return PVMFSuccess;
+        }
+    }
+
+    // COMBINATION failed
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_WARNING,
+                    (0, "VerifyCodecs Failed to find a single matching descriptor"));
+
+    return PVMFErrNotSupported;
+}
+
+PVMFStatus GetCodecCapInfo(PVCodecType_t codec,
+                           PS_TerminalCapabilitySet pTcs,
+                           CodecCapabilityInfo& codec_info,
+                           PVLogger *logger)
+{
+    OSCL_UNUSED_ARG(codec);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_STACK_TRACE,
+                    (0, "GetCodecCapInfo(%d)", codec));
+    PS_CapabilityTableEntry pCapEntry = NULL;
+
+    if (!(pTcs->option_of_capabilityTable && pTcs->option_of_capabilityDescriptors))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_WARNING,
+                        (0, "GetCodecCapInfo - Terminal is incapable of anything"));
+        return PVMFErrNotSupported;
+    }
+
+    for (unsigned cap_entry = 0; cap_entry < pTcs->size_of_capabilityTable; ++cap_entry)
+    {
+        pCapEntry = pTcs->capabilityTable + cap_entry;
+        if (pCapEntry->option_of_capability)
+        {
+            CodecCapabilityInfo cap_info;
+            GetCodecInfo(&pCapEntry->capability, cap_info);
+            if (cap_info.codec == codec)
+            {
+                codec_info = cap_info;
+                return PVMFSuccess;
+            }
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, logger, PVLOGMSG_WARNING,
+                    (0, "GetCodecInfo - codec not suppported"));
+    return PVMFErrNotSupported;
+}
+
+uint32 CheckAltCapSet(PS_AlternativeCapabilitySet pAltCapSet, uint32 entry)
+{
+    for (uint ii = 0; ii < pAltCapSet->size; ++ii)
+    {
+        if (pAltCapSet->item[ii] == entry)
+            return true;
+    }
+
+    return false;
+}
+
+
+PS_TerminalCapabilitySet GenerateTcs(MultiplexCapabilityInfo& mux_cap_info,
+                                     Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& outgoing_codecs,
+                                     Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& incoming_codecs)
+{
+    // === Auto Codeword Generation ===
+    PS_TerminalCapabilitySet ret =
+        (PS_TerminalCapabilitySet)OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySet));
+    oscl_memset(ret, 0, sizeof(S_TerminalCapabilitySet));
+
+    PS_MultiplexCapability x3 = NULL;
+    PS_H223Capability x4 =
+        (PS_H223Capability)OSCL_DEFAULT_MALLOC(sizeof(S_H223Capability));
+    oscl_memset(x4, 0, sizeof(S_H223Capability));
+
+    PS_H223MultiplexTableCapability x5 = NULL;
+    PS_MobileOperationTransmitCapability x6 = NULL;
+
+    unsigned sizeof_cap_table = outgoing_codecs.size() + incoming_codecs.size();
+    PS_CapabilityTableEntry x7 =
+        (PS_CapabilityTableEntry)OSCL_DEFAULT_MALLOC(sizeof(S_CapabilityTableEntry) *
+                sizeof_cap_table);
+    oscl_memset(x7, 0, sizeof(S_CapabilityTableEntry) * sizeof_cap_table);
+
+    unsigned sizeof_cap_descriptors = 1;
+    PS_CapabilityDescriptor x28 =
+        (PS_CapabilityDescriptor)OSCL_DEFAULT_MALLOC(sizeof(S_CapabilityDescriptor) *
+                sizeof_cap_descriptors);
+    oscl_memset(x28, 0, sizeof(S_CapabilityDescriptor) * sizeof_cap_descriptors);
+
+    // ================== //
+    // Build the Codeword //
+    // ================== //
+
+    // (Top two levels deleted -- RAN) //
+
+    // ret is a TerminalCapabilitySet (SEQUENCE) //
+    ret->sequenceNumber = 0;
+    // ----------- Define protocolID -------------- //
+    ret->protocolIdentifier.size = 6;
+    uint8* x2ProtocolIdentifierData = (uint8*)OSCL_DEFAULT_MALLOC(ret->protocolIdentifier.size);
+    x2ProtocolIdentifierData[0] = 0x00;
+    x2ProtocolIdentifierData[1] = 0x08;
+    x2ProtocolIdentifierData[2] = 0x81;
+    x2ProtocolIdentifierData[3] = 0x75;
+    x2ProtocolIdentifierData[4] = 0x00;
+    x2ProtocolIdentifierData[5] = 0x06;
+    ret->protocolIdentifier.data = x2ProtocolIdentifierData;
+
+    ret->option_of_multiplexCapability = ON;
+    ret->option_of_capabilityTable = ON;
+    ret->size_of_capabilityTable = (uint16)sizeof_cap_table;
+    ret->capabilityTable = x7;
+    ret->option_of_capabilityDescriptors = ON;
+    ret->size_of_capabilityDescriptors = (uint16)sizeof_cap_descriptors;
+    ret->capabilityDescriptors = x28;
+
+    // x3 is a MultiplexCapability (CHOICE) //
+    x3 = &ret->multiplexCapability;
+    x3->index = 2;
+    x3->h223Capability = x4;
+
+    // x4 is an H223Capability (SEQUENCE) //
+    x4->transportWithI_frames = OFF; // transmitting contro msgs within LAPM I-frames //
+    x4->videoWithAL1 = (mux_cap_info.iAllowAl1Video ? ON : OFF);
+    x4->videoWithAL2 = (mux_cap_info.iAllowAl2Video ? ON : OFF);
+    x4->videoWithAL3 = (mux_cap_info.iAllowAl3Video ? ON : OFF);
+    x4->audioWithAL1 = (mux_cap_info.iAllowAl1Audio ? ON : OFF);
+    x4->audioWithAL2 = (mux_cap_info.iAllowAl2Audio ? ON : OFF);
+    x4->audioWithAL3 = (mux_cap_info.iAllowAl3Audio ? ON : OFF);
+    x4->dataWithAL1 = OFF;
+    x4->dataWithAL2 = OFF;
+    x4->dataWithAL3 = OFF;
+    x4->maximumAl2SDUSize = (uint16)mux_cap_info.iMaximumAl2SDUSize;
+    x4->maximumAl3SDUSize = (uint16)mux_cap_info.iMaximumAl3SDUSize;
+    x4->maximumDelayJitter = 10;
+    x5 = &x4->h223MultiplexTableCapability;
+    x4->option_of_maxMUXPDUSizeCapability = ON;
+    x4->maxMUXPDUSizeCapability = ON;
+    x4->option_of_nsrpSupport = ON;
+    x4->nsrpSupport = ON;
+    x4->option_of_mobileOperationTransmitCapability = ON;
+    x6 = &x4->mobileOperationTransmitCapability;
+    x4->option_of_h223AnnexCCapability = OFF;
+
+    // x5 is an H223MultiplexTableCapability (CHOICE) //
+    x5->index = 0;
+
+    // x6 is a MobileOperationTransmitCapability (SEQUENCE) //
+    x6->modeChangeCapability = OFF;
+    x6->h223AnnexA = OFF;
+    x6->h223AnnexADoubleFlag = OFF;
+    x6->h223AnnexB = ON;
+    x6->h223AnnexBwithHeader = OFF;
+
+    // x7 is a set of  CapabilityTableEntry(s) //
+    unsigned entry_num = 1, codec_num = 0;
+
+    Oscl_Map<PV2WayMediaType, Oscl_Vector<unsigned, OsclMemAllocator>*, OsclMemAllocator>
+    cap_entries_for_media_type;
+    for (codec_num = 0; codec_num < incoming_codecs.size(); ++codec_num)
+    {
+        FillCapabilityTableEntry(x7 + entry_num - 1, *incoming_codecs[codec_num], entry_num);
+        PV2WayMediaType media_type = GetMediaType(incoming_codecs[codec_num]->codec);
+        Oscl_Vector<unsigned, OsclMemAllocator>* list = NULL;
+        Oscl_Map<PV2WayMediaType, Oscl_Vector<unsigned, OsclMemAllocator>*, OsclMemAllocator>::iterator iter =
+            cap_entries_for_media_type.find(media_type);
+        if (iter == cap_entries_for_media_type.end())
+        {
+            list = new Oscl_Vector<unsigned, OsclMemAllocator>();
+            cap_entries_for_media_type.insert(
+                Oscl_Map < PV2WayMediaType,
+                Oscl_Vector<unsigned, OsclMemAllocator>*,
+                OsclMemAllocator >::value_type(media_type, list));
+        }
+        else
+        {
+            list = (*iter).second;
+        }
+        list->push_back(entry_num++);
+    }
+
+    for (codec_num = 0; codec_num < outgoing_codecs.size(); ++codec_num)
+    {
+        FillCapabilityTableEntry(x7 + entry_num - 1, *outgoing_codecs[codec_num], entry_num);
+        entry_num++;
+    }
+
+
+    // x28 is a set of 1 CapabilityDescriptor(s) //
+    // x29 is a set of num_alt_cap_sets AlternativeCapabilitySet(s) //
+    unsigned num_alt_cap_sets = cap_entries_for_media_type.size();
+    PS_AlternativeCapabilitySet x29 =
+        (PS_AlternativeCapabilitySet)OSCL_DEFAULT_MALLOC(num_alt_cap_sets *
+                sizeof(S_AlternativeCapabilitySet));
+    oscl_memset(x29, 0, num_alt_cap_sets * sizeof(S_AlternativeCapabilitySet));
+    Oscl_Map < PV2WayMediaType,
+    Oscl_Vector<unsigned, OsclMemAllocator>*, OsclMemAllocator >::iterator iter =
+        cap_entries_for_media_type.begin();
+
+    // x28[0] is a CapabilityDescriptor (SEQUENCE) //
+    x28[0].capabilityDescriptorNumber = 0;
+    x28[0].option_of_simultaneousCapabilities = true;
+    x28[0].size_of_simultaneousCapabilities = (uint16)num_alt_cap_sets;
+    x28[0].simultaneousCapabilities = x29;
+
+    for (unsigned acsnum = 0; acsnum < num_alt_cap_sets; ++acsnum)
+    {
+        Oscl_Vector<unsigned, OsclMemAllocator>* alternatives = (*iter++).second;
+        x29[acsnum].item = (uint32*)OSCL_DEFAULT_MALLOC(sizeof(uint32) * alternatives->size());
+        x29[acsnum].size = (uint16)alternatives->size();
+        for (unsigned altnum = 0; altnum < alternatives->size(); ++altnum)
+        {
+            x29[acsnum].item[altnum] = (*alternatives)[altnum];
+        }
+        delete alternatives;
+    }
+
+    return ret;
+}
+
+void FillCapabilityTableEntry(PS_CapabilityTableEntry pCapEntry,
+                              CodecCapabilityInfo& codec_info,
+                              uint32 entry_num)
+{
+    pCapEntry->option_of_capability = 1;
+    pCapEntry->capabilityTableEntryNumber = (uint16)entry_num;
+    PS_Capability capability = &pCapEntry->capability;
+    FillCapability(codec_info, capability);
+}
+
+unsigned GetMaxFrameRate(PS_DataType pDataType)
+{
+    if (!pDataType)
+        return 0;
+    switch (GetCodecType(pDataType))
+    {
+        case PV_VID_TYPE_H263:
+            return GetMaxFrameRate_H263(pDataType->videoData->h263VideoCapability);
+        case PV_VID_TYPE_MPEG4:
+            return GetMaxFrameRate_M4V(
+                       pDataType->videoData->genericVideoCapability);
+        case PV_AUD_TYPE_GSM:
+            return 50;
+        case PV_AUD_TYPE_G723:
+            return 34;
+        default:
+            break;
+    }
+    return 0;
+}
+
+unsigned GetVideoFrameSize(PS_DataType pDataType, bool width)
+{
+    if (!pDataType)
+        return 0;
+    switch (GetCodecType(pDataType))
+    {
+        case PV_VID_TYPE_H263:
+            return GetVideoFrameSize_H263(pDataType->videoData->h263VideoCapability, width);
+        case PV_VID_TYPE_MPEG4:
+            return GetVideoFrameSize_M4V(
+                       pDataType->videoData->genericVideoCapability, width);
+        case PV_AUD_TYPE_GSM:
+            return 0;
+        case PV_AUD_TYPE_G723:
+            return 0;
+        default:
+            break;
+    }
+    return 0;
+}
+
+
+unsigned GetMaxBitrate(PS_DataType pDataType)
+{
+    if (!pDataType)
+        return 0;
+    switch (GetCodecType(pDataType))
+    {
+        case PV_VID_TYPE_H263:
+            return pDataType->videoData->h263VideoCapability->maxBitRate * 100;
+        case PV_VID_TYPE_MPEG4:
+            return pDataType->videoData->genericVideoCapability->maxBitRate * 100;
+        case PV_VID_TYPE_H264:
+            return pDataType->videoData->genericVideoCapability->maxBitRate * 100;
+        case PV_AUD_TYPE_GSM:
+            return pDataType->audioData->genericAudioCapability->maxBitRate * 100;
+        case PV_AUD_TYPE_G723:
+            return 6300;
+        default:
+            break;
+    }
+    return 0;
+}
+
+unsigned GetSampleInterval(PS_DataType pDataType)
+{
+    if (!pDataType)
+        return 0;
+    switch (GetCodecType(pDataType))
+    {
+        case PV_AUD_TYPE_GSM:
+            return 20;
+        case PV_AUD_TYPE_G723:
+            return 30;
+        default:
+            break;
+    }
+    return 0;
+}
+
+unsigned GetMaxFrameRate_H263(PS_H263VideoCapability h263caps)
+{
+    const int MPIMAX = 31;
+    unsigned mpi = MPIMAX;
+    if (h263caps->option_of_cif16MPI && h263caps->cif16MPI)
+    {
+        mpi = h263caps->cif16MPI;
+    }
+    if (h263caps->option_of_cif4MPI && h263caps->cif4MPI)
+    {
+        mpi = (h263caps->cif4MPI < mpi) ? h263caps->cif4MPI : mpi;
+    }
+    if (h263caps->option_of_cifMPI && h263caps->cifMPI)
+    {
+        mpi = (h263caps->cifMPI < mpi) ? h263caps->cifMPI : mpi;
+    }
+    if (h263caps->option_of_qcifMPI && h263caps->qcifMPI)
+    {
+        mpi = (h263caps->qcifMPI < mpi) ? h263caps->qcifMPI : mpi;
+    }
+    return mpi ? (unsigned)(30.0 / mpi) : 0;
+}
+
+unsigned GetMaxFrameRate_M4V(PS_GenericCapability m4vcaps)
+{
+    OSCL_UNUSED_ARG(m4vcaps);
+    return 15;
+}
+
+unsigned GetVideoFrameSize_H263(PS_H263VideoCapability h263caps, bool width)
+{
+    unsigned frame_width = 0;
+    unsigned frame_height = 0;
+
+    if (h263caps->option_of_cif16MPI && h263caps->cif16MPI)
+    {
+        //frame_width = 352;
+        //frame_height = 288;
+    }
+    if (h263caps->option_of_cif4MPI && h263caps->cif4MPI)
+    {
+        //frame_width = 352;
+        //frame_height = 288;
+    }
+    if (h263caps->option_of_cifMPI && h263caps->cifMPI)
+    {
+        frame_width = 352;
+        frame_height = 288;
+    }
+    if (h263caps->option_of_qcifMPI && h263caps->qcifMPI)
+    {
+        frame_width = 176;
+        frame_height = 144;
+    }
+
+    if (width == true)
+    {
+        return frame_width;
+    }
+    else
+    {
+        return frame_height;
+    }
+
+}
+
+unsigned GetVideoFrameSize_M4V(PS_GenericCapability m4vcaps , bool width)
+{
+    OSCL_UNUSED_ARG(m4vcaps);
+    if (width == true)
+    {
+        return 176;
+    }
+    else
+    {
+        return 144;
+    }
+}
+
+
+bool FindCodecForMediaType(PV2WayMediaType media,
+                           Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>&list,
+                           int* index)
+{
+    for (unsigned ii = 0; ii < list.size(); ++ii)
+    {
+        if (GetMediaType(list[ii]->codec) == media)
+        {
+            *index = ii;
+            return true;
+        }
+    }
+    return false;
+}
+
+bool IsSupported(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& list,
+                 PV2WayMediaType media_type,
+                 CodecCapabilityInfo& codec_info,
+                 int* index)
+{
+    for (unsigned nn = 0; nn < list.size(); ++nn)
+    {
+        H324ChannelParameters& param = list[nn];
+        if (param.GetMediaType() != media_type)
+            continue;
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* codecs =
+            param.GetCodecs();
+        if (!codecs)
+        {
+            return false;
+        }
+        codec_info.codec = PVMFFormatTypeToPVCodecType((*codecs)[0].format);
+        codec_info.dir = (*codecs)[0].dir;
+        *index = nn;
+        return true;
+    }
+    return false;
+}
+
+bool IsResolutionSupported(const PVMFVideoResolution& resolution,
+                           const Oscl_Vector < PVMFVideoResolutionRange,
+                           OsclMemAllocator > & resolutions)
+{
+    for (unsigned ii = 0; ii < resolutions.size(); ++ii)
+    {
+        if (resolution.height >= resolutions[ii].iFirst.height &&
+                resolution.height <= resolutions[ii].iLast.height &&
+                resolution.width >= resolutions[ii].iFirst.width &&
+                resolution.width <= resolutions[ii].iLast.width)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+PS_H223LogicalChannelParameters
+GetH223LogicalChannelParameters(uint8 al_index,
+                                bool segmentable,
+                                uint32 al_specific)
+{
+    PS_H223LogicalChannelParameters pParameter =
+        (PS_H223LogicalChannelParameters)OSCL_DEFAULT_MALLOC(
+            sizeof(S_H223LogicalChannelParameters));
+    oscl_memset(pParameter , 0, sizeof(S_H223LogicalChannelParameters));
+
+    pParameter->segmentableFlag = segmentable;
+    pParameter->adaptationLayerType.index = (uint16)al_index;
+    if (pParameter->adaptationLayerType.index == 5)
+    {
+        pParameter->adaptationLayerType.al3 = (PS_Al3) OSCL_DEFAULT_MALLOC(sizeof(S_Al3));
+        oscl_memset(pParameter->adaptationLayerType.al3, 0, sizeof(S_Al3));
+        pParameter->adaptationLayerType.al3->controlFieldOctets = (uint8)al_specific;
+        pParameter->adaptationLayerType.al3->sendBufferSize = DEF_AL3_SEND_BUFFER_SIZE;
+    }
+    return pParameter;
+}
+
+uint16 GetCodecCapabilityInfo(PS_TerminalCapabilitySet pTcs,
+                              PS_AlternativeCapabilitySet pAcs,
+                              Oscl_Vector < CodecCapabilityInfo*,
+                              OsclMemAllocator > & in_codecs_acs)
+{
+    uint16 num_media_types = 0;
+    PV2WayMediaType cur_media_type = PV_MEDIA_NONE;
+    for (int ll = 0; ll < pAcs->size; ++ll)
+    {
+        PS_Capability capability = LookupCapability(pTcs,
+                                   (uint16)pAcs->item[ll]);
+        if (!capability)
+        {
+            continue;
+        }
+        CodecCapabilityInfo* cci = GetCodecCapabilityInfo(capability);
+        if (cci == NULL)
+        {
+            continue;
+        }
+        PV2WayMediaType mediaType = GetMediaType(cci->codec);
+        if (mediaType == PV_MEDIA_NONE)
+        {
+            delete cci;
+        }
+        else
+        {
+            if (mediaType != cur_media_type)
+            {
+                num_media_types++;
+                cur_media_type = mediaType;
+            }
+            in_codecs_acs.push_back(cci);
+        }
+    }
+    return num_media_types;
+}
+
+void Deallocate(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& cci_list)
+{
+    for (unsigned ii = 0; ii < cci_list.size(); ++ii)
+    {
+        delete cci_list[ii];
+    }
+    cci_list.clear();
+}
+
+CodecCapabilityInfo* IsSupported(CodecCapabilityInfo* codecInfo,
+                                 Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& list)
+{
+    for (unsigned ii = 0; ii < list.size(); ++ii)
+    {
+        if (list[ii]->codec == codecInfo->codec)
+            return list[ii];
+    }
+    return NULL;
+}
+
+PVMFStatus SetFormatSpecificInfo(PS_DataType pDataType, uint8* fsi, uint32 fsi_len)
+{
+    PVCodecType_t codec_type = GetCodecType(pDataType);
+    if (codec_type != PV_VID_TYPE_MPEG4)
+    {
+        return PVMFFailure;
+    }
+    PS_OCTETSTRING octet_string = pDataType->videoData->genericVideoCapability->nonCollapsing[2].parameterValue.octetString;
+    OSCL_ASSERT(octet_string != NULL);
+    if (octet_string->data)
+    {
+        OSCL_DEFAULT_FREE(octet_string->data);
+        octet_string->data = NULL;
+        octet_string->size = 0;
+    }
+    octet_string->data = (uint8*)OSCL_DEFAULT_MALLOC(fsi_len);
+    oscl_memcpy(octet_string->data,
+                fsi,
+                fsi_len);
+    octet_string->size = fsi_len;
+    return PVMFSuccess;
+}
+
+uint32 SetFillerFsi(uint8* dest, uint32 dest_len)
+{
+    if (dest_len != PV2WAY_FILLER_FSI_LEN)
+        return 0;
+    uint8 buf[PV2WAY_FILLER_FSI_LEN] = PV2WAY_FILLER_FSI;
+    oscl_memcpy(dest, buf, dest_len);
+    return dest_len;
+}
+
+bool IsFillerFsi(uint8* fsi, uint32 fsi_len)
+{
+    if (fsi_len != PV2WAY_FILLER_FSI_LEN)
+        return false;
+    uint8 buf[PV2WAY_FILLER_FSI_LEN] = PV2WAY_FILLER_FSI;
+    if (oscl_memcmp(fsi, buf, fsi_len) == 0)
+        return true;
+    return false;
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/common/src/pvt_common.cpp b/protocols/systems/3g-324m_pvterminal/common/src/pvt_common.cpp
new file mode 100644
index 0000000..257b084
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/common/src/pvt_common.cpp
@@ -0,0 +1,997 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_base.h"
+#include "oscl_mem.h"
+
+#include "pvt_common.h"
+#include "pvt_params.h"
+
+
+/* CPVMediaParam */
+OSCL_EXPORT_REF CPVMediaParam::CPVMediaParam(PVCodecType_t aCodecType)
+        : iCodecType(aCodecType)
+{
+}
+
+OSCL_EXPORT_REF CPVMediaParam::~CPVMediaParam()
+{
+
+}
+
+OSCL_EXPORT_REF PVCodecType_t CPVMediaParam::GetCodecType()
+{
+    return iCodecType;
+}
+
+
+
+/* CPVAudioParam */
+OSCL_EXPORT_REF CPVParam* CPVAudioParam::Copy()
+{
+    return new CPVAudioParam(GetCodecType());
+}
+
+OSCL_EXPORT_REF PV2WayMediaType CPVAudioParam::GetMediaType()
+{
+    return PV_AUDIO;
+}
+
+CPVAudioParam::CPVAudioParam(PVCodecType_t aCodecType) : CPVMediaParam(aCodecType)
+{
+}
+
+/* CPVVideoParam */
+OSCL_EXPORT_REF CPVVideoParam::~CPVVideoParam()
+{
+}
+
+OSCL_EXPORT_REF PV2WayMediaType CPVVideoParam::GetMediaType()
+{
+    return PV_VIDEO;
+}
+
+OSCL_EXPORT_REF CPVParam* CPVVideoParam::Copy()
+{
+    return new CPVVideoParam(iWidth, iHeight, GetCodecType());
+}
+
+OSCL_EXPORT_REF uint16 CPVVideoParam::GetWidth()
+{
+    return iWidth;
+}
+
+OSCL_EXPORT_REF uint16 CPVVideoParam::GetHeight()
+{
+    return iHeight;
+}
+
+CPVVideoParam::CPVVideoParam(uint16 aWidth, uint16 aHeight, PVCodecType_t aCodecType)
+        : CPVMediaParam(aCodecType), iWidth(aWidth), iHeight(aHeight)
+{
+}
+
+
+OSCL_EXPORT_REF CPVM4vVideoParam::CPVM4vVideoParam(uint16 w, uint16 h, uint16 sz, uint8 *cfg)
+        : CPVVideoParam(w, h, PV_VID_TYPE_MPEG4), iSz(sz), iCfg(NULL)
+{
+    if (iSz)
+    {
+        iCfg = (uint8 *)OSCL_DEFAULT_MALLOC(iSz);
+        oscl_memcpy(iCfg, cfg, iSz);
+    }
+}
+
+OSCL_EXPORT_REF CPVM4vVideoParam::~CPVM4vVideoParam()
+{
+    if (iCfg)
+    {
+        OSCL_DEFAULT_FREE(iCfg);
+        iCfg = NULL;
+    }
+}
+
+OSCL_EXPORT_REF uint16 CPVM4vVideoParam::GetDecoderConfigSize()
+{
+    return iSz;
+}
+
+OSCL_EXPORT_REF uint8 *CPVM4vVideoParam::GetDecoderConfig()
+{
+    return iCfg;
+}
+
+OSCL_EXPORT_REF OsclAny CPVM4vVideoParam::Set(uint16 config_sz, uint8* cfg)
+{
+    iSz = config_sz;
+    if (iCfg)
+    {
+        OSCL_DEFAULT_FREE(iCfg);
+        iCfg = NULL;
+    }
+
+    if (iSz)
+    {
+        iCfg = (uint8 *)OSCL_DEFAULT_MALLOC(iSz);
+        oscl_memcpy(iCfg, cfg, iSz);
+    }
+}
+
+OSCL_EXPORT_REF CPVParam* CPVM4vVideoParam::Copy()
+{
+    return new CPVM4vVideoParam(GetWidth(), GetHeight(), iSz, iCfg);
+}
+
+/* CPVAMRAudioParam */
+OSCL_EXPORT_REF CPVAMRAudioParam::CPVAMRAudioParam() : CPVAudioParam(PV_AUD_TYPE_GSM)
+{
+}
+
+OSCL_EXPORT_REF CPVAMRAudioParam::~CPVAMRAudioParam()
+{
+}
+
+/* CPVG723AudioParam */
+OSCL_EXPORT_REF CPVG723AudioParam::CPVG723AudioParam() : CPVAudioParam(PV_AUD_TYPE_G723)
+{
+}
+
+OSCL_EXPORT_REF CPVG723AudioParam::~CPVG723AudioParam()
+{
+
+}
+
+/* CPVH263VideoParam */
+OSCL_EXPORT_REF CPVH263VideoParam::CPVH263VideoParam(uint16 w, uint16 h) : CPVVideoParam(w, h, PV_VID_TYPE_H263)
+{
+}
+
+OSCL_EXPORT_REF CPVH263VideoParam::~CPVH263VideoParam()
+{
+
+}
+
+
+
+/* CPVTrackInfo */
+OSCL_EXPORT_REF bool operator==(CPVTrackInfo &a, CPVTrackInfo &b)
+{
+    return ((a.GetDirection() == b.GetDirection()) && (a.GetChannelId() == b.GetChannelId()));
+}
+
+/* CPVUserInputDtmf */
+OSCL_EXPORT_REF CPVUserInputDtmf::CPVUserInputDtmf(uint8 input, bool update, uint16 duration)
+{
+    iInput = input;
+    iIsUpdate = update;
+    iDuration = duration;
+}
+
+OSCL_EXPORT_REF TPVUserInputType CPVUserInputDtmf::GetType()
+{
+    return EDtmf;
+}
+
+OSCL_EXPORT_REF uint8 CPVUserInputDtmf::GetInput()
+{
+    return iInput;
+}
+
+OSCL_EXPORT_REF bool CPVUserInputDtmf::IsUpdate()
+{
+    return iIsUpdate;
+}
+
+OSCL_EXPORT_REF uint16 CPVUserInputDtmf::GetDuration()
+{
+    return iDuration;
+}
+OSCL_EXPORT_REF CPVUserInput* CPVUserInputDtmf::Copy()
+{
+    return new CPVUserInputDtmf(iInput, iIsUpdate, iDuration);
+}
+
+/* CPVUserInputAlphanumeric */
+OSCL_EXPORT_REF CPVUserInputAlphanumeric::CPVUserInputAlphanumeric(uint8* input, uint16 len): iInput(NULL), iLength(len)
+{
+    if ((len > 0) && (input != NULL))
+    {
+        iInput = (uint8*) OSCL_DEFAULT_MALLOC(len);
+        oscl_memcpy(iInput, input, len);
+    }
+}
+
+OSCL_EXPORT_REF CPVUserInputAlphanumeric::~CPVUserInputAlphanumeric()
+{
+    if (iInput)
+    {
+        OSCL_DEFAULT_FREE(iInput);
+    }
+}
+
+OSCL_EXPORT_REF TPVUserInputType CPVUserInputAlphanumeric::GetType()
+{
+    return EAlphanumeric ;
+}
+
+OSCL_EXPORT_REF uint8* CPVUserInputAlphanumeric::GetInput()
+{
+    return iInput;
+}
+
+OSCL_EXPORT_REF uint16 CPVUserInputAlphanumeric::GetLength()
+{
+    return iLength;
+}
+OSCL_EXPORT_REF CPVUserInput* CPVUserInputAlphanumeric::Copy()
+{
+    return new CPVUserInputAlphanumeric(iInput, iLength);
+}
+
+/* TPVH245VendorObjectIdentifier */
+OSCL_EXPORT_REF TPVH245VendorObjectIdentifier::TPVH245VendorObjectIdentifier(uint8* vendor, uint16 vendorLength)
+        : iVendor(NULL), iVendorLength(vendorLength)
+{
+    iVendor = (uint8*)OSCL_DEFAULT_MALLOC(iVendorLength);
+    oscl_memcpy(iVendor, vendor, iVendorLength);
+}
+
+OSCL_EXPORT_REF TPVH245VendorObjectIdentifier::~TPVH245VendorObjectIdentifier()
+{
+    if (iVendor)
+    {
+        OSCL_DEFAULT_FREE(iVendor);
+    }
+}
+
+OSCL_EXPORT_REF TPVH245VendorType TPVH245VendorObjectIdentifier::GetVendorType()
+{
+    return EObjectIdentifier;
+}
+
+OSCL_EXPORT_REF uint8* TPVH245VendorObjectIdentifier::GetVendor(uint16* length)
+{
+    *length = iVendorLength;
+    return iVendor;
+}
+
+OSCL_EXPORT_REF TPVH245Vendor* TPVH245VendorObjectIdentifier::Copy()
+{
+    return OSCL_NEW(TPVH245VendorObjectIdentifier, (iVendor, iVendorLength));
+}
+
+
+/* TPVVendorH221NonStandard */
+OSCL_EXPORT_REF TPVVendorH221NonStandard::TPVVendorH221NonStandard(uint8 t35countryCode, uint8 t35extension, uint32 manufacturerCode):
+        iT35CountryCode(t35countryCode), iT35Extension(t35extension), iManufacturerCode(manufacturerCode)
+{
+}
+
+OSCL_EXPORT_REF TPVVendorH221NonStandard::~TPVVendorH221NonStandard()
+{
+}
+
+OSCL_EXPORT_REF TPVH245VendorType TPVVendorH221NonStandard::GetVendorType()
+{
+    return EH221NonStandard;
+}
+
+OSCL_EXPORT_REF TPVH245Vendor* TPVVendorH221NonStandard::Copy()
+{
+    return OSCL_NEW(TPVVendorH221NonStandard, (iT35CountryCode, iT35Extension, iManufacturerCode));
+}
+
+OSCL_EXPORT_REF uint8 TPVVendorH221NonStandard::GetT35CountryCode()
+{
+    return iT35CountryCode;
+}
+
+OSCL_EXPORT_REF uint8 TPVVendorH221NonStandard::GetT35Extension()
+{
+    return iT35Extension;
+}
+
+OSCL_EXPORT_REF uint32 TPVVendorH221NonStandard::GetManufacturerCode()
+{
+    return iManufacturerCode;
+}
+
+/* TPVVendorIdentification */
+OSCL_EXPORT_REF TPVVendorIdentification::TPVVendorIdentification() : iVendor(NULL), iProductNumber(NULL), iProductNumberLen(0),
+        iVersionNumber(NULL), iVersionNumberLen(0)
+{
+}
+
+OSCL_EXPORT_REF TPVVendorIdentification::TPVVendorIdentification(TPVH245Vendor* vendor,
+        uint8* pn, uint16 pn_len,
+        uint8* vn, uint16 vn_len)
+{
+    if (vendor)
+    {
+        iVendor = vendor->Copy();
+    }
+    if (pn_len)
+    {
+        iProductNumber = (uint8*)OSCL_DEFAULT_MALLOC(pn_len);
+        oscl_memcpy(iProductNumber, pn, pn_len);
+        iProductNumberLen = pn_len;
+    }
+    if (vn_len)
+    {
+        iVersionNumber = (uint8*)OSCL_DEFAULT_MALLOC(vn_len);
+        oscl_memcpy(iVersionNumber, vn, vn_len);
+        iVersionNumberLen = vn_len;
+    }
+}
+
+OSCL_EXPORT_REF TPVVendorIdentification::~TPVVendorIdentification()
+{
+    if (iVendor)
+    {
+        OSCL_DELETE(iVendor);
+    }
+    if (iProductNumber)
+    {
+        OSCL_DEFAULT_FREE(iProductNumber);
+    }
+    if (iVersionNumber)
+    {
+        OSCL_DEFAULT_FREE(iVersionNumber);
+    }
+}
+
+
+/* CPvtDiagnosticIndication */
+OSCL_EXPORT_REF CPvtDiagnosticIndication::CPvtDiagnosticIndication(TPVTerminalEvent aEvent, int aParam1, int aParam2, int aParam3)
+        : iEvent(aEvent), iParam1(aParam1), iParam2(aParam2), iParam3(aParam3)
+{
+}
+
+OSCL_EXPORT_REF CPvtDiagnosticIndication::~CPvtDiagnosticIndication()
+{
+}
+
+/* CPVGenericMuxParam */
+OSCL_EXPORT_REF CPVGenericMuxParam::CPVGenericMuxParam(TPVMuxType aMuxType):
+        discard_corrupt_video(PARAM_DEFAULT),
+        max_discard_video_sdu_size(0),
+        err_rate_threshold_to_req_I_frame(0),
+        audio_err_rate_update_interval(0),
+        audio_encode_frame_delay(0),
+        audio_decode_frame_delay(0),
+        iMuxType(aMuxType)
+{
+}
+
+OSCL_EXPORT_REF TPVMuxType CPVGenericMuxParam::GetMuxType()
+{
+    return iMuxType;
+}
+
+OSCL_EXPORT_REF CPVParam* CPVGenericMuxParam::Copy()
+{
+    CPVGenericMuxParam* ret = new CPVGenericMuxParam(iMuxType);
+    ret->discard_corrupt_video = discard_corrupt_video;
+    ret->max_discard_video_sdu_size = max_discard_video_sdu_size;
+    ret->err_rate_threshold_to_req_I_frame = err_rate_threshold_to_req_I_frame;
+    ret->audio_err_rate_update_interval = audio_err_rate_update_interval;
+    ret->audio_encode_frame_delay = audio_encode_frame_delay;
+    ret->audio_decode_frame_delay = audio_decode_frame_delay;
+    return ret;
+}
+
+OSCL_EXPORT_REF OsclAny CPVGenericMuxParam::Copy(CPVGenericMuxParam* param)
+{
+    param->discard_corrupt_video = discard_corrupt_video;
+    param->max_discard_video_sdu_size = max_discard_video_sdu_size;
+    param->err_rate_threshold_to_req_I_frame = err_rate_threshold_to_req_I_frame;
+    param->audio_err_rate_update_interval = audio_err_rate_update_interval;
+    param->audio_encode_frame_delay = audio_encode_frame_delay;
+    param->audio_decode_frame_delay = audio_decode_frame_delay;
+    return;
+}
+
+
+/* CPVH223MuxParam */
+OSCL_EXPORT_REF CPVH223MuxParam::CPVH223MuxParam() : CPVGenericMuxParam(MUX_H223),
+        iBitrate(PVT_NOT_SET),
+        iLevel(H223_LEVEL_UNKNOWN),
+        iMaxAl1SduSize(PVT_NOT_SET),
+        iMaxAl2SduSize(PVT_NOT_SET),
+        iMaxAl3SduSize(PVT_NOT_SET),
+        iMaxAl1SduSizeR(PVT_NOT_SET),
+        iMaxAl2SduSizeR(PVT_NOT_SET),
+        iMaxAl3SduSizeR(PVT_NOT_SET),
+        iParseOnResyncMarkers(false),
+        iOutgoingPduType(H223_PDU_COMBINED),
+        iMaxPduSize(0),
+        iIdleSyncType(H223_IDLE_SYNC_NONE),
+        iIdleSyncByte(0x00)
+{
+}
+
+OSCL_EXPORT_REF CPVH223MuxParam::~CPVH223MuxParam()
+{
+}
+
+OSCL_EXPORT_REF CPVParam* CPVH223MuxParam::Copy()
+{
+    CPVH223MuxParam* ret = new CPVH223MuxParam();
+    CPVGenericMuxParam::Copy(ret);
+    ret->iBitrate = iBitrate;
+    ret->iLevel = iLevel;
+    ret->iMaxAl1SduSize = iMaxAl1SduSize;
+    ret->iMaxAl2SduSize = iMaxAl2SduSize;
+    ret->iMaxAl3SduSize = iMaxAl3SduSize;
+    ret->iMaxAl1SduSizeR = iMaxAl1SduSizeR;
+    ret->iMaxAl2SduSizeR = iMaxAl2SduSizeR;
+    ret->iMaxAl3SduSizeR = iMaxAl3SduSizeR;
+    ret->iParseOnResyncMarkers = iParseOnResyncMarkers;
+    ret->iOutgoingPduType = iOutgoingPduType;
+    ret->iMaxPduSize = iMaxPduSize;
+    ret->iIdleSyncType = iIdleSyncType;
+    ret->iIdleSyncByte = iIdleSyncByte;
+    return ret;
+}
+
+/* CPVH245Param */
+OSCL_EXPORT_REF CPVH245Param::CPVH245Param()
+{
+}
+
+OSCL_EXPORT_REF CPVParam* CPVH245Param::Copy()
+{
+    CPVH245Param* ret = new CPVH245Param();
+    return ret;
+}
+
+/* CPVSrpParam */
+OSCL_EXPORT_REF CPVSrpParam::CPVSrpParam()
+{
+
+}
+
+OSCL_EXPORT_REF CPVParam* CPVSrpParam::Copy()
+{
+    CPVSrpParam* ret = new CPVSrpParam();
+    return ret;
+}
+
+/* CPVTerminalParam */
+OSCL_EXPORT_REF CPVTerminalParam::CPVTerminalParam(CPVGenericMuxParam* muxParam): iMuxParam(NULL)
+{
+    if (muxParam)
+    {
+        iMuxParam = (CPVGenericMuxParam*)muxParam->Copy();
+    }
+}
+
+OSCL_EXPORT_REF CPVTerminalParam::CPVTerminalParam(CPVTerminalParam& that): CPVParam(that), iMuxParam(NULL)
+{
+    if (that.iMuxParam)
+    {
+        iMuxParam = (CPVGenericMuxParam*)that.iMuxParam->Copy();
+    }
+}
+
+
+CPVTerminalParam::~CPVTerminalParam()
+{
+    if (iMuxParam)
+    {
+        delete iMuxParam;
+    }
+}
+
+
+OSCL_EXPORT_REF OsclAny CPVTerminalParam::SetMuxParam(CPVGenericMuxParam* muxParam)
+{
+    if (iMuxParam)
+    {
+        delete iMuxParam;
+    }
+    iMuxParam = (CPVGenericMuxParam*)muxParam->Copy();
+}
+
+OSCL_EXPORT_REF CPVGenericMuxParam* CPVTerminalParam::GetMuxParam()
+{
+    return iMuxParam;
+}
+
+/* CPVH324MParam */
+OSCL_EXPORT_REF CPVH324MParam::CPVH324MParam(CPVH223MuxParam* h223param) : CPVTerminalParam(h223param), iH245Param(NULL), iSrpParam(NULL)
+{
+    iAllowAl1Video = false;
+    iAllowAl2Video = true;
+    iAllowAl3Video = true;
+    iUseAl1Video = true;
+    iUseAl2Video = true;
+    iUseAl3Video = true;
+    iVideoLayer = PVT_AL_UNKNOWN;
+    iMasterSlave = PVT_MSD_INDETERMINATE;
+    iForceVideoLayerIfMaster = PVT_AL_UNKNOWN;
+    iForceVideoLayerIfSlave = PVT_AL_UNKNOWN;
+    iSpecifyReceiveAndTransmitCapability = false;
+    iSendRme = false;
+    iSkipMsd = false;
+    iRequestMaxMuxPduSize = 0;
+}
+
+OSCL_EXPORT_REF CPVH324MParam::CPVH324MParam(const CPVH324MParam& that) : CPVTerminalParam((CPVTerminalParam&)that)
+{
+    iAllowAl1Video = that.iAllowAl1Video;
+    iAllowAl2Video = that.iAllowAl2Video;
+    iAllowAl3Video = that.iAllowAl3Video;
+    iUseAl1Video = that.iUseAl1Video;
+    iUseAl2Video = that.iUseAl2Video;
+    iUseAl3Video = that.iUseAl3Video;
+    iVideoLayer = that.iVideoLayer;
+    iMasterSlave = that.iMasterSlave;
+    iForceVideoLayerIfMaster = that.iForceVideoLayerIfMaster;
+    iForceVideoLayerIfSlave = that.iForceVideoLayerIfSlave;
+    iSpecifyReceiveAndTransmitCapability = that.iSpecifyReceiveAndTransmitCapability;
+    iSendRme = that.iSendRme;
+    iSkipMsd = that.iSkipMsd;
+    iRequestMaxMuxPduSize = that.iRequestMaxMuxPduSize;
+    iH245Param = NULL;
+    if (that.iH245Param)
+        iH245Param = (CPVH245Param*)that.iH245Param->Copy();
+    iSrpParam = NULL;
+    if (that.iSrpParam)
+        iSrpParam = (CPVSrpParam*)that.iSrpParam->Copy();
+}
+
+OSCL_EXPORT_REF CPVH324MParam::~CPVH324MParam()
+{
+
+}
+
+OSCL_EXPORT_REF TPVTerminalType CPVH324MParam::GetTerminalType()
+{
+    return PV_324M;
+}
+
+OSCL_EXPORT_REF CPVParam* CPVH324MParam::Copy()
+{
+    return new CPVH324MParam(*this);
+}
+
+OSCL_EXPORT_REF OsclAny CPVH324MParam::SetH223Param(CPVH223MuxParam* h223Param)
+{
+    SetMuxParam(h223Param);
+}
+
+OSCL_EXPORT_REF CPVH223MuxParam* CPVH324MParam::GetH223Param()
+{
+    return (CPVH223MuxParam*)GetMuxParam();
+}
+
+OSCL_EXPORT_REF OsclAny CPVH324MParam::SetSRPParam(CPVSrpParam* srpParam)
+{
+    iSrpParam = (CPVSrpParam*)srpParam->Copy();
+}
+
+OSCL_EXPORT_REF OsclAny CPVH324MParam::SetH245Param(CPVH245Param* h245Param)
+{
+    iH245Param = (CPVH245Param*)h245Param->Copy();
+}
+
+OSCL_EXPORT_REF TPVVideoEncoderParam::TPVVideoEncoderParam():
+        video_bitrate(KPVDefaultVideoBitRate),
+        codec(PV_VID_TYPE_MPEG4),
+        video_frame_rate(KPVDefaultFrameRate),
+        air(0),
+        intra_refresh(1),
+        data_partitioning(1),
+        advanced(0),
+        use_gov(0),
+        rvlc(0),
+        use_resync(480),
+        use_hec(0),
+        use_gobsync(0),
+        vos(0),
+        ref_frame_rate(15),
+        orig_frameskip(1),
+        chosen_frame_skip(3),
+        qp(10),
+        qpi(10),
+        cam_low_light_mode(1),
+        cam_saturation_level(55),
+        cam_contrast_level(90),
+        cam_edge_enhance(85),
+        cam_brightness(100),
+        deblocking_filter(0),
+        prefilter(0),
+        prefilter_coeff1(0),
+        prefilter_coeff2(0),
+        prefilter_coeff3(0),
+        buffer_backlog(-55000),
+        qp_max(31),
+        qp_min(1),
+        qp_delta_frame(30),
+        qp_delta_slice(30),
+        iframe_interval(KPVDefaultIFrameInterval),
+        iframe_request_interval(KPVDefaultIFrameRequestInterval)
+{};
+
+
+OSCL_EXPORT_REF PVMFFormatType PVCodecTypeToPVMFFormatType(PVCodecType_t aCodecType)
+{
+    PVMFFormatType aFormatType = PVMF_MIME_FORMAT_UNKNOWN;
+    switch (aCodecType)
+    {
+        case PV_AUD_TYPE_G723:
+            aFormatType = PVMF_MIME_G723;
+            break;
+        case PV_AUD_TYPE_GSM:
+            aFormatType = PVMF_MIME_AMR_IF2;
+            break;
+        case PV_VID_TYPE_H263:
+            aFormatType = PVMF_MIME_H2632000;
+            break;
+        case PV_VID_TYPE_MPEG4:
+            aFormatType = PVMF_MIME_M4V;
+            break;
+        default:
+            break;
+    }
+    return aFormatType;
+}
+
+OSCL_EXPORT_REF PVCodecType_t PVMFFormatTypeToPVCodecType(PVMFFormatType aFormatType)
+{
+    PVCodecType_t aCodecType = PV_CODEC_TYPE_NONE;
+
+    if (aFormatType == PVMF_MIME_G723)
+    {
+        aCodecType = PV_AUD_TYPE_G723;
+    }
+    else if (aFormatType == PVMF_MIME_AMR_IF2)
+    {
+        aCodecType = PV_AUD_TYPE_GSM;
+    }
+    else if ((aFormatType == PVMF_MIME_H2632000) || (aFormatType == PVMF_MIME_H2631998))
+    {
+        aCodecType = PV_VID_TYPE_H263;
+    }
+    else if (aFormatType == PVMF_MIME_M4V)
+    {
+        aCodecType = PV_VID_TYPE_MPEG4;
+    }
+    else if (aFormatType == PVMF_MIME_USERINPUT_BASIC_STRING)
+    {
+        aCodecType = PV_UI_BASIC_STRING;
+    }
+    else if (aFormatType == PVMF_MIME_USERINPUT_IA5_STRING)
+    {
+        aCodecType = PV_UI_IA5_STRING;
+    }
+    else if (aFormatType == PVMF_MIME_USERINPUT_GENERAL_STRING)
+    {
+        aCodecType = PV_UI_GENERAL_STRING;
+    }
+    else if (aFormatType == PVMF_MIME_USERINPUT_DTMF)
+    {
+        aCodecType = PV_UI_DTMF;
+    }
+
+    return aCodecType;
+}
+
+OSCL_EXPORT_REF PV2WayMediaType PVMFFormatTypeToPVMediaType(PVMFFormatType aFormatType)
+{
+    PV2WayMediaType aMediaType = PV_MEDIA_NONE;
+    if (aFormatType.isAudio())
+    {
+        aMediaType = PV_AUDIO;
+    }
+    if (aFormatType.isVideo())
+    {
+        aMediaType = PV_VIDEO;
+    }
+    if (aFormatType.isUserInput())
+    {
+        aMediaType = PV_USER_INPUT;
+    }
+    return aMediaType;
+}
+
+
+OSCL_EXPORT_REF int IndexForAdaptationLayer(TPVAdaptationLayer al)
+{
+    int ret = -1;
+    switch (al)
+    {
+        case PVT_AL1:
+            ret = 2;
+            break;
+        case PVT_AL2:
+            ret = 3;
+            break;
+        case PVT_AL3:
+            ret = 5;
+            break;
+        default:
+            break;
+    }
+    return ret;
+}
+
+OSCL_EXPORT_REF TPVAdaptationLayer AdaptationLayerForIndex(int al_index)
+{
+    TPVAdaptationLayer ret = PVT_AL1;
+    switch (al_index)
+    {
+        case 1:
+        case 2:
+            ret = PVT_AL1;
+            break;
+        case 3:
+        case 4:
+            ret = PVT_AL2;
+            break;
+        case 5:
+            ret = PVT_AL3;
+            break;
+    }
+    return ret;
+}
+
+OSCL_EXPORT_REF ErrorProtectionLevel_t EplForAdaptationLayer(TPVAdaptationLayer al)
+{
+    ErrorProtectionLevel_t epl = E_EP_LOW;
+    switch (al)
+    {
+        case PVT_AL1:
+            epl = E_EP_LOW;
+            break;
+        case PVT_AL2:
+            epl = E_EP_MEDIUM;
+            break;
+        case PVT_AL3:
+            epl = E_EP_HIGH;
+            break;
+        default:
+            break;
+    }
+    return epl;
+}
+
+OSCL_EXPORT_REF PV2WayMediaType GetMediaType(PVCodecType_t codec)
+{
+    PV2WayMediaType media_type = PV_MEDIA_NONE;
+    switch (codec)
+    {
+        case PV_AUD_TYPE_G723:
+        case PV_AUD_TYPE_GSM:
+            media_type = PV_AUDIO;
+            break;
+        case PV_VID_TYPE_H263:
+        case PV_VID_TYPE_MPEG4:
+            media_type = PV_VIDEO;
+            break;
+        case PV_UI_BASIC_STRING:
+        case PV_UI_IA5_STRING:
+        case PV_UI_GENERAL_STRING:
+        case PV_UI_DTMF:
+            media_type = PV_USER_INPUT;
+            break;
+        default:
+            break;
+    }
+    return media_type;
+}
+
+OSCL_EXPORT_REF H324ChannelParameters::H324ChannelParameters(TPVDirection dir, PVMFFormatType mediaType, unsigned bandwidth)
+        : iCodecs(NULL)
+{
+    OSCL_UNUSED_ARG(mediaType);
+    iBandwidth = bandwidth;
+    iCodecs = new Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>();
+    FormatCapabilityInfo codec_info;
+    codec_info.dir = dir;
+}
+
+OSCL_EXPORT_REF H324ChannelParameters::H324ChannelParameters(const H324ChannelParameters& that)
+        : iCodecs(NULL)
+{
+    iBandwidth = that.iBandwidth;
+
+    if (that.iCodecs)
+    {
+        iCodecs = new Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>(*that.iCodecs);
+    }
+}
+
+OSCL_EXPORT_REF H324ChannelParameters::~H324ChannelParameters()
+{
+    if (iCodecs)
+        OSCL_DELETE(iCodecs);
+}
+
+OSCL_EXPORT_REF PV2WayMediaType H324ChannelParameters::GetMediaType()
+{
+    if (iCodecs == NULL)
+    {
+        return PV_MEDIA_NONE;
+    }
+    return PVMFFormatTypeToPVMediaType((*iCodecs)[0].format);
+}
+
+OSCL_EXPORT_REF unsigned H324ChannelParameters::GetBandwidth()
+{
+    return iBandwidth;
+}
+
+OSCL_EXPORT_REF void H324ChannelParameters::SetCodecs(Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& codecs)
+{
+    if (iCodecs)
+    {
+        OSCL_DELETE(iCodecs);
+        iCodecs = NULL;
+    }
+    if (!codecs.size())
+        return;
+
+    iCodecs = new Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>(codecs);
+}
+
+OSCL_EXPORT_REF Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* H324ChannelParameters::GetCodecs()
+{
+    return iCodecs;
+}
+
+OSCL_EXPORT_REF CodecCapabilityInfo::CodecCapabilityInfo()
+        : codec(PV_CODEC_TYPE_NONE),
+        dir(PV_DIRECTION_NONE),
+        max_bitrate(0),
+        min_sample_size(0),
+        max_sample_size(0)
+{
+}
+
+OSCL_EXPORT_REF CodecCapabilityInfo* CodecCapabilityInfo::Copy()
+{
+    CodecCapabilityInfo* ret = new CodecCapabilityInfo();
+    ret->codec = codec;
+    ret->dir = dir;
+    ret->max_bitrate = max_bitrate;
+    return ret;
+}
+
+OSCL_EXPORT_REF VideoCodecCapabilityInfo::VideoCodecCapabilityInfo()
+        : codec_specific_info(NULL),
+        codec_specific_info_len(0)
+{
+}
+
+OSCL_EXPORT_REF CodecCapabilityInfo* VideoCodecCapabilityInfo::Copy()
+{
+    VideoCodecCapabilityInfo* ret = new VideoCodecCapabilityInfo();
+    ret->codec = codec;
+    ret->dir = dir;
+    ret->max_bitrate = max_bitrate;
+    ret->resolutions = resolutions;
+    ret->codec_specific_info_len = codec_specific_info_len;
+    ret->codec_specific_info = (uint8*)OSCL_DEFAULT_MALLOC(codec_specific_info_len);
+    oscl_memcpy(ret->codec_specific_info, codec_specific_info, codec_specific_info_len);
+    return ret;
+}
+
+OSCL_EXPORT_REF const char* GetFormatsString(TPVDirection aDir, PV2WayMediaType aMediaType)
+{
+    switch (aDir)
+    {
+        case OUTGOING:
+            switch (aMediaType)
+            {
+                case PV_AUDIO:
+                    return PV_H324_AUDIO_INPUT_FORMATS;
+                case PV_VIDEO:
+                    return PV_H324_VIDEO_INPUT_FORMATS;
+                case PV_MULTIPLEXED:
+                    return PV_H324_MUX_INPUT_FORMATS;
+                default:
+                    break;
+            }
+            break;
+        case INCOMING:
+            switch (aMediaType)
+            {
+                case PV_AUDIO:
+                    return PV_H324_AUDIO_OUTPUT_FORMATS;
+                case PV_VIDEO:
+                    return PV_H324_VIDEO_OUTPUT_FORMATS;
+                case PV_MULTIPLEXED:
+                    return PV_H324_MUX_OUTPUT_FORMATS;
+                default:
+                    break;
+            }
+            break;
+        default:
+            break;
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF const char* GetFormatsValtypeString(TPVDirection aDir, PV2WayMediaType aMediaType)
+{
+    switch (aDir)
+    {
+        case OUTGOING:
+            switch (aMediaType)
+            {
+                case PV_AUDIO:
+                    return PV_H324_AUDIO_INPUT_FORMATS_VALTYPE;
+                case PV_VIDEO:
+                    return PV_H324_VIDEO_INPUT_FORMATS_VALTYPE;
+                case PV_MULTIPLEXED:
+                    return PV_H324_MUX_INPUT_FORMATS_VALTYPE;
+                default:
+                    break;
+            }
+            break;
+        case INCOMING:
+            switch (aMediaType)
+            {
+                case PV_AUDIO:
+                    return PV_H324_AUDIO_OUTPUT_FORMATS_VALTYPE;
+                case PV_VIDEO:
+                    return PV_H324_VIDEO_OUTPUT_FORMATS_VALTYPE;
+                case PV_MULTIPLEXED:
+                    return PV_H324_MUX_OUTPUT_FORMATS_VALTYPE;
+                default:
+                    break;
+            }
+            break;
+        default:
+            break;
+    }
+    return NULL;
+}
+
+OSCL_EXPORT_REF void GetSampleSize(PVMFFormatType aFormatType, uint32* aMin, uint32* aMax)
+{
+    *aMin = *aMax = 0;
+    if (aFormatType == PVMF_MIME_G723)
+    {
+        *aMin = 20;
+        *aMax = 24;
+    }
+    else if (aFormatType == PVMF_MIME_AMR_IF2)
+    {
+        *aMin = 13;
+        *aMax = 31;
+    }
+}
+
+
+OSCL_EXPORT_REF bool CodecRequiresFsi(PVCodecType_t codec)
+{
+    bool ret = false;
+    switch (codec)
+    {
+        case PV_VID_TYPE_MPEG4:
+            ret = true;
+            break;
+        default:
+            break;
+    }
+    return ret;
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/adaptationlayer.h b/protocols/systems/3g-324m_pvterminal/h223/include/adaptationlayer.h
new file mode 100644
index 0000000..b75ccd1
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/adaptationlayer.h
@@ -0,0 +1,313 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(ADAPTATION_LAYER_H)
+#define ADAPTATION_LAYER_H
+#include "oscl_types.h"
+#include "oscl_error_codes.h"
+#include "pvt_params.h"
+#include "h245def.h"
+#include "crccheck_cpp.h"
+#include "h324utils.h"
+
+#ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
+#include "pvmf_media_frag_group.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#define DEF_AL2_SN_POS 1
+#define DEF_AL3_SN_POS 2
+
+class IncomingALPduInfo
+{
+    public:
+        IncomingALPduInfo() : sdu_size(0), crc_error(0), seq_num_error(0) {}
+        int16 sdu_size;
+        bool crc_error;
+        int32 seq_num_error;
+};
+
+class AdaptationLayer
+{
+    public:
+        AdaptationLayer(TPVDirection dir, uint32 sdu_size, uint32 max_num_sdus): iLogger(NULL)
+        {
+            OSCL_UNUSED_ARG(dir);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer::AdaptationLayer Dir=%d, Sdu Size=%d, Max num sdus=%d", dir, sdu_size, max_num_sdus));
+            iSduSize = sdu_size;
+            iMaxNumSdus = max_num_sdus;
+            iPktNum = 0;
+        }
+        virtual ~AdaptationLayer() {}
+        virtual unsigned GetHdrSz() = 0;
+        virtual unsigned GetTrlrSz() = 0;
+        virtual PVMFStatus StartPacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt) = 0;
+        virtual PVMFStatus CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt) = 0;
+        virtual void ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info) = 0;
+        unsigned GetSduSize()
+        {
+            return iSduSize;
+        }
+        unsigned GetPduSize()
+        {
+            return iSduSize + GetHdrSz() + GetTrlrSz();
+        }
+        virtual void Construct() = 0;
+    protected:
+        uint32 iSduSize;
+        uint32 iMaxNumSdus;
+        int32 iPktNum;
+        PVLogger* iLogger;
+};
+
+class AdaptationLayer1 : public AdaptationLayer
+{
+    public:
+        AdaptationLayer1(TPVDirection dir, uint32 sdu_size, uint32 max_num_sdus) : AdaptationLayer(dir, sdu_size, max_num_sdus)
+        {
+        }
+        void Construct();
+
+        unsigned GetHdrSz()
+        {
+            return 0;
+        }
+        unsigned GetTrlrSz()
+        {
+            return 0;
+        }
+        PVMFStatus StartPacket(OsclSharedPtr<PVMFMediaDataImpl>& /*pkt*/)
+        {
+            return PVMFSuccess;
+        }
+
+        PVMFStatus CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt);
+        void ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info);
+};
+
+class AdaptationLayer2 : public AdaptationLayer
+{
+    public:
+        AdaptationLayer2(TPVDirection dir, uint32 sdu_size, uint32 max_num_sdus, bool seqno = false)
+                : AdaptationLayer(dir, sdu_size, max_num_sdus),
+                iSNPos(0),
+                iHdrSz(0),
+                iTrlrSz(1)
+        {
+            SetSeqnum(seqno);
+            iSeqNum = 0;
+        }
+        void Construct();
+
+        ~AdaptationLayer2()
+        {
+        }
+        inline unsigned GetHdrSz()
+        {
+            return iHdrSz;
+        }
+        inline unsigned GetTrlrSz()
+        {
+            return iTrlrSz;
+        }
+        PVMFStatus StartPacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt);
+        PVMFStatus CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt);
+
+        void ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info);
+
+        void SetSeqnum(bool on_off);
+    private:
+        unsigned iSNPos;
+        unsigned iHdrSz;
+        unsigned iTrlrSz;
+        unsigned iSeqNum;
+        PVMFBufferPoolAllocator iMemFragmentAlloc;
+        CRC crc;
+
+};
+
+class AdaptationLayer3 : public AdaptationLayer
+{
+    public:
+        AdaptationLayer3(TPVDirection dir, uint32 sdu_size, uint32 max_num_sdus, uint16 snpos)
+                : AdaptationLayer(dir, sdu_size, max_num_sdus),
+                iSNPos(snpos),
+                iHdrSz(snpos),
+                iTrlrSz(2)
+        {
+            iSeqNum = 0;
+        }
+
+        ~AdaptationLayer3()
+        {
+        }
+
+        void Construct();
+
+        inline unsigned GetHdrSz()
+        {
+            return iHdrSz;
+        }
+        inline unsigned GetTrlrSz()
+        {
+            return iTrlrSz;
+        }
+        void SetSeqnumSz(uint16 sz);
+        PVMFStatus StartPacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt);
+        PVMFStatus CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt);
+
+        void ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info);
+    private:
+        void DRTXSend(int , uint16)
+        {
+        }
+
+        void AlDrtxInd()
+        {
+        }
+
+        unsigned iSNPos;
+        unsigned iHdrSz;
+        unsigned iTrlrSz;
+        unsigned iSeqNum;
+        PVMFBufferPoolAllocator iMemFragmentAlloc;
+
+        CRC crc;
+};
+
+
+
+class AdaptationLayerAlloc
+{
+    public:
+        static int GetAlIndex(ErrorProtectionLevel_t epl)
+        {
+            switch (epl)
+            {
+                case E_EP_LOW:
+                    return 1;
+                case E_EP_MEDIUM:
+                    return 2;
+                case E_EP_HIGH:
+                    return 3;
+            }
+            return 0;
+        }
+
+        static OsclSharedPtr<AdaptationLayer> GetAdaptationLayer(TPVDirection dir,
+                PS_H223LogicalChannelParameters lcnParams,
+                uint32 sdu_size,
+                uint32 max_num_sdus)
+        {
+            uint16 al_index = 0;
+            uint16 hint = 0;
+            switch (lcnParams->adaptationLayerType.index)
+            {
+                case 1:
+                    al_index = 1;
+                    break;
+                case 2:
+                    al_index = 1;
+                    break;
+                case 3:
+                    al_index = 2;
+                    hint = 0;
+                    break;
+                case 4:
+                    al_index = 2;
+                    hint = 1;
+                    break;
+                case 5:
+                    al_index = 3;
+                    hint = lcnParams->adaptationLayerType.al3->controlFieldOctets;
+                    break;
+            }
+            return GetAdaptationLayer(dir, al_index, sdu_size, max_num_sdus, hint);
+        }
+
+        static OsclSharedPtr<AdaptationLayer> GetAdaptationLayer(TPVDirection dir,
+                uint16 index,
+                uint32 sdu_size,
+                uint32 max_num_sdus,
+                uint16 hint)
+        {
+            AdaptationLayer* al = NULL;
+            void* ptr = NULL;
+            switch (index)
+            {
+                case 1:
+                    ptr = OSCL_DEFAULT_MALLOC(sizeof(AdaptationLayer1));
+                    al = new(ptr)AdaptationLayer1(dir, sdu_size, max_num_sdus);
+                    break;
+                case 2:
+                    ptr = OSCL_DEFAULT_MALLOC(sizeof(AdaptationLayer2));
+                    al = new(ptr)AdaptationLayer2(dir, sdu_size, max_num_sdus, (hint ? true : false));
+                    break;
+                case 3:
+                    ptr = OSCL_DEFAULT_MALLOC(sizeof(AdaptationLayer3));
+                    al = new(ptr)AdaptationLayer3(dir, sdu_size, max_num_sdus, hint);
+                    break;
+                default:
+                    OSCL_LEAVE(OsclFailure);
+            }
+            al->Construct();
+            OsclRefCounterSA<Oscl_TAlloc<AdaptationLayer, BasicAlloc> > *alRefCounter =
+                new OsclRefCounterSA<Oscl_TAlloc<AdaptationLayer, BasicAlloc> >(ptr);
+
+            OsclSharedPtr<AdaptationLayer> alPtr(al, alRefCounter);
+
+            return alPtr;
+        }
+
+        static uint16 GetHdrSz(int index)
+        {
+            switch (index)
+            {
+                case 0:
+                case 1:
+                case 2:
+                case 3:
+                    return 0;
+                case 4:
+                    return 1;
+                case 5:
+                    return 2;
+            }
+            return 0;
+        }
+        static int GetTrlrSz(int index)
+        {
+            switch (index)
+            {
+                case 0:
+                case 1:
+                case 2:
+                    return 0;
+                case 3:
+                case 4:
+                    return 1;
+                case 5:
+                    return 2;
+            }
+            return 0;
+        }
+};
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/cpvh223multiplex.h b/protocols/systems/3g-324m_pvterminal/h223/include/cpvh223multiplex.h
new file mode 100644
index 0000000..4a109a0
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/cpvh223multiplex.h
@@ -0,0 +1,297 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(H223_MULTIPLEX_H)
+#define H223_MULTIPLEX_H
+#include "oscl_rand.h"
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
+
+#include "h245pri.h"
+#include "oscl_timer.h"
+#include "h223types.h"
+#include "pduparcom.h"
+#include "lowerlayer.h"
+#include "logicalchannel.h"
+
+#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
+#include "pvmf_media_data_impl.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+class MuxTableMgr;
+
+
+typedef OsclSharedPtr<H223OutgoingChannel> H223OutgoingChannelPtr;
+typedef OsclSharedPtr<H223IncomingChannel> H223IncomingChannelPtr;
+typedef Oscl_Map<unsigned , OsclSharedPtr<PVMFMediaDataImpl>, PoolMemAlloc_OsclMemAllocator_10> MuxSduList;
+class CPVH223MultiplexObserver
+{
+    public:
+        virtual void DataReceptionStart() = 0;
+        virtual ~CPVH223MultiplexObserver() {}
+        virtual void MuxSetupComplete(PVMFStatus status, TPVH223Level level) = 0;
+        virtual void MuxCloseComplete() = 0;
+        virtual void MuxErrorOccurred(TPVDirection direction, TPVMuxComponent component, PVMFStatus error,
+                                      uint8* info = NULL, uint info_len = 0) = 0;
+        virtual void SkewDetected(TPVChannelId lcn1, TPVChannelId lcn2, uint32 skew) = 0;
+        virtual void LcnDataDetected(TPVChannelId lcn) = 0;
+        virtual void ReceivedFormatSpecificInfo(TPVChannelId lcn, uint8* fsi, uint32 fsi_len) = 0;
+};
+
+class CPVH223Multiplex :  public LowerLayerObserver,
+            public H223PduParcomObserver,
+            public LogicalChannelObserver
+{
+    public:
+        CPVH223Multiplex(TPVLoopbackMode aLoopbackMode);
+        ~CPVH223Multiplex();
+        void SetObserver(CPVH223MultiplexObserver* observer)
+        {
+            iObserver = observer;
+        }
+        TPVStatusCode SetTimerRes(uint32 timer_res);
+
+        PVMFPortInterface* GetLowerLayer();
+
+        /* LoweLayer observer virtuals */
+        void DataReceptionStart();
+        void LevelSetupComplete(PVMFStatus status, TPVH223Level level);
+        PVMFStatus GetOutgoingMuxPdus(MuxPduPacketList& packets);
+        void LowerLayerError(TPVDirection directions, PVMFStatus error);
+
+        /* PduParcomObserver virtuals */
+        uint32 MuxPduIndicate(uint8* pPdu, uint32 pduSz, int32 fClosing, int32 muxCode);
+        void MuxPduErrIndicate(EMuxPduError err);
+        void MuxSetupComplete(PVMFStatus status, TPVH223Level level);
+        H223PduParcomObserver* GetParcomObserver()
+        {
+            return this;
+        }
+
+        /* LogicalChannelObserver virtuals */
+        inline int32 GetTimestamp();
+        void LogicalChannelError(TPVDirection direction, TPVChannelId id, PVMFStatus error);
+        void SkewDetected(TPVChannelId lcn1, TPVChannelId lcn2, uint32 skew);
+        void ReceivedFormatSpecificInfo(TPVChannelId lcn, uint8* fsi, uint32 fsi_len);
+
+        void Init();
+
+        /* allocates resources  */
+        TPVStatusCode Open();
+
+        /* de-allocates resources */
+        TPVStatusCode Close();
+
+        /* Starts active element */
+        int Start(H223PduParcomSharedPtr parcom);
+
+        /* Stops active element */
+        int Stop();
+
+        TPVH223Level GetMuxLevel();
+
+        int GetMinTimerRes();
+
+        TPVStatusCode SetSduSize(TPVDirection direction, uint16 size, ErrorProtectionLevel_t epl);
+
+        uint16 GetSduSize(TPVDirection direction, ErrorProtectionLevel_t epl);
+
+        uint16 GetMaxSduSize(TPVDirection direction, ErrorProtectionLevel_t epl);
+
+        // Channel APIs
+        unsigned GetMaxChannels(TPVDirection /*direction*/)
+        {
+            return MAX_LCNS;
+        }
+        unsigned GetNumChannels(TPVDirection direction);
+
+        TPVStatusCode OpenChannel(TPVDirection direction, TPVChannelId channel_id, H223ChannelParam* channel_param);
+        TPVStatusCode CloseChannel(TPVDirection direction, TPVChannelId channel_id);
+        PVMFStatus GetOutgoingChannel(TPVChannelId id, H223OutgoingChannelPtr& channel);
+        PVMFStatus GetIncomingChannel(TPVChannelId id, H223IncomingChannelPtr& channel);
+        TPVStatusCode StopChannel(TPVDirection /*direction*/, TPVChannelId /*channel_id*/);
+        TPVStatusCode FlushChannel(TPVDirection /*direction*/, TPVChannelId /*channel_id*/);
+        bool IsValid(TPVDirection /*direction*/, TPVChannelId /*channel_id*/)
+        {
+            return false;
+        }
+
+
+        TPVStatusCode SetMaxOutgoingPduSize(uint16 Size);
+        unsigned GetMaxPduSize(TPVDirection direction);
+
+        TPVStatusCode SetIncomingMuxTableEntries(CPVMultiplexDescriptor* descriptor);
+        void SetIncomingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors, bool replace = true);
+        void SetOutgoingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors);
+        void RemoveOutgoingMuxDescriptor(uint8 muxTblNum);
+        void RemoveIncomingMuxDescriptor(uint8 muxTblNum);
+        void SetLoopbackMode(TPVLoopbackMode aLoopbackMode);
+        PS_MultiplexEntryDescriptor GetIncomingMuxDescriptor(uint16 muxTblNum);
+
+        void ResetStats();
+        void LogStats(TPVDirection dir);
+
+        /* Set muliplex level.  Can be called before the multiplex is started */
+        void SetMultiplexLevel(TPVH223Level muxLevel);
+        void SetClock(PVMFMediaClock* aClock)
+        {
+            iClock = aClock;
+        }
+        void SetMultiplexingDelayMs(uint16 aDelay);
+        void SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                                          uint32 aOutBufferingMs);
+        void SetBitrate(uint32 bitrate);
+        void SetInterleavingMultiplexFlags(uint16 size, uint8* flags);
+        void EnableStuffing(bool enable);
+        TPVStatusCode SetMuxLevel(TPVH223Level muxLevel);
+        void EnableStuffOnlyFirstSend(bool enable);
+        void SetMioLatency(int32 aLatency, bool aAudio);
+    protected:
+        TPVStatusCode AlPduData(H223IncomingChannel* aChannel,
+                                uint8*& pdu,
+                                PS_MultiplexElement pElement,
+                                int n);
+        TPVStatusCode Dispatch(H223IncomingChannel* aChannel,
+                               PS_MultiplexElement pElement);
+        TPVStatusCode GetAdaptationLayer(OsclSharedPtr<AdaptationLayer> &al,
+                                         TPVDirection aDirection,
+                                         PS_H223LogicalChannelParameters aH223lcnParams,
+                                         int32 aSdu_size,
+                                         uint32 aNum_media_data);
+        void MakePduData(OsclSharedPtr<PVMFMediaDataImpl>& outgoingPkt,
+                         int32 max_size,
+                         PS_MultiplexElement pElement,
+                         MuxSduData& mux_sdu_data,
+                         int* pm);
+        int MuxToALDispatch(uint8* pdu, int pdu_size, int fClosing, int muxCode);
+        int BreakPduData(uint8*& pdu, int pdu_size, PS_MultiplexElement pElement, int ListSize);
+
+        TPVStatusCode Mux()
+        {
+            return EPVT_Success;
+        }
+        TPVStatusCode Demux()
+        {
+            return EPVT_Success;
+        }
+
+
+        PVMFStatus FindOutgoingChannel(TPVChannelId id, OsclSharedPtr<H223OutgoingChannel>& channel);
+        PVMFStatus FindIncomingChannel(TPVChannelId id, OsclSharedPtr<H223IncomingChannel>& channel);
+
+        MuxSduData* FindMuxSduData(TPVChannelId lcn,
+                                   bool segmentable,
+                                   uint32* index = NULL);
+        void AppendMuxSduData(MuxSduData& data);
+        void SetMuxSduData(MuxSduData& data);
+        void RemoveMuxSduData(TPVChannelId lcn, bool segmentable);
+        /* This fn checks if there is more data in the logical channel */
+        void ReleaseMuxSdu(MuxSduData& mux_sdu_data,
+                           MuxSduDataList& list,
+                           unsigned index);
+        unsigned UpdateSduDataLists();
+
+        OsclSharedPtr<PVMFMediaDataImpl> InitPduPacket();
+        PVMFStatus CompletePduPacket(OsclSharedPtr<PVMFMediaDataImpl>& packet, int mt, int pm);
+        unsigned DispatchPduPacket(MuxPduPacketList& packets,
+                                   MuxSduData& mux_sdu_data,
+                                   PS_MultiplexEntryDescriptor entry,
+                                   uint32 max_size);
+        void UpdateMuxInterval(uint16 aInterval = 0);
+        void ClearSduDataLists();
+        uint16 MuxLcnData(MuxSduDataList& list,
+                          MuxPduPacketList& packets,
+                          uint16 max_size);
+
+        void SetStuffingMsgHeader();
+
+        /* Lower Layer instance which binds to TSAP */
+        H223LowerLayer*   iLowerLayer;
+
+        /* Outgoing logical channels */
+        Oscl_Vector<H223OutgoingChannelPtr, OsclMemAllocator> iOutgoingChannels;
+
+        /* Incoming logical channels */
+        Oscl_Vector<H223IncomingChannelPtr, OsclMemAllocator> iIncomingChannels;
+
+        int iALIndex[MAX_LCNS];
+
+        /* Sizes of current packets being muxed */
+        MuxSduDataList iNonSegmentableSduDataList;
+        MuxSduDataList iSegmentableSduDataList;
+        MuxSduDataList iControlSduDataList;
+        /* A '1' in the bit pos indicates data is available for this lcn */
+        unsigned  iLcnsWithData;
+
+        /* segmentable lcn ending on current pdu */
+        H223IncomingChannel* iLcnEnd;
+
+        /* bitrate, bps */
+        uint32 iBitrate;
+
+        /* operational state */
+        bool iState;
+
+        /* Mux table manager*/
+        MuxTableMgr* iMuxTblMgr;
+
+        /* SDU sizes */
+        int iMaxAlSduSize[4];
+        int iMaxAlSduSizeR[4];
+
+        int iAlSduSize[4];
+        int iAlSduSizeR[4];
+
+        OSCL_wHeapString<OsclMemAllocator> iInstanceId;
+
+        TPVLoopbackMode iLoopbackMode;
+
+        /* Use this for aborting a segmentable mux sdu */
+        DefFragmentAllocator iAlloc;
+        MediaFragment* iDummyFragment;
+
+        OsclMemPoolFixedChunkAllocator* iMediaDataImplMemAlloc;
+        PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>* iMuxPduPacketAlloc;
+        PVLogger *iLogger;
+        PVMFMediaClock* iClock;
+        OsclRand iRand;
+        uint16 iMinSampleInterval;
+        uint16 iNumMuxIntervalsPerTimerInterval;
+        uint16 iNumBytesPerMinSampleInterval;
+        uint16 iMultiplexingDelayMs;
+        uint32 iInLogicalChannelBufferingMs;
+        uint32 iOutLogicalChannelBufferingMs;
+        uint32 iFmStuffingRepeatInterval;
+        uint32 iFmStuffingMode;
+        uint32 iPduNum;
+        CPVH223MultiplexObserver* iObserver;
+        bool iLevelSetupComplete;
+        uint32 iInterleavingMultiplexFlagsSize;
+        uint8* iInterleavingMultiplexFlags;
+        OsclSharedPtr<PVMFMediaDataImpl> iInterleavingPacket;
+        bool iEnableStuffing;
+        bool iStuffOnlyFirstSend;
+};
+
+typedef CPVH223Multiplex H223;
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/golay.h b/protocols/systems/3g-324m_pvterminal/h223/include/golay.h
new file mode 100644
index 0000000..859e4b4
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/golay.h
@@ -0,0 +1,32 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#ifndef _GOLAY_H_
+#define  _GOLAY_H_
+inline int get_syndrome(int pattern);
+#endif //_GOLAY_H_
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/h223.h b/protocols/systems/3g-324m_pvterminal/h223/include/h223.h
new file mode 100644
index 0000000..e40dfc7
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/h223.h
@@ -0,0 +1,40 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+ * File:	h223.h
+ * Comment:	H223 internal structure, global variable, and function declarations
+ */
+
+#ifndef _h223_H
+#define _h223_H
+
+#include "oscl_types.h"
+#include "pvt_common.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+    uint H223GetMuxStuffingSz(TPVH223Level level);
+    uint H223GetMaxStuffingSz(TPVH223Level level);
+    uint H223MuxStuffing(TPVH223Level level, uint8* pPdu, uint bufSz);
+    bool H223CheckSync(TPVH223Level level, uint8* buf, uint bufSz, uint tolerance);
+#ifdef __cplusplus
+}
+#endif
+#endif	/* _h223_H */
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/level0.h b/protocols/systems/3g-324m_pvterminal/h223/include/level0.h
new file mode 100644
index 0000000..6dd9778
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/level0.h
@@ -0,0 +1,83 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(LEVEL0_H)
+#define LEVEL0_H
+#include "pduparcom.h"
+
+#define LEVEL0_STUFFING_SZ 1
+#define LEVEL0_HDR_SZ 2
+
+class Level0PduParcom : public H223PduParcomBase
+{
+    public:
+        Level0PduParcom();
+        TPVH223Level GetLevel()
+        {
+            return H223_LEVEL0;
+        }
+        uint32 GetStuffing(uint8* buf, uint32 buf_size, uint8 mux_code = 0);
+        uint32 GetHeaderSz()
+        {
+            return LEVEL0_HDR_SZ;
+        }
+        uint32 GetStuffingSz()
+        {
+            return LEVEL0_STUFFING_SZ;
+        }
+        uint32 Parse(uint8* bsbuf, uint32 bsbsz);
+        PVMFStatus CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 mt, uint8 pm);
+
+    protected:
+        void Construct(uint16 max_outstanding_pdus);
+        void GetHdrFragment(OsclRefCounterMemFrag& frag);
+        uint16 Insert0(uint8* pPdu, int pdu_size, uint8* pRetPdu);
+        uint16 Insert0Octet(uint8 cur_byte, uint16 num_bits_from_octet, uint8* out_buffer);
+        uint16 AppendTxBits0(unsigned num_bits, int bits, uint8* pos);
+        // appends an octet to the output stream without checking for 0 bit.  Flushes the current check bits
+        uint16 AppendTxOctet(uint8 octet, uint8* pos);
+
+        void SearchForHdlcFlag(uint8* bsbuf, int bsbsz);
+        unsigned Remove0();
+        void Remove0Octet(uint8 cur_byte, int num_bits_from_octet);
+        void AppendBit(int c);
+        void AppendBits0(unsigned num_bits, int bits);
+
+        int iPmNext;
+        PVMFBufferPoolAllocator iPduFragmentAlloc;
+        PVMFBufferPoolAllocator iHdrFragmentAlloc;
+
+        uint8 iHecCrc[20];
+        unsigned iRecvBits;
+        unsigned iNumRecvBits;
+        unsigned iRecvByte;
+        int iRecvBytePos;
+        unsigned iRecvByte0;
+        int iRecvByte0Pos;
+        int iZeroBitRemovedOutputPos;
+        unsigned iZeroBitRemovedOutput;
+        uint8* iPduPosZeroRemoved;
+
+        int iTxByte0;
+        int iTxByte0Pos;
+        int iTxCheck0;
+        int iTxCheck0Pos;
+};
+
+#endif
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/level1.h b/protocols/systems/3g-324m_pvterminal/h223/include/level1.h
new file mode 100644
index 0000000..b76e884
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/level1.h
@@ -0,0 +1,86 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(LEVEL1_H)
+#define LEVEL1_H
+#include "pduparcom.h"
+
+#define LEVEL1_STUFFING_SZ 2
+#define LEVEL1DF_STUFFING_SZ 4
+#define LEVEL1_HDR_SZ 3
+#define LEVEL1DF_HDR_SZ 5
+
+class Level1PduParcom : public H223PduParcomBase
+{
+    public:
+        typedef enum
+        {
+            ELookForStartFlag = 0,
+            ESkipFlags,
+            ELookForEndFlag
+        } EOperationId;
+
+        Level1PduParcom(bool df = false);
+        ~Level1PduParcom()
+        {
+        }
+        TPVH223Level GetLevel()
+        {
+            return H223_LEVEL1;
+        }
+
+        bool UseDf(bool df)
+        {
+            bool ret = iDf;
+            iDf = df;
+            return ret;
+        }
+        uint32 GetStuffing(uint8* buf, uint32 buf_size, uint8 mux_code = 0);
+        uint32 GetHeaderSz()
+        {
+            return (uint16)((iDf) ? LEVEL1DF_HDR_SZ : LEVEL1_HDR_SZ);
+        }
+        uint32 GetStuffingSz()
+        {
+            return (uint16)((iDf) ? LEVEL1DF_STUFFING_SZ : LEVEL1_STUFFING_SZ);
+        }
+        uint32 Parse(uint8* bsbuf, uint32 bsbsz);
+        PVMFStatus CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 mt, uint8 pm);
+    protected:
+        void Construct(uint16 max_outstanding_pdus);
+        void GetHdrFragment(OsclRefCounterMemFrag& frag);
+    private:
+        inline bool CheckForFlag(uint8* bsbuf)
+        {
+            if (iDf)
+                return (bsbuf[0] == 0xe1 && bsbuf[1] == 0x4d && bsbuf[2] == 0xe1 && bsbuf[3] == 0x4d);
+            return (bsbuf[0] == 0xe1 && bsbuf[1] == 0x4d);
+        }
+        inline void IndicatePdu();
+
+        PVMFBufferPoolAllocator iHdrFragmentAlloc;
+
+        uint8 iHecCrc[20];
+        bool iDf;
+        int iCurrentInt32;
+        int iSkipBytes;
+        int iClosingNext;
+        EOperationId iCurrentOp;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/level2.h b/protocols/systems/3g-324m_pvterminal/h223/include/level2.h
new file mode 100644
index 0000000..b7cb717
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/level2.h
@@ -0,0 +1,187 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(LEVEL2_H)
+#define LEVEL2_H
+#include "pduparcom.h"
+
+#define PDU_HDR_SIZE_MAX 8
+#define LEVEL2_STUFFING_SZ 5
+#define LEVEL2OH_STUFFING_SZ 6
+#define LEVEL2_HDR_SZ 5
+#define LEVEL2OH_HDR_SZ 6
+#define LEVEL2_THRESHOLD_SYNC 15
+#define LEVEL2_THRESHOLD_DATA 13
+
+#define LEVEL2_FLAG_SZ 2
+#define LEVEL2_MAX_PDU_SZ 254
+#define LEVEL2_FLAG 0xE14D
+#define LEVEL2_CLOSING_FLAG 0x1EB2
+
+class Level2PduParcom : public H223PduParcomBase
+{
+    public:
+        typedef enum
+        {
+            ECopyHdr = 0,
+            ECopyData
+        } EOperationId;
+
+        Level2PduParcom(bool oh = false, int closing_cur = 0);
+        ~Level2PduParcom()
+        {
+            OSCL_DEFAULT_FREE(iEncTab);
+            OSCL_DEFAULT_FREE(iDecTab);
+            OSCL_DEFAULT_FREE(iBsbuf[0]);
+            OSCL_DEFAULT_FREE(iBsbuf[1]);
+        }
+        TPVH223Level GetLevel()
+        {
+            if (iOh)
+                return H223_LEVEL2_OH;
+            return H223_LEVEL2;
+        }
+
+        bool UseOh(bool oh)
+        {
+            bool ret = iOh;
+            iOh = oh;
+            return ret;
+        }
+
+        uint32 GetStuffing(uint8* buf, uint32 buf_size, uint8 mux_code = 0);
+        uint32 GetHeaderSz()
+        {
+            return (uint16)((iOh) ? LEVEL2OH_HDR_SZ : LEVEL2_HDR_SZ);
+        }
+        uint32 GetStuffingSz()
+        {
+            return (uint16)((iOh) ? LEVEL2OH_STUFFING_SZ : LEVEL2_STUFFING_SZ);
+        }
+        uint32 Parse(uint8* bsbuf, uint32 bsbsz);
+        PVMFStatus CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 mt, uint8 pm);
+        void ResetStats();
+        void LogStats(TPVDirection dir);
+        void SetClosingCur(int32 closing);
+    protected:
+        void Construct(uint16 max_outstanding_pdus);
+        void GetHdrFragment(OsclRefCounterMemFrag& frag);
+    private:
+        PVMFBufferPoolAllocator iHdrFragmentAlloc;
+
+        uint8 iHecCrc[20];
+        int iThreshold;
+        bool iOh;
+        bool iUseOh;
+        int iCurrentInt32;
+        int iCnt;
+        int iRecoverCnt;
+        int iMpl;
+        int iMplRemaining;
+        int iPktsInUse;
+        int iMuxCode;
+        int iClosingCur;
+        int iClosingNext;
+        int iClosingNextRx;
+
+        uint8 iPduHdr[PDU_HDR_SIZE_MAX];
+        uint8* iPduHdrPos;
+        uint8* iBsbuf[2];
+        unsigned iCurBsBuf;
+
+        int iPrevMuxTblNum;
+        int iPrevPm;
+        EOperationId iCurrentOp;
+        bool CheckFlag(uint8* buf, int* fClosing, int trsld);
+        void IndicatePdu(uint8 optional_header);
+        int ParseHdr(int* fClosing, int* mpl, int* muxCode, int* numErrors, uint8* optional_header);
+
+        inline void ResetPdu()
+        {
+            iPduPos = iPdu;
+            iMpl = 0;
+            iMplRemaining = 0;
+            iMuxCode = -1;
+            iClosingCur = 0;
+        }
+
+        inline void ResetPduHdr()
+        {
+            iPduHdrPos = iPduHdr;
+        }
+
+        inline void CopyOctetToPdu(uint8 c)
+        {
+            if (iPduPos >= iPduEndPos)
+            {
+                /* Reset the pdu */
+                ResetPdu();
+            }
+            /* Copy the byte to the pdu */
+            *iPduPos++ = c;
+        }
+
+        uint8* FindSync(uint8* data, int len, int* closing);
+        bool RecoverPduData(uint8*& bsbuf, int* bsbsz);
+
+        int GolayDec(int received, int* num_errors)
+        {
+            received = ((received >> 1) & 0xfffff800) + (received & 0x7ff);
+            int syndrome = get_syndrome(received);
+            received ^= iDecTab[syndrome];
+            *num_errors = iNumOnes[syndrome&0xFF] + iNumOnes[(syndrome >> 8)&0xFF] +
+                          iNumOnes[(syndrome >> 16)&0xFF] + iNumOnes[(syndrome >> 24)&0xFF];
+            return received >> 11;
+        }
+
+        int get_syndrome(int pattern)
+        {
+
+            //static const long gen_poly = 0x00000c75;
+
+            long junk = 0x00400000;
+            if (pattern >= 0x00000800)
+            {
+                while (pattern & 0xfffff800)
+                {
+                    while (!(junk & pattern)) junk >>= 1;
+                    pattern ^= (junk + (junk >> 1) + (junk >> 5) + (junk >> 6) + (junk >> 7) + (junk >> 9) + (junk >> 11));
+                }
+            }
+            return(pattern);
+        }
+
+        uint8 iLastHdr[8];
+        int* iEncTab;
+        int* iDecTab;
+        uint8 iNumOnes[256];
+        // Outgoing
+        uint32 iNumClosingFlagsTx;
+        uint32 iNumFlagEmulation;
+
+        // Incoming
+        uint32 iNumClosingFlagsRx;
+        uint32 iNumGolayCblePduHdrErrorsRx;
+        uint32 iNumPduHdrErrorsMplRx;
+        uint32 iNumCorruptedOhRx;
+        uint32 iNumHeadersCorrectedByOh;
+        bool iCopyPduWithSync;
+};
+
+#endif
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/logicalchannel.h b/protocols/systems/3g-324m_pvterminal/h223/include/logicalchannel.h
new file mode 100644
index 0000000..0cfd174
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/logicalchannel.h
@@ -0,0 +1,525 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(LOGICAL_CHANNEL_H)
+#define LOGICAL_CHANNEL_H
+#include "oscl_mem.h"
+#include "adaptationlayer.h"
+#include "h324utils.h"
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
+#endif
+
+#ifndef OSCL_MAP_H_INCLUDED
+#include "oscl_map.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
+#include "pvmf_media_frag_group.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#define INVALID_MUX_CODE 0xFF
+#define DEF_NUM_MEDIA_DATA 100
+#define SKEW_CHECK_INTERVAL 2000
+#define PARSING_JITTER_DURATION 200
+#define	PVDEBUG_LOG_BITSTREAM_PKT(iDebug, comp, pkt) \
+{\
+uint8* ptrbuf = pkt->GetMediaPtr();\
+PVDEBUG_LOG_BITSTREAM(iDebug, (comp, ptrbuf, pkt->GetMediaSize()) );\
+pkt->ClearMediaPtr();\
+}
+
+class LCMediaDataEntry
+{
+    public:
+        LCMediaDataEntry() : next(NULL) {}
+        ~LCMediaDataEntry()
+        {
+            mediaData.Unbind();
+        }
+        PVMFSharedMediaDataPtr mediaData;
+        LCMediaDataEntry* next;
+};
+
+class LcnAlloc : public Oscl_DefAlloc
+{
+    public:
+        void* allocate(const uint32 size)
+        {
+            void* tmp = (void*)OSCL_DEFAULT_MALLOC(size);
+            OSCL_ASSERT(tmp != 0);
+            return tmp;
+        }
+        void deallocate(void* p)
+        {
+            OSCL_DEFAULT_FREE(p);
+        }
+};
+
+class LogicalChannelObserver
+{
+    public:
+        virtual ~LogicalChannelObserver() {}
+        virtual int32 GetTimestamp() = 0;
+        virtual void LogicalChannelError(TPVDirection direction, TPVChannelId id, PVMFStatus error) = 0;
+        virtual void SkewDetected(TPVChannelId lcn1, TPVChannelId lcn2, uint32 skew) = 0;
+        virtual void ReceivedFormatSpecificInfo(TPVChannelId lcn, uint8* fsi, uint32 fsi_len) = 0;
+};
+
+class H223LogicalChannel : public PvmfPortBaseImpl,
+            public PVMFPortActivityHandler,
+            public PvmiCapabilityAndConfig,
+            public virtual LogicalChannelInfo
+{
+    public:
+        H223LogicalChannel(TPVChannelId num,
+                           bool segmentable,
+                           OsclSharedPtr<AdaptationLayer>& al,
+                           PS_DataType data_type,
+                           LogicalChannelObserver* observer,
+                           uint32 bitrate,
+                           uint32 sample_interval,
+                           uint32 num_media_data);
+        virtual ~H223LogicalChannel();
+
+        /* allocate resources in this function */
+        virtual void Init() = 0;
+
+        // LogicalChannelInfo virtuals
+        TPVChannelId GetLogicalChannelNumber()
+        {
+            return lcn;
+        }
+
+        uint32 GetSduSize()
+        {
+            return iAl->GetSduSize();
+        }
+
+        bool IsSegmentable()
+        {
+            return iSegmentable;
+        }
+
+        uint32 GetBitrate()
+        {
+            return iBitrate;
+        }
+
+        uint32 GetSampleInterval()
+        {
+            return iSampleInterval;
+        }
+
+        const uint8* GetFormatSpecificInfo(uint32* format_specific_info_len);
+        PVMFTimestamp GetLastSduTimestamp()
+        {
+            return iLastSduTimestamp;
+        }
+
+        PVMFFormatType GetFormatType()
+        {
+            PVCodecType_t codec_type = GetCodecType(iDataType);
+            return PVCodecTypeToPVMFFormatType(codec_type);
+        }
+
+        OsclAny SetNext(H223LogicalChannel* lcn_next)
+        {
+            next = lcn_next;
+        }
+        H223LogicalChannel* GetNext()
+        {
+            return next;
+        }
+
+        OsclSharedPtr<AdaptationLayer>GetAl()
+        {
+            return iAl;
+        }
+
+        OsclAny SetSampleInterval(uint16 sample_interval)
+        {
+            iSampleInterval = sample_interval;
+        }
+
+        /* Flushes the pending AL SDU data */
+        virtual OsclAny Flush() = 0;
+
+        virtual OsclAny ResetStats() = 0;
+        virtual OsclAny LogStats() = 0;
+
+        // Functions to pause and resume
+        virtual void Pause();
+        virtual void Resume();
+
+        // Set format specific information
+        PVMFStatus SetFormatSpecificInfo(uint8* info, uint16 info_len);
+
+        void SetTimestampOffset(uint32 offset)
+        {
+            iIncomingSkew = offset;
+        }
+        void SetDatapathLatency(uint32 aLatency);
+
+        void SetClock(PVMFMediaClock* aClock)
+        {
+            iClock = aClock;
+        }
+
+        //CapabilityAndConfig virtuals
+        OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
+
+        /* PVMFPortActivityHandler virtuals */
+        void HandlePortActivity(const PVMFPortActivity &aActivity)
+        {
+            OSCL_UNUSED_ARG(aActivity);
+        }
+        PVMFStatus setConfigParametersSync(PvmiKvp* selectedKvp, PvmiCapabilityAndConfig* aConfig, PVMFFormatType lcn_format_type = PVMF_MIME_FORMAT_UNKNOWN, bool aTryTwice = false);
+
+
+
+        //Set the audio/video MIO latencies for the respective channel
+        void SetAudioLatency(int32 aAudioLatency)
+        {
+            iAudioLatency = aAudioLatency;
+        }
+        void SetVideoLatency(int32 aVideoLatency)
+        {
+            iVideoLatency = aVideoLatency;
+        }
+
+    protected:
+        TPVChannelId lcn;
+        bool iSegmentable;
+        H223LogicalChannel* next;
+        OsclSharedPtr<AdaptationLayer> iAl;
+        uint32 iBitrate;
+        uint32 iSampleInterval;
+        LogicalChannelObserver* iObserver;
+        uint8* iFormatSpecificInfo;
+        uint32 iFormatSpecificInfoLen;
+        PVLogger* iLogger;
+        uint32 iIncomingSkew;
+        PVMFTimestamp iLastSduTimestamp;
+        PS_DataType iDataType;
+        OsclMemAllocator iKvpMemAlloc;
+        uint32 iNumMediaData;
+        uint32 iMaxSduSize;
+        bool iSendFormatSpecificInfo;
+        uint32 iDatapathLatency;
+        PVMFFormatType iMediaType;
+        OsclRefCounterMemFrag iFsiFrag;
+        bool iPaused;
+        PVMFMediaClock* iClock;
+        int32 iAudioLatency;
+        int32 iVideoLatency;
+
+};
+
+/* For outgoing A/V/C ( to be muxed) */
+class H223OutgoingChannel : public H223LogicalChannel
+{
+    public:
+        H223OutgoingChannel(TPVChannelId num,
+                            bool segmentable,
+                            OsclSharedPtr<AdaptationLayer>& al,
+                            PS_DataType data_type,
+                            LogicalChannelObserver* observer,
+                            uint32 bitrate,
+                            uint32 sample_interval,
+                            uint32 num_media_data);
+        ~H223OutgoingChannel();
+
+        void Init();
+
+        TPVDirection GetDirection()
+        {
+            return OUTGOING;
+        }
+        bool GetNextPacket(PVMFSharedMediaDataPtr& aMediaData, PVMFStatus aStatus);
+
+        OsclAny ReleasePacket(PVMFSharedMediaDataPtr& aMediaData);
+
+        OsclAny Flush();
+
+        OsclAny ResetStats();
+        OsclAny LogStats();
+        OsclAny SetSkewReference(LogicalChannelInfo* reference_channel)
+        {
+            iSkewReferenceChannel = reference_channel;
+        }
+
+        void BufferMedia(uint16 aMs);
+        void SetBufferSizeMs(uint32 buffer_size_ms);
+
+        uint32 GetNumBytesTransferred()
+        {
+            return iNumBytesIn;
+        }
+        // Functions to pause and resume the output of data from the logical channel to the mux
+        void Resume();
+
+        OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        /* PVMFPortActivityHandler virtuals */
+        void HandlePortActivity(const PVMFPortActivity &aActivity);
+    protected:
+        virtual PVMFStatus PutData(PVMFSharedMediaMsgPtr media_msg);
+
+        bool FragmentPacket(PVMFSharedMediaDataPtr& aMediaData, PVMFSharedMediaDataPtr& newpack);
+
+        OsclSharedPtr<PVMFMediaDataImpl> StartAlPdu();
+
+        PVMFStatus CompletePdu();
+
+        PVMFStatus AppendOutgoingPkt(OsclSharedPtr<PVMFMediaDataImpl>& pdu, PVMFTimestamp timestamp,
+                                     OsclRefCounterMemFrag* fsi = NULL);
+
+        OsclAny ResetSkewParameters();
+
+
+        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam);
+
+        PVMFStatus NegotiateInputSettings(PvmiCapabilityAndConfig* config);
+
+        OsclMemPoolFixedChunkAllocator* iMediaMsgMemoryPool;
+        OsclMemPoolFixedChunkAllocator* iMediaDataEntryAlloc;
+        LCMediaDataEntry* lastMediaData;
+        PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>* iMediaFragGroupAlloc;
+        OsclMemPoolFixedChunkAllocator* iPduPktMemPool;
+        OsclSharedPtr<PVMFMediaDataImpl> iCurPdu;
+
+        TimeValue iCreateTime;
+        TimeValue iStartTime;
+        uint32 iNumPacketsIn;
+        uint32 iNumSdusIn;
+        uint32 iNumSdusDropped;
+        uint32 iNumBytesIn;
+        uint32 iNumSdusOut;
+        uint32 iNumBytesOut;
+        uint32 iMaxPacketMuxTime;
+        uint32 iMaxSduMuxTime;
+        uint32 iNumFlush;
+        uint32 iNumBytesFlushed;
+        // skew related
+        LogicalChannelInfo* iSkewReferenceChannel;
+        int32 iSetBufferMediaMs;
+        int32 iSetBufferMediaBytes;
+        int32 iBufferMediaMs;
+        int32 iBufferMediaBytes;
+        bool iMuxingStarted;
+        PVMFTimestamp iCurPduTimestamp;
+        uint32 iNumPendingPdus;
+        PVLogger* iOutgoingAudioLogger;
+        PVLogger* iOutgoingVideoLogger;
+        bool iWaitForRandomAccessPoint;
+        uint32 iBufferSizeMs;
+};
+
+class H223OutgoingControlChannel : public H223OutgoingChannel
+{
+    public:
+        H223OutgoingControlChannel(OsclSharedPtr<AdaptationLayer>& al,
+                                   PS_DataType data_type,
+                                   LogicalChannelObserver* observer,
+                                   uint32 bitrate,
+                                   uint32 sample_interval,
+                                   uint32 num_media_data)
+                : H223OutgoingChannel(0, SEGMENTABLE, al, data_type, observer, bitrate, sample_interval, num_media_data)
+        {
+        }
+
+        PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg);
+};
+
+#define NUM_INCOMING_SDU_BUFFERS 8
+/* For incoming (from the remote terminal) A/V/C */
+class H223IncomingChannel : public H223LogicalChannel
+{
+    public:
+        H223IncomingChannel(TPVChannelId num,
+                            bool segmentable,
+                            OsclSharedPtr<AdaptationLayer>& al,
+                            PS_DataType data_type,
+                            LogicalChannelObserver* observer,
+                            uint32 bitrate,
+                            uint32 sample_interval,
+                            uint32 num_media_data);
+        ~H223IncomingChannel();
+        void Init();
+
+        TPVDirection GetDirection()
+        {
+            return INCOMING;
+        }
+
+        virtual PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg)
+        {
+            OSCL_UNUSED_ARG(aMsg);
+            return PVMFErrNotSupported;
+        }
+
+        PVMFStatus GetData(PVMFSharedMediaMsgPtr aMsg)
+        {
+            OSCL_UNUSED_ARG(aMsg);
+            return PVMFErrNotSupported;
+        }
+
+        /* Dispaches packets to bound PAcketInput */
+        PVMFStatus AlPduData(uint8* buf, uint16 len);
+
+        PVMFStatus AlDispatch();
+
+        OsclAny ResetAlPdu();
+        OsclAny AllocateAlPdu();
+        OsclAny AppendAlPduFrag();
+        uint32 CopyAlPduData(uint8* buf, uint16 len);
+        uint32 CopyToCurrentFrag(uint8* buf, uint16 len);
+
+        OsclAny Flush();
+
+        OsclAny ResetStats();
+        OsclAny LogStats();
+
+        uint32 GetNumSdusIn()
+        {
+            return iNumSdusIn;
+        }
+        // overload Connect to send out format specific info if available
+        PVMFStatus Connect(PVMFPortInterface* aPort);
+
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        /* PVMFPortActivityHandler virtuals */
+        void HandlePortActivity(const PVMFPortActivity &aActivity);
+
+    private:
+        void PreAlPduData();
+        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam);
+        PVMFStatus NegotiateOutputSettings(PvmiCapabilityAndConfig* config);
+
+        OsclAny SendFormatSpecificInfo();
+
+        PVMFStatus DispatchPendingSdus();
+
+        PVMFStatus SendBeginOfStreamMediaCommand();
+
+        void SetSampleTimestamps(PVMFTimestamp& aTSOffset);
+        PVMFBufferPoolAllocator iMemFragmentAlloc;
+        OsclMemPoolFixedChunkAllocator* iMediaMsgMemoryPool;
+        PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>* iMediaFragGroupAlloc;
+        OsclMemPoolFixedChunkAllocator* iPduPktMemPool;
+
+        OsclMemAllocator iMemAlloc;
+        PVMFSimpleMediaBufferCombinedAlloc iMediaDataAlloc;
+        Oscl_Vector<PVMFSharedMediaMsgPtr, OsclMemAllocator> iPendingSdus;
+        OsclSharedPtr<PVMFMediaDataImpl> iAlPduMediaData;
+        uint8* iAlPduFragPos;
+        OsclRefCounterMemFrag iAlPduFrag;
+        uint32 iPduSize;
+        uint32 iCurPduSize;
+        TimeValue iCreateTime;
+        TimeValue iStartTime;
+        uint32 iNumPdusIn;
+        uint32 iNumSdusIn;
+        uint32 iNumBytesIn;
+        uint32 iSduSizeExceededCnt;
+        uint32 iNumCrcErrors;
+        uint32 iNumSeqNumErrors;
+        uint32 iNumAbort;
+        uint32 iNumBytesFlushed;
+        PVMFTimestamp iCurTimestamp;
+        friend class TSC_324m;
+        PVLogger* iIncomingAudioLogger;
+        PVLogger* iIncomingVideoLogger;
+        int32 iRenderingSkew;
+};
+
+class MuxSduData
+{
+    public:
+        MuxSduData();
+        OsclSharedPtr<H223OutgoingChannel> lcn;
+        PVMFSharedMediaDataPtr sdu;
+        uint16 size;
+        uint16 cur_frag_num;
+        uint16 cur_pos;
+};
+typedef Oscl_Vector<MuxSduData, OsclMemAllocator> MuxSduDataList;
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/lowerlayer.h b/protocols/systems/3g-324m_pvterminal/h223/include/lowerlayer.h
new file mode 100644
index 0000000..c3a34a7
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/lowerlayer.h
@@ -0,0 +1,301 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(LOWER_LAYER_H)
+#define LOWER_LAYER_H
+#include "oscl_types.h"
+#include "oscl_time.h"
+#ifndef OSCL_TIMER_H_INCLUDED
+#include "oscl_timer.h"
+#endif
+#include "pvt_params.h"
+#include "pvt_events.h"
+#include "pduparcom.h"
+#include "layer.h"
+#include "media_packet.h"
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#include "h223types.h"
+#define H223_MAX_SEND_SIZE  1024
+#define DEFAULT_BITRATE 64000
+#define H223_DEMUX_BUFFER_INTERVAL_MS 0
+
+class LowerLayerObserver
+{
+    public:
+        virtual ~LowerLayerObserver() {}
+        virtual PVMFStatus GetOutgoingMuxPdus(MuxPduPacketList& packets) = 0;
+        virtual void LevelSetupComplete(PVMFStatus status, TPVH223Level level) = 0;
+        virtual void DataReceptionStart() = 0;
+        virtual H223PduParcomObserver* GetParcomObserver()  = 0;
+        virtual void LowerLayerError(TPVDirection direction, PVMFStatus error) = 0;
+};
+
+
+/* Lower layer which binds to Network IO */
+class H223LowerLayer : public PvmfPortBaseImpl,
+            public PVMFPortActivityHandler,
+            public OsclTimerObject,
+            public OsclTimerObserver,
+            public H223PduParcomObserver
+{
+    public:
+        H223LowerLayer(int32 aPortTag, TPVLoopbackMode aLoopbackMode);
+        ~H223LowerLayer();
+
+        void SetObserver(LowerLayerObserver* observer)
+        {
+            iObserver = observer;
+            if (iParcom.GetRep())
+                iParcom->SetObserver(iObserver->GetParcomObserver());
+        }
+
+        LowerLayerObserver* GetObserver()
+        {
+            return iObserver;
+        }
+
+        TPVStatusCode SetTimerRes(uint32 timer_res)
+        {
+            iMinTimerResolution = timer_res;
+            UpdatePduSize();
+            return EPVT_Success;
+        }
+
+        TPVStatusCode Open();
+        TPVStatusCode Close();
+        TPVStatusCode Start(H223PduParcomSharedPtr parcom);
+        TPVStatusCode Stop();
+
+        PVMFStatus Connect(PVMFPortInterface* aPort);
+        void HandlePortActivity(const PVMFPortActivity &);
+        //Force lower layer to stop.
+        int Abort();
+
+        TPVStatusCode SetLevel(TPVH223Level muxLevel);
+
+        TPVH223Level GetLevel()
+        {
+            return iParcom->GetLevel();
+        }
+
+        TPVStatusCode SetBitrate(uint32 bitRate);
+
+        TPVStatusCode SetTransmitProfile(bool iAnxA, bool iAnxADf, bool iAnxB, bool iAnxBOh)
+        {
+            iUseAnnexA = iAnxA;
+            iUseAnnexADoubleFlag = iAnxADf;
+            iUseAnnexB = iAnxB;
+            iUseAnnexBwithHeader = iAnxBOh;
+            return EPVT_Success;
+        }
+
+        TPVStatusCode SetMaxOutgoingPduSize(uint16 Size);
+
+        int GetMinTimerRes()
+        {
+            return iMinTimerResolution;
+        }
+        /* Implement PAcketInput: process incoming packet */
+        void PacketIn(PVMFSharedMediaDataPtr aMediaData);
+
+        /* Dispatch outgoing packet */
+        void DispatchPacket(OsclSharedPtr<PVMFMediaDataImpl>& pack);
+
+        void SetLoopbackMode(TPVLoopbackMode aLoopbackMode);
+
+        int iTimerIntervalNum;
+        unsigned int iMinTimerResolution;
+
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+        /* H223PduParcomObserver virtuals */
+        uint32 MuxPduIndicate(uint8* pPdu, uint32 pduSz, int32 fClosing, int32 muxCode);
+        void MuxPduErrIndicate(EMuxPduError err);
+        void MuxSetupComplete(PVMFStatus status, TPVH223Level level);
+        unsigned SetStuffingSize(TPVH223Level level);
+
+        unsigned GetStuffingSize()
+        {
+            return iParcom->GetStuffingSz();
+        }
+        unsigned GetHeaderSize()
+        {
+            return iParcom->GetHeaderSz();
+        }
+
+        unsigned SetPduSize(unsigned pdu_size);
+        unsigned GetPduSize()
+        {
+            return iPduSize;
+        }
+        unsigned GetSendSize();
+
+        void ResetStats();
+        void LogStats(TPVDirection dir);
+        int32 GetTimestamp();
+        void GetHdrFragment(OsclRefCounterMemFrag& hdr_frag);
+        PVMFStatus CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& packet, int mt_entry, int pm);
+        void DoStuffing(TPVH223Level level,
+                        OsclSharedPtr<PVMFMediaDataImpl>& pkt,
+                        uint32 stuffing_sz,
+                        uint8 mux_code = 0);
+        void SendStuffingMsgHeader(uint8* stuffing, uint16 num_bytes);
+    protected:
+        PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg);
+        void Parse(uint8* buf, uint16 size);
+        bool CheckLevel(uint8* pData, uint16 size , uint16* used_bytes, int* sync_detected);
+        bool CheckLevelWithSync(uint8* pData, uint16 size, uint16* used_bytes) ;
+        void SignalLevelSetupComplete(PVMFStatus status);
+
+        void Run();
+        void DoCancel();
+    private:
+        void InitParams();
+        void InitRuntimeParams();
+        PVMFStatus Mux();
+        void UpdatePduSize();
+        void CreateParcom(TPVH223Level level);
+        void MuxException();
+
+        LowerLayerObserver* iObserver;
+
+        /* Transmit profile */
+        bool iUseAnnexA;
+        bool iUseAnnexADoubleFlag;
+        bool iUseAnnexB;
+        bool iUseAnnexBwithHeader;
+
+        /* multiplex level */
+        bool iLevelSetupComplete;
+
+        /* Stuffing buffers for each level.  Pre-allocated and initialized with stuffing for that level */
+        PVMFBufferPoolAllocator* iMemFragmentAlloc;
+        OsclRefCounterMemFrag iStuffingFrag[MAX_H223_LEVELS+1];
+
+        uint16 iStuffingSz[8];
+
+        /* bitrate, bps */
+        uint32 iBitrate;
+
+        FragmentAllocator* iHdrFragmentAlloc;
+
+        PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>* iDispatchPacketAlloc;
+        OsclMemPoolFixedChunkAllocator* iMediaDataImplMemAlloc;
+
+        OsclMemPoolFixedChunkAllocator* iMediaMsgPoolAlloc;
+
+        OsclSharedPtr<PVMFMediaDataImpl> iDispatchPacket;
+        MuxPduPacketList iSendPacketList;
+
+        /* Send MUX-PDU size */
+        unsigned iSendPduSz;
+        unsigned iPduSize;
+        unsigned iStuffingSize;
+
+        /* Timer stuff */
+        OsclTimer<OsclMemAllocator> iTimer;
+
+        /* operational state */
+        int iState;
+        int iStateVal;
+
+        /* PDU parcoms */
+        H223PduParcomSharedPtr iParcom;
+        TPVLoopbackMode iLoopbackMode;
+
+        int iTimerCnt;
+        int iBytesSent;
+        uint32 iSendTimes;
+
+        TimeValue iStartTimeTx;
+        uint32 iNumBytesTx;
+        uint32 iNumMuxSduBytesTx;
+        uint32 iNumStuffingBytesTx;
+        uint32 iNumPdusTx;
+        uint32 iNumPmTx;
+
+        TimeValue iStartTimeRx;
+        uint32 iNumBytesRx;
+
+        TimeValue  iLevelSetupTime;
+
+        // Allocator for simple media data buffer
+        OsclMemAllocator iMemAlloc;
+        PVMFSimpleMediaBufferCombinedAlloc iMediaDataAlloc;
+        TimeValue iStartMuxTime;
+        TimeValue iLastMuxTime;
+
+        PVLogger* iLogger;
+        uint8* iDemuxBuffer;
+        uint8* iDemuxBufferPos;
+        uint32 iDemuxBufferSize;
+        uint32 iSyncCheckCount;
+        bool iSkipLevelCheck;
+        uint8* iIdleSyncCheckBuffer;
+        bool iSyncDetected;
+        bool iDataReceptionStart;
+};
+
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/muxtbl.h b/protocols/systems/3g-324m_pvterminal/h223/include/muxtbl.h
new file mode 100644
index 0000000..75193a1
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/muxtbl.h
@@ -0,0 +1,76 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(MUXTBL_H)
+#define MUXTBL_H
+#include "oscl_types.h"
+#include "h245def.h"
+#include "h245pri.h"
+#include "h223types.h"
+#include "logicalchannel.h"
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#define MAX_MUX_ENTRIES 16
+#define MAX_LCN_NUM 4
+
+#define ACTIVATE 1
+#define DEACTIVATE 0
+
+class MuxTableMgr
+{
+    public:
+        MuxTableMgr();
+        ~MuxTableMgr();
+
+        OsclAny SetIncomingDescriptors(PS_MuxDescriptor mux_desc);
+        OsclAny SetIncomingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors, bool replace = true);
+        void SetOutgoingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors);
+        void RemoveOutgoingMuxDescriptor(uint8 muxTblNum);
+        void RemoveIncomingMuxDescriptor(uint8 muxTblNum);
+        PS_MultiplexEntryDescriptor GetIncomingDescriptor(uint8 tblNum);
+        PS_MultiplexEntryDescriptor GetOutgoingDescriptor(MuxSduDataList& data_list);
+        PS_MultiplexEntryDescriptor GetOutgoingDescriptor(OsclSharedPtr<H223OutgoingChannel>& lcn, PVMFSharedMediaDataPtr sdu);
+
+        OsclAny ResetStats();
+        OsclAny LogStats(TPVDirection dir);
+        uint32 GetMuxEntryAccessCount(TPVDirection dir, uint8 tblNum);
+    private:
+        /* function prototypes */
+        bool RemoveDescriptorR(uint8 tblNum);
+        OsclAny AddIncomingControlDescriptor();
+        void AddControlDescriptor(CPVMultiplexEntryDescriptorVector& descriptors);
+        PS_MultiplexEntryDescriptor GetControlDescriptor(uint16 mux_entry_num);
+
+        /* multiplex table information */
+        uint16		iOutgoingMuxTblCount;
+        uint16		iIncomingMuxTblCount;
+
+        uint8		iMuxDescriptorFlagR[MAX_MUX_ENTRIES];
+        PS_MultiplexEntryDescriptor	iMuxDescriptorR[MAX_MUX_ENTRIES];
+
+        uint32 iNumCorruptMcRx;
+        uint32 iMcAccessCnt[MAX_MUX_ENTRIES];
+        uint32 iMcAccessCntR[MAX_MUX_ENTRIES];
+        CPVMultiplexEntryDescriptorVector* iOutgoingDescriptors;
+        MuxSduDataList iMuxSduDataList;
+        PVLogger* iLogger;
+};
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h223/include/pduparcom.h b/protocols/systems/3g-324m_pvterminal/h223/include/pduparcom.h
new file mode 100644
index 0000000..3cd96e8
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/include/pduparcom.h
@@ -0,0 +1,207 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(PDU_PARCOM_H)
+#define PDU_PARCOM_H
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "media_fragment.h"
+#include "media_packet.h"
+#include "golay.h"
+#include "oscl_time.h"
+#include "oscl_rand.h"
+#include "h324utils.h"
+#include "h223types.h"
+
+#ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
+#include "pvmf_media_frag_group.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+typedef enum
+{
+    EHeaderErr = 0,
+    ESizeErr
+}EMuxPduError;
+
+class H223PduParcomObserver
+{
+    public:
+        virtual ~H223PduParcomObserver() {}
+        virtual uint32 MuxPduIndicate(uint8* pPdu, uint32 pduSz, int32 fClosing, int32 muxCode) = 0;
+        virtual void MuxPduErrIndicate(EMuxPduError err) = 0;
+        virtual void MuxSetupComplete(PVMFStatus status, TPVH223Level level) = 0;
+};
+
+class H223PduParcom
+{
+    public:
+        virtual ~H223PduParcom() {}
+
+        /**
+         * Returns the level associated with this parcom.
+         **/
+        virtual TPVH223Level GetLevel() = 0;
+
+        /**
+         * Constructs the parcom based on max_outstanding_pdus.
+         **/
+        virtual void Construct(uint16 max_outstanding_pdus) = 0;
+        /**
+         * Sets the base parcom observer.
+         **/
+        virtual void SetObserver(H223PduParcomObserver* observer) = 0;
+        /**
+         * Copies one stuffing sequence into the provided buffer.
+         * @param buf The buffer to be used.
+         * @param buf_size The maximum size of the buffer.
+         * @param mux_code The multiplex code to be used in the stuffing header (may not apply for some parcoms)
+         * @return The number of bytes copied.
+         **/
+        virtual uint32 GetStuffing(uint8* buf, uint32 buf_size, uint8 mux_code = 0) = 0;
+
+        /**
+         * @return The size of the header field.
+         **/
+        virtual uint32 GetHeaderSz() = 0;
+
+        /**
+         * Returns the stuffing size.
+         * @return The size of the stuffing sequence.
+         **/
+        virtual uint32 GetStuffingSz() = 0;
+
+        /**
+         * Parses the bitstream and returns pdus using the MuxPduIndicate observer callback.
+         * @param buf The buffer to be used.
+         * @param buf_size The maximum size of the buffer.
+         * @param mux_code The multiplex code to be used in the stuffing header (may not apply for some parcoms)
+         * @return The number of bytes copied.
+         **/
+        virtual uint32 Parse(uint8* buffer, uint32 buffer_size) = 0;
+
+        /**
+         * Returns a header fragment.
+         * @param frag The buffer to be used.
+         * @param buf_size The maximum size of the buffer.
+         * @param mux_code The multiplex code to be used in the stuffing header (may not apply for some parcoms)
+         * @return The number of bytes copied.
+         **/
+        virtual void GetHdrFragment(OsclRefCounterMemFrag& frag) = 0;
+
+        /**
+         * Completes a pdu (sets the header and trailer info if any).
+         * @param pdu The pdu to be completed.
+         * @param mux_code The multiplex code for this pdu.
+         * @param packet_marker The packet marker field.
+         * @return The return status.
+         **/
+        virtual PVMFStatus CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 mux_code, uint8 packet_marker) = 0;
+
+        virtual void ResetStats() = 0;
+        virtual void LogStats(TPVDirection dir) = 0;
+};
+
+typedef OsclSharedPtr<H223PduParcom> H223PduParcomSharedPtr;
+
+/** Base implementation with some common features to Level0,1,2. **/
+class H223PduParcomBase : public H223PduParcom
+{
+    public:
+        H223PduParcomBase():
+                iObserver(NULL),
+                iLogger(NULL),
+                iPduEndPos(NULL)
+        {
+            iPduPos = iPdu;
+            iPduEndPos = &iPdu[H223_MAX_DEMUX_PDU_SIZE-1];
+        }
+
+        void SetObserver(H223PduParcomObserver* observer)
+        {
+            iObserver = observer;
+        }
+
+        void ResetStats();
+        void LogStats(TPVDirection dir);
+    protected:
+        H223PduParcomObserver* iObserver;
+        PVLogger* iLogger;
+
+        uint8 iPdu[H223_MAX_DEMUX_PDU_SIZE];
+        uint8* iPduPos;
+        uint8* iPduEndPos;
+
+        // Outgoing
+        uint32 iNumFlagsTx;
+        uint32 iNumStuffingTx;
+        uint32 iNumPdusTx;
+
+        // Incoming
+        uint32 iNumFlagsRx;
+        uint32 iNumStuffingRx;
+        uint32 iNumPdusRx;
+        uint32 iNumPmRx;
+
+        uint32 iNumFlagErrorsRx;
+        uint32 iCumFlagErrorsRx;
+        uint32 iNumSyncLossRx;
+        uint32 iNumBytesLossRx;
+        uint32 iNumPduHdrErrorRx;
+        uint32 iCumPduHdrErrorRx;
+};
+
+class PduParcomRefCounter: public OsclRefCounter
+{
+    public:
+        PduParcomRefCounter(H223PduParcom* p): ptr(p), refcnt(1) {}
+
+        void addRef()
+        {
+            ++refcnt;
+        }
+
+        void removeRef()
+        {
+            --refcnt;
+            if (refcnt == 0)
+            {
+                if (ptr)
+                {
+                    delete ptr;
+                }
+                delete this;
+            }
+        }
+
+        uint32 getCount()
+        {
+            return refcnt;
+        }
+    private:
+        H223PduParcom* ptr;
+        uint32 refcnt;
+};
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/adaptationlayer.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/adaptationlayer.cpp
new file mode 100644
index 0000000..120c8a5
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/adaptationlayer.cpp
@@ -0,0 +1,430 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "adaptationlayer.h"
+#define SREJ	    0
+#define	DRTX	    255
+#define PV2WAY_H223_AL2_SN_WRAPAROUND 256
+#define PV2WAY_H223_AL2_CRC_SIZE 1
+#define PV2WAY_H223_AL3_CRC_SIZE 2
+#define PV2WAY_MAX_PACKET_MEM_FRAG 32
+#define PV2WAY_H223_AL2_MAX_HDR_TRLR_FRAG_SIZE 4
+#define PV2WAY_H223_AL3_SNPOS1_BITLEN 7
+#define PV2WAY_H223_AL3_SNPOS1_VRMAX 0x7F
+#define PV2WAY_H223_AL3_SNPOS2_VRMAX 0x7FFF
+#define PV2WAY_H223_AL3_SNPOS2_PT_LEN 1
+
+
+void AdaptationLayer1::Construct()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.AdaptationLayer1");
+}
+
+void AdaptationLayer1::ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer1::ParsePacket, pdu_size(%d)", pkt->getFilledSize()));
+    oscl_memset(&info, 0, sizeof(IncomingALPduInfo));
+    info.sdu_size = (int16)pkt->getFilledSize();
+
+}
+
+
+PVMFStatus AdaptationLayer1::CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt)
+{
+    OSCL_UNUSED_ARG(pkt);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer1::CompletePacket packet size(%d)", pkt->getFilledSize()));
+    return PVMFSuccess;
+}
+
+void AdaptationLayer2::Construct()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.AdaptationLayer2");
+    // Do not Leave on allocation failure
+    iMemFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iMemFragmentAlloc.size((uint16)iMaxNumSdus, PV2WAY_H223_AL2_MAX_HDR_TRLR_FRAG_SIZE);
+}
+
+void AdaptationLayer2::SetSeqnum(bool on_off)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer2::SetSeqnum(%d)", on_off));
+    if (on_off)
+    {
+        iSNPos = 1;
+        iHdrSz = 1;
+    }
+    else
+    {
+        iSNPos = 0;
+        iHdrSz = 0;
+    }
+}
+
+PVMFStatus AdaptationLayer2::StartPacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt)
+{
+    if (iSNPos)
+    {
+        OsclRefCounterMemFrag hdr_frag = iMemFragmentAlloc.get();
+        if (hdr_frag.getMemFragPtr() == NULL)
+        {
+            return PVMFErrNoMemory;
+        }
+        hdr_frag.getMemFrag().len = 1;
+        pkt->appendMediaFragment(hdr_frag);
+    }
+    return PVMFSuccess;
+}
+
+
+
+PVMFStatus AdaptationLayer2::CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt)
+{
+    int Size = pkt->getFilledSize();
+    uint8 Crc;
+    uint8* pos = NULL;
+    OsclRefCounterMemFrag hdr_frag;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer2::CompletePacket packet, size(%d)", Size));
+
+    OsclRefCounterMemFrag trlr_frag = iMemFragmentAlloc.get();
+    if (trlr_frag.getMemFragPtr() == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+    trlr_frag.getMemFrag().len = 1;
+
+    if (iSNPos)
+    {
+        pkt->getMediaFragment(0, hdr_frag);
+        Size += iSNPos;
+        pos = (uint8*)hdr_frag.getMemFragPtr();
+        *pos = (uint8)(iSeqNum);
+        if (iSeqNum != 0xff)
+            iSeqNum ++;
+        else
+            iSeqNum = 0;
+    }
+
+    Crc = crc.Crc8Check(pkt);
+    pkt->appendMediaFragment(trlr_frag);
+    pos = (uint8*)trlr_frag.getMemFragPtr();
+
+    *pos = Crc;
+    Size ++;
+
+    return PVMFSuccess;
+}
+
+#define WINSIZE	10
+
+void AdaptationLayer2::ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info)
+{
+    OsclRefCounterMemFrag frag;
+    uint8 Crc = 0;
+    info.crc_error = false; // No CRC error.
+    info.seq_num_error = 0; // No sequence number error.
+    uint8 SeqNum = 0;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer2::ParsePacket pdu size(%d)", pkt->getFilledSize()));
+    info.sdu_size = (uint16)(pkt->getFilledSize() - iSNPos - PV2WAY_H223_AL2_CRC_SIZE);
+    if (info.sdu_size  <= 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "AdaptationLayer2::ParsePacket sdu size(%d) < 0", info.sdu_size));
+        return;
+    }
+    OsclRefCounterMemFrag last_frag;
+    pkt->getMediaFragment(pkt->getNumFragments() - 1, last_frag);
+    Crc = *((uint8*)last_frag.getMemFragPtr() + last_frag.getMemFragSize() - 1);
+    pkt->setMediaFragFilledLen(pkt->getNumFragments() - 1, last_frag.getMemFrag().len - PV2WAY_H223_AL2_CRC_SIZE);
+
+    OsclRefCounterMemFrag first_frag;
+    pkt->getMediaFragment(0, first_frag);
+
+    uint16 CrcCheck = crc.Crc8Check(pkt, false);
+    if (Crc != CrcCheck)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "AdaptationLayer2::ParsePacket CRC error sn(%d)", iSeqNum));
+        info.crc_error = true;
+        //Update expected sequence number.
+        iSeqNum = (iSeqNum + 1) % PV2WAY_H223_AL2_SN_WRAPAROUND;
+    }
+    else
+    {
+        if (iSNPos == 1)
+        {
+            SeqNum = *((uint8*)first_frag.getMemFragPtr());
+            first_frag.getMemFrag().len -= iSNPos;
+            first_frag.getMemFrag().ptr = (uint8*)first_frag.getMemFrag().ptr + iSNPos;
+
+            //If sequence number is good.
+            if (iSeqNum == SeqNum)
+            {
+                iSeqNum = (iSeqNum + 1) % PV2WAY_H223_AL2_SN_WRAPAROUND;
+            }
+            //Else sequence number is not good.
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "AdaptationLayer2::ParsePacket Sequence number error expected(%d), received(%d)", iSeqNum, SeqNum));
+
+                //Check the difference between expected seq number and actual seq number.
+
+                //Check if sequence number wrapped.
+                if (iSeqNum > SeqNum)
+                {
+                    info.seq_num_error = (PV2WAY_H223_AL2_SN_WRAPAROUND - iSeqNum) + SeqNum;
+                }
+                //Else no wrap.
+                {
+                    info.seq_num_error = SeqNum - iSeqNum;
+                }
+
+                //Update expected seq number based on actual seq number received.
+                iSeqNum = (SeqNum + 1) % PV2WAY_H223_AL2_SN_WRAPAROUND;
+            }
+        }
+    }
+    if (iSNPos)
+    {
+        OsclRefCounterMemFrag frags[PV2WAY_MAX_PACKET_MEM_FRAG];
+        unsigned int num_frags = pkt->getNumFragments();
+        if (num_frags <= PV2WAY_MAX_PACKET_MEM_FRAG)
+        {
+            unsigned int fragnum;
+            frags[0] = first_frag;
+            for (fragnum = 1;fragnum < num_frags;fragnum++)
+            {
+                pkt->getMediaFragment(fragnum, frags[fragnum]);
+            }
+            pkt->clearMediaFragments();
+            for (fragnum = 0;fragnum < num_frags;fragnum++)
+            {
+                pkt->appendMediaFragment(frags[fragnum]);
+            }
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer2::ParsePacket pkt->getNumFragments() is greater then PV2WAY_MAX_PACKET_MEM_FRAG"));
+        }
+    }
+}
+
+void AdaptationLayer3::Construct()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.AdaptationLayer3");
+    // Do not Leave on allocation failure
+    iMemFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iMemFragmentAlloc.size((uint16)(iMaxNumSdus*2), 4);
+}
+
+void AdaptationLayer3::SetSeqnumSz(uint16 sz)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer3::SetSeqnumSz(%d)", sz));
+    iSNPos = sz;
+    iHdrSz = sz;
+}
+
+PVMFStatus AdaptationLayer3::StartPacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt)
+{
+    if (iSNPos)
+    {
+        OsclRefCounterMemFrag hdr_frag = iMemFragmentAlloc.get();
+        if (hdr_frag.getMemFragPtr() == NULL)
+        {
+            return PVMFErrNoMemory;
+        }
+        hdr_frag.getMemFrag().len = iSNPos;
+        pkt->appendMediaFragment(hdr_frag);
+    }
+    return PVMFSuccess;
+}
+
+PVMFStatus AdaptationLayer3::CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt)
+{
+    int Size = pkt->getFilledSize();
+    unsigned Crc = 0, usTmp = 0;
+    uint8* pos = NULL;
+    OsclRefCounterMemFrag hdr_frag;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer3::CompletePacket(%d)", pkt->getFilledSize()));
+    OsclRefCounterMemFrag trlr_frag = iMemFragmentAlloc.get();
+    if (trlr_frag.getMemFragPtr() == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    trlr_frag.getMemFrag().len = 2;
+    Size += iSNPos;
+
+    switch (iSNPos)
+    {
+        case 0:
+            break;
+        case 1:
+            usTmp = (uint16)iSeqNum;
+            pkt->getMediaFragment(0, hdr_frag);
+            pos = (uint8*)hdr_frag.getMemFragPtr();
+
+            *pos = (uint8)((usTmp << 1) | 1);
+            if (usTmp != PV2WAY_H223_AL3_SNPOS1_VRMAX)
+                iSeqNum ++;
+            else
+                iSeqNum = 0;
+            break;        /* SN( 7bit ) */
+        case 2:
+            usTmp = iSeqNum;
+            pkt->getMediaFragment(0, hdr_frag);
+            pos = (uint8*)hdr_frag.getMemFragPtr();
+
+            *pos = (uint8)((usTmp >> 7) | 1);
+            *(pos + 1) = (uint8)(usTmp & 0xff);
+            if (usTmp != PV2WAY_H223_AL3_SNPOS2_VRMAX)
+                iSeqNum ++;
+            else
+                iSeqNum = 0;
+            break;			/* SN( 15bit )*/
+    }
+
+    Crc = crc.Crc16Check(pkt);
+    pkt->appendMediaFragment(trlr_frag);
+    pos = (uint8*)trlr_frag.getMemFragPtr();
+
+    *(pos) = (uint8)(Crc & 0xff);
+    *(pos + 1) = (uint8)(Crc >> 8);
+    Size += 2;
+    return PVMFSuccess;
+}
+
+#define WINSIZE	10
+
+void AdaptationLayer3::ParsePacket(OsclSharedPtr<PVMFMediaDataImpl>& pkt, IncomingALPduInfo& info)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "AdaptationLayer3::ParsePacket pdu_size(%d)", pkt->getFilledSize()));
+    OsclRefCounterMemFrag frag;
+    uint16 SeqNum = 0;
+    uint16 Crc = 0, VrMax = 0;
+    iPktNum++;
+    info.crc_error = false;
+    info.seq_num_error = 0;
+    info.sdu_size = (uint16)(pkt->getFilledSize() - iSNPos - PV2WAY_H223_AL3_CRC_SIZE);
+    if (info.sdu_size <= 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "AdaptationLayer3::ParsePacket sdu size(%d) < 0", info.sdu_size));
+        return;
+    }
+
+    OsclRefCounterMemFrag first_frag, last_frag;
+    pkt->getMediaFragment(0, first_frag);
+    pkt->getMediaFragment(pkt->getNumFragments() - 1, last_frag);
+
+    switch (iSNPos)
+    {
+        case 0:
+//		not used currently
+            break;
+        case 1:
+            SeqNum = (uint16)(((uint8*)first_frag.getMemFragPtr())[0] >> (sizeof(uint8)));
+            VrMax = PV2WAY_H223_AL3_SNPOS1_VRMAX;			    /* 0-127 */
+            break;
+        case 2:
+            SeqNum = (uint16)((((uint8*)first_frag.getMemFragPtr())[0] >> 1) << 8 | ((uint8*)first_frag.getMemFragPtr())[1]);
+            VrMax = PV2WAY_H223_AL3_SNPOS2_VRMAX; /* 0-32767 */
+            break;
+    }
+
+    if (last_frag.getMemFragSize() >= PV2WAY_H223_AL3_CRC_SIZE)
+    {
+        Crc = (uint16)(((*((uint8*)last_frag.getMemFragPtr() + last_frag.getMemFragSize() - 1)) << 8) |
+                       (*((uint8*)last_frag.getMemFragPtr() + last_frag.getMemFragSize() - 2)));
+        pkt->setMediaFragFilledLen(pkt->getNumFragments() - 1, last_frag.getMemFrag().len - PV2WAY_H223_AL3_CRC_SIZE);
+    }
+    else // in the rare case that the last fragment contains only 1 byte of the CRC
+    {
+        OsclRefCounterMemFrag second_last_frag;
+        pkt->getMediaFragment(pkt->getNumFragments() - 2, second_last_frag);
+        Crc = (uint16)(((*((uint8*)last_frag.getMemFragPtr())) << 8) |
+                       (*((uint8*)second_last_frag.getMemFragPtr() + second_last_frag.getMemFragSize() - 1)));
+        pkt->setMediaFragFilledLen(pkt->getNumFragments() - 1, last_frag.getMemFrag().len - 1);
+        pkt->setMediaFragFilledLen(pkt->getNumFragments() - 2, second_last_frag.getMemFrag().len - 1);
+    }
+    if (Crc != crc.Crc16Check(pkt, false))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "AdaptationLayer3::ParsePacket CRC error, sn(%d)", iSeqNum));
+
+        info.crc_error = true;
+
+        //Update sequence number.
+        if (iSeqNum == VrMax)
+        {
+            iSeqNum = 0;
+        }
+        else
+        {
+            iSeqNum++;
+        }
+    }
+    else
+    {
+        //If sequence number is good.
+        if (iSeqNum == SeqNum)
+        {
+            if (iSeqNum == VrMax)
+            {
+                iSeqNum = 0;
+            }
+            else
+            {
+                iSeqNum++;
+            }
+        }
+        //Else sequence number is not good.
+        else
+        { /* missing or mis-delivered packets, send them anyway */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "AdaptationLayer3::ParsePacket Sequence number error - Expected(%d), Received(%d)", iSeqNum, SeqNum));
+            //Check the difference between expected seq number and actual seq number.
+
+            //Check if sequence number wrapped.
+            if (iSeqNum > SeqNum)
+            {
+                info.seq_num_error = ((VrMax + 1) - iSeqNum) + SeqNum;
+            }
+            //Else no wrap.
+            {
+                info.seq_num_error = SeqNum - iSeqNum;
+            }
+
+            //Update
+            iSeqNum = (uint16)((SeqNum + 1) % (VrMax + 1));
+        }
+    }
+
+    if (iSNPos)
+    {
+        pkt->getMediaFragment(0, first_frag);// do this in case first frag == last frag
+        first_frag.getMemFrag().len -= iSNPos;
+        first_frag.getMemFrag().ptr = (uint8*)first_frag.getMemFrag().ptr + iSNPos;
+        OsclRefCounterMemFrag frags[PV2WAY_MAX_PACKET_MEM_FRAG];
+        unsigned int num_frags = pkt->getNumFragments();
+        unsigned int fragnum;
+        frags[0] = first_frag;
+        for (fragnum = 1;fragnum < num_frags;fragnum++)
+        {
+            pkt->getMediaFragment(fragnum, frags[fragnum]);
+        }
+        pkt->clearMediaFragments();
+        for (fragnum = 0;fragnum < num_frags;fragnum++)
+        {
+            pkt->appendMediaFragment(frags[fragnum]);
+        }
+    }
+
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/cpvh223multiplex.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/cpvh223multiplex.cpp
new file mode 100644
index 0000000..833d89a
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/cpvh223multiplex.cpp
@@ -0,0 +1,1437 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include  <stdlib.h>
+#include <string.h>
+#include "cpvh223multiplex.h"
+#include "media_packet.h"
+#include "media_fragment.h"
+#include "lowerlayer.h"
+#include "logicalchannel.h"
+#include "adaptationlayer.h"
+#include "muxtbl.h"
+#include "h223.h"
+
+/* Default sizes for outgoing SDUs */
+#define DEF_AL1_SDU_SIZE 1024
+#define DEF_AL2_SDU_SIZE 256
+#define DEF_AL3_SDU_SIZE 256
+
+/* Default sizes for incoming SDUs */
+#define DEF_AL1_SDU_SIZE_R 1024
+#define DEF_AL2_SDU_SIZE_R 256
+#define DEF_AL3_SDU_SIZE_R 256
+
+#define MIN_SEGMENTABLE_SDU_SIZE 256
+#define MAX_NONSEGMENTABLE_SDU_SIZE 128  /* Implementers guide notes that not more than 3 frames of audio per pdu*/
+#define DEF_CHANNEL_BITRATE 64000
+#define DEF_OUTGOING_MEDIA_QUEUE_SIZE_MS 2000
+#define DEF_MIN_SAMPLE_INTERVAL 20
+
+#define GET_SDU_DATA_LIST(segmentable)\
+ segmentable?iSegmentableSduDataList:iNonSegmentableSduDataList
+
+#define PV_H223_DEF_SAMPLE_INTERVAL 20
+#define H223_LCN_DATA_DETECT_THRESHOLD 1
+#define PV_H223_DEF_MULTPLEXING_DELAY_INTERVAL 0
+#define PV_H223_INTERLEAVING_FLAG_SEND_FREQUENCY 10
+
+#define H223_LOWERLAYER_PORT_TAG PV_MULTIPLEXED
+
+/** Change this to force the queue size for number of outgoing media data.  Otherwise, it is calculated
+    based on bitrate, sample rate and sdu size */
+//#define FORCE_NUM_OUTGOING_MEDIA_DATA 150
+
+CPVH223Multiplex::CPVH223Multiplex(TPVLoopbackMode aLoopbackMode)
+        : iLowerLayer(NULL),
+        iMuxTblMgr(NULL),
+        iLoopbackMode(aLoopbackMode),
+        iDummyFragment(NULL),
+        iMediaDataImplMemAlloc(NULL),
+        iMuxPduPacketAlloc(NULL),
+        iClock(NULL),
+        iInterleavingMultiplexFlagsSize(0),
+        iInterleavingMultiplexFlags(NULL)
+{
+    iMuxTblMgr = OSCL_NEW(MuxTableMgr, ());
+
+    iState = false;
+    iLcnsWithData = 0;
+    iStuffOnlyFirstSend = false;
+    for (int n = 0; n < MAX_LCNS; n++)
+    {
+        iALIndex[n] = 0;
+    }
+
+    Init();
+
+    ResetStats();
+}
+
+CPVH223Multiplex::~CPVH223Multiplex()
+{
+    OSCL_DELETE(iMuxTblMgr);
+    iMuxTblMgr = NULL;
+#if 0
+    delete iMutex;
+    iMutex = NULL;
+#endif
+}
+
+void CPVH223Multiplex::Init()
+{
+    iAlSduSize[0] = iMaxAlSduSize[0] = iMaxAlSduSizeR[0] = 0;
+    iAlSduSizeR[0] = 0;
+    iAlSduSize[1] = iMaxAlSduSize[1] = DEF_AL1_SDU_SIZE;
+    iAlSduSize[2] = iMaxAlSduSize[2] = DEF_AL2_SDU_SIZE;
+    iAlSduSize[3] = iMaxAlSduSize[3] = DEF_AL3_SDU_SIZE;
+    iAlSduSizeR[1] = iMaxAlSduSizeR[1] = DEF_AL1_SDU_SIZE_R;
+    iAlSduSizeR[2] = iMaxAlSduSizeR[2] = DEF_AL2_SDU_SIZE_R;
+    iAlSduSizeR[3] = iMaxAlSduSizeR[3] = DEF_AL3_SDU_SIZE_R;
+    iLcnEnd = NULL;
+    iState = false;
+    iLcnsWithData = 0;
+    ClearSduDataLists();
+    for (int n = 0; n < MAX_LCNS; n++)
+    {
+        iALIndex[n] = 0;
+    }
+    iALIndex[0] = AdaptationLayerAlloc::GetAlIndex(E_EP_LOW);
+    iBitrate = DEFAULT_BITRATE;
+    iMinSampleInterval = PV_H223_DEF_SAMPLE_INTERVAL;
+    iNumMuxIntervalsPerTimerInterval = 0;
+    iNumBytesPerMinSampleInterval = 0;
+    iMultiplexingDelayMs = PV_H223_DEF_MULTPLEXING_DELAY_INTERVAL;
+    TimeValue time_now;
+    iRand.Seed(time_now.to_msec());
+    iInLogicalChannelBufferingMs = 0;
+    iOutLogicalChannelBufferingMs = 0;
+    iFmStuffingRepeatInterval = 0;
+    iFmStuffingMode = 0;
+    iLevelSetupComplete = false;
+    iEnableStuffing = true;
+    iInterleavingMultiplexFlagsSize = 0;
+}
+
+int CPVH223Multiplex::GetMinTimerRes()
+{
+    return iLowerLayer->GetMinTimerRes();
+}
+
+void CPVH223Multiplex::SetLoopbackMode(TPVLoopbackMode aLoopbackMode)
+{
+    iLoopbackMode = aLoopbackMode;
+    iLowerLayer->SetLoopbackMode(iLoopbackMode);
+}
+
+TPVStatusCode CPVH223Multiplex::SetTimerRes(uint32 timer_res)
+{
+    return iLowerLayer->SetTimerRes(timer_res);
+}
+
+TPVStatusCode CPVH223Multiplex::Open()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::Open"));
+
+    iLcnEnd = NULL;
+
+    for (unsigned out_lcn = 0; out_lcn < iOutgoingChannels.size(); out_lcn++)
+    {
+        iOutgoingChannels[out_lcn].Unbind();
+    }
+    for (unsigned in_lcn = 0; in_lcn < iIncomingChannels.size(); in_lcn++)
+    {
+        iIncomingChannels[in_lcn].Unbind();
+    }
+
+    iLowerLayer = OSCL_NEW(H223LowerLayer, (H223_LOWERLAYER_PORT_TAG, iLoopbackMode));
+    iLowerLayer->SetObserver(this);
+    iLowerLayer->Open();
+
+    UpdateMuxInterval(DEF_MIN_SAMPLE_INTERVAL);
+
+    uint16 pdu_rate = (uint16)((2000.0 / (float)iMinSampleInterval + .5) + 1); /* For audio and video */
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::Open pdu_rate=%d", pdu_rate));
+    iMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (pdu_rate));
+    if (iMediaDataImplMemAlloc == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::Open() Failed to allocate iMediaDataImplMemAlloc"));
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    iMediaDataImplMemAlloc->enablenullpointerreturn();
+
+    iMuxPduPacketAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (pdu_rate, MAX_FRAGMENTS_PER_H223_PDU_PACKET, iMediaDataImplMemAlloc));
+    if (iMuxPduPacketAlloc == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::Open() Failed to allocate iMuxPduPacketAlloc"));
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    iMuxPduPacketAlloc->create();
+
+    iLcnsWithData = 0;
+    return EPVT_Success;
+}
+
+int CPVH223Multiplex::Start(H223PduParcomSharedPtr parcom)
+{
+    int ret = 1;
+    iState = true;
+    iPduNum = 0;
+    iLevelSetupComplete = false;
+    iEnableStuffing = true;
+    OSCL_ASSERT(iOutgoingChannels[0].GetRep());
+    OSCL_ASSERT(iIncomingChannels[0].GetRep());
+    ret = iLowerLayer->Start(parcom);
+    //SetStuffingMsgHeader();
+    return ret;
+}
+
+TPVStatusCode CPVH223Multiplex::Close()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::Close"));
+    if (iInterleavingMultiplexFlags && iInterleavingPacket)
+    {
+        iInterleavingPacket->clearMediaFragments();
+        iInterleavingPacket.Unbind();
+        OSCL_DEFAULT_FREE(iInterleavingMultiplexFlags);
+        iInterleavingMultiplexFlags = NULL;
+    }
+
+    for (unsigned out_lcn = 0;out_lcn < iOutgoingChannels.size(); out_lcn++)
+    {
+        CloseChannel(OUTGOING, iOutgoingChannels[out_lcn]->GetLogicalChannelNumber());
+    }
+    for (unsigned in_lcn = 0;in_lcn < iIncomingChannels.size(); in_lcn++)
+    {
+        CloseChannel(INCOMING, iIncomingChannels[in_lcn]->GetLogicalChannelNumber());
+    }
+    if (iLowerLayer)
+    {
+        iLowerLayer->Disconnect();
+        iLowerLayer->Close();
+        OSCL_DELETE(iLowerLayer);
+        iLowerLayer = NULL;
+    }
+
+    iMuxPduPacketAlloc->removeRef();
+    OSCL_DELETE(iMediaDataImplMemAlloc);
+    return EPVT_Success;
+}
+
+int CPVH223Multiplex::Stop()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::Stop"));
+
+    iState = false;
+    iLcnEnd = NULL;
+
+    iOutgoingChannels[0]->Flush();
+    iIncomingChannels[0]->Flush();
+
+    iNonSegmentableSduDataList.clear();
+    iSegmentableSduDataList.clear();
+    iControlSduDataList.clear();
+
+    iLowerLayer->Stop();
+
+    return 1;
+}
+
+
+void CPVH223Multiplex::DataReceptionStart()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::DataReceptionStart()"));
+    iObserver->DataReceptionStart();
+}
+void CPVH223Multiplex::LevelSetupComplete(PVMFStatus status, TPVH223Level level)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::LevelSetupComplete - status=%d, level=%d", status, level));
+    if (iInterleavingMultiplexFlags && iInterleavingPacket)
+    {
+        iInterleavingPacket->clearMediaFragments();
+        iInterleavingPacket.Unbind();
+        OSCL_DEFAULT_FREE(iInterleavingMultiplexFlags);
+        iInterleavingMultiplexFlags = NULL;
+        iInterleavingMultiplexFlagsSize = 0;
+    }
+    if (status == PVMFPending)
+    {
+        EnableStuffing(true);
+    }
+    else
+    {
+        iLevelSetupComplete = true;
+    }
+    //SetStuffingMsgHeader();
+    iObserver->MuxSetupComplete(status, level);
+}
+
+uint32 CPVH223Multiplex::MuxPduIndicate(uint8* pPdu, uint32 sz, int32 fClosing, int32 muxCode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::MuxPduIndicate mux code=%d, closing=%d, size=%d", muxCode, fClosing, sz));
+    int ret = MuxToALDispatch(pPdu, sz, fClosing, muxCode);
+    return (uint16)ret;
+}
+
+void CPVH223Multiplex::MuxPduErrIndicate(EMuxPduError err)
+{
+    OSCL_UNUSED_ARG(err);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::MuxPduErrIndicate - err(%d)", err));
+    iObserver->MuxErrorOccurred(INCOMING, PV_MUX_COMPONENT_MUX, PVMFErrCorrupt);
+}
+
+void CPVH223Multiplex::MuxSetupComplete(PVMFStatus status, TPVH223Level level)
+{
+    OSCL_UNUSED_ARG(status);
+    OSCL_UNUSED_ARG(level);
+}
+
+unsigned CPVH223Multiplex::DispatchPduPacket(MuxPduPacketList& packets,
+        MuxSduData& mux_sdu_data,
+        PS_MultiplexEntryDescriptor mux_entry,
+        uint32 max_size)
+{
+    OSCL_ASSERT(mux_entry->size_of_elementList == 1);
+    OsclSharedPtr<PVMFMediaDataImpl> packet = InitPduPacket();
+
+    if (!packet.GetRep())
+    {
+        return 0;
+    }
+
+    int pm = false;
+    MakePduData(packet,
+                max_size - iLowerLayer->GetHeaderSize(),
+                mux_entry->elementList,
+                mux_sdu_data,
+                &pm);
+    if (CompletePduPacket(packet, mux_entry->multiplexTableEntryNumber, pm) == PVMFSuccess)
+    {
+        packets.push_back(packet);
+        return packet->getFilledSize();
+    }
+    return 0;
+}
+
+/* Called by lower layer to get the next mux pdu to dispatch. */
+PVMFStatus CPVH223Multiplex::GetOutgoingMuxPdus(MuxPduPacketList& packets)
+{
+    unsigned cur_pdus_size = 0;
+    uint16 stuffing_size = (uint16)iLowerLayer->GetStuffingSize();
+    OsclSharedPtr<PVMFMediaDataImpl> pkt;
+
+    for (unsigned n = 0;n < iNumMuxIntervalsPerTimerInterval; n++)
+    {
+        // fill the sdu data lists with lcns that contain data
+        UpdateSduDataLists();
+
+        int32 max_pdus_size = iNumBytesPerMinSampleInterval;
+
+        if (iInterleavingPacket &&
+                iInterleavingPacket.GetRep() &&
+                iInterleavingPacket->getFilledSize() &&
+                iInterleavingMultiplexFlags &&
+                ((iPduNum % PV_H223_INTERLEAVING_FLAG_SEND_FREQUENCY) == 0))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::GetOutgoingMuxPdus Adding interleaving packet."));
+            iInterleavingPacket->clearMediaFragments();
+            OsclRefCounterMemFrag frag;
+            frag.getMemFrag().len = iInterleavingMultiplexFlagsSize;
+            frag.getMemFrag().ptr = iInterleavingMultiplexFlags;
+            iInterleavingPacket->appendMediaFragment(frag);
+            packets.push_back(iInterleavingPacket);
+            max_pdus_size -= iInterleavingPacket->getFilledSize();
+        }
+
+        if (iLowerLayer->GetLevel() == H223_LEVEL0)
+        {
+            if (n == 0)
+            {
+                pkt = iMuxPduPacketAlloc->allocate(1);
+                if (!pkt)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "CPVH223Multiplex::GetOutgoingMuxPdus Unable to allocate packet."));
+                    return PVMFErrNoMemory;
+                }
+                iLowerLayer->DoStuffing(iLowerLayer->GetLevel(), pkt, 5);
+                packets.push_back(pkt);
+                max_pdus_size -= pkt->getFilledSize();
+            }
+        }
+        iPduNum++;
+
+        /* Mux non segmentable data */
+        cur_pdus_size = MuxLcnData(GET_SDU_DATA_LIST(false),
+                                   packets,
+                                   (uint16)OSCL_MIN(max_pdus_size, (int)iLowerLayer->GetPduSize()));
+        max_pdus_size -= cur_pdus_size;
+        if (max_pdus_size < (int)iLowerLayer->GetHeaderSize())
+        {
+            return PVMFSuccess;
+        }
+
+        /* Mux control data untill current pdu is filled up */
+        do
+        {
+            cur_pdus_size = MuxLcnData(iControlSduDataList, packets, (uint16)iLowerLayer->GetPduSize());
+            max_pdus_size -= cur_pdus_size;
+        }
+        while (max_pdus_size > (int)iLowerLayer->GetHeaderSize() &&
+                cur_pdus_size);
+
+        if (max_pdus_size < (int)iLowerLayer->GetHeaderSize())
+        {
+            return PVMFSuccess;
+        }
+
+        /* Mux segmentable data untill current pdu is filled up */
+        do
+        {
+            cur_pdus_size = MuxLcnData(GET_SDU_DATA_LIST(true),
+                                       packets,
+                                       (uint16)OSCL_MIN(max_pdus_size, (int)iLowerLayer->GetPduSize()));
+            max_pdus_size -= cur_pdus_size;
+        }
+        while (max_pdus_size > (int)iLowerLayer->GetHeaderSize() &&
+                cur_pdus_size);
+
+        /* Fill stuffing if space remains in pdu.*/
+        if (iEnableStuffing)
+        {
+            if (!iStuffOnlyFirstSend || (iPduNum == 1))
+            {
+                stuffing_size = (uint16)((max_pdus_size > stuffing_size) ? max_pdus_size : stuffing_size);
+            }
+        }
+        pkt = iMuxPduPacketAlloc->allocate(1);
+        if (!pkt)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "CPVH223Multiplex::GetOutgoingMuxPdus Unable to allocate packet."));
+            return PVMFErrNoMemory;
+        }
+        iLowerLayer->DoStuffing(iLowerLayer->GetLevel(), pkt, stuffing_size);
+
+        if (pkt->getFilledSize())
+        {
+            packets.push_back(pkt);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::GetOutgoingMuxPdus WARNING Failed to send single stuffing"));
+            return PVMFErrNoMemory;
+        }
+    }
+    return PVMFSuccess;
+}
+
+
+
+TPVStatusCode CPVH223Multiplex::SetMaxOutgoingPduSize(uint16 Size)
+{
+    return iLowerLayer->SetMaxOutgoingPduSize(Size);
+}
+
+TPVStatusCode CPVH223Multiplex::SetSduSize(TPVDirection direction, uint16 size, ErrorProtectionLevel_t epl)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux: Set sdu size - direction(%d), size(%d), epl(%d)\n", direction, size, epl));
+    if (direction == OUTGOING)
+    {
+        if (iAlSduSize[epl] > size)
+        {
+            iAlSduSize[epl] = size;
+        }
+    }
+    else
+    {
+        if (iAlSduSizeR[epl] > size)
+        {
+            iAlSduSizeR[epl] = size;
+        }
+    }
+
+    return EPVT_Success;
+}
+
+
+uint16 CPVH223Multiplex::GetSduSize(TPVDirection direction, ErrorProtectionLevel_t epl)
+{
+    if (direction == OUTGOING)
+    {
+        return (uint16)iAlSduSize[epl];
+    }
+    return (uint16)iAlSduSizeR[epl];
+}
+
+uint16 CPVH223Multiplex::GetMaxSduSize(TPVDirection direction, ErrorProtectionLevel_t epl)
+{
+    if (direction == OUTGOING)
+    {
+        return (uint16)iMaxAlSduSize[epl];
+    }
+    return (uint16)iMaxAlSduSizeR[epl];
+}
+
+
+TPVStatusCode CPVH223Multiplex::SetMuxLevel(TPVH223Level muxLevel)
+{
+    TPVStatusCode ret = EPVT_Success;
+//	iMutex->Lock();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux: Set Level request (%d)\n", muxLevel));
+    ret = iLowerLayer->SetLevel(muxLevel);
+//	iMutex->Unlock();
+    return ret;
+}
+
+
+TPVH223Level CPVH223Multiplex::GetMuxLevel()
+{
+    return iLowerLayer->GetLevel();
+}
+
+PVMFPortInterface* CPVH223Multiplex::GetLowerLayer()
+{
+    return iLowerLayer;
+}
+
+TPVStatusCode CPVH223Multiplex::SetIncomingMuxTableEntries(CPVMultiplexDescriptor* descriptor)
+{
+//	iMutex->Lock();
+    iMuxTblMgr->SetIncomingDescriptors(descriptor->GetDescriptor());
+//	iMutex->Unlock();
+
+    return EPVT_Success;
+}
+
+void CPVH223Multiplex::SetIncomingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors, bool replace)
+{
+    iMuxTblMgr->SetIncomingMuxDescriptors(descriptors, replace);
+}
+
+void CPVH223Multiplex::SetOutgoingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors)
+{
+    iMuxTblMgr->SetOutgoingMuxDescriptors(descriptors);
+}
+
+void CPVH223Multiplex::RemoveOutgoingMuxDescriptor(uint8 muxTblNum)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::RemoveOutgoingMuxDescriptor muxTblNum(%d)", muxTblNum));
+    iMuxTblMgr->RemoveOutgoingMuxDescriptor(muxTblNum);
+}
+
+void CPVH223Multiplex::RemoveIncomingMuxDescriptor(uint8 muxTblNum)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::RemoveIncomingMuxDescriptor muxTblNum(%d)", muxTblNum));
+    iMuxTblMgr->RemoveIncomingMuxDescriptor(muxTblNum);
+}
+
+PS_MultiplexEntryDescriptor CPVH223Multiplex::GetIncomingMuxDescriptor(uint16 muxTblNum)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::GetIncomingMuxDescriptor muxTblNum(%d)", muxTblNum));
+    return iMuxTblMgr->GetIncomingDescriptor((uint8)muxTblNum);
+}
+
+PVMFStatus CPVH223Multiplex::GetOutgoingChannel(TPVChannelId id, H223OutgoingChannelPtr& channel)
+{
+    if (id == CHANNEL_ID_UNKNOWN)
+    {
+        return PVMFErrArgument;
+    }
+    for (TPVChannelId index = 0; index < iOutgoingChannels.size(); index++)
+    {
+        if (iOutgoingChannels[index]->GetLogicalChannelNumber() == id)
+        {
+            channel = iOutgoingChannels[index];
+            return PVMFSuccess;
+        }
+    }
+    return PVMFErrArgument;
+}
+
+PVMFStatus CPVH223Multiplex::GetIncomingChannel(TPVChannelId id, H223IncomingChannelPtr& channel)
+{
+    if (id == CHANNEL_ID_UNKNOWN)
+    {
+        return PVMFErrArgument;
+    }
+    for (TPVChannelId index = 0; index < iIncomingChannels.size(); index++)
+    {
+        if (iIncomingChannels[index]->GetLogicalChannelNumber() == id)
+        {
+            channel = iIncomingChannels[index];
+            return PVMFSuccess;
+        }
+    }
+    return PVMFErrArgument;
+}
+
+TPVStatusCode CPVH223Multiplex::GetAdaptationLayer(OsclSharedPtr<AdaptationLayer> &al,
+        TPVDirection aDirection,
+        PS_H223LogicalChannelParameters aH223lcnParams,
+        int32 aSdu_size,
+        uint32 aNum_media_data)
+{
+    al = AdaptationLayerAlloc::GetAdaptationLayer(aDirection,
+            aH223lcnParams, (uint16)aSdu_size, aNum_media_data);
+    if (!al)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::GetAdaptationLayer - Memory allocation failure on StartAlPdu\n"));
+        return EPVT_Failed;
+    }
+    return EPVT_Success;
+}
+
+TPVStatusCode CPVH223Multiplex::OpenChannel(TPVDirection direction,
+        TPVChannelId channel_id,
+        H223ChannelParam* h223params)
+{
+    TPVStatusCode ret = EPVT_Success;
+    OSCL_ASSERT(h223params);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPVH223Multiplex::OpenChannel direction(%d), id(%d)\n", direction, channel_id));
+    PS_H223LogicalChannelParameters h223lcnParams = h223params->GetLcnParams();
+    H223LogicalChannel* channel = NULL;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPVH223Multiplex::OpenChannel -  AL index(%d)", h223lcnParams->adaptationLayerType.index));
+
+    /* Set the port property */
+    // TODO - Gkl
+    /*PVMFPortProperty aProps;
+    aProps.iFormatType = PVCodecTypeToPVMFFormatType(GetCodecType(h223params->GetDataType()));
+    aProps.iPortType = PORT_TYPE_FOR_DIRECTION(direction);*/
+    int* sdu_sizes = (direction == OUTGOING) ? iAlSduSize : iAlSduSizeR;
+    int32 sdu_size = 0;
+    switch (h223lcnParams->adaptationLayerType.index)
+    {
+        case 1:
+        case 2:
+            sdu_size = sdu_sizes[1];
+            break;
+        case 3:
+        case 4:
+            sdu_size = sdu_sizes[2];
+            break;
+        case 5:
+            sdu_size = sdu_sizes[3];
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::OpenChannel ERROR - Invalid AL Index.\n"));
+            return EPVT_Failed;
+    }
+    /* Overwrite audio sdu size, otherwise audio memory allocation can become prohibitive*/
+    if (!h223lcnParams->segmentableFlag)
+    {
+        sdu_size = MAX_NONSEGMENTABLE_SDU_SIZE;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::OpenChannel -  SDU Size=%d", sdu_size));
+
+    int bitrate = (h223params->GetBitrate() > 0) ? h223params->GetBitrate() : DEF_CHANNEL_BITRATE;
+    uint16 sample_interval = (uint16)h223params->GetSampleInterval();
+    uint32 min_sdu_size = (direction == INCOMING && h223lcnParams->segmentableFlag) ? sdu_size = MIN_SEGMENTABLE_SDU_SIZE : sdu_size;
+    uint32 num_media_data = (uint32)((double)(bitrate * DEF_OUTGOING_MEDIA_QUEUE_SIZE_MS) / double(1000.0 * 8.0 * min_sdu_size / 2.0) + .99);
+    if (h223lcnParams->segmentableFlag && sample_interval)
+    {
+        num_media_data += (uint32)((double)DEF_OUTGOING_MEDIA_QUEUE_SIZE_MS / (double)sample_interval + 1);
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::OpenChannel bitrate=%d, sample_interval=%d, num_media_data=%d", bitrate, sample_interval, num_media_data));
+
+#if defined(FORCE_NUM_OUTGOING_MEDIA_DATA)
+    if (direction == OUTGOING)
+    {
+        num_media_data = FORCE_NUM_OUTGOING_MEDIA_DATA;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::OpenChannel Forcing outgoing num_media_data=%d", num_media_data));
+    }
+#endif
+
+    OsclSharedPtr<AdaptationLayer> al;
+    if (EPVT_Success != GetAdaptationLayer(al, direction,
+                                           h223lcnParams, (uint16)sdu_size, num_media_data))
+    {
+        return EPVT_Failed;
+    }
+
+    if (direction == OUTGOING)
+    {
+        void* ptr = NULL;
+        if (channel_id)
+        {
+            ptr = OSCL_DEFAULT_MALLOC(sizeof(H223OutgoingChannel));
+            channel = new(ptr) H223OutgoingChannel((uint16)channel_id,
+                                                   h223lcnParams->segmentableFlag, al, h223params->GetDataType(), this,
+                                                   bitrate, sample_interval, num_media_data);
+        }
+        else
+        {
+            ptr = OSCL_DEFAULT_MALLOC(sizeof(H223OutgoingControlChannel));
+            channel =  new(ptr) H223OutgoingControlChannel(al,
+                    h223params->GetDataType(), this, bitrate, sample_interval,
+                    num_media_data);
+        }
+
+        OsclRefCounterSA<Oscl_TAlloc<H223OutgoingChannel, BasicAlloc> > *channelRefCounter =
+            new OsclRefCounterSA<Oscl_TAlloc<H223OutgoingChannel, BasicAlloc> >(ptr);
+        OsclSharedPtr<H223OutgoingChannel> channel_ptr((H223OutgoingChannel*)channel,
+                channelRefCounter);
+        iOutgoingChannels.push_back(channel_ptr);
+        UpdateMuxInterval();
+        if (channel_id)
+            channel_ptr->BufferMedia(iMultiplexingDelayMs);
+    }
+    else
+    {
+        void* ptr = OSCL_DEFAULT_MALLOC(sizeof(H223IncomingChannel));
+        channel = new(ptr)H223IncomingChannel(channel_id,
+                                              h223lcnParams->segmentableFlag, al,
+                                              h223params->GetDataType(), this,
+                                              bitrate, sample_interval, num_media_data);
+        OsclRefCounterSA<Oscl_TAlloc<H223IncomingChannel, BasicAlloc> > *channelRefCounter =
+            new OsclRefCounterSA<Oscl_TAlloc<H223IncomingChannel, BasicAlloc> >(ptr);
+        OsclSharedPtr<H223IncomingChannel> channel_ptr((H223IncomingChannel*)channel, channelRefCounter);
+        iIncomingChannels.push_back(channel_ptr);
+    }
+    channel->Init();
+    // TODO - Gkl
+    channel->SetClock(iClock);
+    //channel->Configure(aProps);
+
+    uint8* fsi = NULL;
+    unsigned fsi_len = 0;
+    fsi_len = h223params->GetFormatSpecificInfo(fsi);
+    if (fsi_len)
+    {
+        channel->SetFormatSpecificInfo(fsi, (uint16)fsi_len);
+    }
+    return ret;
+}
+
+
+TPVStatusCode
+CPVH223Multiplex::CloseChannel(TPVDirection direction, TPVChannelId channel_id)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux: Close channel direction(%d), id(%d)\n", direction, channel_id));
+    OsclSharedPtr<H223OutgoingChannel> outgoing_channel;
+    bool found_channel = false;
+
+    if (direction == OUTGOING)
+    {
+        Oscl_Vector<OsclSharedPtr<H223OutgoingChannel>, OsclMemAllocator>::iterator iter = iOutgoingChannels.begin();
+        while (iter != iOutgoingChannels.end())
+        {
+            outgoing_channel = *iter;
+            if (outgoing_channel->GetLogicalChannelNumber() == channel_id)
+            {
+                iOutgoingChannels.erase(iter);
+                found_channel = true;
+                break;
+            }
+            iter++;
+        }
+        if (!found_channel)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux: Close channel - Failed to lookup channel\n"));
+            return EPVT_Failed;
+        }
+
+        /* Release any SDU that the channel has passed to mux */
+        MuxSduData* sdu_data_ptr = FindMuxSduData(channel_id, outgoing_channel->IsSegmentable());
+        if (sdu_data_ptr)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::CloseChannel - Releasing pending MUX SDU\n"));
+            outgoing_channel->ReleasePacket(sdu_data_ptr->sdu);
+            RemoveMuxSduData(channel_id, outgoing_channel->IsSegmentable());
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::CloseChannel - Successful\n"));
+        return EPVT_Success;
+    }
+    if (iLcnEnd && (iLcnEnd->GetLogicalChannelNumber() == channel_id))
+    {
+        iLcnEnd = NULL;
+    }
+    OsclSharedPtr<H223IncomingChannel> incoming_channel;
+    Oscl_Vector<OsclSharedPtr<H223IncomingChannel>, OsclMemAllocator>::iterator iter = iIncomingChannels.begin();
+
+    while (iter != iIncomingChannels.end())
+    {
+        incoming_channel = *iter;
+        if (incoming_channel->GetLogicalChannelNumber() == channel_id)
+        {
+            iIncomingChannels.erase(iter);
+            found_channel = true;
+            break;
+        }
+        iter++;
+    }
+    if (!found_channel)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux: Close channel - Failed to lookup channel\n"));
+        return EPVT_Failed;
+    }
+    UpdateMuxInterval();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::CloseChannel - Successful\n"));
+    return EPVT_Success;
+}
+
+void CPVH223Multiplex::MakePduData(
+    OsclSharedPtr<PVMFMediaDataImpl>& outgoingPkt,
+    int32 max_size,
+    PS_MultiplexElement pElement,
+    MuxSduData& mux_sdu_data,
+    int* pm)
+{
+    *pm = false;
+
+    PVMFSharedMediaDataPtr& sdu_pkt = mux_sdu_data.sdu;
+    int bytesToMux = mux_sdu_data.size;
+    //OSCL_ASSERT(bytesToMux);
+
+    OsclRefCounterMemFrag frag;
+    uint8* pSduFrag = NULL;
+    int bytesInCurFragment = 0;
+
+    if (pElement->repeatCount.index == 0)   /* finite */
+    {
+        bytesToMux = OSCL_MIN(pElement->repeatCount.finite, bytesToMux);
+    }
+
+    /* dont exceed avail space on PDU */
+    bytesToMux = OSCL_MIN(max_size, bytesToMux);
+    if (bytesToMux < 0)
+    {
+        OSCL_ASSERT(0);
+    }
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"MakePduData - lcn(%d), bytesToMux(%d)", pElement->muxType.logicalChannelNumber, bytesToMux));
+    while (bytesToMux > 0)
+    {
+        int n = 0;
+        sdu_pkt->getMediaFragment(mux_sdu_data.cur_frag_num, frag);
+        bytesInCurFragment = frag.getMemFragSize() - mux_sdu_data.cur_pos;
+
+        pSduFrag = (uint8*)frag.getMemFragPtr() + mux_sdu_data.cur_pos;
+        n = min2(bytesToMux, bytesInCurFragment);
+
+        /* create a snapshot of size n */
+        frag.getMemFrag().ptr = pSduFrag;
+        frag.getMemFrag().len = n;
+        /* add it to outgoing pkt */
+        outgoingPkt->appendMediaFragment(frag);
+        bytesToMux -= n;
+        mux_sdu_data.cur_pos = (uint16)(mux_sdu_data.cur_pos + n);
+        bytesInCurFragment -= n;
+        mux_sdu_data.size = (uint16)(mux_sdu_data.size - n);
+        // check for end of fragment
+        if (bytesInCurFragment == 0)
+        {
+            mux_sdu_data.cur_frag_num++;
+            mux_sdu_data.cur_pos = 0;
+        }
+    }
+    /* check for end of packet */
+    if (mux_sdu_data.size == 0 && mux_sdu_data.lcn->IsSegmentable())
+    {
+        *pm = true;
+    }
+    return;
+}
+
+int CPVH223Multiplex::MuxToALDispatch(uint8* pdu, int pdu_size, int fClosing, int muxCode)
+{
+    int ret = 0;
+
+    if (fClosing)
+    {
+        if (iLcnEnd)
+        {
+            H223IncomingChannel* lcn = iLcnEnd;
+            if (PVMFSuccess != lcn->AlDispatch())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::MuxToALDispatch Memory allocation failure on AlDispatch, channel id=%d", iLcnEnd->GetLogicalChannelNumber()));
+                lcn->ResetAlPdu();
+            }
+            iLcnEnd = NULL;
+        }
+    }
+
+    PS_MultiplexEntryDescriptor mux_entry = iMuxTblMgr->GetIncomingDescriptor((uint8)muxCode);
+
+    if (mux_entry)
+    {
+        if (pdu_size)
+        {
+            ret = BreakPduData(pdu, pdu_size, mux_entry->elementList, mux_entry->size_of_elementList);
+        }
+    }
+
+    return ret;
+}
+
+TPVStatusCode CPVH223Multiplex::AlPduData(H223IncomingChannel* aChannel,
+        uint8*& pdu,
+        PS_MultiplexElement pElement,
+        int n)
+{
+    OSCL_UNUSED_ARG(pElement);
+    if (PVMFSuccess != aChannel->AlPduData(pdu, (uint16)n))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::BreakPduData Memory allocation failure on AlPduData, channel id=%d",
+                         pElement->muxType.logicalChannelNumber));
+        aChannel->ResetAlPdu();
+        return PVMFFailure;
+    }
+    return PVMFSuccess;
+}
+
+TPVStatusCode CPVH223Multiplex::Dispatch(H223IncomingChannel* aChannel,
+        PS_MultiplexElement pElement)
+{
+    OSCL_UNUSED_ARG(pElement);
+    if (PVMFSuccess != aChannel->AlDispatch())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::BreakPduData Memory allocation failure on AlDispatch, channel id=%d",
+                         pElement->muxType.logicalChannelNumber));
+        aChannel->ResetAlPdu();
+        return PVMFErrNoMemory;
+    }
+    return PVMFSuccess;
+}
+
+int CPVH223Multiplex::BreakPduData(uint8*& pdu, int pdu_size, PS_MultiplexElement pElement, int ListSize)
+{
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"CPVH223Multiplex::BreakPduData pdu(%x), pdu_size(%d), pElement(%x), ListSize(%d),iObserver(%x)", pdu,pdu_size,pElement,ListSize,iObserver));
+
+    int cnt = 0, cnt2 = 0, LoopCnt = 0, n = 0;
+    int demuxed_size = 0;
+    H223IncomingChannel* channel = NULL;
+
+    for (cnt = ListSize ; cnt != 0 ; cnt --)
+    {
+        /* sub-element list search */
+        if (pElement->muxType.index != 0)
+        {
+            LoopCnt = (pElement->repeatCount.index) ?
+                      pdu_size /* untill closing flag */ : pElement->repeatCount.finite;
+
+            for (cnt2 = 0 ; cnt2 < LoopCnt ; cnt2 ++)
+            {
+                demuxed_size += BreakPduData(pdu, pdu_size,
+                                             pElement->muxType.subElementList,
+                                             pElement->muxType.size);
+                pdu += demuxed_size;
+                if (demuxed_size >= pdu_size)
+                    return demuxed_size; /* Data End */
+            }
+        }
+        /* Element Search */
+        else
+        {
+            for (cnt2 = 0 ; cnt2 < (int)iIncomingChannels.size(); cnt2++)
+            {
+                if (iIncomingChannels[cnt2].GetRep() == NULL)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::BreakPduData channel(%d) - Does not exist\n", pElement->muxType.logicalChannelNumber));
+                }
+                if (iIncomingChannels[cnt2].GetRep() &&
+                        (pElement->muxType.logicalChannelNumber ==
+                         (0xFFFF&iIncomingChannels[cnt2]->GetLogicalChannelNumber())))
+                {
+                    channel = iIncomingChannels[cnt2];
+                    if (pElement->repeatCount.index == 0)
+                    {
+                        n = min2(pdu_size, pElement->repeatCount.finite);
+                    }
+                    else
+                    {
+                        n = pdu_size;
+                    }
+                    pdu_size -= n;
+                    demuxed_size += n;
+
+
+                    AlPduData(channel, pdu, pElement, n);
+
+                    pdu += n;
+
+                    /* If enough pdus have been received, indicate to observer */
+                    if (channel->GetNumSdusIn() == H223_LCN_DATA_DETECT_THRESHOLD)
+                    {
+                        iObserver->LcnDataDetected(channel->GetLogicalChannelNumber());
+                    }
+
+                    if (!channel->IsSegmentable())
+                    {
+                        Dispatch(channel, pElement);
+                    }
+                    else
+                    {
+                        if (pdu_size == 0)
+                        {
+                            iLcnEnd = channel;
+                            return demuxed_size;
+                        }
+                    }
+                    if (pdu_size == 0)
+                        return demuxed_size;
+                    break;
+                }
+            }
+        }
+        pElement++;
+    }
+    return false;
+}
+
+
+void CPVH223Multiplex::ResetStats()
+{
+    for (unsigned out_lcn = 0; out_lcn < iOutgoingChannels.size(); out_lcn++)
+    {
+        iOutgoingChannels[out_lcn]->ResetStats();
+    }
+    for (unsigned in_lcn = 0; in_lcn < iIncomingChannels.size(); in_lcn++)
+    {
+        iIncomingChannels[in_lcn]->ResetStats();
+    }
+
+    iMuxTblMgr->ResetStats();
+    if (iLowerLayer)
+    {
+        iLowerLayer->ResetStats();
+    }
+}
+
+void CPVH223Multiplex::LogStats(TPVDirection dir)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223 Multiplex Statistics:\n"));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Logical Channel Statistics:\n"));
+    if (dir & OUTGOING)
+    {
+        for (unsigned n = 0; n < iOutgoingChannels.size(); n++)
+        {
+            iOutgoingChannels[n]->LogStats();
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Outgoing Multiplex Entry Statistics:\n"));
+        iMuxTblMgr->LogStats(OUTGOING);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Outgoing Multiplex PDU Statistics:\n"));
+        iLowerLayer->LogStats(OUTGOING);
+    }
+
+    if (dir & INCOMING)
+    {
+        for (unsigned n = 0; n < iIncomingChannels.size(); n++)
+        {
+            iIncomingChannels[n]->LogStats();
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Incoming Multiplex Entry Statistics:\n"));
+        iMuxTblMgr->LogStats(INCOMING);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Incoming Multiplex PDU Statistics:\n"));
+        iLowerLayer->LogStats(INCOMING);
+    }
+}
+
+TPVStatusCode CPVH223Multiplex::StopChannel(TPVDirection direction, TPVChannelId channel_id)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::StopChannel direction(%d), channel id(%d)\n", direction, channel_id));
+    if (iLcnEnd && (iLcnEnd->GetLogicalChannelNumber() == channel_id))
+    {
+        iLcnEnd = NULL;
+    }
+    return FlushChannel(direction, channel_id);
+}
+
+TPVStatusCode CPVH223Multiplex::FlushChannel(TPVDirection direction, TPVChannelId channel_id)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::FlushChannel direction(%d), channel id(%d)\n", direction, channel_id));
+
+    if (direction & OUTGOING)
+    {
+        OsclSharedPtr<H223OutgoingChannel> channel;
+        PVMFStatus status = GetOutgoingChannel(channel_id, channel);
+
+        if (status == PVMFSuccess)
+        {
+            channel->Flush();
+            /* flush any partially sent sdu */
+            RemoveMuxSduData(channel_id, channel->IsSegmentable());
+            return EPVT_Success;
+        }
+        return EPVT_ErrorInvalidParameter;
+    }
+    else if (direction & INCOMING)
+    {
+        OsclSharedPtr<H223IncomingChannel> channel;
+        PVMFStatus status = GetIncomingChannel(channel_id, channel);
+        if (status == PVMFSuccess)
+        {
+            channel->Flush();
+        }
+    }
+    return EPVT_Success;
+}
+
+void CPVH223Multiplex::LowerLayerError(TPVDirection direction, PVMFStatus error)
+{
+    OSCL_UNUSED_ARG(direction);
+    OSCL_UNUSED_ARG(error);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::LowerLayerError error(%d)\n", error));
+    iObserver->MuxErrorOccurred(direction, PV_MUX_COMPONENT_MUX, error);
+}
+
+inline int32 CPVH223Multiplex::GetTimestamp()
+{
+    return iLowerLayer->GetTimestamp();
+}
+
+void CPVH223Multiplex::LogicalChannelError(TPVDirection direction, TPVChannelId id, PVMFStatus error)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::LogicalChannelError  error(%d), id(%d)\n", error, id));
+    iObserver->MuxErrorOccurred(direction, PV_MUX_COMPONENT_LOGICAL_CHANNEL, error, (uint8*)&id, sizeof(id));
+}
+
+void CPVH223Multiplex::SkewDetected(TPVChannelId lcn1, TPVChannelId lcn2, uint32 skew)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SkewDetected lcn1=%d, lcn2=%d, skew=%d", lcn1, lcn2, skew));
+    iObserver->SkewDetected(lcn1, lcn2, skew);
+}
+
+void CPVH223Multiplex::ReceivedFormatSpecificInfo(TPVChannelId lcn, uint8* fsi, uint32 fsi_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::ReceivedFormatSpecificInfo lcn=%d, len=%d", lcn, fsi_len));
+    iObserver->ReceivedFormatSpecificInfo(lcn, fsi, fsi_len);
+}
+
+void CPVH223Multiplex::SetMultiplexLevel(TPVH223Level muxLevel)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetMultiplexLevel  level(%d)\n", muxLevel));
+    if (iLowerLayer == NULL)
+    {
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+    iLowerLayer->SetLevel(muxLevel);
+}
+
+unsigned CPVH223Multiplex::GetNumChannels(TPVDirection direction)
+{
+    if (direction == OUTGOING)
+        return iOutgoingChannels.size() - 1;
+    return iIncomingChannels.size() - 1;
+}
+
+MuxSduData* CPVH223Multiplex::FindMuxSduData(TPVChannelId lcn,
+        bool segmentable,
+        uint32* p_index)
+{
+    MuxSduDataList& list = GET_SDU_DATA_LIST(segmentable);
+    for (unsigned index = 0; index < list.size();index++)
+    {
+        if (list[index].lcn->GetLogicalChannelNumber() == lcn)
+        {
+            if (p_index)
+                *p_index = index;
+            return &list[index];
+        }
+    }
+    return NULL;
+}
+
+void CPVH223Multiplex::AppendMuxSduData(MuxSduData& data)
+{
+    if (data.lcn->GetLogicalChannelNumber() == 0)
+    {
+        iControlSduDataList.push_back(data);
+        return;
+    }
+    MuxSduDataList& list = GET_SDU_DATA_LIST(data.lcn->IsSegmentable());
+    list.push_back(data);
+}
+
+void CPVH223Multiplex::SetMuxSduData(MuxSduData& data)
+{
+    MuxSduData* mux_sdu_data_ptr = FindMuxSduData(data.lcn->GetLogicalChannelNumber(),
+                                   data.lcn->IsSegmentable());
+    if (mux_sdu_data_ptr)
+    {
+        *mux_sdu_data_ptr = data;
+    }
+}
+
+void CPVH223Multiplex::RemoveMuxSduData(TPVChannelId lcn, bool segmentable)
+{
+    if (lcn == 0)
+    {
+        iControlSduDataList.clear();
+        return;
+    }
+    MuxSduDataList& list = GET_SDU_DATA_LIST(segmentable);
+    uint32 index = 0;
+    while (list.size())
+    {
+        if (FindMuxSduData(lcn, segmentable, &index))
+        {
+            list.erase(list.begin() + index);
+        }
+    }
+}
+
+void CPVH223Multiplex::ReleaseMuxSdu(MuxSduData& mux_sdu_data,
+                                     MuxSduDataList& list,
+                                     unsigned index)
+{
+    OSCL_UNUSED_ARG(index);
+    OSCL_UNUSED_ARG(list);
+    mux_sdu_data.lcn->ReleasePacket(mux_sdu_data.sdu);
+    if (mux_sdu_data.lcn->GetNextPacket(mux_sdu_data.sdu, PVMFSuccess))
+    {
+        mux_sdu_data.size = (uint16)mux_sdu_data.sdu->getFilledSize();
+        mux_sdu_data.cur_frag_num = 0;
+        mux_sdu_data.cur_pos = 0;
+    }
+    else
+    {
+        RemoveMuxSduData(mux_sdu_data.lcn->GetLogicalChannelNumber(), mux_sdu_data.lcn->IsSegmentable());
+    }
+}
+
+unsigned CPVH223Multiplex::UpdateSduDataLists()
+{
+    unsigned num_lcns = 0;
+    for (unsigned lcnindex = 0; lcnindex < iOutgoingChannels.size(); lcnindex++)
+    {
+        MuxSduData* mux_sdu_data_ptr = NULL;
+        if (lcnindex == 0)
+        {
+            if (iControlSduDataList.size())
+                mux_sdu_data_ptr = &iControlSduDataList[0];
+        }
+        else
+        {
+            mux_sdu_data_ptr = FindMuxSduData(iOutgoingChannels[lcnindex]->GetLogicalChannelNumber(),
+                                              iOutgoingChannels[lcnindex]->IsSegmentable());
+        }
+        if (mux_sdu_data_ptr)
+        {
+            num_lcns++;
+        }
+        else
+        {
+            // get the next packet and update the sdu size
+            PVMFSharedMediaDataPtr sdu;
+            if (iOutgoingChannels[lcnindex]->GetNextPacket(sdu, PVMFSuccess))
+            {
+                MuxSduData mux_sdu_data;
+                mux_sdu_data.lcn = iOutgoingChannels[lcnindex];
+                mux_sdu_data.sdu = sdu;
+                mux_sdu_data.size = (uint16)sdu->getFilledSize();
+                mux_sdu_data.cur_frag_num = 0;
+                mux_sdu_data.cur_pos = 0;
+                AppendMuxSduData(mux_sdu_data);
+                num_lcns++;
+            }
+        }
+    }
+    return num_lcns;
+}
+
+OsclSharedPtr<PVMFMediaDataImpl> CPVH223Multiplex::InitPduPacket()
+{
+    OsclSharedPtr<PVMFMediaDataImpl> ret = iMuxPduPacketAlloc->allocate(MAX_FRAGMENTS_PER_H223_PDU_PACKET);
+    if (!ret)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::InitPduPacket Unable to allocate packet."));
+        return ret;
+    }
+    OsclRefCounterMemFrag hdr;
+    iLowerLayer->GetHdrFragment(hdr);
+    if (hdr.getMemFragSize())
+    {
+        ret->appendMediaFragment(hdr);
+    }
+    else
+    {
+        ret.Unbind();
+    }
+    return ret;
+}
+
+PVMFStatus CPVH223Multiplex::CompletePduPacket(OsclSharedPtr<PVMFMediaDataImpl>& packet, int mt, int pm)
+{
+    return iLowerLayer->CompletePacket(packet, mt, pm);
+}
+
+void CPVH223Multiplex::UpdateMuxInterval(uint16 aInterval)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::UpdateMuxInterval"));
+    iMinSampleInterval = aInterval ? aInterval : (uint16)iLowerLayer->GetMinTimerRes();
+    unsigned lcnindex;
+    for (lcnindex = 0; lcnindex < iOutgoingChannels.size(); lcnindex++)
+    {
+        uint16 sample_interval = (uint16)iOutgoingChannels[lcnindex]->GetSampleInterval();
+        if (sample_interval && (sample_interval < iMinSampleInterval))
+            iMinSampleInterval = sample_interval;
+    }
+
+    iNumMuxIntervalsPerTimerInterval = (uint16)(iLowerLayer->GetMinTimerRes() / iMinSampleInterval);
+    iNumBytesPerMinSampleInterval = (uint16)((float)(iMinSampleInterval * iBitrate) / 8000.0 + .5);
+    iLowerLayer->SetMaxOutgoingPduSize(iNumBytesPerMinSampleInterval);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::UpdateMuxInterval =%d", iMinSampleInterval));
+}
+
+void CPVH223Multiplex::ClearSduDataLists()
+{
+    iControlSduDataList.clear();
+    iNonSegmentableSduDataList.clear();
+    iSegmentableSduDataList.clear();
+}
+
+uint16 CPVH223Multiplex::MuxLcnData(MuxSduDataList& list,
+                                    MuxPduPacketList& packets,
+                                    uint16 max_size)
+{
+    if (list.size() == 0)
+        return 0;
+
+    int32 pdu_size_left = max_size;
+    PS_MultiplexEntryDescriptor mux_entry = NULL;
+    for (unsigned n = 0;n < list.size();n++)
+    {
+        // get descriptor for this logical channel
+        mux_entry = iMuxTblMgr->GetOutgoingDescriptor(list[n].lcn,
+                    list[n].sdu);
+        if (mux_entry == NULL)
+        {
+            continue;
+        }
+        uint32 packet_size = DispatchPduPacket(packets, list[n], mux_entry, pdu_size_left);
+        if (packet_size == 0)
+            break;
+
+        pdu_size_left -= packet_size;
+        if (pdu_size_left < 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::MuxSduData Size exceeded, pdu_size_left=%d", pdu_size_left));
+        }
+        if (list[n].size == 0)
+        {
+            ReleaseMuxSdu(list[n], list, n);
+        }
+        if (pdu_size_left <= (int)iLowerLayer->GetHeaderSize())
+            break;
+    }
+    return (uint16)(max_size - pdu_size_left);
+}
+
+void CPVH223Multiplex::SetMultiplexingDelayMs(uint16 aDelay)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetMultiplexingDelayMs,aDelay=%d", aDelay));
+    iMultiplexingDelayMs = aDelay;
+}
+
+void CPVH223Multiplex::SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+        uint32 aOutBufferingMs)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetLogicalChannelBufferingMs,aInBufferingMs=%d,aOutBufferingMs=%d", aInBufferingMs, aOutBufferingMs));
+    iInLogicalChannelBufferingMs = aInBufferingMs;
+    iOutLogicalChannelBufferingMs = aOutBufferingMs;
+}
+
+void CPVH223Multiplex::SetBitrate(uint32 aBitrate)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetLogicalChannelBufferingMs,aBitrate=%d", aBitrate));
+    iBitrate = aBitrate;
+}
+
+void CPVH223Multiplex::SetStuffingMsgHeader()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetStuffingMsgHeader() mode=%d", iFmStuffingMode));
+    const int32 MAX_STUFFING_SEQUENCE_SIZE = 16;
+    uint stuffing_size = H223GetMuxStuffingSz(iLowerLayer->GetLevel());
+    if (!stuffing_size)
+        return;
+
+    uint8 buf[MAX_STUFFING_SEQUENCE_SIZE];
+    stuffing_size = H223MuxStuffing(iLowerLayer->GetLevel(), buf, stuffing_size);
+    iLowerLayer->SendStuffingMsgHeader(buf, (uint16)stuffing_size);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetStuffingMsgHeader()-done"));
+}
+
+void CPVH223Multiplex::SetInterleavingMultiplexFlags(uint16 size, uint8* flags)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "CPVH223Multiplex::SetInterleavingMultiplexFlags() size=%d, flags=%x", size, flags));
+
+    if (iInterleavingMultiplexFlags && iInterleavingPacket)
+    {
+        iInterleavingPacket->clearMediaFragments();
+        iInterleavingPacket.Unbind();
+        OSCL_DEFAULT_FREE(iInterleavingMultiplexFlags);
+        iInterleavingMultiplexFlags = NULL;
+    }
+    iInterleavingMultiplexFlagsSize = size;
+    iInterleavingMultiplexFlags = (uint8*)OSCL_DEFAULT_MALLOC(size);
+    oscl_memcpy(iInterleavingMultiplexFlags, flags, size);
+    iInterleavingPacket = iMuxPduPacketAlloc->allocate(1);
+    if (!iInterleavingPacket)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "CPVH223Multiplex::SetInterleavingMultiplexFlags Unable to allocate packet."));
+    }
+}
+
+void CPVH223Multiplex::EnableStuffing(bool enable)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPVH223Multiplex::EnableStuffing enable=%d\n", enable));
+    iEnableStuffing = enable;
+}
+
+void CPVH223Multiplex::EnableStuffOnlyFirstSend(bool enable)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "CPVH223Multiplex::EnableStuffOnlyFirstSend enable=%d\n", enable));
+    iStuffOnlyFirstSend = enable;
+}
+
+void CPVH223Multiplex::SetMioLatency(int32 aLatency, bool aAudio)
+{
+    H223IncomingChannel* channel = NULL;
+    if (iIncomingChannels.size() != 0)
+    {
+        for (int32 ii = 0;ii < (int32)iIncomingChannels.size();ii++)
+        {
+            channel = iIncomingChannels[ii];
+            if (aAudio)
+            {
+                channel->SetAudioLatency(aLatency);
+            }
+            else
+            {
+                channel->SetVideoLatency(aLatency);
+            }
+        }
+    }
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/h223api.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/h223api.cpp
new file mode 100644
index 0000000..8c449c5
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/h223api.cpp
@@ -0,0 +1,159 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "h223_api.h"
+#include "h223.h"
+const uint gMuxStuffingSz[] = {1, 2, 4, 5, 6, 0};
+const uint gMuxFlagSz[] = {1, 2, 4, 2, 2, 0};
+const uint gMaxStuffingSz[] = {3, 3, 5, 5, 6, 0};
+const uint8 gNumOnes[] = {0, 1, 1, 2, 1, 2, 2, 3, // 0
+                          1, 2, 2, 3, 2, 3, 3, 4, // 8
+                          1, 2, 2, 3, 2, 3, 3, 4, // 16
+                          2, 3, 3, 4, 3, 4, 4, 5, // 24
+                          1, 2, 2, 3, 2, 3, 3, 4, // 32
+                          2, 3, 3, 4, 3, 4, 4, 5, // 40
+                          2, 3, 3, 4, 3, 4, 4, 5, // 48
+                          3, 4, 4, 5, 4, 5, 5, 6, // 56
+                          1, 2, 2, 3, 2, 3, 3, 4, // 64
+                          2, 3, 3, 4, 3, 4, 4, 5, // 72
+                          2, 3, 3, 4, 3, 4, 4, 5, // 80
+                          3, 4, 4, 5, 4, 5, 5, 6, // 88
+                          2, 3, 3, 4, 3, 4, 4, 5, // 96
+                          3, 4, 4, 5, 4, 5, 5, 6, // 104
+                          3, 4, 4, 5, 4, 5, 5, 6, // 112
+                          4, 5, 5, 6, 5, 6, 6, 7, // 120
+                          1, 2, 2, 3, 2, 3, 3, 4, // 128
+                          2, 3, 3, 4, 3, 4, 4, 5, // 136
+                          2, 3, 3, 4, 3, 4, 4, 5, // 144
+                          3, 4, 4, 5, 4, 5, 5, 6, // 152
+                          2, 3, 3, 4, 3, 4, 4, 5, // 160
+                          3, 4, 4, 5, 4, 5, 5, 6, // 168
+                          3, 4, 4, 5, 4, 5, 5, 6, // 176
+                          4, 5, 5, 6, 5, 6, 6, 7, // 184
+                          2, 3, 3, 4, 3, 4, 4, 5, // 192
+                          3, 4, 4, 5, 4, 5, 5, 6, // 200
+                          3, 4, 4, 5, 4, 5, 5, 6, // 208
+                          4, 5, 5, 6, 5, 6, 6, 7, // 216
+                          3, 4, 4, 5, 4, 5, 5, 6, // 224
+                          4, 5, 5, 6, 5, 6, 6, 7, // 232
+                          4, 5, 5, 6, 5, 6, 6, 7, // 240
+                          5, 6, 6, 7, 6, 7, 7, 8
+                         }; // 248
+
+/* Delete this */
+OSCL_EXPORT_REF CPVH223Multiplex* AllocateH223Mux(TPVLoopbackMode aLoopbackMode)
+{
+    return OSCL_NEW(CPVH223Multiplex, (aLoopbackMode));
+}
+
+OSCL_EXPORT_REF void DeallocateH223Mux(CPVH223Multiplex* h223mux)
+{
+    OSCL_DELETE(h223mux);
+}
+
+uint H223GetMuxStuffingSz(TPVH223Level flat_level)
+{
+    return gMuxStuffingSz[flat_level];
+}
+
+uint H223GetMuxFlagSz(TPVH223Level flat_level)
+{
+    return gMuxFlagSz[flat_level];
+}
+
+uint H223GetMaxStuffingSz(TPVH223Level flat_level)
+{
+    return gMaxStuffingSz[flat_level];
+}
+
+uint H223MuxStuffing(TPVH223Level level, uint8* pPdu, uint bufSz)
+{
+    int32 stuffing_size = (int32)H223GetMuxStuffingSz(level);
+    if (stuffing_size == 0)
+        return 0;
+
+    int32 size_left = bufSz;
+    while (size_left >= stuffing_size)
+    {
+        switch (level)
+        {
+            case H223_LEVEL0: // level 0
+                *(pPdu) = 0x7e;
+                break;
+            case H223_LEVEL1: // level 1
+            case H223_LEVEL1_DF: // H223DoubleFlag == TRUE
+                *(pPdu) = 0xe1;
+                *(pPdu + 1) = 0x4d;
+                if (level == H223_LEVEL1)
+                    break;
+                *(pPdu + 2) = 0xe1;
+                *(pPdu + 3) = 0x4d;
+                break;
+            case H223_LEVEL2: // level 2
+            case H223_LEVEL2_OH: // H223OptionalHeader==1
+                *(pPdu) = 0xe1;
+                *(pPdu + 1) = 0x4d;
+                *(pPdu + 2) = 0;
+                *(pPdu + 3) = 0;
+                *(pPdu + 4) = 0;
+                if (level == H223_LEVEL2)
+                    break;
+                *(pPdu + 5) = 0;
+                break;
+            default:
+                return 0;
+        }
+        pPdu += stuffing_size;
+        size_left -= stuffing_size;
+    }
+    return (bufSz -size_left);
+}
+
+bool H223CheckSync(TPVH223Level level, uint8* buf, uint bufSz, uint tolerance)
+{
+    if (bufSz < H223GetMuxFlagSz(level))
+        return false;
+    uint mismatch_cnt = 0;
+    switch (level)
+    {
+        case H223_LEVEL0:
+            mismatch_cnt = gNumOnes[(buf[0] ^ 0x7E)];
+            break;
+        case H223_LEVEL1:
+        case H223_LEVEL1_DF:
+            mismatch_cnt = (uint16)(gNumOnes[(buf[0] ^ 0xE1)]  + gNumOnes[(buf[1] ^ 0x4D)]);
+            if (level == H223_LEVEL1)
+                break;
+            mismatch_cnt += (uint16)(gNumOnes[(buf[2] ^ 0xE1)]  + gNumOnes[(buf[3] ^ 0x4D)]);
+            break;
+        case H223_LEVEL2_OH:
+            if (bufSz >= 6)
+                mismatch_cnt = (uint16)(gNumOnes[buf[5]]);
+        case H223_LEVEL2:
+            mismatch_cnt += (uint16)(gNumOnes[(buf[0] ^ 0xE1)]  + gNumOnes[(buf[1] ^ 0x4D)]);
+            if (bufSz >= 5)
+            {
+                mismatch_cnt += (uint16)(gNumOnes[buf[2]]);
+                mismatch_cnt += (uint16)(gNumOnes[buf[3]]);
+                mismatch_cnt += (uint16)(gNumOnes[buf[4]]);
+            }
+            break;
+        default:
+            return false;
+    }
+    return (mismatch_cnt <= tolerance);
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/h223types.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/h223types.cpp
new file mode 100644
index 0000000..6895b7c
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/h223types.cpp
@@ -0,0 +1,828 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "h223types.h"
+#include "h324utils.h"
+
+H223ChannelParam::H223ChannelParam(TPVChannelId id, PS_H223LogicalChannelParameters lcp, PS_DataType dt)
+        : pH223Lcp(NULL), pDataType(NULL)
+{
+    lcn = id;
+    if (lcp)
+    {
+        pH223Lcp = Copy_H223LogicalChannelParameters(lcp);
+    }
+    if (dt)
+    {
+        pDataType = Copy_DataType(dt);
+    }
+    bitrate = GetMaxBitrate(pDataType);
+    sample_interval = 0;
+    unsigned fr = GetMaxFrameRate(pDataType);
+    if (fr)
+        sample_interval = (unsigned)((double)1000 / (double)fr);
+}
+
+H223ChannelParam::H223ChannelParam(TPVChannelId id,
+                                   PS_H223LogicalChannelParameters lcp,
+                                   unsigned aBitrate,
+                                   unsigned aSampleInterval)
+        : pH223Lcp(NULL), pDataType(NULL)
+{
+    lcn = id;
+    if (lcp)
+    {
+        pH223Lcp = Copy_H223LogicalChannelParameters(lcp);
+    }
+    bitrate = aBitrate;
+    sample_interval = aSampleInterval;
+}
+
+H223ChannelParam::H223ChannelParam(const H223ChannelParam & that) : CPVChannelParam(),
+        pH223Lcp(NULL), pDataType(NULL)
+{
+    lcn = that.lcn;
+    if (that.pH223Lcp)
+    {
+        pH223Lcp = Copy_H223LogicalChannelParameters(that.pH223Lcp);
+    }
+    if (that.pDataType)
+    {
+        pDataType = Copy_DataType(that.pDataType);
+    }
+    bitrate = that.bitrate;
+    sample_interval = that.sample_interval;
+}
+
+H223ChannelParam::~H223ChannelParam()
+{
+    if (pH223Lcp)
+    {
+        Delete_H223LogicalChannelParameters(pH223Lcp);
+        OSCL_DEFAULT_FREE(pH223Lcp);
+        pH223Lcp = NULL;
+    }
+    if (pDataType)
+    {
+        Delete_DataType(pDataType);
+        OSCL_DEFAULT_FREE(pDataType);
+        pDataType = NULL;
+    }
+}
+
+H223ChannelParam& H223ChannelParam::operator =(const H223ChannelParam & that)
+{
+    Clear();
+    lcn = that.lcn;
+    SetLcnParams(that.pH223Lcp);
+    SetDataType(that.pDataType);
+    bitrate = that.bitrate;
+    sample_interval = that.sample_interval;
+    return *this;
+}
+
+void H223ChannelParam::SetLcnParams(PS_H223LogicalChannelParameters lcp)
+{
+    if (pH223Lcp)
+    {
+        Delete_H223LogicalChannelParameters(pH223Lcp);
+        OSCL_DEFAULT_FREE(pH223Lcp);
+        pH223Lcp = NULL;
+    }
+    if (lcp)
+    {
+        pH223Lcp = Copy_H223LogicalChannelParameters(lcp);
+    }
+}
+
+void H223ChannelParam::SetDataType(PS_DataType dt)
+{
+    if (pDataType)
+    {
+        Delete_DataType(pDataType);
+        OSCL_DEFAULT_FREE(pDataType);
+        pDataType = NULL;
+    }
+    if (dt)
+    {
+        pDataType = Copy_DataType(dt);
+    }
+}
+
+void H223ChannelParam::Clear()
+{
+    lcn = CHANNEL_ID_UNKNOWN;
+    SetLcnParams(NULL);
+    SetDataType(NULL);
+}
+
+PS_H223LogicalChannelParameters H223ChannelParam::GetLcnParams()
+{
+    return pH223Lcp;
+}
+
+PS_DataType H223ChannelParam::GetDataType()
+{
+    return pDataType;
+}
+
+void H223ChannelParam::SetChannelId(TPVChannelId id)
+{
+    lcn = id;
+}
+
+TPVChannelId H223ChannelParam::GetChannelId()
+{
+    return lcn;
+}
+unsigned H223ChannelParam::GetBitrate()
+{
+    return bitrate;
+}
+
+unsigned H223ChannelParam::GetSampleInterval()
+{
+    return sample_interval;
+}
+
+unsigned H223ChannelParam::GetFormatSpecificInfo(uint8*& fsi)
+{
+    return ::GetFormatSpecificInfo(GetDataType(), fsi);
+}
+
+OlcParam* OlcParam::NewL(TPVDirection dir,
+                         TPVChannelId id,
+                         H223ChannelParam* forward_params,
+                         H223ChannelParam* reverse_params)
+{
+    OlcParam* ret = OSCL_NEW(OlcParam, ());
+    ret->Set(dir, id, forward_params, reverse_params);
+    return ret;
+}
+
+OlcParam::OlcParam()
+        : iForwardParams(NULL),
+        iReverseParams(NULL)
+{
+    iState = OLC_IDLE;
+    iDir = OUTGOING;
+    iId = CHANNEL_ID_UNKNOWN;
+    iMtState = MT_IDLE;
+    iMtSn = H223_DEFAULT_MT_SN;
+    iMtNum = H223_DEFAULT_MT_NUM;
+    iReplacementForChannelId = CHANNEL_ID_UNKNOWN;
+    iMyType = 0;
+}
+
+void OlcParam::Set(TPVDirection dir, TPVChannelId id, H223ChannelParam* forward_params, H223ChannelParam* reverse_params)
+{
+    iDir = dir;
+    iId = id;
+    if (iForwardParams)
+    {
+        OSCL_DELETE(iForwardParams);
+        iForwardParams = NULL;
+    }
+    if (iReverseParams)
+    {
+        OSCL_DELETE(iReverseParams);
+        iReverseParams = NULL;
+    }
+
+    if (forward_params)
+    {
+        iForwardParams = OSCL_NEW(H223ChannelParam, (*forward_params));
+    }
+    if (reverse_params)
+    {
+        iReverseParams = OSCL_NEW(H223ChannelParam, (*reverse_params));
+    }
+}
+
+void OlcParam::InitOlc(TPVDirection dir,
+                       TPVChannelId id,
+                       PS_DataType dt,
+                       PS_H223LogicalChannelParameters lcp,
+                       TPVChannelId idRvs,
+                       PS_DataType dtRvs,
+                       PS_H223LogicalChannelParameters lcpRvs)
+{
+    H223ChannelParam* forward_params = new H223ChannelParam(id, lcp, dt);
+    H223ChannelParam* reverse_params = NULL;
+    if (lcpRvs)
+    {
+        reverse_params = new H223ChannelParam(idRvs, lcpRvs, dtRvs);
+    }
+    // insert into the list of olcs
+    Set(dir, id, forward_params, reverse_params);
+    SetState(OLC_PENDING);
+    delete forward_params;
+    if (reverse_params)
+        delete reverse_params;
+}
+
+OlcParam::~OlcParam()
+{
+    if (iForwardParams)
+    {
+        OSCL_DELETE(iForwardParams);
+        iForwardParams = NULL;
+    }
+    if (iReverseParams)
+    {
+        OSCL_DELETE(iReverseParams);
+        iReverseParams = NULL;
+    }
+}
+
+TPVDirection OlcParam::GetDirection()
+{
+    return iDir;
+}
+
+TPVChannelId OlcParam::GetChannelId()
+{
+    return iId;
+}
+
+void OlcParam::SetState(OlcState state)
+{
+    iState = state;
+}
+
+OlcState OlcParam::GetState()
+{
+    return iState;
+}
+
+TPVDirectionality OlcParam::GetDirectionality()
+{
+    return iReverseParams ? EPVT_BI_DIRECTIONAL : EPVT_UNI_DIRECTIONAL;
+}
+
+H223ChannelParam* OlcParam::GetForwardParams()
+{
+    return iForwardParams;
+}
+
+H223ChannelParam* OlcParam::GetReverseParams()
+{
+    return iReverseParams;
+}
+
+void OlcParam::SetMtState(MtState state)
+{
+    iMtState = state;
+}
+
+MtState OlcParam::GetMtState()
+{
+    return iMtState;
+}
+
+void OlcParam::SetMtSn(int32 sn)
+{
+    iMtSn = sn;
+}
+
+int32 OlcParam::GetMtSn()const
+{
+    return iMtSn;
+}
+
+void OlcParam::SetMtNum(uint32 num)
+{
+    iMtNum = num;
+}
+
+uint32 OlcParam::GetMtNum()const
+{
+    return iMtNum;
+}
+
+void OlcParam::SetReplacementFor(TPVChannelId id)
+{
+    iReplacementForChannelId = id;
+}
+
+TPVChannelId OlcParam::GetReplacementFor()
+{
+    return iReplacementForChannelId;
+}
+
+OlcList::OlcList()
+{
+}
+
+OlcList::~OlcList()
+{
+    Clear();
+}
+
+void OlcList::Clear()
+{
+    OlcParam* olc = NULL;
+    OlcList::iterator it = begin();
+    while (it != end())
+    {
+        olc = (*it++).second;
+        OSCL_DELETE(olc);
+    }
+    clear();
+}
+
+bool OlcList::HasOlcs(TPVDirection dir,
+                      PV2WayMediaType media_type,
+                      unsigned states)
+{
+    bool hasOlcs = false;
+    OlcList::iterator it = begin();
+    while (it != end())
+    {
+        value_type& val = (*it++);
+        PV2WayMediaType mt_cur =::GetMediaType(val.second->GetForwardParams()->GetDataType());
+        if (val.first.iDir == dir &&
+                (media_type == PV_MEDIA_NONE || mt_cur == media_type) &&
+                (states & val.second->GetState()))
+        {
+            hasOlcs = true;
+            break;
+        }
+    }
+    return hasOlcs;
+}
+
+unsigned OlcList::FindOutgoingOlcsByMtState(unsigned states,
+        Oscl_Vector<OlcParam*, OsclMemAllocator>& list)
+{
+    OlcList::iterator it = begin();
+    list.clear();
+    while (it != end())
+    {
+        value_type& val = (*it++);
+        if ((val.first.iDir == OUTGOING || val.second->GetDirectionality() == EPVT_BI_DIRECTIONAL) &&
+                states & val.second->GetMtState())
+        {
+            list.push_back(val.second);
+        }
+    }
+    return list.size();
+}
+
+unsigned OlcList::FindCodecs(TPVDirection dir,
+                             PV2WayMediaType media_type,
+                             unsigned states,
+                             TPVDirection owner,
+                             Oscl_Vector<OlcFormatInfo, OsclMemAllocator>& list)
+{
+    OlcFormatInfo info;
+    OlcList::iterator it = begin();
+    list.clear();
+    while (it != end())
+    {
+        value_type& val = (*it++);
+        if ((owner == PV_DIRECTION_BOTH || owner == PV_DIRECTION_NONE || val.first.iDir == owner) &&
+                ((val.first.iDir == dir) || (val.second->GetDirectionality() == EPVT_BI_DIRECTIONAL)) &&
+                (val.second->GetState() & states))
+        {
+            H223ChannelParam* h223params = (dir == val.first.iDir) ? val.second->GetForwardParams() :
+                                           val.second->GetReverseParams();
+            PVCodecType_t codec =::GetCodecType(h223params->GetDataType());
+            if (codec == PV_CODEC_TYPE_NONE)
+                continue;
+            if ((media_type == PV_MEDIA_NONE) ||
+                    (::GetMediaType(h223params->GetDataType()) == media_type))
+            {
+                info.iId = h223params->GetChannelId();
+                info.iCodec = codec;
+                info.isSymmetric = true;
+                list.push_back(info);
+            }
+        }
+    }
+    return list.size();
+}
+
+bool OlcList::FindCodec(TPVDirection dir,
+                        PV2WayMediaType media_type,
+                        unsigned states,
+                        TPVDirection owner,
+                        OlcFormatInfo& info)
+{
+    OlcList::iterator it = begin();
+    while (it != end())
+    {
+        value_type& val = (*it++);
+        if ((owner == PV_DIRECTION_BOTH || owner == PV_DIRECTION_NONE || val.first.iDir == owner) &&
+                ((val.first.iDir == dir) || (val.second->GetDirectionality() == EPVT_BI_DIRECTIONAL)) &&
+                (val.second->GetState() & states))
+        {
+            H223ChannelParam* h223params = (dir == val.first.iDir) ? val.second->GetForwardParams() :
+                                           val.second->GetReverseParams();
+            if ((media_type == PV_MEDIA_NONE) ||
+                    (::GetMediaType(h223params->GetDataType()) == media_type))
+            {
+                info.iId = h223params->GetChannelId();
+                info.iCodec = ::GetCodecType(h223params->GetDataType());
+                info.isSymmetric = true;
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+bool OlcList::IsSymmetric(PV2WayMediaType media_type,
+                          TPVDirection out_owner,
+                          unsigned outgoing_states,
+                          TPVDirection in_owner,
+                          unsigned incoming_states)
+{
+    OlcFormatInfo outgoing_info, incoming_info;
+    if (FindCodec(OUTGOING,  media_type, outgoing_states, out_owner, outgoing_info) &&
+            FindCodec(INCOMING,  media_type, incoming_states, in_owner, incoming_info))
+    {
+        return (outgoing_info.iCodec == incoming_info.iCodec);
+    }
+    return true;
+}
+
+
+OlcParam* OlcList::AppendOlc(TPVDirection dir,
+                             TPVChannelId id,
+                             PS_DataType dt,
+                             PS_H223LogicalChannelParameters lcp,
+                             TPVChannelId idRvs,
+                             PS_DataType dtRvs,
+                             PS_H223LogicalChannelParameters lcpRvs)
+{
+    OlcParam* olc = OSCL_NEW(OlcParam, ());
+    olc->InitOlc(dir, id, dt, lcp, idRvs, dtRvs, lcpRvs);
+    AppendOlc(olc, dir, id);
+
+    return olc;
+}
+
+void OlcList::AppendOlc(OlcParam* param,
+                        TPVDirection dir,
+                        TPVChannelId id)
+{
+    OlcKey key(dir, id);
+    insert(OlcList::value_type(key, param));
+}
+
+
+unsigned OlcList::FindOlcs(TPVDirection dir,
+                           PV2WayMediaType media_type,
+                           unsigned states,
+                           Oscl_Vector<OlcParam*, OsclMemAllocator>& list)
+{
+    OlcList::iterator it = begin();
+    list.clear();
+    while (it != end())
+    {
+        value_type& val = (*it++);
+        PV2WayMediaType mt_cur =::GetMediaType(val.second->GetForwardParams()->GetDataType());
+        if (val.first.iDir == dir &&
+                (media_type == PV_MEDIA_NONE || (mt_cur == media_type)))
+        {
+            if (states & val.second->GetState())
+            {
+                list.push_back(val.second);
+            }
+        }
+    }
+    return list.size();
+}
+
+
+OlcParam* OlcList::FindOlcByMtSn(uint32 sn)
+{
+    OlcList::iterator it = begin();
+    while (it != end())
+    {
+        OlcList::value_type& val = (*it++);
+        OlcParam* olc = val.second;
+        if (olc->GetDirection() == OUTGOING || olc->GetReverseParams())
+        {
+            if (olc->GetMtSn() >= 0 && sn == (uint32)olc->GetMtSn())
+            {
+                return olc;
+            }
+        }
+    }
+    return NULL;
+}
+
+OlcParam* OlcList::FindOlcGivenChannel(TPVDirection dir, TPVChannelId lcn)
+{
+    OlcKey key(dir, lcn);
+    OlcList::iterator iter = find(key);
+    if (iter == end() || ((*iter).second == NULL))
+    {
+        return NULL;
+    }
+    return (*iter).second;
+}
+
+
+OlcParam* OlcList::FindOlc(TPVDirection dir, PV2WayMediaType media_type, unsigned state)
+{
+    OlcList::iterator it = begin();
+    while (it != end())
+    {
+        value_type& val = (*it++);
+        PV2WayMediaType mt_cur =::GetMediaType(val.second->GetForwardParams()->GetDataType());
+        if (val.first.iDir == dir &&
+                (media_type == PV_MEDIA_NONE || (mt_cur == media_type)))
+        {
+            if (state & val.second->GetState())
+            {
+                return val.second;
+            }
+        }
+    }
+    return NULL;
+}
+
+bool OlcList::HasOlc(TPVDirection dir, TPVChannelId lcn)
+{
+    OlcKey key(dir, lcn);
+    OlcList::iterator iter = find(key);
+    if (iter == end() || ((*iter).second == NULL))
+    {
+        return false;
+    }
+    return true;
+}
+
+bool OlcList::HasOlc(TPVDirection dir, TPVChannelId lcn, unsigned state)
+{
+    OlcKey key(dir, lcn);
+    OlcList::iterator iter = find(key);
+    if (iter == end() || ((*iter).second == NULL))
+    {
+        return false;
+    }
+    else
+    {
+        // loop through and find one with given state
+        while (iter != end())
+        {
+            OlcParam* olcparam = (*iter++).second;
+            int tempState = state;
+            if (olcparam->GetState() == tempState)
+            {
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+void OlcList::SetCurrLcn(TPVChannelId aCurLcn)
+{
+    iCurLcn = aCurLcn;
+}
+
+TPVChannelId OlcList::GetNextAvailLcn()
+{
+    TPVChannelId ret = iCurLcn++;
+    bool duplicate = true;
+    while (duplicate)
+    {
+        OlcParam* olc_param = FindOlcGivenChannel(OUTGOING, ret);
+        if (ret && (olc_param == NULL))
+            duplicate = false;
+        else
+            ret = iCurLcn++;
+    }
+    return ret;
+}
+
+
+int TPVMuxDescriptorSlot::is_fit(unsigned that_lcn, unsigned size)
+{
+    int ret = (lcn == that_lcn);
+    if (ret && size && max_size)
+    {
+        ret = (size >= min_size && size <= max_size);
+    }
+    return ret;
+}
+
+OSCL_EXPORT_REF CPVMultiplexEntryDescriptor* CPVMultiplexEntryDescriptor::NewL(PS_MultiplexEntryDescriptor descriptor,
+        unsigned max_pdu_size)
+{
+    CPVMultiplexEntryDescriptor* ret = OSCL_NEW(CPVMultiplexEntryDescriptor, ());
+    ret->ConstructL(descriptor, max_pdu_size);
+    return ret;
+}
+
+
+CPVMultiplexEntryDescriptor::CPVMultiplexEntryDescriptor():
+        iDescriptor(NULL),
+        iMaxPduSize(0)
+{
+}
+
+OSCL_EXPORT_REF CPVMultiplexEntryDescriptor::CPVMultiplexEntryDescriptor(const CPVMultiplexEntryDescriptor& that)
+{
+    ConstructL(that.iDescriptor, that.iMaxPduSize);
+}
+
+OSCL_EXPORT_REF CPVMultiplexEntryDescriptor::~CPVMultiplexEntryDescriptor()
+{
+    iLcns.clear();
+
+    if (iDescriptor)
+    {
+        Delete_MultiplexEntryDescriptor(iDescriptor);
+        OSCL_DEFAULT_FREE(iDescriptor);
+        iDescriptor = NULL;
+    }
+}
+
+void CPVMultiplexEntryDescriptor::ConstructL(PS_MultiplexEntryDescriptor descriptor, unsigned max_pdu_size)
+{
+    OSCL_ASSERT(descriptor);
+    bool control_descriptor = false;
+    if (descriptor->multiplexTableEntryNumber == 0)
+    {
+        descriptor->multiplexTableEntryNumber = 1;
+        control_descriptor = true;
+    }
+    iDescriptor = Copy_MultiplexEntryDescriptor(descriptor);
+    if (control_descriptor)
+    {
+        iDescriptor->multiplexTableEntryNumber = 0;
+        descriptor->multiplexTableEntryNumber = 0;
+    }
+    iMaxPduSize = max_pdu_size;
+
+    if (descriptor->option_of_elementList)
+    {
+        int size = 0;
+        FindLcns(descriptor->elementList, descriptor->size_of_elementList, iMaxPduSize, iLcns, &size);
+    }
+}
+
+OSCL_EXPORT_REF int CPVMultiplexEntryDescriptor::FindLcn(uint16 channel_id, uint16 len, TPVMuxDescriptorSlot& slot_info)
+{
+    TPVMuxDescriptorSlotList::iterator it = iLcns.find(channel_id);
+    int ret = 0;
+    if (it != iLcns.end())
+    {
+        TPVMuxDescriptorSlot& found_slot = (*it).second;
+        if (found_slot.is_fit(channel_id, len))
+        {
+            slot_info = (*it).second;
+            ret = 1;
+        }
+    }
+    return ret;
+}
+
+unsigned CPVMultiplexEntryDescriptor::FindLcns(
+    PS_MultiplexElement pElement,
+    int ListSize,
+    int max_pdu_size,
+    TPVMuxDescriptorSlotList& lcns,
+    int* subelement_size)
+{
+    unsigned num_lcns = 0;
+    *subelement_size = 0;
+
+    for (int cnt = ListSize ; cnt != 0 ; cnt --)
+    {
+        /* SubElemnt Search	*/
+        if (pElement->muxType.index)
+        {
+            int size = 0;
+            TPVMuxDescriptorSlotList lcns_local;
+            num_lcns += FindLcns(pElement->muxType.subElementList, pElement->muxType.size, max_pdu_size, lcns_local, &size);
+            OSCL_ASSERT(size);
+            unsigned rc_min = 0;
+            unsigned rc_max = 0;
+            if (pElement->repeatCount.index)
+            {
+                // ucf
+                rc_max = max_pdu_size / size;
+                rc_min = 1;
+            }
+            else
+            {
+                // finite
+                rc_max = rc_min = pElement->repeatCount.finite;
+            }
+            /* update the subelement size */
+            *subelement_size += (rc_max * size);
+
+            /* update the max size */
+            max_pdu_size -= (*subelement_size);
+
+            /* Multiply the max and min sizes in lcns_local by rc, and add to the lcns list */
+            TPVMuxDescriptorSlotList::iterator it = lcns_local.begin();
+
+            while (it != lcns_local.end())
+            {
+                TPVMuxDescriptorSlot slot_info = {0, 0, 0};
+                TPVMuxDescriptorSlot& slot = (*it++).second;
+
+                slot.max_size *= rc_max;
+                slot.min_size *= rc_min;
+                /* is it present in the lcns list ? */
+                if (FindLcn((uint16)slot.lcn, 0, slot_info) <= 0)
+                {
+                    lcns.insert(TPVMuxDescriptorSlotList::value_type(slot.lcn, slot_info));
+                }
+                slot_info.lcn = slot.lcn;
+                slot_info.min_size += slot.min_size;
+                slot_info.max_size += slot.max_size;
+                lcns[slot.lcn] = slot_info;
+            }
+        }
+        else
+        {
+            TPVMuxDescriptorSlot slot_info = {0, 0, 0};
+            unsigned min_size = 0;
+            unsigned max_size = 0;
+            if (pElement->repeatCount.index)
+            {
+                // ucf
+                min_size = 1;
+                max_size = 0;
+            }
+            else
+            {
+                // finite
+                min_size = max_size = pElement->repeatCount.finite;
+            }
+            slot_info.lcn = pElement->muxType.logicalChannelNumber;
+            slot_info.min_size = min_size;
+            slot_info.max_size = max_size;
+            lcns.insert(TPVMuxDescriptorSlotList::value_type(slot_info.lcn, slot_info));
+            num_lcns++;
+            *subelement_size += max_size;
+            max_pdu_size -= max_size;
+        }
+        pElement ++;
+    }
+    return num_lcns;
+}
+
+OSCL_EXPORT_REF unsigned CPVMultiplexEntryDescriptor::NumLcns()
+{
+    return iLcns.size();
+}
+
+OSCL_EXPORT_REF PS_MultiplexEntryDescriptor CPVMultiplexEntryDescriptor::GetH245descriptor()
+{
+    return iDescriptor;
+}
+
+OSCL_EXPORT_REF CPVMultiplexEntryDescriptorVector::CPVMultiplexEntryDescriptorVector()
+{
+
+}
+
+OSCL_EXPORT_REF CPVMultiplexEntryDescriptorVector::CPVMultiplexEntryDescriptorVector(const CPVMultiplexEntryDescriptorVector& that) :  Oscl_Vector<CPVMultiplexEntryDescriptor*, OsclMemAllocator>(that)
+
+{
+    CPVMultiplexEntryDescriptor* desc = NULL;
+    for (unsigned num = 0; num < that.size(); num++)
+    {
+        desc = OSCL_NEW(CPVMultiplexEntryDescriptor, (*that[num]));
+        push_back(desc);
+    }
+}
+
+OSCL_EXPORT_REF CPVMultiplexEntryDescriptorVector::~CPVMultiplexEntryDescriptorVector()
+{
+    Clear();
+}
+
+OSCL_EXPORT_REF void CPVMultiplexEntryDescriptorVector::Clear()
+{
+    CPVMultiplexEntryDescriptor* desc = NULL;
+    while (size())
+    {
+        desc = back();
+        OSCL_DELETE(desc);
+        pop_back();
+    }
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/level0.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/level0.cpp
new file mode 100644
index 0000000..5c92bab
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/level0.cpp
@@ -0,0 +1,361 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "level0.h"
+#include "h324utils.h"
+#include "h223.h"
+
+#define HDLC	0x7e
+#define NUM_ZERO_BIT_INSERTION_BUFFERS 32
+
+Level0PduParcom::Level0PduParcom()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.Level0");
+    iNumRecvBits = 0;
+    iRecvBits = 0;
+    iRecvByte = 0;
+    iRecvBytePos = 0;
+    iRecvByte0 = 0;
+    iRecvByte0Pos = 0;
+    iZeroBitRemovedOutputPos = 0;
+    iZeroBitRemovedOutput = 0;
+    iPduPosZeroRemoved = 0;
+
+    iTxByte0 = 0;
+    iTxByte0Pos = 0;
+    iTxCheck0 = 0;
+    iTxCheck0Pos = 0;
+
+    uint8 HecCrc[18] =
+    {
+        0x00, 0x05, 0x07, 0x02, 0x03, 0x06, 0x04, 0x01,
+        0x06, 0x03, 0x01, 0x04, 0x05, 0x00, 0x02, 0x07
+    };
+
+    oscl_memcpy(iHecCrc, HecCrc, 18);
+}
+
+void
+Level0PduParcom::Construct(uint16 max_outstanding_pdus)
+{
+    // Do not Leave on allocation failure
+    iPduFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iPduFragmentAlloc.size(NUM_ZERO_BIT_INSERTION_BUFFERS, H223_MAX_MUX_PDU_SIZE);
+    // Do not Leave on allocation failure
+    iHdrFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iHdrFragmentAlloc.size(max_outstanding_pdus, (uint16)H223GetMaxStuffingSz(H223_LEVEL0));
+}
+
+void Level0PduParcom::GetHdrFragment(OsclRefCounterMemFrag& frag)
+{
+    frag = iHdrFragmentAlloc.get();
+}
+
+uint32
+Level0PduParcom::GetStuffing(uint8* pPdu, uint32 max_size, uint8 mux_code)
+{
+    OSCL_UNUSED_ARG(mux_code);
+    OSCL_UNUSED_ARG(max_size);
+    uint8* pos = pPdu;
+    for (unsigned i = 0; i < max_size; i++)
+    {
+        pos += AppendTxOctet(HDLC, pos);
+    }
+    return (uint16)(pos -pPdu);
+}
+
+PVMFStatus Level0PduParcom::CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 MuxTblNum, uint8 pm)
+{
+    uint8 flag = HDLC;
+    // header
+    OsclRefCounterMemFrag frag;
+    pdu->getMediaFragment(0, frag);
+    pdu->setMediaFragFilledLen(0, GetHeaderSz());
+
+    uint8* pPdu = (uint8*)frag.getMemFragPtr();
+    *pPdu = flag;
+    *(pPdu + 1) = (uint8)(iHecCrc[MuxTblNum] << 5 | MuxTblNum << 1);
+
+
+    OsclRefCounterMemFrag post_zb_frag = iPduFragmentAlloc.get();
+    if (post_zb_frag.getMemFragPtr() == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level0PduParcom::CompletePdu Failed to allocate post_zb_frag"));
+        return PVMFErrNoMemory;
+    }
+
+    uint8* pos = (uint8*)post_zb_frag.getMemFragPtr();
+    pos += AppendTxOctet(flag, pos);
+    pos += AppendTxOctet(flag, pos);
+    pos += Insert0Octet(*(pPdu + 1), 8, pos);
+
+    // write out the payload
+    for (uint frag_num = 1; frag_num < pdu->getNumFragments(); frag_num++)
+    {
+        pdu->getMediaFragment(frag_num, frag);
+        pos += Insert0((uint8*)frag.getMemFragPtr(), frag.getMemFragSize(), pos);
+    }
+    pos += AppendTxOctet(flag, pos);
+    if (pm)
+    {
+        pos += Insert0Octet(1, 8, pos);
+        pos += AppendTxOctet(flag, pos);
+    }
+    pos += AppendTxOctet(flag, pos);
+
+    // replace current fragments with the zero bit inserted fragment
+    pdu->clearMediaFragments();
+    post_zb_frag.getMemFrag().len = pos - (uint8*)post_zb_frag.getMemFragPtr();
+    if (post_zb_frag.getMemFrag().len)
+    {
+        pdu->appendMediaFragment(post_zb_frag);
+    }
+
+    return PVMFSuccess;
+}
+
+uint32 Level0PduParcom::Parse(uint8* bsbuf, uint32 bsbsz)
+{
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"Level0PduParcom::Parse %d\n", bsbsz));
+    //printBuffer(iDebug, bsbuf, bsbsz);
+    SearchForHdlcFlag(bsbuf, bsbsz);
+    return 0;
+}
+
+/* This function writes an octet to the zero bit stuffed tx bitstream.  If there is pending bits for zero bit check,
+   they are flushed out first */
+uint16 Level0PduParcom::AppendTxOctet(uint8 octet, uint8* pos)
+{
+    uint8* write_pos = pos;
+    if (iTxCheck0Pos)
+    {
+        write_pos += AppendTxBits0(iTxCheck0Pos, iTxCheck0, write_pos);
+        iTxCheck0Pos = 0;
+        iTxCheck0 = 0;
+    }
+    write_pos += AppendTxBits0(8, octet, write_pos);
+    return (uint16)(write_pos -pos);
+}
+
+/* Writes out bits to the output stream */
+uint16 Level0PduParcom::AppendTxBits0(unsigned num_bits, int bits, uint8* pos)
+{
+    uint8* write_pos = pos;
+    iTxByte0 |= (bits << iTxByte0Pos);
+    iTxByte0Pos += num_bits;
+
+    while (iTxByte0Pos >= 8)
+    {
+        *write_pos++ = (uint8)iTxByte0;
+        iTxByte0 >>= 8;
+        iTxByte0Pos -= 8;
+    }
+    return (uint16)(write_pos - pos);
+}
+
+/* Inserts the octet while checking for 5 1's.  */
+uint16 Level0PduParcom::Insert0Octet(uint8 octet, uint16 num_bits_from_octet, uint8* out_buffer)
+{
+    uint8* write_pos = out_buffer;
+
+    iTxCheck0 = iTxCheck0 | (octet << iTxCheck0Pos);
+    iTxCheck0Pos += num_bits_from_octet;
+    int bits_consumed = 0;
+    while (iTxCheck0Pos >= 5)
+    {
+        if ((iTxCheck0 & 0x1F) == 0x1F)
+        {
+            // 5 1's detected.  Insert 0 after them
+            //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"Level0PduParcom::Insert0Octet - inserting 0\n"));
+            write_pos += AppendTxBits0(5, iTxCheck0 & 0x1F, write_pos);
+            write_pos += AppendTxBits0(1, 0, write_pos);
+            bits_consumed = 5;
+        }
+        else
+        {
+            // just insert the lsb
+            write_pos += AppendTxBits0(1, iTxCheck0 & 1, write_pos);
+            bits_consumed = 1;
+        }
+        iTxCheck0 >>= bits_consumed;
+        iTxCheck0Pos -= bits_consumed;
+    }
+    return (uint16)(write_pos -out_buffer);
+}
+
+/* Zero bit insertion from a buffer */
+uint16
+Level0PduParcom::Insert0(uint8* chunk, int chunk_size, uint8* out_buffer)
+{
+    uint8* pos = out_buffer;
+    for (int bytenum = 0; bytenum < chunk_size; bytenum++)
+    {
+        pos += Insert0Octet(chunk[bytenum], 8, pos);
+    }
+    return (uint16)(pos -out_buffer);
+}
+
+/* Does more than the name implies.  It searches for the next flag, and if a valid pdu is found, does zero bit removal
+   and indicates pdu to upper layer */
+void Level0PduParcom::SearchForHdlcFlag(uint8* bsbuf, int bsbsz)
+{
+    for (int bytenum = 0; bytenum < bsbsz; bytenum++)
+    {
+        uint8 cur_byte = bsbuf[bytenum];
+        uint8 cur_bit = 0;
+        for (int bitnum = 0; bitnum < 8; bitnum++)
+        {
+            cur_bit = (uint8)(cur_byte & 0x1);
+            cur_byte >>= 1;
+            iRecvBits = (uint8)(iRecvBits | (cur_bit << iNumRecvBits++));
+            if (iNumRecvBits == 8)
+            {
+                if ((iRecvBits&HDLC) == HDLC)
+                {
+                    // found flag
+                    unsigned size = iPduPos - iPdu;
+                    if (size)
+                    {
+                        // perform 0 bit removal within the same buffer
+                        Remove0();
+                    }
+                    iNumRecvBits = 0;
+                    iRecvBits = 0;
+                }
+                else
+                {
+                    // copy current bit to pdu
+                    AppendBit(iRecvBits&0x1);
+                    iRecvBits >>= 1;
+                    iNumRecvBits--;
+                }
+            }
+        }
+    }
+}
+
+/* Appends a bit to the received bitstream.  If 8 bits are received, they are flushed to iPdu */
+void Level0PduParcom::AppendBit(int c)
+{
+    iRecvByte |= (c << iRecvBytePos++);
+    if (iRecvBytePos == 8)
+    {
+        if (iPduPos == iPduEndPos)
+        {
+            Remove0();
+        }
+        *iPduPos++ = (uint8)iRecvByte;
+        iRecvByte = 0;
+        iRecvBytePos = 0;
+    }
+}
+
+/* Appends bits to the zero bit removed incoming bitstream */
+void Level0PduParcom::AppendBits0(unsigned num_bits, int bits)
+{
+    iZeroBitRemovedOutput = iZeroBitRemovedOutput | (bits << iZeroBitRemovedOutputPos);
+    iZeroBitRemovedOutputPos += num_bits;
+    while (iZeroBitRemovedOutputPos >= 8)
+    {
+        OSCL_ASSERT(iPduPosZeroRemoved != (iPduEndPos + 1));
+        *iPduPosZeroRemoved++ = (uint8)iZeroBitRemovedOutput;
+        iZeroBitRemovedOutput >>= 8;
+        iZeroBitRemovedOutputPos -= 8;
+    }
+}
+
+/* Performs 0 bit removal from the current pdu (iPdu) */
+unsigned Level0PduParcom::Remove0()
+{
+    int size = iPduPos - iPdu;
+    OSCL_ASSERT(size >= 0);
+    iPduPosZeroRemoved = iPdu;
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"Level0PduParcom::Remove0 size(%d)", size));
+    for (int bytenum = 0; bytenum < size; bytenum++)
+    {
+        Remove0Octet(iPdu[bytenum], 8);
+    }
+    if (iRecvBytePos)
+    {
+        //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"Level0PduParcom::Remove0 iRecvBytePos(%d)", iRecvBytePos));
+        Remove0Octet((uint8)iRecvByte, iRecvBytePos);
+        iRecvBytePos = 0;
+        iRecvByte = 0;
+    }
+    if (iRecvByte0Pos)
+    {
+        //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"Level0PduParcom::Remove0 iRecvByte0Pos(%d)", iRecvByte0Pos));
+        AppendBits0(iRecvByte0Pos, iRecvByte0);
+        iRecvByte0Pos = 0;
+        iRecvByte0 = 0;
+    }
+    //OSCL_ASSERT(iZeroBitRemovedOutputPos == 0);
+    if (iZeroBitRemovedOutputPos)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "Level0PduParcom::Remove0 Error - iZeroBitRemovedOutputPos(%d) != 0", iZeroBitRemovedOutputPos));
+        iZeroBitRemovedOutputPos = 0;
+    }
+    /* Return MUX-PDU header data */
+    int fClosing = 0;
+    int muxCode = -1;
+    iPduPos = iPdu;
+    if (*iPduPos & 1)
+    {
+        fClosing = 1;
+    }
+    muxCode = (*iPduPos >> 1) & 0xf;
+    iPduPos++;
+    iObserver->MuxPduIndicate(iPduPos, (uint16)(iPduPosZeroRemoved - iPdu - 1), fClosing, muxCode);
+
+    iPduPos = iPdu;
+    return 0;
+}
+
+void Level0PduParcom::Remove0Octet(uint8 cur_byte, int num_bits_from_octet)
+{
+    uint8 cur_bit = 0;
+    for (int bitnum = 0; bitnum < num_bits_from_octet; bitnum++)
+    {
+        cur_bit = (uint8)(cur_byte & 0x1);
+        cur_byte >>= 1;
+        iRecvByte0 = (uint8)(iRecvByte0 | (cur_bit << iRecvByte0Pos++));
+        if (iRecvByte0Pos == 6)
+        {
+            if ((iRecvByte0 & 0x1F) == 0x1F)
+            {
+                //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"Level0PduParcom::Remove0Octet - skipping 0\n"));
+//				OSCL_ASSERT( (iRecvByte0 & 0x20) == 0);
+                if ((iRecvByte0&0x20) != 0)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level0PduParcom::Remove0Octet - Bitstream error.\n"));
+                }
+                // write out 5 1's and skip the following 0 bit
+                AppendBits0(5, 0x1F);
+                iRecvByte0Pos = 0;
+                iRecvByte0 = 0;
+            }
+            else
+            {
+                // write out the lsb
+                AppendBits0(1, iRecvByte0&01);
+                iRecvByte0Pos--;
+                iRecvByte0 >>= 1;
+            }
+
+        }
+    }
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/level1.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/level1.cpp
new file mode 100644
index 0000000..a6385f4
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/level1.cpp
@@ -0,0 +1,229 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+ * File:	muxpdu.c
+ * Comment:	Mux level 1 specific routines
+ */
+#include "level1.h"
+#include "h223.h"
+
+Level1PduParcom::Level1PduParcom(bool df):
+        iDf(df)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.Level1");
+    iCurrentInt32 = 0;
+    iCurrentOp = ELookForStartFlag;
+    iSkipBytes = 0;
+    iPduPos = NULL;
+    uint8 HecCrc[18] =
+    {
+        0x00, 0x05, 0x07, 0x02, 0x03, 0x06, 0x04, 0x01,
+        0x06, 0x03, 0x01, 0x04, 0x05, 0x00, 0x02, 0x07
+    };
+
+    oscl_memcpy(iHecCrc, HecCrc, 18);
+}
+
+void
+Level1PduParcom::Construct(uint16 max_outstanding_pdus)
+{
+    iHdrFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iHdrFragmentAlloc.size(max_outstanding_pdus, (uint16)H223GetMaxStuffingSz(H223_LEVEL1));
+}
+
+void Level1PduParcom::GetHdrFragment(OsclRefCounterMemFrag& frag)
+{
+    frag = iHdrFragmentAlloc.get();
+}
+
+unsigned
+Level1PduParcom::GetStuffing(uint8* pPdu, uint32 buf_size, uint8 mux_code)
+{
+    OSCL_UNUSED_ARG(mux_code);
+    OSCL_UNUSED_ARG(buf_size);
+    int32 stuffing_size = iDf ? 4 : 2;
+    int32 size_left = buf_size;
+    while (size_left >= stuffing_size)
+    {
+        *(pPdu) = 0xe1;
+        *(pPdu + 1) = 0x4d;
+        pPdu += 2;
+        size_left -= 2;
+        if (iDf)
+        {
+            *(pPdu) = 0xe1;
+            *(pPdu + 1) = 0x4d;
+            pPdu += 2;
+            size_left -= 2;
+        }
+    }
+    return (buf_size -size_left);
+}
+
+PVMFStatus Level1PduParcom::CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 MuxTblNum, uint8 pm)
+{
+    iClosingNext = 0;
+    OSCL_UNUSED_ARG(pm);
+    OsclRefCounterMemFrag frag;
+    pdu->getMediaFragment(0, frag);
+    pdu->setMediaFragFilledLen(0, GetHeaderSz());
+
+    // header
+    uint8* pPdu = (uint8*)frag.getMemFrag().ptr;
+
+    *pPdu = 0xe1;
+    *(pPdu + 1) = 0x4d;
+    if (iDf)
+    {
+        *(pPdu + 2) = 0xe1;
+        *(pPdu + 3) = 0x4d;
+        *(pPdu + 4) = (uint8)(iHecCrc[MuxTblNum] << 5 | MuxTblNum << 1);
+    }
+    else
+    {
+        *(pPdu + 2) = (uint8)(iHecCrc[MuxTblNum] << 5 | MuxTblNum << 1);
+    }
+
+    // trailer
+    if (pm)
+    {
+        OsclRefCounterMemFrag frag = iHdrFragmentAlloc.get();
+        if (frag.getMemFragPtr() == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level1PduParcom::CompletePdu Failed to allocate frag"));
+            return PVMFErrNoMemory;
+        }
+
+        frag.getMemFrag().len = GetHeaderSz();
+        pPdu = (uint8*)frag.getMemFragPtr();
+        *pPdu = 0xe1;
+        *(pPdu + 1) = 0x4d;
+        if (iDf) 	/* L1 Double Flag */
+        {
+            *(pPdu + 2) = 0xe1;
+            *(pPdu + 3) = 0x4d;
+            *(pPdu + 4) = (uint8)(iHecCrc[MuxTblNum] << 5 | MuxTblNum << 1 | 1);
+        }
+        else
+        {
+            *(pPdu + 2) = (uint8)(iHecCrc[MuxTblNum] << 5 | MuxTblNum << 1 | 1);
+        }
+        pdu->appendMediaFragment(frag);
+    }
+    return PVMFSuccess;
+}
+
+inline void Level1PduParcom::IndicatePdu()
+{
+    int pdu_size = iPduPos - iPdu;
+    uint8* pdu = iPdu;
+
+    if (pdu_size >= 1)
+    {
+        if (iHecCrc[((*pdu)>>1)&0xf] != (*pdu) >> 5)
+        {
+            iObserver->MuxPduErrIndicate(EHeaderErr);
+#ifdef PVANALYZER
+            nCrcError++;
+            PVAnalyzer(ANALYZER_MUXHDR, "Mux Header Error #=%d, %%=%f", nCrcError, (double)nCrcError / (double)nPdu);
+#endif
+        }
+        else
+        {
+            int fClosing = 0;
+            int muxCode = -1;
+            if ((*pdu) & 1)
+                fClosing = 1;
+            muxCode = ((*pdu) >> 1) & 0xf;
+            pdu++;
+            pdu_size--;
+            iObserver->MuxPduIndicate(pdu, (uint16)pdu_size, fClosing, muxCode);
+        }
+    }
+    iPduPos = NULL;
+}
+
+uint32 Level1PduParcom::Parse(uint8* bsbuf, uint32 bsbsz)
+{
+    const int FLAG = (iDf) ? 0xE14DE14D : 0xE14D;
+    const int FLAG_SZ = (iDf) ? 4 : 2;
+    const int FLAG_MASK = (iDf) ? 0xFFFFFFFF : 0xFFFF;
+#ifdef PVANALYZER
+    static unsigned int nPdu = 0;
+    static unsigned int nCrcError = 0;
+    nPdu++;
+#endif
+
+    for (unsigned num = 0; num < bsbsz; num++)
+    {
+        iCurrentInt32 <<= 8;
+        iCurrentInt32  |= bsbuf[num];
+        switch (iCurrentOp)
+        {
+            case ELookForStartFlag:
+                if ((iCurrentInt32 & FLAG_MASK) == FLAG)
+                {
+                    iCurrentOp = ESkipFlags;
+                    iPduPos = iPdu;
+                }
+                break;
+            case ESkipFlags:
+                iSkipBytes++;
+                if (iSkipBytes == FLAG_SZ)
+                {
+                    if ((iCurrentInt32 & FLAG_MASK) != FLAG)
+                    {
+                        if (!iPduPos)
+                            iPduPos = iPdu;
+                        // Check if iPduPos+FLAG_SZ-1 overflows
+                        int copy_from = iCurrentInt32;
+                        for (uint8* write_pos = iPduPos + FLAG_SZ - 1; write_pos >= iPduPos; write_pos--)
+                        {
+                            *write_pos = (uint8)copy_from;
+                            copy_from >>= 8;
+                        }
+                        iPduPos += FLAG_SZ;
+                        iCurrentOp = ELookForEndFlag;
+                    }
+                    iSkipBytes = 0;
+                }
+                break;
+            case ELookForEndFlag:
+                if ((iCurrentInt32 & FLAG_MASK) == FLAG)
+                {
+                    iPduPos -= (FLAG_SZ - 1);
+                    // found end flag
+                    IndicatePdu();
+                    iCurrentOp = ESkipFlags;
+                }
+                else
+                {
+                    *iPduPos++ = bsbuf[num];
+                    // check for pdu size
+                    if ((iPduPos - iPdu) == H223_MAX_MUX_PDU_SIZE)
+                    {
+                        iObserver->MuxPduErrIndicate(ESizeErr);
+                        iPduPos = NULL;
+                        iCurrentOp = ELookForStartFlag;
+                    }
+                }
+                break;
+        }
+    }
+    return 1;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/level2.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/level2.cpp
new file mode 100644
index 0000000..acad6e7
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/level2.cpp
@@ -0,0 +1,978 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_mem.h"
+#include "golay.h"
+#include "level2.h"
+#include "h223.h"
+//#define CORRUPT_MPL 10
+//#define CORRUPT_MT 1
+//#define CORRUPT_MUXCODE 4
+//#define LOG_FLAG_EMULATIONS 1
+#define SYNC_LOSS_INDICATE_THRESHOLD 160
+
+/* WWUXC: enc table is changed */
+static const int enc_tab[] =
+{
+    0, 7285, 9375, 14570, 19787, 20798, 27092, 30113, 34531, 39574, 41596, 48649, 52136, 55261, 61239, 62274,
+    68019, 71110, 77100, 78169, 83192, 88205, 90215, 97298, 102224, 103205, 109519, 112570, 115227, 122478, 124548, 129777,
+    133990, 136979, 143353, 144268, 149037, 154200, 156338, 163527, 167301, 168432, 174362, 177519, 180430, 187579, 189521, 194596,
+    197333, 204448, 206410, 211519, 216990, 218091, 224001, 227188, 230454, 235587, 237737, 244956, 248189, 251144, 257506, 258455,
+    265932, 266937, 272979, 276006, 279431, 286706, 288536, 293741, 297007, 300122, 306352, 307397, 312676, 317713, 319995, 327054,
+    329599, 334602, 336864, 343957, 346676, 349761, 356011, 357086, 360860, 368105, 369923, 375158, 380119, 381090, 387144, 390205,
+    394666, 399839, 401717, 408896, 411873, 414868, 420990, 421899, 426825, 433980, 436182, 441251, 445954, 447095, 453277, 456424,
+    461849, 462956, 469126, 472307, 475474, 482599, 484813, 489912, 494330, 497295, 503397, 504336, 509873, 515012, 516910, 524123,
+    524781, 531864, 533874, 538887, 543910, 544979, 550969, 554060, 558862, 564091, 566161, 573412, 576069, 579120, 585434, 586415,
+    591966, 594987, 601281, 602292, 607509, 612704, 614794, 622079, 626365, 627400, 633378, 636503, 639990, 647043, 649065, 654108,
+    658059, 661246, 667156, 668257, 673728, 678837, 680799, 687914, 691304, 692253, 698615, 701570, 704803, 712022, 714172, 719305,
+    721720, 728909, 731047, 736210, 740979, 741894, 748268, 751257, 755163, 760238, 762180, 769329, 772240, 775397, 781327, 782458,
+    790305, 791380, 797630, 800715, 803434, 810527, 812789, 817792, 821698, 824759, 830813, 831784, 836745, 841980, 843798, 851043,
+    853650, 858855, 860685, 867960, 871385, 874412, 880454, 881459, 884849, 891908, 894190, 899227, 904506, 905551, 911781, 914896,
+    918599, 923698, 925912, 933037, 936204, 939385, 945555, 946662, 950948, 958161, 960059, 965198, 970735, 971674, 977776, 980741,
+    986612, 987521, 993643, 996638, 999615, 1006794, 1008672, 1013845, 1018647, 1021794, 1027976, 1029117, 1033820, 1038889, 1041091, 1048246,
+    1049562, 1056687, 1058629, 1063728, 1068689, 1069796, 1075726, 1078907, 1082681, 1087820, 1089958, 1097171, 1099890, 1102855, 1109229, 1110168,
+    1116777, 1119772, 1126134, 1127043, 1132322, 1137495, 1139645, 1146824, 1150090, 1151231, 1157141, 1160288, 1163713, 1170868, 1172830, 1177899,
+    1181884, 1184969, 1190947, 1192022, 1197559, 1202562, 1204584, 1211677, 1216095, 1217066, 1223360, 1226421, 1229588, 1236833, 1238923, 1244158,
+    1245455, 1252730, 1254800, 1260005, 1264708, 1265713, 1272027, 1275054, 1279980, 1285017, 1287027, 1294086, 1297063, 1300178, 1306168, 1307213,
+    1314070, 1315171, 1321353, 1324540, 1327197, 1334312, 1336514, 1341623, 1346549, 1349504, 1355626, 1356575, 1361598, 1366731, 1368609, 1375828,
+    1377445, 1382608, 1384506, 1391695, 1395182, 1398171, 1404273, 1405188, 1409606, 1416755, 1418969, 1424044, 1429261, 1430392, 1436562, 1439719,
+    1443440, 1448453, 1450735, 1457818, 1461051, 1464142, 1470372, 1471441, 1474707, 1481958, 1483788, 1489017, 1494488, 1495469, 1501511, 1504562,
+    1511363, 1512374, 1518428, 1521449, 1524360, 1531645, 1533463, 1538658, 1542432, 1545557, 1551807, 1552842, 1557611, 1562654, 1564916, 1571969,
+    1573431, 1580610, 1582760, 1587933, 1593212, 1594121, 1600483, 1603478, 1606868, 1611937, 1613899, 1621054, 1624479, 1627626, 1633536, 1634677,
+    1641348, 1644529, 1650459, 1651566, 1656527, 1661626, 1663568, 1670693, 1674599, 1675538, 1681912, 1684877, 1687596, 1694809, 1696947, 1702086,
+    1706321, 1709348, 1715662, 1716667, 1721370, 1726575, 1728645, 1735920, 1740722, 1741767, 1747757, 1750872, 1753849, 1760908, 1762918, 1767955,
+    1769698, 1776791, 1778813, 1783816, 1789353, 1790428, 1796406, 1799491, 1803777, 1809012, 1811102, 1818347, 1821514, 1824575, 1830869, 1831840,
+    1838331, 1839246, 1845348, 1848337, 1851824, 1859013, 1860911, 1866074, 1870360, 1873517, 1879687, 1880818, 1886035, 1891110, 1893324, 1900473,
+    1901896, 1907005, 1909207, 1916322, 1918979, 1922166, 1928348, 1929449, 1934251, 1941470, 1943348, 1948481, 1953504, 1954453, 1960575, 1963530,
+    1968029, 1973224, 1975042, 1982327, 1985238, 1988259, 1994313, 1995324, 1999230, 2006283, 2008545, 2013588, 2018357, 2019392, 2025642, 2028767,
+    2035246, 2036315, 2042545, 2045636, 2048869, 2055952, 2058234, 2063247, 2066637, 2069688, 2075730, 2076711, 2082182, 2087411, 2089241, 2096492,
+    2099124, 2104257, 2106155, 2113374, 2116351, 2119306, 2125408, 2126357, 2130263, 2137378, 2139592, 2144701, 2149404, 2150505, 2156675, 2159862,
+    2166279, 2167410, 2173592, 2176749, 2179916, 2187065, 2189267, 2194342, 2197732, 2200721, 2206843, 2207758, 2213295, 2218458, 2220336, 2227525,
+    2231506, 2232487, 2238541, 2241592, 2245017, 2252268, 2254086, 2259315, 2263601, 2266692, 2272942, 2274011, 2279290, 2284303, 2286565, 2293648,
+    2295137, 2300180, 2302462, 2309515, 2312234, 2315359, 2321589, 2322624, 2327426, 2334711, 2336541, 2341736, 2346697, 2347708, 2353750, 2356771,
+    2361720, 2364685, 2371047, 2371986, 2376755, 2381894, 2384044, 2391257, 2396059, 2397166, 2403076, 2406257, 2409168, 2416293, 2418255, 2423354,
+    2425035, 2432190, 2434132, 2439201, 2444672, 2445813, 2451743, 2454890, 2459176, 2464349, 2466487, 2473666, 2476899, 2479894, 2486268, 2487177,
+    2490910, 2498155, 2500225, 2505460, 2510677, 2511648, 2517962, 2521023, 2524413, 2529416, 2531426, 2538519, 2542006, 2545091, 2551081, 2552156,
+    2558893, 2562008, 2567986, 2569031, 2574054, 2579091, 2581113, 2588172, 2592078, 2593083, 2599377, 2602404, 2605061, 2612336, 2614426, 2619631,
+    2623065, 2628140, 2630342, 2637491, 2640658, 2643815, 2649997, 2651128, 2654394, 2661583, 2663461, 2668624, 2674161, 2675076, 2681198, 2684187,
+    2691050, 2691999, 2698101, 2701056, 2704033, 2711252, 2713150, 2718283, 2722057, 2725244, 2731414, 2732515, 2737218, 2742327, 2744541, 2751656,
+    2755903, 2756938, 2763168, 2766293, 2769012, 2776065, 2778347, 2783390, 2788316, 2791337, 2797379, 2798390, 2803351, 2808546, 2810376, 2817661,
+    2819212, 2824441, 2826259, 2833510, 2836935, 2839986, 2846040, 2847021, 2851439, 2858522, 2860784, 2865797, 2871076, 2872145, 2878395, 2881486,
+    2885781, 2888928, 2894858, 2895999, 2901470, 2906539, 2908481, 2915636, 2920054, 2920963, 2927337, 2930332, 2933565, 2940744, 2942882, 2948055,
+    2949414, 2956627, 2958777, 2963916, 2968685, 2969624, 2975986, 2978951, 2983877, 2988976, 2990938, 2998063, 3000974, 3004155, 3010065, 3011172,
+    3015667, 3022726, 3024748, 3029785, 3034808, 3035853, 3041831, 3044946, 3048720, 3053925, 3056015, 3063290, 3065947, 3068974, 3075268, 3076273,
+    3082816, 3085877, 3092191, 3093162, 3098379, 3103614, 3105684, 3112929, 3116195, 3117270, 3123260, 3126345, 3129832, 3136925, 3138935, 3143938,
+    3146862, 3151899, 3154161, 3161220, 3164453, 3167568, 3173818, 3174863, 3179149, 3186424, 3188242, 3193447, 3198918, 3199923, 3205977, 3209004,
+    3214813, 3215784, 3221826, 3224887, 3227798, 3235043, 3236873, 3242108, 3246910, 3249995, 3256225, 3257300, 3262069, 3267072, 3269354, 3276447,
+    3280648, 3281789, 3287959, 3291106, 3293763, 3300918, 3303132, 3308201, 3312107, 3315102, 3321204, 3322113, 3327136, 3332309, 3334207, 3341386,
+    3344059, 3349198, 3351076, 3358289, 3361776, 3364741, 3370863, 3371802, 3375192, 3382317, 3384519, 3389618, 3394835, 3395942, 3402124, 3405305,
+    3410594, 3413719, 3419709, 3420744, 3426281, 3431324, 3433334, 3440387, 3443777, 3444788, 3451102, 3454123, 3457290, 3464575, 3466645, 3471840,
+    3474193, 3481444, 3483534, 3488763, 3493466, 3494447, 3500741, 3503792, 3507698, 3512711, 3514733, 3521816, 3524793, 3527884, 3533862, 3534931,
+    3539396, 3546545, 3548507, 3553582, 3558543, 3559674, 3565584, 3568741, 3573543, 3578706, 3580856, 3588045, 3590764, 3593753, 3600115, 3601030,
+    3606647, 3609602, 3615976, 3616925, 3622204, 3627337, 3629475, 3636694, 3640980, 3642081, 3648011, 3651198, 3654623, 3661738, 3663680, 3668789,
+    3671427, 3676662, 3678492, 3685737, 3688648, 3691709, 3697751, 3698722, 3703648, 3710741, 3713023, 3718026, 3722795, 3723870, 3730100, 3733185,
+    3738672, 3739717, 3745967, 3749082, 3752315, 3759374, 3761636, 3766673, 3771091, 3774118, 3780172, 3781177, 3786648, 3791853, 3793671, 3800946,
+    3804901, 3805840, 3811962, 3814927, 3818414, 3825627, 3827505, 3832644, 3835910, 3839091, 3845273, 3846380, 3851597, 3856696, 3858898, 3866023,
+    3868502, 3873571, 3875785, 3882940, 3885597, 3888744, 3894914, 3896055, 3899829, 3907008, 3908906, 3914079, 3919102, 3920011, 3926113, 3929108,
+    3935055, 3938106, 3944400, 3945381, 3950084, 3955313, 3957403, 3964654, 3968428, 3969497, 3975475, 3978566, 3981543, 3988626, 3990648, 3995661,
+    3998460, 4005513, 4007523, 4012566, 4018103, 4019138, 4025128, 4028253, 4031519, 4036714, 4038784, 4046069, 4049236, 4052257, 4058571, 4059582,
+    4063273, 4070492, 4072630, 4077763, 4083042, 4083991, 4090365, 4093320, 4097738, 4102847, 4104789, 4111904, 4115329, 4118516, 4124446, 4125547,
+    4131226, 4134383, 4140293, 4141424, 4146385, 4151460, 4153422, 4160571, 4165497, 4166412, 4172774, 4175763, 4178482, 4185671, 4187821, 4192984,
+    4197149, 4200296, 4206466, 4207607, 4212310, 4217379, 4219593, 4226748, 4230654, 4231563, 4237665, 4240660, 4243637, 4250816, 4252714, 4257887,
+    4260526, 4267739, 4269617, 4274756, 4280293, 4281232, 4287354, 4290319, 4293709, 4298808, 4301010, 4308135, 4311302, 4314483, 4320665, 4321772,
+    4325499, 4332558, 4334820, 4339857, 4345136, 4346181, 4352431, 4355546, 4359832, 4365037, 4366855, 4374130, 4377555, 4380582, 4386636, 4387641,
+    4393416, 4396477, 4402519, 4403490, 4408451, 4413686, 4415516, 4422761, 4427563, 4428638, 4434868, 4437953, 4440672, 4447765, 4450047, 4455050,
+    4457937, 4463012, 4464974, 4472123, 4475034, 4478191, 4484101, 4485232, 4490034, 4497223, 4499373, 4504536, 4509305, 4510220, 4516582, 4519571,
+    4525154, 4526103, 4532477, 4535432, 4538665, 4545884, 4548022, 4553155, 4557441, 4560628, 4566558, 4567659, 4573130, 4578239, 4580181, 4587296,
+    4591287, 4592322, 4598312, 4601437, 4604924, 4611977, 4613987, 4619030, 4622420, 4625441, 4631755, 4632766, 4637983, 4643178, 4645248, 4652533,
+    4654852, 4660081, 4662171, 4669422, 4672079, 4675130, 4681424, 4682405, 4686311, 4693394, 4695416, 4700429, 4705452, 4706521, 4712499, 4715590,
+    4721392, 4724357, 4730479, 4731418, 4736955, 4742094, 4743972, 4751185, 4754451, 4755558, 4761740, 4764921, 4768088, 4775213, 4777415, 4782514,
+    4784963, 4792118, 4794332, 4799401, 4804104, 4805245, 4811415, 4814562, 4818336, 4823509, 4825407, 4832586, 4835563, 4838558, 4844660, 4845569,
+    4850070, 4857315, 4859145, 4864380, 4869341, 4870312, 4876354, 4879415, 4884341, 4889344, 4891626, 4898719, 4901438, 4904523, 4910753, 4911828,
+    4917285, 4920400, 4926650, 4927695, 4932974, 4938011, 4940273, 4947332, 4951750, 4952755, 4958809, 4961836, 4965261, 4972536, 4974354, 4979559,
+    4981820, 4986953, 4989091, 4996310, 4999543, 5002498, 5008872, 5009821, 5014239, 5021354, 5023296, 5028405, 5033876, 5034977, 5040907, 5044094,
+    5049743, 5050874, 5056784, 5059941, 5062852, 5070001, 5071963, 5077038, 5081964, 5084953, 5091315, 5092230, 5096999, 5102162, 5104312, 5111501,
+    5115738, 5116719, 5123013, 5126064, 5128721, 5135972, 5138062, 5143291, 5147065, 5150156, 5156134, 5157203, 5162226, 5167239, 5169261, 5176344,
+    5179113, 5184156, 5186166, 5193219, 5196706, 5199831, 5205821, 5206856, 5210122, 5217407, 5219477, 5224672, 5229889, 5230900, 5237214, 5240235,
+    5245127, 5248178, 5254232, 5255213, 5260684, 5265913, 5267731, 5274982, 5279268, 5280337, 5286587, 5289678, 5292911, 5299994, 5302256, 5307269,
+    5308788, 5315841, 5318123, 5323166, 5327935, 5328970, 5335200, 5338325, 5343127, 5348322, 5350152, 5357437, 5360348, 5363369, 5369411, 5370422,
+    5374881, 5382100, 5383998, 5389131, 5394154, 5395103, 5401205, 5404160, 5408066, 5413175, 5415389, 5422504, 5425161, 5428348, 5434518, 5435619,
+    5442066, 5445223, 5451405, 5452536, 5457753, 5462828, 5465030, 5472179, 5475569, 5476484, 5482606, 5485595, 5489082, 5496271, 5498149, 5503312,
+    5506571, 5511806, 5513876, 5521121, 5524288, 5527349, 5533663, 5534634, 5538024, 5545117, 5547127, 5552130, 5557667, 5558742, 5564732, 5567817,
+    5574584, 5575629, 5581607, 5584722, 5587699, 5594758, 5596780, 5601817, 5605723, 5608750, 5615044, 5616049, 5620752, 5625957, 5628047, 5635322,
+    5639533, 5640472, 5646834, 5649799, 5652518, 5659731, 5661881, 5667020, 5671822, 5675003, 5680913, 5682020, 5686981, 5692080, 5694042, 5701167,
+    5702878, 5707947, 5709889, 5717044, 5720469, 5723616, 5729546, 5730687, 5734973, 5742152, 5744290, 5749463, 5754742, 5755651, 5762025, 5765020,
+    5769514, 5772639, 5778869, 5779904, 5784673, 5789716, 5791998, 5799051, 5803977, 5804988, 5811030, 5814051, 5816962, 5824247, 5826077, 5831272,
+    5832857, 5840108, 5841926, 5847155, 5852626, 5853607, 5859661, 5862712, 5867130, 5872143, 5874405, 5881488, 5884721, 5887812, 5894062, 5895131,
+    5898828, 5905977, 5908179, 5913254, 5918471, 5919602, 5925784, 5928941, 5932207, 5937370, 5939248, 5946437, 5949924, 5952913, 5959035, 5959950,
+    5966847, 5969802, 5975904, 5976853, 5981876, 5987009, 5988907, 5996126, 5999900, 6001001, 6007171, 6010358, 6013015, 6020130, 6022344, 6027453,
+    6031334, 6036371, 6038393, 6045452, 6048429, 6051544, 6057522, 6058567, 6062341, 6069616, 6071706, 6076911, 6081614, 6082619, 6088913, 6091940,
+    6098517, 6099488, 6105802, 6108863, 6112030, 6119275, 6121345, 6126580, 6129846, 6132931, 6138921, 6139996, 6145533, 6150536, 6152546, 6159639,
+    6163584, 6164725, 6170655, 6173802, 6177227, 6184382, 6186324, 6191393, 6195811, 6198806, 6205180, 6206089, 6211368, 6216541, 6218679, 6225858,
+    6227251, 6232390, 6234540, 6241753, 6244472, 6247437, 6253799, 6254738, 6259664, 6266789, 6268751, 6273850, 6278811, 6279918, 6285828, 6289009,
+    6294697, 6295772, 6301750, 6304835, 6308322, 6315415, 6317437, 6322440, 6326858, 6329919, 6336213, 6337184, 6342401, 6347636, 6349726, 6356971,
+    6358298, 6363503, 6365573, 6372848, 6375505, 6378532, 6384846, 6385851, 6390777, 6397836, 6399846, 6404883, 6409906, 6410951, 6416941, 6420056,
+    6424527, 6429626, 6431568, 6438693, 6441604, 6444785, 6450715, 6451822, 6455596, 6462809, 6464947, 6470086, 6474855, 6475794, 6482168, 6485133,
+    6491772, 6492681, 6499043, 6502038, 6505271, 6512450, 6514600, 6519773, 6523039, 6526186, 6532096, 6533237, 6538708, 6543777, 6545739, 6552894,
+    6554213, 6561296, 6563578, 6568591, 6573870, 6574939, 6581169, 6584260, 6587526, 6592755, 6594585, 6601836, 6605261, 6608312, 6614354, 6615335,
+    6622166, 6625187, 6631241, 6632252, 6637213, 6642408, 6644226, 6651511, 6655285, 6656320, 6662570, 6665695, 6668414, 6675467, 6677729, 6682772,
+    6686979, 6690166, 6696348, 6697449, 6702152, 6707261, 6709463, 6716578, 6721504, 6722453, 6728575, 6731530, 6734507, 6741726, 6743604, 6748737,
+    6750384, 6757573, 6759471, 6764634, 6770171, 6771086, 6777188, 6780177, 6784595, 6789670, 6791884, 6799033, 6802200, 6805357, 6811527, 6812658,
+    6819140, 6820145, 6826459, 6829486, 6832143, 6839418, 6841488, 6846693, 6851495, 6854610, 6860600, 6861645, 6866668, 6871705, 6873715, 6880774,
+    6882551, 6887554, 6889576, 6896669, 6900156, 6903241, 6909219, 6910294, 6914580, 6921825, 6923915, 6929150, 6934367, 6935338, 6941632, 6944693,
+    6948386, 6953559, 6955709, 6962888, 6966121, 6969116, 6975478, 6976387, 6979777, 6986932, 6988894, 6993963, 6999434, 7000575, 7006485, 7009632,
+    7016337, 7017444, 7023374, 7026555, 7029466, 7036591, 7038533, 7043632, 7047538, 7050503, 7056877, 7057816, 7062585, 7067724, 7069862, 7077075,
+    7078792, 7086077, 7087895, 7093090, 7098051, 7099062, 7105116, 7108137, 7112043, 7117086, 7119348, 7126401, 7129120, 7132245, 7138495, 7139530,
+    7146043, 7149134, 7155364, 7156433, 7161712, 7166725, 7169007, 7176090, 7179480, 7180461, 7186503, 7189554, 7192979, 7200230, 7202060, 7207289,
+    7211246, 7214235, 7220337, 7221252, 7226789, 7231952, 7233850, 7241039, 7245325, 7246456, 7252626, 7255783, 7258950, 7266099, 7268313, 7273388,
+    7274845, 7281960, 7284162, 7289271, 7293974, 7295075, 7301257, 7304444, 7309246, 7314379, 7316257, 7323476, 7326453, 7329408, 7335530, 7336479,
+    7343987, 7344902, 7351276, 7354265, 7356984, 7364173, 7366311, 7371474, 7375248, 7378405, 7384335, 7385466, 7390427, 7395502, 7397444, 7404593,
+    7407296, 7412405, 7414367, 7421482, 7424907, 7428094, 7434004, 7435105, 7438371, 7445590, 7447740, 7452873, 7458152, 7459101, 7465463, 7468418,
+    7472149, 7477344, 7479434, 7486719, 7489886, 7492907, 7499201, 7500212, 7504630, 7511683, 7513705, 7518748, 7524285, 7525320, 7531298, 7534423,
+    7540134, 7541203, 7547193, 7550284, 7553261, 7560344, 7562354, 7567367, 7572293, 7575344, 7581658, 7582639, 7587342, 7592571, 7594641, 7601892,
+    7602623, 7609802, 7611680, 7616853, 7621876, 7622785, 7628907, 7631902, 7636828, 7641897, 7644099, 7651254, 7653911, 7657058, 7663240, 7664381,
+    7669772, 7672953, 7679123, 7680230, 7685447, 7690546, 7692760, 7699885, 7704303, 7705242, 7711344, 7714309, 7717796, 7725009, 7726907, 7732046,
+    7736025, 7739052, 7745094, 7746099, 7751570, 7756775, 7758605, 7765880, 7769146, 7770191, 7776421, 7779536, 7782769, 7789828, 7792110, 7797147,
+    7799658, 7806751, 7809013, 7814016, 7818785, 7819860, 7826110, 7829195, 7832969, 7838204, 7840022, 7847267, 7850178, 7853239, 7859293, 7860264,
+    7868062, 7869163, 7875073, 7878260, 7881685, 7888800, 7890762, 7895871, 7899261, 7902216, 7908578, 7909527, 7914806, 7919939, 7922089, 7929308,
+    7931693, 7936856, 7938994, 7946183, 7948902, 7951891, 7958265, 7959180, 7963086, 7970235, 7972177, 7977252, 7982213, 7983344, 7989274, 7992431,
+    7996920, 8001933, 8003943, 8011026, 8014003, 8017094, 8023084, 8024153, 8028955, 8036206, 8038276, 8043505, 8048208, 8049189, 8055503, 8058554,
+    8064075, 8065086, 8071380, 8074401, 8077568, 8084853, 8086943, 8092138, 8096424, 8099549, 8105527, 8106562, 8112099, 8117142, 8119164, 8126217,
+    8126546, 8133671, 8135885, 8140984, 8146201, 8147308, 8153478, 8156659, 8160945, 8166084, 8167982, 8175195, 8178682, 8181647, 8187749, 8188688,
+    8194529, 8197524, 8203646, 8204555, 8209578, 8214751, 8216629, 8223808, 8228610, 8229751, 8235933, 8239080, 8241737, 8248892, 8251094, 8256163,
+    8260404, 8263489, 8269739, 8270814, 8275583, 8280586, 8282848, 8289941, 8293847, 8294818, 8300872, 8303933, 8306844, 8314089, 8315907, 8321142,
+    8323719, 8330994, 8332824, 8338029, 8343500, 8344505, 8350547, 8353574, 8356964, 8362001, 8364283, 8371342, 8374575, 8377690, 8383920, 8384965,
+    8392250, 8393295, 8399525, 8402640, 8405873, 8412932, 8415214, 8420251, 8423641, 8426668, 8432710, 8433715, 8439186, 8444391, 8446221, 8453496,
+    8456073, 8461308, 8463126, 8470371, 8473282, 8476343, 8482397, 8483368, 8487274, 8494367, 8496629, 8501632, 8506401, 8507476, 8513726, 8516811,
+    8521052, 8526121, 8528323, 8535478, 8538135, 8541282, 8547464, 8548605, 8553407, 8560586, 8562464, 8567637, 8572660, 8573569, 8579691, 8582686,
+    8588527, 8589466, 8595568, 8598533, 8602020, 8609233, 8611131, 8616270, 8620556, 8623737, 8629907, 8631014, 8636231, 8641330, 8643544, 8650669,
+    8650998, 8658051, 8660073, 8665116, 8670653, 8671688, 8677666, 8680791, 8685077, 8690272, 8692362, 8699647, 8702814, 8705835, 8712129, 8713140,
+    8718661, 8721712, 8728026, 8729007, 8733710, 8738939, 8741009, 8748260, 8753062, 8754131, 8760121, 8763212, 8766189, 8773272, 8775282, 8780295,
+    8784784, 8787941, 8793871, 8795002, 8799963, 8805038, 8806980, 8814129, 8818035, 8818950, 8825324, 8828313, 8831032, 8838221, 8840359, 8845522,
+    8847907, 8855126, 8857276, 8862409, 8867688, 8868637, 8874999, 8877954, 8881344, 8886453, 8888415, 8895530, 8898955, 8902142, 8908052, 8909153,
+    8916951, 8917922, 8923976, 8927037, 8929948, 8937193, 8939011, 8944246, 8948020, 8951105, 8957355, 8958430, 8963199, 8968202, 8970464, 8977557,
+    8980068, 8985105, 8987387, 8994446, 8997679, 9000794, 9007024, 9008069, 9011335, 9018610, 9020440, 9025645, 9031116, 9032121, 9038163, 9041190,
+    9045169, 9050308, 9052206, 9059419, 9062906, 9065871, 9071973, 9072912, 9077330, 9084455, 9086669, 9091768, 9096985, 9098092, 9104262, 9107443,
+    9112834, 9113975, 9120157, 9123304, 9125961, 9133116, 9135318, 9140387, 9145313, 9148308, 9154430, 9155339, 9160362, 9165535, 9167413, 9174592,
+    9175323, 9182574, 9184644, 9189873, 9194576, 9195557, 9201871, 9204922, 9209848, 9214861, 9216871, 9223954, 9226931, 9230022, 9236012, 9237081,
+    9242792, 9245917, 9251895, 9252930, 9258467, 9263510, 9265532, 9272585, 9277003, 9278014, 9284308, 9287329, 9290496, 9297781, 9299871, 9305066,
+    9308797, 9311752, 9318114, 9319063, 9324342, 9329475, 9331625, 9338844, 9342110, 9343211, 9349121, 9352308, 9355733, 9362848, 9364810, 9369919,
+    9372622, 9379771, 9381713, 9386788, 9391749, 9392880, 9398810, 9401967, 9405741, 9410904, 9413042, 9420231, 9422950, 9425939, 9432313, 9433228,
+    9440736, 9441685, 9447807, 9450762, 9453739, 9460958, 9462836, 9467969, 9472771, 9475958, 9482140, 9483241, 9487944, 9493053, 9495255, 9502370,
+    9503827, 9508902, 9511116, 9518265, 9521432, 9524589, 9530759, 9531890, 9536176, 9543365, 9545263, 9550426, 9555963, 9556878, 9562980, 9565969,
+    9569926, 9575155, 9576985, 9584236, 9587661, 9590712, 9596754, 9597735, 9601125, 9608208, 9610490, 9615503, 9620782, 9621851, 9628081, 9631172,
+    9637685, 9638720, 9644970, 9648095, 9650814, 9657867, 9660129, 9665172, 9669078, 9672099, 9678153, 9679164, 9684125, 9689320, 9691138, 9698423,
+    9700140, 9707353, 9709491, 9714630, 9719399, 9720338, 9726712, 9729677, 9733583, 9738682, 9740624, 9747749, 9750660, 9753841, 9759771, 9760878,
+    9767583, 9770730, 9776640, 9777781, 9783252, 9788321, 9790283, 9797438, 9800828, 9801737, 9808099, 9811094, 9814327, 9821506, 9823656, 9828829,
+    9832522, 9835583, 9841877, 9842848, 9848065, 9853300, 9855390, 9862635, 9866921, 9867996, 9873974, 9877059, 9880546, 9887639, 9889661, 9894664,
+    9896441, 9903500, 9905510, 9910547, 9915570, 9916615, 9922605, 9925720, 9930522, 9935727, 9937797, 9945072, 9947729, 9950756, 9957070, 9958075,
+    9964557, 9965688, 9971858, 9975015, 9978182, 9985331, 9987545, 9992620, 9997038, 10000027, 10006129, 10007044, 10012581, 10017744, 10019642, 10026831,
+    10028478, 10033611, 10035489, 10042708, 10045685, 10048640, 10054762, 10055711, 10060637, 10067752, 10069954, 10075063, 10079766, 10080867, 10087049, 10090236,
+    10094443, 10099486, 10101748, 10108801, 10111520, 10114645, 10120895, 10121930, 10125704, 10132989, 10134807, 10140002, 10144963, 10145974, 10152028, 10155049,
+    10161880, 10162861, 10168903, 10171954, 10175379, 10182630, 10184460, 10189689, 10192955, 10196046, 10202276, 10203345, 10208624, 10213637, 10215919, 10223002,
+    10224321, 10231476, 10233438, 10238507, 10243978, 10245119, 10251029, 10254176, 10257442, 10262615, 10264765, 10271944, 10275177, 10278172, 10284534, 10285443,
+    10292082, 10295047, 10301421, 10302360, 10307129, 10312268, 10314406, 10321619, 10325393, 10326500, 10332430, 10335611, 10338522, 10345647, 10347589, 10352688,
+    10357159, 10360274, 10366264, 10367309, 10372332, 10377369, 10379379, 10386438, 10391364, 10392369, 10398683, 10401710, 10404367, 10411642, 10413712, 10418917,
+    10420244, 10427489, 10429579, 10434814, 10440031, 10441002, 10447296, 10450357, 10454775, 10459778, 10461800, 10468893, 10472380, 10475465, 10481443, 10482518,
+    10488206, 10491387, 10497297, 10498404, 10503365, 10508464, 10510426, 10517551, 10522477, 10523416, 10529778, 10532743, 10535462, 10542675, 10544825, 10549964,
+    10551357, 10558536, 10560674, 10565847, 10571126, 10572035, 10578409, 10581404, 10585822, 10590891, 10592833, 10599988, 10603413, 10606560, 10612490, 10613631,
+    10617576, 10624669, 10626679, 10631682, 10637219, 10638294, 10644284, 10647369, 10650635, 10655870, 10657940, 10665185, 10668352, 10671413, 10677727, 10678698,
+    10685275, 10688302, 10694596, 10695601, 10700304, 10705509, 10707599, 10714874, 10718648, 10719693, 10725671, 10728786, 10731763, 10738822, 10740844, 10745881,
+    10749762, 10754871, 10757085, 10764200, 10766857, 10770044, 10776214, 10777315, 10781089, 10788308, 10790206, 10795339, 10800362, 10801311, 10807413, 10810368,
+    10817265, 10818180, 10824302, 10827291, 10830778, 10837967, 10839845, 10845008, 10848274, 10851431, 10857613, 10858744, 10863961, 10869036, 10871238, 10878387,
+    10882084, 10883153, 10889403, 10892494, 10895727, 10902810, 10905072, 10910085, 10914503, 10917554, 10923608, 10924589, 10930060, 10935289, 10937107, 10944358,
+    10945943, 10951138, 10952968, 10960253, 10963164, 10966185, 10972227, 10973238, 10978164, 10985217, 10987499, 10992542, 10997311, 10998346, 11004576, 11007701,
+    11012195, 11015190, 11021564, 11022473, 11027752, 11032925, 11035063, 11042242, 11046528, 11047669, 11053599, 11056746, 11060171, 11067326, 11069268, 11074337,
+    11076048, 11083173, 11085135, 11090234, 11095195, 11096302, 11102212, 11105393, 11110195, 11115334, 11117484, 11124697, 11127416, 11130381, 11136743, 11137682,
+    11141893, 11149168, 11151258, 11156463, 11161166, 11162171, 11168465, 11171492, 11175398, 11180435, 11182457, 11189516, 11192493, 11195608, 11201586, 11202631,
+    11209398, 11212483, 11218473, 11219548, 11225085, 11230088, 11232098, 11239191, 11242581, 11243552, 11249866, 11252927, 11256094, 11263339, 11265409, 11270644,
+    11273903, 11279066, 11280944, 11288133, 11291620, 11294609, 11300731, 11301646, 11305036, 11312185, 11314387, 11319462, 11324679, 11325810, 11331992, 11335149,
+    11341596, 11342697, 11348867, 11352054, 11354711, 11361826, 11364040, 11369149, 11373055, 11376010, 11382112, 11383061, 11388084, 11393217, 11395115, 11402334,
+    11406793, 11407804, 11413846, 11416867, 11419778, 11427063, 11428893, 11434088, 11438890, 11442015, 11448245, 11449280, 11454049, 11459092, 11461374, 11468427,
+    11469946, 11474959, 11477221, 11484304, 11487537, 11490628, 11496878, 11497947, 11502233, 11509484, 11511302, 11516531, 11522002, 11522983, 11529037, 11532088,
+    11536980, 11540001, 11546315, 11547326, 11552543, 11557738, 11559808, 11567093, 11570359, 11571394, 11577384, 11580509, 11583996, 11591049, 11593059, 11598102,
+    11600871, 11607954, 11609976, 11614989, 11620012, 11621081, 11627059, 11630150, 11633924, 11639153, 11641243, 11648494, 11651151, 11654202, 11660496, 11661477,
+    11665714, 11672903, 11675053, 11680216, 11684985, 11685900, 11692262, 11695251, 11700177, 11705252, 11707214, 11714363, 11717274, 11720431, 11726341, 11727472,
+    11733121, 11736308, 11742238, 11743339, 11748810, 11753919, 11755861, 11762976, 11767394, 11768343, 11774717, 11777672, 11780905, 11788124, 11790262, 11795395,
+    11797656, 11802861, 11804679, 11811954, 11815379, 11818406, 11824460, 11825465, 11829883, 11836942, 11839204, 11844241, 11849520, 11850565, 11856815, 11859930,
+    11865387, 11866462, 11872692, 11875777, 11878496, 11885589, 11887871, 11892874, 11897800, 11900861, 11906903, 11907874, 11912835, 11918070, 11919900, 11927145,
+    11931646, 11932555, 11938657, 11941652, 11944629, 11951808, 11953706, 11958879, 11962653, 11965800, 11971970, 11973111, 11977814, 11982883, 11985097, 11992252,
+    11994701, 11999800, 12002002, 12009127, 12012294, 12015475, 12021657, 12022764, 12026030, 12033243, 12035121, 12040260, 12045797, 12046736, 12052858, 12055823,
+    12061625, 12064716, 12070694, 12071763, 12076786, 12081799, 12083821, 12090904, 12094810, 12095791, 12102085, 12105136, 12107793, 12115044, 12117134, 12122363,
+    12124682, 12131967, 12134037, 12139232, 12144449, 12145460, 12151774, 12154795, 12158185, 12163228, 12165238, 12172291, 12175778, 12178903, 12184893, 12185928,
+    12189919, 12197034, 12198976, 12204085, 12209556, 12210657, 12216587, 12219774, 12224060, 12229193, 12231331, 12238550, 12241783, 12244738, 12251112, 12252061,
+    12257644, 12260633, 12266995, 12267910, 12272679, 12277842, 12279992, 12287181, 12291983, 12293114, 12299024, 12302181, 12305092, 12312241, 12314203, 12319278,
+    12322165, 12327168, 12329450, 12336543, 12339262, 12342347, 12348577, 12349652, 12354454, 12361699, 12363529, 12368764, 12373725, 12374696, 12380738, 12383799,
+    12389574, 12390579, 12396633, 12399660, 12403085, 12410360, 12412178, 12417383, 12421669, 12424784, 12431034, 12432079, 12437358, 12442395, 12444657, 12451716,
+    12455443, 12456550, 12462732, 12465913, 12469080, 12476205, 12478407, 12483506, 12486896, 12489861, 12495983, 12496922, 12502459, 12507598, 12509476, 12516689,
+    12519328, 12524501, 12526399, 12533578, 12536555, 12539550, 12545652, 12546561, 12550467, 12557622, 12559836, 12564905, 12569608, 12570749, 12576919, 12580066,
+    12584231, 12589394, 12591544, 12598733, 12601452, 12604441, 12610803, 12611718, 12616644, 12623793, 12625755, 12630830, 12635791, 12636922, 12642832, 12645989,
+    12651668, 12652769, 12658699, 12661886, 12665311, 12672426, 12674368, 12679477, 12683895, 12686850, 12693224, 12694173, 12699452, 12704585, 12706723, 12713942,
+    12717633, 12718644, 12724958, 12727979, 12731146, 12738431, 12740501, 12745696, 12748962, 12752087, 12758077, 12759112, 12764649, 12769692, 12771702, 12778755,
+    12781554, 12786567, 12788589, 12795672, 12798649, 12801740, 12807718, 12808787, 12812561, 12819812, 12821902, 12827131, 12831834, 12832815, 12839109, 12842160,
+    12848107, 12851102, 12857204, 12858113, 12863136, 12868309, 12870207, 12877386, 12881160, 12882301, 12888471, 12891618, 12894275, 12901430, 12903644, 12908713,
+    12911192, 12918317, 12920519, 12925618, 12930835, 12931942, 12938124, 12941305, 12944571, 12949710, 12951588, 12958801, 12962288, 12965253, 12971375, 12972314,
+    12976269, 12983544, 12985362, 12990567, 12996038, 12997043, 13003097, 13006124, 13010542, 13015579, 13017841, 13024900, 13028133, 13031248, 13037498, 13038543,
+    13044030, 13047115, 13053345, 13054420, 13059189, 13064192, 13066474, 13073567, 13078493, 13079464, 13085506, 13088567, 13091478, 13098723, 13100553, 13105788,
+    13108426, 13113535, 13115477, 13122592, 13126017, 13129204, 13135134, 13136235, 13140521, 13147740, 13149878, 13155011, 13160290, 13161239, 13167613, 13170568,
+    13176185, 13177100, 13183462, 13186451, 13189170, 13196359, 13198509, 13203672, 13208474, 13211631, 13217541, 13218672, 13223633, 13228708, 13230670, 13237819,
+    13242284, 13243353, 13249331, 13252422, 13255399, 13262482, 13264504, 13269517, 13273423, 13276474, 13282768, 13283749, 13288452, 13293681, 13295771, 13303022,
+    13305375, 13310570, 13312640, 13319925, 13323092, 13326113, 13332427, 13333438, 13336828, 13343881, 13345891, 13350934, 13356471, 13357506, 13363496, 13366621,
+    13371910, 13375091, 13381273, 13382380, 13387597, 13392696, 13394898, 13402023, 13405413, 13406352, 13412474, 13415439, 13418926, 13426139, 13428017, 13433156,
+    13435829, 13443008, 13444906, 13450079, 13455102, 13456011, 13462113, 13465108, 13469014, 13474083, 13476297, 13483452, 13486109, 13489256, 13495426, 13496567,
+    13500768, 13507861, 13510143, 13515146, 13519915, 13520990, 13527220, 13530305, 13535107, 13540342, 13542172, 13549417, 13552328, 13555389, 13561431, 13562402,
+    13568211, 13571238, 13577292, 13578297, 13583768, 13588973, 13590791, 13598066, 13602352, 13603397, 13609647, 13612762, 13615995, 13623054, 13625316, 13630353,
+    13633277, 13638280, 13640290, 13647383, 13650870, 13653955, 13659945, 13661020, 13664286, 13671531, 13673601, 13678836, 13684053, 13685024, 13691338, 13694399,
+    13700942, 13701947, 13708241, 13711268, 13713925, 13721200, 13723290, 13728495, 13732269, 13735384, 13741362, 13742407, 13747430, 13752467, 13754489, 13761548,
+    13766043, 13767150, 13773060, 13776241, 13779152, 13786277, 13788239, 13793338, 13798264, 13801229, 13807591, 13808530, 13813299, 13818438, 13820588, 13827801,
+    13829160, 13834333, 13836471, 13843650, 13846883, 13849878, 13856252, 13857161, 13861579, 13868734, 13870676, 13875745, 13881216, 13882357, 13888287, 13891434,
+    13895729, 13898820, 13905070, 13906139, 13911418, 13916431, 13918693, 13925776, 13930194, 13931175, 13937229, 13940280, 13943705, 13950956, 13952774, 13958003,
+    13959554, 13966839, 13968669, 13973864, 13978825, 13979836, 13985878, 13988899, 13993825, 13998868, 14001150, 14008203, 14010922, 14014047, 14020277, 14021312,
+    14025559, 14032674, 14034888, 14039997, 14044700, 14045801, 14051971, 14055158, 14058932, 14064065, 14065963, 14073182, 14076159, 14079114, 14085216, 14086165,
+    14093028, 14096017, 14102139, 14103054, 14108591, 14113754, 14115632, 14122821, 14126087, 14127218, 14133400, 14136557, 14139724, 14146873, 14149075, 14154150,
+    14157584, 14162789, 14164879, 14172154, 14174811, 14177838, 14184132, 14185137, 14189043, 14196102, 14198124, 14203161, 14208184, 14209229, 14215207, 14218322,
+    14225059, 14226134, 14232124, 14235209, 14238696, 14245789, 14247799, 14252802, 14256192, 14259253, 14265567, 14266538, 14271755, 14276990, 14279060, 14286305,
+    14290038, 14290947, 14297321, 14300316, 14303549, 14310728, 14312866, 14318039, 14322325, 14325472, 14331402, 14332543, 14338014, 14343083, 14345025, 14352180,
+    14353861, 14358960, 14360922, 14368047, 14370958, 14374139, 14380049, 14381156, 14385958, 14393171, 14395321, 14400460, 14405229, 14406168, 14412530, 14415495,
+    14420444, 14423465, 14429507, 14430518, 14435479, 14440674, 14442504, 14449789, 14454591, 14455626, 14461856, 14464981, 14467700, 14474753, 14477035, 14482078,
+    14483567, 14490650, 14492912, 14497925, 14503204, 14504273, 14510523, 14513614, 14517900, 14523129, 14524947, 14532198, 14535623, 14538674, 14544728, 14545709,
+    14549690, 14556879, 14558757, 14563920, 14569457, 14570372, 14576494, 14579483, 14582873, 14587948, 14590150, 14597299, 14600466, 14603623, 14609805, 14610936,
+    14617353, 14620540, 14626710, 14627811, 14632514, 14637623, 14639837, 14646952, 14650858, 14651807, 14657909, 14660864, 14663841, 14671060, 14672958, 14678091,
+    14680723, 14687974, 14689804, 14695033, 14700504, 14701485, 14707527, 14710578, 14713968, 14718981, 14721263, 14728346, 14731579, 14734670, 14740900, 14741969,
+    14748448, 14751573, 14757823, 14758858, 14763627, 14768670, 14770932, 14777985, 14781891, 14782902, 14788956, 14791977, 14794888, 14802173, 14803991, 14809186,
+    14813685, 14816640, 14822762, 14823711, 14828734, 14833867, 14835745, 14842964, 14847766, 14848867, 14855049, 14858236, 14860893, 14868008, 14870210, 14875319,
+    14876742, 14883891, 14886105, 14891180, 14896397, 14897528, 14903698, 14906855, 14911141, 14916304, 14918202, 14925391, 14928878, 14931867, 14937969, 14938884,
+    14945375, 14946346, 14952640, 14955701, 14958868, 14966113, 14968203, 14973438, 14977724, 14980809, 14986787, 14987862, 14993399, 14998402, 15000424, 15007517,
+    15009260, 15014297, 15016307, 15023366, 15026343, 15029458, 15035448, 15036493, 15041295, 15048570, 15050640, 15055845, 15060548, 15061553, 15067867, 15070894,
+    15075129, 15080268, 15082406, 15089619, 15092338, 15095303, 15101677, 15102616, 15106522, 15113647, 15115589, 15120688, 15125649, 15126756, 15132686, 15135867,
+    15142538, 15143679, 15149589, 15152736, 15156161, 15163316, 15165278, 15170347, 15173737, 15176732, 15183094, 15184003, 15189282, 15194455, 15196605, 15203784,
+    15205246, 15212299, 15214561, 15219604, 15224373, 15225408, 15231658, 15234783, 15238557, 15243752, 15245570, 15252855, 15255766, 15258787, 15264841, 15265852,
+    15272653, 15275704, 15281746, 15282727, 15288198, 15293427, 15295257, 15302508, 15305774, 15306843, 15313073, 15316164, 15319397, 15326480, 15328762, 15333775,
+    15337496, 15340653, 15346823, 15347954, 15353171, 15358246, 15360460, 15367609, 15372027, 15372942, 15379044, 15382033, 15385520, 15392709, 15394607, 15399770,
+    15401387, 15408606, 15410484, 15415617, 15420640, 15421589, 15427711, 15430666, 15435592, 15440701, 15442903, 15450018, 15452675, 15455862, 15462044, 15463145,
+    15470002, 15471047, 15477037, 15480152, 15483129, 15490188, 15492198, 15497235, 15502161, 15505188, 15511502, 15512507, 15517210, 15522415, 15524485, 15531760,
+    15533057, 15538292, 15540382, 15547627, 15550794, 15553855, 15560149, 15561120, 15565538, 15572631, 15574653, 15579656, 15585193, 15586268, 15592246, 15595331,
+    15599316, 15604385, 15606347, 15613502, 15616927, 15620074, 15625984, 15627125, 15630391, 15637570, 15639720, 15644893, 15650172, 15651081, 15657443, 15660438,
+    15667047, 15667986, 15674360, 15677325, 15680044, 15687257, 15689395, 15694534, 15698308, 15701489, 15707419, 15708526, 15713487, 15718586, 15720528, 15727653,
+    15728969, 15736124, 15738326, 15743395, 15748098, 15749239, 15755421, 15758568, 15763370, 15768543, 15770421, 15777600, 15780577, 15783572, 15789694, 15790603,
+    15796474, 15799439, 15805541, 15806480, 15812017, 15817156, 15819054, 15826267, 15830553, 15831660, 15837830, 15841011, 15844178, 15851303, 15853517, 15858616,
+    15862319, 15865434, 15871664, 15872709, 15877988, 15883025, 15885307, 15892366, 15895756, 15896761, 15902803, 15905830, 15909255, 15916530, 15918360, 15923565,
+    15926172, 15933417, 15935235, 15940470, 15945431, 15946402, 15952456, 15955517, 15959423, 15964426, 15966688, 15973781, 15976500, 15979585, 15985835, 15986910,
+    15994757, 15995888, 16001818, 16004975, 16007886, 16015035, 16016977, 16022052, 16025958, 16028947, 16035321, 16036236, 16041005, 16046168, 16048306, 16055495,
+    16057910, 16063043, 16065193, 16072412, 16075645, 16078600, 16084962, 16085911, 16089301, 16096416, 16098378, 16103487, 16108958, 16110059, 16115969, 16119156,
+    16123107, 16128150, 16130172, 16137225, 16140712, 16143837, 16149815, 16150850, 16155136, 16162421, 16164511, 16169706, 16174923, 16175934, 16182228, 16185249,
+    16190800, 16191781, 16198095, 16201146, 16203803, 16211054, 16213124, 16218353, 16223155, 16226246, 16232236, 16233305, 16238328, 16243341, 16245351, 16252434,
+    16253092, 16260305, 16262203, 16267342, 16272879, 16273818, 16279920, 16282885, 16287303, 16292402, 16294616, 16301741, 16304908, 16308089, 16314259, 16315366,
+    16320791, 16323938, 16330120, 16331261, 16335964, 16341033, 16343235, 16350390, 16355316, 16356225, 16362347, 16365342, 16368319, 16375498, 16377376, 16382549,
+    16387010, 16390071, 16396125, 16397096, 16402057, 16407292, 16409110, 16416355, 16420129, 16421204, 16427454, 16430539, 16433258, 16440351, 16442613, 16447616,
+    16450161, 16457220, 16459502, 16464539, 16469818, 16470863, 16477093, 16480208, 16483474, 16488679, 16490509, 16497784, 16501209, 16504236, 16510278, 16511283,
+    16518760, 16519709, 16526071, 16529026, 16532259, 16539478, 16541628, 16546761, 16550027, 16553214, 16559124, 16560225, 16565696, 16570805, 16572767, 16579882,
+    16582619, 16587694, 16589636, 16596785, 16599696, 16602853, 16608783, 16609914, 16613688, 16620877, 16623015, 16628178, 16632947, 16633862, 16640236, 16643225,
+    16647438, 16652667, 16654737, 16661988, 16664645, 16667696, 16674010, 16674991, 16679917, 16687000, 16689010, 16694023, 16699046, 16700115, 16706105, 16709196,
+    16714941, 16715976, 16721954, 16725079, 16728566, 16735619, 16737641, 16742684, 16747102, 16750123, 16756417, 16757428, 16762645, 16767840, 16769930, 16777215
+};
+
+static const int dec_tab[] =
+{
+    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 147488,
+    16, 17, 18, 19, 20, 21, 22, 4268032, 24, 25, 26, 1574912, 28, 2097920, 294976, 5248,
+    32, 33, 34, 35, 36, 37, 38, 147464, 40, 41, 42, 147460, 44, 147458, 147457, 147456,
+    48, 49, 50, 33152, 52, 3136, 3149824, 786944, 56, 274432, 4195840, 2162752, 589952, 5275648, 10496, 147472,
+    64, 65, 66, 67, 68, 69, 70, 2621568, 72, 73, 74, 9472, 76, 1118208, 294928, 4196864,
+    80, 81, 82, 135680, 84, 3104, 294920, 1065216, 88, 4210816, 294916, 2162720, 294914, 663552, 294912, 294913,
+    96, 97, 98, 5505024, 100, 3088, 66304, 45056, 104, 557568, 6272, 2162704, 6299648, 262528, 1573888, 147520,
+    112, 3076, 548864, 2162696, 3073, 3072, 4325504, 3074, 1179904, 2162690, 2162689, 2162688, 20992, 3080, 294944, 2162692,
+    128, 129, 130, 131, 132, 133, 134, 2621504, 136, 137, 138, 328192, 140, 43008, 5243136, 5136,
+    144, 145, 146, 33056, 148, 1441792, 18944, 5128, 152, 4210752, 2236416, 5124, 589856, 5122, 5121, 5120,
+    160, 161, 162, 33040, 164, 4198912, 271360, 1116160, 168, 3146752, 6208, 4726784, 589840, 262464, 2130432, 147584,
+    176, 33026, 33025, 33024, 589832, 2121728, 4325440, 33028, 589828, 133632, 1327104, 33032, 589824, 589825, 589826, 5152,
+    192, 193, 194, 2621444, 196, 2621442, 2621441, 2621440, 200, 4210704, 6176, 1212416, 132608, 262432, 90112, 2621448,
+    208, 4210696, 1115136, 272384, 12544, 98816, 4325408, 2621456, 4210689, 4210688, 525056, 4210690, 3147776, 4210692, 295040, 5184,
+    224, 204800, 6152, 17920, 1097728, 262408, 4325392, 2621472, 6146, 262404, 6144, 6145, 262401, 262400, 6148, 262402,
+    2359808, 1576960, 4325380, 33088, 4325378, 3200, 4325376, 4325377, 41984, 4210720, 6160, 2162816, 589888, 262416, 4325384, 1057280,
+    256, 257, 258, 259, 260, 261, 262, 268288, 264, 265, 266, 9280, 268, 2097680, 5243008, 622592,
+    272, 273, 274, 32928, 276, 2097672, 656384, 1065024, 280, 2097668, 86016, 4587520, 2097665, 2097664, 10272, 2097666,
+    288, 289, 290, 32912, 292, 1581056, 66112, 6292480, 296, 4261888, 2883584, 1053184, 37888, 262336, 10256, 147712,
+    304, 32898, 32897, 32896, 4472832, 200704, 10248, 32900, 1179712, 541696, 10244, 32904, 10242, 2097696, 10240, 10241,
+    320, 321, 322, 9224, 324, 4358144, 66080, 1064976, 328, 9218, 9217, 9216, 542720, 262304, 2232320, 9220,
+    336, 851968, 6293504, 1064964, 12416, 1064962, 1064961, 1064960, 1179680, 38912, 524928, 9232, 4260864, 2097728, 295168, 1064968,
+    352, 2117632, 66052, 657408, 66050, 262280, 66048, 66049, 1179664, 262276, 4243456, 9248, 262273, 262272, 66056, 262274,
+    1179656, 4203008, 267264, 32960, 2654208, 3328, 66064, 1064992, 1179648, 1179649, 1179650, 2162944, 1179652, 262288, 10304, 4722688,
+    384, 385, 386, 32816, 388, 82944, 5242888, 139776, 392, 659456, 5242884, 2115584, 5242882, 262240, 5242880, 5242881,
+    400, 32802, 32801, 32800, 12352, 4720640, 2424832, 32804, 265216, 1122304, 524864, 32808, 180224, 2097792, 5242896, 5376,
+    416, 32786, 32785, 32784, 2230272, 262216, 544768, 32788, 25088, 262212, 197632, 32792, 262209, 262208, 5242912, 262210,
+    32771, 32770, 32769, 32768, 1050112, 32774, 32773, 32772, 6295552, 32778, 32777, 32776, 590080, 262224, 10368, 32780,
+    448, 1051136, 409600, 4263936, 12304, 262184, 35840, 2621696, 2195456, 262180, 524816, 9344, 262177, 262176, 5242944, 262178,
+    12292, 2229248, 524808, 32864, 12288, 12289, 12290, 1065088, 524802, 4210944, 524800, 524801, 12296, 262192, 524804, 198656,
+    4719616, 262156, 3153920, 32848, 262153, 262152, 66176, 262154, 262149, 262148, 6400, 262150, 262145, 262144, 262147, 262146,
+    83968, 32834, 32833, 32832, 12320, 262168, 4325632, 32836, 1179776, 262164, 524832, 32840, 262161, 262160, 2114560, 262162,
+    512, 513, 514, 515, 516, 517, 518, 1082368, 520, 521, 522, 327808, 524, 2097424, 536576, 4196416,
+    528, 529, 530, 135232, 532, 2097416, 18560, 786464, 536, 2097412, 4195360, 57344, 2097409, 2097408, 1245184, 2097410,
+    544, 545, 546, 2107392, 548, 4198528, 65856, 786448, 552, 557120, 4195344, 1052928, 1312768, 74752, 2130048, 147968,
+    560, 1130496, 4195336, 786436, 172032, 786434, 786433, 786432, 4195330, 133248, 4195328, 4195329, 20544, 2097440, 4195332, 786440,
+    576, 577, 578, 135184, 580, 286720, 65824, 4196360, 584, 557088, 3162112, 4196356, 132224, 4196354, 4196353, 4196352,
+    592, 135170, 135169, 135168, 5767168, 98432, 2106368, 135172, 75776, 1311744, 524672, 135176, 20512, 2097472, 295424, 4196368,
+    608, 557064, 65796, 17536, 65794, 3276800, 65792, 65793, 557057, 557056, 401408, 557058, 20496, 557060, 65800, 4196384,
+    2359424, 4202752, 1083392, 135200, 20488, 3584, 65808, 786496, 20484, 557072, 4195392, 2163200, 20480, 20481, 20482, 1056896,
+    640, 641, 642, 327688, 644, 4198432, 18448, 139520, 648, 327682, 327681, 327680, 132160, 1589248, 2129952, 327684,
+    656, 533504, 18436, 7340032, 18434, 98368, 18432, 18433, 1085440, 133152, 524608, 327696, 4464640, 2097536, 18440, 5632,
+    672, 4198404, 1703936, 17472, 4198401, 4198400, 2129928, 4198402, 24832, 133136, 2129924, 327712, 2129922, 4198408, 2129920, 2129921,
+    2359360, 133128, 77824, 33536, 1049856, 4198416, 18464, 786560, 133121, 133120, 4195456, 133122, 590336, 133124, 2129936, 1056832,
+    704, 1050880, 4235264, 17440, 132104, 98320, 1314816, 2621952, 132100, 2109440, 524560, 327744, 132096, 132097, 132098, 4196480,
+    2359328, 98308, 524552, 135296, 98305, 98304, 18496, 98306, 524546, 4211200, 524544, 524545, 132112, 98312, 524548, 1056800,
+    2359312, 17410, 17409, 17408, 534528, 4198464, 65920, 17412, 5308416, 557184, 6656, 17416, 132128, 262912, 2129984, 1056784,
+    2359296, 2359297, 2359298, 17424, 2359300, 98336, 4325888, 1056776, 2359304, 133184, 524576, 1056772, 20608, 1056770, 1056769, 1056768,
+    768, 769, 770, 4734976, 772, 2097176, 65632, 139392, 776, 2097172, 165888, 1052704, 2097169, 2097168, 279552, 2097170,
+    784, 2097164, 1318912, 68608, 2097161, 2097160, 4231168, 2097162, 2097157, 2097156, 524480, 2097158, 2097153, 2097152, 2097155, 2097154,
+    800, 394240, 65604, 1052680, 65602, 51200, 65600, 65601, 24704, 1052674, 1052673, 1052672, 4849664, 2097200, 65608, 1052676,
+    530432, 4202560, 2244608, 33408, 1049728, 2097192, 65616, 786688, 360448, 2097188, 4195584, 1052688, 2097185, 2097184, 10752, 2097186,
+    832, 1050752, 65572, 2392064, 65570, 529408, 65568, 65569, 4460544, 212992, 524432, 9728, 1089536, 2097232, 65576, 4196608,
+    50176, 4202528, 524424, 135424, 395264, 2097224, 65584, 1065472, 524418, 2097220, 524416, 524417, 2097217, 2097216, 524420, 2097218,
+    65542, 4202512, 65540, 65541, 65538, 65539, 65536, 65537, 2100224, 557312, 65548, 1052736, 65546, 262784, 65544, 65545,
+    4202497, 4202496, 65556, 4202498, 65554, 4202500, 65552, 65553, 1180160, 4202504, 524448, 280576, 20736, 2097248, 65560, 164864,
+    896, 1050688, 2102272, 139268, 819200, 139266, 139265, 139264, 24608, 4228096, 524368, 327936, 71680, 2097296, 5243392, 139272,
+    4390912, 282624, 524360, 33312, 1049632, 2097288, 18688, 139280, 524354, 2097284, 524352, 524353, 2097281, 2097280, 524356, 2097282,
+    24584, 2686976, 4458496, 33296, 1049616, 4198656, 65728, 139296, 24576, 24577, 24578, 1052800, 24580, 262720, 2130176, 527360,
+    1049604, 33282, 33281, 33280, 1049600, 1049601, 1049602, 33284, 24592, 133376, 524384, 33288, 1049608, 2097312, 397312, 4276224,
+    1050625, 1050624, 524312, 1050626, 6307840, 1050628, 65696, 139328, 524306, 1050632, 524304, 524305, 132352, 262688, 524308, 53248,
+    524298, 1050640, 524296, 524297, 12800, 98560, 524300, 4457472, 524290, 524291, 524288, 524289, 524294, 2097344, 524292, 524293,
+    167936, 1050656, 65668, 17664, 65666, 262664, 65664, 65665, 24640, 262660, 524336, 6422528, 262657, 262656, 65672, 262658,
+    2359552, 4202624, 524328, 33344, 1049664, 671744, 65680, 2103296, 524322, 70656, 524320, 524321, 4229120, 262672, 524324, 1057024,
+    1024, 1025, 1026, 1027, 1028, 1029, 1030, 1081856, 1032, 1033, 1034, 8512, 1036, 4980736, 2164736, 4240,
+    1040, 1041, 1042, 2375680, 1044, 2144, 655616, 4232, 1048, 229376, 4194848, 4228, 1073152, 4226, 4225, 4224,
+    1056, 1057, 1058, 593920, 1060, 2128, 270464, 6291712, 1064, 3145856, 4194832, 296960, 37120, 74240, 1572928, 148480,
+    1072, 2116, 4194824, 1187840, 2113, 2112, 114688, 2114, 4194818, 540928, 4194816, 4194817, 2490368, 2120, 4194820, 4256,
+    1088, 1089, 1090, 8456, 1092, 2096, 4214784, 458752, 1096, 8450, 8449, 8448, 131712, 2146304, 1572896, 8452,
+    1104, 2084, 1114240, 4751360, 2081, 2080, 2105856, 2082, 2625536, 1311232, 149504, 8464, 4260096, 2088, 295936, 4288,
+    1120, 2068, 2260992, 17024, 2065, 2064, 1572872, 2066, 344064, 4329472, 1572868, 8480, 1572866, 2072, 1572864, 1572865,
+    2053, 2052, 266496, 2054, 2049, 2048, 2051, 2050, 41088, 2060, 4194880, 2163712, 2057, 2056, 1572880, 2058,
+    1152, 1153, 1154, 4327424, 1156, 82176, 270368, 4120, 1160, 3145760, 573440, 4116, 131648, 4114, 4113, 4112,
+    1168, 532992, 1114176, 4108, 6324224, 4106, 4105, 4104, 264448, 4102, 4101, 4100, 4099, 4098, 4097, 4096,
+    1184, 3145736, 270340, 16960, 270338, 688128, 270336, 270337, 3145729, 3145728, 196864, 3145730, 4212736, 3145732, 270344, 4144,
+    151552, 4521984, 2623488, 34048, 1049344, 2240, 270352, 4136, 41024, 3145744, 4194944, 4132, 590848, 4130, 4129, 4128,
+    1216, 299008, 1114128, 16928, 131592, 5251072, 35072, 2622464, 131588, 591872, 6553600, 8576, 131584, 131585, 131586, 4176,
+    1114114, 2228480, 1114112, 1114113, 802816, 2208, 1114116, 4168, 40992, 4211712, 1114120, 4164, 131600, 4162, 4161, 4160,
+    4718848, 16898, 16897, 16896, 2166784, 2192, 270400, 16900, 40976, 3145792, 7168, 16904, 131616, 263424, 1572992, 4292608,
+    40968, 2180, 1114144, 16912, 2177, 2176, 4326400, 2178, 40960, 40961, 40962, 917504, 40964, 2184, 2113792, 4192,
+    1280, 1281, 1282, 8264, 1284, 82048, 655376, 6291488, 1288, 8258, 8257, 8256, 36896, 1181696, 279040, 8260,
+    1296, 5246976, 655364, 68096, 655362, 303104, 655360, 655361, 264320, 540704, 3178496, 8272, 4259904, 2098688, 655368, 4480,
+    1312, 393728, 1067008, 6291460, 36872, 6291458, 6291457, 6291456, 36868, 540688, 196736, 8288, 36864, 36865, 36866, 6291464,
+    2170880, 540680, 266304, 33920, 1049216, 2368, 655392, 6291472, 540673, 540672, 4195072, 540674, 36880, 540676, 11264, 1376256,
+    1344, 8202, 8201, 8200, 3407872, 528896, 34944, 8204, 8195, 8194, 8193, 8192, 4259856, 8198, 8197, 8196,
+    49664, 2228352, 266272, 8216, 4259848, 2336, 655424, 1065984, 4259844, 8210, 8209, 8208, 4259840, 4259841, 4259842, 8212,
+    4718720, 1146880, 266256, 8232, 155648, 2320, 67072, 6291520, 2099712, 8226, 8225, 8224, 36928, 263296, 1573120, 8228,
+    266242, 2308, 266240, 266241, 2305, 2304, 266244, 2306, 1180672, 540736, 266248, 8240, 4259872, 2312, 2113664, 164352,
+    1408, 81924, 2101760, 1835008, 81921, 81920, 34880, 81922, 264208, 4227584, 196640, 8384, 2629632, 81928, 5243904, 4368,
+    264200, 2228288, 4218880, 33824, 1049120, 81936, 655488, 4360, 264192, 264193, 264194, 4356, 264196, 4354, 4353, 4352,
+    4718656, 14336, 196616, 33808, 1049104, 81952, 270592, 6291584, 196610, 3145984, 196608, 196609, 36992, 263232, 196612, 526848,
+    1049092, 33794, 33793, 33792, 1049088, 1049089, 1049090, 33796, 264224, 540800, 196624, 33800, 1049096, 4333568, 2113600, 4384,
+    4718624, 2228240, 34820, 8328, 34818, 81984, 34816, 34817, 1069056, 8322, 8321, 8320, 131840, 263200, 34824, 8324,
+    2228225, 2228224, 1114368, 2228226, 13312, 2228228, 34832, 4456960, 264256, 2228232, 525824, 8336, 4259968, 1605632, 2113568, 4416,
+    4718592, 4718593, 4718594, 17152, 4718596, 263176, 34848, 1183744, 4718600, 263172, 196672, 8352, 263169, 263168, 2113552, 263170,
+    4718608, 2228256, 266368, 33856, 1049152, 2432, 2113544, 598016, 41216, 70144, 2113540, 5244928, 2113538, 263184, 2113536, 2113537,
+    1536, 1537, 1538, 1081348, 1540, 1081346, 1081345, 1081344, 1544, 22528, 4194352, 2752512, 131264, 73760, 278784, 1081352,
+    1552, 532608, 4194344, 67840, 331776, 4341760, 2105408, 1081360, 4194338, 1310784, 4194336, 4194337, 559104, 2098432, 4194340, 4736,
+    1568, 393472, 4194328, 16576, 2637824, 73736, 137216, 1081376, 4194322, 73732, 4194320, 4194321, 73729, 73728, 4194324, 73730,
+    4194314, 2134016, 4194312, 4194313, 1048960, 2624, 4194316, 787456, 4194306, 4194307, 4194304, 4194305, 4194310, 73744, 4194308, 4194309,
+    1600, 6356992, 788480, 16544, 131208, 528640, 2105360, 1081408, 131204, 1310736, 102400, 8960, 131200, 131201, 131202, 4197376,
+    49408, 1310728, 2105348, 136192, 2105346, 2592, 2105344, 2105345, 1310721, 1310720, 4194400, 1310722, 131216, 1310724, 2105352, 606208,
+    1060864, 16514, 16513, 16512, 4489216, 2576, 66816, 16516, 2099456, 558080, 4194384, 16520, 131232, 73792, 1573376, 2363392,
+    720896, 2564, 4194376, 16528, 2561, 2560, 2105376, 2562, 4194370, 1310752, 4194368, 4194369, 21504, 2568, 4194372, 164096,
+    1664, 532496, 2101504, 16480, 131144, 2361344, 4784128, 1081472, 131140, 4227328, 1058816, 328704, 131136, 131137, 131138, 4624,
+    532481, 532480, 425984, 532482, 1048864, 532484, 19456, 4616, 2179072, 532488, 4194464, 4612, 131152, 4610, 4609, 4608,
+    100352, 16450, 16449, 16448, 1048848, 4199424, 270848, 16452, 790528, 3146240, 4194448, 16456, 131168, 73856, 2130944, 526592,
+    1048836, 532512, 4194440, 16464, 1048832, 1048833, 1048834, 2293760, 4194434, 134144, 4194432, 4194433, 1048840, 311296, 4194436, 4640,
+    131084, 16418, 16417, 16416, 131080, 131081, 131082, 16420, 131076, 131077, 131078, 16424, 131072, 131073, 131074, 131075,
+    4200448, 532544, 1114624, 16432, 131096, 99328, 2105472, 4456704, 131092, 1310848, 525568, 2131968, 131088, 131089, 131090, 4672,
+    16387, 16386, 16385, 16384, 131112, 16390, 16389, 16388, 131108, 16394, 16393, 16392, 131104, 131105, 131106, 16396,
+    2360320, 16402, 16401, 16400, 1048896, 2688, 561152, 16404, 41472, 69888, 4194496, 16408, 131120, 6815744, 329728, 1057792,
+    1792, 393248, 2101376, 67600, 4204544, 528448, 278536, 1081600, 1638400, 4227200, 278532, 8768, 278530, 2098192, 278528, 278529,
+    49216, 67586, 67585, 67584, 1048736, 2098184, 655872, 67588, 143360, 2098180, 4194592, 67592, 2098177, 2098176, 278544, 2098178,
+    393217, 393216, 565248, 393218, 1048720, 393220, 66624, 6291968, 2099264, 393224, 4194576, 1053696, 37376, 73984, 278560, 526464,
+    1048708, 393232, 4194568, 67616, 1048704, 1048705, 1048706, 28672, 4194562, 541184, 4194560, 4194561, 1048712, 2098208, 4194564, 163904,
+    49168, 528388, 5373952, 8712, 528385, 528384, 66592, 528386, 2099232, 8706, 8705, 8704, 131456, 528392, 278592, 8708,
+    49152, 49153, 49154, 67648, 49156, 528400, 2105600, 4456576, 49160, 1310976, 525440, 8720, 4260352, 2098240, 1054720, 163872,
+    2099208, 393280, 66564, 16768, 66562, 528416, 66560, 66561, 2099200, 2099201, 2099202, 8736, 2099204, 5259264, 66568, 163856,
+    49184, 4203520, 266752, 3670016, 1048768, 2816, 66576, 163848, 2099216, 69760, 4194624, 163844, 794624, 163842, 163841, 163840,
+    2101250, 4227080, 2101248, 2101249, 1048624, 82432, 2101252, 140288, 4227073, 4227072, 2101256, 4227074, 131392, 4227076, 278656, 526368,
+    1048612, 532736, 2101264, 67712, 1048608, 1048609, 1048610, 4456512, 264704, 4227088, 525376, 1196032, 1048616, 2098304, 106496, 4864,
+    1048596, 393344, 2101280, 16704, 1048592, 1048593, 1048594, 526344, 25600, 4227104, 197120, 526340, 1048600, 526338, 526337, 526336,
+    1048580, 1048581, 1048582, 34304, 1048576, 1048577, 1048578, 1048579, 1048588, 69696, 4194688, 2367488, 1048584, 1048585, 1048586, 526352,
+    335872, 1051648, 2101312, 16672, 131336, 528512, 35328, 4456464, 131332, 4227136, 525328, 8832, 131328, 131329, 131330, 3211264,
+    49280, 2228736, 525320, 4456452, 1048672, 4456450, 4456449, 4456448, 525314, 69664, 525312, 525313, 131344, 26624, 525316, 4456456,
+    4719104, 16642, 16641, 16640, 1048656, 2138112, 66688, 16644, 2099328, 69648, 1343488, 16648, 131360, 263680, 4206592, 526400,
+    1048644, 69640, 141312, 16656, 1048640, 1048641, 1048642, 4456480, 69633, 69632, 525344, 69634, 1048648, 69636, 2114048, 163968
+};
+
+Level2PduParcom::Level2PduParcom(bool oh, int closing_cur):
+        iEncTab(NULL),
+        iDecTab(NULL)
+{
+    iBsbuf[0] = iBsbuf[1] = NULL;
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.Level2");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level2PduParcom::Level2PduParcom"));
+    iPduEndPos = &iPdu[H223_MAX_MUX_PDU_SIZE_LEVEL2-1];
+    iPktsInUse = 0;
+    iPrevMuxTblNum = 0;
+    iPrevPm = 0;
+    iCurrentInt32 = 0;
+    iCurrentOp = ECopyHdr;
+    iOh = oh;
+    iUseOh = false;
+    iClosingCur = closing_cur;
+    iClosingNext = 0;
+    iClosingNextRx = 0;
+    iMpl = 0;
+    iMplRemaining = 0;
+    iMuxCode = -1;
+    iPduHdrPos = iPduHdr;
+    iCnt = 0;
+    iRecoverCnt = 0;
+    iCurBsBuf =  0;
+    iThreshold = LEVEL2_THRESHOLD_SYNC;
+    iCopyPduWithSync = false;
+    iPduEndPos = iPdu + LEVEL2_MAX_PDU_SZ - 1;
+
+    for (int n  = 0; n <= 0xFF; n++)
+    {
+        int m = n;
+        int cnt = 0;
+        while (m)
+        {
+            if (m & 0x1)
+            {
+                cnt++;
+            }
+            m >>= 1;
+        }
+        iNumOnes[n] = (uint8)cnt;
+    }
+    uint8 HecCrc[18] =
+    {
+        0x00, 0x05, 0x07, 0x02, 0x03, 0x06, 0x04, 0x01,
+        0x06, 0x03, 0x01, 0x04, 0x05, 0x00, 0x02, 0x07
+    };
+
+    oscl_memcpy(iHecCrc, HecCrc, 18);
+    ResetStats();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level2PduParcom::Level2PduParcom-d"));
+}
+
+void
+Level2PduParcom::SetClosingCur(int32 closing)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level2PduParcom::SetClosingCur closing=%d", closing));
+    iClosingCur = closing;
+}
+
+void
+Level2PduParcom::Construct(uint16 max_outstanding_pdus)
+{
+    iEncTab = (int*)OSCL_DEFAULT_MALLOC(sizeof(enc_tab));
+    oscl_memcpy(iEncTab, enc_tab, sizeof(enc_tab));
+    iDecTab = (int*)OSCL_DEFAULT_MALLOC(sizeof(dec_tab));
+    oscl_memcpy(iDecTab, dec_tab, sizeof(dec_tab));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level2PduParcom::Construct - iEncTab/iDecTab created"));
+
+    iBsbuf[0] = (uint8*)OSCL_DEFAULT_MALLOC(H223_MAX_DEMUX_PDU_SIZE * 2);
+    iBsbuf[1] = (uint8*)OSCL_DEFAULT_MALLOC(H223_MAX_DEMUX_PDU_SIZE * 2);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level2PduParcom::Construct - bsbufs created"));
+
+    iHdrFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iHdrFragmentAlloc.size(max_outstanding_pdus, (uint16)H223GetMaxStuffingSz(H223_LEVEL2_OH));
+}
+
+void Level2PduParcom::GetHdrFragment(OsclRefCounterMemFrag& frag)
+{
+    frag = iHdrFragmentAlloc.get();
+}
+
+uint32
+Level2PduParcom::GetStuffing(uint8* pPdu, uint32 max_size, uint8 mux_code)
+{
+    int32 stuffing_size = (int32)(iOh ? LEVEL2OH_STUFFING_SZ : LEVEL2_STUFFING_SZ);
+    int32 size_left = max_size;
+    while (size_left >= stuffing_size)
+    {
+        PV_STAT_INCR(iNumFlagsTx, 1)
+        PV_STAT_INCR(iNumStuffingTx, 1)
+
+        if (iClosingNext)
+        {
+            *pPdu = 0x1e;
+            *(pPdu + 1) = 0xb2;
+            iClosingNext = 0;
+            PV_STAT_INCR(iNumClosingFlagsTx, 1)
+        }
+        else
+        {
+            *pPdu = 0xe1;
+            *(pPdu + 1) = 0x4d;
+        }
+        int code = iEncTab[mux_code];
+        *(pPdu + 2) = (uint8)((code >> 12) & 0xff);
+        *(pPdu + 3) = (uint8)(((code >> 20) & 0xf) + ((code & 0xf) << 4));
+        *(pPdu + 4) = (uint8)((code >> 4) & 0xff);
+
+        if (iOh)
+        {
+            *(pPdu + 5) = (uint8)((iHecCrc[iPrevMuxTblNum] << 1) | (iPrevMuxTblNum << 4) | iPrevPm);
+            iPrevMuxTblNum = mux_code;
+            iPrevPm = 0;
+        }
+        pPdu += stuffing_size;
+        size_left -= stuffing_size;
+    }
+
+    return (max_size -size_left);
+}
+
+PVMFStatus
+Level2PduParcom::CompletePdu(OsclSharedPtr<PVMFMediaDataImpl>& pdu, int8 MuxTblNum, uint8 pm)
+{
+    OsclRefCounterMemFrag frag;
+    pdu->getMediaFragment(0, frag);
+    pdu->setMediaFragFilledLen(0, GetHeaderSz());
+
+    int32 pdu_size = pdu->getFilledSize() - GetHeaderSz();
+    if (pdu_size < 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "Level2PduParcom::CompletePdu pdu_size=%d", pdu_size));
+    }
+#if defined(CORRUPT_MT)
+    int MuxTblNumSav = MuxTblNum;
+    MuxTblNum = 6;
+#endif
+    // header
+    uint8* pPdu = (uint8*)frag.getMemFragPtr();
+    OSCL_ASSERT(pPdu);
+    PV_STAT_INCR(iNumFlagsTx, 1)
+    PV_STAT_INCR(iNumPdusTx, 1)
+
+    if (iClosingNext)
+    {
+        *pPdu = 0x1e;
+        *(pPdu + 1) = 0xb2;
+        PV_STAT_INCR(iNumClosingFlagsTx, 1)
+    }
+    else
+    {
+        *pPdu = 0xe1;
+        *(pPdu + 1) = 0x4d;
+    }
+    iClosingNext = pm;
+
+    int code;
+    code = (pdu_size << 4) + MuxTblNum;
+    //OSCL_ASSERT(code < 4096);
+    code = iEncTab[code];//GolayEnc(code);
+#if defined(CORRUPT_MUXCODE)
+    int mask = 0x00;
+    for (int num_errors = 0; num_errors < CORRUPT_MUXCODE; num_errors++)
+    {
+        if ((iRand.Rand() % 2) == 0)
+        {
+            mask |= (1 << (iRand.Rand() % 24));
+        }
+    }
+    code ^= mask;
+#endif
+    *(pPdu + 2) = (uint8)((code >> 12) & 0xff);
+    *(pPdu + 3) = (uint8)(((code >> 20) & 0xf) + ((code & 0xf) << 4));
+    *(pPdu + 4) = (uint8)((code >> 4) & 0xff);
+    if (iOh)
+    {
+        *(pPdu + 5) = (uint8)((iHecCrc[iPrevMuxTblNum] << 1) | (iPrevMuxTblNum << 4) | iPrevPm);
+#if defined(CORRUPT_MT)
+        MuxTblNum = MuxTblNumSav;
+#endif
+        iPrevMuxTblNum = MuxTblNum;
+        iPrevPm = pm;
+    }
+    return PVMFSuccess;
+}
+
+bool Level2PduParcom::CheckFlag(uint8* buf, int* fClosing, int trsld = 16)
+{
+    uint16 match_cnt = (uint16)(iNumOnes[(buf[0] ^ 0xE1)]  + iNumOnes[(buf[1] ^ 0x4D)]);
+    PV_STAT_INCR_COND(iNumFlagErrorsRx, 1, (match_cnt % 16))
+
+    if (match_cnt >= trsld)
+    {
+        *fClosing = 1;
+        PV_STAT_INCR(iNumClosingFlagsRx, 1)
+        PV_STAT_INCR(iCumFlagErrorsRx, (16 - match_cnt))
+        return true;
+    }
+    else if (match_cnt <= (16 - trsld))
+    {
+        *fClosing = 0;
+        PV_STAT_INCR(iCumFlagErrorsRx, match_cnt)
+        return true;
+    }
+    PV_STAT_INCR(iCumFlagErrorsRx, ((match_cnt > 8) ? (16 - match_cnt) : match_cnt))
+
+    return false;
+}
+
+/* Set iPduPos, iMpl, iMplRemaining return < 0 if error*/
+int Level2PduParcom::ParseHdr(int* fClosing, int* mpl, int* muxCode, int* numErrors, uint8* optional_header)
+{
+    OSCL_UNUSED_ARG(fClosing);
+
+    int code = 0;
+    uint8* pos = iPduHdr + 2;
+    oscl_memcpy(iLastHdr, iPduHdr + 2, 3);
+
+    code = (*pos << 12) + ((*(pos + 1) & 0xf) << 20) + (*(pos + 2) << 4)
+           + (*(pos + 1) >> 4);
+    code = GolayDec(code, numErrors);
+
+    *mpl = (code >> 4);
+    *muxCode = code & 0xF;
+
+    if (*mpl >= 255)
+    {
+        PV_STAT_INCR(iNumPduHdrErrorsMplRx, 1)
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "Mux[L2]: Bitstream error - mpl > 255\n"));
+        *mpl = 0;
+        *muxCode = -1;
+    }
+
+    if (iOh)
+    {
+        *optional_header = *(pos + 3);
+    }
+    return *mpl;
+}
+
+uint32 Level2PduParcom::Parse(uint8* buf, uint32 bufsz)
+{
+    int fClosing = 0, mpl = 0, muxCode = 0, sz = 0;
+    uint8* bsbuf = buf;
+    int bsbsz = bufsz;
+    int num_errors = 0;
+    uint8 optional_header = 0;
+    unsigned hdr_sz = iOh ? LEVEL2OH_STUFFING_SZ : LEVEL2_STUFFING_SZ;
+
+    while (bsbsz > 0)
+    {
+        switch (iCurrentOp)
+        {
+            case ECopyHdr:
+                *iPduHdrPos++ = *bsbuf++;
+                bsbsz--;
+                if (iCopyPduWithSync)
+                {
+                    CopyOctetToPdu(iPduHdr[0]);
+                }
+                if ((iPduHdrPos - iPduHdr) == 2)
+                {
+                    // check for flag
+                    iClosingNextRx = 0;
+                    if (CheckFlag(iPduHdr, &iClosingNextRx, iThreshold)) // found a flag.
+                    {
+                        PV_STAT_INCR(iNumFlagsRx, 1)
+
+                        // signal error if sync was lost
+                        if (iNumSyncLossRx > SYNC_LOSS_INDICATE_THRESHOLD)
+                        {
+                            iObserver->MuxPduErrIndicate(EHeaderErr);
+                        }
+                        iNumSyncLossRx = 0;
+
+                        iThreshold = LEVEL2_THRESHOLD_DATA;
+                        if (iCopyPduWithSync)
+                        {
+                            iCopyPduWithSync = false;
+                            iMpl = iPduPos - iPdu - 1;
+                        }
+                        IndicatePdu(0);
+                    }
+                    else  // CheckFlag returned FALSE
+                    {
+                        iThreshold = LEVEL2_THRESHOLD_SYNC;
+                        PV_STAT_INCR_COND(iNumSyncLossRx, 1, iNumFlagsRx)
+                        IndicatePdu(0);
+                        iPduHdr[0] = iPduHdr[1];
+                        iPduHdrPos--;
+                    }
+                }
+                if ((unsigned)(iPduHdrPos - iPduHdr) == hdr_sz)
+                {
+
+                    OSCL_ASSERT((!iCopyPduWithSync));
+                    sz = ParseHdr(&fClosing, &mpl, &muxCode, &num_errors, &optional_header);
+                    PV_STAT_INCR_COND(iNumPduHdrErrorRx, 1, num_errors)
+                    PV_STAT_INCR(iCumPduHdrErrorRx, num_errors)
+                    PV_STAT_INCR_COND(iNumGolayCblePduHdrErrorsRx, 1, (num_errors && (num_errors < 4)))
+
+                    /* Golay can correct upto 3 errors.  Dont bother with optional header if num_errors <= 3. */
+                    if (num_errors < 4)
+                    {
+                        iMpl = mpl;
+                        iMuxCode = muxCode;
+                    }
+                    else if (num_errors == 4)
+                    {
+                        iUseOh = true;
+                    }
+                    else
+                    {
+                        /* Drop the current pdu data and search for sync again */
+                        iMpl = 0;
+                        iMuxCode = -1;
+                        iCurrentOp = ECopyHdr;
+                    }
+                    ResetPduHdr();
+
+                    PV_STAT_INCR_COND(iNumStuffingRx, 1, (sz == 0))
+
+                    if (iMpl > 0)
+                    {
+                        iThreshold = LEVEL2_THRESHOLD_DATA;
+                        iCurrentOp = ECopyData;
+                        iMplRemaining = iMpl;
+                    }
+                    else if (sz == -1)
+                    {
+                        iThreshold = LEVEL2_THRESHOLD_SYNC;
+                    }
+                }
+                break;
+            case ECopyData:
+                OSCL_ASSERT((!iCopyPduWithSync));
+                sz = (bsbsz > iMplRemaining) ? iMplRemaining : bsbsz;
+                if ((iPduPos + sz - 1) > iPduEndPos)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "Level2PduParcom::Parse Bitstream error - mpl > 255"));
+                }
+                oscl_memcpy(iPduPos, bsbuf, sz);
+                bsbuf += sz;
+                iPduPos += sz;
+                bsbsz -= sz;
+                iMplRemaining -= sz;
+
+                if (iMplRemaining == 0)
+                {
+                    PV_STAT_INCR(iNumPdusRx, 1)
+                    /* pdu is complete. it gets indicated when next hdr is found */
+                    iCurrentOp = ECopyHdr;
+                }
+                break;
+        }
+    }
+    return 1;
+}
+
+void Level2PduParcom::IndicatePdu(uint8 optional_header)
+{
+    OSCL_UNUSED_ARG(optional_header);
+
+    // indicate the pdu
+    if (iMpl || (iMuxCode > 0) || iClosingCur)
+    {
+        iObserver->MuxPduIndicate(iPdu, (uint16)iMpl, iClosingCur, iMuxCode);
+    }
+    ResetPdu();
+    iClosingCur = iClosingNextRx;
+    iUseOh = false;
+}
+
+uint8* Level2PduParcom::FindSync(uint8* data, int len, int* closing)
+{
+    uint8* ptr = data;
+    if (len < LEVEL2_FLAG_SZ)
+    {
+        return NULL;
+    }
+    for (int n1 = 0; n1 <= (len - LEVEL2_FLAG_SZ); n1++)
+    {
+        if (CheckFlag(ptr, closing, LEVEL2_THRESHOLD_SYNC))
+        {
+            return ptr;
+        }
+        ptr++;
+    }
+    return NULL;
+}
+
+bool Level2PduParcom::RecoverPduData(uint8*& bsbuf, int* bsbsz)
+{
+    bool search_for_sync = false;
+    uint8* syncpos = NULL;
+    int fClosing = 0;
+
+    if (iMpl)
+    {
+        iThreshold = LEVEL2_THRESHOLD_SYNC;
+        syncpos = FindSync(iPdu, iMpl, &fClosing);
+        if (syncpos)
+        {
+            /* Sync found within PDU */
+            int32 bytes_remaining = iMpl;
+            /* Adjust mpl and indicate pdu */
+            iMpl = syncpos - iPdu;
+            iClosingNextRx = fClosing;
+            bytes_remaining -= (iMpl + 2);
+            IndicatePdu(0);
+            /* Add remaining bytes to bsbuf */
+            /* Create a buffer comprised of prev mpl data + flag + remaining data from current buffer */
+            uint8* from_ptr = syncpos + 2;
+            uint8* to_ptr = iBsbuf[iCurBsBuf];
+            uint8* to_ptrstart =  to_ptr;
+            iCurBsBuf  = (uint8)(1  - iCurBsBuf);
+            if (bytes_remaining)
+            {
+                oscl_memcpy(to_ptr, from_ptr, bytes_remaining);
+                to_ptr += bytes_remaining;
+            }
+            /* Add the 2 flag bytes back to bsbuf */
+            oscl_memcpy(to_ptr, iPduHdr, LEVEL2_FLAG_SZ);
+            to_ptr += LEVEL2_FLAG_SZ;
+            bytes_remaining += LEVEL2_FLAG_SZ;
+            oscl_memcpy(iPduHdr, syncpos, LEVEL2_FLAG_SZ);
+
+            if (*bsbsz)
+            {
+                oscl_memcpy(to_ptr, bsbuf, *bsbsz);
+                bytes_remaining += (*bsbsz);
+            }
+            *bsbsz = bytes_remaining;
+            bsbuf = to_ptrstart;
+        }
+        else /* No sync found within PDU */
+        {
+            uint8 flag_check[2];
+            flag_check[0] = iPdu[iMpl-1];
+            flag_check[1] = iPduHdr[0];
+            /* Check if there is a flag in the boundary of the pdu and header */
+            if (CheckFlag(flag_check, &fClosing, iThreshold))
+            {
+                iMpl--;
+                iClosingNextRx = fClosing;
+                IndicatePdu(0);
+                char c = iPduHdr[1];
+                oscl_memcpy(iPduHdr, flag_check, LEVEL2_FLAG_SZ);
+                iPduHdr[LEVEL2_FLAG_SZ] = c;
+                iPduHdrPos++;
+            }
+            else  /* No flag in the boundary */
+            {
+                search_for_sync = true;
+                /* Copy pdu data along with search for sync */
+                iCopyPduWithSync = true;
+            }
+        }/* check for sync within PDU */
+    }
+    else  /* iMpl == 0 */
+    {
+        search_for_sync = true;
+    }
+    if (iCopyPduWithSync)
+    {
+        /* Copy invalid flags to pdu data */
+        CopyOctetToPdu(iPduHdr[0]);
+    }
+    return search_for_sync;
+}
+
+void H223PduParcomBase::ResetStats()
+{
+    // Outgoing
+    iNumFlagsTx = 0;
+    iNumStuffingTx = 0;
+    iNumPdusTx = 0;
+
+    // Incoming
+    iNumFlagsRx = 0;
+    iNumStuffingRx = 0;
+    iNumPdusRx = 0;
+    iNumPmRx = 0;
+
+    iNumFlagErrorsRx = 0;
+    iCumFlagErrorsRx = 0;
+    iNumSyncLossRx = 0;
+    iNumBytesLossRx = 0;
+    iNumPduHdrErrorRx = 0;
+    iCumPduHdrErrorRx = 0;
+}
+
+void H223PduParcomBase::LogStats(TPVDirection dir)
+{
+    if (iLogger == NULL)
+        return;
+    if (dir & OUTGOING)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux-pdu(O) Statistics:\n"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num flags tx - %d\n", iNumFlagsTx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num stuffing tx - %d\n", iNumStuffingTx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num pdus tx - %d\n", iNumPdusTx));
+    }
+
+    if (dir & INCOMING)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux-pdu(I) Statistics:\n"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num flags rx - %d\n", iNumFlagsRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num stuffing rx - %d\n", iNumStuffingRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num pdus rx - %d\n", iNumPdusRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num pm rx - %d\n", iNumPmRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num flag errors rx - %d\n", iNumFlagErrorsRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Cum flag errors rx - %d\n", iCumFlagErrorsRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sync loss rx - %d\n", iNumSyncLossRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes loss rx - %d\n", iNumBytesLossRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num pdu hdr errors rx - %d\n", iNumPduHdrErrorRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Cum pdu hdr errors rx - %d\n", iCumPduHdrErrorRx));
+    }
+}
+
+void Level2PduParcom::ResetStats()
+{
+    H223PduParcomBase::ResetStats();
+
+    // Outgoing
+    iNumClosingFlagsTx = 0;
+    iNumFlagEmulation = 0;
+
+    // Incoming
+    iNumClosingFlagsRx = 0;
+    iNumGolayCblePduHdrErrorsRx = 0;
+    iNumPduHdrErrorsMplRx = 0;
+    iNumCorruptedOhRx = 0;
+    iNumHeadersCorrectedByOh = 0;
+}
+
+void Level2PduParcom::LogStats(TPVDirection dir)
+{
+    if (dir & OUTGOING)
+    {
+        H223PduParcomBase::LogStats(OUTGOING);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level 2 Mux Statistics:\n"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num closing flags tx - %d\n", iNumClosingFlagsTx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num flag emulation with threshold (%d) in tx bitstream - %d\n", LEVEL2_THRESHOLD_SYNC, iNumFlagEmulation));
+    }
+    if (dir & INCOMING)
+    {
+        H223PduParcomBase::LogStats(INCOMING);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Level 2 Demux Statistics:\n"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num closing flags rx - %d\n", iNumClosingFlagsRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num golay correctable hdr errors rx - %d\n", iNumGolayCblePduHdrErrorsRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num errors in mpl rx - %d\n", iNumPduHdrErrorsMplRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num corrupted OH rx - %d\n", iNumCorruptedOhRx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num headers corrected using OH - %d\n", iNumHeadersCorrectedByOh));
+    }
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/logicalchannel.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/logicalchannel.cpp
new file mode 100644
index 0000000..209ea36
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/logicalchannel.cpp
@@ -0,0 +1,1862 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_rand.h"
+#include "logicalchannel.h"
+#include "pvmf_simple_media_buffer.h"
+#include "pvmf_media_data.h"
+#include "pvmf_media_cmd.h"
+#include "pvmf_media_msg_format_ids.h"
+
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+
+#ifndef PER_COPIER
+#include "h245_copier.h"
+#endif
+
+#ifndef PER_DELETER
+#include "h245_deleter.h"
+#endif
+// decreasing DEF_CHANNEL_BUFFER_SIZE_MS can result out of memory errors,
+// please change also PV_MAX_VIDEO_FRAME_SIZE to lower value.
+#define DEF_CHANNEL_BITRATE 64000
+#define DEF_INCOMING_CHANNEL_BUFFER_SIZE_MS 2800
+#define DEF_OUTGOING_CHANNEL_BUFFER_SIZE_MS 2800
+#define TIMESTAMP_MAX INT_MAX
+#define DEF_SEGMENTABLE_CHANNEL_OH_BPS 2000
+#define H223_INCOMING_CHANNEL_NUM_MEDIA_MSG 300
+#define H223_OUTGOING_CHANNEL_NUM_MEDIA_MSG 300
+#define H223_INCOMING_CHANNEL_FRAGMENT_SIZE 128
+#define H223_INCOMING_CHANNEL_NUM_MEDIA_DATA 300
+#define H223_INCOMING_CHANNEL_NUM_FRAGS_IN_MEDIA_DATA (3*1024/128)
+#define PV2WAY_BPS_TO_BYTES_PER_MSEC_RIGHT_SHIFT 13
+
+
+#define H223_LCN_IN_TIMESTAMP_BASE 40
+
+
+H223LogicalChannel::H223LogicalChannel(TPVChannelId num,
+                                       bool segmentable,
+                                       OsclSharedPtr<AdaptationLayer>& al,
+                                       PS_DataType data_type,
+                                       LogicalChannelObserver* observer,
+                                       uint32 bitrate,
+                                       uint32 sample_interval,
+                                       uint32 num_media_data)
+        : PvmfPortBaseImpl(num, this),
+        lcn(num),
+        next(NULL),
+        iAl(al),
+        iBitrate(0),
+        iSampleInterval(0),
+        iObserver(observer),
+        iFormatSpecificInfo(NULL),
+        iFormatSpecificInfoLen(0),
+        iLogger(NULL),
+        iDataType(NULL),
+        iAudioLatency(0),
+        iVideoLatency(0)
+{
+    iSegmentable = segmentable;
+    iIncomingSkew = 0;
+    iLastSduTimestamp = 0;
+    iSampleInterval = sample_interval;
+    uint32 bitrate_overhead = IsSegmentable() ? DEF_SEGMENTABLE_CHANNEL_OH_BPS :
+                              (uint32)((2000 / sample_interval + 1) >> 1) * (al->GetHdrSz() + al->GetTrlrSz());
+    iBitrate = bitrate + bitrate_overhead;
+    iNumMediaData = num_media_data;
+    iMaxSduSize = (uint16)(iAl->GetSduSize() - iAl->GetHdrSz() - iAl->GetTrlrSz());
+    if (data_type)
+    {
+        iDataType = Copy_DataType(data_type);
+    }
+    iMediaType = GetFormatType();
+    iPaused = false;
+    iClock = NULL;
+}
+
+H223LogicalChannel::~H223LogicalChannel()
+{
+    if (iDataType)
+    {
+        Delete_DataType(iDataType);
+        OSCL_DEFAULT_FREE(iDataType);
+        iDataType = NULL;
+    }
+    if (iFormatSpecificInfo)
+    {
+        oscl_free(iFormatSpecificInfo);
+        iFormatSpecificInfo = NULL;
+        iFormatSpecificInfoLen = 0;
+    }
+
+}
+
+void H223LogicalChannel::Init()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LogicalChannel::Init"));
+    iSendFormatSpecificInfo = false;
+}
+
+PVMFStatus H223LogicalChannel::SetFormatSpecificInfo(uint8* info, uint16 info_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LogicalChannel::SetFormatSpecificInfo lcn=%d, info_len=%d, info=%x", lcn, info_len, info));
+    iSendFormatSpecificInfo = false;
+    if (iFormatSpecificInfo)
+    {
+        oscl_free(iFormatSpecificInfo);
+        iFormatSpecificInfo = NULL;
+        iFormatSpecificInfoLen = 0;
+    }
+
+    if (info == NULL || info_len == 0)
+        return PVMFSuccess;
+
+    iFormatSpecificInfo = (uint8*)oscl_malloc(info_len);
+    oscl_memcpy(iFormatSpecificInfo, info, info_len);
+    iFormatSpecificInfoLen = info_len;
+    iSendFormatSpecificInfo = true;
+    return PVMFSuccess;
+}
+
+const uint8* H223LogicalChannel::GetFormatSpecificInfo(uint32* info_len)
+{
+    if (info_len == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LogicalChannel::GetFormatSpecificInfo ERROR info_len==NULL"));
+        return NULL;
+    }
+    *info_len = iFormatSpecificInfoLen;
+    return iFormatSpecificInfo;
+}
+
+
+OSCL_EXPORT_REF void H223LogicalChannel::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
+{
+    aPtr = NULL;
+    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        aPtr = (PvmiCapabilityAndConfig*)this;
+    }
+    else if (aUuid == PVH324MLogicalChannelInfoUuid)
+    {
+        aPtr = (LogicalChannelInfo*)this;
+    }
+    else
+    {
+        OSCL_LEAVE(OsclErrNotSupported);
+    }
+}
+
+void H223LogicalChannel::Pause()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Pause lcn=%d", lcn));
+    iPaused = true;
+    // flush any pending media data
+    Flush();
+}
+
+void H223LogicalChannel::Resume()
+{
+    iPaused = false;
+}
+
+H223OutgoingChannel::H223OutgoingChannel(TPVChannelId num,
+        bool segmentable,
+        OsclSharedPtr<AdaptationLayer>& al,
+        PS_DataType data_type,
+        LogicalChannelObserver* observer,
+        uint32 bitrate,
+        uint32 sample_interval,
+        uint32 num_media_data)
+        : H223LogicalChannel(num, segmentable, al, data_type, observer, bitrate, sample_interval, num_media_data),
+        iMediaMsgMemoryPool(NULL),
+        iMediaDataEntryAlloc(NULL),
+        iMediaFragGroupAlloc(NULL),
+        iPduPktMemPool(NULL)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.H223OutgoingChannel");
+    iOutgoingVideoLogger = PVLogger::GetLoggerObject("datapath.outgoing.video.h223.lcn");
+    iOutgoingAudioLogger = PVLogger::GetLoggerObject("datapath.outgoing.audio.h223.lcn");
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::H223OutgoingChannel - num(%d),segmentable(%d)", num, segmentable));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::H223OutgoingChannel - AL SDU size(%d), hdr(%d), trlr(%d)", iAl->GetSduSize(), iAl->GetHdrSz(), iAl->GetTrlrSz()));
+    ResetStats();
+    lastMediaData = NULL;
+
+    iSetBufferMediaMs = 0;
+    iSetBufferMediaBytes = 0;
+    iBufferMediaMs = 0;
+    iBufferMediaBytes = 0;
+    iCurPduTimestamp = 0;
+    iNumPendingPdus = 0;
+    iMuxingStarted = false;
+    iWaitForRandomAccessPoint = false;
+    iBufferSizeMs = DEF_OUTGOING_CHANNEL_BUFFER_SIZE_MS;
+
+}
+
+H223OutgoingChannel::~H223OutgoingChannel()
+{
+    if (iDataType)
+    {
+        Delete_DataType(iDataType);
+        OSCL_DEFAULT_FREE(iDataType);
+        iDataType = NULL;
+    }
+    Flush();
+    iMediaFragGroupAlloc->removeRef();
+    OSCL_DELETE(iPduPktMemPool);
+    OSCL_DELETE(iMediaDataEntryAlloc);
+    OSCL_DELETE(iMediaMsgMemoryPool);
+
+}
+
+void H223OutgoingChannel::Init()
+{
+    H223LogicalChannel::Init();
+    iMediaMsgMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (H223_OUTGOING_CHANNEL_NUM_MEDIA_MSG));
+    iMediaMsgMemoryPool->enablenullpointerreturn();
+    iMediaDataEntryAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (iNumMediaData, sizeof(LCMediaDataEntry)));
+    iMediaDataEntryAlloc->enablenullpointerreturn();
+    iPduPktMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (iNumMediaData));
+    iPduPktMemPool->enablenullpointerreturn();
+    iMediaFragGroupAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (iNumMediaData, 10, iPduPktMemPool));
+    iMediaFragGroupAlloc->create();
+}
+
+
+void H223OutgoingChannel::BufferMedia(uint16 aMs)
+{
+    if (iBufferSizeMs && aMs > iBufferSizeMs)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::BufferMedia ERROR buffer interval=%d > buffer size=%d", aMs, iBufferSizeMs));
+    }
+    iSetBufferMediaMs = iBufferMediaMs = aMs;
+    iSetBufferMediaBytes = iBufferMediaBytes = ((iBufferSizeMs * iBitrate + 4000) / 8000);
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"H223OutgoingChannel::BufferMedia ms=%d,bytes=%d", iBufferMediaMs,iBufferMediaBytes));
+}
+
+void H223OutgoingChannel::Resume()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Resume lcn=%d", lcn));
+    H223LogicalChannel::Resume();
+    iPaused = false;
+    // start muxing on a random access point
+    //iWaitForRandomAccessPoint=true;
+}
+
+void H223OutgoingChannel::SetBufferSizeMs(uint32 buffer_size_ms)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingLogicalChannel::SetBufferSizeMs buffer_size_ms=%d", buffer_size_ms));
+    iBufferSizeMs = buffer_size_ms;
+}
+
+
+
+PVMFStatus H223OutgoingChannel::PutData(PVMFSharedMediaMsgPtr media_msg)
+{
+    PVMFStatus ret = PVMFSuccess;
+    PVMFSharedMediaDataPtr mediaData;
+    convertToPVMFMediaData(mediaData, media_msg);
+
+    PV_STAT_SET_TIME(iStartTime, iNumPacketsIn)
+    PV_STAT_INCR(iNumPacketsIn, 1)
+
+    /* zero through 255 is reserved for media data */
+    if (media_msg->getFormatID() >= PVMF_MEDIA_CMD_FORMAT_IDS_START)
+    {
+        return PVMFSuccess;
+    }
+
+    PV_STAT_INCR(iNumBytesIn, (mediaData->getFilledSize()))
+    TimeValue timenow;
+    if (iMediaType.isCompressed() && iMediaType.isAudio())
+    {
+        PVMF_OUTGOING_AUDIO_LOGDATATRAFFIC((0, "Outgoing audio frames received. Stats: Entry time=%ud, lcn=%d, size=%d", timenow.to_msec(), lcn, mediaData->getFilledSize()));
+    }
+    else if (iMediaType.isCompressed() && iMediaType.isVideo())
+    {
+        PVMF_OUTGOING_VIDEO_LOGDATATRAFFIC((0, "Outgoing video frames received.Stats: Entry time=%ud, lcn=%d, size=%d", timenow.to_msec(), lcn, mediaData->getFilledSize()));
+    }
+
+    if (iNumPacketsIn % 20 == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData lcn=%d, size=%d, ts=%d", lcn, mediaData->getFilledSize(), mediaData->getTimestamp()));
+    }
+
+    // Check for FormatSpecificInfo
+    if (mediaData->getFormatSpecificInfo(iFsiFrag) && iFsiFrag.getMemFragPtr() && iFsiFrag.getMemFragSize())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData Received Format Specific Info, len=%d", iFsiFrag.getMemFragSize()));
+        iObserver->ReceivedFormatSpecificInfo(lcn, (uint8*)iFsiFrag.getMemFragPtr(), iFsiFrag.getMemFragSize());
+    }
+
+    if (iPaused)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData Logical channel %d paused.  Dropping media data.", lcn));
+        return PVMFErrInvalidState;
+    }
+
+    if (IsSegmentable() && iWaitForRandomAccessPoint)
+    {
+        if ((mediaData->getMarkerInfo()&PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT) == 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData Not random access point.  Dropping media data."));
+            return PVMFErrInvalidState;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData Found random access point."));
+        iWaitForRandomAccessPoint = false;
+    }
+    else if (iNumPendingPdus == (iNumMediaData - 1))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData - ERROR Overflow, iNumPendingPdus=%d", iNumPendingPdus));
+        return PVMFErrOverflow;
+    }
+
+    uint32 num_frags_required = 0;
+    uint32 frag_num = 0;
+    for (frag_num = 0; frag_num < mediaData->getNumFragments(); frag_num++)
+    {
+        OsclRefCounterMemFrag memfrag;
+        mediaData->getMediaFragment(frag_num, memfrag);
+        if (memfrag.getMemFragSize() > iMaxSduSize)
+        {
+            num_frags_required++;
+        }
+    }
+
+    if ((mediaData->getNumFragments() + num_frags_required + iNumPendingPdus) >= (iNumMediaData - 1))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData - ERROR Overflow, iNumPendingPdus=%d, num_frags_required=%d,iNumMediaData=%d", iNumPendingPdus, num_frags_required, iNumMediaData));
+        Flush();
+        /* Start re-buffering */
+        BufferMedia((uint16)iSetBufferMediaMs);
+        return PVMFErrOverflow;
+    }
+
+    /* Fragment the sdu if needed */
+    PVMFSharedMediaDataPtr& fragmentedMediaData = mediaData;
+    if (num_frags_required)
+    {
+        if (true != FragmentPacket(mediaData, fragmentedMediaData))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData - Memory allocation failure on Fragment\n"));
+            return PVMFErrOverflow;
+        }
+    }
+
+    uint32 sdu_size = 0;
+    if (iCurPdu.GetRep())
+    {
+        sdu_size = iCurPdu->getFilledSize() - iAl->GetHdrSz();
+        /* Is the timestamp different ? */
+        if (iCurPduTimestamp != fragmentedMediaData->getTimestamp() || !IsSegmentable())
+        {
+            if (PVMFSuccess != CompletePdu())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData - Memory allocation failure on CompletePdu\n"));
+                return PVMFErrOverflow;
+            }
+            sdu_size = 0;
+        }
+    }
+    if (sdu_size == 0)
+    {
+        //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"H223OutgoingChannel::PutData Sdu size == 0"));
+        iCurPdu = StartAlPdu();
+        if (!iCurPdu)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "H223OutgoingChannel::PutData - Memory allocation failure on StartAlPdu\n"));
+            return PVMFErrOverflow;
+        }
+
+        if (iFsiFrag.getMemFragSize())
+        {
+            iCurPdu->appendMediaFragment(iFsiFrag);
+            // reset the FSI frag
+            OsclRefCounterMemFrag frag;
+            iFsiFrag = frag;
+        }
+    }
+
+    for (frag_num = 0; frag_num < fragmentedMediaData->getNumFragments(); frag_num++)
+    {
+        OsclRefCounterMemFrag frag;
+        fragmentedMediaData->getMediaFragment(frag_num, frag);
+        OSCL_ASSERT(frag.getMemFragSize() <= iMaxSduSize);
+
+        if (sdu_size &&
+                ((sdu_size + frag.getMemFragSize() > iMaxSduSize) || !IsSegmentable()))
+        {
+            if (PVMFSuccess != CompletePdu())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::PutData - Memory allocation failure on CompletePdu\n"));
+                return PVMFErrOverflow;
+            }
+            sdu_size = 0;
+
+            iCurPdu = StartAlPdu();
+
+            if (!iCurPdu)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "H223OutgoingChannel::PutData - Memory allocation failure on StartAlPdu\n"));
+                return PVMFErrOverflow;
+            }
+        }
+
+        iCurPdu->appendMediaFragment(frag);
+        sdu_size += frag.getMemFragSize();
+        iCurPduTimestamp = fragmentedMediaData->getTimestamp();
+
+    }
+
+    if (iMediaType.isCompressed() && iMediaType.isAudio())
+    {
+        PVMF_OUTGOING_AUDIO_LOGDATATRAFFIC((0, "Stats of the outgoing audio SDU are: timestamp=%d, size=%d", iCurPduTimestamp, sdu_size));
+    }
+    else if (iMediaType.isCompressed() && iMediaType.isVideo())
+    {
+        PVMF_OUTGOING_VIDEO_LOGDATATRAFFIC((0, "Stats of the outgoing video SDU are: timestamp=%d, size=%d", iCurPduTimestamp, sdu_size));
+    }
+    return ret;
+}
+
+bool H223OutgoingChannel::FragmentPacket(PVMFSharedMediaDataPtr& aMediaData, PVMFSharedMediaDataPtr& aFragmentedMediaData)
+{
+    OsclRefCounterMemFrag memfrag;
+    OsclSharedPtr<PVMFMediaDataImpl> newpack;
+    newpack = iMediaFragGroupAlloc->allocate();
+    if (!newpack.GetRep())
+    {
+        return false;
+    }
+
+    int32 pkt_size = 0;
+    PVMFTimestamp timestamp = aMediaData->getTimestamp();
+    for (uint32 frag_num = 0; frag_num < aMediaData->getNumFragments(); frag_num++)
+    {
+        aMediaData->getMediaFragment(frag_num, memfrag);
+        pkt_size = memfrag.getMemFragSize();
+        if ((unsigned)pkt_size <= iMaxSduSize)
+        {
+            newpack->appendMediaFragment(memfrag);
+        }
+        else  /* Need to fragment it */
+        {
+            uint8* pos = (uint8*)memfrag.getMemFragPtr();
+            int32 trim_frag_sz = iMaxSduSize;
+            while (pkt_size)
+            {
+                trim_frag_sz = ((unsigned)pkt_size > iMaxSduSize) ? iMaxSduSize : pkt_size;
+                pkt_size -= trim_frag_sz;
+                OsclRefCounterMemFrag trim_frag(memfrag);
+                trim_frag.getMemFrag().ptr = pos;
+                trim_frag.getMemFrag().len = trim_frag_sz;
+                newpack->appendMediaFragment(trim_frag);
+                pos += trim_frag_sz;
+            }
+        }
+    }
+    aFragmentedMediaData = PVMFMediaData::createMediaData(newpack, iMediaMsgMemoryPool);
+    if (aFragmentedMediaData.GetRep())
+    {
+        aFragmentedMediaData->setTimestamp(timestamp);
+        return true;
+    }
+    return false;
+}
+
+OsclSharedPtr<PVMFMediaDataImpl> H223OutgoingChannel::StartAlPdu()
+{
+    PV_STAT_INCR(iNumSdusIn, 1)
+
+    // allocate packet
+    OsclSharedPtr<PVMFMediaDataImpl> pdu = iMediaFragGroupAlloc->allocate();
+    if (pdu)
+    {
+        // Add header
+        PVMFStatus status = iAl->StartPacket(pdu);
+        if (status != PVMFSuccess)
+        {
+            pdu.Unbind();
+            return pdu;
+        }
+        iNumPendingPdus++;
+    }
+
+    return pdu;
+}
+
+PVMFStatus H223OutgoingChannel::CompletePdu()
+{
+    PVMFStatus status = iAl->CompletePacket(iCurPdu);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::CompletePdu Memory allocation failedlcn=%d, CompletePacket status=%d", lcn, status));
+        return status;
+    }
+    // Add it to the outgoing queue
+    status = AppendOutgoingPkt(iCurPdu, iCurPduTimestamp);
+    if (status != PVMFSuccess)
+    {
+        return status;
+    }
+    iCurPdu.Unbind();
+    iCurPduTimestamp = 0;
+    return PVMFSuccess;
+}
+
+PVMFStatus H223OutgoingChannel::AppendOutgoingPkt(OsclSharedPtr<PVMFMediaDataImpl>& pdu,
+        PVMFTimestamp timestamp,
+        OsclRefCounterMemFrag* fsi)
+{
+    PVMFSharedMediaDataPtr mediaData = PVMFMediaData::createMediaData(pdu, iMediaMsgMemoryPool);
+    if (mediaData.GetRep() == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    mediaData->setTimestamp(timestamp);
+    if (fsi)
+    {
+        mediaData->setFormatSpecificInfo(*fsi);
+    }
+    void* memory_for_entry = iMediaDataEntryAlloc->allocate(sizeof(LCMediaDataEntry));
+    if (!memory_for_entry)
+    {
+        // if couldn't allocate memory - leave
+        return PVMFErrNoMemory;
+    }
+    LCMediaDataEntry* entry = new(memory_for_entry) LCMediaDataEntry();
+    entry->mediaData = mediaData;
+
+    LCMediaDataEntry* first = entry;
+    PVMFTimestamp lastTS = timestamp;
+    if (lastMediaData)
+    {
+        first = lastMediaData->next;
+        lastMediaData->next = entry;
+        lastTS = lastMediaData->mediaData->getTimestamp();
+    }
+    lastMediaData = entry;
+    entry->next = first;
+
+    /* Adjust buffering parameters */
+    if (iBufferMediaMs)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::AppendOutgoingPkt lcn=%d, last ts=%d,cur ts=%d", lcn, lastTS, timestamp));
+        /* Compute delta_t from last media data */
+        int32 delta_t = timestamp - lastTS;
+        if (delta_t < 0)
+            delta_t += TIMESTAMP_MAX;
+        iBufferMediaMs -= delta_t;
+        iBufferMediaBytes -= mediaData->getFilledSize();
+        if (iBufferMediaMs <= 0 || iBufferMediaBytes <= 0)
+        {
+            iBufferMediaMs = 0;
+            iBufferMediaBytes = 0;
+        }
+    }
+    return PVMFSuccess;
+}
+
+bool H223OutgoingChannel::GetNextPacket(PVMFSharedMediaDataPtr& aMediaData, PVMFStatus aStatus)
+{
+    if (!iMuxingStarted && aStatus == PVMFSuccess)
+        iMuxingStarted = true;
+
+    if (lastMediaData == NULL)
+    {
+        return false;
+    }
+
+    if ((aStatus == PVMFSuccess) && iBufferMediaMs && iBufferMediaBytes)
+    {
+        /* Still buffering */
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::GetNextPacket Buffering lcn=%d, ms left=%d", lcn, iBufferMediaMs));
+        return false;
+    }
+
+    LCMediaDataEntry* first = lastMediaData->next;
+    aMediaData = first->mediaData;
+
+    if (first == lastMediaData)
+    {
+        lastMediaData = NULL;
+    }
+    else
+    {
+        lastMediaData->next = first->next;
+    }
+    first->~LCMediaDataEntry();
+    iMediaDataEntryAlloc->deallocate(first);
+
+    iNumPendingPdus--;
+    return true;
+}
+
+OsclAny H223OutgoingChannel::ReleasePacket(PVMFSharedMediaDataPtr& aMediaData)
+{
+    OsclSharedPtr<PVMFMediaDataImpl> aMediaDataImpl;
+    aMediaData->getMediaDataImpl(aMediaDataImpl);
+    aMediaDataImpl->clearMediaFragments();
+}
+
+OsclAny H223OutgoingChannel::Flush()
+{
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"H223OutgoingChannel::Flush\n"));
+
+    PVMFSharedMediaDataPtr aMediaData;
+    // clear messages in input queue
+    ClearMsgQueues();
+    // go through pending queue
+    while (GetNextPacket(aMediaData, PVMFFailure))
+    {
+        PV_STAT_INCR(iNumBytesFlushed, aMediaData->getFilledSize())
+        OsclSharedPtr<PVMFMediaDataImpl> aMediaDataImpl;
+        aMediaData->getMediaDataImpl(aMediaDataImpl);
+        aMediaDataImpl->clearMediaFragments();
+    }
+    if (iCurPdu.GetRep())
+    {
+        iCurPdu->clearMediaFragments();
+        iCurPdu.Unbind();
+    }
+    iCurPduTimestamp = 0;
+    iNumPendingPdus = 0;
+}
+OsclAny H223OutgoingChannel::ResetStats()
+{
+    iNumPacketsIn = 0;
+    iNumSdusIn = 0;
+    iNumBytesIn = 0;
+    iNumSdusDropped = 0;
+    iNumSdusOut = 0;
+    iNumBytesOut = 0;
+    iMaxPacketMuxTime = 0;
+    iMaxSduMuxTime = 0;
+    iNumFlush = 0;
+    iNumBytesFlushed = 0;
+}
+
+OsclAny H223OutgoingChannel::LogStats()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Outgoing Logical Channel %d Statistics:\n", lcn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Adaptation layer header bytes -  %d\n", iAl->GetHdrSz()));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Adaptation layer trailer bytes -  %d\n", iAl->GetTrlrSz()));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num packets received - %d\n", iNumPacketsIn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus received - %d\n", iNumSdusIn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes received - %d\n", iNumBytesIn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus dropped - %d\n", iNumSdusDropped));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus output - %d\n", iNumSdusOut));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes output - %d\n", iNumBytesOut));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Max packet mux time - %d\n", iMaxPacketMuxTime));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Max sdu mux time - %d\n", iMaxSduMuxTime));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num flush - %d\n", iNumFlush));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes flushed - %d\n", iNumBytesFlushed));
+}
+
+OSCL_EXPORT_REF PVMFStatus H223OutgoingChannel::Connect(PVMFPortInterface* aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Connect, aPort=%x", aPort));
+
+    if (iConnectedPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Connect Error: Already connected"));
+        return PVMFFailure;
+    }
+
+    PvmiCapabilityAndConfig* config = NULL;
+    OsclAny* tempInterface = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, tempInterface);
+    config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, tempInterface);
+    if (!config)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Connect: Error - Peer port does not support capability interface"));
+        return PVMFFailure;
+    }
+
+    PVMFStatus status = NegotiateInputSettings(config);
+
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Connect: Error - Settings negotiation failed. status=%d", status));
+        return status;
+    }
+
+    //Automatically connect the peer.
+    if ((status = aPort->PeerConnect(this)) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::Connect: Error - Peer Connect failed. status=%d", status));
+        return status;
+    }
+
+    iConnectedPort = aPort;
+
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+    return PVMFSuccess;
+}
+
+PVMFStatus H223OutgoingChannel::NegotiateInputSettings(PvmiCapabilityAndConfig* aConfig)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::NegotiateInputSettings, aConfig=%x", aConfig));
+
+    PvmiKvp* kvp = NULL;
+    int numParams = 0;
+    int32 i = 0;
+
+    // Get supported output formats from peer
+    PVMFStatus status = aConfig->getParametersSync(NULL,
+                        OSCL_CONST_CAST(char*, OUTPUT_FORMATS_CAP_QUERY),
+                        kvp, numParams, NULL);
+    if (status != PVMFSuccess || numParams == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::NegotiateInputSettings, Error:  getParametersSync failed.  status=%d", status));
+        return status;
+    }
+
+    PvmiKvp* selectedKvp = NULL;
+    PVCodecType_t codec_type = GetCodecType(iDataType);
+    PVMFFormatType lcn_format_type = PVCodecTypeToPVMFFormatType(codec_type);
+
+    for (i = 0; i < numParams && !selectedKvp; i++)
+    {
+        if (lcn_format_type == kvp[i].value.pChar_value)
+            selectedKvp = &(kvp[i]);
+    }
+
+    if (!selectedKvp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::NegotiateInputSettings, Error:  Input format not supported by peer"));
+        return PVMFFailure;
+    }
+    if (PVMFSuccess != setConfigParametersSync(selectedKvp, aConfig))
+    {
+        return PVMFFailure;
+    }
+
+    aConfig->releaseParameters(NULL, kvp, numParams);
+    kvp = NULL;
+    numParams = 0;
+
+    return PVMFSuccess;
+}
+////////////////////////////////////////////////////////////////////////////
+//                  PvmiCapabilityAndConfig
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223OutgoingChannel::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    // Not supported
+    OSCL_UNUSED_ARG(aObserver);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus H223OutgoingChannel::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::getParametersSync"));
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+    parameters = NULL;
+    num_parameter_elements = 0;
+
+    if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        PVMFStatus status = AllocateKvp(iKvpMemAlloc, parameters,
+                                        OSCL_CONST_CAST(char*, INPUT_FORMATS_VALTYPE),
+                                        num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        PVCodecType_t codec_type = GetCodecType(iDataType);
+
+        PVMFFormatType format = PVCodecTypeToPVMFFormatType(codec_type).getMIMEStrPtr();
+        if (format == PVMF_MIME_AMR_IF2)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_AMR_IF2;
+        else if (format == PVMF_MIME_PCM16)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_PCM16;
+        else if (format ==  PVMF_MIME_YUV420)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_YUV420;
+        else if (format ==  PVMF_MIME_M4V)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_M4V;
+        else if (format ==  PVMF_MIME_H2632000)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_H2632000;
+        else if (format ==  PVMF_MIME_H2631998)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_H2631998;
+        else
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_FORMAT_UNKNOWN;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus H223OutgoingChannel::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if (parameters)
+    {
+        iKvpMemAlloc.deallocate((OsclAny*)parameters);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223OutgoingChannel::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223OutgoingChannel::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223OutgoingChannel::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223OutgoingChannel::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    OSCL_UNUSED_ARG(session);
+    PVMFStatus status = PVMFSuccess;
+    ret_kvp = NULL;
+
+    for (int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
+            ret_kvp = &(parameters[i]);
+            /* Silently ignore unrecognized codecs untill CapEx is supported by peer */
+            //OSCL_LEAVE(OsclErrArgument);
+        }
+    }
+}
+
+PVMFStatus H223OutgoingChannel::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    OSCL_UNUSED_ARG(aSetParam);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
+
+    if (!aKvp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::VerifyAndSetParameter: Error - Invalid key-value pair"));
+        return PVMFFailure;
+    }
+
+    if (iDataType == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::VerifyAndSetParameter: Error - DataType == NULL"));
+        return PVMFErrNotSupported;
+    }
+
+    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0)
+    {
+        PVCodecType_t codec_type = GetCodecType(iDataType);
+        PVMFFormatType lcn_format_type = PVCodecTypeToPVMFFormatType(codec_type);
+        if (pv_mime_strcmp(lcn_format_type.getMIMEStrPtr(), aKvp->value.pChar_value) != 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::VerifyAndSetParameter: Error - Input format %s not supported", aKvp->value.pChar_value));
+            return PVMFErrNotSupported;
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId H223OutgoingChannel::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 H223OutgoingChannel::getCapabilityMetric(PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus H223OutgoingChannel::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+
+    PVMFStatus status = PVMFSuccess;
+    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+
+    return status;
+}
+
+void H223OutgoingChannel::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    if (aActivity.iType != PVMF_PORT_ACTIVITY_INCOMING_MSG &&
+            aActivity.iType != PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::HandlePortActivity Unhandled port activity: %d", aActivity.iType));
+        return;
+    }
+    PVMFStatus aStatus;
+    PVMFSharedMediaMsgPtr aMsg;
+    while (IncomingMsgQueueSize())
+    {
+        aStatus = DequeueIncomingMsg(aMsg);
+        if (aStatus == PVMFSuccess)
+        {
+            PutData(aMsg);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223OutgoingChannel::HandlePortActivity Failed to DeQueue incoming message: %d", aStatus));
+            break;
+        }
+    }
+}
+
+PVMFStatus H223OutgoingControlChannel::PutData(PVMFSharedMediaMsgPtr aMsg)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingControlChannel::PutData - iNumPendingPdus=%d,iNumMediaData=%d", iNumPendingPdus, iNumMediaData));
+
+    PVMFSharedMediaDataPtr mediaData;
+    convertToPVMFMediaData(mediaData, aMsg);
+
+    PV_STAT_SET_TIME(iStartTime, iNumPacketsIn)
+    PV_STAT_INCR(iNumPacketsIn, 1)
+    PV_STAT_INCR(iNumSdusIn, 1)
+    PV_STAT_INCR(iNumBytesIn, (mediaData->getFilledSize()))
+
+    OsclSharedPtr<PVMFMediaDataImpl> pdu;
+    pdu = iMediaFragGroupAlloc->allocate();
+
+    if (!pdu)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingControlChannel::PutData - Memory allocation failure on iMediaFragGroupAlloc->allocate\n"));
+        return PVMFErrNoMemory;
+    }
+
+    TimeValue timenow;
+    OsclRefCounterMemFrag frag;
+    for (uint frag_num = 0; frag_num < mediaData->getNumFragments(); frag_num++)
+    {
+        mediaData->getMediaFragment(frag_num, frag);
+        // Add data fragments
+        pdu->appendMediaFragment(frag);
+    }
+
+    PVMFStatus status = iAl->CompletePacket(pdu);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingControlChannel::PutData - Memory allocation failure on iAl->CompletePacket()"));
+        return status;
+    }
+
+    OsclRefCounterMemFrag fsi;
+    bool fsi_available = mediaData->getFormatSpecificInfo(fsi);
+    // Add it to the outgoing queue
+    if (PVMFSuccess != AppendOutgoingPkt(pdu, timenow.to_msec(), (fsi_available ? &fsi : NULL)))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingControlChannel::PutData - Memory allocation failure on AppendOutgoingPkt()"));
+        return PVMFErrNoMemory;
+    }
+    return PVMFSuccess;
+}
+
+void H223LogicalChannel::SetDatapathLatency(uint32 aLatency)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LogicalChannel::SetDatapathLatency lcn=%d, aLatency=%d", lcn, aLatency));
+    iDatapathLatency = aLatency;
+}
+
+PVMFStatus H223LogicalChannel::setConfigParametersSync(PvmiKvp* selectedKvp,
+        PvmiCapabilityAndConfig* aConfig,
+        PVMFFormatType lcn_format_type,
+        bool aTryTwice)
+{
+    int32 err = 0;
+    PvmiKvp* retKvp = NULL;
+    if (!aTryTwice)
+    {
+        OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
+        OSCL_FIRST_CATCH_ANY(err,
+                             PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::setConfigParametersSync, Error:  setParametersSync failed, err=%d", err));
+                             return PVMFFailure;
+                            );
+    }
+    else
+    {
+        int32 err = 0;
+        OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
+        if (err)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::setConfigParametersSync, Error:  setParametersSync failed for pChar value, trying uint32, err=%d", err));
+            selectedKvp->value.pChar_value = OSCL_STATIC_CAST(mbchar*, lcn_format_type.getMIMEStrPtr());
+            err = 0;
+            OSCL_TRY(err, aConfig->setParametersSync(NULL, selectedKvp, 1, retKvp););
+            if (err)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::setConfigParametersSync, Error:  setParametersSync failed, err=%d", err));
+                return PVMFFailure;
+            }
+        }
+    }
+    return PVMFSuccess;
+}
+H223IncomingChannel::H223IncomingChannel(TPVChannelId num,
+        bool segmentable,
+        OsclSharedPtr<AdaptationLayer>& al,
+        PS_DataType data_type,
+        LogicalChannelObserver* observer,
+        uint32 bitrate,
+        uint32 sample_interval,
+        uint32 num_media_data)
+        : H223LogicalChannel(num, segmentable, al, data_type, observer, bitrate, sample_interval, num_media_data),
+        iMediaMsgMemoryPool(NULL),
+        iMediaFragGroupAlloc(NULL),
+        iPduPktMemPool(NULL),
+        iMediaDataAlloc(&iMemAlloc),
+        iPduSize(al->GetPduSize()),
+        iCurPduSize(0),
+        iRenderingSkew(0)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.H223IncomingChannel");
+    iIncomingAudioLogger = PVLogger::GetLoggerObject("datapath.incoming.audio.h223.lcn");
+    iIncomingVideoLogger = PVLogger::GetLoggerObject("datapath.incoming.video.h223.lcn");
+    iAlPduFragPos = NULL;
+    ResetStats();
+}
+
+H223IncomingChannel::~H223IncomingChannel()
+{
+    Flush();
+    OsclRefCounterMemFrag frag;
+    iAlPduFrag = frag;
+    if (iMediaFragGroupAlloc)
+    {
+        iMediaFragGroupAlloc->removeRef();
+    }
+    if (iPduPktMemPool)
+    {
+        OSCL_DELETE(iPduPktMemPool);
+    }
+    if (iMediaMsgMemoryPool)
+    {
+        OSCL_DELETE(iMediaMsgMemoryPool);
+    }
+}
+
+void H223IncomingChannel::Init()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Init"));
+    H223LogicalChannel::Init();
+
+    int bitrate = (GetBitrate() > 0) ? GetBitrate() : DEF_CHANNEL_BITRATE;
+    int mem_size = (DEF_INCOMING_CHANNEL_BUFFER_SIZE_MS * bitrate) >> PV2WAY_BPS_TO_BYTES_PER_MSEC_RIGHT_SHIFT;
+    int num_fragments = (mem_size / H223_INCOMING_CHANNEL_FRAGMENT_SIZE) + 1;
+    iMediaMsgMemoryPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (H223_INCOMING_CHANNEL_NUM_MEDIA_MSG));
+    if (iMediaMsgMemoryPool == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    iMediaMsgMemoryPool->enablenullpointerreturn();
+
+    iPduPktMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (H223_INCOMING_CHANNEL_NUM_MEDIA_DATA));
+    if (iPduPktMemPool == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    iPduPktMemPool->enablenullpointerreturn();
+
+    iMediaFragGroupAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (H223_INCOMING_CHANNEL_NUM_MEDIA_DATA, H223_INCOMING_CHANNEL_NUM_FRAGS_IN_MEDIA_DATA, iPduPktMemPool));
+    if (iMediaFragGroupAlloc == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    iMediaFragGroupAlloc->create();
+
+    iMemFragmentAlloc.SetLeaveOnAllocFailure(false);
+    iMemFragmentAlloc.size((uint16)num_fragments, (uint16)H223_INCOMING_CHANNEL_FRAGMENT_SIZE);
+
+    ResetAlPdu();
+    AllocateAlPdu();
+    iCurTimestamp = 0;
+    iNumSdusIn = 0;
+    iNumPdusIn = 0;
+}
+
+OsclAny H223IncomingChannel::ResetAlPdu()
+{
+    iAlPduFragPos = NULL;
+    iCurPduSize = 0;
+    OsclRefCounterMemFrag frag;
+    iAlPduFrag = frag;
+    iAlPduMediaData.Unbind();
+}
+
+OsclAny H223IncomingChannel::AllocateAlPdu()
+{
+    iAlPduMediaData = iMediaFragGroupAlloc->allocate();
+    if (iAlPduMediaData.GetRep() == NULL)
+    {
+        return;
+    }
+    AppendAlPduFrag();
+}
+
+OsclAny H223IncomingChannel::AppendAlPduFrag()
+{
+    OsclRefCounterMemFrag ref_counter_mem_frag = iMemFragmentAlloc.get();
+    if (ref_counter_mem_frag.getMemFragPtr() == NULL)
+    {
+        return;
+    }
+    ref_counter_mem_frag.getMemFrag().len = 0;
+    iAlPduFrag = ref_counter_mem_frag;
+    iAlPduFragPos = (uint8*)iAlPduFrag.getMemFragPtr();
+}
+
+uint32 H223IncomingChannel::CopyAlPduData(uint8* buf, uint16 len)
+{
+    int32 remaining = len;
+    uint32 copied = 0;
+    do
+    {
+        copied = CopyToCurrentFrag(buf, (uint16)remaining);
+        buf += copied;
+        remaining -= copied;
+    }
+    while (remaining && copied);
+    return (uint32)(len - remaining);
+}
+
+uint32 H223IncomingChannel::CopyToCurrentFrag(uint8* buf, uint16 len)
+{
+    if (iAlPduMediaData.GetRep() == NULL)
+    {
+        AllocateAlPdu();
+    }
+    else if (iAlPduFragPos == NULL)
+    {
+        AppendAlPduFrag();
+    }
+    if (iAlPduFragPos == NULL)
+    {
+        return 0;
+    }
+
+    uint32 space_in_current_frag = ((uint8*)iAlPduFrag.getMemFragPtr() + iAlPduFrag.getCapacity() - iAlPduFragPos);
+    OSCL_ASSERT(space_in_current_frag > 0);
+    uint32 num_bytes_copied = (len > space_in_current_frag) ? space_in_current_frag : len;
+    oscl_memcpy(iAlPduFragPos, buf, num_bytes_copied);
+    iAlPduFrag.getMemFrag().len += num_bytes_copied;
+    iAlPduFragPos += num_bytes_copied;
+    space_in_current_frag -= num_bytes_copied;
+    if (space_in_current_frag == 0)
+    {
+        iAlPduMediaData->appendMediaFragment(iAlPduFrag);
+        iAlPduFragPos = NULL;
+    }
+    PVLOGGER_LOG_USE_ONLY(
+        if (iAlPduMediaData->getFilledSize() > iPduSize)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::CopyToCurrentFrag WARNING current pdu size=%d > iPduSize=%d", iAlPduMediaData->getFilledSize(), iPduSize));
+    }
+    );
+    return num_bytes_copied;
+}
+
+void H223IncomingChannel::PreAlPduData()
+
+{
+    if (iSendFormatSpecificInfo)
+    {
+        SendFormatSpecificInfo();
+    }
+
+    if (iPaused)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::PreAlPduData Logical channel paused.  Dropping media data."));
+        return;
+    }
+}
+
+PVMFStatus H223IncomingChannel::AlPduData(uint8* buf, uint16 len)
+{
+    PV_STAT_INCR(iNumBytesIn, len)
+    PV_STAT_SET_TIME(iStartTime, iNumBytesIn)
+
+    PreAlPduData();
+    if (PVMFSuccess != DispatchPendingSdus())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::AlPduData lcn=%d, Failed to dispatch pending sdus", lcn));
+    }
+    if (iAlPduMediaData.GetRep() == NULL || iAlPduMediaData->getFilledSize() == 0)
+    {
+        bool overflow = false;
+        iClock->GetCurrentTime32(iCurTimestamp, overflow, PVMF_MEDIA_CLOCK_MSEC);
+    }
+    uint32 copied = CopyAlPduData(buf, len);
+    return (copied == len) ? PVMFSuccess : PVMFFailure;
+}
+
+PVMFStatus H223IncomingChannel::AlDispatch()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::AlDispatch lcn=%d, iCurPduSize=%d, sn=%d", lcn, iCurPduSize, iNumSdusIn));
+    IncomingALPduInfo info;
+
+    if (iPaused)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::AlDispatch Logical channel paused."));
+        return PVMFFailure;
+    }
+
+    /*  Nothing to dispatch */
+    if (!iAlPduMediaData.GetRep())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::AlDispatch Nothing to dispatch."));
+        ResetAlPdu();
+        return PVMFSuccess;
+    }
+
+    /*  Add pending fragment to the media message */
+    if (iAlPduFragPos)
+    {
+        iAlPduMediaData->appendMediaFragment(iAlPduFrag);
+    }
+
+    /* Parse AL headers etc */
+    iAl->ParsePacket(iAlPduMediaData, info);
+    int32 len = info.sdu_size;
+    if (len <= 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223OutgoingChannel::AlDispatch Empty SDU lcn=%d, len=%d", lcn, len));
+        ResetAlPdu();
+        return PVMFErrCorrupt;
+    }
+
+    PV_STAT_INCR_COND(iNumCrcErrors, 1, info.crc_error)
+    PV_STAT_INCR_COND(iNumSeqNumErrors, 1, info.seq_num_error)
+    PVMFStatus status = PVMFSuccess;
+
+    // set the errors flag
+    uint32 errorsFlag = 0;
+    if (info.crc_error)
+    {
+        errorsFlag |= PVMF_MEDIA_DATA_BIT_ERRORS;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::AlDispatch CRC error lcn=%d, size=%d", lcn, len));
+        status =  PVMFErrCorrupt;
+    }
+    else
+    {
+        PV_STAT_INCR(iNumSdusIn, 1)
+    }
+    if (info.seq_num_error)
+    {
+        errorsFlag |= PVMF_MEDIA_DATA_PACKET_LOSS;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::AlDispatch Sequence number error lcn=%d, size=%d", lcn, len));
+        status = PVMFErrCorrupt;
+    }
+
+    OsclSharedPtr<PVMFMediaData> aMediaData = PVMFMediaData::createMediaData(iAlPduMediaData, iMediaMsgMemoryPool);
+    if (aMediaData.GetRep() == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    PVMFTimestamp baseTimestamp = 0;
+    SetSampleTimestamps(baseTimestamp);
+    aMediaData->setTimestamp(baseTimestamp);
+
+    iAlPduMediaData->setErrorsFlag(errorsFlag);
+
+    PVMFSharedMediaMsgPtr aMediaMsg;
+    convertToPVMFMediaMsg(aMediaMsg, aMediaData);
+
+    PVMFFormatType mediaType = GetFormatType();
+    if (mediaType.isCompressed() && mediaType.isAudio())
+    {
+        // we are using only full audio frames
+        aMediaData->setMarkerInfo(PVMF_MEDIA_DATA_MARKER_INFO_M_BIT);
+    }
+
+    if (IsConnected())
+    {
+        if (mediaType.isCompressed() && mediaType.isAudio())
+        {
+            PVMF_INCOMING_AUDIO_LOGDATATRAFFIC((0, "Incoming audio SDU received. Stats: Entry time=%d, lcn=%d, size=%d,FmtType=%s", iCurTimestamp, lcn, aMediaData->getFilledSize(), mediaType.getMIMEStrPtr()));
+        }
+        else if (mediaType.isCompressed() && mediaType.isVideo())
+        {
+            PVMF_INCOMING_VIDEO_LOGDATATRAFFIC((0, "Incoming video SDU received.Stats: Entry time=%d, lcn=%d, size=%d,FmtType=%s", iCurTimestamp, lcn, aMediaData->getFilledSize(), mediaType.getMIMEStrPtr()));
+        }
+        PVMFStatus dispatch_status = QueueOutgoingMsg(aMediaMsg);
+        if (dispatch_status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::AlDispatch Failed to queue outgoing media message lcn=%d, size=%d, status=%d", lcn, len, dispatch_status));
+            status = dispatch_status;
+        }
+    }
+    else if (IsSegmentable())
+    {
+        iPendingSdus.push_back(aMediaMsg);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::AlDispatchL Dropping pdu lcn=%d, iCurPduSize=%d", lcn, iCurPduSize));
+        status = PVMFErrNotReady;
+    }
+    ResetAlPdu();
+    AllocateAlPdu();
+    return status;
+}
+
+OsclAny H223IncomingChannel::Flush()
+{
+    PV_STAT_INCR(iNumBytesFlushed, (iAlPduFragPos - (uint8*)iAlPduFrag.getMemFragPtr()))
+    PV_STAT_INCR_COND(iNumAbort, 1, (iAlPduFragPos - (uint8*)iAlPduFrag.getMemFragPtr()))
+    iPendingSdus.clear();
+    ResetAlPdu();
+
+}
+
+PVMFStatus H223IncomingChannel::Connect(PVMFPortInterface* aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect lcn(%d)\n", lcn));
+    if (iConnectedPort)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect Error: Already connected"));
+        return PVMFFailure;
+    }
+
+    PvmiCapabilityAndConfig* config = NULL;
+    OsclAny * tempInterface = NULL;
+    aPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, tempInterface);
+    config = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, tempInterface);
+    if (!config)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect: Error - Peer port does not support capability interface"));
+        return PVMFFailure;
+    }
+
+    PVMFStatus status = NegotiateOutputSettings(config);
+
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect: Error - Settings negotiation failed. status=%d", status));
+        return status;
+    }
+
+    //Automatically connect the peer.
+    if ((status = aPort->PeerConnect(this)) != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect: Error - Peer Connect failed. status=%d", status));
+        return status;
+    }
+
+    iConnectedPort = aPort;
+
+    //Check the BOS command status
+    status = SendBeginOfStreamMediaCommand();
+
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect: Failed to send BOS message status=%d", status));
+        return status;
+    }
+
+    /* Send any format specific info if available */
+    if (iSendFormatSpecificInfo)
+        SendFormatSpecificInfo();
+
+    DispatchPendingSdus();
+
+    PortActivity(PVMF_PORT_ACTIVITY_CONNECT);
+
+    return PVMFSuccess;
+}
+
+OsclAny H223IncomingChannel::ResetStats()
+{
+    iNumSdusIn = 0;
+    iNumBytesIn = 0;
+    iSduSizeExceededCnt = 0;
+    iNumCrcErrors = 0;
+    iNumSeqNumErrors = 0;
+    iNumBytesFlushed = 0;
+    iNumAbort = 0;
+}
+
+OsclAny H223IncomingChannel::LogStats()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Incoming Logical Channel %d Statistics:\n", lcn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus received - %d\n", iNumSdusIn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes received - %d\n", iNumBytesIn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num times sdu size exceeded - %d\n", iSduSizeExceededCnt));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus with CRC errors - %d\n", iNumCrcErrors));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus with sequence number errors - %d\n", iNumSeqNumErrors));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num sdus aborted - %d\n", iNumAbort));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes aborted - %d\n", iNumBytesFlushed));
+}
+
+PVMFStatus H223IncomingChannel::DispatchPendingSdus()
+{
+    if (!iConnectedPort)
+        return PVMFFailure;
+    if (iPendingSdus.size())
+    {
+        /* Dispatch any pending sdus */
+        for (unsigned i = 0; i < iPendingSdus.size(); i++)
+        {
+            PVMFStatus status = QueueOutgoingMsg(iPendingSdus[i]);
+            if (status != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect Error: PutData failed for buffered sdus lcn=%d, status=%d, i=%d", lcn, status, i));
+                iObserver->LogicalChannelError(INCOMING, lcn, status);
+                return PVMFFailure;
+            }
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::Connect lcn=%d,num sdus=%d", lcn, iPendingSdus.size()));
+        iPendingSdus.clear();
+    }
+    return PVMFSuccess;
+}
+
+OsclAny H223IncomingChannel::SendFormatSpecificInfo()
+{
+    //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"H223IncomingChannel::SendFormatSpecificInfo lcn=%d, iFormatSpecificInfoLen=%d, iFormatSpecificInfo=%x", lcn,iFormatSpecificInfoLen,iFormatSpecificInfo));
+    //printBuffer(iLogger, iFormatSpecificInfo, (uint16)iFormatSpecificInfoLen);
+    if (!IsConnected())
+    {
+        //PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"H223IncomingChannel::SendFormatSpecificInfo ERROR Not connected."));
+        //OSCL_LEAVE(PVMFErrNotReady);
+        return;
+    }
+
+    // Create mem frag for VOL header
+    // Create new media data buffer for header fragment
+    OsclSharedPtr<PVMFMediaDataImpl> hdrImpl = iMediaDataAlloc.allocate(iFormatSpecificInfoLen);
+    if (!hdrImpl)
+    {
+        return;
+    }
+    PVMFSharedMediaDataPtr hdrMediaData = PVMFMediaData::createMediaData(hdrImpl);
+    OsclRefCounterMemFrag myVolHeader;
+    hdrMediaData->getMediaFragment(0, myVolHeader);
+    oscl_memcpy(myVolHeader.getMemFragPtr(), iFormatSpecificInfo, iFormatSpecificInfoLen);
+    myVolHeader.getMemFrag().len = iFormatSpecificInfoLen;
+
+    // Create new media data buffer for the message
+    OsclSharedPtr<PVMFMediaDataImpl> emptyImpl = iMediaDataAlloc.allocate(0);
+    if (!emptyImpl)
+    {
+        return;
+    }
+    PVMFSharedMediaDataPtr volData = PVMFMediaData::createMediaData(emptyImpl);
+
+    // Set format specific info in media data message
+    volData->setFormatSpecificInfo(myVolHeader);
+
+    // Send VOL header to downstream node
+    PVMFSharedMediaMsgPtr volMsg;
+    convertToPVMFMediaMsg(volMsg, volData);
+    PVMFStatus status = QueueOutgoingMsg(volMsg);
+    if (status != PVMFSuccess)
+    {
+        OSCL_LEAVE(status);
+    }
+    iSendFormatSpecificInfo = false;
+}
+
+MuxSduData::MuxSduData()
+{
+    size = 0;
+    cur_frag_num = 0;
+    cur_pos = 0;
+}
+PVMFStatus H223IncomingChannel::NegotiateOutputSettings(PvmiCapabilityAndConfig* aConfig)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::NegotiateInputSettings, aConfig=%x", aConfig));
+
+    PvmiKvp* kvp = NULL;
+    int numParams = 0;
+    int32 i = 0;
+
+    // Get supported input formats from peer
+    PVMFStatus status = aConfig->getParametersSync(NULL,
+                        OSCL_CONST_CAST(char*, INPUT_FORMATS_CAP_QUERY),
+                        kvp, numParams, NULL);
+
+    if (status != PVMFSuccess)
+    {
+        status = aConfig->getParametersSync(NULL,
+                                            OSCL_CONST_CAST(char*, "x-pvmf/video/decode/input_formats"),
+                                            kvp, numParams, NULL);
+    }
+
+    if (status != PVMFSuccess || numParams == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::NegotiateInputSettings, Error:  getParametersSync failed.  status=%d", status));
+
+        return PVMFSuccess;
+    }
+
+    PvmiKvp* selectedKvp = NULL;
+    PVCodecType_t codec_type = GetCodecType(iDataType);
+    PVMFFormatType lcn_format_type = PVCodecTypeToPVMFFormatType(codec_type);
+
+    for (i = 0; i < numParams && !selectedKvp; i++)
+    {
+        if (lcn_format_type == kvp[i].value.pChar_value)
+            selectedKvp = &(kvp[i]);
+    }
+
+    if (!selectedKvp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::NegotiateInputSettings, Error:  Input format not supported by peer"));
+        return PVMFFailure;
+    }
+
+    /* This is for the silly problem of MIO components having the convention
+       of returning uint32 for a query and requiring pChar for a setting
+       we don't know if we are talking to an MIO or a decoder node
+       (which will want a uint32), so we try both.  Try the pchar
+       first, because if its expecting pchar and gets uint32, it will
+       crash.
+    */
+    if (PVMFSuccess != setConfigParametersSync(selectedKvp, aConfig, lcn_format_type, true))
+        return PVMFFailure;
+
+    aConfig->releaseParameters(NULL, kvp, numParams);
+    kvp = NULL;
+    numParams = 0;
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                  PvmiCapabilityAndConfig
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223IncomingChannel::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    // Not supported
+    OSCL_UNUSED_ARG(aObserver);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus H223IncomingChannel::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::getParametersSync"));
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+    parameters = NULL;
+    num_parameter_elements = 0;
+
+    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        PVMFStatus status = AllocateKvp(iKvpMemAlloc, parameters,
+                                        OSCL_CONST_CAST(char*, OUTPUT_FORMATS_VALTYPE),
+                                        num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::getParametersSync: Error - AllocateKvp failed. status=%d", status));
+            return status;
+        }
+        PVCodecType_t codec_type = GetCodecType(iDataType);
+        PVMFFormatType format = PVCodecTypeToPVMFFormatType(codec_type).getMIMEStrPtr();
+        if (format == PVMF_MIME_AMR_IF2)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_AMR_IF2;
+        else if (format == PVMF_MIME_PCM16)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_PCM16;
+        else if (format ==  PVMF_MIME_YUV420)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_YUV420;
+        else if (format ==  PVMF_MIME_M4V)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_M4V;
+        else if (format ==  PVMF_MIME_H2632000)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_H2632000;
+        else if (format ==  PVMF_MIME_H2631998)
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_H2631998;
+        else
+            parameters[0].value.pChar_value = (char*) PVMF_MIME_FORMAT_UNKNOWN;
+
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus H223IncomingChannel::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if (parameters)
+    {
+        iKvpMemAlloc.deallocate((OsclAny*)parameters);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223IncomingChannel::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223IncomingChannel::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223IncomingChannel::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void H223IncomingChannel::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    OSCL_UNUSED_ARG(session);
+    PVMFStatus status = PVMFSuccess;
+    ret_kvp = NULL;
+
+    for (int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
+            ret_kvp = &(parameters[i]);
+            /* Silently ignore unrecognized codecs untill CapEx is supported by peer */
+            //OSCL_LEAVE(OsclErrArgument);
+        }
+    }
+}
+
+PVMFStatus H223IncomingChannel::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    OSCL_UNUSED_ARG(aSetParam);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
+
+    if (!aKvp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::VerifyAndSetParameter: Error - Invalid key-value pair"));
+        return PVMFFailure;
+    }
+
+    if (iDataType == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::VerifyAndSetParameter: Error - DataType == NULL"));
+        return PVMFErrNotSupported;
+    }
+
+    if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
+    {
+        PVCodecType_t codec_type = GetCodecType(iDataType);
+        PVMFFormatType lcn_format_type = PVCodecTypeToPVMFFormatType(codec_type);
+        if (lcn_format_type != aKvp->value.pChar_value)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::VerifyAndSetParameter: Error - Output format %s not supported", aKvp->value.pChar_value));
+            return PVMFErrNotSupported;
+        }
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId H223IncomingChannel::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 H223IncomingChannel::getCapabilityMetric(PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus H223IncomingChannel::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+
+    PVMFStatus status = PVMFSuccess;
+    for (int32 i = 0; (i < num_elements) && (status == PVMFSuccess); i++)
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+
+    return status;
+}
+
+void H223IncomingChannel::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    if (aActivity.iType != PVMF_PORT_ACTIVITY_OUTGOING_MSG &&
+            aActivity.iType != PVMF_PORT_ACTIVITY_CONNECTED_PORT_READY)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::HandlePortActivity Unhandled port activity: %d", aActivity.iType));
+        return;
+    }
+    PVMFStatus aStatus;
+    PVMFSharedMediaMsgPtr aMsg;
+    while (OutgoingMsgQueueSize())
+    {
+        aStatus = Send();
+        if (aStatus != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223IncomingChannel::HandlePortActivity Failed to DeQueue incoming message: %d", aStatus));
+            break;
+        }
+    }
+}
+
+PVMFStatus H223IncomingChannel::SendBeginOfStreamMediaCommand()
+{
+    PVMFSharedMediaCmdPtr sharedMediaCmdPtr = PVMFMediaCmd::createMediaCmd();
+    sharedMediaCmdPtr->setFormatID(PVMF_MEDIA_CMD_BOS_FORMAT_ID);
+
+    sharedMediaCmdPtr->setTimestamp(iCurTimestamp);
+
+    uint32 seqNum = 0;
+    uint32 streamID = 0;
+    sharedMediaCmdPtr->setSeqNum(seqNum);
+
+    PVMFSharedMediaMsgPtr mediaMsgOut;
+    convertToPVMFMediaCmdMsg(mediaMsgOut, sharedMediaCmdPtr);
+    mediaMsgOut->setStreamID(streamID);
+
+    PVMFStatus status = QueueOutgoingMsg(mediaMsgOut);
+    if (status != PVMFSuccess)
+    {
+        // Output queue is busy, so wait for the output queue being ready
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "H223IncomingChannel::SendBeginOfMediaStreamCommand: Outgoing queue busy. "));
+        return status;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223IncomingChannel::SendBeginOfMediaStreamCommand() BOS Sent StreamId %d ", streamID));
+    return status;
+}
+
+void H223IncomingChannel::SetSampleTimestamps(PVMFTimestamp& aTSOffset)
+{
+    iRenderingSkew = iAudioLatency - iVideoLatency;
+    uint32 skewDelta = 0;
+    if (iRenderingSkew >= (int32)iIncomingSkew)
+    {
+        skewDelta = iRenderingSkew - iIncomingSkew;
+        if (iMediaType.isCompressed() && iMediaType.isAudio())
+        {
+            aTSOffset = (PVMFTimestamp)(iAudioLatency + PARSING_JITTER_DURATION);
+        }
+        else if (iMediaType.isCompressed() && iMediaType.isVideo())
+        {
+            aTSOffset = (PVMFTimestamp)(iVideoLatency + skewDelta + PARSING_JITTER_DURATION);
+        }
+    }
+    else if (iRenderingSkew < (int32)iIncomingSkew)
+    {
+        skewDelta = iIncomingSkew - iRenderingSkew;
+        if (iMediaType.isCompressed() && iMediaType.isAudio())
+        {
+            aTSOffset = (PVMFTimestamp)(iAudioLatency + PARSING_JITTER_DURATION + skewDelta);
+        }
+        else if (iMediaType.isCompressed() && iMediaType.isVideo())
+        {
+            aTSOffset = (PVMFTimestamp)(iVideoLatency + PARSING_JITTER_DURATION);
+        }
+    }
+    aTSOffset += iCurTimestamp;
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/lowerlayer.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/lowerlayer.cpp
new file mode 100644
index 0000000..e9569ba
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/lowerlayer.cpp
@@ -0,0 +1,960 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_time.h"
+#include "lowerlayer.h"
+#include "media_fragment.h"
+#include "h223.h"
+#include "pvlogger.h"
+#include "level0.h"
+#include "level1.h"
+#include "level2.h"
+
+#define PV_H223_MAIN_TIMER_ID 0
+#define H223_MIN_SAMPLE_INTERVAL 20
+#if defined(__WINS__) || defined(WIN32)
+#define TIMER_RES 100
+#else
+#define TIMER_RES 40
+#endif
+#define H223_MIN_TIMER_RESOLUTION 20
+#define H223_LEVEL_DEFAULT H223_LEVEL2
+
+#define H223_INITIAL_STUFFING_SEND_CNT 3
+#define H223_INITIAL_STUFFING_SEND_CNT_LEVEL0 25
+#define H223_SEND_PDU_SIZE_EXTRA 128
+
+#define CHECKSIZE 21
+
+#define H223_DEMUX_BUFFER_SIZE 2048
+
+H223LowerLayer::H223LowerLayer(int32 aPortTag, TPVLoopbackMode aLoopbackMode)
+        :   PvmfPortBaseImpl(aPortTag, this),
+        OsclTimerObject(OsclActiveObject::EPriorityHigh, "H223AO"),
+        iTimerIntervalNum(0),
+        iMinTimerResolution(TIMER_RES),
+        iObserver(NULL),
+        iMemFragmentAlloc(NULL),
+        iDispatchPacketAlloc(NULL),
+        iMediaDataImplMemAlloc(NULL),
+        iMediaMsgPoolAlloc(NULL),
+        iSendPduSz(0),
+        iPduSize(H223_DEFAULT_PDU_SIZE),
+        iStuffingSize(0),
+        iTimer("H223LL"),
+        iLoopbackMode(aLoopbackMode),
+        iTimerCnt(0),
+        iBytesSent(0),
+        iMediaDataAlloc(&iMemAlloc),
+        iLogger(NULL),
+        iDemuxBuffer(NULL),
+        iDemuxBufferPos(NULL),
+        iIdleSyncCheckBuffer(NULL)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.lowerlayer");
+    AddToScheduler();
+    InitParams();
+    ResetStats();
+}
+
+H223LowerLayer::~H223LowerLayer()
+{
+    Cancel();
+    RemoveFromScheduler();
+}
+
+void H223LowerLayer::InitParams()
+{
+    iMinTimerResolution = TIMER_RES;
+    iState = 0;
+    iStateVal = 0;
+
+    iBitrate = DEFAULT_BITRATE;
+
+    iUseAnnexA = true;
+    iUseAnnexADoubleFlag = true;
+    iUseAnnexB = true;
+    iUseAnnexBwithHeader = true;
+
+    for (uint16 level = H223_LEVEL0; level < H223_LEVEL_UNKNOWN; level++)
+    {
+        iStuffingSz[level] = (uint16)H223GetMuxStuffingSz((TPVH223Level)level);
+    }
+
+    UpdatePduSize();
+
+    InitRuntimeParams();
+    SetLevel(H223_LEVEL_DEFAULT);
+
+    iDemuxBufferSize = 0;
+    iSyncCheckCount = CHECKSIZE;
+    SetLoopbackMode(iLoopbackMode);
+    iSkipLevelCheck = false;
+}
+
+void H223LowerLayer::InitRuntimeParams()
+{
+    iState = iStateVal = 0;
+    iTimerCnt = 0;
+    iBytesSent = 0;
+    iLevelSetupComplete = false;
+    iSyncDetected = false;
+    iDataReceptionStart = false;
+}
+
+TPVStatusCode H223LowerLayer::Open()
+{
+    unsigned pdu_rate = (unsigned)(1000.0 / (float)H223_MIN_SAMPLE_INTERVAL + .5) + 1;
+    iMemFragmentAlloc = OSCL_NEW(PVMFBufferPoolAllocator, ());
+    iMemFragmentAlloc->SetLeaveOnAllocFailure(false);
+    iMemFragmentAlloc->size((uint16)(pdu_rate*2), (uint16)(iSendPduSz + H223_SEND_PDU_SIZE_EXTRA));
+
+    iMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (pdu_rate));
+    iMediaMsgPoolAlloc->enablenullpointerreturn();
+
+    uint media_data_imp_size = oscl_mem_aligned_size(sizeof(PVMFMediaFragGroup<OsclMemAllocator>)) +
+                               oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+    iMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (pdu_rate, media_data_imp_size));
+    iMediaDataImplMemAlloc->enablenullpointerreturn();
+    iDispatchPacketAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (pdu_rate, 30, iMediaDataImplMemAlloc));
+    iDispatchPacketAlloc->create();
+
+    iDemuxBufferSize = (uint32)((float)(H223_DEMUX_BUFFER_INTERVAL_MS * iBitrate) / 8000.0);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Open iBitrate=%d, iDemuxBufferSize=%d", iBitrate, iDemuxBufferSize));
+    iDemuxBufferPos = iDemuxBuffer = (uint8*)OSCL_DEFAULT_MALLOC(H223_DEMUX_BUFFER_SIZE);
+    iIdleSyncCheckBuffer = (uint8*)OSCL_DEFAULT_MALLOC(H223_DEMUX_BUFFER_SIZE);
+    return EPVT_Success;
+}
+
+TPVStatusCode H223LowerLayer::Close()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Close\n"));
+
+    OSCL_DEFAULT_FREE(iIdleSyncCheckBuffer);
+    iIdleSyncCheckBuffer = NULL;
+
+    OSCL_DEFAULT_FREE(iDemuxBuffer);
+    iDemuxBuffer = iDemuxBufferPos = NULL;
+
+    iDispatchPacketAlloc->removeRef();
+    iDispatchPacketAlloc = NULL;
+
+    OSCL_DELETE(iMediaMsgPoolAlloc);
+    iMediaMsgPoolAlloc = NULL;
+
+    OSCL_DELETE(iMediaDataImplMemAlloc);
+    iMediaDataImplMemAlloc = NULL;
+
+    iMemFragmentAlloc->clear();
+    OSCL_DELETE(iMemFragmentAlloc);
+    return EPVT_Success;
+}
+
+TPVStatusCode H223LowerLayer::Start(H223PduParcomSharedPtr aParcom)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Start(), parcom=%x", aParcom.GetRep()));
+    InitRuntimeParams();
+
+    if (aParcom.GetRep())
+    {
+        iParcom = aParcom;
+        iParcom->SetObserver(this);
+    }
+
+    /* Start timer */
+    iTimer.SetFrequency(1000 / iMinTimerResolution);
+    iTimer.SetObserver(this);
+    iTimer.Request(PV_H223_MAIN_TIMER_ID, PV_H223_MAIN_TIMER_ID , 1, this, 1);
+
+    iState = 1;
+    iSkipLevelCheck = false;
+    Mux();
+    return 1;
+}
+
+TPVStatusCode H223LowerLayer::Stop()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Stop"));
+
+    iTimer.Clear();
+
+    iState = 0;
+
+    iParcom.Unbind();
+
+    iDemuxBufferPos = iDemuxBuffer;
+
+    InitParams();
+    iState = 0;
+
+    return EPVT_Success;
+}
+
+int H223LowerLayer::Abort()
+{
+    iState = 0;
+
+    Disconnect();
+
+    //Flush remaining data.
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "LL:Abort Complete\n"));
+
+    return 1;
+}
+
+TPVStatusCode H223LowerLayer::SetLevel(TPVH223Level muxLevel)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SetLevel muxLevel=%d", muxLevel));
+
+    if (muxLevel == H223_LEVEL_UNKNOWN || muxLevel > H223_LEVEL2_OH)
+    {
+        OSCL_LEAVE(PVMFErrNotSupported);
+    }
+
+    CreateParcom(muxLevel);
+
+    SetStuffingSize(muxLevel);
+    return EPVT_Success;
+}
+
+TPVStatusCode H223LowerLayer::SetBitrate(uint32 bitRate)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux[LL]: SetBitrate Request(%d)\n", bitRate));
+    iBitrate = bitRate;
+    UpdatePduSize();
+    return EPVT_Success;
+}
+
+TPVStatusCode H223LowerLayer::SetMaxOutgoingPduSize(uint16 Size)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SetMaxOutgoingPduSize(%d)\n", Size));
+
+    if (Size < H223_MIN_PDU_SIZE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SetMaxOutgoingPduSize -  size < min(%d)!\n", H223_MIN_PDU_SIZE));
+        Size = H223_MIN_PDU_SIZE;
+    }
+    uint16 max_pdu_size = H223_MAX_MUX_PDU_SIZE;
+    if (iParcom->GetLevel() == H223_LEVEL2)
+    {
+        max_pdu_size = H223_MAX_MUX_PDU_SIZE_LEVEL2;
+    }
+    if (Size >= max_pdu_size)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SetMaxOutgoingPduSize - Size >= max_pdu_size(%d)\n", max_pdu_size));
+        return EPVT_Success;
+    }
+
+    SetPduSize(Size);
+    return EPVT_Success;
+}
+
+unsigned H223LowerLayer::SetPduSize(unsigned pdu_size)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SetPduSize - current(%d), new(%d)!\n", iPduSize, pdu_size));
+    if (pdu_size < iPduSize)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SetPduSize - setting pdu size to (%d)", pdu_size));
+        iPduSize = pdu_size;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SetPduSize - not setting pdu size "));
+    }
+    return iPduSize;
+}
+
+void H223LowerLayer::GetHdrFragment(OsclRefCounterMemFrag& hdr_frag)
+{
+    iParcom->GetHdrFragment(hdr_frag);
+}
+
+PVMFStatus H223LowerLayer::CompletePacket(OsclSharedPtr<PVMFMediaDataImpl>& packet, int mt_entry, int pm)
+{
+    PV_STAT_INCR(iNumPdusTx, 1)
+    PV_STAT_INCR(iNumMuxSduBytesTx, packet->getFilledSize() - iParcom->GetHeaderSz())
+    PV_STAT_INCR_COND(iNumPmTx, 1, pm)
+    return iParcom->CompletePdu(packet, (int8)mt_entry, (uint8)pm);
+}
+
+void H223LowerLayer::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timerID);
+    OSCL_UNUSED_ARG(timeoutInfo);
+    if (PVMFSuccess != Mux())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::TimeoutOccurred - Memory allocation failed on Mux()\n"));
+    }
+}
+
+/* H223PduParcomObserver virtuals */
+uint32 H223LowerLayer::MuxPduIndicate(uint8* pPdu, uint32 pduSz, int32 fClosing, int32 muxCode)
+{
+    return iObserver->GetParcomObserver()->MuxPduIndicate(pPdu, pduSz, fClosing, muxCode);
+}
+
+void H223LowerLayer::MuxPduErrIndicate(EMuxPduError err)
+{
+    iObserver->GetParcomObserver()->MuxPduErrIndicate(err);
+}
+
+void H223LowerLayer::MuxSetupComplete(PVMFStatus status, TPVH223Level level)
+{
+    OSCL_UNUSED_ARG(level);
+    if (status == PVMFPending)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::MuxSetupComplete Pending level setup for level=%d", level));
+        iSkipLevelCheck = true;
+        return;
+    }
+    if (status == PVMFSuccess)
+    {
+        iLevelSetupComplete = true;
+    }
+    SignalLevelSetupComplete(status);
+}
+
+void H223LowerLayer::Run()
+{
+}
+
+void H223LowerLayer::DoCancel()
+{
+    iTimer.Clear();
+    Cancel();
+}
+
+void H223LowerLayer::SendStuffingMsgHeader(uint8* stuffing, uint16 stuffing_len)
+{
+    OSCL_UNUSED_ARG(stuffing);
+    OSCL_UNUSED_ARG(stuffing_len);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SendStuffingMsgHeader stuffing(%x), len(%d)\n", stuffing, stuffing_len));
+#if 0
+    if (!IsConnected())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SendStuffingMsgHeader Error - not connected\n"));
+        return;
+    }
+
+    /* Send any format specific info if available */
+    if (stuffing_len > 0 && stuffing)
+    {
+        // Create mem frag for stuffing header
+        // Create new media data buffer for header fragment
+        OsclSharedPtr<PVMFMediaDataImpl> hdrImpl = iMediaDataAlloc.allocate(stuffing_len);
+        PVMFSharedMediaDataPtr hdrMediaData = PVMFMediaData::createMediaData(hdrImpl);
+        OsclRefCounterMemFrag stuffingFrag;
+        hdrMediaData->getMediaFragment(0, stuffingFrag);
+        oscl_memcpy(stuffingFrag.getMemFragPtr(), stuffing, stuffing_len);
+        stuffingFrag.getMemFrag().len = stuffing_len;
+
+        // Create new media data buffer for the message
+        OsclSharedPtr<PVMFMediaDataImpl> emptyImpl = iMediaDataAlloc.allocate(0);
+        PVMFSharedMediaDataPtr stuffingData = PVMFMediaData::createMediaData(emptyImpl);
+
+        // Set format specific info in media data message
+        stuffingData->setFormatSpecificInfo(stuffingFrag);
+
+        PVMFStatus status = PVMFSuccess;
+        if (iLoopbackMode == PV_LOOPBACK_MUX)
+            PacketIn(stuffingData);
+        else
+        {
+            // Send header to downstream node
+            PVMFSharedMediaMsgPtr stuffingMsg;
+            convertToPVMFMediaMsg(stuffingMsg, stuffingData);
+            status = iConnectedPort->PutData(stuffingMsg);
+        }
+
+        if (status != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SendStuffingMsgHeader Error - Peer node rejected stuffing msg\n"));
+            // leave
+            OSCL_LEAVE(PV2WayErrorRejected);
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "H223LowerLayer::SendStuffingMsgHeader Error - empty stuffing msg\n"));
+    }
+#endif
+}
+
+PVMFStatus H223LowerLayer::Mux()
+{
+
+    if (!IsConnected())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "H223LowerLayer::Mux - Error Port not connected"));
+        return PVMFFailure;
+    }
+    TimeValue timenow;
+    OsclSharedPtr<PVMFMediaDataImpl> dispatchPacket = iDispatchPacketAlloc->allocate(30);
+    if (!dispatchPacket)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "H223LowerLayer::Mux - Unable to allocate dispatchPacket"));
+        return PVMFFailure;
+    }
+
+    dispatchPacket->clearMediaFragments();
+
+    if (iSendTimes == 0)
+    {
+        iStartMuxTime = timenow;
+    }
+    iLastMuxTime = timenow;
+    PV_STAT_SET_TIME(iStartTimeTx, iNumBytesTx)
+    uint32 max_cnt = (iParcom->GetLevel() == H223_LEVEL0) ? H223_INITIAL_STUFFING_SEND_CNT_LEVEL0 : H223_INITIAL_STUFFING_SEND_CNT;
+
+    if (iSendTimes < max_cnt)
+    {
+        DoStuffing(iParcom->GetLevel(),
+                   dispatchPacket,
+                   iPduSize,
+                   0);
+        if (dispatchPacket->getFilledSize() == 0)
+        {
+            return PVMFFailure;
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Mux sendtimes %d, sending %d bytes of stuffing", iSendTimes, dispatchPacket->getFilledSize()));
+    }
+    else
+    {
+        if (iObserver)
+        {
+            PVMFStatus status = iObserver->GetOutgoingMuxPdus(iSendPacketList);
+            if (status != PVMFSuccess)
+            {
+                iSendPacketList.clear();
+                return status;
+            }
+        }
+
+        OsclRefCounterMemFrag dispatch_frag = iMemFragmentAlloc->get();
+        if (dispatch_frag.getMemFragPtr() == NULL)
+        {
+            iSendPacketList.clear();
+            return PVMFFailure;
+        }
+
+        uint8 *start_pos = (uint8*)dispatch_frag.getMemFragPtr();
+        uint8 *pos = start_pos;
+        uint16 max_size = (uint16)(iSendPduSz + H223_SEND_PDU_SIZE_EXTRA);
+        for (unsigned pktnum = 0; pktnum < iSendPacketList.size(); pktnum++)
+        {
+            for (unsigned frag_num = 0;frag_num < iSendPacketList[pktnum]->getNumFragments();frag_num++)
+            {
+                OsclRefCounterMemFrag frag;
+                iSendPacketList[pktnum]->getMediaFragment(frag_num, frag);
+                if (pos - start_pos + frag.getMemFragSize() > max_size)
+                    break;
+                oscl_memcpy(pos, frag.getMemFragPtr(), frag.getMemFragSize());
+                pos += frag.getMemFragSize();
+            }
+            iSendPacketList[pktnum]->clearMediaFragments();
+        }
+        iSendPacketList.clear();
+        dispatch_frag.getMemFrag().len = (uint16)(pos - start_pos);
+        if (dispatch_frag.getMemFrag().len)
+            dispatchPacket->appendMediaFragment(dispatch_frag);
+    }
+
+    DispatchPacket(dispatchPacket);
+    return PVMFSuccess;
+}
+
+void H223LowerLayer::MuxException()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::MuxException"));
+}
+
+void H223LowerLayer::Parse(uint8* buf, uint16 size)
+{
+    uint16 used_bytes = 0;
+    if (!size)
+        return;
+
+
+    if (!iSkipLevelCheck && !iLevelSetupComplete)
+    {
+        if (buf[0] != 0x7e && buf[0] != 0xe1)
+        {
+            oscl_memset(iIdleSyncCheckBuffer, buf[0], size);
+            if (oscl_memcmp(iIdleSyncCheckBuffer, buf, size) == 0)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Parse Detected idle sync=%x, dropping %d bytes", buf[0], size));
+                return;
+            }
+        }
+
+        // check for start of data reception
+        if (!iDataReceptionStart)
+        {
+            for (uint16 i = 0; i < size; i++)
+            {
+                if (buf[i] == 0xE1  || buf[i] == 0xA3 || buf[i] == 0x7E)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Parse Data reception started, byte=%x", buf[i]));
+                    iDataReceptionStart = true;
+                    iObserver->DataReceptionStart();
+                    break;
+                }
+            }
+            if (!iDataReceptionStart)
+            {
+                return;
+            }
+        }
+        if (CheckLevelWithSync(buf, size, &used_bytes))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux[LL]: Level Setup Complete - %d\n", iParcom->GetLevel()));
+            SignalLevelSetupComplete(PVMFSuccess);
+        }
+    }
+    if (iDataReceptionStart)
+    {
+        iParcom->Parse(buf, size);
+    }
+}
+
+void H223LowerLayer::DispatchPacket(OsclSharedPtr<PVMFMediaDataImpl>& pack)
+{
+    unsigned pkt_size = pack->getFilledSize();
+    PVMFStatus status = PVMFSuccess;
+
+    PV_STAT_INCR(iNumBytesTx, pkt_size)
+
+    OSCL_ASSERT(pkt_size > 0);
+
+    OsclSharedPtr<PVMFMediaData> aMediaData = PVMFMediaData::createMediaData(pack, iMediaMsgPoolAlloc);
+    if (aMediaData.GetRep() == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::DispatchPacket Failed to allocate media data"));
+        return;
+    }
+
+    if (iLoopbackMode == PV_LOOPBACK_MUX)
+    {
+        PacketIn(aMediaData);
+        iSendTimes++;
+    }
+    else
+    {
+        PVMFSharedMediaMsgPtr aMediaMsg;
+        convertToPVMFMediaMsg(aMediaMsg, aMediaData);
+        aMediaMsg->setSeqNum(iSendTimes++);
+        status = QueueOutgoingMsg(aMediaMsg);
+        if (status != PVMFSuccess && status != PVMFErrInvalidState)
+        {
+            // happens when we start sending data too soon
+            iObserver->LowerLayerError(OUTGOING, PV2WayDispatchError);
+        }
+    }
+
+    if ((iSendTimes % 100) == 0)
+    {
+        PVLOGGER_LOG_USE_ONLY(TimeValue timenow);
+        PVLOGGER_LOG_USE_ONLY(TimeValue delta_t = timenow - iStartTimeTx);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux::DispatchPacket - Sent %d bytes in time(%d ms)\n", iNumBytesTx, delta_t.to_msec()));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux::DispatchPacket - Received %d bytes in time(%d ms)\n", iNumBytesRx, delta_t.to_msec()));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux::DispatchPacket - Delta = %d\n", iNumBytesTx - iNumBytesRx));
+    }
+}
+
+/* Incoming packet from TSAP to be demuxed */
+void H223LowerLayer::PacketIn(PVMFSharedMediaDataPtr aMediaData)
+{
+    PV_STAT_SET_TIME(iStartTimeRx, iNumBytesRx)
+    OsclRefCounterMemFrag refCtrMemFrag;
+    unsigned cur_size = iDemuxBufferPos - iDemuxBuffer;
+    for (uint16 frag_num = 0; frag_num < aMediaData->getNumFragments(); frag_num++)
+    {
+        aMediaData->getMediaFragment(frag_num, refCtrMemFrag);
+        PV_STAT_INCR(iNumBytesRx, (refCtrMemFrag.getMemFragSize()))
+        if (refCtrMemFrag.getMemFragSize() > iDemuxBufferSize)
+        {
+            if (cur_size)
+            {
+                Parse(iDemuxBuffer, (uint16)cur_size);
+                iDemuxBufferPos = iDemuxBuffer;
+                cur_size = 0;
+            }
+            Parse((uint8*)refCtrMemFrag.getMemFragPtr(), (uint16)refCtrMemFrag.getMemFragSize());
+            iDemuxBufferSize = 0;
+            continue;
+        }
+        else
+        {
+            oscl_memcpy(iDemuxBufferPos, refCtrMemFrag.getMemFragPtr(), refCtrMemFrag.getMemFragSize());
+            iDemuxBufferPos += refCtrMemFrag.getMemFragSize();
+            cur_size += refCtrMemFrag.getMemFragSize();
+            iDemuxBufferSize -= refCtrMemFrag.getMemFragSize();
+        }
+    }
+}
+
+
+void H223LowerLayer::SignalLevelSetupComplete(PVMFStatus status)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::SignalLevelSetupComplete"));
+    TimeValue timenow;
+    iLevelSetupTime = timenow - iStartTimeTx;
+    iObserver->LevelSetupComplete(status, iParcom->GetLevel());
+}
+
+void H223LowerLayer::DoStuffing(TPVH223Level level,
+                                OsclSharedPtr<PVMFMediaDataImpl>& pkt,
+                                uint32 stuffing_sz,
+                                uint8 mux_code)
+{
+    OSCL_UNUSED_ARG(level);
+    if (!iParcom.GetRep())
+        return;
+
+    OsclRefCounterMemFrag stuffing_frag = iMemFragmentAlloc->get();
+    if (stuffing_frag.getMemFragPtr() == NULL)
+    {
+        return;
+    }
+
+    int bytes_to_stuff = stuffing_sz > stuffing_frag.getCapacity() ? stuffing_frag.getCapacity() : stuffing_sz;
+
+    uint32 sz = iParcom->GetStuffing((uint8*)stuffing_frag.getMemFragPtr(), bytes_to_stuff, mux_code);
+    if (sz)
+    {
+        stuffing_frag.getMemFrag().len = sz;
+        pkt->appendMediaFragment(stuffing_frag);
+        PV_STAT_INCR(iNumStuffingBytesTx, sz)
+    }
+
+    return;
+}
+
+/***********************************************************************
+  function name	       :CheckLevel
+  function outline     :
+  function discription :CheckLevel( pData, size )
+  input data		   :pData Pointer to data to use
+  output data		   :size  Size of data
+  draw time		       :'96.07.09
+*************************************************************************/
+#define STUFFING_BUF_SZ 8
+#define SYNC_DETECT_TOLERANCE_BITS 2
+bool H223LowerLayer::CheckLevelWithSync(uint8* pData, uint16 size, uint16* used_bytes)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "level check with sync, size(%d)", size));
+    uint8* pos = pData;
+
+    int sync_detected = false;
+    if (CheckLevel(pos, size, used_bytes, &sync_detected))
+    {
+        return true;
+    }
+    if (sync_detected)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevelWithSync - Sync detected, but level mismatch"));
+        // Reset iSendTimes to force the mux to send out stuffing H223_INITIAL_STUFFING_SEND_CNT times
+        iSendTimes = 0;
+        return false;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "level check with sync - done"));
+    return false;
+}
+
+bool H223LowerLayer::CheckLevel(uint8* pData, uint16 size, uint16* used_bytes, int* sync_detected)
+{
+    int j = 0;
+    int level = H223_LEVEL_UNKNOWN;
+    uint stuffing_sz =  0;
+    uint check_sz = 0;
+    uint8 stuffing_buf[STUFFING_BUF_SZ];
+    uint8* pos = pData;
+    uint32 check_cnt = 0;
+    *sync_detected  = false;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel size=%d, current level=%d, iSyncCheckCount=%d", size, iParcom->GetLevel(), iSyncCheckCount));
+
+    if (size < iSyncCheckCount*H223GetMuxStuffingSz(H223_LEVEL_DEFAULT))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel Size inadequate to complete sync check reqd=%d", H223GetMuxStuffingSz(H223_LEVEL_DEFAULT)));
+        return false;
+    }
+    level = (iParcom->GetLevel() == H223_LEVEL_UNKNOWN) ? H223_LEVEL_DEFAULT : iParcom->GetLevel();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel starting level=%d", level));
+
+    for (; level >= H223_LEVEL0; level--)
+    {
+        stuffing_sz =  H223GetMuxStuffingSz((TPVH223Level)level);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel checking level=%d, stuffing sz=%d", level, stuffing_sz));
+        H223MuxStuffing((TPVH223Level)level, stuffing_buf, STUFFING_BUF_SZ);
+        uint tolerance = (level == H223_LEVEL0) ? 0 : SYNC_DETECT_TOLERANCE_BITS;
+        if (level == H223_LEVEL1_DF)
+        {
+            continue;
+        }
+        check_sz = stuffing_sz * iSyncCheckCount;
+        for (j = 0; j < (int)(size - check_sz + 1); j++)
+        {
+            pos = pData + j;
+            check_cnt = 0;
+            for (unsigned checknum = 0; checknum < iSyncCheckCount; checknum++)
+            {
+                if (H223CheckSync((TPVH223Level)level, pos, stuffing_sz, tolerance))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel Found a match, check_cnt=%d", check_cnt));
+                    /* found a match */
+                    pos += stuffing_sz;
+                    *used_bytes = (uint16)(pos - pData);
+                    check_cnt++;
+                }
+                else
+                {
+                    check_cnt = 0;
+                    break;
+                }
+            }
+            if (check_cnt == iSyncCheckCount)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel Sync Detected for level=%d", level));
+                *sync_detected = true;
+                if (iParcom->GetLevel() == level)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel Level setup complete"));
+                    iLevelSetupComplete = true;
+                    return true;
+                }
+                if (!iSyncDetected)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::CheckLevel sync detected for level for first time(%d)", level));
+                    iSyncDetected = true;
+                    int32 err;
+                    OSCL_TRY(err, CreateParcom((TPVH223Level)level))
+                    OSCL_FIRST_CATCH_ANY(err, SignalLevelSetupComplete(PVMFErrNoMemory));
+                    iObserver->LevelSetupComplete(PVMFPending, (TPVH223Level)level);
+                    return false;
+                }
+            }
+        }
+    }
+
+    *used_bytes = (uint16)(pos - pData);
+    return false;
+}
+
+void H223LowerLayer::ResetStats()
+{
+    // Outgoing
+    iSendTimes = 0;
+    iNumBytesTx = 0;
+    iNumMuxSduBytesTx = 0;
+    iNumStuffingBytesTx = 0;
+    iNumPdusTx = 0;
+    iNumPmTx = 0;
+
+    // Incoming
+    iNumBytesRx = 0;
+
+    if (iParcom)
+    {
+        iParcom->ResetStats();
+    }
+}
+
+void H223LowerLayer::LogStats(TPVDirection dir)
+{
+    if (dir & OUTGOING)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux-pdu(O) Statistics:\n"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes tx - %d\n", iNumBytesTx));
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num mux-sdu bytes tx - %d\n", iNumMuxSduBytesTx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num stuffing bytes tx during level setup - %d\n", iNumStuffingBytesTx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num pdus tx - %d\n", iNumPdusTx));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num pm tx - %d\n", iNumPmTx));
+        if (iParcom)
+        {
+            iParcom->LogStats(OUTGOING);
+        }
+    }
+
+    if (dir & INCOMING)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux-pdu(I) Statistics:\n"));
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num bytes rx - %d\n", iNumBytesRx));
+        if (iParcom)
+        {
+            iParcom->LogStats(INCOMING);
+        }
+    }
+
+}
+
+unsigned H223LowerLayer::SetStuffingSize(TPVH223Level level)
+{
+    iStuffingSize = iStuffingSz[level];
+    return iStuffingSize;
+}
+
+
+/* PVMFPortInterface virtuals */
+// All requests are synchronous
+
+
+/* Incoming data from the network interface */
+PVMFStatus H223LowerLayer::PutData(PVMFSharedMediaMsgPtr aMsg)
+{
+    /* In mux loopback mode, discard data from connected port */
+    if (iLoopbackMode == PV_LOOPBACK_MUX)
+        return PVMFSuccess;
+    /* Dont processs data in invalid state */
+    if (iState <= 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::PutData Error - Invalid state(%d)", iState));
+        return PVMFErrInvalidState;
+    }
+
+    PVMFStatus pvmfStatus = PVMFSuccess;
+    /* Convert to media data */
+    PVMFSharedMediaDataPtr mediaData;
+    convertToPVMFMediaData(mediaData, aMsg);
+
+    PacketIn(mediaData);
+
+    return pvmfStatus;
+}
+
+int32 H223LowerLayer::GetTimestamp()
+{
+    return (iLastMuxTime -iStartMuxTime).to_msec();
+}
+
+void H223LowerLayer::UpdatePduSize()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::UpdatePduSize"));
+    iSendPduSz = (uint16)(iMinTimerResolution * iBitrate / (1000 * 8));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer: Send pdu size(%d), pdu size(%d)\n", iSendPduSz, iPduSize));
+}
+
+unsigned H223LowerLayer::GetSendSize()
+{
+    return iSendPduSz;
+}
+
+PVMFStatus H223LowerLayer::Connect(PVMFPortInterface* aPort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Connect"));
+    if (IsConnected())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Connect - Already Connected !!"));
+        return PVMFErrAlreadyExists;
+    }
+
+    PvmfPortBaseImpl::Connect(aPort);
+    return PVMFSuccess;
+}
+
+
+void H223LowerLayer::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    PVMFStatus aStatus;
+    if (aActivity.iType == PVMF_PORT_ACTIVITY_INCOMING_MSG)
+    {
+        PVMFSharedMediaMsgPtr aMsg;
+        while (IncomingMsgQueueSize())
+        {
+            aStatus = DequeueIncomingMsg(aMsg);
+            if (aStatus == PVMFSuccess)
+            {
+                PutData(aMsg);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223LowerLayer::HandlePortActivity Failed to DeQueue incoming message: %d", aStatus));
+                break;
+            }
+        }
+    }
+    else if (aActivity.iType == PVMF_PORT_ACTIVITY_OUTGOING_MSG)
+    {
+        while (OutgoingMsgQueueSize())
+        {
+            aStatus = Send();
+            if (aStatus != PVMFSuccess)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "H223LowerLayer::HandlePortActivity Failed to Send outgoing message: %d", aStatus));
+                break;
+            }
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::HandlePortActivity Unhandled port activity: %d", aActivity.iType));
+    }
+}
+void H223LowerLayer::SetLoopbackMode(TPVLoopbackMode aLoopbackMode)
+{
+    iLoopbackMode = aLoopbackMode;
+#if 0
+    if (iLoopbackMode != PV_LOOPBACK_NONE)
+        iLoopbackMode = PV_LOOPBACK_MUX;
+#endif
+}
+
+
+void H223LowerLayer::CreateParcom(TPVH223Level level)
+{
+    iParcom.Unbind();
+
+
+    H223PduParcom* parcom = NULL;
+
+    switch (level)
+    {
+        case H223_LEVEL0:
+            parcom = OSCL_NEW(Level0PduParcom, ());
+            break;
+        case H223_LEVEL1:
+        case H223_LEVEL1_DF:
+            parcom = OSCL_NEW(Level1PduParcom, ());
+            if (level == H223_LEVEL1)
+                break;
+            ((Level1PduParcom*)parcom)->UseDf(true);
+            break;
+        case H223_LEVEL2:
+        case H223_LEVEL2_OH:
+            parcom = OSCL_NEW(Level2PduParcom, ());
+
+            if (level == H223_LEVEL2)
+                break;
+            ((Level2PduParcom*)parcom)->UseOh(true);
+            break;
+        default:
+            OSCL_LEAVE(PVMFErrArgument);
+            ;
+    }
+    PduParcomRefCounter *refCounter = OSCL_NEW(PduParcomRefCounter, (parcom));
+    H223PduParcomSharedPtr sharedPtr(parcom, refCounter);
+    iParcom = sharedPtr;
+
+    uint16 pdu_rate = (uint16)((1000.0 / (float)H223_MIN_TIMER_RESOLUTION + .5) + 1);
+    pdu_rate <<= 1; /* Double it since it will be used for video and control data also */
+    iParcom->Construct(pdu_rate);
+    iParcom->SetObserver(this);
+    SetStuffingSize(level);
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h223/src/muxtbl.cpp b/protocols/systems/3g-324m_pvterminal/h223/src/muxtbl.cpp
new file mode 100644
index 0000000..59620d7
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h223/src/muxtbl.cpp
@@ -0,0 +1,324 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_mem.h"
+#include "muxtbl.h"
+#include "h245_deleter.h"
+#include "h245_copier.h"
+#include "oscl_mem.h"
+#ifndef	_h324utils_h
+#include "h324utils.h"
+#endif
+#define ON 1
+#define OFF 0
+#define ACTIVATE 1
+#define DEACTIVATE 0
+
+#define SRP_MUX_ENTRY_NUMBER 0
+#define WNSRP_MUX_ENTRY_NUMBER 15
+
+MuxTableMgr::MuxTableMgr(): iOutgoingDescriptors(NULL)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h223.muxtable");
+    iOutgoingMuxTblCount = 0;
+    iIncomingMuxTblCount = 0;
+
+    uint16 entry_num;
+    for (entry_num = 0; entry_num < MAX_MUX_ENTRIES; entry_num ++)
+    {
+        iMuxDescriptorR[entry_num] = NULL;
+    }
+
+    AddIncomingControlDescriptor();
+    iOutgoingDescriptors = OSCL_NEW(CPVMultiplexEntryDescriptorVector, ());
+    AddControlDescriptor(*iOutgoingDescriptors);
+
+    ResetStats();
+}
+
+MuxTableMgr::~MuxTableMgr()
+{
+    for (int32 entry_num = 0; entry_num < MAX_MUX_ENTRIES; entry_num ++)
+    {
+        if (iMuxDescriptorR[entry_num])
+        {
+            Delete_MultiplexEntryDescriptor(iMuxDescriptorR[entry_num]);
+            OSCL_DEFAULT_FREE(iMuxDescriptorR[entry_num]);
+            iMuxDescriptorR[entry_num] = NULL;
+        }
+    }
+
+    if (iOutgoingDescriptors)
+    {
+        OSCL_DELETE(iOutgoingDescriptors);
+        iOutgoingDescriptors = NULL;
+    }
+}
+
+PS_MultiplexEntryDescriptor MuxTableMgr::GetControlDescriptor(uint16 mux_entry_num)
+{
+    PS_MultiplexEntryDescriptor desc;
+
+    desc = (PS_MultiplexEntryDescriptor)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntryDescriptor));
+    desc->multiplexTableEntryNumber = (uint8)mux_entry_num;
+    desc->option_of_elementList = true;
+    desc->size_of_elementList = 1;
+    desc->elementList = (PS_MultiplexElement)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexElement));
+
+    PS_MultiplexElement elem = 	desc->elementList;
+    elem->muxType.index = 0; /* logical channel, 1 = sub-elem list */
+    elem->muxType.logicalChannelNumber = 0;
+    elem->muxType.size = 1; /* size of element list */
+    elem->repeatCount.index = 1; /* ucf */
+    elem->repeatCount.finite = 0;
+
+    return desc;
+}
+
+OsclAny MuxTableMgr::AddIncomingControlDescriptor()
+{
+    iMuxDescriptorR[SRP_MUX_ENTRY_NUMBER]  = GetControlDescriptor(SRP_MUX_ENTRY_NUMBER);
+    iMuxDescriptorFlagR[SRP_MUX_ENTRY_NUMBER] = ACTIVATE;
+    iMuxDescriptorR[WNSRP_MUX_ENTRY_NUMBER]  = GetControlDescriptor(WNSRP_MUX_ENTRY_NUMBER);
+    iMuxDescriptorFlagR[WNSRP_MUX_ENTRY_NUMBER] = ACTIVATE;
+}
+
+void MuxTableMgr::AddControlDescriptor(CPVMultiplexEntryDescriptorVector& descriptors)
+{
+//	PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0,"MuxTableMgr::AddControlDescriptor\n"));
+    PS_MultiplexEntryDescriptor h245_desc = GetControlDescriptor(SRP_MUX_ENTRY_NUMBER);
+    CPVMultiplexEntryDescriptor* descriptor = CPVMultiplexEntryDescriptor::NewL(h245_desc, 128);
+    descriptors.push_back(descriptor);
+    Delete_MultiplexEntryDescriptor(h245_desc);
+    OSCL_DEFAULT_FREE(h245_desc);
+}
+
+OsclAny MuxTableMgr::SetIncomingDescriptors(PS_MuxDescriptor mux_desc)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::SetIncomingDescriptors"));
+    PS_MultiplexEntryDescriptor  descriptor = mux_desc->multiplexEntryDescriptors;
+    uint8 entry_num = 0;
+    for (int32 num = 0; num < mux_desc->size_of_multiplexEntryDescriptors; num++)
+    {
+        entry_num = descriptor->multiplexTableEntryNumber;
+        if (iMuxDescriptorR[entry_num])
+        {
+            RemoveDescriptorR(entry_num);
+            iMuxDescriptorFlagR[entry_num] = DEACTIVATE;
+        }
+
+        if (descriptor->option_of_elementList == true)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::SetIncomingDescriptors Adding mux entry=%d", entry_num));
+            iMuxDescriptorR[entry_num] = Copy_MultiplexEntryDescriptor(descriptor);
+            iMuxDescriptorFlagR[entry_num] = ACTIVATE;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::SetIncomingDescriptors Removing mux entry=%d", entry_num));
+        }
+        descriptor++;
+    }
+}
+
+OsclAny MuxTableMgr::SetIncomingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors, bool replace)
+{
+    for (unsigned n = 0; n < descriptors.size(); n++)
+    {
+        uint8 entry_num = descriptors[n]->GetH245descriptor()->multiplexTableEntryNumber;
+        if (iMuxDescriptorR[entry_num])
+        {
+            if (!replace)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0, "MuxTableMgr::SetIncomingDescriptors descriptor already exists for mux entry=%d and we are not to replace it!", entry_num));
+                continue;
+            }
+            RemoveDescriptorR(entry_num);
+            iMuxDescriptorFlagR[entry_num] = DEACTIVATE;
+        }
+        if (descriptors[n]->GetH245descriptor()->option_of_elementList == true)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::SetIncomingDescriptors Adding mux entry=%d", entry_num));
+            iMuxDescriptorR[entry_num] = Copy_MultiplexEntryDescriptor(descriptors[n]->GetH245descriptor());
+            iMuxDescriptorFlagR[entry_num] = ACTIVATE;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::SetIncomingDescriptors Removing mux entry=%d", entry_num));
+        }
+    }
+}
+
+void MuxTableMgr::SetOutgoingMuxDescriptors(CPVMultiplexEntryDescriptorVector& descriptors)
+{
+    if (!iOutgoingDescriptors)
+    {
+        iOutgoingDescriptors = OSCL_NEW(CPVMultiplexEntryDescriptorVector, ());
+    }
+    for (unsigned n = 0; n < descriptors.size(); n++)
+    {
+        iOutgoingDescriptors->push_back(OSCL_NEW(CPVMultiplexEntryDescriptor, (*descriptors[n])));
+    }
+}
+
+void MuxTableMgr::RemoveOutgoingMuxDescriptor(uint8 muxTblNum)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::RemoveOutgoingMuxDescriptor muxTblNum(%d)", muxTblNum));
+    if (iOutgoingDescriptors == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::RemoveOutgoingMuxDescriptor iOutgoingDescriptors==NULL"));
+        return;
+    }
+    CPVMultiplexEntryDescriptorVector::iterator iter = iOutgoingDescriptors->begin();
+    while (iter != iOutgoingDescriptors->end())
+    {
+        if ((*iter)->GetH245descriptor()->multiplexTableEntryNumber == muxTblNum)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::RemoveOutgoingMuxDescriptor Found the mux table entry"));
+            OSCL_DELETE(*iter);
+            iOutgoingDescriptors->erase(iter);
+            return;
+        }
+        iter++;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::RemoveOutgoingMuxDescriptor Failed to lookup multiplex entry"));
+}
+
+void MuxTableMgr::RemoveIncomingMuxDescriptor(uint8 muxTblNum)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "MuxTableMgr::RemoveIncomingMuxDescriptor muxTblNum(%d)", muxTblNum));
+    RemoveDescriptorR(muxTblNum);
+}
+
+bool MuxTableMgr::RemoveDescriptorR(uint8 entry_num)
+{
+    if (iMuxDescriptorR[entry_num])
+    {
+        Delete_MultiplexEntryDescriptor(iMuxDescriptorR[entry_num]);
+        OSCL_DEFAULT_FREE(iMuxDescriptorR[entry_num]);
+        iMuxDescriptorR[entry_num] = NULL;
+        iMuxDescriptorFlagR[entry_num] = DEACTIVATE;
+    }
+    return true;
+}
+
+PS_MultiplexEntryDescriptor
+MuxTableMgr::GetOutgoingDescriptor(MuxSduDataList& data_list)
+{
+    unsigned num_lcns_with_data = data_list.size();
+    for (unsigned desc_num = 0; desc_num < iOutgoingDescriptors->size(); desc_num++)
+    {
+        // check for num lcns match
+        if ((*iOutgoingDescriptors)[desc_num]->NumLcns() == num_lcns_with_data)
+        {
+            // check for individual lcns
+            MuxSduDataList::iterator it = data_list.begin();
+            bool found_match = true;
+            while (it != data_list.end())
+            {
+                MuxSduData& sdu_data = (*it++);
+                TPVMuxDescriptorSlot slot;
+                if (!(*iOutgoingDescriptors)[desc_num]->FindLcn((uint16)sdu_data.lcn->GetLogicalChannelNumber(), (uint16)(sdu_data.lcn->IsSegmentable() ? 0 : sdu_data.size), slot))
+                {
+                    found_match = false;
+                    break;
+                }
+                if (sdu_data.lcn->GetLogicalChannelNumber() == 0)
+                {
+                    (*iOutgoingDescriptors)[desc_num]->GetH245descriptor()->multiplexTableEntryNumber = 0;
+                    OsclRefCounterMemFrag fsi;
+                    bool fsi_available = sdu_data.sdu->getFormatSpecificInfo(fsi);
+                    if (fsi_available && fsi.getMemFragSize())
+                    {
+                        uint8* fsi_ptr = (uint8*)fsi.getMemFragPtr();
+                        (*iOutgoingDescriptors)[desc_num]->GetH245descriptor()->multiplexTableEntryNumber = fsi_ptr[0];
+                    }
+                }
+            }
+            if (found_match)
+            {
+                return (*iOutgoingDescriptors)[desc_num]->GetH245descriptor();
+            }
+        }
+    }
+    return NULL;
+}
+
+PS_MultiplexEntryDescriptor MuxTableMgr::GetOutgoingDescriptor(OsclSharedPtr<H223OutgoingChannel>& lcn,
+        PVMFSharedMediaDataPtr sdu)
+{
+    MuxSduData sdu_data;
+    sdu_data.lcn = lcn;
+    sdu_data.size = 0;
+    sdu_data.sdu = sdu;
+    iMuxSduDataList.push_back(sdu_data);
+    PS_MultiplexEntryDescriptor ret = GetOutgoingDescriptor(iMuxSduDataList);
+    iMuxSduDataList.clear();
+    return ret;
+}
+
+PS_MultiplexEntryDescriptor MuxTableMgr::GetIncomingDescriptor(uint8 tblNum)
+{
+    int lookup = tblNum & 0x0F;
+    PS_MultiplexEntryDescriptor desc = iMuxDescriptorR[lookup];
+    PV_STAT_INCR_COND(iNumCorruptMcRx, 1, (desc == NULL))
+    PV_STAT_INCR_COND(iMcAccessCntR[lookup], 1, desc);
+    return desc;
+}
+
+OsclAny MuxTableMgr::ResetStats()
+{
+    iNumCorruptMcRx = 0;
+    for (int32 entry_num = 0; entry_num < MAX_MUX_ENTRIES; entry_num ++)
+    {
+        iMcAccessCnt[entry_num] = 0;
+        iMcAccessCntR[entry_num] = 0;
+    }
+}
+
+OsclAny MuxTableMgr::LogStats(TPVDirection dir)
+{
+    if ((dir & OUTGOING) && iOutgoingDescriptors)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux-table(O) Statistics:\n"));
+        for (unsigned entry = 0; entry < iOutgoingDescriptors->size(); entry++)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num outgoing pdus using descriptor %d = %d\n",
+                            (*iOutgoingDescriptors)[entry]->GetH245descriptor()->multiplexTableEntryNumber,
+                            iMcAccessCnt[(*iOutgoingDescriptors)[entry]->GetH245descriptor()->multiplexTableEntryNumber]));
+        }
+    }
+    if (dir & INCOMING)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Mux-table(I) Statistics:\n"));
+        for (int32 entry_num = 0; entry_num < MAX_MUX_ENTRIES; entry_num ++)
+        {
+            if (iMuxDescriptorR[entry_num])
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num incoming pdus using descriptor %d = %d\n", entry_num, iMcAccessCntR[entry_num]));
+            }
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "Num invalid descriptors - %d\n", iNumCorruptMcRx));
+    }
+}
+uint32 MuxTableMgr::GetMuxEntryAccessCount(TPVDirection dir, uint8 tblNum)
+{
+    if (tblNum >= MAX_MUX_ENTRIES)
+        return 0;
+    uint32* table = (dir == OUTGOING) ? iMcAccessCnt : iMcAccessCntR;
+    return table[tblNum];
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245.h b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245.h
new file mode 100644
index 0000000..f1af5fc
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245.h
@@ -0,0 +1,172 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#ifndef _H245_H_
+#define _H245_H_
+
+#include "layer.h"
+#include "packet_io.h"
+#include "media_packet.h"
+#include "per.h"
+#include "se.h"
+#include "oscl_mem.h"
+
+
+//===============================================================
+//---------------------------------------------------------------
+// CLASS DEFINITIONS
+//---------------------------------------------------------------
+//===============================================================
+class H245Observer
+{
+    public:
+        virtual ~H245Observer() {}
+        virtual void Handle(PS_ControlMsgHeader msg) = 0;
+};
+
+class H245 : public Layer, public PacketInput, public PacketOutput
+{
+    public:
+
+        // Constructor
+        H245() : Observer(0)
+        {
+            // Initialize PER
+            MyPer.SetH245(this);
+            MyPer.SetSe(&MySe);
+
+            // Initialize SE
+            MySe.SetH245(this);
+            MySe.SetPer(&MyPer);
+
+            Pack = iMediaPktAlloc.allocate_packet();
+        }
+
+        // Destructor
+        virtual ~H245()
+        {
+            iMediaPktAlloc.deallocate_packet(Pack);
+        }
+
+        // resets the states for a new session
+        void Reset()
+        {
+            // need to reset SEs' state
+            MySe.Reset();
+            // reset PER so it stops processing incoming messages
+            MyPer.Reset();
+        }
+
+        PacketInput *GetPacketInput()
+        {
+            return this;
+        }
+        PacketOutput *GetPacketOutput()
+        {
+            return this;
+        }
+
+        // Send a message to H.245 PER layer (normally from Srp).
+        // Leaves if out-of-memory
+        void PacketIn(Packet *pack)
+        {
+            uint8 *pData = (uint8 *)OSCL_DEFAULT_MALLOC(pack->GetMediaSize());
+            OsclError::LeaveIfNull(pData);
+
+            oscl_memcpy(pData, pack->GetMediaPtr(), pack->GetMediaSize());
+            pack->ClearMediaPtr();
+            MyPer.Decode(pData, pack->GetMediaSize());
+        }
+
+        void PacketOut(unsigned char *pData, int size)
+        {
+            if (pPktOutput)
+            {
+                // create media fragment and copy data to fragment
+                MediaFragment *frag = DefFragAlloc.allocate_fragment(size);
+                oscl_memcpy(frag->GetFragment()->ptr, pData, size);
+                // add fragment to packet and send
+                Pack->AddMediaFragment(frag);
+                DefFragAlloc.deallocate_fragment(frag);
+                pPktOutput->PacketIn(Pack);
+                // decrement fragment use by this
+                Pack->Clear();
+            }
+        }
+
+        void SetObserver(H245Observer *observer)
+        {
+            Observer = observer;
+        }
+
+        // Send a message to Controls Observer (normally Tsc)
+        void ObserverMessage(unsigned char *pData, int size)
+        {
+            OSCL_UNUSED_ARG(size);
+            if (Observer) Observer->Handle((PS_ControlMsgHeader)pData);
+        }
+
+        // Send a message to Lower Layer (normally Srp)
+        void LowerLayerTx(unsigned char *pData, int size)
+        {
+            PacketOut(pData, size);
+        }
+        // Send a message to H.245 SE layer (normally from Tsc).
+        void DispatchControlMessage(PS_ControlMsgHeader msg)
+        {
+            MySe.InformationRecv((PS_InfHeader)msg);
+        }
+
+        MSD* GetMSD()
+        {
+            return MySe.GetMSD();
+        }
+        CE*  GetCE()
+        {
+            return MySe.GetCE();
+        }
+
+        void SetTimers(H245TimerValues& timer_vals)
+        {
+            MySe.SetTimers(timer_vals);
+        }
+    private:
+        H245(H245&);
+
+        PER MyPer;
+        SE MySe;
+
+        H245Observer *Observer;
+        MediaPacket *Pack;
+        DefFragmentAllocator DefFragAlloc;
+        MediaPacketAllocator iMediaPktAlloc;
+};
+//===============================================================
+
+
+#endif // _H245_H_
diff --git a/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245def.h b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245def.h
new file mode 100644
index 0000000..a3c00d9
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245def.h
@@ -0,0 +1,5748 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245def.h
+//
+// DESC: H.245 Structure definitions for PER encode/decode routines
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#ifndef H245DEF
+#define H245DEF
+
+#include "genericper.h"
+
+typedef struct _MultimediaSystemControlMessage     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _RequestMessage *request;
+        struct _ResponseMessage *response;
+        struct _CommandMessage *command;
+        struct _IndicationMessage *indication;
+        /*[...]*/
+    };
+} S_MultimediaSystemControlMessage;
+typedef S_MultimediaSystemControlMessage *PS_MultimediaSystemControlMessage;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMessage     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _MasterSlaveDetermination *masterSlaveDetermination;
+        struct _TerminalCapabilitySet *terminalCapabilitySet;
+        struct _OpenLogicalChannel *openLogicalChannel;
+        struct _CloseLogicalChannel *closeLogicalChannel;
+        struct _RequestChannelClose *requestChannelClose;
+        struct _MultiplexEntrySend *multiplexEntrySend;
+        struct _RequestMultiplexEntry *requestMultiplexEntry;
+        struct _RequestMode *requestMode;
+        struct _RoundTripDelayRequest *roundTripDelayRequest;
+        struct _MaintenanceLoopRequest *maintenanceLoopRequest;
+        /*[...]*/
+        struct _CommunicationModeRequest *communicationModeRequest;
+        struct _ConferenceRequest *conferenceRequest;
+        struct _MultilinkRequest *multilinkRequest;
+        struct _LogicalChannelRateRequest *logicalChannelRateRequest;
+    };
+} S_RequestMessage;
+typedef S_RequestMessage *PS_RequestMessage;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ResponseMessage     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _MasterSlaveDeterminationAck *masterSlaveDeterminationAck;
+        struct _MasterSlaveDeterminationReject *masterSlaveDeterminationReject;
+        struct _TerminalCapabilitySetAck *terminalCapabilitySetAck;
+        struct _TerminalCapabilitySetReject *terminalCapabilitySetReject;
+        struct _OpenLogicalChannelAck *openLogicalChannelAck;
+        struct _OpenLogicalChannelReject *openLogicalChannelReject;
+        struct _CloseLogicalChannelAck *closeLogicalChannelAck;
+        struct _RequestChannelCloseAck *requestChannelCloseAck;
+        struct _RequestChannelCloseReject *requestChannelCloseReject;
+        struct _MultiplexEntrySendAck *multiplexEntrySendAck;
+        struct _MultiplexEntrySendReject *multiplexEntrySendReject;
+        struct _RequestMultiplexEntryAck *requestMultiplexEntryAck;
+        struct _RequestMultiplexEntryReject *requestMultiplexEntryReject;
+        struct _RequestModeAck *requestModeAck;
+        struct _RequestModeReject *requestModeReject;
+        struct _RoundTripDelayResponse *roundTripDelayResponse;
+        struct _MaintenanceLoopAck *maintenanceLoopAck;
+        struct _MaintenanceLoopReject *maintenanceLoopReject;
+        /*[...]*/
+        struct _CommunicationModeResponse *communicationModeResponse;
+        struct _ConferenceResponse *conferenceResponse;
+        struct _MultilinkResponse *multilinkResponse;
+        struct _LogicalChannelRateAcknowledge *logicalChannelRateAcknowledge;
+        struct _LogicalChannelRateReject *logicalChannelRateReject;
+    };
+} S_ResponseMessage;
+typedef S_ResponseMessage *PS_ResponseMessage;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CommandMessage     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _MaintenanceLoopOffCommand *maintenanceLoopOffCommand;
+        struct _SendTerminalCapabilitySet *sendTerminalCapabilitySet;
+        struct _EncryptionCommand *encryptionCommand;
+        struct _FlowControlCommand *flowControlCommand;
+        struct _EndSessionCommand *endSessionCommand;
+        struct _MiscellaneousCommand *miscellaneousCommand;
+        /*[...]*/
+        struct _CommunicationModeCommand *communicationModeCommand;
+        struct _ConferenceCommand *conferenceCommand;
+        struct _H223MultiplexReconfiguration *h223MultiplexReconfiguration;
+        struct _NewATMVCCommand *newATMVCCommand;
+    };
+} S_CommandMessage;
+typedef S_CommandMessage *PS_CommandMessage;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndicationMessage     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _FunctionNotUnderstood *functionNotUnderstood;
+        struct _MasterSlaveDeterminationRelease *masterSlaveDeterminationRelease;
+        struct _TerminalCapabilitySetRelease *terminalCapabilitySetRelease;
+        struct _OpenLogicalChannelConfirm *openLogicalChannelConfirm;
+        struct _RequestChannelCloseRelease *requestChannelCloseRelease;
+        struct _MultiplexEntrySendRelease *multiplexEntrySendRelease;
+        struct _RequestMultiplexEntryRelease *requestMultiplexEntryRelease;
+        struct _RequestModeRelease *requestModeRelease;
+        struct _MiscellaneousIndication *miscellaneousIndication;
+        struct _JitterIndication *jitterIndication;
+        struct _H223SkewIndication *h223SkewIndication;
+        struct _NewATMVCIndication *newATMVCIndication;
+        struct _UserInputIndication *userInput;
+        /*[...]*/
+        struct _H2250MaximumSkewIndication *h2250MaximumSkewIndication;
+        struct _MCLocationIndication *mcLocationIndication;
+        struct _ConferenceIndication *conferenceIndication;
+        struct _VendorIdentification *vendorIdentification;
+        struct _FunctionNotSupported *functionNotSupported;
+        struct _MultilinkIndication *multilinkIndication;
+        struct _LogicalChannelRateRelease *logicalChannelRateRelease;
+        struct _FlowControlIndication *flowControlIndication;
+    };
+} S_IndicationMessage;
+typedef S_IndicationMessage *PS_IndicationMessage;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NonStandardIdentifier     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        PS_OBJECTIDENT object;
+        struct _H221NonStandard *h221NonStandard;
+    };
+} S_NonStandardIdentifier;
+typedef S_NonStandardIdentifier *PS_NonStandardIdentifier;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NonStandardParameter     /* SEQUENCE */
+{
+    struct _NonStandardIdentifier nonStandardIdentifier;
+    S_OCTETSTRING data;
+} S_NonStandardParameter;
+typedef S_NonStandardParameter *PS_NonStandardParameter;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NonStandardMessage     /* SEQUENCE */
+{
+    struct _NonStandardParameter nonStandardData;
+    /*[...]*/
+} S_NonStandardMessage;
+typedef S_NonStandardMessage *PS_NonStandardMessage;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H221NonStandard     /* SEQUENCE */
+{
+    uint8 t35CountryCode;
+    uint8 t35Extension;
+    uint16 manufacturerCode;
+} S_H221NonStandard;
+typedef S_H221NonStandard *PS_H221NonStandard;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MasterSlaveDetermination     /* SEQUENCE */
+{
+    uint8 terminalType;
+    uint32 statusDeterminationNumber;
+    /*[...]*/
+} S_MasterSlaveDetermination;
+typedef S_MasterSlaveDetermination *PS_MasterSlaveDetermination;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Decision     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) master */
+    /* (NULL) slave */
+} S_Decision;
+typedef S_Decision *PS_Decision;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MasterSlaveDeterminationAck     /* SEQUENCE */
+{
+    struct _Decision decision;
+    /*[...]*/
+} S_MasterSlaveDeterminationAck;
+typedef S_MasterSlaveDeterminationAck *PS_MasterSlaveDeterminationAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MsdRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) identicalNumbers */
+    /*[...]*/
+} S_MsdRejectCause;
+typedef S_MsdRejectCause *PS_MsdRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MasterSlaveDeterminationReject     /* SEQUENCE */
+{
+    struct _MsdRejectCause msdRejectCause;
+    /*[...]*/
+} S_MasterSlaveDeterminationReject;
+typedef S_MasterSlaveDeterminationReject *PS_MasterSlaveDeterminationReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MasterSlaveDeterminationRelease     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_MasterSlaveDeterminationRelease;
+typedef S_MasterSlaveDeterminationRelease *PS_MasterSlaveDeterminationRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CapabilityDescriptor     /* SEQUENCE */
+{
+uint32 option_of_simultaneousCapabilities :
+    1;
+    uint8 capabilityDescriptorNumber;
+    uint16 size_of_simultaneousCapabilities;
+    struct _AlternativeCapabilitySet *simultaneousCapabilities;
+} S_CapabilityDescriptor;
+typedef S_CapabilityDescriptor *PS_CapabilityDescriptor;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AlternativeCapabilitySet     /* SEQUENCE OF */
+{
+    uint32* item;
+    uint16 size;
+} S_AlternativeCapabilitySet;
+typedef S_AlternativeCapabilitySet *PS_AlternativeCapabilitySet;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalCapabilitySetAck     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    /*[...]*/
+} S_TerminalCapabilitySetAck;
+typedef S_TerminalCapabilitySetAck *PS_TerminalCapabilitySetAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TcsRejectCause     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) unspecified */
+        /* (NULL) undefinedTableEntryUsed */
+        /* (NULL) descriptorCapacityExceeded */
+        struct _TableEntryCapacityExceeded *tableEntryCapacityExceeded;
+        /*[...]*/
+    };
+} S_TcsRejectCause;
+typedef S_TcsRejectCause *PS_TcsRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalCapabilitySetReject     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    struct _TcsRejectCause tcsRejectCause;
+    /*[...]*/
+} S_TerminalCapabilitySetReject;
+typedef S_TerminalCapabilitySetReject *PS_TerminalCapabilitySetReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TableEntryCapacityExceeded     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 highestEntryNumberProcessed;
+        /* (NULL) noneProcessed */
+    };
+} S_TableEntryCapacityExceeded;
+typedef S_TableEntryCapacityExceeded *PS_TableEntryCapacityExceeded;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalCapabilitySetRelease     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_TerminalCapabilitySetRelease;
+typedef S_TerminalCapabilitySetRelease *PS_TerminalCapabilitySetRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Capability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _VideoCapability *receiveVideoCapability;
+        struct _VideoCapability *transmitVideoCapability;
+        struct _VideoCapability *receiveAndTransmitVideoCapability;
+        struct _AudioCapability *receiveAudioCapability;
+        struct _AudioCapability *transmitAudioCapability;
+        struct _AudioCapability *receiveAndTransmitAudioCapability;
+        struct _DataApplicationCapability *receiveDataApplicationCapability;
+        struct _DataApplicationCapability *transmitDataApplicationCapability;
+        struct _DataApplicationCapability *receiveAndTransmitDataApplicationCapability;
+        uint8 h233EncryptionTransmitCapability;
+        struct _H233EncryptionReceiveCapability *h233EncryptionReceiveCapability;
+        /*[...]*/
+        struct _ConferenceCapability *conferenceCapability;
+        struct _H235SecurityCapability *h235SecurityCapability;
+        uint8 maxPendingReplacementFor;
+        struct _UserInputCapability *receiveUserInputCapability;
+        struct _UserInputCapability *transmitUserInputCapability;
+        struct _UserInputCapability *receiveAndTransmitUserInputCapability;
+        struct _GenericCapability *genericControlCapability;
+    };
+} S_Capability;
+typedef S_Capability *PS_Capability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CapabilityTableEntry     /* SEQUENCE */
+{
+uint32 option_of_capability :
+    1;
+    uint16 capabilityTableEntryNumber;
+    struct _Capability capability;
+} S_CapabilityTableEntry;
+typedef S_CapabilityTableEntry *PS_CapabilityTableEntry;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H233EncryptionReceiveCapability     /* SEQUENCE */
+{
+    uint8 h233IVResponseTime;
+    /*[...]*/
+} S_H233EncryptionReceiveCapability;
+typedef S_H233EncryptionReceiveCapability *PS_H233EncryptionReceiveCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexCapability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _H222Capability *h222Capability;
+        struct _H223Capability *h223Capability;
+        struct _V76Capability *v76Capability;
+        /*[...]*/
+        struct _H2250Capability *h2250Capability;
+        struct _GenericCapability *genericMultiplexCapability;
+    };
+} S_MultiplexCapability;
+typedef S_MultiplexCapability *PS_MultiplexCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalCapabilitySet     /* SEQUENCE */
+{
+uint32 option_of_multiplexCapability :
+    1;
+uint32 option_of_capabilityTable :
+    1;
+uint32 option_of_capabilityDescriptors :
+    1;
+    uint8 sequenceNumber;
+    S_OBJECTIDENT protocolIdentifier;
+    struct _MultiplexCapability multiplexCapability;
+    uint16 size_of_capabilityTable;
+    struct _CapabilityTableEntry *capabilityTable;
+    uint16 size_of_capabilityDescriptors;
+    struct _CapabilityDescriptor *capabilityDescriptors;
+    /*[...]*/
+uint32 option_of_genericInformation :
+    1;
+    uint16 size_of_genericInformation;
+    struct _GenericInformation *genericInformation;
+} S_TerminalCapabilitySet;
+typedef S_TerminalCapabilitySet *PS_TerminalCapabilitySet;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H222Capability     /* SEQUENCE */
+{
+    uint16 numberOfVCs;
+    uint16 size_of_vcCapability;
+    struct _VCCapability *vcCapability;
+    /*[...]*/
+} S_H222Capability;
+typedef S_H222Capability *PS_H222Capability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Aal1ViaGateway     /* SEQUENCE */
+{
+    uint16 size_of_gatewayAddress;
+    struct _Q2931Address *gatewayAddress;
+uint32 nullClockRecovery :
+    1;
+uint32 srtsClockRecovery :
+    1;
+uint32 adaptiveClockRecovery :
+    1;
+uint32 nullErrorCorrection :
+    1;
+uint32 longInterleaver :
+    1;
+uint32 shortInterleaver :
+    1;
+uint32 errorCorrectionOnly :
+    1;
+uint32 structuredDataTransfer :
+    1;
+uint32 partiallyFilledCells :
+    1;
+    /*[...]*/
+} S_Aal1ViaGateway;
+typedef S_Aal1ViaGateway *PS_Aal1ViaGateway;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VccAal5Type     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 singleBitRate;
+        struct _RangeOfBitRates *rangeOfBitRates;
+    };
+} S_VccAal5Type;
+typedef S_VccAal5Type *PS_VccAal5Type;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AvailableBitRates     /* SEQUENCE */
+{
+    struct _VccAal5Type vccAal5Type;
+    /*[...]*/
+} S_AvailableBitRates;
+typedef S_AvailableBitRates *PS_AvailableBitRates;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RangeOfBitRates     /* SEQUENCE */
+{
+    uint16 lowerBitRate;
+    uint16 higherBitRate;
+} S_RangeOfBitRates;
+typedef S_RangeOfBitRates *PS_RangeOfBitRates;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VccAal5     /* SEQUENCE */
+{
+    uint16 forwardMaximumSDUSize;
+    uint16 backwardMaximumSDUSize;
+    /*[...]*/
+} S_VccAal5;
+typedef S_VccAal5 *PS_VccAal5;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VccAal1     /* SEQUENCE */
+{
+uint32 nullClockRecovery :
+    1;
+uint32 srtsClockRecovery :
+    1;
+uint32 adaptiveClockRecovery :
+    1;
+uint32 nullErrorCorrection :
+    1;
+uint32 longInterleaver :
+    1;
+uint32 shortInterleaver :
+    1;
+uint32 errorCorrectionOnly :
+    1;
+uint32 structuredDataTransfer :
+    1;
+uint32 partiallyFilledCells :
+    1;
+    /*[...]*/
+} S_VccAal1;
+typedef S_VccAal1 *PS_VccAal1;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VCCapability     /* SEQUENCE */
+{
+uint32 option_of_vccAal1 :
+    1;
+uint32 option_of_vccAal5 :
+    1;
+    struct _VccAal1 vccAal1;
+    struct _VccAal5 vccAal5;
+uint32 transportStream :
+    1;
+uint32 programStream :
+    1;
+    struct _AvailableBitRates availableBitRates;
+    /*[...]*/
+uint32 option_of_aal1ViaGateway :
+    1;
+    struct _Aal1ViaGateway aal1ViaGateway;
+} S_VCCapability;
+typedef S_VCCapability *PS_VCCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MobileOperationTransmitCapability     /* SEQUENCE */
+{
+uint32 modeChangeCapability :
+    1;
+uint32 h223AnnexA :
+    1;
+uint32 h223AnnexADoubleFlag :
+    1;
+uint32 h223AnnexB :
+    1;
+uint32 h223AnnexBwithHeader :
+    1;
+    /*[...]*/
+} S_MobileOperationTransmitCapability;
+typedef S_MobileOperationTransmitCapability *PS_MobileOperationTransmitCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223MultiplexTableCapability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) basic */
+        struct _Enhanced *enhanced;
+    };
+} S_H223MultiplexTableCapability;
+typedef S_H223MultiplexTableCapability *PS_H223MultiplexTableCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Enhanced     /* SEQUENCE */
+{
+    uint8 maximumNestingDepth;
+    uint8 maximumElementListSize;
+    uint8 maximumSubElementListSize;
+    /*[...]*/
+} S_Enhanced;
+typedef S_Enhanced *PS_Enhanced;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223AnnexCCapability     /* SEQUENCE */
+{
+uint32 videoWithAL1M :
+    1;
+uint32 videoWithAL2M :
+    1;
+uint32 videoWithAL3M :
+    1;
+uint32 audioWithAL1M :
+    1;
+uint32 audioWithAL2M :
+    1;
+uint32 audioWithAL3M :
+    1;
+uint32 dataWithAL1M :
+    1;
+uint32 dataWithAL2M :
+    1;
+uint32 dataWithAL3M :
+    1;
+uint32 alpduInterleaving :
+    1;
+    uint16 maximumAL1MPDUSize;
+    uint16 maximumAL2MSDUSize;
+    uint16 maximumAL3MSDUSize;
+    /*[...]*/
+uint32 option_of_rsCodeCapability :
+    1;
+uint32 rsCodeCapability :
+    1;
+} S_H223AnnexCCapability;
+typedef S_H223AnnexCCapability *PS_H223AnnexCCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223Capability     /* SEQUENCE */
+{
+uint32 transportWithI_frames :
+    1;
+uint32 videoWithAL1 :
+    1;
+uint32 videoWithAL2 :
+    1;
+uint32 videoWithAL3 :
+    1;
+uint32 audioWithAL1 :
+    1;
+uint32 audioWithAL2 :
+    1;
+uint32 audioWithAL3 :
+    1;
+uint32 dataWithAL1 :
+    1;
+uint32 dataWithAL2 :
+    1;
+uint32 dataWithAL3 :
+    1;
+    uint16 maximumAl2SDUSize;
+    uint16 maximumAl3SDUSize;
+    uint16 maximumDelayJitter;
+    struct _H223MultiplexTableCapability h223MultiplexTableCapability;
+    /*[...]*/
+uint32 option_of_maxMUXPDUSizeCapability :
+    1;
+uint32 option_of_nsrpSupport :
+    1;
+uint32 option_of_mobileOperationTransmitCapability :
+    1;
+uint32 option_of_h223AnnexCCapability :
+    1;
+uint32 maxMUXPDUSizeCapability :
+    1;
+uint32 nsrpSupport :
+    1;
+    struct _MobileOperationTransmitCapability mobileOperationTransmitCapability;
+    struct _H223AnnexCCapability h223AnnexCCapability;
+} S_H223Capability;
+typedef S_H223Capability *PS_H223Capability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V75Capability     /* SEQUENCE */
+{
+uint32 audioHeader :
+    1;
+    /*[...]*/
+} S_V75Capability;
+typedef S_V75Capability *PS_V75Capability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V76Capability     /* SEQUENCE */
+{
+uint32 suspendResumeCapabilitywAddress :
+    1;
+uint32 suspendResumeCapabilitywoAddress :
+    1;
+uint32 rejCapability :
+    1;
+uint32 sREJCapability :
+    1;
+uint32 mREJCapability :
+    1;
+uint32 crc8bitCapability :
+    1;
+uint32 crc16bitCapability :
+    1;
+uint32 crc32bitCapability :
+    1;
+uint32 uihCapability :
+    1;
+    uint16 numOfDLCS;
+uint32 twoOctetAddressFieldCapability :
+    1;
+uint32 loopBackTestCapability :
+    1;
+    uint16 n401Capability;
+    uint8 maxWindowSizeCapability;
+    struct _V75Capability v75Capability;
+    /*[...]*/
+} S_V76Capability;
+typedef S_V76Capability *PS_V76Capability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _McCapability     /* SEQUENCE */
+{
+uint32 centralizedConferenceMC :
+    1;
+uint32 decentralizedConferenceMC :
+    1;
+    /*[...]*/
+} S_McCapability;
+typedef S_McCapability *PS_McCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaPacketizationCapability     /* SEQUENCE */
+{
+uint32 h261aVideoPacketization :
+    1;
+    /*[...]*/
+uint32 option_of_rtpPayloadType :
+    1;
+    uint16 size_of_rtpPayloadType;
+    struct _RTPPayloadType *rtpPayloadType;
+} S_MediaPacketizationCapability;
+typedef S_MediaPacketizationCapability *PS_MediaPacketizationCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _QOSMode     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) guaranteedQOS */
+    /* (NULL) controlledLoad */
+    /*[...]*/
+} S_QOSMode;
+typedef S_QOSMode *PS_QOSMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RSVPParameters     /* SEQUENCE */
+{
+uint32 option_of_qosMode :
+    1;
+uint32 option_of_tokenRate :
+    1;
+uint32 option_of_bucketSize :
+    1;
+uint32 option_of_peakRate :
+    1;
+uint32 option_of_minPoliced :
+    1;
+uint32 option_of_maxPktSize :
+    1;
+    struct _QOSMode qosMode;
+    uint32 tokenRate;
+    uint32 bucketSize;
+    uint32 peakRate;
+    uint32 minPoliced;
+    uint32 maxPktSize;
+    /*[...]*/
+} S_RSVPParameters;
+typedef S_RSVPParameters *PS_RSVPParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ATMParameters     /* SEQUENCE */
+{
+    uint16 maxNTUSize;
+uint32 atmUBR :
+    1;
+uint32 atmrtVBR :
+    1;
+uint32 atmnrtVBR :
+    1;
+uint32 atmABR :
+    1;
+uint32 atmCBR :
+    1;
+    /*[...]*/
+} S_ATMParameters;
+typedef S_ATMParameters *PS_ATMParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _QOSCapability     /* SEQUENCE */
+{
+uint32 option_of_nonStandardData :
+    1;
+uint32 option_of_rsvpParameters :
+    1;
+uint32 option_of_atmParameters :
+    1;
+    struct _NonStandardParameter nonStandardData;
+    struct _RSVPParameters rsvpParameters;
+    struct _ATMParameters atmParameters;
+    /*[...]*/
+} S_QOSCapability;
+typedef S_QOSCapability *PS_QOSCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaTransportType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) ip_UDP */
+        /* (NULL) ip_TCP */
+        /* (NULL) atm_AAL5_UNIDIR */
+        /* (NULL) atm_AAL5_BIDIR */
+        /*[...]*/
+        struct _Atm_AAL5_compressed *atm_AAL5_compressed;
+    };
+} S_MediaTransportType;
+typedef S_MediaTransportType *PS_MediaTransportType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Atm_AAL5_compressed     /* SEQUENCE */
+{
+uint32 variable_delta :
+    1;
+    /*[...]*/
+} S_Atm_AAL5_compressed;
+typedef S_Atm_AAL5_compressed *PS_Atm_AAL5_compressed;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaChannelCapability     /* SEQUENCE */
+{
+uint32 option_of_mediaTransport :
+    1;
+    struct _MediaTransportType mediaTransport;
+    /*[...]*/
+} S_MediaChannelCapability;
+typedef S_MediaChannelCapability *PS_MediaChannelCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TransportCapability     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+uint32 option_of_qOSCapabilities :
+    1;
+uint32 option_of_mediaChannelCapabilities :
+    1;
+    struct _NonStandardParameter nonStandard;
+    uint16 size_of_qOSCapabilities;
+    struct _QOSCapability *qOSCapabilities;
+    uint16 size_of_mediaChannelCapabilities;
+    struct _MediaChannelCapability *mediaChannelCapabilities;
+    /*[...]*/
+} S_TransportCapability;
+typedef S_TransportCapability *PS_TransportCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RedundancyEncodingMethod     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) rtpAudioRedundancyEncoding */
+        /*[...]*/
+        struct _RTPH263VideoRedundancyEncoding *rtpH263VideoRedundancyEncoding;
+    };
+} S_RedundancyEncodingMethod;
+typedef S_RedundancyEncodingMethod *PS_RedundancyEncodingMethod;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RedundancyEncodingCapability     /* SEQUENCE */
+{
+uint32 option_of_secondaryEncoding :
+    1;
+    struct _RedundancyEncodingMethod redundancyEncodingMethod;
+    uint16 primaryEncoding;
+    uint16 size_of_secondaryEncoding;
+    uint32* secondaryEncoding;
+    /*[...]*/
+} S_RedundancyEncodingCapability;
+typedef S_RedundancyEncodingCapability *PS_RedundancyEncodingCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FrameToThreadMapping     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) roundrobin */
+        struct _RTPH263VideoRedundancyFrameMapping *custom;
+        /*[...]*/
+    };
+    uint16 size;
+} S_FrameToThreadMapping;
+typedef S_FrameToThreadMapping *PS_FrameToThreadMapping;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RTPH263VideoRedundancyEncoding     /* SEQUENCE */
+{
+uint32 option_of_containedThreads :
+    1;
+    uint8 numberOfThreads;
+    uint16 framesBetweenSyncPoints;
+    struct _FrameToThreadMapping frameToThreadMapping;
+    uint16 size_of_containedThreads;
+    uint32* containedThreads;
+    /*[...]*/
+} S_RTPH263VideoRedundancyEncoding;
+typedef S_RTPH263VideoRedundancyEncoding *PS_RTPH263VideoRedundancyEncoding;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RTPH263VideoRedundancyFrameMapping     /* SEQUENCE */
+{
+    uint8 threadNumber;
+    uint16 size_of_frameSequence;
+    uint32* frameSequence;
+    /*[...]*/
+} S_RTPH263VideoRedundancyFrameMapping;
+typedef S_RTPH263VideoRedundancyFrameMapping *PS_RTPH263VideoRedundancyFrameMapping;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultipointCapability     /* SEQUENCE */
+{
+uint32 multicastCapability :
+    1;
+uint32 multiUniCastConference :
+    1;
+    uint16 size_of_mediaDistributionCapability;
+    struct _MediaDistributionCapability *mediaDistributionCapability;
+    /*[...]*/
+} S_MultipointCapability;
+typedef S_MultipointCapability *PS_MultipointCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H2250Capability     /* SEQUENCE */
+{
+    uint16 maximumAudioDelayJitter;
+    struct _MultipointCapability receiveMultipointCapability;
+    struct _MultipointCapability transmitMultipointCapability;
+    struct _MultipointCapability receiveAndTransmitMultipointCapability;
+    struct _McCapability mcCapability;
+uint32 rtcpVideoControlCapability :
+    1;
+    struct _MediaPacketizationCapability mediaPacketizationCapability;
+    /*[...]*/
+uint32 option_of_transportCapability :
+    1;
+uint32 option_of_redundancyEncodingCapability :
+    1;
+uint32 option_of_logicalChannelSwitchingCapability :
+    1;
+uint32 option_of_t120DynamicPortCapability :
+    1;
+    struct _TransportCapability transportCapability;
+    uint16 size_of_redundancyEncodingCapability;
+    struct _RedundancyEncodingCapability *redundancyEncodingCapability;
+uint32 logicalChannelSwitchingCapability :
+    1;
+uint32 t120DynamicPortCapability :
+    1;
+} S_H2250Capability;
+typedef S_H2250Capability *PS_H2250Capability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaDistributionCapability     /* SEQUENCE */
+{
+uint32 option_of_centralizedData :
+    1;
+uint32 option_of_distributedData :
+    1;
+uint32 centralizedControl :
+    1;
+uint32 distributedControl :
+    1;
+uint32 centralizedAudio :
+    1;
+uint32 distributedAudio :
+    1;
+uint32 centralizedVideo :
+    1;
+uint32 distributedVideo :
+    1;
+    uint16 size_of_centralizedData;
+    struct _DataApplicationCapability *centralizedData;
+    uint16 size_of_distributedData;
+    struct _DataApplicationCapability *distributedData;
+    /*[...]*/
+} S_MediaDistributionCapability;
+typedef S_MediaDistributionCapability *PS_MediaDistributionCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoCapability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _H261VideoCapability *h261VideoCapability;
+        struct _H262VideoCapability *h262VideoCapability;
+        struct _H263VideoCapability *h263VideoCapability;
+        struct _IS11172VideoCapability *is11172VideoCapability;
+        /*[...]*/
+        struct _GenericCapability *genericVideoCapability;
+    };
+} S_VideoCapability;
+typedef S_VideoCapability *PS_VideoCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H261VideoCapability     /* SEQUENCE */
+{
+uint32 option_of_qcifMPI :
+    1;
+uint32 option_of_cifMPI :
+    1;
+    uint8 qcifMPI;
+    uint8 cifMPI;
+uint32 temporalSpatialTradeOffCapability :
+    1;
+    uint16 maxBitRate;
+uint32 stillImageTransmission :
+    1;
+    /*[...]*/
+} S_H261VideoCapability;
+typedef S_H261VideoCapability *PS_H261VideoCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H262VideoCapability     /* SEQUENCE */
+{
+uint32 option_of_videoBitRate :
+    1;
+uint32 option_of_vbvBufferSize :
+    1;
+uint32 option_of_samplesPerLine :
+    1;
+uint32 option_of_linesPerFrame :
+    1;
+uint32 option_of_framesPerSecond :
+    1;
+uint32 option_of_luminanceSampleRate :
+    1;
+uint32 profileAndLevel_SPatML :
+    1;
+uint32 profileAndLevel_MPatLL :
+    1;
+uint32 profileAndLevel_MPatML :
+    1;
+uint32 profileAndLevel_MPatH_14 :
+    1;
+uint32 profileAndLevel_MPatHL :
+    1;
+uint32 profileAndLevel_SNRatLL :
+    1;
+uint32 profileAndLevel_SNRatML :
+    1;
+uint32 profileAndLevel_SpatialatH_14 :
+    1;
+uint32 profileAndLevel_HPatML :
+    1;
+uint32 profileAndLevel_HPatH_14 :
+    1;
+uint32 profileAndLevel_HPatHL :
+    1;
+    uint32 videoBitRate;
+    uint32 vbvBufferSize;
+    uint16 samplesPerLine;
+    uint16 linesPerFrame;
+    uint8 framesPerSecond;
+    uint32 luminanceSampleRate;
+    /*[...]*/
+} S_H262VideoCapability;
+typedef S_H262VideoCapability *PS_H262VideoCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EnhancementLayerInfo     /* SEQUENCE */
+{
+uint32 option_of_snrEnhancement :
+    1;
+uint32 option_of_spatialEnhancement :
+    1;
+uint32 option_of_bPictureEnhancement :
+    1;
+uint32 baseBitRateConstrained :
+    1;
+    uint16 size_of_snrEnhancement;
+    struct _EnhancementOptions *snrEnhancement;
+    uint16 size_of_spatialEnhancement;
+    struct _EnhancementOptions *spatialEnhancement;
+    uint16 size_of_bPictureEnhancement;
+    struct _BEnhancementParameters *bPictureEnhancement;
+    /*[...]*/
+} S_EnhancementLayerInfo;
+typedef S_EnhancementLayerInfo *PS_EnhancementLayerInfo;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TransparencyParameters     /* SEQUENCE */
+{
+    uint16 presentationOrder;
+    int32 offset_x;
+    int32 offset_y;
+    uint8 scale_x;
+    uint8 scale_y;
+    /*[...]*/
+} S_TransparencyParameters;
+typedef S_TransparencyParameters *PS_TransparencyParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoBackChannelSend     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) none */
+    /* (NULL) ackMessageOnly */
+    /* (NULL) nackMessageOnly */
+    /* (NULL) ackOrNackMessageOnly */
+    /* (NULL) ackAndNackMessage */
+    /*[...]*/
+} S_VideoBackChannelSend;
+typedef S_VideoBackChannelSend *PS_VideoBackChannelSend;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AdditionalPictureMemory     /* SEQUENCE */
+{
+uint32 option_of_sqcifAdditionalPictureMemory :
+    1;
+uint32 option_of_qcifAdditionalPictureMemory :
+    1;
+uint32 option_of_cifAdditionalPictureMemory :
+    1;
+uint32 option_of_cif4AdditionalPictureMemory :
+    1;
+uint32 option_of_cif16AdditionalPictureMemory :
+    1;
+uint32 option_of_bigCpfAdditionalPictureMemory :
+    1;
+    uint16 sqcifAdditionalPictureMemory;
+    uint16 qcifAdditionalPictureMemory;
+    uint16 cifAdditionalPictureMemory;
+    uint16 cif4AdditionalPictureMemory;
+    uint16 cif16AdditionalPictureMemory;
+    uint16 bigCpfAdditionalPictureMemory;
+    /*[...]*/
+} S_AdditionalPictureMemory;
+typedef S_AdditionalPictureMemory *PS_AdditionalPictureMemory;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RefPictureSelection     /* SEQUENCE */
+{
+uint32 option_of_additionalPictureMemory :
+    1;
+    struct _AdditionalPictureMemory additionalPictureMemory;
+uint32 videoMux :
+    1;
+    struct _VideoBackChannelSend videoBackChannelSend;
+    /*[...]*/
+} S_RefPictureSelection;
+typedef S_RefPictureSelection *PS_RefPictureSelection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H263Options     /* SEQUENCE */
+{
+uint32 option_of_transparencyParameters :
+    1;
+uint32 option_of_refPictureSelection :
+    1;
+uint32 option_of_customPictureClockFrequency :
+    1;
+uint32 option_of_customPictureFormat :
+    1;
+uint32 option_of_modeCombos :
+    1;
+uint32 advancedIntraCodingMode :
+    1;
+uint32 deblockingFilterMode :
+    1;
+uint32 improvedPBFramesMode :
+    1;
+uint32 unlimitedMotionVectors :
+    1;
+uint32 fullPictureFreeze :
+    1;
+uint32 partialPictureFreezeAndRelease :
+    1;
+uint32 resizingPartPicFreezeAndRelease :
+    1;
+uint32 fullPictureSnapshot :
+    1;
+uint32 partialPictureSnapshot :
+    1;
+uint32 videoSegmentTagging :
+    1;
+uint32 progressiveRefinement :
+    1;
+uint32 dynamicPictureResizingByFour :
+    1;
+uint32 dynamicPictureResizingSixteenthPel :
+    1;
+uint32 dynamicWarpingHalfPel :
+    1;
+uint32 dynamicWarpingSixteenthPel :
+    1;
+uint32 independentSegmentDecoding :
+    1;
+uint32 slicesInOrder_NonRect :
+    1;
+uint32 slicesInOrder_Rect :
+    1;
+uint32 slicesNoOrder_NonRect :
+    1;
+uint32 slicesNoOrder_Rect :
+    1;
+uint32 alternateInterVLCMode :
+    1;
+uint32 modifiedQuantizationMode :
+    1;
+uint32 reducedResolutionUpdate :
+    1;
+    struct _TransparencyParameters transparencyParameters;
+uint32 separateVideoBackChannel :
+    1;
+    struct _RefPictureSelection refPictureSelection;
+    uint16 size_of_customPictureClockFrequency;
+    struct _CustomPictureClockFrequency *customPictureClockFrequency;
+    uint16 size_of_customPictureFormat;
+    struct _CustomPictureFormat *customPictureFormat;
+    uint16 size_of_modeCombos;
+    struct _H263VideoModeCombos *modeCombos;
+    /*[...]*/
+} S_H263Options;
+typedef S_H263Options *PS_H263Options;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H263VideoCapability     /* SEQUENCE */
+{
+uint32 option_of_sqcifMPI :
+    1;
+uint32 option_of_qcifMPI :
+    1;
+uint32 option_of_cifMPI :
+    1;
+uint32 option_of_cif4MPI :
+    1;
+uint32 option_of_cif16MPI :
+    1;
+uint32 option_of_hrd_B :
+    1;
+uint32 option_of_bppMaxKb :
+    1;
+    uint8 sqcifMPI;
+    uint8 qcifMPI;
+    uint8 cifMPI;
+    uint8 cif4MPI;
+    uint8 cif16MPI;
+    uint32 maxBitRate;
+uint32 unrestrictedVector :
+    1;
+uint32 arithmeticCoding :
+    1;
+uint32 advancedPrediction :
+    1;
+uint32 pbFrames :
+    1;
+uint32 temporalSpatialTradeOffCapability :
+    1;
+    uint32 hrd_B;
+    uint16 bppMaxKb;
+    /*[...]*/
+uint32 option_of_slowSqcifMPI :
+    1;
+uint32 option_of_slowQcifMPI :
+    1;
+uint32 option_of_slowCifMPI :
+    1;
+uint32 option_of_slowCif4MPI :
+    1;
+uint32 option_of_slowCif16MPI :
+    1;
+uint32 option_of_errorCompensation :
+    1;
+uint32 option_of_enhancementLayerInfo :
+    1;
+uint32 option_of_h263Options :
+    1;
+    uint16 slowSqcifMPI;
+    uint16 slowQcifMPI;
+    uint16 slowCifMPI;
+    uint16 slowCif4MPI;
+    uint16 slowCif16MPI;
+uint32 errorCompensation :
+    1;
+    struct _EnhancementLayerInfo enhancementLayerInfo;
+    struct _H263Options h263Options;
+} S_H263VideoCapability;
+typedef S_H263VideoCapability *PS_H263VideoCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EnhancementOptions     /* SEQUENCE */
+{
+uint32 option_of_sqcifMPI :
+    1;
+uint32 option_of_qcifMPI :
+    1;
+uint32 option_of_cifMPI :
+    1;
+uint32 option_of_cif4MPI :
+    1;
+uint32 option_of_cif16MPI :
+    1;
+uint32 option_of_slowSqcifMPI :
+    1;
+uint32 option_of_slowQcifMPI :
+    1;
+uint32 option_of_slowCifMPI :
+    1;
+uint32 option_of_slowCif4MPI :
+    1;
+uint32 option_of_slowCif16MPI :
+    1;
+uint32 option_of_h263Options :
+    1;
+    uint8 sqcifMPI;
+    uint8 qcifMPI;
+    uint8 cifMPI;
+    uint8 cif4MPI;
+    uint8 cif16MPI;
+    uint32 maxBitRate;
+uint32 unrestrictedVector :
+    1;
+uint32 arithmeticCoding :
+    1;
+uint32 temporalSpatialTradeOffCapability :
+    1;
+    uint16 slowSqcifMPI;
+    uint16 slowQcifMPI;
+    uint16 slowCifMPI;
+    uint16 slowCif4MPI;
+    uint16 slowCif16MPI;
+uint32 errorCompensation :
+    1;
+    struct _H263Options h263Options;
+    /*[...]*/
+} S_EnhancementOptions;
+typedef S_EnhancementOptions *PS_EnhancementOptions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _BEnhancementParameters     /* SEQUENCE */
+{
+    struct _EnhancementOptions enhancementOptions;
+    uint8 numberOfBPictures;
+    /*[...]*/
+} S_BEnhancementParameters;
+typedef S_BEnhancementParameters *PS_BEnhancementParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CustomPictureClockFrequency     /* SEQUENCE */
+{
+uint32 option_of_sqcifMPI :
+    1;
+uint32 option_of_qcifMPI :
+    1;
+uint32 option_of_cifMPI :
+    1;
+uint32 option_of_cif4MPI :
+    1;
+uint32 option_of_cif16MPI :
+    1;
+    uint16 clockConversionCode;
+    uint8 clockDivisor;
+    uint16 sqcifMPI;
+    uint16 qcifMPI;
+    uint16 cifMPI;
+    uint16 cif4MPI;
+    uint16 cif16MPI;
+    /*[...]*/
+} S_CustomPictureClockFrequency;
+typedef S_CustomPictureClockFrequency *PS_CustomPictureClockFrequency;
+
+/*-------------------------------------------------------*/
+
+typedef struct _PixelAspectInformation     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint8 anyPixelAspectRatio;
+        uint32* pixelAspectCode;
+        struct _ExtendedPARItem *extendedPAR;
+        /*[...]*/
+    };
+    uint16 size;
+} S_PixelAspectInformation;
+typedef S_PixelAspectInformation *PS_PixelAspectInformation;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ExtendedPARItem     /* SEQUENCE */
+{
+    uint8 width;
+    uint8 height;
+    /*[...]*/
+} S_ExtendedPARItem;
+typedef S_ExtendedPARItem *PS_ExtendedPARItem;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MPI     /* SEQUENCE */
+{
+uint32 option_of_standardMPI :
+    1;
+uint32 option_of_customPCF :
+    1;
+    uint8 standardMPI;
+    uint16 size_of_customPCF;
+    struct _CustomPCFItem *customPCF;
+    /*[...]*/
+} S_MPI;
+typedef S_MPI *PS_MPI;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CustomPictureFormat     /* SEQUENCE */
+{
+    uint16 maxCustomPictureWidth;
+    uint16 maxCustomPictureHeight;
+    uint16 minCustomPictureWidth;
+    uint16 minCustomPictureHeight;
+    struct _MPI mPI;
+    struct _PixelAspectInformation pixelAspectInformation;
+    /*[...]*/
+} S_CustomPictureFormat;
+typedef S_CustomPictureFormat *PS_CustomPictureFormat;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CustomPCFItem     /* SEQUENCE */
+{
+    uint16 clockConversionCode;
+    uint8 clockDivisor;
+    uint16 customMPI;
+    /*[...]*/
+} S_CustomPCFItem;
+typedef S_CustomPCFItem *PS_CustomPCFItem;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H263ModeComboFlags     /* SEQUENCE */
+{
+uint32 unrestrictedVector :
+    1;
+uint32 arithmeticCoding :
+    1;
+uint32 advancedPrediction :
+    1;
+uint32 pbFrames :
+    1;
+uint32 advancedIntraCodingMode :
+    1;
+uint32 deblockingFilterMode :
+    1;
+uint32 unlimitedMotionVectors :
+    1;
+uint32 slicesInOrder_NonRect :
+    1;
+uint32 slicesInOrder_Rect :
+    1;
+uint32 slicesNoOrder_NonRect :
+    1;
+uint32 slicesNoOrder_Rect :
+    1;
+uint32 improvedPBFramesMode :
+    1;
+uint32 referencePicSelect :
+    1;
+uint32 dynamicPictureResizingByFour :
+    1;
+uint32 dynamicPictureResizingSixteenthPel :
+    1;
+uint32 dynamicWarpingHalfPel :
+    1;
+uint32 dynamicWarpingSixteenthPel :
+    1;
+uint32 reducedResolutionUpdate :
+    1;
+uint32 independentSegmentDecoding :
+    1;
+uint32 alternateInterVLCMode :
+    1;
+uint32 modifiedQuantizationMode :
+    1;
+    /*[...]*/
+} S_H263ModeComboFlags;
+typedef S_H263ModeComboFlags *PS_H263ModeComboFlags;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H263VideoModeCombos     /* SEQUENCE */
+{
+    struct _H263ModeComboFlags h263VideoUncoupledModes;
+    uint16 size_of_h263VideoCoupledModes;
+    struct _H263ModeComboFlags *h263VideoCoupledModes;
+    /*[...]*/
+} S_H263VideoModeCombos;
+typedef S_H263VideoModeCombos *PS_H263VideoModeCombos;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IS11172VideoCapability     /* SEQUENCE */
+{
+uint32 option_of_videoBitRate :
+    1;
+uint32 option_of_vbvBufferSize :
+    1;
+uint32 option_of_samplesPerLine :
+    1;
+uint32 option_of_linesPerFrame :
+    1;
+uint32 option_of_pictureRate :
+    1;
+uint32 option_of_luminanceSampleRate :
+    1;
+uint32 constrainedBitstream :
+    1;
+    uint32 videoBitRate;
+    uint32 vbvBufferSize;
+    uint16 samplesPerLine;
+    uint16 linesPerFrame;
+    uint8 pictureRate;
+    uint32 luminanceSampleRate;
+    /*[...]*/
+} S_IS11172VideoCapability;
+typedef S_IS11172VideoCapability *PS_IS11172VideoCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AudioCapability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        uint16 g711Alaw64k;
+        uint16 g711Alaw56k;
+        uint16 g711Ulaw64k;
+        uint16 g711Ulaw56k;
+        uint16 g722_64k;
+        uint16 g722_56k;
+        uint16 g722_48k;
+        struct _G7231 *g7231;
+        uint16 g728;
+        uint16 g729;
+        uint16 g729AnnexA;
+        struct _IS11172AudioCapability *is11172AudioCapability;
+        struct _IS13818AudioCapability *is13818AudioCapability;
+        /*[...]*/
+        uint16 g729wAnnexB;
+        uint16 g729AnnexAwAnnexB;
+        struct _G7231AnnexCCapability *g7231AnnexCCapability;
+        struct _GSMAudioCapability *gsmFullRate;
+        struct _GSMAudioCapability *gsmHalfRate;
+        struct _GSMAudioCapability *gsmEnhancedFullRate;
+        struct _GenericCapability *genericAudioCapability;
+        struct _G729Extensions *g729Extensions;
+    };
+} S_AudioCapability;
+typedef S_AudioCapability *PS_AudioCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _G7231     /* SEQUENCE */
+{
+    uint16 maxAl_sduAudioFrames;
+uint32 silenceSuppression :
+    1;
+} S_G7231;
+typedef S_G7231 *PS_G7231;
+
+/*-------------------------------------------------------*/
+
+typedef struct _G729Extensions     /* SEQUENCE */
+{
+uint32 option_of_audioUnit :
+    1;
+    uint16 audioUnit;
+uint32 annexA :
+    1;
+uint32 annexB :
+    1;
+uint32 annexD :
+    1;
+uint32 annexE :
+    1;
+uint32 annexF :
+    1;
+uint32 annexG :
+    1;
+uint32 annexH :
+    1;
+    /*[...]*/
+} S_G729Extensions;
+typedef S_G729Extensions *PS_G729Extensions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _G723AnnexCAudioMode     /* SEQUENCE */
+{
+    uint8 highRateMode0;
+    uint8 highRateMode1;
+    uint8 lowRateMode0;
+    uint8 lowRateMode1;
+    uint8 sidMode0;
+    uint8 sidMode1;
+    /*[...]*/
+} S_G723AnnexCAudioMode;
+typedef S_G723AnnexCAudioMode *PS_G723AnnexCAudioMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _G7231AnnexCCapability     /* SEQUENCE */
+{
+uint32 option_of_g723AnnexCAudioMode :
+    1;
+    uint16 maxAl_sduAudioFrames;
+uint32 silenceSuppression :
+    1;
+    struct _G723AnnexCAudioMode g723AnnexCAudioMode;
+    /*[...]*/
+} S_G7231AnnexCCapability;
+typedef S_G7231AnnexCCapability *PS_G7231AnnexCCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IS11172AudioCapability     /* SEQUENCE */
+{
+uint32 audioLayer1 :
+    1;
+uint32 audioLayer2 :
+    1;
+uint32 audioLayer3 :
+    1;
+uint32 audioSampling32k :
+    1;
+uint32 audioSampling44k1 :
+    1;
+uint32 audioSampling48k :
+    1;
+uint32 singleChannel :
+    1;
+uint32 twoChannels :
+    1;
+    uint16 bitRate;
+    /*[...]*/
+} S_IS11172AudioCapability;
+typedef S_IS11172AudioCapability *PS_IS11172AudioCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IS13818AudioCapability     /* SEQUENCE */
+{
+uint32 audioLayer1 :
+    1;
+uint32 audioLayer2 :
+    1;
+uint32 audioLayer3 :
+    1;
+uint32 audioSampling16k :
+    1;
+uint32 audioSampling22k05 :
+    1;
+uint32 audioSampling24k :
+    1;
+uint32 audioSampling32k :
+    1;
+uint32 audioSampling44k1 :
+    1;
+uint32 audioSampling48k :
+    1;
+uint32 singleChannel :
+    1;
+uint32 twoChannels :
+    1;
+uint32 threeChannels2_1 :
+    1;
+uint32 threeChannels3_0 :
+    1;
+uint32 fourChannels2_0_2_0 :
+    1;
+uint32 fourChannels2_2 :
+    1;
+uint32 fourChannels3_1 :
+    1;
+uint32 fiveChannels3_0_2_0 :
+    1;
+uint32 fiveChannels3_2 :
+    1;
+uint32 lowFrequencyEnhancement :
+    1;
+uint32 multilingual :
+    1;
+    uint16 bitRate;
+    /*[...]*/
+} S_IS13818AudioCapability;
+typedef S_IS13818AudioCapability *PS_IS13818AudioCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _GSMAudioCapability     /* SEQUENCE */
+{
+    uint16 audioUnitSize;
+uint32 comfortNoise :
+    1;
+uint32 scrambled :
+    1;
+    /*[...]*/
+} S_GSMAudioCapability;
+typedef S_GSMAudioCapability *PS_GSMAudioCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Application     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _DataProtocolCapability *t120;
+        struct _DataProtocolCapability *dsm_cc;
+        struct _DataProtocolCapability *userData;
+        struct _T84 *t84;
+        struct _DataProtocolCapability *t434;
+        struct _DataProtocolCapability *h224;
+        struct _Nlpid *nlpid;
+        /* (NULL) dsvdControl */
+        struct _DataProtocolCapability *h222DataPartitioning;
+        /*[...]*/
+        struct _DataProtocolCapability *t30fax;
+        struct _DataProtocolCapability *t140;
+        struct _T38fax *t38fax;
+        struct _GenericCapability *genericDataCapability;
+    };
+} S_Application;
+typedef S_Application *PS_Application;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DataApplicationCapability     /* SEQUENCE */
+{
+    struct _Application application;
+    uint32 maxBitRate;
+    /*[...]*/
+} S_DataApplicationCapability;
+typedef S_DataApplicationCapability *PS_DataApplicationCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DataProtocolCapability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) v14buffered */
+        /* (NULL) v42lapm */
+        /* (NULL) hdlcFrameTunnelling */
+        /* (NULL) h310SeparateVCStack */
+        /* (NULL) h310SingleVCStack */
+        /* (NULL) transparent */
+        /*[...]*/
+        /* (NULL) segmentationAndReassembly */
+        /* (NULL) hdlcFrameTunnelingwSAR */
+        /* (NULL) v120 */
+        /* (NULL) separateLANStack */
+        struct _V76wCompression *v76wCompression;
+        /* (NULL) tcp */
+        /* (NULL) udp */
+    };
+} S_DataProtocolCapability;
+typedef S_DataProtocolCapability *PS_DataProtocolCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Nlpid     /* SEQUENCE */
+{
+    struct _DataProtocolCapability nlpidProtocol;
+    S_OCTETSTRING nlpidData;
+} S_Nlpid;
+typedef S_Nlpid *PS_Nlpid;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V76wCompression     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _CompressionType *transmitCompression;
+        struct _CompressionType *receiveCompression;
+        struct _CompressionType *transmitAndReceiveCompression;
+        /*[...]*/
+    };
+} S_V76wCompression;
+typedef S_V76wCompression *PS_V76wCompression;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CompressionType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _V42bis *v42bis;
+        /*[...]*/
+    };
+} S_CompressionType;
+typedef S_CompressionType *PS_CompressionType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V42bis     /* SEQUENCE */
+{
+    uint32 numberOfCodewords;
+    uint16 maximumStringLength;
+    /*[...]*/
+} S_V42bis;
+typedef S_V42bis *PS_V42bis;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T84Profile     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) t84Unrestricted */
+        struct _T84Restricted *t84Restricted;
+    };
+} S_T84Profile;
+typedef S_T84Profile *PS_T84Profile;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T84     /* SEQUENCE */
+{
+    struct _DataProtocolCapability t84Protocol;
+    struct _T84Profile t84Profile;
+} S_T84;
+typedef S_T84 *PS_T84;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T84Restricted     /* SEQUENCE */
+{
+uint32 qcif :
+    1;
+uint32 cif :
+    1;
+uint32 ccir601Seq :
+    1;
+uint32 ccir601Prog :
+    1;
+uint32 hdtvSeq :
+    1;
+uint32 hdtvProg :
+    1;
+uint32 g3FacsMH200x100 :
+    1;
+uint32 g3FacsMH200x200 :
+    1;
+uint32 g4FacsMMR200x100 :
+    1;
+uint32 g4FacsMMR200x200 :
+    1;
+uint32 jbig200x200Seq :
+    1;
+uint32 jbig200x200Prog :
+    1;
+uint32 jbig300x300Seq :
+    1;
+uint32 jbig300x300Prog :
+    1;
+uint32 digPhotoLow :
+    1;
+uint32 digPhotoMedSeq :
+    1;
+uint32 digPhotoMedProg :
+    1;
+uint32 digPhotoHighSeq :
+    1;
+uint32 digPhotoHighProg :
+    1;
+    /*[...]*/
+} S_T84Restricted;
+typedef S_T84Restricted *PS_T84Restricted;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T38FaxRateManagement     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) localTCF */
+    /* (NULL) transferredTCF */
+    /*[...]*/
+} S_T38FaxRateManagement;
+typedef S_T38FaxRateManagement *PS_T38FaxRateManagement;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T38FaxUdpEC     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) t38UDPFEC */
+    /* (NULL) t38UDPRedundancy */
+    /*[...]*/
+} S_T38FaxUdpEC;
+typedef S_T38FaxUdpEC *PS_T38FaxUdpEC;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T38FaxUdpOptions     /* SEQUENCE */
+{
+uint32 option_of_t38FaxMaxBuffer :
+    1;
+uint32 option_of_t38FaxMaxDatagram :
+    1;
+    uint32 t38FaxMaxBuffer;
+    uint32 t38FaxMaxDatagram;
+    struct _T38FaxUdpEC t38FaxUdpEC;
+} S_T38FaxUdpOptions;
+typedef S_T38FaxUdpOptions *PS_T38FaxUdpOptions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T38FaxProfile     /* SEQUENCE */
+{
+uint32 fillBitRemoval :
+    1;
+uint32 transcodingJBIG :
+    1;
+uint32 transcodingMMR :
+    1;
+    /*[...]*/
+uint32 option_of_version :
+    1;
+uint32 option_of_t38FaxRateManagement :
+    1;
+uint32 option_of_t38FaxUdpOptions :
+    1;
+    uint8 version;
+    struct _T38FaxRateManagement t38FaxRateManagement;
+    struct _T38FaxUdpOptions t38FaxUdpOptions;
+} S_T38FaxProfile;
+typedef S_T38FaxProfile *PS_T38FaxProfile;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T38fax     /* SEQUENCE */
+{
+    struct _DataProtocolCapability t38FaxProtocol;
+    struct _T38FaxProfile t38FaxProfile;
+} S_T38fax;
+typedef S_T38fax *PS_T38fax;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionCapability     /* SEQUENCE OF */
+{
+    struct _MediaEncryptionAlgorithm *item;
+    uint16 size;
+} S_EncryptionCapability;
+typedef S_EncryptionCapability *PS_EncryptionCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaEncryptionAlgorithm     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        PS_OBJECTIDENT algorithm;
+        /*[...]*/
+    };
+} S_MediaEncryptionAlgorithm;
+typedef S_MediaEncryptionAlgorithm *PS_MediaEncryptionAlgorithm;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AuthenticationCapability     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+    struct _NonStandardParameter nonStandard;
+    /*[...]*/
+} S_AuthenticationCapability;
+typedef S_AuthenticationCapability *PS_AuthenticationCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IntegrityCapability     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+    struct _NonStandardParameter nonStandard;
+    /*[...]*/
+} S_IntegrityCapability;
+typedef S_IntegrityCapability *PS_IntegrityCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionAuthenticationAndIntegrity     /* SEQUENCE */
+{
+uint32 option_of_encryptionCapability :
+    1;
+uint32 option_of_authenticationCapability :
+    1;
+uint32 option_of_integrityCapability :
+    1;
+    struct _EncryptionCapability encryptionCapability;
+    struct _AuthenticationCapability authenticationCapability;
+    struct _IntegrityCapability integrityCapability;
+    /*[...]*/
+} S_EncryptionAuthenticationAndIntegrity;
+typedef S_EncryptionAuthenticationAndIntegrity *PS_EncryptionAuthenticationAndIntegrity;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H235SecurityCapability     /* SEQUENCE */
+{
+    struct _EncryptionAuthenticationAndIntegrity encryptionAuthenticationAndIntegrity;
+    uint16 mediaCapability;
+    /*[...]*/
+} S_H235SecurityCapability;
+typedef S_H235SecurityCapability *PS_H235SecurityCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _UserInputCapability     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) basicString */
+        /* (NULL) iA5String */
+        /* (NULL) generalString */
+        /* (NULL) dtmf */
+        /* (NULL) hookflash */
+        /*[...]*/
+    };
+    uint16 size;
+} S_UserInputCapability;
+typedef S_UserInputCapability *PS_UserInputCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConferenceCapability     /* SEQUENCE */
+{
+uint32 option_of_nonStandardData :
+    1;
+    uint16 size_of_nonStandardData;
+    struct _NonStandardParameter *nonStandardData;
+uint32 chairControlCapability :
+    1;
+    /*[...]*/
+uint32 option_of_VideoIndicateMixingCapability :
+    1;
+uint32 option_of_multipointVisualizationCapability :
+    1;
+uint32 VideoIndicateMixingCapability :
+    1;
+uint32 multipointVisualizationCapability :
+    1;
+} S_ConferenceCapability;
+typedef S_ConferenceCapability *PS_ConferenceCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CapabilityIdentifier     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        PS_OBJECTIDENT standard;
+        struct _NonStandardParameter *h221NonStandard;
+        PS_OCTETSTRING uuid;
+        PS_int8STRING domainBased;
+        /*[...]*/
+    };
+} S_CapabilityIdentifier;
+typedef S_CapabilityIdentifier *PS_CapabilityIdentifier;
+
+/*-------------------------------------------------------*/
+
+typedef struct _GenericInformation     /* SEQUENCE */
+{
+uint32 option_of_subMessageIdentifier :
+    1;
+uint32 option_of_messageContent :
+    1;
+    struct _CapabilityIdentifier messageIdentifier;
+    uint8 subMessageIdentifier;
+    uint16 size_of_messageContent;
+    struct _GenericParameter *messageContent;
+    /*[...]*/
+} S_GenericInformation;
+typedef S_GenericInformation *PS_GenericInformation;
+
+/*-------------------------------------------------------*/
+
+typedef struct _GenericCapability     /* SEQUENCE */
+{
+uint32 option_of_maxBitRate :
+    1;
+uint32 option_of_collapsing :
+    1;
+uint32 option_of_nonCollapsing :
+    1;
+uint32 option_of_nonCollapsingRaw :
+    1;
+uint32 option_of_transport :
+    1;
+    struct _CapabilityIdentifier capabilityIdentifier;
+    uint32 maxBitRate;
+    uint16 size_of_collapsing;
+    struct _GenericParameter *collapsing;
+    uint16 size_of_nonCollapsing;
+    struct _GenericParameter *nonCollapsing;
+    S_OCTETSTRING nonCollapsingRaw;
+    struct _DataProtocolCapability transport;
+    /*[...]*/
+} S_GenericCapability;
+typedef S_GenericCapability *PS_GenericCapability;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ParameterIdentifier     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint8 standard;
+        struct _NonStandardParameter *h221NonStandard;
+        PS_OCTETSTRING uuid;
+        PS_int8STRING domainBased;
+        /*[...]*/
+    };
+} S_ParameterIdentifier;
+typedef S_ParameterIdentifier *PS_ParameterIdentifier;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ParameterValue     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) logical */
+        uint8 booleanArray;
+        uint16 unsignedMin;
+        uint16 unsignedMax;
+        uint32 unsigned32Min;
+        uint32 unsigned32Max;
+        PS_OCTETSTRING octetString;
+        struct _GenericParameter *genericParameter;
+        /*[...]*/
+    };
+    uint16 size;
+} S_ParameterValue;
+typedef S_ParameterValue *PS_ParameterValue;
+
+/*-------------------------------------------------------*/
+
+typedef struct _GenericParameter     /* SEQUENCE */
+{
+uint32 option_of_supersedes :
+    1;
+    struct _ParameterIdentifier parameterIdentifier;
+    struct _ParameterValue parameterValue;
+    uint16 size_of_supersedes;
+    struct _ParameterIdentifier *supersedes;
+    /*[...]*/
+} S_GenericParameter;
+typedef S_GenericParameter *PS_GenericParameter;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RlcMultiplexParameters     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _H223LogicalChannelParameters *h223LogicalChannelParameters;
+        struct _V76LogicalChannelParameters *v76LogicalChannelParameters;
+        /*[...]*/
+        struct _H2250LogicalChannelParameters *h2250LogicalChannelParameters;
+    };
+} S_RlcMultiplexParameters;
+typedef S_RlcMultiplexParameters *PS_RlcMultiplexParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexParameters     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _H222LogicalChannelParameters *h222LogicalChannelParameters;
+        struct _H223LogicalChannelParameters *h223LogicalChannelParameters;
+        struct _V76LogicalChannelParameters *v76LogicalChannelParameters;
+        /*[...]*/
+        struct _H2250LogicalChannelParameters *h2250LogicalChannelParameters;
+        /* (NULL) none */
+    };
+} S_MultiplexParameters;
+typedef S_MultiplexParameters *PS_MultiplexParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _T120SetupProcedure     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) originateCall */
+    /* (NULL) waitForCall */
+    /* (NULL) issueQuery */
+    /*[...]*/
+} S_T120SetupProcedure;
+typedef S_T120SetupProcedure *PS_T120SetupProcedure;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NetworkAddress     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _Q2931Address *q2931Address;
+        PS_int8STRING e164Address;
+        struct _TransportAddress *localAreaAddress;
+        /*[...]*/
+    };
+} S_NetworkAddress;
+typedef S_NetworkAddress *PS_NetworkAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Distribution     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unicast */
+    /* (NULL) multicast */
+    /*[...]*/
+} S_Distribution;
+typedef S_Distribution *PS_Distribution;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NetworkAccessParameters     /* SEQUENCE */
+{
+uint32 option_of_distribution :
+    1;
+uint32 option_of_externalReference :
+    1;
+    struct _Distribution distribution;
+    struct _NetworkAddress networkAddress;
+uint32 associateConference :
+    1;
+    S_OCTETSTRING externalReference;
+    /*[...]*/
+uint32 option_of_t120SetupProcedure :
+    1;
+    struct _T120SetupProcedure t120SetupProcedure;
+} S_NetworkAccessParameters;
+typedef S_NetworkAccessParameters *PS_NetworkAccessParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Address     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        PS_int8STRING internationalNumber;
+        PS_OCTETSTRING nsapAddress;
+        /*[...]*/
+    };
+} S_Address;
+typedef S_Address *PS_Address;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Q2931Address     /* SEQUENCE */
+{
+uint32 option_of_subaddress :
+    1;
+    struct _Address address;
+    S_OCTETSTRING subaddress;
+    /*[...]*/
+} S_Q2931Address;
+typedef S_Q2931Address *PS_Q2931Address;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V75Parameters     /* SEQUENCE */
+{
+uint32 audioHeaderPresent :
+    1;
+    /*[...]*/
+} S_V75Parameters;
+typedef S_V75Parameters *PS_V75Parameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DataType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) nullData */
+        struct _VideoCapability *videoData;
+        struct _AudioCapability *audioData;
+        struct _DataApplicationCapability *data;
+        struct _EncryptionMode *encryptionData;
+        /*[...]*/
+        struct _NonStandardParameter *h235Control;
+        struct _H235Media *h235Media;
+    };
+} S_DataType;
+typedef S_DataType *PS_DataType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ReverseLogicalChannelParameters     /* SEQUENCE */
+{
+uint32 option_of_rlcMultiplexParameters :
+    1;
+    struct _DataType dataType;
+    struct _RlcMultiplexParameters rlcMultiplexParameters;
+    /*[...]*/
+uint32 option_of_reverseLogicalChannelDependency :
+    1;
+uint32 option_of_replacementFor :
+    1;
+    uint16 reverseLogicalChannelDependency;
+    uint16 replacementFor;
+} S_ReverseLogicalChannelParameters;
+typedef S_ReverseLogicalChannelParameters *PS_ReverseLogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ForwardLogicalChannelParameters     /* SEQUENCE */
+{
+uint32 option_of_portNumber :
+    1;
+    uint16 portNumber;
+    struct _DataType dataType;
+    struct _MultiplexParameters multiplexParameters;
+    /*[...]*/
+uint32 option_of_forwardLogicalChannelDependency :
+    1;
+uint32 option_of_replacementFor :
+    1;
+    uint16 forwardLogicalChannelDependency;
+    uint16 replacementFor;
+} S_ForwardLogicalChannelParameters;
+typedef S_ForwardLogicalChannelParameters *PS_ForwardLogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _VideoCapability *videoData;
+        struct _AudioCapability *audioData;
+        struct _DataApplicationCapability *data;
+        /*[...]*/
+    };
+} S_MediaType;
+typedef S_MediaType *PS_MediaType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H235Media     /* SEQUENCE */
+{
+    struct _EncryptionAuthenticationAndIntegrity encryptionAuthenticationAndIntegrity;
+    struct _MediaType mediaType;
+    /*[...]*/
+} S_H235Media;
+typedef S_H235Media *PS_H235Media;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H222LogicalChannelParameters     /* SEQUENCE */
+{
+uint32 option_of_pcr_pid :
+    1;
+uint32 option_of_programDescriptors :
+    1;
+uint32 option_of_streamDescriptors :
+    1;
+    uint16 resourceID;
+    uint16 subChannelID;
+    uint16 pcr_pid;
+    S_OCTETSTRING programDescriptors;
+    S_OCTETSTRING streamDescriptors;
+    /*[...]*/
+} S_H222LogicalChannelParameters;
+typedef S_H222LogicalChannelParameters *PS_H222LogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AdaptationLayerType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) al1Framed */
+        /* (NULL) al1NotFramed */
+        /* (NULL) al2WithoutSequenceNumbers */
+        /* (NULL) al2WithSequenceNumbers */
+        struct _Al3 *al3;
+        /*[...]*/
+        struct _H223AL1MParameters *al1M;
+        struct _H223AL2MParameters *al2M;
+        struct _H223AL3MParameters *al3M;
+    };
+} S_AdaptationLayerType;
+typedef S_AdaptationLayerType *PS_AdaptationLayerType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223LogicalChannelParameters     /* SEQUENCE */
+{
+    struct _AdaptationLayerType adaptationLayerType;
+uint32 segmentableFlag :
+    1;
+    /*[...]*/
+} S_H223LogicalChannelParameters;
+typedef S_H223LogicalChannelParameters *PS_H223LogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Al3     /* SEQUENCE */
+{
+    uint8 controlFieldOctets;
+    uint32 sendBufferSize;
+} S_Al3;
+typedef S_Al3 *PS_Al3;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ArqType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) noArq */
+        struct _H223AnnexCArqParameters *typeIArq;
+        struct _H223AnnexCArqParameters *typeIIArq;
+        /*[...]*/
+    };
+} S_ArqType;
+typedef S_ArqType *PS_ArqType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CrcLength     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) crc4bit */
+    /* (NULL) crc12bit */
+    /* (NULL) crc20bit */
+    /* (NULL) crc28bit */
+    /*[...]*/
+    /* (NULL) crc8bit */
+    /* (NULL) crc16bit */
+    /* (NULL) crc32bit */
+    /* (NULL) crcNotUsed */
+} S_CrcLength;
+typedef S_CrcLength *PS_CrcLength;
+
+/*-------------------------------------------------------*/
+
+typedef struct _HeaderFEC     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) sebch16_7 */
+    /* (NULL) golay24_12 */
+    /*[...]*/
+} S_HeaderFEC;
+typedef S_HeaderFEC *PS_HeaderFEC;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TransferMode     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) framed */
+    /* (NULL) unframed */
+    /*[...]*/
+} S_TransferMode;
+typedef S_TransferMode *PS_TransferMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223AL1MParameters     /* SEQUENCE */
+{
+    struct _TransferMode transferMode;
+    struct _HeaderFEC headerFEC;
+    struct _CrcLength crcLength;
+    uint8 rcpcCodeRate;
+    struct _ArqType arqType;
+uint32 alpduInterleaving :
+    1;
+uint32 alsduSplitting :
+    1;
+    /*[...]*/
+uint32 option_of_rsCodeCorrection :
+    1;
+    uint8 rsCodeCorrection;
+} S_H223AL1MParameters;
+typedef S_H223AL1MParameters *PS_H223AL1MParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Al2HeaderFEC     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) sebch16_5 */
+    /* (NULL) golay24_12 */
+    /*[...]*/
+} S_Al2HeaderFEC;
+typedef S_Al2HeaderFEC *PS_Al2HeaderFEC;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223AL2MParameters     /* SEQUENCE */
+{
+    struct _Al2HeaderFEC al2HeaderFEC;
+uint32 alpduInterleaving :
+    1;
+    /*[...]*/
+} S_H223AL2MParameters;
+typedef S_H223AL2MParameters *PS_H223AL2MParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Al3ArqType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) noArq */
+        struct _H223AnnexCArqParameters *typeIArq;
+        struct _H223AnnexCArqParameters *typeIIArq;
+        /*[...]*/
+    };
+} S_Al3ArqType;
+typedef S_Al3ArqType *PS_Al3ArqType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Al3CrcLength     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) crc4bit */
+    /* (NULL) crc12bit */
+    /* (NULL) crc20bit */
+    /* (NULL) crc28bit */
+    /*[...]*/
+    /* (NULL) crc8bit */
+    /* (NULL) crc16bit */
+    /* (NULL) crc32bit */
+    /* (NULL) crcNotUsed */
+} S_Al3CrcLength;
+typedef S_Al3CrcLength *PS_Al3CrcLength;
+
+/*-------------------------------------------------------*/
+
+typedef struct _HeaderFormat     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) sebch16_7 */
+    /* (NULL) golay24_12 */
+    /*[...]*/
+} S_HeaderFormat;
+typedef S_HeaderFormat *PS_HeaderFormat;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223AL3MParameters     /* SEQUENCE */
+{
+    struct _HeaderFormat headerFormat;
+    struct _Al3CrcLength al3CrcLength;
+    uint8 rcpcCodeRate;
+    struct _Al3ArqType al3ArqType;
+uint32 alpduInterleaving :
+    1;
+    /*[...]*/
+uint32 option_of_rsCodeCorrection :
+    1;
+    uint8 rsCodeCorrection;
+} S_H223AL3MParameters;
+typedef S_H223AL3MParameters *PS_H223AL3MParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NumberOfRetransmissions     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint8 finite;
+        /* (NULL) infinite */
+        /*[...]*/
+    };
+} S_NumberOfRetransmissions;
+typedef S_NumberOfRetransmissions *PS_NumberOfRetransmissions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223AnnexCArqParameters     /* SEQUENCE */
+{
+    struct _NumberOfRetransmissions numberOfRetransmissions;
+    uint32 sendBufferSize;
+    /*[...]*/
+} S_H223AnnexCArqParameters;
+typedef S_H223AnnexCArqParameters *PS_H223AnnexCArqParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Mode     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _ERM *eRM;
+        /* (NULL) uNERM */
+        /*[...]*/
+    };
+} S_Mode;
+typedef S_Mode *PS_Mode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Recovery     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) rej */
+    /* (NULL) sREJ */
+    /* (NULL) mSREJ */
+    /*[...]*/
+} S_Recovery;
+typedef S_Recovery *PS_Recovery;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ERM     /* SEQUENCE */
+{
+    uint8 windowSize;
+    struct _Recovery recovery;
+    /*[...]*/
+} S_ERM;
+typedef S_ERM *PS_ERM;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SuspendResume     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) noSuspendResume */
+    /* (NULL) suspendResumewAddress */
+    /* (NULL) suspendResumewoAddress */
+    /*[...]*/
+} S_SuspendResume;
+typedef S_SuspendResume *PS_SuspendResume;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CRCLength     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) crc8bit */
+    /* (NULL) crc16bit */
+    /* (NULL) crc32bit */
+    /*[...]*/
+} S_CRCLength;
+typedef S_CRCLength *PS_CRCLength;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V76HDLCParameters     /* SEQUENCE */
+{
+    struct _CRCLength crcLength;
+    uint16 n401;
+uint32 loopbackTestProcedure :
+    1;
+    /*[...]*/
+} S_V76HDLCParameters;
+typedef S_V76HDLCParameters *PS_V76HDLCParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V76LogicalChannelParameters     /* SEQUENCE */
+{
+    struct _V76HDLCParameters hdlcParameters;
+    struct _SuspendResume suspendResume;
+uint32 uIH :
+    1;
+    struct _Mode mode;
+    struct _V75Parameters v75Parameters;
+    /*[...]*/
+} S_V76LogicalChannelParameters;
+typedef S_V76LogicalChannelParameters *PS_V76LogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaPacketization     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) h261aVideoPacketization */
+        /*[...]*/
+        struct _RTPPayloadType *rtpPayloadType;
+    };
+} S_MediaPacketization;
+typedef S_MediaPacketization *PS_MediaPacketization;
+
+/*-------------------------------------------------------*/
+
+typedef struct _PayloadDescriptor     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandardIdentifier;
+        uint16 rfc_number;
+        PS_OBJECTIDENT oid;
+        /*[...]*/
+    };
+} S_PayloadDescriptor;
+typedef S_PayloadDescriptor *PS_PayloadDescriptor;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RTPPayloadType     /* SEQUENCE */
+{
+uint32 option_of_payloadType :
+    1;
+    struct _PayloadDescriptor payloadDescriptor;
+    uint8 payloadType;
+    /*[...]*/
+} S_RTPPayloadType;
+typedef S_RTPPayloadType *PS_RTPPayloadType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RedundancyEncoding     /* SEQUENCE */
+{
+uint32 option_of_secondaryEncoding :
+    1;
+    struct _RedundancyEncodingMethod redundancyEncodingMethod;
+    struct _DataType secondaryEncoding;
+    /*[...]*/
+} S_RedundancyEncoding;
+typedef S_RedundancyEncoding *PS_RedundancyEncoding;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TransportAddress     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _UnicastAddress *unicastAddress;
+        struct _MulticastAddress *multicastAddress;
+        /*[...]*/
+    };
+} S_TransportAddress;
+typedef S_TransportAddress *PS_TransportAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _UnicastAddress     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _IPAddress *iPAddress;
+        struct _IPXAddress *iPXAddress;
+        struct _IP6Address *iP6Address;
+        PS_OCTETSTRING netBios;
+        struct _IPSourceRouteAddress *iPSourceRouteAddress;
+        /*[...]*/
+        PS_OCTETSTRING nsap;
+        struct _NonStandardParameter *nonStandardAddress;
+    };
+} S_UnicastAddress;
+typedef S_UnicastAddress *PS_UnicastAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Routing     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) strict */
+    /* (NULL) loose */
+} S_Routing;
+typedef S_Routing *PS_Routing;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IPSourceRouteAddress     /* SEQUENCE */
+{
+    struct _Routing routing;
+    S_OCTETSTRING network;
+    uint16 tsapIdentifier;
+    uint16 size_of_route;
+    PS_OCTETSTRING route;
+    /*[...]*/
+} S_IPSourceRouteAddress;
+typedef S_IPSourceRouteAddress *PS_IPSourceRouteAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IP6Address     /* SEQUENCE */
+{
+    S_OCTETSTRING network;
+    uint16 tsapIdentifier;
+    /*[...]*/
+} S_IP6Address;
+typedef S_IP6Address *PS_IP6Address;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IPXAddress     /* SEQUENCE */
+{
+    S_OCTETSTRING node;
+    S_OCTETSTRING netnum;
+    S_OCTETSTRING tsapIdentifier;
+    /*[...]*/
+} S_IPXAddress;
+typedef S_IPXAddress *PS_IPXAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IPAddress     /* SEQUENCE */
+{
+    S_OCTETSTRING network;
+    uint16 tsapIdentifier;
+    /*[...]*/
+} S_IPAddress;
+typedef S_IPAddress *PS_IPAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MulticastAddress     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _MaIpAddress *maIpAddress;
+        struct _MaIp6Address *maIp6Address;
+        /*[...]*/
+        PS_OCTETSTRING nsap;
+        struct _NonStandardParameter *nonStandardAddress;
+    };
+} S_MulticastAddress;
+typedef S_MulticastAddress *PS_MulticastAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaIp6Address     /* SEQUENCE */
+{
+    S_OCTETSTRING network;
+    uint16 tsapIdentifier;
+    /*[...]*/
+} S_MaIp6Address;
+typedef S_MaIp6Address *PS_MaIp6Address;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaIpAddress     /* SEQUENCE */
+{
+    S_OCTETSTRING network;
+    uint16 tsapIdentifier;
+    /*[...]*/
+} S_MaIpAddress;
+typedef S_MaIpAddress *PS_MaIpAddress;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionSync     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+uint32 option_of_escrowentry :
+    1;
+    struct _NonStandardParameter nonStandard;
+    uint8 synchFlag;
+    S_OCTETSTRING h235Key;
+    uint16 size_of_escrowentry;
+    struct _EscrowData *escrowentry;
+    /*[...]*/
+} S_EncryptionSync;
+typedef S_EncryptionSync *PS_EncryptionSync;
+
+/*-------------------------------------------------------*/
+
+typedef struct _OpenLogicalChannel     /* SEQUENCE */
+{
+uint32 option_of_reverseLogicalChannelParameters :
+    1;
+    uint16 forwardLogicalChannelNumber;
+    struct _ForwardLogicalChannelParameters forwardLogicalChannelParameters;
+    struct _ReverseLogicalChannelParameters reverseLogicalChannelParameters;
+    /*[...]*/
+uint32 option_of_separateStack :
+    1;
+uint32 option_of_encryptionSync :
+    1;
+    struct _NetworkAccessParameters separateStack;
+    struct _EncryptionSync encryptionSync;
+} S_OpenLogicalChannel;
+typedef S_OpenLogicalChannel *PS_OpenLogicalChannel;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EscrowData     /* SEQUENCE */
+{
+    S_OBJECTIDENT escrowID;
+    S_BITSTRING escrowValue;
+    /*[...]*/
+} S_EscrowData;
+typedef S_EscrowData *PS_EscrowData;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ForwardMultiplexAckParameters     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _H2250LogicalChannelAckParameters *h2250LogicalChannelAckParameters;
+        /*[...]*/
+    };
+} S_ForwardMultiplexAckParameters;
+typedef S_ForwardMultiplexAckParameters *PS_ForwardMultiplexAckParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AckMultiplexParameters     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _H222LogicalChannelParameters *h222LogicalChannelParameters;
+        /*[...]*/
+        struct _H2250LogicalChannelParameters *h2250LogicalChannelParameters;
+    };
+} S_AckMultiplexParameters;
+typedef S_AckMultiplexParameters *PS_AckMultiplexParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AckReverseLogicalChannelParameters     /* SEQUENCE */
+{
+uint32 option_of_portNumber :
+    1;
+uint32 option_of_ackMultiplexParameters :
+    1;
+    uint16 reverseLogicalChannelNumber;
+    uint16 portNumber;
+    struct _AckMultiplexParameters ackMultiplexParameters;
+    /*[...]*/
+uint32 option_of_replacementFor :
+    1;
+    uint16 replacementFor;
+} S_AckReverseLogicalChannelParameters;
+typedef S_AckReverseLogicalChannelParameters *PS_AckReverseLogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _OpenLogicalChannelAck     /* SEQUENCE */
+{
+uint32 option_of_ackReverseLogicalChannelParameters :
+    1;
+    uint16 forwardLogicalChannelNumber;
+    struct _AckReverseLogicalChannelParameters ackReverseLogicalChannelParameters;
+    /*[...]*/
+uint32 option_of_separateStack :
+    1;
+uint32 option_of_forwardMultiplexAckParameters :
+    1;
+uint32 option_of_encryptionSync :
+    1;
+    struct _NetworkAccessParameters separateStack;
+    struct _ForwardMultiplexAckParameters forwardMultiplexAckParameters;
+    struct _EncryptionSync encryptionSync;
+} S_OpenLogicalChannelAck;
+typedef S_OpenLogicalChannelAck *PS_OpenLogicalChannelAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _OlcRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unspecified */
+    /* (NULL) unsuitableReverseParameters */
+    /* (NULL) dataTypeNotSupported */
+    /* (NULL) dataTypeNotAvailable */
+    /* (NULL) unknownDataType */
+    /* (NULL) dataTypeALCombinationNotSupported */
+    /*[...]*/
+    /* (NULL) multicastChannelNotAllowed */
+    /* (NULL) insufficientBandwidth */
+    /* (NULL) separateStackEstablishmentFailed */
+    /* (NULL) invalidSessionID */
+    /* (NULL) masterSlaveConflict */
+    /* (NULL) waitForCommunicationMode */
+    /* (NULL) invalidDependentChannel */
+    /* (NULL) replacementForRejected */
+} S_OlcRejectCause;
+typedef S_OlcRejectCause *PS_OlcRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _OpenLogicalChannelReject     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    struct _OlcRejectCause olcRejectCause;
+    /*[...]*/
+} S_OpenLogicalChannelReject;
+typedef S_OpenLogicalChannelReject *PS_OpenLogicalChannelReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _OpenLogicalChannelConfirm     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    /*[...]*/
+} S_OpenLogicalChannelConfirm;
+typedef S_OpenLogicalChannelConfirm *PS_OpenLogicalChannelConfirm;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H2250LogicalChannelAckParameters     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+uint32 option_of_sessionID :
+    1;
+uint32 option_of_mediaChannel :
+    1;
+uint32 option_of_mediaControlChannel :
+    1;
+uint32 option_of_dynamicRTPPayloadType :
+    1;
+    uint16 size_of_nonStandard;
+    struct _NonStandardParameter *nonStandard;
+    uint8 sessionID;
+    struct _TransportAddress mediaChannel;
+    struct _TransportAddress mediaControlChannel;
+    uint8 dynamicRTPPayloadType;
+    /*[...]*/
+uint32 option_of_flowControlToZero :
+    1;
+uint32 option_of_portNumber :
+    1;
+uint32 flowControlToZero :
+    1;
+    uint16 portNumber;
+} S_H2250LogicalChannelAckParameters;
+typedef S_H2250LogicalChannelAckParameters *PS_H2250LogicalChannelAckParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Reason     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unknown */
+    /* (NULL) reopen */
+    /* (NULL) reservationFailure */
+    /*[...]*/
+} S_Reason;
+typedef S_Reason *PS_Reason;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Source     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) user */
+    /* (NULL) lcse */
+} S_Source;
+typedef S_Source *PS_Source;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CloseLogicalChannel     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    struct _Source source;
+    /*[...]*/
+uint32 option_of_reason :
+    1;
+    struct _Reason reason;
+} S_CloseLogicalChannel;
+typedef S_CloseLogicalChannel *PS_CloseLogicalChannel;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CloseLogicalChannelAck     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    /*[...]*/
+} S_CloseLogicalChannelAck;
+typedef S_CloseLogicalChannelAck *PS_CloseLogicalChannelAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RccReason     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unknown */
+    /* (NULL) normal */
+    /* (NULL) reopen */
+    /* (NULL) reservationFailure */
+    /*[...]*/
+} S_RccReason;
+typedef S_RccReason *PS_RccReason;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestChannelClose     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    /*[...]*/
+uint32 option_of_qosCapability :
+    1;
+uint32 option_of_rccReason :
+    1;
+    struct _QOSCapability qosCapability;
+    struct _RccReason rccReason;
+} S_RequestChannelClose;
+typedef S_RequestChannelClose *PS_RequestChannelClose;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestChannelCloseAck     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    /*[...]*/
+} S_RequestChannelCloseAck;
+typedef S_RequestChannelCloseAck *PS_RequestChannelCloseAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RccRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unspecified */
+    /*[...]*/
+} S_RccRejectCause;
+typedef S_RccRejectCause *PS_RccRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestChannelCloseReject     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    struct _RccRejectCause rccRejectCause;
+    /*[...]*/
+} S_RequestChannelCloseReject;
+typedef S_RequestChannelCloseReject *PS_RequestChannelCloseReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestChannelCloseRelease     /* SEQUENCE */
+{
+    uint16 forwardLogicalChannelNumber;
+    /*[...]*/
+} S_RequestChannelCloseRelease;
+typedef S_RequestChannelCloseRelease *PS_RequestChannelCloseRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexEntrySend     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    uint16 size_of_multiplexEntryDescriptors;
+    struct _MultiplexEntryDescriptor *multiplexEntryDescriptors;
+    /*[...]*/
+} S_MultiplexEntrySend;
+typedef S_MultiplexEntrySend *PS_MultiplexEntrySend;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexEntryDescriptor     /* SEQUENCE */
+{
+uint32 option_of_elementList :
+    1;
+    uint8 multiplexTableEntryNumber;
+    uint16 size_of_elementList;
+    struct _MultiplexElement *elementList;
+} S_MultiplexEntryDescriptor;
+typedef S_MultiplexEntryDescriptor *PS_MultiplexEntryDescriptor;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RepeatCount     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 finite;
+        /* (NULL) untilClosingFlag */
+    };
+} S_RepeatCount;
+typedef S_RepeatCount *PS_RepeatCount;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MuxType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 logicalChannelNumber;
+        struct _MultiplexElement *subElementList;
+    };
+    uint16 size;
+} S_MuxType;
+typedef S_MuxType *PS_MuxType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexElement     /* SEQUENCE */
+{
+    struct _MuxType muxType;
+    struct _RepeatCount repeatCount;
+} S_MultiplexElement;
+typedef S_MultiplexElement *PS_MultiplexElement;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexEntrySendAck     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    uint16 size_of_multiplexTableEntryNumber;
+    uint32* multiplexTableEntryNumber;
+    /*[...]*/
+} S_MultiplexEntrySendAck;
+typedef S_MultiplexEntrySendAck *PS_MultiplexEntrySendAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexEntrySendReject     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    uint16 size_of_rejectionDescriptions;
+    struct _MultiplexEntryRejectionDescriptions *rejectionDescriptions;
+    /*[...]*/
+} S_MultiplexEntrySendReject;
+typedef S_MultiplexEntrySendReject *PS_MultiplexEntrySendReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MeRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unspecifiedCause */
+    /* (NULL) descriptorTooComplex */
+    /*[...]*/
+} S_MeRejectCause;
+typedef S_MeRejectCause *PS_MeRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexEntryRejectionDescriptions     /* SEQUENCE */
+{
+    uint8 multiplexTableEntryNumber;
+    struct _MeRejectCause meRejectCause;
+    /*[...]*/
+} S_MultiplexEntryRejectionDescriptions;
+typedef S_MultiplexEntryRejectionDescriptions *PS_MultiplexEntryRejectionDescriptions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultiplexEntrySendRelease     /* SEQUENCE */
+{
+    uint16 size_of_multiplexTableEntryNumber;
+    uint32* multiplexTableEntryNumber;
+    /*[...]*/
+} S_MultiplexEntrySendRelease;
+typedef S_MultiplexEntrySendRelease *PS_MultiplexEntrySendRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMultiplexEntry     /* SEQUENCE */
+{
+    uint16 size_of_entryNumbers;
+    uint32* entryNumbers;
+    /*[...]*/
+} S_RequestMultiplexEntry;
+typedef S_RequestMultiplexEntry *PS_RequestMultiplexEntry;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMultiplexEntryAck     /* SEQUENCE */
+{
+    uint16 size_of_entryNumbers;
+    uint32* entryNumbers;
+    /*[...]*/
+} S_RequestMultiplexEntryAck;
+typedef S_RequestMultiplexEntryAck *PS_RequestMultiplexEntryAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMultiplexEntryReject     /* SEQUENCE */
+{
+    uint16 size_of_entryNumbers;
+    uint32* entryNumbers;
+    uint16 size_of_rejectionDescriptions;
+    struct _RequestMultiplexEntryRejectionDescriptions *rejectionDescriptions;
+    /*[...]*/
+} S_RequestMultiplexEntryReject;
+typedef S_RequestMultiplexEntryReject *PS_RequestMultiplexEntryReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RmeRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unspecifiedCause */
+    /*[...]*/
+} S_RmeRejectCause;
+typedef S_RmeRejectCause *PS_RmeRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMultiplexEntryRejectionDescriptions     /* SEQUENCE */
+{
+    uint8 multiplexTableEntryNumber;
+    struct _RmeRejectCause rmeRejectCause;
+    /*[...]*/
+} S_RequestMultiplexEntryRejectionDescriptions;
+typedef S_RequestMultiplexEntryRejectionDescriptions *PS_RequestMultiplexEntryRejectionDescriptions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMultiplexEntryRelease     /* SEQUENCE */
+{
+    uint16 size_of_entryNumbers;
+    uint32* entryNumbers;
+    /*[...]*/
+} S_RequestMultiplexEntryRelease;
+typedef S_RequestMultiplexEntryRelease *PS_RequestMultiplexEntryRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestMode     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    uint16 size_of_requestedModes;
+    struct _ModeDescription *requestedModes;
+    /*[...]*/
+} S_RequestMode;
+typedef S_RequestMode *PS_RequestMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Response     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) willTransmitMostPreferredMode */
+    /* (NULL) willTransmitLessPreferredMode */
+    /*[...]*/
+} S_Response;
+typedef S_Response *PS_Response;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestModeAck     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    struct _Response response;
+    /*[...]*/
+} S_RequestModeAck;
+typedef S_RequestModeAck *PS_RequestModeAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RmRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) modeUnavailable */
+    /* (NULL) multipointConstraint */
+    /* (NULL) requestDenied */
+    /*[...]*/
+} S_RmRejectCause;
+typedef S_RmRejectCause *PS_RmRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestModeReject     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    struct _RmRejectCause rmRejectCause;
+    /*[...]*/
+} S_RequestModeReject;
+typedef S_RequestModeReject *PS_RequestModeReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestModeRelease     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_RequestModeRelease;
+typedef S_RequestModeRelease *PS_RequestModeRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeDescription     /* SET OF */
+{
+    struct _ModeElement *item;
+    uint16 size;
+} S_ModeDescription;
+typedef S_ModeDescription *PS_ModeDescription;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _VideoMode *videoMode;
+        struct _AudioMode *audioMode;
+        struct _DataMode *dataMode;
+        struct _EncryptionMode *encryptionMode;
+        /*[...]*/
+        struct _H235Mode *h235Mode;
+    };
+} S_ModeType;
+typedef S_ModeType *PS_ModeType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MediaMode     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _VideoMode *videoMode;
+        struct _AudioMode *audioMode;
+        struct _DataMode *dataMode;
+        /*[...]*/
+    };
+} S_MediaMode;
+typedef S_MediaMode *PS_MediaMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H235Mode     /* SEQUENCE */
+{
+    struct _EncryptionAuthenticationAndIntegrity encryptionAuthenticationAndIntegrity;
+    struct _MediaMode mediaMode;
+    /*[...]*/
+} S_H235Mode;
+typedef S_H235Mode *PS_H235Mode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeAdaptationLayerType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) al1Framed */
+        /* (NULL) al1NotFramed */
+        /* (NULL) al2WithoutSequenceNumbers */
+        /* (NULL) al2WithSequenceNumbers */
+        struct _ModeAl3 *modeAl3;
+        /*[...]*/
+        struct _H223AL1MParameters *al1M;
+        struct _H223AL2MParameters *al2M;
+        struct _H223AL3MParameters *al3M;
+    };
+} S_ModeAdaptationLayerType;
+typedef S_ModeAdaptationLayerType *PS_ModeAdaptationLayerType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223ModeParameters     /* SEQUENCE */
+{
+    struct _ModeAdaptationLayerType modeAdaptationLayerType;
+uint32 segmentableFlag :
+    1;
+    /*[...]*/
+} S_H223ModeParameters;
+typedef S_H223ModeParameters *PS_H223ModeParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeAl3     /* SEQUENCE */
+{
+    uint8 controlFieldOctets;
+    uint32 sendBufferSize;
+} S_ModeAl3;
+typedef S_ModeAl3 *PS_ModeAl3;
+
+/*-------------------------------------------------------*/
+
+typedef struct _V76ModeParameters     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) suspendResumewAddress */
+    /* (NULL) suspendResumewoAddress */
+    /*[...]*/
+} S_V76ModeParameters;
+typedef S_V76ModeParameters *PS_V76ModeParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SecondaryEncoding     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _AudioMode *audioData;
+        /*[...]*/
+    };
+} S_SecondaryEncoding;
+typedef S_SecondaryEncoding *PS_SecondaryEncoding;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RedundancyEncodingMode     /* SEQUENCE */
+{
+uint32 option_of_secondaryEncoding :
+    1;
+    struct _RedundancyEncodingMethod redundancyEncodingMethod;
+    struct _SecondaryEncoding secondaryEncoding;
+    /*[...]*/
+} S_RedundancyEncodingMode;
+typedef S_RedundancyEncodingMode *PS_RedundancyEncodingMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H2250ModeParameters     /* SEQUENCE */
+{
+uint32 option_of_redundancyEncodingMode :
+    1;
+    struct _RedundancyEncodingMode redundancyEncodingMode;
+    /*[...]*/
+} S_H2250ModeParameters;
+typedef S_H2250ModeParameters *PS_H2250ModeParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeElement     /* SEQUENCE */
+{
+uint32 option_of_h223ModeParameters :
+    1;
+    struct _ModeType modeType;
+    struct _H223ModeParameters h223ModeParameters;
+    /*[...]*/
+uint32 option_of_v76ModeParameters :
+    1;
+uint32 option_of_h2250ModeParameters :
+    1;
+uint32 option_of_genericModeParameters :
+    1;
+    struct _V76ModeParameters v76ModeParameters;
+    struct _H2250ModeParameters h2250ModeParameters;
+    struct _GenericCapability genericModeParameters;
+} S_ModeElement;
+typedef S_ModeElement *PS_ModeElement;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoMode     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _H261VideoMode *h261VideoMode;
+        struct _H262VideoMode *h262VideoMode;
+        struct _H263VideoMode *h263VideoMode;
+        struct _IS11172VideoMode *is11172VideoMode;
+        /*[...]*/
+        struct _GenericCapability *genericVideoMode;
+    };
+} S_VideoMode;
+typedef S_VideoMode *PS_VideoMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Resolution     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) qcif */
+    /* (NULL) cif */
+} S_Resolution;
+typedef S_Resolution *PS_Resolution;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H261VideoMode     /* SEQUENCE */
+{
+    struct _Resolution resolution;
+    uint16 bitRate;
+uint32 stillImageTransmission :
+    1;
+    /*[...]*/
+} S_H261VideoMode;
+typedef S_H261VideoMode *PS_H261VideoMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ProfileAndLevel     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) profileAndLevel_SPatML */
+    /* (NULL) profileAndLevel_MPatLL */
+    /* (NULL) profileAndLevel_MPatML */
+    /* (NULL) profileAndLevel_MPatH_14 */
+    /* (NULL) profileAndLevel_MPatHL */
+    /* (NULL) profileAndLevel_SNRatLL */
+    /* (NULL) profileAndLevel_SNRatML */
+    /* (NULL) profileAndLevel_SpatialatH_14 */
+    /* (NULL) profileAndLevel_HPatML */
+    /* (NULL) profileAndLevel_HPatH_14 */
+    /* (NULL) profileAndLevel_HPatHL */
+    /*[...]*/
+} S_ProfileAndLevel;
+typedef S_ProfileAndLevel *PS_ProfileAndLevel;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H262VideoMode     /* SEQUENCE */
+{
+uint32 option_of_videoBitRate :
+    1;
+uint32 option_of_vbvBufferSize :
+    1;
+uint32 option_of_samplesPerLine :
+    1;
+uint32 option_of_linesPerFrame :
+    1;
+uint32 option_of_framesPerSecond :
+    1;
+uint32 option_of_luminanceSampleRate :
+    1;
+    struct _ProfileAndLevel profileAndLevel;
+    uint32 videoBitRate;
+    uint32 vbvBufferSize;
+    uint16 samplesPerLine;
+    uint16 linesPerFrame;
+    uint8 framesPerSecond;
+    uint32 luminanceSampleRate;
+    /*[...]*/
+} S_H262VideoMode;
+typedef S_H262VideoMode *PS_H262VideoMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H263Resolution     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) sqcif */
+    /* (NULL) qcif */
+    /* (NULL) cif */
+    /* (NULL) cif4 */
+    /* (NULL) cif16 */
+    /*[...]*/
+} S_H263Resolution;
+typedef S_H263Resolution *PS_H263Resolution;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H263VideoMode     /* SEQUENCE */
+{
+    struct _H263Resolution h263Resolution;
+    uint16 bitRate;
+uint32 unrestrictedVector :
+    1;
+uint32 arithmeticCoding :
+    1;
+uint32 advancedPrediction :
+    1;
+uint32 pbFrames :
+    1;
+    /*[...]*/
+uint32 option_of_errorCompensation :
+    1;
+uint32 option_of_enhancementLayerInfo :
+    1;
+uint32 option_of_h263Options :
+    1;
+uint32 errorCompensation :
+    1;
+    struct _EnhancementLayerInfo enhancementLayerInfo;
+    struct _H263Options h263Options;
+} S_H263VideoMode;
+typedef S_H263VideoMode *PS_H263VideoMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IS11172VideoMode     /* SEQUENCE */
+{
+uint32 option_of_videoBitRate :
+    1;
+uint32 option_of_vbvBufferSize :
+    1;
+uint32 option_of_samplesPerLine :
+    1;
+uint32 option_of_linesPerFrame :
+    1;
+uint32 option_of_pictureRate :
+    1;
+uint32 option_of_luminanceSampleRate :
+    1;
+uint32 constrainedBitstream :
+    1;
+    uint32 videoBitRate;
+    uint32 vbvBufferSize;
+    uint16 samplesPerLine;
+    uint16 linesPerFrame;
+    uint8 pictureRate;
+    uint32 luminanceSampleRate;
+    /*[...]*/
+} S_IS11172VideoMode;
+typedef S_IS11172VideoMode *PS_IS11172VideoMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AudioMode     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) g711Alaw64k */
+        /* (NULL) g711Alaw56k */
+        /* (NULL) g711Ulaw64k */
+        /* (NULL) g711Ulaw56k */
+        /* (NULL) g722_64k */
+        /* (NULL) g722_56k */
+        /* (NULL) g722_48k */
+        /* (NULL) g728 */
+        /* (NULL) g729 */
+        /* (NULL) g729AnnexA */
+        struct _ModeG7231 *modeG7231;
+        struct _IS11172AudioMode *is11172AudioMode;
+        struct _IS13818AudioMode *is13818AudioMode;
+        /*[...]*/
+        uint16 g729wAnnexB;
+        uint16 g729AnnexAwAnnexB;
+        struct _G7231AnnexCMode *g7231AnnexCMode;
+        struct _GSMAudioCapability *gsmFullRate;
+        struct _GSMAudioCapability *gsmHalfRate;
+        struct _GSMAudioCapability *gsmEnhancedFullRate;
+        struct _GenericCapability *genericAudioMode;
+        struct _G729Extensions *g729Extensions;
+    };
+} S_AudioMode;
+typedef S_AudioMode *PS_AudioMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeG7231     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) noSilenceSuppressionLowRate */
+    /* (NULL) noSilenceSuppressionHighRate */
+    /* (NULL) silenceSuppressionLowRate */
+    /* (NULL) silenceSuppressionHighRate */
+} S_ModeG7231;
+typedef S_ModeG7231 *PS_ModeG7231;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultichannelType     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) singleChannel */
+    /* (NULL) twoChannelStereo */
+    /* (NULL) twoChannelDual */
+} S_MultichannelType;
+typedef S_MultichannelType *PS_MultichannelType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AudioSampling     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) audioSampling32k */
+    /* (NULL) audioSampling44k1 */
+    /* (NULL) audioSampling48k */
+} S_AudioSampling;
+typedef S_AudioSampling *PS_AudioSampling;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AudioLayer     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) audioLayer1 */
+    /* (NULL) audioLayer2 */
+    /* (NULL) audioLayer3 */
+} S_AudioLayer;
+typedef S_AudioLayer *PS_AudioLayer;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IS11172AudioMode     /* SEQUENCE */
+{
+    struct _AudioLayer audioLayer;
+    struct _AudioSampling audioSampling;
+    struct _MultichannelType multichannelType;
+    uint16 bitRate;
+    /*[...]*/
+} S_IS11172AudioMode;
+typedef S_IS11172AudioMode *PS_IS11172AudioMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Is13818MultichannelType     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) singleChannel */
+    /* (NULL) twoChannelStereo */
+    /* (NULL) twoChannelDual */
+    /* (NULL) threeChannels2_1 */
+    /* (NULL) threeChannels3_0 */
+    /* (NULL) fourChannels2_0_2_0 */
+    /* (NULL) fourChannels2_2 */
+    /* (NULL) fourChannels3_1 */
+    /* (NULL) fiveChannels3_0_2_0 */
+    /* (NULL) fiveChannels3_2 */
+} S_Is13818MultichannelType;
+typedef S_Is13818MultichannelType *PS_Is13818MultichannelType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Is13818AudioSampling     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) audioSampling16k */
+    /* (NULL) audioSampling22k05 */
+    /* (NULL) audioSampling24k */
+    /* (NULL) audioSampling32k */
+    /* (NULL) audioSampling44k1 */
+    /* (NULL) audioSampling48k */
+} S_Is13818AudioSampling;
+typedef S_Is13818AudioSampling *PS_Is13818AudioSampling;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Is13818AudioLayer     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) audioLayer1 */
+    /* (NULL) audioLayer2 */
+    /* (NULL) audioLayer3 */
+} S_Is13818AudioLayer;
+typedef S_Is13818AudioLayer *PS_Is13818AudioLayer;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IS13818AudioMode     /* SEQUENCE */
+{
+    struct _Is13818AudioLayer is13818AudioLayer;
+    struct _Is13818AudioSampling is13818AudioSampling;
+    struct _Is13818MultichannelType is13818MultichannelType;
+uint32 lowFrequencyEnhancement :
+    1;
+uint32 multilingual :
+    1;
+    uint16 bitRate;
+    /*[...]*/
+} S_IS13818AudioMode;
+typedef S_IS13818AudioMode *PS_IS13818AudioMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ModeG723AnnexCAudioMode     /* SEQUENCE */
+{
+    uint8 highRateMode0;
+    uint8 highRateMode1;
+    uint8 lowRateMode0;
+    uint8 lowRateMode1;
+    uint8 sidMode0;
+    uint8 sidMode1;
+    /*[...]*/
+} S_ModeG723AnnexCAudioMode;
+typedef S_ModeG723AnnexCAudioMode *PS_ModeG723AnnexCAudioMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _G7231AnnexCMode     /* SEQUENCE */
+{
+    uint16 maxAl_sduAudioFrames;
+uint32 silenceSuppression :
+    1;
+    struct _ModeG723AnnexCAudioMode modeG723AnnexCAudioMode;
+    /*[...]*/
+} S_G7231AnnexCMode;
+typedef S_G7231AnnexCMode *PS_G7231AnnexCMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DmApplication     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        struct _DataProtocolCapability *t120;
+        struct _DataProtocolCapability *dsm_cc;
+        struct _DataProtocolCapability *userData;
+        struct _DataProtocolCapability *t84;
+        struct _DataProtocolCapability *t434;
+        struct _DataProtocolCapability *h224;
+        struct _DmNlpid *dmNlpid;
+        /* (NULL) dsvdControl */
+        struct _DataProtocolCapability *h222DataPartitioning;
+        /*[...]*/
+        struct _DataProtocolCapability *t30fax;
+        struct _DataProtocolCapability *t140;
+        struct _DmT38fax *dmT38fax;
+        struct _GenericCapability *genericDataMode;
+    };
+} S_DmApplication;
+typedef S_DmApplication *PS_DmApplication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DataMode     /* SEQUENCE */
+{
+    struct _DmApplication dmApplication;
+    uint32 bitRate;
+    /*[...]*/
+} S_DataMode;
+typedef S_DataMode *PS_DataMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DmT38fax     /* SEQUENCE */
+{
+    struct _DataProtocolCapability t38FaxProtocol;
+    struct _T38FaxProfile t38FaxProfile;
+} S_DmT38fax;
+typedef S_DmT38fax *PS_DmT38fax;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DmNlpid     /* SEQUENCE */
+{
+    struct _DataProtocolCapability nlpidProtocol;
+    S_OCTETSTRING nlpidData;
+} S_DmNlpid;
+typedef S_DmNlpid *PS_DmNlpid;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionMode     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) h233Encryption */
+        /*[...]*/
+    };
+} S_EncryptionMode;
+typedef S_EncryptionMode *PS_EncryptionMode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RoundTripDelayRequest     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    /*[...]*/
+} S_RoundTripDelayRequest;
+typedef S_RoundTripDelayRequest *PS_RoundTripDelayRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RoundTripDelayResponse     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    /*[...]*/
+} S_RoundTripDelayResponse;
+typedef S_RoundTripDelayResponse *PS_RoundTripDelayResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MlRequestType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) systemLoop */
+        uint16 mediaLoop;
+        uint16 logicalChannelLoop;
+        /*[...]*/
+    };
+} S_MlRequestType;
+typedef S_MlRequestType *PS_MlRequestType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaintenanceLoopRequest     /* SEQUENCE */
+{
+    struct _MlRequestType mlRequestType;
+    /*[...]*/
+} S_MaintenanceLoopRequest;
+typedef S_MaintenanceLoopRequest *PS_MaintenanceLoopRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MlAckType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) systemLoop */
+        uint16 mediaLoop;
+        uint16 logicalChannelLoop;
+        /*[...]*/
+    };
+} S_MlAckType;
+typedef S_MlAckType *PS_MlAckType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaintenanceLoopAck     /* SEQUENCE */
+{
+    struct _MlAckType mlAckType;
+    /*[...]*/
+} S_MaintenanceLoopAck;
+typedef S_MaintenanceLoopAck *PS_MaintenanceLoopAck;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MlRejectCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) canNotPerformLoop */
+    /*[...]*/
+} S_MlRejectCause;
+typedef S_MlRejectCause *PS_MlRejectCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MlRejectType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) systemLoop */
+        uint16 mediaLoop;
+        uint16 logicalChannelLoop;
+        /*[...]*/
+    };
+} S_MlRejectType;
+typedef S_MlRejectType *PS_MlRejectType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaintenanceLoopReject     /* SEQUENCE */
+{
+    struct _MlRejectType mlRejectType;
+    struct _MlRejectCause mlRejectCause;
+    /*[...]*/
+} S_MaintenanceLoopReject;
+typedef S_MaintenanceLoopReject *PS_MaintenanceLoopReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaintenanceLoopOffCommand     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_MaintenanceLoopOffCommand;
+typedef S_MaintenanceLoopOffCommand *PS_MaintenanceLoopOffCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CommunicationModeCommand     /* SEQUENCE */
+{
+    uint16 size_of_communicationModeTable;
+    struct _CommunicationModeTableEntry *communicationModeTable;
+    /*[...]*/
+} S_CommunicationModeCommand;
+typedef S_CommunicationModeCommand *PS_CommunicationModeCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CommunicationModeRequest     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_CommunicationModeRequest;
+typedef S_CommunicationModeRequest *PS_CommunicationModeRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CommunicationModeResponse     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _CommunicationModeTableEntry *communicationModeTable;
+        /*[...]*/
+    };
+    uint16 size;
+} S_CommunicationModeResponse;
+typedef S_CommunicationModeResponse *PS_CommunicationModeResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmtDataType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _VideoCapability *videoData;
+        struct _AudioCapability *audioData;
+        struct _DataApplicationCapability *data;
+        /*[...]*/
+    };
+} S_CmtDataType;
+typedef S_CmtDataType *PS_CmtDataType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConferenceRequest     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) terminalListRequest */
+        /* (NULL) makeMeChair */
+        /* (NULL) cancelMakeMeChair */
+        struct _TerminalLabel *dropTerminal;
+        struct _TerminalLabel *requestTerminalID;
+        /* (NULL) enterH243Password */
+        /* (NULL) enterH243TerminalID */
+        /* (NULL) enterH243ConferenceID */
+        /*[...]*/
+        /* (NULL) enterExtensionAddress */
+        /* (NULL) requestChairTokenOwner */
+        struct _RequestTerminalCertificate *requestTerminalCertificate;
+        uint16 broadcastMyLogicalChannel;
+        struct _TerminalLabel *makeTerminalBroadcaster;
+        struct _TerminalLabel *sendThisSource;
+        /* (NULL) requestAllTerminalIDs */
+        struct _RemoteMCRequest *remoteMCRequest;
+    };
+} S_ConferenceRequest;
+typedef S_ConferenceRequest *PS_ConferenceRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CertSelectionCriteria     /* SEQUENCE OF */
+{
+    struct _Criteria *item;
+    uint16 size;
+} S_CertSelectionCriteria;
+typedef S_CertSelectionCriteria *PS_CertSelectionCriteria;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Criteria     /* SEQUENCE */
+{
+    S_OBJECTIDENT field;
+    S_OCTETSTRING value;
+    /*[...]*/
+} S_Criteria;
+typedef S_Criteria *PS_Criteria;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalLabel     /* SEQUENCE */
+{
+    uint8 mcuNumber;
+    uint8 terminalNumber;
+    /*[...]*/
+} S_TerminalLabel;
+typedef S_TerminalLabel *PS_TerminalLabel;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H2250LogicalChannelParameters     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+uint32 option_of_associatedSessionID :
+    1;
+uint32 option_of_mediaChannel :
+    1;
+uint32 option_of_mediaGuaranteedDelivery :
+    1;
+uint32 option_of_mediaControlChannel :
+    1;
+uint32 option_of_mediaControlGuaranteedDelivery :
+    1;
+uint32 option_of_silenceSuppression :
+    1;
+uint32 option_of_destination :
+    1;
+uint32 option_of_dynamicRTPPayloadType :
+    1;
+uint32 option_of_mediaPacketization :
+    1;
+    uint16 size_of_nonStandard;
+    struct _NonStandardParameter *nonStandard;
+    uint8 sessionID;
+    uint8 associatedSessionID;
+    struct _TransportAddress mediaChannel;
+uint32 mediaGuaranteedDelivery :
+    1;
+    struct _TransportAddress mediaControlChannel;
+uint32 mediaControlGuaranteedDelivery :
+    1;
+uint32 silenceSuppression :
+    1;
+    struct _TerminalLabel destination;
+    uint8 dynamicRTPPayloadType;
+    struct _MediaPacketization mediaPacketization;
+    /*[...]*/
+uint32 option_of_transportCapability :
+    1;
+uint32 option_of_redundancyEncoding :
+    1;
+uint32 option_of_source :
+    1;
+uint32 option_of_symmetricMediaAddress :
+    1;
+    struct _TransportCapability transportCapability;
+    struct _RedundancyEncoding redundancyEncoding;
+    struct _TerminalLabel source;
+uint32 symmetricMediaAddress :
+    1;
+} S_H2250LogicalChannelParameters;
+typedef S_H2250LogicalChannelParameters *PS_H2250LogicalChannelParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CommunicationModeTableEntry     /* SEQUENCE */
+{
+uint32 option_of_nonStandard :
+    1;
+uint32 option_of_associatedSessionID :
+    1;
+uint32 option_of_terminalLabel :
+    1;
+uint32 option_of_mediaChannel :
+    1;
+uint32 option_of_mediaGuaranteedDelivery :
+    1;
+uint32 option_of_mediaControlChannel :
+    1;
+uint32 option_of_mediaControlGuaranteedDelivery :
+    1;
+    uint16 size_of_nonStandard;
+    struct _NonStandardParameter *nonStandard;
+    uint8 sessionID;
+    uint8 associatedSessionID;
+    struct _TerminalLabel terminalLabel;
+    S_int8STRING sessionDescription;
+    struct _CmtDataType cmtDataType;
+    struct _TransportAddress mediaChannel;
+uint32 mediaGuaranteedDelivery :
+    1;
+    struct _TransportAddress mediaControlChannel;
+uint32 mediaControlGuaranteedDelivery :
+    1;
+    /*[...]*/
+uint32 option_of_redundancyEncoding :
+    1;
+uint32 option_of_sessionDependency :
+    1;
+uint32 option_of_destination :
+    1;
+    struct _RedundancyEncoding redundancyEncoding;
+    uint8 sessionDependency;
+    struct _TerminalLabel destination;
+} S_CommunicationModeTableEntry;
+typedef S_CommunicationModeTableEntry *PS_CommunicationModeTableEntry;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestTerminalCertificate     /* SEQUENCE */
+{
+uint32 option_of_terminalLabel :
+    1;
+uint32 option_of_certSelectionCriteria :
+    1;
+uint32 option_of_sRandom :
+    1;
+    struct _TerminalLabel terminalLabel;
+    struct _CertSelectionCriteria certSelectionCriteria;
+    uint32 sRandom;
+    /*[...]*/
+} S_RequestTerminalCertificate;
+typedef S_RequestTerminalCertificate *PS_RequestTerminalCertificate;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConferenceResponse     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _MCTerminalIDResponse *mCTerminalIDResponse;
+        struct _TerminalIDResponse *terminalIDResponse;
+        struct _ConferenceIDResponse *conferenceIDResponse;
+        struct _PasswordResponse *passwordResponse;
+        struct _TerminalLabel *terminalListResponse;
+        /* (NULL) videoCommandReject */
+        /* (NULL) terminalDropReject */
+        struct _MakeMeChairResponse *makeMeChairResponse;
+        /*[...]*/
+        struct _ExtensionAddressResponse *extensionAddressResponse;
+        struct _ChairTokenOwnerResponse *chairTokenOwnerResponse;
+        struct _TerminalCertificateResponse *terminalCertificateResponse;
+        struct _BroadcastMyLogicalChannelResponse *broadcastMyLogicalChannelResponse;
+        struct _MakeTerminalBroadcasterResponse *makeTerminalBroadcasterResponse;
+        struct _SendThisSourceResponse *sendThisSourceResponse;
+        struct _RequestAllTerminalIDsResponse *requestAllTerminalIDsResponse;
+        struct _RemoteMCResponse *remoteMCResponse;
+    };
+    uint16 size;
+} S_ConferenceResponse;
+typedef S_ConferenceResponse *PS_ConferenceResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SendThisSourceResponse     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) grantedSendThisSource */
+    /* (NULL) deniedSendThisSource */
+    /*[...]*/
+} S_SendThisSourceResponse;
+typedef S_SendThisSourceResponse *PS_SendThisSourceResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MakeTerminalBroadcasterResponse     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) grantedMakeTerminalBroadcaster */
+    /* (NULL) deniedMakeTerminalBroadcaster */
+    /*[...]*/
+} S_MakeTerminalBroadcasterResponse;
+typedef S_MakeTerminalBroadcasterResponse *PS_MakeTerminalBroadcasterResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _BroadcastMyLogicalChannelResponse     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) grantedBroadcastMyLogicalChannel */
+    /* (NULL) deniedBroadcastMyLogicalChannel */
+    /*[...]*/
+} S_BroadcastMyLogicalChannelResponse;
+typedef S_BroadcastMyLogicalChannelResponse *PS_BroadcastMyLogicalChannelResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalCertificateResponse     /* SEQUENCE */
+{
+uint32 option_of_terminalLabel :
+    1;
+uint32 option_of_certificateResponse :
+    1;
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING certificateResponse;
+    /*[...]*/
+} S_TerminalCertificateResponse;
+typedef S_TerminalCertificateResponse *PS_TerminalCertificateResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ChairTokenOwnerResponse     /* SEQUENCE */
+{
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING terminalID;
+    /*[...]*/
+} S_ChairTokenOwnerResponse;
+typedef S_ChairTokenOwnerResponse *PS_ChairTokenOwnerResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ExtensionAddressResponse     /* SEQUENCE */
+{
+    S_OCTETSTRING extensionAddress;
+    /*[...]*/
+} S_ExtensionAddressResponse;
+typedef S_ExtensionAddressResponse *PS_ExtensionAddressResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MakeMeChairResponse     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) grantedChairToken */
+    /* (NULL) deniedChairToken */
+    /*[...]*/
+} S_MakeMeChairResponse;
+typedef S_MakeMeChairResponse *PS_MakeMeChairResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _PasswordResponse     /* SEQUENCE */
+{
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING password;
+    /*[...]*/
+} S_PasswordResponse;
+typedef S_PasswordResponse *PS_PasswordResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConferenceIDResponse     /* SEQUENCE */
+{
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING conferenceID;
+    /*[...]*/
+} S_ConferenceIDResponse;
+typedef S_ConferenceIDResponse *PS_ConferenceIDResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalIDResponse     /* SEQUENCE */
+{
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING terminalID;
+    /*[...]*/
+} S_TerminalIDResponse;
+typedef S_TerminalIDResponse *PS_TerminalIDResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MCTerminalIDResponse     /* SEQUENCE */
+{
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING terminalID;
+    /*[...]*/
+} S_MCTerminalIDResponse;
+typedef S_MCTerminalIDResponse *PS_MCTerminalIDResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestAllTerminalIDsResponse     /* SEQUENCE */
+{
+    uint16 size_of_terminalInformation;
+    struct _TerminalInformation *terminalInformation;
+    /*[...]*/
+} S_RequestAllTerminalIDsResponse;
+typedef S_RequestAllTerminalIDsResponse *PS_RequestAllTerminalIDsResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalInformation     /* SEQUENCE */
+{
+    struct _TerminalLabel terminalLabel;
+    S_OCTETSTRING terminalID;
+    /*[...]*/
+} S_TerminalInformation;
+typedef S_TerminalInformation *PS_TerminalInformation;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RemoteMCRequest     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) masterActivate */
+    /* (NULL) slaveActivate */
+    /* (NULL) deActivate */
+    /*[...]*/
+} S_RemoteMCRequest;
+typedef S_RemoteMCRequest *PS_RemoteMCRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RemoteMCResponse     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) accept */
+        struct _Reject *reject;
+        /*[...]*/
+    };
+} S_RemoteMCResponse;
+typedef S_RemoteMCResponse *PS_RemoteMCResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Reject     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) unspecified */
+    /* (NULL) functionNotSupported */
+    /*[...]*/
+} S_Reject;
+typedef S_Reject *PS_Reject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultilinkRequest     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _CallInformation *callInformation;
+        struct _AddConnection *addConnection;
+        struct _RemoveConnection *removeConnection;
+        struct _MaximumHeaderInterval *maximumHeaderInterval;
+        /*[...]*/
+    };
+} S_MultilinkRequest;
+typedef S_MultilinkRequest *PS_MultilinkRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RequestType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) currentIntervalInformation */
+        uint16 requestedInterval;
+        /*[...]*/
+    };
+} S_RequestType;
+typedef S_RequestType *PS_RequestType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MaximumHeaderInterval     /* SEQUENCE */
+{
+    struct _RequestType requestType;
+    /*[...]*/
+} S_MaximumHeaderInterval;
+typedef S_MaximumHeaderInterval *PS_MaximumHeaderInterval;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CallInformation     /* SEQUENCE */
+{
+    uint16 maxNumberOfAdditionalConnections;
+    /*[...]*/
+} S_CallInformation;
+typedef S_CallInformation *PS_CallInformation;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultilinkResponse     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _RespCallInformation *respCallInformation;
+        struct _RespAddConnection *respAddConnection;
+        struct _RespRemoveConnection *respRemoveConnection;
+        struct _RespMaximumHeaderInterval *respMaximumHeaderInterval;
+        /*[...]*/
+    };
+} S_MultilinkResponse;
+typedef S_MultilinkResponse *PS_MultilinkResponse;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RespMaximumHeaderInterval     /* SEQUENCE */
+{
+    uint16 currentInterval;
+    /*[...]*/
+} S_RespMaximumHeaderInterval;
+typedef S_RespMaximumHeaderInterval *PS_RespMaximumHeaderInterval;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ResponseCode     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) accepted */
+        struct _Rejected *rejected;
+        /*[...]*/
+    };
+} S_ResponseCode;
+typedef S_ResponseCode *PS_ResponseCode;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RespAddConnection     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    struct _ResponseCode responseCode;
+    /*[...]*/
+} S_RespAddConnection;
+typedef S_RespAddConnection *PS_RespAddConnection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Rejected     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) connectionsNotAvailable */
+    /* (NULL) userRejected */
+    /*[...]*/
+} S_Rejected;
+typedef S_Rejected *PS_Rejected;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MultilinkIndication     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _CrcDesired *crcDesired;
+        struct _ExcessiveError *excessiveError;
+        /*[...]*/
+    };
+} S_MultilinkIndication;
+typedef S_MultilinkIndication *PS_MultilinkIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CrcDesired     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_CrcDesired;
+typedef S_CrcDesired *PS_CrcDesired;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DialingInformation     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        struct _DialingInformationNumber *differential;
+        uint16 infoNotAvailable;
+        /*[...]*/
+    };
+    uint16 size;
+} S_DialingInformation;
+typedef S_DialingInformation *PS_DialingInformation;
+
+/*-------------------------------------------------------*/
+
+typedef struct _AddConnection     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    struct _DialingInformation dialingInformation;
+    /*[...]*/
+} S_AddConnection;
+typedef S_AddConnection *PS_AddConnection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RespCallInformation     /* SEQUENCE */
+{
+    struct _DialingInformation dialingInformation;
+    uint32 callAssociationNumber;
+    /*[...]*/
+} S_RespCallInformation;
+typedef S_RespCallInformation *PS_RespCallInformation;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DialingInformationNumber     /* SEQUENCE */
+{
+uint32 option_of_subAddress :
+    1;
+    S_int8STRING networkAddress;
+    S_int8STRING subAddress;
+    uint16 size_of_networkType;
+    struct _DialingInformationNetworkType *networkType;
+    /*[...]*/
+} S_DialingInformationNumber;
+typedef S_DialingInformationNumber *PS_DialingInformationNumber;
+
+/*-------------------------------------------------------*/
+
+typedef struct _DialingInformationNetworkType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardMessage *nonStandard;
+        /* (NULL) n_isdn */
+        /* (NULL) gstn */
+        /*[...]*/
+    };
+} S_DialingInformationNetworkType;
+typedef S_DialingInformationNetworkType *PS_DialingInformationNetworkType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConnectionIdentifier     /* SEQUENCE */
+{
+    uint32 channelTag;
+    uint32 sequenceNumber;
+    /*[...]*/
+} S_ConnectionIdentifier;
+typedef S_ConnectionIdentifier *PS_ConnectionIdentifier;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RemoveConnection     /* SEQUENCE */
+{
+    struct _ConnectionIdentifier connectionIdentifier;
+    /*[...]*/
+} S_RemoveConnection;
+typedef S_RemoveConnection *PS_RemoveConnection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _RespRemoveConnection     /* SEQUENCE */
+{
+    struct _ConnectionIdentifier connectionIdentifier;
+    /*[...]*/
+} S_RespRemoveConnection;
+typedef S_RespRemoveConnection *PS_RespRemoveConnection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ExcessiveError     /* SEQUENCE */
+{
+    struct _ConnectionIdentifier connectionIdentifier;
+    /*[...]*/
+} S_ExcessiveError;
+typedef S_ExcessiveError *PS_ExcessiveError;
+
+/*-------------------------------------------------------*/
+
+typedef struct _LogicalChannelRateRequest     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    uint16 logicalChannelNumber;
+    uint32 maximumBitRate;
+    /*[...]*/
+} S_LogicalChannelRateRequest;
+typedef S_LogicalChannelRateRequest *PS_LogicalChannelRateRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _LogicalChannelRateAcknowledge     /* SEQUENCE */
+{
+    uint8 sequenceNumber;
+    uint16 logicalChannelNumber;
+    uint32 maximumBitRate;
+    /*[...]*/
+} S_LogicalChannelRateAcknowledge;
+typedef S_LogicalChannelRateAcknowledge *PS_LogicalChannelRateAcknowledge;
+
+/*-------------------------------------------------------*/
+
+typedef struct _LogicalChannelRateRejectReason     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) undefinedReason */
+    /* (NULL) insufficientResources */
+    /*[...]*/
+} S_LogicalChannelRateRejectReason;
+typedef S_LogicalChannelRateRejectReason *PS_LogicalChannelRateRejectReason;
+
+/*-------------------------------------------------------*/
+
+typedef struct _LogicalChannelRateReject     /* SEQUENCE */
+{
+uint32 option_of_currentMaximumBitRate :
+    1;
+    uint8 sequenceNumber;
+    uint16 logicalChannelNumber;
+    struct _LogicalChannelRateRejectReason rejectReason;
+    uint32 currentMaximumBitRate;
+    /*[...]*/
+} S_LogicalChannelRateReject;
+typedef S_LogicalChannelRateReject *PS_LogicalChannelRateReject;
+
+/*-------------------------------------------------------*/
+
+typedef struct _LogicalChannelRateRelease     /* SEQUENCE */
+{
+    uint8(empty_sequence);
+    /*[...]*/
+} S_LogicalChannelRateRelease;
+typedef S_LogicalChannelRateRelease *PS_LogicalChannelRateRelease;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SendTerminalCapabilitySet     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _SpecificRequest *specificRequest;
+        /* (NULL) genericRequest */
+        /*[...]*/
+    };
+} S_SendTerminalCapabilitySet;
+typedef S_SendTerminalCapabilitySet *PS_SendTerminalCapabilitySet;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SpecificRequest     /* SEQUENCE */
+{
+uint32 option_of_capabilityTableEntryNumbers :
+    1;
+uint32 option_of_capabilityDescriptorNumbers :
+    1;
+uint32 multiplexCapability :
+    1;
+    uint16 size_of_capabilityTableEntryNumbers;
+    uint32* capabilityTableEntryNumbers;
+    uint16 size_of_capabilityDescriptorNumbers;
+    uint32* capabilityDescriptorNumbers;
+    /*[...]*/
+} S_SpecificRequest;
+typedef S_SpecificRequest *PS_SpecificRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionCommand     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        PS_OCTETSTRING encryptionSE;
+        /* (NULL) encryptionIVRequest */
+        struct _EncryptionAlgorithmID *encryptionAlgorithmID;
+        /*[...]*/
+    };
+} S_EncryptionCommand;
+typedef S_EncryptionCommand *PS_EncryptionCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionAlgorithmID     /* SEQUENCE */
+{
+    uint8 h233AlgorithmIdentifier;
+    struct _NonStandardParameter associatedAlgorithm;
+} S_EncryptionAlgorithmID;
+typedef S_EncryptionAlgorithmID *PS_EncryptionAlgorithmID;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FccRestriction     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint32 maximumBitRate;
+        /* (NULL) noRestriction */
+    };
+} S_FccRestriction;
+typedef S_FccRestriction *PS_FccRestriction;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FccScope     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 logicalChannelNumber;
+        uint16 resourceID;
+        /* (NULL) wholeMultiplex */
+    };
+} S_FccScope;
+typedef S_FccScope *PS_FccScope;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FlowControlCommand     /* SEQUENCE */
+{
+    struct _FccScope fccScope;
+    struct _FccRestriction fccRestriction;
+    /*[...]*/
+} S_FlowControlCommand;
+typedef S_FlowControlCommand *PS_FlowControlCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EndSessionCommand     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) disconnect */
+        struct _GstnOptions *gstnOptions;
+        /*[...]*/
+        struct _IsdnOptions *isdnOptions;
+    };
+} S_EndSessionCommand;
+typedef S_EndSessionCommand *PS_EndSessionCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IsdnOptions     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) telephonyMode */
+    /* (NULL) v140 */
+    /* (NULL) terminalOnHold */
+    /*[...]*/
+} S_IsdnOptions;
+typedef S_IsdnOptions *PS_IsdnOptions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _GstnOptions     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) telephonyMode */
+    /* (NULL) v8bis */
+    /* (NULL) v34DSVD */
+    /* (NULL) v34DuplexFAX */
+    /* (NULL) v34H324 */
+    /*[...]*/
+} S_GstnOptions;
+typedef S_GstnOptions *PS_GstnOptions;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConferenceCommand     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 broadcastMyLogicalChannel;
+        uint16 cancelBroadcastMyLogicalChannel;
+        struct _TerminalLabel *makeTerminalBroadcaster;
+        /* (NULL) cancelMakeTerminalBroadcaster */
+        struct _TerminalLabel *sendThisSource;
+        /* (NULL) cancelSendThisSource */
+        /* (NULL) dropConference */
+        /*[...]*/
+        struct _SubstituteConferenceIDCommand *substituteConferenceIDCommand;
+    };
+} S_ConferenceCommand;
+typedef S_ConferenceCommand *PS_ConferenceCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SubstituteConferenceIDCommand     /* SEQUENCE */
+{
+    S_OCTETSTRING conferenceIdentifier;
+    /*[...]*/
+} S_SubstituteConferenceIDCommand;
+typedef S_SubstituteConferenceIDCommand *PS_SubstituteConferenceIDCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _McType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) equaliseDelay */
+        /* (NULL) zeroDelay */
+        /* (NULL) multipointModeCommand */
+        /* (NULL) cancelMultipointModeCommand */
+        /* (NULL) videoFreezePicture */
+        /* (NULL) videoFastUpdatePicture */
+        struct _VideoFastUpdateGOB *videoFastUpdateGOB;
+        uint8 videoTemporalSpatialTradeOff;
+        /* (NULL) videoSendSyncEveryGOB */
+        /* (NULL) videoSendSyncEveryGOBCancel */
+        /*[...]*/
+        struct _VideoFastUpdateMB *videoFastUpdateMB;
+        uint16 maxH223MUXPDUsize;
+        struct _EncryptionSync *encryptionUpdate;
+        struct _EncryptionUpdateRequest *encryptionUpdateRequest;
+        /* (NULL) switchReceiveMediaOff */
+        /* (NULL) switchReceiveMediaOn */
+        struct _ProgressiveRefinementStart *progressiveRefinementStart;
+        /* (NULL) progressiveRefinementAbortOne */
+        /* (NULL) progressiveRefinementAbortContinuous */
+    };
+} S_McType;
+typedef S_McType *PS_McType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MiscellaneousCommand     /* SEQUENCE */
+{
+    uint16 logicalChannelNumber;
+    struct _McType mcType;
+    /*[...]*/
+} S_MiscellaneousCommand;
+typedef S_MiscellaneousCommand *PS_MiscellaneousCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _PrsRepeatCount     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) doOneProgression */
+    /* (NULL) doContinuousProgressions */
+    /* (NULL) doOneIndependentProgression */
+    /* (NULL) doContinuousIndependentProgressions */
+    /*[...]*/
+} S_PrsRepeatCount;
+typedef S_PrsRepeatCount *PS_PrsRepeatCount;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ProgressiveRefinementStart     /* SEQUENCE */
+{
+    struct _PrsRepeatCount prsRepeatCount;
+    /*[...]*/
+} S_ProgressiveRefinementStart;
+typedef S_ProgressiveRefinementStart *PS_ProgressiveRefinementStart;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoFastUpdateMB     /* SEQUENCE */
+{
+uint32 option_of_firstGOB :
+    1;
+uint32 option_of_firstMB :
+    1;
+    uint8 firstGOB;
+    uint16 firstMB;
+    uint16 numberOfMBs;
+    /*[...]*/
+} S_VideoFastUpdateMB;
+typedef S_VideoFastUpdateMB *PS_VideoFastUpdateMB;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoFastUpdateGOB     /* SEQUENCE */
+{
+    uint8 firstGOB;
+    uint8 numberOfGOBs;
+} S_VideoFastUpdateGOB;
+typedef S_VideoFastUpdateGOB *PS_VideoFastUpdateGOB;
+
+/*-------------------------------------------------------*/
+
+typedef struct _KeyProtectionMethod     /* SEQUENCE */
+{
+uint32 secureChannel :
+    1;
+uint32 sharedSecret :
+    1;
+uint32 certProtectedKey :
+    1;
+    /*[...]*/
+} S_KeyProtectionMethod;
+typedef S_KeyProtectionMethod *PS_KeyProtectionMethod;
+
+/*-------------------------------------------------------*/
+
+typedef struct _EncryptionUpdateRequest     /* SEQUENCE */
+{
+uint32 option_of_keyProtectionMethod :
+    1;
+    struct _KeyProtectionMethod keyProtectionMethod;
+    /*[...]*/
+} S_EncryptionUpdateRequest;
+typedef S_EncryptionUpdateRequest *PS_EncryptionUpdateRequest;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223MultiplexReconfiguration     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _H223ModeChange *h223ModeChange;
+        struct _H223AnnexADoubleFlag *h223AnnexADoubleFlag;
+        /*[...]*/
+    };
+} S_H223MultiplexReconfiguration;
+typedef S_H223MultiplexReconfiguration *PS_H223MultiplexReconfiguration;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223AnnexADoubleFlag     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) start */
+    /* (NULL) stop */
+    /*[...]*/
+} S_H223AnnexADoubleFlag;
+typedef S_H223AnnexADoubleFlag *PS_H223AnnexADoubleFlag;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223ModeChange     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) toLevel0 */
+    /* (NULL) toLevel1 */
+    /* (NULL) toLevel2 */
+    /* (NULL) toLevel2withOptionalHeader */
+    /*[...]*/
+} S_H223ModeChange;
+typedef S_H223ModeChange *PS_H223ModeChange;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Multiplex     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) noMultiplex */
+    /* (NULL) transportStream */
+    /* (NULL) programStream */
+    /*[...]*/
+} S_Multiplex;
+typedef S_Multiplex *PS_Multiplex;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdReverseParameters     /* SEQUENCE */
+{
+    uint16 bitRate;
+uint32 bitRateLockedToPCRClock :
+    1;
+uint32 bitRateLockedToNetworkClock :
+    1;
+    struct _Multiplex multiplex;
+    /*[...]*/
+} S_CmdReverseParameters;
+typedef S_CmdReverseParameters *PS_CmdReverseParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdMultiplex     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) noMultiplex */
+    /* (NULL) transportStream */
+    /* (NULL) programStream */
+    /*[...]*/
+} S_CmdMultiplex;
+typedef S_CmdMultiplex *PS_CmdMultiplex;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdAal     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _CmdAal1 *cmdAal1;
+        struct _CmdAal5 *cmdAal5;
+        /*[...]*/
+    };
+} S_CmdAal;
+typedef S_CmdAal *PS_CmdAal;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NewATMVCCommand     /* SEQUENCE */
+{
+    uint16 resourceID;
+    uint16 bitRate;
+uint32 bitRateLockedToPCRClock :
+    1;
+uint32 bitRateLockedToNetworkClock :
+    1;
+    struct _CmdAal cmdAal;
+    struct _CmdMultiplex cmdMultiplex;
+    struct _CmdReverseParameters cmdReverseParameters;
+    /*[...]*/
+} S_NewATMVCCommand;
+typedef S_NewATMVCCommand *PS_NewATMVCCommand;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdAal5     /* SEQUENCE */
+{
+    uint16 forwardMaximumSDUSize;
+    uint16 backwardMaximumSDUSize;
+    /*[...]*/
+} S_CmdAal5;
+typedef S_CmdAal5 *PS_CmdAal5;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdErrorCorrection     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) nullErrorCorrection */
+    /* (NULL) longInterleaver */
+    /* (NULL) shortInterleaver */
+    /* (NULL) errorCorrectionOnly */
+    /*[...]*/
+} S_CmdErrorCorrection;
+typedef S_CmdErrorCorrection *PS_CmdErrorCorrection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdClockRecovery     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) nullClockRecovery */
+    /* (NULL) srtsClockRecovery */
+    /* (NULL) adaptiveClockRecovery */
+    /*[...]*/
+} S_CmdClockRecovery;
+typedef S_CmdClockRecovery *PS_CmdClockRecovery;
+
+/*-------------------------------------------------------*/
+
+typedef struct _CmdAal1     /* SEQUENCE */
+{
+    struct _CmdClockRecovery cmdClockRecovery;
+    struct _CmdErrorCorrection cmdErrorCorrection;
+uint32 structuredDataTransfer :
+    1;
+uint32 partiallyFilledCells :
+    1;
+    /*[...]*/
+} S_CmdAal1;
+typedef S_CmdAal1 *PS_CmdAal1;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FunctionNotUnderstood     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _RequestMessage *request;
+        struct _ResponseMessage *response;
+        struct _CommandMessage *command;
+    };
+} S_FunctionNotUnderstood;
+typedef S_FunctionNotUnderstood *PS_FunctionNotUnderstood;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FnsCause     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) syntaxError */
+    /* (NULL) semanticError */
+    /* (NULL) unknownFunction */
+    /*[...]*/
+} S_FnsCause;
+typedef S_FnsCause *PS_FnsCause;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FunctionNotSupported     /* SEQUENCE */
+{
+uint32 option_of_returnedFunction :
+    1;
+    struct _FnsCause fnsCause;
+    S_OCTETSTRING returnedFunction;
+    /*[...]*/
+} S_FunctionNotSupported;
+typedef S_FunctionNotSupported *PS_FunctionNotSupported;
+
+/*-------------------------------------------------------*/
+
+typedef struct _ConferenceIndication     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint8 sbeNumber;
+        struct _TerminalLabel *terminalNumberAssign;
+        struct _TerminalLabel *terminalJoinedConference;
+        struct _TerminalLabel *terminalLeftConference;
+        /* (NULL) seenByAtLeastOneOther */
+        /* (NULL) cancelSeenByAtLeastOneOther */
+        /* (NULL) seenByAll */
+        /* (NULL) cancelSeenByAll */
+        struct _TerminalLabel *terminalYouAreSeeing;
+        /* (NULL) requestForFloor */
+        /*[...]*/
+        /* (NULL) withdrawChairToken */
+        struct _TerminalLabel *floorRequested;
+        struct _TerminalYouAreSeeingInSubPictureNumber *terminalYouAreSeeingInSubPictureNumber;
+        struct _VideoIndicateCompose *videoIndicateCompose;
+    };
+} S_ConferenceIndication;
+typedef S_ConferenceIndication *PS_ConferenceIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _TerminalYouAreSeeingInSubPictureNumber     /* SEQUENCE */
+{
+    uint8 terminalNumber;
+    uint8 subPictureNumber;
+    /*[...]*/
+} S_TerminalYouAreSeeingInSubPictureNumber;
+typedef S_TerminalYouAreSeeingInSubPictureNumber *PS_TerminalYouAreSeeingInSubPictureNumber;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoIndicateCompose     /* SEQUENCE */
+{
+    uint8 compositionNumber;
+    /*[...]*/
+} S_VideoIndicateCompose;
+typedef S_VideoIndicateCompose *PS_VideoIndicateCompose;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MiType     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        /* (NULL) logicalChannelActive */
+        /* (NULL) logicalChannelInactive */
+        /* (NULL) multipointConference */
+        /* (NULL) cancelMultipointConference */
+        /* (NULL) multipointZeroComm */
+        /* (NULL) cancelMultipointZeroComm */
+        /* (NULL) multipointSecondaryStatus */
+        /* (NULL) cancelMultipointSecondaryStatus */
+        /* (NULL) videoIndicateReadyToActivate */
+        uint8 videoTemporalSpatialTradeOff;
+        /*[...]*/
+        struct _VideoNotDecodedMBs *videoNotDecodedMBs;
+        struct _TransportCapability *transportCapability;
+    };
+} S_MiType;
+typedef S_MiType *PS_MiType;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MiscellaneousIndication     /* SEQUENCE */
+{
+    uint16 logicalChannelNumber;
+    struct _MiType miType;
+    /*[...]*/
+} S_MiscellaneousIndication;
+typedef S_MiscellaneousIndication *PS_MiscellaneousIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VideoNotDecodedMBs     /* SEQUENCE */
+{
+    uint16 firstMB;
+    uint16 numberOfMBs;
+    uint8 temporalReference;
+    /*[...]*/
+} S_VideoNotDecodedMBs;
+typedef S_VideoNotDecodedMBs *PS_VideoNotDecodedMBs;
+
+/*-------------------------------------------------------*/
+
+typedef struct _JiScope     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 logicalChannelNumber;
+        uint16 resourceID;
+        /* (NULL) wholeMultiplex */
+    };
+} S_JiScope;
+typedef S_JiScope *PS_JiScope;
+
+/*-------------------------------------------------------*/
+
+typedef struct _JitterIndication     /* SEQUENCE */
+{
+uint32 option_of_skippedFrameCount :
+    1;
+uint32 option_of_additionalDecoderBuffer :
+    1;
+    struct _JiScope jiScope;
+    uint8 estimatedReceivedJitterMantissa;
+    uint8 estimatedReceivedJitterExponent;
+    uint8 skippedFrameCount;
+    uint32 additionalDecoderBuffer;
+    /*[...]*/
+} S_JitterIndication;
+typedef S_JitterIndication *PS_JitterIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H223SkewIndication     /* SEQUENCE */
+{
+    uint16 logicalChannelNumber1;
+    uint16 logicalChannelNumber2;
+    uint16 skew;
+    /*[...]*/
+} S_H223SkewIndication;
+typedef S_H223SkewIndication *PS_H223SkewIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _H2250MaximumSkewIndication     /* SEQUENCE */
+{
+    uint16 logicalChannelNumber1;
+    uint16 logicalChannelNumber2;
+    uint16 maximumSkew;
+    /*[...]*/
+} S_H2250MaximumSkewIndication;
+typedef S_H2250MaximumSkewIndication *PS_H2250MaximumSkewIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _MCLocationIndication     /* SEQUENCE */
+{
+    struct _TransportAddress signalAddress;
+    /*[...]*/
+} S_MCLocationIndication;
+typedef S_MCLocationIndication *PS_MCLocationIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _VendorIdentification     /* SEQUENCE */
+{
+uint32 option_of_productNumber :
+    1;
+uint32 option_of_versionNumber :
+    1;
+    struct _NonStandardIdentifier vendor;
+    S_OCTETSTRING productNumber;
+    S_OCTETSTRING versionNumber;
+    /*[...]*/
+} S_VendorIdentification;
+typedef S_VendorIdentification *PS_VendorIdentification;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IrpMultiplex     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) noMultiplex */
+    /* (NULL) transportStream */
+    /* (NULL) programStream */
+    /*[...]*/
+} S_IrpMultiplex;
+typedef S_IrpMultiplex *PS_IrpMultiplex;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndReverseParameters     /* SEQUENCE */
+{
+    uint16 bitRate;
+uint32 bitRateLockedToPCRClock :
+    1;
+uint32 bitRateLockedToNetworkClock :
+    1;
+    struct _IrpMultiplex irpMultiplex;
+    /*[...]*/
+} S_IndReverseParameters;
+typedef S_IndReverseParameters *PS_IndReverseParameters;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndMultiplex     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) noMultiplex */
+    /* (NULL) transportStream */
+    /* (NULL) programStream */
+    /*[...]*/
+} S_IndMultiplex;
+typedef S_IndMultiplex *PS_IndMultiplex;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndAal     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _IndAal1 *indAal1;
+        struct _IndAal5 *indAal5;
+        /*[...]*/
+    };
+} S_IndAal;
+typedef S_IndAal *PS_IndAal;
+
+/*-------------------------------------------------------*/
+
+typedef struct _NewATMVCIndication     /* SEQUENCE */
+{
+    uint16 resourceID;
+    uint16 bitRate;
+uint32 bitRateLockedToPCRClock :
+    1;
+uint32 bitRateLockedToNetworkClock :
+    1;
+    struct _IndAal indAal;
+    struct _IndMultiplex indMultiplex;
+    /*[...]*/
+uint32 option_of_indReverseParameters :
+    1;
+    struct _IndReverseParameters indReverseParameters;
+} S_NewATMVCIndication;
+typedef S_NewATMVCIndication *PS_NewATMVCIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndAal5     /* SEQUENCE */
+{
+    uint16 forwardMaximumSDUSize;
+    uint16 backwardMaximumSDUSize;
+    /*[...]*/
+} S_IndAal5;
+typedef S_IndAal5 *PS_IndAal5;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndErrorCorrection     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) nullErrorCorrection */
+    /* (NULL) longInterleaver */
+    /* (NULL) shortInterleaver */
+    /* (NULL) errorCorrectionOnly */
+    /*[...]*/
+} S_IndErrorCorrection;
+typedef S_IndErrorCorrection *PS_IndErrorCorrection;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndClockRecovery     /* CHOICE */
+{
+    uint16 index;
+    /* (NULL) nullClockRecovery */
+    /* (NULL) srtsClockRecovery */
+    /* (NULL) adaptiveClockRecovery */
+    /*[...]*/
+} S_IndClockRecovery;
+typedef S_IndClockRecovery *PS_IndClockRecovery;
+
+/*-------------------------------------------------------*/
+
+typedef struct _IndAal1     /* SEQUENCE */
+{
+    struct _IndClockRecovery indClockRecovery;
+    struct _IndErrorCorrection indErrorCorrection;
+uint32 structuredDataTransfer :
+    1;
+uint32 partiallyFilledCells :
+    1;
+    /*[...]*/
+} S_IndAal1;
+typedef S_IndAal1 *PS_IndAal1;
+
+/*-------------------------------------------------------*/
+
+typedef struct _UserInputIndication     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        PS_int8STRING alphanumeric;
+        /*[...]*/
+        struct _UserInputSupportIndication *userInputSupportIndication;
+        struct _Signal *signal;
+        struct _SignalUpdate *signalUpdate;
+    };
+} S_UserInputIndication;
+typedef S_UserInputIndication *PS_UserInputIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Rtp     /* SEQUENCE */
+{
+    uint16 logicalChannelNumber;
+    /*[...]*/
+} S_Rtp;
+typedef S_Rtp *PS_Rtp;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SignalUpdate     /* SEQUENCE */
+{
+uint32 option_of_rtp :
+    1;
+    uint16 duration;
+    struct _Rtp rtp;
+    /*[...]*/
+} S_SignalUpdate;
+typedef S_SignalUpdate *PS_SignalUpdate;
+
+/*-------------------------------------------------------*/
+
+typedef struct _SignalRtp     /* SEQUENCE */
+{
+uint32 option_of_timestamp :
+    1;
+uint32 option_of_expirationTime :
+    1;
+    uint32 timestamp;
+    uint32 expirationTime;
+    uint16 logicalChannelNumber;
+    /*[...]*/
+} S_SignalRtp;
+typedef S_SignalRtp *PS_SignalRtp;
+
+/*-------------------------------------------------------*/
+
+typedef struct _Signal     /* SEQUENCE */
+{
+uint32 option_of_duration :
+    1;
+uint32 option_of_signalRtp :
+    1;
+    S_int8STRING signalType;
+    uint16 duration;
+    struct _SignalRtp signalRtp;
+    /*[...]*/
+} S_Signal;
+typedef S_Signal *PS_Signal;
+
+/*-------------------------------------------------------*/
+
+typedef struct _UserInputSupportIndication     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        struct _NonStandardParameter *nonStandard;
+        /* (NULL) basicString */
+        /* (NULL) iA5String */
+        /* (NULL) generalString */
+        /*[...]*/
+    };
+} S_UserInputSupportIndication;
+typedef S_UserInputSupportIndication *PS_UserInputSupportIndication;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FciRestriction     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint32 maximumBitRate;
+        /* (NULL) noRestriction */
+    };
+} S_FciRestriction;
+typedef S_FciRestriction *PS_FciRestriction;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FciScope     /* CHOICE */
+{
+    uint16 index;
+    union
+    {
+        uint16 logicalChannelNumber;
+        uint16 resourceID;
+        /* (NULL) wholeMultiplex */
+    };
+} S_FciScope;
+typedef S_FciScope *PS_FciScope;
+
+/*-------------------------------------------------------*/
+
+typedef struct _FlowControlIndication     /* SEQUENCE */
+{
+    struct _FciScope fciScope;
+    struct _FciRestriction fciRestriction;
+    /*[...]*/
+} S_FlowControlIndication;
+typedef S_FlowControlIndication *PS_FlowControlIndication;
+
+/*-------------------------------------------------------*/
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245inf.h b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245inf.h
new file mode 100644
index 0000000..1acca1b
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245inf.h
@@ -0,0 +1,311 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : H245Inf.h                                            */
+/*  file contents   : H.245 Interface Information Definition                  */
+/*  draw            : '96.10.04                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _H245INF_
+#define _H245INF_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "control_msg_hdr.h"
+
+/************************************************************************/
+/*  Interface Information Type Definition                               */
+/************************************************************************/
+#define     H245_USER           0       /* H.245 User Information */
+#define     H245_PRIMITIVE      1       /* H.245 Primitive Information */
+#define     H245_ERROR          2       /* H.245 Error Information */
+#define     H245_TIMEOUT        3       /* H.245 Timeout Information */
+
+
+/************************************************************************/
+/*  Interface Information Id Definition: User Operation Id              */
+/************************************************************************/
+typedef enum _userreportid
+{
+//    E_User_Ce_Req_Idc ,             /* ( 0) Capability exchange Request Indication        */
+//    E_User_Ce_Rjt_Idc ,             /* ( 1) Capability exchange Reject Indication         */
+//    E_User_Msd_Rjt_Idc ,            /* ( 2) Master slave determination Reject Indication  */
+//    E_User_Msd_Err_Idc ,            /* ( 3) Master slave determination Error Indication   */
+    E_User_Lc_Req_Idc = 4 ,           /* ( 4) Uni-directional Logical Channel signalling Request Indication */
+    E_User_Lc_Rls_Idc ,             /* ( 5) Uni-directional Logical Channel signalling Release Indication */
+    E_User_Lc_Err_Idc ,             /* ( 6) Uni-directional Logical Channel signalling Error Indication   */
+    E_User_Lc_RlsCfm_Idc ,          /* ( 7) Uni-directional Logical Channel signalling RlsCfm Indication  */
+    E_User_Blc_Req_Idc ,            /* ( 8) Bi-directional Logical Channel signalling Request Indication */
+    E_User_Blc_Rls_Idc ,            /* ( 9) Bi-directional Logical Channel signalling Release Indication */
+    E_User_Blc_Err_Idc ,            /* (10) Bi-directional Logical Channel signalling Error Indication   */
+    E_User_Blc_RlsCfm_Idc ,         /* (11) Bi-directional Logical Channel signalling RlsCfm Indication  */
+    E_User_Clc_Req_Idc ,            /* (12) Close Logical Channel Request Indication      */
+    E_User_Clc_Rjt_Idc ,            /* (13) Close Logical Channel Reject Indication       */
+    E_User_Mt_Req_Idc ,             /* (14) H.223 Multiplex Table Request Indication      */
+    E_User_Mt_Rjt_Idc ,             /* (15) H.223 Multiplex Table Reject Indication       */
+    E_User_Rme_Req_Idc ,            /* (16) Request Multiplex Entry Request Indication */
+    E_User_Rme_Rjt_Idc ,            /* (17) Request Multiplex Entry Reject Indication  */
+    E_User_Mr_Req_Idc ,             /* (18) Mode request Request Indication */
+    E_User_Mr_Rjt_Idc ,             /* (19) Mode request Reject Indication  */
+    E_User_Rtd_Rjt_Idc ,            /* (20) Round trip delay Reject Indication */
+    E_User_Ml_Req_Idc ,             /* (21) Maintenance Loop Request Indication */
+    E_User_Ml_Rjt_Idc ,             /* (22) Maintenance Loop Reject Indication  */
+    E_User_Ml_Err_Idc ,             /* (23) Maintenance Loop Error Indication  */
+    E_User_CSUP_Done				/* (24) Call Setup Done Signal (WWU)		*/
+} ENUM_UserReportId ;
+
+
+typedef enum _useroperationid
+{
+//    E_User_Ce_Instruct ,            /* ( 0) Capability exchange     */
+    E_User_Mt_Instruct = 1 ,          /* ( 1) H.223 Multiplex Table   */
+    E_User_Rme_Instruct ,           /* ( 2) Request Multiplex Entry */
+    E_User_Mr_Instruct ,            /* ( 3) Mode Request            */
+    E_User_Rtd_Instruct ,           /* ( 4) Round trip delay        */
+    E_User_Ml_Instruct ,            /* ( 5) Maintenance Loop        */
+
+    E_User_Connect ,                /* ( 6) Connect to Remote       */
+    E_User_Open ,                   /* ( 7) Session Open            */
+    E_User_Consent ,                /* ( 8) Concent                 */
+    E_User_Reject ,                 /* ( 9) Reject                  */
+    E_User_Retry ,                  /* (10) Retry                   */
+    E_User_Close ,                  /* (11) Session Close           */
+    E_User_Disconnect ,             /* (12) Disconnect              */
+
+    E_User_NonProcedure,            /* (13) Non Procedure           */
+    E_User_TestButton,              /* (14) Test Button (RAN TB)    */
+
+    E_User_Stcs_Instruct,           /* (15) Send Terminal Cap Set  (RAN) */
+    E_User_Hmr_Instruct,            /* (16) H223Multiplex Reconfig (RAN) */
+    E_User_Rcc_Instruct,            /* (17) RequestChannelClose    (RAN) */
+    E_User_Clc_Instruct             /* (18) CloseLogicalChannel    (RAN) */
+} ENUM_UserOperationId ;
+
+
+/************************************************************************/
+/*  Interface Information Id Definition: Primitive Id                   */
+/************************************************************************/
+typedef enum _primitiveid
+{
+    /* Request primitive */
+
+//    E_PtvId_Msd_Dtm_Req ,           /* (  0) DETERMINE.request ( MSD ) */
+//    E_PtvId_Ce_Trf_Req ,            /* (  1) TRANSFER.request ( CE ) */
+//    E_PtvId_Ce_Rjt_Req ,            /* (  2) REJECT.request ( CE ) */
+    E_PtvId_Lc_Etb_Req = 3 ,          /* (  3) ESTABLISH.request ( LC ) */
+    E_PtvId_Lc_Rls_Req ,            /* (  4) RELEASE.request ( LC ) */
+    E_PtvId_Blc_Etb_Req ,           /* (  5) ESTABLISH.request ( B-LC ) */
+    E_PtvId_Blc_Rls_Req ,           /* (  6) RELEASE.request ( B-LC ) */
+    E_PtvId_Clc_Cls_Req ,           /* (  7) CLOSE.request ( CLC ) */
+    E_PtvId_Clc_Rjt_Req ,           /* (  8) REJECT.request ( CLC ) */
+    E_PtvId_Mt_Trf_Req ,            /* (  9) TRANSFER.request ( MT ) */
+    E_PtvId_Mt_Rjt_Req ,            /* ( 10) REJECT.request ( MT ) */
+    E_PtvId_Rme_Send_Req ,          /* ( 11) SEND.request ( RME ) */
+    E_PtvId_Rme_Rjt_Req ,           /* ( 12) REJECT.request ( RME ) */
+    E_PtvId_Mr_Trf_Req ,            /* ( 13) TRANSFER.request ( MR ) */
+    E_PtvId_Mr_Rjt_Req ,            /* ( 14) REJECT.request ( MR ) */
+    E_PtvId_Rtd_Trf_Req ,           /* ( 15) TRANSFER.request ( RTD ) */
+    E_PtvId_Ml_Loop_Req ,           /* ( 16) LOOP.request ( ML ) */
+    E_PtvId_Ml_Rls_Req ,            /* ( 17) RELEASE.request ( ML ) */
+
+    /* Indication primitive */
+
+//    E_PtvId_Msd_Dtm_Idc ,           /* ( 18) DETERMINE.indication ( MSD ) */
+//    E_PtvId_Msd_Rjt_Idc ,           /* ( 19) REJECT.indication ( MSD ) */
+//    E_PtvId_Msd_Err_Idc ,           /* ( 20) ERROR.indication ( MSD ) */
+//    E_PtvId_Ce_Trf_Idc ,            /* ( 21) TRANSFER.indication ( CE ) */
+//    E_PtvId_Ce_Rjt_Idc ,            /* ( 22) REJECT.indication ( CE ) */
+    E_PtvId_Lc_Etb_Idc = 23 ,          /* ( 23) ESTABLISH.indication ( LC ) */
+    E_PtvId_Lc_Rls_Idc ,            /* ( 24) RELEASE.indication ( LC ) */
+    E_PtvId_Lc_Err_Idc ,            /* ( 25) ERROR.indication ( LC ) */
+    E_PtvId_Blc_Etb_Idc ,           /* ( 26) ESTABLISH.indication ( B-LC ) */
+    E_PtvId_Blc_Rls_Idc ,           /* ( 27) RELEASE.indication ( B-LC ) */
+    E_PtvId_Blc_Err_Idc ,           /* ( 28) ERROR.indication ( B-LC ) */
+    E_PtvId_Clc_Cls_Idc ,           /* ( 29) CLOSE.indication ( CLC ) */
+    E_PtvId_Clc_Rjt_Idc ,           /* ( 30) REJECT.indication ( CLC ) */
+    E_PtvId_Mt_Trf_Idc ,            /* ( 31) TRANSFER.indication ( MT ) */
+    E_PtvId_Mt_Rjt_Idc ,            /* ( 32) REJECT.indication ( MT ) */
+    E_PtvId_Rme_Send_Idc ,          /* ( 33) SEND.indication ( RME ) */
+    E_PtvId_Rme_Rjt_Idc ,           /* ( 34) REJECT.indication ( RME ) */
+    E_PtvId_Mr_Trf_Idc ,            /* ( 35) TRANSFER.indication ( MR ) */
+    E_PtvId_Mr_Rjt_Idc ,            /* ( 36) REJECT.indication ( MR ) */
+    E_PtvId_Rtd_Exp_Idc ,           /* ( 37) EXPIRY.indication ( RTD ) */
+    E_PtvId_Ml_Loop_Idc ,           /* ( 38) LOOP.indication ( ML ) */
+    E_PtvId_Ml_Rls_Idc ,            /* ( 39) RELEASE.indication ( ML ) */
+    E_PtvId_Ml_Err_Idc ,            /* ( 40) ERROR.indication ( ML ) */
+
+    /* Response primitive */
+
+    E_PtvId_Ce_Trf_Rps ,            /* ( 41) TRANSFER.response ( CE ) */
+    E_PtvId_Lc_Etb_Rps ,            /* ( 42) ESTABLISH.response ( LC ) */
+    E_PtvId_Blc_Etb_Rps ,           /* ( 43) ESTABLISH.response ( B-LC ) */
+    E_PtvId_Clc_Cls_Rps ,           /* ( 44) CLOSE.response ( CLC ) */
+    E_PtvId_Mt_Trf_Rps ,            /* ( 45) TRANSFER.response ( MT ) */
+    E_PtvId_Rme_Send_Rps ,          /* ( 46) SEND.response ( RME ) */
+    E_PtvId_Mr_Trf_Rps ,            /* ( 47) TRANSFER.response ( MR ) */
+    E_PtvId_Ml_Loop_Rps ,           /* ( 48) LOOP.response ( ML ) */
+
+    /* Confirm primitive */
+
+    E_PtvId_Msd_Dtm_Cfm ,           /* ( 49) DETERMINE.confirm ( MSD ) */
+    E_PtvId_Ce_Trf_Cfm ,            /* ( 50) TRANSFER.confirm ( CE ) */
+    E_PtvId_Lc_Etb_Cfm ,            /* ( 51) ESTABLISH.confirm ( LC ) */
+    E_PtvId_Lc_Rls_Cfm ,            /* ( 52) RELEASE.confirm ( LC ) */
+    E_PtvId_Blc_Etb_Cfm ,           /* ( 53) ESTABLISH.confirm ( BLC ) */
+    E_PtvId_Blc_Etb_Cfm2,			/* WWU_BLC */
+    E_PtvId_Blc_Rls_Cfm ,           /* ( 54) RELEASE.confirm ( BLC ) */
+    E_PtvId_Clc_Cls_Cfm ,           /* ( 55) CLOSE.confirm ( CLC ) */
+    E_PtvId_Mt_Trf_Cfm ,            /* ( 56) TRANSFER.confirm ( MT ) */
+    E_PtvId_Rme_Send_Cfm ,          /* ( 57) SEND.confirm ( RME ) */
+    E_PtvId_Mr_Trf_Cfm ,            /* ( 58) TRANSFER.confirm ( MR ) */
+    E_PtvId_Rtd_Trf_Cfm ,           /* ( 59) TRANSFER.confirm ( RTD ) */
+    E_PtvId_Ml_Loop_Cfm ,           /* ( 60) LOOP.confirm ( ML ) */
+
+    /* Other primitive */
+    E_PtvId_Nsd_Req ,               /* ( 61) NONSTANDARDMESSAGE_REQUEST ( NSD ) */
+    E_PtvId_Nsd_Req_Cfm ,           /* ( 62) NONSTANDARDMESSAGE_REQUEST.confirm ( NSD ) */
+    E_PtvId_Nsd_Rps ,               /* ( 63) NONSTANDARDMESSAGE_RESPONSE ( NSD ) */
+    E_PtvId_Nsd_Rps_Cfm ,           /* ( 64) NONSTANDARDMESSAGE_RESPONSE.confirm ( NSD ) */
+    E_PtvId_Nsd_Cmd ,               /* ( 65) NONSTANDARDMESSAGE_COMMAND ( NSD ) */
+    E_PtvId_Nsd_Cmd_Cfm ,           /* ( 66) NONSTANDARDMESSAGE_COMMAND.confirm ( NSD ) */
+    E_PtvId_Nsd_Idc ,               /* ( 67) NONSTANDARDMESSAGE_INDICATION ( NSD ) */
+    E_PtvId_Nsd_Idc_Cfm ,           /* ( 68) NONSTANDARDMESSAGE_INDICATION.confirm ( NSD ) */
+
+    E_PtvId_Cm_Req ,                /* ( 69) COMMUNICATIONMODE_REQUEST ( CM ) */
+    E_PtvId_Cm_Req_Cfm ,            /* ( 70) COMMUNICATIONMODE_REQUEST.confirm ( CM ) */
+    E_PtvId_Cm_Rps ,                /* ( 71) COMMUNICATIONMODE_RESPONSE ( CM ) */
+    E_PtvId_Cm_Rps_Cfm ,            /* ( 72) COMMUNICATIONMODE_RESPONSE.confirm ( CM ) */
+    E_PtvId_Cm_Cmd ,                /* ( 73) COMMUNICATIONMODE_COMMAND ( CM ) */
+    E_PtvId_Cm_Cmd_Cfm ,            /* ( 74) COMMUNICATIONMODE_COMMAND.confirm ( CM ) */
+
+    E_PtvId_H223aar ,               /* ( 75) H223ANNEXARECONFIGURATION ( H223AAR ) */
+    E_PtvId_H223aar_Cfm ,           /* ( 76) H223ANNEXARECONFIGURATION.confirm ( H223AAR ) */
+    E_PtvId_H223aar_Ack ,           /* ( 77) H223ANNEXARECONFIGURATION_ACK ( H223AAR ) */
+    E_PtvId_H223aar_Ack_Cfm ,       /* ( 78) H223ANNEXARECONFIGURATION_ACK.confirm ( H223AAR ) */
+    E_PtvId_H223aar_Rjt ,           /* ( 79) H223ANNEXARECONFIGURATION_REJECT ( H223AAR ) */
+    E_PtvId_H223aar_Rjt_Cfm ,       /* ( 80) H223ANNEXARECONFIGURATION_REJECT.confirm ( H223AAR ) */
+
+    E_PtvId_Cnf_Req ,               /* ( 81) CONFERENCE_REQUEST ( CNF ) */
+    E_PtvId_Cnf_Req_Cfm ,           /* ( 82) CONFERENCE_REQUEST.confirm ( CNF ) */
+    E_PtvId_Cnf_Rps ,               /* ( 83) CONFERENCE_RESPONSE ( CNF ) */
+    E_PtvId_Cnf_Rps_Cfm ,           /* ( 84) CONFERENCE_RESPONSE.confirm ( CNF ) */
+
+    E_PtvId_Cmd_Stcs ,              /* ( 85) SENDTERMINALCAPABILITYSET ( CMD ) */
+    E_PtvId_Cmd_Stcs_Cfm ,          /* ( 86) SENDTERMINALCAPABILITYSET.confirm ( CMD ) */
+    E_PtvId_Cmd_Ecrpt ,             /* ( 87) ENCRYPTIONCOMMAND ( CMD ) */
+    E_PtvId_Cmd_Ecrpt_Cfm ,         /* ( 88) ENCRYPTIONCOMMAND.confirm ( CMD ) */
+    E_PtvId_Cmd_Fc ,                /* ( 89) FLOWCONTROLCOMMAND ( CMD ) */
+    E_PtvId_Cmd_Fc_Cfm ,            /* ( 90) FLOWCONTROLCOMMAND.confirm ( CMD ) */
+    E_PtvId_Cmd_Es ,                /* ( 91) ENDSESSIONCOMMAND ( CMD ) */
+    E_PtvId_Cmd_Es_Cfm ,            /* ( 92) ENDSESSIONCOMMAND.confirm ( CMD ) */
+    E_PtvId_Cmd_Mscl ,              /* ( 93) MISCELLANEOUSCOMMAND ( CMD ) */
+    E_PtvId_Cmd_Mscl_Cfm ,          /* ( 94) MISCELLANEOUSCOMMAND.confirm ( CMD ) */
+    E_PtvId_Cmd_Cnf ,               /* ( 95) CONFERENCECOMMAND ( CMD ) */
+    E_PtvId_Cmd_Cnf_Cfm ,           /* ( 96) CONFERENCECOMMAND.confirm ( CMD ) */
+
+    E_PtvId_Idc_Fnu ,               /* ( 97) FUNCTIONNOTUNDERSTOOD ( IDC ) */
+    E_PtvId_Idc_Fnu_Cfm ,           /* ( 98) FUNCTIONNOTUNDERSTOOD.confirm ( IDC ) */
+    E_PtvId_Idc_Mscl ,              /* ( 99) MISCELLANEOUSINDICATION ( IDC ) */
+    E_PtvId_Idc_Mscl_Cfm ,          /* (100) MISCELLANEOUSINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Jtr ,               /* (101) JITTERINDICATION ( IDC ) */
+    E_PtvId_Idc_Jtr_Cfm ,           /* (102) JITTERINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_H223skw ,           /* (103) H223SKEWINDICATION ( IDC ) */
+    E_PtvId_Idc_H223skw_Cfm ,       /* (104) H223SKEWINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Nwatmvc ,           /* (105) NEWATMVCINDICATION ( IDC ) */
+    E_PtvId_Idc_Nwatmvc_Cfm ,       /* (106) NEWATMVCINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Ui ,                /* (107) USERINPUTINDICATION ( IDC ) */
+    E_PtvId_Idc_Ui_Cfm ,            /* (108) USERINPUTINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Cnf ,               /* (109) CONFERENCEINDICATION ( IDC ) */
+    E_PtvId_Idc_Cnf_Cfm ,           /* (110) CONFERENCEINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_H2250mxskw ,        /* (111) H2250MAXIMUMSKEWINDICATION ( IDC ) */
+    E_PtvId_Idc_H2250mxskw_Cfm ,    /* (112) H2250MAXIMUMSKEWINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Mclct ,             /* (113) MCLOCATIONINDICATION ( IDC ) */
+    E_PtvId_Idc_Mclct_Cfm ,         /* (114) MCLOCATIONINDICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Vi ,                /* (115) VENDORIDENTIFICATION ( IDC ) */
+    E_PtvId_Idc_Vi_Cfm ,            /* (116) VENDORIDENTIFICATION.confirm ( IDC ) */
+    E_PtvId_Idc_Fns ,               /* (117) FUNCTIONNOTSUPPORTED ( IDC ) */
+    E_PtvId_Idc_Fns_Cfm,            /* (118) FUNCTIONNOTSUPPORTED.confirm ( IDC ) */
+    E_PtvId_Idc_Fc,                 /* (119) FLOWCONTROL( IDC ) */
+    E_PtvId_Idc_Fc_Cfm,            /* (120) FLOWCONTROL.confirm ( IDC ) */
+
+    /* Additional events (RAN) */
+    /* (NOTE: above numbers are off by 1) */
+    E_PtvId_Cmd_Hmr ,              /* (120) H223MultiplexReconfiguration ( CMD ) */
+    E_PtvId_Cmd_Hmr_Cfm            /* (121) H223MultiplexReconfiguration.confirm ( CMD ) */
+} ENUM_PrimitiveId ;
+
+/************************************************************************/
+/*  Interface Information Id Definition:                                */
+/*                                     Internal Error Occurence Routine */
+/************************************************************************/
+#define     H245_INTERNAL_ERROR_TSC         0       /* Occur in Terminal Status Control Routine */
+#define     H245_INTERNAL_ERROR_SE          1       /* Occur in Control Entity Routine ( Signalling Entity ) */
+#define     H245_INTERNAL_ERROR_SRP         2       /* Occur in Simple Retransmission Protocol Routine */
+
+
+/************************************************************************/
+/*  Interface Information Id Definition: Timer Id                       */
+/************************************************************************/
+typedef enum _timerid
+{
+    E_TmrId_Msd_T106 ,              /* ( 0) Master Slave Determination */
+    E_TmrId_Ce_T101 ,               /* ( 1) Capability Exchange */
+    E_TmrId_LcBlc_T103 ,            /* ( 2) Uni-Directional and Bi-Directional Logical Channel Signalling */
+    E_TmrId_Clc_T108 ,              /* ( 3) Close Logical Channel */
+    E_TmrId_Mt_T104 ,               /* ( 4) Multiplex Table */
+    E_TmrId_Rme_T107 ,              /* ( 5) Request Multiplex Entry */
+    E_TmrId_Mr_T109 ,               /* ( 6) Mode Request */
+    E_TmrId_Rtd_T105 ,              /* ( 7) Round Trip Delay */
+    E_TmrId_Ml_T102                 /* ( 8) Maintenance Loop */
+} ENUM_TimerId ;
+
+
+/************************************************************************/
+/*  Interface Information Structure Type Definitions                    */
+/************************************************************************/
+typedef S_ControlMsgHeader S_InfHeader;
+typedef PS_ControlMsgHeader PS_InfHeader;
+
+typedef struct
+{
+    uint32 iT101; /* Capability Exchange */
+    uint32 iT103; /* OLC/OBLC */
+    uint32 iT104; /* MT */
+    uint32 iT105; /* RTD */
+    uint32 iT106; /* MSD */
+    uint32 iT107; /* RME */
+    uint32 iT108; /* CLC */
+    uint32 iT109; /* MR */
+}H245TimerValues;
+
+#endif /* _H245INF_ */
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245msg.h b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245msg.h
new file mode 100644
index 0000000..bc53797
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245msg.h
@@ -0,0 +1,51 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name		:H245Msg.h					*/
+/*  file contents	:H245 Message I/F Definition Header		*/
+/*  draw		:'96.11.15					*/
+/*----------------------------------------------------------------------*/
+/*  amendment		:						*/
+/*		Copyright (C) 1996 NTT DoCoMo     			*/
+/************************************************************************/
+#ifndef _H245MSG_H_
+#define _H245MSG_H_
+
+#include "oscl_base.h"
+/****************************************/
+/* H245 Message Interface Structure	    */
+/****************************************/
+typedef struct _h245Msg
+{
+    uint8	Type1;				    /* Message Type	*/
+    uint8	Type2;				    /* Message Number */
+    uint8*	pData;				    /* Real Data Pointer */
+}S_H245Msg;
+typedef S_H245Msg	    *PS_H245Msg;
+
+#endif /* H245MSG */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245pri.h b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245pri.h
new file mode 100644
index 0000000..9da3095
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/cmn/include/h245pri.h
@@ -0,0 +1,239 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : H245Pri.h                                         */
+/*  file contents        : Primitive Infomation Header                       */
+/*  draw                 : '96.11.28                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#ifndef _H245PRI_
+#define _H245PRI_
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "oscl_base.h"
+#include	"oscl_mem.h"
+#include    "h245def.h"
+
+
+/************************************************************************/
+/*  Common Value Definition: Error Code Value                           */
+/************************************************************************/
+typedef enum _enum_errcode
+{
+    ErrCode_Msd_A = 0,  /* ( 0) no response from remote MSDSE ( Local Timer T106 Expiry ) */
+    ErrCode_Msd_B ,     /* ( 1) remote sees no response from local MSDSE ( Remort Timer T106 Expiry ) */
+    ErrCode_Msd_C ,     /* ( 2) inappropriate message ( MasterSlaveDetermination ) */
+    ErrCode_Msd_D ,     /* ( 3) inappropriate message ( MasterSlaveDeterminationReject ) */
+    ErrCode_Msd_E ,     /* ( 4) inconsistent field value ( MasterSlaveDeterminationAck.decision != sv_STATUS ) */
+    ErrCode_Msd_F ,     /* ( 5) maximum number of retries ( sv_NCOUNT == N100 ) */
+
+    /* Outgoing LCSE */
+
+    ErrCode_Lc_A ,      /* ( 6) inappropriate message ( OpenLogicalChannelAck ) */
+    ErrCode_Lc_B ,      /* ( 7) inappropriate message ( OpenLogicalChannelReject ) */
+    ErrCode_Lc_C ,      /* ( 8) inappropriate message ( CloseLogicalChannelAck ) */
+    ErrCode_Lc_D ,      /* ( 9) no response from Peer LCSE / B-LCSE ( Timer T103 Expiry ) */
+
+    /* Outgoing B-LCSE */
+
+    ErrCode_Blc_A ,     /* ( 6) inappropriate message ( OpenLogicalChannelAck ) */
+    ErrCode_Blc_B ,     /* ( 7) inappropriate message ( OpenLogicalChannelReject ) */
+    ErrCode_Blc_C ,     /* ( 8) inappropriate message ( CloseLogicalChannelAck ) */
+    ErrCode_Blc_D ,     /* ( 9) no response from Peer LCSE / B-LCSE ( Timer T103 Expiry ) */
+
+    /* Incoming B-LCSE */
+
+    ErrCode_Blc_E ,     /* (10) inappropriate message ( OpenLogicalChannelConfirm ) */
+    ErrCode_Blc_F ,     /* (11) no response from Peer B-LCSE ( Timer T103 Expiry ) */
+
+    /* Outgoing Mlse */
+
+    ErrCode_Ml_A ,      /* (12) inappropriate message ( MaintenanceLoopAck ) */
+    ErrCode_Ml_B        /* (13) no response from Peer MLSE ( Timer T102 Expiry ) */
+} ENUM_ErrCode ;
+
+
+/************************************************************************/
+/*  Common Parameter Definition: Error Code Parameter                   */
+/************************************************************************/
+/* ERROR.indication */
+typedef struct _errcode
+{
+    ENUM_ErrCode    ErrCode ;   /* ERRORCODE Parameter */
+} S_ErrCode ;
+typedef S_ErrCode   *PS_ErrCode ;
+
+
+/************************************************************************/
+/*  Common Value Definition: Source Value                               */
+/************************************************************************/
+typedef enum _esource
+{
+    Src_USER = 0,       /* ( 0) User        CESE LCSE B-LCSE CLCSE MTSE RMESE MRSE MLSE */
+    Src_PROTOCOL ,      /* ( 1) Protocol    CESE             CLCSE MTSE RMESE MRSE      */
+    Src_LCSE ,          /* ( 2) Lcse             LCSE                                   */
+    Src_BLCSE ,         /* ( 3) Blcse                 B-LCSE                            */
+    Src_MLSE            /* ( 4) Mlse                                               MLSE */
+} ENUM_Source ;
+
+// ==========================================================
+// NOTE: The following "DoCoMo Structures" are used for
+//   communication between TSC and SE.  We eliminated many
+//   of the original ones when we integrated the new H.245
+//   PER codec, replacing them with the actual H.245 message
+//   definitions.  Here are the ones that we found advantageous
+//   to keep.  (RAN)
+// ==========================================================
+
+/************************************************************************/
+/*  Parameter Definition: H223 Multiplex Table                          */
+/************************************************************************/
+/* TRANSFER.request */
+/* TRANSFER.indication */
+typedef struct _muxdescriptor
+{
+    int32                         size_of_multiplexEntryDescriptors ;
+    /* MUX_DESCRIPTOR Parameter */
+    S_MultiplexEntryDescriptor  *multiplexEntryDescriptors ;
+} S_MuxDescriptor ;
+typedef S_MuxDescriptor     *PS_MuxDescriptor ;
+
+/* REJECT.indication */
+typedef struct _sourcecause_mt
+{
+    ENUM_Source                 Source ;                        /* SOURCE Parameter */
+    S_MeRejectCause             Cause ;                         /* CAUSE Parameter */
+} S_SourceCause_Mt ;
+typedef S_SourceCause_Mt    *PS_SourceCause_Mt ;
+
+/************************************************************************/
+/*  Parameter Definition: Capability Exchange                           */
+/************************************************************************/
+/* REJECT.indication */
+typedef struct _sourcecause_ce
+{
+    ENUM_Source             Source ;                            /* SOURCE Parameter */
+    S_TcsRejectCause        Cause ;                             /* CAUSE Parameter */
+} S_SourceCause_Ce ;
+typedef S_SourceCause_Ce        *PS_SourceCause_Ce ;
+
+/************************************************************************/
+/*  Parameter Definition: Uni-directional Logical Channel               */
+/*                      : Bi-directional Logical Channel                */
+/************************************************************************/
+/* ESTABLISH.request */
+/* ESTABLISH.indication */
+typedef struct _forwardreverseparam
+{
+    S_ForwardLogicalChannelParameters forwardLogicalChannelParameters ;
+    int32 option_of_reverseLogicalChannelParameters ;  /* (Not present for unidirectional) */
+    S_ReverseLogicalChannelParameters reverseLogicalChannelParameters ;
+} S_ForwardReverseParam ;
+typedef S_ForwardReverseParam *PS_ForwardReverseParam ;
+
+/* ESTABLISH.response */
+/* ESTABLISH.confirm */
+typedef struct _reversedata
+{
+    int32 option_of_reverseLogicalChannelParameters ; /* (Not present for unidirectional) */
+    S_AckReverseLogicalChannelParameters reverseLogicalChannelParameters ;
+    // FwdMuxAckParameters added to 245 library on 9/28/00 (RAN)
+    int32 option_of_forwardMultiplexAckParameters ;
+    S_ForwardMultiplexAckParameters forwardMultiplexAckParameters;
+} S_ReverseData ;
+typedef S_ReverseData           *PS_ReverseData ;
+
+/* RELEASE.indication */
+typedef struct _sourcecause_lcblc
+{
+    ENUM_Source                                 Source ;        /* SOURCE Parameter */
+    S_OlcRejectCause                            Cause ;         /* CAUSE Parameter */
+} S_SourceCause_LcBlc ;
+typedef S_SourceCause_LcBlc     *PS_SourceCause_LcBlc ;
+
+/************************************************************************/
+/*  Parameter Definition: Close Logical Channel                         */
+/************************************************************************/
+/* REJECT.indication */
+typedef struct _sourcecause_clc
+{
+    ENUM_Source     Source ;   /* SOURCE Parameter */
+    S_RccRejectCause   Cause ; /* CAUSE Parameter */
+} S_SourceCause_Clc ;
+typedef S_SourceCause_Clc   *PS_SourceCause_Clc ;
+
+/************************************************************************/
+/*  Parameter Definition: Round Trip Delay                              */
+/************************************************************************/
+/* TRANSFER.confirm */
+typedef struct _delay_rtd
+{
+    int32     Delay_Value ;
+} S_Delay_Rtd ;
+typedef S_Delay_Rtd     *PS_Delay_Rtd ;
+
+/************************************************************************/
+/*  Parameter Definition: Maintenance Loop                              */
+/************************************************************************/
+/* RELEASE.indication */
+/* Structure Salvaged (RAN) */
+typedef struct _sourcecause_ml
+{
+    ENUM_Source     Source ;                                    /* SOURCE Parameter */
+    S_MlRejectCause    Cause ;                                     /* CAUSE Parameter */
+} S_SourceCause_Ml ;
+typedef S_SourceCause_Ml    *PS_SourceCause_Ml ;
+
+/************************************************************************/
+/*  Parameter Definition: Mode Request                                  */
+/************************************************************************/
+/* REJECT.indication */
+typedef struct _sourcecause_mr
+{
+    ENUM_Source         Source ;                                /* SOURCE Parameter */
+    S_RmRejectCause     Cause ;                                 /* CAUSE Parameter */
+} S_SourceCause_Mr ;
+typedef S_SourceCause_Mr    *PS_SourceCause_Mr ;
+
+/************************************************************************/
+/*  Parameter Definition: Request Multiplex Entry                       */
+/************************************************************************/
+/* REJECT.indication */
+typedef struct _sourcecause_rme
+{
+    ENUM_Source        Source ;   /* SOURCE Parameter */
+    S_RmeRejectCause   Cause ;    /* CAUSE Parameter */
+} S_SourceCause_Rme ;
+typedef S_SourceCause_Rme   *PS_SourceCause_Rme ;
+
+
+#endif /* _H245PRI_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/analyzeper.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/analyzeper.h
new file mode 100644
index 0000000..dc1ba69
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/analyzeper.h
@@ -0,0 +1,111 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+// ============================================================
+
+// FILE: AnalyzePER.h
+
+//
+
+// DESCRIPTION: PER analysis support routine prototypes.
+
+//   These routines provide support for the automatically
+
+//   generated functions in h245_analysis.[ch].
+
+//
+
+// Written by Ralph Neff, PacketVideo, 3/6/2000
+
+// (c) 2000 PacketVideo Corp.
+
+// ============================================================
+
+
+#ifndef ANALYZEPER
+
+#define ANALYZEPER
+
+#include "genericper.h"
+
+#define ANALYZER_PERE	0x0002	// (assume tags are fixed)
+#define ANALYZER_PEREH	0x0004
+#define ANALYZER_PERD	0x0008
+#define ANALYZER_PERDH	0x0010
+
+/*=========================================================*/
+
+/*============ Function Prototypes ========================*/
+
+/*=========================================================*/
+
+/* Base-Level Interface */
+
+void Show245(uint16 tag, uint16 indent, const char *inString);
+
+void ShowHexData(uint16 tag, uint16 indent, uint16 size, uint8* data);
+
+/* Low-Level Objects */
+
+void ShowPERNull(uint16 tag, uint16 indent, const char *label);
+
+void ShowPERBoolean(uint16 tag, uint16 indent, const char *label, uint32 value);
+
+void ShowPERInteger(uint16 tag, uint16 indent, const char *label, uint32 value);
+
+void ShowPERSignedInteger(uint16 tag, uint16 indent, const char *label, int32 value);
+
+void ShowPERUnboundedInteger(uint16 tag, uint16 indent, const char *label, uint32 value);
+
+void ShowPEROctetString(uint16 tag, uint16 indent, const char *label, PS_OCTETSTRING x);
+
+void ShowPERBitString(uint16 tag, uint16 indent, const char *label, PS_BITSTRING x);
+
+void ShowPERCharString(uint16 tag, uint16 indent, const char *label, PS_int8STRING x);
+
+void ShowPERObjectID(uint16 tag, uint16 indent, const char *label, PS_OBJECTIDENT x);
+
+/* Higher Level Objects */
+
+void ShowPERChoice(uint16 tag, uint16 indent, const char *label, const char *typestring);
+
+void ShowPERSequence(uint16 tag, uint16 indent, const char *label, const char *typestring);
+
+void ShowPERSequenceof(uint16 tag, uint16 indent, const char *label, const char *typestring);
+
+void ShowPERSetof(uint16 tag, uint16 indent, const char *label, const char *typestring);
+
+void ShowPERClosure(uint16 tag, uint16 indent, const char *label);
+
+/* Arrays of Multiple Objects */
+
+void ShowPERIntegers(uint16 tag, uint16 indent, const char *label, uint32 value, uint32 number);
+
+void ShowPEROctetStrings(uint16 tag, uint16 indent, const char *label, PS_OCTETSTRING x, uint32 number);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/genericper.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/genericper.h
new file mode 100644
index 0000000..9ab5151
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/genericper.h
@@ -0,0 +1,215 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef GENERICPER
+#define GENERICPER
+
+#include "oscl_base.h"
+#include "per_common.h"
+
+/*========================================*/
+/*========== MISCELLANEOUS DEFS ==========*/
+/*========================================*/
+
+#define EPASS (void (*)(uint8*,PS_OutStream))
+
+
+/*=========================================================*/
+/*========== STRUCTURE DEFINITIONS (Generic PER) ==========*/
+/*=========================================================*/
+
+typedef struct _OCTETSTRING    /* ASN OCTET STRING */
+{
+    uint16 size;
+    uint8* data;
+} S_OCTETSTRING;
+typedef S_OCTETSTRING *PS_OCTETSTRING;
+
+typedef struct _BITSTRING    /* ASN BIT STRING */
+{
+    uint16 size;
+    uint8* data;
+} S_BITSTRING;
+
+typedef S_BITSTRING *PS_BITSTRING;
+
+typedef struct _int8STRING    /* ASN int8 STRING */
+{
+    uint16 size;
+    uint8* data;
+} S_int8STRING;
+
+typedef S_int8STRING *PS_int8STRING;
+
+typedef struct _OBJECTIDENT    /* ASN OBJECT IDENTIFIER */
+{
+    uint16 size;
+    uint8* data;
+} S_OBJECTIDENT;
+
+typedef S_OBJECTIDENT *PS_OBJECTIDENT;
+
+typedef struct _UnknownSigMap    /* Unknown SigMap */
+{
+    uint16 size;
+    uint8* optionFlags;
+    uint16 extensionsRead;
+} S_UnknownSigMap;
+
+typedef S_UnknownSigMap *PS_UnknownSigMap;
+
+typedef struct _InStream    /* Input Stream */
+{
+    uint8* data;           /* Current byte in stream */
+    uint8 bitIndex;        /* Next bit within the byte */
+} S_InStream;
+
+typedef S_InStream *PS_InStream;
+
+typedef struct _OutStream    /* Output Stream */
+{
+    uint8* data;           /* Start of allocated space */
+    uint16 size;           /* Size of allocated space */
+    uint16 byteIndex;      /* Index: next byte to write */
+    uint16 bitIndex;       /* Index: next bit to write */
+    uint8 buildByte;       /* Next byte, under construction */
+} S_OutStream;
+
+typedef S_OutStream *PS_OutStream;
+
+/*=========================================================*/
+/*============ DECODING ROUTINES (Generic PER) ============*/
+/*=========================================================*/
+/* ------------- LOW LEVEL STREAM -------------- */
+uint8 ReadBits(uint32 number, PS_InStream stream);
+void  ReadRemainingBits(PS_InStream stream);
+void  ReadOctets(uint32 number, uint8* octets, uint8 reorder, PS_InStream stream);
+
+/* ------------- HIGH LEVEL ASN DATA ------------- */
+uint8 GetBoolean(PS_InStream stream);
+uint32  GetInteger(uint32 lower, uint32 upper, PS_InStream stream);
+int32   GetSignedInteger(int32 lower, int32 upper, PS_InStream stream);
+uint32  GetUnboundedInteger(PS_InStream stream);
+uint32  GetExtendedInteger(uint32 lower, uint32 upper, PS_InStream stream);
+void  GetOctetString(uint8 unbounded, uint32 min, uint32 max,
+                     PS_OCTETSTRING x, PS_InStream stream);
+void  GetBitString(uint8 unbounded, uint32 min, uint32 max,
+                   PS_BITSTRING x, PS_InStream stream);
+void  GetCharString(const char *stringName,
+                    uint8 unbounded, uint32 min, uint32 max, const char *from,
+                    PS_int8STRING x, PS_InStream stream);
+void  GetObjectID(PS_OBJECTIDENT x, PS_InStream stream);
+
+/* ------------- OTHER CALLS ----------------*/
+uint32 GetLengthDet(PS_InStream stream);
+/* General length det, e.g. for extension wrapper */
+uint32 GetNormSmallLength(PS_InStream stream);
+/* e.g. for length of extensions SigMap */
+uint32 GetNormSmallValue(PS_InStream stream);
+/* e.g. for choice index when extension is ON */
+void SkipOneExtension(PS_InStream stream);
+/* Reads a General Length Det, skips that many octets. */
+void SkipAllExtensions(PS_InStream stream);
+/* Reads SigMap including length.  Skips each */
+/*   extension which SigMap says is present.  */
+/* NOTE: Not generated by MiniParser.  Delete? */
+uint16 GetChoiceIndex(uint32 rootnum, uint8 extmarker, PS_InStream stream);
+/* Gets (possibly extended) choice index */
+PS_UnknownSigMap GetUnknownSigMap(PS_InStream stream);
+/* Gets the unknown sig-map for SEQUENCE extensions */
+uint8 SigMapValue(uint32 index, PS_UnknownSigMap map);
+/* Reads a value from the unknown sig-map */
+void ExtensionPrep(PS_UnknownSigMap map, PS_InStream stream);
+/* Does ++map->extensionsRead */
+/* Also calls GetLengthDet(stream) to skip wrapper */
+uint32 SkipUnreadExtensions(PS_UnknownSigMap, PS_InStream stream);
+/* Use map->extensionsRead to determine how many have */
+/*   been read, and how many are left to be read. */
+/* Skips unread exts via calls to SkipOneExtension() */
+/* Frees the map */
+/* Returns the number of exts skipped. */
+void SkipOneOctet(PS_InStream stream);
+
+/*=========================================================*/
+/*============ ENCODING ROUTINES (Generic PER) ============*/
+/*=========================================================*/
+
+/* ------------- LOW LEVEL STREAM -------------- */
+void WriteBits(uint32 number, uint8 bits, PS_OutStream stream);
+void WriteRemainingBits(PS_OutStream stream);
+void WriteOctets(uint32 number, uint8* octets, uint8 reorder, PS_OutStream stream);
+PS_OutStream NewOutStream(void);
+void ExpandOutStream(PS_OutStream x);
+void FreeOutStream(PS_OutStream x);
+
+/* ------------- HIGH LEVEL ASN DATA ------------- */
+void PutBoolean(uint32 value, PS_OutStream stream);
+void PutInteger(uint32 lower, uint32 upper, uint32 value, PS_OutStream stream);
+void PutSignedInteger(int32 lower, int32 upper, int32 value, PS_OutStream stream);
+void PutUnboundedInteger(uint32 value, PS_OutStream stream);
+void PutExtendedInteger(uint32 lower, uint32 upper, uint32 value, PS_OutStream stream);
+void PutOctetString(uint8 unbounded,
+                    uint32 min, uint32 max, PS_OCTETSTRING x, PS_OutStream stream);
+void PutBitString(uint8 unbounded,
+                  uint32 min, uint32 max, PS_BITSTRING x, PS_OutStream stream);
+void PutCharString(const char *stringName,
+                   uint8 unbounded, uint32 min, uint32 max, const char *from,
+                   PS_int8STRING x, PS_OutStream stream);
+void PutObjectID(PS_OBJECTIDENT x, PS_OutStream stream);
+void PutExtensionNull(PS_OutStream stream);
+void PutExtensionBoolean(uint32 value, PS_OutStream stream);
+void PutExtensionInteger(uint32 lower, uint32 upper, uint32 value, PS_OutStream stream);
+void PutExtensionOctetString(uint8 unbounded,
+                             uint32 min, uint32 max, PS_OCTETSTRING x, PS_OutStream stream);
+
+/* ------------- OTHER CALLS ----------------*/
+void PutNormSmallValue(uint32 value, PS_OutStream stream);
+/* e.g. for choice index when extension is ON */
+void PutChoiceIndex(uint32 rootnum, uint8 extmarker, uint32 index, PS_OutStream stream);
+/* Writes extension bit, choice index */
+void PutNormSmallLength(uint32 value, PS_OutStream stream);
+/* e.g. for length of extensions SigMap */
+void PutLengthDet(uint32 value, PS_OutStream stream);
+/* General length det, e.g. for extension wrapper */
+void PutExtensionItem(
+    void (*Func)(uint8* x, PS_OutStream stream),
+    uint8* x, PS_OutStream stream);
+/* Write extension item, including length det */
+void PutTempStream(PS_OutStream tempStream, PS_OutStream stream);
+/* Copy contents of tempStream to the real one */
+
+/*======================================================*/
+/*============ OTHER ROUTINES (Generic PER) ============*/
+/*======================================================*/
+void ErrorMessage(const char *msg);
+void ErrorMessageAndLeave(const char *msg);
+/* Generic error call.  Just print it for now */
+PS_InStream ConvertOutstreamToInstream(PS_OutStream outstream);
+PS_OCTETSTRING NewOctetString(void);
+PS_BITSTRING NewBitString(void);
+PS_int8STRING NewCharString(void);
+PS_OBJECTIDENT NewObjectID(void);
+void InitOctetString(PS_OCTETSTRING x);
+void InitBitString(PS_BITSTRING x);
+void InitCharString(PS_int8STRING x);
+void InitObjectid(PS_OBJECTIDENT x);
+void FreeOctetString(PS_OCTETSTRING x);
+void FreeBitString(PS_BITSTRING x);
+void FreeCharString(PS_int8STRING x);
+void FreeObjectID(PS_OBJECTIDENT x);
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_analysis.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_analysis.h
new file mode 100644
index 0000000..4f9a884
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_analysis.h
@@ -0,0 +1,408 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_analysis.h
+//
+// DESC: PER Analyzer routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#ifndef PER_ANALYZER
+#define PER_ANALYZER
+
+void Analyze_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMessage(PS_RequestMessage x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ResponseMessage(PS_ResponseMessage x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CommandMessage(PS_CommandMessage x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndicationMessage(PS_IndicationMessage x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NonStandardMessage(PS_NonStandardMessage x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NonStandardParameter(PS_NonStandardParameter x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NonStandardIdentifier(PS_NonStandardIdentifier x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H221NonStandard(PS_H221NonStandard x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MasterSlaveDetermination(PS_MasterSlaveDetermination x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Decision(PS_Decision x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MsdRejectCause(PS_MsdRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalCapabilitySet(PS_TerminalCapabilitySet x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CapabilityTableEntry(PS_CapabilityTableEntry x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CapabilityDescriptor(PS_CapabilityDescriptor x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TcsRejectCause(PS_TcsRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Capability(PS_Capability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H235SecurityCapability(PS_H235SecurityCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexCapability(PS_MultiplexCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H222Capability(PS_H222Capability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VCCapability(PS_VCCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Aal1ViaGateway(PS_Aal1ViaGateway x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AvailableBitRates(PS_AvailableBitRates x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VccAal5Type(PS_VccAal5Type x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RangeOfBitRates(PS_RangeOfBitRates x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VccAal5(PS_VccAal5 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VccAal1(PS_VccAal1 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223Capability(PS_H223Capability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Enhanced(PS_Enhanced x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223AnnexCCapability(PS_H223AnnexCCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V76Capability(PS_V76Capability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V75Capability(PS_V75Capability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H2250Capability(PS_H2250Capability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_McCapability(PS_McCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaPacketizationCapability(PS_MediaPacketizationCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RSVPParameters(PS_RSVPParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_QOSMode(PS_QOSMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ATMParameters(PS_ATMParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_QOSCapability(PS_QOSCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaTransportType(PS_MediaTransportType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaChannelCapability(PS_MediaChannelCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TransportCapability(PS_TransportCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FrameToThreadMapping(PS_FrameToThreadMapping x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultipointCapability(PS_MultipointCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaDistributionCapability(PS_MediaDistributionCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoCapability(PS_VideoCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H261VideoCapability(PS_H261VideoCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H262VideoCapability(PS_H262VideoCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H263VideoCapability(PS_H263VideoCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EnhancementLayerInfo(PS_EnhancementLayerInfo x, const char* label, uint16 tag, uint16 indent);
+void Analyze_BEnhancementParameters(PS_BEnhancementParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EnhancementOptions(PS_EnhancementOptions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H263Options(PS_H263Options x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TransparencyParameters(PS_TransparencyParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RefPictureSelection(PS_RefPictureSelection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoBackChannelSend(PS_VideoBackChannelSend x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AdditionalPictureMemory(PS_AdditionalPictureMemory x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CustomPictureFormat(PS_CustomPictureFormat x, const char* label, uint16 tag, uint16 indent);
+void Analyze_PixelAspectInformation(PS_PixelAspectInformation x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ExtendedPARItem(PS_ExtendedPARItem x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MPI(PS_MPI x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CustomPCFItem(PS_CustomPCFItem x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H263VideoModeCombos(PS_H263VideoModeCombos x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H263ModeComboFlags(PS_H263ModeComboFlags x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IS11172VideoCapability(PS_IS11172VideoCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AudioCapability(PS_AudioCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_G7231(PS_G7231 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_G729Extensions(PS_G729Extensions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_G7231AnnexCCapability(PS_G7231AnnexCCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IS11172AudioCapability(PS_IS11172AudioCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IS13818AudioCapability(PS_IS13818AudioCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_GSMAudioCapability(PS_GSMAudioCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DataApplicationCapability(PS_DataApplicationCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Application(PS_Application x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T38fax(PS_T38fax x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Nlpid(PS_Nlpid x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T84(PS_T84 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DataProtocolCapability(PS_DataProtocolCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V76wCompression(PS_V76wCompression x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CompressionType(PS_CompressionType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V42bis(PS_V42bis x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T84Profile(PS_T84Profile x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T84Restricted(PS_T84Restricted x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T38FaxProfile(PS_T38FaxProfile x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T38FaxRateManagement(PS_T38FaxRateManagement x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T38FaxUdpOptions(PS_T38FaxUdpOptions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T38FaxUdpEC(PS_T38FaxUdpEC x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionCapability(PS_EncryptionCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AuthenticationCapability(PS_AuthenticationCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IntegrityCapability(PS_IntegrityCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_UserInputCapability(PS_UserInputCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConferenceCapability(PS_ConferenceCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_GenericCapability(PS_GenericCapability x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CapabilityIdentifier(PS_CapabilityIdentifier x, const char* label, uint16 tag, uint16 indent);
+void Analyze_GenericParameter(PS_GenericParameter x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ParameterIdentifier(PS_ParameterIdentifier x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ParameterValue(PS_ParameterValue x, const char* label, uint16 tag, uint16 indent);
+void Analyze_OpenLogicalChannel(PS_OpenLogicalChannel x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RlcMultiplexParameters(PS_RlcMultiplexParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexParameters(PS_MultiplexParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NetworkAccessParameters(PS_NetworkAccessParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_T120SetupProcedure(PS_T120SetupProcedure x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NetworkAddress(PS_NetworkAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Distribution(PS_Distribution x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Q2931Address(PS_Q2931Address x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Address(PS_Address x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V75Parameters(PS_V75Parameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DataType(PS_DataType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H235Media(PS_H235Media x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaType(PS_MediaType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AdaptationLayerType(PS_AdaptationLayerType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Al3(PS_Al3 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223AL1MParameters(PS_H223AL1MParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ArqType(PS_ArqType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CrcLength(PS_CrcLength x, const char* label, uint16 tag, uint16 indent);
+void Analyze_HeaderFEC(PS_HeaderFEC x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TransferMode(PS_TransferMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223AL2MParameters(PS_H223AL2MParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Al2HeaderFEC(PS_Al2HeaderFEC x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223AL3MParameters(PS_H223AL3MParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Al3ArqType(PS_Al3ArqType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Al3CrcLength(PS_Al3CrcLength x, const char* label, uint16 tag, uint16 indent);
+void Analyze_HeaderFormat(PS_HeaderFormat x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NumberOfRetransmissions(PS_NumberOfRetransmissions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Mode(PS_Mode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ERM(PS_ERM x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Recovery(PS_Recovery x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SuspendResume(PS_SuspendResume x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V76HDLCParameters(PS_V76HDLCParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CRCLength(PS_CRCLength x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaPacketization(PS_MediaPacketization x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RTPPayloadType(PS_RTPPayloadType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_PayloadDescriptor(PS_PayloadDescriptor x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RedundancyEncoding(PS_RedundancyEncoding x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TransportAddress(PS_TransportAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_UnicastAddress(PS_UnicastAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IPSourceRouteAddress(PS_IPSourceRouteAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Routing(PS_Routing x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IP6Address(PS_IP6Address x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IPXAddress(PS_IPXAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IPAddress(PS_IPAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MulticastAddress(PS_MulticastAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaIp6Address(PS_MaIp6Address x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaIpAddress(PS_MaIpAddress x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionSync(PS_EncryptionSync x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EscrowData(PS_EscrowData x, const char* label, uint16 tag, uint16 indent);
+void Analyze_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AckMultiplexParameters(PS_AckMultiplexParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_OlcRejectCause(PS_OlcRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CloseLogicalChannel(PS_CloseLogicalChannel x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Reason(PS_Reason x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Source(PS_Source x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestChannelClose(PS_RequestChannelClose x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RccReason(PS_RccReason x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestChannelCloseAck(PS_RequestChannelCloseAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestChannelCloseReject(PS_RequestChannelCloseReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RccRejectCause(PS_RccRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexEntrySend(PS_MultiplexEntrySend x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexElement(PS_MultiplexElement x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RepeatCount(PS_RepeatCount x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MuxType(PS_MuxType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MeRejectCause(PS_MeRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMultiplexEntry(PS_RequestMultiplexEntry x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RmeRejectCause(PS_RmeRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestMode(PS_RequestMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestModeAck(PS_RequestModeAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Response(PS_Response x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestModeReject(PS_RequestModeReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RmRejectCause(PS_RmRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestModeRelease(PS_RequestModeRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeDescription(PS_ModeDescription x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeElement(PS_ModeElement x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeType(PS_ModeType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H235Mode(PS_H235Mode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MediaMode(PS_MediaMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223ModeParameters(PS_H223ModeParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeAl3(PS_ModeAl3 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_V76ModeParameters(PS_V76ModeParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H2250ModeParameters(PS_H2250ModeParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RedundancyEncodingMode(PS_RedundancyEncodingMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SecondaryEncoding(PS_SecondaryEncoding x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoMode(PS_VideoMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H261VideoMode(PS_H261VideoMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Resolution(PS_Resolution x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H262VideoMode(PS_H262VideoMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ProfileAndLevel(PS_ProfileAndLevel x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H263VideoMode(PS_H263VideoMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H263Resolution(PS_H263Resolution x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IS11172VideoMode(PS_IS11172VideoMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AudioMode(PS_AudioMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeG7231(PS_ModeG7231 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IS11172AudioMode(PS_IS11172AudioMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultichannelType(PS_MultichannelType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AudioSampling(PS_AudioSampling x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AudioLayer(PS_AudioLayer x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IS13818AudioMode(PS_IS13818AudioMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Is13818MultichannelType(PS_Is13818MultichannelType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Is13818AudioSampling(PS_Is13818AudioSampling x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Is13818AudioLayer(PS_Is13818AudioLayer x, const char* label, uint16 tag, uint16 indent);
+void Analyze_G7231AnnexCMode(PS_G7231AnnexCMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DataMode(PS_DataMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DmApplication(PS_DmApplication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DmT38fax(PS_DmT38fax x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DmNlpid(PS_DmNlpid x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionMode(PS_EncryptionMode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RoundTripDelayRequest(PS_RoundTripDelayRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RoundTripDelayResponse(PS_RoundTripDelayResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MlRequestType(PS_MlRequestType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaintenanceLoopAck(PS_MaintenanceLoopAck x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MlAckType(PS_MlAckType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaintenanceLoopReject(PS_MaintenanceLoopReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MlRejectCause(PS_MlRejectCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MlRejectType(PS_MlRejectType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CommunicationModeCommand(PS_CommunicationModeCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CommunicationModeRequest(PS_CommunicationModeRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CommunicationModeResponse(PS_CommunicationModeResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmtDataType(PS_CmtDataType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConferenceRequest(PS_ConferenceRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestTerminalCertificate(PS_RequestTerminalCertificate x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CertSelectionCriteria(PS_CertSelectionCriteria x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Criteria(PS_Criteria x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalLabel(PS_TerminalLabel x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConferenceResponse(PS_ConferenceResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SendThisSourceResponse(PS_SendThisSourceResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalCertificateResponse(PS_TerminalCertificateResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ExtensionAddressResponse(PS_ExtensionAddressResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MakeMeChairResponse(PS_MakeMeChairResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_PasswordResponse(PS_PasswordResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConferenceIDResponse(PS_ConferenceIDResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalIDResponse(PS_TerminalIDResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MCTerminalIDResponse(PS_MCTerminalIDResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalInformation(PS_TerminalInformation x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RemoteMCRequest(PS_RemoteMCRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RemoteMCResponse(PS_RemoteMCResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Reject(PS_Reject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultilinkRequest(PS_MultilinkRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MaximumHeaderInterval(PS_MaximumHeaderInterval x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RequestType(PS_RequestType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RemoveConnection(PS_RemoveConnection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_AddConnection(PS_AddConnection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CallInformation(PS_CallInformation x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultilinkResponse(PS_MultilinkResponse x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RespRemoveConnection(PS_RespRemoveConnection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RespAddConnection(PS_RespAddConnection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ResponseCode(PS_ResponseCode x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Rejected(PS_Rejected x, const char* label, uint16 tag, uint16 indent);
+void Analyze_RespCallInformation(PS_RespCallInformation x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MultilinkIndication(PS_MultilinkIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ExcessiveError(PS_ExcessiveError x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CrcDesired(PS_CrcDesired x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DialingInformation(PS_DialingInformation x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DialingInformationNumber(PS_DialingInformationNumber x, const char* label, uint16 tag, uint16 indent);
+void Analyze_DialingInformationNetworkType(PS_DialingInformationNetworkType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConnectionIdentifier(PS_ConnectionIdentifier x, const char* label, uint16 tag, uint16 indent);
+void Analyze_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x, const char* label, uint16 tag, uint16 indent);
+void Analyze_LogicalChannelRateReject(PS_LogicalChannelRateReject x, const char* label, uint16 tag, uint16 indent);
+void Analyze_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x, const char* label, uint16 tag, uint16 indent);
+void Analyze_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SpecificRequest(PS_SpecificRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionCommand(PS_EncryptionCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FlowControlCommand(PS_FlowControlCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FccRestriction(PS_FccRestriction x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FccScope(PS_FccScope x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EndSessionCommand(PS_EndSessionCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IsdnOptions(PS_IsdnOptions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_GstnOptions(PS_GstnOptions x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConferenceCommand(PS_ConferenceCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MiscellaneousCommand(PS_MiscellaneousCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_McType(PS_McType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x, const char* label, uint16 tag, uint16 indent);
+void Analyze_PrsRepeatCount(PS_PrsRepeatCount x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoFastUpdateMB(PS_VideoFastUpdateMB x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x, const char* label, uint16 tag, uint16 indent);
+void Analyze_KeyProtectionMethod(PS_KeyProtectionMethod x, const char* label, uint16 tag, uint16 indent);
+void Analyze_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223ModeChange(PS_H223ModeChange x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NewATMVCCommand(PS_NewATMVCCommand x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdReverseParameters(PS_CmdReverseParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Multiplex(PS_Multiplex x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdMultiplex(PS_CmdMultiplex x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdAal(PS_CmdAal x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdAal5(PS_CmdAal5 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdAal1(PS_CmdAal1 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdErrorCorrection(PS_CmdErrorCorrection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_CmdClockRecovery(PS_CmdClockRecovery x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FunctionNotUnderstood(PS_FunctionNotUnderstood x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FunctionNotSupported(PS_FunctionNotSupported x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FnsCause(PS_FnsCause x, const char* label, uint16 tag, uint16 indent);
+void Analyze_ConferenceIndication(PS_ConferenceIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoIndicateCompose(PS_VideoIndicateCompose x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MiscellaneousIndication(PS_MiscellaneousIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MiType(PS_MiType x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x, const char* label, uint16 tag, uint16 indent);
+void Analyze_JitterIndication(PS_JitterIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_JiScope(PS_JiScope x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H223SkewIndication(PS_H223SkewIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_MCLocationIndication(PS_MCLocationIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_VendorIdentification(PS_VendorIdentification x, const char* label, uint16 tag, uint16 indent);
+void Analyze_NewATMVCIndication(PS_NewATMVCIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndReverseParameters(PS_IndReverseParameters x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IrpMultiplex(PS_IrpMultiplex x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndMultiplex(PS_IndMultiplex x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndAal(PS_IndAal x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndAal5(PS_IndAal5 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndAal1(PS_IndAal1 x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndErrorCorrection(PS_IndErrorCorrection x, const char* label, uint16 tag, uint16 indent);
+void Analyze_IndClockRecovery(PS_IndClockRecovery x, const char* label, uint16 tag, uint16 indent);
+void Analyze_UserInputIndication(PS_UserInputIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SignalUpdate(PS_SignalUpdate x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Rtp(PS_Rtp x, const char* label, uint16 tag, uint16 indent);
+void Analyze_Signal(PS_Signal x, const char* label, uint16 tag, uint16 indent);
+void Analyze_SignalRtp(PS_SignalRtp x, const char* label, uint16 tag, uint16 indent);
+void Analyze_UserInputSupportIndication(PS_UserInputSupportIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FlowControlIndication(PS_FlowControlIndication x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FciRestriction(PS_FciRestriction x, const char* label, uint16 tag, uint16 indent);
+void Analyze_FciScope(PS_FciScope x, const char* label, uint16 tag, uint16 indent);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_copier.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_copier.h
new file mode 100644
index 0000000..ff5954c
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_copier.h
@@ -0,0 +1,43 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ===================================================================
+// FILE: h245_copier.h
+//
+// DESC: PER Copy routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+// ****************************************************
+// ** NOTE: This file is not auto-generated.         **
+// ** Add copy routines as needed in the application **
+// ****************************************************
+
+#ifndef PER_COPIER
+#define PER_COPIER
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+OSCL_IMPORT_REF PS_DataType Copy_DataType(PS_DataType x);
+OSCL_IMPORT_REF PS_H223LogicalChannelParameters Copy_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x);
+PS_MultiplexEntryDescriptor Copy_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x);
+PS_ForwardLogicalChannelParameters Copy_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x);
+PS_ReverseLogicalChannelParameters Copy_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x);
+PS_TerminalCapabilitySet Copy_TerminalCapabilitySet(PS_TerminalCapabilitySet x);
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_decoder.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_decoder.h
new file mode 100644
index 0000000..7d6892f
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_decoder.h
@@ -0,0 +1,409 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_decoder.h
+//
+// DESC: PER Decode routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#ifndef PER_DECODER
+#define PER_DECODER
+
+void Decode_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x, PS_InStream stream);
+void Decode_RequestMessage(PS_RequestMessage x, PS_InStream stream);
+void Decode_ResponseMessage(PS_ResponseMessage x, PS_InStream stream);
+void Decode_CommandMessage(PS_CommandMessage x, PS_InStream stream);
+void Decode_IndicationMessage(PS_IndicationMessage x, PS_InStream stream);
+void Decode_GenericInformation(PS_GenericInformation x, PS_InStream stream);
+void Decode_NonStandardMessage(PS_NonStandardMessage x, PS_InStream stream);
+void Decode_NonStandardParameter(PS_NonStandardParameter x, PS_InStream stream);
+void Decode_NonStandardIdentifier(PS_NonStandardIdentifier x, PS_InStream stream);
+void Decode_H221NonStandard(PS_H221NonStandard x, PS_InStream stream);
+void Decode_MasterSlaveDetermination(PS_MasterSlaveDetermination x, PS_InStream stream);
+void Decode_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x, PS_InStream stream);
+void Decode_Decision(PS_Decision x, PS_InStream stream);
+void Decode_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x, PS_InStream stream);
+void Decode_MsdRejectCause(PS_MsdRejectCause x, PS_InStream stream);
+void Decode_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x, PS_InStream stream);
+void Decode_TerminalCapabilitySet(PS_TerminalCapabilitySet x, PS_InStream stream);
+void Decode_CapabilityTableEntry(PS_CapabilityTableEntry x, PS_InStream stream);
+void Decode_CapabilityDescriptor(PS_CapabilityDescriptor x, PS_InStream stream);
+void Decode_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x, PS_InStream stream);
+void Decode_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x, PS_InStream stream);
+void Decode_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x, PS_InStream stream);
+void Decode_TcsRejectCause(PS_TcsRejectCause x, PS_InStream stream);
+void Decode_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x, PS_InStream stream);
+void Decode_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x, PS_InStream stream);
+void Decode_Capability(PS_Capability x, PS_InStream stream);
+void Decode_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x, PS_InStream stream);
+void Decode_H235SecurityCapability(PS_H235SecurityCapability x, PS_InStream stream);
+void Decode_MultiplexCapability(PS_MultiplexCapability x, PS_InStream stream);
+void Decode_H222Capability(PS_H222Capability x, PS_InStream stream);
+void Decode_VCCapability(PS_VCCapability x, PS_InStream stream);
+void Decode_Aal1ViaGateway(PS_Aal1ViaGateway x, PS_InStream stream);
+void Decode_AvailableBitRates(PS_AvailableBitRates x, PS_InStream stream);
+void Decode_VccAal5Type(PS_VccAal5Type x, PS_InStream stream);
+void Decode_RangeOfBitRates(PS_RangeOfBitRates x, PS_InStream stream);
+void Decode_VccAal5(PS_VccAal5 x, PS_InStream stream);
+void Decode_VccAal1(PS_VccAal1 x, PS_InStream stream);
+void Decode_H223Capability(PS_H223Capability x, PS_InStream stream);
+void Decode_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x, PS_InStream stream);
+void Decode_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x, PS_InStream stream);
+void Decode_Enhanced(PS_Enhanced x, PS_InStream stream);
+void Decode_H223AnnexCCapability(PS_H223AnnexCCapability x, PS_InStream stream);
+void Decode_V76Capability(PS_V76Capability x, PS_InStream stream);
+void Decode_V75Capability(PS_V75Capability x, PS_InStream stream);
+void Decode_H2250Capability(PS_H2250Capability x, PS_InStream stream);
+void Decode_McCapability(PS_McCapability x, PS_InStream stream);
+void Decode_MediaPacketizationCapability(PS_MediaPacketizationCapability x, PS_InStream stream);
+void Decode_RSVPParameters(PS_RSVPParameters x, PS_InStream stream);
+void Decode_QOSMode(PS_QOSMode x, PS_InStream stream);
+void Decode_ATMParameters(PS_ATMParameters x, PS_InStream stream);
+void Decode_QOSCapability(PS_QOSCapability x, PS_InStream stream);
+void Decode_MediaTransportType(PS_MediaTransportType x, PS_InStream stream);
+void Decode_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x, PS_InStream stream);
+void Decode_MediaChannelCapability(PS_MediaChannelCapability x, PS_InStream stream);
+void Decode_TransportCapability(PS_TransportCapability x, PS_InStream stream);
+void Decode_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x, PS_InStream stream);
+void Decode_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x, PS_InStream stream);
+void Decode_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x, PS_InStream stream);
+void Decode_FrameToThreadMapping(PS_FrameToThreadMapping x, PS_InStream stream);
+void Decode_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x, PS_InStream stream);
+void Decode_MultipointCapability(PS_MultipointCapability x, PS_InStream stream);
+void Decode_MediaDistributionCapability(PS_MediaDistributionCapability x, PS_InStream stream);
+void Decode_VideoCapability(PS_VideoCapability x, PS_InStream stream);
+void Decode_H261VideoCapability(PS_H261VideoCapability x, PS_InStream stream);
+void Decode_H262VideoCapability(PS_H262VideoCapability x, PS_InStream stream);
+void Decode_H263VideoCapability(PS_H263VideoCapability x, PS_InStream stream);
+void Decode_EnhancementLayerInfo(PS_EnhancementLayerInfo x, PS_InStream stream);
+void Decode_BEnhancementParameters(PS_BEnhancementParameters x, PS_InStream stream);
+void Decode_EnhancementOptions(PS_EnhancementOptions x, PS_InStream stream);
+void Decode_H263Options(PS_H263Options x, PS_InStream stream);
+void Decode_TransparencyParameters(PS_TransparencyParameters x, PS_InStream stream);
+void Decode_RefPictureSelection(PS_RefPictureSelection x, PS_InStream stream);
+void Decode_VideoBackChannelSend(PS_VideoBackChannelSend x, PS_InStream stream);
+void Decode_AdditionalPictureMemory(PS_AdditionalPictureMemory x, PS_InStream stream);
+void Decode_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x, PS_InStream stream);
+void Decode_CustomPictureFormat(PS_CustomPictureFormat x, PS_InStream stream);
+void Decode_PixelAspectInformation(PS_PixelAspectInformation x, PS_InStream stream);
+void Decode_ExtendedPARItem(PS_ExtendedPARItem x, PS_InStream stream);
+void Decode_MPI(PS_MPI x, PS_InStream stream);
+void Decode_CustomPCFItem(PS_CustomPCFItem x, PS_InStream stream);
+void Decode_H263VideoModeCombos(PS_H263VideoModeCombos x, PS_InStream stream);
+void Decode_H263ModeComboFlags(PS_H263ModeComboFlags x, PS_InStream stream);
+void Decode_IS11172VideoCapability(PS_IS11172VideoCapability x, PS_InStream stream);
+void Decode_AudioCapability(PS_AudioCapability x, PS_InStream stream);
+void Decode_G7231(PS_G7231 x, PS_InStream stream);
+void Decode_G729Extensions(PS_G729Extensions x, PS_InStream stream);
+void Decode_G7231AnnexCCapability(PS_G7231AnnexCCapability x, PS_InStream stream);
+void Decode_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x, PS_InStream stream);
+void Decode_IS11172AudioCapability(PS_IS11172AudioCapability x, PS_InStream stream);
+void Decode_IS13818AudioCapability(PS_IS13818AudioCapability x, PS_InStream stream);
+void Decode_GSMAudioCapability(PS_GSMAudioCapability x, PS_InStream stream);
+void Decode_DataApplicationCapability(PS_DataApplicationCapability x, PS_InStream stream);
+void Decode_Application(PS_Application x, PS_InStream stream);
+void Decode_T38fax(PS_T38fax x, PS_InStream stream);
+void Decode_Nlpid(PS_Nlpid x, PS_InStream stream);
+void Decode_T84(PS_T84 x, PS_InStream stream);
+void Decode_DataProtocolCapability(PS_DataProtocolCapability x, PS_InStream stream);
+void Decode_V76wCompression(PS_V76wCompression x, PS_InStream stream);
+void Decode_CompressionType(PS_CompressionType x, PS_InStream stream);
+void Decode_V42bis(PS_V42bis x, PS_InStream stream);
+void Decode_T84Profile(PS_T84Profile x, PS_InStream stream);
+void Decode_T84Restricted(PS_T84Restricted x, PS_InStream stream);
+void Decode_T38FaxProfile(PS_T38FaxProfile x, PS_InStream stream);
+void Decode_T38FaxRateManagement(PS_T38FaxRateManagement x, PS_InStream stream);
+void Decode_T38FaxUdpOptions(PS_T38FaxUdpOptions x, PS_InStream stream);
+void Decode_T38FaxUdpEC(PS_T38FaxUdpEC x, PS_InStream stream);
+void Decode_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x, PS_InStream stream);
+void Decode_EncryptionCapability(PS_EncryptionCapability x, PS_InStream stream);
+void Decode_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x, PS_InStream stream);
+void Decode_AuthenticationCapability(PS_AuthenticationCapability x, PS_InStream stream);
+void Decode_IntegrityCapability(PS_IntegrityCapability x, PS_InStream stream);
+void Decode_UserInputCapability(PS_UserInputCapability x, PS_InStream stream);
+void Decode_ConferenceCapability(PS_ConferenceCapability x, PS_InStream stream);
+void Decode_GenericCapability(PS_GenericCapability x, PS_InStream stream);
+void Decode_CapabilityIdentifier(PS_CapabilityIdentifier x, PS_InStream stream);
+void Decode_GenericParameter(PS_GenericParameter x, PS_InStream stream);
+void Decode_ParameterIdentifier(PS_ParameterIdentifier x, PS_InStream stream);
+void Decode_ParameterValue(PS_ParameterValue x, PS_InStream stream);
+void Decode_OpenLogicalChannel(PS_OpenLogicalChannel x, PS_InStream stream);
+void Decode_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x, PS_InStream stream);
+void Decode_RlcMultiplexParameters(PS_RlcMultiplexParameters x, PS_InStream stream);
+void Decode_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x, PS_InStream stream);
+void Decode_MultiplexParameters(PS_MultiplexParameters x, PS_InStream stream);
+void Decode_NetworkAccessParameters(PS_NetworkAccessParameters x, PS_InStream stream);
+void Decode_T120SetupProcedure(PS_T120SetupProcedure x, PS_InStream stream);
+void Decode_NetworkAddress(PS_NetworkAddress x, PS_InStream stream);
+void Decode_Distribution(PS_Distribution x, PS_InStream stream);
+void Decode_Q2931Address(PS_Q2931Address x, PS_InStream stream);
+void Decode_Address(PS_Address x, PS_InStream stream);
+void Decode_V75Parameters(PS_V75Parameters x, PS_InStream stream);
+void Decode_DataType(PS_DataType x, PS_InStream stream);
+void Decode_H235Media(PS_H235Media x, PS_InStream stream);
+void Decode_MediaType(PS_MediaType x, PS_InStream stream);
+void Decode_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x, PS_InStream stream);
+void Decode_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x, PS_InStream stream);
+void Decode_AdaptationLayerType(PS_AdaptationLayerType x, PS_InStream stream);
+void Decode_Al3(PS_Al3 x, PS_InStream stream);
+void Decode_H223AL1MParameters(PS_H223AL1MParameters x, PS_InStream stream);
+void Decode_ArqType(PS_ArqType x, PS_InStream stream);
+void Decode_CrcLength(PS_CrcLength x, PS_InStream stream);
+void Decode_HeaderFEC(PS_HeaderFEC x, PS_InStream stream);
+void Decode_TransferMode(PS_TransferMode x, PS_InStream stream);
+void Decode_H223AL2MParameters(PS_H223AL2MParameters x, PS_InStream stream);
+void Decode_Al2HeaderFEC(PS_Al2HeaderFEC x, PS_InStream stream);
+void Decode_H223AL3MParameters(PS_H223AL3MParameters x, PS_InStream stream);
+void Decode_Al3ArqType(PS_Al3ArqType x, PS_InStream stream);
+void Decode_Al3CrcLength(PS_Al3CrcLength x, PS_InStream stream);
+void Decode_HeaderFormat(PS_HeaderFormat x, PS_InStream stream);
+void Decode_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x, PS_InStream stream);
+void Decode_NumberOfRetransmissions(PS_NumberOfRetransmissions x, PS_InStream stream);
+void Decode_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x, PS_InStream stream);
+void Decode_Mode(PS_Mode x, PS_InStream stream);
+void Decode_ERM(PS_ERM x, PS_InStream stream);
+void Decode_Recovery(PS_Recovery x, PS_InStream stream);
+void Decode_SuspendResume(PS_SuspendResume x, PS_InStream stream);
+void Decode_V76HDLCParameters(PS_V76HDLCParameters x, PS_InStream stream);
+void Decode_CRCLength(PS_CRCLength x, PS_InStream stream);
+void Decode_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x, PS_InStream stream);
+void Decode_MediaPacketization(PS_MediaPacketization x, PS_InStream stream);
+void Decode_RTPPayloadType(PS_RTPPayloadType x, PS_InStream stream);
+void Decode_PayloadDescriptor(PS_PayloadDescriptor x, PS_InStream stream);
+void Decode_RedundancyEncoding(PS_RedundancyEncoding x, PS_InStream stream);
+void Decode_TransportAddress(PS_TransportAddress x, PS_InStream stream);
+void Decode_UnicastAddress(PS_UnicastAddress x, PS_InStream stream);
+void Decode_IPSourceRouteAddress(PS_IPSourceRouteAddress x, PS_InStream stream);
+void Decode_Routing(PS_Routing x, PS_InStream stream);
+void Decode_IP6Address(PS_IP6Address x, PS_InStream stream);
+void Decode_IPXAddress(PS_IPXAddress x, PS_InStream stream);
+void Decode_IPAddress(PS_IPAddress x, PS_InStream stream);
+void Decode_MulticastAddress(PS_MulticastAddress x, PS_InStream stream);
+void Decode_MaIp6Address(PS_MaIp6Address x, PS_InStream stream);
+void Decode_MaIpAddress(PS_MaIpAddress x, PS_InStream stream);
+void Decode_EncryptionSync(PS_EncryptionSync x, PS_InStream stream);
+void Decode_EscrowData(PS_EscrowData x, PS_InStream stream);
+void Decode_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x, PS_InStream stream);
+void Decode_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x, PS_InStream stream);
+void Decode_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x, PS_InStream stream);
+void Decode_AckMultiplexParameters(PS_AckMultiplexParameters x, PS_InStream stream);
+void Decode_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x, PS_InStream stream);
+void Decode_OlcRejectCause(PS_OlcRejectCause x, PS_InStream stream);
+void Decode_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x, PS_InStream stream);
+void Decode_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x, PS_InStream stream);
+void Decode_CloseLogicalChannel(PS_CloseLogicalChannel x, PS_InStream stream);
+void Decode_Reason(PS_Reason x, PS_InStream stream);
+void Decode_Source(PS_Source x, PS_InStream stream);
+void Decode_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x, PS_InStream stream);
+void Decode_RequestChannelClose(PS_RequestChannelClose x, PS_InStream stream);
+void Decode_RccReason(PS_RccReason x, PS_InStream stream);
+void Decode_RequestChannelCloseAck(PS_RequestChannelCloseAck x, PS_InStream stream);
+void Decode_RequestChannelCloseReject(PS_RequestChannelCloseReject x, PS_InStream stream);
+void Decode_RccRejectCause(PS_RccRejectCause x, PS_InStream stream);
+void Decode_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x, PS_InStream stream);
+void Decode_MultiplexEntrySend(PS_MultiplexEntrySend x, PS_InStream stream);
+void Decode_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x, PS_InStream stream);
+void Decode_MultiplexElement(PS_MultiplexElement x, PS_InStream stream);
+void Decode_RepeatCount(PS_RepeatCount x, PS_InStream stream);
+void Decode_MuxType(PS_MuxType x, PS_InStream stream);
+void Decode_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x, PS_InStream stream);
+void Decode_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x, PS_InStream stream);
+void Decode_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x, PS_InStream stream);
+void Decode_MeRejectCause(PS_MeRejectCause x, PS_InStream stream);
+void Decode_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x, PS_InStream stream);
+void Decode_RequestMultiplexEntry(PS_RequestMultiplexEntry x, PS_InStream stream);
+void Decode_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x, PS_InStream stream);
+void Decode_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x, PS_InStream stream);
+void Decode_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x, PS_InStream stream);
+void Decode_RmeRejectCause(PS_RmeRejectCause x, PS_InStream stream);
+void Decode_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x, PS_InStream stream);
+void Decode_RequestMode(PS_RequestMode x, PS_InStream stream);
+void Decode_RequestModeAck(PS_RequestModeAck x, PS_InStream stream);
+void Decode_Response(PS_Response x, PS_InStream stream);
+void Decode_RequestModeReject(PS_RequestModeReject x, PS_InStream stream);
+void Decode_RmRejectCause(PS_RmRejectCause x, PS_InStream stream);
+void Decode_RequestModeRelease(PS_RequestModeRelease x, PS_InStream stream);
+void Decode_ModeDescription(PS_ModeDescription x, PS_InStream stream);
+void Decode_ModeElement(PS_ModeElement x, PS_InStream stream);
+void Decode_ModeType(PS_ModeType x, PS_InStream stream);
+void Decode_H235Mode(PS_H235Mode x, PS_InStream stream);
+void Decode_MediaMode(PS_MediaMode x, PS_InStream stream);
+void Decode_H223ModeParameters(PS_H223ModeParameters x, PS_InStream stream);
+void Decode_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x, PS_InStream stream);
+void Decode_ModeAl3(PS_ModeAl3 x, PS_InStream stream);
+void Decode_V76ModeParameters(PS_V76ModeParameters x, PS_InStream stream);
+void Decode_H2250ModeParameters(PS_H2250ModeParameters x, PS_InStream stream);
+void Decode_RedundancyEncodingMode(PS_RedundancyEncodingMode x, PS_InStream stream);
+void Decode_SecondaryEncoding(PS_SecondaryEncoding x, PS_InStream stream);
+void Decode_VideoMode(PS_VideoMode x, PS_InStream stream);
+void Decode_H261VideoMode(PS_H261VideoMode x, PS_InStream stream);
+void Decode_Resolution(PS_Resolution x, PS_InStream stream);
+void Decode_H262VideoMode(PS_H262VideoMode x, PS_InStream stream);
+void Decode_ProfileAndLevel(PS_ProfileAndLevel x, PS_InStream stream);
+void Decode_H263VideoMode(PS_H263VideoMode x, PS_InStream stream);
+void Decode_H263Resolution(PS_H263Resolution x, PS_InStream stream);
+void Decode_IS11172VideoMode(PS_IS11172VideoMode x, PS_InStream stream);
+void Decode_AudioMode(PS_AudioMode x, PS_InStream stream);
+void Decode_ModeG7231(PS_ModeG7231 x, PS_InStream stream);
+void Decode_IS11172AudioMode(PS_IS11172AudioMode x, PS_InStream stream);
+void Decode_MultichannelType(PS_MultichannelType x, PS_InStream stream);
+void Decode_AudioSampling(PS_AudioSampling x, PS_InStream stream);
+void Decode_AudioLayer(PS_AudioLayer x, PS_InStream stream);
+void Decode_IS13818AudioMode(PS_IS13818AudioMode x, PS_InStream stream);
+void Decode_Is13818MultichannelType(PS_Is13818MultichannelType x, PS_InStream stream);
+void Decode_Is13818AudioSampling(PS_Is13818AudioSampling x, PS_InStream stream);
+void Decode_Is13818AudioLayer(PS_Is13818AudioLayer x, PS_InStream stream);
+void Decode_G7231AnnexCMode(PS_G7231AnnexCMode x, PS_InStream stream);
+void Decode_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x, PS_InStream stream);
+void Decode_DataMode(PS_DataMode x, PS_InStream stream);
+void Decode_DmApplication(PS_DmApplication x, PS_InStream stream);
+void Decode_DmT38fax(PS_DmT38fax x, PS_InStream stream);
+void Decode_DmNlpid(PS_DmNlpid x, PS_InStream stream);
+void Decode_EncryptionMode(PS_EncryptionMode x, PS_InStream stream);
+void Decode_RoundTripDelayRequest(PS_RoundTripDelayRequest x, PS_InStream stream);
+void Decode_RoundTripDelayResponse(PS_RoundTripDelayResponse x, PS_InStream stream);
+void Decode_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x, PS_InStream stream);
+void Decode_MlRequestType(PS_MlRequestType x, PS_InStream stream);
+void Decode_MaintenanceLoopAck(PS_MaintenanceLoopAck x, PS_InStream stream);
+void Decode_MlAckType(PS_MlAckType x, PS_InStream stream);
+void Decode_MaintenanceLoopReject(PS_MaintenanceLoopReject x, PS_InStream stream);
+void Decode_MlRejectCause(PS_MlRejectCause x, PS_InStream stream);
+void Decode_MlRejectType(PS_MlRejectType x, PS_InStream stream);
+void Decode_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x, PS_InStream stream);
+void Decode_CommunicationModeCommand(PS_CommunicationModeCommand x, PS_InStream stream);
+void Decode_CommunicationModeRequest(PS_CommunicationModeRequest x, PS_InStream stream);
+void Decode_CommunicationModeResponse(PS_CommunicationModeResponse x, PS_InStream stream);
+void Decode_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x, PS_InStream stream);
+void Decode_CmtDataType(PS_CmtDataType x, PS_InStream stream);
+void Decode_ConferenceRequest(PS_ConferenceRequest x, PS_InStream stream);
+void Decode_RequestTerminalCertificate(PS_RequestTerminalCertificate x, PS_InStream stream);
+void Decode_CertSelectionCriteria(PS_CertSelectionCriteria x, PS_InStream stream);
+void Decode_Criteria(PS_Criteria x, PS_InStream stream);
+void Decode_TerminalLabel(PS_TerminalLabel x, PS_InStream stream);
+void Decode_ConferenceResponse(PS_ConferenceResponse x, PS_InStream stream);
+void Decode_SendThisSourceResponse(PS_SendThisSourceResponse x, PS_InStream stream);
+void Decode_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x, PS_InStream stream);
+void Decode_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x, PS_InStream stream);
+void Decode_TerminalCertificateResponse(PS_TerminalCertificateResponse x, PS_InStream stream);
+void Decode_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x, PS_InStream stream);
+void Decode_ExtensionAddressResponse(PS_ExtensionAddressResponse x, PS_InStream stream);
+void Decode_MakeMeChairResponse(PS_MakeMeChairResponse x, PS_InStream stream);
+void Decode_PasswordResponse(PS_PasswordResponse x, PS_InStream stream);
+void Decode_ConferenceIDResponse(PS_ConferenceIDResponse x, PS_InStream stream);
+void Decode_TerminalIDResponse(PS_TerminalIDResponse x, PS_InStream stream);
+void Decode_MCTerminalIDResponse(PS_MCTerminalIDResponse x, PS_InStream stream);
+void Decode_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x, PS_InStream stream);
+void Decode_TerminalInformation(PS_TerminalInformation x, PS_InStream stream);
+void Decode_RemoteMCRequest(PS_RemoteMCRequest x, PS_InStream stream);
+void Decode_RemoteMCResponse(PS_RemoteMCResponse x, PS_InStream stream);
+void Decode_Reject(PS_Reject x, PS_InStream stream);
+void Decode_MultilinkRequest(PS_MultilinkRequest x, PS_InStream stream);
+void Decode_MaximumHeaderInterval(PS_MaximumHeaderInterval x, PS_InStream stream);
+void Decode_RequestType(PS_RequestType x, PS_InStream stream);
+void Decode_RemoveConnection(PS_RemoveConnection x, PS_InStream stream);
+void Decode_AddConnection(PS_AddConnection x, PS_InStream stream);
+void Decode_CallInformation(PS_CallInformation x, PS_InStream stream);
+void Decode_MultilinkResponse(PS_MultilinkResponse x, PS_InStream stream);
+void Decode_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x, PS_InStream stream);
+void Decode_RespRemoveConnection(PS_RespRemoveConnection x, PS_InStream stream);
+void Decode_RespAddConnection(PS_RespAddConnection x, PS_InStream stream);
+void Decode_ResponseCode(PS_ResponseCode x, PS_InStream stream);
+void Decode_Rejected(PS_Rejected x, PS_InStream stream);
+void Decode_RespCallInformation(PS_RespCallInformation x, PS_InStream stream);
+void Decode_MultilinkIndication(PS_MultilinkIndication x, PS_InStream stream);
+void Decode_ExcessiveError(PS_ExcessiveError x, PS_InStream stream);
+void Decode_CrcDesired(PS_CrcDesired x, PS_InStream stream);
+void Decode_DialingInformation(PS_DialingInformation x, PS_InStream stream);
+void Decode_DialingInformationNumber(PS_DialingInformationNumber x, PS_InStream stream);
+void Decode_DialingInformationNetworkType(PS_DialingInformationNetworkType x, PS_InStream stream);
+void Decode_ConnectionIdentifier(PS_ConnectionIdentifier x, PS_InStream stream);
+void Decode_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x, PS_InStream stream);
+void Decode_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x, PS_InStream stream);
+void Decode_LogicalChannelRateReject(PS_LogicalChannelRateReject x, PS_InStream stream);
+void Decode_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x, PS_InStream stream);
+void Decode_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x, PS_InStream stream);
+void Decode_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x, PS_InStream stream);
+void Decode_SpecificRequest(PS_SpecificRequest x, PS_InStream stream);
+void Decode_EncryptionCommand(PS_EncryptionCommand x, PS_InStream stream);
+void Decode_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x, PS_InStream stream);
+void Decode_FlowControlCommand(PS_FlowControlCommand x, PS_InStream stream);
+void Decode_FccRestriction(PS_FccRestriction x, PS_InStream stream);
+void Decode_FccScope(PS_FccScope x, PS_InStream stream);
+void Decode_EndSessionCommand(PS_EndSessionCommand x, PS_InStream stream);
+void Decode_IsdnOptions(PS_IsdnOptions x, PS_InStream stream);
+void Decode_GstnOptions(PS_GstnOptions x, PS_InStream stream);
+void Decode_ConferenceCommand(PS_ConferenceCommand x, PS_InStream stream);
+void Decode_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x, PS_InStream stream);
+void Decode_MiscellaneousCommand(PS_MiscellaneousCommand x, PS_InStream stream);
+void Decode_McType(PS_McType x, PS_InStream stream);
+void Decode_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x, PS_InStream stream);
+void Decode_PrsRepeatCount(PS_PrsRepeatCount x, PS_InStream stream);
+void Decode_VideoFastUpdateMB(PS_VideoFastUpdateMB x, PS_InStream stream);
+void Decode_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x, PS_InStream stream);
+void Decode_KeyProtectionMethod(PS_KeyProtectionMethod x, PS_InStream stream);
+void Decode_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x, PS_InStream stream);
+void Decode_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x, PS_InStream stream);
+void Decode_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x, PS_InStream stream);
+void Decode_H223ModeChange(PS_H223ModeChange x, PS_InStream stream);
+void Decode_NewATMVCCommand(PS_NewATMVCCommand x, PS_InStream stream);
+void Decode_CmdReverseParameters(PS_CmdReverseParameters x, PS_InStream stream);
+void Decode_Multiplex(PS_Multiplex x, PS_InStream stream);
+void Decode_CmdMultiplex(PS_CmdMultiplex x, PS_InStream stream);
+void Decode_CmdAal(PS_CmdAal x, PS_InStream stream);
+void Decode_CmdAal5(PS_CmdAal5 x, PS_InStream stream);
+void Decode_CmdAal1(PS_CmdAal1 x, PS_InStream stream);
+void Decode_CmdErrorCorrection(PS_CmdErrorCorrection x, PS_InStream stream);
+void Decode_CmdClockRecovery(PS_CmdClockRecovery x, PS_InStream stream);
+void Decode_FunctionNotUnderstood(PS_FunctionNotUnderstood x, PS_InStream stream);
+void Decode_FunctionNotSupported(PS_FunctionNotSupported x, PS_InStream stream);
+void Decode_FnsCause(PS_FnsCause x, PS_InStream stream);
+void Decode_ConferenceIndication(PS_ConferenceIndication x, PS_InStream stream);
+void Decode_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x, PS_InStream stream);
+void Decode_VideoIndicateCompose(PS_VideoIndicateCompose x, PS_InStream stream);
+void Decode_MiscellaneousIndication(PS_MiscellaneousIndication x, PS_InStream stream);
+void Decode_MiType(PS_MiType x, PS_InStream stream);
+void Decode_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x, PS_InStream stream);
+void Decode_JitterIndication(PS_JitterIndication x, PS_InStream stream);
+void Decode_JiScope(PS_JiScope x, PS_InStream stream);
+void Decode_H223SkewIndication(PS_H223SkewIndication x, PS_InStream stream);
+void Decode_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x, PS_InStream stream);
+void Decode_MCLocationIndication(PS_MCLocationIndication x, PS_InStream stream);
+void Decode_VendorIdentification(PS_VendorIdentification x, PS_InStream stream);
+void Decode_NewATMVCIndication(PS_NewATMVCIndication x, PS_InStream stream);
+void Decode_IndReverseParameters(PS_IndReverseParameters x, PS_InStream stream);
+void Decode_IrpMultiplex(PS_IrpMultiplex x, PS_InStream stream);
+void Decode_IndMultiplex(PS_IndMultiplex x, PS_InStream stream);
+void Decode_IndAal(PS_IndAal x, PS_InStream stream);
+void Decode_IndAal5(PS_IndAal5 x, PS_InStream stream);
+void Decode_IndAal1(PS_IndAal1 x, PS_InStream stream);
+void Decode_IndErrorCorrection(PS_IndErrorCorrection x, PS_InStream stream);
+void Decode_IndClockRecovery(PS_IndClockRecovery x, PS_InStream stream);
+void Decode_UserInputIndication(PS_UserInputIndication x, PS_InStream stream);
+void Decode_SignalUpdate(PS_SignalUpdate x, PS_InStream stream);
+void Decode_Rtp(PS_Rtp x, PS_InStream stream);
+void Decode_Signal(PS_Signal x, PS_InStream stream);
+void Decode_SignalRtp(PS_SignalRtp x, PS_InStream stream);
+void Decode_UserInputSupportIndication(PS_UserInputSupportIndication x, PS_InStream stream);
+void Decode_FlowControlIndication(PS_FlowControlIndication x, PS_InStream stream);
+void Decode_FciRestriction(PS_FciRestriction x, PS_InStream stream);
+void Decode_FciScope(PS_FciScope x, PS_InStream stream);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_deleter.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_deleter.h
new file mode 100644
index 0000000..5e1abf8
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_deleter.h
@@ -0,0 +1,411 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_deleter.h
+//
+// DESC: PER Delete routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#ifndef PER_DELETER
+#define PER_DELETER
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+void Delete_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x);
+void Delete_RequestMessage(PS_RequestMessage x);
+void Delete_ResponseMessage(PS_ResponseMessage x);
+void Delete_CommandMessage(PS_CommandMessage x);
+void Delete_IndicationMessage(PS_IndicationMessage x);
+void Delete_GenericInformation(PS_GenericInformation x);
+void Delete_NonStandardMessage(PS_NonStandardMessage x);
+void Delete_NonStandardParameter(PS_NonStandardParameter x);
+void Delete_NonStandardIdentifier(PS_NonStandardIdentifier x);
+void Delete_H221NonStandard(PS_H221NonStandard x);
+void Delete_MasterSlaveDetermination(PS_MasterSlaveDetermination x);
+void Delete_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x);
+void Delete_Decision(PS_Decision x);
+void Delete_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x);
+void Delete_MsdRejectCause(PS_MsdRejectCause x);
+void Delete_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x);
+void Delete_TerminalCapabilitySet(PS_TerminalCapabilitySet x);
+void Delete_CapabilityTableEntry(PS_CapabilityTableEntry x);
+void Delete_CapabilityDescriptor(PS_CapabilityDescriptor x);
+void Delete_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x);
+void Delete_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x);
+void Delete_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x);
+void Delete_TcsRejectCause(PS_TcsRejectCause x);
+void Delete_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x);
+void Delete_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x);
+void Delete_Capability(PS_Capability x);
+void Delete_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x);
+void Delete_H235SecurityCapability(PS_H235SecurityCapability x);
+void Delete_MultiplexCapability(PS_MultiplexCapability x);
+void Delete_H222Capability(PS_H222Capability x);
+void Delete_VCCapability(PS_VCCapability x);
+void Delete_Aal1ViaGateway(PS_Aal1ViaGateway x);
+void Delete_AvailableBitRates(PS_AvailableBitRates x);
+void Delete_VccAal5Type(PS_VccAal5Type x);
+void Delete_RangeOfBitRates(PS_RangeOfBitRates x);
+void Delete_VccAal5(PS_VccAal5 x);
+void Delete_VccAal1(PS_VccAal1 x);
+void Delete_H223Capability(PS_H223Capability x);
+void Delete_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x);
+void Delete_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x);
+void Delete_Enhanced(PS_Enhanced x);
+void Delete_H223AnnexCCapability(PS_H223AnnexCCapability x);
+void Delete_V76Capability(PS_V76Capability x);
+void Delete_V75Capability(PS_V75Capability x);
+void Delete_H2250Capability(PS_H2250Capability x);
+void Delete_McCapability(PS_McCapability x);
+void Delete_MediaPacketizationCapability(PS_MediaPacketizationCapability x);
+void Delete_RSVPParameters(PS_RSVPParameters x);
+void Delete_QOSMode(PS_QOSMode x);
+void Delete_ATMParameters(PS_ATMParameters x);
+void Delete_QOSCapability(PS_QOSCapability x);
+void Delete_MediaTransportType(PS_MediaTransportType x);
+void Delete_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x);
+void Delete_MediaChannelCapability(PS_MediaChannelCapability x);
+void Delete_TransportCapability(PS_TransportCapability x);
+void Delete_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x);
+void Delete_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x);
+void Delete_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x);
+void Delete_FrameToThreadMapping(PS_FrameToThreadMapping x);
+void Delete_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x);
+void Delete_MultipointCapability(PS_MultipointCapability x);
+void Delete_MediaDistributionCapability(PS_MediaDistributionCapability x);
+void Delete_VideoCapability(PS_VideoCapability x);
+void Delete_H261VideoCapability(PS_H261VideoCapability x);
+void Delete_H262VideoCapability(PS_H262VideoCapability x);
+void Delete_H263VideoCapability(PS_H263VideoCapability x);
+void Delete_EnhancementLayerInfo(PS_EnhancementLayerInfo x);
+void Delete_BEnhancementParameters(PS_BEnhancementParameters x);
+void Delete_EnhancementOptions(PS_EnhancementOptions x);
+void Delete_H263Options(PS_H263Options x);
+void Delete_TransparencyParameters(PS_TransparencyParameters x);
+void Delete_RefPictureSelection(PS_RefPictureSelection x);
+void Delete_VideoBackChannelSend(PS_VideoBackChannelSend x);
+void Delete_AdditionalPictureMemory(PS_AdditionalPictureMemory x);
+void Delete_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x);
+void Delete_CustomPictureFormat(PS_CustomPictureFormat x);
+void Delete_PixelAspectInformation(PS_PixelAspectInformation x);
+void Delete_ExtendedPARItem(PS_ExtendedPARItem x);
+void Delete_MPI(PS_MPI x);
+void Delete_CustomPCFItem(PS_CustomPCFItem x);
+void Delete_H263VideoModeCombos(PS_H263VideoModeCombos x);
+void Delete_H263ModeComboFlags(PS_H263ModeComboFlags x);
+void Delete_IS11172VideoCapability(PS_IS11172VideoCapability x);
+void Delete_AudioCapability(PS_AudioCapability x);
+void Delete_G7231(PS_G7231 x);
+void Delete_G729Extensions(PS_G729Extensions x);
+void Delete_G7231AnnexCCapability(PS_G7231AnnexCCapability x);
+void Delete_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x);
+void Delete_IS11172AudioCapability(PS_IS11172AudioCapability x);
+void Delete_IS13818AudioCapability(PS_IS13818AudioCapability x);
+void Delete_GSMAudioCapability(PS_GSMAudioCapability x);
+void Delete_DataApplicationCapability(PS_DataApplicationCapability x);
+void Delete_Application(PS_Application x);
+void Delete_T38fax(PS_T38fax x);
+void Delete_Nlpid(PS_Nlpid x);
+void Delete_T84(PS_T84 x);
+void Delete_DataProtocolCapability(PS_DataProtocolCapability x);
+void Delete_V76wCompression(PS_V76wCompression x);
+void Delete_CompressionType(PS_CompressionType x);
+void Delete_V42bis(PS_V42bis x);
+void Delete_T84Profile(PS_T84Profile x);
+void Delete_T84Restricted(PS_T84Restricted x);
+void Delete_T38FaxProfile(PS_T38FaxProfile x);
+void Delete_T38FaxRateManagement(PS_T38FaxRateManagement x);
+void Delete_T38FaxUdpOptions(PS_T38FaxUdpOptions x);
+void Delete_T38FaxUdpEC(PS_T38FaxUdpEC x);
+void Delete_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x);
+void Delete_EncryptionCapability(PS_EncryptionCapability x);
+void Delete_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x);
+void Delete_AuthenticationCapability(PS_AuthenticationCapability x);
+void Delete_IntegrityCapability(PS_IntegrityCapability x);
+void Delete_UserInputCapability(PS_UserInputCapability x);
+void Delete_ConferenceCapability(PS_ConferenceCapability x);
+void Delete_GenericCapability(PS_GenericCapability x);
+void Delete_CapabilityIdentifier(PS_CapabilityIdentifier x);
+void Delete_GenericParameter(PS_GenericParameter x);
+void Delete_ParameterIdentifier(PS_ParameterIdentifier x);
+void Delete_ParameterValue(PS_ParameterValue x);
+void Delete_OpenLogicalChannel(PS_OpenLogicalChannel x);
+void Delete_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x);
+void Delete_RlcMultiplexParameters(PS_RlcMultiplexParameters x);
+void Delete_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x);
+void Delete_MultiplexParameters(PS_MultiplexParameters x);
+void Delete_NetworkAccessParameters(PS_NetworkAccessParameters x);
+void Delete_T120SetupProcedure(PS_T120SetupProcedure x);
+void Delete_NetworkAddress(PS_NetworkAddress x);
+void Delete_Distribution(PS_Distribution x);
+void Delete_Q2931Address(PS_Q2931Address x);
+void Delete_Address(PS_Address x);
+void Delete_V75Parameters(PS_V75Parameters x);
+OSCL_IMPORT_REF void Delete_DataType(PS_DataType x);
+void Delete_H235Media(PS_H235Media x);
+void Delete_MediaType(PS_MediaType x);
+void Delete_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x);
+OSCL_IMPORT_REF void Delete_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x);
+void Delete_AdaptationLayerType(PS_AdaptationLayerType x);
+void Delete_Al3(PS_Al3 x);
+void Delete_H223AL1MParameters(PS_H223AL1MParameters x);
+void Delete_ArqType(PS_ArqType x);
+void Delete_CrcLength(PS_CrcLength x);
+void Delete_HeaderFEC(PS_HeaderFEC x);
+void Delete_TransferMode(PS_TransferMode x);
+void Delete_H223AL2MParameters(PS_H223AL2MParameters x);
+void Delete_Al2HeaderFEC(PS_Al2HeaderFEC x);
+void Delete_H223AL3MParameters(PS_H223AL3MParameters x);
+void Delete_Al3ArqType(PS_Al3ArqType x);
+void Delete_Al3CrcLength(PS_Al3CrcLength x);
+void Delete_HeaderFormat(PS_HeaderFormat x);
+void Delete_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x);
+void Delete_NumberOfRetransmissions(PS_NumberOfRetransmissions x);
+void Delete_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x);
+void Delete_Mode(PS_Mode x);
+void Delete_ERM(PS_ERM x);
+void Delete_Recovery(PS_Recovery x);
+void Delete_SuspendResume(PS_SuspendResume x);
+void Delete_V76HDLCParameters(PS_V76HDLCParameters x);
+void Delete_CRCLength(PS_CRCLength x);
+void Delete_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x);
+void Delete_MediaPacketization(PS_MediaPacketization x);
+void Delete_RTPPayloadType(PS_RTPPayloadType x);
+void Delete_PayloadDescriptor(PS_PayloadDescriptor x);
+void Delete_RedundancyEncoding(PS_RedundancyEncoding x);
+void Delete_TransportAddress(PS_TransportAddress x);
+void Delete_UnicastAddress(PS_UnicastAddress x);
+void Delete_IPSourceRouteAddress(PS_IPSourceRouteAddress x);
+void Delete_Routing(PS_Routing x);
+void Delete_IP6Address(PS_IP6Address x);
+void Delete_IPXAddress(PS_IPXAddress x);
+void Delete_IPAddress(PS_IPAddress x);
+void Delete_MulticastAddress(PS_MulticastAddress x);
+void Delete_MaIp6Address(PS_MaIp6Address x);
+void Delete_MaIpAddress(PS_MaIpAddress x);
+void Delete_EncryptionSync(PS_EncryptionSync x);
+void Delete_EscrowData(PS_EscrowData x);
+void Delete_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x);
+void Delete_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x);
+void Delete_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x);
+void Delete_AckMultiplexParameters(PS_AckMultiplexParameters x);
+void Delete_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x);
+void Delete_OlcRejectCause(PS_OlcRejectCause x);
+void Delete_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x);
+void Delete_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x);
+void Delete_CloseLogicalChannel(PS_CloseLogicalChannel x);
+void Delete_Reason(PS_Reason x);
+void Delete_Source(PS_Source x);
+void Delete_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x);
+void Delete_RequestChannelClose(PS_RequestChannelClose x);
+void Delete_RccReason(PS_RccReason x);
+void Delete_RequestChannelCloseAck(PS_RequestChannelCloseAck x);
+void Delete_RequestChannelCloseReject(PS_RequestChannelCloseReject x);
+void Delete_RccRejectCause(PS_RccRejectCause x);
+void Delete_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x);
+void Delete_MultiplexEntrySend(PS_MultiplexEntrySend x);
+OSCL_IMPORT_REF void Delete_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x);
+void Delete_MultiplexElement(PS_MultiplexElement x);
+void Delete_RepeatCount(PS_RepeatCount x);
+void Delete_MuxType(PS_MuxType x);
+void Delete_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x);
+void Delete_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x);
+void Delete_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x);
+void Delete_MeRejectCause(PS_MeRejectCause x);
+void Delete_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x);
+void Delete_RequestMultiplexEntry(PS_RequestMultiplexEntry x);
+void Delete_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x);
+void Delete_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x);
+void Delete_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x);
+void Delete_RmeRejectCause(PS_RmeRejectCause x);
+void Delete_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x);
+void Delete_RequestMode(PS_RequestMode x);
+void Delete_RequestModeAck(PS_RequestModeAck x);
+void Delete_Response(PS_Response x);
+void Delete_RequestModeReject(PS_RequestModeReject x);
+void Delete_RmRejectCause(PS_RmRejectCause x);
+void Delete_RequestModeRelease(PS_RequestModeRelease x);
+void Delete_ModeDescription(PS_ModeDescription x);
+void Delete_ModeElement(PS_ModeElement x);
+void Delete_ModeType(PS_ModeType x);
+void Delete_H235Mode(PS_H235Mode x);
+void Delete_MediaMode(PS_MediaMode x);
+void Delete_H223ModeParameters(PS_H223ModeParameters x);
+void Delete_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x);
+void Delete_ModeAl3(PS_ModeAl3 x);
+void Delete_V76ModeParameters(PS_V76ModeParameters x);
+void Delete_H2250ModeParameters(PS_H2250ModeParameters x);
+void Delete_RedundancyEncodingMode(PS_RedundancyEncodingMode x);
+void Delete_SecondaryEncoding(PS_SecondaryEncoding x);
+void Delete_VideoMode(PS_VideoMode x);
+void Delete_H261VideoMode(PS_H261VideoMode x);
+void Delete_Resolution(PS_Resolution x);
+void Delete_H262VideoMode(PS_H262VideoMode x);
+void Delete_ProfileAndLevel(PS_ProfileAndLevel x);
+void Delete_H263VideoMode(PS_H263VideoMode x);
+void Delete_H263Resolution(PS_H263Resolution x);
+void Delete_IS11172VideoMode(PS_IS11172VideoMode x);
+void Delete_AudioMode(PS_AudioMode x);
+void Delete_ModeG7231(PS_ModeG7231 x);
+void Delete_IS11172AudioMode(PS_IS11172AudioMode x);
+void Delete_MultichannelType(PS_MultichannelType x);
+void Delete_AudioSampling(PS_AudioSampling x);
+void Delete_AudioLayer(PS_AudioLayer x);
+void Delete_IS13818AudioMode(PS_IS13818AudioMode x);
+void Delete_Is13818MultichannelType(PS_Is13818MultichannelType x);
+void Delete_Is13818AudioSampling(PS_Is13818AudioSampling x);
+void Delete_Is13818AudioLayer(PS_Is13818AudioLayer x);
+void Delete_G7231AnnexCMode(PS_G7231AnnexCMode x);
+void Delete_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x);
+void Delete_DataMode(PS_DataMode x);
+void Delete_DmApplication(PS_DmApplication x);
+void Delete_DmT38fax(PS_DmT38fax x);
+void Delete_DmNlpid(PS_DmNlpid x);
+void Delete_EncryptionMode(PS_EncryptionMode x);
+void Delete_RoundTripDelayRequest(PS_RoundTripDelayRequest x);
+void Delete_RoundTripDelayResponse(PS_RoundTripDelayResponse x);
+void Delete_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x);
+void Delete_MlRequestType(PS_MlRequestType x);
+void Delete_MaintenanceLoopAck(PS_MaintenanceLoopAck x);
+void Delete_MlAckType(PS_MlAckType x);
+void Delete_MaintenanceLoopReject(PS_MaintenanceLoopReject x);
+void Delete_MlRejectCause(PS_MlRejectCause x);
+void Delete_MlRejectType(PS_MlRejectType x);
+void Delete_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x);
+void Delete_CommunicationModeCommand(PS_CommunicationModeCommand x);
+void Delete_CommunicationModeRequest(PS_CommunicationModeRequest x);
+void Delete_CommunicationModeResponse(PS_CommunicationModeResponse x);
+void Delete_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x);
+void Delete_CmtDataType(PS_CmtDataType x);
+void Delete_ConferenceRequest(PS_ConferenceRequest x);
+void Delete_RequestTerminalCertificate(PS_RequestTerminalCertificate x);
+void Delete_CertSelectionCriteria(PS_CertSelectionCriteria x);
+void Delete_Criteria(PS_Criteria x);
+void Delete_TerminalLabel(PS_TerminalLabel x);
+void Delete_ConferenceResponse(PS_ConferenceResponse x);
+void Delete_SendThisSourceResponse(PS_SendThisSourceResponse x);
+void Delete_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x);
+void Delete_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x);
+void Delete_TerminalCertificateResponse(PS_TerminalCertificateResponse x);
+void Delete_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x);
+void Delete_ExtensionAddressResponse(PS_ExtensionAddressResponse x);
+void Delete_MakeMeChairResponse(PS_MakeMeChairResponse x);
+void Delete_PasswordResponse(PS_PasswordResponse x);
+void Delete_ConferenceIDResponse(PS_ConferenceIDResponse x);
+void Delete_TerminalIDResponse(PS_TerminalIDResponse x);
+void Delete_MCTerminalIDResponse(PS_MCTerminalIDResponse x);
+void Delete_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x);
+void Delete_TerminalInformation(PS_TerminalInformation x);
+void Delete_RemoteMCRequest(PS_RemoteMCRequest x);
+void Delete_RemoteMCResponse(PS_RemoteMCResponse x);
+void Delete_Reject(PS_Reject x);
+void Delete_MultilinkRequest(PS_MultilinkRequest x);
+void Delete_MaximumHeaderInterval(PS_MaximumHeaderInterval x);
+void Delete_RequestType(PS_RequestType x);
+void Delete_RemoveConnection(PS_RemoveConnection x);
+void Delete_AddConnection(PS_AddConnection x);
+void Delete_CallInformation(PS_CallInformation x);
+void Delete_MultilinkResponse(PS_MultilinkResponse x);
+void Delete_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x);
+void Delete_RespRemoveConnection(PS_RespRemoveConnection x);
+void Delete_RespAddConnection(PS_RespAddConnection x);
+void Delete_ResponseCode(PS_ResponseCode x);
+void Delete_Rejected(PS_Rejected x);
+void Delete_RespCallInformation(PS_RespCallInformation x);
+void Delete_MultilinkIndication(PS_MultilinkIndication x);
+void Delete_ExcessiveError(PS_ExcessiveError x);
+void Delete_CrcDesired(PS_CrcDesired x);
+void Delete_DialingInformation(PS_DialingInformation x);
+void Delete_DialingInformationNumber(PS_DialingInformationNumber x);
+void Delete_DialingInformationNetworkType(PS_DialingInformationNetworkType x);
+void Delete_ConnectionIdentifier(PS_ConnectionIdentifier x);
+void Delete_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x);
+void Delete_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x);
+void Delete_LogicalChannelRateReject(PS_LogicalChannelRateReject x);
+void Delete_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x);
+void Delete_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x);
+void Delete_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x);
+void Delete_SpecificRequest(PS_SpecificRequest x);
+void Delete_EncryptionCommand(PS_EncryptionCommand x);
+void Delete_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x);
+void Delete_FlowControlCommand(PS_FlowControlCommand x);
+void Delete_FccRestriction(PS_FccRestriction x);
+void Delete_FccScope(PS_FccScope x);
+void Delete_EndSessionCommand(PS_EndSessionCommand x);
+void Delete_IsdnOptions(PS_IsdnOptions x);
+void Delete_GstnOptions(PS_GstnOptions x);
+void Delete_ConferenceCommand(PS_ConferenceCommand x);
+void Delete_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x);
+void Delete_MiscellaneousCommand(PS_MiscellaneousCommand x);
+void Delete_McType(PS_McType x);
+void Delete_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x);
+void Delete_PrsRepeatCount(PS_PrsRepeatCount x);
+void Delete_VideoFastUpdateMB(PS_VideoFastUpdateMB x);
+void Delete_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x);
+void Delete_KeyProtectionMethod(PS_KeyProtectionMethod x);
+void Delete_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x);
+void Delete_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x);
+void Delete_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x);
+void Delete_H223ModeChange(PS_H223ModeChange x);
+void Delete_NewATMVCCommand(PS_NewATMVCCommand x);
+void Delete_CmdReverseParameters(PS_CmdReverseParameters x);
+void Delete_Multiplex(PS_Multiplex x);
+void Delete_CmdMultiplex(PS_CmdMultiplex x);
+void Delete_CmdAal(PS_CmdAal x);
+void Delete_CmdAal5(PS_CmdAal5 x);
+void Delete_CmdAal1(PS_CmdAal1 x);
+void Delete_CmdErrorCorrection(PS_CmdErrorCorrection x);
+void Delete_CmdClockRecovery(PS_CmdClockRecovery x);
+void Delete_FunctionNotUnderstood(PS_FunctionNotUnderstood x);
+void Delete_FunctionNotSupported(PS_FunctionNotSupported x);
+void Delete_FnsCause(PS_FnsCause x);
+void Delete_ConferenceIndication(PS_ConferenceIndication x);
+void Delete_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x);
+void Delete_VideoIndicateCompose(PS_VideoIndicateCompose x);
+void Delete_MiscellaneousIndication(PS_MiscellaneousIndication x);
+void Delete_MiType(PS_MiType x);
+void Delete_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x);
+void Delete_JitterIndication(PS_JitterIndication x);
+void Delete_JiScope(PS_JiScope x);
+void Delete_H223SkewIndication(PS_H223SkewIndication x);
+void Delete_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x);
+void Delete_MCLocationIndication(PS_MCLocationIndication x);
+void Delete_VendorIdentification(PS_VendorIdentification x);
+void Delete_NewATMVCIndication(PS_NewATMVCIndication x);
+void Delete_IndReverseParameters(PS_IndReverseParameters x);
+void Delete_IrpMultiplex(PS_IrpMultiplex x);
+void Delete_IndMultiplex(PS_IndMultiplex x);
+void Delete_IndAal(PS_IndAal x);
+void Delete_IndAal5(PS_IndAal5 x);
+void Delete_IndAal1(PS_IndAal1 x);
+void Delete_IndErrorCorrection(PS_IndErrorCorrection x);
+void Delete_IndClockRecovery(PS_IndClockRecovery x);
+void Delete_UserInputIndication(PS_UserInputIndication x);
+void Delete_SignalUpdate(PS_SignalUpdate x);
+void Delete_Rtp(PS_Rtp x);
+void Delete_Signal(PS_Signal x);
+void Delete_SignalRtp(PS_SignalRtp x);
+void Delete_UserInputSupportIndication(PS_UserInputSupportIndication x);
+void Delete_FlowControlIndication(PS_FlowControlIndication x);
+void Delete_FciRestriction(PS_FciRestriction x);
+void Delete_FciScope(PS_FciScope x);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_encoder.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_encoder.h
new file mode 100644
index 0000000..cdbdc69
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/h245_encoder.h
@@ -0,0 +1,409 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_encoder.h
+//
+// DESC: PER Encode routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#ifndef PER_ENCODER
+#define PER_ENCODER
+
+void Encode_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x, PS_OutStream stream);
+void Encode_RequestMessage(PS_RequestMessage x, PS_OutStream stream);
+void Encode_ResponseMessage(PS_ResponseMessage x, PS_OutStream stream);
+void Encode_CommandMessage(PS_CommandMessage x, PS_OutStream stream);
+void Encode_IndicationMessage(PS_IndicationMessage x, PS_OutStream stream);
+void Encode_GenericInformation(PS_GenericInformation x, PS_OutStream stream);
+void Encode_NonStandardMessage(PS_NonStandardMessage x, PS_OutStream stream);
+void Encode_NonStandardParameter(PS_NonStandardParameter x, PS_OutStream stream);
+void Encode_NonStandardIdentifier(PS_NonStandardIdentifier x, PS_OutStream stream);
+void Encode_H221NonStandard(PS_H221NonStandard x, PS_OutStream stream);
+void Encode_MasterSlaveDetermination(PS_MasterSlaveDetermination x, PS_OutStream stream);
+void Encode_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x, PS_OutStream stream);
+void Encode_Decision(PS_Decision x, PS_OutStream stream);
+void Encode_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x, PS_OutStream stream);
+void Encode_MsdRejectCause(PS_MsdRejectCause x, PS_OutStream stream);
+void Encode_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x, PS_OutStream stream);
+void Encode_TerminalCapabilitySet(PS_TerminalCapabilitySet x, PS_OutStream stream);
+void Encode_CapabilityTableEntry(PS_CapabilityTableEntry x, PS_OutStream stream);
+void Encode_CapabilityDescriptor(PS_CapabilityDescriptor x, PS_OutStream stream);
+void Encode_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x, PS_OutStream stream);
+void Encode_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x, PS_OutStream stream);
+void Encode_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x, PS_OutStream stream);
+void Encode_TcsRejectCause(PS_TcsRejectCause x, PS_OutStream stream);
+void Encode_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x, PS_OutStream stream);
+void Encode_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x, PS_OutStream stream);
+void Encode_Capability(PS_Capability x, PS_OutStream stream);
+void Encode_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x, PS_OutStream stream);
+void Encode_H235SecurityCapability(PS_H235SecurityCapability x, PS_OutStream stream);
+void Encode_MultiplexCapability(PS_MultiplexCapability x, PS_OutStream stream);
+void Encode_H222Capability(PS_H222Capability x, PS_OutStream stream);
+void Encode_VCCapability(PS_VCCapability x, PS_OutStream stream);
+void Encode_Aal1ViaGateway(PS_Aal1ViaGateway x, PS_OutStream stream);
+void Encode_AvailableBitRates(PS_AvailableBitRates x, PS_OutStream stream);
+void Encode_VccAal5Type(PS_VccAal5Type x, PS_OutStream stream);
+void Encode_RangeOfBitRates(PS_RangeOfBitRates x, PS_OutStream stream);
+void Encode_VccAal5(PS_VccAal5 x, PS_OutStream stream);
+void Encode_VccAal1(PS_VccAal1 x, PS_OutStream stream);
+void Encode_H223Capability(PS_H223Capability x, PS_OutStream stream);
+void Encode_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x, PS_OutStream stream);
+void Encode_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x, PS_OutStream stream);
+void Encode_Enhanced(PS_Enhanced x, PS_OutStream stream);
+void Encode_H223AnnexCCapability(PS_H223AnnexCCapability x, PS_OutStream stream);
+void Encode_V76Capability(PS_V76Capability x, PS_OutStream stream);
+void Encode_V75Capability(PS_V75Capability x, PS_OutStream stream);
+void Encode_H2250Capability(PS_H2250Capability x, PS_OutStream stream);
+void Encode_McCapability(PS_McCapability x, PS_OutStream stream);
+void Encode_MediaPacketizationCapability(PS_MediaPacketizationCapability x, PS_OutStream stream);
+void Encode_RSVPParameters(PS_RSVPParameters x, PS_OutStream stream);
+void Encode_QOSMode(PS_QOSMode x, PS_OutStream stream);
+void Encode_ATMParameters(PS_ATMParameters x, PS_OutStream stream);
+void Encode_QOSCapability(PS_QOSCapability x, PS_OutStream stream);
+void Encode_MediaTransportType(PS_MediaTransportType x, PS_OutStream stream);
+void Encode_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x, PS_OutStream stream);
+void Encode_MediaChannelCapability(PS_MediaChannelCapability x, PS_OutStream stream);
+void Encode_TransportCapability(PS_TransportCapability x, PS_OutStream stream);
+void Encode_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x, PS_OutStream stream);
+void Encode_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x, PS_OutStream stream);
+void Encode_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x, PS_OutStream stream);
+void Encode_FrameToThreadMapping(PS_FrameToThreadMapping x, PS_OutStream stream);
+void Encode_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x, PS_OutStream stream);
+void Encode_MultipointCapability(PS_MultipointCapability x, PS_OutStream stream);
+void Encode_MediaDistributionCapability(PS_MediaDistributionCapability x, PS_OutStream stream);
+void Encode_VideoCapability(PS_VideoCapability x, PS_OutStream stream);
+void Encode_H261VideoCapability(PS_H261VideoCapability x, PS_OutStream stream);
+void Encode_H262VideoCapability(PS_H262VideoCapability x, PS_OutStream stream);
+void Encode_H263VideoCapability(PS_H263VideoCapability x, PS_OutStream stream);
+void Encode_EnhancementLayerInfo(PS_EnhancementLayerInfo x, PS_OutStream stream);
+void Encode_BEnhancementParameters(PS_BEnhancementParameters x, PS_OutStream stream);
+void Encode_EnhancementOptions(PS_EnhancementOptions x, PS_OutStream stream);
+void Encode_H263Options(PS_H263Options x, PS_OutStream stream);
+void Encode_TransparencyParameters(PS_TransparencyParameters x, PS_OutStream stream);
+void Encode_RefPictureSelection(PS_RefPictureSelection x, PS_OutStream stream);
+void Encode_VideoBackChannelSend(PS_VideoBackChannelSend x, PS_OutStream stream);
+void Encode_AdditionalPictureMemory(PS_AdditionalPictureMemory x, PS_OutStream stream);
+void Encode_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x, PS_OutStream stream);
+void Encode_CustomPictureFormat(PS_CustomPictureFormat x, PS_OutStream stream);
+void Encode_PixelAspectInformation(PS_PixelAspectInformation x, PS_OutStream stream);
+void Encode_ExtendedPARItem(PS_ExtendedPARItem x, PS_OutStream stream);
+void Encode_MPI(PS_MPI x, PS_OutStream stream);
+void Encode_CustomPCFItem(PS_CustomPCFItem x, PS_OutStream stream);
+void Encode_H263VideoModeCombos(PS_H263VideoModeCombos x, PS_OutStream stream);
+void Encode_H263ModeComboFlags(PS_H263ModeComboFlags x, PS_OutStream stream);
+void Encode_IS11172VideoCapability(PS_IS11172VideoCapability x, PS_OutStream stream);
+void Encode_AudioCapability(PS_AudioCapability x, PS_OutStream stream);
+void Encode_G7231(PS_G7231 x, PS_OutStream stream);
+void Encode_G729Extensions(PS_G729Extensions x, PS_OutStream stream);
+void Encode_G7231AnnexCCapability(PS_G7231AnnexCCapability x, PS_OutStream stream);
+void Encode_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x, PS_OutStream stream);
+void Encode_IS11172AudioCapability(PS_IS11172AudioCapability x, PS_OutStream stream);
+void Encode_IS13818AudioCapability(PS_IS13818AudioCapability x, PS_OutStream stream);
+void Encode_GSMAudioCapability(PS_GSMAudioCapability x, PS_OutStream stream);
+void Encode_DataApplicationCapability(PS_DataApplicationCapability x, PS_OutStream stream);
+void Encode_Application(PS_Application x, PS_OutStream stream);
+void Encode_T38fax(PS_T38fax x, PS_OutStream stream);
+void Encode_Nlpid(PS_Nlpid x, PS_OutStream stream);
+void Encode_T84(PS_T84 x, PS_OutStream stream);
+void Encode_DataProtocolCapability(PS_DataProtocolCapability x, PS_OutStream stream);
+void Encode_V76wCompression(PS_V76wCompression x, PS_OutStream stream);
+void Encode_CompressionType(PS_CompressionType x, PS_OutStream stream);
+void Encode_V42bis(PS_V42bis x, PS_OutStream stream);
+void Encode_T84Profile(PS_T84Profile x, PS_OutStream stream);
+void Encode_T84Restricted(PS_T84Restricted x, PS_OutStream stream);
+void Encode_T38FaxProfile(PS_T38FaxProfile x, PS_OutStream stream);
+void Encode_T38FaxRateManagement(PS_T38FaxRateManagement x, PS_OutStream stream);
+void Encode_T38FaxUdpOptions(PS_T38FaxUdpOptions x, PS_OutStream stream);
+void Encode_T38FaxUdpEC(PS_T38FaxUdpEC x, PS_OutStream stream);
+void Encode_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x, PS_OutStream stream);
+void Encode_EncryptionCapability(PS_EncryptionCapability x, PS_OutStream stream);
+void Encode_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x, PS_OutStream stream);
+void Encode_AuthenticationCapability(PS_AuthenticationCapability x, PS_OutStream stream);
+void Encode_IntegrityCapability(PS_IntegrityCapability x, PS_OutStream stream);
+void Encode_UserInputCapability(PS_UserInputCapability x, PS_OutStream stream);
+void Encode_ConferenceCapability(PS_ConferenceCapability x, PS_OutStream stream);
+void Encode_GenericCapability(PS_GenericCapability x, PS_OutStream stream);
+void Encode_CapabilityIdentifier(PS_CapabilityIdentifier x, PS_OutStream stream);
+void Encode_GenericParameter(PS_GenericParameter x, PS_OutStream stream);
+void Encode_ParameterIdentifier(PS_ParameterIdentifier x, PS_OutStream stream);
+void Encode_ParameterValue(PS_ParameterValue x, PS_OutStream stream);
+void Encode_OpenLogicalChannel(PS_OpenLogicalChannel x, PS_OutStream stream);
+void Encode_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x, PS_OutStream stream);
+void Encode_RlcMultiplexParameters(PS_RlcMultiplexParameters x, PS_OutStream stream);
+void Encode_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x, PS_OutStream stream);
+void Encode_MultiplexParameters(PS_MultiplexParameters x, PS_OutStream stream);
+void Encode_NetworkAccessParameters(PS_NetworkAccessParameters x, PS_OutStream stream);
+void Encode_T120SetupProcedure(PS_T120SetupProcedure x, PS_OutStream stream);
+void Encode_NetworkAddress(PS_NetworkAddress x, PS_OutStream stream);
+void Encode_Distribution(PS_Distribution x, PS_OutStream stream);
+void Encode_Q2931Address(PS_Q2931Address x, PS_OutStream stream);
+void Encode_Address(PS_Address x, PS_OutStream stream);
+void Encode_V75Parameters(PS_V75Parameters x, PS_OutStream stream);
+void Encode_DataType(PS_DataType x, PS_OutStream stream);
+void Encode_H235Media(PS_H235Media x, PS_OutStream stream);
+void Encode_MediaType(PS_MediaType x, PS_OutStream stream);
+void Encode_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x, PS_OutStream stream);
+void Encode_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x, PS_OutStream stream);
+void Encode_AdaptationLayerType(PS_AdaptationLayerType x, PS_OutStream stream);
+void Encode_Al3(PS_Al3 x, PS_OutStream stream);
+void Encode_H223AL1MParameters(PS_H223AL1MParameters x, PS_OutStream stream);
+void Encode_ArqType(PS_ArqType x, PS_OutStream stream);
+void Encode_CrcLength(PS_CrcLength x, PS_OutStream stream);
+void Encode_HeaderFEC(PS_HeaderFEC x, PS_OutStream stream);
+void Encode_TransferMode(PS_TransferMode x, PS_OutStream stream);
+void Encode_H223AL2MParameters(PS_H223AL2MParameters x, PS_OutStream stream);
+void Encode_Al2HeaderFEC(PS_Al2HeaderFEC x, PS_OutStream stream);
+void Encode_H223AL3MParameters(PS_H223AL3MParameters x, PS_OutStream stream);
+void Encode_Al3ArqType(PS_Al3ArqType x, PS_OutStream stream);
+void Encode_Al3CrcLength(PS_Al3CrcLength x, PS_OutStream stream);
+void Encode_HeaderFormat(PS_HeaderFormat x, PS_OutStream stream);
+void Encode_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x, PS_OutStream stream);
+void Encode_NumberOfRetransmissions(PS_NumberOfRetransmissions x, PS_OutStream stream);
+void Encode_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x, PS_OutStream stream);
+void Encode_Mode(PS_Mode x, PS_OutStream stream);
+void Encode_ERM(PS_ERM x, PS_OutStream stream);
+void Encode_Recovery(PS_Recovery x, PS_OutStream stream);
+void Encode_SuspendResume(PS_SuspendResume x, PS_OutStream stream);
+void Encode_V76HDLCParameters(PS_V76HDLCParameters x, PS_OutStream stream);
+void Encode_CRCLength(PS_CRCLength x, PS_OutStream stream);
+void Encode_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x, PS_OutStream stream);
+void Encode_MediaPacketization(PS_MediaPacketization x, PS_OutStream stream);
+void Encode_RTPPayloadType(PS_RTPPayloadType x, PS_OutStream stream);
+void Encode_PayloadDescriptor(PS_PayloadDescriptor x, PS_OutStream stream);
+void Encode_RedundancyEncoding(PS_RedundancyEncoding x, PS_OutStream stream);
+void Encode_TransportAddress(PS_TransportAddress x, PS_OutStream stream);
+void Encode_UnicastAddress(PS_UnicastAddress x, PS_OutStream stream);
+void Encode_IPSourceRouteAddress(PS_IPSourceRouteAddress x, PS_OutStream stream);
+void Encode_Routing(PS_Routing x, PS_OutStream stream);
+void Encode_IP6Address(PS_IP6Address x, PS_OutStream stream);
+void Encode_IPXAddress(PS_IPXAddress x, PS_OutStream stream);
+void Encode_IPAddress(PS_IPAddress x, PS_OutStream stream);
+void Encode_MulticastAddress(PS_MulticastAddress x, PS_OutStream stream);
+void Encode_MaIp6Address(PS_MaIp6Address x, PS_OutStream stream);
+void Encode_MaIpAddress(PS_MaIpAddress x, PS_OutStream stream);
+void Encode_EncryptionSync(PS_EncryptionSync x, PS_OutStream stream);
+void Encode_EscrowData(PS_EscrowData x, PS_OutStream stream);
+void Encode_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x, PS_OutStream stream);
+void Encode_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x, PS_OutStream stream);
+void Encode_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x, PS_OutStream stream);
+void Encode_AckMultiplexParameters(PS_AckMultiplexParameters x, PS_OutStream stream);
+void Encode_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x, PS_OutStream stream);
+void Encode_OlcRejectCause(PS_OlcRejectCause x, PS_OutStream stream);
+void Encode_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x, PS_OutStream stream);
+void Encode_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x, PS_OutStream stream);
+void Encode_CloseLogicalChannel(PS_CloseLogicalChannel x, PS_OutStream stream);
+void Encode_Reason(PS_Reason x, PS_OutStream stream);
+void Encode_Source(PS_Source x, PS_OutStream stream);
+void Encode_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x, PS_OutStream stream);
+void Encode_RequestChannelClose(PS_RequestChannelClose x, PS_OutStream stream);
+void Encode_RccReason(PS_RccReason x, PS_OutStream stream);
+void Encode_RequestChannelCloseAck(PS_RequestChannelCloseAck x, PS_OutStream stream);
+void Encode_RequestChannelCloseReject(PS_RequestChannelCloseReject x, PS_OutStream stream);
+void Encode_RccRejectCause(PS_RccRejectCause x, PS_OutStream stream);
+void Encode_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x, PS_OutStream stream);
+void Encode_MultiplexEntrySend(PS_MultiplexEntrySend x, PS_OutStream stream);
+void Encode_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x, PS_OutStream stream);
+void Encode_MultiplexElement(PS_MultiplexElement x, PS_OutStream stream);
+void Encode_RepeatCount(PS_RepeatCount x, PS_OutStream stream);
+void Encode_MuxType(PS_MuxType x, PS_OutStream stream);
+void Encode_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x, PS_OutStream stream);
+void Encode_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x, PS_OutStream stream);
+void Encode_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x, PS_OutStream stream);
+void Encode_MeRejectCause(PS_MeRejectCause x, PS_OutStream stream);
+void Encode_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x, PS_OutStream stream);
+void Encode_RequestMultiplexEntry(PS_RequestMultiplexEntry x, PS_OutStream stream);
+void Encode_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x, PS_OutStream stream);
+void Encode_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x, PS_OutStream stream);
+void Encode_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x, PS_OutStream stream);
+void Encode_RmeRejectCause(PS_RmeRejectCause x, PS_OutStream stream);
+void Encode_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x, PS_OutStream stream);
+void Encode_RequestMode(PS_RequestMode x, PS_OutStream stream);
+void Encode_RequestModeAck(PS_RequestModeAck x, PS_OutStream stream);
+void Encode_Response(PS_Response x, PS_OutStream stream);
+void Encode_RequestModeReject(PS_RequestModeReject x, PS_OutStream stream);
+void Encode_RmRejectCause(PS_RmRejectCause x, PS_OutStream stream);
+void Encode_RequestModeRelease(PS_RequestModeRelease x, PS_OutStream stream);
+void Encode_ModeDescription(PS_ModeDescription x, PS_OutStream stream);
+void Encode_ModeElement(PS_ModeElement x, PS_OutStream stream);
+void Encode_ModeType(PS_ModeType x, PS_OutStream stream);
+void Encode_H235Mode(PS_H235Mode x, PS_OutStream stream);
+void Encode_MediaMode(PS_MediaMode x, PS_OutStream stream);
+void Encode_H223ModeParameters(PS_H223ModeParameters x, PS_OutStream stream);
+void Encode_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x, PS_OutStream stream);
+void Encode_ModeAl3(PS_ModeAl3 x, PS_OutStream stream);
+void Encode_V76ModeParameters(PS_V76ModeParameters x, PS_OutStream stream);
+void Encode_H2250ModeParameters(PS_H2250ModeParameters x, PS_OutStream stream);
+void Encode_RedundancyEncodingMode(PS_RedundancyEncodingMode x, PS_OutStream stream);
+void Encode_SecondaryEncoding(PS_SecondaryEncoding x, PS_OutStream stream);
+void Encode_VideoMode(PS_VideoMode x, PS_OutStream stream);
+void Encode_H261VideoMode(PS_H261VideoMode x, PS_OutStream stream);
+void Encode_Resolution(PS_Resolution x, PS_OutStream stream);
+void Encode_H262VideoMode(PS_H262VideoMode x, PS_OutStream stream);
+void Encode_ProfileAndLevel(PS_ProfileAndLevel x, PS_OutStream stream);
+void Encode_H263VideoMode(PS_H263VideoMode x, PS_OutStream stream);
+void Encode_H263Resolution(PS_H263Resolution x, PS_OutStream stream);
+void Encode_IS11172VideoMode(PS_IS11172VideoMode x, PS_OutStream stream);
+void Encode_AudioMode(PS_AudioMode x, PS_OutStream stream);
+void Encode_ModeG7231(PS_ModeG7231 x, PS_OutStream stream);
+void Encode_IS11172AudioMode(PS_IS11172AudioMode x, PS_OutStream stream);
+void Encode_MultichannelType(PS_MultichannelType x, PS_OutStream stream);
+void Encode_AudioSampling(PS_AudioSampling x, PS_OutStream stream);
+void Encode_AudioLayer(PS_AudioLayer x, PS_OutStream stream);
+void Encode_IS13818AudioMode(PS_IS13818AudioMode x, PS_OutStream stream);
+void Encode_Is13818MultichannelType(PS_Is13818MultichannelType x, PS_OutStream stream);
+void Encode_Is13818AudioSampling(PS_Is13818AudioSampling x, PS_OutStream stream);
+void Encode_Is13818AudioLayer(PS_Is13818AudioLayer x, PS_OutStream stream);
+void Encode_G7231AnnexCMode(PS_G7231AnnexCMode x, PS_OutStream stream);
+void Encode_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x, PS_OutStream stream);
+void Encode_DataMode(PS_DataMode x, PS_OutStream stream);
+void Encode_DmApplication(PS_DmApplication x, PS_OutStream stream);
+void Encode_DmT38fax(PS_DmT38fax x, PS_OutStream stream);
+void Encode_DmNlpid(PS_DmNlpid x, PS_OutStream stream);
+void Encode_EncryptionMode(PS_EncryptionMode x, PS_OutStream stream);
+void Encode_RoundTripDelayRequest(PS_RoundTripDelayRequest x, PS_OutStream stream);
+void Encode_RoundTripDelayResponse(PS_RoundTripDelayResponse x, PS_OutStream stream);
+void Encode_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x, PS_OutStream stream);
+void Encode_MlRequestType(PS_MlRequestType x, PS_OutStream stream);
+void Encode_MaintenanceLoopAck(PS_MaintenanceLoopAck x, PS_OutStream stream);
+void Encode_MlAckType(PS_MlAckType x, PS_OutStream stream);
+void Encode_MaintenanceLoopReject(PS_MaintenanceLoopReject x, PS_OutStream stream);
+void Encode_MlRejectCause(PS_MlRejectCause x, PS_OutStream stream);
+void Encode_MlRejectType(PS_MlRejectType x, PS_OutStream stream);
+void Encode_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x, PS_OutStream stream);
+void Encode_CommunicationModeCommand(PS_CommunicationModeCommand x, PS_OutStream stream);
+void Encode_CommunicationModeRequest(PS_CommunicationModeRequest x, PS_OutStream stream);
+void Encode_CommunicationModeResponse(PS_CommunicationModeResponse x, PS_OutStream stream);
+void Encode_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x, PS_OutStream stream);
+void Encode_CmtDataType(PS_CmtDataType x, PS_OutStream stream);
+void Encode_ConferenceRequest(PS_ConferenceRequest x, PS_OutStream stream);
+void Encode_RequestTerminalCertificate(PS_RequestTerminalCertificate x, PS_OutStream stream);
+void Encode_CertSelectionCriteria(PS_CertSelectionCriteria x, PS_OutStream stream);
+void Encode_Criteria(PS_Criteria x, PS_OutStream stream);
+void Encode_TerminalLabel(PS_TerminalLabel x, PS_OutStream stream);
+void Encode_ConferenceResponse(PS_ConferenceResponse x, PS_OutStream stream);
+void Encode_SendThisSourceResponse(PS_SendThisSourceResponse x, PS_OutStream stream);
+void Encode_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x, PS_OutStream stream);
+void Encode_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x, PS_OutStream stream);
+void Encode_TerminalCertificateResponse(PS_TerminalCertificateResponse x, PS_OutStream stream);
+void Encode_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x, PS_OutStream stream);
+void Encode_ExtensionAddressResponse(PS_ExtensionAddressResponse x, PS_OutStream stream);
+void Encode_MakeMeChairResponse(PS_MakeMeChairResponse x, PS_OutStream stream);
+void Encode_PasswordResponse(PS_PasswordResponse x, PS_OutStream stream);
+void Encode_ConferenceIDResponse(PS_ConferenceIDResponse x, PS_OutStream stream);
+void Encode_TerminalIDResponse(PS_TerminalIDResponse x, PS_OutStream stream);
+void Encode_MCTerminalIDResponse(PS_MCTerminalIDResponse x, PS_OutStream stream);
+void Encode_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x, PS_OutStream stream);
+void Encode_TerminalInformation(PS_TerminalInformation x, PS_OutStream stream);
+void Encode_RemoteMCRequest(PS_RemoteMCRequest x, PS_OutStream stream);
+void Encode_RemoteMCResponse(PS_RemoteMCResponse x, PS_OutStream stream);
+void Encode_Reject(PS_Reject x, PS_OutStream stream);
+void Encode_MultilinkRequest(PS_MultilinkRequest x, PS_OutStream stream);
+void Encode_MaximumHeaderInterval(PS_MaximumHeaderInterval x, PS_OutStream stream);
+void Encode_RequestType(PS_RequestType x, PS_OutStream stream);
+void Encode_RemoveConnection(PS_RemoveConnection x, PS_OutStream stream);
+void Encode_AddConnection(PS_AddConnection x, PS_OutStream stream);
+void Encode_CallInformation(PS_CallInformation x, PS_OutStream stream);
+void Encode_MultilinkResponse(PS_MultilinkResponse x, PS_OutStream stream);
+void Encode_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x, PS_OutStream stream);
+void Encode_RespRemoveConnection(PS_RespRemoveConnection x, PS_OutStream stream);
+void Encode_RespAddConnection(PS_RespAddConnection x, PS_OutStream stream);
+void Encode_ResponseCode(PS_ResponseCode x, PS_OutStream stream);
+void Encode_Rejected(PS_Rejected x, PS_OutStream stream);
+void Encode_RespCallInformation(PS_RespCallInformation x, PS_OutStream stream);
+void Encode_MultilinkIndication(PS_MultilinkIndication x, PS_OutStream stream);
+void Encode_ExcessiveError(PS_ExcessiveError x, PS_OutStream stream);
+void Encode_CrcDesired(PS_CrcDesired x, PS_OutStream stream);
+void Encode_DialingInformation(PS_DialingInformation x, PS_OutStream stream);
+void Encode_DialingInformationNumber(PS_DialingInformationNumber x, PS_OutStream stream);
+void Encode_DialingInformationNetworkType(PS_DialingInformationNetworkType x, PS_OutStream stream);
+void Encode_ConnectionIdentifier(PS_ConnectionIdentifier x, PS_OutStream stream);
+void Encode_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x, PS_OutStream stream);
+void Encode_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x, PS_OutStream stream);
+void Encode_LogicalChannelRateReject(PS_LogicalChannelRateReject x, PS_OutStream stream);
+void Encode_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x, PS_OutStream stream);
+void Encode_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x, PS_OutStream stream);
+void Encode_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x, PS_OutStream stream);
+void Encode_SpecificRequest(PS_SpecificRequest x, PS_OutStream stream);
+void Encode_EncryptionCommand(PS_EncryptionCommand x, PS_OutStream stream);
+void Encode_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x, PS_OutStream stream);
+void Encode_FlowControlCommand(PS_FlowControlCommand x, PS_OutStream stream);
+void Encode_FccRestriction(PS_FccRestriction x, PS_OutStream stream);
+void Encode_FccScope(PS_FccScope x, PS_OutStream stream);
+void Encode_EndSessionCommand(PS_EndSessionCommand x, PS_OutStream stream);
+void Encode_IsdnOptions(PS_IsdnOptions x, PS_OutStream stream);
+void Encode_GstnOptions(PS_GstnOptions x, PS_OutStream stream);
+void Encode_ConferenceCommand(PS_ConferenceCommand x, PS_OutStream stream);
+void Encode_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x, PS_OutStream stream);
+void Encode_MiscellaneousCommand(PS_MiscellaneousCommand x, PS_OutStream stream);
+void Encode_McType(PS_McType x, PS_OutStream stream);
+void Encode_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x, PS_OutStream stream);
+void Encode_PrsRepeatCount(PS_PrsRepeatCount x, PS_OutStream stream);
+void Encode_VideoFastUpdateMB(PS_VideoFastUpdateMB x, PS_OutStream stream);
+void Encode_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x, PS_OutStream stream);
+void Encode_KeyProtectionMethod(PS_KeyProtectionMethod x, PS_OutStream stream);
+void Encode_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x, PS_OutStream stream);
+void Encode_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x, PS_OutStream stream);
+void Encode_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x, PS_OutStream stream);
+void Encode_H223ModeChange(PS_H223ModeChange x, PS_OutStream stream);
+void Encode_NewATMVCCommand(PS_NewATMVCCommand x, PS_OutStream stream);
+void Encode_CmdReverseParameters(PS_CmdReverseParameters x, PS_OutStream stream);
+void Encode_Multiplex(PS_Multiplex x, PS_OutStream stream);
+void Encode_CmdMultiplex(PS_CmdMultiplex x, PS_OutStream stream);
+void Encode_CmdAal(PS_CmdAal x, PS_OutStream stream);
+void Encode_CmdAal5(PS_CmdAal5 x, PS_OutStream stream);
+void Encode_CmdAal1(PS_CmdAal1 x, PS_OutStream stream);
+void Encode_CmdErrorCorrection(PS_CmdErrorCorrection x, PS_OutStream stream);
+void Encode_CmdClockRecovery(PS_CmdClockRecovery x, PS_OutStream stream);
+void Encode_FunctionNotUnderstood(PS_FunctionNotUnderstood x, PS_OutStream stream);
+void Encode_FunctionNotSupported(PS_FunctionNotSupported x, PS_OutStream stream);
+void Encode_FnsCause(PS_FnsCause x, PS_OutStream stream);
+void Encode_ConferenceIndication(PS_ConferenceIndication x, PS_OutStream stream);
+void Encode_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x, PS_OutStream stream);
+void Encode_VideoIndicateCompose(PS_VideoIndicateCompose x, PS_OutStream stream);
+void Encode_MiscellaneousIndication(PS_MiscellaneousIndication x, PS_OutStream stream);
+void Encode_MiType(PS_MiType x, PS_OutStream stream);
+void Encode_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x, PS_OutStream stream);
+void Encode_JitterIndication(PS_JitterIndication x, PS_OutStream stream);
+void Encode_JiScope(PS_JiScope x, PS_OutStream stream);
+void Encode_H223SkewIndication(PS_H223SkewIndication x, PS_OutStream stream);
+void Encode_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x, PS_OutStream stream);
+void Encode_MCLocationIndication(PS_MCLocationIndication x, PS_OutStream stream);
+void Encode_VendorIdentification(PS_VendorIdentification x, PS_OutStream stream);
+void Encode_NewATMVCIndication(PS_NewATMVCIndication x, PS_OutStream stream);
+void Encode_IndReverseParameters(PS_IndReverseParameters x, PS_OutStream stream);
+void Encode_IrpMultiplex(PS_IrpMultiplex x, PS_OutStream stream);
+void Encode_IndMultiplex(PS_IndMultiplex x, PS_OutStream stream);
+void Encode_IndAal(PS_IndAal x, PS_OutStream stream);
+void Encode_IndAal5(PS_IndAal5 x, PS_OutStream stream);
+void Encode_IndAal1(PS_IndAal1 x, PS_OutStream stream);
+void Encode_IndErrorCorrection(PS_IndErrorCorrection x, PS_OutStream stream);
+void Encode_IndClockRecovery(PS_IndClockRecovery x, PS_OutStream stream);
+void Encode_UserInputIndication(PS_UserInputIndication x, PS_OutStream stream);
+void Encode_SignalUpdate(PS_SignalUpdate x, PS_OutStream stream);
+void Encode_Rtp(PS_Rtp x, PS_OutStream stream);
+void Encode_Signal(PS_Signal x, PS_OutStream stream);
+void Encode_SignalRtp(PS_SignalRtp x, PS_OutStream stream);
+void Encode_UserInputSupportIndication(PS_UserInputSupportIndication x, PS_OutStream stream);
+void Encode_FlowControlIndication(PS_FlowControlIndication x, PS_OutStream stream);
+void Encode_FciRestriction(PS_FciRestriction x, PS_OutStream stream);
+void Encode_FciScope(PS_FciScope x, PS_OutStream stream);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/per.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/per.h
new file mode 100644
index 0000000..d46d0dc
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/per.h
@@ -0,0 +1,83 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#ifndef _PER_H_
+#define _PER_H_
+
+#include "oscl_base.h"
+#include "h245msg.h"
+#include "genericper.h"
+
+class H245;
+class SE;
+class PVLogger;
+
+class PER
+{
+    public:
+        OSCL_IMPORT_REF PER();
+        OSCL_IMPORT_REF ~PER();
+
+        void SetH245(H245 *h245)
+        {
+            MyH245 = h245;
+        }
+        void SetSe(SE *se)
+        {
+            MySe = se;
+        }
+
+        OSCL_IMPORT_REF void Reset();
+
+        OSCL_IMPORT_REF void Encode(PS_H245Msg pmsg);
+        OSCL_IMPORT_REF void Decode(uint8* pbuffer, uint32 size);
+
+        static void DeleteMessage(uint8, uint8, uint8*);
+
+    private:
+        bool Decode(int& nBytes, uint8* pBuffer, uint16& GetSize, uint8*& pData,
+                    uint8& MsgType1, uint8& MsgType2);
+        void MultiSysCtrlMessage_encode(uint16*, uint8*	*, uint8*, uint8, uint8);
+        int MultiSysCtrlMessage_decode(uint8*, uint16*, uint8*	*, uint8*, uint8*);
+        void RequestMessage_encode(uint8*, uint8, PS_OutStream);
+        void ResponseMessage_encode(uint8*, uint8, PS_OutStream);
+        void CommandMessage_encode(uint8*, uint8, PS_OutStream);
+        void IndicationMessage_encode(uint8*, uint8, PS_OutStream);
+        void RequestMessage_decode(uint8* *, uint8*, PS_InStream);
+        void ResponseMessage_decode(uint8* *, uint8*, PS_InStream);
+        void CommandMessage_decode(uint8* *, uint8*, PS_InStream);
+        void IndicationMessage_decode(uint8* *, uint8*, PS_InStream);
+
+        H245 *MyH245;
+        SE   *MySe;
+        PVLogger *MyLogger;
+
+        int32 decodeSizeLeft;
+};
+
+#endif //_PER_H_
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/per_common.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/per_common.h
new file mode 100644
index 0000000..505be3a
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/per_common.h
@@ -0,0 +1,41 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================
+// FILE: PER_Common.h
+//
+// DESCRIPTION: This file defines convenient datatypes, etc.
+//   These are not necessarily specific to the PER Codec project.
+//
+// Written by Ralph Neff, PacketVideo, 1/25/2000
+// (c) 2000 PacketVideo Corp.
+// ============================================================
+
+
+#ifndef PER_COMMONDEFS
+#define PER_COMMONDEFS
+
+// --------------------- BEGIN COMMON DEFINITIONS --------------------
+
+#define ON  1
+#define OFF 0
+
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+
+// --------------------- END COMMON DEFINITIONS --------------------
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/include/per_headers.h b/protocols/systems/3g-324m_pvterminal/h245/per/include/per_headers.h
new file mode 100644
index 0000000..7d79a89
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/include/per_headers.h
@@ -0,0 +1,42 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+// ===================================================================
+// FILE: PER_headers.h
+//
+// DESC: Common header files required by h245_encoder.c and
+//       h245_decoder.c.  This is a convenience, to take these
+//       definitions outside of auto-generation.
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "per_common.h"
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/analyzeper.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/analyzeper.cpp
new file mode 100644
index 0000000..75e4f6f
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/analyzeper.cpp
@@ -0,0 +1,527 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+// ============================================================
+// FILE: AnalyzePER.c
+//
+// DESCRIPTION: PER analysis support routines.
+//   These routines provide support for the automatically
+//   generated functions in h245_analysis.[ch].
+//
+// Written by Ralph Neff, PacketVideo, 3/6/2000
+// (c) 2000 PacketVideo Corp.
+// ============================================================
+
+#include "oscl_base.h"
+#include "per_headers.h"
+#include "genericper.h"
+#include "analyzeper.h"
+
+#ifdef PVANALYZER	// Analyzer interface function
+#include <tchar.h>
+void PVAnalyzer(unsigned int tag, Tint8 *message_fmt, ...);
+#endif
+
+/* --------------------------------------------- */
+/* ----------- BASE LEVEL int32ERFACE ------------ */
+/* --------------------------------------------- */
+
+/*
+void MyPVAnalyzer(uint16 tag, uint8 *outString)
+{
+	FILE *fp = fopen("analyzer.txt","a");
+	fprintf(fp, outString);
+	fprintf(fp, "\n");
+	fclose(fp);
+}
+*/
+
+// =========================================================
+// Show245()
+//
+// This function takes an output analysis line, adds the
+// proper indent, and sends the result out to the display
+// routine.  The 'tag' argument is simply passed on.
+// =========================================================
+void Show245(uint16 tag, uint16 indent, const char* inString)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(inString);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint32 i;
+    uint8 outString[200];
+
+    /* Construct outString with proper indent */
+    for (i = 0;i < indent;++i)
+    {
+        outString[i] = ' ';
+    }
+    sprintf(outString + i, "%s", inString);
+
+//#ifdef PVANALYZER  //07/12/01wjj
+    /* Send outString to display */
+    PVAnalyzer(tag, outString);        /* The real deal */
+#endif
+}
+
+// =========================================================
+// ShowHexData()
+//
+// This function shows a hex dump of a string of uint8s.
+// The resulting output line(s) gets displayed by call to
+// Show245().  The first two input arguments (tag, indent)
+// are simply passed through.
+// =========================================================
+void ShowHexData(uint16 tag, uint16 indent, uint16 size, uint8* data)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(size);
+    OSCL_UNUSED_ARG(data);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint32 i;
+    uint8 outString[100];
+
+    for (i = 0;i < size;++i)
+    {
+        sprintf(outString + 3*(i % 16), "%02x ", data[i]);
+        if ((i % 16) == 15 || (i + 1) == size)
+        {
+            outString[3*(i%16+1)] = '\0';
+            Show245(tag, indent, outString);
+        }
+    }
+#endif
+}
+
+/* --------------------------------------------- */
+/* ----------- LOW LEVEL OBJECTS --------------- */
+/* --------------------------------------------- */
+
+// =========================================================
+// ShowPERNull()
+//
+// This function displays a NULL object via call to Show245().
+// =========================================================
+void ShowPERNull(uint16 tag, uint16 indent, const char* label)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = NULL", label);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERBoolean()
+//
+// This function displays a BOOLEAN object via call to
+// Show245().
+// =========================================================
+void ShowPERBoolean(uint16 tag, uint16 indent, const char* label, uint32 value)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(value);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    if (value)
+    {
+        sprintf(outString, "%s = TRUE", label);
+    }
+    else
+    {
+        sprintf(outString, "%s = FALSE", label);
+    }
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERInteger()
+//
+// This function displays an int32EGER object via call to
+// Show245().
+// =========================================================
+void ShowPERInteger(uint16 tag, uint16 indent, const char* label, uint32 value)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(value);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %u", label, value);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERSignedInteger()
+//
+// This function displays the signed variant of an int32EGER
+// object via call to Show245().
+// =========================================================
+void ShowPERSignedInteger(uint16 tag, uint16 indent, const char* label, int32 value)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(value);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %d", label, value);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERUnboundedInteger()
+//
+// This function displays the unbounded variant of an int32EGER
+// object via call to Show245().  We currently take the
+// input type to be uint32.
+// =========================================================
+void ShowPERUnboundedInteger(uint16 tag, uint16 indent, const char* label, uint32 value)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(value);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %u", label, value);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPEROctetString()
+//
+// This function displays an OCTETSTRING object via call
+// to Show245().
+// =========================================================
+void ShowPEROctetString(uint16 tag, uint16 indent, const char* label, PS_OCTETSTRING x)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(x);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s is an OCTET STRING (SIZE = %hu)",
+            label, x->size);
+    Show245(tag, indent, outString);
+    ShowHexData(tag, (uint16)(indent + 2), x->size, x->data);
+#endif
+}
+
+// =========================================================
+// ShowPERBitString()
+//
+// This function displays a BITSTRING object via calls
+// to Show245().
+// =========================================================
+void ShowPERBitString(uint16 tag, uint16 indent, const char *label, PS_BITSTRING x)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(x);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s is a BIT STRING (SIZE = %hu)",
+            label, x->size);
+    Show245(tag, indent, outString);
+    ShowHexData(tag, (uint16)(indent + 2), (uint16)(x->size / 8), x->data);
+#endif
+}
+
+// =========================================================
+// ShowPERCharString()
+//
+// This function displays a int8STRING object via calls
+// to Show245().
+// =========================================================
+void ShowPERCharString(uint16 tag, uint16 indent, const char* label, PS_int8STRING x)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(x);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+    uint8 displayType = 1;  /* Select output type -- See Below */
+
+    sprintf(outString, "%s is a int8 STRING (SIZE = %hu)",
+            label, x->size);
+    Show245(tag, indent, outString);
+
+    if (displayType == 0)
+    {
+        /* Show Hex Version of string data */
+        ShowHexData(tag, (uint16)(indent + 2), x->size, x->data);
+    }
+    else
+    {
+        /* Show Printable character version */
+        sprintf(outString, "stringdata = \"%s\"", x->data);
+        Show245(tag, (uint16)(indent + 2), outString);
+    }
+#endif
+}
+
+// =========================================================
+// ShowPERObjectID()
+//
+// This function displays an OBJECT IDENTIFIER via calls
+// to Show245().
+// =========================================================
+void ShowPERObjectID(uint16 tag, uint16 indent, const char* label, PS_OBJECTIDENT x)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(x);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s is an OBJECT IDENTIFIER (SIZE = %hu)",
+            label, x->size);
+    Show245(tag, indent, outString);
+    ShowHexData(tag, (uint16)(indent + 2), x->size, x->data);
+#endif
+}
+
+/* --------------------------------------------- */
+/* ---------- HIGHER LEVEL OBJECTS ------------- */
+/* --------------------------------------------- */
+
+// =========================================================
+// ShowPERChoice()
+//
+// This function displays the identity of a toplevel
+// CHOICE definition.
+// =========================================================
+void ShowPERChoice(uint16 tag, uint16 indent, const char *label, const char *typestring)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(typestring);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %s (CHOICE)", label, typestring);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERSequence()
+//
+// This function displays the identity of a toplevel
+// SEQUENCE definition.
+// =========================================================
+void ShowPERSequence(uint16 tag, uint16 indent, const char* label, const char* typestring)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(typestring);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %s (SEQUENCE)", label, typestring);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERSequenceof()
+//
+// This function displays the identity of a toplevel
+// SEQUENCE OF definition.
+// =========================================================
+void ShowPERSequenceof(uint16 tag, uint16 indent, const char* label, const char* typestring)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(typestring);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %s (SEQUENCE-OF)", label, typestring);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERSetof()
+//
+// This function displays the identity of a toplevel
+// SET OF definition.
+// =========================================================
+void ShowPERSetof(uint16 tag, uint16 indent, const char* label, const char* typestring)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(typestring);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s = %s (SET-OF)", label, typestring);
+    Show245(tag, indent, outString);
+#endif
+}
+
+// =========================================================
+// ShowPERClosure()
+//
+// This function displays the closure of a top level object.
+// It should be called once with the existing (already
+// incremented) indent level.
+// =========================================================
+void ShowPERClosure(uint16 tag, uint16 indent, const char* label)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    if (indent >= 2)  /* Reduce indent, guarantee minimum 0 */
+    {
+        indent -= 2;
+    }
+    sprintf(outString, "(end of %s)", label);
+    Show245(tag, indent, outString);
+#endif
+}
+
+/* --------------------------------------------- */
+/* ----------- ARRAYS OF OBJECTS --------------- */
+/* --------------------------------------------- */
+
+// =========================================================
+// ShowPERIntegers()
+//
+// This function displays an int32EGER object which is the
+// ofitem of a SeqOf or SetOf.  It does so via call to
+// ShowPERInteger(), after constructing a special label.
+// =========================================================
+void ShowPERIntegers(uint16 tag, uint16 indent, const char* label, uint32 value, uint32 number)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(value);
+    OSCL_UNUSED_ARG(number);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s[%u]", label, number);
+    ShowPERInteger(tag, indent, outString, value);
+#endif
+}
+
+// =========================================================
+// ShowPEROctetStrings()
+//
+// This function displays an OCTET STRING which is the
+// ofitem of a SeqOf or SetOf.  It does so via call to
+// ShowPEROctetString(), after constructing a special label.
+// =========================================================
+void ShowPEROctetStrings(uint16 tag, uint16 indent, const char* label, PS_OCTETSTRING x, uint32 number)
+{
+    OSCL_UNUSED_ARG(tag);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(label);
+    OSCL_UNUSED_ARG(x);
+    OSCL_UNUSED_ARG(number);
+#ifdef PVANALYZER  //07/12/01wjj
+    uint8 outString[100];
+
+    sprintf(outString, "%s[%u]", label, number);
+    ShowPEROctetString(tag, indent, outString, x);
+#endif
+}
+
+// -----------------------------------------------------------
+// Dummy PVAnalyzer() Function
+// --> This may be added to provide the analyzer function if
+//       PVAnalyzer() is not provided at the application layer.
+//       However, the app layer is really where the analyzer
+//       should reside.
+// --> Note: This requires <stdio.h> and <time.h> to be included.
+// -----------------------------------------------------------
+//#ifdef PVANALYZER
+//void PVAnalyzer( uint32 tag, Tint8 *pPerDataIn,...)
+//{
+//  FILE    *pFile;
+//  uint8 *pFileName ="h245per.txt";
+//  uint8 pTimeBuf[32];
+//  uint8 *tagString;
+//
+//  pFile = fopen( pFileName, "a+");
+//  if( pFile != NULL )
+//  {
+//    _tzset();
+//    _strtime( pTimeBuf );
+//
+//    if(tag==2)
+//        tagString="PerEnc";
+//    else if(tag==4)
+//        tagString="PerEnx";
+//    else if(tag==8)
+//        tagString="PerDec";
+//    else if(tag==16)
+//        tagString="PerDe";
+//    else if(tag==32)
+//        tagString="  Se  ";
+//    else if(tag==64)
+//        tagString="  Tsc ";
+//
+//    fprintf( pFile, "<%s> <%s> %s\n", pTimeBuf, tagString, pPerDataIn );
+//    fclose(pFile);
+//  } /*end if(pFile != NULL) */
+//}
+//#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/genericper.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/genericper.cpp
new file mode 100644
index 0000000..83595df
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/genericper.cpp
@@ -0,0 +1,1912 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+// ============================================================
+// FILE: GenericPER.c
+//
+// DESCRIPTION: Generic PER encode/decode routines.  These are
+//   called by the automatically generated MiniParser code.
+//
+// Written by Ralph Neff, PacketVideo, 2/8/2000
+// (c) 2000 PacketVideo Corp.
+// ============================================================
+
+#include "per_headers.h"
+#include "analyzeper.h"
+#include "genericper.h"
+#include "oscl_error_codes.h"
+#include "oscl_mem.h"
+#include "oscl_stdstring.h"
+#include "pvlogger.h"
+
+#define STREAM_ADDITION 64      /* Output stream grows in increments */
+/*   of this many bytes.             */
+
+const uint8 MaskBit[] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
+
+/***********************************************************/
+/*=========================================================*/
+/*============ DECODING ROUTINES (Generic PER) ============*/
+/*=========================================================*/
+/***********************************************************/
+
+/* --------------------------------------------- */
+/* ------------- LOW LEVEL STREAM -------------- */
+/* --------------------------------------------- */
+
+// =========================================================
+// ErrorMessage()
+//
+// This function is a generic error call for PER routines.
+//
+// NOTE: Removed the MessageBox called and replaced with a
+//   call to the analyzer via Show245().  Since tag informaion
+//   isn't easy to get (encoder/decoder autogen routines don't
+//   provide tags, and deleter autogen routines don't even have
+//   a tag defined!), we will fix to the "PER Decoder" tag for
+//   now.  The proper thing to do would be to use a newly
+//   defined "PER Error" tag.  But it's not so important to
+//   do this, since the source of the error is always defined
+//   in the message itself.  (RAN-MessageBox)  10/5/01
+// =========================================================
+void ErrorMessage(const char *msg)
+{
+    OSCL_UNUSED_ARG(msg);
+
+    PVLogger *logger = PVLogger::GetLoggerObject("3g324m.h245.per");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger, PVLOGMSG_ERR, (0, "GenericPer::ErrorMessage - %s", msg));
+}
+
+void ErrorMessageAndLeave(const char *msg)
+{
+    ErrorMessage(msg);
+    PVLogger *logger = PVLogger::GetLoggerObject("3g324m.h245.per");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, logger, PVLOGMSG_ERR, (0, "GenericPer::ErrorMessageAndLeave - LEAVE"));
+    OSCL_LEAVE(OsclErrCorrupt);
+}
+
+// =========================================================
+// ReadBits()
+//
+// This function reads some number of bits from the
+// input stream.
+// =========================================================
+uint8 ReadBits(uint32 number, PS_InStream stream)
+{
+    uint8 x;
+    uint8 NextBit, BitSize;
+
+    if (number > 8)
+    {
+        ErrorMessageAndLeave("ReadBits(): Max number (8) exceeded");
+    }
+
+    BitSize = (uint8)(stream->bitIndex + number);
+    x = (uint8)(stream->data[0] & MaskBit[(int)stream->bitIndex ]);
+    if (BitSize > 8)
+    {
+        NextBit = (uint8)(BitSize - 8);
+        x <<= NextBit;
+        ++stream->data;
+        x |= ((stream->data[0]) & ~MaskBit[(int)stream->bitIndex ]) >> (8 - NextBit);
+    }
+    else if (BitSize < 8)
+    {
+        NextBit = BitSize;
+        x >>= (8 - NextBit);
+    }
+    else
+    {
+        NextBit = 0;
+        ++stream->data;
+    }
+
+    stream->bitIndex = NextBit;
+    return(x);
+}
+
+// =========================================================
+// ReadRemainingBits()
+//
+// This function advances to the next octet boundary in
+// the input stream.  If the stream already points to
+// an octet boundary, no action is taken.
+// =========================================================
+void  ReadRemainingBits(PS_InStream stream)
+{
+    if (stream->bitIndex)
+    {
+        stream->bitIndex = 0;
+        ++stream->data;
+    }
+}
+
+// =========================================================
+// ReadOctets()
+//
+// This function reads one or more octets from the input
+// stream.  Input arguments are:
+//   uint32 number;        /* Number of octets to read */
+//   uint8* octets;      /* Destination for octets */
+//   uint8 reorder;      /* Reorder for little-endian machine? */
+//   PS_InStream stream; /* Input stream */
+// =========================================================
+void  ReadOctets(uint32 number, uint8* octets, uint8 reorder, PS_InStream stream)
+{
+    ReadRemainingBits(stream);  /* Octet alignment */
+
+    if (number == 0)   /* No action */
+    {
+        return;
+    }
+    else if (number <= 4 && reorder)   /* Apply reordering */
+    {
+        switch (number)
+        {
+            case 1:
+                octets[0] = stream->data[0];
+                break;
+            case 2:
+                octets[0] = stream->data[1];
+                octets[1] = stream->data[0];
+                break;
+            case 3:
+                octets[0] = stream->data[2];
+                octets[1] = stream->data[1];
+                octets[2] = stream->data[0];
+                break;
+            case 4:
+                octets[0] = stream->data[3];
+                octets[1] = stream->data[2];
+                octets[2] = stream->data[1];
+                octets[3] = stream->data[0];
+                break;
+        }
+    }
+    else
+    {
+        oscl_memcpy(octets, stream->data, number);  /* Straight copy */
+    }
+
+    stream->data += number;
+}
+
+
+/* --------------------------------------------- */
+/* ------------ HIGH LEVEL ASN DATA ------------ */
+/* --------------------------------------------- */
+
+
+// =========================================================
+// GetBoolean()
+//
+// This function reads a boolean from the input stream.
+// =========================================================
+uint8 GetBoolean(PS_InStream stream)
+{
+    return(ReadBits(1, stream));
+}
+
+// =========================================================
+// GetInteger()                           X.691 Section 10.5
+//
+// This function decodes a constrained integer, given the
+// lower/upper bounds.  Note that bounds are uint32, which
+// means min>=0, max<=4294967295.
+// Assumes ALIGNED variant of PER.
+// =========================================================
+uint32  GetInteger(uint32 lower, uint32 upper, PS_InStream stream)
+{
+    uint32 value = 0, range;
+    uint8 nbits, nbytes = 0;
+
+    if (lower > upper)
+    {
+        ErrorMessageAndLeave("GetInteger(): Range is negative.");
+        return(lower);
+    }
+    range = upper - lower + 1;
+
+    if (range == 0)     /* Special case: int32EGER(0..4294967295) */
+    {
+        nbytes = (uint8)(ReadBits(2, stream) + 1);
+        ReadOctets(nbytes, (uint8*)&value, 1, stream);
+        return(value);
+    }
+    else if (range == 1)            /* 0-bits */
+        return(lower);
+    else if (range < 256)           /* Bit-field cases */
+    {
+        if (range <= 2) nbits = 1;
+        else if (range <= 4) nbits = 2;
+        else if (range <= 8) nbits = 3;
+        else if (range <= 16) nbits = 4;
+        else if (range <= 32) nbits = 5;
+        else if (range <= 64) nbits = 6;
+        else if (range <= 128) nbits = 7;
+        else nbits = 8;
+        value = ReadBits(nbits, stream);
+        if (lower + value > upper)
+        {
+            ErrorMessageAndLeave("GetInteger(): Integer exceeds range");
+        }
+        return(lower + value);
+    }
+    else                            /* One or more octets */
+    {
+        if (range == 256) nbytes = 1;
+        else if (range <= 65536) nbytes = 2;
+        else nbytes = (uint8)(ReadBits(2, stream) + 1);
+        ReadOctets(nbytes, (uint8*)&value, 1, stream);
+        if (lower + value > upper)
+        {
+            ErrorMessageAndLeave("GetInteger(): exceeds range");
+        }
+        return(lower + value);
+    }
+}
+
+// =========================================================
+// GetSignedInteger()                     X.691 Section 10.5
+//
+// This function decodes a constrained integer, given the
+// lower/upper bounds.  The only difference from GetInteger()
+// is that the bounds and returned values are int32, and
+// so may be negative.
+// Assumes ALIGNED variant of PER.
+// =========================================================
+int32   GetSignedInteger(int32 lower, int32 upper, PS_InStream stream)
+{
+    int32 value = 0, range;
+    uint8 nbits, nbytes = 0;
+
+    if (lower > upper)
+    {
+        ErrorMessageAndLeave("GetSignedInteger(): Range is negative.");
+        return(lower);
+    }
+    range = upper - lower + 1;
+
+    if (range == 0)
+    {
+        ErrorMessageAndLeave("GetSignedInteger(): Range is zero.");
+        return(lower);
+    }
+    else if (range == 1)            /* 0-bits */
+        return(lower);
+    else if (range < 256)           /* Bit-field cases */
+    {
+        if (range <= 2) nbits = 1;
+        else if (range <= 4) nbits = 2;
+        else if (range <= 8) nbits = 3;
+        else if (range <= 16) nbits = 4;
+        else if (range <= 32) nbits = 5;
+        else if (range <= 64) nbits = 6;
+        else if (range <= 128) nbits = 7;
+        else nbits = 8;
+        value = ReadBits(nbits, stream);
+        if (lower + value > upper)
+        {
+            ErrorMessageAndLeave("GetSignedInteger(): Integer exceeds range");
+        }
+        return(lower + value);
+    }
+    else                            /* One or more octets */
+    {
+        if (range == 256) nbytes = 1;
+        else if (range <= 65536) nbytes = 2;
+        else nbytes = (uint8)(ReadBits(2, stream) + 1);
+        ReadOctets(nbytes, (uint8*)&value, 1, stream);
+        if (lower + value > upper)
+        {
+            ErrorMessageAndLeave("GetSignedInteger(): GetInteger exceeds range");
+        }
+        return(lower + value);
+    }
+}
+
+// =========================================================
+// GetUnboundedInteger()                   X.691 Section 12
+//                                         and also 10.4, 10.9.
+//
+// This function decodes an unbounded integer.  The structure
+// definition can only accomodate a uint32 return type, so if
+// the decoded value is negative, we signal an error.
+// Assumes ALIGNED variant of PER.
+// =========================================================
+uint32  GetUnboundedInteger(PS_InStream stream)
+{
+    uint32 nbytes, value = 0;
+
+    nbytes = GetLengthDet(stream);               // Length Det (10.9)
+    ReadOctets(nbytes, (uint8*)&value, 1, stream);  // Value (10.4)
+
+    // Check for negative value
+    if ((nbytes == 1 && value >= 0x7f) ||
+            (nbytes == 2 && value >= 0x8000) ||
+            (nbytes == 3 && value >= 0x800000) ||
+            (nbytes == 4 && value >= 0x80000000))
+    {
+        ErrorMessageAndLeave("GetUnboundedInteger: Found a negative value!");
+    }
+
+    return(value);
+}
+
+// =========================================================
+// GetExtendedInteger()                   X.691 Section 12.1
+//
+// This function decodes a constrained integer with an
+// extended range.  We assume the value is unsigned, and
+// that the ALIGNED variant of PER is used.
+// =========================================================
+uint32  GetExtendedInteger(uint32 lower, uint32 upper, PS_InStream stream)
+{
+    uint32 extension_bit, value;
+
+    extension_bit = ReadBits(1, stream);
+    if (extension_bit)
+    {
+        value = GetUnboundedInteger(stream);
+    }
+    else
+    {
+        value = GetInteger(lower, upper, stream);
+    }
+
+    return(value);
+}
+
+// =========================================================
+// GetOctetString()                      X.691 Section 16
+//
+// This function reads an OCTET STRING from the input stream.
+// Bounds on the size, if any, are included in the input
+// arguments.
+// =========================================================
+void GetOctetString(uint8 unbounded, uint32 min, uint32 max,
+                    PS_OCTETSTRING x, PS_InStream stream)
+{
+    if (unbounded)         /* ====Size is unbounded==== */
+    {
+        x->size = (uint16) GetLengthDet(stream);
+        if (x->size)
+        {
+            x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+            ReadOctets(x->size, x->data, 0, stream);
+        }
+        else
+        {
+            x->data = NULL;
+        }
+    }
+    else                   /* ====Size is bounded==== */
+    {
+
+        if (min > max)            /* Error handling */
+        {
+            ErrorMessageAndLeave("GetOctetString(): Constraint error (min>max)");
+        }
+
+        if (min == max)           /* Fixed size (no length det!) */
+        {
+            x->size = (uint16) min;
+            if (x->size)
+            {
+                x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+                if (x->size > 2)
+                {
+                    ReadOctets(x->size, x->data, 0, stream);
+                }
+                else if (x->size == 2)
+                {
+                    x->data[0] = ReadBits(8, stream);
+                    x->data[1] = ReadBits(8, stream);
+                }
+                else if (x->size == 1)
+                {
+                    x->data[0] = ReadBits(8, stream);
+                }
+            }
+            else
+            {
+                x->data = NULL;
+            }
+        }
+        else                      /* Constrained size */
+        {
+            x->size = (uint16) GetInteger(min, max, stream);
+            if (x->size)
+            {
+                x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+                ReadOctets(x->size, x->data, 0, stream);
+            }
+            else
+            {
+                x->data = NULL;
+            }
+        }
+    }
+}
+
+// =========================================================
+// GetBitString()                      X.691 Section 16
+//
+// This function reads a BIT STRING from the input stream.
+// Bounds on the size, if any, are included in the input
+// arguments.  The BITSTRING structure (x) is returned.
+// =========================================================
+void GetBitString(uint8 unbounded, uint32 min, uint32 max,
+                  PS_BITSTRING x, PS_InStream stream)
+{
+    uint32 count;
+    uint8* temp;
+
+    if (unbounded)         /* ====Size is unbounded==== */
+    {
+        count = GetLengthDet(stream);
+        x->size = (uint16) count;
+        temp = x->data = (uint8*) OSCL_DEFAULT_MALLOC((1 + x->size / 8) * sizeof(uint8));
+        while (count >= 8)
+        {
+            temp[0] = ReadBits(8, stream);
+            ++temp;
+            count -= 8;
+        }
+        temp[0] = (uint8)(ReadBits(count, stream) << (8 - count));
+    }
+    else                   /* ====Size is bounded==== */
+    {
+
+        if (min > max)            /* Error handling */
+        {
+            ErrorMessageAndLeave("GetBitString(): Constraint error (min>max)");
+        }
+
+        if (min == max)           /* Fixed size (no length det!) */
+        {
+            count = min;
+            x->size = (uint16) count;
+            temp = x->data = (uint8*) OSCL_DEFAULT_MALLOC((1 + x->size / 8) * sizeof(uint8));
+            if (x->size > 16)
+            {
+                ReadRemainingBits(stream);  /* Octet align */
+            }
+            while (count >= 8)
+            {
+                temp[0] = ReadBits(8, stream);
+                ++temp;
+                count -= 8;
+            }
+            temp[0] = (uint8)(ReadBits(count, stream) << (8 - count));
+        }
+        else                      /* Constrained size */
+        {
+            count = GetInteger(min, max, stream);
+            x->size = (uint16) count;
+            temp = x->data = (uint8*) OSCL_DEFAULT_MALLOC((1 + x->size / 8) * sizeof(uint8));
+            ReadRemainingBits(stream);
+            while (count >= 8)
+            {
+                temp[0] = ReadBits(8, stream);
+                ++temp;
+                count -= 8;
+            }
+        }
+    }
+}
+
+// =========================================================
+// GetCharString()                             (RAN-UII)
+//
+// This function decodes a character string from a stream.
+// Currently it only handles the special case of DTMF user
+//   input (that is, signalType in UserInputIndication).
+// However, it should be straightforward to extend this
+//   to handle generic restrictions on the four common
+//   types (IA5String, NumericString, PrintableString,
+//   and VisibleString).  See X.691 Clause 26.5 for details.
+// NOTE: For now I'm adding NULL string termination so that
+//   the analyzer (ShowPERCharString() ) will correctly display
+//   it on the decode side.  Should correct this at some point,
+//   since x->data should really only contain characters that
+//   were pulled from the input stream.
+// =========================================================
+void GetCharString(const char *stringName,
+                   uint8 unbounded, uint32 min, uint32 max, const char *from,
+                   PS_int8STRING x, PS_InStream stream)
+{
+    if (oscl_strncmp(stringName, "IA5String", oscl_strlen("IA5String")) == 0 &&    // Validate DTMF UII case
+            unbounded == 0 &&
+            min == 1 &&
+            max == 1 &&
+            oscl_strncmp(from, "0123456789#*ABCD!", oscl_strlen("0123456789#*ABCD!")) == 0)
+    {
+        x->size = 2;
+        x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+        x->data[0] = ReadBits(8, stream);     // Read single character,
+        // Normal ascii value, not octet aligned
+        x->data[1] = 0;  // NULL terminate
+    }
+    else if (oscl_strncmp(stringName, "GeneralString", oscl_strlen("GeneralString")) == 0)   // Validate GeneralString case  (RAN-ALPHA)
+    {
+        x->size = (uint16)(1 + GetLengthDet(stream)); // (leave extra space for NULL)
+        x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+        ReadOctets(x->size - 1, x->data, 1, stream);
+        x->data[x->size-1] = 0;  // NULL terminate
+    }
+    else
+    {
+        x->size = 0;
+        x->data = NULL;
+        ErrorMessageAndLeave("GetCharString(): Not yet implemented.");
+    }
+}
+
+// =========================================================
+// GetObjectID()                        X.691 Section 23
+//
+// This function reads an OBJECT IDENTIFIER from the input
+// stream.  This is just a length determinant, followed by
+// a variable number of octets.
+// =========================================================
+void GetObjectID(PS_OBJECTIDENT x, PS_InStream stream)
+{
+    x->size = (uint16) GetLengthDet(stream);
+    if (x->size)
+    {
+        x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+        ReadOctets(x->size, x->data, 0, stream);
+    }
+    else
+    {
+        x->data = NULL;
+    }
+}
+
+
+/* --------------------------------------------- */
+/* --------------- OTHER CALLS ------------------*/
+/* --------------------------------------------- */
+
+// =========================================================
+// GetLengthDet()                        X.691 Section 10.9
+//
+// Decodes a general length determinant from the input
+// stream.  Assumes ALIGNED variant of PER.
+// =========================================================
+uint32 GetLengthDet(PS_InStream stream)
+{
+    uint32 length;
+    uint8 byte1, byte2;
+    uint8 mask1 = 0x80;   /* 10000000 */
+    uint8 mask2 = 0x40;   /* 01000000 */
+    uint8 mask3 = 0x3f;   /* 00111111 */
+
+    ReadOctets(1, (uint8*)&byte1, 0, stream);  /* Get first byte */
+    if (!(byte1&mask1))       /* 0xxxxxxx ==>Single octet case */
+    {
+        length = (uint32) byte1;
+    }
+    else if (!(byte1&mask2))  /* 10xxxxxx ==>Dual octet case */
+    {
+        ReadOctets(1, (uint8*)&byte2, 0, stream); /* Second byte */
+        length = (((uint32)(byte1 & mask3)) << 8) + (int32)byte2;
+    }
+    else
+    {
+        ErrorMessageAndLeave("GetLengthDet(): Fragmented Length Dets Not Supported.");
+        return(0);
+    }
+    return(length);
+}
+
+// =========================================================
+// GetNormSmallLength()              X.691 Section 10.9.3.4
+//
+// Decodes a Normally Small length determinant from the
+// input stream.  (In SEQUENCE, this gets the size of an
+// unknown extensions map).
+// Assumes ALIGNED variant of PER.
+// =========================================================
+uint32 GetNormSmallLength(PS_InStream stream)
+{
+    uint8 value = 0;
+    uint8 mask = 0x40;  /* 01000000 */
+
+    value = ReadBits(7, stream);
+    if (value&mask)
+    {
+        ErrorMessageAndLeave("GetNormSmallLength(): Range exceeded.");
+        return(0);
+    }
+    return((uint32)value + 1); /* Valid range is 1...64 */
+}
+
+// =========================================================
+// GetNormSmallValue()                     X.691 Section 10.6
+//
+// Decodes a Normally Small Nonnegative Whole Number from
+// the input stream.
+// (In CHOICE, gets choice index when extension is ON.)
+// Assumes ALIGNED variant of PER.
+// =========================================================
+uint32 GetNormSmallValue(PS_InStream stream)
+{
+    uint8 value = 0;
+    uint8 mask = 0x40;  /* 01000000 */
+
+    value = ReadBits(7, stream);
+    if (value&mask)
+    {
+        ErrorMessageAndLeave("GetNormSmallValue(): range exceeded.");
+        return(0);
+    }
+    return((uint32)value);    /* Valid range is 0...63 */
+}
+
+// =========================================================
+// SkipOneExtension()                X.691 Section 18.9
+//
+// The general length is first read, and that number of
+// octets are then skipped.
+// (In SEQUENCE, this skips over a single unknown extension.
+//  In CHOICE, this skips an item that has been chosen from
+//  the extension, assuming the choice index has already
+//  been read).
+// Assumes aligned variant of PER.
+// =========================================================
+void SkipOneExtension(PS_InStream stream)
+{
+    uint16 length;
+    uint8 buffer[32];
+
+    length = (uint16) GetLengthDet(stream);
+    while (length > 32)      /* Pieces of at most 32 bytes */
+    {
+        ReadOctets(32, buffer, 0, stream);
+        length -= 32;
+    }
+    ReadOctets(length, buffer, 0, stream);  /* Leftovers */
+}
+
+// =========================================================
+// SkipAllExtensions()                X.691 Section 18.9
+//
+// For SEQUENCE, this skips over all unknown extensions.
+// This includes reading the SigMap, including size.
+// Call this routine at the location of the ext marker [...].
+//
+// NOTE: This routine may be obsolete.  Miniparser code
+// instead uses a combination of GetUnknownSigMap() and
+// SkipUnreadExtensions().
+// =========================================================
+void SkipAllExtensions(PS_InStream stream)
+{
+    uint32 size, i, num_to_skip = 0;
+
+    size = GetNormSmallLength(stream);  /* Length of SigMap */
+    /* Read sigmap, counting number of significant extensions */
+    for (i = 0;i < size;++i)
+    {
+        num_to_skip += ReadBits(1, stream);
+    }
+    for (i = 0;i < num_to_skip;++i)
+    {
+        SkipOneExtension(stream);
+    }
+}
+
+// =========================================================
+// GetChoiceIndex()              X.691 Sections 22.4 - 22.8
+//
+// Reads the extension bit and choice index from the input
+// stream, and constructs a (possibly extended) choice index.
+// Assumes ALIGNED variant of PER.
+// ---------------------------------------------------------
+// Inputs: rootnum   (number of objects in root)
+//         extmarker (0 if no extension marker, 1 otherwise)
+// =========================================================
+uint16 GetChoiceIndex(uint32 rootnum, uint8 extmarker, PS_InStream stream)
+{
+    uint8 extension;
+    uint16 index;
+
+    extension = 0;
+    if (extmarker) 			/* Get extension bit */
+    {
+        extension = ReadBits(1, stream);
+    }
+
+    if (!extension)      /* ---Item in root--- */
+    {
+        if (rootnum == 1)     /* Trivial index */
+        {
+            return(0);
+        }
+        else                  /* Standard index */
+        {
+            index = (uint16) GetInteger(0, rootnum - 1, stream);
+        }               /* ---Item in extension--- */
+    }
+    else                    /* Extended index */
+    {
+        index = (uint16)(GetNormSmallValue(stream) + rootnum);
+    }
+
+    return(index);
+}
+
+// =========================================================
+// GetUnknownSigMap()           X.691 Sections 18.7 - 18.8
+//
+// This function reads an unknown significance map from
+// the input stream.  This includes the length of the
+// significance map, and an options bit corresponding to
+// each of the possible extension items.  The completed
+// map is returned in a special structure.
+// =========================================================
+PS_UnknownSigMap GetUnknownSigMap(PS_InStream stream)
+{
+    int32 i;
+    PS_UnknownSigMap x;
+
+    x = (PS_UnknownSigMap) OSCL_DEFAULT_MALLOC(sizeof(S_UnknownSigMap));
+
+    x->size = (uint16) GetNormSmallLength(stream);
+    x->optionFlags = (uint8*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint8));
+    for (i = 0;i < x->size;++i)
+    {
+        x->optionFlags[i] = ReadBits(1, stream);
+    }
+    x->extensionsRead = 0;
+
+    return(x);
+}
+
+// =========================================================
+// SigMapValue()
+//
+// This function reads a single options flag from an
+// unknown significance map (UnknownSigMap).  If the
+// index of the desired value exceeds the size of the
+// map, the return value is zero.
+// =========================================================
+uint8 SigMapValue(uint32 index, PS_UnknownSigMap map)
+{
+    if (index < map->size)
+    {
+        return(map->optionFlags[index]);
+    }
+    else
+    {
+        return(0);
+    }
+}
+
+// =========================================================
+// ExtensionPrep()
+//
+// This function is called immediately before reading each
+// unknown extension item in a SEQUENCE.  It performs two
+// actions:
+//    1. Records within the unknown sigmap that another
+//       extension is being read (++map->extensionsRead).
+//       This is so SkipUnreadExtensions() later knows
+//       how many extensions should be skipped.
+//    2. Reads and discards the length wrapper from the
+//       input stream.
+// =========================================================
+void ExtensionPrep(PS_UnknownSigMap map, PS_InStream stream)
+{
+    ++map->extensionsRead;
+    GetLengthDet(stream);
+}
+
+// =========================================================
+// SkipUnreadExtensions()
+//
+// This function skips any unread (and possibly unknown) items
+// in the extension of a SEQUENCE.  In order for this to work,
+// previously read extension items must have been counted in
+// map->extensionsRead; see ExtensionPrep() for details.
+//
+// This routine takes the following actions:
+//    1. Uses map->extensionsRead to determine how many
+//       extension items remain in the input stream.
+//    2. Skips remaining extension items.
+//    3. Frees the UnknownSigMap.
+//    4. Returns the number of extensions skipped.
+// =========================================================
+uint32 SkipUnreadExtensions(PS_UnknownSigMap map, PS_InStream stream)
+{
+    uint32 i, numExtensions;
+
+    /* Compute the number of extensions to skip */
+    numExtensions = 0;
+    for (i = 0;i < map->size;++i)
+    {
+        numExtensions += map->optionFlags[i];
+    }
+    numExtensions -= map->extensionsRead;
+
+    /* Skip remaining extensions */
+    for (i = 0;i < numExtensions;++i)
+    {
+        SkipOneExtension(stream);
+    }
+
+    /* Free map, return number skipped */
+    OSCL_DEFAULT_FREE(map->optionFlags);
+    OSCL_DEFAULT_FREE(map);
+
+    return(numExtensions);
+}
+
+// =========================================================
+// SkipOneOctet()
+//
+// Skip a single octet.  This is used when a NULL is
+// read from the extension of a CHOICE (since an empty
+// octet is present)
+// =========================================================
+void SkipOneOctet(PS_InStream stream)
+{
+    uint8 temp;
+
+    ReadOctets(1, &temp, 0, stream);
+}
+
+/***********************************************************/
+/*=========================================================*/
+/*============ ENCODING ROUTINES (Generic PER) ============*/
+/*=========================================================*/
+/***********************************************************/
+
+
+/* --------------------------------------------- */
+/* ------------- LOW LEVEL STREAM -------------- */
+/* --------------------------------------------- */
+
+// =========================================================
+// WriteBits()
+//
+// This function writes some number of bits to the
+// output stream.
+// =========================================================
+void WriteBits(uint32 number, uint8 bits, PS_OutStream stream)
+{
+    uint8 BitSize;
+    uint8 temp;
+
+    BitSize = (uint8)((stream->bitIndex) + number);
+    temp = (uint8)(bits << (8 - number));
+    (stream->buildByte) |= (temp >> (stream->bitIndex));
+
+    if (BitSize > 8)  				          /* Appended size > 8 bits */
+    {
+        stream->bitIndex = 8;
+        WriteRemainingBits(stream);
+        stream->buildByte = (uint8)((bits) << (16 - BitSize));
+        stream->bitIndex = (uint16)(BitSize - 8);
+        return;
+    }
+    else if (BitSize < 8)  			      /* Appended size < 8 bits */
+    {
+        stream->bitIndex = BitSize;
+        return;
+    }
+    else                                     /* Appended size == 8 bits */
+    {
+        stream->bitIndex = 8;
+        WriteRemainingBits(stream);
+        return;
+    }
+
+}
+
+// =========================================================
+// WriteRemainingBits()
+//
+// This function advances to the next octet boundary in
+// the output stream.  Zero-bit padding is done, if needed.
+// If the stream already points to an octet boundary, no
+// action is taken.
+// =========================================================
+void WriteRemainingBits(PS_OutStream stream)
+{
+    if (stream->bitIndex)
+    {
+        if (stream->byteIndex + 1 > stream->size)
+        {
+            ExpandOutStream(stream);
+        }
+        stream->data[stream->byteIndex] = stream->buildByte;
+        ++stream->byteIndex;
+        stream->bitIndex = 0;
+        stream->buildByte = 0;
+    }
+}
+
+// =========================================================
+// WriteOctets()
+//
+// This function writes one or more octets to the output
+// stream.  Input arguments are:
+//   uint32 number;         /* Number of octets to write */
+//   uint8* octets;       /* Source for octets */
+//   uint8 reorder;       /* Reorder for little-endian machine? */
+//   PS_OutStream stream; /* Output stream */
+// =========================================================
+void WriteOctets(uint32 number, uint8* octets, uint8 reorder, PS_OutStream stream)
+{
+    uint8* destination;
+
+    WriteRemainingBits(stream);  /* Octet alignment */
+
+    /* Expand the stream, if needed */
+    while (stream->byteIndex + number > stream->size)
+    {
+        ExpandOutStream(stream);
+    }
+
+    /* Write the octets to stream */
+    destination = stream->data + stream->byteIndex;
+    if (number == 0)   /* No action */
+    {
+        return;
+    }
+    else if (number <= 4 && reorder)   /* Apply reordering */
+    {
+        switch (number)
+        {
+            case 1:
+                destination[0] = octets[0];
+                break;
+            case 2:
+                destination[0] = octets[1];
+                destination[1] = octets[0];
+                break;
+            case 3:
+                destination[0] = octets[2];
+                destination[1] = octets[1];
+                destination[2] = octets[0];
+                break;
+            case 4:
+                destination[0] = octets[3];
+                destination[1] = octets[2];
+                destination[2] = octets[1];
+                destination[3] = octets[0];
+                break;
+        }
+    }
+    else
+    {
+        oscl_memcpy(destination, octets, number);  /* Straight copy */
+    }
+
+    stream->byteIndex = (uint16)(number + stream->byteIndex);
+}
+
+// =========================================================
+// NewOutStream()
+//
+// This function creates a new, empty output stream.
+// =========================================================
+PS_OutStream NewOutStream(void)
+{
+    PS_OutStream x;
+
+    x = (PS_OutStream) OSCL_DEFAULT_MALLOC(sizeof(S_OutStream));
+    x->data = NULL;
+    x->size = 0;
+    x->byteIndex = 0;
+    x->bitIndex = 0;
+    x->buildByte = 0;
+
+    return(x);
+}
+
+// =========================================================
+// ExpandOutStream()
+//
+// This function expands an output stream by some number
+// of bytes, as defined by STREAM_ADDITION.
+// =========================================================
+void ExpandOutStream(PS_OutStream x)
+{
+    uint8* tmp = x->data;
+
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(x->size + STREAM_ADDITION);
+    oscl_memcpy(x->data, tmp, x->size);
+    if (tmp)
+        OSCL_DEFAULT_FREE(tmp);
+
+    x->size += STREAM_ADDITION;
+}
+
+// =========================================================
+// FreeOutStream()
+//
+// This function frees an existing output stream.
+// =========================================================
+void FreeOutStream(PS_OutStream x)
+{
+    OSCL_DEFAULT_FREE(x->data);
+    OSCL_DEFAULT_FREE(x);
+}
+
+/* ----------------------------------------------- */
+/* ------------- HIGH LEVEL ASN DATA ------------- */
+/* ----------------------------------------------- */
+
+// =========================================================
+// PutBoolean()
+//
+// This function writes a boolean to the output stream.
+// =========================================================
+void PutBoolean(uint32 value, PS_OutStream stream)
+{
+    WriteBits(1, (uint8)value, stream);
+}
+
+// =========================================================
+// PutInteger()                           X.691 Section 10.5
+//
+// This function encodes a constrained integer, given the
+// lower/upper bounds.  Note that bounds and value must be
+// uint32.  This means 0<= {lower,upper,value} <=4294967295.
+// Assumes ALIGNED variant of PER.
+// =========================================================
+void PutInteger(uint32 lower, uint32 upper, uint32 value, PS_OutStream stream)
+{
+    uint32 range, offset;
+    uint8 nbits, nbytes = 0;
+    uint8 code_nbytes;
+
+    if (lower > upper)
+    {
+        ErrorMessageAndLeave("PutInteger(): Negative range.");
+        return;
+    }
+    if (value < lower)
+    {
+        ErrorMessageAndLeave("PutInteger(): Value too small.");
+        return;
+    }
+    if (value > upper)
+    {
+        ErrorMessageAndLeave("PutInteger(): Value too large.");
+        return;
+    }
+
+    range = upper - lower + 1;
+    offset = value - lower;
+
+    if (range == 0 || range > 65536)     /* Range exceeds 2-octets */
+    {
+        /* (Range==0 means [0,2^32-1] case) */
+        if (offset < 256) nbytes = 1; /* Send using minimum #octets */
+        else if (offset < 65536) nbytes = 2;
+        else if (offset < 16777216) nbytes = 3;
+        else nbytes = 4;
+        code_nbytes = (uint8)(nbytes - 1);
+        WriteBits(2, code_nbytes, stream);              /* Send #octets */
+        WriteOctets(nbytes, (uint8*)&offset, 1, stream);  /* Offset value */
+        return;
+    }
+    else if (range == 1)            /* 0-bits */
+        return;
+    else if (range < 256)           /* Bit-field cases */
+    {
+        if (range <= 2) nbits = 1;
+        else if (range <= 4) nbits = 2;
+        else if (range <= 8) nbits = 3;
+        else if (range <= 16) nbits = 4;
+        else if (range <= 32) nbits = 5;
+        else if (range <= 64) nbits = 6;
+        else if (range <= 128) nbits = 7;
+        else nbits = 8;
+        WriteBits(nbits, (uint8)offset, stream);
+        return;
+    }
+    else if (range == 256)          /* One octet */
+    {
+        WriteOctets(1, (uint8*)(&offset), 1, stream);
+        return;
+    }
+    else                            /* range<=65536; Two octet */
+    {
+        WriteOctets(2, (uint8*)(&offset), 1, stream);
+        return;
+    }
+}
+
+// =========================================================
+// PutSignedInteger()                   X.691 Section 10.5
+//
+// This function encodes a constrained integer, given the
+// lower/upper bounds.  The only difference from
+// PutInteger() is that the bounds and the values are
+// of type int32, and so may be negative.
+// Assumes ALIGNED variant of PER.
+// =========================================================
+void PutSignedInteger(int32 lower, int32 upper, int32 value, PS_OutStream stream)
+{
+    int32 range, offset;
+    uint8 nbits, nbytes = 0;
+    uint8 code_nbytes;
+
+    if (lower > upper)
+    {
+        ErrorMessageAndLeave("PutSignedInteger(): Negative range.");
+        return;
+    }
+    if (value < lower)
+    {
+        ErrorMessageAndLeave("PutSignedInteger(): Value too small.");
+        return;
+    }
+    if (value > upper)
+    {
+        ErrorMessageAndLeave("PutSignedInteger(): Value too large.");
+        return;
+    }
+
+    range = upper - lower + 1;
+    offset = value - lower;
+
+    if (range == 0 || range > 65536)     /* Range exceeds 2-octets */
+    {
+        /* (Range==0 means [0,2^32-1] case) */
+        if (offset < 256) nbytes = 1; /* Send using minimum #octets */
+        else if (offset < 65536) nbytes = 2;
+        else if (offset < 16777216) nbytes = 3;
+        else nbytes = 4;
+        code_nbytes = (uint8)(nbytes - 1);
+        WriteBits(2, code_nbytes, stream);              /* Send #octets */
+        WriteOctets(nbytes, (uint8*)&offset, 1, stream);  /* Offset value */
+        return;
+    }
+    else if (range == 1)            /* 0-bits */
+        return;
+    else if (range < 256)           /* Bit-field cases */
+    {
+        if (range <= 2) nbits = 1;
+        else if (range <= 4) nbits = 2;
+        else if (range <= 8) nbits = 3;
+        else if (range <= 16) nbits = 4;
+        else if (range <= 32) nbits = 5;
+        else if (range <= 64) nbits = 6;
+        else if (range <= 128) nbits = 7;
+        else nbits = 8;
+        WriteBits(nbits, (uint8)offset, stream);
+        return;
+    }
+    else if (range == 256)          /* One octet */
+    {
+        WriteOctets(1, (uint8*)(&offset), 1, stream);
+        return;
+    }
+    else                            /* range<=65536; Two octet */
+    {
+        WriteOctets(2, (uint8*)(&offset), 1, stream);
+        return;
+    }
+}
+
+// =========================================================
+// PutUnboundedInteger()                   X.691 Section 12
+//                                         and also 10.4, 10.9.
+//
+// This function encodes an unbounded integer, which we
+// currently assume has type uint32.  We'd need to make
+// special arrangements if negative values are allowed.
+// Assumes ALIGNED variant of PER.
+// =========================================================
+void PutUnboundedInteger(uint32 value, PS_OutStream stream)
+{
+    uint32 nbytes;
+
+    /* The encoding is min-octets, and so depends on value */
+    if (value < 128)
+        nbytes = 1;
+    else if (value < 32768)
+        nbytes = 2;
+    else if (value < 8388608)
+        nbytes = 3;
+    else
+        nbytes = 4;
+
+    /* Send length det, followed by 2's complement encoding */
+    PutLengthDet(nbytes, stream);
+    WriteOctets(nbytes, (uint8*)(&value), 1, stream);
+}
+
+// =========================================================
+// PutExtendedInteger()                   X.691 Section 12.1
+//
+// This function encodes a constrained integer with an
+// extended range.  We assume the value is unsigned, and
+// that the ALIGNED variant of PER is used.
+// =========================================================
+void PutExtendedInteger(uint32 lower, uint32 upper, uint32 value, PS_OutStream stream)
+{
+    if (value > upper) 				// Extension ON
+    {
+        WriteBits(1, 1, stream);
+        PutUnboundedInteger(value, stream);
+    }
+    else 							// Extension OFF
+    {
+        WriteBits(1, 0, stream);
+        PutInteger(lower, upper, value, stream);
+    }
+}
+
+// =========================================================
+// PutOctetString()                      X.691 Section 16
+//
+// This function writes an OCTET STRING to the output stream.
+// Bounds on the size, if any, are included in the input
+// arguments.  The OCTETSTRING structure (x) is freed at
+// the end.
+// =========================================================
+void PutOctetString(uint8 unbounded, uint32 min, uint32 max,
+                    PS_OCTETSTRING x, PS_OutStream stream)
+{
+    if (unbounded)         /* ====Size is unbounded==== */
+    {
+        PutLengthDet(x->size, stream);
+        WriteOctets(x->size, x->data, 0, stream);
+    }
+    else                   /* ====Size is bounded==== */
+    {
+
+        if (min > max)            /* Error handling */
+        {
+            ErrorMessageAndLeave("PutOctetString(): Constraint error (min>max)");
+        }
+        else if ((x->size < min) || (x->size > max))
+        {
+            ErrorMessageAndLeave("PutOctetString(): Size out of bounds");
+        }
+
+        if (min == max)           /* Fixed size (no length det!) */
+        {
+            if (x->size > 2)
+            {
+                WriteOctets(x->size, x->data, 0, stream);
+            }
+            else if (x->size == 2)
+            {
+                WriteBits(8, x->data[0], stream);
+                WriteBits(8, x->data[1], stream);
+            }
+            else if (x->size == 1)
+            {
+                WriteBits(8, x->data[0], stream);
+            }
+        }
+        else                      /* Constrained size */
+        {
+            PutInteger(min, max, x->size, stream);
+            WriteOctets(x->size, x->data, 0, stream);
+        }
+    }
+}
+
+// =========================================================
+// PutBitString()                      X.691 Section 16
+//
+// This function writes a BIT STRING to the output stream.
+// Bounds on the size, if any, are included in the input
+// arguments.  The BITSTRING structure (x) is freed at
+// the end.
+// =========================================================
+void PutBitString(uint8 unbounded, uint32 min, uint32 max,
+                  PS_BITSTRING x, PS_OutStream stream)
+{
+    uint32 count;
+    uint8* temp;
+
+    count = x->size;
+    temp = x->data;
+
+    if (unbounded)         /* ====Size is unbounded==== */
+    {
+        PutLengthDet(x->size, stream);
+        while (count >= 8)
+        {
+            WriteBits(8, temp[0], stream);
+            ++temp;
+            count -= 8;
+        }
+        WriteBits(count, (uint8)(temp[0] >> (8 - count)), stream);
+    }
+    else                   /* ====Size is bounded==== */
+    {
+
+        if (min > max)            /* Error handling */
+        {
+            ErrorMessageAndLeave("PutBitString(): Constraint error (min>max)");
+        }
+        else if ((x->size < min) || (x->size > max))
+        {
+            ErrorMessageAndLeave("PutBitString(): Size out of bounds");
+        }
+
+        if (min == max)           /* Fixed size (no length det!) */
+        {
+            if (x->size > 16)
+            {
+                WriteRemainingBits(stream);  /* Octet align */
+            }
+            while (count >= 8)
+            {
+                WriteBits(8, temp[0], stream);
+                ++temp;
+                count -= 8;
+            }
+            WriteBits(count, (uint8)(temp[0] >> (8 - count)), stream);
+        }
+        else                      /* Constrained size */
+        {
+            PutInteger(min, max, x->size, stream);
+            WriteRemainingBits(stream);
+            while (count >= 8)
+            {
+                WriteBits(8, temp[0], stream);
+                ++temp;
+                count -= 8;
+            }
+            WriteBits(count, (uint8)(temp[0] >> (8 - count)), stream);
+        }
+    }
+}
+
+// =========================================================
+// PutCharString()                             (RAN-UII)
+//
+// This function encodes a character string to a stream.
+// Currently it only handles the special case of DTMF user
+//   input (that is, signalType in UserInputIndication).
+// However, it should be straightforward to extend this
+//   to handle generic restrictions on the four common
+//   types (IA5String, NumericString, PrintableString,
+//   and VisibleString).  See X.691 Clause 26.5 for details.
+// =========================================================
+void PutCharString(const char *stringName,
+                   uint8 unbounded, uint32 min, uint32 max, const char *from,
+                   PS_int8STRING x, PS_OutStream stream)
+{
+    if (oscl_strncmp(stringName, "IA5String", oscl_strlen("IA5String")) == 0 &&    // Validate DTMF UII case
+            unbounded == 0 &&
+            min == 1 &&
+            max == 1 &&
+            oscl_strncmp(from, "0123456789#*ABCD!", oscl_strlen("0123456789#*ABCD!")) == 0)
+    {
+        WriteBits(8, x->data[0], stream);     // Write single character,
+        // Normal ascii value, not octet aligned
+    }
+    else if (oscl_strncmp(stringName, "GeneralString", oscl_strlen("GeneralString")) == 0)   // Validate GeneralString case (RAN-ALPHA)
+        // ------------------------------------------------------------------------
+        // Note on GeneralString: as far as I can tell this is treated as a
+        // restricted character string type which is not a known-multiplier character
+        // string.  As such it falls under clause 26.6 of X.691.  In this case, any
+        // constraints passed from the PER encoder are not considered 'PER-visible'
+        // and so they are not used.  Because of this, the following should be a
+        // complete implementation of GeneralString (regardless of constraints).
+        // It should work for alphanumeric, and anything else that would use
+        // GeneralString.
+        // ------------------------------------------------------------------------
+        // Note also: I assume you need to install the primary graphic character
+        // set described in T.51, i.e. that there is no default character set.
+        // Invoking a character set means sending an escape code.  Whether you NEED
+        // this to get the primary character set wasn't made clear in T.51
+        // itself, though I found a hint elsewhere that suggested you have to send
+        // the escape code.  The escape code is 27 40 66 15 (or in T.51 lingo,
+        // "ESC 2/8 4/2 0/15").  Sending this code shouldn't hurt anything if the
+        // receiving end is compliant to T.51, but if it doesn't work on the first
+        // try, then one thing you guys might try is removing the escape code, in
+        // case maybe the VIG is choking on it.  Comment out the relevant four lines
+        // below, and also get rid of the extra '4+' in the length calculation.
+        // BTW, the escape sequence breaks down into:
+        //   "Designate primary T.51 character set as G0" -- 27 40 66
+        //   "Invoke G0 as the current character set" -- 15
+        // ------------------------------------------------------------------------
+    {
+#if 0
+        // Encode length of string, in octets
+        PutLengthDet(4 + (x->size), stream);  // Assumes 4-byte T.51 escape sequence
+        // Remove the '4+' if the escape sequence is removed.
+        // Note: PutLengthDet() does octet alignment for us
+        // Send T.51 escapes
+        WriteBits(8, 27, stream);  // Designate primary T.51 character set as G0; see T.51 clause 2.1.2
+        WriteBits(8, 40, stream);  //   (cont'd)
+        WriteBits(8, 66, stream);  //   (cont'd)
+        WriteBits(8, 15, stream);  // Invoke character set G0 as current charset; see T.51 clause 3.5
+#else
+        // Encode length of string, in octets
+        PutLengthDet((x->size), stream);  // Assumes 4-byte T.51 escape sequence
+        // Remove the '4+' if the escape sequence is removed.
+        // Note: PutLengthDet() does octet alignment for us
+#endif
+        // Send the T.51 encoded character data
+        WriteOctets(x->size, x->data, 1, stream);
+    }
+    else
+    {
+        ErrorMessageAndLeave("PutCharString(): Not fully implemented.");
+    }
+}
+
+// =========================================================
+// PutObjectID()                        X.691 Section 23
+//
+// This function writes an OBJECT IDENTIFIER to the output
+// stream.  This is just a length determinant, followed by
+// a variable number of octets.  The OBJECTID structure is
+// freed at the end.
+// =========================================================
+void PutObjectID(PS_OBJECTIDENT x, PS_OutStream stream)
+{
+    PutLengthDet(x->size, stream);
+    WriteOctets(x->size, x->data, 0, stream);
+}
+
+// =========================================================
+// PutExtensionNull()
+//
+// This function encodes a NULL object as an extension.
+// =========================================================
+void PutExtensionNull(PS_OutStream stream)
+{
+    uint8 temp = 0;
+
+    PutLengthDet(1, stream);        /* Length wrapper */
+    WriteOctets(1, &temp, 0, stream);  /* Empty octet */
+}
+
+// =========================================================
+// PutExtensionBoolean()
+//
+// This function encodes a boolean as an extension.
+// =========================================================
+void PutExtensionBoolean(uint32 value, PS_OutStream stream)
+{
+    PutLengthDet(1, stream);        /* Length wrapper */
+    PutBoolean(value, stream);      /* Boolean */
+    WriteRemainingBits(stream);     /* Complete the octet */
+}
+
+// =========================================================
+// PutExtensionInteger()
+//
+// This function encodes an integer as an extension.
+// =========================================================
+void PutExtensionInteger(uint32 lower, uint32 upper, uint32 value, PS_OutStream stream)
+{
+    PS_OutStream tempStream;
+
+    tempStream = NewOutStream();              /* Create a temp stream */
+    PutInteger(lower, upper, value, tempStream); /* Write integer to temp */
+    PutTempStream(tempStream, stream); /* Transmit contents of tempStream */
+}
+
+// =========================================================
+// PutExtensionOctetString()
+//
+// This function encodes an octet string as an extension.
+// =========================================================
+void PutExtensionOctetString(uint8 unbounded,
+                             uint32 min, uint32 max, PS_OCTETSTRING x, PS_OutStream stream)
+{
+    PS_OutStream tempStream;
+
+    tempStream = NewOutStream();                  /* Create a temp stream */
+    PutOctetString(unbounded, min, max, x, tempStream);  /* Write to temp */
+    PutTempStream(tempStream, stream); /* Transmit contents of tempStream */
+}
+
+
+/* --------------------------------------------- */
+/* ---------------- OTHER CALLS -----------------*/
+/* --------------------------------------------- */
+
+// =========================================================
+// PutNormSmallValue()                  X.691 Section 10.6
+//
+// Sends a normally small nonnegative value.  Range is
+// [0,infinity].  (In CHOICE, this sends the choice index
+// when extension is ON).
+// Assumes ALIGNED variant of PER.
+// =========================================================
+void PutNormSmallValue(uint32 value, PS_OutStream stream)
+{
+    uint8 sendval;
+    if (value < 64)
+    {
+        sendval = (uint8) value;
+        WriteBits(7, sendval, stream);
+    }
+    else
+    {
+        ErrorMessageAndLeave("PutNormSmallValue(): range exceeded.");
+    }
+}
+
+// =========================================================
+// PutChoiceIndex()              X.691 Sections 22.4 - 22.8
+//
+// Writes the extension bit (if needed) and the choice index
+// to the bitstream.  Assumes ALIGNED variant of PER.
+//
+// Inputs: rootnum      (number of items in root)
+//         extmarker    (0 if no extension marker, 1 otherwise)
+//         index        (choice index, possibly extended)
+// =========================================================
+void PutChoiceIndex(uint32 rootnum, uint8 extmarker, uint32 index,
+                    PS_OutStream stream)
+{
+    if (!extmarker)    /* ---Extension marker NOT present --- */
+    {
+        PutInteger(0, rootnum - 1, (uint32)index, stream);
+    }
+    else               /* ---Extension marker present --- */
+    {
+        if (index < rootnum)
+        {
+            WriteBits(1, 0, stream); /* Extension bit OFF */
+            PutInteger(0, rootnum - 1, (uint32)index, stream);
+        }
+        else
+        {
+            WriteBits(1, 1, stream); /* Extension bit ON */
+            PutNormSmallValue((uint32)(index - rootnum), stream);
+        }
+    }
+}
+
+// =========================================================
+// PutNormSmallLength()              X.691 Section 10.9.3.4
+//
+// Sends a normally small length determinant.  Range is
+// [1,infinity].  (For SEQUENCE, this sends the size of
+// the SigMap for unknown extensions.)
+// Assumes ALIGNED variant of PER.
+// =========================================================
+void PutNormSmallLength(uint32 value, PS_OutStream stream)
+{
+    uint8 sendval;
+    if (value < 65)
+    {
+        sendval = (uint8)(value - 1);
+        WriteBits(7, sendval, stream);
+    }
+    else
+    {
+        ErrorMessageAndLeave("PutNormSmallLength(): range exceeded.");
+    }
+}
+
+// =========================================================
+// PutLengthDet()                        X.691 Section 10.9
+//
+// Encodes a general length determinant to the output stream.
+// (e.g. for extension wrapper).
+// Assumes ALIGNED variant of PER.
+// =========================================================
+void PutLengthDet(uint32 value, PS_OutStream stream)
+{
+    uint8 byte;
+    uint16 bytes;
+    uint16 mask = 0x8000;   /* 10000000 00000000 */
+
+    if (value < 128)       /* One octet with leading '0' */
+    {
+        byte = (uint8) value;
+        WriteOctets(1, &byte, 0, stream);
+    }
+    else if (value < 16384)   /* Two octets with leading '10' */
+    {
+        bytes = (uint16)(value | mask);
+        WriteOctets(2, (uint8*)&bytes, 0, stream);
+    }
+    else
+    {
+        ErrorMessageAndLeave("PutLengthDet(): Fragmented Length Dets Not Supported.");
+    }
+}
+
+// =========================================================
+// PutExtensionItem()
+//
+// This function writes an extension item, including the
+// length wrapper.  It makes a generic call to one of the
+// H.245-defined PER Encoder routines.
+// =========================================================
+void PutExtensionItem(
+    void (*Func)(uint8* data, PS_OutStream stream),
+    uint8* x, PS_OutStream stream)
+{
+    PS_OutStream tempStream;
+
+    tempStream = NewOutStream();                  /* Create a temp stream */
+    Func(x, tempStream);               /* Encode x, writing to tempStream */
+    PutTempStream(tempStream, stream); /* Transmit contents of tempStream */
+}
+
+// =========================================================
+// PutTempStream()
+//
+// This function copies the contents of a temporary output
+// stream (tempStream) to the main output stream (stream),
+// preceeded by a generial length determinant.
+// It also frees tempStream at the end.
+// =========================================================
+void PutTempStream(PS_OutStream tempStream, PS_OutStream stream)
+{
+    WriteRemainingBits(tempStream);
+    PutLengthDet(tempStream->byteIndex, stream); /* Copy to real stream */
+    WriteOctets(tempStream->byteIndex, tempStream->data, 0, stream);
+    FreeOutStream(tempStream);
+}
+
+/********************************************************/
+/*======================================================*/
+/*============ OTHER ROUTINES (Generic PER) ============*/
+/*======================================================*/
+/********************************************************/
+
+// =========================================================
+// ConvertOutstreamToInstream()
+//
+// This function creates a new InStream and copies into
+// it the contents of an old OutStream.  This is useful
+// for internal testing.
+// Note that the outstream is destroyed in the process.
+// =========================================================
+PS_InStream ConvertOutstreamToInstream(PS_OutStream outstream)
+{
+    PS_InStream instream;
+
+    WriteRemainingBits(outstream);
+    instream = (PS_InStream) OSCL_DEFAULT_MALLOC(sizeof(S_InStream));
+    instream->data = outstream->data;
+    instream->bitIndex = 0;
+
+    OSCL_DEFAULT_FREE(outstream);
+    return(instream);
+}
+
+// =========================================================
+// NewOctetString()
+//
+// This function creates a new OCTETSTRING.
+// For now, the data field just contains the string
+// "OctetString".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+PS_OCTETSTRING NewOctetString(void)
+{
+    PS_OCTETSTRING x;
+
+    x = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+    x->size = 12;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(12 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "OctetString", x->size);
+
+    return(x);
+}
+
+// =========================================================
+// NewBitString()
+//
+// This function creates a new BITSTRING.
+// For now, the data field just contains the string
+// "BitString".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+PS_BITSTRING NewBitString(void)
+{
+    PS_BITSTRING x;
+
+    x = (PS_BITSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_BITSTRING));
+    x->size = 10;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(10 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "BitString", x->size);
+
+    return(x);
+}
+
+// =========================================================
+// NewCharString()
+//
+// This function creates a new int8STRING.
+// For now, the data field just contains the string
+// "CharString".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+PS_int8STRING NewCharString(void)
+{
+    PS_int8STRING x;
+
+    x = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+    x->size = 11;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(11 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "CharString", x->size);
+
+    return(x);
+}
+
+// =========================================================
+// NewObjectID()
+//
+// This function creates a new OBJECTID.
+// For now, the ID just contains the string "Object ID".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+PS_OBJECTIDENT NewObjectID(void)
+{
+    PS_OBJECTIDENT x;
+
+    x = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+    x->size = 10;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(10 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "Object ID", x->size);
+
+    return(x);
+}
+
+// =========================================================
+// InitOctetString()
+//
+// This function inits a previously allocated OCTET STRING.
+// For now, the data field just contains the string
+// "OctetString".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+void InitOctetString(PS_OCTETSTRING x)
+{
+    x->size = 12;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(12 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "OctetString", x->size);
+}
+
+// =========================================================
+// InitBitString()
+//
+// This function inits a previously allocated BIT STRING.
+// For now, the data field just contains the string
+// "BitString".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+void InitBitString(PS_BITSTRING x)
+{
+    x->size = 10;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(10 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "BitString", x->size);
+}
+
+// =========================================================
+// InitCharString()
+//
+// This function inits a previously allocated int8 STRING.
+// For now, the data field just contains the string
+// "CharString".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+void InitCharString(PS_int8STRING x)
+{
+    x->size = 11;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(11 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "CharString", x->size);
+}
+
+// =========================================================
+// InitObjectid()
+//
+// This function inits a previously allocated OBJECT IDENTIFIER.
+// For now, the data field just contains the string
+// "ObjectID".
+// Later, I'll add input parameters and construct the
+// real thing.
+// THIS ROUTINE NEEDS ATTENTION!
+// =========================================================
+void InitObjectid(PS_OBJECTIDENT x)
+{
+    x->size = 9;
+    x->data = (uint8*) OSCL_DEFAULT_MALLOC(9 * sizeof(uint8));
+    oscl_strncpy((char *) x->data, "ObjectID", x->size);
+}
+
+// =========================================================
+// FreeOctetString()
+//
+// This frees an OCTET STRING.
+// =========================================================
+void FreeOctetString(PS_OCTETSTRING x)
+{
+    if (x->size > 0)
+    {
+        OSCL_DEFAULT_FREE(x->data);
+    }
+    OSCL_DEFAULT_FREE(x);
+}
+
+// =========================================================
+// FreeBitString()
+//
+// This frees a BIT STRING.
+// =========================================================
+void FreeBitString(PS_BITSTRING x)
+{
+    OSCL_DEFAULT_FREE(x->data);
+    OSCL_DEFAULT_FREE(x);
+}
+
+// =========================================================
+// FreeCharString()
+//
+// This frees a int8 STRING.
+// =========================================================
+void FreeCharString(PS_int8STRING x)
+{
+    if (x->data)
+    {
+        OSCL_DEFAULT_FREE(x->data);
+    }
+    OSCL_DEFAULT_FREE(x);
+}
+
+// =========================================================
+// FreeObjectID()
+//
+// This frees an OBJECT IDENTIFIER.
+// =========================================================
+void FreeObjectID(PS_OBJECTIDENT x)
+{
+    OSCL_DEFAULT_FREE(x->data);
+    OSCL_DEFAULT_FREE(x);
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_analysis.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_analysis.cpp
new file mode 100644
index 0000000..683a301
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_analysis.cpp
@@ -0,0 +1,9960 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_analysis.c
+//
+// DESC: PER Analyzer routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#include "per_headers.h"
+#include "h245def.h"
+#include "h245_analysis.h"
+#include "analyzeper.h"
+
+
+/* <========================================================> */
+/*  PER-Analyzer for MultimediaSystemControlMessage (CHOICE)  */
+/* <========================================================> */
+void Analyze_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultimediaSystemControlMessage");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_RequestMessage(x->request, "request", tag, indent);
+            break;
+        case 1:
+            Analyze_ResponseMessage(x->response, "response", tag, indent);
+            break;
+        case 2:
+            Analyze_CommandMessage(x->command, "command", tag, indent);
+            break;
+        case 3:
+            Analyze_IndicationMessage(x->indication, "indication", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MultimediaSystemControlMessage: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultimediaSystemControlMessage");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for RequestMessage (CHOICE)  */
+/* <========================================> */
+void Analyze_RequestMessage(PS_RequestMessage x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RequestMessage");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_MasterSlaveDetermination(x->masterSlaveDetermination, "masterSlaveDetermination", tag, indent);
+            break;
+        case 2:
+            Analyze_TerminalCapabilitySet(x->terminalCapabilitySet, "terminalCapabilitySet", tag, indent);
+            break;
+        case 3:
+            Analyze_OpenLogicalChannel(x->openLogicalChannel, "openLogicalChannel", tag, indent);
+            break;
+        case 4:
+            Analyze_CloseLogicalChannel(x->closeLogicalChannel, "closeLogicalChannel", tag, indent);
+            break;
+        case 5:
+            Analyze_RequestChannelClose(x->requestChannelClose, "requestChannelClose", tag, indent);
+            break;
+        case 6:
+            Analyze_MultiplexEntrySend(x->multiplexEntrySend, "multiplexEntrySend", tag, indent);
+            break;
+        case 7:
+            Analyze_RequestMultiplexEntry(x->requestMultiplexEntry, "requestMultiplexEntry", tag, indent);
+            break;
+        case 8:
+            Analyze_RequestMode(x->requestMode, "requestMode", tag, indent);
+            break;
+        case 9:
+            Analyze_RoundTripDelayRequest(x->roundTripDelayRequest, "roundTripDelayRequest", tag, indent);
+            break;
+        case 10:
+            Analyze_MaintenanceLoopRequest(x->maintenanceLoopRequest, "maintenanceLoopRequest", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            Analyze_CommunicationModeRequest(x->communicationModeRequest, "communicationModeRequest", tag, indent);
+            break;
+        case 12:
+            Analyze_ConferenceRequest(x->conferenceRequest, "conferenceRequest", tag, indent);
+            break;
+        case 13:
+            Analyze_MultilinkRequest(x->multilinkRequest, "multilinkRequest", tag, indent);
+            break;
+        case 14:
+            Analyze_LogicalChannelRateRequest(x->logicalChannelRateRequest, "logicalChannelRateRequest", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_RequestMessage: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RequestMessage");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for ResponseMessage (CHOICE)  */
+/* <=========================================> */
+void Analyze_ResponseMessage(PS_ResponseMessage x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ResponseMessage");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_MasterSlaveDeterminationAck(x->masterSlaveDeterminationAck, "masterSlaveDeterminationAck", tag, indent);
+            break;
+        case 2:
+            Analyze_MasterSlaveDeterminationReject(x->masterSlaveDeterminationReject, "masterSlaveDeterminationReject", tag, indent);
+            break;
+        case 3:
+            Analyze_TerminalCapabilitySetAck(x->terminalCapabilitySetAck, "terminalCapabilitySetAck", tag, indent);
+            break;
+        case 4:
+            Analyze_TerminalCapabilitySetReject(x->terminalCapabilitySetReject, "terminalCapabilitySetReject", tag, indent);
+            break;
+        case 5:
+            Analyze_OpenLogicalChannelAck(x->openLogicalChannelAck, "openLogicalChannelAck", tag, indent);
+            break;
+        case 6:
+            Analyze_OpenLogicalChannelReject(x->openLogicalChannelReject, "openLogicalChannelReject", tag, indent);
+            break;
+        case 7:
+            Analyze_CloseLogicalChannelAck(x->closeLogicalChannelAck, "closeLogicalChannelAck", tag, indent);
+            break;
+        case 8:
+            Analyze_RequestChannelCloseAck(x->requestChannelCloseAck, "requestChannelCloseAck", tag, indent);
+            break;
+        case 9:
+            Analyze_RequestChannelCloseReject(x->requestChannelCloseReject, "requestChannelCloseReject", tag, indent);
+            break;
+        case 10:
+            Analyze_MultiplexEntrySendAck(x->multiplexEntrySendAck, "multiplexEntrySendAck", tag, indent);
+            break;
+        case 11:
+            Analyze_MultiplexEntrySendReject(x->multiplexEntrySendReject, "multiplexEntrySendReject", tag, indent);
+            break;
+        case 12:
+            Analyze_RequestMultiplexEntryAck(x->requestMultiplexEntryAck, "requestMultiplexEntryAck", tag, indent);
+            break;
+        case 13:
+            Analyze_RequestMultiplexEntryReject(x->requestMultiplexEntryReject, "requestMultiplexEntryReject", tag, indent);
+            break;
+        case 14:
+            Analyze_RequestModeAck(x->requestModeAck, "requestModeAck", tag, indent);
+            break;
+        case 15:
+            Analyze_RequestModeReject(x->requestModeReject, "requestModeReject", tag, indent);
+            break;
+        case 16:
+            Analyze_RoundTripDelayResponse(x->roundTripDelayResponse, "roundTripDelayResponse", tag, indent);
+            break;
+        case 17:
+            Analyze_MaintenanceLoopAck(x->maintenanceLoopAck, "maintenanceLoopAck", tag, indent);
+            break;
+        case 18:
+            Analyze_MaintenanceLoopReject(x->maintenanceLoopReject, "maintenanceLoopReject", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            Analyze_CommunicationModeResponse(x->communicationModeResponse, "communicationModeResponse", tag, indent);
+            break;
+        case 20:
+            Analyze_ConferenceResponse(x->conferenceResponse, "conferenceResponse", tag, indent);
+            break;
+        case 21:
+            Analyze_MultilinkResponse(x->multilinkResponse, "multilinkResponse", tag, indent);
+            break;
+        case 22:
+            Analyze_LogicalChannelRateAcknowledge(x->logicalChannelRateAcknowledge, "logicalChannelRateAcknowledge", tag, indent);
+            break;
+        case 23:
+            Analyze_LogicalChannelRateReject(x->logicalChannelRateReject, "logicalChannelRateReject", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ResponseMessage: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ResponseMessage");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for CommandMessage (CHOICE)  */
+/* <========================================> */
+void Analyze_CommandMessage(PS_CommandMessage x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CommandMessage");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_MaintenanceLoopOffCommand(x->maintenanceLoopOffCommand, "maintenanceLoopOffCommand", tag, indent);
+            break;
+        case 2:
+            Analyze_SendTerminalCapabilitySet(x->sendTerminalCapabilitySet, "sendTerminalCapabilitySet", tag, indent);
+            break;
+        case 3:
+            Analyze_EncryptionCommand(x->encryptionCommand, "encryptionCommand", tag, indent);
+            break;
+        case 4:
+            Analyze_FlowControlCommand(x->flowControlCommand, "flowControlCommand", tag, indent);
+            break;
+        case 5:
+            Analyze_EndSessionCommand(x->endSessionCommand, "endSessionCommand", tag, indent);
+            break;
+        case 6:
+            Analyze_MiscellaneousCommand(x->miscellaneousCommand, "miscellaneousCommand", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            Analyze_CommunicationModeCommand(x->communicationModeCommand, "communicationModeCommand", tag, indent);
+            break;
+        case 8:
+            Analyze_ConferenceCommand(x->conferenceCommand, "conferenceCommand", tag, indent);
+            break;
+        case 9:
+            Analyze_H223MultiplexReconfiguration(x->h223MultiplexReconfiguration, "h223MultiplexReconfiguration", tag, indent);
+            break;
+        case 10:
+            Analyze_NewATMVCCommand(x->newATMVCCommand, "newATMVCCommand", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_CommandMessage: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CommandMessage");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for IndicationMessage (CHOICE)  */
+/* <===========================================> */
+void Analyze_IndicationMessage(PS_IndicationMessage x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IndicationMessage");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_FunctionNotUnderstood(x->functionNotUnderstood, "functionNotUnderstood", tag, indent);
+            break;
+        case 2:
+            Analyze_MasterSlaveDeterminationRelease(x->masterSlaveDeterminationRelease, "masterSlaveDeterminationRelease", tag, indent);
+            break;
+        case 3:
+            Analyze_TerminalCapabilitySetRelease(x->terminalCapabilitySetRelease, "terminalCapabilitySetRelease", tag, indent);
+            break;
+        case 4:
+            Analyze_OpenLogicalChannelConfirm(x->openLogicalChannelConfirm, "openLogicalChannelConfirm", tag, indent);
+            break;
+        case 5:
+            Analyze_RequestChannelCloseRelease(x->requestChannelCloseRelease, "requestChannelCloseRelease", tag, indent);
+            break;
+        case 6:
+            Analyze_MultiplexEntrySendRelease(x->multiplexEntrySendRelease, "multiplexEntrySendRelease", tag, indent);
+            break;
+        case 7:
+            Analyze_RequestMultiplexEntryRelease(x->requestMultiplexEntryRelease, "requestMultiplexEntryRelease", tag, indent);
+            break;
+        case 8:
+            Analyze_RequestModeRelease(x->requestModeRelease, "requestModeRelease", tag, indent);
+            break;
+        case 9:
+            Analyze_MiscellaneousIndication(x->miscellaneousIndication, "miscellaneousIndication", tag, indent);
+            break;
+        case 10:
+            Analyze_JitterIndication(x->jitterIndication, "jitterIndication", tag, indent);
+            break;
+        case 11:
+            Analyze_H223SkewIndication(x->h223SkewIndication, "h223SkewIndication", tag, indent);
+            break;
+        case 12:
+            Analyze_NewATMVCIndication(x->newATMVCIndication, "newATMVCIndication", tag, indent);
+            break;
+        case 13:
+            Analyze_UserInputIndication(x->userInput, "userInput", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            Analyze_H2250MaximumSkewIndication(x->h2250MaximumSkewIndication, "h2250MaximumSkewIndication", tag, indent);
+            break;
+        case 15:
+            Analyze_MCLocationIndication(x->mcLocationIndication, "mcLocationIndication", tag, indent);
+            break;
+        case 16:
+            Analyze_ConferenceIndication(x->conferenceIndication, "conferenceIndication", tag, indent);
+            break;
+        case 17:
+            Analyze_VendorIdentification(x->vendorIdentification, "vendorIdentification", tag, indent);
+            break;
+        case 18:
+            Analyze_FunctionNotSupported(x->functionNotSupported, "functionNotSupported", tag, indent);
+            break;
+        case 19:
+            Analyze_MultilinkIndication(x->multilinkIndication, "multilinkIndication", tag, indent);
+            break;
+        case 20:
+            Analyze_LogicalChannelRateRelease(x->logicalChannelRateRelease, "logicalChannelRateRelease", tag, indent);
+            break;
+        case 21:
+            Analyze_FlowControlIndication(x->flowControlIndication, "flowControlIndication", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_IndicationMessage: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IndicationMessage");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for NonStandardMessage (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_NonStandardMessage(PS_NonStandardMessage x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "NonStandardMessage");
+    indent += 2;
+    Analyze_NonStandardParameter(&x->nonStandardData, "nonStandardData", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "NonStandardMessage");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for NonStandardParameter (SEQUENCE)  */
+/* <================================================> */
+void Analyze_NonStandardParameter(PS_NonStandardParameter x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "NonStandardParameter");
+    indent += 2;
+    Analyze_NonStandardIdentifier(&x->nonStandardIdentifier, "nonStandardIdentifier", tag, indent);
+    ShowPEROctetString(tag, indent, "data", &x->data);
+    ShowPERClosure(tag, indent, "NonStandardParameter");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for NonStandardIdentifier (CHOICE)  */
+/* <===============================================> */
+void Analyze_NonStandardIdentifier(PS_NonStandardIdentifier x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "NonStandardIdentifier");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERObjectID(tag, indent, "object", x->object);
+            break;
+        case 1:
+            Analyze_H221NonStandard(x->h221NonStandard, "h221NonStandard", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_NonStandardIdentifier: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "NonStandardIdentifier");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for H221NonStandard (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_H221NonStandard(PS_H221NonStandard x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H221NonStandard");
+    indent += 2;
+    ShowPERInteger(tag, indent, "t35CountryCode", (int32)x->t35CountryCode);
+    ShowPERInteger(tag, indent, "t35Extension", (int32)x->t35Extension);
+    ShowPERInteger(tag, indent, "manufacturerCode", (int32)x->manufacturerCode);
+    ShowPERClosure(tag, indent, "H221NonStandard");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for MasterSlaveDetermination (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_MasterSlaveDetermination(PS_MasterSlaveDetermination x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MasterSlaveDetermination");
+    indent += 2;
+    ShowPERInteger(tag, indent, "terminalType", (int32)x->terminalType);
+    ShowPERInteger(tag, indent, "statusDeterminationNumber", (int32)x->statusDeterminationNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MasterSlaveDetermination");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for MasterSlaveDeterminationAck (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MasterSlaveDeterminationAck");
+    indent += 2;
+    Analyze_Decision(&x->decision, "decision", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MasterSlaveDeterminationAck");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for Decision (CHOICE)  */
+/* <==================================> */
+void Analyze_Decision(PS_Decision x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Decision");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "master");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "slave");
+            break;
+        default:
+            ErrorMessage("Analyze_Decision: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Decision");
+}
+
+/* <==========================================================> */
+/*  PER-Analyzer for MasterSlaveDeterminationReject (SEQUENCE)  */
+/* <==========================================================> */
+void Analyze_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MasterSlaveDeterminationReject");
+    indent += 2;
+    Analyze_MsdRejectCause(&x->msdRejectCause, "msdRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MasterSlaveDeterminationReject");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for MsdRejectCause (CHOICE)  */
+/* <========================================> */
+void Analyze_MsdRejectCause(PS_MsdRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MsdRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "identicalNumbers");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MsdRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MsdRejectCause");
+}
+
+/* <===========================================================> */
+/*  PER-Analyzer for MasterSlaveDeterminationRelease (SEQUENCE)  */
+/* <===========================================================> */
+void Analyze_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "MasterSlaveDeterminationRelease");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MasterSlaveDeterminationRelease");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for TerminalCapabilitySet (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_TerminalCapabilitySet(PS_TerminalCapabilitySet x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "TerminalCapabilitySet");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_multiplexCapability", x->option_of_multiplexCapability);
+    ShowPERBoolean(tag, indent, "option_of_capabilityTable", x->option_of_capabilityTable);
+    ShowPERBoolean(tag, indent, "option_of_capabilityDescriptors", x->option_of_capabilityDescriptors);
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERObjectID(tag, indent, "protocolIdentifier", &x->protocolIdentifier);
+    if (x->option_of_multiplexCapability)
+    {
+        Analyze_MultiplexCapability(&x->multiplexCapability, "multiplexCapability", tag, indent);
+    }
+    if (x->option_of_capabilityTable)
+    {
+        ShowPERInteger(tag, indent, "size_of_capabilityTable", (uint32)x->size_of_capabilityTable);
+        for (i = 0;i < x->size_of_capabilityTable;++i)
+        {
+            sprintf(tempLabelString, "capabilityTable[%hu]", i);
+            Analyze_CapabilityTableEntry(x->capabilityTable + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_capabilityDescriptors)
+    {
+        ShowPERInteger(tag, indent, "size_of_capabilityDescriptors", (uint32)x->size_of_capabilityDescriptors);
+        for (i = 0;i < x->size_of_capabilityDescriptors;++i)
+        {
+            sprintf(tempLabelString, "capabilityDescriptors[%hu]", i);
+            Analyze_CapabilityDescriptor(x->capabilityDescriptors + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalCapabilitySet");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for CapabilityTableEntry (SEQUENCE)  */
+/* <================================================> */
+void Analyze_CapabilityTableEntry(PS_CapabilityTableEntry x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CapabilityTableEntry");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_capability", x->option_of_capability);
+    ShowPERInteger(tag, indent, "capabilityTableEntryNumber", (int32)x->capabilityTableEntryNumber);
+    if (x->option_of_capability)
+    {
+        Analyze_Capability(&x->capability, "capability", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "CapabilityTableEntry");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for CapabilityDescriptor (SEQUENCE)  */
+/* <================================================> */
+void Analyze_CapabilityDescriptor(PS_CapabilityDescriptor x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "CapabilityDescriptor");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_simultaneousCapabilities", x->option_of_simultaneousCapabilities);
+    ShowPERInteger(tag, indent, "capabilityDescriptorNumber", (int32)x->capabilityDescriptorNumber);
+    if (x->option_of_simultaneousCapabilities)
+    {
+        ShowPERInteger(tag, indent, "size_of_simultaneousCapabilities", (uint32)x->size_of_simultaneousCapabilities);
+        for (i = 0;i < x->size_of_simultaneousCapabilities;++i)
+        {
+            sprintf(tempLabelString, "simultaneousCapabilities[%hu]", i);
+            Analyze_AlternativeCapabilitySet(x->simultaneousCapabilities + i, tempLabelString, tag, indent);
+        }
+    }
+    ShowPERClosure(tag, indent, "CapabilityDescriptor");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for AlternativeCapabilitySet (SEQUENCE-OF)  */
+/* <=======================================================> */
+void Analyze_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequenceof(tag, indent, label, "AlternativeCapabilitySet");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size", (uint32)x->size);
+    for (i = 0;i < x->size;++i)
+    {
+        ShowPERIntegers(tag, indent, "item", (uint32)x->item[i], i);
+    }
+    ShowPERClosure(tag, indent, "AlternativeCapabilitySet");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for TerminalCapabilitySetAck (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalCapabilitySetAck");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalCapabilitySetAck");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for TerminalCapabilitySetReject (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalCapabilitySetReject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    Analyze_TcsRejectCause(&x->tcsRejectCause, "tcsRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalCapabilitySetReject");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for TcsRejectCause (CHOICE)  */
+/* <========================================> */
+void Analyze_TcsRejectCause(PS_TcsRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "TcsRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unspecified");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "undefinedTableEntryUsed");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "descriptorCapacityExceeded");
+            break;
+        case 3:
+            Analyze_TableEntryCapacityExceeded(x->tableEntryCapacityExceeded, "tableEntryCapacityExceeded", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_TcsRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "TcsRejectCause");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for TableEntryCapacityExceeded (CHOICE)  */
+/* <====================================================> */
+void Analyze_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "TableEntryCapacityExceeded");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "highestEntryNumberProcessed", (uint32)x->highestEntryNumberProcessed);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "noneProcessed");
+            break;
+        default:
+            ErrorMessage("Analyze_TableEntryCapacityExceeded: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "TableEntryCapacityExceeded");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for TerminalCapabilitySetRelease (SEQUENCE)  */
+/* <========================================================> */
+void Analyze_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "TerminalCapabilitySetRelease");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalCapabilitySetRelease");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for Capability (CHOICE)  */
+/* <====================================> */
+void Analyze_Capability(PS_Capability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Capability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_VideoCapability(x->receiveVideoCapability, "receiveVideoCapability", tag, indent);
+            break;
+        case 2:
+            Analyze_VideoCapability(x->transmitVideoCapability, "transmitVideoCapability", tag, indent);
+            break;
+        case 3:
+            Analyze_VideoCapability(x->receiveAndTransmitVideoCapability, "receiveAndTransmitVideoCapability", tag, indent);
+            break;
+        case 4:
+            Analyze_AudioCapability(x->receiveAudioCapability, "receiveAudioCapability", tag, indent);
+            break;
+        case 5:
+            Analyze_AudioCapability(x->transmitAudioCapability, "transmitAudioCapability", tag, indent);
+            break;
+        case 6:
+            Analyze_AudioCapability(x->receiveAndTransmitAudioCapability, "receiveAndTransmitAudioCapability", tag, indent);
+            break;
+        case 7:
+            Analyze_DataApplicationCapability(x->receiveDataApplicationCapability, "receiveDataApplicationCapability", tag, indent);
+            break;
+        case 8:
+            Analyze_DataApplicationCapability(x->transmitDataApplicationCapability, "transmitDataApplicationCapability", tag, indent);
+            break;
+        case 9:
+            Analyze_DataApplicationCapability(x->receiveAndTransmitDataApplicationCapability, "receiveAndTransmitDataApplicationCapability", tag, indent);
+            break;
+        case 10:
+            ShowPERBoolean(tag, indent, "h233EncryptionTransmitCapability", x->h233EncryptionTransmitCapability);
+            break;
+        case 11:
+            Analyze_H233EncryptionReceiveCapability(x->h233EncryptionReceiveCapability, "h233EncryptionReceiveCapability", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 12:
+            Analyze_ConferenceCapability(x->conferenceCapability, "conferenceCapability", tag, indent);
+            break;
+        case 13:
+            Analyze_H235SecurityCapability(x->h235SecurityCapability, "h235SecurityCapability", tag, indent);
+            break;
+        case 14:
+            ShowPERInteger(tag, indent, "maxPendingReplacementFor", (uint32)x->maxPendingReplacementFor);
+            break;
+        case 15:
+            Analyze_UserInputCapability(x->receiveUserInputCapability, "receiveUserInputCapability", tag, indent);
+            break;
+        case 16:
+            Analyze_UserInputCapability(x->transmitUserInputCapability, "transmitUserInputCapability", tag, indent);
+            break;
+        case 17:
+            Analyze_UserInputCapability(x->receiveAndTransmitUserInputCapability, "receiveAndTransmitUserInputCapability", tag, indent);
+            break;
+        case 18:
+            Analyze_GenericCapability(x->genericControlCapability, "genericControlCapability", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_Capability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Capability");
+}
+
+/* <===========================================================> */
+/*  PER-Analyzer for H233EncryptionReceiveCapability (SEQUENCE)  */
+/* <===========================================================> */
+void Analyze_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H233EncryptionReceiveCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "h233IVResponseTime", (int32)x->h233IVResponseTime);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H233EncryptionReceiveCapability");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for H235SecurityCapability (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_H235SecurityCapability(PS_H235SecurityCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H235SecurityCapability");
+    indent += 2;
+    Analyze_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, "encryptionAuthenticationAndIntegrity", tag, indent);
+    ShowPERInteger(tag, indent, "mediaCapability", (int32)x->mediaCapability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H235SecurityCapability");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for MultiplexCapability (CHOICE)  */
+/* <=============================================> */
+void Analyze_MultiplexCapability(PS_MultiplexCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultiplexCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_H222Capability(x->h222Capability, "h222Capability", tag, indent);
+            break;
+        case 2:
+            Analyze_H223Capability(x->h223Capability, "h223Capability", tag, indent);
+            break;
+        case 3:
+            Analyze_V76Capability(x->v76Capability, "v76Capability", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            Analyze_H2250Capability(x->h2250Capability, "h2250Capability", tag, indent);
+            break;
+        case 5:
+            Analyze_GenericCapability(x->genericMultiplexCapability, "genericMultiplexCapability", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_MultiplexCapability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultiplexCapability");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for H222Capability (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_H222Capability(PS_H222Capability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "H222Capability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "numberOfVCs", (int32)x->numberOfVCs);
+    ShowPERInteger(tag, indent, "size_of_vcCapability", (uint32)x->size_of_vcCapability);
+    for (i = 0;i < x->size_of_vcCapability;++i)
+    {
+        sprintf(tempLabelString, "vcCapability[%hu]", i);
+        Analyze_VCCapability(x->vcCapability + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H222Capability");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for VCCapability (SEQUENCE)  */
+/* <========================================> */
+void Analyze_VCCapability(PS_VCCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VCCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_vccAal1", x->option_of_vccAal1);
+    ShowPERBoolean(tag, indent, "option_of_vccAal5", x->option_of_vccAal5);
+    if (x->option_of_vccAal1)
+    {
+        Analyze_VccAal1(&x->vccAal1, "vccAal1", tag, indent);
+    }
+    if (x->option_of_vccAal5)
+    {
+        Analyze_VccAal5(&x->vccAal5, "vccAal5", tag, indent);
+    }
+    ShowPERBoolean(tag, indent, "transportStream", x->transportStream);
+    ShowPERBoolean(tag, indent, "programStream", x->programStream);
+    Analyze_AvailableBitRates(&x->availableBitRates, "availableBitRates", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_aal1ViaGateway", x->option_of_aal1ViaGateway);
+    if (x->option_of_aal1ViaGateway)
+    {
+        Analyze_Aal1ViaGateway(&x->aal1ViaGateway, "aal1ViaGateway", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "VCCapability");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for Aal1ViaGateway (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_Aal1ViaGateway(PS_Aal1ViaGateway x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "Aal1ViaGateway");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_gatewayAddress", (uint32)x->size_of_gatewayAddress);
+    for (i = 0;i < x->size_of_gatewayAddress;++i)
+    {
+        sprintf(tempLabelString, "gatewayAddress[%hu]", i);
+        Analyze_Q2931Address(x->gatewayAddress + i, tempLabelString, tag, indent);
+    }
+    ShowPERBoolean(tag, indent, "nullClockRecovery", x->nullClockRecovery);
+    ShowPERBoolean(tag, indent, "srtsClockRecovery", x->srtsClockRecovery);
+    ShowPERBoolean(tag, indent, "adaptiveClockRecovery", x->adaptiveClockRecovery);
+    ShowPERBoolean(tag, indent, "nullErrorCorrection", x->nullErrorCorrection);
+    ShowPERBoolean(tag, indent, "longInterleaver", x->longInterleaver);
+    ShowPERBoolean(tag, indent, "shortInterleaver", x->shortInterleaver);
+    ShowPERBoolean(tag, indent, "errorCorrectionOnly", x->errorCorrectionOnly);
+    ShowPERBoolean(tag, indent, "structuredDataTransfer", x->structuredDataTransfer);
+    ShowPERBoolean(tag, indent, "partiallyFilledCells", x->partiallyFilledCells);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Aal1ViaGateway");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for AvailableBitRates (SEQUENCE)  */
+/* <=============================================> */
+void Analyze_AvailableBitRates(PS_AvailableBitRates x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "AvailableBitRates");
+    indent += 2;
+    Analyze_VccAal5Type(&x->vccAal5Type, "vccAal5Type", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "AvailableBitRates");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for VccAal5Type (CHOICE)  */
+/* <=====================================> */
+void Analyze_VccAal5Type(PS_VccAal5Type x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "VccAal5Type");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "singleBitRate", (uint32)x->singleBitRate);
+            break;
+        case 1:
+            Analyze_RangeOfBitRates(x->rangeOfBitRates, "rangeOfBitRates", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_VccAal5Type: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "VccAal5Type");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for RangeOfBitRates (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_RangeOfBitRates(PS_RangeOfBitRates x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RangeOfBitRates");
+    indent += 2;
+    ShowPERInteger(tag, indent, "lowerBitRate", (int32)x->lowerBitRate);
+    ShowPERInteger(tag, indent, "higherBitRate", (int32)x->higherBitRate);
+    ShowPERClosure(tag, indent, "RangeOfBitRates");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for VccAal5 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_VccAal5(PS_VccAal5 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VccAal5");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardMaximumSDUSize", (int32)x->forwardMaximumSDUSize);
+    ShowPERInteger(tag, indent, "backwardMaximumSDUSize", (int32)x->backwardMaximumSDUSize);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "VccAal5");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for VccAal1 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_VccAal1(PS_VccAal1 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VccAal1");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "nullClockRecovery", x->nullClockRecovery);
+    ShowPERBoolean(tag, indent, "srtsClockRecovery", x->srtsClockRecovery);
+    ShowPERBoolean(tag, indent, "adaptiveClockRecovery", x->adaptiveClockRecovery);
+    ShowPERBoolean(tag, indent, "nullErrorCorrection", x->nullErrorCorrection);
+    ShowPERBoolean(tag, indent, "longInterleaver", x->longInterleaver);
+    ShowPERBoolean(tag, indent, "shortInterleaver", x->shortInterleaver);
+    ShowPERBoolean(tag, indent, "errorCorrectionOnly", x->errorCorrectionOnly);
+    ShowPERBoolean(tag, indent, "structuredDataTransfer", x->structuredDataTransfer);
+    ShowPERBoolean(tag, indent, "partiallyFilledCells", x->partiallyFilledCells);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "VccAal1");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for H223Capability (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_H223Capability(PS_H223Capability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223Capability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "transportWithI_frames", x->transportWithI_frames);
+    ShowPERBoolean(tag, indent, "videoWithAL1", x->videoWithAL1);
+    ShowPERBoolean(tag, indent, "videoWithAL2", x->videoWithAL2);
+    ShowPERBoolean(tag, indent, "videoWithAL3", x->videoWithAL3);
+    ShowPERBoolean(tag, indent, "audioWithAL1", x->audioWithAL1);
+    ShowPERBoolean(tag, indent, "audioWithAL2", x->audioWithAL2);
+    ShowPERBoolean(tag, indent, "audioWithAL3", x->audioWithAL3);
+    ShowPERBoolean(tag, indent, "dataWithAL1", x->dataWithAL1);
+    ShowPERBoolean(tag, indent, "dataWithAL2", x->dataWithAL2);
+    ShowPERBoolean(tag, indent, "dataWithAL3", x->dataWithAL3);
+    ShowPERInteger(tag, indent, "maximumAl2SDUSize", (int32)x->maximumAl2SDUSize);
+    ShowPERInteger(tag, indent, "maximumAl3SDUSize", (int32)x->maximumAl3SDUSize);
+    ShowPERInteger(tag, indent, "maximumDelayJitter", (int32)x->maximumDelayJitter);
+    Analyze_H223MultiplexTableCapability(&x->h223MultiplexTableCapability, "h223MultiplexTableCapability", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_maxMUXPDUSizeCapability", x->option_of_maxMUXPDUSizeCapability);
+    ShowPERBoolean(tag, indent, "option_of_nsrpSupport", x->option_of_nsrpSupport);
+    ShowPERBoolean(tag, indent, "option_of_mobileOperationTransmitCapability", x->option_of_mobileOperationTransmitCapability);
+    ShowPERBoolean(tag, indent, "option_of_h223AnnexCCapability", x->option_of_h223AnnexCCapability);
+    if (x->option_of_maxMUXPDUSizeCapability)
+    {
+        ShowPERBoolean(tag, indent, "maxMUXPDUSizeCapability", x->maxMUXPDUSizeCapability);
+    }
+    if (x->option_of_nsrpSupport)
+    {
+        ShowPERBoolean(tag, indent, "nsrpSupport", x->nsrpSupport);
+    }
+    if (x->option_of_mobileOperationTransmitCapability)
+    {
+        Analyze_MobileOperationTransmitCapability(&x->mobileOperationTransmitCapability, "mobileOperationTransmitCapability", tag, indent);
+    }
+    if (x->option_of_h223AnnexCCapability)
+    {
+        Analyze_H223AnnexCCapability(&x->h223AnnexCCapability, "h223AnnexCCapability", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "H223Capability");
+}
+
+/* <=============================================================> */
+/*  PER-Analyzer for MobileOperationTransmitCapability (SEQUENCE)  */
+/* <=============================================================> */
+void Analyze_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MobileOperationTransmitCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "modeChangeCapability", x->modeChangeCapability);
+    ShowPERBoolean(tag, indent, "h223AnnexA", x->h223AnnexA);
+    ShowPERBoolean(tag, indent, "h223AnnexADoubleFlag", x->h223AnnexADoubleFlag);
+    ShowPERBoolean(tag, indent, "h223AnnexB", x->h223AnnexB);
+    ShowPERBoolean(tag, indent, "h223AnnexBwithHeader", x->h223AnnexBwithHeader);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MobileOperationTransmitCapability");
+}
+
+/* <======================================================> */
+/*  PER-Analyzer for H223MultiplexTableCapability (CHOICE)  */
+/* <======================================================> */
+void Analyze_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "H223MultiplexTableCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "basic");
+            break;
+        case 1:
+            Analyze_Enhanced(x->enhanced, "enhanced", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_H223MultiplexTableCapability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "H223MultiplexTableCapability");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for Enhanced (SEQUENCE)  */
+/* <====================================> */
+void Analyze_Enhanced(PS_Enhanced x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Enhanced");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maximumNestingDepth", (int32)x->maximumNestingDepth);
+    ShowPERInteger(tag, indent, "maximumElementListSize", (int32)x->maximumElementListSize);
+    ShowPERInteger(tag, indent, "maximumSubElementListSize", (int32)x->maximumSubElementListSize);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Enhanced");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for H223AnnexCCapability (SEQUENCE)  */
+/* <================================================> */
+void Analyze_H223AnnexCCapability(PS_H223AnnexCCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223AnnexCCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "videoWithAL1M", x->videoWithAL1M);
+    ShowPERBoolean(tag, indent, "videoWithAL2M", x->videoWithAL2M);
+    ShowPERBoolean(tag, indent, "videoWithAL3M", x->videoWithAL3M);
+    ShowPERBoolean(tag, indent, "audioWithAL1M", x->audioWithAL1M);
+    ShowPERBoolean(tag, indent, "audioWithAL2M", x->audioWithAL2M);
+    ShowPERBoolean(tag, indent, "audioWithAL3M", x->audioWithAL3M);
+    ShowPERBoolean(tag, indent, "dataWithAL1M", x->dataWithAL1M);
+    ShowPERBoolean(tag, indent, "dataWithAL2M", x->dataWithAL2M);
+    ShowPERBoolean(tag, indent, "dataWithAL3M", x->dataWithAL3M);
+    ShowPERBoolean(tag, indent, "alpduInterleaving", x->alpduInterleaving);
+    ShowPERInteger(tag, indent, "maximumAL1MPDUSize", (int32)x->maximumAL1MPDUSize);
+    ShowPERInteger(tag, indent, "maximumAL2MSDUSize", (int32)x->maximumAL2MSDUSize);
+    ShowPERInteger(tag, indent, "maximumAL3MSDUSize", (int32)x->maximumAL3MSDUSize);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_rsCodeCapability", x->option_of_rsCodeCapability);
+    if (x->option_of_rsCodeCapability)
+    {
+        ShowPERBoolean(tag, indent, "rsCodeCapability", x->rsCodeCapability);
+    }
+    ShowPERClosure(tag, indent, "H223AnnexCCapability");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for V76Capability (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_V76Capability(PS_V76Capability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "V76Capability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "suspendResumeCapabilitywAddress", x->suspendResumeCapabilitywAddress);
+    ShowPERBoolean(tag, indent, "suspendResumeCapabilitywoAddress", x->suspendResumeCapabilitywoAddress);
+    ShowPERBoolean(tag, indent, "rejCapability", x->rejCapability);
+    ShowPERBoolean(tag, indent, "sREJCapability", x->sREJCapability);
+    ShowPERBoolean(tag, indent, "mREJCapability", x->mREJCapability);
+    ShowPERBoolean(tag, indent, "crc8bitCapability", x->crc8bitCapability);
+    ShowPERBoolean(tag, indent, "crc16bitCapability", x->crc16bitCapability);
+    ShowPERBoolean(tag, indent, "crc32bitCapability", x->crc32bitCapability);
+    ShowPERBoolean(tag, indent, "uihCapability", x->uihCapability);
+    ShowPERInteger(tag, indent, "numOfDLCS", (int32)x->numOfDLCS);
+    ShowPERBoolean(tag, indent, "twoOctetAddressFieldCapability", x->twoOctetAddressFieldCapability);
+    ShowPERBoolean(tag, indent, "loopBackTestCapability", x->loopBackTestCapability);
+    ShowPERInteger(tag, indent, "n401Capability", (int32)x->n401Capability);
+    ShowPERInteger(tag, indent, "maxWindowSizeCapability", (int32)x->maxWindowSizeCapability);
+    Analyze_V75Capability(&x->v75Capability, "v75Capability", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "V76Capability");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for V75Capability (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_V75Capability(PS_V75Capability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "V75Capability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "audioHeader", x->audioHeader);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "V75Capability");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for H2250Capability (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_H2250Capability(PS_H2250Capability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "H2250Capability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maximumAudioDelayJitter", (int32)x->maximumAudioDelayJitter);
+    Analyze_MultipointCapability(&x->receiveMultipointCapability, "receiveMultipointCapability", tag, indent);
+    Analyze_MultipointCapability(&x->transmitMultipointCapability, "transmitMultipointCapability", tag, indent);
+    Analyze_MultipointCapability(&x->receiveAndTransmitMultipointCapability, "receiveAndTransmitMultipointCapability", tag, indent);
+    Analyze_McCapability(&x->mcCapability, "mcCapability", tag, indent);
+    ShowPERBoolean(tag, indent, "rtcpVideoControlCapability", x->rtcpVideoControlCapability);
+    Analyze_MediaPacketizationCapability(&x->mediaPacketizationCapability, "mediaPacketizationCapability", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_transportCapability", x->option_of_transportCapability);
+    ShowPERBoolean(tag, indent, "option_of_redundancyEncodingCapability", x->option_of_redundancyEncodingCapability);
+    ShowPERBoolean(tag, indent, "option_of_logicalChannelSwitchingCapability", x->option_of_logicalChannelSwitchingCapability);
+    ShowPERBoolean(tag, indent, "option_of_t120DynamicPortCapability", x->option_of_t120DynamicPortCapability);
+    if (x->option_of_transportCapability)
+    {
+        Analyze_TransportCapability(&x->transportCapability, "transportCapability", tag, indent);
+    }
+    if (x->option_of_redundancyEncodingCapability)
+    {
+        ShowPERInteger(tag, indent, "size_of_redundancyEncodingCapability", (uint32)x->size_of_redundancyEncodingCapability);
+        for (i = 0;i < x->size_of_redundancyEncodingCapability;++i)
+        {
+            sprintf(tempLabelString, "redundancyEncodingCapability[%hu]", i);
+            Analyze_RedundancyEncodingCapability(x->redundancyEncodingCapability + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_logicalChannelSwitchingCapability)
+    {
+        ShowPERBoolean(tag, indent, "logicalChannelSwitchingCapability", x->logicalChannelSwitchingCapability);
+    }
+    if (x->option_of_t120DynamicPortCapability)
+    {
+        ShowPERBoolean(tag, indent, "t120DynamicPortCapability", x->t120DynamicPortCapability);
+    }
+    ShowPERClosure(tag, indent, "H2250Capability");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for McCapability (SEQUENCE)  */
+/* <========================================> */
+void Analyze_McCapability(PS_McCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "McCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "centralizedConferenceMC", x->centralizedConferenceMC);
+    ShowPERBoolean(tag, indent, "decentralizedConferenceMC", x->decentralizedConferenceMC);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "McCapability");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for MediaPacketizationCapability (SEQUENCE)  */
+/* <========================================================> */
+void Analyze_MediaPacketizationCapability(PS_MediaPacketizationCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MediaPacketizationCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "h261aVideoPacketization", x->h261aVideoPacketization);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_rtpPayloadType", x->option_of_rtpPayloadType);
+    if (x->option_of_rtpPayloadType)
+    {
+        ShowPERInteger(tag, indent, "size_of_rtpPayloadType", (uint32)x->size_of_rtpPayloadType);
+        for (i = 0;i < x->size_of_rtpPayloadType;++i)
+        {
+            sprintf(tempLabelString, "rtpPayloadType[%hu]", i);
+            Analyze_RTPPayloadType(x->rtpPayloadType + i, tempLabelString, tag, indent);
+        }
+    }
+    ShowPERClosure(tag, indent, "MediaPacketizationCapability");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for RSVPParameters (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_RSVPParameters(PS_RSVPParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RSVPParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_qosMode", x->option_of_qosMode);
+    ShowPERBoolean(tag, indent, "option_of_tokenRate", x->option_of_tokenRate);
+    ShowPERBoolean(tag, indent, "option_of_bucketSize", x->option_of_bucketSize);
+    ShowPERBoolean(tag, indent, "option_of_peakRate", x->option_of_peakRate);
+    ShowPERBoolean(tag, indent, "option_of_minPoliced", x->option_of_minPoliced);
+    ShowPERBoolean(tag, indent, "option_of_maxPktSize", x->option_of_maxPktSize);
+    if (x->option_of_qosMode)
+    {
+        Analyze_QOSMode(&x->qosMode, "qosMode", tag, indent);
+    }
+    if (x->option_of_tokenRate)
+    {
+        ShowPERInteger(tag, indent, "tokenRate", (int32)x->tokenRate);
+    }
+    if (x->option_of_bucketSize)
+    {
+        ShowPERInteger(tag, indent, "bucketSize", (int32)x->bucketSize);
+    }
+    if (x->option_of_peakRate)
+    {
+        ShowPERInteger(tag, indent, "peakRate", (int32)x->peakRate);
+    }
+    if (x->option_of_minPoliced)
+    {
+        ShowPERInteger(tag, indent, "minPoliced", (int32)x->minPoliced);
+    }
+    if (x->option_of_maxPktSize)
+    {
+        ShowPERInteger(tag, indent, "maxPktSize", (int32)x->maxPktSize);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RSVPParameters");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for QOSMode (CHOICE)  */
+/* <=================================> */
+void Analyze_QOSMode(PS_QOSMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "QOSMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "guaranteedQOS");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "controlledLoad");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_QOSMode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "QOSMode");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for ATMParameters (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_ATMParameters(PS_ATMParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ATMParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maxNTUSize", (int32)x->maxNTUSize);
+    ShowPERBoolean(tag, indent, "atmUBR", x->atmUBR);
+    ShowPERBoolean(tag, indent, "atmrtVBR", x->atmrtVBR);
+    ShowPERBoolean(tag, indent, "atmnrtVBR", x->atmnrtVBR);
+    ShowPERBoolean(tag, indent, "atmABR", x->atmABR);
+    ShowPERBoolean(tag, indent, "atmCBR", x->atmCBR);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ATMParameters");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for QOSCapability (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_QOSCapability(PS_QOSCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "QOSCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandardData", x->option_of_nonStandardData);
+    ShowPERBoolean(tag, indent, "option_of_rsvpParameters", x->option_of_rsvpParameters);
+    ShowPERBoolean(tag, indent, "option_of_atmParameters", x->option_of_atmParameters);
+    if (x->option_of_nonStandardData)
+    {
+        Analyze_NonStandardParameter(&x->nonStandardData, "nonStandardData", tag, indent);
+    }
+    if (x->option_of_rsvpParameters)
+    {
+        Analyze_RSVPParameters(&x->rsvpParameters, "rsvpParameters", tag, indent);
+    }
+    if (x->option_of_atmParameters)
+    {
+        Analyze_ATMParameters(&x->atmParameters, "atmParameters", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "QOSCapability");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for MediaTransportType (CHOICE)  */
+/* <============================================> */
+void Analyze_MediaTransportType(PS_MediaTransportType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MediaTransportType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "ip_UDP");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "ip_TCP");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "atm_AAL5_UNIDIR");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "atm_AAL5_BIDIR");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            Analyze_Atm_AAL5_compressed(x->atm_AAL5_compressed, "atm_AAL5_compressed", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_MediaTransportType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MediaTransportType");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for Atm_AAL5_compressed (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Atm_AAL5_compressed");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "variable_delta", x->variable_delta);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Atm_AAL5_compressed");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for MediaChannelCapability (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_MediaChannelCapability(PS_MediaChannelCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MediaChannelCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_mediaTransport", x->option_of_mediaTransport);
+    if (x->option_of_mediaTransport)
+    {
+        Analyze_MediaTransportType(&x->mediaTransport, "mediaTransport", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MediaChannelCapability");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for TransportCapability (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_TransportCapability(PS_TransportCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "TransportCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    ShowPERBoolean(tag, indent, "option_of_qOSCapabilities", x->option_of_qOSCapabilities);
+    ShowPERBoolean(tag, indent, "option_of_mediaChannelCapabilities", x->option_of_mediaChannelCapabilities);
+    if (x->option_of_nonStandard)
+    {
+        Analyze_NonStandardParameter(&x->nonStandard, "nonStandard", tag, indent);
+    }
+    if (x->option_of_qOSCapabilities)
+    {
+        ShowPERInteger(tag, indent, "size_of_qOSCapabilities", (uint32)x->size_of_qOSCapabilities);
+        for (i = 0;i < x->size_of_qOSCapabilities;++i)
+        {
+            sprintf(tempLabelString, "qOSCapabilities[%hu]", i);
+            Analyze_QOSCapability(x->qOSCapabilities + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_mediaChannelCapabilities)
+    {
+        ShowPERInteger(tag, indent, "size_of_mediaChannelCapabilities", (uint32)x->size_of_mediaChannelCapabilities);
+        for (i = 0;i < x->size_of_mediaChannelCapabilities;++i)
+        {
+            sprintf(tempLabelString, "mediaChannelCapabilities[%hu]", i);
+            Analyze_MediaChannelCapability(x->mediaChannelCapabilities + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TransportCapability");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for RedundancyEncodingCapability (SEQUENCE)  */
+/* <========================================================> */
+void Analyze_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RedundancyEncodingCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_secondaryEncoding", x->option_of_secondaryEncoding);
+    Analyze_RedundancyEncodingMethod(&x->redundancyEncodingMethod, "redundancyEncodingMethod", tag, indent);
+    ShowPERInteger(tag, indent, "primaryEncoding", (int32)x->primaryEncoding);
+    if (x->option_of_secondaryEncoding)
+    {
+        ShowPERInteger(tag, indent, "size_of_secondaryEncoding", (uint32)x->size_of_secondaryEncoding);
+        for (i = 0;i < x->size_of_secondaryEncoding;++i)
+        {
+            ShowPERIntegers(tag, indent, "secondaryEncoding", (uint32)x->secondaryEncoding[i], i);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RedundancyEncodingCapability");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for RedundancyEncodingMethod (CHOICE)  */
+/* <==================================================> */
+void Analyze_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RedundancyEncodingMethod");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "rtpAudioRedundancyEncoding");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            Analyze_RTPH263VideoRedundancyEncoding(x->rtpH263VideoRedundancyEncoding, "rtpH263VideoRedundancyEncoding", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_RedundancyEncodingMethod: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RedundancyEncodingMethod");
+}
+
+/* <==========================================================> */
+/*  PER-Analyzer for RTPH263VideoRedundancyEncoding (SEQUENCE)  */
+/* <==========================================================> */
+void Analyze_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RTPH263VideoRedundancyEncoding");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_containedThreads", x->option_of_containedThreads);
+    ShowPERInteger(tag, indent, "numberOfThreads", (int32)x->numberOfThreads);
+    ShowPERInteger(tag, indent, "framesBetweenSyncPoints", (int32)x->framesBetweenSyncPoints);
+    Analyze_FrameToThreadMapping(&x->frameToThreadMapping, "frameToThreadMapping", tag, indent);
+    if (x->option_of_containedThreads)
+    {
+        ShowPERInteger(tag, indent, "size_of_containedThreads", (uint32)x->size_of_containedThreads);
+        for (i = 0;i < x->size_of_containedThreads;++i)
+        {
+            ShowPERIntegers(tag, indent, "containedThreads", (uint32)x->containedThreads[i], i);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RTPH263VideoRedundancyEncoding");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for FrameToThreadMapping (CHOICE)  */
+/* <==============================================> */
+void Analyze_FrameToThreadMapping(PS_FrameToThreadMapping x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "FrameToThreadMapping");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "roundrobin");
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "custom[%hu]", i);
+                Analyze_RTPH263VideoRedundancyFrameMapping(x->custom + i, tempLabelString, tag, indent);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_FrameToThreadMapping: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FrameToThreadMapping");
+}
+
+/* <==============================================================> */
+/*  PER-Analyzer for RTPH263VideoRedundancyFrameMapping (SEQUENCE)  */
+/* <==============================================================> */
+void Analyze_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RTPH263VideoRedundancyFrameMapping");
+    indent += 2;
+    ShowPERInteger(tag, indent, "threadNumber", (int32)x->threadNumber);
+    ShowPERInteger(tag, indent, "size_of_frameSequence", (uint32)x->size_of_frameSequence);
+    for (i = 0;i < x->size_of_frameSequence;++i)
+    {
+        ShowPERIntegers(tag, indent, "frameSequence", (uint32)x->frameSequence[i], i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RTPH263VideoRedundancyFrameMapping");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for MultipointCapability (SEQUENCE)  */
+/* <================================================> */
+void Analyze_MultipointCapability(PS_MultipointCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MultipointCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "multicastCapability", x->multicastCapability);
+    ShowPERBoolean(tag, indent, "multiUniCastConference", x->multiUniCastConference);
+    ShowPERInteger(tag, indent, "size_of_mediaDistributionCapability", (uint32)x->size_of_mediaDistributionCapability);
+    for (i = 0;i < x->size_of_mediaDistributionCapability;++i)
+    {
+        sprintf(tempLabelString, "mediaDistributionCapability[%hu]", i);
+        Analyze_MediaDistributionCapability(x->mediaDistributionCapability + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MultipointCapability");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for MediaDistributionCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_MediaDistributionCapability(PS_MediaDistributionCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MediaDistributionCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_centralizedData", x->option_of_centralizedData);
+    ShowPERBoolean(tag, indent, "option_of_distributedData", x->option_of_distributedData);
+    ShowPERBoolean(tag, indent, "centralizedControl", x->centralizedControl);
+    ShowPERBoolean(tag, indent, "distributedControl", x->distributedControl);
+    ShowPERBoolean(tag, indent, "centralizedAudio", x->centralizedAudio);
+    ShowPERBoolean(tag, indent, "distributedAudio", x->distributedAudio);
+    ShowPERBoolean(tag, indent, "centralizedVideo", x->centralizedVideo);
+    ShowPERBoolean(tag, indent, "distributedVideo", x->distributedVideo);
+    if (x->option_of_centralizedData)
+    {
+        ShowPERInteger(tag, indent, "size_of_centralizedData", (uint32)x->size_of_centralizedData);
+        for (i = 0;i < x->size_of_centralizedData;++i)
+        {
+            sprintf(tempLabelString, "centralizedData[%hu]", i);
+            Analyze_DataApplicationCapability(x->centralizedData + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_distributedData)
+    {
+        ShowPERInteger(tag, indent, "size_of_distributedData", (uint32)x->size_of_distributedData);
+        for (i = 0;i < x->size_of_distributedData;++i)
+        {
+            sprintf(tempLabelString, "distributedData[%hu]", i);
+            Analyze_DataApplicationCapability(x->distributedData + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MediaDistributionCapability");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for VideoCapability (CHOICE)  */
+/* <=========================================> */
+void Analyze_VideoCapability(PS_VideoCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "VideoCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_H261VideoCapability(x->h261VideoCapability, "h261VideoCapability", tag, indent);
+            break;
+        case 2:
+            Analyze_H262VideoCapability(x->h262VideoCapability, "h262VideoCapability", tag, indent);
+            break;
+        case 3:
+            Analyze_H263VideoCapability(x->h263VideoCapability, "h263VideoCapability", tag, indent);
+            break;
+        case 4:
+            Analyze_IS11172VideoCapability(x->is11172VideoCapability, "is11172VideoCapability", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            Analyze_GenericCapability(x->genericVideoCapability, "genericVideoCapability", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_VideoCapability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "VideoCapability");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for H261VideoCapability (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_H261VideoCapability(PS_H261VideoCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H261VideoCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_qcifMPI", x->option_of_qcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cifMPI", x->option_of_cifMPI);
+    if (x->option_of_qcifMPI)
+    {
+        ShowPERInteger(tag, indent, "qcifMPI", (int32)x->qcifMPI);
+    }
+    if (x->option_of_cifMPI)
+    {
+        ShowPERInteger(tag, indent, "cifMPI", (int32)x->cifMPI);
+    }
+    ShowPERBoolean(tag, indent, "temporalSpatialTradeOffCapability", x->temporalSpatialTradeOffCapability);
+    ShowPERInteger(tag, indent, "maxBitRate", (int32)x->maxBitRate);
+    ShowPERBoolean(tag, indent, "stillImageTransmission", x->stillImageTransmission);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H261VideoCapability");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for H262VideoCapability (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_H262VideoCapability(PS_H262VideoCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H262VideoCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_videoBitRate", x->option_of_videoBitRate);
+    ShowPERBoolean(tag, indent, "option_of_vbvBufferSize", x->option_of_vbvBufferSize);
+    ShowPERBoolean(tag, indent, "option_of_samplesPerLine", x->option_of_samplesPerLine);
+    ShowPERBoolean(tag, indent, "option_of_linesPerFrame", x->option_of_linesPerFrame);
+    ShowPERBoolean(tag, indent, "option_of_framesPerSecond", x->option_of_framesPerSecond);
+    ShowPERBoolean(tag, indent, "option_of_luminanceSampleRate", x->option_of_luminanceSampleRate);
+    ShowPERBoolean(tag, indent, "profileAndLevel_SPatML", x->profileAndLevel_SPatML);
+    ShowPERBoolean(tag, indent, "profileAndLevel_MPatLL", x->profileAndLevel_MPatLL);
+    ShowPERBoolean(tag, indent, "profileAndLevel_MPatML", x->profileAndLevel_MPatML);
+    ShowPERBoolean(tag, indent, "profileAndLevel_MPatH_14", x->profileAndLevel_MPatH_14);
+    ShowPERBoolean(tag, indent, "profileAndLevel_MPatHL", x->profileAndLevel_MPatHL);
+    ShowPERBoolean(tag, indent, "profileAndLevel_SNRatLL", x->profileAndLevel_SNRatLL);
+    ShowPERBoolean(tag, indent, "profileAndLevel_SNRatML", x->profileAndLevel_SNRatML);
+    ShowPERBoolean(tag, indent, "profileAndLevel_SpatialatH_14", x->profileAndLevel_SpatialatH_14);
+    ShowPERBoolean(tag, indent, "profileAndLevel_HPatML", x->profileAndLevel_HPatML);
+    ShowPERBoolean(tag, indent, "profileAndLevel_HPatH_14", x->profileAndLevel_HPatH_14);
+    ShowPERBoolean(tag, indent, "profileAndLevel_HPatHL", x->profileAndLevel_HPatHL);
+    if (x->option_of_videoBitRate)
+    {
+        ShowPERInteger(tag, indent, "videoBitRate", (int32)x->videoBitRate);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        ShowPERInteger(tag, indent, "vbvBufferSize", (int32)x->vbvBufferSize);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        ShowPERInteger(tag, indent, "samplesPerLine", (int32)x->samplesPerLine);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        ShowPERInteger(tag, indent, "linesPerFrame", (int32)x->linesPerFrame);
+    }
+    if (x->option_of_framesPerSecond)
+    {
+        ShowPERInteger(tag, indent, "framesPerSecond", (int32)x->framesPerSecond);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        ShowPERInteger(tag, indent, "luminanceSampleRate", (int32)x->luminanceSampleRate);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H262VideoCapability");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for H263VideoCapability (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_H263VideoCapability(PS_H263VideoCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H263VideoCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_sqcifMPI", x->option_of_sqcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_qcifMPI", x->option_of_qcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cifMPI", x->option_of_cifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cif4MPI", x->option_of_cif4MPI);
+    ShowPERBoolean(tag, indent, "option_of_cif16MPI", x->option_of_cif16MPI);
+    ShowPERBoolean(tag, indent, "option_of_hrd_B", x->option_of_hrd_B);
+    ShowPERBoolean(tag, indent, "option_of_bppMaxKb", x->option_of_bppMaxKb);
+    if (x->option_of_sqcifMPI)
+    {
+        ShowPERInteger(tag, indent, "sqcifMPI", (int32)x->sqcifMPI);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        ShowPERInteger(tag, indent, "qcifMPI", (int32)x->qcifMPI);
+    }
+    if (x->option_of_cifMPI)
+    {
+        ShowPERInteger(tag, indent, "cifMPI", (int32)x->cifMPI);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        ShowPERInteger(tag, indent, "cif4MPI", (int32)x->cif4MPI);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        ShowPERInteger(tag, indent, "cif16MPI", (int32)x->cif16MPI);
+    }
+    ShowPERInteger(tag, indent, "maxBitRate", (int32)x->maxBitRate);
+    ShowPERBoolean(tag, indent, "unrestrictedVector", x->unrestrictedVector);
+    ShowPERBoolean(tag, indent, "arithmeticCoding", x->arithmeticCoding);
+    ShowPERBoolean(tag, indent, "advancedPrediction", x->advancedPrediction);
+    ShowPERBoolean(tag, indent, "pbFrames", x->pbFrames);
+    ShowPERBoolean(tag, indent, "temporalSpatialTradeOffCapability", x->temporalSpatialTradeOffCapability);
+    if (x->option_of_hrd_B)
+    {
+        ShowPERInteger(tag, indent, "hrd_B", (int32)x->hrd_B);
+    }
+    if (x->option_of_bppMaxKb)
+    {
+        ShowPERInteger(tag, indent, "bppMaxKb", (int32)x->bppMaxKb);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_slowSqcifMPI", x->option_of_slowSqcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_slowQcifMPI", x->option_of_slowQcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_slowCifMPI", x->option_of_slowCifMPI);
+    ShowPERBoolean(tag, indent, "option_of_slowCif4MPI", x->option_of_slowCif4MPI);
+    ShowPERBoolean(tag, indent, "option_of_slowCif16MPI", x->option_of_slowCif16MPI);
+    ShowPERBoolean(tag, indent, "option_of_errorCompensation", x->option_of_errorCompensation);
+    ShowPERBoolean(tag, indent, "option_of_enhancementLayerInfo", x->option_of_enhancementLayerInfo);
+    ShowPERBoolean(tag, indent, "option_of_h263Options", x->option_of_h263Options);
+    if (x->option_of_slowSqcifMPI)
+    {
+        ShowPERInteger(tag, indent, "slowSqcifMPI", (int32)x->slowSqcifMPI);
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+        ShowPERInteger(tag, indent, "slowQcifMPI", (int32)x->slowQcifMPI);
+    }
+    if (x->option_of_slowCifMPI)
+    {
+        ShowPERInteger(tag, indent, "slowCifMPI", (int32)x->slowCifMPI);
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+        ShowPERInteger(tag, indent, "slowCif4MPI", (int32)x->slowCif4MPI);
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+        ShowPERInteger(tag, indent, "slowCif16MPI", (int32)x->slowCif16MPI);
+    }
+    if (x->option_of_errorCompensation)
+    {
+        ShowPERBoolean(tag, indent, "errorCompensation", x->errorCompensation);
+    }
+    if (x->option_of_enhancementLayerInfo)
+    {
+        Analyze_EnhancementLayerInfo(&x->enhancementLayerInfo, "enhancementLayerInfo", tag, indent);
+    }
+    if (x->option_of_h263Options)
+    {
+        Analyze_H263Options(&x->h263Options, "h263Options", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "H263VideoCapability");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for EnhancementLayerInfo (SEQUENCE)  */
+/* <================================================> */
+void Analyze_EnhancementLayerInfo(PS_EnhancementLayerInfo x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "EnhancementLayerInfo");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_snrEnhancement", x->option_of_snrEnhancement);
+    ShowPERBoolean(tag, indent, "option_of_spatialEnhancement", x->option_of_spatialEnhancement);
+    ShowPERBoolean(tag, indent, "option_of_bPictureEnhancement", x->option_of_bPictureEnhancement);
+    ShowPERBoolean(tag, indent, "baseBitRateConstrained", x->baseBitRateConstrained);
+    if (x->option_of_snrEnhancement)
+    {
+        ShowPERInteger(tag, indent, "size_of_snrEnhancement", (uint32)x->size_of_snrEnhancement);
+        for (i = 0;i < x->size_of_snrEnhancement;++i)
+        {
+            sprintf(tempLabelString, "snrEnhancement[%hu]", i);
+            Analyze_EnhancementOptions(x->snrEnhancement + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_spatialEnhancement)
+    {
+        ShowPERInteger(tag, indent, "size_of_spatialEnhancement", (uint32)x->size_of_spatialEnhancement);
+        for (i = 0;i < x->size_of_spatialEnhancement;++i)
+        {
+            sprintf(tempLabelString, "spatialEnhancement[%hu]", i);
+            Analyze_EnhancementOptions(x->spatialEnhancement + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_bPictureEnhancement)
+    {
+        ShowPERInteger(tag, indent, "size_of_bPictureEnhancement", (uint32)x->size_of_bPictureEnhancement);
+        for (i = 0;i < x->size_of_bPictureEnhancement;++i)
+        {
+            sprintf(tempLabelString, "bPictureEnhancement[%hu]", i);
+            Analyze_BEnhancementParameters(x->bPictureEnhancement + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "EnhancementLayerInfo");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for BEnhancementParameters (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_BEnhancementParameters(PS_BEnhancementParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "BEnhancementParameters");
+    indent += 2;
+    Analyze_EnhancementOptions(&x->enhancementOptions, "enhancementOptions", tag, indent);
+    ShowPERInteger(tag, indent, "numberOfBPictures", (int32)x->numberOfBPictures);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "BEnhancementParameters");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for EnhancementOptions (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_EnhancementOptions(PS_EnhancementOptions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "EnhancementOptions");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_sqcifMPI", x->option_of_sqcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_qcifMPI", x->option_of_qcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cifMPI", x->option_of_cifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cif4MPI", x->option_of_cif4MPI);
+    ShowPERBoolean(tag, indent, "option_of_cif16MPI", x->option_of_cif16MPI);
+    ShowPERBoolean(tag, indent, "option_of_slowSqcifMPI", x->option_of_slowSqcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_slowQcifMPI", x->option_of_slowQcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_slowCifMPI", x->option_of_slowCifMPI);
+    ShowPERBoolean(tag, indent, "option_of_slowCif4MPI", x->option_of_slowCif4MPI);
+    ShowPERBoolean(tag, indent, "option_of_slowCif16MPI", x->option_of_slowCif16MPI);
+    ShowPERBoolean(tag, indent, "option_of_h263Options", x->option_of_h263Options);
+    if (x->option_of_sqcifMPI)
+    {
+        ShowPERInteger(tag, indent, "sqcifMPI", (int32)x->sqcifMPI);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        ShowPERInteger(tag, indent, "qcifMPI", (int32)x->qcifMPI);
+    }
+    if (x->option_of_cifMPI)
+    {
+        ShowPERInteger(tag, indent, "cifMPI", (int32)x->cifMPI);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        ShowPERInteger(tag, indent, "cif4MPI", (int32)x->cif4MPI);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        ShowPERInteger(tag, indent, "cif16MPI", (int32)x->cif16MPI);
+    }
+    ShowPERInteger(tag, indent, "maxBitRate", (int32)x->maxBitRate);
+    ShowPERBoolean(tag, indent, "unrestrictedVector", x->unrestrictedVector);
+    ShowPERBoolean(tag, indent, "arithmeticCoding", x->arithmeticCoding);
+    ShowPERBoolean(tag, indent, "temporalSpatialTradeOffCapability", x->temporalSpatialTradeOffCapability);
+    if (x->option_of_slowSqcifMPI)
+    {
+        ShowPERInteger(tag, indent, "slowSqcifMPI", (int32)x->slowSqcifMPI);
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+        ShowPERInteger(tag, indent, "slowQcifMPI", (int32)x->slowQcifMPI);
+    }
+    if (x->option_of_slowCifMPI)
+    {
+        ShowPERInteger(tag, indent, "slowCifMPI", (int32)x->slowCifMPI);
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+        ShowPERInteger(tag, indent, "slowCif4MPI", (int32)x->slowCif4MPI);
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+        ShowPERInteger(tag, indent, "slowCif16MPI", (int32)x->slowCif16MPI);
+    }
+    ShowPERBoolean(tag, indent, "errorCompensation", x->errorCompensation);
+    if (x->option_of_h263Options)
+    {
+        Analyze_H263Options(&x->h263Options, "h263Options", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "EnhancementOptions");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for H263Options (SEQUENCE)  */
+/* <=======================================> */
+void Analyze_H263Options(PS_H263Options x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "H263Options");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_transparencyParameters", x->option_of_transparencyParameters);
+    ShowPERBoolean(tag, indent, "option_of_refPictureSelection", x->option_of_refPictureSelection);
+    ShowPERBoolean(tag, indent, "option_of_customPictureClockFrequency", x->option_of_customPictureClockFrequency);
+    ShowPERBoolean(tag, indent, "option_of_customPictureFormat", x->option_of_customPictureFormat);
+    ShowPERBoolean(tag, indent, "option_of_modeCombos", x->option_of_modeCombos);
+    ShowPERBoolean(tag, indent, "advancedIntraCodingMode", x->advancedIntraCodingMode);
+    ShowPERBoolean(tag, indent, "deblockingFilterMode", x->deblockingFilterMode);
+    ShowPERBoolean(tag, indent, "improvedPBFramesMode", x->improvedPBFramesMode);
+    ShowPERBoolean(tag, indent, "unlimitedMotionVectors", x->unlimitedMotionVectors);
+    ShowPERBoolean(tag, indent, "fullPictureFreeze", x->fullPictureFreeze);
+    ShowPERBoolean(tag, indent, "partialPictureFreezeAndRelease", x->partialPictureFreezeAndRelease);
+    ShowPERBoolean(tag, indent, "resizingPartPicFreezeAndRelease", x->resizingPartPicFreezeAndRelease);
+    ShowPERBoolean(tag, indent, "fullPictureSnapshot", x->fullPictureSnapshot);
+    ShowPERBoolean(tag, indent, "partialPictureSnapshot", x->partialPictureSnapshot);
+    ShowPERBoolean(tag, indent, "videoSegmentTagging", x->videoSegmentTagging);
+    ShowPERBoolean(tag, indent, "progressiveRefinement", x->progressiveRefinement);
+    ShowPERBoolean(tag, indent, "dynamicPictureResizingByFour", x->dynamicPictureResizingByFour);
+    ShowPERBoolean(tag, indent, "dynamicPictureResizingSixteenthPel", x->dynamicPictureResizingSixteenthPel);
+    ShowPERBoolean(tag, indent, "dynamicWarpingHalfPel", x->dynamicWarpingHalfPel);
+    ShowPERBoolean(tag, indent, "dynamicWarpingSixteenthPel", x->dynamicWarpingSixteenthPel);
+    ShowPERBoolean(tag, indent, "independentSegmentDecoding", x->independentSegmentDecoding);
+    ShowPERBoolean(tag, indent, "slicesInOrder_NonRect", x->slicesInOrder_NonRect);
+    ShowPERBoolean(tag, indent, "slicesInOrder_Rect", x->slicesInOrder_Rect);
+    ShowPERBoolean(tag, indent, "slicesNoOrder_NonRect", x->slicesNoOrder_NonRect);
+    ShowPERBoolean(tag, indent, "slicesNoOrder_Rect", x->slicesNoOrder_Rect);
+    ShowPERBoolean(tag, indent, "alternateInterVLCMode", x->alternateInterVLCMode);
+    ShowPERBoolean(tag, indent, "modifiedQuantizationMode", x->modifiedQuantizationMode);
+    ShowPERBoolean(tag, indent, "reducedResolutionUpdate", x->reducedResolutionUpdate);
+    if (x->option_of_transparencyParameters)
+    {
+        Analyze_TransparencyParameters(&x->transparencyParameters, "transparencyParameters", tag, indent);
+    }
+    ShowPERBoolean(tag, indent, "separateVideoBackChannel", x->separateVideoBackChannel);
+    if (x->option_of_refPictureSelection)
+    {
+        Analyze_RefPictureSelection(&x->refPictureSelection, "refPictureSelection", tag, indent);
+    }
+    if (x->option_of_customPictureClockFrequency)
+    {
+        ShowPERInteger(tag, indent, "size_of_customPictureClockFrequency", (uint32)x->size_of_customPictureClockFrequency);
+        for (i = 0;i < x->size_of_customPictureClockFrequency;++i)
+        {
+            sprintf(tempLabelString, "customPictureClockFrequency[%hu]", i);
+            Analyze_CustomPictureClockFrequency(x->customPictureClockFrequency + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_customPictureFormat)
+    {
+        ShowPERInteger(tag, indent, "size_of_customPictureFormat", (uint32)x->size_of_customPictureFormat);
+        for (i = 0;i < x->size_of_customPictureFormat;++i)
+        {
+            sprintf(tempLabelString, "customPictureFormat[%hu]", i);
+            Analyze_CustomPictureFormat(x->customPictureFormat + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_modeCombos)
+    {
+        ShowPERInteger(tag, indent, "size_of_modeCombos", (uint32)x->size_of_modeCombos);
+        for (i = 0;i < x->size_of_modeCombos;++i)
+        {
+            sprintf(tempLabelString, "modeCombos[%hu]", i);
+            Analyze_H263VideoModeCombos(x->modeCombos + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H263Options");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for TransparencyParameters (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_TransparencyParameters(PS_TransparencyParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TransparencyParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "presentationOrder", (int32)x->presentationOrder);
+    ShowPERSignedInteger(tag, indent, "offset_x", (int32)x->offset_x);
+    ShowPERSignedInteger(tag, indent, "offset_y", (int32)x->offset_y);
+    ShowPERInteger(tag, indent, "scale_x", (int32)x->scale_x);
+    ShowPERInteger(tag, indent, "scale_y", (int32)x->scale_y);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TransparencyParameters");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for RefPictureSelection (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_RefPictureSelection(PS_RefPictureSelection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RefPictureSelection");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_additionalPictureMemory", x->option_of_additionalPictureMemory);
+    if (x->option_of_additionalPictureMemory)
+    {
+        Analyze_AdditionalPictureMemory(&x->additionalPictureMemory, "additionalPictureMemory", tag, indent);
+    }
+    ShowPERBoolean(tag, indent, "videoMux", x->videoMux);
+    Analyze_VideoBackChannelSend(&x->videoBackChannelSend, "videoBackChannelSend", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RefPictureSelection");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for VideoBackChannelSend (CHOICE)  */
+/* <==============================================> */
+void Analyze_VideoBackChannelSend(PS_VideoBackChannelSend x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "VideoBackChannelSend");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "none");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "ackMessageOnly");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "nackMessageOnly");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "ackOrNackMessageOnly");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "ackAndNackMessage");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_VideoBackChannelSend: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "VideoBackChannelSend");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for AdditionalPictureMemory (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_AdditionalPictureMemory(PS_AdditionalPictureMemory x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "AdditionalPictureMemory");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_sqcifAdditionalPictureMemory", x->option_of_sqcifAdditionalPictureMemory);
+    ShowPERBoolean(tag, indent, "option_of_qcifAdditionalPictureMemory", x->option_of_qcifAdditionalPictureMemory);
+    ShowPERBoolean(tag, indent, "option_of_cifAdditionalPictureMemory", x->option_of_cifAdditionalPictureMemory);
+    ShowPERBoolean(tag, indent, "option_of_cif4AdditionalPictureMemory", x->option_of_cif4AdditionalPictureMemory);
+    ShowPERBoolean(tag, indent, "option_of_cif16AdditionalPictureMemory", x->option_of_cif16AdditionalPictureMemory);
+    ShowPERBoolean(tag, indent, "option_of_bigCpfAdditionalPictureMemory", x->option_of_bigCpfAdditionalPictureMemory);
+    if (x->option_of_sqcifAdditionalPictureMemory)
+    {
+        ShowPERInteger(tag, indent, "sqcifAdditionalPictureMemory", (int32)x->sqcifAdditionalPictureMemory);
+    }
+    if (x->option_of_qcifAdditionalPictureMemory)
+    {
+        ShowPERInteger(tag, indent, "qcifAdditionalPictureMemory", (int32)x->qcifAdditionalPictureMemory);
+    }
+    if (x->option_of_cifAdditionalPictureMemory)
+    {
+        ShowPERInteger(tag, indent, "cifAdditionalPictureMemory", (int32)x->cifAdditionalPictureMemory);
+    }
+    if (x->option_of_cif4AdditionalPictureMemory)
+    {
+        ShowPERInteger(tag, indent, "cif4AdditionalPictureMemory", (int32)x->cif4AdditionalPictureMemory);
+    }
+    if (x->option_of_cif16AdditionalPictureMemory)
+    {
+        ShowPERInteger(tag, indent, "cif16AdditionalPictureMemory", (int32)x->cif16AdditionalPictureMemory);
+    }
+    if (x->option_of_bigCpfAdditionalPictureMemory)
+    {
+        ShowPERInteger(tag, indent, "bigCpfAdditionalPictureMemory", (int32)x->bigCpfAdditionalPictureMemory);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "AdditionalPictureMemory");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for CustomPictureClockFrequency (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CustomPictureClockFrequency");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_sqcifMPI", x->option_of_sqcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_qcifMPI", x->option_of_qcifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cifMPI", x->option_of_cifMPI);
+    ShowPERBoolean(tag, indent, "option_of_cif4MPI", x->option_of_cif4MPI);
+    ShowPERBoolean(tag, indent, "option_of_cif16MPI", x->option_of_cif16MPI);
+    ShowPERInteger(tag, indent, "clockConversionCode", (int32)x->clockConversionCode);
+    ShowPERInteger(tag, indent, "clockDivisor", (int32)x->clockDivisor);
+    if (x->option_of_sqcifMPI)
+    {
+        ShowPERInteger(tag, indent, "sqcifMPI", (int32)x->sqcifMPI);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        ShowPERInteger(tag, indent, "qcifMPI", (int32)x->qcifMPI);
+    }
+    if (x->option_of_cifMPI)
+    {
+        ShowPERInteger(tag, indent, "cifMPI", (int32)x->cifMPI);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        ShowPERInteger(tag, indent, "cif4MPI", (int32)x->cif4MPI);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        ShowPERInteger(tag, indent, "cif16MPI", (int32)x->cif16MPI);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CustomPictureClockFrequency");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for CustomPictureFormat (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_CustomPictureFormat(PS_CustomPictureFormat x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CustomPictureFormat");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maxCustomPictureWidth", (int32)x->maxCustomPictureWidth);
+    ShowPERInteger(tag, indent, "maxCustomPictureHeight", (int32)x->maxCustomPictureHeight);
+    ShowPERInteger(tag, indent, "minCustomPictureWidth", (int32)x->minCustomPictureWidth);
+    ShowPERInteger(tag, indent, "minCustomPictureHeight", (int32)x->minCustomPictureHeight);
+    Analyze_MPI(&x->mPI, "mPI", tag, indent);
+    Analyze_PixelAspectInformation(&x->pixelAspectInformation, "pixelAspectInformation", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CustomPictureFormat");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for PixelAspectInformation (CHOICE)  */
+/* <================================================> */
+void Analyze_PixelAspectInformation(PS_PixelAspectInformation x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "PixelAspectInformation");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERBoolean(tag, indent, "anyPixelAspectRatio", x->anyPixelAspectRatio);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                ShowPERIntegers(tag, indent, "pixelAspectCode", (uint32)x->pixelAspectCode[i], i);
+            }
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "extendedPAR[%hu]", i);
+                Analyze_ExtendedPARItem(x->extendedPAR + i, tempLabelString, tag, indent);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_PixelAspectInformation: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "PixelAspectInformation");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for ExtendedPARItem (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_ExtendedPARItem(PS_ExtendedPARItem x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ExtendedPARItem");
+    indent += 2;
+    ShowPERInteger(tag, indent, "width", (int32)x->width);
+    ShowPERInteger(tag, indent, "height", (int32)x->height);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ExtendedPARItem");
+}
+
+/* <===============================> */
+/*  PER-Analyzer for MPI (SEQUENCE)  */
+/* <===============================> */
+void Analyze_MPI(PS_MPI x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MPI");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_standardMPI", x->option_of_standardMPI);
+    ShowPERBoolean(tag, indent, "option_of_customPCF", x->option_of_customPCF);
+    if (x->option_of_standardMPI)
+    {
+        ShowPERInteger(tag, indent, "standardMPI", (int32)x->standardMPI);
+    }
+    if (x->option_of_customPCF)
+    {
+        ShowPERInteger(tag, indent, "size_of_customPCF", (uint32)x->size_of_customPCF);
+        for (i = 0;i < x->size_of_customPCF;++i)
+        {
+            sprintf(tempLabelString, "customPCF[%hu]", i);
+            Analyze_CustomPCFItem(x->customPCF + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MPI");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for CustomPCFItem (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_CustomPCFItem(PS_CustomPCFItem x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CustomPCFItem");
+    indent += 2;
+    ShowPERInteger(tag, indent, "clockConversionCode", (int32)x->clockConversionCode);
+    ShowPERInteger(tag, indent, "clockDivisor", (int32)x->clockDivisor);
+    ShowPERInteger(tag, indent, "customMPI", (int32)x->customMPI);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CustomPCFItem");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for H263VideoModeCombos (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_H263VideoModeCombos(PS_H263VideoModeCombos x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "H263VideoModeCombos");
+    indent += 2;
+    Analyze_H263ModeComboFlags(&x->h263VideoUncoupledModes, "h263VideoUncoupledModes", tag, indent);
+    ShowPERInteger(tag, indent, "size_of_h263VideoCoupledModes", (uint32)x->size_of_h263VideoCoupledModes);
+    for (i = 0;i < x->size_of_h263VideoCoupledModes;++i)
+    {
+        sprintf(tempLabelString, "h263VideoCoupledModes[%hu]", i);
+        Analyze_H263ModeComboFlags(x->h263VideoCoupledModes + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H263VideoModeCombos");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H263ModeComboFlags (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_H263ModeComboFlags(PS_H263ModeComboFlags x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H263ModeComboFlags");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "unrestrictedVector", x->unrestrictedVector);
+    ShowPERBoolean(tag, indent, "arithmeticCoding", x->arithmeticCoding);
+    ShowPERBoolean(tag, indent, "advancedPrediction", x->advancedPrediction);
+    ShowPERBoolean(tag, indent, "pbFrames", x->pbFrames);
+    ShowPERBoolean(tag, indent, "advancedIntraCodingMode", x->advancedIntraCodingMode);
+    ShowPERBoolean(tag, indent, "deblockingFilterMode", x->deblockingFilterMode);
+    ShowPERBoolean(tag, indent, "unlimitedMotionVectors", x->unlimitedMotionVectors);
+    ShowPERBoolean(tag, indent, "slicesInOrder_NonRect", x->slicesInOrder_NonRect);
+    ShowPERBoolean(tag, indent, "slicesInOrder_Rect", x->slicesInOrder_Rect);
+    ShowPERBoolean(tag, indent, "slicesNoOrder_NonRect", x->slicesNoOrder_NonRect);
+    ShowPERBoolean(tag, indent, "slicesNoOrder_Rect", x->slicesNoOrder_Rect);
+    ShowPERBoolean(tag, indent, "improvedPBFramesMode", x->improvedPBFramesMode);
+    ShowPERBoolean(tag, indent, "referencePicSelect", x->referencePicSelect);
+    ShowPERBoolean(tag, indent, "dynamicPictureResizingByFour", x->dynamicPictureResizingByFour);
+    ShowPERBoolean(tag, indent, "dynamicPictureResizingSixteenthPel", x->dynamicPictureResizingSixteenthPel);
+    ShowPERBoolean(tag, indent, "dynamicWarpingHalfPel", x->dynamicWarpingHalfPel);
+    ShowPERBoolean(tag, indent, "dynamicWarpingSixteenthPel", x->dynamicWarpingSixteenthPel);
+    ShowPERBoolean(tag, indent, "reducedResolutionUpdate", x->reducedResolutionUpdate);
+    ShowPERBoolean(tag, indent, "independentSegmentDecoding", x->independentSegmentDecoding);
+    ShowPERBoolean(tag, indent, "alternateInterVLCMode", x->alternateInterVLCMode);
+    ShowPERBoolean(tag, indent, "modifiedQuantizationMode", x->modifiedQuantizationMode);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H263ModeComboFlags");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for IS11172VideoCapability (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_IS11172VideoCapability(PS_IS11172VideoCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IS11172VideoCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_videoBitRate", x->option_of_videoBitRate);
+    ShowPERBoolean(tag, indent, "option_of_vbvBufferSize", x->option_of_vbvBufferSize);
+    ShowPERBoolean(tag, indent, "option_of_samplesPerLine", x->option_of_samplesPerLine);
+    ShowPERBoolean(tag, indent, "option_of_linesPerFrame", x->option_of_linesPerFrame);
+    ShowPERBoolean(tag, indent, "option_of_pictureRate", x->option_of_pictureRate);
+    ShowPERBoolean(tag, indent, "option_of_luminanceSampleRate", x->option_of_luminanceSampleRate);
+    ShowPERBoolean(tag, indent, "constrainedBitstream", x->constrainedBitstream);
+    if (x->option_of_videoBitRate)
+    {
+        ShowPERInteger(tag, indent, "videoBitRate", (int32)x->videoBitRate);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        ShowPERInteger(tag, indent, "vbvBufferSize", (int32)x->vbvBufferSize);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        ShowPERInteger(tag, indent, "samplesPerLine", (int32)x->samplesPerLine);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        ShowPERInteger(tag, indent, "linesPerFrame", (int32)x->linesPerFrame);
+    }
+    if (x->option_of_pictureRate)
+    {
+        ShowPERInteger(tag, indent, "pictureRate", (int32)x->pictureRate);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        ShowPERInteger(tag, indent, "luminanceSampleRate", (int32)x->luminanceSampleRate);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IS11172VideoCapability");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for AudioCapability (CHOICE)  */
+/* <=========================================> */
+void Analyze_AudioCapability(PS_AudioCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "AudioCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "g711Alaw64k", (uint32)x->g711Alaw64k);
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "g711Alaw56k", (uint32)x->g711Alaw56k);
+            break;
+        case 3:
+            ShowPERInteger(tag, indent, "g711Ulaw64k", (uint32)x->g711Ulaw64k);
+            break;
+        case 4:
+            ShowPERInteger(tag, indent, "g711Ulaw56k", (uint32)x->g711Ulaw56k);
+            break;
+        case 5:
+            ShowPERInteger(tag, indent, "g722_64k", (uint32)x->g722_64k);
+            break;
+        case 6:
+            ShowPERInteger(tag, indent, "g722_56k", (uint32)x->g722_56k);
+            break;
+        case 7:
+            ShowPERInteger(tag, indent, "g722_48k", (uint32)x->g722_48k);
+            break;
+        case 8:
+            Analyze_G7231(x->g7231, "g7231", tag, indent);
+            break;
+        case 9:
+            ShowPERInteger(tag, indent, "g728", (uint32)x->g728);
+            break;
+        case 10:
+            ShowPERInteger(tag, indent, "g729", (uint32)x->g729);
+            break;
+        case 11:
+            ShowPERInteger(tag, indent, "g729AnnexA", (uint32)x->g729AnnexA);
+            break;
+        case 12:
+            Analyze_IS11172AudioCapability(x->is11172AudioCapability, "is11172AudioCapability", tag, indent);
+            break;
+        case 13:
+            Analyze_IS13818AudioCapability(x->is13818AudioCapability, "is13818AudioCapability", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            ShowPERInteger(tag, indent, "g729wAnnexB", (uint32)x->g729wAnnexB);
+            break;
+        case 15:
+            ShowPERInteger(tag, indent, "g729AnnexAwAnnexB", (uint32)x->g729AnnexAwAnnexB);
+            break;
+        case 16:
+            Analyze_G7231AnnexCCapability(x->g7231AnnexCCapability, "g7231AnnexCCapability", tag, indent);
+            break;
+        case 17:
+            Analyze_GSMAudioCapability(x->gsmFullRate, "gsmFullRate", tag, indent);
+            break;
+        case 18:
+            Analyze_GSMAudioCapability(x->gsmHalfRate, "gsmHalfRate", tag, indent);
+            break;
+        case 19:
+            Analyze_GSMAudioCapability(x->gsmEnhancedFullRate, "gsmEnhancedFullRate", tag, indent);
+            break;
+        case 20:
+            Analyze_GenericCapability(x->genericAudioCapability, "genericAudioCapability", tag, indent);
+            break;
+        case 21:
+            Analyze_G729Extensions(x->g729Extensions, "g729Extensions", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_AudioCapability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "AudioCapability");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for G7231 (SEQUENCE)  */
+/* <=================================> */
+void Analyze_G7231(PS_G7231 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "G7231");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maxAl_sduAudioFrames", (int32)x->maxAl_sduAudioFrames);
+    ShowPERBoolean(tag, indent, "silenceSuppression", x->silenceSuppression);
+    ShowPERClosure(tag, indent, "G7231");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for G729Extensions (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_G729Extensions(PS_G729Extensions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "G729Extensions");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_audioUnit", x->option_of_audioUnit);
+    if (x->option_of_audioUnit)
+    {
+        ShowPERInteger(tag, indent, "audioUnit", (int32)x->audioUnit);
+    }
+    ShowPERBoolean(tag, indent, "annexA", x->annexA);
+    ShowPERBoolean(tag, indent, "annexB", x->annexB);
+    ShowPERBoolean(tag, indent, "annexD", x->annexD);
+    ShowPERBoolean(tag, indent, "annexE", x->annexE);
+    ShowPERBoolean(tag, indent, "annexF", x->annexF);
+    ShowPERBoolean(tag, indent, "annexG", x->annexG);
+    ShowPERBoolean(tag, indent, "annexH", x->annexH);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "G729Extensions");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for G7231AnnexCCapability (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_G7231AnnexCCapability(PS_G7231AnnexCCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "G7231AnnexCCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_g723AnnexCAudioMode", x->option_of_g723AnnexCAudioMode);
+    ShowPERInteger(tag, indent, "maxAl_sduAudioFrames", (int32)x->maxAl_sduAudioFrames);
+    ShowPERBoolean(tag, indent, "silenceSuppression", x->silenceSuppression);
+    if (x->option_of_g723AnnexCAudioMode)
+    {
+        Analyze_G723AnnexCAudioMode(&x->g723AnnexCAudioMode, "g723AnnexCAudioMode", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "G7231AnnexCCapability");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for G723AnnexCAudioMode (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "G723AnnexCAudioMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "highRateMode0", (int32)x->highRateMode0);
+    ShowPERInteger(tag, indent, "highRateMode1", (int32)x->highRateMode1);
+    ShowPERInteger(tag, indent, "lowRateMode0", (int32)x->lowRateMode0);
+    ShowPERInteger(tag, indent, "lowRateMode1", (int32)x->lowRateMode1);
+    ShowPERInteger(tag, indent, "sidMode0", (int32)x->sidMode0);
+    ShowPERInteger(tag, indent, "sidMode1", (int32)x->sidMode1);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "G723AnnexCAudioMode");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for IS11172AudioCapability (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_IS11172AudioCapability(PS_IS11172AudioCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IS11172AudioCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "audioLayer1", x->audioLayer1);
+    ShowPERBoolean(tag, indent, "audioLayer2", x->audioLayer2);
+    ShowPERBoolean(tag, indent, "audioLayer3", x->audioLayer3);
+    ShowPERBoolean(tag, indent, "audioSampling32k", x->audioSampling32k);
+    ShowPERBoolean(tag, indent, "audioSampling44k1", x->audioSampling44k1);
+    ShowPERBoolean(tag, indent, "audioSampling48k", x->audioSampling48k);
+    ShowPERBoolean(tag, indent, "singleChannel", x->singleChannel);
+    ShowPERBoolean(tag, indent, "twoChannels", x->twoChannels);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IS11172AudioCapability");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for IS13818AudioCapability (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_IS13818AudioCapability(PS_IS13818AudioCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IS13818AudioCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "audioLayer1", x->audioLayer1);
+    ShowPERBoolean(tag, indent, "audioLayer2", x->audioLayer2);
+    ShowPERBoolean(tag, indent, "audioLayer3", x->audioLayer3);
+    ShowPERBoolean(tag, indent, "audioSampling16k", x->audioSampling16k);
+    ShowPERBoolean(tag, indent, "audioSampling22k05", x->audioSampling22k05);
+    ShowPERBoolean(tag, indent, "audioSampling24k", x->audioSampling24k);
+    ShowPERBoolean(tag, indent, "audioSampling32k", x->audioSampling32k);
+    ShowPERBoolean(tag, indent, "audioSampling44k1", x->audioSampling44k1);
+    ShowPERBoolean(tag, indent, "audioSampling48k", x->audioSampling48k);
+    ShowPERBoolean(tag, indent, "singleChannel", x->singleChannel);
+    ShowPERBoolean(tag, indent, "twoChannels", x->twoChannels);
+    ShowPERBoolean(tag, indent, "threeChannels2_1", x->threeChannels2_1);
+    ShowPERBoolean(tag, indent, "threeChannels3_0", x->threeChannels3_0);
+    ShowPERBoolean(tag, indent, "fourChannels2_0_2_0", x->fourChannels2_0_2_0);
+    ShowPERBoolean(tag, indent, "fourChannels2_2", x->fourChannels2_2);
+    ShowPERBoolean(tag, indent, "fourChannels3_1", x->fourChannels3_1);
+    ShowPERBoolean(tag, indent, "fiveChannels3_0_2_0", x->fiveChannels3_0_2_0);
+    ShowPERBoolean(tag, indent, "fiveChannels3_2", x->fiveChannels3_2);
+    ShowPERBoolean(tag, indent, "lowFrequencyEnhancement", x->lowFrequencyEnhancement);
+    ShowPERBoolean(tag, indent, "multilingual", x->multilingual);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IS13818AudioCapability");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for GSMAudioCapability (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_GSMAudioCapability(PS_GSMAudioCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "GSMAudioCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "audioUnitSize", (int32)x->audioUnitSize);
+    ShowPERBoolean(tag, indent, "comfortNoise", x->comfortNoise);
+    ShowPERBoolean(tag, indent, "scrambled", x->scrambled);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "GSMAudioCapability");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for DataApplicationCapability (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_DataApplicationCapability(PS_DataApplicationCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "DataApplicationCapability");
+    indent += 2;
+    Analyze_Application(&x->application, "application", tag, indent);
+    ShowPERInteger(tag, indent, "maxBitRate", (int32)x->maxBitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "DataApplicationCapability");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for Application (CHOICE)  */
+/* <=====================================> */
+void Analyze_Application(PS_Application x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Application");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_DataProtocolCapability(x->t120, "t120", tag, indent);
+            break;
+        case 2:
+            Analyze_DataProtocolCapability(x->dsm_cc, "dsm_cc", tag, indent);
+            break;
+        case 3:
+            Analyze_DataProtocolCapability(x->userData, "userData", tag, indent);
+            break;
+        case 4:
+            Analyze_T84(x->t84, "t84", tag, indent);
+            break;
+        case 5:
+            Analyze_DataProtocolCapability(x->t434, "t434", tag, indent);
+            break;
+        case 6:
+            Analyze_DataProtocolCapability(x->h224, "h224", tag, indent);
+            break;
+        case 7:
+            Analyze_Nlpid(x->nlpid, "nlpid", tag, indent);
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "dsvdControl");
+            break;
+        case 9:
+            Analyze_DataProtocolCapability(x->h222DataPartitioning, "h222DataPartitioning", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Analyze_DataProtocolCapability(x->t30fax, "t30fax", tag, indent);
+            break;
+        case 11:
+            Analyze_DataProtocolCapability(x->t140, "t140", tag, indent);
+            break;
+        case 12:
+            Analyze_T38fax(x->t38fax, "t38fax", tag, indent);
+            break;
+        case 13:
+            Analyze_GenericCapability(x->genericDataCapability, "genericDataCapability", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_Application: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Application");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for T38fax (SEQUENCE)  */
+/* <==================================> */
+void Analyze_T38fax(PS_T38fax x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "T38fax");
+    indent += 2;
+    Analyze_DataProtocolCapability(&x->t38FaxProtocol, "t38FaxProtocol", tag, indent);
+    Analyze_T38FaxProfile(&x->t38FaxProfile, "t38FaxProfile", tag, indent);
+    ShowPERClosure(tag, indent, "T38fax");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for Nlpid (SEQUENCE)  */
+/* <=================================> */
+void Analyze_Nlpid(PS_Nlpid x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Nlpid");
+    indent += 2;
+    Analyze_DataProtocolCapability(&x->nlpidProtocol, "nlpidProtocol", tag, indent);
+    ShowPEROctetString(tag, indent, "nlpidData", &x->nlpidData);
+    ShowPERClosure(tag, indent, "Nlpid");
+}
+
+/* <===============================> */
+/*  PER-Analyzer for T84 (SEQUENCE)  */
+/* <===============================> */
+void Analyze_T84(PS_T84 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "T84");
+    indent += 2;
+    Analyze_DataProtocolCapability(&x->t84Protocol, "t84Protocol", tag, indent);
+    Analyze_T84Profile(&x->t84Profile, "t84Profile", tag, indent);
+    ShowPERClosure(tag, indent, "T84");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for DataProtocolCapability (CHOICE)  */
+/* <================================================> */
+void Analyze_DataProtocolCapability(PS_DataProtocolCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "DataProtocolCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "v14buffered");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "v42lapm");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "hdlcFrameTunnelling");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "h310SeparateVCStack");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "h310SingleVCStack");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "transparent");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            ShowPERNull(tag, indent, "segmentationAndReassembly");
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "hdlcFrameTunnelingwSAR");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "v120");
+            break;
+        case 10:
+            ShowPERNull(tag, indent, "separateLANStack");
+            break;
+        case 11:
+            Analyze_V76wCompression(x->v76wCompression, "v76wCompression", tag, indent);
+            break;
+        case 12:
+            ShowPERNull(tag, indent, "tcp");
+            break;
+        case 13:
+            ShowPERNull(tag, indent, "udp");
+            break;
+        default:
+            ErrorMessage("Analyze_DataProtocolCapability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "DataProtocolCapability");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for V76wCompression (CHOICE)  */
+/* <=========================================> */
+void Analyze_V76wCompression(PS_V76wCompression x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "V76wCompression");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_CompressionType(x->transmitCompression, "transmitCompression", tag, indent);
+            break;
+        case 1:
+            Analyze_CompressionType(x->receiveCompression, "receiveCompression", tag, indent);
+            break;
+        case 2:
+            Analyze_CompressionType(x->transmitAndReceiveCompression, "transmitAndReceiveCompression", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_V76wCompression: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "V76wCompression");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for CompressionType (CHOICE)  */
+/* <=========================================> */
+void Analyze_CompressionType(PS_CompressionType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CompressionType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_V42bis(x->v42bis, "v42bis", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CompressionType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CompressionType");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for V42bis (SEQUENCE)  */
+/* <==================================> */
+void Analyze_V42bis(PS_V42bis x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "V42bis");
+    indent += 2;
+    ShowPERInteger(tag, indent, "numberOfCodewords", (int32)x->numberOfCodewords);
+    ShowPERInteger(tag, indent, "maximumStringLength", (int32)x->maximumStringLength);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "V42bis");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for T84Profile (CHOICE)  */
+/* <====================================> */
+void Analyze_T84Profile(PS_T84Profile x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "T84Profile");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "t84Unrestricted");
+            break;
+        case 1:
+            Analyze_T84Restricted(x->t84Restricted, "t84Restricted", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_T84Profile: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "T84Profile");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for T84Restricted (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_T84Restricted(PS_T84Restricted x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "T84Restricted");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "qcif", x->qcif);
+    ShowPERBoolean(tag, indent, "cif", x->cif);
+    ShowPERBoolean(tag, indent, "ccir601Seq", x->ccir601Seq);
+    ShowPERBoolean(tag, indent, "ccir601Prog", x->ccir601Prog);
+    ShowPERBoolean(tag, indent, "hdtvSeq", x->hdtvSeq);
+    ShowPERBoolean(tag, indent, "hdtvProg", x->hdtvProg);
+    ShowPERBoolean(tag, indent, "g3FacsMH200x100", x->g3FacsMH200x100);
+    ShowPERBoolean(tag, indent, "g3FacsMH200x200", x->g3FacsMH200x200);
+    ShowPERBoolean(tag, indent, "g4FacsMMR200x100", x->g4FacsMMR200x100);
+    ShowPERBoolean(tag, indent, "g4FacsMMR200x200", x->g4FacsMMR200x200);
+    ShowPERBoolean(tag, indent, "jbig200x200Seq", x->jbig200x200Seq);
+    ShowPERBoolean(tag, indent, "jbig200x200Prog", x->jbig200x200Prog);
+    ShowPERBoolean(tag, indent, "jbig300x300Seq", x->jbig300x300Seq);
+    ShowPERBoolean(tag, indent, "jbig300x300Prog", x->jbig300x300Prog);
+    ShowPERBoolean(tag, indent, "digPhotoLow", x->digPhotoLow);
+    ShowPERBoolean(tag, indent, "digPhotoMedSeq", x->digPhotoMedSeq);
+    ShowPERBoolean(tag, indent, "digPhotoMedProg", x->digPhotoMedProg);
+    ShowPERBoolean(tag, indent, "digPhotoHighSeq", x->digPhotoHighSeq);
+    ShowPERBoolean(tag, indent, "digPhotoHighProg", x->digPhotoHighProg);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "T84Restricted");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for T38FaxProfile (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_T38FaxProfile(PS_T38FaxProfile x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "T38FaxProfile");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "fillBitRemoval", x->fillBitRemoval);
+    ShowPERBoolean(tag, indent, "transcodingJBIG", x->transcodingJBIG);
+    ShowPERBoolean(tag, indent, "transcodingMMR", x->transcodingMMR);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_version", x->option_of_version);
+    ShowPERBoolean(tag, indent, "option_of_t38FaxRateManagement", x->option_of_t38FaxRateManagement);
+    ShowPERBoolean(tag, indent, "option_of_t38FaxUdpOptions", x->option_of_t38FaxUdpOptions);
+    if (x->option_of_version)
+    {
+        ShowPERInteger(tag, indent, "version", (int32)x->version);
+    }
+    if (x->option_of_t38FaxRateManagement)
+    {
+        Analyze_T38FaxRateManagement(&x->t38FaxRateManagement, "t38FaxRateManagement", tag, indent);
+    }
+    if (x->option_of_t38FaxUdpOptions)
+    {
+        Analyze_T38FaxUdpOptions(&x->t38FaxUdpOptions, "t38FaxUdpOptions", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "T38FaxProfile");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for T38FaxRateManagement (CHOICE)  */
+/* <==============================================> */
+void Analyze_T38FaxRateManagement(PS_T38FaxRateManagement x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "T38FaxRateManagement");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "localTCF");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "transferredTCF");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_T38FaxRateManagement: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "T38FaxRateManagement");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for T38FaxUdpOptions (SEQUENCE)  */
+/* <============================================> */
+void Analyze_T38FaxUdpOptions(PS_T38FaxUdpOptions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "T38FaxUdpOptions");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_t38FaxMaxBuffer", x->option_of_t38FaxMaxBuffer);
+    ShowPERBoolean(tag, indent, "option_of_t38FaxMaxDatagram", x->option_of_t38FaxMaxDatagram);
+    if (x->option_of_t38FaxMaxBuffer)
+    {
+        ShowPERUnboundedInteger(tag, indent, "t38FaxMaxBuffer", (uint32)x->t38FaxMaxBuffer);
+    }
+    if (x->option_of_t38FaxMaxDatagram)
+    {
+        ShowPERUnboundedInteger(tag, indent, "t38FaxMaxDatagram", (uint32)x->t38FaxMaxDatagram);
+    }
+    Analyze_T38FaxUdpEC(&x->t38FaxUdpEC, "t38FaxUdpEC", tag, indent);
+    ShowPERClosure(tag, indent, "T38FaxUdpOptions");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for T38FaxUdpEC (CHOICE)  */
+/* <=====================================> */
+void Analyze_T38FaxUdpEC(PS_T38FaxUdpEC x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "T38FaxUdpEC");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "t38UDPFEC");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "t38UDPRedundancy");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_T38FaxUdpEC: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "T38FaxUdpEC");
+}
+
+/* <================================================================> */
+/*  PER-Analyzer for EncryptionAuthenticationAndIntegrity (SEQUENCE)  */
+/* <================================================================> */
+void Analyze_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "EncryptionAuthenticationAndIntegrity");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_encryptionCapability", x->option_of_encryptionCapability);
+    ShowPERBoolean(tag, indent, "option_of_authenticationCapability", x->option_of_authenticationCapability);
+    ShowPERBoolean(tag, indent, "option_of_integrityCapability", x->option_of_integrityCapability);
+    if (x->option_of_encryptionCapability)
+    {
+        Analyze_EncryptionCapability(&x->encryptionCapability, "encryptionCapability", tag, indent);
+    }
+    if (x->option_of_authenticationCapability)
+    {
+        Analyze_AuthenticationCapability(&x->authenticationCapability, "authenticationCapability", tag, indent);
+    }
+    if (x->option_of_integrityCapability)
+    {
+        Analyze_IntegrityCapability(&x->integrityCapability, "integrityCapability", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "EncryptionAuthenticationAndIntegrity");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for EncryptionCapability (SEQUENCE-OF)  */
+/* <===================================================> */
+void Analyze_EncryptionCapability(PS_EncryptionCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequenceof(tag, indent, label, "EncryptionCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size", (uint32)x->size);
+    for (i = 0;i < x->size;++i)
+    {
+        sprintf(tempLabelString, "item[%hu]", i);
+        Analyze_MediaEncryptionAlgorithm(x->item + i, tempLabelString, tag, indent);
+    }
+    ShowPERClosure(tag, indent, "EncryptionCapability");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for MediaEncryptionAlgorithm (CHOICE)  */
+/* <==================================================> */
+void Analyze_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MediaEncryptionAlgorithm");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERObjectID(tag, indent, "algorithm", x->algorithm);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MediaEncryptionAlgorithm: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MediaEncryptionAlgorithm");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for AuthenticationCapability (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_AuthenticationCapability(PS_AuthenticationCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "AuthenticationCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    if (x->option_of_nonStandard)
+    {
+        Analyze_NonStandardParameter(&x->nonStandard, "nonStandard", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "AuthenticationCapability");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for IntegrityCapability (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_IntegrityCapability(PS_IntegrityCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IntegrityCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    if (x->option_of_nonStandard)
+    {
+        Analyze_NonStandardParameter(&x->nonStandard, "nonStandard", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IntegrityCapability");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for UserInputCapability (CHOICE)  */
+/* <=============================================> */
+void Analyze_UserInputCapability(PS_UserInputCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "UserInputCapability");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "nonStandard[%hu]", i);
+                Analyze_NonStandardParameter(x->nonStandard + i, tempLabelString, tag, indent);
+            }
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "basicString");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "iA5String");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "generalString");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "dtmf");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "hookflash");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_UserInputCapability: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "UserInputCapability");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for ConferenceCapability (SEQUENCE)  */
+/* <================================================> */
+void Analyze_ConferenceCapability(PS_ConferenceCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "ConferenceCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandardData", x->option_of_nonStandardData);
+    if (x->option_of_nonStandardData)
+    {
+        ShowPERInteger(tag, indent, "size_of_nonStandardData", (uint32)x->size_of_nonStandardData);
+        for (i = 0;i < x->size_of_nonStandardData;++i)
+        {
+            sprintf(tempLabelString, "nonStandardData[%hu]", i);
+            Analyze_NonStandardParameter(x->nonStandardData + i, tempLabelString, tag, indent);
+        }
+    }
+    ShowPERBoolean(tag, indent, "chairControlCapability", x->chairControlCapability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_VideoIndicateMixingCapability", x->option_of_VideoIndicateMixingCapability);
+    ShowPERBoolean(tag, indent, "option_of_multipointVisualizationCapability", x->option_of_multipointVisualizationCapability);
+    if (x->option_of_VideoIndicateMixingCapability)
+    {
+        ShowPERBoolean(tag, indent, "VideoIndicateMixingCapability", x->VideoIndicateMixingCapability);
+    }
+    if (x->option_of_multipointVisualizationCapability)
+    {
+        ShowPERBoolean(tag, indent, "multipointVisualizationCapability", x->multipointVisualizationCapability);
+    }
+    ShowPERClosure(tag, indent, "ConferenceCapability");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for GenericCapability (SEQUENCE)  */
+/* <=============================================> */
+void Analyze_GenericCapability(PS_GenericCapability x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "GenericCapability");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_maxBitRate", x->option_of_maxBitRate);
+    ShowPERBoolean(tag, indent, "option_of_collapsing", x->option_of_collapsing);
+    ShowPERBoolean(tag, indent, "option_of_nonCollapsing", x->option_of_nonCollapsing);
+    ShowPERBoolean(tag, indent, "option_of_nonCollapsingRaw", x->option_of_nonCollapsingRaw);
+    ShowPERBoolean(tag, indent, "option_of_transport", x->option_of_transport);
+    Analyze_CapabilityIdentifier(&x->capabilityIdentifier, "capabilityIdentifier", tag, indent);
+    if (x->option_of_maxBitRate)
+    {
+        ShowPERInteger(tag, indent, "maxBitRate", (int32)x->maxBitRate);
+    }
+    if (x->option_of_collapsing)
+    {
+        ShowPERInteger(tag, indent, "size_of_collapsing", (uint32)x->size_of_collapsing);
+        for (i = 0;i < x->size_of_collapsing;++i)
+        {
+            sprintf(tempLabelString, "collapsing[%hu]", i);
+            Analyze_GenericParameter(x->collapsing + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_nonCollapsing)
+    {
+        ShowPERInteger(tag, indent, "size_of_nonCollapsing", (uint32)x->size_of_nonCollapsing);
+        for (i = 0;i < x->size_of_nonCollapsing;++i)
+        {
+            sprintf(tempLabelString, "nonCollapsing[%hu]", i);
+            Analyze_GenericParameter(x->nonCollapsing + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_nonCollapsingRaw)
+    {
+        ShowPEROctetString(tag, indent, "nonCollapsingRaw", &x->nonCollapsingRaw);
+    }
+    if (x->option_of_transport)
+    {
+        Analyze_DataProtocolCapability(&x->transport, "transport", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "GenericCapability");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for CapabilityIdentifier (CHOICE)  */
+/* <==============================================> */
+void Analyze_CapabilityIdentifier(PS_CapabilityIdentifier x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CapabilityIdentifier");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERObjectID(tag, indent, "standard", x->standard);
+            break;
+        case 1:
+            Analyze_NonStandardParameter(x->h221NonStandard, "h221NonStandard", tag, indent);
+            break;
+        case 2:
+            ShowPEROctetString(tag, indent, "uuid", x->uuid);
+            break;
+        case 3:
+            ShowPERCharString(tag, indent, "domainBased", x->domainBased);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CapabilityIdentifier: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CapabilityIdentifier");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for GenericParameter (SEQUENCE)  */
+/* <============================================> */
+void Analyze_GenericParameter(PS_GenericParameter x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "GenericParameter");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_supersedes", x->option_of_supersedes);
+    Analyze_ParameterIdentifier(&x->parameterIdentifier, "parameterIdentifier", tag, indent);
+    Analyze_ParameterValue(&x->parameterValue, "parameterValue", tag, indent);
+    if (x->option_of_supersedes)
+    {
+        ShowPERInteger(tag, indent, "size_of_supersedes", (uint32)x->size_of_supersedes);
+        for (i = 0;i < x->size_of_supersedes;++i)
+        {
+            sprintf(tempLabelString, "supersedes[%hu]", i);
+            Analyze_ParameterIdentifier(x->supersedes + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "GenericParameter");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for ParameterIdentifier (CHOICE)  */
+/* <=============================================> */
+void Analyze_ParameterIdentifier(PS_ParameterIdentifier x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ParameterIdentifier");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "standard", (uint32)x->standard);
+            break;
+        case 1:
+            Analyze_NonStandardParameter(x->h221NonStandard, "h221NonStandard", tag, indent);
+            break;
+        case 2:
+            ShowPEROctetString(tag, indent, "uuid", x->uuid);
+            break;
+        case 3:
+            ShowPERCharString(tag, indent, "domainBased", x->domainBased);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_ParameterIdentifier: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ParameterIdentifier");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for ParameterValue (CHOICE)  */
+/* <========================================> */
+void Analyze_ParameterValue(PS_ParameterValue x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "ParameterValue");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "logical");
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "booleanArray", (uint32)x->booleanArray);
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "unsignedMin", (uint32)x->unsignedMin);
+            break;
+        case 3:
+            ShowPERInteger(tag, indent, "unsignedMax", (uint32)x->unsignedMax);
+            break;
+        case 4:
+            ShowPERInteger(tag, indent, "unsigned32Min", (uint32)x->unsigned32Min);
+            break;
+        case 5:
+            ShowPERInteger(tag, indent, "unsigned32Max", (uint32)x->unsigned32Max);
+            break;
+        case 6:
+            ShowPEROctetString(tag, indent, "octetString", x->octetString);
+            break;
+        case 7:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "genericParameter[%hu]", i);
+                Analyze_GenericParameter(x->genericParameter + i, tempLabelString, tag, indent);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_ParameterValue: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ParameterValue");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for OpenLogicalChannel (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_OpenLogicalChannel(PS_OpenLogicalChannel x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "OpenLogicalChannel");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_reverseLogicalChannelParameters", x->option_of_reverseLogicalChannelParameters);
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    Analyze_ForwardLogicalChannelParameters(&x->forwardLogicalChannelParameters, "forwardLogicalChannelParameters", tag, indent);
+    if (x->option_of_reverseLogicalChannelParameters)
+    {
+        Analyze_ReverseLogicalChannelParameters(&x->reverseLogicalChannelParameters, "reverseLogicalChannelParameters", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_separateStack", x->option_of_separateStack);
+    ShowPERBoolean(tag, indent, "option_of_encryptionSync", x->option_of_encryptionSync);
+    if (x->option_of_separateStack)
+    {
+        Analyze_NetworkAccessParameters(&x->separateStack, "separateStack", tag, indent);
+    }
+    if (x->option_of_encryptionSync)
+    {
+        Analyze_EncryptionSync(&x->encryptionSync, "encryptionSync", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "OpenLogicalChannel");
+}
+
+/* <===========================================================> */
+/*  PER-Analyzer for ReverseLogicalChannelParameters (SEQUENCE)  */
+/* <===========================================================> */
+void Analyze_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ReverseLogicalChannelParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_rlcMultiplexParameters", x->option_of_rlcMultiplexParameters);
+    Analyze_DataType(&x->dataType, "dataType", tag, indent);
+    if (x->option_of_rlcMultiplexParameters)
+    {
+        Analyze_RlcMultiplexParameters(&x->rlcMultiplexParameters, "rlcMultiplexParameters", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_reverseLogicalChannelDependency", x->option_of_reverseLogicalChannelDependency);
+    ShowPERBoolean(tag, indent, "option_of_replacementFor", x->option_of_replacementFor);
+    if (x->option_of_reverseLogicalChannelDependency)
+    {
+        ShowPERInteger(tag, indent, "reverseLogicalChannelDependency", (int32)x->reverseLogicalChannelDependency);
+    }
+    if (x->option_of_replacementFor)
+    {
+        ShowPERInteger(tag, indent, "replacementFor", (int32)x->replacementFor);
+    }
+    ShowPERClosure(tag, indent, "ReverseLogicalChannelParameters");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for RlcMultiplexParameters (CHOICE)  */
+/* <================================================> */
+void Analyze_RlcMultiplexParameters(PS_RlcMultiplexParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RlcMultiplexParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_H223LogicalChannelParameters(x->h223LogicalChannelParameters, "h223LogicalChannelParameters", tag, indent);
+            break;
+        case 1:
+            Analyze_V76LogicalChannelParameters(x->v76LogicalChannelParameters, "v76LogicalChannelParameters", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            Analyze_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters, "h2250LogicalChannelParameters", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_RlcMultiplexParameters: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RlcMultiplexParameters");
+}
+
+/* <===========================================================> */
+/*  PER-Analyzer for ForwardLogicalChannelParameters (SEQUENCE)  */
+/* <===========================================================> */
+void Analyze_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ForwardLogicalChannelParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_portNumber", x->option_of_portNumber);
+    if (x->option_of_portNumber)
+    {
+        ShowPERInteger(tag, indent, "portNumber", (int32)x->portNumber);
+    }
+    Analyze_DataType(&x->dataType, "dataType", tag, indent);
+    Analyze_MultiplexParameters(&x->multiplexParameters, "multiplexParameters", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_forwardLogicalChannelDependency", x->option_of_forwardLogicalChannelDependency);
+    ShowPERBoolean(tag, indent, "option_of_replacementFor", x->option_of_replacementFor);
+    if (x->option_of_forwardLogicalChannelDependency)
+    {
+        ShowPERInteger(tag, indent, "forwardLogicalChannelDependency", (int32)x->forwardLogicalChannelDependency);
+    }
+    if (x->option_of_replacementFor)
+    {
+        ShowPERInteger(tag, indent, "replacementFor", (int32)x->replacementFor);
+    }
+    ShowPERClosure(tag, indent, "ForwardLogicalChannelParameters");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for MultiplexParameters (CHOICE)  */
+/* <=============================================> */
+void Analyze_MultiplexParameters(PS_MultiplexParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultiplexParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_H222LogicalChannelParameters(x->h222LogicalChannelParameters, "h222LogicalChannelParameters", tag, indent);
+            break;
+        case 1:
+            Analyze_H223LogicalChannelParameters(x->h223LogicalChannelParameters, "h223LogicalChannelParameters", tag, indent);
+            break;
+        case 2:
+            Analyze_V76LogicalChannelParameters(x->v76LogicalChannelParameters, "v76LogicalChannelParameters", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            Analyze_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters, "h2250LogicalChannelParameters", tag, indent);
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "none");
+            break;
+        default:
+            ErrorMessage("Analyze_MultiplexParameters: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultiplexParameters");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for NetworkAccessParameters (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_NetworkAccessParameters(PS_NetworkAccessParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "NetworkAccessParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_distribution", x->option_of_distribution);
+    ShowPERBoolean(tag, indent, "option_of_externalReference", x->option_of_externalReference);
+    if (x->option_of_distribution)
+    {
+        Analyze_Distribution(&x->distribution, "distribution", tag, indent);
+    }
+    Analyze_NetworkAddress(&x->networkAddress, "networkAddress", tag, indent);
+    ShowPERBoolean(tag, indent, "associateConference", x->associateConference);
+    if (x->option_of_externalReference)
+    {
+        ShowPEROctetString(tag, indent, "externalReference", &x->externalReference);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_t120SetupProcedure", x->option_of_t120SetupProcedure);
+    if (x->option_of_t120SetupProcedure)
+    {
+        Analyze_T120SetupProcedure(&x->t120SetupProcedure, "t120SetupProcedure", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "NetworkAccessParameters");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for T120SetupProcedure (CHOICE)  */
+/* <============================================> */
+void Analyze_T120SetupProcedure(PS_T120SetupProcedure x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "T120SetupProcedure");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "originateCall");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "waitForCall");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "issueQuery");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_T120SetupProcedure: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "T120SetupProcedure");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for NetworkAddress (CHOICE)  */
+/* <========================================> */
+void Analyze_NetworkAddress(PS_NetworkAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "NetworkAddress");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_Q2931Address(x->q2931Address, "q2931Address", tag, indent);
+            break;
+        case 1:
+            ShowPERCharString(tag, indent, "e164Address", x->e164Address);
+            break;
+        case 2:
+            Analyze_TransportAddress(x->localAreaAddress, "localAreaAddress", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_NetworkAddress: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "NetworkAddress");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for Distribution (CHOICE)  */
+/* <======================================> */
+void Analyze_Distribution(PS_Distribution x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Distribution");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unicast");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "multicast");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Distribution: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Distribution");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for Q2931Address (SEQUENCE)  */
+/* <========================================> */
+void Analyze_Q2931Address(PS_Q2931Address x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Q2931Address");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_subaddress", x->option_of_subaddress);
+    Analyze_Address(&x->address, "address", tag, indent);
+    if (x->option_of_subaddress)
+    {
+        ShowPEROctetString(tag, indent, "subaddress", &x->subaddress);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Q2931Address");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for Address (CHOICE)  */
+/* <=================================> */
+void Analyze_Address(PS_Address x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Address");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERCharString(tag, indent, "internationalNumber", x->internationalNumber);
+            break;
+        case 1:
+            ShowPEROctetString(tag, indent, "nsapAddress", x->nsapAddress);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Address: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Address");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for V75Parameters (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_V75Parameters(PS_V75Parameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "V75Parameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "audioHeaderPresent", x->audioHeaderPresent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "V75Parameters");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for DataType (CHOICE)  */
+/* <==================================> */
+void Analyze_DataType(PS_DataType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "DataType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "nullData");
+            break;
+        case 2:
+            Analyze_VideoCapability(x->videoData, "videoData", tag, indent);
+            break;
+        case 3:
+            Analyze_AudioCapability(x->audioData, "audioData", tag, indent);
+            break;
+        case 4:
+            Analyze_DataApplicationCapability(x->data, "data", tag, indent);
+            break;
+        case 5:
+            Analyze_EncryptionMode(x->encryptionData, "encryptionData", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            Analyze_NonStandardParameter(x->h235Control, "h235Control", tag, indent);
+            break;
+        case 7:
+            Analyze_H235Media(x->h235Media, "h235Media", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_DataType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "DataType");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for H235Media (SEQUENCE)  */
+/* <=====================================> */
+void Analyze_H235Media(PS_H235Media x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H235Media");
+    indent += 2;
+    Analyze_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, "encryptionAuthenticationAndIntegrity", tag, indent);
+    Analyze_MediaType(&x->mediaType, "mediaType", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H235Media");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for MediaType (CHOICE)  */
+/* <===================================> */
+void Analyze_MediaType(PS_MediaType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MediaType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_VideoCapability(x->videoData, "videoData", tag, indent);
+            break;
+        case 2:
+            Analyze_AudioCapability(x->audioData, "audioData", tag, indent);
+            break;
+        case 3:
+            Analyze_DataApplicationCapability(x->data, "data", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MediaType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MediaType");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for H222LogicalChannelParameters (SEQUENCE)  */
+/* <========================================================> */
+void Analyze_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H222LogicalChannelParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_pcr_pid", x->option_of_pcr_pid);
+    ShowPERBoolean(tag, indent, "option_of_programDescriptors", x->option_of_programDescriptors);
+    ShowPERBoolean(tag, indent, "option_of_streamDescriptors", x->option_of_streamDescriptors);
+    ShowPERInteger(tag, indent, "resourceID", (int32)x->resourceID);
+    ShowPERInteger(tag, indent, "subChannelID", (int32)x->subChannelID);
+    if (x->option_of_pcr_pid)
+    {
+        ShowPERInteger(tag, indent, "pcr_pid", (int32)x->pcr_pid);
+    }
+    if (x->option_of_programDescriptors)
+    {
+        ShowPEROctetString(tag, indent, "programDescriptors", &x->programDescriptors);
+    }
+    if (x->option_of_streamDescriptors)
+    {
+        ShowPEROctetString(tag, indent, "streamDescriptors", &x->streamDescriptors);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H222LogicalChannelParameters");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for H223LogicalChannelParameters (SEQUENCE)  */
+/* <========================================================> */
+void Analyze_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223LogicalChannelParameters");
+    indent += 2;
+    Analyze_AdaptationLayerType(&x->adaptationLayerType, "adaptationLayerType", tag, indent);
+    ShowPERBoolean(tag, indent, "segmentableFlag", x->segmentableFlag);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H223LogicalChannelParameters");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for AdaptationLayerType (CHOICE)  */
+/* <=============================================> */
+void Analyze_AdaptationLayerType(PS_AdaptationLayerType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "AdaptationLayerType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "al1Framed");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "al1NotFramed");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "al2WithoutSequenceNumbers");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "al2WithSequenceNumbers");
+            break;
+        case 5:
+            Analyze_Al3(x->al3, "al3", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            Analyze_H223AL1MParameters(x->al1M, "al1M", tag, indent);
+            break;
+        case 7:
+            Analyze_H223AL2MParameters(x->al2M, "al2M", tag, indent);
+            break;
+        case 8:
+            Analyze_H223AL3MParameters(x->al3M, "al3M", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_AdaptationLayerType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "AdaptationLayerType");
+}
+
+/* <===============================> */
+/*  PER-Analyzer for Al3 (SEQUENCE)  */
+/* <===============================> */
+void Analyze_Al3(PS_Al3 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Al3");
+    indent += 2;
+    ShowPERInteger(tag, indent, "controlFieldOctets", (int32)x->controlFieldOctets);
+    ShowPERInteger(tag, indent, "sendBufferSize", (int32)x->sendBufferSize);
+    ShowPERClosure(tag, indent, "Al3");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H223AL1MParameters (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_H223AL1MParameters(PS_H223AL1MParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223AL1MParameters");
+    indent += 2;
+    Analyze_TransferMode(&x->transferMode, "transferMode", tag, indent);
+    Analyze_HeaderFEC(&x->headerFEC, "headerFEC", tag, indent);
+    Analyze_CrcLength(&x->crcLength, "crcLength", tag, indent);
+    ShowPERInteger(tag, indent, "rcpcCodeRate", (int32)x->rcpcCodeRate);
+    Analyze_ArqType(&x->arqType, "arqType", tag, indent);
+    ShowPERBoolean(tag, indent, "alpduInterleaving", x->alpduInterleaving);
+    ShowPERBoolean(tag, indent, "alsduSplitting", x->alsduSplitting);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_rsCodeCorrection", x->option_of_rsCodeCorrection);
+    if (x->option_of_rsCodeCorrection)
+    {
+        ShowPERInteger(tag, indent, "rsCodeCorrection", (int32)x->rsCodeCorrection);
+    }
+    ShowPERClosure(tag, indent, "H223AL1MParameters");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for ArqType (CHOICE)  */
+/* <=================================> */
+void Analyze_ArqType(PS_ArqType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ArqType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noArq");
+            break;
+        case 1:
+            Analyze_H223AnnexCArqParameters(x->typeIArq, "typeIArq", tag, indent);
+            break;
+        case 2:
+            Analyze_H223AnnexCArqParameters(x->typeIIArq, "typeIIArq", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_ArqType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ArqType");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for CrcLength (CHOICE)  */
+/* <===================================> */
+void Analyze_CrcLength(PS_CrcLength x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CrcLength");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "crc4bit");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "crc12bit");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "crc20bit");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "crc28bit");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            ShowPERNull(tag, indent, "crc8bit");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "crc16bit");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "crc32bit");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "crcNotUsed");
+            break;
+        default:
+            ErrorMessage("Analyze_CrcLength: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CrcLength");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for HeaderFEC (CHOICE)  */
+/* <===================================> */
+void Analyze_HeaderFEC(PS_HeaderFEC x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "HeaderFEC");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "sebch16_7");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "golay24_12");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_HeaderFEC: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "HeaderFEC");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for TransferMode (CHOICE)  */
+/* <======================================> */
+void Analyze_TransferMode(PS_TransferMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "TransferMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "framed");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "unframed");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_TransferMode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "TransferMode");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H223AL2MParameters (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_H223AL2MParameters(PS_H223AL2MParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223AL2MParameters");
+    indent += 2;
+    Analyze_Al2HeaderFEC(&x->al2HeaderFEC, "al2HeaderFEC", tag, indent);
+    ShowPERBoolean(tag, indent, "alpduInterleaving", x->alpduInterleaving);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H223AL2MParameters");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for Al2HeaderFEC (CHOICE)  */
+/* <======================================> */
+void Analyze_Al2HeaderFEC(PS_Al2HeaderFEC x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Al2HeaderFEC");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "sebch16_5");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "golay24_12");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Al2HeaderFEC: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Al2HeaderFEC");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H223AL3MParameters (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_H223AL3MParameters(PS_H223AL3MParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223AL3MParameters");
+    indent += 2;
+    Analyze_HeaderFormat(&x->headerFormat, "headerFormat", tag, indent);
+    Analyze_Al3CrcLength(&x->al3CrcLength, "al3CrcLength", tag, indent);
+    ShowPERInteger(tag, indent, "rcpcCodeRate", (int32)x->rcpcCodeRate);
+    Analyze_Al3ArqType(&x->al3ArqType, "al3ArqType", tag, indent);
+    ShowPERBoolean(tag, indent, "alpduInterleaving", x->alpduInterleaving);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_rsCodeCorrection", x->option_of_rsCodeCorrection);
+    if (x->option_of_rsCodeCorrection)
+    {
+        ShowPERInteger(tag, indent, "rsCodeCorrection", (int32)x->rsCodeCorrection);
+    }
+    ShowPERClosure(tag, indent, "H223AL3MParameters");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for Al3ArqType (CHOICE)  */
+/* <====================================> */
+void Analyze_Al3ArqType(PS_Al3ArqType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Al3ArqType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noArq");
+            break;
+        case 1:
+            Analyze_H223AnnexCArqParameters(x->typeIArq, "typeIArq", tag, indent);
+            break;
+        case 2:
+            Analyze_H223AnnexCArqParameters(x->typeIIArq, "typeIIArq", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Al3ArqType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Al3ArqType");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for Al3CrcLength (CHOICE)  */
+/* <======================================> */
+void Analyze_Al3CrcLength(PS_Al3CrcLength x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Al3CrcLength");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "crc4bit");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "crc12bit");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "crc20bit");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "crc28bit");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            ShowPERNull(tag, indent, "crc8bit");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "crc16bit");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "crc32bit");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "crcNotUsed");
+            break;
+        default:
+            ErrorMessage("Analyze_Al3CrcLength: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Al3CrcLength");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for HeaderFormat (CHOICE)  */
+/* <======================================> */
+void Analyze_HeaderFormat(PS_HeaderFormat x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "HeaderFormat");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "sebch16_7");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "golay24_12");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_HeaderFormat: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "HeaderFormat");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for H223AnnexCArqParameters (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223AnnexCArqParameters");
+    indent += 2;
+    Analyze_NumberOfRetransmissions(&x->numberOfRetransmissions, "numberOfRetransmissions", tag, indent);
+    ShowPERInteger(tag, indent, "sendBufferSize", (int32)x->sendBufferSize);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H223AnnexCArqParameters");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for NumberOfRetransmissions (CHOICE)  */
+/* <=================================================> */
+void Analyze_NumberOfRetransmissions(PS_NumberOfRetransmissions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "NumberOfRetransmissions");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "finite", (uint32)x->finite);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "infinite");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_NumberOfRetransmissions: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "NumberOfRetransmissions");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for V76LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "V76LogicalChannelParameters");
+    indent += 2;
+    Analyze_V76HDLCParameters(&x->hdlcParameters, "hdlcParameters", tag, indent);
+    Analyze_SuspendResume(&x->suspendResume, "suspendResume", tag, indent);
+    ShowPERBoolean(tag, indent, "uIH", x->uIH);
+    Analyze_Mode(&x->mode, "mode", tag, indent);
+    Analyze_V75Parameters(&x->v75Parameters, "v75Parameters", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "V76LogicalChannelParameters");
+}
+
+/* <==============================> */
+/*  PER-Analyzer for Mode (CHOICE)  */
+/* <==============================> */
+void Analyze_Mode(PS_Mode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Mode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_ERM(x->eRM, "eRM", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "uNERM");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Mode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Mode");
+}
+
+/* <===============================> */
+/*  PER-Analyzer for ERM (SEQUENCE)  */
+/* <===============================> */
+void Analyze_ERM(PS_ERM x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ERM");
+    indent += 2;
+    ShowPERInteger(tag, indent, "windowSize", (int32)x->windowSize);
+    Analyze_Recovery(&x->recovery, "recovery", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ERM");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for Recovery (CHOICE)  */
+/* <==================================> */
+void Analyze_Recovery(PS_Recovery x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Recovery");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "rej");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "sREJ");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "mSREJ");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Recovery: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Recovery");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for SuspendResume (CHOICE)  */
+/* <=======================================> */
+void Analyze_SuspendResume(PS_SuspendResume x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "SuspendResume");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noSuspendResume");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "suspendResumewAddress");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "suspendResumewoAddress");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_SuspendResume: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "SuspendResume");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for V76HDLCParameters (SEQUENCE)  */
+/* <=============================================> */
+void Analyze_V76HDLCParameters(PS_V76HDLCParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "V76HDLCParameters");
+    indent += 2;
+    Analyze_CRCLength(&x->crcLength, "crcLength", tag, indent);
+    ShowPERInteger(tag, indent, "n401", (int32)x->n401);
+    ShowPERBoolean(tag, indent, "loopbackTestProcedure", x->loopbackTestProcedure);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "V76HDLCParameters");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for CRCLength (CHOICE)  */
+/* <===================================> */
+void Analyze_CRCLength(PS_CRCLength x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CRCLength");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "crc8bit");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "crc16bit");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "crc32bit");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CRCLength: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CRCLength");
+}
+
+/* <=========================================================> */
+/*  PER-Analyzer for H2250LogicalChannelParameters (SEQUENCE)  */
+/* <=========================================================> */
+void Analyze_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "H2250LogicalChannelParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    ShowPERBoolean(tag, indent, "option_of_associatedSessionID", x->option_of_associatedSessionID);
+    ShowPERBoolean(tag, indent, "option_of_mediaChannel", x->option_of_mediaChannel);
+    ShowPERBoolean(tag, indent, "option_of_mediaGuaranteedDelivery", x->option_of_mediaGuaranteedDelivery);
+    ShowPERBoolean(tag, indent, "option_of_mediaControlChannel", x->option_of_mediaControlChannel);
+    ShowPERBoolean(tag, indent, "option_of_mediaControlGuaranteedDelivery", x->option_of_mediaControlGuaranteedDelivery);
+    ShowPERBoolean(tag, indent, "option_of_silenceSuppression", x->option_of_silenceSuppression);
+    ShowPERBoolean(tag, indent, "option_of_destination", x->option_of_destination);
+    ShowPERBoolean(tag, indent, "option_of_dynamicRTPPayloadType", x->option_of_dynamicRTPPayloadType);
+    ShowPERBoolean(tag, indent, "option_of_mediaPacketization", x->option_of_mediaPacketization);
+    if (x->option_of_nonStandard)
+    {
+        ShowPERInteger(tag, indent, "size_of_nonStandard", (uint32)x->size_of_nonStandard);
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            sprintf(tempLabelString, "nonStandard[%hu]", i);
+            Analyze_NonStandardParameter(x->nonStandard + i, tempLabelString, tag, indent);
+        }
+    }
+    ShowPERInteger(tag, indent, "sessionID", (int32)x->sessionID);
+    if (x->option_of_associatedSessionID)
+    {
+        ShowPERInteger(tag, indent, "associatedSessionID", (int32)x->associatedSessionID);
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Analyze_TransportAddress(&x->mediaChannel, "mediaChannel", tag, indent);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+        ShowPERBoolean(tag, indent, "mediaGuaranteedDelivery", x->mediaGuaranteedDelivery);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Analyze_TransportAddress(&x->mediaControlChannel, "mediaControlChannel", tag, indent);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+        ShowPERBoolean(tag, indent, "mediaControlGuaranteedDelivery", x->mediaControlGuaranteedDelivery);
+    }
+    if (x->option_of_silenceSuppression)
+    {
+        ShowPERBoolean(tag, indent, "silenceSuppression", x->silenceSuppression);
+    }
+    if (x->option_of_destination)
+    {
+        Analyze_TerminalLabel(&x->destination, "destination", tag, indent);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+        ShowPERInteger(tag, indent, "dynamicRTPPayloadType", (int32)x->dynamicRTPPayloadType);
+    }
+    if (x->option_of_mediaPacketization)
+    {
+        Analyze_MediaPacketization(&x->mediaPacketization, "mediaPacketization", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_transportCapability", x->option_of_transportCapability);
+    ShowPERBoolean(tag, indent, "option_of_redundancyEncoding", x->option_of_redundancyEncoding);
+    ShowPERBoolean(tag, indent, "option_of_source", x->option_of_source);
+    ShowPERBoolean(tag, indent, "option_of_symmetricMediaAddress", x->option_of_symmetricMediaAddress);
+    if (x->option_of_transportCapability)
+    {
+        Analyze_TransportCapability(&x->transportCapability, "transportCapability", tag, indent);
+    }
+    if (x->option_of_redundancyEncoding)
+    {
+        Analyze_RedundancyEncoding(&x->redundancyEncoding, "redundancyEncoding", tag, indent);
+    }
+    if (x->option_of_source)
+    {
+        Analyze_TerminalLabel(&x->source, "source", tag, indent);
+    }
+    if (x->option_of_symmetricMediaAddress)
+    {
+        ShowPERBoolean(tag, indent, "symmetricMediaAddress", x->symmetricMediaAddress);
+    }
+    ShowPERClosure(tag, indent, "H2250LogicalChannelParameters");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for MediaPacketization (CHOICE)  */
+/* <============================================> */
+void Analyze_MediaPacketization(PS_MediaPacketization x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MediaPacketization");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "h261aVideoPacketization");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            Analyze_RTPPayloadType(x->rtpPayloadType, "rtpPayloadType", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_MediaPacketization: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MediaPacketization");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for RTPPayloadType (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_RTPPayloadType(PS_RTPPayloadType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RTPPayloadType");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_payloadType", x->option_of_payloadType);
+    Analyze_PayloadDescriptor(&x->payloadDescriptor, "payloadDescriptor", tag, indent);
+    if (x->option_of_payloadType)
+    {
+        ShowPERInteger(tag, indent, "payloadType", (int32)x->payloadType);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RTPPayloadType");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for PayloadDescriptor (CHOICE)  */
+/* <===========================================> */
+void Analyze_PayloadDescriptor(PS_PayloadDescriptor x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "PayloadDescriptor");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandardIdentifier, "nonStandardIdentifier", tag, indent);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "rfc_number", (uint32)x->rfc_number);
+            break;
+        case 2:
+            ShowPERObjectID(tag, indent, "oid", x->oid);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_PayloadDescriptor: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "PayloadDescriptor");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for RedundancyEncoding (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_RedundancyEncoding(PS_RedundancyEncoding x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RedundancyEncoding");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_secondaryEncoding", x->option_of_secondaryEncoding);
+    Analyze_RedundancyEncodingMethod(&x->redundancyEncodingMethod, "redundancyEncodingMethod", tag, indent);
+    if (x->option_of_secondaryEncoding)
+    {
+        Analyze_DataType(&x->secondaryEncoding, "secondaryEncoding", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RedundancyEncoding");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for TransportAddress (CHOICE)  */
+/* <==========================================> */
+void Analyze_TransportAddress(PS_TransportAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "TransportAddress");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_UnicastAddress(x->unicastAddress, "unicastAddress", tag, indent);
+            break;
+        case 1:
+            Analyze_MulticastAddress(x->multicastAddress, "multicastAddress", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_TransportAddress: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "TransportAddress");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for UnicastAddress (CHOICE)  */
+/* <========================================> */
+void Analyze_UnicastAddress(PS_UnicastAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "UnicastAddress");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_IPAddress(x->iPAddress, "iPAddress", tag, indent);
+            break;
+        case 1:
+            Analyze_IPXAddress(x->iPXAddress, "iPXAddress", tag, indent);
+            break;
+        case 2:
+            Analyze_IP6Address(x->iP6Address, "iP6Address", tag, indent);
+            break;
+        case 3:
+            ShowPEROctetString(tag, indent, "netBios", x->netBios);
+            break;
+        case 4:
+            Analyze_IPSourceRouteAddress(x->iPSourceRouteAddress, "iPSourceRouteAddress", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            ShowPEROctetString(tag, indent, "nsap", x->nsap);
+            break;
+        case 6:
+            Analyze_NonStandardParameter(x->nonStandardAddress, "nonStandardAddress", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_UnicastAddress: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "UnicastAddress");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for IPSourceRouteAddress (SEQUENCE)  */
+/* <================================================> */
+void Analyze_IPSourceRouteAddress(PS_IPSourceRouteAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "IPSourceRouteAddress");
+    indent += 2;
+    Analyze_Routing(&x->routing, "routing", tag, indent);
+    ShowPEROctetString(tag, indent, "network", &x->network);
+    ShowPERInteger(tag, indent, "tsapIdentifier", (int32)x->tsapIdentifier);
+    ShowPERInteger(tag, indent, "size_of_route", (uint32)x->size_of_route);
+    for (i = 0;i < x->size_of_route;++i)
+    {
+        ShowPEROctetStrings(tag, indent, "route", x->route + i, i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IPSourceRouteAddress");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for Routing (CHOICE)  */
+/* <=================================> */
+void Analyze_Routing(PS_Routing x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Routing");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "strict");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "loose");
+            break;
+        default:
+            ErrorMessage("Analyze_Routing: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Routing");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for IP6Address (SEQUENCE)  */
+/* <======================================> */
+void Analyze_IP6Address(PS_IP6Address x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IP6Address");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "network", &x->network);
+    ShowPERInteger(tag, indent, "tsapIdentifier", (int32)x->tsapIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IP6Address");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for IPXAddress (SEQUENCE)  */
+/* <======================================> */
+void Analyze_IPXAddress(PS_IPXAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IPXAddress");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "node", &x->node);
+    ShowPEROctetString(tag, indent, "netnum", &x->netnum);
+    ShowPEROctetString(tag, indent, "tsapIdentifier", &x->tsapIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IPXAddress");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for IPAddress (SEQUENCE)  */
+/* <=====================================> */
+void Analyze_IPAddress(PS_IPAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IPAddress");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "network", &x->network);
+    ShowPERInteger(tag, indent, "tsapIdentifier", (int32)x->tsapIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IPAddress");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for MulticastAddress (CHOICE)  */
+/* <==========================================> */
+void Analyze_MulticastAddress(PS_MulticastAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MulticastAddress");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_MaIpAddress(x->maIpAddress, "maIpAddress", tag, indent);
+            break;
+        case 1:
+            Analyze_MaIp6Address(x->maIp6Address, "maIp6Address", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            ShowPEROctetString(tag, indent, "nsap", x->nsap);
+            break;
+        case 3:
+            Analyze_NonStandardParameter(x->nonStandardAddress, "nonStandardAddress", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_MulticastAddress: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MulticastAddress");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for MaIp6Address (SEQUENCE)  */
+/* <========================================> */
+void Analyze_MaIp6Address(PS_MaIp6Address x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MaIp6Address");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "network", &x->network);
+    ShowPERInteger(tag, indent, "tsapIdentifier", (int32)x->tsapIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaIp6Address");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for MaIpAddress (SEQUENCE)  */
+/* <=======================================> */
+void Analyze_MaIpAddress(PS_MaIpAddress x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MaIpAddress");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "network", &x->network);
+    ShowPERInteger(tag, indent, "tsapIdentifier", (int32)x->tsapIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaIpAddress");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for EncryptionSync (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_EncryptionSync(PS_EncryptionSync x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "EncryptionSync");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    ShowPERBoolean(tag, indent, "option_of_escrowentry", x->option_of_escrowentry);
+    if (x->option_of_nonStandard)
+    {
+        Analyze_NonStandardParameter(&x->nonStandard, "nonStandard", tag, indent);
+    }
+    ShowPERInteger(tag, indent, "synchFlag", (int32)x->synchFlag);
+    ShowPEROctetString(tag, indent, "h235Key", &x->h235Key);
+    if (x->option_of_escrowentry)
+    {
+        ShowPERInteger(tag, indent, "size_of_escrowentry", (uint32)x->size_of_escrowentry);
+        for (i = 0;i < x->size_of_escrowentry;++i)
+        {
+            sprintf(tempLabelString, "escrowentry[%hu]", i);
+            Analyze_EscrowData(x->escrowentry + i, tempLabelString, tag, indent);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "EncryptionSync");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for EscrowData (SEQUENCE)  */
+/* <======================================> */
+void Analyze_EscrowData(PS_EscrowData x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "EscrowData");
+    indent += 2;
+    ShowPERObjectID(tag, indent, "escrowID", &x->escrowID);
+    ShowPERBitString(tag, indent, "escrowValue", &x->escrowValue);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "EscrowData");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for OpenLogicalChannelAck (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "OpenLogicalChannelAck");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_ackReverseLogicalChannelParameters", x->option_of_ackReverseLogicalChannelParameters);
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    if (x->option_of_ackReverseLogicalChannelParameters)
+    {
+        Analyze_AckReverseLogicalChannelParameters(&x->ackReverseLogicalChannelParameters, "ackReverseLogicalChannelParameters", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_separateStack", x->option_of_separateStack);
+    ShowPERBoolean(tag, indent, "option_of_forwardMultiplexAckParameters", x->option_of_forwardMultiplexAckParameters);
+    ShowPERBoolean(tag, indent, "option_of_encryptionSync", x->option_of_encryptionSync);
+    if (x->option_of_separateStack)
+    {
+        Analyze_NetworkAccessParameters(&x->separateStack, "separateStack", tag, indent);
+    }
+    if (x->option_of_forwardMultiplexAckParameters)
+    {
+        Analyze_ForwardMultiplexAckParameters(&x->forwardMultiplexAckParameters, "forwardMultiplexAckParameters", tag, indent);
+    }
+    if (x->option_of_encryptionSync)
+    {
+        Analyze_EncryptionSync(&x->encryptionSync, "encryptionSync", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "OpenLogicalChannelAck");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for ForwardMultiplexAckParameters (CHOICE)  */
+/* <=======================================================> */
+void Analyze_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ForwardMultiplexAckParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_H2250LogicalChannelAckParameters(x->h2250LogicalChannelAckParameters, "h2250LogicalChannelAckParameters", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_ForwardMultiplexAckParameters: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ForwardMultiplexAckParameters");
+}
+
+/* <==============================================================> */
+/*  PER-Analyzer for AckReverseLogicalChannelParameters (SEQUENCE)  */
+/* <==============================================================> */
+void Analyze_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "AckReverseLogicalChannelParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_portNumber", x->option_of_portNumber);
+    ShowPERBoolean(tag, indent, "option_of_ackMultiplexParameters", x->option_of_ackMultiplexParameters);
+    ShowPERInteger(tag, indent, "reverseLogicalChannelNumber", (int32)x->reverseLogicalChannelNumber);
+    if (x->option_of_portNumber)
+    {
+        ShowPERInteger(tag, indent, "portNumber", (int32)x->portNumber);
+    }
+    if (x->option_of_ackMultiplexParameters)
+    {
+        Analyze_AckMultiplexParameters(&x->ackMultiplexParameters, "ackMultiplexParameters", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_replacementFor", x->option_of_replacementFor);
+    if (x->option_of_replacementFor)
+    {
+        ShowPERInteger(tag, indent, "replacementFor", (int32)x->replacementFor);
+    }
+    ShowPERClosure(tag, indent, "AckReverseLogicalChannelParameters");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for AckMultiplexParameters (CHOICE)  */
+/* <================================================> */
+void Analyze_AckMultiplexParameters(PS_AckMultiplexParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "AckMultiplexParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_H222LogicalChannelParameters(x->h222LogicalChannelParameters, "h222LogicalChannelParameters", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            Analyze_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters, "h2250LogicalChannelParameters", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_AckMultiplexParameters: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "AckMultiplexParameters");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for OpenLogicalChannelReject (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "OpenLogicalChannelReject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    Analyze_OlcRejectCause(&x->olcRejectCause, "olcRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "OpenLogicalChannelReject");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for OlcRejectCause (CHOICE)  */
+/* <========================================> */
+void Analyze_OlcRejectCause(PS_OlcRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "OlcRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unspecified");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "unsuitableReverseParameters");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "dataTypeNotSupported");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "dataTypeNotAvailable");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "unknownDataType");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "dataTypeALCombinationNotSupported");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            ShowPERNull(tag, indent, "multicastChannelNotAllowed");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "insufficientBandwidth");
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "separateStackEstablishmentFailed");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "invalidSessionID");
+            break;
+        case 10:
+            ShowPERNull(tag, indent, "masterSlaveConflict");
+            break;
+        case 11:
+            ShowPERNull(tag, indent, "waitForCommunicationMode");
+            break;
+        case 12:
+            ShowPERNull(tag, indent, "invalidDependentChannel");
+            break;
+        case 13:
+            ShowPERNull(tag, indent, "replacementForRejected");
+            break;
+        default:
+            ErrorMessage("Analyze_OlcRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "OlcRejectCause");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for OpenLogicalChannelConfirm (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "OpenLogicalChannelConfirm");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "OpenLogicalChannelConfirm");
+}
+
+/* <============================================================> */
+/*  PER-Analyzer for H2250LogicalChannelAckParameters (SEQUENCE)  */
+/* <============================================================> */
+void Analyze_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "H2250LogicalChannelAckParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    ShowPERBoolean(tag, indent, "option_of_sessionID", x->option_of_sessionID);
+    ShowPERBoolean(tag, indent, "option_of_mediaChannel", x->option_of_mediaChannel);
+    ShowPERBoolean(tag, indent, "option_of_mediaControlChannel", x->option_of_mediaControlChannel);
+    ShowPERBoolean(tag, indent, "option_of_dynamicRTPPayloadType", x->option_of_dynamicRTPPayloadType);
+    if (x->option_of_nonStandard)
+    {
+        ShowPERInteger(tag, indent, "size_of_nonStandard", (uint32)x->size_of_nonStandard);
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            sprintf(tempLabelString, "nonStandard[%hu]", i);
+            Analyze_NonStandardParameter(x->nonStandard + i, tempLabelString, tag, indent);
+        }
+    }
+    if (x->option_of_sessionID)
+    {
+        ShowPERInteger(tag, indent, "sessionID", (int32)x->sessionID);
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Analyze_TransportAddress(&x->mediaChannel, "mediaChannel", tag, indent);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Analyze_TransportAddress(&x->mediaControlChannel, "mediaControlChannel", tag, indent);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+        ShowPERInteger(tag, indent, "dynamicRTPPayloadType", (int32)x->dynamicRTPPayloadType);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_flowControlToZero", x->option_of_flowControlToZero);
+    ShowPERBoolean(tag, indent, "option_of_portNumber", x->option_of_portNumber);
+    if (x->option_of_flowControlToZero)
+    {
+        ShowPERBoolean(tag, indent, "flowControlToZero", x->flowControlToZero);
+    }
+    if (x->option_of_portNumber)
+    {
+        ShowPERInteger(tag, indent, "portNumber", (int32)x->portNumber);
+    }
+    ShowPERClosure(tag, indent, "H2250LogicalChannelAckParameters");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for CloseLogicalChannel (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_CloseLogicalChannel(PS_CloseLogicalChannel x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CloseLogicalChannel");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    Analyze_Source(&x->source, "source", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_reason", x->option_of_reason);
+    if (x->option_of_reason)
+    {
+        Analyze_Reason(&x->reason, "reason", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "CloseLogicalChannel");
+}
+
+/* <================================> */
+/*  PER-Analyzer for Reason (CHOICE)  */
+/* <================================> */
+void Analyze_Reason(PS_Reason x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Reason");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unknown");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "reopen");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "reservationFailure");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Reason: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Reason");
+}
+
+/* <================================> */
+/*  PER-Analyzer for Source (CHOICE)  */
+/* <================================> */
+void Analyze_Source(PS_Source x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Source");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "user");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "lcse");
+            break;
+        default:
+            ErrorMessage("Analyze_Source: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Source");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for CloseLogicalChannelAck (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CloseLogicalChannelAck");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CloseLogicalChannelAck");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for RequestChannelClose (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_RequestChannelClose(PS_RequestChannelClose x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestChannelClose");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_qosCapability", x->option_of_qosCapability);
+    ShowPERBoolean(tag, indent, "option_of_rccReason", x->option_of_rccReason);
+    if (x->option_of_qosCapability)
+    {
+        Analyze_QOSCapability(&x->qosCapability, "qosCapability", tag, indent);
+    }
+    if (x->option_of_rccReason)
+    {
+        Analyze_RccReason(&x->rccReason, "rccReason", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "RequestChannelClose");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for RccReason (CHOICE)  */
+/* <===================================> */
+void Analyze_RccReason(PS_RccReason x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RccReason");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unknown");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "normal");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "reopen");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "reservationFailure");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RccReason: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RccReason");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for RequestChannelCloseAck (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_RequestChannelCloseAck(PS_RequestChannelCloseAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestChannelCloseAck");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestChannelCloseAck");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for RequestChannelCloseReject (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_RequestChannelCloseReject(PS_RequestChannelCloseReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestChannelCloseReject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    Analyze_RccRejectCause(&x->rccRejectCause, "rccRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestChannelCloseReject");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for RccRejectCause (CHOICE)  */
+/* <========================================> */
+void Analyze_RccRejectCause(PS_RccRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RccRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unspecified");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RccRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RccRejectCause");
+}
+
+/* <======================================================> */
+/*  PER-Analyzer for RequestChannelCloseRelease (SEQUENCE)  */
+/* <======================================================> */
+void Analyze_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestChannelCloseRelease");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardLogicalChannelNumber", (int32)x->forwardLogicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestChannelCloseRelease");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for MultiplexEntrySend (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_MultiplexEntrySend(PS_MultiplexEntrySend x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MultiplexEntrySend");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "size_of_multiplexEntryDescriptors", (uint32)x->size_of_multiplexEntryDescriptors);
+    for (i = 0;i < x->size_of_multiplexEntryDescriptors;++i)
+    {
+        sprintf(tempLabelString, "multiplexEntryDescriptors[%hu]", i);
+        Analyze_MultiplexEntryDescriptor(x->multiplexEntryDescriptors + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MultiplexEntrySend");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for MultiplexEntryDescriptor (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MultiplexEntryDescriptor");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_elementList", x->option_of_elementList);
+    ShowPERInteger(tag, indent, "multiplexTableEntryNumber", (int32)x->multiplexTableEntryNumber);
+    if (x->option_of_elementList)
+    {
+        ShowPERInteger(tag, indent, "size_of_elementList", (uint32)x->size_of_elementList);
+        for (i = 0;i < x->size_of_elementList;++i)
+        {
+            sprintf(tempLabelString, "elementList[%hu]", i);
+            Analyze_MultiplexElement(x->elementList + i, tempLabelString, tag, indent);
+        }
+    }
+    ShowPERClosure(tag, indent, "MultiplexEntryDescriptor");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for MultiplexElement (SEQUENCE)  */
+/* <============================================> */
+void Analyze_MultiplexElement(PS_MultiplexElement x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MultiplexElement");
+    indent += 2;
+    Analyze_MuxType(&x->muxType, "muxType", tag, indent);
+    Analyze_RepeatCount(&x->repeatCount, "repeatCount", tag, indent);
+    ShowPERClosure(tag, indent, "MultiplexElement");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for RepeatCount (CHOICE)  */
+/* <=====================================> */
+void Analyze_RepeatCount(PS_RepeatCount x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RepeatCount");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "finite", (uint32)x->finite);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "untilClosingFlag");
+            break;
+        default:
+            ErrorMessage("Analyze_RepeatCount: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RepeatCount");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for MuxType (CHOICE)  */
+/* <=================================> */
+void Analyze_MuxType(PS_MuxType x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "MuxType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "logicalChannelNumber", (uint32)x->logicalChannelNumber);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "subElementList[%hu]", i);
+                Analyze_MultiplexElement(x->subElementList + i, tempLabelString, tag, indent);
+            }
+            break;
+        default:
+            ErrorMessage("Analyze_MuxType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MuxType");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for MultiplexEntrySendAck (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MultiplexEntrySendAck");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "size_of_multiplexTableEntryNumber", (uint32)x->size_of_multiplexTableEntryNumber);
+    for (i = 0;i < x->size_of_multiplexTableEntryNumber;++i)
+    {
+        ShowPERIntegers(tag, indent, "multiplexTableEntryNumber", (uint32)x->multiplexTableEntryNumber[i], i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MultiplexEntrySendAck");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for MultiplexEntrySendReject (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MultiplexEntrySendReject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "size_of_rejectionDescriptions", (uint32)x->size_of_rejectionDescriptions);
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        sprintf(tempLabelString, "rejectionDescriptions[%hu]", i);
+        Analyze_MultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MultiplexEntrySendReject");
+}
+
+/* <===============================================================> */
+/*  PER-Analyzer for MultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <===============================================================> */
+void Analyze_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MultiplexEntryRejectionDescriptions");
+    indent += 2;
+    ShowPERInteger(tag, indent, "multiplexTableEntryNumber", (int32)x->multiplexTableEntryNumber);
+    Analyze_MeRejectCause(&x->meRejectCause, "meRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MultiplexEntryRejectionDescriptions");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for MeRejectCause (CHOICE)  */
+/* <=======================================> */
+void Analyze_MeRejectCause(PS_MeRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MeRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unspecifiedCause");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "descriptorTooComplex");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MeRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MeRejectCause");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for MultiplexEntrySendRelease (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "MultiplexEntrySendRelease");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_multiplexTableEntryNumber", (uint32)x->size_of_multiplexTableEntryNumber);
+    for (i = 0;i < x->size_of_multiplexTableEntryNumber;++i)
+    {
+        ShowPERIntegers(tag, indent, "multiplexTableEntryNumber", (uint32)x->multiplexTableEntryNumber[i], i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MultiplexEntrySendRelease");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for RequestMultiplexEntry (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_RequestMultiplexEntry(PS_RequestMultiplexEntry x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RequestMultiplexEntry");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_entryNumbers", (uint32)x->size_of_entryNumbers);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        ShowPERIntegers(tag, indent, "entryNumbers", (uint32)x->entryNumbers[i], i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestMultiplexEntry");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for RequestMultiplexEntryAck (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RequestMultiplexEntryAck");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_entryNumbers", (uint32)x->size_of_entryNumbers);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        ShowPERIntegers(tag, indent, "entryNumbers", (uint32)x->entryNumbers[i], i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestMultiplexEntryAck");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for RequestMultiplexEntryReject (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RequestMultiplexEntryReject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_entryNumbers", (uint32)x->size_of_entryNumbers);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        ShowPERIntegers(tag, indent, "entryNumbers", (uint32)x->entryNumbers[i], i);
+    }
+    ShowPERInteger(tag, indent, "size_of_rejectionDescriptions", (uint32)x->size_of_rejectionDescriptions);
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        sprintf(tempLabelString, "rejectionDescriptions[%hu]", i);
+        Analyze_RequestMultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestMultiplexEntryReject");
+}
+
+/* <======================================================================> */
+/*  PER-Analyzer for RequestMultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <======================================================================> */
+void Analyze_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestMultiplexEntryRejectionDescriptions");
+    indent += 2;
+    ShowPERInteger(tag, indent, "multiplexTableEntryNumber", (int32)x->multiplexTableEntryNumber);
+    Analyze_RmeRejectCause(&x->rmeRejectCause, "rmeRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestMultiplexEntryRejectionDescriptions");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for RmeRejectCause (CHOICE)  */
+/* <========================================> */
+void Analyze_RmeRejectCause(PS_RmeRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RmeRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unspecifiedCause");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RmeRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RmeRejectCause");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for RequestMultiplexEntryRelease (SEQUENCE)  */
+/* <========================================================> */
+void Analyze_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RequestMultiplexEntryRelease");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_entryNumbers", (uint32)x->size_of_entryNumbers);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        ShowPERIntegers(tag, indent, "entryNumbers", (uint32)x->entryNumbers[i], i);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestMultiplexEntryRelease");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for RequestMode (SEQUENCE)  */
+/* <=======================================> */
+void Analyze_RequestMode(PS_RequestMode x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RequestMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "size_of_requestedModes", (uint32)x->size_of_requestedModes);
+    for (i = 0;i < x->size_of_requestedModes;++i)
+    {
+        sprintf(tempLabelString, "requestedModes[%hu]", i);
+        Analyze_ModeDescription(x->requestedModes + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestMode");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for RequestModeAck (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_RequestModeAck(PS_RequestModeAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestModeAck");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    Analyze_Response(&x->response, "response", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestModeAck");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for Response (CHOICE)  */
+/* <==================================> */
+void Analyze_Response(PS_Response x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Response");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "willTransmitMostPreferredMode");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "willTransmitLessPreferredMode");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Response: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Response");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for RequestModeReject (SEQUENCE)  */
+/* <=============================================> */
+void Analyze_RequestModeReject(PS_RequestModeReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestModeReject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    Analyze_RmRejectCause(&x->rmRejectCause, "rmRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestModeReject");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for RmRejectCause (CHOICE)  */
+/* <=======================================> */
+void Analyze_RmRejectCause(PS_RmRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RmRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "modeUnavailable");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "multipointConstraint");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "requestDenied");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RmRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RmRejectCause");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for RequestModeRelease (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_RequestModeRelease(PS_RequestModeRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "RequestModeRelease");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestModeRelease");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for ModeDescription (SET-OF)  */
+/* <=========================================> */
+void Analyze_ModeDescription(PS_ModeDescription x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSetof(tag, indent, label, "ModeDescription");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size", (uint32)x->size);
+    for (i = 0;i < x->size;++i)
+    {
+        sprintf(tempLabelString, "item[%hu]", i);
+        Analyze_ModeElement(x->item + i, tempLabelString, tag, indent);
+    }
+    ShowPERClosure(tag, indent, "ModeDescription");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for ModeElement (SEQUENCE)  */
+/* <=======================================> */
+void Analyze_ModeElement(PS_ModeElement x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ModeElement");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_h223ModeParameters", x->option_of_h223ModeParameters);
+    Analyze_ModeType(&x->modeType, "modeType", tag, indent);
+    if (x->option_of_h223ModeParameters)
+    {
+        Analyze_H223ModeParameters(&x->h223ModeParameters, "h223ModeParameters", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_v76ModeParameters", x->option_of_v76ModeParameters);
+    ShowPERBoolean(tag, indent, "option_of_h2250ModeParameters", x->option_of_h2250ModeParameters);
+    ShowPERBoolean(tag, indent, "option_of_genericModeParameters", x->option_of_genericModeParameters);
+    if (x->option_of_v76ModeParameters)
+    {
+        Analyze_V76ModeParameters(&x->v76ModeParameters, "v76ModeParameters", tag, indent);
+    }
+    if (x->option_of_h2250ModeParameters)
+    {
+        Analyze_H2250ModeParameters(&x->h2250ModeParameters, "h2250ModeParameters", tag, indent);
+    }
+    if (x->option_of_genericModeParameters)
+    {
+        Analyze_GenericCapability(&x->genericModeParameters, "genericModeParameters", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "ModeElement");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for ModeType (CHOICE)  */
+/* <==================================> */
+void Analyze_ModeType(PS_ModeType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ModeType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_VideoMode(x->videoMode, "videoMode", tag, indent);
+            break;
+        case 2:
+            Analyze_AudioMode(x->audioMode, "audioMode", tag, indent);
+            break;
+        case 3:
+            Analyze_DataMode(x->dataMode, "dataMode", tag, indent);
+            break;
+        case 4:
+            Analyze_EncryptionMode(x->encryptionMode, "encryptionMode", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            Analyze_H235Mode(x->h235Mode, "h235Mode", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ModeType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ModeType");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for H235Mode (SEQUENCE)  */
+/* <====================================> */
+void Analyze_H235Mode(PS_H235Mode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H235Mode");
+    indent += 2;
+    Analyze_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, "encryptionAuthenticationAndIntegrity", tag, indent);
+    Analyze_MediaMode(&x->mediaMode, "mediaMode", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H235Mode");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for MediaMode (CHOICE)  */
+/* <===================================> */
+void Analyze_MediaMode(PS_MediaMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MediaMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_VideoMode(x->videoMode, "videoMode", tag, indent);
+            break;
+        case 2:
+            Analyze_AudioMode(x->audioMode, "audioMode", tag, indent);
+            break;
+        case 3:
+            Analyze_DataMode(x->dataMode, "dataMode", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MediaMode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MediaMode");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H223ModeParameters (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_H223ModeParameters(PS_H223ModeParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223ModeParameters");
+    indent += 2;
+    Analyze_ModeAdaptationLayerType(&x->modeAdaptationLayerType, "modeAdaptationLayerType", tag, indent);
+    ShowPERBoolean(tag, indent, "segmentableFlag", x->segmentableFlag);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H223ModeParameters");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for ModeAdaptationLayerType (CHOICE)  */
+/* <=================================================> */
+void Analyze_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ModeAdaptationLayerType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "al1Framed");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "al1NotFramed");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "al2WithoutSequenceNumbers");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "al2WithSequenceNumbers");
+            break;
+        case 5:
+            Analyze_ModeAl3(x->modeAl3, "modeAl3", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            Analyze_H223AL1MParameters(x->al1M, "al1M", tag, indent);
+            break;
+        case 7:
+            Analyze_H223AL2MParameters(x->al2M, "al2M", tag, indent);
+            break;
+        case 8:
+            Analyze_H223AL3MParameters(x->al3M, "al3M", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ModeAdaptationLayerType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ModeAdaptationLayerType");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for ModeAl3 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_ModeAl3(PS_ModeAl3 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ModeAl3");
+    indent += 2;
+    ShowPERInteger(tag, indent, "controlFieldOctets", (int32)x->controlFieldOctets);
+    ShowPERInteger(tag, indent, "sendBufferSize", (int32)x->sendBufferSize);
+    ShowPERClosure(tag, indent, "ModeAl3");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for V76ModeParameters (CHOICE)  */
+/* <===========================================> */
+void Analyze_V76ModeParameters(PS_V76ModeParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "V76ModeParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "suspendResumewAddress");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "suspendResumewoAddress");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_V76ModeParameters: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "V76ModeParameters");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for H2250ModeParameters (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_H2250ModeParameters(PS_H2250ModeParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H2250ModeParameters");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_redundancyEncodingMode", x->option_of_redundancyEncodingMode);
+    if (x->option_of_redundancyEncodingMode)
+    {
+        Analyze_RedundancyEncodingMode(&x->redundancyEncodingMode, "redundancyEncodingMode", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H2250ModeParameters");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for RedundancyEncodingMode (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_RedundancyEncodingMode(PS_RedundancyEncodingMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RedundancyEncodingMode");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_secondaryEncoding", x->option_of_secondaryEncoding);
+    Analyze_RedundancyEncodingMethod(&x->redundancyEncodingMethod, "redundancyEncodingMethod", tag, indent);
+    if (x->option_of_secondaryEncoding)
+    {
+        Analyze_SecondaryEncoding(&x->secondaryEncoding, "secondaryEncoding", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RedundancyEncodingMode");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for SecondaryEncoding (CHOICE)  */
+/* <===========================================> */
+void Analyze_SecondaryEncoding(PS_SecondaryEncoding x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "SecondaryEncoding");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_AudioMode(x->audioData, "audioData", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_SecondaryEncoding: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "SecondaryEncoding");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for VideoMode (CHOICE)  */
+/* <===================================> */
+void Analyze_VideoMode(PS_VideoMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "VideoMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_H261VideoMode(x->h261VideoMode, "h261VideoMode", tag, indent);
+            break;
+        case 2:
+            Analyze_H262VideoMode(x->h262VideoMode, "h262VideoMode", tag, indent);
+            break;
+        case 3:
+            Analyze_H263VideoMode(x->h263VideoMode, "h263VideoMode", tag, indent);
+            break;
+        case 4:
+            Analyze_IS11172VideoMode(x->is11172VideoMode, "is11172VideoMode", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            Analyze_GenericCapability(x->genericVideoMode, "genericVideoMode", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_VideoMode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "VideoMode");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for H261VideoMode (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_H261VideoMode(PS_H261VideoMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H261VideoMode");
+    indent += 2;
+    Analyze_Resolution(&x->resolution, "resolution", tag, indent);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    ShowPERBoolean(tag, indent, "stillImageTransmission", x->stillImageTransmission);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H261VideoMode");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for Resolution (CHOICE)  */
+/* <====================================> */
+void Analyze_Resolution(PS_Resolution x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Resolution");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "qcif");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "cif");
+            break;
+        default:
+            ErrorMessage("Analyze_Resolution: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Resolution");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for H262VideoMode (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_H262VideoMode(PS_H262VideoMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H262VideoMode");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_videoBitRate", x->option_of_videoBitRate);
+    ShowPERBoolean(tag, indent, "option_of_vbvBufferSize", x->option_of_vbvBufferSize);
+    ShowPERBoolean(tag, indent, "option_of_samplesPerLine", x->option_of_samplesPerLine);
+    ShowPERBoolean(tag, indent, "option_of_linesPerFrame", x->option_of_linesPerFrame);
+    ShowPERBoolean(tag, indent, "option_of_framesPerSecond", x->option_of_framesPerSecond);
+    ShowPERBoolean(tag, indent, "option_of_luminanceSampleRate", x->option_of_luminanceSampleRate);
+    Analyze_ProfileAndLevel(&x->profileAndLevel, "profileAndLevel", tag, indent);
+    if (x->option_of_videoBitRate)
+    {
+        ShowPERInteger(tag, indent, "videoBitRate", (int32)x->videoBitRate);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        ShowPERInteger(tag, indent, "vbvBufferSize", (int32)x->vbvBufferSize);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        ShowPERInteger(tag, indent, "samplesPerLine", (int32)x->samplesPerLine);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        ShowPERInteger(tag, indent, "linesPerFrame", (int32)x->linesPerFrame);
+    }
+    if (x->option_of_framesPerSecond)
+    {
+        ShowPERInteger(tag, indent, "framesPerSecond", (int32)x->framesPerSecond);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        ShowPERInteger(tag, indent, "luminanceSampleRate", (int32)x->luminanceSampleRate);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H262VideoMode");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for ProfileAndLevel (CHOICE)  */
+/* <=========================================> */
+void Analyze_ProfileAndLevel(PS_ProfileAndLevel x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ProfileAndLevel");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "profileAndLevel_SPatML");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "profileAndLevel_MPatLL");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "profileAndLevel_MPatML");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "profileAndLevel_MPatH_14");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "profileAndLevel_MPatHL");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "profileAndLevel_SNRatLL");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "profileAndLevel_SNRatML");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "profileAndLevel_SpatialatH_14");
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "profileAndLevel_HPatML");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "profileAndLevel_HPatH_14");
+            break;
+        case 10:
+            ShowPERNull(tag, indent, "profileAndLevel_HPatHL");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_ProfileAndLevel: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ProfileAndLevel");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for H263VideoMode (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_H263VideoMode(PS_H263VideoMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H263VideoMode");
+    indent += 2;
+    Analyze_H263Resolution(&x->h263Resolution, "h263Resolution", tag, indent);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    ShowPERBoolean(tag, indent, "unrestrictedVector", x->unrestrictedVector);
+    ShowPERBoolean(tag, indent, "arithmeticCoding", x->arithmeticCoding);
+    ShowPERBoolean(tag, indent, "advancedPrediction", x->advancedPrediction);
+    ShowPERBoolean(tag, indent, "pbFrames", x->pbFrames);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_errorCompensation", x->option_of_errorCompensation);
+    ShowPERBoolean(tag, indent, "option_of_enhancementLayerInfo", x->option_of_enhancementLayerInfo);
+    ShowPERBoolean(tag, indent, "option_of_h263Options", x->option_of_h263Options);
+    if (x->option_of_errorCompensation)
+    {
+        ShowPERBoolean(tag, indent, "errorCompensation", x->errorCompensation);
+    }
+    if (x->option_of_enhancementLayerInfo)
+    {
+        Analyze_EnhancementLayerInfo(&x->enhancementLayerInfo, "enhancementLayerInfo", tag, indent);
+    }
+    if (x->option_of_h263Options)
+    {
+        Analyze_H263Options(&x->h263Options, "h263Options", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "H263VideoMode");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for H263Resolution (CHOICE)  */
+/* <========================================> */
+void Analyze_H263Resolution(PS_H263Resolution x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "H263Resolution");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "sqcif");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "qcif");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "cif");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "cif4");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "cif16");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_H263Resolution: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "H263Resolution");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for IS11172VideoMode (SEQUENCE)  */
+/* <============================================> */
+void Analyze_IS11172VideoMode(PS_IS11172VideoMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IS11172VideoMode");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_videoBitRate", x->option_of_videoBitRate);
+    ShowPERBoolean(tag, indent, "option_of_vbvBufferSize", x->option_of_vbvBufferSize);
+    ShowPERBoolean(tag, indent, "option_of_samplesPerLine", x->option_of_samplesPerLine);
+    ShowPERBoolean(tag, indent, "option_of_linesPerFrame", x->option_of_linesPerFrame);
+    ShowPERBoolean(tag, indent, "option_of_pictureRate", x->option_of_pictureRate);
+    ShowPERBoolean(tag, indent, "option_of_luminanceSampleRate", x->option_of_luminanceSampleRate);
+    ShowPERBoolean(tag, indent, "constrainedBitstream", x->constrainedBitstream);
+    if (x->option_of_videoBitRate)
+    {
+        ShowPERInteger(tag, indent, "videoBitRate", (int32)x->videoBitRate);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        ShowPERInteger(tag, indent, "vbvBufferSize", (int32)x->vbvBufferSize);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        ShowPERInteger(tag, indent, "samplesPerLine", (int32)x->samplesPerLine);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        ShowPERInteger(tag, indent, "linesPerFrame", (int32)x->linesPerFrame);
+    }
+    if (x->option_of_pictureRate)
+    {
+        ShowPERInteger(tag, indent, "pictureRate", (int32)x->pictureRate);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        ShowPERInteger(tag, indent, "luminanceSampleRate", (int32)x->luminanceSampleRate);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IS11172VideoMode");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for AudioMode (CHOICE)  */
+/* <===================================> */
+void Analyze_AudioMode(PS_AudioMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "AudioMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "g711Alaw64k");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "g711Alaw56k");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "g711Ulaw64k");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "g711Ulaw56k");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "g722_64k");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "g722_56k");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "g722_48k");
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "g728");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "g729");
+            break;
+        case 10:
+            ShowPERNull(tag, indent, "g729AnnexA");
+            break;
+        case 11:
+            Analyze_ModeG7231(x->modeG7231, "modeG7231", tag, indent);
+            break;
+        case 12:
+            Analyze_IS11172AudioMode(x->is11172AudioMode, "is11172AudioMode", tag, indent);
+            break;
+        case 13:
+            Analyze_IS13818AudioMode(x->is13818AudioMode, "is13818AudioMode", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            ShowPERInteger(tag, indent, "g729wAnnexB", (uint32)x->g729wAnnexB);
+            break;
+        case 15:
+            ShowPERInteger(tag, indent, "g729AnnexAwAnnexB", (uint32)x->g729AnnexAwAnnexB);
+            break;
+        case 16:
+            Analyze_G7231AnnexCMode(x->g7231AnnexCMode, "g7231AnnexCMode", tag, indent);
+            break;
+        case 17:
+            Analyze_GSMAudioCapability(x->gsmFullRate, "gsmFullRate", tag, indent);
+            break;
+        case 18:
+            Analyze_GSMAudioCapability(x->gsmHalfRate, "gsmHalfRate", tag, indent);
+            break;
+        case 19:
+            Analyze_GSMAudioCapability(x->gsmEnhancedFullRate, "gsmEnhancedFullRate", tag, indent);
+            break;
+        case 20:
+            Analyze_GenericCapability(x->genericAudioMode, "genericAudioMode", tag, indent);
+            break;
+        case 21:
+            Analyze_G729Extensions(x->g729Extensions, "g729Extensions", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_AudioMode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "AudioMode");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for ModeG7231 (CHOICE)  */
+/* <===================================> */
+void Analyze_ModeG7231(PS_ModeG7231 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ModeG7231");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noSilenceSuppressionLowRate");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "noSilenceSuppressionHighRate");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "silenceSuppressionLowRate");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "silenceSuppressionHighRate");
+            break;
+        default:
+            ErrorMessage("Analyze_ModeG7231: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ModeG7231");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for IS11172AudioMode (SEQUENCE)  */
+/* <============================================> */
+void Analyze_IS11172AudioMode(PS_IS11172AudioMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IS11172AudioMode");
+    indent += 2;
+    Analyze_AudioLayer(&x->audioLayer, "audioLayer", tag, indent);
+    Analyze_AudioSampling(&x->audioSampling, "audioSampling", tag, indent);
+    Analyze_MultichannelType(&x->multichannelType, "multichannelType", tag, indent);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IS11172AudioMode");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for MultichannelType (CHOICE)  */
+/* <==========================================> */
+void Analyze_MultichannelType(PS_MultichannelType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultichannelType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "singleChannel");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "twoChannelStereo");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "twoChannelDual");
+            break;
+        default:
+            ErrorMessage("Analyze_MultichannelType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultichannelType");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for AudioSampling (CHOICE)  */
+/* <=======================================> */
+void Analyze_AudioSampling(PS_AudioSampling x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "AudioSampling");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "audioSampling32k");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "audioSampling44k1");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "audioSampling48k");
+            break;
+        default:
+            ErrorMessage("Analyze_AudioSampling: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "AudioSampling");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for AudioLayer (CHOICE)  */
+/* <====================================> */
+void Analyze_AudioLayer(PS_AudioLayer x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "AudioLayer");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "audioLayer1");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "audioLayer2");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "audioLayer3");
+            break;
+        default:
+            ErrorMessage("Analyze_AudioLayer: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "AudioLayer");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for IS13818AudioMode (SEQUENCE)  */
+/* <============================================> */
+void Analyze_IS13818AudioMode(PS_IS13818AudioMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IS13818AudioMode");
+    indent += 2;
+    Analyze_Is13818AudioLayer(&x->is13818AudioLayer, "is13818AudioLayer", tag, indent);
+    Analyze_Is13818AudioSampling(&x->is13818AudioSampling, "is13818AudioSampling", tag, indent);
+    Analyze_Is13818MultichannelType(&x->is13818MultichannelType, "is13818MultichannelType", tag, indent);
+    ShowPERBoolean(tag, indent, "lowFrequencyEnhancement", x->lowFrequencyEnhancement);
+    ShowPERBoolean(tag, indent, "multilingual", x->multilingual);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IS13818AudioMode");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for Is13818MultichannelType (CHOICE)  */
+/* <=================================================> */
+void Analyze_Is13818MultichannelType(PS_Is13818MultichannelType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Is13818MultichannelType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "singleChannel");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "twoChannelStereo");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "twoChannelDual");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "threeChannels2_1");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "threeChannels3_0");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "fourChannels2_0_2_0");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "fourChannels2_2");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "fourChannels3_1");
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "fiveChannels3_0_2_0");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "fiveChannels3_2");
+            break;
+        default:
+            ErrorMessage("Analyze_Is13818MultichannelType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Is13818MultichannelType");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for Is13818AudioSampling (CHOICE)  */
+/* <==============================================> */
+void Analyze_Is13818AudioSampling(PS_Is13818AudioSampling x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Is13818AudioSampling");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "audioSampling16k");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "audioSampling22k05");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "audioSampling24k");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "audioSampling32k");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "audioSampling44k1");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "audioSampling48k");
+            break;
+        default:
+            ErrorMessage("Analyze_Is13818AudioSampling: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Is13818AudioSampling");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for Is13818AudioLayer (CHOICE)  */
+/* <===========================================> */
+void Analyze_Is13818AudioLayer(PS_Is13818AudioLayer x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Is13818AudioLayer");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "audioLayer1");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "audioLayer2");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "audioLayer3");
+            break;
+        default:
+            ErrorMessage("Analyze_Is13818AudioLayer: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Is13818AudioLayer");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for G7231AnnexCMode (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_G7231AnnexCMode(PS_G7231AnnexCMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "G7231AnnexCMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maxAl_sduAudioFrames", (int32)x->maxAl_sduAudioFrames);
+    ShowPERBoolean(tag, indent, "silenceSuppression", x->silenceSuppression);
+    Analyze_ModeG723AnnexCAudioMode(&x->modeG723AnnexCAudioMode, "modeG723AnnexCAudioMode", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "G7231AnnexCMode");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for ModeG723AnnexCAudioMode (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ModeG723AnnexCAudioMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "highRateMode0", (int32)x->highRateMode0);
+    ShowPERInteger(tag, indent, "highRateMode1", (int32)x->highRateMode1);
+    ShowPERInteger(tag, indent, "lowRateMode0", (int32)x->lowRateMode0);
+    ShowPERInteger(tag, indent, "lowRateMode1", (int32)x->lowRateMode1);
+    ShowPERInteger(tag, indent, "sidMode0", (int32)x->sidMode0);
+    ShowPERInteger(tag, indent, "sidMode1", (int32)x->sidMode1);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ModeG723AnnexCAudioMode");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for DataMode (SEQUENCE)  */
+/* <====================================> */
+void Analyze_DataMode(PS_DataMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "DataMode");
+    indent += 2;
+    Analyze_DmApplication(&x->dmApplication, "dmApplication", tag, indent);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "DataMode");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for DmApplication (CHOICE)  */
+/* <=======================================> */
+void Analyze_DmApplication(PS_DmApplication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "DmApplication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_DataProtocolCapability(x->t120, "t120", tag, indent);
+            break;
+        case 2:
+            Analyze_DataProtocolCapability(x->dsm_cc, "dsm_cc", tag, indent);
+            break;
+        case 3:
+            Analyze_DataProtocolCapability(x->userData, "userData", tag, indent);
+            break;
+        case 4:
+            Analyze_DataProtocolCapability(x->t84, "t84", tag, indent);
+            break;
+        case 5:
+            Analyze_DataProtocolCapability(x->t434, "t434", tag, indent);
+            break;
+        case 6:
+            Analyze_DataProtocolCapability(x->h224, "h224", tag, indent);
+            break;
+        case 7:
+            Analyze_DmNlpid(x->dmNlpid, "dmNlpid", tag, indent);
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "dsvdControl");
+            break;
+        case 9:
+            Analyze_DataProtocolCapability(x->h222DataPartitioning, "h222DataPartitioning", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Analyze_DataProtocolCapability(x->t30fax, "t30fax", tag, indent);
+            break;
+        case 11:
+            Analyze_DataProtocolCapability(x->t140, "t140", tag, indent);
+            break;
+        case 12:
+            Analyze_DmT38fax(x->dmT38fax, "dmT38fax", tag, indent);
+            break;
+        case 13:
+            Analyze_GenericCapability(x->genericDataMode, "genericDataMode", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_DmApplication: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "DmApplication");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for DmT38fax (SEQUENCE)  */
+/* <====================================> */
+void Analyze_DmT38fax(PS_DmT38fax x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "DmT38fax");
+    indent += 2;
+    Analyze_DataProtocolCapability(&x->t38FaxProtocol, "t38FaxProtocol", tag, indent);
+    Analyze_T38FaxProfile(&x->t38FaxProfile, "t38FaxProfile", tag, indent);
+    ShowPERClosure(tag, indent, "DmT38fax");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for DmNlpid (SEQUENCE)  */
+/* <===================================> */
+void Analyze_DmNlpid(PS_DmNlpid x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "DmNlpid");
+    indent += 2;
+    Analyze_DataProtocolCapability(&x->nlpidProtocol, "nlpidProtocol", tag, indent);
+    ShowPEROctetString(tag, indent, "nlpidData", &x->nlpidData);
+    ShowPERClosure(tag, indent, "DmNlpid");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for EncryptionMode (CHOICE)  */
+/* <========================================> */
+void Analyze_EncryptionMode(PS_EncryptionMode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "EncryptionMode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "h233Encryption");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_EncryptionMode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "EncryptionMode");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for RoundTripDelayRequest (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_RoundTripDelayRequest(PS_RoundTripDelayRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RoundTripDelayRequest");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RoundTripDelayRequest");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for RoundTripDelayResponse (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_RoundTripDelayResponse(PS_RoundTripDelayResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RoundTripDelayResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RoundTripDelayResponse");
+}
+
+/* <==================================================> */
+/*  PER-Analyzer for MaintenanceLoopRequest (SEQUENCE)  */
+/* <==================================================> */
+void Analyze_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MaintenanceLoopRequest");
+    indent += 2;
+    Analyze_MlRequestType(&x->mlRequestType, "mlRequestType", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaintenanceLoopRequest");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for MlRequestType (CHOICE)  */
+/* <=======================================> */
+void Analyze_MlRequestType(PS_MlRequestType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MlRequestType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "systemLoop");
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "mediaLoop", (uint32)x->mediaLoop);
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "logicalChannelLoop", (uint32)x->logicalChannelLoop);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MlRequestType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MlRequestType");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for MaintenanceLoopAck (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_MaintenanceLoopAck(PS_MaintenanceLoopAck x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MaintenanceLoopAck");
+    indent += 2;
+    Analyze_MlAckType(&x->mlAckType, "mlAckType", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaintenanceLoopAck");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for MlAckType (CHOICE)  */
+/* <===================================> */
+void Analyze_MlAckType(PS_MlAckType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MlAckType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "systemLoop");
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "mediaLoop", (uint32)x->mediaLoop);
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "logicalChannelLoop", (uint32)x->logicalChannelLoop);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MlAckType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MlAckType");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for MaintenanceLoopReject (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_MaintenanceLoopReject(PS_MaintenanceLoopReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MaintenanceLoopReject");
+    indent += 2;
+    Analyze_MlRejectType(&x->mlRejectType, "mlRejectType", tag, indent);
+    Analyze_MlRejectCause(&x->mlRejectCause, "mlRejectCause", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaintenanceLoopReject");
+}
+
+/* <=======================================> */
+/*  PER-Analyzer for MlRejectCause (CHOICE)  */
+/* <=======================================> */
+void Analyze_MlRejectCause(PS_MlRejectCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MlRejectCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "canNotPerformLoop");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MlRejectCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MlRejectCause");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for MlRejectType (CHOICE)  */
+/* <======================================> */
+void Analyze_MlRejectType(PS_MlRejectType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MlRejectType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "systemLoop");
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "mediaLoop", (uint32)x->mediaLoop);
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "logicalChannelLoop", (uint32)x->logicalChannelLoop);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MlRejectType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MlRejectType");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for MaintenanceLoopOffCommand (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "MaintenanceLoopOffCommand");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaintenanceLoopOffCommand");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for CommunicationModeCommand (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_CommunicationModeCommand(PS_CommunicationModeCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "CommunicationModeCommand");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_communicationModeTable", (uint32)x->size_of_communicationModeTable);
+    for (i = 0;i < x->size_of_communicationModeTable;++i)
+    {
+        sprintf(tempLabelString, "communicationModeTable[%hu]", i);
+        Analyze_CommunicationModeTableEntry(x->communicationModeTable + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CommunicationModeCommand");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for CommunicationModeRequest (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_CommunicationModeRequest(PS_CommunicationModeRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "CommunicationModeRequest");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CommunicationModeRequest");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for CommunicationModeResponse (CHOICE)  */
+/* <===================================================> */
+void Analyze_CommunicationModeResponse(PS_CommunicationModeResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "CommunicationModeResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "communicationModeTable[%hu]", i);
+                Analyze_CommunicationModeTableEntry(x->communicationModeTable + i, tempLabelString, tag, indent);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CommunicationModeResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CommunicationModeResponse");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for CommunicationModeTableEntry (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "CommunicationModeTableEntry");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_nonStandard", x->option_of_nonStandard);
+    ShowPERBoolean(tag, indent, "option_of_associatedSessionID", x->option_of_associatedSessionID);
+    ShowPERBoolean(tag, indent, "option_of_terminalLabel", x->option_of_terminalLabel);
+    ShowPERBoolean(tag, indent, "option_of_mediaChannel", x->option_of_mediaChannel);
+    ShowPERBoolean(tag, indent, "option_of_mediaGuaranteedDelivery", x->option_of_mediaGuaranteedDelivery);
+    ShowPERBoolean(tag, indent, "option_of_mediaControlChannel", x->option_of_mediaControlChannel);
+    ShowPERBoolean(tag, indent, "option_of_mediaControlGuaranteedDelivery", x->option_of_mediaControlGuaranteedDelivery);
+    if (x->option_of_nonStandard)
+    {
+        ShowPERInteger(tag, indent, "size_of_nonStandard", (uint32)x->size_of_nonStandard);
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            sprintf(tempLabelString, "nonStandard[%hu]", i);
+            Analyze_NonStandardParameter(x->nonStandard + i, tempLabelString, tag, indent);
+        }
+    }
+    ShowPERInteger(tag, indent, "sessionID", (int32)x->sessionID);
+    if (x->option_of_associatedSessionID)
+    {
+        ShowPERInteger(tag, indent, "associatedSessionID", (int32)x->associatedSessionID);
+    }
+    if (x->option_of_terminalLabel)
+    {
+        Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    }
+    ShowPERCharString(tag, indent, "sessionDescription", &x->sessionDescription);
+    Analyze_CmtDataType(&x->cmtDataType, "cmtDataType", tag, indent);
+    if (x->option_of_mediaChannel)
+    {
+        Analyze_TransportAddress(&x->mediaChannel, "mediaChannel", tag, indent);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+        ShowPERBoolean(tag, indent, "mediaGuaranteedDelivery", x->mediaGuaranteedDelivery);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Analyze_TransportAddress(&x->mediaControlChannel, "mediaControlChannel", tag, indent);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+        ShowPERBoolean(tag, indent, "mediaControlGuaranteedDelivery", x->mediaControlGuaranteedDelivery);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_redundancyEncoding", x->option_of_redundancyEncoding);
+    ShowPERBoolean(tag, indent, "option_of_sessionDependency", x->option_of_sessionDependency);
+    ShowPERBoolean(tag, indent, "option_of_destination", x->option_of_destination);
+    if (x->option_of_redundancyEncoding)
+    {
+        Analyze_RedundancyEncoding(&x->redundancyEncoding, "redundancyEncoding", tag, indent);
+    }
+    if (x->option_of_sessionDependency)
+    {
+        ShowPERInteger(tag, indent, "sessionDependency", (int32)x->sessionDependency);
+    }
+    if (x->option_of_destination)
+    {
+        Analyze_TerminalLabel(&x->destination, "destination", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "CommunicationModeTableEntry");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for CmtDataType (CHOICE)  */
+/* <=====================================> */
+void Analyze_CmtDataType(PS_CmtDataType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CmtDataType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_VideoCapability(x->videoData, "videoData", tag, indent);
+            break;
+        case 1:
+            Analyze_AudioCapability(x->audioData, "audioData", tag, indent);
+            break;
+        case 2:
+            Analyze_DataApplicationCapability(x->data, "data", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CmtDataType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CmtDataType");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for ConferenceRequest (CHOICE)  */
+/* <===========================================> */
+void Analyze_ConferenceRequest(PS_ConferenceRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ConferenceRequest");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "terminalListRequest");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "makeMeChair");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "cancelMakeMeChair");
+            break;
+        case 3:
+            Analyze_TerminalLabel(x->dropTerminal, "dropTerminal", tag, indent);
+            break;
+        case 4:
+            Analyze_TerminalLabel(x->requestTerminalID, "requestTerminalID", tag, indent);
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "enterH243Password");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "enterH243TerminalID");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "enterH243ConferenceID");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            ShowPERNull(tag, indent, "enterExtensionAddress");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "requestChairTokenOwner");
+            break;
+        case 10:
+            Analyze_RequestTerminalCertificate(x->requestTerminalCertificate, "requestTerminalCertificate", tag, indent);
+            break;
+        case 11:
+            ShowPERInteger(tag, indent, "broadcastMyLogicalChannel", (uint32)x->broadcastMyLogicalChannel);
+            break;
+        case 12:
+            Analyze_TerminalLabel(x->makeTerminalBroadcaster, "makeTerminalBroadcaster", tag, indent);
+            break;
+        case 13:
+            Analyze_TerminalLabel(x->sendThisSource, "sendThisSource", tag, indent);
+            break;
+        case 14:
+            ShowPERNull(tag, indent, "requestAllTerminalIDs");
+            break;
+        case 15:
+            Analyze_RemoteMCRequest(x->remoteMCRequest, "remoteMCRequest", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ConferenceRequest: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ConferenceRequest");
+}
+
+/* <======================================================> */
+/*  PER-Analyzer for RequestTerminalCertificate (SEQUENCE)  */
+/* <======================================================> */
+void Analyze_RequestTerminalCertificate(PS_RequestTerminalCertificate x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RequestTerminalCertificate");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_terminalLabel", x->option_of_terminalLabel);
+    ShowPERBoolean(tag, indent, "option_of_certSelectionCriteria", x->option_of_certSelectionCriteria);
+    ShowPERBoolean(tag, indent, "option_of_sRandom", x->option_of_sRandom);
+    if (x->option_of_terminalLabel)
+    {
+        Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    }
+    if (x->option_of_certSelectionCriteria)
+    {
+        Analyze_CertSelectionCriteria(&x->certSelectionCriteria, "certSelectionCriteria", tag, indent);
+    }
+    if (x->option_of_sRandom)
+    {
+        ShowPERInteger(tag, indent, "sRandom", (int32)x->sRandom);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestTerminalCertificate");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for CertSelectionCriteria (SEQUENCE-OF)  */
+/* <====================================================> */
+void Analyze_CertSelectionCriteria(PS_CertSelectionCriteria x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequenceof(tag, indent, label, "CertSelectionCriteria");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size", (uint32)x->size);
+    for (i = 0;i < x->size;++i)
+    {
+        sprintf(tempLabelString, "item[%hu]", i);
+        Analyze_Criteria(x->item + i, tempLabelString, tag, indent);
+    }
+    ShowPERClosure(tag, indent, "CertSelectionCriteria");
+}
+
+/* <====================================> */
+/*  PER-Analyzer for Criteria (SEQUENCE)  */
+/* <====================================> */
+void Analyze_Criteria(PS_Criteria x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Criteria");
+    indent += 2;
+    ShowPERObjectID(tag, indent, "field", &x->field);
+    ShowPEROctetString(tag, indent, "value", &x->value);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Criteria");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for TerminalLabel (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_TerminalLabel(PS_TerminalLabel x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalLabel");
+    indent += 2;
+    ShowPERInteger(tag, indent, "mcuNumber", (int32)x->mcuNumber);
+    ShowPERInteger(tag, indent, "terminalNumber", (int32)x->terminalNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalLabel");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for ConferenceResponse (CHOICE)  */
+/* <============================================> */
+void Analyze_ConferenceResponse(PS_ConferenceResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "ConferenceResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_MCTerminalIDResponse(x->mCTerminalIDResponse, "mCTerminalIDResponse", tag, indent);
+            break;
+        case 1:
+            Analyze_TerminalIDResponse(x->terminalIDResponse, "terminalIDResponse", tag, indent);
+            break;
+        case 2:
+            Analyze_ConferenceIDResponse(x->conferenceIDResponse, "conferenceIDResponse", tag, indent);
+            break;
+        case 3:
+            Analyze_PasswordResponse(x->passwordResponse, "passwordResponse", tag, indent);
+            break;
+        case 4:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "terminalListResponse[%hu]", i);
+                Analyze_TerminalLabel(x->terminalListResponse + i, tempLabelString, tag, indent);
+            }
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "videoCommandReject");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "terminalDropReject");
+            break;
+        case 7:
+            Analyze_MakeMeChairResponse(x->makeMeChairResponse, "makeMeChairResponse", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            Analyze_ExtensionAddressResponse(x->extensionAddressResponse, "extensionAddressResponse", tag, indent);
+            break;
+        case 9:
+            Analyze_ChairTokenOwnerResponse(x->chairTokenOwnerResponse, "chairTokenOwnerResponse", tag, indent);
+            break;
+        case 10:
+            Analyze_TerminalCertificateResponse(x->terminalCertificateResponse, "terminalCertificateResponse", tag, indent);
+            break;
+        case 11:
+            Analyze_BroadcastMyLogicalChannelResponse(x->broadcastMyLogicalChannelResponse, "broadcastMyLogicalChannelResponse", tag, indent);
+            break;
+        case 12:
+            Analyze_MakeTerminalBroadcasterResponse(x->makeTerminalBroadcasterResponse, "makeTerminalBroadcasterResponse", tag, indent);
+            break;
+        case 13:
+            Analyze_SendThisSourceResponse(x->sendThisSourceResponse, "sendThisSourceResponse", tag, indent);
+            break;
+        case 14:
+            Analyze_RequestAllTerminalIDsResponse(x->requestAllTerminalIDsResponse, "requestAllTerminalIDsResponse", tag, indent);
+            break;
+        case 15:
+            Analyze_RemoteMCResponse(x->remoteMCResponse, "remoteMCResponse", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ConferenceResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ConferenceResponse");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for SendThisSourceResponse (CHOICE)  */
+/* <================================================> */
+void Analyze_SendThisSourceResponse(PS_SendThisSourceResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "SendThisSourceResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "grantedSendThisSource");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "deniedSendThisSource");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_SendThisSourceResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "SendThisSourceResponse");
+}
+
+/* <=========================================================> */
+/*  PER-Analyzer for MakeTerminalBroadcasterResponse (CHOICE)  */
+/* <=========================================================> */
+void Analyze_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MakeTerminalBroadcasterResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "grantedMakeTerminalBroadcaster");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "deniedMakeTerminalBroadcaster");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MakeTerminalBroadcasterResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MakeTerminalBroadcasterResponse");
+}
+
+/* <===========================================================> */
+/*  PER-Analyzer for BroadcastMyLogicalChannelResponse (CHOICE)  */
+/* <===========================================================> */
+void Analyze_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "BroadcastMyLogicalChannelResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "grantedBroadcastMyLogicalChannel");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "deniedBroadcastMyLogicalChannel");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_BroadcastMyLogicalChannelResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "BroadcastMyLogicalChannelResponse");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for TerminalCertificateResponse (SEQUENCE)  */
+/* <=======================================================> */
+void Analyze_TerminalCertificateResponse(PS_TerminalCertificateResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalCertificateResponse");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_terminalLabel", x->option_of_terminalLabel);
+    ShowPERBoolean(tag, indent, "option_of_certificateResponse", x->option_of_certificateResponse);
+    if (x->option_of_terminalLabel)
+    {
+        Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    }
+    if (x->option_of_certificateResponse)
+    {
+        ShowPEROctetString(tag, indent, "certificateResponse", &x->certificateResponse);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalCertificateResponse");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for ChairTokenOwnerResponse (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ChairTokenOwnerResponse");
+    indent += 2;
+    Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    ShowPEROctetString(tag, indent, "terminalID", &x->terminalID);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ChairTokenOwnerResponse");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for ExtensionAddressResponse (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_ExtensionAddressResponse(PS_ExtensionAddressResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ExtensionAddressResponse");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "extensionAddress", &x->extensionAddress);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ExtensionAddressResponse");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for MakeMeChairResponse (CHOICE)  */
+/* <=============================================> */
+void Analyze_MakeMeChairResponse(PS_MakeMeChairResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MakeMeChairResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "grantedChairToken");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "deniedChairToken");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MakeMeChairResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MakeMeChairResponse");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for PasswordResponse (SEQUENCE)  */
+/* <============================================> */
+void Analyze_PasswordResponse(PS_PasswordResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "PasswordResponse");
+    indent += 2;
+    Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    ShowPEROctetString(tag, indent, "password", &x->password);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "PasswordResponse");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for ConferenceIDResponse (SEQUENCE)  */
+/* <================================================> */
+void Analyze_ConferenceIDResponse(PS_ConferenceIDResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ConferenceIDResponse");
+    indent += 2;
+    Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    ShowPEROctetString(tag, indent, "conferenceID", &x->conferenceID);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ConferenceIDResponse");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for TerminalIDResponse (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_TerminalIDResponse(PS_TerminalIDResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalIDResponse");
+    indent += 2;
+    Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    ShowPEROctetString(tag, indent, "terminalID", &x->terminalID);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalIDResponse");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for MCTerminalIDResponse (SEQUENCE)  */
+/* <================================================> */
+void Analyze_MCTerminalIDResponse(PS_MCTerminalIDResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MCTerminalIDResponse");
+    indent += 2;
+    Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    ShowPEROctetString(tag, indent, "terminalID", &x->terminalID);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MCTerminalIDResponse");
+}
+
+/* <=========================================================> */
+/*  PER-Analyzer for RequestAllTerminalIDsResponse (SEQUENCE)  */
+/* <=========================================================> */
+void Analyze_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "RequestAllTerminalIDsResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "size_of_terminalInformation", (uint32)x->size_of_terminalInformation);
+    for (i = 0;i < x->size_of_terminalInformation;++i)
+    {
+        sprintf(tempLabelString, "terminalInformation[%hu]", i);
+        Analyze_TerminalInformation(x->terminalInformation + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RequestAllTerminalIDsResponse");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for TerminalInformation (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_TerminalInformation(PS_TerminalInformation x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalInformation");
+    indent += 2;
+    Analyze_TerminalLabel(&x->terminalLabel, "terminalLabel", tag, indent);
+    ShowPEROctetString(tag, indent, "terminalID", &x->terminalID);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalInformation");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for RemoteMCRequest (CHOICE)  */
+/* <=========================================> */
+void Analyze_RemoteMCRequest(PS_RemoteMCRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RemoteMCRequest");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "masterActivate");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "slaveActivate");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "deActivate");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RemoteMCRequest: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RemoteMCRequest");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for RemoteMCResponse (CHOICE)  */
+/* <==========================================> */
+void Analyze_RemoteMCResponse(PS_RemoteMCResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RemoteMCResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "accept");
+            break;
+        case 1:
+            Analyze_Reject(x->reject, "reject", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RemoteMCResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RemoteMCResponse");
+}
+
+/* <================================> */
+/*  PER-Analyzer for Reject (CHOICE)  */
+/* <================================> */
+void Analyze_Reject(PS_Reject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Reject");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "unspecified");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "functionNotSupported");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Reject: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Reject");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for MultilinkRequest (CHOICE)  */
+/* <==========================================> */
+void Analyze_MultilinkRequest(PS_MultilinkRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultilinkRequest");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_CallInformation(x->callInformation, "callInformation", tag, indent);
+            break;
+        case 2:
+            Analyze_AddConnection(x->addConnection, "addConnection", tag, indent);
+            break;
+        case 3:
+            Analyze_RemoveConnection(x->removeConnection, "removeConnection", tag, indent);
+            break;
+        case 4:
+            Analyze_MaximumHeaderInterval(x->maximumHeaderInterval, "maximumHeaderInterval", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MultilinkRequest: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultilinkRequest");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for MaximumHeaderInterval (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_MaximumHeaderInterval(PS_MaximumHeaderInterval x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MaximumHeaderInterval");
+    indent += 2;
+    Analyze_RequestType(&x->requestType, "requestType", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MaximumHeaderInterval");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for RequestType (CHOICE)  */
+/* <=====================================> */
+void Analyze_RequestType(PS_RequestType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "RequestType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "currentIntervalInformation");
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "requestedInterval", (uint32)x->requestedInterval);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_RequestType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "RequestType");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for RemoveConnection (SEQUENCE)  */
+/* <============================================> */
+void Analyze_RemoveConnection(PS_RemoveConnection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RemoveConnection");
+    indent += 2;
+    Analyze_ConnectionIdentifier(&x->connectionIdentifier, "connectionIdentifier", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RemoveConnection");
+}
+
+/* <=========================================> */
+/*  PER-Analyzer for AddConnection (SEQUENCE)  */
+/* <=========================================> */
+void Analyze_AddConnection(PS_AddConnection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "AddConnection");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    Analyze_DialingInformation(&x->dialingInformation, "dialingInformation", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "AddConnection");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for CallInformation (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_CallInformation(PS_CallInformation x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CallInformation");
+    indent += 2;
+    ShowPERInteger(tag, indent, "maxNumberOfAdditionalConnections", (int32)x->maxNumberOfAdditionalConnections);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CallInformation");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for MultilinkResponse (CHOICE)  */
+/* <===========================================> */
+void Analyze_MultilinkResponse(PS_MultilinkResponse x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultilinkResponse");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_RespCallInformation(x->respCallInformation, "respCallInformation", tag, indent);
+            break;
+        case 2:
+            Analyze_RespAddConnection(x->respAddConnection, "respAddConnection", tag, indent);
+            break;
+        case 3:
+            Analyze_RespRemoveConnection(x->respRemoveConnection, "respRemoveConnection", tag, indent);
+            break;
+        case 4:
+            Analyze_RespMaximumHeaderInterval(x->respMaximumHeaderInterval, "respMaximumHeaderInterval", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MultilinkResponse: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultilinkResponse");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for RespMaximumHeaderInterval (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RespMaximumHeaderInterval");
+    indent += 2;
+    ShowPERInteger(tag, indent, "currentInterval", (int32)x->currentInterval);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RespMaximumHeaderInterval");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for RespRemoveConnection (SEQUENCE)  */
+/* <================================================> */
+void Analyze_RespRemoveConnection(PS_RespRemoveConnection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RespRemoveConnection");
+    indent += 2;
+    Analyze_ConnectionIdentifier(&x->connectionIdentifier, "connectionIdentifier", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RespRemoveConnection");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for RespAddConnection (SEQUENCE)  */
+/* <=============================================> */
+void Analyze_RespAddConnection(PS_RespAddConnection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RespAddConnection");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    Analyze_ResponseCode(&x->responseCode, "responseCode", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RespAddConnection");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for ResponseCode (CHOICE)  */
+/* <======================================> */
+void Analyze_ResponseCode(PS_ResponseCode x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ResponseCode");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "accepted");
+            break;
+        case 1:
+            Analyze_Rejected(x->rejected, "rejected", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_ResponseCode: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ResponseCode");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for Rejected (CHOICE)  */
+/* <==================================> */
+void Analyze_Rejected(PS_Rejected x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Rejected");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "connectionsNotAvailable");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "userRejected");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Rejected: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Rejected");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for RespCallInformation (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_RespCallInformation(PS_RespCallInformation x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "RespCallInformation");
+    indent += 2;
+    Analyze_DialingInformation(&x->dialingInformation, "dialingInformation", tag, indent);
+    ShowPERInteger(tag, indent, "callAssociationNumber", (int32)x->callAssociationNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "RespCallInformation");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for MultilinkIndication (CHOICE)  */
+/* <=============================================> */
+void Analyze_MultilinkIndication(PS_MultilinkIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MultilinkIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            Analyze_CrcDesired(x->crcDesired, "crcDesired", tag, indent);
+            break;
+        case 2:
+            Analyze_ExcessiveError(x->excessiveError, "excessiveError", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_MultilinkIndication: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MultilinkIndication");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for ExcessiveError (SEQUENCE)  */
+/* <==========================================> */
+void Analyze_ExcessiveError(PS_ExcessiveError x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ExcessiveError");
+    indent += 2;
+    Analyze_ConnectionIdentifier(&x->connectionIdentifier, "connectionIdentifier", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ExcessiveError");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for CrcDesired (SEQUENCE)  */
+/* <======================================> */
+void Analyze_CrcDesired(PS_CrcDesired x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "CrcDesired");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CrcDesired");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for DialingInformation (CHOICE)  */
+/* <============================================> */
+void Analyze_DialingInformation(PS_DialingInformation x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERChoice(tag, indent, label, "DialingInformation");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "size", (uint32)x->size);
+            for (i = 0;i < x->size;++i)
+            {
+                sprintf(tempLabelString, "differential[%hu]", i);
+                Analyze_DialingInformationNumber(x->differential + i, tempLabelString, tag, indent);
+            }
+            break;
+        case 2:
+            ShowPERInteger(tag, indent, "infoNotAvailable", (uint32)x->infoNotAvailable);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_DialingInformation: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "DialingInformation");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for DialingInformationNumber (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_DialingInformationNumber(PS_DialingInformationNumber x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+    char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "DialingInformationNumber");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_subAddress", x->option_of_subAddress);
+    ShowPERCharString(tag, indent, "networkAddress", &x->networkAddress);
+    if (x->option_of_subAddress)
+    {
+        ShowPERCharString(tag, indent, "subAddress", &x->subAddress);
+    }
+    ShowPERInteger(tag, indent, "size_of_networkType", (uint32)x->size_of_networkType);
+    for (i = 0;i < x->size_of_networkType;++i)
+    {
+        sprintf(tempLabelString, "networkType[%hu]", i);
+        Analyze_DialingInformationNetworkType(x->networkType + i, tempLabelString, tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "DialingInformationNumber");
+}
+
+/* <=======================================================> */
+/*  PER-Analyzer for DialingInformationNetworkType (CHOICE)  */
+/* <=======================================================> */
+void Analyze_DialingInformationNetworkType(PS_DialingInformationNetworkType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "DialingInformationNetworkType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardMessage(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "n_isdn");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "gstn");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_DialingInformationNetworkType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "DialingInformationNetworkType");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for ConnectionIdentifier (SEQUENCE)  */
+/* <================================================> */
+void Analyze_ConnectionIdentifier(PS_ConnectionIdentifier x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ConnectionIdentifier");
+    indent += 2;
+    ShowPERInteger(tag, indent, "channelTag", (int32)x->channelTag);
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ConnectionIdentifier");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for LogicalChannelRateRequest (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "LogicalChannelRateRequest");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    ShowPERInteger(tag, indent, "maximumBitRate", (int32)x->maximumBitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "LogicalChannelRateRequest");
+}
+
+/* <=========================================================> */
+/*  PER-Analyzer for LogicalChannelRateAcknowledge (SEQUENCE)  */
+/* <=========================================================> */
+void Analyze_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "LogicalChannelRateAcknowledge");
+    indent += 2;
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    ShowPERInteger(tag, indent, "maximumBitRate", (int32)x->maximumBitRate);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "LogicalChannelRateAcknowledge");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for LogicalChannelRateReject (SEQUENCE)  */
+/* <====================================================> */
+void Analyze_LogicalChannelRateReject(PS_LogicalChannelRateReject x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "LogicalChannelRateReject");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_currentMaximumBitRate", x->option_of_currentMaximumBitRate);
+    ShowPERInteger(tag, indent, "sequenceNumber", (int32)x->sequenceNumber);
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    Analyze_LogicalChannelRateRejectReason(&x->rejectReason, "rejectReason", tag, indent);
+    if (x->option_of_currentMaximumBitRate)
+    {
+        ShowPERInteger(tag, indent, "currentMaximumBitRate", (int32)x->currentMaximumBitRate);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "LogicalChannelRateReject");
+}
+
+/* <========================================================> */
+/*  PER-Analyzer for LogicalChannelRateRejectReason (CHOICE)  */
+/* <========================================================> */
+void Analyze_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "LogicalChannelRateRejectReason");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "undefinedReason");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "insufficientResources");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_LogicalChannelRateRejectReason: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "LogicalChannelRateRejectReason");
+}
+
+/* <=====================================================> */
+/*  PER-Analyzer for LogicalChannelRateRelease (SEQUENCE)  */
+/* <=====================================================> */
+void Analyze_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x, const char* label, uint16 tag, uint16 indent)
+{
+    OSCL_UNUSED_ARG(x);
+
+    ShowPERSequence(tag, indent, label, "LogicalChannelRateRelease");
+    indent += 2;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "LogicalChannelRateRelease");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for SendTerminalCapabilitySet (CHOICE)  */
+/* <===================================================> */
+void Analyze_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "SendTerminalCapabilitySet");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_SpecificRequest(x->specificRequest, "specificRequest", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "genericRequest");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_SendTerminalCapabilitySet: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "SendTerminalCapabilitySet");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for SpecificRequest (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_SpecificRequest(PS_SpecificRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    uint16 i;
+//  char tempLabelString[100];
+    ShowPERSequence(tag, indent, label, "SpecificRequest");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_capabilityTableEntryNumbers", x->option_of_capabilityTableEntryNumbers);
+    ShowPERBoolean(tag, indent, "option_of_capabilityDescriptorNumbers", x->option_of_capabilityDescriptorNumbers);
+    ShowPERBoolean(tag, indent, "multiplexCapability", x->multiplexCapability);
+    if (x->option_of_capabilityTableEntryNumbers)
+    {
+        ShowPERInteger(tag, indent, "size_of_capabilityTableEntryNumbers", (uint32)x->size_of_capabilityTableEntryNumbers);
+        for (i = 0;i < x->size_of_capabilityTableEntryNumbers;++i)
+        {
+            ShowPERIntegers(tag, indent, "capabilityTableEntryNumbers", (uint32)x->capabilityTableEntryNumbers[i], i);
+        }
+    }
+    if (x->option_of_capabilityDescriptorNumbers)
+    {
+        ShowPERInteger(tag, indent, "size_of_capabilityDescriptorNumbers", (uint32)x->size_of_capabilityDescriptorNumbers);
+        for (i = 0;i < x->size_of_capabilityDescriptorNumbers;++i)
+        {
+            ShowPERIntegers(tag, indent, "capabilityDescriptorNumbers", (uint32)x->capabilityDescriptorNumbers[i], i);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "SpecificRequest");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for EncryptionCommand (CHOICE)  */
+/* <===========================================> */
+void Analyze_EncryptionCommand(PS_EncryptionCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "EncryptionCommand");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPEROctetString(tag, indent, "encryptionSE", x->encryptionSE);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "encryptionIVRequest");
+            break;
+        case 2:
+            Analyze_EncryptionAlgorithmID(x->encryptionAlgorithmID, "encryptionAlgorithmID", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_EncryptionCommand: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "EncryptionCommand");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for EncryptionAlgorithmID (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "EncryptionAlgorithmID");
+    indent += 2;
+    ShowPERInteger(tag, indent, "h233AlgorithmIdentifier", (int32)x->h233AlgorithmIdentifier);
+    Analyze_NonStandardParameter(&x->associatedAlgorithm, "associatedAlgorithm", tag, indent);
+    ShowPERClosure(tag, indent, "EncryptionAlgorithmID");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for FlowControlCommand (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_FlowControlCommand(PS_FlowControlCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "FlowControlCommand");
+    indent += 2;
+    Analyze_FccScope(&x->fccScope, "fccScope", tag, indent);
+    Analyze_FccRestriction(&x->fccRestriction, "fccRestriction", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "FlowControlCommand");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for FccRestriction (CHOICE)  */
+/* <========================================> */
+void Analyze_FccRestriction(PS_FccRestriction x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "FccRestriction");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "maximumBitRate", (uint32)x->maximumBitRate);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "noRestriction");
+            break;
+        default:
+            ErrorMessage("Analyze_FccRestriction: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FccRestriction");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for FccScope (CHOICE)  */
+/* <==================================> */
+void Analyze_FccScope(PS_FccScope x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "FccScope");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "logicalChannelNumber", (uint32)x->logicalChannelNumber);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "resourceID", (uint32)x->resourceID);
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "wholeMultiplex");
+            break;
+        default:
+            ErrorMessage("Analyze_FccScope: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FccScope");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for EndSessionCommand (CHOICE)  */
+/* <===========================================> */
+void Analyze_EndSessionCommand(PS_EndSessionCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "EndSessionCommand");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "disconnect");
+            break;
+        case 2:
+            Analyze_GstnOptions(x->gstnOptions, "gstnOptions", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            Analyze_IsdnOptions(x->isdnOptions, "isdnOptions", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_EndSessionCommand: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "EndSessionCommand");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for IsdnOptions (CHOICE)  */
+/* <=====================================> */
+void Analyze_IsdnOptions(PS_IsdnOptions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IsdnOptions");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "telephonyMode");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "v140");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "terminalOnHold");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_IsdnOptions: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IsdnOptions");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for GstnOptions (CHOICE)  */
+/* <=====================================> */
+void Analyze_GstnOptions(PS_GstnOptions x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "GstnOptions");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "telephonyMode");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "v8bis");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "v34DSVD");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "v34DuplexFAX");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "v34H324");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_GstnOptions: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "GstnOptions");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for ConferenceCommand (CHOICE)  */
+/* <===========================================> */
+void Analyze_ConferenceCommand(PS_ConferenceCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ConferenceCommand");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "broadcastMyLogicalChannel", (uint32)x->broadcastMyLogicalChannel);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "cancelBroadcastMyLogicalChannel", (uint32)x->cancelBroadcastMyLogicalChannel);
+            break;
+        case 2:
+            Analyze_TerminalLabel(x->makeTerminalBroadcaster, "makeTerminalBroadcaster", tag, indent);
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "cancelMakeTerminalBroadcaster");
+            break;
+        case 4:
+            Analyze_TerminalLabel(x->sendThisSource, "sendThisSource", tag, indent);
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "cancelSendThisSource");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "dropConference");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            Analyze_SubstituteConferenceIDCommand(x->substituteConferenceIDCommand, "substituteConferenceIDCommand", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ConferenceCommand: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ConferenceCommand");
+}
+
+/* <=========================================================> */
+/*  PER-Analyzer for SubstituteConferenceIDCommand (SEQUENCE)  */
+/* <=========================================================> */
+void Analyze_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "SubstituteConferenceIDCommand");
+    indent += 2;
+    ShowPEROctetString(tag, indent, "conferenceIdentifier", &x->conferenceIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "SubstituteConferenceIDCommand");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for MiscellaneousCommand (SEQUENCE)  */
+/* <================================================> */
+void Analyze_MiscellaneousCommand(PS_MiscellaneousCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MiscellaneousCommand");
+    indent += 2;
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    Analyze_McType(&x->mcType, "mcType", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MiscellaneousCommand");
+}
+
+/* <================================> */
+/*  PER-Analyzer for McType (CHOICE)  */
+/* <================================> */
+void Analyze_McType(PS_McType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "McType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "equaliseDelay");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "zeroDelay");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "multipointModeCommand");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "cancelMultipointModeCommand");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "videoFreezePicture");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "videoFastUpdatePicture");
+            break;
+        case 6:
+            Analyze_VideoFastUpdateGOB(x->videoFastUpdateGOB, "videoFastUpdateGOB", tag, indent);
+            break;
+        case 7:
+            ShowPERInteger(tag, indent, "videoTemporalSpatialTradeOff", (uint32)x->videoTemporalSpatialTradeOff);
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "videoSendSyncEveryGOB");
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "videoSendSyncEveryGOBCancel");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Analyze_VideoFastUpdateMB(x->videoFastUpdateMB, "videoFastUpdateMB", tag, indent);
+            break;
+        case 11:
+            ShowPERInteger(tag, indent, "maxH223MUXPDUsize", (uint32)x->maxH223MUXPDUsize);
+            break;
+        case 12:
+            Analyze_EncryptionSync(x->encryptionUpdate, "encryptionUpdate", tag, indent);
+            break;
+        case 13:
+            Analyze_EncryptionUpdateRequest(x->encryptionUpdateRequest, "encryptionUpdateRequest", tag, indent);
+            break;
+        case 14:
+            ShowPERNull(tag, indent, "switchReceiveMediaOff");
+            break;
+        case 15:
+            ShowPERNull(tag, indent, "switchReceiveMediaOn");
+            break;
+        case 16:
+            Analyze_ProgressiveRefinementStart(x->progressiveRefinementStart, "progressiveRefinementStart", tag, indent);
+            break;
+        case 17:
+            ShowPERNull(tag, indent, "progressiveRefinementAbortOne");
+            break;
+        case 18:
+            ShowPERNull(tag, indent, "progressiveRefinementAbortContinuous");
+            break;
+        default:
+            ErrorMessage("Analyze_McType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "McType");
+}
+
+/* <======================================================> */
+/*  PER-Analyzer for ProgressiveRefinementStart (SEQUENCE)  */
+/* <======================================================> */
+void Analyze_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "ProgressiveRefinementStart");
+    indent += 2;
+    Analyze_PrsRepeatCount(&x->prsRepeatCount, "prsRepeatCount", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "ProgressiveRefinementStart");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for PrsRepeatCount (CHOICE)  */
+/* <========================================> */
+void Analyze_PrsRepeatCount(PS_PrsRepeatCount x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "PrsRepeatCount");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "doOneProgression");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "doContinuousProgressions");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "doOneIndependentProgression");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "doContinuousIndependentProgressions");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_PrsRepeatCount: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "PrsRepeatCount");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for VideoFastUpdateMB (SEQUENCE)  */
+/* <=============================================> */
+void Analyze_VideoFastUpdateMB(PS_VideoFastUpdateMB x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VideoFastUpdateMB");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_firstGOB", x->option_of_firstGOB);
+    ShowPERBoolean(tag, indent, "option_of_firstMB", x->option_of_firstMB);
+    if (x->option_of_firstGOB)
+    {
+        ShowPERInteger(tag, indent, "firstGOB", (int32)x->firstGOB);
+    }
+    if (x->option_of_firstMB)
+    {
+        ShowPERInteger(tag, indent, "firstMB", (int32)x->firstMB);
+    }
+    ShowPERInteger(tag, indent, "numberOfMBs", (int32)x->numberOfMBs);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "VideoFastUpdateMB");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for VideoFastUpdateGOB (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VideoFastUpdateGOB");
+    indent += 2;
+    ShowPERInteger(tag, indent, "firstGOB", (int32)x->firstGOB);
+    ShowPERInteger(tag, indent, "numberOfGOBs", (int32)x->numberOfGOBs);
+    ShowPERClosure(tag, indent, "VideoFastUpdateGOB");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for KeyProtectionMethod (SEQUENCE)  */
+/* <===============================================> */
+void Analyze_KeyProtectionMethod(PS_KeyProtectionMethod x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "KeyProtectionMethod");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "secureChannel", x->secureChannel);
+    ShowPERBoolean(tag, indent, "sharedSecret", x->sharedSecret);
+    ShowPERBoolean(tag, indent, "certProtectedKey", x->certProtectedKey);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "KeyProtectionMethod");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for EncryptionUpdateRequest (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "EncryptionUpdateRequest");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_keyProtectionMethod", x->option_of_keyProtectionMethod);
+    if (x->option_of_keyProtectionMethod)
+    {
+        Analyze_KeyProtectionMethod(&x->keyProtectionMethod, "keyProtectionMethod", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "EncryptionUpdateRequest");
+}
+
+/* <======================================================> */
+/*  PER-Analyzer for H223MultiplexReconfiguration (CHOICE)  */
+/* <======================================================> */
+void Analyze_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "H223MultiplexReconfiguration");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_H223ModeChange(x->h223ModeChange, "h223ModeChange", tag, indent);
+            break;
+        case 1:
+            Analyze_H223AnnexADoubleFlag(x->h223AnnexADoubleFlag, "h223AnnexADoubleFlag", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_H223MultiplexReconfiguration: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "H223MultiplexReconfiguration");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H223AnnexADoubleFlag (CHOICE)  */
+/* <==============================================> */
+void Analyze_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "H223AnnexADoubleFlag");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "start");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "stop");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_H223AnnexADoubleFlag: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "H223AnnexADoubleFlag");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for H223ModeChange (CHOICE)  */
+/* <========================================> */
+void Analyze_H223ModeChange(PS_H223ModeChange x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "H223ModeChange");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "toLevel0");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "toLevel1");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "toLevel2");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "toLevel2withOptionalHeader");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_H223ModeChange: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "H223ModeChange");
+}
+
+/* <===========================================> */
+/*  PER-Analyzer for NewATMVCCommand (SEQUENCE)  */
+/* <===========================================> */
+void Analyze_NewATMVCCommand(PS_NewATMVCCommand x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "NewATMVCCommand");
+    indent += 2;
+    ShowPERInteger(tag, indent, "resourceID", (int32)x->resourceID);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    ShowPERBoolean(tag, indent, "bitRateLockedToPCRClock", x->bitRateLockedToPCRClock);
+    ShowPERBoolean(tag, indent, "bitRateLockedToNetworkClock", x->bitRateLockedToNetworkClock);
+    Analyze_CmdAal(&x->cmdAal, "cmdAal", tag, indent);
+    Analyze_CmdMultiplex(&x->cmdMultiplex, "cmdMultiplex", tag, indent);
+    Analyze_CmdReverseParameters(&x->cmdReverseParameters, "cmdReverseParameters", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "NewATMVCCommand");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for CmdReverseParameters (SEQUENCE)  */
+/* <================================================> */
+void Analyze_CmdReverseParameters(PS_CmdReverseParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CmdReverseParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    ShowPERBoolean(tag, indent, "bitRateLockedToPCRClock", x->bitRateLockedToPCRClock);
+    ShowPERBoolean(tag, indent, "bitRateLockedToNetworkClock", x->bitRateLockedToNetworkClock);
+    Analyze_Multiplex(&x->multiplex, "multiplex", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CmdReverseParameters");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for Multiplex (CHOICE)  */
+/* <===================================> */
+void Analyze_Multiplex(PS_Multiplex x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "Multiplex");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noMultiplex");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "transportStream");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "programStream");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_Multiplex: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "Multiplex");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for CmdMultiplex (CHOICE)  */
+/* <======================================> */
+void Analyze_CmdMultiplex(PS_CmdMultiplex x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CmdMultiplex");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noMultiplex");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "transportStream");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "programStream");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CmdMultiplex: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CmdMultiplex");
+}
+
+/* <================================> */
+/*  PER-Analyzer for CmdAal (CHOICE)  */
+/* <================================> */
+void Analyze_CmdAal(PS_CmdAal x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CmdAal");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_CmdAal1(x->cmdAal1, "cmdAal1", tag, indent);
+            break;
+        case 1:
+            Analyze_CmdAal5(x->cmdAal5, "cmdAal5", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CmdAal: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CmdAal");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for CmdAal5 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_CmdAal5(PS_CmdAal5 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CmdAal5");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardMaximumSDUSize", (int32)x->forwardMaximumSDUSize);
+    ShowPERInteger(tag, indent, "backwardMaximumSDUSize", (int32)x->backwardMaximumSDUSize);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CmdAal5");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for CmdAal1 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_CmdAal1(PS_CmdAal1 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "CmdAal1");
+    indent += 2;
+    Analyze_CmdClockRecovery(&x->cmdClockRecovery, "cmdClockRecovery", tag, indent);
+    Analyze_CmdErrorCorrection(&x->cmdErrorCorrection, "cmdErrorCorrection", tag, indent);
+    ShowPERBoolean(tag, indent, "structuredDataTransfer", x->structuredDataTransfer);
+    ShowPERBoolean(tag, indent, "partiallyFilledCells", x->partiallyFilledCells);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "CmdAal1");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for CmdErrorCorrection (CHOICE)  */
+/* <============================================> */
+void Analyze_CmdErrorCorrection(PS_CmdErrorCorrection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CmdErrorCorrection");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "nullErrorCorrection");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "longInterleaver");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "shortInterleaver");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "errorCorrectionOnly");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CmdErrorCorrection: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CmdErrorCorrection");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for CmdClockRecovery (CHOICE)  */
+/* <==========================================> */
+void Analyze_CmdClockRecovery(PS_CmdClockRecovery x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "CmdClockRecovery");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "nullClockRecovery");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "srtsClockRecovery");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "adaptiveClockRecovery");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_CmdClockRecovery: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "CmdClockRecovery");
+}
+
+/* <===============================================> */
+/*  PER-Analyzer for FunctionNotUnderstood (CHOICE)  */
+/* <===============================================> */
+void Analyze_FunctionNotUnderstood(PS_FunctionNotUnderstood x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "FunctionNotUnderstood");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_RequestMessage(x->request, "request", tag, indent);
+            break;
+        case 1:
+            Analyze_ResponseMessage(x->response, "response", tag, indent);
+            break;
+        case 2:
+            Analyze_CommandMessage(x->command, "command", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_FunctionNotUnderstood: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FunctionNotUnderstood");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for FunctionNotSupported (SEQUENCE)  */
+/* <================================================> */
+void Analyze_FunctionNotSupported(PS_FunctionNotSupported x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "FunctionNotSupported");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_returnedFunction", x->option_of_returnedFunction);
+    Analyze_FnsCause(&x->fnsCause, "fnsCause", tag, indent);
+    if (x->option_of_returnedFunction)
+    {
+        ShowPEROctetString(tag, indent, "returnedFunction", &x->returnedFunction);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "FunctionNotSupported");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for FnsCause (CHOICE)  */
+/* <==================================> */
+void Analyze_FnsCause(PS_FnsCause x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "FnsCause");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "syntaxError");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "semanticError");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "unknownFunction");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_FnsCause: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FnsCause");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for ConferenceIndication (CHOICE)  */
+/* <==============================================> */
+void Analyze_ConferenceIndication(PS_ConferenceIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "ConferenceIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "sbeNumber", (uint32)x->sbeNumber);
+            break;
+        case 1:
+            Analyze_TerminalLabel(x->terminalNumberAssign, "terminalNumberAssign", tag, indent);
+            break;
+        case 2:
+            Analyze_TerminalLabel(x->terminalJoinedConference, "terminalJoinedConference", tag, indent);
+            break;
+        case 3:
+            Analyze_TerminalLabel(x->terminalLeftConference, "terminalLeftConference", tag, indent);
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "seenByAtLeastOneOther");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "cancelSeenByAtLeastOneOther");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "seenByAll");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "cancelSeenByAll");
+            break;
+        case 8:
+            Analyze_TerminalLabel(x->terminalYouAreSeeing, "terminalYouAreSeeing", tag, indent);
+            break;
+        case 9:
+            ShowPERNull(tag, indent, "requestForFloor");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            ShowPERNull(tag, indent, "withdrawChairToken");
+            break;
+        case 11:
+            Analyze_TerminalLabel(x->floorRequested, "floorRequested", tag, indent);
+            break;
+        case 12:
+            Analyze_TerminalYouAreSeeingInSubPictureNumber(x->terminalYouAreSeeingInSubPictureNumber, "terminalYouAreSeeingInSubPictureNumber", tag, indent);
+            break;
+        case 13:
+            Analyze_VideoIndicateCompose(x->videoIndicateCompose, "videoIndicateCompose", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_ConferenceIndication: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "ConferenceIndication");
+}
+
+/* <==================================================================> */
+/*  PER-Analyzer for TerminalYouAreSeeingInSubPictureNumber (SEQUENCE)  */
+/* <==================================================================> */
+void Analyze_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "TerminalYouAreSeeingInSubPictureNumber");
+    indent += 2;
+    ShowPERInteger(tag, indent, "terminalNumber", (int32)x->terminalNumber);
+    ShowPERInteger(tag, indent, "subPictureNumber", (int32)x->subPictureNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "TerminalYouAreSeeingInSubPictureNumber");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for VideoIndicateCompose (SEQUENCE)  */
+/* <================================================> */
+void Analyze_VideoIndicateCompose(PS_VideoIndicateCompose x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VideoIndicateCompose");
+    indent += 2;
+    ShowPERInteger(tag, indent, "compositionNumber", (int32)x->compositionNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "VideoIndicateCompose");
+}
+
+/* <===================================================> */
+/*  PER-Analyzer for MiscellaneousIndication (SEQUENCE)  */
+/* <===================================================> */
+void Analyze_MiscellaneousIndication(PS_MiscellaneousIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MiscellaneousIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    Analyze_MiType(&x->miType, "miType", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MiscellaneousIndication");
+}
+
+/* <================================> */
+/*  PER-Analyzer for MiType (CHOICE)  */
+/* <================================> */
+void Analyze_MiType(PS_MiType x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "MiType");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "logicalChannelActive");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "logicalChannelInactive");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "multipointConference");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "cancelMultipointConference");
+            break;
+        case 4:
+            ShowPERNull(tag, indent, "multipointZeroComm");
+            break;
+        case 5:
+            ShowPERNull(tag, indent, "cancelMultipointZeroComm");
+            break;
+        case 6:
+            ShowPERNull(tag, indent, "multipointSecondaryStatus");
+            break;
+        case 7:
+            ShowPERNull(tag, indent, "cancelMultipointSecondaryStatus");
+            break;
+        case 8:
+            ShowPERNull(tag, indent, "videoIndicateReadyToActivate");
+            break;
+        case 9:
+            ShowPERInteger(tag, indent, "videoTemporalSpatialTradeOff", (uint32)x->videoTemporalSpatialTradeOff);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Analyze_VideoNotDecodedMBs(x->videoNotDecodedMBs, "videoNotDecodedMBs", tag, indent);
+            break;
+        case 11:
+            Analyze_TransportCapability(x->transportCapability, "transportCapability", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_MiType: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "MiType");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for VideoNotDecodedMBs (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VideoNotDecodedMBs");
+    indent += 2;
+    ShowPERInteger(tag, indent, "firstMB", (int32)x->firstMB);
+    ShowPERInteger(tag, indent, "numberOfMBs", (int32)x->numberOfMBs);
+    ShowPERInteger(tag, indent, "temporalReference", (int32)x->temporalReference);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "VideoNotDecodedMBs");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for JitterIndication (SEQUENCE)  */
+/* <============================================> */
+void Analyze_JitterIndication(PS_JitterIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "JitterIndication");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_skippedFrameCount", x->option_of_skippedFrameCount);
+    ShowPERBoolean(tag, indent, "option_of_additionalDecoderBuffer", x->option_of_additionalDecoderBuffer);
+    Analyze_JiScope(&x->jiScope, "jiScope", tag, indent);
+    ShowPERInteger(tag, indent, "estimatedReceivedJitterMantissa", (int32)x->estimatedReceivedJitterMantissa);
+    ShowPERInteger(tag, indent, "estimatedReceivedJitterExponent", (int32)x->estimatedReceivedJitterExponent);
+    if (x->option_of_skippedFrameCount)
+    {
+        ShowPERInteger(tag, indent, "skippedFrameCount", (int32)x->skippedFrameCount);
+    }
+    if (x->option_of_additionalDecoderBuffer)
+    {
+        ShowPERInteger(tag, indent, "additionalDecoderBuffer", (int32)x->additionalDecoderBuffer);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "JitterIndication");
+}
+
+/* <=================================> */
+/*  PER-Analyzer for JiScope (CHOICE)  */
+/* <=================================> */
+void Analyze_JiScope(PS_JiScope x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "JiScope");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "logicalChannelNumber", (uint32)x->logicalChannelNumber);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "resourceID", (uint32)x->resourceID);
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "wholeMultiplex");
+            break;
+        default:
+            ErrorMessage("Analyze_JiScope: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "JiScope");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for H223SkewIndication (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_H223SkewIndication(PS_H223SkewIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H223SkewIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "logicalChannelNumber1", (int32)x->logicalChannelNumber1);
+    ShowPERInteger(tag, indent, "logicalChannelNumber2", (int32)x->logicalChannelNumber2);
+    ShowPERInteger(tag, indent, "skew", (int32)x->skew);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H223SkewIndication");
+}
+
+/* <======================================================> */
+/*  PER-Analyzer for H2250MaximumSkewIndication (SEQUENCE)  */
+/* <======================================================> */
+void Analyze_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "H2250MaximumSkewIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "logicalChannelNumber1", (int32)x->logicalChannelNumber1);
+    ShowPERInteger(tag, indent, "logicalChannelNumber2", (int32)x->logicalChannelNumber2);
+    ShowPERInteger(tag, indent, "maximumSkew", (int32)x->maximumSkew);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "H2250MaximumSkewIndication");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for MCLocationIndication (SEQUENCE)  */
+/* <================================================> */
+void Analyze_MCLocationIndication(PS_MCLocationIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "MCLocationIndication");
+    indent += 2;
+    Analyze_TransportAddress(&x->signalAddress, "signalAddress", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "MCLocationIndication");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for VendorIdentification (SEQUENCE)  */
+/* <================================================> */
+void Analyze_VendorIdentification(PS_VendorIdentification x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "VendorIdentification");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_productNumber", x->option_of_productNumber);
+    ShowPERBoolean(tag, indent, "option_of_versionNumber", x->option_of_versionNumber);
+    Analyze_NonStandardIdentifier(&x->vendor, "vendor", tag, indent);
+    if (x->option_of_productNumber)
+    {
+        ShowPEROctetString(tag, indent, "productNumber", &x->productNumber);
+    }
+    if (x->option_of_versionNumber)
+    {
+        ShowPEROctetString(tag, indent, "versionNumber", &x->versionNumber);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "VendorIdentification");
+}
+
+/* <==============================================> */
+/*  PER-Analyzer for NewATMVCIndication (SEQUENCE)  */
+/* <==============================================> */
+void Analyze_NewATMVCIndication(PS_NewATMVCIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "NewATMVCIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "resourceID", (int32)x->resourceID);
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    ShowPERBoolean(tag, indent, "bitRateLockedToPCRClock", x->bitRateLockedToPCRClock);
+    ShowPERBoolean(tag, indent, "bitRateLockedToNetworkClock", x->bitRateLockedToNetworkClock);
+    Analyze_IndAal(&x->indAal, "indAal", tag, indent);
+    Analyze_IndMultiplex(&x->indMultiplex, "indMultiplex", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERBoolean(tag, indent, "option_of_indReverseParameters", x->option_of_indReverseParameters);
+    if (x->option_of_indReverseParameters)
+    {
+        Analyze_IndReverseParameters(&x->indReverseParameters, "indReverseParameters", tag, indent);
+    }
+    ShowPERClosure(tag, indent, "NewATMVCIndication");
+}
+
+/* <================================================> */
+/*  PER-Analyzer for IndReverseParameters (SEQUENCE)  */
+/* <================================================> */
+void Analyze_IndReverseParameters(PS_IndReverseParameters x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IndReverseParameters");
+    indent += 2;
+    ShowPERInteger(tag, indent, "bitRate", (int32)x->bitRate);
+    ShowPERBoolean(tag, indent, "bitRateLockedToPCRClock", x->bitRateLockedToPCRClock);
+    ShowPERBoolean(tag, indent, "bitRateLockedToNetworkClock", x->bitRateLockedToNetworkClock);
+    Analyze_IrpMultiplex(&x->irpMultiplex, "irpMultiplex", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IndReverseParameters");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for IrpMultiplex (CHOICE)  */
+/* <======================================> */
+void Analyze_IrpMultiplex(PS_IrpMultiplex x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IrpMultiplex");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noMultiplex");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "transportStream");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "programStream");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_IrpMultiplex: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IrpMultiplex");
+}
+
+/* <======================================> */
+/*  PER-Analyzer for IndMultiplex (CHOICE)  */
+/* <======================================> */
+void Analyze_IndMultiplex(PS_IndMultiplex x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IndMultiplex");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "noMultiplex");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "transportStream");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "programStream");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_IndMultiplex: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IndMultiplex");
+}
+
+/* <================================> */
+/*  PER-Analyzer for IndAal (CHOICE)  */
+/* <================================> */
+void Analyze_IndAal(PS_IndAal x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IndAal");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_IndAal1(x->indAal1, "indAal1", tag, indent);
+            break;
+        case 1:
+            Analyze_IndAal5(x->indAal5, "indAal5", tag, indent);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_IndAal: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IndAal");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for IndAal5 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_IndAal5(PS_IndAal5 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IndAal5");
+    indent += 2;
+    ShowPERInteger(tag, indent, "forwardMaximumSDUSize", (int32)x->forwardMaximumSDUSize);
+    ShowPERInteger(tag, indent, "backwardMaximumSDUSize", (int32)x->backwardMaximumSDUSize);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IndAal5");
+}
+
+/* <===================================> */
+/*  PER-Analyzer for IndAal1 (SEQUENCE)  */
+/* <===================================> */
+void Analyze_IndAal1(PS_IndAal1 x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "IndAal1");
+    indent += 2;
+    Analyze_IndClockRecovery(&x->indClockRecovery, "indClockRecovery", tag, indent);
+    Analyze_IndErrorCorrection(&x->indErrorCorrection, "indErrorCorrection", tag, indent);
+    ShowPERBoolean(tag, indent, "structuredDataTransfer", x->structuredDataTransfer);
+    ShowPERBoolean(tag, indent, "partiallyFilledCells", x->partiallyFilledCells);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "IndAal1");
+}
+
+/* <============================================> */
+/*  PER-Analyzer for IndErrorCorrection (CHOICE)  */
+/* <============================================> */
+void Analyze_IndErrorCorrection(PS_IndErrorCorrection x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IndErrorCorrection");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "nullErrorCorrection");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "longInterleaver");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "shortInterleaver");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "errorCorrectionOnly");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_IndErrorCorrection: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IndErrorCorrection");
+}
+
+/* <==========================================> */
+/*  PER-Analyzer for IndClockRecovery (CHOICE)  */
+/* <==========================================> */
+void Analyze_IndClockRecovery(PS_IndClockRecovery x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "IndClockRecovery");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERNull(tag, indent, "nullClockRecovery");
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "srtsClockRecovery");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "adaptiveClockRecovery");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_IndClockRecovery: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "IndClockRecovery");
+}
+
+/* <=============================================> */
+/*  PER-Analyzer for UserInputIndication (CHOICE)  */
+/* <=============================================> */
+void Analyze_UserInputIndication(PS_UserInputIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "UserInputIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERCharString(tag, indent, "alphanumeric", x->alphanumeric);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            Analyze_UserInputSupportIndication(x->userInputSupportIndication, "userInputSupportIndication", tag, indent);
+            break;
+        case 3:
+            Analyze_Signal(x->signal, "signal", tag, indent);
+            break;
+        case 4:
+            Analyze_SignalUpdate(x->signalUpdate, "signalUpdate", tag, indent);
+            break;
+        default:
+            ErrorMessage("Analyze_UserInputIndication: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "UserInputIndication");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for SignalUpdate (SEQUENCE)  */
+/* <========================================> */
+void Analyze_SignalUpdate(PS_SignalUpdate x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "SignalUpdate");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_rtp", x->option_of_rtp);
+    ShowPERInteger(tag, indent, "duration", (int32)x->duration);
+    if (x->option_of_rtp)
+    {
+        Analyze_Rtp(&x->rtp, "rtp", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "SignalUpdate");
+}
+
+/* <===============================> */
+/*  PER-Analyzer for Rtp (SEQUENCE)  */
+/* <===============================> */
+void Analyze_Rtp(PS_Rtp x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Rtp");
+    indent += 2;
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Rtp");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for Signal (SEQUENCE)  */
+/* <==================================> */
+void Analyze_Signal(PS_Signal x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "Signal");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_duration", x->option_of_duration);
+    ShowPERBoolean(tag, indent, "option_of_signalRtp", x->option_of_signalRtp);
+    ShowPERCharString(tag, indent, "signalType", &x->signalType);
+    if (x->option_of_duration)
+    {
+        ShowPERInteger(tag, indent, "duration", (int32)x->duration);
+    }
+    if (x->option_of_signalRtp)
+    {
+        Analyze_SignalRtp(&x->signalRtp, "signalRtp", tag, indent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "Signal");
+}
+
+/* <=====================================> */
+/*  PER-Analyzer for SignalRtp (SEQUENCE)  */
+/* <=====================================> */
+void Analyze_SignalRtp(PS_SignalRtp x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "SignalRtp");
+    indent += 2;
+    ShowPERBoolean(tag, indent, "option_of_timestamp", x->option_of_timestamp);
+    ShowPERBoolean(tag, indent, "option_of_expirationTime", x->option_of_expirationTime);
+    if (x->option_of_timestamp)
+    {
+        ShowPERInteger(tag, indent, "timestamp", (int32)x->timestamp);
+    }
+    if (x->option_of_expirationTime)
+    {
+        ShowPERInteger(tag, indent, "expirationTime", (int32)x->expirationTime);
+    }
+    ShowPERInteger(tag, indent, "logicalChannelNumber", (int32)x->logicalChannelNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "SignalRtp");
+}
+
+/* <====================================================> */
+/*  PER-Analyzer for UserInputSupportIndication (CHOICE)  */
+/* <====================================================> */
+void Analyze_UserInputSupportIndication(PS_UserInputSupportIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "UserInputSupportIndication");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            Analyze_NonStandardParameter(x->nonStandard, "nonStandard", tag, indent);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "basicString");
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "iA5String");
+            break;
+        case 3:
+            ShowPERNull(tag, indent, "generalString");
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Analyze_UserInputSupportIndication: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "UserInputSupportIndication");
+}
+
+/* <=================================================> */
+/*  PER-Analyzer for FlowControlIndication (SEQUENCE)  */
+/* <=================================================> */
+void Analyze_FlowControlIndication(PS_FlowControlIndication x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERSequence(tag, indent, label, "FlowControlIndication");
+    indent += 2;
+    Analyze_FciScope(&x->fciScope, "fciScope", tag, indent);
+    Analyze_FciRestriction(&x->fciRestriction, "fciRestriction", tag, indent);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    ShowPERClosure(tag, indent, "FlowControlIndication");
+}
+
+/* <========================================> */
+/*  PER-Analyzer for FciRestriction (CHOICE)  */
+/* <========================================> */
+void Analyze_FciRestriction(PS_FciRestriction x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "FciRestriction");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "maximumBitRate", (uint32)x->maximumBitRate);
+            break;
+        case 1:
+            ShowPERNull(tag, indent, "noRestriction");
+            break;
+        default:
+            ErrorMessage("Analyze_FciRestriction: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FciRestriction");
+}
+
+/* <==================================> */
+/*  PER-Analyzer for FciScope (CHOICE)  */
+/* <==================================> */
+void Analyze_FciScope(PS_FciScope x, const char* label, uint16 tag, uint16 indent)
+{
+    ShowPERChoice(tag, indent, label, "FciScope");
+    indent += 2;
+    ShowPERInteger(tag, indent, "index", x->index);
+    switch (x->index)
+    {
+        case 0:
+            ShowPERInteger(tag, indent, "logicalChannelNumber", (uint32)x->logicalChannelNumber);
+            break;
+        case 1:
+            ShowPERInteger(tag, indent, "resourceID", (uint32)x->resourceID);
+            break;
+        case 2:
+            ShowPERNull(tag, indent, "wholeMultiplex");
+            break;
+        default:
+            ErrorMessage("Analyze_FciScope: Illegal CHOICE index");
+    }
+    ShowPERClosure(tag, indent, "FciScope");
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_copier.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_copier.cpp
new file mode 100644
index 0000000..61ef895
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_copier.cpp
@@ -0,0 +1,221 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_copier.c
+//
+// DESC: PER Copy routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+// ========================================================
+//           D E E P   C O P Y   R O U T I N E S
+// ========================================================
+// ****************************************************
+// ** NOTE: This file is not auto-generated.         **
+// ** Add copy routines as needed in the application **
+// ****************************************************
+
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "per_headers.h"
+#include "h245def.h"
+#include "h245_encoder.h"
+#include "h245_decoder.h"
+#include "h245_copier.h"
+
+//-------------------------------------------------------------
+// Copy_DataType()
+//
+// Generic copy routine for an H.245 DataType.
+//-------------------------------------------------------------
+OSCL_EXPORT_REF PS_DataType
+Copy_DataType(PS_DataType x)
+{
+    PS_OutStream outstream;
+    PS_InStream  instream;
+    PS_DataType y;
+    uint8 *data_origin;
+
+    /* Encode original (x) to Outstream */
+    outstream = NewOutStream();
+    Encode_DataType(x, outstream);
+
+    /* Decode copy (y) from Instream */
+    instream = ConvertOutstreamToInstream(outstream);
+    data_origin = instream->data;  // Save the origin for later OSCL_DEFAULT_FREE
+    y = (PS_DataType) OSCL_DEFAULT_MALLOC(sizeof(S_DataType));
+    Decode_DataType(y, instream);
+
+    /* Free the bitstream */
+    OSCL_DEFAULT_FREE(data_origin);
+    OSCL_DEFAULT_FREE(instream);
+
+    /* Return copy */
+    return(y);
+}
+
+//-------------------------------------------------------------
+// Copy_H223LogicalChannelParameters()
+//
+// Generic copy routine for an H.245 H223LogicalChannelParameters.
+//-------------------------------------------------------------
+OSCL_EXPORT_REF PS_H223LogicalChannelParameters
+Copy_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x)
+{
+    PS_OutStream outstream;
+    PS_InStream  instream;
+    PS_H223LogicalChannelParameters y;
+    uint8 *data_origin;
+
+    /* Encode original (x) to Outstream */
+    outstream = NewOutStream();
+    Encode_H223LogicalChannelParameters(x, outstream);
+
+    /* Decode copy (y) from Instream */
+    instream = ConvertOutstreamToInstream(outstream);
+    data_origin = instream->data;  // Save the origin for later OSCL_DEFAULT_FREE
+    y = (PS_H223LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223LogicalChannelParameters));
+    Decode_H223LogicalChannelParameters(y, instream);
+
+    /* Free the bitstream */
+    OSCL_DEFAULT_FREE(data_origin);
+    OSCL_DEFAULT_FREE(instream);
+
+    /* Return copy */
+    return(y);
+}
+
+//-------------------------------------------------------------
+// Copy_MultiplexEntryDescriptor()
+//
+// Generic copy routine for an H.245 MultiplexEntryDescriptor.
+//-------------------------------------------------------------
+PS_MultiplexEntryDescriptor
+Copy_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x)
+{
+    PS_OutStream outstream;
+    PS_InStream  instream;
+    PS_MultiplexEntryDescriptor y;
+    uint8 *data_origin;
+
+    /* Encode original (x) to Outstream */
+    outstream = NewOutStream();
+    Encode_MultiplexEntryDescriptor(x, outstream);
+
+    /* Decode copy (y) from Instream */
+    instream = ConvertOutstreamToInstream(outstream);
+    data_origin = instream->data;  // Save the origin for later OSCL_DEFAULT_FREE
+    y = (PS_MultiplexEntryDescriptor) OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntryDescriptor));
+    Decode_MultiplexEntryDescriptor(y, instream);
+
+    /* Free the bitstream */
+    OSCL_DEFAULT_FREE(data_origin);
+    OSCL_DEFAULT_FREE(instream);
+
+    /* Return copy */
+    return(y);
+}
+
+//-------------------------------------------------------------
+// Copy_ForwardLogicalChannelParameters()
+//
+// Generic copy routine for an H.245 ForwardLogicalChannelParameters.
+//-------------------------------------------------------------
+PS_ForwardLogicalChannelParameters
+Copy_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x)
+{
+    PS_OutStream outstream;
+    PS_InStream  instream;
+    PS_ForwardLogicalChannelParameters y;
+    uint8 *data_origin;
+
+    /* Encode original (x) to Outstream */
+    outstream = NewOutStream();
+    Encode_ForwardLogicalChannelParameters(x, outstream);
+
+    /* Decode copy (y) from Instream */
+    instream = ConvertOutstreamToInstream(outstream);
+    data_origin = instream->data;  // Save the origin for later OSCL_DEFAULT_FREE
+    y = (PS_ForwardLogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_ForwardLogicalChannelParameters));
+    Decode_ForwardLogicalChannelParameters(y, instream);
+
+    /* Free the bitstream */
+    OSCL_DEFAULT_FREE(data_origin);
+    OSCL_DEFAULT_FREE(instream);
+
+    /* Return copy */
+    return(y);
+}
+
+//-------------------------------------------------------------
+// Copy_ReverseLogicalChannelParameters()
+//
+// Generic copy routine for an H.245 ReverseLogicalChannelParameters.
+//-------------------------------------------------------------
+PS_ReverseLogicalChannelParameters
+Copy_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x)
+{
+    PS_OutStream outstream;
+    PS_InStream  instream;
+    PS_ReverseLogicalChannelParameters y;
+    uint8 *data_origin;
+
+    /* Encode original (x) to Outstream */
+    outstream = NewOutStream();
+    Encode_ReverseLogicalChannelParameters(x, outstream);
+
+    /* Decode copy (y) from Instream */
+    instream = ConvertOutstreamToInstream(outstream);
+    data_origin = instream->data;  // Save the origin for later OSCL_DEFAULT_FREE
+    y = (PS_ReverseLogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_ReverseLogicalChannelParameters));
+    Decode_ReverseLogicalChannelParameters(y, instream);
+
+    /* Free the bitstream */
+    OSCL_DEFAULT_FREE(data_origin);
+    OSCL_DEFAULT_FREE(instream);
+
+    /* Return copy */
+    return(y);
+}
+
+PS_TerminalCapabilitySet Copy_TerminalCapabilitySet(PS_TerminalCapabilitySet x)
+{
+    PS_OutStream outstream;
+    PS_InStream  instream;
+    PS_TerminalCapabilitySet y;
+    uint8 *data_origin;
+
+    /* Encode original (x) to Outstream */
+    outstream = NewOutStream();
+    Encode_TerminalCapabilitySet(x, outstream);
+
+    /* Decode copy (y) from Instream */
+    instream = ConvertOutstreamToInstream(outstream);
+    data_origin = instream->data;  // Save the origin for later OSCL_DEFAULT_FREE
+    y = (PS_TerminalCapabilitySet) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySet));
+    Decode_TerminalCapabilitySet(y, instream);
+
+    /* Free the bitstream */
+    OSCL_DEFAULT_FREE(data_origin);
+    OSCL_DEFAULT_FREE(instream);
+
+    /* Return copy */
+    return(y);
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_decoder.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_decoder.cpp
new file mode 100644
index 0000000..e724473
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_decoder.cpp
@@ -0,0 +1,12249 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_decoder.c
+//
+// DESC: PER Decode routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "per_headers.h"
+#include "h245def.h"
+#include "h245_decoder.h"
+
+/* <=======================================================> */
+/*  PER-Decoder for MultimediaSystemControlMessage (CHOICE)  */
+/* <=======================================================> */
+void Decode_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->request = (PS_RequestMessage) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMessage));
+            Decode_RequestMessage(x->request, stream);
+            break;
+        case 1:
+            x->response = (PS_ResponseMessage) OSCL_DEFAULT_MALLOC(sizeof(S_ResponseMessage));
+            Decode_ResponseMessage(x->response, stream);
+            break;
+        case 2:
+            x->command = (PS_CommandMessage) OSCL_DEFAULT_MALLOC(sizeof(S_CommandMessage));
+            Decode_CommandMessage(x->command, stream);
+            break;
+        case 3:
+            x->indication = (PS_IndicationMessage) OSCL_DEFAULT_MALLOC(sizeof(S_IndicationMessage));
+            Decode_IndicationMessage(x->indication, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MultimediaSystemControlMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for RequestMessage (CHOICE)  */
+/* <=======================================> */
+void Decode_RequestMessage(PS_RequestMessage x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(11, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->masterSlaveDetermination = (PS_MasterSlaveDetermination) OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDetermination));
+            Decode_MasterSlaveDetermination(x->masterSlaveDetermination, stream);
+            break;
+        case 2:
+            x->terminalCapabilitySet = (PS_TerminalCapabilitySet) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySet));
+            Decode_TerminalCapabilitySet(x->terminalCapabilitySet, stream);
+            break;
+        case 3:
+            x->openLogicalChannel = (PS_OpenLogicalChannel) OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannel));
+            Decode_OpenLogicalChannel(x->openLogicalChannel, stream);
+            break;
+        case 4:
+            x->closeLogicalChannel = (PS_CloseLogicalChannel) OSCL_DEFAULT_MALLOC(sizeof(S_CloseLogicalChannel));
+            Decode_CloseLogicalChannel(x->closeLogicalChannel, stream);
+            break;
+        case 5:
+            x->requestChannelClose = (PS_RequestChannelClose) OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelClose));
+            Decode_RequestChannelClose(x->requestChannelClose, stream);
+            break;
+        case 6:
+            x->multiplexEntrySend = (PS_MultiplexEntrySend) OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySend));
+            Decode_MultiplexEntrySend(x->multiplexEntrySend, stream);
+            break;
+        case 7:
+            x->requestMultiplexEntry = (PS_RequestMultiplexEntry) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntry));
+            Decode_RequestMultiplexEntry(x->requestMultiplexEntry, stream);
+            break;
+        case 8:
+            x->requestMode = (PS_RequestMode) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMode));
+            Decode_RequestMode(x->requestMode, stream);
+            break;
+        case 9:
+            x->roundTripDelayRequest = (PS_RoundTripDelayRequest) OSCL_DEFAULT_MALLOC(sizeof(S_RoundTripDelayRequest));
+            Decode_RoundTripDelayRequest(x->roundTripDelayRequest, stream);
+            break;
+        case 10:
+            x->maintenanceLoopRequest = (PS_MaintenanceLoopRequest) OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopRequest));
+            Decode_MaintenanceLoopRequest(x->maintenanceLoopRequest, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            GetLengthDet(stream);
+            x->communicationModeRequest = (PS_CommunicationModeRequest) OSCL_DEFAULT_MALLOC(sizeof(S_CommunicationModeRequest));
+            Decode_CommunicationModeRequest(x->communicationModeRequest, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->conferenceRequest = (PS_ConferenceRequest) OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceRequest));
+            Decode_ConferenceRequest(x->conferenceRequest, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->multilinkRequest = (PS_MultilinkRequest) OSCL_DEFAULT_MALLOC(sizeof(S_MultilinkRequest));
+            Decode_MultilinkRequest(x->multilinkRequest, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 14:
+            GetLengthDet(stream);
+            x->logicalChannelRateRequest = (PS_LogicalChannelRateRequest) OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateRequest));
+            Decode_LogicalChannelRateRequest(x->logicalChannelRateRequest, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_RequestMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for ResponseMessage (CHOICE)  */
+/* <========================================> */
+void Decode_ResponseMessage(PS_ResponseMessage x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(19, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->masterSlaveDeterminationAck = (PS_MasterSlaveDeterminationAck) OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDeterminationAck));
+            Decode_MasterSlaveDeterminationAck(x->masterSlaveDeterminationAck, stream);
+            break;
+        case 2:
+            x->masterSlaveDeterminationReject = (PS_MasterSlaveDeterminationReject) OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDeterminationReject));
+            Decode_MasterSlaveDeterminationReject(x->masterSlaveDeterminationReject, stream);
+            break;
+        case 3:
+            x->terminalCapabilitySetAck = (PS_TerminalCapabilitySetAck) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySetAck));
+            Decode_TerminalCapabilitySetAck(x->terminalCapabilitySetAck, stream);
+            break;
+        case 4:
+            x->terminalCapabilitySetReject = (PS_TerminalCapabilitySetReject) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySetReject));
+            Decode_TerminalCapabilitySetReject(x->terminalCapabilitySetReject, stream);
+            break;
+        case 5:
+            x->openLogicalChannelAck = (PS_OpenLogicalChannelAck) OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannelAck));
+            Decode_OpenLogicalChannelAck(x->openLogicalChannelAck, stream);
+            break;
+        case 6:
+            x->openLogicalChannelReject = (PS_OpenLogicalChannelReject) OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannelReject));
+            Decode_OpenLogicalChannelReject(x->openLogicalChannelReject, stream);
+            break;
+        case 7:
+            x->closeLogicalChannelAck = (PS_CloseLogicalChannelAck) OSCL_DEFAULT_MALLOC(sizeof(S_CloseLogicalChannelAck));
+            Decode_CloseLogicalChannelAck(x->closeLogicalChannelAck, stream);
+            break;
+        case 8:
+            x->requestChannelCloseAck = (PS_RequestChannelCloseAck) OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelCloseAck));
+            Decode_RequestChannelCloseAck(x->requestChannelCloseAck, stream);
+            break;
+        case 9:
+            x->requestChannelCloseReject = (PS_RequestChannelCloseReject) OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelCloseReject));
+            Decode_RequestChannelCloseReject(x->requestChannelCloseReject, stream);
+            break;
+        case 10:
+            x->multiplexEntrySendAck = (PS_MultiplexEntrySendAck) OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySendAck));
+            Decode_MultiplexEntrySendAck(x->multiplexEntrySendAck, stream);
+            break;
+        case 11:
+            x->multiplexEntrySendReject = (PS_MultiplexEntrySendReject) OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySendReject));
+            Decode_MultiplexEntrySendReject(x->multiplexEntrySendReject, stream);
+            break;
+        case 12:
+            x->requestMultiplexEntryAck = (PS_RequestMultiplexEntryAck) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntryAck));
+            Decode_RequestMultiplexEntryAck(x->requestMultiplexEntryAck, stream);
+            break;
+        case 13:
+            x->requestMultiplexEntryReject = (PS_RequestMultiplexEntryReject) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntryReject));
+            Decode_RequestMultiplexEntryReject(x->requestMultiplexEntryReject, stream);
+            break;
+        case 14:
+            x->requestModeAck = (PS_RequestModeAck) OSCL_DEFAULT_MALLOC(sizeof(S_RequestModeAck));
+            Decode_RequestModeAck(x->requestModeAck, stream);
+            break;
+        case 15:
+            x->requestModeReject = (PS_RequestModeReject) OSCL_DEFAULT_MALLOC(sizeof(S_RequestModeReject));
+            Decode_RequestModeReject(x->requestModeReject, stream);
+            break;
+        case 16:
+            x->roundTripDelayResponse = (PS_RoundTripDelayResponse) OSCL_DEFAULT_MALLOC(sizeof(S_RoundTripDelayResponse));
+            Decode_RoundTripDelayResponse(x->roundTripDelayResponse, stream);
+            break;
+        case 17:
+            x->maintenanceLoopAck = (PS_MaintenanceLoopAck) OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopAck));
+            Decode_MaintenanceLoopAck(x->maintenanceLoopAck, stream);
+            break;
+        case 18:
+            x->maintenanceLoopReject = (PS_MaintenanceLoopReject) OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopReject));
+            Decode_MaintenanceLoopReject(x->maintenanceLoopReject, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            GetLengthDet(stream);
+            x->communicationModeResponse = (PS_CommunicationModeResponse) OSCL_DEFAULT_MALLOC(sizeof(S_CommunicationModeResponse));
+            Decode_CommunicationModeResponse(x->communicationModeResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 20:
+            GetLengthDet(stream);
+            x->conferenceResponse = (PS_ConferenceResponse) OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceResponse));
+            Decode_ConferenceResponse(x->conferenceResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 21:
+            GetLengthDet(stream);
+            x->multilinkResponse = (PS_MultilinkResponse) OSCL_DEFAULT_MALLOC(sizeof(S_MultilinkResponse));
+            Decode_MultilinkResponse(x->multilinkResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 22:
+            GetLengthDet(stream);
+            x->logicalChannelRateAcknowledge = (PS_LogicalChannelRateAcknowledge) OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateAcknowledge));
+            Decode_LogicalChannelRateAcknowledge(x->logicalChannelRateAcknowledge, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 23:
+            GetLengthDet(stream);
+            x->logicalChannelRateReject = (PS_LogicalChannelRateReject) OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateReject));
+            Decode_LogicalChannelRateReject(x->logicalChannelRateReject, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ResponseMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for CommandMessage (CHOICE)  */
+/* <=======================================> */
+void Decode_CommandMessage(PS_CommandMessage x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(7, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->maintenanceLoopOffCommand = (PS_MaintenanceLoopOffCommand) OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopOffCommand));
+            Decode_MaintenanceLoopOffCommand(x->maintenanceLoopOffCommand, stream);
+            break;
+        case 2:
+            x->sendTerminalCapabilitySet = (PS_SendTerminalCapabilitySet) OSCL_DEFAULT_MALLOC(sizeof(S_SendTerminalCapabilitySet));
+            Decode_SendTerminalCapabilitySet(x->sendTerminalCapabilitySet, stream);
+            break;
+        case 3:
+            x->encryptionCommand = (PS_EncryptionCommand) OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionCommand));
+            Decode_EncryptionCommand(x->encryptionCommand, stream);
+            break;
+        case 4:
+            x->flowControlCommand = (PS_FlowControlCommand) OSCL_DEFAULT_MALLOC(sizeof(S_FlowControlCommand));
+            Decode_FlowControlCommand(x->flowControlCommand, stream);
+            break;
+        case 5:
+            x->endSessionCommand = (PS_EndSessionCommand) OSCL_DEFAULT_MALLOC(sizeof(S_EndSessionCommand));
+            Decode_EndSessionCommand(x->endSessionCommand, stream);
+            break;
+        case 6:
+            x->miscellaneousCommand = (PS_MiscellaneousCommand) OSCL_DEFAULT_MALLOC(sizeof(S_MiscellaneousCommand));
+            Decode_MiscellaneousCommand(x->miscellaneousCommand, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            GetLengthDet(stream);
+            x->communicationModeCommand = (PS_CommunicationModeCommand) OSCL_DEFAULT_MALLOC(sizeof(S_CommunicationModeCommand));
+            Decode_CommunicationModeCommand(x->communicationModeCommand, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 8:
+            GetLengthDet(stream);
+            x->conferenceCommand = (PS_ConferenceCommand) OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceCommand));
+            Decode_ConferenceCommand(x->conferenceCommand, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 9:
+            GetLengthDet(stream);
+            x->h223MultiplexReconfiguration = (PS_H223MultiplexReconfiguration) OSCL_DEFAULT_MALLOC(sizeof(S_H223MultiplexReconfiguration));
+            Decode_H223MultiplexReconfiguration(x->h223MultiplexReconfiguration, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 10:
+            GetLengthDet(stream);
+            x->newATMVCCommand = (PS_NewATMVCCommand) OSCL_DEFAULT_MALLOC(sizeof(S_NewATMVCCommand));
+            Decode_NewATMVCCommand(x->newATMVCCommand, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_CommandMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for IndicationMessage (CHOICE)  */
+/* <==========================================> */
+void Decode_IndicationMessage(PS_IndicationMessage x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(14, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->functionNotUnderstood = (PS_FunctionNotUnderstood) OSCL_DEFAULT_MALLOC(sizeof(S_FunctionNotUnderstood));
+            Decode_FunctionNotUnderstood(x->functionNotUnderstood, stream);
+            break;
+        case 2:
+            x->masterSlaveDeterminationRelease = (PS_MasterSlaveDeterminationRelease) OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDeterminationRelease));
+            Decode_MasterSlaveDeterminationRelease(x->masterSlaveDeterminationRelease, stream);
+            break;
+        case 3:
+            x->terminalCapabilitySetRelease = (PS_TerminalCapabilitySetRelease) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySetRelease));
+            Decode_TerminalCapabilitySetRelease(x->terminalCapabilitySetRelease, stream);
+            break;
+        case 4:
+            x->openLogicalChannelConfirm = (PS_OpenLogicalChannelConfirm) OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannelConfirm));
+            Decode_OpenLogicalChannelConfirm(x->openLogicalChannelConfirm, stream);
+            break;
+        case 5:
+            x->requestChannelCloseRelease = (PS_RequestChannelCloseRelease) OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelCloseRelease));
+            Decode_RequestChannelCloseRelease(x->requestChannelCloseRelease, stream);
+            break;
+        case 6:
+            x->multiplexEntrySendRelease = (PS_MultiplexEntrySendRelease) OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySendRelease));
+            Decode_MultiplexEntrySendRelease(x->multiplexEntrySendRelease, stream);
+            break;
+        case 7:
+            x->requestMultiplexEntryRelease = (PS_RequestMultiplexEntryRelease) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntryRelease));
+            Decode_RequestMultiplexEntryRelease(x->requestMultiplexEntryRelease, stream);
+            break;
+        case 8:
+            x->requestModeRelease = (PS_RequestModeRelease) OSCL_DEFAULT_MALLOC(sizeof(S_RequestModeRelease));
+            Decode_RequestModeRelease(x->requestModeRelease, stream);
+            break;
+        case 9:
+            x->miscellaneousIndication = (PS_MiscellaneousIndication) OSCL_DEFAULT_MALLOC(sizeof(S_MiscellaneousIndication));
+            Decode_MiscellaneousIndication(x->miscellaneousIndication, stream);
+            break;
+        case 10:
+            x->jitterIndication = (PS_JitterIndication) OSCL_DEFAULT_MALLOC(sizeof(S_JitterIndication));
+            Decode_JitterIndication(x->jitterIndication, stream);
+            break;
+        case 11:
+            x->h223SkewIndication = (PS_H223SkewIndication) OSCL_DEFAULT_MALLOC(sizeof(S_H223SkewIndication));
+            Decode_H223SkewIndication(x->h223SkewIndication, stream);
+            break;
+        case 12:
+            x->newATMVCIndication = (PS_NewATMVCIndication) OSCL_DEFAULT_MALLOC(sizeof(S_NewATMVCIndication));
+            Decode_NewATMVCIndication(x->newATMVCIndication, stream);
+            break;
+        case 13:
+            x->userInput = (PS_UserInputIndication) OSCL_DEFAULT_MALLOC(sizeof(S_UserInputIndication));
+            Decode_UserInputIndication(x->userInput, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            GetLengthDet(stream);
+            x->h2250MaximumSkewIndication = (PS_H2250MaximumSkewIndication) OSCL_DEFAULT_MALLOC(sizeof(S_H2250MaximumSkewIndication));
+            Decode_H2250MaximumSkewIndication(x->h2250MaximumSkewIndication, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            x->mcLocationIndication = (PS_MCLocationIndication) OSCL_DEFAULT_MALLOC(sizeof(S_MCLocationIndication));
+            Decode_MCLocationIndication(x->mcLocationIndication, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 16:
+            GetLengthDet(stream);
+            x->conferenceIndication = (PS_ConferenceIndication) OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceIndication));
+            Decode_ConferenceIndication(x->conferenceIndication, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 17:
+            GetLengthDet(stream);
+            x->vendorIdentification = (PS_VendorIdentification) OSCL_DEFAULT_MALLOC(sizeof(S_VendorIdentification));
+            Decode_VendorIdentification(x->vendorIdentification, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 18:
+            GetLengthDet(stream);
+            x->functionNotSupported = (PS_FunctionNotSupported) OSCL_DEFAULT_MALLOC(sizeof(S_FunctionNotSupported));
+            Decode_FunctionNotSupported(x->functionNotSupported, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 19:
+            GetLengthDet(stream);
+            x->multilinkIndication = (PS_MultilinkIndication) OSCL_DEFAULT_MALLOC(sizeof(S_MultilinkIndication));
+            Decode_MultilinkIndication(x->multilinkIndication, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 20:
+            GetLengthDet(stream);
+            x->logicalChannelRateRelease = (PS_LogicalChannelRateRelease) OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateRelease));
+            Decode_LogicalChannelRateRelease(x->logicalChannelRateRelease, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 21:
+            GetLengthDet(stream);
+            x->flowControlIndication = (PS_FlowControlIndication) OSCL_DEFAULT_MALLOC(sizeof(S_FlowControlIndication));
+            Decode_FlowControlIndication(x->flowControlIndication, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_IndicationMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for GenericInformation (SEQUENCE)  */
+/* <=============================================> */
+void Decode_GenericInformation(PS_GenericInformation x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_subMessageIdentifier = GetBoolean(stream);
+    x->option_of_messageContent = GetBoolean(stream);
+    Decode_CapabilityIdentifier(&x->messageIdentifier, stream);
+    if (x->option_of_subMessageIdentifier)
+    {
+        x->subMessageIdentifier = (uint8)GetInteger(0, 127, stream);
+    }
+    if (x->option_of_messageContent)
+    {
+        x->size_of_messageContent = (uint16)GetLengthDet(stream);
+        x->messageContent = (PS_GenericParameter)
+                            OSCL_DEFAULT_MALLOC(x->size_of_messageContent * sizeof(S_GenericParameter));
+        for (i = 0;i < x->size_of_messageContent;++i)
+        {
+            Decode_GenericParameter(x->messageContent + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessageAndLeave("Decode_GenericInformation: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for NonStandardMessage (SEQUENCE)  */
+/* <=============================================> */
+void Decode_NonStandardMessage(PS_NonStandardMessage x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_NonStandardParameter(&x->nonStandardData, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_NonStandardMessage: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for NonStandardParameter (SEQUENCE)  */
+/* <===============================================> */
+void Decode_NonStandardParameter(PS_NonStandardParameter x, PS_InStream stream)
+{
+    Decode_NonStandardIdentifier(&x->nonStandardIdentifier, stream);
+    GetOctetString(1, 0, 0, &x->data, stream);
+}
+
+/* <==============================================> */
+/*  PER-Decoder for NonStandardIdentifier (CHOICE)  */
+/* <==============================================> */
+void Decode_NonStandardIdentifier(PS_NonStandardIdentifier x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->object = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            GetObjectID(x->object, stream);
+            break;
+        case 1:
+            x->h221NonStandard = (PS_H221NonStandard) OSCL_DEFAULT_MALLOC(sizeof(S_H221NonStandard));
+            Decode_H221NonStandard(x->h221NonStandard, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_NonStandardIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for H221NonStandard (SEQUENCE)  */
+/* <==========================================> */
+void Decode_H221NonStandard(PS_H221NonStandard x, PS_InStream stream)
+{
+    x->t35CountryCode = (uint8) GetInteger(0, 255, stream);
+    x->t35Extension = (uint8) GetInteger(0, 255, stream);
+    x->manufacturerCode = (uint16) GetInteger(0, 65535, stream);
+}
+
+/* <===================================================> */
+/*  PER-Decoder for MasterSlaveDetermination (SEQUENCE)  */
+/* <===================================================> */
+void Decode_MasterSlaveDetermination(PS_MasterSlaveDetermination x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->terminalType = (uint8) GetInteger(0, 255, stream);
+    x->statusDeterminationNumber = GetInteger(0, 16777215, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MasterSlaveDetermination: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for MasterSlaveDeterminationAck (SEQUENCE)  */
+/* <======================================================> */
+void Decode_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_Decision(&x->decision, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MasterSlaveDeterminationAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for Decision (CHOICE)  */
+/* <=================================> */
+void Decode_Decision(PS_Decision x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (master is NULL) */
+            break;
+        case 1:
+            /* (slave is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Decision: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================================> */
+/*  PER-Decoder for MasterSlaveDeterminationReject (SEQUENCE)  */
+/* <=========================================================> */
+void Decode_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_MsdRejectCause(&x->msdRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MasterSlaveDeterminationReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for MsdRejectCause (CHOICE)  */
+/* <=======================================> */
+void Decode_MsdRejectCause(PS_MsdRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (identicalNumbers is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MsdRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Decoder for MasterSlaveDeterminationRelease (SEQUENCE)  */
+/* <==========================================================> */
+void Decode_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MasterSlaveDeterminationRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for TerminalCapabilitySet (SEQUENCE)  */
+/* <================================================> */
+void Decode_TerminalCapabilitySet(PS_TerminalCapabilitySet x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_multiplexCapability = GetBoolean(stream);
+    x->option_of_capabilityTable = GetBoolean(stream);
+    x->option_of_capabilityDescriptors = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    GetObjectID(&x->protocolIdentifier, stream);
+    if (x->option_of_multiplexCapability)
+    {
+        Decode_MultiplexCapability(&x->multiplexCapability, stream);
+    }
+    if (x->option_of_capabilityTable)
+    {
+        x->size_of_capabilityTable = (uint16) GetInteger(1, 256, stream);
+        x->capabilityTable = (PS_CapabilityTableEntry)
+                             OSCL_DEFAULT_MALLOC(x->size_of_capabilityTable * sizeof(S_CapabilityTableEntry));
+        for (i = 0;i < x->size_of_capabilityTable;++i)
+        {
+            Decode_CapabilityTableEntry(x->capabilityTable + i, stream);
+        }
+    }
+    if (x->option_of_capabilityDescriptors)
+    {
+        x->size_of_capabilityDescriptors = (uint16) GetInteger(1, 256, stream);
+        x->capabilityDescriptors = (PS_CapabilityDescriptor)
+                                   OSCL_DEFAULT_MALLOC(x->size_of_capabilityDescriptors * sizeof(S_CapabilityDescriptor));
+        for (i = 0;i < x->size_of_capabilityDescriptors;++i)
+        {
+            Decode_CapabilityDescriptor(x->capabilityDescriptors + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_genericInformation = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_genericInformation = SigMapValue(0, map);
+        if (x->option_of_genericInformation)
+        {
+            ExtensionPrep(map, stream);
+            x->size_of_genericInformation = (uint16)GetLengthDet(stream);
+            x->genericInformation = (PS_GenericInformation)
+                                    OSCL_DEFAULT_MALLOC(x->size_of_genericInformation * sizeof(S_GenericInformation));
+            for (i = 0;i < x->size_of_genericInformation;++i)
+            {
+                Decode_GenericInformation(x->genericInformation + i, stream);
+            }
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalCapabilitySet: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for CapabilityTableEntry (SEQUENCE)  */
+/* <===============================================> */
+void Decode_CapabilityTableEntry(PS_CapabilityTableEntry x, PS_InStream stream)
+{
+    x->option_of_capability = GetBoolean(stream);
+    x->capabilityTableEntryNumber = (uint16) GetInteger(1, 65535, stream);
+    if (x->option_of_capability)
+    {
+        Decode_Capability(&x->capability, stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for CapabilityDescriptor (SEQUENCE)  */
+/* <===============================================> */
+void Decode_CapabilityDescriptor(PS_CapabilityDescriptor x, PS_InStream stream)
+{
+    uint16 i;
+    x->option_of_simultaneousCapabilities = GetBoolean(stream);
+    x->capabilityDescriptorNumber = (uint8) GetInteger(0, 255, stream);
+    if (x->option_of_simultaneousCapabilities)
+    {
+        x->size_of_simultaneousCapabilities = (uint16) GetInteger(1, 256, stream);
+        x->simultaneousCapabilities = (PS_AlternativeCapabilitySet)
+                                      OSCL_DEFAULT_MALLOC(x->size_of_simultaneousCapabilities * sizeof(S_AlternativeCapabilitySet));
+        for (i = 0;i < x->size_of_simultaneousCapabilities;++i)
+        {
+            Decode_AlternativeCapabilitySet(x->simultaneousCapabilities + i, stream);
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for AlternativeCapabilitySet (SEQUENCE-OF)  */
+/* <======================================================> */
+void Decode_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x, PS_InStream stream)
+{
+    uint16 i;
+    x->size = (uint16) GetInteger(1, 256, stream);
+    x->item = (uint32*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint32));
+    for (i = 0;i < x->size;++i)
+    {
+        x->item[i] = GetInteger(1, 65535, stream);
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for TerminalCapabilitySetAck (SEQUENCE)  */
+/* <===================================================> */
+void Decode_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalCapabilitySetAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for TerminalCapabilitySetReject (SEQUENCE)  */
+/* <======================================================> */
+void Decode_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    Decode_TcsRejectCause(&x->tcsRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalCapabilitySetReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for TcsRejectCause (CHOICE)  */
+/* <=======================================> */
+void Decode_TcsRejectCause(PS_TcsRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (undefinedTableEntryUsed is NULL) */
+            break;
+        case 2:
+            /* (descriptorCapacityExceeded is NULL) */
+            break;
+        case 3:
+            x->tableEntryCapacityExceeded = (PS_TableEntryCapacityExceeded) OSCL_DEFAULT_MALLOC(sizeof(S_TableEntryCapacityExceeded));
+            Decode_TableEntryCapacityExceeded(x->tableEntryCapacityExceeded, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_TcsRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for TableEntryCapacityExceeded (CHOICE)  */
+/* <===================================================> */
+void Decode_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->highestEntryNumberProcessed = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            /* (noneProcessed is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_TableEntryCapacityExceeded: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for TerminalCapabilitySetRelease (SEQUENCE)  */
+/* <=======================================================> */
+void Decode_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalCapabilitySetRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for Capability (CHOICE)  */
+/* <===================================> */
+void Decode_Capability(PS_Capability x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(12, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->receiveVideoCapability = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            Decode_VideoCapability(x->receiveVideoCapability, stream);
+            break;
+        case 2:
+            x->transmitVideoCapability = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            Decode_VideoCapability(x->transmitVideoCapability, stream);
+            break;
+        case 3:
+            x->receiveAndTransmitVideoCapability = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            Decode_VideoCapability(x->receiveAndTransmitVideoCapability, stream);
+            break;
+        case 4:
+            x->receiveAudioCapability = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            Decode_AudioCapability(x->receiveAudioCapability, stream);
+            break;
+        case 5:
+            x->transmitAudioCapability = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            Decode_AudioCapability(x->transmitAudioCapability, stream);
+            break;
+        case 6:
+            x->receiveAndTransmitAudioCapability = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            Decode_AudioCapability(x->receiveAndTransmitAudioCapability, stream);
+            break;
+        case 7:
+            x->receiveDataApplicationCapability = (PS_DataApplicationCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataApplicationCapability));
+            Decode_DataApplicationCapability(x->receiveDataApplicationCapability, stream);
+            break;
+        case 8:
+            x->transmitDataApplicationCapability = (PS_DataApplicationCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataApplicationCapability));
+            Decode_DataApplicationCapability(x->transmitDataApplicationCapability, stream);
+            break;
+        case 9:
+            x->receiveAndTransmitDataApplicationCapability = (PS_DataApplicationCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataApplicationCapability));
+            Decode_DataApplicationCapability(x->receiveAndTransmitDataApplicationCapability, stream);
+            break;
+        case 10:
+            x->h233EncryptionTransmitCapability = GetBoolean(stream);
+            break;
+        case 11:
+            x->h233EncryptionReceiveCapability = (PS_H233EncryptionReceiveCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H233EncryptionReceiveCapability));
+            Decode_H233EncryptionReceiveCapability(x->h233EncryptionReceiveCapability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 12:
+            GetLengthDet(stream);
+            x->conferenceCapability = (PS_ConferenceCapability) OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceCapability));
+            Decode_ConferenceCapability(x->conferenceCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->h235SecurityCapability = (PS_H235SecurityCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H235SecurityCapability));
+            Decode_H235SecurityCapability(x->h235SecurityCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 14:
+            GetLengthDet(stream);
+            x->maxPendingReplacementFor = (uint8) GetInteger(0, 255, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            x->receiveUserInputCapability = (PS_UserInputCapability) OSCL_DEFAULT_MALLOC(sizeof(S_UserInputCapability));
+            Decode_UserInputCapability(x->receiveUserInputCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 16:
+            GetLengthDet(stream);
+            x->transmitUserInputCapability = (PS_UserInputCapability) OSCL_DEFAULT_MALLOC(sizeof(S_UserInputCapability));
+            Decode_UserInputCapability(x->transmitUserInputCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 17:
+            GetLengthDet(stream);
+            x->receiveAndTransmitUserInputCapability = (PS_UserInputCapability) OSCL_DEFAULT_MALLOC(sizeof(S_UserInputCapability));
+            Decode_UserInputCapability(x->receiveAndTransmitUserInputCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 18:
+            GetLengthDet(stream);
+            x->genericControlCapability = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericControlCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_Capability: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Decoder for H233EncryptionReceiveCapability (SEQUENCE)  */
+/* <==========================================================> */
+void Decode_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->h233IVResponseTime = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H233EncryptionReceiveCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for H235SecurityCapability (SEQUENCE)  */
+/* <=================================================> */
+void Decode_H235SecurityCapability(PS_H235SecurityCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, stream);
+    x->mediaCapability = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H235SecurityCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for MultiplexCapability (CHOICE)  */
+/* <============================================> */
+void Decode_MultiplexCapability(PS_MultiplexCapability x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->h222Capability = (PS_H222Capability) OSCL_DEFAULT_MALLOC(sizeof(S_H222Capability));
+            Decode_H222Capability(x->h222Capability, stream);
+            break;
+        case 2:
+            x->h223Capability = (PS_H223Capability) OSCL_DEFAULT_MALLOC(sizeof(S_H223Capability));
+            Decode_H223Capability(x->h223Capability, stream);
+            break;
+        case 3:
+            x->v76Capability = (PS_V76Capability) OSCL_DEFAULT_MALLOC(sizeof(S_V76Capability));
+            Decode_V76Capability(x->v76Capability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            GetLengthDet(stream);
+            x->h2250Capability = (PS_H2250Capability) OSCL_DEFAULT_MALLOC(sizeof(S_H2250Capability));
+            Decode_H2250Capability(x->h2250Capability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 5:
+            GetLengthDet(stream);
+            x->genericMultiplexCapability = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericMultiplexCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_MultiplexCapability: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for H222Capability (SEQUENCE)  */
+/* <=========================================> */
+void Decode_H222Capability(PS_H222Capability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->numberOfVCs = (uint16) GetInteger(1, 256, stream);
+    x->size_of_vcCapability = (uint16) GetLengthDet(stream);
+    x->vcCapability = (PS_VCCapability)
+                      OSCL_DEFAULT_MALLOC(x->size_of_vcCapability * sizeof(S_VCCapability));
+    for (i = 0;i < x->size_of_vcCapability;++i)
+    {
+        Decode_VCCapability(x->vcCapability + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H222Capability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for VCCapability (SEQUENCE)  */
+/* <=======================================> */
+void Decode_VCCapability(PS_VCCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_vccAal1 = GetBoolean(stream);
+    x->option_of_vccAal5 = GetBoolean(stream);
+    if (x->option_of_vccAal1)
+    {
+        Decode_VccAal1(&x->vccAal1, stream);
+    }
+    if (x->option_of_vccAal5)
+    {
+        Decode_VccAal5(&x->vccAal5, stream);
+    }
+    x->transportStream = GetBoolean(stream);
+    x->programStream = GetBoolean(stream);
+    Decode_AvailableBitRates(&x->availableBitRates, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_aal1ViaGateway = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_aal1ViaGateway = SigMapValue(0, map);
+        if (x->option_of_aal1ViaGateway)
+        {
+            ExtensionPrep(map, stream);
+            Decode_Aal1ViaGateway(&x->aal1ViaGateway, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VCCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for Aal1ViaGateway (SEQUENCE)  */
+/* <=========================================> */
+void Decode_Aal1ViaGateway(PS_Aal1ViaGateway x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_gatewayAddress = (uint16) GetInteger(1, 256, stream);
+    x->gatewayAddress = (PS_Q2931Address)
+                        OSCL_DEFAULT_MALLOC(x->size_of_gatewayAddress * sizeof(S_Q2931Address));
+    for (i = 0;i < x->size_of_gatewayAddress;++i)
+    {
+        Decode_Q2931Address(x->gatewayAddress + i, stream);
+    }
+    x->nullClockRecovery = GetBoolean(stream);
+    x->srtsClockRecovery = GetBoolean(stream);
+    x->adaptiveClockRecovery = GetBoolean(stream);
+    x->nullErrorCorrection = GetBoolean(stream);
+    x->longInterleaver = GetBoolean(stream);
+    x->shortInterleaver = GetBoolean(stream);
+    x->errorCorrectionOnly = GetBoolean(stream);
+    x->structuredDataTransfer = GetBoolean(stream);
+    x->partiallyFilledCells = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Aal1ViaGateway: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for AvailableBitRates (SEQUENCE)  */
+/* <============================================> */
+void Decode_AvailableBitRates(PS_AvailableBitRates x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_VccAal5Type(&x->vccAal5Type, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_AvailableBitRates: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for VccAal5Type (CHOICE)  */
+/* <====================================> */
+void Decode_VccAal5Type(PS_VccAal5Type x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->singleBitRate = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            x->rangeOfBitRates = (PS_RangeOfBitRates) OSCL_DEFAULT_MALLOC(sizeof(S_RangeOfBitRates));
+            Decode_RangeOfBitRates(x->rangeOfBitRates, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_VccAal5Type: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for RangeOfBitRates (SEQUENCE)  */
+/* <==========================================> */
+void Decode_RangeOfBitRates(PS_RangeOfBitRates x, PS_InStream stream)
+{
+    x->lowerBitRate = (uint16) GetInteger(1, 65535, stream);
+    x->higherBitRate = (uint16) GetInteger(1, 65535, stream);
+}
+
+/* <==================================> */
+/*  PER-Decoder for VccAal5 (SEQUENCE)  */
+/* <==================================> */
+void Decode_VccAal5(PS_VccAal5 x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardMaximumSDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->backwardMaximumSDUSize = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VccAal5: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for VccAal1 (SEQUENCE)  */
+/* <==================================> */
+void Decode_VccAal1(PS_VccAal1 x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->nullClockRecovery = GetBoolean(stream);
+    x->srtsClockRecovery = GetBoolean(stream);
+    x->adaptiveClockRecovery = GetBoolean(stream);
+    x->nullErrorCorrection = GetBoolean(stream);
+    x->longInterleaver = GetBoolean(stream);
+    x->shortInterleaver = GetBoolean(stream);
+    x->errorCorrectionOnly = GetBoolean(stream);
+    x->structuredDataTransfer = GetBoolean(stream);
+    x->partiallyFilledCells = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VccAal1: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for H223Capability (SEQUENCE)  */
+/* <=========================================> */
+void Decode_H223Capability(PS_H223Capability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->transportWithI_frames = GetBoolean(stream);
+    x->videoWithAL1 = GetBoolean(stream);
+    x->videoWithAL2 = GetBoolean(stream);
+    x->videoWithAL3 = GetBoolean(stream);
+    x->audioWithAL1 = GetBoolean(stream);
+    x->audioWithAL2 = GetBoolean(stream);
+    x->audioWithAL3 = GetBoolean(stream);
+    x->dataWithAL1 = GetBoolean(stream);
+    x->dataWithAL2 = GetBoolean(stream);
+    x->dataWithAL3 = GetBoolean(stream);
+    x->maximumAl2SDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->maximumAl3SDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->maximumDelayJitter = (uint16) GetInteger(0, 1023, stream);
+    Decode_H223MultiplexTableCapability(&x->h223MultiplexTableCapability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_maxMUXPDUSizeCapability = OFF;
+    x->option_of_nsrpSupport = OFF;
+    x->option_of_mobileOperationTransmitCapability = OFF;
+    x->option_of_h223AnnexCCapability = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_maxMUXPDUSizeCapability = SigMapValue(0, map);
+        if (x->option_of_maxMUXPDUSizeCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->maxMUXPDUSizeCapability = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_nsrpSupport = SigMapValue(1, map);
+        if (x->option_of_nsrpSupport)
+        {
+            ExtensionPrep(map, stream);
+            x->nsrpSupport = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_mobileOperationTransmitCapability = SigMapValue(2, map);
+        if (x->option_of_mobileOperationTransmitCapability)
+        {
+            ExtensionPrep(map, stream);
+            Decode_MobileOperationTransmitCapability(&x->mobileOperationTransmitCapability, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_h223AnnexCCapability = SigMapValue(3, map);
+        if (x->option_of_h223AnnexCCapability)
+        {
+            ExtensionPrep(map, stream);
+            Decode_H223AnnexCCapability(&x->h223AnnexCCapability, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223Capability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================================> */
+/*  PER-Decoder for MobileOperationTransmitCapability (SEQUENCE)  */
+/* <============================================================> */
+void Decode_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->modeChangeCapability = GetBoolean(stream);
+    x->h223AnnexA = GetBoolean(stream);
+    x->h223AnnexADoubleFlag = GetBoolean(stream);
+    x->h223AnnexB = GetBoolean(stream);
+    x->h223AnnexBwithHeader = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MobileOperationTransmitCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Decoder for H223MultiplexTableCapability (CHOICE)  */
+/* <=====================================================> */
+void Decode_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (basic is NULL) */
+            break;
+        case 1:
+            x->enhanced = (PS_Enhanced) OSCL_DEFAULT_MALLOC(sizeof(S_Enhanced));
+            Decode_Enhanced(x->enhanced, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_H223MultiplexTableCapability: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for Enhanced (SEQUENCE)  */
+/* <===================================> */
+void Decode_Enhanced(PS_Enhanced x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->maximumNestingDepth = (uint8) GetInteger(1, 15, stream);
+    x->maximumElementListSize = (uint8) GetInteger(2, 255, stream);
+    x->maximumSubElementListSize = (uint8) GetInteger(2, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Enhanced: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for H223AnnexCCapability (SEQUENCE)  */
+/* <===============================================> */
+void Decode_H223AnnexCCapability(PS_H223AnnexCCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->videoWithAL1M = GetBoolean(stream);
+    x->videoWithAL2M = GetBoolean(stream);
+    x->videoWithAL3M = GetBoolean(stream);
+    x->audioWithAL1M = GetBoolean(stream);
+    x->audioWithAL2M = GetBoolean(stream);
+    x->audioWithAL3M = GetBoolean(stream);
+    x->dataWithAL1M = GetBoolean(stream);
+    x->dataWithAL2M = GetBoolean(stream);
+    x->dataWithAL3M = GetBoolean(stream);
+    x->alpduInterleaving = GetBoolean(stream);
+    x->maximumAL1MPDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->maximumAL2MSDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->maximumAL3MSDUSize = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_rsCodeCapability = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_rsCodeCapability = SigMapValue(0, map);
+        if (x->option_of_rsCodeCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->rsCodeCapability = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223AnnexCCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for V76Capability (SEQUENCE)  */
+/* <========================================> */
+void Decode_V76Capability(PS_V76Capability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->suspendResumeCapabilitywAddress = GetBoolean(stream);
+    x->suspendResumeCapabilitywoAddress = GetBoolean(stream);
+    x->rejCapability = GetBoolean(stream);
+    x->sREJCapability = GetBoolean(stream);
+    x->mREJCapability = GetBoolean(stream);
+    x->crc8bitCapability = GetBoolean(stream);
+    x->crc16bitCapability = GetBoolean(stream);
+    x->crc32bitCapability = GetBoolean(stream);
+    x->uihCapability = GetBoolean(stream);
+    x->numOfDLCS = (uint16) GetInteger(2, 8191, stream);
+    x->twoOctetAddressFieldCapability = GetBoolean(stream);
+    x->loopBackTestCapability = GetBoolean(stream);
+    x->n401Capability = (uint16) GetInteger(1, 4095, stream);
+    x->maxWindowSizeCapability = (uint8) GetInteger(1, 127, stream);
+    Decode_V75Capability(&x->v75Capability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_V76Capability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for V75Capability (SEQUENCE)  */
+/* <========================================> */
+void Decode_V75Capability(PS_V75Capability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->audioHeader = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_V75Capability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for H2250Capability (SEQUENCE)  */
+/* <==========================================> */
+void Decode_H2250Capability(PS_H2250Capability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->maximumAudioDelayJitter = (uint16) GetInteger(0, 1023, stream);
+    Decode_MultipointCapability(&x->receiveMultipointCapability, stream);
+    Decode_MultipointCapability(&x->transmitMultipointCapability, stream);
+    Decode_MultipointCapability(&x->receiveAndTransmitMultipointCapability, stream);
+    Decode_McCapability(&x->mcCapability, stream);
+    x->rtcpVideoControlCapability = GetBoolean(stream);
+    Decode_MediaPacketizationCapability(&x->mediaPacketizationCapability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_transportCapability = OFF;
+    x->option_of_redundancyEncodingCapability = OFF;
+    x->option_of_logicalChannelSwitchingCapability = OFF;
+    x->option_of_t120DynamicPortCapability = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_transportCapability = SigMapValue(0, map);
+        if (x->option_of_transportCapability)
+        {
+            ExtensionPrep(map, stream);
+            Decode_TransportCapability(&x->transportCapability, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_redundancyEncodingCapability = SigMapValue(1, map);
+        if (x->option_of_redundancyEncodingCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->size_of_redundancyEncodingCapability = (uint16) GetInteger(1, 256, stream);
+            x->redundancyEncodingCapability = (PS_RedundancyEncodingCapability)
+                                              OSCL_DEFAULT_MALLOC(x->size_of_redundancyEncodingCapability * sizeof(S_RedundancyEncodingCapability));
+            for (i = 0;i < x->size_of_redundancyEncodingCapability;++i)
+            {
+                Decode_RedundancyEncodingCapability(x->redundancyEncodingCapability + i, stream);
+            }
+            ReadRemainingBits(stream);
+        }
+        x->option_of_logicalChannelSwitchingCapability = SigMapValue(2, map);
+        if (x->option_of_logicalChannelSwitchingCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->logicalChannelSwitchingCapability = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_t120DynamicPortCapability = SigMapValue(3, map);
+        if (x->option_of_t120DynamicPortCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->t120DynamicPortCapability = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H2250Capability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for McCapability (SEQUENCE)  */
+/* <=======================================> */
+void Decode_McCapability(PS_McCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->centralizedConferenceMC = GetBoolean(stream);
+    x->decentralizedConferenceMC = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_McCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for MediaPacketizationCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Decode_MediaPacketizationCapability(PS_MediaPacketizationCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->h261aVideoPacketization = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_rtpPayloadType = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_rtpPayloadType = SigMapValue(0, map);
+        if (x->option_of_rtpPayloadType)
+        {
+            ExtensionPrep(map, stream);
+            x->size_of_rtpPayloadType = (uint16) GetInteger(1, 256, stream);
+            x->rtpPayloadType = (PS_RTPPayloadType)
+                                OSCL_DEFAULT_MALLOC(x->size_of_rtpPayloadType * sizeof(S_RTPPayloadType));
+            for (i = 0;i < x->size_of_rtpPayloadType;++i)
+            {
+                Decode_RTPPayloadType(x->rtpPayloadType + i, stream);
+            }
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MediaPacketizationCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for RSVPParameters (SEQUENCE)  */
+/* <=========================================> */
+void Decode_RSVPParameters(PS_RSVPParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_qosMode = GetBoolean(stream);
+    x->option_of_tokenRate = GetBoolean(stream);
+    x->option_of_bucketSize = GetBoolean(stream);
+    x->option_of_peakRate = GetBoolean(stream);
+    x->option_of_minPoliced = GetBoolean(stream);
+    x->option_of_maxPktSize = GetBoolean(stream);
+    if (x->option_of_qosMode)
+    {
+        Decode_QOSMode(&x->qosMode, stream);
+    }
+    if (x->option_of_tokenRate)
+    {
+        x->tokenRate = GetInteger(1, 0xffffffff, stream);
+    }
+    if (x->option_of_bucketSize)
+    {
+        x->bucketSize = GetInteger(1, 0xffffffff, stream);
+    }
+    if (x->option_of_peakRate)
+    {
+        x->peakRate = GetInteger(1, 0xffffffff, stream);
+    }
+    if (x->option_of_minPoliced)
+    {
+        x->minPoliced = GetInteger(1, 0xffffffff, stream);
+    }
+    if (x->option_of_maxPktSize)
+    {
+        x->maxPktSize = GetInteger(1, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RSVPParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for QOSMode (CHOICE)  */
+/* <================================> */
+void Decode_QOSMode(PS_QOSMode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (guaranteedQOS is NULL) */
+            break;
+        case 1:
+            /* (controlledLoad is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_QOSMode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for ATMParameters (SEQUENCE)  */
+/* <========================================> */
+void Decode_ATMParameters(PS_ATMParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->maxNTUSize = (uint16) GetInteger(0, 65535, stream);
+    x->atmUBR = GetBoolean(stream);
+    x->atmrtVBR = GetBoolean(stream);
+    x->atmnrtVBR = GetBoolean(stream);
+    x->atmABR = GetBoolean(stream);
+    x->atmCBR = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ATMParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for QOSCapability (SEQUENCE)  */
+/* <========================================> */
+void Decode_QOSCapability(PS_QOSCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandardData = GetBoolean(stream);
+    x->option_of_rsvpParameters = GetBoolean(stream);
+    x->option_of_atmParameters = GetBoolean(stream);
+    if (x->option_of_nonStandardData)
+    {
+        Decode_NonStandardParameter(&x->nonStandardData, stream);
+    }
+    if (x->option_of_rsvpParameters)
+    {
+        Decode_RSVPParameters(&x->rsvpParameters, stream);
+    }
+    if (x->option_of_atmParameters)
+    {
+        Decode_ATMParameters(&x->atmParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_QOSCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for MediaTransportType (CHOICE)  */
+/* <===========================================> */
+void Decode_MediaTransportType(PS_MediaTransportType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (ip_UDP is NULL) */
+            break;
+        case 1:
+            /* (ip_TCP is NULL) */
+            break;
+        case 2:
+            /* (atm_AAL5_UNIDIR is NULL) */
+            break;
+        case 3:
+            /* (atm_AAL5_BIDIR is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            GetLengthDet(stream);
+            x->atm_AAL5_compressed = (PS_Atm_AAL5_compressed) OSCL_DEFAULT_MALLOC(sizeof(S_Atm_AAL5_compressed));
+            Decode_Atm_AAL5_compressed(x->atm_AAL5_compressed, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_MediaTransportType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for Atm_AAL5_compressed (SEQUENCE)  */
+/* <==============================================> */
+void Decode_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->variable_delta = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Atm_AAL5_compressed: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for MediaChannelCapability (SEQUENCE)  */
+/* <=================================================> */
+void Decode_MediaChannelCapability(PS_MediaChannelCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_mediaTransport = GetBoolean(stream);
+    if (x->option_of_mediaTransport)
+    {
+        Decode_MediaTransportType(&x->mediaTransport, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MediaChannelCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for TransportCapability (SEQUENCE)  */
+/* <==============================================> */
+void Decode_TransportCapability(PS_TransportCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    x->option_of_qOSCapabilities = GetBoolean(stream);
+    x->option_of_mediaChannelCapabilities = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        Decode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    if (x->option_of_qOSCapabilities)
+    {
+        x->size_of_qOSCapabilities = (uint16) GetInteger(1, 256, stream);
+        x->qOSCapabilities = (PS_QOSCapability)
+                             OSCL_DEFAULT_MALLOC(x->size_of_qOSCapabilities * sizeof(S_QOSCapability));
+        for (i = 0;i < x->size_of_qOSCapabilities;++i)
+        {
+            Decode_QOSCapability(x->qOSCapabilities + i, stream);
+        }
+    }
+    if (x->option_of_mediaChannelCapabilities)
+    {
+        x->size_of_mediaChannelCapabilities = (uint16) GetInteger(1, 256, stream);
+        x->mediaChannelCapabilities = (PS_MediaChannelCapability)
+                                      OSCL_DEFAULT_MALLOC(x->size_of_mediaChannelCapabilities * sizeof(S_MediaChannelCapability));
+        for (i = 0;i < x->size_of_mediaChannelCapabilities;++i)
+        {
+            Decode_MediaChannelCapability(x->mediaChannelCapabilities + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TransportCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for RedundancyEncodingCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Decode_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_secondaryEncoding = GetBoolean(stream);
+    Decode_RedundancyEncodingMethod(&x->redundancyEncodingMethod, stream);
+    x->primaryEncoding = (uint16) GetInteger(1, 65535, stream);
+    if (x->option_of_secondaryEncoding)
+    {
+        x->size_of_secondaryEncoding = (uint16) GetInteger(1, 256, stream);
+        x->secondaryEncoding = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_secondaryEncoding * sizeof(uint32));
+        for (i = 0;i < x->size_of_secondaryEncoding;++i)
+        {
+            x->secondaryEncoding[i] = GetInteger(1, 65535, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RedundancyEncodingCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for RedundancyEncodingMethod (CHOICE)  */
+/* <=================================================> */
+void Decode_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (rtpAudioRedundancyEncoding is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            GetLengthDet(stream);
+            x->rtpH263VideoRedundancyEncoding = (PS_RTPH263VideoRedundancyEncoding) OSCL_DEFAULT_MALLOC(sizeof(S_RTPH263VideoRedundancyEncoding));
+            Decode_RTPH263VideoRedundancyEncoding(x->rtpH263VideoRedundancyEncoding, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_RedundancyEncodingMethod: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================================> */
+/*  PER-Decoder for RTPH263VideoRedundancyEncoding (SEQUENCE)  */
+/* <=========================================================> */
+void Decode_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_containedThreads = GetBoolean(stream);
+    x->numberOfThreads = (uint8) GetInteger(1, 16, stream);
+    x->framesBetweenSyncPoints = (uint16) GetInteger(1, 256, stream);
+    Decode_FrameToThreadMapping(&x->frameToThreadMapping, stream);
+    if (x->option_of_containedThreads)
+    {
+        x->size_of_containedThreads = (uint16) GetInteger(1, 256, stream);
+        x->containedThreads = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_containedThreads * sizeof(uint32));
+        for (i = 0;i < x->size_of_containedThreads;++i)
+        {
+            x->containedThreads[i] = GetInteger(0, 15, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RTPH263VideoRedundancyEncoding: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for FrameToThreadMapping (CHOICE)  */
+/* <=============================================> */
+void Decode_FrameToThreadMapping(PS_FrameToThreadMapping x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (roundrobin is NULL) */
+            break;
+        case 1:
+            x->size = (uint16) GetInteger(1, 256, stream);
+            x->custom = (PS_RTPH263VideoRedundancyFrameMapping)
+                        OSCL_DEFAULT_MALLOC(x->size * sizeof(S_RTPH263VideoRedundancyFrameMapping));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_RTPH263VideoRedundancyFrameMapping(x->custom + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_FrameToThreadMapping: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================================> */
+/*  PER-Decoder for RTPH263VideoRedundancyFrameMapping (SEQUENCE)  */
+/* <=============================================================> */
+void Decode_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->threadNumber = (uint8) GetInteger(0, 15, stream);
+    x->size_of_frameSequence = (uint16) GetInteger(1, 256, stream);
+    x->frameSequence = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_frameSequence * sizeof(uint32));
+    for (i = 0;i < x->size_of_frameSequence;++i)
+    {
+        x->frameSequence[i] = GetInteger(0, 255, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RTPH263VideoRedundancyFrameMapping: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for MultipointCapability (SEQUENCE)  */
+/* <===============================================> */
+void Decode_MultipointCapability(PS_MultipointCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->multicastCapability = GetBoolean(stream);
+    x->multiUniCastConference = GetBoolean(stream);
+    x->size_of_mediaDistributionCapability = (uint16) GetLengthDet(stream);
+    x->mediaDistributionCapability = (PS_MediaDistributionCapability)
+                                     OSCL_DEFAULT_MALLOC(x->size_of_mediaDistributionCapability * sizeof(S_MediaDistributionCapability));
+    for (i = 0;i < x->size_of_mediaDistributionCapability;++i)
+    {
+        Decode_MediaDistributionCapability(x->mediaDistributionCapability + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MultipointCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for MediaDistributionCapability (SEQUENCE)  */
+/* <======================================================> */
+void Decode_MediaDistributionCapability(PS_MediaDistributionCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_centralizedData = GetBoolean(stream);
+    x->option_of_distributedData = GetBoolean(stream);
+    x->centralizedControl = GetBoolean(stream);
+    x->distributedControl = GetBoolean(stream);
+    x->centralizedAudio = GetBoolean(stream);
+    x->distributedAudio = GetBoolean(stream);
+    x->centralizedVideo = GetBoolean(stream);
+    x->distributedVideo = GetBoolean(stream);
+    if (x->option_of_centralizedData)
+    {
+        x->size_of_centralizedData = (uint16) GetLengthDet(stream);
+        x->centralizedData = (PS_DataApplicationCapability)
+                             OSCL_DEFAULT_MALLOC(x->size_of_centralizedData * sizeof(S_DataApplicationCapability));
+        for (i = 0;i < x->size_of_centralizedData;++i)
+        {
+            Decode_DataApplicationCapability(x->centralizedData + i, stream);
+        }
+    }
+    if (x->option_of_distributedData)
+    {
+        x->size_of_distributedData = (uint16) GetLengthDet(stream);
+        x->distributedData = (PS_DataApplicationCapability)
+                             OSCL_DEFAULT_MALLOC(x->size_of_distributedData * sizeof(S_DataApplicationCapability));
+        for (i = 0;i < x->size_of_distributedData;++i)
+        {
+            Decode_DataApplicationCapability(x->distributedData + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MediaDistributionCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for VideoCapability (CHOICE)  */
+/* <========================================> */
+void Decode_VideoCapability(PS_VideoCapability x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->h261VideoCapability = (PS_H261VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H261VideoCapability));
+            Decode_H261VideoCapability(x->h261VideoCapability, stream);
+            break;
+        case 2:
+            x->h262VideoCapability = (PS_H262VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H262VideoCapability));
+            Decode_H262VideoCapability(x->h262VideoCapability, stream);
+            break;
+        case 3:
+            x->h263VideoCapability = (PS_H263VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoCapability));
+            Decode_H263VideoCapability(x->h263VideoCapability, stream);
+            break;
+        case 4:
+            x->is11172VideoCapability = (PS_IS11172VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_IS11172VideoCapability));
+            Decode_IS11172VideoCapability(x->is11172VideoCapability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            GetLengthDet(stream);
+            x->genericVideoCapability = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericVideoCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_VideoCapability: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for H261VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Decode_H261VideoCapability(PS_H261VideoCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_qcifMPI = GetBoolean(stream);
+    x->option_of_cifMPI = GetBoolean(stream);
+    if (x->option_of_qcifMPI)
+    {
+        x->qcifMPI = (uint8) GetInteger(1, 4, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        x->cifMPI = (uint8) GetInteger(1, 4, stream);
+    }
+    x->temporalSpatialTradeOffCapability = GetBoolean(stream);
+    x->maxBitRate = (uint16) GetInteger(1, 19200, stream);
+    x->stillImageTransmission = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H261VideoCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for H262VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Decode_H262VideoCapability(PS_H262VideoCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_videoBitRate = GetBoolean(stream);
+    x->option_of_vbvBufferSize = GetBoolean(stream);
+    x->option_of_samplesPerLine = GetBoolean(stream);
+    x->option_of_linesPerFrame = GetBoolean(stream);
+    x->option_of_framesPerSecond = GetBoolean(stream);
+    x->option_of_luminanceSampleRate = GetBoolean(stream);
+    x->profileAndLevel_SPatML = GetBoolean(stream);
+    x->profileAndLevel_MPatLL = GetBoolean(stream);
+    x->profileAndLevel_MPatML = GetBoolean(stream);
+    x->profileAndLevel_MPatH_14 = GetBoolean(stream);
+    x->profileAndLevel_MPatHL = GetBoolean(stream);
+    x->profileAndLevel_SNRatLL = GetBoolean(stream);
+    x->profileAndLevel_SNRatML = GetBoolean(stream);
+    x->profileAndLevel_SpatialatH_14 = GetBoolean(stream);
+    x->profileAndLevel_HPatML = GetBoolean(stream);
+    x->profileAndLevel_HPatH_14 = GetBoolean(stream);
+    x->profileAndLevel_HPatHL = GetBoolean(stream);
+    if (x->option_of_videoBitRate)
+    {
+        x->videoBitRate = GetInteger(0, 1073741823, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        x->vbvBufferSize = GetInteger(0, 262143, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        x->samplesPerLine = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        x->linesPerFrame = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_framesPerSecond)
+    {
+        x->framesPerSecond = (uint8) GetInteger(0, 15, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        x->luminanceSampleRate = GetInteger(0, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H262VideoCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for H263VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Decode_H263VideoCapability(PS_H263VideoCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_sqcifMPI = GetBoolean(stream);
+    x->option_of_qcifMPI = GetBoolean(stream);
+    x->option_of_cifMPI = GetBoolean(stream);
+    x->option_of_cif4MPI = GetBoolean(stream);
+    x->option_of_cif16MPI = GetBoolean(stream);
+    x->option_of_hrd_B = GetBoolean(stream);
+    x->option_of_bppMaxKb = GetBoolean(stream);
+    if (x->option_of_sqcifMPI)
+    {
+        x->sqcifMPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        x->qcifMPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        x->cifMPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        x->cif4MPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        x->cif16MPI = (uint8) GetInteger(1, 32, stream);
+    }
+    x->maxBitRate = GetInteger(1, 192400, stream);
+    x->unrestrictedVector = GetBoolean(stream);
+    x->arithmeticCoding = GetBoolean(stream);
+    x->advancedPrediction = GetBoolean(stream);
+    x->pbFrames = GetBoolean(stream);
+    x->temporalSpatialTradeOffCapability = GetBoolean(stream);
+    if (x->option_of_hrd_B)
+    {
+        x->hrd_B = GetInteger(0, 524287, stream);
+    }
+    if (x->option_of_bppMaxKb)
+    {
+        x->bppMaxKb = (uint16) GetInteger(0, 65535, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_slowSqcifMPI = OFF;
+    x->option_of_slowQcifMPI = OFF;
+    x->option_of_slowCifMPI = OFF;
+    x->option_of_slowCif4MPI = OFF;
+    x->option_of_slowCif16MPI = OFF;
+    x->option_of_errorCompensation = OFF;
+    x->option_of_enhancementLayerInfo = OFF;
+    x->option_of_h263Options = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_slowSqcifMPI = SigMapValue(0, map);
+        if (x->option_of_slowSqcifMPI)
+        {
+            ExtensionPrep(map, stream);
+            x->slowSqcifMPI = (uint16) GetInteger(1, 3600, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_slowQcifMPI = SigMapValue(1, map);
+        if (x->option_of_slowQcifMPI)
+        {
+            ExtensionPrep(map, stream);
+            x->slowQcifMPI = (uint16) GetInteger(1, 3600, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_slowCifMPI = SigMapValue(2, map);
+        if (x->option_of_slowCifMPI)
+        {
+            ExtensionPrep(map, stream);
+            x->slowCifMPI = (uint16) GetInteger(1, 3600, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_slowCif4MPI = SigMapValue(3, map);
+        if (x->option_of_slowCif4MPI)
+        {
+            ExtensionPrep(map, stream);
+            x->slowCif4MPI = (uint16) GetInteger(1, 3600, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_slowCif16MPI = SigMapValue(4, map);
+        if (x->option_of_slowCif16MPI)
+        {
+            ExtensionPrep(map, stream);
+            x->slowCif16MPI = (uint16) GetInteger(1, 3600, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_errorCompensation = SigMapValue(5, map);
+        if (x->option_of_errorCompensation)
+        {
+            ExtensionPrep(map, stream);
+            x->errorCompensation = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_enhancementLayerInfo = SigMapValue(6, map);
+        if (x->option_of_enhancementLayerInfo)
+        {
+            ExtensionPrep(map, stream);
+            Decode_EnhancementLayerInfo(&x->enhancementLayerInfo, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_h263Options = SigMapValue(7, map);
+        if (x->option_of_h263Options)
+        {
+            ExtensionPrep(map, stream);
+            Decode_H263Options(&x->h263Options, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H263VideoCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for EnhancementLayerInfo (SEQUENCE)  */
+/* <===============================================> */
+void Decode_EnhancementLayerInfo(PS_EnhancementLayerInfo x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_snrEnhancement = GetBoolean(stream);
+    x->option_of_spatialEnhancement = GetBoolean(stream);
+    x->option_of_bPictureEnhancement = GetBoolean(stream);
+    x->baseBitRateConstrained = GetBoolean(stream);
+    if (x->option_of_snrEnhancement)
+    {
+        x->size_of_snrEnhancement = (uint8) GetInteger(1, 14, stream);
+        x->snrEnhancement = (PS_EnhancementOptions)
+                            OSCL_DEFAULT_MALLOC(x->size_of_snrEnhancement * sizeof(S_EnhancementOptions));
+        for (i = 0;i < x->size_of_snrEnhancement;++i)
+        {
+            Decode_EnhancementOptions(x->snrEnhancement + i, stream);
+        }
+    }
+    if (x->option_of_spatialEnhancement)
+    {
+        x->size_of_spatialEnhancement = (uint8) GetInteger(1, 14, stream);
+        x->spatialEnhancement = (PS_EnhancementOptions)
+                                OSCL_DEFAULT_MALLOC(x->size_of_spatialEnhancement * sizeof(S_EnhancementOptions));
+        for (i = 0;i < x->size_of_spatialEnhancement;++i)
+        {
+            Decode_EnhancementOptions(x->spatialEnhancement + i, stream);
+        }
+    }
+    if (x->option_of_bPictureEnhancement)
+    {
+        x->size_of_bPictureEnhancement = (uint8) GetInteger(1, 14, stream);
+        x->bPictureEnhancement = (PS_BEnhancementParameters)
+                                 OSCL_DEFAULT_MALLOC(x->size_of_bPictureEnhancement * sizeof(S_BEnhancementParameters));
+        for (i = 0;i < x->size_of_bPictureEnhancement;++i)
+        {
+            Decode_BEnhancementParameters(x->bPictureEnhancement + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_EnhancementLayerInfo: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for BEnhancementParameters (SEQUENCE)  */
+/* <=================================================> */
+void Decode_BEnhancementParameters(PS_BEnhancementParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_EnhancementOptions(&x->enhancementOptions, stream);
+    x->numberOfBPictures = (uint8) GetInteger(1, 64, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_BEnhancementParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for EnhancementOptions (SEQUENCE)  */
+/* <=============================================> */
+void Decode_EnhancementOptions(PS_EnhancementOptions x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_sqcifMPI = GetBoolean(stream);
+    x->option_of_qcifMPI = GetBoolean(stream);
+    x->option_of_cifMPI = GetBoolean(stream);
+    x->option_of_cif4MPI = GetBoolean(stream);
+    x->option_of_cif16MPI = GetBoolean(stream);
+    x->option_of_slowSqcifMPI = GetBoolean(stream);
+    x->option_of_slowQcifMPI = GetBoolean(stream);
+    x->option_of_slowCifMPI = GetBoolean(stream);
+    x->option_of_slowCif4MPI = GetBoolean(stream);
+    x->option_of_slowCif16MPI = GetBoolean(stream);
+    x->option_of_h263Options = GetBoolean(stream);
+    if (x->option_of_sqcifMPI)
+    {
+        x->sqcifMPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        x->qcifMPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        x->cifMPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        x->cif4MPI = (uint8) GetInteger(1, 32, stream);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        x->cif16MPI = (uint8) GetInteger(1, 32, stream);
+    }
+    x->maxBitRate = GetInteger(1, 192400, stream);
+    x->unrestrictedVector = GetBoolean(stream);
+    x->arithmeticCoding = GetBoolean(stream);
+    x->temporalSpatialTradeOffCapability = GetBoolean(stream);
+    if (x->option_of_slowSqcifMPI)
+    {
+        x->slowSqcifMPI = (uint16) GetInteger(1, 3600, stream);
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+        x->slowQcifMPI = (uint16) GetInteger(1, 3600, stream);
+    }
+    if (x->option_of_slowCifMPI)
+    {
+        x->slowCifMPI = (uint16) GetInteger(1, 3600, stream);
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+        x->slowCif4MPI = (uint16) GetInteger(1, 3600, stream);
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+        x->slowCif16MPI = (uint16) GetInteger(1, 3600, stream);
+    }
+    x->errorCompensation = GetBoolean(stream);
+    if (x->option_of_h263Options)
+    {
+        Decode_H263Options(&x->h263Options, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_EnhancementOptions: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for H263Options (SEQUENCE)  */
+/* <======================================> */
+void Decode_H263Options(PS_H263Options x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_transparencyParameters = GetBoolean(stream);
+    x->option_of_refPictureSelection = GetBoolean(stream);
+    x->option_of_customPictureClockFrequency = GetBoolean(stream);
+    x->option_of_customPictureFormat = GetBoolean(stream);
+    x->option_of_modeCombos = GetBoolean(stream);
+    x->advancedIntraCodingMode = GetBoolean(stream);
+    x->deblockingFilterMode = GetBoolean(stream);
+    x->improvedPBFramesMode = GetBoolean(stream);
+    x->unlimitedMotionVectors = GetBoolean(stream);
+    x->fullPictureFreeze = GetBoolean(stream);
+    x->partialPictureFreezeAndRelease = GetBoolean(stream);
+    x->resizingPartPicFreezeAndRelease = GetBoolean(stream);
+    x->fullPictureSnapshot = GetBoolean(stream);
+    x->partialPictureSnapshot = GetBoolean(stream);
+    x->videoSegmentTagging = GetBoolean(stream);
+    x->progressiveRefinement = GetBoolean(stream);
+    x->dynamicPictureResizingByFour = GetBoolean(stream);
+    x->dynamicPictureResizingSixteenthPel = GetBoolean(stream);
+    x->dynamicWarpingHalfPel = GetBoolean(stream);
+    x->dynamicWarpingSixteenthPel = GetBoolean(stream);
+    x->independentSegmentDecoding = GetBoolean(stream);
+    x->slicesInOrder_NonRect = GetBoolean(stream);
+    x->slicesInOrder_Rect = GetBoolean(stream);
+    x->slicesNoOrder_NonRect = GetBoolean(stream);
+    x->slicesNoOrder_Rect = GetBoolean(stream);
+    x->alternateInterVLCMode = GetBoolean(stream);
+    x->modifiedQuantizationMode = GetBoolean(stream);
+    x->reducedResolutionUpdate = GetBoolean(stream);
+    if (x->option_of_transparencyParameters)
+    {
+        Decode_TransparencyParameters(&x->transparencyParameters, stream);
+    }
+    x->separateVideoBackChannel = GetBoolean(stream);
+    if (x->option_of_refPictureSelection)
+    {
+        Decode_RefPictureSelection(&x->refPictureSelection, stream);
+    }
+    if (x->option_of_customPictureClockFrequency)
+    {
+        x->size_of_customPictureClockFrequency = (uint8) GetInteger(1, 16, stream);
+        x->customPictureClockFrequency = (PS_CustomPictureClockFrequency)
+                                         OSCL_DEFAULT_MALLOC(x->size_of_customPictureClockFrequency * sizeof(S_CustomPictureClockFrequency));
+        for (i = 0;i < x->size_of_customPictureClockFrequency;++i)
+        {
+            Decode_CustomPictureClockFrequency(x->customPictureClockFrequency + i, stream);
+        }
+    }
+    if (x->option_of_customPictureFormat)
+    {
+        x->size_of_customPictureFormat = (uint8) GetInteger(1, 16, stream);
+        x->customPictureFormat = (PS_CustomPictureFormat)
+                                 OSCL_DEFAULT_MALLOC(x->size_of_customPictureFormat * sizeof(S_CustomPictureFormat));
+        for (i = 0;i < x->size_of_customPictureFormat;++i)
+        {
+            Decode_CustomPictureFormat(x->customPictureFormat + i, stream);
+        }
+    }
+    if (x->option_of_modeCombos)
+    {
+        x->size_of_modeCombos = (uint8) GetInteger(1, 16, stream);
+        x->modeCombos = (PS_H263VideoModeCombos)
+                        OSCL_DEFAULT_MALLOC(x->size_of_modeCombos * sizeof(S_H263VideoModeCombos));
+        for (i = 0;i < x->size_of_modeCombos;++i)
+        {
+            Decode_H263VideoModeCombos(x->modeCombos + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H263Options: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for TransparencyParameters (SEQUENCE)  */
+/* <=================================================> */
+void Decode_TransparencyParameters(PS_TransparencyParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->presentationOrder = (uint16) GetInteger(1, 256, stream);
+    x->offset_x = GetSignedInteger(-262144, 262143, stream);
+    x->offset_y = GetSignedInteger(-262144, 262143, stream);
+    x->scale_x = (uint8) GetInteger(1, 255, stream);
+    x->scale_y = (uint8) GetInteger(1, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TransparencyParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for RefPictureSelection (SEQUENCE)  */
+/* <==============================================> */
+void Decode_RefPictureSelection(PS_RefPictureSelection x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_additionalPictureMemory = GetBoolean(stream);
+    if (x->option_of_additionalPictureMemory)
+    {
+        Decode_AdditionalPictureMemory(&x->additionalPictureMemory, stream);
+    }
+    x->videoMux = GetBoolean(stream);
+    Decode_VideoBackChannelSend(&x->videoBackChannelSend, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RefPictureSelection: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for VideoBackChannelSend (CHOICE)  */
+/* <=============================================> */
+void Decode_VideoBackChannelSend(PS_VideoBackChannelSend x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (none is NULL) */
+            break;
+        case 1:
+            /* (ackMessageOnly is NULL) */
+            break;
+        case 2:
+            /* (nackMessageOnly is NULL) */
+            break;
+        case 3:
+            /* (ackOrNackMessageOnly is NULL) */
+            break;
+        case 4:
+            /* (ackAndNackMessage is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_VideoBackChannelSend: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for AdditionalPictureMemory (SEQUENCE)  */
+/* <==================================================> */
+void Decode_AdditionalPictureMemory(PS_AdditionalPictureMemory x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_sqcifAdditionalPictureMemory = GetBoolean(stream);
+    x->option_of_qcifAdditionalPictureMemory = GetBoolean(stream);
+    x->option_of_cifAdditionalPictureMemory = GetBoolean(stream);
+    x->option_of_cif4AdditionalPictureMemory = GetBoolean(stream);
+    x->option_of_cif16AdditionalPictureMemory = GetBoolean(stream);
+    x->option_of_bigCpfAdditionalPictureMemory = GetBoolean(stream);
+    if (x->option_of_sqcifAdditionalPictureMemory)
+    {
+        x->sqcifAdditionalPictureMemory = (uint16) GetInteger(1, 256, stream);
+    }
+    if (x->option_of_qcifAdditionalPictureMemory)
+    {
+        x->qcifAdditionalPictureMemory = (uint16) GetInteger(1, 256, stream);
+    }
+    if (x->option_of_cifAdditionalPictureMemory)
+    {
+        x->cifAdditionalPictureMemory = (uint16) GetInteger(1, 256, stream);
+    }
+    if (x->option_of_cif4AdditionalPictureMemory)
+    {
+        x->cif4AdditionalPictureMemory = (uint16) GetInteger(1, 256, stream);
+    }
+    if (x->option_of_cif16AdditionalPictureMemory)
+    {
+        x->cif16AdditionalPictureMemory = (uint16) GetInteger(1, 256, stream);
+    }
+    if (x->option_of_bigCpfAdditionalPictureMemory)
+    {
+        x->bigCpfAdditionalPictureMemory = (uint16) GetInteger(1, 256, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_AdditionalPictureMemory: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for CustomPictureClockFrequency (SEQUENCE)  */
+/* <======================================================> */
+void Decode_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_sqcifMPI = GetBoolean(stream);
+    x->option_of_qcifMPI = GetBoolean(stream);
+    x->option_of_cifMPI = GetBoolean(stream);
+    x->option_of_cif4MPI = GetBoolean(stream);
+    x->option_of_cif16MPI = GetBoolean(stream);
+    x->clockConversionCode = (uint16) GetInteger(1000, 1001, stream);
+    x->clockDivisor = (uint8) GetInteger(1, 127, stream);
+    if (x->option_of_sqcifMPI)
+    {
+        x->sqcifMPI = (uint16) GetInteger(1, 2048, stream);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        x->qcifMPI = (uint16) GetInteger(1, 2048, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        x->cifMPI = (uint16) GetInteger(1, 2048, stream);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        x->cif4MPI = (uint16) GetInteger(1, 2048, stream);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        x->cif16MPI = (uint16) GetInteger(1, 2048, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CustomPictureClockFrequency: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for CustomPictureFormat (SEQUENCE)  */
+/* <==============================================> */
+void Decode_CustomPictureFormat(PS_CustomPictureFormat x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->maxCustomPictureWidth = (uint16) GetInteger(1, 2048, stream);
+    x->maxCustomPictureHeight = (uint16) GetInteger(1, 2048, stream);
+    x->minCustomPictureWidth = (uint16) GetInteger(1, 2048, stream);
+    x->minCustomPictureHeight = (uint16) GetInteger(1, 2048, stream);
+    Decode_MPI(&x->mPI, stream);
+    Decode_PixelAspectInformation(&x->pixelAspectInformation, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CustomPictureFormat: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for PixelAspectInformation (CHOICE)  */
+/* <===============================================> */
+void Decode_PixelAspectInformation(PS_PixelAspectInformation x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->anyPixelAspectRatio = GetBoolean(stream);
+            break;
+        case 1:
+            x->size = (uint8) GetInteger(1, 14, stream);
+            x->pixelAspectCode = (uint32*) OSCL_DEFAULT_MALLOC(x->size * sizeof(uint32));
+            for (i = 0;i < x->size;++i)
+            {
+                x->pixelAspectCode[i] = GetInteger(1, 14, stream);
+            }
+            break;
+        case 2:
+            x->size = (uint16) GetInteger(1, 256, stream);
+            x->extendedPAR = (PS_ExtendedPARItem)
+                             OSCL_DEFAULT_MALLOC(x->size * sizeof(S_ExtendedPARItem));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_ExtendedPARItem(x->extendedPAR + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_PixelAspectInformation: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for ExtendedPARItem (SEQUENCE)  */
+/* <==========================================> */
+void Decode_ExtendedPARItem(PS_ExtendedPARItem x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->width = (uint8) GetInteger(1, 255, stream);
+    x->height = (uint8) GetInteger(1, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ExtendedPARItem: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================> */
+/*  PER-Decoder for MPI (SEQUENCE)  */
+/* <==============================> */
+void Decode_MPI(PS_MPI x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_standardMPI = GetBoolean(stream);
+    x->option_of_customPCF = GetBoolean(stream);
+    if (x->option_of_standardMPI)
+    {
+        x->standardMPI = (uint8) GetInteger(1, 31, stream);
+    }
+    if (x->option_of_customPCF)
+    {
+        x->size_of_customPCF = (uint8) GetInteger(1, 16, stream);
+        x->customPCF = (PS_CustomPCFItem)
+                       OSCL_DEFAULT_MALLOC(x->size_of_customPCF * sizeof(S_CustomPCFItem));
+        for (i = 0;i < x->size_of_customPCF;++i)
+        {
+            Decode_CustomPCFItem(x->customPCF + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MPI: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for CustomPCFItem (SEQUENCE)  */
+/* <========================================> */
+void Decode_CustomPCFItem(PS_CustomPCFItem x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->clockConversionCode = (uint16) GetInteger(1000, 1001, stream);
+    x->clockDivisor = (uint8) GetInteger(1, 127, stream);
+    x->customMPI = (uint16) GetInteger(1, 2048, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CustomPCFItem: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for H263VideoModeCombos (SEQUENCE)  */
+/* <==============================================> */
+void Decode_H263VideoModeCombos(PS_H263VideoModeCombos x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_H263ModeComboFlags(&x->h263VideoUncoupledModes, stream);
+    x->size_of_h263VideoCoupledModes = (uint8) GetInteger(1, 16, stream);
+    x->h263VideoCoupledModes = (PS_H263ModeComboFlags)
+                               OSCL_DEFAULT_MALLOC(x->size_of_h263VideoCoupledModes * sizeof(S_H263ModeComboFlags));
+    for (i = 0;i < x->size_of_h263VideoCoupledModes;++i)
+    {
+        Decode_H263ModeComboFlags(x->h263VideoCoupledModes + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H263VideoModeCombos: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H263ModeComboFlags (SEQUENCE)  */
+/* <=============================================> */
+void Decode_H263ModeComboFlags(PS_H263ModeComboFlags x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->unrestrictedVector = GetBoolean(stream);
+    x->arithmeticCoding = GetBoolean(stream);
+    x->advancedPrediction = GetBoolean(stream);
+    x->pbFrames = GetBoolean(stream);
+    x->advancedIntraCodingMode = GetBoolean(stream);
+    x->deblockingFilterMode = GetBoolean(stream);
+    x->unlimitedMotionVectors = GetBoolean(stream);
+    x->slicesInOrder_NonRect = GetBoolean(stream);
+    x->slicesInOrder_Rect = GetBoolean(stream);
+    x->slicesNoOrder_NonRect = GetBoolean(stream);
+    x->slicesNoOrder_Rect = GetBoolean(stream);
+    x->improvedPBFramesMode = GetBoolean(stream);
+    x->referencePicSelect = GetBoolean(stream);
+    x->dynamicPictureResizingByFour = GetBoolean(stream);
+    x->dynamicPictureResizingSixteenthPel = GetBoolean(stream);
+    x->dynamicWarpingHalfPel = GetBoolean(stream);
+    x->dynamicWarpingSixteenthPel = GetBoolean(stream);
+    x->reducedResolutionUpdate = GetBoolean(stream);
+    x->independentSegmentDecoding = GetBoolean(stream);
+    x->alternateInterVLCMode = GetBoolean(stream);
+    x->modifiedQuantizationMode = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H263ModeComboFlags: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for IS11172VideoCapability (SEQUENCE)  */
+/* <=================================================> */
+void Decode_IS11172VideoCapability(PS_IS11172VideoCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_videoBitRate = GetBoolean(stream);
+    x->option_of_vbvBufferSize = GetBoolean(stream);
+    x->option_of_samplesPerLine = GetBoolean(stream);
+    x->option_of_linesPerFrame = GetBoolean(stream);
+    x->option_of_pictureRate = GetBoolean(stream);
+    x->option_of_luminanceSampleRate = GetBoolean(stream);
+    x->constrainedBitstream = GetBoolean(stream);
+    if (x->option_of_videoBitRate)
+    {
+        x->videoBitRate = GetInteger(0, 1073741823, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        x->vbvBufferSize = GetInteger(0, 262143, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        x->samplesPerLine = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        x->linesPerFrame = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_pictureRate)
+    {
+        x->pictureRate = (uint8) GetInteger(0, 15, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        x->luminanceSampleRate = GetInteger(0, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IS11172VideoCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for AudioCapability (CHOICE)  */
+/* <========================================> */
+void Decode_AudioCapability(PS_AudioCapability x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(14, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->g711Alaw64k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 2:
+            x->g711Alaw56k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 3:
+            x->g711Ulaw64k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 4:
+            x->g711Ulaw56k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 5:
+            x->g722_64k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 6:
+            x->g722_56k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 7:
+            x->g722_48k = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 8:
+            x->g7231 = (PS_G7231) OSCL_DEFAULT_MALLOC(sizeof(S_G7231));
+            Decode_G7231(x->g7231, stream);
+            break;
+        case 9:
+            x->g728 = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 10:
+            x->g729 = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 11:
+            x->g729AnnexA = (uint16) GetInteger(1, 256, stream);
+            break;
+        case 12:
+            x->is11172AudioCapability = (PS_IS11172AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_IS11172AudioCapability));
+            Decode_IS11172AudioCapability(x->is11172AudioCapability, stream);
+            break;
+        case 13:
+            x->is13818AudioCapability = (PS_IS13818AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_IS13818AudioCapability));
+            Decode_IS13818AudioCapability(x->is13818AudioCapability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            GetLengthDet(stream);
+            x->g729wAnnexB = (uint16) GetInteger(1, 256, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            x->g729AnnexAwAnnexB = (uint16) GetInteger(1, 256, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 16:
+            GetLengthDet(stream);
+            x->g7231AnnexCCapability = (PS_G7231AnnexCCapability) OSCL_DEFAULT_MALLOC(sizeof(S_G7231AnnexCCapability));
+            Decode_G7231AnnexCCapability(x->g7231AnnexCCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 17:
+            GetLengthDet(stream);
+            x->gsmFullRate = (PS_GSMAudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GSMAudioCapability));
+            Decode_GSMAudioCapability(x->gsmFullRate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 18:
+            GetLengthDet(stream);
+            x->gsmHalfRate = (PS_GSMAudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GSMAudioCapability));
+            Decode_GSMAudioCapability(x->gsmHalfRate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 19:
+            GetLengthDet(stream);
+            x->gsmEnhancedFullRate = (PS_GSMAudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GSMAudioCapability));
+            Decode_GSMAudioCapability(x->gsmEnhancedFullRate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 20:
+            GetLengthDet(stream);
+            x->genericAudioCapability = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericAudioCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 21:
+            GetLengthDet(stream);
+            x->g729Extensions = (PS_G729Extensions) OSCL_DEFAULT_MALLOC(sizeof(S_G729Extensions));
+            Decode_G729Extensions(x->g729Extensions, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_AudioCapability: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for G7231 (SEQUENCE)  */
+/* <================================> */
+void Decode_G7231(PS_G7231 x, PS_InStream stream)
+{
+    x->maxAl_sduAudioFrames = (uint16) GetInteger(1, 256, stream);
+    x->silenceSuppression = GetBoolean(stream);
+}
+
+/* <=========================================> */
+/*  PER-Decoder for G729Extensions (SEQUENCE)  */
+/* <=========================================> */
+void Decode_G729Extensions(PS_G729Extensions x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_audioUnit = GetBoolean(stream);
+    if (x->option_of_audioUnit)
+    {
+        x->audioUnit = (uint16) GetInteger(1, 256, stream);
+    }
+    x->annexA = GetBoolean(stream);
+    x->annexB = GetBoolean(stream);
+    x->annexD = GetBoolean(stream);
+    x->annexE = GetBoolean(stream);
+    x->annexF = GetBoolean(stream);
+    x->annexG = GetBoolean(stream);
+    x->annexH = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_G729Extensions: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for G7231AnnexCCapability (SEQUENCE)  */
+/* <================================================> */
+void Decode_G7231AnnexCCapability(PS_G7231AnnexCCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_g723AnnexCAudioMode = GetBoolean(stream);
+    x->maxAl_sduAudioFrames = (uint16) GetInteger(1, 256, stream);
+    x->silenceSuppression = GetBoolean(stream);
+    if (x->option_of_g723AnnexCAudioMode)
+    {
+        Decode_G723AnnexCAudioMode(&x->g723AnnexCAudioMode, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_G7231AnnexCCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for G723AnnexCAudioMode (SEQUENCE)  */
+/* <==============================================> */
+void Decode_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->highRateMode0 = (uint8) GetInteger(27, 78, stream);
+    x->highRateMode1 = (uint8) GetInteger(27, 78, stream);
+    x->lowRateMode0 = (uint8) GetInteger(23, 66, stream);
+    x->lowRateMode1 = (uint8) GetInteger(23, 66, stream);
+    x->sidMode0 = (uint8) GetInteger(6, 17, stream);
+    x->sidMode1 = (uint8) GetInteger(6, 17, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_G723AnnexCAudioMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for IS11172AudioCapability (SEQUENCE)  */
+/* <=================================================> */
+void Decode_IS11172AudioCapability(PS_IS11172AudioCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->audioLayer1 = GetBoolean(stream);
+    x->audioLayer2 = GetBoolean(stream);
+    x->audioLayer3 = GetBoolean(stream);
+    x->audioSampling32k = GetBoolean(stream);
+    x->audioSampling44k1 = GetBoolean(stream);
+    x->audioSampling48k = GetBoolean(stream);
+    x->singleChannel = GetBoolean(stream);
+    x->twoChannels = GetBoolean(stream);
+    x->bitRate = (uint16) GetInteger(1, 448, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IS11172AudioCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for IS13818AudioCapability (SEQUENCE)  */
+/* <=================================================> */
+void Decode_IS13818AudioCapability(PS_IS13818AudioCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->audioLayer1 = GetBoolean(stream);
+    x->audioLayer2 = GetBoolean(stream);
+    x->audioLayer3 = GetBoolean(stream);
+    x->audioSampling16k = GetBoolean(stream);
+    x->audioSampling22k05 = GetBoolean(stream);
+    x->audioSampling24k = GetBoolean(stream);
+    x->audioSampling32k = GetBoolean(stream);
+    x->audioSampling44k1 = GetBoolean(stream);
+    x->audioSampling48k = GetBoolean(stream);
+    x->singleChannel = GetBoolean(stream);
+    x->twoChannels = GetBoolean(stream);
+    x->threeChannels2_1 = GetBoolean(stream);
+    x->threeChannels3_0 = GetBoolean(stream);
+    x->fourChannels2_0_2_0 = GetBoolean(stream);
+    x->fourChannels2_2 = GetBoolean(stream);
+    x->fourChannels3_1 = GetBoolean(stream);
+    x->fiveChannels3_0_2_0 = GetBoolean(stream);
+    x->fiveChannels3_2 = GetBoolean(stream);
+    x->lowFrequencyEnhancement = GetBoolean(stream);
+    x->multilingual = GetBoolean(stream);
+    x->bitRate = (uint16) GetInteger(1, 1130, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IS13818AudioCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for GSMAudioCapability (SEQUENCE)  */
+/* <=============================================> */
+void Decode_GSMAudioCapability(PS_GSMAudioCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->audioUnitSize = (uint16) GetInteger(1, 256, stream);
+    x->comfortNoise = GetBoolean(stream);
+    x->scrambled = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_GSMAudioCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for DataApplicationCapability (SEQUENCE)  */
+/* <====================================================> */
+void Decode_DataApplicationCapability(PS_DataApplicationCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_Application(&x->application, stream);
+    x->maxBitRate = GetInteger(0, 0xffffffff, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_DataApplicationCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for Application (CHOICE)  */
+/* <====================================> */
+void Decode_Application(PS_Application x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(10, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->t120 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t120, stream);
+            break;
+        case 2:
+            x->dsm_cc = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->dsm_cc, stream);
+            break;
+        case 3:
+            x->userData = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->userData, stream);
+            break;
+        case 4:
+            x->t84 = (PS_T84) OSCL_DEFAULT_MALLOC(sizeof(S_T84));
+            Decode_T84(x->t84, stream);
+            break;
+        case 5:
+            x->t434 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t434, stream);
+            break;
+        case 6:
+            x->h224 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->h224, stream);
+            break;
+        case 7:
+            x->nlpid = (PS_Nlpid) OSCL_DEFAULT_MALLOC(sizeof(S_Nlpid));
+            Decode_Nlpid(x->nlpid, stream);
+            break;
+        case 8:
+            /* (dsvdControl is NULL) */
+            break;
+        case 9:
+            x->h222DataPartitioning = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->h222DataPartitioning, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            GetLengthDet(stream);
+            x->t30fax = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t30fax, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->t140 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t140, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->t38fax = (PS_T38fax) OSCL_DEFAULT_MALLOC(sizeof(S_T38fax));
+            Decode_T38fax(x->t38fax, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->genericDataCapability = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericDataCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_Application: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for T38fax (SEQUENCE)  */
+/* <=================================> */
+void Decode_T38fax(PS_T38fax x, PS_InStream stream)
+{
+    Decode_DataProtocolCapability(&x->t38FaxProtocol, stream);
+    Decode_T38FaxProfile(&x->t38FaxProfile, stream);
+}
+
+/* <================================> */
+/*  PER-Decoder for Nlpid (SEQUENCE)  */
+/* <================================> */
+void Decode_Nlpid(PS_Nlpid x, PS_InStream stream)
+{
+    Decode_DataProtocolCapability(&x->nlpidProtocol, stream);
+    GetOctetString(1, 0, 0, &x->nlpidData, stream);
+}
+
+/* <==============================> */
+/*  PER-Decoder for T84 (SEQUENCE)  */
+/* <==============================> */
+void Decode_T84(PS_T84 x, PS_InStream stream)
+{
+    Decode_DataProtocolCapability(&x->t84Protocol, stream);
+    Decode_T84Profile(&x->t84Profile, stream);
+}
+
+/* <===============================================> */
+/*  PER-Decoder for DataProtocolCapability (CHOICE)  */
+/* <===============================================> */
+void Decode_DataProtocolCapability(PS_DataProtocolCapability x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(7, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (v14buffered is NULL) */
+            break;
+        case 2:
+            /* (v42lapm is NULL) */
+            break;
+        case 3:
+            /* (hdlcFrameTunnelling is NULL) */
+            break;
+        case 4:
+            /* (h310SeparateVCStack is NULL) */
+            break;
+        case 5:
+            /* (h310SingleVCStack is NULL) */
+            break;
+        case 6:
+            /* (transparent is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            GetLengthDet(stream);
+            /* (segmentationAndReassembly is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 8:
+            GetLengthDet(stream);
+            /* (hdlcFrameTunnelingwSAR is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 9:
+            GetLengthDet(stream);
+            /* (v120 is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 10:
+            GetLengthDet(stream);
+            /* (separateLANStack is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->v76wCompression = (PS_V76wCompression) OSCL_DEFAULT_MALLOC(sizeof(S_V76wCompression));
+            Decode_V76wCompression(x->v76wCompression, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            /* (tcp is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            /* (udp is NULL) */
+            SkipOneOctet(stream);
+            break;
+        default:
+            ErrorMessage("Decode_DataProtocolCapability: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for V76wCompression (CHOICE)  */
+/* <========================================> */
+void Decode_V76wCompression(PS_V76wCompression x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->transmitCompression = (PS_CompressionType) OSCL_DEFAULT_MALLOC(sizeof(S_CompressionType));
+            Decode_CompressionType(x->transmitCompression, stream);
+            break;
+        case 1:
+            x->receiveCompression = (PS_CompressionType) OSCL_DEFAULT_MALLOC(sizeof(S_CompressionType));
+            Decode_CompressionType(x->receiveCompression, stream);
+            break;
+        case 2:
+            x->transmitAndReceiveCompression = (PS_CompressionType) OSCL_DEFAULT_MALLOC(sizeof(S_CompressionType));
+            Decode_CompressionType(x->transmitAndReceiveCompression, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_V76wCompression: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for CompressionType (CHOICE)  */
+/* <========================================> */
+void Decode_CompressionType(PS_CompressionType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->v42bis = (PS_V42bis) OSCL_DEFAULT_MALLOC(sizeof(S_V42bis));
+            Decode_V42bis(x->v42bis, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CompressionType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for V42bis (SEQUENCE)  */
+/* <=================================> */
+void Decode_V42bis(PS_V42bis x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->numberOfCodewords = GetInteger(1, 65536, stream);
+    x->maximumStringLength = (uint16) GetInteger(1, 256, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_V42bis: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for T84Profile (CHOICE)  */
+/* <===================================> */
+void Decode_T84Profile(PS_T84Profile x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (t84Unrestricted is NULL) */
+            break;
+        case 1:
+            x->t84Restricted = (PS_T84Restricted) OSCL_DEFAULT_MALLOC(sizeof(S_T84Restricted));
+            Decode_T84Restricted(x->t84Restricted, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_T84Profile: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for T84Restricted (SEQUENCE)  */
+/* <========================================> */
+void Decode_T84Restricted(PS_T84Restricted x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->qcif = GetBoolean(stream);
+    x->cif = GetBoolean(stream);
+    x->ccir601Seq = GetBoolean(stream);
+    x->ccir601Prog = GetBoolean(stream);
+    x->hdtvSeq = GetBoolean(stream);
+    x->hdtvProg = GetBoolean(stream);
+    x->g3FacsMH200x100 = GetBoolean(stream);
+    x->g3FacsMH200x200 = GetBoolean(stream);
+    x->g4FacsMMR200x100 = GetBoolean(stream);
+    x->g4FacsMMR200x200 = GetBoolean(stream);
+    x->jbig200x200Seq = GetBoolean(stream);
+    x->jbig200x200Prog = GetBoolean(stream);
+    x->jbig300x300Seq = GetBoolean(stream);
+    x->jbig300x300Prog = GetBoolean(stream);
+    x->digPhotoLow = GetBoolean(stream);
+    x->digPhotoMedSeq = GetBoolean(stream);
+    x->digPhotoMedProg = GetBoolean(stream);
+    x->digPhotoHighSeq = GetBoolean(stream);
+    x->digPhotoHighProg = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_T84Restricted: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for T38FaxProfile (SEQUENCE)  */
+/* <========================================> */
+void Decode_T38FaxProfile(PS_T38FaxProfile x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->fillBitRemoval = GetBoolean(stream);
+    x->transcodingJBIG = GetBoolean(stream);
+    x->transcodingMMR = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_version = OFF;
+    x->option_of_t38FaxRateManagement = OFF;
+    x->option_of_t38FaxUdpOptions = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_version = SigMapValue(0, map);
+        if (x->option_of_version)
+        {
+            ExtensionPrep(map, stream);
+            x->version = (uint8) GetInteger(0, 255, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_t38FaxRateManagement = SigMapValue(1, map);
+        if (x->option_of_t38FaxRateManagement)
+        {
+            ExtensionPrep(map, stream);
+            Decode_T38FaxRateManagement(&x->t38FaxRateManagement, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_t38FaxUdpOptions = SigMapValue(2, map);
+        if (x->option_of_t38FaxUdpOptions)
+        {
+            ExtensionPrep(map, stream);
+            Decode_T38FaxUdpOptions(&x->t38FaxUdpOptions, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_T38FaxProfile: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for T38FaxRateManagement (CHOICE)  */
+/* <=============================================> */
+void Decode_T38FaxRateManagement(PS_T38FaxRateManagement x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (localTCF is NULL) */
+            break;
+        case 1:
+            /* (transferredTCF is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_T38FaxRateManagement: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for T38FaxUdpOptions (SEQUENCE)  */
+/* <===========================================> */
+void Decode_T38FaxUdpOptions(PS_T38FaxUdpOptions x, PS_InStream stream)
+{
+    x->option_of_t38FaxMaxBuffer = GetBoolean(stream);
+    x->option_of_t38FaxMaxDatagram = GetBoolean(stream);
+    if (x->option_of_t38FaxMaxBuffer)
+    {
+        x->t38FaxMaxBuffer = GetUnboundedInteger(stream);
+    }
+    if (x->option_of_t38FaxMaxDatagram)
+    {
+        x->t38FaxMaxDatagram = GetUnboundedInteger(stream);
+    }
+    Decode_T38FaxUdpEC(&x->t38FaxUdpEC, stream);
+}
+
+/* <====================================> */
+/*  PER-Decoder for T38FaxUdpEC (CHOICE)  */
+/* <====================================> */
+void Decode_T38FaxUdpEC(PS_T38FaxUdpEC x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (t38UDPFEC is NULL) */
+            break;
+        case 1:
+            /* (t38UDPRedundancy is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_T38FaxUdpEC: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================================================> */
+/*  PER-Decoder for EncryptionAuthenticationAndIntegrity (SEQUENCE)  */
+/* <===============================================================> */
+void Decode_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_encryptionCapability = GetBoolean(stream);
+    x->option_of_authenticationCapability = GetBoolean(stream);
+    x->option_of_integrityCapability = GetBoolean(stream);
+    if (x->option_of_encryptionCapability)
+    {
+        Decode_EncryptionCapability(&x->encryptionCapability, stream);
+    }
+    if (x->option_of_authenticationCapability)
+    {
+        Decode_AuthenticationCapability(&x->authenticationCapability, stream);
+    }
+    if (x->option_of_integrityCapability)
+    {
+        Decode_IntegrityCapability(&x->integrityCapability, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_EncryptionAuthenticationAndIntegrity: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for EncryptionCapability (SEQUENCE-OF)  */
+/* <==================================================> */
+void Decode_EncryptionCapability(PS_EncryptionCapability x, PS_InStream stream)
+{
+    uint16 i;
+    x->size = (uint16) GetInteger(1, 256, stream);
+    x->item = (PS_MediaEncryptionAlgorithm)
+              OSCL_DEFAULT_MALLOC(x->size * sizeof(S_MediaEncryptionAlgorithm));
+    for (i = 0;i < x->size;++i)
+    {
+        Decode_MediaEncryptionAlgorithm(x->item + i, stream);
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for MediaEncryptionAlgorithm (CHOICE)  */
+/* <=================================================> */
+void Decode_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->algorithm = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            GetObjectID(x->algorithm, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MediaEncryptionAlgorithm: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for AuthenticationCapability (SEQUENCE)  */
+/* <===================================================> */
+void Decode_AuthenticationCapability(PS_AuthenticationCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        Decode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_AuthenticationCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for IntegrityCapability (SEQUENCE)  */
+/* <==============================================> */
+void Decode_IntegrityCapability(PS_IntegrityCapability x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        Decode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IntegrityCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for UserInputCapability (CHOICE)  */
+/* <============================================> */
+void Decode_UserInputCapability(PS_UserInputCapability x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(6, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->size = (uint8) GetInteger(1, 16, stream);
+            x->nonStandard = (PS_NonStandardParameter)
+                             OSCL_DEFAULT_MALLOC(x->size * sizeof(S_NonStandardParameter));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_NonStandardParameter(x->nonStandard + i, stream);
+            }
+            break;
+        case 1:
+            /* (basicString is NULL) */
+            break;
+        case 2:
+            /* (iA5String is NULL) */
+            break;
+        case 3:
+            /* (generalString is NULL) */
+            break;
+        case 4:
+            /* (dtmf is NULL) */
+            break;
+        case 5:
+            /* (hookflash is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_UserInputCapability: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for ConferenceCapability (SEQUENCE)  */
+/* <===============================================> */
+void Decode_ConferenceCapability(PS_ConferenceCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandardData = GetBoolean(stream);
+    if (x->option_of_nonStandardData)
+    {
+        x->size_of_nonStandardData = (uint16) GetLengthDet(stream);
+        x->nonStandardData = (PS_NonStandardParameter)
+                             OSCL_DEFAULT_MALLOC(x->size_of_nonStandardData * sizeof(S_NonStandardParameter));
+        for (i = 0;i < x->size_of_nonStandardData;++i)
+        {
+            Decode_NonStandardParameter(x->nonStandardData + i, stream);
+        }
+    }
+    x->chairControlCapability = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_VideoIndicateMixingCapability = OFF;
+    x->option_of_multipointVisualizationCapability = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_VideoIndicateMixingCapability = SigMapValue(0, map);
+        if (x->option_of_VideoIndicateMixingCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->VideoIndicateMixingCapability = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_multipointVisualizationCapability = SigMapValue(1, map);
+        if (x->option_of_multipointVisualizationCapability)
+        {
+            ExtensionPrep(map, stream);
+            x->multipointVisualizationCapability = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ConferenceCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for GenericCapability (SEQUENCE)  */
+/* <============================================> */
+void Decode_GenericCapability(PS_GenericCapability x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_maxBitRate = GetBoolean(stream);
+    x->option_of_collapsing = GetBoolean(stream);
+    x->option_of_nonCollapsing = GetBoolean(stream);
+    x->option_of_nonCollapsingRaw = GetBoolean(stream);
+    x->option_of_transport = GetBoolean(stream);
+    Decode_CapabilityIdentifier(&x->capabilityIdentifier, stream);
+    if (x->option_of_maxBitRate)
+    {
+        x->maxBitRate = GetInteger(0, 0xffffffff, stream);
+    }
+    if (x->option_of_collapsing)
+    {
+        x->size_of_collapsing = (uint16) GetLengthDet(stream);
+        x->collapsing = (PS_GenericParameter)
+                        OSCL_DEFAULT_MALLOC(x->size_of_collapsing * sizeof(S_GenericParameter));
+        for (i = 0;i < x->size_of_collapsing;++i)
+        {
+            Decode_GenericParameter(x->collapsing + i, stream);
+        }
+    }
+    if (x->option_of_nonCollapsing)
+    {
+        x->size_of_nonCollapsing = (uint16) GetLengthDet(stream);
+        x->nonCollapsing = (PS_GenericParameter)
+                           OSCL_DEFAULT_MALLOC(x->size_of_nonCollapsing * sizeof(S_GenericParameter));
+        for (i = 0;i < x->size_of_nonCollapsing;++i)
+        {
+            Decode_GenericParameter(x->nonCollapsing + i, stream);
+        }
+    }
+    if (x->option_of_nonCollapsingRaw)
+    {
+        GetOctetString(1, 0, 0, &x->nonCollapsingRaw, stream);
+    }
+    if (x->option_of_transport)
+    {
+        Decode_DataProtocolCapability(&x->transport, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_GenericCapability: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for CapabilityIdentifier (CHOICE)  */
+/* <=============================================> */
+void Decode_CapabilityIdentifier(PS_CapabilityIdentifier x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            GetObjectID(x->standard, stream);
+            break;
+        case 1:
+            x->h221NonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->h221NonStandard, stream);
+            break;
+        case 2:
+            x->uuid = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(0, 16, 16, x->uuid, stream);
+            break;
+        case 3:
+            x->domainBased = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+            GetCharString("IA5String", 0, 1, 64, NULL, x->domainBased, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CapabilityIdentifier: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for GenericParameter (SEQUENCE)  */
+/* <===========================================> */
+void Decode_GenericParameter(PS_GenericParameter x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_supersedes = GetBoolean(stream);
+    Decode_ParameterIdentifier(&x->parameterIdentifier, stream);
+    Decode_ParameterValue(&x->parameterValue, stream);
+    if (x->option_of_supersedes)
+    {
+        x->size_of_supersedes = (uint16) GetLengthDet(stream);
+        x->supersedes = (PS_ParameterIdentifier)
+                        OSCL_DEFAULT_MALLOC(x->size_of_supersedes * sizeof(S_ParameterIdentifier));
+        for (i = 0;i < x->size_of_supersedes;++i)
+        {
+            Decode_ParameterIdentifier(x->supersedes + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_GenericParameter: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for ParameterIdentifier (CHOICE)  */
+/* <============================================> */
+void Decode_ParameterIdentifier(PS_ParameterIdentifier x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->standard = (uint8) GetInteger(0, 127, stream);
+            break;
+        case 1:
+            x->h221NonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->h221NonStandard, stream);
+            break;
+        case 2:
+            x->uuid = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(0, 16, 16, x->uuid, stream);
+            break;
+        case 3:
+            x->domainBased = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+            GetCharString("IA5String", 0, 1, 64, NULL, x->domainBased, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_ParameterIdentifier: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for ParameterValue (CHOICE)  */
+/* <=======================================> */
+void Decode_ParameterValue(PS_ParameterValue x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(8, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (logical is NULL) */
+            break;
+        case 1:
+            x->booleanArray = (uint8) GetInteger(0, 255, stream);
+            break;
+        case 2:
+            x->unsignedMin = (uint16) GetInteger(0, 65535, stream);
+            break;
+        case 3:
+            x->unsignedMax = (uint16) GetInteger(0, 65535, stream);
+            break;
+        case 4:
+            x->unsigned32Min = GetInteger(0, 0xffffffff, stream);
+            break;
+        case 5:
+            x->unsigned32Max = GetInteger(0, 0xffffffff, stream);
+            break;
+        case 6:
+            x->octetString = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(1, 0, 0, x->octetString, stream);
+            break;
+        case 7:
+            x->size = (uint16) GetLengthDet(stream);
+            x->genericParameter = (PS_GenericParameter)
+                                  OSCL_DEFAULT_MALLOC(x->size * sizeof(S_GenericParameter));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_GenericParameter(x->genericParameter + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_ParameterValue: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for OpenLogicalChannel (SEQUENCE)  */
+/* <=============================================> */
+void Decode_OpenLogicalChannel(PS_OpenLogicalChannel x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_reverseLogicalChannelParameters = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_ForwardLogicalChannelParameters(&x->forwardLogicalChannelParameters, stream);
+    if (x->option_of_reverseLogicalChannelParameters)
+    {
+        Decode_ReverseLogicalChannelParameters(&x->reverseLogicalChannelParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_separateStack = OFF;
+    x->option_of_encryptionSync = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_separateStack = SigMapValue(0, map);
+        if (x->option_of_separateStack)
+        {
+            ExtensionPrep(map, stream);
+            Decode_NetworkAccessParameters(&x->separateStack, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_encryptionSync = SigMapValue(1, map);
+        if (x->option_of_encryptionSync)
+        {
+            ExtensionPrep(map, stream);
+            Decode_EncryptionSync(&x->encryptionSync, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_OpenLogicalChannel: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Decoder for ReverseLogicalChannelParameters (SEQUENCE)  */
+/* <==========================================================> */
+void Decode_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_rlcMultiplexParameters = GetBoolean(stream);
+    Decode_DataType(&x->dataType, stream);
+    if (x->option_of_rlcMultiplexParameters)
+    {
+        Decode_RlcMultiplexParameters(&x->rlcMultiplexParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_reverseLogicalChannelDependency = OFF;
+    x->option_of_replacementFor = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_reverseLogicalChannelDependency = SigMapValue(0, map);
+        if (x->option_of_reverseLogicalChannelDependency)
+        {
+            ExtensionPrep(map, stream);
+            x->reverseLogicalChannelDependency = (uint16) GetInteger(1, 65535, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_replacementFor = SigMapValue(1, map);
+        if (x->option_of_replacementFor)
+        {
+            ExtensionPrep(map, stream);
+            x->replacementFor = (uint16) GetInteger(1, 65535, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ReverseLogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for RlcMultiplexParameters (CHOICE)  */
+/* <===============================================> */
+void Decode_RlcMultiplexParameters(PS_RlcMultiplexParameters x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->h223LogicalChannelParameters = (PS_H223LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223LogicalChannelParameters));
+            Decode_H223LogicalChannelParameters(x->h223LogicalChannelParameters, stream);
+            break;
+        case 1:
+            x->v76LogicalChannelParameters = (PS_V76LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_V76LogicalChannelParameters));
+            Decode_V76LogicalChannelParameters(x->v76LogicalChannelParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            GetLengthDet(stream);
+            x->h2250LogicalChannelParameters = (PS_H2250LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H2250LogicalChannelParameters));
+            Decode_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_RlcMultiplexParameters: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Decoder for ForwardLogicalChannelParameters (SEQUENCE)  */
+/* <==========================================================> */
+void Decode_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_portNumber = GetBoolean(stream);
+    if (x->option_of_portNumber)
+    {
+        x->portNumber = (uint16) GetInteger(0, 65535, stream);
+    }
+    Decode_DataType(&x->dataType, stream);
+    Decode_MultiplexParameters(&x->multiplexParameters, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_forwardLogicalChannelDependency = OFF;
+    x->option_of_replacementFor = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_forwardLogicalChannelDependency = SigMapValue(0, map);
+        if (x->option_of_forwardLogicalChannelDependency)
+        {
+            ExtensionPrep(map, stream);
+            x->forwardLogicalChannelDependency = (uint16) GetInteger(1, 65535, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_replacementFor = SigMapValue(1, map);
+        if (x->option_of_replacementFor)
+        {
+            ExtensionPrep(map, stream);
+            x->replacementFor = (uint16) GetInteger(1, 65535, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ForwardLogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for MultiplexParameters (CHOICE)  */
+/* <============================================> */
+void Decode_MultiplexParameters(PS_MultiplexParameters x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->h222LogicalChannelParameters = (PS_H222LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H222LogicalChannelParameters));
+            Decode_H222LogicalChannelParameters(x->h222LogicalChannelParameters, stream);
+            break;
+        case 1:
+            x->h223LogicalChannelParameters = (PS_H223LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223LogicalChannelParameters));
+            Decode_H223LogicalChannelParameters(x->h223LogicalChannelParameters, stream);
+            break;
+        case 2:
+            x->v76LogicalChannelParameters = (PS_V76LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_V76LogicalChannelParameters));
+            Decode_V76LogicalChannelParameters(x->v76LogicalChannelParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            GetLengthDet(stream);
+            x->h2250LogicalChannelParameters = (PS_H2250LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H2250LogicalChannelParameters));
+            Decode_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 4:
+            GetLengthDet(stream);
+            /* (none is NULL) */
+            SkipOneOctet(stream);
+            break;
+        default:
+            ErrorMessage("Decode_MultiplexParameters: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for NetworkAccessParameters (SEQUENCE)  */
+/* <==================================================> */
+void Decode_NetworkAccessParameters(PS_NetworkAccessParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_distribution = GetBoolean(stream);
+    x->option_of_externalReference = GetBoolean(stream);
+    if (x->option_of_distribution)
+    {
+        Decode_Distribution(&x->distribution, stream);
+    }
+    Decode_NetworkAddress(&x->networkAddress, stream);
+    x->associateConference = GetBoolean(stream);
+    if (x->option_of_externalReference)
+    {
+        GetOctetString(0, 1, 255, &x->externalReference, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_t120SetupProcedure = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_t120SetupProcedure = SigMapValue(0, map);
+        if (x->option_of_t120SetupProcedure)
+        {
+            ExtensionPrep(map, stream);
+            Decode_T120SetupProcedure(&x->t120SetupProcedure, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_NetworkAccessParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for T120SetupProcedure (CHOICE)  */
+/* <===========================================> */
+void Decode_T120SetupProcedure(PS_T120SetupProcedure x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (originateCall is NULL) */
+            break;
+        case 1:
+            /* (waitForCall is NULL) */
+            break;
+        case 2:
+            /* (issueQuery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_T120SetupProcedure: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for NetworkAddress (CHOICE)  */
+/* <=======================================> */
+void Decode_NetworkAddress(PS_NetworkAddress x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->q2931Address = (PS_Q2931Address) OSCL_DEFAULT_MALLOC(sizeof(S_Q2931Address));
+            Decode_Q2931Address(x->q2931Address, stream);
+            break;
+        case 1:
+            x->e164Address = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+            GetCharString("IA5String(SIZE(1..128))", 0, 1, 128, "0123456789#*,", x->e164Address, stream);
+            break;
+        case 2:
+            x->localAreaAddress = (PS_TransportAddress) OSCL_DEFAULT_MALLOC(sizeof(S_TransportAddress));
+            Decode_TransportAddress(x->localAreaAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_NetworkAddress: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for Distribution (CHOICE)  */
+/* <=====================================> */
+void Decode_Distribution(PS_Distribution x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unicast is NULL) */
+            break;
+        case 1:
+            /* (multicast is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Distribution: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for Q2931Address (SEQUENCE)  */
+/* <=======================================> */
+void Decode_Q2931Address(PS_Q2931Address x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_subaddress = GetBoolean(stream);
+    Decode_Address(&x->address, stream);
+    if (x->option_of_subaddress)
+    {
+        GetOctetString(0, 1, 20, &x->subaddress, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Q2931Address: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for Address (CHOICE)  */
+/* <================================> */
+void Decode_Address(PS_Address x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->internationalNumber = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+            GetCharString("NumericString(SIZE(1..16))", 0, 1, 16, NULL, x->internationalNumber, stream);
+            break;
+        case 1:
+            x->nsapAddress = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(0, 1, 20, x->nsapAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Address: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for V75Parameters (SEQUENCE)  */
+/* <========================================> */
+void Decode_V75Parameters(PS_V75Parameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->audioHeaderPresent = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_V75Parameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for DataType (CHOICE)  */
+/* <=================================> */
+void Decode_DataType(PS_DataType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(6, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (nullData is NULL) */
+            break;
+        case 2:
+            x->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            Decode_VideoCapability(x->videoData, stream);
+            break;
+        case 3:
+            x->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            Decode_AudioCapability(x->audioData, stream);
+            break;
+        case 4:
+            x->data = (PS_DataApplicationCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataApplicationCapability));
+            Decode_DataApplicationCapability(x->data, stream);
+            break;
+        case 5:
+            x->encryptionData = (PS_EncryptionMode) OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionMode));
+            Decode_EncryptionMode(x->encryptionData, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            GetLengthDet(stream);
+            x->h235Control = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->h235Control, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 7:
+            GetLengthDet(stream);
+            x->h235Media = (PS_H235Media) OSCL_DEFAULT_MALLOC(sizeof(S_H235Media));
+            Decode_H235Media(x->h235Media, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_DataType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for H235Media (SEQUENCE)  */
+/* <====================================> */
+void Decode_H235Media(PS_H235Media x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, stream);
+    Decode_MediaType(&x->mediaType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H235Media: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for MediaType (CHOICE)  */
+/* <==================================> */
+void Decode_MediaType(PS_MediaType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            Decode_VideoCapability(x->videoData, stream);
+            break;
+        case 2:
+            x->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            Decode_AudioCapability(x->audioData, stream);
+            break;
+        case 3:
+            x->data = (PS_DataApplicationCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataApplicationCapability));
+            Decode_DataApplicationCapability(x->data, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MediaType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for H222LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+void Decode_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_pcr_pid = GetBoolean(stream);
+    x->option_of_programDescriptors = GetBoolean(stream);
+    x->option_of_streamDescriptors = GetBoolean(stream);
+    x->resourceID = (uint16) GetInteger(0, 65535, stream);
+    x->subChannelID = (uint16) GetInteger(0, 8191, stream);
+    if (x->option_of_pcr_pid)
+    {
+        x->pcr_pid = (uint16) GetInteger(0, 8191, stream);
+    }
+    if (x->option_of_programDescriptors)
+    {
+        GetOctetString(1, 0, 0, &x->programDescriptors, stream);
+    }
+    if (x->option_of_streamDescriptors)
+    {
+        GetOctetString(1, 0, 0, &x->streamDescriptors, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H222LogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for H223LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+void Decode_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_AdaptationLayerType(&x->adaptationLayerType, stream);
+    x->segmentableFlag = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223LogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for AdaptationLayerType (CHOICE)  */
+/* <============================================> */
+void Decode_AdaptationLayerType(PS_AdaptationLayerType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(6, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (al1Framed is NULL) */
+            break;
+        case 2:
+            /* (al1NotFramed is NULL) */
+            break;
+        case 3:
+            /* (al2WithoutSequenceNumbers is NULL) */
+            break;
+        case 4:
+            /* (al2WithSequenceNumbers is NULL) */
+            break;
+        case 5:
+            x->al3 = (PS_Al3) OSCL_DEFAULT_MALLOC(sizeof(S_Al3));
+            Decode_Al3(x->al3, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            GetLengthDet(stream);
+            x->al1M = (PS_H223AL1MParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AL1MParameters));
+            Decode_H223AL1MParameters(x->al1M, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 7:
+            GetLengthDet(stream);
+            x->al2M = (PS_H223AL2MParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AL2MParameters));
+            Decode_H223AL2MParameters(x->al2M, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 8:
+            GetLengthDet(stream);
+            x->al3M = (PS_H223AL3MParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AL3MParameters));
+            Decode_H223AL3MParameters(x->al3M, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_AdaptationLayerType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================> */
+/*  PER-Decoder for Al3 (SEQUENCE)  */
+/* <==============================> */
+void Decode_Al3(PS_Al3 x, PS_InStream stream)
+{
+    x->controlFieldOctets = (uint8) GetInteger(0, 2, stream);
+    x->sendBufferSize = GetInteger(0, 16777215, stream);
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H223AL1MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Decode_H223AL1MParameters(PS_H223AL1MParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TransferMode(&x->transferMode, stream);
+    Decode_HeaderFEC(&x->headerFEC, stream);
+    Decode_CrcLength(&x->crcLength, stream);
+    x->rcpcCodeRate = (uint8) GetInteger(8, 32, stream);
+    Decode_ArqType(&x->arqType, stream);
+    x->alpduInterleaving = GetBoolean(stream);
+    x->alsduSplitting = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_rsCodeCorrection = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_rsCodeCorrection = SigMapValue(0, map);
+        if (x->option_of_rsCodeCorrection)
+        {
+            ExtensionPrep(map, stream);
+            x->rsCodeCorrection = (uint8) GetInteger(0, 127, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223AL1MParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for ArqType (CHOICE)  */
+/* <================================> */
+void Decode_ArqType(PS_ArqType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noArq is NULL) */
+            break;
+        case 1:
+            x->typeIArq = (PS_H223AnnexCArqParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AnnexCArqParameters));
+            Decode_H223AnnexCArqParameters(x->typeIArq, stream);
+            break;
+        case 2:
+            x->typeIIArq = (PS_H223AnnexCArqParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AnnexCArqParameters));
+            Decode_H223AnnexCArqParameters(x->typeIIArq, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_ArqType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for CrcLength (CHOICE)  */
+/* <==================================> */
+void Decode_CrcLength(PS_CrcLength x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (crc4bit is NULL) */
+            break;
+        case 1:
+            /* (crc12bit is NULL) */
+            break;
+        case 2:
+            /* (crc20bit is NULL) */
+            break;
+        case 3:
+            /* (crc28bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            GetLengthDet(stream);
+            /* (crc8bit is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 5:
+            GetLengthDet(stream);
+            /* (crc16bit is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 6:
+            GetLengthDet(stream);
+            /* (crc32bit is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 7:
+            GetLengthDet(stream);
+            /* (crcNotUsed is NULL) */
+            SkipOneOctet(stream);
+            break;
+        default:
+            ErrorMessage("Decode_CrcLength: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for HeaderFEC (CHOICE)  */
+/* <==================================> */
+void Decode_HeaderFEC(PS_HeaderFEC x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_7 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_HeaderFEC: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for TransferMode (CHOICE)  */
+/* <=====================================> */
+void Decode_TransferMode(PS_TransferMode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (framed is NULL) */
+            break;
+        case 1:
+            /* (unframed is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_TransferMode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H223AL2MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Decode_H223AL2MParameters(PS_H223AL2MParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_Al2HeaderFEC(&x->al2HeaderFEC, stream);
+    x->alpduInterleaving = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223AL2MParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for Al2HeaderFEC (CHOICE)  */
+/* <=====================================> */
+void Decode_Al2HeaderFEC(PS_Al2HeaderFEC x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_5 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Al2HeaderFEC: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H223AL3MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Decode_H223AL3MParameters(PS_H223AL3MParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_HeaderFormat(&x->headerFormat, stream);
+    Decode_Al3CrcLength(&x->al3CrcLength, stream);
+    x->rcpcCodeRate = (uint8) GetInteger(8, 32, stream);
+    Decode_Al3ArqType(&x->al3ArqType, stream);
+    x->alpduInterleaving = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_rsCodeCorrection = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_rsCodeCorrection = SigMapValue(0, map);
+        if (x->option_of_rsCodeCorrection)
+        {
+            ExtensionPrep(map, stream);
+            x->rsCodeCorrection = (uint8) GetInteger(0, 127, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223AL3MParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for Al3ArqType (CHOICE)  */
+/* <===================================> */
+void Decode_Al3ArqType(PS_Al3ArqType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noArq is NULL) */
+            break;
+        case 1:
+            x->typeIArq = (PS_H223AnnexCArqParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AnnexCArqParameters));
+            Decode_H223AnnexCArqParameters(x->typeIArq, stream);
+            break;
+        case 2:
+            x->typeIIArq = (PS_H223AnnexCArqParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AnnexCArqParameters));
+            Decode_H223AnnexCArqParameters(x->typeIIArq, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Al3ArqType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for Al3CrcLength (CHOICE)  */
+/* <=====================================> */
+void Decode_Al3CrcLength(PS_Al3CrcLength x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (crc4bit is NULL) */
+            break;
+        case 1:
+            /* (crc12bit is NULL) */
+            break;
+        case 2:
+            /* (crc20bit is NULL) */
+            break;
+        case 3:
+            /* (crc28bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            GetLengthDet(stream);
+            /* (crc8bit is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 5:
+            GetLengthDet(stream);
+            /* (crc16bit is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 6:
+            GetLengthDet(stream);
+            /* (crc32bit is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 7:
+            GetLengthDet(stream);
+            /* (crcNotUsed is NULL) */
+            SkipOneOctet(stream);
+            break;
+        default:
+            ErrorMessage("Decode_Al3CrcLength: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for HeaderFormat (CHOICE)  */
+/* <=====================================> */
+void Decode_HeaderFormat(PS_HeaderFormat x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_7 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_HeaderFormat: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for H223AnnexCArqParameters (SEQUENCE)  */
+/* <==================================================> */
+void Decode_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_NumberOfRetransmissions(&x->numberOfRetransmissions, stream);
+    x->sendBufferSize = GetInteger(0, 16777215, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223AnnexCArqParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for NumberOfRetransmissions (CHOICE)  */
+/* <================================================> */
+void Decode_NumberOfRetransmissions(PS_NumberOfRetransmissions x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->finite = (uint8) GetInteger(0, 16, stream);
+            break;
+        case 1:
+            /* (infinite is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_NumberOfRetransmissions: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for V76LogicalChannelParameters (SEQUENCE)  */
+/* <======================================================> */
+void Decode_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_V76HDLCParameters(&x->hdlcParameters, stream);
+    Decode_SuspendResume(&x->suspendResume, stream);
+    x->uIH = GetBoolean(stream);
+    Decode_Mode(&x->mode, stream);
+    Decode_V75Parameters(&x->v75Parameters, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_V76LogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================> */
+/*  PER-Decoder for Mode (CHOICE)  */
+/* <=============================> */
+void Decode_Mode(PS_Mode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->eRM = (PS_ERM) OSCL_DEFAULT_MALLOC(sizeof(S_ERM));
+            Decode_ERM(x->eRM, stream);
+            break;
+        case 1:
+            /* (uNERM is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Mode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================> */
+/*  PER-Decoder for ERM (SEQUENCE)  */
+/* <==============================> */
+void Decode_ERM(PS_ERM x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->windowSize = (uint8) GetInteger(1, 127, stream);
+    Decode_Recovery(&x->recovery, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ERM: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for Recovery (CHOICE)  */
+/* <=================================> */
+void Decode_Recovery(PS_Recovery x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (rej is NULL) */
+            break;
+        case 1:
+            /* (sREJ is NULL) */
+            break;
+        case 2:
+            /* (mSREJ is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Recovery: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for SuspendResume (CHOICE)  */
+/* <======================================> */
+void Decode_SuspendResume(PS_SuspendResume x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noSuspendResume is NULL) */
+            break;
+        case 1:
+            /* (suspendResumewAddress is NULL) */
+            break;
+        case 2:
+            /* (suspendResumewoAddress is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_SuspendResume: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for V76HDLCParameters (SEQUENCE)  */
+/* <============================================> */
+void Decode_V76HDLCParameters(PS_V76HDLCParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_CRCLength(&x->crcLength, stream);
+    x->n401 = (uint16) GetInteger(1, 4095, stream);
+    x->loopbackTestProcedure = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_V76HDLCParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for CRCLength (CHOICE)  */
+/* <==================================> */
+void Decode_CRCLength(PS_CRCLength x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (crc8bit is NULL) */
+            break;
+        case 1:
+            /* (crc16bit is NULL) */
+            break;
+        case 2:
+            /* (crc32bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CRCLength: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================================> */
+/*  PER-Decoder for H2250LogicalChannelParameters (SEQUENCE)  */
+/* <========================================================> */
+void Decode_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    x->option_of_associatedSessionID = GetBoolean(stream);
+    x->option_of_mediaChannel = GetBoolean(stream);
+    x->option_of_mediaGuaranteedDelivery = GetBoolean(stream);
+    x->option_of_mediaControlChannel = GetBoolean(stream);
+    x->option_of_mediaControlGuaranteedDelivery = GetBoolean(stream);
+    x->option_of_silenceSuppression = GetBoolean(stream);
+    x->option_of_destination = GetBoolean(stream);
+    x->option_of_dynamicRTPPayloadType = GetBoolean(stream);
+    x->option_of_mediaPacketization = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        x->size_of_nonStandard = (uint16) GetLengthDet(stream);
+        x->nonStandard = (PS_NonStandardParameter)
+                         OSCL_DEFAULT_MALLOC(x->size_of_nonStandard * sizeof(S_NonStandardParameter));
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Decode_NonStandardParameter(x->nonStandard + i, stream);
+        }
+    }
+    x->sessionID = (uint8) GetInteger(0, 255, stream);
+    if (x->option_of_associatedSessionID)
+    {
+        x->associatedSessionID = (uint8) GetInteger(1, 255, stream);
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Decode_TransportAddress(&x->mediaChannel, stream);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+        x->mediaGuaranteedDelivery = GetBoolean(stream);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Decode_TransportAddress(&x->mediaControlChannel, stream);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+        x->mediaControlGuaranteedDelivery = GetBoolean(stream);
+    }
+    if (x->option_of_silenceSuppression)
+    {
+        x->silenceSuppression = GetBoolean(stream);
+    }
+    if (x->option_of_destination)
+    {
+        Decode_TerminalLabel(&x->destination, stream);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+        x->dynamicRTPPayloadType = (uint8) GetInteger(96, 127, stream);
+    }
+    if (x->option_of_mediaPacketization)
+    {
+        Decode_MediaPacketization(&x->mediaPacketization, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_transportCapability = OFF;
+    x->option_of_redundancyEncoding = OFF;
+    x->option_of_source = OFF;
+    x->option_of_symmetricMediaAddress = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_transportCapability = SigMapValue(0, map);
+        if (x->option_of_transportCapability)
+        {
+            ExtensionPrep(map, stream);
+            Decode_TransportCapability(&x->transportCapability, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_redundancyEncoding = SigMapValue(1, map);
+        if (x->option_of_redundancyEncoding)
+        {
+            ExtensionPrep(map, stream);
+            Decode_RedundancyEncoding(&x->redundancyEncoding, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_source = SigMapValue(2, map);
+        if (x->option_of_source)
+        {
+            ExtensionPrep(map, stream);
+            Decode_TerminalLabel(&x->source, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_symmetricMediaAddress = SigMapValue(3, map);
+        if (x->option_of_symmetricMediaAddress)
+        {
+            ExtensionPrep(map, stream);
+            x->symmetricMediaAddress = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H2250LogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for MediaPacketization (CHOICE)  */
+/* <===========================================> */
+void Decode_MediaPacketization(PS_MediaPacketization x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (h261aVideoPacketization is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            GetLengthDet(stream);
+            x->rtpPayloadType = (PS_RTPPayloadType) OSCL_DEFAULT_MALLOC(sizeof(S_RTPPayloadType));
+            Decode_RTPPayloadType(x->rtpPayloadType, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_MediaPacketization: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for RTPPayloadType (SEQUENCE)  */
+/* <=========================================> */
+void Decode_RTPPayloadType(PS_RTPPayloadType x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_payloadType = GetBoolean(stream);
+    Decode_PayloadDescriptor(&x->payloadDescriptor, stream);
+    if (x->option_of_payloadType)
+    {
+        x->payloadType = (uint8) GetInteger(0, 127, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RTPPayloadType: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for PayloadDescriptor (CHOICE)  */
+/* <==========================================> */
+void Decode_PayloadDescriptor(PS_PayloadDescriptor x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandardIdentifier = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandardIdentifier, stream);
+            break;
+        case 1:
+            x->rfc_number = (uint16) GetExtendedInteger(1, 32768, stream);
+            break;
+        case 2:
+            x->oid = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            GetObjectID(x->oid, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_PayloadDescriptor: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for RedundancyEncoding (SEQUENCE)  */
+/* <=============================================> */
+void Decode_RedundancyEncoding(PS_RedundancyEncoding x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_secondaryEncoding = GetBoolean(stream);
+    Decode_RedundancyEncodingMethod(&x->redundancyEncodingMethod, stream);
+    if (x->option_of_secondaryEncoding)
+    {
+        Decode_DataType(&x->secondaryEncoding, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RedundancyEncoding: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for TransportAddress (CHOICE)  */
+/* <=========================================> */
+void Decode_TransportAddress(PS_TransportAddress x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->unicastAddress = (PS_UnicastAddress) OSCL_DEFAULT_MALLOC(sizeof(S_UnicastAddress));
+            Decode_UnicastAddress(x->unicastAddress, stream);
+            break;
+        case 1:
+            x->multicastAddress = (PS_MulticastAddress) OSCL_DEFAULT_MALLOC(sizeof(S_MulticastAddress));
+            Decode_MulticastAddress(x->multicastAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_TransportAddress: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for UnicastAddress (CHOICE)  */
+/* <=======================================> */
+void Decode_UnicastAddress(PS_UnicastAddress x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->iPAddress = (PS_IPAddress) OSCL_DEFAULT_MALLOC(sizeof(S_IPAddress));
+            Decode_IPAddress(x->iPAddress, stream);
+            break;
+        case 1:
+            x->iPXAddress = (PS_IPXAddress) OSCL_DEFAULT_MALLOC(sizeof(S_IPXAddress));
+            Decode_IPXAddress(x->iPXAddress, stream);
+            break;
+        case 2:
+            x->iP6Address = (PS_IP6Address) OSCL_DEFAULT_MALLOC(sizeof(S_IP6Address));
+            Decode_IP6Address(x->iP6Address, stream);
+            break;
+        case 3:
+            x->netBios = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(0, 16, 16, x->netBios, stream);
+            break;
+        case 4:
+            x->iPSourceRouteAddress = (PS_IPSourceRouteAddress) OSCL_DEFAULT_MALLOC(sizeof(S_IPSourceRouteAddress));
+            Decode_IPSourceRouteAddress(x->iPSourceRouteAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            GetLengthDet(stream);
+            x->nsap = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(0, 1, 20, x->nsap, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 6:
+            GetLengthDet(stream);
+            x->nonStandardAddress = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandardAddress, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_UnicastAddress: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for IPSourceRouteAddress (SEQUENCE)  */
+/* <===============================================> */
+void Decode_IPSourceRouteAddress(PS_IPSourceRouteAddress x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_Routing(&x->routing, stream);
+    GetOctetString(0, 4, 4, &x->network, stream);
+    x->tsapIdentifier = (uint16) GetInteger(0, 65535, stream);
+    x->size_of_route = (uint16) GetLengthDet(stream);
+    x->route = (PS_OCTETSTRING)
+               OSCL_DEFAULT_MALLOC(x->size_of_route * sizeof(S_OCTETSTRING));
+    for (i = 0;i < x->size_of_route;++i)
+    {
+        GetOctetString(0, 4, 4, x->route + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IPSourceRouteAddress: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for Routing (CHOICE)  */
+/* <================================> */
+void Decode_Routing(PS_Routing x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (strict is NULL) */
+            break;
+        case 1:
+            /* (loose is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Routing: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for IP6Address (SEQUENCE)  */
+/* <=====================================> */
+void Decode_IP6Address(PS_IP6Address x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 16, 16, &x->network, stream);
+    x->tsapIdentifier = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IP6Address: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for IPXAddress (SEQUENCE)  */
+/* <=====================================> */
+void Decode_IPXAddress(PS_IPXAddress x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 6, 6, &x->node, stream);
+    GetOctetString(0, 4, 4, &x->netnum, stream);
+    GetOctetString(0, 2, 2, &x->tsapIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IPXAddress: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for IPAddress (SEQUENCE)  */
+/* <====================================> */
+void Decode_IPAddress(PS_IPAddress x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 4, 4, &x->network, stream);
+    x->tsapIdentifier = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IPAddress: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for MulticastAddress (CHOICE)  */
+/* <=========================================> */
+void Decode_MulticastAddress(PS_MulticastAddress x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->maIpAddress = (PS_MaIpAddress) OSCL_DEFAULT_MALLOC(sizeof(S_MaIpAddress));
+            Decode_MaIpAddress(x->maIpAddress, stream);
+            break;
+        case 1:
+            x->maIp6Address = (PS_MaIp6Address) OSCL_DEFAULT_MALLOC(sizeof(S_MaIp6Address));
+            Decode_MaIp6Address(x->maIp6Address, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            GetLengthDet(stream);
+            x->nsap = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(0, 1, 20, x->nsap, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 3:
+            GetLengthDet(stream);
+            x->nonStandardAddress = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandardAddress, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_MulticastAddress: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for MaIp6Address (SEQUENCE)  */
+/* <=======================================> */
+void Decode_MaIp6Address(PS_MaIp6Address x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 16, 16, &x->network, stream);
+    x->tsapIdentifier = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaIp6Address: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for MaIpAddress (SEQUENCE)  */
+/* <======================================> */
+void Decode_MaIpAddress(PS_MaIpAddress x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 4, 4, &x->network, stream);
+    x->tsapIdentifier = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaIpAddress: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for EncryptionSync (SEQUENCE)  */
+/* <=========================================> */
+void Decode_EncryptionSync(PS_EncryptionSync x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    x->option_of_escrowentry = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        Decode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    x->synchFlag = (uint8) GetInteger(0, 255, stream);
+    GetOctetString(0, 1, 65535, &x->h235Key, stream);
+    if (x->option_of_escrowentry)
+    {
+        x->size_of_escrowentry = (uint16) GetInteger(1, 256, stream);
+        x->escrowentry = (PS_EscrowData)
+                         OSCL_DEFAULT_MALLOC(x->size_of_escrowentry * sizeof(S_EscrowData));
+        for (i = 0;i < x->size_of_escrowentry;++i)
+        {
+            Decode_EscrowData(x->escrowentry + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_EncryptionSync: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for EscrowData (SEQUENCE)  */
+/* <=====================================> */
+void Decode_EscrowData(PS_EscrowData x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetObjectID(&x->escrowID, stream);
+    GetBitString(0, 1, 65535, &x->escrowValue, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_EscrowData: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for OpenLogicalChannelAck (SEQUENCE)  */
+/* <================================================> */
+void Decode_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_ackReverseLogicalChannelParameters = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    if (x->option_of_ackReverseLogicalChannelParameters)
+    {
+        Decode_AckReverseLogicalChannelParameters(&x->ackReverseLogicalChannelParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_separateStack = OFF;
+    x->option_of_forwardMultiplexAckParameters = OFF;
+    x->option_of_encryptionSync = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_separateStack = SigMapValue(0, map);
+        if (x->option_of_separateStack)
+        {
+            ExtensionPrep(map, stream);
+            Decode_NetworkAccessParameters(&x->separateStack, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_forwardMultiplexAckParameters = SigMapValue(1, map);
+        if (x->option_of_forwardMultiplexAckParameters)
+        {
+            ExtensionPrep(map, stream);
+            Decode_ForwardMultiplexAckParameters(&x->forwardMultiplexAckParameters, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_encryptionSync = SigMapValue(2, map);
+        if (x->option_of_encryptionSync)
+        {
+            ExtensionPrep(map, stream);
+            Decode_EncryptionSync(&x->encryptionSync, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_OpenLogicalChannelAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for ForwardMultiplexAckParameters (CHOICE)  */
+/* <======================================================> */
+void Decode_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->h2250LogicalChannelAckParameters = (PS_H2250LogicalChannelAckParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H2250LogicalChannelAckParameters));
+            Decode_H2250LogicalChannelAckParameters(x->h2250LogicalChannelAckParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_ForwardMultiplexAckParameters: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================================> */
+/*  PER-Decoder for AckReverseLogicalChannelParameters (SEQUENCE)  */
+/* <=============================================================> */
+void Decode_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_portNumber = GetBoolean(stream);
+    x->option_of_ackMultiplexParameters = GetBoolean(stream);
+    x->reverseLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    if (x->option_of_portNumber)
+    {
+        x->portNumber = (uint16) GetInteger(0, 65535, stream);
+    }
+    if (x->option_of_ackMultiplexParameters)
+    {
+        Decode_AckMultiplexParameters(&x->ackMultiplexParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_replacementFor = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_replacementFor = SigMapValue(0, map);
+        if (x->option_of_replacementFor)
+        {
+            ExtensionPrep(map, stream);
+            x->replacementFor = (uint16) GetInteger(1, 65535, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_AckReverseLogicalChannelParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for AckMultiplexParameters (CHOICE)  */
+/* <===============================================> */
+void Decode_AckMultiplexParameters(PS_AckMultiplexParameters x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->h222LogicalChannelParameters = (PS_H222LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H222LogicalChannelParameters));
+            Decode_H222LogicalChannelParameters(x->h222LogicalChannelParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            GetLengthDet(stream);
+            x->h2250LogicalChannelParameters = (PS_H2250LogicalChannelParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H2250LogicalChannelParameters));
+            Decode_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_AckMultiplexParameters: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for OpenLogicalChannelReject (SEQUENCE)  */
+/* <===================================================> */
+void Decode_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_OlcRejectCause(&x->olcRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_OpenLogicalChannelReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for OlcRejectCause (CHOICE)  */
+/* <=======================================> */
+void Decode_OlcRejectCause(PS_OlcRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(6, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (unsuitableReverseParameters is NULL) */
+            break;
+        case 2:
+            /* (dataTypeNotSupported is NULL) */
+            break;
+        case 3:
+            /* (dataTypeNotAvailable is NULL) */
+            break;
+        case 4:
+            /* (unknownDataType is NULL) */
+            break;
+        case 5:
+            /* (dataTypeALCombinationNotSupported is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            GetLengthDet(stream);
+            /* (multicastChannelNotAllowed is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 7:
+            GetLengthDet(stream);
+            /* (insufficientBandwidth is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 8:
+            GetLengthDet(stream);
+            /* (separateStackEstablishmentFailed is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 9:
+            GetLengthDet(stream);
+            /* (invalidSessionID is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 10:
+            GetLengthDet(stream);
+            /* (masterSlaveConflict is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            /* (waitForCommunicationMode is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            /* (invalidDependentChannel is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            /* (replacementForRejected is NULL) */
+            SkipOneOctet(stream);
+            break;
+        default:
+            ErrorMessage("Decode_OlcRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for OpenLogicalChannelConfirm (SEQUENCE)  */
+/* <====================================================> */
+void Decode_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_OpenLogicalChannelConfirm: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================================> */
+/*  PER-Decoder for H2250LogicalChannelAckParameters (SEQUENCE)  */
+/* <===========================================================> */
+void Decode_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    x->option_of_sessionID = GetBoolean(stream);
+    x->option_of_mediaChannel = GetBoolean(stream);
+    x->option_of_mediaControlChannel = GetBoolean(stream);
+    x->option_of_dynamicRTPPayloadType = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        x->size_of_nonStandard = (uint16) GetLengthDet(stream);
+        x->nonStandard = (PS_NonStandardParameter)
+                         OSCL_DEFAULT_MALLOC(x->size_of_nonStandard * sizeof(S_NonStandardParameter));
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Decode_NonStandardParameter(x->nonStandard + i, stream);
+        }
+    }
+    if (x->option_of_sessionID)
+    {
+        x->sessionID = (uint8) GetInteger(1, 255, stream);
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Decode_TransportAddress(&x->mediaChannel, stream);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Decode_TransportAddress(&x->mediaControlChannel, stream);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+        x->dynamicRTPPayloadType = (uint8) GetInteger(96, 127, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_flowControlToZero = OFF;
+    x->option_of_portNumber = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_flowControlToZero = SigMapValue(0, map);
+        if (x->option_of_flowControlToZero)
+        {
+            ExtensionPrep(map, stream);
+            x->flowControlToZero = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_portNumber = SigMapValue(1, map);
+        if (x->option_of_portNumber)
+        {
+            ExtensionPrep(map, stream);
+            x->portNumber = (uint16) GetInteger(0, 65535, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H2250LogicalChannelAckParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for CloseLogicalChannel (SEQUENCE)  */
+/* <==============================================> */
+void Decode_CloseLogicalChannel(PS_CloseLogicalChannel x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_Source(&x->source, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_reason = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_reason = SigMapValue(0, map);
+        if (x->option_of_reason)
+        {
+            ExtensionPrep(map, stream);
+            Decode_Reason(&x->reason, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CloseLogicalChannel: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for Reason (CHOICE)  */
+/* <===============================> */
+void Decode_Reason(PS_Reason x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unknown is NULL) */
+            break;
+        case 1:
+            /* (reopen is NULL) */
+            break;
+        case 2:
+            /* (reservationFailure is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Reason: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for Source (CHOICE)  */
+/* <===============================> */
+void Decode_Source(PS_Source x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (user is NULL) */
+            break;
+        case 1:
+            /* (lcse is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Source: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for CloseLogicalChannelAck (SEQUENCE)  */
+/* <=================================================> */
+void Decode_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CloseLogicalChannelAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for RequestChannelClose (SEQUENCE)  */
+/* <==============================================> */
+void Decode_RequestChannelClose(PS_RequestChannelClose x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_qosCapability = OFF;
+    x->option_of_rccReason = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_qosCapability = SigMapValue(0, map);
+        if (x->option_of_qosCapability)
+        {
+            ExtensionPrep(map, stream);
+            Decode_QOSCapability(&x->qosCapability, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_rccReason = SigMapValue(1, map);
+        if (x->option_of_rccReason)
+        {
+            ExtensionPrep(map, stream);
+            Decode_RccReason(&x->rccReason, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestChannelClose: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for RccReason (CHOICE)  */
+/* <==================================> */
+void Decode_RccReason(PS_RccReason x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unknown is NULL) */
+            break;
+        case 1:
+            /* (normal is NULL) */
+            break;
+        case 2:
+            /* (reopen is NULL) */
+            break;
+        case 3:
+            /* (reservationFailure is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RccReason: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for RequestChannelCloseAck (SEQUENCE)  */
+/* <=================================================> */
+void Decode_RequestChannelCloseAck(PS_RequestChannelCloseAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestChannelCloseAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for RequestChannelCloseReject (SEQUENCE)  */
+/* <====================================================> */
+void Decode_RequestChannelCloseReject(PS_RequestChannelCloseReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_RccRejectCause(&x->rccRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestChannelCloseReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for RccRejectCause (CHOICE)  */
+/* <=======================================> */
+void Decode_RccRejectCause(PS_RccRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RccRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Decoder for RequestChannelCloseRelease (SEQUENCE)  */
+/* <=====================================================> */
+void Decode_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardLogicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestChannelCloseRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for MultiplexEntrySend (SEQUENCE)  */
+/* <=============================================> */
+void Decode_MultiplexEntrySend(PS_MultiplexEntrySend x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->size_of_multiplexEntryDescriptors = (uint8) GetInteger(1, 15, stream);
+    x->multiplexEntryDescriptors = (PS_MultiplexEntryDescriptor)
+                                   OSCL_DEFAULT_MALLOC(x->size_of_multiplexEntryDescriptors * sizeof(S_MultiplexEntryDescriptor));
+    for (i = 0;i < x->size_of_multiplexEntryDescriptors;++i)
+    {
+        Decode_MultiplexEntryDescriptor(x->multiplexEntryDescriptors + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MultiplexEntrySend: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for MultiplexEntryDescriptor (SEQUENCE)  */
+/* <===================================================> */
+void Decode_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x, PS_InStream stream)
+{
+    uint16 i;
+    x->option_of_elementList = GetBoolean(stream);
+    x->multiplexTableEntryNumber = (uint8) GetInteger(1, 15, stream);
+    if (x->option_of_elementList)
+    {
+        x->size_of_elementList = (uint16) GetInteger(1, 256, stream);
+        x->elementList = (PS_MultiplexElement)
+                         OSCL_DEFAULT_MALLOC(x->size_of_elementList * sizeof(S_MultiplexElement));
+        for (i = 0;i < x->size_of_elementList;++i)
+        {
+            Decode_MultiplexElement(x->elementList + i, stream);
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for MultiplexElement (SEQUENCE)  */
+/* <===========================================> */
+void Decode_MultiplexElement(PS_MultiplexElement x, PS_InStream stream)
+{
+    Decode_MuxType(&x->muxType, stream);
+    Decode_RepeatCount(&x->repeatCount, stream);
+}
+
+/* <====================================> */
+/*  PER-Decoder for RepeatCount (CHOICE)  */
+/* <====================================> */
+void Decode_RepeatCount(PS_RepeatCount x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->finite = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            /* (untilClosingFlag is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_RepeatCount: Illegal CHOICE index");
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for MuxType (CHOICE)  */
+/* <================================> */
+void Decode_MuxType(PS_MuxType x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->logicalChannelNumber = (uint16) GetInteger(0, 65535, stream);
+            break;
+        case 1:
+            x->size = (uint8) GetInteger(2, 255, stream);
+            x->subElementList = (PS_MultiplexElement)
+                                OSCL_DEFAULT_MALLOC(x->size * sizeof(S_MultiplexElement));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_MultiplexElement(x->subElementList + i, stream);
+            }
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_MuxType: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for MultiplexEntrySendAck (SEQUENCE)  */
+/* <================================================> */
+void Decode_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->size_of_multiplexTableEntryNumber = (uint8) GetInteger(1, 15, stream);
+    x->multiplexTableEntryNumber = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_multiplexTableEntryNumber * sizeof(uint32));
+    for (i = 0;i < x->size_of_multiplexTableEntryNumber;++i)
+    {
+        x->multiplexTableEntryNumber[i] = GetInteger(1, 15, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MultiplexEntrySendAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for MultiplexEntrySendReject (SEQUENCE)  */
+/* <===================================================> */
+void Decode_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->size_of_rejectionDescriptions = (uint8) GetInteger(1, 15, stream);
+    x->rejectionDescriptions = (PS_MultiplexEntryRejectionDescriptions)
+                               OSCL_DEFAULT_MALLOC(x->size_of_rejectionDescriptions * sizeof(S_MultiplexEntryRejectionDescriptions));
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        Decode_MultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MultiplexEntrySendReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================================> */
+/*  PER-Decoder for MultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <==============================================================> */
+void Decode_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->multiplexTableEntryNumber = (uint8) GetInteger(1, 15, stream);
+    Decode_MeRejectCause(&x->meRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MultiplexEntryRejectionDescriptions: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for MeRejectCause (CHOICE)  */
+/* <======================================> */
+void Decode_MeRejectCause(PS_MeRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecifiedCause is NULL) */
+            break;
+        case 1:
+            /* (descriptorTooComplex is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MeRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for MultiplexEntrySendRelease (SEQUENCE)  */
+/* <====================================================> */
+void Decode_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_multiplexTableEntryNumber = (uint8) GetInteger(1, 15, stream);
+    x->multiplexTableEntryNumber = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_multiplexTableEntryNumber * sizeof(uint32));
+    for (i = 0;i < x->size_of_multiplexTableEntryNumber;++i)
+    {
+        x->multiplexTableEntryNumber[i] = GetInteger(1, 15, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MultiplexEntrySendRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for RequestMultiplexEntry (SEQUENCE)  */
+/* <================================================> */
+void Decode_RequestMultiplexEntry(PS_RequestMultiplexEntry x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_entryNumbers = (uint8) GetInteger(1, 15, stream);
+    x->entryNumbers = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_entryNumbers * sizeof(uint32));
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        x->entryNumbers[i] = GetInteger(1, 15, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestMultiplexEntry: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for RequestMultiplexEntryAck (SEQUENCE)  */
+/* <===================================================> */
+void Decode_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_entryNumbers = (uint8) GetInteger(1, 15, stream);
+    x->entryNumbers = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_entryNumbers * sizeof(uint32));
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        x->entryNumbers[i] = GetInteger(1, 15, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestMultiplexEntryAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for RequestMultiplexEntryReject (SEQUENCE)  */
+/* <======================================================> */
+void Decode_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_entryNumbers = (uint8) GetInteger(1, 15, stream);
+    x->entryNumbers = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_entryNumbers * sizeof(uint32));
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        x->entryNumbers[i] = GetInteger(1, 15, stream);
+    }
+    x->size_of_rejectionDescriptions = (uint8) GetInteger(1, 15, stream);
+    x->rejectionDescriptions = (PS_RequestMultiplexEntryRejectionDescriptions)
+                               OSCL_DEFAULT_MALLOC(x->size_of_rejectionDescriptions * sizeof(S_RequestMultiplexEntryRejectionDescriptions));
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        Decode_RequestMultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestMultiplexEntryReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================================================> */
+/*  PER-Decoder for RequestMultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <=====================================================================> */
+void Decode_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->multiplexTableEntryNumber = (uint8) GetInteger(1, 15, stream);
+    Decode_RmeRejectCause(&x->rmeRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestMultiplexEntryRejectionDescriptions: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for RmeRejectCause (CHOICE)  */
+/* <=======================================> */
+void Decode_RmeRejectCause(PS_RmeRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecifiedCause is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RmeRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for RequestMultiplexEntryRelease (SEQUENCE)  */
+/* <=======================================================> */
+void Decode_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_entryNumbers = (uint8) GetInteger(1, 15, stream);
+    x->entryNumbers = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_entryNumbers * sizeof(uint32));
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        x->entryNumbers[i] = GetInteger(1, 15, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestMultiplexEntryRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for RequestMode (SEQUENCE)  */
+/* <======================================> */
+void Decode_RequestMode(PS_RequestMode x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->size_of_requestedModes = (uint16) GetInteger(1, 256, stream);
+    x->requestedModes = (PS_ModeDescription)
+                        OSCL_DEFAULT_MALLOC(x->size_of_requestedModes * sizeof(S_ModeDescription));
+    for (i = 0;i < x->size_of_requestedModes;++i)
+    {
+        Decode_ModeDescription(x->requestedModes + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for RequestModeAck (SEQUENCE)  */
+/* <=========================================> */
+void Decode_RequestModeAck(PS_RequestModeAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    Decode_Response(&x->response, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestModeAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for Response (CHOICE)  */
+/* <=================================> */
+void Decode_Response(PS_Response x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (willTransmitMostPreferredMode is NULL) */
+            break;
+        case 1:
+            /* (willTransmitLessPreferredMode is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Response: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for RequestModeReject (SEQUENCE)  */
+/* <============================================> */
+void Decode_RequestModeReject(PS_RequestModeReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    Decode_RmRejectCause(&x->rmRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestModeReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for RmRejectCause (CHOICE)  */
+/* <======================================> */
+void Decode_RmRejectCause(PS_RmRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (modeUnavailable is NULL) */
+            break;
+        case 1:
+            /* (multipointConstraint is NULL) */
+            break;
+        case 2:
+            /* (requestDenied is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RmRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for RequestModeRelease (SEQUENCE)  */
+/* <=============================================> */
+void Decode_RequestModeRelease(PS_RequestModeRelease x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestModeRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for ModeDescription (SET-OF)  */
+/* <========================================> */
+void Decode_ModeDescription(PS_ModeDescription x, PS_InStream stream)
+{
+    uint16 i;
+    x->size = (uint16) GetInteger(1, 256, stream);
+    x->item = (PS_ModeElement)
+              OSCL_DEFAULT_MALLOC(x->size * sizeof(S_ModeElement));
+    for (i = 0;i < x->size;++i)
+    {
+        Decode_ModeElement(x->item + i, stream);
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for ModeElement (SEQUENCE)  */
+/* <======================================> */
+void Decode_ModeElement(PS_ModeElement x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_h223ModeParameters = GetBoolean(stream);
+    Decode_ModeType(&x->modeType, stream);
+    if (x->option_of_h223ModeParameters)
+    {
+        Decode_H223ModeParameters(&x->h223ModeParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_v76ModeParameters = OFF;
+    x->option_of_h2250ModeParameters = OFF;
+    x->option_of_genericModeParameters = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_v76ModeParameters = SigMapValue(0, map);
+        if (x->option_of_v76ModeParameters)
+        {
+            ExtensionPrep(map, stream);
+            Decode_V76ModeParameters(&x->v76ModeParameters, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_h2250ModeParameters = SigMapValue(1, map);
+        if (x->option_of_h2250ModeParameters)
+        {
+            ExtensionPrep(map, stream);
+            Decode_H2250ModeParameters(&x->h2250ModeParameters, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_genericModeParameters = SigMapValue(2, map);
+        if (x->option_of_genericModeParameters)
+        {
+            ExtensionPrep(map, stream);
+            Decode_GenericCapability(&x->genericModeParameters, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ModeElement: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for ModeType (CHOICE)  */
+/* <=================================> */
+void Decode_ModeType(PS_ModeType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->videoMode = (PS_VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_VideoMode));
+            Decode_VideoMode(x->videoMode, stream);
+            break;
+        case 2:
+            x->audioMode = (PS_AudioMode) OSCL_DEFAULT_MALLOC(sizeof(S_AudioMode));
+            Decode_AudioMode(x->audioMode, stream);
+            break;
+        case 3:
+            x->dataMode = (PS_DataMode) OSCL_DEFAULT_MALLOC(sizeof(S_DataMode));
+            Decode_DataMode(x->dataMode, stream);
+            break;
+        case 4:
+            x->encryptionMode = (PS_EncryptionMode) OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionMode));
+            Decode_EncryptionMode(x->encryptionMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            GetLengthDet(stream);
+            x->h235Mode = (PS_H235Mode) OSCL_DEFAULT_MALLOC(sizeof(S_H235Mode));
+            Decode_H235Mode(x->h235Mode, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ModeType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for H235Mode (SEQUENCE)  */
+/* <===================================> */
+void Decode_H235Mode(PS_H235Mode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, stream);
+    Decode_MediaMode(&x->mediaMode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H235Mode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for MediaMode (CHOICE)  */
+/* <==================================> */
+void Decode_MediaMode(PS_MediaMode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->videoMode = (PS_VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_VideoMode));
+            Decode_VideoMode(x->videoMode, stream);
+            break;
+        case 2:
+            x->audioMode = (PS_AudioMode) OSCL_DEFAULT_MALLOC(sizeof(S_AudioMode));
+            Decode_AudioMode(x->audioMode, stream);
+            break;
+        case 3:
+            x->dataMode = (PS_DataMode) OSCL_DEFAULT_MALLOC(sizeof(S_DataMode));
+            Decode_DataMode(x->dataMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MediaMode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H223ModeParameters (SEQUENCE)  */
+/* <=============================================> */
+void Decode_H223ModeParameters(PS_H223ModeParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_ModeAdaptationLayerType(&x->modeAdaptationLayerType, stream);
+    x->segmentableFlag = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223ModeParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for ModeAdaptationLayerType (CHOICE)  */
+/* <================================================> */
+void Decode_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(6, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (al1Framed is NULL) */
+            break;
+        case 2:
+            /* (al1NotFramed is NULL) */
+            break;
+        case 3:
+            /* (al2WithoutSequenceNumbers is NULL) */
+            break;
+        case 4:
+            /* (al2WithSequenceNumbers is NULL) */
+            break;
+        case 5:
+            x->modeAl3 = (PS_ModeAl3) OSCL_DEFAULT_MALLOC(sizeof(S_ModeAl3));
+            Decode_ModeAl3(x->modeAl3, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            GetLengthDet(stream);
+            x->al1M = (PS_H223AL1MParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AL1MParameters));
+            Decode_H223AL1MParameters(x->al1M, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 7:
+            GetLengthDet(stream);
+            x->al2M = (PS_H223AL2MParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AL2MParameters));
+            Decode_H223AL2MParameters(x->al2M, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 8:
+            GetLengthDet(stream);
+            x->al3M = (PS_H223AL3MParameters) OSCL_DEFAULT_MALLOC(sizeof(S_H223AL3MParameters));
+            Decode_H223AL3MParameters(x->al3M, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ModeAdaptationLayerType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for ModeAl3 (SEQUENCE)  */
+/* <==================================> */
+void Decode_ModeAl3(PS_ModeAl3 x, PS_InStream stream)
+{
+    x->controlFieldOctets = (uint8) GetInteger(0, 2, stream);
+    x->sendBufferSize = GetInteger(0, 16777215, stream);
+}
+
+/* <==========================================> */
+/*  PER-Decoder for V76ModeParameters (CHOICE)  */
+/* <==========================================> */
+void Decode_V76ModeParameters(PS_V76ModeParameters x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (suspendResumewAddress is NULL) */
+            break;
+        case 1:
+            /* (suspendResumewoAddress is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_V76ModeParameters: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for H2250ModeParameters (SEQUENCE)  */
+/* <==============================================> */
+void Decode_H2250ModeParameters(PS_H2250ModeParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_redundancyEncodingMode = GetBoolean(stream);
+    if (x->option_of_redundancyEncodingMode)
+    {
+        Decode_RedundancyEncodingMode(&x->redundancyEncodingMode, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H2250ModeParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for RedundancyEncodingMode (SEQUENCE)  */
+/* <=================================================> */
+void Decode_RedundancyEncodingMode(PS_RedundancyEncodingMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_secondaryEncoding = GetBoolean(stream);
+    Decode_RedundancyEncodingMethod(&x->redundancyEncodingMethod, stream);
+    if (x->option_of_secondaryEncoding)
+    {
+        Decode_SecondaryEncoding(&x->secondaryEncoding, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RedundancyEncodingMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for SecondaryEncoding (CHOICE)  */
+/* <==========================================> */
+void Decode_SecondaryEncoding(PS_SecondaryEncoding x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->audioData = (PS_AudioMode) OSCL_DEFAULT_MALLOC(sizeof(S_AudioMode));
+            Decode_AudioMode(x->audioData, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_SecondaryEncoding: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for VideoMode (CHOICE)  */
+/* <==================================> */
+void Decode_VideoMode(PS_VideoMode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->h261VideoMode = (PS_H261VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_H261VideoMode));
+            Decode_H261VideoMode(x->h261VideoMode, stream);
+            break;
+        case 2:
+            x->h262VideoMode = (PS_H262VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_H262VideoMode));
+            Decode_H262VideoMode(x->h262VideoMode, stream);
+            break;
+        case 3:
+            x->h263VideoMode = (PS_H263VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoMode));
+            Decode_H263VideoMode(x->h263VideoMode, stream);
+            break;
+        case 4:
+            x->is11172VideoMode = (PS_IS11172VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_IS11172VideoMode));
+            Decode_IS11172VideoMode(x->is11172VideoMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            GetLengthDet(stream);
+            x->genericVideoMode = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericVideoMode, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_VideoMode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for H261VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Decode_H261VideoMode(PS_H261VideoMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_Resolution(&x->resolution, stream);
+    x->bitRate = (uint16) GetInteger(1, 19200, stream);
+    x->stillImageTransmission = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H261VideoMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for Resolution (CHOICE)  */
+/* <===================================> */
+void Decode_Resolution(PS_Resolution x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (qcif is NULL) */
+            break;
+        case 1:
+            /* (cif is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Resolution: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for H262VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Decode_H262VideoMode(PS_H262VideoMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_videoBitRate = GetBoolean(stream);
+    x->option_of_vbvBufferSize = GetBoolean(stream);
+    x->option_of_samplesPerLine = GetBoolean(stream);
+    x->option_of_linesPerFrame = GetBoolean(stream);
+    x->option_of_framesPerSecond = GetBoolean(stream);
+    x->option_of_luminanceSampleRate = GetBoolean(stream);
+    Decode_ProfileAndLevel(&x->profileAndLevel, stream);
+    if (x->option_of_videoBitRate)
+    {
+        x->videoBitRate = GetInteger(0, 1073741823, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        x->vbvBufferSize = GetInteger(0, 262143, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        x->samplesPerLine = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        x->linesPerFrame = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_framesPerSecond)
+    {
+        x->framesPerSecond = (uint8) GetInteger(0, 15, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        x->luminanceSampleRate = GetInteger(0, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H262VideoMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for ProfileAndLevel (CHOICE)  */
+/* <========================================> */
+void Decode_ProfileAndLevel(PS_ProfileAndLevel x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(11, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (profileAndLevel_SPatML is NULL) */
+            break;
+        case 1:
+            /* (profileAndLevel_MPatLL is NULL) */
+            break;
+        case 2:
+            /* (profileAndLevel_MPatML is NULL) */
+            break;
+        case 3:
+            /* (profileAndLevel_MPatH_14 is NULL) */
+            break;
+        case 4:
+            /* (profileAndLevel_MPatHL is NULL) */
+            break;
+        case 5:
+            /* (profileAndLevel_SNRatLL is NULL) */
+            break;
+        case 6:
+            /* (profileAndLevel_SNRatML is NULL) */
+            break;
+        case 7:
+            /* (profileAndLevel_SpatialatH_14 is NULL) */
+            break;
+        case 8:
+            /* (profileAndLevel_HPatML is NULL) */
+            break;
+        case 9:
+            /* (profileAndLevel_HPatH_14 is NULL) */
+            break;
+        case 10:
+            /* (profileAndLevel_HPatHL is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_ProfileAndLevel: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for H263VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Decode_H263VideoMode(PS_H263VideoMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_H263Resolution(&x->h263Resolution, stream);
+    x->bitRate = (uint16) GetInteger(1, 19200, stream);
+    x->unrestrictedVector = GetBoolean(stream);
+    x->arithmeticCoding = GetBoolean(stream);
+    x->advancedPrediction = GetBoolean(stream);
+    x->pbFrames = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_errorCompensation = OFF;
+    x->option_of_enhancementLayerInfo = OFF;
+    x->option_of_h263Options = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_errorCompensation = SigMapValue(0, map);
+        if (x->option_of_errorCompensation)
+        {
+            ExtensionPrep(map, stream);
+            x->errorCompensation = GetBoolean(stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_enhancementLayerInfo = SigMapValue(1, map);
+        if (x->option_of_enhancementLayerInfo)
+        {
+            ExtensionPrep(map, stream);
+            Decode_EnhancementLayerInfo(&x->enhancementLayerInfo, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_h263Options = SigMapValue(2, map);
+        if (x->option_of_h263Options)
+        {
+            ExtensionPrep(map, stream);
+            Decode_H263Options(&x->h263Options, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H263VideoMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for H263Resolution (CHOICE)  */
+/* <=======================================> */
+void Decode_H263Resolution(PS_H263Resolution x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sqcif is NULL) */
+            break;
+        case 1:
+            /* (qcif is NULL) */
+            break;
+        case 2:
+            /* (cif is NULL) */
+            break;
+        case 3:
+            /* (cif4 is NULL) */
+            break;
+        case 4:
+            /* (cif16 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_H263Resolution: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for IS11172VideoMode (SEQUENCE)  */
+/* <===========================================> */
+void Decode_IS11172VideoMode(PS_IS11172VideoMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_videoBitRate = GetBoolean(stream);
+    x->option_of_vbvBufferSize = GetBoolean(stream);
+    x->option_of_samplesPerLine = GetBoolean(stream);
+    x->option_of_linesPerFrame = GetBoolean(stream);
+    x->option_of_pictureRate = GetBoolean(stream);
+    x->option_of_luminanceSampleRate = GetBoolean(stream);
+    x->constrainedBitstream = GetBoolean(stream);
+    if (x->option_of_videoBitRate)
+    {
+        x->videoBitRate = GetInteger(0, 1073741823, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        x->vbvBufferSize = GetInteger(0, 262143, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        x->samplesPerLine = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        x->linesPerFrame = (uint16) GetInteger(0, 16383, stream);
+    }
+    if (x->option_of_pictureRate)
+    {
+        x->pictureRate = (uint8) GetInteger(0, 15, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        x->luminanceSampleRate = GetInteger(0, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IS11172VideoMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for AudioMode (CHOICE)  */
+/* <==================================> */
+void Decode_AudioMode(PS_AudioMode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(14, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (g711Alaw64k is NULL) */
+            break;
+        case 2:
+            /* (g711Alaw56k is NULL) */
+            break;
+        case 3:
+            /* (g711Ulaw64k is NULL) */
+            break;
+        case 4:
+            /* (g711Ulaw56k is NULL) */
+            break;
+        case 5:
+            /* (g722_64k is NULL) */
+            break;
+        case 6:
+            /* (g722_56k is NULL) */
+            break;
+        case 7:
+            /* (g722_48k is NULL) */
+            break;
+        case 8:
+            /* (g728 is NULL) */
+            break;
+        case 9:
+            /* (g729 is NULL) */
+            break;
+        case 10:
+            /* (g729AnnexA is NULL) */
+            break;
+        case 11:
+            x->modeG7231 = (PS_ModeG7231) OSCL_DEFAULT_MALLOC(sizeof(S_ModeG7231));
+            Decode_ModeG7231(x->modeG7231, stream);
+            break;
+        case 12:
+            x->is11172AudioMode = (PS_IS11172AudioMode) OSCL_DEFAULT_MALLOC(sizeof(S_IS11172AudioMode));
+            Decode_IS11172AudioMode(x->is11172AudioMode, stream);
+            break;
+        case 13:
+            x->is13818AudioMode = (PS_IS13818AudioMode) OSCL_DEFAULT_MALLOC(sizeof(S_IS13818AudioMode));
+            Decode_IS13818AudioMode(x->is13818AudioMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            GetLengthDet(stream);
+            x->g729wAnnexB = (uint16) GetInteger(1, 256, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            x->g729AnnexAwAnnexB = (uint16) GetInteger(1, 256, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 16:
+            GetLengthDet(stream);
+            x->g7231AnnexCMode = (PS_G7231AnnexCMode) OSCL_DEFAULT_MALLOC(sizeof(S_G7231AnnexCMode));
+            Decode_G7231AnnexCMode(x->g7231AnnexCMode, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 17:
+            GetLengthDet(stream);
+            x->gsmFullRate = (PS_GSMAudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GSMAudioCapability));
+            Decode_GSMAudioCapability(x->gsmFullRate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 18:
+            GetLengthDet(stream);
+            x->gsmHalfRate = (PS_GSMAudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GSMAudioCapability));
+            Decode_GSMAudioCapability(x->gsmHalfRate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 19:
+            GetLengthDet(stream);
+            x->gsmEnhancedFullRate = (PS_GSMAudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GSMAudioCapability));
+            Decode_GSMAudioCapability(x->gsmEnhancedFullRate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 20:
+            GetLengthDet(stream);
+            x->genericAudioMode = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericAudioMode, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 21:
+            GetLengthDet(stream);
+            x->g729Extensions = (PS_G729Extensions) OSCL_DEFAULT_MALLOC(sizeof(S_G729Extensions));
+            Decode_G729Extensions(x->g729Extensions, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_AudioMode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for ModeG7231 (CHOICE)  */
+/* <==================================> */
+void Decode_ModeG7231(PS_ModeG7231 x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noSilenceSuppressionLowRate is NULL) */
+            break;
+        case 1:
+            /* (noSilenceSuppressionHighRate is NULL) */
+            break;
+        case 2:
+            /* (silenceSuppressionLowRate is NULL) */
+            break;
+        case 3:
+            /* (silenceSuppressionHighRate is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_ModeG7231: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for IS11172AudioMode (SEQUENCE)  */
+/* <===========================================> */
+void Decode_IS11172AudioMode(PS_IS11172AudioMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_AudioLayer(&x->audioLayer, stream);
+    Decode_AudioSampling(&x->audioSampling, stream);
+    Decode_MultichannelType(&x->multichannelType, stream);
+    x->bitRate = (uint16) GetInteger(1, 448, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IS11172AudioMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for MultichannelType (CHOICE)  */
+/* <=========================================> */
+void Decode_MultichannelType(PS_MultichannelType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (singleChannel is NULL) */
+            break;
+        case 1:
+            /* (twoChannelStereo is NULL) */
+            break;
+        case 2:
+            /* (twoChannelDual is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_MultichannelType: Illegal CHOICE index");
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for AudioSampling (CHOICE)  */
+/* <======================================> */
+void Decode_AudioSampling(PS_AudioSampling x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioSampling32k is NULL) */
+            break;
+        case 1:
+            /* (audioSampling44k1 is NULL) */
+            break;
+        case 2:
+            /* (audioSampling48k is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_AudioSampling: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for AudioLayer (CHOICE)  */
+/* <===================================> */
+void Decode_AudioLayer(PS_AudioLayer x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioLayer1 is NULL) */
+            break;
+        case 1:
+            /* (audioLayer2 is NULL) */
+            break;
+        case 2:
+            /* (audioLayer3 is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_AudioLayer: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for IS13818AudioMode (SEQUENCE)  */
+/* <===========================================> */
+void Decode_IS13818AudioMode(PS_IS13818AudioMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_Is13818AudioLayer(&x->is13818AudioLayer, stream);
+    Decode_Is13818AudioSampling(&x->is13818AudioSampling, stream);
+    Decode_Is13818MultichannelType(&x->is13818MultichannelType, stream);
+    x->lowFrequencyEnhancement = GetBoolean(stream);
+    x->multilingual = GetBoolean(stream);
+    x->bitRate = (uint16) GetInteger(1, 1130, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IS13818AudioMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for Is13818MultichannelType (CHOICE)  */
+/* <================================================> */
+void Decode_Is13818MultichannelType(PS_Is13818MultichannelType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(10, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (singleChannel is NULL) */
+            break;
+        case 1:
+            /* (twoChannelStereo is NULL) */
+            break;
+        case 2:
+            /* (twoChannelDual is NULL) */
+            break;
+        case 3:
+            /* (threeChannels2_1 is NULL) */
+            break;
+        case 4:
+            /* (threeChannels3_0 is NULL) */
+            break;
+        case 5:
+            /* (fourChannels2_0_2_0 is NULL) */
+            break;
+        case 6:
+            /* (fourChannels2_2 is NULL) */
+            break;
+        case 7:
+            /* (fourChannels3_1 is NULL) */
+            break;
+        case 8:
+            /* (fiveChannels3_0_2_0 is NULL) */
+            break;
+        case 9:
+            /* (fiveChannels3_2 is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Is13818MultichannelType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for Is13818AudioSampling (CHOICE)  */
+/* <=============================================> */
+void Decode_Is13818AudioSampling(PS_Is13818AudioSampling x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(6, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioSampling16k is NULL) */
+            break;
+        case 1:
+            /* (audioSampling22k05 is NULL) */
+            break;
+        case 2:
+            /* (audioSampling24k is NULL) */
+            break;
+        case 3:
+            /* (audioSampling32k is NULL) */
+            break;
+        case 4:
+            /* (audioSampling44k1 is NULL) */
+            break;
+        case 5:
+            /* (audioSampling48k is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Is13818AudioSampling: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for Is13818AudioLayer (CHOICE)  */
+/* <==========================================> */
+void Decode_Is13818AudioLayer(PS_Is13818AudioLayer x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioLayer1 is NULL) */
+            break;
+        case 1:
+            /* (audioLayer2 is NULL) */
+            break;
+        case 2:
+            /* (audioLayer3 is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_Is13818AudioLayer: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for G7231AnnexCMode (SEQUENCE)  */
+/* <==========================================> */
+void Decode_G7231AnnexCMode(PS_G7231AnnexCMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->maxAl_sduAudioFrames = (uint16) GetInteger(1, 256, stream);
+    x->silenceSuppression = GetBoolean(stream);
+    Decode_ModeG723AnnexCAudioMode(&x->modeG723AnnexCAudioMode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_G7231AnnexCMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for ModeG723AnnexCAudioMode (SEQUENCE)  */
+/* <==================================================> */
+void Decode_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->highRateMode0 = (uint8) GetInteger(27, 78, stream);
+    x->highRateMode1 = (uint8) GetInteger(27, 78, stream);
+    x->lowRateMode0 = (uint8) GetInteger(23, 66, stream);
+    x->lowRateMode1 = (uint8) GetInteger(23, 66, stream);
+    x->sidMode0 = (uint8) GetInteger(6, 17, stream);
+    x->sidMode1 = (uint8) GetInteger(6, 17, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ModeG723AnnexCAudioMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for DataMode (SEQUENCE)  */
+/* <===================================> */
+void Decode_DataMode(PS_DataMode x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_DmApplication(&x->dmApplication, stream);
+    x->bitRate = GetInteger(0, 0xffffffff, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_DataMode: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for DmApplication (CHOICE)  */
+/* <======================================> */
+void Decode_DmApplication(PS_DmApplication x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(10, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->t120 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t120, stream);
+            break;
+        case 2:
+            x->dsm_cc = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->dsm_cc, stream);
+            break;
+        case 3:
+            x->userData = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->userData, stream);
+            break;
+        case 4:
+            x->t84 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t84, stream);
+            break;
+        case 5:
+            x->t434 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t434, stream);
+            break;
+        case 6:
+            x->h224 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->h224, stream);
+            break;
+        case 7:
+            x->dmNlpid = (PS_DmNlpid) OSCL_DEFAULT_MALLOC(sizeof(S_DmNlpid));
+            Decode_DmNlpid(x->dmNlpid, stream);
+            break;
+        case 8:
+            /* (dsvdControl is NULL) */
+            break;
+        case 9:
+            x->h222DataPartitioning = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->h222DataPartitioning, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            GetLengthDet(stream);
+            x->t30fax = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t30fax, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->t140 = (PS_DataProtocolCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataProtocolCapability));
+            Decode_DataProtocolCapability(x->t140, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->dmT38fax = (PS_DmT38fax) OSCL_DEFAULT_MALLOC(sizeof(S_DmT38fax));
+            Decode_DmT38fax(x->dmT38fax, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->genericDataMode = (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            Decode_GenericCapability(x->genericDataMode, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_DmApplication: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for DmT38fax (SEQUENCE)  */
+/* <===================================> */
+void Decode_DmT38fax(PS_DmT38fax x, PS_InStream stream)
+{
+    Decode_DataProtocolCapability(&x->t38FaxProtocol, stream);
+    Decode_T38FaxProfile(&x->t38FaxProfile, stream);
+}
+
+/* <==================================> */
+/*  PER-Decoder for DmNlpid (SEQUENCE)  */
+/* <==================================> */
+void Decode_DmNlpid(PS_DmNlpid x, PS_InStream stream)
+{
+    Decode_DataProtocolCapability(&x->nlpidProtocol, stream);
+    GetOctetString(1, 0, 0, &x->nlpidData, stream);
+}
+
+/* <=======================================> */
+/*  PER-Decoder for EncryptionMode (CHOICE)  */
+/* <=======================================> */
+void Decode_EncryptionMode(PS_EncryptionMode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (h233Encryption is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_EncryptionMode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for RoundTripDelayRequest (SEQUENCE)  */
+/* <================================================> */
+void Decode_RoundTripDelayRequest(PS_RoundTripDelayRequest x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RoundTripDelayRequest: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for RoundTripDelayResponse (SEQUENCE)  */
+/* <=================================================> */
+void Decode_RoundTripDelayResponse(PS_RoundTripDelayResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RoundTripDelayResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================================> */
+/*  PER-Decoder for MaintenanceLoopRequest (SEQUENCE)  */
+/* <=================================================> */
+void Decode_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_MlRequestType(&x->mlRequestType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaintenanceLoopRequest: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for MlRequestType (CHOICE)  */
+/* <======================================> */
+void Decode_MlRequestType(PS_MlRequestType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            x->mediaLoop = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 2:
+            x->logicalChannelLoop = (uint16) GetInteger(1, 65535, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MlRequestType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for MaintenanceLoopAck (SEQUENCE)  */
+/* <=============================================> */
+void Decode_MaintenanceLoopAck(PS_MaintenanceLoopAck x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_MlAckType(&x->mlAckType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaintenanceLoopAck: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for MlAckType (CHOICE)  */
+/* <==================================> */
+void Decode_MlAckType(PS_MlAckType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            x->mediaLoop = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 2:
+            x->logicalChannelLoop = (uint16) GetInteger(1, 65535, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MlAckType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for MaintenanceLoopReject (SEQUENCE)  */
+/* <================================================> */
+void Decode_MaintenanceLoopReject(PS_MaintenanceLoopReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_MlRejectType(&x->mlRejectType, stream);
+    Decode_MlRejectCause(&x->mlRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaintenanceLoopReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================> */
+/*  PER-Decoder for MlRejectCause (CHOICE)  */
+/* <======================================> */
+void Decode_MlRejectCause(PS_MlRejectCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (canNotPerformLoop is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MlRejectCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for MlRejectType (CHOICE)  */
+/* <=====================================> */
+void Decode_MlRejectType(PS_MlRejectType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            x->mediaLoop = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 2:
+            x->logicalChannelLoop = (uint16) GetInteger(1, 65535, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MlRejectType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for MaintenanceLoopOffCommand (SEQUENCE)  */
+/* <====================================================> */
+void Decode_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaintenanceLoopOffCommand: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for CommunicationModeCommand (SEQUENCE)  */
+/* <===================================================> */
+void Decode_CommunicationModeCommand(PS_CommunicationModeCommand x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_communicationModeTable = (uint16) GetInteger(1, 256, stream);
+    x->communicationModeTable = (PS_CommunicationModeTableEntry)
+                                OSCL_DEFAULT_MALLOC(x->size_of_communicationModeTable * sizeof(S_CommunicationModeTableEntry));
+    for (i = 0;i < x->size_of_communicationModeTable;++i)
+    {
+        Decode_CommunicationModeTableEntry(x->communicationModeTable + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CommunicationModeCommand: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for CommunicationModeRequest (SEQUENCE)  */
+/* <===================================================> */
+void Decode_CommunicationModeRequest(PS_CommunicationModeRequest x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CommunicationModeRequest: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for CommunicationModeResponse (CHOICE)  */
+/* <==================================================> */
+void Decode_CommunicationModeResponse(PS_CommunicationModeResponse x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(1, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->size = (uint16) GetInteger(1, 256, stream);
+            x->communicationModeTable = (PS_CommunicationModeTableEntry)
+                                        OSCL_DEFAULT_MALLOC(x->size * sizeof(S_CommunicationModeTableEntry));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_CommunicationModeTableEntry(x->communicationModeTable + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CommunicationModeResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for CommunicationModeTableEntry (SEQUENCE)  */
+/* <======================================================> */
+void Decode_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_nonStandard = GetBoolean(stream);
+    x->option_of_associatedSessionID = GetBoolean(stream);
+    x->option_of_terminalLabel = GetBoolean(stream);
+    x->option_of_mediaChannel = GetBoolean(stream);
+    x->option_of_mediaGuaranteedDelivery = GetBoolean(stream);
+    x->option_of_mediaControlChannel = GetBoolean(stream);
+    x->option_of_mediaControlGuaranteedDelivery = GetBoolean(stream);
+    if (x->option_of_nonStandard)
+    {
+        x->size_of_nonStandard = (uint16) GetLengthDet(stream);
+        x->nonStandard = (PS_NonStandardParameter)
+                         OSCL_DEFAULT_MALLOC(x->size_of_nonStandard * sizeof(S_NonStandardParameter));
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Decode_NonStandardParameter(x->nonStandard + i, stream);
+        }
+    }
+    x->sessionID = (uint8) GetInteger(1, 255, stream);
+    if (x->option_of_associatedSessionID)
+    {
+        x->associatedSessionID = (uint8) GetInteger(1, 255, stream);
+    }
+    if (x->option_of_terminalLabel)
+    {
+        Decode_TerminalLabel(&x->terminalLabel, stream);
+    }
+    GetCharString("BMPString", 0, 1, 128, NULL, &x->sessionDescription, stream);
+    Decode_CmtDataType(&x->cmtDataType, stream);
+    if (x->option_of_mediaChannel)
+    {
+        Decode_TransportAddress(&x->mediaChannel, stream);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+        x->mediaGuaranteedDelivery = GetBoolean(stream);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Decode_TransportAddress(&x->mediaControlChannel, stream);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+        x->mediaControlGuaranteedDelivery = GetBoolean(stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_redundancyEncoding = OFF;
+    x->option_of_sessionDependency = OFF;
+    x->option_of_destination = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_redundancyEncoding = SigMapValue(0, map);
+        if (x->option_of_redundancyEncoding)
+        {
+            ExtensionPrep(map, stream);
+            Decode_RedundancyEncoding(&x->redundancyEncoding, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_sessionDependency = SigMapValue(1, map);
+        if (x->option_of_sessionDependency)
+        {
+            ExtensionPrep(map, stream);
+            x->sessionDependency = (uint8) GetInteger(1, 255, stream);
+            ReadRemainingBits(stream);
+        }
+        x->option_of_destination = SigMapValue(2, map);
+        if (x->option_of_destination)
+        {
+            ExtensionPrep(map, stream);
+            Decode_TerminalLabel(&x->destination, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CommunicationModeTableEntry: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for CmtDataType (CHOICE)  */
+/* <====================================> */
+void Decode_CmtDataType(PS_CmtDataType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            Decode_VideoCapability(x->videoData, stream);
+            break;
+        case 1:
+            x->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            Decode_AudioCapability(x->audioData, stream);
+            break;
+        case 2:
+            x->data = (PS_DataApplicationCapability) OSCL_DEFAULT_MALLOC(sizeof(S_DataApplicationCapability));
+            Decode_DataApplicationCapability(x->data, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CmtDataType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for ConferenceRequest (CHOICE)  */
+/* <==========================================> */
+void Decode_ConferenceRequest(PS_ConferenceRequest x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(8, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (terminalListRequest is NULL) */
+            break;
+        case 1:
+            /* (makeMeChair is NULL) */
+            break;
+        case 2:
+            /* (cancelMakeMeChair is NULL) */
+            break;
+        case 3:
+            x->dropTerminal = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->dropTerminal, stream);
+            break;
+        case 4:
+            x->requestTerminalID = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->requestTerminalID, stream);
+            break;
+        case 5:
+            /* (enterH243Password is NULL) */
+            break;
+        case 6:
+            /* (enterH243TerminalID is NULL) */
+            break;
+        case 7:
+            /* (enterH243ConferenceID is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            GetLengthDet(stream);
+            /* (enterExtensionAddress is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 9:
+            GetLengthDet(stream);
+            /* (requestChairTokenOwner is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 10:
+            GetLengthDet(stream);
+            x->requestTerminalCertificate = (PS_RequestTerminalCertificate) OSCL_DEFAULT_MALLOC(sizeof(S_RequestTerminalCertificate));
+            Decode_RequestTerminalCertificate(x->requestTerminalCertificate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->broadcastMyLogicalChannel = (uint16) GetInteger(1, 65535, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->makeTerminalBroadcaster = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->makeTerminalBroadcaster, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->sendThisSource = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->sendThisSource, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 14:
+            GetLengthDet(stream);
+            /* (requestAllTerminalIDs is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            x->remoteMCRequest = (PS_RemoteMCRequest) OSCL_DEFAULT_MALLOC(sizeof(S_RemoteMCRequest));
+            Decode_RemoteMCRequest(x->remoteMCRequest, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ConferenceRequest: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Decoder for RequestTerminalCertificate (SEQUENCE)  */
+/* <=====================================================> */
+void Decode_RequestTerminalCertificate(PS_RequestTerminalCertificate x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_terminalLabel = GetBoolean(stream);
+    x->option_of_certSelectionCriteria = GetBoolean(stream);
+    x->option_of_sRandom = GetBoolean(stream);
+    if (x->option_of_terminalLabel)
+    {
+        Decode_TerminalLabel(&x->terminalLabel, stream);
+    }
+    if (x->option_of_certSelectionCriteria)
+    {
+        Decode_CertSelectionCriteria(&x->certSelectionCriteria, stream);
+    }
+    if (x->option_of_sRandom)
+    {
+        x->sRandom = GetInteger(1, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestTerminalCertificate: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for CertSelectionCriteria (SEQUENCE-OF)  */
+/* <===================================================> */
+void Decode_CertSelectionCriteria(PS_CertSelectionCriteria x, PS_InStream stream)
+{
+    uint16 i;
+    x->size = (uint8) GetInteger(1, 16, stream);
+    x->item = (PS_Criteria)
+              OSCL_DEFAULT_MALLOC(x->size * sizeof(S_Criteria));
+    for (i = 0;i < x->size;++i)
+    {
+        Decode_Criteria(x->item + i, stream);
+    }
+}
+
+/* <===================================> */
+/*  PER-Decoder for Criteria (SEQUENCE)  */
+/* <===================================> */
+void Decode_Criteria(PS_Criteria x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetObjectID(&x->field, stream);
+    GetOctetString(0, 1, 65535, &x->value, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Criteria: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for TerminalLabel (SEQUENCE)  */
+/* <========================================> */
+void Decode_TerminalLabel(PS_TerminalLabel x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->mcuNumber = (uint8) GetInteger(0, 192, stream);
+    x->terminalNumber = (uint8) GetInteger(0, 192, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalLabel: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for ConferenceResponse (CHOICE)  */
+/* <===========================================> */
+void Decode_ConferenceResponse(PS_ConferenceResponse x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(8, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->mCTerminalIDResponse = (PS_MCTerminalIDResponse) OSCL_DEFAULT_MALLOC(sizeof(S_MCTerminalIDResponse));
+            Decode_MCTerminalIDResponse(x->mCTerminalIDResponse, stream);
+            break;
+        case 1:
+            x->terminalIDResponse = (PS_TerminalIDResponse) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalIDResponse));
+            Decode_TerminalIDResponse(x->terminalIDResponse, stream);
+            break;
+        case 2:
+            x->conferenceIDResponse = (PS_ConferenceIDResponse) OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceIDResponse));
+            Decode_ConferenceIDResponse(x->conferenceIDResponse, stream);
+            break;
+        case 3:
+            x->passwordResponse = (PS_PasswordResponse) OSCL_DEFAULT_MALLOC(sizeof(S_PasswordResponse));
+            Decode_PasswordResponse(x->passwordResponse, stream);
+            break;
+        case 4:
+            x->size = (uint16) GetInteger(1, 256, stream);
+            x->terminalListResponse = (PS_TerminalLabel)
+                                      OSCL_DEFAULT_MALLOC(x->size * sizeof(S_TerminalLabel));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_TerminalLabel(x->terminalListResponse + i, stream);
+            }
+            break;
+        case 5:
+            /* (videoCommandReject is NULL) */
+            break;
+        case 6:
+            /* (terminalDropReject is NULL) */
+            break;
+        case 7:
+            x->makeMeChairResponse = (PS_MakeMeChairResponse) OSCL_DEFAULT_MALLOC(sizeof(S_MakeMeChairResponse));
+            Decode_MakeMeChairResponse(x->makeMeChairResponse, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            GetLengthDet(stream);
+            x->extensionAddressResponse = (PS_ExtensionAddressResponse) OSCL_DEFAULT_MALLOC(sizeof(S_ExtensionAddressResponse));
+            Decode_ExtensionAddressResponse(x->extensionAddressResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 9:
+            GetLengthDet(stream);
+            x->chairTokenOwnerResponse = (PS_ChairTokenOwnerResponse) OSCL_DEFAULT_MALLOC(sizeof(S_ChairTokenOwnerResponse));
+            Decode_ChairTokenOwnerResponse(x->chairTokenOwnerResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 10:
+            GetLengthDet(stream);
+            x->terminalCertificateResponse = (PS_TerminalCertificateResponse) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCertificateResponse));
+            Decode_TerminalCertificateResponse(x->terminalCertificateResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->broadcastMyLogicalChannelResponse = (PS_BroadcastMyLogicalChannelResponse) OSCL_DEFAULT_MALLOC(sizeof(S_BroadcastMyLogicalChannelResponse));
+            Decode_BroadcastMyLogicalChannelResponse(x->broadcastMyLogicalChannelResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->makeTerminalBroadcasterResponse = (PS_MakeTerminalBroadcasterResponse) OSCL_DEFAULT_MALLOC(sizeof(S_MakeTerminalBroadcasterResponse));
+            Decode_MakeTerminalBroadcasterResponse(x->makeTerminalBroadcasterResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->sendThisSourceResponse = (PS_SendThisSourceResponse) OSCL_DEFAULT_MALLOC(sizeof(S_SendThisSourceResponse));
+            Decode_SendThisSourceResponse(x->sendThisSourceResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 14:
+            GetLengthDet(stream);
+            x->requestAllTerminalIDsResponse = (PS_RequestAllTerminalIDsResponse) OSCL_DEFAULT_MALLOC(sizeof(S_RequestAllTerminalIDsResponse));
+            Decode_RequestAllTerminalIDsResponse(x->requestAllTerminalIDsResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            x->remoteMCResponse = (PS_RemoteMCResponse) OSCL_DEFAULT_MALLOC(sizeof(S_RemoteMCResponse));
+            Decode_RemoteMCResponse(x->remoteMCResponse, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ConferenceResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for SendThisSourceResponse (CHOICE)  */
+/* <===============================================> */
+void Decode_SendThisSourceResponse(PS_SendThisSourceResponse x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedSendThisSource is NULL) */
+            break;
+        case 1:
+            /* (deniedSendThisSource is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_SendThisSourceResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================================> */
+/*  PER-Decoder for MakeTerminalBroadcasterResponse (CHOICE)  */
+/* <========================================================> */
+void Decode_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedMakeTerminalBroadcaster is NULL) */
+            break;
+        case 1:
+            /* (deniedMakeTerminalBroadcaster is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MakeTerminalBroadcasterResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Decoder for BroadcastMyLogicalChannelResponse (CHOICE)  */
+/* <==========================================================> */
+void Decode_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedBroadcastMyLogicalChannel is NULL) */
+            break;
+        case 1:
+            /* (deniedBroadcastMyLogicalChannel is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_BroadcastMyLogicalChannelResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for TerminalCertificateResponse (SEQUENCE)  */
+/* <======================================================> */
+void Decode_TerminalCertificateResponse(PS_TerminalCertificateResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_terminalLabel = GetBoolean(stream);
+    x->option_of_certificateResponse = GetBoolean(stream);
+    if (x->option_of_terminalLabel)
+    {
+        Decode_TerminalLabel(&x->terminalLabel, stream);
+    }
+    if (x->option_of_certificateResponse)
+    {
+        GetOctetString(0, 1, 65535, &x->certificateResponse, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalCertificateResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for ChairTokenOwnerResponse (SEQUENCE)  */
+/* <==================================================> */
+void Decode_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TerminalLabel(&x->terminalLabel, stream);
+    GetOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ChairTokenOwnerResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for ExtensionAddressResponse (SEQUENCE)  */
+/* <===================================================> */
+void Decode_ExtensionAddressResponse(PS_ExtensionAddressResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 1, 128, &x->extensionAddress, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ExtensionAddressResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for MakeMeChairResponse (CHOICE)  */
+/* <============================================> */
+void Decode_MakeMeChairResponse(PS_MakeMeChairResponse x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedChairToken is NULL) */
+            break;
+        case 1:
+            /* (deniedChairToken is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MakeMeChairResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for PasswordResponse (SEQUENCE)  */
+/* <===========================================> */
+void Decode_PasswordResponse(PS_PasswordResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TerminalLabel(&x->terminalLabel, stream);
+    GetOctetString(0, 1, 32, &x->password, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_PasswordResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for ConferenceIDResponse (SEQUENCE)  */
+/* <===============================================> */
+void Decode_ConferenceIDResponse(PS_ConferenceIDResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TerminalLabel(&x->terminalLabel, stream);
+    GetOctetString(0, 1, 32, &x->conferenceID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ConferenceIDResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for TerminalIDResponse (SEQUENCE)  */
+/* <=============================================> */
+void Decode_TerminalIDResponse(PS_TerminalIDResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TerminalLabel(&x->terminalLabel, stream);
+    GetOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalIDResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for MCTerminalIDResponse (SEQUENCE)  */
+/* <===============================================> */
+void Decode_MCTerminalIDResponse(PS_MCTerminalIDResponse x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TerminalLabel(&x->terminalLabel, stream);
+    GetOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MCTerminalIDResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================================> */
+/*  PER-Decoder for RequestAllTerminalIDsResponse (SEQUENCE)  */
+/* <========================================================> */
+void Decode_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->size_of_terminalInformation = (uint16) GetLengthDet(stream);
+    x->terminalInformation = (PS_TerminalInformation)
+                             OSCL_DEFAULT_MALLOC(x->size_of_terminalInformation * sizeof(S_TerminalInformation));
+    for (i = 0;i < x->size_of_terminalInformation;++i)
+    {
+        Decode_TerminalInformation(x->terminalInformation + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RequestAllTerminalIDsResponse: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for TerminalInformation (SEQUENCE)  */
+/* <==============================================> */
+void Decode_TerminalInformation(PS_TerminalInformation x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TerminalLabel(&x->terminalLabel, stream);
+    GetOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalInformation: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for RemoteMCRequest (CHOICE)  */
+/* <========================================> */
+void Decode_RemoteMCRequest(PS_RemoteMCRequest x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (masterActivate is NULL) */
+            break;
+        case 1:
+            /* (slaveActivate is NULL) */
+            break;
+        case 2:
+            /* (deActivate is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RemoteMCRequest: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for RemoteMCResponse (CHOICE)  */
+/* <=========================================> */
+void Decode_RemoteMCResponse(PS_RemoteMCResponse x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (accept is NULL) */
+            break;
+        case 1:
+            x->reject = (PS_Reject) OSCL_DEFAULT_MALLOC(sizeof(S_Reject));
+            Decode_Reject(x->reject, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RemoteMCResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for Reject (CHOICE)  */
+/* <===============================> */
+void Decode_Reject(PS_Reject x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (functionNotSupported is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Reject: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for MultilinkRequest (CHOICE)  */
+/* <=========================================> */
+void Decode_MultilinkRequest(PS_MultilinkRequest x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->callInformation = (PS_CallInformation) OSCL_DEFAULT_MALLOC(sizeof(S_CallInformation));
+            Decode_CallInformation(x->callInformation, stream);
+            break;
+        case 2:
+            x->addConnection = (PS_AddConnection) OSCL_DEFAULT_MALLOC(sizeof(S_AddConnection));
+            Decode_AddConnection(x->addConnection, stream);
+            break;
+        case 3:
+            x->removeConnection = (PS_RemoveConnection) OSCL_DEFAULT_MALLOC(sizeof(S_RemoveConnection));
+            Decode_RemoveConnection(x->removeConnection, stream);
+            break;
+        case 4:
+            x->maximumHeaderInterval = (PS_MaximumHeaderInterval) OSCL_DEFAULT_MALLOC(sizeof(S_MaximumHeaderInterval));
+            Decode_MaximumHeaderInterval(x->maximumHeaderInterval, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MultilinkRequest: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for MaximumHeaderInterval (SEQUENCE)  */
+/* <================================================> */
+void Decode_MaximumHeaderInterval(PS_MaximumHeaderInterval x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_RequestType(&x->requestType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MaximumHeaderInterval: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for RequestType (CHOICE)  */
+/* <====================================> */
+void Decode_RequestType(PS_RequestType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (currentIntervalInformation is NULL) */
+            break;
+        case 1:
+            x->requestedInterval = (uint16) GetInteger(0, 65535, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_RequestType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for RemoveConnection (SEQUENCE)  */
+/* <===========================================> */
+void Decode_RemoveConnection(PS_RemoveConnection x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_ConnectionIdentifier(&x->connectionIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RemoveConnection: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================> */
+/*  PER-Decoder for AddConnection (SEQUENCE)  */
+/* <========================================> */
+void Decode_AddConnection(PS_AddConnection x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    Decode_DialingInformation(&x->dialingInformation, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_AddConnection: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for CallInformation (SEQUENCE)  */
+/* <==========================================> */
+void Decode_CallInformation(PS_CallInformation x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->maxNumberOfAdditionalConnections = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CallInformation: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for MultilinkResponse (CHOICE)  */
+/* <==========================================> */
+void Decode_MultilinkResponse(PS_MultilinkResponse x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->respCallInformation = (PS_RespCallInformation) OSCL_DEFAULT_MALLOC(sizeof(S_RespCallInformation));
+            Decode_RespCallInformation(x->respCallInformation, stream);
+            break;
+        case 2:
+            x->respAddConnection = (PS_RespAddConnection) OSCL_DEFAULT_MALLOC(sizeof(S_RespAddConnection));
+            Decode_RespAddConnection(x->respAddConnection, stream);
+            break;
+        case 3:
+            x->respRemoveConnection = (PS_RespRemoveConnection) OSCL_DEFAULT_MALLOC(sizeof(S_RespRemoveConnection));
+            Decode_RespRemoveConnection(x->respRemoveConnection, stream);
+            break;
+        case 4:
+            x->respMaximumHeaderInterval = (PS_RespMaximumHeaderInterval) OSCL_DEFAULT_MALLOC(sizeof(S_RespMaximumHeaderInterval));
+            Decode_RespMaximumHeaderInterval(x->respMaximumHeaderInterval, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MultilinkResponse: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for RespMaximumHeaderInterval (SEQUENCE)  */
+/* <====================================================> */
+void Decode_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->currentInterval = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RespMaximumHeaderInterval: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for RespRemoveConnection (SEQUENCE)  */
+/* <===============================================> */
+void Decode_RespRemoveConnection(PS_RespRemoveConnection x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_ConnectionIdentifier(&x->connectionIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RespRemoveConnection: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for RespAddConnection (SEQUENCE)  */
+/* <============================================> */
+void Decode_RespAddConnection(PS_RespAddConnection x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    Decode_ResponseCode(&x->responseCode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RespAddConnection: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for ResponseCode (CHOICE)  */
+/* <=====================================> */
+void Decode_ResponseCode(PS_ResponseCode x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (accepted is NULL) */
+            break;
+        case 1:
+            x->rejected = (PS_Rejected) OSCL_DEFAULT_MALLOC(sizeof(S_Rejected));
+            Decode_Rejected(x->rejected, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_ResponseCode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for Rejected (CHOICE)  */
+/* <=================================> */
+void Decode_Rejected(PS_Rejected x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (connectionsNotAvailable is NULL) */
+            break;
+        case 1:
+            /* (userRejected is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Rejected: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for RespCallInformation (SEQUENCE)  */
+/* <==============================================> */
+void Decode_RespCallInformation(PS_RespCallInformation x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_DialingInformation(&x->dialingInformation, stream);
+    x->callAssociationNumber = GetInteger(0, 0xffffffff, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_RespCallInformation: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for MultilinkIndication (CHOICE)  */
+/* <============================================> */
+void Decode_MultilinkIndication(PS_MultilinkIndication x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->crcDesired = (PS_CrcDesired) OSCL_DEFAULT_MALLOC(sizeof(S_CrcDesired));
+            Decode_CrcDesired(x->crcDesired, stream);
+            break;
+        case 2:
+            x->excessiveError = (PS_ExcessiveError) OSCL_DEFAULT_MALLOC(sizeof(S_ExcessiveError));
+            Decode_ExcessiveError(x->excessiveError, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_MultilinkIndication: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for ExcessiveError (SEQUENCE)  */
+/* <=========================================> */
+void Decode_ExcessiveError(PS_ExcessiveError x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_ConnectionIdentifier(&x->connectionIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ExcessiveError: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for CrcDesired (SEQUENCE)  */
+/* <=====================================> */
+void Decode_CrcDesired(PS_CrcDesired x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CrcDesired: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for DialingInformation (CHOICE)  */
+/* <===========================================> */
+void Decode_DialingInformation(PS_DialingInformation x, PS_InStream stream)
+{
+    uint16 i;
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            x->size = (uint16) GetInteger(1, 65535, stream);
+            x->differential = (PS_DialingInformationNumber)
+                              OSCL_DEFAULT_MALLOC(x->size * sizeof(S_DialingInformationNumber));
+            for (i = 0;i < x->size;++i)
+            {
+                Decode_DialingInformationNumber(x->differential + i, stream);
+            }
+            break;
+        case 2:
+            x->infoNotAvailable = (uint16) GetInteger(1, 65535, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_DialingInformation: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for DialingInformationNumber (SEQUENCE)  */
+/* <===================================================> */
+void Decode_DialingInformationNumber(PS_DialingInformationNumber x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_subAddress = GetBoolean(stream);
+    GetCharString("NumericString", 0, 0, 40, NULL, &x->networkAddress, stream);
+    if (x->option_of_subAddress)
+    {
+        GetCharString("IA5String", 0, 1, 40, NULL, &x->subAddress, stream);
+    }
+    x->size_of_networkType = (uint8) GetInteger(1, 255, stream);
+    x->networkType = (PS_DialingInformationNetworkType)
+                     OSCL_DEFAULT_MALLOC(x->size_of_networkType * sizeof(S_DialingInformationNetworkType));
+    for (i = 0;i < x->size_of_networkType;++i)
+    {
+        Decode_DialingInformationNetworkType(x->networkType + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_DialingInformationNumber: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Decoder for DialingInformationNetworkType (CHOICE)  */
+/* <======================================================> */
+void Decode_DialingInformationNetworkType(PS_DialingInformationNetworkType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardMessage) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (n_isdn is NULL) */
+            break;
+        case 2:
+            /* (gstn is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_DialingInformationNetworkType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for ConnectionIdentifier (SEQUENCE)  */
+/* <===============================================> */
+void Decode_ConnectionIdentifier(PS_ConnectionIdentifier x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->channelTag = GetInteger(0, 0xffffffff, stream);
+    x->sequenceNumber = GetInteger(0, 0xffffffff, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ConnectionIdentifier: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for LogicalChannelRateRequest (SEQUENCE)  */
+/* <====================================================> */
+void Decode_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    x->maximumBitRate = GetInteger(0, 0xffffffff, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_LogicalChannelRateRequest: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <========================================================> */
+/*  PER-Decoder for LogicalChannelRateAcknowledge (SEQUENCE)  */
+/* <========================================================> */
+void Decode_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    x->maximumBitRate = GetInteger(0, 0xffffffff, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_LogicalChannelRateAcknowledge: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for LogicalChannelRateReject (SEQUENCE)  */
+/* <===================================================> */
+void Decode_LogicalChannelRateReject(PS_LogicalChannelRateReject x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_currentMaximumBitRate = GetBoolean(stream);
+    x->sequenceNumber = (uint8) GetInteger(0, 255, stream);
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_LogicalChannelRateRejectReason(&x->rejectReason, stream);
+    if (x->option_of_currentMaximumBitRate)
+    {
+        x->currentMaximumBitRate = GetInteger(0, 0xffffffff, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_LogicalChannelRateReject: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Decoder for LogicalChannelRateRejectReason (CHOICE)  */
+/* <=======================================================> */
+void Decode_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (undefinedReason is NULL) */
+            break;
+        case 1:
+            /* (insufficientResources is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_LogicalChannelRateRejectReason: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================================> */
+/*  PER-Decoder for LogicalChannelRateRelease (SEQUENCE)  */
+/* <====================================================> */
+void Decode_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    OSCL_UNUSED_ARG(x);
+
+    extension = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_LogicalChannelRateRelease: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for SendTerminalCapabilitySet (CHOICE)  */
+/* <==================================================> */
+void Decode_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->specificRequest = (PS_SpecificRequest) OSCL_DEFAULT_MALLOC(sizeof(S_SpecificRequest));
+            Decode_SpecificRequest(x->specificRequest, stream);
+            break;
+        case 1:
+            /* (genericRequest is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_SendTerminalCapabilitySet: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for SpecificRequest (SEQUENCE)  */
+/* <==========================================> */
+void Decode_SpecificRequest(PS_SpecificRequest x, PS_InStream stream)
+{
+    uint16 i;
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_capabilityTableEntryNumbers = GetBoolean(stream);
+    x->option_of_capabilityDescriptorNumbers = GetBoolean(stream);
+    x->multiplexCapability = GetBoolean(stream);
+    if (x->option_of_capabilityTableEntryNumbers)
+    {
+        x->size_of_capabilityTableEntryNumbers = (uint16) GetInteger(1, 65535, stream);
+        x->capabilityTableEntryNumbers = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_capabilityTableEntryNumbers * sizeof(uint32));
+        for (i = 0;i < x->size_of_capabilityTableEntryNumbers;++i)
+        {
+            x->capabilityTableEntryNumbers[i] = GetInteger(1, 65535, stream);
+        }
+    }
+    if (x->option_of_capabilityDescriptorNumbers)
+    {
+        x->size_of_capabilityDescriptorNumbers = (uint16) GetInteger(1, 256, stream);
+        x->capabilityDescriptorNumbers = (uint32*) OSCL_DEFAULT_MALLOC(x->size_of_capabilityDescriptorNumbers * sizeof(uint32));
+        for (i = 0;i < x->size_of_capabilityDescriptorNumbers;++i)
+        {
+            x->capabilityDescriptorNumbers[i] = GetInteger(0, 255, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_SpecificRequest: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for EncryptionCommand (CHOICE)  */
+/* <==========================================> */
+void Decode_EncryptionCommand(PS_EncryptionCommand x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->encryptionSE = (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            GetOctetString(1, 0, 0, x->encryptionSE, stream);
+            break;
+        case 1:
+            /* (encryptionIVRequest is NULL) */
+            break;
+        case 2:
+            x->encryptionAlgorithmID = (PS_EncryptionAlgorithmID) OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionAlgorithmID));
+            Decode_EncryptionAlgorithmID(x->encryptionAlgorithmID, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_EncryptionCommand: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for EncryptionAlgorithmID (SEQUENCE)  */
+/* <================================================> */
+void Decode_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x, PS_InStream stream)
+{
+    x->h233AlgorithmIdentifier = (uint8) GetInteger(0, 255, stream);
+    Decode_NonStandardParameter(&x->associatedAlgorithm, stream);
+}
+
+/* <=============================================> */
+/*  PER-Decoder for FlowControlCommand (SEQUENCE)  */
+/* <=============================================> */
+void Decode_FlowControlCommand(PS_FlowControlCommand x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_FccScope(&x->fccScope, stream);
+    Decode_FccRestriction(&x->fccRestriction, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_FlowControlCommand: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for FccRestriction (CHOICE)  */
+/* <=======================================> */
+void Decode_FccRestriction(PS_FccRestriction x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->maximumBitRate = GetInteger(0, 16777215, stream);
+            break;
+        case 1:
+            /* (noRestriction is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_FccRestriction: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for FccScope (CHOICE)  */
+/* <=================================> */
+void Decode_FccScope(PS_FccScope x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            x->resourceID = (uint16) GetInteger(0, 65535, stream);
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_FccScope: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for EndSessionCommand (CHOICE)  */
+/* <==========================================> */
+void Decode_EndSessionCommand(PS_EndSessionCommand x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (disconnect is NULL) */
+            break;
+        case 2:
+            x->gstnOptions = (PS_GstnOptions) OSCL_DEFAULT_MALLOC(sizeof(S_GstnOptions));
+            Decode_GstnOptions(x->gstnOptions, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            GetLengthDet(stream);
+            x->isdnOptions = (PS_IsdnOptions) OSCL_DEFAULT_MALLOC(sizeof(S_IsdnOptions));
+            Decode_IsdnOptions(x->isdnOptions, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_EndSessionCommand: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for IsdnOptions (CHOICE)  */
+/* <====================================> */
+void Decode_IsdnOptions(PS_IsdnOptions x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (telephonyMode is NULL) */
+            break;
+        case 1:
+            /* (v140 is NULL) */
+            break;
+        case 2:
+            /* (terminalOnHold is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_IsdnOptions: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for GstnOptions (CHOICE)  */
+/* <====================================> */
+void Decode_GstnOptions(PS_GstnOptions x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(5, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (telephonyMode is NULL) */
+            break;
+        case 1:
+            /* (v8bis is NULL) */
+            break;
+        case 2:
+            /* (v34DSVD is NULL) */
+            break;
+        case 3:
+            /* (v34DuplexFAX is NULL) */
+            break;
+        case 4:
+            /* (v34H324 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_GstnOptions: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for ConferenceCommand (CHOICE)  */
+/* <==========================================> */
+void Decode_ConferenceCommand(PS_ConferenceCommand x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(7, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->broadcastMyLogicalChannel = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            x->cancelBroadcastMyLogicalChannel = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 2:
+            x->makeTerminalBroadcaster = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->makeTerminalBroadcaster, stream);
+            break;
+        case 3:
+            /* (cancelMakeTerminalBroadcaster is NULL) */
+            break;
+        case 4:
+            x->sendThisSource = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->sendThisSource, stream);
+            break;
+        case 5:
+            /* (cancelSendThisSource is NULL) */
+            break;
+        case 6:
+            /* (dropConference is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            GetLengthDet(stream);
+            x->substituteConferenceIDCommand = (PS_SubstituteConferenceIDCommand) OSCL_DEFAULT_MALLOC(sizeof(S_SubstituteConferenceIDCommand));
+            Decode_SubstituteConferenceIDCommand(x->substituteConferenceIDCommand, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ConferenceCommand: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <========================================================> */
+/*  PER-Decoder for SubstituteConferenceIDCommand (SEQUENCE)  */
+/* <========================================================> */
+void Decode_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    GetOctetString(0, 16, 16, &x->conferenceIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_SubstituteConferenceIDCommand: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for MiscellaneousCommand (SEQUENCE)  */
+/* <===============================================> */
+void Decode_MiscellaneousCommand(PS_MiscellaneousCommand x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_McType(&x->mcType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MiscellaneousCommand: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for McType (CHOICE)  */
+/* <===============================> */
+void Decode_McType(PS_McType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(10, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (equaliseDelay is NULL) */
+            break;
+        case 1:
+            /* (zeroDelay is NULL) */
+            break;
+        case 2:
+            /* (multipointModeCommand is NULL) */
+            break;
+        case 3:
+            /* (cancelMultipointModeCommand is NULL) */
+            break;
+        case 4:
+            /* (videoFreezePicture is NULL) */
+            break;
+        case 5:
+            /* (videoFastUpdatePicture is NULL) */
+            break;
+        case 6:
+            x->videoFastUpdateGOB = (PS_VideoFastUpdateGOB) OSCL_DEFAULT_MALLOC(sizeof(S_VideoFastUpdateGOB));
+            Decode_VideoFastUpdateGOB(x->videoFastUpdateGOB, stream);
+            break;
+        case 7:
+            x->videoTemporalSpatialTradeOff = (uint8) GetInteger(0, 31, stream);
+            break;
+        case 8:
+            /* (videoSendSyncEveryGOB is NULL) */
+            break;
+        case 9:
+            /* (videoSendSyncEveryGOBCancel is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            GetLengthDet(stream);
+            x->videoFastUpdateMB = (PS_VideoFastUpdateMB) OSCL_DEFAULT_MALLOC(sizeof(S_VideoFastUpdateMB));
+            Decode_VideoFastUpdateMB(x->videoFastUpdateMB, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->maxH223MUXPDUsize = (uint16) GetInteger(1, (uint16) 65535, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->encryptionUpdate = (PS_EncryptionSync) OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionSync));
+            Decode_EncryptionSync(x->encryptionUpdate, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->encryptionUpdateRequest = (PS_EncryptionUpdateRequest) OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionUpdateRequest));
+            Decode_EncryptionUpdateRequest(x->encryptionUpdateRequest, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 14:
+            GetLengthDet(stream);
+            /* (switchReceiveMediaOff is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            /* (switchReceiveMediaOn is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 16:
+            GetLengthDet(stream);
+            x->progressiveRefinementStart = (PS_ProgressiveRefinementStart) OSCL_DEFAULT_MALLOC(sizeof(S_ProgressiveRefinementStart));
+            Decode_ProgressiveRefinementStart(x->progressiveRefinementStart, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 17:
+            GetLengthDet(stream);
+            /* (progressiveRefinementAbortOne is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 18:
+            GetLengthDet(stream);
+            /* (progressiveRefinementAbortContinuous is NULL) */
+            SkipOneOctet(stream);
+            break;
+        default:
+            ErrorMessage("Decode_McType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Decoder for ProgressiveRefinementStart (SEQUENCE)  */
+/* <=====================================================> */
+void Decode_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_PrsRepeatCount(&x->prsRepeatCount, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_ProgressiveRefinementStart: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for PrsRepeatCount (CHOICE)  */
+/* <=======================================> */
+void Decode_PrsRepeatCount(PS_PrsRepeatCount x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (doOneProgression is NULL) */
+            break;
+        case 1:
+            /* (doContinuousProgressions is NULL) */
+            break;
+        case 2:
+            /* (doOneIndependentProgression is NULL) */
+            break;
+        case 3:
+            /* (doContinuousIndependentProgressions is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_PrsRepeatCount: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for VideoFastUpdateMB (SEQUENCE)  */
+/* <============================================> */
+void Decode_VideoFastUpdateMB(PS_VideoFastUpdateMB x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_firstGOB = GetBoolean(stream);
+    x->option_of_firstMB = GetBoolean(stream);
+    if (x->option_of_firstGOB)
+    {
+        x->firstGOB = (uint8)  GetInteger(0, 255, stream);
+    }
+    if (x->option_of_firstMB)
+    {
+        x->firstMB = (uint16) GetInteger(1, 8192, stream);
+    }
+    x->numberOfMBs = (uint16) GetInteger(1, 8192, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VideoFastUpdateMB: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for VideoFastUpdateGOB (SEQUENCE)  */
+/* <=============================================> */
+void Decode_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x, PS_InStream stream)
+{
+    x->firstGOB = (uint8) GetInteger(0, 17, stream);
+    x->numberOfGOBs = (uint8) GetInteger(1, 18, stream);
+}
+
+/* <==============================================> */
+/*  PER-Decoder for KeyProtectionMethod (SEQUENCE)  */
+/* <==============================================> */
+void Decode_KeyProtectionMethod(PS_KeyProtectionMethod x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->secureChannel = GetBoolean(stream);
+    x->sharedSecret = GetBoolean(stream);
+    x->certProtectedKey = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_KeyProtectionMethod: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for EncryptionUpdateRequest (SEQUENCE)  */
+/* <==================================================> */
+void Decode_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_keyProtectionMethod = GetBoolean(stream);
+    if (x->option_of_keyProtectionMethod)
+    {
+        Decode_KeyProtectionMethod(&x->keyProtectionMethod, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_EncryptionUpdateRequest: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Decoder for H223MultiplexReconfiguration (CHOICE)  */
+/* <=====================================================> */
+void Decode_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->h223ModeChange = (PS_H223ModeChange) OSCL_DEFAULT_MALLOC(sizeof(S_H223ModeChange));
+            Decode_H223ModeChange(x->h223ModeChange, stream);
+            break;
+        case 1:
+            x->h223AnnexADoubleFlag = (PS_H223AnnexADoubleFlag) OSCL_DEFAULT_MALLOC(sizeof(S_H223AnnexADoubleFlag));
+            Decode_H223AnnexADoubleFlag(x->h223AnnexADoubleFlag, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_H223MultiplexReconfiguration: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H223AnnexADoubleFlag (CHOICE)  */
+/* <=============================================> */
+void Decode_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (start is NULL) */
+            break;
+        case 1:
+            /* (stop is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_H223AnnexADoubleFlag: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for H223ModeChange (CHOICE)  */
+/* <=======================================> */
+void Decode_H223ModeChange(PS_H223ModeChange x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (toLevel0 is NULL) */
+            break;
+        case 1:
+            /* (toLevel1 is NULL) */
+            break;
+        case 2:
+            /* (toLevel2 is NULL) */
+            break;
+        case 3:
+            /* (toLevel2withOptionalHeader is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_H223ModeChange: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==========================================> */
+/*  PER-Decoder for NewATMVCCommand (SEQUENCE)  */
+/* <==========================================> */
+void Decode_NewATMVCCommand(PS_NewATMVCCommand x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->resourceID = (uint16) GetInteger(0, 65535, stream);
+    x->bitRate = (uint16) GetInteger(1, 65535, stream);
+    x->bitRateLockedToPCRClock = GetBoolean(stream);
+    x->bitRateLockedToNetworkClock = GetBoolean(stream);
+    Decode_CmdAal(&x->cmdAal, stream);
+    Decode_CmdMultiplex(&x->cmdMultiplex, stream);
+    Decode_CmdReverseParameters(&x->cmdReverseParameters, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_NewATMVCCommand: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for CmdReverseParameters (SEQUENCE)  */
+/* <===============================================> */
+void Decode_CmdReverseParameters(PS_CmdReverseParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->bitRate = (uint16) GetInteger(1, 65535, stream);
+    x->bitRateLockedToPCRClock = GetBoolean(stream);
+    x->bitRateLockedToNetworkClock = GetBoolean(stream);
+    Decode_Multiplex(&x->multiplex, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CmdReverseParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for Multiplex (CHOICE)  */
+/* <==================================> */
+void Decode_Multiplex(PS_Multiplex x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_Multiplex: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for CmdMultiplex (CHOICE)  */
+/* <=====================================> */
+void Decode_CmdMultiplex(PS_CmdMultiplex x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CmdMultiplex: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for CmdAal (CHOICE)  */
+/* <===============================> */
+void Decode_CmdAal(PS_CmdAal x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->cmdAal1 = (PS_CmdAal1) OSCL_DEFAULT_MALLOC(sizeof(S_CmdAal1));
+            Decode_CmdAal1(x->cmdAal1, stream);
+            break;
+        case 1:
+            x->cmdAal5 = (PS_CmdAal5) OSCL_DEFAULT_MALLOC(sizeof(S_CmdAal5));
+            Decode_CmdAal5(x->cmdAal5, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CmdAal: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for CmdAal5 (SEQUENCE)  */
+/* <==================================> */
+void Decode_CmdAal5(PS_CmdAal5 x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardMaximumSDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->backwardMaximumSDUSize = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CmdAal5: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for CmdAal1 (SEQUENCE)  */
+/* <==================================> */
+void Decode_CmdAal1(PS_CmdAal1 x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_CmdClockRecovery(&x->cmdClockRecovery, stream);
+    Decode_CmdErrorCorrection(&x->cmdErrorCorrection, stream);
+    x->structuredDataTransfer = GetBoolean(stream);
+    x->partiallyFilledCells = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_CmdAal1: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for CmdErrorCorrection (CHOICE)  */
+/* <===========================================> */
+void Decode_CmdErrorCorrection(PS_CmdErrorCorrection x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullErrorCorrection is NULL) */
+            break;
+        case 1:
+            /* (longInterleaver is NULL) */
+            break;
+        case 2:
+            /* (shortInterleaver is NULL) */
+            break;
+        case 3:
+            /* (errorCorrectionOnly is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CmdErrorCorrection: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for CmdClockRecovery (CHOICE)  */
+/* <=========================================> */
+void Decode_CmdClockRecovery(PS_CmdClockRecovery x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullClockRecovery is NULL) */
+            break;
+        case 1:
+            /* (srtsClockRecovery is NULL) */
+            break;
+        case 2:
+            /* (adaptiveClockRecovery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_CmdClockRecovery: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==============================================> */
+/*  PER-Decoder for FunctionNotUnderstood (CHOICE)  */
+/* <==============================================> */
+void Decode_FunctionNotUnderstood(PS_FunctionNotUnderstood x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->request = (PS_RequestMessage) OSCL_DEFAULT_MALLOC(sizeof(S_RequestMessage));
+            Decode_RequestMessage(x->request, stream);
+            break;
+        case 1:
+            x->response = (PS_ResponseMessage) OSCL_DEFAULT_MALLOC(sizeof(S_ResponseMessage));
+            Decode_ResponseMessage(x->response, stream);
+            break;
+        case 2:
+            x->command = (PS_CommandMessage) OSCL_DEFAULT_MALLOC(sizeof(S_CommandMessage));
+            Decode_CommandMessage(x->command, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_FunctionNotUnderstood: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for FunctionNotSupported (SEQUENCE)  */
+/* <===============================================> */
+void Decode_FunctionNotSupported(PS_FunctionNotSupported x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_returnedFunction = GetBoolean(stream);
+    Decode_FnsCause(&x->fnsCause, stream);
+    if (x->option_of_returnedFunction)
+    {
+        GetOctetString(1, 0, 0, &x->returnedFunction, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_FunctionNotSupported: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for FnsCause (CHOICE)  */
+/* <=================================> */
+void Decode_FnsCause(PS_FnsCause x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (syntaxError is NULL) */
+            break;
+        case 1:
+            /* (semanticError is NULL) */
+            break;
+        case 2:
+            /* (unknownFunction is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_FnsCause: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for ConferenceIndication (CHOICE)  */
+/* <=============================================> */
+void Decode_ConferenceIndication(PS_ConferenceIndication x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(10, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->sbeNumber = (uint8) GetInteger(0, 9, stream);
+            break;
+        case 1:
+            x->terminalNumberAssign = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->terminalNumberAssign, stream);
+            break;
+        case 2:
+            x->terminalJoinedConference = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->terminalJoinedConference, stream);
+            break;
+        case 3:
+            x->terminalLeftConference = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->terminalLeftConference, stream);
+            break;
+        case 4:
+            /* (seenByAtLeastOneOther is NULL) */
+            break;
+        case 5:
+            /* (cancelSeenByAtLeastOneOther is NULL) */
+            break;
+        case 6:
+            /* (seenByAll is NULL) */
+            break;
+        case 7:
+            /* (cancelSeenByAll is NULL) */
+            break;
+        case 8:
+            x->terminalYouAreSeeing = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->terminalYouAreSeeing, stream);
+            break;
+        case 9:
+            /* (requestForFloor is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            GetLengthDet(stream);
+            /* (withdrawChairToken is NULL) */
+            SkipOneOctet(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->floorRequested = (PS_TerminalLabel) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalLabel));
+            Decode_TerminalLabel(x->floorRequested, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            x->terminalYouAreSeeingInSubPictureNumber = (PS_TerminalYouAreSeeingInSubPictureNumber) OSCL_DEFAULT_MALLOC(sizeof(S_TerminalYouAreSeeingInSubPictureNumber));
+            Decode_TerminalYouAreSeeingInSubPictureNumber(x->terminalYouAreSeeingInSubPictureNumber, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            x->videoIndicateCompose = (PS_VideoIndicateCompose) OSCL_DEFAULT_MALLOC(sizeof(S_VideoIndicateCompose));
+            Decode_VideoIndicateCompose(x->videoIndicateCompose, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ConferenceIndication: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=================================================================> */
+/*  PER-Decoder for TerminalYouAreSeeingInSubPictureNumber (SEQUENCE)  */
+/* <=================================================================> */
+void Decode_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->terminalNumber = (uint8) GetInteger(0, 192, stream);
+    x->subPictureNumber = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_TerminalYouAreSeeingInSubPictureNumber: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for VideoIndicateCompose (SEQUENCE)  */
+/* <===============================================> */
+void Decode_VideoIndicateCompose(PS_VideoIndicateCompose x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->compositionNumber = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VideoIndicateCompose: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================================> */
+/*  PER-Decoder for MiscellaneousIndication (SEQUENCE)  */
+/* <==================================================> */
+void Decode_MiscellaneousIndication(PS_MiscellaneousIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    Decode_MiType(&x->miType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MiscellaneousIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for MiType (CHOICE)  */
+/* <===============================> */
+void Decode_MiType(PS_MiType x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(10, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (logicalChannelActive is NULL) */
+            break;
+        case 1:
+            /* (logicalChannelInactive is NULL) */
+            break;
+        case 2:
+            /* (multipointConference is NULL) */
+            break;
+        case 3:
+            /* (cancelMultipointConference is NULL) */
+            break;
+        case 4:
+            /* (multipointZeroComm is NULL) */
+            break;
+        case 5:
+            /* (cancelMultipointZeroComm is NULL) */
+            break;
+        case 6:
+            /* (multipointSecondaryStatus is NULL) */
+            break;
+        case 7:
+            /* (cancelMultipointSecondaryStatus is NULL) */
+            break;
+        case 8:
+            /* (videoIndicateReadyToActivate is NULL) */
+            break;
+        case 9:
+            x->videoTemporalSpatialTradeOff = (uint8) GetInteger(0, 31, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            GetLengthDet(stream);
+            x->videoNotDecodedMBs = (PS_VideoNotDecodedMBs) OSCL_DEFAULT_MALLOC(sizeof(S_VideoNotDecodedMBs));
+            Decode_VideoNotDecodedMBs(x->videoNotDecodedMBs, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 11:
+            GetLengthDet(stream);
+            x->transportCapability = (PS_TransportCapability) OSCL_DEFAULT_MALLOC(sizeof(S_TransportCapability));
+            Decode_TransportCapability(x->transportCapability, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_MiType: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for VideoNotDecodedMBs (SEQUENCE)  */
+/* <=============================================> */
+void Decode_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->firstMB = (uint16) GetInteger(1, 8192, stream);
+    x->numberOfMBs = (uint16) GetInteger(1, 8192, stream);
+    x->temporalReference = (uint8) GetInteger(0, 255, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VideoNotDecodedMBs: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for JitterIndication (SEQUENCE)  */
+/* <===========================================> */
+void Decode_JitterIndication(PS_JitterIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_skippedFrameCount = GetBoolean(stream);
+    x->option_of_additionalDecoderBuffer = GetBoolean(stream);
+    Decode_JiScope(&x->jiScope, stream);
+    x->estimatedReceivedJitterMantissa = (uint8) GetInteger(0, 3, stream);
+    x->estimatedReceivedJitterExponent = (uint8) GetInteger(0, 7, stream);
+    if (x->option_of_skippedFrameCount)
+    {
+        x->skippedFrameCount = (uint8) GetInteger(0, 15, stream);
+    }
+    if (x->option_of_additionalDecoderBuffer)
+    {
+        x->additionalDecoderBuffer = GetInteger(0, 262143, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_JitterIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <================================> */
+/*  PER-Decoder for JiScope (CHOICE)  */
+/* <================================> */
+void Decode_JiScope(PS_JiScope x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            x->resourceID = (uint16) GetInteger(0, 65535, stream);
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_JiScope: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for H223SkewIndication (SEQUENCE)  */
+/* <=============================================> */
+void Decode_H223SkewIndication(PS_H223SkewIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->logicalChannelNumber1 = (uint16) GetInteger(1, 65535, stream);
+    x->logicalChannelNumber2 = (uint16) GetInteger(1, 65535, stream);
+    x->skew = (uint16) GetInteger(0, 4095, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H223SkewIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Decoder for H2250MaximumSkewIndication (SEQUENCE)  */
+/* <=====================================================> */
+void Decode_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->logicalChannelNumber1 = (uint16) GetInteger(1, 65535, stream);
+    x->logicalChannelNumber2 = (uint16) GetInteger(1, 65535, stream);
+    x->maximumSkew = (uint16) GetInteger(0, 4095, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_H2250MaximumSkewIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for MCLocationIndication (SEQUENCE)  */
+/* <===============================================> */
+void Decode_MCLocationIndication(PS_MCLocationIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_TransportAddress(&x->signalAddress, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_MCLocationIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for VendorIdentification (SEQUENCE)  */
+/* <===============================================> */
+void Decode_VendorIdentification(PS_VendorIdentification x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_productNumber = GetBoolean(stream);
+    x->option_of_versionNumber = GetBoolean(stream);
+    Decode_NonStandardIdentifier(&x->vendor, stream);
+    if (x->option_of_productNumber)
+    {
+        GetOctetString(0, 1, 256, &x->productNumber, stream);
+    }
+    if (x->option_of_versionNumber)
+    {
+        GetOctetString(0, 1, 256, &x->versionNumber, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_VendorIdentification: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=============================================> */
+/*  PER-Decoder for NewATMVCIndication (SEQUENCE)  */
+/* <=============================================> */
+void Decode_NewATMVCIndication(PS_NewATMVCIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->resourceID = (uint16) GetInteger(0, 65535, stream);
+    x->bitRate = (uint16) GetInteger(1, 65535, stream);
+    x->bitRateLockedToPCRClock = GetBoolean(stream);
+    x->bitRateLockedToNetworkClock = GetBoolean(stream);
+    Decode_IndAal(&x->indAal, stream);
+    Decode_IndMultiplex(&x->indMultiplex, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    x->option_of_indReverseParameters = OFF;
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        x->option_of_indReverseParameters = SigMapValue(0, map);
+        if (x->option_of_indReverseParameters)
+        {
+            ExtensionPrep(map, stream);
+            Decode_IndReverseParameters(&x->indReverseParameters, stream);
+            ReadRemainingBits(stream);
+        }
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_NewATMVCIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===============================================> */
+/*  PER-Decoder for IndReverseParameters (SEQUENCE)  */
+/* <===============================================> */
+void Decode_IndReverseParameters(PS_IndReverseParameters x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->bitRate = (uint16) GetInteger(1, 65535, stream);
+    x->bitRateLockedToPCRClock = GetBoolean(stream);
+    x->bitRateLockedToNetworkClock = GetBoolean(stream);
+    Decode_IrpMultiplex(&x->irpMultiplex, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IndReverseParameters: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for IrpMultiplex (CHOICE)  */
+/* <=====================================> */
+void Decode_IrpMultiplex(PS_IrpMultiplex x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_IrpMultiplex: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=====================================> */
+/*  PER-Decoder for IndMultiplex (CHOICE)  */
+/* <=====================================> */
+void Decode_IndMultiplex(PS_IndMultiplex x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_IndMultiplex: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <===============================> */
+/*  PER-Decoder for IndAal (CHOICE)  */
+/* <===============================> */
+void Decode_IndAal(PS_IndAal x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->indAal1 = (PS_IndAal1) OSCL_DEFAULT_MALLOC(sizeof(S_IndAal1));
+            Decode_IndAal1(x->indAal1, stream);
+            break;
+        case 1:
+            x->indAal5 = (PS_IndAal5) OSCL_DEFAULT_MALLOC(sizeof(S_IndAal5));
+            Decode_IndAal5(x->indAal5, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_IndAal: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for IndAal5 (SEQUENCE)  */
+/* <==================================> */
+void Decode_IndAal5(PS_IndAal5 x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->forwardMaximumSDUSize = (uint16) GetInteger(0, 65535, stream);
+    x->backwardMaximumSDUSize = (uint16) GetInteger(0, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IndAal5: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==================================> */
+/*  PER-Decoder for IndAal1 (SEQUENCE)  */
+/* <==================================> */
+void Decode_IndAal1(PS_IndAal1 x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_IndClockRecovery(&x->indClockRecovery, stream);
+    Decode_IndErrorCorrection(&x->indErrorCorrection, stream);
+    x->structuredDataTransfer = GetBoolean(stream);
+    x->partiallyFilledCells = GetBoolean(stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_IndAal1: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Decoder for IndErrorCorrection (CHOICE)  */
+/* <===========================================> */
+void Decode_IndErrorCorrection(PS_IndErrorCorrection x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullErrorCorrection is NULL) */
+            break;
+        case 1:
+            /* (longInterleaver is NULL) */
+            break;
+        case 2:
+            /* (shortInterleaver is NULL) */
+            break;
+        case 3:
+            /* (errorCorrectionOnly is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_IndErrorCorrection: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Decoder for IndClockRecovery (CHOICE)  */
+/* <=========================================> */
+void Decode_IndClockRecovery(PS_IndClockRecovery x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullClockRecovery is NULL) */
+            break;
+        case 1:
+            /* (srtsClockRecovery is NULL) */
+            break;
+        case 2:
+            /* (adaptiveClockRecovery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_IndClockRecovery: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <============================================> */
+/*  PER-Decoder for UserInputIndication (CHOICE)  */
+/* <============================================> */
+void Decode_UserInputIndication(PS_UserInputIndication x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            x->alphanumeric = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+            GetCharString("GeneralString", 1, 0, 0, NULL, x->alphanumeric, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            GetLengthDet(stream);
+            x->userInputSupportIndication = (PS_UserInputSupportIndication) OSCL_DEFAULT_MALLOC(sizeof(S_UserInputSupportIndication));
+            Decode_UserInputSupportIndication(x->userInputSupportIndication, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 3:
+            GetLengthDet(stream);
+            x->signal = (PS_Signal) OSCL_DEFAULT_MALLOC(sizeof(S_Signal));
+            Decode_Signal(x->signal, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 4:
+            GetLengthDet(stream);
+            x->signalUpdate = (PS_SignalUpdate) OSCL_DEFAULT_MALLOC(sizeof(S_SignalUpdate));
+            Decode_SignalUpdate(x->signalUpdate, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_UserInputIndication: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for SignalUpdate (SEQUENCE)  */
+/* <=======================================> */
+void Decode_SignalUpdate(PS_SignalUpdate x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_rtp = GetBoolean(stream);
+    x->duration = (uint16) GetInteger(1, 65535, stream);
+    if (x->option_of_rtp)
+    {
+        Decode_Rtp(&x->rtp, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_SignalUpdate: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <==============================> */
+/*  PER-Decoder for Rtp (SEQUENCE)  */
+/* <==============================> */
+void Decode_Rtp(PS_Rtp x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Rtp: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for Signal (SEQUENCE)  */
+/* <=================================> */
+void Decode_Signal(PS_Signal x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_duration = GetBoolean(stream);
+    x->option_of_signalRtp = GetBoolean(stream);
+    GetCharString("IA5String", 0, 1, 1, "0123456789#*ABCD!", &x->signalType, stream);
+    if (x->option_of_duration)
+    {
+        x->duration = (uint16) GetInteger(1, 65535, stream);
+    }
+    if (x->option_of_signalRtp)
+    {
+        Decode_SignalRtp(&x->signalRtp, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_Signal: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <====================================> */
+/*  PER-Decoder for SignalRtp (SEQUENCE)  */
+/* <====================================> */
+void Decode_SignalRtp(PS_SignalRtp x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    x->option_of_timestamp = GetBoolean(stream);
+    x->option_of_expirationTime = GetBoolean(stream);
+    if (x->option_of_timestamp)
+    {
+        x->timestamp = GetInteger(0, 0xffffffff, stream);
+    }
+    if (x->option_of_expirationTime)
+    {
+        x->expirationTime = GetInteger(0, 0xffffffff, stream);
+    }
+    x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_SignalRtp: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <===================================================> */
+/*  PER-Decoder for UserInputSupportIndication (CHOICE)  */
+/* <===================================================> */
+void Decode_UserInputSupportIndication(PS_UserInputSupportIndication x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(4, 1, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->nonStandard = (PS_NonStandardParameter) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardParameter));
+            Decode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (basicString is NULL) */
+            break;
+        case 2:
+            /* (iA5String is NULL) */
+            break;
+        case 3:
+            /* (generalString is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Decode_UserInputSupportIndication: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+/* <================================================> */
+/*  PER-Decoder for FlowControlIndication (SEQUENCE)  */
+/* <================================================> */
+void Decode_FlowControlIndication(PS_FlowControlIndication x, PS_InStream stream)
+{
+    uint8 extension;
+    PS_UnknownSigMap map;
+
+    extension = GetBoolean(stream);
+    Decode_FciScope(&x->fciScope, stream);
+    Decode_FciRestriction(&x->fciRestriction, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (extension)
+    {
+        map = GetUnknownSigMap(stream);
+        if (SkipUnreadExtensions(map, stream))
+        {
+            ErrorMessage("Decode_FlowControlIndication: Unknown extensions (skipped)");
+        }
+    }
+}
+
+/* <=======================================> */
+/*  PER-Decoder for FciRestriction (CHOICE)  */
+/* <=======================================> */
+void Decode_FciRestriction(PS_FciRestriction x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(2, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->maximumBitRate = GetInteger(0, 16777215, stream);
+            break;
+        case 1:
+            /* (noRestriction is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_FciRestriction: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Decoder for FciScope (CHOICE)  */
+/* <=================================> */
+void Decode_FciScope(PS_FciScope x, PS_InStream stream)
+{
+    x->index = GetChoiceIndex(3, 0, stream);
+    switch (x->index)
+    {
+        case 0:
+            x->logicalChannelNumber = (uint16) GetInteger(1, 65535, stream);
+            break;
+        case 1:
+            x->resourceID = (uint16) GetInteger(0, 65535, stream);
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Decode_FciScope: Illegal CHOICE index");
+    }
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_deleter.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_deleter.cpp
new file mode 100644
index 0000000..a0a905c
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_deleter.cpp
@@ -0,0 +1,8180 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_deleter.c
+//
+// DESC: PER Delete routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "per_headers.h"
+#include "h245def.h"
+#include "h245_deleter.h"
+
+/* <=======================================================> */
+/*  PER-Deleter for MultimediaSystemControlMessage (CHOICE)  */
+/* <=======================================================> */
+void Delete_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_RequestMessage(x->request);
+            OSCL_DEFAULT_FREE(x->request);
+            break;
+        case 1:
+            Delete_ResponseMessage(x->response);
+            OSCL_DEFAULT_FREE(x->response);
+            break;
+        case 2:
+            Delete_CommandMessage(x->command);
+            OSCL_DEFAULT_FREE(x->command);
+            break;
+        case 3:
+            Delete_IndicationMessage(x->indication);
+            OSCL_DEFAULT_FREE(x->indication);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MultimediaSystemControlMessage: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for RequestMessage (CHOICE)  */
+/* <=======================================> */
+void Delete_RequestMessage(PS_RequestMessage x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_MasterSlaveDetermination(x->masterSlaveDetermination);
+            OSCL_DEFAULT_FREE(x->masterSlaveDetermination);
+            break;
+        case 2:
+            Delete_TerminalCapabilitySet(x->terminalCapabilitySet);
+            OSCL_DEFAULT_FREE(x->terminalCapabilitySet);
+            break;
+        case 3:
+            Delete_OpenLogicalChannel(x->openLogicalChannel);
+            OSCL_DEFAULT_FREE(x->openLogicalChannel);
+            break;
+        case 4:
+            Delete_CloseLogicalChannel(x->closeLogicalChannel);
+            OSCL_DEFAULT_FREE(x->closeLogicalChannel);
+            break;
+        case 5:
+            Delete_RequestChannelClose(x->requestChannelClose);
+            OSCL_DEFAULT_FREE(x->requestChannelClose);
+            break;
+        case 6:
+            Delete_MultiplexEntrySend(x->multiplexEntrySend);
+            OSCL_DEFAULT_FREE(x->multiplexEntrySend);
+            break;
+        case 7:
+            Delete_RequestMultiplexEntry(x->requestMultiplexEntry);
+            OSCL_DEFAULT_FREE(x->requestMultiplexEntry);
+            break;
+        case 8:
+            Delete_RequestMode(x->requestMode);
+            OSCL_DEFAULT_FREE(x->requestMode);
+            break;
+        case 9:
+            Delete_RoundTripDelayRequest(x->roundTripDelayRequest);
+            OSCL_DEFAULT_FREE(x->roundTripDelayRequest);
+            break;
+        case 10:
+            Delete_MaintenanceLoopRequest(x->maintenanceLoopRequest);
+            OSCL_DEFAULT_FREE(x->maintenanceLoopRequest);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            Delete_CommunicationModeRequest(x->communicationModeRequest);
+            OSCL_DEFAULT_FREE(x->communicationModeRequest);
+            break;
+        case 12:
+            Delete_ConferenceRequest(x->conferenceRequest);
+            OSCL_DEFAULT_FREE(x->conferenceRequest);
+            break;
+        case 13:
+            Delete_MultilinkRequest(x->multilinkRequest);
+            OSCL_DEFAULT_FREE(x->multilinkRequest);
+            break;
+        case 14:
+            Delete_LogicalChannelRateRequest(x->logicalChannelRateRequest);
+            OSCL_DEFAULT_FREE(x->logicalChannelRateRequest);
+            break;
+        default:
+            ErrorMessage("Delete_RequestMessage: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for ResponseMessage (CHOICE)  */
+/* <========================================> */
+void Delete_ResponseMessage(PS_ResponseMessage x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_MasterSlaveDeterminationAck(x->masterSlaveDeterminationAck);
+            OSCL_DEFAULT_FREE(x->masterSlaveDeterminationAck);
+            break;
+        case 2:
+            Delete_MasterSlaveDeterminationReject(x->masterSlaveDeterminationReject);
+            OSCL_DEFAULT_FREE(x->masterSlaveDeterminationReject);
+            break;
+        case 3:
+            Delete_TerminalCapabilitySetAck(x->terminalCapabilitySetAck);
+            OSCL_DEFAULT_FREE(x->terminalCapabilitySetAck);
+            break;
+        case 4:
+            Delete_TerminalCapabilitySetReject(x->terminalCapabilitySetReject);
+            OSCL_DEFAULT_FREE(x->terminalCapabilitySetReject);
+            break;
+        case 5:
+            Delete_OpenLogicalChannelAck(x->openLogicalChannelAck);
+            OSCL_DEFAULT_FREE(x->openLogicalChannelAck);
+            break;
+        case 6:
+            Delete_OpenLogicalChannelReject(x->openLogicalChannelReject);
+            OSCL_DEFAULT_FREE(x->openLogicalChannelReject);
+            break;
+        case 7:
+            Delete_CloseLogicalChannelAck(x->closeLogicalChannelAck);
+            OSCL_DEFAULT_FREE(x->closeLogicalChannelAck);
+            break;
+        case 8:
+            Delete_RequestChannelCloseAck(x->requestChannelCloseAck);
+            OSCL_DEFAULT_FREE(x->requestChannelCloseAck);
+            break;
+        case 9:
+            Delete_RequestChannelCloseReject(x->requestChannelCloseReject);
+            OSCL_DEFAULT_FREE(x->requestChannelCloseReject);
+            break;
+        case 10:
+            Delete_MultiplexEntrySendAck(x->multiplexEntrySendAck);
+            OSCL_DEFAULT_FREE(x->multiplexEntrySendAck);
+            break;
+        case 11:
+            Delete_MultiplexEntrySendReject(x->multiplexEntrySendReject);
+            OSCL_DEFAULT_FREE(x->multiplexEntrySendReject);
+            break;
+        case 12:
+            Delete_RequestMultiplexEntryAck(x->requestMultiplexEntryAck);
+            OSCL_DEFAULT_FREE(x->requestMultiplexEntryAck);
+            break;
+        case 13:
+            Delete_RequestMultiplexEntryReject(x->requestMultiplexEntryReject);
+            OSCL_DEFAULT_FREE(x->requestMultiplexEntryReject);
+            break;
+        case 14:
+            Delete_RequestModeAck(x->requestModeAck);
+            OSCL_DEFAULT_FREE(x->requestModeAck);
+            break;
+        case 15:
+            Delete_RequestModeReject(x->requestModeReject);
+            OSCL_DEFAULT_FREE(x->requestModeReject);
+            break;
+        case 16:
+            Delete_RoundTripDelayResponse(x->roundTripDelayResponse);
+            OSCL_DEFAULT_FREE(x->roundTripDelayResponse);
+            break;
+        case 17:
+            Delete_MaintenanceLoopAck(x->maintenanceLoopAck);
+            OSCL_DEFAULT_FREE(x->maintenanceLoopAck);
+            break;
+        case 18:
+            Delete_MaintenanceLoopReject(x->maintenanceLoopReject);
+            OSCL_DEFAULT_FREE(x->maintenanceLoopReject);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            Delete_CommunicationModeResponse(x->communicationModeResponse);
+            OSCL_DEFAULT_FREE(x->communicationModeResponse);
+            break;
+        case 20:
+            Delete_ConferenceResponse(x->conferenceResponse);
+            OSCL_DEFAULT_FREE(x->conferenceResponse);
+            break;
+        case 21:
+            Delete_MultilinkResponse(x->multilinkResponse);
+            OSCL_DEFAULT_FREE(x->multilinkResponse);
+            break;
+        case 22:
+            Delete_LogicalChannelRateAcknowledge(x->logicalChannelRateAcknowledge);
+            OSCL_DEFAULT_FREE(x->logicalChannelRateAcknowledge);
+            break;
+        case 23:
+            Delete_LogicalChannelRateReject(x->logicalChannelRateReject);
+            OSCL_DEFAULT_FREE(x->logicalChannelRateReject);
+            break;
+        default:
+            ErrorMessage("Delete_ResponseMessage: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for CommandMessage (CHOICE)  */
+/* <=======================================> */
+void Delete_CommandMessage(PS_CommandMessage x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_MaintenanceLoopOffCommand(x->maintenanceLoopOffCommand);
+            OSCL_DEFAULT_FREE(x->maintenanceLoopOffCommand);
+            break;
+        case 2:
+            Delete_SendTerminalCapabilitySet(x->sendTerminalCapabilitySet);
+            OSCL_DEFAULT_FREE(x->sendTerminalCapabilitySet);
+            break;
+        case 3:
+            Delete_EncryptionCommand(x->encryptionCommand);
+            OSCL_DEFAULT_FREE(x->encryptionCommand);
+            break;
+        case 4:
+            Delete_FlowControlCommand(x->flowControlCommand);
+            OSCL_DEFAULT_FREE(x->flowControlCommand);
+            break;
+        case 5:
+            Delete_EndSessionCommand(x->endSessionCommand);
+            OSCL_DEFAULT_FREE(x->endSessionCommand);
+            break;
+        case 6:
+            Delete_MiscellaneousCommand(x->miscellaneousCommand);
+            OSCL_DEFAULT_FREE(x->miscellaneousCommand);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            Delete_CommunicationModeCommand(x->communicationModeCommand);
+            OSCL_DEFAULT_FREE(x->communicationModeCommand);
+            break;
+        case 8:
+            Delete_ConferenceCommand(x->conferenceCommand);
+            OSCL_DEFAULT_FREE(x->conferenceCommand);
+            break;
+        case 9:
+            Delete_H223MultiplexReconfiguration(x->h223MultiplexReconfiguration);
+            OSCL_DEFAULT_FREE(x->h223MultiplexReconfiguration);
+            break;
+        case 10:
+            Delete_NewATMVCCommand(x->newATMVCCommand);
+            OSCL_DEFAULT_FREE(x->newATMVCCommand);
+            break;
+        default:
+            ErrorMessage("Delete_CommandMessage: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for IndicationMessage (CHOICE)  */
+/* <==========================================> */
+void Delete_IndicationMessage(PS_IndicationMessage x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_FunctionNotUnderstood(x->functionNotUnderstood);
+            OSCL_DEFAULT_FREE(x->functionNotUnderstood);
+            break;
+        case 2:
+            Delete_MasterSlaveDeterminationRelease(x->masterSlaveDeterminationRelease);
+            OSCL_DEFAULT_FREE(x->masterSlaveDeterminationRelease);
+            break;
+        case 3:
+            Delete_TerminalCapabilitySetRelease(x->terminalCapabilitySetRelease);
+            OSCL_DEFAULT_FREE(x->terminalCapabilitySetRelease);
+            break;
+        case 4:
+            Delete_OpenLogicalChannelConfirm(x->openLogicalChannelConfirm);
+            OSCL_DEFAULT_FREE(x->openLogicalChannelConfirm);
+            break;
+        case 5:
+            Delete_RequestChannelCloseRelease(x->requestChannelCloseRelease);
+            OSCL_DEFAULT_FREE(x->requestChannelCloseRelease);
+            break;
+        case 6:
+            Delete_MultiplexEntrySendRelease(x->multiplexEntrySendRelease);
+            OSCL_DEFAULT_FREE(x->multiplexEntrySendRelease);
+            break;
+        case 7:
+            Delete_RequestMultiplexEntryRelease(x->requestMultiplexEntryRelease);
+            OSCL_DEFAULT_FREE(x->requestMultiplexEntryRelease);
+            break;
+        case 8:
+            Delete_RequestModeRelease(x->requestModeRelease);
+            OSCL_DEFAULT_FREE(x->requestModeRelease);
+            break;
+        case 9:
+            Delete_MiscellaneousIndication(x->miscellaneousIndication);
+            OSCL_DEFAULT_FREE(x->miscellaneousIndication);
+            break;
+        case 10:
+            Delete_JitterIndication(x->jitterIndication);
+            OSCL_DEFAULT_FREE(x->jitterIndication);
+            break;
+        case 11:
+            Delete_H223SkewIndication(x->h223SkewIndication);
+            OSCL_DEFAULT_FREE(x->h223SkewIndication);
+            break;
+        case 12:
+            Delete_NewATMVCIndication(x->newATMVCIndication);
+            OSCL_DEFAULT_FREE(x->newATMVCIndication);
+            break;
+        case 13:
+            Delete_UserInputIndication(x->userInput);
+            OSCL_DEFAULT_FREE(x->userInput);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            Delete_H2250MaximumSkewIndication(x->h2250MaximumSkewIndication);
+            OSCL_DEFAULT_FREE(x->h2250MaximumSkewIndication);
+            break;
+        case 15:
+            Delete_MCLocationIndication(x->mcLocationIndication);
+            OSCL_DEFAULT_FREE(x->mcLocationIndication);
+            break;
+        case 16:
+            Delete_ConferenceIndication(x->conferenceIndication);
+            OSCL_DEFAULT_FREE(x->conferenceIndication);
+            break;
+        case 17:
+            Delete_VendorIdentification(x->vendorIdentification);
+            OSCL_DEFAULT_FREE(x->vendorIdentification);
+            break;
+        case 18:
+            Delete_FunctionNotSupported(x->functionNotSupported);
+            OSCL_DEFAULT_FREE(x->functionNotSupported);
+            break;
+        case 19:
+            Delete_MultilinkIndication(x->multilinkIndication);
+            OSCL_DEFAULT_FREE(x->multilinkIndication);
+            break;
+        case 20:
+            Delete_LogicalChannelRateRelease(x->logicalChannelRateRelease);
+            OSCL_DEFAULT_FREE(x->logicalChannelRateRelease);
+            break;
+        case 21:
+            Delete_FlowControlIndication(x->flowControlIndication);
+            OSCL_DEFAULT_FREE(x->flowControlIndication);
+            break;
+        default:
+            ErrorMessage("Delete_IndicationMessage: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for GenericInformation (SEQUENCE)  */
+/* <=============================================> */
+void Delete_GenericInformation(PS_GenericInformation x)
+{
+    uint16 i = 0;
+    Delete_CapabilityIdentifier(&x->messageIdentifier);
+    if (x->option_of_subMessageIdentifier)
+    {
+    }
+    if (x->option_of_messageContent)
+    {
+        for (i = 0;i < x->size_of_messageContent;++i)
+        {
+            Delete_GenericParameter(x->messageContent + i);
+        }
+        OSCL_DEFAULT_FREE(x->messageContent);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for NonStandardMessage (SEQUENCE)  */
+/* <=============================================> */
+void Delete_NonStandardMessage(PS_NonStandardMessage x)
+{
+    Delete_NonStandardParameter(&x->nonStandardData);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for NonStandardParameter (SEQUENCE)  */
+/* <===============================================> */
+void Delete_NonStandardParameter(PS_NonStandardParameter x)
+{
+    Delete_NonStandardIdentifier(&x->nonStandardIdentifier);
+}
+
+/* <==============================================> */
+/*  PER-Deleter for NonStandardIdentifier (CHOICE)  */
+/* <==============================================> */
+void Delete_NonStandardIdentifier(PS_NonStandardIdentifier x)
+{
+    switch (x->index)
+    {
+        case 0:
+            FreeObjectID(x->object);
+            break;
+        case 1:
+            Delete_H221NonStandard(x->h221NonStandard);
+            OSCL_DEFAULT_FREE(x->h221NonStandard);
+            break;
+        default:
+            ErrorMessage("Delete_NonStandardIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for H221NonStandard (SEQUENCE)  */
+/* <==========================================> */
+void Delete_H221NonStandard(PS_H221NonStandard x)
+{
+    OSCL_UNUSED_ARG(x);
+}
+
+/* <===================================================> */
+/*  PER-Deleter for MasterSlaveDetermination (SEQUENCE)  */
+/* <===================================================> */
+void Delete_MasterSlaveDetermination(PS_MasterSlaveDetermination x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Deleter for MasterSlaveDeterminationAck (SEQUENCE)  */
+/* <======================================================> */
+void Delete_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x)
+{
+    Delete_Decision(&x->decision);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Deleter for Decision (CHOICE)  */
+/* <=================================> */
+void Delete_Decision(PS_Decision x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (master is NULL) */
+            break;
+        case 1:
+            /* (slave is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Decision: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================================> */
+/*  PER-Deleter for MasterSlaveDeterminationReject (SEQUENCE)  */
+/* <=========================================================> */
+void Delete_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x)
+{
+    Delete_MsdRejectCause(&x->msdRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for MsdRejectCause (CHOICE)  */
+/* <=======================================> */
+void Delete_MsdRejectCause(PS_MsdRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (identicalNumbers is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MsdRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Deleter for MasterSlaveDeterminationRelease (SEQUENCE)  */
+/* <==========================================================> */
+void Delete_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for TerminalCapabilitySet (SEQUENCE)  */
+/* <================================================> */
+void Delete_TerminalCapabilitySet(PS_TerminalCapabilitySet x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_genericInformation;
+    OSCL_DEFAULT_FREE(x->protocolIdentifier.data);
+    if (x->option_of_multiplexCapability)
+    {
+        Delete_MultiplexCapability(&x->multiplexCapability);
+    }
+    if (x->option_of_capabilityTable)
+    {
+        for (i = 0;i < x->size_of_capabilityTable;++i)
+        {
+            Delete_CapabilityTableEntry(x->capabilityTable + i);
+        }
+        OSCL_DEFAULT_FREE(x->capabilityTable);
+    }
+    if (x->option_of_capabilityDescriptors)
+    {
+        for (i = 0;i < x->size_of_capabilityDescriptors;++i)
+        {
+            Delete_CapabilityDescriptor(x->capabilityDescriptors + i);
+        }
+        OSCL_DEFAULT_FREE(x->capabilityDescriptors);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_genericInformation)
+    {
+        for (i = 0;i < x->size_of_genericInformation;++i)
+        {
+            Delete_GenericInformation(x->genericInformation + i);
+        }
+        OSCL_DEFAULT_FREE(x->genericInformation);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for CapabilityTableEntry (SEQUENCE)  */
+/* <===============================================> */
+void Delete_CapabilityTableEntry(PS_CapabilityTableEntry x)
+{
+    if (x->option_of_capability)
+    {
+        Delete_Capability(&x->capability);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for CapabilityDescriptor (SEQUENCE)  */
+/* <===============================================> */
+void Delete_CapabilityDescriptor(PS_CapabilityDescriptor x)
+{
+    uint16 i = 0;
+    if (x->option_of_simultaneousCapabilities)
+    {
+        for (i = 0;i < x->size_of_simultaneousCapabilities;++i)
+        {
+            Delete_AlternativeCapabilitySet(x->simultaneousCapabilities + i);
+        }
+        OSCL_DEFAULT_FREE(x->simultaneousCapabilities);
+    }
+}
+
+/* <======================================================> */
+/*  PER-Deleter for AlternativeCapabilitySet (SEQUENCE-OF)  */
+/* <======================================================> */
+void Delete_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x)
+{
+    OSCL_DEFAULT_FREE(x->item);
+}
+
+/* <===================================================> */
+/*  PER-Deleter for TerminalCapabilitySetAck (SEQUENCE)  */
+/* <===================================================> */
+void Delete_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Deleter for TerminalCapabilitySetReject (SEQUENCE)  */
+/* <======================================================> */
+void Delete_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x)
+{
+    Delete_TcsRejectCause(&x->tcsRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for TcsRejectCause (CHOICE)  */
+/* <=======================================> */
+void Delete_TcsRejectCause(PS_TcsRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (undefinedTableEntryUsed is NULL) */
+            break;
+        case 2:
+            /* (descriptorCapacityExceeded is NULL) */
+            break;
+        case 3:
+            Delete_TableEntryCapacityExceeded(x->tableEntryCapacityExceeded);
+            OSCL_DEFAULT_FREE(x->tableEntryCapacityExceeded);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_TcsRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Deleter for TableEntryCapacityExceeded (CHOICE)  */
+/* <===================================================> */
+void Delete_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            /* (noneProcessed is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_TableEntryCapacityExceeded: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for TerminalCapabilitySetRelease (SEQUENCE)  */
+/* <=======================================================> */
+void Delete_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Deleter for Capability (CHOICE)  */
+/* <===================================> */
+void Delete_Capability(PS_Capability x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_VideoCapability(x->receiveVideoCapability);
+            OSCL_DEFAULT_FREE(x->receiveVideoCapability);
+            break;
+        case 2:
+            Delete_VideoCapability(x->transmitVideoCapability);
+            OSCL_DEFAULT_FREE(x->transmitVideoCapability);
+            break;
+        case 3:
+            Delete_VideoCapability(x->receiveAndTransmitVideoCapability);
+            OSCL_DEFAULT_FREE(x->receiveAndTransmitVideoCapability);
+            break;
+        case 4:
+            Delete_AudioCapability(x->receiveAudioCapability);
+            OSCL_DEFAULT_FREE(x->receiveAudioCapability);
+            break;
+        case 5:
+            Delete_AudioCapability(x->transmitAudioCapability);
+            OSCL_DEFAULT_FREE(x->transmitAudioCapability);
+            break;
+        case 6:
+            Delete_AudioCapability(x->receiveAndTransmitAudioCapability);
+            OSCL_DEFAULT_FREE(x->receiveAndTransmitAudioCapability);
+            break;
+        case 7:
+            Delete_DataApplicationCapability(x->receiveDataApplicationCapability);
+            OSCL_DEFAULT_FREE(x->receiveDataApplicationCapability);
+            break;
+        case 8:
+            Delete_DataApplicationCapability(x->transmitDataApplicationCapability);
+            OSCL_DEFAULT_FREE(x->transmitDataApplicationCapability);
+            break;
+        case 9:
+            Delete_DataApplicationCapability(x->receiveAndTransmitDataApplicationCapability);
+            OSCL_DEFAULT_FREE(x->receiveAndTransmitDataApplicationCapability);
+            break;
+        case 10:
+            break;
+        case 11:
+            Delete_H233EncryptionReceiveCapability(x->h233EncryptionReceiveCapability);
+            OSCL_DEFAULT_FREE(x->h233EncryptionReceiveCapability);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 12:
+            Delete_ConferenceCapability(x->conferenceCapability);
+            OSCL_DEFAULT_FREE(x->conferenceCapability);
+            break;
+        case 13:
+            Delete_H235SecurityCapability(x->h235SecurityCapability);
+            OSCL_DEFAULT_FREE(x->h235SecurityCapability);
+            break;
+        case 14:
+            break;
+        case 15:
+            Delete_UserInputCapability(x->receiveUserInputCapability);
+            OSCL_DEFAULT_FREE(x->receiveUserInputCapability);
+            break;
+        case 16:
+            Delete_UserInputCapability(x->transmitUserInputCapability);
+            OSCL_DEFAULT_FREE(x->transmitUserInputCapability);
+            break;
+        case 17:
+            Delete_UserInputCapability(x->receiveAndTransmitUserInputCapability);
+            OSCL_DEFAULT_FREE(x->receiveAndTransmitUserInputCapability);
+            break;
+        case 18:
+            Delete_GenericCapability(x->genericControlCapability);
+            OSCL_DEFAULT_FREE(x->genericControlCapability);
+            break;
+        default:
+            ErrorMessage("Delete_Capability: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Deleter for H233EncryptionReceiveCapability (SEQUENCE)  */
+/* <==========================================================> */
+void Delete_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for H235SecurityCapability (SEQUENCE)  */
+/* <=================================================> */
+void Delete_H235SecurityCapability(PS_H235SecurityCapability x)
+{
+    Delete_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for MultiplexCapability (CHOICE)  */
+/* <============================================> */
+void Delete_MultiplexCapability(PS_MultiplexCapability x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_H222Capability(x->h222Capability);
+            OSCL_DEFAULT_FREE(x->h222Capability);
+            break;
+        case 2:
+            Delete_H223Capability(x->h223Capability);
+            OSCL_DEFAULT_FREE(x->h223Capability);
+            break;
+        case 3:
+            Delete_V76Capability(x->v76Capability);
+            OSCL_DEFAULT_FREE(x->v76Capability);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            Delete_H2250Capability(x->h2250Capability);
+            OSCL_DEFAULT_FREE(x->h2250Capability);
+            break;
+        case 5:
+            Delete_GenericCapability(x->genericMultiplexCapability);
+            OSCL_DEFAULT_FREE(x->genericMultiplexCapability);
+            break;
+        default:
+            ErrorMessage("Delete_MultiplexCapability: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for H222Capability (SEQUENCE)  */
+/* <=========================================> */
+void Delete_H222Capability(PS_H222Capability x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_vcCapability;++i)
+    {
+        Delete_VCCapability(x->vcCapability + i);
+    }
+    OSCL_DEFAULT_FREE(x->vcCapability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for VCCapability (SEQUENCE)  */
+/* <=======================================> */
+void Delete_VCCapability(PS_VCCapability x)
+{
+    uint32 extension;
+
+    extension = x->option_of_aal1ViaGateway;
+    if (x->option_of_vccAal1)
+    {
+        Delete_VccAal1(&x->vccAal1);
+    }
+    if (x->option_of_vccAal5)
+    {
+        Delete_VccAal5(&x->vccAal5);
+    }
+    Delete_AvailableBitRates(&x->availableBitRates);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_aal1ViaGateway)
+    {
+        Delete_Aal1ViaGateway(&x->aal1ViaGateway);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for Aal1ViaGateway (SEQUENCE)  */
+/* <=========================================> */
+void Delete_Aal1ViaGateway(PS_Aal1ViaGateway x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_gatewayAddress;++i)
+    {
+        Delete_Q2931Address(x->gatewayAddress + i);
+    }
+    OSCL_DEFAULT_FREE(x->gatewayAddress);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for AvailableBitRates (SEQUENCE)  */
+/* <============================================> */
+void Delete_AvailableBitRates(PS_AvailableBitRates x)
+{
+    Delete_VccAal5Type(&x->vccAal5Type);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Deleter for VccAal5Type (CHOICE)  */
+/* <====================================> */
+void Delete_VccAal5Type(PS_VccAal5Type x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            Delete_RangeOfBitRates(x->rangeOfBitRates);
+            OSCL_DEFAULT_FREE(x->rangeOfBitRates);
+            break;
+        default:
+            ErrorMessage("Delete_VccAal5Type: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for RangeOfBitRates (SEQUENCE)  */
+/* <==========================================> */
+void Delete_RangeOfBitRates(PS_RangeOfBitRates x)
+{
+    OSCL_UNUSED_ARG(x);
+}
+
+/* <==================================> */
+/*  PER-Deleter for VccAal5 (SEQUENCE)  */
+/* <==================================> */
+void Delete_VccAal5(PS_VccAal5 x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for VccAal1 (SEQUENCE)  */
+/* <==================================> */
+void Delete_VccAal1(PS_VccAal1 x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Deleter for H223Capability (SEQUENCE)  */
+/* <=========================================> */
+void Delete_H223Capability(PS_H223Capability x)
+{
+    uint32 extension;
+
+    extension = x->option_of_maxMUXPDUSizeCapability |
+                x->option_of_nsrpSupport |
+                x->option_of_mobileOperationTransmitCapability |
+                x->option_of_h223AnnexCCapability;
+    Delete_H223MultiplexTableCapability(&x->h223MultiplexTableCapability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_maxMUXPDUSizeCapability)
+    {
+    }
+    if (x->option_of_nsrpSupport)
+    {
+    }
+    if (x->option_of_mobileOperationTransmitCapability)
+    {
+        Delete_MobileOperationTransmitCapability(&x->mobileOperationTransmitCapability);
+    }
+    if (x->option_of_h223AnnexCCapability)
+    {
+        Delete_H223AnnexCCapability(&x->h223AnnexCCapability);
+    }
+}
+
+/* <============================================================> */
+/*  PER-Deleter for MobileOperationTransmitCapability (SEQUENCE)  */
+/* <============================================================> */
+void Delete_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================> */
+/*  PER-Deleter for H223MultiplexTableCapability (CHOICE)  */
+/* <=====================================================> */
+void Delete_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (basic is NULL) */
+            break;
+        case 1:
+            Delete_Enhanced(x->enhanced);
+            OSCL_DEFAULT_FREE(x->enhanced);
+            break;
+        default:
+            ErrorMessage("Delete_H223MultiplexTableCapability: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Deleter for Enhanced (SEQUENCE)  */
+/* <===================================> */
+void Delete_Enhanced(PS_Enhanced x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for H223AnnexCCapability (SEQUENCE)  */
+/* <===============================================> */
+void Delete_H223AnnexCCapability(PS_H223AnnexCCapability x)
+{
+    uint32 extension;
+
+    extension = x->option_of_rsCodeCapability;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_rsCodeCapability)
+    {
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for V76Capability (SEQUENCE)  */
+/* <========================================> */
+void Delete_V76Capability(PS_V76Capability x)
+{
+    Delete_V75Capability(&x->v75Capability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for V75Capability (SEQUENCE)  */
+/* <========================================> */
+void Delete_V75Capability(PS_V75Capability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Deleter for H2250Capability (SEQUENCE)  */
+/* <==========================================> */
+void Delete_H2250Capability(PS_H2250Capability x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_transportCapability |
+                x->option_of_redundancyEncodingCapability |
+                x->option_of_logicalChannelSwitchingCapability |
+                x->option_of_t120DynamicPortCapability;
+    Delete_MultipointCapability(&x->receiveMultipointCapability);
+    Delete_MultipointCapability(&x->transmitMultipointCapability);
+    Delete_MultipointCapability(&x->receiveAndTransmitMultipointCapability);
+    Delete_McCapability(&x->mcCapability);
+    Delete_MediaPacketizationCapability(&x->mediaPacketizationCapability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_transportCapability)
+    {
+        Delete_TransportCapability(&x->transportCapability);
+    }
+    if (x->option_of_redundancyEncodingCapability)
+    {
+        for (i = 0;i < x->size_of_redundancyEncodingCapability;++i)
+        {
+            Delete_RedundancyEncodingCapability(x->redundancyEncodingCapability + i);
+        }
+        OSCL_DEFAULT_FREE(x->redundancyEncodingCapability);
+    }
+    if (x->option_of_logicalChannelSwitchingCapability)
+    {
+    }
+    if (x->option_of_t120DynamicPortCapability)
+    {
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for McCapability (SEQUENCE)  */
+/* <=======================================> */
+void Delete_McCapability(PS_McCapability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for MediaPacketizationCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Delete_MediaPacketizationCapability(PS_MediaPacketizationCapability x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_rtpPayloadType;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_rtpPayloadType)
+    {
+        for (i = 0;i < x->size_of_rtpPayloadType;++i)
+        {
+            Delete_RTPPayloadType(x->rtpPayloadType + i);
+        }
+        OSCL_DEFAULT_FREE(x->rtpPayloadType);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for RSVPParameters (SEQUENCE)  */
+/* <=========================================> */
+void Delete_RSVPParameters(PS_RSVPParameters x)
+{
+    if (x->option_of_qosMode)
+    {
+        Delete_QOSMode(&x->qosMode);
+    }
+    if (x->option_of_tokenRate)
+    {
+    }
+    if (x->option_of_bucketSize)
+    {
+    }
+    if (x->option_of_peakRate)
+    {
+    }
+    if (x->option_of_minPoliced)
+    {
+    }
+    if (x->option_of_maxPktSize)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Deleter for QOSMode (CHOICE)  */
+/* <================================> */
+void Delete_QOSMode(PS_QOSMode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (guaranteedQOS is NULL) */
+            break;
+        case 1:
+            /* (controlledLoad is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_QOSMode: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for ATMParameters (SEQUENCE)  */
+/* <========================================> */
+void Delete_ATMParameters(PS_ATMParameters x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for QOSCapability (SEQUENCE)  */
+/* <========================================> */
+void Delete_QOSCapability(PS_QOSCapability x)
+{
+    if (x->option_of_nonStandardData)
+    {
+        Delete_NonStandardParameter(&x->nonStandardData);
+    }
+    if (x->option_of_rsvpParameters)
+    {
+        Delete_RSVPParameters(&x->rsvpParameters);
+    }
+    if (x->option_of_atmParameters)
+    {
+        Delete_ATMParameters(&x->atmParameters);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Deleter for MediaTransportType (CHOICE)  */
+/* <===========================================> */
+void Delete_MediaTransportType(PS_MediaTransportType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (ip_UDP is NULL) */
+            break;
+        case 1:
+            /* (ip_TCP is NULL) */
+            break;
+        case 2:
+            /* (atm_AAL5_UNIDIR is NULL) */
+            break;
+        case 3:
+            /* (atm_AAL5_BIDIR is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            Delete_Atm_AAL5_compressed(x->atm_AAL5_compressed);
+            OSCL_DEFAULT_FREE(x->atm_AAL5_compressed);
+            break;
+        default:
+            ErrorMessage("Delete_MediaTransportType: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Deleter for Atm_AAL5_compressed (SEQUENCE)  */
+/* <==============================================> */
+void Delete_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for MediaChannelCapability (SEQUENCE)  */
+/* <=================================================> */
+void Delete_MediaChannelCapability(PS_MediaChannelCapability x)
+{
+    if (x->option_of_mediaTransport)
+    {
+        Delete_MediaTransportType(&x->mediaTransport);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for TransportCapability (SEQUENCE)  */
+/* <==============================================> */
+void Delete_TransportCapability(PS_TransportCapability x)
+{
+    uint16 i = 0;
+    if (x->option_of_nonStandard)
+    {
+        Delete_NonStandardParameter(&x->nonStandard);
+    }
+    if (x->option_of_qOSCapabilities)
+    {
+        for (i = 0;i < x->size_of_qOSCapabilities;++i)
+        {
+            Delete_QOSCapability(x->qOSCapabilities + i);
+        }
+        OSCL_DEFAULT_FREE(x->qOSCapabilities);
+    }
+    if (x->option_of_mediaChannelCapabilities)
+    {
+        for (i = 0;i < x->size_of_mediaChannelCapabilities;++i)
+        {
+            Delete_MediaChannelCapability(x->mediaChannelCapabilities + i);
+        }
+        OSCL_DEFAULT_FREE(x->mediaChannelCapabilities);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for RedundancyEncodingCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Delete_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x)
+{
+    Delete_RedundancyEncodingMethod(&x->redundancyEncodingMethod);
+    if (x->option_of_secondaryEncoding)
+    {
+        OSCL_DEFAULT_FREE(x->secondaryEncoding);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for RedundancyEncodingMethod (CHOICE)  */
+/* <=================================================> */
+void Delete_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (rtpAudioRedundancyEncoding is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            Delete_RTPH263VideoRedundancyEncoding(x->rtpH263VideoRedundancyEncoding);
+            OSCL_DEFAULT_FREE(x->rtpH263VideoRedundancyEncoding);
+            break;
+        default:
+            ErrorMessage("Delete_RedundancyEncodingMethod: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================================> */
+/*  PER-Deleter for RTPH263VideoRedundancyEncoding (SEQUENCE)  */
+/* <=========================================================> */
+void Delete_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x)
+{
+    Delete_FrameToThreadMapping(&x->frameToThreadMapping);
+    if (x->option_of_containedThreads)
+    {
+        OSCL_DEFAULT_FREE(x->containedThreads);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for FrameToThreadMapping (CHOICE)  */
+/* <=============================================> */
+void Delete_FrameToThreadMapping(PS_FrameToThreadMapping x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            /* (roundrobin is NULL) */
+            break;
+        case 1:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_RTPH263VideoRedundancyFrameMapping(x->custom + i);
+            }
+            OSCL_DEFAULT_FREE(x->custom);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_FrameToThreadMapping: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================================> */
+/*  PER-Deleter for RTPH263VideoRedundancyFrameMapping (SEQUENCE)  */
+/* <=============================================================> */
+void Delete_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x)
+{
+    OSCL_DEFAULT_FREE(x->frameSequence);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for MultipointCapability (SEQUENCE)  */
+/* <===============================================> */
+void Delete_MultipointCapability(PS_MultipointCapability x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_mediaDistributionCapability;++i)
+    {
+        Delete_MediaDistributionCapability(x->mediaDistributionCapability + i);
+    }
+    OSCL_DEFAULT_FREE(x->mediaDistributionCapability);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Deleter for MediaDistributionCapability (SEQUENCE)  */
+/* <======================================================> */
+void Delete_MediaDistributionCapability(PS_MediaDistributionCapability x)
+{
+    uint16 i = 0;
+    if (x->option_of_centralizedData)
+    {
+        for (i = 0;i < x->size_of_centralizedData;++i)
+        {
+            Delete_DataApplicationCapability(x->centralizedData + i);
+        }
+        OSCL_DEFAULT_FREE(x->centralizedData);
+    }
+    if (x->option_of_distributedData)
+    {
+        for (i = 0;i < x->size_of_distributedData;++i)
+        {
+            Delete_DataApplicationCapability(x->distributedData + i);
+        }
+        OSCL_DEFAULT_FREE(x->distributedData);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for VideoCapability (CHOICE)  */
+/* <========================================> */
+void Delete_VideoCapability(PS_VideoCapability x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_H261VideoCapability(x->h261VideoCapability);
+            OSCL_DEFAULT_FREE(x->h261VideoCapability);
+            break;
+        case 2:
+            Delete_H262VideoCapability(x->h262VideoCapability);
+            OSCL_DEFAULT_FREE(x->h262VideoCapability);
+            break;
+        case 3:
+            Delete_H263VideoCapability(x->h263VideoCapability);
+            OSCL_DEFAULT_FREE(x->h263VideoCapability);
+            break;
+        case 4:
+            Delete_IS11172VideoCapability(x->is11172VideoCapability);
+            OSCL_DEFAULT_FREE(x->is11172VideoCapability);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            Delete_GenericCapability(x->genericVideoCapability);
+            OSCL_DEFAULT_FREE(x->genericVideoCapability);
+            break;
+        default:
+            ErrorMessage("Delete_VideoCapability: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Deleter for H261VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Delete_H261VideoCapability(PS_H261VideoCapability x)
+{
+    if (x->option_of_qcifMPI)
+    {
+    }
+    if (x->option_of_cifMPI)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for H262VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Delete_H262VideoCapability(PS_H262VideoCapability x)
+{
+    if (x->option_of_videoBitRate)
+    {
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+    }
+    if (x->option_of_samplesPerLine)
+    {
+    }
+    if (x->option_of_linesPerFrame)
+    {
+    }
+    if (x->option_of_framesPerSecond)
+    {
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for H263VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Delete_H263VideoCapability(PS_H263VideoCapability x)
+{
+    uint32 extension;
+
+    extension = x->option_of_slowSqcifMPI |
+                x->option_of_slowQcifMPI |
+                x->option_of_slowCifMPI |
+                x->option_of_slowCif4MPI |
+                x->option_of_slowCif16MPI |
+                x->option_of_errorCompensation |
+                x->option_of_enhancementLayerInfo |
+                x->option_of_h263Options;
+    if (x->option_of_sqcifMPI)
+    {
+    }
+    if (x->option_of_qcifMPI)
+    {
+    }
+    if (x->option_of_cifMPI)
+    {
+    }
+    if (x->option_of_cif4MPI)
+    {
+    }
+    if (x->option_of_cif16MPI)
+    {
+    }
+    if (x->option_of_hrd_B)
+    {
+    }
+    if (x->option_of_bppMaxKb)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_slowSqcifMPI)
+    {
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+    }
+    if (x->option_of_slowCifMPI)
+    {
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+    }
+    if (x->option_of_errorCompensation)
+    {
+    }
+    if (x->option_of_enhancementLayerInfo)
+    {
+        Delete_EnhancementLayerInfo(&x->enhancementLayerInfo);
+    }
+    if (x->option_of_h263Options)
+    {
+        Delete_H263Options(&x->h263Options);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for EnhancementLayerInfo (SEQUENCE)  */
+/* <===============================================> */
+void Delete_EnhancementLayerInfo(PS_EnhancementLayerInfo x)
+{
+    uint16 i = 0;
+    if (x->option_of_snrEnhancement)
+    {
+        for (i = 0;i < x->size_of_snrEnhancement;++i)
+        {
+            Delete_EnhancementOptions(x->snrEnhancement + i);
+        }
+        OSCL_DEFAULT_FREE(x->snrEnhancement);
+    }
+    if (x->option_of_spatialEnhancement)
+    {
+        for (i = 0;i < x->size_of_spatialEnhancement;++i)
+        {
+            Delete_EnhancementOptions(x->spatialEnhancement + i);
+        }
+        OSCL_DEFAULT_FREE(x->spatialEnhancement);
+    }
+    if (x->option_of_bPictureEnhancement)
+    {
+        for (i = 0;i < x->size_of_bPictureEnhancement;++i)
+        {
+            Delete_BEnhancementParameters(x->bPictureEnhancement + i);
+        }
+        OSCL_DEFAULT_FREE(x->bPictureEnhancement);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for BEnhancementParameters (SEQUENCE)  */
+/* <=================================================> */
+void Delete_BEnhancementParameters(PS_BEnhancementParameters x)
+{
+    Delete_EnhancementOptions(&x->enhancementOptions);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for EnhancementOptions (SEQUENCE)  */
+/* <=============================================> */
+void Delete_EnhancementOptions(PS_EnhancementOptions x)
+{
+    if (x->option_of_sqcifMPI)
+    {
+    }
+    if (x->option_of_qcifMPI)
+    {
+    }
+    if (x->option_of_cifMPI)
+    {
+    }
+    if (x->option_of_cif4MPI)
+    {
+    }
+    if (x->option_of_cif16MPI)
+    {
+    }
+    if (x->option_of_slowSqcifMPI)
+    {
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+    }
+    if (x->option_of_slowCifMPI)
+    {
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+    }
+    if (x->option_of_h263Options)
+    {
+        Delete_H263Options(&x->h263Options);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for H263Options (SEQUENCE)  */
+/* <======================================> */
+void Delete_H263Options(PS_H263Options x)
+{
+    uint16 i = 0;
+    if (x->option_of_transparencyParameters)
+    {
+        Delete_TransparencyParameters(&x->transparencyParameters);
+    }
+    if (x->option_of_refPictureSelection)
+    {
+        Delete_RefPictureSelection(&x->refPictureSelection);
+    }
+    if (x->option_of_customPictureClockFrequency)
+    {
+        for (i = 0;i < x->size_of_customPictureClockFrequency;++i)
+        {
+            Delete_CustomPictureClockFrequency(x->customPictureClockFrequency + i);
+        }
+        OSCL_DEFAULT_FREE(x->customPictureClockFrequency);
+    }
+    if (x->option_of_customPictureFormat)
+    {
+        for (i = 0;i < x->size_of_customPictureFormat;++i)
+        {
+            Delete_CustomPictureFormat(x->customPictureFormat + i);
+        }
+        OSCL_DEFAULT_FREE(x->customPictureFormat);
+    }
+    if (x->option_of_modeCombos)
+    {
+        for (i = 0;i < x->size_of_modeCombos;++i)
+        {
+            Delete_H263VideoModeCombos(x->modeCombos + i);
+        }
+        OSCL_DEFAULT_FREE(x->modeCombos);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for TransparencyParameters (SEQUENCE)  */
+/* <=================================================> */
+void Delete_TransparencyParameters(PS_TransparencyParameters x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for RefPictureSelection (SEQUENCE)  */
+/* <==============================================> */
+void Delete_RefPictureSelection(PS_RefPictureSelection x)
+{
+    if (x->option_of_additionalPictureMemory)
+    {
+        Delete_AdditionalPictureMemory(&x->additionalPictureMemory);
+    }
+    Delete_VideoBackChannelSend(&x->videoBackChannelSend);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for VideoBackChannelSend (CHOICE)  */
+/* <=============================================> */
+void Delete_VideoBackChannelSend(PS_VideoBackChannelSend x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (none is NULL) */
+            break;
+        case 1:
+            /* (ackMessageOnly is NULL) */
+            break;
+        case 2:
+            /* (nackMessageOnly is NULL) */
+            break;
+        case 3:
+            /* (ackOrNackMessageOnly is NULL) */
+            break;
+        case 4:
+            /* (ackAndNackMessage is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_VideoBackChannelSend: Illegal CHOICE index");
+    }
+}
+
+/* <==================================================> */
+/*  PER-Deleter for AdditionalPictureMemory (SEQUENCE)  */
+/* <==================================================> */
+void Delete_AdditionalPictureMemory(PS_AdditionalPictureMemory x)
+{
+    if (x->option_of_sqcifAdditionalPictureMemory)
+    {
+    }
+    if (x->option_of_qcifAdditionalPictureMemory)
+    {
+    }
+    if (x->option_of_cifAdditionalPictureMemory)
+    {
+    }
+    if (x->option_of_cif4AdditionalPictureMemory)
+    {
+    }
+    if (x->option_of_cif16AdditionalPictureMemory)
+    {
+    }
+    if (x->option_of_bigCpfAdditionalPictureMemory)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Deleter for CustomPictureClockFrequency (SEQUENCE)  */
+/* <======================================================> */
+void Delete_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x)
+{
+    if (x->option_of_sqcifMPI)
+    {
+    }
+    if (x->option_of_qcifMPI)
+    {
+    }
+    if (x->option_of_cifMPI)
+    {
+    }
+    if (x->option_of_cif4MPI)
+    {
+    }
+    if (x->option_of_cif16MPI)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for CustomPictureFormat (SEQUENCE)  */
+/* <==============================================> */
+void Delete_CustomPictureFormat(PS_CustomPictureFormat x)
+{
+    Delete_MPI(&x->mPI);
+    Delete_PixelAspectInformation(&x->pixelAspectInformation);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for PixelAspectInformation (CHOICE)  */
+/* <===============================================> */
+void Delete_PixelAspectInformation(PS_PixelAspectInformation x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            OSCL_DEFAULT_FREE(x->pixelAspectCode);
+            break;
+        case 2:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_ExtendedPARItem(x->extendedPAR + i);
+            }
+            OSCL_DEFAULT_FREE(x->extendedPAR);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_PixelAspectInformation: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for ExtendedPARItem (SEQUENCE)  */
+/* <==========================================> */
+void Delete_ExtendedPARItem(PS_ExtendedPARItem x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================> */
+/*  PER-Deleter for MPI (SEQUENCE)  */
+/* <==============================> */
+void Delete_MPI(PS_MPI x)
+{
+    uint16 i = 0;
+    if (x->option_of_standardMPI)
+    {
+    }
+    if (x->option_of_customPCF)
+    {
+        for (i = 0;i < x->size_of_customPCF;++i)
+        {
+            Delete_CustomPCFItem(x->customPCF + i);
+        }
+        OSCL_DEFAULT_FREE(x->customPCF);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for CustomPCFItem (SEQUENCE)  */
+/* <========================================> */
+void Delete_CustomPCFItem(PS_CustomPCFItem x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for H263VideoModeCombos (SEQUENCE)  */
+/* <==============================================> */
+void Delete_H263VideoModeCombos(PS_H263VideoModeCombos x)
+{
+    uint16 i = 0;
+    Delete_H263ModeComboFlags(&x->h263VideoUncoupledModes);
+    for (i = 0;i < x->size_of_h263VideoCoupledModes;++i)
+    {
+        Delete_H263ModeComboFlags(x->h263VideoCoupledModes + i);
+    }
+    OSCL_DEFAULT_FREE(x->h263VideoCoupledModes);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H263ModeComboFlags (SEQUENCE)  */
+/* <=============================================> */
+void Delete_H263ModeComboFlags(PS_H263ModeComboFlags x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for IS11172VideoCapability (SEQUENCE)  */
+/* <=================================================> */
+void Delete_IS11172VideoCapability(PS_IS11172VideoCapability x)
+{
+    if (x->option_of_videoBitRate)
+    {
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+    }
+    if (x->option_of_samplesPerLine)
+    {
+    }
+    if (x->option_of_linesPerFrame)
+    {
+    }
+    if (x->option_of_pictureRate)
+    {
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for AudioCapability (CHOICE)  */
+/* <========================================> */
+void Delete_AudioCapability(PS_AudioCapability x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            break;
+        case 2:
+            break;
+        case 3:
+            break;
+        case 4:
+            break;
+        case 5:
+            break;
+        case 6:
+            break;
+        case 7:
+            break;
+        case 8:
+            Delete_G7231(x->g7231);
+            OSCL_DEFAULT_FREE(x->g7231);
+            break;
+        case 9:
+            break;
+        case 10:
+            break;
+        case 11:
+            break;
+        case 12:
+            Delete_IS11172AudioCapability(x->is11172AudioCapability);
+            OSCL_DEFAULT_FREE(x->is11172AudioCapability);
+            break;
+        case 13:
+            Delete_IS13818AudioCapability(x->is13818AudioCapability);
+            OSCL_DEFAULT_FREE(x->is13818AudioCapability);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            break;
+        case 15:
+            break;
+        case 16:
+            Delete_G7231AnnexCCapability(x->g7231AnnexCCapability);
+            OSCL_DEFAULT_FREE(x->g7231AnnexCCapability);
+            break;
+        case 17:
+            Delete_GSMAudioCapability(x->gsmFullRate);
+            OSCL_DEFAULT_FREE(x->gsmFullRate);
+            break;
+        case 18:
+            Delete_GSMAudioCapability(x->gsmHalfRate);
+            OSCL_DEFAULT_FREE(x->gsmHalfRate);
+            break;
+        case 19:
+            Delete_GSMAudioCapability(x->gsmEnhancedFullRate);
+            OSCL_DEFAULT_FREE(x->gsmEnhancedFullRate);
+            break;
+        case 20:
+            Delete_GenericCapability(x->genericAudioCapability);
+            OSCL_DEFAULT_FREE(x->genericAudioCapability);
+            break;
+        case 21:
+            Delete_G729Extensions(x->g729Extensions);
+            OSCL_DEFAULT_FREE(x->g729Extensions);
+            break;
+        default:
+            ErrorMessage("Delete_AudioCapability: Illegal CHOICE index");
+    }
+}
+
+/* <================================> */
+/*  PER-Deleter for G7231 (SEQUENCE)  */
+/* <================================> */
+void Delete_G7231(PS_G7231 x)
+{
+    OSCL_UNUSED_ARG(x);
+}
+
+/* <=========================================> */
+/*  PER-Deleter for G729Extensions (SEQUENCE)  */
+/* <=========================================> */
+void Delete_G729Extensions(PS_G729Extensions x)
+{
+    if (x->option_of_audioUnit)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for G7231AnnexCCapability (SEQUENCE)  */
+/* <================================================> */
+void Delete_G7231AnnexCCapability(PS_G7231AnnexCCapability x)
+{
+    if (x->option_of_g723AnnexCAudioMode)
+    {
+        Delete_G723AnnexCAudioMode(&x->g723AnnexCAudioMode);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for G723AnnexCAudioMode (SEQUENCE)  */
+/* <==============================================> */
+void Delete_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for IS11172AudioCapability (SEQUENCE)  */
+/* <=================================================> */
+void Delete_IS11172AudioCapability(PS_IS11172AudioCapability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for IS13818AudioCapability (SEQUENCE)  */
+/* <=================================================> */
+void Delete_IS13818AudioCapability(PS_IS13818AudioCapability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for GSMAudioCapability (SEQUENCE)  */
+/* <=============================================> */
+void Delete_GSMAudioCapability(PS_GSMAudioCapability x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================================> */
+/*  PER-Deleter for DataApplicationCapability (SEQUENCE)  */
+/* <====================================================> */
+void Delete_DataApplicationCapability(PS_DataApplicationCapability x)
+{
+    Delete_Application(&x->application);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Deleter for Application (CHOICE)  */
+/* <====================================> */
+void Delete_Application(PS_Application x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_DataProtocolCapability(x->t120);
+            OSCL_DEFAULT_FREE(x->t120);
+            break;
+        case 2:
+            Delete_DataProtocolCapability(x->dsm_cc);
+            OSCL_DEFAULT_FREE(x->dsm_cc);
+            break;
+        case 3:
+            Delete_DataProtocolCapability(x->userData);
+            OSCL_DEFAULT_FREE(x->userData);
+            break;
+        case 4:
+            Delete_T84(x->t84);
+            OSCL_DEFAULT_FREE(x->t84);
+            break;
+        case 5:
+            Delete_DataProtocolCapability(x->t434);
+            OSCL_DEFAULT_FREE(x->t434);
+            break;
+        case 6:
+            Delete_DataProtocolCapability(x->h224);
+            OSCL_DEFAULT_FREE(x->h224);
+            break;
+        case 7:
+            Delete_Nlpid(x->nlpid);
+            OSCL_DEFAULT_FREE(x->nlpid);
+            break;
+        case 8:
+            /* (dsvdControl is NULL) */
+            break;
+        case 9:
+            Delete_DataProtocolCapability(x->h222DataPartitioning);
+            OSCL_DEFAULT_FREE(x->h222DataPartitioning);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Delete_DataProtocolCapability(x->t30fax);
+            OSCL_DEFAULT_FREE(x->t30fax);
+            break;
+        case 11:
+            Delete_DataProtocolCapability(x->t140);
+            OSCL_DEFAULT_FREE(x->t140);
+            break;
+        case 12:
+            Delete_T38fax(x->t38fax);
+            OSCL_DEFAULT_FREE(x->t38fax);
+            break;
+        case 13:
+            Delete_GenericCapability(x->genericDataCapability);
+            OSCL_DEFAULT_FREE(x->genericDataCapability);
+            break;
+        default:
+            ErrorMessage("Delete_Application: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Deleter for T38fax (SEQUENCE)  */
+/* <=================================> */
+void Delete_T38fax(PS_T38fax x)
+{
+    Delete_DataProtocolCapability(&x->t38FaxProtocol);
+    Delete_T38FaxProfile(&x->t38FaxProfile);
+}
+
+/* <================================> */
+/*  PER-Deleter for Nlpid (SEQUENCE)  */
+/* <================================> */
+void Delete_Nlpid(PS_Nlpid x)
+{
+    Delete_DataProtocolCapability(&x->nlpidProtocol);
+}
+
+/* <==============================> */
+/*  PER-Deleter for T84 (SEQUENCE)  */
+/* <==============================> */
+void Delete_T84(PS_T84 x)
+{
+    Delete_DataProtocolCapability(&x->t84Protocol);
+    Delete_T84Profile(&x->t84Profile);
+}
+
+/* <===============================================> */
+/*  PER-Deleter for DataProtocolCapability (CHOICE)  */
+/* <===============================================> */
+void Delete_DataProtocolCapability(PS_DataProtocolCapability x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (v14buffered is NULL) */
+            break;
+        case 2:
+            /* (v42lapm is NULL) */
+            break;
+        case 3:
+            /* (hdlcFrameTunnelling is NULL) */
+            break;
+        case 4:
+            /* (h310SeparateVCStack is NULL) */
+            break;
+        case 5:
+            /* (h310SingleVCStack is NULL) */
+            break;
+        case 6:
+            /* (transparent is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            break;
+        case 8:
+            break;
+        case 9:
+            break;
+        case 10:
+            break;
+        case 11:
+            Delete_V76wCompression(x->v76wCompression);
+            OSCL_DEFAULT_FREE(x->v76wCompression);
+            break;
+        case 12:
+            break;
+        case 13:
+            break;
+        default:
+            ErrorMessage("Delete_DataProtocolCapability: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for V76wCompression (CHOICE)  */
+/* <========================================> */
+void Delete_V76wCompression(PS_V76wCompression x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_CompressionType(x->transmitCompression);
+            OSCL_DEFAULT_FREE(x->transmitCompression);
+            break;
+        case 1:
+            Delete_CompressionType(x->receiveCompression);
+            OSCL_DEFAULT_FREE(x->receiveCompression);
+            break;
+        case 2:
+            Delete_CompressionType(x->transmitAndReceiveCompression);
+            OSCL_DEFAULT_FREE(x->transmitAndReceiveCompression);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_V76wCompression: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for CompressionType (CHOICE)  */
+/* <========================================> */
+void Delete_CompressionType(PS_CompressionType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_V42bis(x->v42bis);
+            OSCL_DEFAULT_FREE(x->v42bis);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CompressionType: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Deleter for V42bis (SEQUENCE)  */
+/* <=================================> */
+void Delete_V42bis(PS_V42bis x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Deleter for T84Profile (CHOICE)  */
+/* <===================================> */
+void Delete_T84Profile(PS_T84Profile x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (t84Unrestricted is NULL) */
+            break;
+        case 1:
+            Delete_T84Restricted(x->t84Restricted);
+            OSCL_DEFAULT_FREE(x->t84Restricted);
+            break;
+        default:
+            ErrorMessage("Delete_T84Profile: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for T84Restricted (SEQUENCE)  */
+/* <========================================> */
+void Delete_T84Restricted(PS_T84Restricted x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for T38FaxProfile (SEQUENCE)  */
+/* <========================================> */
+void Delete_T38FaxProfile(PS_T38FaxProfile x)
+{
+    uint32 extension;
+
+    extension = x->option_of_version |
+                x->option_of_t38FaxRateManagement |
+                x->option_of_t38FaxUdpOptions;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_version)
+    {
+    }
+    if (x->option_of_t38FaxRateManagement)
+    {
+        Delete_T38FaxRateManagement(&x->t38FaxRateManagement);
+    }
+    if (x->option_of_t38FaxUdpOptions)
+    {
+        Delete_T38FaxUdpOptions(&x->t38FaxUdpOptions);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for T38FaxRateManagement (CHOICE)  */
+/* <=============================================> */
+void Delete_T38FaxRateManagement(PS_T38FaxRateManagement x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (localTCF is NULL) */
+            break;
+        case 1:
+            /* (transferredTCF is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_T38FaxRateManagement: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for T38FaxUdpOptions (SEQUENCE)  */
+/* <===========================================> */
+void Delete_T38FaxUdpOptions(PS_T38FaxUdpOptions x)
+{
+    if (x->option_of_t38FaxMaxBuffer)
+    {
+    }
+    if (x->option_of_t38FaxMaxDatagram)
+    {
+    }
+    Delete_T38FaxUdpEC(&x->t38FaxUdpEC);
+}
+
+/* <====================================> */
+/*  PER-Deleter for T38FaxUdpEC (CHOICE)  */
+/* <====================================> */
+void Delete_T38FaxUdpEC(PS_T38FaxUdpEC x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (t38UDPFEC is NULL) */
+            break;
+        case 1:
+            /* (t38UDPRedundancy is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_T38FaxUdpEC: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================================> */
+/*  PER-Deleter for EncryptionAuthenticationAndIntegrity (SEQUENCE)  */
+/* <===============================================================> */
+void Delete_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x)
+{
+    if (x->option_of_encryptionCapability)
+    {
+        Delete_EncryptionCapability(&x->encryptionCapability);
+    }
+    if (x->option_of_authenticationCapability)
+    {
+        Delete_AuthenticationCapability(&x->authenticationCapability);
+    }
+    if (x->option_of_integrityCapability)
+    {
+        Delete_IntegrityCapability(&x->integrityCapability);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for EncryptionCapability (SEQUENCE-OF)  */
+/* <==================================================> */
+void Delete_EncryptionCapability(PS_EncryptionCapability x)
+{
+    uint16 i;
+    for (i = 0;i < x->size;++i)
+    {
+        Delete_MediaEncryptionAlgorithm(x->item + i);
+    }
+    OSCL_DEFAULT_FREE(x->item);
+}
+
+/* <=================================================> */
+/*  PER-Deleter for MediaEncryptionAlgorithm (CHOICE)  */
+/* <=================================================> */
+void Delete_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            FreeObjectID(x->algorithm);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MediaEncryptionAlgorithm: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Deleter for AuthenticationCapability (SEQUENCE)  */
+/* <===================================================> */
+void Delete_AuthenticationCapability(PS_AuthenticationCapability x)
+{
+    if (x->option_of_nonStandard)
+    {
+        Delete_NonStandardParameter(&x->nonStandard);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for IntegrityCapability (SEQUENCE)  */
+/* <==============================================> */
+void Delete_IntegrityCapability(PS_IntegrityCapability x)
+{
+    if (x->option_of_nonStandard)
+    {
+        Delete_NonStandardParameter(&x->nonStandard);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for UserInputCapability (CHOICE)  */
+/* <============================================> */
+void Delete_UserInputCapability(PS_UserInputCapability x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_NonStandardParameter(x->nonStandard + i);
+            }
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (basicString is NULL) */
+            break;
+        case 2:
+            /* (iA5String is NULL) */
+            break;
+        case 3:
+            /* (generalString is NULL) */
+            break;
+        case 4:
+            /* (dtmf is NULL) */
+            break;
+        case 5:
+            /* (hookflash is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_UserInputCapability: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for ConferenceCapability (SEQUENCE)  */
+/* <===============================================> */
+void Delete_ConferenceCapability(PS_ConferenceCapability x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_VideoIndicateMixingCapability |
+                x->option_of_multipointVisualizationCapability;
+    if (x->option_of_nonStandardData)
+    {
+        for (i = 0;i < x->size_of_nonStandardData;++i)
+        {
+            Delete_NonStandardParameter(x->nonStandardData + i);
+        }
+        OSCL_DEFAULT_FREE(x->nonStandardData);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_VideoIndicateMixingCapability)
+    {
+    }
+    if (x->option_of_multipointVisualizationCapability)
+    {
+    }
+}
+
+/* <============================================> */
+/*  PER-Deleter for GenericCapability (SEQUENCE)  */
+/* <============================================> */
+void Delete_GenericCapability(PS_GenericCapability x)
+{
+    uint16 i = 0;
+    Delete_CapabilityIdentifier(&x->capabilityIdentifier);
+    if (x->option_of_maxBitRate)
+    {
+    }
+    if (x->option_of_collapsing)
+    {
+        for (i = 0;i < x->size_of_collapsing;++i)
+        {
+            Delete_GenericParameter(x->collapsing + i);
+        }
+        OSCL_DEFAULT_FREE(x->collapsing);
+    }
+    if (x->option_of_nonCollapsing)
+    {
+        for (i = 0;i < x->size_of_nonCollapsing;++i)
+        {
+            Delete_GenericParameter(x->nonCollapsing + i);
+        }
+        OSCL_DEFAULT_FREE(x->nonCollapsing);
+    }
+    if (x->option_of_nonCollapsingRaw)
+    {
+    }
+    if (x->option_of_transport)
+    {
+        Delete_DataProtocolCapability(&x->transport);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for CapabilityIdentifier (CHOICE)  */
+/* <=============================================> */
+void Delete_CapabilityIdentifier(PS_CapabilityIdentifier x)
+{
+    switch (x->index)
+    {
+        case 0:
+            FreeObjectID(x->standard);
+            break;
+        case 1:
+            Delete_NonStandardParameter(x->h221NonStandard);
+            OSCL_DEFAULT_FREE(x->h221NonStandard);
+            break;
+        case 2:
+            FreeOctetString(x->uuid);
+            break;
+        case 3:
+            FreeCharString(x->domainBased);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CapabilityIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for GenericParameter (SEQUENCE)  */
+/* <===========================================> */
+void Delete_GenericParameter(PS_GenericParameter x)
+{
+    uint16 i = 0;
+    Delete_ParameterIdentifier(&x->parameterIdentifier);
+    Delete_ParameterValue(&x->parameterValue);
+    if (x->option_of_supersedes)
+    {
+        for (i = 0;i < x->size_of_supersedes;++i)
+        {
+            Delete_ParameterIdentifier(x->supersedes + i);
+        }
+        OSCL_DEFAULT_FREE(x->supersedes);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for ParameterIdentifier (CHOICE)  */
+/* <============================================> */
+void Delete_ParameterIdentifier(PS_ParameterIdentifier x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            Delete_NonStandardParameter(x->h221NonStandard);
+            OSCL_DEFAULT_FREE(x->h221NonStandard);
+            break;
+        case 2:
+            FreeOctetString(x->uuid);
+            break;
+        case 3:
+            FreeCharString(x->domainBased);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_ParameterIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for ParameterValue (CHOICE)  */
+/* <=======================================> */
+void Delete_ParameterValue(PS_ParameterValue x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            /* (logical is NULL) */
+            break;
+        case 1:
+            break;
+        case 2:
+            break;
+        case 3:
+            break;
+        case 4:
+            break;
+        case 5:
+            break;
+        case 6:
+            FreeOctetString(x->octetString);
+            break;
+        case 7:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_GenericParameter(x->genericParameter + i);
+            }
+            OSCL_DEFAULT_FREE(x->genericParameter);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_ParameterValue: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for OpenLogicalChannel (SEQUENCE)  */
+/* <=============================================> */
+void Delete_OpenLogicalChannel(PS_OpenLogicalChannel x)
+{
+    uint32 extension;
+
+    extension = x->option_of_separateStack |
+                x->option_of_encryptionSync;
+    Delete_ForwardLogicalChannelParameters(&x->forwardLogicalChannelParameters);
+    if (x->option_of_reverseLogicalChannelParameters)
+    {
+        Delete_ReverseLogicalChannelParameters(&x->reverseLogicalChannelParameters);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_separateStack)
+    {
+        Delete_NetworkAccessParameters(&x->separateStack);
+    }
+    if (x->option_of_encryptionSync)
+    {
+        Delete_EncryptionSync(&x->encryptionSync);
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Deleter for ReverseLogicalChannelParameters (SEQUENCE)  */
+/* <==========================================================> */
+void Delete_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x)
+{
+    uint32 extension;
+
+    extension = x->option_of_reverseLogicalChannelDependency |
+                x->option_of_replacementFor;
+    Delete_DataType(&x->dataType);
+    if (x->option_of_rlcMultiplexParameters)
+    {
+        Delete_RlcMultiplexParameters(&x->rlcMultiplexParameters);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_reverseLogicalChannelDependency)
+    {
+    }
+    if (x->option_of_replacementFor)
+    {
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for RlcMultiplexParameters (CHOICE)  */
+/* <===============================================> */
+void Delete_RlcMultiplexParameters(PS_RlcMultiplexParameters x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_H223LogicalChannelParameters(x->h223LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h223LogicalChannelParameters);
+            break;
+        case 1:
+            Delete_V76LogicalChannelParameters(x->v76LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->v76LogicalChannelParameters);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            Delete_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h2250LogicalChannelParameters);
+            break;
+        default:
+            ErrorMessage("Delete_RlcMultiplexParameters: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Deleter for ForwardLogicalChannelParameters (SEQUENCE)  */
+/* <==========================================================> */
+void Delete_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x)
+{
+    uint32 extension;
+
+    extension = x->option_of_forwardLogicalChannelDependency |
+                x->option_of_replacementFor;
+    if (x->option_of_portNumber)
+    {
+    }
+    Delete_DataType(&x->dataType);
+    Delete_MultiplexParameters(&x->multiplexParameters);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_forwardLogicalChannelDependency)
+    {
+    }
+    if (x->option_of_replacementFor)
+    {
+    }
+}
+
+/* <============================================> */
+/*  PER-Deleter for MultiplexParameters (CHOICE)  */
+/* <============================================> */
+void Delete_MultiplexParameters(PS_MultiplexParameters x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_H222LogicalChannelParameters(x->h222LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h222LogicalChannelParameters);
+            break;
+        case 1:
+            Delete_H223LogicalChannelParameters(x->h223LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h223LogicalChannelParameters);
+            break;
+        case 2:
+            Delete_V76LogicalChannelParameters(x->v76LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->v76LogicalChannelParameters);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            Delete_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h2250LogicalChannelParameters);
+            break;
+        case 4:
+            break;
+        default:
+            ErrorMessage("Delete_MultiplexParameters: Illegal CHOICE index");
+    }
+}
+
+/* <==================================================> */
+/*  PER-Deleter for NetworkAccessParameters (SEQUENCE)  */
+/* <==================================================> */
+void Delete_NetworkAccessParameters(PS_NetworkAccessParameters x)
+{
+    uint32 extension;
+
+    extension = x->option_of_t120SetupProcedure;
+    if (x->option_of_distribution)
+    {
+        Delete_Distribution(&x->distribution);
+    }
+    Delete_NetworkAddress(&x->networkAddress);
+    if (x->option_of_externalReference)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_t120SetupProcedure)
+    {
+        Delete_T120SetupProcedure(&x->t120SetupProcedure);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for T120SetupProcedure (CHOICE)  */
+/* <===========================================> */
+void Delete_T120SetupProcedure(PS_T120SetupProcedure x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (originateCall is NULL) */
+            break;
+        case 1:
+            /* (waitForCall is NULL) */
+            break;
+        case 2:
+            /* (issueQuery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_T120SetupProcedure: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for NetworkAddress (CHOICE)  */
+/* <=======================================> */
+void Delete_NetworkAddress(PS_NetworkAddress x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_Q2931Address(x->q2931Address);
+            OSCL_DEFAULT_FREE(x->q2931Address);
+            break;
+        case 1:
+            FreeCharString(x->e164Address);
+            break;
+        case 2:
+            Delete_TransportAddress(x->localAreaAddress);
+            OSCL_DEFAULT_FREE(x->localAreaAddress);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_NetworkAddress: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for Distribution (CHOICE)  */
+/* <=====================================> */
+void Delete_Distribution(PS_Distribution x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unicast is NULL) */
+            break;
+        case 1:
+            /* (multicast is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Distribution: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for Q2931Address (SEQUENCE)  */
+/* <=======================================> */
+void Delete_Q2931Address(PS_Q2931Address x)
+{
+    Delete_Address(&x->address);
+    if (x->option_of_subaddress)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Deleter for Address (CHOICE)  */
+/* <================================> */
+void Delete_Address(PS_Address x)
+{
+    switch (x->index)
+    {
+        case 0:
+            FreeCharString(x->internationalNumber);
+            break;
+        case 1:
+            FreeOctetString(x->nsapAddress);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Address: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for V75Parameters (SEQUENCE)  */
+/* <========================================> */
+void Delete_V75Parameters(PS_V75Parameters x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Deleter for DataType (CHOICE)  */
+/* <=================================> */
+OSCL_EXPORT_REF void Delete_DataType(PS_DataType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            if (x->nonStandard)
+            {
+                Delete_NonStandardParameter(x->nonStandard);
+                OSCL_DEFAULT_FREE(x->nonStandard);
+            }
+            break;
+        case 1:
+            /* (nullData is NULL) */
+            break;
+        case 2:
+            Delete_VideoCapability(x->videoData);
+            OSCL_DEFAULT_FREE(x->videoData);
+            break;
+        case 3:
+            Delete_AudioCapability(x->audioData);
+            OSCL_DEFAULT_FREE(x->audioData);
+            break;
+        case 4:
+            Delete_DataApplicationCapability(x->data);
+            OSCL_DEFAULT_FREE(x->data);
+            break;
+        case 5:
+            Delete_EncryptionMode(x->encryptionData);
+            OSCL_DEFAULT_FREE(x->encryptionData);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            Delete_NonStandardParameter(x->h235Control);
+            OSCL_DEFAULT_FREE(x->h235Control);
+            break;
+        case 7:
+            Delete_H235Media(x->h235Media);
+            OSCL_DEFAULT_FREE(x->h235Media);
+            break;
+        default:
+            ErrorMessage("Delete_DataType: Illegal CHOICE index");
+    }
+}
+
+/* <====================================> */
+/*  PER-Deleter for H235Media (SEQUENCE)  */
+/* <====================================> */
+void Delete_H235Media(PS_H235Media x)
+{
+    Delete_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity);
+    Delete_MediaType(&x->mediaType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for MediaType (CHOICE)  */
+/* <==================================> */
+void Delete_MediaType(PS_MediaType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_VideoCapability(x->videoData);
+            OSCL_DEFAULT_FREE(x->videoData);
+            break;
+        case 2:
+            Delete_AudioCapability(x->audioData);
+            OSCL_DEFAULT_FREE(x->audioData);
+            break;
+        case 3:
+            Delete_DataApplicationCapability(x->data);
+            OSCL_DEFAULT_FREE(x->data);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MediaType: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for H222LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+void Delete_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x)
+{
+    if (x->option_of_pcr_pid)
+    {
+    }
+    if (x->option_of_programDescriptors)
+    {
+    }
+    if (x->option_of_streamDescriptors)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for H223LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+OSCL_EXPORT_REF void Delete_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x)
+{
+    Delete_AdaptationLayerType(&x->adaptationLayerType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for AdaptationLayerType (CHOICE)  */
+/* <============================================> */
+void Delete_AdaptationLayerType(PS_AdaptationLayerType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (al1Framed is NULL) */
+            break;
+        case 2:
+            /* (al1NotFramed is NULL) */
+            break;
+        case 3:
+            /* (al2WithoutSequenceNumbers is NULL) */
+            break;
+        case 4:
+            /* (al2WithSequenceNumbers is NULL) */
+            break;
+        case 5:
+            Delete_Al3(x->al3);
+            OSCL_DEFAULT_FREE(x->al3);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            Delete_H223AL1MParameters(x->al1M);
+            OSCL_DEFAULT_FREE(x->al1M);
+            break;
+        case 7:
+            Delete_H223AL2MParameters(x->al2M);
+            OSCL_DEFAULT_FREE(x->al2M);
+            break;
+        case 8:
+            Delete_H223AL3MParameters(x->al3M);
+            OSCL_DEFAULT_FREE(x->al3M);
+            break;
+        default:
+            ErrorMessage("Delete_AdaptationLayerType: Illegal CHOICE index");
+    }
+}
+
+/* <==============================> */
+/*  PER-Deleter for Al3 (SEQUENCE)  */
+/* <==============================> */
+void Delete_Al3(PS_Al3 x)
+{
+    OSCL_UNUSED_ARG(x);
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H223AL1MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Delete_H223AL1MParameters(PS_H223AL1MParameters x)
+{
+    uint32 extension;
+
+    extension = x->option_of_rsCodeCorrection;
+    Delete_TransferMode(&x->transferMode);
+    Delete_HeaderFEC(&x->headerFEC);
+    Delete_CrcLength(&x->crcLength);
+    Delete_ArqType(&x->arqType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_rsCodeCorrection)
+    {
+    }
+}
+
+/* <================================> */
+/*  PER-Deleter for ArqType (CHOICE)  */
+/* <================================> */
+void Delete_ArqType(PS_ArqType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noArq is NULL) */
+            break;
+        case 1:
+            Delete_H223AnnexCArqParameters(x->typeIArq);
+            OSCL_DEFAULT_FREE(x->typeIArq);
+            break;
+        case 2:
+            Delete_H223AnnexCArqParameters(x->typeIIArq);
+            OSCL_DEFAULT_FREE(x->typeIIArq);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_ArqType: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for CrcLength (CHOICE)  */
+/* <==================================> */
+void Delete_CrcLength(PS_CrcLength x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (crc4bit is NULL) */
+            break;
+        case 1:
+            /* (crc12bit is NULL) */
+            break;
+        case 2:
+            /* (crc20bit is NULL) */
+            break;
+        case 3:
+            /* (crc28bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            break;
+        case 5:
+            break;
+        case 6:
+            break;
+        case 7:
+            break;
+        default:
+            ErrorMessage("Delete_CrcLength: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for HeaderFEC (CHOICE)  */
+/* <==================================> */
+void Delete_HeaderFEC(PS_HeaderFEC x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_7 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_HeaderFEC: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for TransferMode (CHOICE)  */
+/* <=====================================> */
+void Delete_TransferMode(PS_TransferMode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (framed is NULL) */
+            break;
+        case 1:
+            /* (unframed is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_TransferMode: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H223AL2MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Delete_H223AL2MParameters(PS_H223AL2MParameters x)
+{
+    Delete_Al2HeaderFEC(&x->al2HeaderFEC);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Deleter for Al2HeaderFEC (CHOICE)  */
+/* <=====================================> */
+void Delete_Al2HeaderFEC(PS_Al2HeaderFEC x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_5 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Al2HeaderFEC: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H223AL3MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Delete_H223AL3MParameters(PS_H223AL3MParameters x)
+{
+    uint32 extension;
+
+    extension = x->option_of_rsCodeCorrection;
+    Delete_HeaderFormat(&x->headerFormat);
+    Delete_Al3CrcLength(&x->al3CrcLength);
+    Delete_Al3ArqType(&x->al3ArqType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_rsCodeCorrection)
+    {
+    }
+}
+
+/* <===================================> */
+/*  PER-Deleter for Al3ArqType (CHOICE)  */
+/* <===================================> */
+void Delete_Al3ArqType(PS_Al3ArqType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noArq is NULL) */
+            break;
+        case 1:
+            Delete_H223AnnexCArqParameters(x->typeIArq);
+            OSCL_DEFAULT_FREE(x->typeIArq);
+            break;
+        case 2:
+            Delete_H223AnnexCArqParameters(x->typeIIArq);
+            OSCL_DEFAULT_FREE(x->typeIIArq);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Al3ArqType: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for Al3CrcLength (CHOICE)  */
+/* <=====================================> */
+void Delete_Al3CrcLength(PS_Al3CrcLength x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (crc4bit is NULL) */
+            break;
+        case 1:
+            /* (crc12bit is NULL) */
+            break;
+        case 2:
+            /* (crc20bit is NULL) */
+            break;
+        case 3:
+            /* (crc28bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            break;
+        case 5:
+            break;
+        case 6:
+            break;
+        case 7:
+            break;
+        default:
+            ErrorMessage("Delete_Al3CrcLength: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for HeaderFormat (CHOICE)  */
+/* <=====================================> */
+void Delete_HeaderFormat(PS_HeaderFormat x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_7 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_HeaderFormat: Illegal CHOICE index");
+    }
+}
+
+/* <==================================================> */
+/*  PER-Deleter for H223AnnexCArqParameters (SEQUENCE)  */
+/* <==================================================> */
+void Delete_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x)
+{
+    Delete_NumberOfRetransmissions(&x->numberOfRetransmissions);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for NumberOfRetransmissions (CHOICE)  */
+/* <================================================> */
+void Delete_NumberOfRetransmissions(PS_NumberOfRetransmissions x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            /* (infinite is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_NumberOfRetransmissions: Illegal CHOICE index");
+    }
+}
+
+/* <======================================================> */
+/*  PER-Deleter for V76LogicalChannelParameters (SEQUENCE)  */
+/* <======================================================> */
+void Delete_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x)
+{
+    Delete_V76HDLCParameters(&x->hdlcParameters);
+    Delete_SuspendResume(&x->suspendResume);
+    Delete_Mode(&x->mode);
+    Delete_V75Parameters(&x->v75Parameters);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================> */
+/*  PER-Deleter for Mode (CHOICE)  */
+/* <=============================> */
+void Delete_Mode(PS_Mode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_ERM(x->eRM);
+            OSCL_DEFAULT_FREE(x->eRM);
+            break;
+        case 1:
+            /* (uNERM is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Mode: Illegal CHOICE index");
+    }
+}
+
+/* <==============================> */
+/*  PER-Deleter for ERM (SEQUENCE)  */
+/* <==============================> */
+void Delete_ERM(PS_ERM x)
+{
+    Delete_Recovery(&x->recovery);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Deleter for Recovery (CHOICE)  */
+/* <=================================> */
+void Delete_Recovery(PS_Recovery x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (rej is NULL) */
+            break;
+        case 1:
+            /* (sREJ is NULL) */
+            break;
+        case 2:
+            /* (mSREJ is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Recovery: Illegal CHOICE index");
+    }
+}
+
+/* <======================================> */
+/*  PER-Deleter for SuspendResume (CHOICE)  */
+/* <======================================> */
+void Delete_SuspendResume(PS_SuspendResume x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noSuspendResume is NULL) */
+            break;
+        case 1:
+            /* (suspendResumewAddress is NULL) */
+            break;
+        case 2:
+            /* (suspendResumewoAddress is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_SuspendResume: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Deleter for V76HDLCParameters (SEQUENCE)  */
+/* <============================================> */
+void Delete_V76HDLCParameters(PS_V76HDLCParameters x)
+{
+    Delete_CRCLength(&x->crcLength);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for CRCLength (CHOICE)  */
+/* <==================================> */
+void Delete_CRCLength(PS_CRCLength x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (crc8bit is NULL) */
+            break;
+        case 1:
+            /* (crc16bit is NULL) */
+            break;
+        case 2:
+            /* (crc32bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CRCLength: Illegal CHOICE index");
+    }
+}
+
+/* <========================================================> */
+/*  PER-Deleter for H2250LogicalChannelParameters (SEQUENCE)  */
+/* <========================================================> */
+void Delete_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_transportCapability |
+                x->option_of_redundancyEncoding |
+                x->option_of_source |
+                x->option_of_symmetricMediaAddress;
+    if (x->option_of_nonStandard)
+    {
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Delete_NonStandardParameter(x->nonStandard + i);
+        }
+        OSCL_DEFAULT_FREE(x->nonStandard);
+    }
+    if (x->option_of_associatedSessionID)
+    {
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Delete_TransportAddress(&x->mediaChannel);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Delete_TransportAddress(&x->mediaControlChannel);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+    }
+    if (x->option_of_silenceSuppression)
+    {
+    }
+    if (x->option_of_destination)
+    {
+        Delete_TerminalLabel(&x->destination);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+    }
+    if (x->option_of_mediaPacketization)
+    {
+        Delete_MediaPacketization(&x->mediaPacketization);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_transportCapability)
+    {
+        Delete_TransportCapability(&x->transportCapability);
+    }
+    if (x->option_of_redundancyEncoding)
+    {
+        Delete_RedundancyEncoding(&x->redundancyEncoding);
+    }
+    if (x->option_of_source)
+    {
+        Delete_TerminalLabel(&x->source);
+    }
+    if (x->option_of_symmetricMediaAddress)
+    {
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for MediaPacketization (CHOICE)  */
+/* <===========================================> */
+void Delete_MediaPacketization(PS_MediaPacketization x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (h261aVideoPacketization is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            Delete_RTPPayloadType(x->rtpPayloadType);
+            OSCL_DEFAULT_FREE(x->rtpPayloadType);
+            break;
+        default:
+            ErrorMessage("Delete_MediaPacketization: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for RTPPayloadType (SEQUENCE)  */
+/* <=========================================> */
+void Delete_RTPPayloadType(PS_RTPPayloadType x)
+{
+    Delete_PayloadDescriptor(&x->payloadDescriptor);
+    if (x->option_of_payloadType)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Deleter for PayloadDescriptor (CHOICE)  */
+/* <==========================================> */
+void Delete_PayloadDescriptor(PS_PayloadDescriptor x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandardIdentifier);
+            OSCL_DEFAULT_FREE(x->nonStandardIdentifier);
+            break;
+        case 1:
+            break;
+        case 2:
+            FreeObjectID(x->oid);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_PayloadDescriptor: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for RedundancyEncoding (SEQUENCE)  */
+/* <=============================================> */
+void Delete_RedundancyEncoding(PS_RedundancyEncoding x)
+{
+    Delete_RedundancyEncodingMethod(&x->redundancyEncodingMethod);
+    if (x->option_of_secondaryEncoding)
+    {
+        Delete_DataType(&x->secondaryEncoding);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Deleter for TransportAddress (CHOICE)  */
+/* <=========================================> */
+void Delete_TransportAddress(PS_TransportAddress x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_UnicastAddress(x->unicastAddress);
+            OSCL_DEFAULT_FREE(x->unicastAddress);
+            break;
+        case 1:
+            Delete_MulticastAddress(x->multicastAddress);
+            OSCL_DEFAULT_FREE(x->multicastAddress);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_TransportAddress: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for UnicastAddress (CHOICE)  */
+/* <=======================================> */
+void Delete_UnicastAddress(PS_UnicastAddress x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_IPAddress(x->iPAddress);
+            OSCL_DEFAULT_FREE(x->iPAddress);
+            break;
+        case 1:
+            Delete_IPXAddress(x->iPXAddress);
+            OSCL_DEFAULT_FREE(x->iPXAddress);
+            break;
+        case 2:
+            Delete_IP6Address(x->iP6Address);
+            OSCL_DEFAULT_FREE(x->iP6Address);
+            break;
+        case 3:
+            FreeOctetString(x->netBios);
+            break;
+        case 4:
+            Delete_IPSourceRouteAddress(x->iPSourceRouteAddress);
+            OSCL_DEFAULT_FREE(x->iPSourceRouteAddress);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            FreeOctetString(x->nsap);
+            break;
+        case 6:
+            Delete_NonStandardParameter(x->nonStandardAddress);
+            OSCL_DEFAULT_FREE(x->nonStandardAddress);
+            break;
+        default:
+            ErrorMessage("Delete_UnicastAddress: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for IPSourceRouteAddress (SEQUENCE)  */
+/* <===============================================> */
+void Delete_IPSourceRouteAddress(PS_IPSourceRouteAddress x)
+{
+    Delete_Routing(&x->routing);
+    OSCL_DEFAULT_FREE(x->route);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Deleter for Routing (CHOICE)  */
+/* <================================> */
+void Delete_Routing(PS_Routing x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (strict is NULL) */
+            break;
+        case 1:
+            /* (loose is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Routing: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for IP6Address (SEQUENCE)  */
+/* <=====================================> */
+void Delete_IP6Address(PS_IP6Address x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Deleter for IPXAddress (SEQUENCE)  */
+/* <=====================================> */
+void Delete_IPXAddress(PS_IPXAddress x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Deleter for IPAddress (SEQUENCE)  */
+/* <====================================> */
+void Delete_IPAddress(PS_IPAddress x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Deleter for MulticastAddress (CHOICE)  */
+/* <=========================================> */
+void Delete_MulticastAddress(PS_MulticastAddress x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_MaIpAddress(x->maIpAddress);
+            OSCL_DEFAULT_FREE(x->maIpAddress);
+            break;
+        case 1:
+            Delete_MaIp6Address(x->maIp6Address);
+            OSCL_DEFAULT_FREE(x->maIp6Address);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            FreeOctetString(x->nsap);
+            break;
+        case 3:
+            Delete_NonStandardParameter(x->nonStandardAddress);
+            OSCL_DEFAULT_FREE(x->nonStandardAddress);
+            break;
+        default:
+            ErrorMessage("Delete_MulticastAddress: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for MaIp6Address (SEQUENCE)  */
+/* <=======================================> */
+void Delete_MaIp6Address(PS_MaIp6Address x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for MaIpAddress (SEQUENCE)  */
+/* <======================================> */
+void Delete_MaIpAddress(PS_MaIpAddress x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Deleter for EncryptionSync (SEQUENCE)  */
+/* <=========================================> */
+void Delete_EncryptionSync(PS_EncryptionSync x)
+{
+    uint16 i = 0;
+    if (x->option_of_nonStandard)
+    {
+        Delete_NonStandardParameter(&x->nonStandard);
+    }
+    if (x->option_of_escrowentry)
+    {
+        for (i = 0;i < x->size_of_escrowentry;++i)
+        {
+            Delete_EscrowData(x->escrowentry + i);
+        }
+        OSCL_DEFAULT_FREE(x->escrowentry);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Deleter for EscrowData (SEQUENCE)  */
+/* <=====================================> */
+void Delete_EscrowData(PS_EscrowData x)
+{
+    OSCL_DEFAULT_FREE(x->escrowID.data);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for OpenLogicalChannelAck (SEQUENCE)  */
+/* <================================================> */
+void Delete_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x)
+{
+    uint32 extension;
+
+    extension = x->option_of_separateStack |
+                x->option_of_forwardMultiplexAckParameters |
+                x->option_of_encryptionSync;
+    if (x->option_of_ackReverseLogicalChannelParameters)
+    {
+        Delete_AckReverseLogicalChannelParameters(&x->ackReverseLogicalChannelParameters);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_separateStack)
+    {
+        Delete_NetworkAccessParameters(&x->separateStack);
+    }
+    if (x->option_of_forwardMultiplexAckParameters)
+    {
+        Delete_ForwardMultiplexAckParameters(&x->forwardMultiplexAckParameters);
+    }
+    if (x->option_of_encryptionSync)
+    {
+        Delete_EncryptionSync(&x->encryptionSync);
+    }
+}
+
+/* <======================================================> */
+/*  PER-Deleter for ForwardMultiplexAckParameters (CHOICE)  */
+/* <======================================================> */
+void Delete_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_H2250LogicalChannelAckParameters(x->h2250LogicalChannelAckParameters);
+            OSCL_DEFAULT_FREE(x->h2250LogicalChannelAckParameters);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_ForwardMultiplexAckParameters: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================================> */
+/*  PER-Deleter for AckReverseLogicalChannelParameters (SEQUENCE)  */
+/* <=============================================================> */
+void Delete_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x)
+{
+    uint32 extension;
+
+    extension = x->option_of_replacementFor;
+    if (x->option_of_portNumber)
+    {
+    }
+    if (x->option_of_ackMultiplexParameters)
+    {
+        Delete_AckMultiplexParameters(&x->ackMultiplexParameters);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_replacementFor)
+    {
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for AckMultiplexParameters (CHOICE)  */
+/* <===============================================> */
+void Delete_AckMultiplexParameters(PS_AckMultiplexParameters x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_H222LogicalChannelParameters(x->h222LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h222LogicalChannelParameters);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            Delete_H2250LogicalChannelParameters(x->h2250LogicalChannelParameters);
+            OSCL_DEFAULT_FREE(x->h2250LogicalChannelParameters);
+            break;
+        default:
+            ErrorMessage("Delete_AckMultiplexParameters: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Deleter for OpenLogicalChannelReject (SEQUENCE)  */
+/* <===================================================> */
+void Delete_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x)
+{
+    Delete_OlcRejectCause(&x->olcRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for OlcRejectCause (CHOICE)  */
+/* <=======================================> */
+void Delete_OlcRejectCause(PS_OlcRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (unsuitableReverseParameters is NULL) */
+            break;
+        case 2:
+            /* (dataTypeNotSupported is NULL) */
+            break;
+        case 3:
+            /* (dataTypeNotAvailable is NULL) */
+            break;
+        case 4:
+            /* (unknownDataType is NULL) */
+            break;
+        case 5:
+            /* (dataTypeALCombinationNotSupported is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            break;
+        case 7:
+            break;
+        case 8:
+            break;
+        case 9:
+            break;
+        case 10:
+            break;
+        case 11:
+            break;
+        case 12:
+            break;
+        case 13:
+            break;
+        default:
+            ErrorMessage("Delete_OlcRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Deleter for OpenLogicalChannelConfirm (SEQUENCE)  */
+/* <====================================================> */
+void Delete_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================================> */
+/*  PER-Deleter for H2250LogicalChannelAckParameters (SEQUENCE)  */
+/* <===========================================================> */
+void Delete_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_flowControlToZero |
+                x->option_of_portNumber;
+    if (x->option_of_nonStandard)
+    {
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Delete_NonStandardParameter(x->nonStandard + i);
+        }
+        OSCL_DEFAULT_FREE(x->nonStandard);
+    }
+    if (x->option_of_sessionID)
+    {
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Delete_TransportAddress(&x->mediaChannel);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Delete_TransportAddress(&x->mediaControlChannel);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_flowControlToZero)
+    {
+    }
+    if (x->option_of_portNumber)
+    {
+    }
+}
+
+/* <==============================================> */
+/*  PER-Deleter for CloseLogicalChannel (SEQUENCE)  */
+/* <==============================================> */
+void Delete_CloseLogicalChannel(PS_CloseLogicalChannel x)
+{
+    uint32 extension;
+
+    extension = x->option_of_reason;
+    Delete_Source(&x->source);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_reason)
+    {
+        Delete_Reason(&x->reason);
+    }
+}
+
+/* <===============================> */
+/*  PER-Deleter for Reason (CHOICE)  */
+/* <===============================> */
+void Delete_Reason(PS_Reason x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unknown is NULL) */
+            break;
+        case 1:
+            /* (reopen is NULL) */
+            break;
+        case 2:
+            /* (reservationFailure is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Reason: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Deleter for Source (CHOICE)  */
+/* <===============================> */
+void Delete_Source(PS_Source x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (user is NULL) */
+            break;
+        case 1:
+            /* (lcse is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Source: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================> */
+/*  PER-Deleter for CloseLogicalChannelAck (SEQUENCE)  */
+/* <=================================================> */
+void Delete_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for RequestChannelClose (SEQUENCE)  */
+/* <==============================================> */
+void Delete_RequestChannelClose(PS_RequestChannelClose x)
+{
+    uint32 extension;
+
+    extension = x->option_of_qosCapability |
+                x->option_of_rccReason;
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_qosCapability)
+    {
+        Delete_QOSCapability(&x->qosCapability);
+    }
+    if (x->option_of_rccReason)
+    {
+        Delete_RccReason(&x->rccReason);
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for RccReason (CHOICE)  */
+/* <==================================> */
+void Delete_RccReason(PS_RccReason x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unknown is NULL) */
+            break;
+        case 1:
+            /* (normal is NULL) */
+            break;
+        case 2:
+            /* (reopen is NULL) */
+            break;
+        case 3:
+            /* (reservationFailure is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RccReason: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================> */
+/*  PER-Deleter for RequestChannelCloseAck (SEQUENCE)  */
+/* <=================================================> */
+void Delete_RequestChannelCloseAck(PS_RequestChannelCloseAck x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================================> */
+/*  PER-Deleter for RequestChannelCloseReject (SEQUENCE)  */
+/* <====================================================> */
+void Delete_RequestChannelCloseReject(PS_RequestChannelCloseReject x)
+{
+    Delete_RccRejectCause(&x->rccRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for RccRejectCause (CHOICE)  */
+/* <=======================================> */
+void Delete_RccRejectCause(PS_RccRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RccRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Deleter for RequestChannelCloseRelease (SEQUENCE)  */
+/* <=====================================================> */
+void Delete_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for MultiplexEntrySend (SEQUENCE)  */
+/* <=============================================> */
+void Delete_MultiplexEntrySend(PS_MultiplexEntrySend x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_multiplexEntryDescriptors;++i)
+    {
+        Delete_MultiplexEntryDescriptor(x->multiplexEntryDescriptors + i);
+    }
+    OSCL_DEFAULT_FREE(x->multiplexEntryDescriptors);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for MultiplexEntryDescriptor (SEQUENCE)  */
+/* <===================================================> */
+OSCL_EXPORT_REF void Delete_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x)
+{
+    uint16 i = 0;
+    if (x->option_of_elementList)
+    {
+        for (i = 0;i < x->size_of_elementList;++i)
+        {
+            Delete_MultiplexElement(x->elementList + i);
+        }
+        OSCL_DEFAULT_FREE(x->elementList);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for MultiplexElement (SEQUENCE)  */
+/* <===========================================> */
+void Delete_MultiplexElement(PS_MultiplexElement x)
+{
+    Delete_MuxType(&x->muxType);
+    Delete_RepeatCount(&x->repeatCount);
+}
+
+/* <====================================> */
+/*  PER-Deleter for RepeatCount (CHOICE)  */
+/* <====================================> */
+void Delete_RepeatCount(PS_RepeatCount x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            /* (untilClosingFlag is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_RepeatCount: Illegal CHOICE index");
+    }
+}
+
+/* <================================> */
+/*  PER-Deleter for MuxType (CHOICE)  */
+/* <================================> */
+void Delete_MuxType(PS_MuxType x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_MultiplexElement(x->subElementList + i);
+            }
+            OSCL_DEFAULT_FREE(x->subElementList);
+            break;
+        default:
+            ErrorMessage("Delete_MuxType: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Deleter for MultiplexEntrySendAck (SEQUENCE)  */
+/* <================================================> */
+void Delete_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x)
+{
+    OSCL_DEFAULT_FREE(x->multiplexTableEntryNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for MultiplexEntrySendReject (SEQUENCE)  */
+/* <===================================================> */
+void Delete_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        Delete_MultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i);
+    }
+    OSCL_DEFAULT_FREE(x->rejectionDescriptions);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================================> */
+/*  PER-Deleter for MultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <==============================================================> */
+void Delete_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x)
+{
+    Delete_MeRejectCause(&x->meRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for MeRejectCause (CHOICE)  */
+/* <======================================> */
+void Delete_MeRejectCause(PS_MeRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecifiedCause is NULL) */
+            break;
+        case 1:
+            /* (descriptorTooComplex is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MeRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Deleter for MultiplexEntrySendRelease (SEQUENCE)  */
+/* <====================================================> */
+void Delete_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x)
+{
+    OSCL_DEFAULT_FREE(x->multiplexTableEntryNumber);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for RequestMultiplexEntry (SEQUENCE)  */
+/* <================================================> */
+void Delete_RequestMultiplexEntry(PS_RequestMultiplexEntry x)
+{
+    OSCL_DEFAULT_FREE(x->entryNumbers);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for RequestMultiplexEntryAck (SEQUENCE)  */
+/* <===================================================> */
+void Delete_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x)
+{
+    OSCL_DEFAULT_FREE(x->entryNumbers);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Deleter for RequestMultiplexEntryReject (SEQUENCE)  */
+/* <======================================================> */
+void Delete_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x)
+{
+    uint16 i = 0;
+    OSCL_DEFAULT_FREE(x->entryNumbers);
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        Delete_RequestMultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i);
+    }
+    OSCL_DEFAULT_FREE(x->rejectionDescriptions);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================================> */
+/*  PER-Deleter for RequestMultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <=====================================================================> */
+void Delete_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x)
+{
+    Delete_RmeRejectCause(&x->rmeRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for RmeRejectCause (CHOICE)  */
+/* <=======================================> */
+void Delete_RmeRejectCause(PS_RmeRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecifiedCause is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RmeRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for RequestMultiplexEntryRelease (SEQUENCE)  */
+/* <=======================================================> */
+void Delete_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x)
+{
+    OSCL_DEFAULT_FREE(x->entryNumbers);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for RequestMode (SEQUENCE)  */
+/* <======================================> */
+void Delete_RequestMode(PS_RequestMode x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_requestedModes;++i)
+    {
+        Delete_ModeDescription(x->requestedModes + i);
+    }
+    OSCL_DEFAULT_FREE(x->requestedModes);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Deleter for RequestModeAck (SEQUENCE)  */
+/* <=========================================> */
+void Delete_RequestModeAck(PS_RequestModeAck x)
+{
+    Delete_Response(&x->response);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Deleter for Response (CHOICE)  */
+/* <=================================> */
+void Delete_Response(PS_Response x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (willTransmitMostPreferredMode is NULL) */
+            break;
+        case 1:
+            /* (willTransmitLessPreferredMode is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Response: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Deleter for RequestModeReject (SEQUENCE)  */
+/* <============================================> */
+void Delete_RequestModeReject(PS_RequestModeReject x)
+{
+    Delete_RmRejectCause(&x->rmRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for RmRejectCause (CHOICE)  */
+/* <======================================> */
+void Delete_RmRejectCause(PS_RmRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (modeUnavailable is NULL) */
+            break;
+        case 1:
+            /* (multipointConstraint is NULL) */
+            break;
+        case 2:
+            /* (requestDenied is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RmRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for RequestModeRelease (SEQUENCE)  */
+/* <=============================================> */
+void Delete_RequestModeRelease(PS_RequestModeRelease x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for ModeDescription (SET-OF)  */
+/* <========================================> */
+void Delete_ModeDescription(PS_ModeDescription x)
+{
+    uint16 i;
+    for (i = 0;i < x->size;++i)
+    {
+        Delete_ModeElement(x->item + i);
+    }
+    OSCL_DEFAULT_FREE(x->item);
+}
+
+/* <======================================> */
+/*  PER-Deleter for ModeElement (SEQUENCE)  */
+/* <======================================> */
+void Delete_ModeElement(PS_ModeElement x)
+{
+    uint32 extension;
+
+    extension = x->option_of_v76ModeParameters |
+                x->option_of_h2250ModeParameters |
+                x->option_of_genericModeParameters;
+    Delete_ModeType(&x->modeType);
+    if (x->option_of_h223ModeParameters)
+    {
+        Delete_H223ModeParameters(&x->h223ModeParameters);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_v76ModeParameters)
+    {
+        Delete_V76ModeParameters(&x->v76ModeParameters);
+    }
+    if (x->option_of_h2250ModeParameters)
+    {
+        Delete_H2250ModeParameters(&x->h2250ModeParameters);
+    }
+    if (x->option_of_genericModeParameters)
+    {
+        Delete_GenericCapability(&x->genericModeParameters);
+    }
+}
+
+/* <=================================> */
+/*  PER-Deleter for ModeType (CHOICE)  */
+/* <=================================> */
+void Delete_ModeType(PS_ModeType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_VideoMode(x->videoMode);
+            OSCL_DEFAULT_FREE(x->videoMode);
+            break;
+        case 2:
+            Delete_AudioMode(x->audioMode);
+            OSCL_DEFAULT_FREE(x->audioMode);
+            break;
+        case 3:
+            Delete_DataMode(x->dataMode);
+            OSCL_DEFAULT_FREE(x->dataMode);
+            break;
+        case 4:
+            Delete_EncryptionMode(x->encryptionMode);
+            OSCL_DEFAULT_FREE(x->encryptionMode);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            Delete_H235Mode(x->h235Mode);
+            OSCL_DEFAULT_FREE(x->h235Mode);
+            break;
+        default:
+            ErrorMessage("Delete_ModeType: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Deleter for H235Mode (SEQUENCE)  */
+/* <===================================> */
+void Delete_H235Mode(PS_H235Mode x)
+{
+    Delete_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity);
+    Delete_MediaMode(&x->mediaMode);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for MediaMode (CHOICE)  */
+/* <==================================> */
+void Delete_MediaMode(PS_MediaMode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_VideoMode(x->videoMode);
+            OSCL_DEFAULT_FREE(x->videoMode);
+            break;
+        case 2:
+            Delete_AudioMode(x->audioMode);
+            OSCL_DEFAULT_FREE(x->audioMode);
+            break;
+        case 3:
+            Delete_DataMode(x->dataMode);
+            OSCL_DEFAULT_FREE(x->dataMode);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MediaMode: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H223ModeParameters (SEQUENCE)  */
+/* <=============================================> */
+void Delete_H223ModeParameters(PS_H223ModeParameters x)
+{
+    Delete_ModeAdaptationLayerType(&x->modeAdaptationLayerType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for ModeAdaptationLayerType (CHOICE)  */
+/* <================================================> */
+void Delete_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (al1Framed is NULL) */
+            break;
+        case 2:
+            /* (al1NotFramed is NULL) */
+            break;
+        case 3:
+            /* (al2WithoutSequenceNumbers is NULL) */
+            break;
+        case 4:
+            /* (al2WithSequenceNumbers is NULL) */
+            break;
+        case 5:
+            Delete_ModeAl3(x->modeAl3);
+            OSCL_DEFAULT_FREE(x->modeAl3);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            Delete_H223AL1MParameters(x->al1M);
+            OSCL_DEFAULT_FREE(x->al1M);
+            break;
+        case 7:
+            Delete_H223AL2MParameters(x->al2M);
+            OSCL_DEFAULT_FREE(x->al2M);
+            break;
+        case 8:
+            Delete_H223AL3MParameters(x->al3M);
+            OSCL_DEFAULT_FREE(x->al3M);
+            break;
+        default:
+            ErrorMessage("Delete_ModeAdaptationLayerType: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for ModeAl3 (SEQUENCE)  */
+/* <==================================> */
+void Delete_ModeAl3(PS_ModeAl3 x)
+{
+    OSCL_UNUSED_ARG(x);
+}
+
+/* <==========================================> */
+/*  PER-Deleter for V76ModeParameters (CHOICE)  */
+/* <==========================================> */
+void Delete_V76ModeParameters(PS_V76ModeParameters x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (suspendResumewAddress is NULL) */
+            break;
+        case 1:
+            /* (suspendResumewoAddress is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_V76ModeParameters: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Deleter for H2250ModeParameters (SEQUENCE)  */
+/* <==============================================> */
+void Delete_H2250ModeParameters(PS_H2250ModeParameters x)
+{
+    if (x->option_of_redundancyEncodingMode)
+    {
+        Delete_RedundancyEncodingMode(&x->redundancyEncodingMode);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for RedundancyEncodingMode (SEQUENCE)  */
+/* <=================================================> */
+void Delete_RedundancyEncodingMode(PS_RedundancyEncodingMode x)
+{
+    Delete_RedundancyEncodingMethod(&x->redundancyEncodingMethod);
+    if (x->option_of_secondaryEncoding)
+    {
+        Delete_SecondaryEncoding(&x->secondaryEncoding);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Deleter for SecondaryEncoding (CHOICE)  */
+/* <==========================================> */
+void Delete_SecondaryEncoding(PS_SecondaryEncoding x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_AudioMode(x->audioData);
+            OSCL_DEFAULT_FREE(x->audioData);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_SecondaryEncoding: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for VideoMode (CHOICE)  */
+/* <==================================> */
+void Delete_VideoMode(PS_VideoMode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_H261VideoMode(x->h261VideoMode);
+            OSCL_DEFAULT_FREE(x->h261VideoMode);
+            break;
+        case 2:
+            Delete_H262VideoMode(x->h262VideoMode);
+            OSCL_DEFAULT_FREE(x->h262VideoMode);
+            break;
+        case 3:
+            Delete_H263VideoMode(x->h263VideoMode);
+            OSCL_DEFAULT_FREE(x->h263VideoMode);
+            break;
+        case 4:
+            Delete_IS11172VideoMode(x->is11172VideoMode);
+            OSCL_DEFAULT_FREE(x->is11172VideoMode);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            Delete_GenericCapability(x->genericVideoMode);
+            OSCL_DEFAULT_FREE(x->genericVideoMode);
+            break;
+        default:
+            ErrorMessage("Delete_VideoMode: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for H261VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Delete_H261VideoMode(PS_H261VideoMode x)
+{
+    Delete_Resolution(&x->resolution);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Deleter for Resolution (CHOICE)  */
+/* <===================================> */
+void Delete_Resolution(PS_Resolution x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (qcif is NULL) */
+            break;
+        case 1:
+            /* (cif is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Resolution: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for H262VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Delete_H262VideoMode(PS_H262VideoMode x)
+{
+    Delete_ProfileAndLevel(&x->profileAndLevel);
+    if (x->option_of_videoBitRate)
+    {
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+    }
+    if (x->option_of_samplesPerLine)
+    {
+    }
+    if (x->option_of_linesPerFrame)
+    {
+    }
+    if (x->option_of_framesPerSecond)
+    {
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for ProfileAndLevel (CHOICE)  */
+/* <========================================> */
+void Delete_ProfileAndLevel(PS_ProfileAndLevel x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (profileAndLevel_SPatML is NULL) */
+            break;
+        case 1:
+            /* (profileAndLevel_MPatLL is NULL) */
+            break;
+        case 2:
+            /* (profileAndLevel_MPatML is NULL) */
+            break;
+        case 3:
+            /* (profileAndLevel_MPatH_14 is NULL) */
+            break;
+        case 4:
+            /* (profileAndLevel_MPatHL is NULL) */
+            break;
+        case 5:
+            /* (profileAndLevel_SNRatLL is NULL) */
+            break;
+        case 6:
+            /* (profileAndLevel_SNRatML is NULL) */
+            break;
+        case 7:
+            /* (profileAndLevel_SpatialatH_14 is NULL) */
+            break;
+        case 8:
+            /* (profileAndLevel_HPatML is NULL) */
+            break;
+        case 9:
+            /* (profileAndLevel_HPatH_14 is NULL) */
+            break;
+        case 10:
+            /* (profileAndLevel_HPatHL is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_ProfileAndLevel: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Deleter for H263VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Delete_H263VideoMode(PS_H263VideoMode x)
+{
+    uint32 extension;
+
+    extension = x->option_of_errorCompensation |
+                x->option_of_enhancementLayerInfo |
+                x->option_of_h263Options;
+    Delete_H263Resolution(&x->h263Resolution);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_errorCompensation)
+    {
+    }
+    if (x->option_of_enhancementLayerInfo)
+    {
+        Delete_EnhancementLayerInfo(&x->enhancementLayerInfo);
+    }
+    if (x->option_of_h263Options)
+    {
+        Delete_H263Options(&x->h263Options);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for H263Resolution (CHOICE)  */
+/* <=======================================> */
+void Delete_H263Resolution(PS_H263Resolution x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (sqcif is NULL) */
+            break;
+        case 1:
+            /* (qcif is NULL) */
+            break;
+        case 2:
+            /* (cif is NULL) */
+            break;
+        case 3:
+            /* (cif4 is NULL) */
+            break;
+        case 4:
+            /* (cif16 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_H263Resolution: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for IS11172VideoMode (SEQUENCE)  */
+/* <===========================================> */
+void Delete_IS11172VideoMode(PS_IS11172VideoMode x)
+{
+    if (x->option_of_videoBitRate)
+    {
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+    }
+    if (x->option_of_samplesPerLine)
+    {
+    }
+    if (x->option_of_linesPerFrame)
+    {
+    }
+    if (x->option_of_pictureRate)
+    {
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for AudioMode (CHOICE)  */
+/* <==================================> */
+void Delete_AudioMode(PS_AudioMode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (g711Alaw64k is NULL) */
+            break;
+        case 2:
+            /* (g711Alaw56k is NULL) */
+            break;
+        case 3:
+            /* (g711Ulaw64k is NULL) */
+            break;
+        case 4:
+            /* (g711Ulaw56k is NULL) */
+            break;
+        case 5:
+            /* (g722_64k is NULL) */
+            break;
+        case 6:
+            /* (g722_56k is NULL) */
+            break;
+        case 7:
+            /* (g722_48k is NULL) */
+            break;
+        case 8:
+            /* (g728 is NULL) */
+            break;
+        case 9:
+            /* (g729 is NULL) */
+            break;
+        case 10:
+            /* (g729AnnexA is NULL) */
+            break;
+        case 11:
+            Delete_ModeG7231(x->modeG7231);
+            OSCL_DEFAULT_FREE(x->modeG7231);
+            break;
+        case 12:
+            Delete_IS11172AudioMode(x->is11172AudioMode);
+            OSCL_DEFAULT_FREE(x->is11172AudioMode);
+            break;
+        case 13:
+            Delete_IS13818AudioMode(x->is13818AudioMode);
+            OSCL_DEFAULT_FREE(x->is13818AudioMode);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            break;
+        case 15:
+            break;
+        case 16:
+            Delete_G7231AnnexCMode(x->g7231AnnexCMode);
+            OSCL_DEFAULT_FREE(x->g7231AnnexCMode);
+            break;
+        case 17:
+            Delete_GSMAudioCapability(x->gsmFullRate);
+            OSCL_DEFAULT_FREE(x->gsmFullRate);
+            break;
+        case 18:
+            Delete_GSMAudioCapability(x->gsmHalfRate);
+            OSCL_DEFAULT_FREE(x->gsmHalfRate);
+            break;
+        case 19:
+            Delete_GSMAudioCapability(x->gsmEnhancedFullRate);
+            OSCL_DEFAULT_FREE(x->gsmEnhancedFullRate);
+            break;
+        case 20:
+            Delete_GenericCapability(x->genericAudioMode);
+            OSCL_DEFAULT_FREE(x->genericAudioMode);
+            break;
+        case 21:
+            Delete_G729Extensions(x->g729Extensions);
+            OSCL_DEFAULT_FREE(x->g729Extensions);
+            break;
+        default:
+            ErrorMessage("Delete_AudioMode: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for ModeG7231 (CHOICE)  */
+/* <==================================> */
+void Delete_ModeG7231(PS_ModeG7231 x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noSilenceSuppressionLowRate is NULL) */
+            break;
+        case 1:
+            /* (noSilenceSuppressionHighRate is NULL) */
+            break;
+        case 2:
+            /* (silenceSuppressionLowRate is NULL) */
+            break;
+        case 3:
+            /* (silenceSuppressionHighRate is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_ModeG7231: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for IS11172AudioMode (SEQUENCE)  */
+/* <===========================================> */
+void Delete_IS11172AudioMode(PS_IS11172AudioMode x)
+{
+    Delete_AudioLayer(&x->audioLayer);
+    Delete_AudioSampling(&x->audioSampling);
+    Delete_MultichannelType(&x->multichannelType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Deleter for MultichannelType (CHOICE)  */
+/* <=========================================> */
+void Delete_MultichannelType(PS_MultichannelType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (singleChannel is NULL) */
+            break;
+        case 1:
+            /* (twoChannelStereo is NULL) */
+            break;
+        case 2:
+            /* (twoChannelDual is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_MultichannelType: Illegal CHOICE index");
+    }
+}
+
+/* <======================================> */
+/*  PER-Deleter for AudioSampling (CHOICE)  */
+/* <======================================> */
+void Delete_AudioSampling(PS_AudioSampling x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (audioSampling32k is NULL) */
+            break;
+        case 1:
+            /* (audioSampling44k1 is NULL) */
+            break;
+        case 2:
+            /* (audioSampling48k is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_AudioSampling: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Deleter for AudioLayer (CHOICE)  */
+/* <===================================> */
+void Delete_AudioLayer(PS_AudioLayer x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (audioLayer1 is NULL) */
+            break;
+        case 1:
+            /* (audioLayer2 is NULL) */
+            break;
+        case 2:
+            /* (audioLayer3 is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_AudioLayer: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for IS13818AudioMode (SEQUENCE)  */
+/* <===========================================> */
+void Delete_IS13818AudioMode(PS_IS13818AudioMode x)
+{
+    Delete_Is13818AudioLayer(&x->is13818AudioLayer);
+    Delete_Is13818AudioSampling(&x->is13818AudioSampling);
+    Delete_Is13818MultichannelType(&x->is13818MultichannelType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Deleter for Is13818MultichannelType (CHOICE)  */
+/* <================================================> */
+void Delete_Is13818MultichannelType(PS_Is13818MultichannelType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (singleChannel is NULL) */
+            break;
+        case 1:
+            /* (twoChannelStereo is NULL) */
+            break;
+        case 2:
+            /* (twoChannelDual is NULL) */
+            break;
+        case 3:
+            /* (threeChannels2_1 is NULL) */
+            break;
+        case 4:
+            /* (threeChannels3_0 is NULL) */
+            break;
+        case 5:
+            /* (fourChannels2_0_2_0 is NULL) */
+            break;
+        case 6:
+            /* (fourChannels2_2 is NULL) */
+            break;
+        case 7:
+            /* (fourChannels3_1 is NULL) */
+            break;
+        case 8:
+            /* (fiveChannels3_0_2_0 is NULL) */
+            break;
+        case 9:
+            /* (fiveChannels3_2 is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Is13818MultichannelType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for Is13818AudioSampling (CHOICE)  */
+/* <=============================================> */
+void Delete_Is13818AudioSampling(PS_Is13818AudioSampling x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (audioSampling16k is NULL) */
+            break;
+        case 1:
+            /* (audioSampling22k05 is NULL) */
+            break;
+        case 2:
+            /* (audioSampling24k is NULL) */
+            break;
+        case 3:
+            /* (audioSampling32k is NULL) */
+            break;
+        case 4:
+            /* (audioSampling44k1 is NULL) */
+            break;
+        case 5:
+            /* (audioSampling48k is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Is13818AudioSampling: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for Is13818AudioLayer (CHOICE)  */
+/* <==========================================> */
+void Delete_Is13818AudioLayer(PS_Is13818AudioLayer x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (audioLayer1 is NULL) */
+            break;
+        case 1:
+            /* (audioLayer2 is NULL) */
+            break;
+        case 2:
+            /* (audioLayer3 is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_Is13818AudioLayer: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for G7231AnnexCMode (SEQUENCE)  */
+/* <==========================================> */
+void Delete_G7231AnnexCMode(PS_G7231AnnexCMode x)
+{
+    Delete_ModeG723AnnexCAudioMode(&x->modeG723AnnexCAudioMode);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for ModeG723AnnexCAudioMode (SEQUENCE)  */
+/* <==================================================> */
+void Delete_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Deleter for DataMode (SEQUENCE)  */
+/* <===================================> */
+void Delete_DataMode(PS_DataMode x)
+{
+    Delete_DmApplication(&x->dmApplication);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for DmApplication (CHOICE)  */
+/* <======================================> */
+void Delete_DmApplication(PS_DmApplication x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_DataProtocolCapability(x->t120);
+            OSCL_DEFAULT_FREE(x->t120);
+            break;
+        case 2:
+            Delete_DataProtocolCapability(x->dsm_cc);
+            OSCL_DEFAULT_FREE(x->dsm_cc);
+            break;
+        case 3:
+            Delete_DataProtocolCapability(x->userData);
+            OSCL_DEFAULT_FREE(x->userData);
+            break;
+        case 4:
+            Delete_DataProtocolCapability(x->t84);
+            OSCL_DEFAULT_FREE(x->t84);
+            break;
+        case 5:
+            Delete_DataProtocolCapability(x->t434);
+            OSCL_DEFAULT_FREE(x->t434);
+            break;
+        case 6:
+            Delete_DataProtocolCapability(x->h224);
+            OSCL_DEFAULT_FREE(x->h224);
+            break;
+        case 7:
+            Delete_DmNlpid(x->dmNlpid);
+            OSCL_DEFAULT_FREE(x->dmNlpid);
+            break;
+        case 8:
+            /* (dsvdControl is NULL) */
+            break;
+        case 9:
+            Delete_DataProtocolCapability(x->h222DataPartitioning);
+            OSCL_DEFAULT_FREE(x->h222DataPartitioning);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Delete_DataProtocolCapability(x->t30fax);
+            OSCL_DEFAULT_FREE(x->t30fax);
+            break;
+        case 11:
+            Delete_DataProtocolCapability(x->t140);
+            OSCL_DEFAULT_FREE(x->t140);
+            break;
+        case 12:
+            Delete_DmT38fax(x->dmT38fax);
+            OSCL_DEFAULT_FREE(x->dmT38fax);
+            break;
+        case 13:
+            Delete_GenericCapability(x->genericDataMode);
+            OSCL_DEFAULT_FREE(x->genericDataMode);
+            break;
+        default:
+            ErrorMessage("Delete_DmApplication: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Deleter for DmT38fax (SEQUENCE)  */
+/* <===================================> */
+void Delete_DmT38fax(PS_DmT38fax x)
+{
+    Delete_DataProtocolCapability(&x->t38FaxProtocol);
+    Delete_T38FaxProfile(&x->t38FaxProfile);
+}
+
+/* <==================================> */
+/*  PER-Deleter for DmNlpid (SEQUENCE)  */
+/* <==================================> */
+void Delete_DmNlpid(PS_DmNlpid x)
+{
+    Delete_DataProtocolCapability(&x->nlpidProtocol);
+}
+
+/* <=======================================> */
+/*  PER-Deleter for EncryptionMode (CHOICE)  */
+/* <=======================================> */
+void Delete_EncryptionMode(PS_EncryptionMode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (h233Encryption is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_EncryptionMode: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Deleter for RoundTripDelayRequest (SEQUENCE)  */
+/* <================================================> */
+void Delete_RoundTripDelayRequest(PS_RoundTripDelayRequest x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for RoundTripDelayResponse (SEQUENCE)  */
+/* <=================================================> */
+void Delete_RoundTripDelayResponse(PS_RoundTripDelayResponse x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Deleter for MaintenanceLoopRequest (SEQUENCE)  */
+/* <=================================================> */
+void Delete_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x)
+{
+    Delete_MlRequestType(&x->mlRequestType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for MlRequestType (CHOICE)  */
+/* <======================================> */
+void Delete_MlRequestType(PS_MlRequestType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            break;
+        case 2:
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MlRequestType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for MaintenanceLoopAck (SEQUENCE)  */
+/* <=============================================> */
+void Delete_MaintenanceLoopAck(PS_MaintenanceLoopAck x)
+{
+    Delete_MlAckType(&x->mlAckType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for MlAckType (CHOICE)  */
+/* <==================================> */
+void Delete_MlAckType(PS_MlAckType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            break;
+        case 2:
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MlAckType: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Deleter for MaintenanceLoopReject (SEQUENCE)  */
+/* <================================================> */
+void Delete_MaintenanceLoopReject(PS_MaintenanceLoopReject x)
+{
+    Delete_MlRejectType(&x->mlRejectType);
+    Delete_MlRejectCause(&x->mlRejectCause);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Deleter for MlRejectCause (CHOICE)  */
+/* <======================================> */
+void Delete_MlRejectCause(PS_MlRejectCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (canNotPerformLoop is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MlRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for MlRejectType (CHOICE)  */
+/* <=====================================> */
+void Delete_MlRejectType(PS_MlRejectType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            break;
+        case 2:
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MlRejectType: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Deleter for MaintenanceLoopOffCommand (SEQUENCE)  */
+/* <====================================================> */
+void Delete_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for CommunicationModeCommand (SEQUENCE)  */
+/* <===================================================> */
+void Delete_CommunicationModeCommand(PS_CommunicationModeCommand x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_communicationModeTable;++i)
+    {
+        Delete_CommunicationModeTableEntry(x->communicationModeTable + i);
+    }
+    OSCL_DEFAULT_FREE(x->communicationModeTable);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for CommunicationModeRequest (SEQUENCE)  */
+/* <===================================================> */
+void Delete_CommunicationModeRequest(PS_CommunicationModeRequest x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for CommunicationModeResponse (CHOICE)  */
+/* <==================================================> */
+void Delete_CommunicationModeResponse(PS_CommunicationModeResponse x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_CommunicationModeTableEntry(x->communicationModeTable + i);
+            }
+            OSCL_DEFAULT_FREE(x->communicationModeTable);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CommunicationModeResponse: Illegal CHOICE index");
+    }
+}
+
+/* <======================================================> */
+/*  PER-Deleter for CommunicationModeTableEntry (SEQUENCE)  */
+/* <======================================================> */
+void Delete_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x)
+{
+    uint16 i = 0;
+    uint32 extension;
+
+    extension = x->option_of_redundancyEncoding |
+                x->option_of_sessionDependency |
+                x->option_of_destination;
+    if (x->option_of_nonStandard)
+    {
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Delete_NonStandardParameter(x->nonStandard + i);
+        }
+        OSCL_DEFAULT_FREE(x->nonStandard);
+    }
+    if (x->option_of_associatedSessionID)
+    {
+    }
+    if (x->option_of_terminalLabel)
+    {
+        Delete_TerminalLabel(&x->terminalLabel);
+    }
+    Delete_CmtDataType(&x->cmtDataType);
+    if (x->option_of_mediaChannel)
+    {
+        Delete_TransportAddress(&x->mediaChannel);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Delete_TransportAddress(&x->mediaControlChannel);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_redundancyEncoding)
+    {
+        Delete_RedundancyEncoding(&x->redundancyEncoding);
+    }
+    if (x->option_of_sessionDependency)
+    {
+    }
+    if (x->option_of_destination)
+    {
+        Delete_TerminalLabel(&x->destination);
+    }
+}
+
+/* <====================================> */
+/*  PER-Deleter for CmtDataType (CHOICE)  */
+/* <====================================> */
+void Delete_CmtDataType(PS_CmtDataType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_VideoCapability(x->videoData);
+            OSCL_DEFAULT_FREE(x->videoData);
+            break;
+        case 1:
+            Delete_AudioCapability(x->audioData);
+            OSCL_DEFAULT_FREE(x->audioData);
+            break;
+        case 2:
+            Delete_DataApplicationCapability(x->data);
+            OSCL_DEFAULT_FREE(x->data);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CmtDataType: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for ConferenceRequest (CHOICE)  */
+/* <==========================================> */
+void Delete_ConferenceRequest(PS_ConferenceRequest x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (terminalListRequest is NULL) */
+            break;
+        case 1:
+            /* (makeMeChair is NULL) */
+            break;
+        case 2:
+            /* (cancelMakeMeChair is NULL) */
+            break;
+        case 3:
+            Delete_TerminalLabel(x->dropTerminal);
+            OSCL_DEFAULT_FREE(x->dropTerminal);
+            break;
+        case 4:
+            Delete_TerminalLabel(x->requestTerminalID);
+            OSCL_DEFAULT_FREE(x->requestTerminalID);
+            break;
+        case 5:
+            /* (enterH243Password is NULL) */
+            break;
+        case 6:
+            /* (enterH243TerminalID is NULL) */
+            break;
+        case 7:
+            /* (enterH243ConferenceID is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            break;
+        case 9:
+            break;
+        case 10:
+            Delete_RequestTerminalCertificate(x->requestTerminalCertificate);
+            OSCL_DEFAULT_FREE(x->requestTerminalCertificate);
+            break;
+        case 11:
+            break;
+        case 12:
+            Delete_TerminalLabel(x->makeTerminalBroadcaster);
+            OSCL_DEFAULT_FREE(x->makeTerminalBroadcaster);
+            break;
+        case 13:
+            Delete_TerminalLabel(x->sendThisSource);
+            OSCL_DEFAULT_FREE(x->sendThisSource);
+            break;
+        case 14:
+            break;
+        case 15:
+            Delete_RemoteMCRequest(x->remoteMCRequest);
+            OSCL_DEFAULT_FREE(x->remoteMCRequest);
+            break;
+        default:
+            ErrorMessage("Delete_ConferenceRequest: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Deleter for RequestTerminalCertificate (SEQUENCE)  */
+/* <=====================================================> */
+void Delete_RequestTerminalCertificate(PS_RequestTerminalCertificate x)
+{
+    if (x->option_of_terminalLabel)
+    {
+        Delete_TerminalLabel(&x->terminalLabel);
+    }
+    if (x->option_of_certSelectionCriteria)
+    {
+        Delete_CertSelectionCriteria(&x->certSelectionCriteria);
+    }
+    if (x->option_of_sRandom)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for CertSelectionCriteria (SEQUENCE-OF)  */
+/* <===================================================> */
+void Delete_CertSelectionCriteria(PS_CertSelectionCriteria x)
+{
+    uint16 i;
+    for (i = 0;i < x->size;++i)
+    {
+        Delete_Criteria(x->item + i);
+    }
+    OSCL_DEFAULT_FREE(x->item);
+}
+
+/* <===================================> */
+/*  PER-Deleter for Criteria (SEQUENCE)  */
+/* <===================================> */
+void Delete_Criteria(PS_Criteria x)
+{
+    OSCL_DEFAULT_FREE(x->field.data);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for TerminalLabel (SEQUENCE)  */
+/* <========================================> */
+void Delete_TerminalLabel(PS_TerminalLabel x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Deleter for ConferenceResponse (CHOICE)  */
+/* <===========================================> */
+void Delete_ConferenceResponse(PS_ConferenceResponse x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            Delete_MCTerminalIDResponse(x->mCTerminalIDResponse);
+            OSCL_DEFAULT_FREE(x->mCTerminalIDResponse);
+            break;
+        case 1:
+            Delete_TerminalIDResponse(x->terminalIDResponse);
+            OSCL_DEFAULT_FREE(x->terminalIDResponse);
+            break;
+        case 2:
+            Delete_ConferenceIDResponse(x->conferenceIDResponse);
+            OSCL_DEFAULT_FREE(x->conferenceIDResponse);
+            break;
+        case 3:
+            Delete_PasswordResponse(x->passwordResponse);
+            OSCL_DEFAULT_FREE(x->passwordResponse);
+            break;
+        case 4:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_TerminalLabel(x->terminalListResponse + i);
+            }
+            OSCL_DEFAULT_FREE(x->terminalListResponse);
+            break;
+        case 5:
+            /* (videoCommandReject is NULL) */
+            break;
+        case 6:
+            /* (terminalDropReject is NULL) */
+            break;
+        case 7:
+            Delete_MakeMeChairResponse(x->makeMeChairResponse);
+            OSCL_DEFAULT_FREE(x->makeMeChairResponse);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            Delete_ExtensionAddressResponse(x->extensionAddressResponse);
+            OSCL_DEFAULT_FREE(x->extensionAddressResponse);
+            break;
+        case 9:
+            Delete_ChairTokenOwnerResponse(x->chairTokenOwnerResponse);
+            OSCL_DEFAULT_FREE(x->chairTokenOwnerResponse);
+            break;
+        case 10:
+            Delete_TerminalCertificateResponse(x->terminalCertificateResponse);
+            OSCL_DEFAULT_FREE(x->terminalCertificateResponse);
+            break;
+        case 11:
+            Delete_BroadcastMyLogicalChannelResponse(x->broadcastMyLogicalChannelResponse);
+            OSCL_DEFAULT_FREE(x->broadcastMyLogicalChannelResponse);
+            break;
+        case 12:
+            Delete_MakeTerminalBroadcasterResponse(x->makeTerminalBroadcasterResponse);
+            OSCL_DEFAULT_FREE(x->makeTerminalBroadcasterResponse);
+            break;
+        case 13:
+            Delete_SendThisSourceResponse(x->sendThisSourceResponse);
+            OSCL_DEFAULT_FREE(x->sendThisSourceResponse);
+            break;
+        case 14:
+            Delete_RequestAllTerminalIDsResponse(x->requestAllTerminalIDsResponse);
+            OSCL_DEFAULT_FREE(x->requestAllTerminalIDsResponse);
+            break;
+        case 15:
+            Delete_RemoteMCResponse(x->remoteMCResponse);
+            OSCL_DEFAULT_FREE(x->remoteMCResponse);
+            break;
+        default:
+            ErrorMessage("Delete_ConferenceResponse: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for SendThisSourceResponse (CHOICE)  */
+/* <===============================================> */
+void Delete_SendThisSourceResponse(PS_SendThisSourceResponse x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedSendThisSource is NULL) */
+            break;
+        case 1:
+            /* (deniedSendThisSource is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_SendThisSourceResponse: Illegal CHOICE index");
+    }
+}
+
+/* <========================================================> */
+/*  PER-Deleter for MakeTerminalBroadcasterResponse (CHOICE)  */
+/* <========================================================> */
+void Delete_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedMakeTerminalBroadcaster is NULL) */
+            break;
+        case 1:
+            /* (deniedMakeTerminalBroadcaster is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MakeTerminalBroadcasterResponse: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Deleter for BroadcastMyLogicalChannelResponse (CHOICE)  */
+/* <==========================================================> */
+void Delete_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedBroadcastMyLogicalChannel is NULL) */
+            break;
+        case 1:
+            /* (deniedBroadcastMyLogicalChannel is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_BroadcastMyLogicalChannelResponse: Illegal CHOICE index");
+    }
+}
+
+/* <======================================================> */
+/*  PER-Deleter for TerminalCertificateResponse (SEQUENCE)  */
+/* <======================================================> */
+void Delete_TerminalCertificateResponse(PS_TerminalCertificateResponse x)
+{
+    if (x->option_of_terminalLabel)
+    {
+        Delete_TerminalLabel(&x->terminalLabel);
+    }
+    if (x->option_of_certificateResponse)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for ChairTokenOwnerResponse (SEQUENCE)  */
+/* <==================================================> */
+void Delete_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x)
+{
+    Delete_TerminalLabel(&x->terminalLabel);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for ExtensionAddressResponse (SEQUENCE)  */
+/* <===================================================> */
+void Delete_ExtensionAddressResponse(PS_ExtensionAddressResponse x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for MakeMeChairResponse (CHOICE)  */
+/* <============================================> */
+void Delete_MakeMeChairResponse(PS_MakeMeChairResponse x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedChairToken is NULL) */
+            break;
+        case 1:
+            /* (deniedChairToken is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MakeMeChairResponse: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for PasswordResponse (SEQUENCE)  */
+/* <===========================================> */
+void Delete_PasswordResponse(PS_PasswordResponse x)
+{
+    Delete_TerminalLabel(&x->terminalLabel);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for ConferenceIDResponse (SEQUENCE)  */
+/* <===============================================> */
+void Delete_ConferenceIDResponse(PS_ConferenceIDResponse x)
+{
+    Delete_TerminalLabel(&x->terminalLabel);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for TerminalIDResponse (SEQUENCE)  */
+/* <=============================================> */
+void Delete_TerminalIDResponse(PS_TerminalIDResponse x)
+{
+    Delete_TerminalLabel(&x->terminalLabel);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for MCTerminalIDResponse (SEQUENCE)  */
+/* <===============================================> */
+void Delete_MCTerminalIDResponse(PS_MCTerminalIDResponse x)
+{
+    Delete_TerminalLabel(&x->terminalLabel);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================================> */
+/*  PER-Deleter for RequestAllTerminalIDsResponse (SEQUENCE)  */
+/* <========================================================> */
+void Delete_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x)
+{
+    uint16 i = 0;
+    for (i = 0;i < x->size_of_terminalInformation;++i)
+    {
+        Delete_TerminalInformation(x->terminalInformation + i);
+    }
+    OSCL_DEFAULT_FREE(x->terminalInformation);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Deleter for TerminalInformation (SEQUENCE)  */
+/* <==============================================> */
+void Delete_TerminalInformation(PS_TerminalInformation x)
+{
+    Delete_TerminalLabel(&x->terminalLabel);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for RemoteMCRequest (CHOICE)  */
+/* <========================================> */
+void Delete_RemoteMCRequest(PS_RemoteMCRequest x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (masterActivate is NULL) */
+            break;
+        case 1:
+            /* (slaveActivate is NULL) */
+            break;
+        case 2:
+            /* (deActivate is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RemoteMCRequest: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for RemoteMCResponse (CHOICE)  */
+/* <=========================================> */
+void Delete_RemoteMCResponse(PS_RemoteMCResponse x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (accept is NULL) */
+            break;
+        case 1:
+            Delete_Reject(x->reject);
+            OSCL_DEFAULT_FREE(x->reject);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RemoteMCResponse: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Deleter for Reject (CHOICE)  */
+/* <===============================> */
+void Delete_Reject(PS_Reject x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (functionNotSupported is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Reject: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for MultilinkRequest (CHOICE)  */
+/* <=========================================> */
+void Delete_MultilinkRequest(PS_MultilinkRequest x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_CallInformation(x->callInformation);
+            OSCL_DEFAULT_FREE(x->callInformation);
+            break;
+        case 2:
+            Delete_AddConnection(x->addConnection);
+            OSCL_DEFAULT_FREE(x->addConnection);
+            break;
+        case 3:
+            Delete_RemoveConnection(x->removeConnection);
+            OSCL_DEFAULT_FREE(x->removeConnection);
+            break;
+        case 4:
+            Delete_MaximumHeaderInterval(x->maximumHeaderInterval);
+            OSCL_DEFAULT_FREE(x->maximumHeaderInterval);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MultilinkRequest: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Deleter for MaximumHeaderInterval (SEQUENCE)  */
+/* <================================================> */
+void Delete_MaximumHeaderInterval(PS_MaximumHeaderInterval x)
+{
+    Delete_RequestType(&x->requestType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Deleter for RequestType (CHOICE)  */
+/* <====================================> */
+void Delete_RequestType(PS_RequestType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (currentIntervalInformation is NULL) */
+            break;
+        case 1:
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_RequestType: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Deleter for RemoveConnection (SEQUENCE)  */
+/* <===========================================> */
+void Delete_RemoveConnection(PS_RemoveConnection x)
+{
+    Delete_ConnectionIdentifier(&x->connectionIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Deleter for AddConnection (SEQUENCE)  */
+/* <========================================> */
+void Delete_AddConnection(PS_AddConnection x)
+{
+    Delete_DialingInformation(&x->dialingInformation);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Deleter for CallInformation (SEQUENCE)  */
+/* <==========================================> */
+void Delete_CallInformation(PS_CallInformation x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Deleter for MultilinkResponse (CHOICE)  */
+/* <==========================================> */
+void Delete_MultilinkResponse(PS_MultilinkResponse x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_RespCallInformation(x->respCallInformation);
+            OSCL_DEFAULT_FREE(x->respCallInformation);
+            break;
+        case 2:
+            Delete_RespAddConnection(x->respAddConnection);
+            OSCL_DEFAULT_FREE(x->respAddConnection);
+            break;
+        case 3:
+            Delete_RespRemoveConnection(x->respRemoveConnection);
+            OSCL_DEFAULT_FREE(x->respRemoveConnection);
+            break;
+        case 4:
+            Delete_RespMaximumHeaderInterval(x->respMaximumHeaderInterval);
+            OSCL_DEFAULT_FREE(x->respMaximumHeaderInterval);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MultilinkResponse: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Deleter for RespMaximumHeaderInterval (SEQUENCE)  */
+/* <====================================================> */
+void Delete_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for RespRemoveConnection (SEQUENCE)  */
+/* <===============================================> */
+void Delete_RespRemoveConnection(PS_RespRemoveConnection x)
+{
+    Delete_ConnectionIdentifier(&x->connectionIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for RespAddConnection (SEQUENCE)  */
+/* <============================================> */
+void Delete_RespAddConnection(PS_RespAddConnection x)
+{
+    Delete_ResponseCode(&x->responseCode);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Deleter for ResponseCode (CHOICE)  */
+/* <=====================================> */
+void Delete_ResponseCode(PS_ResponseCode x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (accepted is NULL) */
+            break;
+        case 1:
+            Delete_Rejected(x->rejected);
+            OSCL_DEFAULT_FREE(x->rejected);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_ResponseCode: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Deleter for Rejected (CHOICE)  */
+/* <=================================> */
+void Delete_Rejected(PS_Rejected x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (connectionsNotAvailable is NULL) */
+            break;
+        case 1:
+            /* (userRejected is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Rejected: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Deleter for RespCallInformation (SEQUENCE)  */
+/* <==============================================> */
+void Delete_RespCallInformation(PS_RespCallInformation x)
+{
+    Delete_DialingInformation(&x->dialingInformation);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Deleter for MultilinkIndication (CHOICE)  */
+/* <============================================> */
+void Delete_MultilinkIndication(PS_MultilinkIndication x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            Delete_CrcDesired(x->crcDesired);
+            OSCL_DEFAULT_FREE(x->crcDesired);
+            break;
+        case 2:
+            Delete_ExcessiveError(x->excessiveError);
+            OSCL_DEFAULT_FREE(x->excessiveError);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_MultilinkIndication: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for ExcessiveError (SEQUENCE)  */
+/* <=========================================> */
+void Delete_ExcessiveError(PS_ExcessiveError x)
+{
+    Delete_ConnectionIdentifier(&x->connectionIdentifier);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Deleter for CrcDesired (SEQUENCE)  */
+/* <=====================================> */
+void Delete_CrcDesired(PS_CrcDesired x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Deleter for DialingInformation (CHOICE)  */
+/* <===========================================> */
+void Delete_DialingInformation(PS_DialingInformation x)
+{
+    uint16 i;
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            for (i = 0;i < x->size;++i)
+            {
+                Delete_DialingInformationNumber(x->differential + i);
+            }
+            OSCL_DEFAULT_FREE(x->differential);
+            break;
+        case 2:
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_DialingInformation: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Deleter for DialingInformationNumber (SEQUENCE)  */
+/* <===================================================> */
+void Delete_DialingInformationNumber(PS_DialingInformationNumber x)
+{
+    uint16 i = 0;
+    if (x->option_of_subAddress)
+    {
+    }
+    for (i = 0;i < x->size_of_networkType;++i)
+    {
+        Delete_DialingInformationNetworkType(x->networkType + i);
+    }
+    OSCL_DEFAULT_FREE(x->networkType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Deleter for DialingInformationNetworkType (CHOICE)  */
+/* <======================================================> */
+void Delete_DialingInformationNetworkType(PS_DialingInformationNetworkType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardMessage(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (n_isdn is NULL) */
+            break;
+        case 2:
+            /* (gstn is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_DialingInformationNetworkType: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for ConnectionIdentifier (SEQUENCE)  */
+/* <===============================================> */
+void Delete_ConnectionIdentifier(PS_ConnectionIdentifier x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================================> */
+/*  PER-Deleter for LogicalChannelRateRequest (SEQUENCE)  */
+/* <====================================================> */
+void Delete_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================================> */
+/*  PER-Deleter for LogicalChannelRateAcknowledge (SEQUENCE)  */
+/* <========================================================> */
+void Delete_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for LogicalChannelRateReject (SEQUENCE)  */
+/* <===================================================> */
+void Delete_LogicalChannelRateReject(PS_LogicalChannelRateReject x)
+{
+    Delete_LogicalChannelRateRejectReason(&x->rejectReason);
+    if (x->option_of_currentMaximumBitRate)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Deleter for LogicalChannelRateRejectReason (CHOICE)  */
+/* <=======================================================> */
+void Delete_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (undefinedReason is NULL) */
+            break;
+        case 1:
+            /* (insufficientResources is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_LogicalChannelRateRejectReason: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Deleter for LogicalChannelRateRelease (SEQUENCE)  */
+/* <====================================================> */
+void Delete_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for SendTerminalCapabilitySet (CHOICE)  */
+/* <==================================================> */
+void Delete_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_SpecificRequest(x->specificRequest);
+            OSCL_DEFAULT_FREE(x->specificRequest);
+            break;
+        case 1:
+            /* (genericRequest is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_SendTerminalCapabilitySet: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for SpecificRequest (SEQUENCE)  */
+/* <==========================================> */
+void Delete_SpecificRequest(PS_SpecificRequest x)
+{
+    if (x->option_of_capabilityTableEntryNumbers)
+    {
+        OSCL_DEFAULT_FREE(x->capabilityTableEntryNumbers);
+    }
+    if (x->option_of_capabilityDescriptorNumbers)
+    {
+        OSCL_DEFAULT_FREE(x->capabilityDescriptorNumbers);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Deleter for EncryptionCommand (CHOICE)  */
+/* <==========================================> */
+void Delete_EncryptionCommand(PS_EncryptionCommand x)
+{
+    switch (x->index)
+    {
+        case 0:
+            FreeOctetString(x->encryptionSE);
+            break;
+        case 1:
+            /* (encryptionIVRequest is NULL) */
+            break;
+        case 2:
+            Delete_EncryptionAlgorithmID(x->encryptionAlgorithmID);
+            OSCL_DEFAULT_FREE(x->encryptionAlgorithmID);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_EncryptionCommand: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Deleter for EncryptionAlgorithmID (SEQUENCE)  */
+/* <================================================> */
+void Delete_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x)
+{
+    Delete_NonStandardParameter(&x->associatedAlgorithm);
+}
+
+/* <=============================================> */
+/*  PER-Deleter for FlowControlCommand (SEQUENCE)  */
+/* <=============================================> */
+void Delete_FlowControlCommand(PS_FlowControlCommand x)
+{
+    Delete_FccScope(&x->fccScope);
+    Delete_FccRestriction(&x->fccRestriction);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for FccRestriction (CHOICE)  */
+/* <=======================================> */
+void Delete_FccRestriction(PS_FccRestriction x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            /* (noRestriction is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_FccRestriction: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Deleter for FccScope (CHOICE)  */
+/* <=================================> */
+void Delete_FccScope(PS_FccScope x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_FccScope: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for EndSessionCommand (CHOICE)  */
+/* <==========================================> */
+void Delete_EndSessionCommand(PS_EndSessionCommand x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (disconnect is NULL) */
+            break;
+        case 2:
+            Delete_GstnOptions(x->gstnOptions);
+            OSCL_DEFAULT_FREE(x->gstnOptions);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            Delete_IsdnOptions(x->isdnOptions);
+            OSCL_DEFAULT_FREE(x->isdnOptions);
+            break;
+        default:
+            ErrorMessage("Delete_EndSessionCommand: Illegal CHOICE index");
+    }
+}
+
+/* <====================================> */
+/*  PER-Deleter for IsdnOptions (CHOICE)  */
+/* <====================================> */
+void Delete_IsdnOptions(PS_IsdnOptions x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (telephonyMode is NULL) */
+            break;
+        case 1:
+            /* (v140 is NULL) */
+            break;
+        case 2:
+            /* (terminalOnHold is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_IsdnOptions: Illegal CHOICE index");
+    }
+}
+
+/* <====================================> */
+/*  PER-Deleter for GstnOptions (CHOICE)  */
+/* <====================================> */
+void Delete_GstnOptions(PS_GstnOptions x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (telephonyMode is NULL) */
+            break;
+        case 1:
+            /* (v8bis is NULL) */
+            break;
+        case 2:
+            /* (v34DSVD is NULL) */
+            break;
+        case 3:
+            /* (v34DuplexFAX is NULL) */
+            break;
+        case 4:
+            /* (v34H324 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_GstnOptions: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for ConferenceCommand (CHOICE)  */
+/* <==========================================> */
+void Delete_ConferenceCommand(PS_ConferenceCommand x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            break;
+        case 2:
+            Delete_TerminalLabel(x->makeTerminalBroadcaster);
+            OSCL_DEFAULT_FREE(x->makeTerminalBroadcaster);
+            break;
+        case 3:
+            /* (cancelMakeTerminalBroadcaster is NULL) */
+            break;
+        case 4:
+            Delete_TerminalLabel(x->sendThisSource);
+            OSCL_DEFAULT_FREE(x->sendThisSource);
+            break;
+        case 5:
+            /* (cancelSendThisSource is NULL) */
+            break;
+        case 6:
+            /* (dropConference is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            Delete_SubstituteConferenceIDCommand(x->substituteConferenceIDCommand);
+            OSCL_DEFAULT_FREE(x->substituteConferenceIDCommand);
+            break;
+        default:
+            ErrorMessage("Delete_ConferenceCommand: Illegal CHOICE index");
+    }
+}
+
+/* <========================================================> */
+/*  PER-Deleter for SubstituteConferenceIDCommand (SEQUENCE)  */
+/* <========================================================> */
+void Delete_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for MiscellaneousCommand (SEQUENCE)  */
+/* <===============================================> */
+void Delete_MiscellaneousCommand(PS_MiscellaneousCommand x)
+{
+    Delete_McType(&x->mcType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================> */
+/*  PER-Deleter for McType (CHOICE)  */
+/* <===============================> */
+void Delete_McType(PS_McType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (equaliseDelay is NULL) */
+            break;
+        case 1:
+            /* (zeroDelay is NULL) */
+            break;
+        case 2:
+            /* (multipointModeCommand is NULL) */
+            break;
+        case 3:
+            /* (cancelMultipointModeCommand is NULL) */
+            break;
+        case 4:
+            /* (videoFreezePicture is NULL) */
+            break;
+        case 5:
+            /* (videoFastUpdatePicture is NULL) */
+            break;
+        case 6:
+            Delete_VideoFastUpdateGOB(x->videoFastUpdateGOB);
+            OSCL_DEFAULT_FREE(x->videoFastUpdateGOB);
+            break;
+        case 7:
+            break;
+        case 8:
+            /* (videoSendSyncEveryGOB is NULL) */
+            break;
+        case 9:
+            /* (videoSendSyncEveryGOBCancel is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Delete_VideoFastUpdateMB(x->videoFastUpdateMB);
+            OSCL_DEFAULT_FREE(x->videoFastUpdateMB);
+            break;
+        case 11:
+            break;
+        case 12:
+            Delete_EncryptionSync(x->encryptionUpdate);
+            OSCL_DEFAULT_FREE(x->encryptionUpdate);
+            break;
+        case 13:
+            Delete_EncryptionUpdateRequest(x->encryptionUpdateRequest);
+            OSCL_DEFAULT_FREE(x->encryptionUpdateRequest);
+            break;
+        case 14:
+            break;
+        case 15:
+            break;
+        case 16:
+            Delete_ProgressiveRefinementStart(x->progressiveRefinementStart);
+            OSCL_DEFAULT_FREE(x->progressiveRefinementStart);
+            break;
+        case 17:
+            break;
+        case 18:
+            break;
+        default:
+            ErrorMessage("Delete_McType: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Deleter for ProgressiveRefinementStart (SEQUENCE)  */
+/* <=====================================================> */
+void Delete_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x)
+{
+    Delete_PrsRepeatCount(&x->prsRepeatCount);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for PrsRepeatCount (CHOICE)  */
+/* <=======================================> */
+void Delete_PrsRepeatCount(PS_PrsRepeatCount x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (doOneProgression is NULL) */
+            break;
+        case 1:
+            /* (doContinuousProgressions is NULL) */
+            break;
+        case 2:
+            /* (doOneIndependentProgression is NULL) */
+            break;
+        case 3:
+            /* (doContinuousIndependentProgressions is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_PrsRepeatCount: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Deleter for VideoFastUpdateMB (SEQUENCE)  */
+/* <============================================> */
+void Delete_VideoFastUpdateMB(PS_VideoFastUpdateMB x)
+{
+    if (x->option_of_firstGOB)
+    {
+    }
+    if (x->option_of_firstMB)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for VideoFastUpdateGOB (SEQUENCE)  */
+/* <=============================================> */
+void Delete_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x)
+{
+    OSCL_UNUSED_ARG(x);
+}
+
+/* <==============================================> */
+/*  PER-Deleter for KeyProtectionMethod (SEQUENCE)  */
+/* <==============================================> */
+void Delete_KeyProtectionMethod(PS_KeyProtectionMethod x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for EncryptionUpdateRequest (SEQUENCE)  */
+/* <==================================================> */
+void Delete_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x)
+{
+    if (x->option_of_keyProtectionMethod)
+    {
+        Delete_KeyProtectionMethod(&x->keyProtectionMethod);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================> */
+/*  PER-Deleter for H223MultiplexReconfiguration (CHOICE)  */
+/* <=====================================================> */
+void Delete_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_H223ModeChange(x->h223ModeChange);
+            OSCL_DEFAULT_FREE(x->h223ModeChange);
+            break;
+        case 1:
+            Delete_H223AnnexADoubleFlag(x->h223AnnexADoubleFlag);
+            OSCL_DEFAULT_FREE(x->h223AnnexADoubleFlag);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_H223MultiplexReconfiguration: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H223AnnexADoubleFlag (CHOICE)  */
+/* <=============================================> */
+void Delete_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (start is NULL) */
+            break;
+        case 1:
+            /* (stop is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_H223AnnexADoubleFlag: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for H223ModeChange (CHOICE)  */
+/* <=======================================> */
+void Delete_H223ModeChange(PS_H223ModeChange x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (toLevel0 is NULL) */
+            break;
+        case 1:
+            /* (toLevel1 is NULL) */
+            break;
+        case 2:
+            /* (toLevel2 is NULL) */
+            break;
+        case 3:
+            /* (toLevel2withOptionalHeader is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_H223ModeChange: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Deleter for NewATMVCCommand (SEQUENCE)  */
+/* <==========================================> */
+void Delete_NewATMVCCommand(PS_NewATMVCCommand x)
+{
+    Delete_CmdAal(&x->cmdAal);
+    Delete_CmdMultiplex(&x->cmdMultiplex);
+    Delete_CmdReverseParameters(&x->cmdReverseParameters);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for CmdReverseParameters (SEQUENCE)  */
+/* <===============================================> */
+void Delete_CmdReverseParameters(PS_CmdReverseParameters x)
+{
+    Delete_Multiplex(&x->multiplex);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for Multiplex (CHOICE)  */
+/* <==================================> */
+void Delete_Multiplex(PS_Multiplex x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_Multiplex: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for CmdMultiplex (CHOICE)  */
+/* <=====================================> */
+void Delete_CmdMultiplex(PS_CmdMultiplex x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CmdMultiplex: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Deleter for CmdAal (CHOICE)  */
+/* <===============================> */
+void Delete_CmdAal(PS_CmdAal x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_CmdAal1(x->cmdAal1);
+            OSCL_DEFAULT_FREE(x->cmdAal1);
+            break;
+        case 1:
+            Delete_CmdAal5(x->cmdAal5);
+            OSCL_DEFAULT_FREE(x->cmdAal5);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CmdAal: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for CmdAal5 (SEQUENCE)  */
+/* <==================================> */
+void Delete_CmdAal5(PS_CmdAal5 x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for CmdAal1 (SEQUENCE)  */
+/* <==================================> */
+void Delete_CmdAal1(PS_CmdAal1 x)
+{
+    Delete_CmdClockRecovery(&x->cmdClockRecovery);
+    Delete_CmdErrorCorrection(&x->cmdErrorCorrection);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Deleter for CmdErrorCorrection (CHOICE)  */
+/* <===========================================> */
+void Delete_CmdErrorCorrection(PS_CmdErrorCorrection x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (nullErrorCorrection is NULL) */
+            break;
+        case 1:
+            /* (longInterleaver is NULL) */
+            break;
+        case 2:
+            /* (shortInterleaver is NULL) */
+            break;
+        case 3:
+            /* (errorCorrectionOnly is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CmdErrorCorrection: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for CmdClockRecovery (CHOICE)  */
+/* <=========================================> */
+void Delete_CmdClockRecovery(PS_CmdClockRecovery x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (nullClockRecovery is NULL) */
+            break;
+        case 1:
+            /* (srtsClockRecovery is NULL) */
+            break;
+        case 2:
+            /* (adaptiveClockRecovery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_CmdClockRecovery: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Deleter for FunctionNotUnderstood (CHOICE)  */
+/* <==============================================> */
+void Delete_FunctionNotUnderstood(PS_FunctionNotUnderstood x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_RequestMessage(x->request);
+            OSCL_DEFAULT_FREE(x->request);
+            break;
+        case 1:
+            Delete_ResponseMessage(x->response);
+            OSCL_DEFAULT_FREE(x->response);
+            break;
+        case 2:
+            Delete_CommandMessage(x->command);
+            OSCL_DEFAULT_FREE(x->command);
+            break;
+        default:
+            ErrorMessage("Delete_FunctionNotUnderstood: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for FunctionNotSupported (SEQUENCE)  */
+/* <===============================================> */
+void Delete_FunctionNotSupported(PS_FunctionNotSupported x)
+{
+    Delete_FnsCause(&x->fnsCause);
+    if (x->option_of_returnedFunction)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Deleter for FnsCause (CHOICE)  */
+/* <=================================> */
+void Delete_FnsCause(PS_FnsCause x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (syntaxError is NULL) */
+            break;
+        case 1:
+            /* (semanticError is NULL) */
+            break;
+        case 2:
+            /* (unknownFunction is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_FnsCause: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for ConferenceIndication (CHOICE)  */
+/* <=============================================> */
+void Delete_ConferenceIndication(PS_ConferenceIndication x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            Delete_TerminalLabel(x->terminalNumberAssign);
+            OSCL_DEFAULT_FREE(x->terminalNumberAssign);
+            break;
+        case 2:
+            Delete_TerminalLabel(x->terminalJoinedConference);
+            OSCL_DEFAULT_FREE(x->terminalJoinedConference);
+            break;
+        case 3:
+            Delete_TerminalLabel(x->terminalLeftConference);
+            OSCL_DEFAULT_FREE(x->terminalLeftConference);
+            break;
+        case 4:
+            /* (seenByAtLeastOneOther is NULL) */
+            break;
+        case 5:
+            /* (cancelSeenByAtLeastOneOther is NULL) */
+            break;
+        case 6:
+            /* (seenByAll is NULL) */
+            break;
+        case 7:
+            /* (cancelSeenByAll is NULL) */
+            break;
+        case 8:
+            Delete_TerminalLabel(x->terminalYouAreSeeing);
+            OSCL_DEFAULT_FREE(x->terminalYouAreSeeing);
+            break;
+        case 9:
+            /* (requestForFloor is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            break;
+        case 11:
+            Delete_TerminalLabel(x->floorRequested);
+            OSCL_DEFAULT_FREE(x->floorRequested);
+            break;
+        case 12:
+            Delete_TerminalYouAreSeeingInSubPictureNumber(x->terminalYouAreSeeingInSubPictureNumber);
+            OSCL_DEFAULT_FREE(x->terminalYouAreSeeingInSubPictureNumber);
+            break;
+        case 13:
+            Delete_VideoIndicateCompose(x->videoIndicateCompose);
+            OSCL_DEFAULT_FREE(x->videoIndicateCompose);
+            break;
+        default:
+            ErrorMessage("Delete_ConferenceIndication: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================================> */
+/*  PER-Deleter for TerminalYouAreSeeingInSubPictureNumber (SEQUENCE)  */
+/* <=================================================================> */
+void Delete_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for VideoIndicateCompose (SEQUENCE)  */
+/* <===============================================> */
+void Delete_VideoIndicateCompose(PS_VideoIndicateCompose x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Deleter for MiscellaneousIndication (SEQUENCE)  */
+/* <==================================================> */
+void Delete_MiscellaneousIndication(PS_MiscellaneousIndication x)
+{
+    Delete_MiType(&x->miType);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================> */
+/*  PER-Deleter for MiType (CHOICE)  */
+/* <===============================> */
+void Delete_MiType(PS_MiType x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (logicalChannelActive is NULL) */
+            break;
+        case 1:
+            /* (logicalChannelInactive is NULL) */
+            break;
+        case 2:
+            /* (multipointConference is NULL) */
+            break;
+        case 3:
+            /* (cancelMultipointConference is NULL) */
+            break;
+        case 4:
+            /* (multipointZeroComm is NULL) */
+            break;
+        case 5:
+            /* (cancelMultipointZeroComm is NULL) */
+            break;
+        case 6:
+            /* (multipointSecondaryStatus is NULL) */
+            break;
+        case 7:
+            /* (cancelMultipointSecondaryStatus is NULL) */
+            break;
+        case 8:
+            /* (videoIndicateReadyToActivate is NULL) */
+            break;
+        case 9:
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            Delete_VideoNotDecodedMBs(x->videoNotDecodedMBs);
+            OSCL_DEFAULT_FREE(x->videoNotDecodedMBs);
+            break;
+        case 11:
+            Delete_TransportCapability(x->transportCapability);
+            OSCL_DEFAULT_FREE(x->transportCapability);
+            break;
+        default:
+            ErrorMessage("Delete_MiType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for VideoNotDecodedMBs (SEQUENCE)  */
+/* <=============================================> */
+void Delete_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Deleter for JitterIndication (SEQUENCE)  */
+/* <===========================================> */
+void Delete_JitterIndication(PS_JitterIndication x)
+{
+    Delete_JiScope(&x->jiScope);
+    if (x->option_of_skippedFrameCount)
+    {
+    }
+    if (x->option_of_additionalDecoderBuffer)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Deleter for JiScope (CHOICE)  */
+/* <================================> */
+void Delete_JiScope(PS_JiScope x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_JiScope: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Deleter for H223SkewIndication (SEQUENCE)  */
+/* <=============================================> */
+void Delete_H223SkewIndication(PS_H223SkewIndication x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================> */
+/*  PER-Deleter for H2250MaximumSkewIndication (SEQUENCE)  */
+/* <=====================================================> */
+void Delete_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for MCLocationIndication (SEQUENCE)  */
+/* <===============================================> */
+void Delete_MCLocationIndication(PS_MCLocationIndication x)
+{
+    Delete_TransportAddress(&x->signalAddress);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Deleter for VendorIdentification (SEQUENCE)  */
+/* <===============================================> */
+void Delete_VendorIdentification(PS_VendorIdentification x)
+{
+    Delete_NonStandardIdentifier(&x->vendor);
+    if (x->option_of_productNumber)
+    {
+        OSCL_DEFAULT_FREE(x->productNumber.data);
+        x->productNumber.data = NULL;
+    }
+    if (x->option_of_versionNumber)
+    {
+        OSCL_DEFAULT_FREE(x->versionNumber.data);
+        x->versionNumber.data = NULL;
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Deleter for NewATMVCIndication (SEQUENCE)  */
+/* <=============================================> */
+void Delete_NewATMVCIndication(PS_NewATMVCIndication x)
+{
+    uint32 extension;
+
+    extension = x->option_of_indReverseParameters;
+    Delete_IndAal(&x->indAal);
+    Delete_IndMultiplex(&x->indMultiplex);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    if (x->option_of_indReverseParameters)
+    {
+        Delete_IndReverseParameters(&x->indReverseParameters);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Deleter for IndReverseParameters (SEQUENCE)  */
+/* <===============================================> */
+void Delete_IndReverseParameters(PS_IndReverseParameters x)
+{
+    Delete_IrpMultiplex(&x->irpMultiplex);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Deleter for IrpMultiplex (CHOICE)  */
+/* <=====================================> */
+void Delete_IrpMultiplex(PS_IrpMultiplex x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_IrpMultiplex: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Deleter for IndMultiplex (CHOICE)  */
+/* <=====================================> */
+void Delete_IndMultiplex(PS_IndMultiplex x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_IndMultiplex: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Deleter for IndAal (CHOICE)  */
+/* <===============================> */
+void Delete_IndAal(PS_IndAal x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_IndAal1(x->indAal1);
+            OSCL_DEFAULT_FREE(x->indAal1);
+            break;
+        case 1:
+            Delete_IndAal5(x->indAal5);
+            OSCL_DEFAULT_FREE(x->indAal5);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_IndAal: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Deleter for IndAal5 (SEQUENCE)  */
+/* <==================================> */
+void Delete_IndAal5(PS_IndAal5 x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Deleter for IndAal1 (SEQUENCE)  */
+/* <==================================> */
+void Delete_IndAal1(PS_IndAal1 x)
+{
+    Delete_IndClockRecovery(&x->indClockRecovery);
+    Delete_IndErrorCorrection(&x->indErrorCorrection);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Deleter for IndErrorCorrection (CHOICE)  */
+/* <===========================================> */
+void Delete_IndErrorCorrection(PS_IndErrorCorrection x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (nullErrorCorrection is NULL) */
+            break;
+        case 1:
+            /* (longInterleaver is NULL) */
+            break;
+        case 2:
+            /* (shortInterleaver is NULL) */
+            break;
+        case 3:
+            /* (errorCorrectionOnly is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_IndErrorCorrection: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Deleter for IndClockRecovery (CHOICE)  */
+/* <=========================================> */
+void Delete_IndClockRecovery(PS_IndClockRecovery x)
+{
+    switch (x->index)
+    {
+        case 0:
+            /* (nullClockRecovery is NULL) */
+            break;
+        case 1:
+            /* (srtsClockRecovery is NULL) */
+            break;
+        case 2:
+            /* (adaptiveClockRecovery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_IndClockRecovery: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Deleter for UserInputIndication (CHOICE)  */
+/* <============================================> */
+void Delete_UserInputIndication(PS_UserInputIndication x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            FreeCharString(x->alphanumeric);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            Delete_UserInputSupportIndication(x->userInputSupportIndication);
+            OSCL_DEFAULT_FREE(x->userInputSupportIndication);
+            break;
+        case 3:
+            Delete_Signal(x->signal);
+            OSCL_DEFAULT_FREE(x->signal);
+            break;
+        case 4:
+            Delete_SignalUpdate(x->signalUpdate);
+            OSCL_DEFAULT_FREE(x->signalUpdate);
+            break;
+        default:
+            ErrorMessage("Delete_UserInputIndication: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Deleter for SignalUpdate (SEQUENCE)  */
+/* <=======================================> */
+void Delete_SignalUpdate(PS_SignalUpdate x)
+{
+    if (x->option_of_rtp)
+    {
+        Delete_Rtp(&x->rtp);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================> */
+/*  PER-Deleter for Rtp (SEQUENCE)  */
+/* <==============================> */
+void Delete_Rtp(PS_Rtp x)
+{
+    OSCL_UNUSED_ARG(x);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Deleter for Signal (SEQUENCE)  */
+/* <=================================> */
+void Delete_Signal(PS_Signal x)
+{
+    if (x->signalType.data)
+    {
+        OSCL_DEFAULT_FREE(x->signalType.data);
+    }
+    if (x->option_of_duration)
+    {
+    }
+    if (x->option_of_signalRtp)
+    {
+        Delete_SignalRtp(&x->signalRtp);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Deleter for SignalRtp (SEQUENCE)  */
+/* <====================================> */
+void Delete_SignalRtp(PS_SignalRtp x)
+{
+    if (x->option_of_timestamp)
+    {
+    }
+    if (x->option_of_expirationTime)
+    {
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Deleter for UserInputSupportIndication (CHOICE)  */
+/* <===================================================> */
+void Delete_UserInputSupportIndication(PS_UserInputSupportIndication x)
+{
+    switch (x->index)
+    {
+        case 0:
+            Delete_NonStandardParameter(x->nonStandard);
+            OSCL_DEFAULT_FREE(x->nonStandard);
+            break;
+        case 1:
+            /* (basicString is NULL) */
+            break;
+        case 2:
+            /* (iA5String is NULL) */
+            break;
+        case 3:
+            /* (generalString is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("Delete_UserInputSupportIndication: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Deleter for FlowControlIndication (SEQUENCE)  */
+/* <================================================> */
+void Delete_FlowControlIndication(PS_FlowControlIndication x)
+{
+    Delete_FciScope(&x->fciScope);
+    Delete_FciRestriction(&x->fciRestriction);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Deleter for FciRestriction (CHOICE)  */
+/* <=======================================> */
+void Delete_FciRestriction(PS_FciRestriction x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            /* (noRestriction is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_FciRestriction: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Deleter for FciScope (CHOICE)  */
+/* <=================================> */
+void Delete_FciScope(PS_FciScope x)
+{
+    switch (x->index)
+    {
+        case 0:
+            break;
+        case 1:
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessage("Delete_FciScope: Illegal CHOICE index");
+    }
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_encoder.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_encoder.cpp
new file mode 100644
index 0000000..823f288
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/h245_encoder.cpp
@@ -0,0 +1,9155 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ============================================================(Auto)=
+// FILE: h245_encoder.c
+//
+// DESC: PER Encode routines for H.245
+// -------------------------------------------------------------------
+//  Copyright (c) 1998- 2000, PacketVideo Corporation.
+//                   All Rights Reserved.
+// ===================================================================
+
+#include "per_headers.h"
+#include "h245def.h"
+#include "h245_encoder.h"
+
+/* <=======================================================> */
+/*  PER-Encoder for MultimediaSystemControlMessage (CHOICE)  */
+/* <=======================================================> */
+void Encode_MultimediaSystemControlMessage(PS_MultimediaSystemControlMessage x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_RequestMessage(x->request, stream);
+            break;
+        case 1:
+            Encode_ResponseMessage(x->response, stream);
+            break;
+        case 2:
+            Encode_CommandMessage(x->command, stream);
+            break;
+        case 3:
+            Encode_IndicationMessage(x->indication, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MultimediaSystemControlMessage: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for RequestMessage (CHOICE)  */
+/* <=======================================> */
+void Encode_RequestMessage(PS_RequestMessage x, PS_OutStream stream)
+{
+    PutChoiceIndex(11, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_MasterSlaveDetermination(x->masterSlaveDetermination, stream);
+            break;
+        case 2:
+            Encode_TerminalCapabilitySet(x->terminalCapabilitySet, stream);
+            break;
+        case 3:
+            Encode_OpenLogicalChannel(x->openLogicalChannel, stream);
+            break;
+        case 4:
+            Encode_CloseLogicalChannel(x->closeLogicalChannel, stream);
+            break;
+        case 5:
+            Encode_RequestChannelClose(x->requestChannelClose, stream);
+            break;
+        case 6:
+            Encode_MultiplexEntrySend(x->multiplexEntrySend, stream);
+            break;
+        case 7:
+            Encode_RequestMultiplexEntry(x->requestMultiplexEntry, stream);
+            break;
+        case 8:
+            Encode_RequestMode(x->requestMode, stream);
+            break;
+        case 9:
+            Encode_RoundTripDelayRequest(x->roundTripDelayRequest, stream);
+            break;
+        case 10:
+            Encode_MaintenanceLoopRequest(x->maintenanceLoopRequest, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            PutExtensionItem(EPASS Encode_CommunicationModeRequest, (uint8*)x->communicationModeRequest, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_ConferenceRequest, (uint8*)x->conferenceRequest, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_MultilinkRequest, (uint8*)x->multilinkRequest, stream);
+            break;
+        case 14:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateRequest, (uint8*)x->logicalChannelRateRequest, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_RequestMessage: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for ResponseMessage (CHOICE)  */
+/* <========================================> */
+void Encode_ResponseMessage(PS_ResponseMessage x, PS_OutStream stream)
+{
+    PutChoiceIndex(19, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_MasterSlaveDeterminationAck(x->masterSlaveDeterminationAck, stream);
+            break;
+        case 2:
+            Encode_MasterSlaveDeterminationReject(x->masterSlaveDeterminationReject, stream);
+            break;
+        case 3:
+            Encode_TerminalCapabilitySetAck(x->terminalCapabilitySetAck, stream);
+            break;
+        case 4:
+            Encode_TerminalCapabilitySetReject(x->terminalCapabilitySetReject, stream);
+            break;
+        case 5:
+            Encode_OpenLogicalChannelAck(x->openLogicalChannelAck, stream);
+            break;
+        case 6:
+            Encode_OpenLogicalChannelReject(x->openLogicalChannelReject, stream);
+            break;
+        case 7:
+            Encode_CloseLogicalChannelAck(x->closeLogicalChannelAck, stream);
+            break;
+        case 8:
+            Encode_RequestChannelCloseAck(x->requestChannelCloseAck, stream);
+            break;
+        case 9:
+            Encode_RequestChannelCloseReject(x->requestChannelCloseReject, stream);
+            break;
+        case 10:
+            Encode_MultiplexEntrySendAck(x->multiplexEntrySendAck, stream);
+            break;
+        case 11:
+            Encode_MultiplexEntrySendReject(x->multiplexEntrySendReject, stream);
+            break;
+        case 12:
+            Encode_RequestMultiplexEntryAck(x->requestMultiplexEntryAck, stream);
+            break;
+        case 13:
+            Encode_RequestMultiplexEntryReject(x->requestMultiplexEntryReject, stream);
+            break;
+        case 14:
+            Encode_RequestModeAck(x->requestModeAck, stream);
+            break;
+        case 15:
+            Encode_RequestModeReject(x->requestModeReject, stream);
+            break;
+        case 16:
+            Encode_RoundTripDelayResponse(x->roundTripDelayResponse, stream);
+            break;
+        case 17:
+            Encode_MaintenanceLoopAck(x->maintenanceLoopAck, stream);
+            break;
+        case 18:
+            Encode_MaintenanceLoopReject(x->maintenanceLoopReject, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            PutExtensionItem(EPASS Encode_CommunicationModeResponse, (uint8*)x->communicationModeResponse, stream);
+            break;
+        case 20:
+            PutExtensionItem(EPASS Encode_ConferenceResponse, (uint8*)x->conferenceResponse, stream);
+            break;
+        case 21:
+            PutExtensionItem(EPASS Encode_MultilinkResponse, (uint8*)x->multilinkResponse, stream);
+            break;
+        case 22:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateAcknowledge, (uint8*)x->logicalChannelRateAcknowledge, stream);
+            break;
+        case 23:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateReject, (uint8*)x->logicalChannelRateReject, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ResponseMessage: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for CommandMessage (CHOICE)  */
+/* <=======================================> */
+void Encode_CommandMessage(PS_CommandMessage x, PS_OutStream stream)
+{
+    PutChoiceIndex(7, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_MaintenanceLoopOffCommand(x->maintenanceLoopOffCommand, stream);
+            break;
+        case 2:
+            Encode_SendTerminalCapabilitySet(x->sendTerminalCapabilitySet, stream);
+            break;
+        case 3:
+            Encode_EncryptionCommand(x->encryptionCommand, stream);
+            break;
+        case 4:
+            Encode_FlowControlCommand(x->flowControlCommand, stream);
+            break;
+        case 5:
+            Encode_EndSessionCommand(x->endSessionCommand, stream);
+            break;
+        case 6:
+            Encode_MiscellaneousCommand(x->miscellaneousCommand, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            PutExtensionItem(EPASS Encode_CommunicationModeCommand, (uint8*)x->communicationModeCommand, stream);
+            break;
+        case 8:
+            PutExtensionItem(EPASS Encode_ConferenceCommand, (uint8*)x->conferenceCommand, stream);
+            break;
+        case 9:
+            PutExtensionItem(EPASS Encode_H223MultiplexReconfiguration, (uint8*)x->h223MultiplexReconfiguration, stream);
+            break;
+        case 10:
+            PutExtensionItem(EPASS Encode_NewATMVCCommand, (uint8*)x->newATMVCCommand, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_CommandMessage: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for IndicationMessage (CHOICE)  */
+/* <==========================================> */
+void Encode_IndicationMessage(PS_IndicationMessage x, PS_OutStream stream)
+{
+    PutChoiceIndex(14, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_FunctionNotUnderstood(x->functionNotUnderstood, stream);
+            break;
+        case 2:
+            Encode_MasterSlaveDeterminationRelease(x->masterSlaveDeterminationRelease, stream);
+            break;
+        case 3:
+            Encode_TerminalCapabilitySetRelease(x->terminalCapabilitySetRelease, stream);
+            break;
+        case 4:
+            Encode_OpenLogicalChannelConfirm(x->openLogicalChannelConfirm, stream);
+            break;
+        case 5:
+            Encode_RequestChannelCloseRelease(x->requestChannelCloseRelease, stream);
+            break;
+        case 6:
+            Encode_MultiplexEntrySendRelease(x->multiplexEntrySendRelease, stream);
+            break;
+        case 7:
+            Encode_RequestMultiplexEntryRelease(x->requestMultiplexEntryRelease, stream);
+            break;
+        case 8:
+            Encode_RequestModeRelease(x->requestModeRelease, stream);
+            break;
+        case 9:
+            Encode_MiscellaneousIndication(x->miscellaneousIndication, stream);
+            break;
+        case 10:
+            Encode_JitterIndication(x->jitterIndication, stream);
+            break;
+        case 11:
+            Encode_H223SkewIndication(x->h223SkewIndication, stream);
+            break;
+        case 12:
+            Encode_NewATMVCIndication(x->newATMVCIndication, stream);
+            break;
+        case 13:
+            Encode_UserInputIndication(x->userInput, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            PutExtensionItem(EPASS Encode_H2250MaximumSkewIndication, (uint8*)x->h2250MaximumSkewIndication, stream);
+            break;
+        case 15:
+            PutExtensionItem(EPASS Encode_MCLocationIndication, (uint8*)x->mcLocationIndication, stream);
+            break;
+        case 16:
+            PutExtensionItem(EPASS Encode_ConferenceIndication, (uint8*)x->conferenceIndication, stream);
+            break;
+        case 17:
+            PutExtensionItem(EPASS Encode_VendorIdentification, (uint8*)x->vendorIdentification, stream);
+            break;
+        case 18:
+            PutExtensionItem(EPASS Encode_FunctionNotSupported, (uint8*)x->functionNotSupported, stream);
+            break;
+        case 19:
+            PutExtensionItem(EPASS Encode_MultilinkIndication, (uint8*)x->multilinkIndication, stream);
+            break;
+        case 20:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateRelease, (uint8*)x->logicalChannelRateRelease, stream);
+            break;
+        case 21:
+            PutExtensionItem(EPASS Encode_FlowControlIndication, (uint8*)x->flowControlIndication, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_IndicationMessage: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for GenericInformation (SEQUENCE)  */
+/* <=============================================> */
+void Encode_GenericInformation(PS_GenericInformation x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_subMessageIdentifier, stream);
+    PutBoolean(x->option_of_messageContent, stream);
+    Encode_CapabilityIdentifier(&x->messageIdentifier, stream);
+    if (x->option_of_subMessageIdentifier)
+    {
+        PutInteger(0, 127, (uint32)x->subMessageIdentifier, stream);
+    }
+    if (x->option_of_messageContent)
+    {
+        PutLengthDet(x->size_of_messageContent, stream);
+        for (i = 0;i < x->size_of_messageContent;++i)
+        {
+            Encode_GenericParameter(x->messageContent + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for NonStandardMessage (SEQUENCE)  */
+/* <=============================================> */
+void Encode_NonStandardMessage(PS_NonStandardMessage x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_NonStandardParameter(&x->nonStandardData, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for NonStandardParameter (SEQUENCE)  */
+/* <===============================================> */
+void Encode_NonStandardParameter(PS_NonStandardParameter x, PS_OutStream stream)
+{
+    Encode_NonStandardIdentifier(&x->nonStandardIdentifier, stream);
+    PutOctetString(1, 0, 0, &x->data, stream);
+}
+
+/* <==============================================> */
+/*  PER-Encoder for NonStandardIdentifier (CHOICE)  */
+/* <==============================================> */
+void Encode_NonStandardIdentifier(PS_NonStandardIdentifier x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutObjectID(x->object, stream);
+            break;
+        case 1:
+            Encode_H221NonStandard(x->h221NonStandard, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_NonStandardIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for H221NonStandard (SEQUENCE)  */
+/* <==========================================> */
+void Encode_H221NonStandard(PS_H221NonStandard x, PS_OutStream stream)
+{
+    PutInteger(0, 255, (uint32)x->t35CountryCode, stream);
+    PutInteger(0, 255, (uint32)x->t35Extension, stream);
+    PutInteger(0, 65535, (uint32)x->manufacturerCode, stream);
+}
+
+/* <===================================================> */
+/*  PER-Encoder for MasterSlaveDetermination (SEQUENCE)  */
+/* <===================================================> */
+void Encode_MasterSlaveDetermination(PS_MasterSlaveDetermination x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->terminalType, stream);
+    PutInteger(0, 16777215, (uint32)x->statusDeterminationNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Encoder for MasterSlaveDeterminationAck (SEQUENCE)  */
+/* <======================================================> */
+void Encode_MasterSlaveDeterminationAck(PS_MasterSlaveDeterminationAck x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_Decision(&x->decision, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Encoder for Decision (CHOICE)  */
+/* <=================================> */
+void Encode_Decision(PS_Decision x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (master is NULL) */
+            break;
+        case 1:
+            /* (slave is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Decision: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================================> */
+/*  PER-Encoder for MasterSlaveDeterminationReject (SEQUENCE)  */
+/* <=========================================================> */
+void Encode_MasterSlaveDeterminationReject(PS_MasterSlaveDeterminationReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_MsdRejectCause(&x->msdRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for MsdRejectCause (CHOICE)  */
+/* <=======================================> */
+void Encode_MsdRejectCause(PS_MsdRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (identicalNumbers is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MsdRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Encoder for MasterSlaveDeterminationRelease (SEQUENCE)  */
+/* <==========================================================> */
+void Encode_MasterSlaveDeterminationRelease(PS_MasterSlaveDeterminationRelease x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for TerminalCapabilitySet (SEQUENCE)  */
+/* <================================================> */
+void Encode_TerminalCapabilitySet(PS_TerminalCapabilitySet x, PS_OutStream stream)
+{
+    uint16 i;
+    PS_OutStream tempStream;
+    uint32 extension;
+
+    extension = x->option_of_genericInformation;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_multiplexCapability, stream);
+    PutBoolean(x->option_of_capabilityTable, stream);
+    PutBoolean(x->option_of_capabilityDescriptors, stream);
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutObjectID(&x->protocolIdentifier, stream);
+    if (x->option_of_multiplexCapability)
+    {
+        Encode_MultiplexCapability(&x->multiplexCapability, stream);
+    }
+    if (x->option_of_capabilityTable)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_capabilityTable, stream);
+        for (i = 0;i < x->size_of_capabilityTable;++i)
+        {
+            Encode_CapabilityTableEntry(x->capabilityTable + i, stream);
+        }
+    }
+    if (x->option_of_capabilityDescriptors)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_capabilityDescriptors, stream);
+        for (i = 0;i < x->size_of_capabilityDescriptors;++i)
+        {
+            Encode_CapabilityDescriptor(x->capabilityDescriptors + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_genericInformation, stream);
+    if (x->option_of_genericInformation)
+    {
+        tempStream = NewOutStream();  /* Write to temp stream */
+        PutLengthDet(x->size_of_genericInformation, tempStream);
+        for (i = 0;i < x->size_of_genericInformation;++i)
+        {
+            Encode_GenericInformation(x->genericInformation + i, tempStream);
+        }
+        PutTempStream(tempStream, stream); /* Copy to real stream */
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for CapabilityTableEntry (SEQUENCE)  */
+/* <===============================================> */
+void Encode_CapabilityTableEntry(PS_CapabilityTableEntry x, PS_OutStream stream)
+{
+    PutBoolean(x->option_of_capability, stream);
+    PutInteger(1, 65535, (uint32)x->capabilityTableEntryNumber, stream);
+    if (x->option_of_capability)
+    {
+        Encode_Capability(&x->capability, stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for CapabilityDescriptor (SEQUENCE)  */
+/* <===============================================> */
+void Encode_CapabilityDescriptor(PS_CapabilityDescriptor x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(x->option_of_simultaneousCapabilities, stream);
+    PutInteger(0, 255, (uint32)x->capabilityDescriptorNumber, stream);
+    if (x->option_of_simultaneousCapabilities)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_simultaneousCapabilities, stream);
+        for (i = 0;i < x->size_of_simultaneousCapabilities;++i)
+        {
+            Encode_AlternativeCapabilitySet(x->simultaneousCapabilities + i, stream);
+        }
+    }
+}
+
+/* <======================================================> */
+/*  PER-Encoder for AlternativeCapabilitySet (SEQUENCE-OF)  */
+/* <======================================================> */
+void Encode_AlternativeCapabilitySet(PS_AlternativeCapabilitySet x, PS_OutStream stream)
+{
+    uint16 i;
+    PutInteger(1, 256, (uint32)x->size, stream);
+    for (i = 0;i < x->size;++i)
+    {
+        PutInteger(1, 65535, (uint32)x->item[i], stream);
+    }
+}
+
+/* <===================================================> */
+/*  PER-Encoder for TerminalCapabilitySetAck (SEQUENCE)  */
+/* <===================================================> */
+void Encode_TerminalCapabilitySetAck(PS_TerminalCapabilitySetAck x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Encoder for TerminalCapabilitySetReject (SEQUENCE)  */
+/* <======================================================> */
+void Encode_TerminalCapabilitySetReject(PS_TerminalCapabilitySetReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    Encode_TcsRejectCause(&x->tcsRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for TcsRejectCause (CHOICE)  */
+/* <=======================================> */
+void Encode_TcsRejectCause(PS_TcsRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (undefinedTableEntryUsed is NULL) */
+            break;
+        case 2:
+            /* (descriptorCapacityExceeded is NULL) */
+            break;
+        case 3:
+            Encode_TableEntryCapacityExceeded(x->tableEntryCapacityExceeded, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_TcsRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Encoder for TableEntryCapacityExceeded (CHOICE)  */
+/* <===================================================> */
+void Encode_TableEntryCapacityExceeded(PS_TableEntryCapacityExceeded x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->highestEntryNumberProcessed, stream);
+            break;
+        case 1:
+            /* (noneProcessed is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_TableEntryCapacityExceeded: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for TerminalCapabilitySetRelease (SEQUENCE)  */
+/* <=======================================================> */
+void Encode_TerminalCapabilitySetRelease(PS_TerminalCapabilitySetRelease x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Encoder for Capability (CHOICE)  */
+/* <===================================> */
+void Encode_Capability(PS_Capability x, PS_OutStream stream)
+{
+    PutChoiceIndex(12, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_VideoCapability(x->receiveVideoCapability, stream);
+            break;
+        case 2:
+            Encode_VideoCapability(x->transmitVideoCapability, stream);
+            break;
+        case 3:
+            Encode_VideoCapability(x->receiveAndTransmitVideoCapability, stream);
+            break;
+        case 4:
+            Encode_AudioCapability(x->receiveAudioCapability, stream);
+            break;
+        case 5:
+            Encode_AudioCapability(x->transmitAudioCapability, stream);
+            break;
+        case 6:
+            Encode_AudioCapability(x->receiveAndTransmitAudioCapability, stream);
+            break;
+        case 7:
+            Encode_DataApplicationCapability(x->receiveDataApplicationCapability, stream);
+            break;
+        case 8:
+            Encode_DataApplicationCapability(x->transmitDataApplicationCapability, stream);
+            break;
+        case 9:
+            Encode_DataApplicationCapability(x->receiveAndTransmitDataApplicationCapability, stream);
+            break;
+        case 10:
+            PutBoolean(x->h233EncryptionTransmitCapability, stream);
+            break;
+        case 11:
+            Encode_H233EncryptionReceiveCapability(x->h233EncryptionReceiveCapability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 12:
+            PutExtensionItem(EPASS Encode_ConferenceCapability, (uint8*)x->conferenceCapability, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_H235SecurityCapability, (uint8*)x->h235SecurityCapability, stream);
+            break;
+        case 14:
+            PutExtensionInteger(0, 255, (uint32)x->maxPendingReplacementFor, stream);
+            break;
+        case 15:
+            PutExtensionItem(EPASS Encode_UserInputCapability, (uint8*)x->receiveUserInputCapability, stream);
+            break;
+        case 16:
+            PutExtensionItem(EPASS Encode_UserInputCapability, (uint8*)x->transmitUserInputCapability, stream);
+            break;
+        case 17:
+            PutExtensionItem(EPASS Encode_UserInputCapability, (uint8*)x->receiveAndTransmitUserInputCapability, stream);
+            break;
+        case 18:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericControlCapability, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Capability: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Encoder for H233EncryptionReceiveCapability (SEQUENCE)  */
+/* <==========================================================> */
+void Encode_H233EncryptionReceiveCapability(PS_H233EncryptionReceiveCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->h233IVResponseTime, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for H235SecurityCapability (SEQUENCE)  */
+/* <=================================================> */
+void Encode_H235SecurityCapability(PS_H235SecurityCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, stream);
+    PutInteger(1, 65535, (uint32)x->mediaCapability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for MultiplexCapability (CHOICE)  */
+/* <============================================> */
+void Encode_MultiplexCapability(PS_MultiplexCapability x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_H222Capability(x->h222Capability, stream);
+            break;
+        case 2:
+            Encode_H223Capability(x->h223Capability, stream);
+            break;
+        case 3:
+            Encode_V76Capability(x->v76Capability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            PutExtensionItem(EPASS Encode_H2250Capability, (uint8*)x->h2250Capability, stream);
+            break;
+        case 5:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericMultiplexCapability, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MultiplexCapability: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for H222Capability (SEQUENCE)  */
+/* <=========================================> */
+void Encode_H222Capability(PS_H222Capability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 256, (uint32)x->numberOfVCs, stream);
+    PutLengthDet(x->size_of_vcCapability, stream);
+    for (i = 0;i < x->size_of_vcCapability;++i)
+    {
+        Encode_VCCapability(x->vcCapability + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for VCCapability (SEQUENCE)  */
+/* <=======================================> */
+void Encode_VCCapability(PS_VCCapability x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_aal1ViaGateway;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_vccAal1, stream);
+    PutBoolean(x->option_of_vccAal5, stream);
+    if (x->option_of_vccAal1)
+    {
+        Encode_VccAal1(&x->vccAal1, stream);
+    }
+    if (x->option_of_vccAal5)
+    {
+        Encode_VccAal5(&x->vccAal5, stream);
+    }
+    PutBoolean(x->transportStream, stream);
+    PutBoolean(x->programStream, stream);
+    Encode_AvailableBitRates(&x->availableBitRates, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_aal1ViaGateway, stream);
+    if (x->option_of_aal1ViaGateway)
+    {
+        PutExtensionItem(EPASS Encode_Aal1ViaGateway, (uint8*)&x->aal1ViaGateway, stream);
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for Aal1ViaGateway (SEQUENCE)  */
+/* <=========================================> */
+void Encode_Aal1ViaGateway(PS_Aal1ViaGateway x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 256, (uint32)x->size_of_gatewayAddress, stream);
+    for (i = 0;i < x->size_of_gatewayAddress;++i)
+    {
+        Encode_Q2931Address(x->gatewayAddress + i, stream);
+    }
+    PutBoolean(x->nullClockRecovery, stream);
+    PutBoolean(x->srtsClockRecovery, stream);
+    PutBoolean(x->adaptiveClockRecovery, stream);
+    PutBoolean(x->nullErrorCorrection, stream);
+    PutBoolean(x->longInterleaver, stream);
+    PutBoolean(x->shortInterleaver, stream);
+    PutBoolean(x->errorCorrectionOnly, stream);
+    PutBoolean(x->structuredDataTransfer, stream);
+    PutBoolean(x->partiallyFilledCells, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for AvailableBitRates (SEQUENCE)  */
+/* <============================================> */
+void Encode_AvailableBitRates(PS_AvailableBitRates x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_VccAal5Type(&x->vccAal5Type, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Encoder for VccAal5Type (CHOICE)  */
+/* <====================================> */
+void Encode_VccAal5Type(PS_VccAal5Type x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->singleBitRate, stream);
+            break;
+        case 1:
+            Encode_RangeOfBitRates(x->rangeOfBitRates, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_VccAal5Type: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for RangeOfBitRates (SEQUENCE)  */
+/* <==========================================> */
+void Encode_RangeOfBitRates(PS_RangeOfBitRates x, PS_OutStream stream)
+{
+    PutInteger(1, 65535, (uint32)x->lowerBitRate, stream);
+    PutInteger(1, 65535, (uint32)x->higherBitRate, stream);
+}
+
+/* <==================================> */
+/*  PER-Encoder for VccAal5 (SEQUENCE)  */
+/* <==================================> */
+void Encode_VccAal5(PS_VccAal5 x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 65535, (uint32)x->forwardMaximumSDUSize, stream);
+    PutInteger(0, 65535, (uint32)x->backwardMaximumSDUSize, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for VccAal1 (SEQUENCE)  */
+/* <==================================> */
+void Encode_VccAal1(PS_VccAal1 x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->nullClockRecovery, stream);
+    PutBoolean(x->srtsClockRecovery, stream);
+    PutBoolean(x->adaptiveClockRecovery, stream);
+    PutBoolean(x->nullErrorCorrection, stream);
+    PutBoolean(x->longInterleaver, stream);
+    PutBoolean(x->shortInterleaver, stream);
+    PutBoolean(x->errorCorrectionOnly, stream);
+    PutBoolean(x->structuredDataTransfer, stream);
+    PutBoolean(x->partiallyFilledCells, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Encoder for H223Capability (SEQUENCE)  */
+/* <=========================================> */
+void Encode_H223Capability(PS_H223Capability x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_maxMUXPDUSizeCapability |
+                x->option_of_nsrpSupport |
+                x->option_of_mobileOperationTransmitCapability |
+                x->option_of_h223AnnexCCapability;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->transportWithI_frames, stream);
+    PutBoolean(x->videoWithAL1, stream);
+    PutBoolean(x->videoWithAL2, stream);
+    PutBoolean(x->videoWithAL3, stream);
+    PutBoolean(x->audioWithAL1, stream);
+    PutBoolean(x->audioWithAL2, stream);
+    PutBoolean(x->audioWithAL3, stream);
+    PutBoolean(x->dataWithAL1, stream);
+    PutBoolean(x->dataWithAL2, stream);
+    PutBoolean(x->dataWithAL3, stream);
+    PutInteger(0, 65535, (uint32)x->maximumAl2SDUSize, stream);
+    PutInteger(0, 65535, (uint32)x->maximumAl3SDUSize, stream);
+    PutInteger(0, 1023, (uint32)x->maximumDelayJitter, stream);
+    Encode_H223MultiplexTableCapability(&x->h223MultiplexTableCapability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(4, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_maxMUXPDUSizeCapability, stream);
+    PutBoolean(x->option_of_nsrpSupport, stream);
+    PutBoolean(x->option_of_mobileOperationTransmitCapability, stream);
+    PutBoolean(x->option_of_h223AnnexCCapability, stream);
+    if (x->option_of_maxMUXPDUSizeCapability)
+    {
+        PutExtensionBoolean(x->maxMUXPDUSizeCapability, stream);
+    }
+    if (x->option_of_nsrpSupport)
+    {
+        PutExtensionBoolean(x->nsrpSupport, stream);
+    }
+    if (x->option_of_mobileOperationTransmitCapability)
+    {
+        PutExtensionItem(EPASS Encode_MobileOperationTransmitCapability, (uint8*)&x->mobileOperationTransmitCapability, stream);
+    }
+    if (x->option_of_h223AnnexCCapability)
+    {
+        PutExtensionItem(EPASS Encode_H223AnnexCCapability, (uint8*)&x->h223AnnexCCapability, stream);
+    }
+}
+
+/* <============================================================> */
+/*  PER-Encoder for MobileOperationTransmitCapability (SEQUENCE)  */
+/* <============================================================> */
+void Encode_MobileOperationTransmitCapability(PS_MobileOperationTransmitCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->modeChangeCapability, stream);
+    PutBoolean(x->h223AnnexA, stream);
+    PutBoolean(x->h223AnnexADoubleFlag, stream);
+    PutBoolean(x->h223AnnexB, stream);
+    PutBoolean(x->h223AnnexBwithHeader, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================> */
+/*  PER-Encoder for H223MultiplexTableCapability (CHOICE)  */
+/* <=====================================================> */
+void Encode_H223MultiplexTableCapability(PS_H223MultiplexTableCapability x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (basic is NULL) */
+            break;
+        case 1:
+            Encode_Enhanced(x->enhanced, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_H223MultiplexTableCapability: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Encoder for Enhanced (SEQUENCE)  */
+/* <===================================> */
+void Encode_Enhanced(PS_Enhanced x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->maximumNestingDepth, stream);
+    PutInteger(2, 255, (uint32)x->maximumElementListSize, stream);
+    PutInteger(2, 255, (uint32)x->maximumSubElementListSize, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for H223AnnexCCapability (SEQUENCE)  */
+/* <===============================================> */
+void Encode_H223AnnexCCapability(PS_H223AnnexCCapability x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_rsCodeCapability;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->videoWithAL1M, stream);
+    PutBoolean(x->videoWithAL2M, stream);
+    PutBoolean(x->videoWithAL3M, stream);
+    PutBoolean(x->audioWithAL1M, stream);
+    PutBoolean(x->audioWithAL2M, stream);
+    PutBoolean(x->audioWithAL3M, stream);
+    PutBoolean(x->dataWithAL1M, stream);
+    PutBoolean(x->dataWithAL2M, stream);
+    PutBoolean(x->dataWithAL3M, stream);
+    PutBoolean(x->alpduInterleaving, stream);
+    PutInteger(0, 65535, (uint32)x->maximumAL1MPDUSize, stream);
+    PutInteger(0, 65535, (uint32)x->maximumAL2MSDUSize, stream);
+    PutInteger(0, 65535, (uint32)x->maximumAL3MSDUSize, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_rsCodeCapability, stream);
+    if (x->option_of_rsCodeCapability)
+    {
+        PutExtensionBoolean(x->rsCodeCapability, stream);
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for V76Capability (SEQUENCE)  */
+/* <========================================> */
+void Encode_V76Capability(PS_V76Capability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->suspendResumeCapabilitywAddress, stream);
+    PutBoolean(x->suspendResumeCapabilitywoAddress, stream);
+    PutBoolean(x->rejCapability, stream);
+    PutBoolean(x->sREJCapability, stream);
+    PutBoolean(x->mREJCapability, stream);
+    PutBoolean(x->crc8bitCapability, stream);
+    PutBoolean(x->crc16bitCapability, stream);
+    PutBoolean(x->crc32bitCapability, stream);
+    PutBoolean(x->uihCapability, stream);
+    PutInteger(2, 8191, (uint32)x->numOfDLCS, stream);
+    PutBoolean(x->twoOctetAddressFieldCapability, stream);
+    PutBoolean(x->loopBackTestCapability, stream);
+    PutInteger(1, 4095, (uint32)x->n401Capability, stream);
+    PutInteger(1, 127, (uint32)x->maxWindowSizeCapability, stream);
+    Encode_V75Capability(&x->v75Capability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for V75Capability (SEQUENCE)  */
+/* <========================================> */
+void Encode_V75Capability(PS_V75Capability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->audioHeader, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Encoder for H2250Capability (SEQUENCE)  */
+/* <==========================================> */
+void Encode_H2250Capability(PS_H2250Capability x, PS_OutStream stream)
+{
+    uint16 i;
+    PS_OutStream tempStream;
+    uint32 extension;
+
+    extension = x->option_of_transportCapability |
+                x->option_of_redundancyEncodingCapability |
+                x->option_of_logicalChannelSwitchingCapability |
+                x->option_of_t120DynamicPortCapability;
+    PutBoolean(extension, stream);
+
+    PutInteger(0, 1023, (uint32)x->maximumAudioDelayJitter, stream);
+    Encode_MultipointCapability(&x->receiveMultipointCapability, stream);
+    Encode_MultipointCapability(&x->transmitMultipointCapability, stream);
+    Encode_MultipointCapability(&x->receiveAndTransmitMultipointCapability, stream);
+    Encode_McCapability(&x->mcCapability, stream);
+    PutBoolean(x->rtcpVideoControlCapability, stream);
+    Encode_MediaPacketizationCapability(&x->mediaPacketizationCapability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(4, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_transportCapability, stream);
+    PutBoolean(x->option_of_redundancyEncodingCapability, stream);
+    PutBoolean(x->option_of_logicalChannelSwitchingCapability, stream);
+    PutBoolean(x->option_of_t120DynamicPortCapability, stream);
+    if (x->option_of_transportCapability)
+    {
+        PutExtensionItem(EPASS Encode_TransportCapability, (uint8*)&x->transportCapability, stream);
+    }
+    if (x->option_of_redundancyEncodingCapability)
+    {
+        tempStream = NewOutStream();  /* Write to temp stream */
+        PutInteger(1, 256, (uint32)x->size_of_redundancyEncodingCapability, tempStream);
+        for (i = 0;i < x->size_of_redundancyEncodingCapability;++i)
+        {
+            Encode_RedundancyEncodingCapability(x->redundancyEncodingCapability + i, tempStream);
+        }
+        PutTempStream(tempStream, stream); /* Copy to real stream */
+    }
+    if (x->option_of_logicalChannelSwitchingCapability)
+    {
+        PutExtensionBoolean(x->logicalChannelSwitchingCapability, stream);
+    }
+    if (x->option_of_t120DynamicPortCapability)
+    {
+        PutExtensionBoolean(x->t120DynamicPortCapability, stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for McCapability (SEQUENCE)  */
+/* <=======================================> */
+void Encode_McCapability(PS_McCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->centralizedConferenceMC, stream);
+    PutBoolean(x->decentralizedConferenceMC, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for MediaPacketizationCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Encode_MediaPacketizationCapability(PS_MediaPacketizationCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PS_OutStream tempStream;
+    uint32 extension;
+
+    extension = x->option_of_rtpPayloadType;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->h261aVideoPacketization, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_rtpPayloadType, stream);
+    if (x->option_of_rtpPayloadType)
+    {
+        tempStream = NewOutStream();  /* Write to temp stream */
+        PutInteger(1, 256, (uint32)x->size_of_rtpPayloadType, tempStream);
+        for (i = 0;i < x->size_of_rtpPayloadType;++i)
+        {
+            Encode_RTPPayloadType(x->rtpPayloadType + i, tempStream);
+        }
+        PutTempStream(tempStream, stream); /* Copy to real stream */
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for RSVPParameters (SEQUENCE)  */
+/* <=========================================> */
+void Encode_RSVPParameters(PS_RSVPParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_qosMode, stream);
+    PutBoolean(x->option_of_tokenRate, stream);
+    PutBoolean(x->option_of_bucketSize, stream);
+    PutBoolean(x->option_of_peakRate, stream);
+    PutBoolean(x->option_of_minPoliced, stream);
+    PutBoolean(x->option_of_maxPktSize, stream);
+    if (x->option_of_qosMode)
+    {
+        Encode_QOSMode(&x->qosMode, stream);
+    }
+    if (x->option_of_tokenRate)
+    {
+        PutInteger(1, 0xffffffff, (uint32)x->tokenRate, stream);
+    }
+    if (x->option_of_bucketSize)
+    {
+        PutInteger(1, 0xffffffff, (uint32)x->bucketSize, stream);
+    }
+    if (x->option_of_peakRate)
+    {
+        PutInteger(1, 0xffffffff, (uint32)x->peakRate, stream);
+    }
+    if (x->option_of_minPoliced)
+    {
+        PutInteger(1, 0xffffffff, (uint32)x->minPoliced, stream);
+    }
+    if (x->option_of_maxPktSize)
+    {
+        PutInteger(1, 0xffffffff, (uint32)x->maxPktSize, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Encoder for QOSMode (CHOICE)  */
+/* <================================> */
+void Encode_QOSMode(PS_QOSMode x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (guaranteedQOS is NULL) */
+            break;
+        case 1:
+            /* (controlledLoad is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_QOSMode: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for ATMParameters (SEQUENCE)  */
+/* <========================================> */
+void Encode_ATMParameters(PS_ATMParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 65535, (uint32)x->maxNTUSize, stream);
+    PutBoolean(x->atmUBR, stream);
+    PutBoolean(x->atmrtVBR, stream);
+    PutBoolean(x->atmnrtVBR, stream);
+    PutBoolean(x->atmABR, stream);
+    PutBoolean(x->atmCBR, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for QOSCapability (SEQUENCE)  */
+/* <========================================> */
+void Encode_QOSCapability(PS_QOSCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_nonStandardData, stream);
+    PutBoolean(x->option_of_rsvpParameters, stream);
+    PutBoolean(x->option_of_atmParameters, stream);
+    if (x->option_of_nonStandardData)
+    {
+        Encode_NonStandardParameter(&x->nonStandardData, stream);
+    }
+    if (x->option_of_rsvpParameters)
+    {
+        Encode_RSVPParameters(&x->rsvpParameters, stream);
+    }
+    if (x->option_of_atmParameters)
+    {
+        Encode_ATMParameters(&x->atmParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Encoder for MediaTransportType (CHOICE)  */
+/* <===========================================> */
+void Encode_MediaTransportType(PS_MediaTransportType x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (ip_UDP is NULL) */
+            break;
+        case 1:
+            /* (ip_TCP is NULL) */
+            break;
+        case 2:
+            /* (atm_AAL5_UNIDIR is NULL) */
+            break;
+        case 3:
+            /* (atm_AAL5_BIDIR is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            PutExtensionItem(EPASS Encode_Atm_AAL5_compressed, (uint8*)x->atm_AAL5_compressed, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MediaTransportType: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Encoder for Atm_AAL5_compressed (SEQUENCE)  */
+/* <==============================================> */
+void Encode_Atm_AAL5_compressed(PS_Atm_AAL5_compressed x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->variable_delta, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for MediaChannelCapability (SEQUENCE)  */
+/* <=================================================> */
+void Encode_MediaChannelCapability(PS_MediaChannelCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_mediaTransport, stream);
+    if (x->option_of_mediaTransport)
+    {
+        Encode_MediaTransportType(&x->mediaTransport, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for TransportCapability (SEQUENCE)  */
+/* <==============================================> */
+void Encode_TransportCapability(PS_TransportCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_nonStandard, stream);
+    PutBoolean(x->option_of_qOSCapabilities, stream);
+    PutBoolean(x->option_of_mediaChannelCapabilities, stream);
+    if (x->option_of_nonStandard)
+    {
+        Encode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    if (x->option_of_qOSCapabilities)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_qOSCapabilities, stream);
+        for (i = 0;i < x->size_of_qOSCapabilities;++i)
+        {
+            Encode_QOSCapability(x->qOSCapabilities + i, stream);
+        }
+    }
+    if (x->option_of_mediaChannelCapabilities)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_mediaChannelCapabilities, stream);
+        for (i = 0;i < x->size_of_mediaChannelCapabilities;++i)
+        {
+            Encode_MediaChannelCapability(x->mediaChannelCapabilities + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for RedundancyEncodingCapability (SEQUENCE)  */
+/* <=======================================================> */
+void Encode_RedundancyEncodingCapability(PS_RedundancyEncodingCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_secondaryEncoding, stream);
+    Encode_RedundancyEncodingMethod(&x->redundancyEncodingMethod, stream);
+    PutInteger(1, 65535, (uint32)x->primaryEncoding, stream);
+    if (x->option_of_secondaryEncoding)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_secondaryEncoding, stream);
+        for (i = 0;i < x->size_of_secondaryEncoding;++i)
+        {
+            PutInteger(1, 65535, (uint32)x->secondaryEncoding[i], stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for RedundancyEncodingMethod (CHOICE)  */
+/* <=================================================> */
+void Encode_RedundancyEncodingMethod(PS_RedundancyEncodingMethod x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (rtpAudioRedundancyEncoding is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            PutExtensionItem(EPASS Encode_RTPH263VideoRedundancyEncoding, (uint8*)x->rtpH263VideoRedundancyEncoding, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_RedundancyEncodingMethod: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================================> */
+/*  PER-Encoder for RTPH263VideoRedundancyEncoding (SEQUENCE)  */
+/* <=========================================================> */
+void Encode_RTPH263VideoRedundancyEncoding(PS_RTPH263VideoRedundancyEncoding x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_containedThreads, stream);
+    PutInteger(1, 16, (uint32)x->numberOfThreads, stream);
+    PutInteger(1, 256, (uint32)x->framesBetweenSyncPoints, stream);
+    Encode_FrameToThreadMapping(&x->frameToThreadMapping, stream);
+    if (x->option_of_containedThreads)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_containedThreads, stream);
+        for (i = 0;i < x->size_of_containedThreads;++i)
+        {
+            PutInteger(0, 15, (uint32)x->containedThreads[i], stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for FrameToThreadMapping (CHOICE)  */
+/* <=============================================> */
+void Encode_FrameToThreadMapping(PS_FrameToThreadMapping x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (roundrobin is NULL) */
+            break;
+        case 1:
+            PutInteger(1, 256, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_RTPH263VideoRedundancyFrameMapping(x->custom + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_FrameToThreadMapping: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================================> */
+/*  PER-Encoder for RTPH263VideoRedundancyFrameMapping (SEQUENCE)  */
+/* <=============================================================> */
+void Encode_RTPH263VideoRedundancyFrameMapping(PS_RTPH263VideoRedundancyFrameMapping x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 15, (uint32)x->threadNumber, stream);
+    PutInteger(1, 256, (uint32)x->size_of_frameSequence, stream);
+    for (i = 0;i < x->size_of_frameSequence;++i)
+    {
+        PutInteger(0, 255, (uint32)x->frameSequence[i], stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for MultipointCapability (SEQUENCE)  */
+/* <===============================================> */
+void Encode_MultipointCapability(PS_MultipointCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->multicastCapability, stream);
+    PutBoolean(x->multiUniCastConference, stream);
+    PutLengthDet(x->size_of_mediaDistributionCapability, stream);
+    for (i = 0;i < x->size_of_mediaDistributionCapability;++i)
+    {
+        Encode_MediaDistributionCapability(x->mediaDistributionCapability + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Encoder for MediaDistributionCapability (SEQUENCE)  */
+/* <======================================================> */
+void Encode_MediaDistributionCapability(PS_MediaDistributionCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_centralizedData, stream);
+    PutBoolean(x->option_of_distributedData, stream);
+    PutBoolean(x->centralizedControl, stream);
+    PutBoolean(x->distributedControl, stream);
+    PutBoolean(x->centralizedAudio, stream);
+    PutBoolean(x->distributedAudio, stream);
+    PutBoolean(x->centralizedVideo, stream);
+    PutBoolean(x->distributedVideo, stream);
+    if (x->option_of_centralizedData)
+    {
+        PutLengthDet(x->size_of_centralizedData, stream);
+        for (i = 0;i < x->size_of_centralizedData;++i)
+        {
+            Encode_DataApplicationCapability(x->centralizedData + i, stream);
+        }
+    }
+    if (x->option_of_distributedData)
+    {
+        PutLengthDet(x->size_of_distributedData, stream);
+        for (i = 0;i < x->size_of_distributedData;++i)
+        {
+            Encode_DataApplicationCapability(x->distributedData + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for VideoCapability (CHOICE)  */
+/* <========================================> */
+void Encode_VideoCapability(PS_VideoCapability x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_H261VideoCapability(x->h261VideoCapability, stream);
+            break;
+        case 2:
+            Encode_H262VideoCapability(x->h262VideoCapability, stream);
+            break;
+        case 3:
+            Encode_H263VideoCapability(x->h263VideoCapability, stream);
+            break;
+        case 4:
+            Encode_IS11172VideoCapability(x->is11172VideoCapability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericVideoCapability, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_VideoCapability: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Encoder for H261VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Encode_H261VideoCapability(PS_H261VideoCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_qcifMPI, stream);
+    PutBoolean(x->option_of_cifMPI, stream);
+    if (x->option_of_qcifMPI)
+    {
+        PutInteger(1, 4, (uint32)x->qcifMPI, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        PutInteger(1, 4, (uint32)x->cifMPI, stream);
+    }
+    PutBoolean(x->temporalSpatialTradeOffCapability, stream);
+    PutInteger(1, 19200, (uint32)x->maxBitRate, stream);
+    PutBoolean(x->stillImageTransmission, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for H262VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Encode_H262VideoCapability(PS_H262VideoCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_videoBitRate, stream);
+    PutBoolean(x->option_of_vbvBufferSize, stream);
+    PutBoolean(x->option_of_samplesPerLine, stream);
+    PutBoolean(x->option_of_linesPerFrame, stream);
+    PutBoolean(x->option_of_framesPerSecond, stream);
+    PutBoolean(x->option_of_luminanceSampleRate, stream);
+    PutBoolean(x->profileAndLevel_SPatML, stream);
+    PutBoolean(x->profileAndLevel_MPatLL, stream);
+    PutBoolean(x->profileAndLevel_MPatML, stream);
+    PutBoolean(x->profileAndLevel_MPatH_14, stream);
+    PutBoolean(x->profileAndLevel_MPatHL, stream);
+    PutBoolean(x->profileAndLevel_SNRatLL, stream);
+    PutBoolean(x->profileAndLevel_SNRatML, stream);
+    PutBoolean(x->profileAndLevel_SpatialatH_14, stream);
+    PutBoolean(x->profileAndLevel_HPatML, stream);
+    PutBoolean(x->profileAndLevel_HPatH_14, stream);
+    PutBoolean(x->profileAndLevel_HPatHL, stream);
+    if (x->option_of_videoBitRate)
+    {
+        PutInteger(0, 1073741823, (uint32)x->videoBitRate, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        PutInteger(0, 262143, (uint32)x->vbvBufferSize, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        PutInteger(0, 16383, (uint32)x->samplesPerLine, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        PutInteger(0, 16383, (uint32)x->linesPerFrame, stream);
+    }
+    if (x->option_of_framesPerSecond)
+    {
+        PutInteger(0, 15, (uint32)x->framesPerSecond, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->luminanceSampleRate, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for H263VideoCapability (SEQUENCE)  */
+/* <==============================================> */
+void Encode_H263VideoCapability(PS_H263VideoCapability x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_slowSqcifMPI |
+                x->option_of_slowQcifMPI |
+                x->option_of_slowCifMPI |
+                x->option_of_slowCif4MPI |
+                x->option_of_slowCif16MPI |
+                x->option_of_errorCompensation |
+                x->option_of_enhancementLayerInfo |
+                x->option_of_h263Options;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_sqcifMPI, stream);
+    PutBoolean(x->option_of_qcifMPI, stream);
+    PutBoolean(x->option_of_cifMPI, stream);
+    PutBoolean(x->option_of_cif4MPI, stream);
+    PutBoolean(x->option_of_cif16MPI, stream);
+    PutBoolean(x->option_of_hrd_B, stream);
+    PutBoolean(x->option_of_bppMaxKb, stream);
+    if (x->option_of_sqcifMPI)
+    {
+        PutInteger(1, 32, (uint32)x->sqcifMPI, stream);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        PutInteger(1, 32, (uint32)x->qcifMPI, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        PutInteger(1, 32, (uint32)x->cifMPI, stream);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        PutInteger(1, 32, (uint32)x->cif4MPI, stream);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        PutInteger(1, 32, (uint32)x->cif16MPI, stream);
+    }
+    PutInteger(1, 192400, (uint32)x->maxBitRate, stream);
+    PutBoolean(x->unrestrictedVector, stream);
+    PutBoolean(x->arithmeticCoding, stream);
+    PutBoolean(x->advancedPrediction, stream);
+    PutBoolean(x->pbFrames, stream);
+    PutBoolean(x->temporalSpatialTradeOffCapability, stream);
+    if (x->option_of_hrd_B)
+    {
+        PutInteger(0, 524287, (uint32)x->hrd_B, stream);
+    }
+    if (x->option_of_bppMaxKb)
+    {
+        PutInteger(0, 65535, (uint32)x->bppMaxKb, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(8, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_slowSqcifMPI, stream);
+    PutBoolean(x->option_of_slowQcifMPI, stream);
+    PutBoolean(x->option_of_slowCifMPI, stream);
+    PutBoolean(x->option_of_slowCif4MPI, stream);
+    PutBoolean(x->option_of_slowCif16MPI, stream);
+    PutBoolean(x->option_of_errorCompensation, stream);
+    PutBoolean(x->option_of_enhancementLayerInfo, stream);
+    PutBoolean(x->option_of_h263Options, stream);
+    if (x->option_of_slowSqcifMPI)
+    {
+        PutExtensionInteger(1, 3600, (uint32)x->slowSqcifMPI, stream);
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+        PutExtensionInteger(1, 3600, (uint32)x->slowQcifMPI, stream);
+    }
+    if (x->option_of_slowCifMPI)
+    {
+        PutExtensionInteger(1, 3600, (uint32)x->slowCifMPI, stream);
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+        PutExtensionInteger(1, 3600, (uint32)x->slowCif4MPI, stream);
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+        PutExtensionInteger(1, 3600, (uint32)x->slowCif16MPI, stream);
+    }
+    if (x->option_of_errorCompensation)
+    {
+        PutExtensionBoolean(x->errorCompensation, stream);
+    }
+    if (x->option_of_enhancementLayerInfo)
+    {
+        PutExtensionItem(EPASS Encode_EnhancementLayerInfo, (uint8*)&x->enhancementLayerInfo, stream);
+    }
+    if (x->option_of_h263Options)
+    {
+        PutExtensionItem(EPASS Encode_H263Options, (uint8*)&x->h263Options, stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for EnhancementLayerInfo (SEQUENCE)  */
+/* <===============================================> */
+void Encode_EnhancementLayerInfo(PS_EnhancementLayerInfo x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_snrEnhancement, stream);
+    PutBoolean(x->option_of_spatialEnhancement, stream);
+    PutBoolean(x->option_of_bPictureEnhancement, stream);
+    PutBoolean(x->baseBitRateConstrained, stream);
+    if (x->option_of_snrEnhancement)
+    {
+        PutInteger(1, 14, (uint32)x->size_of_snrEnhancement, stream);
+        for (i = 0;i < x->size_of_snrEnhancement;++i)
+        {
+            Encode_EnhancementOptions(x->snrEnhancement + i, stream);
+        }
+    }
+    if (x->option_of_spatialEnhancement)
+    {
+        PutInteger(1, 14, (uint32)x->size_of_spatialEnhancement, stream);
+        for (i = 0;i < x->size_of_spatialEnhancement;++i)
+        {
+            Encode_EnhancementOptions(x->spatialEnhancement + i, stream);
+        }
+    }
+    if (x->option_of_bPictureEnhancement)
+    {
+        PutInteger(1, 14, (uint32)x->size_of_bPictureEnhancement, stream);
+        for (i = 0;i < x->size_of_bPictureEnhancement;++i)
+        {
+            Encode_BEnhancementParameters(x->bPictureEnhancement + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for BEnhancementParameters (SEQUENCE)  */
+/* <=================================================> */
+void Encode_BEnhancementParameters(PS_BEnhancementParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_EnhancementOptions(&x->enhancementOptions, stream);
+    PutInteger(1, 64, (uint32)x->numberOfBPictures, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for EnhancementOptions (SEQUENCE)  */
+/* <=============================================> */
+void Encode_EnhancementOptions(PS_EnhancementOptions x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_sqcifMPI, stream);
+    PutBoolean(x->option_of_qcifMPI, stream);
+    PutBoolean(x->option_of_cifMPI, stream);
+    PutBoolean(x->option_of_cif4MPI, stream);
+    PutBoolean(x->option_of_cif16MPI, stream);
+    PutBoolean(x->option_of_slowSqcifMPI, stream);
+    PutBoolean(x->option_of_slowQcifMPI, stream);
+    PutBoolean(x->option_of_slowCifMPI, stream);
+    PutBoolean(x->option_of_slowCif4MPI, stream);
+    PutBoolean(x->option_of_slowCif16MPI, stream);
+    PutBoolean(x->option_of_h263Options, stream);
+    if (x->option_of_sqcifMPI)
+    {
+        PutInteger(1, 32, (uint32)x->sqcifMPI, stream);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        PutInteger(1, 32, (uint32)x->qcifMPI, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        PutInteger(1, 32, (uint32)x->cifMPI, stream);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        PutInteger(1, 32, (uint32)x->cif4MPI, stream);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        PutInteger(1, 32, (uint32)x->cif16MPI, stream);
+    }
+    PutInteger(1, 192400, (uint32)x->maxBitRate, stream);
+    PutBoolean(x->unrestrictedVector, stream);
+    PutBoolean(x->arithmeticCoding, stream);
+    PutBoolean(x->temporalSpatialTradeOffCapability, stream);
+    if (x->option_of_slowSqcifMPI)
+    {
+        PutInteger(1, 3600, (uint32)x->slowSqcifMPI, stream);
+    }
+    if (x->option_of_slowQcifMPI)
+    {
+        PutInteger(1, 3600, (uint32)x->slowQcifMPI, stream);
+    }
+    if (x->option_of_slowCifMPI)
+    {
+        PutInteger(1, 3600, (uint32)x->slowCifMPI, stream);
+    }
+    if (x->option_of_slowCif4MPI)
+    {
+        PutInteger(1, 3600, (uint32)x->slowCif4MPI, stream);
+    }
+    if (x->option_of_slowCif16MPI)
+    {
+        PutInteger(1, 3600, (uint32)x->slowCif16MPI, stream);
+    }
+    PutBoolean(x->errorCompensation, stream);
+    if (x->option_of_h263Options)
+    {
+        Encode_H263Options(&x->h263Options, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for H263Options (SEQUENCE)  */
+/* <======================================> */
+void Encode_H263Options(PS_H263Options x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_transparencyParameters, stream);
+    PutBoolean(x->option_of_refPictureSelection, stream);
+    PutBoolean(x->option_of_customPictureClockFrequency, stream);
+    PutBoolean(x->option_of_customPictureFormat, stream);
+    PutBoolean(x->option_of_modeCombos, stream);
+    PutBoolean(x->advancedIntraCodingMode, stream);
+    PutBoolean(x->deblockingFilterMode, stream);
+    PutBoolean(x->improvedPBFramesMode, stream);
+    PutBoolean(x->unlimitedMotionVectors, stream);
+    PutBoolean(x->fullPictureFreeze, stream);
+    PutBoolean(x->partialPictureFreezeAndRelease, stream);
+    PutBoolean(x->resizingPartPicFreezeAndRelease, stream);
+    PutBoolean(x->fullPictureSnapshot, stream);
+    PutBoolean(x->partialPictureSnapshot, stream);
+    PutBoolean(x->videoSegmentTagging, stream);
+    PutBoolean(x->progressiveRefinement, stream);
+    PutBoolean(x->dynamicPictureResizingByFour, stream);
+    PutBoolean(x->dynamicPictureResizingSixteenthPel, stream);
+    PutBoolean(x->dynamicWarpingHalfPel, stream);
+    PutBoolean(x->dynamicWarpingSixteenthPel, stream);
+    PutBoolean(x->independentSegmentDecoding, stream);
+    PutBoolean(x->slicesInOrder_NonRect, stream);
+    PutBoolean(x->slicesInOrder_Rect, stream);
+    PutBoolean(x->slicesNoOrder_NonRect, stream);
+    PutBoolean(x->slicesNoOrder_Rect, stream);
+    PutBoolean(x->alternateInterVLCMode, stream);
+    PutBoolean(x->modifiedQuantizationMode, stream);
+    PutBoolean(x->reducedResolutionUpdate, stream);
+    if (x->option_of_transparencyParameters)
+    {
+        Encode_TransparencyParameters(&x->transparencyParameters, stream);
+    }
+    PutBoolean(x->separateVideoBackChannel, stream);
+    if (x->option_of_refPictureSelection)
+    {
+        Encode_RefPictureSelection(&x->refPictureSelection, stream);
+    }
+    if (x->option_of_customPictureClockFrequency)
+    {
+        PutInteger(1, 16, (uint32)x->size_of_customPictureClockFrequency, stream);
+        for (i = 0;i < x->size_of_customPictureClockFrequency;++i)
+        {
+            Encode_CustomPictureClockFrequency(x->customPictureClockFrequency + i, stream);
+        }
+    }
+    if (x->option_of_customPictureFormat)
+    {
+        PutInteger(1, 16, (uint32)x->size_of_customPictureFormat, stream);
+        for (i = 0;i < x->size_of_customPictureFormat;++i)
+        {
+            Encode_CustomPictureFormat(x->customPictureFormat + i, stream);
+        }
+    }
+    if (x->option_of_modeCombos)
+    {
+        PutInteger(1, 16, (uint32)x->size_of_modeCombos, stream);
+        for (i = 0;i < x->size_of_modeCombos;++i)
+        {
+            Encode_H263VideoModeCombos(x->modeCombos + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for TransparencyParameters (SEQUENCE)  */
+/* <=================================================> */
+void Encode_TransparencyParameters(PS_TransparencyParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 256, (uint32)x->presentationOrder, stream);
+    PutSignedInteger(-262144, 262143, (int32)x->offset_x, stream);
+    PutSignedInteger(-262144, 262143, (int32)x->offset_y, stream);
+    PutInteger(1, 255, (uint32)x->scale_x, stream);
+    PutInteger(1, 255, (uint32)x->scale_y, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for RefPictureSelection (SEQUENCE)  */
+/* <==============================================> */
+void Encode_RefPictureSelection(PS_RefPictureSelection x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_additionalPictureMemory, stream);
+    if (x->option_of_additionalPictureMemory)
+    {
+        Encode_AdditionalPictureMemory(&x->additionalPictureMemory, stream);
+    }
+    PutBoolean(x->videoMux, stream);
+    Encode_VideoBackChannelSend(&x->videoBackChannelSend, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for VideoBackChannelSend (CHOICE)  */
+/* <=============================================> */
+void Encode_VideoBackChannelSend(PS_VideoBackChannelSend x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (none is NULL) */
+            break;
+        case 1:
+            /* (ackMessageOnly is NULL) */
+            break;
+        case 2:
+            /* (nackMessageOnly is NULL) */
+            break;
+        case 3:
+            /* (ackOrNackMessageOnly is NULL) */
+            break;
+        case 4:
+            /* (ackAndNackMessage is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_VideoBackChannelSend: Illegal CHOICE index");
+    }
+}
+
+/* <==================================================> */
+/*  PER-Encoder for AdditionalPictureMemory (SEQUENCE)  */
+/* <==================================================> */
+void Encode_AdditionalPictureMemory(PS_AdditionalPictureMemory x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_sqcifAdditionalPictureMemory, stream);
+    PutBoolean(x->option_of_qcifAdditionalPictureMemory, stream);
+    PutBoolean(x->option_of_cifAdditionalPictureMemory, stream);
+    PutBoolean(x->option_of_cif4AdditionalPictureMemory, stream);
+    PutBoolean(x->option_of_cif16AdditionalPictureMemory, stream);
+    PutBoolean(x->option_of_bigCpfAdditionalPictureMemory, stream);
+    if (x->option_of_sqcifAdditionalPictureMemory)
+    {
+        PutInteger(1, 256, (uint32)x->sqcifAdditionalPictureMemory, stream);
+    }
+    if (x->option_of_qcifAdditionalPictureMemory)
+    {
+        PutInteger(1, 256, (uint32)x->qcifAdditionalPictureMemory, stream);
+    }
+    if (x->option_of_cifAdditionalPictureMemory)
+    {
+        PutInteger(1, 256, (uint32)x->cifAdditionalPictureMemory, stream);
+    }
+    if (x->option_of_cif4AdditionalPictureMemory)
+    {
+        PutInteger(1, 256, (uint32)x->cif4AdditionalPictureMemory, stream);
+    }
+    if (x->option_of_cif16AdditionalPictureMemory)
+    {
+        PutInteger(1, 256, (uint32)x->cif16AdditionalPictureMemory, stream);
+    }
+    if (x->option_of_bigCpfAdditionalPictureMemory)
+    {
+        PutInteger(1, 256, (uint32)x->bigCpfAdditionalPictureMemory, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Encoder for CustomPictureClockFrequency (SEQUENCE)  */
+/* <======================================================> */
+void Encode_CustomPictureClockFrequency(PS_CustomPictureClockFrequency x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_sqcifMPI, stream);
+    PutBoolean(x->option_of_qcifMPI, stream);
+    PutBoolean(x->option_of_cifMPI, stream);
+    PutBoolean(x->option_of_cif4MPI, stream);
+    PutBoolean(x->option_of_cif16MPI, stream);
+    PutInteger(1000, 1001, (uint32)x->clockConversionCode, stream);
+    PutInteger(1, 127, (uint32)x->clockDivisor, stream);
+    if (x->option_of_sqcifMPI)
+    {
+        PutInteger(1, 2048, (uint32)x->sqcifMPI, stream);
+    }
+    if (x->option_of_qcifMPI)
+    {
+        PutInteger(1, 2048, (uint32)x->qcifMPI, stream);
+    }
+    if (x->option_of_cifMPI)
+    {
+        PutInteger(1, 2048, (uint32)x->cifMPI, stream);
+    }
+    if (x->option_of_cif4MPI)
+    {
+        PutInteger(1, 2048, (uint32)x->cif4MPI, stream);
+    }
+    if (x->option_of_cif16MPI)
+    {
+        PutInteger(1, 2048, (uint32)x->cif16MPI, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for CustomPictureFormat (SEQUENCE)  */
+/* <==============================================> */
+void Encode_CustomPictureFormat(PS_CustomPictureFormat x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 2048, (uint32)x->maxCustomPictureWidth, stream);
+    PutInteger(1, 2048, (uint32)x->maxCustomPictureHeight, stream);
+    PutInteger(1, 2048, (uint32)x->minCustomPictureWidth, stream);
+    PutInteger(1, 2048, (uint32)x->minCustomPictureHeight, stream);
+    Encode_MPI(&x->mPI, stream);
+    Encode_PixelAspectInformation(&x->pixelAspectInformation, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for PixelAspectInformation (CHOICE)  */
+/* <===============================================> */
+void Encode_PixelAspectInformation(PS_PixelAspectInformation x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutBoolean(x->anyPixelAspectRatio, stream);
+            break;
+        case 1:
+            PutInteger(1, 14, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                PutInteger(1, 14, (uint32)x->pixelAspectCode[i], stream);
+            }
+            break;
+        case 2:
+            PutInteger(1, 256, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_ExtendedPARItem(x->extendedPAR + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_PixelAspectInformation: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for ExtendedPARItem (SEQUENCE)  */
+/* <==========================================> */
+void Encode_ExtendedPARItem(PS_ExtendedPARItem x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 255, (uint32)x->width, stream);
+    PutInteger(1, 255, (uint32)x->height, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================> */
+/*  PER-Encoder for MPI (SEQUENCE)  */
+/* <==============================> */
+void Encode_MPI(PS_MPI x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_standardMPI, stream);
+    PutBoolean(x->option_of_customPCF, stream);
+    if (x->option_of_standardMPI)
+    {
+        PutInteger(1, 31, (uint32)x->standardMPI, stream);
+    }
+    if (x->option_of_customPCF)
+    {
+        PutInteger(1, 16, (uint32)x->size_of_customPCF, stream);
+        for (i = 0;i < x->size_of_customPCF;++i)
+        {
+            Encode_CustomPCFItem(x->customPCF + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for CustomPCFItem (SEQUENCE)  */
+/* <========================================> */
+void Encode_CustomPCFItem(PS_CustomPCFItem x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1000, 1001, (uint32)x->clockConversionCode, stream);
+    PutInteger(1, 127, (uint32)x->clockDivisor, stream);
+    PutInteger(1, 2048, (uint32)x->customMPI, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for H263VideoModeCombos (SEQUENCE)  */
+/* <==============================================> */
+void Encode_H263VideoModeCombos(PS_H263VideoModeCombos x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_H263ModeComboFlags(&x->h263VideoUncoupledModes, stream);
+    PutInteger(1, 16, (uint32)x->size_of_h263VideoCoupledModes, stream);
+    for (i = 0;i < x->size_of_h263VideoCoupledModes;++i)
+    {
+        Encode_H263ModeComboFlags(x->h263VideoCoupledModes + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H263ModeComboFlags (SEQUENCE)  */
+/* <=============================================> */
+void Encode_H263ModeComboFlags(PS_H263ModeComboFlags x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->unrestrictedVector, stream);
+    PutBoolean(x->arithmeticCoding, stream);
+    PutBoolean(x->advancedPrediction, stream);
+    PutBoolean(x->pbFrames, stream);
+    PutBoolean(x->advancedIntraCodingMode, stream);
+    PutBoolean(x->deblockingFilterMode, stream);
+    PutBoolean(x->unlimitedMotionVectors, stream);
+    PutBoolean(x->slicesInOrder_NonRect, stream);
+    PutBoolean(x->slicesInOrder_Rect, stream);
+    PutBoolean(x->slicesNoOrder_NonRect, stream);
+    PutBoolean(x->slicesNoOrder_Rect, stream);
+    PutBoolean(x->improvedPBFramesMode, stream);
+    PutBoolean(x->referencePicSelect, stream);
+    PutBoolean(x->dynamicPictureResizingByFour, stream);
+    PutBoolean(x->dynamicPictureResizingSixteenthPel, stream);
+    PutBoolean(x->dynamicWarpingHalfPel, stream);
+    PutBoolean(x->dynamicWarpingSixteenthPel, stream);
+    PutBoolean(x->reducedResolutionUpdate, stream);
+    PutBoolean(x->independentSegmentDecoding, stream);
+    PutBoolean(x->alternateInterVLCMode, stream);
+    PutBoolean(x->modifiedQuantizationMode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for IS11172VideoCapability (SEQUENCE)  */
+/* <=================================================> */
+void Encode_IS11172VideoCapability(PS_IS11172VideoCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_videoBitRate, stream);
+    PutBoolean(x->option_of_vbvBufferSize, stream);
+    PutBoolean(x->option_of_samplesPerLine, stream);
+    PutBoolean(x->option_of_linesPerFrame, stream);
+    PutBoolean(x->option_of_pictureRate, stream);
+    PutBoolean(x->option_of_luminanceSampleRate, stream);
+    PutBoolean(x->constrainedBitstream, stream);
+    if (x->option_of_videoBitRate)
+    {
+        PutInteger(0, 1073741823, (uint32)x->videoBitRate, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        PutInteger(0, 262143, (uint32)x->vbvBufferSize, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        PutInteger(0, 16383, (uint32)x->samplesPerLine, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        PutInteger(0, 16383, (uint32)x->linesPerFrame, stream);
+    }
+    if (x->option_of_pictureRate)
+    {
+        PutInteger(0, 15, (uint32)x->pictureRate, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->luminanceSampleRate, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for AudioCapability (CHOICE)  */
+/* <========================================> */
+void Encode_AudioCapability(PS_AudioCapability x, PS_OutStream stream)
+{
+    PutChoiceIndex(14, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            PutInteger(1, 256, (uint32)x->g711Alaw64k, stream);
+            break;
+        case 2:
+            PutInteger(1, 256, (uint32)x->g711Alaw56k, stream);
+            break;
+        case 3:
+            PutInteger(1, 256, (uint32)x->g711Ulaw64k, stream);
+            break;
+        case 4:
+            PutInteger(1, 256, (uint32)x->g711Ulaw56k, stream);
+            break;
+        case 5:
+            PutInteger(1, 256, (uint32)x->g722_64k, stream);
+            break;
+        case 6:
+            PutInteger(1, 256, (uint32)x->g722_56k, stream);
+            break;
+        case 7:
+            PutInteger(1, 256, (uint32)x->g722_48k, stream);
+            break;
+        case 8:
+            Encode_G7231(x->g7231, stream);
+            break;
+        case 9:
+            PutInteger(1, 256, (uint32)x->g728, stream);
+            break;
+        case 10:
+            PutInteger(1, 256, (uint32)x->g729, stream);
+            break;
+        case 11:
+            PutInteger(1, 256, (uint32)x->g729AnnexA, stream);
+            break;
+        case 12:
+            Encode_IS11172AudioCapability(x->is11172AudioCapability, stream);
+            break;
+        case 13:
+            Encode_IS13818AudioCapability(x->is13818AudioCapability, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            PutExtensionInteger(1, 256, (uint32)x->g729wAnnexB, stream);
+            break;
+        case 15:
+            PutExtensionInteger(1, 256, (uint32)x->g729AnnexAwAnnexB, stream);
+            break;
+        case 16:
+            PutExtensionItem(EPASS Encode_G7231AnnexCCapability, (uint8*)x->g7231AnnexCCapability, stream);
+            break;
+        case 17:
+            PutExtensionItem(EPASS Encode_GSMAudioCapability, (uint8*)x->gsmFullRate, stream);
+            break;
+        case 18:
+            PutExtensionItem(EPASS Encode_GSMAudioCapability, (uint8*)x->gsmHalfRate, stream);
+            break;
+        case 19:
+            PutExtensionItem(EPASS Encode_GSMAudioCapability, (uint8*)x->gsmEnhancedFullRate, stream);
+            break;
+        case 20:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericAudioCapability, stream);
+            break;
+        case 21:
+            PutExtensionItem(EPASS Encode_G729Extensions, (uint8*)x->g729Extensions, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_AudioCapability: Illegal CHOICE index");
+    }
+}
+
+/* <================================> */
+/*  PER-Encoder for G7231 (SEQUENCE)  */
+/* <================================> */
+void Encode_G7231(PS_G7231 x, PS_OutStream stream)
+{
+    PutInteger(1, 256, (uint32)x->maxAl_sduAudioFrames, stream);
+    PutBoolean(x->silenceSuppression, stream);
+}
+
+/* <=========================================> */
+/*  PER-Encoder for G729Extensions (SEQUENCE)  */
+/* <=========================================> */
+void Encode_G729Extensions(PS_G729Extensions x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_audioUnit, stream);
+    if (x->option_of_audioUnit)
+    {
+        PutInteger(1, 256, (uint32)x->audioUnit, stream);
+    }
+    PutBoolean(x->annexA, stream);
+    PutBoolean(x->annexB, stream);
+    PutBoolean(x->annexD, stream);
+    PutBoolean(x->annexE, stream);
+    PutBoolean(x->annexF, stream);
+    PutBoolean(x->annexG, stream);
+    PutBoolean(x->annexH, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for G7231AnnexCCapability (SEQUENCE)  */
+/* <================================================> */
+void Encode_G7231AnnexCCapability(PS_G7231AnnexCCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_g723AnnexCAudioMode, stream);
+    PutInteger(1, 256, (uint32)x->maxAl_sduAudioFrames, stream);
+    PutBoolean(x->silenceSuppression, stream);
+    if (x->option_of_g723AnnexCAudioMode)
+    {
+        Encode_G723AnnexCAudioMode(&x->g723AnnexCAudioMode, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for G723AnnexCAudioMode (SEQUENCE)  */
+/* <==============================================> */
+void Encode_G723AnnexCAudioMode(PS_G723AnnexCAudioMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(27, 78, (uint32)x->highRateMode0, stream);
+    PutInteger(27, 78, (uint32)x->highRateMode1, stream);
+    PutInteger(23, 66, (uint32)x->lowRateMode0, stream);
+    PutInteger(23, 66, (uint32)x->lowRateMode1, stream);
+    PutInteger(6, 17, (uint32)x->sidMode0, stream);
+    PutInteger(6, 17, (uint32)x->sidMode1, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for IS11172AudioCapability (SEQUENCE)  */
+/* <=================================================> */
+void Encode_IS11172AudioCapability(PS_IS11172AudioCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->audioLayer1, stream);
+    PutBoolean(x->audioLayer2, stream);
+    PutBoolean(x->audioLayer3, stream);
+    PutBoolean(x->audioSampling32k, stream);
+    PutBoolean(x->audioSampling44k1, stream);
+    PutBoolean(x->audioSampling48k, stream);
+    PutBoolean(x->singleChannel, stream);
+    PutBoolean(x->twoChannels, stream);
+    PutInteger(1, 448, (uint32)x->bitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for IS13818AudioCapability (SEQUENCE)  */
+/* <=================================================> */
+void Encode_IS13818AudioCapability(PS_IS13818AudioCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->audioLayer1, stream);
+    PutBoolean(x->audioLayer2, stream);
+    PutBoolean(x->audioLayer3, stream);
+    PutBoolean(x->audioSampling16k, stream);
+    PutBoolean(x->audioSampling22k05, stream);
+    PutBoolean(x->audioSampling24k, stream);
+    PutBoolean(x->audioSampling32k, stream);
+    PutBoolean(x->audioSampling44k1, stream);
+    PutBoolean(x->audioSampling48k, stream);
+    PutBoolean(x->singleChannel, stream);
+    PutBoolean(x->twoChannels, stream);
+    PutBoolean(x->threeChannels2_1, stream);
+    PutBoolean(x->threeChannels3_0, stream);
+    PutBoolean(x->fourChannels2_0_2_0, stream);
+    PutBoolean(x->fourChannels2_2, stream);
+    PutBoolean(x->fourChannels3_1, stream);
+    PutBoolean(x->fiveChannels3_0_2_0, stream);
+    PutBoolean(x->fiveChannels3_2, stream);
+    PutBoolean(x->lowFrequencyEnhancement, stream);
+    PutBoolean(x->multilingual, stream);
+    PutInteger(1, 1130, (uint32)x->bitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for GSMAudioCapability (SEQUENCE)  */
+/* <=============================================> */
+void Encode_GSMAudioCapability(PS_GSMAudioCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 256, (uint32)x->audioUnitSize, stream);
+    PutBoolean(x->comfortNoise, stream);
+    PutBoolean(x->scrambled, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================================> */
+/*  PER-Encoder for DataApplicationCapability (SEQUENCE)  */
+/* <====================================================> */
+void Encode_DataApplicationCapability(PS_DataApplicationCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_Application(&x->application, stream);
+    PutInteger(0, 0xffffffff, (uint32)x->maxBitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Encoder for Application (CHOICE)  */
+/* <====================================> */
+void Encode_Application(PS_Application x, PS_OutStream stream)
+{
+    PutChoiceIndex(10, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_DataProtocolCapability(x->t120, stream);
+            break;
+        case 2:
+            Encode_DataProtocolCapability(x->dsm_cc, stream);
+            break;
+        case 3:
+            Encode_DataProtocolCapability(x->userData, stream);
+            break;
+        case 4:
+            Encode_T84(x->t84, stream);
+            break;
+        case 5:
+            Encode_DataProtocolCapability(x->t434, stream);
+            break;
+        case 6:
+            Encode_DataProtocolCapability(x->h224, stream);
+            break;
+        case 7:
+            Encode_Nlpid(x->nlpid, stream);
+            break;
+        case 8:
+            /* (dsvdControl is NULL) */
+            break;
+        case 9:
+            Encode_DataProtocolCapability(x->h222DataPartitioning, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            PutExtensionItem(EPASS Encode_DataProtocolCapability, (uint8*)x->t30fax, stream);
+            break;
+        case 11:
+            PutExtensionItem(EPASS Encode_DataProtocolCapability, (uint8*)x->t140, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_T38fax, (uint8*)x->t38fax, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericDataCapability, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Application: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Encoder for T38fax (SEQUENCE)  */
+/* <=================================> */
+void Encode_T38fax(PS_T38fax x, PS_OutStream stream)
+{
+    Encode_DataProtocolCapability(&x->t38FaxProtocol, stream);
+    Encode_T38FaxProfile(&x->t38FaxProfile, stream);
+}
+
+/* <================================> */
+/*  PER-Encoder for Nlpid (SEQUENCE)  */
+/* <================================> */
+void Encode_Nlpid(PS_Nlpid x, PS_OutStream stream)
+{
+    Encode_DataProtocolCapability(&x->nlpidProtocol, stream);
+    PutOctetString(1, 0, 0, &x->nlpidData, stream);
+}
+
+/* <==============================> */
+/*  PER-Encoder for T84 (SEQUENCE)  */
+/* <==============================> */
+void Encode_T84(PS_T84 x, PS_OutStream stream)
+{
+    Encode_DataProtocolCapability(&x->t84Protocol, stream);
+    Encode_T84Profile(&x->t84Profile, stream);
+}
+
+/* <===============================================> */
+/*  PER-Encoder for DataProtocolCapability (CHOICE)  */
+/* <===============================================> */
+void Encode_DataProtocolCapability(PS_DataProtocolCapability x, PS_OutStream stream)
+{
+    PutChoiceIndex(7, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (v14buffered is NULL) */
+            break;
+        case 2:
+            /* (v42lapm is NULL) */
+            break;
+        case 3:
+            /* (hdlcFrameTunnelling is NULL) */
+            break;
+        case 4:
+            /* (h310SeparateVCStack is NULL) */
+            break;
+        case 5:
+            /* (h310SingleVCStack is NULL) */
+            break;
+        case 6:
+            /* (transparent is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            PutExtensionNull(stream);
+            break;
+        case 8:
+            PutExtensionNull(stream);
+            break;
+        case 9:
+            PutExtensionNull(stream);
+            break;
+        case 10:
+            PutExtensionNull(stream);
+            break;
+        case 11:
+            PutExtensionItem(EPASS Encode_V76wCompression, (uint8*)x->v76wCompression, stream);
+            break;
+        case 12:
+            PutExtensionNull(stream);
+            break;
+        case 13:
+            PutExtensionNull(stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_DataProtocolCapability: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for V76wCompression (CHOICE)  */
+/* <========================================> */
+void Encode_V76wCompression(PS_V76wCompression x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_CompressionType(x->transmitCompression, stream);
+            break;
+        case 1:
+            Encode_CompressionType(x->receiveCompression, stream);
+            break;
+        case 2:
+            Encode_CompressionType(x->transmitAndReceiveCompression, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_V76wCompression: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for CompressionType (CHOICE)  */
+/* <========================================> */
+void Encode_CompressionType(PS_CompressionType x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_V42bis(x->v42bis, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CompressionType: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Encoder for V42bis (SEQUENCE)  */
+/* <=================================> */
+void Encode_V42bis(PS_V42bis x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65536, (uint32)x->numberOfCodewords, stream);
+    PutInteger(1, 256, (uint32)x->maximumStringLength, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Encoder for T84Profile (CHOICE)  */
+/* <===================================> */
+void Encode_T84Profile(PS_T84Profile x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (t84Unrestricted is NULL) */
+            break;
+        case 1:
+            Encode_T84Restricted(x->t84Restricted, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_T84Profile: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for T84Restricted (SEQUENCE)  */
+/* <========================================> */
+void Encode_T84Restricted(PS_T84Restricted x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->qcif, stream);
+    PutBoolean(x->cif, stream);
+    PutBoolean(x->ccir601Seq, stream);
+    PutBoolean(x->ccir601Prog, stream);
+    PutBoolean(x->hdtvSeq, stream);
+    PutBoolean(x->hdtvProg, stream);
+    PutBoolean(x->g3FacsMH200x100, stream);
+    PutBoolean(x->g3FacsMH200x200, stream);
+    PutBoolean(x->g4FacsMMR200x100, stream);
+    PutBoolean(x->g4FacsMMR200x200, stream);
+    PutBoolean(x->jbig200x200Seq, stream);
+    PutBoolean(x->jbig200x200Prog, stream);
+    PutBoolean(x->jbig300x300Seq, stream);
+    PutBoolean(x->jbig300x300Prog, stream);
+    PutBoolean(x->digPhotoLow, stream);
+    PutBoolean(x->digPhotoMedSeq, stream);
+    PutBoolean(x->digPhotoMedProg, stream);
+    PutBoolean(x->digPhotoHighSeq, stream);
+    PutBoolean(x->digPhotoHighProg, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for T38FaxProfile (SEQUENCE)  */
+/* <========================================> */
+void Encode_T38FaxProfile(PS_T38FaxProfile x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_version |
+                x->option_of_t38FaxRateManagement |
+                x->option_of_t38FaxUdpOptions;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->fillBitRemoval, stream);
+    PutBoolean(x->transcodingJBIG, stream);
+    PutBoolean(x->transcodingMMR, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(3, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_version, stream);
+    PutBoolean(x->option_of_t38FaxRateManagement, stream);
+    PutBoolean(x->option_of_t38FaxUdpOptions, stream);
+    if (x->option_of_version)
+    {
+        PutExtensionInteger(0, 255, (uint32)x->version, stream);
+    }
+    if (x->option_of_t38FaxRateManagement)
+    {
+        PutExtensionItem(EPASS Encode_T38FaxRateManagement, (uint8*)&x->t38FaxRateManagement, stream);
+    }
+    if (x->option_of_t38FaxUdpOptions)
+    {
+        PutExtensionItem(EPASS Encode_T38FaxUdpOptions, (uint8*)&x->t38FaxUdpOptions, stream);
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for T38FaxRateManagement (CHOICE)  */
+/* <=============================================> */
+void Encode_T38FaxRateManagement(PS_T38FaxRateManagement x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (localTCF is NULL) */
+            break;
+        case 1:
+            /* (transferredTCF is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_T38FaxRateManagement: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for T38FaxUdpOptions (SEQUENCE)  */
+/* <===========================================> */
+void Encode_T38FaxUdpOptions(PS_T38FaxUdpOptions x, PS_OutStream stream)
+{
+    PutBoolean(x->option_of_t38FaxMaxBuffer, stream);
+    PutBoolean(x->option_of_t38FaxMaxDatagram, stream);
+    if (x->option_of_t38FaxMaxBuffer)
+    {
+        PutUnboundedInteger((uint32)x->t38FaxMaxBuffer, stream);
+    }
+    if (x->option_of_t38FaxMaxDatagram)
+    {
+        PutUnboundedInteger((uint32)x->t38FaxMaxDatagram, stream);
+    }
+    Encode_T38FaxUdpEC(&x->t38FaxUdpEC, stream);
+}
+
+/* <====================================> */
+/*  PER-Encoder for T38FaxUdpEC (CHOICE)  */
+/* <====================================> */
+void Encode_T38FaxUdpEC(PS_T38FaxUdpEC x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (t38UDPFEC is NULL) */
+            break;
+        case 1:
+            /* (t38UDPRedundancy is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_T38FaxUdpEC: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================================> */
+/*  PER-Encoder for EncryptionAuthenticationAndIntegrity (SEQUENCE)  */
+/* <===============================================================> */
+void Encode_EncryptionAuthenticationAndIntegrity(PS_EncryptionAuthenticationAndIntegrity x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_encryptionCapability, stream);
+    PutBoolean(x->option_of_authenticationCapability, stream);
+    PutBoolean(x->option_of_integrityCapability, stream);
+    if (x->option_of_encryptionCapability)
+    {
+        Encode_EncryptionCapability(&x->encryptionCapability, stream);
+    }
+    if (x->option_of_authenticationCapability)
+    {
+        Encode_AuthenticationCapability(&x->authenticationCapability, stream);
+    }
+    if (x->option_of_integrityCapability)
+    {
+        Encode_IntegrityCapability(&x->integrityCapability, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for EncryptionCapability (SEQUENCE-OF)  */
+/* <==================================================> */
+void Encode_EncryptionCapability(PS_EncryptionCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutInteger(1, 256, (uint32)x->size, stream);
+    for (i = 0;i < x->size;++i)
+    {
+        Encode_MediaEncryptionAlgorithm(x->item + i, stream);
+    }
+}
+
+/* <=================================================> */
+/*  PER-Encoder for MediaEncryptionAlgorithm (CHOICE)  */
+/* <=================================================> */
+void Encode_MediaEncryptionAlgorithm(PS_MediaEncryptionAlgorithm x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            PutObjectID(x->algorithm, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MediaEncryptionAlgorithm: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Encoder for AuthenticationCapability (SEQUENCE)  */
+/* <===================================================> */
+void Encode_AuthenticationCapability(PS_AuthenticationCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_nonStandard, stream);
+    if (x->option_of_nonStandard)
+    {
+        Encode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for IntegrityCapability (SEQUENCE)  */
+/* <==============================================> */
+void Encode_IntegrityCapability(PS_IntegrityCapability x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_nonStandard, stream);
+    if (x->option_of_nonStandard)
+    {
+        Encode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for UserInputCapability (CHOICE)  */
+/* <============================================> */
+void Encode_UserInputCapability(PS_UserInputCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(6, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 16, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_NonStandardParameter(x->nonStandard + i, stream);
+            }
+            break;
+        case 1:
+            /* (basicString is NULL) */
+            break;
+        case 2:
+            /* (iA5String is NULL) */
+            break;
+        case 3:
+            /* (generalString is NULL) */
+            break;
+        case 4:
+            /* (dtmf is NULL) */
+            break;
+        case 5:
+            /* (hookflash is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_UserInputCapability: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for ConferenceCapability (SEQUENCE)  */
+/* <===============================================> */
+void Encode_ConferenceCapability(PS_ConferenceCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    uint32 extension;
+
+    extension = x->option_of_VideoIndicateMixingCapability |
+                x->option_of_multipointVisualizationCapability;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_nonStandardData, stream);
+    if (x->option_of_nonStandardData)
+    {
+        PutLengthDet(x->size_of_nonStandardData, stream);
+        for (i = 0;i < x->size_of_nonStandardData;++i)
+        {
+            Encode_NonStandardParameter(x->nonStandardData + i, stream);
+        }
+    }
+    PutBoolean(x->chairControlCapability, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(2, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_VideoIndicateMixingCapability, stream);
+    PutBoolean(x->option_of_multipointVisualizationCapability, stream);
+    if (x->option_of_VideoIndicateMixingCapability)
+    {
+        PutExtensionBoolean(x->VideoIndicateMixingCapability, stream);
+    }
+    if (x->option_of_multipointVisualizationCapability)
+    {
+        PutExtensionBoolean(x->multipointVisualizationCapability, stream);
+    }
+}
+
+/* <============================================> */
+/*  PER-Encoder for GenericCapability (SEQUENCE)  */
+/* <============================================> */
+void Encode_GenericCapability(PS_GenericCapability x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_maxBitRate, stream);
+    PutBoolean(x->option_of_collapsing, stream);
+    PutBoolean(x->option_of_nonCollapsing, stream);
+    PutBoolean(x->option_of_nonCollapsingRaw, stream);
+    PutBoolean(x->option_of_transport, stream);
+    Encode_CapabilityIdentifier(&x->capabilityIdentifier, stream);
+    if (x->option_of_maxBitRate)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->maxBitRate, stream);
+    }
+    if (x->option_of_collapsing)
+    {
+        PutLengthDet(x->size_of_collapsing, stream);
+        for (i = 0;i < x->size_of_collapsing;++i)
+        {
+            Encode_GenericParameter(x->collapsing + i, stream);
+        }
+    }
+    if (x->option_of_nonCollapsing)
+    {
+        PutLengthDet(x->size_of_nonCollapsing, stream);
+        for (i = 0;i < x->size_of_nonCollapsing;++i)
+        {
+            Encode_GenericParameter(x->nonCollapsing + i, stream);
+        }
+    }
+    if (x->option_of_nonCollapsingRaw)
+    {
+        PutOctetString(1, 0, 0, &x->nonCollapsingRaw, stream);
+    }
+    if (x->option_of_transport)
+    {
+        Encode_DataProtocolCapability(&x->transport, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for CapabilityIdentifier (CHOICE)  */
+/* <=============================================> */
+void Encode_CapabilityIdentifier(PS_CapabilityIdentifier x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutObjectID(x->standard, stream);
+            break;
+        case 1:
+            Encode_NonStandardParameter(x->h221NonStandard, stream);
+            break;
+        case 2:
+            PutOctetString(0, 16, 16, x->uuid, stream);
+            break;
+        case 3:
+            PutCharString("IA5String", 0, 1, 64, NULL, x->domainBased, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CapabilityIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for GenericParameter (SEQUENCE)  */
+/* <===========================================> */
+void Encode_GenericParameter(PS_GenericParameter x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_supersedes, stream);
+    Encode_ParameterIdentifier(&x->parameterIdentifier, stream);
+    Encode_ParameterValue(&x->parameterValue, stream);
+    if (x->option_of_supersedes)
+    {
+        PutLengthDet(x->size_of_supersedes, stream);
+        for (i = 0;i < x->size_of_supersedes;++i)
+        {
+            Encode_ParameterIdentifier(x->supersedes + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for ParameterIdentifier (CHOICE)  */
+/* <============================================> */
+void Encode_ParameterIdentifier(PS_ParameterIdentifier x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(0, 127, (uint32)x->standard, stream);
+            break;
+        case 1:
+            Encode_NonStandardParameter(x->h221NonStandard, stream);
+            break;
+        case 2:
+            PutOctetString(0, 16, 16, x->uuid, stream);
+            break;
+        case 3:
+            PutCharString("IA5String", 0, 1, 64, NULL, x->domainBased, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_ParameterIdentifier: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for ParameterValue (CHOICE)  */
+/* <=======================================> */
+void Encode_ParameterValue(PS_ParameterValue x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(8, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (logical is NULL) */
+            break;
+        case 1:
+            PutInteger(0, 255, (uint32)x->booleanArray, stream);
+            break;
+        case 2:
+            PutInteger(0, 65535, (uint32)x->unsignedMin, stream);
+            break;
+        case 3:
+            PutInteger(0, 65535, (uint32)x->unsignedMax, stream);
+            break;
+        case 4:
+            PutInteger(0, 0xffffffff, (uint32)x->unsigned32Min, stream);
+            break;
+        case 5:
+            PutInteger(0, 0xffffffff, (uint32)x->unsigned32Max, stream);
+            break;
+        case 6:
+            PutOctetString(1, 0, 0, x->octetString, stream);
+            break;
+        case 7:
+            PutLengthDet(x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_GenericParameter(x->genericParameter + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_ParameterValue: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for OpenLogicalChannel (SEQUENCE)  */
+/* <=============================================> */
+void Encode_OpenLogicalChannel(PS_OpenLogicalChannel x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_separateStack |
+                x->option_of_encryptionSync;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_reverseLogicalChannelParameters, stream);
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    Encode_ForwardLogicalChannelParameters(&x->forwardLogicalChannelParameters, stream);
+    if (x->option_of_reverseLogicalChannelParameters)
+    {
+        Encode_ReverseLogicalChannelParameters(&x->reverseLogicalChannelParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(2, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_separateStack, stream);
+    PutBoolean(x->option_of_encryptionSync, stream);
+    if (x->option_of_separateStack)
+    {
+        PutExtensionItem(EPASS Encode_NetworkAccessParameters, (uint8*)&x->separateStack, stream);
+    }
+    if (x->option_of_encryptionSync)
+    {
+        PutExtensionItem(EPASS Encode_EncryptionSync, (uint8*)&x->encryptionSync, stream);
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Encoder for ReverseLogicalChannelParameters (SEQUENCE)  */
+/* <==========================================================> */
+void Encode_ReverseLogicalChannelParameters(PS_ReverseLogicalChannelParameters x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_reverseLogicalChannelDependency |
+                x->option_of_replacementFor;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_rlcMultiplexParameters, stream);
+    Encode_DataType(&x->dataType, stream);
+    if (x->option_of_rlcMultiplexParameters)
+    {
+        Encode_RlcMultiplexParameters(&x->rlcMultiplexParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(2, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_reverseLogicalChannelDependency, stream);
+    PutBoolean(x->option_of_replacementFor, stream);
+    if (x->option_of_reverseLogicalChannelDependency)
+    {
+        PutExtensionInteger(1, 65535, (uint32)x->reverseLogicalChannelDependency, stream);
+    }
+    if (x->option_of_replacementFor)
+    {
+        PutExtensionInteger(1, 65535, (uint32)x->replacementFor, stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for RlcMultiplexParameters (CHOICE)  */
+/* <===============================================> */
+void Encode_RlcMultiplexParameters(PS_RlcMultiplexParameters x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_H223LogicalChannelParameters(x->h223LogicalChannelParameters, stream);
+            break;
+        case 1:
+            Encode_V76LogicalChannelParameters(x->v76LogicalChannelParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            PutExtensionItem(EPASS Encode_H2250LogicalChannelParameters, (uint8*)x->h2250LogicalChannelParameters, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_RlcMultiplexParameters: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Encoder for ForwardLogicalChannelParameters (SEQUENCE)  */
+/* <==========================================================> */
+void Encode_ForwardLogicalChannelParameters(PS_ForwardLogicalChannelParameters x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_forwardLogicalChannelDependency |
+                x->option_of_replacementFor;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_portNumber, stream);
+    if (x->option_of_portNumber)
+    {
+        PutInteger(0, 65535, (uint32)x->portNumber, stream);
+    }
+    Encode_DataType(&x->dataType, stream);
+    Encode_MultiplexParameters(&x->multiplexParameters, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(2, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_forwardLogicalChannelDependency, stream);
+    PutBoolean(x->option_of_replacementFor, stream);
+    if (x->option_of_forwardLogicalChannelDependency)
+    {
+        PutExtensionInteger(1, 65535, (uint32)x->forwardLogicalChannelDependency, stream);
+    }
+    if (x->option_of_replacementFor)
+    {
+        PutExtensionInteger(1, 65535, (uint32)x->replacementFor, stream);
+    }
+}
+
+/* <============================================> */
+/*  PER-Encoder for MultiplexParameters (CHOICE)  */
+/* <============================================> */
+void Encode_MultiplexParameters(PS_MultiplexParameters x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_H222LogicalChannelParameters(x->h222LogicalChannelParameters, stream);
+            break;
+        case 1:
+            Encode_H223LogicalChannelParameters(x->h223LogicalChannelParameters, stream);
+            break;
+        case 2:
+            Encode_V76LogicalChannelParameters(x->v76LogicalChannelParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            PutExtensionItem(EPASS Encode_H2250LogicalChannelParameters, (uint8*)x->h2250LogicalChannelParameters, stream);
+            break;
+        case 4:
+            PutExtensionNull(stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MultiplexParameters: Illegal CHOICE index");
+    }
+}
+
+/* <==================================================> */
+/*  PER-Encoder for NetworkAccessParameters (SEQUENCE)  */
+/* <==================================================> */
+void Encode_NetworkAccessParameters(PS_NetworkAccessParameters x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_t120SetupProcedure;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_distribution, stream);
+    PutBoolean(x->option_of_externalReference, stream);
+    if (x->option_of_distribution)
+    {
+        Encode_Distribution(&x->distribution, stream);
+    }
+    Encode_NetworkAddress(&x->networkAddress, stream);
+    PutBoolean(x->associateConference, stream);
+    if (x->option_of_externalReference)
+    {
+        PutOctetString(0, 1, 255, &x->externalReference, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_t120SetupProcedure, stream);
+    if (x->option_of_t120SetupProcedure)
+    {
+        PutExtensionItem(EPASS Encode_T120SetupProcedure, (uint8*)&x->t120SetupProcedure, stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for T120SetupProcedure (CHOICE)  */
+/* <===========================================> */
+void Encode_T120SetupProcedure(PS_T120SetupProcedure x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (originateCall is NULL) */
+            break;
+        case 1:
+            /* (waitForCall is NULL) */
+            break;
+        case 2:
+            /* (issueQuery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_T120SetupProcedure: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for NetworkAddress (CHOICE)  */
+/* <=======================================> */
+void Encode_NetworkAddress(PS_NetworkAddress x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_Q2931Address(x->q2931Address, stream);
+            break;
+        case 1:
+            PutCharString("IA5String(SIZE(1..128))", 0, 1, 128, "0123456789#*,", x->e164Address, stream);
+            break;
+        case 2:
+            Encode_TransportAddress(x->localAreaAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_NetworkAddress: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for Distribution (CHOICE)  */
+/* <=====================================> */
+void Encode_Distribution(PS_Distribution x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unicast is NULL) */
+            break;
+        case 1:
+            /* (multicast is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Distribution: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for Q2931Address (SEQUENCE)  */
+/* <=======================================> */
+void Encode_Q2931Address(PS_Q2931Address x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_subaddress, stream);
+    Encode_Address(&x->address, stream);
+    if (x->option_of_subaddress)
+    {
+        PutOctetString(0, 1, 20, &x->subaddress, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Encoder for Address (CHOICE)  */
+/* <================================> */
+void Encode_Address(PS_Address x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutCharString("NumericString(SIZE(1..16))", 0, 1, 16, NULL, x->internationalNumber, stream);
+            break;
+        case 1:
+            PutOctetString(0, 1, 20, x->nsapAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Address: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for V75Parameters (SEQUENCE)  */
+/* <========================================> */
+void Encode_V75Parameters(PS_V75Parameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->audioHeaderPresent, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Encoder for DataType (CHOICE)  */
+/* <=================================> */
+void Encode_DataType(PS_DataType x, PS_OutStream stream)
+{
+    PutChoiceIndex(6, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (nullData is NULL) */
+            break;
+        case 2:
+            Encode_VideoCapability(x->videoData, stream);
+            break;
+        case 3:
+            Encode_AudioCapability(x->audioData, stream);
+            break;
+        case 4:
+            Encode_DataApplicationCapability(x->data, stream);
+            break;
+        case 5:
+            Encode_EncryptionMode(x->encryptionData, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            PutExtensionItem(EPASS Encode_NonStandardParameter, (uint8*)x->h235Control, stream);
+            break;
+        case 7:
+            PutExtensionItem(EPASS Encode_H235Media, (uint8*)x->h235Media, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_DataType: Illegal CHOICE index");
+    }
+}
+
+/* <====================================> */
+/*  PER-Encoder for H235Media (SEQUENCE)  */
+/* <====================================> */
+void Encode_H235Media(PS_H235Media x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, stream);
+    Encode_MediaType(&x->mediaType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for MediaType (CHOICE)  */
+/* <==================================> */
+void Encode_MediaType(PS_MediaType x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_VideoCapability(x->videoData, stream);
+            break;
+        case 2:
+            Encode_AudioCapability(x->audioData, stream);
+            break;
+        case 3:
+            Encode_DataApplicationCapability(x->data, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MediaType: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for H222LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+void Encode_H222LogicalChannelParameters(PS_H222LogicalChannelParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_pcr_pid, stream);
+    PutBoolean(x->option_of_programDescriptors, stream);
+    PutBoolean(x->option_of_streamDescriptors, stream);
+    PutInteger(0, 65535, (uint32)x->resourceID, stream);
+    PutInteger(0, 8191, (uint32)x->subChannelID, stream);
+    if (x->option_of_pcr_pid)
+    {
+        PutInteger(0, 8191, (uint32)x->pcr_pid, stream);
+    }
+    if (x->option_of_programDescriptors)
+    {
+        PutOctetString(1, 0, 0, &x->programDescriptors, stream);
+    }
+    if (x->option_of_streamDescriptors)
+    {
+        PutOctetString(1, 0, 0, &x->streamDescriptors, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for H223LogicalChannelParameters (SEQUENCE)  */
+/* <=======================================================> */
+void Encode_H223LogicalChannelParameters(PS_H223LogicalChannelParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_AdaptationLayerType(&x->adaptationLayerType, stream);
+    PutBoolean(x->segmentableFlag, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for AdaptationLayerType (CHOICE)  */
+/* <============================================> */
+void Encode_AdaptationLayerType(PS_AdaptationLayerType x, PS_OutStream stream)
+{
+    PutChoiceIndex(6, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (al1Framed is NULL) */
+            break;
+        case 2:
+            /* (al1NotFramed is NULL) */
+            break;
+        case 3:
+            /* (al2WithoutSequenceNumbers is NULL) */
+            break;
+        case 4:
+            /* (al2WithSequenceNumbers is NULL) */
+            break;
+        case 5:
+            Encode_Al3(x->al3, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            PutExtensionItem(EPASS Encode_H223AL1MParameters, (uint8*)x->al1M, stream);
+            break;
+        case 7:
+            PutExtensionItem(EPASS Encode_H223AL2MParameters, (uint8*)x->al2M, stream);
+            break;
+        case 8:
+            PutExtensionItem(EPASS Encode_H223AL3MParameters, (uint8*)x->al3M, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_AdaptationLayerType: Illegal CHOICE index");
+    }
+}
+
+/* <==============================> */
+/*  PER-Encoder for Al3 (SEQUENCE)  */
+/* <==============================> */
+void Encode_Al3(PS_Al3 x, PS_OutStream stream)
+{
+    PutInteger(0, 2, (uint32)x->controlFieldOctets, stream);
+    PutInteger(0, 16777215, (uint32)x->sendBufferSize, stream);
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H223AL1MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Encode_H223AL1MParameters(PS_H223AL1MParameters x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_rsCodeCorrection;
+    PutBoolean(extension, stream);
+
+    Encode_TransferMode(&x->transferMode, stream);
+    Encode_HeaderFEC(&x->headerFEC, stream);
+    Encode_CrcLength(&x->crcLength, stream);
+    PutInteger(8, 32, (uint32)x->rcpcCodeRate, stream);
+    Encode_ArqType(&x->arqType, stream);
+    PutBoolean(x->alpduInterleaving, stream);
+    PutBoolean(x->alsduSplitting, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_rsCodeCorrection, stream);
+    if (x->option_of_rsCodeCorrection)
+    {
+        PutExtensionInteger(0, 127, (uint32)x->rsCodeCorrection, stream);
+    }
+}
+
+/* <================================> */
+/*  PER-Encoder for ArqType (CHOICE)  */
+/* <================================> */
+void Encode_ArqType(PS_ArqType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noArq is NULL) */
+            break;
+        case 1:
+            Encode_H223AnnexCArqParameters(x->typeIArq, stream);
+            break;
+        case 2:
+            Encode_H223AnnexCArqParameters(x->typeIIArq, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_ArqType: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for CrcLength (CHOICE)  */
+/* <==================================> */
+void Encode_CrcLength(PS_CrcLength x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (crc4bit is NULL) */
+            break;
+        case 1:
+            /* (crc12bit is NULL) */
+            break;
+        case 2:
+            /* (crc20bit is NULL) */
+            break;
+        case 3:
+            /* (crc28bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            PutExtensionNull(stream);
+            break;
+        case 5:
+            PutExtensionNull(stream);
+            break;
+        case 6:
+            PutExtensionNull(stream);
+            break;
+        case 7:
+            PutExtensionNull(stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_CrcLength: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for HeaderFEC (CHOICE)  */
+/* <==================================> */
+void Encode_HeaderFEC(PS_HeaderFEC x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_7 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_HeaderFEC: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for TransferMode (CHOICE)  */
+/* <=====================================> */
+void Encode_TransferMode(PS_TransferMode x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (framed is NULL) */
+            break;
+        case 1:
+            /* (unframed is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_TransferMode: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H223AL2MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Encode_H223AL2MParameters(PS_H223AL2MParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_Al2HeaderFEC(&x->al2HeaderFEC, stream);
+    PutBoolean(x->alpduInterleaving, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Encoder for Al2HeaderFEC (CHOICE)  */
+/* <=====================================> */
+void Encode_Al2HeaderFEC(PS_Al2HeaderFEC x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_5 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Al2HeaderFEC: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H223AL3MParameters (SEQUENCE)  */
+/* <=============================================> */
+void Encode_H223AL3MParameters(PS_H223AL3MParameters x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_rsCodeCorrection;
+    PutBoolean(extension, stream);
+
+    Encode_HeaderFormat(&x->headerFormat, stream);
+    Encode_Al3CrcLength(&x->al3CrcLength, stream);
+    PutInteger(8, 32, (uint32)x->rcpcCodeRate, stream);
+    Encode_Al3ArqType(&x->al3ArqType, stream);
+    PutBoolean(x->alpduInterleaving, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_rsCodeCorrection, stream);
+    if (x->option_of_rsCodeCorrection)
+    {
+        PutExtensionInteger(0, 127, (uint32)x->rsCodeCorrection, stream);
+    }
+}
+
+/* <===================================> */
+/*  PER-Encoder for Al3ArqType (CHOICE)  */
+/* <===================================> */
+void Encode_Al3ArqType(PS_Al3ArqType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noArq is NULL) */
+            break;
+        case 1:
+            Encode_H223AnnexCArqParameters(x->typeIArq, stream);
+            break;
+        case 2:
+            Encode_H223AnnexCArqParameters(x->typeIIArq, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Al3ArqType: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for Al3CrcLength (CHOICE)  */
+/* <=====================================> */
+void Encode_Al3CrcLength(PS_Al3CrcLength x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (crc4bit is NULL) */
+            break;
+        case 1:
+            /* (crc12bit is NULL) */
+            break;
+        case 2:
+            /* (crc20bit is NULL) */
+            break;
+        case 3:
+            /* (crc28bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 4:
+            PutExtensionNull(stream);
+            break;
+        case 5:
+            PutExtensionNull(stream);
+            break;
+        case 6:
+            PutExtensionNull(stream);
+            break;
+        case 7:
+            PutExtensionNull(stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Al3CrcLength: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for HeaderFormat (CHOICE)  */
+/* <=====================================> */
+void Encode_HeaderFormat(PS_HeaderFormat x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sebch16_7 is NULL) */
+            break;
+        case 1:
+            /* (golay24_12 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_HeaderFormat: Illegal CHOICE index");
+    }
+}
+
+/* <==================================================> */
+/*  PER-Encoder for H223AnnexCArqParameters (SEQUENCE)  */
+/* <==================================================> */
+void Encode_H223AnnexCArqParameters(PS_H223AnnexCArqParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_NumberOfRetransmissions(&x->numberOfRetransmissions, stream);
+    PutInteger(0, 16777215, (uint32)x->sendBufferSize, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for NumberOfRetransmissions (CHOICE)  */
+/* <================================================> */
+void Encode_NumberOfRetransmissions(PS_NumberOfRetransmissions x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(0, 16, (uint32)x->finite, stream);
+            break;
+        case 1:
+            /* (infinite is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_NumberOfRetransmissions: Illegal CHOICE index");
+    }
+}
+
+/* <======================================================> */
+/*  PER-Encoder for V76LogicalChannelParameters (SEQUENCE)  */
+/* <======================================================> */
+void Encode_V76LogicalChannelParameters(PS_V76LogicalChannelParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_V76HDLCParameters(&x->hdlcParameters, stream);
+    Encode_SuspendResume(&x->suspendResume, stream);
+    PutBoolean(x->uIH, stream);
+    Encode_Mode(&x->mode, stream);
+    Encode_V75Parameters(&x->v75Parameters, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================> */
+/*  PER-Encoder for Mode (CHOICE)  */
+/* <=============================> */
+void Encode_Mode(PS_Mode x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_ERM(x->eRM, stream);
+            break;
+        case 1:
+            /* (uNERM is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Mode: Illegal CHOICE index");
+    }
+}
+
+/* <==============================> */
+/*  PER-Encoder for ERM (SEQUENCE)  */
+/* <==============================> */
+void Encode_ERM(PS_ERM x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 127, (uint32)x->windowSize, stream);
+    Encode_Recovery(&x->recovery, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Encoder for Recovery (CHOICE)  */
+/* <=================================> */
+void Encode_Recovery(PS_Recovery x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (rej is NULL) */
+            break;
+        case 1:
+            /* (sREJ is NULL) */
+            break;
+        case 2:
+            /* (mSREJ is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Recovery: Illegal CHOICE index");
+    }
+}
+
+/* <======================================> */
+/*  PER-Encoder for SuspendResume (CHOICE)  */
+/* <======================================> */
+void Encode_SuspendResume(PS_SuspendResume x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noSuspendResume is NULL) */
+            break;
+        case 1:
+            /* (suspendResumewAddress is NULL) */
+            break;
+        case 2:
+            /* (suspendResumewoAddress is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_SuspendResume: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Encoder for V76HDLCParameters (SEQUENCE)  */
+/* <============================================> */
+void Encode_V76HDLCParameters(PS_V76HDLCParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_CRCLength(&x->crcLength, stream);
+    PutInteger(1, 4095, (uint32)x->n401, stream);
+    PutBoolean(x->loopbackTestProcedure, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for CRCLength (CHOICE)  */
+/* <==================================> */
+void Encode_CRCLength(PS_CRCLength x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (crc8bit is NULL) */
+            break;
+        case 1:
+            /* (crc16bit is NULL) */
+            break;
+        case 2:
+            /* (crc32bit is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CRCLength: Illegal CHOICE index");
+    }
+}
+
+/* <========================================================> */
+/*  PER-Encoder for H2250LogicalChannelParameters (SEQUENCE)  */
+/* <========================================================> */
+void Encode_H2250LogicalChannelParameters(PS_H2250LogicalChannelParameters x, PS_OutStream stream)
+{
+    uint16 i;
+    uint32 extension;
+
+    extension = x->option_of_transportCapability |
+                x->option_of_redundancyEncoding |
+                x->option_of_source |
+                x->option_of_symmetricMediaAddress;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_nonStandard, stream);
+    PutBoolean(x->option_of_associatedSessionID, stream);
+    PutBoolean(x->option_of_mediaChannel, stream);
+    PutBoolean(x->option_of_mediaGuaranteedDelivery, stream);
+    PutBoolean(x->option_of_mediaControlChannel, stream);
+    PutBoolean(x->option_of_mediaControlGuaranteedDelivery, stream);
+    PutBoolean(x->option_of_silenceSuppression, stream);
+    PutBoolean(x->option_of_destination, stream);
+    PutBoolean(x->option_of_dynamicRTPPayloadType, stream);
+    PutBoolean(x->option_of_mediaPacketization, stream);
+    if (x->option_of_nonStandard)
+    {
+        PutLengthDet(x->size_of_nonStandard, stream);
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Encode_NonStandardParameter(x->nonStandard + i, stream);
+        }
+    }
+    PutInteger(0, 255, (uint32)x->sessionID, stream);
+    if (x->option_of_associatedSessionID)
+    {
+        PutInteger(1, 255, (uint32)x->associatedSessionID, stream);
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Encode_TransportAddress(&x->mediaChannel, stream);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+        PutBoolean(x->mediaGuaranteedDelivery, stream);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Encode_TransportAddress(&x->mediaControlChannel, stream);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+        PutBoolean(x->mediaControlGuaranteedDelivery, stream);
+    }
+    if (x->option_of_silenceSuppression)
+    {
+        PutBoolean(x->silenceSuppression, stream);
+    }
+    if (x->option_of_destination)
+    {
+        Encode_TerminalLabel(&x->destination, stream);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+        PutInteger(96, 127, (uint32)x->dynamicRTPPayloadType, stream);
+    }
+    if (x->option_of_mediaPacketization)
+    {
+        Encode_MediaPacketization(&x->mediaPacketization, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(4, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_transportCapability, stream);
+    PutBoolean(x->option_of_redundancyEncoding, stream);
+    PutBoolean(x->option_of_source, stream);
+    PutBoolean(x->option_of_symmetricMediaAddress, stream);
+    if (x->option_of_transportCapability)
+    {
+        PutExtensionItem(EPASS Encode_TransportCapability, (uint8*)&x->transportCapability, stream);
+    }
+    if (x->option_of_redundancyEncoding)
+    {
+        PutExtensionItem(EPASS Encode_RedundancyEncoding, (uint8*)&x->redundancyEncoding, stream);
+    }
+    if (x->option_of_source)
+    {
+        PutExtensionItem(EPASS Encode_TerminalLabel, (uint8*)&x->source, stream);
+    }
+    if (x->option_of_symmetricMediaAddress)
+    {
+        PutExtensionBoolean(x->symmetricMediaAddress, stream);
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for MediaPacketization (CHOICE)  */
+/* <===========================================> */
+void Encode_MediaPacketization(PS_MediaPacketization x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (h261aVideoPacketization is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            PutExtensionItem(EPASS Encode_RTPPayloadType, (uint8*)x->rtpPayloadType, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MediaPacketization: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for RTPPayloadType (SEQUENCE)  */
+/* <=========================================> */
+void Encode_RTPPayloadType(PS_RTPPayloadType x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_payloadType, stream);
+    Encode_PayloadDescriptor(&x->payloadDescriptor, stream);
+    if (x->option_of_payloadType)
+    {
+        PutInteger(0, 127, (uint32)x->payloadType, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Encoder for PayloadDescriptor (CHOICE)  */
+/* <==========================================> */
+void Encode_PayloadDescriptor(PS_PayloadDescriptor x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandardIdentifier, stream);
+            break;
+        case 1:
+            PutExtendedInteger(1, 32768, (int32)x->rfc_number, stream);
+            break;
+        case 2:
+            PutObjectID(x->oid, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_PayloadDescriptor: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for RedundancyEncoding (SEQUENCE)  */
+/* <=============================================> */
+void Encode_RedundancyEncoding(PS_RedundancyEncoding x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_secondaryEncoding, stream);
+    Encode_RedundancyEncodingMethod(&x->redundancyEncodingMethod, stream);
+    if (x->option_of_secondaryEncoding)
+    {
+        Encode_DataType(&x->secondaryEncoding, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Encoder for TransportAddress (CHOICE)  */
+/* <=========================================> */
+void Encode_TransportAddress(PS_TransportAddress x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_UnicastAddress(x->unicastAddress, stream);
+            break;
+        case 1:
+            Encode_MulticastAddress(x->multicastAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_TransportAddress: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for UnicastAddress (CHOICE)  */
+/* <=======================================> */
+void Encode_UnicastAddress(PS_UnicastAddress x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_IPAddress(x->iPAddress, stream);
+            break;
+        case 1:
+            Encode_IPXAddress(x->iPXAddress, stream);
+            break;
+        case 2:
+            Encode_IP6Address(x->iP6Address, stream);
+            break;
+        case 3:
+            PutOctetString(0, 16, 16, x->netBios, stream);
+            break;
+        case 4:
+            Encode_IPSourceRouteAddress(x->iPSourceRouteAddress, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            PutExtensionOctetString(0, 1, 20, x->nsap, stream);
+            break;
+        case 6:
+            PutExtensionItem(EPASS Encode_NonStandardParameter, (uint8*)x->nonStandardAddress, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_UnicastAddress: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for IPSourceRouteAddress (SEQUENCE)  */
+/* <===============================================> */
+void Encode_IPSourceRouteAddress(PS_IPSourceRouteAddress x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_Routing(&x->routing, stream);
+    PutOctetString(0, 4, 4, &x->network, stream);
+    PutInteger(0, 65535, (uint32)x->tsapIdentifier, stream);
+    PutLengthDet(x->size_of_route, stream);
+    for (i = 0;i < x->size_of_route;++i)
+    {
+        PutOctetString(0, 4, 4, x->route + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Encoder for Routing (CHOICE)  */
+/* <================================> */
+void Encode_Routing(PS_Routing x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (strict is NULL) */
+            break;
+        case 1:
+            /* (loose is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Routing: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for IP6Address (SEQUENCE)  */
+/* <=====================================> */
+void Encode_IP6Address(PS_IP6Address x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 16, 16, &x->network, stream);
+    PutInteger(0, 65535, (uint32)x->tsapIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Encoder for IPXAddress (SEQUENCE)  */
+/* <=====================================> */
+void Encode_IPXAddress(PS_IPXAddress x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 6, 6, &x->node, stream);
+    PutOctetString(0, 4, 4, &x->netnum, stream);
+    PutOctetString(0, 2, 2, &x->tsapIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Encoder for IPAddress (SEQUENCE)  */
+/* <====================================> */
+void Encode_IPAddress(PS_IPAddress x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 4, 4, &x->network, stream);
+    PutInteger(0, 65535, (uint32)x->tsapIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Encoder for MulticastAddress (CHOICE)  */
+/* <=========================================> */
+void Encode_MulticastAddress(PS_MulticastAddress x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_MaIpAddress(x->maIpAddress, stream);
+            break;
+        case 1:
+            Encode_MaIp6Address(x->maIp6Address, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            PutExtensionOctetString(0, 1, 20, x->nsap, stream);
+            break;
+        case 3:
+            PutExtensionItem(EPASS Encode_NonStandardParameter, (uint8*)x->nonStandardAddress, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MulticastAddress: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for MaIp6Address (SEQUENCE)  */
+/* <=======================================> */
+void Encode_MaIp6Address(PS_MaIp6Address x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 16, 16, &x->network, stream);
+    PutInteger(0, 65535, (uint32)x->tsapIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for MaIpAddress (SEQUENCE)  */
+/* <======================================> */
+void Encode_MaIpAddress(PS_MaIpAddress x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 4, 4, &x->network, stream);
+    PutInteger(0, 65535, (uint32)x->tsapIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Encoder for EncryptionSync (SEQUENCE)  */
+/* <=========================================> */
+void Encode_EncryptionSync(PS_EncryptionSync x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_nonStandard, stream);
+    PutBoolean(x->option_of_escrowentry, stream);
+    if (x->option_of_nonStandard)
+    {
+        Encode_NonStandardParameter(&x->nonStandard, stream);
+    }
+    PutInteger(0, 255, (uint32)x->synchFlag, stream);
+    PutOctetString(0, 1, 65535, &x->h235Key, stream);
+    if (x->option_of_escrowentry)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_escrowentry, stream);
+        for (i = 0;i < x->size_of_escrowentry;++i)
+        {
+            Encode_EscrowData(x->escrowentry + i, stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Encoder for EscrowData (SEQUENCE)  */
+/* <=====================================> */
+void Encode_EscrowData(PS_EscrowData x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutObjectID(&x->escrowID, stream);
+    PutBitString(0, 1, 65535, &x->escrowValue, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for OpenLogicalChannelAck (SEQUENCE)  */
+/* <================================================> */
+void Encode_OpenLogicalChannelAck(PS_OpenLogicalChannelAck x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_separateStack |
+                x->option_of_forwardMultiplexAckParameters |
+                x->option_of_encryptionSync;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_ackReverseLogicalChannelParameters, stream);
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    if (x->option_of_ackReverseLogicalChannelParameters)
+    {
+        Encode_AckReverseLogicalChannelParameters(&x->ackReverseLogicalChannelParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(3, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_separateStack, stream);
+    PutBoolean(x->option_of_forwardMultiplexAckParameters, stream);
+    PutBoolean(x->option_of_encryptionSync, stream);
+    if (x->option_of_separateStack)
+    {
+        PutExtensionItem(EPASS Encode_NetworkAccessParameters, (uint8*)&x->separateStack, stream);
+    }
+    if (x->option_of_forwardMultiplexAckParameters)
+    {
+        PutExtensionItem(EPASS Encode_ForwardMultiplexAckParameters, (uint8*)&x->forwardMultiplexAckParameters, stream);
+    }
+    if (x->option_of_encryptionSync)
+    {
+        PutExtensionItem(EPASS Encode_EncryptionSync, (uint8*)&x->encryptionSync, stream);
+    }
+}
+
+/* <======================================================> */
+/*  PER-Encoder for ForwardMultiplexAckParameters (CHOICE)  */
+/* <======================================================> */
+void Encode_ForwardMultiplexAckParameters(PS_ForwardMultiplexAckParameters x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_H2250LogicalChannelAckParameters(x->h2250LogicalChannelAckParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_ForwardMultiplexAckParameters: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================================> */
+/*  PER-Encoder for AckReverseLogicalChannelParameters (SEQUENCE)  */
+/* <=============================================================> */
+void Encode_AckReverseLogicalChannelParameters(PS_AckReverseLogicalChannelParameters x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_replacementFor;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_portNumber, stream);
+    PutBoolean(x->option_of_ackMultiplexParameters, stream);
+    PutInteger(1, 65535, (uint32)x->reverseLogicalChannelNumber, stream);
+    if (x->option_of_portNumber)
+    {
+        PutInteger(0, 65535, (uint32)x->portNumber, stream);
+    }
+    if (x->option_of_ackMultiplexParameters)
+    {
+        Encode_AckMultiplexParameters(&x->ackMultiplexParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_replacementFor, stream);
+    if (x->option_of_replacementFor)
+    {
+        PutExtensionInteger(1, 65535, (uint32)x->replacementFor, stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for AckMultiplexParameters (CHOICE)  */
+/* <===============================================> */
+void Encode_AckMultiplexParameters(PS_AckMultiplexParameters x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_H222LogicalChannelParameters(x->h222LogicalChannelParameters, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 1:
+            PutExtensionItem(EPASS Encode_H2250LogicalChannelParameters, (uint8*)x->h2250LogicalChannelParameters, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_AckMultiplexParameters: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Encoder for OpenLogicalChannelReject (SEQUENCE)  */
+/* <===================================================> */
+void Encode_OpenLogicalChannelReject(PS_OpenLogicalChannelReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    Encode_OlcRejectCause(&x->olcRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for OlcRejectCause (CHOICE)  */
+/* <=======================================> */
+void Encode_OlcRejectCause(PS_OlcRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(6, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (unsuitableReverseParameters is NULL) */
+            break;
+        case 2:
+            /* (dataTypeNotSupported is NULL) */
+            break;
+        case 3:
+            /* (dataTypeNotAvailable is NULL) */
+            break;
+        case 4:
+            /* (unknownDataType is NULL) */
+            break;
+        case 5:
+            /* (dataTypeALCombinationNotSupported is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            PutExtensionNull(stream);
+            break;
+        case 7:
+            PutExtensionNull(stream);
+            break;
+        case 8:
+            PutExtensionNull(stream);
+            break;
+        case 9:
+            PutExtensionNull(stream);
+            break;
+        case 10:
+            PutExtensionNull(stream);
+            break;
+        case 11:
+            PutExtensionNull(stream);
+            break;
+        case 12:
+            PutExtensionNull(stream);
+            break;
+        case 13:
+            PutExtensionNull(stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_OlcRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Encoder for OpenLogicalChannelConfirm (SEQUENCE)  */
+/* <====================================================> */
+void Encode_OpenLogicalChannelConfirm(PS_OpenLogicalChannelConfirm x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================================> */
+/*  PER-Encoder for H2250LogicalChannelAckParameters (SEQUENCE)  */
+/* <===========================================================> */
+void Encode_H2250LogicalChannelAckParameters(PS_H2250LogicalChannelAckParameters x, PS_OutStream stream)
+{
+    uint16 i;
+    uint32 extension;
+
+    extension = x->option_of_flowControlToZero |
+                x->option_of_portNumber;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_nonStandard, stream);
+    PutBoolean(x->option_of_sessionID, stream);
+    PutBoolean(x->option_of_mediaChannel, stream);
+    PutBoolean(x->option_of_mediaControlChannel, stream);
+    PutBoolean(x->option_of_dynamicRTPPayloadType, stream);
+    if (x->option_of_nonStandard)
+    {
+        PutLengthDet(x->size_of_nonStandard, stream);
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Encode_NonStandardParameter(x->nonStandard + i, stream);
+        }
+    }
+    if (x->option_of_sessionID)
+    {
+        PutInteger(1, 255, (uint32)x->sessionID, stream);
+    }
+    if (x->option_of_mediaChannel)
+    {
+        Encode_TransportAddress(&x->mediaChannel, stream);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Encode_TransportAddress(&x->mediaControlChannel, stream);
+    }
+    if (x->option_of_dynamicRTPPayloadType)
+    {
+        PutInteger(96, 127, (uint32)x->dynamicRTPPayloadType, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(2, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_flowControlToZero, stream);
+    PutBoolean(x->option_of_portNumber, stream);
+    if (x->option_of_flowControlToZero)
+    {
+        PutExtensionBoolean(x->flowControlToZero, stream);
+    }
+    if (x->option_of_portNumber)
+    {
+        PutExtensionInteger(0, 65535, (uint32)x->portNumber, stream);
+    }
+}
+
+/* <==============================================> */
+/*  PER-Encoder for CloseLogicalChannel (SEQUENCE)  */
+/* <==============================================> */
+void Encode_CloseLogicalChannel(PS_CloseLogicalChannel x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_reason;
+    PutBoolean(extension, stream);
+
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    Encode_Source(&x->source, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_reason, stream);
+    if (x->option_of_reason)
+    {
+        PutExtensionItem(EPASS Encode_Reason, (uint8*)&x->reason, stream);
+    }
+}
+
+/* <===============================> */
+/*  PER-Encoder for Reason (CHOICE)  */
+/* <===============================> */
+void Encode_Reason(PS_Reason x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unknown is NULL) */
+            break;
+        case 1:
+            /* (reopen is NULL) */
+            break;
+        case 2:
+            /* (reservationFailure is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Reason: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Encoder for Source (CHOICE)  */
+/* <===============================> */
+void Encode_Source(PS_Source x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (user is NULL) */
+            break;
+        case 1:
+            /* (lcse is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Source: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================> */
+/*  PER-Encoder for CloseLogicalChannelAck (SEQUENCE)  */
+/* <=================================================> */
+void Encode_CloseLogicalChannelAck(PS_CloseLogicalChannelAck x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for RequestChannelClose (SEQUENCE)  */
+/* <==============================================> */
+void Encode_RequestChannelClose(PS_RequestChannelClose x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_qosCapability |
+                x->option_of_rccReason;
+    PutBoolean(extension, stream);
+
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(2, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_qosCapability, stream);
+    PutBoolean(x->option_of_rccReason, stream);
+    if (x->option_of_qosCapability)
+    {
+        PutExtensionItem(EPASS Encode_QOSCapability, (uint8*)&x->qosCapability, stream);
+    }
+    if (x->option_of_rccReason)
+    {
+        PutExtensionItem(EPASS Encode_RccReason, (uint8*)&x->rccReason, stream);
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for RccReason (CHOICE)  */
+/* <==================================> */
+void Encode_RccReason(PS_RccReason x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unknown is NULL) */
+            break;
+        case 1:
+            /* (normal is NULL) */
+            break;
+        case 2:
+            /* (reopen is NULL) */
+            break;
+        case 3:
+            /* (reservationFailure is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RccReason: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================> */
+/*  PER-Encoder for RequestChannelCloseAck (SEQUENCE)  */
+/* <=================================================> */
+void Encode_RequestChannelCloseAck(PS_RequestChannelCloseAck x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================================> */
+/*  PER-Encoder for RequestChannelCloseReject (SEQUENCE)  */
+/* <====================================================> */
+void Encode_RequestChannelCloseReject(PS_RequestChannelCloseReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    Encode_RccRejectCause(&x->rccRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for RccRejectCause (CHOICE)  */
+/* <=======================================> */
+void Encode_RccRejectCause(PS_RccRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RccRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Encoder for RequestChannelCloseRelease (SEQUENCE)  */
+/* <=====================================================> */
+void Encode_RequestChannelCloseRelease(PS_RequestChannelCloseRelease x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->forwardLogicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for MultiplexEntrySend (SEQUENCE)  */
+/* <=============================================> */
+void Encode_MultiplexEntrySend(PS_MultiplexEntrySend x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 15, (uint32)x->size_of_multiplexEntryDescriptors, stream);
+    for (i = 0;i < x->size_of_multiplexEntryDescriptors;++i)
+    {
+        Encode_MultiplexEntryDescriptor(x->multiplexEntryDescriptors + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for MultiplexEntryDescriptor (SEQUENCE)  */
+/* <===================================================> */
+void Encode_MultiplexEntryDescriptor(PS_MultiplexEntryDescriptor x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(x->option_of_elementList, stream);
+    PutInteger(1, 15, (uint32)x->multiplexTableEntryNumber, stream);
+    if (x->option_of_elementList)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_elementList, stream);
+        for (i = 0;i < x->size_of_elementList;++i)
+        {
+            Encode_MultiplexElement(x->elementList + i, stream);
+        }
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for MultiplexElement (SEQUENCE)  */
+/* <===========================================> */
+void Encode_MultiplexElement(PS_MultiplexElement x, PS_OutStream stream)
+{
+    Encode_MuxType(&x->muxType, stream);
+    Encode_RepeatCount(&x->repeatCount, stream);
+}
+
+/* <====================================> */
+/*  PER-Encoder for RepeatCount (CHOICE)  */
+/* <====================================> */
+void Encode_RepeatCount(PS_RepeatCount x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->finite, stream);
+            break;
+        case 1:
+            /* (untilClosingFlag is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_RepeatCount: Illegal CHOICE index");
+    }
+}
+
+/* <================================> */
+/*  PER-Encoder for MuxType (CHOICE)  */
+/* <================================> */
+void Encode_MuxType(PS_MuxType x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(0, 65535, (uint32)x->logicalChannelNumber, stream);
+            break;
+        case 1:
+            PutInteger(2, 255, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_MultiplexElement(x->subElementList + i, stream);
+            }
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MuxType: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Encoder for MultiplexEntrySendAck (SEQUENCE)  */
+/* <================================================> */
+void Encode_MultiplexEntrySendAck(PS_MultiplexEntrySendAck x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 15, (uint32)x->size_of_multiplexTableEntryNumber, stream);
+    for (i = 0;i < x->size_of_multiplexTableEntryNumber;++i)
+    {
+        PutInteger(1, 15, (uint32)x->multiplexTableEntryNumber[i], stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for MultiplexEntrySendReject (SEQUENCE)  */
+/* <===================================================> */
+void Encode_MultiplexEntrySendReject(PS_MultiplexEntrySendReject x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 15, (uint32)x->size_of_rejectionDescriptions, stream);
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        Encode_MultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================================> */
+/*  PER-Encoder for MultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <==============================================================> */
+void Encode_MultiplexEntryRejectionDescriptions(PS_MultiplexEntryRejectionDescriptions x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->multiplexTableEntryNumber, stream);
+    Encode_MeRejectCause(&x->meRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for MeRejectCause (CHOICE)  */
+/* <======================================> */
+void Encode_MeRejectCause(PS_MeRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecifiedCause is NULL) */
+            break;
+        case 1:
+            /* (descriptorTooComplex is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MeRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Encoder for MultiplexEntrySendRelease (SEQUENCE)  */
+/* <====================================================> */
+void Encode_MultiplexEntrySendRelease(PS_MultiplexEntrySendRelease x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->size_of_multiplexTableEntryNumber, stream);
+    for (i = 0;i < x->size_of_multiplexTableEntryNumber;++i)
+    {
+        PutInteger(1, 15, (uint32)x->multiplexTableEntryNumber[i], stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for RequestMultiplexEntry (SEQUENCE)  */
+/* <================================================> */
+void Encode_RequestMultiplexEntry(PS_RequestMultiplexEntry x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->size_of_entryNumbers, stream);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        PutInteger(1, 15, (uint32)x->entryNumbers[i], stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for RequestMultiplexEntryAck (SEQUENCE)  */
+/* <===================================================> */
+void Encode_RequestMultiplexEntryAck(PS_RequestMultiplexEntryAck x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->size_of_entryNumbers, stream);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        PutInteger(1, 15, (uint32)x->entryNumbers[i], stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Encoder for RequestMultiplexEntryReject (SEQUENCE)  */
+/* <======================================================> */
+void Encode_RequestMultiplexEntryReject(PS_RequestMultiplexEntryReject x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->size_of_entryNumbers, stream);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        PutInteger(1, 15, (uint32)x->entryNumbers[i], stream);
+    }
+    PutInteger(1, 15, (uint32)x->size_of_rejectionDescriptions, stream);
+    for (i = 0;i < x->size_of_rejectionDescriptions;++i)
+    {
+        Encode_RequestMultiplexEntryRejectionDescriptions(x->rejectionDescriptions + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================================> */
+/*  PER-Encoder for RequestMultiplexEntryRejectionDescriptions (SEQUENCE)  */
+/* <=====================================================================> */
+void Encode_RequestMultiplexEntryRejectionDescriptions(PS_RequestMultiplexEntryRejectionDescriptions x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->multiplexTableEntryNumber, stream);
+    Encode_RmeRejectCause(&x->rmeRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for RmeRejectCause (CHOICE)  */
+/* <=======================================> */
+void Encode_RmeRejectCause(PS_RmeRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecifiedCause is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RmeRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for RequestMultiplexEntryRelease (SEQUENCE)  */
+/* <=======================================================> */
+void Encode_RequestMultiplexEntryRelease(PS_RequestMultiplexEntryRelease x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 15, (uint32)x->size_of_entryNumbers, stream);
+    for (i = 0;i < x->size_of_entryNumbers;++i)
+    {
+        PutInteger(1, 15, (uint32)x->entryNumbers[i], stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for RequestMode (SEQUENCE)  */
+/* <======================================> */
+void Encode_RequestMode(PS_RequestMode x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 256, (uint32)x->size_of_requestedModes, stream);
+    for (i = 0;i < x->size_of_requestedModes;++i)
+    {
+        Encode_ModeDescription(x->requestedModes + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Encoder for RequestModeAck (SEQUENCE)  */
+/* <=========================================> */
+void Encode_RequestModeAck(PS_RequestModeAck x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    Encode_Response(&x->response, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Encoder for Response (CHOICE)  */
+/* <=================================> */
+void Encode_Response(PS_Response x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (willTransmitMostPreferredMode is NULL) */
+            break;
+        case 1:
+            /* (willTransmitLessPreferredMode is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Response: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Encoder for RequestModeReject (SEQUENCE)  */
+/* <============================================> */
+void Encode_RequestModeReject(PS_RequestModeReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    Encode_RmRejectCause(&x->rmRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for RmRejectCause (CHOICE)  */
+/* <======================================> */
+void Encode_RmRejectCause(PS_RmRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (modeUnavailable is NULL) */
+            break;
+        case 1:
+            /* (multipointConstraint is NULL) */
+            break;
+        case 2:
+            /* (requestDenied is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RmRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for RequestModeRelease (SEQUENCE)  */
+/* <=============================================> */
+void Encode_RequestModeRelease(PS_RequestModeRelease x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for ModeDescription (SET-OF)  */
+/* <========================================> */
+void Encode_ModeDescription(PS_ModeDescription x, PS_OutStream stream)
+{
+    uint16 i;
+    PutInteger(1, 256, (uint32)x->size, stream);
+    for (i = 0;i < x->size;++i)
+    {
+        Encode_ModeElement(x->item + i, stream);
+    }
+}
+
+/* <======================================> */
+/*  PER-Encoder for ModeElement (SEQUENCE)  */
+/* <======================================> */
+void Encode_ModeElement(PS_ModeElement x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_v76ModeParameters |
+                x->option_of_h2250ModeParameters |
+                x->option_of_genericModeParameters;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_h223ModeParameters, stream);
+    Encode_ModeType(&x->modeType, stream);
+    if (x->option_of_h223ModeParameters)
+    {
+        Encode_H223ModeParameters(&x->h223ModeParameters, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(3, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_v76ModeParameters, stream);
+    PutBoolean(x->option_of_h2250ModeParameters, stream);
+    PutBoolean(x->option_of_genericModeParameters, stream);
+    if (x->option_of_v76ModeParameters)
+    {
+        PutExtensionItem(EPASS Encode_V76ModeParameters, (uint8*)&x->v76ModeParameters, stream);
+    }
+    if (x->option_of_h2250ModeParameters)
+    {
+        PutExtensionItem(EPASS Encode_H2250ModeParameters, (uint8*)&x->h2250ModeParameters, stream);
+    }
+    if (x->option_of_genericModeParameters)
+    {
+        PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)&x->genericModeParameters, stream);
+    }
+}
+
+/* <=================================> */
+/*  PER-Encoder for ModeType (CHOICE)  */
+/* <=================================> */
+void Encode_ModeType(PS_ModeType x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_VideoMode(x->videoMode, stream);
+            break;
+        case 2:
+            Encode_AudioMode(x->audioMode, stream);
+            break;
+        case 3:
+            Encode_DataMode(x->dataMode, stream);
+            break;
+        case 4:
+            Encode_EncryptionMode(x->encryptionMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            PutExtensionItem(EPASS Encode_H235Mode, (uint8*)x->h235Mode, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ModeType: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Encoder for H235Mode (SEQUENCE)  */
+/* <===================================> */
+void Encode_H235Mode(PS_H235Mode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_EncryptionAuthenticationAndIntegrity(&x->encryptionAuthenticationAndIntegrity, stream);
+    Encode_MediaMode(&x->mediaMode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for MediaMode (CHOICE)  */
+/* <==================================> */
+void Encode_MediaMode(PS_MediaMode x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_VideoMode(x->videoMode, stream);
+            break;
+        case 2:
+            Encode_AudioMode(x->audioMode, stream);
+            break;
+        case 3:
+            Encode_DataMode(x->dataMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MediaMode: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H223ModeParameters (SEQUENCE)  */
+/* <=============================================> */
+void Encode_H223ModeParameters(PS_H223ModeParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_ModeAdaptationLayerType(&x->modeAdaptationLayerType, stream);
+    PutBoolean(x->segmentableFlag, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for ModeAdaptationLayerType (CHOICE)  */
+/* <================================================> */
+void Encode_ModeAdaptationLayerType(PS_ModeAdaptationLayerType x, PS_OutStream stream)
+{
+    PutChoiceIndex(6, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (al1Framed is NULL) */
+            break;
+        case 2:
+            /* (al1NotFramed is NULL) */
+            break;
+        case 3:
+            /* (al2WithoutSequenceNumbers is NULL) */
+            break;
+        case 4:
+            /* (al2WithSequenceNumbers is NULL) */
+            break;
+        case 5:
+            Encode_ModeAl3(x->modeAl3, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 6:
+            PutExtensionItem(EPASS Encode_H223AL1MParameters, (uint8*)x->al1M, stream);
+            break;
+        case 7:
+            PutExtensionItem(EPASS Encode_H223AL2MParameters, (uint8*)x->al2M, stream);
+            break;
+        case 8:
+            PutExtensionItem(EPASS Encode_H223AL3MParameters, (uint8*)x->al3M, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ModeAdaptationLayerType: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for ModeAl3 (SEQUENCE)  */
+/* <==================================> */
+void Encode_ModeAl3(PS_ModeAl3 x, PS_OutStream stream)
+{
+    PutInteger(0, 2, (uint32)x->controlFieldOctets, stream);
+    PutInteger(0, 16777215, (uint32)x->sendBufferSize, stream);
+}
+
+/* <==========================================> */
+/*  PER-Encoder for V76ModeParameters (CHOICE)  */
+/* <==========================================> */
+void Encode_V76ModeParameters(PS_V76ModeParameters x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (suspendResumewAddress is NULL) */
+            break;
+        case 1:
+            /* (suspendResumewoAddress is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_V76ModeParameters: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Encoder for H2250ModeParameters (SEQUENCE)  */
+/* <==============================================> */
+void Encode_H2250ModeParameters(PS_H2250ModeParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_redundancyEncodingMode, stream);
+    if (x->option_of_redundancyEncodingMode)
+    {
+        Encode_RedundancyEncodingMode(&x->redundancyEncodingMode, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for RedundancyEncodingMode (SEQUENCE)  */
+/* <=================================================> */
+void Encode_RedundancyEncodingMode(PS_RedundancyEncodingMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_secondaryEncoding, stream);
+    Encode_RedundancyEncodingMethod(&x->redundancyEncodingMethod, stream);
+    if (x->option_of_secondaryEncoding)
+    {
+        Encode_SecondaryEncoding(&x->secondaryEncoding, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Encoder for SecondaryEncoding (CHOICE)  */
+/* <==========================================> */
+void Encode_SecondaryEncoding(PS_SecondaryEncoding x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_AudioMode(x->audioData, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_SecondaryEncoding: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for VideoMode (CHOICE)  */
+/* <==================================> */
+void Encode_VideoMode(PS_VideoMode x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_H261VideoMode(x->h261VideoMode, stream);
+            break;
+        case 2:
+            Encode_H262VideoMode(x->h262VideoMode, stream);
+            break;
+        case 3:
+            Encode_H263VideoMode(x->h263VideoMode, stream);
+            break;
+        case 4:
+            Encode_IS11172VideoMode(x->is11172VideoMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 5:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericVideoMode, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_VideoMode: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for H261VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Encode_H261VideoMode(PS_H261VideoMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_Resolution(&x->resolution, stream);
+    PutInteger(1, 19200, (uint32)x->bitRate, stream);
+    PutBoolean(x->stillImageTransmission, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Encoder for Resolution (CHOICE)  */
+/* <===================================> */
+void Encode_Resolution(PS_Resolution x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (qcif is NULL) */
+            break;
+        case 1:
+            /* (cif is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Resolution: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for H262VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Encode_H262VideoMode(PS_H262VideoMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_videoBitRate, stream);
+    PutBoolean(x->option_of_vbvBufferSize, stream);
+    PutBoolean(x->option_of_samplesPerLine, stream);
+    PutBoolean(x->option_of_linesPerFrame, stream);
+    PutBoolean(x->option_of_framesPerSecond, stream);
+    PutBoolean(x->option_of_luminanceSampleRate, stream);
+    Encode_ProfileAndLevel(&x->profileAndLevel, stream);
+    if (x->option_of_videoBitRate)
+    {
+        PutInteger(0, 1073741823, (uint32)x->videoBitRate, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        PutInteger(0, 262143, (uint32)x->vbvBufferSize, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        PutInteger(0, 16383, (uint32)x->samplesPerLine, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        PutInteger(0, 16383, (uint32)x->linesPerFrame, stream);
+    }
+    if (x->option_of_framesPerSecond)
+    {
+        PutInteger(0, 15, (uint32)x->framesPerSecond, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->luminanceSampleRate, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for ProfileAndLevel (CHOICE)  */
+/* <========================================> */
+void Encode_ProfileAndLevel(PS_ProfileAndLevel x, PS_OutStream stream)
+{
+    PutChoiceIndex(11, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (profileAndLevel_SPatML is NULL) */
+            break;
+        case 1:
+            /* (profileAndLevel_MPatLL is NULL) */
+            break;
+        case 2:
+            /* (profileAndLevel_MPatML is NULL) */
+            break;
+        case 3:
+            /* (profileAndLevel_MPatH_14 is NULL) */
+            break;
+        case 4:
+            /* (profileAndLevel_MPatHL is NULL) */
+            break;
+        case 5:
+            /* (profileAndLevel_SNRatLL is NULL) */
+            break;
+        case 6:
+            /* (profileAndLevel_SNRatML is NULL) */
+            break;
+        case 7:
+            /* (profileAndLevel_SpatialatH_14 is NULL) */
+            break;
+        case 8:
+            /* (profileAndLevel_HPatML is NULL) */
+            break;
+        case 9:
+            /* (profileAndLevel_HPatH_14 is NULL) */
+            break;
+        case 10:
+            /* (profileAndLevel_HPatHL is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_ProfileAndLevel: Illegal CHOICE index");
+    }
+}
+
+/* <========================================> */
+/*  PER-Encoder for H263VideoMode (SEQUENCE)  */
+/* <========================================> */
+void Encode_H263VideoMode(PS_H263VideoMode x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_errorCompensation |
+                x->option_of_enhancementLayerInfo |
+                x->option_of_h263Options;
+    PutBoolean(extension, stream);
+
+    Encode_H263Resolution(&x->h263Resolution, stream);
+    PutInteger(1, 19200, (uint32)x->bitRate, stream);
+    PutBoolean(x->unrestrictedVector, stream);
+    PutBoolean(x->arithmeticCoding, stream);
+    PutBoolean(x->advancedPrediction, stream);
+    PutBoolean(x->pbFrames, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(3, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_errorCompensation, stream);
+    PutBoolean(x->option_of_enhancementLayerInfo, stream);
+    PutBoolean(x->option_of_h263Options, stream);
+    if (x->option_of_errorCompensation)
+    {
+        PutExtensionBoolean(x->errorCompensation, stream);
+    }
+    if (x->option_of_enhancementLayerInfo)
+    {
+        PutExtensionItem(EPASS Encode_EnhancementLayerInfo, (uint8*)&x->enhancementLayerInfo, stream);
+    }
+    if (x->option_of_h263Options)
+    {
+        PutExtensionItem(EPASS Encode_H263Options, (uint8*)&x->h263Options, stream);
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for H263Resolution (CHOICE)  */
+/* <=======================================> */
+void Encode_H263Resolution(PS_H263Resolution x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (sqcif is NULL) */
+            break;
+        case 1:
+            /* (qcif is NULL) */
+            break;
+        case 2:
+            /* (cif is NULL) */
+            break;
+        case 3:
+            /* (cif4 is NULL) */
+            break;
+        case 4:
+            /* (cif16 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_H263Resolution: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for IS11172VideoMode (SEQUENCE)  */
+/* <===========================================> */
+void Encode_IS11172VideoMode(PS_IS11172VideoMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_videoBitRate, stream);
+    PutBoolean(x->option_of_vbvBufferSize, stream);
+    PutBoolean(x->option_of_samplesPerLine, stream);
+    PutBoolean(x->option_of_linesPerFrame, stream);
+    PutBoolean(x->option_of_pictureRate, stream);
+    PutBoolean(x->option_of_luminanceSampleRate, stream);
+    PutBoolean(x->constrainedBitstream, stream);
+    if (x->option_of_videoBitRate)
+    {
+        PutInteger(0, 1073741823, (uint32)x->videoBitRate, stream);
+    }
+    if (x->option_of_vbvBufferSize)
+    {
+        PutInteger(0, 262143, (uint32)x->vbvBufferSize, stream);
+    }
+    if (x->option_of_samplesPerLine)
+    {
+        PutInteger(0, 16383, (uint32)x->samplesPerLine, stream);
+    }
+    if (x->option_of_linesPerFrame)
+    {
+        PutInteger(0, 16383, (uint32)x->linesPerFrame, stream);
+    }
+    if (x->option_of_pictureRate)
+    {
+        PutInteger(0, 15, (uint32)x->pictureRate, stream);
+    }
+    if (x->option_of_luminanceSampleRate)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->luminanceSampleRate, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for AudioMode (CHOICE)  */
+/* <==================================> */
+void Encode_AudioMode(PS_AudioMode x, PS_OutStream stream)
+{
+    PutChoiceIndex(14, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (g711Alaw64k is NULL) */
+            break;
+        case 2:
+            /* (g711Alaw56k is NULL) */
+            break;
+        case 3:
+            /* (g711Ulaw64k is NULL) */
+            break;
+        case 4:
+            /* (g711Ulaw56k is NULL) */
+            break;
+        case 5:
+            /* (g722_64k is NULL) */
+            break;
+        case 6:
+            /* (g722_56k is NULL) */
+            break;
+        case 7:
+            /* (g722_48k is NULL) */
+            break;
+        case 8:
+            /* (g728 is NULL) */
+            break;
+        case 9:
+            /* (g729 is NULL) */
+            break;
+        case 10:
+            /* (g729AnnexA is NULL) */
+            break;
+        case 11:
+            Encode_ModeG7231(x->modeG7231, stream);
+            break;
+        case 12:
+            Encode_IS11172AudioMode(x->is11172AudioMode, stream);
+            break;
+        case 13:
+            Encode_IS13818AudioMode(x->is13818AudioMode, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            PutExtensionInteger(1, 256, (uint32)x->g729wAnnexB, stream);
+            break;
+        case 15:
+            PutExtensionInteger(1, 256, (uint32)x->g729AnnexAwAnnexB, stream);
+            break;
+        case 16:
+            PutExtensionItem(EPASS Encode_G7231AnnexCMode, (uint8*)x->g7231AnnexCMode, stream);
+            break;
+        case 17:
+            PutExtensionItem(EPASS Encode_GSMAudioCapability, (uint8*)x->gsmFullRate, stream);
+            break;
+        case 18:
+            PutExtensionItem(EPASS Encode_GSMAudioCapability, (uint8*)x->gsmHalfRate, stream);
+            break;
+        case 19:
+            PutExtensionItem(EPASS Encode_GSMAudioCapability, (uint8*)x->gsmEnhancedFullRate, stream);
+            break;
+        case 20:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericAudioMode, stream);
+            break;
+        case 21:
+            PutExtensionItem(EPASS Encode_G729Extensions, (uint8*)x->g729Extensions, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_AudioMode: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for ModeG7231 (CHOICE)  */
+/* <==================================> */
+void Encode_ModeG7231(PS_ModeG7231 x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noSilenceSuppressionLowRate is NULL) */
+            break;
+        case 1:
+            /* (noSilenceSuppressionHighRate is NULL) */
+            break;
+        case 2:
+            /* (silenceSuppressionLowRate is NULL) */
+            break;
+        case 3:
+            /* (silenceSuppressionHighRate is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ModeG7231: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for IS11172AudioMode (SEQUENCE)  */
+/* <===========================================> */
+void Encode_IS11172AudioMode(PS_IS11172AudioMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_AudioLayer(&x->audioLayer, stream);
+    Encode_AudioSampling(&x->audioSampling, stream);
+    Encode_MultichannelType(&x->multichannelType, stream);
+    PutInteger(1, 448, (uint32)x->bitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=========================================> */
+/*  PER-Encoder for MultichannelType (CHOICE)  */
+/* <=========================================> */
+void Encode_MultichannelType(PS_MultichannelType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (singleChannel is NULL) */
+            break;
+        case 1:
+            /* (twoChannelStereo is NULL) */
+            break;
+        case 2:
+            /* (twoChannelDual is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MultichannelType: Illegal CHOICE index");
+    }
+}
+
+/* <======================================> */
+/*  PER-Encoder for AudioSampling (CHOICE)  */
+/* <======================================> */
+void Encode_AudioSampling(PS_AudioSampling x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioSampling32k is NULL) */
+            break;
+        case 1:
+            /* (audioSampling44k1 is NULL) */
+            break;
+        case 2:
+            /* (audioSampling48k is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_AudioSampling: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Encoder for AudioLayer (CHOICE)  */
+/* <===================================> */
+void Encode_AudioLayer(PS_AudioLayer x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioLayer1 is NULL) */
+            break;
+        case 1:
+            /* (audioLayer2 is NULL) */
+            break;
+        case 2:
+            /* (audioLayer3 is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_AudioLayer: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for IS13818AudioMode (SEQUENCE)  */
+/* <===========================================> */
+void Encode_IS13818AudioMode(PS_IS13818AudioMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_Is13818AudioLayer(&x->is13818AudioLayer, stream);
+    Encode_Is13818AudioSampling(&x->is13818AudioSampling, stream);
+    Encode_Is13818MultichannelType(&x->is13818MultichannelType, stream);
+    PutBoolean(x->lowFrequencyEnhancement, stream);
+    PutBoolean(x->multilingual, stream);
+    PutInteger(1, 1130, (uint32)x->bitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================================> */
+/*  PER-Encoder for Is13818MultichannelType (CHOICE)  */
+/* <================================================> */
+void Encode_Is13818MultichannelType(PS_Is13818MultichannelType x, PS_OutStream stream)
+{
+    PutChoiceIndex(10, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (singleChannel is NULL) */
+            break;
+        case 1:
+            /* (twoChannelStereo is NULL) */
+            break;
+        case 2:
+            /* (twoChannelDual is NULL) */
+            break;
+        case 3:
+            /* (threeChannels2_1 is NULL) */
+            break;
+        case 4:
+            /* (threeChannels3_0 is NULL) */
+            break;
+        case 5:
+            /* (fourChannels2_0_2_0 is NULL) */
+            break;
+        case 6:
+            /* (fourChannels2_2 is NULL) */
+            break;
+        case 7:
+            /* (fourChannels3_1 is NULL) */
+            break;
+        case 8:
+            /* (fiveChannels3_0_2_0 is NULL) */
+            break;
+        case 9:
+            /* (fiveChannels3_2 is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Is13818MultichannelType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for Is13818AudioSampling (CHOICE)  */
+/* <=============================================> */
+void Encode_Is13818AudioSampling(PS_Is13818AudioSampling x, PS_OutStream stream)
+{
+    PutChoiceIndex(6, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioSampling16k is NULL) */
+            break;
+        case 1:
+            /* (audioSampling22k05 is NULL) */
+            break;
+        case 2:
+            /* (audioSampling24k is NULL) */
+            break;
+        case 3:
+            /* (audioSampling32k is NULL) */
+            break;
+        case 4:
+            /* (audioSampling44k1 is NULL) */
+            break;
+        case 5:
+            /* (audioSampling48k is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Is13818AudioSampling: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for Is13818AudioLayer (CHOICE)  */
+/* <==========================================> */
+void Encode_Is13818AudioLayer(PS_Is13818AudioLayer x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (audioLayer1 is NULL) */
+            break;
+        case 1:
+            /* (audioLayer2 is NULL) */
+            break;
+        case 2:
+            /* (audioLayer3 is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_Is13818AudioLayer: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for G7231AnnexCMode (SEQUENCE)  */
+/* <==========================================> */
+void Encode_G7231AnnexCMode(PS_G7231AnnexCMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 256, (uint32)x->maxAl_sduAudioFrames, stream);
+    PutBoolean(x->silenceSuppression, stream);
+    Encode_ModeG723AnnexCAudioMode(&x->modeG723AnnexCAudioMode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for ModeG723AnnexCAudioMode (SEQUENCE)  */
+/* <==================================================> */
+void Encode_ModeG723AnnexCAudioMode(PS_ModeG723AnnexCAudioMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(27, 78, (uint32)x->highRateMode0, stream);
+    PutInteger(27, 78, (uint32)x->highRateMode1, stream);
+    PutInteger(23, 66, (uint32)x->lowRateMode0, stream);
+    PutInteger(23, 66, (uint32)x->lowRateMode1, stream);
+    PutInteger(6, 17, (uint32)x->sidMode0, stream);
+    PutInteger(6, 17, (uint32)x->sidMode1, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================> */
+/*  PER-Encoder for DataMode (SEQUENCE)  */
+/* <===================================> */
+void Encode_DataMode(PS_DataMode x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_DmApplication(&x->dmApplication, stream);
+    PutInteger(0, 0xffffffff, (uint32)x->bitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for DmApplication (CHOICE)  */
+/* <======================================> */
+void Encode_DmApplication(PS_DmApplication x, PS_OutStream stream)
+{
+    PutChoiceIndex(10, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_DataProtocolCapability(x->t120, stream);
+            break;
+        case 2:
+            Encode_DataProtocolCapability(x->dsm_cc, stream);
+            break;
+        case 3:
+            Encode_DataProtocolCapability(x->userData, stream);
+            break;
+        case 4:
+            Encode_DataProtocolCapability(x->t84, stream);
+            break;
+        case 5:
+            Encode_DataProtocolCapability(x->t434, stream);
+            break;
+        case 6:
+            Encode_DataProtocolCapability(x->h224, stream);
+            break;
+        case 7:
+            Encode_DmNlpid(x->dmNlpid, stream);
+            break;
+        case 8:
+            /* (dsvdControl is NULL) */
+            break;
+        case 9:
+            Encode_DataProtocolCapability(x->h222DataPartitioning, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            PutExtensionItem(EPASS Encode_DataProtocolCapability, (uint8*)x->t30fax, stream);
+            break;
+        case 11:
+            PutExtensionItem(EPASS Encode_DataProtocolCapability, (uint8*)x->t140, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_DmT38fax, (uint8*)x->dmT38fax, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_GenericCapability, (uint8*)x->genericDataMode, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_DmApplication: Illegal CHOICE index");
+    }
+}
+
+/* <===================================> */
+/*  PER-Encoder for DmT38fax (SEQUENCE)  */
+/* <===================================> */
+void Encode_DmT38fax(PS_DmT38fax x, PS_OutStream stream)
+{
+    Encode_DataProtocolCapability(&x->t38FaxProtocol, stream);
+    Encode_T38FaxProfile(&x->t38FaxProfile, stream);
+}
+
+/* <==================================> */
+/*  PER-Encoder for DmNlpid (SEQUENCE)  */
+/* <==================================> */
+void Encode_DmNlpid(PS_DmNlpid x, PS_OutStream stream)
+{
+    Encode_DataProtocolCapability(&x->nlpidProtocol, stream);
+    PutOctetString(1, 0, 0, &x->nlpidData, stream);
+}
+
+/* <=======================================> */
+/*  PER-Encoder for EncryptionMode (CHOICE)  */
+/* <=======================================> */
+void Encode_EncryptionMode(PS_EncryptionMode x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (h233Encryption is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_EncryptionMode: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Encoder for RoundTripDelayRequest (SEQUENCE)  */
+/* <================================================> */
+void Encode_RoundTripDelayRequest(PS_RoundTripDelayRequest x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for RoundTripDelayResponse (SEQUENCE)  */
+/* <=================================================> */
+void Encode_RoundTripDelayResponse(PS_RoundTripDelayResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================================> */
+/*  PER-Encoder for MaintenanceLoopRequest (SEQUENCE)  */
+/* <=================================================> */
+void Encode_MaintenanceLoopRequest(PS_MaintenanceLoopRequest x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_MlRequestType(&x->mlRequestType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for MlRequestType (CHOICE)  */
+/* <======================================> */
+void Encode_MlRequestType(PS_MlRequestType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            PutInteger(1, 65535, (uint32)x->mediaLoop, stream);
+            break;
+        case 2:
+            PutInteger(1, 65535, (uint32)x->logicalChannelLoop, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MlRequestType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for MaintenanceLoopAck (SEQUENCE)  */
+/* <=============================================> */
+void Encode_MaintenanceLoopAck(PS_MaintenanceLoopAck x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_MlAckType(&x->mlAckType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for MlAckType (CHOICE)  */
+/* <==================================> */
+void Encode_MlAckType(PS_MlAckType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            PutInteger(1, 65535, (uint32)x->mediaLoop, stream);
+            break;
+        case 2:
+            PutInteger(1, 65535, (uint32)x->logicalChannelLoop, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MlAckType: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Encoder for MaintenanceLoopReject (SEQUENCE)  */
+/* <================================================> */
+void Encode_MaintenanceLoopReject(PS_MaintenanceLoopReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_MlRejectType(&x->mlRejectType, stream);
+    Encode_MlRejectCause(&x->mlRejectCause, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================> */
+/*  PER-Encoder for MlRejectCause (CHOICE)  */
+/* <======================================> */
+void Encode_MlRejectCause(PS_MlRejectCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (canNotPerformLoop is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MlRejectCause: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for MlRejectType (CHOICE)  */
+/* <=====================================> */
+void Encode_MlRejectType(PS_MlRejectType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (systemLoop is NULL) */
+            break;
+        case 1:
+            PutInteger(1, 65535, (uint32)x->mediaLoop, stream);
+            break;
+        case 2:
+            PutInteger(1, 65535, (uint32)x->logicalChannelLoop, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MlRejectType: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Encoder for MaintenanceLoopOffCommand (SEQUENCE)  */
+/* <====================================================> */
+void Encode_MaintenanceLoopOffCommand(PS_MaintenanceLoopOffCommand x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for CommunicationModeCommand (SEQUENCE)  */
+/* <===================================================> */
+void Encode_CommunicationModeCommand(PS_CommunicationModeCommand x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 256, (uint32)x->size_of_communicationModeTable, stream);
+    for (i = 0;i < x->size_of_communicationModeTable;++i)
+    {
+        Encode_CommunicationModeTableEntry(x->communicationModeTable + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for CommunicationModeRequest (SEQUENCE)  */
+/* <===================================================> */
+void Encode_CommunicationModeRequest(PS_CommunicationModeRequest x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for CommunicationModeResponse (CHOICE)  */
+/* <==================================================> */
+void Encode_CommunicationModeResponse(PS_CommunicationModeResponse x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(1, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 256, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_CommunicationModeTableEntry(x->communicationModeTable + i, stream);
+            }
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CommunicationModeResponse: Illegal CHOICE index");
+    }
+}
+
+/* <======================================================> */
+/*  PER-Encoder for CommunicationModeTableEntry (SEQUENCE)  */
+/* <======================================================> */
+void Encode_CommunicationModeTableEntry(PS_CommunicationModeTableEntry x, PS_OutStream stream)
+{
+    uint16 i;
+    uint32 extension;
+
+    extension = x->option_of_redundancyEncoding |
+                x->option_of_sessionDependency |
+                x->option_of_destination;
+    PutBoolean(extension, stream);
+
+    PutBoolean(x->option_of_nonStandard, stream);
+    PutBoolean(x->option_of_associatedSessionID, stream);
+    PutBoolean(x->option_of_terminalLabel, stream);
+    PutBoolean(x->option_of_mediaChannel, stream);
+    PutBoolean(x->option_of_mediaGuaranteedDelivery, stream);
+    PutBoolean(x->option_of_mediaControlChannel, stream);
+    PutBoolean(x->option_of_mediaControlGuaranteedDelivery, stream);
+    if (x->option_of_nonStandard)
+    {
+        PutLengthDet(x->size_of_nonStandard, stream);
+        for (i = 0;i < x->size_of_nonStandard;++i)
+        {
+            Encode_NonStandardParameter(x->nonStandard + i, stream);
+        }
+    }
+    PutInteger(1, 255, (uint32)x->sessionID, stream);
+    if (x->option_of_associatedSessionID)
+    {
+        PutInteger(1, 255, (uint32)x->associatedSessionID, stream);
+    }
+    if (x->option_of_terminalLabel)
+    {
+        Encode_TerminalLabel(&x->terminalLabel, stream);
+    }
+    PutCharString("BMPString", 0, 1, 128, NULL, &x->sessionDescription, stream);
+    Encode_CmtDataType(&x->cmtDataType, stream);
+    if (x->option_of_mediaChannel)
+    {
+        Encode_TransportAddress(&x->mediaChannel, stream);
+    }
+    if (x->option_of_mediaGuaranteedDelivery)
+    {
+        PutBoolean(x->mediaGuaranteedDelivery, stream);
+    }
+    if (x->option_of_mediaControlChannel)
+    {
+        Encode_TransportAddress(&x->mediaControlChannel, stream);
+    }
+    if (x->option_of_mediaControlGuaranteedDelivery)
+    {
+        PutBoolean(x->mediaControlGuaranteedDelivery, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(3, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_redundancyEncoding, stream);
+    PutBoolean(x->option_of_sessionDependency, stream);
+    PutBoolean(x->option_of_destination, stream);
+    if (x->option_of_redundancyEncoding)
+    {
+        PutExtensionItem(EPASS Encode_RedundancyEncoding, (uint8*)&x->redundancyEncoding, stream);
+    }
+    if (x->option_of_sessionDependency)
+    {
+        PutExtensionInteger(1, 255, (uint32)x->sessionDependency, stream);
+    }
+    if (x->option_of_destination)
+    {
+        PutExtensionItem(EPASS Encode_TerminalLabel, (uint8*)&x->destination, stream);
+    }
+}
+
+/* <====================================> */
+/*  PER-Encoder for CmtDataType (CHOICE)  */
+/* <====================================> */
+void Encode_CmtDataType(PS_CmtDataType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_VideoCapability(x->videoData, stream);
+            break;
+        case 1:
+            Encode_AudioCapability(x->audioData, stream);
+            break;
+        case 2:
+            Encode_DataApplicationCapability(x->data, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CmtDataType: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for ConferenceRequest (CHOICE)  */
+/* <==========================================> */
+void Encode_ConferenceRequest(PS_ConferenceRequest x, PS_OutStream stream)
+{
+    PutChoiceIndex(8, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (terminalListRequest is NULL) */
+            break;
+        case 1:
+            /* (makeMeChair is NULL) */
+            break;
+        case 2:
+            /* (cancelMakeMeChair is NULL) */
+            break;
+        case 3:
+            Encode_TerminalLabel(x->dropTerminal, stream);
+            break;
+        case 4:
+            Encode_TerminalLabel(x->requestTerminalID, stream);
+            break;
+        case 5:
+            /* (enterH243Password is NULL) */
+            break;
+        case 6:
+            /* (enterH243TerminalID is NULL) */
+            break;
+        case 7:
+            /* (enterH243ConferenceID is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            PutExtensionNull(stream);
+            break;
+        case 9:
+            PutExtensionNull(stream);
+            break;
+        case 10:
+            PutExtensionItem(EPASS Encode_RequestTerminalCertificate, (uint8*)x->requestTerminalCertificate, stream);
+            break;
+        case 11:
+            PutExtensionInteger(1, 65535, (uint32)x->broadcastMyLogicalChannel, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_TerminalLabel, (uint8*)x->makeTerminalBroadcaster, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_TerminalLabel, (uint8*)x->sendThisSource, stream);
+            break;
+        case 14:
+            PutExtensionNull(stream);
+            break;
+        case 15:
+            PutExtensionItem(EPASS Encode_RemoteMCRequest, (uint8*)x->remoteMCRequest, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ConferenceRequest: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Encoder for RequestTerminalCertificate (SEQUENCE)  */
+/* <=====================================================> */
+void Encode_RequestTerminalCertificate(PS_RequestTerminalCertificate x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_terminalLabel, stream);
+    PutBoolean(x->option_of_certSelectionCriteria, stream);
+    PutBoolean(x->option_of_sRandom, stream);
+    if (x->option_of_terminalLabel)
+    {
+        Encode_TerminalLabel(&x->terminalLabel, stream);
+    }
+    if (x->option_of_certSelectionCriteria)
+    {
+        Encode_CertSelectionCriteria(&x->certSelectionCriteria, stream);
+    }
+    if (x->option_of_sRandom)
+    {
+        PutInteger(1, 0xffffffff, (uint32)x->sRandom, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for CertSelectionCriteria (SEQUENCE-OF)  */
+/* <===================================================> */
+void Encode_CertSelectionCriteria(PS_CertSelectionCriteria x, PS_OutStream stream)
+{
+    uint16 i;
+    PutInteger(1, 16, (uint32)x->size, stream);
+    for (i = 0;i < x->size;++i)
+    {
+        Encode_Criteria(x->item + i, stream);
+    }
+}
+
+/* <===================================> */
+/*  PER-Encoder for Criteria (SEQUENCE)  */
+/* <===================================> */
+void Encode_Criteria(PS_Criteria x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutObjectID(&x->field, stream);
+    PutOctetString(0, 1, 65535, &x->value, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for TerminalLabel (SEQUENCE)  */
+/* <========================================> */
+void Encode_TerminalLabel(PS_TerminalLabel x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 192, (uint32)x->mcuNumber, stream);
+    PutInteger(0, 192, (uint32)x->terminalNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Encoder for ConferenceResponse (CHOICE)  */
+/* <===========================================> */
+void Encode_ConferenceResponse(PS_ConferenceResponse x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(8, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_MCTerminalIDResponse(x->mCTerminalIDResponse, stream);
+            break;
+        case 1:
+            Encode_TerminalIDResponse(x->terminalIDResponse, stream);
+            break;
+        case 2:
+            Encode_ConferenceIDResponse(x->conferenceIDResponse, stream);
+            break;
+        case 3:
+            Encode_PasswordResponse(x->passwordResponse, stream);
+            break;
+        case 4:
+            PutInteger(1, 256, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_TerminalLabel(x->terminalListResponse + i, stream);
+            }
+            break;
+        case 5:
+            /* (videoCommandReject is NULL) */
+            break;
+        case 6:
+            /* (terminalDropReject is NULL) */
+            break;
+        case 7:
+            Encode_MakeMeChairResponse(x->makeMeChairResponse, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 8:
+            PutExtensionItem(EPASS Encode_ExtensionAddressResponse, (uint8*)x->extensionAddressResponse, stream);
+            break;
+        case 9:
+            PutExtensionItem(EPASS Encode_ChairTokenOwnerResponse, (uint8*)x->chairTokenOwnerResponse, stream);
+            break;
+        case 10:
+            PutExtensionItem(EPASS Encode_TerminalCertificateResponse, (uint8*)x->terminalCertificateResponse, stream);
+            break;
+        case 11:
+            PutExtensionItem(EPASS Encode_BroadcastMyLogicalChannelResponse, (uint8*)x->broadcastMyLogicalChannelResponse, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_MakeTerminalBroadcasterResponse, (uint8*)x->makeTerminalBroadcasterResponse, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_SendThisSourceResponse, (uint8*)x->sendThisSourceResponse, stream);
+            break;
+        case 14:
+            PutExtensionItem(EPASS Encode_RequestAllTerminalIDsResponse, (uint8*)x->requestAllTerminalIDsResponse, stream);
+            break;
+        case 15:
+            PutExtensionItem(EPASS Encode_RemoteMCResponse, (uint8*)x->remoteMCResponse, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ConferenceResponse: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for SendThisSourceResponse (CHOICE)  */
+/* <===============================================> */
+void Encode_SendThisSourceResponse(PS_SendThisSourceResponse x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedSendThisSource is NULL) */
+            break;
+        case 1:
+            /* (deniedSendThisSource is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_SendThisSourceResponse: Illegal CHOICE index");
+    }
+}
+
+/* <========================================================> */
+/*  PER-Encoder for MakeTerminalBroadcasterResponse (CHOICE)  */
+/* <========================================================> */
+void Encode_MakeTerminalBroadcasterResponse(PS_MakeTerminalBroadcasterResponse x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedMakeTerminalBroadcaster is NULL) */
+            break;
+        case 1:
+            /* (deniedMakeTerminalBroadcaster is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MakeTerminalBroadcasterResponse: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================================> */
+/*  PER-Encoder for BroadcastMyLogicalChannelResponse (CHOICE)  */
+/* <==========================================================> */
+void Encode_BroadcastMyLogicalChannelResponse(PS_BroadcastMyLogicalChannelResponse x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedBroadcastMyLogicalChannel is NULL) */
+            break;
+        case 1:
+            /* (deniedBroadcastMyLogicalChannel is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_BroadcastMyLogicalChannelResponse: Illegal CHOICE index");
+    }
+}
+
+/* <======================================================> */
+/*  PER-Encoder for TerminalCertificateResponse (SEQUENCE)  */
+/* <======================================================> */
+void Encode_TerminalCertificateResponse(PS_TerminalCertificateResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_terminalLabel, stream);
+    PutBoolean(x->option_of_certificateResponse, stream);
+    if (x->option_of_terminalLabel)
+    {
+        Encode_TerminalLabel(&x->terminalLabel, stream);
+    }
+    if (x->option_of_certificateResponse)
+    {
+        PutOctetString(0, 1, 65535, &x->certificateResponse, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for ChairTokenOwnerResponse (SEQUENCE)  */
+/* <==================================================> */
+void Encode_ChairTokenOwnerResponse(PS_ChairTokenOwnerResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TerminalLabel(&x->terminalLabel, stream);
+    PutOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for ExtensionAddressResponse (SEQUENCE)  */
+/* <===================================================> */
+void Encode_ExtensionAddressResponse(PS_ExtensionAddressResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 1, 128, &x->extensionAddress, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for MakeMeChairResponse (CHOICE)  */
+/* <============================================> */
+void Encode_MakeMeChairResponse(PS_MakeMeChairResponse x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (grantedChairToken is NULL) */
+            break;
+        case 1:
+            /* (deniedChairToken is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MakeMeChairResponse: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for PasswordResponse (SEQUENCE)  */
+/* <===========================================> */
+void Encode_PasswordResponse(PS_PasswordResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TerminalLabel(&x->terminalLabel, stream);
+    PutOctetString(0, 1, 32, &x->password, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for ConferenceIDResponse (SEQUENCE)  */
+/* <===============================================> */
+void Encode_ConferenceIDResponse(PS_ConferenceIDResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TerminalLabel(&x->terminalLabel, stream);
+    PutOctetString(0, 1, 32, &x->conferenceID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for TerminalIDResponse (SEQUENCE)  */
+/* <=============================================> */
+void Encode_TerminalIDResponse(PS_TerminalIDResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TerminalLabel(&x->terminalLabel, stream);
+    PutOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for MCTerminalIDResponse (SEQUENCE)  */
+/* <===============================================> */
+void Encode_MCTerminalIDResponse(PS_MCTerminalIDResponse x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TerminalLabel(&x->terminalLabel, stream);
+    PutOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================================> */
+/*  PER-Encoder for RequestAllTerminalIDsResponse (SEQUENCE)  */
+/* <========================================================> */
+void Encode_RequestAllTerminalIDsResponse(PS_RequestAllTerminalIDsResponse x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutLengthDet(x->size_of_terminalInformation, stream);
+    for (i = 0;i < x->size_of_terminalInformation;++i)
+    {
+        Encode_TerminalInformation(x->terminalInformation + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================================> */
+/*  PER-Encoder for TerminalInformation (SEQUENCE)  */
+/* <==============================================> */
+void Encode_TerminalInformation(PS_TerminalInformation x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TerminalLabel(&x->terminalLabel, stream);
+    PutOctetString(0, 1, 128, &x->terminalID, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for RemoteMCRequest (CHOICE)  */
+/* <========================================> */
+void Encode_RemoteMCRequest(PS_RemoteMCRequest x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (masterActivate is NULL) */
+            break;
+        case 1:
+            /* (slaveActivate is NULL) */
+            break;
+        case 2:
+            /* (deActivate is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RemoteMCRequest: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for RemoteMCResponse (CHOICE)  */
+/* <=========================================> */
+void Encode_RemoteMCResponse(PS_RemoteMCResponse x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (accept is NULL) */
+            break;
+        case 1:
+            Encode_Reject(x->reject, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RemoteMCResponse: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Encoder for Reject (CHOICE)  */
+/* <===============================> */
+void Encode_Reject(PS_Reject x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (unspecified is NULL) */
+            break;
+        case 1:
+            /* (functionNotSupported is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Reject: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for MultilinkRequest (CHOICE)  */
+/* <=========================================> */
+void Encode_MultilinkRequest(PS_MultilinkRequest x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_CallInformation(x->callInformation, stream);
+            break;
+        case 2:
+            Encode_AddConnection(x->addConnection, stream);
+            break;
+        case 3:
+            Encode_RemoveConnection(x->removeConnection, stream);
+            break;
+        case 4:
+            Encode_MaximumHeaderInterval(x->maximumHeaderInterval, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MultilinkRequest: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Encoder for MaximumHeaderInterval (SEQUENCE)  */
+/* <================================================> */
+void Encode_MaximumHeaderInterval(PS_MaximumHeaderInterval x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_RequestType(&x->requestType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Encoder for RequestType (CHOICE)  */
+/* <====================================> */
+void Encode_RequestType(PS_RequestType x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (currentIntervalInformation is NULL) */
+            break;
+        case 1:
+            PutInteger(0, 65535, (uint32)x->requestedInterval, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_RequestType: Illegal CHOICE index");
+    }
+}
+
+/* <===========================================> */
+/*  PER-Encoder for RemoveConnection (SEQUENCE)  */
+/* <===========================================> */
+void Encode_RemoveConnection(PS_RemoveConnection x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_ConnectionIdentifier(&x->connectionIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================> */
+/*  PER-Encoder for AddConnection (SEQUENCE)  */
+/* <========================================> */
+void Encode_AddConnection(PS_AddConnection x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    Encode_DialingInformation(&x->dialingInformation, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Encoder for CallInformation (SEQUENCE)  */
+/* <==========================================> */
+void Encode_CallInformation(PS_CallInformation x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->maxNumberOfAdditionalConnections, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Encoder for MultilinkResponse (CHOICE)  */
+/* <==========================================> */
+void Encode_MultilinkResponse(PS_MultilinkResponse x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_RespCallInformation(x->respCallInformation, stream);
+            break;
+        case 2:
+            Encode_RespAddConnection(x->respAddConnection, stream);
+            break;
+        case 3:
+            Encode_RespRemoveConnection(x->respRemoveConnection, stream);
+            break;
+        case 4:
+            Encode_RespMaximumHeaderInterval(x->respMaximumHeaderInterval, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MultilinkResponse: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Encoder for RespMaximumHeaderInterval (SEQUENCE)  */
+/* <====================================================> */
+void Encode_RespMaximumHeaderInterval(PS_RespMaximumHeaderInterval x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 65535, (uint32)x->currentInterval, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for RespRemoveConnection (SEQUENCE)  */
+/* <===============================================> */
+void Encode_RespRemoveConnection(PS_RespRemoveConnection x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_ConnectionIdentifier(&x->connectionIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for RespAddConnection (SEQUENCE)  */
+/* <============================================> */
+void Encode_RespAddConnection(PS_RespAddConnection x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    Encode_ResponseCode(&x->responseCode, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Encoder for ResponseCode (CHOICE)  */
+/* <=====================================> */
+void Encode_ResponseCode(PS_ResponseCode x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (accepted is NULL) */
+            break;
+        case 1:
+            Encode_Rejected(x->rejected, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_ResponseCode: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Encoder for Rejected (CHOICE)  */
+/* <=================================> */
+void Encode_Rejected(PS_Rejected x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (connectionsNotAvailable is NULL) */
+            break;
+        case 1:
+            /* (userRejected is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Rejected: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Encoder for RespCallInformation (SEQUENCE)  */
+/* <==============================================> */
+void Encode_RespCallInformation(PS_RespCallInformation x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_DialingInformation(&x->dialingInformation, stream);
+    PutInteger(0, 0xffffffff, (uint32)x->callAssociationNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <============================================> */
+/*  PER-Encoder for MultilinkIndication (CHOICE)  */
+/* <============================================> */
+void Encode_MultilinkIndication(PS_MultilinkIndication x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            Encode_CrcDesired(x->crcDesired, stream);
+            break;
+        case 2:
+            Encode_ExcessiveError(x->excessiveError, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_MultilinkIndication: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for ExcessiveError (SEQUENCE)  */
+/* <=========================================> */
+void Encode_ExcessiveError(PS_ExcessiveError x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_ConnectionIdentifier(&x->connectionIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Encoder for CrcDesired (SEQUENCE)  */
+/* <=====================================> */
+void Encode_CrcDesired(PS_CrcDesired x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Encoder for DialingInformation (CHOICE)  */
+/* <===========================================> */
+void Encode_DialingInformation(PS_DialingInformation x, PS_OutStream stream)
+{
+    uint16 i;
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            PutInteger(1, 65535, (uint32)x->size, stream);
+            for (i = 0;i < x->size;++i)
+            {
+                Encode_DialingInformationNumber(x->differential + i, stream);
+            }
+            break;
+        case 2:
+            PutInteger(1, 65535, (uint32)x->infoNotAvailable, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_DialingInformation: Illegal CHOICE index");
+    }
+}
+
+/* <===================================================> */
+/*  PER-Encoder for DialingInformationNumber (SEQUENCE)  */
+/* <===================================================> */
+void Encode_DialingInformationNumber(PS_DialingInformationNumber x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_subAddress, stream);
+    PutCharString("NumericString", 0, 0, 40, NULL, &x->networkAddress, stream);
+    if (x->option_of_subAddress)
+    {
+        PutCharString("IA5String", 0, 1, 40, NULL, &x->subAddress, stream);
+    }
+    PutInteger(1, 255, (uint32)x->size_of_networkType, stream);
+    for (i = 0;i < x->size_of_networkType;++i)
+    {
+        Encode_DialingInformationNetworkType(x->networkType + i, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <======================================================> */
+/*  PER-Encoder for DialingInformationNetworkType (CHOICE)  */
+/* <======================================================> */
+void Encode_DialingInformationNetworkType(PS_DialingInformationNetworkType x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardMessage(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (n_isdn is NULL) */
+            break;
+        case 2:
+            /* (gstn is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_DialingInformationNetworkType: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for ConnectionIdentifier (SEQUENCE)  */
+/* <===============================================> */
+void Encode_ConnectionIdentifier(PS_ConnectionIdentifier x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 0xffffffff, (uint32)x->channelTag, stream);
+    PutInteger(0, 0xffffffff, (uint32)x->sequenceNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================================> */
+/*  PER-Encoder for LogicalChannelRateRequest (SEQUENCE)  */
+/* <====================================================> */
+void Encode_LogicalChannelRateRequest(PS_LogicalChannelRateRequest x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    PutInteger(0, 0xffffffff, (uint32)x->maximumBitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <========================================================> */
+/*  PER-Encoder for LogicalChannelRateAcknowledge (SEQUENCE)  */
+/* <========================================================> */
+void Encode_LogicalChannelRateAcknowledge(PS_LogicalChannelRateAcknowledge x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    PutInteger(0, 0xffffffff, (uint32)x->maximumBitRate, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for LogicalChannelRateReject (SEQUENCE)  */
+/* <===================================================> */
+void Encode_LogicalChannelRateReject(PS_LogicalChannelRateReject x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_currentMaximumBitRate, stream);
+    PutInteger(0, 255, (uint32)x->sequenceNumber, stream);
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    Encode_LogicalChannelRateRejectReason(&x->rejectReason, stream);
+    if (x->option_of_currentMaximumBitRate)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->currentMaximumBitRate, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================================> */
+/*  PER-Encoder for LogicalChannelRateRejectReason (CHOICE)  */
+/* <=======================================================> */
+void Encode_LogicalChannelRateRejectReason(PS_LogicalChannelRateRejectReason x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (undefinedReason is NULL) */
+            break;
+        case 1:
+            /* (insufficientResources is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_LogicalChannelRateRejectReason: Illegal CHOICE index");
+    }
+}
+
+/* <====================================================> */
+/*  PER-Encoder for LogicalChannelRateRelease (SEQUENCE)  */
+/* <====================================================> */
+void Encode_LogicalChannelRateRelease(PS_LogicalChannelRateRelease x, PS_OutStream stream)
+{
+    OSCL_UNUSED_ARG(x);
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for SendTerminalCapabilitySet (CHOICE)  */
+/* <==================================================> */
+void Encode_SendTerminalCapabilitySet(PS_SendTerminalCapabilitySet x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_SpecificRequest(x->specificRequest, stream);
+            break;
+        case 1:
+            /* (genericRequest is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_SendTerminalCapabilitySet: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for SpecificRequest (SEQUENCE)  */
+/* <==========================================> */
+void Encode_SpecificRequest(PS_SpecificRequest x, PS_OutStream stream)
+{
+    uint16 i;
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_capabilityTableEntryNumbers, stream);
+    PutBoolean(x->option_of_capabilityDescriptorNumbers, stream);
+    PutBoolean(x->multiplexCapability, stream);
+    if (x->option_of_capabilityTableEntryNumbers)
+    {
+        PutInteger(1, 65535, (uint32)x->size_of_capabilityTableEntryNumbers, stream);
+        for (i = 0;i < x->size_of_capabilityTableEntryNumbers;++i)
+        {
+            PutInteger(1, 65535, (uint32)x->capabilityTableEntryNumbers[i], stream);
+        }
+    }
+    if (x->option_of_capabilityDescriptorNumbers)
+    {
+        PutInteger(1, 256, (uint32)x->size_of_capabilityDescriptorNumbers, stream);
+        for (i = 0;i < x->size_of_capabilityDescriptorNumbers;++i)
+        {
+            PutInteger(0, 255, (uint32)x->capabilityDescriptorNumbers[i], stream);
+        }
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==========================================> */
+/*  PER-Encoder for EncryptionCommand (CHOICE)  */
+/* <==========================================> */
+void Encode_EncryptionCommand(PS_EncryptionCommand x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutOctetString(1, 0, 0, x->encryptionSE, stream);
+            break;
+        case 1:
+            /* (encryptionIVRequest is NULL) */
+            break;
+        case 2:
+            Encode_EncryptionAlgorithmID(x->encryptionAlgorithmID, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_EncryptionCommand: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Encoder for EncryptionAlgorithmID (SEQUENCE)  */
+/* <================================================> */
+void Encode_EncryptionAlgorithmID(PS_EncryptionAlgorithmID x, PS_OutStream stream)
+{
+    PutInteger(0, 255, (uint32)x->h233AlgorithmIdentifier, stream);
+    Encode_NonStandardParameter(&x->associatedAlgorithm, stream);
+}
+
+/* <=============================================> */
+/*  PER-Encoder for FlowControlCommand (SEQUENCE)  */
+/* <=============================================> */
+void Encode_FlowControlCommand(PS_FlowControlCommand x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_FccScope(&x->fccScope, stream);
+    Encode_FccRestriction(&x->fccRestriction, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for FccRestriction (CHOICE)  */
+/* <=======================================> */
+void Encode_FccRestriction(PS_FccRestriction x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(0, 16777215, (uint32)x->maximumBitRate, stream);
+            break;
+        case 1:
+            /* (noRestriction is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_FccRestriction: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Encoder for FccScope (CHOICE)  */
+/* <=================================> */
+void Encode_FccScope(PS_FccScope x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+            break;
+        case 1:
+            PutInteger(0, 65535, (uint32)x->resourceID, stream);
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_FccScope: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for EndSessionCommand (CHOICE)  */
+/* <==========================================> */
+void Encode_EndSessionCommand(PS_EndSessionCommand x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (disconnect is NULL) */
+            break;
+        case 2:
+            Encode_GstnOptions(x->gstnOptions, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 3:
+            PutExtensionItem(EPASS Encode_IsdnOptions, (uint8*)x->isdnOptions, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_EndSessionCommand: Illegal CHOICE index");
+    }
+}
+
+/* <====================================> */
+/*  PER-Encoder for IsdnOptions (CHOICE)  */
+/* <====================================> */
+void Encode_IsdnOptions(PS_IsdnOptions x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (telephonyMode is NULL) */
+            break;
+        case 1:
+            /* (v140 is NULL) */
+            break;
+        case 2:
+            /* (terminalOnHold is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_IsdnOptions: Illegal CHOICE index");
+    }
+}
+
+/* <====================================> */
+/*  PER-Encoder for GstnOptions (CHOICE)  */
+/* <====================================> */
+void Encode_GstnOptions(PS_GstnOptions x, PS_OutStream stream)
+{
+    PutChoiceIndex(5, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (telephonyMode is NULL) */
+            break;
+        case 1:
+            /* (v8bis is NULL) */
+            break;
+        case 2:
+            /* (v34DSVD is NULL) */
+            break;
+        case 3:
+            /* (v34DuplexFAX is NULL) */
+            break;
+        case 4:
+            /* (v34H324 is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_GstnOptions: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for ConferenceCommand (CHOICE)  */
+/* <==========================================> */
+void Encode_ConferenceCommand(PS_ConferenceCommand x, PS_OutStream stream)
+{
+    PutChoiceIndex(7, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->broadcastMyLogicalChannel, stream);
+            break;
+        case 1:
+            PutInteger(1, 65535, (uint32)x->cancelBroadcastMyLogicalChannel, stream);
+            break;
+        case 2:
+            Encode_TerminalLabel(x->makeTerminalBroadcaster, stream);
+            break;
+        case 3:
+            /* (cancelMakeTerminalBroadcaster is NULL) */
+            break;
+        case 4:
+            Encode_TerminalLabel(x->sendThisSource, stream);
+            break;
+        case 5:
+            /* (cancelSendThisSource is NULL) */
+            break;
+        case 6:
+            /* (dropConference is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            PutExtensionItem(EPASS Encode_SubstituteConferenceIDCommand, (uint8*)x->substituteConferenceIDCommand, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ConferenceCommand: Illegal CHOICE index");
+    }
+}
+
+/* <========================================================> */
+/*  PER-Encoder for SubstituteConferenceIDCommand (SEQUENCE)  */
+/* <========================================================> */
+void Encode_SubstituteConferenceIDCommand(PS_SubstituteConferenceIDCommand x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutOctetString(0, 16, 16, &x->conferenceIdentifier, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for MiscellaneousCommand (SEQUENCE)  */
+/* <===============================================> */
+void Encode_MiscellaneousCommand(PS_MiscellaneousCommand x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    Encode_McType(&x->mcType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================> */
+/*  PER-Encoder for McType (CHOICE)  */
+/* <===============================> */
+void Encode_McType(PS_McType x, PS_OutStream stream)
+{
+    PutChoiceIndex(10, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (equaliseDelay is NULL) */
+            break;
+        case 1:
+            /* (zeroDelay is NULL) */
+            break;
+        case 2:
+            /* (multipointModeCommand is NULL) */
+            break;
+        case 3:
+            /* (cancelMultipointModeCommand is NULL) */
+            break;
+        case 4:
+            /* (videoFreezePicture is NULL) */
+            break;
+        case 5:
+            /* (videoFastUpdatePicture is NULL) */
+            break;
+        case 6:
+            Encode_VideoFastUpdateGOB(x->videoFastUpdateGOB, stream);
+            break;
+        case 7:
+            PutInteger(0, 31, (uint32)x->videoTemporalSpatialTradeOff, stream);
+            break;
+        case 8:
+            /* (videoSendSyncEveryGOB is NULL) */
+            break;
+        case 9:
+            /* (videoSendSyncEveryGOBCancel is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            PutExtensionItem(EPASS Encode_VideoFastUpdateMB, (uint8*)x->videoFastUpdateMB, stream);
+            break;
+        case 11:
+            PutExtensionInteger(1, 65535, (uint32)x->maxH223MUXPDUsize, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_EncryptionSync, (uint8*)x->encryptionUpdate, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_EncryptionUpdateRequest, (uint8*)x->encryptionUpdateRequest, stream);
+            break;
+        case 14:
+            PutExtensionNull(stream);
+            break;
+        case 15:
+            PutExtensionNull(stream);
+            break;
+        case 16:
+            PutExtensionItem(EPASS Encode_ProgressiveRefinementStart, (uint8*)x->progressiveRefinementStart, stream);
+            break;
+        case 17:
+            PutExtensionNull(stream);
+            break;
+        case 18:
+            PutExtensionNull(stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_McType: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================================> */
+/*  PER-Encoder for ProgressiveRefinementStart (SEQUENCE)  */
+/* <=====================================================> */
+void Encode_ProgressiveRefinementStart(PS_ProgressiveRefinementStart x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_PrsRepeatCount(&x->prsRepeatCount, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for PrsRepeatCount (CHOICE)  */
+/* <=======================================> */
+void Encode_PrsRepeatCount(PS_PrsRepeatCount x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (doOneProgression is NULL) */
+            break;
+        case 1:
+            /* (doContinuousProgressions is NULL) */
+            break;
+        case 2:
+            /* (doOneIndependentProgression is NULL) */
+            break;
+        case 3:
+            /* (doContinuousIndependentProgressions is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_PrsRepeatCount: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Encoder for VideoFastUpdateMB (SEQUENCE)  */
+/* <============================================> */
+void Encode_VideoFastUpdateMB(PS_VideoFastUpdateMB x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_firstGOB, stream);
+    PutBoolean(x->option_of_firstMB, stream);
+    if (x->option_of_firstGOB)
+    {
+        PutInteger(0, 255, (uint32)x->firstGOB, stream);
+    }
+    if (x->option_of_firstMB)
+    {
+        PutInteger(1, 8192, (uint32)x->firstMB, stream);
+    }
+    PutInteger(1, 8192, (uint32)x->numberOfMBs, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for VideoFastUpdateGOB (SEQUENCE)  */
+/* <=============================================> */
+void Encode_VideoFastUpdateGOB(PS_VideoFastUpdateGOB x, PS_OutStream stream)
+{
+    PutInteger(0, 17, (uint32)x->firstGOB, stream);
+    PutInteger(1, 18, (uint32)x->numberOfGOBs, stream);
+}
+
+/* <==============================================> */
+/*  PER-Encoder for KeyProtectionMethod (SEQUENCE)  */
+/* <==============================================> */
+void Encode_KeyProtectionMethod(PS_KeyProtectionMethod x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->secureChannel, stream);
+    PutBoolean(x->sharedSecret, stream);
+    PutBoolean(x->certProtectedKey, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for EncryptionUpdateRequest (SEQUENCE)  */
+/* <==================================================> */
+void Encode_EncryptionUpdateRequest(PS_EncryptionUpdateRequest x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_keyProtectionMethod, stream);
+    if (x->option_of_keyProtectionMethod)
+    {
+        Encode_KeyProtectionMethod(&x->keyProtectionMethod, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================> */
+/*  PER-Encoder for H223MultiplexReconfiguration (CHOICE)  */
+/* <=====================================================> */
+void Encode_H223MultiplexReconfiguration(PS_H223MultiplexReconfiguration x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_H223ModeChange(x->h223ModeChange, stream);
+            break;
+        case 1:
+            Encode_H223AnnexADoubleFlag(x->h223AnnexADoubleFlag, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_H223MultiplexReconfiguration: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H223AnnexADoubleFlag (CHOICE)  */
+/* <=============================================> */
+void Encode_H223AnnexADoubleFlag(PS_H223AnnexADoubleFlag x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (start is NULL) */
+            break;
+        case 1:
+            /* (stop is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_H223AnnexADoubleFlag: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for H223ModeChange (CHOICE)  */
+/* <=======================================> */
+void Encode_H223ModeChange(PS_H223ModeChange x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (toLevel0 is NULL) */
+            break;
+        case 1:
+            /* (toLevel1 is NULL) */
+            break;
+        case 2:
+            /* (toLevel2 is NULL) */
+            break;
+        case 3:
+            /* (toLevel2withOptionalHeader is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_H223ModeChange: Illegal CHOICE index");
+    }
+}
+
+/* <==========================================> */
+/*  PER-Encoder for NewATMVCCommand (SEQUENCE)  */
+/* <==========================================> */
+void Encode_NewATMVCCommand(PS_NewATMVCCommand x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 65535, (uint32)x->resourceID, stream);
+    PutInteger(1, 65535, (uint32)x->bitRate, stream);
+    PutBoolean(x->bitRateLockedToPCRClock, stream);
+    PutBoolean(x->bitRateLockedToNetworkClock, stream);
+    Encode_CmdAal(&x->cmdAal, stream);
+    Encode_CmdMultiplex(&x->cmdMultiplex, stream);
+    Encode_CmdReverseParameters(&x->cmdReverseParameters, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for CmdReverseParameters (SEQUENCE)  */
+/* <===============================================> */
+void Encode_CmdReverseParameters(PS_CmdReverseParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->bitRate, stream);
+    PutBoolean(x->bitRateLockedToPCRClock, stream);
+    PutBoolean(x->bitRateLockedToNetworkClock, stream);
+    Encode_Multiplex(&x->multiplex, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for Multiplex (CHOICE)  */
+/* <==================================> */
+void Encode_Multiplex(PS_Multiplex x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_Multiplex: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for CmdMultiplex (CHOICE)  */
+/* <=====================================> */
+void Encode_CmdMultiplex(PS_CmdMultiplex x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CmdMultiplex: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Encoder for CmdAal (CHOICE)  */
+/* <===============================> */
+void Encode_CmdAal(PS_CmdAal x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_CmdAal1(x->cmdAal1, stream);
+            break;
+        case 1:
+            Encode_CmdAal5(x->cmdAal5, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CmdAal: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for CmdAal5 (SEQUENCE)  */
+/* <==================================> */
+void Encode_CmdAal5(PS_CmdAal5 x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 65535, (uint32)x->forwardMaximumSDUSize, stream);
+    PutInteger(0, 65535, (uint32)x->backwardMaximumSDUSize, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for CmdAal1 (SEQUENCE)  */
+/* <==================================> */
+void Encode_CmdAal1(PS_CmdAal1 x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_CmdClockRecovery(&x->cmdClockRecovery, stream);
+    Encode_CmdErrorCorrection(&x->cmdErrorCorrection, stream);
+    PutBoolean(x->structuredDataTransfer, stream);
+    PutBoolean(x->partiallyFilledCells, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Encoder for CmdErrorCorrection (CHOICE)  */
+/* <===========================================> */
+void Encode_CmdErrorCorrection(PS_CmdErrorCorrection x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullErrorCorrection is NULL) */
+            break;
+        case 1:
+            /* (longInterleaver is NULL) */
+            break;
+        case 2:
+            /* (shortInterleaver is NULL) */
+            break;
+        case 3:
+            /* (errorCorrectionOnly is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CmdErrorCorrection: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for CmdClockRecovery (CHOICE)  */
+/* <=========================================> */
+void Encode_CmdClockRecovery(PS_CmdClockRecovery x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullClockRecovery is NULL) */
+            break;
+        case 1:
+            /* (srtsClockRecovery is NULL) */
+            break;
+        case 2:
+            /* (adaptiveClockRecovery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_CmdClockRecovery: Illegal CHOICE index");
+    }
+}
+
+/* <==============================================> */
+/*  PER-Encoder for FunctionNotUnderstood (CHOICE)  */
+/* <==============================================> */
+void Encode_FunctionNotUnderstood(PS_FunctionNotUnderstood x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_RequestMessage(x->request, stream);
+            break;
+        case 1:
+            Encode_ResponseMessage(x->response, stream);
+            break;
+        case 2:
+            Encode_CommandMessage(x->command, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_FunctionNotUnderstood: Illegal CHOICE index");
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for FunctionNotSupported (SEQUENCE)  */
+/* <===============================================> */
+void Encode_FunctionNotSupported(PS_FunctionNotSupported x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_returnedFunction, stream);
+    Encode_FnsCause(&x->fnsCause, stream);
+    if (x->option_of_returnedFunction)
+    {
+        PutOctetString(1, 0, 0, &x->returnedFunction, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Encoder for FnsCause (CHOICE)  */
+/* <=================================> */
+void Encode_FnsCause(PS_FnsCause x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (syntaxError is NULL) */
+            break;
+        case 1:
+            /* (semanticError is NULL) */
+            break;
+        case 2:
+            /* (unknownFunction is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_FnsCause: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for ConferenceIndication (CHOICE)  */
+/* <=============================================> */
+void Encode_ConferenceIndication(PS_ConferenceIndication x, PS_OutStream stream)
+{
+    PutChoiceIndex(10, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(0, 9, (uint32)x->sbeNumber, stream);
+            break;
+        case 1:
+            Encode_TerminalLabel(x->terminalNumberAssign, stream);
+            break;
+        case 2:
+            Encode_TerminalLabel(x->terminalJoinedConference, stream);
+            break;
+        case 3:
+            Encode_TerminalLabel(x->terminalLeftConference, stream);
+            break;
+        case 4:
+            /* (seenByAtLeastOneOther is NULL) */
+            break;
+        case 5:
+            /* (cancelSeenByAtLeastOneOther is NULL) */
+            break;
+        case 6:
+            /* (seenByAll is NULL) */
+            break;
+        case 7:
+            /* (cancelSeenByAll is NULL) */
+            break;
+        case 8:
+            Encode_TerminalLabel(x->terminalYouAreSeeing, stream);
+            break;
+        case 9:
+            /* (requestForFloor is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            PutExtensionNull(stream);
+            break;
+        case 11:
+            PutExtensionItem(EPASS Encode_TerminalLabel, (uint8*)x->floorRequested, stream);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_TerminalYouAreSeeingInSubPictureNumber, (uint8*)x->terminalYouAreSeeingInSubPictureNumber, stream);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_VideoIndicateCompose, (uint8*)x->videoIndicateCompose, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ConferenceIndication: Illegal CHOICE index");
+    }
+}
+
+/* <=================================================================> */
+/*  PER-Encoder for TerminalYouAreSeeingInSubPictureNumber (SEQUENCE)  */
+/* <=================================================================> */
+void Encode_TerminalYouAreSeeingInSubPictureNumber(PS_TerminalYouAreSeeingInSubPictureNumber x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 192, (uint32)x->terminalNumber, stream);
+    PutInteger(0, 255, (uint32)x->subPictureNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for VideoIndicateCompose (SEQUENCE)  */
+/* <===============================================> */
+void Encode_VideoIndicateCompose(PS_VideoIndicateCompose x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 255, (uint32)x->compositionNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================================> */
+/*  PER-Encoder for MiscellaneousIndication (SEQUENCE)  */
+/* <==================================================> */
+void Encode_MiscellaneousIndication(PS_MiscellaneousIndication x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    Encode_MiType(&x->miType, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================> */
+/*  PER-Encoder for MiType (CHOICE)  */
+/* <===============================> */
+void Encode_MiType(PS_MiType x, PS_OutStream stream)
+{
+    PutChoiceIndex(10, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (logicalChannelActive is NULL) */
+            break;
+        case 1:
+            /* (logicalChannelInactive is NULL) */
+            break;
+        case 2:
+            /* (multipointConference is NULL) */
+            break;
+        case 3:
+            /* (cancelMultipointConference is NULL) */
+            break;
+        case 4:
+            /* (multipointZeroComm is NULL) */
+            break;
+        case 5:
+            /* (cancelMultipointZeroComm is NULL) */
+            break;
+        case 6:
+            /* (multipointSecondaryStatus is NULL) */
+            break;
+        case 7:
+            /* (cancelMultipointSecondaryStatus is NULL) */
+            break;
+        case 8:
+            /* (videoIndicateReadyToActivate is NULL) */
+            break;
+        case 9:
+            PutInteger(0, 31, (uint32)x->videoTemporalSpatialTradeOff, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 10:
+            PutExtensionItem(EPASS Encode_VideoNotDecodedMBs, (uint8*)x->videoNotDecodedMBs, stream);
+            break;
+        case 11:
+            PutExtensionItem(EPASS Encode_TransportCapability, (uint8*)x->transportCapability, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_MiType: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for VideoNotDecodedMBs (SEQUENCE)  */
+/* <=============================================> */
+void Encode_VideoNotDecodedMBs(PS_VideoNotDecodedMBs x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 8192, (uint32)x->firstMB, stream);
+    PutInteger(1, 8192, (uint32)x->numberOfMBs, stream);
+    PutInteger(0, 255, (uint32)x->temporalReference, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Encoder for JitterIndication (SEQUENCE)  */
+/* <===========================================> */
+void Encode_JitterIndication(PS_JitterIndication x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_skippedFrameCount, stream);
+    PutBoolean(x->option_of_additionalDecoderBuffer, stream);
+    Encode_JiScope(&x->jiScope, stream);
+    PutInteger(0, 3, (uint32)x->estimatedReceivedJitterMantissa, stream);
+    PutInteger(0, 7, (uint32)x->estimatedReceivedJitterExponent, stream);
+    if (x->option_of_skippedFrameCount)
+    {
+        PutInteger(0, 15, (uint32)x->skippedFrameCount, stream);
+    }
+    if (x->option_of_additionalDecoderBuffer)
+    {
+        PutInteger(0, 262143, (uint32)x->additionalDecoderBuffer, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <================================> */
+/*  PER-Encoder for JiScope (CHOICE)  */
+/* <================================> */
+void Encode_JiScope(PS_JiScope x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+            break;
+        case 1:
+            PutInteger(0, 65535, (uint32)x->resourceID, stream);
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_JiScope: Illegal CHOICE index");
+    }
+}
+
+/* <=============================================> */
+/*  PER-Encoder for H223SkewIndication (SEQUENCE)  */
+/* <=============================================> */
+void Encode_H223SkewIndication(PS_H223SkewIndication x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber1, stream);
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber2, stream);
+    PutInteger(0, 4095, (uint32)x->skew, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================================> */
+/*  PER-Encoder for H2250MaximumSkewIndication (SEQUENCE)  */
+/* <=====================================================> */
+void Encode_H2250MaximumSkewIndication(PS_H2250MaximumSkewIndication x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber1, stream);
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber2, stream);
+    PutInteger(0, 4095, (uint32)x->maximumSkew, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for MCLocationIndication (SEQUENCE)  */
+/* <===============================================> */
+void Encode_MCLocationIndication(PS_MCLocationIndication x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_TransportAddress(&x->signalAddress, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===============================================> */
+/*  PER-Encoder for VendorIdentification (SEQUENCE)  */
+/* <===============================================> */
+void Encode_VendorIdentification(PS_VendorIdentification x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_productNumber, stream);
+    PutBoolean(x->option_of_versionNumber, stream);
+    Encode_NonStandardIdentifier(&x->vendor, stream);
+    if (x->option_of_productNumber)
+    {
+        PutOctetString(0, 1, 256, &x->productNumber, stream);
+    }
+    if (x->option_of_versionNumber)
+    {
+        PutOctetString(0, 1, 256, &x->versionNumber, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=============================================> */
+/*  PER-Encoder for NewATMVCIndication (SEQUENCE)  */
+/* <=============================================> */
+void Encode_NewATMVCIndication(PS_NewATMVCIndication x, PS_OutStream stream)
+{
+    uint32 extension;
+
+    extension = x->option_of_indReverseParameters;
+    PutBoolean(extension, stream);
+
+    PutInteger(0, 65535, (uint32)x->resourceID, stream);
+    PutInteger(1, 65535, (uint32)x->bitRate, stream);
+    PutBoolean(x->bitRateLockedToPCRClock, stream);
+    PutBoolean(x->bitRateLockedToNetworkClock, stream);
+    Encode_IndAal(&x->indAal, stream);
+    Encode_IndMultiplex(&x->indMultiplex, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+    if (!extension) return; /* (No items present?) */
+    PutNormSmallLength(1, stream); /* Begin Options Map */
+    PutBoolean(x->option_of_indReverseParameters, stream);
+    if (x->option_of_indReverseParameters)
+    {
+        PutExtensionItem(EPASS Encode_IndReverseParameters, (uint8*)&x->indReverseParameters, stream);
+    }
+}
+
+/* <===============================================> */
+/*  PER-Encoder for IndReverseParameters (SEQUENCE)  */
+/* <===============================================> */
+void Encode_IndReverseParameters(PS_IndReverseParameters x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->bitRate, stream);
+    PutBoolean(x->bitRateLockedToPCRClock, stream);
+    PutBoolean(x->bitRateLockedToNetworkClock, stream);
+    Encode_IrpMultiplex(&x->irpMultiplex, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=====================================> */
+/*  PER-Encoder for IrpMultiplex (CHOICE)  */
+/* <=====================================> */
+void Encode_IrpMultiplex(PS_IrpMultiplex x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_IrpMultiplex: Illegal CHOICE index");
+    }
+}
+
+/* <=====================================> */
+/*  PER-Encoder for IndMultiplex (CHOICE)  */
+/* <=====================================> */
+void Encode_IndMultiplex(PS_IndMultiplex x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (noMultiplex is NULL) */
+            break;
+        case 1:
+            /* (transportStream is NULL) */
+            break;
+        case 2:
+            /* (programStream is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_IndMultiplex: Illegal CHOICE index");
+    }
+}
+
+/* <===============================> */
+/*  PER-Encoder for IndAal (CHOICE)  */
+/* <===============================> */
+void Encode_IndAal(PS_IndAal x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_IndAal1(x->indAal1, stream);
+            break;
+        case 1:
+            Encode_IndAal5(x->indAal5, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_IndAal: Illegal CHOICE index");
+    }
+}
+
+/* <==================================> */
+/*  PER-Encoder for IndAal5 (SEQUENCE)  */
+/* <==================================> */
+void Encode_IndAal5(PS_IndAal5 x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(0, 65535, (uint32)x->forwardMaximumSDUSize, stream);
+    PutInteger(0, 65535, (uint32)x->backwardMaximumSDUSize, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==================================> */
+/*  PER-Encoder for IndAal1 (SEQUENCE)  */
+/* <==================================> */
+void Encode_IndAal1(PS_IndAal1 x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_IndClockRecovery(&x->indClockRecovery, stream);
+    Encode_IndErrorCorrection(&x->indErrorCorrection, stream);
+    PutBoolean(x->structuredDataTransfer, stream);
+    PutBoolean(x->partiallyFilledCells, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===========================================> */
+/*  PER-Encoder for IndErrorCorrection (CHOICE)  */
+/* <===========================================> */
+void Encode_IndErrorCorrection(PS_IndErrorCorrection x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullErrorCorrection is NULL) */
+            break;
+        case 1:
+            /* (longInterleaver is NULL) */
+            break;
+        case 2:
+            /* (shortInterleaver is NULL) */
+            break;
+        case 3:
+            /* (errorCorrectionOnly is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_IndErrorCorrection: Illegal CHOICE index");
+    }
+}
+
+/* <=========================================> */
+/*  PER-Encoder for IndClockRecovery (CHOICE)  */
+/* <=========================================> */
+void Encode_IndClockRecovery(PS_IndClockRecovery x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            /* (nullClockRecovery is NULL) */
+            break;
+        case 1:
+            /* (srtsClockRecovery is NULL) */
+            break;
+        case 2:
+            /* (adaptiveClockRecovery is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_IndClockRecovery: Illegal CHOICE index");
+    }
+}
+
+/* <============================================> */
+/*  PER-Encoder for UserInputIndication (CHOICE)  */
+/* <============================================> */
+void Encode_UserInputIndication(PS_UserInputIndication x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            PutCharString("GeneralString", 1, 0, 0, NULL, x->alphanumeric, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 2:
+            PutExtensionItem(EPASS Encode_UserInputSupportIndication, (uint8*)x->userInputSupportIndication, stream);
+            break;
+        case 3:
+            PutExtensionItem(EPASS Encode_Signal, (uint8*)x->signal, stream);
+            break;
+        case 4:
+            PutExtensionItem(EPASS Encode_SignalUpdate, (uint8*)x->signalUpdate, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_UserInputIndication: Illegal CHOICE index");
+    }
+}
+
+/* <=======================================> */
+/*  PER-Encoder for SignalUpdate (SEQUENCE)  */
+/* <=======================================> */
+void Encode_SignalUpdate(PS_SignalUpdate x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_rtp, stream);
+    PutInteger(1, 65535, (uint32)x->duration, stream);
+    if (x->option_of_rtp)
+    {
+        Encode_Rtp(&x->rtp, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <==============================> */
+/*  PER-Encoder for Rtp (SEQUENCE)  */
+/* <==============================> */
+void Encode_Rtp(PS_Rtp x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=================================> */
+/*  PER-Encoder for Signal (SEQUENCE)  */
+/* <=================================> */
+void Encode_Signal(PS_Signal x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_duration, stream);
+    PutBoolean(x->option_of_signalRtp, stream);
+    PutCharString("IA5String", 0, 1, 1, "0123456789#*ABCD!", &x->signalType, stream);
+    if (x->option_of_duration)
+    {
+        PutInteger(1, 65535, (uint32)x->duration, stream);
+    }
+    if (x->option_of_signalRtp)
+    {
+        Encode_SignalRtp(&x->signalRtp, stream);
+    }
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <====================================> */
+/*  PER-Encoder for SignalRtp (SEQUENCE)  */
+/* <====================================> */
+void Encode_SignalRtp(PS_SignalRtp x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    PutBoolean(x->option_of_timestamp, stream);
+    PutBoolean(x->option_of_expirationTime, stream);
+    if (x->option_of_timestamp)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->timestamp, stream);
+    }
+    if (x->option_of_expirationTime)
+    {
+        PutInteger(0, 0xffffffff, (uint32)x->expirationTime, stream);
+    }
+    PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <===================================================> */
+/*  PER-Encoder for UserInputSupportIndication (CHOICE)  */
+/* <===================================================> */
+void Encode_UserInputSupportIndication(PS_UserInputSupportIndication x, PS_OutStream stream)
+{
+    PutChoiceIndex(4, 1, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            Encode_NonStandardParameter(x->nonStandard, stream);
+            break;
+        case 1:
+            /* (basicString is NULL) */
+            break;
+        case 2:
+            /* (iA5String is NULL) */
+            break;
+        case 3:
+            /* (generalString is NULL) */
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessageAndLeave("Encode_UserInputSupportIndication: Illegal CHOICE index");
+    }
+}
+
+/* <================================================> */
+/*  PER-Encoder for FlowControlIndication (SEQUENCE)  */
+/* <================================================> */
+void Encode_FlowControlIndication(PS_FlowControlIndication x, PS_OutStream stream)
+{
+    PutBoolean(0, stream); /* Extension Bit OFF */
+    Encode_FciScope(&x->fciScope, stream);
+    Encode_FciRestriction(&x->fciRestriction, stream);
+    /* ------------------------------- */
+    /* ---- Extension Begins Here ---- */
+    /* ------------------------------- */
+}
+
+/* <=======================================> */
+/*  PER-Encoder for FciRestriction (CHOICE)  */
+/* <=======================================> */
+void Encode_FciRestriction(PS_FciRestriction x, PS_OutStream stream)
+{
+    PutChoiceIndex(2, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(0, 16777215, (uint32)x->maximumBitRate, stream);
+            break;
+        case 1:
+            /* (noRestriction is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_FciRestriction: Illegal CHOICE index");
+    }
+}
+
+/* <=================================> */
+/*  PER-Encoder for FciScope (CHOICE)  */
+/* <=================================> */
+void Encode_FciScope(PS_FciScope x, PS_OutStream stream)
+{
+    PutChoiceIndex(3, 0, x->index, stream);
+    switch (x->index)
+    {
+        case 0:
+            PutInteger(1, 65535, (uint32)x->logicalChannelNumber, stream);
+            break;
+        case 1:
+            PutInteger(0, 65535, (uint32)x->resourceID, stream);
+            break;
+        case 2:
+            /* (wholeMultiplex is NULL) */
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_FciScope: Illegal CHOICE index");
+    }
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/per/src/per.cpp b/protocols/systems/3g-324m_pvterminal/h245/per/src/per.cpp
new file mode 100644
index 0000000..aa29153
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/per/src/per.cpp
@@ -0,0 +1,1654 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+//====================================================================
+// FILE: codemain.c
+//
+//   Main contact routines for PER encoding/decoding of H.245 messages.
+//====================================================================
+
+#include "h245.h"
+#include "h245def.h"
+#include "h245msg.h"				    /* H245 Message I/F  Header	    	    */
+#include "per.h"
+#include "se.h"
+#include "genericper.h"
+#include "h245_decoder.h"
+#include "h245_encoder.h"
+#include "h245_deleter.h"
+#include "h245_analysis.h"
+#include "oscl_mem.h"
+#include "pvlogger.h"
+#include "oscl_file_io.h"
+#include "oscl_mem.h"
+
+/* ---------------------------------------- */
+/* H.245 PER Analysis Routines              */
+/* ---------------------------------------- */
+#ifdef PVANALYZER
+
+#include "analyzeper.h"
+
+void MultiSysCtrlMessage_analyze(uint16 tag, uint8 type1, uint8 type2, uint8* message);
+void RequestMessage_analyze(uint16 tag, uint8 type2, uint8* message);
+void ResponseMessage_analyze(uint16 tag, uint8 type2, uint8* message);
+void CommandMessage_analyze(uint16 tag, uint8 type2, uint8* message);
+void IndicationMessage_analyze(uint16 tag, uint8 type2, uint8* message);
+void ShowH245Hex(uint16 tag, uint8 type1, uint8 type2, uint16 size, uint8* data);
+void ShowHexData(uint16 tag, uint16 indent, uint16 size, uint8* data);
+
+#endif //PVANALYZER
+
+// ========================================================
+// Constructor()
+//
+// ========================================================
+OSCL_EXPORT_REF PER::PER() :
+        MyH245(NULL)
+        , MySe(NULL)
+        , MyLogger(NULL)
+{
+    MyLogger = PVLogger::GetLoggerObject("3g324m.h245.per");
+}
+
+// ========================================================
+// Destructor()
+//
+// ========================================================
+OSCL_EXPORT_REF PER::~PER()
+{
+}
+
+// ========================================================
+// Encode()
+//
+// This is the main call for the PER Encoder.  It encodes
+// the H.245 message in pMsg, calls the analyzer functions
+// as needed, and then sends the binary coded message to
+// SRP.
+// ========================================================
+OSCL_EXPORT_REF void PER::Encode(PS_H245Msg pMsg)
+{
+    uint16		GetSize = 0;
+    uint8*		pCodeData;
+
+    // -----------------------
+    // Analyzer output
+    // -----------------------
+#ifdef PVANALYZER
+    MultiSysCtrlMessage_analyze(ANALYZER_PERE, pMsg->Type1, pMsg->Type2, pMsg->pData);
+#endif
+
+    // -----------------------
+    // Message encoding
+    // -----------------------
+    MultiSysCtrlMessage_encode(&GetSize, &pCodeData, pMsg->pData, pMsg->Type1, pMsg->Type2);
+
+    // -----------------------
+    // Analyzer output (HEX)
+    // -----------------------
+#ifdef PVANALYZER
+    ShowH245Hex(ANALYZER_PEREH, pMsg->Type1, pMsg->Type2, GetSize, pCodeData);
+#endif
+
+    // send encoded message
+    if (MyH245)
+    {
+        MyH245->LowerLayerTx((unsigned char*)pCodeData, (int)GetSize);
+    }
+
+    OSCL_DEFAULT_FREE(pCodeData);
+}
+
+// ========================================================
+// Reset()
+//
+// ========================================================
+OSCL_EXPORT_REF void PER::Reset()
+{
+    // tells the decoder to stop processing remaining messages
+    decodeSizeLeft = 0;
+}
+
+class DecodedMsgDestructDealloc : public OsclDestructDealloc
+{
+    public:
+        DecodedMsgDestructDealloc(uint8 amsgtype1, uint8 amsgtype2, uint8* apdata) :
+                msgtype1(amsgtype1), msgtype2(amsgtype2), pdata(apdata)
+        {}
+
+        virtual void destruct_and_dealloc(OsclAny *ptr)
+        {
+            // delete message
+            PER::DeleteMessage(msgtype1, msgtype2, pdata);
+            // destruct ref counter
+            ((OsclRefCounterDA*)ptr)->~OsclRefCounterDA();
+            // destruct this
+            this->~DecodedMsgDestructDealloc();
+            // free memory holding all
+            OSCL_DEFAULT_FREE(ptr);
+        }
+
+    private:
+        uint8 msgtype1;
+        uint8 msgtype2;
+        uint8 *pdata;
+};
+
+// ========================================================
+// Decode()
+//
+// ========================================================
+OSCL_EXPORT_REF void PER::Decode(uint8* pBuffer, uint32 size)
+{
+    uint8		MsgType1 = 0;
+    uint8       MsgType2 = 0;
+    uint16		GetSize = 0;
+    uint8*		pData = NULL;
+    uint8*		pBufferTop = NULL;
+    int			nBytes = 0;
+
+    decodeSizeLeft =  size;
+
+    // Save original start of pBuffer (for later freeing)
+    pBufferTop = pBuffer;
+
+#if 0	// saved for testing purposes
+    Oscl_FileServer infileserv;
+    Oscl_File infile;
+    infileserv.Connect();
+    if (infile.Open("test.245", Oscl_File::MODE_READ, infileserv) == 0)
+    {
+        uint8 codeword[2000];
+        pBuffer = codeword;
+        decodeSizeLeft = infile.Read(codeword, 1, 2000);
+        infile.Close();
+    }
+    infileserv.Close();
+#endif
+
+    // ----------------------------------------------------------
+    // Decode messages from pBuffer.  There may be multiple msgs.
+    // ----------------------------------------------------------
+    while (decodeSizeLeft > 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, MyLogger, PVLOGMSG_DEBUG, (0, "PER::Decode - decodeSizeLeft(%d)", decodeSizeLeft));
+
+        // ------------------------------------
+        // Decode the current message to pData
+        // ------------------------------------
+        if (!Decode(nBytes, pBuffer, GetSize, pData, MsgType1, MsgType2))
+        {
+            return;
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, MyLogger, PVLOGMSG_DEBUG, (0, "PER::Decode - num bytes decoded(%d), bytes:", nBytes));
+        PVLOGGER_LOGBIN(PVLOGMSG_INST_LLDBG, MyLogger, PVLOGMSG_DEBUG, (0, 1, nBytes, pBuffer));
+
+#ifdef PVANALYZER
+        // ----------------------
+        // Analyzer output
+        // ----------------------
+        MultiSysCtrlMessage_analyze(ANALYZER_PERD, MsgType1, MsgType2, pData);
+#endif
+
+        // ----------------------------
+        // Send decoded message to SE
+        // ----------------------------
+        if (GetSize)
+        {
+            // pass message up via smart pointer.  Some messages are held by user.
+            uint8 *space = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(OsclRefCounterDA) + sizeof(DecodedMsgDestructDealloc));
+            DecodedMsgDestructDealloc *destructor = new(space + sizeof(OsclRefCounterDA)) DecodedMsgDestructDealloc(MsgType1, MsgType2, pData);
+            OsclRefCounter *decodedMsgRefCnter    = new(space)                          OsclRefCounterDA(space, destructor);
+            OsclSharedPtr<uint8> decodedMsgPtr(pData, decodedMsgRefCnter);
+
+            MySe->MessageRecv(MsgType1, MsgType2, decodedMsgPtr, pBuffer, nBytes);
+        }
+
+        // Skip to the next message in pBuffer
+        decodeSizeLeft -= nBytes;
+        if (decodeSizeLeft < 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, MyLogger, PVLOGMSG_DEBUG, (0, "PER::Decode - decodeSizeLeft=%d", decodeSizeLeft));
+        }
+        pBuffer += nBytes;
+
+    }
+
+    // Free the original pBuffer space
+    OSCL_DEFAULT_FREE(pBufferTop);
+}
+
+
+bool PER::Decode(int& nBytes, uint8* pBuffer, uint16& GetSize, uint8*& pData,
+                 uint8&	MsgType1, uint8& MsgType2)
+{
+    int32 leave_status = 0;
+    OSCL_TRY(leave_status, nBytes = MultiSysCtrlMessage_decode(pBuffer, &GetSize,
+                                    &pData, &MsgType1, &MsgType2));
+    OSCL_FIRST_CATCH_ANY(leave_status,
+                         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, MyLogger, PVLOGMSG_ERR, (0, "PER::Decode - caught LEAVE during decode"));
+                         return false;
+                        );
+    return true;
+}
+// ========================================================
+// DeleteMessage()
+// Deep delete the message structure
+// ========================================================
+void PER::DeleteMessage(uint8 MsgType1, uint8 MsgType2, uint8* pData)
+{
+    switch (MsgType1)
+    {
+        case 0:
+            S_RequestMessage request;
+            request.index = MsgType2;
+            request.nonStandard = (PS_NonStandardMessage)pData;
+            Delete_RequestMessage(&request);
+            break;
+        case 1:
+            S_ResponseMessage response;
+            response.index = MsgType2;
+            response.nonStandard = (PS_NonStandardMessage)pData;
+            Delete_ResponseMessage(&response);
+            break;
+        case 2:
+            S_CommandMessage command;
+            command.index = MsgType2;
+            command.nonStandard = (PS_NonStandardMessage)pData;
+            Delete_CommandMessage(&command);
+            break;
+        case 3:
+            S_IndicationMessage indication;
+            indication.index = MsgType2;
+            indication.nonStandard = (PS_NonStandardMessage)pData;
+            Delete_IndicationMessage(&indication);
+            break;
+    }
+}
+
+// ========================================================
+// MultiSysCtrlMessage_encode()
+//
+// ========================================================
+void PER::MultiSysCtrlMessage_encode(uint16* pGetSize,
+                                     uint8* *ppDataOut,
+                                     uint8* pDataIn,
+                                     uint8 type1,
+                                     uint8 type2)
+{
+    PS_OutStream stream;
+
+    stream = NewOutStream();
+    PutChoiceIndex(4, 1, type1, stream);
+    switch (type1)
+    {
+        case 0:
+            RequestMessage_encode(pDataIn, type2, stream);
+            break;
+        case 1:
+            ResponseMessage_encode(pDataIn, type2, stream);
+            break;
+        case 2:
+            CommandMessage_encode(pDataIn, type2, stream);
+            break;
+        case 3:
+            IndicationMessage_encode(pDataIn, type2, stream);
+            break;
+        default:
+            ErrorMessageAndLeave("MultiSysCtrlMessage_encode: Illegal CHOICE index");
+    }
+
+    WriteRemainingBits(stream);
+    *ppDataOut = stream->data;
+    *pGetSize = stream->byteIndex;
+    OSCL_DEFAULT_FREE(stream);
+
+    return;
+}
+
+// ========================================================
+// RequestMessage_encode()
+//
+// ========================================================
+void PER::RequestMessage_encode(uint8* pDataIn,
+                                uint8 type2,
+                                PS_OutStream stream)
+{
+    PutChoiceIndex(11, 1, type2, stream);
+    switch (type2)
+    {
+        case 0:
+            Encode_NonStandardMessage((PS_NonStandardMessage)pDataIn, stream);
+            //Delete_NonStandardMessage((PS_NonStandardMessage)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 1:
+            Encode_MasterSlaveDetermination((PS_MasterSlaveDetermination)pDataIn, stream);
+            //Delete_MasterSlaveDetermination((PS_MasterSlaveDetermination)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 2:
+            Encode_TerminalCapabilitySet((PS_TerminalCapabilitySet)pDataIn, stream);
+            //Delete_TerminalCapabilitySet((PS_TerminalCapabilitySet)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 3:
+            Encode_OpenLogicalChannel((PS_OpenLogicalChannel)pDataIn, stream);
+            //Delete_OpenLogicalChannel((PS_OpenLogicalChannel)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 4:
+            Encode_CloseLogicalChannel((PS_CloseLogicalChannel)pDataIn, stream);
+            //Delete_CloseLogicalChannel((PS_CloseLogicalChannel)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 5:
+            Encode_RequestChannelClose((PS_RequestChannelClose)pDataIn, stream);
+            //Delete_RequestChannelClose((PS_RequestChannelClose)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 6:
+            Encode_MultiplexEntrySend((PS_MultiplexEntrySend)pDataIn, stream);
+            //Delete_MultiplexEntrySend((PS_MultiplexEntrySend)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 7:
+            Encode_RequestMultiplexEntry((PS_RequestMultiplexEntry)pDataIn, stream);
+            //Delete_RequestMultiplexEntry((PS_RequestMultiplexEntry)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 8:
+            Encode_RequestMode((PS_RequestMode)pDataIn, stream);
+            //Delete_RequestMode((PS_RequestMode)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 9:
+            Encode_RoundTripDelayRequest((PS_RoundTripDelayRequest)pDataIn, stream);
+            //Delete_RoundTripDelayRequest((PS_RoundTripDelayRequest)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 10:
+            Encode_MaintenanceLoopRequest((PS_MaintenanceLoopRequest)pDataIn, stream);
+            //Delete_MaintenanceLoopRequest((PS_MaintenanceLoopRequest)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            PutExtensionItem(EPASS Encode_CommunicationModeRequest, pDataIn, stream);
+            //Delete_CommunicationModeRequest((PS_CommunicationModeRequest)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 12:
+            PutExtensionItem(EPASS Encode_ConferenceRequest, pDataIn, stream);
+            //Delete_ConferenceRequest((PS_ConferenceRequest)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 13:
+            PutExtensionItem(EPASS Encode_MultilinkRequest, pDataIn, stream);
+            //Delete_MultilinkRequest((PS_MultilinkRequest)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 14:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateRequest, pDataIn, stream);
+            //Delete_LogicalChannelRateRequest((PS_LogicalChannelRateRequest)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_RequestMessage: Illegal CHOICE index");
+    }
+}
+
+
+// ========================================================
+// ResponseMessage_encode()
+//
+// ========================================================
+void PER::ResponseMessage_encode(uint8* pDataIn,
+                                 uint8 type2,
+                                 PS_OutStream stream)
+{
+    PutChoiceIndex(19, 1, type2, stream);
+    switch (type2)
+    {
+        case 0:
+            Encode_NonStandardMessage((PS_NonStandardMessage)pDataIn, stream);
+            //Delete_NonStandardMessage((PS_NonStandardMessage)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 1:
+            Encode_MasterSlaveDeterminationAck((PS_MasterSlaveDeterminationAck)pDataIn, stream);
+            //Delete_MasterSlaveDeterminationAck((PS_MasterSlaveDeterminationAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 2:
+            Encode_MasterSlaveDeterminationReject((PS_MasterSlaveDeterminationReject)pDataIn, stream);
+            //Delete_MasterSlaveDeterminationReject((PS_MasterSlaveDeterminationReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 3:
+            Encode_TerminalCapabilitySetAck((PS_TerminalCapabilitySetAck)pDataIn, stream);
+            //Delete_TerminalCapabilitySetAck((PS_TerminalCapabilitySetAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 4:
+            Encode_TerminalCapabilitySetReject((PS_TerminalCapabilitySetReject)pDataIn, stream);
+            //Delete_TerminalCapabilitySetReject((PS_TerminalCapabilitySetReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 5:
+            Encode_OpenLogicalChannelAck((PS_OpenLogicalChannelAck)pDataIn, stream);
+            //Delete_OpenLogicalChannelAck((PS_OpenLogicalChannelAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 6:
+            Encode_OpenLogicalChannelReject((PS_OpenLogicalChannelReject)pDataIn, stream);
+            //Delete_OpenLogicalChannelReject((PS_OpenLogicalChannelReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 7:
+            Encode_CloseLogicalChannelAck((PS_CloseLogicalChannelAck)pDataIn, stream);
+            //Delete_CloseLogicalChannelAck((PS_CloseLogicalChannelAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 8:
+            Encode_RequestChannelCloseAck((PS_RequestChannelCloseAck)pDataIn, stream);
+            //Delete_RequestChannelCloseAck((PS_RequestChannelCloseAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 9:
+            Encode_RequestChannelCloseReject((PS_RequestChannelCloseReject)pDataIn, stream);
+            //Delete_RequestChannelCloseReject((PS_RequestChannelCloseReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 10:
+            Encode_MultiplexEntrySendAck((PS_MultiplexEntrySendAck)pDataIn, stream);
+            //Delete_MultiplexEntrySendAck((PS_MultiplexEntrySendAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 11:
+            Encode_MultiplexEntrySendReject((PS_MultiplexEntrySendReject)pDataIn, stream);
+            //Delete_MultiplexEntrySendReject((PS_MultiplexEntrySendReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 12:
+            Encode_RequestMultiplexEntryAck((PS_RequestMultiplexEntryAck)pDataIn, stream);
+            //Delete_RequestMultiplexEntryAck((PS_RequestMultiplexEntryAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 13:
+            Encode_RequestMultiplexEntryReject((PS_RequestMultiplexEntryReject)pDataIn, stream);
+            //Delete_RequestMultiplexEntryReject((PS_RequestMultiplexEntryReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 14:
+            Encode_RequestModeAck((PS_RequestModeAck)pDataIn, stream);
+            //Delete_RequestModeAck((PS_RequestModeAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 15:
+            Encode_RequestModeReject((PS_RequestModeReject)pDataIn, stream);
+            //Delete_RequestModeReject((PS_RequestModeReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 16:
+            Encode_RoundTripDelayResponse((PS_RoundTripDelayResponse)pDataIn, stream);
+            //Delete_RoundTripDelayResponse((PS_RoundTripDelayResponse)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 17:
+            Encode_MaintenanceLoopAck((PS_MaintenanceLoopAck)pDataIn, stream);
+            //Delete_MaintenanceLoopAck((PS_MaintenanceLoopAck)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 18:
+            Encode_MaintenanceLoopReject((PS_MaintenanceLoopReject)pDataIn, stream);
+            //Delete_MaintenanceLoopReject((PS_MaintenanceLoopReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            PutExtensionItem(EPASS Encode_CommunicationModeResponse, pDataIn, stream);
+            //Delete_CommunicationModeResponse((PS_CommunicationModeResponse)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 20:
+            PutExtensionItem(EPASS Encode_ConferenceResponse, pDataIn, stream);
+            //Delete_ConferenceResponse((PS_ConferenceResponse)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 21:
+            PutExtensionItem(EPASS Encode_MultilinkResponse, pDataIn, stream);
+            //Delete_MultilinkResponse((PS_MultilinkResponse)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 22:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateAcknowledge, pDataIn, stream);
+            //Delete_LogicalChannelRateAcknowledge((PS_LogicalChannelRateAcknowledge)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 23:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateReject, pDataIn, stream);
+            //Delete_LogicalChannelRateReject((PS_LogicalChannelRateReject)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_ResponseMessage: Illegal CHOICE index");
+    }
+}
+
+// ========================================================
+// CommandMessage_encode()
+//
+// ========================================================
+void PER::CommandMessage_encode(uint8* pDataIn,
+                                uint8 type2,
+                                PS_OutStream stream)
+{
+    PutChoiceIndex(7, 1, type2, stream);
+    switch (type2)
+    {
+        case 0:
+            Encode_NonStandardMessage((PS_NonStandardMessage)pDataIn, stream);
+            //Delete_NonStandardMessage((PS_NonStandardMessage)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 1:
+            Encode_MaintenanceLoopOffCommand((PS_MaintenanceLoopOffCommand)pDataIn, stream);
+            //Delete_MaintenanceLoopOffCommand((PS_MaintenanceLoopOffCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 2:
+            Encode_SendTerminalCapabilitySet((PS_SendTerminalCapabilitySet)pDataIn, stream);
+            //Delete_SendTerminalCapabilitySet((PS_SendTerminalCapabilitySet)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 3:
+            Encode_EncryptionCommand((PS_EncryptionCommand)pDataIn, stream);
+            //Delete_EncryptionCommand((PS_EncryptionCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 4:
+            Encode_FlowControlCommand((PS_FlowControlCommand)pDataIn, stream);
+            //Delete_FlowControlCommand((PS_FlowControlCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 5:
+            Encode_EndSessionCommand((PS_EndSessionCommand)pDataIn, stream);
+            //Delete_EndSessionCommand((PS_EndSessionCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 6:
+            Encode_MiscellaneousCommand((PS_MiscellaneousCommand)pDataIn, stream);
+            //Delete_MiscellaneousCommand((PS_MiscellaneousCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            PutExtensionItem(EPASS Encode_CommunicationModeCommand, pDataIn, stream);
+            //Delete_CommunicationModeCommand((PS_CommunicationModeCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 8:
+            PutExtensionItem(EPASS Encode_ConferenceCommand, pDataIn, stream);
+            //Delete_ConferenceCommand((PS_ConferenceCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 9:
+            PutExtensionItem(EPASS Encode_H223MultiplexReconfiguration, pDataIn, stream);
+            //Delete_H223MultiplexReconfiguration((PS_H223MultiplexReconfiguration)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 10:
+            PutExtensionItem(EPASS Encode_NewATMVCCommand, pDataIn, stream);
+            //Delete_NewATMVCCommand((PS_NewATMVCCommand)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_CommandMessage: Illegal CHOICE index");
+    }
+}
+
+// ========================================================
+// IndicationMessage_encode()
+//
+// ========================================================
+void PER::IndicationMessage_encode(uint8* pDataIn,
+                                   uint8 type2,
+                                   PS_OutStream stream)
+{
+    PutChoiceIndex(14, 1, type2, stream);
+    switch (type2)
+    {
+        case 0:
+            Encode_NonStandardMessage((PS_NonStandardMessage)pDataIn, stream);
+            //Delete_NonStandardMessage((PS_NonStandardMessage)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 1:
+            Encode_FunctionNotUnderstood((PS_FunctionNotUnderstood)pDataIn, stream);
+            //Delete_FunctionNotUnderstood((PS_FunctionNotUnderstood)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 2:
+            Encode_MasterSlaveDeterminationRelease((PS_MasterSlaveDeterminationRelease)pDataIn, stream);
+            //Delete_MasterSlaveDeterminationRelease((PS_MasterSlaveDeterminationRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 3:
+            Encode_TerminalCapabilitySetRelease((PS_TerminalCapabilitySetRelease)pDataIn, stream);
+            //Delete_TerminalCapabilitySetRelease((PS_TerminalCapabilitySetRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 4:
+            Encode_OpenLogicalChannelConfirm((PS_OpenLogicalChannelConfirm)pDataIn, stream);
+            //Delete_OpenLogicalChannelConfirm((PS_OpenLogicalChannelConfirm)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 5:
+            Encode_RequestChannelCloseRelease((PS_RequestChannelCloseRelease)pDataIn, stream);
+            //Delete_RequestChannelCloseRelease((PS_RequestChannelCloseRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 6:
+            Encode_MultiplexEntrySendRelease((PS_MultiplexEntrySendRelease)pDataIn, stream);
+            //Delete_MultiplexEntrySendRelease((PS_MultiplexEntrySendRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 7:
+            Encode_RequestMultiplexEntryRelease((PS_RequestMultiplexEntryRelease)pDataIn, stream);
+            //Delete_RequestMultiplexEntryRelease((PS_RequestMultiplexEntryRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 8:
+            Encode_RequestModeRelease((PS_RequestModeRelease)pDataIn, stream);
+            //Delete_RequestModeRelease((PS_RequestModeRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 9:
+            Encode_MiscellaneousIndication((PS_MiscellaneousIndication)pDataIn, stream);
+            //Delete_MiscellaneousIndication((PS_MiscellaneousIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 10:
+            Encode_JitterIndication((PS_JitterIndication)pDataIn, stream);
+            //Delete_JitterIndication((PS_JitterIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 11:
+            Encode_H223SkewIndication((PS_H223SkewIndication)pDataIn, stream);
+            //Delete_H223SkewIndication((PS_H223SkewIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 12:
+            Encode_NewATMVCIndication((PS_NewATMVCIndication)pDataIn, stream);
+            //Delete_NewATMVCIndication((PS_NewATMVCIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 13:
+            Encode_UserInputIndication((PS_UserInputIndication)pDataIn, stream);
+            //Delete_UserInputIndication((PS_UserInputIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            PutExtensionItem(EPASS Encode_H2250MaximumSkewIndication, pDataIn, stream);
+            //Delete_H2250MaximumSkewIndication((PS_H2250MaximumSkewIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 15:
+            PutExtensionItem(EPASS Encode_MCLocationIndication, pDataIn, stream);
+            //Delete_MCLocationIndication((PS_MCLocationIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 16:
+            PutExtensionItem(EPASS Encode_ConferenceIndication, pDataIn, stream);
+            //Delete_ConferenceIndication((PS_ConferenceIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 17:
+            PutExtensionItem(EPASS Encode_VendorIdentification, pDataIn, stream);
+            //Delete_VendorIdentification((PS_VendorIdentification)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 18:
+            PutExtensionItem(EPASS Encode_FunctionNotSupported, pDataIn, stream);
+            //Delete_FunctionNotSupported((PS_FunctionNotSupported)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 19:
+            PutExtensionItem(EPASS Encode_MultilinkIndication, pDataIn, stream);
+            //Delete_MultilinkIndication((PS_MultilinkIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 20:
+            PutExtensionItem(EPASS Encode_LogicalChannelRateRelease, pDataIn, stream);
+            //Delete_LogicalChannelRateRelease((PS_LogicalChannelRateRelease)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        case 21:
+            PutExtensionItem(EPASS Encode_FlowControlIndication, pDataIn, stream);
+            //Delete_FlowControlIndication((PS_FlowControlIndication)pDataIn);
+            //OSCL_DEFAULT_FREE(pDataIn);
+            break;
+        default:
+            ErrorMessageAndLeave("Encode_IndicationMessage: Illegal CHOICE index");
+    }
+}
+
+// ========================================================
+// MultiSysCtrlMessage_decode()
+//
+// ========================================================
+int PER::MultiSysCtrlMessage_decode(uint8*	pDataIn,
+                                    uint16*	pGetSize,
+                                    uint8*	*ppDataOut,
+                                    uint8*	pType1,
+                                    uint8*	pType2)
+{
+    PS_InStream stream;
+
+    stream = (PS_InStream) OSCL_DEFAULT_MALLOC(sizeof(S_InStream));
+    stream->bitIndex = 0;
+    stream->data = pDataIn;
+    *pType1 = (uint8)GetChoiceIndex(4, 1, stream);
+    switch (*pType1)
+    {
+        case 0:
+            RequestMessage_decode(ppDataOut, pType2, stream);
+            break;
+        case 1:
+            ResponseMessage_decode(ppDataOut, pType2, stream);
+            break;
+        case 2:
+            CommandMessage_decode(ppDataOut, pType2, stream);
+            break;
+        case 3:
+            IndicationMessage_decode(ppDataOut, pType2, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        default:
+            ErrorMessage("MultiSysCtrlMessage_decode: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+    ReadRemainingBits(stream);
+    *pGetSize = (uint16)(stream->data - pDataIn);
+    OSCL_DEFAULT_FREE(stream);
+    return *pGetSize;
+}
+
+// ========================================================
+// RequestMessage_decode()
+//
+// ========================================================
+void PER::RequestMessage_decode(uint8* *ppDataOut, uint8* pType2, PS_InStream stream)
+{
+    *pType2 = (uint8)GetChoiceIndex(11, 1, stream);
+    switch (*pType2)
+    {
+        case 0:
+            *ppDataOut = (uint8*) OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage((PS_NonStandardMessage) *ppDataOut, stream);
+            break;
+        case 1:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDetermination));
+            Decode_MasterSlaveDetermination((PS_MasterSlaveDetermination) *ppDataOut, stream);
+            break;
+        case 2:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySet));
+            Decode_TerminalCapabilitySet((PS_TerminalCapabilitySet) *ppDataOut, stream);
+            break;
+        case 3:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannel));
+            Decode_OpenLogicalChannel((PS_OpenLogicalChannel) *ppDataOut, stream);
+            break;
+        case 4:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_CloseLogicalChannel));
+            Decode_CloseLogicalChannel((PS_CloseLogicalChannel) *ppDataOut, stream);
+            break;
+        case 5:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelClose));
+            Decode_RequestChannelClose((PS_RequestChannelClose) *ppDataOut, stream);
+            break;
+        case 6:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySend));
+            Decode_MultiplexEntrySend((PS_MultiplexEntrySend) *ppDataOut, stream);
+            break;
+        case 7:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntry));
+            Decode_RequestMultiplexEntry((PS_RequestMultiplexEntry) *ppDataOut, stream);
+            break;
+        case 8:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestMode));
+            Decode_RequestMode((PS_RequestMode) *ppDataOut, stream);
+            break;
+        case 9:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RoundTripDelayRequest));
+            Decode_RoundTripDelayRequest((PS_RoundTripDelayRequest) *ppDataOut, stream);
+            break;
+        case 10:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopRequest));
+            Decode_MaintenanceLoopRequest((PS_MaintenanceLoopRequest) *ppDataOut, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_CommunicationModeRequest));
+            Decode_CommunicationModeRequest((PS_CommunicationModeRequest) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 12:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceRequest));
+            Decode_ConferenceRequest((PS_ConferenceRequest) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 13:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultilinkRequest));
+            Decode_MultilinkRequest((PS_MultilinkRequest) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 14:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateRequest));
+            Decode_LogicalChannelRateRequest((PS_LogicalChannelRateRequest) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_RequestMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+// ========================================================
+// ResponseMessage_decode()
+//
+// ========================================================
+void PER::ResponseMessage_decode(uint8* *ppDataOut, uint8* pType2, PS_InStream stream)
+{
+    *pType2 = (uint8) GetChoiceIndex(19, 1, stream);
+    switch (*pType2)
+    {
+        case 0:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage((PS_NonStandardMessage) *ppDataOut, stream);
+            break;
+        case 1:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDeterminationAck));
+            Decode_MasterSlaveDeterminationAck((PS_MasterSlaveDeterminationAck) *ppDataOut, stream);
+            break;
+        case 2:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDeterminationReject));
+            Decode_MasterSlaveDeterminationReject((PS_MasterSlaveDeterminationReject) *ppDataOut, stream);
+            break;
+        case 3:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySetAck));
+            Decode_TerminalCapabilitySetAck((PS_TerminalCapabilitySetAck) *ppDataOut, stream);
+            break;
+        case 4:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySetReject));
+            Decode_TerminalCapabilitySetReject((PS_TerminalCapabilitySetReject) *ppDataOut, stream);
+            break;
+        case 5:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannelAck));
+            Decode_OpenLogicalChannelAck((PS_OpenLogicalChannelAck) *ppDataOut, stream);
+            break;
+        case 6:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannelReject));
+            Decode_OpenLogicalChannelReject((PS_OpenLogicalChannelReject) *ppDataOut, stream);
+            break;
+        case 7:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_CloseLogicalChannelAck));
+            Decode_CloseLogicalChannelAck((PS_CloseLogicalChannelAck) *ppDataOut, stream);
+            break;
+        case 8:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelCloseAck));
+            Decode_RequestChannelCloseAck((PS_RequestChannelCloseAck) *ppDataOut, stream);
+            break;
+        case 9:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelCloseReject));
+            Decode_RequestChannelCloseReject((PS_RequestChannelCloseReject) *ppDataOut, stream);
+            break;
+        case 10:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySendAck));
+            Decode_MultiplexEntrySendAck((PS_MultiplexEntrySendAck) *ppDataOut, stream);
+            break;
+        case 11:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySendReject));
+            Decode_MultiplexEntrySendReject((PS_MultiplexEntrySendReject) *ppDataOut, stream);
+            break;
+        case 12:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntryAck));
+            Decode_RequestMultiplexEntryAck((PS_RequestMultiplexEntryAck) *ppDataOut, stream);
+            break;
+        case 13:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntryReject));
+            Decode_RequestMultiplexEntryReject((PS_RequestMultiplexEntryReject) *ppDataOut, stream);
+            break;
+        case 14:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestModeAck));
+            Decode_RequestModeAck((PS_RequestModeAck) *ppDataOut, stream);
+            break;
+        case 15:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestModeReject));
+            Decode_RequestModeReject((PS_RequestModeReject) *ppDataOut, stream);
+            break;
+        case 16:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RoundTripDelayResponse));
+            Decode_RoundTripDelayResponse((PS_RoundTripDelayResponse) *ppDataOut, stream);
+            break;
+        case 17:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopAck));
+            Decode_MaintenanceLoopAck((PS_MaintenanceLoopAck) *ppDataOut, stream);
+            break;
+        case 18:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopReject));
+            Decode_MaintenanceLoopReject((PS_MaintenanceLoopReject) *ppDataOut, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_CommunicationModeResponse));
+            Decode_CommunicationModeResponse((PS_CommunicationModeResponse) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 20:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceResponse));
+            Decode_ConferenceResponse((PS_ConferenceResponse) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 21:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultilinkResponse));
+            Decode_MultilinkResponse((PS_MultilinkResponse) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 22:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateAcknowledge));
+            Decode_LogicalChannelRateAcknowledge((PS_LogicalChannelRateAcknowledge) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 23:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateReject));
+            Decode_LogicalChannelRateReject((PS_LogicalChannelRateReject) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_ResponseMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+// ========================================================
+// CommandMessage_decode()
+//
+// ========================================================
+void PER::CommandMessage_decode(uint8* *ppDataOut, uint8* pType2, PS_InStream stream)
+{
+    *pType2 = (uint8) GetChoiceIndex(7, 1, stream);
+    switch (*pType2)
+    {
+        case 0:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage((PS_NonStandardMessage) *ppDataOut, stream);
+            break;
+        case 1:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MaintenanceLoopOffCommand));
+            Decode_MaintenanceLoopOffCommand((PS_MaintenanceLoopOffCommand) *ppDataOut, stream);
+            break;
+        case 2:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_SendTerminalCapabilitySet));
+            Decode_SendTerminalCapabilitySet((PS_SendTerminalCapabilitySet) *ppDataOut, stream);
+            break;
+        case 3:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_EncryptionCommand));
+            Decode_EncryptionCommand((PS_EncryptionCommand) *ppDataOut, stream);
+            break;
+        case 4:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_FlowControlCommand));
+            Decode_FlowControlCommand((PS_FlowControlCommand) *ppDataOut, stream);
+            break;
+        case 5:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_EndSessionCommand));
+            Decode_EndSessionCommand((PS_EndSessionCommand) *ppDataOut, stream);
+            break;
+        case 6:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MiscellaneousCommand));
+            Decode_MiscellaneousCommand((PS_MiscellaneousCommand) *ppDataOut, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_CommunicationModeCommand));
+            Decode_CommunicationModeCommand((PS_CommunicationModeCommand) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 8:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceCommand));
+            Decode_ConferenceCommand((PS_ConferenceCommand) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 9:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_H223MultiplexReconfiguration));
+            Decode_H223MultiplexReconfiguration((PS_H223MultiplexReconfiguration) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 10:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_NewATMVCCommand));
+            Decode_NewATMVCCommand((PS_NewATMVCCommand) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_CommandMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+// ========================================================
+// IndicationMessage_decode()
+//
+// ========================================================
+void PER::IndicationMessage_decode(uint8* *ppDataOut, uint8* pType2, PS_InStream stream)
+{
+    *pType2 = (uint8)GetChoiceIndex(14, 1, stream);
+    switch (*pType2)
+    {
+        case 0:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_NonStandardMessage));
+            Decode_NonStandardMessage((PS_NonStandardMessage) *ppDataOut, stream);
+            break;
+        case 1:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_FunctionNotUnderstood));
+            Decode_FunctionNotUnderstood((PS_FunctionNotUnderstood) *ppDataOut, stream);
+            break;
+        case 2:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MasterSlaveDeterminationRelease));
+            Decode_MasterSlaveDeterminationRelease((PS_MasterSlaveDeterminationRelease) *ppDataOut, stream);
+            break;
+        case 3:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_TerminalCapabilitySetRelease));
+            Decode_TerminalCapabilitySetRelease((PS_TerminalCapabilitySetRelease) *ppDataOut, stream);
+            break;
+        case 4:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_OpenLogicalChannelConfirm));
+            Decode_OpenLogicalChannelConfirm((PS_OpenLogicalChannelConfirm) *ppDataOut, stream);
+            break;
+        case 5:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestChannelCloseRelease));
+            Decode_RequestChannelCloseRelease((PS_RequestChannelCloseRelease) *ppDataOut, stream);
+            break;
+        case 6:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntrySendRelease));
+            Decode_MultiplexEntrySendRelease((PS_MultiplexEntrySendRelease) *ppDataOut, stream);
+            break;
+        case 7:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestMultiplexEntryRelease));
+            Decode_RequestMultiplexEntryRelease((PS_RequestMultiplexEntryRelease) *ppDataOut, stream);
+            break;
+        case 8:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_RequestModeRelease));
+            Decode_RequestModeRelease((PS_RequestModeRelease) *ppDataOut, stream);
+            break;
+        case 9:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MiscellaneousIndication));
+            Decode_MiscellaneousIndication((PS_MiscellaneousIndication) *ppDataOut, stream);
+            break;
+        case 10:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_JitterIndication));
+            Decode_JitterIndication((PS_JitterIndication) *ppDataOut, stream);
+            break;
+        case 11:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_H223SkewIndication));
+            Decode_H223SkewIndication((PS_H223SkewIndication) *ppDataOut, stream);
+            break;
+        case 12:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_NewATMVCIndication));
+            Decode_NewATMVCIndication((PS_NewATMVCIndication) *ppDataOut, stream);
+            break;
+        case 13:
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_UserInputIndication));
+            Decode_UserInputIndication((PS_UserInputIndication) *ppDataOut, stream);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_H2250MaximumSkewIndication));
+            Decode_H2250MaximumSkewIndication((PS_H2250MaximumSkewIndication) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 15:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MCLocationIndication));
+            Decode_MCLocationIndication((PS_MCLocationIndication) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 16:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_ConferenceIndication));
+            Decode_ConferenceIndication((PS_ConferenceIndication) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 17:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_VendorIdentification));
+            Decode_VendorIdentification((PS_VendorIdentification) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 18:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_FunctionNotSupported));
+            Decode_FunctionNotSupported((PS_FunctionNotSupported) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 19:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_MultilinkIndication));
+            Decode_MultilinkIndication((PS_MultilinkIndication) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 20:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_LogicalChannelRateRelease));
+            Decode_LogicalChannelRateRelease((PS_LogicalChannelRateRelease) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        case 21:
+            GetLengthDet(stream);
+            *ppDataOut = (uint8*)OSCL_DEFAULT_MALLOC(sizeof(S_FlowControlIndication));
+            Decode_FlowControlIndication((PS_FlowControlIndication) *ppDataOut, stream);
+            ReadRemainingBits(stream);
+            break;
+        default:
+            ErrorMessage("Decode_IndicationMessage: Unsupported extension (skipping)");
+            SkipOneExtension(stream);
+    }
+}
+
+#ifdef PVANALYZER
+
+/* ---------------------------------------- */
+/* ---------------------------------------- */
+/*   (RAN) H.245 PER Analysis Routines      */
+/* ---------------------------------------- */
+/* ---------------------------------------- */
+
+/* ======================================================= */
+/* PER Analysis for Top Level H.245 Messages (RAN)         */
+/* Input Arguments:                                        */
+/*    uint16 tag;            Identifies source of message  */
+/*    uint8 type1,type2;     Choice indices (top 2 levels) */
+/*    uint8* message;        Message data                  */
+/* ======================================================= */
+void MultiSysCtrlMessage_analyze(uint16 tag, uint8 type1, uint8 type2, uint8* message)
+{
+    Show245(tag, 0, "<============= BEGIN H.245 MESSAGE ANALYSIS =============>");
+    switch (type1)
+    {
+        case 0:
+            RequestMessage_analyze(tag, type2, message);
+            break;
+        case 1:
+            ResponseMessage_analyze(tag, type2, message);
+            break;
+        case 2:
+            CommandMessage_analyze(tag, type2, message);
+            break;
+        case 3:
+            IndicationMessage_analyze(tag, type2, message);
+            break;
+        default:
+            ErrorMessage("MultiSysCtrlMessage_analyze: Illegal CHOICE index");
+    }
+    Show245(tag, 0, "<============== END H.245 MESSAGE ANALYSIS ==============>");
+    Show245(tag, 0, " ");
+}
+
+/* ================================================= */
+/* PER Analysis for RequestMessage (RAN)             */
+/* ================================================= */
+void RequestMessage_analyze(uint16 tag, uint8 type2, uint8* message)
+{
+    int8 origin[] = "requestMessage";
+    switch (type2)
+    {
+        case 0:
+            Analyze_NonStandardMessage((PS_NonStandardMessage)message, origin, tag, 0);
+            break;
+        case 1:
+            Analyze_MasterSlaveDetermination((PS_MasterSlaveDetermination)message, origin, tag, 0);
+            break;
+        case 2:
+            Analyze_TerminalCapabilitySet((PS_TerminalCapabilitySet)message, origin, tag, 0);
+            break;
+        case 3:
+            Analyze_OpenLogicalChannel((PS_OpenLogicalChannel)message, origin, tag, 0);
+            break;
+        case 4:
+            Analyze_CloseLogicalChannel((PS_CloseLogicalChannel)message, origin, tag, 0);
+            break;
+        case 5:
+            Analyze_RequestChannelClose((PS_RequestChannelClose)message, origin, tag, 0);
+            break;
+        case 6:
+            Analyze_MultiplexEntrySend((PS_MultiplexEntrySend)message, origin, tag, 0);
+            break;
+        case 7:
+            Analyze_RequestMultiplexEntry((PS_RequestMultiplexEntry)message, origin, tag, 0);
+            break;
+        case 8:
+            Analyze_RequestMode((PS_RequestMode)message, origin, tag, 0);
+            break;
+        case 9:
+            Analyze_RoundTripDelayRequest((PS_RoundTripDelayRequest)message, origin, tag, 0);
+            break;
+        case 10:
+            Analyze_MaintenanceLoopRequest((PS_MaintenanceLoopRequest)message, origin, tag, 0);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 11:
+            Analyze_CommunicationModeRequest((PS_CommunicationModeRequest)message, origin, tag, 0);
+            break;
+        case 12:
+            Analyze_ConferenceRequest((PS_ConferenceRequest)message, origin, tag, 0);
+            break;
+        case 13:
+            Analyze_MultilinkRequest((PS_MultilinkRequest)message, origin, tag, 0);
+            break;
+        case 14:
+            Analyze_LogicalChannelRateRequest((PS_LogicalChannelRateRequest)message, origin, tag, 0);
+            break;
+        default:
+            ErrorMessage("RequestMessage_analyze: Illegal CHOICE index");
+    }
+}
+
+/* ================================================= */
+/* PER Analysis for ResponseMessage (RAN)             */
+/* ================================================= */
+void ResponseMessage_analyze(uint16 tag, uint8 type2, uint8* message)
+{
+    int8 origin[] = "responseMessage";
+    switch (type2)
+    {
+        case 0:
+            Analyze_NonStandardMessage((PS_NonStandardMessage)message, origin, tag, 0);
+            break;
+        case 1:
+            Analyze_MasterSlaveDeterminationAck((PS_MasterSlaveDeterminationAck)message, origin, tag, 0);
+            break;
+        case 2:
+            Analyze_MasterSlaveDeterminationReject((PS_MasterSlaveDeterminationReject)message, origin, tag, 0);
+            break;
+        case 3:
+            Analyze_TerminalCapabilitySetAck((PS_TerminalCapabilitySetAck)message, origin, tag, 0);
+            break;
+        case 4:
+            Analyze_TerminalCapabilitySetReject((PS_TerminalCapabilitySetReject)message, origin, tag, 0);
+            break;
+        case 5:
+            Analyze_OpenLogicalChannelAck((PS_OpenLogicalChannelAck)message, origin, tag, 0);
+            break;
+        case 6:
+            Analyze_OpenLogicalChannelReject((PS_OpenLogicalChannelReject)message, origin, tag, 0);
+            break;
+        case 7:
+            Analyze_CloseLogicalChannelAck((PS_CloseLogicalChannelAck)message, origin, tag, 0);
+            break;
+        case 8:
+            Analyze_RequestChannelCloseAck((PS_RequestChannelCloseAck)message, origin, tag, 0);
+            break;
+        case 9:
+            Analyze_RequestChannelCloseReject((PS_RequestChannelCloseReject)message, origin, tag, 0);
+            break;
+        case 10:
+            Analyze_MultiplexEntrySendAck((PS_MultiplexEntrySendAck)message, origin, tag, 0);
+            break;
+        case 11:
+            Analyze_MultiplexEntrySendReject((PS_MultiplexEntrySendReject)message, origin, tag, 0);
+            break;
+        case 12:
+            Analyze_RequestMultiplexEntryAck((PS_RequestMultiplexEntryAck)message, origin, tag, 0);
+            break;
+        case 13:
+            Analyze_RequestMultiplexEntryReject((PS_RequestMultiplexEntryReject)message, origin, tag, 0);
+            break;
+        case 14:
+            Analyze_RequestModeAck((PS_RequestModeAck)message, origin, tag, 0);
+            break;
+        case 15:
+            Analyze_RequestModeReject((PS_RequestModeReject)message, origin, tag, 0);
+            break;
+        case 16:
+            Analyze_RoundTripDelayResponse((PS_RoundTripDelayResponse)message, origin, tag, 0);
+            break;
+        case 17:
+            Analyze_MaintenanceLoopAck((PS_MaintenanceLoopAck)message, origin, tag, 0);
+            break;
+        case 18:
+            Analyze_MaintenanceLoopReject((PS_MaintenanceLoopReject)message, origin, tag, 0);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 19:
+            Analyze_CommunicationModeResponse((PS_CommunicationModeResponse)message, origin, tag, 0);
+            break;
+        case 20:
+            Analyze_ConferenceResponse((PS_ConferenceResponse)message, origin, tag, 0);
+            break;
+        case 21:
+            Analyze_MultilinkResponse((PS_MultilinkResponse)message, origin, tag, 0);
+            break;
+        case 22:
+            Analyze_LogicalChannelRateAcknowledge((PS_LogicalChannelRateAcknowledge)message, origin, tag, 0);
+            break;
+        case 23:
+            Analyze_LogicalChannelRateReject((PS_LogicalChannelRateReject)message, origin, tag, 0);
+            break;
+        default:
+            ErrorMessage("ResponseMessage_analyze: Illegal CHOICE index");
+    }
+}
+
+/* ================================================= */
+/* PER Analysis for CommandMessage (RAN)             */
+/* ================================================= */
+void CommandMessage_analyze(uint16 tag, uint8 type2, uint8* message)
+{
+    int8 origin[] = "commandMessage";
+    switch (type2)
+    {
+        case 0:
+            Analyze_NonStandardMessage((PS_NonStandardMessage)message, origin, tag, 0);
+            break;
+        case 1:
+            Analyze_MaintenanceLoopOffCommand((PS_MaintenanceLoopOffCommand)message, origin, tag, 0);
+            break;
+        case 2:
+            Analyze_SendTerminalCapabilitySet((PS_SendTerminalCapabilitySet)message, origin, tag, 0);
+            break;
+        case 3:
+            Analyze_EncryptionCommand((PS_EncryptionCommand)message, origin, tag, 0);
+            break;
+        case 4:
+            Analyze_FlowControlCommand((PS_FlowControlCommand)message, origin, tag, 0);
+            break;
+        case 5:
+            Analyze_EndSessionCommand((PS_EndSessionCommand)message, origin, tag, 0);
+            break;
+        case 6:
+            Analyze_MiscellaneousCommand((PS_MiscellaneousCommand)message, origin, tag, 0);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 7:
+            Analyze_CommunicationModeCommand((PS_CommunicationModeCommand)message, origin, tag, 0);
+            break;
+        case 8:
+            Analyze_ConferenceCommand((PS_ConferenceCommand)message, origin, tag, 0);
+            break;
+        case 9:
+            Analyze_H223MultiplexReconfiguration((PS_H223MultiplexReconfiguration)message, origin, tag, 0);
+            break;
+        case 10:
+            Analyze_NewATMVCCommand((PS_NewATMVCCommand)message, origin, tag, 0);
+            break;
+        default:
+            ErrorMessage("CommandMessage_analyze: Illegal CHOICE index");
+    }
+}
+
+/* ================================================= */
+/* PER Analysis for IndicationMessage (RAN)          */
+/* ================================================= */
+void IndicationMessage_analyze(uint16 tag, uint8 type2, uint8* message)
+{
+    int8 origin[] = "indicationMessage";
+    switch (type2)
+    {
+        case 0:
+            Analyze_NonStandardMessage((PS_NonStandardMessage)message, origin, tag, 0);
+            break;
+        case 1:
+            Analyze_FunctionNotUnderstood((PS_FunctionNotUnderstood)message, origin, tag, 0);
+            break;
+        case 2:
+            Analyze_MasterSlaveDeterminationRelease((PS_MasterSlaveDeterminationRelease)message, origin, tag, 0);
+            break;
+        case 3:
+            Analyze_TerminalCapabilitySetRelease((PS_TerminalCapabilitySetRelease)message, origin, tag, 0);
+            break;
+        case 4:
+            Analyze_OpenLogicalChannelConfirm((PS_OpenLogicalChannelConfirm)message, origin, tag, 0);
+            break;
+        case 5:
+            Analyze_RequestChannelCloseRelease((PS_RequestChannelCloseRelease)message, origin, tag, 0);
+            break;
+        case 6:
+            Analyze_MultiplexEntrySendRelease((PS_MultiplexEntrySendRelease)message, origin, tag, 0);
+            break;
+        case 7:
+            Analyze_RequestMultiplexEntryRelease((PS_RequestMultiplexEntryRelease)message, origin, tag, 0);
+            break;
+        case 8:
+            Analyze_RequestModeRelease((PS_RequestModeRelease)message, origin, tag, 0);
+            break;
+        case 9:
+            Analyze_MiscellaneousIndication((PS_MiscellaneousIndication)message, origin, tag, 0);
+            break;
+        case 10:
+            Analyze_JitterIndication((PS_JitterIndication)message, origin, tag, 0);
+            break;
+        case 11:
+            Analyze_H223SkewIndication((PS_H223SkewIndication)message, origin, tag, 0);
+            break;
+        case 12:
+            Analyze_NewATMVCIndication((PS_NewATMVCIndication)message, origin, tag, 0);
+            break;
+        case 13:
+            Analyze_UserInputIndication((PS_UserInputIndication)message, origin, tag, 0);
+            break;
+            /* ------------------------------- */
+            /* ---- Extension Begins Here ---- */
+            /* ------------------------------- */
+        case 14:
+            Analyze_H2250MaximumSkewIndication((PS_H2250MaximumSkewIndication)message, origin, tag, 0);
+            break;
+        case 15:
+            Analyze_MCLocationIndication((PS_MCLocationIndication)message, origin, tag, 0);
+            break;
+        case 16:
+            Analyze_ConferenceIndication((PS_ConferenceIndication)message, origin, tag, 0);
+            break;
+        case 17:
+            Analyze_VendorIdentification((PS_VendorIdentification)message, origin, tag, 0);
+            break;
+        case 18:
+            Analyze_FunctionNotSupported((PS_FunctionNotSupported)message, origin, tag, 0);
+            break;
+        case 19:
+            Analyze_MultilinkIndication((PS_MultilinkIndication)message, origin, tag, 0);
+            break;
+        case 20:
+            Analyze_LogicalChannelRateRelease((PS_LogicalChannelRateRelease)message, origin, tag, 0);
+            break;
+        case 21:
+            Analyze_FlowControlIndication((PS_FlowControlIndication)message, origin, tag, 0);
+            break;
+        default:
+            ErrorMessage("IndicationMessage_analyze: Illegal CHOICE index");
+    }
+}
+
+/*********************************************/
+/* Text Descriptions of Codewords	         */
+/* (For printing to codeword.txt)            */
+/*********************************************/
+char *EncodeDescription[ 4][ 24 ] =
+{
+    /* Request Message */
+    {   "NonStandardMessage",		/* 0: NonStandardMessage		    */
+        "MasterSlaveDetermination",	/* 1: MasterSlaveDetermination	    */
+        "TerminalCapabilitySet",		/* 2: TerminalCapabilitySet		    */
+        "OpenLogicalChannel",		/* 3: OpenLogicalChannel 		    */
+        "CloseLogicalChannel",		/* 4: CloseLogicalChannel		    */
+        "RequestChannelClose",		/* 5: RequestChannelClose		    */
+        "MultiplexEntrySend",		/* 6: MultiplexEntrySend		    */
+        "RequestMultiplexEntry",		/* 7: RequestMultiplexEntry		    */
+        "RequestMode",				/* 8: RequestMode			    */
+        "RoundTripDelayRequest",		/* 9: RoundTripDelayRequest		    */
+        "MaintenanceLoopRequest",	/* A: MaintenanceLoopRequest	    */
+        "CommunicationModeRequest",	/* B: CommunicationModeRequest	    */
+        "ConferenceRequest",			/* C: ConferenceRequest		    */
+        "H223AnnexAReConfiguration", /* D: H223AnnexAReconfiguration	    */
+        "(Not Defined)",					    /* E: ( Not Define  )		    */
+        "(Not Defined)",					    /* 10: ( Not Define  )		    */
+        "(Not Defined)",					    /* 11: ( Not Define  )		    */
+        "(Not Defined)",					    /* 12: ( Not Define  )		    */
+        "(Not Defined)",					    /* 13: ( Not Define  )		    */
+        "(Not Defined)",					    /* 14: ( Not Define  )		    */
+        "(Not Defined)",					    /* 15: ( Not Define  )		    */
+        "(Not Defined)" },				    /* 16: ( Not Define  )		    */
+
+    /* Response Messeage */
+    {   "NonStandardMessage",			    /* 0: NonStandradMessage		    */
+        "MasterSlaveDeterminationAck",             /* 1: MasterSlaveDeterminationAck	    */
+        "MasterSlaveDeterminationReject",          /* 2: MasterSlaveDeterminationReject    */
+        "TerminalCapabilitySetAck",                /* 3: TerminalCapabilitySetAck	    */
+        "TerminalCapabilitySetReject",             /* 4: TerminalCapabilitySetReject	    */
+        "OpenLogicalChannelAck",                   /* 5: OpenLogicalChannelAck		    */
+        "OpenLogicalChannelReject",                /* 6: OpenLogicalChannelReject	    */
+        "CloseLogicalChannelAck",                  /* 7: CloseLogicalChannelAck	    */
+        "RequestChannelCloseAck",                  /* 8: RequestChannelCloseAck	    */
+        "RequestChannelCloseReject",               /* 9: RequestChannelCloseReject	    */
+        "MultiplexEntrySendAck",                   /* A: MultiplexEntrySendAck		    */
+        "MultiplexEntrySendReject",                /* B: MultiplexEntrySendReject	    */
+        "RequestMultiplexEntryAck",                /* C: RequestMultiplexEntryAck	    */
+        "RequestMultiplexEntryReject",	    	    /* D: RequestMultiplexEntryReject	    */
+        "RequestModeAck",                          /* E: RequestModeAck		    */
+        "RequestModeReject",                       /* F RequestModeReject		    */
+        "RoundTripDelayResponse",                  /* 10 RoundTripDelayResponse	    */
+        "MaintenanceLoopAck",                      /* 11 MaintenanceLoopAck		    */
+        "MaintenanceLoopReject",                   /* 12 MaintenanceLoopReject		    */
+        "CommunicationModeResponse",               /* 13 CommunicationModeResponse	    */
+        "ConferenceResponse",		    	    /* 14 ConferenceResponse		    */
+        "H223AnnexAReConfigurationAck",	    /* 15 H223AnnexAReconfigurationAck	    */
+        "H223AnnexAReConfigurationReject" },	    /* 16 H223AnnexAReconfigurationReject   */
+
+    /* Command Messeage */
+    {   "NonStandardMessage",			    /* 0: NonStandradMessage		    */
+        "MaintenanceLoopOffCommand",               /* 1: MaintenanceLoopOffCommand	    */
+        "SendTerminalCapabilitySet",               /* 2: SendTerminalCapabilitySet	    */
+        "EncryptionCommand",                       /* 3: EncryptionCommand		    */
+        "FlowControlCommand",                      /* 4: FlowControlCommand		    */
+        "EndSessionCommand",                       /* 5: EndSessionCommand		    */
+        "MiscellaneousCommand",                    /* 6: MiscellaneousCommand		    */
+        "CommunicationModeCommand",                /* 7: CommunicationModeCommand	    */
+        "ConferenceCommand",			    /* 8: ConferenceCommand		    */
+        "H223MultiplexReconfiguration",
+        "(Not Defined)",					    /* B:  ( Not Define  )		    */
+        "(Not Defined)",					    /* C:  ( Not Define  )		    */
+        "(Not Defined)",					    /* D:  ( Not Define  )		    */
+        "(Not Defined)",					    /* E:  ( Not Define  )		    */
+        "(Not Defined)",					    /* F:  ( Not Define  )		    */
+        "(Not Defined)",					    /* 10: ( Not Define  )		    */
+        "(Not Defined)",					    /* 11: ( Not Define  )		    */
+        "(Not Defined)",					    /* 12: ( Not Define  )		    */
+        "(Not Defined)",					    /* 13: ( Not Define  )		    */
+        "(Not Defined)",					    /* 14: ( Not Define  )		    */
+        "(Not Defined)",					    /* 15: ( Not Define  )		    */
+        "(Not Defined)" },				    /* 16: ( Not Define  )		    */
+
+    /* Indication Message */
+    {   "NonStandardMessage",			    /* 0: NonStandradMessage		    */
+        "FunctionNotUnderstood",                   /* 1: FunctionNotUnderstood		    */
+        "MasterSlaveDeterminationRelease",         /* 2: MasterSlaveDeterminationRelease   */
+        "TerminalCapabilitySetRelease",            /* 3: TerminalCapabilitySetRelease	    */
+        "OpenLogicalChannelConfirm",               /* 4: OpenLogicalChannelConfirm	    */
+        "RequestChannelCloseRelease",              /* 5: RequestChannelCloseRelease	    */
+        "MultiplexEntrySendRelease",               /* 6: MultiplexEntrySendRelease	    */
+        "RequestMultiplexEntryRelease",            /* 7: RequestMultiplexEntryRelease	    */
+        "RequestModeRelease",                      /* 8: RequestModeRelease		    */
+        "MiscellaneousIndication",		    /* 9: MiscellaneousIndication	    */
+        "JitterIndication",                        /* A: JitterIndication		    */
+        "H223SkewIndication",                      /* B: H223SkewIndication		    */
+        "NewATMVCIndication",                      /* C: NewATMVCIndication		    */
+        "UserInputIndication",                     /* D: UserInputIndication		    */
+        "H2250MaximumSkewIndication",              /* E: H2250MaximumSkewIndication	    */
+        "MCLocationIndication",                    /* F: MCLocationIndication		    */
+        "ConferenceIndication",                    /* 10:ConferenceIndication		    */
+        "VendorIdentification",                    /* 11:VendorIndication		    */
+        "FunctionNotSupported",		    /* 12:FunctionNotSupported		    */
+        "(Not Defined)",					    /* 13: ( Not Define  )		    */
+        "(Not Defined)",					    /* 14: ( Not Define  )		    */
+        "FlowControlCommand",	/* WWU_IND 15: FlowControl		*/
+        "(Not Defined)" }					    /* 16: ( Not Define  )		    */
+};
+
+/* ================================================= */
+/* Display an H.245 Message Bitstream as Hex         */
+/* ================================================= */
+void ShowH245Hex(uint16 tag, uint8 type1, uint8 type2, uint16 size, uint8* data)
+{
+    Show245(tag, 0, "<============= BEGIN H.245 MESSAGE (HEX) =============>");
+    Show245(tag, 0, EncodeDescription[type1][type2]);
+    ShowHexData(tag, 2, size, data);
+    Show245(tag, 0, "<============== END H.245 MESSAGE (HEX) ==============>");
+    Show245(tag, 0, " ");
+}
+
+#endif  /* end PVANALYZER */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/annex.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/annex.h
new file mode 100644
index 0000000..9cb9657
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/annex.h
@@ -0,0 +1,164 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seannex.h                                         */
+/*  file contents   : Other Management Header ( Annex )                 */
+/*  draw            : '96.11.28                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEANNEX_H_
+#define _SEANNEX_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245pri.h"
+#include "h245def.h"
+#include "sebase.h"
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class Annex : public SEBase
+{
+    public:
+        Annex() : SEBase() {}
+        ~Annex() {}
+        void Reset() {}
+        void MsgSend(uint8 , uint8 , uint8*) ;
+        void PtvSend(uint32 , uint32 , uint32 , uint32 , uint8* , uint32, uint8* EncodedMsg = NULL, uint32 EncodedMsgSize = 0) ;
+
+    private:
+        Annex(const Annex&);
+};
+
+class NSD : public Annex
+{
+    public:
+        NSD() : Annex() {}
+        ~NSD() {}
+        void _1000_XXXX(PS_NonStandardMessage) ;
+        void _1001_XXXX(PS_NonStandardMessage) ;
+        void _1002_XXXX(PS_NonStandardMessage) ;
+        void _1003_XXXX(PS_NonStandardMessage) ;
+        void _1004_XXXX(PS_NonStandardMessage) ;
+        void _1005_XXXX(PS_NonStandardMessage) ;
+        void _1006_XXXX(PS_NonStandardMessage) ;
+        void _1007_XXXX(PS_NonStandardMessage) ;
+    private:
+        NSD(const NSD&);
+};
+
+class CM : public Annex
+{
+    public:
+        CM() : Annex() {}
+        ~CM() {}
+        void _1100_XXXX(PS_CommunicationModeRequest) ;
+        void _1101_XXXX(PS_CommunicationModeRequest) ;
+        void _1102_XXXX(PS_CommunicationModeResponse) ;
+        void _1103_XXXX(PS_CommunicationModeResponse) ;
+        void _1104_XXXX(PS_CommunicationModeCommand) ;
+        void _1105_XXXX(PS_CommunicationModeCommand) ;
+    private:
+        CM(const NSD&);
+};
+
+class CNF : public Annex
+{
+    public:
+        CNF() : Annex() {}
+        ~CNF() {}
+        void _1300_XXXX(PS_ConferenceRequest) ;
+        void _1301_XXXX(PS_ConferenceRequest) ;
+        void _1302_XXXX(PS_ConferenceResponse) ;
+        void _1303_XXXX(PS_ConferenceResponse) ;
+    private:
+        CNF(const NSD&);
+};
+
+class CMD : public Annex
+{
+    public:
+        CMD() : Annex() {}
+        ~CMD() {}
+        void _1400_XXXX(PS_SendTerminalCapabilitySet) ;
+        void _1401_XXXX(PS_SendTerminalCapabilitySet) ;
+        void _1402_XXXX(PS_EncryptionCommand) ;
+        void _1403_XXXX(PS_EncryptionCommand) ;
+        void _1404_XXXX(PS_FlowControlCommand) ;
+        void _1405_XXXX(PS_FlowControlCommand, uint8* EncodedMsg = NULL, uint32 EncodedMsgSize = 0) ;
+        void _1406_XXXX(PS_EndSessionCommand) ;
+        void _1407_XXXX(PS_EndSessionCommand) ;
+        void _1408_XXXX(PS_MiscellaneousCommand) ;
+        void _1409_XXXX(PS_MiscellaneousCommand, uint8* EncodedMsg = NULL, uint32 EncodedMsgSize = 0) ;
+        void _140A_XXXX(PS_ConferenceCommand) ;
+        void _140B_XXXX(PS_ConferenceCommand) ;
+        void _140C_XXXX(PS_H223MultiplexReconfiguration) ;
+        void _140D_XXXX(PS_H223MultiplexReconfiguration, uint8* EncodedMsg = NULL, uint32 EncodedMsgSize = 0) ;
+    private:
+        CMD(const NSD&);
+};
+
+class IDC : public Annex
+{
+    public:
+        IDC() : Annex() {}
+        ~IDC() {}
+        void _1500_XXXX(PS_FunctionNotUnderstood) ;
+        void _1501_XXXX(PS_FunctionNotUnderstood) ;
+        void _1502_XXXX(PS_MiscellaneousIndication) ;
+        void _1503_XXXX(PS_MiscellaneousIndication) ;
+        void _1504_XXXX(PS_JitterIndication) ;
+        void _1505_XXXX(PS_JitterIndication) ;
+        void _1506_XXXX(PS_H223SkewIndication) ;
+        void _1507_XXXX(PS_H223SkewIndication) ;
+        void _1508_XXXX(PS_NewATMVCIndication) ;
+        void _1509_XXXX(PS_NewATMVCIndication) ;
+        void _150A_XXXX(PS_UserInputIndication) ;
+        void _150B_XXXX(PS_UserInputIndication) ;
+        void _150C_XXXX(PS_ConferenceIndication) ;
+        void _150D_XXXX(PS_ConferenceIndication) ;
+        void _150E_XXXX(PS_H2250MaximumSkewIndication) ;
+        void _150F_XXXX(PS_H2250MaximumSkewIndication) ;
+        void _1510_XXXX(PS_MCLocationIndication) ;
+        void _1511_XXXX(PS_MCLocationIndication) ;
+        void _1512_XXXX(PS_VendorIdentification) ;
+        void _1513_XXXX(PS_VendorIdentification) ;
+        void _1514_XXXX(PS_FunctionNotSupported) ;
+        void _1515_XXXX(PS_FunctionNotSupported) ;
+        void _1516_XXXX(PS_FlowControlIndication) ;
+        void _1517_XXXX(PS_FlowControlIndication) ;
+    private:
+        IDC(const IDC&);
+};
+
+#endif /* _SEANNEX_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/blc.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/blc.h
new file mode 100644
index 0000000..cf199eb
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/blc.h
@@ -0,0 +1,96 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seblc.h                                           */
+/*  file contents   : Bi-Directional Logical Channel Signalling Entity  */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEBLC_H_
+#define _SEBLC_H_
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245pri.h"
+#include "lcblccmn.h"
+
+class MSD;
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class BLC : public LCBLCCmn
+{
+    public:
+        BLC() : LCBLCCmn(), MyMSD(0) {}
+        ~BLC() {}
+
+        void SetMSD(MSD *msd)
+        {
+            MyMSD = msd;
+        }
+
+        void Reset() {}
+
+        void _0300_0000(LCEntry*, PS_ForwardReverseParam) ;
+        void _0300_0030(LCEntry*, PS_ForwardReverseParam) ;
+        void _0301_0010(LCEntry*, PS_OpenLogicalChannel) ;
+        void _0303_0010(LCEntry*, PS_OlcRejectCause) ;
+        void _0303_0020(LCEntry*, PS_OlcRejectCause) ;
+        void _0304_0000(LCEntry*, PS_OpenLogicalChannelAck) ;
+        void _0304_0010(LCEntry*, PS_OpenLogicalChannelAck) ;
+        void _0306_0000(LCEntry*, PS_OpenLogicalChannelReject) ;
+        void _0306_0010(LCEntry*, PS_OpenLogicalChannelReject) ;
+        void _0306_0020(LCEntry*, PS_OpenLogicalChannelReject) ;
+        void _0306_0030(LCEntry*, PS_OpenLogicalChannelReject) ;
+        void _0307_0010(LCEntry*, int32) ;
+        void _0307_0030(LCEntry*, int32) ;
+        void _0309_0020(LCEntry*, PS_CloseLogicalChannelAck) ;
+        void _0309_0030(LCEntry*, PS_CloseLogicalChannelAck) ;
+        void _0301_0001(LCEntry*, PS_OpenLogicalChannel) ;
+        void _0301_0011(LCEntry*, PS_OpenLogicalChannel) ;
+        void _0301_0021(LCEntry*, PS_OpenLogicalChannel) ;
+        void _0302_0011(LCEntry*, PS_ReverseData , uint16) ;
+        void _0303_0011(LCEntry*, PS_OlcRejectCause) ;
+        void _0305_0011(LCEntry*, PS_OpenLogicalChannelConfirm) ;
+        void _0305_0021(LCEntry*, PS_OpenLogicalChannelConfirm) ;
+        void _0307_0021(LCEntry*, int32) ;
+        void _0308_0001(LCEntry*, PS_CloseLogicalChannel) ;
+        void _0308_0011(LCEntry*, PS_CloseLogicalChannel) ;
+        void _0308_0021(LCEntry*, PS_CloseLogicalChannel) ;
+
+    private:
+        BLC(const BLC&);
+        MSD *MyMSD;
+};
+
+#endif /* _SEBLC_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/ce.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/ce.h
new file mode 100644
index 0000000..4d2e959
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/ce.h
@@ -0,0 +1,362 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : sece.h                                            */
+/*  file contents   : Capability Exchange Signalling Entity             */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SECE_H_
+#define _SECE_H_
+
+#include "oscl_base.h"
+#include "sebase.h"
+#include "oscl_timer.h"
+#include "h245def.h"
+#include "h245inf.h"
+
+enum CESource { CE_USER, CE_PROTOCOL };
+enum CECause
+{
+    CE_UNSPECIFIED = 0,
+    CE_UNDEFINED_TABLE_ENTRY_USED,
+    CE_DESCRIPTOR_CAPACITY_EXCEEDED,
+    CE_TABLE_ENTRY_CAPACITY_EXCEEDED
+};
+enum CEDirection { CE_OUTGOING, CE_INCOMING };
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+class CEObserver
+{
+    public:
+        virtual ~CEObserver() {}
+        virtual void CETransferIndication(OsclSharedPtr<S_TerminalCapabilitySet> tcs) = 0;
+        virtual void CETransferConfirm() = 0;
+        virtual void CERejectIndication(CESource source, CECause cause, CEDirection direction) = 0;
+};
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+class CE : public SEBase, public OsclTimerObserver
+{
+    private:
+        enum CEState { IDLE, AWAITING_RESPONSE }; // states
+
+    public:
+        CE() :
+                Observer(NULL),
+                OutgoingState(IDLE),
+                IncomingState(IDLE),
+                OutSeqNum(0),
+                InSeqNum(0xff)
+        {}
+
+        ~CE() {}
+
+        void Reset()
+        {
+            Print("Reset CE\n");
+            OutgoingState = IDLE;
+            IncomingState = IDLE;
+            OutSeqNum = 0;
+            InSeqNum = 0xff;
+            ResetTimer();
+        }
+
+        void SetObserver(CEObserver *observer)
+        {
+            Observer = observer;
+        }
+
+        // Primitives
+        void TransferRequest(PS_TerminalCapabilitySet tcs)
+        {
+            Print("Received CE Transfer Request\n");
+            switch (OutgoingState)
+            {
+                case IDLE:
+                    OutgoingIdle(tcs);
+                    break;
+                case AWAITING_RESPONSE:
+                default:
+                    break;
+            }
+        }
+
+        void TransferResponse()
+        {
+            Print("Received CE Transfer Response\n");
+            switch (IncomingState)
+            {
+                case IDLE:
+                    break;
+                case AWAITING_RESPONSE:
+                    IncomingAwaitingResponse();
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void RejectRequest(CECause cause, uint16 highestEntryProcessed = 0)
+        {
+            Print("Received CE Reject Request\n");
+            switch (IncomingState)
+            {
+                case IDLE:
+                    break;
+                case AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(cause, highestEntryProcessed);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        // Outgoing Message Handlers
+        void Handler(PS_TerminalCapabilitySetAck tcsa)
+        {
+            Print("Received TCSAck \n");
+            switch (OutgoingState)
+            {
+                case IDLE:
+                    break;
+                case AWAITING_RESPONSE:
+                    OutgoingAwaitingResponse(tcsa);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void Handler(PS_TerminalCapabilitySetReject tcsr)
+        {
+            Print("Received TCSReject\n");
+            switch (OutgoingState)
+            {
+                case IDLE:
+                    break;
+                case AWAITING_RESPONSE:
+                    OutgoingAwaitingResponse(tcsr);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void HandlerTimeout()
+        {
+            Print("Received TCS Timeout\n");
+            switch (OutgoingState)
+            {
+                case IDLE:
+                    break;
+                case AWAITING_RESPONSE:
+                    OutgoingAwaitingResponseTimeout();
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        // Incoming Message Handlers
+        void Handler(OsclSharedPtr<S_TerminalCapabilitySet> tcs)
+        {
+            Print("Received TCS\n");
+            switch (IncomingState)
+            {
+                case IDLE:
+                    IncomingIdle(tcs);
+                    break;
+                case AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(tcs);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void Handler(PS_TerminalCapabilitySetRelease tcsr)
+        {
+            Print("Received TCSRelease\n");
+            switch (IncomingState)
+            {
+                case IDLE:
+                    break;
+                case AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(tcsr);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+        {
+            Print("    CE::TimeoutOccurred");
+            OSCL_UNUSED_ARG(timerID);
+            OSCL_UNUSED_ARG(timeoutInfo);
+            HandlerTimeout();
+        }
+
+    private:
+        CE(const CE&);
+        CE& operator=(const CE&);
+
+        CEObserver *Observer;
+        CEState OutgoingState;
+        CEState IncomingState;
+        uint8 OutSeqNum;
+        uint8 InSeqNum;
+
+        void SetTimer()
+        {
+            RequestTimer(101, 0, TimerDuration, this);
+        }
+        void ResetTimer()
+        {
+            CancelTimer(101);
+        }
+
+        void OutgoingIdle(PS_TerminalCapabilitySet tcs)
+        {
+            OutSeqNum++;
+            SetTimer();
+            OutgoingState = AWAITING_RESPONSE;
+            SendTerminalCapabilitySet(tcs);
+        }
+
+        void OutgoingAwaitingResponse(PS_TerminalCapabilitySetAck tcsa)
+        {
+            if (tcsa->sequenceNumber == OutSeqNum)
+            {
+                ResetTimer();
+                OutgoingState = IDLE;
+                if (Observer) Observer->CETransferConfirm();
+            }
+        }
+
+        void OutgoingAwaitingResponse(PS_TerminalCapabilitySetReject tcsr)
+        {
+            if (tcsr->sequenceNumber == OutSeqNum)
+            {
+                ResetTimer();
+                OutgoingState = IDLE;
+                if (Observer) Observer->CERejectIndication(CE_USER, (CECause)tcsr->tcsRejectCause.index, CE_OUTGOING);
+            }
+        }
+
+        void OutgoingAwaitingResponseTimeout()
+        {
+            OutgoingState = IDLE;
+            SendTerminalCapabilitySetRelease();
+            if (Observer) Observer->CERejectIndication(CE_PROTOCOL, CE_UNSPECIFIED, CE_OUTGOING);
+        }
+
+        void IncomingIdle(OsclSharedPtr<S_TerminalCapabilitySet> tcs)
+        {
+            InSeqNum = tcs->sequenceNumber;
+            IncomingState = AWAITING_RESPONSE;
+            if (Observer) Observer->CETransferIndication(tcs);
+        }
+
+        // handles TransferResponse
+        void IncomingAwaitingResponse()
+        {
+            IncomingState = IDLE;
+            SendTerminalCapabilitySetAck();
+        }
+
+        // handles RejectRequest
+        void IncomingAwaitingResponse(CECause cause, uint16 highestEntryProcessed)
+        {
+            IncomingState = IDLE;
+            SendTerminalCapabilitySetReject(cause, highestEntryProcessed);
+        }
+
+        void IncomingAwaitingResponse(PS_TerminalCapabilitySetRelease tcsr)
+        {
+            OSCL_UNUSED_ARG(tcsr);
+            IncomingState = IDLE;
+            if (Observer) Observer->CERejectIndication(CE_PROTOCOL, CE_UNSPECIFIED, CE_INCOMING);
+        }
+
+        void IncomingAwaitingResponse(OsclSharedPtr<S_TerminalCapabilitySet> tcs)
+        {
+            InSeqNum = tcs->sequenceNumber;
+            IncomingState = AWAITING_RESPONSE;
+            if (Observer) Observer->CERejectIndication(CE_USER, CE_UNSPECIFIED, CE_INCOMING);
+            if (Observer) Observer->CETransferIndication(tcs);
+        }
+
+        void SendTerminalCapabilitySet(PS_TerminalCapabilitySet tcs)
+        {
+            Print("    Sending TCS\n");
+            tcs->sequenceNumber = OutSeqNum;
+            MessageSend(H245_MSG_REQ, MSGTYP_CE, (uint8*)tcs);
+        }
+
+        void SendTerminalCapabilitySetAck()
+        {
+            Print("    Sending TCS Ack\n");
+            S_TerminalCapabilitySetAck tcsa ;
+            tcsa.sequenceNumber = InSeqNum;
+            MessageSend(H245_MSG_RPS, MSGTYP_CE_ACK, (uint8*)&tcsa);
+        }
+
+        void SendTerminalCapabilitySetRelease()
+        {
+            Print("    Sending TCS Release\n");
+            S_TerminalCapabilitySetRelease tcsr;
+            oscl_memset((int8*)&tcsr, 0, sizeof(S_TerminalCapabilitySetRelease)) ;
+            MessageSend(H245_MSG_IDC, MSGTYP_CE_RLS, (uint8*)&tcsr);
+        }
+
+        void SendTerminalCapabilitySetReject(CECause cause, uint16 highestEntryProcessed)
+        {
+            Print("    Sending TCS Reject\n");
+            S_TerminalCapabilitySetReject tcsr;
+            S_TableEntryCapacityExceeded tece;
+
+            tcsr.sequenceNumber = InSeqNum;
+            tcsr.tcsRejectCause.index = (uint16)cause;
+            if (cause == CE_TABLE_ENTRY_CAPACITY_EXCEEDED)
+            {
+                tcsr.tcsRejectCause.tableEntryCapacityExceeded = &tece;
+                tcsr.tcsRejectCause.tableEntryCapacityExceeded->index = (uint16)(highestEntryProcessed ? 0 : 1);
+                tcsr.tcsRejectCause.tableEntryCapacityExceeded->highestEntryNumberProcessed = highestEntryProcessed;
+            }
+            MessageSend(H245_MSG_RPS, MSGTYP_CE_RJT, (uint8*)&tcsr);
+        }
+};
+
+#endif /* _SECE_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/clc.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/clc.h
new file mode 100644
index 0000000..73acd09
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/clc.h
@@ -0,0 +1,85 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seclc.h                                           */
+/*  file contents   : Close Logical Channel Signalling Entity           */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.19                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SECLC_H_
+#define _SECLC_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "h245pri.h"
+#include	"lcentry.h"
+#include	"sebase.h"
+
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class CLC : public SEBase
+{
+    public:
+        CLC() : SEBase() {}
+        ~CLC() {}
+
+        void Reset() {}
+
+        void _0400_0000(LCEntry*) ;
+        void _0401_0001(LCEntry*) ;
+        void _0401_0011(LCEntry*) ;
+        void _0402_0011(LCEntry*) ;
+        void _0403_0011(LCEntry*, PS_RccRejectCause) ;
+        void _0404_0010(LCEntry*) ;
+        void _0405_0010(LCEntry*, PS_RequestChannelCloseReject) ;
+        void _0406_0010(LCEntry*, int32) ;
+        void _0407_0011(LCEntry*) ;
+
+    private:
+        CLC(const CLC&);
+
+        void MsgCloseSend(LCEntry*) ;
+        void MsgCloseAckSend(LCEntry*) ;
+        void MsgCloseRjtSend(LCEntry*, PS_RccRejectCause) ;
+        void MsgCloseRlsSend(LCEntry*) ;
+        void PtvCloseIdcSend(LCEntry*) ;
+        void PtvRjtIdcSend(LCEntry*, int32 , PS_RccRejectCause) ;
+        void PtvCloseCfmSend(LCEntry*) ;
+        int32 T108TimerIdGet(LCEntry*);
+        void T108TimerStart(LCEntry*) ;
+        void T108TimerStop(LCEntry*) ;
+};
+
+#endif /* _SECLC_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/lc.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/lc.h
new file mode 100644
index 0000000..1832085
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/lc.h
@@ -0,0 +1,92 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : selc.h                                            */
+/*  file contents   : Uni-Directional Logical Channel Signalling Entity */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SELC_H_
+#define _SELC_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "h245pri.h"
+#include    "lcblccmn.h"
+
+class MSD;
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class LC : public LCBLCCmn
+{
+    public:
+        LC() : LCBLCCmn(), MyMSD(0) {}
+        ~LC() {}
+
+        void SetMSD(MSD *msd)
+        {
+            MyMSD = msd;
+        }
+
+        void Reset() {}
+
+        void _0200_0000(LCEntry* , PS_ForwardReverseParam) ;
+        void _0200_0030(LCEntry* , PS_ForwardReverseParam) ;
+        void _0201_0010(LCEntry* , PS_OpenLogicalChannel) ;
+        void _0203_0010(LCEntry* , PS_OlcRejectCause) ;
+        void _0203_0020(LCEntry* , PS_OlcRejectCause) ;
+        void _0204_0000(LCEntry* , PS_OpenLogicalChannelAck) ;
+        void _0204_0010(LCEntry* , PS_OpenLogicalChannelAck) ;
+        void _0206_0000(LCEntry* , PS_OpenLogicalChannelReject) ;
+        void _0206_0010(LCEntry* , PS_OpenLogicalChannelReject) ;
+        void _0206_0020(LCEntry* , PS_OpenLogicalChannelReject) ;
+        void _0206_0030(LCEntry* , PS_OpenLogicalChannelReject) ;
+        void _0207_0010(LCEntry* , int32) ;
+        void _0207_0030(LCEntry* , int32) ;
+        void _0209_0020(LCEntry* , PS_CloseLogicalChannelAck) ;
+        void _0209_0030(LCEntry* , PS_CloseLogicalChannelAck) ;
+        void _0201_0001(LCEntry* , PS_OpenLogicalChannel) ;
+        void _0201_0011(LCEntry* , PS_OpenLogicalChannel) ;
+        void _0202_0011(LCEntry* , PS_ReverseData) ;
+        void _0203_0011(LCEntry* , PS_OlcRejectCause) ;
+        void _0208_0001(LCEntry* , PS_CloseLogicalChannel) ;
+        void _0208_0011(LCEntry* , PS_CloseLogicalChannel) ;
+
+    private:
+        LC(const LC&);
+        MSD *MyMSD;
+};
+
+#endif /* _SELC_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/lcblc.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/lcblc.h
new file mode 100644
index 0000000..7da0729
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/lcblc.h
@@ -0,0 +1,649 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : selcblc.h                                           */
+/*  file contents   : Common Logical Channel / Bi-directional Logical Channel */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SELCBLC_
+#define _SELCBLC_
+
+#include "oscl_base.h"
+#include "sebase.h"
+#include "h245def.h"
+#include "h245inf.h"
+#include "semsgque.h"
+
+enum LCBLCErrCode
+{
+    LCBLC_ERROR_CODE_A = 0, // inappropriate message
+    LCBLC_ERROR_CODE_B = 1, // inappropriate message
+    LCBLC_ERROR_CODE_C = 2, // inappropriate message
+    LCBLC_ERROR_CODE_D = 3  // no response from peer LCSE
+};
+
+enum LCBLCSource { LCBLC_USER, LCBLC_SE };
+enum LCBLCCause
+{
+    LCBLC_UNSPECIFIED = 0,  /* (NULL) unspecified */
+    LCBLC_UNSUITABLE_REVERSE_PARAMETERS, /* (NULL) unsuitableReverseParameters */
+    LCBLC_DATA_TYPE_NOT_SUPPORTED, /* (NULL) dataTypeNotSupported */
+    LCBLC_DATA_TYPE_NOT_AVAILABLE, /* (NULL) dataTypeNotAvailable */
+    LCBLC_UNKNOWN_DATA_TYPE, /* (NULL) unknownDataType */
+    LCBLC_DATA_TYPE_AL_COMBINATION_NOT_SUPPORTED, /* (NULL) dataTypeALCombinationNotSupported */
+    LCBLC_MULTICAST_CHANNEL_NOT_ALLOWED, /* (NULL) multicastChannelNotAllowed */
+    LCBLC_INSUFFICIENT_BANDWIDTH, /* (NULL) insufficientBandwidth */
+    LCBLC_SEPERATE_STACK_ESTABLISHMENT_FAILED, /* (NULL) separateStackEstablishmentFailed */
+    LCBLC_INVALID_SESSION_ID, /* (NULL) invalidSessionID */
+    LCBLC_MASTER_SLAVE_CONFLICT, /* (NULL) masterSlaveConflict */
+    LCBLC_WAIT_FOR_COMMUNICATION_MODE, /* (NULL) waitForCommunicationMode */
+    LCBLC_INVALID_DEPENDENT_CHANNEL, /* (NULL) invalidDependentChannel */
+    LCBLC_REPLACEMENT_FOR_REJECTED /* (NULL) replacementForRejected */
+};
+enum LCBLCDirection { LCBLC_OUTGOING, LCBLC_INCOMING };
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+class LCBLCObserver
+{
+    public:
+        virtual void LCBLCEstablishIndication(uint32 forwardLcn, PS_ForwardLogicalChannelParameters fwdparam, uint32 reverseLcn, PS_ReverseLogicalChannelParameters revparam) = 0;
+        virtual void LCBLCEstablishConfirm(uint32 forwardLcn, uint32 reverseLcn, PS_OpenLogicalChannelAck olca) = 0;
+        virtual void LCBLCReleaseIndication(LCBLCSource source, LCBLCCause cause, uint32 ForwardLcn, uint32 ReverseLcn, LCBLCDirection direction) = 0;
+        virtual void LCBLCReleaseConfirm(uint32 forwardLcn, uint32 reverseLcn) = 0;
+        virtual void LCBLCErrorIndication(LCBLCErrCode error, uint32 forwardLcn, uint32 reverseLcn) = 0;
+};
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+class LCBLC : public SEBase, public SETimerObserver
+{
+    private:
+        enum LCBLCState { RELEASED, AWAITING_ESTABLISHMENT, ESTABLISHED, AWAITING_RELEASE }; // states
+
+    public:
+        LCBLC(uint32 forwardLcn, LCBLCDirection direction) :
+                Observer(NULL),
+                State(RELEASED),
+                Direction(direction),
+                ForwardLcn(forwardLcn),
+                ReverseLcn(0)
+        {}
+
+        ~LCBLC() {}
+
+        void SetObserver(LCBLCObserver *observer)
+        {
+            Observer = observer;
+        }
+
+        void EstablishRequest(PS_ForwardReverseParam param)
+        {
+            Print("R e c e i v e d   L C B L C   E s t a b l i s h   R e q u e s t\n");
+            if (GetDirection() == LCBLC_OUTGOING)
+            {
+                switch (GetState())
+                {
+                    case RELEASED:
+                        OutgoingReleased(param);
+                        break;
+                    case AWAITING_RELEASE:
+                        OutgoingAwaitingRelease(param);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void EstablishResponse()
+        {
+            Print("R e c e i v e d   L C B L C   E s t a b l i s h   R e s p o n s e\n");
+            if (GetDirection() == LCBLC_INCOMING)
+            {
+                switch (GetState())
+                {
+                    case AWAITING_ESTABLISHMENT:
+                        IncomingAwaitingEstablishment();
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void ReleaseRequest(LCBLCCause cause)
+        {
+            Print("R e c e i v e d   L C B L C   R e l e a s e   R e q u e s t\n");
+            if (GetDirection() == LCBLC_OUTGOING)
+            {
+                switch (GetState())
+                {
+                    case AWAITING_ESTABLISHMENT:
+                        OutgoingAwaitingEstablishment(cause);
+                        break;
+                    case ESTABLISHED:
+                        OutgoingEstablished(cause);
+                        break;
+                    default:
+                        break;
+                }
+            }
+            else
+            {
+                switch (GetState())
+                {
+                    case AWAITING_ESTABLISHMENT:
+                        IncomingAwaitingEstablishment(cause);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void Handler(PS_OpenLogicalChannel olc)
+        {
+            Print("R e c e i v e d   L C B L C   O p e n   L o g i c a l   C h a n n e l\n");
+            if (GetDirection() == LCBLC_INCOMING)
+            {
+                switch (GetState())
+                {
+                    case RELEASED:
+                        IncomingReleased(olc);
+                        break;
+                    case AWAITING_ESTABLISHMENT:
+                        IncomingAwaitingEstablishment(olc);
+                        break;
+                    case ESTABLISHED:
+                        IncomingEstablished(olc);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void Handler(PS_CloseLogicalChannel clc)
+        {
+            Print("R e c e i v e d   L C B L C   C l o s e   L o g i c a l   C h a n n e l\n");
+            if (GetDirection() == LCBLC_INCOMING)
+            {
+                switch (GetState())
+                {
+                    case RELEASED:
+                        IncomingReleased(clc);
+                        break;
+                    case AWAITING_ESTABLISHMENT:
+                        IncomingAwaitingEstablishment(clc);
+                        break;
+                    case ESTABLISHED:
+                        IncomingEstablished(clc);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void Handler(PS_OpenLogicalChannelAck olca)
+        {
+            Print("R e c e i v e d   L C B L C   O p e n   L o g i c a l   C h a n n e l   A c k\n");
+            if (GetDirection() == LCBLC_OUTGOING)
+            {
+                switch (GetState())
+                {
+                    case RELEASED:
+                        OutgoingReleased(olca);
+                        break;
+                    case AWAITING_ESTABLISHMENT:
+                        OutgoingAwaitingEstablishment(olca);
+                        break;
+                    case ESTABLISHED:
+                        OutgoingEstablished(olca);
+                        break;
+                    case AWAITING_RELEASE:
+                        OutgoingAwaitingRelease(olca);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void Handler(PS_OpenLogicalChannelReject olcr)
+        {
+            Print("R e c e i v e d   L C B L C   O p e n   L o g i c a l   C h a n n e l   R e j e c t\n");
+            if (GetDirection() == LCBLC_OUTGOING)
+            {
+                switch (GetState())
+                {
+                    case RELEASED:
+                        OutgoingReleased(olcr);
+                        break;
+                    case AWAITING_ESTABLISHMENT:
+                        OutgoingAwaitingEstablishment(olcr);
+                        break;
+                    case ESTABLISHED:
+                        OutgoingEstablished(olcr);
+                        break;
+                    case AWAITING_RELEASE:
+                        OutgoingAwaitingRelease(olcr);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void Handler(PS_CloseLogicalChannelAck clca)
+        {
+            Print("R e c e i v e d   L C B L C   C l o s e   L o g i c a l   C h a n n e l   A c k\n");
+            if (GetDirection() == LCBLC_OUTGOING)
+            {
+                switch (GetState())
+                {
+                    case RELEASED:
+                        OutgoingReleased(clca);
+                        break;
+                    case AWAITING_ESTABLISHMENT:
+                        OutgoingAwaitingEstablishment(clca);
+                        break;
+                    case ESTABLISHED:
+                        OutgoingEstablished(clca);
+                        break;
+                    case AWAITING_RELEASE:
+                        OutgoingAwaitingRelease(clca);
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void HandlerTimeout()
+        {
+            Print("R e c e i v e d   L C B L C   T i m e o u t\n");
+            if (GetDirection() == LCBLC_OUTGOING)
+            {
+                switch (GetState())
+                {
+                    case AWAITING_ESTABLISHMENT:
+                        OutgoingAwaitingEstablishmentTimeout();
+                        break;
+                    case AWAITING_RELEASE:
+                        OutgoingAwaitingReleaseTimeout();
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+        {
+            HandlerTimeout();
+        }
+
+    private:
+        LCBLC(const LCBLC&);
+
+        void SetState(LCBLCState state)
+        {
+            State = state;
+
+            if (State == RELEASED)	Print("State -> RELEASED\n");
+            else if (State == AWAITING_ESTABLISHMENT) Print("State -> AWAITING_ESTABLISHMENT\n");
+            else if (State == ESTABLISHED) Print("State -> ESTABLISHED\n");
+            else if (State == AWAITING_RELEASE) Print("State -> AWAITING_RELEASE\n");
+        }
+
+        LCBLCState GetState()
+        {
+            if (State == RELEASED)	Print("State == RELEASED\n");
+            else if (State == AWAITING_ESTABLISHMENT) Print("State == AWAITING_ESTABLISHMENT\n");
+            else if (State == ESTABLISHED) Print("State == ESTABLISHED\n");
+            else if (State == AWAITING_RELEASE) Print("State == AWAITING_RELEASE\n");
+
+            return State;
+        }
+
+        void OutgoingReleased(PS_ForwardReverseParam param)
+        {
+            SetTimer();
+            SetState(AWAITING_ESTABLISHMENT);
+            SendOpenLogicalChannel(param);
+        }
+
+        void OutgoingReleased(PS_ForwardReverseParam param)
+        {
+            ResetTimer();
+            SetTimer();
+            SetState(AWAITING_ESTABLISHMENT);
+            SendOpenLogicalChannel(param);
+        }
+
+        void OutgoingEstablished(LCBLCCause cause)
+        {
+            SetTimer();
+            SetState(AWAITING_RELEASE);
+            SendCloseLogicalChannel(LCBLC_USER, cause);
+        }
+
+        void OutgoingAwaitingEstablishment(LCBLCCause cause)
+        {
+            ResetTimer();
+            SetTimer();
+            SetState(AWAITING_RELEASE);
+            SendCloseLogicalChannel(LCBLC_USER, cause);
+        }
+
+        void IncomingAwaitingEstablishment()
+        {
+            SetState(ESTABLISHED);
+            SendOpenLogicalChannelAck();
+        }
+
+        void IncomingAwaitingEstablishment(LCBLCCause cause)
+        {
+            SetState(RELEASED);
+            SendOpenLogicalChannelReject(cause);
+        }
+
+        void IncomingReleased(PS_OpenLogicalChannel olc)
+        {
+            SetState(AWAITING_ESTABLISHMENT);
+            if (Observer) Observer->LCBLCEstablishIndication(ForwardLcn, olc->forwardLogicalChannelParameters, ReverseLcn, olc->reverseLogicalChannelParameters);
+        }
+
+        void IncomingAwaitingEstablishment(PS_OpenLogicalChannel olc)
+        {
+            SetState(AWAITING_ESTABLISHMENT);
+            if (Observer)
+            {
+                Observer->LCBLCReleaseIndication(LCBLC_USER, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_INCOMING);
+                Observer->LCBLCEstablishIndication(ForwardLcn, olc->forwardLogicalChannelParameters, ReverseLcn, olc->reverseLogicalChannelParameters);
+            }
+        }
+
+        void IncomingEstablished(PS_OpenLogicalChannel olc)
+        {
+            SetState(AWAITING_ESTABLISHMENT);
+            if (Observer)
+            {
+                Observer->LCBLCReleaseIndication(LCBLC_USER, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_INCOMING);
+                Observer->LCBLCEstablishIndication(ForwardLcn, olc->forwardLogicalChannelParameters, ReverseLcn, olc->reverseLogicalChannelParameters);
+            }
+        }
+
+        void IncomingReleased(PS_CloseLogicalChannel clc)
+        {
+            SetState(RELEASED);
+            SendCloseLogicalChannelAck();
+        }
+
+        void IncomingAwaitingEstablishment(PS_CloseLogicalChannel clc)
+        {
+            SetState(RELEASED);
+            SendCloseLogicalChannelAck();
+            if (Observer)
+            {
+                Observer->LCBLCReleaseIndication(LCBLC_NONE, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_INCOMING);
+            }
+        }
+
+        void IncomingEstablished(PS_CloseLogicalChannel clc)
+        {
+            SetState(RELEASED);
+            SendCloseLogicalChannelAck();
+            if (Observer)
+            {
+                Observer->LCBLCReleaseIndication(LCBLC_NONE, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_INCOMING);
+            }
+        }
+
+        void OutgoingReleased(PS_OpenLogicalChannelAck olca)
+        {
+            SetState(RELEASED);
+            if (Observer) Observer->LCBLCErrorIndication(LCBLC_ERROR_CODE_A, ForwardLcn, ReverseLcn);
+        }
+
+        void OutgoingAwaitingEstablishment(PS_OpenLogicalChannelAck olca)
+        {
+            ResetTimer();
+            SetState(ESTABLISHED);
+            if (Observer) Observer->LCBLCEstablishConfirm(ForwardLcn, ReverseLcn, olca);
+        }
+
+        void OutgoingEstablished(PS_OpenLogicalChannelAck olca)
+        {
+            SetState(ESTABLISHED);
+        }
+
+        void OutgoingAwaitingRelease(PS_OpenLogicalChannelAck olca)
+        {
+            SetState(AWAITING_RELEASE);
+        }
+
+        void OutgoingReleased(PS_OpenLogicalChannelReject olcr)
+        {
+            SetState(RELEASED);
+            if (Observer) Observer->LCBLCErrorIndication(LCBLC_ERROR_CODE_B, ForwardLcn, ReverseLcn);
+        }
+
+        void OutgoingAwaitingEstablishment(PS_OpenLogicalChannelReject olcr)
+        {
+            ResetTimer();
+            SetState(RELEASED);
+            if (Observer) Observer->LCBLCReleaseIndication(LCBLC_USER, olcr->olcRejectCause.index, ForwardLcn, ReverseLcn, LCBLC_OUTGOING);
+        }
+
+        void OutgoingEstablished(PS_OpenLogicalChannelReject olcr)
+        {
+            SetState(RELEASED);
+            if (Observer)
+            {
+                Observer->LCBLCErrorIndication(LCBLC_ERROR_CODE_B, ForwardLcn, ReverseLcn);
+                Observer->LCBLCReleaseIndication(LCBLC_LCSE, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_OUTGOING);
+            }
+        }
+
+        void OutgoingAwaitingRelease(PS_OpenLogicalChannelReject olcr)
+        {
+            ResetTimer();
+            SetState(RELEASED);
+            if (Observer) Observer->ReleaseConfirm();
+        }
+
+        void OutgoingReleased(PS_CloseLogicalChannelAck clca)
+        {
+            SetState(RELEASED);
+        }
+
+        void OutgoingAwaitingEstablishment(PS_CloseLogicalChannelAck clca)
+        {
+            SetState(AWAITING_ESTABLISHMENT);
+        }
+
+        void OutgoingEstablished(PS_CloseLogicalChannelAck clca)
+        {
+            SetState(RELEASED);
+            if (Observer)
+            {
+                Observer->LCBLCErrorIndication(LCBLC_ERROR_CODE_C, ForwardLcn, ReverseLcn);
+                Observer->LCBLCReleaseIndication(LCBLC_LCSE, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_OUTGOING);
+            }
+        }
+
+        void OutgoingAwaitingRelease(PS_CloseLogicalChannelAck clca)
+        {
+            ResetTimer();
+            SetState(RELEASED);
+            if (Observer) Observer->ReleaseConfirm();
+        }
+
+        void OutgoingAwaitingEstablishmentTimeout()
+        {
+            SetState(RELEASED);
+            if (Observer) Observer->LCBLCErrorIndication(LCBLC_ERROR_CODE_D, ForwardLcn, ReverseLcn);
+            SendCloseLogicalChannel(LCBLC_SE, LCBLC_UNSPECIFIED);
+            if (Observer) Observer->LCBLCReleaseIndication(LCBLC_LCSE, LCBLC_UNSPECIFIED, ForwardLcn, ReverseLcn, LCBLC_OUTGOING);
+        }
+
+        void OutgoingAwaitingReleaseTimeout()
+        {
+            SetState(RELEASED);
+            if (Observer) Observer->LCBLCErrorIndication(LCBLC_ERROR_CODE_D, ForwardLcn, ReverseLcn);
+            if (Observer) Observer->LCBLCReleaseConfirm(ForwardLcn, ReverseLcn);
+        }
+
+        void SendOpenLogicalChannel(PS_ForwardReverseParam param)
+        {
+            Print("Sending Open Logical Channel\n");
+            S_OpenLogicalChannel   openLogicalChannel ;
+
+            openLogicalChannel.forwardLogicalChannelNumber = ForwardLcn;
+            oscl_memcpy((int8*)&openLogicalChannel.forwardLogicalChannelParameters ,
+                        (int8*)&param->forwardLogicalChannelParameters ,
+                        sizeof(S_ForwardLogicalChannelParameters)) ;
+
+            openLogicalChannel.option_of_reverseLogicalChannelParameters = param->option_of_reverseLogicalChannelParameters ;
+            oscl_memcpy((int8*)&openLogicalChannel.reverseLogicalChannelParameters ,
+                        (int8*)&param->reverseLogicalChannelParameters ,
+                        sizeof(S_ReverseLogicalChannelParameters)) ;
+
+            openLogicalChannel.option_of_separateStack = FALSE ;
+            oscl_memset((int8*)&openLogicalChannel.separateStack , 0 , sizeof(S_NetworkAccessParameters)) ;
+
+            openLogicalChannel.option_of_encryptionSync = FALSE;
+
+            MessageSend(H245_MSG_REQ, MSGTYP_LCBLC_OP, (uint8*)&openLogicalChannel) ;
+        }
+
+        void SendOpenLogicalChannelAck(PS_ReverseData reverseData = 0)
+        {
+            Print("Sending Open Logical Channel Ack\n");
+            S_OpenLogicalChannelAck    openLogicalChannelAck ;
+
+            oscl_memset(&openLogicalChannelAck, 0, sizeof(S_OpenLogicalChannelAck));
+
+            // Logical Channel Number
+            openLogicalChannelAck.forwardLogicalChannelNumber = ForwardLcn;
+
+            if (reverseData)
+            {
+                // ReverseLogicalChannelParameters
+                openLogicalChannelAck.option_of_ackReverseLogicalChannelParameters =
+                    p_ReverseData->option_of_reverseLogicalChannelParameters ;
+
+                oscl_memcpy((int8*)&openLogicalChannelAck.ackReverseLogicalChannelParameters ,
+                            (int8*)&p_ReverseData->reverseLogicalChannelParameters ,
+                            sizeof(S_AckReverseLogicalChannelParameters)) ;
+
+                openLogicalChannelAck.option_of_forwardMultiplexAckParameters =
+                    p_ReverseData->option_of_forwardMultiplexAckParameters ;
+                oscl_memcpy((int8*)&openLogicalChannelAck.forwardMultiplexAckParameters ,
+                            (int8*)&p_ReverseData->forwardMultiplexAckParameters ,
+                            sizeof(S_ForwardMultiplexAckParameters)) ;
+            }
+
+            openLogicalChannelAck.option_of_separateStack = FALSE ;
+            // SeparateStack is OFF
+            oscl_memset((int8*)&openLogicalChannelAck.separateStack , 0 , sizeof(S_NetworkAccessParameters)) ;
+
+            // EncryptionSync is OFF
+            openLogicalChannelAck.option_of_encryptionSync = FALSE;
+
+            MessageSend(H245_MSG_RPS, MSGTYP_LCBLC_OP_ACK, (uint8*)&openLogicalChannelAck) ;
+        }
+
+        void SendOpenLogicalChannelConfirm(PS_OpenLogicalChannelAck openLogicalChannelAck)
+        {
+            Print("Sending Open Logical Channel Confirm\n", cause);
+            S_OpenLogicalChannelConfirm openLogicalChannelConfirm ;
+
+            openLogicalChannelConfirm.forwardLogicalChannelNumber = ForwardLcn;
+
+            MessageSend(H245_MSG_IDC, MSGTYP_LCBLC_OP_CFM, (uint8*)&openLogicalChannelConfirm) ;
+        }
+
+        void SendOpenLogicalChannelReject(LCBLCCause cause)
+        {
+            Print("Sending Open Logical Channel Reject - Cause = %d\n", cause);
+            S_OpenLogicalChannelReject openLogicalChannelReject ;
+
+            openLogicalChannelReject.forwardLogicalChannelNumber = ForwardLcn;
+            openLogicalChannelReject.olcRejectCause.index = cause;
+
+            MessageSend(H245_MSG_RPS, MSGTYP_LCBLC_OP_RJT, (uint8*)&openLogicalChannelReject) ;
+        }
+
+        void SendCloseLogicalChannel(LCBLCSource source)
+        {
+            Print("Sending Close Logical Channel - Source = %d\n", source);
+            S_CloseLogicalChannel  closeLogicalChannel ;
+
+            closeLogicalChannel.forwardLogicalChannelNumber = ForwardLcn;
+            closeLogicalChannel.source.index = source;
+            closeLogicalChannel.option_of_reason = 1;
+            closeLogicalChannel.reason.index = LCBLC_UNSPECIFIED;
+
+            MessageSend(H245_MSG_REQ, MSGTYP_LCBLC_CL, (uint8*)&closeLogicalChannel) ;
+        }
+
+        void SendCloseLogicalChannelAck()
+        {
+            Print("Sending Close Logical Channel Ack\n");
+            S_CloseLogicalChannelAck   closeLogicalChannelAck ;
+
+            closeLogicalChannelAck.forwardLogicalChannelNumber = ForwardLcn;
+
+            MessageSend(H245_MSG_RPS, MSGTYP_LCBLC_CL_ACK, (uint8*)&closeLogicalChannelAck) ;
+        }
+
+        void SetTimer()
+        {
+            RequestTimer(103, (int32)this, TimerDuration, this);
+        }
+        void ResetTimer()
+        {
+            CancelTimer(103, (int32)this);
+        }
+
+        LCBLCObserver *Observer;
+        LCBLCState State;
+        LCBLCDirection Direction;
+        uint32 ForwardLcn;
+        uint32 ReverseLcn;
+};
+
+#endif /* _SEMSD_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/lcblccmn.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/lcblccmn.h
new file mode 100644
index 0000000..39b81c5
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/lcblccmn.h
@@ -0,0 +1,76 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : selcblccmn.h                                      */
+/*  file contents   : Uni-Directional and Bi-Directional                */
+/*                  :              Logical Channel Signalling Entity    */
+/*                  :                          Common Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SELCBLCCMN_H_
+#define _SELCBLCCMN_H_
+
+#include "lcentry.h"
+#include "sebase.h"
+
+/************************************************************************/
+/*  Class Declaration                                                   */
+/************************************************************************/
+class LCBLCCmn : public SEBase
+{
+    public:
+        LCBLCCmn() : SEBase() {}
+        ~LCBLCCmn() {}
+
+        int32 T103TimerIdGet(uint32 forwardLcn) ;
+        void T103TimerStart(uint32 forwardLcn, uint32 tmrSqcNumber) ;
+        void T103TimerStop(uint32 forwardLcn) ;
+
+        void MsgOpenSend(uint16 forwardLcn, PS_ForwardReverseParam) ;
+        void MsgOpenAckSend(uint16 forwardLcn, PS_ReverseData) ;
+        void MsgOpenCfmSend(uint16 forwardLcn, PS_OpenLogicalChannelAck) ;
+        void MsgOpenRjtSend(uint16 forwardLcn, PS_OlcRejectCause) ;
+        void MsgCloseSend(uint16 forwardLcn, PS_Source) ;
+        void MsgCloseAckSend(uint16 forwardLcn) ;
+
+        void PtvEtbIdcSend(uint32 forwardLcn, PS_OpenLogicalChannel, int32 reverseLcn = -1) ;
+        void PtvEtbCfmSend(uint32 forwardLcn, PS_OpenLogicalChannelAck, int32 reverseLcn = -1) ;
+
+        void PtvEtbCfmSend2(uint32 forwardLcn, PS_OpenLogicalChannelAck, int32 reverseLcn = -1) ;
+        void PtvRlsIdcSend(uint32 forwardLcn, PS_Source , PS_OlcRejectCause, S_InfHeader::TDirection dir, int32 reverseLcn = -1) ;
+        void PtvRlsCfmSend(uint32 forwardLcn, int32 reverseLcn = -1) ;
+        void PtvErrIdcSend(uint32 forwardLcn, ENUM_ErrCode, int32 reverseLcn = -1) ;
+
+    private:
+        LCBLCCmn(const LCBLCCmn&);
+};
+
+#endif /* _SELCBLCCMN */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/lcentry.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/lcentry.h
new file mode 100644
index 0000000..e965f0e
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/lcentry.h
@@ -0,0 +1,394 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : selcblccmn.h                                      */
+/*  file contents   : Uni-Directional and Bi-Directional                */
+/*                  :              Logical Channel Signalling Entity    */
+/*                  :                          Common Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _LCENTRY_H_
+#define _LCENTRY_H_
+
+#include <stdio.h>
+#include "oscl_vector.h"
+#include "oscl_mem.h"
+#include "oscl_base.h"
+
+/************************************************************************/
+/*  Uni-Directional and Bi-Directional Logical Status Definition        */
+/************************************************************************/
+#define     LCBLC_OUTGOING_RLSED            0X00    /* Outgoing Released */
+#define     LCBLC_OUTGOING_AWTING_ETBMNT    0X10    /* Outgoing Awaiting Establishement */
+#define     LCBLC_OUTGOING_ETBED            0X20    /* Outgoing Established */
+#define     LCBLC_OUTGOING_AWTING_RLS       0X30    /* Outgoing Awaiting Release */
+#define     LCBLC_INCOMING_RLSED            0X01    /* Incoming Released */
+#define     LCBLC_INCOMING_AWTING_ETBMNT    0X11    /* Incoming Awaiting Establishment */
+#define     LCBLC_INCOMING_AWTING_CNFMTN    0X21    /* Incoming Awaiting Confirmation ( Bi-Directional Only ) */
+#define     LCBLC_INCOMING_ETBED            0X31    /* Incoming Established */
+
+
+/************************************************************************/
+/*  Directional Information Definition                                  */
+/************************************************************************/
+#define     NO_DIRECTIONAL      0   /* No-Directional */
+#define     UNI_DIRECTIONAL     1   /* Uni-Directional */
+#define     BI_DIRECTIONAL      2   /* Bi-Directional */
+
+
+/************************************************************************/
+/*  CLC Definition                                                      */
+/************************************************************************/
+#define     CLS_OUTGOING_IDLE           0X00    /* Outgoing Idle */
+#define     CLS_OUTGOING_AWTING_RPS     0X10    /* Outgoing Awaiting Response */
+#define     CLS_INCOMING_IDLE           0X01    /* Incoming Idle */
+#define     CLS_INCOMING_AWTING_RPS     0X11    /* Incoming Awaiting Response */
+
+
+/************************************************************************/
+/*  Class Definitions                                                   */
+/************************************************************************/
+typedef enum { LC_OUTGOING, LC_INCOMING } LCDirection_t;
+
+class LCEntry
+{
+    public:
+        LCEntry(uint32 lcn, LCDirection_t direction)
+        {
+            FwdLcn = lcn ;
+            RvsLcn = 0 ;
+
+            /********************************************************/
+            /* NOTE: OUTGOING with respect to LCBLC                 */
+            /********************************************************/
+            if (direction == LC_OUTGOING)
+            {
+                Status = LCBLC_OUTGOING_RLSED ;
+                ClcStatus = CLS_INCOMING_IDLE;
+            }
+            else
+            {
+                Status = LCBLC_INCOMING_RLSED ;
+                ClcStatus = CLS_OUTGOING_IDLE;
+            }
+
+            Directional = NO_DIRECTIONAL ;
+            TmrSqcNumber = 0 ;
+            ClcTmrSqcNumber = 0;
+        }
+        ~LCEntry() {}
+
+        void Reset()
+        {
+            RvsLcn = 0 ;
+
+            if (Status & 0x01)    //LC_INCOMING
+            {
+                Status = LCBLC_INCOMING_RLSED ;
+                ClcStatus = CLS_OUTGOING_IDLE;
+            }
+            else   //LC_OUTGOING
+            {
+                Status = LCBLC_OUTGOING_RLSED ;
+                ClcStatus = CLS_INCOMING_IDLE;
+            }
+
+            Directional = NO_DIRECTIONAL ;
+            TmrSqcNumber = 0 ;
+            ClcTmrSqcNumber = 0;
+        }
+
+        uint32 FwdLcnRead()
+        {
+            return FwdLcn;
+        }
+        void FwdLcnWrite(uint32 fwdLcn)
+        {
+            FwdLcn = fwdLcn;
+        }
+
+        uint32 RvsLcnRead()
+        {
+            return RvsLcn;
+        }
+        void RvsLcnWrite(uint32 rvsLcn)
+        {
+            RvsLcn = rvsLcn;
+        }
+
+        uint8 StatusRead()
+        {
+            return Status;
+        }
+        void StatusWrite(uint8 status)
+        {
+#ifdef PVANALYZER
+            StatusShow(status, Status);
+#endif
+            Status = status;
+
+            // if LC is set to released state, then reset it's attributes so it can be used again
+            if (Status == LCBLC_OUTGOING_RLSED || Status == LCBLC_INCOMING_RLSED)
+            {
+                RvsLcn = 0;
+                Directional = NO_DIRECTIONAL ;
+                TmrSqcNumber = 0 ;
+            }
+        }
+
+        uint8 DirectionalRead()
+        {
+            return Directional;
+        }
+        void DirectionalWrite(uint8 directional)
+        {
+            Directional = directional;
+        }
+
+        void TmrSqcNumberClear()
+        {
+            TmrSqcNumber = 0;
+        }
+        int32 TmrSqcNumberRead()
+        {
+            return TmrSqcNumber;
+        }
+        int32 TmrSqcNumberInc()
+        {
+            return (++TmrSqcNumber);
+        }
+
+        uint8 ClcStatusRead()
+        {
+            return ClcStatus;
+        }
+        void ClcStatusWrite(uint8 status)
+        {
+#ifdef PVANALYZER
+            ClcStatusShow(status, ClcStatus);
+#endif
+            ClcStatus = status;
+        }
+
+        void ClcTmrSqcNumberClear()
+        {
+            ClcTmrSqcNumber = 0;
+        }
+        int32 ClcTmrSqcNumberRead()
+        {
+            return ClcTmrSqcNumber;
+        }
+        void ClcTmrSqcNumberInc()
+        {
+            ClcTmrSqcNumber++;
+        }
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+        void StatusShow(uint8 oldStatus, uint8 newStatus)
+        {
+            void Show245(uint16 tag, uint16 indent, char* inString);
+            char tempString[80];
+
+            Show245(ANALYZER_SE, 0, "LCSE/BLCSE State Transition:");
+            sprintf(tempString, "  LogicalChannelNumber = %u", FwdLcn);
+            Show245(ANALYZER_SE, 0, tempString);
+            sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
+            Show245(ANALYZER_SE, 0, tempString);
+            sprintf(tempString, "    to--> %s", StateLabel(newStatus));
+            Show245(ANALYZER_SE, 0, tempString);
+            Show245(ANALYZER_SE, 0, " ");
+        }
+
+        char* StateLabel(uint8 status)
+        {
+            switch (status)
+            {
+                case LCBLC_OUTGOING_RLSED:
+                    return("Outgoing RELEASED");
+                    break;
+                case LCBLC_OUTGOING_AWTING_ETBMNT:
+                    return("Outgoing AWAITING ESTABLISHMENT");
+                    break;
+                case LCBLC_OUTGOING_ETBED:
+                    return("Outgoing ESTABLISHED");
+                    break;
+                case LCBLC_OUTGOING_AWTING_RLS:
+                    return("Outgoing AWAITING RELEASE");
+                    break;
+                case LCBLC_INCOMING_RLSED:
+                    return("Incoming RELEASED");
+                    break;
+                case LCBLC_INCOMING_AWTING_ETBMNT:
+                    return("Incoming AWAITING ESTABLISHMENT");
+                    break;
+                case LCBLC_INCOMING_AWTING_CNFMTN:
+                    return("Incoming AWAITING CONFIRMATION");
+                    break;
+                case LCBLC_INCOMING_ETBED:
+                    return("Incoming ESTABLISHED");
+                    break;
+                default:
+                    return("UNKNOWN STATE");
+            }
+        }
+
+        void ClcStatusShow(uint8 oldStatus, uint8 newStatus)
+        {
+            void Show245(uint16 tag, uint16 indent, char* inString);
+            char tempString[80];
+
+            Show245(ANALYZER_SE, 0, "CLCSE State Transition:");
+            sprintf(tempString, "  LogicalChannelNumber = %u", FwdLcn);
+            Show245(ANALYZER_SE, 0, tempString);
+            sprintf(tempString, "  from--> %s", ClcStateLabel(oldStatus));
+            Show245(ANALYZER_SE, 0, tempString);
+            sprintf(tempString, "    to--> %s", ClcStateLabel(newStatus));
+            Show245(ANALYZER_SE, 0, tempString);
+            Show245(ANALYZER_SE, 0, " ");
+        }
+
+        char *ClcStateLabel(uint8 status)
+        {
+            switch (status)
+            {
+                case CLS_OUTGOING_IDLE:
+                    return("Outgoing IDLE");
+                    break;
+                case CLS_OUTGOING_AWTING_RPS:
+                    return("Outgoing AWAITING RESPONSE");
+                    break;
+                case CLS_INCOMING_IDLE:
+                    return("Incoming IDLE");
+                    break;
+                case CLS_INCOMING_AWTING_RPS:
+                    return("Incoming AWAITING RESPONSE");
+                    break;
+                default:
+                    return("UNKNOWN STATE");
+            }
+        }
+
+#endif            /* --------------------------------- */
+
+    private:
+        LCEntry(const LCEntry&);
+
+        uint32    FwdLcn ;
+        uint32    RvsLcn ;
+        uint8   Directional ;
+        uint8   Status ;
+        int32     TmrSqcNumber ;
+        uint8   ClcStatus;          /* Multiple CLCSEs (RAN) */
+        int32     ClcTmrSqcNumber;    /* Multiple CLCSEs (RAN) */
+};
+
+class LCEntryList
+{
+    public:
+        LCEntryList() : Direction(LC_OUTGOING) {}
+        LCEntryList(LCDirection_t direction) : Direction(direction) {}
+
+        ~LCEntryList()
+        {
+            // delete all LCEntry's remaining
+            for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++) OSCL_DELETE((*it));
+        }
+
+        void Reset()
+        {
+            // reset all LCEntry's remaining
+            for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)(*it)->Reset();
+        }
+
+        void SetDirection(LCDirection_t direction)
+        {
+            Direction = direction;
+        }
+
+        LCEntry* NewLCEntry(uint32 lcn)
+        {
+            // allocate a new LCEntry
+            LCEntry *lcentry = OSCL_NEW(LCEntry, (lcn, Direction));
+            OsclError::LeaveIfNull(lcentry);
+            // add it to the list
+            EntryList.push_back(lcentry);
+
+            return lcentry;
+        }
+
+        LCEntry* GetLCEntry(uint32 lcn)
+        {
+            lcn = (lcn & 0xFFFF);
+            // look for existing LCEntry
+            for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)
+            {
+                if ((*it)->FwdLcnRead() == lcn)
+                {
+                    return (*it);
+                }
+            }
+
+            return NULL;
+        }
+
+        void DeleteLCEntry(uint32 lcn)
+        {
+            for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)
+            {
+                if ((*it)->FwdLcnRead() == lcn)
+                {
+                    OSCL_DELETE((*it));
+                    EntryList.erase(it);
+                    return;
+                }
+            }
+        }
+
+        void DeleteLCEntry(LCEntry *lcentry)
+        {
+            for (Oscl_Vector<LCEntry*, OsclMemAllocator>::iterator it = EntryList.begin(); it != EntryList.end(); it++)
+            {
+                if ((*it) == lcentry)
+                {
+                    OSCL_DELETE((*it));
+                    EntryList.erase(it);
+                    return;
+                }
+            }
+        }
+
+    private:
+        LCDirection_t Direction;
+        Oscl_Vector<LCEntry*, OsclMemAllocator> EntryList;
+};
+
+#endif /* _LCENTRY_H_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/ml.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/ml.h
new file mode 100644
index 0000000..9f90ac4
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/ml.h
@@ -0,0 +1,152 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seml.h                                            */
+/*  file contents   : Maintenance Loop Signalling Entity                */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEML_H_
+#define _SEML_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    <string.h>
+#include    "h245pri.h"
+#include	"sebase.h"
+
+/************************************************************************/
+/*  Definition                                                          */
+/************************************************************************/
+#define    ML_OUTGOING_NOT_LOOPED       0X00    /* Outgoing Not Looped */
+#define    ML_OUTGOING_AWTING_RPS       0X10    /* Outgoing Awaiting Response */
+#define    ML_OUTGOING_LOOPED           0X20    /* Outgoing Looped */
+#define    ML_INCOMING_NOT_LOOPED       0X01    /* Incoming Not Looped */
+#define    ML_INCOMING_AWTING_RPS       0X11    /* Incoming Awaiting Response */
+#define    ML_INCOMING_LOOPED           0X21    /* Incoming Looped */
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+
+class ML : public SEBase
+{
+    public:
+        enum InOut { OUTGOING, INCOMING };
+
+        ML(InOut inout = OUTGOING) : SEBase()
+        {
+            T102TimerStop() ;
+            TmrSqcNumberClear() ;
+            if (inout == INCOMING) StatusWrite(ML_INCOMING_NOT_LOOPED);
+            else StatusWrite(ML_OUTGOING_NOT_LOOPED);
+        }
+        ~ML() {}
+
+        void Reset()
+        {
+            T102TimerStop() ;
+            TmrSqcNumberClear() ;
+            if (StatusRead() & 0x01 /*INCOMING*/) StatusWrite(ML_INCOMING_NOT_LOOPED);
+            else StatusWrite(ML_OUTGOING_NOT_LOOPED);
+        }
+
+        void _0900_0000(PS_MlRequestType) ;
+        void _0901_0010(PS_MlRejectCause) ;
+        void _0901_0011(PS_MlRejectCause) ;
+        void _0901_0020(PS_MlRejectCause) ;
+        void _0902_0001(PS_MaintenanceLoopRequest) ;
+        void _0902_0011(PS_MaintenanceLoopRequest) ;
+        void _0903_0011(void) ;
+        void _0904_0010(PS_MaintenanceLoopAck) ;
+        void _0905_0010(PS_MaintenanceLoopReject) ;
+        void _0905_0020(PS_MaintenanceLoopReject) ;
+        void _0906_0010(int32) ;
+        void _0907_0011(void) ;
+
+    private:
+        ML(const ML&);
+
+        void MsgLoopReqSend(PS_MlRequestType);
+        void MsgLoopAckSend(void);
+        void MsgLoopRjtSend(PS_MlRejectCause);
+        void MsgLoopOffSend(void);
+        void PtvLoopIdcSend(PS_MaintenanceLoopRequest);
+        void PtvRlsIdcSend(int32, PS_MlRejectCause);
+        void PtvLoopCfmSend(void);
+        void PtvErrIdcSend(ENUM_ErrCode);
+    public:
+        uint8 StatusRead(void)
+        {
+            return Status;
+        }
+    private:
+        void StatusWrite(uint8 status)
+        {
+#ifdef PVANALYZER
+            StatusShow(Status, status);
+#endif
+            Status = status ;
+        }
+#ifdef PVANALYZER
+        void StatusShow(uint8 oldStatus, uint8 newStatus);
+        char* StateLabel(uint8 status);
+#endif
+        void LoopTypeRead(PS_MlRequestType pType)
+        {
+            oscl_memcpy((int8*)pType, (int8*)&LoopType, sizeof(S_MlRequestType));
+        }
+        void LoopTypeWrite(PS_MlRequestType pType)
+        {
+            oscl_memcpy((int8*)&LoopType, (int8*)pType, sizeof(S_MlRequestType));
+        }
+        void TmrSqcNumberClear(void)
+        {
+            TmrSqcNumber = 0;
+        }
+        int32 TmrSqcNumberRead(void)
+        {
+            return TmrSqcNumber;
+        }
+        void TmrSqcNumberInc(void)
+        {
+            TmrSqcNumber++;
+        }
+        void T102TimerStart(void);
+        void T102TimerStop(void);
+
+        int32		TmrSqcNumber;
+        uint8	Status;
+        S_MlRequestType LoopType ;
+};
+#endif /* _SEML_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/mr.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/mr.h
new file mode 100644
index 0000000..c551875
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/mr.h
@@ -0,0 +1,177 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : semr.h                                            */
+/*  file contents   : Mode Request Signalling Entity                    */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEMR_H_
+#define _SEMR_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "h245pri.h"
+#include	"sebase.h"
+
+/************************************************************************/
+/*  Definition                                                          */
+/************************************************************************/
+#define     MR_OUTGOING_IDLE            0X00    /* Outgoing Idle */
+#define     MR_OUTGOING_AWTING_RPS      0X10    /* Outgoing Awaiting Response */
+#define     MR_INCOMING_IDLE            0X01    /* Incoming Idle */
+#define     MR_INCOMING_AWTING_RPS      0X11    /* Incoming Awaiting Response */
+
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class MR : public SEBase
+{
+    public:
+        MR() : SEBase()
+        {
+            Reset();
+        }
+        ~MR() {}
+
+        void Reset()
+        {
+            OutSqcClear() ;
+            InSqcClear() ;
+            T109TimerStop() ;
+            TmrSqcNumberClear() ;
+            StatusWrite(MR_INCOMING_IDLE) ;
+            StatusWrite(MR_OUTGOING_IDLE) ;
+        }
+        void _0700_0000(PS_RequestMode) ;
+        void _0700_0010(PS_RequestMode) ;
+        void _0701_0001(PS_RequestMode) ;
+        void _0701_0011(PS_RequestMode) ;
+        void _0702_0011(PS_Response) ;
+        void _0703_0011(PS_RmRejectCause) ;
+        void _0704_0010(PS_RequestModeAck) ;
+        void _0705_0010(PS_RequestModeReject) ;
+        void _0706_0010(int32) ;
+        void _0707_0011(void) ;
+
+    private:
+        MR(const MR&);
+
+        void MsgRequestSend(PS_RequestMode) ;
+        void MsgAckSend(PS_Response) ;
+        void MsgRjtSend(PS_RmRejectCause) ;
+        void MsgRlsSend(void) ;
+        void PtvTrnsIndSend(PS_RequestMode) ;
+        void PtvRjtIndSend(int32 , PS_RmRejectCause) ;
+        void PtvTrnsCfmSend(PS_RequestModeAck) ;
+    public:
+        uint8 StatusRead(void)
+        {
+            return Status;
+        }
+        uint8 StatusRead2(void)
+        {
+            return Status2;
+        }
+    private:
+        void StatusWrite(uint8 status)
+        {
+            if (status&0x01)  /* Incoming */
+            {
+#ifdef PVANALYZER
+                StatusShow(Status2, status);
+#endif
+                Status2 = status ;
+            }
+            else  /* Outgoing */
+            {
+#ifdef PVANALYZER
+                StatusShow(Status, status);
+#endif
+                Status = status;
+            }
+        }
+
+#ifdef PVANALYZER
+        void StatusShow(uint8 oldStatus, uint8 newStatus);
+        char* StateLabel(uint8 status);
+#endif
+
+        void OutSqcClear(void)
+        {
+            OutSqc = 0;
+        }
+        void OutSqcInc(void)
+        {
+            OutSqc++;
+        }
+        int32 OutSqcRead(void)
+        {
+            return OutSqc;
+        }
+        void InSqcClear(void)
+        {
+            InSqc = 0;
+        }
+        void InSqcWrite(int32 insqc)
+        {
+            InSqc = insqc;
+        }
+        int32 InSqcRead(void)
+        {
+            return InSqc;
+        }
+        void TmrSqcNumberClear(void)
+        {
+            TmrSqcNumber = 0;
+        }
+        int32 TmrSqcNumberRead(void)
+        {
+            return TmrSqcNumber;
+        }
+        void TmrSqcNumberInc(void)
+        {
+            TmrSqcNumber++;
+        }
+        void T109TimerStart(void) ;
+        void T109TimerStop(void) ;
+
+        int32      OutSqc;
+        int32      InSqc;
+        int32      TmrSqcNumber;
+        uint8    Status;
+        uint8    Status2;
+};
+
+#endif /* _SEMR_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/msd.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/msd.h
new file mode 100644
index 0000000..2d4f979
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/msd.h
@@ -0,0 +1,534 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : semsd.h                                           */
+/*  file contents   : Master Slave Determination Signalling Entity      */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEMSD_
+#define _SEMSD_
+
+#include "oscl_base.h"
+#include "oscl_rand.h"
+#include "oscl_tickcount.h"
+#include "oscl_timer.h"
+#include "sebase.h"
+#include "h245def.h"
+#include "h245inf.h"
+#include "semsgque.h"
+
+#define TWO_24 (1<<24)
+#define TWO_23 (1<<23)
+#define MSD_MAX_RETRIES 100
+
+enum MSDStatus { MSD_INDETERMINATE = 0, MSD_MASTER = 1, MSD_SLAVE = 2 };
+enum MSDErrCode
+{
+    MSD_ERROR_CODE_A = 0, // no response from remove MSD
+    MSD_ERROR_CODE_B = 1, // remote MSD see no response from local MSD
+    MSD_ERROR_CODE_C = 2, // inappropriate message
+    MSD_ERROR_CODE_D = 3, // inappropriate message
+    MSD_ERROR_CODE_E = 4, // inconsistent field value
+    MSD_ERROR_CODE_F = 5  // max number of retries reached
+};
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+class MSDObserver
+{
+    public:
+        virtual ~MSDObserver() {}
+        virtual void MSDDetermineConfirm(MSDStatus type) = 0;
+        virtual void MSDDetermineIndication(MSDStatus type) = 0;
+        virtual void MSDRejectIndication() = 0;
+        virtual void MSDErrorIndication(MSDErrCode errCode) = 0;
+};
+
+//////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////
+class MSD : public SEBase, public OsclTimerObserver
+{
+    private:
+        enum MSDState { IDLE, OUTGOING_AWAITING_RESPONSE, INCOMING_AWAITING_RESPONSE }; // states
+
+    public:
+        MSD() :
+                Observer(NULL),
+                TerminalType(128),
+                State(IDLE),
+                Status(MSD_INDETERMINATE),
+                StatusDeterminationNumber(0),
+                RetryCnt(0)
+        {
+            // seed the random number generator
+            RandGen.Seed(OsclTickCount::TickCount());
+            // calcuate initial status determination number
+            NewStatusDeterminationNumber();
+        }
+
+        virtual ~MSD() {}
+
+        void Reset()
+        {
+            Print("Reset MSD\n");
+            State = IDLE;
+            Status = MSD_INDETERMINATE;
+            RetryCnt = 0;
+            // calcuate new status determination number
+            NewStatusDeterminationNumber();
+            ResetTimer();
+        }
+
+        void SetObserver(MSDObserver *observer)
+        {
+            Observer = observer;
+        }
+
+        void SetTerminalType(uint8 ttype)
+        {
+            TerminalType = ttype;
+        }
+
+        void DetermineRequest()
+        {
+            Print("Received MSD Determine Request\n");
+            switch (GetState())
+            {
+                case IDLE:
+                    Idle();
+                    break;
+                case OUTGOING_AWAITING_RESPONSE:
+                case INCOMING_AWAITING_RESPONSE:
+                default:
+                    break;
+            }
+        }
+
+        void Handler(PS_MasterSlaveDetermination msd)
+        {
+            Print("Received MSD\n");
+            switch (GetState())
+            {
+                case IDLE:
+                    Idle(msd);
+                    break;
+                case OUTGOING_AWAITING_RESPONSE:
+                    OutgoingAwaitingResponse(msd);
+                    break;
+                case INCOMING_AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(msd);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void Handler(PS_MasterSlaveDeterminationAck msda)
+        {
+            Print("Received MSDAck\n");
+            switch (GetState())
+            {
+                case IDLE:
+                    break;
+                case OUTGOING_AWAITING_RESPONSE:
+                    OutgoingAwaitingResponse(msda);
+                    break;
+                case INCOMING_AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(msda);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void Handler(PS_MasterSlaveDeterminationReject msdr)
+        {
+            Print("Received MSDReject\n");
+            switch (GetState())
+            {
+                case IDLE:
+                    break;
+                case OUTGOING_AWAITING_RESPONSE:
+                    OutgoingAwaitingResponse(msdr);
+                    break;
+                case INCOMING_AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(msdr);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void Handler(PS_MasterSlaveDeterminationRelease msdr)
+        {
+            Print("Received MSDRelease\n");
+            switch (GetState())
+            {
+                case IDLE:
+                    break;
+                case OUTGOING_AWAITING_RESPONSE:
+                    OutgoingAwaitingResponse(msdr);
+                    break;
+                case INCOMING_AWAITING_RESPONSE:
+                    IncomingAwaitingResponse(msdr);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void HandlerTimeout()
+        {
+            Print("Received MSD Timeout\n");
+            switch (GetState())
+            {
+                case IDLE:
+                    break;
+                case OUTGOING_AWAITING_RESPONSE:
+                    OutgoingAwaitingResponseTimeout();
+                    break;
+                case INCOMING_AWAITING_RESPONSE:
+                    IncomingAwaitingResponseTimeout();
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+        {
+            Print("    MSD::TimeoutOccurred");
+
+            OSCL_UNUSED_ARG(timerID);
+            OSCL_UNUSED_ARG(timeoutInfo);
+            HandlerTimeout();
+        }
+
+        MSDStatus GetStatus()
+        {
+            if (Status == MSD_INDETERMINATE) Print("    Status == INDETERMINATE\n");
+            else if (Status == MSD_MASTER) Print("    Status == MASTER\n");
+            else if (Status == MSD_SLAVE) Print("    Status == SLAVE\n");
+
+            return Status;
+        }
+
+    private:
+        MSD(const MSD&);
+
+        void SetStatus(MSDStatus status)
+        {
+            Status = status;
+
+            if (Status == MSD_INDETERMINATE) Print("    Status -> INDETERMINATE\n");
+            else if (Status == MSD_MASTER) Print("    Status -> MASTER\n");
+            else if (Status == MSD_SLAVE) Print("    Status -> SLAVE\n");
+        }
+
+        void SetState(MSDState state)
+        {
+            State = state;
+
+            if (State == IDLE)	Print("    State -> IDLE\n");
+            else if (State == OUTGOING_AWAITING_RESPONSE) Print("    State -> OUTGOING_AWAITING_RESPONSE\n");
+            else if (State == INCOMING_AWAITING_RESPONSE) Print("    State -> INCOMING_AWAITING_RESPONSE\n");
+        }
+
+        MSDState GetState()
+        {
+            if (State == IDLE)	Print("    State == IDLE\n");
+            else if (State == OUTGOING_AWAITING_RESPONSE) Print("    State == OUTGOING_AWAITING_RESPONSE\n");
+            else if (State == INCOMING_AWAITING_RESPONSE) Print("    State == INCOMING_AWAITING_RESPONSE\n");
+
+            return State;
+        }
+
+        // Handles Determine.Request when in IDLE state
+        void Idle()
+        {
+            RetryCnt = 1;
+            SetTimer();
+            SetState(OUTGOING_AWAITING_RESPONSE);
+            SendMSD();
+        }
+
+        void Idle(PS_MasterSlaveDetermination msd)
+        {
+            DetermineStatus(msd);
+            if (GetStatus() == MSD_INDETERMINATE)
+            {
+                SendMSDReject();
+            }
+            else
+            {
+                SetTimer();
+                SetState(INCOMING_AWAITING_RESPONSE);
+                SendMSDAck();
+                if (Observer) Observer->MSDDetermineIndication(Status);
+            }
+        }
+
+        void OutgoingAwaitingResponse(PS_MasterSlaveDeterminationAck msda)
+        {
+            ResetTimer();
+            SetStatus(((msda->decision.index == 0) ? MSD_MASTER : MSD_SLAVE));
+            SetState(IDLE);
+            SendMSDAck();
+            if (Observer) Observer->MSDDetermineConfirm(Status);
+        }
+
+        void OutgoingAwaitingResponse(PS_MasterSlaveDetermination msd)
+        {
+            ResetTimer();
+            DetermineStatus(msd);
+            if (GetStatus() == MSD_INDETERMINATE)
+            {
+                if (RetryCnt >= MSD_MAX_RETRIES)
+                {
+                    SetState(IDLE);
+                    if (Observer)
+                    {
+                        Observer->MSDErrorIndication(MSD_ERROR_CODE_F);
+                        Observer->MSDRejectIndication();
+                    }
+                }
+                else
+                {
+                    NewStatusDeterminationNumber();
+                    RetryCnt++;
+                    SetTimer();
+                    SetState(OUTGOING_AWAITING_RESPONSE);
+                    SendMSD();
+                }
+            }
+            else
+            {
+                SetTimer();
+                SetState(INCOMING_AWAITING_RESPONSE);
+                SendMSDAck();
+                if (Observer) Observer->MSDDetermineIndication(Status);
+            }
+        }
+
+        void OutgoingAwaitingResponse(PS_MasterSlaveDeterminationReject msdr)
+        {
+            OSCL_UNUSED_ARG(msdr);
+            ResetTimer();
+            if (RetryCnt >= MSD_MAX_RETRIES)
+            {
+                SetState(IDLE);
+                if (Observer)
+                {
+                    Observer->MSDErrorIndication(MSD_ERROR_CODE_F);
+                    Observer->MSDRejectIndication();
+                }
+            }
+            else
+            {
+                NewStatusDeterminationNumber();
+                RetryCnt++;
+                SetTimer();
+                SetState(OUTGOING_AWAITING_RESPONSE);
+                SendMSD();
+            }
+        }
+
+        void OutgoingAwaitingResponse(PS_MasterSlaveDeterminationRelease msdr)
+        {
+            OSCL_UNUSED_ARG(msdr);
+            ResetTimer();
+            SetState(IDLE);
+            if (Observer)
+            {
+                Observer->MSDErrorIndication(MSD_ERROR_CODE_B);
+                Observer->MSDRejectIndication();
+            }
+        }
+
+        void OutgoingAwaitingResponseTimeout()
+        {
+            SendMSDRelease();
+            SetState(IDLE);
+            if (Observer)
+            {
+                Observer->MSDErrorIndication(MSD_ERROR_CODE_A);
+                Observer->MSDRejectIndication();
+            }
+        }
+
+        void IncomingAwaitingResponse(PS_MasterSlaveDeterminationAck msda)
+        {
+            ResetTimer();
+            if ((msda->decision.index == 0 && GetStatus() == MSD_MASTER) ||
+                    (msda->decision.index == 1 && GetStatus() == MSD_SLAVE))
+            {
+                SetState(IDLE);
+                if (Observer) Observer->MSDDetermineConfirm(Status);
+            }
+            else
+            {
+                SetState(IDLE);
+                if (Observer)
+                {
+                    Observer->MSDErrorIndication(MSD_ERROR_CODE_E);
+                    Observer->MSDRejectIndication();
+                }
+            }
+        }
+
+        void IncomingAwaitingResponse(PS_MasterSlaveDetermination msd)
+        {
+            OSCL_UNUSED_ARG(msd);
+            ResetTimer();
+            SetState(IDLE);
+            if (Observer)
+            {
+                Observer->MSDErrorIndication(MSD_ERROR_CODE_C);
+                Observer->MSDRejectIndication();
+            }
+        }
+
+        void IncomingAwaitingResponse(PS_MasterSlaveDeterminationReject msdr)
+        {
+            OSCL_UNUSED_ARG(msdr);
+            ResetTimer();
+            SetState(IDLE);
+            if (Observer)
+            {
+                Observer->MSDErrorIndication(MSD_ERROR_CODE_D);
+                Observer->MSDRejectIndication();
+            }
+        }
+
+        void IncomingAwaitingResponse(PS_MasterSlaveDeterminationRelease msdr)
+        {
+            OSCL_UNUSED_ARG(msdr);
+            ResetTimer();
+            SetState(IDLE);
+            if (Observer)
+            {
+                Observer->MSDErrorIndication(MSD_ERROR_CODE_B);
+                Observer->MSDRejectIndication();
+            }
+        }
+
+        void IncomingAwaitingResponseTimeout()
+        {
+            SetState(IDLE);
+            if (Observer)
+            {
+                Observer->MSDErrorIndication(MSD_ERROR_CODE_A);
+                Observer->MSDRejectIndication();
+            }
+        }
+
+        void DetermineStatus(PS_MasterSlaveDetermination msd)
+        {
+            Print("    My Terminal Type == %d, Incoming Terminal Type == %d\n", TerminalType, msd->terminalType);
+            Print("    My Status Det Num == 0x%08x, Incoming Status Det Num == 0x%08x\n", StatusDeterminationNumber, msd->statusDeterminationNumber);
+
+            if (TerminalType != msd->terminalType)
+            {
+                SetStatus((TerminalType < msd->terminalType) ? MSD_SLAVE : MSD_MASTER);
+            }
+            else
+            {
+                uint32 diff = (msd->statusDeterminationNumber - StatusDeterminationNumber) % TWO_24;
+                if (diff == 0 || diff == TWO_23) SetStatus(MSD_INDETERMINATE);
+                else SetStatus((diff < TWO_23) ? MSD_MASTER : MSD_SLAVE);
+            }
+        }
+
+        void SendMSD()
+        {
+            Print("    Sending MSD - Terminal Type == %d, Status Det Num == 0x%08x\n", TerminalType, StatusDeterminationNumber);
+            S_MasterSlaveDetermination masterSlaveDetermination ;
+
+            masterSlaveDetermination.terminalType = TerminalType;
+            masterSlaveDetermination.statusDeterminationNumber = StatusDeterminationNumber;
+
+            MessageSend(H245_MSG_REQ, MSGTYP_MSD, (uint8*)&masterSlaveDetermination);
+        }
+
+        void SendMSDReject()
+        {
+            Print("    Sending MSDReject\n");
+            S_MasterSlaveDeterminationReject masterSlaveDeterminationReject ;
+
+            masterSlaveDeterminationReject.msdRejectCause.index = 0 ;
+
+            MessageSend(H245_MSG_RPS, MSGTYP_MSD_RJT, (uint8*)&masterSlaveDeterminationReject) ;
+        }
+
+        void SendMSDAck()
+        {
+            Print("    Sending MSDAck\n");
+            S_MasterSlaveDeterminationAck  masterSlaveDeterminationAck ;
+
+            masterSlaveDeterminationAck.decision.index = (uint16)((Status == MSD_MASTER) ? 1 : 0);
+
+            MessageSend(H245_MSG_RPS, MSGTYP_MSD_ACK, (uint8*)&masterSlaveDeterminationAck) ;
+        }
+
+        void SendMSDRelease()
+        {
+            Print("    Sending MSDRelease\n");
+            S_MasterSlaveDeterminationRelease  masterSlaveDeterminationRelease ;
+
+            MessageSend(H245_MSG_IDC, MSGTYP_MSD_RLS, (uint8*)&masterSlaveDeterminationRelease);
+        }
+
+        void NewStatusDeterminationNumber()
+        {
+            StatusDeterminationNumber = RandGen.Rand() & 0xFFFFFF; // 0xFFFFFF max allowed
+            Print("    Status Det Number -> 0x%08x\n", StatusDeterminationNumber);
+        }
+
+        void SetTimer()
+        {
+            RequestTimer(106, 0, TimerDuration, this);
+        }
+        void ResetTimer()
+        {
+            CancelTimer(106);
+        }
+
+        MSDObserver *Observer;
+        uint8 TerminalType;
+        MSDState State;
+        MSDStatus Status;
+        uint32 StatusDeterminationNumber;
+        uint8 RetryCnt;
+        OsclRand RandGen;
+};
+
+#endif /* _SEMSD_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/mt.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/mt.h
new file mode 100644
index 0000000..79f5121
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/mt.h
@@ -0,0 +1,246 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : semt.h                                            */
+/*  file contents   : Multiplex Table Signalling Entity                 */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEMT_H_
+#define _SEMT_H_
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "oscl_timer.h"
+#include "oscl_map.h"
+#include "h245pri.h"
+#include "sebase.h"
+#include "oscl_mem.h"
+
+/************************************************************************/
+/*  Multuplex Table Status Definition                                   */
+/************************************************************************/
+#define     MT_OUTGOING_IDLE            0X00    /* Outgoing Idle */
+#define     MT_OUTGOING_AWTING_RPS      0X10    /* Outgoing Awaiting Response */
+#define     MT_INCOMING_IDLE            0X01    /* Incoming Idle */
+#define     MT_INCOMING_AWTING_RPS      0X11    /* Incoming Awaiting Response */
+
+#define T104_TIMER_DURATION  30 /* In seconds */
+
+/************************************************************************/
+/*  Entry Number Type Definition                                        */
+/************************************************************************/
+#define MAX_MUX_ENTRIES 15
+
+class MTEntries
+{
+    public:
+        MTEntries()
+        {
+            Clear();
+        }
+        ~MTEntries() {}
+
+        int32 SizeRead()
+        {
+            return SizeMuxTableEntries;
+        }
+        uint32* MuxTableEntriesRead()
+        {
+            return MuxTableEntries;
+        };
+
+        void Clear()
+        {
+            SizeMuxTableEntries = 0;
+            oscl_memset(MuxTableEntries, 0, sizeof(MuxTableEntries[0]));
+        }
+
+        void Write(PS_MultiplexEntryDescriptor descriptors, int32 size)
+        {
+            SizeMuxTableEntries = size;
+            for (int ii = 0; ii < size && ii < MAX_MUX_ENTRIES; ii++)
+            {
+                MuxTableEntries[ii] = descriptors->multiplexTableEntryNumber;
+                descriptors++;
+            }
+        }
+
+    private:
+        int32  SizeMuxTableEntries;
+        uint32 MuxTableEntries[ MAX_MUX_ENTRIES ];
+};
+
+/* This interface provides utility functions that will be required by multiplex entry send
+   state managers */
+class MultiplexEntrySendUtility
+{
+    public:
+        virtual ~MultiplexEntrySendUtility() {}
+        virtual void MsgMtSend(PS_MuxDescriptor, uint8 sn) = 0;
+        virtual void PtvTrfCfmSend(int32 sn) = 0;
+        virtual void PtvRjtIdcSend(S_InfHeader::TDirection dir, int32 Source , PS_MeRejectCause p_Cause, int32 sn) = 0;
+        virtual void MsgMtRlsSend(MTEntries& entries) = 0;
+        virtual void RequestT104Timer(int32 sn) = 0;
+        virtual void CancelT104Timer(int32 sn) = 0;
+};
+
+/* This class maintains state information about outgoing multiplex entry send requests */
+//class MultiplexEntrySendMgr : public HeapBase
+class MultiplexEntrySendMgr : public HeapBase
+{
+    public:
+        MultiplexEntrySendMgr(int32 sn, MultiplexEntrySendUtility* util);
+        void TransferRequest(PS_MuxDescriptor p_MuxDescriptor);
+        void MultiplexEntrySendAck(PS_MultiplexEntrySendAck p_MultiplexEntrySendAck);
+        void MultiplexEntrySendReject(PS_MultiplexEntrySendReject p_MultiplexEntrySendReject);
+        void T104Timeout();
+    private:
+        void Write(PS_MultiplexEntryDescriptor descriptors, int32 size);
+        void StatusWrite(uint32 status);
+        void T104TimerStart(void) ;
+        void T104TimerStop(void) ;
+
+        MTEntries		iOutMTEntries;
+        MultiplexEntrySendUtility* iUtil;
+        int32            iSn;
+        uint32           iStatus;
+};
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+typedef Oscl_Map<int32, MultiplexEntrySendMgr*, OsclMemAllocator> PendingMtSendMap;
+class MT : public SEBase, public MultiplexEntrySendUtility, public OsclTimerObserver
+{
+    public:
+        MT();
+        ~MT()
+        {
+            Reset();
+        }
+
+        void Reset();
+
+        void TransferRequest(PS_MuxDescriptor) ;
+        void _0501_0001(PS_MultiplexEntrySend) ;
+        void _0501_0011(PS_MultiplexEntrySend) ;
+        void _0502_0011(uint32 sequenceNumber, PS_MuxDescriptor pMux) ;
+        void _0503_0011(PS_MeRejectCause) ;
+        void MultiplexEntrySendAck(PS_MultiplexEntrySendAck) ;
+        void MultiplexEntrySendReject(PS_MultiplexEntrySendReject) ;
+        void _0506_0010(int32) ;
+        void _0507_0011(void) ;
+        /* MultiplexEntrySendUtility virtuals */
+        void MsgMtSend(PS_MuxDescriptor, uint8 sn) ;
+        void PtvTrfCfmSend(int32 sn) ;
+        void PtvRjtIdcSend(S_InfHeader::TDirection dir, int32 Source , PS_MeRejectCause p_Cause, int32 sn);
+        void MsgMtRlsSend(MTEntries& entries) ;
+        void RequestT104Timer(int32 sn);
+        void CancelT104Timer(int32 sn);
+        /* OsclTimer virtuals */
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+    private:
+        MT(const MT&);
+
+        void MsgMtAckSend(uint32 sequenceNumber, PS_MuxDescriptor pMux) ;
+        void MsgMtRjtSend(PS_MeRejectCause) ;
+
+        void PtvTrfIdcSend(PS_MultiplexEntrySend) ;
+    public:
+        uint8 StatusRead2(void)
+        {
+            return Status2;
+        }
+    private:
+
+        void StatusWrite(uint8 status)
+        {
+            if (status & 0x01)  	                  /* Incoming */
+            {
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+                StatusShow(Status2, status);
+#endif            /* --------------------------------- */
+                Status2 = status;
+            }
+        }
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+        void StatusShow(uint8 oldStatus, uint8 newStatus);
+        char* StateLabel(uint8 status);
+#endif
+        void OutSqcClear(void)
+        {
+            OutSqc = 0;
+        }
+        void OutSqcInc(void)
+        {
+            OutSqc++;
+        }
+        int32 OutSqcRead(void)
+        {
+            return OutSqc;
+        }
+        void InSqcClear(void)
+        {
+            InSqc = 0;
+        }
+        void InSqcWrite(int32 insqc)
+        {
+            InSqc = insqc;
+        }
+        int32 InSqcRead(void)
+        {
+            return InSqc;
+        }
+        void TmrSqcNumberClear(void)
+        {
+            TmrSqcNumber = 0;
+        }
+        int32 TmrSqcNumberRead(void)
+        {
+            return TmrSqcNumber;
+        }
+        void TmrSqcNumberInc(void)
+        {
+            TmrSqcNumber++;
+        }
+
+        uint8			Status2;
+        int32             OutSqc;
+        int32             InSqc;
+        int32             TmrSqcNumber;
+        MTEntries		InMTEntries;
+        PendingMtSendMap iPendingMtSend;
+        OsclTimer<OsclMemAllocator> iTimer;
+};
+
+#endif /* _SEMT_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/rme.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/rme.h
new file mode 100644
index 0000000..fb7fe84
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/rme.h
@@ -0,0 +1,205 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : serme.h                                           */
+/*  file contents   : Request Multiplex Entry Signalling Entity         */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.26                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SERME_H_
+#define _SERME_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245pri.h"
+#include "sebase.h"
+#include "oscl_mem.h"
+
+/************************************************************************/
+/*  Definition                                                          */
+/************************************************************************/
+#define     RME_OUTGOING_IDLE           0X00    /* Outgoing Idle */
+#define     RME_OUTGOING_AWTING_RPS     0X10    /* Outgoing Awaiting Response */
+#define     RME_INCOMING_IDLE           0X01    /* Incoming Idle */
+#define     RME_INCOMING_AWTING_RPS     0X11    /* Incoming Awaiting Response */
+
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+
+class RMEntries
+{
+        enum { MAX_ENTRIES = 20 };
+    public:
+        RMEntries()
+        {
+            Clear();
+        }
+        ~RMEntries() {}
+
+        int32 SizeRead()
+        {
+            return SizeEntries;
+        }
+        void EntriesCopy(uint32* pEntries)
+        {
+            oscl_memcpy((int8*)pEntries, (int8*)Entries, SizeEntries * sizeof(uint32)) ;
+        }
+
+        void Write(int sizeEntries, uint32* entries)
+        {
+            SizeEntries = sizeEntries;
+            oscl_memcpy((int8*)Entries, entries, sizeEntries * sizeof(uint32));
+        }
+
+        void Clear()
+        {
+            SizeEntries = 0;
+            oscl_memset(Entries, 0, sizeof(Entries[0]));
+        }
+
+        void Sequence()
+        {
+            SizeEntries = 15;
+            for (int ii = 0; ii < SizeEntries; ii++)
+            {
+                Entries[ii] = ii + 1;
+            }
+        }
+
+    private:
+        int32  SizeEntries;
+        uint32 Entries[ MAX_ENTRIES ];
+};
+
+class RME : public SEBase
+{
+    public:
+        RME() : SEBase()
+        {
+            OutRMEntries.Sequence();
+            InRMEntries.Clear();
+            T107TimerStop() ;
+            TmrSqcNumberClear() ;               /* H245_TWOWAY */
+            StatusWrite(RME_INCOMING_IDLE) ;    /* Init incoming RMESE */
+            StatusWrite(RME_OUTGOING_IDLE) ;    /* Init outgoing RMESE */
+        }
+        ~RME() {}
+
+        void Reset()
+        {
+            OutRMEntries.Sequence();
+            InRMEntries.Clear();
+            T107TimerStop() ;
+            TmrSqcNumberClear() ;
+            StatusWrite(RME_INCOMING_IDLE) ;
+            StatusWrite(RME_OUTGOING_IDLE) ;
+        }
+
+        void _0600_0000(void) ;
+        void _0601_0001(PS_RequestMultiplexEntry) ;
+        void _0601_0011(PS_RequestMultiplexEntry) ;
+        void _0602_0011(void) ;
+        void _0603_0011(PS_RmeRejectCause) ;
+        void _0604_0010(PS_RequestMultiplexEntryAck) ;
+        void _0605_0010(PS_RequestMultiplexEntryReject) ;
+        void _0606_0010(int32) ;
+        void _0607_0011(PS_RequestMultiplexEntryRelease) ;
+
+    private:
+        RME(const RME&);
+
+        void MsgEntrySend(void) ;
+        void MsgEntryAckSend(void) ;
+        void MsgEntryRjtSend(PS_RmeRejectCause) ;
+        void MsgEntryRlsSend(void) ;
+        void PtvSendIndSend(void) ;
+        void PtvRjtIdcSend(int32 , PS_RmeRejectCause) ;
+        void PtvSendCfmSend(void) ;
+    public:
+        uint8 StatusRead(void)
+        {
+            return Status;
+        }
+        uint8 StatusRead2(void)
+        {
+            return Status2;
+        }
+    private:
+        void StatusWrite(uint8 status)
+        {
+            if (status&0x01)  	                  /* Incoming */
+            {
+#ifdef PVANALYZER
+                StatusShow(Status2, status);
+#endif
+                Status2 = status;
+            }
+            else  			                       /* Outgoing */
+            {
+#ifdef PVANALYZER
+                StatusShow(Status, status);
+#endif
+                Status = status;
+            }
+        }
+
+#ifdef PVANALYZER
+        void StatusShow(uint8 oldStatus, uint8 newStatus);
+        char* StateLabel(uint8 status);
+#endif
+
+        void TmrSqcNumberClear(void)
+        {
+            TmrSqcNumber = 0;
+        }
+        int32 TmrSqcNumberRead(void)
+        {
+            return TmrSqcNumber;
+        }
+        void TmrSqcNumberInc(void)
+        {
+            TmrSqcNumber++;
+        }
+        void T107TimerStart(void);
+        void T107TimerStop(void);
+
+        RMEntries OutRMEntries;
+        RMEntries InRMEntries;
+        int32       TmrSqcNumber;
+        uint8     Status;
+        uint8     Status2;
+};
+
+#endif /* _SERME_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/rtd.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/rtd.h
new file mode 100644
index 0000000..700f6b3
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/rtd.h
@@ -0,0 +1,143 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : sertd.h                                           */
+/*  file contents   : Round Trip Deray Signalling Entity                */
+/*                  :                                 Management Header */
+/*  draw            : '96.11.13                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SERTD_H_
+#define _SERTD_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include	"oscl_base.h"
+#include	"oscl_time.h"
+#include    "h245pri.h"
+#include	"sebase.h"
+
+/************************************************************************/
+/*  Definition                                                          */
+/************************************************************************/
+#define     RTD_IDLE                    0X00    /* Idle */
+#define     RTD_AWTING_RPS              0X10    /* Awaiting Response */
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class RTD : public SEBase
+{
+    public:
+        RTD() : SEBase()
+        {
+            Reset();
+        }
+        ~RTD() {}
+
+        void Reset()
+        {
+            OutSqcClear() ;
+            T105TimerStop() ;
+            TmrSqcNumberClear() ;
+            StatusWrite(RTD_IDLE) ;
+        }
+
+        void _0800_0000(void) ;
+        void _0800_0010(void) ;
+        void _0801_0000(PS_RoundTripDelayRequest) ;
+        void _0802_0010(PS_RoundTripDelayResponse) ;
+        void _0803_0010(int32) ;
+
+    private:
+        RTD(const RTD&);
+
+        void MsgRequestSend(void) ;
+        void MsgResponseSend(PS_RoundTripDelayRequest) ;
+        void PtvTrnsCfmSend(int32) ;
+        void PtvExpIndSend(void) ;
+    public:
+        uint8 StatusRead(void)
+        {
+            return Status;
+        }
+    private:
+        void StatusWrite(uint8 status)
+        {
+#ifdef PVANALYZER
+            StatusShow(Status, status);
+#endif
+            Status = status ;
+        }
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+        void StatusShow(uint8 oldStatus, uint8 newStatus);
+        char* StateLabel(uint8 status);
+#endif            /* --------------------------------- */
+
+        void OutSqcClear(void)
+        {
+            OutSqc = 0;
+        }
+        void OutSqcInc(void)
+        {
+            OutSqc++;
+            if (OutSqc == 256) OutSqc = 0;
+        }
+        int32  OutSqcRead(void)
+        {
+            return OutSqc;
+        }
+        void TmrSqcNumberClear(void)
+        {
+            TmrSqcNumber = 0;
+        }
+        int32  TmrSqcNumberRead(void)
+        {
+            return TmrSqcNumber;
+        }
+        void TmrSqcNumberInc(void)
+        {
+            TmrSqcNumber++;
+        }
+        void T105TimerStart(void);
+        void T105TimerStop(void);
+        void StartMeasurement(void);
+        int32  StopMeasurement(void);
+
+        int32      OutSqc;
+        int32      TmrSqcNumber;
+        uint8    Status;
+        TimeValue StartTime;
+};
+
+#endif /* _SERTD_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/se.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/se.h
new file mode 100644
index 0000000..a5637f4
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/se.h
@@ -0,0 +1,409 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : sedisp.h                                          */
+/*  file contents   : Receive Data Dispatch Header                      */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SE_H_
+#define _SE_H_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include	"oscl_base.h"
+#include	"oscl_timer.h"
+#include    "oscl_mem.h"
+#include    "oscl_shared_ptr.h"
+#include    "h245inf.h"
+#include    "h245msg.h"
+#include	"msd.h"
+#include	"blc.h"
+#include	"lc.h"
+#include	"clc.h"
+#include	"ce.h"
+#include	"mt.h"
+#include	"rtd.h"
+#include	"ml.h"
+#include	"mr.h"
+#include	"rme.h"
+#include	"annex.h"
+#include	"lcentry.h"
+
+class H245;
+class PER;
+class PVLogger;
+
+/************************************************************************/
+/*  Signalling Entity Definition                                        */
+/************************************************************************/
+#define     EVENT_MSDSE                 0X00000000      /* Master Slave Determination Signalling Entity */
+#define     EVENT_CESE                  0X01000000      /* Capability Exchange Signalling Entity */
+#define     EVENT_LCBLCSE               0X23000000      /* Uni-Directional and Bi-Directional Logical Channel Signalling Entity */
+/* Note : Befor Dispatch */
+#define     EVENT_LCSE                  0X02000000      /* Uni-Directional Logical Channel Signalling Entity */
+/* Note : After Dispatch */
+#define     EVENT_BLCSE                 0X03000000      /* Bi-Directional Logical Channel Signalling Entity */
+/* Note : After Dispatch */
+#define     EVENT_CLCSE                 0X04000000      /* Close Logical Channel Signalling Entity */
+#define     EVENT_MTSE                  0X05000000      /* Multiplex Table Signalling Entity */
+#define     EVENT_RMESE                 0X06000000      /* Request Multiplex Entry Signalling Entity */
+#define     EVENT_MRSE                  0X07000000      /* Mode Request Signalling Entity */
+#define     EVENT_RTDSE                 0X08000000      /* Round Trip Deray Signalling Entity */
+#define     EVENT_MLSE                  0X09000000      /* Maintenance Loop Signalling Entity */
+
+/************************************************************************/
+/*  Non Standard Definition                                             */
+/************************************************************************/
+#define     EVENT_NSD                   0X10000000      /* Non Standard */
+
+
+/************************************************************************/
+/*  Communication Mode Definition                                       */
+/************************************************************************/
+#define     EVENT_CM                    0X11000000      /* Communication Mode */
+
+/************************************************************************/
+/*  H223 Annex A Reconfiguration Definition                             */
+/************************************************************************/
+#define     EVENT_H223AAR               0X12000000      /* H223 Annex A Reconfiguration */
+
+
+/************************************************************************/
+/*  Conference Request And Response Definition                          */
+/************************************************************************/
+#define     EVENT_CNF                   0X13000000      /* Conference Request And Response */
+
+
+/************************************************************************/
+/*  Command Definition                                                  */
+/************************************************************************/
+#define     EVENT_CMD                   0X14000000      /* Command */
+
+
+/************************************************************************/
+/*  Indication Definition                                               */
+/************************************************************************/
+#define     EVENT_IDC                   0X15000000      /* Indication */
+
+
+/************************************************************************/
+/*  Event No Definition                                                 */
+/************************************************************************/
+/* Stopper */
+#define     STOPPER                     0XFFFFFFFF                  /* Stopper */
+
+
+/* Master Slave Determination Signalling Entity ( MSDSE )  */
+//#define     EVENT_PTV_MSD_DTM_REQ       EVENT_MSDSE   | 0X00000000  /* DETERMINE.request */
+#define     EVENT_MSG_MSD               EVENT_MSDSE   | 0X00010000  /* MasterSlaveDetermination */
+#define     EVENT_MSG_MSD_ACK           EVENT_MSDSE   | 0X00020000  /* MasterSlaveDeterminationAck */
+#define     EVENT_MSG_MSD_RJT           EVENT_MSDSE   | 0X00030000  /* MasterSlaveDeterminationReject */
+#define     EVENT_TIM_MSD_T106          EVENT_MSDSE   | 0X00040000  /* Timer T106 Timeout */
+#define     EVENT_MSG_MSD_RLS           EVENT_MSDSE   | 0X00050000  /* MasterSlaveDeterminationRelease */
+
+
+/* Capability Exchange Signalling Entity ( CESE ) */
+//#define     EVENT_PTV_CE_TRF_REQ        EVENT_CESE    | 0X00000000  /* TRANSFER.request */
+#define     EVENT_MSG_CE                EVENT_CESE    | 0X00010000  /* TerminalCapabilitySet */
+//#define     EVENT_PTV_CE_TRF_RPS        EVENT_CESE    | 0X00020000  /* TRANSFER.response */
+//#define     EVENT_PTV_CE_RJT_REQ        EVENT_CESE    | 0X00030000  /* REJECT.request */
+#define     EVENT_MSG_CE_ACK            EVENT_CESE    | 0X00040000  /* TerminalCapabilitySetAck */
+#define     EVENT_MSG_CE_RJT            EVENT_CESE    | 0X00050000  /* TerminalCapabilitySetReject */
+#define     EVENT_TIM_CE_T101           EVENT_CESE    | 0X00060000  /* Timer T101 Timeout */
+#define     EVENT_MSG_CE_RLS            EVENT_CESE    | 0X00070000  /* TerminalCapabilitySetRelease */
+
+
+/* Uni-Directional Logical Channel Signalling Entity ( LCSE ) */
+/* Bi-Directional Logical Channel Signalling Entity ( B-LCSE ) */
+#define     EVENT_PTV_LCBLC_ETB_REQ     EVENT_LCBLCSE | 0X00000000  /* ESTABLISH.request */
+#define     EVENT_MSG_LCBLC_OP          EVENT_LCBLCSE | 0X00010000  /* OpenLogicalChannel */
+#define     EVENT_PTV_LCBLC_ETB_RPS     EVENT_LCBLCSE | 0X00020000  /* ESTABLISH.response */
+#define     EVENT_PTV_LCBLC_RLS_REQ     EVENT_LCBLCSE | 0X00030000  /* RELEASE.request */
+#define     EVENT_MSG_LCBLC_OP_ACK      EVENT_LCBLCSE | 0X00040000  /* OpenLogicalChannelAck */
+#define     EVENT_MSG_LCBLC_OP_CFM      EVENT_LCBLCSE | 0X00050000  /* OpenLogicalChannelConfirm ( Bi-Directional Only ) */
+#define     EVENT_MSG_LCBLC_OP_RJT      EVENT_LCBLCSE | 0X00060000  /* OpenLogicalChannelReject */
+#define     EVENT_TIM_LCBLC_T103        EVENT_LCBLCSE | 0X00070000  /* Timer T103 Timeout */
+#define     EVENT_MSG_LCBLC_CL          EVENT_LCBLCSE | 0X00080000  /* CloseLogicalChannel */
+#define     EVENT_MSG_LCBLC_CL_ACK      EVENT_LCBLCSE | 0X00090000  /* CloseLogicalChannelAck */
+
+
+/* Close Logical Channel Signalling Entity ( CLCSE ) */
+#define     EVENT_PTV_CLC_CLS_REQ       EVENT_CLCSE   | 0X00000000  /* CLOSE.request  */
+#define     EVENT_MSG_CLC               EVENT_CLCSE   | 0X00010000  /* RequestChannelClose */
+#define     EVENT_PTV_CLC_CLS_RPS       EVENT_CLCSE   | 0X00020000  /* CLOSE.response */
+#define     EVENT_PTV_CLC_RJT_REQ       EVENT_CLCSE   | 0X00030000  /* REJECT.request */
+#define     EVENT_MSG_CLC_ACK           EVENT_CLCSE   | 0X00040000  /* RequestChannelCloseAck */
+#define     EVENT_MSG_CLC_RJT           EVENT_CLCSE   | 0X00050000  /* RequestChannelCloseReject */
+#define     EVENT_TIM_CLC_T108          EVENT_CLCSE   | 0X00060000  /* Timer T108 Timeout */
+#define     EVENT_MSG_CLC_RLS           EVENT_CLCSE   | 0X00070000  /* RequestChannelCloseRelease */
+
+
+/* Multiplex Table Signalling Entity ( MTSE ) */
+#define     EVENT_PTV_MT_TRF_REQ        EVENT_MTSE    | 0X00000000  /* TRANSFER.request */
+#define     EVENT_MSG_MT                EVENT_MTSE    | 0X00010000  /* MultiplexEntrySend */
+#define     EVENT_PTV_MT_TRF_RPS        EVENT_MTSE    | 0X00020000  /* TRANSFER.response  */
+#define     EVENT_PTV_MT_RJT_REQ        EVENT_MTSE    | 0X00030000  /* REJECT.request */
+#define     EVENT_MSG_MT_ACK            EVENT_MTSE    | 0X00040000  /* MultiplexEntrySendAck */
+#define     EVENT_MSG_MT_RJT            EVENT_MTSE    | 0X00050000  /* MultiplexEntrySendReject */
+#define     EVENT_TIM_MT_T104           EVENT_MTSE    | 0X00060000  /* Timer T104 Timeout */
+#define     EVENT_MSG_MT_RLS            EVENT_MTSE    | 0X00070000  /* MultiplexEntrySendRelease */
+
+
+/* Request Multiplex Entry Signalling Entity ( RMESE ) */
+#define     EVENT_PTV_RME_SEND_REQ      EVENT_RMESE   | 0X00000000  /* SEND.request */
+#define     EVENT_MSG_RME               EVENT_RMESE   | 0X00010000  /* RequestMultiplexEntry */
+#define     EVENT_PTV_RME_SEND_RPS      EVENT_RMESE   | 0X00020000  /* SEND.responsse */
+#define     EVENT_PTV_RME_RJT_REQ       EVENT_RMESE   | 0X00030000  /* REJECT.request */
+#define     EVENT_MSG_RME_ACK           EVENT_RMESE   | 0X00040000  /* RequestMultiplexEntryAck */
+#define     EVENT_MSG_RME_RJT           EVENT_RMESE   | 0X00050000  /* RequestMultiplexEntryReject */
+#define     EVENT_TIM_RME_T107          EVENT_RMESE   | 0X00060000  /* Timer T107 Timeout */
+#define     EVENT_MSG_RME_RLS           EVENT_RMESE   | 0X00070000  /* RequestMultiplexEntryRelease */
+
+
+/* Mode Request Signalling Entity ( MRSE ) */
+#define     EVENT_PTV_MR_TRF_REQ        EVENT_MRSE    | 0X00000000  /* TRANSFER.request */
+#define     EVENT_MSG_MR                EVENT_MRSE    | 0X00010000  /* RequestMode */
+#define     EVENT_PTV_MR_TRF_RPS        EVENT_MRSE    | 0X00020000  /* TRANSFER.response */
+#define     EVENT_PTV_MR_RJT_REQ        EVENT_MRSE    | 0X00030000  /* REJECT.request */
+#define     EVENT_MSG_MR_ACK            EVENT_MRSE    | 0X00040000  /* RequestModeAck */
+#define     EVENT_MSG_MR_RJT            EVENT_MRSE    | 0X00050000  /* RequestModeReject */
+#define     EVENT_TIM_MR_T109           EVENT_MRSE    | 0X00060000  /* Timer T109 Timeout */
+#define     EVENT_MSG_MR_RLS            EVENT_MRSE    | 0X00070000  /* RequestModeRelease */
+
+
+/* Round Trip Deray Signalling Entity ( RTDSE ) */
+#define     EVENT_PTV_RTD_TRF_REQ       EVENT_RTDSE   | 0X00000000  /* TRANSFER.request */
+#define     EVENT_MSG_RTD_REQ           EVENT_RTDSE   | 0X00010000  /* RoundTripDelayRequest */
+#define     EVENT_TIM_RTD_T105          EVENT_RTDSE   | 0X00020000  /* Timer T105 Timeout */
+#define     EVENT_MSG_RTD_RPS           EVENT_RTDSE   | 0X00030000  /* RoundTripDelayResponse */
+
+
+/* Maintenance Loop Signalling Entity ( MLSE ) */
+#define     EVENT_PTV_ML_LOOP_REQ       EVENT_MLSE    | 0X00000000  /* LOOP.request */
+#define     EVENT_MSG_ML_REQ            EVENT_MLSE    | 0X00010000  /* MaintenanceLoopRequest */
+#define     EVENT_PTV_ML_LOOP_RPS       EVENT_MLSE    | 0X00020000  /* LOOP.response */
+#define     EVENT_PTV_ML_RLS_REQ        EVENT_MLSE    | 0X00030000  /* RELEASE.request */
+#define     EVENT_MSG_ML_ACK            EVENT_MLSE    | 0X00040000  /* MaintenanceLoopAck */
+#define     EVENT_MSG_ML_RJT            EVENT_MLSE    | 0X00050000  /* MaintenanceLoopReject */
+#define     EVENT_TIM_ML_T102           EVENT_MLSE    | 0X00060000  /* Timer T102 Timeout */
+#define     EVENT_MSG_ML_OFF_CMD        EVENT_MLSE    | 0X00070000  /* MaintenanceLoopOffCommand */
+
+
+/* Non Standard */
+#define     EVENT_PTV_NSD_REQ           EVENT_NSD     | 0X00000000  /* NONSTANDARDMESSAGE_REQUEST */
+#define     EVENT_MSG_NSD_REQ           EVENT_NSD     | 0X00010000  /* NonStandardMessageRequest */
+#define     EVENT_PTV_NSD_RPS           EVENT_NSD     | 0X00020000  /* NONSTANDARDMESSAGE_RESPONSE */
+#define     EVENT_MSG_NSD_RPS           EVENT_NSD     | 0X00030000  /* NonStandardMessageResponse */
+#define     EVENT_PTV_NSD_CMD           EVENT_NSD     | 0X00040000  /* NONSTANDARDMESSAGE_COMMAND */
+#define     EVENT_MSG_NSD_CMD           EVENT_NSD     | 0X00050000  /* NonStandardMessageCommand */
+#define     EVENT_PTV_NSD_IDC           EVENT_NSD     | 0X00060000  /* NONSTANDARDMESSAGE_INDICATION */
+#define     EVENT_MSG_NSD_IDC           EVENT_NSD     | 0X00070000  /* NonStandardMessageIndication */
+
+
+/* Communication Mode */
+#define     EVENT_PTV_CM_REQ            EVENT_CM      | 0X00000000  /* COMMUNICATIONMODE_REQUEST */
+#define     EVENT_MSG_CM_REQ            EVENT_CM      | 0X00010000  /* CommunicationModeRequest */
+#define     EVENT_PTV_CM_RPS            EVENT_CM      | 0X00020000  /* COMMUNICATIONMODE_RESPONSE */
+#define     EVENT_MSG_CM_RPS            EVENT_CM      | 0X00030000  /* CommunicationModeResponse */
+#define     EVENT_PTV_CM_CMD            EVENT_CM      | 0X00040000  /* COMMUNICATIONMODE_COMMAND */
+#define     EVENT_MSG_CM_CMD            EVENT_CM      | 0X00050000  /* CommunicationModeCommand */
+
+
+/* H223 Annex A Reconfiguration */
+/* Note: This is not a 245 codeword.  */
+/* These events are not supported. (RAN) */
+#define     EVENT_PTV_H223AAR           EVENT_H223AAR | 0X00000000  /* H223ANNEXARECONFIGURATION */
+#define     EVENT_MSG_H223AAR           EVENT_H223AAR | 0X00010000  /* H223AnnexAReconfiguration */
+#define     EVENT_PTV_H223AAR_ACK       EVENT_H223AAR | 0X00020000  /* H223ANNEXARECONFIGURATION_ACK */
+#define     EVENT_MSG_H223AAR_ACK       EVENT_H223AAR | 0X00030000  /* H223AnnexAReconfigurationAck */
+#define     EVENT_PTV_H223AAR_RJT       EVENT_H223AAR | 0X00040000  /* H223ANNEXARECONFIGURATION_REJECT */
+#define     EVENT_MSG_H223AAR_RJT       EVENT_H223AAR | 0X00050000  /* H223AnnexAReconfigurationReject */
+
+
+/* Conference Request And Response */
+#define     EVENT_PTV_CNF_REQ           EVENT_CNF     | 0X00000000  /* CONFERENCE_REQUEST */
+#define     EVENT_MSG_CNF_REQ           EVENT_CNF     | 0X00010000  /* ConferenceRequest */
+#define     EVENT_PTV_CNF_RPS           EVENT_CNF     | 0X00020000  /* CONFERENCE_RESPONSE */
+#define     EVENT_MSG_CNF_RPS           EVENT_CNF     | 0X00030000  /* ConferenceResponse */
+
+
+/* Command */
+#define     EVENT_PTV_CMD_STCS          EVENT_CMD     | 0X00000000  /* SENDTERMINALCAPABILITYSET */
+#define     EVENT_MSG_CMD_STCS          EVENT_CMD     | 0X00010000  /* SendTerminalCapabilitySet */
+#define     EVENT_PTV_CMD_ECRPT         EVENT_CMD     | 0X00020000  /* ENCRYPTIONCOMMAND */
+#define     EVENT_MSG_CMD_ECRPT         EVENT_CMD     | 0X00030000  /* EncryptionCommand */
+#define     EVENT_PTV_CMD_FC            EVENT_CMD     | 0X00040000  /* FLOWCONTROLCOMMAND */
+#define     EVENT_MSG_CMD_FC            EVENT_CMD     | 0X00050000  /* FlowControlCommand */
+#define     EVENT_PTV_CMD_ES            EVENT_CMD     | 0X00060000  /* ENDSESSIONCOMMAND */
+#define     EVENT_MSG_CMD_ES            EVENT_CMD     | 0X00070000  /* EndSessionCommand */
+#define     EVENT_PTV_CMD_MSCL          EVENT_CMD     | 0X00080000  /* MISCELLANEOUSCOMMAND */
+#define     EVENT_MSG_CMD_MSCL          EVENT_CMD     | 0X00090000  /* MiscellaneousCommand */
+#define     EVENT_PTV_CMD_CNF           EVENT_CMD     | 0X000A0000  /* CONFERENCECOMMAND */
+#define     EVENT_MSG_CMD_CNF           EVENT_CMD     | 0X000B0000  /* ConferenceCommand */
+#define     EVENT_PTV_CMD_HMR           EVENT_CMD     | 0X000C0000  /* CONFERENCECOMMAND */
+#define     EVENT_MSG_CMD_HMR           EVENT_CMD     | 0X000D0000  /* ConferenceCommand */
+
+
+/* Indication */
+#define     EVENT_PTV_IDC_FNU           EVENT_IDC     | 0X00000000  /* FUNCTIONNOTUNDERSTOOD */
+#define     EVENT_MSG_IDC_FNU           EVENT_IDC     | 0X00010000  /* FunctionNotUnderstood */
+#define     EVENT_PTV_IDC_MSCL          EVENT_IDC     | 0X00020000  /* MISCELLANEOUSINDICATION */
+#define     EVENT_MSG_IDC_MSCL          EVENT_IDC     | 0X00030000  /* MiscellaneousIndication */
+#define     EVENT_PTV_IDC_JTR           EVENT_IDC     | 0X00040000  /* JITTERINDICATION */
+#define     EVENT_MSG_IDC_JTR           EVENT_IDC     | 0X00050000  /* JitterIndication */
+#define     EVENT_PTV_IDC_H223SKW       EVENT_IDC     | 0X00060000  /* H223SKEWINDICATION */
+#define     EVENT_MSG_IDC_H223SKW       EVENT_IDC     | 0X00070000  /* H223SkewIndication */
+#define     EVENT_PTV_IDC_NWATMVC       EVENT_IDC     | 0X00080000  /* NEWATMVCINDICATION */
+#define     EVENT_MSG_IDC_NWATMVC       EVENT_IDC     | 0X00090000  /* NewATMVCIndication */
+#define     EVENT_PTV_IDC_UI            EVENT_IDC     | 0X000A0000  /* USERINPUTINDICATION */
+#define     EVENT_MSG_IDC_UI            EVENT_IDC     | 0X000B0000  /* UserInputIndication */
+#define     EVENT_PTV_IDC_CNF           EVENT_IDC     | 0X000C0000  /* CONFERENCEINDICATION */
+#define     EVENT_MSG_IDC_CNF           EVENT_IDC     | 0X000D0000  /* ConferenceIndication */
+#define     EVENT_PTV_IDC_H2250MXSKW    EVENT_IDC     | 0X000E0000  /* H2250MAXIMUMSKEWINDICATION */
+#define     EVENT_MSG_IDC_H2250MXSKW    EVENT_IDC     | 0X000F0000  /* H2250MaximumSkewIndication */
+#define     EVENT_PTV_IDC_MCLCT         EVENT_IDC     | 0X00100000  /* MCLOCATIONINDICATION */
+#define     EVENT_MSG_IDC_MCLCT         EVENT_IDC     | 0X00110000  /* MCLocationIndication */
+#define     EVENT_PTV_IDC_VI            EVENT_IDC     | 0X00120000  /* VENDORIDENTIFICATION */
+#define     EVENT_MSG_IDC_VI            EVENT_IDC     | 0X00130000  /* VendorIdentification */
+#define     EVENT_PTV_IDC_FNS           EVENT_IDC     | 0X00140000  /* FUNCTIONNOTSUPPORTED */
+#define     EVENT_MSG_IDC_FNS           EVENT_IDC     | 0X00150000  /* FunctionNotSupported */
+#define     EVENT_PTV_IDC_FC            EVENT_IDC     | 0X00160000  /* FLOWCONTROL */
+#define     EVENT_MSG_IDC_FC            EVENT_IDC     | 0X00170000  /* FlowControl */
+
+#define		ITN_ERR_CODE_0000			0X00000000  /* Information Type Error ( Information Type ) */
+#define		ITN_ERR_CODE_0001			0X00000001  /* Information Id Error ( Information Id ) */
+#define		ITN_ERR_CODE_0002			0X00000002  /* Status Error ( Event Number | Status ) */
+
+/************************************************************************/
+/*  Event No Table Type Definition                                      */
+/************************************************************************/
+typedef struct _EventNoTable
+{
+    uint32    EventNo ;       /* Event Number */
+    uint32    InfType2 ;      /* Information Type 2 */
+    const char    *Comment ;       /* Description of event (RAN) */
+} S_EventNoTable ;
+typedef S_EventNoTable *PS_EventNoTable ;
+
+/************************************************************************/
+/*  Function Prototype Declare                                          */
+/************************************************************************/
+class SE : public OsclTimerObserver
+{
+    public:
+        OSCL_IMPORT_REF SE();
+        OSCL_IMPORT_REF virtual ~SE();
+
+        OSCL_IMPORT_REF void Reset();
+
+        OSCL_IMPORT_REF void InformationRecv(PS_InfHeader);
+        void MessageRecv(uint8 Type1, uint8 Type2, OsclSharedPtr<uint8> Data, uint8* EncodedMsg, uint32 EncodedMsgSize);
+
+        OSCL_IMPORT_REF void SetPer(PER *per);
+        OSCL_IMPORT_REF void SetH245(H245 *h245);
+        OSCL_IMPORT_REF void SetTimers(H245TimerValues& timer_vals)
+        {
+            iTimerValues = timer_vals;
+            MyCE.TimerDuration = iTimerValues.iT101;
+            MyLC.TimerDuration = iTimerValues.iT103;
+            MyBLC.TimerDuration = iTimerValues.iT103;
+            MyMT.TimerDuration = iTimerValues.iT104;
+            MyRTD.TimerDuration = iTimerValues.iT105;
+            MyMSD.TimerDuration = iTimerValues.iT106;
+            MyRME.TimerDuration = iTimerValues.iT107;
+            MyCLC.TimerDuration = iTimerValues.iT108;
+            MyMR.TimerDuration = iTimerValues.iT109;
+        }
+
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+        void RequestTimer(int32 timerID, int32 timeoutInfo, int32 count, OsclTimerObserver *observer = 0)
+        {
+            MyTimer.Request(timerID, timeoutInfo, count, observer);
+        }
+        void CancelTimer(int32 timerID)
+        {
+            MyTimer.Cancel(timerID);
+        }
+
+        void Print(const char *format, ...);
+
+        MSD* GetMSD()
+        {
+            return &MyMSD;
+        }
+        CE*  GetCE()
+        {
+            return &MyCE;
+        }
+
+    private:
+        SE(const SE&);
+        PS_EventNoTable TablePointerGetUpperLayer(uint32) ;
+        PS_EventNoTable TablePointerGetLowerLayer(uint32) ;
+        uint32 EventNoDecision(PS_EventNoTable , uint32) ;
+        void EventNoShow(char *comment);
+        void Dispatch(uint32 , OsclSharedPtr<uint8> , uint32 , uint32, uint8* EncodedMsg = NULL, uint32 EncodedMsgSize = 0) ;
+        void Nop_XXXX_XXXX(void)
+        { /* no operation */
+            ;
+        }
+        void ItnErrNotificationSend(uint32 , uint32) ;
+
+        PER *MyPER;
+        H245 *MyH245;
+        OsclTimer<OsclMemAllocator> MyTimer;
+        MSD MyMSD;
+        BLC MyBLC;
+        LC  MyLC;
+        CLC MyCLC;
+        NSD MyNSD;
+        CM  MyCM;
+        CNF MyCNF;
+        CMD MyCMD;
+        IDC MyIDC;
+        CE	MyCE;
+        MT  MyMT;
+        RTD	MyRTD;
+        MR	MyMR;
+        RME MyRME;
+        ML	MyML;  // Caution: MLSE is not implemented for Two-Way.
+
+        LCEntryList LCBLCOutgoing;
+        LCEntryList LCBLCIncoming;
+
+        PVLogger *Logger;
+        H245TimerValues iTimerValues;
+};
+
+
+#endif /* _SE_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/sebase.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/sebase.h
new file mode 100644
index 0000000..9d3fd69
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/sebase.h
@@ -0,0 +1,71 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef _SEBASE_H_
+#define _SEBASE_H_
+
+#include "h245msg.h"
+#include "h245inf.h"
+#include "oscl_timer.h"
+
+class PER;
+class H245;
+class SE;
+class PVLogger;
+
+#define TIMER_DURATION 30
+
+class SEBase
+{
+    public:
+        SEBase();
+        virtual ~SEBase() {}
+
+        void SetSE(SE *se)
+        {
+            MySE = se;
+        }
+        void RequestTimer(int32 timerID, int32 timeoutInfo, int32 count, OsclTimerObserver *observer = 0);
+        void CancelTimer(int32 timerID);
+
+        void SetPer(PER *per)
+        {
+            MyPer = per;
+        }
+        void MessageSend(PS_H245Msg pMsg);
+        OSCL_IMPORT_REF void MessageSend(uint32 type1, uint32 type2, uint8 *pdata);
+
+        void SetH245(H245 *h245)
+        {
+            MyH245 = h245;
+        }
+        void PrimitiveSend(PS_InfHeader pPrimitive);
+
+        OSCL_IMPORT_REF void Print(const char *format, ...);
+
+        uint32 TimerDuration; // Duration of timers in seconds
+
+    private:
+        SEBase(const SEBase&);
+
+        SE *MySE;
+        PER *MyPer;
+        H245 *MyH245;
+        PVLogger *Logger;
+};
+
+#endif //_SEBASE_H_
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/include/semsgque.h b/protocols/systems/3g-324m_pvterminal/h245/se/include/semsgque.h
new file mode 100644
index 0000000..9ea0137
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/include/semsgque.h
@@ -0,0 +1,145 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : semsgque.h                                        */
+/*  file contents   : Between Encode/Decode to Control Entity           */
+/*                                            Queuing Infomation Header */
+/*  draw            : '96.11.11                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+#ifndef _SEMSGQUE_
+#define _SEMSGQUE_
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "h245msg.h"
+
+
+/************************************************************************/
+/*  H.245 Message Type1 Definition                                      */
+/************************************************************************/
+#define     H245_MSG_REQ            0X00    /* H.245 Request Message */
+#define     H245_MSG_RPS            0X01    /* H.245 Response Message */
+#define     H245_MSG_CMD            0X02    /* H.245 Command Message */
+#define     H245_MSG_IDC            0X03    /* H.245 Indication Message */
+
+
+/************************************************************************/
+/*  H.245 Message Type2 Definition: Request Message                     */
+/************************************************************************/
+#define     MSGTYP_NSD_REQ          0X00    /* NonStandardMessageRequest */
+#define     MSGTYP_MSD              0X01    /* MasterSlaveDetermination */
+#define     MSGTYP_CE               0X02    /* TerminalCapabilitySet */
+#define     MSGTYP_LCBLC_OP         0X03    /* OpenLogicalChannel ( LC/B-LC ) */
+#define     MSGTYP_LCBLC_CL         0X04    /* CloseLogicalChannel ( LC/B-LC ) */
+#define     MSGTYP_CLC              0X05    /* RequestChannelClose */
+#define     MSGTYP_MT               0X06    /* MultiplexEntrySend */
+#define     MSGTYP_RME              0X07    /* RequestMultiplexEntry */
+#define     MSGTYP_MR               0X08    /* RequestMode  */
+#define     MSGTYP_RTD_REQ          0X09    /* RoundTripDelayRequest */
+#define     MSGTYP_ML_REQ           0X0A    /* MaintenanceLoopRequest */
+#define     MSGTYP_CM_REQ           0X0B    /* CommunicationModeRequest */
+#define     MSGTYP_CNF_REQ          0X0C    /* ConferenceRequest */
+#define     MSGTYP_H223AAR          0X0D    /* H223AnnexAReconfiguration */
+/*  (Not a codeword - Not supported (RAN)) */
+
+
+/************************************************************************/
+/*  H.245 Message Type2 Definition: Response Message                    */
+/************************************************************************/
+#define     MSGTYP_NSD_RPS          0X00    /* NonStandardMessageResponse */
+#define     MSGTYP_MSD_ACK          0X01    /* MasterSlaveDeterminationAck */
+#define     MSGTYP_MSD_RJT          0X02    /* MasterSlaveDeterminationReject */
+#define     MSGTYP_CE_ACK           0X03    /* TerminalCapabilitySetAck */
+#define     MSGTYP_CE_RJT           0X04    /* TerminalCapabilitySetReject */
+#define     MSGTYP_LCBLC_OP_ACK     0X05    /* OpenLogicalChannelAck ( LC/B-LC ) */
+#define     MSGTYP_LCBLC_OP_RJT     0X06    /* OpenLogicalChannelReject ( LC/B-LC ) */
+#define     MSGTYP_LCBLC_CL_ACK     0X07    /* CloseLogicalChannelAck ( LC/B-LC ) */
+#define     MSGTYP_CLC_ACK          0X08    /* RequestChannelCloseAck */
+#define     MSGTYP_CLC_RJT          0X09    /* RequestChannelCloseReject */
+#define     MSGTYP_MT_ACK           0X0A    /* MultiplexEntrySendAck */
+#define     MSGTYP_MT_RJT           0X0B    /* MultiplexEntrySendReject */
+#define     MSGTYP_RME_ACK          0X0C    /* RequestMultiplexEntryAck */
+#define     MSGTYP_RME_RJT          0X0D    /* RequestMultiplexEntryReject */
+#define     MSGTYP_MR_ACK           0X0E    /* RequestModeAck */
+#define     MSGTYP_MR_RJT           0X0F    /* RequestModeReject */
+#define     MSGTYP_RTD_RPS          0X10    /* RoundTripDelayResponse */
+#define     MSGTYP_ML_ACK           0X11    /* MaintenanceLoopAck */
+#define     MSGTYP_ML_RJT           0X12    /* MaintenanceLoopReject */
+#define     MSGTYP_CM_RPS           0X13    /* CommunicationModeResponse */
+#define     MSGTYP_CNF_RPS          0X14    /* ConferenceResponse */
+#define     MSGTYP_H223AAR_ACK      0X15    /* H223AnnexAReconfigurationAck */
+#define     MSGTYP_H223AAR_RJT      0X16    /* H223AnnexAReconfigurationReject */
+/*  (Not a codeword -- Not supported (RAN)) */
+
+
+/************************************************************************/
+/*  H.245 Message Type2 Definition: Command Message                     */
+/************************************************************************/
+#define     MSGTYP_NSD_CMD          0X00    /* NonStandardMessageCommand */
+#define     MSGTYP_ML_OFF_CMD       0X01    /* MaintenanceLoopOffCommand */
+#define     MSGTYP_CMD_STCS         0X02    /* SendTerminalCapabilitySet */
+#define     MSGTYP_CMD_ECRPT        0X03    /* EncryptionCommand */
+#define     MSGTYP_CMD_FC           0X04    /* FlowControlCommand */
+#define     MSGTYP_CMD_ES           0X05    /* EndSessionCommand */
+#define     MSGTYP_CMD_MSCL         0X06    /* MiscellaneousCommand */
+#define     MSGTYP_CM_CMD           0X07    /* CommunicationModeCommand */
+#define     MSGTYP_CMD_CNF          0X08    /* ConferenceCommand */
+#define     MSGTYP_CMD_HMR          0X09    /* H223MultiplexReconfigurationCommand */
+
+
+/************************************************************************/
+/*  H.245 Message Type2 Definition: Indication Message                  */
+/************************************************************************/
+#define     MSGTYP_NSD_IDC          0X00    /* NonStandardMessage */
+#define     MSGTYP_IDC_FNU          0X01    /* FunctionNotUnderstood */
+#define     MSGTYP_MSD_RLS          0X02    /* MasterSlaveDeterminationRelease */
+#define     MSGTYP_CE_RLS           0X03    /* TerminalCapabilitySetRelease */
+#define     MSGTYP_LCBLC_OP_CFM     0X04    /* OpenLogicalChannelConfirm ( Bi-Directional Only ) */
+#define     MSGTYP_CLC_RLS          0X05    /* RequestChannelCloseRelease */
+#define     MSGTYP_MT_RLS           0X06    /* MultiplexEntrySendRelease */
+#define     MSGTYP_RME_RLS          0X07    /* RequestMultiplexEntryRelease */
+#define     MSGTYP_MR_RLS           0X08    /* RequestModeRelease */
+#define     MSGTYP_IDC_MSCL         0X09    /* MiscellaneousIndication */
+#define     MSGTYP_IDC_JTR          0X0A    /* JitterIndication */
+#define     MSGTYP_IDC_H223SKW      0X0B    /* H223SkewIndication */
+#define     MSGTYP_IDC_NWATMVC      0X0C    /* NewATMVCIndication */
+#define     MSGTYP_IDC_UI           0X0D    /* UserInputIndication */
+#define     MSGTYP_IDC_H2250MXSKW   0X0E    /* H2250MaximumSkewIndication */
+#define     MSGTYP_IDC_MCLCT        0X0F    /* MCLocationIndication */
+#define     MSGTYP_IDC_CNF          0X10    /* ConferenceIndication */
+#define     MSGTYP_IDC_VI           0X11    /* VendorIdentification */
+#define     MSGTYP_IDC_FNS          0X12    /* FunctionNotSupported */
+#define     MSGTYP_IDC_FC           0X13    /* FlowControl */
+
+
+#endif /* _SEMSGQUE_ */
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/annex.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/annex.cpp
new file mode 100644
index 0000000..7d88765
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/annex.cpp
@@ -0,0 +1,1174 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seannex.c                                         */
+/*  file contents   : Other Management ( Annex )                        */
+/*  draw            : '96.11.28                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "semsgque.h"
+#include "h245def.h"
+#include "h245pri.h"
+#include "annex.h"
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1000_XXXX                              */
+/*  function outline    : Event     NonStandardMessageRequest Primitive */
+/*  function discription: Se_Nsd_1000_XXXX( PS_NonStandardMessage ) */
+/*  input data          : PS_NonStandardMessage                     */
+/*                      :                      p_NonstandardMessage */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1000_XXXX(PS_NonStandardMessage p_NsmIn)
+{
+    MsgSend(H245_MSG_REQ , MSGTYP_NSD_REQ , (uint8*)p_NsmIn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1001_XXXX                              */
+/*  function outline    : Event     NonStandardMessageRequest           */
+/*  function discription: Se_Nsd_1001_XXXX( PS_NonStandardMessage )     */
+/*  input data          : PS_NonStandardMessage p_NonStandardMessage    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1001_XXXX(PS_NonStandardMessage p_NonStandardMessage)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Nsd_Req_Cfm , 0 , 0 , (uint8*)p_NonStandardMessage , sizeof(S_NonStandardMessage)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1002_XXXX                              */
+/*  function outline    : Event     NonStandardMessageResponse          */
+/*                      :                                     Primitive */
+/*  function discription: Se_Nsd_1002_XXXX( PS_NonStandardMessage ) */
+/*  input data          : PS_NonStandardMessage                     */
+/*                      :                      p_NonstandardMessage */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1002_XXXX(PS_NonStandardMessage p_NonstandardMessage)
+{
+    MsgSend(H245_MSG_RPS , MSGTYP_NSD_RPS , (uint8*)p_NonstandardMessage) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1003_XXXX                              */
+/*  function outline    : Event     NonStandardMessageResponse          */
+/*  function discription: Se_Nsd_1003_XXXX( PS_NonStandardMessage )     */
+/*  input data          : PS_NonStandardMessage p_NonStandardMessage    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1003_XXXX(PS_NonStandardMessage p_NonStandardMessage)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Nsd_Rps_Cfm , 0 , 0 , (uint8*)p_NonStandardMessage , sizeof(S_NonStandardMessage)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1004_XXXX                              */
+/*  function outline    : Event     NonStandardMessageCommand Primitive */
+/*  function discription: Se_Nsd_1004_XXXX( PS_NonStandardMessage ) */
+/*  input data          : PS_NonStandardMessage                     */
+/*                      :                      p_NonstandardMessage */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1004_XXXX(PS_NonStandardMessage p_NonstandardMessage)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_NSD_CMD , (uint8*)p_NonstandardMessage) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1005_XXXX                              */
+/*  function outline    : Event     NonStandardMessageCommand           */
+/*  function discription: Se_Nsd_1005_XXXX( PS_NonStandardMessage )     */
+/*  input data          : PS_NonStandardMessage p_NonStandardMessage    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1005_XXXX(PS_NonStandardMessage p_NonStandardMessage)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Nsd_Cmd_Cfm , 0 , 0 , (uint8*)p_NonStandardMessage , sizeof(S_NonStandardMessage)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1006_XXXX                              */
+/*  function outline    : Event     NonStandardMessageIndication        */
+/*                      :                                     Primitive */
+/*  function discription: Se_Nsd_1006_XXXX( PS_NonStandardMessage ) */
+/*  input data          : PS_NonStandardMessage                     */
+/*                      :                      p_NonstandardMessage */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1006_XXXX(PS_NonStandardMessage p_NonstandardMessage)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_NSD_IDC , (uint8*)p_NonstandardMessage) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Nsd_1007_XXXX                              */
+/*  function outline    : Event     NonStandardMessageIndication        */
+/*  function discription: Se_Nsd_1007_XXXX( PS_NonStandardMessage )     */
+/*  input data          : PS_NonStandardMessage p_NonStandardMessage    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void NSD::_1007_XXXX(PS_NonStandardMessage p_NonStandardMessage)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Nsd_Idc_Cfm , 0 , 0 , (uint8*)p_NonStandardMessage , sizeof(S_NonStandardMessage)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cm_1100_XXXX                               */
+/*  function outline    : Event     CommunicationModeRequest Primitive  */
+/*  function discription: Se_Cm_1100_XXXX                               */
+/*                      :           ( PS_CommunicationModeRequest ) */
+/*  input data          : PS_CommunicationModeRequest               */
+/*                      :                p_CommunicationModeRequest */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CM::_1100_XXXX(PS_CommunicationModeRequest p_CommunicationModeRequest)
+{
+    MsgSend(H245_MSG_REQ , MSGTYP_CM_REQ , (uint8*)p_CommunicationModeRequest) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cm_1101_XXXX                               */
+/*  function outline    : Event     CommunicationModeRequest            */
+/*  function discription: Se_Cm_1101_XXXX                               */
+/*                      :               ( PS_CommunicationModeRequest ) */
+/*  input data          : PS_CommunicationModeRequest                   */
+/*                      :                    p_CommunicationModeRequest */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CM::_1101_XXXX(PS_CommunicationModeRequest p_CommunicationModeRequest)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cm_Req_Cfm , 0 , 0 , (uint8*)p_CommunicationModeRequest , sizeof(S_CommunicationModeRequest)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cm_1102_XXXX                               */
+/*  function outline    : Event     CommunicationModeResponse Primitive */
+/*  function discription: Se_Cm_1102_XXXX                               */
+/*                      :          ( PS_CommunicationModeResponse ) */
+/*  input data          : PS_CommunicationModeResponse              */
+/*                      :               p_CommunicationModeResponse */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CM::_1102_XXXX(PS_CommunicationModeResponse p_CommunicationModeResponse)
+{
+    MsgSend(H245_MSG_RPS , MSGTYP_CM_RPS , (uint8*)p_CommunicationModeResponse) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cm_1103_XXXX                               */
+/*  function outline    : Event     CommunicationModeResponse           */
+/*  function discription: Se_Cm_1103_XXXX                               */
+/*                      :              ( PS_CommunicationModeResponse ) */
+/*  input data          : PS_CommunicationModeResponse                  */
+/*                      :                   p_CommunicationModeResponse */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CM::_1103_XXXX(PS_CommunicationModeResponse p_CommunicationModeResponse)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cm_Rps_Cfm , 0 , 0 , (uint8*)p_CommunicationModeResponse , sizeof(S_CommunicationModeResponse)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cm_1104_XXXX                               */
+/*  function outline    : Event     CommunicationModeCommand Primitive  */
+/*  function discription: Se_Cm_1104_XXXX                               */
+/*                      :          ( PS_CommunicationModeCommand )  */
+/*  input data          : PS_CommunicationModeCommand               */
+/*                      :                p_CommunicationModeCommand*/
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CM::_1104_XXXX(PS_CommunicationModeCommand p_CommunicationModeCommand)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CM_CMD , (uint8*)p_CommunicationModeCommand) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cm_1105_XXXX                               */
+/*  function outline    : Event     CommunicationModeCommand            */
+/*  function discription: Se_Cm_1105_XXXX                               */
+/*                      :               ( PS_CommunicationModeCommand ) */
+/*  input data          : PS_CommunicationModeCommand                   */
+/*                      :                    p_CommunicationModeCommand */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CM::_1105_XXXX(PS_CommunicationModeCommand p_CommunicationModeCommand)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cm_Cmd_Cfm , 0 , 0 , (uint8*)p_CommunicationModeCommand , sizeof(S_CommunicationModeCommand)) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Cnf_1300_XXXX                              */
+/*  function outline    : Event     ConferenceRequest Primitive         */
+/*  function discription: void Se_Cnf_1300_XXXX                         */
+/*                      :                  ( PS_ConferenceRequest ) */
+/*  input data          : PS_ConferenceRequest                      */
+/*                      :                       p_ConferenceRequest */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CNF::_1300_XXXX(PS_ConferenceRequest p_ConferenceRequest)
+{
+    MsgSend(H245_MSG_REQ , MSGTYP_CNF_REQ , (uint8*)p_ConferenceRequest) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cnf_1301_XXXX                              */
+/*  function outline    : Event     ConferenceRequest                   */
+/*  function discription: Se_Cnf_1301_XXXX( PS_ConferenceRequest )      */
+/*  input data          : PS_ConferenceRequest p_ConferenceRequest      */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CNF::_1301_XXXX(PS_ConferenceRequest p_ConferenceRequest)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cnf_Req_Cfm , 0 , 0 , (uint8*)p_ConferenceRequest , sizeof(S_ConferenceRequest)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cnf_1302_XXXX                              */
+/*  function outline    : Event     ConferenceResponse Primitive        */
+/*  function discription: Se_Cnf_1302_XXXX( PS_ConferenceResponse ) */
+/*  input data          : PS_ConferenceResponse                     */
+/*                      :                      p_ConferenceResponse */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CNF::_1302_XXXX(PS_ConferenceResponse p_ConferenceResponse)
+{
+    MsgSend(H245_MSG_RPS , MSGTYP_CNF_RPS , (uint8*)p_ConferenceResponse) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cnf_1303_XXXX                              */
+/*  function outline    : Event     ConferenceResponse                  */
+/*  function discription: Se_Cnf_1303_XXXX( PS_ConferenceResponse )     */
+/*  input data          : PS_ConferenceResponse p_ConferenceResponse    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CNF::_1303_XXXX(PS_ConferenceResponse p_ConferenceResponse)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cnf_Rps_Cfm , 0 , 0 , (uint8*)p_ConferenceResponse , sizeof(S_ConferenceResponse)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1400_XXXX                              */
+/*  function outline    : Event     SendTerminalCapabilitySet Primitive */
+/*  function discription: Se_Cmd_1400_XXXX                              */
+/*                      :          ( PS_SendTerminalCapabilitySet ) */
+/*  input data          : PS_SendTerminalCapabilitySet              */
+/*                      :               p_SendTerminalCapabilitySet */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1400_XXXX(PS_SendTerminalCapabilitySet p_SendTerminalCapabilitySet)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_STCS , (uint8*)p_SendTerminalCapabilitySet) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1401_XXXX                              */
+/*  function outline    : Event     SendTerminalCapabilitySet           */
+/*  function discription: Se_Cmd_1401_XXXX                              */
+/*                      :              ( PS_SendTerminalCapabilitySet ) */
+/*  input data          : PS_SendTerminalCapabilitySet                  */
+/*                      :                   p_SendTerminalCapabilitySet */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1401_XXXX(PS_SendTerminalCapabilitySet p_SendTerminalCapabilitySet)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Stcs_Cfm , 0 , 0 , (uint8*)p_SendTerminalCapabilitySet , sizeof(S_SendTerminalCapabilitySet)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1402_XXXX                              */
+/*  function outline    : Event     EncryptionCommand Primitive         */
+/*  function discription: Se_Cmd_1402_XXXX( PS_EncryptionCommand )  */
+/*  input data          : PS_EncryptionCommand                      */
+/*                      :                       p_EncryptionCommand */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1402_XXXX(PS_EncryptionCommand p_EncryptionCommand)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_ECRPT , (uint8*)p_EncryptionCommand) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1403_XXXX                              */
+/*  function outline    : Event     EncryptionCommand                   */
+/*  function discription: Se_Cmd_1403_XXXX( PS_EncryptionCommand )      */
+/*  input data          : PS_EncryptionCommand p_EncryptionCommand      */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1403_XXXX(PS_EncryptionCommand p_EncryptionCommand)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Ecrpt_Cfm , 0 , 0 , (uint8*)p_EncryptionCommand , sizeof(S_EncryptionCommand)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1404_XXXX                              */
+/*  function outline    : Event     FlowControlCommand Primitive        */
+/*  function discription: Se_Cmd_1404_XXXX( PS_FlowControlCommand ) */
+/*  input data          : PS_FlowControlCommand                     */
+/*                      :                      p_FlowControlCommand */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1404_XXXX(PS_FlowControlCommand p_FlowControlCommand)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_FC , (uint8*)p_FlowControlCommand) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1405_XXXX                              */
+/*  function outline    : Event     FlowControlCommand                  */
+/*  function discription: Se_Cmd_1405_XXXX( PS_FlowControlCommand )     */
+/*  input data          : PS_FlowControlCommand p_FlowControlCommand    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1405_XXXX(PS_FlowControlCommand p_FlowControlCommand, uint8* EncodedMsg, uint32 EncodedMsgSize)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Fc_Cfm , 0 , 0 , (uint8*)p_FlowControlCommand , sizeof(S_FlowControlCommand),
+            EncodedMsg, EncodedMsgSize) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1406_XXXX                              */
+/*  function outline    : Event                                         */
+/*  function discription: Se_Cmd_1406_XXXX( PS_EndSessionCommand )      */
+/*  input data          :                                               */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1406_XXXX(PS_EndSessionCommand p_EndSessionCommand)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_ES , (uint8*)p_EndSessionCommand) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1407_XXXX                              */
+/*  function outline    : Event                                         */
+/*  function discription: Se_Cmd_1407_XXXX( PS_EndSessionCommand )      */
+/*  input data          :                                               */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1407_XXXX(PS_EndSessionCommand p_EndSessionCommand)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Es_Cfm , 0 , 0 , (uint8*)p_EndSessionCommand , sizeof(S_EndSessionCommand)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1408_XXXX                              */
+/*  function outline    : Event     MiscellaneousCommand Primitive      */
+/*  function discription: Se_Cmd_1408_XXXX                              */
+/*                      :               ( PS_MiscellaneousCommand ) */
+/*  input data          : PS_MiscellaneousCommand                   */
+/*                      :                    p_MiscellaneousCommand */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1408_XXXX(PS_MiscellaneousCommand p_MiscellaneousCommand)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_MSCL , (uint8*)p_MiscellaneousCommand) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_1409_XXXX                              */
+/*  function outline    : Event     MiscellaneousCommand                */
+/*  function discription: Se_Cmd_1409_XXXX( PS_MiscellaneousCommand )   */
+/*  input data          : PS_MiscellaneousCommand p_MiscellaneousCommand*/
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_1409_XXXX(PS_MiscellaneousCommand p_MiscellaneousCommand, uint8* EncodedMsg, uint32 EncodedMsgSize)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Mscl_Cfm , 0 , 0 , (uint8*)p_MiscellaneousCommand , sizeof(S_MiscellaneousCommand),
+            EncodedMsg, EncodedMsgSize) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_140A_XXXX                              */
+/*  function outline    : Event     ConferenceCommand Primitive         */
+/*  function discription: Se_Cmd_140A_XXXX( PS_ConferenceCommand )  */
+/*  input data          : PS_ConferenceCommand                      */
+/*                      :                       p_ConferenceCommand */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_140A_XXXX(PS_ConferenceCommand p_ConferenceCommand)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_CNF , (uint8*)p_ConferenceCommand) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_140B_XXXX                              */
+/*  function outline    : Event     ConferenceCommand                   */
+/*  function discription: Se_Cmd_140B_XXXX( PS_ConferenceCommand )      */
+/*  input data          : PS_ConferenceCommand p_ConferenceCommand      */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_140B_XXXX(PS_ConferenceCommand p_ConferenceCommand)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Cnf_Cfm , 0 , 0 , (uint8*)p_ConferenceCommand , sizeof(S_ConferenceCommand)) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Cmd_140C_XXXX                              */
+/*  function outline    : Event h223MultiplexReconfiguration Primitive  */
+/*  function discription: Se_Cmd_140C_XXXX( PS_h223MultiplexReconfiguration)  */
+/*  input data          : PS_h223MultiplexReconfigurationPara                      */
+/*                      :                       p_h223MultiplexReconfiguration */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_140C_XXXX(PS_H223MultiplexReconfiguration p_h223MultiplexReconfiguration)
+{
+    MsgSend(H245_MSG_CMD , MSGTYP_CMD_HMR , (uint8*)p_h223MultiplexReconfiguration) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Cmd_140D_XXXX                              */
+/*  function outline    : Event     h223MultiplexReconfiguration                   */
+/*  function discription: Se_Cmd_140D_XXXX( PS_h223MultiplexReconfiguration )      */
+/*  input data          : PS_h223MultiplexReconfiguration p_h223MultiplexReconfiguration      */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CMD::_140D_XXXX(PS_H223MultiplexReconfiguration p_h223MultiplexReconfiguration, uint8* EncodedMsg, uint32 EncodedMsgSize)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Cmd_Hmr_Cfm , 0 , 0 ,
+            (uint8*)p_h223MultiplexReconfiguration , sizeof(S_H223MultiplexReconfiguration),
+            EncodedMsg, EncodedMsgSize) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Idc_1500_XXXX                              */
+/*  function outline    : Event     FunctionNotUnderstood Primitive     */
+/*  function discription: Se_Idc_1500_XXXX                              */
+/*                      :              ( PS_FunctionNotUnderstood ) */
+/*  input data          : PS_FunctionNotUnderstood                  */
+/*                      :                   p_FunctionNotUnderstood */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1500_XXXX(PS_FunctionNotUnderstood p_FunctionNotUnderstood)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_FNU , (uint8*)p_FunctionNotUnderstood) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1501_XXXX                              */
+/*  function outline    : Event     FunctionNotUnderstood               */
+/*  function discription: Se_Idc_1501_XXXX( PS_FunctionNotUnderstood )  */
+/*  input data          : PS_FunctionNotUnderstood                      */
+/*                      :                       p_FunctionNotUnderstood */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1501_XXXX(PS_FunctionNotUnderstood p_FunctionNotUnderstood)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Fnu_Cfm , 0 , 0 , (uint8*)p_FunctionNotUnderstood , sizeof(S_FunctionNotUnderstood)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1502_XXXX                              */
+/*  function outline    : Event     MiscellaneousIndication Primitive   */
+/*  function discription: Se_Idc_1502_XXXX                              */
+/*                      :            ( PS_MiscellaneousIndication ) */
+/*  input data          : PS_MiscellaneousIndication                */
+/*                      :                 p_MiscellaneousIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1502_XXXX(PS_MiscellaneousIndication p_MiscellaneousIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_MSCL , (uint8*)p_MiscellaneousIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1503_XXXX                              */
+/*  function outline    : Event     MiscellaneousIndication             */
+/*  function discription: Se_Idc_1503_XXXX                              */
+/*                      :                ( PS_MiscellaneousIndication ) */
+/*  input data          : PS_MiscellaneousIndication                    */
+/*                      :                     p_MiscellaneousIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1503_XXXX(PS_MiscellaneousIndication p_MiscellaneousIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Mscl_Cfm , 0 , 0 , (uint8*)p_MiscellaneousIndication , sizeof(S_MiscellaneousIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1504_XXXX                              */
+/*  function outline    : Event     JitterIndication Primitive          */
+/*  function discription: Se_Idc_1504_XXXX( PS_JitterIndication )   */
+/*  input data          : PS_JitterIndication                       */
+/*                      :                        p_JitterIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1504_XXXX(PS_JitterIndication p_JitterIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_JTR , (uint8*)p_JitterIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1505_XXXX                              */
+/*  function outline    : Event     JitterIndication                    */
+/*  function discription: Se_Idc_1505_XXXX( PS_JitterIndication )       */
+/*  input data          : PS_JitterIndication p_JitterIndication        */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1505_XXXX(PS_JitterIndication p_JitterIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Jtr_Cfm , 0 , 0 , (uint8*)p_JitterIndication , sizeof(S_JitterIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1506_XXXX                              */
+/*  function outline    : Event     H223SkewIndication Primitive        */
+/*  function discription: Se_Idc_1506_XXXX( PS_H223SkewIndication ) */
+/*  input data          : PS_H223SkewIndication                     */
+/*                      :                      p_H223SkewIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1506_XXXX(PS_H223SkewIndication p_H223SkewIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_H223SKW , (uint8*)p_H223SkewIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1507_XXXX                              */
+/*  function outline    : Event     H223SkewIndication                  */
+/*  function discription: Se_Idc_1507_XXXX( PS_H223SkewIndication )     */
+/*  input data          : PS_H223SkewIndication p_H223SkewIndication    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1507_XXXX(PS_H223SkewIndication p_H223SkewIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_H223skw_Cfm , 0 , 0 , (uint8*)p_H223SkewIndication , sizeof(S_H223SkewIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1508_XXXX                              */
+/*  function outline    : Event     NewATMVCIndication Primitive        */
+/*  function discription: Se_Idc_1508_XXXX( PS_NewATMVCIndication ) */
+/*  input data          : PS_NewATMVCIndication                     */
+/*                      :                      p_NewATMVCIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1508_XXXX(PS_NewATMVCIndication p_NewATMVCIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_NWATMVC , (uint8*)p_NewATMVCIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1509_XXXX                              */
+/*  function outline    : Event     NewATMVCIndication                  */
+/*  function discription: Se_Idc_1509_XXXX( PS_NewATMVCIndication )     */
+/*  input data          : PS_NewATMVCIndication p_NewATMVCIndication    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1509_XXXX(PS_NewATMVCIndication p_NewATMVCIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Nwatmvc_Cfm , 0 , 0 , (uint8*)p_NewATMVCIndication , sizeof(S_NewATMVCIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_150A_XXXX                              */
+/*  function outline    : Event     UserInputIndication Primitive       */
+/*  function discription: Se_Idc_150A_XXXX( PS_UserInputIndication )*/
+/*  input data          : PS_UserInputIndication                    */
+/*                      :                     p_UserInputIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_150A_XXXX(PS_UserInputIndication p_UserInputIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_UI , (uint8*)p_UserInputIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_150B_XXXX                              */
+/*  function outline    : Event     UserInputIndication                 */
+/*  function discription: Se_Idc_150B_XXXX( PS_UserInputIndication )    */
+/*  input data          : PS_UserInputIndication p_UserInputIndication  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_150B_XXXX(PS_UserInputIndication p_UserInputIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Ui_Cfm , 0 , 0 , (uint8*)p_UserInputIndication , sizeof(S_UserInputIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_150C_XXXX                              */
+/*  function outline    : Event     ConferenceIndication Primitive      */
+/*  function discription: Se_Idc_150C_XXXX                              */
+/*                      :               ( PS_ConferenceIndication ) */
+/*  input data          : PS_ConferenceIndication                   */
+/*                      :                    p_ConferenceIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_150C_XXXX(PS_ConferenceIndication p_ConferenceIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_CNF , (uint8*)p_ConferenceIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_150C_XXXX                              */
+/*  function outline    : Event     ConferenceIndication                */
+/*  function discription: Se_Idc_150C_XXXX( PS_ConferenceIndication )   */
+/*  input data          : PS_ConferenceIndication                       */
+/*                      :                        p_ConferenceIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_150D_XXXX(PS_ConferenceIndication p_ConferenceIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Cnf_Cfm , 0 , 0 , (uint8*)p_ConferenceIndication , sizeof(S_ConferenceIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_150E_XXXX                              */
+/*  function outline    : Event     H2250MaximumSkewIndication Primitive*/
+/*  function discription: Se_Idc_150E_XXXX                              */
+/*                      :         ( PS_H2250MaximumSkewIndication ) */
+/*  input data          : PS_H2250MaximumSkewIndication             */
+/*                      :              p_H2250MaximumSkewIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_150E_XXXX(PS_H2250MaximumSkewIndication p_H2250MaximumSkewIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_H2250MXSKW , (uint8*)p_H2250MaximumSkewIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_150F_XXXX                              */
+/*  function outline    : Event     H2250MaximumSkewIndication          */
+/*  function discription: Se_Idc_150F_XXXX                              */
+/*                      :             ( PS_H2250MaximumSkewIndication ) */
+/*  input data          : PS_H2250MaximumSkewIndication                 */
+/*                      :                  p_H2250MaximumSkewIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_150F_XXXX(PS_H2250MaximumSkewIndication p_H2250MaximumSkewIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_H2250mxskw_Cfm , 0 , 0 , (uint8*)p_H2250MaximumSkewIndication , sizeof(S_H2250MaximumSkewIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1510_XXXX                              */
+/*  function outline    : Event     MCLocationIndication Primitive      */
+/*  function discription: Se_Idc_1510_XXXX                              */
+/*                      :               ( PS_MCLocationIndication ) */
+/*  input data          : PS_MCLocationIndication                   */
+/*                      :                    p_McLocationIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1510_XXXX(PS_MCLocationIndication p_McLocationIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_MCLCT , (uint8*)p_McLocationIndication) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1511_XXXX                              */
+/*  function outline    : Event     MCLocationIndication                */
+/*  function discription: Se_Idc_1511_XXXX( PS_MCLocationIndication )   */
+/*  input data          : PS_MCLocationIndication                       */
+/*                      :                        p_McLocationIndication */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1511_XXXX(PS_MCLocationIndication p_McLocationIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Mclct_Cfm , 0 , 0 , (uint8*)p_McLocationIndication , sizeof(S_MCLocationIndication)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1512_XXXX                              */
+/*  function outline    : Event     VendorIdentification Primitive      */
+/*  function discription: Se_Idc_1512_XXXX                              */
+/*                      :               ( PS_VendorIdentification ) */
+/*  input data          : PS_VendorIdentification                   */
+/*                      :                    p_VendorIdentification */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1512_XXXX(PS_VendorIdentification p_VendorIdentification)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_VI , (uint8*)p_VendorIdentification) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1513_XXXX                              */
+/*  function outline    : Event     VendorIdentification                */
+/*  function discription: Se_Idc_1513_XXXX                              */
+/*                      :               ( PS_VendorIdentification )     */
+/*  input data          : PS_VendorIdentification                       */
+/*                      :                       p_VendorIdentification */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1513_XXXX(PS_VendorIdentification p_VendorIdentification)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Vi_Cfm , 0 , 0 , (uint8*)p_VendorIdentification , sizeof(S_VendorIdentification)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1514_XXXX                              */
+/*  function outline    : Event     FunctionNotSupported Primitive      */
+/*  function discription: Se_Idc_1514_XXXX                              */
+/*                      :               ( PS_FunctionNotSupported ) */
+/*  input data          : PS_FunctionNotSupported                   */
+/*                      :                    p_FunctionNotSupported */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1514_XXXX(PS_FunctionNotSupported p_FunctionNotSupported)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_FNS , (uint8*)p_FunctionNotSupported) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Idc_1515_XXXX                              */
+/*  function outline    : Event     FunctionNotSupported                */
+/*  function discription: Se_Idc_1515_XXXX( PS_FunctionNotSupported )   */
+/*  input data          : PS_FunctionNotSupported                       */
+/*                      :                        p_FunctionNotSupported */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1515_XXXX(PS_FunctionNotSupported p_FunctionNotSupported)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Fns_Cfm , 0 , 0 , (uint8*)p_FunctionNotSupported , sizeof(S_FunctionNotSupported)) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Idc_1516_XXXX                              */
+/*  function outline    : Event     FlowControlIndication Primitive     */
+/*  function discription: Se_Idc_1516_XXXX                              */
+/*                      :               ( PS_FlowControlIndication )    */
+/*  input data          : PS_FlowControlIndication                      */
+/*                      :                    p_FlowControlIndication    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1516_XXXX(PS_FlowControlIndication p_FlowControlIndication)
+{
+    MsgSend(H245_MSG_IDC , MSGTYP_IDC_FC , (uint8*)p_FlowControlIndication) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Idc_1517_XXXX                              */
+/*  function outline    : Event     FlowControlIndication               */
+/*  function discription: Se_Idc_1517_XXXX( PS_FlowControlIndication)   */
+/*  input data          : PS_FlowControlIndication                      */
+/*                      :                        p_FlowControlIndication*/
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void IDC::_1517_XXXX(PS_FlowControlIndication p_FlowControlIndication)
+{
+    PtvSend(H245_PRIMITIVE , E_PtvId_Idc_Fc_Cfm , 0 , 0 , (uint8*)p_FlowControlIndication , sizeof(S_FlowControlIndication)) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_AnnexMsgSend                               */
+/*  function outline    : Message Send Function ( Annex )               */
+/*  function discription: Se_AnnexMsgSend( uint8 , uint8 , uint8* )     */
+/*  input data          : uint8 MessageType                             */
+/*                      : uint8 MessageNumber                           */
+/*                      : uint8* RealDataPointer                        */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void Annex::MsgSend(uint8 MessageType , uint8 MessageNumber , uint8* RealDataPointer)
+{
+    S_H245Msg h245msg;
+
+    h245msg.Type1 = MessageType ;
+    h245msg.Type2 = MessageNumber ;
+    h245msg.pData = RealDataPointer ;
+
+    MessageSend(&h245msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_AnnexPtvSend                               */
+/*  function outline    : Primitive Send Function ( Annex )             */
+/*  function discription: Se_AnnexMsgSend( uint32 , uint32 , uint32 , uint32 ,  */
+/*                      :                                   uint8* uint32 */
+/*  input data          : uint32 InfType                                  */
+/*                      : uint32 InfId                                    */
+/*                      : uint32 InfSupplement1                           */
+/*                      : uint32 InfSupplement2                           */
+/*                      : uint8* p_Parameter                            */
+/*                      : uint32 Size                                     */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void Annex::PtvSend(uint32 InfType , uint32 InfId , uint32 InfSupplement1 , uint32 InfSupplement2 , uint8* p_Parameter , uint32 Size,
+                    uint8* EncodedMsg, uint32 EncodedMsgSize)
+{
+    S_InfHeader                infHeader ;
+
+    infHeader.InfType = InfType ;
+    infHeader.InfId = InfId ;
+    infHeader.InfSupplement1 = InfSupplement1 ;
+    infHeader.InfSupplement2 = InfSupplement2 ;
+    infHeader.pParameter = p_Parameter ;
+    infHeader.Size = Size ;
+    infHeader.EncodedMsg = EncodedMsg;
+    infHeader.EncodedMsgSize = EncodedMsgSize;
+
+    PrimitiveSend(&infHeader) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/blc.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/blc.cpp
new file mode 100644
index 0000000..1392ca1
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/blc.cpp
@@ -0,0 +1,851 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seblc.c                                           */
+/*  file contents   : Bi-Directional Logical Channel Signalling Entity  */
+/*                  :                                        Management */
+/*  draw            : '96.11.26                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245inf.h"
+#include "msd.h"
+#include "blc.h"
+#include "lcblccmn.h"
+
+/************************************************************************/
+/*  function name       : Se_Blc_0300_0000                              */
+/*  function outline    : Event     ESTABLISH.request                   */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Blc_0300_0000( PS_LCB_ENTRY ,              */
+/*                      :                      PS_ForwardReverseParam ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ForwardReverseParam p_ForwardReverseParam  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0300_0000(LCEntry *p_LcbEntry , PS_ForwardReverseParam p_ForwardReverseParam)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_ETBMNT) ;
+    MsgOpenSend((uint16) forwardLcn, p_ForwardReverseParam) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0300_0030                              */
+/*  function outline    : Event     ESTABLISH.request                   */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Blc_0300_0030( PS_LCB_ENTRY ,              */
+/*                      :                      PS_ForwardReverseParam ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ForwardReverseParam p_ForwardReverseParam  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0300_0030(LCEntry *p_LcbEntry , PS_ForwardReverseParam p_ForwardReverseParam)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_ETBMNT) ;
+    MsgOpenSend((uint16) forwardLcn, p_ForwardReverseParam) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0301_0010                              */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Blc_0301_0010( PS_LCB_ENTRY ,              */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0301_0010(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    if (MyMSD->GetStatus() != MSD_MASTER)
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+        uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+        T103TimerStop(forwardLcn) ;
+        p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+        PtvEtbIdcSend(forwardLcn, p_OpenLogicalChannel, reverseLcn) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0303_0010                              */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Blc_0303_0010( PS_LCB_ENTRY ,              */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0303_0010(LCEntry *p_LcbEntry , PS_OlcRejectCause p_Cause)
+{
+    S_Source    source ;
+    OSCL_UNUSED_ARG(p_Cause);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    source.index = 0 ;  /* user */
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_RLS) ;
+    MsgCloseSend((uint16) forwardLcn, &source) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0303_0020                              */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Established                */
+/*  function discription: Se_Blc_0303_0020( PS_LCB_ENTRY ,              */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0303_0020(LCEntry *p_LcbEntry , PS_OlcRejectCause p_Cause)
+{
+    S_Source    source ;
+    OSCL_UNUSED_ARG(p_Cause);
+
+    source.index = 0 ;  /* user */
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_RLS) ;
+    MsgCloseSend((uint16) forwardLcn, &source) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0304_0000                              */
+/*  function outline    : Event     OpenLogicalChannelAck               */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Blc_0304_0000( PS_LCB_ENTRY ,              */
+/*                      :                    PS_OpenLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelAck                      */
+/*                      :                       p_OpenLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0304_0000(LCEntry *p_LcbEntry , PS_OpenLogicalChannelAck p_OpenLogicalChannelAck)
+{
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelAck);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+    PtvErrIdcSend(forwardLcn, ErrCode_Blc_A, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0304_0010                              */
+/*  function outline    : Event     OpenLogicalChannelAck               */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Blc_0304_0010( PS_LCB_ENTRY ,              */
+/*                      :                    PS_OpenLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelAck                      */
+/*                      :                       p_OpenLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0304_0010(LCEntry *p_LcbEntry , PS_OpenLogicalChannelAck p_OpenLogicalChannelAck)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_ETBED) ;
+    p_LcbEntry->RvsLcnWrite(p_OpenLogicalChannelAck->ackReverseLogicalChannelParameters.reverseLogicalChannelNumber) ;
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+    PtvEtbCfmSend(forwardLcn, p_OpenLogicalChannelAck, reverseLcn) ;
+    MsgOpenCfmSend((uint16) forwardLcn, p_OpenLogicalChannelAck) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0306_0000                              */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Blc_0306_0000 ( PS_LCB_ENTRY ,             */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0306_0000(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelReject);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+    PtvErrIdcSend(forwardLcn, ErrCode_Blc_B, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0306_0010                              */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Blc_0306_0010 ( PS_LCB_ENTRY ,             */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0306_0010(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    S_Source    source ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    source.index = 0 ;  /* user */
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvRlsIdcSend(forwardLcn, &source , &p_OpenLogicalChannelReject->olcRejectCause, S_InfHeader::OUTGOING, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0306_0020                              */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Established                */
+/*  function discription: Se_Blc_0306_0020 ( PS_LCB_ENTRY ,             */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0306_0020(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    S_Source    source ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+
+    PtvErrIdcSend(forwardLcn, ErrCode_Blc_B, reverseLcn) ;
+
+    source.index = 1 ;  /* lcse */
+
+    PtvRlsIdcSend(forwardLcn, &source , &p_OpenLogicalChannelReject->olcRejectCause, S_InfHeader::OUTGOING, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0306_0030                              */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Blc_0306_0030 ( PS_LCB_ENTRY ,             */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0306_0030(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelReject);
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvRlsCfmSend(forwardLcn, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0307_0010                              */
+/*  function outline    : Event     Timer T103 Timeout                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Blc_0307_0010( PS_LCB_ENTRY , int32 )        */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : int32 TmrSqcNumber                              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0307_0010(LCEntry *p_LcbEntry , int32 TmrSqcNumber)
+{
+    S_Source           source ;
+    S_OlcRejectCause   cause ;
+
+    if (TmrSqcNumber == p_LcbEntry->TmrSqcNumberRead())
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+        uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+        p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+
+        PtvErrIdcSend(forwardLcn, ErrCode_Blc_D, reverseLcn) ;
+
+        source.index = 1 ;  /* lcse */
+        MsgCloseSend((uint16) forwardLcn, &source) ;
+
+        oscl_memset((void*)&cause , 0 , sizeof(S_OlcRejectCause)) ;
+        PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::OUTGOING, reverseLcn) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0307_0030                              */
+/*  function outline    : Event     Timer T103 Timeout                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Blc_0307_0030( PS_LCB_ENTRY , int32 )        */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : int32 TmrSqcNumber                              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0307_0030(LCEntry *p_LcbEntry , int32 TmrSqcNumber)
+{
+    if (TmrSqcNumber == p_LcbEntry->TmrSqcNumberRead())
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+        uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+        p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+        PtvErrIdcSend(forwardLcn, ErrCode_Blc_D, reverseLcn) ;
+        PtvRlsCfmSend(forwardLcn, reverseLcn) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0309_0020                              */
+/*  function outline    : Event     CloseLogicalChannelAck              */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Established                */
+/*  function discription: Se_Blc_0309_0020( PS_LCB_ENTRY ,              */
+/*                      :                   PS_CloseLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannelAck                     */
+/*                      :                      p_CloseLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0309_0020(LCEntry *p_LcbEntry , PS_CloseLogicalChannelAck p_CloseLogicalChannelAck)
+{
+    S_Source           source ;
+    S_OlcRejectCause   cause ;
+
+    OSCL_UNUSED_ARG(p_CloseLogicalChannelAck);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvErrIdcSend(forwardLcn, ErrCode_Blc_C, reverseLcn) ;
+
+    source.index = 1 ;
+    oscl_memset((void*)&cause , 0 , sizeof(S_OlcRejectCause)) ;
+    PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::OUTGOING, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0309_0030                              */
+/*  function outline    : Event     CloseLogicalChannelAck              */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Blc_0309_0030( PS_LCB_ENTRY ,              */
+/*                      :                   PS_CloseLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannelAck                     */
+/*                      :                      p_CloseLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0309_0030(LCEntry *p_LcbEntry , PS_CloseLogicalChannelAck p_CloseLogicalChannelAck)
+{
+    OSCL_UNUSED_ARG(p_CloseLogicalChannelAck);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvRlsCfmSend(forwardLcn, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0301_0001                              */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Released                   */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Blc_0301_0001( PS_LCB_ENTRY ,              */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0301_0001(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+    PtvEtbIdcSend(forwardLcn, p_OpenLogicalChannel, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0301_0011                              */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*                      : Status    Incoming Established                */
+/*  function discription: Se_Blc_0301_0011( PS_LCB_ENTRY ,              */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0301_0011(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    S_Source           source ;
+    S_OlcRejectCause   cause ;
+
+    source.index = 0 ;  /* user */
+    cause.index = 0 ;   /* unspecified */
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+    PtvRlsIdcSend(forwardLcn, &source , &cause , S_InfHeader::INCOMING, reverseLcn) ;
+    PtvEtbIdcSend(forwardLcn, p_OpenLogicalChannel, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0301_0021                              */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Confirmation      */
+/*  function discription: Se_Blc_0301_0021( PS_LCB_ENTRY ,              */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0301_0021(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    S_Source           source ;
+    S_OlcRejectCause   cause ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    source.index = 0 ;  /* user */
+    cause.index = 0 ;   /* unspecified */
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+    PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::INCOMING, reverseLcn) ;
+    PtvEtbIdcSend(forwardLcn, p_OpenLogicalChannel, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0302_0011                              */
+/*  function outline    : Event     ESTABLISH.response                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*  function discription: Se_Blc_0302_0011( PS_LCB_ENTRY ,              */
+/*                      :                       PS_ReverseData , uint32 ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ReverseData p_ReverseData                  */
+/*                      : uint32 ReverseLogicalChannelNumber              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0302_0011(LCEntry *p_LcbEntry , PS_ReverseData p_ReverseData , uint16 ReverseLogicalChannelNumber)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->RvsLcnWrite(ReverseLogicalChannelNumber) ;
+    p_ReverseData->reverseLogicalChannelParameters.reverseLogicalChannelNumber = ReverseLogicalChannelNumber;
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_CNFMTN) ;
+    MsgOpenAckSend((uint16) forwardLcn, p_ReverseData) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0303_0011                              */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*  function discription: Se_Blc_0303_0011( PS_LCB_ENTRY ,              */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0303_0011(LCEntry *p_LcbEntry , PS_OlcRejectCause p_Cause)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+    MsgOpenRjtSend((uint16) forwardLcn, p_Cause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0305_0011                              */
+/*  function outline    : Event     OpenLogicalChannelConfirm           */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*  function discription: Se_Blc_0305_0011( PS_LCB_ENTRY ,              */
+/*                      :                PS_OpenLogicalChannelConfirm ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelConfirm                  */
+/*                      :                   p_OpenLogicalChannelConfirm */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0305_0011(LCEntry *p_LcbEntry , PS_OpenLogicalChannelConfirm p_OpenLogicalChannelConfirm)
+{
+    S_Source           source ;
+    S_OlcRejectCause   cause ;
+
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelConfirm);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+    PtvErrIdcSend(forwardLcn, ErrCode_Blc_E, reverseLcn) ;
+    source.index = 1 ;  /* user */
+    oscl_memset((void*)&cause , 0 , sizeof(S_OlcRejectCause)) ;
+    PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::INCOMING, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0305_0021                              */
+/*  function outline    : Event     OpenLogicalChannelConfirm           */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Confirmation      */
+/*  function discription: Se_Blc_0305_0021( PS_LCB_ENTRY ,              */
+/*                      :                PS_OpenLogicalChannelConfirm ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelConfirm                  */
+/*                      :                   p_OpenLogicalChannelConfirm */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0305_0021(LCEntry *p_LcbEntry , PS_OpenLogicalChannelConfirm p_OpenLogicalChannelConfirm)
+{
+    S_OpenLogicalChannelAck     OpenLogicalChannelAck ;
+
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelConfirm);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    OpenLogicalChannelAck.forwardLogicalChannelNumber = (uint16) forwardLcn;
+    OpenLogicalChannelAck.option_of_ackReverseLogicalChannelParameters = false ;
+    oscl_memset((void*)&OpenLogicalChannelAck.ackReverseLogicalChannelParameters ,
+                0 ,
+                sizeof(S_AckReverseLogicalChannelParameters)) ;
+    OpenLogicalChannelAck.option_of_separateStack = false ;
+    oscl_memset((void*)&OpenLogicalChannelAck.separateStack , 0 , sizeof(S_NetworkAccessParameters)) ;
+    OpenLogicalChannelAck.option_of_forwardMultiplexAckParameters = false ;
+    oscl_memset((void*)&OpenLogicalChannelAck.forwardMultiplexAckParameters , 0 , sizeof(S_ForwardMultiplexAckParameters)) ;
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_ETBED) ;
+    PtvEtbCfmSend2(forwardLcn, &OpenLogicalChannelAck, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0307_0021                              */
+/*  function outline    : Event     Timer T103 Timeout                  */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Confirmation      */
+/*  function discription: Se_Blc_0307_0021( PS_LCB_ENTRY , int32 )        */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : int32 TmrSqcNumber                              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0307_0021(LCEntry *p_LcbEntry , int32 TmrSqcNumber)
+{
+    S_Source           source ;
+    S_OlcRejectCause   cause ;
+
+    if (TmrSqcNumber == p_LcbEntry->TmrSqcNumberRead())
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+        uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+        p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+
+        PtvErrIdcSend(forwardLcn, ErrCode_Blc_F, reverseLcn) ;
+
+        source.index = 1 ;  /* lcse */
+        oscl_memset((void*)&cause , 0 , sizeof(S_OlcRejectCause)) ;
+        PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::INCOMING, reverseLcn) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0308_0001                              */
+/*  function outline    : Event     CloseLogicalChannel                 */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Released                   */
+/*  function discription: Se_Blc_0308_0001( PS_LCB_ENTRY ,              */
+/*                      :                      PS_CloseLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannel p_CloseLogicalChannel  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0308_0001(LCEntry *p_LcbEntry , PS_CloseLogicalChannel p_CloseLogicalChannel)
+{
+    OSCL_UNUSED_ARG(p_CloseLogicalChannel);
+    MsgCloseAckSend((uint16) p_LcbEntry->FwdLcnRead()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0308_0011                              */
+/*  function outline    : Event     CloseLogicalChannel                 */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*                      : Status    Incoming Established                */
+/*  function discription: Se_Blc_0308_0011( PS_LCB_ENTRY ,              */
+/*                      :                      PS_CloseLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannel p_CloseLogicalChannel  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0308_0011(LCEntry *p_LcbEntry , PS_CloseLogicalChannel p_CloseLogicalChannel)
+{
+    S_OlcRejectCause   cause ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+
+    MsgCloseAckSend((uint16) forwardLcn) ;
+
+    cause.index = 0 ;  /* unspecified */
+    PtvRlsIdcSend(forwardLcn, &p_CloseLogicalChannel->source , &cause, S_InfHeader::INCOMING, reverseLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Blc_0308_0021                              */
+/*  function outline    : Event     CloseLogicalChannel                 */
+/*                      :                            ( Bi-Directional ) */
+/*                      : Status    Incoming Awaiting Confirmation      */
+/*  function discription: Se_Blc_0308_0021( PS_LCB_ENTRY ,              */
+/*                      :                      PS_CloseLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannel p_CloseLogicalChannel  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career ()  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void BLC::_0308_0021(LCEntry *p_LcbEntry , PS_CloseLogicalChannel p_CloseLogicalChannel)
+{
+    S_OlcRejectCause   cause ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    uint32 reverseLcn = p_LcbEntry->RvsLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    cause.index = 0 ;  /* unspecified */
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+    MsgCloseAckSend((uint16) forwardLcn) ;
+    PtvRlsIdcSend(forwardLcn, &p_CloseLogicalChannel->source , &cause, S_InfHeader::INCOMING, reverseLcn) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/clc.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/clc.cpp
new file mode 100644
index 0000000..16ed3fc
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/clc.cpp
@@ -0,0 +1,501 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seclc.c                                           */
+/*  file contents   : Close Logical Channel                             */
+/*                  :                      Signalling Entity Management */
+/*  draw            : '96.11.19                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "h245inf.h"
+#include    "semsgque.h"
+#include	"clc.h"
+#include	"lcentry.h"
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0400_0000                              */
+/*  function outline    : Event     CLOSE.request                       */
+/*                      : Status    Outgoing Idle                       */
+/*  function discription: void Se_Clc_0400_0000( )                      */
+/*  input data          : int32 Lcn                                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career ()  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0400_0000(LCEntry *pLcbEntry)
+{
+    pLcbEntry->ClcStatusWrite(CLS_OUTGOING_AWTING_RPS) ;
+    MsgCloseSend(pLcbEntry) ;
+    T108TimerStart(pLcbEntry) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0401_0001                              */
+/*  function outline    : Event     RequestChannelClose                 */
+/*                      : Status    Incoming Idle                       */
+/*  function discription: void Se_Clc_0401_0001()  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0401_0001(LCEntry *pLcbEntry)
+{
+    pLcbEntry->ClcStatusWrite(CLS_INCOMING_AWTING_RPS) ;
+    PtvCloseIdcSend(pLcbEntry) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0401_0011                              */
+/*  function outline    : Event     RequestChannelClose                 */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Clc_0401_0011( )  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0401_0011(LCEntry *pLcbEntry)
+{
+    S_RccRejectCause    cause;
+
+    cause.index = 0 ;  /* unspecified */
+    PtvRjtIdcSend(pLcbEntry, Src_USER , &cause) ;
+    PtvCloseIdcSend(pLcbEntry) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Clc_0402_0011                              */
+/*  function outline    : Event     CLOSE.response                      */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Clc_0402_0011( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0402_0011(LCEntry *pLcbEntry)
+{
+    pLcbEntry->ClcStatusWrite(CLS_INCOMING_IDLE) ;
+    MsgCloseAckSend(pLcbEntry) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0403_0011                              */
+/*  function outline    : Event     REJECT.request                      */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Clc_0403_0011( PS_RccRejectCause )         */
+/*  input data          : PS_RccRejectCause pCause_Clc                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0403_0011(LCEntry *pLcbEntry, PS_RccRejectCause pCause)
+{
+    pLcbEntry->ClcStatusWrite(CLS_INCOMING_IDLE) ;
+    MsgCloseRjtSend(pLcbEntry, pCause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0404_0010                              */
+/*  function outline    : Event     RequestChannelCloseAck              */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Clc_0404_0010( ) */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0404_0010(LCEntry *pLcbEntry)
+{
+    T108TimerStop(pLcbEntry) ;
+    pLcbEntry->ClcStatusWrite(CLS_OUTGOING_IDLE) ;
+    PtvCloseCfmSend(pLcbEntry) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0405_0010                              */
+/*  function outline    : Event     RequestChannelCloseReject           */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Clc_0405_0010                         */
+/*                      :              ( PS_RequestChannelCloseReject ) */
+/*  input data          : PS_RequestChannelCloseReject                  */
+/*                                          pRequestChannelCloseReject  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0405_0010(LCEntry *pLcbEntry, PS_RequestChannelCloseReject pRequestChannelCloseReject)
+{
+    T108TimerStop(pLcbEntry) ;
+    pLcbEntry->ClcStatusWrite(CLS_OUTGOING_IDLE) ;
+    PtvRjtIdcSend(pLcbEntry, Src_USER, &pRequestChannelCloseReject->rccRejectCause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0406_0010                              */
+/*  function outline    : Event     Timer T108 Timeout                  */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Clc_0406_0010( int32 )                  */
+/*  input data          : int32 Timer_Sequence_Number                     */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0406_0010(LCEntry *pLcbEntry, int32 Timer_Sequence_Number)
+{
+    S_RccRejectCause    cause;
+
+    /* Receive Timer Sequense Number Equal Timer Sequence Number */
+    if (Timer_Sequence_Number == pLcbEntry->ClcTmrSqcNumberRead())
+    {
+        pLcbEntry->ClcStatusWrite(CLS_OUTGOING_IDLE) ;
+        MsgCloseRlsSend(pLcbEntry) ;
+        cause.index = 0 ;  /* unspecified */
+        PtvRjtIdcSend(pLcbEntry, Src_PROTOCOL , &cause) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Clc_0407_0011                              */
+/*  function outline    : Event     RequestChannelCloseRelease          */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Clc_0407_0011( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::_0407_0011(LCEntry *pLcbEntry)
+{
+    S_RccRejectCause    cause;
+
+    cause.index = 0 ;  /* unspecified */
+    pLcbEntry->ClcStatusWrite(CLS_INCOMING_IDLE) ;
+    PtvRjtIdcSend(pLcbEntry, Src_PROTOCOL , &cause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcMsgCloseSend                            */
+/*  function outline    : RequestChannelClose Send                      */
+/*  function discription: void Se_ClcMsgCloseSend( void )               */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::MsgCloseSend(LCEntry *pLcbEntry)
+{
+    S_RequestChannelClose  requestChannelClose ;
+    S_H245Msg              h245Msg ;
+
+    requestChannelClose.forwardLogicalChannelNumber = (uint16) pLcbEntry->FwdLcnRead() ;
+    requestChannelClose.option_of_qosCapability = false;
+    requestChannelClose.option_of_rccReason = false;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_CLC ;
+    h245Msg.pData = (uint8*) & requestChannelClose ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcMsgCloseAckSend                         */
+/*  function outline    : RequestChannelCloseAck Send                   */
+/*  function discription: void Se_ClcMsgCloseAckSend( void )            */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::MsgCloseAckSend(LCEntry *pLcbEntry)
+{
+    S_RequestChannelCloseAck   requestChannelCloseAck ;
+    S_H245Msg                  h245Msg ;
+
+    requestChannelCloseAck.forwardLogicalChannelNumber = (uint16) pLcbEntry->FwdLcnRead() ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_CLC_ACK ;
+    h245Msg.pData = (uint8*) & requestChannelCloseAck ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcMsgCloseRjtSend                         */
+/*  function outline    : RequestChannelCloseReject Send                */
+/*  function discription: void Se_ClcMsgCloseRjtSend( PS_RccRejectCause )  */
+/*  input data          : PS_RccRejectCause pCause_clcse                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::MsgCloseRjtSend(LCEntry *pLcbEntry, PS_RccRejectCause pCause)
+{
+    S_RequestChannelCloseReject    requestChannelCloseReject ;
+    S_H245Msg                      h245Msg ;
+
+    requestChannelCloseReject.forwardLogicalChannelNumber = (uint16) pLcbEntry->FwdLcnRead() ;
+    oscl_memcpy((int8*)&requestChannelCloseReject.rccRejectCause ,
+                (int8*)pCause , sizeof(S_RccRejectCause)) ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_CLC_RJT ;
+    h245Msg.pData = (uint8*) & requestChannelCloseReject ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcMsgCloseRlsSend                         */
+/*  function outline    : RequestChannelCloseRelease Send               */
+/*  function discription: void Se_ClcMsgCloseRlsSend( void )            */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::MsgCloseRlsSend(LCEntry *pLcbEntry)
+{
+    S_RequestChannelCloseRelease   requestChannelCloseRelease ;
+    S_H245Msg                      h245Msg ;
+
+    requestChannelCloseRelease.forwardLogicalChannelNumber = (uint16) pLcbEntry->FwdLcnRead() ;
+
+    h245Msg.Type1 = H245_MSG_IDC ;
+    h245Msg.Type2 = MSGTYP_CLC_RLS ;
+    h245Msg.pData = (uint8*) & requestChannelCloseRelease ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcPtvCloseIdcSend                         */
+/*  function outline    : CLOSE.indicaton Send                          */
+/*  function discription: void Se_ClcPtvCloseIdcSend( void )            */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::PtvCloseIdcSend(LCEntry *pLcbEntry)
+{
+    S_InfHeader         header ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Clc_Cls_Idc ;
+    header.InfSupplement1 = pLcbEntry->FwdLcnRead() ;
+    header.InfSupplement2 = pLcbEntry->DirectionalRead() ;
+    /* (UNI=1, BI=2) */
+    header.pParameter = NULL ;
+    header.Size = 0 ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcPtvRjtIdcSend                           */
+/*  function outline    : REJECT.indication Send                        */
+/*  function discription: void Se_ClcPtvRjtIdcSend( int32,                */
+/*                                                   PS_RccRejectCause )   */
+/*  input data          : int32 Source                                    */
+/*                      : PS_RccRejectCause pCause_clcse                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::PtvRjtIdcSend(LCEntry *pLcbEntry,
+                        int32 Source ,
+                        PS_RccRejectCause pCause)
+{
+    S_InfHeader        header ;
+    S_SourceCause_Clc  sourceCause_Clc ;
+
+    sourceCause_Clc.Source = (ENUM_Source)Source ;
+    oscl_memcpy((int8*)&sourceCause_Clc.Cause , (int8*)pCause , sizeof(S_RccRejectCause)) ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Clc_Rjt_Idc ;
+
+    /* Test for OutgoingIncoming not needed -- RAN */
+    header.InfSupplement1 = pLcbEntry->FwdLcnRead() ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & sourceCause_Clc ;
+    header.Size = sizeof(S_SourceCause_Clc) ;
+
+    PrimitiveSend(&header) ;
+
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcPtvCloseCfmSend                         */
+/*  function outline    : SEND.confirm Send                             */
+/*  function discription: void Se_ClcPtvCloseCfmSend( void )            */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::PtvCloseCfmSend(LCEntry *pLcbEntry)
+{
+    S_InfHeader    header ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Clc_Cls_Cfm ;
+    header.InfSupplement1 = pLcbEntry->FwdLcnRead() ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = NULL ;
+    header.Size = 0 ;
+
+    PrimitiveSend(&header) ;
+
+}
+
+/************************************************************************/
+/*  function name       : Se_ClcT108TimerIdGet                          */
+/*  function outline    : T108 Timer Id Get                             */
+/*  function discription: Se_ClcT108TimerIdGet( PS_LCB_ENTRY )          */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*  output data         : int32 Timer Id                                  */
+/*  draw time           : '96.11.11                                     */
+/*----------------------------------------------------------------------*/
+/*  (x)                                                                 */
+/*  This routine added for multiple CLCSEs.   RAN                       */
+/************************************************************************/
+int32 CLC::T108TimerIdGet(LCEntry *p_LcbEntry)
+{
+    /* Return T108 Timer Id  */
+    return(((p_LcbEntry->FwdLcnRead()) << 16) | E_TmrId_Clc_T108) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_ClcT108TimerStart                          */
+/*  function outline    : T108 Timer Start                              */
+/*  function discription: void Se_ClcT108TimerStart( void )             */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::T108TimerStart(LCEntry *pLcbEntry)
+{
+    pLcbEntry->ClcTmrSqcNumberInc() ;
+    RequestTimer(T108TimerIdGet(pLcbEntry),
+                 pLcbEntry->ClcTmrSqcNumberRead(),
+                 TimerDuration);
+}
+
+
+/************************************************************************/
+/*  function name       : Se_ClcT108TimerStop                           */
+/*  function outline    : T108 Timer Stop                               */
+/*  function discription: void Se_ClcT108TimerStop( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void CLC::T108TimerStop(LCEntry *pLcbEntry)
+{
+    CancelTimer(T108TimerIdGet(pLcbEntry)) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/lc.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/lc.cpp
new file mode 100644
index 0000000..a3318e6
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/lc.cpp
@@ -0,0 +1,711 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : selc.c                                            */
+/*  file contents   : Uni-Directional Logical Channel Signalling Entity */
+/*                  :                                        Management */
+/*  draw            : '96.11.25                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245inf.h"
+#include "lcentry.h"
+#include "msd.h"
+#include "lc.h"
+
+/************************************************************************/
+/*  function name       : Se_Lc_0200_0000                               */
+/*  function outline    : Event     ESTABLISH.request                   */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Lc_0200_0000( PS_LCB_ENTRY ,               */
+/*                      :                      PS_ForwardReverseParam ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ForwardReverseParam p_ForwardReverseParam  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0200_0000(LCEntry *p_LcbEntry , PS_ForwardReverseParam p_ForwardReverseParam)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_ETBMNT) ;
+    MsgOpenSend((uint16) forwardLcn, p_ForwardReverseParam) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0200_0030                               */
+/*  function outline    : Event     ESTABLISH.request                   */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Lc_0200_0030( PS_LCB_ENTRY ,               */
+/*                      :                      PS_ForwardReverseParam ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ForwardReverseParam p_ForwardReverseParam  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0200_0030(LCEntry *p_LcbEntry , PS_ForwardReverseParam p_ForwardReverseParam)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_ETBMNT) ;
+    MsgOpenSend((uint16) forwardLcn, p_ForwardReverseParam) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0201_0010                               */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Lc_0201_0010( PS_LCB_ENTRY ,               */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0201_0010(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    if (MyMSD->GetStatus() != MSD_MASTER)
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+        T103TimerStop(forwardLcn) ;
+        p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+        PtvEtbIdcSend(forwardLcn , p_OpenLogicalChannel) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0203_0010                               */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Lc_0203_0010( PS_LCB_ENTRY ,               */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0203_0010(LCEntry *p_LcbEntry , PS_OlcRejectCause p_Cause_LcBlc)
+{
+    S_Source    source ;
+
+    OSCL_UNUSED_ARG(p_Cause_LcBlc);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    /* NEW245
+    source.select_of_Source = 0 ;
+    source.user = true ;
+    source.lcse = false ;
+    */
+    source.index = 0;
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_RLS) ;
+    MsgCloseSend((uint16) forwardLcn, &source) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0203_0020                               */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Established                */
+/*  function discription: Se_Lc_0203_0020( PS_LCB_ENTRY ,               */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0203_0020(LCEntry *p_LcbEntry , PS_OlcRejectCause p_Cause_LcBlc)
+{
+    S_Source    source ;
+
+    OSCL_UNUSED_ARG(p_Cause_LcBlc);
+    /* NEW245
+    source.select_of_Source = 0 ;
+    source.user = true ;
+    source.lcse = false ;
+    */
+    source.index = 0;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_AWTING_RLS) ;
+    MsgCloseSend((uint16) forwardLcn, &source) ;
+    T103TimerStart(forwardLcn, p_LcbEntry->TmrSqcNumberInc()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0204_0000                               */
+/*  function outline    : Event     OpenLogicalChannelAck               */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Lc_0204_0000( PS_LCB_ENTRY ,               */
+/*                      :                    PS_OpenLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelAck                      */
+/*                      :                       p_OpenLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0204_0000(LCEntry *p_LcbEntry , PS_OpenLogicalChannelAck p_OpenLogicalChannelAck)
+{
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelAck);
+    PtvErrIdcSend(p_LcbEntry->FwdLcnRead() , ErrCode_Lc_A) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0204_0010                               */
+/*  function outline    : Event     OpenLogicalChannelAck               */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Lc_0204_0010( PS_LCB_ENTRY ,               */
+/*                      :                    PS_OpenLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelAck                      */
+/*                      :                       p_OpenLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0204_0010(LCEntry *p_LcbEntry , PS_OpenLogicalChannelAck p_OpenLogicalChannelAck)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_ETBED) ;
+    PtvEtbCfmSend(forwardLcn, p_OpenLogicalChannelAck) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0206_0000                               */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Lc_0206_0000( PS_LCB_ENTRY ,               */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0206_0000(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelReject);
+    PtvErrIdcSend(p_LcbEntry->FwdLcnRead() , ErrCode_Lc_B) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0206_0010                               */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Lc_0206_0010( PS_LCB_ENTRY ,               */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0206_0010(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    S_Source    source ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+
+    source.index = 0;  /* user */
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvRlsIdcSend(forwardLcn, &source , &p_OpenLogicalChannelReject->olcRejectCause, S_InfHeader::OUTGOING) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0206_0020                               */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Established                */
+/*  function discription: Se_Lc_0206_0020( PS_LCB_ENTRY ,               */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0206_0020(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    S_Source    source ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+
+    PtvErrIdcSend(forwardLcn, ErrCode_Lc_B) ;
+
+    /* NEW245
+    source.select_of_Source = 1 ;
+    source.user = false ;
+    source.lcse = true ;
+    */
+    source.index = 1;
+
+    PtvRlsIdcSend(forwardLcn, &source , &p_OpenLogicalChannelReject->olcRejectCause, S_InfHeader::OUTGOING) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0206_0030                               */
+/*  function outline    : Event     OpenLogicalChannelReject            */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Lc_0206_0030( PS_LCB_ENTRY ,               */
+/*                      :                 PS_OpenLogicalChannelReject ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelReject                   */
+/*                      :                    p_OpenLogicalChannelReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0206_0030(LCEntry *p_LcbEntry , PS_OpenLogicalChannelReject p_OpenLogicalChannelReject)
+{
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelReject);
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvRlsCfmSend(forwardLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0207_0010                               */
+/*  function outline    : Event     Timer T103 Timeout                  */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Establishment     */
+/*  function discription: Se_Lc_0207_0010( PS_LCB_ENTRY , int32 )         */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : int32 TmrSqcNumber                              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.11                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0207_0010(LCEntry *p_LcbEntry , int32 TmrSqcNumber)
+{
+    S_Source        source ;
+    S_OlcRejectCause   cause ;
+
+    if (TmrSqcNumber == p_LcbEntry->TmrSqcNumberRead())
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+        p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+        PtvErrIdcSend(forwardLcn, ErrCode_Lc_D) ;
+
+        /* NEW245
+        source.select_of_Source = 1 ;
+        source.user = false ;
+        source.lcse = true ;
+        */
+        source.index = 1;
+
+        MsgCloseSend((uint16) forwardLcn, &source) ;
+
+        cause.index = 0 ;
+        /* NEW245
+        cause.unspecified = true ;
+        cause.unsuitableReverseParameters = false ;
+        cause.dataTypeNotSupported = false ;
+        cause.dataTypeNotAvailable = false ;
+        cause.unknownDataType = false ;
+        cause.dataTypeALCombinationNotSupported = false ;
+        cause.multicastChanneNotAllowed = false ;
+        cause.insufficientBandwidth = false ;
+        cause.separateStackEstablishmentFailed = false ;
+        cause.invalidSessionID = false ;
+        */
+
+        PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::OUTGOING) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0207_0030                               */
+/*  function outline    : Event     Timer T103 Timeout                  */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Lc_0207_0030( PS_LCB_ENTRY , int32 )         */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : int32 TmrSqcNumber                              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.11                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0207_0030(LCEntry *p_LcbEntry , int32 TmrSqcNumber)
+{
+    if (TmrSqcNumber == p_LcbEntry->TmrSqcNumberRead())
+    {
+        uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+        p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+        PtvErrIdcSend(forwardLcn, ErrCode_Lc_D) ;
+        PtvRlsCfmSend(forwardLcn) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0209_0020                               */
+/*  function outline    : Event     CloseLogicalChannelAck              */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Established                */
+/*  function discription: Se_Lc_0209_0020( PS_LCB_ENTRY ,               */
+/*                      :                   PS_CloseLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannelAck                     */
+/*                      :                      p_CloseLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0209_0020(LCEntry *p_LcbEntry , PS_CloseLogicalChannelAck p_CloseLogicalChannelAck)
+{
+    S_Source        source ;
+    S_OlcRejectCause   cause ;
+
+    OSCL_UNUSED_ARG(p_CloseLogicalChannelAck);
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+
+    PtvErrIdcSend(forwardLcn, ErrCode_Lc_C) ;
+
+    /* NEW245
+    source.select_of_Source = 1 ;
+    source.user = false ;
+    source.lcse = true ;
+    */
+    source.index = 1;
+
+    cause.index = 0 ;
+    /* NEW245
+    cause.unspecified = true ;
+    cause.unsuitableReverseParameters = false ;
+    cause.dataTypeNotSupported = false ;
+    cause.dataTypeNotAvailable = false ;
+    cause.unknownDataType = false ;
+    cause.dataTypeALCombinationNotSupported = false ;
+    cause.multicastChanneNotAllowed = false ;
+    cause.insufficientBandwidth = false ;
+    cause.separateStackEstablishmentFailed = false ;
+    cause.invalidSessionID = false ;
+    */
+
+    PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::OUTGOING) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0209_0030                               */
+/*  function outline    : Event     CloseLogicalChannelAck              */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Outgoing Awaiting Release           */
+/*  function discription: Se_Lc_0209_0030( PS_LCB_ENTRY ,               */
+/*                      :                   PS_CloseLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannelAck                     */
+/*                      :                      p_CloseLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0209_0030(LCEntry *p_LcbEntry , PS_CloseLogicalChannelAck p_CloseLogicalChannelAck)
+{
+    OSCL_UNUSED_ARG(p_CloseLogicalChannelAck);
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    T103TimerStop(forwardLcn) ;
+    p_LcbEntry->StatusWrite(LCBLC_OUTGOING_RLSED) ;
+    PtvRlsCfmSend(forwardLcn) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0201_0001                               */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Incoming Released                   */
+/*                      : Status    Outgoing Released                   */
+/*  function discription: Se_Lc_0201_0001( PS_LCB_ENTRY ,               */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0201_0001(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+    PtvEtbIdcSend(forwardLcn, p_OpenLogicalChannel) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0201_0011                               */
+/*  function outline    : Event     OpenLogicalChannel                  */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*                      : Status    Incoming Established                */
+/*  function discription: Se_Lc_0201_0011( PS_LCB_ENTRY ,               */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0201_0011(LCEntry *p_LcbEntry , PS_OpenLogicalChannel p_OpenLogicalChannel)
+{
+    S_Source        source ;
+    S_OlcRejectCause   cause ;
+
+    source.index = 0;  /* User */
+
+    cause.index = 999 ; /* Special cause to indicate received CLC */
+    // Note that the RELEASE.indication generated here is essentially the
+    //   same as if a CLC has been received for the given channel.
+    //   (it's really a new OLC for an existing, established channel, so
+    //    the intent seems to be to close the channel and immediately
+    //    reopen it).
+    // See the notes I made in Se_Lc_0208_0011() for more info.
+    // (This was added 9/29/00, RAN)
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_AWTING_ETBMNT) ;
+    PtvRlsIdcSend(forwardLcn, &source , &cause, S_InfHeader::INCOMING) ;
+    PtvEtbIdcSend(forwardLcn, p_OpenLogicalChannel) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0202_0011                               */
+/*  function outline    : Event     ESTABLISH.response                  */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*  function discription: Se_Lc_0202_0011( PS_LCB_ENTRY ,               */
+/*                      :                              PS_ReverseData ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ReverseData p_ReverseData                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0202_0011(LCEntry *p_LcbEntry , PS_ReverseData p_ReverseData)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_ETBED) ;
+    MsgOpenAckSend((uint16) forwardLcn, p_ReverseData) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0203_0011                               */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*  function discription: Se_Lc_0203_0011( PS_LCB_ENTRY ,               */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0203_0011(LCEntry *p_LcbEntry , PS_OlcRejectCause p_Cause_LcBlc)
+{
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+    MsgOpenRjtSend((uint16) forwardLcn, p_Cause_LcBlc) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0208_0001                               */
+/*  function outline    : Event     CloseLogicalChannel                 */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Incoming Released                   */
+/*  function discription: Se_Lc_0208_0001( PS_LCB_ENTRY ,               */
+/*                      :                      PS_CloseLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannel p_CloseLogicalChannel  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0208_0001(LCEntry *p_LcbEntry , PS_CloseLogicalChannel p_CloseLogicalChannel)
+{
+    OSCL_UNUSED_ARG(p_CloseLogicalChannel);
+    MsgCloseAckSend((uint16) p_LcbEntry->FwdLcnRead()) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Lc_0208_0011                               */
+/*  function outline    : Event     CloseLogicalChannel                 */
+/*                      :                           ( Uni-Directional ) */
+/*                      : Status    Incoming Awaiting Establishment     */
+/*                      : Status    Incoming Established                */
+/*  function discription: Se_Lc_0208_0011( PS_LCB_ENTRY ,               */
+/*                      :                      PS_CloseLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_CloseLogicalChannel p_CloseLogicalChannel  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LC::_0208_0011(LCEntry *p_LcbEntry , PS_CloseLogicalChannel p_CloseLogicalChannel)
+{
+    S_OlcRejectCause   cause ;
+
+    uint32 forwardLcn = p_LcbEntry->FwdLcnRead();
+
+    p_LcbEntry->StatusWrite(LCBLC_INCOMING_RLSED) ;
+
+    MsgCloseAckSend((uint16) forwardLcn) ;
+
+    cause.index = 999 ; /* Special cause to indicate received CLC */
+    // NOTE: I'm putting this in because there's currently no way for
+    //   Tsc to distinguish between the following cases:
+    //   1. Outgoing LCSE: OLCReject received or Timer Expired
+    //   2. Incoming LCSE: CLC received for normal channel closure
+    // We'll require Tsc to intercept this special (illegal) OLCRejectCause
+    //   and take action appropriate for a received CLC.
+    // (This was added 9/29/00, RAN)
+
+    PtvRlsIdcSend(forwardLcn, &p_CloseLogicalChannel->source , &cause, S_InfHeader::INCOMING) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/lcblccmn.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/lcblccmn.cpp
new file mode 100644
index 0000000..286c50e
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/lcblccmn.cpp
@@ -0,0 +1,590 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : selcblccmn.c                                      */
+/*  file contents   : Uni-Directional and Bi-Directional                */
+/*                  :              Logical Channel Signalling Entity    */
+/*                  :                                 Common Management */
+/*  draw            : '96.11.23                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include	"h245pri.h"
+#include	"semsgque.h"
+#include	"lcentry.h"
+#include	"lcblccmn.h"
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcT103TimerIdGet                        */
+/*  function outline    : T103 Timer Id Get                             */
+/*  function discription: Se_LcBlcT103TimerIdGet( PS_LCB_ENTRY )        */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*  output data         : int32 Timer Id                                  */
+/*  draw time           : '96.11.11                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int32 LCBLCCmn::T103TimerIdGet(uint32 forwardLcn)
+{
+    /* Return T103 Timer Id  */
+    return((forwardLcn << 16) | E_TmrId_LcBlc_T103) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcT103TimerStart                        */
+/*  function outline    : T103 Timer Start                              */
+/*  function discription: Se_LcBlcT103TimerStart( PS_LCB_ENTRY )        */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.11                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::T103TimerStart(uint32 forwardLcn, uint32 tmrSqcNumber)
+{
+    RequestTimer(T103TimerIdGet(forwardLcn), tmrSqcNumber, TimerDuration) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcT103TimerStop                         */
+/*  function outline    : T103 Timer Stop                               */
+/*  function discription: Se_LcBlcT103TimerStop( PS_LCB_ENTRY )         */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.11                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::T103TimerStop(uint32 forwardLcn)
+{
+    CancelTimer(T103TimerIdGet(forwardLcn)) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcMsgOpenSend                           */
+/*  function outline    : Open Logical Channel Send                     */
+/*  function discription: Se_LcBlcMsgOpenSend( PS_LCB_ENTRY ,           */
+/*                      :                      PS_ForwardReverseParam ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ForwardReverseParam p_ForwardReverseParam  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::MsgOpenSend(uint16 forwardLcn, PS_ForwardReverseParam p_ForwardReverseParam)
+{
+    S_OpenLogicalChannel   openLogicalChannel ;
+    S_H245Msg              h245Msg ;
+
+    openLogicalChannel.forwardLogicalChannelNumber = forwardLcn;
+    oscl_memcpy((int8*)&openLogicalChannel.forwardLogicalChannelParameters ,
+                (int8*)&p_ForwardReverseParam->forwardLogicalChannelParameters ,
+                sizeof(S_ForwardLogicalChannelParameters)) ;
+
+    openLogicalChannel.option_of_reverseLogicalChannelParameters = p_ForwardReverseParam->option_of_reverseLogicalChannelParameters ;
+    oscl_memcpy((int8*)&openLogicalChannel.reverseLogicalChannelParameters ,
+                (int8*)&p_ForwardReverseParam->reverseLogicalChannelParameters ,
+                sizeof(S_ReverseLogicalChannelParameters)) ;
+
+    openLogicalChannel.option_of_separateStack = false ;
+    oscl_memset((int8*)&openLogicalChannel.separateStack , 0 , sizeof(S_NetworkAccessParameters)) ;
+
+    openLogicalChannel.option_of_encryptionSync = false;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_LCBLC_OP ;
+    h245Msg.pData = (uint8*) & openLogicalChannel ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcMsgOpenAckSend                        */
+/*  function outline    : Open Logical Channel Ack Send                 */
+/*  function discription: Se_LcBlcMsgOpenAckSend( PS_LCB_ENTRY ,        */
+/*                      :                              PS_ReverseData ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_ReverseData p_ReverseData                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::MsgOpenAckSend(uint16 forwardLcn, PS_ReverseData p_ReverseData)
+{
+    S_OpenLogicalChannelAck    openLogicalChannelAck ;
+    S_H245Msg                  h245Msg ;
+
+    // Logical Channel Number
+    openLogicalChannelAck.forwardLogicalChannelNumber = forwardLcn;
+
+    // ReverseLogicalChannelParameters
+    openLogicalChannelAck.option_of_ackReverseLogicalChannelParameters =
+        p_ReverseData->option_of_reverseLogicalChannelParameters ;
+
+    oscl_memcpy((int8*)&openLogicalChannelAck.ackReverseLogicalChannelParameters ,
+                (int8*)&p_ReverseData->reverseLogicalChannelParameters ,
+                sizeof(S_AckReverseLogicalChannelParameters)) ;
+
+    openLogicalChannelAck.option_of_separateStack = false ;
+
+    // SeparateStack is OFF
+    oscl_memset((int8*)&openLogicalChannelAck.separateStack , 0 , sizeof(S_NetworkAccessParameters)) ;
+
+    openLogicalChannelAck.option_of_forwardMultiplexAckParameters =
+        p_ReverseData->option_of_forwardMultiplexAckParameters ;
+    oscl_memcpy((int8*)&openLogicalChannelAck.forwardMultiplexAckParameters ,
+                (int8*)&p_ReverseData->forwardMultiplexAckParameters ,
+                sizeof(S_ForwardMultiplexAckParameters)) ;
+
+    // EncryptionSync is OFF
+    openLogicalChannelAck.option_of_encryptionSync = false;	/* IMP20 */
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_LCBLC_OP_ACK ;
+    h245Msg.pData = (uint8*) & openLogicalChannelAck ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcMsgOpenCfmSend                        */
+/*  function outline    : Open Logical Channel Confirm Send             */
+/*                      :                       ( Bi-Directional Only ) */
+/*  function discription: Se_LcBlcMsgOpenCfmSend( PS_LCB_ENTRY ,        */
+/*                      :                    PS_OpenLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelAck                      */
+/*                      :                       p_OpenLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::MsgOpenCfmSend(uint16 forwardLcn, PS_OpenLogicalChannelAck p_OpenLogicalChannelAck)
+{
+    S_OpenLogicalChannelConfirm    openLogicalChannelConfirm ;
+    S_H245Msg                      h245Msg ;
+
+    OSCL_UNUSED_ARG(p_OpenLogicalChannelAck);
+
+    openLogicalChannelConfirm.forwardLogicalChannelNumber = forwardLcn;
+
+    h245Msg.Type1 = H245_MSG_IDC ;
+    h245Msg.Type2 = MSGTYP_LCBLC_OP_CFM ;
+    h245Msg.pData = (uint8*) & openLogicalChannelConfirm ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcMsgOpenRjtSend                        */
+/*  function outline    : Open Logical Channel Reject Send              */
+/*  function discription: Se_LcBlcMsgOpenRjtSend( PS_LCB_ENTRY ,        */
+/*                      :                              PS_Cause_LcBlc ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Cause_LcBlc p_Cause_LcBlc                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::MsgOpenRjtSend(uint16 forwardLcn, PS_OlcRejectCause p_Cause)
+{
+    S_OpenLogicalChannelReject openLogicalChannelReject ;
+    S_H245Msg                  h245Msg ;
+
+    openLogicalChannelReject.forwardLogicalChannelNumber = forwardLcn;
+    oscl_memcpy((int8*)&openLogicalChannelReject.olcRejectCause ,
+                (int8*)p_Cause ,
+                sizeof(S_OlcRejectCause)) ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_LCBLC_OP_RJT ;
+    h245Msg.pData = (uint8*) & openLogicalChannelReject ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcMsgCloseSend                          */
+/*  function outline    : Close Logical Channel Send                    */
+/*  function discription: Se_LcBlcMsgCloseSend( PS_LCB_ENTRY ,          */
+/*                      :                                   PS_Source ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Source p_Source                            */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::MsgCloseSend(uint16 forwardLcn, PS_Source p_Source)
+{
+    S_CloseLogicalChannel  closeLogicalChannel ;
+    S_H245Msg              h245Msg ;
+
+    closeLogicalChannel.forwardLogicalChannelNumber = forwardLcn;
+    oscl_memcpy((int8*)&closeLogicalChannel.source , (int8*)p_Source , sizeof(S_Source)) ;
+    /* IMP20_1 */
+    closeLogicalChannel.option_of_reason = 1;
+    closeLogicalChannel.reason.index = 0;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_LCBLC_CL ;
+    h245Msg.pData = (uint8*) & closeLogicalChannel ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcMsgCloseAckSend                       */
+/*  function outline    : Close Logical Channel Ack Send                */
+/*  function discription: Se_LcBlcMsgCloseAckSend( PS_LCB_ENTRY )       */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::MsgCloseAckSend(uint16 forwardLcn)
+{
+    S_CloseLogicalChannelAck   closeLogicalChannelAck ;
+    S_H245Msg                  h245Msg ;
+
+    closeLogicalChannelAck.forwardLogicalChannelNumber = forwardLcn;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_LCBLC_CL_ACK ;
+    h245Msg.pData = (uint8*) & closeLogicalChannelAck ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcPtvEtbIdcSend                         */
+/*  function outline    : ESTABLISH.indication Send                     */
+/*  function discription: Se_LcBlcPtvEtbIdcSend( PS_LCB_ENTRY ,         */
+/*                      :                       PS_OpenLogicalChannel ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannel p_OpenLogicalChannel    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::PtvEtbIdcSend(uint32 forwardLcn, PS_OpenLogicalChannel p_OpenLogicalChannel, int32 reverseLcn)
+{
+    S_InfHeader                infHeader ;
+    S_ForwardReverseParam      forwardReverseParam ;
+
+    oscl_memcpy((int8*)&forwardReverseParam.forwardLogicalChannelParameters ,
+                (int8*)&p_OpenLogicalChannel->forwardLogicalChannelParameters ,
+                sizeof(S_ForwardLogicalChannelParameters)) ;
+    forwardReverseParam.option_of_reverseLogicalChannelParameters =
+        p_OpenLogicalChannel->option_of_reverseLogicalChannelParameters ;
+    oscl_memcpy((int8*)&forwardReverseParam.reverseLogicalChannelParameters ,
+                (int8*)&p_OpenLogicalChannel->reverseLogicalChannelParameters ,
+                sizeof(S_ReverseLogicalChannelParameters)) ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    if (reverseLcn == -1)  /* Uni-Directional */
+    {
+        infHeader.InfId = E_PtvId_Lc_Etb_Idc ;
+    }
+    else /* Bi-Directional */
+    {
+        infHeader.InfId = E_PtvId_Blc_Etb_Idc ;
+    }
+    infHeader.InfSupplement1 = forwardLcn;
+    infHeader.InfSupplement2 = reverseLcn;
+    infHeader.pParameter = (uint8*) & forwardReverseParam ;
+    infHeader.Size = sizeof(S_ForwardReverseParam) ;
+
+    PrimitiveSend(&infHeader) ;
+
+    return ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcPtvEtbCfmSend                         */
+/*  function outline    : ESTABLISH.confirm Send                        */
+/*  function discription: Se_LcBlcPtvEtbCfmSend( PS_LCB_ENTRY ,         */
+/*                      :                    PS_OpenLogicalChannelAck ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_OpenLogicalChannelAck                      */
+/*                      :                       p_OpenLogicalChannelAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::PtvEtbCfmSend(uint32 forwardLcn, PS_OpenLogicalChannelAck p_OpenLogicalChannelAck, int32 reverseLcn)
+{
+    S_InfHeader    infHeader ;
+    S_ReverseData  reverseData ;
+
+    // ReverseLogicalChannelParameters
+    reverseData.option_of_reverseLogicalChannelParameters =
+        p_OpenLogicalChannelAck->option_of_ackReverseLogicalChannelParameters ;
+    oscl_memcpy((int8*)&reverseData.reverseLogicalChannelParameters ,
+                (int8*)&p_OpenLogicalChannelAck->ackReverseLogicalChannelParameters ,
+                sizeof(S_AckReverseLogicalChannelParameters)) ;
+
+    // ForwardMultiplexAckParameters added to 245 Library on 9/28/00 (RAN)
+    reverseData.option_of_forwardMultiplexAckParameters =
+        p_OpenLogicalChannelAck->option_of_forwardMultiplexAckParameters;
+    oscl_memcpy((int8*)&reverseData.forwardMultiplexAckParameters ,
+                (int8*)&p_OpenLogicalChannelAck->forwardMultiplexAckParameters ,
+                sizeof(S_ForwardMultiplexAckParameters)) ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    if (reverseLcn == -1)  /* Uni-Directional */
+    {
+        infHeader.InfId = E_PtvId_Lc_Etb_Cfm ;
+    }
+    else /* Bi-Directional */
+    {
+        infHeader.InfId = E_PtvId_Blc_Etb_Cfm ;
+    }
+    infHeader.InfSupplement1 = forwardLcn;
+    infHeader.InfSupplement2 = reverseLcn;
+    infHeader.pParameter = (uint8*) & reverseData ;
+    infHeader.Size = sizeof(S_ReverseData) ;
+
+    PrimitiveSend(&infHeader) ;
+
+    return ;
+}
+
+void LCBLCCmn::PtvEtbCfmSend2(uint32 forwardLcn, PS_OpenLogicalChannelAck p_OpenLogicalChannelAck, int32 reverseLcn)
+{
+    S_InfHeader    infHeader ;
+    S_ReverseData  reverseData ;
+
+    // ReverseLogicalChannelParameters
+    reverseData.option_of_reverseLogicalChannelParameters =
+        p_OpenLogicalChannelAck->option_of_ackReverseLogicalChannelParameters ;
+    oscl_memcpy((int8*)&reverseData.reverseLogicalChannelParameters ,
+                (int8*)&p_OpenLogicalChannelAck->ackReverseLogicalChannelParameters ,
+                sizeof(S_AckReverseLogicalChannelParameters)) ;
+
+    // ForwardMultiplexAckParameters added to 245 Library on 9/28/00 (RAN)
+    reverseData.option_of_forwardMultiplexAckParameters =
+        p_OpenLogicalChannelAck->option_of_forwardMultiplexAckParameters ;
+    oscl_memcpy((int8*)&reverseData.forwardMultiplexAckParameters ,
+                (int8*)&p_OpenLogicalChannelAck->forwardMultiplexAckParameters ,
+                sizeof(S_ForwardMultiplexAckParameters)) ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+
+    infHeader.InfId = E_PtvId_Blc_Etb_Cfm2 ;
+
+    infHeader.InfSupplement1 = forwardLcn;
+    infHeader.InfSupplement2 = reverseLcn;
+    infHeader.pParameter = (uint8*) & reverseData ;
+    infHeader.Size = sizeof(S_ReverseData) ;
+
+    PrimitiveSend(&infHeader) ;
+
+    return ;
+}
+
+/************************************************************************/
+/*  function name       : Se_LcBlcPtvRlsIdcSend                         */
+/*  function outline    : RELEASE.indication Send                       */
+/*  function discription: Se_LcBlcPtvRlsIdcSend( PS_LCB_ENTRY ,         */
+/*                      :                  PS_Source , PS_Cause_lcse2 ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : PS_Source p_Source                            */
+/*                      : PS_Cause_lcse2 p_Cause_lcse2                  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::PtvRlsIdcSend(uint32 forwardLcn, PS_Source p_Source , PS_OlcRejectCause p_Cause,
+                             S_InfHeader::TDirection dir, int32 reverseLcn)
+{
+    S_InfHeader            infHeader ;
+    S_SourceCause_LcBlc    sourceCause_LcBlc ;
+
+    if (p_Source->index == 0)	/* Source == User */
+    {
+        sourceCause_LcBlc.Source = Src_USER ;
+    }
+    else						/* Source == LCSE */
+    {
+        if (reverseLcn == -1)  /* Uni-Directional */
+        {
+            sourceCause_LcBlc.Source = Src_LCSE ;
+        }
+        else /* Bi-Directional */
+        {
+            sourceCause_LcBlc.Source = Src_BLCSE ;
+        }
+    }
+    oscl_memcpy((int8*)&sourceCause_LcBlc.Cause , (int8*)p_Cause , sizeof(S_OlcRejectCause)) ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    if (reverseLcn == -1)  /* Uni-Directional */
+    {
+        infHeader.InfId = E_PtvId_Lc_Rls_Idc ;
+    }
+    else /* Bi-Directional */
+    {
+        infHeader.InfId = E_PtvId_Blc_Rls_Idc ;
+    }
+    infHeader.InfSupplement1 = forwardLcn;
+    infHeader.InfSupplement2 = reverseLcn;
+    infHeader.pParameter = (uint8*) & sourceCause_LcBlc ;
+    infHeader.Size = sizeof(S_SourceCause_LcBlc) ;
+    infHeader.Dir = dir;
+
+    PrimitiveSend(&infHeader) ;
+
+    return ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcPtvRlsCfmSend                         */
+/*  function outline    : RELEASE.confirm Send                          */
+/*  function discription: Se_LcBlcPtvRlsCfmSend( PS_LCB_ENTRY )         */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::PtvRlsCfmSend(uint32 forwardLcn, int32 reverseLcn)
+{
+    S_InfHeader    infHeader ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    if (reverseLcn == -1)  /* Uni-Directional */
+    {
+        infHeader.InfId = E_PtvId_Lc_Rls_Cfm ;
+    }
+    else /* Bi-Directional */
+    {
+        infHeader.InfId = E_PtvId_Blc_Rls_Cfm ;
+    }
+    infHeader.InfSupplement1 = forwardLcn;
+    infHeader.InfSupplement2 = reverseLcn;
+    infHeader.pParameter = NULL ;
+    infHeader.Size = 0 ;
+
+    PrimitiveSend(&infHeader) ;
+
+    return ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcBlcPtvErrIdcSend                         */
+/*  function outline    : ERROR.indication Send                         */
+/*  function discription: Se_LcBlcPtvErrIdcSend( PS_LCB_ENTRY ,         */
+/*                      :                                ENUM_ErrCode ) */
+/*  input data          : PS_LCB_ENTRY p_LcbEntry                       */
+/*                      : ENUM_ErrCode ErrCode                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void LCBLCCmn::PtvErrIdcSend(uint32 forwardLcn, ENUM_ErrCode ErrCode, int32 reverseLcn)
+{
+    S_InfHeader    infHeader ;
+    S_ErrCode      errCode ;
+
+    errCode.ErrCode = ErrCode ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    if (reverseLcn == -1)  /* Uni-Directional */
+    {
+        infHeader.InfId = E_PtvId_Lc_Err_Idc ;
+    }
+    else /* Bi-Directional */
+    {
+        infHeader.InfId = E_PtvId_Blc_Err_Idc ;
+    }
+    infHeader.InfSupplement1 = forwardLcn;
+    infHeader.InfSupplement2 = reverseLcn;
+    infHeader.pParameter = (uint8*) & errCode ;
+    infHeader.Size = sizeof(S_ErrCode) ;
+
+    PrimitiveSend(&infHeader) ;
+
+    return ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/ml.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/ml.cpp
new file mode 100644
index 0000000..385998b
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/ml.cpp
@@ -0,0 +1,647 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : seml.c                                            */
+/*  file contents   : Maintenance Loop Signalling Entity Management     */
+/*  draw            : '96.11.19                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245inf.h"
+#include "semsgque.h"
+#include "ml.h"
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0900_0000                               */
+/*  function outline    : Event     LOOP.request                        */
+/*                      : Status    Outgoing Not Looped                 */
+/*  function discription: void Se_Ml_0900_0000( PS_MlRequestType )          */
+/*  input data          : PS_MlRequestType pLoop_Type                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0900_0000(PS_MlRequestType pLoop_Type)
+{
+    StatusWrite(ML_OUTGOING_AWTING_RPS) ;
+    MsgLoopReqSend(pLoop_Type) ;
+    T102TimerStart() ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Ml_0901_0010                               */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Ml_0901_0010( PS_MlRejectCause )           */
+/*  input data          : PS_MlRejectCause pCause_Ml                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0901_0010(PS_MlRejectCause pCause_Ml)
+{
+    OSCL_UNUSED_ARG(pCause_Ml);
+    T102TimerStop() ;
+    StatusWrite(ML_OUTGOING_NOT_LOOPED) ;
+    MsgLoopOffSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0901_0011                               */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Ml_0901_0011( PS_MlRejectCause )           */
+/*  input data          : PS_MlRejectCause pCause_Ml                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0901_0011(PS_MlRejectCause pCause_Ml)
+{
+    StatusWrite(ML_INCOMING_NOT_LOOPED) ;
+    MsgLoopRjtSend(pCause_Ml) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0901_0020                               */
+/*  function outline    : Event     RELEASE.request                     */
+/*                      : Status    Outgoing Looped                     */
+/*  function discription: void Se_Ml_0901_0020( PS_MlRejectCause )           */
+/*  input data          : PS_MlRejectCause pCause_Ml                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0901_0020(PS_MlRejectCause pCause_Ml)
+{
+    OSCL_UNUSED_ARG(pCause_Ml);
+    StatusWrite(ML_OUTGOING_NOT_LOOPED) ;
+    MsgLoopOffSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0902_0001                               */
+/*  function outline    : Event     MaintenanceLoopRequest              */
+/*                      : Status    Incoming Not Looped                 */
+/*  function discription: void Se_Ml_0902_0001(                         */
+/*                                         PS_MaintenanceLoopRequest )  */
+/*  input data          : PS_MaintenanceLoopRequest                     */
+/*                                              pMaintenanceLoopRequest */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0902_0001(PS_MaintenanceLoopRequest pMaintenanceLoopRequest)
+{
+    LoopTypeWrite(&pMaintenanceLoopRequest->mlRequestType) ;
+    StatusWrite(ML_INCOMING_AWTING_RPS) ;
+    PtvLoopIdcSend(pMaintenanceLoopRequest) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0902_0011                               */
+/*  function outline    : Event     MaintenanceLoopRequest              */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Ml_0902_0001(                         */
+/*                                         PS_MaintenanceLoopRequest )  */
+/*  input data          : PS_MaintenanceLoopRequest                     */
+/*                                              pMaintenanceLoopRequest */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0902_0011(PS_MaintenanceLoopRequest pMaintenanceLoopRequest)
+{
+    S_MlRejectCause    cause;
+
+    cause.index = 0 ; /* canNotPerformLoop */
+
+    StatusWrite(ML_INCOMING_AWTING_RPS) ;
+    PtvRlsIdcSend(Src_USER, &cause) ;
+    LoopTypeWrite(&pMaintenanceLoopRequest->mlRequestType) ;
+    PtvLoopIdcSend(pMaintenanceLoopRequest) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0903_0011                               */
+/*  function outline    : Event     LOOP.response                       */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Ml_0903_0011( void )                  */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0903_0011(void)
+{
+    StatusWrite(ML_INCOMING_LOOPED) ;
+    MsgLoopAckSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0904_0010                               */
+/*  function outline    : Event     MaintenanceLoopAck                  */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Ml_0904_0010( PS_MaintenanceLoopAck ) */
+/*  input data          : PS_MaintenanceLoopAck pMaintenanceLoopAck     */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0904_0010(PS_MaintenanceLoopAck pMaintenanceLoopAck)
+{
+    OSCL_UNUSED_ARG(pMaintenanceLoopAck);
+    T102TimerStop() ;
+    StatusWrite(ML_OUTGOING_LOOPED) ;
+    PtvLoopCfmSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0905_0010                               */
+/*  function outline    : Event     MaintenanceLoopReject               */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Ml_0905_0010(                         */
+/*                                         PS_MaintenanceLoopReject )   */
+/*  input data          : PS_MaintenanceLoopReject                      */
+/*                                               pMaintenanceLoopReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0905_0010(PS_MaintenanceLoopReject pMaintenanceLoopReject)
+{
+    T102TimerStop() ;
+    StatusWrite(ML_OUTGOING_NOT_LOOPED) ;
+    PtvRlsIdcSend(Src_USER , &pMaintenanceLoopReject->mlRejectCause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0905_0020                               */
+/*  function outline    : Event     MaintenanceLoopReject               */
+/*                      : Status    Outgoing LOOPED                     */
+/*  function discription: void Se_Ml_0905_0020(                         */
+/*                                         PS_MaintenanceLoopReject )   */
+/*  input data          : PS_MaintenanceLoopReject                      */
+/*                                               pMaintenanceLoopReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0905_0020(PS_MaintenanceLoopReject pMaintenanceLoopReject)
+{
+    StatusWrite(ML_OUTGOING_NOT_LOOPED) ;
+    PtvErrIdcSend(ErrCode_Ml_A) ;
+    PtvRlsIdcSend(Src_MLSE , &pMaintenanceLoopReject->mlRejectCause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0906_0010                               */
+/*  function outline    : Event     Timer T102 Timeout                  */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Ml_0906_0010( int32 )                   */
+/*  input data          : int32 Timer_Sequence_Number                     */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0906_0010(int32 Timer_Sequence_Number)
+{
+    S_MlRejectCause    cause;
+
+    if (Timer_Sequence_Number == TmrSqcNumberRead())    /* Receive Timer Sequense Number Equal Timer Sequence Number */
+    {
+        StatusWrite(ML_OUTGOING_NOT_LOOPED) ;
+        PtvErrIdcSend(ErrCode_Ml_B) ;
+        MsgLoopOffSend() ;
+        cause.index = 0 ;  /* canNotPerformLoop */
+
+        PtvRlsIdcSend(Src_MLSE , &cause) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Ml_0907_0011                               */
+/*  function outline    : Event     MaintenanceLoopOffCommand           */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Ml_0907_0011( void )                  */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::_0907_0011(void)
+{
+    S_MlRejectCause    cause;
+
+    cause.index = 0 ;  /* canNotPerformLoop */
+
+    StatusWrite(ML_INCOMING_NOT_LOOPED) ;
+    PtvRlsIdcSend(Src_USER , &cause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlMsgLoopReqSend                           */
+/*  function outline    : MaintenanceLoopRequest Send                   */
+/*  function discription: void Se_MlMsgLoopReqSend( PS_MlRequestType )      */
+/*  input data          : PS_MlRequestType pLoop_Type                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::MsgLoopReqSend(PS_MlRequestType pLoop_Type)
+{
+    S_MaintenanceLoopRequest   maintenanceLoopRequest ;
+    S_H245Msg                  h245Msg ;
+
+    oscl_memcpy((int8*)&maintenanceLoopRequest.mlRequestType, (int8*)pLoop_Type, sizeof(S_MlRequestType)) ;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_ML_REQ ;
+    h245Msg.pData = (uint8*) & maintenanceLoopRequest ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlMsgLoopAckSend                           */
+/*  function outline    : MaintenanceLoopAck Send                       */
+/*  function discription: void Se_MlMsgLoopAckSend( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::MsgLoopAckSend(void)
+{
+    S_MaintenanceLoopAck   maintenanceLoopAck ;
+    S_H245Msg              h245Msg ;
+
+    PS_MlAckType temp = &(maintenanceLoopAck.mlAckType);
+
+    LoopTypeRead(OSCL_STATIC_CAST(PS_MlRequestType, temp));
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_ML_ACK ;
+    h245Msg.pData = (uint8*) & maintenanceLoopAck ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlMsgLoopRjtSend                           */
+/*  function outline    : MaintenanceLoopReject Send                    */
+/*  function discription: void Se_MlMsgLoopRjtSend( PS_MlRejectCause )       */
+/*  input data          : PS_MlRejectCause pCause                            */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::MsgLoopRjtSend(PS_MlRejectCause pCause)
+{
+    S_MaintenanceLoopReject    maintenanceLoopReject ;
+    S_H245Msg                  h245Msg ;
+    PS_MlRejectType temp = &(maintenanceLoopReject.mlRejectType);
+
+    LoopTypeRead(OSCL_STATIC_CAST(PS_MlRequestType, temp));
+    oscl_memcpy((int8*)&maintenanceLoopReject.mlRejectCause , (int8*)pCause , sizeof(S_MlRejectCause)) ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_ML_RJT ;
+    h245Msg.pData = (uint8*) & maintenanceLoopReject ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlMsgLoopOffSend                           */
+/*  function outline    : MaintenanceLoopOff Send                       */
+/*  function discription: void Se_MlMsgLoopOffSend( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::MsgLoopOffSend(void)
+{
+    S_MaintenanceLoopOffCommand    maintenanceLoopOffCommand ;
+    S_H245Msg                      h245Msg ;
+
+    oscl_memset(&maintenanceLoopOffCommand, 0, sizeof(S_MaintenanceLoopOffCommand)) ;
+
+    h245Msg.Type1 = H245_MSG_CMD ;
+    h245Msg.Type2 = MSGTYP_ML_OFF_CMD ;
+    h245Msg.pData = (uint8*) & maintenanceLoopOffCommand ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlPtvLoopIdcSend                           */
+/*  function outline    : LOOP.indicaton Send                           */
+/*  function discription: void Se_MlPtvLoopIdcSend(                     */
+/*                                       PS_MaintenanceLoopRequest )    */
+/*  input data          : PS_MaintenanceLoopRequest                     */
+/*                                              pMaintenanceLoopRequest */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::PtvLoopIdcSend(PS_MaintenanceLoopRequest pMaintenanceLoopRequest)
+{
+    S_InfHeader         header ;
+    S_MlRequestType     loop_Type ;
+
+    oscl_memcpy((int8*)&loop_Type, (int8*)&pMaintenanceLoopRequest->mlRequestType, sizeof(S_MlRequestType)) ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Ml_Loop_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & loop_Type ;
+    header.Size = sizeof(S_MlRequestType) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlPtvRlsIdcSend                            */
+/*  function outline    : RELEASE.indication Send                       */
+/*  function discription: void Se_MlPtvRlsIdcSend( int32, PS_Cause_mlse ) */
+/*  input data          : int32 Source                                    */
+/*                      : PS_Cause_mlse pCause                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::PtvRlsIdcSend(int32 Source , PS_MlRejectCause pCause)
+{
+    S_InfHeader        header ;
+    S_SourceCause_Ml   sourceCause_Ml ;
+
+    sourceCause_Ml.Source = (ENUM_Source)Source ;
+    oscl_memcpy((int8*)&sourceCause_Ml.Cause , (int8*)pCause , sizeof(S_MlRejectCause)) ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Ml_Rls_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & sourceCause_Ml ;
+    header.Size = sizeof(S_SourceCause_Ml) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlPtvLoopCfmSend                           */
+/*  function outline    : LOOP.confirm Send                             */
+/*  function discription: void Se_MlPtvLoopCfmSend( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::PtvLoopCfmSend(void)
+{
+    S_InfHeader    header ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Ml_Loop_Cfm ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = NULL ;
+    header.Size = 0 ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_LcPtvErrIdcSend                            */
+/*  function outline    : ERROR.indication Send ( Uni-Directional )     */
+/*  function discription: Se_LcPtvErrIdcSend( PS_LCB_ENTRY ,            */
+/*                      :                                ENUM_ErrCode ) */
+/*  input data          : PS_LCB_ENTRY pLcbEntry                        */
+/*                      : ENUM_ErrCode ErrCode                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.01                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                            */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::PtvErrIdcSend(ENUM_ErrCode ErrCode)
+{
+    S_InfHeader    header ;
+    S_ErrCode      errCode ;
+
+    errCode.ErrCode = ErrCode ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Ml_Err_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & errCode ;
+    header.Size = sizeof(S_ErrCode) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+void Show245(uint16 tag, uint16 indent, char* inString);
+
+// =========================================================
+// Se_MlStatusShow()
+//
+// This function displays state transition information for
+// the ML signaling entity.
+// =========================================================
+void ML::StatusShow(uint8 oldStatus, uint8 newStatus)
+{
+    char tempString[80];
+
+    Show245(ANALYZER_SE, 0, "MLSE State Transition:");
+    sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    sprintf(tempString, "    to--> %s", StateLabel(newStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    Show245(ANALYZER_SE, 0, " ");
+}
+
+// ==========================================================
+// Se_MlStateLabel()
+//
+// Returns a pointer to an approprate state label string.
+// ==========================================================
+char* ML::StateLabel(uint8 status)
+{
+    switch (status)
+    {
+        case ML_OUTGOING_NOT_LOOPED:
+            return("Outgoing NOT LOOPED");
+            break;
+        case ML_OUTGOING_AWTING_RPS:
+            return("Outgoing AWAITING RESPONSE");
+            break;
+        case ML_OUTGOING_LOOPED:
+            return("Outgoing LOOPED");
+            break;
+        case ML_INCOMING_NOT_LOOPED:
+            return("Incoming NOT LOOPED");
+            break;
+        case ML_INCOMING_AWTING_RPS:
+            return("Incoming AWAITING RESPONSE");
+            break;
+        case ML_INCOMING_LOOPED:
+            return("Incoming LOOPED");
+            break;
+        default:
+            return("UNKNOWN STATE");
+    }
+}
+#endif            /* --------------------------------- */
+
+/************************************************************************/
+/*  function name       : Se_MlT102TimerStart                           */
+/*  function outline    : T102 Timer Start                              */
+/*  function discription: void Se_MlT102TimerStart( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::T102TimerStart(void)
+{
+    TmrSqcNumberInc() ;
+    RequestTimer(E_TmrId_Ml_T102 , TmrSqcNumberRead() ,
+                 TimerDuration) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MlT102TimerStop                            */
+/*  function outline    : T102 Timer Stop                               */
+/*  function discription: void Se_MlT102TimerStop( void )               */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void ML::T102TimerStop(void)
+{
+    CancelTimer(E_TmrId_Ml_T102) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/mr.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/mr.cpp
new file mode 100644
index 0000000..4bd7aca
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/mr.cpp
@@ -0,0 +1,563 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : semr.c                                            */
+/*  file contents   : Mode Request Signalling Entity Management         */
+/*  draw            : '96.11.15                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245inf.h"
+#include "semsgque.h"
+#include "mr.h"
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0700_0000                               */
+/*  function outline    : Event     TRANSFER.request                    */
+/*                      : Status    Outgoing Idle                       */
+/*  function discription: Se_Mr_0700_0000( PS_RequestMode )        */
+/*  input data          : PS_RequestMode pModeElementParam         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0700_0000(PS_RequestMode pModeElementParam)
+{
+    OutSqcInc() ;
+    StatusWrite(MR_OUTGOING_AWTING_RPS) ;
+    MsgRequestSend(pModeElementParam) ;
+    T109TimerStart() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0700_0010                               */
+/*  function outline    : Event     TRANSFER.request                    */
+/*                      : Status    Outgoing Idle                       */
+/*  function discription: Se_Mr_0700_0010( PS_RequestMode )        */
+/*  input data          : PS_RequestMode pModeElementParam         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0700_0010(PS_RequestMode pModeElementParam)
+{
+    T109TimerStop() ;
+    OutSqcInc() ;
+    StatusWrite(MR_OUTGOING_AWTING_RPS) ;
+    MsgRequestSend(pModeElementParam) ;
+    T109TimerStart() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0701_0001                               */
+/*  function outline    : Event     RequestMode                         */
+/*                      : Status    Incoming Idle                       */
+/*  function discription: Se_Mr_0701_0001( PS_RequestMode )             */
+/*  input data          : PS_RequestMode pRequestMode                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0701_0001(PS_RequestMode pRequestMode)
+{
+    InSqcWrite(pRequestMode->sequenceNumber) ;
+    StatusWrite(MR_INCOMING_AWTING_RPS) ;
+    PtvTrnsIndSend(pRequestMode) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0701_0011                               */
+/*  function outline    : Event     RequestMode                         */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mr_0701_0011( PS_RequestMode )             */
+/*  input data          : PS_RequestMode pRequestMode                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0701_0011(PS_RequestMode pRequestMode)
+{
+    S_RmRejectCause    cause;
+
+    InSqcWrite(pRequestMode->sequenceNumber) ;
+    cause.index = 0 ;  /* modeUnavailable */
+    PtvRjtIndSend(Src_USER , &cause) ;
+    PtvTrnsIndSend(pRequestMode) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0702_0011                               */
+/*  function outline    : Event     TRANSFER.response                   */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mr_0702_0011( PS_Response pModePref )      */
+/*  input data          : PS_Response pModePref                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0702_0011(PS_Response pModePref)
+{
+    StatusWrite(MR_INCOMING_IDLE) ;
+    MsgAckSend(pModePref) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0703_0011                               */
+/*  function outline    : Event     REJECT.request                      */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mr_0703_0011( PS_RmRejectCause )                */
+/*  input data          : PS_RmRejectCause pCause_Mr                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0703_0011(PS_RmRejectCause pCause)
+{
+    StatusWrite(MR_INCOMING_IDLE) ;
+    MsgRjtSend(pCause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0704_0010                               */
+/*  function outline    : Event     RequestModeAck                      */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: Se_Mr_0704_0010( PS_RequestModeAck )          */
+/*  input data          : PS_RequestModeAck pRequestModeAck             */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0704_0010(PS_RequestModeAck pRequestModeAck)
+{
+    if (pRequestModeAck->sequenceNumber == OutSqcRead())    /* Receive Sequence Number Equal Outgoing Sequence Number */
+    {
+        T109TimerStop() ;
+        StatusWrite(MR_OUTGOING_IDLE) ;
+        PtvTrnsCfmSend(pRequestModeAck) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0705_0010                               */
+/*  function outline    : Event     RequestModeReject                   */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: Se_Mr_0705_0010                               */
+/*                      :            ( PS_RequestModeReject )           */
+/*  input data          : PS_RequestModeReject pRequestModeReject       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0705_0010(PS_RequestModeReject pRequestModeReject)
+{
+    if (pRequestModeReject->sequenceNumber == OutSqcRead())    /* Receive Sequence Number Equal Outgoing Sequence Number */
+    {
+        T109TimerStop() ;
+        StatusWrite(MR_OUTGOING_IDLE) ;
+        PtvRjtIndSend(Src_USER , &pRequestModeReject->rmRejectCause) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0706_0010                               */
+/*  function outline    : Event     Timer T109 Timeout                  */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: Se_Mr_0706_0010( int32 )                        */
+/*  input data          : int32 Timer_Sequence_Number                     */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0706_0010(int32 Timer_Sequence_Number)
+{
+    S_RmRejectCause    cause;
+
+    if (Timer_Sequence_Number == TmrSqcNumberRead())    /* Receive Timer Sequense Number Equal Timer Sequence Number */
+    {
+        StatusWrite(MR_OUTGOING_IDLE) ;
+        MsgRlsSend() ;
+        cause.index = 0 ; /* modeUnavailable */
+        PtvRjtIndSend(Src_PROTOCOL , &cause) ;
+    }
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mr_0707_0011                               */
+/*  function outline    : Event     RequestModeRelease                  */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mr_0707_0011( void )                       */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::_0707_0011(void)
+{
+    S_RmRejectCause    cause;
+
+    cause.index = 0 ;  /* modeUnavailable */
+    StatusWrite(MR_INCOMING_IDLE) ;
+    PtvRjtIndSend(Src_PROTOCOL , &cause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MrMsgRequestSend                           */
+/*  function outline    : RequestMode Send                              */
+/*  function discription: void Se_MrMsgRequestSend(                     */
+/*                                                PS_RequestMode ) */
+/*  input data          : PS_RequestMode pModeElementParam         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::MsgRequestSend(PS_RequestMode pModeElementParam)
+{
+    S_RequestMode    requestMode ;
+    S_H245Msg        h245Msg ;
+
+    requestMode.sequenceNumber = (uint8) OutSqcRead() ;
+    requestMode.size_of_requestedModes = pModeElementParam->size_of_requestedModes ;
+    requestMode.requestedModes = pModeElementParam->requestedModes ;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_MR ;
+    h245Msg.pData = (uint8*) & requestMode ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MrMsgAckSend                               */
+/*  function outline    : RequestModeAck Send                           */
+/*  function discription: void Se_MrMsgAckSend( PS_Response )           */
+/*  input data          : PS_Response pModePref                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::MsgAckSend(PS_Response pModePref)
+{
+    S_RequestModeAck requestModeAck ;
+    S_H245Msg        h245Msg ;
+
+    requestModeAck.sequenceNumber = (uint8) InSqcRead() ;
+    oscl_memcpy(&requestModeAck.response, pModePref, sizeof(S_Response)) ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_MR_ACK ;
+    h245Msg.pData = (uint8*) & requestModeAck ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MrMsgRjtSend                               */
+/*  function outline    : RequestModeReject Send                        */
+/*  function discription: Se_MrMsgRjtSend( PS_RmRejectCause )                */
+/*  input data          : PS_RmRejectCause pCause                            */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::MsgRjtSend(PS_RmRejectCause pCause)
+{
+    S_RequestModeReject        requestModeReject ;
+    S_H245Msg                  h245Msg ;
+
+    requestModeReject.sequenceNumber = (uint8) InSqcRead() ;
+    oscl_memcpy((int8*)&requestModeReject.rmRejectCause , (int8*)pCause , sizeof(S_RmRejectCause)) ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_MR_RJT ;
+    h245Msg.pData = (uint8*) & requestModeReject ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : MsgRlsSend                               */
+/*  function outline    : RequestModeRelease Send                       */
+/*  function discription: Se_MrMsgRlsSend( void )                       */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::MsgRlsSend(void)
+{
+    S_RequestModeRelease requestModeRelease ;
+    S_H245Msg            h245Msg ;
+
+    oscl_memset((int8*)&requestModeRelease  , 0 , sizeof(S_RequestModeRelease)) ;
+
+    h245Msg.Type1 = H245_MSG_IDC ;
+    h245Msg.Type2 = MSGTYP_MR_RLS ;
+    h245Msg.pData = (uint8*) & requestModeRelease ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : PtvTrnsIndSend                           */
+/*  function outline    : TRANSFER.indicaton Send                       */
+/*  function discription: Se_MrPtvTrnsIndSend( PS_RequestMode )         */
+/*  input data          : PS_RequestMode pRequestMode                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::PtvTrnsIndSend(PS_RequestMode pRequestMode)
+{
+    S_InfHeader    header ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Mr_Trf_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*)pRequestMode ;
+    header.Size = sizeof(S_RequestMode) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MrPtvRjtIndSend                            */
+/*  function outline    : REJECT.indication Send                        */
+/*  function discription: Se_MrPtvRjtIndSend( int32 , PS_RmRejectCause )     */
+/*  input data          : int32 Source                                    */
+/*                      : PS_RmRejectCause pCause                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::PtvRjtIndSend(int32 Source , PS_RmRejectCause pCause)
+{
+    S_InfHeader        header ;
+    S_SourceCause_Mr   sourceCause_Mr ;
+
+    sourceCause_Mr.Source = (ENUM_Source)Source ;
+    oscl_memcpy((int8*)&sourceCause_Mr.Cause , (int8*)pCause , sizeof(S_RmRejectCause)) ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Mr_Rjt_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & sourceCause_Mr ;
+    header.Size = sizeof(S_SourceCause_Mr) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MrPtvTrnsCfmSend                           */
+/*  function outline    : TRANSFER.confirm Send                         */
+/*  function discription: Se_MrPtvTrnsCfmSend( PS_RequestModeAck )      */
+/*  input data          : PS_RequestModeAck pRequestModeAck             */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::PtvTrnsCfmSend(PS_RequestModeAck pRequestModeAck)
+{
+    S_InfHeader    header ;
+    S_Response     modePref ;
+
+    oscl_memcpy((int8*)&modePref , (int8*)&pRequestModeAck->response , sizeof(S_Response)) ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Mr_Trf_Cfm ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & modePref ;
+    header.Size = sizeof(S_Response) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+void Show245(uint16 tag, uint16 indent, char* inString);
+
+// =========================================================
+// Se_MrStatusShow()
+//
+// This function displays state transition information for
+// the MR signaling entity.
+// =========================================================
+void MR::StatusShow(uint8 oldStatus, uint8 newStatus)
+{
+    char tempString[80];
+
+    Show245(ANALYZER_SE, 0, "MRSE State Transition:");
+    sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    sprintf(tempString, "    to--> %s", StateLabel(newStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    Show245(ANALYZER_SE, 0, " ");
+}
+
+// ==========================================================
+// Se_MrStateLabel()
+//
+// Returns a pointer to an approprate state label string.
+// ==========================================================
+char* MR::StateLabel(uint8 status)
+{
+    switch (status)
+    {
+        case MR_OUTGOING_IDLE:
+            return("Outgoing IDLE");
+            break;
+        case MR_OUTGOING_AWTING_RPS:
+            return("Outgoing AWAITING RESPONSE");
+            break;
+        case MR_INCOMING_IDLE:
+            return("Incoming IDLE");
+            break;
+        case MR_INCOMING_AWTING_RPS:
+            return("Incoming AWAITING RESPONSE");
+            break;
+        default:
+            return("UNKNOWN STATE");
+    }
+}
+#endif            /* --------------------------------- */
+
+
+/************************************************************************/
+/*  function name       : Se_MrT109TimerStart                           */
+/*  function outline    : T109 Timer Start                              */
+/*  function discription: void Se_MrT109TimerStart( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::T109TimerStart(void)
+{
+    TmrSqcNumberInc() ;
+    RequestTimer(E_TmrId_Mr_T109 , TmrSqcNumberRead() ,
+                 TimerDuration) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MrT109TimerStop                            */
+/*  function outline    : T109 Timer Stop                               */
+/*  function discription: void Se_MrT109TimerStop( void )               */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MR::T109TimerStop(void)
+{
+    CancelTimer(E_TmrId_Mr_T109) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/mt.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/mt.cpp
new file mode 100644
index 0000000..d27a497
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/mt.cpp
@@ -0,0 +1,652 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : semt.c                                            */
+/*  file contents   : Multiplex Table Signalling Entity Management      */
+/*  draw            : '96.11.15                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245inf.h"
+#include "semsgque.h"
+#include "mt.h"
+
+
+MultiplexEntrySendMgr::MultiplexEntrySendMgr(int32 sn, MultiplexEntrySendUtility* util)
+{
+    iSn = sn;
+    iUtil = util;
+}
+
+void MultiplexEntrySendMgr::Write(PS_MultiplexEntryDescriptor descriptors, int32 size)
+{
+    iOutMTEntries.Write(descriptors, size);
+}
+
+void MultiplexEntrySendMgr::TransferRequest(PS_MuxDescriptor p_MuxDescriptor)
+{
+    iOutMTEntries.Clear();
+    iOutMTEntries.Write(p_MuxDescriptor->multiplexEntryDescriptors ,
+                        p_MuxDescriptor->size_of_multiplexEntryDescriptors);
+    StatusWrite(MT_OUTGOING_AWTING_RPS) ;
+    iUtil->MsgMtSend(p_MuxDescriptor, (uint8)iSn) ;
+    T104TimerStart() ;
+}
+
+void MultiplexEntrySendMgr::MultiplexEntrySendAck(PS_MultiplexEntrySendAck p_MultiplexEntrySendAck)
+{
+    T104TimerStop() ;
+    StatusWrite(MT_OUTGOING_IDLE) ;
+    iUtil->PtvTrfCfmSend(p_MultiplexEntrySendAck->sequenceNumber) ;
+}
+
+void MultiplexEntrySendMgr::MultiplexEntrySendReject(PS_MultiplexEntrySendReject p_MultiplexEntrySendReject)
+{
+    T104TimerStop() ;
+    StatusWrite(MT_OUTGOING_IDLE) ;
+    iUtil->PtvRjtIdcSend(S_InfHeader::OUTGOING, Src_USER ,
+                         &p_MultiplexEntrySendReject->rejectionDescriptions->meRejectCause,
+                         p_MultiplexEntrySendReject->sequenceNumber) ;
+}
+
+void MultiplexEntrySendMgr::T104Timeout()
+{
+//	Print("MultiplexEntrySendMgr::TimeoutOccurred Error: T104 timer timed out for sn(%d)",iSn);
+    StatusWrite(MT_OUTGOING_IDLE) ;
+    iUtil->MsgMtRlsSend(iOutMTEntries) ;
+    iUtil->PtvRjtIdcSend(S_InfHeader::OUTGOING, Src_PROTOCOL , NULL, iSn) ;
+}
+
+void MultiplexEntrySendMgr::StatusWrite(uint32 status)
+{
+    iStatus = status;
+}
+
+void MultiplexEntrySendMgr::T104TimerStart(void)
+{
+    iUtil->RequestT104Timer(iSn);
+}
+
+void MultiplexEntrySendMgr::T104TimerStop(void)
+{
+    iUtil->CancelT104Timer(iSn);
+}
+
+MT::MT() : SEBase(), iTimer("MultiplexTables")
+{
+    Reset();
+    /* Initialize timer */
+    iTimer .SetFrequency(1);
+    iTimer.SetObserver(this);
+}
+
+void MT::Reset()
+{
+    OutSqcClear() ;
+    InSqcClear() ;
+    iTimer.Clear() ;
+    InMTEntries.Clear();
+    StatusWrite(MT_INCOMING_IDLE) ;
+
+    PendingMtSendMap::iterator it = iPendingMtSend.begin();
+    while (it != iPendingMtSend.end())
+    {
+        //OSCL_DELETE((*it++).second);
+        delete(*it++).second;
+    }
+    iPendingMtSend.clear();
+}
+
+void MT::RequestT104Timer(int32 sn)
+{
+    iTimer.Request(sn, sn, T104_TIMER_DURATION, this);
+}
+
+void MT::CancelT104Timer(int32 sn)
+{
+    iTimer.Cancel(sn);
+}
+
+void MT::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    Print("MT::TimeoutOccurred Error: T104 timer timed out for timerID(%d), timeoutInfo(%d)", timerID, timeoutInfo);
+    PendingMtSendMap::iterator iter = iPendingMtSend.find(timerID);
+    if (iter == iPendingMtSend.end())
+    {
+        Print("MT::TimeoutOccurred   Error: Failed to lookup pending MultiplexEntrySend for sequence number %d", timerID);
+        return;
+    }
+    (*iter).second->T104Timeout();
+    OSCL_DELETE((*iter).second);
+    iPendingMtSend.erase(iter);
+}
+
+/************************************************************************/
+/*  function name       : Se_Mt_0500_0000                               */
+/*  function outline    : Event     TRANSFER.request                    */
+/*                      : Status    Outgoing Idle                       */
+/*  function discription: Se_Mt_0500_0000( PS_MuxDescriptor )           */
+/*  input data          : PS_MuxDescriptor p_MuxDescriptor              */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::TransferRequest(PS_MuxDescriptor p_MuxDescriptor)
+{
+    //MultiplexEntrySendMgr* new_mesend_mgr= OSCL_NEW(MultiplexEntrySendMgr , (OutSqcRead(),this));
+    MultiplexEntrySendMgr* new_mesend_mgr = new MultiplexEntrySendMgr(OutSqcRead(), this);
+    iPendingMtSend.insert(PendingMtSendMap::value_type(OutSqcRead(), new_mesend_mgr));
+    new_mesend_mgr->TransferRequest(p_MuxDescriptor);
+    OutSqcInc() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mt_0501_0001                               */
+/*  function outline    : Event     MultiplexEntrySend                  */
+/*                      : Status    Incoming Idle                       */
+/*  function discription: Se_Mt_0501_0001( PS_MultiplexEntrySend )      */
+/*  input data          : PS_MultiplexEntrySend p_MultiplexEntrySend    */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::_0501_0001(PS_MultiplexEntrySend p_MultiplexEntrySend)
+{
+    InSqcWrite(p_MultiplexEntrySend->sequenceNumber) ;
+    // ---------------------------------------------(RAN-MT)---
+    // No need to record incoming InEnum;
+    // The entries will be passed to TSC and returned.
+    //Se_MtInEnumClear(  ) ;
+    //Se_MtInEnumWrite( p_MultiplexEntrySend->multiplexEntryDescriptors,
+    //                  p_MultiplexEntrySend->size_of_multiplexEntryDescriptors ) ;
+    // --------------------------------------------------------
+    StatusWrite(MT_INCOMING_AWTING_RPS) ;
+    PtvTrfIdcSend(p_MultiplexEntrySend) ;
+    /* WWUSGW: 06/22/01 move the following line above the indication send
+    Se_MtStatusWrite( MT_INCOMING_AWTING_RPS ) ;
+    */
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mt_0501_0011                               */
+/*  function outline    : Event     MultiplexEntrySend                  */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mt_0501_0011( PS_MultiplexEntrySend )      */
+/*  input data          : PS_MultiplexEntrySend p_MultiplexEntrySend    */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::_0501_0011(PS_MultiplexEntrySend p_MultiplexEntrySend)
+{
+    InSqcWrite(p_MultiplexEntrySend->sequenceNumber) ;
+    // ---------------------------------------------(RAN-MT)---
+    // No need to record InEnum;
+    // These will be passed to TSC and returned.
+    // REJECT.indication also not sent; Has no effect in our TSC.
+    //S_MeRejectCause    cause;
+    //cause.index = 0 ;  /* unspecifiedCause */
+    //Se_MtPtvRjtIdcSend( Src_USER , &cause ) ;
+    //Se_MtInEnumClear(  ) ;
+    //Se_MtInEnumWrite( p_MultiplexEntrySend->multiplexEntryDescriptors ,
+    //                  p_MultiplexEntrySend->size_of_multiplexEntryDescriptors ) ;
+    // ---------------------------------------------------------
+    PtvTrfIdcSend(p_MultiplexEntrySend) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mt_0502_0011                               */
+/*  function outline    : Event     TRANSFER.response                   */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mt_0502_0011( void )                       */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::_0502_0011(uint32 sequenceNumber, PS_MuxDescriptor pMux)
+{
+    // Return to IDLE only if we have acknowledged the last pending MES (RAN-MT)
+    if (sequenceNumber == (uint32)InSqcRead())
+    {
+        StatusWrite(MT_INCOMING_IDLE) ;
+    }
+
+    MsgMtAckSend(sequenceNumber, pMux) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mt_0503_0011                               */
+/*  function outline    : Event     REJECT.request                      */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mt_0503_0011( PS_Cause_Mt )                */
+/*  input data          : PS_Cause_Mt p_Cause_Mt                        */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career ()  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::_0503_0011(PS_MeRejectCause p_Cause)
+{
+    StatusWrite(MT_INCOMING_IDLE) ;
+    MsgMtRjtSend(p_Cause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mt_0504_0010                               */
+/*  function outline    : Event     MultiplexEntrySendAck               */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: Se_Mt_0504_0010( PS_MultiplexEntrySendAck )   */
+/*  input data          : PS_MultiplexEntrySendAck                      */
+/*                      :                       p_MultiplexEntrySendAck */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::MultiplexEntrySendAck(PS_MultiplexEntrySendAck p_MultiplexEntrySendAck)
+{
+    PendingMtSendMap::iterator iter = iPendingMtSend.find(p_MultiplexEntrySendAck->sequenceNumber);
+    if (iter == iPendingMtSend.end())
+    {
+        Print("MT::MultiplexEntrySendAck  Error: Failed to lookup pending MultiplexEntrySend for sequence number %d", p_MultiplexEntrySendAck->sequenceNumber);
+        return;
+    }
+    (*iter).second->MultiplexEntrySendAck(p_MultiplexEntrySendAck);
+    OSCL_DELETE((*iter).second);
+    iPendingMtSend.erase(iter);
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Mt_0505_0010                               */
+/*  function outline    : Event     MultiplexEntrySendReject            */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: Se_Mt_0505_0010( PS_MultiplexEntrySendReject )*/
+/*  input data          : PS_MultiplexEntrySendReject                   */
+/*                      :                    p_MultiplexEntrySendReject */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::MultiplexEntrySendReject(PS_MultiplexEntrySendReject p_MultiplexEntrySendReject)
+{
+    PendingMtSendMap::iterator iter = iPendingMtSend.find(p_MultiplexEntrySendReject->sequenceNumber);
+    if (iter == iPendingMtSend.end())
+    {
+        Print("MT::MultiplexEntrySendReject  Error: Failed to lookup pending MultiplexEntrySend for sequence number %d", p_MultiplexEntrySendReject->sequenceNumber);
+        return;
+    }
+    (*iter).second->MultiplexEntrySendReject(p_MultiplexEntrySendReject);
+    OSCL_DELETE((*iter).second);
+    iPendingMtSend.erase(iter);
+}
+
+/************************************************************************/
+/*  function name       : Se_Mt_0507_0011                               */
+/*  function outline    : Event     MultiplexEntrySendRelease           */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: Se_Mt_0507_0011( void )                       */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::_0507_0011(void)
+{
+    StatusWrite(MT_INCOMING_IDLE) ;
+    PtvRjtIdcSend(S_InfHeader::OUTGOING, Src_PROTOCOL , NULL, 0) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtMsgMtSend                                */
+/*  function outline    : MultiplexEntrySend Send                       */
+/*  function discription: Se_MtMsgMtSend( PS_MuxDescriptor )            */
+/*  input data          : PS_MuxDescriptor p_MuxDescriptor              */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::MsgMtSend(PS_MuxDescriptor p_MuxDescriptor, uint8 sn)
+{
+    S_MultiplexEntrySend       multiplexEntrySend ;
+    S_H245Msg                  h245Msg ;
+
+    multiplexEntrySend.sequenceNumber = sn ;
+    multiplexEntrySend.size_of_multiplexEntryDescriptors = (uint16) p_MuxDescriptor->size_of_multiplexEntryDescriptors ;
+    multiplexEntrySend.multiplexEntryDescriptors = p_MuxDescriptor->multiplexEntryDescriptors ;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_MT ;
+    h245Msg.pData = (uint8*) & multiplexEntrySend ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtMsgMtAckSend                             */
+/*  function outline    : MultiplexEntrySendAck Send                    */
+/*  function discription: Se_MtMsgMtAckSend( void )                     */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::MsgMtAckSend(uint32 sequenceNumber, PS_MuxDescriptor pMux)
+{
+    S_MultiplexEntrySendAck		multiplexEntrySendAck ;
+    uint32						multiplexTableEntryNumber[15];
+    S_H245Msg					h245Msg ;
+    uint32						i, numEntries;
+
+    numEntries = pMux->size_of_multiplexEntryDescriptors;
+
+    multiplexEntrySendAck.sequenceNumber = (uint8) sequenceNumber;
+    multiplexEntrySendAck.size_of_multiplexTableEntryNumber = (uint16) numEntries;
+
+    // Copy the entry numbers into the MESAck codeword... (RAN-MT)
+    for (i = 0;i < numEntries && i < 15;++i)
+    {
+        multiplexTableEntryNumber[i] = pMux->multiplexEntryDescriptors[i].multiplexTableEntryNumber;
+    }
+    multiplexEntrySendAck.multiplexTableEntryNumber = multiplexTableEntryNumber;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_MT_ACK ;
+    h245Msg.pData = (uint8*) & multiplexEntrySendAck ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtMsgMtRjtSend                             */
+/*  function outline    : MultiplexEntrySendReject Send                 */
+/*  function discription: Se_MtMsgMtRjtSend( PS_Cause_Mt )              */
+/*  input data          : PS_Cause_Mt p_Cause_Mt                        */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::MsgMtRjtSend(PS_MeRejectCause p_Cause)
+{
+    // -----------------------------------------------------(RAN-MT)---
+    // NOTE: This routine needs an update.
+    //       Should probably add arguments for sequenceNumber, entryList
+    //         and used passed-in values in the MESReject codeword.
+    //       (The InEnum array is not written, and should no longer be used)
+    //       See Se_MtMsgMtAckSend() for a model.
+    //       No reason to update it yet, since our terminal never rejects an MT.
+    // -----------------------------------------------------------------
+    S_MultiplexEntrySendReject             multiplexEntrySendReject ;
+    S_MultiplexEntryRejectionDescriptions  multiplexEntryRejectionDescriptions ;
+    S_H245Msg                              h245Msg ;
+
+    multiplexEntrySendReject.sequenceNumber = (uint8) InSqcRead() ;
+
+    multiplexEntryRejectionDescriptions.multiplexTableEntryNumber = (uint8) * (InMTEntries.MuxTableEntriesRead()) ;
+    oscl_memcpy((int8*)&multiplexEntryRejectionDescriptions.meRejectCause , (int8*)&p_Cause , sizeof(S_MeRejectCause)) ;
+    multiplexEntrySendReject.rejectionDescriptions = &multiplexEntryRejectionDescriptions ;
+    multiplexEntrySendReject.size_of_rejectionDescriptions = 1 ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_MT_RJT ;
+    h245Msg.pData = (uint8*) & multiplexEntrySendReject ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtMsgMtRlsSend                             */
+/*  function outline    : MultiplexEntrySendRelease Send                */
+/*  function discription: Se_MtMsgMtRlsSend( void )                     */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::MsgMtRlsSend(MTEntries& entries)
+{
+    S_MultiplexEntrySendRelease    multiplexEntrySendRelease;
+    uint32                         multiplexTableEntryNumber[15];
+    S_H245Msg                      h245Msg;
+
+    multiplexEntrySendRelease.size_of_multiplexTableEntryNumber = (uint16) entries.SizeRead() ;
+
+    oscl_memcpy((int8*)&multiplexTableEntryNumber ,
+                (int8*)entries.MuxTableEntriesRead() ,
+                sizeof(uint32) * entries.SizeRead()) ;
+    multiplexEntrySendRelease.multiplexTableEntryNumber = multiplexTableEntryNumber ;
+
+    h245Msg.Type1 = H245_MSG_IDC ;
+    h245Msg.Type2 = MSGTYP_MT_RLS ;
+    h245Msg.pData = (uint8*) & multiplexEntrySendRelease ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtPtvTrfIdcSend                            */
+/*  function outline    : TRANSFER.indication Send                      */
+/*  function discription: Se_MtPtvTrfIdcSend( PS_MultiplexEntrySend )   */
+/*  input data          : PS_MultiplexEntrySend p_MultiplexEntrySend    */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::PtvTrfIdcSend(PS_MultiplexEntrySend p_MultiplexEntrySend)
+{
+    S_MuxDescriptor    muxDescriptor ;
+    S_InfHeader        infHeader ;
+
+    muxDescriptor.size_of_multiplexEntryDescriptors = p_MultiplexEntrySend->size_of_multiplexEntryDescriptors ;
+    muxDescriptor.multiplexEntryDescriptors = p_MultiplexEntrySend->multiplexEntryDescriptors ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    infHeader.InfId = E_PtvId_Mt_Trf_Idc ;
+    infHeader.InfSupplement1 = p_MultiplexEntrySend->sequenceNumber;
+    infHeader.InfSupplement2 = 0 ;
+    infHeader.pParameter = (uint8*) & muxDescriptor ;
+    infHeader.Size = sizeof(S_MuxDescriptor) ;
+
+    PrimitiveSend(&infHeader) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtPtvRjtIdcSend                            */
+/*  function outline    : REJECT.indication Send                        */
+/*  function discription: Se_MtPtvRjtIdcSend( int32 , PS_Cause_mtse )     */
+/*  input data          : int32 Source                                    */
+/*                      : PS_Cause_mtse p_Cause                         */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.16                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::PtvRjtIdcSend(S_InfHeader::TDirection dir, int32 Source , PS_MeRejectCause p_Cause, int32 sn)
+{
+    S_SourceCause_Mt   sourceCause_Mt ;
+    S_InfHeader        infHeader ;
+
+    if (Source == Src_USER)  /* SOURCE Parameter == USER */
+    {
+        sourceCause_Mt.Source = (ENUM_Source)Source ;
+        oscl_memcpy((int8*)&sourceCause_Mt.Cause , (int8*)p_Cause , sizeof(S_MeRejectCause)) ;
+    }
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    infHeader.InfId = E_PtvId_Mt_Rjt_Idc ;
+    infHeader.InfSupplement1 = dir ;
+    infHeader.InfSupplement2 = sn ;
+    if (Source == Src_USER)  /* SOURCE Parameter Equal USER */
+    {
+        infHeader.pParameter = (uint8*) & sourceCause_Mt ;
+        infHeader.Size = sizeof(S_SourceCause_Mt) ;
+    }
+    else /* SOURCE Parameter Equal PROTOCOL ( The CAUSE parameter is not present ) */
+    {
+        infHeader.pParameter = NULL;
+        infHeader.Size = 0 ;
+    }
+
+    PrimitiveSend(&infHeader) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_MtPtvTrfCfmSend                            */
+/*  function outline    : TRANSFER.confirm Send                         */
+/*  function discription: Se_MtPtvTrfCfmSend( void )                    */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.31                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void MT::PtvTrfCfmSend(int32 sn)
+{
+    S_InfHeader    infHeader ;
+
+    infHeader.InfType = H245_PRIMITIVE ;
+    infHeader.InfId = E_PtvId_Mt_Trf_Cfm ;
+    infHeader.InfSupplement1 = (uint32)sn ;
+    infHeader.InfSupplement2 = 0 ;
+    infHeader.pParameter = NULL ;
+    infHeader.Size = 0 ;
+
+    PrimitiveSend(&infHeader) ;
+}
+
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+void Show245(uint16 tag, uint16 indent, char *inString);
+
+// =========================================================
+// Se_MtStatusShow()
+//
+// This function displays state transition information for
+// the MT signaling entity.
+// =========================================================
+void MT::StatusShow(uint8 oldStatus, uint8 newStatus)
+{
+    char tempString[80];
+
+    Show245(ANALYZER_SE, 0, "MTSE State Transition:");
+    sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    sprintf(tempString, "    to--> %s", StateLabel(newStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    Show245(ANALYZER_SE, 0, " ");
+}
+
+// ==========================================================
+// Se_MtStateLabel()
+//
+// Returns a pointer to an approprate state label string.
+// ==========================================================
+char* MT::StateLabel(uint8 status)
+{
+    switch (status)
+    {
+        case MT_OUTGOING_IDLE:
+            return("Outgoing IDLE");
+            break;
+        case MT_OUTGOING_AWTING_RPS:
+            return("Outgoing AWAITING RESPONSE");
+            break;
+        case MT_INCOMING_IDLE:
+            return("Incoming IDLE");
+            break;
+        case MT_INCOMING_AWTING_RPS:
+            return("Incoming AWAITING RESPONSE");
+            break;
+        default:
+            return("UNKNOWN STATE");
+    }
+}
+#endif            /* --------------------------------- */
+
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/rme.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/rme.cpp
new file mode 100644
index 0000000..9d11530
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/rme.cpp
@@ -0,0 +1,563 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : serme.c                                           */
+/*  file contents   : Request Multiplex Entry                           */
+/*                  :                      Signalling Entity Management */
+/*  draw            : '96.11.26                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "h245inf.h"
+#include "semsgque.h"
+#include "rme.h"
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0600_0000                              */
+/*  function outline    : Event     SEND.request                        */
+/*                      : Status    Outgoing Idle                       */
+/*  function discription: void Se_Rme_0600_0000( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0600_0000(void)
+{
+    StatusWrite(RME_OUTGOING_AWTING_RPS) ;
+    MsgEntrySend() ;
+    T107TimerStart() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0601_0001                              */
+/*  function outline    : Event     RequestMultiplexEntry               */
+/*                      : Status    Incoming Idle                       */
+/*  function discription: void Se_Rme_0601_0001(                        */
+/*                                          PS_RequestMultiplexEntry )  */
+/*  input data          : PS_RequestMultiplexEntry                      */
+/*                                              pRequestMultiplexEntry  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0601_0001(PS_RequestMultiplexEntry pRequestMultiplexEntry)
+{
+    InRMEntries.Write(pRequestMultiplexEntry->size_of_entryNumbers,
+                      pRequestMultiplexEntry->entryNumbers);
+    StatusWrite(RME_INCOMING_AWTING_RPS) ;
+    PtvSendIndSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0601_0011                              */
+/*  function outline    : Event     RequestMultiplexEntry               */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Rme_0601_0011(                        */
+/*                                          PS_RequestMultiplexEntry )  */
+/*  input data          : PS_RequestMultiplexEntry                      */
+/*                                              pRequestMultiplexEntry  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0601_0011(PS_RequestMultiplexEntry pRequestMultiplexEntry)
+{
+    S_RmeRejectCause    cause;
+
+    cause.index = 0 ;  /* unspecifiedCause */
+    PtvRjtIdcSend(Src_USER , &cause) ;
+    InRMEntries.Write(pRequestMultiplexEntry->size_of_entryNumbers,
+                      pRequestMultiplexEntry->entryNumbers);
+
+    PtvSendIndSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0602_0011                              */
+/*  function outline    : Event     SEND.response                       */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Rme_0602_0011( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0602_0011(void)
+{
+    StatusWrite(RME_INCOMING_IDLE) ;
+    MsgEntryAckSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0603_0011                              */
+/*  function outline    : Event     REJECT.request                      */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Rme_0603_0011( PS_RmeRejectCause )         */
+/*  input data          : PS_RmeRejectCause pCause_Rme                       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0603_0011(PS_RmeRejectCause pCause_Rme)
+{
+    StatusWrite(RME_INCOMING_IDLE) ;
+    MsgEntryRjtSend(pCause_Rme) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0604_0010                              */
+/*  function outline    : Event     RequestMultiplexEntryAck            */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Rme_0604_0010(                        */
+/*                                        PS_RequestMultiplexEntryAck ) */
+/*  input data          : PS_RequestMultiplexEntryAck                   */
+/*                                           pRequestMultiplexEntryAck  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0604_0010(PS_RequestMultiplexEntryAck pRequestMultiplexEntryAck)
+{
+    OSCL_UNUSED_ARG(pRequestMultiplexEntryAck);
+    T107TimerStop() ;
+    StatusWrite(RME_OUTGOING_IDLE) ;
+    PtvSendCfmSend() ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0605_0010                              */
+/*  function outline    : Event     RequestMultiplexEntryReject         */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Rme_0605_0010                         */
+/*                      :            ( PS_RequestMultiplexEntryReject ) */
+/*  input data          : PS_RequestMultiplexEntryReject                */
+/*                                        pRequestMultiplexEntryReject  */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0605_0010(PS_RequestMultiplexEntryReject pRequestMultiplexEntryReject)
+{
+    T107TimerStop() ;
+    StatusWrite(RME_OUTGOING_IDLE) ;
+    PtvRjtIdcSend(Src_USER , &pRequestMultiplexEntryReject->rejectionDescriptions->rmeRejectCause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_Rme_0606_0010                              */
+/*  function outline    : Event     Timer T107 Timeout                  */
+/*                      : Status    Outgoing Awaiting Response          */
+/*  function discription: void Se_Rme_0606_0010( int32 )                  */
+/*  input data          : int32 Timer_Sequence_Number                     */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0606_0010(int32 Timer_Sequence_Number)
+{
+    S_RmeRejectCause    cause;
+
+    if (Timer_Sequence_Number == TmrSqcNumberRead())    /* Receive Timer Sequense Number Equal Timer Sequence Number */
+    {
+        StatusWrite(RME_OUTGOING_IDLE) ;
+        MsgEntryRlsSend() ;
+        cause.index = 0 ;  /* unspecifiedCause */
+        PtvRjtIdcSend(Src_PROTOCOL , &cause) ;
+    }
+}
+
+/************************************************************************/
+/*  function name       : Se_Rme_0607_0011                              */
+/*  function outline    : Event     RequestMultiplexEntryRelease        */
+/*                      : Status    Incoming Awaiting Response          */
+/*  function discription: void Se_Rme_0607_0011( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::_0607_0011(PS_RequestMultiplexEntryRelease pRequestMultiplexEntryRelease)
+{
+    S_RmeRejectCause    cause;
+
+    OSCL_UNUSED_ARG(pRequestMultiplexEntryRelease);
+
+    cause.index = 0 ;  /* unspecifiedCause */
+    StatusWrite(RME_INCOMING_IDLE) ;
+    PtvRjtIdcSend(Src_PROTOCOL , &cause) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmeMsgEntrySend                            */
+/*  function outline    : RequestMultiplexEntry Send                    */
+/*  function discription: void Se_RmeMsgEntrySend( void )               */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::MsgEntrySend(void)
+{
+    S_RequestMultiplexEntry		requestMultiplexEntry;
+    uint32						entryNumbers[15];
+    S_H245Msg					h245Msg;
+
+    requestMultiplexEntry.size_of_entryNumbers = (uint16) OutRMEntries.SizeRead();
+    OutRMEntries.EntriesCopy(entryNumbers);
+    requestMultiplexEntry.entryNumbers = entryNumbers;
+
+    h245Msg.Type1 = H245_MSG_REQ ;
+    h245Msg.Type2 = MSGTYP_RME ;
+    h245Msg.pData = (uint8*) & requestMultiplexEntry ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmeMsgEntryAckSend                         */
+/*  function outline    : RequestMultiplexEntryAck Send                 */
+/*  function discription: void Se_RmeMsgEntryAckSend( void )            */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::MsgEntryAckSend(void)
+{
+    S_RequestMultiplexEntryAck	requestMultiplexEntryAck ;
+    uint32						entryNumbers[15];
+    S_H245Msg					h245Msg ;
+
+    requestMultiplexEntryAck.size_of_entryNumbers = (uint16) InRMEntries.SizeRead();
+    InRMEntries.EntriesCopy(entryNumbers);
+    requestMultiplexEntryAck.entryNumbers = entryNumbers;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_RME_ACK ;
+    h245Msg.pData = (uint8*) & requestMultiplexEntryAck ;
+
+    MessageSend(&h245Msg) ;
+
+    return ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmeMsgEntryRjtSend                         */
+/*  function outline    : RequestMultiplexEntryReject Send              */
+/*  function discription: void Se_RmeMsgEntryRjtSend( PS_RmeRejectCause )  */
+/*  input data          : PS_RmeRejectCause pCause_rmese                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::MsgEntryRjtSend(PS_RmeRejectCause pCause_rmese)
+{
+    S_RequestMultiplexEntryReject					requestMultiplexEntryReject ;
+    uint32											entryNumbers[15];
+    S_RequestMultiplexEntryRejectionDescriptions	requestMultiplexEntryRejectionDescriptions ;
+    S_H245Msg										h245Msg ;
+
+    requestMultiplexEntryReject.size_of_entryNumbers = (uint16) InRMEntries.SizeRead();
+    InRMEntries.EntriesCopy(entryNumbers);
+    requestMultiplexEntryReject.entryNumbers = entryNumbers;
+
+    requestMultiplexEntryReject.size_of_rejectionDescriptions = 1 ;
+
+    requestMultiplexEntryRejectionDescriptions.multiplexTableEntryNumber = 1 ;
+    oscl_memcpy((int8*)&requestMultiplexEntryRejectionDescriptions.rmeRejectCause ,
+                (int8*)pCause_rmese, sizeof(S_RmeRejectCause)) ;
+
+    requestMultiplexEntryReject.rejectionDescriptions = &requestMultiplexEntryRejectionDescriptions ;
+
+    h245Msg.Type1 = H245_MSG_RPS ;
+    h245Msg.Type2 = MSGTYP_RME_RJT ;
+    h245Msg.pData = (uint8*) & requestMultiplexEntryReject ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmeMsgEntryRlsSend                         */
+/*  function outline    : RequestMultiplexEntryRelease Send             */
+/*  function discription: void Se_RmeMsgEntryRlsSend( void )            */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::MsgEntryRlsSend(void)
+{
+    S_RequestMultiplexEntryRelease	requestMultiplexEntryRelease;
+    uint32							entryNumbers[15];
+    S_H245Msg						h245Msg;
+
+    requestMultiplexEntryRelease.size_of_entryNumbers = (uint16) OutRMEntries.SizeRead();
+    OutRMEntries.EntriesCopy(entryNumbers);
+    requestMultiplexEntryRelease.entryNumbers = entryNumbers;
+
+    h245Msg.Type1 = H245_MSG_IDC ;
+    h245Msg.Type2 = MSGTYP_RME_RLS ;
+    h245Msg.pData = (uint8*) & requestMultiplexEntryRelease ;
+
+    MessageSend(&h245Msg) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmePtvSendIndSend                          */
+/*  function outline    : SEND.indicaton Send                           */
+/*  function discription: void Se_RmePtvSendIndSend( void )             */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::PtvSendIndSend(void)
+{
+    S_InfHeader         header ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Rme_Send_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = NULL ;
+    header.Size = 0 ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : PtvRjtIdcSend                           */
+/*  function outline    : REJECT.indication Send                        */
+/*  function discription: void PtvRjtIdcSend( int32,                */
+/*                                                   PS_RmeRejectCause )   */
+/*  input data          : int32 Source                                    */
+/*                      : PS_RmeRejectCause pCause_rmese                   */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::PtvRjtIdcSend(int32 Source , PS_RmeRejectCause pCause)
+{
+    S_InfHeader        header ;
+    S_SourceCause_Rme  sourceCause ;
+
+    sourceCause.Source = (ENUM_Source)Source ;
+    oscl_memcpy((int8*)&sourceCause.Cause , (int8*)pCause , sizeof(S_RmeRejectCause)) ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Rme_Rjt_Idc ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = (uint8*) & sourceCause ;
+    header.Size = sizeof(S_SourceCause_Rme) ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmePtvSendCfmSend                          */
+/*  function outline    : SEND.confirm Send                             */
+/*  function discription: void Se_RmePtvSendCfmSend( void )             */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::PtvSendCfmSend(void)
+{
+    S_InfHeader    header ;
+
+    header.InfType = H245_PRIMITIVE ;
+    header.InfId = E_PtvId_Rme_Send_Cfm ;
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    header.pParameter = NULL ;
+    header.Size = 0 ;
+
+    PrimitiveSend(&header) ;
+}
+
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+void Show245(uint16 tag, uint16 indent, char *inString);
+
+// =========================================================
+// Se_RmeStatusShow()
+//
+// This function displays state transition information for
+// the RME signaling entity.
+// =========================================================
+void RME::StatusShow(uint8 oldStatus, uint8 newStatus)
+{
+    char tempString[80];
+
+    Show245(ANALYZER_SE, 0, "RMESE State Transition:");
+    sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    sprintf(tempString, "    to--> %s", StateLabel(newStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    Show245(ANALYZER_SE, 0, " ");
+}
+
+// ==========================================================
+// Se_RmeStateLabel()
+//
+// Returns a pointer to an approprate state label string.
+// ==========================================================
+char* RME::StateLabel(uint8 status)
+{
+    switch (status)
+    {
+        case RME_OUTGOING_IDLE:
+            return("Outgoing IDLE");
+            break;
+        case RME_OUTGOING_AWTING_RPS:
+            return("Outgoing AWAITING RESPONSE");
+            break;
+        case RME_INCOMING_IDLE:
+            return("Incoming IDLE");
+            break;
+        case RME_INCOMING_AWTING_RPS:
+            return("Incoming AWAITING RESPONSE");
+            break;
+        default:
+            return("UNKNOWN STATE");
+    }
+}
+#endif            /* --------------------------------- */
+
+
+
+/************************************************************************/
+/*  function name       : Se_RmeT107TimerStart                          */
+/*  function outline    : T107 Timer Start                              */
+/*  function discription: void Se_RmeT107TimerStart( void )             */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::T107TimerStart(void)
+{
+    TmrSqcNumberInc() ;
+    RequestTimer(E_TmrId_Rme_T107 , TmrSqcNumberRead() ,
+                 TimerDuration) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RmeT107TimerStop                           */
+/*  function outline    : T107 Timer Stop                               */
+/*  function discription: void Se_RmeT107TimerStop( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.19                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career (x)  :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RME::T107TimerStop(void)
+{
+    CancelTimer(E_TmrId_Rme_T107) ;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/rtd.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/rtd.cpp
new file mode 100644
index 0000000..05c21d2
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/rtd.cpp
@@ -0,0 +1,431 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : sertd.c                                           */
+/*  file contents   : Round Trip Deray Signalling Entity Management     */
+/*  draw            : '96.11.13                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include "oscl_base.h"
+#include "oscl_time.h"
+#include "semsgque.h"
+#include "rtd.h"
+
+/************************************************************************/
+/*  function name       : _0800_0000                              */
+/*  function outline    : Event     TRANSFER.request                    */
+/*                      : Status    IDLE                                */
+/*  function discription: void Se_Rtd_0800_0000( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::_0800_0000(void)
+{
+    /* Increment out-sequence number */
+    OutSqcInc() ;
+    /* RoundTripDelayRequest message send */
+    StatusWrite(RTD_AWTING_RPS) ;
+    MsgRequestSend() ;
+    /* Start mesurement of delay time */
+    StartMeasurement() ;
+    /* Start timer for waiting response */
+    T105TimerStart() ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Rtd_0800_0010                              */
+/*  function outline    : Event     TRANSFER.request                    */
+/*                      : Status    AWAITING RESPONSE                   */
+/*  function discription: void Se_Rtd_0800_0010( void )                 */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::_0800_0010(void)
+{
+    /* Stop timer for waiting response */
+    T105TimerStop() ;
+    /* Increment out-sequence number */
+    OutSqcInc() ;
+    /* Update status */
+    StatusWrite(RTD_AWTING_RPS) ;
+    /* RoundTripDelayRequest message send */
+    MsgRequestSend() ;
+    /* Start mesurement of delay time */
+    StartMeasurement() ;
+    /* Start timer for waiting response */
+    T105TimerStart() ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Rtd_0801_0000                              */
+/*  function outline    : Event     RoundTripDelayRequest               */
+/*                      : Status    IDLE or AWAITING RESPONSE           */
+/*  function discription: void Se_Rtd_0801_0000(                        */
+/*                                           PS_RoundTripDelayRequest ) */
+/*  input data          : RoundTripDelayRequest message parameter       */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::_0801_0000(PS_RoundTripDelayRequest pRoundTripDelayRequest)
+{
+    /* RoundTripDelayResponse message send */
+    MsgResponseSend(pRoundTripDelayRequest) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_Rtd_0802_0010                              */
+/*  function outline    : Event     RoundTripDelayResponse              */
+/*                      : Status    AWAITING RESPONSE                   */
+/*  function discription: void Se_Rtd_0802_0010(                        */
+/*                                           PS_RoundTripDelayRequest ) */
+/*  input data          : RoundTripDelayResponse message parameter      */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::_0802_0010(PS_RoundTripDelayResponse pRoundTripDelayResponse)
+{
+    int32 Delay ;
+
+    if (pRoundTripDelayResponse->sequenceNumber == OutSqcRead())    /* Ckeck Sequence number */
+    {
+        /* Stop timer for waiting response */
+        T105TimerStop() ;
+        /* Stop measurement and get delay time */
+        Delay = StopMeasurement() ;
+        /* Update status */
+        StatusWrite(RTD_IDLE) ;
+        /* TRANSFER.confirm send */
+        PtvTrnsCfmSend(Delay) ;
+    }
+}
+
+/************************************************************************/
+/*  function name       : Se_Rtd_0803_0010                              */
+/*  function outline    : Event     T105 Timeout                        */
+/*                      : Status    AWAITING RESPONSE                   */
+/*  function discription: void Se_Rtd_0803_0010( int32 )                  */
+/*  input data          : Timer sequence numeber                        */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::_0803_0010(int32 Param)
+{
+    if (Param == TmrSqcNumberRead())    /* check timer-sequence number */
+    {
+        /* Update status */
+        StatusWrite(RTD_IDLE) ;
+        /* EXPIRY.indication send */
+        PtvExpIndSend() ;
+    }
+}
+
+/************************************************************************/
+/*  function name       : Se_RtdMsgRequestSend                          */
+/*  function outline    : RoundTripDelayRequest message edit & send     */
+/*  function discription: void Se_RtdMsgRequestSend( void )             */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::MsgRequestSend(void)
+{
+    S_RoundTripDelayRequest roundTripDelayRequest ;
+    S_H245Msg               h245Msg ;
+
+    /* Allocate message parameter area and clear it */
+    oscl_memset(&roundTripDelayRequest, 0, sizeof(S_RoundTripDelayRequest)) ;
+    /* Set sequence number */
+    roundTripDelayRequest.sequenceNumber = (uint8) OutSqcRead() ;
+
+    /* Set message type (Request message) */
+    h245Msg.Type1 = H245_MSG_REQ ;
+    /* Set message id (RoundTripDelayRequest) */
+    h245Msg.Type2 = MSGTYP_RTD_REQ ;
+    /* Set parameter address */
+    h245Msg.pData = (uint8*) & roundTripDelayRequest ;
+
+    /* Send message to corder */
+    MessageSend(&h245Msg) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_RtdMsgResponseSend                         */
+/*  function outline    : RoundTripDelayResponse message edit & send    */
+/*  function discription: void Se_RtdMsgResponseSend(                   */
+/*                                           PS_RoundTripDelayRequest ) */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::MsgResponseSend(PS_RoundTripDelayRequest pRoundTripDelayRequest)
+{
+    S_RoundTripDelayResponse roundTripDelayResponse ;
+    S_H245Msg                h245Msg ;
+
+    oscl_memset(&roundTripDelayResponse, 0, sizeof(S_RoundTripDelayResponse)) ;
+    /* Set sequence number */
+    roundTripDelayResponse.sequenceNumber = pRoundTripDelayRequest->sequenceNumber ;
+
+    /* Set message type (Response message) */
+    h245Msg.Type1 = H245_MSG_RPS ;
+    /* Set message id (RoundTripDelayResponse) */
+    h245Msg.Type2 = MSGTYP_RTD_RPS ;
+    /* Set parameter address */
+    h245Msg.pData = (uint8*) & roundTripDelayResponse ;
+
+    /* Send message to corder */
+    MessageSend(&h245Msg) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_RtdPtvTrnsCfmSend                          */
+/*  function outline    : TRANSFER.confirm primitive edit & send        */
+/*  function discription: void Se_RtdPtvTrnsCfmSend( int32 )              */
+/*  input data          : Delay time                                    */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::PtvTrnsCfmSend(int32 Delay)
+{
+    S_InfHeader        header ;
+    S_Delay_Rtd        delay_Rtd ;
+
+    /* Allocate primitive parameter area and clear it */
+    oscl_memset(&delay_Rtd  , 0 , sizeof(S_Delay_Rtd)) ;
+    /* Set delay time */
+    delay_Rtd.Delay_Value = Delay ;
+
+    /* Set information type */
+    header.InfType = H245_PRIMITIVE ;
+    /* Set promitive id */
+    header.InfId = E_PtvId_Rtd_Trf_Cfm ;
+    /* clear supplement */
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    /* Set parameter address */
+    header.pParameter = (uint8*) & delay_Rtd ;
+    /* Set parameter size */
+    header.Size = sizeof(S_Delay_Rtd) ;
+
+    /* Send primitive to tsc */
+    PrimitiveSend(&header) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_RtdPtvExpIndSend                           */
+/*  function outline    : EXPIRY.indication primitive edit & send        */
+/*  function discription: void Se_RtdPtvExpIndSend( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::PtvExpIndSend(void)
+{
+    S_InfHeader        header ;
+
+    /* Set information type */
+    header.InfType = H245_PRIMITIVE ;
+    /* Set promitive id */
+    header.InfId = E_PtvId_Rtd_Exp_Idc ;
+    /* clear supplement */
+    header.InfSupplement1 = 0 ;
+    header.InfSupplement2 = 0 ;
+    /* Clear parameter address */
+    header.pParameter = NULL ;
+    /* Clear parameter size */
+    header.Size = 0 ;
+
+    /* Send primitive to tsc */
+    PrimitiveSend(&header) ;
+}
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+void Show245(uint16 tag, uint16 indent, char* inString);
+
+// =========================================================
+// Se_RtdStatusShow()
+//
+// This function displays state transition information for
+// the RTD signaling entity.
+// =========================================================
+void RTD::StatusShow(uint8 oldStatus, uint8 newStatus)
+{
+    char tempString[80];
+
+    Show245(ANALYZER_SE, 0, "RTD State Transition:");
+    sprintf(tempString, "  from--> %s", StateLabel(oldStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    sprintf(tempString, "    to--> %s", StateLabel(newStatus));
+    Show245(ANALYZER_SE, 0, tempString);
+    Show245(ANALYZER_SE, 0, " ");
+}
+
+// ==========================================================
+// Se_RtdStateLabel()
+//
+// Returns a pointer to an approprate state label string.
+// ==========================================================
+char* RTD::StateLabel(uint8 status)
+{
+    switch (status)
+    {
+        case RTD_IDLE:
+            return("IDLE");
+            break;
+        case RTD_AWTING_RPS:
+            return("AWAITING RESPONSE");
+            break;
+        default:
+            return("UNKNOWN STATE");
+    }
+}
+#endif            /* --------------------------------- */
+
+/************************************************************************/
+/*  function name       : Se_RtdT105TimerStart                          */
+/*  function outline    : T105 Timer Start                              */
+/*  function discription: void Se_RtdT105TimerStart( void )             */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::T105TimerStart(void)
+{
+    /* Increment timer-sequence number */
+    TmrSqcNumberInc() ;
+    /* Start timer (T105) */
+    RequestTimer(E_TmrId_Rtd_T105 , TmrSqcNumberRead() ,
+                 TimerDuration) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_RtdT105TimerStop                           */
+/*  function outline    : T105 Timer Stop                               */
+/*  function discription: void Se_RtdT105TimerStop( void )              */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::T105TimerStop(void)
+{
+    /* Stop timer (T105) */
+    CancelTimer(E_TmrId_Rtd_T105) ;
+}
+
+/************************************************************************/
+/*  function name       : Se_RtdStartMeasurement                        */
+/*  function outline    : Start mesurement of Round Trip Delay          */
+/*  function discription: void Se_RtdStartMeasurement( void )           */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void RTD::StartMeasurement(void)
+{
+    StartTime.set_to_current_time();
+}
+
+/************************************************************************/
+/*  function name       : Se_RtdStopMeasurement                         */
+/*  function outline    : Stop mesurement of Round Trip Delay           */
+/*  function discription: int32 Se_RtdSStopMeasurement( void )            */
+/*  input data          : None                                          */
+/*  output data         : Round Trip Delay time (milli second)          */
+/*  draw time           : '96.11.13                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int32 RTD::StopMeasurement(void)
+{
+    TimeValue StopTime;
+
+    StopTime.set_to_current_time();
+    return (StopTime.to_msec() - StartTime.to_msec());
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/se.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/se.cpp
new file mode 100644
index 0000000..b385673
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/se.cpp
@@ -0,0 +1,2437 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/************************************************************************/
+/*  file name       : sedisp.c                                          */
+/*  file contents   : Receive Data Dispatch Management                  */
+/*                  : Primitive and Timeout and Message                 */
+/*  draw            : '96.11.28                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+
+
+/************************************************************************/
+/*  Headerfile Include                                                  */
+/************************************************************************/
+#include    "h245pri.h"
+#include	"oscl_timer.h"
+#include    "semsgque.h"
+#include    "se.h"
+#include    "msd.h"
+#include	"blc.h"
+#include    "lc.h"
+#include    "clc.h"
+#include    "annex.h"
+#include    "ce.h"
+#include    "mt.h"
+#include    "rtd.h"
+#include    "ml.h"
+#include    "mr.h"
+#include    "rme.h"
+#include	"h245.h"
+#include    "oscl_snprintf.h"
+#include    "pvlogger.h"
+
+/* PVANALYZER */
+#define ANALYZER_SE 0x0020		// (Assume tag is fixed)
+void Show245(uint16 tag, uint16 indent, char *inString);
+
+/************************************************************************/
+/*  External Variable Definition: Primitive Event No Table              */
+/************************************************************************/
+static const S_EventNoTable EventNoTblForPri[  ] =
+{
+//    { EVENT_PTV_MSD_DTM_REQ     , E_PtvId_Msd_Dtm_Req   ,"MSDSE --> DETERMINE.request" },
+//    { EVENT_PTV_CE_TRF_REQ      , E_PtvId_Ce_Trf_Req    ,"CESE --> TRANSFER.request" },
+//    { EVENT_PTV_CE_TRF_RPS      , E_PtvId_Ce_Trf_Rps    ,"CESE --> TRANSFER.response" },
+//    { EVENT_PTV_CE_RJT_REQ      , E_PtvId_Ce_Rjt_Req    ,"CESE --> REJECT.request" },
+    { EVENT_PTV_LCBLC_ETB_REQ   , E_PtvId_Lc_Etb_Req    , "LCSE --> ESTABLISH.request" },
+    { EVENT_PTV_LCBLC_ETB_RPS   , E_PtvId_Lc_Etb_Rps    , "LCSE --> ESTABLISH.response" },
+    { EVENT_PTV_LCBLC_RLS_REQ   , E_PtvId_Lc_Rls_Req    , "LCSE --> RELEASE.request" },
+    { EVENT_PTV_LCBLC_ETB_REQ   , E_PtvId_Blc_Etb_Req   , "BLCSE --> ESTABLISH.request" },
+    { EVENT_PTV_LCBLC_ETB_RPS   , E_PtvId_Blc_Etb_Rps   , "BLCSE --> ESTABLISH.response" },
+    { EVENT_PTV_LCBLC_RLS_REQ   , E_PtvId_Blc_Rls_Req   , "BLCSE --> RELEASE.request" },
+    { EVENT_PTV_CLC_CLS_REQ     , E_PtvId_Clc_Cls_Req   , "CLCSE --> CLOSE.request" },
+    { EVENT_PTV_CLC_CLS_RPS     , E_PtvId_Clc_Cls_Rps   , "CLCSE --> CLOSE.response" },
+    { EVENT_PTV_CLC_RJT_REQ     , E_PtvId_Clc_Rjt_Req   , "CLCSE --> REJECT.request" },
+    { EVENT_PTV_MT_TRF_REQ      , E_PtvId_Mt_Trf_Req    , "MTSE --> TRANSFER.request" },
+    { EVENT_PTV_MT_TRF_RPS      , E_PtvId_Mt_Trf_Rps    , "MTSE --> TRANSFER.response" },
+    { EVENT_PTV_MT_RJT_REQ      , E_PtvId_Mt_Rjt_Req    , "MTSE --> REJECT.request" },
+    { EVENT_PTV_RME_SEND_REQ    , E_PtvId_Rme_Send_Req  , "RMESE --> SEND.request" },
+    { EVENT_PTV_RME_SEND_RPS    , E_PtvId_Rme_Send_Rps  , "RMESE --> SEND.responsse" },
+    { EVENT_PTV_RME_RJT_REQ     , E_PtvId_Rme_Rjt_Req   , "RMESE --> REJECT.request" },
+    { EVENT_PTV_MR_TRF_REQ      , E_PtvId_Mr_Trf_Req    , "MRSE --> TRANSFER.request" },
+    { EVENT_PTV_MR_TRF_RPS      , E_PtvId_Mr_Trf_Rps    , "MRSE --> TRANSFER.response" },
+    { EVENT_PTV_MR_RJT_REQ      , E_PtvId_Mr_Rjt_Req    , "MRSE --> REJECT.request" },
+    { EVENT_PTV_RTD_TRF_REQ     , E_PtvId_Rtd_Trf_Req   , "RTDSE --> TRANSFER.request" },
+    { EVENT_PTV_ML_LOOP_REQ     , E_PtvId_Ml_Loop_Req   , "MLSE --> LOOP.request" },
+    { EVENT_PTV_ML_LOOP_RPS     , E_PtvId_Ml_Loop_Rps   , "MLSE --> LOOP.response" },
+    { EVENT_PTV_ML_RLS_REQ      , E_PtvId_Ml_Rls_Req    , "MLSE --> RELEASE.request" },
+    { EVENT_PTV_NSD_REQ         , E_PtvId_Nsd_Req       , "NSDSE --> NonstandardMessage REQUEST" },
+    { EVENT_PTV_NSD_RPS         , E_PtvId_Nsd_Rps       , "NSDSE --> NonstandardMessage RESPONSE" },
+    { EVENT_PTV_NSD_CMD         , E_PtvId_Nsd_Cmd       , "NSDSE --> NonstandardMessage COMMAND" },
+    { EVENT_PTV_NSD_IDC         , E_PtvId_Nsd_Idc       , "NSDSE --> NonstandardMessage INDICATION" },
+    { EVENT_PTV_CM_REQ          , E_PtvId_Cm_Req        , "CMSE --> CommunicationMode REQUEST" },
+    { EVENT_PTV_CM_RPS          , E_PtvId_Cm_Rps        , "CMSE --> CommunicationMode RESPONSE" },
+    { EVENT_PTV_CM_CMD          , E_PtvId_Cm_Cmd        , "CMSE --> CommunicationMode COMMAND" },
+    { EVENT_PTV_H223AAR         , E_PtvId_H223aar       , "H223AAR --> H223AnnexA RECONFIG" },
+    { EVENT_PTV_H223AAR_ACK     , E_PtvId_H223aar_Ack   , "H223AAR --> H223AnnexA RECONFIG ACK" },
+    { EVENT_PTV_H223AAR_RJT     , E_PtvId_H223aar_Rjt   , "H223AAR --> H223AnnexA RECONFIG REJECT" },
+    { EVENT_PTV_CNF_REQ         , E_PtvId_Cnf_Req       , "CNF --> Conference REQUEST" },
+    { EVENT_PTV_CNF_RPS         , E_PtvId_Cnf_Rps       , "CNF --> Conference RESPONSE" },
+    { EVENT_PTV_CMD_STCS        , E_PtvId_Cmd_Stcs      , "CMD --> SEND TerminalCapabilitySet" },
+    { EVENT_PTV_CMD_ECRPT       , E_PtvId_Cmd_Ecrpt     , "CMD --> Encryption COMMAND" },
+    { EVENT_PTV_CMD_FC          , E_PtvId_Cmd_Fc        , "CMD --> FlowControl COMMAND" },
+    { EVENT_PTV_CMD_ES          , E_PtvId_Cmd_Es        , "CMD --> EndSession COMMAND" },
+    { EVENT_PTV_CMD_MSCL        , E_PtvId_Cmd_Mscl      , "CMD --> Miscellaneous COMMAND" },
+    { EVENT_PTV_CMD_CNF         , E_PtvId_Cmd_Cnf       , "CMD --> Conference COMMAND" },
+    { EVENT_PTV_CMD_HMR         , E_PtvId_Cmd_Hmr       , "CMD --> H223 Multiplex RECONFIG" },
+    { EVENT_PTV_IDC_FNU         , E_PtvId_Idc_Fnu       , "IDC --> FunctionNotUnderstood" },
+    { EVENT_PTV_IDC_MSCL        , E_PtvId_Idc_Mscl      , "IDC --> Miscellaneous INDICATION" },
+    { EVENT_PTV_IDC_JTR         , E_PtvId_Idc_Jtr       , "IDC --> Jitter INDICATION" },
+    { EVENT_PTV_IDC_H223SKW     , E_PtvId_Idc_H223skw   , "IDC --> H223 Skew INDICATION" },
+    { EVENT_PTV_IDC_NWATMVC     , E_PtvId_Idc_Nwatmvc   , "IDC --> NewATMVC INDICATION" },
+    { EVENT_PTV_IDC_UI          , E_PtvId_Idc_Ui        , "IDC --> UserInput INDICATION" },
+    { EVENT_PTV_IDC_CNF         , E_PtvId_Idc_Cnf       , "IDC --> Conference INDICATION" },
+    { EVENT_PTV_IDC_H2250MXSKW  , E_PtvId_Idc_H2250mxskw, "IDC --> H2250 Maximum Skew INDICATION" },
+    { EVENT_PTV_IDC_MCLCT       , E_PtvId_Idc_Mclct     , "IDC --> McLocation INDICATION" },
+    { EVENT_PTV_IDC_VI          , E_PtvId_Idc_Vi        , "IDC --> Vendor ID" },
+    { EVENT_PTV_IDC_FNS         , E_PtvId_Idc_Fns       , "IDC --> FunctionNotSupported" },
+
+    /* Table End */
+
+    { STOPPER                   , STOPPER               , "Undefined PRIMATIVE" },
+} ;
+
+
+/************************************************************************/
+/*  External Variable Definition: Timeout Event No Table                */
+/************************************************************************/
+static const S_EventNoTable EventNoTblForTo[  ] =
+{
+//    { EVENT_TIM_MSD_T106        , E_TmrId_Msd_T106      ,"Timeout T106 (MSD)"   },
+//    { EVENT_TIM_CE_T101         , E_TmrId_Ce_T101       ,"Timeout T101 (CE)"    },
+    { EVENT_TIM_LCBLC_T103      , E_TmrId_LcBlc_T103    , "Timeout T103 (LC/BLC)"},
+    { EVENT_TIM_CLC_T108        , E_TmrId_Clc_T108      , "Timeout T108 (CLC)"   },
+    { EVENT_TIM_MT_T104         , E_TmrId_Mt_T104       , "Timeout T104 (MT)"    },
+    { EVENT_TIM_RME_T107        , E_TmrId_Rme_T107      , "Timeout T107 (RME)"   },
+    { EVENT_TIM_MR_T109         , E_TmrId_Mr_T109       , "Timeout T109 (MR)"    },
+    { EVENT_TIM_RTD_T105        , E_TmrId_Rtd_T105      , "Timeout T105 (RTD)"   },
+    { EVENT_TIM_ML_T102         , E_TmrId_Ml_T102       , "Timeout T102 (ML)"    },
+
+    /* Table End */
+
+    { STOPPER                   , STOPPER               , "Undefined TIMEOUT" },
+} ;
+
+
+/************************************************************************/
+/*  External Variable Definition: Request Message Event No Table        */
+/************************************************************************/
+static const S_EventNoTable EventNoTblForReqMsg[  ] =
+{
+    { EVENT_MSG_NSD_REQ         , MSGTYP_NSD_REQ        , "NonStandardMessageRequest RECEIVED" },
+    { EVENT_MSG_MSD             , MSGTYP_MSD            , "MasterSlaveDetermination RECEIVED" },
+    { EVENT_MSG_CE              , MSGTYP_CE             , "TerminalCapabilitySet RECEIVED" },
+    { EVENT_MSG_LCBLC_OP        , MSGTYP_LCBLC_OP       , "OpenLogicalChannel (LC/BLC) RECEIVED" },
+    { EVENT_MSG_LCBLC_CL        , MSGTYP_LCBLC_CL       , "CloseLogicalChannel (LC/BLC) RECEIVED" },
+    { EVENT_MSG_CLC             , MSGTYP_CLC            , "RequestChannelClose RECEIVED" },
+    { EVENT_MSG_MT              , MSGTYP_MT             , "MultiplexEntrySend RECEIVED" },
+    { EVENT_MSG_RME             , MSGTYP_RME            , "RequestMultiplexEntry RECEIVED" },
+    { EVENT_MSG_MR              , MSGTYP_MR             , "RequestMode RECEIVED" },
+    { EVENT_MSG_RTD_REQ         , MSGTYP_RTD_REQ        , "RoundTripDelayRequest RECEIVED" },
+    { EVENT_MSG_ML_REQ          , MSGTYP_ML_REQ         , "MaintenanceLoopRequest RECEIVED" },
+    { EVENT_MSG_CM_REQ          , MSGTYP_CM_REQ         , "CommunicationModeRequest RECEIVED" },
+    { EVENT_MSG_CNF_REQ         , MSGTYP_CNF_REQ        , "ConferenceRequest RECEIVED" },
+    { EVENT_MSG_H223AAR         , MSGTYP_H223AAR        , "H223AnnexAReconfiguration RECEIVED" },
+    /* (Not a codeword -- Not supported (RAN)) */
+    /* Table End */
+
+    { STOPPER                   , STOPPER               , "Undefined REQUEST MESSAGE" },
+} ;
+
+
+/************************************************************************/
+/*  External Variable Definition: Response Message Event No Table       */
+/************************************************************************/
+static const S_EventNoTable EventNoTblForRpsMsg[  ] =
+{
+    { EVENT_MSG_NSD_RPS         , MSGTYP_NSD_RPS        , "NonStandardMessageResponse RECEIVED" },
+    { EVENT_MSG_MSD_ACK         , MSGTYP_MSD_ACK        , "MasterSlaveDeterminationAck RECEIVED" },
+    { EVENT_MSG_MSD_RJT         , MSGTYP_MSD_RJT        , "MasterSlaveDeterminationReject RECEIVED" },
+    { EVENT_MSG_CE_ACK          , MSGTYP_CE_ACK         , "TerminalCapabilitySetAck RECEIVED" },
+    { EVENT_MSG_CE_RJT          , MSGTYP_CE_RJT         , "TerminalCapabilitySetReject RECEIVED" },
+    { EVENT_MSG_LCBLC_OP_ACK    , MSGTYP_LCBLC_OP_ACK   , "OpenLogicalChannelAck (LC/BLC) RECEIVED" },
+    { EVENT_MSG_LCBLC_OP_RJT    , MSGTYP_LCBLC_OP_RJT   , "OpenLogicalChannelReject (LC/BLC) RECEIVED" },
+    { EVENT_MSG_LCBLC_CL_ACK    , MSGTYP_LCBLC_CL_ACK   , "CloseLogicalChannelAck (LC/BLC) RECEIVED" },
+    { EVENT_MSG_CLC_ACK         , MSGTYP_CLC_ACK        , "RequestChannelCloseAck RECEIVED" },
+    { EVENT_MSG_CLC_RJT         , MSGTYP_CLC_RJT        , "RequestChannelCloseReject RECEIVED" },
+    { EVENT_MSG_MT_ACK          , MSGTYP_MT_ACK         , "MultiplexEntrySendAck RECEIVED" },
+    { EVENT_MSG_MT_RJT          , MSGTYP_MT_RJT         , "MultiplexEntrySendReject RECEIVED" },
+    { EVENT_MSG_RME_ACK         , MSGTYP_RME_ACK        , "RequestMultiplexEntryAck RECEIVED" },
+    { EVENT_MSG_RME_RJT         , MSGTYP_RME_RJT        , "RequestMultiplexEntryReject RECEIVED" },
+    { EVENT_MSG_MR_ACK          , MSGTYP_MR_ACK         , "RequestModeAck RECEIVED" },
+    { EVENT_MSG_MR_RJT          , MSGTYP_MR_RJT         , "RequestModeReject RECEIVED" },
+    { EVENT_MSG_RTD_RPS         , MSGTYP_RTD_RPS        , "RoundTripDelayResponse RECEIVED" },
+    { EVENT_MSG_ML_ACK          , MSGTYP_ML_ACK         , "MaintenanceLoopAck RECEIVED" },
+    { EVENT_MSG_ML_RJT          , MSGTYP_ML_RJT         , "MaintenanceLoopReject RECEIVED" },
+    { EVENT_MSG_CM_RPS          , MSGTYP_CM_RPS         , "CommunicationModeResponse RECEIVED" },
+    { EVENT_MSG_CNF_RPS         , MSGTYP_CNF_RPS        , "ConferenceResponse RECEIVED" },
+    { EVENT_MSG_H223AAR_ACK     , MSGTYP_H223AAR_ACK    , "H223AnnexAReconfigurationAck RECEIVED" },
+    { EVENT_MSG_H223AAR_RJT     , MSGTYP_H223AAR_RJT    , "H223AnnexAReconfigurationReject RECEIVED" },
+    /* (Not a codeword -- Not supported (RAN)) */
+    /* Table End */
+
+    { STOPPER                   , STOPPER               , "Undefined RESPONSE MESSAGE" },
+} ;
+
+
+/************************************************************************/
+/*  External Variable Definition: Command Message Event No Table        */
+/************************************************************************/
+static const S_EventNoTable EventNoTblForCmdMsg[  ] =
+{
+    { EVENT_MSG_NSD_CMD         , MSGTYP_NSD_CMD        , "NonStandardMessageCommand RECEIVED" },
+    { EVENT_MSG_ML_OFF_CMD      , MSGTYP_ML_OFF_CMD     , "MaintenanceLoopOffCommand RECEIVED" },
+    { EVENT_MSG_CMD_STCS        , MSGTYP_CMD_STCS       , "SendTerminalCapabilitySet RECEIVED" },
+    { EVENT_MSG_CMD_ECRPT       , MSGTYP_CMD_ECRPT      , "EncryptionCommand RECEIVED" },
+    { EVENT_MSG_CMD_FC          , MSGTYP_CMD_FC         , "FlowControlCommand RECEIVED" },
+    { EVENT_MSG_CMD_ES          , MSGTYP_CMD_ES         , "EndSessionCommand RECEIVED" },
+    { EVENT_MSG_CMD_MSCL        , MSGTYP_CMD_MSCL       , "MiscellaneousCommand RECEIVED" },
+    { EVENT_MSG_CM_CMD          , MSGTYP_CM_CMD         , "CommunicationModeCommand RECEIVED" },
+    { EVENT_MSG_CMD_CNF         , MSGTYP_CMD_CNF        , "ConferenceCommand RECEIVED" },
+    { EVENT_MSG_CMD_HMR         , MSGTYP_CMD_HMR        , "H223MultiplexReconfiguration RECEIVED" },
+
+    /* Table End */
+
+    { STOPPER                   , STOPPER               , "Undefined COMMAND MESSAGE" },
+} ;
+
+
+/************************************************************************/
+/*  External Variable Definition: Indication Message Event No Table     */
+/************************************************************************/
+static const S_EventNoTable EventNoTblForIdcMsg[  ] =
+{
+    { EVENT_MSG_NSD_IDC         , MSGTYP_NSD_IDC        , "NonStandardMessageIndication RECEIVED" },
+    { EVENT_MSG_IDC_FNU         , MSGTYP_IDC_FNU        , "FunctionNotUnderstood RECEIVED" },
+    { EVENT_MSG_MSD_RLS         , MSGTYP_MSD_RLS        , "MasterSlaveDeterminationRelease RECEIVED" },
+    { EVENT_MSG_CE_RLS          , MSGTYP_CE_RLS         , "TerminalCapabilitySetRelease RECEIVED" },
+    { EVENT_MSG_LCBLC_OP_CFM    , MSGTYP_LCBLC_OP_CFM   , "OpenLogicalChannelConfirm (BLC) RECEIVED" },
+    { EVENT_MSG_CLC_RLS         , MSGTYP_CLC_RLS        , "RequestChannelCloseRelease RECEIVED" },
+    { EVENT_MSG_MT_RLS          , MSGTYP_MT_RLS         , "MultiplexEntrySendRelease RECEIVED" },
+    { EVENT_MSG_RME_RLS         , MSGTYP_RME_RLS        , "RequestMultiplexEntryRelease RECEIVED" },
+    { EVENT_MSG_MR_RLS          , MSGTYP_MR_RLS         , "RequestModeRelease RECEIVED" },
+    { EVENT_MSG_IDC_MSCL        , MSGTYP_IDC_MSCL       , "MiscellaneousIndication RECEIVED" },
+    { EVENT_MSG_IDC_JTR         , MSGTYP_IDC_JTR        , "JitterIndication RECEIVED" },
+    { EVENT_MSG_IDC_H223SKW     , MSGTYP_IDC_H223SKW    , "H223SkewIndication RECEIVED" },
+    { EVENT_MSG_IDC_NWATMVC     , MSGTYP_IDC_NWATMVC    , "NewATMVCIndication RECEIVED" },
+    { EVENT_MSG_IDC_UI          , MSGTYP_IDC_UI         , "UserInputIndication RECEIVED" },
+    { EVENT_MSG_IDC_H2250MXSKW  , MSGTYP_IDC_H2250MXSKW , "H2250MaximumSkewIndication RECEIVED" },
+    { EVENT_MSG_IDC_MCLCT       , MSGTYP_IDC_MCLCT      , "MCLocationIndication RECEIVED" },
+    { EVENT_MSG_IDC_CNF         , MSGTYP_IDC_CNF        , "ConferenceIndication RECEIVED" },
+    { EVENT_MSG_IDC_VI          , MSGTYP_IDC_VI         , "VendorIdentification RECEIVED" },
+    { EVENT_MSG_IDC_FNS         , MSGTYP_IDC_FNS        , "FunctionNotSupported RECEIVED" },
+    { EVENT_MSG_IDC_FC         , MSGTYP_IDC_FC          , "FlowControlIndication RECEIVED" },
+
+    /* Table End */
+
+    { STOPPER                   , STOPPER               , "Undefined INDICATION MESSAGE" },
+} ;
+
+
+/************************************************************************/
+/*  function name       : SE class constructor                          */
+/************************************************************************/
+OSCL_EXPORT_REF SE::SE() : MyPER(0), MyH245(0), MyTimer("SETimer")
+{
+
+    MyTimer.SetObserver(this);
+    MyMSD.SetSE(this);
+    MyBLC.SetSE(this);
+    MyLC.SetSE(this);
+    MyCLC.SetSE(this);
+    MyNSD.SetSE(this);
+    MyCM.SetSE(this);
+    MyCNF.SetSE(this);
+    MyCMD.SetSE(this);
+    MyIDC.SetSE(this);
+    MyCE.SetSE(this);
+    MyMT.SetSE(this);
+    MyRTD.SetSE(this);
+    MyML.SetSE(this);
+    MyMR.SetSE(this);
+    MyRME.SetSE(this);
+
+    /* Signalling Entity Initialize */
+    MyBLC.SetMSD(&MyMSD);
+    MyLC.SetMSD(&MyMSD);
+
+    LCBLCOutgoing.SetDirection(LC_OUTGOING);
+    LCBLCIncoming.SetDirection(LC_INCOMING);
+
+    oscl_memset(&iTimerValues, 0, sizeof(H245TimerValues));
+
+    Logger = PVLogger::GetLoggerObject("3g324m.h245.se");
+}
+
+/************************************************************************/
+/*  function name       : SE class destructor                           */
+/************************************************************************/
+OSCL_EXPORT_REF SE::~SE()
+{
+}
+
+/************************************************************************/
+/*                                                                      */
+/************************************************************************/
+OSCL_EXPORT_REF void SE::Reset()
+{
+    // reset the states for the SEs
+    MyTimer.Clear();
+    MyMSD.Reset();
+    MyBLC.Reset();
+    MyLC.Reset();
+    MyCLC.Reset();
+    MyNSD.Reset();
+    MyCM.Reset();
+    MyCNF.Reset();
+    MyCMD.Reset();
+    MyIDC.Reset();
+    MyCE.Reset();
+    MyMT.Reset();
+    MyRTD.Reset();
+    MyML.Reset();
+    MyMR.Reset();
+    MyRME.Reset();
+    LCBLCOutgoing.Reset();
+    LCBLCIncoming.Reset();
+}
+
+/************************************************************************/
+/*                                                                      */
+/************************************************************************/
+OSCL_EXPORT_REF void SE::SetPer(PER *per)
+{
+    MyPER = per;
+    MyMSD.SetPer(per);
+    MyBLC.SetPer(per);
+    MyLC.SetPer(per);
+    MyCLC.SetPer(per);
+    MyNSD.SetPer(per);
+    MyCM.SetPer(per);
+    MyCNF.SetPer(per);
+    MyCMD.SetPer(per);
+    MyIDC.SetPer(per);
+    MyCE.SetPer(per);
+    MyMT.SetPer(per);
+    MyRTD.SetPer(per);
+    MyML.SetPer(per);
+    MyMR.SetPer(per);
+    MyRME.SetPer(per);
+}
+
+/************************************************************************/
+/*                                                                      */
+/************************************************************************/
+OSCL_EXPORT_REF void SE::SetH245(H245 *h245)
+{
+    MyH245 = h245;
+    MyMSD.SetH245(h245);
+    MyBLC.SetH245(h245);
+    MyLC.SetH245(h245);
+    MyCLC.SetH245(h245);
+    MyNSD.SetH245(h245);
+    MyCM.SetH245(h245);
+    MyCNF.SetH245(h245);
+    MyCMD.SetH245(h245);
+    MyIDC.SetH245(h245);
+    MyCE.SetH245(h245);
+    MyMT.SetH245(h245);
+    MyRTD.SetH245(h245);
+    MyML.SetH245(h245);
+    MyMR.SetH245(h245);
+    MyRME.SetH245(h245);
+}
+
+/************************************************************************/
+/*                                                                      */
+/************************************************************************/
+void SE::TimeoutOccurred(int32 timerID , int32 timeoutInfo)
+{
+    Print("    SE::TimeoutOccurred timerId, timeoutInfo=", timerID, timeoutInfo);
+
+    S_InfHeader infHeader;
+
+    infHeader.InfType = H245_TIMEOUT ;
+    infHeader.InfId = (timerID & 0x0000FFFF) ;
+    infHeader.InfSupplement1 = timeoutInfo ;
+    infHeader.InfSupplement2 = ((timerID >> 16) & 0x0000FFFF) ;
+    infHeader.pParameter = NULL;
+
+    InformationRecv(&infHeader);
+}
+
+
+/************************************************************************/
+/*  function name       : InformationRecv                               */
+/*  function outline    : Receive Information From Upper Layer          */
+/*                      : Primitive and Timeout                         */
+/*  function discription: InformationRecv( PS_InfHeader )               */
+/*  input data          : PS_InfHeader p_InfHeader                      */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+OSCL_EXPORT_REF void SE::InformationRecv(PS_InfHeader p_InfHeader)
+{
+    PS_EventNoTable     p_EventNoTable ;
+    uint32                Event_No ;
+
+    p_EventNoTable = TablePointerGetUpperLayer(p_InfHeader->InfType) ;
+    if (p_EventNoTable != NULL)  /* Search Table Pointer Get OK */
+    {
+        /* Event No Decision  */
+        Event_No = EventNoDecision(p_EventNoTable , p_InfHeader->InfId) ;
+        if (Event_No != STOPPER)  /* Event No Decision OK */
+        {
+            int32 leave_status = 0;
+            OsclSharedPtr<uint8> parameter(p_InfHeader->pParameter, NULL);
+            OSCL_TRY(leave_status, Dispatch(Event_No , parameter , p_InfHeader->InfSupplement1 , p_InfHeader->InfSupplement2));
+            OSCL_FIRST_CATCH_ANY(leave_status, Print("SE::InformationRecv - Dispatch LEAVE"));
+        }
+        else /* Event No Decision NG ( Information Id Error ) */
+        {
+            /* Internal Error Notification ( To TSC ) */
+            ItnErrNotificationSend(ITN_ERR_CODE_0000 , p_InfHeader->InfId) ;
+        }
+    }
+    else /* Search Table Pointer Get NG ( Message Type1 Error ) */
+    {
+        /* Internal Error Notification ( To TSC ) */
+        ItnErrNotificationSend(ITN_ERR_CODE_0000 , (uint32) p_InfHeader->InfType) ;
+    }
+    return ;
+}
+
+/************************************************************************/
+/*  function name       : MessageRecv                                   */
+/*  function outline    : Receive Information From Lower Layer          */
+/*                      : Message                                       */
+/*  function discription: MessageRecv( PS_H245Msg )                     */
+/*  input data          : PS_H245Msg p_H245Msg                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SE::MessageRecv(uint8 Type1, uint8 Type2, OsclSharedPtr<uint8> Data, uint8* EncodedMsg, uint32 EncodedMsgSize)
+{
+    PS_EventNoTable     p_EventNoTable ;
+    uint32                Event_No ;
+
+    p_EventNoTable = TablePointerGetLowerLayer(Type1) ;
+    if (p_EventNoTable != NULL)  /* Search Table Pointer Get OK */
+    {
+        /* Event No Decision  */
+        Event_No = EventNoDecision(p_EventNoTable , (uint32)Type2) ;
+        if (Event_No != STOPPER)  /* Event No Decision OK */
+        {
+            int32 leave_status = 0;
+            OSCL_TRY(leave_status, Dispatch(Event_No , Data , 0 , 0, EncodedMsg, EncodedMsgSize));
+            OSCL_FIRST_CATCH_ANY(leave_status, Print("SE::MessageRecv - Dispatch() LEAVE"));
+        }
+        else  /* Event No Decision NG ( Message Type1 Error ) */
+        {
+            /* Internal Error Notification ( To TSC ) */
+            ItnErrNotificationSend(ITN_ERR_CODE_0001 , (uint32) Type2) ;
+        }
+    }
+    else /* Search Table Pointer Get NG ( Message Type1 Error ) */
+    {
+        /* Internal Error Notification ( To TSC ) */
+        ItnErrNotificationSend(ITN_ERR_CODE_0000 , (uint32) Type1) ;
+    }
+    return ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_TablePointerGetUpperLayer                  */
+/*  function outline    : Table Pointer Get ( From Upper Layer )        */
+/*  function discription: Se_TablePointerGetUpperLayer( uint32 )          */
+/*  input data          : uint32 InfType_2                                */
+/*  output data         : PS_EventNoTable p_EventNoTable                */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+PS_EventNoTable SE::TablePointerGetUpperLayer(uint32 InfType_2)
+{
+    PS_EventNoTable p_EventNoTable ;
+
+    switch (InfType_2)  /* Information Type 2 */
+    {
+        case    H245_PRIMITIVE : /* H.245 Primitive Information Receive */
+            p_EventNoTable = (PS_EventNoTable)EventNoTblForPri ;
+            break ;
+        case    H245_TIMEOUT : /* H.245 Timeout Information Receive */
+            p_EventNoTable = (PS_EventNoTable)EventNoTblForTo ;
+            break ;
+        default : /* Receive Information Error */
+            p_EventNoTable = NULL ;
+            break ;
+    }
+    /* Return Event No Table Pointer */
+    return(p_EventNoTable) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_TablePointerGetLowerLayer                  */
+/*  function outline    : Table Pointer Get ( From Lower Layer )        */
+/*  function discription: Se_TablePointerGetLowerLayer( uint32 )          */
+/*  input data          : uint32 InfType_2                                */
+/*  output data         : PS_EventNoTable p_EventNoTable                */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+PS_EventNoTable SE::TablePointerGetLowerLayer(uint32 InfType_2)
+{
+    PS_EventNoTable p_EventNoTable ;
+
+    switch (InfType_2)  /* Information Type 2 */
+    {
+        case    H245_MSG_REQ : /* Request Message Information Receive */
+            p_EventNoTable = (PS_EventNoTable) EventNoTblForReqMsg ;
+            break ;
+        case    H245_MSG_RPS : /* Response Message Information Receive */
+            p_EventNoTable = (PS_EventNoTable) EventNoTblForRpsMsg ;
+            break ;
+        case    H245_MSG_CMD : /* Command Message Information Receive */
+            p_EventNoTable = (PS_EventNoTable) EventNoTblForCmdMsg ;
+            break ;
+        case    H245_MSG_IDC : /* Indication Message Information Receive */
+            p_EventNoTable = (PS_EventNoTable) EventNoTblForIdcMsg ;
+            break ;
+        default : /* Receive Information Error */
+            p_EventNoTable = NULL ;
+            break ;
+    }
+    /* Return Event No Table Pointer */
+    return(p_EventNoTable) ;
+}
+
+
+/************************************************************************/
+/*  function name       : Se_EventNoDecision                            */
+/*  function outline    : Event No Decision                             */
+/*  function discription: Se_EventNoDecision( PS_EventNoTable , uint32 )  */
+/*  input data          : PS_EventNoTable p_EventNoTable                */
+/*                      : uint32 InfType_2                                */
+/*  output data         : uint32 Event_No                                 */
+/*                      :   STOPPER : Event No Decision NG              */
+/*                      :   Other   : Event No Decision OK              */
+/*  draw time           : '96.11.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+uint32 SE::EventNoDecision(PS_EventNoTable p_EventNoTable , uint32 InfType_2)
+{
+    uint32    Event_No ;
+
+    /* Event No Initialize */
+    Event_No = STOPPER ;
+
+    while (p_EventNoTable->InfType2 != STOPPER)   /* Until Information Type2 Equal Stopper */
+    {
+        if (p_EventNoTable->InfType2 == InfType_2)  /* Information Type2 Equal */
+        {
+            /* Event No Set */
+            Event_No = p_EventNoTable->EventNo ;
+            break ;
+        }
+        p_EventNoTable ++ ;
+    }
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+    EventNoShow(p_EventNoTable->Comment);  /* PVANALYZER (RAN) */
+#endif            /* --------------------------------- */
+
+    /* Event No Return */
+    return(Event_No) ;
+}
+
+#ifdef PVANALYZER /* --------SE Analyzer Tool -------- */
+// =========================================================
+// Se_EventNoShow()
+//
+// This function displays the SE event which is about to
+// be handled by Se_Dispatch().
+// =========================================================
+void SE::EventNoShow(char *comment)
+{
+    Show245(ANALYZER_SE, 0, "Signaling Entity Event:");
+    Show245(ANALYZER_SE, 2, comment);
+    Show245(ANALYZER_SE, 0, " ");
+}
+#endif            /* --------------------------------- */
+
+/************************************************************************/
+/*  function name       : Se_Dispatch                                   */
+/*  function outline    : Dispatch                                      */
+/*  function discription: Se_DispatchMain( uint32 , uint8 , uint32 , uint32 ) */
+/*  input data          : uint32 Event_No                                 */
+/*                      : uint8* pParameter                             */
+/*                      : uint32 Supplement_1                             */
+/*                      : uint32 Supplement_2                             */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.28                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SE::Dispatch(uint32 Event_No , OsclSharedPtr<uint8> pParameter , uint32 Supplement_1 , uint32 Supplement_2,
+                  uint8* EncodedMsg, uint32 EncodedMsgSize)
+{
+    uint8                   Se_Status ;
+    uint8					Se_Status2;
+    LCEntry*				pLCEntry;
+    uint8                   Directional ;
+    PS_ForwardReverseParam  p_ForwardReverseParam ;
+    PS_OpenLogicalChannel   p_OpenLogicalChannel ;
+    int32                     lcn;        /* Temp holder for FwdLCN.  RAN */
+
+    switch (Event_No & 0XFF000000)  /* Signalling Entity Check */
+    {
+        case    EVENT_MSDSE : /* Master Slave Determination Signalling Entity */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_MSG_MSD : /* MasterSlaveDetermination */
+                    MyMSD.Handler((PS_MasterSlaveDetermination)((uint8*)pParameter));
+                    break ;
+                case    EVENT_MSG_MSD_ACK : /* MasterSlaveDeterminationAck */
+                    MyMSD.Handler((PS_MasterSlaveDeterminationAck)((uint8*)pParameter));
+                    break ;
+                case    EVENT_MSG_MSD_RJT: /* MasterSlaveDeterminationReject */
+                    MyMSD.Handler((PS_MasterSlaveDeterminationReject)((uint8*)pParameter));
+                    break ;
+                case    EVENT_MSG_MSD_RLS : /* MasterSlaveDeterminationRelease */
+                    MyMSD.Handler((PS_MasterSlaveDeterminationRelease)((uint8*)pParameter));
+                    break;
+            }
+            break ;
+        case    EVENT_CESE : /* Capability Exchange Signalling Entity */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_MSG_CE : /* TerminalCapabilitySet */
+                {
+                    OsclSharedPtr<S_TerminalCapabilitySet> param;
+                    param.Bind((PS_TerminalCapabilitySet)pParameter.GetRep(), pParameter.GetRefCounter());
+                    if (param.GetRefCounter())(param.GetRefCounter())->addRef();
+                    MyCE.Handler(param);
+                }
+                break ;
+                case    EVENT_MSG_CE_ACK : /* TerminalCapabilitySetAck */
+                    MyCE.Handler((PS_TerminalCapabilitySetAck)((uint8*)pParameter));
+                    break ;
+                case    EVENT_MSG_CE_RJT : /* TerminalCapabilitySetReject */
+                    MyCE.Handler((PS_TerminalCapabilitySetReject)((uint8*)pParameter));
+                    break ;
+                case    EVENT_MSG_CE_RLS : /* TerminalCapabilitySetRelease */
+                    MyCE.Handler((PS_TerminalCapabilitySetRelease)((uint8*)pParameter));
+                    break ;
+            }
+            break ;
+        case    EVENT_LCBLCSE : /* Uni-Directional and Bi-Directional Logical Channel Signalling Entity */
+            pLCEntry = NULL ;
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_LCBLC_ETB_REQ : /* ESTABLISH.request */
+                    Print("Received LCBLC Establish.Request\n");
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(Supplement_1);
+                    /* if LC doesn't exist then create it */
+                    if (pLCEntry == NULL)
+                    {
+                        Print("    Creating New Logical Channel Entry : Outgoing %d\n", Supplement_1);
+                        pLCEntry = LCBLCOutgoing.NewLCEntry(Supplement_1);
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+
+                    if (pLCEntry->DirectionalRead() == NO_DIRECTIONAL)  /* Unsettled Directional */
+                    {                                                            /* (true for new LCB's) */
+                        p_ForwardReverseParam = (PS_ForwardReverseParam)((uint8*)pParameter) ;
+                        if (p_ForwardReverseParam->option_of_reverseLogicalChannelParameters == false)   /* Uni-Directional */
+                        {
+                            Directional = UNI_DIRECTIONAL ;
+                        }
+                        else /* Bi-Directional */
+                        {
+                            Directional = BI_DIRECTIONAL ;
+                        }
+                        pLCEntry->DirectionalWrite(Directional);
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                MyLC._0200_0000(pLCEntry , (PS_ForwardReverseParam)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyLC._0200_0030(pLCEntry , (PS_ForwardReverseParam)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                /* (RAN) Comment: this path is not appropriate; */
+                                /*       It should never be called.             */
+                                MyLC._0200_0000(pLCEntry , (PS_ForwardReverseParam)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                MyBLC._0300_0000(pLCEntry , (PS_ForwardReverseParam)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyBLC._0300_0030(pLCEntry , (PS_ForwardReverseParam)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                /* (RAN) Comment: this path is not appropriate; */
+                                /*       It should never be called.             */
+                                MyBLC._0300_0000(pLCEntry , (PS_ForwardReverseParam)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_MSG_LCBLC_OP : /* OpenLogicalChannel */
+                    Print("Received LCBLC OpenLogicalChannel\n");
+                    pLCEntry = LCBLCIncoming.GetLCEntry(((PS_OpenLogicalChannel)((uint8*)pParameter))->forwardLogicalChannelNumber) ;
+                    if (pLCEntry == NULL)
+                    {
+                        Print("    Creating New Logical Channel Entry : Incoming %d\n", ((PS_OpenLogicalChannel)((uint8*)pParameter))->forwardLogicalChannelNumber);
+                        pLCEntry = LCBLCIncoming.NewLCEntry(((PS_OpenLogicalChannel)((uint8*)pParameter))->forwardLogicalChannelNumber);
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    if (pLCEntry->DirectionalRead() == NO_DIRECTIONAL)  /* Unsettled Directional */
+                    {
+                        p_OpenLogicalChannel = (PS_OpenLogicalChannel)((uint8*)pParameter) ;
+                        if (p_OpenLogicalChannel->option_of_reverseLogicalChannelParameters == false)   /* Uni-Directional */
+                        {
+                            Directional = UNI_DIRECTIONAL ;
+                        }
+                        else /* Bi-Directional */
+                        {
+                            Directional = BI_DIRECTIONAL ;
+                        }
+                        pLCEntry->DirectionalWrite(Directional);
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                /* (RAN) Comment: this path is not appropriate; */
+                                /*       It should never be called.             */
+                                MyLC._0201_0001(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                /* (RAN) Comment: this path is not appropriate; */
+                                /*       It should never be called.             */
+                                MyLC._0201_0010(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                MyLC._0201_0001(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyLC._0201_0011(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                MyLC._0201_0011(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                /* (RAN) Comment: this path is not appropriate; */
+                                /*       It should never be called.             */
+                                MyBLC._0301_0001(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                /* (RAN) Comment: this path is not appropriate; */
+                                /*       It should never be called.             */
+                                MyBLC._0301_0010(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , Event_No & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                MyBLC._0301_0001(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyBLC._0301_0011(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                                MyBLC._0301_0021(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                MyBLC._0301_0011(pLCEntry , (PS_OpenLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_PTV_LCBLC_ETB_RPS : /* ESTABLISH.response */
+                    Print("Received LCBLC Establish.Response\n");
+                    pLCEntry = LCBLCIncoming.GetLCEntry(Supplement_1);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyLC._0202_0011(pLCEntry , (PS_ReverseData)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyBLC._0302_0011(pLCEntry , (PS_ReverseData)((uint8*)pParameter) , (uint16) Supplement_2) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_PTV_LCBLC_RLS_REQ : /* RELEASE.request */
+                    Print("Received LCBLC Release.Request\n");
+                    if (((uint8*)pParameter) != NULL)  	/* WWU_VOAL2: incoming SE */
+                    {
+                        pLCEntry = LCBLCIncoming.GetLCEntry(Supplement_1);
+                        if (pLCEntry != NULL)
+                        {
+                            Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                        }
+                    }
+                    else  				/* WWU_VOAL2: outgoing SE */
+                    {
+                        pLCEntry = LCBLCOutgoing.GetLCEntry(Supplement_1);
+                        if (pLCEntry != NULL)
+                        {
+                            Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                        }
+                    }
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyLC._0203_0010(pLCEntry , (PS_OlcRejectCause)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                MyLC._0203_0020(pLCEntry , (PS_OlcRejectCause)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyLC._0203_0011(pLCEntry , (PS_OlcRejectCause)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyBLC._0303_0010(pLCEntry , (PS_OlcRejectCause)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                MyBLC._0303_0020(pLCEntry , (PS_OlcRejectCause)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyBLC._0303_0011(pLCEntry , (PS_OlcRejectCause)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_MSG_LCBLC_OP_ACK : /* OpenLogicalChannelAck */
+                    Print("Received LCBLC OpenLogicalChannelAck\n");
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(((PS_OpenLogicalChannelAck)((uint8*)pParameter))->forwardLogicalChannelNumber) ;
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                MyLC._0204_0000(pLCEntry , (PS_OpenLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyLC._0204_0010(pLCEntry , (PS_OpenLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                MyBLC._0304_0000(pLCEntry , (PS_OpenLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyBLC._0304_0010(pLCEntry , (PS_OpenLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_MSG_LCBLC_OP_CFM : /* OpenLogicalChannelConfirm ( Bi-Directional Only ) */
+                    Print("Received LCBLC OpenLogicalChannelConfirm\n");
+                    pLCEntry = LCBLCIncoming.GetLCEntry(((PS_OpenLogicalChannelConfirm)((uint8*)pParameter))->forwardLogicalChannelNumber) ;
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                Nop_XXXX_XXXX() ;    /* (RAN) Replaced error notn with NOP() as in SDL */
+                                /* ItnErrNotificationSend( ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status ) ;*/
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyBLC._0305_0011(pLCEntry , (PS_OpenLogicalChannelConfirm)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                                MyBLC._0305_0021(pLCEntry , (PS_OpenLogicalChannelConfirm)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_MSG_LCBLC_OP_RJT : /* OpenLogicalChannelReject */
+                    Print("Received LCBLC OpenLogicalChannelReject\n");
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(((PS_OpenLogicalChannelReject)((uint8*)pParameter))->forwardLogicalChannelNumber) ;
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                MyLC._0206_0000(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyLC._0206_0010(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                MyLC._0206_0020(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyLC._0206_0030(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                MyBLC._0306_0000(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyBLC._0306_0010(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                MyBLC._0306_0020(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyBLC._0306_0030(pLCEntry , (PS_OpenLogicalChannelReject)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_TIM_LCBLC_T103 : /* Timer T103 Timeout */
+                    Print("Received LCBLC T103 Timeout\n");
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(Supplement_2);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyLC._0207_0010(pLCEntry , Supplement_1) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyLC._0207_0030(pLCEntry , Supplement_1) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                MyBLC._0307_0010(pLCEntry , Supplement_1) ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyBLC._0307_0030(pLCEntry , Supplement_1) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                                MyBLC._0307_0021(pLCEntry , Supplement_1) ;
+                                break ;
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_MSG_LCBLC_CL : /* CloseLogicalChannel */
+                    Print("Received LCBLC CloseLogicalChannel\n");
+                    /* WWU_H245_TWOWAY */
+                    pLCEntry = LCBLCIncoming.GetLCEntry(((PS_CloseLogicalChannel)((uint8*)pParameter))->forwardLogicalChannelNumber) ;
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                MyLC._0208_0001(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyLC._0208_0011(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                MyLC._0208_0011(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                                MyBLC._0308_0001(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                                MyBLC._0308_0011(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                                MyBLC._0308_0021(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                MyBLC._0308_0011(pLCEntry , (PS_CloseLogicalChannel)((uint8*)pParameter)) ;
+                                break ;
+                        }
+                    }
+                    break ;
+                case    EVENT_MSG_LCBLC_CL_ACK : /* CloseLogicalChannelAck */
+                    Print("Received LCBLC CloseLogicalChannelAck\n");
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(((PS_CloseLogicalChannelAck)((uint8*)pParameter))->forwardLogicalChannelNumber) ;
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    /* Uni-Directional and Bi-Directional Logical Channel Status Read ( Each Logical Channel Number ) */
+                    Se_Status = pLCEntry->StatusRead();
+                    if (pLCEntry->DirectionalRead() == UNI_DIRECTIONAL)  /* Uni-Directional */
+                    {
+                        Print("    Channel Uni-Directional\n");
+                        switch (Se_Status)  /* Uni-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                MyLC._0209_0020(pLCEntry , (PS_CloseLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyLC._0209_0030(pLCEntry , (PS_CloseLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    else /* Bi-Directional */
+                    {
+                        Print("    Channel Bi-Directional\n");
+                        switch (Se_Status)  /* Bi-Directional Logical Channel Status Read */
+                        {
+                            case    LCBLC_OUTGOING_RLSED : /* Outgoing Released  */
+                            case    LCBLC_OUTGOING_AWTING_ETBMNT : /* Outgoing Awaiting Establishment */
+                                Nop_XXXX_XXXX() ;
+                                break ;
+                            case    LCBLC_OUTGOING_ETBED : /* Outgoing Established */
+                                MyBLC._0309_0020(pLCEntry , (PS_CloseLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_OUTGOING_AWTING_RLS : /* Outgoing Awaiting Release */
+                                MyBLC._0309_0030(pLCEntry , (PS_CloseLogicalChannelAck)((uint8*)pParameter)) ;
+                                break ;
+                            case    LCBLC_INCOMING_RLSED : /* Incoming Released  */
+                            case    LCBLC_INCOMING_AWTING_ETBMNT : /* Incoming Awaiting Establishment */
+                            case    LCBLC_INCOMING_AWTING_CNFMTN : /* Incoming Awaiting Confirmation */
+                            case    LCBLC_INCOMING_ETBED : /* Incoming Established */
+                                /* Internal Error Notification ( To TSC ) */
+                                ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_BLCSE & Se_Status) ;
+                                break ;
+                        }
+                    }
+                    break ;
+            }
+            break ;
+
+        case    EVENT_CLCSE : /* Close Logical Channel Signalling Entity */
+            /* Close Logical channel Status Read */
+            pLCEntry = NULL;
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_CLC_CLS_REQ : /* CLOSE.request */
+                    Print("Received CLC Close.Request\n");
+                    lcn = Supplement_1;
+                    pLCEntry = LCBLCIncoming.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            MyCLC._0400_0000(pLCEntry) ;
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_CLC : /* RequestChannelClose */
+                    Print("Received CLC RequestChannelClose\n");
+                    lcn = ((PS_RequestChannelClose)((uint8*)pParameter))->forwardLogicalChannelNumber;
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            MyCLC._0401_0001(pLCEntry) ;
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyCLC._0401_0011(pLCEntry) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_CLC_CLS_RPS : /* CLOSE.response */
+                    Print("Received CLC Close.Response\n");
+                    lcn = Supplement_1;
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyCLC._0402_0011(pLCEntry) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_CLC_RJT_REQ : /* REJECT.request */
+                    Print("Received CLC Reject.Request\n");
+                    lcn = Supplement_1;
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyCLC._0403_0011(pLCEntry, (PS_RccRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_CLC_ACK : /* RequestChannelCloseAck */
+                    Print("Received CLC RequestChannelCloseAck\n");
+                    lcn = ((PS_RequestChannelCloseAck)((uint8*)pParameter))->forwardLogicalChannelNumber;
+                    pLCEntry = LCBLCIncoming.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyCLC._0404_0010(pLCEntry) ;
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_CLC_RJT : /* RequestChannelCloseReject */
+                    Print("Received CLC RequestChannelCloseReject\n");
+                    lcn = ((PS_RequestChannelCloseReject)((uint8*)pParameter))->forwardLogicalChannelNumber;
+                    pLCEntry = LCBLCIncoming.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyCLC._0405_0010(pLCEntry, (PS_RequestChannelCloseReject)((uint8*)pParameter)) ;
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_TIM_CLC_T108 : /* Timer T108 Timeout */
+                    Print("Received CLC Timeout T108\n");
+                    lcn = Supplement_2;
+                    pLCEntry = LCBLCIncoming.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Incoming %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyCLC._0406_0010(pLCEntry, Supplement_1) ;
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_CLC_RLS : /* RequestChannelCloseRelease */
+                    Print("Received CLC RequestChannelCloseRelease\n");
+                    lcn = ((PS_RequestChannelCloseRelease)((uint8*)pParameter))->forwardLogicalChannelNumber;
+                    pLCEntry = LCBLCOutgoing.GetLCEntry(lcn);
+                    if (pLCEntry == NULL)
+                    {
+                        ItnErrNotificationSend(ITN_ERR_CODE_0002 , EVENT_LCSE) ;
+                        break;
+                    }
+                    else
+                    {
+                        Print("    Using existing Logical Channel Entry : Outgoing %d %d\n", pLCEntry->FwdLcnRead(), pLCEntry->RvsLcnRead());
+                    }
+                    Se_Status = pLCEntry->ClcStatusRead();
+                    switch (Se_Status)  /* Close Logical Chennel Status Check */
+                    {
+                        case    CLS_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    CLS_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    CLS_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    CLS_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyCLC._0407_0011(pLCEntry) ;
+                            break ;
+                    }
+                    break ;
+            }
+            break ;
+        case    EVENT_MTSE : /* Multiplex Table Signalling Entity */
+            /* Multiplex Table Status Read */
+            Se_Status2 = MyMT.StatusRead2() ;	/* WWU_H245_TWOWAY */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_MT_TRF_REQ : /* TRANSFER.request */
+                    Print("Received MT Transfer.Request\n");
+                    MyMT.TransferRequest((PS_MuxDescriptor)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_MT : /* MultiplexEntrySend */
+                    Print("Received MT MultiplexEntrySend\n");
+                    switch (Se_Status2)  /* Multiplex Table Status Check */
+                    {
+                        case    MT_INCOMING_IDLE : /* Incoming Idle */
+                            MyMT._0501_0001((PS_MultiplexEntrySend)((uint8*)pParameter)) ;
+                            break ;
+                        case    MT_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMT._0501_0011((PS_MultiplexEntrySend)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_MT_TRF_RPS : /* TRANSFER.response */
+                    Print("Received MT Transfer.Response\n");
+                    switch (Se_Status2)  /* Multiplex Table Status Check */
+                    {
+                        case    MT_INCOMING_IDLE : /* Incoming Idle */
+                            /* Internal Error Notification ( To TSC ) */
+                            ItnErrNotificationSend(ITN_ERR_CODE_0002 , Event_No & Se_Status2) ;
+                            break ;
+                        case    MT_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMT._0502_0011(Supplement_1, (PS_MuxDescriptor)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_MT_RJT_REQ : /* REJECT.request */
+                    Print("Received MT Reject.Request\n");
+                    switch (Se_Status2)  /* Multiplex Table Status Check */
+                    {
+                        case    MT_OUTGOING_IDLE : /* Outgoing Idle */
+                        case    MT_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                        case    MT_INCOMING_IDLE : /* Incoming Idle */
+                            /* Internal Error Notification ( To TSC ) */
+                            ItnErrNotificationSend(ITN_ERR_CODE_0002 , Event_No & Se_Status2) ;
+                            break ;
+                        case    MT_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMT._0503_0011((PS_MeRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_MT_ACK : /* MultiplexEntrySendAck */
+                    Print("Received MT MultiplexEntrySendAck\n");
+                    MyMT.MultiplexEntrySendAck((PS_MultiplexEntrySendAck)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_MT_RJT : /* MultiplexEntrySendReject */
+                    Print("Received MT MultiplexEntrySendReject\n");
+                    MyMT.MultiplexEntrySendReject((PS_MultiplexEntrySendReject)((uint8*)pParameter));
+                    break ;
+                case    EVENT_MSG_MT_RLS : /* MultiplexEntrySendRelease */
+                    Print("Received MT MultiplexEntrySendRelease\n");
+                    switch (Se_Status2)  /* Multiplex Table Status Check */
+                    {
+                        case    MT_OUTGOING_IDLE : /* Outgoing Idle */
+                        case    MT_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            /* Internal Error Notification ( To TSC ) */
+                            ItnErrNotificationSend(ITN_ERR_CODE_0002 , Event_No & Se_Status2) ;
+                            break ;
+                        case    MT_INCOMING_IDLE : /* Incoming Idle */
+                            Nop_XXXX_XXXX() ;
+                            break ;
+                        case    MT_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMT._0507_0011() ;
+                            break ;
+                    }
+                    break ;
+            }
+            break ;
+        case    EVENT_RMESE : /* Request Multiplex Entry Signalling Entity */
+            /* Request Multiplex Entry Status Read */
+            Se_Status = MyRME.StatusRead() ;
+            Se_Status2 = MyRME.StatusRead2() ;	/* H245_TWOWAY */
+            /* Note: Se_Status is OUTGOING, Se_Status2 is INCOMING */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_RME_SEND_REQ : /* SEND.request */
+                    Print("Received RME Send.Request\n");
+                    switch (Se_Status)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            MyRME._0600_0000() ;
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_RME : /* RequestMultiplexEntry */
+                    Print("Received RME RequestMultiplexEntry\n");
+                    switch (Se_Status2)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            MyRME._0601_0001((PS_RequestMultiplexEntry)((uint8*)pParameter)) ;
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyRME._0601_0011((PS_RequestMultiplexEntry)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_RME_SEND_RPS : /* SEND.responsse */
+                    Print("Received RME Send.Response\n");
+                    switch (Se_Status2)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyRME._0602_0011() ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_RME_RJT_REQ : /* REJECT.request */
+                    Print("Received RME Reject.Request\n");
+                    switch (Se_Status2)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyRME._0603_0011((PS_RmeRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_RME_ACK : /* RequestMultiplexEntryAck */
+                    Print("Received RME RequestMultiplexEntryAck\n");
+                    switch (Se_Status)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            MyRME._0604_0010((PS_RequestMultiplexEntryAck)((uint8*)pParameter)) ;
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_RME_RJT : /* RequestMultiplexEntryReject */
+                    Print("Received RME RequestMultiplexEntryReject\n");
+                    switch (Se_Status)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            MyRME._0605_0010((PS_RequestMultiplexEntryReject)((uint8*)pParameter)) ;
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_TIM_RME_T107 : /* Timer T107 Timeout */
+                    Print("Received RME Timeout T107\n");
+                    switch (Se_Status)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            MyRME._0606_0010(Supplement_1) ;
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_RME_RLS : /* RequestMultiplexEntryRelease */
+                    Print("Received RME RequestMultiplexEntryRelease\n");
+                    switch (Se_Status2)  /* Request Multiplex Entry Status Check */
+                    {
+                        case    RME_OUTGOING_IDLE : /* Outgoing Idle */
+                            break ;
+                        case    RME_OUTGOING_AWTING_RPS : /* Outgoing Awaitimg Response */
+                            break ;
+                        case    RME_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    RME_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyRME._0607_0011((PS_RequestMultiplexEntryRelease)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+            }
+            break ;
+        case    EVENT_MRSE : /* Mode Request Signalling Entry */
+            /* Mode Request Status Read */
+            Se_Status = MyMR.StatusRead() ;
+            Se_Status2 = MyMR.StatusRead2() ;
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_MR_TRF_REQ : /* TRANSFER.request */
+                    Print("Received MR Transfer.Request\n");
+                    switch (Se_Status)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            MyMR._0700_0000((PS_RequestMode)((uint8*)pParameter)) ;
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyMR._0700_0010((PS_RequestMode)((uint8*)pParameter)) ;
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_MR : /* RequestMode */
+                    Print("Received MR RequestMode\n");
+                    switch (Se_Status2)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            MyMR._0701_0001((PS_RequestMode)((uint8*)pParameter)) ;
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMR._0701_0011((PS_RequestMode)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_MR_TRF_RPS : /* TRANSFER.response */
+                    Print("Received MR Transfer.Response\n");
+                    switch (Se_Status2)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMR._0702_0011((PS_Response)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_MR_RJT_REQ : /* REJECT.request */
+                    Print("Received MR Reject.Request\n");
+                    switch (Se_Status2)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMR._0703_0011((PS_RmRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_MR_ACK : /* RequestModeAck */
+                    Print("Received MR RequestModeAck\n");
+                    switch (Se_Status)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyMR._0704_0010((PS_RequestModeAck)((uint8*)pParameter)) ;
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_MR_RJT : /* RequestModeReject */
+                    Print("Received MR RequestModeReject\n");
+                    switch (Se_Status)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyMR._0705_0010((PS_RequestModeReject)((uint8*)pParameter)) ;
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_TIM_MR_T109 : /* Timer T109 Timeout */
+                    Print("Received MR Timeout T109\n");
+                    switch (Se_Status)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyMR._0706_0010(Supplement_1) ;
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_MR_RLS : /* RequestModeReject */
+                    Print("Received MR RequestModeReject\n");
+                    switch (Se_Status2)  /* Mode Request Status Check */
+                    {
+                        case    MR_OUTGOING_IDLE : /* OutGoing Idle */
+                            break ;
+                        case    MR_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    MR_INCOMING_IDLE : /* Incoming Idle */
+                            break ;
+                        case    MR_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyMR._0707_0011() ;
+                            break ;
+                    }
+                    break ;
+            }
+            break ;
+        case    EVENT_RTDSE : /* Round Trip Delay Signaling Entity */
+            /* Round Trip Delay Status Read */
+            Se_Status = MyRTD.StatusRead() ;
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_RTD_TRF_REQ : /* TRANSFER.request */
+                    Print("Received RTD Transfer.Request\n");
+                    switch (Se_Status)  /* Round Trip Delay Status Check */
+                    {
+                        case    RTD_IDLE : /* Idle */
+                            MyRTD._0800_0000() ;
+                            break ;
+                        case    RTD_AWTING_RPS : /* Awaiting Response */
+                            MyRTD._0800_0010() ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_RTD_REQ : /* RoundTripDelayRequest */
+                    Print("Received RTD RoundTripDelayRequest\n");
+                    switch (Se_Status)  /* Round Trip Delay Status Check */
+                    {
+                        case    RTD_IDLE : /* Idle */
+                        case    RTD_AWTING_RPS : /* Awaiting Response */
+                            MyRTD._0801_0000((PS_RoundTripDelayRequest)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_RTD_RPS : /* RoundTripDelayResponse */
+                    Print("Received RTD RoundTripDelayResponse\n");
+                    switch (Se_Status)  /* Round Trip Delay Status Check */
+                    {
+                        case    RTD_IDLE : /* Idle */
+                            break ;
+                        case    RTD_AWTING_RPS : /* Awaiting Response */
+                            MyRTD._0802_0010((PS_RoundTripDelayResponse)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_TIM_RTD_T105 : /* Timer T105 Timeout */
+                    Print("Received RTD Timeout T105\n");
+                    switch (Se_Status)  /* Round Trip Delay Status Check */
+                    {
+                        case    RTD_IDLE : /* Idle */
+                            break ;
+                        case    RTD_AWTING_RPS : /* Awaiting Response */
+                            MyRTD._0803_0010(Supplement_1) ;
+                            break ;
+                    }
+                    break ;
+            }
+            break ;
+        case    EVENT_MLSE : /* Maintenance Loop Signalling Entity */
+            /* Maintenance Loop Status Read */
+            Se_Status = MyML.StatusRead() ;
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_ML_LOOP_REQ : /* LOOP.request */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            MyML._0900_0000((PS_MlRequestType)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_ML_RLS_REQ : /* RELEASE.request */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyML._0901_0010((PS_MlRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            MyML._0901_0020((PS_MlRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyML._0901_0011((PS_MlRejectCause)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_ML_REQ : /* MaintenanceLoopRequest */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            MyML._0902_0001((PS_MaintenanceLoopRequest)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            MyML._0902_0011((PS_MaintenanceLoopRequest)((uint8*)pParameter)) ;
+                            break ;
+                    }
+                    break ;
+                case    EVENT_PTV_ML_LOOP_RPS : /* LOOP.response */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            MyML._0903_0011() ;
+                            break ;
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_ML_ACK : /* MaintenanceLoopAck */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyML._0904_0010((PS_MaintenanceLoopAck)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_ML_RJT : /* MaintenanceLoopReject */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyML._0905_0010((PS_MaintenanceLoopReject)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            MyML._0905_0020((PS_MaintenanceLoopReject)((uint8*)pParameter)) ;
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_TIM_ML_T102 : /* Timer T102 Timeout */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            MyML._0906_0010(Supplement_1) ;
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                            break ;
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            break ;
+                    }
+                    break ;
+                case    EVENT_MSG_ML_OFF_CMD : /* MaintenanceLoopOffCommand */
+                    switch (Se_Status)  /* Maintenance Loop Status Check */
+                    {
+                        case    ML_OUTGOING_NOT_LOOPED : /* Outgoing Not Looped */
+                            break ;
+                        case    ML_OUTGOING_AWTING_RPS : /* Outgoing Awaiting Response */
+                            break ;
+                        case    ML_OUTGOING_LOOPED : /* Outgoing Looped */
+                            break ;
+                        case    ML_INCOMING_NOT_LOOPED : /* Incoming Not Looped */
+                            break ;
+                        case    ML_INCOMING_AWTING_RPS : /* Incoming Awaiting Response */
+                        case    ML_INCOMING_LOOPED : /* Incoming Looped */
+                            MyML._0907_0011() ;
+                            break ;
+                    }
+                    break ;
+            }
+            break ;
+        case    EVENT_NSD : /* Non Standard */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_NSD_REQ : /* NonStandardMessageRequest Primitive */
+                    MyNSD._1000_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_NSD_REQ : /* NonStandardMessageRequest */
+                    MyNSD._1001_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_NSD_RPS : /* NonStandardMessageResponse Primitive */
+                    MyNSD._1002_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_NSD_RPS : /* NonStandardMessageResponse */
+                    MyNSD._1003_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_NSD_CMD : /* NonStandardMessageCommand Primitive */
+                    MyNSD._1004_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_NSD_CMD : /* NonStandardMessageCommand */
+                    MyNSD._1005_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_NSD_IDC : /* NonStandardMessageIndication Primitive */
+                    MyNSD._1006_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_NSD_IDC : /* NonStandardMessageIndication */
+                    MyNSD._1007_XXXX((PS_NonStandardMessage)((uint8*)pParameter)) ;
+                    break ;
+            }
+            break ;
+        case    EVENT_CM : /* Communication Mode */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_CM_REQ : /* CommunicationModeRequest Primitive */
+                    MyCM._1100_XXXX((PS_CommunicationModeRequest)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CM_REQ : /* CommunicationModeRequest */
+                    MyCM._1101_XXXX((PS_CommunicationModeRequest)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CM_RPS : /* CommunicationModeResponse Primitive */
+                    MyCM._1102_XXXX((PS_CommunicationModeResponse)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CM_RPS : /* CommunicationModeResponse */
+                    MyCM._1103_XXXX((PS_CommunicationModeResponse)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CM_CMD : /* CommunicationModeCommand Primitive */
+                    MyCM._1104_XXXX((PS_CommunicationModeCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CM_CMD : /* CommunicationModeCommand */
+                    MyCM._1105_XXXX((PS_CommunicationModeCommand)((uint8*)pParameter)) ;
+                    break ;
+            }
+            break ;
+        case    EVENT_H223AAR : /* H223 Annex A Reconfiguration */
+            /* ---------------------------------- */
+            /* H223AnnexAReConfiguration Removed. */
+            /* (Not a 245 codeword) (RAN)         */
+            /* ---------------------------------- */
+            break ;
+        case    EVENT_CNF : /* Conference */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_CNF_REQ : /* ConferenceRequest Primitive */
+                    MyCNF._1300_XXXX((PS_ConferenceRequest)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CNF_REQ : /* ConferenceRequest */
+                    MyCNF._1301_XXXX((PS_ConferenceRequest)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CNF_RPS : /* ConferenceResponse Primitive */
+                    MyCNF._1302_XXXX((PS_ConferenceResponse)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CNF_RPS : /* ConferenceResponse */
+                    MyCNF._1303_XXXX((PS_ConferenceResponse)((uint8*)pParameter)) ;
+                    break ;
+            }
+            break ;
+        case    EVENT_CMD : /* Command */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_CMD_STCS : /* SendTerminalCapabilitySet Primitive */
+                    MyCMD._1400_XXXX((PS_SendTerminalCapabilitySet)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_STCS : /* SendTerminalCapabilitySet */
+                    MyCMD._1401_XXXX((PS_SendTerminalCapabilitySet)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CMD_ECRPT : /* EncryptionCommand Primitive */
+                    MyCMD._1402_XXXX((PS_EncryptionCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_ECRPT : /* EncryptionCommand */
+                    MyCMD._1403_XXXX((PS_EncryptionCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CMD_FC : /* FlowControlCommand Primitive */
+                    MyCMD._1404_XXXX((PS_FlowControlCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_FC : /* FlowControlCommand */
+                    MyCMD._1405_XXXX((PS_FlowControlCommand)((uint8*)pParameter), EncodedMsg, EncodedMsgSize) ;
+                    break ;
+                case    EVENT_PTV_CMD_ES : /* ENDSESSION */
+                    MyCMD._1406_XXXX((PS_EndSessionCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_ES : /* EndSessionCommand */
+                    MyCMD._1407_XXXX((PS_EndSessionCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CMD_MSCL : /* MiscellaneousCommand Primitive */
+                    MyCMD._1408_XXXX((PS_MiscellaneousCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_MSCL : /* MiscellaneousCommand */
+                    MyCMD._1409_XXXX((PS_MiscellaneousCommand)((uint8*)pParameter), EncodedMsg, EncodedMsgSize) ;
+                    break ;
+                case    EVENT_PTV_CMD_CNF : /* ConferenceCommand Primitive */
+                    MyCMD._140A_XXXX((PS_ConferenceCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_CNF : /* ConferenceCommand */
+                    MyCMD._140B_XXXX((PS_ConferenceCommand)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_CMD_HMR : /* H223MultiplexReconfiguration Primitive */
+                    MyCMD._140C_XXXX((PS_H223MultiplexReconfiguration)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_CMD_HMR : /* H223MultiplexReconfiguration */
+                    MyCMD._140D_XXXX((PS_H223MultiplexReconfiguration)((uint8*)pParameter), EncodedMsg, EncodedMsgSize) ;
+                    break ;
+
+            }
+            break ;
+        case    EVENT_IDC : /* Indication */
+            switch (Event_No)  /* Event No Check */
+            {
+                case    EVENT_PTV_IDC_FNU : /* FunctionNotUnderstood Primitive */
+                    MyIDC._1500_XXXX((PS_FunctionNotUnderstood)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_FNU : /* FunctionNotUnderstood */
+                    MyIDC._1501_XXXX((PS_FunctionNotUnderstood)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_MSCL : /* MiscellaneousIndication Primitive */
+                    MyIDC._1502_XXXX((PS_MiscellaneousIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_MSCL : /* MiscellaneousIndication */
+                    MyIDC._1503_XXXX((PS_MiscellaneousIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_JTR : /* JitterIndication Primitive */
+                    MyIDC._1504_XXXX((PS_JitterIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_JTR : /* JitterIndication */
+                    MyIDC._1505_XXXX((PS_JitterIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_H223SKW : /* H223SkewIndication Primitive */
+                    MyIDC._1506_XXXX((PS_H223SkewIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_H223SKW : /* H223SkewIndication */
+                    MyIDC._1507_XXXX((PS_H223SkewIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_NWATMVC : /* NewATMVCIndication Primitive */
+                    MyIDC._1508_XXXX((PS_NewATMVCIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_NWATMVC : /* NewATMVCIndication */
+                    MyIDC._1509_XXXX((PS_NewATMVCIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_UI : /* UserInputIndication Primitive */
+                    MyIDC._150A_XXXX((PS_UserInputIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_UI : /* UserInputIndication */
+                    MyIDC._150B_XXXX((PS_UserInputIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_CNF : /* ConferenceIndication Primitive */
+                    MyIDC._150C_XXXX((PS_ConferenceIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_CNF : /* ConferenceIndication */
+                    MyIDC._150D_XXXX((PS_ConferenceIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_H2250MXSKW : /* H2250MaximumSkewIndication Primitive */
+                    MyIDC._150E_XXXX((PS_H2250MaximumSkewIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_H2250MXSKW : /* H2250MaximumSkewIndication */
+                    MyIDC._150F_XXXX((PS_H2250MaximumSkewIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_MCLCT : /* MCLocationIndication Primitive */
+                    MyIDC._1510_XXXX((PS_MCLocationIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_MCLCT : /* MCLocationIndication */
+                    MyIDC._1511_XXXX((PS_MCLocationIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_VI : /* VendorIdentification Primitive */
+                    MyIDC._1512_XXXX((PS_VendorIdentification)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_VI : /* VendorIdentification */
+                    MyIDC._1513_XXXX((PS_VendorIdentification)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_FNS : /* FunctionNotSupported Primitive */
+                    MyIDC._1514_XXXX((PS_FunctionNotSupported)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_FNS : /* FunctionNotSupported */
+                    MyIDC._1515_XXXX((PS_FunctionNotSupported)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_MSG_IDC_FC : /* FlowControlIndication  */
+                    MyIDC._1516_XXXX((PS_FlowControlIndication)((uint8*)pParameter)) ;
+                    break ;
+                case    EVENT_PTV_IDC_FC : /* FlowControlIndication Primitive */
+                    MyIDC._1517_XXXX((PS_FlowControlIndication)((uint8*)pParameter)) ;
+                    break ;
+            }
+            break ;
+    }
+
+    return ;
+}
+
+/************************************************************************/
+/*  function name       : ItnErrNotificationSend                     */
+/*  function outline    : Internal Error Notification                   */
+/*                      :                    to Terminal Status Control */
+/*  function discription: ItnErrNotificationSend( uint32 , uint32 )      */
+/*  input data          : uint32 Error_Inf_1                              */
+/*                      : uint32 Error_Inf_2                              */
+/*  output data         : None                                          */
+/*  draw time           : '96.11.15                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                                                                      */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SE::ItnErrNotificationSend(uint32 Error_Inf_1 , uint32 Error_Inf_2)
+{
+    S_InfHeader    infHeader ;
+
+    infHeader.pParameter = NULL;
+
+    infHeader.InfType = H245_ERROR ;
+    infHeader.InfId = H245_INTERNAL_ERROR_SE ;
+    infHeader.InfSupplement1 = Error_Inf_1 ;
+    infHeader.InfSupplement2 = Error_Inf_2 ;
+
+    Print("Sending ItnErrNotification Msg\n");
+
+    if (MyH245)
+    {
+        MyH245->ObserverMessage((unsigned char*)&infHeader, sizeof(S_InfHeader));
+    }
+}
+
+void SE::Print(const char *format, ...)
+{
+    OSCL_UNUSED_ARG(format);
+
+    PVLOGGER_LOG_USE_ONLY(va_list args);
+    PVLOGGER_LOG_USE_ONLY(va_start(args, format));
+    PVLOGGER_LOGMSG_V(PVLOGMSG_INST_LLDBG, Logger, PVLOGMSG_DEBUG, (0, format, args));
+    PVLOGGER_LOG_USE_ONLY(va_end(args));
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h245/se/src/sebase.cpp b/protocols/systems/3g-324m_pvterminal/h245/se/src/sebase.cpp
new file mode 100644
index 0000000..f065f4e
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h245/se/src/sebase.cpp
@@ -0,0 +1,80 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "sebase.h"
+#include "se.h"
+#include "per.h"
+#include "h245.h"
+#include "oscl_snprintf.h"
+#include "pvlogger.h"
+
+SEBase::SEBase() : TimerDuration(TIMER_DURATION), MySE(0), MyPer(0), MyH245(0)
+{
+    Logger = PVLogger::GetLoggerObject("3g324m.h245.se");
+}
+
+void SEBase::MessageSend(PS_H245Msg pMsg)
+{
+    if (MyPer)
+    {
+        MyPer->Encode(pMsg);
+    }
+}
+
+OSCL_EXPORT_REF void SEBase::MessageSend(uint32 type1, uint32 type2, uint8 *pdata)
+{
+    S_H245Msg h245Msg ;
+
+    h245Msg.Type1 = (uint8)type1;
+    h245Msg.Type2 = (uint8)type2 ;
+    h245Msg.pData = pdata;
+
+    MessageSend(&h245Msg) ;
+}
+
+void SEBase::PrimitiveSend(PS_InfHeader pPrimitive)
+{
+    if (MyH245)
+    {
+        MyH245->ObserverMessage((unsigned char*)pPrimitive, sizeof(S_InfHeader));
+    }
+}
+
+void SEBase::RequestTimer(int32 timerID, int32 timeoutInfo, int32 count, OsclTimerObserver *observer)
+{
+    if (MySE)
+    {
+        MySE->RequestTimer(timerID, timeoutInfo, count, observer);
+    }
+}
+
+void SEBase::CancelTimer(int32 timerID)
+{
+    if (MySE)
+    {
+        MySE->CancelTimer(timerID);
+    }
+}
+
+OSCL_EXPORT_REF void SEBase::Print(const char *format, ...)
+{
+    OSCL_UNUSED_ARG(format);
+    PVLOGGER_LOG_USE_ONLY(va_list args);
+    PVLOGGER_LOG_USE_ONLY(va_start(args, format));
+    PVLOGGER_LOGMSG_V(PVLOGMSG_INST_LLDBG, Logger, PVLOGMSG_VERBOSE, (0, format, args));
+    PVLOGGER_LOG_USE_ONLY(va_end(args));
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/srp/include/srp.h b/protocols/systems/3g-324m_pvterminal/h324/srp/include/srp.h
new file mode 100644
index 0000000..371a230
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/srp/include/srp.h
@@ -0,0 +1,617 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef SRP_H
+#define SRP_H
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_TIMER_H_INCLUDED
+#include "oscl_timer.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_port_interface.h"
+#endif
+
+#ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
+#include "pvmf_media_frag_group.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#include "crccheck_cpp.h"
+
+
+/* SRP frame information */
+#define SRP_HEADER_SIZE		1
+#define SRP_SEQUENCE_SIZE	1
+#define SRP_FCS_SIZE		2
+#define CCSRL_HEADER_SIZE	1
+#define SRP_COMMAND_HEADER	0xF9
+#define SRP_RESPONSE_HEADER	0xFB
+#define NSRP_RESPONSE_HEADER 0xF7
+#define MINIMUM_FRAME_SIZE  SRP_HEADER_SIZE+SRP_FCS_SIZE
+#define DEFAULT_CCSRL_SIZE	256
+#define INTERMEDIATE_CCSRL_CHUNK 0x00
+#define LAST_CCSRL_CHUNK 0xFF
+#define DEFAULT_SEND_QUEUE_SIZE 24
+#define MAX_SEND_FRAGS_PER_MSG 4 //Header + CCSRL + data + FCS frags
+#define MAX_RESP_MSGS 24
+
+/* CRC definition */
+#define  GX_CRC_12    0x1021  /* CRC Generate matrix ( G(X) = X^16 + X^12 + X^5 + 1j */
+
+
+/* Fragment pool definition */
+#define MAX_SIZE_OF_SRP_HEADER (SRP_HEADER_SIZE+SRP_SEQUENCE_SIZE+SRP_FCS_SIZE)
+#define MAX_SIZE_OF_SRP_PDU 1024 /* Thie is the AL1 SDU size */
+
+/* WNSRP definitions */
+#define WNSRP_COMMAND_HEADER 0xF1
+#define WNSRP_RESPONSE_HEADER 0xF3
+#define DEFAULT_WNSRP_WINDOW 5
+#define N402_DEFAULT_MAX_COUNTER 3 /* Number of SRP/NSRP frames to accept before dropping out of WNSRP mode */
+
+/* Timer definition */
+#define N400_DEFAULT_MAX_COUNTER 100
+#define T401_PRIMARY 	WNSRP_WINDOW /* Primary SRP timer id, set it to the WNSRP window, id for the WNSRP timers will be the array index */
+#define T401_RESOLUTION 10  // Set SRP timeout to 100ms
+#define T401_VALUE_DEFAULT 2 // Sets the default T401 timeout to 200ms
+
+/* Multiplex table entry definitions */
+#define SRP_NSRP_MT_ENTRY_NUMBER 0
+#define WNSRP_MT_ENTRY_NUMBER 15
+#define NUM_MT_ENTRY_NUMBERS 2 //Number of possible MT entry numbers SRP can send on (SRP/NSRP = 0, WNSRP = 15)
+#define MT_ENTRY_NUMBER_SIZE sizeof(uint8)
+
+/* TBD */
+#define SRP_INPUT_PORT_TAG 0
+#define SRP_OUTPUT_PORT_TAG 1
+
+class SRPStats
+{
+    public:
+        SRPStats() : totalFramesRecv(0),
+                totalInvalidSizeFramesRecv(0),
+                totalCRCErrorsRecv(0),
+                totalCommandFramesRecv(0),
+                totalWNSRPCommandFramesRecv(0),
+                totalInvalidCCSRLChunkRecv(0),
+                totalSRPRespRecv(0),
+                totalNSRPRespRecv(0),
+                totalWNSRPRespRecv(0),
+                totalH245MessagesRecv(0),
+                totalCCSRLChunksRecv(0),
+                totalCommandFramesSent(0),
+                totalH245MessagesToSend(0),
+                totalH245MessagesFragmented(0),
+                totalCCSRLChunksSent(0),
+                totalNumTimeouts(0),
+                totalBytesRecv(0),
+                totalBytesSent(0),
+                totalInvalidFrames(0),
+                minRespTime(0xFFFFFFFF),
+                maxRespTime(0),
+                aveRespTime(0) {};
+
+        ~SRPStats() {};
+
+        void Reset()
+        {
+            totalFramesRecv = 0;
+            totalInvalidSizeFramesRecv = 0;
+            totalCRCErrorsRecv = 0;
+            totalCommandFramesRecv = 0;
+            totalWNSRPCommandFramesRecv = 0;
+            totalInvalidCCSRLChunkRecv = 0;
+            totalSRPRespRecv = 0;
+            totalNSRPRespRecv = 0;
+            totalWNSRPRespRecv = 0;
+            totalH245MessagesRecv = 0;
+            totalCCSRLChunksRecv = 0;
+            totalCommandFramesSent = 0;
+            totalH245MessagesToSend = 0;
+            totalH245MessagesFragmented = 0;
+            totalCCSRLChunksSent = 0;
+            totalNumTimeouts = 0;
+            totalBytesRecv = 0;
+            totalBytesSent = 0;
+            totalInvalidFrames = 0;
+            minRespTime = 0xFFFFFFFF;
+            maxRespTime = 0;
+            aveRespTime = 0;
+        }
+
+        SRPStats &operator=(SRPStats &a)
+        {
+            totalFramesRecv = a.totalFramesRecv;
+            totalInvalidSizeFramesRecv = a.totalInvalidSizeFramesRecv;
+            totalCRCErrorsRecv = a.totalCRCErrorsRecv;
+            totalCommandFramesRecv = a.totalCommandFramesRecv;
+            totalWNSRPCommandFramesRecv = a.totalWNSRPCommandFramesRecv;
+            totalInvalidCCSRLChunkRecv = a.totalInvalidCCSRLChunkRecv;
+            totalSRPRespRecv = a.totalSRPRespRecv;
+            totalNSRPRespRecv = a.totalNSRPRespRecv;
+            totalWNSRPRespRecv = a.totalWNSRPRespRecv;
+            totalH245MessagesRecv = a.totalH245MessagesRecv;
+            totalCCSRLChunksRecv = a.totalCCSRLChunksRecv;
+            totalCommandFramesSent = a.totalCommandFramesSent;
+            totalH245MessagesToSend = a.totalH245MessagesToSend;
+            totalH245MessagesFragmented = a.totalH245MessagesFragmented;
+            totalCCSRLChunksSent = a.totalCCSRLChunksSent;
+            totalNumTimeouts = a.totalNumTimeouts;
+            totalBytesRecv = a.totalBytesRecv;
+            totalBytesSent = a.totalBytesSent;
+            totalInvalidFrames = a.totalInvalidFrames;
+            minRespTime = a.minRespTime;
+            maxRespTime = a.maxRespTime;
+            aveRespTime = a.aveRespTime;
+            return *this;
+        }
+
+        uint32 totalFramesRecv;
+        uint32 totalInvalidSizeFramesRecv;
+        uint32 totalCRCErrorsRecv;
+        uint32 totalCommandFramesRecv;
+        uint32 totalWNSRPCommandFramesRecv;
+        uint32 totalInvalidCCSRLChunkRecv;
+        uint32 totalSRPRespRecv;
+        uint32 totalNSRPRespRecv;
+        uint32 totalWNSRPRespRecv;
+        uint32 totalH245MessagesRecv;
+        uint32 totalCCSRLChunksRecv;
+        uint32 totalCommandFramesSent;
+        uint32 totalH245MessagesToSend;
+        uint32 totalH245MessagesFragmented;
+        uint32 totalCCSRLChunksSent;
+        uint32 totalNumTimeouts;
+        uint32 totalBytesRecv;
+        uint32 totalBytesSent;
+        uint32 totalInvalidFrames;
+        uint32 minRespTime;
+        uint32 maxRespTime;
+        uint32 aveRespTime;
+};
+
+
+class SRPObserver
+{
+    public:
+        virtual ~SRPObserver() {}
+        virtual void TransmissionFailure() = 0;
+        virtual void UseWNSRP(bool aUse) = 0;
+};
+
+typedef OsclSharedPtr<PVMFMediaDataImpl> PVMFSharedMediaDataImplPtr;
+
+class SRP : public OsclTimerObserver
+{
+    public:
+        /* structures used by SRP class */
+
+        enum SrpStatus {STS_IDLE = 0, STS_WAIT_RESPONSE, MAX_STATUS};
+        enum SrpEvent {EV_NOP = 0,			/* Unknown Event */
+                       EV_PDU,				/* PDU message */
+                       EV_COMMAND,			/* PRIMITIVE(DATA-COMMAND) */
+                       EV_RESPONSE,			/* PRIMITIVE(DATA-RESPONSE) */
+                       EV_NSRP_RESPONSE,	/* PRIMITIVE NSRP(DATA-RESPONSE) */
+                       EV_TIMEOUT,			/* Response wait timeout */
+                       EV_WNSRP_COMMAND,	/* WNSRP(DATA-COMMAND) */
+                       EV_WNSRP_RESPONSE,	/* WNSRP(DATA-RESPONSE) */
+                       MAX_EVENT
+                  };
+        enum SrpAction {ACTION_NOP = 0, ACTION_0_1, ACTION_0_2, ACTION_1_1, ACTION_1_3, ACTION_1_4};
+
+        enum WnsrpStatus {NO_WNSRP_SUPPORT, WNSRP_TX_SUPPORT, WNSRP_FULL_SUPPORT};
+
+
+
+        /* methods */
+        OSCL_IMPORT_REF SRP() ;
+        OSCL_IMPORT_REF virtual ~SRP() ;
+
+        OSCL_IMPORT_REF void SetObserver(SRPObserver *pObserver)
+        {
+            iObserver = pObserver;
+        }
+
+        /* srp_main.cpp */
+        OSCL_IMPORT_REF void SrpInitL(void);   /* Initialization method */
+        OSCL_IMPORT_REF void SrpReset(void);   /* Shutdown method */
+
+        OSCL_IMPORT_REF void SrpStart(void);   /* Restart SRP operations after stop. */
+        OSCL_IMPORT_REF void SrpStop(void);   /* Halt SRP operations, stop timers, flush queue, do not shutdown. */
+
+        /* srp_tim.cpp */
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+        void LowerLayerRx(PVMFSharedMediaDataPtr aData);
+        void UpperLayerRx(PVMFSharedMediaDataPtr aData);
+
+        void SetWNSRPTxWindow(uint32 window)
+        {
+            iWNSRPTxWindow = window;
+        }
+        void SetWNSRPRxWindow(uint32 window)
+        {
+            iWNSRPRxWindow = window;
+        }
+        void SetCCSRLSduSize(int size)
+        {
+            iCcsrlSduSize = size;
+        }
+
+        void UseNSRP(bool aUseNsrp = true);
+        void DisableWNSRPSupport();
+
+        void SetNumTxMsgs(uint32 numMsgs)
+        {
+            iNumTxMsgs = numMsgs;
+        }
+
+        void SrpResetStats();
+        void SrpGetStats(SRPStats &aStats);
+
+        //Number or times to retry sending SRP command before notifying upper layer of failure.
+        void SetNumSRPRetries(int maxRetries)
+        {
+            iN400MaxCounter = maxRetries;
+        }
+        //Actual timeout is (resolution * value).
+        void SetSRPTimeoutValue(int value)
+        {
+            iT401TimerValue = value;
+        }
+
+
+
+        PVMFPortInterface * RequestLLPort(const int32 aPortTag)
+        {
+            if (aPortTag == SRP_INPUT_PORT_TAG)
+            {
+                return iLLPortIn;
+            }
+            if (aPortTag == SRP_OUTPUT_PORT_TAG)
+            {
+                return iLLPortOut;
+            }
+
+            return NULL;
+        }
+
+        PVMFPortInterface * RequestULPort(const int32 aPortTag)
+        {
+            if (aPortTag == SRP_INPUT_PORT_TAG)
+            {
+                return iULPortIn;
+            }
+            if (aPortTag == SRP_OUTPUT_PORT_TAG)
+            {
+                return iULPortOut;
+            }
+
+            return NULL;
+        }
+
+        WnsrpStatus WnsrpStatusGet(void)
+        {
+            return(iCurWnsrpStatus);
+        }
+    private:
+
+        class SRPRxData
+        {
+            public:
+                SRPRxData() : seqNum(0),
+                        next(NULL)
+                {};
+
+                uint8 seqNum;
+                PVMFSharedMediaDataPtr data;
+                SRPRxData *next;
+        };
+
+        bool AllocateRxPacket(OsclSharedPtr<PVMFMediaDataImpl>& data, SRPRxData* rxData);
+        bool CreateMediaData(SRPRxData* rxData, OsclSharedPtr<PVMFMediaDataImpl> data);
+        bool Allocate(OsclSharedPtr<PVMFMediaDataImpl>& data, OsclRefCounterMemFrag& CCSRLFrag);
+        bool CreateMediaData(PVMFSharedMediaDataPtr& srpPkt,
+                             OsclSharedPtr<PVMFMediaDataImpl> data);
+
+        class SRPRespTimer
+        {
+            public:
+                SRPRespTimer() : T401Timer("SRPTimer"),
+                        timerID(0),
+                        N400Counter(0),
+                        isTimerActive(false)
+                {};
+
+                ~SRPRespTimer() {};
+
+                OsclTimer<OsclMemAllocator> T401Timer;
+                int32 timerID;
+                int	N400Counter;
+                bool isTimerActive;
+                PVMFSharedMediaDataPtr pPkt;
+        };
+
+        /* srp_cnt.cpp */
+        int SrpN400Check(SRPRespTimer &timer);
+
+        /* WNSRP counter */
+        void SrpN402Initialize(void);
+        void SrpN402Clear(void)
+        {
+            iN402Counter = 0;
+        }
+        void SrpN402Count(void)
+        {
+            ++iN402Counter;
+        }
+        int SrpN402Check();
+
+        /* srp_crc.cpp */
+        void CrcClear(void)
+        {
+            iCrcData = 0;
+        }
+        void CrcCalc(uint8 *pData, int Size);
+        uint16 CrcResultGet(void);
+        void CrcSetToFrame(uint16 crc, uint8 *pFcs);
+
+        /* srp_edit.cpp */
+        PVMFSharedMediaDataPtr SrpCommandCreate(PVMFSharedMediaDataPtr pPkt, uint8 header);
+        void SrpCommandClear(uint32 seqNum);
+        PVMFSharedMediaDataPtr SrpResponseCreate(uint8 seqNum, uint8 header);
+
+        /* srp_main.cpp */
+        SrpEvent SrpGetEventNoFromAL1(PVMFSharedMediaDataPtr pPkt);
+
+        bool SrpMsgCopy(PVMFSharedMediaDataPtr inPkt);
+
+        /* srp_prot.cpp */
+        int SrpNop()
+        {
+            return 1;
+        }
+        int Srp_0_1();
+        int Srp_0_2(PVMFSharedMediaDataPtr pPkt, int event);
+        int Srp_1_1();
+        int Srp_1_3(PVMFSharedMediaDataPtr pPkt, int event);
+        int Srp_1_4(int32 id);
+
+        /* srp_que.cpp */
+        void SrpSendWaitSet(PVMFSharedMediaDataPtr pPkt)
+        {
+            iSrpWaitQueue.push_back(pPkt);
+        }
+        PVMFSharedMediaDataPtr SrpSendWaitGet(uint32 index);
+        int SrpSendWaitRemove(uint32 index);
+
+        /* srp_seq.cpp */
+        void SrpSendSeqClear(void)
+        {
+            iSendSeqNumber = 0;
+        }
+        void SrpSendSeqCount(void);
+        uint32 SrpSendSeqGet(void)
+        {
+            return(iSendSeqNumber);
+        }
+        void SrpRecvSeqClear(void)
+        {
+            iRecvSeqNumber = 0;
+            iOldestWNSRPRetransSeqNum = (iRecvSeqNumber - ((256 - iWNSRPRxWindow) / 2)) % 256;
+        }
+        void SrpRecvSeqCount(void);
+        uint32 SrpRecvSeqGet(void)
+        {
+            return(iRecvSeqNumber);
+        }
+        void SrpRecvSeqSet(uint8 seqNo)
+        {
+            iRecvSeqNumber = seqNo;
+        }
+
+        /* srp_sts.cpp */
+        void SrpStatusSet(SrpStatus newStatus) ;
+        SrpStatus SrpStatusGet(void)
+        {
+            return(iStatus);
+        }
+
+        /* WNSRP status */
+        void WnsrpStatusSet(WnsrpStatus newStatus) ;
+
+        /* srp_tim.cpp */
+        void SrpT401Start(SRPRespTimer &timer, PVMFSharedMediaDataPtr pPkt);
+        void SrpT401Stop(SRPRespTimer &timer);
+
+
+        /* Layer sendto interfaces.*/
+        void LowerLayerTx(PVMFSharedMediaDataPtr pPkt)
+        {
+            if (iLLPortOut)
+            {
+                iStats.totalBytesSent += pPkt->getFilledSize();
+
+                PVMFSharedMediaMsgPtr mediaMsg;
+                convertToPVMFMediaMsg(mediaMsg, pPkt);
+                iLLPortOut->QueueOutgoingMsg(mediaMsg);
+                iLLPortOut->Send();
+            }
+        }
+        void UpperLayerTx(PVMFSharedMediaDataPtr pPkt)
+        {
+            if (iULPortOut)
+            {
+                iStats.totalBytesSent += pPkt->getFilledSize();
+
+                PVMFSharedMediaMsgPtr mediaMsg;
+                convertToPVMFMediaMsg(mediaMsg, pPkt);
+                iULPortOut->QueueOutgoingMsg(mediaMsg);
+                iULPortOut->Send();
+            }
+        }
+
+        int SrpStateChange(int status, int event, void *data);
+
+        void UpdateRespStats();
+
+        SRPRespTimer *GetFreeWnsrpTimer();
+        void FreeWnsrpTimer(SRPRespTimer *timer)
+        {
+            iFreeWnsrpCommandSave.push_back(timer);
+        }
+        void AddActiveWnsrpTimer(SRPRespTimer *timer)
+        {
+            iActiveWnsrpCommandSave.push_back(timer);
+        }
+        SRPRespTimer *FindActiveWnsrpTimer(int32 timerID);
+        void RemoveActiveWnsrpTimer(SRPRespTimer *timer);
+
+        void FreeRxFrag(SRPRxData *frag);
+        SRPRxData *GetRxFrag();
+
+        void AddPendingRxFrag(SRPRxData *frag);
+        bool CheckRxSeqNum(uint32 seqNum, uint8 header);
+        bool CheckPendingRxList(uint32 seqNum);
+        bool CheckWNSRPRetrans(uint32 seqNum);
+
+        static const SRP::SrpAction iSrpStateTable[MAX_STATUS][MAX_EVENT];
+
+        /* Counter data */
+        int	iN400MaxCounter;
+
+        /* WNSRP counter data */
+        int	iN402MaxCounter;
+        int	iN402Counter;
+
+        /* CRC data */
+        CRC iCrc;
+        uint32	iCrcData;
+
+        /* Queue data */
+        Oscl_Vector<PVMFSharedMediaDataPtr, OsclMemAllocator> iSrpWaitQueue;
+
+        /* Seq data */
+        uint32 iSendSeqNumber;
+        uint32 iRecvSeqNumber;
+
+        /* Status data */
+        SrpStatus	iStatus;
+        WnsrpStatus iCurWnsrpStatus;
+
+        /* Timer data */
+        int	iT401TimerValue;
+
+        /* Commands that have not been acknowledged yet */
+        SRPRespTimer iSrpCommandSave;
+        SRPRespTimer *iWnsrpCommandSave;
+        Oscl_Vector<SRPRespTimer *, OsclMemAllocator> iFreeWnsrpCommandSave;
+        Oscl_Vector<SRPRespTimer *, OsclMemAllocator> iActiveWnsrpCommandSave;
+
+        /* CCSRL data */
+        unsigned int iCcsrlSduSize;
+
+        /* Received packet data */
+        SRPRxData *iRxFrags;
+        SRPRxData *iFreeRxFragList;
+        SRPRxData *iPendingRxFragList;
+
+
+        /* WWU_CCSRL: add end */
+        bool iFirstCmd;	/* WWU_RB8 */
+
+        PVMFPortInterface *iLLPortOut;
+        PVMFPortInterface *iLLPortIn;
+        PVMFPortInterface *iULPortOut;
+        PVMFPortInterface *iULPortIn;
+
+        OsclMemAllocator iMemAllocator;
+
+        OsclMemPoolFixedChunkAllocator* iTxMediaMsgPoolAlloc;
+        OsclMemPoolFixedChunkAllocator* iTxMediaDataImplMemAlloc;
+        PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>* iTxPacketAlloc;
+
+        OsclMemPoolFixedChunkAllocator* iOutstandingTxMediaMsgPoolAlloc;
+        OsclMemPoolFixedChunkAllocator* iOutstandingTxMediaDataImplMemAlloc;
+
+        OsclMemPoolFixedChunkAllocator* iRxMediaMsgPoolAlloc;
+        OsclMemPoolFixedChunkAllocator* iRxMediaDataImplMemAlloc;
+        PVMFSimpleMediaBufferCombinedAlloc *iRxPacketAlloc;
+
+        OsclMemPoolFixedChunkAllocator* iRespMediaMsgPoolAlloc;
+        OsclMemPoolFixedChunkAllocator* iRespMemAlloc;
+        PVMFSimpleMediaBufferCombinedAlloc *iRespPacketAlloc;
+        OsclMemPoolFixedChunkAllocator* iNsrpRespMemAlloc;
+        PVMFSimpleMediaBufferCombinedAlloc *iNsrpRespPacketAlloc;
+
+        PVMFBufferPoolAllocator iHdrAllocator;
+        PVMFBufferPoolAllocator iCcsrlAllocator;
+        PVMFBufferPoolAllocator iFCSAllocator;
+        PVMFBufferPoolAllocator iMTEntryNumAllocator;
+
+        OsclRefCounterMemFrag iSrpNsrpEntryNumFrag;
+        OsclRefCounterMemFrag iWnsrpEntryNumFrag;
+
+        uint32 iNumTxMsgs;
+
+        bool iUseNSRP;
+        //If first NSRP response message was received.
+        bool iFirstNSRPResp;
+
+        //For testing purposes.  Always should support receiving WNSRP messages.
+        bool iHandleWNSRP;
+        uint32 iWNSRPTxWindow;
+        uint32 iWNSRPRxWindow;
+        uint32 iOldestWNSRPRetransSeqNum;
+
+        int iT401Resolution;
+        SRPObserver* iObserver;
+
+        SRPStats iStats;
+        uint32 iTotalRespTime;
+        TimeValue iInitialTimeChunkSent;
+
+        PVLogger *iLogger;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/srp/include/srp_ports.h b/protocols/systems/3g-324m_pvterminal/h324/srp/include/srp_ports.h
new file mode 100644
index 0000000..9f4c42e
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/srp/include/srp_ports.h
@@ -0,0 +1,103 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef SRP_PORTS_H_INCLUDED
+#define SRP_PORTS_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef SRP_H
+#include "srp.h"
+#endif
+
+#include "media_packet.h"
+
+class SRPLowerLayerPortOut : public PvmfPortBaseImpl
+{
+        // All requests are synchronous
+    public:
+        SRPLowerLayerPortOut() : PvmfPortBaseImpl(SRP_OUTPUT_PORT_TAG, NULL) {};
+
+        ~SRPLowerLayerPortOut() {}
+};
+
+class SRPLowerLayerPortIn : public PvmfPortBaseImpl
+{
+        // All requests are synchronous
+    public:
+        SRPLowerLayerPortIn(SRP *aSrp) : PvmfPortBaseImpl(SRP_INPUT_PORT_TAG, NULL),
+                iSrp(aSrp)
+        {};
+
+        ~SRPLowerLayerPortIn() {};
+
+        virtual PVMFStatus Receive(PVMFSharedMediaMsgPtr aMsg)
+        {
+            PVMFSharedMediaDataPtr mediaData;
+            convertToPVMFMediaData(mediaData, aMsg);
+
+            // send packet to SRP
+            iSrp->LowerLayerRx(mediaData);
+
+            return PVMFSuccess;
+        }
+
+    private:
+        SRP *iSrp;
+};
+
+class SRPUpperLayerPortOut : public PvmfPortBaseImpl
+{
+        // All requests are synchronous
+    public:
+        SRPUpperLayerPortOut() : PvmfPortBaseImpl(SRP_OUTPUT_PORT_TAG, NULL) {};
+
+        ~SRPUpperLayerPortOut() {}
+};
+
+class SRPUpperLayerPortIn : public PvmfPortBaseImpl
+{
+        // All requests are synchronous
+    public:
+        SRPUpperLayerPortIn(SRP *aSrp) : PvmfPortBaseImpl(SRP_INPUT_PORT_TAG, NULL),
+                iSrp(aSrp)
+        {};
+
+        ~SRPUpperLayerPortIn() {};
+
+        virtual PVMFStatus Receive(PVMFSharedMediaMsgPtr aMsg)
+        {
+            PVMFSharedMediaDataPtr mediaData;
+            convertToPVMFMediaData(mediaData, aMsg);
+
+            // send packet to SRP
+            iSrp->UpperLayerRx(mediaData);
+
+            return PVMFSuccess;
+        }
+
+    private:
+        SRP *iSrp;
+};
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h324/srp/src/srp.cpp b/protocols/systems/3g-324m_pvterminal/h324/srp/src/srp.cpp
new file mode 100644
index 0000000..74750cd
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/srp/src/srp.cpp
@@ -0,0 +1,2753 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#include "srp.h"
+#include "srp_ports.h"
+#include "pvlogger.h"
+
+/************************************************************************/
+/*  Constants			                                                */
+/************************************************************************/
+const SRP::SrpAction SRP::iSrpStateTable[MAX_STATUS][MAX_EVENT] =
+{
+    /* Event No.		 0						1					2				3				4				5					6				7		*/
+    /* Status 0 */ { SRP::ACTION_NOP,  SRP::ACTION_0_1, SRP::ACTION_0_2, SRP::ACTION_NOP,  SRP::ACTION_NOP, SRP::ACTION_NOP, SRP::ACTION_0_2, SRP::ACTION_NOP} ,
+    /* Status 1 */ { SRP::ACTION_NOP,  SRP::ACTION_1_1, SRP::ACTION_0_2, SRP::ACTION_1_3,  SRP::ACTION_1_3, SRP::ACTION_1_4, SRP::ACTION_0_2, SRP::ACTION_1_3}
+};
+
+
+OSCL_EXPORT_REF SRP::SRP() : iN400MaxCounter(N400_DEFAULT_MAX_COUNTER),  //changed max # of allowable retries from 10 to 200
+        //This was done in conjunction with lowering the SRP
+        //timeout value from 400ms to 50ms
+        iN402MaxCounter(N402_DEFAULT_MAX_COUNTER), //WNSRP counter
+        iCrcData(0),
+        iSendSeqNumber(0),
+        iRecvSeqNumber(0),
+        iStatus(STS_IDLE),
+        iCurWnsrpStatus(WNSRP_TX_SUPPORT),
+        iT401TimerValue(T401_VALUE_DEFAULT),
+        iWnsrpCommandSave(NULL),
+        iCcsrlSduSize(DEFAULT_CCSRL_SIZE),
+        iRxFrags(NULL),
+        iFreeRxFragList(NULL),
+        iPendingRxFragList(NULL),
+        iFirstCmd(true),
+        iLLPortOut(NULL),
+        iLLPortIn(NULL),
+        iULPortOut(NULL),
+        iULPortIn(NULL),
+        iTxMediaMsgPoolAlloc(NULL),
+        iTxMediaDataImplMemAlloc(NULL),
+        iTxPacketAlloc(NULL),
+        iOutstandingTxMediaMsgPoolAlloc(NULL),
+        iOutstandingTxMediaDataImplMemAlloc(NULL),
+        iRxMediaMsgPoolAlloc(NULL),
+        iRxMediaDataImplMemAlloc(NULL),
+        iRxPacketAlloc(NULL),
+        iRespMediaMsgPoolAlloc(NULL),
+        iRespMemAlloc(NULL),
+        iRespPacketAlloc(NULL),
+        iNsrpRespMemAlloc(NULL),
+        iNsrpRespPacketAlloc(NULL),
+        iNumTxMsgs(DEFAULT_SEND_QUEUE_SIZE),
+        iUseNSRP(true),
+        iFirstNSRPResp(false),
+        iHandleWNSRP(true),
+        iWNSRPTxWindow(DEFAULT_WNSRP_WINDOW),
+        iWNSRPRxWindow(DEFAULT_WNSRP_WINDOW),
+        iOldestWNSRPRetransSeqNum(0),
+        iT401Resolution(T401_RESOLUTION),
+        iObserver(NULL)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h324.srp");
+}
+
+OSCL_EXPORT_REF SRP::~SRP()
+{
+}
+
+OSCL_EXPORT_REF void SRP::SrpInitL(void)
+{
+    iLLPortOut = OSCL_NEW(SRPLowerLayerPortOut, ());
+    OsclError::LeaveIfNull(iLLPortOut);
+    iLLPortIn  = OSCL_NEW(SRPLowerLayerPortIn, (this));
+    OsclError::LeaveIfNull(iLLPortIn);
+    iULPortOut = OSCL_NEW(SRPUpperLayerPortOut, ());
+    OsclError::LeaveIfNull(iULPortOut);
+    iULPortIn  = OSCL_NEW(SRPUpperLayerPortIn, (this));
+    OsclError::LeaveIfNull(iULPortIn);
+
+    uint32 i;
+    iSrpCommandSave.timerID = iWNSRPTxWindow;
+
+    iWnsrpCommandSave = OSCL_ARRAY_NEW(SRPRespTimer, iWNSRPTxWindow);
+    OsclError::LeaveIfNull(iWnsrpCommandSave);
+    for (i = 0; i < iWNSRPTxWindow; i++)
+    {
+        iWnsrpCommandSave[i].timerID = i;
+    }
+
+    iRxFrags = OSCL_ARRAY_NEW(SRPRxData, iWNSRPRxWindow);
+    OsclError::LeaveIfNull(iRxFrags);
+    for (i = 0; i < iWNSRPRxWindow; i++)
+    {
+        FreeRxFrag(&iRxFrags[i]);
+    }
+
+    iTxMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (iNumTxMsgs, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iTxMediaMsgPoolAlloc);
+    iTxMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (iNumTxMsgs + ((iWNSRPTxWindow + 1) * 2), 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iTxMediaDataImplMemAlloc);
+    iTxPacketAlloc = OSCL_NEW(PVMFMediaFragGroupCombinedAlloc<OsclMemAllocator>, (iNumTxMsgs + ((iWNSRPTxWindow + 1) * 2), MAX_SEND_FRAGS_PER_MSG, iTxMediaDataImplMemAlloc));
+    OsclError::LeaveIfNull(iTxPacketAlloc);
+    iTxPacketAlloc->create();
+
+    iOutstandingTxMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, ((iWNSRPTxWindow + 1) * 2, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iOutstandingTxMediaMsgPoolAlloc);
+    iOutstandingTxMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, ((iWNSRPTxWindow + 1) * 2, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iOutstandingTxMediaDataImplMemAlloc);
+
+    iRxMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (iWNSRPRxWindow * 2, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iRxMediaMsgPoolAlloc);
+    iRxMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (iWNSRPRxWindow * 2, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iRxMediaDataImplMemAlloc);
+    iRxPacketAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iRxMediaDataImplMemAlloc));
+    OsclError::LeaveIfNull(iRxPacketAlloc);
+
+    iRespMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (MAX_RESP_MSGS, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iRespMediaMsgPoolAlloc);
+    iRespMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (MAX_RESP_MSGS, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iRespMemAlloc);
+    iRespPacketAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iRespMemAlloc));
+    OsclError::LeaveIfNull(iRespPacketAlloc);
+    iNsrpRespMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (MAX_RESP_MSGS, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iNsrpRespMemAlloc);
+    iNsrpRespPacketAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (iNsrpRespMemAlloc));
+    OsclError::LeaveIfNull(iNsrpRespPacketAlloc);
+
+    iHdrAllocator.size((uint16) iNumTxMsgs*2, (SRP_HEADER_SIZE));
+    iHdrAllocator.SetLeaveOnAllocFailure(false);
+    iCcsrlAllocator.size((uint16) iNumTxMsgs*2, CCSRL_HEADER_SIZE + SRP_SEQUENCE_SIZE);
+    iCcsrlAllocator.SetLeaveOnAllocFailure(false);
+    iFCSAllocator.size((uint16) iNumTxMsgs*2, SRP_FCS_SIZE);
+    iFCSAllocator.SetLeaveOnAllocFailure(false);
+
+    //Just need 1 fragment for SRP/NSRP messages and 1 for WNSRP messages
+    iMTEntryNumAllocator.size(NUM_MT_ENTRY_NUMBERS, MT_ENTRY_NUMBER_SIZE);
+    iMTEntryNumAllocator.SetLeaveOnAllocFailure(false);
+    iSrpNsrpEntryNumFrag = iMTEntryNumAllocator.get();
+    *(uint8 *)iSrpNsrpEntryNumFrag.getMemFragPtr() = SRP_NSRP_MT_ENTRY_NUMBER;
+    iWnsrpEntryNumFrag = iMTEntryNumAllocator.get();
+    *(uint8 *)iWnsrpEntryNumFrag.getMemFragPtr() = WNSRP_MT_ENTRY_NUMBER;
+
+    iSrpWaitQueue.reserve(iNumTxMsgs);
+
+    iFreeWnsrpCommandSave.reserve(iWNSRPTxWindow);
+    iActiveWnsrpCommandSave.reserve(iWNSRPTxWindow);
+
+    iSrpCommandSave.T401Timer.SetFrequency(T401_RESOLUTION);
+    for (i = 0; i < iWNSRPTxWindow; i++)
+    {
+        iWnsrpCommandSave[i].T401Timer.SetFrequency(T401_RESOLUTION);
+        iFreeWnsrpCommandSave.push_back(&iWnsrpCommandSave[i]);
+    }
+
+    //Temporary for now, should be called when tsc does a connect.
+    SrpStart();
+}
+
+OSCL_EXPORT_REF void SRP::SrpReset(void)
+{
+    //Temporary for now, should be called when tsc does a disconnect.
+    SrpStop();
+
+    OsclRefCounterMemFrag temp;
+    iSrpNsrpEntryNumFrag = temp;
+    iWnsrpEntryNumFrag = temp;
+
+    iActiveWnsrpCommandSave.clear();
+    iFreeWnsrpCommandSave.clear();
+
+    iMTEntryNumAllocator.clear();
+    iHdrAllocator.clear();
+    iCcsrlAllocator.clear();
+    iFCSAllocator.clear();
+
+    if (iTxPacketAlloc)
+    {
+        iTxPacketAlloc->removeRef();
+        iTxPacketAlloc = NULL;
+    }
+
+    if (iTxMediaDataImplMemAlloc)
+    {
+        OSCL_DELETE(iTxMediaDataImplMemAlloc);
+        iTxMediaDataImplMemAlloc = NULL;
+    }
+
+    if (iTxMediaMsgPoolAlloc)
+    {
+        OSCL_DELETE(iTxMediaMsgPoolAlloc);
+        iTxMediaMsgPoolAlloc = NULL;
+    }
+
+    if (iOutstandingTxMediaDataImplMemAlloc)
+    {
+        OSCL_DELETE(iOutstandingTxMediaDataImplMemAlloc);
+        iOutstandingTxMediaDataImplMemAlloc = NULL;
+    }
+
+    if (iOutstandingTxMediaMsgPoolAlloc)
+    {
+        OSCL_DELETE(iOutstandingTxMediaMsgPoolAlloc);
+        iOutstandingTxMediaMsgPoolAlloc = NULL;
+    }
+
+    if (iRxPacketAlloc)
+    {
+        OSCL_DELETE(iRxPacketAlloc);
+        iRxPacketAlloc = NULL;
+    }
+
+    if (iRxMediaDataImplMemAlloc)
+    {
+        OSCL_DELETE(iRxMediaDataImplMemAlloc);
+        iRxMediaDataImplMemAlloc = NULL;
+    }
+
+    if (iRxMediaMsgPoolAlloc)
+    {
+        OSCL_DELETE(iRxMediaMsgPoolAlloc);
+        iRxMediaMsgPoolAlloc = NULL;
+    }
+
+    if (iNsrpRespMemAlloc)
+    {
+        OSCL_DELETE(iNsrpRespMemAlloc);
+        iNsrpRespMemAlloc = NULL;
+    }
+
+    if (iNsrpRespPacketAlloc)
+    {
+        OSCL_DELETE(iNsrpRespPacketAlloc);
+        iNsrpRespPacketAlloc = NULL;
+    }
+
+    if (iRespMemAlloc)
+    {
+        OSCL_DELETE(iRespMemAlloc);
+        iRespMemAlloc = NULL;
+    }
+
+    if (iRespPacketAlloc)
+    {
+        OSCL_DELETE(iRespPacketAlloc);
+        iRespPacketAlloc = NULL;
+    }
+
+    if (iRespMediaMsgPoolAlloc)
+    {
+        OSCL_DELETE(iRespMediaMsgPoolAlloc);
+        iRespMediaMsgPoolAlloc = NULL;
+    }
+
+    if (iWnsrpCommandSave)
+    {
+        OSCL_ARRAY_DELETE(iWnsrpCommandSave);
+        iWnsrpCommandSave = NULL;
+    }
+
+    if (iRxFrags)
+    {
+        OSCL_ARRAY_DELETE(iRxFrags);
+        iRxFrags = NULL;
+    }
+
+    if (iLLPortOut)
+    {
+        OSCL_DELETE(iLLPortOut);
+        iLLPortOut = NULL;
+    }
+
+    if (iLLPortIn)
+    {
+        OSCL_DELETE(iLLPortIn);
+        iLLPortIn = NULL;
+    }
+
+    if (iULPortOut)
+    {
+        OSCL_DELETE(iULPortOut);
+        iULPortOut = NULL;
+    }
+
+    if (iULPortIn)
+    {
+        OSCL_DELETE(iULPortIn);
+        iULPortIn = NULL;
+    }
+
+    WnsrpStatusSet(WNSRP_TX_SUPPORT);
+    iHandleWNSRP = true;
+}
+
+
+OSCL_EXPORT_REF void SRP::SrpStart(void)
+{
+    SrpResetStats();
+
+    iFirstCmd = true;
+
+    /* Clear receive sequence number */
+    SrpRecvSeqClear();
+    /* Clear send sequence number */
+    SrpSendSeqClear();
+
+    /* Clear WNSRP retry counter */
+    SrpN402Initialize();
+    /* Set status */
+    SrpStatusSet(STS_IDLE);
+}
+
+OSCL_EXPORT_REF void SRP::SrpStop(void)
+{
+    SRPRxData *pendingRxFrag;
+
+    // Cancel any outstanding timer events
+    if (iSrpCommandSave.isTimerActive)
+    {
+        SrpT401Stop(iSrpCommandSave);
+        iSrpCommandSave.pPkt.Unbind();
+    }
+
+    //Clear all WNSRP resp timers
+    while (!iActiveWnsrpCommandSave.empty())
+    {
+        // Stop response wait timer
+        SrpT401Stop(*iActiveWnsrpCommandSave[0]);
+
+        // Release packet
+        iActiveWnsrpCommandSave[0]->pPkt.Unbind();
+
+        // Remove timer from active list
+        RemoveActiveWnsrpTimer(iActiveWnsrpCommandSave[0]);
+    }
+
+    WnsrpStatusSet(WNSRP_TX_SUPPORT);
+
+    // Flush the queue
+    iSrpWaitQueue.clear();
+
+    // Clear pending received packet.
+    while (iPendingRxFragList)
+    {
+        pendingRxFrag = iPendingRxFragList;
+        iPendingRxFragList = iPendingRxFragList->next;
+        FreeRxFrag(pendingRxFrag);
+    }
+
+
+    /* AR: Switch back to SRP mode */
+    iUseNSRP = false;
+
+    /* Print iStats */
+    SRPStats tempStats;
+    SrpGetStats(tempStats);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "SRP Stats:"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Total frames recv %d", tempStats.totalFramesRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Invalid size frames recv %d", tempStats.totalInvalidSizeFramesRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "CRC errors recv %d", tempStats.totalCRCErrorsRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Cmd frames recv %d", tempStats.totalCommandFramesRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Cmd WNSRP frames recv %d", tempStats.totalWNSRPCommandFramesRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Invalid CCSRL chunk recv %d", tempStats.totalInvalidCCSRLChunkRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "SRP resp recv %d", tempStats.totalSRPRespRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "NSRP resp recv %d", tempStats.totalNSRPRespRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "WNSRP resp recv %d", tempStats.totalWNSRPRespRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "H245 messages recv %d", tempStats.totalH245MessagesRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "CCSRL chunks recv %d", tempStats.totalCCSRLChunksRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Cmd frames sent %d", tempStats.totalCommandFramesSent));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "H245 messages to send %d", tempStats.totalH245MessagesToSend));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "H245 messages fragmented %d", tempStats.totalH245MessagesFragmented));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "CCSRL chunks sent %d", tempStats.totalCCSRLChunksSent));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Num of timeouts %d", tempStats.totalNumTimeouts));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Bytes recv %d", tempStats.totalBytesRecv));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Bytes sent %d", tempStats.totalBytesSent));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Invalid frames %d", tempStats.totalInvalidFrames));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Min response time %d", tempStats.minRespTime));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Max response time %d", tempStats.maxRespTime));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STATISTIC, (0x40000020, "Ave response time %d", tempStats.aveRespTime));
+}
+
+/************************************************************************/
+/*  function name       : SrpGetEventNoFromAL1                          */
+/*  function outline    : decide event number from received PDU         */
+/*                                                          (H.223 AL1) */
+/*  function discription: INT SrpGetEventNoFromAL1(						*/
+/*									PVMFSharedMediaDataPtr pPkt )		*/
+/*  input data          : pPkt - pointer of received packet             */
+/*  output data         : event number                                  */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+SRP::SrpEvent SRP::SrpGetEventNoFromAL1(PVMFSharedMediaDataPtr pPkt)
+{
+    SrpEvent EventNo = EV_NOP;
+    uint8 *pFrame;
+    uint8 CrcWork[2];
+    OsclRefCounterMemFrag frag;
+    OsclSharedPtr<PVMFMediaDataImpl> data;
+    uint16 Crc16Check(PVMFSharedMediaDataPtr aData);
+
+    if (pPkt->getNumFragments() != 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP:SrpGetEventNoFromAL1 - fragments not equal to 1, num frags %d", pPkt->getNumFragments()));
+        return EventNo;
+    }
+
+    if (pPkt->getFilledSize() >= MINIMUM_FRAME_SIZE)
+    {
+        pPkt->getMediaDataImpl(data);
+
+        CrcClear();
+        CrcSetToFrame(iCrc.Crc16Check(data, true), &CrcWork[0]);
+
+        pPkt->getMediaFragment(0, frag);
+        pFrame = (uint8 *) frag.getMemFragPtr();
+
+        if ((CrcWork[0] == pFrame[pPkt->getFilledSize()-SRP_FCS_SIZE]) &&
+                (CrcWork[1] == pFrame[pPkt->getFilledSize()-SRP_FCS_SIZE+1]))
+        {
+            switch (pFrame[0])
+            {
+                case SRP_COMMAND_HEADER:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP:SrpGetEventNoFromAL1 - SRP_COMMAND_HEADER, seq num %d", pFrame[1]));
+
+                    //Disable WNSRP if 1st command frame does not start with seq num 0
+                    if ((WnsrpStatusGet() == WNSRP_TX_SUPPORT) &&
+                            iFirstCmd &&
+                            (pFrame[1] != 0))
+                    {
+                        WnsrpStatusSet(NO_WNSRP_SUPPORT);
+                    }
+
+                    iStats.totalCommandFramesRecv++;
+
+                    pPkt->setSeqNum((uint32) pFrame[1]);
+
+                    //If using CCSRL method.
+                    if (iCcsrlSduSize > 0)
+                    {
+                        //Check if is a valid CCSRL chunk.
+                        if ((pFrame[2] == INTERMEDIATE_CCSRL_CHUNK) || (pFrame[2] == LAST_CCSRL_CHUNK))
+                        {
+                            EventNo = EV_COMMAND;
+                        }
+                        else
+                        {
+                            // Record invalid CCSRL chunk
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP: Invalid CCSRL Chunk"));
+                            iStats.totalInvalidCCSRLChunkRecv++;
+                        }
+                    }
+                    //Else not using CCSRL method
+                    else
+                    {
+                        EventNo = EV_COMMAND;
+                    }
+
+                    break;
+
+                case SRP_RESPONSE_HEADER: // No sequence number in SRP responses
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP:SrpGetEventNoFromAL1 - SRP_RESPONSE_HEADER"));
+
+                    if (WnsrpStatusGet() == WNSRP_TX_SUPPORT)
+                    {
+                        SrpN402Count();
+                        if (SrpN402Check() == false)
+                        {
+                            WnsrpStatusSet(NO_WNSRP_SUPPORT);
+                        }
+                    }
+
+                    iStats.totalSRPRespRecv++;
+
+                    // If using NSRP
+                    if (iUseNSRP)
+                    {
+                        // If we haven't received an NSRP response yet, keep accepting SRP responses.
+                        if (!iFirstNSRPResp)
+                        {
+                            EventNo = EV_RESPONSE;
+                        }
+                    }
+                    // Else not using NSRP
+                    else
+                    {
+                        EventNo = EV_RESPONSE;
+                    }
+                    break;
+
+                case NSRP_RESPONSE_HEADER:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP:SrpGetEventNoFromAL1 - NSRP_RESPONSE_HEADER, seq num %d", pFrame[1]));
+
+                    if (WnsrpStatusGet() == WNSRP_TX_SUPPORT)
+                    {
+                        SrpN402Count();
+                        if (SrpN402Check() == false)
+                        {
+                            WnsrpStatusSet(NO_WNSRP_SUPPORT);
+                        }
+                    }
+
+                    iStats.totalNSRPRespRecv++;
+
+                    // If using NSRP, check sequence number.
+                    if (iUseNSRP)
+                    {
+                        pPkt->setSeqNum((uint32) pFrame[1]);
+
+                        if (!iFirstNSRPResp)
+                        {
+                            iFirstNSRPResp = true;
+                        }
+
+                        EventNo = EV_NSRP_RESPONSE;
+                    }
+                    //Else using SRP, just accept as a valid SRP response frame
+                    else
+                    {
+                        EventNo = EV_RESPONSE;
+                    }
+                    break;
+
+                case WNSRP_COMMAND_HEADER:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP:SrpGetEventNoFromAL1 - WNSRP_COMMAND_HEADER, status %d, seq num %d", WnsrpStatusGet(), pFrame[1]));
+
+                    if (!iHandleWNSRP)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP:SrpGetEventNoFromAL1 - WNSRP_COMMAND_HEADER, not handling WNSRP frames"));
+                        break;
+                    }
+
+                    iStats.totalWNSRPCommandFramesRecv++;
+
+                    pPkt->setSeqNum((uint32) pFrame[1]);
+
+                    switch (WnsrpStatusGet())
+                    {
+                        case WNSRP_TX_SUPPORT:
+                            WnsrpStatusSet(WNSRP_FULL_SUPPORT);
+                            //Fall into next case.
+
+                        case WNSRP_FULL_SUPPORT:
+                            //If using CCSRL method.
+                            if (iCcsrlSduSize > 0)
+                            {
+                                //Check if is a valid CCSRL chunk.
+                                if ((pFrame[2] == INTERMEDIATE_CCSRL_CHUNK) || (pFrame[2] == LAST_CCSRL_CHUNK))
+                                {
+                                    EventNo = EV_WNSRP_COMMAND;
+                                }
+                                else
+                                {
+                                    // Record invalid CCSRL chunk
+                                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP: Invalid CCSRL Chunk"));
+                                    iStats.totalInvalidCCSRLChunkRecv++;
+                                }
+                            }
+                            //Else not using CCSRL method
+                            else
+                            {
+                                EventNo = EV_WNSRP_COMMAND;
+                            }
+
+                            break;
+
+                        case NO_WNSRP_SUPPORT:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP:SrpGetEventNoFromAL1 - no WNSRP support"));
+                            break;
+                    }
+
+                    break;
+
+                case WNSRP_RESPONSE_HEADER:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP:SrpGetEventNoFromAL1 - WNSRP_RESPONSE_HEADER, status %d, seq num %d", WnsrpStatusGet(), pFrame[1]));
+
+                    if (!iHandleWNSRP)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP:SrpGetEventNoFromAL1 - WNSRP_COMMAND_HEADER, not handling WNSRP frames"));
+                        break;
+                    }
+
+                    iStats.totalWNSRPRespRecv++;
+
+                    switch (WnsrpStatusGet())
+                    {
+                        case WNSRP_TX_SUPPORT:
+                            WnsrpStatusSet(WNSRP_FULL_SUPPORT);
+                            //Fall into next case.
+
+                        case WNSRP_FULL_SUPPORT:
+                            //Set sequence number of the response.
+                            pPkt->setSeqNum((uint32) pFrame[1]);
+
+                            EventNo = EV_WNSRP_RESPONSE;
+                            break;
+
+                        case NO_WNSRP_SUPPORT:
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP:SrpGetEventNoFromAL1 - no WNSRP support"));
+                            break;
+                    }
+                    break;
+
+                default:
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP: Unknown SRP command %d", pFrame[0]));
+                    iStats.totalInvalidFrames++;
+                    break;
+            }
+        }
+        // CRC errors.
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP: CRC check failed"));
+            iStats.totalCRCErrorsRecv++;
+        }
+    }
+    else
+    {
+        // Record number of frames received that have an invalid size.
+        iStats.totalInvalidSizeFramesRecv++;
+    }
+
+    return(EventNo) ;
+}
+
+/************************************************************************/
+/*  function name       : SrpStateChange		                        */
+/*  function outline    : decide function to call given the status and  */
+/*                        event											*/
+/*  function discription: INT SrpGetEventNoFromAL1( void *data )		*/
+/*  input data          : status - Status of Srp		                */
+/*						  event - Incoming event						*/
+/*						  data - optional state change data				*/
+/*  output data         : None			                                */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::SrpStateChange(int status, int event, void *data)
+{
+    switch (iSrpStateTable[status][event])
+    {
+        case ACTION_NOP:
+            return (SrpNop());
+        case ACTION_0_1:
+            return (Srp_0_1());
+        case ACTION_0_2:
+            return (Srp_0_2(*(PVMFSharedMediaDataPtr *) data, event));
+
+
+        case ACTION_1_1:
+            return (Srp_1_1());
+        case ACTION_1_3:
+            return (Srp_1_3(*(PVMFSharedMediaDataPtr *) data, event));
+        case ACTION_1_4:
+            return (Srp_1_4(*(int32 *) data));
+        default:
+            return 0;
+    }
+}
+
+/************************************************************************/
+/*  function name       : SrpN400Check                                  */
+/*  function outline    : N400 counter check                            */
+/*  function discription: INT  SrpN400Check(SRPRespTimer &timer)        */
+/*  input data          : timer - timer to check                        */
+/*  output data         : Check result                                  */
+/*                         OK : Not count over                          */
+/*                         NG : Count over                              */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::SrpN400Check(SRPRespTimer &timer)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpN400Check - N400Counter=%d N400MaxCounter=%d", timer.N400Counter, iN400MaxCounter));
+
+    if (timer.N400Counter < iN400MaxCounter)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+/************************************************************************/
+/*  function name       : SrpN402Initialize                             */
+/*  function outline    : N402 counter initialize                       */
+/*  function discription: void SrpN402Initialize( void )                */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.23                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::SrpN402Initialize()
+{
+    /* Clear counter */
+    iN402Counter = 0 ;
+}
+
+
+/************************************************************************/
+/*  function name       : SrpN402Check                                  */
+/*  function outline    : N402 counter check                            */
+/*  function discription: INT  SrpN402Check( void )                     */
+/*  input data          : None                                          */
+/*  output data         : Check result                                  */
+/*                         OK : Not count over                          */
+/*                         NG : Count over                              */
+/*  draw time           : '05.08.23                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+int SRP::SrpN402Check()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpN402Check - N402Counter=%d N402MaxCounter=%d", iN402Counter, iN402MaxCounter));
+
+    if (iN402Counter < iN402MaxCounter)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+/************************************************************************/
+/*  function name       : CrcCalc                                       */
+/*  function outline    : CRC calculation                               */
+/*  function discription: void CrcCalc( PUCHAR pData, int Size )        */
+/*  input data          : pData - object data pointer                   */
+/*                        Size  - object data size (octet length)       */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::CrcCalc(uint8 *pData, int Size)
+{
+    int     BitCount;
+
+    while (Size--)  /* process for all data */
+    {
+        for (BitCount = 0 ; BitCount < 8 ; BitCount++)  /* process for 8 bit data */
+        {
+            if ((iCrcData & 0x8000) != 0)   /* MSB=1? */
+            {
+                iCrcData <<= 1;
+                iCrcData |= ((*pData >> BitCount) & 0x01);
+                iCrcData ^= GX_CRC_12;
+            }
+            else
+            {
+                iCrcData <<= 1;
+                iCrcData |= ((*pData >> BitCount) & 0x01);
+            }
+        }
+
+        /* update pointer of data */
+        pData++;
+    }
+    return ;
+}
+
+/************************************************************************/
+/*  function name       : CrcResultGet                                  */
+/*  function outline    : Get result of CRC calculation                 */
+/*  function discription: USHORT CrcResultGet( void )                   */
+/*  input data          : None                                          */
+/*  output data         : Result of CRC Calculation                     */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+uint16 SRP::CrcResultGet(void)
+{
+    int	BitCount;
+
+    for (BitCount = 0 ; BitCount < 16 ; BitCount++)  /* process for 16bit */
+    {
+        if ((iCrcData & 0x8000) != 0)   /* MSB=1? */
+        {
+            iCrcData <<= 1;
+            iCrcData  ^= GX_CRC_12;
+        }
+        else
+        {
+            iCrcData <<= 1;
+        }
+    }
+    return((uint16)iCrcData) ;
+}
+
+/************************************************************************/
+/*  function name       : CrcSetToFrame                                 */
+/*  function outline    : Set CRC data to FCS area of frame             */
+/*  function discription: void CrcSetToFrame( USHORT Crc, PUCHAR pFcs ) */
+/*  input data          : None                                          */
+/*  output data         : Crc - CRC data                                */
+/*                        pFcs - FCS data pointer                       */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::CrcSetToFrame(uint16 crc, uint8 *pFcs)
+{
+
+    /* Clear first fcs octet */
+    *pFcs = 0;
+
+    *pFcs = (uint8)(crc & 0x00ff);
+    pFcs++;
+    *pFcs = (uint8)((crc & 0xff00) >> 8);
+
+    return ;
+}
+
+/************************************************************************/
+/*  function name       : SrpCommandCreate                              */
+/*  function outline    : Create command frame                          */
+/*  function discription: void SrpCommandCreate(                        */
+/*                                    PVMFSharedMediaDataPtr pPkt )		*/
+/*  input data          : pPkt - data packet to create SRP command frame*/
+/*  output data         : None                                          */
+/*  draw time           : '05.08.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+PVMFSharedMediaDataPtr SRP::SrpCommandCreate(PVMFSharedMediaDataPtr pPkt, uint8 header)
+{
+    uint16 crc;
+    uint16 Crc16Check(PVMFSharedMediaDataPtr aData);
+    int32 error = OsclErrNone;
+    OsclSharedPtr<PVMFMediaDataImpl> srpPkt;
+    PVMFSharedMediaDataPtr txData;
+    OsclRefCounterMemFrag headerFrag;
+    OsclRefCounterMemFrag FCSFrag;
+
+    OSCL_UNUSED_ARG(error);
+    switch (header)
+    {
+        case SRP_COMMAND_HEADER:
+        case WNSRP_COMMAND_HEADER:
+            srpPkt = iTxPacketAlloc->allocate();
+            if (!srpPkt)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0x40000020, "SRP::SrpCommandCreate - Unable allocate tx media impl %d", error));
+                return txData;
+            }
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpCommandCreate - Unable command type %x", header));
+            return txData;
+
+    }
+
+    // Allocate header fragment.
+    headerFrag = iHdrAllocator.get();
+    if (headerFrag.getMemFragPtr() == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpCommandCreate Unable to allocate header frag %d", error));
+        return txData;
+    }
+
+
+    // Allocate fcs fragment.
+    FCSFrag = iFCSAllocator.get();
+    if (FCSFrag.getMemFragPtr() == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpCommandCreate Unable to allocate FCS frag %d", error));
+        return txData;
+    }
+
+
+    //Set header value
+    *(uint8 *) headerFrag.getMemFragPtr() = header;
+    headerFrag.getMemFrag().len = SRP_HEADER_SIZE;
+
+    // Add header to the front of the packet.
+    srpPkt->appendMediaFragment(headerFrag);
+
+    // Add data fragments
+    for (uint32 i = 0; i < pPkt->getNumFragments(); i++)
+    {
+        pPkt->getMediaFragment(i, headerFrag);
+        srpPkt->appendMediaFragment(headerFrag);
+    }
+
+    // Initialize crc calcuration
+    CrcClear();
+    // Calculate crc
+    crc = iCrc.Crc16Check(srpPkt);   // 16bit CRC Infomation Create
+
+    // Set crc to fcs
+    CrcSetToFrame(crc, (uint8 *) FCSFrag.getMemFragPtr());
+    FCSFrag.getMemFrag().len = SRP_FCS_SIZE;
+
+    // Add CRC to the end of the packet.
+    srpPkt->appendMediaFragment(FCSFrag);
+
+    txData = PVMFMediaData::createMediaData(srpPkt, iOutstandingTxMediaMsgPoolAlloc);
+    if (!txData)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpCommandCreate - Unable allocate tx message %d", error))
+        return txData;
+    }
+    //If SRP
+    if (header == SRP_COMMAND_HEADER)
+    {
+        txData->setFormatSpecificInfo(iSrpNsrpEntryNumFrag);
+    }
+    //Else WNSRP
+    else
+    {
+        txData->setFormatSpecificInfo(iWnsrpEntryNumFrag);
+    }
+
+    // Set sequence number
+    txData->setSeqNum(pPkt->getSeqNum());
+
+    iStats.totalCCSRLChunksSent++;
+    iStats.totalCommandFramesSent++;
+
+    /* Record initial time when chunk is sent. */
+    iInitialTimeChunkSent.set_to_current_time();
+
+    return txData;
+}
+
+/************************************************************************/
+/*  function name       : SrpCommandClear                               */
+/*  function outline    : Clear comand frame for re-transmittion        */
+/*  function discription: void SrpCommandClear(SRPRespTimer &timer)		*/
+/*  input data          : timer - response timer that hold frame to be	*/
+/*								  retransmitted.						*/
+/*  output data         : None                                          */
+/*  draw time           : '05.08.24	                                    */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::SrpCommandClear(uint32 seqNum)
+{
+    uint32 i;
+
+    //Find packet with same sequence number in wait queue and remove
+    for (i = 0; i < iSrpWaitQueue.size(); i++)
+    {
+        if (iSrpWaitQueue[i]->getSeqNum() == seqNum)
+        {
+            iSrpWaitQueue.erase(&iSrpWaitQueue[i]);
+            return;
+        }
+    }
+
+    return;
+}
+
+/************************************************************************/
+/*  function name       : SrpResponseCreate                             */
+/*  function outline    : Create response frame                         */
+/*  function discription: void SrpResponseCreate( uint8 seqNum )        */
+/*  input data          : seqNum - Sequence number of response frame    */
+/*						  header - SRP response frame type				*/
+/*  output data         : pointer to created response packet            */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+PVMFSharedMediaDataPtr SRP::SrpResponseCreate(uint8 seqNum, uint8 header)
+{
+    OsclSharedPtr<PVMFMediaDataImpl> resp;
+    PVMFSharedMediaDataPtr mediaData;
+    int32 error = OsclErrNone;
+    uint8* pEditPtr;
+    uint16 crc;
+    uint16 Crc16Check(uint8 *, uint16);
+    OsclRefCounterMemFrag frag;
+
+    OSCL_UNUSED_ARG(error);
+
+    switch (header)
+    {
+        case NSRP_RESPONSE_HEADER:
+        case WNSRP_RESPONSE_HEADER:
+            resp = iNsrpRespPacketAlloc->allocate(SRP_HEADER_SIZE + SRP_FCS_SIZE + SRP_SEQUENCE_SIZE); /* WWU_NSRP */
+            break;
+
+        case SRP_RESPONSE_HEADER:
+            resp = iRespPacketAlloc->allocate(SRP_HEADER_SIZE + SRP_FCS_SIZE); /* SRP */
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpResponseCreate - Unknown response type %d", header));
+            return mediaData;
+    }
+
+    //Unable to allocate fragment.
+    if (!resp)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpResponseCreate - Unable to allocate fragment %d", error));
+        return mediaData;
+    }
+
+    resp->getMediaFragment(0, frag);
+
+    pEditPtr = (uint8 *) frag.getMemFragPtr();
+
+    /* Initialize crc calcuration */
+    CrcClear() ;
+
+    /* Set header octet */
+    switch (header)
+    {
+        case NSRP_RESPONSE_HEADER:
+        case WNSRP_RESPONSE_HEADER:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpResponseCreate - Sending NSRP or WNSRP Response, SeqNum = %d", seqNum));
+            *pEditPtr++ = header;
+            *pEditPtr++ = seqNum;
+            resp->setMediaFragFilledLen(0, SRP_HEADER_SIZE + SRP_FCS_SIZE + SRP_SEQUENCE_SIZE);
+            crc = iCrc.Crc16Check((uint8 *) frag.getMemFragPtr(), SRP_HEADER_SIZE + SRP_SEQUENCE_SIZE);	     /* 16bit CRC Infomation Create	    */
+            break;
+
+        case SRP_RESPONSE_HEADER:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpResponseCreate - Sending SRP Response"));
+            *pEditPtr++ = header;
+            resp->setMediaFragFilledLen(0, SRP_HEADER_SIZE + SRP_FCS_SIZE);
+            crc = iCrc.Crc16Check((uint8 *) frag.getMemFragPtr(), SRP_HEADER_SIZE);	      /* 16bit CRC Infomation Create	    */
+            break;
+
+        default:
+            return mediaData;
+    }
+
+    /* Set crc to fcs */
+    CrcSetToFrame(crc, pEditPtr) ;
+
+    mediaData = PVMFMediaData::createMediaData(resp, iRespMediaMsgPoolAlloc);
+    if (!mediaData)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpResponseCreate - Unable to allocate msg %d", error));
+        return mediaData;
+    }
+    mediaData->setSeqNum((uint32) seqNum);
+    //If SRP
+    switch (header)
+    {
+        case NSRP_RESPONSE_HEADER:
+        case SRP_RESPONSE_HEADER:
+            mediaData->setFormatSpecificInfo(iSrpNsrpEntryNumFrag);
+            break;
+
+        case WNSRP_RESPONSE_HEADER:
+            mediaData->setFormatSpecificInfo(iWnsrpEntryNumFrag);
+            break;
+    }
+
+    return mediaData;
+}
+
+/************************************************************************/
+/*  function name       : SrpMsgCopy                                    */
+/*  function outline    : Get SRP data from in packet and put it in the */
+/*                        out packet.                                   */
+/*  function discription: bool SrpMsgCopy(								*/
+/*										PVMFSharedMediaDataPtr inPkt)	*/
+/*  input data          : inPkt - Pointer to incoming packet.			*/
+/*                        outPkt - Pointer to outgoing packet.          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+bool SRP::SrpMsgCopy(PVMFSharedMediaDataPtr inPkt)
+{
+    OsclRefCounterMemFrag frag;
+    OsclSharedPtr<PVMFMediaDataImpl> data;
+    SRPRxData *rxData;
+    int32 error = OsclErrNone;
+    OSCL_UNUSED_ARG(error);
+    uint8 *pData;
+    uint8* pFragPos = NULL;
+    int fragLen = 0;
+
+    inPkt->getMediaFragment(0, frag);
+
+    pData = ((uint8 *) frag.getMemFragPtr()) + SRP_HEADER_SIZE + SRP_SEQUENCE_SIZE;
+
+    //If using CCSRL method.
+    if (iCcsrlSduSize > 0)
+    {
+        iStats.totalCCSRLChunksRecv++;
+        pFragPos = pData + CCSRL_HEADER_SIZE;
+        fragLen = frag.getMemFragSize() - SRP_HEADER_SIZE - SRP_SEQUENCE_SIZE - CCSRL_HEADER_SIZE - SRP_FCS_SIZE;
+    }
+    else
+    {
+        pFragPos = pData;
+        fragLen = frag.getMemFragSize() - SRP_HEADER_SIZE - SRP_SEQUENCE_SIZE - SRP_FCS_SIZE;
+    }
+
+    //Data to large.  Pass up whatever is buffered in receive packet
+    if (fragLen > MAX_SIZE_OF_SRP_PDU)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpMsgCopy - incoming data to large to copy %d, max %d", fragLen, MAX_SIZE_OF_SRP_PDU));
+        return false;
+    }
+
+    rxData = GetRxFrag();
+
+    if (rxData == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpMsgCopy - unable to allocate rx data frag %d", error));
+        return false;
+    }
+
+    if (!AllocateRxPacket(data, rxData))
+        return 0;
+    if (!CreateMediaData(rxData, data))
+        return 0;
+    rxData->data->getMediaFragment(0, frag);
+    oscl_memcpy(frag.getMemFragPtr(), pFragPos, fragLen);
+    rxData->data->setMediaFragFilledLen(0, fragLen);
+
+    rxData->seqNum = (uint8) inPkt->getSeqNum();
+
+    if (iCcsrlSduSize > 0)
+    {
+        // Return true if last CCSRL fragment in original H245 packet.
+        data->setMarkerInfo(((*pData == LAST_CCSRL_CHUNK) ? true : false));
+    }
+    else
+    {
+        data->setMarkerInfo(true);
+    }
+
+    //Add to rx pending list
+    AddPendingRxFrag(rxData);
+
+    return true;
+}
+
+bool SRP::AllocateRxPacket(OsclSharedPtr<PVMFMediaDataImpl>& data, SRPRxData* rxData)
+{
+    data = iRxPacketAlloc->allocate(MAX_SIZE_OF_SRP_PDU);
+    if (!data)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpMsgCopy - Unable allocate rx message impl"));
+        FreeRxFrag(rxData);
+        return false;
+    }
+    return true;
+
+}
+bool SRP::CreateMediaData(SRPRxData* rxData, OsclSharedPtr<PVMFMediaDataImpl> data)
+{
+    rxData->data = PVMFMediaData::createMediaData(data, iRxMediaMsgPoolAlloc);
+    if (!(rxData->data))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::SrpMsgCopy - Unable allocate rx message"));
+        FreeRxFrag(rxData);
+        return false;
+    }
+    return true;
+
+}
+
+
+bool SRP::CreateMediaData(PVMFSharedMediaDataPtr& srpPkt,
+                          OsclSharedPtr<PVMFMediaDataImpl> data)
+{
+    srpPkt = PVMFMediaData::createMediaData(data, iTxMediaMsgPoolAlloc);
+    if (!srpPkt)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0x40000020, "SRP::UpperLayerRx - Unable allocate tx message"));
+        return false;
+    }
+    return true;
+}
+
+/************************************************************************/
+/*  function name       : Srp_0_1                                       */
+/*  function outline    : PDU received in IDLE                          */
+/*  function discription: PVMFSharedMediaDataPtr Srp_0_1()				*/
+/*  input data          : pPkt - pointer of received packet from corder */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::Srp_0_1()
+{
+    PVMFSharedMediaDataPtr pSrpCommandPkt;
+    PVMFSharedMediaDataPtr pTxPkt;
+    PVMFSharedMediaDataPtr pFirstPkt;
+    SRPRespTimer *pTimer;
+
+    switch (WnsrpStatusGet())
+    {
+        case NO_WNSRP_SUPPORT:
+        case WNSRP_TX_SUPPORT:
+            pFirstPkt = SrpSendWaitGet(0);
+
+            /* Create SRP command */
+            pTxPkt = SrpCommandCreate(pFirstPkt, SRP_COMMAND_HEADER);
+
+            /* If packet could not be created. */
+            if (pTxPkt.GetRep() == NULL)
+            {
+                return(0);
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_0_1 - lowerlayertx srp cmd seq num %d", pTxPkt->getSeqNum()));
+
+            /* Send SRP command */
+            LowerLayerTx(pTxPkt);
+            /* Start response wait timer */
+            SrpT401Start(iSrpCommandSave, pTxPkt);
+
+            if (WnsrpStatusGet() == NO_WNSRP_SUPPORT) break;
+            //If tx support only, must send srp frame also.
+
+        case WNSRP_FULL_SUPPORT:
+            while (!iFreeWnsrpCommandSave.empty() &&
+                    (iActiveWnsrpCommandSave.size() < iSrpWaitQueue.size()))
+            {
+                pSrpCommandPkt = SrpSendWaitGet(iActiveWnsrpCommandSave.size());
+
+                //No more outstanding frags to send
+                if (pSrpCommandPkt.GetRep() == NULL)
+                {
+                    break;
+                }
+
+                /* Create WNSRP command */
+                pTxPkt = SrpCommandCreate(pSrpCommandPkt, WNSRP_COMMAND_HEADER);
+
+                /* If packet could not be created. */
+                if (pTxPkt.GetRep() == NULL)
+                {
+                    return(0);
+                }
+
+                pTimer = GetFreeWnsrpTimer();
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_0_1 - lowerlayertx wnsrp cmd seq num %d", pTxPkt->getSeqNum()));
+
+                /* Send SRP command */
+                LowerLayerTx(pTxPkt);
+                /* Start response wait timer */
+                SrpT401Start(*pTimer, pTxPkt);
+
+                AddActiveWnsrpTimer(pTimer);
+            }
+
+            break;
+
+        default:
+            break;
+    }
+
+    /* Set status */
+    SrpStatusSet(STS_WAIT_RESPONSE);
+    return (1);
+}
+
+/************************************************************************/
+/*  function name       : Srp_0_2                                       */
+/*  function outline    : SRP command received                          */
+/*                                    in IDLE or WAITING-RESPONSE       */
+/*  function discription: PVMFSharedMediaDataPtr Srp_0_2(				*/
+/*										PVMFSharedMediaDataPtr pPkt )   */
+/*  input data          : pPkt - pointer of received packet from AL1C   */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::Srp_0_2(PVMFSharedMediaDataPtr pPkt, int event)
+{
+    PVMFSharedMediaDataPtr resp;
+    OsclRefCounterMemFrag frag;
+    SRPRxData *rxData;
+    uint8 header;
+
+    //If WNSRP command
+    if (event == EV_WNSRP_COMMAND)
+    {
+        header = WNSRP_RESPONSE_HEADER;
+    }
+    //Else SRP command
+    else
+    {
+        if (iUseNSRP)
+        {
+            header = NSRP_RESPONSE_HEADER;
+        }
+        else
+        {
+            header = SRP_RESPONSE_HEADER;
+        }
+    }
+
+    if (iFirstCmd)
+    {
+        //WNSRP must always start with 0
+        if (event == EV_WNSRP_COMMAND)
+        {
+            SrpRecvSeqSet(0);
+        }
+        else
+        {
+            SrpRecvSeqSet((uint8) pPkt->getSeqNum());
+        }
+
+        iFirstCmd = false;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::Srp_0_2 - Incoming SequenceNumber = %d", pPkt->getSeqNum()));
+
+    if (CheckRxSeqNum(pPkt->getSeqNum(), header))
+    {
+        if (!SrpMsgCopy(pPkt))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::Srp_0_2 - Unable to copy data"));
+            return 0;
+        }
+
+        // Create SRP response
+        resp = SrpResponseCreate((uint8) pPkt->getSeqNum(), header);
+        if (resp.GetRep() == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::Srp_0_2 - Unable create reponse packet"));
+            /* If unable to create response message. */
+            return 0;
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_0_2 - lowerlayertx srp resp seq num %d", resp->getSeqNum()));
+
+        // SRP response send
+        LowerLayerTx(resp);
+
+        // Check for full H245 messages
+        while (iPendingRxFragList &&
+                (iPendingRxFragList->seqNum == SrpRecvSeqGet()))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_0_2 - upperlayertx last frag %d", iPendingRxFragList->data->getMarkerInfo()));
+
+            UpperLayerTx(iPendingRxFragList->data);
+
+            rxData = iPendingRxFragList;
+            iPendingRxFragList = iPendingRxFragList->next;
+
+            FreeRxFrag(rxData);
+
+            SrpRecvSeqCount();
+        }
+    }
+
+    return 1;
+}
+
+/************************************************************************/
+/*  function name       : Srp_1_1                                       */
+/*  function outline    : PDU received from corder in WAITING-RESPONSE  */
+/*  function discription: PVMFSharedMediaDataPtr Srp_1_1()				*/
+/*  input data          : pPkt - pointer of received packet from corder */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::Srp_1_1()
+{
+    PVMFSharedMediaDataPtr pTxPkt;
+    SRPRespTimer *pTimer;
+
+    switch (WnsrpStatusGet())
+    {
+        case NO_WNSRP_SUPPORT:
+            //SRP mode, cannot send until response for last packet is received.
+            break;
+
+        case WNSRP_TX_SUPPORT:
+        case WNSRP_FULL_SUPPORT:
+            while (!iFreeWnsrpCommandSave.empty() &&
+                    (iActiveWnsrpCommandSave.size() < iSrpWaitQueue.size()))
+            {
+                /* Create WNSRP command */
+                pTxPkt = SrpCommandCreate(SrpSendWaitGet(iActiveWnsrpCommandSave.size()), WNSRP_COMMAND_HEADER);
+
+                /* If packet could not be created. */
+                if (pTxPkt.GetRep() == NULL)
+                {
+                    return(0);
+                }
+
+                pTimer = GetFreeWnsrpTimer();
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_1_1 - lowerlayertx wnsrp cmd seq num %d", pTxPkt->getSeqNum()));
+
+                /* Send SRP command */
+                LowerLayerTx(pTxPkt);
+                /* Start response wait timer */
+                SrpT401Start(*pTimer, pTxPkt);
+
+                AddActiveWnsrpTimer(pTimer);
+            }
+            break;
+
+        default:
+            break;
+    }
+
+    return (1);
+}
+
+/************************************************************************/
+/*  function name       : Srp_1_3                                       */
+/*  function outline    : SRP response received in WAITING-RESPONSE     */
+/*  function discription: PVMFSharedMediaDataPtr Srp_1_3(				*/
+/*										PVMFSharedMediaDataPtr pPkt )   */
+/*  input data          : pPkt - pointer of received packet from AL1C   */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::Srp_1_3(PVMFSharedMediaDataPtr pPkt, int event)
+{
+    PVMFSharedMediaDataPtr pSrpCommandPkt;
+    SRPRespTimer *pTimer;
+    uint32 i;
+    uint32 seqNum = pPkt->getSeqNum();
+    bool isWaiting;
+
+    switch (event)
+    {
+        case EV_WNSRP_RESPONSE:
+            // Remove packet from waiting list
+            SrpCommandClear(seqNum);
+
+            for (isWaiting = false, i = 0; i < iActiveWnsrpCommandSave.size(); i++)
+            {
+                if (seqNum == iActiveWnsrpCommandSave[i]->pPkt->getSeqNum())
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_1_3 - wnsrp timer found %d", i));
+
+                    // Resend previous WNSRP packets per section A.4.3
+                    for (uint32 k = 0; k < i; k++)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_1_3 - lowerlayertx EV_WNSRP_RESPONSE wnsrp cmd seq num %d, index k %d", iActiveWnsrpCommandSave[k]->pPkt->getSeqNum(), k));
+
+                        // Send SRP command
+                        LowerLayerTx(iActiveWnsrpCommandSave[k]->pPkt);
+                        // Stop timer
+                        SrpT401Stop(*iActiveWnsrpCommandSave[k]);
+                        // Restart timer
+                        SrpT401Start(*iActiveWnsrpCommandSave[k], iActiveWnsrpCommandSave[k]->pPkt);
+                        // Count-up retry counter
+                        ++iActiveWnsrpCommandSave[k]->N400Counter;
+                    }
+
+                    // Stop response wait timer
+                    SrpT401Stop(*iActiveWnsrpCommandSave[i]);
+
+                    // Release packet
+                    iActiveWnsrpCommandSave[i]->pPkt.Unbind();
+
+                    // Remove timer from active list
+                    RemoveActiveWnsrpTimer(iActiveWnsrpCommandSave[i]);
+
+                    isWaiting = true;
+                    break;
+                }
+            }
+
+            if (!isWaiting)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_3 - WNSRP command with seq %d not waiting for response", seqNum));
+                return 0;
+            }
+            break;
+
+        case EV_NSRP_RESPONSE:
+            // Remove packet from waiting list
+            SrpCommandClear(seqNum);
+
+            //Stop any wnsrp timers with same seq number
+            for (i = 0; i < iActiveWnsrpCommandSave.size(); i++)
+            {
+                if (seqNum == iActiveWnsrpCommandSave[i]->pPkt->getSeqNum())
+                {
+                    // Stop response wait timer
+                    SrpT401Stop(*iActiveWnsrpCommandSave[i]);
+
+                    // Release packet
+                    iActiveWnsrpCommandSave[i]->pPkt.Unbind();
+
+                    // Remove timer from active list
+                    RemoveActiveWnsrpTimer(iActiveWnsrpCommandSave[i]);
+                    break;
+                }
+            }
+
+            if (iSrpCommandSave.isTimerActive)
+            {
+                if (seqNum == iSrpCommandSave.pPkt->getSeqNum())
+                {
+                    // Stop response wait timer
+                    SrpT401Stop(iSrpCommandSave);
+
+                    // Release packet
+                    iSrpCommandSave.pPkt.Unbind();
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_3 - NSRP command seq %d does not match  NSRP resp seq %d", iSrpCommandSave.pPkt->getSeqNum(), seqNum));
+                    return 0;
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_3 - No command waiting for NSRP response"));
+                return 0;
+            }
+            break;
+
+        case EV_RESPONSE:
+            if (iSrpCommandSave.isTimerActive)
+            {
+                //Stop oldest wnsrp timer
+                if (!iActiveWnsrpCommandSave.empty())
+                {
+                    // Stop response wait timer
+                    SrpT401Stop(*iActiveWnsrpCommandSave[0]);
+
+                    // Release packet
+                    iActiveWnsrpCommandSave[0]->pPkt.Unbind();
+
+                    // Remove timer from active list
+                    RemoveActiveWnsrpTimer(iActiveWnsrpCommandSave[0]);
+                }
+
+                // Remove packet from waiting list
+                SrpCommandClear(iSrpCommandSave.pPkt->getSeqNum());
+
+                // Stop response wait timer
+                SrpT401Stop(iSrpCommandSave);
+
+                // Release packet
+                iSrpCommandSave.pPkt.Unbind();
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_3 - No command waiting for SRP response"));
+                return 0;
+            }
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::Srp_1_3 - Invalid response type %d", event));
+            return 0;
+    }
+
+    switch (WnsrpStatusGet())
+    {
+        case NO_WNSRP_SUPPORT:
+        case WNSRP_TX_SUPPORT:
+            // Waiting PDU exists?
+            if (!iSrpWaitQueue.empty())
+            {
+                // Create SRP command
+                pSrpCommandPkt = SrpCommandCreate(SrpSendWaitGet(0), SRP_COMMAND_HEADER);
+
+                if (pSrpCommandPkt.GetRep() == NULL)
+                {
+                    // Set status
+                    SrpStatusSet(STS_IDLE);
+                    return 0;
+                }
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_1_3 - lowerlayertx srp cmd seq num %d", pSrpCommandPkt->getSeqNum()));
+
+                // Send SRP command
+                LowerLayerTx(pSrpCommandPkt);
+                // Start response wait timer
+                SrpT401Start(iSrpCommandSave, pSrpCommandPkt);
+            }
+
+            if (WnsrpStatusGet() == NO_WNSRP_SUPPORT)
+            {
+                break;
+            }
+
+            //Fall through to next case
+
+        case WNSRP_FULL_SUPPORT:
+            //Check if wnsrp timer is available
+            if (iActiveWnsrpCommandSave.size() < iSrpWaitQueue.size())
+            {
+                /* Create WNSRP command */
+                pSrpCommandPkt = SrpCommandCreate(SrpSendWaitGet(iActiveWnsrpCommandSave.size()), WNSRP_COMMAND_HEADER);
+
+                /* If packet could not be created. */
+                if (pSrpCommandPkt.GetRep() == NULL)
+                {
+                    return(0);
+                }
+
+                pTimer = GetFreeWnsrpTimer();
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::Srp_1_3 - lowerlayertx WNSRP_FULL_SUPPORT wnsrp cmd seq num %d", pSrpCommandPkt->getSeqNum()));
+
+                /* Send SRP command */
+                LowerLayerTx(pSrpCommandPkt);
+                /* Start response wait timer */
+                SrpT401Start(*pTimer, pSrpCommandPkt);
+
+                AddActiveWnsrpTimer(pTimer);
+            }
+
+
+            break;
+    }
+
+    if (!iSrpCommandSave.isTimerActive && iActiveWnsrpCommandSave.empty())
+    {
+        // Set status
+        SrpStatusSet(STS_IDLE);
+    }
+
+    /* Get total response time for frame. */
+    UpdateRespStats();
+
+    return(1) ;
+}
+
+/************************************************************************/
+/*  function name       : Srp_1_4                                       */
+/*  function outline    : Response wait timer timeout                   */
+/*                                            in WAITING-RESPONSE       */
+/*  function discription: PVMFSharedMediaDataPtr Srp_1_4(				*/
+/*										PVMFSharedMediaDataPtr pPkt,	*/
+/*										int32 id  )						*/
+/*  input data          : pPkt - pointer of timeout information         */
+/*						  id - id of timer that timed out				*/
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+int SRP::Srp_1_4(int32 id)
+{
+    PVMFSharedMediaDataPtr pSrpCommandPkt;
+    SRPRespTimer *timer;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_4 - Response wait timer timeout"));
+
+    if (iSrpCommandSave.timerID == id)
+    {
+        timer = &iSrpCommandSave;
+    }
+    else if ((uint32) id < iWNSRPTxWindow)
+    {
+        timer = FindActiveWnsrpTimer(id);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::Srp_1_4 - unknown SRP timer %d", id));
+        return 0;
+    }
+
+    // Retry over ?
+    if (SrpN400Check(*timer) == false)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_4 - Max retry over"));
+
+        // Remove command from wait queue.
+        SrpCommandClear(timer->pPkt->getSeqNum());
+
+        // Stop timer
+        SrpT401Stop(*timer);
+
+        //Release packet
+        timer->pPkt.Unbind();
+
+        // Take timer off WNSRP timer wait list (if it is a WNSRP timer)
+        RemoveActiveWnsrpTimer(timer);
+
+        // If observer exists.
+
+
+        if (iObserver)
+        {
+            /* Report transmission failure to TSC.
+               TSC will stop SRP if necessary. */
+            iObserver->TransmissionFailure();
+        }
+
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::Srp_1_4 - No observer!"));
+
+            switch (WnsrpStatusGet())
+            {
+                case NO_WNSRP_SUPPORT:
+                    // Set status
+                    SrpStatusSet(STS_IDLE);
+                    break;
+
+                case WNSRP_TX_SUPPORT:
+                case WNSRP_FULL_SUPPORT:
+                    //If no more packets waiting to be sent.
+                    if (!iSrpWaitQueue.empty())
+                    {
+                        // Set status
+                        SrpStatusSet(STS_IDLE);
+                    }
+                    break;
+            }
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0x40000020, "SRP::Srp_1_4 - Create and send SRP command again, seq num %d", timer->pPkt->getSeqNum()));
+        // Send SRP command
+        LowerLayerTx(timer->pPkt);
+        // Count-up retry counter
+        ++timer->N400Counter;
+    }
+
+    return 1;
+}
+
+/************************************************************************/
+/*  function name       : SrpSendWaitGet                                */
+/*  function outline    : Get from queue for waiting transmittion       */
+/*  function discription: PVMFSharedMediaDataPtr SrpSendWaitGet(		*/
+/*														uint32 index)   */
+/*  input data          : index - index of srp frags                    */
+/*  output data         : data pointer of waiting transmittion          */
+/*  draw time           : '05.08.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+PVMFSharedMediaDataPtr SRP::SrpSendWaitGet(uint32 index)
+{
+    if (index < iSrpWaitQueue.size())
+    {
+        return iSrpWaitQueue[index];
+    }
+    else
+    {
+        PVMFSharedMediaDataPtr temp;
+        return temp;
+    }
+}
+
+/************************************************************************/
+/*  function name       : SrpSendWaitRemove                             */
+/*  function outline    : Remove from queue for waiting transmission    */
+/*  function discription: PVMFSharedMediaDataPtr SrpSendWaitRemove(		*/
+/*														uint32 index)	*/
+/*  input data          : index - index of srp frags                    */
+/*  output data         : data pointer of waiting transmittion          */
+/*  draw time           : '05.08.25                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+int SRP::SrpSendWaitRemove(uint32 index)
+{
+    if (index < iSrpWaitQueue.size())
+    {
+        iSrpWaitQueue.erase(&iSrpWaitQueue[index]);
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+/************************************************************************/
+/*  function name       : SrpSendSeqCount                               */
+/*  function outline    : Count up sequence number for sending          */
+/*  function discription: void SrpSendSeqCount( void )                  */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::SrpSendSeqCount()
+{
+    if (iSendSeqNumber < 255)
+    {
+        ++ iSendSeqNumber;
+    }
+    else
+    {
+        iSendSeqNumber = 0;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpSendSeqCount = %d", iSendSeqNumber));
+    return;
+}
+
+
+/************************************************************************/
+/*  function name       : SrpRecvSeqCount                               */
+/*  function outline    : Count up sequence number for receiving        */
+/*  function discription: void SrpRecvSeqCount( void )                  */
+/*  input data          : None                                          */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::SrpRecvSeqCount()
+{
+    if (iRecvSeqNumber < 255)
+    {
+        ++iRecvSeqNumber;
+    }
+    else
+    {
+        iRecvSeqNumber = 0;
+    }
+
+    if (iOldestWNSRPRetransSeqNum < 255)
+    {
+        ++iOldestWNSRPRetransSeqNum;
+    }
+    else
+    {
+        iOldestWNSRPRetransSeqNum = 0;
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpRecvSeqCount = %d, oldest retrans = %d", iRecvSeqNumber, iOldestWNSRPRetransSeqNum));
+    return;
+}
+
+
+/************************************************************************/
+/*  function name       : SrpStatusSet                                  */
+/*  function outline    : Status number set                             */
+/*  function discription: void SrpStatusSet( SrpStatus newStatus )      */
+/*  input data          : newStatus - status number                     */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::SrpStatusSet(SrpStatus newStatus)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::SrpStatusSet - SrpStatus from %d => %d", iStatus, newStatus));
+    iStatus = newStatus;
+    return;
+}
+
+/************************************************************************/
+/*  function name       : WnsrpStatusSet                                */
+/*  function outline    : WNSRP Status number set                       */
+/*  function discription: void WnsrpStatusSet( WnsrpStatus newStatus )  */
+/*  input data          : newStatus - status number                     */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.23                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::WnsrpStatusSet(WnsrpStatus newStatus)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_VERBOSE, (0x40000020, "SRP::WnsrpStatusSet - WnsrpStatus from %d => %d", iCurWnsrpStatus, newStatus));
+    iCurWnsrpStatus = newStatus;
+
+    switch (iCurWnsrpStatus)
+    {
+        case NO_WNSRP_SUPPORT:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0x40000020, "SRP::WnsrpStatusSet - Remote does not support WNSRP!"));
+            //Clear all WNSRP resp timers
+            while (!iActiveWnsrpCommandSave.empty())
+            {
+                // Stop response wait timer
+                SrpT401Stop(*iActiveWnsrpCommandSave[0]);
+
+                // Release packet
+                iActiveWnsrpCommandSave[0]->pPkt.Unbind();
+
+                // Remove timer from active list
+                RemoveActiveWnsrpTimer(iActiveWnsrpCommandSave[0]);
+            }
+
+            if (iObserver) iObserver->UseWNSRP(false);
+            break;
+
+        case WNSRP_FULL_SUPPORT:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0x40000020, "SRP::WnsrpStatusSet - Remote supports WNSRP!"));
+            //Disable SRP tx
+            if (iSrpCommandSave.isTimerActive)
+            {
+                // Stop response wait timer
+                SrpT401Stop(iSrpCommandSave);
+
+                // Release packet
+                iSrpCommandSave.pPkt.Unbind();
+            }
+
+            //Send all WNSRP frames using the default multiplex table entry number 0
+            *(uint8 *)iWnsrpEntryNumFrag.getMemFragPtr() = SRP_NSRP_MT_ENTRY_NUMBER;
+
+            if (iObserver) iObserver->UseWNSRP(true);
+            break;
+        default:
+            break;
+    }
+    return;
+}
+
+/************************************************************************/
+/*  function name       : SrpT401Start                                  */
+/*  function outline    : T401 timer start                              */
+/*  function discription: void SrpT401Start( SRPRespTimer &timer )      */
+/*  input data          : timer - timer to start                        */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::SrpT401Start(SRPRespTimer &timer, PVMFSharedMediaDataPtr pPkt)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "SRP::SrpT401Start - id %d, IsPrimaryTimerActive = %d", timer.timerID, timer.isTimerActive));
+
+    /* Start timer that is not active. */
+    if (!timer.isTimerActive)
+    {
+        timer.T401Timer.Request(timer.timerID, (int32)this, iT401TimerValue, this, true);
+        timer.isTimerActive = true;
+    }
+
+    timer.pPkt = pPkt;
+    timer.N400Counter = 0;
+
+    return;
+}
+
+/************************************************************************/
+/*  function name       : SrpT401Stop                                   */
+/*  function outline    : T401 timer stop                               */
+/*  function discription: void SrpT401Stop( SRPRespTimer &timer )       */
+/*  input data          : timer - timer to stop                         */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.24                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::SrpT401Stop(SRPRespTimer &timer)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::SrpT401Stop - id %d, IsPrimaryTimerActive = %d", timer.timerID, timer.isTimerActive));
+
+    /* Reset active timer */
+    if (timer.isTimerActive)
+    {
+        timer.T401Timer.Cancel(timer.timerID);
+        timer.isTimerActive = false;
+    }
+
+    return;
+}
+
+/************************************************************************/
+/*  function name       : SrpT401Timeout                                */
+/*  function outline    : T401 timeout                                  */
+/*  function discription: int SrpT401Timeout(int TimerId, void *Param)  */
+/*  input data          : TimerId - timer id                            */
+/*                        Param - timer parameter                       */
+/*  output data         : 0 - Reset timer  to fire again                */
+/*						  1 - Do not reset timer						*/
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+// OsclTimerObserver virtual function
+void SRP::TimeoutOccurred(int32 timerID, int32 param)
+{
+    OSCL_UNUSED_ARG(param);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::TimeoutOccurred, id %d, wnsrp status %d", timerID, iCurWnsrpStatus));
+
+    iStats.totalNumTimeouts++;
+
+    /* Process call */
+    SrpStateChange(SrpStatusGet(), EV_TIMEOUT, (void *) &timerID);
+}
+
+
+/************************************************************************/
+/*  function name       : LowerLayerRx									*/
+/*  function outline    : Lower Layer Receive                           */
+/*  function description: void LowerLayerRx(MediaPacket* pPkt)			*/
+/*  input data          : pPkt - pointer to incoming packet             */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::LowerLayerRx(PVMFSharedMediaDataPtr pPkt)
+{
+    int32 error;
+    OsclSharedPtr<PVMFMediaDataImpl> data;
+    OSCL_TRY(error, data = iRxPacketAlloc->allocate(MAX_SIZE_OF_SRP_PDU));
+    OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::LowerLayerRx - Unable allocate rx message impl %d", error));
+                         return);
+
+    OsclRefCounterMemFrag frag;
+    data->getMediaFragment(0, frag);
+    uint8* pos = (uint8*)frag.getMemFragPtr();
+    for (unsigned i = 0;i < pPkt->getNumFragments();i++)
+    {
+        OsclRefCounterMemFrag src_frag;
+        pPkt->getMediaFragment(i, src_frag);
+        oscl_memcpy(pos, src_frag.getMemFragPtr(), src_frag.getMemFragSize());
+        pos += src_frag.getMemFragSize();
+    }
+    data->setMediaFragFilledLen(0, pPkt->getFilledSize());
+    /* Record number of frames received from lower layer. */
+    iStats.totalFramesRecv++;
+
+    /* Record number of bytes received. */
+    iStats.totalBytesRecv += pPkt->getFilledSize();
+
+    /* Process call */
+    PVMFSharedMediaDataPtr mediaData;
+    OSCL_TRY(error, mediaData = PVMFMediaData::createMediaData(data, iRxMediaMsgPoolAlloc));
+    OSCL_FIRST_CATCH_ANY(error, PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::LowerLayerRx - Unable allocate rx message %d", error));
+                         return);
+    SrpStateChange(SrpStatusGet(), SrpGetEventNoFromAL1(mediaData), &mediaData);
+    return;
+
+}
+
+/************************************************************************/
+/*  function name       : UpperLayerRx									*/
+/*  function outline    : Upper Layer Receive                           */
+/*  function description: void UpperLayerRx(MediaPacket* pPkt)			*/
+/*  input data          : pPkt - pointer to incoming packet             */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::UpperLayerRx(PVMFSharedMediaDataPtr pPkt)
+{
+    uint32 offset;
+    uint8 *buf;
+    PVMFSharedMediaDataPtr srpPkt;
+    OsclRefCounterMemFrag newFrag;
+    OsclRefCounterMemFrag CCSRLFrag;
+    OsclRefCounterMemFrag frag;
+    OsclSharedPtr<PVMFMediaDataImpl> data;
+    uint8 seqNum;
+    uint32 size;
+
+    iStats.totalH245MessagesToSend++;
+
+
+    // IMPORTANT: Assume upper layer is sending 1 fragment in a packet!
+    if (pPkt->getNumFragments() != 1)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::UpperLayerRx - Num frags of incoming message not equal to 1, %d", pPkt->getNumFragments()));
+        return;
+    }
+
+    pPkt->getMediaFragment(0, frag);
+
+    /* CCSRL */
+    if (iCcsrlSduSize > 0)
+    {
+        //---------------------------------------------------------
+        // Send the encoded message (pCodeData, GetSize) to SRP
+        //   using the multi-chunk feature of H.324.
+        //---------------------------------------------------------
+        size = frag.getMemFragSize();
+
+        // If queue cannot hold the number of fragments that will be needed.
+        // If not enough messages available to send the entire message
+        if (((size / iCcsrlSduSize) + 1) > iTxPacketAlloc->NumMsgAvail())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::UpperLayerRx - Unable allocate enough messages, current num %d", iTxPacketAlloc->NumMsgAvail()));
+            return;
+        }
+
+        if (size > iCcsrlSduSize)
+        {
+            iStats.totalH245MessagesFragmented++;
+        }
+
+        buf = (uint8 *) frag.getMemFragPtr();
+        offset = 0;
+
+        while (offset < size)
+        {
+            if (!Allocate(data, CCSRLFrag))
+                return;
+            newFrag = frag;
+            newFrag.getMemFrag().ptr = (buf + offset);
+
+            /* Set sequence number */
+            seqNum = (uint8)SrpSendSeqGet();
+            SrpSendSeqCount();
+            *(uint8 *)CCSRLFrag.getMemFrag().ptr = seqNum;
+            CCSRLFrag.getMemFrag().len = SRP_SEQUENCE_SIZE + CCSRL_HEADER_SIZE;
+
+            if ((offset + iCcsrlSduSize) >= size)
+            {
+                /* Last CCSRL chunk */
+                *((uint8 *)CCSRLFrag.getMemFrag().ptr + 1) = LAST_CCSRL_CHUNK;
+                data->appendMediaFragment(CCSRLFrag);
+
+                newFrag.getMemFrag().len = size - offset;
+
+                offset += (size - offset);
+            }
+            else
+            {
+                /* Intermediate CCSRL chunk */
+                *((uint8 *)CCSRLFrag.getMemFrag().ptr + 1) = INTERMEDIATE_CCSRL_CHUNK;
+                data->appendMediaFragment(CCSRLFrag);
+
+                newFrag.getMemFrag().len = iCcsrlSduSize;
+
+                offset += iCcsrlSduSize;
+            }
+
+            data->appendMediaFragment(newFrag);
+            if (!CreateMediaData(srpPkt, data))
+                return;
+            srpPkt->setSeqNum(seqNum);
+
+            /* Queue received PDU */
+            SrpSendWaitSet(srpPkt);
+        }
+    }
+    else
+    {
+        // If no message available to send the entire message
+        if (iTxPacketAlloc->NumMsgAvail() == 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::UpperLayerRx - no message available"));
+            return;
+        }
+        if (!Allocate(data, CCSRLFrag))
+            return;
+
+        /* Set sequence number */
+        seqNum = (uint8) SrpSendSeqGet();
+        SrpSendSeqCount();
+        *(uint8 *)CCSRLFrag.getMemFrag().ptr = seqNum;
+        CCSRLFrag.getMemFrag().len = SRP_SEQUENCE_SIZE;
+
+        data->appendMediaFragment(CCSRLFrag);
+
+        data->appendMediaFragment(frag);
+
+        if (!CreateMediaData(srpPkt, data))
+            return;
+
+        //---------------------------------------------------------
+        // Send the encoded message (pCodeData, GetSize) to SRP
+        //   without using the H.324 multi-chunk method.
+        //---------------------------------------------------------
+
+        srpPkt->setSeqNum(seqNum);
+
+        /* Queue received PDU */
+        SrpSendWaitSet(srpPkt);
+    }
+
+    /* Process call */
+    SrpStateChange(SrpStatusGet(), EV_PDU, NULL);
+
+    return;
+}
+
+bool SRP::Allocate(OsclSharedPtr<PVMFMediaDataImpl>& data, OsclRefCounterMemFrag& CCSRLFrag)
+{
+    data = iTxPacketAlloc->allocate();
+
+    if (!data)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0x40000020, "SRP::UpperLayerRx - Unable allocate tx media impl"));
+        return false;
+    }
+
+    CCSRLFrag = iCcsrlAllocator.get();
+
+    return (CCSRLFrag.getMemFragPtr() ? true : false);
+}
+
+/************************************************************************/
+/*  function name       : UseNSRP								   		*/
+/*  function outline    : Set use of NSRP response frames or not.       */
+/*  function description: void UseNSRP( bool aUseNsrp )					*/
+/*  input data          : None							                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.23                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::UseNSRP(bool aUseNsrp)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_INFO, (0x40000020, "SRP::UseNSRP - cur %d, new %d", iUseNSRP, aUseNsrp));
+    if (aUseNsrp == iUseNSRP)
+    {
+        return;
+    }
+    iUseNSRP = aUseNsrp;
+    iFirstNSRPResp = false;
+    return;
+}
+
+/************************************************************************/
+/*  function name       : DisableWNSRPSupport					   		*/
+/*  function outline    : Disables all support for WNSRP.  Must be      */
+/*						  called before initailization.					*/
+/*  function description: void DisableWNSRPSupport()					*/
+/*  input data          : None							                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.23                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::DisableWNSRPSupport()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::DisableWNSRPSupport"));
+
+    if (WnsrpStatusGet() == WNSRP_TX_SUPPORT)
+    {
+        WnsrpStatusSet(NO_WNSRP_SUPPORT);
+    }
+
+    iHandleWNSRP = false;
+    return;
+}
+
+/************************************************************************/
+/*  function name       : SrpResetStats									*/
+/*  function outline    : Reset statistics                              */
+/*  function description: void SrpResetStats( void )					*/
+/*  input data          : None							                */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::SrpResetStats()
+{
+    iStats.Reset();
+    iTotalRespTime = 0;
+}
+
+/************************************************************************/
+/*  function name       : SrpGetStats									*/
+/*  function outline    : Retrieve statistics                           */
+/*  function description: void SrpGetStats(SRPStats &aStats)			*/
+/*  input data          : aStats - iStats object to fill                 */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::SrpGetStats(SRPStats &aStats)
+{
+    if (iStats.totalCCSRLChunksSent > 0)
+    {
+        iStats.aveRespTime = iTotalRespTime / iStats.totalCCSRLChunksSent;
+    }
+    else
+    {
+        iStats.aveRespTime = 0;
+    }
+
+    aStats = iStats;
+}
+
+/************************************************************************/
+/*  function name       : UpdateRespStats								*/
+/*  function outline    : Update response statistics                    */
+/*  function description: void UpdateRespStats()						*/
+/*  input data          : None							                */
+/*  output data         : None                                          */
+/*  draw time           : '96.10.29                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 1996 NTT DoCoMo               */
+/************************************************************************/
+void SRP::UpdateRespStats()
+{
+    TimeValue timeNow;
+    uint32 timeDifference;
+
+    timeNow.set_to_current_time();
+
+    timeDifference = timeNow.to_msec() - iInitialTimeChunkSent.to_msec();
+
+    if (timeDifference > iStats.maxRespTime)
+    {
+        iStats.maxRespTime = timeDifference;
+    }
+    else if (timeDifference < iStats.minRespTime)
+    {
+        iStats.minRespTime = timeDifference;
+    }
+
+    iTotalRespTime += timeDifference;
+}
+
+/************************************************************************/
+/*  function name       : GetFreeWnsrpTimer								*/
+/*  function outline    : Get free WNSRP response timer                 */
+/*  function description: SRPRespTimer *GetFreeWnsrpTimer()				*/
+/*  input data          : None							                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+SRP::SRPRespTimer *SRP::GetFreeWnsrpTimer()
+{
+    SRPRespTimer *timer = NULL;
+    if (!iFreeWnsrpCommandSave.empty())
+    {
+        timer = iFreeWnsrpCommandSave[0];
+        iFreeWnsrpCommandSave.erase(iFreeWnsrpCommandSave.begin());
+    }
+
+    return timer;
+}
+
+/************************************************************************/
+/*  function name       : FindActiveWnsrpTimer							*/
+/*  function outline    : Get free WNSRP response timer                 */
+/*  function description: SRPRespTimer *FindActiveWnsrpTimer(			*/
+/*														int32 timerID)	*/
+/*  input data          : timerID - id of timer			                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+SRP::SRPRespTimer *SRP::FindActiveWnsrpTimer(int32 timerID)
+{
+    for (uint32 i = 0; i < iActiveWnsrpCommandSave.size(); i++)
+    {
+        if (iActiveWnsrpCommandSave[i]->timerID == timerID)
+        {
+            return iActiveWnsrpCommandSave[i];
+        }
+    }
+
+    return NULL;
+}
+
+/************************************************************************/
+/*  function name       : RemoveActiveWnsrpTimer						*/
+/*  function outline    : Remove an timer from the active WNSRP timer   */
+/*						  list											*/
+/*  function description: void RemoveActiveWnsrpTimer(					*/
+/*												SRPRespTimer *timer)	*/
+/*  input data          : timer - timer to remove		                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::RemoveActiveWnsrpTimer(SRPRespTimer *timer)
+{
+    //Timer should be stopped before this method is called.
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::RemoveActiveWnsrpTimer id %d", timer->timerID));
+
+    for (uint32 i = 0; i < iActiveWnsrpCommandSave.size(); i++)
+    {
+        if (iActiveWnsrpCommandSave[i] == timer)
+        {
+            FreeWnsrpTimer(iActiveWnsrpCommandSave[i]);
+            iActiveWnsrpCommandSave.erase(&iActiveWnsrpCommandSave[i]);
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::RemoveActiveWnsrpTimer timer removed index %d", i));
+            return;
+        }
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::RemoveActiveWnsrpTimer timer not found"));
+    return;
+}
+
+
+/************************************************************************/
+/*  function name       : FreeRxFrag									*/
+/*  function outline    : Free a frag to the free list					*/
+/*  function description: void FreeRxFrag(SRPRxData *frag)				*/
+/*  input data          : timer - timer to remove		                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::FreeRxFrag(SRPRxData *frag)
+{
+    frag->seqNum = 0;
+    frag->data.Unbind();
+
+    frag->next = iFreeRxFragList;
+    iFreeRxFragList = frag;
+
+    return;
+}
+
+/************************************************************************/
+/*  function name       : GetRxFrag										*/
+/*  function outline    : Remove an frag from the free list				*/
+/*  function description: SRPRxData *GetRxFrag()						*/
+/*  input data          : timer - timer to remove		                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+SRP::SRPRxData *SRP::GetRxFrag(void)
+{
+    SRPRxData *free;
+    if (iFreeRxFragList)
+    {
+        free = iFreeRxFragList;
+        iFreeRxFragList = iFreeRxFragList->next;
+        return free;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+/************************************************************************/
+/*  function name       : AddPendingRxFrag								*/
+/*  function outline    : Add a rx frag to the pending list in order of */
+/*						  rx sequence number mod 256.					*/
+/*  function description: void AddPendingRxFrag(SRPRxData *frag)		*/
+/*  input data          : timer - timer to remove		                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+void SRP::AddPendingRxFrag(SRPRxData *frag)
+{
+    SRPRxData *cur = iPendingRxFragList;
+    SRPRxData *prev = NULL;
+
+    while (cur)
+    {
+        if (cur->seqNum > frag->seqNum)
+        {
+            if (prev)
+            {
+                prev->next = frag;
+                frag->next = cur;
+            }
+            else
+            {
+                frag->next = iPendingRxFragList;
+                iPendingRxFragList = frag;
+            }
+            return;
+        }
+
+        prev = cur;
+        cur = cur->next;
+    }
+
+    frag->next = NULL;
+    if (prev)
+    {
+        prev->next = frag;
+    }
+    else
+    {
+        iPendingRxFragList = frag;
+    }
+    return;
+}
+
+/************************************************************************/
+/*  function name       : CheckRxSeqNum									*/
+/*  function outline    : Check Rx sequence number for against the		*/
+/*						  pending rx frags.								*/
+/*  function description: bool CheckRxSeqNum(uint32 seqNum,				*/
+/*														uint8 header)	*/
+/*  input data          : timer - timer to remove		                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+bool SRP::CheckRxSeqNum(uint32 seqNum, uint8 header)
+{
+    PVMFSharedMediaDataPtr resp;
+    uint32 endSeqNum;
+
+    //If WNSRP command
+    switch (header)
+    {
+        case WNSRP_RESPONSE_HEADER:
+            //Check if data is already pending to be sent up
+            if (CheckPendingRxList(seqNum))
+            {
+                /* Create WNSRP response */
+                resp = SrpResponseCreate((uint8) seqNum, header);
+                if (resp.GetRep() == NULL)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::CheckRxSeqNum - Unable create WNSRP reponse packet"));
+                    /* If unable to create response message. */
+                    return false;
+                }
+
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::CheckRxSeqNum - lowerlayertx wnsrp resp seq num %d", resp->getSeqNum()));
+
+                /* SRP response send */
+                LowerLayerTx(resp);
+                return false;
+            }
+
+            endSeqNum = (SrpRecvSeqGet() + iWNSRPRxWindow) % 256;
+            //If rx window does not wrap
+            if (endSeqNum > SrpRecvSeqGet())
+            {
+                //If can't accept sequence number because of rx window
+                if ((seqNum < SrpRecvSeqGet()) ||
+                        (seqNum > endSeqNum))
+                {
+                    if (CheckWNSRPRetrans(seqNum))
+                    {
+                        /* Create WNSRP response */
+                        resp = SrpResponseCreate((uint8) seqNum, header);
+                        if (resp.GetRep() == NULL)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::CheckRxSeqNum - Unable create WNSRP reponse packet"));
+                            /* If unable to create response message. */
+                            return false;
+                        }
+
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::CheckRxSeqNum - lowerlayertx wnsrp resp seq num %d", resp->getSeqNum()));
+
+                        /* SRP response send */
+                        LowerLayerTx(resp);
+                    }
+                    return false;
+                }
+
+                //Else can accept sequence number
+            }
+            //Else window wraps around
+            else
+            {
+                //If can accept sequence number
+                if ((seqNum >= SrpRecvSeqGet()) ||
+                        (seqNum <= endSeqNum))
+                {
+                    return true;
+                }
+                //Else can't accept sequence number
+                else
+                {
+                    if (CheckWNSRPRetrans(seqNum))
+                    {
+                        /* Create WNSRP response */
+                        resp = SrpResponseCreate((uint8) seqNum, header);
+                        if (resp.GetRep() == NULL)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::CheckRxSeqNum - Unable create WNSRP reponse packet"));
+                            /* If unable to create response message. */
+                            return false;
+                        }
+
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::CheckRxSeqNum - lowerlayertx wnsrp resp seq num %d", resp->getSeqNum()));
+
+                        /* SRP response send */
+                        LowerLayerTx(resp);
+                    }
+                    return false;
+                }
+            }
+            return true;
+
+        case NSRP_RESPONSE_HEADER:
+        case SRP_RESPONSE_HEADER:
+            if (seqNum != SrpRecvSeqGet())
+            {
+                if (((seqNum + 1) % 256) == SrpRecvSeqGet())
+                {
+                    /* Create SRP response */
+                    resp = SrpResponseCreate((uint8) seqNum, header);
+                    if (resp.GetRep() == NULL)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0x40000020, "SRP::CheckRxSeqNum - Unable create SRP reponse packet"));
+                        /* If unable to create response message. */
+                        return false;
+                    }
+
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0x40000020, "SRP::CheckRxSeqNum - lowerlayertx srp resp seq num %d", resp->getSeqNum()));
+
+                    /* SRP response send */
+                    LowerLayerTx(resp);
+                }
+                return false;
+            }
+            return true;
+
+        default:
+            return false;
+    }
+}
+
+/************************************************************************/
+/*  function name       : CheckPendingRxList							*/
+/*  function outline    : Check pending rx list against sequence number	*/
+/*  function description: bool CheckRxSeqNum(uint32 seqNum)				*/
+/*  input data          : seqNum - sequence number to check	            */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+bool SRP::CheckPendingRxList(uint32 seqNum)
+{
+    SRPRxData *data = iPendingRxFragList;
+    while (data)
+    {
+        if (data->seqNum == seqNum)
+        {
+            return true;
+        }
+        data = data->next;
+    }
+    return false;
+}
+
+/************************************************************************/
+/*  function name       : CheckWNSRPRetrans								*/
+/*  function outline    : Check Rx sequence number for WNSRP retrans	*/
+/*						  window.										*/
+/*  function description: bool CheckWNSRPRetrans(uint32 seqNum)			*/
+/*  input data          : timer - timer to remove		                */
+/*  output data         : None                                          */
+/*  draw time           : '05.08.26                                     */
+/*----------------------------------------------------------------------*/
+/*  amendent career     :                                               */
+/*                          Copyright (C) 2005 PacketVideo Corp.        */
+/************************************************************************/
+bool SRP::CheckWNSRPRetrans(uint32 seqNum)
+{
+    //Retrans window does not wrap
+    if (iOldestWNSRPRetransSeqNum < SrpRecvSeqGet())
+    {
+        if ((seqNum < SrpRecvSeqGet()) &&
+                (seqNum > iOldestWNSRPRetransSeqNum))
+        {
+            return true;
+        }
+    }
+    //Retrans window wraps
+    else if ((seqNum < SrpRecvSeqGet()) ||
+             (seqNum > iOldestWNSRPRetransSeqNum))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_blc.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_blc.h
new file mode 100644
index 0000000..c6fd646
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_blc.h
@@ -0,0 +1,85 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_blc.h                                         */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCBLC_H_INCLUDED
+#define TSCBLC_H_INCLUDED
+
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef H245_H_INCLUDED
+#include "h245.h"
+#endif
+
+#ifndef H223TYPES_H_INCLUDED
+#include "h223types.h"
+#endif
+
+
+class TSC_statemanager;
+
+
+class TSC_blc
+{
+    public:
+        TSC_blc(TSC_statemanager& aStateManager):  iTSCstatemanager(aStateManager)
+        {
+            iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+        };
+        ~TSC_blc() {};
+
+        void SetH245(H245* aH245)
+        {
+            iH245 = aH245;
+        }
+        /* Bi-Directional Logical Channel Establish */
+        void BlcEtbReq(TPVChannelId Lcn,
+                       PS_DataType pDataTypeForward,
+                       PS_H223LogicalChannelParameters pH223ParamsForward,
+                       PS_DataType pDataTypeReverse,
+                       PS_H223LogicalChannelParameters pH223ParamsReverse);
+        void BlcEtbRps(TPVChannelId, TPVChannelId);
+        TPVDirection BlcRlsReq(int32, uint32, uint32);	// add cause parameter
+    private:
+        H245* iH245;
+        TSC_statemanager& iTSCstatemanager;
+        PVLogger* iLogger;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_capability.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_capability.h
new file mode 100644
index 0000000..c855c30
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_capability.h
@@ -0,0 +1,147 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_capability.h                                  */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCCAPABILILTY_H_INCLUDED
+#define TSCCAPABILILTY_H_INCLUDED
+
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef TSC_H_INCLUDED
+#include "tsc.h"
+#endif
+
+#ifndef H245DEF_H_INCLUDED
+#include "h245def.h"
+#endif
+
+#ifndef H245PRI_H_INCLUDED
+#include "h245pri.h"
+#endif
+
+#ifndef TSC_CONSTANTS_H_INCLUDED
+#include "tsc_constants.h"
+#endif
+
+
+class TSC_statemanager;
+class TSC_component;
+
+class TSC_capability
+{
+    public:
+        TSC_capability(TSC_statemanager& aTSCstatemanager) :
+                iTSCstatemanager(aTSCstatemanager),
+                iRemoteCapability(NULL)
+        {
+            iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+        };
+
+        ~TSC_capability();
+
+        void SetMembers(TSC_component* aTSCcomponent)
+        {
+            iTSCcomponent = aTSCcomponent;
+        }
+        void InitVarsSession();
+        void InitVarsLocal();
+
+        CPvtTerminalCapability* GetRemoteCapability();
+        uint32 GetRemoteBitrate(PVCodecType_t codec_type);
+        void ResetCapability();
+        void CreateNewCapability(Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator> aCapabilityItems)
+        {
+            iRemoteCapability = new CPvtTerminalCapability(aCapabilityItems);
+        }
+        void ExtractTcsParameters(PS_VideoCapability apVideo, CPvtH263Capability *aMedia_capability);
+        void ExtractTcsParameters(PS_VideoCapability pVideo, CPvtMpeg4Capability *aMedia_capability);
+        void ParseTcsCapabilities(S_Capability &aCapability, Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator> &aMedia_capability, uint32 userInputCapabilities, S_UserInputCapability *aUserInputCapability);
+        bool IsSegmentable(TPVDirection direction, PV2WayMediaType media_type);
+
+        PS_DataType GetOutgoingDataType(PVCodecType_t codecType, uint32 bitrate, uint16 csi_len, uint8* csi);
+        PS_H223LogicalChannelParameters GetOutgoingLcnParams(PV2WayMediaType media_type,
+                PS_AdaptationLayerType adaptation_layer);
+        PVMFStatus ValidateIncomingDataType(bool forRev, PS_DataType pDataType);
+        PVMFStatus ValidateIncomingH223LcnParams(PS_H223LogicalChannelParameters h223params, TPVDirection dir);
+        PVMFStatus ValidateForwardReverseParams(PS_ForwardReverseParam forRevParams, TPVDirection dir);
+        bool VerifyReverseParameters(PS_ForwardReverseParam forRevParams,
+                                     TSCObserver* aObserver,
+                                     PVMFStatus& status);
+        uint32 GetMaxBitrateForOutgoingChannel(PVCodecType_t codecType);
+        PS_DataType GetDataType(PVCodecType_t codecType, uint32 bitrate, const uint8* dci, uint16 dci_len);
+        uint16 GetSupportedCodecCapabilityInfo(TPVDirection dir,
+                                               PV2WayMediaType mediaType,
+                                               Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& cci);
+        bool HasSymmetryConstraint(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& codec_list);
+        CodecCapabilityInfo* SelectOutgoingCodec(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* remote_list,
+                Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* local_list);
+        CodecCapabilityInfo* SelectOutgoingCodec(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* remote_list);
+
+
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator> GetResolutions(TPVDirection dir);
+        void SetVideoResolutions(TPVDirection dir,
+                                 Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& resolutions);
+
+
+    private:
+
+        // -------------------------------------------------
+        // Parameters extracted from incoming TCS (RAN-32K)
+        // -------------------------------------------------
+        uint32 iTcsIn_H263_sqcifMPI;		// Units 1/30 second
+        uint32 iTcsIn_H263_qcifMPI;		// Units 1/30 second
+        uint32 iTcsIn_H263_cifMPI;		// Units 1/30 second
+        uint32 iTcsIn_H263_4cifMPI;		// Units 1/30 second
+        uint32 iTcsIn_H263_16cifMPI;		// Units 1/30 second
+
+
+        /* Video resolutions */
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator> iResolutionsRx;
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator> iResolutionsTx;
+
+        TSC_statemanager& iTSCstatemanager;
+        /* Capability of local and remote and mutual capabiliites */
+        CPvtTerminalCapability* iRemoteCapability;
+        PVLogger* iLogger;
+
+
+        TSC_component* iTSCcomponent;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_channelcontrol.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_channelcontrol.h
new file mode 100644
index 0000000..6ec756d
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_channelcontrol.h
@@ -0,0 +1,104 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_channelcontrol.h                                         */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCCHANNELCONTROL_H_INCLUDED
+#define TSCCHANNELCONTROL_H_INCLUDED
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef TSC_CONSTANTS_H_INCLUDED
+#include "tsc_constants.h"
+#endif
+#include "tsc.h"
+#include "cpvh223multiplex.h"
+
+class TSC_statemanager;
+class TSC_blc;
+class TSC_mt;
+class TSC_lc;
+class TSC_component;
+class TSC_capability;
+class TSC_clc;
+
+class TSC_channelcontrol
+{
+    public:
+        TSC_channelcontrol(OlcList& aOlcs,
+                           TSC_statemanager& aTSCStateManager,
+                           TSC_blc& aTSCblc,
+                           TSC_mt& aTSCmt,
+                           TSC_lc& aTSClc,
+                           TSC_capability& aTSCcapability,
+                           TSC_clc& aTSCclc,
+                           TSC_component& aTSCcomponent);
+        ~TSC_channelcontrol() {};
+
+        void SetMembers(H223* aH223, TSCObserver* aTSCObserver)
+        {
+            iObserver = aTSCObserver;
+            iH223 = aH223;
+        }
+
+        LogicalChannelInfo* GetLogicalChannelInfo(PVMFPortInterface& port);
+        // utility functions
+        TPVStatusCode RequestIncomingChannelClose(TPVChannelId lcn);
+
+        bool IsEstablishedLogicalChannel(TPVDirection aDir, TPVChannelId aChannelId);
+        void ReceivedFormatSpecificInfo(TPVChannelId lcn, uint8* fsi, uint32 fsi_len);
+
+    private:
+        OlcList& iOlcs;
+        TSCObserver* iObserver;
+
+        // The H223 instance
+        H223* iH223;
+
+        PVLogger* iLogger;
+
+        TSC_statemanager& iTSCstatemanager;
+        TSC_blc& iTSCblc;
+        TSC_mt& iTSCmt;
+        TSC_lc& iTSClc;
+        TSC_capability& iTSCcapability;
+        TSC_clc& iTSCclc;
+
+        TSC_component& iTSCcomponent;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_clc.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_clc.h
new file mode 100644
index 0000000..ed61609
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_clc.h
@@ -0,0 +1,68 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_clc.h                                         */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCCLC_H_INCLUDED
+#define TSCCLC_H_INCLUDED
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#include "h245.h"
+
+
+class TSC_clc
+{
+    public:
+
+        TSC_clc() {};
+        ~TSC_clc() {};
+
+        void SetH245(H245* aH245)
+        {
+            iH245 = aH245;
+        }
+
+        /* Close Logical Channel */
+        void ClcClsReq(uint32);
+        void ClcClsRps(uint32);
+        void ClcRjtReq(uint32);
+    private:
+        H245* iH245;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_component.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_component.h
new file mode 100644
index 0000000..0466851
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_component.h
@@ -0,0 +1,334 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_component.h                                   */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCCOMPONENT_H_INCLUDED
+#define TSCCOMPONENT_H_INCLUDED
+
+
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#ifndef TSC_H_INCLUDED
+#include "tsc.h"
+#endif
+
+#ifndef H245_H_INCLUDED
+#include "h245.h"
+#endif
+
+#ifndef TSC_NODE_INTERFACE_H_INCLUDED
+#include "tsc_node_interface.h"
+#endif
+
+#ifndef TSC_CHANNELCONTROL_H_INCLUDED
+#include "tsc_channelcontrol.h"
+#endif
+
+#ifndef TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
+#include "tsc_h324m_config_interface.h"
+#endif
+
+class TSC_statemanager;
+class TSC_capability;
+class TSC_mt;
+class TSC_lc;
+class TSC_blc;
+class TSC_clc;
+
+
+
+class TSC_component : public OsclTimerObserver,
+            public PVMFComponentInterface
+{
+    public:
+        TSC_component(TSC_statemanager& aTSCStateManager,
+                      TSC_capability& aTSCcapability,
+                      TSC_lc& aTSClc,
+                      TSC_blc& aTSCblc,
+                      TSC_clc& aTSCclc,
+                      TSC_mt& aTSCmt);
+
+        void SetMembers(H245* aH245, H223* aH223, TSCObserver* aTSCObserver);
+        bool queryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr);
+
+        void Init()
+        {
+            InitVarsLocal();
+            InitVarsSession();
+        }
+        bool CEStart();
+        virtual void InitVarsSession();
+        virtual void InitVarsLocal();
+        virtual void MembersSet() {};
+        void InitTsc();
+        void ResetTsc();
+        void Disconnect();
+
+        void GetTerminalParam(CPVH324MParam& ah324param);
+        TPVStatusCode SetTerminalParam(CPVTerminalParam& params);
+
+        bool IsSupported(TPVDirection dir, PV2WayMediaType media, CodecCapabilityInfo& codec_info);
+        bool IsSupported(TPVDirection dir, PVCodecType_t codec, FormatCapabilityInfo& capability_info);
+
+        virtual void ExtractTcsParameters(PS_TerminalCapabilitySet pTcs);
+        void CETransferIndication(OsclSharedPtr<S_TerminalCapabilitySet> tcs, uint32 aTerminalStatus);
+        TPVAdaptationLayer GetVideoLayer()
+        {
+            return iVideoLayer;
+        }
+
+        void ClipCodecs(PS_TerminalCapabilitySet pTcs);			// (RAN-32K)
+
+        // mux descriptors
+        CPVMultiplexEntryDescriptor* GenerateSingleDescriptor(uint8 entry_num, TPVChannelId lcn1);
+        void SetAlConfig(PV2WayMediaType media_type,
+                         TPVAdaptationLayer layer,
+                         bool allow);
+
+        void SetAl2Al3VideoFlags(int32 userInput);
+        int32 GetAl2Al3VideoFlags();
+        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* GetChannelConfig(TPVDirection dir);
+        void SetAl3ControlFieldOctets(unsigned cfo);
+
+        void SetAl2Sn(int width);
+        uint32 LcEtbIdc(PS_ControlMsgHeader pReceiveInf);
+        uint32 BlcEtbIdc(PS_ControlMsgHeader pReceiveInf);
+        PVMFStatus ValidateOlcsWithTcs();
+        OsclAny TcsMsdComplete();
+
+        virtual void SetOutgoingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& out_channel_config);
+        virtual void SetIncomingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& in_channel_config);
+        virtual uint32 LcEtbCfm(PS_ControlMsgHeader pReceiveInf);
+        unsigned GetOutgoingBitrate(PVCodecType_t codecType);
+        void GetChannelFormatAndCapabilities(TPVDirection dir,
+                                             Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& formats);
+
+
+        bool HasOlc(TPVDirection direction, TPVChannelId id, unsigned state = 0);
+        OlcParam* FindOlcGivenChannel(TPVDirection direction, TPVChannelId id);
+        OlcParam* FindOlc(TPVDirection direction, PV2WayMediaType media_type, unsigned state = 0);
+
+        virtual void LcnDataDetected(TPVChannelId lcn);
+        OsclAny AcceptBLCRequest(TPVChannelId OpenLcnF,
+                                 TPVChannelId OpenLcnB,
+                                 PS_ForwardReverseParam forRevParams);
+        uint32 LcRlsIdc(PS_ControlMsgHeader pReceiveInf);
+        uint32 BlcRlsIdc(PS_ControlMsgHeader pReceiveInf);
+        OsclAny MuxTableSendComplete(uint32 sn, PVMFStatus status);
+        OsclAny StopData();
+        void Start();
+        virtual void StartDisconnect(bool terminate);
+        virtual bool Connect1LevelKnown();
+        virtual void Connect2();
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+        virtual bool ProcessCommand(Tsc324mNodeCommand& aCmd)
+        {
+            OSCL_UNUSED_ARG(aCmd);
+            return false;
+        }
+        virtual void MuxSetupComplete(PVMFStatus status, TPVH223Level level)
+        {
+            OSCL_UNUSED_ARG(status);
+            OSCL_UNUSED_ARG(level);
+        };
+        virtual Tsc324mNodeCommand* GetCommand()
+        {
+            return NULL;
+        };
+        virtual bool IsEnabled()
+        {
+            return true;
+        };
+        uint32 Status08Event19(PS_ControlMsgHeader pReceiveInf);
+        uint32 BlcEtbCfm(PS_ControlMsgHeader pReceiveInf);
+        uint32 BlcEtbCfm2(PS_ControlMsgHeader pReceiveInf);
+        uint32 LcRlsCfm(PS_ControlMsgHeader pReceiveInf);
+        uint32 BlcRlsCfm(PS_ControlMsgHeader pReceiveInf);
+        void CloseChannels();
+        LogicalChannelInfo* GetLogicalChannelInfo(PVMFPortInterface& port);
+        virtual void Timeout() {};
+
+        void ReceivedFormatSpecificInfo(TPVChannelId channel_id, uint8* fsi, uint32 fsi_len);
+        bool IsEstablishedLogicalChannel(TPVDirection aDir, TPVChannelId aChannelId);
+#ifdef MEM_TRACK
+        void MemStats();
+#endif
+    protected:
+        virtual bool Pausable()
+        {
+            return true;
+        }
+        void CheckOutgoingChannel(OlcParam* olc_param, PVMFStatus status);
+        void ChannelReleased(TPVDirection dir, TPVChannelId lcn, PVMFStatus status);
+        OlcParam* OpenLogicalChannel(TPVDirection dir,
+                                     TPVChannelId lcn,
+                                     TPVChannelId lcnRvs = CHANNEL_ID_UNKNOWN,
+                                     PS_DataType dt = NULL,
+                                     PS_H223LogicalChannelParameters lcp = NULL,
+                                     PS_DataType dtRvs = NULL,
+                                     PS_H223LogicalChannelParameters lcpRvs = NULL);
+        void RemoveOlc(TPVDirection dir, TPVChannelId id);
+        virtual void ReleasePendingIncomingChannel(TPVChannelId aOpenLcn)
+        {
+            OSCL_UNUSED_ARG(aOpenLcn);
+        };
+        virtual bool ReleasedPendingIncomingChannel(OlcParam* aPendingParam)
+        {
+            OSCL_UNUSED_ARG(aPendingParam);
+            return false;
+        };
+        PS_AdaptationLayerType GetOutgoingLayer(PV2WayMediaType media_type, uint32 max_sample_size);
+        OlcParam* OpenOutgoingChannelWithTcsCheck(PVCodecType_t codec,
+                PS_AdaptationLayerType adaptation_layer,
+                PVCodecType_t in_codec);
+
+        virtual void SetCustomMultiplex(PS_ControlMsgHeader pReceiveInf,
+                                        PV2WayMediaType media_type)
+        {
+            OSCL_UNUSED_ARG(pReceiveInf);
+            OSCL_UNUSED_ARG(media_type);
+        };
+        virtual void RemoveMultiplex(OlcParam* olc_param)
+        {
+            OSCL_UNUSED_ARG(olc_param);
+        };
+        virtual bool AlreadyAssigned(PV2WayMediaType media_type)
+        {
+            OSCL_UNUSED_ARG(media_type);
+            return false;
+        };
+        virtual void StartOlc(OlcParam* olc_param,
+                              PV2WayMediaType media_type,
+                              CPVMultiplexEntryDescriptorVector descriptors)
+        {
+            OSCL_UNUSED_ARG(olc_param);
+            OSCL_UNUSED_ARG(media_type);
+            OSCL_UNUSED_ARG(descriptors);
+        };
+        virtual bool FinishTcsMsdComplete(CPVMultiplexEntryDescriptorVector descriptors)
+        {
+            OSCL_UNUSED_ARG(descriptors);
+            return true;
+        };
+        virtual void CustomGenerateTcs(PS_TerminalCapabilitySet& ret)
+        {
+            OSCL_UNUSED_ARG(ret);
+        };
+        virtual bool IsRemovable(TPVChannelId lcn)
+        {
+            OSCL_UNUSED_ARG(lcn);
+            return true;
+        };
+        virtual PS_DataType GetOutgoingDataType(PVCodecType_t codecType,
+                                                uint32 bitrate);
+
+        OlcParam* OpenOutgoingChannel(PVCodecType_t codec,
+                                      PS_AdaptationLayerType adaptation_layer,
+                                      PS_DataType pDataTypeRvs = NULL,
+                                      PS_H223LogicalChannelParameters pH223ParamsRvs = NULL);
+
+        OlcList iOlcs;
+
+
+        TSC_statemanager& iTSCstatemanager;
+        TSC_capability& iTSCcapability;
+        TSC_lc& iTSClc;
+        TSC_blc& iTSCblc;
+        TSC_clc& iTSCclc;
+        TSC_mt& iTSCmt;
+
+        H245* iH245;
+        H223* iH223;
+
+        PS_TerminalCapabilitySet iLocalTcs;
+        OsclTimer<OsclMemAllocator>* iWaitingForOblcTimer;
+        // Configuration of outgoing channels
+        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* iOutgoingChannelConfig;
+        // Configuration of incoming channels
+        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* iIncomingChannelConfig;
+        TSCObserver* iTSCObserver;
+        TSC_channelcontrol iTSCchannelcontrol;
+
+
+        PVLogger* iLogger;
+
+        bool iAllowAl1Video;
+        bool iAllowAl2Video;
+        bool iAllowAl3Video;
+        bool iAllowAl1Audio;
+        bool iAllowAl2Audio;
+        bool iAllowAl3Audio;		/*   (These are sent in outgoing CE) */
+        bool iUseAl1Video;
+        bool iUseAl2Video;
+        bool iUseAl3Video;
+    private:
+        uint32 OpenLogicalChannel(TPVChannelId OpenLcn,
+                                  PS_DataType pDataType,
+                                  PS_H223LogicalChannelParameters pH223Lcp);
+        PVMFStatus VerifyReverseParameters(PS_ForwardReverseParam forRevParams,
+                                           TSCObserver* aObserver);
+        void ReleaseOlc(OlcParam* olc, uint16 cause);
+        void SignalChannelClose(TPVDirection dir, TPVChannelId lcn, TPVDirectionality directionality);
+        void OpenPort(TPVDirection dir, TPVChannelId lcn, H223ChannelParam* param);
+
+    private:
+
+
+        /* AL3 control field octets */
+        unsigned iAl3ControlFieldOctets;
+        /* AL2 with/without sequence numbers */
+        bool iAl2WithSn;
+
+        unsigned iRemoteAl1Audio;			/* Remote terminal */
+        unsigned iRemoteAl2Audio;			/* Remote terminal */
+        unsigned iRemoteAl3Audio;			/*   (These are received in incoming CE) */
+        unsigned iRemoteAl1Video;			/* Remote terminal */
+        unsigned iRemoteAl2Video;			/* Remote terminal */
+        unsigned iRemoteAl3Video;			/*   (These are received in incoming CE) */
+
+        TPVAdaptationLayer iVideoLayer;			/* Layer to use, decided by local terminal */
+        /*   (0=undetermined, 2=AL2, 3=AL3) */
+        OsclSharedPtr<S_TerminalCapabilitySet> iRemoteTcs;
+
+        Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> iOutCodecList;
+        bool iWaitingForOblc;
+        PVCodecType_t iWaitingForOblcCodec;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_componentregistry.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_componentregistry.h
new file mode 100644
index 0000000..39f70a2
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_componentregistry.h
@@ -0,0 +1,60 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_COMPONENTREGISTRY_H
+#define TSC_COMPONENTREGISTRY_H
+
+#define TSC_COMPONENT_MIME_TYPE "x-pvmf/component"
+
+#include "tsc_node_interface.h"
+#include "tsc_component.h"
+
+
+class TSC_statemanager;
+class TSC_capability;
+class TSC_lc;
+class TSC_blc;
+class TSC_clc;
+class TSC_mt;
+
+class TSCComponentRegistry
+{
+    public:
+        TSCComponentRegistry(TSC_statemanager& aTSCStateManager,
+                             TSC_capability& aTSCcapability,
+                             TSC_lc& aTSClc,
+                             TSC_blc& aTSCblc,
+                             TSC_clc& aTSCclc,
+                             TSC_mt& aTSCmt);
+
+        void QueryRegistry(Tsc324mNodeCommand& cmd);
+
+        TSC_component* Create(PVMFSessionId aSession,
+                              const PVUuid& aUuid,
+                              PVInterface*& aInterfacePtr,
+                              const OsclAny* aContext);
+    private:
+        TSC_statemanager& iTSCstatemanager;
+        TSC_capability& iTSCcapability;
+        TSC_lc& iTSClc;
+        TSC_blc& iTSCblc;
+        TSC_clc& iTSCclc;
+        TSC_mt& iTSCmt;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_constants.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_constants.h
new file mode 100644
index 0000000..d81f4da
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_constants.h
@@ -0,0 +1,77 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_CONSTANTS_H_INCLUDED
+#define TSC_CONSTANTS_H_INCLUDED
+
+#define TSC_INCOMING_CHANNEL_MASK (1<<16)
+
+typedef enum _status
+{
+    Phase0_Idle = 1 ,
+    PhaseA          ,
+    PhaseB          ,
+    PhaseC          ,
+    PhaseD_CSUP		,  /* Call Setup */
+    PhaseE_Comm     ,  /* Ongoing Communication */
+    PhaseF_Clc      ,  /* Closing all outgoing LCNs */
+    PhaseF_End      ,  /* End of Session */
+    PhaseG_Dis
+} ENUM_Status;
+
+
+/* From tsc_lc.h */
+#define     RELEASE_REJECT      1           /* RELEASE.request(LC) - Reject  */
+#define     RELEASE_CLOSE       2           /* RELEASE.request(LC) - Close   */
+
+
+#define PV_TSC_WAITING_FOR_OBLC_TIMER_ID 4
+
+
+#define  TSC_CE_SEND           0
+#define  TSC_CE_RECEIVE        1
+#define  TSC_MSD               2
+#define  TSC_MSD_RECEIVE       12
+#define  TSC_MT_SEND           3
+#define  TSC_MT_RECEIVE        4
+#define  TSC_LC_AUDIO_SEND     5
+#define  TSC_LC_AUDIO_RECEIVE  6
+#define  TSC_LC_VIDEO_SEND     7    // I may need to modify this to accom * /
+#define  TSC_LC_VIDEO_RECEIVE  8    // *  both Uni- and Bi- cases. * /
+//-----------------------------* /
+#define  TSC_MSD_DECISION      9    // * either MASTER or SLAVE * /
+#define  TSC_MSD_RETRYCOUNT    10
+#define  TSC_MUXTABLE_CHANGE   11   // * Mux Table Change Flag * /
+//----------------------------- * /
+#define  MAX_TSC_STATES        13   // * Max number of states * /
+
+
+#define NOT_STARTED   0
+#define STARTED       1
+#define COMPLETE      2
+#define WAIT_FOR_OLC  3  // BLC Open; We have received Reject(URP) and
+
+
+/* MasterSlaveDetermination Decision */
+#define MASTER 0
+#define SLAVE 1
+
+#define N100_DEFAULT 3
+
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_eventreceive.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_eventreceive.h
new file mode 100644
index 0000000..cddebb7
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_eventreceive.h
@@ -0,0 +1,64 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+/*****************************************************************************/
+
+/*  file name            : tsc_eventreceive.h                                */
+
+/*  file contents        : Event Id Receive Header                           */
+
+/*  draw                 : '96.10.04                                         */
+
+/*---------------------------------------------------------------------------*/
+
+/*  amendment                                                                */
+
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+
+/*****************************************************************************/
+
+#if !defined (_TSC_EVENTRECEIVE)
+
+#define _TSC_EVENTRECEIVE
+#include "pvt_params.h"
+
+
+/*---------------------------------------------------------------------------*/
+
+/*  Prototype Declare                                                        */
+
+/*---------------------------------------------------------------------------*/
+
+uint32 Tsc_EventReceive(PS_ControlMsgHeader pReceiveInf);
+
+uint32 Tsc_UserEventLookup(PS_ControlMsgHeader pReceiveInf);
+
+
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config.h
new file mode 100644
index 0000000..d6a0b11
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config.h
@@ -0,0 +1,232 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_H324M_CONFIG_H_INCLUDED
+#define TSC_H324M_CONFIG_H_INCLUDED
+
+#ifndef TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
+#include "tsc_h324m_config_interface.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_MAP_H_INCLUDED
+#include "oscl_map.h"
+#endif
+#ifndef PV_PROXIED_INTERFACE_H_INCLUDED
+#include "pv_proxied_interface.h"
+#endif
+
+#ifndef TSCMAIN_H_INCLUDED
+#include "tscmain.h"
+#endif
+
+class PVLogger;
+class CPVCmnInterfaceCmdMessage;
+class TSC_324m;
+
+class H324MConfig : public OsclActiveObject,
+            public H324MConfigInterface,
+            public TSC_324mObserver
+{
+    public:
+        H324MConfig(TSC_324m* aH324M, bool aUseAO);
+        virtual ~H324MConfig();
+
+        void SetObserver(H324MConfigObserver* aObserver);
+
+        PVMFCommandId SetMultiplexLevel(TPVH223Level aLevel, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxSduSize(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxSduSizeR(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetAl2SequenceNumbers(int32 aSeqNumWidth, OsclAny* aContextData = NULL);
+        PVMFCommandId SetAl3ControlFieldOctets(int32 aCfo, OsclAny* aContextData = NULL);
+        PVMFCommandId SetOutoingPduType(TPVH223MuxPduType aOutgoingPduType, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxPduSize(int32 aMaxPduSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetTerminalType(uint8 aTerminalType, OsclAny* aContextData = NULL);
+        PVMFCommandId SetALConfiguration(TPVMediaType_t aMediaType, TPVAdaptationLayer aLayer,
+                                         bool aAllow, OsclAny* aContextData = NULL);
+        PVMFCommandId SendRme(OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxMuxPduSize(int32 aRequestMaxMuxPduSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxMuxCcsrlSduSize(int32 aMaxCcsrlSduSize, OsclAny* aContextData = NULL);
+        PVMFCommandId FastUpdate(PVMFNodeInterface& aTrack, OsclAny* aContextData = NULL);
+        PVMFCommandId SendRtd(OsclAny* aContextData = NULL);
+        PVMFCommandId SetVendor(uint8 aCc, uint8 aExt, uint32 aMc,
+                                const uint8* aProduct, uint16 aProductLen,
+                                const uint8* aVersion, uint16 aVersionLen,
+                                OsclAny* aContextData = NULL);
+        PVMFCommandId SendEndSession(OsclAny* aContextData = NULL);
+        PVMFCommandId SetEndSessionTimeout(uint32 aTimeout, OsclAny* aContextData = NULL);
+        PVMFCommandId SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+                                      uint8 aSeries, uint32 aSeriesOffset,
+                                      uint32 aValue,
+                                      OsclAny* aContextData = NULL);
+        PVMFCommandId SetVideoResolutions(TPVDirection aDirection,
+                                          Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+                                          OsclAny* aContextData = NULL);
+        PVMFCommandId SendVendorId(OsclAny* aContextData = NULL);
+        PVMFCommandId SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+                OsclAny* aContextData = NULL);
+        PVMFCommandId SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+                OsclAny* aContextData = NULL);
+        PVMFCommandId SendSkewIndication(TPVChannelId aLogicalChannel1, TPVChannelId aLogicalChannel2, uint16 aSkew,
+                                         OsclAny* aContextData = NULL);
+        PVMFCommandId SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                uint32 aOutBufferingMs,
+                OsclAny* aContextData = NULL);
+        PVMFCommandId SendUserInput(CPVUserInput* user_input,
+                                    OsclAny* aContextData = NULL);
+        PVMFCommandId SetWnsrp(const bool aEnableWnsrp,
+                               OsclAny* aContextData = NULL);
+        ////////////////////////////////////
+        // PVInterface virtuals
+        ////////////////////////////////////
+        void addRef();
+        void removeRef();
+        bool queryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr);
+
+        // TSC_324mObserver virtuals
+        void IncomingVendorId(TPVH245Vendor* vendor, const uint8* pn, uint16 pn_len, const uint8* vn, uint16 vn_len);
+        void UserInputReceived(CPVUserInput* aUI);
+        void UserInputCapability(int formats);
+        void VideoSpatialTemporalTradeoffCommandReceived(TPVChannelId id, uint8 tradeoff);
+        void VideoSpatialTemporalTradeoffIndicationReceived(TPVChannelId id, uint8 tradeoff);
+        void SkewIndicationReceived(TPVChannelId lcn1, TPVChannelId lcn2, uint16 skew);
+    private:
+        void Run();
+        void SendCmdResponse(PVMFCommandId id, OsclAny* context, PVMFStatus status);
+        void SendAsyncEvent(PVMFAsyncEvent& event);
+
+        void UseAO();
+
+        TSC_324m* iH324M;
+        int32 iReferenceCount;
+        PVLogger* iLogger;
+        PVMFCommandId iCommandId;
+        H324MConfigObserver* iObserver;
+        Oscl_Vector<PVMFCmdResp, OsclMemAllocator> iPendingResponses;
+        Oscl_Vector<PVMFAsyncEvent, OsclMemAllocator> iPendingEvents;
+        bool iUseAO;
+
+        friend class H324MConfigProxied;
+};
+
+
+class H324MConfigProxied :
+            public H324MConfigInterface,
+            public PVProxiedInterfaceServer,
+            public PVProxiedInterfaceClient,
+            public H324MConfigObserver
+{
+    public:
+        H324MConfigProxied(H324MConfigInterface *aH324MConfigIF, PVMainProxy *aMainProxy);
+        virtual ~H324MConfigProxied();
+
+        void SetObserver(H324MConfigObserver* aObserver);
+        void H324MConfigCommandCompletedL(PVMFCmdResp& aResponse);
+        void H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification);
+
+        PVMFCommandId SetMultiplexLevel(TPVH223Level aLevel, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxSduSize(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxSduSizeR(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetAl2SequenceNumbers(int32 aSeqNumWidth, OsclAny* aContextData = NULL);
+        PVMFCommandId SetAl3ControlFieldOctets(int32 aCfo, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxPduSize(int32 aMaxPduSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetTerminalType(uint8 aTerminalType, OsclAny* aContextData = NULL);
+        PVMFCommandId SetALConfiguration(TPVMediaType_t aMediaType, TPVAdaptationLayer aLayer,
+                                         bool aAllow, OsclAny* aContextData = NULL);
+        PVMFCommandId SendRme(OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxMuxPduSize(int32 aRequestMaxMuxPduSize, OsclAny* aContextData = NULL);
+        PVMFCommandId SetMaxMuxCcsrlSduSize(int32 aMaxCcsrlSduSize, OsclAny* aContextData = NULL);
+        PVMFCommandId FastUpdate(PVMFNodeInterface& aTrack, OsclAny* aContextData = NULL);
+        PVMFCommandId SendRtd(OsclAny* aContextData = NULL);
+        PVMFCommandId SetVendor(uint8 aCc, uint8 aExt, uint32 aMc,
+                                const uint8* aProduct, uint16 aProductLen,
+                                const uint8* aVersion, uint16 aVersionLen,
+                                OsclAny* aContextData = NULL);
+        PVMFCommandId SendEndSession(OsclAny* aContextData = NULL);
+        PVMFCommandId SetEndSessionTimeout(uint32 aTimeout, OsclAny* aContextData = NULL);
+        PVMFCommandId SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+                                      uint8 aSeries, uint32 aSeriesOffset,
+                                      uint32 aValue,
+                                      OsclAny* aContextData = NULL);
+        PVMFCommandId SetVideoResolutions(TPVDirection aDirection,
+                                          Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+                                          OsclAny* aContextData = NULL);
+        PVMFCommandId SendVendorId(OsclAny* aContextData = NULL);
+        PVMFCommandId SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+                OsclAny* aContextData = NULL);
+        PVMFCommandId SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+                OsclAny* aContextData = NULL);
+        PVMFCommandId SendSkewIndication(TPVChannelId aLogicalChannel1, TPVChannelId aLogicalChannel2, uint16 aSkew,
+                                         OsclAny* aContextData = NULL);
+        PVMFCommandId SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                uint32 aOutBufferingMs,
+                OsclAny* aContextData = NULL);
+        PVMFCommandId SendUserInput(CPVUserInput* user_input,
+                                    OsclAny* aContextData = NULL);
+
+        PVMFCommandId SetWnsrp(const bool aEnableWnsrp,
+                               OsclAny* aContextData = NULL);
+        void CleanupNotification(TPVProxyMsgId aId, OsclAny *aMsg);
+        void HandleCommand(TPVProxyMsgId aMsgId, OsclAny *aMsg);
+        void HandleNotification(TPVProxyMsgId aId, OsclAny *aMsg);
+        void CleanupCommand(TPVProxyMsgId aId, OsclAny *aMsg);
+
+        ////////////////////////////////////
+        // PVInterface virtuals
+        ////////////////////////////////////
+        void addRef();
+        void removeRef();
+        bool queryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr);
+
+    private:
+        H324MConfigInterface* iH324MConfigIF;
+        PVMainProxy* iMainProxy;
+        PVLogger* iLoggerClient;
+        PVLogger* iLoggerServer;
+        int32 iReferenceCount;
+        TPVProxyId iProxyId;
+        Oscl_Map<PVMFCommandId, CPVCmnInterfaceCmdMessage*, OsclMemAllocator> iPendingCmds;
+        PVMFCommandId iCommandId;
+        H324MConfigObserver* iObserver;
+};
+
+class H324MProxiedInterface : public PVProxiedInterface
+{
+    public:
+        H324MProxiedInterface();
+        virtual ~H324MProxiedInterface();
+
+        void QueryProxiedInterface(const TPVProxyUUID& aUuid, PVInterface*& aInterfacePtr);
+        void SetMainProxy(PVMainProxy* aMainProxy);
+
+        void addRef();
+        void removeRef();
+        bool queryInterface(const PVUuid& aUuid, PVInterface*& aInterface);
+
+        void SetH324M(TSC_324m* aH324M);
+
+    private:
+        TSC_324m* iH324M;
+        PVMainProxy* iMainProxy;
+        int32 iReferenceCount;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config_interface.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config_interface.h
new file mode 100644
index 0000000..e5265eb
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_h324m_config_interface.h
@@ -0,0 +1,509 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
+#define TSC_H324M_CONFIG_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PVT_COMMON_H_INCLUDED
+#include "pvt_common.h"
+#endif
+
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#define PVH324MConfigUuid PVUuid(0x2b0b54e2,0x7079,0x46c6,0xb2,0x3e,0x04,0xff,0xd3,0x0e,0x14,0x36)
+
+//----f6b47190-f88d-4cbf-a6f6-c61efe98053f
+// UUID for the extension interface
+#define PVUuidH324ComponentInterface  PVUuid(0xf6b47190,0xf88d,0x4cbf,0xa6,0xf6,0xc6,0x1e,0xfe,0x98,0x05,0x3f)
+
+
+typedef uint32 H324MConfigInformationalEvent;
+typedef uint32 H324MConfigStatusResponse;
+
+class PVMFComponentInterface: public PVInterface
+{
+        // get, set functions, etc
+        ////////////////////////////////////
+        // PVInterface virtuals
+        ////////////////////////////////////
+        void addRef() {};
+        void removeRef() {}
+};
+
+class H324MConfigObserver
+{
+    public:
+        virtual ~H324MConfigObserver() {}
+        virtual void H324MConfigCommandCompletedL(PVMFCmdResp& aResponse) = 0;
+        virtual void H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification) = 0;
+};
+
+
+class H324MConfigInterface : public PVInterface
+{
+    public:
+        /**
+        * This API allows the user to specify separate observers for the 324m interface.  Otherwise, the default
+        * observers will be used
+        *
+        * @param aObserver        the observer for command status and for unsolicited informational events
+        **/
+        virtual void SetObserver(H324MConfigObserver* aObserver) = 0;
+
+        /**
+        * This API allows the user to specify the starting H223 multiplex level
+        *
+        * @param aLevel
+        *			The starting H223 multiplex level.  Note that the final level that is neotiated will depend
+        *          on the starting level of the peer
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetMultiplexLevel(TPVH223Level aLevel,
+                                                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to specify maximum outgoing sdu sizes for each adaptation layer
+        *
+        * @param aLayer
+        *			The h223 adaptation layer type
+        * @param aSize
+        *			The sdu size
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+
+        virtual PVMFCommandId SetMaxSduSize(TPVAdaptationLayer aLayer, int32 aSize,
+                                            OsclAny* aContextData = NULL) = 0;
+        /**
+        * This API allows the user to specify maximum incoming sdu sizes for each adaptation layer.  This is indicated
+        * to the peer via the TCS
+        *
+        * @param aLayer
+        *			The h223 adaptation layer type
+        * @param aSize
+        *			The sdu size
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+
+        virtual PVMFCommandId SetMaxSduSizeR(TPVAdaptationLayer aLayer,
+                                             int32 aSize, OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to specify the sequence number field for AL2
+        *
+        * @param aSeqNumWidth
+        *			The number of octets to use for AL2 sequence numbers.  Allowed values are 0, 1.
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+
+        virtual PVMFCommandId SetAl2SequenceNumbers(int32 aSeqNumWidth,
+                OsclAny* aContextData = NULL) = 0;
+        /**
+        * This API allows the user to specify the control field octets field for AL3
+        *
+        * @param aCfo
+        *			The number of octets to use for AL3 CFO.  Allowed values are 0, 1, 2.
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+
+        virtual PVMFCommandId SetAl3ControlFieldOctets(int32 aCfo,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to limit the size of the outgoing h223 pdus
+        *
+        * @param aMaxPduSize
+        *			The max pdu size
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetMaxPduSize(int32 aMaxPduSize,
+                                            OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to specify the terminal type that is advertized to the peer.  This can be used to
+        * force the local terminal to be master/slave when communicating with a peer 324m terminal for testing purposes.
+        *
+        * @param aTerminalType The terminal type
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetTerminalType(uint8 aTerminalType,
+                                              OsclAny* aContextData = NULL) = 0;
+        /**
+        * This API allows the user to specify the allowable adaptation layers for audio and video.
+        * By default AL2 is allowed for audio and AL2, AL3 are allowed for video
+        *
+        * @param aMediaType The media type, i.e audio, video, data
+        * @param aLayer The adaptation layer
+        * @param aAllow Is this adaptation layer allowed for this media type ?
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetALConfiguration(TPVMediaType_t aMediaType,
+                TPVAdaptationLayer aLayer,
+                bool aAllow,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to specify whether Request Multiplex Entry is sent to the remote terminal after TCS
+        *
+        * @param aSendRme If true, RME is sent to the peer after TCS
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SendRme(OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API causes a maxMuxPduSize request to be sent to the remote terminal if set to a valid value (64 - 255).
+        This is done after TCS if the remote terminal supports the maxMuxPduCapability
+        *
+        * @param aRequestMaxMuxPduSize The max mux pdu size
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetMaxMuxPduSize(int32 aRequestMaxMuxPduSize,
+                                               OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API sets the max ccsrl sdu size
+        *
+        * @param aMaxCcsrlSduSize The max ccsrl sdu size
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetMaxMuxCcsrlSduSize(int32 aMaxCcsrlSduSize,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API may be called only after the media source has been successfully added
+        * to the pv2way engine.  It causes the 2way engine to immediately send out a fast update frame
+        * specific to the media type identified by the aTrack parameter.
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @param aTrack
+        *         The identifier for the track
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId FastUpdate(PVMFNodeInterface& aTrack,
+                                         OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Sends a Round Trip Determination message to the peer and indicates the round trip delay to the caller
+        * on completion of the command.  The round trip delay is stored in 4 bytes in the local buffer of the completion event
+        * in network byte order.
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SendRtd(OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Sets the vendor identification data.  This does not cause the stack to issue a vendor identifiation request.
+        * Set to NULL to disable sending vendor id.  If set to a valid parameter before Connect, it will cause the stack
+        * to automatically send it along with the TCS message.
+        * @param cc
+        *         T35 Country code
+        * @param ext
+        *         T35 Extension
+        * @param mc
+        *         T35 Manufacturer code
+        * @param aProduct
+        *         Product number
+        * @param aVersion
+        *         Version number
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetVendor(uint8 cc, uint8 ext, uint32 mc,
+                                        const uint8* aProduct, uint16 aProductLen,
+                                        const uint8* aVersion, uint16 aVersionLen,
+                                        OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Sends an end session command to the peer.  Only to be used for testing purposes.
+        *
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SendEndSession(OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Sets the disconnect timeout interval.
+        *
+        * @param aTimeout The timeout value in seconds
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetEndSessionTimeout(uint32 aTimeout,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Sets an H.324 timer/counter value.  This should be called before ConnectL is invoked.
+        * The  supported timers are:
+        *		T106	Master Slave Determination (in units of 1s)
+        *		T101	Capability Exchange (in units of 1s)
+        *		T103	Uni-directional and Bi-directional Logical Channel Signalling (in units of 1s)
+        *		T108	Close Logical Channel (in units of 1s)
+        *		T104	H.223 Multiplex Table (in units of 1s)
+        *		T109	Mode Request (in units of 1s)
+        *		T105	Round Trip Delay (in units of 1s)
+        *		T107	Request Multiplex Entry (in units of 100ms)
+        *      T401    SRP retransmission (in units of 100ms)
+        * The supported counters are:
+        *      N100	H245 (TCS, MSD)
+        *      N401    SRP retransmission
+        * @param aTimerCounter
+        *         Identifies whether a timer or counter is being set.
+        * @param aSeries
+        *         Identifies the H.324 timer/counter series.
+        * @param aSeriesOffset
+        *         Specifies the offset within a particular series.
+        *         E.g.
+        *              aTimerCounter=EH324Timer, aSeries=1, aSeriesOffset=1 indicates T101.
+        *              aTimerCounter=EH324Timer, aSeries=4, aSeriesOffset=1 indicates T401.
+        *              aTimerCounter=EH324Counter, aSeries=4, aSeriesOffset=1 indicates T401.
+        * @param aValue
+        *         The new value for the H.324 timer/counter
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        **/
+        virtual PVMFCommandId SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+                                              uint8 aSeries, uint32 aSeriesOffset,
+                                              uint32 aValue,
+                                              OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to specify the supported resolutions for video for transmit and receive.
+        *
+        * @param aDirection
+        *         The direction (Tx/Rx) for which the capability is specified.
+        * @param aResolutions
+        *         An array of resolutions.
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        **/
+        virtual PVMFCommandId SetVideoResolutions(TPVDirection aDirection,
+                Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to send the vendor id info to the peer.
+        * Note:  Calling this API during call-setup negotiations can affect the time for
+        * call-setup adversely.
+        *
+        **/
+        virtual PVMFCommandId SendVendorId(OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to send a videoTemporalSpatialTradeOff command to the peer.
+        * It is a request to the remote encoder to adjust its encoding in accordance with the tradeoff value.
+        * A value of 0 indicates a high spatial resolution and a value of 31 indicates a high frame rate.
+        * The values from 0 to 31 indicate monotonically a higher frame rate. Actual values do not correspond
+        * to precise values of spatial resolution or frame rate.
+        *
+        **/
+        virtual PVMFCommandId SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel,
+                uint8 aTradeoff,
+                OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to send a videoTemporalSpatialTradeOff command to the peer.
+        * It is an indication to the remote decoder that the local encoder has adjusted its encoding parameters
+        * according to the tradeoff value.
+        * A value of 0 indicates a high spatial resolution and a value of 31 indicates a high frame rate.
+        * The values from 0 to 31 indicate monotonically a higher frame rate. Actual values do not correspond
+        * to precise values of spatial resolution or frame rate.
+        *
+        **/
+        virtual PVMFCommandId SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel,
+                uint8 aTradeoff, OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * This API allows the user to send a SkewIndication to the peer.
+        * Skew is measured in milliseconds, and indicates the maximum number of milliseconds that the data on
+        * logicalChannel2 is delayed from the data on logicalChannel1 as delivered to the network transport.
+        *
+        **/
+        virtual PVMFCommandId SendSkewIndication(TPVChannelId aLogicalChannel1, TPVChannelId aLogicalChannel2,
+                uint16 aSkew, OsclAny* aContextData = NULL) = 0;
+
+
+        /**
+        * This API allows the user to configure the logical channel buffer sizes for incoming
+        * and outgoing logical channels.
+        * @param aDirection
+        *         The direction (Rx or Tx).
+        * @param aBufferingMs
+        *         The amount of buffering in milliseconds.
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        **/
+        virtual PVMFCommandId
+        SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                                     uint32 aOutBufferingMs,
+                                     OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Causes the pv2way to send the specified user input to the remote terminal using
+        * control channel.  The user input can be either DTMF ot Alphanumeric
+        * @param user_input A pointer to either CPVUserInputDtmf or CPVUserInputAlphanumeric
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        *
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId
+        SendUserInput(CPVUserInput* user_input,
+                      OsclAny* aContextData = NULL) = 0;
+
+        /**
+        * Causes the pv2way to send the specified user input to the remote terminal using
+        * control channel.
+        * @param aEnableWnsrp Boolean whether to enable Wnsrp or not
+        * @param aContextData
+        *         Optional opaque data that will be passed back to the user with the command response
+        *
+        * @returns A unique command id for asynchronous completion
+        **/
+        virtual PVMFCommandId SetWnsrp(const bool aEnableWnsrp,
+                                       OsclAny* aContextData = NULL) = 0;
+
+};
+
+
+/**
+* PVH324MIndicationType enum
+*
+*  Enumeration of unsolicited H324m specific indications from pv2way.
+*
+**/
+enum PVH324MIndicationType
+{
+    /**
+    * Indicates the receipt of a videoSpatialTemporalTradeoff command from the peer.
+    * The first 2 bytes of the event local buffer indicate the logical channel (network byte order) and the 3rd
+    * byte indicates the tradeoff value.
+    *
+    **/
+    PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND,
+    /**
+    * Indicates the receipt of a videoSpatialTemporalTradeoff indication from the peer.
+    * The first 2 bytes of the event local buffer indicate the logical channel (network byte order) and the 3rd
+    * byte indicates the tradeoff value.
+    *
+    **/
+    PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION,
+    /**
+    * Indicates a fast update message from the remote terminal.  The first two bytes of the
+    * local buffer encode the logical channel number in network byte order.
+    *
+    **/
+    PV_INDICATION_FAST_UPDATE,
+    /**
+    * Indicates an incoming RTD command.
+    *
+    **/
+    PV_INDICATION_RTD,
+    /**
+    * Indicates an incoming request multiplex entry command.
+    *
+    **/
+    PV_INDICATION_RME,
+    /**
+    * Indicates an incoming vendor id indication message.
+    *
+    **/
+    PV_INDICATION_VENDOR_ID,
+    /**
+    * Indicates the receipt of user input capability from the remote terminal.  The local buffer
+    * contains the indices of the user input formats supported by the peer.
+    *
+    **/
+    PV_INDICATION_USER_INPUT_CAPABILITY,
+    /**
+    * Indicates the receipt of user input from the remote terminal.  The derived class
+    * contains the actual user input sequences received.
+    *
+    **/
+    PV_INDICATION_USER_INPUT,
+    /**
+    * Indicates the receipt of a an h223SkewIndication indication from the peer.
+    * The first 2 bytes of the event local buffer indicate the first logical channel, the 3rd and
+    * 4th bytes the second logical channel and the 5th and 6th bytes the value of the skew in milliseconds.
+    * All values are in network byte order.
+    *
+    **/
+    PV_INDICATION_SKEW
+};
+/**
+Extension interface to indicate reverse logical channel parameters to the user of the stack node
+**/
+class H324MReverseParametersExtensionInterface : public PVInterface
+{
+    public:
+        /**
+        * @return The reverse media format and capabilities.
+        **/
+        virtual const PvmfMimeString* GetFormatCapabilities() = 0;
+
+        /**
+        * @param aPortTag The port tag to use for the reverse channel if it is accepted.
+        **/
+        virtual void SetPortTag(int32 aPortTag) = 0;
+
+        /**
+        * @return The port tag for the reverse channel
+        **/
+        virtual int32 GetPortTag()const = 0;
+};
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_lc.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_lc.h
new file mode 100644
index 0000000..e4362ac
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_lc.h
@@ -0,0 +1,81 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_lc.h                                         */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCLC_H_INCLUDED
+#define TSCLC_H_INCLUDED
+
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#include "h245.h"
+#include "h223types.h"
+
+
+class TSC_statemanager;
+
+class TSC_lc
+{
+    public:
+        TSC_lc(TSC_statemanager& aStateManager): iTSCstatemanager(aStateManager)
+        {
+            iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+        };
+        ~TSC_lc() {};
+
+        void SetH245(H245* aH245)
+        {
+            iH245 = aH245;
+        }
+
+        /* Logical Channel Establish */
+        void LcEtbReq(TPVChannelId Lcn,
+                      PS_DataType pDataType,
+                      PS_H223LogicalChannelParameters pH223Params);
+
+        void LcEtbRps(uint32);
+        TPVDirection LcRlsReq(int32, TPVChannelId, uint16);
+
+
+    private:
+        H245* iH245;
+        TSC_statemanager& iTSCstatemanager;
+        PVLogger* iLogger;
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_mt.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_mt.h
new file mode 100644
index 0000000..0f69ae3
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_mt.h
@@ -0,0 +1,106 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_mt.h                                         */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSC_MT_H_INCLUDED
+#define TSC_MT_H_INCLUDED
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+
+#include "cpvh223multiplex.h"
+#include "h245.h"
+
+class TSC_component;
+
+class TSC_mt
+{
+    public:
+        TSC_mt()
+        {
+            iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+        };
+        ~TSC_mt() {};
+
+        void SetMembers(H245* aH245, H223* aH223, TSC_component* aTSCcomponent)
+        {
+            iH245 = aH245;
+            iH223 = aH223;
+            iTSCcomponent = aTSCcomponent;
+        }
+        void InitVarsSession();
+        void ClearVars();
+        void DeleteMuxEntry(uint32 aParam);
+
+        /* Multiplex Table */
+        bool CheckMtTrf(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> aOutCodecList,
+                        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* aOutgoingChannelConfig);
+        void MtTrfReq(OlcList& aOlcs);
+        void MtTrfRps(uint32 sequenceNumber, PS_MuxDescriptor pMux);
+        void MtRjtReq();
+        bool MuxTableSendComplete(uint32 sn);
+
+        uint32 SendMuxTableForLcn(TPVChannelId id);
+        void ReleaseMuxTables();
+        int GetPendingMtSn()
+        {
+            return iPendingMtSn;
+        }
+        // mux descriptors
+        CPVMultiplexEntryDescriptor* GenerateCombinedDescriptor(uint8 entry_num,
+                TPVChannelId lcn1, unsigned size, TPVChannelId lcn2);
+
+    private:
+
+        Oscl_Vector<int, OsclMemAllocator> iAvailableMuxEntryNumbers;
+        int iOutMtSn;
+        int iPendingMtSn;
+        Oscl_Vector<int, OsclMemAllocator> iToBeDeletedMuxEntryNumbers;
+
+        //TSC_capability* iTSCcapability;
+        TSC_component* iTSCcomponent;
+
+        PVLogger* iLogger;
+        /* The H245 instance */
+        H245* iH245;
+        /* The H223 instance */
+        H223* iH223;
+
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_node_interface.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_node_interface.h
new file mode 100644
index 0000000..fe5a45f
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_node_interface.h
@@ -0,0 +1,40 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_NODE_INTERFACE_H_INCLUDED
+#define TSC_NODE_INTERFACE_H_INCLUDED
+
+#ifndef PVMF_NODE_UTILS_H_INCLUDED
+#include "pvmf_node_utils.h"
+#endif
+
+
+//memory allocator type for this node.
+typedef OsclMemAllocator Tsc324mNodeAllocator;
+
+#define Tsc324mNodeCommandBase PVMFGenericNodeCommand<Tsc324mNodeAllocator>  // to remove typedef warning on symbian
+
+class Tsc324mNodeCommand: public Tsc324mNodeCommandBase
+{
+    public:
+        Tsc324mNodeCommand() {}
+};
+
+typedef PVMFNodeCommandQueue<Tsc324mNodeCommand, Tsc324mNodeAllocator> Tsc324mNodeCmdQ;
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_statemanager.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_statemanager.h
new file mode 100644
index 0000000..efae975
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_statemanager.h
@@ -0,0 +1,91 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_statemanager.h                                 */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCSTATEMANAGER_H_INCLUDED
+#define TSCSTATEMANAGER_H_INCLUDED
+
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#include "h245.h"
+#include "h324utils.h"
+#include "tsc_constants.h"
+
+class TSC_statemanager
+{
+    public:
+        ~TSC_statemanager() {};
+
+        void InitVarsSession();
+        void InitVarsLocal();
+        TPVStatusCode SetTerminalParam(CPVTerminalParam* params);
+        // State Manager
+        void StateInitialize(void);
+        int32 ReadState(uint32 stateIndex);
+        void WriteState(uint32 stateIndex, uint32 value);
+        void StatusShow(uint32 stateIndex, uint32 value);
+        void IncrementState(uint32 stateIndex);
+        void DecrementState(uint32 stateIndex);
+        uint32 PreReq_CeSend(void);
+        uint32 PreReq_MsdSend(void);
+        uint32 PreReq_MtSend(void);
+        bool PreReq_LcMediaSend();
+        void SkipMsd();
+        bool MSDStart(TPVLoopbackMode iLoopbackMode);
+        void MSDDetermineIndication(MSDStatus type);
+
+
+
+        void SetN100(uint32 aN100)
+        {
+            iN100 = aN100;
+        }
+
+    private:
+        // State Manager
+        // Array of state values and priority levels
+        int32 iTerminalState[MAX_TSC_STATES];
+
+        unsigned iSkipMsd; // Skip msd
+        PVLogger *iLogger;
+        uint32 iN100; // H245
+
+};
+
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_sub.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_sub.h
new file mode 100644
index 0000000..ef5f70a
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tsc_sub.h
@@ -0,0 +1,74 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_sub.h                                         */
+/*  file contents        : Sub Routine Information Header                    */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#if !defined (_TSC_SUB)
+#define _TSC_SUB
+
+#include <stdio.h>
+#include "h245inf.h"
+#include "pvt_params.h"
+
+/*---------------------------------------------------------------------------*/
+/*  Constant Definition                                                      */
+/*---------------------------------------------------------------------------*/
+typedef enum _parameterflag
+{
+    NOPARA,
+    REJECT,
+    ERRCODE,
+    SOURCECAUSE
+} ENUM_ParameterFlag;
+
+/*---------------------------------------------------------------------------*/
+/*  Prototype Declare                                                        */
+/*---------------------------------------------------------------------------*/
+void Tsc_UserNotify(ENUM_UserOperationId  UserOpId,
+                    ENUM_ParameterFlag fParameter,
+                    PS_ControlMsgHeader pReceiveInf);
+void Tsc_SendDataSet(PS_ControlMsgHeader pInfHeader,
+                     uint32 InfType,
+                     uint32 InfId,
+                     uint32 InfSupplement1,
+                     uint32 InfSupplement2,
+                     uint8* pParameter, uint32 Size);
+void Tsc_ChoiceDataSet(uint32 TrueTarget,
+                       uint8* pFirstTarget,
+                       uint32 NumberTarget);
+void Tsc_DescriptorFlagChange(uint32 fActDact,
+                              uint32 TblEntryNumber,
+                              uint32 isLocal);
+void Tsc_InternalError(PS_ControlMsgHeader  pReceiveInf);
+
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tscmain.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tscmain.h
new file mode 100644
index 0000000..76663a9
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tscmain.h
@@ -0,0 +1,680 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tscmain.h                                         */
+/*  file contents        :                                                   */
+/*  draw                 : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+
+#ifndef TSCMAIN_H_INCLUDED
+#define TSCMAIN_H_INCLUDED
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef OSCL_TIMER_H_INCLUDED
+#include "oscl_timer.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#include "pvmf_video.h"
+
+#include "tsc.h"
+#include "cpvh223multiplex.h"
+#include "srp.h"
+#include "h245.h"
+#include "h245def.h"
+#include "h245pri.h"
+#include "h223types.h"
+#include "h324utils.h"
+#include "tscsrpbuffer.h"
+#include "tsc_node_interface.h"
+#include "pv_common_types.h"
+#include "tsc_statemanager.h"
+#include "tsc_lc.h"
+#include "tsc_blc.h"
+#include "tsc_clc.h"
+#include "tsc_mt.h"
+#include "tsc_capability.h"
+#include "tsc_componentregistry.h"
+
+class SimpleStackElement;
+
+#define PVUidH324Interface  PVUuid(0x2b0b54e2,0x7079,0x46c6,0xb2,0x3e,0x04,0xff,0xd3,0x0e,0x14,0x36)
+
+
+/* Directional indicators */
+#define     UNI             1
+#define     BI              2
+
+/* Values for MUXTABLE_CHANGE */
+#define     WAIT_IDLE       0
+#define     WAIT_RES1       1
+#define     WAIT_RES2       2
+
+
+#define PV_TSC_RTD_TIMER_ID 2
+#define PV_TSC_DISCONNECT_TIMER_ID 3
+#define PV_TSC_WAITING_FOR_OBLC_TIMER_ID 4
+#define PV_TSC_TCS_RECEIVE_TIMER_ID 5
+#define PV_TSC_LEVEL_SETUP_TIMER_ID 6
+#define FIRST_OUTGOING_LCN 6
+#define DEFAULT_AUDIO_AL_INDEX 4
+#define DEFAULT_VIDEO_AL_INDEX 5
+#define DEFAULT_AL3_CONTROL_FIELD_OCTETS 1
+#define DEFAULT_END_SESSION_TIMEOUT 5
+#define WAITING_FOR_OBLC_TIMEOUT_SECONDS 15
+#define PV_TSC_MAX_COMMAND_ID 65535
+#define TSC_SE_TIMEOUT_DEFAULT 30
+#define T401_DEFAULT 8
+#define N401_DEFAULT 100
+
+#define FIRST_MUX_ENTRY_NUMBER TSC_FM_MAX_MTE+1
+#define LAST_MUX_ENTRY_NUMBER 14
+#define TSC_WNSRP_MUX_ENTRY_NUMBER 15
+#define TSC_INCOMING_CHANNEL_MASK (1<<16)
+
+// For requesting ports
+#define PVMF_AUDIO_OUTGOING_MIMETYPE    "x-pvmf/audio;dir=outgoing"
+#define PVMF_VIDEO_OUTGOING_MIMETYPE    "x-pvmf/video;dir=outgoing"
+#define PVMF_INCOMING_MIMETYPE          "x-pvmf/dir=incoming"
+#define PVMF_OUTGOING_MIMETYPE          "x-pvmf/dir=outgoing"
+
+/*---------------------------------------------------------------------------*/
+/*  Constant Definition                                                      */
+/*---------------------------------------------------------------------------*/
+
+
+// H.245 Miscellaneous Commands
+typedef enum _TCmdMisc
+{
+    EVideoFastUpdatePicture,
+    EVideoTemporalSpatialTradeOff,
+    EMaxH223MUXPDUsize
+}TCmdMisc;
+
+class TSC_324mObserver
+{
+    public:
+        virtual void IncomingVendorId(TPVH245Vendor* vendor, const uint8* pn, uint16 pn_len, const uint8* vn, uint16 vn_len) = 0;
+        virtual void UserInputReceived(CPVUserInput* aUI) = 0;
+        virtual void UserInputCapability(int formats) = 0;
+        virtual void VideoSpatialTemporalTradeoffCommandReceived(TPVChannelId id, uint8 tradeoff) = 0;
+        virtual void VideoSpatialTemporalTradeoffIndicationReceived(TPVChannelId id, uint8 tradeoff) = 0;
+        virtual void SkewIndicationReceived(TPVChannelId lcn1, TPVChannelId lcn2, uint16 skew) = 0;
+};
+
+class TSC_component;
+
+
+class TSC_324m : public TSC,
+            public PVMFNodeInterface,
+            public OsclActiveObject,
+            public CPVH223MultiplexObserver,
+            public H245Observer,
+            public MSDObserver,
+            public CEObserver,
+            public SRPObserver,
+            public OsclTimerObserver
+{
+    public:
+        OSCL_IMPORT_REF TSC_324m(TPVLoopbackMode aLoopbackMode);
+        ~TSC_324m();
+        void SetTSC_324mObserver(TSC_324mObserver* aObserver);
+
+        void SetInitialValues();
+        void InitComponent();
+        bool ProcessCommand(Tsc324mNodeCommand& aCmd);
+        void ReceivedFormatSpecificInfo(TPVChannelId lcn, uint8* fsi, uint32 fsi_len);
+        bool IsEstablishedLogicalChannel(TPVDirection aDir, TPVChannelId aChannelId);
+
+        /********************************/
+        /** node virtuals              **/
+        /********************************/
+        OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
+
+        OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId aSession, const OsclAny* aContext = NULL);
+        void DoInit(Tsc324mNodeCommand& cmd);
+
+        PVMFCommandId Prepare(PVMFSessionId aSession
+                              , const OsclAny* aContext = NULL);
+        void DoPrepare(Tsc324mNodeCommand& cmd);
+
+        OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId aSession, const OsclAny* aContext = NULL);
+        void DoStart(Tsc324mNodeCommand& cmd);
+
+        OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId aSession, const OsclAny* aContext = NULL);
+        void StartDisconnect(Tsc324mNodeCommand& cmd);
+        void DoStop(Tsc324mNodeCommand& cmd);
+
+        OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId aSession, const OsclAny* aContext = NULL);
+        void DoPause(Tsc324mNodeCommand& cmd)
+        {
+            OSCL_UNUSED_ARG(cmd);
+        }
+
+        OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId aSession, const OsclAny* aContext = NULL);
+        void DoReset(Tsc324mNodeCommand& cmd);
+
+        OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
+
+        OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId aSession
+                , int32 aPortTag
+                , const PvmfMimeString* aPortConfig = NULL
+                                                      , const OsclAny* aContext = NULL);
+
+        void DoRequestPort(Tsc324mNodeCommand& cmd);
+
+        OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId aSession, PVMFPortInterface& aPort, const OsclAny* aContext = NULL);
+        void DoReleasePort(Tsc324mNodeCommand& cmd);
+
+        // Port iterator virtuals
+        OSCL_IMPORT_REF uint16 NumPorts()
+        {
+            return 1;
+        }
+
+        OSCL_IMPORT_REF PVMFPortInterface* GetNext()
+        {
+            return NULL;
+        }
+
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId aSession, const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSession, const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+        void DoQueryInterface(Tsc324mNodeCommand& cmd);
+        void DoQueryUuid(Tsc324mNodeCommand& cmd);
+
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId aSession, const OsclAny* aContextData = NULL);
+        void DoCancelAllCommands(Tsc324mNodeCommand& cmd)
+        {
+            OSCL_UNUSED_ARG(cmd);
+        }
+
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId aSession, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
+        void DoCancelCommand(Tsc324mNodeCommand& cmd);
+
+        PVMFStatus ThreadLogon();
+        PVMFStatus ThreadLogoff();
+        void HandlePortActivity(const PVMFPortActivity& aActivity);
+        PVMFCommandId Flush(PVMFSessionId aSession , const OsclAny* aContext = NULL);
+        void DoFlush(Tsc324mNodeCommand& cmd)
+        {
+            OSCL_UNUSED_ARG(cmd);
+        }
+
+        /* PVInterface virtuals */
+        void addRef() {}
+        void removeRef() {}
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            OSCL_UNUSED_ARG(uuid);
+            OSCL_UNUSED_ARG(iface);
+            return false;
+        }
+
+        /********************************/
+        /** TSC virtuals               **/
+        /********************************/
+        virtual void Tsc_UII_DTMF(uint8 dtmf_value, uint16 dtmf_duration);
+        virtual void Tsc_UII_Alphanumeric(const uint8* str, uint16 str_len);
+
+        OSCL_IMPORT_REF TPVStatusCode SetVendorIdInfo(TPVH245Vendor* vendor, const uint8* pn, uint16 pn_len, const uint8* vn, uint16 vn_len);
+
+        /* Initializes the TSC with reference to mux and controls */
+        virtual TPVStatusCode InitTsc();
+
+        TPVStatusCode SetTimerRes(uint32 timer_res);
+
+        //virtual TPVStatusCode SetCapability(CapabilitySet* capabilities) = 0;
+        virtual TPVStatusCode ResetTsc();
+        virtual TPVStatusCode Connect(uint16 info_len = 0, uint8* info_buf = NULL);
+        virtual TPVStatusCode Disconnect();
+        //Network is already disconnected, no need to send out any messages, just shutdown (synchronous call).
+        virtual TPVStatusCode Abort();
+
+        /* Channel specific commands */
+        virtual TPVStatusCode SetChannelParam(CPVParam* params, TPVChannelId channel_id = CHANNEL_ID_UNKNOWN)
+        {
+            OSCL_UNUSED_ARG(channel_id);
+            OSCL_UNUSED_ARG(params);
+            return EPVT_Success;
+        }
+        virtual TPVStatusCode SetTerminalParam(CPVTerminalParam* params);
+        virtual CPVTerminalParam* GetTerminalParam();
+        virtual TPVStatusCode SetOutgoingBitrate(int32 bitrate);
+
+
+        virtual TPVStatusCode RequestFrameUpdate(PVMFPortInterface* port);
+        const uint8* GetFormatSpecificInfo(PVMFPortInterface* port, uint32* len);
+        TPVStatusCode RequestMaxMuxPduSize(unsigned aPduSize);
+        OSCL_IMPORT_REF TPVStatusCode SetTerminalType(uint8 aTType);
+        void SetDatapathLatency(TPVDirection aDir, PVMFPortInterface* aPort, uint32 aLatency);
+        void SetSkewReference(PVMFPortInterface* aPort, PVMFPortInterface* aReferencePort);
+        OSCL_IMPORT_REF void SetMultiplexingDelayMs(uint16 aDelay);
+
+        /* CPVMultiplexiObserver virtuals */
+        void DataReceptionStart();
+        void MuxSetupComplete(PVMFStatus aStatus, TPVH223Level aLevel);
+        void MuxCloseComplete();
+        void MuxErrorOccurred(TPVDirection direction, TPVMuxComponent component, PVMFStatus error,
+                              uint8* info = NULL, uint info_len = 0);
+        void SkewDetected(TPVChannelId lcn1, TPVChannelId lcn2, uint32 skew);
+        void LcnDataDetected(TPVChannelId lcn);
+
+        /* H245Observer virtuals */
+        void Handle(PS_ControlMsgHeader msg);
+
+        // MSD User
+        MSD *Msd;
+        void MSDStart();
+        // Observer functions
+        void MSDDetermineConfirm(MSDStatus type);
+        void MSDDetermineIndication(MSDStatus type);
+        void MSDRejectIndication();
+        void MSDErrorIndication(MSDErrCode errCode);
+
+        // CE User
+        CE *Ce;
+        void CEStart();
+        // Observer functions
+        void CETransferIndication(OsclSharedPtr<S_TerminalCapabilitySet> tcs);
+        void CETransferConfirm();
+        void CERejectIndication(CESource source, CECause cause, CEDirection direction);
+        void SetLoopbackMode(TPVLoopbackMode aLoopbackMode)
+        {
+            iLoopbackMode = aLoopbackMode;
+            if (iH223) iH223->SetLoopbackMode(iLoopbackMode);
+        }
+
+        //SRP observer functions
+        void TransmissionFailure()
+        {
+            if (iObserver)
+            {
+                StopData();
+                iObserver->InternalError();
+            }
+        }
+
+        void SetWnsrp(bool aEnableWnsrp)
+        {
+            iEnableWnsrp = aEnableWnsrp;
+        }
+        void UseWNSRP(bool aUse);
+
+        LogicalChannelInfo* GetLogicalChannelInfo(PVMFPortInterface& port);
+
+
+        /* OsclTimer observer virtuals */
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+        void ResetStats();
+        void LogStats(TPVDirection dir);
+
+        /* Set muliplex level.  Can be called when the node is in the Initialized state */
+        OSCL_IMPORT_REF void SetMultiplexLevel(TPVH223Level muxLevel);
+        OSCL_IMPORT_REF void SetSduSize(TPVDirection direction, uint16 size, TPVAdaptationLayer al);
+        OSCL_IMPORT_REF void SetAl2Sn(int width);
+        OSCL_IMPORT_REF void SetAl3ControlFieldOctets(unsigned cfo);
+        OSCL_IMPORT_REF void SetMaxOutgoingPduSize(uint16 size);
+        OSCL_IMPORT_REF void SetMaxMuxPduSize(uint16 size);
+        OSCL_IMPORT_REF void SetMaxCcsrlSduSize(int size);
+        OSCL_IMPORT_REF void SetOutgoingMuxPduType(TPVH223MuxPduType outgoingPduType);
+        /**
+          Sets the list of outgoing channel types to open and the b/w associated with them.
+          Leaves if the media types, number of channels or the bandwidth is not supported
+          **/
+        OSCL_IMPORT_REF void SetOutgoingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& out_channel_config);
+        OSCL_IMPORT_REF void SetIncomingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& in_channel_config);
+        OSCL_IMPORT_REF void SetEndSessionTimeout(uint32 timeout);
+        OSCL_IMPORT_REF void SetAlConfig(PV2WayMediaType media_type,
+                                         TPVAdaptationLayer layer,
+                                         bool allow);
+        OSCL_IMPORT_REF void SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+                                             uint8 aSeries, uint32 aSeriesOffset, uint32 aValue);
+        OSCL_IMPORT_REF void SetVideoResolutions(TPVDirection dir, Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& resolutions);
+        OSCL_IMPORT_REF void RmeSendReq(void);
+        void EndSessionCommand(void);          /* Change or End Session         */
+        void Tsc_IdcVi(void);
+        void SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel, uint8 aTradeoff);
+        void SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel, uint8 aTradeoff);
+        void SendSkewIndication(TPVChannelId aLogicalChannel1, TPVChannelId aLogicalChannel2, uint16 aSkew);
+        OSCL_IMPORT_REF void  SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                uint32 aOutBufferingMs);
+        void RtdTrfReq(void);
+        OSCL_IMPORT_REF void GetChannelFormatAndCapabilities(TPVDirection dir,
+                Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& formats);
+        OSCL_IMPORT_REF void SendTerminalCapabilitySetCommand(void);
+        OSCL_IMPORT_REF void SendModeRequestCommand();
+
+        void CmdMisc(TCmdMisc type, TPVChannelId channelId, uint32 param = 0);
+
+        CPvtTerminalCapability* GetRemoteCapability();
+        void SetClock(PVMFMediaClock* aClock);
+        void SetMioLatency(int32 aLatency, bool aAudio);
+
+    private:
+        /* Function Prototypes */
+        void CommandComplete(Tsc324mNodeCmdQ& aCmdQ, Tsc324mNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aEventData = NULL);
+
+        /* Sets the dispatch table entries */
+        void SetDispatchTable();
+        void initVarsLocal();
+        void initVarsSession();
+
+        OsclAny TcsMsdComplete();
+        OsclAny SignalCsupComplete(PVMFStatus status);
+
+        /* TSC Handling */
+        /* ------------------------------------ */
+        /*        CALL SETUP Prototypes         */
+        /* ------------------------------------ */
+        uint32 OpenSession(void);
+        uint32 LcEtbIdc(PS_ControlMsgHeader  pReceiveInf);
+        uint32 LcEtbCfm(PS_ControlMsgHeader  pReceiveInf);
+        uint32 LcRlsIdc(PS_ControlMsgHeader  pReceiveInf);
+        uint32 LcErrIdc(PS_ControlMsgHeader  pReceiveInf);
+        uint32 BlcEtbIdc(PS_ControlMsgHeader  pReceiveInf);
+        uint32 BlcEtbCfm(PS_ControlMsgHeader  pReceiveInf);
+        uint32 BlcRlsIdc(PS_ControlMsgHeader  pReceiveInf);
+        uint32 BlcErrIdc(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status04Event22(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status04Event23(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status04Event24(PS_ControlMsgHeader  pReceiveInf);
+        uint32 BlcEtbCfm2(PS_ControlMsgHeader  pReceiveInf);      /* WWU_BLC */
+        uint32 SessionClose_CSUP();
+        uint32 InternalError_CSUP(PS_ControlMsgHeader  pReceiveInf);
+        uint32 MuxTableTransferIndication(PS_ControlMsgHeader  pReceiveInf);
+
+        /* ------------------------------------ */
+        /*       ONGOING COMM Prototypes        */
+        /* ------------------------------------ */
+        uint32 Status08Event11(PS_ControlMsgHeader  pReceiveInf);
+        uint32 LcRlsCfm(PS_ControlMsgHeader  pReceiveInf);       /* WWU BGFX1 */
+        uint32 BlcRlsCfm(PS_ControlMsgHeader  pReceiveInf);       /* RAN BGFX1 Bi-Dir OLCAck */
+        uint32 Status08Event19(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event20(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event21(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event22(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event23(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event24(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event25(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event26(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event27(PS_ControlMsgHeader  pReceiveInf);
+        uint32 ModeRequestIndication(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event29(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event30(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event31(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08Event32(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08User03(PS_ControlMsgHeader  pReceiveInf);
+        uint32 Status08User04(PS_ControlMsgHeader  pReceiveInf);
+        uint32 SendTerminalCapabilitySet(PS_ControlMsgHeader  pReceiveInf);    /* RAN STCS */
+        uint32 FlowControlCommandReceived(PS_ControlMsgHeader  pReceiveInf);        /* AR FC */
+        uint32 FlowControlIndicationReceived(PS_ControlMsgHeader  pReceiveInf);        /* AR FC */
+        void SendFlowControlIndication();
+        uint32 MiscCmdRecv(PS_ControlMsgHeader  pReceiveInf);        /* RAN MSCL */
+        uint32 Status08Event55(PS_ControlMsgHeader  pReceiveInf);        /* RAN HMR */
+        uint32 Status08User06(PS_ControlMsgHeader  pReceiveInf);        /* RAN RME */
+        uint32 Status08User07(PS_ControlMsgHeader  pReceiveInf);        /* RAN STCS */
+        uint32 Status08User08(PS_ControlMsgHeader  pReceiveInf);        /* RAN HMR */
+        uint32 Status08User09(PS_ControlMsgHeader  pReceiveInf);        /* RAN RCC */
+        uint32 Status08User10(PS_ControlMsgHeader  pReceiveInf);	/* RAN CLC */
+        uint32 SessionClose_Comm();
+        uint32 InternalError_Comm(PS_ControlMsgHeader  pReceiveInf);
+        uint32 EndSessionRecv(PS_ControlMsgHeader  pReceiveInf);
+        uint32 VendorIdRecv(PS_ControlMsgHeader  pReceiveInf);
+        uint32 UserInputIndicationRecv(PS_ControlMsgHeader  pReceiveInf);
+        uint32 MiscIndicationRecv(PS_ControlMsgHeader  pReceiveInf);
+        uint32 SkewIndicationRecv(PS_ControlMsgHeader  pReceiveInf);
+        uint32 FunctionNotSupportedIndicationReceived(PS_ControlMsgHeader  pReceiveInf);
+        void StopData();  /* RAN CLC */
+
+        uint32 NonProcedure_Ui(PS_ControlMsgHeader  pReceiveInf);
+        uint32 NonProcedure_Se(PS_ControlMsgHeader  pReceiveInf);
+
+        /* ------------------------------------ */
+        /*           MISC Prototypes            */
+        /* ------------------------------------ */
+        int32 GetReceivedAudioCodec(void);						// (RAN-TD)
+        int32 GetReceivedVideoCodec(void);						// (RAN-TD)
+
+        uint32 CheckAltCapSet(PS_AlternativeCapabilitySet pAltCapSet, uint32 entry, uint32* preference_index);
+        void ExtractTcsParameters(PS_TerminalCapabilitySet pCap);
+        void ParseTcsCapabilities(S_Capability &aCapability);
+
+        void CmdEcrpt(void);                   /* Encryption                    */
+        void CmdFc(void);                      /* Flow Control                  */
+        PVMFPortInterface* FindOutgoingPort(TPVMediaType_t mediaType);
+//	void CmdCnf            ( void );       /* Conference Commands           */
+//	void CmdCm             ( void );       /* Communication Mode Commands   */
+        void CmdHmr(int32);                    /* H223MultiplexReconfiguration  */
+
+        /* RME */
+        void RmeSendRps(void);
+        void RmeRjtReq(void);
+
+        /* Mode Request */
+        void getModeRequestInfo(PS_ControlMsgHeader pReceiveInf, int *param1, int *param2);
+        void MrRjtReq(void);
+
+        // H.245 Miscellaneous Indications
+        typedef enum _TIndicationMisc
+        {
+            EVideoTemporalSpatialTradeOffIdc,
+        }TIndicationMisc;
+        void IndicationMisc(TIndicationMisc type, TPVChannelId channelId, uint32 param = 0, OsclAny* param1 = NULL);
+        void Tsc_IdcSkew(TPVChannelId lcn1, TPVChannelId lcn2, uint16 skew);
+        void SendFunctionNotSupportedIndication(uint16 cause, uint8* function = NULL, uint16 len = 0);
+        // utility functions
+
+        void ShowTsc(uint16 tag, uint16 indent, char* inString);
+        void IgnoreH245Callbacks();
+        void ConfigureSrp(TPVH223Level aLevel);
+        void StopSrp();
+
+#ifdef MEM_TRACK
+        void MemStats();
+#endif
+        /* member variables */
+        /* The SRP Instance */
+        SRP* iSrp;
+
+        /* The H245 instance */
+        H245* iH245;
+
+        /* The H223 instance */
+        H223* iH223;
+
+        uint32 iTerminalStatus;		/* Terminal Status */
+        uint32 iCeRetries;
+
+
+        TPVH245Vendor* iVendor;
+        uint8* iProductNumber;
+        uint32 iProductNumberLen;
+        uint8*  iVersionNumber;
+        uint32 iVersionNumberLen;
+        TPVH245Vendor* iVendorR;
+        uint8* iProductNumberR;
+        uint32 iProductNumberLenR;
+        uint8*  iVersionNumberR;
+        uint32 iVersionNumberLenR;
+
+        unsigned iSendRme; /* Send RME to remote */
+        unsigned iCsupSeq; /* Order of sending TCS, MSD, VID */
+        unsigned iRequestMaxMuxPduSize; /* Requests maxMuxPduSize to the remote terminal if > 0.  This is done after TCS
+											 if the remote terminal supports the maxMuxPduCapability */
+        bool iMaxMuxPduCapabilityR;  /* Does the remote terminal suport maxMuxPduCapability ? */
+
+
+
+        // Additional global variables.
+        S_MobileOperationTransmitCapability* iTransmitCaps;
+
+
+        /* Who initiated disconnect ? 0 - None, 1 - Local, 2 - Remote */
+        unsigned iDisconnectInitiator;
+
+        /* Why did the Connect fail ? */
+        TPVStatusCode iConnectFailReason;
+
+        /* Supplementary Connect info.  We shall use it for now for the case of 2-stage dialling.
+            Here the supplementary info, specifies the url of the person to be dialled */
+        uint8* iSuppInfo;
+        uint32 iSuppInfoLen;
+        // --------------------------------------
+        //  Dispatch table structure definition
+        // --------------------------------------
+        typedef uint32(TSC_324m::*DISPATCH_PTR)(PS_ControlMsgHeader);           /* function pointer              */
+
+        typedef struct _dispatchtable
+        {
+            DISPATCH_PTR Module;      /* function pointer              */
+            uint32    Status;                         /* Status of terminal            */
+            uint32    Event;                          /* Event                         */
+        } S_DispatchTable;
+        S_DispatchTable     iDispatchTable[100];
+
+        // ----------------------------------------------------------
+        // Original dispatch table for (Se<->Tsc) events
+        // ----------------------------------------------------------
+        H223ChannelParam* iUnusedChannels[MAX_LCNS];
+        TPVLoopbackMode iLoopbackMode;
+
+        OsclTimer<OsclMemAllocator>* iTimer;
+    private:
+        // OsclActiveObject virtuals
+        void DoCancel();
+        void Run();
+
+        Tsc324mNodeCommand* FindPendingStartCmd();
+        int32 FindPendingPortCmd(TPVMFGenericNodeCommand aCmdType,  int32 aPortTag, Tsc324mNodeCommand& cmd);
+        Tsc324mNodeCommand* FindPendingStopCmd();
+
+        int FindPendingCmd(PVMFCommandId aCommandId);
+        PVMFCommandId QueueCommandL(Tsc324mNodeCommand& aCmd);
+
+        int32 GetPortTagForLcn(TPVDirection aDir, TPVChannelId aId, PVCodecType_t aCodecType);
+        uint32 GetMaxBitrateForOutgoingChannel(PVCodecType_t codecType);
+        PS_DataType GetDataType(PVCodecType_t codecType, uint32 bitrate, const uint8* dci, uint16 dci_len);
+
+        PVMFCommandId iCurrentCmdId;
+        // Priority queue of commands
+        Tsc324mNodeCmdQ iCmdQueue;
+        Tsc324mNodeCmdQ iPendingCmdQueue;
+
+        // SRP ports
+        PVMFPortInterface* iOutgoingSrpPort;
+        PVMFPortInterface* iIncomingSrpPort;
+        TscSrpBuffer* iTscSrpBuffer;
+
+        /* Mux level */
+        TPVH223Level iH223Level;
+
+        /* Outgoing pdu type - audio only, video only OR Audio+Video */
+        TPVH223MuxPduType iOutgoingPduType;
+        /* Configuration of incoming channels */
+        Oscl_Vector<H223ChannelParam*, PVMFTscAlloc> iIncomingChannels;
+        /* Pending OLCs:  This includes pending and established uni- and bi- directional, incoming and outgoing OLCs. */
+        PVLogger *iLogger;
+        bool iMuxTableUpdateRequired;
+        uint32 iEndSessionTimeout;
+        Tsc324mNodeCommand *iStopCmd;
+        OsclAny* iStopContext;
+        /* Timer/counter values */
+        H245TimerValues iTimerValues;
+        uint32 iT401; /* SRP */
+        uint32 iN100; /* H245 */
+        uint32 iN401; /* SRP */
+        uint32 iMultiplexingDelayMs;
+        uint32 iInLogicalChannelBufferingMs;
+        uint32 iOutLogicalChannelBufferingMs;
+        TSC_324mObserver* iTSC_324mObserver;
+        Oscl_Map<PVMFPortInterface*, H223IncomingChannelPtr, OsclMemAllocator> iRequestedIncomingChannels;
+        Oscl_Map<PVMFPortInterface*, H223OutgoingChannelPtr, OsclMemAllocator> iRequestedOutgoingChannels;
+        uint32 iNumRtdRequests;
+        uint32 iRtdMin;
+        uint32 iRtdMax;
+        uint32 iRtdAve;
+
+        bool iEnableWnsrp;
+        bool iInitialized;
+        bool iInitializedComponent;
+
+        TSC_statemanager iTSCstatemanager;
+        TSC_component* iTSCcomponent;
+        TSC_clc iTSCclc;
+        TSC_blc iTSCblc;
+        TSC_lc  iTSClc;
+        TSC_mt  iTSCmt;
+        TSC_capability iTSCcapability;
+        TSCComponentRegistry iComponentRegistry;
+        PVMFMediaClock* iClock;
+};
+
+#define TSC_TIMER_RES 1000
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tscsrpbuffer.h b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tscsrpbuffer.h
new file mode 100644
index 0000000..65bd813
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/include/tscsrpbuffer.h
@@ -0,0 +1,248 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_SRP_BUFFER_H
+#define TSC_SRP_BUFFER_H
+
+#include "oscl_stdstring.h"
+#include "oscl_types.h"
+#include "oscl_timer.h"
+#include "oscl_mem.h"
+
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+#ifndef PVMF_PORT_INTERFACE_H_INCLUDED
+#include "pvmf_port_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_POOL_BUFFER_ALLOCATOR_H_INCLUDED
+#include "pvmf_pool_buffer_allocator.h"
+#endif
+
+#include "layer.h"
+#include "pvt_params.h"
+
+#include "media_packet.h"
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+
+#define TSCSRPBUFFER_INPUT_PORT_TAG 0
+#define TSCSRPBUFFER_OUTPUT_PORT_TAG 1
+
+class TscSrpBuffer;
+
+class TscSrpBufferLLPortOut : public PvmfPortBaseImpl
+{
+    public:
+        TscSrpBufferLLPortOut() : PvmfPortBaseImpl(TSCSRPBUFFER_OUTPUT_PORT_TAG, NULL) {};
+
+        ~TscSrpBufferLLPortOut() {};
+};
+
+class TscSrpBufferLLPortIn : public PvmfPortBaseImpl
+{
+    public:
+        static TscSrpBufferLLPortIn* NewL(TscSrpBuffer* aTscSrpBuffer);
+
+        virtual ~TscSrpBufferLLPortIn();
+
+        virtual PVMFStatus Receive(PVMFSharedMediaMsgPtr aMsg);
+
+    private:
+        TscSrpBufferLLPortIn(TscSrpBuffer* aTscSrpBuffer) : PvmfPortBaseImpl(TSCSRPBUFFER_INPUT_PORT_TAG, NULL),
+                iCurSize(0),
+                iPkt(NULL),
+                iFrag(NULL),
+                iMediaFragAlloc(NULL),
+                iTscSrpBuffer(aTscSrpBuffer)
+        {};
+        static void ConstructSelf(TscSrpBufferLLPortIn* self);
+
+        void ConstructL();
+
+        uint32 iCurSize;
+        MediaPacket* iPkt;
+        MediaFragment* iFrag;
+        MediaPacketAllocator iMediaPktAlloc;
+        PoolFragmentAllocator* iMediaFragAlloc;
+        TscSrpBuffer* iTscSrpBuffer;
+};
+
+class TscSrpBuffer : /*public SimpleStackElement, */public OsclTimerObserver
+{
+    public:
+        typedef enum
+        {
+            TscSrpBufferStopped,
+            TscSrpBufferStarted
+        }TscSrpBufferState;
+
+        static TscSrpBuffer* NewL();
+
+        virtual ~TscSrpBuffer();
+
+        Layer* GetUpperLayer()
+        {
+            return &iH245Interface;
+        }
+
+        PVMFPortInterface* GetLLPort(const int32 aPortTag)
+        {
+            if (aPortTag == TSCSRPBUFFER_INPUT_PORT_TAG)
+            {
+                return iLLPortIn;
+            }
+            if (aPortTag == TSCSRPBUFFER_OUTPUT_PORT_TAG)
+            {
+                return iLLPortOut;
+            }
+
+            return NULL;
+        }
+
+        void Start();
+        void Stop();
+
+        void Reset();
+        void EnableBuffering(bool enable);
+
+        // Receive packet from H245
+        void ProcessOutgoingH245Packet(MediaPacket* pPkt);
+        // Receive packet from SRP
+        void ProcessIncomingSrpPacket(MediaPacket* pPkt);
+
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+    private:
+
+        static void ConstructSelf(TscSrpBuffer* self);
+        TscSrpBuffer() : iNumMsgs(0),
+                iTxMediaMsgPoolAlloc(NULL),
+                iTxMediaDataImplMemAlloc(NULL),
+                iTxPacketAlloc(NULL),
+                iTimer(NULL),
+                iH245Interface(NULL),
+                iLLPortOut(NULL),
+                iLLPortIn(NULL),
+                iLogger(NULL),
+                iState(TscSrpBufferStarted),
+                iEnableBuffering(true)
+        {};
+
+        void ConstructL();
+
+        uint32 iNumMsgs;
+        OsclMemAllocator iMemAllocator;
+        OsclMemPoolFixedChunkAllocator* iTxMediaMsgPoolAlloc;
+        OsclMemPoolFixedChunkAllocator* iTxMediaDataImplMemAlloc;
+        PVMFSimpleMediaBufferCombinedAlloc* iTxPacketAlloc;
+        OsclTimer<OsclMemAllocator>* iTimer;
+
+        // Interface with H245
+        class UpperLayer : public Layer, public PacketInput, public PacketOutput
+        {
+            public:
+                UpperLayer(TscSrpBuffer* parent)
+                {
+                    iParent = parent;
+                }
+                PacketInput* GetPacketInput()
+                {
+                    return this;
+                }
+                PacketOutput* GetPacketOutput()
+                {
+                    return this;
+                }
+
+                // Implement PAcketInput: process incoming packet
+                void PacketIn(Packet* pack)
+                {
+                    if (iParent)
+                    {
+                        iParent->ProcessOutgoingH245Packet((MediaPacket*) pack);
+                    }
+                }
+                void Dispatch(Packet* pack)
+                {
+                    if (pPktOutput) pPktOutput->PacketIn(pack);
+                }
+
+            private:
+                TscSrpBuffer* iParent;
+        };
+
+        // Interface with SRP
+        class LowerLayer : public Layer, public PacketInput, public PacketOutput
+        {
+            public:
+                LowerLayer(TscSrpBuffer* parent)
+                {
+                    iParent = parent;
+                }
+                PacketInput* GetPacketInput()
+                {
+                    return this;
+                }
+                PacketOutput* GetPacketOutput()
+                {
+                    return this;
+                }
+
+                // Implement PAcketInput: process incoming packet
+                void PacketIn(Packet* pack)
+                {
+                    if (iParent)
+                    {
+                        iParent->ProcessIncomingSrpPacket((MediaPacket*) pack);
+                    }
+                }
+                void Dispatch(Packet* pack)
+                {
+                    if (pPktOutput) pPktOutput->PacketIn(pack);
+                }
+            private:
+                TscSrpBuffer* iParent;
+        };
+
+
+        // Data sendto interfaces.
+        // When sending to a lower layer, you are calling that object's upper layer rx,
+        // when sending to an upper layer, you are calling that object's lower layer rx, got it?
+        UpperLayer iH245Interface;
+        PVMFPortInterface* iLLPortOut;
+        PVMFPortInterface* iLLPortIn;
+        PVLogger* iLogger;
+        PVMFSharedMediaDataPtr iTxData;
+        TscSrpBufferState iState;
+        bool iEnableBuffering;
+        friend class TscSrpBufferLLPortIn;
+};
+#endif
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_blc.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_blc.cpp
new file mode 100644
index 0000000..ab46c47
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_blc.cpp
@@ -0,0 +1,247 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#include "tsc_blc.h"         // Bi-directional Logical Channel Information Header 
+#include "tsc_sub.h"         // Sub Routine Information Header            
+#include "oscl_mem.h"
+#include "h245def.h"
+#include "h245_copier.h"
+#include "h223types.h"
+#include "tsc_constants.h"
+#include "tsc_statemanager.h"
+
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_BlcEtbReq                                     */
+/*  function outline     : Tsc_BlcEtbReq procedure                           */
+/*  function discription : Tsc_BlcEtbReq( LcnIndex )                          */
+/*  input data           : uint32                 Open Lcn                     */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_blc::BlcEtbReq(TPVChannelId Lcn,
+                        PS_DataType pDataTypeForward,
+                        PS_H223LogicalChannelParameters pH223ParamsForward,
+                        PS_DataType pDataTypeReverse,
+                        PS_H223LogicalChannelParameters pH223ParamsReverse)
+{
+    S_ControlMsgHeader         infHeader;
+    S_ForwardReverseParam      parameter;
+    S_DataType  dataTypeNull;
+    dataTypeNull.index = 1;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_blc::BlcEtbReq lcn(%d), %x, %x, %x, %x", Lcn, pDataTypeForward, pH223ParamsForward, pDataTypeReverse, pH223ParamsReverse));
+
+    if (pDataTypeReverse == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0,
+                         "TSC_blc::BlcEtbReq Reverse DataType == null"));
+        pDataTypeReverse = &dataTypeNull;
+    }
+
+    if (pH223ParamsReverse == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0,
+                         "TSC_blc::BlcEtbReq Reverse H223Params == null"));
+        pH223ParamsReverse = pH223ParamsForward;
+    }
+
+    PS_DataType dt = Copy_DataType(pDataTypeForward);
+    oscl_memcpy(&parameter.forwardLogicalChannelParameters.dataType,
+                dt,
+                sizeof(S_DataType));
+    OSCL_DEFAULT_FREE(dt);
+
+    // Buffer Allocate
+    parameter.forwardLogicalChannelParameters.option_of_portNumber = false;
+
+    // MultiplexParameters
+    parameter.forwardLogicalChannelParameters.multiplexParameters.index = 1;  // h223
+    parameter.forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters =
+        Copy_H223LogicalChannelParameters(pH223ParamsForward);
+
+    // ForwardLogicalChannelParameters
+    parameter.forwardLogicalChannelParameters.option_of_forwardLogicalChannelDependency = false;
+    parameter.forwardLogicalChannelParameters.option_of_replacementFor = false;
+
+    // ===========================================================
+    // =========== reverseLogicalChannelParameters ===============
+    // ===========================================================
+
+    parameter.option_of_reverseLogicalChannelParameters = true;
+
+    dt = Copy_DataType(pDataTypeReverse);
+    oscl_memcpy(&parameter.reverseLogicalChannelParameters.dataType,
+                dt,
+                sizeof(S_DataType));
+    OSCL_DEFAULT_FREE(dt);
+
+    parameter.reverseLogicalChannelParameters.option_of_rlcMultiplexParameters = true;
+    // MultiplexParameters
+    parameter.reverseLogicalChannelParameters.rlcMultiplexParameters.index = 0;  // h223
+    parameter.reverseLogicalChannelParameters.rlcMultiplexParameters.h223LogicalChannelParameters =
+        Copy_H223LogicalChannelParameters(pH223ParamsReverse);
+
+    // rEVERSELogicalChannelParameters
+    parameter.reverseLogicalChannelParameters.option_of_reverseLogicalChannelDependency = false;
+    parameter.reverseLogicalChannelParameters.option_of_replacementFor = false;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Blc_Etb_Req,
+                    Lcn,
+                    0,
+                    (uint8*)&parameter,
+                    sizeof(S_ForwardReverseParam));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    iTSCstatemanager.WriteState(TSC_LC_VIDEO_SEND, STARTED);
+
+    Delete_DataType(&parameter.forwardLogicalChannelParameters.dataType);
+    Delete_DataType(&parameter.reverseLogicalChannelParameters.dataType);
+    Delete_H223LogicalChannelParameters(
+        parameter.forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters);
+    OSCL_DEFAULT_FREE(
+        parameter.forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters);
+    Delete_H223LogicalChannelParameters(
+        parameter.reverseLogicalChannelParameters.rlcMultiplexParameters.h223LogicalChannelParameters);
+    OSCL_DEFAULT_FREE(
+        parameter.reverseLogicalChannelParameters.rlcMultiplexParameters.h223LogicalChannelParameters);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_BlcEtbRps                                     */
+/*  function outline     : Tsc_BlcEtbRps procedure                           */
+/*  function discription : Tsc_BlcEtbRps( OpenPendingLcn )                   */
+/*  input data           : uint32                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_blc::BlcEtbRps(TPVChannelId incoming_lcn, TPVChannelId outgoing_lcn)
+{
+    S_ControlMsgHeader	infHeader;
+    S_ReverseData		parameter;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0,
+                     "TSC_blc::BlcEtbRps incoming(%d), outgoing(%d)\n", incoming_lcn, outgoing_lcn));
+
+    // Buffer Allocate
+    oscl_memset(&parameter, 0, sizeof(S_ReverseData));
+
+    // ESTABLISH.response primitive - Parameter(REVERSE_DATA)
+    parameter.option_of_reverseLogicalChannelParameters = true;
+    parameter.reverseLogicalChannelParameters.reverseLogicalChannelNumber =
+        (uint16)incoming_lcn; // WWU_BLC: change 0->3
+    parameter.reverseLogicalChannelParameters.option_of_portNumber = false;
+    parameter.reverseLogicalChannelParameters.option_of_ackMultiplexParameters = false;
+    parameter.reverseLogicalChannelParameters.option_of_replacementFor = false;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Blc_Etb_Rps,
+                    incoming_lcn,
+                    outgoing_lcn,
+                    (uint8*)&parameter,
+                    sizeof(S_ReverseData));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_BlcRlsReq                                     */
+/*  function outline     : Tsc_BlcRlsReq                                     */
+/*  function discription : Tsc_BlcRlsReq( ReleaseType, CloseLcn )            */
+/*  input data           : int32                                               */
+/*                       : uint32                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+TPVDirection TSC_blc::BlcRlsReq(int32 ReleaseType,
+                                uint32 CloseLcn,
+                                uint32 Cause)	// WWU_VOAL2: add Cause
+{
+    S_ControlMsgHeader	infHeader;
+    S_OlcRejectCause	parameter;
+    TPVDirection dir = OUTGOING;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0,
+                     "TSC_blc::BlcRlsReq lcn(%d), Release type(%d), Cause(%d)\n",
+                     CloseLcn, ReleaseType, Cause));
+
+    if (ReleaseType == RELEASE_CLOSE)
+    {
+        // Close outgoing
+        dir = OUTGOING;
+        Tsc_SendDataSet(&infHeader,
+                        H245_PRIMITIVE,
+                        E_PtvId_Blc_Rls_Req,
+                        CloseLcn,
+                        0,
+                        NULL,
+                        0);
+    }
+    else
+    {
+        // Reject incoming
+        dir = INCOMING;
+        // Buffer Allocate
+        parameter.index = (uint16)Cause;
+        Tsc_SendDataSet(&infHeader,
+                        H245_PRIMITIVE,
+                        E_PtvId_Blc_Rls_Req,
+                        CloseLcn,
+                        0,
+                        (uint8*)&parameter,
+                        sizeof(S_OlcRejectCause));
+    }
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+    return dir;
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_capability.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_capability.cpp
new file mode 100644
index 0000000..c965a95
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_capability.cpp
@@ -0,0 +1,1239 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "tsc_capability.h"
+
+#include "tsc_statemanager.h"
+#include "tsc_component.h"
+
+void TSC_capability::InitVarsSession()
+{
+    iTcsIn_H263_sqcifMPI = 0;		// Units 1/30 second
+    iTcsIn_H263_qcifMPI = 2;		// Units 1/30 second
+    iTcsIn_H263_cifMPI = 0;		// Units 1/30 second
+    iTcsIn_H263_4cifMPI = 0;		// Units 1/30 second
+    iTcsIn_H263_16cifMPI = 0;		// Units 1/30 second
+}
+
+void TSC_capability::InitVarsLocal()
+{
+    /* Initialize video resolutions */
+    PVMFVideoResolutionRange qcif_range(PVMF_RESOLUTION_QCIF, PVMF_RESOLUTION_QCIF);
+    iResolutionsRx.push_back(qcif_range);
+    iResolutionsTx.push_back(qcif_range);
+}
+void TSC_capability::ResetCapability()
+{
+    if (iRemoteCapability)
+    {
+        delete iRemoteCapability;
+        iRemoteCapability = NULL;
+    }
+}
+
+TSC_capability::~TSC_capability()
+{
+    ResetCapability();
+}
+
+Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>
+TSC_capability::GetResolutions(TPVDirection dir)
+{
+    if (dir == OUTGOING)
+    {
+        return iResolutionsTx;
+    }
+    return iResolutionsRx;
+}
+
+void TSC_capability::SetVideoResolutions(TPVDirection dir,
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& resolutions)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::SetVideoResolutions dir(%d), size(%d)", dir, resolutions.size()));
+    if (dir == OUTGOING)
+    {
+        iResolutionsTx = resolutions;
+    }
+    else if (dir == INCOMING)
+    {
+        iResolutionsRx = resolutions;
+    }
+}
+
+
+uint32 TSC_capability::GetRemoteBitrate(PVCodecType_t codec_type)
+{
+    /* lookup the bitrate from remote capabilities */
+    for (uint16 i = 0; i < iRemoteCapability->GetNumCapabilityItems();i++)
+    {
+        if (iRemoteCapability->GetCapabilityItem(i)->GetFormatType() == PVCodecTypeToPVMFFormatType(codec_type))
+        {
+            uint32 br = iRemoteCapability->GetCapabilityItem(i)->GetBitrate();
+            return br;
+        }
+    }
+    return 0;
+}
+
+void TSC_capability::ExtractTcsParameters(PS_VideoCapability pVideo, CPvtH263Capability *aMedia_capability)
+{
+    int frame_rate = GetMaxFrameRate_H263(pVideo->h263VideoCapability);
+    if (pVideo->h263VideoCapability->option_of_sqcifMPI)
+    {
+        iTcsIn_H263_sqcifMPI = pVideo->h263VideoCapability->sqcifMPI;
+        aMedia_capability->SetMaxResolution(128, 96, frame_rate);
+
+    }
+    if (pVideo->h263VideoCapability->option_of_qcifMPI)
+    {
+        iTcsIn_H263_qcifMPI = pVideo->h263VideoCapability->qcifMPI;
+        aMedia_capability->SetMaxResolution(176, 144, frame_rate);
+    }
+    if (pVideo->h263VideoCapability->option_of_cifMPI)
+    {
+        iTcsIn_H263_cifMPI = pVideo->h263VideoCapability->cifMPI;
+        aMedia_capability->SetMaxResolution(352, 288, frame_rate);
+    }
+    if (pVideo->h263VideoCapability->option_of_cif4MPI)
+    {
+        iTcsIn_H263_4cifMPI = pVideo->h263VideoCapability->cif4MPI;
+        aMedia_capability->SetMaxResolution(704, 576, frame_rate);
+    }
+    if (pVideo->h263VideoCapability->option_of_cif16MPI)
+    {
+        iTcsIn_H263_16cifMPI = pVideo->h263VideoCapability->cif16MPI;
+        aMedia_capability->SetMaxResolution(1408, 1192, frame_rate);
+    }
+}
+
+void TSC_capability::ExtractTcsParameters(PS_VideoCapability pVideo, CPvtMpeg4Capability *aMedia_capability)
+{
+    int frame_rate = GetMaxFrameRate_M4V(pVideo->genericVideoCapability);
+    aMedia_capability->SetMaxResolution(176, 144, frame_rate);
+}
+
+////////////////////////////////////////////////////////////////////////////
+// ParseTcsCapabilities()
+//
+// This routine takes the incoming TerminalCapability
+//   and parsed all capabilities - Audio, Video, UserInput.
+//
+////////////////////////////////////////////////////////////////////////////
+
+void TSC_capability::ParseTcsCapabilities(S_Capability &aCapability, Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator> &aMedia_capability, uint32 aUserInputCapabilities, S_UserInputCapability *aUserInputCapability)
+{
+    CodecCapabilityInfo codec_info;
+    PS_VideoCapability pVideo = NULL;
+    PS_AudioCapability pAudio = NULL;
+    PVMFFormatType format_type = PVMF_MIME_FORMAT_UNKNOWN;
+
+    pVideo = NULL;
+    pAudio = NULL;
+    switch (aCapability.index)
+    {
+        case 1: // ReceiveVideo
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability: Remote video caps ReceiveVideo\n"));
+            pVideo = aCapability.receiveVideoCapability;
+            break;
+        case 3: // ReceiveAndTransmitVideo
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability: Remote video caps ReceiveAndTransmitVideo\n"));
+            pVideo = aCapability.receiveAndTransmitVideoCapability;
+            break;
+        case 4:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability: Remote video caps ReceiveAudio\n"));
+            pAudio = aCapability.receiveAudioCapability;
+            break;
+        case 6:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability: Remote video caps ReceiveAndTransmitAudio\n"));
+            pAudio = aCapability.receiveAndTransmitAudioCapability;
+            break;
+        case 15:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability: Remote caps receiveUserInputCapability"));
+            aUserInputCapability = aCapability.receiveUserInputCapability;
+            break;
+        case 17:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability: Remote caps receiveAndTransmitUserInputCapability"));
+            aUserInputCapability = aCapability.receiveAndTransmitUserInputCapability;
+            break;
+        default:
+            return;
+    }
+    GetCodecInfo(&aCapability, codec_info);
+    if (codec_info.codec == PV_CODEC_TYPE_NONE)
+        return;
+    format_type = PVCodecTypeToPVMFFormatType(codec_info.codec);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::ParseTcsCapabilities CapabilityTable codec=%d,format=%s",
+                     codec_info.codec, format_type.getMIMEStrPtr()));
+    CPvtMediaCapability* media_capability = NULL;
+
+    if (pVideo)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability::ParseTcsCapabilities Remote video caps Video index(%d)\n",
+                         pVideo->index));
+        if (format_type == PVMF_MIME_H2632000) 			// H263VideoCapability
+        {
+            pVideo->index = 3;
+            media_capability = new CPvtH263Capability();
+
+            media_capability->iBitrate = pVideo->h263VideoCapability->maxBitRate;
+            // Extract H263 Parameters
+            ExtractTcsParameters(pVideo, (CPvtH263Capability*)media_capability);
+            ((CPvtH263Capability *)media_capability)->iH263VideoCapability = pVideo->h263VideoCapability;
+            aMedia_capability.push_back(media_capability);
+
+        }
+        else if (format_type == PVMF_MIME_M4V)
+        {
+
+            media_capability = new CPvtMpeg4Capability();
+            media_capability->iBitrate = pVideo->genericVideoCapability->maxBitRate;
+            ExtractTcsParameters(pVideo, (CPvtMpeg4Capability*)media_capability);
+            ((CPvtMpeg4Capability*)media_capability)->iGenericCapability = pVideo->genericVideoCapability;
+            aMedia_capability.push_back(media_capability);
+        }
+#if 0
+        else if (format_type == PVMF_MIME_AVC)
+        {
+            CPvtAvcCapability* h264_capability = (CPvtAvcCapability*)media_capability;
+            media_capability->iBitrate = pVideo->genericVideoCapability->maxBitRate;
+            ParseH264Capability(pVideo->genericVideoCapability, *h264_capability);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ParseTcsCapabilities H264 Capability:"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "Profile=%d,Level=%d,DCI Length=%d",
+                             h264_capability->iProfile,
+                             h264_capability->iLevel,
+                             h264_capability->iDecoderConfigLen));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "CustomMaxMBPS=%d,CustomMaxFS=%d,CustomMaxDPB=%d",
+                             h264_capability->iCustomMaxMBPS,
+                             h264_capability->iCustomMaxFS,
+                             h264_capability->iCustomMaxDPB));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "CustomMaxBRandCPB=%d,MaxStaticMBPS=%d",
+                             h264_capability->iCustomMaxBRandCPB,
+                             h264_capability->iMaxStaticMBPS));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "max-rcmd-nal-unit-size=%d,max-nal-unit-size=%d",
+                             h264_capability->iMaxRcmdNalUnitSize,
+                             h264_capability->iMaxNalUnitSize));
+        }
+#endif
+    }
+    else if (pAudio)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability: Remote caps Audio index(%d)\n", pAudio->index));
+        if (pAudio->index == 8)
+        {
+            media_capability = new CPvtAudioCapability(format_type);
+            aMedia_capability.push_back(media_capability);
+            media_capability->iBitrate = 64;
+        }
+        else if (pAudio->index == 20)
+        {
+            media_capability = new CPvtAudioCapability(format_type);
+            aMedia_capability.push_back(media_capability);
+            media_capability->iBitrate = pAudio->genericAudioCapability->maxBitRate;
+        }
+    }
+    else if (aUserInputCapability)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability: Remote caps UI index(%d)\n",
+                         aUserInputCapability->index));
+        aUserInputCapabilities |= (1 << aUserInputCapability->index);
+    }
+
+
+}
+
+PS_DataType TSC_capability::GetOutgoingDataType(PVCodecType_t codecType,
+        uint32 bitrate,
+        uint16 csi_len,
+        uint8* csi)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::GetOutgoingDataType - codecType(%d), bitrate(%d)", codecType, bitrate));
+
+    PS_DataType pDataType = (PS_DataType) OSCL_DEFAULT_MALLOC(sizeof(S_DataType));
+    oscl_memset(pDataType, 0, sizeof(S_DataType));
+    PS_GenericCapability	genericCap = NULL;
+    uint16 index = 0;
+
+    /* lookup the bitrate from remote capabilities */
+    for (index = 0; index < iRemoteCapability->GetNumCapabilityItems();index++)
+    {
+        if (iRemoteCapability->GetCapabilityItem(index)->GetFormatType() ==
+                PVCodecTypeToPVMFFormatType(codecType))
+        {
+            bitrate = iRemoteCapability->GetCapabilityItem(index)->GetBitrate();
+            break;
+
+        }
+    }
+    switch (codecType)
+    {
+        case PV_AUD_TYPE_G723: /* WWURM: change H324_AUDIO_RECV to H324_AUDIO_SEND */
+            /* (LCN=2): G723 Audio */
+            PS_G7231		g723Cap;
+            pDataType->index = 3;
+            /* NEW245: allocate memory for audioData*/
+            pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            pDataType->audioData->index = 8;
+            /* NEW245: allocate memory for g7231 */
+            pDataType->audioData->g7231 =
+                g723Cap =
+                    (PS_G7231) OSCL_DEFAULT_MALLOC(sizeof(S_G7231));
+            g723Cap->maxAl_sduAudioFrames = 1;
+            g723Cap->silenceSuppression = false;
+            break;
+        case PV_AUD_TYPE_GSM:
+            /* (LCN=2): Amr Audio */
+            pDataType->index = 3;
+            /* NEW245: allocate memory for audioData */
+            pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            pDataType->audioData->index = 20;
+            /* NEW245: allocate memory for genericAudioCapability */
+            pDataType->audioData->genericAudioCapability =
+                genericCap =
+                    (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            genericCap->capabilityIdentifier.index = 0;
+            /* NEW245: allocate memory for standard */
+            genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            genericCap->capabilityIdentifier.standard->size = 7;
+            genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8));
+            genericCap->capabilityIdentifier.standard->data[0] = 0x00;
+            genericCap->capabilityIdentifier.standard->data[1] = 0x08;
+            genericCap->capabilityIdentifier.standard->data[2] = 0x81;
+            genericCap->capabilityIdentifier.standard->data[3] = 0x75;
+            genericCap->capabilityIdentifier.standard->data[4] = 0x01;
+            genericCap->capabilityIdentifier.standard->data[5] = 0x01;
+            genericCap->capabilityIdentifier.standard->data[6] = 0x01;
+            genericCap->option_of_maxBitRate = true;
+            genericCap->maxBitRate = bitrate;
+            genericCap->option_of_collapsing = true;
+            genericCap->size_of_collapsing = 1;
+            genericCap->collapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(1 * sizeof(S_GenericParameter));
+            genericCap->collapsing[0].parameterIdentifier.index = 0;
+            genericCap->collapsing[0].parameterIdentifier.standard = 0;
+            genericCap->collapsing[0].parameterValue.index = 2;
+            genericCap->collapsing[0].parameterValue.unsignedMin = 1;
+            genericCap->collapsing[0].option_of_supersedes = false;
+
+            genericCap->option_of_nonCollapsing = false;
+            genericCap->option_of_nonCollapsingRaw = false;
+            genericCap->option_of_transport = false;
+            break;
+        case PV_VID_TYPE_H263:
+            /* (LCN=3): H263 Video */
+            PS_H263VideoCapability	h263VideoCap;
+            pDataType->index = 2;
+            /* NEW245: allocate memory for videoData */
+            pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            oscl_memset(pDataType->videoData, 0, sizeof(S_VideoCapability));
+            pDataType->videoData->index = 3;
+            /* NEW245: allocate memory for h263VideoCapability */
+            pDataType->videoData->h263VideoCapability =
+                h263VideoCap =
+                    (PS_H263VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoCapability));
+            oscl_memset(pDataType->videoData->h263VideoCapability, 0, sizeof(S_H263VideoCapability));
+
+            if (iTcsIn_H263_sqcifMPI && IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_sqcifMPI = true;
+                h263VideoCap->sqcifMPI = (uint8)iTcsIn_H263_sqcifMPI;
+            }
+
+            if (iTcsIn_H263_qcifMPI && IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_qcifMPI = true;
+                h263VideoCap->qcifMPI = 2;
+            }
+
+            if (iTcsIn_H263_cifMPI && IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_cifMPI = true;
+                h263VideoCap->cifMPI = (uint8)iTcsIn_H263_cifMPI;
+            }
+
+            if (iTcsIn_H263_4cifMPI && IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_cif4MPI = true;
+                h263VideoCap->cif4MPI = (uint8)iTcsIn_H263_4cifMPI;
+            }
+
+            if (iTcsIn_H263_16cifMPI && IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_cif16MPI = true;
+                h263VideoCap->cif16MPI = (uint8)iTcsIn_H263_16cifMPI;
+            }
+
+            h263VideoCap->option_of_cifMPI = false;
+            h263VideoCap->option_of_cif4MPI = false;
+            h263VideoCap->option_of_cif16MPI = false;
+            h263VideoCap->maxBitRate = bitrate;
+            h263VideoCap->unrestrictedVector = false;
+            h263VideoCap->arithmeticCoding = false;
+            h263VideoCap->advancedPrediction = false;
+            h263VideoCap->pbFrames = false;
+            h263VideoCap->temporalSpatialTradeOffCapability = ON;
+            h263VideoCap->option_of_hrd_B = false;
+            h263VideoCap->option_of_bppMaxKb = false;
+            h263VideoCap->option_of_slowSqcifMPI = false;
+            h263VideoCap->option_of_slowQcifMPI = false;
+            h263VideoCap->option_of_slowCifMPI = false;
+            h263VideoCap->option_of_slowCif4MPI = false;
+            h263VideoCap->option_of_slowCif16MPI = false;
+            h263VideoCap->errorCompensation = false;
+            h263VideoCap->option_of_enhancementLayerInfo = false;
+            h263VideoCap->option_of_h263Options = false;
+            break;
+        case PV_VID_TYPE_MPEG4:
+        {
+            /* (LCN=3): MPEG4 Video */
+            pDataType->index = 2;
+            /* NEW245: allocate memory for videoData */
+            pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            pDataType->videoData->index = 5;
+            /* NEW245: allocate memory for genericVideoCapability */
+            pDataType->videoData->genericVideoCapability =
+                genericCap =
+                    (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            genericCap->capabilityIdentifier.index = 0;
+            /* NEW245: allocate memory for standard */
+            genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            genericCap->capabilityIdentifier.standard->size = 7;
+            genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8));
+            genericCap->capabilityIdentifier.standard->data[0] = 0x00;
+            genericCap->capabilityIdentifier.standard->data[1] = 0x08;
+            genericCap->capabilityIdentifier.standard->data[2] = 0x81;
+            genericCap->capabilityIdentifier.standard->data[3] = 0x75;
+            genericCap->capabilityIdentifier.standard->data[4] = 0x01;
+            genericCap->capabilityIdentifier.standard->data[5] = 0x00;
+            genericCap->capabilityIdentifier.standard->data[6] = 0x00;
+            genericCap->option_of_maxBitRate = true;
+            genericCap->maxBitRate = bitrate;
+            genericCap->option_of_collapsing = false;
+            genericCap->option_of_nonCollapsing = true;
+            genericCap->size_of_nonCollapsing = 3;
+            genericCap->nonCollapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(3 * sizeof(S_GenericParameter));
+            genericCap->nonCollapsing[0].parameterIdentifier.index = 0;
+            genericCap->nonCollapsing[0].parameterIdentifier.standard = 0;
+            genericCap->nonCollapsing[0].parameterValue.index = 3;
+            // Value on next line changed to 8 (RAN - PandL)
+            genericCap->nonCollapsing[0].parameterValue.unsignedMax = 8;	/* simple profile level 0 */
+            genericCap->nonCollapsing[0].option_of_supersedes = false;
+
+            genericCap->nonCollapsing[1].parameterIdentifier.index = 0;
+            genericCap->nonCollapsing[1].parameterIdentifier.standard = 1;
+            genericCap->nonCollapsing[1].parameterValue.index = 3;
+            genericCap->nonCollapsing[1].parameterValue.unsignedMax = 1;	/* simple profile object */
+            genericCap->nonCollapsing[1].option_of_supersedes = false;
+
+            /* WWU_VOAL2: BLCMP4 temporally off */
+            genericCap->nonCollapsing[2].parameterIdentifier.index = 0;
+            genericCap->nonCollapsing[2].parameterIdentifier.standard = 2;
+            genericCap->nonCollapsing[2].parameterValue.index = 6;
+            /* NEW245: allocate memory for octetString */
+            genericCap->nonCollapsing[2].parameterValue.octetString =
+                (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+            if (csi && csi_len)
+            {
+                genericCap->nonCollapsing[2].parameterValue.octetString->data = (uint8*)OSCL_DEFAULT_MALLOC(csi_len);
+                oscl_memcpy(genericCap->nonCollapsing[2].parameterValue.octetString->data,
+                            csi,
+                            csi_len);
+                genericCap->nonCollapsing[2].parameterValue.octetString->size = csi_len;
+            }
+            else  // need to set it to FILLER FSI otherwise PER copy/delete routines will Leave
+            {
+                genericCap->nonCollapsing[2].parameterValue.octetString->data = (uint8*)OSCL_DEFAULT_MALLOC(PV2WAY_FILLER_FSI_LEN);
+                SetFillerFsi(genericCap->nonCollapsing[2].parameterValue.octetString->data, PV2WAY_FILLER_FSI_LEN);
+                genericCap->nonCollapsing[2].parameterValue.octetString->size = PV2WAY_FILLER_FSI_LEN;
+            }
+            genericCap->nonCollapsing[2].option_of_supersedes = false;
+
+            genericCap->option_of_nonCollapsingRaw = false;
+            genericCap->option_of_transport = false;
+        }
+        break;
+#if 0
+        case PV_VID_TYPE_H264:
+        {
+            VideoCodecCapabilityInfo h264_info;
+            h264_info.codec = PV_VID_TYPE_H264;
+            h264_info.dir = OUTGOING;
+            h264_info.codec_specific_info_len = csi_len;
+            h264_info.codec_specific_info = (uint8*)OSCL_DEFAULT_MALLOC(h264_info.codec_specific_info_len);
+            oscl_memcpy(h264_info.codec_specific_info, csi, csi_len);
+            pDataType->index = 2;
+            pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            oscl_memset(pDataType->videoData, 0, sizeof(S_VideoCapability));
+            pDataType->videoData->index = 5;
+            pDataType->videoData->genericVideoCapability =
+                (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            oscl_memset(pDataType->videoData->genericVideoCapability, 0, sizeof(S_GenericCapability));
+            FillH264Capability(h264_info, pDataType->videoData->genericVideoCapability, TRUE);
+        }
+        break;
+#endif
+        default:
+            /* NULL data type */
+            pDataType->index = 1;
+    }
+    return pDataType;
+}
+
+/* The following routine verifies if an incoming datatype is syntactically valid and supported */
+PVMFStatus TSC_capability::ValidateIncomingDataType(bool forRev, PS_DataType pDataType)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::ValidateIncomingDataType(%d,%x)", forRev, pDataType));
+    if (!pDataType)
+        return PVMFFailure;
+
+    if (pDataType->index == 1) // null data
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability::ValidateIncomingDataType - null data type received"));
+        if (forRev)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ValidateIncomingDataType Error - null data not acceptable for forward parameters"));
+            return PVMFFailure;
+        }
+        return PVMFSuccess;
+    }
+    else if (pDataType->index == 2)  // videoData
+    {
+        PS_VideoCapability video_cap = pDataType->videoData;
+        if (video_cap->index == 3) /* H263 */
+        {
+            PS_H263VideoCapability	h263Cap = video_cap->h263VideoCapability;
+            // checks only valid on forward parameters
+            if (forRev)
+            {
+                // check if any unsupported resolution is indicated
+                if ((h263Cap->option_of_sqcifMPI && !IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsRx)) ||
+                        (h263Cap->option_of_qcifMPI && !IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsRx)) ||
+                        (h263Cap->option_of_cifMPI && !IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsRx)) ||
+                        (h263Cap->option_of_cif4MPI && !IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsRx)) ||
+                        (h263Cap->option_of_cif16MPI && !IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsRx)))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                    (0, "TSC_capability::ValidateIncomingDataType ERROR  - Unsuported resolution"));
+                    return PVMFErrNotSupported;
+                }
+                // check if atleast one resolution is enabled
+                if (!(h263Cap->option_of_sqcifMPI ||
+                        h263Cap->option_of_qcifMPI ||
+                        h263Cap->option_of_cifMPI ||
+                        h263Cap->option_of_cif4MPI ||
+                        h263Cap->option_of_cif16MPI))
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                    (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid datatype for H.263.  No resolutions indicated."));
+                    return PVMFFailure;
+                }
+            }
+            else // checks only valid on reverse parameters
+            {
+                unsigned num_ok_resolutions = 0;
+                if (h263Cap->option_of_sqcifMPI &&
+                        IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsTx))
+                {
+                    if (h263Cap->sqcifMPI < 1 || h263Cap->sqcifMPI > 30)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                        (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid H263 SQCIF mpi"));
+                    }
+                    else
+                        num_ok_resolutions++;
+                }
+                if (h263Cap->option_of_qcifMPI &&
+                        IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsTx))
+                {
+                    if (h263Cap->qcifMPI < 1 || h263Cap->qcifMPI > 30)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                        (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid H263 QCIF mpi"));
+                    }
+                    else
+                        num_ok_resolutions++;
+                }
+                if (h263Cap->option_of_cifMPI &&
+                        IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsTx))
+                {
+                    if (h263Cap->cifMPI < 1 || h263Cap->cifMPI > 30)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                        (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid H263 QCIF mpi"));
+                    }
+                    else
+                        num_ok_resolutions++;
+                }
+                if (h263Cap->option_of_cif4MPI &&
+                        IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsTx))
+                {
+                    if (h263Cap->cif4MPI < 1 || h263Cap->cif4MPI > 30)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                        (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid H263 QCIF mpi"));
+                    }
+                    else
+                        num_ok_resolutions++;
+                }
+                if (h263Cap->option_of_cif16MPI &&
+                        IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsTx))
+                {
+                    if (h263Cap->cif16MPI < 1 || h263Cap->cif16MPI > 30)
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                        (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid H263 QCIF mpi"));
+                    }
+                    else
+                        num_ok_resolutions++;
+                }
+                if (num_ok_resolutions == 0)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                    (0, "TSC_capability::ValidateIncomingDataType ERROR  - Cannot transmit using this codec"));
+                    return PVMFFailure;
+                }
+            }
+            if (h263Cap->maxBitRate > 640)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                (0, "TSC_capability::ValidateIncomingDataType ERROR  - Invalid bitrate(%d)", h263Cap->maxBitRate));
+                return PVMFFailure;
+            }
+        }
+        else if (video_cap->index == 5) /* MPEG 4 */
+        {
+            //PS_GenericCapability m4vCap=video_cap->genericVideoCapability;
+            uint8* fsi = NULL;
+            unsigned fsisz =::GetFormatSpecificInfo(pDataType, fsi);
+            if (fsi != NULL && fsisz != 0)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                (0, "TSC_capability::ValidateIncomingDataType VOL header dump"));
+                printBuffer(iLogger, fsi, (uint16)fsisz);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                                (0, "TSC_capability::ValidateIncomingDataType VOL header not given"));
+            }
+        }
+        else
+        {
+            return PVMFErrNotSupported;
+        }
+    }
+    else if (pDataType->index == 3)  // audioData
+    {
+        PS_AudioCapability audio_cap = pDataType->audioData;
+        if (audio_cap->index == 8) /* G.723 */
+        {
+            //PS_G7231 g723Cap = audio_cap->g7231;
+
+        }
+        else if (audio_cap->index == 20) /* AMR */
+        {
+            //PS_GenericCapability amrCap=audio_cap->genericAudioCapability;
+        }
+        else
+        {
+
+            return PVMFErrNotSupported;
+        }
+    }
+    else
+    {
+        return PVMFErrNotSupported;
+    }
+    return PVMFSuccess;
+}
+
+/* The following routines return our preferences for DataType and H223LogicalChannelParameters */
+bool TSC_capability::IsSegmentable(TPVDirection direction, PV2WayMediaType media_type)
+{
+    OSCL_UNUSED_ARG(direction);
+    switch (media_type)
+    {
+        case PV_AUDIO:
+            return false;
+        case PV_VIDEO:
+            return true;
+        default:
+            return true;
+    }
+}
+
+PS_H223LogicalChannelParameters
+TSC_capability::GetOutgoingLcnParams(PV2WayMediaType media_type, PS_AdaptationLayerType adaptation_layer)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability:GetLcnParams - media_type(%d), layer(%x)", media_type, adaptation_layer));
+    OSCL_ASSERT(media_type == PV_AUDIO || media_type == PV_VIDEO);
+    PS_H223LogicalChannelParameters pParameter = (PS_H223LogicalChannelParameters)OSCL_DEFAULT_MALLOC(sizeof(S_H223LogicalChannelParameters));
+    oscl_memset(pParameter , 0, sizeof(S_H223LogicalChannelParameters));
+
+    pParameter->segmentableFlag = IsSegmentable(OUTGOING, media_type);
+    pParameter->adaptationLayerType.index = adaptation_layer->index;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability: GetLcnParams al index(%d) \n", pParameter->adaptationLayerType.index));
+
+    if (pParameter->adaptationLayerType.index == 5)
+    {
+        /* AL3(Video) */
+        pParameter->adaptationLayerType.al3 = (PS_Al3) OSCL_DEFAULT_MALLOC(sizeof(S_Al3));
+        oscl_memcpy(pParameter->adaptationLayerType.al3, adaptation_layer->al3, sizeof(S_Al3));
+        pParameter->adaptationLayerType.al3->sendBufferSize = 0;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability: GetLcnParams controlFieldOctets(%d),  sendBufferSize(%d)\n",
+                         pParameter->adaptationLayerType.al3->controlFieldOctets,
+                         pParameter->adaptationLayerType.al3->sendBufferSize));
+    }
+    return pParameter;
+}
+
+PVMFStatus TSC_capability::ValidateIncomingH223LcnParams(PS_H223LogicalChannelParameters h223params,
+        TPVDirection dir)
+{
+    OSCL_UNUSED_ARG(dir);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::ValidateIncomingH223LcnParams(%x),dir(%d)",
+                     h223params, dir));
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::ValidateIncomingH223LcnParams AL index(%d)",
+                     h223params->adaptationLayerType.index));
+    if (h223params->adaptationLayerType.index == 0 ||
+            h223params->adaptationLayerType.index > 5)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability::ValidateIncomingH223LcnParams invalid index(%d)",
+                         h223params->adaptationLayerType.index));
+        return PVMFErrNotSupported;
+    }
+
+    if (h223params->adaptationLayerType.index == 5)
+    {
+        PS_Al3 al3 = h223params->adaptationLayerType.al3;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability::ValidateIncomingH223LcnParams al3->controlFieldOctets(%d),al3->sendBufferSize(%d)", al3->controlFieldOctets, al3->sendBufferSize));
+        if (al3->controlFieldOctets > 2)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                            (0, "TSC_capability::ValidateIncomingH223LcnParams ERROR  - Invalid al3->controlFieldOctets(%d)", al3->controlFieldOctets));
+            return PVMFFailure;
+        }
+    }
+    return PVMFSuccess;
+}
+
+PVMFStatus TSC_capability::ValidateForwardReverseParams(PS_ForwardReverseParam forRevParams,
+        TPVDirection dir)
+{
+    if (forRevParams == NULL || dir == PV_DIRECTION_NONE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability::ValidateForwardReverseParams forRevParams==NULL || dir==PV_DIRECTION_NONE"));
+        return PVMFFailure;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::ValidateForwardReverseParams params(%x), option_of_reverse(%d)",
+                     forRevParams,
+                     forRevParams->option_of_reverseLogicalChannelParameters));
+    if (dir&INCOMING)
+    {
+        PS_ForwardLogicalChannelParameters forwardParams = &forRevParams->forwardLogicalChannelParameters;
+        /* validate datatype */
+        PVMFStatus datatypeCheck = ValidateIncomingDataType(true, &forwardParams->dataType);
+        if (datatypeCheck != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                            (0, "TSC_capability::ValidateForwardReverseParams ERROR  - forward datatype not supported."));
+            return datatypeCheck;
+        }
+        /* Validate lcp */
+        if (forwardParams->multiplexParameters.index != 1)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ValidateForwardReverseParams Invalid index for forward multipleParameters(%d)", forwardParams->multiplexParameters.index));
+            return PVMFFailure;
+        }
+        if (forwardParams->multiplexParameters.h223LogicalChannelParameters == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ValidateForwardReverseParams forward multipleParameters==NULL"));
+            return PVMFFailure;
+        }
+        PVMFStatus h223paramsCheck = ValidateIncomingH223LcnParams(forwardParams->multiplexParameters.h223LogicalChannelParameters, INCOMING);
+        if (h223paramsCheck != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                            (0, "TSC_capability::ValidateForwardReverseParams ERROR  - forward h223params not supported."));
+            return h223paramsCheck;
+        }
+    }
+
+    if (dir&OUTGOING)
+    {
+        if (!forRevParams->option_of_reverseLogicalChannelParameters)
+            return PVMFSuccess;
+        PS_ReverseLogicalChannelParameters reverseParams = &forRevParams->reverseLogicalChannelParameters;
+        /* validate datatype */
+        PVMFStatus datatypeCheck = ValidateIncomingDataType(false, &reverseParams->dataType);
+        if (datatypeCheck != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                            (0, "TSC_capability::ValidateForwardReverseParams ERROR  - reverse datatype not supported."));
+            return datatypeCheck;
+        }
+        if (!reverseParams->option_of_rlcMultiplexParameters)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ValidateForwardReverseParams no option for reverse multipleParameters"));
+            return PVMFFailure;
+        }
+        /* Validate lcp */
+        if (reverseParams->rlcMultiplexParameters.index != 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ValidateForwardReverseParams Invalid index for reverse multipleParameters(%d)", reverseParams->rlcMultiplexParameters.index));
+            return PVMFFailure;
+        }
+        if (reverseParams->rlcMultiplexParameters.h223LogicalChannelParameters == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::ValidateForwardReverseParams reverse multipleParameters==NULL"));
+            return PVMFFailure;
+        }
+        PVMFStatus h223paramsCheck = ValidateIncomingH223LcnParams(reverseParams->rlcMultiplexParameters.h223LogicalChannelParameters, OUTGOING);
+        if (h223paramsCheck != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                            (0, "TSC_capability::ValidateForwardReverseParams ERROR  - reverse h223params not supported."));
+            return h223paramsCheck;
+        }
+    }
+    return PVMFSuccess;
+}
+
+bool TSC_capability::VerifyReverseParameters(PS_ForwardReverseParam forRevParams,
+        TSCObserver* aObserver,
+        PVMFStatus& status)
+{
+    OSCL_UNUSED_ARG(aObserver);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::VerifyReverseParameters"));
+    status = PVMFSuccess;
+    status = ValidateForwardReverseParams(forRevParams, OUTGOING);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability:VerifyReverseParameters - Reverse params invalid"));
+        return true;
+    }
+
+    PVCodecType_t codec = GetCodecType(&forRevParams->reverseLogicalChannelParameters.dataType);
+    GetMediaType(codec);
+    if (!CodecRequiresFsi(codec))
+    {
+        status = PVMFSuccess;
+        return true;
+    }
+    status = PVMFFailure;
+    return false;
+}
+
+CPvtTerminalCapability* TSC_capability::GetRemoteCapability()
+{
+    return iRemoteCapability;
+}
+
+uint32 TSC_capability::GetMaxBitrateForOutgoingChannel(PVCodecType_t codecType)
+{
+    uint32 bitrate = 0;
+    /* lookup the bitrate from remote capabilities */
+    for (uint16 i = 0; i < iRemoteCapability->GetNumCapabilityItems();i++)
+    {
+        if (iRemoteCapability->GetCapabilityItem(i)->GetFormatType() == PVCodecTypeToPVMFFormatType(codecType))
+            bitrate = iRemoteCapability->GetCapabilityItem(i)->GetBitrate();
+    }
+    return bitrate;
+}
+
+PS_DataType
+TSC_capability::GetDataType(PVCodecType_t codecType,
+                            uint32 bitrate,
+                            const uint8* dci,
+                            uint16 dci_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::GetDataType - codecType(%d),bitrate(%d),dci(%x),dci_len(%d)",
+                     codecType, bitrate, dci, dci_len));
+    bitrate /= 100;
+    PS_DataType pDataType = (PS_DataType) OSCL_DEFAULT_MALLOC(sizeof(S_DataType));
+    oscl_memset(pDataType , 0, sizeof(S_DataType));
+    PS_GenericCapability	genericCap = NULL;
+
+    switch (codecType)
+    {
+        case PV_AUD_TYPE_G723: /* WWURM: change H324_AUDIO_RECV to H324_AUDIO_SEND */
+            /* (LCN=2): G723 Audio */
+            PS_G7231		g723Cap;
+            pDataType->index = 3;
+            /* NEW245: allocate memory for audioData*/
+            pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            pDataType->audioData->index = 8;
+            /* NEW245: allocate memory for g7231 */
+            pDataType->audioData->g7231 =
+                g723Cap =
+                    (PS_G7231) OSCL_DEFAULT_MALLOC(sizeof(S_G7231));
+            g723Cap->maxAl_sduAudioFrames = 1;
+            g723Cap->silenceSuppression = false;
+            break;
+        case PV_AUD_TYPE_GSM:
+            /* (LCN=2): Amr Audio */
+            pDataType->index = 3;
+            /* NEW245: allocate memory for audioData */
+            pDataType->audioData = (PS_AudioCapability) OSCL_DEFAULT_MALLOC(sizeof(S_AudioCapability));
+            pDataType->audioData->index = 20;
+            /* NEW245: allocate memory for genericAudioCapability */
+            pDataType->audioData->genericAudioCapability =
+                genericCap =
+                    (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            genericCap->capabilityIdentifier.index = 0;
+            /* NEW245: allocate memory for standard */
+            genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            genericCap->capabilityIdentifier.standard->size = 7;
+            genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8));
+            genericCap->capabilityIdentifier.standard->data[0] = 0x00;
+            genericCap->capabilityIdentifier.standard->data[1] = 0x08;
+            genericCap->capabilityIdentifier.standard->data[2] = 0x81;
+            genericCap->capabilityIdentifier.standard->data[3] = 0x75;
+            genericCap->capabilityIdentifier.standard->data[4] = 0x01;
+            genericCap->capabilityIdentifier.standard->data[5] = 0x01;
+            genericCap->capabilityIdentifier.standard->data[6] = 0x01;
+            genericCap->option_of_maxBitRate = true;
+            genericCap->maxBitRate = bitrate;
+            genericCap->option_of_collapsing = true;
+            genericCap->size_of_collapsing = 1;
+            genericCap->collapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(1 * sizeof(S_GenericParameter));
+            genericCap->collapsing[0].parameterIdentifier.index = 0;
+            genericCap->collapsing[0].parameterIdentifier.standard = 0;
+            genericCap->collapsing[0].parameterValue.index = 2;
+            genericCap->collapsing[0].parameterValue.unsignedMin = 1;
+            genericCap->collapsing[0].option_of_supersedes = false;
+
+            genericCap->option_of_nonCollapsing = false;
+            genericCap->option_of_nonCollapsingRaw = false;
+            genericCap->option_of_transport = false;
+            break;
+        case PV_VID_TYPE_H263:
+            /* (LCN=3): H263 Video */
+            PS_H263VideoCapability	h263VideoCap;
+            pDataType->index = 2;
+            /* NEW245: allocate memory for videoData */
+            pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            oscl_memset(pDataType->videoData, 0, sizeof(S_VideoCapability));
+            pDataType->videoData->index = 3;
+            /* NEW245: allocate memory for h263VideoCapability */
+            pDataType->videoData->h263VideoCapability =
+                h263VideoCap =
+                    (PS_H263VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoCapability));
+            oscl_memset(pDataType->videoData->h263VideoCapability, 0, sizeof(S_H263VideoCapability));
+
+            if (iTcsIn_H263_sqcifMPI && IsResolutionSupported(PVMF_RESOLUTION_SQCIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_sqcifMPI = true;
+                h263VideoCap->sqcifMPI = (uint8)iTcsIn_H263_sqcifMPI;
+            }
+
+            if (iTcsIn_H263_qcifMPI && IsResolutionSupported(PVMF_RESOLUTION_QCIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_qcifMPI = true;
+                h263VideoCap->qcifMPI = 2;
+            }
+
+            if (iTcsIn_H263_cifMPI && IsResolutionSupported(PVMF_RESOLUTION_CIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_cifMPI = true;
+                h263VideoCap->cifMPI = (uint8)iTcsIn_H263_cifMPI;
+            }
+
+            if (iTcsIn_H263_4cifMPI && IsResolutionSupported(PVMF_RESOLUTION_4CIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_cif4MPI = true;
+                h263VideoCap->cif4MPI = (uint8)iTcsIn_H263_4cifMPI;
+            }
+
+            if (iTcsIn_H263_16cifMPI && IsResolutionSupported(PVMF_RESOLUTION_16CIF, iResolutionsTx))
+            {
+                h263VideoCap->option_of_cif16MPI = true;
+                h263VideoCap->cif16MPI = (uint8)iTcsIn_H263_16cifMPI;
+            }
+
+            h263VideoCap->option_of_cifMPI = false;
+            h263VideoCap->option_of_cif4MPI = false;
+            h263VideoCap->option_of_cif16MPI = false;
+            h263VideoCap->maxBitRate = bitrate;
+            h263VideoCap->unrestrictedVector = false;
+            h263VideoCap->arithmeticCoding = false;
+            h263VideoCap->advancedPrediction = false;
+            h263VideoCap->pbFrames = false;
+            h263VideoCap->temporalSpatialTradeOffCapability = ON;
+            h263VideoCap->option_of_hrd_B = false;
+            h263VideoCap->option_of_bppMaxKb = false;
+            h263VideoCap->option_of_slowSqcifMPI = false;
+            h263VideoCap->option_of_slowQcifMPI = false;
+            h263VideoCap->option_of_slowCifMPI = false;
+            h263VideoCap->option_of_slowCif4MPI = false;
+            h263VideoCap->option_of_slowCif16MPI = false;
+            h263VideoCap->errorCompensation = false;
+            h263VideoCap->option_of_enhancementLayerInfo = false;
+            h263VideoCap->option_of_h263Options = false;
+            break;
+        case PV_VID_TYPE_MPEG4:
+        {
+            /* (LCN=3): MPEG4 Video */
+            pDataType->index = 2;
+            /* NEW245: allocate memory for videoData */
+            pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            pDataType->videoData->index = 5;
+            /* NEW245: allocate memory for genericVideoCapability */
+            pDataType->videoData->genericVideoCapability =
+                genericCap =
+                    (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            genericCap->capabilityIdentifier.index = 0;
+            /* NEW245: allocate memory for standard */
+            genericCap->capabilityIdentifier.standard = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+            genericCap->capabilityIdentifier.standard->size = 7;
+            genericCap->capabilityIdentifier.standard->data = (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8));
+            genericCap->capabilityIdentifier.standard->data[0] = 0x00;
+            genericCap->capabilityIdentifier.standard->data[1] = 0x08;
+            genericCap->capabilityIdentifier.standard->data[2] = 0x81;
+            genericCap->capabilityIdentifier.standard->data[3] = 0x75;
+            genericCap->capabilityIdentifier.standard->data[4] = 0x01;
+            genericCap->capabilityIdentifier.standard->data[5] = 0x00;
+            genericCap->capabilityIdentifier.standard->data[6] = 0x00;
+            genericCap->option_of_maxBitRate = true;
+            genericCap->maxBitRate = bitrate;
+            genericCap->option_of_collapsing = false;
+            genericCap->option_of_nonCollapsing = true;
+            genericCap->size_of_nonCollapsing = (uint16)((dci && dci_len) ? 3 : 2);
+            genericCap->nonCollapsing = (PS_GenericParameter) OSCL_DEFAULT_MALLOC(3 * sizeof(S_GenericParameter));
+            genericCap->nonCollapsing[0].parameterIdentifier.index = 0;
+            genericCap->nonCollapsing[0].parameterIdentifier.standard = 0;
+            genericCap->nonCollapsing[0].parameterValue.index = 3;
+            // Value on next line changed to 8 (RAN - PandL)
+            genericCap->nonCollapsing[0].parameterValue.unsignedMax = 8;	/* simple profile level 0 */
+            genericCap->nonCollapsing[0].option_of_supersedes = false;
+
+            genericCap->nonCollapsing[1].parameterIdentifier.index = 0;
+            genericCap->nonCollapsing[1].parameterIdentifier.standard = 1;
+            genericCap->nonCollapsing[1].parameterValue.index = 3;
+            genericCap->nonCollapsing[1].parameterValue.unsignedMax = 1;	/* simple profile object */
+            genericCap->nonCollapsing[1].option_of_supersedes = false;
+
+            if (dci && dci_len)
+            {
+                /* WWU_VOAL2: BLCMP4 temporally off */
+                genericCap->nonCollapsing[2].parameterIdentifier.index = 0;
+                genericCap->nonCollapsing[2].parameterIdentifier.standard = 2;
+                genericCap->nonCollapsing[2].parameterValue.index = 6;
+                /* NEW245: allocate memory for octetString */
+                genericCap->nonCollapsing[2].parameterValue.octetString =
+                    (PS_OCTETSTRING) OSCL_DEFAULT_MALLOC(sizeof(S_OCTETSTRING));
+                genericCap->nonCollapsing[2].parameterValue.octetString->data =
+                    (uint8*)OSCL_DEFAULT_MALLOC(dci_len);
+                oscl_memcpy(genericCap->nonCollapsing[2].parameterValue.octetString->data,
+                            dci, dci_len);
+                genericCap->nonCollapsing[2].parameterValue.octetString->size = dci_len;
+                genericCap->nonCollapsing[2].option_of_supersedes = false;
+            }
+
+            genericCap->option_of_nonCollapsingRaw = false;
+            genericCap->option_of_transport = false;
+        }
+        break;
+
+#if 0
+        case PV_VID_TYPE_H264:
+        {
+            VideoCodecCapabilityInfo h264_info;
+            h264_info.codec = PV_VID_TYPE_H264;
+            h264_info.dir = OUTGOING;
+            h264_info.codec_specific_info_len = dci_len;
+            if (dci_len)
+            {
+                h264_info.codec_specific_info = (uint8*)OSCL_DEFAULT_MALLOC(MAX_CONFIG_INFO_SIZE);
+                oscl_memcpy(h264_info.codec_specific_info, dci, dci_len);
+            }
+            pDataType->index = 2;
+            pDataType->videoData = (PS_VideoCapability) OSCL_DEFAULT_MALLOC(sizeof(S_VideoCapability));
+            oscl_memset(pDataType->videoData, 0, sizeof(S_VideoCapability));
+            pDataType->videoData->index = 5;
+            pDataType->videoData->genericVideoCapability =
+                (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+            oscl_memset(pDataType->videoData->genericVideoCapability, 0, sizeof(S_GenericCapability));
+            FillH264Capability(h264_info, pDataType->videoData->genericVideoCapability, TRUE);
+        }
+        break;
+#endif
+        default:
+            /* NULL data type */
+            pDataType->index = 1;
+    }
+    return pDataType;
+}
+
+uint16
+TSC_capability::GetSupportedCodecCapabilityInfo(TPVDirection dir,
+        PV2WayMediaType mediaType,
+        Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& codec_info_list)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                    (0, "TSC_capability::GetSupportedCodecCapabilityInfo dir=%d, mediaType=%d",
+                     dir, mediaType));
+    Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* channel_config =
+        iTSCcomponent->GetChannelConfig(dir);
+    if (channel_config == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_capability::GetSupportedCodecCapabilityInfo channel config for this direction == NULL"));
+        return 0;
+    }
+    for (unsigned n = 0;n < channel_config->size();n++)
+    {
+        PV2WayMediaType channelMediaType = (*channel_config)[n].GetMediaType();
+        if (channelMediaType != mediaType)
+        {
+            continue;
+        }
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* formats = (*channel_config)[n].GetCodecs();
+        if (!formats)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_capability::GetSupportedCodecCapabilityInfo No formats specified for format type(%d)", channelMediaType));
+            continue;
+        }
+        for (unsigned m = 0;m < formats->size();m++)
+        {
+            CodecCapabilityInfo* info = NULL;
+            PVCodecType_t codec_type = PVMFFormatTypeToPVCodecType((*formats)[m].format);
+            TPVDirection dir = (*formats)[m].dir;
+            if (GetMediaType(codec_type) == PV_VIDEO)
+            {
+                info = new VideoCodecCapabilityInfo;
+                ((VideoCodecCapabilityInfo*)info)->resolutions = (dir == OUTGOING) ? iResolutionsTx : iResolutionsRx;
+            }
+            else
+            {
+                info = new CodecCapabilityInfo;
+            }
+            info->codec = codec_type;
+            info->dir = dir;
+            codec_info_list.push_back(info);
+        }
+    }
+    return (uint16)codec_info_list.size();
+}
+
+bool
+TSC_capability::HasSymmetryConstraint(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>& codec_list)
+{
+    for (unsigned i = 0;i < codec_list.size();i++)
+    {
+        if (codec_list[i]->dir == PV_DIRECTION_BOTH)
+            return true;
+    }
+    return false;
+}
+
+CodecCapabilityInfo*
+TSC_capability::SelectOutgoingCodec(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* remote_list,
+                                    Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* local_list)
+{
+    Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* list1 = remote_list;
+    Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator>* list2 = local_list;
+    if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == MASTER)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_capability::SelectOutgoingCodec Selecting our preferred codec for mediaType since we are master"));
+        list1 = local_list;
+        list2 = remote_list;
+    }
+    for (unsigned i = 0;i < (*list1).size();i++)
+    {
+        CodecCapabilityInfo* supported_codec_info =::IsSupported((*list1)[i], *list2);
+        if (supported_codec_info == NULL)
+            continue;
+        // check if we support transmitting this codec
+        FormatCapabilityInfo capability_info;
+        if (iTSCcomponent->IsSupported(OUTGOING,
+                                       supported_codec_info->codec, capability_info))
+        {
+            return (list1 == remote_list) ? (*list1)[i] : supported_codec_info;
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_capability::SelectOutgoingCodec Codec=%d not supported in outgoing direction",
+                             supported_codec_info->codec));
+        }
+    }
+    return NULL;
+}
+
+CodecCapabilityInfo*
+TSC_capability::SelectOutgoingCodec(Oscl_Vector < CodecCapabilityInfo*,
+                                    OsclMemAllocator > * remote_list)
+{
+    for (unsigned i = 0;i < (*remote_list).size();i++)
+    {
+        // check if this includes receive capability
+        if ((*remote_list)[i]->dir == OUTGOING)
+        {
+            continue;
+        }
+        // check if we support transmitting this codec
+        FormatCapabilityInfo capability_info;
+        if (iTSCcomponent->IsSupported(OUTGOING,
+                                       (*remote_list)[i]->codec, capability_info))
+        {
+            return (*remote_list)[i];
+        }
+    }
+    return NULL;
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_ce.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_ce.cpp
new file mode 100644
index 0000000..2d315ed
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_ce.cpp
@@ -0,0 +1,333 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_ce.c                                          */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include "tscmain.h"
+#include "tsc_sub.h"     /* Sub Routine Information Header                */
+#include "tsc_constants.h"
+#include "tsc_statemanager.h"
+#include "tsc_capability.h"
+#include "tsc_component.h"
+
+#define PV2WAY_DEFAULT_USER_INPUT_CAPABILITY_INDEX 2 /* Index for IA5 string */
+
+//////////////////////////////////////////////////////////////////////////
+// Start the CE process by sending this terminals capabilites to the peer terminal
+//////////////////////////////////////////////////////////////////////////
+void TSC_324m::CEStart(void)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "TSC_324m: CEStart\n"));
+    if (iCeRetries <= 0)
+    {
+        return;
+    }
+    if (iTSCcomponent->CEStart())
+    {
+        iCeRetries--;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////
+// CE User - Transfer.Indication primitive received from H.245
+////////////////////////////////////////////////////////////////////////
+void TSC_324m::CETransferIndication(OsclSharedPtr<S_TerminalCapabilitySet> tcs)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: CE transfer indication received.\n"));
+
+    // Cancel timers for TCS receive
+    iTimer->Cancel(PV_TSC_TCS_RECEIVE_TIMER_ID);
+    iH223->EnableStuffing(false);
+
+    Tsc324mNodeCommand* cmd = iTSCcomponent->GetCommand();
+    if (cmd)
+    {
+        iCmdQueue.AddL(*cmd);
+        RunIfNotReady();
+    }
+
+
+    ////////////////////////
+    // State = Call Setup
+    ////////////////////////
+    if (iTerminalStatus == PhaseD_CSUP)
+    {
+        // TRANSFER.response(CE) Primitive Send
+        if (Ce) Ce->TransferResponse();
+
+        ExtractTcsParameters(tcs);
+
+        iTSCcomponent->CETransferIndication(tcs, iTerminalStatus);
+
+        if (iTSCcomponent->GetVideoLayer() == 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::CETransferIndication - Failed to negotiate video layer.\n"));
+            iCeRetries = iN100;
+            iConnectFailReason = EPVT_FailedToNegotiate;
+            SessionClose_CSUP();
+        }
+        if (iTSCstatemanager.ReadState(TSC_CE_RECEIVE) != COMPLETE)
+        {
+            iTSCstatemanager.WriteState(TSC_CE_RECEIVE, COMPLETE);
+
+            if ((iTSCstatemanager.ReadState(TSC_MSD) == COMPLETE))
+            {
+                int leave_status = 0;
+                OSCL_TRY(leave_status, TcsMsdComplete());
+                OSCL_FIRST_CATCH_ANY(leave_status, void());
+                if (leave_status != 0)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                    (0, "TSC_324m::CETransferIndication - Memory Allocation Failed."));
+                    SignalCsupComplete(PVMFErrNoMemory);
+                    return;
+                }
+            }
+        }
+    }
+    //////////////////////////////////
+    // State = Ongoing Communication
+    //////////////////////////////////
+    else if (iTerminalStatus == PhaseE_Comm)
+    {
+        iTSCcomponent->CETransferIndication(tcs, iTerminalStatus);
+        if (Ce) Ce->TransferResponse();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::CETransferIndication Error - invalid state(%d)", iTerminalStatus));
+    }
+}
+
+////////////////////////////////////////////////////////////////////////
+// CE User - Transfer.Confirm primitive received from H.245
+////////////////////////////////////////////////////////////////////////
+void TSC_324m::CETransferConfirm()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::CETransferConfirm Capability Exchange Send...Complete."));
+    ////////////////////////
+    // State = Call Setup
+    ////////////////////////
+    if (iTerminalStatus == PhaseD_CSUP || iTerminalStatus == PhaseE_Comm)
+    {
+        iTSCstatemanager.WriteState(TSC_CE_SEND, COMPLETE);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::CETransferConfirm Error - Invalid state(%d)", iTerminalStatus));
+    }
+    iCeRetries = iN100; /* Num CE retries left */
+}
+
+////////////////////////////////////////////////////////////////////////
+// CE User - Reject.Indication primitive received from H.245
+////////////////////////////////////////////////////////////////////////
+void TSC_324m::CERejectIndication(CESource source, CECause cause, CEDirection direction)
+{
+    OSCL_UNUSED_ARG(cause);
+
+    /* WWUAPI: four scenarios can cause this function being called
+    	1. INCOMING SE gets TCS again while in AWAITING RESPONSE state
+    	   We send out CE RPS as soon as we receive a TCS.  It means the other temrinal
+    	   is a whacky terminal sending out successive TCS's.  Maybe we just use the most
+    	   recent TCS ?
+    	2. OUTGOING SE gets REJECT while in AWAITING RESPONSE state
+    	   End Session and reset.
+    	3. TIMEOUT for OUTGOING SE
+    	   End Session and reset if we are in PhaseD_CSUP
+    	4. INCOMING SE gets RELEASE while in AWAITING RESPONSE
+    	   We took too much time to send a response and remote SE timed out.
+    	   End Session and reset
+       We need a fat brain in the future to handle all these unusual cases.
+       Here we just do nothing.
+    */
+
+    ////////////////////////
+    // State = Call Setup
+    ////////////////////////
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: CE Reject Indication received."));
+
+    if (iTerminalStatus == PhaseD_CSUP || iTerminalStatus == PhaseE_Comm)
+    {
+        if (direction == CE_OUTGOING)
+        {
+            if (source == CE_USER)  /* Reject */
+            {
+                iCeRetries = iN100;
+                iConnectFailReason = EPVT_ErrorRemoteRejected;
+                SessionClose_CSUP();
+            }
+            else  /* Caused by PROTOCOL, most likely due to timeouts */
+            {
+                if (iCeRetries)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "TSC_324m: Starting CE Send.\n"));
+                    CEStart();		/* INITIATE CE-SEND */
+                }
+                else  /* Retried enough. Call setup failed */
+                {
+                    iCeRetries = iN100;
+                    iConnectFailReason = EPVT_Timeout;
+                    SessionClose_CSUP();
+                }
+            }
+        }
+        else  /* INCOMING */
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: Capability Exchange(I)...Release received.\n"));
+            SessionClose_CSUP();
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::CERejectIndication Error - Invalid state(%d)", iTerminalStatus));
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+// ExtractTcsParameters()						(RAN-32K)
+//
+// This routine takes the incoming TerminalCapabilitySet
+//   and extracts the following useful parameters:
+//      {h263_qcifMPI, h263_maxBitRate, mpeg4_maxBitRate}
+// The parameters are stored in globals and may be sent
+//   later to the application.
+////////////////////////////////////////////////////////////////////////////
+void TSC_324m::ExtractTcsParameters(PS_TerminalCapabilitySet pTcs)
+{
+    uint32 i;
+    PS_CapabilityTableEntry pCapEntry = NULL;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::ExtractTcsParameters"));
+
+    iTSCcapability.ResetCapability();
+    Oscl_Vector<CPvtMediaCapability*, OsclMemAllocator> capabilityItems;
+    int userInputCapabilities = 0;//1<<PV2WAY_DEFAULT_USER_INPUT_CAPABILITY_INDEX;
+    struct _UserInputCapability *userInputCapability = NULL;
+
+    iTSCcomponent->ExtractTcsParameters(pTcs);
+    if (pTcs->option_of_multiplexCapability)
+    {
+        PS_MultiplexCapability muxcaps = &pTcs->multiplexCapability;
+        if (muxcaps->index == 2)
+        {
+            PS_H223Capability h223caps = muxcaps->h223Capability;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::ExtractTcsParameters maximumAl2SDUSize=%d,maximumAl3SDUSize=%d",
+                             h223caps->maximumAl2SDUSize, h223caps->maximumAl3SDUSize));
+            iH223->SetSduSize(OUTGOING, h223caps->maximumAl2SDUSize, E_EP_MEDIUM);
+            iH223->SetSduSize(OUTGOING, h223caps->maximumAl3SDUSize, E_EP_HIGH);
+            if ((h223caps->option_of_nsrpSupport == ON) && (h223caps->nsrpSupport == ON))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m: Remote video caps Option of NSRP support is ON\n"));
+
+                // switch to NSRP if mux level == 0.  If level was 1 or 2, we would have switched after level setup
+                if (iH223->GetMuxLevel() == 0)
+                {
+                    iSrp->UseNSRP(true);
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m: Remote video caps Option of NSRP support is OFF\n"));
+            }
+
+            if (h223caps->option_of_mobileOperationTransmitCapability)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m: Remote video caps Option of Mobile Transmit Capability is ON\n"));
+                struct _MobileOperationTransmitCapability* mobile_caps = &h223caps->mobileOperationTransmitCapability;
+                if (iTransmitCaps)
+                    OSCL_DEFAULT_FREE(iTransmitCaps);
+                iTransmitCaps = (struct _MobileOperationTransmitCapability*)OSCL_DEFAULT_MALLOC(sizeof(struct _MobileOperationTransmitCapability));
+                oscl_memcpy(iTransmitCaps, mobile_caps, sizeof(struct _MobileOperationTransmitCapability));
+            }
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::ExtractTcsParameters option_of_maxMUXPDUSizeCapability=%d",
+                             h223caps->option_of_maxMUXPDUSizeCapability));
+            if (h223caps->option_of_maxMUXPDUSizeCapability)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m: Remote maxMuxPduCapability - %d\n",
+                                 h223caps->maxMUXPDUSizeCapability));
+                iMaxMuxPduCapabilityR = h223caps->maxMUXPDUSizeCapability ? true : false;
+                unsigned size = iRequestMaxMuxPduSize;
+                if (iH223->GetMuxLevel() == H223_LEVEL2)
+                    size = size > H223_MAX_MUX_PDU_SIZE_LEVEL2 ? H223_MAX_MUX_PDU_SIZE_LEVEL2 : size;
+                if (iMaxMuxPduCapabilityR && size)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "TSC_324m::ExtractTcsParameters Requesting max mux pdu size (%d) from remote",
+                                     size));
+                    RequestMaxMuxPduSize(size);
+                }
+            }
+        }
+    }
+
+    if (pTcs->option_of_capabilityTable)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: Remote video caps Option of Capability Table is ON, size(%d)\n",
+                         pTcs->size_of_capabilityTable));
+        for (i = 0;i < pTcs->size_of_capabilityTable;++i)
+        {
+            pCapEntry = pTcs->capabilityTable + i;
+            if (pCapEntry->option_of_capability)
+            {
+                iTSCcapability.ParseTcsCapabilities(pCapEntry->capability, capabilityItems, userInputCapabilities, userInputCapability);
+            }
+
+        }
+    }
+    iTSCcapability.CreateNewCapability(capabilityItems);
+    userInputCapabilities = userInputCapabilities ?
+                            userInputCapabilities : 1 << PV2WAY_DEFAULT_USER_INPUT_CAPABILITY_INDEX;
+    if (iTSC_324mObserver)
+    {
+        iTSC_324mObserver->UserInputCapability(userInputCapabilities);
+    }
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_channelcontrol.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_channelcontrol.cpp
new file mode 100644
index 0000000..91bd565
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_channelcontrol.cpp
@@ -0,0 +1,158 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "tsc_statemanager.h"
+#include "tsc_lc.h"
+#include "tsc_blc.h"
+#include "tsc_clc.h"
+#include "tsc_constants.h"
+#include "tsc_mt.h"
+#include "tsc_component.h"
+#include "tsc_capability.h"
+#include "tsc_channelcontrol.h"
+
+
+
+TSC_channelcontrol::TSC_channelcontrol(OlcList& aOlcs,
+                                       TSC_statemanager& aTSCStateManager,
+                                       TSC_blc& aTSCblc,
+                                       TSC_mt& aTSCmt,
+                                       TSC_lc& aTSClc,
+                                       TSC_capability& aTSCcapability,
+                                       TSC_clc& aTSCclc,
+                                       TSC_component& aTSCcomponent) :
+        iOlcs(aOlcs),
+        iH223(NULL),
+        iTSCstatemanager(aTSCStateManager),
+        iTSCblc(aTSCblc),
+        iTSCmt(aTSCmt),
+        iTSClc(aTSClc),
+        iTSCcapability(aTSCcapability),
+        iTSCclc(aTSCclc),
+        iTSCcomponent(aTSCcomponent)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+};
+
+
+
+
+LogicalChannelInfo* TSC_channelcontrol::GetLogicalChannelInfo(PVMFPortInterface& port)
+{
+    if (port.GetPortTag() == PV_MULTIPLEXED)
+    {
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+    return OSCL_STATIC_CAST(LogicalChannelInfo*, &port);
+}
+
+TPVStatusCode TSC_channelcontrol::RequestIncomingChannelClose(TPVChannelId lcn)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol: Requesting incoming channel close (%d).\n", lcn));
+
+    /* Initiate RequestChannelClose Command */
+    iTSCclc.ClcClsReq(lcn);
+
+    return EPVT_Pending;
+}
+
+
+bool TSC_channelcontrol::IsEstablishedLogicalChannel(TPVDirection aDir, TPVChannelId aChannelId)
+{
+    OlcParam* param = iOlcs.FindOlcGivenChannel(aDir, aChannelId);
+    if (param)
+    {
+        if (param->GetState() == OLC_PENDING ||
+                param->GetState() == OLC_ESTABLISHED)
+        {
+            return true;
+        }
+        return false;
+    }
+
+    OlcList::iterator it = iOlcs.begin();
+    while (it != iOlcs.end())
+    {
+        OlcList::value_type& val = (*it++);
+        OlcParam* olc = val.second;
+        if (olc->GetDirection() == REVERSE_DIR(aDir) &&
+                olc->GetReverseParams() &&
+                olc->GetReverseParams()->GetChannelId() == aChannelId)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+void TSC_channelcontrol::ReceivedFormatSpecificInfo(TPVChannelId channel_id,
+        uint8* fsi,
+        uint32 fsi_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::ReceivedFormatSpecificInfo lcn=%d, len=%d",
+                     channel_id, fsi_len));
+    OlcParam* param = iOlcs.FindOlcGivenChannel(OUTGOING, channel_id);
+    if (param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_channelcontrol::ReceivedFormatSpecificInfo - Failed to lookup channel"));
+        return;
+    }
+    if (param->GetState() != OLC_PENDING)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_channelcontrol::ReceivedFormatSpecificInfo - Channel not in pending state.  Not sending OLC."));
+        return;
+    }
+    PVMFStatus status = SetFormatSpecificInfo(param->GetForwardParams()->GetDataType(),
+                        fsi, fsi_len);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_channelcontrol::ReceivedFormatSpecificInfo - Failed to set FormatSpecificInfo, status=%d.",
+                         status));
+        return;
+    }
+    if (param->GetDirectionality() == EPVT_BI_DIRECTIONAL)
+    {
+        // Check FSI in reverse parameters.  Set it to fsi if its different from filler fsi
+        uint8* rvs_fsi = NULL;
+        unsigned rvs_fsi_len =
+            ::GetFormatSpecificInfo(param->GetReverseParams()->GetDataType(),
+                                    rvs_fsi);
+        if (IsFillerFsi(rvs_fsi, rvs_fsi_len))
+        {
+            SetFormatSpecificInfo(param->GetReverseParams()->GetDataType(),
+                                  fsi, fsi_len);
+        }
+
+        iTSCblc.BlcEtbReq(channel_id,
+                          param->GetForwardParams()->GetDataType(),
+                          param->GetForwardParams()->GetLcnParams(),
+                          param->GetReverseParams()->GetDataType(),
+                          param->GetReverseParams()->GetLcnParams());
+    }
+    else
+    {
+        iTSClc.LcEtbReq(channel_id,
+                        param->GetForwardParams()->GetDataType(),
+                        param->GetForwardParams()->GetLcnParams());
+    }
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_clc.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_clc.cpp
new file mode 100644
index 0000000..59aaf54
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_clc.cpp
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_clc.c                                         */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include	"tsc_clc.h"
+#include    "tsc_sub.h"     /* Sub Routine Information Header                */
+#include    "h245def.h"
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_ClcClsRps                                     */
+/*  function outline     : Tsc_ClcClsRps procedure                           */
+/*  function discription : Tsc_ClcClsRps( void )                             */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_clc::ClcClsReq(uint32 Lcn)
+{
+    S_ControlMsgHeader infHeader;
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Clc_Cls_Req, Lcn, 0, NULL, 0);
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_ClcClsRps                                     */
+/*  function outline     : Tsc_ClcClsRps procedure                           */
+/*  function discription : Tsc_ClcClsRps( uint32 )                             */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_clc::ClcClsRps(uint32 Lcn)
+{
+    S_ControlMsgHeader infHeader;
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Clc_Cls_Rps, Lcn, 0, NULL, 0);
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_ClcRjtReq                                     */
+/*  function outline     : Tsc_ClcRjtReq procedure                           */
+/*  function discription : Tsc_ClcRjtReq( void )                             */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_clc::ClcRjtReq(uint32 Lcn)
+{
+    S_ControlMsgHeader infHeader;
+    S_RccRejectCause parameter;
+
+    // REJECT.request primitive - Parameter[CAUSE]
+    parameter.index = 0;  // unspecified
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Clc_Rjt_Req, Lcn, 0,
+                    (uint8*)&parameter, sizeof(S_RccRejectCause));
+    iH245->DispatchControlMessage(&infHeader);
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_command.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_command.cpp
new file mode 100644
index 0000000..46aa5a5
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_command.cpp
@@ -0,0 +1,451 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_command.c                                     */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include    "oscl_base.h"
+#include    "h245def.h"
+#include    "tsc_sub.h"         /* Sub Routine Information Header            */
+#include	"tscmain.h"
+
+/*****************************************************************************/
+/*  function name        : Tsc_EndSessionCommand                             */
+/*  function outline     : Command (Change or EndSession) procedure          */
+/*  function discription : Tsc_EndSessionCommand( void )                     */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::EndSessionCommand()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::EndSessionCommand"));
+    S_ControlMsgHeader infHeader;
+    S_EndSessionCommand endSessionCommand;
+
+    oscl_memset(&endSessionCommand, 0, sizeof(S_EndSessionCommand));
+    endSessionCommand.index = 1;  // disconnect
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Cmd_Es,
+                    0,
+                    0,
+                    (uint8*)&endSessionCommand,
+                    sizeof(S_EndSessionCommand));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_CmdStcs                                       */
+/*  function outline     : Command (SendTerminalCapabilitySet) procedure     */
+/*  function discription : Tsc_CmdStcs( void )                               */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+OSCL_EXPORT_REF void TSC_324m::SendTerminalCapabilitySetCommand()
+{
+    S_ControlMsgHeader infHeader;
+    S_SendTerminalCapabilitySet sendTerminalCapabilitySet;
+
+    oscl_memset(&sendTerminalCapabilitySet, 0,
+                sizeof(S_SendTerminalCapabilitySet));
+
+    sendTerminalCapabilitySet.index = 1; // genericRequest
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Cmd_Stcs,
+                    0,
+                    0,
+                    (uint8*)&sendTerminalCapabilitySet,
+                    sizeof(S_SendTerminalCapabilitySet));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_CmdEcrpt                                      */
+/*  function outline     : Command (Encryption) procedure                    */
+/*  function discription : Tsc_CmdEcrpt( void )                              */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::CmdEcrpt()
+{
+    S_ControlMsgHeader infHeader;
+    S_EncryptionCommand encryptionCommand;
+
+    oscl_memset(&encryptionCommand, 0, sizeof(S_EncryptionCommand));
+
+    encryptionCommand.index = 1; // encryptionIVRequest
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Cmd_Ecrpt,
+                    0,
+                    0,
+                    (uint8*)&encryptionCommand,
+                    sizeof(S_EncryptionCommand));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_CmdFc                                         */
+/*  function outline     : Command (FlowControl) procedure                   */
+/*  function discription : Tsc_CmdFc( void )                                 */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::CmdFc()
+{
+    S_ControlMsgHeader infHeader;
+    S_FlowControlCommand flowControlCommand;
+
+    oscl_memset(&flowControlCommand, 0, sizeof(S_FlowControlCommand));
+
+    /// ORIGINAL CODEWORD : {wholeMultiplex, noRestriction}
+    //pFlowControlCommand->fccScope.index = 2;  // wholeMultiplex
+    //pFlowControlCommand->fccRestriction.index = 1; // noRestriction
+
+    // ALTERNATE CODEWORD: {logicalChannelNumber=3,maximumBitRate=1000}
+    flowControlCommand.fccScope.index = 0;  // logicalChannelNumber
+    flowControlCommand.fccScope.logicalChannelNumber = 3;
+    flowControlCommand.fccRestriction.index = 0; // maximumBitRate
+    flowControlCommand.fccRestriction.maximumBitRate = 1000;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Cmd_Fc,
+                    0,
+                    0,
+                    (uint8*)&flowControlCommand,
+                    sizeof(S_FlowControlCommand));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_CmdHmr                                  (RAN) */
+/*  function outline     : H223MultiplexReconfiguration procedure            */
+/*---------------------------------------------------------------------------*/
+/*  This routine initiates transmission of H223MultiplexReconfiguration.     */
+/*  The option argument is in [0...5] corresponding to:                      */
+/*    {toLevel0, toLevel1, toLevel2, toLevel2Hdr, dFlagStart, dFlagStop}     */
+/*****************************************************************************/
+void TSC_324m::CmdHmr(int32 option)
+{
+    S_ControlMsgHeader infHeader;
+    S_H223MultiplexReconfiguration hmr;
+    S_H223ModeChange modeChange;
+    S_H223AnnexADoubleFlag doubleFlag;
+
+    oscl_memset(&hmr, 0, sizeof(S_H223MultiplexReconfiguration));
+
+    if (option < 4)
+    {
+        hmr.index = 0; // h223ModeChange
+        hmr.h223ModeChange = &modeChange;
+        hmr.h223ModeChange->index = (uint16)option;
+    }
+    else
+    {
+        hmr.index = 1; // h223AnnexADoubleFlag
+        hmr.h223AnnexADoubleFlag = &doubleFlag;
+        hmr.h223AnnexADoubleFlag->index = (uint16)(option - 4);
+    }
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Cmd_Hmr,
+                    0,
+                    0,
+                    (uint8*)&hmr,
+                    sizeof(S_H223MultiplexReconfiguration));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_CmdMscl                                       */
+/*  function outline     : Command (MiscellaneousCommands) procedure         */
+/*  function discription : Tsc_CmdMscl( int32 )                                */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  NOTE: Input CommandIndex specifies one of the sample commands to transmit*/
+/*        Currently these are:                                               */
+/*          0 --> videoFastUpdatePicture for Lcn=3                           */
+/*          1 --> videoTemporalSpatialTradeOff=29 for Lcn=3                  */
+/*          2 --> maxH223MUXPDUsize=256 for Lcn=3                            */
+/*****************************************************************************/
+void TSC_324m::CmdMisc(TCmdMisc type, TPVChannelId channelId, uint32 param)
+{
+    S_ControlMsgHeader infHeader;
+    S_MiscellaneousCommand miscellaneousCommand;
+
+    oscl_memset(&miscellaneousCommand, 0, sizeof(S_MiscellaneousCommand));
+
+    switch (type)
+    {
+        case EVideoFastUpdatePicture:
+            miscellaneousCommand.logicalChannelNumber = (uint16)channelId;
+            miscellaneousCommand.mcType.index = 5; // videoFastUpdatePicture
+            break;
+        case EVideoTemporalSpatialTradeOff:
+            miscellaneousCommand.logicalChannelNumber = (uint16)channelId;
+            miscellaneousCommand.mcType.index = 7; // videoTemporalSpatialTradeOff
+            miscellaneousCommand.mcType.videoTemporalSpatialTradeOff = (uint8)param;
+            break;
+        case EMaxH223MUXPDUsize:
+            miscellaneousCommand.logicalChannelNumber = (uint16)channelId;
+            miscellaneousCommand.mcType.index = 11; // maxH223MUXPDUsize
+            miscellaneousCommand.mcType.maxH223MUXPDUsize = (uint16)param;
+            break;
+        default:
+            break;
+    }
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Cmd_Mscl,
+                    0,
+                    0,
+                    (uint8*)&miscellaneousCommand,
+                    sizeof(S_MiscellaneousCommand));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+/*****************************************************************************/
+/*  function name        : Tsc_RtdTrfReq                                     */
+/*  function outline     : Tsc_RtdTrfReq                                     */
+/*  function discription : Tsc_RtdTrfReq( void )                             */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::RtdTrfReq()
+{
+    S_ControlMsgHeader infHeader;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Rtd_Trf_Req,
+                    0, 0, NULL, 0);
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    return;
+}
+
+OSCL_EXPORT_REF void TSC_324m::SendModeRequestCommand()
+{
+    S_ControlMsgHeader infHeader;
+    PS_RequestMode          pParameter;
+    PS_ModeDescription      pModeDescription;
+    PS_ModeElement          pModeElement, pModeElement2;
+    PS_VideoMode            pVideoMode; /* RAN */
+    PS_AudioMode			pAudioMode;	/* WWURM */
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SendModeRequestCommand"));
+
+    // Buffer Allocate
+    pParameter = (PS_RequestMode)OSCL_DEFAULT_MALLOC(sizeof(S_RequestMode));
+
+    // TRANSFER.request primitive - Parameter[MODE-ELEMENT]
+    pParameter->size_of_requestedModes = 1;
+
+    // Buffer Allocate
+    pModeDescription = (PS_ModeDescription)OSCL_DEFAULT_MALLOC(
+                           sizeof(S_ModeDescription));
+
+    // ModeDescription
+    pModeDescription->size = 2;
+
+    // Buffer Allocate
+    pModeElement = (PS_ModeElement)OSCL_DEFAULT_MALLOC(
+                       pModeDescription->size * sizeof(S_ModeElement));
+
+
+    pModeElement->option_of_h223ModeParameters = false;
+    pModeElement->option_of_v76ModeParameters = false;
+    pModeElement->option_of_h2250ModeParameters = false;
+    pModeElement->option_of_genericModeParameters = false;
+    pModeElement->modeType.index = 1;  // videoMode
+    pModeElement->modeType.videoMode =
+        pVideoMode = (PS_VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_VideoMode));
+
+    pVideoMode->index = 3;   // H.263 Video
+    pVideoMode->h263VideoMode = (PS_H263VideoMode) OSCL_DEFAULT_MALLOC(sizeof(S_H263VideoMode));
+    pVideoMode->h263VideoMode->h263Resolution.index = 1; // QCIF
+    pVideoMode->h263VideoMode->bitRate = 480;       // 48000 bits/sec
+    pVideoMode->h263VideoMode->unrestrictedVector = false;
+    pVideoMode->h263VideoMode->arithmeticCoding = false;
+    pVideoMode->h263VideoMode->advancedPrediction = false;
+    pVideoMode->h263VideoMode->pbFrames = false;
+    pVideoMode->h263VideoMode->option_of_errorCompensation = false;
+    pVideoMode->h263VideoMode->option_of_enhancementLayerInfo = false;
+    pVideoMode->h263VideoMode->option_of_h263Options = false;
+
+    pModeElement2 = &pModeElement[1];
+    pModeElement2->option_of_h223ModeParameters = false;
+    pModeElement2->option_of_v76ModeParameters = false;
+    pModeElement2->option_of_h2250ModeParameters = false;
+    pModeElement2->option_of_genericModeParameters = false;
+    pModeElement2->modeType.index = 2;  // audioMode
+    pModeElement2->modeType.audioMode =
+
+        pAudioMode = (PS_AudioMode) OSCL_DEFAULT_MALLOC(sizeof(S_AudioMode));
+    PS_GenericCapability	genericCap;
+    pAudioMode->index = 20;
+    pAudioMode->genericAudioMode = genericCap =
+                                       (PS_GenericCapability) OSCL_DEFAULT_MALLOC(sizeof(S_GenericCapability));
+    genericCap->capabilityIdentifier.index = 0;
+    genericCap->capabilityIdentifier.standard =
+        (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+    genericCap->capabilityIdentifier.standard->size = 7;
+    genericCap->capabilityIdentifier.standard->data =
+        (uint8*) OSCL_DEFAULT_MALLOC(7 * sizeof(uint8));
+    genericCap->capabilityIdentifier.standard->data[0] = 0x00;
+    genericCap->capabilityIdentifier.standard->data[1] = 0x08;
+    genericCap->capabilityIdentifier.standard->data[2] = 0x81;
+    genericCap->capabilityIdentifier.standard->data[3] = 0x75;
+    genericCap->capabilityIdentifier.standard->data[4] = 0x01;
+    genericCap->capabilityIdentifier.standard->data[5] = 0x01;
+    genericCap->capabilityIdentifier.standard->data[6] = 0x01;
+    genericCap->option_of_maxBitRate = true;
+    genericCap->maxBitRate = 122;
+    genericCap->option_of_collapsing = true;
+    genericCap->size_of_collapsing = 1;
+    genericCap->collapsing =
+        (PS_GenericParameter) OSCL_DEFAULT_MALLOC(sizeof(S_GenericParameter));
+    genericCap->collapsing[0].parameterIdentifier.index = 0;
+    genericCap->collapsing[0].parameterIdentifier.standard = 0;
+    genericCap->collapsing[0].parameterValue.index = 2;
+    genericCap->collapsing[0].parameterValue.unsignedMin = 1;
+    genericCap->collapsing[0].option_of_supersedes = false;
+    genericCap->option_of_nonCollapsing = true;
+    genericCap->size_of_nonCollapsing = 1;
+    genericCap->nonCollapsing =
+        (PS_GenericParameter) OSCL_DEFAULT_MALLOC(sizeof(S_GenericParameter));
+    genericCap->nonCollapsing[0].parameterIdentifier.index = 0;
+    genericCap->nonCollapsing[0].parameterIdentifier.standard = 1;
+    genericCap->nonCollapsing[0].parameterValue.index = 2;
+    genericCap->nonCollapsing[0].parameterValue.unsignedMin = 1;
+    genericCap->nonCollapsing[0].option_of_supersedes = false;
+
+    genericCap->option_of_nonCollapsingRaw = false;
+    genericCap->option_of_transport = false;
+
+
+    // Link the sub-objects together
+    pModeDescription->item = pModeElement;
+    pParameter->requestedModes = pModeDescription;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mr_Trf_Req,
+                    0,
+                    0,
+                    (uint8*)pParameter,
+                    sizeof(S_RequestMode));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    Delete_RequestMode(pParameter);
+    OSCL_DEFAULT_FREE(pParameter);
+
+    return;
+}
+
+/*****************************************************************************/
+/*  function name        : MrRjtReq                                     */
+/*  function outline     : MrRjtReq                                     */
+/*  function discription : MrRjtReq( void )                             */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::MrRjtReq()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MrRjtReq"));
+    S_ControlMsgHeader infHeader;
+    S_RmRejectCause     parameter;
+    oscl_memset(&parameter, 0, sizeof(S_RmRejectCause));
+
+    // REJECT.request primitive - Parameter[CAUSE]
+    parameter.index = 2; // requestDenied
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mr_Rjt_Req,
+                    0,
+                    0,
+                    (uint8*)&parameter,
+                    sizeof(S_RmRejectCause));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    return;
+
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_component.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_component.cpp
new file mode 100644
index 0000000..b0ddcf6
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_component.cpp
@@ -0,0 +1,2506 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#include "h223.h"
+#include "tsc_h324m_config.h"
+#include "tsc_component.h"
+#include "tsc_constants.h"
+#include "tsc_statemanager.h"
+#include "tsc_capability.h"
+#include "tsc_lc.h"
+#include "tsc_blc.h"
+#include "tsc_clc.h"
+#include "tsc_channelcontrol.h"
+#include "tsc_mt.h"
+#ifdef MEM_TRACK
+#include "oscl_mem.h"
+#include "oscl_mem_audit.h"
+#endif
+
+
+
+#define PV_2WAY_TSC_WAIT_FOR_OBLC_TIMER_ID "PV_2WAY_TSC_WAIT_FOR_OBLC_TIMER"
+#define PV_2WAY_TSC_WAIT_FOR_OBLC_TIMER_INTERVAL 1 /* 1 s */
+
+#define TSC_MAX_OUTSTANDING_PREFMSG_PDUS 32
+
+
+TSC_component::TSC_component(TSC_statemanager& aTSCStateManager,
+                             TSC_capability& aTSCcapability,
+                             TSC_lc& aTSClc,
+                             TSC_blc& aTSCblc,
+                             TSC_clc& aTSCclc,
+                             TSC_mt& aTSCmt):
+        iTSCstatemanager(aTSCStateManager),
+        iTSCcapability(aTSCcapability),
+        iTSClc(aTSClc),
+        iTSCblc(aTSCblc),
+        iTSCclc(aTSCclc),
+        iTSCmt(aTSCmt),
+        iH245(NULL),
+        iH223(NULL),
+        iLocalTcs(NULL),
+        iWaitingForOblcTimer(NULL),
+        iOutgoingChannelConfig(NULL),
+        iIncomingChannelConfig(NULL),
+        iTSCObserver(NULL),
+        iTSCchannelcontrol(iOlcs, aTSCStateManager, aTSCblc,
+                           aTSCmt, aTSClc, aTSCcapability, aTSCclc, *this)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::TSC_component"));
+
+}
+
+void TSC_component::SetMembers(H245* aH245, H223* aH223, TSCObserver* aTSCObserver)
+{
+    iTSCObserver = aTSCObserver;
+    iTSCchannelcontrol.SetMembers(aH223, aTSCObserver);
+    iH245 = aH245;
+    iH223 = aH223;
+    MembersSet();
+}
+
+
+void TSC_component::InitVarsSession()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::InitVarsSession"));
+    iRemoteAl1Audio = OFF;
+    iRemoteAl2Audio = OFF;
+    iRemoteAl3Audio = OFF;
+    iRemoteAl1Video = OFF;
+    iRemoteAl2Video = OFF;
+    iRemoteAl3Video = OFF;
+    iVideoLayer = PVT_AL_UNKNOWN;
+    if (iLocalTcs)
+    {
+        Delete_TerminalCapabilitySet(iLocalTcs);
+        OSCL_DEFAULT_FREE(iLocalTcs);
+        iLocalTcs = NULL;
+    }
+    iRemoteTcs.Unbind();
+
+    iOlcs.SetCurrLcn(FIRST_OUTGOING_LCN);
+}
+
+void TSC_component::InitVarsLocal()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::InitVarsLocal"));
+    iAl3ControlFieldOctets = DEFAULT_AL3_CONTROL_FIELD_OCTETS;
+    iAl2WithSn = true;
+
+    iAllowAl1Video = ON;
+    iAllowAl2Video = ON;
+    iAllowAl3Video = ON;
+    iAllowAl1Audio = OFF;
+    iAllowAl2Audio = ON;
+    iAllowAl3Audio = OFF;
+    iUseAl1Video = true;
+    iUseAl2Video = true;
+    iUseAl3Video = true;
+}
+
+void TSC_component::InitTsc()
+{
+    iWaitingForOblcTimer = OSCL_NEW(OsclTimer<OsclMemAllocator>,
+                                    (PV_2WAY_TSC_WAIT_FOR_OBLC_TIMER_ID, PV_2WAY_TSC_WAIT_FOR_OBLC_TIMER_INTERVAL));
+    iWaitingForOblcTimer->SetObserver(this);
+}
+
+void TSC_component::ResetTsc()
+{
+    if (iOutgoingChannelConfig)
+    {
+        OSCL_DELETE(iOutgoingChannelConfig);
+        iOutgoingChannelConfig = NULL;
+    }
+
+    if (iIncomingChannelConfig)
+    {
+        OSCL_DELETE(iIncomingChannelConfig);
+        iIncomingChannelConfig = NULL;
+    }
+
+    if (iWaitingForOblcTimer)
+    {
+        iWaitingForOblcTimer->Clear();
+        OSCL_DELETE(iWaitingForOblcTimer);
+        iWaitingForOblcTimer = NULL;
+    }
+}
+
+void TSC_component::Disconnect()
+{
+
+    iWaitingForOblcTimer->Clear();
+}
+
+CPVMultiplexEntryDescriptor* TSC_component::GenerateSingleDescriptor(uint8 entry_num,
+        TPVChannelId lcn1)
+{
+    PS_MultiplexEntryDescriptor h245_desc =
+        (PS_MultiplexEntryDescriptor)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntryDescriptor));
+    h245_desc->multiplexTableEntryNumber = entry_num;
+    h245_desc->option_of_elementList = true;
+    h245_desc->size_of_elementList = 1;
+    h245_desc->elementList =
+        (PS_MultiplexElement)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexElement));
+
+    PS_MultiplexElement elem = 	h245_desc->elementList;
+    elem->muxType.index = 0; // logical channel = 0, 1 = sub-elem list
+    elem->muxType.logicalChannelNumber = (uint16)lcn1;
+    elem->muxType.size = 1; // size of element list
+    elem->repeatCount.index = 1; // ucf
+    elem->repeatCount.finite = 0;
+
+    CPVMultiplexEntryDescriptor* ret =
+        CPVMultiplexEntryDescriptor::NewL(h245_desc, 128);
+    Delete_MultiplexEntryDescriptor(h245_desc);
+    OSCL_DEFAULT_FREE(h245_desc);
+
+    return ret;
+}
+
+PS_AdaptationLayerType
+TSC_component::GetOutgoingLayer(PV2WayMediaType media_type, uint32 max_sample_size)
+{
+    PS_AdaptationLayerType al_type =
+        (PS_AdaptationLayerType)OSCL_DEFAULT_MALLOC(sizeof(S_AdaptationLayerType));
+    int room_for_sn = 0;
+
+    oscl_memset(al_type, 0, sizeof(S_AdaptationLayerType));
+    uint32 max_sdu_size = 0;
+    switch (media_type)
+    {
+        case PV_AUDIO:
+            if (iRemoteAl2Audio)
+            {
+                max_sdu_size = iH223->GetSduSize(OUTGOING, E_EP_MEDIUM);
+                room_for_sn = max_sdu_size - max_sample_size - 1; /* 1 byte for CRC */
+                room_for_sn = (room_for_sn > 1) ? 1 : room_for_sn;
+                if (room_for_sn >= 0)
+                {
+                    al_type->index = (uint16)(3 + room_for_sn);
+                    return al_type;
+                }
+            }
+            if (iRemoteAl3Audio)
+            {
+                max_sdu_size = iH223->GetSduSize(OUTGOING, E_EP_HIGH);
+                room_for_sn = max_sdu_size - max_sample_size - 2; /* 2 bytes for CRC */
+                if (room_for_sn >= 0)
+                {
+                    PS_Al3 al3 = (PS_Al3)OSCL_DEFAULT_MALLOC(sizeof(S_Al3));
+                    al3->controlFieldOctets = (int8)((room_for_sn >
+                                                      (int)iAl3ControlFieldOctets) ? iAl3ControlFieldOctets : room_for_sn);
+                    al3->sendBufferSize = DEF_AL3_SEND_BUFFER_SIZE;
+                    al_type->index = 5;
+                    al_type->al3 = al3;
+                    return al_type;
+                }
+            }
+            if (iRemoteAl1Audio)
+            {
+                max_sdu_size = iH223->GetSduSize(OUTGOING, E_EP_LOW);
+                room_for_sn = max_sdu_size - max_sample_size;
+                room_for_sn = (room_for_sn > 1) ? 1 : room_for_sn;
+                if (max_sdu_size >= max_sample_size)
+                {
+                    al_type->index = 1;
+                    return al_type;
+                }
+            }
+            break;
+        case PV_VIDEO:
+            if (iUseAl2Video && iRemoteAl2Video)
+            {
+                al_type->index = (uint16)(iAl2WithSn ? 4 : 3);
+                return al_type;
+            }
+            if (iUseAl3Video && iRemoteAl3Video)
+            {
+                PS_Al3 al3 = (PS_Al3)OSCL_DEFAULT_MALLOC(sizeof(S_Al3));
+                al3->controlFieldOctets = (int8)iAl3ControlFieldOctets;
+                al3->sendBufferSize = DEF_AL3_SEND_BUFFER_SIZE;
+                al_type->index = 5;
+                al_type->al3 = al3;
+                return al_type;
+            }
+            if (iUseAl1Video && iRemoteAl1Video)
+            {
+                al_type->index = 1;
+                return al_type;
+            }
+            break;
+        default:
+            break;
+    }
+    OSCL_DEFAULT_FREE(al_type);
+    return NULL;
+}
+
+void TSC_component::SetAlConfig(PV2WayMediaType media_type,
+                                TPVAdaptationLayer layer,
+                                bool allow)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::SetAlConfig"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::SetAlConfig media type(%d), layer(%d), allow(%d)",
+                     media_type, layer, allow));
+
+    switch (media_type)
+    {
+        case PV_AUDIO:
+            if (layer == PVT_AL1)
+                iAllowAl1Audio = allow;
+            else if (layer == PVT_AL2)
+                iAllowAl2Audio = allow;
+            else if (layer == PVT_AL3)
+                iAllowAl3Audio = allow;
+            break;
+        case PV_VIDEO:
+            if (layer == PVT_AL1)
+                iAllowAl1Video = allow;
+            else if (layer == PVT_AL2)
+                iAllowAl2Video = allow;
+            else if (layer == PVT_AL3)
+                iAllowAl3Video = allow;
+            break;
+        case PV_DATA:
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::SetAlConfig Invalid media type"));
+    }
+}
+
+//////////////////////////////////////////////////////////////////////////
+// Start the CE process by sending this terminals capabilites to the peer terminal
+//////////////////////////////////////////////////////////////////////////
+bool TSC_component::CEStart()
+{
+    if (!iIncomingChannelConfig || !iIncomingChannelConfig->size())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::CEStart- Incoming channel config not set"));
+        return false;
+    }
+
+    iTSCstatemanager.WriteState(TSC_CE_SEND, STARTED);
+
+    MultiplexCapabilityInfo mux_cap_info;
+    mux_cap_info.iAllowAl1Video = iAllowAl1Video;
+    mux_cap_info.iAllowAl2Video = iAllowAl2Video;
+    mux_cap_info.iAllowAl3Video = iAllowAl3Video;
+    mux_cap_info.iAllowAl1Audio = iAllowAl1Audio;
+    mux_cap_info.iAllowAl2Audio = iAllowAl2Audio;
+    mux_cap_info.iAllowAl3Audio = iAllowAl3Audio;
+    mux_cap_info.iMaximumAl2SDUSize = iH223->GetSduSize(INCOMING, E_EP_MEDIUM);
+    mux_cap_info.iMaximumAl3SDUSize = iH223->GetSduSize(INCOMING, E_EP_HIGH);
+    Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> outgoing_codecs;
+    Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> incoming_codecs;
+    for (unsigned n = 0;n < iIncomingChannelConfig->size();n++)
+    {
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* codecs =
+            (*iIncomingChannelConfig)[n].GetCodecs();
+        if (!codecs)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::CEStart No codecs specified for format type(%d)",
+                             (*iIncomingChannelConfig)[n].GetMediaType()));
+            continue;
+        }
+        for (unsigned m = 0;m < codecs->size();m++)
+        {
+            CodecCapabilityInfo* info = NULL;
+            PVCodecType_t codec_type = PVMFFormatTypeToPVCodecType((*codecs)[m].format);
+            TPVDirection dir = (*codecs)[m].dir;
+            if (GetMediaType(codec_type) == PV_VIDEO)
+            {
+                info = new VideoCodecCapabilityInfo;
+                ((VideoCodecCapabilityInfo*)info)->resolutions =
+                    iTSCcapability.GetResolutions(dir);
+            }
+            else
+            {
+                info = new CodecCapabilityInfo;
+            }
+            info->codec = codec_type;
+            info->dir = dir;
+            incoming_codecs.push_back(info);
+        }
+    }
+#if 0
+    for (n = 0;n < iOutgoingChannelConfig->size();n++)
+    {
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* codecs =
+            (*iOutgoingChannelConfig)[n].GetCodecs();
+        if (!codecs)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::CEStart No codecs specified for format type(%d)",
+                             (*iIncomingChannelConfig)[n].GetMediaType()));
+            continue;
+        }
+        for (unsigned m = 0;m < codecs->size();m++)
+        {
+            CodecCapabilityInfo* info = NULL;
+            PVCodecType_t codec_type = PVMFFormatTypeToPVCodecType((*codecs)[m].format);
+            TPVDirection dir = (*codecs)[m].dir;
+            if (GetMediaType(codec_type) == PV_VIDEO)
+            {
+                info = new VideoCodecCapabilityInfo;
+                ((VideoCodecCapabilityInfo*)info)->resolutions =
+                    iTSCcapability.GetResolutions(dir);
+
+            }
+            else
+            {
+                info = new CodecCapabilityInfo;
+            }
+            info->codec = codec_type;
+            info->dir = dir;
+            outgoing_codecs.push_back(info);
+        }
+    }
+#endif
+    if (iLocalTcs)
+    {
+        Delete_TerminalCapabilitySet(iLocalTcs);
+        OSCL_DEFAULT_FREE(iLocalTcs);
+        iLocalTcs = NULL;
+    }
+    iLocalTcs = GenerateTcs(mux_cap_info, outgoing_codecs, incoming_codecs);
+    CustomGenerateTcs(iLocalTcs);
+
+    CE* Ce = iH245->GetCE();
+    if (Ce) Ce->TransferRequest(iLocalTcs);
+
+    for (unsigned i = 0;i < incoming_codecs.size();i++)
+    {
+        delete incoming_codecs[i];
+    }
+    return true;
+}
+
+TPVStatusCode TSC_component::SetTerminalParam(CPVTerminalParam& params)
+{
+    CPVH324MParam* h324params = (CPVH324MParam*) & params;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component:SetTerminalParam - AL1(%d), AL2(%d), AL3(%d)",
+                     h324params->iAllowAl1Video,
+                     h324params->iAllowAl2Video,
+                     h324params->iAllowAl3Video));
+
+    iAllowAl1Video = h324params->iAllowAl1Video;
+    iAllowAl2Video = h324params->iAllowAl2Video;
+    iAllowAl3Video = h324params->iAllowAl3Video;
+    iUseAl1Video = h324params->iUseAl1Video;
+    iUseAl2Video = h324params->iUseAl2Video;
+    iUseAl3Video = h324params->iUseAl3Video;
+
+    iVideoLayer = h324params->iVideoLayer;
+
+    return EPVT_Success;
+}
+
+void TSC_component::GetTerminalParam(CPVH324MParam& ah324param)
+{
+    ah324param.iAllowAl1Video = iAllowAl1Video ? true : false;
+    ah324param.iAllowAl2Video = iAllowAl2Video ? true : false;
+    ah324param.iAllowAl3Video = iAllowAl3Video ? true : false;
+    ah324param.iVideoLayer = iVideoLayer;
+}
+
+bool TSC_component::IsSupported(TPVDirection dir,
+                                PVCodecType_t codec,
+                                FormatCapabilityInfo& capability_info)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::IsSupported dir(%d), codec(%d)", dir, codec));
+    if (codec == PV_CODEC_TYPE_NONE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::IsSupported No codec is always ok"));
+        return true;
+    }
+    Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* config = (dir == OUTGOING) ?
+            iOutgoingChannelConfig : iIncomingChannelConfig;
+    if (!config)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::IsSupported No config available"));
+        return false;
+    }
+    for (unsigned n = 0;n < config->size();n++)
+    {
+        H324ChannelParameters& param = (*config)[n];
+        if (param.GetMediaType() != GetMediaType(codec))
+            continue;
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* codecs = param.GetCodecs();
+        if (!codecs)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::IsSupported No codecs specified"));
+            return false;
+        }
+        for (unsigned m = 0;m < codecs->size();m++)
+        {
+            if ((*codecs)[m].format == PVCodecTypeToPVMFFormatType(codec))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::IsSupported Match found"));
+                capability_info = (*codecs)[m];
+                return true;
+            }
+        }
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::IsSupported No match found"));
+    return false;
+}
+
+bool TSC_component::IsSupported(TPVDirection dir,
+                                PV2WayMediaType media_type,
+                                CodecCapabilityInfo& codec_info)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::IsSupported dir(%d), media_type(%d)", dir, media_type));
+    if (media_type == PV_MEDIA_NONE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::IsSupported No media is always ok"));
+        return true;
+    }
+    Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* config = (dir == OUTGOING) ?
+            iOutgoingChannelConfig : iIncomingChannelConfig;
+    if (!config)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::IsSupported No config available"));
+        return false;
+    }
+    for (unsigned n = 0;n < config->size();n++)
+    {
+        H324ChannelParameters& param = (*config)[n];
+        if (param.GetMediaType() != media_type)
+            continue;
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* codecs = param.GetCodecs();
+        if (!codecs)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::IsSupported No codecs specified"));
+            return false;
+        }
+        codec_info.codec = PVMFFormatTypeToPVCodecType((*codecs)[0].format);
+        codec_info.dir = (*codecs)[0].dir;
+        return true;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::IsSupported No match found"));
+    return false;
+}
+////////////////////////////////////////////////////////////////////////////
+// ExtractTcsParameters()						(RAN-32K)
+//
+// This routine takes the incoming TerminalCapabilitySet
+//   and extracts the following useful parameters:
+//      {h263_qcifMPI, h263_maxBitRate, mpeg4_maxBitRate}
+// The parameters are stored in globals and may be sent
+//   later to the application.
+////////////////////////////////////////////////////////////////////////////
+void TSC_component::ExtractTcsParameters(PS_TerminalCapabilitySet pTcs)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::ExtractTcsParameters"));
+
+    if (pTcs->option_of_multiplexCapability)
+    {
+        PS_MultiplexCapability muxcaps = &pTcs->multiplexCapability;
+        if (muxcaps->index == 2)
+        {
+
+            PS_H223Capability h223caps = muxcaps->h223Capability;
+            iRemoteAl1Audio = h223caps->audioWithAL1;
+            iRemoteAl2Audio = h223caps->audioWithAL2;
+            iRemoteAl3Audio = h223caps->audioWithAL3;
+            iRemoteAl1Video = h223caps->videoWithAL1;
+            iRemoteAl2Video = h223caps->videoWithAL2;
+            iRemoteAl3Video = h223caps->videoWithAL3;
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::ExtractTcsParameters Remote audio caps AL1(%d), AL2(%d), AL3(%d)",
+                             iRemoteAl1Audio, iRemoteAl2Audio, iRemoteAl3Audio));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::ExtractTcsParameters Remote video caps AL1(%d), AL2(%d), AL3(%d)",
+                             iRemoteAl1Video, iRemoteAl2Video, iRemoteAl3Video));
+            // -------------------------------------
+            // Decide which Video Layer to use (RAN)
+            // -------------------------------------
+            /* If both terminals support AL2, use AL2 */
+            if (iUseAl2Video && iRemoteAl2Video)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::ExtractTcsParameters Video Layer Decision is AL2"));
+                iVideoLayer = PVT_AL2;
+            }
+            /* If not, check for mutual AL3 support */
+            else if (iUseAl3Video && iRemoteAl3Video)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::ExtractTcsParameters Video Layer Decision is AL3"));
+                iVideoLayer = PVT_AL3;
+            }
+            /* If not, check for mutual AL1 support */
+            else if (iUseAl1Video && iRemoteAl1Video)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::ExtractTcsParameters Video Layer Decision is AL1"));
+                iVideoLayer = PVT_AL1;
+            }
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////
+// CE User - Transfer.Indication primitive received from H.245
+////////////////////////////////////////////////////////////////////////
+void TSC_component::CETransferIndication(OsclSharedPtr<S_TerminalCapabilitySet> tcs,
+        uint32 aTerminalStatus)
+{
+    if (aTerminalStatus == PhaseD_CSUP)
+    {
+        iRemoteTcs = tcs;
+    }
+
+    else if (aTerminalStatus == PhaseE_Comm)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::CETransferIndication TCS received during PhaseE_Comm"));
+        if (tcs->option_of_multiplexCapability)
+        {
+            /* Save any required CE data */
+            iRemoteAl2Video =
+                tcs->multiplexCapability.h223Capability->videoWithAL2;
+            iRemoteAl3Video =
+                tcs->multiplexCapability.h223Capability->videoWithAL3;
+        }
+    }
+}
+
+// ========================================================
+// SetAl2Al3VideoFlags()                              (RAN)
+//
+// New API from application layer.  Sets the flags as follows:
+//   INPUT		gAllowAl2Video		gAllowAl3Video
+//     0               ON                 OFF
+//     1               OFF                ON
+//     2               ON                 ON
+// ========================================================
+void TSC_component::SetAl2Al3VideoFlags(int32 userInput)
+{
+    iAllowAl2Video = iAllowAl3Video = ON;
+    if (userInput == 0)
+    {
+        iAllowAl3Video = OFF;
+    }
+    else if (userInput == 1)
+    {
+        iAllowAl2Video = OFF;
+    }
+}
+
+// ========================================================
+// GetAl2Al3VideoFlags()                              (RAN)
+//
+// Complements SetAl2Al3VideoFlags()
+// ========================================================
+int32 TSC_component::GetAl2Al3VideoFlags(void)
+{
+    return(iAllowAl2Video + 2 * iAllowAl3Video - 1);
+}
+
+////////////////////////////////////////////////
+//
+////////////////////////////////////////////////
+Oscl_Vector < H324ChannelParameters,
+PVMFTscAlloc > * TSC_component::GetChannelConfig(TPVDirection dir)
+{
+    if (dir == OUTGOING)
+    {
+        return iOutgoingChannelConfig;
+    }
+    return iIncomingChannelConfig;
+}
+
+void TSC_component::SetAl3ControlFieldOctets(unsigned cfo)
+{
+    iAl3ControlFieldOctets = cfo;
+}
+
+void TSC_component::SetAl2Sn(int width)
+{
+    iAl2WithSn = width ? true : false;
+}
+
+
+/*****************************************************************************/
+/*  function name        : LcEtbIdc           E_PtvId_Lc_Etb_Idc  */
+/*  function outline     : Status04/Event09 procedure                        */
+/*  function discription : Status04Event09( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_component::LcEtbIdc(PS_ControlMsgHeader  pReceiveInf)
+{
+    TPVChannelId OpenLcn = (TPVChannelId)pReceiveInf->InfSupplement1 +
+                           TSC_INCOMING_CHANNEL_MASK;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcEtbIdc lcn(%d)", OpenLcn));
+    PS_ForwardReverseParam pLcParam = (PS_ForwardReverseParam) pReceiveInf->pParameter;
+    /* validate forRevParams */
+    PVMFStatus forRevCheck = iTSCcapability.ValidateForwardReverseParams(pLcParam, INCOMING);
+    if (forRevCheck != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                        (0, "TSC_component::LcEtbIdc ERROR  - Incoming forRevParams not supported.  Rejecting."));
+        uint16 reason = (uint16)((forRevCheck == PVMFErrNotSupported) ? 2/* dataTypeNotSupported */ : 0/*unspecified*/);
+        TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, reason);
+        RemoveOlc(dir, OpenLcn);
+        return PhaseE_Comm;
+    }
+    PS_H223LogicalChannelParameters pH223Lcp =
+        pLcParam->forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters;
+    PS_DataType pDataType = &pLcParam->forwardLogicalChannelParameters.dataType;
+    PV2WayMediaType media_type  = PV_MEDIA_NONE;
+    PVCodecType_t incoming_codec_type = PV_CODEC_TYPE_NONE;
+
+    incoming_codec_type = ::GetCodecType(pDataType);
+    media_type = ::GetMediaType(pDataType);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcEtbIdc lcn(%d), media type(%d), codec type(%d)",
+                     OpenLcn, media_type, incoming_codec_type));
+
+    OlcKey key(INCOMING, OpenLcn);
+
+    if (iOlcs.count(key))
+    {
+        if (iOlcs[key]->GetState() == OLC_ESTABLISHED)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::LcEtbIdc Established incoming OLC found for same channel id. Rejecting OLC(%d)",
+                             media_type, OpenLcn));
+            TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, 0);  // unspecified
+            RemoveOlc(dir, OpenLcn);
+            return PhaseE_Comm;
+        }
+        else
+        {
+            ReleasePendingIncomingChannel(OpenLcn);
+        }
+    }
+
+    /* pending incoming OLC for the same media type */
+    Oscl_Vector<OlcParam*, OsclMemAllocator> pending_olc_list;
+    // Search for pending and established channels
+    if (iOlcs.FindOlcs(INCOMING, media_type, OLC_PENDING | OLC_ESTABLISHED,
+                       pending_olc_list))
+    {
+        for (unsigned i = 0; i < pending_olc_list.size(); i++)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::LcEtbIdc Pending incoming OLC found for media type=%d, lcn=%d",
+                             media_type, pending_olc_list[i]->GetChannelId()));
+            if (!ReleasedPendingIncomingChannel(pending_olc_list[i]))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::LcEtbIdc Established incoming OLC found for same media type. Rejecting OLC(%d)",
+                                 media_type, OpenLcn));
+                TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, 0); /* unspecified */
+                RemoveOlc(dir, OpenLcn);
+                return PhaseE_Comm;
+            }
+        }
+    }
+
+    OlcParam* pending_outgoing_olc = NULL;
+    PVCodecType_t to_be_opened_codec = PV_CODEC_TYPE_NONE;
+
+    // Add pending olc to list
+    iOlcs.AppendOlc(INCOMING, OpenLcn, pDataType, pH223Lcp);
+    // is there is a pending outgoing OLC for the same media type ?
+    if (iOlcs.FindOlcs(OUTGOING, media_type, OLC_PENDING, pending_olc_list))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::LcEtbIdc Pending outgoing OLCs(%d) found for incoming media type(%d).",
+                         pending_olc_list.size(), media_type, OpenLcn));
+        OSCL_ASSERT(pending_olc_list.size() == 1);
+        OlcParam* param = pending_outgoing_olc = pending_olc_list[0];
+        if (param->GetDirectionality() == EPVT_BI_DIRECTIONAL)
+        {
+            pending_outgoing_olc = NULL;
+            // There is an OLC/OBLC conflict
+            if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == MASTER)
+            {
+                // We are master, hence we reject the OLC
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::LcEtbIdc BLC Already initiated by local. Rejecting OLC cause we are Master"));
+                TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, 10);  // Master slave conflict
+                RemoveOlc(dir, OpenLcn);
+                return PhaseE_Comm;
+            }
+            else  // We are Slave
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::LcEtbIdc BLC Already initiated by local. Closing BLC cause we are Slave"));
+                to_be_opened_codec = GetCodecType(param->GetForwardParams()->GetDataType());;
+                // Release the pending blc
+                iTSCblc.BlcRlsReq(RELEASE_CLOSE, param->GetChannelId(), 0);
+                ChannelReleased(OUTGOING, param->GetChannelId(), PVMFErrCancelled);
+                // Logical channel will be deleted from the mux when the engine calls ReleasePort
+            }
+        }
+    }
+
+
+    PVMFStatus tscCheck = ValidateOlcsWithTcs();
+    if (tscCheck != PVMFSuccess)
+    {
+        if (pending_outgoing_olc)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::LcEtbIdc pending olcs."));
+            if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == MASTER)
+            {
+                // We are master, hence we reject the incoming OLC with code M/S conflict
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::LcEtbIdc TCS violated with pending olcs from Master."));
+                TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, 10);  // Master slave conflict
+                RemoveOlc(dir, OpenLcn);
+                return PhaseE_Comm;
+            }
+            /* We should close the conflicting codec and reopen a replacement.  Assumption here is that the
+               conflict is due to the media type of the current incoming channel.  This will not work if there
+               are symmetry inter-dependencies between audio and video codecs in the TCS.  */
+            pending_outgoing_olc->GetForwardParams()->GetBitrate();
+            iTSClc.LcRlsReq(RELEASE_CLOSE,
+                            pending_outgoing_olc->GetChannelId(), 0);
+            ChannelReleased(OUTGOING,
+                            pending_outgoing_olc->GetChannelId(), PVMFErrCancelled);
+            FormatCapabilityInfo codec_caps;
+            if (IsSupported(OUTGOING, incoming_codec_type, codec_caps))
+            {
+                /* Verify if the capability sets can support it */
+                TPVChannelId tmp_lcn = iOlcs.GetNextAvailLcn();
+                iOlcs.AppendOlc(OUTGOING, tmp_lcn, pDataType, pH223Lcp);
+                if (ValidateOlcsWithTcs() == PVMFSuccess)
+                {
+                    to_be_opened_codec = incoming_codec_type;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                    (0, "TSC_component::LcEtbIdc Cannot open a replacement channel as incoming codec is not supported"));
+                }
+                RemoveOlc(OUTGOING, tmp_lcn);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::LcEtbIdc Incoming codec not supported for transmit"));
+            }
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::LcEtbIdc no pending olcs."));
+            // There were no pending OLCs from the local terminal.
+            TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, 3);  // dataTypeNotAvailable
+            RemoveOlc(dir, OpenLcn);
+            return PhaseE_Comm;
+        }
+    }
+
+    int leave_status = OpenLogicalChannel(OpenLcn, pDataType, pH223Lcp);
+    if (leave_status != 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::LcEtbIdc - Memory Allocation Failed."));
+        return leave_status;
+    }
+
+    uint8* fsi = NULL;
+    uint32 fsi_len = ::GetFormatSpecificInfo(pDataType, fsi);
+    iTSCObserver->IncomingChannel(OpenLcn, incoming_codec_type, fsi, fsi_len);
+
+    // ESTABLISH.response(LC) Primitive Send
+    iTSClc.LcEtbRps(OpenLcn);
+
+    SetCustomMultiplex(pReceiveInf, media_type);
+    if (to_be_opened_codec == PV_CODEC_TYPE_NONE)
+        return PhaseE_Comm;
+    FormatCapabilityInfo fci;
+    IsSupported(OUTGOING, to_be_opened_codec, fci);
+    PS_AdaptationLayerType al_type = GetOutgoingLayer(media_type, fci.max_sample_size);
+    if (al_type == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    OpenOutgoingChannel(to_be_opened_codec, al_type);
+    Delete_AdaptationLayerType(al_type);
+    OSCL_DEFAULT_FREE(al_type);
+    iTSCmt.MtTrfReq(iOlcs);
+    return PhaseE_Comm;
+}
+
+uint32 TSC_component::OpenLogicalChannel(TPVChannelId OpenLcn,
+        PS_DataType pDataType,
+        PS_H223LogicalChannelParameters pH223Lcp)
+{
+    int leave_status = 0;
+    OlcParam* param = NULL;
+    OSCL_TRY(leave_status, param = OpenLogicalChannel(INCOMING,
+                                   OpenLcn, CHANNEL_ID_UNKNOWN, pDataType, pH223Lcp));
+    OSCL_FIRST_CATCH_ANY(leave_status, void());
+    if (leave_status != 0)
+    {
+        TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcn, 0);  // unspecified
+        RemoveOlc(dir, OpenLcn);
+        return PhaseE_Comm;
+    }
+    param->SetState(OLC_ESTABLISHED);
+    return leave_status;
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event14          E_PtvId_Blc_Etb_Idc  */
+/*  function outline     : Status04/Event14 procedure                        */
+/*  function discription : Status04Event14( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_component::BlcEtbIdc(PS_ControlMsgHeader  pReceiveInf)
+{
+    TPVChannelId OpenLcnB = pReceiveInf->InfSupplement1 + TSC_INCOMING_CHANNEL_MASK; /* incoming lcn */
+    TPVChannelId OpenLcnF = CHANNEL_ID_UNKNOWN; /* outgoing lcn */
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::BlcEtbIdc lcn(%d)", OpenLcnB));
+    /* Function prototypes */
+    uint8* GetDecoderConfigFromOLC(PS_ForwardReverseParam pPara, uint32 forRev, uint16 *nOctets);
+    PS_ForwardReverseParam forRevParams = (PS_ForwardReverseParam)pReceiveInf->pParameter;
+
+    /* validate forRevParams */
+    PVMFStatus forRevCheck = iTSCcapability.ValidateForwardReverseParams(forRevParams, INCOMING);
+    if (forRevCheck != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_EMERG,
+                        (0, "TSC_component::BlcEtbIdc ERROR  - Incoming forRevParams not supported.  Rejecting."));
+        uint16 reason = (uint16)((forRevCheck == PVMFErrNotSupported) ? 2/* dataTypeNotSupported */ : 0/*unspecified*/);
+        TPVDirection dir = iTSClc.LcRlsReq(RELEASE_REJECT, OpenLcnB, reason);
+        RemoveOlc(dir, OpenLcnB);
+        return PhaseE_Comm;
+    }
+
+    PS_ForwardLogicalChannelParameters forwardParams = &forRevParams->forwardLogicalChannelParameters;
+    PS_ReverseLogicalChannelParameters reverseParams = &forRevParams->reverseLogicalChannelParameters;
+    PVCodecType_t in_codec_type = ::GetCodecType(&forwardParams->dataType);
+    PVCodecType_t out_codec_type = ::GetCodecType(&reverseParams->dataType);
+    PV2WayMediaType out_media_type = ::GetMediaType(&reverseParams->dataType);
+    OSCL_UNUSED_ARG(out_media_type);
+    PV2WayMediaType in_media_type = ::GetMediaType(&forwardParams->dataType);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::BlcEtbIdc in media type(%d), in codec type(%d), out media type(%d), out codec type(%d)", in_media_type, in_codec_type, out_media_type, out_codec_type));
+
+    /* Do we support the outgoing codec ? */
+    FormatCapabilityInfo codec_caps;
+    if (!IsSupported(OUTGOING, out_codec_type, codec_caps) ||
+            !IsSupported(INCOMING, in_codec_type, codec_caps))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::BlcEtbIdc Outgoing/incoming codec not supported for transmit"));
+        TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_REJECT, OpenLcnB, 2); /* dataTypeNotSupported */
+        RemoveOlc(dir, OpenLcnB);
+        return(PhaseE_Comm);
+    }
+
+    unsigned outgoing_bitrate = 0;
+    if (out_codec_type != PV_CODEC_TYPE_NONE)
+    {
+        outgoing_bitrate = GetOutgoingBitrate(out_codec_type);
+        if (outgoing_bitrate <= 0)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::BlcEtbIdc No bandwidth allocated for outgoing media type(%d)",
+                             out_media_type));
+            TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_REJECT, OpenLcnB, 3); /* dataTypeNotAvailable */
+            RemoveOlc(dir, OpenLcnB);
+            return PhaseE_Comm ;
+        }
+    }
+
+    /* Cancel waiting for OBLC */
+    if (iWaitingForOblc)
+    {
+        if (out_codec_type != iWaitingForOblcCodec)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::BlcEtbIdc Reverse codec in BLC(%d) does not match iWaitingForOblcCodec(%d)",
+                             out_codec_type, iWaitingForOblcCodec));
+        }
+    }
+    iWaitingForOblc = false;
+    iWaitingForOblcTimer->Clear();
+    iWaitingForOblcCodec = PV_CODEC_TYPE_NONE;
+
+    Oscl_Vector<OlcParam*, OsclMemAllocator> pending_olc_list;
+    /* Pending incoming OLC for the same media type */
+    if (iOlcs.FindOlcs(INCOMING, in_media_type, OLC_PENDING | OLC_ESTABLISHED, pending_olc_list))
+    {
+        for (unsigned i = 0; i < pending_olc_list.size(); i++)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::BlcEtbIdc Pending incoming OLC found for media type=%d, lcn=%d",
+                             in_media_type, pending_olc_list[i]->GetChannelId()));
+            if (!ReleasedPendingIncomingChannel(pending_olc_list[i]))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::BlcEtbIdc Established incoming OLC found for same media type. Rejecting OLC(%d)", in_media_type, OpenLcnB));
+                TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_REJECT, OpenLcnB, 0); /* unspecified */
+                RemoveOlc(dir, OpenLcnB);
+                return PhaseE_Comm;
+            }
+
+        }
+    }
+
+    /* if there are established outgoing channels for the same media type, close them */
+    if (out_codec_type != PV_CODEC_TYPE_NONE &&
+            iOlcs.FindOlcs(OUTGOING, in_media_type, OLC_ESTABLISHED, pending_olc_list))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::BlcEtbIdc Established outgoing OLC found for same media type(%d). Closing down the OLCS", in_media_type));
+        for (unsigned i = 0; i < pending_olc_list.size(); i++)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::BlcEtbIdc Established outgoing OLC found for media type=%d, lcn=%d",
+                             in_media_type, pending_olc_list[i]->GetChannelId()));
+            ChannelReleased(OUTGOING, pending_olc_list[i]->GetChannelId(), PVMFFailure);
+        }
+    }
+
+    PVCodecType_t to_be_opened_codec = PV_CODEC_TYPE_NONE;
+    /* is there is a pending outgoing OLC for the same media type ?*/
+    if (iOlcs.FindOlcs(OUTGOING, in_media_type, OLC_PENDING, pending_olc_list))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::BlcEtbIdc Pending outgoing OLCs(%d) found for incoming media type(%d).",
+                         pending_olc_list.size(), in_media_type, OpenLcnB));
+        OSCL_ASSERT(pending_olc_list.size() == 1);
+        OlcParam* param = pending_olc_list[0];
+        if (param->GetDirectionality() == EPVT_BI_DIRECTIONAL || /* Bi-dir: always causes conflict*/
+                out_codec_type != PV_CODEC_TYPE_NONE)  /*Uni-dir: no conflict if reverse params are NULL */
+        {
+            /* OLCs are conflicting */
+            if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == MASTER)
+            {
+                /* We are master, hence we reject the incoming OLC */
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::BlcEtbIdc BLC Already initiated by local. Rejecting OBLC cause we are Master"));
+                TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_REJECT, OpenLcnB, 10);  /* Master slave conflict */
+                RemoveOlc(dir, OpenLcnB);
+                return PhaseE_Comm ;
+            }
+            /* we are slave */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::BlcEtbIdc LC Already initiated by local. Closing it cause we are Slave"));
+            if (out_codec_type == PV_CODEC_TYPE_NONE)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::BlcEtbIdc Reverse DataType==NULL; Need to open replacement OLC/OBLC"));
+                to_be_opened_codec = GetCodecType(param->GetForwardParams()->GetDataType());
+            }
+            ReleaseOlc(param, 0);
+            ChannelReleased(OUTGOING, param->GetChannelId(), PVMFErrCancelled);
+        }
+    }
+    pending_olc_list.clear();
+    /* Generate logical channel number */
+    OpenLcnF = iOlcs.GetNextAvailLcn();
+    OlcParam* prm = iOlcs.AppendOlc(INCOMING, OpenLcnB,
+                                    &forwardParams->dataType,
+                                    forwardParams->multiplexParameters.h223LogicalChannelParameters,
+                                    OpenLcnF,
+                                    &reverseParams->dataType,
+                                    reverseParams->rlcMultiplexParameters.h223LogicalChannelParameters);
+
+    prm->GetReverseParams()->SetChannelId(OpenLcnF);
+    /* Validate the TCS's */
+    PVMFStatus tscCheck = ValidateOlcsWithTcs();
+    bool transfer_mux_tables = false;
+    if (tscCheck != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::BlcEtbIdc TCS check failed"));
+        TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_REJECT, OpenLcnB, 2);  /* dataTypeNotSupported */
+        RemoveOlc(dir, OpenLcnB);
+    }
+    else
+    {
+        PVMFStatus RvsParametersOkay = VerifyReverseParameters(forRevParams, iTSCObserver);
+        if (RvsParametersOkay == PVMFSuccess)
+        {
+            AcceptBLCRequest(OpenLcnF, OpenLcnB, forRevParams);
+        }
+        else
+        {
+            /* RvsParameters are unsuitable; reject the OLC */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::BlcEtbIdc - Rejecting BLC request (%d).  Reverse parameters not ok.",
+                             OpenLcnB));
+            TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_REJECT, OpenLcnB, 1);  /* unsuitableReverseParameters */
+            RemoveOlc(dir, OpenLcnB);
+            /* Fill the data type for the outgoing codec */
+            PS_DataType pDataType = GetOutgoingDataType(out_codec_type, outgoing_bitrate);
+            /*  Fill the outgoing h223 logical channel parameters */
+            PS_H223LogicalChannelParameters pH223Params =
+                GetH223LogicalChannelParameters((uint8)IndexForAdaptationLayer(PVT_AL3),
+                                                iTSCcapability.IsSegmentable(OUTGOING, in_media_type),
+                                                iAl3ControlFieldOctets);
+
+            // Use AL3 for OBLC
+            PS_AdaptationLayerType al_type = (PS_AdaptationLayerType)OSCL_DEFAULT_MALLOC(sizeof(S_AdaptationLayerType));
+            if (al_type == NULL)
+            {
+                OSCL_LEAVE(PVMFErrNoMemory);
+            }
+            PS_Al3 al3 = (PS_Al3)OSCL_DEFAULT_MALLOC(sizeof(S_Al3));
+            al3->controlFieldOctets = iAl3ControlFieldOctets;
+            al3->sendBufferSize = DEF_AL3_SEND_BUFFER_SIZE;
+            al_type->index = 5;
+            al_type->al3 = al3;
+
+            OpenOutgoingChannel(out_codec_type,
+                                al_type,
+                                &forRevParams->forwardLogicalChannelParameters.dataType,
+                                forRevParams->forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters);
+
+            iOlcs.AppendOlc(OUTGOING, OpenLcnF, pDataType, pH223Params,
+                            CHANNEL_ID_UNKNOWN, &forRevParams->forwardLogicalChannelParameters.dataType,
+                            forRevParams->forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters);
+            transfer_mux_tables = true;
+            Delete_AdaptationLayerType(al_type);
+            OSCL_DEFAULT_FREE(al_type);
+            Delete_DataType(pDataType);
+            OSCL_DEFAULT_FREE(pDataType);
+            Delete_H223LogicalChannelParameters(pH223Params);
+            OSCL_DEFAULT_FREE(pH223Params);
+        }
+    }
+
+    if (to_be_opened_codec != PV_CODEC_TYPE_NONE)
+    {
+        FormatCapabilityInfo fci;
+        IsSupported(OUTGOING, to_be_opened_codec, fci);
+        PS_AdaptationLayerType al_type = GetOutgoingLayer(::GetMediaType(to_be_opened_codec),
+                                         fci.max_sample_size);
+        if (al_type == NULL)
+        {
+            OSCL_LEAVE(PVMFErrNoMemory);
+        }
+        OpenOutgoingChannel(to_be_opened_codec, al_type);
+        Delete_AdaptationLayerType(al_type);
+        OSCL_DEFAULT_FREE(al_type);
+        transfer_mux_tables = true;
+    }
+    if (transfer_mux_tables)
+    {
+        iTSCmt.MtTrfReq(iOlcs);
+    }
+    return(PhaseE_Comm);
+}
+
+PVMFStatus TSC_component::VerifyReverseParameters(PS_ForwardReverseParam forRevParams,
+        TSCObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_capability::VerifyReverseParameters"));
+    PVMFStatus status;
+    bool returnNow = iTSCcapability.VerifyReverseParameters(forRevParams, iTSCObserver, status);
+
+    if (returnNow)
+    {
+        return status;
+    }
+    PVCodecType_t codec = GetCodecType(&forRevParams->reverseLogicalChannelParameters.dataType);
+    PV2WayMediaType media_type = GetMediaType(codec);
+    uint8* decodeConfigInfoOblc = NULL;
+    unsigned decodeConfigInfoSzOblc =
+        ::GetFormatSpecificInfo(&forRevParams->reverseLogicalChannelParameters.dataType,
+                                decodeConfigInfoOblc);
+    // get the outgoing FSI if any
+    for (unsigned n = 0;n < iOutgoingChannelConfig->size();n++)
+    {
+        PV2WayMediaType channelMediaType = (*iOutgoingChannelConfig)[n].GetMediaType();
+        if (channelMediaType != media_type)
+        {
+            continue;
+        }
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>* formats =
+            (*iOutgoingChannelConfig)[n].GetCodecs();
+        if (!formats)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::VerifyReverseParameters No formats specified for media type(%d)",
+                             channelMediaType));
+            continue;
+        }
+        for (unsigned m = 0;m < formats->size();m++)
+        {
+            PVCodecType_t codec_type_outgoing = PVMFFormatTypeToPVCodecType((*formats)[m].format);
+            if (codec_type_outgoing != codec)
+                continue;
+            if ((*formats)[m].fsi == NULL || (*formats)[m].fsi_len == 0)
+            {
+                // There are no FSI restrictions
+                return PVMFSuccess;
+            }
+            if (decodeConfigInfoSzOblc == (*formats)[m].fsi_len &&
+                    oscl_memcmp(decodeConfigInfoOblc, (*formats)[m].fsi, decodeConfigInfoSzOblc) == 0)
+            {
+                return PVMFSuccess;
+            }
+        }
+    }
+
+    return PVMFFailure;
+}
+
+
+PVMFStatus TSC_component::ValidateOlcsWithTcs()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::ValidateOlcsWithTcs"));
+    /* Verify if local TCS is satisfied */
+    Oscl_Vector<OlcFormatInfo, OsclMemAllocator> incoming_codecs;
+    if (!iOlcs.FindCodecs(INCOMING, PV_MEDIA_NONE, OLC_ESTABLISHED,
+                          PV_DIRECTION_BOTH, incoming_codecs))
+        return PVMFSuccess;
+    /* Set symmetry info in the codecs */
+    unsigned n = 0;
+    for (n = 0;n < incoming_codecs.size();n++)
+    {
+        PV2WayMediaType media_type = GetMediaType(incoming_codecs[n].iCodec);
+        incoming_codecs[n].isSymmetric = iOlcs.IsSymmetric(media_type,
+                                         PV_DIRECTION_BOTH, OLC_PENDING | OLC_ESTABLISHED,
+                                         PV_DIRECTION_BOTH, OLC_PENDING | OLC_ESTABLISHED);
+    }
+    PVMFStatus status = VerifyCodecs(iLocalTcs, incoming_codecs, iLogger);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::ValidateOlcsWithTcs Codecs not compatible with local TCS"));
+        return status;
+    }
+
+    /* Verify if remote TCS is satisfied */
+    Oscl_Vector<OlcFormatInfo, OsclMemAllocator> outgoing_codecs;
+    if (!iOlcs.FindCodecs(OUTGOING, PV_MEDIA_NONE,
+                          OLC_PENDING | OLC_ESTABLISHED, PV_DIRECTION_BOTH, outgoing_codecs))
+        return PVMFSuccess;
+    /* Set symmetry info in the codecs */
+    for (n = 0;n < outgoing_codecs.size();n++)
+    {
+        PV2WayMediaType media_type = GetMediaType(outgoing_codecs[n].iCodec);
+        outgoing_codecs[n].isSymmetric = iOlcs.IsSymmetric(media_type,
+                                         PV_DIRECTION_BOTH,
+                                         OLC_PENDING | OLC_ESTABLISHED,
+                                         PV_DIRECTION_BOTH,
+                                         OLC_PENDING | OLC_ESTABLISHED);
+    }
+    status = VerifyCodecs(iRemoteTcs, outgoing_codecs, iLogger);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::ValidateOlcsWithTcs Codecs not compatible with remote TCS"));
+    }
+    return status;
+}
+
+OsclAny TSC_component::TcsMsdComplete()
+{
+    ClipCodecs(iRemoteTcs);
+
+    if (!iOutgoingChannelConfig || iOutgoingChannelConfig->size() == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::TcsMsdComplete No outgoing channels configured(%x)",
+                         iOutgoingChannelConfig));
+        return;
+    }
+
+    //Oscl_Vector<OlcParam*, OsclMemAllocator> olc_list;
+    CPVMultiplexEntryDescriptorVector descriptors;
+
+    // start OLCs
+    for (unsigned olcnum = 0; olcnum < iOutgoingChannelConfig->size(); olcnum++)
+    {
+        int index = -1;
+        PV2WayMediaType media_type = (*iOutgoingChannelConfig)[olcnum].GetMediaType();
+        if (!FindCodecForMediaType(media_type, iOutCodecList, &index))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::TcsMsdComplete No outgoing codec selected for media type=%d",
+                             media_type));
+            continue;
+        }
+        if (AlreadyAssigned(media_type))
+        {
+            continue;
+        }
+
+
+        PVCodecType_t incoming_codec = PV_CODEC_TYPE_NONE;
+        FormatCapabilityInfo fci;
+        IsSupported(OUTGOING, iOutCodecList[index]->codec, fci);
+        PS_AdaptationLayerType al_type = GetOutgoingLayer(media_type, fci.max_sample_size);
+        if (al_type == NULL)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::TcsMsdComplete Failed to allocate adaptation layer for media type=%d",
+                             media_type));
+            continue;
+        }
+        PS_DataType pDataTypeRvs = NULL;
+        PS_H223LogicalChannelParameters pH223ParamsRvs = NULL;
+        if (al_type->index == 5) /* AL3 */
+        {
+            incoming_codec = iOutCodecList[index]->codec;
+            pDataTypeRvs = GetOutgoingDataType(incoming_codec,
+                                               GetOutgoingBitrate(incoming_codec));
+            pH223ParamsRvs = GetH223LogicalChannelParameters((uint8)IndexForAdaptationLayer(PVT_AL3),
+                             iTSCcapability.IsSegmentable(INCOMING, media_type),
+                             iAl3ControlFieldOctets);
+        }
+
+        OlcParam* olc_param = OpenOutgoingChannel(iOutCodecList[index]->codec,
+                              al_type, pDataTypeRvs, pH223ParamsRvs);
+        if (pH223ParamsRvs)
+        {
+            Delete_H223LogicalChannelParameters(pH223ParamsRvs);
+            OSCL_DEFAULT_FREE(pH223ParamsRvs);
+        }
+        if (pDataTypeRvs)
+        {
+            Delete_DataType(pDataTypeRvs);
+            OSCL_DEFAULT_FREE(pDataTypeRvs);
+        }
+        Delete_AdaptationLayerType(al_type);
+        OSCL_DEFAULT_FREE(al_type);
+        StartOlc(olc_param, media_type, descriptors);
+    }
+    if (FinishTcsMsdComplete(descriptors))
+    {
+        iTSCmt.MtTrfReq(iOlcs);
+    }
+    // Reset flags used to force AL
+    iUseAl1Video = true;
+    iUseAl2Video = true;
+    iUseAl3Video = true;
+#ifdef MEM_TRACK
+    printf("\n Memory Stats After TcsMsdComplete");
+    MemStats();
+#endif
+}
+
+void TSC_component::SetOutgoingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& out_channel_config)
+{
+    if (iOutgoingChannelConfig)
+    {
+        OSCL_DELETE(iOutgoingChannelConfig);
+        iOutgoingChannelConfig = NULL;
+    }
+    iOutgoingChannelConfig = new Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>(out_channel_config);
+
+}
+
+void TSC_component::SetIncomingChannelConfig(Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& in_channel_config)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::SetIncomingChannelConfig size(%d)\n", in_channel_config.size()));
+    if (iIncomingChannelConfig)
+    {
+        OSCL_DELETE(iIncomingChannelConfig);
+        iIncomingChannelConfig = NULL;
+    }
+    iIncomingChannelConfig = new Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>(in_channel_config);
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event10           E_PtvId_Lc_Etb_Cfm  */
+/*  function outline     : Status04/Event10 procedure                        */
+/*  function discription : Status04Event10( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_component::LcEtbCfm(PS_ControlMsgHeader pReceiveInf)
+{
+    TPVChannelId lcn = pReceiveInf->InfSupplement1;
+    /*OlcParam* olc_param = OpenLogicalChannel(OUTGOING, lcn);
+    }
+    return PhaseE_Comm;
+    */
+    OlcParam* olc_param = iOlcs.FindOlcGivenChannel(OUTGOING, lcn);
+    if (olc_param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::LcEtbCfm ERROR Unable to lookup channel"));
+        return (PhaseE_Comm);
+    }
+    olc_param->SetState(OLC_ESTABLISHED);
+    CheckOutgoingChannel(olc_param, PVMFSuccess);
+    return PhaseE_Comm;
+
+}
+
+unsigned TSC_component::GetOutgoingBitrate(PVCodecType_t codec_type)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::GetOutgoingBitrate codec_type=%d", codec_type));
+    PV2WayMediaType media_type = GetMediaType(codec_type);
+    if (!iOutgoingChannelConfig || !iOutgoingChannelConfig->size())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::GetOutgoingBitrate outgoing channel config not found."));
+        return 0;
+    }
+    uint32 bitrate = 0;
+    for (unsigned n = 0; n < iOutgoingChannelConfig->size(); n++)
+    {
+        H324ChannelParameters& params = (*iOutgoingChannelConfig)[n];
+        if (params.GetMediaType() == media_type)
+        {
+            bitrate = params.GetBandwidth();
+            break;
+        }
+    }
+    if (bitrate == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::GetOutgoingBitrate outgoing channel bitrate=0."));
+        return bitrate;
+    }
+    // lookup the bitrate from remote capabilities
+    uint32 br = iTSCcapability.GetRemoteBitrate(codec_type);
+    bitrate = (bitrate > br) ? br : bitrate;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::GetOutgoingBitrate outgoing channel bitrate=%d.", bitrate));
+    return bitrate;
+}
+
+void TSC_component::GetChannelFormatAndCapabilities(TPVDirection dir,
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& formats)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::GetChannelFormatAndCapabilities"));
+    OlcList::iterator it = iOlcs.begin();
+
+    while (it != iOlcs.end())
+    {
+        OlcList::value_type& val = (*it++);
+        OlcParam* olc = val.second;
+        H223ChannelParam* param = NULL;
+        if (olc->GetDirection() == dir)
+        {
+            param = olc->GetForwardParams();
+        }
+        else if (olc->GetReverseParams())
+        {
+            param = olc->GetReverseParams();
+        }
+        FormatCapabilityInfo fci;
+        fci.id = param->GetChannelId();
+        fci.dir = dir;
+        fci.format = PVCodecTypeToPVMFFormatType(param->GetMediaParam()->GetCodecType());
+        fci.bitrate = param->GetBitrate();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::GetChannelFormatAndCapabilities Adding(%d,%d,%s,%d) to list",
+                         fci.dir, fci.id, fci.format.getMIMEStrPtr(), fci.bitrate));
+        formats.push_back(fci);
+    }
+}
+
+bool TSC_component::HasOlc(TPVDirection direction,
+                           TPVChannelId id,
+                           unsigned state)
+{
+    if (state)
+    {
+        return iOlcs.HasOlc(direction, id, state);
+    }
+    else
+    {
+        return iOlcs.HasOlc(direction, id);
+    }
+}
+
+OlcParam* TSC_component::FindOlcGivenChannel(TPVDirection direction,
+        TPVChannelId id)
+{
+    return iOlcs.FindOlcGivenChannel(direction, id);
+}
+
+OlcParam* TSC_component::FindOlc(TPVDirection direction,
+                                 PV2WayMediaType media_type,
+                                 unsigned state)
+{
+    return iOlcs.FindOlc(direction, media_type, state);
+}
+
+void TSC_component::LcnDataDetected(TPVChannelId lcn)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcnDataDetected - lcn=%d", lcn));
+    OlcParam* param = iOlcs.FindOlcGivenChannel(INCOMING, lcn);
+    if (param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::LcnDataDetected - Failed to lookup channel, lcn=%d", lcn));
+        return;
+    }
+    if (param->GetReplacementFor() != CHANNEL_ID_UNKNOWN)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::LcnDataDetected - Replaced channel id=%d",
+                         param->GetReplacementFor()));
+        ChannelReleased(INCOMING, param->GetReplacementFor(), PV2WayErrReplaced);
+        param->SetReplacementFor((TPVChannelId)NULL);
+    }
+}
+
+// =======================================================
+// AcceptBLCRequest()
+//
+// WWUAPI - New Function
+// =======================================================
+OsclAny TSC_component::AcceptBLCRequest(TPVChannelId OpenLcnF,
+                                        TPVChannelId OpenLcnB,
+                                        PS_ForwardReverseParam forRevParams)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: AcceptBLCRequest reverse(%d), forward(%d)\n", OpenLcnB, OpenLcnF));
+    /* RvsParameters are okay; accept the OLC */
+    iTSCblc.BlcEtbRps(OpenLcnB - TSC_INCOMING_CHANNEL_MASK, OpenLcnF);
+    // Open the incoming and outgoing logical channels in the mux
+    OlcParam* param = OpenLogicalChannel(INCOMING,
+                                         OpenLcnB,
+                                         OpenLcnF,
+                                         &forRevParams->forwardLogicalChannelParameters.dataType,
+                                         forRevParams->forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters,
+                                         &forRevParams->reverseLogicalChannelParameters.dataType,
+                                         forRevParams->reverseLogicalChannelParameters.rlcMultiplexParameters.h223LogicalChannelParameters);
+    param->SetState(OLC_ESTABLISHED);
+    /* Send updated MuxTable for outgoing part of the BLC */
+    iTSCmt.MtTrfReq(iOlcs);
+
+    uint8* fsi = NULL;
+    uint32 fsi_len = ::GetFormatSpecificInfo(&forRevParams->forwardLogicalChannelParameters.dataType, fsi);
+    iTSCObserver->IncomingChannel(OpenLcnB,
+                                  GetCodecType(&forRevParams->forwardLogicalChannelParameters.dataType),
+                                  fsi, fsi_len);
+
+    if (OpenLcnF == CHANNEL_ID_UNKNOWN ||
+            GetCodecType(param->GetReverseParams()->GetDataType()) == PV_CODEC_TYPE_NONE)
+        return;
+
+    // Pause the channel untill OlcAck+MtAck is received
+    H223OutgoingChannelPtr outgoing_channel;
+    iH223->GetOutgoingChannel(OpenLcnF, outgoing_channel);
+    outgoing_channel->Pause();
+    // Notify outgoing channel
+    fsi_len = GetFormatSpecificInfo(&forRevParams->reverseLogicalChannelParameters.dataType, fsi);
+    iTSCObserver->OutgoingChannelEstablished(OpenLcnF,
+            GetCodecType(&forRevParams->reverseLogicalChannelParameters.dataType),
+            fsi, fsi_len);
+}
+
+// =============================================================
+// Status04Event11()                     E_PtvId_Lc_Rls_Idc
+//
+// This is LCSE RELEASE.indication.
+// =============================================================
+uint32 TSC_component::LcRlsIdc(PS_ControlMsgHeader  pReceiveInf)
+{
+    TPVDirection dir = (pReceiveInf->Dir == S_ControlMsgHeader::INCOMING) ? INCOMING : OUTGOING;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcRlsIdc dir(%d), lcn(%d).",
+                     dir, pReceiveInf->InfSupplement1));
+    TPVChannelId lcn = (dir == INCOMING) ? (TPVChannelId)(pReceiveInf->InfSupplement1 +
+                       TSC_INCOMING_CHANNEL_MASK) : (TPVChannelId)pReceiveInf->InfSupplement1;
+    PS_SourceCause_LcBlc sourceCause = (PS_SourceCause_LcBlc)pReceiveInf->pParameter;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcRlsIdc sourceCause(%x), cause index(%d)",
+                     sourceCause, sourceCause->Cause.index));
+    PVMFStatus status = PVMFSuccess;
+
+    OlcParam* olc_param = iOlcs.FindOlcGivenChannel(dir, lcn);
+    if (olc_param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::LcRlsIdc ERROR Unable to lookup channel"));
+        return (PhaseE_Comm);
+    }
+
+    if (dir == OUTGOING)
+    {
+        if (olc_param->GetState() == OLC_PENDING)
+        {
+            // only valid rejection code is m/s conflict
+            if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == SLAVE &&
+                    sourceCause->Cause.index == 10)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::LcRlsIdc Reject due to M/S conflict"));
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::LcRlsIdc Olc failure"));
+                status = PVMFFailure;
+            }
+        }
+    }
+    else if (dir == INCOMING)
+    {
+        RemoveMultiplex(olc_param);
+    }
+    ChannelReleased(dir, lcn, status);
+    return(PhaseE_Comm);
+}
+
+// =============================================================
+// Status04Event16()                   E_PtvId_Blc_Rls_Idc
+//
+// This is BLCSE RELEASE.indication.  It is called when
+// a Bi-Dir OLCReject is received.  It could be from an incoming or outgoing SE
+// =============================================================
+uint32 TSC_component::BlcRlsIdc(PS_ControlMsgHeader  pReceiveInf)
+{
+    PS_SourceCause_LcBlc sourceCause = (PS_SourceCause_LcBlc)pReceiveInf->pParameter;
+    int32 causeIndex = sourceCause->Cause.index;
+    TPVDirection dir = OUTGOING;
+    TPVChannelId lcn = (TPVChannelId)pReceiveInf->InfSupplement1;;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::BlcRlsIdc BLC rejected. dir(%d), forward lcn(%d), reverse lcn(%d), cause index(%d)",
+                     dir, pReceiveInf->InfSupplement1, pReceiveInf->InfSupplement2, causeIndex));
+
+    if (pReceiveInf->Dir == S_ControlMsgHeader::INCOMING)
+    {
+        dir = INCOMING;
+        lcn += TSC_INCOMING_CHANNEL_MASK;
+    }
+
+    PVMFStatus status = PVMFSuccess;
+    PVCodecType_t to_be_opened_codec = PV_CODEC_TYPE_NONE;
+    PV2WayMediaType media_type = PV_MEDIA_NONE;
+
+    if (dir == OUTGOING)
+    {
+        OlcParam* olc_param = iOlcs.FindOlcGivenChannel(OUTGOING, lcn);
+        if (olc_param != NULL)
+        {
+            media_type = GetMediaType(olc_param->GetForwardParams()->GetDataType());
+            if (olc_param->GetState() == OLC_PENDING)
+            {
+                if (causeIndex == 1)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "TSC_component::BlcRlsIdc UnsuitableReverseParams. Entering wait state ..."));
+                    /* Cause is unsuitableReverseParameters; Enter wait state */
+                    iWaitingForOblc = true;
+                    iWaitingForOblcCodec = GetCodecType(olc_param->GetForwardParams()->GetDataType());
+                    iWaitingForOblcTimer->Request(PV_TSC_WAITING_FOR_OBLC_TIMER_ID,
+                                                  PV_TSC_WAITING_FOR_OBLC_TIMER_ID , WAITING_FOR_OBLC_TIMEOUT_SECONDS, this);
+                }
+                else if (iTSCstatemanager.ReadState(TSC_MSD_DECISION) == SLAVE &&
+                         causeIndex == 10)
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "TSC_component::BlcRlsIdc Master/Slave conflict"));
+                    // is there is a pending outgoing OLC for the same media type ?
+                    Oscl_Vector<OlcParam*, OsclMemAllocator> pending_olc_list;
+                    if (iOlcs.FindOlcs(OUTGOING, media_type, OLC_PENDING, pending_olc_list))
+                    {
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                        (0, "TSC_component::BlcRlsIdc Pending outgoing OLCs(%d) found for incoming media type(%d).",
+                                         pending_olc_list.size(), media_type));
+                        OSCL_ASSERT(pending_olc_list.size() == 1);
+                        OlcParam* param = pending_olc_list[0];
+                        to_be_opened_codec = GetCodecType(param->GetForwardParams()->GetDataType());
+                    }
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                    (0, "TSC_component::BlcRlsIdc Olc failure"));
+                    status = PVMFFailure;
+                }
+            }
+        }
+    }
+    else if (dir == INCOMING)
+    {
+        lcn += TSC_INCOMING_CHANNEL_MASK;
+    }
+    ChannelReleased(dir, lcn, status);
+
+    if (to_be_opened_codec == PV_CODEC_TYPE_NONE)
+        return PhaseE_Comm;
+    FormatCapabilityInfo fci;
+    IsSupported(OUTGOING, to_be_opened_codec, fci);
+    PS_AdaptationLayerType al_type = GetOutgoingLayer(media_type, fci.max_sample_size);
+    if (al_type == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    OpenOutgoingChannel(to_be_opened_codec, al_type);
+    Delete_AdaptationLayerType(al_type);
+    OSCL_DEFAULT_FREE(al_type);
+    iTSCmt.MtTrfReq(iOlcs);
+    return(PhaseE_Comm);
+}
+
+OsclAny TSC_component::MuxTableSendComplete(uint32 sn, PVMFStatus status)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC::MuxTableSendComplete sn(%d), status(%d)", sn, status));
+    if (!iTSCmt.MuxTableSendComplete(sn))
+    {
+        return;
+    }
+    Oscl_Vector<OlcParam*, OsclMemAllocator> olc_list;
+    unsigned num_pending = iOlcs.FindOutgoingOlcsByMtState(MT_PENDING, olc_list);
+    for (unsigned lcn = 0;lcn < num_pending;lcn++)
+    {
+        //OSCL_ASSERT(olc_list[lcn]->GetMtSn()==sn);
+        olc_list[lcn]->SetMtState(status == PVMFSuccess ? MT_COMPLETE : MT_RELEASED);
+        if (olc_list[lcn]->GetState() == OLC_ESTABLISHED)
+        {
+            CheckOutgoingChannel(olc_list[lcn], status);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::MuxTableSendComplete Mux table completed, but channel still pending. channel id=(%d)", olc_list[lcn]->GetChannelId()));
+        }
+    }
+    iTSCmt.ReleaseMuxTables();
+}
+
+// ===============================================================
+// StopData()
+//
+// Sets flags in the H324 system table which stop data transmission
+// for each open, outgoing logical channel.
+// ================================================================
+OsclAny TSC_component::StopData()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::StopData"));
+    OlcList::iterator it = iOlcs.begin();
+    while (it != iOlcs.end())
+    {
+        OlcParam* olc = (*it++).second;
+        iH223->StopChannel(olc->GetDirection(), olc->GetChannelId());
+        if (olc->GetReverseParams())
+        {
+            iH223->StopChannel(olc->GetReverseParams()->GetDirection(),
+                               olc->GetReverseParams()->GetChannelId());
+        }
+    }
+}
+
+// bool whether level is unknown
+bool TSC_component::Connect1LevelKnown()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iLogger, PVLOGMSG_NOTICE,
+                    (0, "TSC_component::Connect"));
+    bool levelknown = true;
+    iWaitingForOblc = false;
+    iWaitingForOblcCodec = PV_CODEC_TYPE_NONE;
+
+
+    if (iOutgoingChannelConfig == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    if (iIncomingChannelConfig == NULL)
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    iWaitingForOblcTimer->Clear();
+    return levelknown;
+}
+
+void TSC_component::Connect2()
+{
+    H223PduParcomSharedPtr parcom;
+    iH223->Start(parcom);
+}
+
+// =======================================================
+// ClipCodecs()									(RAN-32K)
+//
+// This one reconciles the desired outgoing codecs with the
+//   capabilities of the remote terminal.  The outgoing
+//   codecs have been specified by the application via calls
+//   to pH324.SetVideoType(), pH324.SetAudioType().  The
+//   remote terminal capabilities from the received
+//   TerminalCapabilitySet are passed in (pTcs).
+// If insufficient capabilities are found, the routine will
+//   modify the outgoing codecs stored in pH324.
+// =======================================================
+OsclAny TSC_component::ClipCodecs(PS_TerminalCapabilitySet pTcs)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::ClipCodecs(%d,%d)",
+                     pTcs->size_of_capabilityTable,
+                     pTcs->size_of_capabilityDescriptors));
+    if (!(pTcs->option_of_capabilityTable && pTcs->option_of_capabilityDescriptors))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::ClipCodecs - Remote terminal is incapable of decoding anything"));
+        return;
+    }
+    if (!iOutgoingChannelConfig || iOutgoingChannelConfig->size() == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::ClipCodecs - We dont want to send anything.  Skip ClipCodecs."));
+        return;
+    }
+    PS_CapabilityDescriptor pCapDesc = NULL;
+    PS_AlternativeCapabilitySet pAltCapSet = NULL;
+    for (unsigned i = 0;i < pTcs->size_of_capabilityDescriptors;++i)
+    {
+        pCapDesc = pTcs->capabilityDescriptors + i;
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::ClipCodecs - descriptor(%d),size_of_simultaneousCapabilities(%d)",
+                         i, pCapDesc->size_of_simultaneousCapabilities));
+        /* Temporary list of selected codecs.  Retain the codecs for descriptor with most matching codecs */
+        Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> codec_list;
+        /* A changing list of available media for outgoing channels.  Once a codec is selected,
+           the entry for that media is removed from this list */
+        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc> outgoing_media(*iOutgoingChannelConfig);
+        if (pCapDesc->size_of_simultaneousCapabilities != iOutgoingChannelConfig->size())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_component::ClipCodecs - descriptor(%d),size_of_simultaneousCapabilities does not match num channels(%d)", i, iOutgoingChannelConfig->size()));
+        }
+
+        for (unsigned j = 0;j < pCapDesc->size_of_simultaneousCapabilities;++j)
+        {
+            bool txOnly = true;
+            pAltCapSet = pCapDesc->simultaneousCapabilities + j;
+            // Get the list of codecs in this ACS
+            Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> codecs_acs;
+            uint16 num_media_types = GetCodecCapabilityInfo(pTcs, pAltCapSet, codecs_acs);
+            if (num_media_types != 1)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::ClipCodecs - ERROR:  Badly formed AlternativeCapabilitySet j=%d, num media types=%d", j, num_media_types));
+                Deallocate(codecs_acs);
+                continue;
+            }
+
+            //Check for tx only capabilities
+            for (unsigned k = 0; k < codecs_acs.size(); ++k)
+            {
+                if (codecs_acs[k]->dir != OUTGOING)
+                {
+                    txOnly = false;
+                    break;
+                }
+            }
+            if (txOnly)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::ClipCodecs: tx only codecs"));
+                Deallocate(codecs_acs);
+                continue;
+            }
+
+            PV2WayMediaType mediaType = GetMediaType(codecs_acs[0]->codec);
+            if (mediaType != PV_AUDIO && mediaType != PV_VIDEO)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_component::ClipCodecs:  Media type in AlternativeCapabilitySet j=%d is neither audio/video, media type=%d", j, mediaType));
+                Deallocate(codecs_acs);
+                continue;
+            }
+            // Get the list of our incoming codecs for this media type
+            Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> in_codecs_for_media_type;
+            iTSCcapability.GetSupportedCodecCapabilityInfo(INCOMING, mediaType, in_codecs_for_media_type);
+
+            // Do either side have symmetry constraints ?
+            bool local_has_symmetry_constraint = iTSCcapability.HasSymmetryConstraint(in_codecs_for_media_type);
+            bool remote_has_symmetry_constraint = iTSCcapability.HasSymmetryConstraint(codecs_acs);
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::ClipCodecs mediaType=%d, local_has_symmetry_constraint=%d, remote_has_symmetry_constraint=%d", mediaType, local_has_symmetry_constraint, remote_has_symmetry_constraint));
+            CodecCapabilityInfo* selected_codec_info;
+            if (local_has_symmetry_constraint || remote_has_symmetry_constraint)
+            {
+                selected_codec_info = iTSCcapability.SelectOutgoingCodec(&codecs_acs,
+                                      &in_codecs_for_media_type);
+            }
+            else
+            {
+                selected_codec_info = iTSCcapability.SelectOutgoingCodec(&codecs_acs);
+            }
+            if (selected_codec_info)
+                codec_list.push_back(selected_codec_info->Copy());
+            Deallocate(codecs_acs);
+            Deallocate(in_codecs_for_media_type);
+        }
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::ClipCodecs codec_list size=%d, iOutCodecList size=%d",
+                         codec_list.size(), iOutCodecList.size()));
+        if (codec_list.size() > iOutCodecList.size())
+        {
+            /* found a match */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::ClipCodecs Match found for descriptor(%d), size(%d)",
+                             i, pCapDesc->size_of_simultaneousCapabilities));
+            Deallocate(iOutCodecList);
+            iOutCodecList = codec_list;
+            for (unsigned num = 0;num < iOutCodecList.size();num++)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_component::ClipCodecs Selected codec(%d)=%d",
+                                 num, codec_list[num]->codec));
+            }
+        }
+        else
+        {
+            Deallocate(codec_list);
+        }
+    }
+}
+
+void TSC_component::Start()
+{
+    if (iOutgoingChannelConfig == NULL || iIncomingChannelConfig == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::Start here"));
+    }
+
+}
+
+void TSC_component::StartDisconnect(bool terminate)
+{
+    if (terminate)
+    {
+        StopData();
+        CloseChannels();
+        Deallocate(iOutCodecList);
+    }
+}
+
+void TSC_component::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timeoutInfo);
+    if (timerID == PV_TSC_WAITING_FOR_OBLC_TIMER_ID)
+    {
+        iWaitingForOblc = false;
+        iWaitingForOblcCodec = PV_CODEC_TYPE_NONE;
+    }
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event19          E_PtvId_Clc_Cls_Idc  */
+/*  function outline     : Status08/Event19 procedure                        */
+/*  function discription : Status08Event19( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_component::Status08Event19(PS_ControlMsgHeader pReceiveInf)
+{
+    TPVChannelId ClcLcn = CHANNEL_ID_UNKNOWN;
+    uint32 Directional = 0;          /* UNI=1, BI=2 */
+
+    /* (RECEIVED AN INCOMING RequestChannelClose) */
+    /* Input parameters */
+    ClcLcn = (TPVChannelId)pReceiveInf->InfSupplement1;         /* Channel requested to be closed */
+    Directional = pReceiveInf->InfSupplement2;    /* Directionality */
+    if (Directional != 1 && Directional != 2)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::Status08Event19 Invalid directionality"));
+        iTSCclc.ClcRjtReq(ClcLcn);
+        return (PhaseE_Comm);
+    }
+
+    if (!HasOlc(OUTGOING, ClcLcn))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_component::Status08Event19 unable to lookup outgoing channel id(%d)",
+                         ClcLcn));
+        iTSCclc.ClcRjtReq(ClcLcn);
+        return (PhaseE_Comm);
+    }
+
+    /* Primitive Send */
+    iTSCclc.ClcClsRps(ClcLcn);            /* Send RCCAck Message */
+
+    ChannelReleased(OUTGOING, ClcLcn, PVMFSuccess);
+
+    /* Send the H.245 CloseLogicalChannel message */
+    if (Directional == 1)          /* UniDirectional */
+    {
+        TPVDirection dir = iTSClc.LcRlsReq(RELEASE_CLOSE, ClcLcn, 0);
+        RemoveOlc(dir, ClcLcn);
+    }
+    else if (Directional == 2)     /* BiDirectional */
+    {
+        TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_CLOSE, ClcLcn, 0);
+        RemoveOlc(dir, ClcLcn);
+    }
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event15          E_PtvId_Blc_Etb_Cfm  */
+/*  function outline     : Status04/Event15 procedure                        */
+/*  function discription : Status04Event15( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_component::BlcEtbCfm(PS_ControlMsgHeader pReceiveInf)
+{
+    TPVChannelId incoming_lcn = pReceiveInf->InfSupplement2 + TSC_INCOMING_CHANNEL_MASK;
+    OlcParam* olc_param = iOlcs.FindOlcGivenChannel(OUTGOING, pReceiveInf->InfSupplement1);
+    if (olc_param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::BlcEtbCfm ERROR Unable to lookup channel"));
+        return PhaseE_Comm;
+    }
+    olc_param->SetState(OLC_ESTABLISHED);
+
+    // Resume the channel if MT is also complete
+    CheckOutgoingChannel(olc_param, PVMFSuccess);
+
+    if (olc_param->GetReverseParams())
+    {
+        // Set the incoming logical channel number
+        olc_param->GetReverseParams()->SetChannelId(incoming_lcn);
+        // Open the incoming channel in the mux
+        OpenPort(INCOMING,
+                 olc_param->GetReverseParams()->GetChannelId(),
+                 olc_param->GetReverseParams());
+
+        uint8* fsi = NULL;
+        uint32 fsi_len = ::GetFormatSpecificInfo(olc_param->GetReverseParams()->GetDataType(), fsi);
+        iTSCObserver->IncomingChannel(incoming_lcn,
+                                      GetCodecType(olc_param->GetReverseParams()->GetDataType()),
+                                      fsi, fsi_len);
+    }
+    return PhaseE_Comm;
+}
+
+
+// =============================================================
+// Status04Event50()                  E_PtvId_Blc_Etb_Cfm2
+//
+// This is "BLCSE ESTABLISH.confirm2"
+// It is called when SE receives an OLCConfirm (Bi-Dir).
+// =============================================================
+uint32 TSC_component::BlcEtbCfm2(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::BlcEtbCfm2 forward(%d), reverse(%d))\n",
+                     pReceiveInf->InfSupplement1, pReceiveInf->InfSupplement2));
+    OlcParam* olc_param = iOlcs.FindOlcGivenChannel(INCOMING,
+                          pReceiveInf->InfSupplement1 + TSC_INCOMING_CHANNEL_MASK);
+    if (olc_param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::BlcEtbCfm ERROR Unable to lookup channel"));
+        return PhaseE_Comm;
+    }
+    olc_param->SetState(OLC_ESTABLISHED);
+    // Resume the channel if MT is also complete
+    CheckOutgoingChannel(olc_param, PVMFSuccess);
+    return PhaseE_Comm;
+}
+
+
+/*****************************************************************************/
+/*  function name        : Status08Event12           E_PtvId_Lc_Rls_Cfm  */
+/*  function outline     : Status08/Event12 procedure                        */
+/*  function discription : Status08Event12( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '00.4.13                                          */
+/*---------------------------------------------------------------------------*/
+uint32 TSC_component::LcRlsCfm(PS_ControlMsgHeader  pReceiveInf)
+{
+    TPVChannelId lcn = (TPVChannelId) pReceiveInf->InfSupplement1;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcRlsCfm - lcn(%d)\n", lcn));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::LcRlsCfm - lcn(%d)\n", lcn));
+    ChannelReleased(OUTGOING, lcn, PVMFSuccess);
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event17          E_PtvId_Blc_Rls_Cfm  */
+/*  function outline     : Status08/Event17 procedure                        */
+/*  function discription : Status08Event17( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '00.4.13                                         */
+/*---------------------------------------------------------------------------*/
+/* RAN - Bi-Dir OLCAck */
+uint32 TSC_component::BlcRlsCfm(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::BlcRlsCfm - forward(%d), reverse(%d)",
+                     pReceiveInf->InfSupplement1, pReceiveInf->InfSupplement2));
+    ChannelReleased(OUTGOING,
+                    pReceiveInf->InfSupplement1, PVMFSuccess);
+    return PhaseE_Comm;
+}
+
+LogicalChannelInfo* TSC_component::GetLogicalChannelInfo(PVMFPortInterface& port)
+{
+    return iTSCchannelcontrol.GetLogicalChannelInfo(port);
+}
+
+void TSC_component::ReceivedFormatSpecificInfo(TPVChannelId channel_id,
+        uint8* fsi,
+        uint32 fsi_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::ReceivedFormatSpecificInfo lcn=%d, len=%d",
+                     channel_id, fsi_len));
+    iTSCchannelcontrol.ReceivedFormatSpecificInfo(channel_id, fsi, fsi_len);
+}
+
+bool TSC_component::IsEstablishedLogicalChannel(TPVDirection aDir,
+        TPVChannelId aChannelId)
+{
+    return iTSCchannelcontrol.IsEstablishedLogicalChannel(aDir, aChannelId);
+}
+
+
+void TSC_component::RemoveOlc(TPVDirection dir, TPVChannelId lcn)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::RemoveOlc lcn(%d), dir(%d)", lcn, dir));
+    OlcKey key(dir, lcn);
+    OlcList::iterator iter = iOlcs.find(key);
+    if (iter == iOlcs.end())
+        return;
+    OlcParam* param = (*iter).second;
+
+    if ((dir == OUTGOING || param->GetReverseParams()) &&
+            (param->GetMtNum() && (param->GetMtSn() >= 0)) &&
+            IsRemovable(lcn))
+    {
+        iTSCmt.DeleteMuxEntry(param->GetMtNum());
+    }
+
+    iTSCmt.ReleaseMuxTables();
+
+    if (iter != iOlcs.end())
+    {
+        delete(*iter).second;
+        iOlcs.erase(iter);
+    }
+}
+
+void TSC_component::ReleaseOlc(OlcParam* olc, uint16 cause)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::ReleaseOlc olc(%x), reason(%d))", olc, cause));
+    int release_type = (olc->GetDirection() == OUTGOING) ? RELEASE_CLOSE : RELEASE_REJECT;
+
+    if (olc->GetDirectionality() == EPVT_UNI_DIRECTIONAL)
+    {
+        iTSClc.LcRlsReq(release_type, olc->GetChannelId(), cause);
+    }
+    else
+    {
+        iTSCblc.BlcRlsReq(release_type, olc->GetChannelId(), cause);
+    }
+}
+
+/* This function just does the h.245 signalling for closing a logical channel - incoming/outgoing */
+void TSC_component::SignalChannelClose(TPVDirection dir,
+                                       TPVChannelId lcn,
+                                       TPVDirectionality directionality)
+{
+    /* Multiplex entries must have failed.  Close the channel */
+    if (dir == OUTGOING)
+    {
+        if (directionality == EPVT_BI_DIRECTIONAL)
+        {
+            TPVDirection dir = iTSCblc.BlcRlsReq(RELEASE_CLOSE, lcn, 0);
+            RemoveOlc(dir, lcn);
+        }
+        else
+        {
+            TPVDirection dir = iTSClc.LcRlsReq(RELEASE_CLOSE, lcn, 0);
+            RemoveOlc(dir, lcn);
+        }
+    }
+    else
+    {
+        iTSCclc.ClcClsReq(lcn);
+    }
+}
+
+void TSC_component::CheckOutgoingChannel(OlcParam* olc_param, PVMFStatus status)
+{
+    TPVChannelId id = (olc_param->GetDirection() == OUTGOING) ?
+                      olc_param->GetChannelId() : olc_param->GetReverseParams()->GetChannelId();
+    PVCodecType_t codec_type = olc_param->GetDirection() == OUTGOING ?
+                               GetCodecType(olc_param->GetForwardParams()->GetDataType()) :
+                               GetCodecType(olc_param->GetReverseParams()->GetDataType());
+    OSCL_UNUSED_ARG(codec_type);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::CheckOutgoingChannel channel id=%d, codec type=%d, status=%d",
+                     olc_param->GetChannelId(), codec_type, status));
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::CheckOutgoingChannel Channel open failed"));
+        ChannelReleased(OUTGOING, olc_param->GetChannelId(), status);
+        return;
+    }
+    if (olc_param->GetMtState() != MT_COMPLETE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::CheckOutgoingChannel channel id=%d Mux table send not complete",
+                         olc_param->GetChannelId()));
+        return;
+    }
+    // OLC+MT is complete.  Resume the channel.
+    H223OutgoingChannelPtr outgoing_channel;
+    status = iH223->GetOutgoingChannel(id, outgoing_channel);
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::CheckOutgoingChannel ERROR Failed to lookup channel."));
+        return;
+    }
+    outgoing_channel->Resume();
+    // Request fast update from the engine
+    iTSCObserver->RequestFrameUpdate(outgoing_channel);
+}
+
+OsclAny TSC_component::ChannelReleased(TPVDirection dir, TPVChannelId lcn, PVMFStatus status)
+{
+    OSCL_UNUSED_ARG(status);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::ChannelReleased dir(%d), lcn(%d), status(%d)",
+                     dir, lcn, status));
+    OlcParam* olc_param = iOlcs.FindOlcGivenChannel(dir, lcn);
+    if (olc_param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_channelcontrol::ChannelReleased Failed to lookup channel(%d), lcn(%d)\n",
+                         dir, lcn));
+        return;
+    }
+
+    if (dir == OUTGOING || olc_param->GetState() == OLC_ESTABLISHED)
+    {
+        iTSCObserver->ChannelClosed(dir,
+                                    lcn,
+                                    ::GetCodecType(olc_param->GetForwardParams()->GetDataType()),
+                                    status);
+    }
+    if (olc_param->GetDirectionality() == EPVT_BI_DIRECTIONAL)
+    {
+        TPVChannelId rvs_lcn = olc_param->GetReverseParams()->GetChannelId();
+        if (rvs_lcn &&
+                (rvs_lcn != CHANNEL_ID_UNKNOWN) &&
+                (dir == INCOMING || olc_param->GetState() == OLC_ESTABLISHED))
+        {
+            iTSCObserver->ChannelClosed(REVERSE_DIR(dir),
+                                        rvs_lcn,
+                                        ::GetCodecType(olc_param->GetReverseParams()->GetDataType()),
+                                        status);
+        }
+    }
+
+    RemoveOlc(dir, lcn);
+}
+
+void TSC_component::CloseChannels()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::CloseChannels "));
+    OlcList::iterator it = iOlcs.begin();
+    while (it != iOlcs.end())
+    {
+        OlcParam* olc = (*it++).second;
+        ChannelReleased(olc->GetDirection(), olc->GetChannelId(), PVMFSuccess);
+        it = iOlcs.begin();
+    }
+}
+
+
+OlcParam* TSC_component::OpenLogicalChannel(TPVDirection dir,
+        TPVChannelId lcn,
+        TPVChannelId lcnRvs,
+        PS_DataType dt,
+        PS_H223LogicalChannelParameters lcp,
+        PS_DataType dtRvs,
+        PS_H223LogicalChannelParameters lcpRvs)
+{
+
+    OSCL_UNUSED_ARG(lcpRvs);
+    OSCL_UNUSED_ARG(dtRvs);
+    OSCL_UNUSED_ARG(lcp);
+    OSCL_UNUSED_ARG(dt);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::OpenLogicalChannel dir(%d), lcn(%d), dt(%x), lcp(%x), lcnRvs(%d), dtRvs(%x), lcpRvs(%x)\n", dir, lcn, dt, lcp, lcnRvs, dtRvs, lcpRvs));
+    // add to list of channels
+    OlcParam* olc_param = iOlcs.FindOlcGivenChannel(dir, lcn);
+    if (olc_param == NULL)
+    {
+        SignalChannelClose(dir, lcn, lcnRvs == CHANNEL_ID_UNKNOWN ? EPVT_UNI_DIRECTIONAL : EPVT_BI_DIRECTIONAL);
+        return NULL;
+    }
+
+    /* Is this a replacement channel outgoing channel ? */
+    if (dir == OUTGOING && olc_param->GetReplacementFor() != CHANNEL_ID_UNKNOWN)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_channelcontrol::OpenLogicalChannel Replacement for outgoing channel id=%d",
+                         olc_param->GetReplacementFor()));
+        ChannelReleased(OUTGOING, olc_param->GetReplacementFor(), PV2WayErrReplaced);
+        olc_param->SetReplacementFor(0);
+    }
+
+    if (olc_param->GetReverseParams())
+        olc_param->GetReverseParams()->SetChannelId(lcnRvs);
+
+    TPVDirection rvs_dir = REVERSE_DIR(dir);
+    OpenPort(dir, lcn, olc_param->GetForwardParams());
+    if (olc_param->GetReverseParams() &&
+            olc_param->GetReverseParams()->GetChannelId() != CHANNEL_ID_UNKNOWN)
+    {
+        OpenPort(rvs_dir, olc_param->GetReverseParams()->GetChannelId(),
+                 olc_param->GetReverseParams());
+    }
+    return olc_param;
+}
+void TSC_component::OpenPort(TPVDirection dir, TPVChannelId lcn, H223ChannelParam* param)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_channelcontrol::OpenPort dir(%d), lcn(%d), param(%x)\n",
+                     dir, lcn, param));
+    PVCodecType_t codec_type = ::GetCodecType(param->GetDataType());
+    if (codec_type == PV_CODEC_TYPE_NONE)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_channelcontrol::OpenPort codec_type==NONE", codec_type));
+        return;
+    }
+    iH223->OpenChannel(dir, lcn, param);
+}
+
+
+PS_DataType TSC_component::GetOutgoingDataType(PVCodecType_t codecType,
+        uint32 bitrate)
+{
+    uint8* csi = NULL;
+    uint16 csi_len = 0;
+    return iTSCcapability.GetOutgoingDataType(codecType, bitrate, csi_len, csi);
+}
+
+OlcParam* TSC_component::OpenOutgoingChannel(PVCodecType_t out_codec_type,
+        PS_AdaptationLayerType adaptation_layer,
+        PS_DataType pDataTypeRvs,
+        PS_H223LogicalChannelParameters pH223ParamsRvs)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_component::OpenOutgoingChannel codec(%d), layer(%x)",
+                     out_codec_type, adaptation_layer));
+    OlcParam* ret = NULL;
+    // allocate a channel id for this channel
+    TPVChannelId channel_id = iOlcs.GetNextAvailLcn();
+    uint32 bitrate = GetOutgoingBitrate(out_codec_type);
+
+    /* Fill the data type for the outgoing codec */
+    PS_DataType pDataType = GetOutgoingDataType(out_codec_type, bitrate);
+
+    /*  Fill the outgoing h223 logical channel parameters */
+    PS_H223LogicalChannelParameters pH223Params =
+        iTSCcapability.GetOutgoingLcnParams(GetMediaType(out_codec_type),
+                                            adaptation_layer);
+    if (adaptation_layer->index == 5)
+    { /* AL3 */
+        S_DataType nullDataType;
+        if (pDataTypeRvs == NULL)
+        {
+            nullDataType.index = 1;
+            pDataTypeRvs = &nullDataType;
+        }
+        if (pH223ParamsRvs == NULL)
+        {
+            pH223ParamsRvs = pH223Params;
+        }
+        PVCodecType_t in_codec_type = GetCodecType(pDataTypeRvs);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_component::OpenOutgoingChannel reverse codec(%d)", in_codec_type));
+        if (in_codec_type != out_codec_type)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_component::OpenOutgoingChannel in codec type != out codec type"));
+        }
+        if (!CodecRequiresFsi(out_codec_type))
+        {
+            iTSCblc.BlcEtbReq(channel_id, pDataType, pH223Params,
+                              pDataTypeRvs, pH223ParamsRvs);
+        }
+        ret = iOlcs.AppendOlc(OUTGOING, channel_id, pDataType, pH223Params,
+                              CHANNEL_ID_UNKNOWN, pDataTypeRvs,
+                              pH223ParamsRvs);
+    }
+    else
+    {
+        if (!CodecRequiresFsi(out_codec_type))
+        {
+            iTSClc.LcEtbReq(channel_id, pDataType, pH223Params);
+        }
+
+        ret = iOlcs.AppendOlc(OUTGOING, channel_id, pDataType, pH223Params);
+    }
+
+    // Open the channel in the mux
+    OpenLogicalChannel(OUTGOING, ret->GetChannelId());
+    // Pause the channel untill OlcAck+MtAck is received
+    H223OutgoingChannelPtr outgoing_channel;
+    iH223->GetOutgoingChannel(ret->GetChannelId(), outgoing_channel);
+    if (Pausable())
+    {
+        outgoing_channel->Pause();
+    }
+    // Notify outgoing channel
+    iTSCObserver->OutgoingChannelEstablished(ret->GetChannelId(), out_codec_type,
+            NULL, 0); /* FSI will be generated by video source/encoder */
+
+    Delete_DataType(pDataType);
+    OSCL_DEFAULT_FREE(pDataType);
+    Delete_H223LogicalChannelParameters(pH223Params);
+    OSCL_DEFAULT_FREE(pH223Params);
+    return ret;
+}
+
+
+bool TSC_component::queryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    // Only returns the component interface
+    if (uuid == PVUuidH324ComponentInterface)
+    {
+        PVMFComponentInterface* myInterface = OSCL_STATIC_CAST(PVMFComponentInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
+    else
+    {
+        return false;
+    }
+
+    return true;
+}
+
+#ifdef MEM_TRACK
+void TSC_component::MemStats()
+{
+#if !(OSCL_BYPASS_MEMMGT)
+
+    OsclAuditCB auditCB;
+    OsclMemInit(auditCB);
+    if (auditCB.pAudit)
+    {
+        MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
+        if (stats)
+        {
+            printf("\n###################Memory Stats Start#################\n");
+            printf("  numBytes %d\n", stats->numBytes);
+            printf("  peakNumBytes %d\n", stats->peakNumBytes);
+            printf("  numAllocs %d\n", stats->numAllocs);
+            printf("  peakNumAllocs %d\n", stats->peakNumAllocs);
+            printf("  numAllocFails %d\n", stats->numAllocFails);
+            printf("  totalNumAllocs %d\n", stats->totalNumAllocs);
+            printf("  totalNumBytes %d\n", stats->totalNumBytes);
+            printf("\n###################Memory Stats End###################\n");
+        }
+
+    }
+#endif
+}
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_componentregistry.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_componentregistry.cpp
new file mode 100644
index 0000000..30d1892
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_componentregistry.cpp
@@ -0,0 +1,67 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "tsc_componentregistry.h"
+
+TSCComponentRegistry::TSCComponentRegistry(TSC_statemanager& aTSCStateManager,
+        TSC_capability& aTSCcapability,
+        TSC_lc& aTSClc,
+        TSC_blc& aTSCblc,
+        TSC_clc& aTSCclc,
+        TSC_mt& aTSCmt) :
+        iTSCstatemanager(aTSCStateManager),
+        iTSCcapability(aTSCcapability),
+        iTSClc(aTSClc),
+        iTSCblc(aTSCblc),
+        iTSCclc(aTSCclc),
+        iTSCmt(aTSCmt)
+{
+}
+
+void TSCComponentRegistry::QueryRegistry(Tsc324mNodeCommand& aCmd)
+{
+
+    OSCL_String* mimetype;
+    Oscl_Vector<PVUuid, OsclMemAllocator>* uuidvec;
+    bool exactMatch;
+    aCmd.Parse(mimetype, uuidvec, exactMatch);
+
+//    uuidvec->clear();
+    if (*mimetype == (TSC_COMPONENT_MIME_TYPE))
+    {
+        uuidvec->push_back((PVUuidH324ComponentInterface));
+    }
+}
+
+TSC_component* TSCComponentRegistry::Create(PVMFSessionId aSession,
+        const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    TSC_component* component = NULL;
+    if (aUuid == PVUuidH324ComponentInterface)
+    {
+        component = OSCL_NEW(TSC_component,
+                             (iTSCstatemanager, iTSCcapability, iTSClc, iTSCblc, iTSCclc, iTSCmt));
+        aInterfacePtr = (PVMFComponentInterface*)component;
+    }
+    return component;
+}
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_eventreceive.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_eventreceive.cpp
new file mode 100644
index 0000000..c7629d1
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_eventreceive.cpp
@@ -0,0 +1,212 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_eventreceive.c                                */
+/*  file contents        : Event Id Receive                                  */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include "oscl_types.h"
+#include "oscl_mem.h"
+#include "h245inf.h"
+#include "tsc_eventreceive.h"
+
+/*---------------------------------------------------------------------------*/
+/*  Variable  Definition                                                     */
+/*---------------------------------------------------------------------------*/
+typedef struct _eventidtable
+{
+    uint32      EventId;                /* EventId                   */
+    uint32      EventInfType;           /* EventType                 */
+    uint32      EventInfId;             /* EventId(receive)          */
+} S_EventIdTable;
+
+// -------------------------------------------------------------
+// New event table for User Events (App<->Tsc).  These are now
+//   handled separately from the SE<->Tsc events.  (RAN)
+// -------------------------------------------------------------
+static  const S_EventIdTable      UserEventIdTable[] =
+{
+//        {  1,  H245_USER     ,  E_User_Ce_Instruct          },
+    {  2,  H245_USER     ,  E_User_Mt_Instruct          },
+    {  3,  H245_USER     ,  E_User_Mr_Instruct          },
+    {  4,  H245_USER     ,  E_User_Rtd_Instruct         },
+    {  5,  H245_USER     ,  E_User_Ml_Instruct          },
+    {  6,  H245_USER     ,  E_User_Rme_Instruct         },
+    {  7,  H245_USER     ,  E_User_Stcs_Instruct        },
+    {  8,  H245_USER     ,  E_User_Hmr_Instruct         },
+    {  9,  H245_USER     ,  E_User_Rcc_Instruct         },
+    { 10,  H245_USER     ,  E_User_Clc_Instruct         },
+    { 44,  H245_USER     ,  E_User_Consent              },
+    { 45,  H245_USER     ,  E_User_Reject               },
+    { 50,  H245_USER     ,  E_User_Close                },
+    { 51,  H245_USER     ,  E_User_NonProcedure         },
+    {  0,  0             ,  0                       }
+};
+
+// -------------------------------------------------------------
+// The original event table for SE<->Tsc events.  The user
+//   events have been removed.  (RAN)
+// -------------------------------------------------------------
+static  const S_EventIdTable      EventIdTable[] =
+{
+//        {  2,  H245_PRIMITIVE,  E_PtvId_Msd_Dtm_Idc         },
+//        {  3,  H245_PRIMITIVE,  E_PtvId_Msd_Dtm_Cfm         },
+//        {  4,  H245_PRIMITIVE,  E_PtvId_Msd_Rjt_Idc         },
+//        {  5,  H245_PRIMITIVE,  E_PtvId_Msd_Err_Idc         },
+//        {  6,  H245_PRIMITIVE,  E_PtvId_Ce_Trf_Idc          },
+//        {  7,  H245_PRIMITIVE,  E_PtvId_Ce_Trf_Cfm          },
+//        {  8,  H245_PRIMITIVE,  E_PtvId_Ce_Rjt_Idc          },
+    {  9,  H245_PRIMITIVE,  E_PtvId_Lc_Etb_Idc          },
+    { 10,  H245_PRIMITIVE,  E_PtvId_Lc_Etb_Cfm          },
+    { 11,  H245_PRIMITIVE,  E_PtvId_Lc_Rls_Idc          },
+    { 12,  H245_PRIMITIVE,  E_PtvId_Lc_Rls_Cfm          },
+    { 13,  H245_PRIMITIVE,  E_PtvId_Lc_Err_Idc          },
+    { 14,  H245_PRIMITIVE,  E_PtvId_Blc_Etb_Idc         },
+    { 15,  H245_PRIMITIVE,  E_PtvId_Blc_Etb_Cfm         },
+    { 16,  H245_PRIMITIVE,  E_PtvId_Blc_Rls_Idc         },
+    { 17,  H245_PRIMITIVE,  E_PtvId_Blc_Rls_Cfm         },
+    { 18,  H245_PRIMITIVE,  E_PtvId_Blc_Err_Idc         },
+    { 19,  H245_PRIMITIVE,  E_PtvId_Clc_Cls_Idc         },
+    { 20,  H245_PRIMITIVE,  E_PtvId_Clc_Cls_Cfm         },
+    { 21,  H245_PRIMITIVE,  E_PtvId_Clc_Rjt_Idc         },
+    { 22,  H245_PRIMITIVE,  E_PtvId_Mt_Trf_Idc          },
+    { 23,  H245_PRIMITIVE,  E_PtvId_Mt_Trf_Cfm          },
+    { 24,  H245_PRIMITIVE,  E_PtvId_Mt_Rjt_Idc          },
+    { 25,  H245_PRIMITIVE,  E_PtvId_Rme_Send_Idc        },
+    { 26,  H245_PRIMITIVE,  E_PtvId_Rme_Send_Cfm        },
+    { 27,  H245_PRIMITIVE,  E_PtvId_Rme_Rjt_Idc         },
+    { 28,  H245_PRIMITIVE,  E_PtvId_Mr_Trf_Idc          },
+    { 29,  H245_PRIMITIVE,  E_PtvId_Mr_Trf_Cfm          },
+    { 30,  H245_PRIMITIVE,  E_PtvId_Mr_Rjt_Idc          },
+    { 31,  H245_PRIMITIVE,  E_PtvId_Rtd_Trf_Cfm         },
+    { 32,  H245_PRIMITIVE,  E_PtvId_Rtd_Exp_Idc         },
+    { 33,  H245_PRIMITIVE,  E_PtvId_Ml_Loop_Idc         },
+    { 34,  H245_PRIMITIVE,  E_PtvId_Ml_Loop_Cfm         },
+    { 35,  H245_PRIMITIVE,  E_PtvId_Ml_Rls_Idc          },
+    { 36,  H245_PRIMITIVE,  E_PtvId_Ml_Err_Idc          },
+    { 37,  H245_PRIMITIVE,  E_PtvId_Cmd_Es_Cfm          },
+    { 38,  H245_ERROR    ,  H245_INTERNAL_ERROR_TSC     },
+    { 38,  H245_ERROR    ,  H245_INTERNAL_ERROR_SE      },
+    { 38,  H245_ERROR    ,  H245_INTERNAL_ERROR_SRP     },
+    // NOTE: Tsc currently has no handling for Event38.
+
+    { 49,  H245_PRIMITIVE,  E_PtvId_Nsd_Req_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Nsd_Rps_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Nsd_Cmd_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Nsd_Idc_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cm_Req_Cfm          },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cm_Rps_Cfm          },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cm_Cmd_Cfm          },
+    { 49,  H245_PRIMITIVE,  E_PtvId_H223aar_Cfm         },  /* Not a codeword! (RAN) */
+    { 49,  H245_PRIMITIVE,  E_PtvId_H223aar_Ack_Cfm     },  /* Not a codeword! (RAN) */
+    { 49,  H245_PRIMITIVE,  E_PtvId_H223aar_Rjt_Cfm     },  /* Not a codeword! (RAN) */
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cnf_Req_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cnf_Rps_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cmd_Ecrpt_Cfm       },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cmd_Es_Cfm          },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Cmd_Cnf_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Fnu_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Jtr_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Nwatmvc_Cfm     },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Cnf_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_H2250mxskw_Cfm  },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Mclct_Cfm       },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Fns_Cfm         },
+    { 49,  H245_PRIMITIVE,  E_PtvId_Idc_Fc_Cfm          },
+    /* WWU_BLC: added table entries */
+    { 50,  H245_PRIMITIVE,	E_PtvId_Blc_Etb_Cfm2		},
+    { 52,  H245_PRIMITIVE,  E_PtvId_Cmd_Stcs_Cfm        }, /* RAN STCS */
+    { 53,  H245_PRIMITIVE,  E_PtvId_Cmd_Fc_Cfm          }, /* RAN FC */
+    { 54,  H245_PRIMITIVE,  E_PtvId_Cmd_Mscl_Cfm        }, /* RAN MSCL */
+    { 55,  H245_PRIMITIVE,  E_PtvId_Cmd_Hmr_Cfm         }, /* RAN HMR */
+    { 56,  H245_PRIMITIVE,  E_PtvId_Idc_Vi_Cfm          },
+    { 57,  H245_PRIMITIVE,  E_PtvId_Idc_Ui_Cfm          }, /* AR: 2SD*/
+    { 58,  H245_PRIMITIVE,  E_PtvId_Idc_Mscl_Cfm        },
+    { 59,  H245_PRIMITIVE,  E_PtvId_Idc_H223skw_Cfm     },
+    { 60,  H245_PRIMITIVE,  E_PtvId_Cmd_Fc          }, /* AR FC */
+    {  0,  0             ,  0                       }
+};
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_EventReceive                                  */
+/*  function outline     : Event Id Receive procedure                        */
+/*  function discription : Tsc_EventReceive(pReceiveInf)                     */
+/*  input data           : PS_InfHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Event Id                     */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 Tsc_EventReceive(PS_ControlMsgHeader  pReceiveInf)
+{
+
+    for (uint32 Cnt = 0; EventIdTable[Cnt].EventId != 0; ++Cnt)
+    {
+        if (((uint32)EventIdTable[Cnt].EventInfType == pReceiveInf->InfType) &&
+                ((uint32)EventIdTable[Cnt].EventInfId == pReceiveInf->InfId))
+        {
+            return(EventIdTable[Cnt].EventId);
+        }
+    }
+    return 0;
+}
+
+//===================================================================
+// Tsc_UserEventLookup()                     (RAN) 6/26/00
+//
+// This one is added to process user events from App layer.
+// It searches the UserEventIdTable to get the event ID, which
+//   it then returns to the calling routine.
+// NOTE: This routine differs from Tsc_EventReceive() in that
+//   it doesn't pull the contents of pReceiveInf from a queue.
+//   It instead assumes the contents are already there, having
+//   been passed to Tsc by a direct call from the App layer.
+//====================================================================
+uint32 Tsc_UserEventLookup(PS_ControlMsgHeader pReceiveInf)
+{
+    if (pReceiveInf != NULL)
+    {
+        // Look up the UserEventId
+        for (uint32 Cnt = 0; UserEventIdTable[Cnt].EventId != 0; ++Cnt)
+        {
+            if (((uint32)UserEventIdTable[Cnt].EventInfType == pReceiveInf->InfType) &&
+                    ((uint32)UserEventIdTable[Cnt].EventInfId == pReceiveInf->InfId))
+            {
+                return(UserEventIdTable[Cnt].EventId);
+            }
+        }
+        return 0;  // None found
+    }
+    return 0;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_h324m_config.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_h324m_config.cpp
new file mode 100644
index 0000000..fcbaf01
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_h324m_config.cpp
@@ -0,0 +1,1932 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "tsc_h324m_config.h"
+#include "oscl_mem.h"
+#include "pv_interface_cmd_message.h"
+#include "pvlogger.h"
+
+enum PVH234MessageType
+{
+    PVT_H324_COMMAND_QUERY_INTERFACE,
+    PVT_H324_COMMAND_SET_H223_LEVEL,
+    PVT_H324_COMMAND_SET_MAX_SDU_SIZE,
+    PVT_H324_COMMAND_SET_MAX_SDU_SIZE_R,
+    PVT_H324_COMMAND_SEND_RME,
+    PVT_H324_COMMAND_SET_AL2_SEQ_NUM,
+    PVT_H324_COMMAND_SET_CONTROL_FIELD_OCTETS,
+    PVT_H324_COMMAND_SET_MAX_PDU_SIZE,
+    PVT_H324_COMMAND_SET_TERMINAL_TYPE,
+    PVT_H324_COMMAND_SET_MAX_MUX_PDU_SIZE,
+    PVT_H324_COMMAND_SET_MAX_MUX_CCSRL_SDU_SIZE,
+    PVT_H324_COMMAND_SEND_RTD,
+    PVT_H324_COMMAND_SET_VENDOR_ID,
+    PVT_H324_COMMAND_SEND_VENDOR_ID,
+    PVT_H324_COMMAND_SEND_END_SESSION,
+    PVT_H324_COMMAND_SET_END_SESSION_TIMEOUT,
+    PVT_H324_COMMAND_SET_AL_CONFIGURATION,
+    PVT_H324_COMMAND_SET_TIMER_COUNTER,
+    PVT_H324_COMMAND_SET_VIDEO_RESOLUTIONS,
+    PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND,
+    PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION,
+    PVT_H324_COMMAND_SEND_SKEW_INDICATION,
+    PVT_H324_COMMAND_SET_FAST_CSUP_OPTIONS,
+    PVT_H324_COMMAND_SET_LOGICAL_CHANNEL_BUFFERING_MS,
+    PVT_H324_COMMAND_SEND_USER_INPUT,
+    PVT_H324_COMMAND_SET_WNSRP
+};
+
+class CPVH324InterfaceCmdMessage : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        CPVH324InterfaceCmdMessage(TPVCmnCommandType aType,
+                                   OsclAny* aContextData,
+                                   TPVCmnCommandId aId)
+                : CPVCmnInterfaceCmdMessage(aType, aContextData)
+        {
+            SetId(aId);
+        }
+        PVMFCmdResp GetResponse(PVMFCommandId aId,
+                                const OsclAny* aContext,
+                                PVMFStatus aStatus,
+                                OsclAny* aEventData = NULL)
+        {
+            return PVMFCmdResp(aId, aContext, aStatus, aEventData);
+        }
+    private:
+        //PVMFCmdResp iResp;
+};
+
+class PVH324MessageQueryInterface : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageQueryInterface(const PVUuid& aUuid,
+                                    PVInterface*& aInterfacePtr,
+                                    OsclAny* aContextData,
+                                    TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_QUERY_INTERFACE, aContextData, aId),
+                iUuid(aUuid),
+                iInterfacePtr(aInterfacePtr)
+        {
+            somenumber = 101;
+        }
+        int somenumber;
+        PVUuid iUuid;
+        PVInterface*& iInterfacePtr;
+};
+
+class PVH324MessageSetH223Level : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetH223Level(TPVH223Level aLevel,
+                                  OsclAny* aContextData,
+                                  TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_H223_LEVEL, aContextData, aId)
+                , iH223Level(aLevel)
+        {}
+
+        TPVH223Level iH223Level;
+};
+
+class PVH324MessageSetMaxSduSize : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetMaxSduSize(TPVAdaptationLayer aAl,
+                                   uint32 aSize,
+                                   OsclAny* aContextData,
+                                   TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_MAX_SDU_SIZE, aContextData, aId)
+                , iAl(aAl)
+                , iSize(aSize)
+        {}
+
+        TPVAdaptationLayer iAl;
+        uint32 iSize;
+};
+
+class PVH324MessageSetMaxSduSizeR : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetMaxSduSizeR(TPVAdaptationLayer aAl,
+                                    uint32 aSize,
+                                    OsclAny* aContextData,
+                                    TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_MAX_SDU_SIZE_R, aContextData, aId)
+                , iAl(aAl)
+                , iSize(aSize)
+        {}
+
+        TPVAdaptationLayer iAl;
+        uint32 iSize;
+};
+
+class PVH324MessageSendRme : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendRme(OsclAny* aContextData,
+                             TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_RME, aContextData, aId)
+        {}
+};
+
+class PVH324MessageSetAl2SequenceNumbers : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetAl2SequenceNumbers(int32 aSeqNumWidth,
+                                           OsclAny* aContextData,
+                                           TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_AL2_SEQ_NUM, aContextData, aId)
+                , iSeqNumWidth(aSeqNumWidth)
+        {}
+
+        int32 iSeqNumWidth;
+};
+
+class PVH324MessageSetAl3ControlFieldOctets : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetAl3ControlFieldOctets(int32 aCfo,
+                                              OsclAny* aContextData,
+                                              TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_CONTROL_FIELD_OCTETS, aContextData, aId)
+                , iCfo(aCfo)
+        {}
+
+        int32 iCfo;
+};
+
+class PVH324MessageSetMaxPduSize : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetMaxPduSize(int32 aMaxPduSize,
+                                   OsclAny* aContextData,
+                                   TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_MAX_PDU_SIZE, aContextData, aId)
+                , iMaxPduSize(aMaxPduSize)
+        {}
+
+        int32 iMaxPduSize;
+};
+
+class PVH324MessageSetTerminalType : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetTerminalType(uint8 aTerminalType,
+                                     OsclAny* aContextData,
+                                     TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_TERMINAL_TYPE, aContextData, aId)
+                , iTerminalType(aTerminalType)
+        {}
+
+        uint8 iTerminalType;
+};
+
+class PVH324MessageSetMaxMuxPduSize : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetMaxMuxPduSize(int32 aMaxMuxPduSize,
+                                      OsclAny* aContextData,
+                                      TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_MAX_MUX_PDU_SIZE, aContextData, aId)
+                , iMaxMuxPduSize(aMaxMuxPduSize)
+        {}
+
+        int32 iMaxMuxPduSize;
+};
+
+class PVH324MessageSetMaxMuxCcsrlSduSize : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetMaxMuxCcsrlSduSize(int32 aMaxMuxCcsrlSduSize,
+                                           OsclAny* aContextData,
+                                           TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_MAX_MUX_CCSRL_SDU_SIZE, aContextData, aId)
+                , iMaxMuxCcsrlSduSize(aMaxMuxCcsrlSduSize)
+        {}
+
+        int32 iMaxMuxCcsrlSduSize;
+};
+
+class PVH324MessageSendRtd : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendRtd(OsclAny* aContextData,
+                             TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_RTD, aContextData, aId)
+        {}
+};
+
+class PVH324MessageSetVendorId : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetVendorId(uint8 cc, uint8 ext, uint32 mc,
+                                 OsclAny* aContextData,
+                                 TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_VENDOR_ID, aContextData, aId),
+                iCc(cc), iExt(ext), iMc(mc),
+                iProduct(NULL), iProductLen(0), iVersion(NULL), iVersionLen(0)
+        {}
+        ~PVH324MessageSetVendorId()
+        {
+            if (iProduct)
+                OSCL_DEFAULT_FREE(iProduct);
+            if (iVersion)
+                OSCL_DEFAULT_FREE(iVersion);
+        }
+
+        bool SetProduct(const uint8* product, uint16 product_len)
+        {
+            if (iProduct) OSCL_DEFAULT_FREE(iProduct);
+            iProduct = NULL;
+            iProductLen = 0;
+            iProduct = (uint8*)OSCL_DEFAULT_MALLOC(product_len);
+            if (iProduct)
+            {
+                iProductLen = product_len;
+                oscl_memcpy(iProduct, product, iProductLen);
+            }
+            return (iProduct) ? true : false;
+        }
+        bool SetVersion(const uint8* version, uint16 version_len)
+        {
+            if (iVersion) OSCL_DEFAULT_FREE(iVersion);
+            iVersion = NULL;
+            iVersionLen = 0;
+            iVersion = (uint8*)OSCL_DEFAULT_MALLOC(version_len);
+            if (iVersion)
+            {
+                iVersionLen = version_len;
+                oscl_memcpy(iVersion, version, iVersionLen);
+            }
+            return (iVersion) ? true : false;
+        }
+        uint8 iCc;
+        uint8 iExt;
+        uint32 iMc;
+        uint8* iProduct;
+        uint16 iProductLen;
+        uint8* iVersion;
+        uint16 iVersionLen;
+};
+
+class PVH324MessageSendVendorId : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendVendorId(OsclAny* aContextData, TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_VENDOR_ID, aContextData, aId)
+        {}
+};
+
+class PVH324MessageEndSession : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageEndSession(OsclAny* aContextData, TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_END_SESSION, aContextData, aId)
+        {}
+};
+
+class PVH324MessageSetEndSessionTimeout : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetEndSessionTimeout(uint32 timeout,
+                                          OsclAny* aContextData,
+                                          TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_END_SESSION_TIMEOUT, aContextData, aId),
+                iTimeout(timeout)
+        {}
+        uint32 iTimeout;
+};
+
+class PVH324MessageSetALConfiguration : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetALConfiguration(TPVMediaType_t aMediaType,
+                                        TPVAdaptationLayer aLayer,
+                                        bool aAllow,
+                                        OsclAny* aContextData,
+                                        TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_AL_CONFIGURATION, aContextData, aId),
+                iMediaType(aMediaType),
+                iLayer(aLayer),
+                iAllow(aAllow)
+        {}
+        TPVMediaType_t iMediaType;
+        TPVAdaptationLayer iLayer;
+        bool iAllow;
+};
+
+class PVH324MessageSetTimerCounter: public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetTimerCounter(TPVH324TimerCounter aTimerCounter,
+                                     uint8 aSeries,
+                                     uint32 aSeriesOffset,
+                                     uint32 aValue,
+                                     OsclAny* aContextData,
+                                     TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_TIMER_COUNTER, aContextData, aId),
+                iTimerCounter(aTimerCounter),
+                iSeries(aSeries),
+                iSeriesOffset(aSeriesOffset),
+                iValue(aValue)
+        {}
+        TPVH324TimerCounter iTimerCounter;
+        uint8 iSeries;
+        uint32 iSeriesOffset;
+        uint32 iValue;
+};
+
+class PVH324MessageSetVideoResolutions : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetVideoResolutions(TPVDirection aDirection,
+                                         Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+                                         OsclAny* aContextData,
+                                         TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_VIDEO_RESOLUTIONS, aContextData, aId),
+                iDirection(aDirection),
+                iResolutions(aResolutions)
+        {}
+        TPVDirection iDirection;
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator> iResolutions;
+};
+
+class PVH324MessageSendVideoSpatialTemporalTradeoffCommand : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendVideoSpatialTemporalTradeoffCommand(TPVChannelId aLogicalChannel,
+                uint8 aTradeoff,
+                OsclAny* aContextData,
+                TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND, aContextData, aId),
+                iLogicalChannel(aLogicalChannel),
+                iTradeoff(aTradeoff)
+        {}
+        TPVChannelId iLogicalChannel;
+        uint8 iTradeoff;
+};
+
+class PVH324MessageSendVideoSpatialTemporalTradeoffIndication : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendVideoSpatialTemporalTradeoffIndication(TPVChannelId aLogicalChannel,
+                uint8 aTradeoff,
+                OsclAny* aContextData,
+                TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION, aContextData, aId),
+                iLogicalChannel(aLogicalChannel),
+                iTradeoff(aTradeoff)
+        {}
+        TPVChannelId iLogicalChannel;
+        uint8 iTradeoff;
+};
+
+class PVH324MessageSendSkewIndication : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendSkewIndication(TPVChannelId aLogicalChannel1,
+                                        TPVChannelId aLogicalChannel2,
+                                        uint16 aSkew,
+                                        OsclAny* aContextData,
+                                        TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SEND_SKEW_INDICATION, aContextData, aId),
+                iLogicalChannel1(aLogicalChannel1),
+                iLogicalChannel2(aLogicalChannel2),
+                iSkew(aSkew)
+        {}
+        TPVChannelId iLogicalChannel1;
+        TPVChannelId iLogicalChannel2;
+        uint16 iSkew;
+};
+
+class PVH324MessageSetLogicalChannelBufferingMs : public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+                uint32 aOutBufferingMs,
+                OsclAny* aContextData,
+                TPVCmnCommandId aId)
+                : CPVCmnInterfaceCmdMessage(PVT_H324_COMMAND_SET_LOGICAL_CHANNEL_BUFFERING_MS, aContextData),
+                iInLogicalChannelBufferingMs(aInBufferingMs),
+                iOutLogicalChannelBufferingMs(aOutBufferingMs)
+        {
+            OSCL_UNUSED_ARG(aId);
+        }
+        uint32 iInLogicalChannelBufferingMs;
+        uint32 iOutLogicalChannelBufferingMs;
+};
+
+class PVH324MessageSendUserInput: public CPVCmnInterfaceCmdMessage
+{
+    public:
+        PVH324MessageSendUserInput(OsclAny* aContextData,
+                                   TPVCmnCommandId aId)
+                : CPVCmnInterfaceCmdMessage(PVT_H324_COMMAND_SEND_USER_INPUT, aContextData),
+                iUserInput(NULL)
+        {
+            OSCL_UNUSED_ARG(aId);
+        }
+        ~PVH324MessageSendUserInput()
+        {
+            SetUserInput(NULL);
+        }
+        void SetUserInput(CPVUserInput* input)
+        {
+            if (iUserInput)
+            {
+                delete iUserInput;
+                iUserInput = NULL;
+            }
+            if (input)
+            {
+                iUserInput = input->Copy();
+            }
+        }
+        CPVUserInput* iUserInput;
+};
+
+class PVH324MessageSetWnsrp : public CPVH324InterfaceCmdMessage
+{
+    public:
+        PVH324MessageSetWnsrp(bool wnsrp,
+                              OsclAny* aContextData,
+                              TPVCmnCommandId aId)
+                : CPVH324InterfaceCmdMessage(PVT_H324_COMMAND_SET_WNSRP, aContextData, aId),
+                iWnsrp(wnsrp)
+        {}
+        bool iWnsrp;
+};
+
+class PVH324MessageUtils
+{
+    public:
+        static void DestroyMessage(CPVCmnInterfaceCmdMessage *aCmd)
+        {
+            switch (aCmd->GetType())
+            {
+                case PVT_H324_COMMAND_QUERY_INTERFACE:
+                    OSCL_DELETE((PVH324MessageQueryInterface*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_H223_LEVEL:
+                    OSCL_DELETE((PVH324MessageSetH223Level*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_MAX_SDU_SIZE:
+                    OSCL_DELETE((PVH324MessageSetMaxSduSize*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_MAX_SDU_SIZE_R:
+                    OSCL_DELETE((PVH324MessageSetMaxSduSizeR*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_RME:
+                    OSCL_DELETE((PVH324MessageSendRme*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_AL2_SEQ_NUM:
+                    OSCL_DELETE((PVH324MessageSetAl2SequenceNumbers*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_CONTROL_FIELD_OCTETS:
+                    OSCL_DELETE((PVH324MessageSetAl3ControlFieldOctets*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_MAX_PDU_SIZE:
+                    OSCL_DELETE((PVH324MessageSetMaxPduSize*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_TERMINAL_TYPE:
+                    OSCL_DELETE((PVH324MessageSetTerminalType*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_MAX_MUX_PDU_SIZE:
+                    OSCL_DELETE((PVH324MessageSetMaxMuxPduSize*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_MAX_MUX_CCSRL_SDU_SIZE:
+                    OSCL_DELETE((PVH324MessageSetMaxMuxCcsrlSduSize*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_RTD:
+                    OSCL_DELETE((PVH324MessageSendRtd*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_VENDOR_ID:
+                    OSCL_DELETE((PVH324MessageSetVendorId*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_VENDOR_ID:
+                    OSCL_DELETE((PVH324MessageSendVendorId*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_END_SESSION:
+                    OSCL_DELETE((PVH324MessageEndSession*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_END_SESSION_TIMEOUT:
+                    OSCL_DELETE((PVH324MessageSetEndSessionTimeout*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_AL_CONFIGURATION:
+                    OSCL_DELETE((PVH324MessageSetALConfiguration*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_TIMER_COUNTER:
+                    OSCL_DELETE((PVH324MessageSetTimerCounter*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_VIDEO_RESOLUTIONS:
+                    OSCL_DELETE((PVH324MessageSetVideoResolutions*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND:
+                    OSCL_DELETE((PVH324MessageSendVideoSpatialTemporalTradeoffCommand*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION:
+                    OSCL_DELETE((PVH324MessageSendVideoSpatialTemporalTradeoffIndication*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_SKEW_INDICATION:
+                    OSCL_DELETE((PVH324MessageSendSkewIndication*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_LOGICAL_CHANNEL_BUFFERING_MS:
+                    OSCL_DELETE((PVH324MessageSetLogicalChannelBufferingMs*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SEND_USER_INPUT:
+                    OSCL_DELETE((PVH324MessageSendUserInput*)aCmd);
+                    break;
+                case PVT_H324_COMMAND_SET_WNSRP:
+                    OSCL_DELETE((PVH324MessageSetWnsrp*)aCmd);
+                    break;
+                default:
+                    break;
+            }
+        }
+};
+
+
+/////////////////////////////////////////////////
+// H324MConfig
+/////////////////////////////////////////////////
+H324MConfig::H324MConfig(TSC_324m *aH324M, bool aUseAO) :
+        OsclActiveObject(OsclActiveObject::EPriorityNominal, "H324MConfig"),
+        iH324M(aH324M),
+        iReferenceCount(0),
+        iLogger(NULL),
+        iCommandId(1),
+        iObserver(NULL),
+        iUseAO(aUseAO)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h324mconfig");
+    addRef();
+    iH324M->SetTSC_324mObserver((TSC_324mObserver*)this);
+}
+
+H324MConfig::~H324MConfig()
+{
+    // Gkl
+    iH324M->SetTSC_324mObserver(NULL);
+}
+
+void H324MConfig::SetObserver(H324MConfigObserver* aObserver)
+{
+    iObserver = aObserver;
+}
+
+void H324MConfig::Run()
+{
+    unsigned i = 0;
+    for (i = 0;i < iPendingResponses.size();i++)
+    {
+        iObserver->H324MConfigCommandCompletedL(iPendingResponses[i]);
+    }
+    iPendingResponses.clear();
+
+    for (i = 0;i < iPendingEvents.size();i++)
+    {
+        iObserver->H324MConfigHandleInformationalEventL(iPendingEvents[i]);
+    }
+    iPendingEvents.clear();
+}
+
+PVMFCommandId H324MConfig::SetMultiplexLevel(TPVH223Level aLevel, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetMultiplexLevel(aLevel);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetMaxSduSize(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetSduSize(OUTGOING, (uint16)aSize, aLayer);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetMaxSduSizeR(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetSduSize(INCOMING, (uint16)aSize, aLayer);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetAl2SequenceNumbers(int32 aSeqNumWidth, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetAl2Sn(aSeqNumWidth);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetAl3ControlFieldOctets(int32 aCfo, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetAl3ControlFieldOctets(aCfo);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetOutoingPduType(TPVH223MuxPduType aOutgoingPduType, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetMaxOutgoingPduSize((uint16)aOutgoingPduType);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetMaxPduSize(int32 aMaxPduSize, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetMaxMuxPduSize((uint16)aMaxPduSize);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetTerminalType(uint8 aTerminalType, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetTerminalType(aTerminalType);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetALConfiguration(TPVMediaType_t aMediaType, TPVAdaptationLayer aLayer,
+        bool aAllow, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetAlConfig(aMediaType, aLayer, aAllow);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SendRme(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->RmeSendReq();
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+
+PVMFCommandId H324MConfig::SetMaxMuxPduSize(int32 aRequestMaxMuxPduSize, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetMaxMuxPduSize((uint16)aRequestMaxMuxPduSize);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetMaxMuxCcsrlSduSize(int32 aMaxCcsrlSduSize, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetMaxCcsrlSduSize(aMaxCcsrlSduSize);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::FastUpdate(PVMFNodeInterface& aTrack, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aTrack);
+    OSCL_UNUSED_ARG(aContextData);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SendRtd(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->RtdTrfReq();
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetVendor(uint8 aCc, uint8 aExt, uint32 aMc,
+                                     const uint8* aProduct, uint16 aProductLen,
+                                     const uint8* aVersion, uint16 aVersionLen,
+                                     OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+
+    TPVH245Vendor* h245vendor = new TPVVendorH221NonStandard(aCc, aExt, aMc);
+    iH324M->SetVendorIdInfo(h245vendor,
+                            aProduct, aProductLen,
+                            aVersion, aVersionLen);
+    delete h245vendor;
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SendEndSession(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->EndSessionCommand();
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetEndSessionTimeout(uint32 aTimeout, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetEndSessionTimeout(aTimeout);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfig::SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+        uint8 aSeries, uint32 aSeriesOffset,
+        uint32 aValue,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetTimerCounter(aTimerCounter, aSeries, aSeriesOffset, aValue);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SetVideoResolutions(TPVDirection aDirection,
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetVideoResolutions(aDirection, aResolutions);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SendVendorId(OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->Tsc_IdcVi();
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfig::SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SendVideoTemporalSpatialTradeoffCommand(aLogicalChannel, aTradeoff);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfig::SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SendVideoTemporalSpatialTradeoffIndication(aLogicalChannel, aTradeoff);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfig::SendSkewIndication(TPVChannelId aLogicalChannel1, TPVChannelId aLogicalChannel2, uint16 aSkew,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SendSkewIndication(aLogicalChannel1, aLogicalChannel2, aSkew);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+
+PVMFCommandId
+H324MConfig::SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+        uint32 aOutBufferingMs,
+        OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetLogicalChannelBufferingMs(aInBufferingMs, aOutBufferingMs);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+PVMFCommandId
+H324MConfig::SendUserInput(CPVUserInput* aUserInput,
+                           OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    switch (aUserInput->GetType())
+    {
+        case EAlphanumeric:
+            CPVUserInputAlphanumeric *alpha;
+
+            alpha = (CPVUserInputAlphanumeric *) aUserInput;
+
+            if ((alpha->GetInput() == NULL) || (alpha->GetLength() == 0))
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                (0, "H324MConfig::SendUserInput invalid alphanumeric string, ptr %x, len %d!\n",
+                                 alpha->GetInput(), alpha->GetLength()));
+                OSCL_LEAVE(PVMFErrArgument);
+            }
+            iH324M->Tsc_UII_Alphanumeric(alpha->GetInput(), alpha->GetLength());
+            break;
+
+        case EDtmf:
+            CPVUserInputDtmf *dtmf;
+            dtmf = (CPVUserInputDtmf *) aUserInput;
+            iH324M->Tsc_UII_DTMF(dtmf->GetInput(), dtmf->GetDuration());
+            break;
+
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "H324MConfig::SendUserInput invalid user input type!\n"));
+            OSCL_LEAVE(PVMFErrArgument);
+            break;
+    }
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfig::SetWnsrp(const bool aEnableWnsrp,
+                                    OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aContextData);
+    iH324M->SetWnsrp(aEnableWnsrp);
+    SendCmdResponse(iCommandId, aContextData, PVMFSuccess);
+    return iCommandId++;
+}
+
+////////////////////////////////////
+// PVInterface virtuals
+////////////////////////////////////
+void H324MConfig::addRef()
+{
+    if (iReferenceCount == 0 && iUseAO)
+        AddToScheduler();
+    iReferenceCount++;
+}
+
+void H324MConfig::removeRef()
+{
+    if (--iReferenceCount == 0)
+    {
+        OSCL_DELETE(this);
+    }
+}
+
+bool H324MConfig::queryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr)
+{
+    aInterfacePtr = NULL;
+
+    if (aUuid == PVUidProxiedInterface)
+    {
+        H324MProxiedInterface* proxied_interface_ptr = NULL;
+        proxied_interface_ptr = OSCL_NEW(H324MProxiedInterface, ());
+        proxied_interface_ptr->SetH324M(iH324M);
+        aInterfacePtr = proxied_interface_ptr;
+        return true;
+    }
+    else
+    {
+        // could have several interfaces we may be looking for here.
+        //here add way to get the component interface.
+        // do in steps.  First- you know what you want.
+        if (iH324M->QueryInterface(0, aUuid, aInterfacePtr))
+            return true;
+    }
+
+    return false;
+}
+
+void H324MConfig::SendCmdResponse(PVMFCommandId id, OsclAny* context, PVMFStatus status)
+{
+    PVMFCmdResp resp(id, context, status);
+    if (iUseAO)
+    {
+        iPendingResponses.push_back(resp);
+        RunIfNotReady();
+    }
+    else
+    {
+        iObserver->H324MConfigCommandCompletedL(resp);
+    }
+}
+
+void H324MConfig::SendAsyncEvent(PVMFAsyncEvent& event)
+{
+    if (iUseAO)
+    {
+        iPendingEvents.push_back(event);
+        RunIfNotReady();
+    }
+    else
+    {
+        iObserver->H324MConfigHandleInformationalEventL(event);
+    }
+}
+
+void H324MConfig::IncomingVendorId(TPVH245Vendor* vendor,
+                                   const uint8* pn, uint16 pn_len,
+                                   const uint8* vn, uint16 vn_len)
+{
+    OSCL_UNUSED_ARG(vendor);
+    OSCL_UNUSED_ARG(pn);
+    OSCL_UNUSED_ARG(pn_len);
+    OSCL_UNUSED_ARG(vn);
+    OSCL_UNUSED_ARG(vn_len);
+}
+
+void H324MConfig::UserInputReceived(CPVUserInput* aUI)
+{
+    OSCL_UNUSED_ARG(aUI);
+#if 0
+    int error;
+    TPV2WayEventInfo* aEvent = NULL;
+    switch (aUI)
+    {
+        case EAlphanumeric:
+        case EDtmf:
+            OSCL_TRY(error, aEvent = GetEventInfoL());
+            OSCL_FIRST_CATCH_ANY(error,
+                                 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                                                 (0, "H324MConfig::UserInputReceived unable to notify app!\n"));
+                                 return EPVT_Failed);
+
+            aEvent->type = PVT_INDICATION_USER_INPUT;
+            (CPVUserInput *)&aEvent->localBuffer[0] = aUI;
+            aEvent->localBufferSize = 4;
+
+            Dispatch(aEvent);
+            break;
+
+        default:
+            break;
+    }
+#endif
+}
+
+void H324MConfig::UserInputCapability(int formats)
+{
+    PVMFAsyncEvent event(PVMFInfoEvent, PV_INDICATION_USER_INPUT_CAPABILITY, NULL, NULL);
+    oscl_memset(event.GetLocalBuffer(), 0, PVMF_ASYNC_EVENT_LOCAL_BUF_SIZE);
+    event.GetLocalBuffer()[0] = (uint8)(formats & 0xFF);
+    SendAsyncEvent(event);
+}
+
+void H324MConfig::VideoSpatialTemporalTradeoffCommandReceived(TPVChannelId id, uint8 tradeoff)
+{
+    PVMFAsyncEvent event(PVMFInfoEvent, PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND, NULL, NULL);
+    oscl_memset(event.GetLocalBuffer(), 0, PVMF_ASYNC_EVENT_LOCAL_BUF_SIZE);
+    event.GetLocalBuffer()[0] = (uint8)((id >> 8) & 0xFF);
+    event.GetLocalBuffer()[1] = (uint8)(id & 0xFF);
+    event.GetLocalBuffer()[2] = (uint8) tradeoff;
+    SendAsyncEvent(event);
+}
+
+void H324MConfig::VideoSpatialTemporalTradeoffIndicationReceived(TPVChannelId id, uint8 tradeoff)
+{
+    PVMFAsyncEvent event(PVMFInfoEvent, PV_INDICATION_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION, NULL, NULL);
+    oscl_memset(event.GetLocalBuffer(), 0, PVMF_ASYNC_EVENT_LOCAL_BUF_SIZE);
+    event.GetLocalBuffer()[0] = (uint8)((id >> 8) & 0xFF);
+    event.GetLocalBuffer()[1] = (uint8)(id & 0xFF);
+    event.GetLocalBuffer()[2] = (uint8) tradeoff;
+    SendAsyncEvent(event);
+}
+
+void H324MConfig::SkewIndicationReceived(TPVChannelId lcn1, TPVChannelId lcn2, uint16 skew)
+{
+    PVMFAsyncEvent event(PVMFInfoEvent, PV_INDICATION_SKEW, NULL, NULL);
+    oscl_memset(event.GetLocalBuffer(), 0, PVMF_ASYNC_EVENT_LOCAL_BUF_SIZE);
+    event.GetLocalBuffer()[0] = (uint8)((lcn1 >> 8) & 0xFF);
+    event.GetLocalBuffer()[1] = (uint8)(lcn1 & 0xFF);
+    event.GetLocalBuffer()[2] = (uint8)((lcn2 >> 8) & 0xFF);
+    event.GetLocalBuffer()[3] = (uint8)(lcn2 & 0xFF);
+    event.GetLocalBuffer()[4] = (uint8)((skew >> 8) & 0xFF);
+    event.GetLocalBuffer()[5] = (uint8)(skew & 0xFF);
+    SendAsyncEvent(event);
+}
+
+///////////////////////////////////////
+// H324MConfigProxied
+///////////////////////////////////////
+H324MConfigProxied::H324MConfigProxied(H324MConfigInterface *aH324MConfigIF, PVMainProxy *aMainProxy) :
+        iH324MConfigIF(aH324MConfigIF),
+        iMainProxy(aMainProxy),
+        iLoggerClient(NULL),
+        iLoggerServer(NULL),
+        iReferenceCount(1),
+        iProxyId(0),
+        iCommandId(1),
+        iObserver(NULL)
+{
+    iProxyId = iMainProxy->RegisterProxiedInterface(*this, *this);
+    iH324MConfigIF->addRef();
+    iH324MConfigIF->SetObserver(this);
+    iLoggerServer = PVLogger::GetLoggerObject("3g324m.h324mconfig.proxied.server");
+}
+
+H324MConfigProxied::~H324MConfigProxied()
+{
+    iMainProxy->UnregisterProxiedInterface(iProxyId);
+    Oscl_Map<PVMFCommandId, CPVCmnInterfaceCmdMessage*, OsclMemAllocator>::iterator it = iPendingCmds.begin();
+    while (it != iPendingCmds.end())
+    {
+        CPVCmnInterfaceCmdMessage* msg = (*it++).second;
+        if (msg)PVH324MessageUtils::DestroyMessage(msg);
+    }
+    iPendingCmds.clear();
+    iH324MConfigIF->removeRef();
+}
+
+void H324MConfigProxied::addRef()
+{
+    iReferenceCount++;
+}
+
+void H324MConfigProxied::removeRef()
+{
+    if (--iReferenceCount <= 0)
+    {
+        OSCL_DELETE(this);
+    }
+}
+
+bool H324MConfigProxied::queryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr)
+{
+    aInterfacePtr = NULL;
+
+    iH324MConfigIF->queryInterface(aUuid, aInterfacePtr);
+
+    if (aInterfacePtr)
+        return true;
+    return false;
+
+}
+
+void H324MConfigProxied::SetObserver(H324MConfigObserver* aObserver)
+{
+    iObserver = aObserver;
+}
+
+void H324MConfigProxied::H324MConfigCommandCompletedL(PVMFCmdResp& aResponse)
+{
+    CPVCmnInterfaceCmdMessage* cmdMsg = iPendingCmds[aResponse.GetCmdId()];
+    if (cmdMsg == NULL)
+        return;
+    CPVH324InterfaceCmdMessage* h324CmdMsg = OSCL_STATIC_CAST(CPVH324InterfaceCmdMessage*, cmdMsg);
+
+    PVMFCmdResp *response = OSCL_NEW(PVMFCmdResp, (h324CmdMsg->GetResponse(aResponse.GetCmdId(),
+                                     (OsclAny*)aResponse.GetContext(),
+                                     aResponse.GetCmdStatus(),
+                                     aResponse.GetEventData())));
+    iMainProxy->SendNotification(iProxyId, response);
+}
+
+void H324MConfigProxied::H324MConfigHandleInformationalEventL(PVMFAsyncEvent& aNotification)
+{
+    PVMFAsyncEvent* event = NULL;
+    event = OSCL_NEW(PVMFAsyncEvent, (aNotification));
+    iMainProxy->SendNotification(iProxyId, event);
+}
+
+PVMFCommandId H324MConfigProxied::SetMultiplexLevel(TPVH223Level aLevel, OsclAny* aContextData)
+{
+    PVH324MessageSetH223Level *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetH223Level, (aLevel, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetMaxSduSize(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData)
+{
+    PVH324MessageSetMaxSduSize *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetMaxSduSize, (aLayer, aSize, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetMaxSduSizeR(TPVAdaptationLayer aLayer, int32 aSize, OsclAny* aContextData)
+{
+    PVH324MessageSetMaxSduSizeR *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetMaxSduSizeR, (aLayer, aSize, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetAl2SequenceNumbers(int32 aSeqNumWidth, OsclAny* aContextData)
+{
+    PVH324MessageSetAl2SequenceNumbers *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetAl2SequenceNumbers, (aSeqNumWidth, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetAl3ControlFieldOctets(int32 aCfo, OsclAny* aContextData)
+{
+    PVH324MessageSetAl3ControlFieldOctets *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetAl3ControlFieldOctets, (aCfo, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetMaxPduSize(int32 aMaxPduSize, OsclAny* aContextData)
+{
+    PVH324MessageSetMaxPduSize *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetMaxPduSize, (aMaxPduSize, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetTerminalType(uint8 aTerminalType, OsclAny* aContextData)
+{
+    PVH324MessageSetTerminalType *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetTerminalType, (aTerminalType, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetALConfiguration(TPVMediaType_t aMediaType, TPVAdaptationLayer aLayer,
+        bool aAllow, OsclAny* aContextData)
+{
+    PVH324MessageSetALConfiguration *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetALConfiguration, (aMediaType, aLayer, aAllow, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SendRme(OsclAny* aContextData)
+{
+    PVH324MessageSendRme *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendRme, (aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetMaxMuxPduSize(int32 aRequestMaxMuxPduSize, OsclAny* aContextData)
+{
+    PVH324MessageSetMaxMuxPduSize *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetMaxMuxPduSize, (aRequestMaxMuxPduSize, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetMaxMuxCcsrlSduSize(int32 aMaxCcsrlSduSize, OsclAny* aContextData)
+{
+    PVH324MessageSetMaxMuxCcsrlSduSize *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetMaxMuxCcsrlSduSize, (aMaxCcsrlSduSize, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::FastUpdate(PVMFNodeInterface& aTrack, OsclAny* aContextData)
+{
+    OSCL_UNUSED_ARG(aTrack);
+    OSCL_UNUSED_ARG(aContextData);
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SendRtd(OsclAny* aContextData)
+{
+    PVH324MessageSendRtd *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendRtd, (aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SetVendor(uint8 aCc, uint8 aExt, uint32 aMc,
+        const uint8* aProduct, uint16 aProductLen,
+        const uint8* aVersion, uint16 aVersionLen,
+        OsclAny* aContextData)
+{
+    PVH324MessageSetVendorId *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetVendorId, (aCc, aExt, aMc, aContextData, iCommandId));
+    cmd->SetProduct(aProduct, aProductLen);
+    cmd->SetVersion(aVersion, aVersionLen);
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfigProxied::SendEndSession(OsclAny* aContextData)
+{
+    PVH324MessageEndSession *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageEndSession, (aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfigProxied::SetEndSessionTimeout(uint32 aTimeout, OsclAny* aContextData)
+{
+    PVH324MessageSetEndSessionTimeout *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetEndSessionTimeout, (aTimeout, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfigProxied::SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+        uint8 aSeries, uint32 aSeriesOffset,
+        uint32 aValue,
+        OsclAny* aContextData)
+{
+    PVH324MessageSetTimerCounter *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetTimerCounter, (aTimerCounter, aSeries, aSeriesOffset, aValue, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfigProxied::SetVideoResolutions(TPVDirection aDirection,
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& aResolutions,
+        OsclAny* aContextData)
+{
+    PVH324MessageSetVideoResolutions *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetVideoResolutions, (aDirection, aResolutions, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfigProxied::SendVendorId(OsclAny* aContextData)
+{
+    PVH324MessageSendVendorId *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendVendorId, (aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+};
+
+PVMFCommandId H324MConfigProxied::SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+        OsclAny* aContextData)
+{
+    PVH324MessageSendVideoSpatialTemporalTradeoffCommand *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendVideoSpatialTemporalTradeoffCommand, (aLogicalChannel, aTradeoff, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel, uint8 aTradeoff,
+        OsclAny* aContextData)
+{
+    PVH324MessageSendVideoSpatialTemporalTradeoffIndication *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendVideoSpatialTemporalTradeoffIndication, (aLogicalChannel, aTradeoff, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId H324MConfigProxied::SendSkewIndication(TPVChannelId aLogicalChannel1, TPVChannelId aLogicalChannel2, uint16 aSkew,
+        OsclAny* aContextData)
+{
+    PVH324MessageSendSkewIndication *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendSkewIndication, (aLogicalChannel1, aLogicalChannel2, aSkew, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId
+H324MConfigProxied::SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+        uint32 aOutBufferingMs,
+        OsclAny* aContextData)
+{
+    PVH324MessageSetLogicalChannelBufferingMs*cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetLogicalChannelBufferingMs, (aInBufferingMs, aOutBufferingMs, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId
+H324MConfigProxied::SendUserInput(CPVUserInput* aUserInput,
+                                  OsclAny* aContextData)
+{
+    PVH324MessageSendUserInput*cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSendUserInput, (aContextData, iCommandId));
+    cmd->SetUserInput(aUserInput);
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+PVMFCommandId
+H324MConfigProxied::SetWnsrp(const bool aEnableWnsrp,
+                             OsclAny* aContextData)
+{
+    PVH324MessageSetWnsrp *cmd = NULL;
+    cmd = OSCL_NEW(PVH324MessageSetWnsrp, (aEnableWnsrp, aContextData, iCommandId));
+    int32 error = 0;
+    OSCL_TRY(error, iMainProxy->SendCommand(iProxyId, cmd));
+    OSCL_FIRST_CATCH_ANY(error, PVH324MessageUtils::DestroyMessage(cmd););
+    return iCommandId++;
+}
+
+void H324MConfigProxied::CleanupNotification(TPVProxyMsgId aId, OsclAny *aMsg)
+{
+    OSCL_UNUSED_ARG(aId);
+    PVMFEventBase* event = OSCL_STATIC_CAST(PVMFEventBase*, aMsg);
+    if (event)
+        delete event;
+}
+
+void H324MConfigProxied::HandleCommand(TPVProxyMsgId aMsgId, OsclAny *aMsg)
+{
+    OSCL_UNUSED_ARG(aMsgId);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                    (0, "H324MConfigProxied::HandleCommand"));
+    PVMFCommandId commandId = 0;
+
+    switch (((CPVCmnInterfaceCmdMessage*)aMsg)->GetType())
+    {
+        case PVT_H324_COMMAND_QUERY_INTERFACE:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Query Interface"));
+            {
+                PVH324MessageQueryInterface* query_msg = OSCL_STATIC_CAST(PVH324MessageQueryInterface*, aMsg);
+                if (query_msg)
+                {
+                    commandId = iH324MConfigIF->queryInterface(query_msg->iUuid,
+                                query_msg->iInterfacePtr);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+            //
+        case PVT_H324_COMMAND_SET_H223_LEVEL :
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set H223 Level"));
+            {
+                PVH324MessageSetH223Level* set_level_msg = OSCL_STATIC_CAST(PVH324MessageSetH223Level*, aMsg);
+                if (set_level_msg)
+                {
+                    commandId = iH324MConfigIF->SetMultiplexLevel(set_level_msg->iH223Level,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_MAX_SDU_SIZE:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Max Sdu Size"));
+            {
+                PVH324MessageSetMaxSduSize* msg = OSCL_STATIC_CAST(PVH324MessageSetMaxSduSize*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetMaxSduSize(msg->iAl, msg->iSize,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_MAX_SDU_SIZE_R:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Max Sdu Size Remote"));
+            {
+                PVH324MessageSetMaxSduSizeR* msg = OSCL_STATIC_CAST(PVH324MessageSetMaxSduSizeR*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetMaxSduSizeR(msg->iAl, msg->iSize,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_RME:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Send RME"));
+            {
+                PVH324MessageSendRme* msg = OSCL_STATIC_CAST(PVH324MessageSendRme*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendRme((CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_AL2_SEQ_NUM:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set AL2 Sequence Numbers"));
+            {
+                PVH324MessageSetAl2SequenceNumbers* msg = OSCL_STATIC_CAST(PVH324MessageSetAl2SequenceNumbers*,
+                        aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetAl2SequenceNumbers(msg->iSeqNumWidth,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_CONTROL_FIELD_OCTETS:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set AL3 Control Field Octets"));
+            {
+                PVH324MessageSetAl3ControlFieldOctets* msg = OSCL_STATIC_CAST(PVH324MessageSetAl3ControlFieldOctets*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetAl3ControlFieldOctets(msg->iCfo,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_MAX_PDU_SIZE:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Max Pdu Size"));
+            {
+                PVH324MessageSetMaxPduSize* msg = OSCL_STATIC_CAST(PVH324MessageSetMaxPduSize*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetMaxMuxPduSize(msg->iMaxPduSize,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_MAX_MUX_PDU_SIZE:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Max Mux Pdu Size"));
+            {
+                PVH324MessageSetMaxMuxPduSize* msg = OSCL_STATIC_CAST(PVH324MessageSetMaxMuxPduSize*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetMaxMuxPduSize(msg->iMaxMuxPduSize,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_MAX_MUX_CCSRL_SDU_SIZE:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Max CCSRL Sdu Size"));
+            {
+                PVH324MessageSetMaxMuxCcsrlSduSize* msg = OSCL_STATIC_CAST(PVH324MessageSetMaxMuxCcsrlSduSize*,
+                        aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetMaxMuxCcsrlSduSize(msg->iMaxMuxCcsrlSduSize,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_RTD:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Send RTD"));
+            {
+                PVH324MessageSendRtd* msg = OSCL_STATIC_CAST(PVH324MessageSendRtd*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendRtd((CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_VENDOR_ID:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Vendor ID"));
+            {
+                PVH324MessageSetVendorId* msg = OSCL_STATIC_CAST(PVH324MessageSetVendorId*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetVendor(msg->iCc, msg->iExt, msg->iMc,
+                                                          msg->iProduct, msg->iProductLen,
+                                                          msg->iVersion, msg->iVersionLen,
+                                                          (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_END_SESSION:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Send End Session"));
+            {
+                PVH324MessageEndSession* msg = OSCL_STATIC_CAST(PVH324MessageEndSession*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendEndSession((CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_END_SESSION_TIMEOUT:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set End Session Timeout"));
+            {
+                PVH324MessageSetEndSessionTimeout* msg = OSCL_STATIC_CAST(PVH324MessageSetEndSessionTimeout*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetEndSessionTimeout(msg->iTimeout,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_AL_CONFIGURATION:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Adaptation Layer Config"));
+            {
+                PVH324MessageSetALConfiguration* msg = OSCL_STATIC_CAST(PVH324MessageSetALConfiguration*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetALConfiguration(msg->iMediaType, msg->iLayer,
+                                msg->iAllow, (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_TIMER_COUNTER:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Timer Counter"));
+            {
+                PVH324MessageSetTimerCounter* msg = OSCL_STATIC_CAST(PVH324MessageSetTimerCounter*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetTimerCounter(msg->iTimerCounter,
+                                msg->iSeries, msg->iSeriesOffset, msg->iValue, (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_VIDEO_RESOLUTIONS:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Video Resolutions"));
+            {
+                PVH324MessageSetVideoResolutions* msg = OSCL_STATIC_CAST(PVH324MessageSetVideoResolutions*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetVideoResolutions(msg->iDirection, msg->iResolutions,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_COMMAND:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Spatial temporal tradeoff command"));
+            {
+                PVH324MessageSendVideoSpatialTemporalTradeoffCommand* msg = OSCL_STATIC_CAST(PVH324MessageSendVideoSpatialTemporalTradeoffCommand*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendVideoTemporalSpatialTradeoffCommand(msg->iLogicalChannel, msg->iTradeoff, (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_VIDEO_SPATIAL_TEMPORAL_TRADEOFF_INDICATION:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Spatial temporal tradeoff indication"));
+            {
+                PVH324MessageSendVideoSpatialTemporalTradeoffIndication* msg =
+                    OSCL_STATIC_CAST(PVH324MessageSendVideoSpatialTemporalTradeoffIndication*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendVideoTemporalSpatialTradeoffIndication(msg->iLogicalChannel, msg->iTradeoff, (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_VENDOR_ID:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Send vendor id"));
+            {
+                PVH324MessageSendVendorId* msg = OSCL_STATIC_CAST(PVH324MessageSendVendorId*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendVendorId((CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_SKEW_INDICATION:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Send skew indication"));
+            {
+                PVH324MessageSendSkewIndication* msg = OSCL_STATIC_CAST(PVH324MessageSendSkewIndication*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendSkewIndication(msg->iLogicalChannel1,
+                                msg->iLogicalChannel2, msg->iSkew, (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_LOGICAL_CHANNEL_BUFFERING_MS:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Logical Channel Buffering"));
+            {
+                PVH324MessageSetLogicalChannelBufferingMs* msg = OSCL_STATIC_CAST(PVH324MessageSetLogicalChannelBufferingMs*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetLogicalChannelBufferingMs(msg->iInLogicalChannelBufferingMs,
+                                msg->iOutLogicalChannelBufferingMs, (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SEND_USER_INPUT:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Send user input"));
+            {
+                PVH324MessageSendUserInput* msg = OSCL_STATIC_CAST(PVH324MessageSendUserInput*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SendUserInput(msg->iUserInput,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_WNSRP:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set WNSRP"));
+            {
+                PVH324MessageSetWnsrp* msg = OSCL_STATIC_CAST(PVH324MessageSetWnsrp*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetWnsrp(msg->iWnsrp,
+                                                         (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        case PVT_H324_COMMAND_SET_TERMINAL_TYPE :
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                            (0, "H324MConfigProxied::HandleCommand - Set Terminal Type"));
+            {
+                PVH324MessageSetTerminalType* msg = OSCL_STATIC_CAST(PVH324MessageSetTerminalType*, aMsg);
+                if (msg)
+                {
+                    commandId = iH324MConfigIF->SetTerminalType(msg->iTerminalType,
+                                (CPVCmnInterfaceCmdMessage*)aMsg);
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                                    (0, "H324MConfigProxied::HandleCommand - Failed to cast"));
+                }
+            }
+            break;
+        default:
+            PVH324MessageUtils::DestroyMessage((CPVCmnInterfaceCmdMessage*)aMsg);
+            return;
+    }
+    // Store command id and msg
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                    (0, "H324MConfigProxied::HandleCommand Adding command id=%d to pending queue", commandId));
+    iPendingCmds[commandId] = (CPVCmnInterfaceCmdMessage*)aMsg;
+}
+
+void H324MConfigProxied::HandleNotification(TPVProxyMsgId aId, OsclAny *aMsg)
+{
+    OSCL_UNUSED_ARG(aId);
+    PVMFEventBase* event = OSCL_STATIC_CAST(PVMFEventBase*, aMsg);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                    (0, "H324MConfigProxied::HandleNotification Event type=%d", event->IsA()));
+
+    if (event->IsA() == PVMFCmdRespEvent)
+    {
+        PVMFCmdResp* cmdResp = OSCL_STATIC_CAST(PVMFCmdResp*, event);
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLoggerServer, PVLOGMSG_STACK_TRACE,
+                        (0, "H324MConfigProxied::HandleNotification Event Command completioin received for command id=%d",
+                         cmdResp->GetCmdId()));
+        CPVCmnInterfaceCmdMessage* cmdMsg = iPendingCmds[cmdResp->GetCmdId()];
+        if (cmdMsg)
+        {
+            PVMFCmdResp response(cmdMsg->GetCommandId(), cmdMsg->GetContextData(),
+                                 cmdResp->GetCmdStatus());
+            if (iObserver)
+            {
+                iObserver->H324MConfigCommandCompletedL(response);
+            }
+            iPendingCmds.erase(cmdResp->GetCmdId());
+            PVH324MessageUtils::DestroyMessage(cmdMsg);
+        }
+    }
+    else if (event->IsA() == PVMFInfoEvent)
+    {
+        PVMFAsyncEvent* async_event = OSCL_STATIC_CAST(PVMFAsyncEvent*, event);
+        if (iObserver)
+        {
+            iObserver->H324MConfigHandleInformationalEventL(*async_event);
+        }
+        OSCL_DELETE(async_event);
+    }
+    else if (event->IsA() == PVMFErrorEvent)
+    {
+        OSCL_DELETE((PVMFAsyncEvent*)event);
+    }
+}
+
+void H324MConfigProxied::CleanupCommand(TPVProxyMsgId aId, OsclAny *aMsg)
+{
+    OSCL_UNUSED_ARG(aId);
+    PVMFEventBase* event = OSCL_STATIC_CAST(PVMFEventBase*, aMsg);
+    if (event->IsA() == PVMFCmdRespEvent)
+    {
+        PVMFCmdResp* cmdResp = OSCL_STATIC_CAST(PVMFCmdResp*, event);
+        CPVCmnInterfaceCmdMessage* cmdMsg = iPendingCmds[cmdResp->GetCmdId()];
+        if (cmdMsg)
+        {
+            OSCL_DELETE(cmdMsg);
+            iPendingCmds.erase(cmdResp->GetCmdId());
+        }
+    }
+    else if (event->IsA() == PVMFInfoEvent)
+    {
+        OSCL_DELETE((PVMFAsyncEvent*)event);
+    }
+    else if (event->IsA() == PVMFErrorEvent)
+    {
+        OSCL_DELETE((PVMFAsyncEvent*)event);
+    }
+}
+
+
+
+///////////////////////////////////////
+// H324MProxiedInterface
+///////////////////////////////////////
+H324MProxiedInterface::H324MProxiedInterface() : iH324M(NULL), iMainProxy(NULL), iReferenceCount(0) {}
+H324MProxiedInterface::~H324MProxiedInterface() {}
+
+void H324MProxiedInterface::QueryProxiedInterface(const TPVProxyUUID &aUuid,
+        PVInterface *&aInterfacePtr)
+{
+    if (aUuid == PVH324MConfigUuid)
+    {
+        H324MConfig *h324mconfig = NULL;
+        h324mconfig = OSCL_NEW(H324MConfig, (iH324M, true));
+        aInterfacePtr = OSCL_NEW(H324MConfigProxied, (h324mconfig, iMainProxy));
+        h324mconfig->removeRef();
+    }
+}
+void H324MProxiedInterface::SetMainProxy(PVMainProxy * aMainProxy)
+{
+    iMainProxy = aMainProxy;
+}
+
+void H324MProxiedInterface::addRef()
+{
+    iReferenceCount++;
+}
+
+void H324MProxiedInterface::removeRef()
+{
+    if (--iReferenceCount <= 0)
+        OSCL_DELETE(this);
+}
+bool H324MProxiedInterface::queryInterface(const PVUuid&, PVInterface*&)
+{
+    return false;
+}
+void H324MProxiedInterface::SetH324M(TSC_324m *aH324M)
+{
+    iH324M = aH324M;
+}
+
+
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_indication.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_indication.cpp
new file mode 100644
index 0000000..98ee35d
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_indication.cpp
@@ -0,0 +1,521 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#include    "tscmain.h"
+#include    "tsc_sub.h"     /* Sub Routine Information Header                */
+#include    "tsc_component.h"
+
+#define MAX_VENDOR_ID_OID_LEN 512 /* Max len of object identifier sequence */
+/*****************************************************************************/
+/*  function name        : Tsc_IdcVi                                         */
+/*  function outline     : VendorIdentification procedure                    */
+/*  function discription : Tsc_IdcVi( void )                                 */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.11.29                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::Tsc_IdcVi(void)
+{
+    S_ControlMsgHeader infHeader;
+    PS_VendorIdentification      pVendorIdentification;
+
+    if (iVendor == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m:Tsc_IdcVi - Not sending vendor id\n"));
+        return;
+    }
+    /* Buffer Allocate */
+    pVendorIdentification = (PS_VendorIdentification)OSCL_DEFAULT_MALLOC(sizeof(S_VendorIdentification));
+    oscl_memset(pVendorIdentification, 0, sizeof(S_VendorIdentification));
+    if (iVendor->GetVendorType() == EObjectIdentifier)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m:Tsc_IdcVi - EObjectIdentifier\n"));
+        pVendorIdentification->vendor.index = 0; /* object */
+        pVendorIdentification->vendor.object = (PS_OBJECTIDENT) OSCL_DEFAULT_MALLOC(sizeof(S_OBJECTIDENT));
+        uint16 sz = 0;
+        uint8* data = ((TPVH245VendorObjectIdentifier*)iVendor)->GetVendor(&sz);
+        pVendorIdentification->vendor.object->size = sz;
+        pVendorIdentification->vendor.object->data = (uint8*)OSCL_DEFAULT_MALLOC(sz);
+        oscl_memcpy(pVendorIdentification->vendor.object->data, data, sz);
+    }
+    else if (iVendor->GetVendorType() == EH221NonStandard)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m:Tsc_IdcVi - EH221NonStandard\n"));
+        pVendorIdentification->vendor.index = 1; /* H221Nonstandard */
+        pVendorIdentification->vendor.h221NonStandard =
+            (struct _H221NonStandard *)OSCL_DEFAULT_MALLOC(sizeof(struct _H221NonStandard));
+        pVendorIdentification->vendor.h221NonStandard->manufacturerCode =
+            (uint16)((TPVVendorH221NonStandard*)iVendor)->GetManufacturerCode();
+        pVendorIdentification->vendor.h221NonStandard->t35CountryCode =
+            ((TPVVendorH221NonStandard*)iVendor)->GetT35CountryCode();
+        pVendorIdentification->vendor.h221NonStandard->t35Extension =
+            ((TPVVendorH221NonStandard*)iVendor)->GetT35Extension();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m:Tsc_IdcVi - ERROR - Invalid vendor type\n"));
+        OSCL_DEFAULT_FREE(pVendorIdentification);
+        return;
+    }
+    pVendorIdentification->option_of_productNumber = false;
+    if (iProductNumberLen)
+    {
+        pVendorIdentification->option_of_productNumber = true;
+        pVendorIdentification->productNumber.size =
+            (uint16)iProductNumberLen;
+        pVendorIdentification->productNumber.data =
+            (uint8*)OSCL_DEFAULT_MALLOC(iProductNumberLen);
+        oscl_memcpy(pVendorIdentification->productNumber.data,
+                    iProductNumber, iProductNumberLen);
+    }
+    pVendorIdentification->option_of_versionNumber = false;
+    if (iVersionNumberLen)
+    {
+        pVendorIdentification->option_of_versionNumber = true;
+        pVendorIdentification->versionNumber.size =
+            (uint16)iVersionNumberLen;
+        pVendorIdentification->versionNumber.data =
+            (uint8*)OSCL_DEFAULT_MALLOC(iVersionNumberLen);
+        oscl_memcpy(pVendorIdentification->versionNumber.data,
+                    iVersionNumber, iVersionNumberLen);
+    }
+
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Vi, 0, 0,
+                    (uint8*)pVendorIdentification, sizeof(S_VendorIdentification));
+    /* Primitive Send */
+    iH245->DispatchControlMessage(&infHeader);
+    Delete_VendorIdentification(pVendorIdentification);
+    OSCL_DEFAULT_FREE(pVendorIdentification);
+    return;
+}
+
+uint32 TSC_324m::VendorIdRecv(PS_ControlMsgHeader  pReceiveInf)
+{
+    PS_VendorIdentification  pVendorIdentification =
+        (PS_VendorIdentification)pReceiveInf->pParameter;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: Vendor Id Received - vendor index(%d), opn(%d), ovn(%d)\n",
+                     pVendorIdentification->vendor.index,
+                     pVendorIdentification->option_of_productNumber,
+                     pVendorIdentification->option_of_versionNumber));
+    if (iVendorR)
+    {
+        OSCL_DELETE(iVendorR);
+        iVendorR = NULL;
+    }
+
+    if (iProductNumberR)
+    {
+        OSCL_DEFAULT_FREE(iProductNumberR);
+        iProductNumberR = NULL;
+        iProductNumberLenR = 0;
+    }
+    if (iVersionNumberR)
+    {
+        OSCL_DEFAULT_FREE(iVersionNumberR);
+        iVersionNumberR = NULL;
+        iVersionNumberLenR = 0;
+    }
+
+    if (pVendorIdentification->vendor.index == 0) // object identifier
+    {
+        if (pVendorIdentification->vendor.object->size &&
+                (pVendorIdentification->vendor.object->size < MAX_VENDOR_ID_OID_LEN))
+        {
+            if (pVendorIdentification->vendor.object->data[pVendorIdentification->vendor.object->size - 1] == '\0')
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m: Vendor Id - %s\n",
+                                 pVendorIdentification->vendor.object->data));
+            }
+            iVendorR = new TPVH245VendorObjectIdentifier((uint8*)pVendorIdentification->vendor.object->data,
+                    pVendorIdentification->vendor.object->size);
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m:VendorIdRecv - Error - invalid length(%d)\n",
+                             pVendorIdentification->vendor.object->size));
+            return iTerminalStatus;
+        }
+    }
+    else if (pVendorIdentification->vendor.index == 1) // H221NonStandard
+    {
+        iVendorR = new TPVVendorH221NonStandard(pVendorIdentification->vendor.h221NonStandard->t35CountryCode,
+                                                pVendorIdentification->vendor.h221NonStandard->t35Extension,
+                                                pVendorIdentification->vendor.h221NonStandard->manufacturerCode);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m:VendorIdRecv - Error - invalid index(%d)\n",
+                         pVendorIdentification->vendor.index));
+        return iTerminalStatus;
+    }
+    if (pVendorIdentification->option_of_productNumber)
+    {
+        iProductNumberLenR = pVendorIdentification->productNumber.size;
+    }
+    if (iProductNumberLenR)
+    {
+        if (pVendorIdentification->productNumber.data[iProductNumberLenR-1] == '\0')
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: Product Number - %s\n",
+                             pVendorIdentification->productNumber.data));
+        }
+        iProductNumberR = (uint8*)OSCL_DEFAULT_MALLOC(iProductNumberLenR);
+        oscl_memcpy(iProductNumberR, pVendorIdentification->productNumber.data,
+                    iProductNumberLenR);
+    }
+    if (pVendorIdentification->option_of_versionNumber)
+    {
+        iVersionNumberLenR = pVendorIdentification->versionNumber.size;
+    }
+    if (iVersionNumberLenR)
+    {
+        if (pVendorIdentification->versionNumber.data[iVersionNumberLenR-1] == '\0')
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: Version Number - %s\n",
+                             pVendorIdentification->versionNumber.data));
+        }
+        iVersionNumberR = (uint8*)OSCL_DEFAULT_MALLOC(iVersionNumberLenR);
+        oscl_memcpy(iVersionNumberR, pVendorIdentification->versionNumber.data, iVersionNumberLenR);
+    }
+    if (iTSC_324mObserver)
+    {
+        iTSC_324mObserver->IncomingVendorId(iVendorR, iProductNumberR,
+                                            (uint16)iProductNumberLenR, iVersionNumberR, (uint16)iVersionNumberLenR);
+    }
+    return iTerminalStatus;
+}
+
+
+//-----------------------------------------------------------------------------
+// Tsc_UII_DTMF()                                              (RAN-UII)
+//
+// This routine sends a DTMF signal via H.245 UserInputIndication message.
+// It takes two input values:
+//
+//   uint8   dtmf_value      (ascii value of a character in [0123456789#*ABCD!])
+//   uint16  dtmf_duration   (duration of pulse in mSec; 0 means no duration)
+//-----------------------------------------------------------------------------
+void TSC_324m::Tsc_UII_DTMF(uint8 dtmf_value, uint16 dtmf_duration)
+{
+    S_ControlMsgHeader			 infHeader;
+    PS_UserInputIndication       pUserInputIndication;
+
+    // Allocate the UII structure
+    pUserInputIndication = (PS_UserInputIndication)OSCL_DEFAULT_MALLOC(sizeof(S_UserInputIndication));
+
+    // Fill in the 'signal'
+    pUserInputIndication->index = 3;  /* signal */
+    pUserInputIndication->signal = (PS_Signal) OSCL_DEFAULT_MALLOC(sizeof(S_Signal));
+
+    pUserInputIndication->signal->option_of_signalRtp = 0;
+    pUserInputIndication->signal->signalType.size = 1;
+    pUserInputIndication->signal->signalType.data = (uint8*) OSCL_DEFAULT_MALLOC(1 * sizeof(uint8));
+    pUserInputIndication->signal->signalType.data[0] = dtmf_value;
+
+    if (dtmf_duration == 0)
+    {
+        pUserInputIndication->signal->option_of_duration = 0;
+    }
+    else
+    {
+        pUserInputIndication->signal->option_of_duration = 1;
+        pUserInputIndication->signal->duration = dtmf_duration;
+    }
+
+    // Send the message
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Ui, 0, 0, (uint8*)pUserInputIndication,
+                    sizeof(S_UserInputIndication));
+    iH245->DispatchControlMessage(&infHeader);
+    Delete_UserInputIndication(pUserInputIndication);
+    OSCL_DEFAULT_FREE(pUserInputIndication);
+    return;
+}
+
+void TSC_324m::Tsc_UII_Alphanumeric(const uint8* str, uint16 str_len)
+{
+    S_ControlMsgHeader			 infHeader;
+    PS_UserInputIndication       pUserInputIndication;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m:Tsc_UII_Alphanumeric - len(%d)", str_len));
+
+    // Allocate the UII structure
+    pUserInputIndication = (PS_UserInputIndication)OSCL_DEFAULT_MALLOC(sizeof(S_UserInputIndication));
+
+    // Fill in the 'signal'
+    pUserInputIndication->index = 1;  /* alphanumeric */
+    pUserInputIndication->alphanumeric = (PS_int8STRING) OSCL_DEFAULT_MALLOC(sizeof(S_int8STRING));
+    pUserInputIndication->alphanumeric->size = str_len;
+    pUserInputIndication->alphanumeric->data = (uint8*) OSCL_DEFAULT_MALLOC(str_len * sizeof(uint8));
+    oscl_memcpy(pUserInputIndication->alphanumeric->data, str, str_len);
+
+    // Send the message
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Ui, 0, 0, (uint8*)pUserInputIndication,
+                    sizeof(S_UserInputIndication));
+    iH245->DispatchControlMessage(&infHeader);
+    Delete_UserInputIndication(pUserInputIndication);
+    OSCL_DEFAULT_FREE(pUserInputIndication);
+    return;
+}
+
+uint32 TSC_324m::UserInputIndicationRecv(PS_ControlMsgHeader  pReceiveInf)
+{
+    PS_UserInputIndication pUserInputIndication  = (PS_UserInputIndication)pReceiveInf->pParameter;
+    CPVUserInput* uii = NULL;
+    uint16 duration = 0;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: User Input Indication Received - index(%d)\n", pUserInputIndication->index));
+    switch (pUserInputIndication->index)
+    {
+        case 1: /* alphanumeric */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: User Input Indication Received - alphanumeric size(%d)",
+                             pUserInputIndication->alphanumeric->size));
+            uii = OSCL_NEW(CPVUserInputAlphanumeric, (pUserInputIndication->alphanumeric->data,
+                           pUserInputIndication->alphanumeric->size));
+            break;
+        case 3: /* signal */
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: User Input Indication Received - signal option_of_duration(%d), option_of_signalRtp(%d), signalType(%d)", pUserInputIndication->signal->option_of_duration, pUserInputIndication->signal->option_of_signalRtp, pUserInputIndication->signal->signalType.size));
+            if (pUserInputIndication->signal->option_of_duration)
+            {
+                duration = pUserInputIndication->signal->duration;
+            }
+            uii = OSCL_NEW(CPVUserInputDtmf, (*pUserInputIndication->signal->signalType.data,
+                                              false, duration));
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: User Input Indication Received - unrecognized type\n"));
+    }
+    if (uii)
+    {
+        if (iTSC_324mObserver)
+            iTSC_324mObserver->UserInputReceived(uii);
+        OSCL_DELETE(uii);
+    }
+
+    return iTerminalStatus;
+}
+
+void TSC_324m::IndicationMisc(TIndicationMisc type,
+                              TPVChannelId channelId,
+                              uint32 param,
+                              OsclAny* param1)
+{
+    OSCL_UNUSED_ARG(param1);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::IndicationMisc type(%d), channelId(%d), param(%d), param1(%x)",
+                     type, channelId, param, param1));
+
+    S_ControlMsgHeader infHeader;
+    S_MiscellaneousIndication miscellaneousIndication;
+    oscl_memset(&miscellaneousIndication, 0, sizeof(S_MiscellaneousIndication));
+
+    switch (type)
+    {
+        case EVideoTemporalSpatialTradeOffIdc:
+            miscellaneousIndication.logicalChannelNumber = (uint16)channelId;
+            miscellaneousIndication.miType.index = 9;
+            miscellaneousIndication.miType.videoTemporalSpatialTradeOff = (uint8)param;
+            break;
+        default:
+            return;
+    }
+
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Mscl, 0, 0,
+                    (uint8*)&miscellaneousIndication, sizeof(S_MiscellaneousIndication));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+void TSC_324m::Tsc_IdcSkew(TPVChannelId lcn1, TPVChannelId lcn2, uint16 skew)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Tsc_IdcSkew lcn1(%d), lcn2(%d), skew(%d)",
+                     lcn1, lcn2, skew));
+    S_ControlMsgHeader infHeader;
+    S_H223SkewIndication skewIndication;
+    oscl_memset(&skewIndication, 0, sizeof(S_H223SkewIndication));
+    skewIndication.logicalChannelNumber1 = (uint16)lcn1;
+    skewIndication.logicalChannelNumber2 = (uint16)lcn2;
+    skewIndication.skew = skew;
+
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_H223skw, 0, 0,
+                    (uint8*)&skewIndication, sizeof(S_H223SkewIndication));
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+uint32 TSC_324m::MiscIndicationRecv(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MiscIndicationRecv"));
+    PS_MiscellaneousIndication indication = (PS_MiscellaneousIndication)pReceiveInf->pParameter;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MiscIndicationRecv lcn(%d),index(%d)",
+                     indication->logicalChannelNumber, indication->miType.index));
+    switch (indication->miType.index)
+    {
+        case 9:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::MiscIndicationRecv videoSpatialTemporalTradeoff(%d)",
+                             indication->miType.videoTemporalSpatialTradeOff));
+            if (iTSC_324mObserver)
+            {
+                iTSC_324mObserver->VideoSpatialTemporalTradeoffIndicationReceived(indication->logicalChannelNumber,
+                        indication->miType.videoTemporalSpatialTradeOff);
+            }
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::MiscIndicationRecv Indication not handled"));
+            break;
+    }
+    return iTerminalStatus;
+}
+
+uint32 TSC_324m::SkewIndicationRecv(PS_ControlMsgHeader  pReceiveInf)
+{
+    PS_H223SkewIndication indication = (PS_H223SkewIndication)pReceiveInf->pParameter;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SkewIndicationRecv lcn1(%d), lcn2(%d), skew(%d)",
+                     indication->logicalChannelNumber1,
+                     indication->logicalChannelNumber2,
+                     indication->skew));
+    uint16 skew = indication->skew;
+    if (skew > PV_2WAY_MAX_SKEW_MS)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SkewIndicationRecv skew(%d) > max skew(%d)",
+                         indication->skew, PV_2WAY_MAX_SKEW_MS));
+        skew = PV_2WAY_MAX_SKEW_MS;
+    }
+
+    /* Validate the skew indication */
+    OlcParam* olcparam = iTSCcomponent->FindOlc(INCOMING, PV_AUDIO, OLC_ESTABLISHED);
+    if (!olcparam)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::SkewIndicationRecv Established incoming audio lcn not found"));
+        return iTerminalStatus ;
+    }
+    if (indication->logicalChannelNumber2 != olcparam->GetChannelId())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::SkewIndicationRecv indication->logicalChannelNumber2=%d != audio lcn id=%d",
+                         indication->logicalChannelNumber2, olcparam->GetChannelId()));
+        //return iTerminalStatus ;
+    }
+
+    olcparam = iTSCcomponent->FindOlc(INCOMING, PV_VIDEO, OLC_ESTABLISHED);
+    if (!olcparam)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::SkewIndicationRecv Established incoming video lcn not found"));
+        return iTerminalStatus ;
+    }
+    if (indication->logicalChannelNumber1 != olcparam->GetChannelId())
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::SkewIndicationRecv indication->logicalChannelNumber1=%d != video lcn id=%d",
+                         indication->logicalChannelNumber1, olcparam->GetChannelId()));
+        //return iTerminalStatus ;
+    }
+
+    if (iTSC_324mObserver)
+    {
+        iTSC_324mObserver->SkewIndicationReceived(indication->logicalChannelNumber1,
+                indication->logicalChannelNumber2, skew);
+    }
+    //Obtain logical channel #1, and transmit the skew duration
+    OsclSharedPtr<H223IncomingChannel> channel;
+    PVMFStatus retVal = iH223->GetIncomingChannel(indication->logicalChannelNumber1, channel);
+
+    if (retVal != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING, (0, "TSC_324m::SkewIndicationRecv Error - Failed to lookup logical channel %d", indication->logicalChannelNumber1));
+        return iTerminalStatus;
+    }
+
+    channel->SetTimestampOffset(skew);
+
+    return iTerminalStatus;
+}
+
+void TSC_324m::SendFunctionNotSupportedIndication(uint16 cause,
+        uint8* function,
+        uint16 len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SendFunctionNotSupportedIndication"));
+    S_ControlMsgHeader infHeader;
+    S_FunctionNotSupported fnsIndication;
+    oscl_memset(&fnsIndication, 0, sizeof(S_FunctionNotSupported));
+    fnsIndication.fnsCause.index = cause;
+    if (function && len)
+    {
+        fnsIndication.option_of_returnedFunction = 1;
+        fnsIndication.returnedFunction.size = len;
+        fnsIndication.returnedFunction.data = function;
+    }
+    Tsc_SendDataSet(&infHeader, H245_PRIMITIVE, E_PtvId_Idc_Fns, 0, 0,
+                    (uint8*)&fnsIndication, sizeof(S_FunctionNotSupported));
+    iH245->DispatchControlMessage(&infHeader);
+    return;
+}
+
+uint32 TSC_324m::FunctionNotSupportedIndicationReceived(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::FunctionNotSupportedIndicationReceived"));
+    return iTerminalStatus;
+}
+
+uint32 TSC_324m::FlowControlIndicationReceived(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::FlowControlIndicationReceived"));
+    return iTerminalStatus;
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_lc.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_lc.cpp
new file mode 100644
index 0000000..9a018c9
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_lc.cpp
@@ -0,0 +1,190 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#include    "tsc_lc.h"
+#include    "tsc_sub.h"     /* Sub Routine Information Header                */
+#include    "tsc_statemanager.h"
+#include    "tsc_constants.h"
+
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_LcEtbReq                                      */
+/*  function outline     : Tsc_LcEtbReq procedure                            */
+/*  function discription : Tsc_LcEtbReq( LcnIndex )                          */
+/*  input data           : uint32                 Open Lcn                     */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_lc::LcEtbReq(TPVChannelId Lcn,
+                      PS_DataType pDataType,
+                      PS_H223LogicalChannelParameters pH223Params)
+{
+    S_ControlMsgHeader infHeader;
+    S_ForwardReverseParam parameter;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_lc: LcEtbReq lcn(%d)\n", Lcn));
+
+    // ESTABLISH.request primitive - Parameter(FORWARD_PARAM)
+    parameter.forwardLogicalChannelParameters.option_of_portNumber = false;
+
+    PS_DataType dt = Copy_DataType(pDataType);
+    oscl_memcpy(&parameter.forwardLogicalChannelParameters.dataType,
+                dt,
+                sizeof(S_DataType));
+    OSCL_DEFAULT_FREE(dt);
+
+    // MultiplexParameters
+    parameter.forwardLogicalChannelParameters.multiplexParameters.index = 1;  // 1 = h223LogicalChannelParameters
+
+    parameter.forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters =
+        Copy_H223LogicalChannelParameters(pH223Params);
+
+    // WWU_LC: start
+    parameter.forwardLogicalChannelParameters.option_of_forwardLogicalChannelDependency =
+        false;
+    parameter.forwardLogicalChannelParameters.option_of_replacementFor = false;
+    // WWU_LC: end
+
+    parameter.option_of_reverseLogicalChannelParameters = false;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Lc_Etb_Req,
+                    Lcn,
+                    0,
+                    (uint8*)&parameter,
+                    sizeof(S_ForwardReverseParam));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    iTSCstatemanager.WriteState(TSC_LC_AUDIO_SEND, STARTED);
+
+    Delete_DataType(&parameter.forwardLogicalChannelParameters.dataType);
+    Delete_H223LogicalChannelParameters(
+        parameter.forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters);
+    OSCL_DEFAULT_FREE(
+        parameter.forwardLogicalChannelParameters.multiplexParameters.h223LogicalChannelParameters);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_LcEtbRps                                      */
+/*  function outline     : Tsc_LcEtbRps procedure                            */
+/*  function discription : Tsc_LcEtbRps( OpenPendingLcn )                    */
+/*  input data           : uint32                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_lc::LcEtbRps(uint32 lcn)
+{
+    S_ControlMsgHeader infHeader;
+    S_ReverseData      parameter;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_lc: LcEtbRps lcn(%d)\n", lcn));
+
+    parameter.option_of_reverseLogicalChannelParameters = false;
+    parameter.option_of_forwardMultiplexAckParameters = false;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Lc_Etb_Rps,
+                    lcn,
+                    0,
+                    (uint8*)&parameter,
+                    sizeof(S_ReverseData));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_LcRlsReq                                      */
+/*  function outline     : Tsc_LcRlsReq                                      */
+/*  function discription : Tsc_LcRlsReq( ReleaseType, CloseLcnIndex )                          */
+/*  input data           : int32                                               */
+/*                       : uint32                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+TPVDirection TSC_lc::LcRlsReq(int32 ReleaseType, TPVChannelId CloseLcn, uint16 Cause)
+{
+    S_ControlMsgHeader infHeader;
+    S_OlcRejectCause parameter;
+    TPVDirection dir = OUTGOING;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0,
+                     "TSC_lc: LcRlsReq lcn(%d), ReleaseType(%d), Cause(%d)\n",
+                     CloseLcn, ReleaseType, Cause));
+
+    if (ReleaseType == RELEASE_CLOSE)
+    {
+        // Close outgoing
+        dir = OUTGOING;
+        Tsc_SendDataSet(&infHeader,
+                        H245_PRIMITIVE,
+                        E_PtvId_Lc_Rls_Req,
+                        CloseLcn,
+                        0, NULL, 0);
+    }
+    else
+    {
+        // Reject incoming
+        dir = INCOMING;
+        // REJECT.request primitive - Parameter[CAUSE]
+        parameter.index = (uint16)Cause;
+        Tsc_SendDataSet(&infHeader,
+                        H245_PRIMITIVE,
+                        E_PtvId_Lc_Rls_Req,
+                        CloseLcn,
+                        0,
+                        (uint8*)&parameter,
+                        sizeof(S_OlcRejectCause));
+    }
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    return dir;
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_msd.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_msd.cpp
new file mode 100644
index 0000000..2c40660
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_msd.cpp
@@ -0,0 +1,126 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_msd.c                                         */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include    "tscmain.h"
+#include    "tsc_statemanager.h"
+#include    "tsc_constants.h"
+
+void TSC_324m::MSDStart()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MSDStart()\n"));
+    iTSCstatemanager.MSDStart(iLoopbackMode);
+    if (iLoopbackMode == PV_LOOPBACK_NONE && Msd)
+    {
+        Msd->DetermineRequest();
+    }
+}
+
+void TSC_324m::MSDDetermineConfirm(MSDStatus type)
+{
+    if (type == MSD_MASTER)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC: MSD complete. decision MASTER."));
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC: MSD complete. decision SLAVE."));
+    }
+    // Master/Slave Determination... Complete
+    iTSCstatemanager.WriteState(TSC_MSD_DECISION, (type == MSD_MASTER) ?
+                                MASTER : SLAVE);
+    iTSCstatemanager.WriteState(TSC_MSD, COMPLETE);
+    if (iTerminalStatus == PhaseD_CSUP)
+    {
+        if (iTSCstatemanager.ReadState(TSC_CE_RECEIVE) == COMPLETE)
+        {
+            int leave_status = 0;
+            OSCL_TRY(leave_status, TcsMsdComplete());
+            OSCL_FIRST_CATCH_ANY(leave_status, void());
+            if (leave_status != 0)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_324m::MSDDetermineConfirm - Memory Allocation Failed."));
+                SignalCsupComplete(PVMFErrNoMemory);
+                return;
+            }
+        }
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::MSDDetermineConfirm Invalid state(%d)",
+                         iTerminalStatus));
+    }
+}
+
+void TSC_324m::MSDDetermineIndication(MSDStatus type)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: MSD indication received.\n"));
+
+    iTSCstatemanager.MSDDetermineIndication(type);
+}
+
+void TSC_324m::MSDRejectIndication()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: MSD reject indication.\n"));
+
+    // Retry TSC_MSD several times, then give up (RAN)
+    iTSCstatemanager.DecrementState(TSC_MSD_RETRYCOUNT);
+    if (iTSCstatemanager.ReadState(TSC_MSD_RETRYCOUNT) > 0)
+    {
+        MSDStart();
+    }
+    else
+    {
+        iConnectFailReason = EPVT_FailedToNegotiate;
+        SessionClose_CSUP();
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC: MSD failed after retries.\n"));
+    }
+}
+
+void TSC_324m::MSDErrorIndication(MSDErrCode errCode)
+{
+    OSCL_UNUSED_ARG(errCode);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: MSD Error %d.\n", errCode));
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_mt.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_mt.cpp
new file mode 100644
index 0000000..4e2e417
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_mt.cpp
@@ -0,0 +1,396 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_mt.cpp                                        */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include    "tsc_mt.h"
+#include    "tsc_sub.h"     /* Sub Routine Information Header                */
+#include    "cpvh223multiplex.h"
+#include    "tsc_component.h"
+
+
+#define TSC_FM_H263_MTE 5
+#define TSC_FM_MAX_MTE TSC_FM_H263_MTE
+#define FIRST_MUX_ENTRY_NUMBER TSC_FM_MAX_MTE + 1
+#define LAST_MUX_ENTRY_NUMBER 14
+
+void TSC_mt::ClearVars()
+{
+    iToBeDeletedMuxEntryNumbers.clear();
+    iOutMtSn = 0;
+    iPendingMtSn = 0;
+}
+
+void TSC_mt::DeleteMuxEntry(uint32 aNum)
+{
+    iToBeDeletedMuxEntryNumbers.push_back(aNum);
+}
+
+void TSC_mt::InitVarsSession()
+{
+    // Initialize available multiplex entry numbers
+    iAvailableMuxEntryNumbers.clear();
+    for (int ii = TSC_FM_MAX_MTE + 1; ii <= LAST_MUX_ENTRY_NUMBER; ii++)
+    {
+        iAvailableMuxEntryNumbers.push_back(ii);
+    }
+    iOutMtSn = 0;
+    iPendingMtSn = 0;
+}
+
+bool TSC_mt::MuxTableSendComplete(uint32 sn)
+{
+    if ((uint32)iPendingMtSn != sn)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0,
+                         "TSC_mt::MuxTableSendComplete Outdated multipex entry send sn(%d), last sn(%d)",
+                         sn, iPendingMtSn));
+        return false;
+    }
+    iPendingMtSn = -1;
+    return true;
+}
+
+
+bool TSC_mt::CheckMtTrf(Oscl_Vector<CodecCapabilityInfo*, OsclMemAllocator> aOutCodecList,
+                        Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>* aOutgoingChannelConfig)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_mt::CheckMtTrf"));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0,
+                     "TSC_mt::CheckMtTrf codec list size(%d), num h223 channels(%d)",
+                     aOutCodecList.size(), iH223->GetNumChannels(OUTGOING)));
+    unsigned num_channels = (aOutgoingChannelConfig) ?
+                            aOutgoingChannelConfig->size() : 0;
+    num_channels = aOutCodecList.size() < num_channels ?
+                   aOutCodecList.size() : num_channels;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_mt::CheckMtTrf num opened h223 channels(%d)", num_channels));
+    return (iH223->GetNumChannels(OUTGOING) >= num_channels) ? true : false;
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_MtTrfRps                                      */
+/*  function outline     : Tsc_MtTrfRps procedure                            */
+/*  function discription : Tsc_MtTrfRps( void )                              */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_mt::MtTrfRps(uint32 sequenceNumber, PS_MuxDescriptor pMux)
+{
+    S_ControlMsgHeader infHeader;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mt_Trf_Rps,
+                    sequenceNumber,
+                    0,
+                    (uint8*)pMux,
+                    sizeof(S_MuxDescriptor));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    return;
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_MtRjtReq                                      */
+/*  function outline     : Tsc_MtRjtReq procedure                            */
+/*  function discription : Tsc_MtRjtReq( pReceiveInf )                       */
+/*  input data           : PS_ControlMsgHeader                                      */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_mt::MtRjtReq()
+{
+    S_ControlMsgHeader infHeader;
+    S_MeRejectCause parameter;
+
+    // REJECT.request primitive - Parameter[CAUSE]
+    parameter.index = 1;
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mt_Rjt_Req,
+                    0,
+                    0,
+                    (uint8*)&parameter,
+                    sizeof(S_MeRejectCause));
+
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+CPVMultiplexEntryDescriptor* TSC_mt::GenerateCombinedDescriptor(uint8 entry_num,
+        TPVChannelId lcn1,
+        unsigned lcn1_size,
+        TPVChannelId lcn2)
+{
+    PS_MultiplexEntryDescriptor h245_desc =
+        (PS_MultiplexEntryDescriptor)OSCL_DEFAULT_MALLOC(sizeof(S_MultiplexEntryDescriptor));
+    h245_desc->multiplexTableEntryNumber = entry_num;
+    h245_desc->option_of_elementList = true;
+    h245_desc->size_of_elementList = 2;
+
+    h245_desc->elementList =
+        (PS_MultiplexElement)OSCL_DEFAULT_MALLOC(2 * sizeof(S_MultiplexElement));
+    oscl_memset(h245_desc->elementList, 0, 2 * sizeof(S_MultiplexElement));
+    PS_MultiplexElement elem = h245_desc->elementList;
+    elem->muxType.index = 0;
+    elem->muxType.logicalChannelNumber = (uint16)lcn1;
+    elem->muxType.size = 1;
+    elem->repeatCount.index = 0;
+    elem->repeatCount.finite = (uint16)lcn1_size;
+
+    elem++;
+    elem->muxType.index = 0;
+    elem->muxType.logicalChannelNumber = (uint16)lcn2;
+    elem->muxType.size = 1;
+    elem->repeatCount.index = 1;
+    CPVMultiplexEntryDescriptor* ret = CPVMultiplexEntryDescriptor::NewL(h245_desc, 128);
+    Delete_MultiplexEntryDescriptor(h245_desc);
+    OSCL_DEFAULT_FREE(h245_desc);
+    return ret;
+}
+
+
+uint32 TSC_mt::SendMuxTableForLcn(TPVChannelId lcn)
+{
+    S_ControlMsgHeader infHeader;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_mt::SendMuxTableForLcn lcn(%d)", lcn));
+    CPVMultiplexEntryDescriptorVector descriptors;
+    if (iAvailableMuxEntryNumbers.size() == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_mt::SendMuxTableForLcn Ran out of mux table entries"));
+        OSCL_LEAVE(PVMFErrNoResources);
+    }
+    int entry_num = iAvailableMuxEntryNumbers[0];
+    iAvailableMuxEntryNumbers.erase(iAvailableMuxEntryNumbers.begin());
+    CPVMultiplexEntryDescriptor* desc =
+        iTSCcomponent->GenerateSingleDescriptor((uint8)entry_num, lcn);
+    descriptors.push_back(desc);
+    iH223->SetOutgoingMuxDescriptors(descriptors);
+
+    PS_MuxDescriptor mux_descriptor =
+        (PS_MuxDescriptor)OSCL_DEFAULT_MALLOC(sizeof(S_MuxDescriptor));
+    oscl_memset(mux_descriptor, 0, sizeof(S_MuxDescriptor));
+    mux_descriptor->size_of_multiplexEntryDescriptors = 1;
+    mux_descriptor->multiplexEntryDescriptors = desc->GetH245descriptor();
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mt_Trf_Req,
+                    0,
+                    0,
+                    (uint8*)mux_descriptor,
+                    sizeof(S_MuxDescriptor));
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    OSCL_DEFAULT_FREE(mux_descriptor);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0,
+                     "TSC_mt::SendMuxTableForLcn lcn(%d), mt sn(%d), mt num(%d)",
+                     lcn, iOutMtSn, entry_num));
+    return entry_num;
+}
+
+void TSC_mt::ReleaseMuxTables()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_mt::ReleaseMuxTable "));
+    S_ControlMsgHeader infHeader;
+    if (iToBeDeletedMuxEntryNumbers.size() == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_mt::ReleaseMuxTable No MT entries to be released"));
+        return;
+    }
+    unsigned mem_size = sizeof(S_MuxDescriptor) +
+                        iToBeDeletedMuxEntryNumbers.size() * sizeof(S_MultiplexEntryDescriptor);
+    uint8* mem_ptr = (uint8*)OSCL_DEFAULT_MALLOC(mem_size);
+    if (mem_ptr == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_mt::ReleaseMuxTable ERROR:  Memory allocation failed."));
+        return;
+    }
+    oscl_memset(mem_ptr, 0, mem_size);
+    PS_MuxDescriptor mux_descriptor = (PS_MuxDescriptor)mem_ptr;
+    mux_descriptor->size_of_multiplexEntryDescriptors =
+        iToBeDeletedMuxEntryNumbers.size();
+    mux_descriptor->multiplexEntryDescriptors =
+        (PS_MultiplexEntryDescriptor)(mem_ptr + sizeof(S_MuxDescriptor));
+    for (unsigned ii = 0; ii < iToBeDeletedMuxEntryNumbers.size(); ++ii)
+    {
+        uint8 mt_num = (uint8)iToBeDeletedMuxEntryNumbers[ii];
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0,
+                         "TSC_mt::ReleaseMuxTable Deleting Entry number=%d, sn=%d",
+                         mt_num, iOutMtSn));
+        iH223->RemoveOutgoingMuxDescriptor(mt_num);
+        mux_descriptor->multiplexEntryDescriptors[ii].option_of_elementList =
+            false;
+        mux_descriptor->multiplexEntryDescriptors[ii].multiplexTableEntryNumber =
+            (int8)mt_num;
+        iAvailableMuxEntryNumbers.push_back(mt_num);
+    }
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mt_Trf_Req,
+                    0,
+                    0,
+                    (uint8*)mux_descriptor,
+                    sizeof(S_MuxDescriptor));
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+    OSCL_DEFAULT_FREE(mem_ptr);
+    iPendingMtSn = iOutMtSn++;
+    iToBeDeletedMuxEntryNumbers.clear();
+}
+
+/**
+*  Generates and send multiplex table entries for all logical channels for which MT state is idle/pending
+**/
+void TSC_mt::MtTrfReq(OlcList& aOlcs)
+{
+    S_ControlMsgHeader infHeader;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_mt::MtTrfReq"));
+    CPVMultiplexEntryDescriptorVector descriptors;
+    CPVMultiplexEntryDescriptor* desc = NULL;
+    Oscl_Vector<OlcParam*, OsclMemAllocator> olc_list;
+    unsigned num_pending = aOlcs.FindOutgoingOlcsByMtState(MT_IDLE | MT_PENDING,
+                           olc_list);
+
+    if (num_pending == 0)
+    {
+        // No mux entries to send
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_mt::MtTrfReq No mux entries to send"));
+        return;
+    }
+
+    if (iAvailableMuxEntryNumbers.size() < num_pending)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0,
+                         "TSC_mt::MtTrfReq Ran out of mux table entries - needed(%d), have(%d)",
+                         num_pending, iAvailableMuxEntryNumbers.size()));
+        OSCL_LEAVE(PVMFErrNoResources);
+    }
+
+    for (unsigned lcn = 0; lcn < num_pending; ++lcn)
+    {
+        int entry_num = iAvailableMuxEntryNumbers[0];
+        iAvailableMuxEntryNumbers.erase(iAvailableMuxEntryNumbers.begin());
+        TPVChannelId channel_id = (olc_list[lcn]->GetDirection() == OUTGOING) ?
+                                  olc_list[lcn]->GetChannelId() :
+                                  olc_list[lcn]->GetReverseParams()->GetChannelId();
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_mt::MtTrfReq Descriptor for lcn(%d)=%d", channel_id, entry_num));
+        desc = iTSCcomponent->GenerateSingleDescriptor((uint8)entry_num, channel_id);
+        descriptors.push_back(desc);
+        olc_list[lcn]->SetMtState(MT_PENDING);
+        olc_list[lcn]->SetMtSn(iOutMtSn);
+        olc_list[lcn]->SetMtNum(entry_num);
+    }
+    iH223->SetOutgoingMuxDescriptors(descriptors);
+
+    PS_MultiplexEntryDescriptor temp = NULL;
+    PS_MuxDescriptor mux_descriptor =
+        (PS_MuxDescriptor)OSCL_DEFAULT_MALLOC(sizeof(S_MuxDescriptor));
+    oscl_memset(mux_descriptor, 0, sizeof(S_MuxDescriptor));
+    mux_descriptor->size_of_multiplexEntryDescriptors = descriptors.size();
+    mux_descriptor->multiplexEntryDescriptors =
+        (PS_MultiplexEntryDescriptor)OSCL_DEFAULT_MALLOC(
+            sizeof(S_MultiplexEntryDescriptor) *
+            mux_descriptor->size_of_multiplexEntryDescriptors);
+    oscl_memset(mux_descriptor->multiplexEntryDescriptors,
+                0,
+                sizeof(S_MultiplexEntryDescriptor) *
+                mux_descriptor->size_of_multiplexEntryDescriptors);
+    PS_MultiplexEntryDescriptor cur_desc =
+        mux_descriptor->multiplexEntryDescriptors;
+    Oscl_Vector<PS_MultiplexEntryDescriptor, PVMFTscAlloc> to_be_deleted;
+
+    for (unsigned num = 0; num < descriptors.size(); ++num)
+    {
+        temp = Copy_MultiplexEntryDescriptor(
+                   descriptors[num]->GetH245descriptor());
+        oscl_memcpy(cur_desc, temp, sizeof(S_MultiplexEntryDescriptor));
+        cur_desc++;
+        to_be_deleted.push_back(temp);
+    }
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Mt_Trf_Req,
+                    0,
+                    0,
+                    (uint8*)mux_descriptor,
+                    sizeof(S_MuxDescriptor));
+    // Primitive Send
+    iH245->DispatchControlMessage(&infHeader);
+
+    while (to_be_deleted.size())
+    {
+        PS_MultiplexEntryDescriptor desc = to_be_deleted.back();
+        Delete_MultiplexEntryDescriptor(desc);
+        OSCL_DEFAULT_FREE(desc);
+        to_be_deleted.pop_back();
+    }
+    OSCL_DEFAULT_FREE(mux_descriptor->multiplexEntryDescriptors);
+    OSCL_DEFAULT_FREE(mux_descriptor);
+
+    iPendingMtSn = iOutMtSn++;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_mt::MtTrfReq iOutMtSn(%d)", iOutMtSn));
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_node_interface.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_node_interface.cpp
new file mode 100644
index 0000000..1ff5c87
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_node_interface.cpp
@@ -0,0 +1,21 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef TSC_NODE_INTERFACE_H_INCLUDED
+#include "tsc_node_interface.h"
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_rme.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_rme.cpp
new file mode 100644
index 0000000..7269987
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_rme.cpp
@@ -0,0 +1,116 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_rme.c                                         */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include    "tsc_sub.h"
+#include    "h245def.h"
+#include	"tscmain.h"
+
+/*****************************************************************************/
+/*  function name        : Tsc_RmeSendReq                                    */
+/*  function outline     : Tsc_RmeSendReq procedure                          */
+/*  function discription : Tsc_RmeSendReq( void )                            */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+OSCL_EXPORT_REF void TSC_324m::RmeSendReq()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::RmeSendReq\n"));
+    S_ControlMsgHeader infHeader;
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Rme_Send_Req,
+                    0, 0, NULL, 0);
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_RmeSendRps                                    */
+/*  function outline     : Tsc_RmeSendRps procedure                          */
+/*  function discription : Tsc_RmeSendRps( void )                            */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::RmeSendRps()
+{
+    S_ControlMsgHeader infHeader;
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Rme_Send_Rps,
+                    0, 0, NULL, 0);
+    iH245->DispatchControlMessage(&infHeader);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_RmeRjtReq                                     */
+/*  function outline     : Tsc_RmeRjtReq procedure                           */
+/*  function discription : Tsc_RmeRjtReq( void )                             */
+/*  input data           : None                                              */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career (x)   :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void TSC_324m::RmeRjtReq()
+{
+    S_ControlMsgHeader infHeader;
+    S_RmeRejectCause parameter;
+
+    // REJECT.request primitive - Parameter[CAUSE]
+    parameter.index = 0; // unspecifiedCause
+
+    Tsc_SendDataSet(&infHeader,
+                    H245_PRIMITIVE,
+                    E_PtvId_Rme_Rjt_Req,
+                    0,
+                    0,
+                    (uint8*)&parameter,
+                    sizeof(S_RmeRejectCause));
+    iH245->DispatchControlMessage(&infHeader);
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_statemanager.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_statemanager.cpp
new file mode 100644
index 0000000..dda64f9
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_statemanager.cpp
@@ -0,0 +1,259 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+// ============================================================
+// FILE: TSC_statemanager.c
+//
+// DESCRIPTION: Terminal state management and initiation
+//   of TSC events.
+//
+// Written by Ralph Neff, PacketVideo, 3/16/2000
+// (c) 2000 PacketVideo Corp.
+// ============================================================
+
+#define TSC_statemanager_SRC
+#include "tsc_statemanager.h"
+#include "tsc_constants.h"
+
+void TSC_statemanager::InitVarsSession()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m");
+}
+
+void TSC_statemanager::InitVarsLocal()
+{
+    iN100 = N100_DEFAULT;
+    iSkipMsd = false;
+}
+
+TPVStatusCode TSC_statemanager::SetTerminalParam(CPVTerminalParam* params)
+{
+    CPVH324MParam* h324params = (CPVH324MParam*)params;
+    iSkipMsd = h324params->iSkipMsd;
+    return EPVT_Success;
+}
+
+void TSC_statemanager::MSDDetermineIndication(MSDStatus type)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_statemanager: MSD indication received.\n"));
+
+    //Master slave determination(R)...Start
+    if (ReadState(TSC_MSD_RECEIVE) != STARTED)
+    {
+        WriteState(TSC_MSD_RECEIVE, COMPLETE);
+    }
+    WriteState(TSC_MSD_DECISION, (type == MSD_MASTER) ? MASTER : SLAVE);
+}
+
+bool TSC_statemanager::MSDStart(TPVLoopbackMode iLoopbackMode)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_statemanager: MSD Start indication\n"));
+
+    WriteState(TSC_MSD, STARTED);
+    WriteState(TSC_MSD_RECEIVE, STARTED);
+    if (iLoopbackMode != PV_LOOPBACK_NONE)
+    {
+        SkipMsd(); // Skip MSD for loopback
+        return false;
+    }
+    return true;
+}
+
+
+// *********************************************************
+// =========================================================
+//                STATE AND EVENT PRIORITY I/O
+// =========================================================
+// *********************************************************
+
+// =========================================================
+// Tsc_StateInitialize()
+//
+// Set all terminal states to initial values.
+// =========================================================
+void TSC_statemanager::StateInitialize(void)
+{
+    // Exceptions
+    iTerminalState[TSC_MSD_RETRYCOUNT] = iN100;
+
+}
+
+// =========================================================
+// ReadState()
+//
+// Read a terminal state variable.
+// =========================================================
+int32 TSC_statemanager::ReadState(uint32 stateIndex)
+{
+    return iTerminalState[stateIndex];
+}
+
+// =========================================================
+// WriteState()
+//
+// Write to a terminal state variable.
+// =========================================================
+void TSC_statemanager::WriteState(uint32 stateIndex, uint32 value)
+{
+    StatusShow(stateIndex, value);
+    iTerminalState[stateIndex] = value;
+}
+
+// =========================================================
+// Tsc_StatusShow()
+//
+// Display the new value of a terminal state.
+// =========================================================
+void TSC_statemanager::StatusShow(uint32 stateIndex, uint32 value)
+{
+    OSCL_UNUSED_ARG(stateIndex);
+    OSCL_UNUSED_ARG(value);
+    return;
+}
+
+// =========================================================
+// Tsc_IncrementState()
+//
+// Increment a terminal state variable.
+// =========================================================
+void TSC_statemanager::IncrementState(uint32 stateIndex)
+{
+    ++iTerminalState[stateIndex];
+}
+
+// =========================================================
+// Tsc_DecrementState()
+//
+// Decrement a terminal state variable.
+// =========================================================
+void TSC_statemanager::DecrementState(uint32 stateIndex)
+{
+    --iTerminalState[stateIndex];
+}
+
+
+// *********************************************************
+// =========================================================
+//                   PRE-REQUISITE CHECKS
+// =========================================================
+// *********************************************************
+
+// =========================================================
+// Tsc_PreReq_CeSend()
+//
+// Check pre-requisites for initiating CE Send procedure.
+//
+// SPECIFICS: CE Send may be started at any time.
+// =========================================================
+uint32 TSC_statemanager::PreReq_CeSend()
+{
+    if (ReadState(TSC_CE_SEND) == NOT_STARTED)
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+// =========================================================
+// Tsc_PreReq_MsdSend()
+//
+// Check pre-requisites for initiating the MSD procedure.
+//
+// SPECIFICS: MSD may be started any time after completion of
+//            the CE Send procedure.
+// =========================================================
+uint32 TSC_statemanager::PreReq_MsdSend()
+{
+    if ((ReadState(TSC_MSD) == NOT_STARTED) &&
+            (ReadState(TSC_CE_SEND) == COMPLETE))
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+// =========================================================
+// PreReq_MtSend()
+//
+// Check pre-requisites for initiating the MT Send procedure.
+//
+// SPECIFICS: MT Send may be started at any time after
+//   the remote terminal's capabilities have been received
+// =========================================================
+uint32 TSC_statemanager::PreReq_MtSend()
+{
+    if ((ReadState(TSC_MT_SEND) == NOT_STARTED) &&
+            (ReadState(TSC_CE_RECEIVE) == COMPLETE))
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+// =========================================================
+// PreReq_LcAudioSend()
+//
+// Check pre-requisites for initiating LC Audio Send.
+//
+// SPECIFICS: LC Audio Send may be started at any time after
+//   the remote terminal's capabilities have been received.
+//   We additionally require MSD to be complete.
+// =========================================================
+bool TSC_statemanager::PreReq_LcMediaSend()
+{
+    if ((ReadState(TSC_CE_RECEIVE) == COMPLETE)  &&
+            (ReadState(TSC_MSD) == COMPLETE))
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+void TSC_statemanager::SkipMsd()
+{
+    // Make us a slave so BLC can succeed in loopback mode
+    WriteState(TSC_MSD_RECEIVE, COMPLETE);
+    WriteState(TSC_MSD_DECISION, SLAVE);
+    WriteState(TSC_MSD, COMPLETE);
+}
+
+
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_sub.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_sub.cpp
new file mode 100644
index 0000000..6c25c4a
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tsc_sub.cpp
@@ -0,0 +1,118 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+/*****************************************************************************/
+/*  file name            : tsc_sub.c                                         */
+/*  file contents        : Terminal State Control routine                    */
+/*  draw                 : '96.10.04                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment                                                                */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+#include "tsc_sub.h"         /* Sub Information Header                    */
+#include "oscl_mem.h"
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_SendDataSet                                   */
+/*  function outline     : Send Data Set procedure                           */
+/*  function discription : Tsc_SendDataSet( InfType,                         */
+/*                                          InfId,                           */
+/*                                          InfSupplement1,                  */
+/*                                          InfSupplement2,                  */
+/*                                          pParameter,                      */
+/*                                          Size )                           */
+/*  input data           : uint32                 Information Type             */
+/*                         uint32                 Information Id               */
+/*                         uint32                 Information Supplement 1     */
+/*                         uint32                 Information Supplement 2     */
+/*                         uint8*               Information Parameter        */
+/*                         uint32                 Information Parameter Size   */
+/*  output data          : PS_ControlMsgHeader         Send InfHeader Pointer       */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void Tsc_SendDataSet(PS_ControlMsgHeader pInfHeader,
+                     uint32    InfType,
+                     uint32    InfId,
+                     uint32    InfSupplement1,
+                     uint32    InfSupplement2,
+                     uint8*    pParameter,
+                     uint32    Size)
+{
+    // TRANSFER.request primitive -  MsgHeader
+    pInfHeader->InfType        = InfType;
+    pInfHeader->InfId          = InfId;
+    pInfHeader->InfSupplement1 = InfSupplement1;
+    pInfHeader->InfSupplement2 = InfSupplement2;
+    pInfHeader->pParameter     = pParameter;
+    pInfHeader->Size           = Size;
+}
+
+
+/*****************************************************************************/
+/*  function name        : Tsc_ChoiceDataSet                                 */
+/*  function outline     : Choice Data Set procedure                         */
+/*  function discription : Tsc_ChoiceDataSet( TrueTarget,                    */
+/*                                            pFirstTarget,                  */
+/*                                            NumberTarget )                 */
+/*  input data           : uint32                 True Target                  */
+/*                       : uint8*               First Target Pointer         */
+/*                       : uint32                 Target Numberd               */
+/*  output data          : None                                              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendent career      :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+void Tsc_ChoiceDataSet(uint32      TrueTarget,
+                       uint8*      pFirstTarget,
+                       uint32      NumberTarget)
+{
+    uint8*              pBooleanData;
+    uint32              Cnt;
+
+    for (pBooleanData = pFirstTarget, Cnt = 0;
+            Cnt < NumberTarget;
+            pBooleanData++, Cnt++)
+    {
+        if (TrueTarget == Cnt)
+        {
+            *pBooleanData = true;
+        }
+        else
+        {
+            *pBooleanData = false;
+        }
+    }
+    return;
+}
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tschandling.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tschandling.cpp
new file mode 100644
index 0000000..ac96664
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tschandling.cpp
@@ -0,0 +1,1206 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// ----------------------------------------------------------------------
+//
+// This Software is an original work of authorship of PacketVideo Corporation.
+// Portions of the Software were developed in collaboration with NTT  DoCoMo,
+// Inc. or were derived from the public domain or materials licensed from
+// third parties.  Title and ownership, including all intellectual property
+// rights in and to the Software shall remain with PacketVideo Corporation
+// and NTT DoCoMo, Inc.
+//
+// -----------------------------------------------------------------------
+
+#include    "tscmain.h"
+#include    "h245pri.h"         /* Primitive Infomation Header               */
+#include    "h245_deleter.h"    // (RAN-LEAK) - Prototypes for deep delete
+#include    "h245_copier.h"     // (RAN-LEAK) - Prototypes for deep copy
+#include    "cpvh223multiplex.h"
+#include    "logicalchannel.h"
+#include    "oscl_mem.h"
+#include    "tsc_constants.h"
+#include    "tsc_statemanager.h"
+#include    "tsc_lc.h"
+#include    "tsc_clc.h"
+#include    "tsc_blc.h"
+#include    "tsc_mt.h"
+#include    "tsc_component.h"
+#include    "tsc_channelcontrol.h"
+#include    "tsc_capability.h"
+
+// =============================================================
+// =============================================================
+// =====   HANDLING ROUTINES FOR USER EVENTS (FROM APP)    =====
+// =============================================================
+// =============================================================
+
+/*****************************************************************************/
+/*  function name        : OpenSession                                   */
+/*  input data           : PS_ControlMsgHeader         Dummy Pointer                */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  Note: This one is now called automatically when the TscMain thread      */
+/*        is created.  No queue message is required. (RAN)                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::OpenSession(void)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: OpenSession.\n"));
+
+    if (iSuppInfoLen)
+    {
+        /* Send supp info in UII msg  and wait for TCS from remote terminal */
+        Tsc_UII_Alphanumeric(iSuppInfo, (uint16)iSuppInfoLen);
+    }
+    else
+    {
+        CEStart();		// INITIATE CE-SEND
+        Tsc_IdcVi();    // Send vendor information
+        MSDStart();	    // INITIATE MSD
+    }
+    return(PhaseD_CSUP);
+}
+
+// ----------------------------------------------------------------
+// NOTE: The 'PhaseF Closing Channels' routines are removed.  (RAN)
+// These were:
+//   Status09Event12(), Status09Event13(),
+//   Status09Event17(), Status09Event18()
+// ----------------------------------------------------------------
+
+// =============================================================
+// SessionClose_Comm()
+//
+// TSC Session Close (in Ongoing Communication) command received from user.
+// =============================================================
+uint32 TSC_324m::SessionClose_Comm()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: SessionClose_Comm ... Start.\n"));
+    iTerminalStatus = PhaseF_End;
+    StopData();
+    iTSCcomponent->CloseChannels();
+    /* Primitive Send */
+    EndSessionCommand();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: EndSession complete.\n"));
+    return(iTerminalStatus);
+}
+
+// =============================================================
+// SessionClose_CSUP()
+//
+// TSC Session Close (in Call Setup).
+// =============================================================
+uint32 TSC_324m::SessionClose_CSUP()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SessionClose_CSUP"));
+    iTerminalStatus = PhaseF_End;
+    SignalCsupComplete(PVMFFailure);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: EndSession complete."));
+    return(iTerminalStatus);
+}
+
+
+// =============================================================
+// =============================================================
+// === HANDLING ROUTINES FOR SIGNAL ENTITY EVENTS (FROM 245) ===
+// =============================================================
+// =============================================================
+
+/*****************************************************************************/
+/*  function name        : LcEtbIdc           E_PtvId_Lc_Etb_Idc  */
+/*  function outline     : Status04/Event09 procedure                        */
+/*  function discription : Status04Event09( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::LcEtbIdc(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: LcEtbIdc.\n"));
+    return iTSCcomponent->LcEtbIdc(pReceiveInf);
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event10           E_PtvId_Lc_Etb_Cfm  */
+/*  function outline     : Status04/Event10 procedure                        */
+/*  function discription : Status04Event10( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::LcEtbCfm(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: LcEtbCfm.\n"));
+    return iTSCcomponent->LcEtbCfm(pReceiveInf);
+}
+
+// =============================================================
+// Status04Event11()                     E_PtvId_Lc_Rls_Idc
+//
+// This is LCSE RELEASE.indication.
+// =============================================================
+uint32 TSC_324m::LcRlsIdc(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: LcRlsIdc.\n"));
+    return iTSCcomponent->LcRlsIdc(pReceiveInf);
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event13           E_PtvId_Lc_Err_Idc  */
+/*  function outline     : Status04/Event13 procedure                        */
+/*  function discription : Status04Event13( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::LcErrIdc(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: Logical channel error indication.\n"));
+
+    /*
+    ErrCode_Lc_A ,      // ( 6) inappropriate message ( OpenLogicalChannelAck )
+
+    ErrCode_Lc_B ,      // ( 7) inappropriate message ( OpenLogicalChannelReject )
+
+    ErrCode_Lc_C ,      // ( 8) inappropriate message ( CloseLogicalChannelAck )
+
+    ErrCode_Lc_D ,      // ( 9) no response from Peer LCSE / B-LCSE ( Timer T103 Expiry ) */
+
+    /*	switch(pReceiveInf->pParameter){
+    	  case ErrCode_Lc_A:
+    		break;
+    	  case ErrCode_Lc_B:
+    		break;
+    	  case ErrCode_Lc_C:
+    		break;
+    	  case ErrCode_Lc_D:
+    		break;
+    	}
+    */
+    /* Buffer Free */
+//    OSCL_DEFAULT_FREE( pReceiveInf->pParameter );
+//    OSCL_DEFAULT_FREE( pReceiveInf );
+
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event14          E_PtvId_Blc_Etb_Idc  */
+/*  function outline     : Status04/Event14 procedure                        */
+/*  function discription : Status04Event14( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::BlcEtbIdc(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: BlcEtbIdc.\n"));
+    return iTSCcomponent->BlcEtbIdc(pReceiveInf);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Status04Event15          E_PtvId_Blc_Etb_Cfm  */
+/*  function outline     : Status04/Event15 procedure                        */
+/*  function discription : Status04Event15( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::BlcEtbCfm(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::BlcEtbCfm forward(%d), reverse(%d))\n",
+                     pReceiveInf->InfSupplement1,  pReceiveInf->InfSupplement2));
+    if (iLoopbackMode == PV_LOOPBACK_NONE)
+    {
+        iTSCcomponent->BlcEtbCfm(pReceiveInf);
+    }
+    return PhaseE_Comm;
+}
+
+// =============================================================
+// Status04Event16()                   E_PtvId_Blc_Rls_Idc
+//
+// This is BLCSE RELEASE.indication.  It is called when
+// a Bi-Dir OLCReject is received.  It could be from an incoming or outgoing SE
+// =============================================================
+uint32 TSC_324m::BlcRlsIdc(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: BlcRlsIdc.\n"));
+    return iTSCcomponent->BlcRlsIdc(pReceiveInf);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Status04Event18          E_PtvId_Blc_Err_Idc  */
+/*  function outline     : Status04/Event18 procedure                        */
+/*  function discription : Status04Event18( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::BlcErrIdc(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::BlcErrIdc "));
+    return PhaseE_Comm;
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event22           E_PtvId_Mt_Trf_Idc  */
+/*  function outline     : Status04/Event22 procedure                        */
+/*  function discription : Status04Event22( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status04Event22(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status04Event22"));
+    return MuxTableTransferIndication(pReceiveInf);
+}
+
+uint32 TSC_324m::MuxTableTransferIndication(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MuxTableTransferIndication, wnsrp status=%d",
+                     iSrp->WnsrpStatusGet()));
+    PS_MuxDescriptor pMux = (PS_MuxDescriptor)pReceiveInf->pParameter;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status04Event22 Received mux entries sn=%d, num mux entries=%d",
+                     pReceiveInf->InfSupplement1, pMux->size_of_multiplexEntryDescriptors));
+
+    CPVMultiplexDescriptor desc(pMux);
+    ((CPVH223Multiplex*)iH223)->SetIncomingMuxTableEntries(&desc);
+
+    /* If WNSRP is enabled and Mux Entry TSC_WNSRP_MUX_ENTRY_NUMBER is received, disable WNSRP */
+    if (iSrp->WnsrpStatusGet() == SRP::WNSRP_TX_SUPPORT)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::Status04Event22 WNSRP is ON.  Checking for mux entry 15."));
+        for (unsigned entry_num = 0; entry_num < (unsigned)pMux->size_of_multiplexEntryDescriptors; entry_num++)
+        {
+            if (pMux->multiplexEntryDescriptors[entry_num].multiplexTableEntryNumber ==
+                    TSC_WNSRP_MUX_ENTRY_NUMBER)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::Status04Event22 Received new descriptor for mux entry 15.  Disabling WNSRP."));
+                iSrp->DisableWNSRPSupport();
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::Status04Event22 Received new descriptor for mux entry 15.  Flushing control channel."));
+                /* Flush the control logical channel */
+                PVMFStatus aStatus = PVMFFailure;
+                H223OutgoingChannelPtr outgoing_control_channel;
+                aStatus = iH223->GetOutgoingChannel(0, outgoing_control_channel);
+                if (aStatus == PVMFSuccess)
+                {
+                    outgoing_control_channel->Flush();
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                    (0, "TSC_324m::MuxTableTransferIndication Error - Failed to lookup logical channel 0"));
+                    return iTerminalStatus;
+                }
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::Status04Event22 Received new descriptor for mux entry 15.  Done."));
+                break;
+            }
+        }
+    }
+    /* TRANSFER.response(MT) Primitive Send */
+    iTSCmt.MtTrfRps(pReceiveInf->InfSupplement1, pMux); // Pass pMux on for response.
+    desc.descriptor = NULL;
+    return 0;
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event23            E_PtvId_Mt_Trf_Cfm */
+/*  function outline     : Status04/Event23 procedure                        */
+/*  function discription : Status04Event23( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status04Event23(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status04Event23 sn=%d", pReceiveInf->InfSupplement1));
+    iTSCcomponent->MuxTableSendComplete(pReceiveInf->InfSupplement1, PVMFSuccess);
+    return 0;
+}
+
+
+OsclAny TSC_324m::TcsMsdComplete()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::TcsMsdComplete"));
+    SignalCsupComplete(PVMFSuccess);
+    iTSCcomponent->TcsMsdComplete();
+}
+
+OsclAny TSC_324m::SignalCsupComplete(PVMFStatus status)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SignalCsupComplete(%d)\n", status));
+    iObserver->ConnectComplete(status);
+    // update the node state
+    if (status == PVMFSuccess)
+    {
+        iTerminalStatus = PhaseE_Comm;
+    }
+}
+
+/*****************************************************************************/
+/*  function name        : Status04Event24            E_PtvId_Mt_Rjt_Idc */
+/*  function outline     : Status04/Event24 procedure                        */
+/*  function discription : Status04Event24( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status04Event24(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                    (0, "TSC_324m::Status04Event24 Mux table reject received dir(%d), sn(%d)",
+                     pReceiveInf->InfSupplement1, pReceiveInf->InfSupplement2));
+    if ((S_InfHeader::TDirection)pReceiveInf->InfSupplement1 == S_InfHeader::OUTGOING)
+    {
+        iTSCcomponent->MuxTableSendComplete(pReceiveInf->InfSupplement2,
+                                            PVMFFailure);
+    }
+    return(PhaseD_CSUP);
+}
+
+// =============================================================
+// Status04Event50()                  E_PtvId_Blc_Etb_Cfm2
+//
+// This is "BLCSE ESTABLISH.confirm2"
+// It is called when SE receives an OLCConfirm (Bi-Dir).
+// =============================================================
+uint32 TSC_324m::BlcEtbCfm2(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: BlcEtbCfm2.\n"));
+    return iTSCcomponent->BlcEtbCfm2(pReceiveInf);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Status08Event12           E_PtvId_Lc_Rls_Cfm  */
+/*  function outline     : Status08/Event12 procedure                        */
+/*  function discription : Status08Event12( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '00.4.13                                          */
+/*---------------------------------------------------------------------------*/
+uint32 TSC_324m::LcRlsCfm(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: LcRlsCfm.\n"));
+    iTSCcomponent->LcRlsCfm(pReceiveInf);
+    return(PhaseE_Comm);
+}
+
+
+/*****************************************************************************/
+/*  function name        : Status08Event17          E_PtvId_Blc_Rls_Cfm  */
+/*  function outline     : Status08/Event17 procedure                        */
+/*  function discription : Status08Event17( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '00.4.13                                         */
+/*---------------------------------------------------------------------------*/
+/* RAN - Bi-Dir OLCAck */
+uint32 TSC_324m::BlcRlsCfm(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: BlcRlsCfm.\n"));
+    iTSCcomponent->BlcRlsCfm(pReceiveInf);
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event19          E_PtvId_Clc_Cls_Idc  */
+/*  function outline     : Status08/Event19 procedure                        */
+/*  function discription : Status08Event19( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event19(PS_ControlMsgHeader pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: Status08Event19.\n"));
+    return iTSCcomponent->Status08Event19(pReceiveInf);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event20          E_PtvId_Clc_Cls_Cfm  */
+/*  function outline     : Status08/Event20 procedure                        */
+/*  function discription : Status08Event20( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event20(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: RequestChannelClose(S)...Complete\n"));
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event21           E_PtvId_Clc_Rjt_Idc */
+/*  function outline     : Status08/Event21 procedure                        */
+/*  function discription : Status08Event21( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event21(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: RequestChannelClose(%d)...Failed\n", pReceiveInf->InfSupplement1));
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event22            E_PtvId_Mt_Trf_Idc */
+/*  function outline     : Status08/Event22 procedure                        */
+/*  function discription : Status08Event22( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event22(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status08Event22 Received mux entries sn=%d",
+                     pReceiveInf->InfSupplement1));
+    return MuxTableTransferIndication(pReceiveInf);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event23            E_PtvId_Mt_Trf_Cfm */
+/*  function outline     : Status08/Event23 procedure                        */
+/*  function discription : Status08Event23( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event23(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status04Event23 sn=%d",
+                     pReceiveInf->InfSupplement1));
+    iTSCcomponent->MuxTableSendComplete(pReceiveInf->InfSupplement1,
+                                        PVMFSuccess);
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event24            E_PtvId_Mt_Rjt_Idc */
+/*  function outline     : Status08/Event24 procedure                        */
+/*  function discription : Status08Event24( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event24(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                    (0, "TSC_324m::Status08Event24 Mux table reject received dir(%d), sn(%d)",
+                     pReceiveInf->InfSupplement1, pReceiveInf->InfSupplement2));
+    if ((S_InfHeader::TDirection)pReceiveInf->InfSupplement1 ==
+            S_InfHeader::OUTGOING)
+    {
+        iTSCcomponent->MuxTableSendComplete(pReceiveInf->InfSupplement2,
+                                            PVMFFailure);
+    }
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event25          E_PtvId_Rme_Send_Idc */
+/*  function outline     : Status08/Event25 procedure                        */
+/*  function discription : Status08Event25( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event25(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status08Event25 RME received.  Rejecting it."));
+    RmeRjtReq();
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event26          E_PtvId_Rme_Send_Cfm */
+/*  function outline     : Status08/Event26 procedure                        */
+/*  function discription : Status08Event26( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event26(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: RME complete.\n"));
+
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event27         E_PtvId_Rme_Rjt_Idc   */
+/*  function outline     : Status08/Event27 procedure                        */
+/*  function discription : Status08Event27( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event27(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: RME failed: reject indication.\n"));
+    /*  NO ACTION FOR NOW.  MAY WANT TO ADD BETTER HANDLING LATER.
+    */
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : ModeRequestIndication           E_PtvId_Mr_Trf_Idc  */
+/*  function outline     : ModeRequestIndication procedure                        */
+/*  function discription : ModeRequestIndication( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+/* WWURM: modified to handle incoming request mode message */
+uint32 TSC_324m::ModeRequestIndication(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::ModeRequestIndication"));
+    MrRjtReq();
+    return(PhaseE_Comm);
+}
+
+// -------------------------------------------------
+// getModeRequestInfo()
+//
+// WWURM: help function for request mode message.
+// -------------------------------------------------
+OsclAny TSC_324m::getModeRequestInfo(PS_ControlMsgHeader pReceiveInf,
+                                     int32 *param1, int32 *param2)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    OSCL_UNUSED_ARG(param2);
+    OSCL_UNUSED_ARG(param1);
+#if 0
+    PS_RequestMode  pModeElementParam;
+    PS_ModeElement	pModeElement;
+    int32 i, nModeElements;
+
+    if (GetSimpleAudioType() == PV_AUD_TYPE_GSM)
+    {
+        pModeElementParam = (PS_RequestMode) pReceiveInf->pParameter;
+        nModeElements = pModeElementParam->requestedModes->size;
+        for (i = 0; i < nModeElements; i++)
+        {
+            pModeElement = (pModeElementParam->requestedModes->item + i);
+            if (pModeElement->modeType.index == 2)
+            {
+                PS_AudioMode pAudioMode = pModeElement->modeType.audioMode;
+                if (pAudioMode->index == 20)
+                {
+                    PS_GenericCapability pGenericCap = pAudioMode->genericAudioMode;
+                    if (pGenericCap->option_of_nonCollapsing)
+                    {
+                        *param1 = GSM_RATE_CHANGE;
+                        *param2 = pGenericCap->nonCollapsing->parameterValue.unsignedMin;
+                        return;
+                    }
+                }
+            }
+        }
+    }
+    *param1 = -1;
+    *param2 = 0;
+#endif
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event29           E_PtvId_Mr_Trf_Cfm  */
+/*  function outline     : Status08/Event29 procedure                        */
+/*  function discription : Status08Event29( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event29(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event30            E_PtvId_Mr_Rjt_Idc */
+/*  function outline     : Status08/Event30 procedure                        */
+/*  function discription : Status08Event30( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event30(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+#if 0
+    /*  DO NOTHING FOR NOW.  ADD BETTER HANDLING LATER. */
+
+    /* Buffer Free */
+    OSCL_DEFAULT_FREE(pReceiveInf->pParameter);
+    OSCL_DEFAULT_FREE(pReceiveInf);
+#endif
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event31           E_PtvId_Rtd_Trf_Cfm */
+/*  function outline     : Status08/Event31 procedure                        */
+/*  function discription : Status08Event31( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event31(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    uint32 rtd = (uint32)((PS_Delay_Rtd)pReceiveInf->pParameter)->Delay_Value;
+    iNumRtdRequests++;
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Status08Event31 - iNumRtdRequests = %d, RTD = %d ms",
+                     iNumRtdRequests, rtd));
+    iRtdAve += rtd;
+    if (rtd < iRtdMin)
+    {
+        iRtdMin = rtd;
+    }
+    if (rtd > iRtdMax)
+    {
+        iRtdMax = rtd;
+    }
+
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : Status08Event32           E_PtvId_Rtd_Exp_Idc */
+/*  function outline     : Status08/Event32 procedure                        */
+/*  function discription : Status08Event32( pReceiveInf )                */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::Status08Event32(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+#if 0
+    //Tsc_Analyzer( "<Comm> Round trip delay...Failed" );
+
+    /* WWUAPI: do nothing here
+    */
+
+    /* Buffer Free */
+    OSCL_DEFAULT_FREE(pReceiveInf->pParameter);
+    OSCL_DEFAULT_FREE(pReceiveInf);
+#endif
+    return(PhaseE_Comm);
+}
+
+//===============================================================
+// SendTerminalCapabilitySet()               E_PtvId_Cmd_Stcs_Cfm (RAN)
+//
+// Handle a received SendTerminalCapabilitySet codeword.
+//===============================================================
+uint32 TSC_324m::SendTerminalCapabilitySet(PS_ControlMsgHeader  pReceiveInf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SendTerminalCapabilitySet"));
+    OSCL_UNUSED_ARG(pReceiveInf);
+    CEStart();
+    return(PhaseE_Comm);
+}
+
+//===============================================================
+// FlowControlCommandReceived()                 E_PtvId_Cmd_Fc_Cfm (RAN)
+//
+// This routine handles a received FlowControl (FC) command.
+// For now it does nothing but print the command received message.
+// But later we should pass the received params up to application layer.
+//===============================================================
+uint32 TSC_324m::FlowControlCommandReceived(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+#if 0
+    PS_FlowControlCommand p_FCC;
+
+    //Tsc_Analyzer( "<Comm> Flow Control Command(R)...Received" );
+    p_FCC = (PS_FlowControlCommand) pReceiveInf->pParameter;
+
+    /* -------------------------------------------- */
+    /* NO ACTION FOR NOW.  ADD HANDLING LATER.      */
+    /* -------------------------------------------- */
+
+    // Deep OSCL_DEFAULT_FREE the input parameter (RAN-LEAK)
+    Delete_FlowControlCommand(p_FCC);
+    OSCL_DEFAULT_FREE(pReceiveInf->pParameter);
+    OSCL_DEFAULT_FREE(pReceiveInf);
+#endif
+    SendFunctionNotSupportedIndication(2, pReceiveInf->EncodedMsg,
+                                       (uint16)pReceiveInf->EncodedMsgSize);//unknown function
+
+    return(PhaseE_Comm);
+}
+
+//===============================================================
+// MiscCmdRecv()              E_PtvId_Cmd_Mscl_Cfm (RAN)
+//
+// This routine handles a received Miscellaneous (MSCL) command.
+//===============================================================
+uint32 TSC_324m::MiscCmdRecv(PS_ControlMsgHeader  pReceiveInf)
+{
+    PS_MiscellaneousCommand mc;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MiscCmdRecv - Received Miscellaneous command"));
+    mc = (PS_MiscellaneousCommand) pReceiveInf->pParameter;
+
+    // if command is a request for new I-Frame, then verify outgoing
+    // channel exists and request new I-Frame from observer
+    if (mc->mcType.index == 5)    // 5 = videoFastUpdatePicture
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: MiscCmdRecv - Received videoFastUpdatePicture, lcn(%d)\n",
+                         mc->logicalChannelNumber));
+        if (iTerminalStatus != PhaseE_Comm)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: MiscCmdRecv Error - invalid state(%d)",
+                             iTerminalStatus));
+            return iTerminalStatus;
+        }
+        H223OutgoingChannelPtr lcn;
+        PVMFStatus aStatus = iH223->GetOutgoingChannel(mc->logicalChannelNumber,
+                             lcn);
+        if (aStatus != PVMFSuccess)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::MiscCmdRecv Error - Request I-Frame for invalid channel ID=%d",
+                             mc->logicalChannelNumber));
+            return iTerminalStatus;
+        }
+        if (iObserver) iObserver->RequestFrameUpdate(lcn);
+    }
+    if (mc->mcType.index == 7)    // 7 = videoSpatialTemporalTradeoff
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: MiscCmdRecv - Received videoTemporalSpatialTradeOff lcn(%d), value(%d)",
+                         mc->logicalChannelNumber, mc->mcType.videoTemporalSpatialTradeOff));
+        if (iTerminalStatus != PhaseE_Comm)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: MiscCmdRecv Error - invalid state(%d)",
+                             iTerminalStatus));
+            return iTerminalStatus;
+        }
+        if (iTSC_324mObserver)
+        {
+            iTSC_324mObserver->VideoSpatialTemporalTradeoffCommandReceived(mc->logicalChannelNumber,
+                    mc->mcType.videoTemporalSpatialTradeOff);
+        }
+    }
+    else if (mc->mcType.index == 11)   // 11 = maxMuxPduSize
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: MiscCmdRecv - Received maxMuxPduSize, size(%d)\n",
+                         mc->mcType.maxH223MUXPDUsize));
+        TPVStatusCode ret = iH223->SetMaxOutgoingPduSize(mc->mcType.maxH223MUXPDUsize);
+        if (ret != EPVT_Success)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m: Error - Request maxMuxPduSize(%d), error(%d)\n",
+                             mc->mcType.maxH223MUXPDUsize, ret));
+        }
+    }
+    return(iTerminalStatus);
+}
+
+//===============================================================
+// Status08Event55()               E_PtvId_Cmd_Hmr_Cfm (RAN)
+//
+// This routine handles a received H223MultiplexReconfiguration (HMR) command.
+// For now it does nothing but print the command received message.
+// But later we should pass the received params up to application layer.
+//===============================================================
+uint32 TSC_324m::Status08Event55(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    SendFunctionNotSupportedIndication(2, pReceiveInf->EncodedMsg,
+                                       (uint16)pReceiveInf->EncodedMsgSize);//unknown function
+#if 0
+    PS_H223MultiplexReconfiguration p_HMR;
+
+    //Tsc_Analyzer( "<Comm> H223MultiplexReconfiguration -- Received" );
+    p_HMR = (PS_H223MultiplexReconfiguration) pReceiveInf->pParameter;
+
+    /* -------------------------------------------- */
+    /* Act on the received HMR Command.             */
+    /*   (THIS WILL REQUIRE LINKS TO H223)          */
+    /* -------------------------------------------- */
+    if (p_HMR->index == 0)  /* h223ModeChange */
+    {
+        switch (p_HMR->h223ModeChange->index)
+        {
+            case 0:  /* toLevel0 */
+                /* INSERT ACTION HERE */
+                break;
+            case 1:  /* toLevel1 */
+                /* INSERT ACTION HERE */
+                break;
+            case 2:  /* toLevel2 */
+                /* INSERT ACTION HERE */
+                break;
+            case 3:  /* toLevel2withOptionalHeader */
+                /* INSERT ACTION HERE */
+                break;
+        }
+    }
+    else  /* h223AnnexADoubleFlag */
+    {
+        switch (p_HMR->h223AnnexADoubleFlag->index)
+        {
+            case 0:  /* start */
+                /* INSERT ACTION HERE */
+                break;
+            case 1:  /* stop */
+                /* INSERT ACTION HERE */
+                break;
+        }
+    }
+
+    // Deep OSCL_DEFAULT_FREE the input parameter (RAN-LEAK)
+    Delete_H223MultiplexReconfiguration(p_HMR);
+    OSCL_DEFAULT_FREE(pReceiveInf->pParameter);
+    OSCL_DEFAULT_FREE(pReceiveInf);
+#endif
+    return(PhaseE_Comm);
+}
+
+/*****************************************************************************/
+/*  function name        : EndSessionRecv          E_PtvId_Cmd_Es_Cfm    */
+/*  function outline     : EndSessionCommand Receive procedure               */
+/*  function discription : EndSessionRecv( pReceiveInf )                 */
+/*  input data           : PS_ControlMsgHeader         Receive InfHeader Pointer    */
+/*  output data          : uint32                 Terminal Status              */
+/*  draw time            : '96.10.09                                         */
+/*---------------------------------------------------------------------------*/
+/*  amendment career(x)  :                                                   */
+/*                                                                           */
+/*              Copyright (C) 1996 NTT DoCoMo                                */
+/*****************************************************************************/
+uint32 TSC_324m::EndSessionRecv(PS_ControlMsgHeader  pReceiveInf)
+{
+    OSCL_UNUSED_ARG(pReceiveInf);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::EndSessionRecv"));
+    iDisconnectInitiator |= EPVT_REMOTE;
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            iObserver->DisconnectRequestReceived();
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "EndSession...Received in invalid state"));
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::EndSessionRecv Ignoring end session due to invalid state(%d)",
+                             iInterfaceState));
+    }
+    StopData();
+    iTSCcomponent->CloseChannels();
+    return PhaseF_End;
+}
+
+
+// ===============================================================
+// StopData()
+//
+// Sets flags in the H324 system table which stop data transmission
+// for each open, outgoing logical channel.
+// ================================================================
+OsclAny TSC_324m::StopData()
+{
+    iTSCcomponent->StopData();
+}
+
+
+// ======================================================
+// GetDecoderConfigFromOLC()
+//
+// Returns the decoder configuration info from an incoming
+// OLC codeword.  The info is copied from either the
+// Forward or Reverse LogicalChannelParameters, depending
+// on the value of input argument forRev:
+//
+//     forRev = 0  --> info from Forward Parameters
+//     forRev = 1  --> info from Reverse Parameters
+//
+// Note that if 'pPara' does not have genericVideo description
+//   (i.e. MPEG4), then a NULL string is returned.
+// =======================================================
+uint8* GetDecoderConfigFromOLC(PS_ForwardReverseParam pPara, uint32 forRev, uint16 *nOctets)
+{
+    uint32 i = 0, n = 0;
+    PS_GenericCapability pGenericCap = NULL;
+    PS_GenericParameter	nonCollapsing = NULL;
+    uint8* ret = NULL;
+
+    if (forRev)  	/* reverse */
+    {
+        if (pPara->reverseLogicalChannelParameters.dataType.videoData->index == 5) /* genericVideoCapability */
+        {
+            pGenericCap = pPara->reverseLogicalChannelParameters.dataType.videoData->genericVideoCapability;
+        }
+    }
+    else  		/* forward  */
+    {
+        if (pPara->forwardLogicalChannelParameters.dataType.videoData->index == 5) /* genericVideoCapability */
+        {
+            pGenericCap = pPara->forwardLogicalChannelParameters.dataType.videoData->genericVideoCapability;
+        }
+    }
+
+    if (pGenericCap != NULL) 	/* Search for decoderConfig parameters */
+    {
+        n = pGenericCap->size_of_nonCollapsing;
+        for (i = 0; i < n; i++)
+        {
+            nonCollapsing = &pGenericCap->nonCollapsing[i];
+            if (nonCollapsing->parameterIdentifier.standard == 2)
+            {
+                *nOctets = nonCollapsing->parameterValue.octetString->size;
+                ret = (uint8*) OSCL_DEFAULT_MALLOC(*nOctets);
+                oscl_memcpy(ret, nonCollapsing->parameterValue.octetString->data, *nOctets);
+                return ret;
+            }
+        }
+    }
+    *nOctets = 0;	/* None found; return empty string */
+    return NULL;
+}
+
+// =========================================================
+// ShowTsc()
+//
+// This function takes an output analysis line, adds the
+// proper indent, and sends the result out to the display
+// routine.  The 'tag' argument is simply passed on.
+// =========================================================
+OsclAny TSC_324m::ShowTsc(uint16 tag, uint16 indent, char* inString)
+{
+    OSCL_UNUSED_ARG(inString);
+    OSCL_UNUSED_ARG(indent);
+    OSCL_UNUSED_ARG(tag);
+#ifdef PVTsc_Analyzer
+    uint32 i;
+    char outString[200];
+
+    /* Construct outString with proper indent */
+    for (i = 0;i < indent;++i)
+    {
+        outString[i] = ' ';
+    }
+    sprintf(outString + i, "%s", inString);
+
+    /* Send outString to display */
+    PV//Tsc_Analyzer(tag,outString);         /* The real deal */
+#endif
+}
+
+// =======================================================
+// //Tsc_Analyzer()
+//
+// Display messages using the central Tsc_Analyzer functions.
+// =======================================================
+/*OsclAny TSC_324m::Tsc_Analyzer(char* msg)
+{
+#ifdef PVTsc_Analyzer
+	ShowTsc(Tsc_Analyzer_TSC,0,msg);
+#endif
+}*/
+
+
+
+
+
+// =======================================================
+// CheckAltCapSet()								(RAN-32K)
+//
+// This routine checks an AlternativeCapabilitySet structure
+//   to see if a particular entry number is present.  Simple.
+// =======================================================
+uint32 TSC_324m::CheckAltCapSet(PS_AlternativeCapabilitySet pAltCapSet,
+                                uint32 entry, uint32* preference_index)
+{
+    uint32 i;
+    *preference_index = 999;
+    for (i = 0;i < pAltCapSet->size;++i)
+    {
+        if (pAltCapSet->item[i] == entry)
+        {
+            *preference_index = i;
+            return(true);
+        }
+    }
+
+    return(false);
+}
+
+
+CPvtTerminalCapability* TSC_324m::GetRemoteCapability()
+{
+    return iTSCcapability.GetRemoteCapability();
+}
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tscmain.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tscmain.cpp
new file mode 100644
index 0000000..a7a0511
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tscmain.cpp
@@ -0,0 +1,2592 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_base.h"
+#include "oscl_mem.h"
+#include "osclconfig_compiler_warnings.h"
+#include "tscmain.h"
+#include "h223types.h"
+#include "h223_api.h"
+#include "h223.h"
+#include "cpvh223multiplex.h"
+#include "layer.h"
+#include "tsc_eventreceive.h"
+#include "tsc_h324m_config.h"
+#include "tsc_statemanager.h"
+#include "tsc_lc.h"
+#include "tsc_blc.h"
+#include "tsc_clc.h"
+#include "tsc_constants.h"
+#include "tsc_mt.h"
+#include "tsc_component.h"
+#include "tsc_capability.h"
+#include "tsc_channelcontrol.h"
+#ifdef MEM_TRACK
+#include "oscl_mem.h"
+#include "oscl_mem_audit.h"
+#endif
+#define PV_2WAY_TSC_TIMER_ID "PV_2WAY_TSC_TIMER"
+#define PV_2WAY_TSC_TIMER_INTERVAL 1 /* 1 second */
+
+#define PV_2WAY_TSC_NUM_CMD_Q_ELEMENTS 10
+#define PV_2WAY_TSC_NUM_PENDING_CMD_Q_ELEMENTS 10
+
+#define TSC_MAX_CONTROL_CHANNEL_BITRATE_BPS 64000
+#define TSC_BIG_UINT32 0XFFFFFFFF
+#define TSC_H223_LEVEL_DEFAULT H223_LEVEL2
+#define DEFAULT_TCS_RECEIVE_TIMEOUT_SECONDS 20
+#define DEFAULT_TCS_LEVEL_SETUP_TIMEOUT_SECONDS 6
+#define DEFAULT_RTD_TIMER_SECONDS 7
+
+
+// Default command queue reserve size
+#define PVMF_CMD_QUEUE_RESERVE 10
+
+// Starting value for command IDs
+#define PVMF_CMD_ID_START 10000
+
+// the assumed minimum T401 timer interval for sizing memory pools
+#define PV2WAY_TSC_MIN_T401_INCOMING 100
+
+OSCL_EXPORT_REF TSC_324m::TSC_324m(TPVLoopbackMode aLoopbackMode)
+        :   TSC(),
+        OsclActiveObject(OsclActiveObject::EPriorityHigh, "TSC"),
+        Msd(NULL),
+        Ce(NULL),
+        iSrp(NULL),
+        iH245(NULL),
+        iH223(NULL),
+        iVendor(NULL),
+        iProductNumber(NULL),
+        iVersionNumber(NULL),
+        iVendorR(NULL),
+        iProductNumberR(NULL),
+        iVersionNumberR(NULL),
+        iTransmitCaps(NULL),
+        iSuppInfo(NULL),
+        iSuppInfoLen(0),
+        iLoopbackMode(aLoopbackMode),
+        iTimer(NULL),
+        iOutgoingSrpPort(NULL),
+        iIncomingSrpPort(NULL),
+        iTscSrpBuffer(NULL),
+        iLogger(NULL),
+        iTSC_324mObserver(NULL),
+        iTSCcomponent(NULL),
+        iTSCblc(iTSCstatemanager),
+        iTSClc(iTSCstatemanager),
+        iTSCcapability(iTSCstatemanager),
+        iComponentRegistry(iTSCstatemanager,
+                           iTSCcapability,
+                           iTSClc,
+                           iTSCblc,
+                           iTSCclc,
+                           iTSCmt)
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.h245user");
+
+    iTSCcomponent = NULL;
+
+    AddToScheduler();
+
+    SetDispatchTable();
+
+    iDisconnectInitiator = EPVT_NONE;
+    iConnectFailReason = EPVT_Failed;
+
+    iOutgoingSrpPort = NULL;
+    iIncomingSrpPort = NULL;
+
+    iTscSrpBuffer = NULL;
+    iCurrentCmdId = 1;
+    iInitialized = false;
+    iInitializedComponent = false;
+    iEnableWnsrp = true;
+    iCmdQueue.Construct(PVMF_CMD_ID_START, PVMF_CMD_QUEUE_RESERVE);
+    iPendingCmdQueue.Construct(PVMF_CMD_ID_START, PVMF_CMD_QUEUE_RESERVE);
+}
+
+TSC_324m::~TSC_324m()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::~TSC_324m"));
+    ResetTsc();
+}
+
+void TSC_324m::SetInitialValues()
+{
+    initVarsLocal();
+    initVarsSession();
+    iInitialized = true;
+}
+
+void TSC_324m::initVarsLocal()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::initVarsLocal"));
+
+    if (iTransmitCaps)
+    {
+        OSCL_DEFAULT_FREE(iTransmitCaps);
+        iTransmitCaps = NULL;
+    }
+
+
+    iSendRme = false;
+    iCsupSeq = 0;
+    iRequestMaxMuxPduSize = H223_MAX_DEMUX_PDU_SIZE;
+
+    iPendingCmdQueue.Construct(1, 5);
+
+    iOutgoingPduType = H223_PDU_COMBINED;
+
+    iEndSessionTimeout = DEFAULT_END_SESSION_TIMEOUT;
+
+    iTimerValues.iT101 = iTimerValues.iT103 = iTimerValues.iT104 =
+                             iTimerValues.iT105 = iTimerValues.iT106 = iTimerValues.iT107 =
+                                                      iTimerValues.iT108 = iTimerValues.iT109 = TSC_SE_TIMEOUT_DEFAULT;
+    iT401 = T401_DEFAULT; /* SRP */
+    iN100 = N100_DEFAULT; /* H245 */
+    iN401 = N401_DEFAULT; /* SRP */
+    iCeRetries = iN100; /* Num CE retries left */
+
+    iEnableWnsrp = true;
+
+    iMultiplexingDelayMs = 0;
+    iInLogicalChannelBufferingMs = 0;
+    iOutLogicalChannelBufferingMs = 0;
+
+    iTSCstatemanager.InitVarsLocal();
+    iTSCcapability.InitVarsLocal();
+    if (iTSCcomponent)
+    {
+        iTSCcomponent->InitVarsLocal();
+    }
+}
+
+void TSC_324m::initVarsSession()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::initVarsSession"));
+    iTerminalStatus = Phase0_Idle;		/* Terminal Status */
+
+
+    iDisconnectInitiator = EPVT_NONE;
+    iConnectFailReason = EPVT_Failed;
+
+    iMaxMuxPduCapabilityR = false;
+
+    /* Terminal ID for vendor identification */
+    /* Local terminal id */
+    if (iVendorR)
+    {
+        OSCL_DELETE(iVendorR);
+    }
+    if (iProductNumberR)
+    {
+        OSCL_DEFAULT_FREE(iProductNumberR);
+    }
+    if (iVersionNumberR)
+    {
+        OSCL_DEFAULT_FREE(iVersionNumberR);
+    }
+    iVendorR = NULL;
+    iProductNumberR = NULL;
+    iProductNumberLenR = 0;
+    iVersionNumberR = NULL;
+    iVersionNumberLenR = 0;
+
+    iH223Level = TSC_H223_LEVEL_DEFAULT;
+
+    iMuxTableUpdateRequired = false;
+
+    if (iSuppInfo)
+    {
+        OSCL_DEFAULT_FREE(iSuppInfo);
+        iSuppInfo = NULL;
+        iSuppInfoLen = 0;
+    }
+
+
+    iCeRetries = iN100; /* Num CE retries left */
+
+
+    /* Initialized RTD values */
+    iNumRtdRequests = 0;
+    iRtdMin = TSC_BIG_UINT32;
+    iRtdMax = 0;
+    iRtdAve = 0;
+
+    iTSCstatemanager.InitVarsSession();
+    iTSCmt.InitVarsSession();
+    iTSCcapability.InitVarsSession();
+    if (iTSCcomponent)
+    {
+        iTSCcomponent->InitVarsSession();
+    }
+}
+
+void TSC_324m::IgnoreH245Callbacks()
+{
+    if (!iH245)
+    {
+        return;
+    }
+    iH245->SetObserver(NULL);
+    Msd->SetObserver(NULL);
+    Ce->SetObserver(NULL);
+}
+
+void TSC_324m::InitComponent()
+{
+#ifdef MEM_TRACK
+    printf("\nMemory Stats before TSC Component Init\n");
+    MemStats();
+#endif
+    if (!iTSCcomponent)
+    {
+        PVInterface *componentInterface;
+        // QueryInterface sets iTSCcomponent
+        QueryInterface(0, PVUuidH324ComponentInterface, (PVInterface*&)componentInterface);
+        if (!iTSCcomponent)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_324m::InitComponent- unable to create component"));
+            OSCL_LEAVE(PVMFFailure);
+        }
+        iTSCcomponent->InitVarsLocal();
+        iTSCcomponent->InitVarsSession();
+    }
+    if (iTSCcomponent &&
+            !iInitializedComponent &&
+            iH245 &&
+            iH223)
+    {
+        iTSCcomponent->SetMembers(iH245, iH223, iObserver);
+        iTSCcomponent->InitTsc();
+        iInitializedComponent = true;
+    }
+#ifdef MEM_TRACK
+    printf("\nMemory Stats after TSC Component Init\n");
+    MemStats();
+#endif
+}
+
+TPVStatusCode TSC_324m::InitTsc()
+{
+#ifdef MEM_TRACK
+    printf("\nMemory Stats before TSC Init\n");
+    MemStats();
+#endif
+    int error;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: InitTsc"));
+
+    if (!iInitialized)
+    {
+        SetInitialValues();
+    }
+
+    // Allocate stack elements.
+    iH245 = OSCL_NEW(H245, ());
+    iH245->SetObserver(this);
+
+    iSrp = OSCL_NEW(SRP, ());
+    iSrp->SetObserver(this);
+
+    iH223 = OSCL_NEW(CPVH223Multiplex, (iLoopbackMode));
+    iH223->SetObserver(this);
+
+
+
+    iTSClc.SetH245(iH245);
+    iTSCblc.SetH245(iH245);
+    iTSCclc.SetH245(iH245);
+
+    InitComponent();
+
+
+    iTSCcapability.SetMembers(iTSCcomponent);
+    iTSCmt.SetMembers(iH245, iH223, iTSCcomponent);
+    iH223->SetClock(iClock);
+    iH223->Open();
+
+    // set direct connection to MSD SE
+    Msd = iH245->GetMSD();
+    Msd->SetObserver(this);
+
+    // set direct connection to CE SE
+    Ce = iH245->GetCE();
+    Ce->SetObserver(this);
+
+    OSCL_TRY(error, iTscSrpBuffer = TscSrpBuffer::NewL());
+    if (error)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "TSC: InitTsc, tscsrpbuffer allocation failed", error));
+    }
+
+    iTimer = OSCL_NEW(OsclTimer<OsclMemAllocator>,
+                      (PV_2WAY_TSC_TIMER_ID, PV_2WAY_TSC_TIMER_INTERVAL));
+    //OSCL_TRAP_NEW(iTimer, OsclTimer<OsclMemAllocator>, (PV_2WAY_TSC_TIMER_ID, PV_2WAY_TSC_TIMER_INTERVAL) );
+    iTimer->SetObserver(this);
+
+#ifdef MEM_TRACK
+    printf("\nMemory Stats after TSC Init\n");
+    MemStats();
+#endif
+
+    return EPVT_Success;
+}
+
+TPVStatusCode TSC_324m::ResetTsc()
+{
+    TPVStatusCode ret = EPVT_Success;
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: Reset request."));
+
+    if (iTSCcomponent)
+    {
+        iTSCcomponent->ResetTsc();
+        iTSCstatemanager.WriteState(TSC_CE_RECEIVE, NOT_STARTED);
+        iTSCstatemanager.WriteState(TSC_CE_SEND, NOT_STARTED);
+        iInitializedComponent = false; // TSC Component
+    }
+
+    if (iSrp)
+    {
+        if (iSrp->RequestULPort(SRP_INPUT_PORT_TAG))
+            iSrp->RequestULPort(SRP_INPUT_PORT_TAG)->Disconnect();
+
+        if (iSrp->RequestULPort(SRP_OUTPUT_PORT_TAG))
+            iSrp->RequestULPort(SRP_OUTPUT_PORT_TAG)->Disconnect();
+    }
+
+    if (iTscSrpBuffer)
+    {
+        iTscSrpBuffer->GetLLPort(TSCSRPBUFFER_INPUT_PORT_TAG)->Disconnect();
+        iTscSrpBuffer->GetLLPort(TSCSRPBUFFER_OUTPUT_PORT_TAG)->Disconnect();
+    }
+
+    if (iH245)
+    {
+        iH245->UnBind();
+    }
+
+    if (iIncomingSrpPort)
+    {
+        iIncomingSrpPort->Disconnect();
+        iIncomingSrpPort = NULL;
+    }
+
+    if (iOutgoingSrpPort)
+    {
+        iOutgoingSrpPort->Disconnect();
+        iOutgoingSrpPort = NULL;
+    }
+
+    if (iH223)
+    {
+        H223IncomingChannelPtr incoming_control_channel;
+        PVMFStatus aStatus = iH223->GetIncomingChannel((TPVChannelId)0,
+                             incoming_control_channel);
+        if (aStatus == PVMFSuccess)
+        {
+            incoming_control_channel->Disconnect();
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_324m::ResetTsc Error - Failed to lookup incoming logical channel %d", 0));
+        }
+
+        H223OutgoingChannelPtr outgoing_control_channel;
+        aStatus = iH223->GetOutgoingChannel((TPVChannelId)0, outgoing_control_channel);
+        if (aStatus == PVMFSuccess)
+        {
+            outgoing_control_channel->Disconnect();
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_324m::ResetTsc Error - Failed to lookup outgoing logical channel %d", 0));
+        }
+    }
+
+    //Shutdown stack elements.
+
+    if (iTransmitCaps)
+    {
+        OSCL_DEFAULT_FREE(iTransmitCaps);
+        iTransmitCaps = NULL;
+    }
+
+    if (iVendor)
+    {
+        delete iVendor;
+        iVendor = NULL;
+    }
+
+    if (iVendorR)
+    {
+        delete iVendorR;
+        iVendorR = NULL;
+    }
+
+    if (iProductNumber)
+    {
+        OSCL_DEFAULT_FREE(iProductNumber);
+        iProductNumber = NULL;
+    }
+
+    if (iProductNumberR)
+    {
+        OSCL_DEFAULT_FREE(iProductNumberR);
+        iProductNumberR = NULL;
+    }
+
+    if (iVersionNumber)
+    {
+        OSCL_DEFAULT_FREE(iVersionNumber);
+        iVersionNumber = NULL;
+    }
+
+    if (iVersionNumberR)
+    {
+        OSCL_DEFAULT_FREE(iVersionNumberR);
+        iVersionNumberR = NULL;
+    }
+
+
+    if (iTimer)
+    {
+        iTimer->Clear();
+        OSCL_DELETE(iTimer);
+        iTimer = NULL;
+    }
+
+
+    if (iTSCcomponent)
+    {
+        OSCL_DELETE(iTSCcomponent);
+        iTSCcomponent = NULL;
+    }
+
+
+    if (iH223)
+    {
+        iH223->Close();
+        DeallocateH223Mux(iH223);
+        iH223 = NULL;
+    }
+
+    if (iTscSrpBuffer)
+    {
+        OSCL_DELETE(iTscSrpBuffer);
+        iTscSrpBuffer = NULL;
+    }
+
+    if (iSrp)
+    {
+        iSrp->SrpReset();
+        OSCL_DELETE(iSrp);
+        iSrp = NULL;
+    }
+
+    if (iH245)
+    {
+        OSCL_DELETE(iH245);
+        iH245 = NULL;
+    }
+
+    iInitialized = false; //TSC node
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: Reset request - done"));
+#ifdef MEM_TRACK
+    printf("\nMemory Stats after TSC Reset\n");
+    MemStats();
+#endif
+    return ret;
+}
+
+TPVStatusCode TSC_324m::SetOutgoingBitrate(int32 bitrate)
+{
+    iH223->SetBitrate(bitrate);
+    return EPVT_Success;
+}
+
+TPVStatusCode TSC_324m::SetTimerRes(uint32 timer_res)
+{
+    return iH223->SetTimerRes(timer_res);
+}
+
+TPVStatusCode TSC_324m::SetTerminalParam(CPVTerminalParam* params)
+{
+    CPVH324MParam* h324params = (CPVH324MParam*)params;
+
+    iSendRme = h324params->iSendRme;
+    iRequestMaxMuxPduSize = h324params->iRequestMaxMuxPduSize;
+    iTSCcomponent->SetTerminalParam(*h324params);
+    iTSCstatemanager.SetTerminalParam(params);
+    return EPVT_Success;
+}
+
+CPVTerminalParam* TSC_324m::GetTerminalParam()
+{
+    CPVH223MuxParam h223Param;
+    CPVH324MParam* h324param = new CPVH324MParam();
+    iTSCcomponent->GetTerminalParam(*h324param);
+    h324param->iMasterSlave = (TPVMasterSlave)iTSCstatemanager.ReadState(TSC_MSD_DECISION);
+    h324param->SetH223Param(&h223Param);
+    return 	h324param;
+}
+
+TPVStatusCode
+TSC_324m::Connect(uint16 info_len, uint8* info_buf)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_PROF, iLogger, PVLOGMSG_NOTICE,
+                    (0, "TSC_324m::Connect"));
+    TPVStatusCode ret = EPVT_Pending;
+
+    iMuxTableUpdateRequired = false;
+    iStopCmd = NULL;
+    iTerminalStatus = Phase0_Idle;
+
+    iTSCmt.ClearVars();
+
+    // moved stuff to component
+
+    if (!iTSCcomponent->Connect1LevelKnown())
+    {
+        iH223Level = H223_LEVEL_UNKNOWN;
+    }
+    ResetStats();
+
+    iH245->Reset();
+    iH245->SetTimers(iTimerValues);
+
+
+    // set direct connection to MSD SE
+    Msd = iH245->GetMSD();
+    Msd->SetObserver(this);
+
+    // set direct connection to CE SE
+    Ce = iH245->GetCE();
+    Ce->SetObserver(this);
+
+    if (iSuppInfo)
+    {
+        OSCL_DEFAULT_FREE(iSuppInfo);
+        iSuppInfo = NULL;
+        iSuppInfoLen = 0;
+    }
+
+    if (info_len)
+    {
+        iSuppInfo = (uint8*)OSCL_DEFAULT_MALLOC(info_len);
+        iSuppInfoLen = info_len;
+        oscl_memcpy(iSuppInfo, info_buf, info_len);
+    }
+    iTimer->Clear();
+
+    CPVH223MuxParam level_set;
+
+    // Initialize the mux and wait for completion.  Performs level setup
+    if (iH223Level != H223_LEVEL_UNKNOWN)
+    {
+        iH223->SetMultiplexLevel(iH223Level);
+    }
+    iH223->SetMultiplexingDelayMs((uint16)iMultiplexingDelayMs);
+    iH223->SetLogicalChannelBufferingMs(iInLogicalChannelBufferingMs,
+                                        iOutLogicalChannelBufferingMs);
+    iH223->SetClock(iClock);
+
+    S_H223LogicalChannelParameters lcnParams;
+    lcnParams.segmentableFlag = true;
+    lcnParams.adaptationLayerType.index = 1;
+    H223ChannelParam in_channel_params(0,
+                                       &lcnParams,
+                                       TSC_MAX_CONTROL_CHANNEL_BITRATE_BPS,
+                                       PV2WAY_TSC_MIN_T401_INCOMING);
+    H223ChannelParam out_channel_params(0,
+                                        &lcnParams,
+                                        TSC_MAX_CONTROL_CHANNEL_BITRATE_BPS,
+                                        iT401*100);
+
+    iH223->OpenChannel(OUTGOING, 0, &out_channel_params);
+    iH223->OpenChannel(INCOMING, 0, &in_channel_params);
+
+
+    ConfigureSrp(iH223Level);
+
+    // Reset global states (RAN-MS)
+    iTSCstatemanager.StateInitialize();    // Reset call-setup states
+
+    iTerminalStatus = PhaseD_CSUP;
+
+    iTSCcomponent->Connect2();
+    return ret;
+}
+
+void TSC_324m::SetClock(PVMFMediaClock* aClock)
+{
+    iClock = aClock;
+}
+
+void TSC_324m::DataReceptionStart()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DataReceptionStart"));
+    /* Start timer for Level Setup countdown */
+    int32 levelSetupTimeoutInfo = 0;
+    if (iTSCcomponent->IsEnabled())
+    {
+        levelSetupTimeoutInfo = 1; // Level setup can commence again if it fails the first time
+    }
+    iTimer->Request(PV_TSC_LEVEL_SETUP_TIMER_ID, levelSetupTimeoutInfo,
+                    DEFAULT_TCS_LEVEL_SETUP_TIMEOUT_SECONDS, this);
+}
+
+void TSC_324m::MuxSetupComplete(PVMFStatus status, TPVH223Level level)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MuxSetupComplete status=%d, level=%d",
+                     status, level));
+    iTimer->Cancel(PV_TSC_LEVEL_SETUP_TIMER_ID);
+
+    /* Reconfigure SRP if multiplex level 0 is negotiated starting from a higher level */
+    if (level == H223_LEVEL0 && level != iH223Level)
+    {
+        ConfigureSrp(level);
+    }
+    iH223Level = level;
+    if (status == PVMFPending)
+    {
+        return;
+    }
+    if (status != PVMFSuccess)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::MuxSetupComplete Mux setup failed."));
+        SignalCsupComplete(status);
+        return;
+    }
+
+    iTSCcomponent->MuxSetupComplete(status, level);
+
+    OpenSession();
+    iTimer->Request(PV_TSC_RTD_TIMER_ID, PV_TSC_RTD_TIMER_ID, DEFAULT_RTD_TIMER_SECONDS, this, false);
+    /* Start timer for TCS countdown */
+    if (iTSCstatemanager.ReadState(TSC_CE_RECEIVE) != COMPLETE)
+    {
+        iTimer->Request(PV_TSC_TCS_RECEIVE_TIMER_ID, PV_TSC_TCS_RECEIVE_TIMER_ID,
+                        DEFAULT_TCS_RECEIVE_TIMEOUT_SECONDS, this);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::MuxSetupComplete TCS received before MuxSetupComplete."));
+    }
+}
+
+void TSC_324m::MuxCloseComplete()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m: Mux close complete - status(%d).", iTerminalStatus));
+
+    /* All logical channels closed */
+    iTerminalStatus = PhaseF_End;
+
+    iH245->Reset();
+    // set direct connection to MSD SE
+    Msd = iH245->GetMSD();
+    Msd->SetObserver(this);
+
+    // set direct connection to CE SE
+    Ce = iH245->GetCE();
+    Ce->SetObserver(this);
+
+    iH223->CloseChannel(OUTGOING, 0);
+    iH223->CloseChannel(INCOMING, 0);
+}
+
+void TSC_324m::MuxErrorOccurred(TPVDirection direction,
+                                TPVMuxComponent component,
+                                PVMFStatus error,
+                                uint8* info,
+                                uint info_len)
+{
+    OSCL_UNUSED_ARG(info_len);
+    OSCL_UNUSED_ARG(info);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::MuxErrorOccurred - direction(%d), component(%d), error(%d)",
+                     direction, component, error));
+    TPVChannelId id = CHANNEL_ID_UNKNOWN;
+    if (info && component == PV_MUX_COMPONENT_LOGICAL_CHANNEL)
+    {
+        id = *((TPVChannelId*)info);
+
+        if (!iTSCcomponent->HasOlc(direction, id))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::MuxErrorOccurred - Failed to lookup channel info, lcn=%d",
+                             id));
+            return;
+        }
+        if (direction == INCOMING)
+        {
+            H223IncomingChannelPtr incoming_lcn;
+            PVMFStatus aStatus = iH223->GetIncomingChannel(id, incoming_lcn);
+            if (aStatus == PVMFSuccess)
+            {
+                if (!incoming_lcn->IsConnected())
+                {
+                    RequestFrameUpdate(incoming_lcn);
+                }
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::MuxErrorOccurred - Failed to lookup incoming channel, lcn=%d",
+                                 id));
+                return;
+            }
+        }
+    }
+
+    PVMFAsyncEvent aEvent(PVMFInfoEvent, error, this, NULL);
+    uint8* buf = aEvent.GetLocalBuffer();
+    buf[0] = (uint8)PV_H324COMPONENT_H223;
+    buf[1] = (uint8)component;
+    buf[2] = (uint8)direction;
+    if (component == PV_MUX_COMPONENT_LOGICAL_CHANNEL)
+    {
+        *((TPVChannelId*)(buf + 4)) = id;
+    }
+    //iInfoObserver->HandleNodeInformationalEvent(aEvent);
+}
+
+void TSC_324m::SkewDetected(TPVChannelId lcn1, TPVChannelId lcn2, uint32 skew)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SkewDetected - lcn1=%d, lcn2=%d, skew=%d",
+                     lcn1, lcn2, skew));
+    Tsc_IdcSkew(lcn1, lcn2, (uint16)skew);
+}
+
+void TSC_324m::LcnDataDetected(TPVChannelId lcn)
+{
+    iTSCcomponent->LcnDataDetected(lcn);
+}
+
+void TSC_324m::ReceivedFormatSpecificInfo(TPVChannelId channel_id,
+        uint8* fsi,
+        uint32 fsi_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::ReceivedFormatSpecificInfo lcn=%d, len=%d",
+                     channel_id, fsi_len));
+    iTSCcomponent->ReceivedFormatSpecificInfo(channel_id, fsi, fsi_len);
+}
+
+TPVStatusCode TSC_324m::Disconnect()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: Disconnect request."));
+    //LogStats(OUTGOING);
+    //LogStats(INCOMING);
+
+    TPVStatusCode ret = EPVT_Success;
+
+    iDisconnectInitiator |= EPVT_LOCAL;
+
+    iTimer->Clear();
+
+    StopSrp();
+    iH223->Stop();
+
+    MuxCloseComplete();
+    while (iIncomingChannels.size())
+    {
+        H223ChannelParam* param = iIncomingChannels.back();
+        iIncomingChannels.pop_back();
+        delete param;
+    }
+
+    initVarsSession();
+    return ret;
+}
+
+TPVStatusCode TSC_324m::Abort()
+{
+//	iMutex->Lock();
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC: Abort."));
+    //LogStats(OUTGOING);
+    //LogStats(INCOMING);
+    TPVStatusCode ret = EPVT_Success;
+
+    iDisconnectInitiator |= EPVT_LOCAL;
+
+    if (iSuppInfo)
+    {
+        OSCL_DEFAULT_FREE(iSuppInfo);
+        iSuppInfo = NULL;
+        iSuppInfoLen = 0;
+        iTimer->Clear();
+    }
+
+    SessionClose_Comm();
+
+    iSrp->SrpStop();
+
+    /* All logical channels closed */
+    iTerminalStatus = PhaseF_End;
+
+    iH245->Reset();
+    // set direct connection to MSD SE
+    Msd = iH245->GetMSD();
+    Msd->SetObserver(this);
+
+    // set direct connection to CE SE
+    Ce = iH245->GetCE();
+    Ce->SetObserver(this);
+
+    initVarsSession();
+
+//	iMutex->Unlock();
+    return ret;
+}
+
+/* Handle control events depending on state */
+/*
+        Phase0_Idle = 1 ,
+        PhaseA          ,
+        PhaseB          ,
+        PhaseC          ,
+		PhaseD_CSUP		,  // Call Setup
+        PhaseE_Comm     ,  // Ongoing Communication
+        PhaseF_Clc      ,  // Closing all outgoing LCNs
+        PhaseF_End      ,  // End of Session
+        PhaseG_Dis
+*/
+void TSC_324m::Handle(PS_ControlMsgHeader msg)
+{
+    uint32            EventNo;                        /* EventNo         */
+    uint32            Cnt;                            /* Counter         */
+    DISPATCH_PTR func_ptr = NULL;
+    bool handled = false;
+
+//	iMutex->Lock();
+
+    /* Event Receive; a non blocking call */
+    EventNo = Tsc_EventReceive(msg);
+
+    for (Cnt = 0; iDispatchTable[Cnt].Module != NULL; Cnt++)
+    {
+        if (iDispatchTable[Cnt].Status == iTerminalStatus && iDispatchTable[Cnt].Event == EventNo)
+        {
+            func_ptr = iDispatchTable[Cnt].Module;
+            handled = true;
+            (this->*func_ptr)(msg);
+            break;
+        }
+    }
+    if (!handled)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: Failed to handle control message - state(%d), event no(%d).",
+                         iTerminalStatus, EventNo));
+    }
+
+    return;
+}
+
+TPVStatusCode TSC_324m::RequestFrameUpdate(PVMFPortInterface* port)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::RequestFrameUpdate"));
+
+    if (iTSCstatemanager.ReadState(TSC_CE_SEND) == NOT_STARTED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::RequestFrameUpdate ERROR  - TCS not yet requested, tcs state=NOT_STARTED"));
+        return EPVT_ErrorInvalidState;
+    }
+
+    H223IncomingChannel *channel = OSCL_STATIC_CAST(H223IncomingChannel *, port);
+    if (channel == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC: RequestFrameUpdate - Null port"));
+        return EPVT_Failed;
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::RequestFrameUpdate lcn=%d", channel->GetLogicalChannelNumber()));
+    OlcParam* param = iTSCcomponent->FindOlcGivenChannel(INCOMING, channel->GetLogicalChannelNumber());
+    if (param == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: RequestFrameUpdate - Failed to lookup channel param"));
+        return EPVT_Failed;
+    }
+    if (param->GetState() != OLC_ESTABLISHED)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: RequestFrameUpdate - Channel not in established state.  Not sending request."));
+        return EPVT_Failed;
+    }
+
+    CmdMisc(EVideoFastUpdatePicture, channel->GetLogicalChannelNumber());
+    return EPVT_Success;
+}
+
+TPVStatusCode TSC_324m::RequestMaxMuxPduSize(unsigned aPduSize)
+{
+    if ((iTerminalStatus != PhaseD_CSUP) && (iTerminalStatus != PhaseE_Comm))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m: ERROR - RequestMaxMuxPduSize - invalid state(%d)",
+                         iTerminalStatus));
+        return EPVT_ErrorInvalidState;
+    }
+    CmdMisc(EMaxH223MUXPDUsize, CHANNEL_ID_UNKNOWN&0xFFFF, aPduSize);
+    return EPVT_Success;
+}
+
+OSCL_EXPORT_REF TPVStatusCode TSC_324m::SetTerminalType(uint8 aTType)
+{
+    if (Msd)
+    {
+        Msd->SetTerminalType(aTType);
+        return EPVT_Success;
+    }
+    else
+    {
+        return EPVT_Failed;
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetEndSessionTimeout(uint32 timeout)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetEndSessionTimeout timeout(%d)", timeout));
+    iEndSessionTimeout = timeout;
+    if (iStopCmd != 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::SetEndSessionTimeout Already disconnectiing",
+                         timeout));
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetTimerCounter(TPVH324TimerCounter aTimerCounter,
+        uint8 aSeries, uint32 aSeriesOffset, uint32 aValue)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetTimerCounter timer/counter(%d), series(%d), offset(%d), value(%d)",
+                     aTimerCounter, aSeries, aSeriesOffset, aValue));
+    if (aTimerCounter == EH324Timer)
+    {
+        switch (aSeries)
+        {
+            case 1:
+            {
+                switch (aSeriesOffset)
+                {
+                    case 1:
+                        iTimerValues.iT101 = aValue;
+                        break;
+                    case 3:
+                        iTimerValues.iT103 = aValue;
+                        break;
+                    case 4:
+                        iTimerValues.iT104 = aValue;
+                        break;
+                    case 5:
+                        iTimerValues.iT105 = aValue;
+                        break;
+                    case 6:
+                        iTimerValues.iT106 = aValue;
+                        break;
+                    case 7:
+                        iTimerValues.iT107 = aValue;
+                        break;
+                    case 8:
+                        iTimerValues.iT108 = aValue;
+                        break;
+                    case 9:
+                        iTimerValues.iT109 = aValue;
+                        break;
+                    default:
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "TSC_324m::SetTimerCounter Error - Offset not supported for series"));
+                }
+            }
+            break;
+            case 4:
+            {
+                switch (aSeriesOffset)
+                {
+                    case 1:
+                        iT401 = aValue;
+                        break;
+                    default:
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "TSC_324m::SetTimerCounter Error - Offset not supported for series"));
+                }
+            }
+            break;
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::SetTimerCounter Error - Series not supported"));
+        }
+    }
+    else if (aTimerCounter == EH324Counter)
+    {
+        switch (aSeries)
+        {
+            case 1:
+            {
+                switch (aSeriesOffset)
+                {
+                    case 0:
+                        iN100 = aValue;
+                        iTSCstatemanager.SetN100(iN100);
+                        break;
+                    default:
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "TSC_324m::SetTimerCounter Error - Offset not supported for series"));
+                }
+            }
+            break;
+            case 4:
+            {
+                switch (aSeriesOffset)
+                {
+                    case 1:
+                        iN401 = aValue;
+                        break;
+                    default:
+                        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                        (0, "TSC_324m::SetTimerCounter Error - Offset not supported for series"));
+                }
+            }
+            break;
+            default:
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::SetTimerCounter Error - Series not supported"));
+        }
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetVideoResolutions(TPVDirection dir,
+        Oscl_Vector<PVMFVideoResolutionRange, OsclMemAllocator>& resolutions)
+{
+    iTSCcapability.SetVideoResolutions(dir, resolutions);
+}
+
+void TSC_324m::SetDispatchTable()
+{
+    const uint16 sizeofDispatchTable = 56;
+    S_DispatchTable     aDispatchTable[sizeofDispatchTable] =
+    {
+        /* ----------------------------------------- */
+        /* ---------- CALL SETUP EVENTS ------------ */
+        /* ----------------------------------------- */
+        { OSCL_FUNCTION_PTR(TSC_324m::Status04Event22)   ,  PhaseD_CSUP  ,  22 }, //E_PtvId_Mt_Trf_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status04Event23)   ,  PhaseD_CSUP  ,  23 }, //E_PtvId_Mt_Trf_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status04Event24)   ,  PhaseD_CSUP  ,  24 }, //E_PtvId_Mt_Rjt_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::ModeRequestIndication)   ,  PhaseD_CSUP  ,  28 }, //E_PtvId_Mr_Trf_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::EndSessionRecv)    ,  PhaseD_CSUP  ,  37 }, //E_PtvId_Cmd_Es_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::VendorIdRecv)      ,  PhaseD_CSUP,    56},
+        { OSCL_FUNCTION_PTR(TSC_324m::UserInputIndicationRecv), PhaseD_CSUP, 57}, //E_PtvId_Idc_Ui_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::LcEtbIdc)          ,  PhaseD_CSUP  ,   9 }, //E_PtvId_Lc_Etb_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::LcRlsIdc)          ,  PhaseD_CSUP  ,  11 }, //E_PtvId_Lc_Rls_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcEtbIdc)          ,  PhaseD_CSUP  ,   14 }, //E_PtvId_Lc_Etb_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcRlsIdc)          ,  PhaseD_CSUP  ,  16 }, //E_PtvId_Lc_Rls_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::FunctionNotSupportedIndicationReceived)   ,  PhaseD_CSUP  ,  49}, //E_PtvId_Idc_Fns_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::FlowControlCommandReceived)   ,  PhaseD_CSUP  ,  53 }, //E_PtvId_Cmd_Fc
+        { OSCL_FUNCTION_PTR(TSC_324m::SendTerminalCapabilitySet)   ,  PhaseD_CSUP  ,  52 }, //E_PtvId_Cmd_Stcs_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::MiscCmdRecv)       ,  PhaseD_CSUP  ,  54 }, //E_PtvId_Cmd_Mscl_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::MiscIndicationRecv), PhaseD_CSUP, 58}, //E_PtvId_Idc_Mscl_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::SkewIndicationRecv), PhaseD_CSUP, 59}, //E_PtvId_Idc_H223skw_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::FlowControlIndicationReceived)   ,  PhaseD_CSUP  ,  60 }, //E_PtvId_Cmd_Fc
+//		{ InternalError_CSUP,  PhaseD_CSUP  ,  38 }, //H245_INTERNAL_ERROR
+        /* ----------------------------------------- */
+        /* --------- ONGOING COMM EVENTS ----------- */
+        /* ----------------------------------------- */
+        { OSCL_FUNCTION_PTR(TSC_324m::LcEtbIdc)          ,  PhaseE_Comm  ,   9 }, //E_PtvId_Lc_Etb_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::LcRlsIdc)          ,  PhaseE_Comm  ,  11 }, //E_PtvId_Lc_Rls_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::LcEtbCfm)          ,  PhaseE_Comm  ,  10 }, //E_PtvId_Lc_Etb_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::LcRlsCfm)          ,  PhaseE_Comm  ,  12 }, //E_PtvId_Lc_Rls_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::LcErrIdc)          ,  PhaseE_Comm  ,  13 }, //E_PtvId_Lc_Err_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcEtbIdc)         ,  PhaseE_Comm  ,  14 }, //E_PtvId_Blc_Etb_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcEtbCfm)         ,  PhaseE_Comm  ,  15 }, //E_PtvId_Blc_Etb_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcEtbCfm2)        ,  PhaseE_Comm  ,  50 }, //E_PtvId_Blc_Etb_Cfm2
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcErrIdc)         ,  PhaseE_Comm  ,  18 }, //E_PtvId_Blc_Err_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcRlsIdc)         ,  PhaseE_Comm  ,  16 }, //E_PtvId_Blc_Rls_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::BlcRlsCfm)         ,  PhaseE_Comm  ,  17 }, //E_PtvId_Blc_Rls_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event19)   ,  PhaseE_Comm  ,  19 }, //E_PtvId_Clc_Cls_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event20)   ,  PhaseE_Comm  ,  20 }, //E_PtvId_Clc_Cls_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event21)   ,  PhaseE_Comm  ,  21 }, //E_PtvId_Clc_Rjt_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status04Event22)   ,  PhaseE_Comm  ,  22 }, //E_PtvId_Mt_Trf_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status04Event23)   ,  PhaseE_Comm  ,  23 }, //E_PtvId_Mt_Trf_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status04Event24)   ,  PhaseE_Comm  ,  24 }, //E_PtvId_Mt_Rjt_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event25)   ,  PhaseE_Comm  ,  25 }, //E_PtvId_Rme_Send_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event26)   ,  PhaseE_Comm  ,  26 }, //E_PtvId_Rme_Send_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event27)   ,  PhaseE_Comm  ,  27 }, //E_PtvId_Rme_Rjt_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::ModeRequestIndication)   ,  PhaseE_Comm  ,  28 }, //E_PtvId_Mr_Trf_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event29)   ,  PhaseE_Comm  ,  29 }, //E_PtvId_Mr_Trf_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event30)   ,  PhaseE_Comm  ,  30 }, //E_PtvId_Mr_Rjt_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event31)   ,  PhaseE_Comm  ,  31 }, //E_PtvId_Rtd_Trf_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event32)   ,  PhaseE_Comm  ,  32 }, //E_PtvId_Rtd_Exp_Idc
+        { OSCL_FUNCTION_PTR(TSC_324m::FunctionNotSupportedIndicationReceived)   ,  PhaseE_Comm ,  49}, //E_PtvId_Idc_Fns_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::SendTerminalCapabilitySet)   ,  PhaseE_Comm  ,  52 }, //E_PtvId_Cmd_Stcs_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::FlowControlCommandReceived)   ,  PhaseE_Comm  ,  53 }, //E_PtvId_Cmd_Fc_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::MiscCmdRecv)       ,  PhaseE_Comm  ,  54 }, //E_PtvId_Cmd_Mscl_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::Status08Event55)   ,  PhaseE_Comm  ,  55 }, //E_PtvId_Cmd_Hmr_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::EndSessionRecv)    ,  PhaseE_Comm  ,  37 }, //E_PtvId_Cmd_Es_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::VendorIdRecv)      ,  PhaseE_Comm  ,  56},
+        { OSCL_FUNCTION_PTR(TSC_324m::UserInputIndicationRecv), PhaseE_Comm, 57}, //E_PtvId_Idc_Ui_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::MiscIndicationRecv), PhaseE_Comm, 58}, //E_PtvId_Idc_Mscl_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::SkewIndicationRecv), PhaseE_Comm, 59}, //E_PtvId_Idc_H223skw_Cfm
+        { OSCL_FUNCTION_PTR(TSC_324m::FlowControlIndicationReceived)   ,  PhaseE_Comm,  60 }, //E_PtvId_Cmd_Fc
+        /* ----------------------------------------- */
+        /* --------- CLOSE and END EVENTS ---------- */
+        /* ----------------------------------------- */
+        { OSCL_FUNCTION_PTR(TSC_324m::EndSessionRecv)    ,  PhaseF_End   ,  37 }, //E_PtvId_Cmd_Es_Cfm
+
+        { NULL                  ,  0            ,   0 }
+    };
+
+    for (int n = 0; n < sizeofDispatchTable; n++)
+    {
+        iDispatchTable[n] = aDispatchTable[n];
+    }
+}
+
+OSCL_EXPORT_REF TPVStatusCode TSC_324m::SetVendorIdInfo(TPVH245Vendor* vendor,
+        const uint8* pn,
+        uint16 pn_len,
+        const uint8* vn,
+        uint16 vn_len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetVendorIdInfo vendor(%x), pn_len(%d), vn_len(%d)", vendor, pn_len, vn_len));
+    if (pn && pn_len && (pn[pn_len-1] == '\0'))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SetVendorIdInfo pn(%s)", pn));
+    }
+    if (vn && vn_len && (vn[vn_len-1] == '\0'))
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SetVendorIdInfo vn(%s)", vn));
+    }
+
+    if (iVendor)
+    {
+        OSCL_DELETE(iVendor);
+        iVendor = NULL;
+    }
+    if (iProductNumber)
+    {
+        OSCL_DEFAULT_FREE(iProductNumber);
+        iProductNumber = NULL;
+    }
+    if (iVersionNumber)
+    {
+        OSCL_DEFAULT_FREE(iVersionNumber);
+        iVersionNumber = NULL;
+    }
+    iProductNumberLen = pn_len;
+    iVersionNumberLen = vn_len;
+
+    if (vendor)
+    {
+        iVendor = vendor->Copy();
+    }
+
+    if (iProductNumberLen)
+    {
+        iProductNumber = (uint8*)OSCL_DEFAULT_MALLOC(iProductNumberLen);
+        oscl_memcpy(iProductNumber, pn, iProductNumberLen);
+    }
+
+    if (iVersionNumberLen)
+    {
+        iVersionNumber = (uint8*)OSCL_DEFAULT_MALLOC(iVersionNumberLen);
+        oscl_memcpy(iVersionNumber, vn, iVersionNumberLen);
+    }
+    return EPVT_Success;
+}
+
+OSCL_EXPORT_REF TSC* Allocate324mTSC(TPVLoopbackMode aLoopbackMode)
+{
+    return OSCL_NEW(TSC_324m, (aLoopbackMode));
+}
+
+OSCL_EXPORT_REF void Deallocate324mTSC(TSC* tsc)
+{
+    TSC_324m* tsc_324m = (TSC_324m*)tsc;
+    OSCL_DELETE(tsc_324m);
+}
+
+
+void TSC_324m::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timeoutInfo);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::TimeoutOccurred"));
+
+    if (timerID == PV_TSC_RTD_TIMER_ID)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::TimeoutOccurred - Sending RTD"));
+        iTscSrpBuffer->EnableBuffering(false);
+        RtdTrfReq();
+    }
+    else if (timerID == PV_TSC_LEVEL_SETUP_TIMER_ID)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::TimeoutOccurred Level setup timeout out, timeoutInfo=%d",
+                         timeoutInfo));
+        if (!timeoutInfo)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::TimeoutOccurred Level Setup Failed."));
+            SignalCsupComplete(PVMFErrTimeout);
+        }
+        else
+        {
+            /* We timed out waiting for TCS. */
+            iTSCcomponent->Timeout();
+            /* Start timer to receive TCS */
+            iTimer->Request(PV_TSC_TCS_RECEIVE_TIMER_ID, PV_TSC_TCS_RECEIVE_TIMER_ID,
+                            DEFAULT_TCS_RECEIVE_TIMEOUT_SECONDS, this);
+            iH223->EnableStuffing(true);
+            iH223->SetInterleavingMultiplexFlags(0, NULL);
+            iH223->SetMuxLevel(TSC_H223_LEVEL_DEFAULT);
+            /* Start timer to receive TCS */
+            iTimer->Request(PV_TSC_LEVEL_SETUP_TIMER_ID, 0,
+                            DEFAULT_TCS_LEVEL_SETUP_TIMEOUT_SECONDS, this);
+        }
+    }
+    else if (timerID == PV_TSC_TCS_RECEIVE_TIMER_ID)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::TimeoutOccurred Timed out on TCS receive.  Connect failed."));
+        SignalCsupComplete(PVMFErrTimeout);
+    }
+    else
+    {
+        iTSCcomponent->TimeoutOccurred(timerID, timeoutInfo);
+    }
+}
+
+
+void TSC_324m::ResetStats()
+{
+    iH223->ResetStats();
+}
+void TSC_324m::LogStats(TPVDirection dir)
+{
+    if (iH223)
+        iH223->LogStats(dir);
+}
+
+// Node virtuals
+// Node virtuals
+// Sync requests that will NOT trigger callback events
+
+OSCL_EXPORT_REF  PVMFStatus TSC_324m::GetCapability(PVMFNodeCapability& aNodeCapability)
+{
+    aNodeCapability.iCanSupportMultipleInputPorts = true;
+    aNodeCapability.iCanSupportMultipleOutputPorts = true;
+    aNodeCapability.iHasMaxNumberOfPorts = true;
+    aNodeCapability.iMaxNumberOfPorts = 5;
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H223);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_M4V);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H2631998);
+    aNodeCapability.iInputFormatCapability.push_back(PVMF_MIME_H2632000);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_H223);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_M4V);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2631998);
+    aNodeCapability.iOutputFormatCapability.push_back(PVMF_MIME_H2632000);
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF  PVMFCommandId TSC_324m::Init(PVMFSessionId aSession, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Init(%x)", aContext));
+
+    if (iInterfaceState != EPVMFNodeIdle)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::Init Invalid state(%d)", iInterfaceState));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_INIT, aContext);
+    return QueueCommandL(cmd);
+}
+
+// Async requests that will trigger callback events
+/**
+This should establish the comm server session.  Thread specific initialization happens here */
+void TSC_324m::DoInit(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                    (0, "TSC_324m::DoInit(%x)", cmd.iId));
+
+    PVMFStatus pvmfStatus = PVMFSuccess;
+    // Initialize TSC
+    int leave_status = 0;
+    OSCL_TRY(leave_status, InitTsc());
+    OSCL_FIRST_CATCH_ANY(leave_status, void());
+
+    if (leave_status == 0)
+    {
+        iInterfaceState = EPVMFNodeInitialized;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::Init - failed to initialize"));
+        pvmfStatus = PVMFFailure;
+        iInterfaceState = EPVMFNodeError;
+    }
+
+    CommandComplete(iCmdQueue, cmd, pvmfStatus, NULL);
+}
+
+PVMFCommandId TSC_324m::Prepare(PVMFSessionId aSession
+                                , const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Prepare aSession=%x, aContext=%x",
+                     aSession, aContext));
+    if (iInterfaceState != EPVMFNodeInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::Prepare Invalid state(%d)", iInterfaceState));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_PREPARE, aContext);
+    return QueueCommandL(cmd);
+}
+
+void TSC_324m::DoPrepare(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoPrepare"));
+    iInterfaceState = EPVMFNodePrepared;
+    CommandComplete(iCmdQueue, cmd, PVMFSuccess);
+}
+
+OSCL_EXPORT_REF  PVMFCommandId TSC_324m::Start(PVMFSessionId aSession, const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Start aSession=%x, aContext=%x", aSession, aContext));
+
+    iTSCcomponent->Start();
+
+    if (iInterfaceState != EPVMFNodePrepared || iTerminalStatus != Phase0_Idle)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::Start Init Invalid state iInterfaceState=%d, iTerminalStatus=%d",
+                         iInterfaceState, iTerminalStatus));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_START, aContext);
+    return QueueCommandL(cmd);
+}
+
+void TSC_324m::DoStart(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoStart"));
+    TPVStatusCode stat = EPVT_Failed;
+    int leave_status = 0;
+    PVMFStatus pvmfStatus = PVMFFailure;
+
+    OSCL_TRY(leave_status, stat = Connect());
+    OSCL_FIRST_CATCH_ANY(leave_status, Disconnect());
+    if (stat == EPVT_Success || stat == EPVT_Pending)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::DoStart Connect complete"));
+        pvmfStatus = PVMFSuccess;
+        iInterfaceState = EPVMFNodeStarted;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::DoStart Connect failed leave_status=%d",
+                         leave_status));
+        iInterfaceState = EPVMFNodePrepared;
+    }
+
+    CommandComplete(iCmdQueue, cmd, pvmfStatus);
+    return;
+
+}
+
+/**
+ * Causes the node to stop servicing one or all disconnected ports.
+ * TBD:  Should we add an API or modify this to take an arbitrary subset of ports ?
+ * @exception port_connected leaves if any of the ports are not disconnected.
+ **/
+OSCL_EXPORT_REF  PVMFCommandId TSC_324m::Stop(PVMFSessionId aSession,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Stop aSession=%x, aContext=%x",
+                     aSession, aContext));
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            // ok to call stop
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                            (0, "TSC_324m::Stop Invalid state(%d)", iInterfaceState));
+            OSCL_LEAVE(PVMFErrInvalidState);
+    }
+
+    while (!iCmdQueue.empty())
+    {
+        CommandComplete(iCmdQueue, iCmdQueue.front(), PVMFErrCancelled);
+        iCmdQueue.Erase(&iCmdQueue.front());
+    }
+
+    iPendingCmdQueue.clear();
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_STOP, aContext);
+    return QueueCommandL(cmd);
+}
+
+
+
+void TSC_324m::DoStop(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoStop"));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        case EPVMFNodeStarted:
+        case EPVMFNodePaused:
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::DoStop Ignoring stop due to invalid state(%d)",
+                             iInterfaceState));
+            CommandComplete(iCmdQueue, cmd, PVMFErrInvalidState);
+            return;
+    }
+
+    if (iTSCcomponent)
+    {
+        iTSCcomponent->StartDisconnect(true);
+    }
+
+    iTerminalStatus = PhaseF_Clc;
+    Disconnect();
+
+    if (iNumRtdRequests)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::DoStop iNumRtdRequests=%d, iRtdMin=%d, iRtdmax=%d, iRtdAve=%d",
+                         iNumRtdRequests, iRtdMin, iRtdMax, iRtdAve / iNumRtdRequests));
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::DoStop No RTD requests issued"));
+    }
+
+    iInterfaceState = EPVMFNodePrepared;
+    CommandComplete(iCmdQueue, cmd, PVMFSuccess);
+}
+
+/**
+ * Causes the node to pause servicing one or all connected and started ports.
+ * Ports are to be resumed using the Start command ?
+ * TBD:  Should we add an API or modify this to take an arbitrary subset of ports ?
+ * @exception port_disconnected leaves if any of the ports are not connected.
+ **/
+OSCL_EXPORT_REF  PVMFCommandId TSC_324m::Pause(PVMFSessionId aSession,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+/**
+ * Resets the node.  The node should relinquish all resources that is has acquired as part of the
+ * initialization process and should be ready to be deleted when this completes.
+ * @exception port_disconnected leaves if any of the ports are not connected.
+
+ **/
+OSCL_EXPORT_REF  PVMFCommandId TSC_324m::Reset(PVMFSessionId aSession,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::Reset(%d)", iInterfaceState));
+
+    switch (iInterfaceState)
+    {
+        case EPVMFNodeInitialized:
+        case EPVMFNodePrepared:
+        case EPVMFNodeError:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::Reset Ok to reset"));
+            break;
+        default:
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::Reset Invalid state for Reset"));
+            OSCL_LEAVE(PVMFErrInvalidState);
+            break;
+    }
+
+    while (!iCmdQueue.empty())
+    {
+        CommandComplete(iCmdQueue, iCmdQueue.front(), PVMFErrCancelled);
+        iCmdQueue.Erase(&iCmdQueue.front());
+    }
+    iPendingCmdQueue.clear();
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_RESET, aContext);
+    return QueueCommandL(cmd);
+}
+
+void TSC_324m::DoReset(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoReset"));
+    iInterfaceState = EPVMFNodeIdle;
+    ResetTsc();
+    CommandComplete(iCmdQueue, cmd, PVMFSuccess);
+}
+
+OSCL_EXPORT_REF PVMFCommandId TSC_324m::RequestPort(PVMFSessionId aSession
+        , int32 aPortTag
+        , const PvmfMimeString* aPortConfig
+        , const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::RequestPort"));
+
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_REQUESTPORT, aPortTag,
+                  aPortConfig, aContext);
+    return QueueCommandL(cmd);
+}
+
+PVMFPortInterface* TSC_324m::FindOutgoingPort(TPVMediaType_t mediaType)
+{
+    PVMFPortInterface* port = NULL;
+    OlcParam* param = iTSCcomponent->FindOlc(OUTGOING,
+                      mediaType, OLC_ESTABLISHED | OLC_PENDING);
+    if (param)
+    {
+        uint32 channelID = param->GetChannelId();
+        H223OutgoingChannelPtr outgoing_lcn;
+        PVMFStatus pvmfStatus = iH223->GetOutgoingChannel(channelID,
+                                outgoing_lcn);
+        if (pvmfStatus == PVMFSuccess)
+        {
+            port = outgoing_lcn;
+            iRequestedOutgoingChannels[port] = outgoing_lcn;
+        }
+    }
+    return port;
+}
+
+void TSC_324m::DoRequestPort(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoRequestPort"));
+    PVMFStatus pvmfStatus = PVMFSuccess;
+    int32 aPortTag = (int32)cmd.iParam1;
+
+    PvmfMimeString* aPortConfig = (PvmfMimeString*)cmd.iParam2;
+    PVMFPortInterface* port = NULL;
+    if (aPortConfig)
+    {
+        PVMFFormatType formatType(aPortConfig->get_str());
+        if (formatType.isFile())
+        {
+
+            // Multiplexed  PV_MULTIPLEXED
+            // x-pvmf/multiplexed: to identify the lowerlayer port
+            // Is the port already requested ?
+            if (iH223->GetLowerLayer()->IsConnected())
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::RequestPort - Port is in use"));
+                pvmfStatus = PVMFErrBusy;
+            }
+            else
+            {
+                port = iH223->GetLowerLayer();
+            }
+        }
+        else if (*aPortConfig == PVMF_AUDIO_OUTGOING_MIMETYPE)
+        {
+            // Audio x-pvmf/audio;dir=outgoing to identify the outgoing audio channel
+            port = FindOutgoingPort(PV_AUDIO);
+            if (port == NULL)
+            {
+                pvmfStatus = PVMFFailure;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_324m::DoRequestPort Error - Failed to lookup outgoing channel %d",
+                                 aPortTag));
+            }
+        }
+        else if (*aPortConfig == PVMF_VIDEO_OUTGOING_MIMETYPE)
+        {
+            // Video x-pvmf/video;dir=outgoing to identify the outgoing video channel
+            port = FindOutgoingPort(PV_VIDEO);
+            if (port == NULL)
+            {
+                pvmfStatus = PVMFFailure;
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_324m::DoRequestPort Error - Failed to lookup outgoing channel %d",
+                                 aPortTag));
+            }
+        }
+
+        else if (*aPortConfig == PVMF_INCOMING_MIMETYPE || (aPortTag < 0))
+        {
+            if (aPortTag < 0)
+            {
+                aPortTag = -aPortTag;
+            }
+            // just use the channel id
+            //x-pvmf/dir=incoming
+            // Incoming
+            H223IncomingChannelPtr incoming_lcn;
+            pvmfStatus = iH223->GetIncomingChannel(aPortTag, incoming_lcn);
+            if (pvmfStatus == PVMFSuccess)
+            {
+                port = incoming_lcn;
+                iRequestedIncomingChannels[port] = incoming_lcn;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_324m::DoRequestPort Error - Failed to lookup incoming channel %d",
+                                 aPortTag));
+            }
+        }
+
+        else //if (*aPortConfig == PVMF_OUTGOING_MIMETYPE || aPortTag >=0)
+        {
+            //x-pvmf/dir=outgoing
+            // Outgoing
+            H223OutgoingChannelPtr outgoing_lcn;
+            pvmfStatus = iH223->GetOutgoingChannel(aPortTag, outgoing_lcn);
+            if (pvmfStatus == PVMFSuccess)
+            {
+                port = outgoing_lcn;
+                iRequestedOutgoingChannels[port] = outgoing_lcn;
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                                (0, "TSC_324m::DoRequestPort Error - Failed to lookup outgoing channel %d",
+                                 aPortTag));
+            }
+        }
+
+    }
+
+    if (pvmfStatus != PVMFPending)
+    {
+        CommandComplete(iCmdQueue, cmd, pvmfStatus, port);
+        return;
+    }
+    // queue up the command in the pending queue
+    iPendingCmdQueue.StoreL(cmd);
+    iCmdQueue.Erase(&cmd);
+}
+
+
+OSCL_EXPORT_REF  PVMFCommandId TSC_324m::ReleasePort(PVMFSessionId aSession,
+        PVMFPortInterface& aPort,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::ReleasePort"));
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_RELEASEPORT, aPort, aContext);
+    return QueueCommandL(cmd);
+}
+
+void TSC_324m::DoReleasePort(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoReleasePort"));
+
+    PVMFPortInterface* port = (PVMFPortInterface*)cmd.iParam1;
+    if (port->GetPortTag() == PV_MULTIPLEXED)
+    {
+        CommandComplete(iCmdQueue, cmd, PVMFSuccess, port);
+        return;
+    }
+
+    H223LogicalChannel* lcn = OSCL_STATIC_CAST(H223LogicalChannel*, port);
+    if (lcn)
+    {
+        TPVDirection aDirection = port->GetPortTag() < 0 ? INCOMING : OUTGOING;
+        if (aDirection == INCOMING)
+        {
+            Oscl_Map<PVMFPortInterface*, H223IncomingChannelPtr, OsclMemAllocator>::iterator iter;
+            iter = iRequestedIncomingChannels.find(port);
+            if (iter != iRequestedIncomingChannels.end())
+            {
+                iRequestedIncomingChannels[port]->Flush();
+                iH223->CloseChannel(INCOMING,
+                                    iRequestedIncomingChannels[port]->GetLogicalChannelNumber());
+
+
+                iRequestedIncomingChannels.erase(iter);
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TSC_324m::DoReleasePort - Incoming channel not requested"));
+
+            }
+        }
+        else
+        {
+            Oscl_Map<PVMFPortInterface*, H223OutgoingChannelPtr, OsclMemAllocator>::iterator iter;
+            iter = iRequestedOutgoingChannels.find(port);
+            if (iter != iRequestedOutgoingChannels.end())
+            {
+                iH223->FlushChannel(OUTGOING,
+                                    iRequestedOutgoingChannels[port]->GetLogicalChannelNumber());
+                iH223->CloseChannel(OUTGOING,
+                                    iRequestedOutgoingChannels[port]->GetLogicalChannelNumber());
+                iRequestedOutgoingChannels.erase(iter);
+            }
+        }
+    }
+
+    CommandComplete(iCmdQueue, cmd, PVMFSuccess, port);
+    return;
+}
+
+/**
+* Returns a list of ports currently available in the node that meet the filter criteria
+* We can add fancier iterators and filters as needed.  For now we return all the ports.
+**/
+OSCL_EXPORT_REF  PVMFPortIter* TSC_324m::GetPorts(const PVMFPortFilter* aFilter)
+{
+    OSCL_UNUSED_ARG(aFilter);
+    return NULL;
+}
+
+void TSC_324m::DoCancel()
+{
+}
+
+void TSC_324m::Run()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, " TSC_324m::Run()"));
+    if (!iCmdQueue.empty())
+    {
+        ProcessCommand(iCmdQueue.front());
+    }
+
+    if (!iCmdQueue.empty())
+    {
+        // Run again if there are more things to process
+        RunIfNotReady();
+    }
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, " TSC_324m::Run() - done"));
+}
+
+bool TSC_324m::ProcessCommand(Tsc324mNodeCommand& aCmd)
+{
+    switch (aCmd.iCmd)
+    {
+        case PVMF_GENERIC_NODE_QUERYUUID:
+            DoQueryUuid(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_QUERYINTERFACE:
+            DoQueryInterface(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_REQUESTPORT:
+            DoRequestPort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RELEASEPORT:
+            DoReleasePort(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_INIT:
+            DoInit(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PREPARE:
+            DoPrepare(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_START:
+            DoStart(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_STOP:
+            DoStop(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_FLUSH:
+            DoFlush(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_PAUSE:
+            DoPause(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_RESET:
+            DoReset(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELALLCOMMANDS:
+            DoCancelAllCommands(aCmd);
+            break;
+
+        case PVMF_GENERIC_NODE_CANCELCOMMAND:
+            DoCancelCommand(aCmd);
+            break;
+
+        default://unknown command type
+            if (iTSCcomponent->ProcessCommand(aCmd))
+            {
+                CommandComplete(iCmdQueue, aCmd, PVMFSuccess);
+            }
+            else
+            {
+                CommandComplete(iCmdQueue, aCmd, PVMFFailure);
+            }
+            break;
+    }
+
+    return true;
+}
+
+int32 TSC_324m::FindPendingPortCmd(TPVMFGenericNodeCommand aCmdType,
+                                   int32 aPortTag,
+                                   Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::FindPendingRequestPortCmd aCmdType=%d, aPortTag=%d",
+                     aCmdType, aPortTag));
+
+    int32 cmdIndex = -1;
+
+    for (uint32 i = 0; i < iPendingCmdQueue.size(); i++)
+    {
+        if ((TPVMFGenericNodeCommand)iPendingCmdQueue[i].iCmd == aCmdType)
+        {
+            if (aPortTag == (int32)iPendingCmdQueue[i].iParam1)
+            {
+                cmd = iPendingCmdQueue[i];
+                cmdIndex = i;
+                break;
+            }
+        }
+    }
+
+    if (cmdIndex < 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::FindPendingPortCmd Error - command not found"));
+        return 0;
+    }
+
+    // Destroy command object
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::FindPendingPortCmd : Deleting cmd from iPendingQueue. cmdIndex=%d",
+                     cmdIndex));
+    iPendingCmdQueue.Erase(&iPendingCmdQueue[cmdIndex]);
+    return cmdIndex;
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetMultiplexLevel(TPVH223Level muxLevel)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetMultiplexLevel  level(%d)\n", muxLevel));
+    iH223Level = muxLevel;
+
+    if (iH223)
+    {
+        iH223->SetMultiplexLevel(muxLevel);
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetSduSize(TPVDirection direction,
+        uint16 size,
+        TPVAdaptationLayer al)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetSduSize  direction(%d), size(%d), al(%d)\n",
+                     direction, size, al));
+    if (iH223)
+    {
+        iH223->SetSduSize(direction, size, EplForAdaptationLayer(al));
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetAl2Sn(int width)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetAl2Sn on/off(%d)\n", width));
+    iTSCcomponent->SetAl2Sn(width);
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetAl3ControlFieldOctets(unsigned cfo)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetAl3ControlFieldOctets cfo(%d)\n", cfo));
+    iTSCcomponent->SetAl3ControlFieldOctets(cfo);
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetMaxOutgoingPduSize(uint16 size)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetMaxOutgoingPduSize size(%d)\n", size));
+    if (iH223)
+    {
+        iH223->SetMaxOutgoingPduSize(size);
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetMaxMuxPduSize(uint16 size)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetMaxMuxPduSize size(%d)\n", size));
+    iRequestMaxMuxPduSize = size;
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetMaxCcsrlSduSize(int size)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetMaxCcsrlSduSize size(%d)\n", size));
+    if (iSrp)
+    {
+        iSrp->SetCCSRLSduSize(size);
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SetMaxCcsrlSduSize - Invalid state: SRP == NULL"));
+    }
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetOutgoingMuxPduType(TPVH223MuxPduType outgoingPduType)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetOutgoingMuxPduType type(%d)\n",
+                     outgoingPduType));
+    iOutgoingPduType = outgoingPduType;
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetOutgoingChannelConfig(
+    Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& out_channel_config)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetOutgoingChannelConfig size(%d)\n",
+                     out_channel_config.size()));
+    if (iInterfaceState != EPVMFNodeInitialized)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SetOutgoingChannelConfig Error: Invalid state."));
+        OSCL_LEAVE(PVMFErrInvalidState);
+    }
+    iTSCcomponent->SetOutgoingChannelConfig(out_channel_config);
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetIncomingChannelConfig(
+    Oscl_Vector<H324ChannelParameters, PVMFTscAlloc>& in_channel_config)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetIncomingChannelConfig size(%d)\n",
+                     in_channel_config.size()));
+    iTSCcomponent->SetIncomingChannelConfig(in_channel_config);
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetAlConfig(PV2WayMediaType media_type,
+        TPVAdaptationLayer layer,
+        bool allow)
+{
+    iTSCcomponent->SetAlConfig(media_type, layer, allow);
+}
+
+PVMFCommandId TSC_324m::QueryUUID(PVMFSessionId aSession,
+                                  const PvmfMimeString& aMimeType,
+                                  Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+                                  bool aExactUuidsOnly,
+                                  const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::QueryUUID"));
+    // create message to be completed later - depending on what it is...
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYUUID, aMimeType,
+                  aUuids, aExactUuidsOnly, aContext);
+    iComponentRegistry.QueryRegistry(cmd);
+    //return QueueCommandL(cmd);
+    return 0;
+}
+
+PVMFCommandId TSC_324m::QueryInterface(PVMFSessionId aSession,
+                                       const PVUuid& aUuid,
+                                       PVInterface*& aInterfacePtr,
+                                       const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::QueryInterface()"));
+
+    if (aUuid == PVH324MConfigUuid)
+    {
+        aInterfacePtr = OSCL_NEW(H324MConfig, (this, true));
+    }
+    else if (aUuid == PVUidProxiedInterface)
+    {
+        H324MProxiedInterface* proxied_interface_ptr = NULL;
+        proxied_interface_ptr = OSCL_NEW(H324MProxiedInterface, ());
+        proxied_interface_ptr->SetH324M(this);
+        aInterfacePtr = proxied_interface_ptr;
+    }
+    else
+    {
+        TSC_component* backup = iTSCcomponent;
+
+        // send onto TSCComponentRegistry::Create to let it finish
+        iTSCcomponent = iComponentRegistry.Create(aSession, aUuid,
+                        aInterfacePtr, aContext);
+        if (iTSCcomponent)
+        {
+            InitComponent();
+            if (backup)
+            {
+                OSCL_DELETE(backup);
+            }
+        }
+    }
+
+    // Add command to queue
+    /*Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_QUERYINTERFACE, aUuid, aInterfacePtr, aContext) ;
+    return QueueCommandL(cmd);
+    */
+    return 0;
+}
+
+void TSC_324m::DoQueryInterface(Tsc324mNodeCommand& cmd)
+{
+    OSCL_UNUSED_ARG(cmd);
+    //CommandComplete(iCmdQueue, cmd, PVMFSuccess);
+}
+
+void TSC_324m::DoQueryUuid(Tsc324mNodeCommand& cmd)
+{
+    OSCL_UNUSED_ARG(cmd);
+    //CommandComplete(iCmdQueue, cmd, PVMFSuccess);
+}
+
+PVMFCommandId TSC_324m::CancelAllCommands(PVMFSessionId aSession,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return -1;
+}
+
+
+OSCL_EXPORT_REF PVMFCommandId TSC_324m::CancelCommand(PVMFSessionId aSession,
+        PVMFCommandId aCommandId,
+        const OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::CancelCommand id(%d)", aCommandId));
+    // Add command to queue
+    Tsc324mNodeCommand cmd;
+    cmd.Construct(aSession, PVMF_GENERIC_NODE_CANCELCOMMAND, aCommandId, aContext);
+    return QueueCommandL(cmd);
+}
+
+void TSC_324m::DoCancelCommand(Tsc324mNodeCommand& cmd)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::DoCancelCommand cmd(%x)", &cmd));
+    PVMFStatus status = PVMFSuccess;
+    int cmdIndex = FindPendingCmd((PVMFCommandId)cmd.iParam1);
+
+    if (cmdIndex < 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::DoCancelCommand Failed to lookup command(%d)",
+                         (PVMFCommandId)cmd.iParam1));
+        Tsc324mNodeCommand* found_cmd = iCmdQueue.FindById((PVMFCommandId)cmd.iParam1);
+        if (found_cmd)
+        {
+            iCmdQueue.Erase(found_cmd);
+        }
+        else
+            status = PVMFErrArgument;
+    }
+    else
+    {
+        // Destroy command object
+        Tsc324mNodeCommand to_be_deleted_cmd = iPendingCmdQueue[cmdIndex];
+        iPendingCmdQueue.Erase(&iPendingCmdQueue[cmdIndex]);
+    }
+    CommandComplete(iCmdQueue, cmd, status);
+}
+
+int TSC_324m::FindPendingCmd(PVMFCommandId aCommandId)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::FindPendingCmd id(%d)", aCommandId));
+    int32 cmdIndex = -1;
+    for (uint32 i = 0; i < iPendingCmdQueue.size(); i++)
+    {
+        if (iPendingCmdQueue[i].iId == aCommandId)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TSC_324m::FindPendingCmd - command found in iPendingCmdQueue"));
+            cmdIndex = i;
+            break;
+        }
+    }
+    return cmdIndex;
+}
+
+const uint8* TSC_324m::GetFormatSpecificInfo(PVMFPortInterface* port,
+        uint32* len)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::GetFormatSpecificInfo port(%x)", port));
+    return ((H223LogicalChannel*)port)->GetFormatSpecificInfo(len);
+}
+
+LogicalChannelInfo* TSC_324m::GetLogicalChannelInfo(PVMFPortInterface& port)
+{
+    return iTSCcomponent->GetLogicalChannelInfo(port);
+}
+
+bool TSC_324m::IsEstablishedLogicalChannel(TPVDirection aDir,
+        TPVChannelId aChannelId)
+{
+    return iTSCcomponent->IsEstablishedLogicalChannel(aDir, aChannelId);
+}
+
+void TSC_324m::SetSkewReference(PVMFPortInterface* aPort,
+                                PVMFPortInterface* aReferencePort)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetSkewReference"));
+    H223OutgoingChannel* lcn2 = OSCL_STATIC_CAST(H223OutgoingChannel*,
+                                aPort);
+    H223OutgoingChannel* lcn1 = OSCL_STATIC_CAST(H223OutgoingChannel*,
+                                aReferencePort);
+    lcn2->SetSkewReference(lcn1);
+}
+
+void TSC_324m::SendVideoTemporalSpatialTradeoffCommand(TPVChannelId aLogicalChannel,
+        uint8 aTradeoff)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SendVideoTemporalSpatialTradeoffCommand aLogicalChannel=%d, aTradeoff=%d", aLogicalChannel, aTradeoff));
+    if (iTerminalStatus != PhaseE_Comm)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SendVideoTemporalSpatialTradeoffCommand Ignoring due to invalid state."));
+        return;
+    }
+    CmdMisc(EVideoTemporalSpatialTradeOff, aLogicalChannel, aTradeoff);
+}
+
+void TSC_324m::SendVideoTemporalSpatialTradeoffIndication(TPVChannelId aLogicalChannel,
+        uint8 aTradeoff)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SendVideoTemporalSpatialTradeoffIndication aLogicalChannel=%d, aTradeoff=%d", aLogicalChannel, aTradeoff));
+    if (iTerminalStatus != PhaseE_Comm)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SendVideoTemporalSpatialTradeoffIndication Ignoring due to invalid state."));
+        return;
+    }
+    IndicationMisc(EVideoTemporalSpatialTradeOffIdc, aLogicalChannel,
+                   aTradeoff);
+}
+
+void TSC_324m::SetDatapathLatency(TPVDirection aDir, PVMFPortInterface* aPort,
+                                  uint32 aLatency)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetDatapathLatency aDir=%d, aPort=%x, aLatency=%d", aDir, aPort, aLatency));
+    OSCL_UNUSED_ARG(aDir);
+    H223LogicalChannel* lcn = OSCL_STATIC_CAST(H223LogicalChannel* , aPort);
+    if (lcn == NULL)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::SetDatapathLatency WARNING lcn==NULL"));
+        return;
+    }
+
+    lcn->SetDatapathLatency(aLatency);
+}
+
+void TSC_324m::SendSkewIndication(TPVChannelId aLogicalChannel1,
+                                  TPVChannelId aLogicalChannel2,
+                                  uint16 aSkew)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SendSkewIndication aLogicalChannel1=%d, aLogicalChannel2=%d, aSkew=%d",
+                     aLogicalChannel1, aLogicalChannel2, aSkew));
+    if (iTerminalStatus != PhaseE_Comm)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::SendSkewIndication Ignoring due to invalid state."));
+        return;
+    }
+    Tsc_IdcSkew(aLogicalChannel1, aLogicalChannel2, aSkew);
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetMultiplexingDelayMs(uint16 aDelay)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetMultiplexingDelayMs,aDelay=%d", aDelay));
+    iMultiplexingDelayMs = aDelay;
+    if (iH223)
+        iH223->SetMultiplexingDelayMs((uint16)iMultiplexingDelayMs);
+}
+
+void TSC_324m::ConfigureSrp(TPVH223Level aLevel)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::ConfigureSrp aLevel=%d", aLevel));
+    iTscSrpBuffer->Stop();
+
+    iSrp->SrpStop();
+    iSrp->SrpReset();
+    iSrp->SrpInitL();
+    iSrp->SetSRPTimeoutValue(iT401);
+    iSrp->SetNumSRPRetries(iN401);
+
+    /* We will enable NSRP for level 0 if the remote terminal signals capability */
+    if (aLevel == H223_LEVEL0)
+    {
+        iSrp->SetCCSRLSduSize(0);
+        iSrp->UseNSRP(false);
+    }
+    else
+    {
+        iSrp->UseNSRP(true);
+    }
+
+    if (!iEnableWnsrp || aLevel == H223_LEVEL0)
+    {
+        iSrp->DisableWNSRPSupport();
+    }
+
+    H223IncomingChannelPtr incoming_control_channel;
+    PVMFStatus aStatus = iH223->GetIncomingChannel((TPVChannelId)0,
+                         incoming_control_channel);
+    if (aStatus == PVMFSuccess)
+    {
+        incoming_control_channel->Disconnect();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::ConfigureSrp Error - Failed to lookup incoming logical channel %d", 0));
+        return;
+    }
+
+    H223OutgoingChannelPtr outgoing_control_channel;
+    aStatus = iH223->GetOutgoingChannel((TPVChannelId)0,
+                                        outgoing_control_channel);
+    if (aStatus == PVMFSuccess)
+    {
+        outgoing_control_channel->Disconnect();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::ConfigureSrp Error - Failed to lookup outgoing logical channel %d", 0));
+        return;
+    }
+
+    PVMFPortInterface *port;
+
+    port = iSrp->RequestULPort(SRP_INPUT_PORT_TAG);
+    iTscSrpBuffer->GetLLPort(TSCSRPBUFFER_OUTPUT_PORT_TAG)->Connect(port);
+
+    port = iSrp->RequestULPort(SRP_OUTPUT_PORT_TAG);
+    port->Connect(iTscSrpBuffer->GetLLPort(TSCSRPBUFFER_INPUT_PORT_TAG));
+
+    iTscSrpBuffer->GetUpperLayer()->Bind(iH245);
+
+    iOutgoingSrpPort = iSrp->RequestLLPort(SRP_INPUT_PORT_TAG);
+    iIncomingSrpPort = iSrp->RequestLLPort(SRP_OUTPUT_PORT_TAG);
+    iOutgoingSrpPort->Connect(incoming_control_channel);
+//	incoming_control_channel->Connect(iOutgoingSrpPort);
+    iIncomingSrpPort->Connect(outgoing_control_channel);
+//	outgoing_control_channel->Connect(iIncomingSrpPort);
+
+    iTscSrpBuffer->Start();
+    iSrp->SrpStart();
+}
+
+void TSC_324m::StopSrp()
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::StopSrp "));
+    iSrp->SrpStop();
+    iTscSrpBuffer->Stop();
+
+    H223IncomingChannelPtr incoming_control_channel;
+    PVMFStatus aStatus = iH223->GetIncomingChannel((TPVChannelId)0,
+                         incoming_control_channel);
+    if (aStatus == PVMFSuccess)
+    {
+        incoming_control_channel->Disconnect();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::ConfigureSrp Error - Failed to lookup incoming logical channel %d", 0));
+    }
+
+    H223OutgoingChannelPtr outgoing_control_channel;
+    aStatus = iH223->GetOutgoingChannel((TPVChannelId)0,
+                                        outgoing_control_channel);
+    if (aStatus == PVMFSuccess)
+    {
+        outgoing_control_channel->Disconnect();
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_WARNING,
+                        (0, "TSC_324m::ConfigureSrp Error - Failed to lookup outgoing logical channel %d", 0));
+    }
+
+    PVMFPortInterface *port = NULL;
+
+    port = iSrp->RequestULPort(SRP_INPUT_PORT_TAG);
+    if (port)
+        port->Disconnect();
+
+    port = iTscSrpBuffer->GetLLPort(TSCSRPBUFFER_OUTPUT_PORT_TAG);
+    if (port)
+        port->Disconnect();
+
+    port = iSrp->RequestULPort(SRP_OUTPUT_PORT_TAG);
+    if (port)
+        port->Disconnect();
+
+    port = iTscSrpBuffer->GetLLPort(TSCSRPBUFFER_INPUT_PORT_TAG);
+    if (port)
+        port->Disconnect();
+
+    iTscSrpBuffer->GetUpperLayer()->UnBind();
+
+    if (iOutgoingSrpPort)
+        iOutgoingSrpPort->Disconnect();
+    if (iIncomingSrpPort)
+        iIncomingSrpPort->Disconnect();
+}
+
+
+OSCL_EXPORT_REF void TSC_324m::GetChannelFormatAndCapabilities(TPVDirection dir,
+        Oscl_Vector<FormatCapabilityInfo, OsclMemAllocator>& formats)
+{
+    iTSCcomponent->GetChannelFormatAndCapabilities(dir, formats);
+}
+
+OSCL_EXPORT_REF void TSC_324m::SetLogicalChannelBufferingMs(uint32 aInBufferingMs,
+        uint32 aOutBufferingMs)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::SetLogicalChannelBufferingMs aInBufferingMs=%d, aOutBufferingMs=%d",
+                     aInBufferingMs, aOutBufferingMs));
+    iInLogicalChannelBufferingMs = aInBufferingMs;
+    iOutLogicalChannelBufferingMs = aOutBufferingMs;
+}
+
+void TSC_324m::UseWNSRP(bool aUse)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m::UseWNSRP %d", aUse));
+    SetWnsrp(aUse);
+
+    PS_MultiplexEntryDescriptor desc = iH223->GetIncomingMuxDescriptor(TSC_WNSRP_MUX_ENTRY_NUMBER);
+    if (desc &&
+            desc->size_of_elementList &&
+            desc->elementList->muxType.index == 0 &&
+            desc->elementList->muxType.logicalChannelNumber == 0)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TSC_324m::UseWNSRP Deleting incoming descriptor for WNSRP"));
+        iH223->RemoveIncomingMuxDescriptor(TSC_WNSRP_MUX_ENTRY_NUMBER);
+    }
+}
+
+
+void TSC_324m::SetTSC_324mObserver(TSC_324mObserver* aObserver)
+{
+    if (aObserver == NULL)
+        return;
+    iTSC_324mObserver = aObserver;
+}
+
+PVMFCommandId TSC_324m::QueueCommandL(Tsc324mNodeCommand& aCmd)
+{
+    PVMFCommandId id;
+
+    id = iCmdQueue.AddL(aCmd);
+
+    //wakeup the AO
+    RunIfNotReady();
+
+    return id;
+}
+
+void TSC_324m::CommandComplete(Tsc324mNodeCmdQ& aCmdQ, Tsc324mNodeCommand& aCmd,
+                               PVMFStatus aStatus, OsclAny* aEventData)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TSC_324m:CommandComplete Id %d Cmd %d Status %d Context %d Data %d",
+                     aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
+
+    //create response
+    PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+    PVMFSessionId session = aCmd.iSession;
+
+    //Erase the command from the queue.
+    aCmdQ.Erase(&aCmd);
+
+    //Report completion to the session observer.
+    ReportCmdCompleteEvent(session, resp);
+}
+
+int32 TSC_324m::GetPortTagForLcn(TPVDirection aDir, TPVChannelId aId,
+                                 PVCodecType_t aCodecType)
+{
+    if (aDir == INCOMING)
+        return -aId;
+    return GetMediaType(aCodecType);
+}
+
+PVMFStatus TSC_324m::ThreadLogon()
+{
+    AddToScheduler();
+
+    SetState(EPVMFNodeIdle);
+    return PVMFSuccess;
+}
+
+PVMFStatus TSC_324m::ThreadLogoff()
+{
+    SetState(EPVMFNodeCreated);
+    RemoveFromScheduler();
+    return PVMFSuccess;
+}
+
+void TSC_324m::HandlePortActivity(const PVMFPortActivity& aActivity)
+{
+    OSCL_UNUSED_ARG(aActivity);
+}
+
+PVMFCommandId TSC_324m::Flush(PVMFSessionId aSession,
+                              const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+
+    OSCL_LEAVE(PVMFErrNotSupported);
+    return 0;
+}
+
+void TSC_324m::SetMioLatency(int32 aLatency, bool aAudio)
+{
+    iH223->SetMioLatency(aLatency, aAudio);
+}
+
+#ifdef MEM_TRACK
+void TSC_324m::MemStats()
+{
+#if !(OSCL_BYPASS_MEMMGT)
+
+    OsclAuditCB auditCB;
+    OsclMemInit(auditCB);
+    if (auditCB.pAudit)
+    {
+        MM_Stats_t* stats = auditCB.pAudit->MM_GetStats("");
+        if (stats)
+        {
+            printf("\n###################Memory Stats Start#################\n");
+            printf("  numBytes %d\n", stats->numBytes);
+            printf("  peakNumBytes %d\n", stats->peakNumBytes);
+            printf("  numAllocs %d\n", stats->numAllocs);
+            printf("  peakNumAllocs %d\n", stats->peakNumAllocs);
+            printf("  numAllocFails %d\n", stats->numAllocFails);
+            printf("  totalNumAllocs %d\n", stats->totalNumAllocs);
+            printf("  totalNumBytes %d\n", stats->totalNumBytes);
+            printf("\n###################Memory Stats End###################\n");
+        }
+
+    }
+#endif
+}
+#endif
+
diff --git a/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tscsrpbuffer.cpp b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tscsrpbuffer.cpp
new file mode 100644
index 0000000..c4a4ec4
--- /dev/null
+++ b/protocols/systems/3g-324m_pvterminal/h324/tsc/src/tscsrpbuffer.cpp
@@ -0,0 +1,365 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "tscsrpbuffer.h"
+#define MAX_TSCSRP_BUFFER_SZ 768
+#define NUM_TSCSRP_FRAGS 24
+#define PV_TSC_SRP_BUFFER_TIMER_ID 1
+#define TSC_SRP_BUFFER_TIMEOUT 50
+
+
+TscSrpBufferLLPortIn *TscSrpBufferLLPortIn::NewL(TscSrpBuffer *aTscSrpBuffer)
+{
+    TscSrpBufferLLPortIn *self = OSCL_NEW(TscSrpBufferLLPortIn, (aTscSrpBuffer));
+    if (self)
+    {
+        ConstructSelf(self);
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+    return self;
+}
+
+void TscSrpBufferLLPortIn::ConstructSelf(TscSrpBufferLLPortIn* self)
+{
+    int error;
+    OSCL_TRY(error, self->ConstructL(););
+    if (error)
+    {
+        OSCL_DELETE(self);
+        OSCL_LEAVE(error);
+    }
+}
+
+
+TscSrpBufferLLPortIn::~TscSrpBufferLLPortIn()
+{
+    if (iFrag)
+    {
+        iMediaFragAlloc->deallocate_fragment(iFrag);
+        iFrag = NULL;
+    }
+
+    if (iPkt)
+    {
+        iPkt->Clear();
+        iMediaPktAlloc.deallocate_packet(iPkt);
+        iPkt = NULL;
+    }
+
+    if (iMediaFragAlloc)
+    {
+        OSCL_DELETE(iMediaFragAlloc);
+        iMediaFragAlloc = NULL;
+    }
+}
+
+PVMFStatus TscSrpBufferLLPortIn::Receive(PVMFSharedMediaMsgPtr aMsg)
+{
+    OsclRefCounterMemFrag frag;
+    PVMFSharedMediaDataPtr mediaData;
+    convertToPVMFMediaData(mediaData, aMsg);
+    uint32 fullH245Msg = mediaData->getMarkerInfo();
+
+    if (iFrag == NULL)
+    {
+        iFrag = iMediaFragAlloc->allocate_fragment(MAX_TSCSRP_BUFFER_SZ);
+        if (iFrag == NULL) return PVMFFailure;
+    }
+
+    for (uint32 i = 0; i < mediaData->getNumFragments(); i++)
+    {
+        if (mediaData->getMediaFragment(i, frag))
+        {
+            if ((frag.getMemFragSize() + iCurSize) > MAX_TSCSRP_BUFFER_SZ)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iTscSrpBuffer->iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "TscSrpBufferLLPortIn::PutData MAX_TSCSRP_BUFFER_SZ size exceeded"));
+                fullH245Msg = true;
+                break;
+            }
+            else
+            {
+                oscl_memcpy(iFrag->GetPtr() + iCurSize, frag.getMemFragPtr(),
+                            frag.getMemFragSize());
+                iCurSize += frag.getMemFragSize();
+            }
+        }
+    }
+
+    if (fullH245Msg)
+    {
+        iFrag->GetFragment()->len = iCurSize;
+        iPkt->AddMediaFragment(iFrag);
+        iMediaFragAlloc->deallocate_fragment(iFrag);
+        iFrag = NULL;
+        iCurSize = 0;
+
+        iTscSrpBuffer->ProcessIncomingSrpPacket(iPkt);
+        iPkt->Clear();
+    }
+
+    return PVMFSuccess;
+}
+
+void TscSrpBufferLLPortIn::ConstructL()
+{
+    iMediaFragAlloc = OSCL_NEW(PoolFragmentAllocator, (NUM_TSCSRP_FRAGS,
+                               MAX_TSCSRP_BUFFER_SZ));
+    OsclError::LeaveIfNull(iMediaFragAlloc);
+    iPkt = iMediaPktAlloc.allocate_packet();
+}
+
+TscSrpBuffer *TscSrpBuffer::NewL()
+{
+    TscSrpBuffer *self = OSCL_NEW(TscSrpBuffer, ());
+    if (self)
+    {
+        ConstructSelf(self);
+    }
+    else
+    {
+        OSCL_LEAVE(PVMFErrNoMemory);
+    }
+
+    return self;
+}
+
+void TscSrpBuffer::ConstructSelf(TscSrpBuffer* self)
+{
+    int error;
+    OSCL_TRY(error, self->ConstructL(););
+    if (error)
+    {
+        OSCL_DELETE(self);
+        OSCL_LEAVE(error);
+    }
+}
+
+
+TscSrpBuffer::~TscSrpBuffer()
+{
+    iTxData.Unbind();
+
+    if (iLLPortIn)
+    {
+        OSCL_DELETE(iLLPortIn);
+        iLLPortIn = NULL;
+    }
+
+    if (iLLPortOut)
+    {
+        OSCL_DELETE(iLLPortOut);
+        iLLPortOut = NULL;
+    }
+
+    if (iTimer)
+    {
+        iTimer->Clear();
+        OSCL_DELETE(iTimer);
+        iTimer = NULL;
+    }
+
+    if (iTxPacketAlloc)
+    {
+        OSCL_DELETE(iTxPacketAlloc);
+        iTxPacketAlloc = NULL;
+    }
+
+    if (iTxMediaDataImplMemAlloc)
+    {
+        OSCL_DELETE(iTxMediaDataImplMemAlloc);
+        iTxMediaDataImplMemAlloc = NULL;
+    }
+
+    if (iTxMediaMsgPoolAlloc)
+    {
+        OSCL_DELETE(iTxMediaMsgPoolAlloc);
+        iTxMediaMsgPoolAlloc = NULL;
+    }
+}
+
+void TscSrpBuffer::ProcessIncomingSrpPacket(MediaPacket* pPkt)
+{
+    iH245Interface.Dispatch(pPkt);
+}
+
+void TscSrpBuffer::ProcessOutgoingH245Packet(MediaPacket* pPkt)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TscSrpBuffer::ProcessOutgoingH245Packet instance=%x, pPkt=%x",
+                     this, pPkt));
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TscSrpBuffer::ProcessOutgoingH245Packet pPkt length=%d",
+                     pPkt->GetLength()));
+
+    if (iState != TscSrpBufferStarted)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "TscSrpBuffer::ProcessOutgoingH245Packet - Error: Message received in stopped state"));
+        return;
+    }
+
+    //Allocate message and data
+    if (iTxData.GetRep() == NULL)
+    {
+        OsclSharedPtr<PVMFMediaDataImpl> data;
+
+        data = iTxPacketAlloc->allocate(MAX_TSCSRP_BUFFER_SZ);
+        if (!data)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                            PVLOGMSG_ERR, (0,
+                                           "TscSrpBuffer::ProcessOutgoingH245Packet - Unable allocate tx message impl"));
+            return;
+        }
+
+        iTxData = PVMFMediaData::createMediaData(data, iTxMediaMsgPoolAlloc);
+        if (!iTxData)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger,
+                            PVLOGMSG_ERR, (0,
+                                           "TscSrpBuffer::ProcessOutgoingH245Packet - Unable allocate tx message"));
+            return;
+        }
+    }
+
+    iNumMsgs++;
+
+    /* Just add the fragments to our fragment */
+    MediaFragment frag;
+    OsclRefCounterMemFrag osclFrag;
+    uint32 curSize = iTxData->getFilledSize();
+    iTxData->getMediaFragment(0, osclFrag);
+
+    for (int frag_num = 0; frag_num < pPkt->GetNumFrags(); frag_num++)
+    {
+        pPkt->GetMediaFragment(frag_num, frag);
+
+        if ((curSize + frag.GetLen()) > MAX_TSCSRP_BUFFER_SZ)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "TscSrpBuffer::ProcessOutgoingH245Packet - Error: Buffer size exceeded"));
+            /* reset the buffer */
+            Reset();
+            return;
+        }
+        oscl_memcpy((uint8 *)osclFrag.getMemFragPtr() + curSize, frag.GetPtr(),
+                    frag.GetLen());
+        curSize += frag.GetLen();
+    }
+
+    iTxData->setMediaFragFilledLen(0, curSize);
+
+    if (iEnableBuffering)
+    {
+        if (iNumMsgs == 1)
+        {
+            // start the timer
+            iTimer->Request(PV_TSC_SRP_BUFFER_TIMER_ID,
+                            PV_TSC_SRP_BUFFER_TIMER_ID , 1, this);
+        }
+    }
+    else
+    {
+        // Cancel the timer
+        iTimer->Cancel(PV_TSC_SRP_BUFFER_TIMER_ID);
+        // Call the dispatch routine immediately
+        TimeoutOccurred(PV_TSC_SRP_BUFFER_TIMER_ID, 0);
+    }
+}
+
+void TscSrpBuffer::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timerID);
+    OSCL_UNUSED_ARG(timeoutInfo);
+
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TscSrpBuffer::TimeoutOccurred- iNumMsgs(%d), size(%d)\n",
+                     iNumMsgs, iTxData->getFilledSize()));
+    OSCL_ASSERT(iNumMsgs);
+
+    /* Dispatch message to SRP */
+    if (iNumMsgs)
+    {
+        PVMFSharedMediaMsgPtr msg;
+
+        convertToPVMFMediaMsg(msg, iTxData);
+
+        iNumMsgs = 0;
+        iTxData.Unbind();
+        iLLPortOut->QueueOutgoingMsg(msg);
+        iLLPortOut->Send();
+    }
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "TscSrpBuffer::TimeoutOccurred- done"));
+
+}
+
+void TscSrpBuffer::Start()
+{
+    iState = TscSrpBufferStarted;
+}
+
+void TscSrpBuffer::Stop()
+{
+    iState = TscSrpBufferStopped;
+    iTimer->Clear();
+    Reset();
+}
+
+void TscSrpBuffer::Reset()
+{
+    iTxData.Unbind();
+    iNumMsgs = 0;
+}
+
+void TscSrpBuffer::EnableBuffering(bool enable)
+{
+    iEnableBuffering = enable;
+}
+
+void TscSrpBuffer::ConstructL()
+{
+    iLogger = PVLogger::GetLoggerObject("3g324m.srp.tscsrpbuffer");
+
+    iTxMediaMsgPoolAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator,
+                                    (NUM_TSCSRP_FRAGS, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iTxMediaMsgPoolAlloc);
+    iTxMediaDataImplMemAlloc = OSCL_NEW(OsclMemPoolFixedChunkAllocator,
+                                        (NUM_TSCSRP_FRAGS, 0, &iMemAllocator));
+    OsclError::LeaveIfNull(iTxMediaDataImplMemAlloc);
+    iTxPacketAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc,
+                              (iTxMediaDataImplMemAlloc));
+    OsclError::LeaveIfNull(iTxPacketAlloc);
+
+    iTimer = new OsclTimer<OsclMemAllocator>("TSCSRPBufferTimer");
+    OsclError::LeaveIfNull(iTimer);
+    iTimer->SetFrequency(1000 / TSC_SRP_BUFFER_TIMEOUT); // make timer work in 20ms intervals
+    iTimer->SetObserver(this);
+
+    iLLPortOut = OSCL_NEW(TscSrpBufferLLPortOut, ());
+    OsclError::LeaveIfNull(iLLPortOut);
+    iLLPortIn = TscSrpBufferLLPortIn::NewL(this);
+
+    iH245Interface = this;
+}
+
+
+
diff --git a/protocols/systems/common/Android.mk b/protocols/systems/common/Android.mk
new file mode 100644
index 0000000..50e23a8
--- /dev/null
+++ b/protocols/systems/common/Android.mk
@@ -0,0 +1,29 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ 	
+
+
+
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/protocols/systems/common/src \
+ 	$(PV_TOP)/protocols/systems/common/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	include/pv_2way_basic_types.h \
+ 	include/pv_2way_basic_interfaces.h
+
+include $(BUILD_COPY_HEADERS)
diff --git a/protocols/systems/common/build/make/local.mk b/protocols/systems/common/build/make/local.mk
new file mode 100644
index 0000000..8937038
--- /dev/null
+++ b/protocols/systems/common/build/make/local.mk
@@ -0,0 +1,20 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET :=  
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := 
+
+HDRS := pv_2way_basic_types.h \
+	pv_2way_basic_interfaces.h
+ 
+include $(MK)/library.mk
+
+ 
diff --git a/protocols/systems/common/include/controls.h b/protocols/systems/common/include/controls.h
new file mode 100644
index 0000000..cb6505e
--- /dev/null
+++ b/protocols/systems/common/include/controls.h
@@ -0,0 +1,39 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(CPVCONTROLS_H)
+#define CPVCONTROLS_H
+#include "oscl_types.h"
+#include "pvt_params.h"
+
+class CPVControlsObserver
+{
+    public:
+        virtual void HandleControlMessage(PS_ControlMsgHeader msg) = 0;
+};
+
+class CPVControls
+{
+    public:
+        CPVControls() {}
+        virtual ~CPVControls() {}
+        virtual void DispatchControlMessage(PS_ControlMsgHeader msg) = 0;
+        virtual void SetControlsObserver(CPVControlsObserver* observer) = 0;
+    protected:
+        //CPVControlsObserver* iObserver;
+};
+#endif
diff --git a/protocols/systems/common/include/pv_2way_basic_interfaces.h b/protocols/systems/common/include/pv_2way_basic_interfaces.h
new file mode 100644
index 0000000..da7b866
--- /dev/null
+++ b/protocols/systems/common/include/pv_2way_basic_interfaces.h
@@ -0,0 +1,104 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+* ==============================================================================
+*  Name        : pv_2way_basic_interfaces.h
+*  Part of     :
+*  Interface   :
+*  Description : Interface class and supporting definitions for the PV2Way SDK
+*  Version     : (see RELEASE field in copyright header above)
+*
+* ==============================================================================
+*/
+
+#ifndef PV_2WAY_BASIC_INTERFACES_H_INCLUDED
+#define PV_2WAY_BASIC_INTERFACES_H_INCLUDED
+
+
+//  INCLUDES
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+
+/**
+ * The UUID for PV2WayTrackInfoInterface extension interface in PVAsyncInformationalEvent
+ **/
+#define PV2WayTrackInfoInterfaceUUID PVUuid(0x0864f8a2,0xde16,0x4ced,0xaa,0x48,0xda,0x18,0x20,0xf0,0x75,0xfb) // TBD: generate a new UUID here
+
+/**
+ * PV2WayTrackInfoInterface
+ *
+ * PV2WayTrackInfoInterface is an optional extension interface exposed by the PVAsyncInformationalEvent class
+ * to indicate extended track attributes to the application.
+ *
+ **/
+class PV2WayTrackInfoInterface : public PVInterface
+{
+    public:
+        /*
+           Returns the code and space UUID for this info message
+
+           @param aCode Reference to an integer which will be filled in with event code
+           @param aUuid Reference to a PVUuid which will be filled in with UUID assocated to event code
+
+           @return None
+        */
+        virtual void GetCodeUUID(int32& aCode, PVUuid& aUuid) = 0;
+
+        /*
+           Returns a reference to the format string.
+
+           @return Reference to the format string
+        */
+        virtual void GetFormatString(PVMFFormatType& aMimeString) = 0;
+
+        /*
+           Returns the Format Specific Info associated with this track
+
+           @return A pointer to the Format Specific Info.  NULL if FSI is not present
+        */
+        virtual uint8* GetFormatSpecificInfo(uint32& aFormatSpecificInfoLen) = 0;
+
+        // From PVInterface
+
+        /*
+           Increments the reference count for this info message object
+         */
+        virtual void addRef() = 0;
+        /*
+           Decrements the reference count for this info message object and deletes
+           this object if count goes to 0.
+        */
+        virtual void removeRef() = 0;
+        /*
+           Returns the extension interface for the specified UUID if this info
+           message object supports it. If the requested extension interface is supported
+           true is returned, else false.
+        */
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
+};
+
+
+#endif //
+
+
diff --git a/protocols/systems/common/include/pv_2way_basic_types.h b/protocols/systems/common/include/pv_2way_basic_types.h
new file mode 100644
index 0000000..a8688d5
--- /dev/null
+++ b/protocols/systems/common/include/pv_2way_basic_types.h
@@ -0,0 +1,348 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+* ==============================================================================
+*  Name        : pv_2way_basic_types
+*  Part of     :
+*  Interface   :
+*  Description : Basic / low-level enums and types used by PV2Way engine
+*  Version     : (see RELEASE field in copyright header above)
+*
+* ==============================================================================
+*/
+
+#ifndef PV_2WAY_BASIC_TYPES_H_INCLUDED
+#define PV_2WAY_BASIC_TYPES_H_INCLUDED
+
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+// CONSTANTS
+/** The starting error code for 2way specific errors **/
+const int PV2WayErrorStatusStart = (-10500);
+/** There was an error dispatching muxed data to the downstream node **/
+const int PV2WayDispatchError = PV2WayErrorStatusStart - 1;
+/** The request was rejected by the peer **/
+const int PV2WayErrorRejected = PV2WayErrorStatusStart - 5;
+/** Signals replacement of an existing resource **/
+const int PV2WayErrReplaced = PV2WayErrorStatusStart - 6;
+
+// DATA TYPES
+/**
+ *  TPVTerminalType enum
+ *  TPVTerminalType enumerates the possible 2-way protocols
+ **/
+typedef enum TPVTerminalType
+{
+    PV_323,/* based on H.323 */
+    PV_324M, /* based on H.324m */
+    PV_SIP, /* based on SIP */
+    PV_TERMINAL_TYPE_NONE
+}PV2WayTerminalType;
+
+/**
+ * TPVLoopbackMode Enum
+ *
+ * TPVLoopbackMode emumerates the possible loopback options that can be used with the pv2way SDK
+ **/
+typedef enum TPVLoopbackMode
+{
+    PV_LOOPBACK_NONE,
+    PV_LOOPBACK_COMM, /* Loops back from Comm source to Comm sink */
+    PV_LOOPBACK_ENGINE, /* Loops back media at the engine level, no mux involved */
+    PV_LOOPBACK_MUX /* Loops back at the output of the mux */
+}PV2WayLoopbackMode;
+
+/**
+ * TPVDirection Enum
+ *
+ * TPVDirection emumerates the direction of the track.
+ **/
+typedef enum TPVDirection
+{
+    PV_DIRECTION_NONE = 0,
+    INCOMING = 1,
+    OUTGOING = 2,
+    PV_DIRECTION_BOTH = 3
+}PV2WayDirection;
+
+/**
+Enumeration of high level media types supported by the SDK
+ **/
+typedef enum TPVMediaType_t
+{
+    PV_MEDIA_NONE = 0,
+    PV_CONTROL = 1,
+    PV_AUDIO = 2,
+    PV_VIDEO = 4,
+    PV_DATA = 8,
+    PV_USER_INPUT = 16,
+    PV_MULTIPLEXED = 32,
+    PV_MEDIA_ALL = 0xFFFF
+}PV2WayMediaType;
+
+/**
+ * PVTrackId uniquely identifies a track for transferring audio/video in a particular direction -
+ * receive or transmit.
+ *
+ **/
+typedef unsigned int PVTrackId;
+
+/**
+ * TPV2WayState Class
+ *
+ * An enumeration of the major states of the pv2way engine.
+ **/
+typedef enum
+{
+    /**
+    	The state immediately after the pv2way instance has been successfully created or instantiated.
+    	No resources have been allocated yet.
+    **/
+    EIdle = 0,
+    /**
+    	The pv2way is in this state when it is initializing from the EIdle to the ESetup state.  The terminal queries the
+    	available device capabilities (encode, decode, mux), acquires resources to make a two-way call (codecs, formats, memory etc)
+    	and transitions to the ESetup state when it will be ready to accept setup parameters and Connect.
+    	If initializing fails, the pv2way relinquishes the resources and reverts to the EIdle state.
+    **/
+    EInitializing,
+    /**
+    	The state where the pv2way instance is in the process of receiving setup parameters from the application, for encoding,
+    	multiplexing, capturing and rendering.  Each time a new set of parameters is passed in, validation will take place and a
+    	status will be returned accordingly.  A valid data source and data sink for the communications port are to be added to the
+    	terminal in this state before it can be transitioned to the Econnecting state.  Media sources and sinks can also be added
+    	at this time.
+    **/
+    ESetup,
+    /**
+    	The state where the pv2way instance has received a call to start connecting.  It starts communication with the remote terminal
+    	to exchange media capabilities and channel configuration in preparation for the establishment of media channels.
+    **/
+    EConnecting,
+    /**
+    	The state after all control signaling is completed.  The terminal is now able to open media tracks for audio and video.
+    **/
+    EConnected,
+    /**
+    	The state where the terminal is shutting down all tracks and the multiplex.
+    **/
+    EDisconnecting,
+    /**
+    	The state where the terminal is releasing all resources and transitioning to the EIdle state.
+    **/
+    EResetting
+} PV2WayState;
+
+/**
+ * TPVTIndicationType enum
+ *
+ *  Enumeration of unsolicited indications from pv2way.
+ *
+ **/
+enum TPVTIndicationType
+{
+
+    /**
+     * Indicates that the peer terminal has established an incoming track.  The
+     * local buffer specifies the media type associated with the track.
+     * The first octet of the local buffer indicates the media type.
+     * The second,third and fourth octets are reserved.
+     * The four octets from five to eight are to be interpreted as a unique track id.
+     * The format type and additional capabilities are indicated using the PV2WayTrackInfoInterface extension interface.
+     **/
+    PVT_INDICATION_INCOMING_TRACK,
+    /**
+     * Indicates that the local terminal has established an outgoing track that is
+     * acceptable to the peer.  The local buffer specifies the media type associated with the track.
+     * The first octet of the local buffer indicates the media type.
+     * The second,third and fourth octets are reserved.
+     * The four octets from five to eight are to be interpreted as a unique track id.
+     * The format type and additional capabilities are indicated using the PV2WayTrackInfoInterface extension interface.
+     **/
+    PVT_INDICATION_OUTGOING_TRACK,
+    /**
+     * Indicates that 2way engine has ended the current telephony session.  The app
+     * can now either reset the engine or make a subsequent call.
+     *
+     **/
+    PVT_INDICATION_DISCONNECT,
+    /**
+     * Indicates the start of unsolicited closure of an incoming/outgoing track.  The PVT_INDICATION_CLOSE_TRACK
+     * indication will be sent when the track is completely close.
+     * The first octet of the local buffer indicates the direction of the track.
+     * The second and third octets indicates the track id.
+     **/
+    PVT_INDICATION_CLOSING_TRACK,
+    /**
+     * Indicates an unsolicited closure of an incoming/outgoing track.  Any media sink/source
+     * associated with this will be stopped and returned to the application.
+     * The first octet of the local buffer indicates the media type of the track.
+     * The second octet indicates the direction.
+     * The third octet indicates whether there is a replacement for this track available.  If true,
+     * the application may add data source/sink for this track again.
+     **/
+    PVT_INDICATION_CLOSE_TRACK,
+    /**
+     * Indicates that the remote terminal has paused an incoming track.  Any media sink
+     * associated with this will be stopped.
+     *
+     **/
+
+    PVT_INDICATION_PAUSE_TRACK,
+    /**
+     * Indicates that the remote terminal has resumed an incoming track.  Any media sink
+     * associated with this will be restarted.
+     *
+     **/
+    PVT_INDICATION_RESUME_TRACK,
+    /**
+     * Indicates an internal error in the pv2way engine.  The derived class provides
+     * further information about the actual error.
+     *
+     **/
+    PVT_INDICATION_INTERNAL_ERROR,
+};
+
+
+// CLASS DECLARATION
+
+/**
+* PV2WayInitInfo Class
+*
+* PV2WayInitInfo is an interface required
+* for protocols specific classes pass to the PV2WayInterface's
+* InitL() method
+*
+**/
+class PV2WayInitInfo
+{
+    public:
+        /**
+        *  pure virtual method that must be overridden to return
+        *  the classname of the actual subclass
+         **/
+        virtual void GetInitInfoClassName(OSCL_wString& aClassName) = 0;
+
+        virtual ~PV2WayInitInfo() { }
+
+        /**
+        *  The list of audio formats that can be transmitted
+         **/
+        Oscl_Vector<const char*, OsclMemAllocator> iOutgoingAudioFormats;
+
+        /**
+        *  The list of video formats that can be transmitted
+         **/
+        Oscl_Vector<const char*, OsclMemAllocator> iOutgoingVideoFormats;
+
+        /**
+        *  The list of audio formats that can be received
+         **/
+        Oscl_Vector<const char*, OsclMemAllocator> iIncomingAudioFormats;
+
+        /**
+        *  The list of video formats that can be received
+         **/
+        Oscl_Vector<const char*, OsclMemAllocator> iIncomingVideoFormats;
+
+};
+
+
+/**
+* PV2WayConnectOptions Class
+ *
+* PV2WayConnectOptions class contains options to be specified during connect
+ **/
+class PV2WayConnectOptions
+{
+    public:
+        /**
+         * Default Constructor
+         **/
+        PV2WayConnectOptions()
+                : iLoopbackMode(PV_LOOPBACK_NONE),
+                iLocalId(NULL),
+                iLocalIdSize(0),
+                iRemoteId(NULL),
+                iRemoteIdSize(0) {}
+
+        /**
+         * Constructor
+         * @param aLoopbackMode
+         *         The loopback mode to used during Connect
+         * @param aLocalId, aLocalIdSize
+         *         A unique octet string identifying the local terminal
+         * @param aRemoteId, aRemoteIdSize
+         *         A unique octet string identifying the peer (Used only in 2-Stage dialling)
+         * @returns void
+         *
+         **/
+        PV2WayConnectOptions(TPVLoopbackMode aLoopbackMode,
+                             uint8* aLocalId, uint32 aLocalIdSize,
+                             uint8* aRemoteId, uint32 aRemoteIdSize)
+                : iLoopbackMode(aLoopbackMode),
+                iLocalId(aLocalId),
+                iLocalIdSize(aLocalIdSize),
+                iRemoteId(aRemoteId),
+                iRemoteIdSize(aRemoteIdSize)
+        {}
+
+        /**
+        * Pure virtual method that must be overridden.  Retrieves class name
+        *
+        * @param aClassName
+        *         A reference to an OSCL_wString, which is to hold the subclass
+        *          name
+        * @returns void
+        **/
+        virtual void GetConnectInfoClassName(OSCL_wString &aClassName) = 0;
+
+        /**
+        *  The loopback mode
+        **/
+        TPVLoopbackMode iLoopbackMode;
+
+        /**
+        *  The id of the local terminal
+        **/
+        uint8* iLocalId;
+        /**
+        *  The size of the local id
+        **/
+        uint32 iLocalIdSize;
+
+        /**
+        *  The id of the peer
+        **/
+        uint8* iRemoteId;
+        /**
+        *  The size of the remote id
+        **/
+        uint32 iRemoteIdSize;
+};
+#endif
diff --git a/protocols/systems/common/include/pv_2way_track_info_impl.h b/protocols/systems/common/include/pv_2way_track_info_impl.h
new file mode 100644
index 0000000..8bd0030
--- /dev/null
+++ b/protocols/systems/common/include/pv_2way_track_info_impl.h
@@ -0,0 +1,147 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+* ==============================================================================
+*  Name        : pv_2way_track_info_impl.h
+*  Part of     :
+*  Interface   :
+*  Description : Interface class and supporting definitions for the PV2Way SDK
+*  Version     : (see RELEASE field in copyright header above)
+*
+* ==============================================================================
+*/
+
+#ifndef PV_2WAY_TRACK_INFO_IMPL_H_INCLUDED
+#define PV_2WAY_TRACK_INFO_IMPL_H_INCLUDED
+
+
+#include "pv_2way_basic_interfaces.h"
+
+
+class PV2WayTrackInfoImpl : public PV2WayTrackInfoInterface
+
+{
+
+    private:
+
+        PVMFFormatType iMimeString;
+        uint8* iFormatSpecificInfo;
+        uint32 iFormatSpecificInfoLen;
+        int32 iEventCode;
+        PVUuid iEventUuid;
+        int32 iRefCount;
+
+    public:
+
+        PV2WayTrackInfoImpl(PVMFFormatType aMimeString, uint8* aFormatSpecificInfo, uint32 aFormatSpecificInfoLen, int32 aCode, PVUuid aUuid): iRefCount(1)
+        {
+            iMimeString = aMimeString;
+
+            iFormatSpecificInfo = aFormatSpecificInfo;
+            iFormatSpecificInfoLen = aFormatSpecificInfoLen;
+            iEventCode = aCode;
+            iEventUuid = aUuid;
+        }
+
+        /*
+             Returns the code and space UUID for this info message
+
+        	 @param aCode Reference to an integer which will be filled in with event code
+        	 @param aUuid Reference to a PVUuid which will be filled in with UUID assocated to event code
+
+        	 @return None
+          */
+        virtual void GetCodeUUID(int32& aCode, PVUuid& aUuid)
+        {
+            aCode = iEventCode;
+            aUuid = iEventUuid;
+        }
+
+        /*
+           Returns a reference to the format string.
+
+           @return Reference to the format string
+        */
+
+        virtual void GetFormatString(PVMFFormatType& aMimeString)
+        {
+
+            aMimeString = iMimeString;
+        }
+
+
+        /*    Returns the Format Specific Info associated with this track
+
+            @return A pointer to the Format Specific Info.  NULL if FSI is not present
+         */
+
+        virtual uint8* GetFormatSpecificInfo(uint32& aFormatSpecificInfoLen)
+        {
+            if (aFormatSpecificInfoLen == 0 || iFormatSpecificInfo == NULL)
+            {
+                aFormatSpecificInfoLen = 0;
+                return NULL;
+            }
+            aFormatSpecificInfoLen = iFormatSpecificInfoLen;
+            return iFormatSpecificInfo;
+        }
+
+        // From PVInterface
+
+        /*
+           Increments the reference count for this info message object
+         */
+
+        virtual void addRef()
+        {
+            ++iRefCount;
+        }
+
+        /*
+           Decrements the reference count for this info message object and deletes
+           this object if count goes to 0.
+        */
+
+        virtual void removeRef()
+        {
+            --iRefCount;
+        }
+
+        /*
+             Returns the extension interface for the specified UUID if this info
+             message object supports it. If the requested extension interface is supported
+             true is returned, else false.
+         */
+
+        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            if (uuid == PV2WayTrackInfoInterfaceUUID)
+            {
+                PV2WayTrackInfoInterface* myInterface = OSCL_STATIC_CAST(PV2WayTrackInfoInterface*, this);
+                iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+            }
+            else
+            {
+                return false;
+            }
+
+            return true;
+        }
+};
+
+#endif
diff --git a/protocols/systems/common/include/tsc.h b/protocols/systems/common/include/tsc.h
new file mode 100644
index 0000000..a77e6ad
--- /dev/null
+++ b/protocols/systems/common/include/tsc.h
@@ -0,0 +1,126 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined (TSC_H_INCLUDED)
+#define TSC_H_INCLUDED
+
+#include "pvt_params.h"
+#include "pvt_events.h"
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#define PV_2WAY_TSC_EXTENSIONINTERFACE_UUID PVUuid(0x50e23520,0xf8a3,0x11d9,0xbe,0xab,0x00,0x02,0xa5,0xd5,0xc5,0x1b)
+enum TSCState
+{
+    TSC_Idle = 0,
+    TSC_Connecting,
+    TSC_Communicating,
+    TSC_Disconnected
+};
+
+/** Observer interface for TSC extension interface **/
+class TSCObserver
+{
+    public:
+        virtual ~TSCObserver() {}
+        /* Responses to commands */
+        /* Indicates completion of a previously issued Connect command */
+        virtual void ConnectComplete(PVMFStatus status) = 0;
+
+        /* Unsolicited indications */
+        /* An internal error has occurred.  User should disconnect and teardown */
+        virtual void InternalError() = 0;
+        /* Requests the user to stop av codecs.  Logical channels will be closed by TSC */
+        virtual void DisconnectRequestReceived() = 0;
+        /* Indicates establishment of an outgoing logical channel by the stack */
+        virtual void OutgoingChannelEstablished(TPVChannelId aId,
+                                                PVCodecType_t aCodec,
+                                                uint8* aFormatSpecificInfo = NULL, uint32 aFormatSpecificInfoLen = 0) = 0;
+        /* Indicates establishment of an incoming logical channel by the stack */
+        virtual TPVStatusCode IncomingChannel(TPVChannelId aId,
+                                              PVCodecType_t aCodec,
+                                              uint8* aFormatSpecificInfo = NULL, uint32 aFormatSpecificInfoLen = 0) = 0;
+        /* Indicates closure of a logical channel by the stack */
+        virtual void ChannelClosed(TPVDirection direction,
+                                   TPVChannelId id,
+                                   PVCodecType_t codec,
+                                   PVMFStatus status = PVMFSuccess) = 0;
+        /* Requests the user to generate Intra content for the specified port/logical channel */
+        virtual void RequestFrameUpdate(PVMFPortInterface *port) = 0;
+};
+
+#define MAX_STACK_ELEMENTS 10
+
+/** Abstract extension interface for all 2-way Terminal State Controllers **/
+class TSC : public PVInterface
+{
+    public:
+        virtual ~TSC() {};
+        /* Terminal wide commands */
+        /* Initializes the TSC with reference to mux and controls */
+        virtual TPVStatusCode InitTsc() = 0;
+        virtual TSCObserver* SetTscObserver(TSCObserver* aObserver)
+        {
+            if (!iObserver)
+            {
+                iObserver = aObserver;
+                return iObserver;
+            }
+            return NULL;
+        }
+        //virtual TPVStatusCode SetCapability(CapabilitySet* capabilities) = 0;
+        virtual CPvtTerminalCapability* GetRemoteCapability() = 0;
+        virtual TSCState GetTscState()
+        {
+            return iState;
+        }
+        virtual TPVStatusCode ResetTsc() = 0;
+        virtual TPVStatusCode Connect(uint16 info_len = 0, uint8* info_buf = NULL) = 0;
+        virtual TPVStatusCode SetTimerRes(uint32 timer_res) = 0;
+
+        virtual TPVStatusCode Disconnect() = 0;
+        virtual TPVStatusCode Abort() = 0;
+
+        /* Channel specific commands */
+        virtual TPVStatusCode SetTerminalParam(CPVTerminalParam* params) = 0;
+        virtual CPVTerminalParam* GetTerminalParam() = 0;
+        virtual TPVStatusCode SetOutgoingBitrate(int32 bitrate) = 0;
+        virtual TPVStatusCode RequestFrameUpdate(PVMFPortInterface* port) = 0;
+        /* Returns a pointer to the logical channels buffer.  DO NOT DELETE */
+        virtual const uint8* GetFormatSpecificInfo(PVMFPortInterface* port, uint32* len) = 0;
+
+        virtual void SetLoopbackMode(TPVLoopbackMode aLoopbackMode) = 0;
+        virtual void ResetStats() = 0;
+        virtual void LogStats(TPVDirection dir) = 0;
+        virtual LogicalChannelInfo* GetLogicalChannelInfo(PVMFPortInterface& port) = 0;
+        virtual void SetDatapathLatency(TPVDirection aDir, PVMFPortInterface* aPort, uint32 aLatency) = 0;
+        virtual void SetSkewReference(PVMFPortInterface* aPort, PVMFPortInterface* aReferencePort) = 0;
+
+    protected:
+        TSC() : iState(TSC_Idle), iObserver(NULL)
+        {
+        }
+
+        TSCState iState;
+        TSCObserver* iObserver;
+    private:
+};
+
+#endif
+
diff --git a/protocols/systems/tools/general/Android.mk b/protocols/systems/tools/general/Android.mk
new file mode 100644
index 0000000..356d705
--- /dev/null
+++ b/protocols/systems/tools/general/Android.mk
@@ -0,0 +1,37 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	common/src/crccheck.cpp \
+ 	common/src/layer.cpp \
+ 	common/src/media_fragment.cpp \
+ 	common/src/media_packet.cpp \
+ 	common/src/general_tools.cpp \
+ 	common/src/pvmf_buffer_data_source.cpp \
+ 	common/src/pvmf_buffer_data_sink.cpp \
+ 	common/src/pvmf_file_data_sink.cpp \
+ 	common/src/pvmf_file_data_source.cpp
+
+
+LOCAL_MODULE := libpvgeneraltools
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/protocols/systems/tools/general/common/src \
+ 	$(PV_TOP)/protocols/systems/tools/general/common/include \
+ 	$(PV_TOP)/protocols/systems/common/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/protocols/systems/tools/general/build/make/local.mk b/protocols/systems/tools/general/build/make/local.mk
new file mode 100644
index 0000000..a49cbd9
--- /dev/null
+++ b/protocols/systems/tools/general/build/make/local.mk
@@ -0,0 +1,33 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvgeneraltools
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../../../common/include
+
+
+
+
+SRCDIR := ../../common/src
+INCSRCDIR := ../../common/include
+
+SRCS := crccheck.cpp \
+	layer.cpp \
+	media_fragment.cpp \
+	media_packet.cpp \
+	general_tools.cpp \
+	pvmf_buffer_data_source.cpp \
+	pvmf_buffer_data_sink.cpp \
+	pvmf_file_data_sink.cpp \
+	pvmf_file_data_source.cpp
+
+HDRS := 
+
+include $(MK)/library.mk
diff --git a/protocols/systems/tools/general/common/include/control_msg_hdr.h b/protocols/systems/tools/general/common/include/control_msg_hdr.h
new file mode 100644
index 0000000..717a4b0
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/control_msg_hdr.h
@@ -0,0 +1,53 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef CONTROL_MSG_HDR_H
+#define CONTROL_MSG_HDR_H
+
+#include "oscl_base.h"
+
+/************************************************************************/
+/*  Interface Information Structure Type Definitions                    */
+/************************************************************************/
+typedef struct _control_msg_header
+{
+    enum TDirection
+    {
+        INCOMING = 1,
+        OUTGOING = 2
+    };
+
+    uint32    InfType ;               /* Information Type */
+    uint32    InfId ;                 /* Information Id */
+    /* User Operation Id */
+    /* Primitive Id */
+    /* Internal Error Occurence Routine */
+    /* Timeout Id */
+    uint32    InfSupplement1 ;        /* Information Supplement 1 */
+    uint32    InfSupplement2 ;        /* Information Supplement 2 */
+    uint8*    pParameter ;            /* Primitive Information Pointer ( cf.infptv.h ) */
+    uint32    Size ;                  /* Information Parameter Size */
+    TDirection Dir;                 /* Incoming/Outgoing SE */
+
+    uint8*    EncodedMsg;           /* Per encoded version of this message */
+    uint32    EncodedMsgSize;
+
+} S_ControlMsgHeader ;
+typedef S_ControlMsgHeader *PS_ControlMsgHeader ;
+
+
+#endif
diff --git a/protocols/systems/tools/general/common/include/crccheck_cpp.h b/protocols/systems/tools/general/common/include/crccheck_cpp.h
new file mode 100644
index 0000000..8543c0c
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/crccheck_cpp.h
@@ -0,0 +1,52 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+ * File:	crccheck_cpp.h
+ * Author:	RussellHayashida (rhayashida@packetvideo.com)
+ * Date:	February 13, 2002
+ * Comment:	crc check function declarations
+ */
+
+#ifndef _CRCCHECK_CPP_H
+#define _CRCCHECK_CPP_H
+
+#include "oscl_base.h"
+#include "media_packet.h"
+#include "pvmf_media_data_impl.h"
+#define	NO_ERR	    0
+#define	CRC_ERR	    1
+#define	SN_ERR	    2
+
+class CRC
+{
+    public:
+        OSCL_IMPORT_REF CRC();
+        ~CRC() {};
+        OSCL_IMPORT_REF uint8 Crc8Check(uint8 *pData, int16 Size);
+        OSCL_IMPORT_REF uint8 Crc8Check(Packet *pPkt);
+        OSCL_IMPORT_REF uint8 Crc8Check(OsclSharedPtr<PVMFMediaDataImpl>& mediaData, bool hasCRC = false);
+
+        OSCL_IMPORT_REF uint16 Crc16Check(uint8 *pData, int16 Size);
+        OSCL_IMPORT_REF uint16 Crc16Check(Packet *pPkt);
+        OSCL_IMPORT_REF uint16 Crc16Check(OsclSharedPtr<PVMFMediaDataImpl>& mediaData, bool hasCRC = false);
+
+        uint16	CrcTbl8[256];
+        uint16	CrcTbl16[256];
+};
+
+#endif	/* _CRCCHECK_H */
diff --git a/protocols/systems/tools/general/common/include/layer.h b/protocols/systems/tools/general/common/include/layer.h
new file mode 100644
index 0000000..4eed371
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/layer.h
@@ -0,0 +1,73 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/************************************************************************/
+/*  file name       : layer.h                                           */
+/*  file contents   :											        */
+/*  draw            :                                                   */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*      Copyright (C) 2002 PacketVideo                                  */
+/************************************************************************/
+
+#if !defined(LAYER_H)
+#define LAYER_H
+
+#include "packet_io.h"
+
+/* The Layer interface represents an upper or lower layer of an element in the stack.
+It aggregates one PacketInput and one PacketOutput
+*/
+class Layer
+{
+    public:
+        enum
+        {
+            PACKET_INPUT = 0,
+            PACKET_OUTPUT
+        }TLayerNode;
+        virtual ~Layer() {}
+        OSCL_IMPORT_REF virtual PacketInput* GetPacketInput() = 0;
+        OSCL_IMPORT_REF virtual PacketOutput* GetPacketOutput() = 0;
+        OSCL_IMPORT_REF OsclAny SetBoundLayer(Layer* layer)
+        {
+            bound_layer = layer;
+        }
+        OSCL_IMPORT_REF virtual OsclAny Bind(Layer* layer);
+        OSCL_IMPORT_REF virtual OsclAny UnBind();
+        OSCL_IMPORT_REF virtual bool IsBound();
+    protected:
+        OSCL_IMPORT_REF Layer();
+        Layer* GetBoundLayer();
+        Layer* bound_layer;
+};
+
+/*
+A SimpleStackElement has one upper layer and one lower layer
+*/
+class SimpleStackElement
+{
+    public:
+        virtual ~SimpleStackElement() {}
+        OSCL_IMPORT_REF virtual Layer* GetUpperLayer() = 0;
+        OSCL_IMPORT_REF virtual Layer* GetLowerLayer() = 0;
+        /*OSCL_IMPORT_REF virtual int Start(){ return 0;}
+        OSCL_IMPORT_REF virtual int Stop(){ return 0;}*/
+
+};
+
+#endif /* LAYER_H */
diff --git a/protocols/systems/tools/general/common/include/media_fragment.h b/protocols/systems/tools/general/common/include/media_fragment.h
new file mode 100644
index 0000000..fb8fd7f
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/media_fragment.h
@@ -0,0 +1,246 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/************************************************************************/
+/*  file name       : media_fragment.h                                           */
+/*  file contents   : media fragment class & utilities       */
+/*  draw            : '96.10.29                                         */
+/*----------------------------------------------------------------------*/
+/*  amendment       :                                                   */
+/*      Copyright (C) 2002 PacketVideo                                   */
+/************************************************************************/
+
+#ifndef MEDIA_FRAGMENT_H
+#define MEDIA_FRAGMENT_H
+
+#include "oscl_mem.h"
+#include "oscl_media_data.h"
+
+class DefaultBufferMgr : public BufferMgr
+{
+    public:
+        DefaultBufferMgr()
+        {
+
+        }
+        virtual ~DefaultBufferMgr()
+        {
+
+        }
+        OsclAny BufferReleased(OsclAny* ptr, BufferState* state = NULL)
+        {
+            OSCL_DEFAULT_FREE(ptr);
+            if (state)
+                OSCL_DELETE(state);
+        }
+};
+
+
+/* the memory pool manager should allocate this.  The free function pointer iin the
+buffer_state should point to a routine that returns it to the pool */
+
+class MediaFragment
+{
+    public:
+        MediaFragment(): _state(NULL)
+        {
+            _fragment.ptr = NULL;
+            _fragment.len = 0;
+        }
+        OSCL_IMPORT_REF MediaFragment(const MediaFragment& that, OsclAny* ptr = NULL, int32 len = 0);
+
+        virtual ~MediaFragment()
+        {
+            if (_state)
+                _state->decrement_refcnt();
+        }
+        inline uint8* GetPtr()
+        {
+            return (uint8*)_fragment.ptr;
+        }
+        inline int32 GetLen()
+        {
+            return _fragment.len;
+        }
+
+        OsclAny Trim(uint8* ptr, int32 len)
+        {
+//		if( (ptr >= _fragment.ptr && ptr < ((uint8*)_fragment.ptr+_fragment.len)) &&
+//			(((uint8*)ptr +len) <= ((uint8*)_fragment.ptr+_fragment.len)) ){
+            _fragment.ptr = ptr;
+            _fragment.len = len;
+//		}
+        }
+
+        virtual BufferFragment* GetFragment()
+        {
+            return &_fragment;
+        }
+        virtual BufferState* GetState()
+        {
+            return _state;
+        }
+
+    protected:
+        BufferFragment _fragment;
+        BufferState* _state;
+    private:
+        MediaFragment(BufferFragment& frag, BufferState* state):
+                _fragment(frag), _state(state)
+        {
+            if (state)
+                _state->increment_refcnt();
+        }
+
+        OsclAny Set(BufferFragment& frag, BufferState* state)
+        {
+            BufferState* old_state = _state;
+            _state = state;
+
+            if (_state)
+            {
+                _state->increment_refcnt();
+            }
+            _fragment = frag;
+            if (old_state)
+            {
+                old_state->decrement_refcnt();
+            }
+        }
+
+        OsclAny Set(OsclAny* ptr, int32 len, BufferState* state)
+        {
+            BufferState* old_state = _state;
+            _state = state;
+
+            if (_state)
+            {
+                _state->increment_refcnt();
+            }
+            _fragment.len = len;
+            _fragment.ptr = ptr;
+
+            if (old_state)
+            {
+                old_state->decrement_refcnt();
+            }
+        }
+
+        friend class DefFragmentAllocator;
+        friend class PoolFragmentAllocator;
+        friend class MediaPacket;
+
+        friend class AudioEncodeFragmentAllocator;
+        friend class VideoEncodeFragmentAllocator;
+};
+
+typedef int32 FragmentType;
+const FragmentType FRAG_TYPE_DEFAULT = 0;
+
+/* Default media fragment and allocator. */
+class FragmentAllocator
+{
+    public:
+        virtual ~FragmentAllocator() {}
+        OSCL_IMPORT_REF virtual MediaFragment* allocate_fragment(uint32 sz) = 0;
+        OSCL_IMPORT_REF virtual MediaFragment* allocate_fragment(MediaFragment* fragment,
+                OsclAny* ptr = NULL, uint32 len = 0) = 0;
+        OSCL_IMPORT_REF virtual int32 deallocate_fragment(MediaFragment* fragment) = 0;
+};
+
+class DefFragmentAllocator :  public FragmentAllocator
+{
+    public:
+        DefFragmentAllocator()
+        {
+
+        }
+        ~DefFragmentAllocator()
+        {
+
+        }
+        OSCL_IMPORT_REF virtual MediaFragment* allocate_fragment(uint32 sz);
+        OSCL_IMPORT_REF virtual MediaFragment* allocate_fragment(MediaFragment* fragment,
+                OsclAny* ptr = NULL, uint32 len = 0);
+        OSCL_IMPORT_REF virtual int32 deallocate_fragment(MediaFragment* fragment);
+    private:
+        DefaultBufferMgr buffer_state_listener;
+};
+
+
+/* Media fragment pool and allocator. */
+
+class BufferStateEntry
+{
+    public:
+        BufferStateEntry() : next_entry(NULL)
+        {
+            frag.ptr = NULL;
+            frag.len = 0;
+        };
+        ~BufferStateEntry() {};
+        BufferState buf_state;
+        BufferFragment frag;
+        MediaFragment media_frag;
+        BufferStateEntry *next_entry;
+};
+
+class PoolFragmentAllocator;
+
+class BufferPoolMgr : public BufferMgr
+{
+    public:
+        BufferPoolMgr(PoolFragmentAllocator *pPool)
+        {
+            pBufferPool = pPool;
+        }
+        virtual ~BufferPoolMgr() {};
+        OSCL_IMPORT_REF OsclAny BufferReleased(OsclAny* ptr, BufferState* state = NULL);
+    private:
+        PoolFragmentAllocator *pBufferPool;
+};
+
+
+class PoolFragmentAllocator :  public FragmentAllocator
+{
+    public:
+        OSCL_IMPORT_REF PoolFragmentAllocator(int32 max_frags, int32 max_frag_size);
+        OSCL_IMPORT_REF ~PoolFragmentAllocator();
+
+        OSCL_IMPORT_REF virtual MediaFragment* allocate_fragment(uint32 sz);
+        OSCL_IMPORT_REF virtual MediaFragment* allocate_fragment(MediaFragment* fragment,
+                OsclAny* ptr = NULL, uint32 len = 0);
+        OSCL_IMPORT_REF virtual int32 deallocate_fragment(MediaFragment* fragment);
+
+        OsclAny free_buffer_to_pool(BufferStateEntry *entry);
+    private:
+
+        int32 num_frags;
+        int32 frag_size;
+        BufferPoolMgr *buffer_state_listener;
+        BufferStateEntry *free_list;
+        BufferStateEntry *entire_list;
+        uint8 *buffer;
+};
+
+
+#if 0
+
+
+#endif //0
+
+#endif /* MEDIA_FRAGMENT_H */
diff --git a/protocols/systems/tools/general/common/include/media_packet.h b/protocols/systems/tools/general/common/include/media_packet.h
new file mode 100644
index 0000000..9388427
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/media_packet.h
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+#ifndef MEDIA_PACKET_H
+#define MEDIA_PACKET_H
+
+#include "oscl_media_data.h"
+#include "oscl_media_status.h"
+#include "oscl_time.h"
+
+#include "media_fragment.h"
+#include "packet.h"
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+// Constants controlling the size of the RTP packet container
+
+class MediaPacket : public Packet
+{
+    public:
+        virtual ~MediaPacket() {};
+
+        OSCL_IMPORT_REF BufFragStatusClass::status_t AddMediaFragment(MediaFragment* fragment, int32 location_offset = APPEND_MEDIA_AT_END);
+
+        OSCL_IMPORT_REF MediaFragment* GetMediaFragment(int32 idx, MediaFragment& fragment);
+
+        OSCL_IMPORT_REF void Reset();
+        OSCL_IMPORT_REF void SetTimeval(TimeValue& val)
+        {
+            time_val = val;
+        }
+        OSCL_IMPORT_REF TimeValue* GetTimeval()
+        {
+            return &time_val;
+        }
+
+        uint8* cur_pos;
+        uint8* end_pos;
+        int cur_frag_num;
+
+    protected:
+        MediaPacket() : cur_pos(NULL), end_pos(NULL), cur_frag_num(0)/*, next(NULL)*/ {};
+    private:
+//	MediaPacket *next;
+        TimeValue time_val;
+        friend class MediaPacketAllocator;
+        friend class MediaPacketPoolAllocator;
+};
+
+class MediaPacketAllocator
+{
+    public:
+        MediaPacketAllocator() {};
+
+        virtual ~MediaPacketAllocator()
+        {
+            //printf("here\n");
+        }
+        /* This should change to allocate memory from a memory pool */
+        OSCL_IMPORT_REF virtual MediaPacket* allocate_packet(EPacketType type = EPacketDefault);
+        /* Change to return to pool */
+        OSCL_IMPORT_REF virtual void deallocate_packet(MediaPacket* pack);
+};
+
+class MediaPacketPoolAllocator : public MediaPacketAllocator
+{
+    public:
+        OSCL_IMPORT_REF MediaPacketPoolAllocator(int packets);
+        virtual ~MediaPacketPoolAllocator();
+
+        OSCL_IMPORT_REF MediaPacket *allocate_packet(EPacketType type = EPacketDefault);
+
+        OSCL_IMPORT_REF void deallocate_packet(MediaPacket *pack);
+
+    private:
+        int num_packets;
+        MediaPacket *free_list;
+        MediaPacket *entire_list;
+};
+
+OSCL_IMPORT_REF PVMFSharedMediaMsgPtr MediaPacketToPVMFMediaMsg(MediaPacket* packet, PVMFSimpleMediaBufferCombinedAlloc& alloc);
+OSCL_IMPORT_REF MediaPacket* PVMFMediaMsgToMediaPacket(PVMFSharedMediaMsgPtr aMsg,
+        MediaPacketAllocator& aMediaPacketAlloc, FragmentAllocator& aFragmentAlloc);
+#endif
diff --git a/protocols/systems/tools/general/common/include/packet.h b/protocols/systems/tools/general/common/include/packet.h
new file mode 100644
index 0000000..2ea2b01
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/packet.h
@@ -0,0 +1,118 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+#ifndef PACKET_H
+#define PACKET_H
+
+#include "oscl_media_data.h"
+#include "oscl_media_status.h"
+
+#include "media_fragment.h"
+
+const int DEF_PACKET_MAX_FRAGMENTS = 128;
+const int DEF_PACKET_IMMEDIATE_DATA = 128;
+const int DEF_MAX_PACKET_SIZE = 1024;
+
+/* A packet represents a message.  It contains a list of MediaFragments.
+   Packets can be chained. */
+class Packet : public MediaData<Packet, DEF_PACKET_MAX_FRAGMENTS, DEF_PACKET_IMMEDIATE_DATA>
+{
+    public:
+        Packet(): flat_ptr(NULL)
+        {
+        }
+
+        virtual ~Packet()
+        {
+            if (flat_ptr) OSCL_DEFAULT_FREE(flat_ptr);
+            flat_ptr = NULL;
+            Clear();
+        }
+
+        BufFragStatusClass::status_t AddBufferFragment(BufferFragment& frag, BufferState* state)
+        {
+            return AddFragment(frag, state);
+        }
+
+        virtual uint8* AddHeader(MediaFragment* mfrag)
+        {
+            AddFragment(*mfrag->GetFragment(), mfrag->GetState(), 0);
+            return mfrag->GetPtr();
+        }
+
+        virtual uint8* AddTrailer(MediaFragment* mfrag)
+        {
+            AddFragment(*mfrag->GetFragment(), mfrag->GetState(), APPEND_MEDIA_AT_END);
+            return mfrag->GetPtr();
+        }
+
+        /*  virtual BufFragStatus AddFragment(MediaFragment* fragment, int32 location_offset = APPEND_MEDIA_AT_END) = 0;
+          virtual void Clear() = 0;
+          virtual BufferFragment* GetFragments() = 0;
+          virtual MediaFragment* GetFragment(int32 idx, MediaFragment& fragment) = 0;
+          virtual int GetAvailableBufferSize() = 0;
+          virtual int32 GetNumFrags() const = 0;
+          virtual int32 GetMaxFrags() const = 0;
+          virtual uint32 GetLength() const = 0;
+          virtual int GetMediaSize() const = 0;
+          virtual void AppendNext(Packet *next_ptr) = 0;
+          virtual Packet*  GetNext() const = 0;*/
+        /* constructs a flat buffer containing the media data.  It gets deleted when the Packet is destroyed
+           Shall be removed in later versions */
+
+        virtual uint8* GetDataPtr()
+        {
+            BufferFragment* frag = NULL;
+            if (GetMediaSize() <= 0) return NULL;
+            frag = GetFragment(0);
+            return ((uint8 *) frag->ptr);
+        }
+
+        virtual uint8* GetMediaPtr()
+        {
+            uint8* buf = NULL;
+            BufferFragment* frag = NULL;
+
+            if (GetMediaSize() <= 0) return NULL;
+            if (flat_ptr) return flat_ptr;
+            buf = flat_ptr = (uint8*)OSCL_DEFAULT_MALLOC(GetMediaSize());
+            for (int frag_num = 0; frag_num < GetNumFrags(); frag_num++)
+            {
+                frag = GetFragment(frag_num);
+                oscl_memcpy(buf, frag->ptr, frag->len);
+                buf += frag->len;
+            }
+            return flat_ptr;
+        }
+
+        virtual void ClearMediaPtr()
+        {
+            if (flat_ptr) OSCL_DEFAULT_FREE(flat_ptr);
+            flat_ptr = NULL;
+        }
+    private:
+        uint8* flat_ptr;
+};
+
+
+typedef enum PacketTypes
+{
+    EPacketDefault
+}EPacketType;
+
+#endif
diff --git a/protocols/systems/tools/general/common/include/packet_io.h b/protocols/systems/tools/general/common/include/packet_io.h
new file mode 100644
index 0000000..582aa5f
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/packet_io.h
@@ -0,0 +1,78 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+#ifndef PACKET_IO_H
+#define PACKET_IO_H
+
+#include "packet.h"
+
+typedef enum
+{
+    PACKET_IO_SUCCESS = 0,
+    PACKET_IO_FAILURE
+}TPvPacketIoStatus;
+
+class PacketInputObserver
+{
+    public:
+        virtual ~PacketInputObserver() {}
+        virtual void PacketInComplete(TPvPacketIoStatus status) = 0;
+};
+
+/* A PacketInput interface is implemented to receive packets.  */
+class PacketInput
+{
+    public:
+        PacketInput() : iPacketInputObserver(NULL)
+        {
+
+        }
+        virtual void PacketIn(Packet* pack) = 0;
+        virtual void PacketIn(Packet* pack, bool /*crc_error*/, int32 /*seq_num_error*/)
+        {
+            PacketIn(pack);
+        }
+        virtual ~PacketInput() {}
+        virtual void SetPacketInputObserver(PacketInputObserver* observer)
+        {
+            iPacketInputObserver = observer;
+        }
+    protected:
+        PacketInputObserver* iPacketInputObserver;
+};
+
+/* PacketOutput interface is implemented to indicate packets via the PacketInput interface */
+class PacketOutput
+{
+    public:
+        PacketOutput() : pPktOutput(NULL)
+        {
+        }
+        void SetPacketOutput(PacketInput* packet_output)
+        {
+            pPktOutput = packet_output;
+        }
+        void ResetPacketOutput(void)
+        {
+            pPktOutput = NULL;
+        }
+    protected:
+        PacketInput* pPktOutput;
+};
+
+#endif
diff --git a/protocols/systems/tools/general/common/include/pv_paragon_bp_rx_header.h b/protocols/systems/tools/general/common/include/pv_paragon_bp_rx_header.h
new file mode 100644
index 0000000..30666bf
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pv_paragon_bp_rx_header.h
@@ -0,0 +1,59 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef __PV_PARAGON_BP_RX_HEADER_H
+#define __PV_PARAGON_BP_RX_HEADER_H
+
+
+#include "oscl_base.h"
+
+#define PARAGON_BP_INFO_FIELD_TX_QUEUE_SIZE_BIT 0x01
+#define PARAGON_BP_TX_QUEUE_SIZE_FIELD 2
+
+#define PARAGON_BP_PAYLOAD_SIZE_FIELD 2
+
+typedef struct
+{
+    uint8 seqNum;
+    uint8 infoField;
+} Paragon_BP_Rx_Base_Hdr;
+
+typedef struct
+{
+    uint8 seqNum;
+    uint8 infoField;
+    uint16 payloadSize;
+    uint8 payload[2];  //Use address of this to access payload data (align structure to 16 bit boudaries).
+} Paragon_BP_Rx_Normal_Hdr;
+
+typedef struct
+{
+    uint8 seqNum;
+    uint8 infoField;
+    uint16 txQueueSize;
+    uint16 payloadSize;
+    uint8 payload[2];  //Use address of this to access payload data (align structure to 16 bit boudaries).
+} Paragon_BP_Rx_Hdr_Opt_Tx_Q_Size;
+
+
+#define PARAGON_BP_RX_BASE_HDR_SIZE sizeof(Paragon_BP_Rx_Base_Hdr)
+//Always subtract payload from size
+#define PARAGON_BP_RX_NORMAL_HDR_SIZE (sizeof(Paragon_BP_Rx_Normal_Hdr) - sizeof(uint16))
+#define PARAGON_BP_RX_OPT_TX_Q_SIZE_HDR_SIZE (sizeof(Paragon_BP_Rx_Hdr_Opt_Tx_Q_Size) - sizeof(uint16))
+
+#endif // __PV_PARAGON_BP_RX_HEADER_H
diff --git a/protocols/systems/tools/general/common/include/pv_paragon_bp_tx_header.h b/protocols/systems/tools/general/common/include/pv_paragon_bp_tx_header.h
new file mode 100644
index 0000000..efd3529
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pv_paragon_bp_tx_header.h
@@ -0,0 +1,59 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef __PV_PARAGON_BP_TX_HEADER_H
+#define __PV_PARAGON_BP_TX_HEADER_H
+
+
+#include "oscl_base.h"
+
+#define PARAGON_BP_INFO_FIELD_TX_SYNC_FLAG_BIT 0x01
+#define PARAGON_BP_TX_SYNC_FLAG_SIZE_FIELD 1
+
+#define PARAGON_BP_TX_PAYLOAD_SIZE_FIELD 2
+#define PARAGON_BP_TX_MAX_SYNC_FLAG_SIZE 8
+
+typedef struct
+{
+    uint8 seqNum;
+    uint8 infoField;
+    uint8 payload[2];  // To align the struct to 32 bit boundaries
+} Paragon_BP_Tx_Base_Hdr;
+
+typedef struct
+{
+    uint8 seqNum;
+    uint8 infoField;
+    uint16 payloadSize;
+    uint8 payload[4];  //Use this address to access payload data (also aligns structure to 32 bit boudaries).
+} Paragon_BP_Tx_Normal_Hdr;
+
+typedef struct
+{
+    uint8 seqNum;
+    uint8 infoField;
+    uint8 syncFlagSize;
+    uint8 syncFlag[1];
+} Paragon_BP_Tx_Hdr_Opt_Sync_Flag;
+
+
+#define PARAGON_BP_TX_BASE_HDR_SIZE (sizeof(Paragon_BP_Tx_Base_Hdr)-(2*sizeof(uint8)))
+//Always subtract payload from size
+#define PARAGON_BP_TX_NORMAL_HDR_SIZE (sizeof(Paragon_BP_Rx_Normal_Hdr) - (4*sizeof(uint8)))
+
+#endif // __PV_PARAGON_BP_RX_HEADER_H
diff --git a/protocols/systems/tools/general/common/include/pvcommon.h b/protocols/systems/tools/general/common/include/pvcommon.h
new file mode 100644
index 0000000..e13d148
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvcommon.h
@@ -0,0 +1,232 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#ifndef __PVCOMMON_H__
+#define __PVCOMMON_H__
+
+#include <e32base.h>
+
+enum TPVURNType
+{
+    EURNTypeError,
+    EUrlFile,
+    ELocalFile,
+    EPvxFile
+};
+
+enum TPVClipSource
+{
+    EClipSourceError	= 0x000,
+    ELocal				= 0x001,
+    EStreaming			= 0x002,
+    EDownload			= 0x004,
+};
+
+enum TPVCodecType
+{
+    ENoCodec		= 0x0000,
+    EAacDec			= 0x0001,
+    EGsmamrDec		= 0x0002,
+    EEvrcDec		= 0x0004,
+    ELastAudioCodec	= 0x00FF,
+
+    EM4vDec			= 0x0100,
+    EH263Dec		= 0x0200
+};
+
+enum TPVClipType
+{
+    EInvalidType,
+    EAudioOnly,
+    EVideoOnly,
+    EAudioVideo,
+    EStillVideo,
+    EAudioStillVideo
+};
+
+enum TPVEndOfClipAction
+{
+    ENoAction	= 0,
+    ECloseApp,
+    ENextUrl
+};
+
+enum TPVPlaybackControl		// For Download only
+{
+    ENoPlayback		= 0,
+    EAfterDownload,
+    EAsap,
+    EReserve
+};
+
+enum TPVPlayerEngineState
+{
+    EIdle,
+    EClipSelected,
+    ESelectingTrack,
+    EInitializingPlay,
+    EPlaying,
+    EBuffering,
+    EStopped,
+    EPaused,
+    EDownloading,
+    EDownloadingPlaying,
+    EDownloadSuspended,
+    EUnknownEngineState
+};
+
+enum TPVStatusCode
+{
+    EPVError = 0,	// API return value only
+    EPVSuccess,		// API return value only
+
+    EOpenURNSuccess,
+    EOpenURNFailure,
+
+    EPlaySuccess,
+    EPlayFailure,
+
+    EStopSuccess,
+    EStopEndOfClip,
+    EStopTimeReached,
+    EStopFailure,
+
+    EPauseSuccess,
+    EPauseFailure,
+
+    EInvalidStartTime,
+    EInvalidStopTime,
+    EInvalidFilename,
+
+    ERepositionNotAllowed,
+    EAudioOnlyNotAllowed,
+    EVideoOnlyNotAllowed,
+
+    EUnsupportedCodec,
+    EVideoDimensionTooLarge,
+
+    EDownloadSuccess,
+    EDownloadFailure,
+    EDownloadNotEnoughMemorySpace,
+
+    EResumeDownloadSuccess,
+    EResumeDownloadFailure,
+
+    EStopDownloadSuccess,
+    EStopDownloadFailure,
+
+    EAudioError,
+    EVideoError,
+    EDownloadError,
+
+    EInvalidURL,
+    EConnectionError,
+    EServerError,
+    EServerErrorMessage,
+
+    EDownloadStatus,	// 0-100 for download status
+    EPlayStatus,		// 0-100 for play status, -1 for buffering/waiting mode
+    EStreamBuffering,	// 0-100 how much of buffer filled (100 for buffer==preroll buffer time)
+    ERepositionBuffering, // how much more time in ms till start time
+
+    EVideoWidth,
+    EVideoHeight,
+    EDisplayVideoFrame,
+
+    EMemoryAllocationError,
+    ELastEventId
+};
+
+
+//
+// Defines
+//
+#define MAX_URL_LEN			256
+#define MAX_FILENAME_LEN	256
+#define MAX_TITLE_LEN		256
+#define MAX_AUTHOR_LEN		256
+#define MAX_COPYRIGHT_LEN	256
+#define MAX_RATING_LEN		256
+#define MAX_DESCRIPTION_LEN	256
+#define MAX_VERSION_LEN		256
+#define MAX_OWNER_LEN		256
+#define MAX_DATE_LEN		256
+
+#define MAX_VERSIONSTRING_LEN		12
+#define MAX_OBSERVERPARAM2_LEN		100
+
+
+//
+// Structures
+//
+struct TPVAppParams
+{
+public:
+    TBool iSecured;
+    TBool iUserPlaybackAllowed;
+    TBool iRepositioningAllowed;
+    TPVPlaybackControl iControl;
+    TPVEndOfClipAction iAction;
+    TBufC<MAX_URL_LEN> iNextUrl;
+};
+
+struct TPVClipInfo
+{
+public:
+    TBool iLive;
+    TBool iRepositioningAllowed;
+    TBool iAllowAudioOnly;					// NOT USED CURRENTLY
+    TBool iAllowVideoOnly;
+    TPVClipType iType;						// Clip type
+    TInt iWidth;							// Width of video
+    TInt iHeight;							// Height of video
+    TInt iDuration;							// Length of clip in milliseconds
+    TInt iSize;								// Download file size in bytes
+    TBufC<MAX_TITLE_LEN> iTitle;
+    TBufC<MAX_AUTHOR_LEN> iAuthor;
+    TBufC<MAX_COPYRIGHT_LEN> iCopyright;
+    TBufC<MAX_RATING_LEN> iRating;
+    TBufC<MAX_DESCRIPTION_LEN> iDescription;
+    TBufC<MAX_OWNER_LEN> iOwner;
+    TBufC<MAX_VERSION_LEN> iVersion;
+    TBufC<MAX_DATE_LEN> iCreationDate;
+};
+
+struct TPVDownloadInfo
+{
+public:
+    TBool iDownloadComplete;
+    TInt iInterruptedTime;
+    TBufC<MAX_FILENAME_LEN> iFilename;
+};
+
+
+// PVEngine event observer - for communicating events back to UI
+class MPVEngineObserver
+{
+    public:
+        IMPORT_C virtual void HandlePVEngineEvent(TPVStatusCode aEventId,
+                TInt aParam1,
+                const TDesC& aParam2) = 0;
+        IMPORT_C virtual void HandlePVVideoEvent(const unsigned char* aData,
+                TInt aSize) = 0;
+};
+
+#endif // __PVCOMMON_H__
+
+
diff --git a/protocols/systems/tools/general/common/include/pvmf_buffer_data_sink.h b/protocols/systems/tools/general/common/include/pvmf_buffer_data_sink.h
new file mode 100644
index 0000000..0f9d57f
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvmf_buffer_data_sink.h
@@ -0,0 +1,88 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_BUFFER_DATA_SINK_H_INCLUDED
+#define PVMF_BUFFER_DATA_SINK_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+
+class PVMFBufferDataSink : public PvmfPortBaseImpl,
+            public PVMFPortActivityHandler,
+            public PvmiCapabilityAndConfig
+{
+    public:
+        OSCL_IMPORT_REF PVMFBufferDataSink(int32 aPortTag);
+        OSCL_IMPORT_REF virtual ~PVMFBufferDataSink();
+
+        void HandlePortActivity(const PVMFPortActivity &);
+
+        OSCL_IMPORT_REF unsigned GetNumBytesReceived();
+        OSCL_IMPORT_REF unsigned GetNumPktsReceived();
+        OSCL_IMPORT_REF unsigned GetNumPktErrorsReceived();
+
+        // PVMFPortInterface virtuals
+        virtual PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg);
+        PVMFStatus GetData(PVMFSharedMediaMsgPtr aMsg);
+
+        OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+    protected:
+        PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc;
+        unsigned iNumBytesReceived;
+        unsigned iNumPktsReceived;
+        unsigned iNumPktErrorsReceived;
+};
+#endif
diff --git a/protocols/systems/tools/general/common/include/pvmf_buffer_data_source.h b/protocols/systems/tools/general/common/include/pvmf_buffer_data_source.h
new file mode 100644
index 0000000..2d72d37
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvmf_buffer_data_source.h
@@ -0,0 +1,106 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_BUFFER_DATA_SOURCE_H_INCLUDED
+#define PVMF_BUFFER_DATA_SOURCE_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef OSCL_TIMER_H_INCLUDED
+#include "oscl_timer.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+class PVMFBufferDataSource : public PvmfPortBaseImpl,
+            public OsclTimerObserver,
+            public PVMFPortActivityHandler,
+            public PvmiCapabilityAndConfig
+{
+    public:
+        OSCL_IMPORT_REF PVMFBufferDataSource(int32 aPortTag,
+                                             unsigned bitrate,
+                                             unsigned min_sample_sz,
+                                             unsigned max_sample_sz,
+                                             uint8*   fsi = NULL,
+                                             unsigned fsi_len = 0);
+        OSCL_IMPORT_REF virtual ~PVMFBufferDataSource();
+
+        void HandlePortActivity(const PVMFPortActivity &);
+
+        // Start/stop the source
+        OSCL_IMPORT_REF void Start();
+        OSCL_IMPORT_REF void Stop();
+
+        // PVMFPortInterface virtuals
+        PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg);
+        PVMFStatus GetData(PVMFSharedMediaMsgPtr aMsg);
+
+        // timer observer
+        virtual void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+        OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr);
+
+        // Implement pure virtuals from PvmiCapabilityAndConfig interface
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
+    protected:
+        unsigned iBitrate;
+        unsigned iMinSampleSz;
+        unsigned iMaxSampleSz;
+        OsclTimer<OsclMemAllocator> iTimer;
+        unsigned iSampleInterval;
+        PVMFTimestamp iTimestamp;
+        PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc;
+        OsclMemAllocator iMemAlloc;
+        uint8* iFsi;
+        unsigned iFsiLen;
+};
+#endif
diff --git a/protocols/systems/tools/general/common/include/pvmf_file_data_sink.h b/protocols/systems/tools/general/common/include/pvmf_file_data_sink.h
new file mode 100644
index 0000000..57ba48f
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvmf_file_data_sink.h
@@ -0,0 +1,71 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_FILE_DATA_SINK_H_INCLUDED
+#define PVMF_FILE_DATA_SINK_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#ifndef PVMF_BUFFER_DATA_SINK_H_INCLUDED
+#include "pvmf_buffer_data_sink.h"
+#endif
+
+class PVMFFileDataSink : public PVMFBufferDataSink
+{
+    public:
+        OSCL_IMPORT_REF PVMFFileDataSink(int32 aPortTag);
+        OSCL_IMPORT_REF virtual ~PVMFFileDataSink();
+
+        // PVMFPortInterface virtuals
+        PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg);
+
+        bool OpenFile(char *aFileName)
+        {
+            iWriteFile = fopen(aFileName, "wb");
+            if (iWriteFile)
+            {
+                return true;
+            }
+            return false;
+        }
+
+    private:
+        FILE *iWriteFile;
+};
+#endif
diff --git a/protocols/systems/tools/general/common/include/pvmf_file_data_source.h b/protocols/systems/tools/general/common/include/pvmf_file_data_source.h
new file mode 100644
index 0000000..b742228
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvmf_file_data_source.h
@@ -0,0 +1,92 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_FILE_DATA_SOURCE_H_INCLUDED
+#define PVMF_FILE_DATA_SOURCE_H_INCLUDED
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_NODE_INTERFACE_H_INCLUDED
+#include "pvmf_node_interface.h"
+#endif
+
+#ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
+#include "pvmf_port_base_impl.h"
+#endif
+
+#ifndef OSCL_TIMER_H_INCLUDED
+#include "oscl_timer.h"
+#endif
+
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability_utils.h"
+#endif
+
+#ifndef PVMF_BUFFER_DATA_SOURCE_H_INCLUDED
+#include "pvmf_buffer_data_source.h"
+#endif
+
+class PVMFFileDataSourceObserver
+{
+    public:
+        virtual void FileDataFinished() = 0;
+};
+
+class PVMFFileDataSource : public PVMFBufferDataSource
+{
+    public:
+        OSCL_IMPORT_REF PVMFFileDataSource(int32 aPortTag,
+                                           unsigned bitrate,
+                                           unsigned min_sample_sz,
+                                           unsigned max_sample_sz);
+        OSCL_IMPORT_REF virtual ~PVMFFileDataSource();
+
+        // timer observer
+        void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
+
+        bool OpenFile(char *aFileName)
+        {
+            iReadFile = fopen(aFileName, "rb");
+            if (iReadFile)
+            {
+                iIsFileDone = false;
+                return true;
+            }
+            return false;
+        }
+
+        void SetObserver(PVMFFileDataSourceObserver *aObserver)
+        {
+            iObserver = aObserver;
+        }
+
+    private:
+        FILE *iReadFile;
+        PVMFFileDataSourceObserver *iObserver;
+        bool iIsFileDone;
+};
+#endif
diff --git a/protocols/systems/tools/general/common/include/pvt_events.h b/protocols/systems/tools/general/common/include/pvt_events.h
new file mode 100644
index 0000000..0008b27
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvt_events.h
@@ -0,0 +1,195 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(PVT_EVENTS_H)
+#define PVT_EVENTS_H
+#include "oscl_types.h"
+#include "oscl_string_containers.h"
+#include "pvt_common.h"
+#include "pvt_params.h"
+
+/* Base class for all PVTemrinal events */
+class CPVTerminalEvent
+{
+    public:
+        CPVTerminalEvent(OSCL_wHeapString<OsclMemAllocator>* desc = NULL)
+        {
+            if (desc)
+                SetDescription(*desc);
+        }
+        virtual ~CPVTerminalEvent() {};
+
+        /* Returns a texual description of the event */
+        virtual const OSCL_wHeapString<OsclMemAllocator>* GetDescription() const
+        {
+            return &description;
+        }
+        virtual void SetDescription(OSCL_wHeapString<OsclMemAllocator>& desc)
+        {
+            description =  desc;
+        }
+    protected:
+        OSCL_wHeapString<OsclMemAllocator> description;
+};
+
+/* Response to a command.  Contains the command id and the status code */
+class CPVTerminalResponse : public CPVTerminalEvent
+{
+    public:
+        CPVTerminalResponse(TPVStatusCode a_status_code):
+                status_code(a_status_code) {};
+
+        virtual ~CPVTerminalResponse() {};
+
+        TPVStatusCode GetStatusCode() const
+        {
+            return status_code;
+        }
+    protected:
+        TPVStatusCode status_code;
+};
+
+/* Unsolicited indication messages */
+class CPVTerminalIndication : public CPVTerminalEvent
+{
+};
+
+class CPVTerminalError : public CPVTerminalEvent
+{
+    public:
+        CPVTerminalError(TPVSeverity s, OSCL_wHeapString<OsclMemAllocator>& desc) : CPVTerminalEvent(&desc), severity(s) {}
+        virtual ~CPVTerminalError() {};
+        TPVSeverity GetSeverity()
+        {
+            return severity;
+        }
+    private:
+        TPVSeverity severity;
+};
+
+
+class ConnectResponse : public CPVTerminalResponse
+{
+    public:
+        ConnectResponse(TPVStatusCode a_status_code): CPVTerminalResponse(a_status_code) {}
+    private:
+};
+
+
+class DisconnectResponse : public CPVTerminalResponse
+{
+    public:
+        DisconnectResponse(TPVStatusCode a_status_code, TPVTerminalIdentifier which):
+                CPVTerminalResponse(a_status_code), iWhich(which) {};
+        virtual ~DisconnectResponse() {};
+
+        TPVTerminalIdentifier GetTerminalIdentifier()
+        {
+            return iWhich;
+        }
+    private:
+        TPVTerminalIdentifier iWhich;
+};
+
+class HoldResponse : public CPVTerminalResponse
+{
+    public:
+        HoldResponse(TPVStatusCode a_status_code): CPVTerminalResponse(a_status_code) {};
+        virtual ~HoldResponse() {};
+};
+class ReleaseHoldResponse : public CPVTerminalResponse
+{
+    public:
+        ReleaseHoldResponse(TPVStatusCode a_status_code): CPVTerminalResponse(a_status_code) {};
+        virtual ~ReleaseHoldResponse() {};
+};
+class SetChannelParamsResponse : public CPVTerminalResponse
+{
+    public:
+        SetChannelParamsResponse(TPVStatusCode a_status_code): CPVTerminalResponse(a_status_code) {};
+        virtual ~SetChannelParamsResponse() {};
+};
+class SetMuxParamsResponse : public CPVTerminalResponse
+{
+    public:
+        SetMuxParamsResponse(TPVStatusCode a_status_code): CPVTerminalResponse(a_status_code) {};
+        virtual ~SetMuxParamsResponse() {};
+};
+
+class OpenChannelResponse : public CPVTerminalResponse
+{
+    public:
+        OpenChannelResponse(TPVStatusCode a_status_code, PV2WayMediaType type, CPVChannelParam* param):
+                CPVTerminalResponse(a_status_code), iChannelParam(param), iType(type) {};
+        virtual ~OpenChannelResponse() {};
+        PV2WayMediaType GetMediaType()
+        {
+            return iType;
+        }
+        CPVChannelParam* GetChannelParam()
+        {
+            return iChannelParam;
+        }
+    private:
+        CPVChannelParam* iChannelParam;
+        PV2WayMediaType iType;
+};
+
+class CloseChannelResponse : public CPVTerminalResponse
+{
+    public:
+        CloseChannelResponse(TPVDirection aDirection, TPVChannelId aChannelId, TPVStatusCode a_status_code):
+                CPVTerminalResponse(a_status_code), iDirection(aDirection), iChannelId(aChannelId)
+        {
+        }
+
+        virtual ~CloseChannelResponse() {};
+
+        TPVDirection GetDirection()
+        {
+            return iDirection;
+        }
+
+        TPVChannelId GetChannelId()
+        {
+            return iChannelId;
+        }
+    private:
+        TPVDirection     iDirection;
+        TPVChannelId     iChannelId;
+};
+
+class CPVChannelError: public CPVTerminalError
+{
+    public:
+        CPVChannelError(TPVDirection dir, TPVChannelId id, TPVSeverity s, OSCL_wHeapString<OsclMemAllocator>& desc) :
+                CPVTerminalError(s, desc), direction(dir), cid(id) {};
+        virtual ~CPVChannelError() {};
+        TPVDirection GetDirection()
+        {
+            return direction;
+        }
+        TPVChannelId GetChannelId()
+        {
+            return cid;
+        }
+    private:
+        TPVDirection direction;
+        TPVChannelId cid;
+};
+
+#endif
diff --git a/protocols/systems/tools/general/common/include/pvt_params.h b/protocols/systems/tools/general/common/include/pvt_params.h
new file mode 100644
index 0000000..ea2b712
--- /dev/null
+++ b/protocols/systems/tools/general/common/include/pvt_params.h
@@ -0,0 +1,174 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#if !defined(PVT_PARAMS_H)
+#define PVT_PARAMS_H
+
+#include "oscl_stdstring.h"
+#include "oscl_base.h"
+#include "control_msg_hdr.h"
+#include "pvt_common.h"
+#include "oscl_mem.h"
+
+class CPVChannelParam : public CPVTrackInfo
+{
+    public:
+        CPVChannelParam(TPVDirection dir, TPVChannelId id, TPVDirectionality directionality, ErrorProtectionLevel_t epl):
+                iDirection(dir), iChannelId(id), iDirectionality(directionality), iEpl(epl),
+                iNumSduSizes(0), iSduSizes(NULL), iMediaParam(NULL)
+        {
+        }
+        CPVChannelParam(CPVChannelParam& that) : CPVTrackInfo(that),
+                iDirection(that.iDirection), iChannelId(that.iChannelId), iDirectionality(that.iDirectionality), iEpl(that.iEpl),
+                iNumSduSizes(that.iNumSduSizes), iSduSizes(NULL), iMediaParam(NULL)
+        {
+            if (iNumSduSizes)
+            {
+                iSduSizes = (int*)OSCL_DEFAULT_MALLOC(iNumSduSizes * sizeof(int));
+                oscl_memcpy(iSduSizes, that.iSduSizes, iNumSduSizes*sizeof(int));
+            }
+            if (that.iMediaParam)
+            {
+                iMediaParam = (CPVMediaParam*)that.iMediaParam->Copy();
+            }
+
+        }
+        virtual ~CPVChannelParam()
+        {
+            if (iSduSizes)
+                OSCL_DEFAULT_FREE(iSduSizes);
+            if (iMediaParam)
+                OSCL_DELETE(iMediaParam);
+        }
+
+        void SetChannelParams(TPVDirection dir, TPVChannelId id, TPVDirectionality directionality, ErrorProtectionLevel_t epl)
+        {
+            iDirection = dir;
+            iChannelId = id;
+            iDirectionality = directionality;
+            iEpl = epl;
+        }
+
+        void SetMediaParam(CPVMediaParam* media_param)
+        {
+            if (iMediaParam)
+            {
+                OSCL_DELETE(iMediaParam);
+                iMediaParam = NULL;
+            }
+            if (media_param)
+            {
+                iMediaParam = (CPVMediaParam*)media_param->Copy();
+            }
+        }
+
+        int SetSduSizes(int num_sizes, int* sizes)
+        {
+            iNumSduSizes = num_sizes;
+            if (iSduSizes)
+            {
+                OSCL_DEFAULT_FREE(iSduSizes);
+                iSduSizes = NULL;
+            }
+            if (num_sizes)
+            {
+                iSduSizes = (int*)OSCL_DEFAULT_MALLOC(iNumSduSizes * sizeof(int));
+
+                for (int i = 0; i < num_sizes; i++)
+                {
+                    iSduSizes[i] = sizes[i];
+                }
+            }
+            return num_sizes;
+        }
+
+        void Clear()
+        {
+            SetChannelParams(OUTGOING, CHANNEL_ID_UNKNOWN, EPVT_UNI_DIRECTIONAL, E_EP_LOW);
+            SetMediaParam(NULL);
+            SetSduSizes(0, NULL);
+        }
+
+        /* Get methods */
+        TPVDirection GetDirection()
+        {
+            return iDirection;
+        }
+        TPVChannelId GetChannelId()
+        {
+            return iChannelId;
+        }
+
+        TPVDirectionality GetDirectionality()
+        {
+            return iDirectionality;
+        }
+
+        ErrorProtectionLevel_t GetErrorProtectionLevel()
+        {
+            return iEpl;
+        }
+
+        int GetNumSduSizes()
+        {
+            return iNumSduSizes;
+        }
+        int GetSduSize(int index = 0)
+        {
+            return iSduSizes[index];
+        }
+        int* GetSduSizes()
+        {
+            if (iNumSduSizes)
+                return iSduSizes;
+            return NULL;
+        }
+        CPVMediaParam* GetMediaParam()
+        {
+            return iMediaParam;
+        }
+
+        CPVTrackInfo* Copy()
+        {
+            return OSCL_NEW(CPVChannelParam, (*this));
+        }
+
+    protected:
+        CPVChannelParam() : iDirection(OUTGOING), iChannelId(CHANNEL_ID_UNKNOWN), iDirectionality(EPVT_UNI_DIRECTIONAL), iEpl(E_EP_LOW),
+                iNumSduSizes(0), iSduSizes(NULL), iMediaParam(NULL)
+        {
+        }
+
+        TPVDirection iDirection;
+        TPVChannelId iChannelId;
+        TPVDirectionality iDirectionality;
+        ErrorProtectionLevel_t iEpl;
+        int iNumSduSizes;
+        int* iSduSizes;
+        CPVMediaParam* iMediaParam;
+};
+
+
+class CPVDataParam : public CPVParam
+{
+    public:
+        CPVDataParam() {}
+};
+
+#define min2(a, b) ((a > b) ? b : a)
+
+#endif
diff --git a/protocols/systems/tools/general/common/src/crccheck.cpp b/protocols/systems/tools/general/common/src/crccheck.cpp
new file mode 100644
index 0000000..edc8383
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/crccheck.cpp
@@ -0,0 +1,224 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+ * File:	crccheck.cpp
+ * Author:	Russell Hayashida (rhayashida@packetvideo.com)
+ * Date:	February 13, 2002
+ * Comment:	CRC procedures
+ */
+
+#include "crccheck_cpp.h"
+#include <limits.h>
+
+#define CRC_X8 0xe0		/* X8+X2+X+1( 0x107 <-> 0xe0 ) */
+#define CRC_X 0x8408U	/* X16+X12+X5+1 ( 0x11021 <-> 0x8408 )  */
+
+
+//Initialize both tables.
+OSCL_EXPORT_REF CRC::CRC()
+{
+    int i;
+    uint8 j, Crc;
+
+    for (i = 0 ; i <= (int) UCHAR_MAX ; i ++)
+    {
+        Crc = (uint8) i;
+        for (j =  0 ; j < CHAR_BIT ; j ++)
+        {
+            if (Crc & 1)
+                Crc = (uint8)((Crc >> 1) ^ CRC_X8);	       /* Generator Polynomial		    */
+            else
+                Crc >>= 1;
+        }
+        CrcTbl8[i] = Crc;
+    }
+
+
+    uint16	n, m, Crc16;
+
+    for (n = 0 ; n <= UCHAR_MAX ; n++)
+    {
+        Crc16 = n;
+        for (m =  0 ; m < CHAR_BIT ; m++)
+        {
+            if (Crc16 & 1)
+                Crc16 = (uint16)((Crc16 >> 1) ^ CRC_X);		       /* Genarator Polynomial		    */
+            else
+                Crc16 >>= 1;
+        }
+        CrcTbl16[ n ] = Crc16;		    /* CRC Infomaiton Set		    */
+    }
+}
+
+
+OSCL_EXPORT_REF uint8 CRC::Crc8Check(uint8 *pAlPdu, int16 Size)
+{
+    uint8	crc;
+
+    crc = 0;
+    while (--Size >= 0)
+    {
+        crc = (uint8)((crc >> CHAR_BIT) ^ CrcTbl8[ crc ^ *pAlPdu++ ]);
+    }
+    return (uint8)(crc & 0xffU);
+}
+
+OSCL_EXPORT_REF uint8 CRC::Crc8Check(Packet *pPkt)
+{
+    uint8	crc;
+    uint8	*pData = NULL;
+    int32	fragIdx, curSize, dataSize;
+    BufferFragment* frag = NULL;
+
+    crc = 0;
+    fragIdx = 0;
+    dataSize = pPkt->GetMediaSize();
+    curSize = 0;
+    while (--dataSize >= 0)
+    {
+
+        if ((--curSize) <= 0)
+        {
+            frag = pPkt->GetMediaFragment(fragIdx);
+            fragIdx++;
+            curSize = frag->len;
+            pData = (uint8 *) frag->ptr;
+        }
+        crc = (uint8)((crc >> CHAR_BIT) ^ CrcTbl8[ crc ^ *pData++ ]);
+    }
+    return (uint8)(crc & 0xffU);
+}
+
+OSCL_EXPORT_REF uint8 CRC::Crc8Check(OsclSharedPtr<PVMFMediaDataImpl>& mediaData, bool hasCRC)
+{
+    uint8	crc;
+    uint8	*pData = NULL;
+    int32	fragIdx, curSize, dataSize;
+    OsclRefCounterMemFrag frag;
+
+    crc = 0;
+    fragIdx = 0;
+    //Don't include CRC field in calculation
+    if (hasCRC)
+    {
+        dataSize = mediaData->getFilledSize() - 1;
+    }
+    else
+    {
+        dataSize = mediaData->getFilledSize();
+    }
+    curSize = 0;
+    while (--dataSize >= 0)
+    {
+
+        if ((--curSize) <= 0)
+        {
+            mediaData->getMediaFragment(fragIdx, frag);
+            fragIdx++;
+            curSize = frag.getMemFragSize();
+            pData = (uint8 *) frag.getMemFragPtr();
+        }
+        crc = (uint8)((crc >> CHAR_BIT) ^ CrcTbl8[ crc ^ *pData++ ]);
+    }
+    return (uint8)(crc & 0xffU);
+}
+
+
+OSCL_EXPORT_REF uint16 CRC::Crc16Check(uint8 *pAlPdu, int16 Size)
+{
+    uint16	crc;
+
+    crc = 0xffffU;
+    while (--Size >= 0)
+    {
+        crc = (uint16)((crc >> CHAR_BIT) ^ CrcTbl16[(uint8)crc ^ *pAlPdu++ ]);
+    }
+    return (uint16)(crc ^ 0xffffU);
+    /*
+    crc ^= 0xffffU;
+    crc = (crc&0xff)<<8 | crc>>8;
+    return crc;
+    */
+}
+
+OSCL_EXPORT_REF uint16 CRC::Crc16Check(Packet *pPkt)
+{
+    uint16	crc;
+    uint8	*pData = NULL;
+    int32	fragIdx, curSize, dataSize;
+    BufferFragment* frag = NULL;
+
+    crc = 0xffffU;
+    fragIdx = 0;
+    dataSize = pPkt->GetMediaSize();
+    curSize = 0;
+    while (--dataSize >= 0)
+    {
+
+        if ((--curSize) <= 0)
+        {
+            frag = pPkt->GetMediaFragment(fragIdx);
+            fragIdx++;
+            curSize = frag->len;
+            pData = (uint8 *) frag->ptr;
+        }
+        crc = (uint16)((crc >> CHAR_BIT) ^ CrcTbl16[(uint8)crc ^ *pData++ ]);
+    }
+    return (uint16)(crc ^ 0xffffU);
+    /*
+    crc ^= 0xffffU;
+    crc = (crc&0xff)<<8 | crc>>8;
+    return crc;
+    */
+
+}
+
+OSCL_EXPORT_REF uint16 CRC::Crc16Check(OsclSharedPtr<PVMFMediaDataImpl>& mediaData, bool hasCRC)
+{
+    uint16	crc;
+    uint8	*pData = NULL;
+    int32	fragIdx, curSize, dataSize;
+    OsclRefCounterMemFrag frag;
+
+    crc = 0xffffU;
+    fragIdx = 0;
+    //Don't include CRC field in calculation
+    if (hasCRC)
+    {
+        dataSize = mediaData->getFilledSize() - 2;
+    }
+    else
+    {
+        dataSize = mediaData->getFilledSize();
+    }
+    curSize = 0;
+
+    while (--dataSize >= 0)
+    {
+
+        if ((--curSize) <= 0)
+        {
+            mediaData->getMediaFragment(fragIdx, frag);
+            fragIdx++;
+            curSize = frag.getMemFragSize();
+            pData = (uint8 *) frag.getMemFragPtr();
+        }
+        crc = (uint16)((crc >> CHAR_BIT) ^ CrcTbl16[(uint8)crc ^ *pData++ ]);
+    }
+    return (uint16)(crc ^ 0xffffU);
+}
diff --git a/protocols/systems/tools/general/common/src/general_tools.cpp b/protocols/systems/tools/general/common/src/general_tools.cpp
new file mode 100644
index 0000000..5adbc95
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/general_tools.cpp
@@ -0,0 +1,21 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "oscl_dll.h"
+
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
diff --git a/protocols/systems/tools/general/common/src/layer.cpp b/protocols/systems/tools/general/common/src/layer.cpp
new file mode 100644
index 0000000..729016d
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/layer.cpp
@@ -0,0 +1,72 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "layer.h"
+
+OSCL_EXPORT_REF Layer::Layer() : bound_layer(NULL)
+{
+}
+
+OSCL_EXPORT_REF OsclAny Layer::Bind(Layer* layer)
+{
+    PacketOutput *pOutput;
+
+    if (!layer) return;
+
+    //Unbind if already bound.
+    if (IsBound()) UnBind();
+    if (layer->IsBound()) layer->UnBind();
+
+    //Set this layer's output.
+    pOutput = GetPacketOutput();
+    if (pOutput) pOutput->SetPacketOutput(layer->GetPacketInput());
+
+    //Set other incoming layer's output.
+    pOutput = layer->GetPacketOutput();
+    if (pOutput) pOutput->SetPacketOutput(GetPacketInput());
+
+    layer->SetBoundLayer(this);
+    SetBoundLayer(layer);
+    return;
+}
+
+OSCL_EXPORT_REF OsclAny Layer::UnBind()
+{
+    PacketOutput *pOutput;
+    if (bound_layer)
+    {
+        pOutput = GetPacketOutput();
+        if (pOutput) pOutput->ResetPacketOutput();
+
+        pOutput = bound_layer->GetPacketOutput();
+        if (pOutput) pOutput->ResetPacketOutput();
+
+        bound_layer->SetBoundLayer(NULL);
+        SetBoundLayer(NULL);
+    }
+}
+
+inline Layer* Layer::GetBoundLayer()
+{
+    return bound_layer;
+}
+
+OSCL_EXPORT_REF bool Layer::IsBound()
+{
+    return (bound_layer != NULL);
+}
diff --git a/protocols/systems/tools/general/common/src/media_fragment.cpp b/protocols/systems/tools/general/common/src/media_fragment.cpp
new file mode 100644
index 0000000..c55a1ab
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/media_fragment.cpp
@@ -0,0 +1,155 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "media_fragment.h"
+
+
+OSCL_EXPORT_REF MediaFragment::MediaFragment(const MediaFragment& that, OsclAny* ptr, int32 len):
+        _fragment(that._fragment), _state(that._state)
+{
+    if (_state)
+        _state->increment_refcnt();
+    if (ptr && (len > 0))
+    {
+        if ((ptr >= _fragment.ptr && ptr < ((uint8*)_fragment.ptr + _fragment.len)) &&
+                (((uint8*)ptr + len) <= ((uint8*)_fragment.ptr + _fragment.len)))
+        {
+            _fragment.ptr = ptr;
+            _fragment.len = len;
+        }
+    }
+}
+
+// Default fragment allocator.  Just malloc's and free's memory as needed.
+OSCL_EXPORT_REF MediaFragment* DefFragmentAllocator::allocate_fragment(uint32 sz)
+{
+    BufferFragment frag;
+    BufferState* state = NULL;
+
+    frag.ptr = OSCL_DEFAULT_MALLOC(sz);
+    frag.len = sz;
+    state = OSCL_NEW(BufferState, (&buffer_state_listener, frag.ptr));
+    return OSCL_NEW(MediaFragment, (frag, state));
+}
+
+OSCL_EXPORT_REF MediaFragment* DefFragmentAllocator::allocate_fragment(MediaFragment* fragment,
+        OsclAny* ptr, uint32 len)
+{
+    return OSCL_NEW(MediaFragment, (*fragment, ptr, len));
+}
+
+
+OSCL_EXPORT_REF int32 DefFragmentAllocator::deallocate_fragment(MediaFragment* fragment)
+{
+    OSCL_DELETE(fragment);
+    return 1;
+}
+
+
+
+// Buffer pool manager.  Frees the buffer back to the pool.
+OSCL_EXPORT_REF OsclAny BufferPoolMgr::BufferReleased(OsclAny* ptr, BufferState* state)
+{
+    OSCL_UNUSED_ARG(state);
+
+    BufferStateEntry *entry = (BufferStateEntry *) ptr;
+    pBufferPool->free_buffer_to_pool(entry);
+}
+
+// Buffer fragment pool.  Memory is pre-allocated at constructor time.
+OSCL_EXPORT_REF PoolFragmentAllocator::PoolFragmentAllocator(int32 max_frags, int32 max_frag_size)
+{
+    buffer_state_listener = OSCL_NEW(BufferPoolMgr, (this));
+
+    num_frags = max_frags;
+    frag_size = max_frag_size;
+    entire_list = new BufferStateEntry[max_frags];
+    free_list = entire_list;
+    buffer = (uint8 *) OSCL_DEFAULT_MALLOC((max_frags * max_frag_size));
+    oscl_memset(buffer, 0, (max_frags * max_frag_size));
+
+    int32 i;
+    for (i = 0; i < max_frags; i++)
+    {
+        entire_list[i].buf_state.bind(&entire_list[i], buffer_state_listener);
+        entire_list[i].frag.ptr = buffer + (i * max_frag_size);
+        entire_list[i].frag.len = max_frag_size;
+        if (i > 0)
+        {
+            entire_list[i-1].next_entry = &entire_list[i];
+        }
+    }
+    entire_list[i-1].next_entry = NULL;
+}
+
+OSCL_EXPORT_REF PoolFragmentAllocator::~PoolFragmentAllocator()
+{
+    for (int32 i = 0; i < num_frags; i++)
+    {
+        if (entire_list[i].buf_state.get_refcount() > 0)
+        {
+            OSCL_ASSERT(0);
+        }
+    }
+
+    if (buffer) OSCL_DEFAULT_FREE(buffer);
+    if (entire_list) delete[] entire_list;
+    if (buffer_state_listener) OSCL_DELETE(buffer_state_listener);
+}
+
+OSCL_EXPORT_REF MediaFragment* PoolFragmentAllocator::allocate_fragment(uint32 sz)
+{
+    BufferStateEntry *entry;
+
+    if (free_list && ((int32) sz <= frag_size))
+    {
+        entry = free_list;
+        free_list = free_list->next_entry;
+
+        entry->next_entry = NULL;
+        entry->frag.len = sz;
+        entry->media_frag.Set(entry->frag, &entry->buf_state);
+
+        return &entry->media_frag;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+OSCL_EXPORT_REF MediaFragment* PoolFragmentAllocator::allocate_fragment(MediaFragment* fragment,
+        OsclAny* ptr,
+        uint32 len)
+{
+    return OSCL_NEW(MediaFragment, (*fragment, ptr, len));
+}
+
+OSCL_EXPORT_REF int32 PoolFragmentAllocator::deallocate_fragment(MediaFragment* fragment)
+{
+    fragment->Set(NULL, 0, NULL);
+    return 1;
+}
+
+OsclAny PoolFragmentAllocator::free_buffer_to_pool(BufferStateEntry *entry)
+{
+    entry->next_entry = free_list;
+    free_list = entry;
+}
+
+
diff --git a/protocols/systems/tools/general/common/src/media_packet.cpp b/protocols/systems/tools/general/common/src/media_packet.cpp
new file mode 100644
index 0000000..fca173f
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/media_packet.cpp
@@ -0,0 +1,182 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+// -*- c++ -*-
+#ifndef PVMF_RETURN_CODES_H_INCLUDED
+#include "pvmf_return_codes.h"
+#endif
+
+#include "media_packet.h"
+
+OSCL_EXPORT_REF MediaFragment* MediaPacket::GetMediaFragment(int32 idx, MediaFragment& fragment)
+{
+    BufferState * state = GetBufferState(idx);
+    /*if(!state)
+    	return NULL;*/
+    fragment.Set(*GetFragment(idx), state);
+    return &fragment;
+}
+
+
+OSCL_EXPORT_REF BufFragStatusClass::status_t MediaPacket::AddMediaFragment(MediaFragment* fragment, int32 location_offset)
+{
+    return AddFragment(*fragment->GetFragment(), fragment->GetState(), location_offset);
+}
+
+OSCL_EXPORT_REF void MediaPacket::Reset()
+{
+    cur_frag_num = 0;
+    cur_pos = NULL;
+    end_pos = NULL;
+    AppendNext(NULL);
+}
+
+
+/* This should change to allocate memory from a memory pool */
+OSCL_EXPORT_REF MediaPacket* MediaPacketAllocator::allocate_packet(EPacketType type)
+{
+    OSCL_UNUSED_ARG(type);
+    return OSCL_NEW(MediaPacket, ());
+}
+
+/* Change to return to pool */
+OSCL_EXPORT_REF void MediaPacketAllocator::deallocate_packet(MediaPacket* pack)
+{
+    OSCL_DELETE(pack);
+}
+
+OSCL_EXPORT_REF MediaPacketPoolAllocator::MediaPacketPoolAllocator(int packets)
+{
+    num_packets = packets;
+
+    entire_list = OSCL_ARRAY_NEW(MediaPacket, num_packets);
+    free_list = entire_list;
+
+    int i;
+    for (i = 0; i < num_packets; i++)
+    {
+        if (i > 0)
+        {
+            entire_list[i-1].AppendNext(&entire_list[i]);
+        }
+    }
+    entire_list[i-1].AppendNext(NULL);
+
+}
+
+MediaPacketPoolAllocator::~MediaPacketPoolAllocator()
+{
+    if (entire_list) delete[] entire_list;
+}
+
+OSCL_EXPORT_REF MediaPacket *MediaPacketPoolAllocator::allocate_packet(EPacketType type)
+{
+    OSCL_UNUSED_ARG(type);
+
+    MediaPacket *pkt;
+
+    if (free_list)
+    {
+        pkt = free_list;
+        free_list = (MediaPacket *)free_list->GetNext();
+
+        pkt->AppendNext(NULL);
+
+        return pkt;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+OSCL_EXPORT_REF void MediaPacketPoolAllocator::deallocate_packet(MediaPacket* pack)
+{
+    pack->Clear();
+    pack->Reset();
+
+    pack->AppendNext(free_list);
+    free_list = pack;
+
+}
+
+OSCL_EXPORT_REF PVMFSharedMediaMsgPtr MediaPacketToPVMFMediaMsg(MediaPacket* packet, PVMFSimpleMediaBufferCombinedAlloc& alloc)
+{
+    if (packet == NULL || packet->GetMediaSize() == 0)
+    {
+        OSCL_LEAVE(PVMFErrArgument);
+    }
+    uint16 packet_size = (uint16)packet->GetMediaSize();
+
+    // Create new media data buffer
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = alloc.allocate(packet_size);
+    PVMFSharedMediaDataPtr mediaData = PVMFMediaData::createMediaData(mediaDataImpl);
+
+    // Retrieve memory fragment to write to
+    OsclRefCounterMemFrag refCtrMemFrag;
+    mediaData->getMediaFragment(0, refCtrMemFrag);
+    uint8* copy_pos = (uint8*)refCtrMemFrag.getMemFragPtr();
+    MediaFragment frag;
+    for (int frag_num = 0; frag_num < packet->GetNumFrags(); frag_num++)
+    {
+        packet->GetMediaFragment(frag_num, frag);
+        oscl_memcpy(copy_pos, frag.GetPtr(), frag.GetLen());
+        copy_pos += frag.GetLen();
+    }
+
+    // update the filled length of the fragment
+    mediaData->setMediaFragFilledLen(0, packet_size);
+
+    // Send packet to downstream node
+    PVMFSharedMediaMsgPtr mediaMsg;
+    convertToPVMFMediaMsg(mediaMsg, mediaData);
+    return mediaMsg;
+}
+
+/* Callers responsibility to delete the packet */
+OSCL_EXPORT_REF MediaPacket* PVMFMediaMsgToMediaPacket(PVMFSharedMediaMsgPtr aMsg,
+        MediaPacketAllocator& aMediaPacketAlloc, FragmentAllocator& aFragmentAlloc)
+{
+
+    PVMFSharedMediaDataPtr mediaData;
+    convertToPVMFMediaData(mediaData, aMsg);
+    if (mediaData->getFilledSize() == 0)
+    {
+        return NULL;
+    }
+
+    MediaPacket* packet = aMediaPacketAlloc.allocate_packet();
+    OSCL_ASSERT(packet->GetNumFrags() == 0);
+
+    MediaFragment *frag = aFragmentAlloc.allocate_fragment(mediaData->getFilledSize());
+
+    OsclRefCounterMemFrag rcmfrag;
+
+    uint8* write_pos = frag->GetPtr();
+    for (uint16 frag_num = 0; frag_num < mediaData->getNumFragments(); frag_num++)
+    {
+        mediaData->getMediaFragment(frag_num, rcmfrag);
+        oscl_memcpy(write_pos, rcmfrag.getMemFragPtr(), rcmfrag.getMemFragSize());
+        write_pos += rcmfrag.getMemFragSize();
+    }
+
+    // add fragment to packet and send
+    packet->AddMediaFragment(frag);
+    aFragmentAlloc.deallocate_fragment(frag);
+
+    return packet;
+}
diff --git a/protocols/systems/tools/general/common/src/pvmf_buffer_data_sink.cpp b/protocols/systems/tools/general/common/src/pvmf_buffer_data_sink.cpp
new file mode 100644
index 0000000..8e8fb54
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/pvmf_buffer_data_sink.cpp
@@ -0,0 +1,178 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_buffer_data_sink.h"
+
+OSCL_EXPORT_REF PVMFBufferDataSink::PVMFBufferDataSink(int32 aPortTag)
+        : PvmfPortBaseImpl(aPortTag, this)
+{
+    iNumBytesReceived = 0;
+    iNumPktsReceived = 0;
+    iNumPktErrorsReceived = 0;
+}
+
+OSCL_EXPORT_REF PVMFBufferDataSink::~PVMFBufferDataSink()
+{
+}
+
+void PVMFBufferDataSink::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    if (aActivity.iType != PVMF_PORT_ACTIVITY_INCOMING_MSG)
+        return;
+    PVMFSharedMediaMsgPtr aMsg;
+    PVMFStatus aStatus;
+    while (IncomingMsgQueueSize())
+    {
+        aStatus = DequeueIncomingMsg(aMsg);
+        PutData(aMsg);
+    }
+}
+
+// PVMFPortInterface virtuals
+
+PVMFStatus PVMFBufferDataSink::PutData(PVMFSharedMediaMsgPtr aMsg)
+{
+    OSCL_UNUSED_ARG(aMsg);
+    iNumPktsReceived++;
+    PVMFSharedMediaDataPtr mediaData;
+    convertToPVMFMediaData(mediaData, aMsg);
+    iNumBytesReceived += (mediaData->getFilledSize());
+    if (mediaData->getErrorsFlag())
+        iNumPktErrorsReceived++;
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFBufferDataSink::GetData(PVMFSharedMediaMsgPtr aMsg)
+{
+    OSCL_UNUSED_ARG(aMsg);
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF unsigned PVMFBufferDataSink::GetNumBytesReceived()
+{
+    return iNumBytesReceived;
+}
+
+OSCL_EXPORT_REF unsigned PVMFBufferDataSink::GetNumPktsReceived()
+{
+    return iNumPktsReceived;
+}
+
+OSCL_EXPORT_REF unsigned PVMFBufferDataSink::GetNumPktErrorsReceived()
+{
+    return iNumPktErrorsReceived;
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSink::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFBufferDataSink::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters, int& num_parameter_elements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aIdentifier);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+    OSCL_UNUSED_ARG(aContext);
+
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFBufferDataSink::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSink::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSink::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+        PvmiKvp* aParameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSink::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSink::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+        int num_elements, PvmiKvp * & aRet_kvp)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(aRet_kvp);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PVMFBufferDataSink::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+        int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(aRet_kvp);
+    OSCL_UNUSED_ARG(context);
+
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+OSCL_EXPORT_REF uint32 PVMFBufferDataSink::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    return 1;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFBufferDataSink::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+
+    OSCL_LEAVE(OsclErrNotSupported);
+    return PVMFFailure;
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSink::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
+{
+    aPtr = NULL;
+    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        aPtr = (PvmiCapabilityAndConfig*)this;
+    }
+    else
+    {
+        OSCL_LEAVE(OsclErrNotSupported);
+    }
+}
diff --git a/protocols/systems/tools/general/common/src/pvmf_buffer_data_source.cpp b/protocols/systems/tools/general/common/src/pvmf_buffer_data_source.cpp
new file mode 100644
index 0000000..ccdd3cd
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/pvmf_buffer_data_source.cpp
@@ -0,0 +1,252 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_buffer_data_source.h"
+
+OSCL_EXPORT_REF PVMFBufferDataSource::PVMFBufferDataSource(int32 aPortTag,
+        unsigned bitrate,
+        unsigned min_sample_sz,
+        unsigned max_sample_sz,
+        uint8*   fsi,
+        unsigned fsi_len):
+        PvmfPortBaseImpl(aPortTag, this),
+        iTimer("PVMFBufferDataSource"),
+        iMediaDataAlloc(NULL),
+        iFsi(NULL),
+        iFsiLen(0)
+{
+    iBitrate = bitrate;
+    iMinSampleSz = min_sample_sz;
+    iMaxSampleSz = max_sample_sz;
+    iTimestamp = 0;
+    iSampleInterval = 0;
+    if (fsi && fsi_len)
+    {
+        iFsi = (uint8*)OSCL_DEFAULT_MALLOC(fsi_len);
+        oscl_memcpy(iFsi, fsi, fsi_len);
+        iFsiLen = fsi_len;
+    }
+}
+
+OSCL_EXPORT_REF PVMFBufferDataSource::~PVMFBufferDataSource()
+{
+    Stop();
+    if (iMediaDataAlloc)
+    {
+        OSCL_DELETE(iMediaDataAlloc);
+        iMediaDataAlloc = NULL;
+    }
+    if (iFsi)
+    {
+        OSCL_DEFAULT_FREE(iFsi);
+        iFsi = NULL;
+    }
+}
+
+void PVMFBufferDataSource::HandlePortActivity(const PVMFPortActivity &aActivity)
+{
+    if (aActivity.iType != PVMF_PORT_ACTIVITY_OUTGOING_MSG)
+        return;
+    PVMFSharedMediaMsgPtr aMsg;
+    while (OutgoingMsgQueueSize())
+    {
+        Send();
+    }
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::Start()
+{
+    iMediaDataAlloc = OSCL_NEW(PVMFSimpleMediaBufferCombinedAlloc, (&iMemAlloc));
+    unsigned ave_sample_sz = (iMinSampleSz + iMaxSampleSz) / 2;
+    unsigned frequency = (iBitrate >> 3) / ave_sample_sz;
+    iSampleInterval = 1000 / frequency;
+    iTimer .SetFrequency(frequency);
+    iTimer.SetObserver(this);
+    iTimer.Request(1/*timer id*/, ave_sample_sz/*timer info*/ , 1/*num ticks*/, this, 1/*recurring*/);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::Stop()
+{
+    iTimer.Clear();
+    Disconnect();
+}
+
+void PVMFBufferDataSource::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timerID);
+    unsigned bytesToSend = timeoutInfo;
+    if (bytesToSend <= 0)
+        return;
+
+    if (!IsConnected())
+        return;
+
+    // Create new media data buffer
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(bytesToSend);
+    PVMFSharedMediaDataPtr mediaData;
+    int leavecode = 0;
+    OSCL_TRY(leavecode, mediaData = PVMFMediaData::createMediaData(mediaDataImpl));
+    OSCL_FIRST_CATCH_ANY(leavecode, return);
+
+    // Send FSI if available
+    if (iFsi)
+    {
+        OsclSharedPtr<PVMFMediaDataImpl> fsiMediaDataImpl = iMediaDataAlloc->allocate(iFsiLen);
+        PVMFSharedMediaDataPtr fsiMediaData;
+        OSCL_TRY(leavecode, fsiMediaData = PVMFMediaData::createMediaData(fsiMediaDataImpl));
+        OSCL_FIRST_CATCH_ANY(leavecode, return);
+        OsclRefCounterMemFrag fsi_frag;
+        fsiMediaData->getMediaFragment(0, fsi_frag);
+        oscl_memcpy((uint8*)fsi_frag.getMemFragPtr(), iFsi, iFsiLen);
+        fsi_frag.getMemFrag().len = iFsiLen;
+        mediaData->setFormatSpecificInfo(fsi_frag);
+        OSCL_DEFAULT_FREE(iFsi);
+        iFsi = NULL;
+        iFsiLen = 0;
+    }
+
+    // Retrieve memory fragment to write to
+    OsclRefCounterMemFrag refCtrMemFrag;
+    mediaData->getMediaFragment(0, refCtrMemFrag);
+    if (refCtrMemFrag.getCapacity() < bytesToSend)
+        return;
+
+    oscl_memset((uint8*)refCtrMemFrag.getMemFragPtr(), 7, bytesToSend);
+    mediaDataImpl->setMediaFragFilledLen(0, bytesToSend);
+    mediaData->setTimestamp(iTimestamp);
+    iTimestamp += iSampleInterval;
+
+    // Send frame to downstream node
+    PVMFSharedMediaMsgPtr mediaMsg;
+    convertToPVMFMediaMsg(mediaMsg, mediaData);
+    QueueOutgoingMsg(mediaMsg);
+}
+
+// PVMFPortInterface virtuals
+
+PVMFStatus PVMFBufferDataSource::PutData(PVMFSharedMediaMsgPtr aMsg)
+{
+    OSCL_UNUSED_ARG(aMsg);
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFBufferDataSource::GetData(PVMFSharedMediaMsgPtr aMsg)
+{
+    OSCL_UNUSED_ARG(aMsg);
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFBufferDataSource::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+        PvmiKvp*& aParameters, int& num_parameter_elements,
+        PvmiCapabilityContext aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aIdentifier);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+    OSCL_UNUSED_ARG(aContext);
+
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFBufferDataSource::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+
+    return PVMFSuccess;
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+        PvmiKvp* aParameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aContext);
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+        int num_elements, PvmiKvp * & aRet_kvp)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(aRet_kvp);
+}
+
+
+OSCL_EXPORT_REF PVMFCommandId PVMFBufferDataSource::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+        int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(aRet_kvp);
+    OSCL_UNUSED_ARG(context);
+
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+OSCL_EXPORT_REF uint32 PVMFBufferDataSource::getCapabilityMetric(PvmiMIOSession aSession)
+{
+    OSCL_UNUSED_ARG(aSession);
+
+    return 1;
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFBufferDataSource::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(aSession);
+    OSCL_UNUSED_ARG(aParameters);
+    OSCL_UNUSED_ARG(num_elements);
+
+    OSCL_LEAVE(OsclErrNotSupported);
+    return PVMFFailure;
+}
+
+OSCL_EXPORT_REF void PVMFBufferDataSource::QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr)
+{
+    aPtr = NULL;
+    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        aPtr = (PvmiCapabilityAndConfig*)this;
+    }
+    else
+    {
+        OSCL_LEAVE(OsclErrNotSupported);
+    }
+}
diff --git a/protocols/systems/tools/general/common/src/pvmf_file_data_sink.cpp b/protocols/systems/tools/general/common/src/pvmf_file_data_sink.cpp
new file mode 100644
index 0000000..4ff6644
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/pvmf_file_data_sink.cpp
@@ -0,0 +1,57 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_file_data_sink.h"
+#include "pvmf_media_msg_format_ids.h"
+
+OSCL_EXPORT_REF PVMFFileDataSink::PVMFFileDataSink(int32 aPortTag)
+        : PVMFBufferDataSink(aPortTag)
+{
+}
+
+OSCL_EXPORT_REF PVMFFileDataSink::~PVMFFileDataSink()
+{
+    fclose(iWriteFile);
+}
+
+// PVMFPortInterface virtuals
+
+PVMFStatus PVMFFileDataSink::PutData(PVMFSharedMediaMsgPtr aMsg)
+{
+    iNumPktsReceived++;
+    PVUid32 msgFormatID = aMsg->getFormatID();
+    if (msgFormatID < PVMF_MEDIA_CMD_FORMAT_IDS_START)
+    {
+        //this code should be run for media data
+        // object only
+        PVMFSharedMediaDataPtr mediaData;
+        convertToPVMFMediaData(mediaData, aMsg);
+        iNumBytesReceived += mediaData->getFilledSize();
+
+        if (mediaData->getErrorsFlag())
+            iNumPktErrorsReceived++;
+        OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
+        mediaData->getMediaDataImpl(mediaDataImpl);
+        for (uint i = 0; i < mediaDataImpl->getNumFragments() ; i++)
+        {
+            OsclRefCounterMemFrag copy_frag;
+            mediaDataImpl->getMediaFragment(i, copy_frag);
+            fwrite(copy_frag.getMemFragPtr(), 1, copy_frag.getMemFragSize(), iWriteFile);
+        }
+    }
+    return PVMFSuccess;
+}
diff --git a/protocols/systems/tools/general/common/src/pvmf_file_data_source.cpp b/protocols/systems/tools/general/common/src/pvmf_file_data_source.cpp
new file mode 100644
index 0000000..f68385d
--- /dev/null
+++ b/protocols/systems/tools/general/common/src/pvmf_file_data_source.cpp
@@ -0,0 +1,84 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvmf_file_data_source.h"
+//#include "pv_mime_string_utils.h"
+
+OSCL_EXPORT_REF PVMFFileDataSource::PVMFFileDataSource(int32 aPortTag,
+        unsigned bitrate,
+        unsigned min_sample_sz,
+        unsigned max_sample_sz):
+        PVMFBufferDataSource(aPortTag, bitrate, min_sample_sz, max_sample_sz)
+{
+}
+
+OSCL_EXPORT_REF PVMFFileDataSource::~PVMFFileDataSource()
+{
+    Stop();
+    fclose(iReadFile);
+}
+
+uint32 total_bytes_read = 0;
+void PVMFFileDataSource::TimeoutOccurred(int32 timerID, int32 timeoutInfo)
+{
+    OSCL_UNUSED_ARG(timerID);
+    if (iIsFileDone)
+        return;
+    unsigned bytesToSend = timeoutInfo;
+    int bytes_read = 0;
+    if (bytesToSend <= 0)
+        return;
+
+    if (!IsConnected())
+        return;
+
+    // Create new media data buffer
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl = iMediaDataAlloc->allocate(bytesToSend);
+    PVMFSharedMediaDataPtr mediaData;
+    int leavecode = 0;
+    OSCL_TRY(leavecode, mediaData = PVMFMediaData::createMediaData(mediaDataImpl));
+    OSCL_FIRST_CATCH_ANY(leavecode, return);
+
+    // Retrieve memory fragment to write to
+    OsclRefCounterMemFrag refCtrMemFrag;
+    mediaData->getMediaFragment(0, refCtrMemFrag);
+    if (refCtrMemFrag.getCapacity() < bytesToSend)
+        return;
+
+    if (!feof(iReadFile))
+        bytes_read = fread((uint8*)refCtrMemFrag.getMemFragPtr(), 1, bytesToSend, iReadFile);
+    //if(bytes_read)
+    {
+        mediaDataImpl->setMediaFragFilledLen(0, bytes_read);
+        mediaData->setTimestamp(iTimestamp);
+        iTimestamp += iSampleInterval;
+
+        // Send frame to downstream node
+        PVMFSharedMediaMsgPtr mediaMsg;
+        convertToPVMFMediaMsg(mediaMsg, mediaData);
+        QueueOutgoingMsg(mediaMsg);
+        total_bytes_read += bytes_read;
+    }
+    if (!bytes_read)
+    {
+        OSCL_ASSERT(iObserver);
+        iObserver->FileDataFinished();
+        // Disconnect and stop
+        iIsFileDone = true;
+    }
+}
+
diff --git a/pvauthor/Android.mk b/pvauthor/Android.mk
deleted file mode 100644
index 7b2935d..0000000
--- a/pvauthor/Android.mk
+++ /dev/null
@@ -1,51 +0,0 @@
-ifneq ($(BUILD_WITHOUT_PV),true)
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-        libpvauthorengine \
-        libpvm4vencoder \
-        libpvencoder_gsmamr \
-        libpvavch264enc \
-        libpvmp4ffcomposer \
-        libpvamrencnode \
-        libpvmp4ffcomposernode \
-        libpvomxvideoencnode \
-        libpvavcencnode \
-        libpvmediainputnode \
-        libandroidpvauthor
-
-LOCAL_LDLIBS := -lpthread
-
-LOCAL_SHARED_LIBRARIES := libopencoreplayer libutils libcutils libui libhardware_legacy libandroid_runtime libdrm1 libmedia libsgl libopencorecommon 
-
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-# Include board-specific extensions
-LOCAL_SHARED_LIBRARIES += $(BOARD_OPENCORE_LIBRARIES)
-
-LOCAL_MODULE := libopencoreauthor
-
-include $(BUILD_SHARED_LIBRARY)
-include $(PV_TOP)//engines/author/Android.mk
-include $(PV_TOP)//codecs_v2/video/m4v_h263/enc/Android.mk
-include $(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk
-include $(PV_TOP)//codecs_v2/video/avc_h264/enc/Android.mk
-include $(PV_TOP)//fileformats/mp4/composer/Android.mk
-include $(PV_TOP)//nodes/pvamrencnode/Android.mk
-include $(PV_TOP)//nodes/pvmp4ffcomposernode/Android.mk
-include $(PV_TOP)//nodes/pvvideoencnode/Android.mk
-include $(PV_TOP)//nodes/pvomxvideoencnode/Android.mk
-include $(PV_TOP)//nodes/pvavcencnode/Android.mk
-include $(PV_TOP)//nodes/pvmediainputnode/Android.mk
-#include $(PV_TOP)//pvmi/media_io/pvmi_mio_fileinput/Android.mk
-#include $(PV_TOP)//pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk
-#include $(PV_TOP)//fileformats/avi/parser/Android.mk
-include $(PV_TOP)//android/author/Android.mk
-endif
diff --git a/pvauthor/NOTICE b/pvauthor/NOTICE
deleted file mode 100644
index 4421325..0000000
--- a/pvauthor/NOTICE
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ------------------------------------------------------------------

- * Copyright (C) 2008 PacketVideo

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either

- * express or implied.

- * See the License for the specific language governing permissions

- * and limitations under the License.

- * -------------------------------------------------------------------

- */

-

-Portions of the PacketVideo supplied code contain contributions which may be covered by the following copyright statements:

-

-

-/*     -------------------------------------------------------------------       *

- *                    MPEG-4 Simple Profile Video Decoder           *

- *     -------------------------------------------------------------------       *

- *

- * This software module was originally developed and/or edited by

- *

- *   Paulo Nunes (IST / ACTS-MoMuSyS)

- *   Robert Danielsen (Telenor / ACTS-MoMuSyS)

- *   Luis Ducla-Soares (IST / ACTS-MoMuSys).     	           	   	

- *   Cor Quist (KPN / ACTS-MoMuSys).     			              	

- *  Minhua Zhou (HHI / ACTS-MoMuSys).   	  	 	              	

- *

- * in the course of development of the MPEG-4 Video (ISO/IEC 14496-2) standard.

- * This software module is an implementation of a part of one or more MPEG-4

- * Video (ISO/IEC 14496-2) tools as specified by the MPEG-4 Video (ISO/IEC

- * 14496-2) standard.

- *

- * ISO/IEC gives users of the MPEG-4 Video (ISO/IEC 14496-2) standard free

- * license to this software module or modifications thereof for use in hardware

- * or software products claiming conformance to the MPEG-4 Video (ISO/IEC

- * 14496-2) standard.

- *

- * Those intending to use this software module in hardware or software products

- * are advised that its use may infringe existing patents. The original

- * developer of this software module and his/her company, the subsequent

- * editors and their companies, and ISO/IEC have no liability for use of this

- * software module or modifications thereof in an implementation. Copyright is

- * not released for non MPEG-4 Video (ISO/IEC 14496-2) Standard conforming

- * products.

- *

- * ACTS-MoMuSys partners retain full right to use the code for his/her own

- * purpose, assign or donate the code to a third party and to inhibit third

- * parties from using the code for non MPEG-4 Video (ISO/IEC 14496-2) Standard

- * conforming products. This copyright notice must be included in all copies or

- * derivative works.

- *

- * Copyright (c) 1996, 1997

- *

- *****************************************************************************/

-

-

-

-/****************************************************************************

-

-SC 29 Software Copyright Licencing Disclaimer:

-

-This software module was originally developed by

-  Coding Technologies

-

-and edited by

-  -

-

-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 

-standards for reference purposes and its performance may not have been 

-optimized. This software module is an implementation of one or more tools as 

-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.

-ISO/IEC gives users free license to this software module or modifications 

-thereof for use in products claiming conformance to audiovisual and 

-image-coding related ITU Recommendations and/or ISO/IEC International 

-Standards. ISO/IEC gives users the same free license to this software module or 

-modifications thereof for research purposes and further ISO/IEC standardisation.

-Those intending to use this software module in products are advised that its 

-use may infringe existing patents. ISO/IEC have no liability for use of this 

-software module or modifications thereof. Copyright is not released for 

-products that do not conform to audiovisual and image-coding related ITU 

-Recommendations and/or ISO/IEC International Standards.

-The original developer retains full right to modify and use the code for its 

-own purpose, assign or donate the code to a third party and to inhibit third 

-parties from using the code for products that do not conform to audiovisual and 

-image-coding related ITU Recommendations and/or ISO/IEC International Standards.

-This copyright notice must be included in all copies or derivative works.

-Copyright (c) ISO/IEC 2003.

-

-*******************************************************************************/

-

-

-/**************************************************************************

-

-This software module was originally developed by

-

-Mikko Suonio (Nokia)

-

-in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard

-ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an

-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools

-as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives

-users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this

-software module or modifications thereof for use in hardware or

-software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio

-standards. Those intending to use this software module in hardware or

-software products are advised that this use may infringe existing

-patents. The original developer of this software module and his/her

-company, the subsequent editors and their companies, and ISO/IEC have

-no liability for use of this software module or modifications thereof

-in an implementation. Copyright is not released for non MPEG-2

-NBC/MPEG-4 Audio conforming products. The original developer retains

-full right to use the code for his/her own purpose, assign or donate

-the code to a third party and to inhibit third party from using the

-code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This

-copyright notice must be included in all copies or derivative works.

-

-Copyright (c) 1997.

-

-***************************************************************************/

-

-

-/**************************************************************************

-

-This software module was originally developed by

-Nokia in the course of development of the MPEG-2 AAC/MPEG-4 

-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.

-This software module is an implementation of a part

-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the

-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the

-MPEG-2aac/MPEG-4 Audio standards free license to this software module

-or modifications thereof for use in hardware or software products

-claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those

-intending to use this software module in hardware or software products

-are advised that this use may infringe existing patents. The original

-developer of this software module, the subsequent

-editors and their companies, and ISO/IEC have no liability for use of

-this software module or modifications thereof in an

-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4

-Audio conforming products. The original developer retains full right to

-use the code for the developer's own purpose, assign or donate the code to a

-third party and to inhibit third party from using the code for non

-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice

-must be included in all copies or derivative works.

-Copyright (c)1997.  

-

-***************************************************************************/

-

-

-------------------------------------------------------------------------------

-

-MPEG-2 NBC Audio Decoder

-   "This software module was originally developed by AT&T, Dolby

-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development

-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and

-   3. This software module is an implementation of a part of one or more

-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4

-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio

-   standards free license to this software module or modifications thereof

-   for use in hardware or software products claiming conformance to the

-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software

-   module in hardware or software products are advised that this use may

-   infringe existing patents. The original developer of this software

-   module and his/her company, the subsequent editors and their companies,

-   and ISO/IEC have no liability for use of this software module or

-   modifications thereof in an implementation. Copyright is not released

-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original

-   developer retains full right to use the code for his/her own purpose,

-   assign or donate the code to a third party and to inhibit third party

-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.

-   This copyright notice must be included in all copies or derivative

-   works." 

-   Copyright(c)1996.

-

-------------------------------------------------------------------------------

-

-

-/*

- * snprintf.c - a portable implementation of snprintf

- *

- * AUTHOR

- *   Mark Martinec <mark.martinec@ijs.si>, April 1999.

- *

- *   Copyright 1999, Mark Martinec. All rights reserved.

- *

- * TERMS AND CONDITIONS

- *   This program is free software; you can redistribute it and/or modify

- *   it under the terms of the "Frontier Artistic License" which comes

- *   with this Kit.

- *

- *   This program is distributed in the hope that it will be useful,

- *   but WITHOUT ANY WARRANTY; without even the implied warranty

- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

- *   See the Frontier Artistic License for more details.

- *

- *

- */

-

-The "Frontier Artistic License" may be found at

- http://www.spinwardstars.com/frontier/fal.html

-

-

-

-

-

-

-

-/*---------------------------------------------------------------------------*/

-

-/*

- * Copyright (c) 2005 The Khronos Group Inc.

- *

- * Permission is hereby granted, free of charge, to any person obtaining

- * a copy of this software and associated documentation files (the

- * "Software"), to deal in the Software without restriction, including

- * without limitation the rights to use, copy, modify, merge, publish,

- * distribute, sublicense, and/or sell copies of the Software, and to

- * permit persons to whom the Software is furnished to do so, subject

- * to the following conditions:

- * The above copyright notice and this permission notice shall be included

- * in all copies or substantial portions of the Software.

- *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

- *

- */

-

-/*---------------------------------------------------------------------------*/

-

-/**@@@+++@@@@****************************************************************** 

-** 

-** Microsoft Windows Media 

-** Copyright (C) Microsoft Corporation. All rights reserved. 

-** 

-***@@@---@@@@****************************************************************** 

-*/ 

-

-

-

-----------------------------------------------------------------------------------------

-Portions of this file are derived from the following 3GPP standard:

- 

-    3GPP TS 26.073

-    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec

-    Available from http://www.3gpp.org

- 

-(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

-Permission to distribute, modify and use this file under the standard license

-terms listed above has been obtained from the copyright holder.

------------------------------------------------------------------------------------------

-

-

-----------------------------------------------------------------------------------------

-Portions of this file are derived from the following 3GPP standard:

- 

-    3GPP TS 26.173

-    ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec

-    Available from http://www.3gpp.org

- 

-(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

-Permission to distribute, modify and use this file under the standard license

-terms listed above has been obtained from the copyright holder.

------------------------------------------------------------------------------------------

-

diff --git a/pvcommon/Android.mk b/pvcommon/Android.mk
deleted file mode 100644
index 5afe31d..0000000
--- a/pvcommon/Android.mk
+++ /dev/null
@@ -1,62 +0,0 @@
-ifneq ($(BUILD_WITHOUT_PV),true)
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-        libosclbase \
-        libosclerror \
-        libosclmemory \
-        libosclutil \
-        libpvlogger \
-        libosclproc \
-        libosclio \
-        libosclregcli \
-        libosclregserv \
-        liboscllib \
-        libpvmf \
-        libpvmimeutils \
-        libpvfileoutputnode \
-        libpvmediadatastruct \
-        libthreadsafe_callback_ao \
-        libcolorconvert \
-        libpv_amr_nb_common_lib \
-        libpv_avc_common_lib
-
-LOCAL_LDLIBS := -lpthread
-
-LOCAL_SHARED_LIBRARIES := libutils libcutils libhardware libandroid_runtime
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-# Include board-specific extensions
-LOCAL_SHARED_LIBRARIES += $(BOARD_OPENCORE_LIBRARIES)
-
-
-LOCAL_MODULE := libopencorecommon
-
-include $(BUILD_SHARED_LIBRARY)
-include $(PV_TOP)//oscl/oscl/osclbase/Android.mk
-include $(PV_TOP)//oscl/oscl/osclerror/Android.mk
-include $(PV_TOP)//oscl/oscl/osclmemory/Android.mk
-include $(PV_TOP)//oscl/oscl/osclutil/Android.mk
-include $(PV_TOP)//oscl/pvlogger/Android.mk
-include $(PV_TOP)//oscl/oscl/osclproc/Android.mk
-include $(PV_TOP)//oscl/oscl/osclio/Android.mk
-include $(PV_TOP)//oscl/oscl/osclregcli/Android.mk
-include $(PV_TOP)//oscl/oscl/osclregserv/Android.mk
-include $(PV_TOP)//oscl/unit_test/Android.mk
-include $(PV_TOP)//oscl/oscl/oscllib/Android.mk
-include $(PV_TOP)//pvmi/pvmf/Android.mk
-include $(PV_TOP)//baselibs/pv_mime_utils/Android.mk
-include $(PV_TOP)//nodes/pvfileoutputnode/Android.mk
-include $(PV_TOP)//baselibs/media_data_structures/Android.mk
-include $(PV_TOP)//baselibs/threadsafe_callback_ao/Android.mk
-include $(PV_TOP)//codecs_v2/utilities/colorconvert/Android.mk
-include $(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
-include $(PV_TOP)//codecs_v2/video/avc_h264/common/Android.mk
-endif
diff --git a/pvcommon/NOTICE b/pvcommon/NOTICE
deleted file mode 100644
index 4421325..0000000
--- a/pvcommon/NOTICE
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ------------------------------------------------------------------

- * Copyright (C) 2008 PacketVideo

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either

- * express or implied.

- * See the License for the specific language governing permissions

- * and limitations under the License.

- * -------------------------------------------------------------------

- */

-

-Portions of the PacketVideo supplied code contain contributions which may be covered by the following copyright statements:

-

-

-/*     -------------------------------------------------------------------       *

- *                    MPEG-4 Simple Profile Video Decoder           *

- *     -------------------------------------------------------------------       *

- *

- * This software module was originally developed and/or edited by

- *

- *   Paulo Nunes (IST / ACTS-MoMuSyS)

- *   Robert Danielsen (Telenor / ACTS-MoMuSyS)

- *   Luis Ducla-Soares (IST / ACTS-MoMuSys).     	           	   	

- *   Cor Quist (KPN / ACTS-MoMuSys).     			              	

- *  Minhua Zhou (HHI / ACTS-MoMuSys).   	  	 	              	

- *

- * in the course of development of the MPEG-4 Video (ISO/IEC 14496-2) standard.

- * This software module is an implementation of a part of one or more MPEG-4

- * Video (ISO/IEC 14496-2) tools as specified by the MPEG-4 Video (ISO/IEC

- * 14496-2) standard.

- *

- * ISO/IEC gives users of the MPEG-4 Video (ISO/IEC 14496-2) standard free

- * license to this software module or modifications thereof for use in hardware

- * or software products claiming conformance to the MPEG-4 Video (ISO/IEC

- * 14496-2) standard.

- *

- * Those intending to use this software module in hardware or software products

- * are advised that its use may infringe existing patents. The original

- * developer of this software module and his/her company, the subsequent

- * editors and their companies, and ISO/IEC have no liability for use of this

- * software module or modifications thereof in an implementation. Copyright is

- * not released for non MPEG-4 Video (ISO/IEC 14496-2) Standard conforming

- * products.

- *

- * ACTS-MoMuSys partners retain full right to use the code for his/her own

- * purpose, assign or donate the code to a third party and to inhibit third

- * parties from using the code for non MPEG-4 Video (ISO/IEC 14496-2) Standard

- * conforming products. This copyright notice must be included in all copies or

- * derivative works.

- *

- * Copyright (c) 1996, 1997

- *

- *****************************************************************************/

-

-

-

-/****************************************************************************

-

-SC 29 Software Copyright Licencing Disclaimer:

-

-This software module was originally developed by

-  Coding Technologies

-

-and edited by

-  -

-

-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 

-standards for reference purposes and its performance may not have been 

-optimized. This software module is an implementation of one or more tools as 

-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.

-ISO/IEC gives users free license to this software module or modifications 

-thereof for use in products claiming conformance to audiovisual and 

-image-coding related ITU Recommendations and/or ISO/IEC International 

-Standards. ISO/IEC gives users the same free license to this software module or 

-modifications thereof for research purposes and further ISO/IEC standardisation.

-Those intending to use this software module in products are advised that its 

-use may infringe existing patents. ISO/IEC have no liability for use of this 

-software module or modifications thereof. Copyright is not released for 

-products that do not conform to audiovisual and image-coding related ITU 

-Recommendations and/or ISO/IEC International Standards.

-The original developer retains full right to modify and use the code for its 

-own purpose, assign or donate the code to a third party and to inhibit third 

-parties from using the code for products that do not conform to audiovisual and 

-image-coding related ITU Recommendations and/or ISO/IEC International Standards.

-This copyright notice must be included in all copies or derivative works.

-Copyright (c) ISO/IEC 2003.

-

-*******************************************************************************/

-

-

-/**************************************************************************

-

-This software module was originally developed by

-

-Mikko Suonio (Nokia)

-

-in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard

-ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an

-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools

-as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives

-users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this

-software module or modifications thereof for use in hardware or

-software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio

-standards. Those intending to use this software module in hardware or

-software products are advised that this use may infringe existing

-patents. The original developer of this software module and his/her

-company, the subsequent editors and their companies, and ISO/IEC have

-no liability for use of this software module or modifications thereof

-in an implementation. Copyright is not released for non MPEG-2

-NBC/MPEG-4 Audio conforming products. The original developer retains

-full right to use the code for his/her own purpose, assign or donate

-the code to a third party and to inhibit third party from using the

-code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This

-copyright notice must be included in all copies or derivative works.

-

-Copyright (c) 1997.

-

-***************************************************************************/

-

-

-/**************************************************************************

-

-This software module was originally developed by

-Nokia in the course of development of the MPEG-2 AAC/MPEG-4 

-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.

-This software module is an implementation of a part

-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the

-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the

-MPEG-2aac/MPEG-4 Audio standards free license to this software module

-or modifications thereof for use in hardware or software products

-claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those

-intending to use this software module in hardware or software products

-are advised that this use may infringe existing patents. The original

-developer of this software module, the subsequent

-editors and their companies, and ISO/IEC have no liability for use of

-this software module or modifications thereof in an

-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4

-Audio conforming products. The original developer retains full right to

-use the code for the developer's own purpose, assign or donate the code to a

-third party and to inhibit third party from using the code for non

-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice

-must be included in all copies or derivative works.

-Copyright (c)1997.  

-

-***************************************************************************/

-

-

-------------------------------------------------------------------------------

-

-MPEG-2 NBC Audio Decoder

-   "This software module was originally developed by AT&T, Dolby

-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development

-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and

-   3. This software module is an implementation of a part of one or more

-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4

-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio

-   standards free license to this software module or modifications thereof

-   for use in hardware or software products claiming conformance to the

-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software

-   module in hardware or software products are advised that this use may

-   infringe existing patents. The original developer of this software

-   module and his/her company, the subsequent editors and their companies,

-   and ISO/IEC have no liability for use of this software module or

-   modifications thereof in an implementation. Copyright is not released

-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original

-   developer retains full right to use the code for his/her own purpose,

-   assign or donate the code to a third party and to inhibit third party

-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.

-   This copyright notice must be included in all copies or derivative

-   works." 

-   Copyright(c)1996.

-

-------------------------------------------------------------------------------

-

-

-/*

- * snprintf.c - a portable implementation of snprintf

- *

- * AUTHOR

- *   Mark Martinec <mark.martinec@ijs.si>, April 1999.

- *

- *   Copyright 1999, Mark Martinec. All rights reserved.

- *

- * TERMS AND CONDITIONS

- *   This program is free software; you can redistribute it and/or modify

- *   it under the terms of the "Frontier Artistic License" which comes

- *   with this Kit.

- *

- *   This program is distributed in the hope that it will be useful,

- *   but WITHOUT ANY WARRANTY; without even the implied warranty

- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

- *   See the Frontier Artistic License for more details.

- *

- *

- */

-

-The "Frontier Artistic License" may be found at

- http://www.spinwardstars.com/frontier/fal.html

-

-

-

-

-

-

-

-/*---------------------------------------------------------------------------*/

-

-/*

- * Copyright (c) 2005 The Khronos Group Inc.

- *

- * Permission is hereby granted, free of charge, to any person obtaining

- * a copy of this software and associated documentation files (the

- * "Software"), to deal in the Software without restriction, including

- * without limitation the rights to use, copy, modify, merge, publish,

- * distribute, sublicense, and/or sell copies of the Software, and to

- * permit persons to whom the Software is furnished to do so, subject

- * to the following conditions:

- * The above copyright notice and this permission notice shall be included

- * in all copies or substantial portions of the Software.

- *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

- *

- */

-

-/*---------------------------------------------------------------------------*/

-

-/**@@@+++@@@@****************************************************************** 

-** 

-** Microsoft Windows Media 

-** Copyright (C) Microsoft Corporation. All rights reserved. 

-** 

-***@@@---@@@@****************************************************************** 

-*/ 

-

-

-

-----------------------------------------------------------------------------------------

-Portions of this file are derived from the following 3GPP standard:

- 

-    3GPP TS 26.073

-    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec

-    Available from http://www.3gpp.org

- 

-(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

-Permission to distribute, modify and use this file under the standard license

-terms listed above has been obtained from the copyright holder.

------------------------------------------------------------------------------------------

-

-

-----------------------------------------------------------------------------------------

-Portions of this file are derived from the following 3GPP standard:

- 

-    3GPP TS 26.173

-    ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec

-    Available from http://www.3gpp.org

- 

-(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

-Permission to distribute, modify and use this file under the standard license

-terms listed above has been obtained from the copyright holder.

------------------------------------------------------------------------------------------

-

diff --git a/pvmi/content_policy_manager/Android.mk b/pvmi/content_policy_manager/Android.mk
index 1bf3b9b..e48823e 100644
--- a/pvmi/content_policy_manager/Android.mk
+++ b/pvmi/content_policy_manager/Android.mk
@@ -3,31 +3,34 @@
 
 LOCAL_SRC_FILES := \
 	src/cpm.cpp \
-	src/pvmf_cpmplugin_factory_registry.cpp
-
+ 	src/pvmf_cpmplugin_factory_registry.cpp
 
 
 LOCAL_MODULE := libcpm
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/content_policy_manager/include \
-	$(PV_TOP)//pvmi/content_policy_manager/src \
-	$(PV_TOP)//pvmi/content_policy_manager/include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/common/include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/r75/include \
-	$(PV_TOP)//pvmi/content_policy_manager/../../nodes/common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/content_policy_manager/src \
+ 	$(PV_TOP)/pvmi/content_policy_manager/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/common/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/oma1/r75/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/cpm.h \
-	include/cpm_types.h \
-	include/cpm_plugin_registry.h \
-	include/pvmf_cpmplugin_factory_registry.h
+ 	include/cpm_types.h \
+ 	include/cpm_plugin_registry.h \
+ 	include/pvmf_cpmplugin_factory_registry.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/content_policy_manager/build/make/local.mk b/pvmi/content_policy_manager/build/make/local.mk
new file mode 100644
index 0000000..7cd4c67
--- /dev/null
+++ b/pvmi/content_policy_manager/build/make/local.mk
@@ -0,0 +1,31 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := cpm
+
+
+
+
+XINCDIRS +=  ../../include
+XINCDIRS +=  ../../plugins/common/include
+XINCDIRS +=  ../../plugins/oma1/r75/include
+XINCDIRS +=  ../../../../nodes/common/include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := cpm.cpp \
+		pvmf_cpmplugin_factory_registry.cpp
+
+HDRS := cpm.h \
+		cpm_types.h \
+		cpm_plugin_registry.h \
+		pvmf_cpmplugin_factory_registry.h
+
+
+include $(MK)/library.mk
diff --git a/pvmi/content_policy_manager/build/make/makefile b/pvmi/content_policy_manager/build/make/makefile
deleted file mode 100644
index b1cb01e..0000000
--- a/pvmi/content_policy_manager/build/make/makefile
+++ /dev/null
@@ -1,63 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = cpm
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this so that correct headers for player get included
-XINCDIRS += -I ../../include
-XINCDIRS += -I ../../plugins/common/include
-XINCDIRS += -I ../../plugins/oma1/r75/include
-XINCDIRS += -I ../../../../nodes/common/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	cpm.cpp \
-		pvmf_cpmplugin_factory_registry.cpp
-
-HDRS =  cpm.h \
-		cpm_types.h \
-		cpm_plugin_registry.h \
-		pvmf_cpmplugin_factory_registry.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/pvmi/content_policy_manager/include/cpm.h b/pvmi/content_policy_manager/include/cpm.h
index d4f76cd..3acd5d0 100644
--- a/pvmi/content_policy_manager/include/cpm.h
+++ b/pvmi/content_policy_manager/include/cpm.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/include/cpm_plugin_registry.h b/pvmi/content_policy_manager/include/cpm_plugin_registry.h
index e10a133..4d7a47e 100644
--- a/pvmi/content_policy_manager/include/cpm_plugin_registry.h
+++ b/pvmi/content_policy_manager/include/cpm_plugin_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@
  * CPMPluginRegistry is an abstract interface class
  * defining the plugin registry.
  */
+class OsclSharedLibraryList;
 class CPMPluginRegistry
 {
     public:
@@ -90,6 +91,8 @@
          */
         virtual bool GetPluginMimeType(uint32 aIndex, OSCL_String& aMimeType) = 0;
         virtual ~CPMPluginRegistry() {}
+
+        virtual OsclSharedLibraryList*& AccessSharedLibraryList() = 0;
 };
 
 /**
diff --git a/pvmi/content_policy_manager/include/cpm_types.h b/pvmi/content_policy_manager/include/cpm_types.h
index 06239d6..c92d65e 100644
--- a/pvmi/content_policy_manager/include/cpm_types.h
+++ b/pvmi/content_policy_manager/include/cpm_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,8 +47,6 @@
 
 /* MIME strings for CPM Content Formats */
 #define PVMF_CPM_MIME_CONTENT_FORMAT_UKNOWN "X-PV-CPM-UNKNOWN-CONTENT-TYPE"
-#define PVMF_CPM_MIME_CONTENT_FORMAT_OMA1  	"X-DRM-OMA1"
-#define PVMF_CPM_MIME_CONTENT_FORMAT_OMA2  	"X-DRM-OMA2"
 
 /* CPM Content Formats */
 #define PVMF_FIRST_CPM_CONTENT_FORMAT	2000
diff --git a/pvmi/content_policy_manager/include/pvmf_cpmplugin_factory_registry.h b/pvmi/content_policy_manager/include/pvmf_cpmplugin_factory_registry.h
index f202d56..47962e0 100644
--- a/pvmi/content_policy_manager/include/pvmf_cpmplugin_factory_registry.h
+++ b/pvmi/content_policy_manager/include/pvmf_cpmplugin_factory_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/common/Android.mk b/pvmi/content_policy_manager/plugins/common/Android.mk
index 1779356..f1f3959 100644
--- a/pvmi/content_policy_manager/plugins/common/Android.mk
+++ b/pvmi/content_policy_manager/plugins/common/Android.mk
@@ -1,27 +1,36 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
+LOCAL_SRC_FILES := \
+ 	
 
 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
 
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/common/include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/common/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/content_policy_manager/plugins/common/src \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvmf_cpmplugin_access_interface.h\
-	include/pvmf_cpmplugin_access_interface_factory.h\
-	include/pvmf_cpmplugin_authentication_interface.h\
-	include/pvmf_cpmplugin_authorization_interface.h\
-	include/pvmf_cpmplugin_license_interface.h\
-	include/pvmf_cpmplugin_license_interface_types.h\
-	include/pvmf_cpmplugin_interface.h
+	include/pvmf_cpmplugin_access_interface.h \
+ 	include/pvmf_cpmplugin_access_interface_factory.h \
+ 	include/pvmf_cpmplugin_authentication_interface.h \
+ 	include/pvmf_cpmplugin_authorization_interface.h \
+ 	include/pvmf_cpmplugin_contentmanagement_interface.h \
+ 	include/pvmf_cpmplugin_license_interface.h \
+ 	include/pvmf_cpmplugin_license_interface_types.h \
+ 	include/pvmf_cpmplugin_interface.h \
+ 	include/pvmf_cpmplugin_decryption_context.h
 
 include $(BUILD_COPY_HEADERS)
-
diff --git a/pvmi/content_policy_manager/plugins/common/build/make/local.mk b/pvmi/content_policy_manager/plugins/common/build/make/local.mk
new file mode 100644
index 0000000..cddaf62
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/build/make/local.mk
@@ -0,0 +1,32 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := 
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := 
+HDRS := pvmf_cpmplugin_access_interface.h \
+	pvmf_cpmplugin_access_interface_factory.h \
+	pvmf_cpmplugin_authentication_interface.h \
+	pvmf_cpmplugin_authorization_interface.h \
+	pvmf_cpmplugin_contentmanagement_interface.h \
+	pvmf_cpmplugin_license_interface.h \
+	pvmf_cpmplugin_license_interface_types.h \
+	pvmf_cpmplugin_interface.h \
+	pvmf_cpmplugin_decryption_context.h
+ 
+include $(MK)/library.mk
+install:: headers-install
+
+ 
diff --git a/pvmi/content_policy_manager/plugins/common/build/make/makefile b/pvmi/content_policy_manager/plugins/common/build/make/makefile
deleted file mode 100644
index d25bf7c..0000000
--- a/pvmi/content_policy_manager/plugins/common/build/make/makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-# Warning: This is just for the header installed in the common directory
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = 
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =
-
-HDRS =  pvmf_cpmplugin_access_interface.h\
-		pvmf_cpmplugin_access_interface_factory.h\
-		pvmf_cpmplugin_authentication_interface.h\
-		pvmf_cpmplugin_authorization_interface.h\
-		pvmf_cpmplugin_license_interface.h\
-		pvmf_cpmplugin_license_interface_types.h\
-		pvmf_cpmplugin_interface.h
- 
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-install:: headers-install
-
- 
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface.h
index de7ed5c..a890e63 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -53,106 +53,6 @@
         virtual void Reset(void) = 0;
 };
 
-
-#define PVMF_CPMPLUGIN_LOCAL_SYNC_ACCESS_INTERFACE_MIMETYPE "pvxxx/pvmf/cpm/plugin/local_sync_access_interface"
-#define PVMFCPMPluginLocalSyncAccessInterfaceUuid PVUuid(0xa3aa0c20,0xab74,0x4b52,0xaa,0xae,0x76,0x05,0xe8,0x31,0x3c,0x11)
-
-/**
- * Local Synchronous Content Access Interface for Content Policy Manager Plugins
- */
-class PVMFCPMPluginLocalSyncAccessInterface : public PVMFCPMPluginAccessInterface
-{
-    public:
-        /**
-         * Opens the registered content.
-         *
-         *
-         * @return returns 0 if successful and a non-zero value otherwise
-         */
-        virtual int32 OpenContent() = 0;
-
-        /**
-         * The File Read & Decrypt operation
-         * Reads from the file into the buffer a maximum of 'numelements'
-         * of size 'size'.
-         *
-         * @param buffer pointer to buffer of type void
-         * @param size   element size in bytes
-         * @param numelements
-         *               max number of elements to read
-         *
-         * @return returns the number of full elements actually read, which
-         *         may be less than count if an error occurs or if the end
-         *         of the file is encountered before reaching count. Use the
-         *         CheckEndOfFile or GetError function to distinguish a read
-         *         error from an end-of-file condition.
-         */
-        virtual uint32 ReadAndUnlockContent(OsclAny *buffer,
-                                            uint32 size,
-                                            uint32 numelements) = 0;
-
-        /**
-         * The File Seek operation
-         * Sets the position for file pointer
-         *
-         * @param offset offset from the specified origin.
-         * @param origin starting point
-         *
-         * @return returns 0 on success, and a non-zero value otherwise
-         */
-        virtual int32 SeekContent(int32 offset,
-                                  Oscl_File::seek_type origin) = 0;
-
-        /**
-         * The File Tell operation
-         * Returns the current file position for file specified by fp
-         */
-        virtual int32 GetCurrentContentPosition() = 0;
-
-        /**
-         * The File Size operation
-         * Returns the file size
-         */
-        virtual int32 GetContentSize() = 0;
-
-        /**
-         * The File Close operation
-         * Closes the file after flushing any remaining data in the
-         * buffers.
-         *
-         * @return returns 0 if successful, and a non-zero value otherwise
-         */
-        virtual int32 CloseContent() = 0;
-
-        /**
-         * The File Flush operation
-         * On an output stream OSCL_FileFlush causes any buffered
-         * but unwritten data to be written to the file.
-         *
-         * @return returns 0 if successful, and a non-zero value otherwise
-         */
-        virtual int32 Flush() = 0;
-
-        /**
-         * The File Error operation
-         * If no error has occurred on stream, returns 0. Otherwise,
-         * it returns a nonzero value
-         *
-         * @return
-         */
-        virtual int32 GetContentAccessError() = 0;
-        /**
-         * Determines if the content is drm protected or not.
-         *
-         * @param aProtected set to true if protected, false otherwise.
-         * Value undefined in case of error
-         *
-         * @return returns PVMFSuccess if successful and an appropriate errcode
-         * otherwise
-         */
-        virtual PVMFStatus IsContentProtected(bool& aProtected) = 0;
-};
-
 #define PVMF_CPMPLUGIN_DECRYPTION_INTERFACE_MIMETYPE "pvxxx/pvmf/cpm/plugin/remote_sync_access_interface"
 #define PVMFCPMPluginDecryptionInterfaceUuid PVUuid(0x1e14b2fe,0x947b,0x49c8,0x8b,0x11,0xe9,0xec,0x4c,0x11,0xa2,0x8f)
 
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface_factory.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface_factory.h
index 72da045..a2bcabd 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface_factory.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_access_interface_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,9 @@
 #ifndef OSCL_BASE_H_INCLUDED
 #include "oscl_base.h"
 #endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
 #ifndef OSCL_TYPES_H_INCLUDED
 #include "oscl_types.h"
 #endif
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authentication_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authentication_interface.h
index 8ae0aa6..2685fee 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authentication_interface.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authentication_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authorization_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authorization_interface.h
index 4157a43..ebab9e2 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authorization_interface.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_authorization_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_contentmanagement_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_contentmanagement_interface.h
new file mode 100644
index 0000000..b175fcb
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_contentmanagement_interface.h
@@ -0,0 +1,426 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_CONTENTMANAGEMENT_INTERFACE_H_INCLUDED
+#define PVMF_CPMPLUGIN_CONTENTMANAGEMENT_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+
+#define PVMF_CPMPLUGIN_CONTENTMANAGEMENT_INTERFACE_MIMETYPE "pvxxx/pvmf/cpm/plugin/contentmanagement_interface"
+#define PVMFCPMPluginContentManagementInterfaceUuid PVUuid(0x8cf5b9d3, 0x14f9, 0x4ae0, 0xba, 0x46, 0x5c, 0xd7, 0xab, 0x4a, 0xfb, 0x48)
+
+#define PVMF_CONTENT_ENTRY_ATTRIB_UNDEFINED      0xFFFFFFFF
+#define PVMF_CONTENT_ENTRY_ATTRIB_NORMAL         0x00
+#define PVMF_CONTENT_ENTRY_ATTRIB_RDONLY         0x01
+#define PVMF_CONTENT_ENTRY_ATTRIB_HIDDEN         0x02
+#define PVMF_CONTENT_ENTRY_ATTRIB_SYSTEM         0x04
+#define PVMF_CONTENT_ENTRY_ATTRIB_DIRENTRY       0x10
+#define PVMF_CONTENT_ENTRY_ATTRIB_ARCHIVE        0x20
+
+class PVMFContentEntryProperties
+{
+    public:
+        PVMFContentEntryProperties()
+        {
+            iIsWChar         = false;
+            iEntrySizeOnDisk = 0;
+            iEntryAttributes = PVMF_CONTENT_ENTRY_ATTRIB_UNDEFINED;
+        };
+
+        PVMFContentEntryProperties(const PVMFContentEntryProperties& a)
+        {
+            iShortEntryName       = a.iShortEntryName;
+            iLongEntryName        = a.iLongEntryName;
+            iModificationDateTime = a.iModificationDateTime;
+            iEntrySizeOnDisk      = a.iEntrySizeOnDisk;
+            iEntryAttributes      = a.iEntryAttributes;
+            iIsWChar              = a.iIsWChar;
+        };
+
+        virtual ~PVMFContentEntryProperties()
+        {
+        };
+
+        PVMFContentEntryProperties& operator=(const PVMFContentEntryProperties& a)
+        {
+            if (&a != this)
+            {
+                iShortEntryName       = a.iShortEntryName;
+                iLongEntryName        = a.iLongEntryName;
+                iModificationDateTime = a.iModificationDateTime;
+                iEntrySizeOnDisk      = a.iEntrySizeOnDisk;
+                iEntryAttributes      = a.iEntryAttributes;
+                iIsWChar              = a.iIsWChar;
+            }
+            return *this;
+        };
+
+        void SetWideCharMode()
+        {
+            iIsWChar = true;
+        }
+
+        bool IsWideChar()
+        {
+            return iIsWChar;
+        }
+
+        /* Indicates if wide char or reg char strings are in use */
+        bool iIsWChar;
+        /* Just the entry name with extension */
+        OSCL_wHeapString<OsclMemAllocator> iShortEntryNameW;
+        OSCL_HeapString<OsclMemAllocator>  iShortEntryName;
+        /* Complete path of the entry from the root drive */
+        OSCL_wHeapString<OsclMemAllocator> iLongEntryNameW;
+        OSCL_HeapString<OsclMemAllocator>  iLongEntryName;
+        /* Entry Modification date and time in ISO 8601 format */
+        OSCL_wHeapString<OsclMemAllocator> iModificationDateTimeW;
+        OSCL_HeapString<OsclMemAllocator>  iModificationDateTime;
+        /* Entry size on disk - if entry is a file it would be the file size */
+        uint32 iEntrySizeOnDisk;
+        /* Entry attributes - viz. read only, directory etc */
+        uint32 iEntryAttributes;
+};
+
+/**
+ * Content Management interface for all Content Policy Manager Plugins
+ */
+class PVMFCPMPluginContentManagementInterface : public PVInterface
+{
+    public:
+        /**
+         * Method to mount a partition
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated unicode string containing the drive letter
+         *             say, X:\\
+         * @param [in] Null terminated unicode string containing the partition id
+         *             - not required for public partitions
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus MountPartition(PVMFSessionId aSessionId,
+                                          OSCL_wString& aDriveLetter,
+                                          OSCL_wString& aPartitionID) = 0;
+
+        /**
+         * Method to mount a partition
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated string containing the drive letter
+         *             say, X:\\
+         * @param [in] Null terminated string containing the partition id
+         *             - not required for public partitions
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus MountPartition(PVMFSessionId aSessionId,
+                                          OSCL_String& aDriveLetter,
+                                          OSCL_String& aPartitionID) = 0;
+
+        /**
+         * Method to unmount a partition
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated unicode string containing the drive letter
+         *             say, X:\\
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus UnMountPartition(PVMFSessionId aSessionId,
+                                            OSCL_wString& aDriveLetter) = 0;
+
+        /**
+         * Method to unmount a partition
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated string containing the drive letter
+         *             say, X:\\
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus UnMountPartition(PVMFSessionId aSessionId,
+                                            OSCL_String& aDriveLetter) = 0;
+
+        /**
+         * Method to get the current directory in a drive
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated unicode string containing the drive letter
+         *             say, X:\\
+         * @param [out] Path name of the current working directory, say
+         *              X:\\My Content
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus GetCurrentDirectory(PVMFSessionId aSessionId,
+                                               OSCL_wString& aDriveLetter,
+                                               OSCL_wString& aPath) = 0;
+
+        /**
+         * Method to get the current directory in a drive
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated string containing the drive letter
+         *             say, X:\\
+         * @param [out] Path name of the current working directory, say
+         *              X:\\My Content
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus GetCurrentDirectory(PVMFSessionId aSessionId,
+                                               OSCL_String&  aDriveLetter,
+                                               OSCL_String&  aPath) = 0;
+
+        /**
+         * Method to set current directory
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated unicode string containing the path
+         *             including the drive letter say, X:\\My Audios\\Album1
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus SetCurrentDirectory(PVMFSessionId aSessionId,
+                                               OSCL_wString& aPath) = 0;
+
+        /**
+         * Method to set current directory
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Null terminated string containing the path
+         *             including the drive letter say, X:\\My Audios\\Album1
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus SetCurrentDirectory(PVMFSessionId aSessionId,
+                                               OSCL_String&  aPath) = 0;
+
+        /**
+         * Method to get a listing of all the entries that match a pattern
+         * within a path
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aPath[in] Unicode string containing the path, say
+         *              X:\\My Videos
+         * @param aPatternList[in] List containing search pattern for entries, say *.3gp, *.wma etc
+         * @param aEntryList[out] List containing entry properties
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus GetEntriesInPath(PVMFSessionId aSessionId,
+                                            OSCL_wString& aPath,
+                                            Oscl_Vector<OSCL_wHeapString<OsclMemAllocator>, OsclMemAllocator> aPatternList,
+                                            Oscl_Vector<PVMFContentEntryProperties, OsclMemAllocator>& aEntryList) = 0;
+
+        /**
+         * Method to get a listing of all the entries that match a pattern
+         * within a path
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aPath[in] string containing the path, say
+         *              X:\\My Videos
+         * @param aPatternList[in] List containing search pattern for entries, say *.3gp, *.wma etc
+         * @param aEntryList[out] List containing entry properties
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus GetEntriesInPath(PVMFSessionId aSessionId,
+                                            OSCL_String&  aPath,
+                                            Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> aPatternList,
+                                            Oscl_Vector<PVMFContentEntryProperties, OsclMemAllocator>& aEntryList) = 0;
+
+        /**
+         * Method to rename a directory or file
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aOldPath Unicode string with current complete path
+         * @param aNewPath Unicode string with new complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus RenamePath(PVMFSessionId aSessionId,
+                                      OSCL_wString& aOldPath,
+                                      OSCL_wString& aNewPath) = 0;
+
+        /**
+         * Method to rename a directory or file
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aOldPath string with current complete path
+         * @param aNewPath string with new complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus RenamePath(PVMFSessionId aSessionId,
+                                      OSCL_String&  aOldPath,
+                                      OSCL_String&  aNewPath) = 0;
+
+        /**
+         * Method to create a directory
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aPath Unicode string with the complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus CreateDirectory(PVMFSessionId aSessionId,
+                                           OSCL_wString& aPath) = 0;
+
+        /**
+         * Method to create a directory
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aPath string with the complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus CreateDirectory(PVMFSessionId aSessionId,
+                                           OSCL_String&  aPath) = 0;
+
+        /**
+         * Method to remove a directory
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aPath Unicode string with the complete path
+         * @param aRecursive For recursive removal
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus DeleteDirectory(PVMFSessionId aSessionId,
+                                           OSCL_wString& aPath,
+                                           bool          aRecursive) = 0;
+
+        /**
+         * Method to remove a directory
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aPath string with the complete path
+         * @param aRecursive For recursive removal
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus DeleteDirectory(PVMFSessionId aSessionId,
+                                           OSCL_String&  aPath,
+                                           bool          aRecursive) = 0;
+
+        /**
+         * Method to remove a file
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aFileName Unicode string with the complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus DeleteFile(PVMFSessionId aSessionId,
+                                      OSCL_wString& aFileName) = 0;
+
+        /**
+         * Method to remove a file
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aFileName string with the complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus DeleteFile(PVMFSessionId aSessionId,
+                                      OSCL_String& aFileName) = 0;
+
+
+        /**
+         * Method to copy a file
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aSourceFileName unicode string with source file name, with complete path
+         * @param aTargetFileName unicode string with target file name, with complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus CopyFile(PVMFSessionId aSessionId,
+                                    OSCL_wString& aSourceFileName,
+                                    OSCL_wString& aTargetFileName) = 0;
+
+        /**
+         * Method to copy a file
+         *
+         * @param aSessionId The assigned plugin session ID to use for this request
+         * @param aSourceFileName string with source file name, with complete path
+         * @param aTargetFileName string with target file name, with complete path
+         *
+         * @returns PVMFSuccess
+         *          PVMFFailure - In case of errors
+         */
+        virtual PVMFStatus CopyFile(PVMFSessionId aSessionId,
+                                    OSCL_String&  aSourceFileName,
+                                    OSCL_String&  aTargetFileName) = 0;
+
+        virtual PVMFStatus IsFileProtected(PVMFSessionId aSessionId,
+                                           OSCL_wString& aFileName,
+                                           bool& aProtected) = 0;
+
+        virtual PVMFStatus IsFileProtected(PVMFSessionId aSessionId,
+                                           OSCL_String& aFileName,
+                                           bool& aProtected) = 0;
+
+        virtual PVMFStatus GetNumExportsLeft(PVMFSessionId aSessionId,
+                                             OSCL_wString& aFileName,
+                                             uint32& aNumExports) = 0;
+
+        virtual PVMFStatus GetNumExportsLeft(PVMFSessionId aSessionId,
+                                             OSCL_String& aFileName,
+                                             uint32& aNumExports) = 0;
+};
+
+
+#endif //PVMF_CPMPLUGIN_CONTENTMANAGEMENT_INTERFACE_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_decryption_context.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_decryption_context.h
new file mode 100644
index 0000000..c3b398b
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_decryption_context.h
@@ -0,0 +1,83 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_DECRYPTION_CONTEXT_H_INCLUDED
+#define PVMF_CPMPLUGIN_DECRYPTION_CONTEXT_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+
+#define PVMFCPMPluginWMDRMDecryptContextUuid PVUuid(0x19c4fdb8,0x2165,0x4f10,0xa5,0x53,0x72,0x76,0xd7,0xc6,0xb1,0x2a)
+
+/**
+ * Metering interface for all Content Policy Manager Plugins
+ */
+class PVMFCPMPluginWMDRMDecryptContext : public PVInterface
+{
+    public:
+        PVMFCPMPluginWMDRMDecryptContext()
+        {
+            iRef = 0;
+            Oscl_Int64_Utils::set_uint64(iSampleID, 0, 0);
+            iMediaObjectStartOffset = 0;
+        };
+
+        virtual ~PVMFCPMPluginWMDRMDecryptContext()
+        {
+        };
+
+        void addRef()
+        {
+            iRef++;
+        };
+
+        void removeRef()
+        {
+            iRef--;
+        };
+
+        bool queryInterface(const PVUuid& uuid,
+                            PVInterface*& iface)
+        {
+            iface = NULL;
+            if (uuid == PVMFCPMPluginWMDRMDecryptContextUuid)
+            {
+                iface = OSCL_STATIC_CAST(PVInterface*, this);
+                return true;
+            }
+            return false;
+        };
+
+        uint64 iSampleID;
+        uint32 iMediaObjectStartOffset;
+
+    private:
+        uint32 iRef;
+};
+
+#endif //PVMF_CPMPLUGIN_DECRYPTION_CONTEXT_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_domain_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_domain_interface.h
new file mode 100644
index 0000000..cce6296
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_domain_interface.h
@@ -0,0 +1,131 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_DOMAIN_INTERFACE_H_INCLUDED
+#define PVMF_CPMPLUGIN_DOMAIN_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+#include "pvmf_return_codes.h"
+#include "pvmf_event_handling.h"
+#include "pvmf_cpmplugin_domain_interface_types.h"
+
+#define PVMF_CPMPLUGIN_DOMAIN_INTERFACE_MIMETYPE "pvxxx/pvmf/cpm/plugin/domain_interface"
+#define PVMFCPMPluginDomainInterfaceUuid PVUuid(0x379e6e10,0x8a53,0x11db,0xb6,0x06,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
+
+/**
+ * License interface for all Content Policy Manager Plugins
+ */
+class PVMFCPMPluginDomainInterface : public PVInterface
+{
+    public:
+        /**
+         * Method to get the current number of domains
+         *
+         * @param [out] aCount: number of domains
+         * @param [out] errcode: error code in case of failure.
+         *
+         * @returns PVMFSuccess or an error.
+         */
+        virtual PVMFStatus GetDomainCount(
+            uint32& aCount
+            , uint32& errcode) = 0;
+
+        /**
+         * Method to get the current domains.
+         *
+         * @param [in] aIndex: zero-based index of the desired domain info.
+         *
+         * @param [out] aDomainCertData the domain cert data.
+         *
+         * @param [out] errcode: error code in case of failure.
+         *
+         * @returns PVMFSuccess or an error.
+         */
+        virtual PVMFStatus GetDomain(
+            uint32 aIndex
+            , PVMFCPMDomainCertData& aDomainCertData
+            , uint32& errcode) = 0;
+
+        /**
+         * Method to check existence of a domain certificate.
+         *
+         * @param [in] aDomainId: ID of the domain to check
+         *
+         * @param [out] errcode: error code in case of failure.
+         *
+         * @returns PVMFSuccess or an error.
+         */
+        virtual PVMFStatus CheckDomainCertificate(
+            const PVMFCPMDomainId& aDomainId
+            , uint32& errcode) = 0;
+
+        /**
+         * Method to join a domain
+         *
+         * @param [in] aSessionId: The assigned plugin session ID to use for this request
+         *
+         * @param [in] aJoinData: request parameters.
+         *
+         * @param [in] Timeout for the request in milliseconds, or (-1) for
+         *   infinite wait.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId JoinDomain(
+            PVMFSessionId aSessionId
+            , const PVMFCPMDomainJoinData& aJoinData
+            , int32 aTimeoutMsec = (-1)) = 0;
+
+        /**
+         * Method to leave a domain
+         *
+         * @param [in] aSessionId: The assigned plugin session ID to use for this request
+         *
+         * @param [in] aLeaveData: request parameters.
+         *
+         * @param [in] Timeout for the request in milliseconds, or (-1) for
+         *   infinite wait.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId LeaveDomain(
+            PVMFSessionId aSessionId
+            , const PVMFCPMDomainLeaveData& aLeaveData
+            , int32 aTimeoutMsec = (-1)) = 0;
+
+};
+
+#endif //PVMF_CPMPLUGIN_DOMAIN_INTERFACE_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_domain_interface_types.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_domain_interface_types.h
new file mode 100644
index 0000000..9ae0637
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_domain_interface_types.h
@@ -0,0 +1,164 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_DOMAIN_INTERFACE_TYPES_H_INCLUDED
+#define PVMF_CPMPLUGIN_DOMAIN_INTERFACE_TYPES_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+
+#define PVMF_EMPTY_GUID PVUuid(0,0,0,0,0,0,0,0,0,0,0)
+
+class PVMFCPMDomainId
+{
+    public:
+        PVMFCPMDomainId()
+                : iServiceId(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+                , iAccountId(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
+                , iRevision(0)
+        {}
+        PVMFCPMDomainId(const PVMFCPMDomainId& aVal)
+        {
+            iServiceId = aVal.iServiceId;
+            iAccountId = aVal.iAccountId;
+            iRevision = aVal.iRevision;
+        }
+        void SetServiceId(uint8 b0, uint8 b1, uint8 b2, uint8 b3
+                          , uint8 b4, uint8 b5, uint8 b6, uint8 b7, uint8 b8
+                          , uint8 b9, uint8 b10, uint8 b11, uint8 b12
+                          , uint8 b13, uint8 b14, uint8 b15)
+        {
+            uint8* pos = (uint8*) & iServiceId;
+            *pos++ = b0;
+            *pos++ = b1;
+            *pos++ = b2;
+            *pos++ = b3;
+            *pos++ = b4;
+            *pos++ = b5;
+            *pos++ = b6;
+            *pos++ = b7;
+            *pos++ = b8;
+            *pos++ = b9;
+            *pos++ = b10;
+            *pos++ = b11;
+            *pos++ = b12;
+            *pos++ = b13;
+            *pos++ = b14;
+            *pos++ = b15;
+        }
+        void SetAccountId(uint8 b0, uint8 b1, uint8 b2, uint8 b3
+                          , uint8 b4, uint8 b5, uint8 b6, uint8 b7, uint8 b8
+                          , uint8 b9, uint8 b10, uint8 b11, uint8 b12
+                          , uint8 b13, uint8 b14, uint8 b15)
+        {
+            uint8* pos = (uint8*) & iAccountId;
+            *pos++ = b0;
+            *pos++ = b1;
+            *pos++ = b2;
+            *pos++ = b3;
+            *pos++ = b4;
+            *pos++ = b5;
+            *pos++ = b6;
+            *pos++ = b7;
+            *pos++ = b8;
+            *pos++ = b9;
+            *pos++ = b10;
+            *pos++ = b11;
+            *pos++ = b12;
+            *pos++ = b13;
+            *pos++ = b14;
+            *pos++ = b15;
+        }
+        PVUuid iServiceId;
+        PVUuid iAccountId;
+        uint32 iRevision;
+};
+
+//Data associated with a Domain Join request
+class PVMFCPMDomainJoinData
+{
+    public:
+        PVMFCPMDomainJoinData()
+                : iDomainUrl(NULL)
+                , iFlags(0)
+                , iFriendlyName(NULL)
+                , iCustomData(NULL)
+                , iCustomDataLen(0)
+        {}
+
+        OSCL_String* iDomainUrl;	//the domain server URL
+
+        uint32 iFlags;				//Flag that indicates the type of custom data.
+
+        PVMFCPMDomainId iDomainId;	//Domain ID to be registered with the server.
+
+        OSCL_String* iFriendlyName;	//Pointer to the friendly name. Can be NULL.
+
+        uint8* iCustomData;			//Optional custom data.  Can be NULL
+        uint32 iCustomDataLen;		//length of the custom data in bytes.
+};
+
+//Data associated with a Domain Leave request
+class PVMFCPMDomainLeaveData
+{
+    public:
+        PVMFCPMDomainLeaveData()
+                : iDomainUrl(NULL)
+                , iFlags(0)
+                , iCustomData(NULL)
+                , iCustomDataLen(0)
+        {}
+
+        OSCL_String* iDomainUrl;	//Domain URL.
+
+        uint32 iFlags;				//Flag that indicates the type of custom data.
+
+        PVMFCPMDomainId iDomainId;	//Domain ID to be unregistered with the server.
+
+        uint8* iCustomData;			//Pointer to a buffer that contains the custom data
+        //sent to the server. The format of the custom data
+        //is based on the value of iFlags. It may be NULL.
+
+        uint32 iCustomDataLen;		//Size (in bytes) of the custom data buffer.
+        //It must be 0 if iCustomData is NULL.
+};
+
+//Data output by GetDomain request.
+class PVMFCPMDomainCertData
+{
+    public:
+        PVMFCPMDomainId iDomainId;//Domain ID
+
+        OSCL_HeapString<OsclMemAllocator> iUrl;//a URL in the domain cert.  Not used currently.
+};
+
+
+#endif //PVMF_CPMPLUGIN_DOMAIN_INTERFACE_TYPES_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_interface.h
index 19c90fc..e173f41 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_interface.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -273,5 +273,31 @@
         virtual ~PVMFCPMPluginFactory() {}
 };
 
+/**
+ * Content Policy Manager Plugin Registry Populator interface for use
+ * with dynamic loading.
+ */
+class OSCL_String;
+class PVMFCPMPluginRegistryPopulator
+{
+    public:
+        /*
+        ** GetFactoryAndMimeString.  Called by CPM framework to retrieve the plugin factory and
+        **   plugin mimestring.  Note this will be called twice-- when creating the plugin and
+        **   again when destroying the plugin.
+        **
+        ** @param (out) aMimestring: the plugin mimestring
+        ** @return : factory pointer.
+        */
+        virtual PVMFCPMPluginFactory* GetFactoryAndMimeString(OSCL_String& aMimestring) = 0;
+        /*
+        ** ReleaseFactory.  Called by CPM framework to indicate that the the plugin factory
+        **   retrieved by prior calls to GetFactoryAndMimeString is no longer needed.
+        */
+        virtual void ReleaseFactory() = 0;
+};
+
+#define PVMF_CPM_PLUGIN_REGISTRY_POPULATOR_UUID OsclUuid(0x8c988150,0x9b1b,0x11dd,0xad,0x8b,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
 #endif //PVMF_CPMPLUGIN_INTERFACE_H_INCLUDED
 
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface.h
index 6f0e767..fc75204 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,10 @@
 #ifndef PV_INTERFACE_H_INCLUDED
 #include "pv_interface.h"
 #endif
+#ifndef OSCL_BASE_MACROS_H_INCLUDED
+#include "oscl_base_macros.h"
+#endif
+
 #include "pvmf_return_codes.h"
 #include "pvmf_event_handling.h"
 
@@ -141,6 +145,7 @@
         virtual PVMFStatus GetLicenseStatus(
             PVMFCPMLicenseStatus& aStatus)
         {
+            OSCL_UNUSED_ARG(&aStatus);
             return PVMFErrNotSupported;
         };
 };
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface_types.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface_types.h
index 35bc575..cc8a518 100644
--- a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface_types.h
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_interface_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_manager_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_manager_interface.h
new file mode 100644
index 0000000..524530b
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_manager_interface.h
@@ -0,0 +1,153 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_LICENSE_MANAGER_INTERFACE_H_INCLUDED
+#define PVMF_CPMPLUGIN_LICENSE_MANAGER_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+#include "pvmf_return_codes.h"
+#include "pvmf_event_handling.h"
+#include "pvmf_cpmplugin_license_manager_interface_types.h"
+
+#define PVMF_CPMPLUGIN_LICENSE_MANAGER_INTERFACE_MIMETYPE "pvxxx/pvmf/cpm/plugin/license_manager_interface"
+#define PVMFCPMPluginLicenseManagerInterfaceUuid PVUuid(0x05b8186a,0xc2b1,0x11db,0x83,0x14,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
+/**
+ * License Manager interface for all Content Policy Manager Plugins
+ */
+class PVMFCPMPluginLicenseManagerInterface : public PVInterface
+{
+    public:
+
+        /**
+         * Method to clean license store
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] Optional opaque data associated with the request.
+         * @param [in] Size of the optional opaque data.
+         * @param [in] aContextData: optional caller data to accompany the
+         *   request.  The value will be included in the completion callback.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId CleanLicenseStore(PVMFSessionId aSessionId
+                                                , OsclAny* aData = NULL
+                                                                   , uint32 aDataSize = 0
+                                                                                        , OsclAny* aContext = NULL) = 0;
+
+        /**
+         * Method to get the status of an ongoing or recently completed
+         * clean license store command.
+         *
+         * @param [out] aStatus: clean store status output
+         *
+         * @returns: PVMFSuccess if status is available, an error
+         *   otherwise.
+         */
+        virtual PVMFStatus GetCleanLicenseStoreStatus(
+            PVMFCPMCleanLicenseStoreStatus& aStatus) = 0;
+
+        /**
+         * Method to delete a license from the store
+         *
+         * @param [in] The assigned plugin session ID to use for this request
+         * @param [in] PVMFCPMContentId: content ID data blob.
+         * @param [in] aContextData: optional caller data to accompany the
+         *   request.  The value will be included in the completion callback.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId DeleteLicense(PVMFSessionId aSessionId
+                                            , const PVMFCPMContentId& aContentId
+                                            , OsclAny* aContext = NULL) = 0;
+
+        /**
+         * Method to update current licenses by requesting new licenses
+         * from the server.  When the number of licenses is large, the update can be done
+         * in multiple calls by using the aStartingIndex and aMaxNumberofLicenses parameters
+         * to control the range of licenses updated.  The "hours remaining" and "count remaining"
+         * parameters can be used to control how time and count-based licenses are updated.
+         *
+         * To get status during or after this operation, use GetLicenseUpdateStatus.
+         * To interrupt and cancel the sequence, use the plugin CancelCommand API.
+         *
+         * @param [in] aSessionId: The assigned plugin session ID to use for this request
+         * @param [out] aLastLicenseProcessed: The 0-based index of the last license processed
+         *   by the request.
+         * @param [in] aStartingIndex: The 0-based index of the first license to process.
+         * @param [in] aMaxNumberOfLicenses: The maximum number of licenses to update in this
+         *   request.  To update all licenses, use (-1).
+         * @param [in] aHoursRemaining: For time-based licenses, update only those that have
+         *    less than the specified value of hours remaining.  To update all time-based
+         *    licenses regardless of the time remaining, use (-1).
+         * @param [in] aCountRemaining: For counted licenses, update only those that have
+         *    less than the specified number of play counts remaining.  To update all counted
+         *    licenses regardless of the counts remaining, use (-1).
+         * @param [in] aCustomData, aCustomDataSize: Optional opaque data for additional inputs.
+         * @param [in] aTimeoutMsec: Optional timeout in milliseconds
+         *    for each server communication.  Use -1 to indicate infinite wait.
+         * @param [in] aContextData: Optional caller data to accompany the
+         *   request.  The value will be included in the completion callback.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId UpdateLicenses(
+            PVMFSessionId aSessionId
+            , int32& aLastLicenseProcessed
+            , uint32 aStartingIndex = 0
+                                      , int32 aMaxNumberOfLicenses = (-1)
+                                                                     , int32 aHoursRemaining = (-1)
+                                                                                               , int32 aCountRemaining = (-1)
+                                                                                                                         , OsclAny* aCustomData = NULL
+                                                                                                                                                  , uint32 aCustomDataSize = 0
+                                                                                                                                                                             , int32 aTimeoutMsec = (-1)
+                                                                                                                                                                                                    , OsclAny* aContext = NULL) = 0;
+
+        /**
+         * Method to get the status of an ongoing or recently completed
+         * license update sequence.
+         *
+         * @param [out] aStatus: meter status output
+         *
+         * @returns: PVMFSuccess if meter status is available, an error
+         *   otherwise.
+         */
+        virtual PVMFStatus GetLicenseUpdateStatus(
+            PVMFCPMLicenseUpdateStatus& aStatus) = 0;
+
+};
+
+
+#endif //PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_manager_interface_types.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_manager_interface_types.h
new file mode 100644
index 0000000..0ef5cba
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_license_manager_interface_types.h
@@ -0,0 +1,189 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_LICENSE_MANAGER_INTERFACE_TYPES_H_INCLUDED
+#define PVMF_CPMPLUGIN_LICENSE_MANAGER_INTERFACE_TYPES_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+
+
+//A class to hold a content ID.
+class PVMFCPMContentId
+{
+    public:
+        PVMFCPMContentId(): iData(NULL), iDataLen(0)
+        {}
+
+        PVMFCPMContentId(const PVMFCPMContentId& aVal)
+        {
+            iData = NULL;
+            iDataLen = 0;
+            Set(aVal);
+        }
+
+        ~PVMFCPMContentId()
+        {
+            if (iData)
+                OSCL_FREE(iData);
+            iData = NULL;
+        }
+
+        void Set(uint8* aData, uint32 aDataLen)
+        {
+            if (iData)
+                OSCL_FREE(iData);
+            iData = NULL;
+            if (aDataLen)
+            {
+                iData = (uint8*)OSCL_MALLOC(aDataLen);
+                if (iData)
+                    oscl_memcpy(iData, aData, aDataLen);
+                iDataLen = aDataLen;
+            }
+        }
+        void Set(const PVMFCPMContentId& aId)
+        {
+            Set(aId.iData, aId.iDataLen);
+        }
+
+        uint8* iData;
+        uint32 iDataLen;
+};
+
+//A class to hold information about a license request
+class PVMFCPMLicenseUpdateInfo
+{
+    public:
+        PVMFCPMLicenseUpdateInfo(): iValid(false)
+        {}
+
+        //Tells whether data in this class is valid
+        bool iValid;
+
+        //The 0-based index of this entry in the sync store.
+        int32 iLicenseSyncIndex;
+
+        //The ID of this entry
+        PVMFCPMContentId iLicenseSyncId;
+
+        //The URL of the license server for this content.
+        OSCL_HeapString<OsclMemAllocator> iURL;
+
+        void Clear()
+        {
+            iValid = false;
+            iLicenseSyncId.Set(NULL, 0);
+        }
+        void Set(const PVMFCPMLicenseUpdateInfo& aInfo)
+        {
+            iValid = aInfo.iValid;
+            iLicenseSyncIndex = aInfo.iLicenseSyncIndex;
+            iLicenseSyncId.Set(aInfo.iLicenseSyncId);
+            iURL = aInfo.iURL;
+        }
+};
+
+//A class to hold license update status information
+class PVMFCPMLicenseUpdateStatus
+{
+    public:
+        PVMFCPMLicenseUpdateStatus():
+                iNumLicenseChallengesSent(0)
+                , iNumLicenseResponsesReceived(0)
+                , iLastLicenseResponseResult(0)
+                , iNumLicenseAckChallengesSent(0)
+                , iNumLicenseAckResponsesReceived(0)
+                , iLastLicenseAckResponseResult(0)
+        {}
+
+        //Information about the last entry processed.
+        PVMFCPMLicenseUpdateInfo iLicenseUpdateInfo;
+
+        //Number of license challenges sent
+        uint32 iNumLicenseChallengesSent;
+
+        //Number of license responses received
+        uint32 iNumLicenseResponsesReceived;
+
+        //Result of processing the last license response
+        uint32 iLastLicenseResponseResult;
+
+        //Number of license ack challenges sent
+        uint32 iNumLicenseAckChallengesSent;
+
+        //Number of license ack responses received
+        uint32 iNumLicenseAckResponsesReceived;
+
+        //Result of processing the last license ack response
+        uint32 iLastLicenseAckResponseResult;
+
+        void Clear()
+        {
+            iLicenseUpdateInfo.Clear();
+            iNumLicenseChallengesSent = 0;
+            iNumLicenseResponsesReceived = 0;
+            iLastLicenseResponseResult = 0;
+            iNumLicenseAckChallengesSent = 0;
+            iNumLicenseAckResponsesReceived = 0;
+            iLastLicenseAckResponseResult = 0;
+        }
+        void Set(const PVMFCPMLicenseUpdateStatus& aStatus)
+        {
+            iLicenseUpdateInfo.Set(aStatus.iLicenseUpdateInfo);
+            iNumLicenseChallengesSent = aStatus.iNumLicenseChallengesSent;
+            iNumLicenseResponsesReceived = aStatus.iNumLicenseResponsesReceived;
+            iLastLicenseResponseResult = aStatus.iLastLicenseResponseResult;
+            iNumLicenseAckChallengesSent = aStatus.iNumLicenseAckChallengesSent;
+            iNumLicenseAckResponsesReceived = aStatus.iNumLicenseAckResponsesReceived;
+            iLastLicenseAckResponseResult = aStatus.iLastLicenseAckResponseResult;
+        }
+};
+
+//A class to hold license cleanup status
+class PVMFCPMCleanLicenseStoreStatus
+{
+    public:
+        PVMFCPMCleanLicenseStoreStatus():
+                iLicensesProcessed(0)
+                , iTotalLicenses(0)
+        {}
+
+        //Number of licenses processed
+        uint32 iLicensesProcessed;
+
+        //Total number of licenses in the store.
+        uint32 iTotalLicenses;
+
+        void Clear()
+        {
+            iLicensesProcessed = 0;
+            iTotalLicenses = 0;
+        }
+        void Set(const PVMFCPMCleanLicenseStoreStatus& aStatus)
+        {
+            iLicensesProcessed = aStatus.iLicensesProcessed;
+            iTotalLicenses = aStatus.iTotalLicenses;
+        }
+};
+
+#endif //PVMF_CPMPLUGIN_LICENSE_MANAGER_INTERFACE_TYPES H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_metering_interface.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_metering_interface.h
new file mode 100644
index 0000000..716a8fe
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_metering_interface.h
@@ -0,0 +1,161 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_METERING_INTERFACE_H_INCLUDED
+#define PVMF_CPMPLUGIN_METERING_INTERFACE_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef PV_UUID_H_INCLUDED
+#include "pv_uuid.h"
+#endif
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+#include "pvmf_return_codes.h"
+#include "pvmf_event_handling.h"
+#include "pvmf_cpmplugin_metering_interface_types.h"
+
+#define PVMF_CPMPLUGIN_METERING_INTERFACE_MIMETYPE "pvxxx/pvmf/cpm/plugin/metering_interface"
+#define PVMFCPMPluginMeteringInterfaceUuid PVUuid(0x5efe8be0,0xb62f,0x11db,0xab,0xbd,0x08,0x00,0x20,0x0c,0x9a,0x66)
+
+
+/**
+ * Metering interface for all Content Policy Manager Plugins
+ */
+class PVMFCPMPluginMeteringInterface : public PVInterface
+{
+    public:
+        /**
+         * Method to save a meter certificate in the store.
+         * This method is intended to be used in scenarios where
+         * it is not possible to obtain the metering certificate
+         * directly from the server.
+         *
+         * @param [in] aSessionId: The observer session Id.
+         * @param [in] aMeterCert: The meter certificate data as a wide-string.
+         * @param [out] optional output metering ID
+         * @param [in] aTimeoutMsec: Optional timeout in milliseconds
+         *    for each server communication.  Use -1 to indicate infinite wait.
+         * @param [in] aContextData: Optional user data that will be returned
+         *    in the command completion callback.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId UpdateMeterCertificate(
+            PVMFSessionId aSessionId
+            , OSCL_wString& aMeterCert
+            , PVMFCPMMeterId* aMeterId = NULL
+                                         , int32 aTimeoutMsec = (-1)
+                                                                , OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Method to report metering data for a specific Meter ID.
+         * The meter cert store will be searched for a certificate with
+         * the given meter ID.  If the meter ID is found but there is no
+         * certificate, then an attempt will be made to acquire the
+         * certificate from the server.  If the certificate is acquired
+         * successfully then metering will be reported for that certificate.
+         *
+         * To get status during or after this operation, use GetMeteringStatus.
+         * To interrupt and cancel metering, use the plugin CancelCommand.
+         *
+         * @param [in] aSessionId: The observer session Id.
+         * @param [in] aMaxDataSize: The maximum data size for
+         *    each metering data buffer to be sent to the server.
+         *    If there is more data than this size, then multiple
+         *    server transactions will be done automatically.
+         * @param [in] aMeterId: The metering Id.
+         * @param [out] aStatus: Optional meter status output
+         * @param [in] aTimeoutMsec: Optional timeout in milliseconds
+         *    for each server communication.  Use -1 to indicate infinite wait.
+         * @param [in] aContextData: Optional user data that will be returned
+         *    in the command completion callback.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId ReportMeteringData(
+            PVMFSessionId aSessionId
+            , uint32 aMaxDataSize
+            , const PVMFCPMMeterId& aMeterId
+            , int32 aTimeoutMsec = (-1)
+                                   , OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Method to report metering data by iterating through the meter
+         * cert store.
+         * This method may acquire meter certs from a server.
+         *
+         * To get status during or after this operation, use GetMeteringStatus.
+         * To interrupt and cancel metering, use the plugin CancelCommand..
+         *
+         * @param [in] aSessionId: The observer session Id.
+         * @param [in] aMaxDataSize: The maximum data size for
+         *    each metering data buffer to be sent to the server.
+         *    If there is more data than this size, then multiple
+         *    server transactions will be done automatically.
+         * @param [in] aTimeoutMsec: Optional timeout in milliseconds
+         *    for each server communication.  Use -1 to indicate infinite wait.
+         * @param [in] aContextData: Optional user data that will be returned
+         *    in the command completion callback.
+         *
+         * @returns A unique command id for asynchronous completion.
+         */
+        virtual PVMFCommandId ReportMeteringData(
+            PVMFSessionId aSessionId
+            , uint32 aMaxDataSize
+            , int32 aTimeoutMsec = (-1)
+                                   , OsclAny* aContextData = NULL) = 0;
+
+        /**
+         * Method to get a list of all MIDs in the current meter cert store.
+         *
+         * @param [out] aMeterCertList: List of all MIDs.
+         * @param [out] aErrCode: Error code
+         *
+         * @returns: PVMFSuccess or an error.
+         */
+        virtual PVMFStatus GetMeterCertMIDList(
+            Oscl_Vector<PVMFCPMMeterId, OsclMemAllocator>& aMeterCertList,
+            uint32& aErrCode) = 0;
+
+        /**
+         * Method to get the status of an ongoing or recently completed
+         * metering sequence.
+         *
+         * @param [out] aStatus: meter status output
+         *
+         * @returns: PVMFSuccess if meter status is available, an error
+         *   otherwise.
+         */
+        virtual PVMFStatus GetMeteringStatus(
+            PVMFCPMMeterStatus& aStatus) = 0;
+
+};
+
+#endif //PVMF_CPMPLUGIN_DOMAIN_INTERFACE_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_metering_interface_types.h b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_metering_interface_types.h
new file mode 100644
index 0000000..008050e
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/common/include/pvmf_cpmplugin_metering_interface_types.h
@@ -0,0 +1,173 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_CPMPLUGIN_METERING_INTERFACE_TYPES_H_INCLUDED
+#define PVMF_CPMPLUGIN_METERING_INTERFACE_TYPES_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+
+//A class to hold a metering ID.
+class PVMFCPMMeterId
+{
+    public:
+        PVMFCPMMeterId(): iData(NULL), iDataLen(0)
+        {}
+
+        PVMFCPMMeterId(const PVMFCPMMeterId& aVal)
+        {
+            iData = NULL;
+            iDataLen = 0;
+            Set(aVal);
+        }
+
+        ~PVMFCPMMeterId()
+        {
+            if (iData)
+                OSCL_FREE(iData);
+            iData = NULL;
+        }
+
+        void Set(uint8* aData, uint32 aDataLen)
+        {
+            if (iData)
+                OSCL_FREE(iData);
+            iData = NULL;
+            if (aDataLen)
+            {
+                iData = (uint8*)OSCL_MALLOC(aDataLen);
+                if (iData)
+                    oscl_memcpy(iData, aData, aDataLen);
+                iDataLen = aDataLen;
+            }
+        }
+        void Set(const PVMFCPMMeterId& aId)
+        {
+            Set(aId.iData, aId.iDataLen);
+        }
+
+        uint8* iData;
+        uint32 iDataLen;
+};
+
+//A class to hold information about a metering certificate
+class PVMFCPMMeterCertInfo
+{
+    public:
+        PVMFCPMMeterCertInfo(): iValid(false)
+        {}
+
+        //Tells whether data in this class is valid
+        bool iValid;
+
+        //The ID of this metering certificate
+        PVMFCPMMeterId iMeterId;
+
+        //The URL of the metering service.
+        OSCL_wHeapString<OsclMemAllocator> iURL;
+
+        //Tells if the server is V2 (Janus).
+        bool iIsV2;
+
+        void Clear()
+        {
+            iValid = false;
+            iMeterId.Set(NULL, 0);
+            iIsV2 = false;
+        }
+        void Set(const PVMFCPMMeterCertInfo& aInfo)
+        {
+            iValid = aInfo.iValid;
+            if (iValid)
+            {
+                iMeterId.Set(aInfo.iMeterId);
+                iURL = aInfo.iURL;
+                iIsV2 = aInfo.iIsV2;
+            }
+        }
+};
+
+//A class to hold meter status information
+class PVMFCPMMeterStatus
+{
+    public:
+        PVMFCPMMeterStatus():
+                iNumMeterCertChallengesSent(0)
+                , iNumMeterCertResponsesReceived(0)
+                , iLastMeterCertResponseResult(0)
+                , iNumMeterChallengesSent(0)
+                , iNumMeterResponsesReceived(0)
+                , iLastMeterResponseResult(0)
+        {}
+
+        //Information about the last entry retrieved from
+        //the meter cert store.
+        PVMFCPMMeterCertInfo iMeterCertInfo;
+
+
+        //Number of meter cert challenges sent
+        uint32 iNumMeterCertChallengesSent;
+
+        //Number of meter cert responses received
+        uint32 iNumMeterCertResponsesReceived;
+
+        //Result of processing the last meter cert response
+        uint32 iLastMeterCertResponseResult;
+
+        //Number of meter challenges sent
+        uint32 iNumMeterChallengesSent;
+
+        //Number of meter responses received
+        uint32 iNumMeterResponsesReceived;
+
+        //result of processing the last meter response
+        uint32 iLastMeterResponseResult;
+
+        //The URL of the  metering server for this content.
+        OSCL_HeapString<OsclMemAllocator> iLastMeterURL;
+
+        void Clear()
+        {
+            iMeterCertInfo.Clear();
+            iNumMeterCertChallengesSent = 0;
+            iNumMeterCertResponsesReceived = 0;
+            iLastMeterCertResponseResult = 0;
+            iNumMeterChallengesSent = 0;
+            iNumMeterResponsesReceived = 0;
+            iLastMeterResponseResult = 0;
+            iLastMeterURL = "";
+        }
+        void Set(const PVMFCPMMeterStatus& aStatus)
+        {
+            iMeterCertInfo.Set(aStatus.iMeterCertInfo);
+            iNumMeterCertChallengesSent = aStatus.iNumMeterCertChallengesSent;
+            iNumMeterCertResponsesReceived = aStatus.iNumMeterCertResponsesReceived;
+            iLastMeterCertResponseResult = aStatus.iLastMeterCertResponseResult;
+            iNumMeterChallengesSent = aStatus.iNumMeterChallengesSent;
+            iNumMeterResponsesReceived = aStatus.iNumMeterResponsesReceived;
+            iLastMeterResponseResult = aStatus.iLastMeterResponseResult;
+            iLastMeterURL = aStatus.iLastMeterURL;
+        }
+};
+
+
+#endif //PVMF_CPMPLUGIN_METERING_INTERFACE_TYPES_H_INCLUDED
+
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk b/pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk
index f6d4679..4a14166 100644
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk
@@ -2,30 +2,33 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvmf_cpmplugin_passthru_oma1.cpp
-
+ 	src/pvmf_cpmplugin_passthru_oma1.cpp
 
 
 LOCAL_MODULE := libpassthru_oma1
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/src \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/../../common/include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/../../../include \
-	$(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/../../../../../nodes/common/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/content_policy_manager/plugins/oma1/passthru/src \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/oma1/passthru/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/oma1/passthru/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/plugins/common/include \
+ 	$(PV_TOP)/pvmi/content_policy_manager/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_cpmplugin_passthru_oma1.h \
-	include/pvmf_cpmplugin_passthru_oma1_types.h \
-	include/pvmf_cpmplugin_passthru_oma1_factory.h
+ 	include/pvmf_cpmplugin_passthru_oma1_types.h \
+ 	include/pvmf_cpmplugin_passthru_oma1_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/build/make/local.mk b/pvmi/content_policy_manager/plugins/oma1/passthru/build/make/local.mk
new file mode 100644
index 0000000..69b7ce8
--- /dev/null
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := passthru_oma1
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../include
+XINCDIRS +=  ../../../../common/include
+XINCDIRS +=  ../../../../../include
+XINCDIRS +=  ../../../../../../../nodes/common/include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_cpmplugin_passthru_oma1.cpp
+
+HDRS := pvmf_cpmplugin_passthru_oma1.h \
+	pvmf_cpmplugin_passthru_oma1_types.h \
+	pvmf_cpmplugin_passthru_oma1_factory.h
+
+
+include $(MK)/library.mk
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/build/make/makefile b/pvmi/content_policy_manager/plugins/oma1/passthru/build/make/makefile
deleted file mode 100644
index 6d285ab..0000000
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/build/make/makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = passthru_oma1
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this so that correct headers for player get included
-XINCDIRS += -I ../../include
-XINCDIRS += -I ../../../../common/include
-XINCDIRS += -I ../../../../../include
-XINCDIRS += -I ../../../../../../../nodes/common/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_cpmplugin_passthru_oma1.cpp
-
-HDRS =  pvmf_cpmplugin_passthru_oma1.h \
-	pvmf_cpmplugin_passthru_oma1_types.h \
-	pvmf_cpmplugin_passthru_oma1_factory.h
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1.h b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1.h
index e74ef71..78ccb7c 100644
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1.h
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_config.h b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_config.h
index cc00d8f..5877bce 100644
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_config.h
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_config.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_factory.h b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_factory.h
index 74f2081..0c3f45e 100644
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_factory.h
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_types.h b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_types.h
index 85ecb46..6f45c3d 100644
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_types.h
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/include/pvmf_cpmplugin_passthru_oma1_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/content_policy_manager/plugins/oma1/passthru/src/pvmf_cpmplugin_passthru_oma1.cpp b/pvmi/content_policy_manager/plugins/oma1/passthru/src/pvmf_cpmplugin_passthru_oma1.cpp
index 5463cd4..e9580cc 100644
--- a/pvmi/content_policy_manager/plugins/oma1/passthru/src/pvmf_cpmplugin_passthru_oma1.cpp
+++ b/pvmi/content_policy_manager/plugins/oma1/passthru/src/pvmf_cpmplugin_passthru_oma1.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -308,8 +308,16 @@
         OsclAny* aSourceData)
 {
     OSCL_UNUSED_ARG(aSourceData);
-    //just save the parameters-- the passthru plugin does not
-    //do any format checks.
+
+    //In a real OMA1 plugin, we would be able to verify whether the source is really OMA1
+    //content or not.  This passthru plugin is not smart enough to do that, so it
+    //generally accepts all formats.  However, it rejects ASF content to avoid conflicts
+    //with the PV Janus plugin.
+    if (aSourceFormat == PVMF_MIME_ASFFF || PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
+    {
+        return PVMFErrNotSupported;
+    }
+    else
     {
         iFilename = aSourceURL;
         iSourceFormatType = aSourceFormat;
@@ -341,7 +349,7 @@
 
 PVMFStatus PVMFCPMPassThruPlugInOMA1::QueryAccessInterfaceUUIDs(Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids)
 {
-    aUuids.push_back(PVMFCPMPluginLocalSyncAccessInterfaceUuid);
+    aUuids.push_back(PVMIDataStreamSyncInterfaceUuid);
     return PVMFSuccess;
 }
 
@@ -683,19 +691,24 @@
         return;
     }
     MakeMetadata();
-    PvmiKvp* requestedUsage;
-    PvmiKvp* approvedUsage;
-    PvmiKvp* authorizationData;
-    uint32*  requestTimeOutInMS;
-    aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, requestedUsage),
-               OSCL_STATIC_CAST(OsclAny*&, approvedUsage),
-               OSCL_STATIC_CAST(OsclAny*&, authorizationData),
-               OSCL_STATIC_CAST(OsclAny*&, requestTimeOutInMS));
 
+    OsclAny* temp1 = NULL;
+    OsclAny* temp2 = NULL;
+    OsclAny* temp3 = NULL;
+    OsclAny* temp4 = NULL;
+
+    aCmd.Parse(temp1, temp2, temp3, temp4);
+
+    PvmiKvp* requestedUsage = OSCL_STATIC_CAST(PvmiKvp*, temp1);
+    PvmiKvp* approvedUsage = OSCL_STATIC_CAST(PvmiKvp*, temp2);
+    PvmiKvp* authorizationData = OSCL_STATIC_CAST(PvmiKvp*, temp3);
+    uint32*  requestTimeOutInMS = OSCL_STATIC_CAST(uint32*, temp4);
 
     /* No check needed - approve everything */
     approvedUsage->value.uint32_value = requestedUsage->value.uint32_value;
     CommandComplete(iInputCommands, aCmd, PVMFSuccess);
+    OSCL_UNUSED_ARG(authorizationData);
+    OSCL_UNUSED_ARG(requestTimeOutInMS);
 }
 
 void PVMFCPMPassThruPlugInOMA1::DoUsageComplete(PVMFCPMPassThruPlugInOMA1Command& aCmd)
@@ -947,7 +960,7 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PVMFCPMPassThruPlugInOMA1::GetNodeMetadataValues() called"));
-    uint32 total = 0;
+    int32 total = 0;
     for (uint32 j = 0;j < aKeyList.size();j++)
     {
         for (int32 i = aStartingValueIndex;i < ELicLastOMA1;i++)
@@ -1297,6 +1310,7 @@
     }
     int32 result = iFileObject->Flush();
     PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Flush returning %d", result));
+    OSCL_UNUSED_ARG(result);
     return PVDS_SUCCESS;
 }
 
diff --git a/pvmi/content_policy_manager/src/cpm.cpp b/pvmi/content_policy_manager/src/cpm.cpp
index ca62995..a3bd526 100644
--- a/pvmi/content_policy_manager/src/cpm.cpp
+++ b/pvmi/content_policy_manager/src/cpm.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+
 #ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
 #include "oscl_exclusive_ptr.h"
 #endif
@@ -54,79 +55,161 @@
 #ifndef OSCL_MIME_STRING_UTILS_H
 #include "pv_mime_string_utils.h"
 #endif
-
 // Define entry point for this DLL
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
 #include "oscl_registry_access_client.h"
 
+static void _AddPluginInstance(CPMPluginRegistry* aRegistry, PVMFCPMPluginFactory* aFactory, const OSCL_String& aMimestring)
+{
+    if (aRegistry
+            && aFactory)
+    {
+        //Create an instance of the plugin.
+        PVMFCPMPluginInterface* plugin = aFactory->CreateCPMPlugin();
+        if (plugin)
+        {
+            //Package the plugin with its user authentication data.
+            CPMPluginContainer container(*plugin, NULL);
+            //Add the plugin to the registry with its mime string.
+            aRegistry->addPluginToRegistry((OSCL_String&)aMimestring, container);
+        }
+    }
+}
+
+static void _RemovePluginInstance(CPMPluginRegistry* aRegistry, PVMFCPMPluginFactory* aFactory, const OSCL_String& aMimestring)
+{
+    if (aRegistry)
+    {
+        if (aFactory)
+        {
+            CPMPluginContainer* container = aRegistry->lookupPlugin((OSCL_String&)aMimestring);
+            if (container)
+                aFactory->DestroyCPMPlugin(&container->PlugIn());
+        }
+        aRegistry->removePluginFromRegistry((OSCL_String&)aMimestring);
+    }
+}
+
+#ifdef USE_LOADABLE_MODULES
+#include "oscl_shared_library.h"
+#include "osclconfig_lib.h"
+
+static void _AddLoadablePlugins(CPMPluginRegistry* pRegistry)
+{
+    if (!pRegistry)
+        return;
+
+    //Create a list of all libs that implement CPM registry populator
+    pRegistry->AccessSharedLibraryList() = OSCL_NEW(OsclSharedLibraryList, ());
+    OSCL_HeapString<OsclMemAllocator> configPath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH;
+    pRegistry->AccessSharedLibraryList()->Populate(configPath, PVMF_CPM_PLUGIN_REGISTRY_POPULATOR_UUID);
+
+    //For each lib, add its factory to the registry.
+    for (uint32 i = 0;i < pRegistry->AccessSharedLibraryList()->Size();i++)
+    {
+        OsclAny* temp = NULL;
+        pRegistry->AccessSharedLibraryList()->QueryInterfaceAt(i, temp);
+        PVMFCPMPluginRegistryPopulator* pop = (PVMFCPMPluginRegistryPopulator*) temp;
+        if (pop)
+        {
+            OSCL_HeapString<OsclMemAllocator> mimestring;
+            PVMFCPMPluginFactory* fac = pop->GetFactoryAndMimeString(mimestring);
+            if (fac)
+                _AddPluginInstance(pRegistry, fac, mimestring);
+        }
+    }
+}
+static void _RemoveLoadablePlugins(CPMPluginRegistry* aRegistry)
+{
+    if (!aRegistry)
+        return;
+
+    if (aRegistry->AccessSharedLibraryList())
+    {
+        //Loop through loaded modules & remove plugin from list.
+        for (uint32 i = 0;i < aRegistry->AccessSharedLibraryList()->Size();i++)
+        {
+            OsclAny* temp = NULL;
+            aRegistry->AccessSharedLibraryList()->QueryInterfaceAt(i, temp);
+            PVMFCPMPluginRegistryPopulator* pop = (PVMFCPMPluginRegistryPopulator*) temp;
+            if (pop)
+            {
+                OSCL_HeapString<OsclMemAllocator> mimestring;
+                PVMFCPMPluginFactory* fac = pop->GetFactoryAndMimeString(mimestring);
+                if (fac)
+                {
+                    _RemovePluginInstance(aRegistry, fac, mimestring);
+                    pop->ReleaseFactory();
+                }
+            }
+        }
+
+        //Delete loaded module list
+        OSCL_DELETE(aRegistry->AccessSharedLibraryList());
+        aRegistry->AccessSharedLibraryList() = NULL;
+    }
+}
+#endif //USE_LOADABLE_MODULES
+
 static CPMPluginRegistry* PopulateCPMPluginRegistry()
 {
-    //Connect to global component registry.
-    OsclRegistryAccessClient cli;
-    if (cli.Connect() != OsclErrNone)
-        return NULL;
-
-    //Get all the current CPM plugin factory functions.
-    Oscl_Vector<OsclRegistryAccessElement, OsclMemAllocator> factories;
-    OSCL_HeapString<OsclMemAllocator> id("X-CPM-PLUGIN");//PVMF_MIME_CPM_PLUGIN
-    cli.GetFactories(id, factories);
-
     //Create registry
     CPMPluginRegistry* pRegistry = CPMPluginRegistryFactory::CreateCPMPluginRegistry();
     if (pRegistry)
     {
-        //Create implementations of all plugins.
-        Oscl_Vector<CPMPluginContainer, OsclMemAllocator> plugincontainers;
-        for (uint32 i = 0;i < factories.size();i++)
+        //Add plugins from global component registry.
+        OsclRegistryAccessClient cli;
+        if (cli.Connect() == OsclErrNone)
         {
-            if (factories[i].iFactory)
+            //Get all the current CPM plugin factory functions.
+            Oscl_Vector<OsclRegistryAccessElement, OsclMemAllocator> factories;
+            OSCL_HeapString<OsclMemAllocator> id("X-CPM-PLUGIN");//PVMF_MIME_CPM_PLUGIN
+            cli.GetFactories(id, factories);
+
+            //Add each plugin
+            for (uint32 i = 0;i < factories.size();i++)
             {
-                //Create an instance of the plugin.
-                PVMFCPMPluginInterface* plugin = ((PVMFCPMPluginFactory*)factories[i].iFactory)->CreateCPMPlugin();
-                if (plugin)
+                if (factories[i].iFactory)
                 {
-                    //Package the plugin with its user authentication data.
-                    CPMPluginContainer container(*plugin, NULL);
-                    //Add the plugin to the registry with its mime string.
-                    pRegistry->addPluginToRegistry(factories[i].iMimeString, container);
+                    _AddPluginInstance(pRegistry, (PVMFCPMPluginFactory*)factories[i].iFactory, factories[i].iMimeString);
                 }
             }
+            cli.Close();
         }
+#ifdef USE_LOADABLE_MODULES
+        //Add plugins from loadable modules.
+        _AddLoadablePlugins(pRegistry);
+#endif
     }
-    cli.Close();
     return pRegistry;
 }
 
 static void DePopulateCPMPluginRegistry(CPMPluginRegistry* aRegistry)
 {
-    //Connect to global component registry.
-    OsclRegistryAccessClient cli;
-    if (cli.Connect() != OsclErrNone)
-        return ;
-
     if (aRegistry)
     {
-        OSCL_HeapString<OsclMemAllocator> mimetype;
-        //Delete each plugin
-        while (aRegistry->GetNumPlugIns())
+#ifdef USE_LOADABLE_MODULES
+        //Remove dynamically loaded plugins
+        _RemoveLoadablePlugins(aRegistry);
+#endif
+        //Remove plugins created by the global component registry.
+        OsclRegistryAccessClient cli;
+        if (cli.Connect() == OsclErrNone)
         {
-            if (aRegistry->GetPluginMimeType(0, mimetype))
+            //Get all the current CPM plugin factory functions.
+            Oscl_Vector<OsclRegistryAccessElement, OsclMemAllocator> factories;
+            OSCL_HeapString<OsclMemAllocator> id("X-CPM-PLUGIN");//PVMF_MIME_CPM_PLUGIN
+            cli.GetFactories(id, factories);
+
+            for (uint32 i = 0;i < factories.size();i++)
             {
-                //lookup the instance of this plugin
-                CPMPluginContainer* container = aRegistry->lookupPlugin(mimetype);
-                if (container)
+                if (factories[i].iFactory)
                 {
-                    //lookup the factory for this plugin & delete its instance.
-                    OsclComponentFactory factory = cli.GetFactory(mimetype);
-                    if (factory)
-                    {
-                        ((PVMFCPMPluginFactory*)factory)->DestroyCPMPlugin(&container->PlugIn());
-                    }
+                    _RemovePluginInstance(aRegistry, (PVMFCPMPluginFactory*)factories[i].iFactory, factories[i].iMimeString);
                 }
-                //remove it from the registry
-                aRegistry->removePluginFromRegistry(mimetype);
             }
+            cli.Close();
         }
         //Destroy the plugin registry
         CPMPluginRegistryFactory::DestroyCPMPluginRegistry(aRegistry);
@@ -181,7 +264,7 @@
     iExtensionRefCount = 0;
     iGetLicenseCmdId = 0;
 
-    int32 err;
+    int32 err = OsclErrNone;
     OSCL_TRY(err,
              /*
               * Create the input command queue.  Use a reserve to avoid lots of
@@ -253,6 +336,11 @@
 
 OSCL_EXPORT_REF void PVMFCPMImpl::ThreadLogoff()
 {
+    //Note: registry cleanup logically belongs under Reset command, but
+    //some nodes currently hang onto their access interfaces after
+    //CPM is reset, which means the plugins need to survive until after
+    //the access interfaces are cleaned up.
+    //@TODO this should be moved to the CompleteCPMReset routine.
     if (iPluginRegistry)
     {
         DePopulateCPMPluginRegistry(iPluginRegistry);
@@ -716,7 +804,7 @@
 void
 PVMFCPMImpl::MoveCmdToCurrentQueue(PVMFCPMCommand& aCmd)
 {
-    int32 err;
+    int32 err = OsclErrNone;
     OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
     if (err != OsclErrNone)
     {
@@ -1010,10 +1098,10 @@
                 internalCmd->plugInID = it->iPlugInID;
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
+                it->iPlugInMetaDataExtensionInterfacePVI = NULL;
                 it->iPlugInInterface->QueryInterface(it->iPlugInSessionID,
                                                      KPVMFMetadataExtensionUuid,
-                                                     OSCL_STATIC_CAST(PVInterface*&, it->iPlugInMetaDataExtensionInterface),
+                                                     it->iPlugInMetaDataExtensionInterfacePVI,
                                                      cmdContextData);
                 iNumQueryMetaDataExtensionInterfacePending++;
             }
@@ -1064,10 +1152,10 @@
                 internalCmd->plugInID = it->iPlugInID;
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
+                it->iPlugInCapConfigExtensionInterfacePVI = NULL;
                 it->iPlugInInterface->QueryInterface(it->iPlugInSessionID,
                                                      PVMI_CAPABILITY_AND_CONFIG_PVUUID,
-                                                     OSCL_STATIC_CAST(PVInterface*&, it->iPlugInCapConfigExtensionInterface),
+                                                     it->iPlugInCapConfigExtensionInterfacePVI,
                                                      cmdContextData);
                 iNumQueryCapConfigExtensionInterfacePending++;
             }
@@ -1118,10 +1206,10 @@
                 internalCmd->plugInID = it->iPlugInID;
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
+                it->iPlugInAuthenticationInterfacePVI = NULL;
                 it->iPlugInInterface->QueryInterface(it->iPlugInSessionID,
                                                      PVMFCPMPluginAuthenticationInterfaceUuid,
-                                                     OSCL_STATIC_CAST(PVInterface*&, it->iPlugInAuthenticationInterface),
+                                                     it->iPlugInAuthenticationInterfacePVI,
                                                      cmdContextData);
                 iNumQueryAuthenticationInterfacePending++;
             }
@@ -1150,8 +1238,9 @@
 
 void PVMFCPMImpl::DoOpenSession(PVMFCPMCommand& aCmd)
 {
-    PVMFSessionId* sessionIdPtr;
-    aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, sessionIdPtr));
+    OsclAny* temp = NULL;
+    aCmd.Parse(temp);
+    PVMFSessionId* sessionIdPtr = OSCL_STATIC_CAST(PVMFSessionId*, temp);
 
     /* Create a session info */
     CPMSessionInfo sessionInfo;
@@ -1241,16 +1330,19 @@
 
 void PVMFCPMImpl::DoRegisterContent(PVMFCPMCommand& aCmd)
 {
-    OSCL_wString* sourceURL;
-    PVMFFormatType* sourceFormatType;
+    OsclAny* temp1 = NULL;
+    OsclAny* temp2 = NULL;
     OsclAny* aSourceData;
     OsclAny* placeHolder;
 
-    aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, sourceURL),
-               OSCL_STATIC_CAST(OsclAny*&, sourceFormatType),
+    aCmd.Parse(temp1,
+               temp2,
                aSourceData,
                placeHolder);
 
+    OSCL_wString* sourceURL = OSCL_STATIC_CAST(OSCL_wString*, temp1);
+    PVMFFormatType* sourceFormatType = OSCL_STATIC_CAST(PVMFFormatType*, temp2);
+
     CPMSessionInfo* sInfo = LookUpSessionInfo(aCmd.iSession);
 
     if (sInfo != NULL)
@@ -1325,10 +1417,10 @@
                 internalCmd->sessionid = aInfo->iSessionId;
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
+                it->iPlugInAuthorizationInterfacePVI = NULL;
                 it->iPlugInInterface->QueryInterface(it->iPlugInSessionID,
                                                      PVMFCPMPluginAuthorizationInterfaceUuid,
-                                                     OSCL_STATIC_CAST(PVInterface*&, it->iPlugInAuthorizationInterface),
+                                                     it->iPlugInAuthorizationInterfacePVI,
                                                      cmdContextData);
                 aInfo->iNumPlugInAuthorizeInterfaceQueryRequestsPending++;
             }
@@ -1361,10 +1453,10 @@
                 internalCmd->sessionid = aInfo->iSessionId;
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
+                it->iPlugInAccessInterfaceFactoryPVI = NULL;
                 it->iPlugInInterface->QueryInterface(it->iPlugInSessionID,
                                                      PVMFCPMPluginAccessInterfaceFactoryUuid,
-                                                     OSCL_STATIC_CAST(PVInterface*&, it->iPlugInAccessInterfaceFactory),
+                                                     it->iPlugInAccessInterfaceFactoryPVI,
                                                      cmdContextData);
                 aInfo->iNumPlugInAccessInterfaceFactoryQueryRequestsPending++;
             }
@@ -1412,10 +1504,10 @@
                 internalCmd->sessionid = aInfo->iSessionId;
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
-
+                it->iPlugInLicenseInterfacePVI = NULL;
                 it->iPlugInInterface->QueryInterface(it->iPlugInSessionID,
                                                      PVMFCPMPluginLicenseInterfaceUuid,
-                                                     OSCL_STATIC_CAST(PVInterface*&, it->iPlugInLicenseInterface),
+                                                     it->iPlugInLicenseInterfacePVI,
                                                      cmdContextData);
                 aInfo->iNumPlugInLicenseAcquisitionInterfaceRequestsPending++;
             }
@@ -1525,15 +1617,14 @@
 
 void PVMFCPMImpl::DoApproveUsage(PVMFCPMCommand& aCmd)
 {
-    PvmiKvp* requestedUsage;
-    PvmiKvp* approvedUsage;
-    PvmiKvp* authorizationData;
-    PVMFCPMUsageID* usageID;
+    OsclAny* temp1 = NULL;
+    OsclAny* temp2 = NULL;
+    OsclAny* temp3 = NULL;
+    OsclAny* temp4 = NULL;
 
-    aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, requestedUsage),
-               OSCL_STATIC_CAST(OsclAny*&, approvedUsage),
-               OSCL_STATIC_CAST(OsclAny*&, authorizationData),
-               OSCL_STATIC_CAST(OsclAny*&, usageID));
+    aCmd.Parse(temp1, temp2, temp3, temp4);
+
+    PVMFCPMUsageID* usageID = OSCL_STATIC_CAST(PVMFCPMUsageID*, temp4);
 
     /* Create Usage context */
     *usageID = iContentUsageContextVec.size();
@@ -1557,17 +1648,27 @@
 {
     if (iActivePlugInParamsVec.size() > 0)
     {
-        PvmiKvp* requestedUsage;
-        PvmiKvp* approvedUsage;
-        PvmiKvp* authorizationData;
-        PVMFCPMUsageID* usageID;
+        OsclAny* temp1 = NULL;
+        OsclAny* temp2 = NULL;
+        OsclAny* temp3 = NULL;
+        OsclAny* temp4 = NULL;
 
-        aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, requestedUsage),
-                   OSCL_STATIC_CAST(OsclAny*&, approvedUsage),
-                   OSCL_STATIC_CAST(OsclAny*&, authorizationData),
-                   OSCL_STATIC_CAST(OsclAny*&, usageID));
+        aCmd.Parse(temp1, temp2, temp3, temp4);
 
-        CPMSessionInfo* sInfo = LookUpSessionInfo(aCmd.iSession);
+        PvmiKvp* requestedUsage = OSCL_STATIC_CAST(PvmiKvp*, temp1);
+        PvmiKvp* approvedUsage = OSCL_STATIC_CAST(PvmiKvp*, temp2);
+        PvmiKvp* authorizationData = OSCL_STATIC_CAST(PvmiKvp*, temp3);
+        PVMFCPMUsageID* usageID = OSCL_STATIC_CAST(PVMFCPMUsageID*, temp4);
+
+        CPMSessionInfo* sInfo = NULL; // initialize to ensure that if LookUpSeesionInfo() fail, sInfo will be NULL
+        sInfo = LookUpSessionInfo(aCmd.iSession);
+        OSCL_ASSERT(sInfo);
+        if (!sInfo)
+        {
+            PVMF_CPM_LOGERROR((0, "PVMFCPMImpl::RequestApprovalFromActivePlugIns - No Session Info"));
+            return PVMFFailure;
+        }
+
         CPMContentUsageContext* usageContext = LookUpContentUsageContext(*usageID);
         Oscl_Vector<CPMPlugInParams, OsclMemAllocator>::iterator it;
         for (it = iActivePlugInParamsVec.begin(); it != iActivePlugInParamsVec.end(); it++)
@@ -1768,13 +1869,15 @@
     OsclAny* placeHolder1;
     OsclAny* placeHolder2;
     OsclAny* placeHolder3;
-    PVMFCPMUsageID* usageID;
+    OsclAny* temp = NULL;
 
     aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, placeHolder1),
                OSCL_STATIC_CAST(OsclAny*&, placeHolder2),
-               OSCL_STATIC_CAST(OsclAny*&, usageID),
+               temp,
                OSCL_STATIC_CAST(OsclAny*&, placeHolder3));
 
+    PVMFCPMUsageID* usageID = OSCL_STATIC_CAST(PVMFCPMUsageID*, temp);
+
     PVMFStatus status = SendUsageCompleteToRegisteredPlugIns(*usageID);
     if (status == PVMFSuccess)
     {
@@ -1855,8 +1958,9 @@
 
 void PVMFCPMImpl::DoCloseSession(PVMFCPMCommand& aCmd)
 {
-    PVMFSessionId* sessionId;
-    aCmd.Parse(OSCL_STATIC_CAST(OsclAny*&, sessionId));
+    OsclAny* temp = NULL;
+    aCmd.Parse(temp);
+    PVMFSessionId* sessionId = OSCL_STATIC_CAST(PVMFSessionId*, temp);
 
     CPMSessionInfo* sessionInfo = NULL;
 
@@ -2045,14 +2149,36 @@
             break;
 
         case PVMF_CPM_INTERNAL_QUERY_METADATA_EXTENSION_INTERFACE_CMD:
+        {
+            CPMPlugInParams* plugInParams =
+                LookUpPlugInParams(cmdContextData->plugInID);
+            if (plugInParams)
+            {
+                plugInParams->iPlugInMetaDataExtensionInterface =
+                    OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*,
+                                     plugInParams->iPlugInMetaDataExtensionInterfacePVI);
+                plugInParams->iPlugInMetaDataExtensionInterfacePVI = NULL;
+            }
             iNumQueryMetaDataExtensionInterfaceComplete++;
             CompleteMetaDataExtInterfaceQueryFromPlugIns();
-            break;
+        }
+        break;
 
         case PVMF_CPM_INTERNAL_QUERY_AUTHENTICATION_INTERFACE_CMD:
+        {
+            CPMPlugInParams* plugInParams =
+                LookUpPlugInParams(cmdContextData->plugInID);
+            if (plugInParams)
+            {
+                plugInParams->iPlugInAuthenticationInterface =
+                    OSCL_STATIC_CAST(PVMFCPMPluginAuthenticationInterface*,
+                                     plugInParams->iPlugInAuthenticationInterfacePVI);
+                plugInParams->iPlugInAuthenticationInterfacePVI = NULL;
+            }
             iNumQueryAuthenticationInterfaceComplete++;
             CompleteCPMInit();
-            break;
+        }
+        break;
 
         case PVMF_CPM_INTERNAL_AUTHENTICATE_CMD:
         {
@@ -2064,6 +2190,15 @@
 
         case PVMF_CPM_INTERNAL_QUERY_AUTHORIZATION_INTERFACE_CMD:
         {
+            CPMPlugInParams* plugInParams =
+                LookUpPlugInParamsFromActiveList(cmdContextData->plugInID);
+            if (plugInParams)
+            {
+                plugInParams->iPlugInAuthorizationInterface =
+                    OSCL_STATIC_CAST(PVMFCPMPluginAuthorizationInterface*,
+                                     plugInParams->iPlugInAuthorizationInterfacePVI);
+                plugInParams->iPlugInAuthorizationInterfacePVI = NULL;
+            }
             CPMSessionInfo* sessionInfo =
                 LookUpSessionInfo(cmdContextData->sessionid);
             CompleteRegisterContentPhase1(sessionInfo);
@@ -2072,6 +2207,15 @@
 
         case PVMF_CPM_INTERNAL_QUERY_ACCESS_INTERFACE_FACTORY_CMD:
         {
+            CPMPlugInParams* plugInParams =
+                LookUpPlugInParamsFromActiveList(cmdContextData->plugInID);
+            if (plugInParams)
+            {
+                plugInParams->iPlugInAccessInterfaceFactory =
+                    OSCL_STATIC_CAST(PVMFCPMPluginAccessInterfaceFactory*,
+                                     plugInParams->iPlugInAccessInterfaceFactoryPVI);
+                plugInParams->iPlugInAccessInterfaceFactoryPVI = NULL;
+            }
             CPMSessionInfo* sessionInfo =
                 LookUpSessionInfo(cmdContextData->sessionid);
             CompleteRegisterContentPhase2(sessionInfo);
@@ -2080,6 +2224,15 @@
 
         case PVMF_CPM_INTERNAL_QUERY_LICENSE_INTERFACE_CMD:
         {
+            CPMPlugInParams* plugInParams =
+                LookUpPlugInParamsFromActiveList(cmdContextData->plugInID);
+            if (plugInParams)
+            {
+                plugInParams->iPlugInLicenseInterface =
+                    OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*,
+                                     plugInParams->iPlugInLicenseInterfacePVI);
+                plugInParams->iPlugInLicenseInterfacePVI = NULL;
+            }
             CPMSessionInfo* sessionInfo =
                 LookUpSessionInfo(cmdContextData->sessionid);
             CompleteRegisterContentPhase3(sessionInfo);
@@ -2093,7 +2246,6 @@
             CompleteApproveUsage(usageContext);
             CPMPlugInParams* plugInParams =
                 LookUpPlugInParams(cmdContextData->plugInID);
-            OSCL_ASSERT(plugInParams);
             if (plugInParams)
                 plugInParams->iAuthorized = true;
         }
@@ -2106,7 +2258,6 @@
             CompleteUsageComplete(usageContext);
             CPMPlugInParams* plugInParams =
                 LookUpPlugInParams(cmdContextData->plugInID);
-            OSCL_ASSERT(plugInParams);
             if (plugInParams)
                 plugInParams->iAuthorized = false;
         }
@@ -2134,9 +2285,20 @@
         break;
 
         case PVMF_CPM_INTERNAL_QUERY_CAP_CONFIG_INTERFACE_CMD:
+        {
+            CPMPlugInParams* plugInParams =
+                LookUpPlugInParams(cmdContextData->plugInID);
+            if (plugInParams)
+            {
+                plugInParams->iPlugInCapConfigExtensionInterface =
+                    OSCL_STATIC_CAST(PvmiCapabilityAndConfig*,
+                                     plugInParams->iPlugInCapConfigExtensionInterfacePVI);
+                plugInParams->iPlugInCapConfigExtensionInterfacePVI = NULL;
+            }
             iNumQueryCapConfigExtensionInterfaceComplete++;
             CompleteCapConfigExtInterfaceQueryFromPlugIns();
-            break;
+        }
+        break;
 
         default:
             break;
@@ -2273,11 +2435,11 @@
 {
     iGetMetaDataKeysInProgress = false;
 
+    int32 leavecode = OsclErrNone;
     PVMFMetadataList* keylistptr = NULL;
     int32 starting_index;
     int32 max_entries;
     char* query_key = NULL;
-
     aCmd.PVMFCPMCommand::Parse(keylistptr,
                                starting_index,
                                max_entries,
@@ -2296,12 +2458,10 @@
     /* Copy the requested keys from all active plugins */
     uint32 num_entries = 0;
     int32 num_added = 0;
-    int32 leavecode = 0;
     Oscl_Vector<CPMPlugInParams, OsclMemAllocator>::iterator it;
     for (it = iActivePlugInParamsVec.begin(); it != iActivePlugInParamsVec.end(); it++)
     {
         it->iMetaDataKeyStartIndex = keylistptr->size();
-
         for (uint32 lcv = 0; lcv < it->iAvailableMetadataKeys.size(); lcv++)
         {
             if (query_key == NULL)
@@ -2311,11 +2471,12 @@
                 if (num_entries > (uint32)starting_index)
                 {
                     /* Past the starting index so copy the key */
-                    leavecode = 0;
-                    OSCL_TRY(leavecode, keylistptr->push_back(it->iAvailableMetadataKeys[lcv]));
-                    OSCL_FIRST_CATCH_ANY(leavecode,
-                                         PVMF_CPM_LOGERROR((0, "PVMFCPMImpl::CompleteDoGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                         return PVMFErrNoMemory);
+                    leavecode = OsclErrNone;
+                    leavecode = PushKVPKey(it->iAvailableMetadataKeys[lcv], *keylistptr);
+                    if (OsclErrNone != leavecode)
+                    {
+                        return PVMFErrNoMemory;
+                    }
                     num_added++;
                 }
             }
@@ -2329,11 +2490,12 @@
                     if (num_entries > (uint32)starting_index)
                     {
                         /* Past the starting index so copy the key */
-                        leavecode = 0;
-                        OSCL_TRY(leavecode, keylistptr->push_back(it->iAvailableMetadataKeys[lcv]));
-                        OSCL_FIRST_CATCH_ANY(leavecode,
-                                             PVMF_CPM_LOGERROR((0, "PVMFCPMImpl::CompleteDoGetMetadataKeys() Memory allocation failure when copying metadata key"));
-                                             return PVMFErrNoMemory);
+                        leavecode = OsclErrNone;
+                        leavecode = PushKVPKey(it->iAvailableMetadataKeys[lcv], *keylistptr);
+                        if (OsclErrNone != leavecode)
+                        {
+                            return PVMFErrNoMemory;
+                        }
                         num_added++;
                     }
                 }
@@ -2588,7 +2750,7 @@
     {
         if (it->iPlugInCapConfigExtensionInterface != NULL)
         {
-            int32 err;
+            int32 err = OsclErrNone;
             OSCL_TRY(err,
                      it->iPlugInCapConfigExtensionInterface->setParametersSync(aSession,
                              aParameters,
@@ -2814,7 +2976,25 @@
             {
                 internalCmd->cmd = PVMF_CPM_INTERNAL_CANCEL_GET_LICENSE;
                 internalCmd->parentCmd = PVMF_CPM_CANCEL_GET_LICENSE;
+
+                OSCL_ASSERT(pluginParamsPtr);
+
+                if (!pluginParamsPtr)
+
+                {
+
+                    status = PVMFErrCorrupt;
+
+                    PVMF_CPM_LOGERROR((0, "PVMFCPMImpl::DoCancelGetLicense - data corrupted"));
+
+                    CommandComplete(iInputCommands, aCmd, status);
+
+                    return;
+
+                }
+
                 internalCmd->plugInID = pluginParamsPtr->iPlugInID;
+
                 OsclAny *cmdContextData =
                     OSCL_REINTERPRET_CAST(OsclAny*, internalCmd);
 
@@ -2874,6 +3054,7 @@
     Oscl_Map<string_key_type, CPMPluginContainer*, OsclMemAllocator, string_key_compare_class>::iterator it;
     it = iCPMPluginRegistry.find(aMimeType);
 
+    /* Workaround for the ADS1.2 compiler*/
     if (!(it == iCPMPluginRegistry.end()))
     {
         return (((*it).second));
@@ -2899,8 +3080,13 @@
 OSCL_EXPORT_REF CPMPluginRegistryImpl::CPMPluginRegistryImpl()
 {
     iRefCount = 0;
+    iSharedLibList = NULL;
 }
 
+#ifdef USE_LOADABLE_MODULES
+#include "oscl_shared_library.h"
+#endif
+
 OSCL_EXPORT_REF CPMPluginRegistryImpl::~CPMPluginRegistryImpl()
 {
     //just in case plugins weren't removed, go through and cleanup
@@ -2910,6 +3096,10 @@
         if (container)
             OSCL_DELETE(container);
     }
+#ifdef USE_LOADABLE_MODULES
+    if (iSharedLibList)
+        OSCL_DELETE(iSharedLibList);
+#endif
 }
 
 CPMPluginRegistry* CPMPluginRegistryFactory::CreateCPMPluginRegistry()
@@ -2923,3 +3113,9 @@
     OSCL_DELETE(impl);
 }
 
+int32 PVMFCPMImpl::PushKVPKey(OSCL_String& aString, PVMFMetadataList& aKeyList)
+{
+    int32 leavecode = OsclErrNone;
+    OSCL_TRY(leavecode, aKeyList.push_back(aString));
+    return leavecode;
+}
diff --git a/pvmi/content_policy_manager/src/cpm_internal.h b/pvmi/content_policy_manager/src/cpm_internal.h
index 348cbad..1ce521f 100644
--- a/pvmi/content_policy_manager/src/cpm_internal.h
+++ b/pvmi/content_policy_manager/src/cpm_internal.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -393,6 +393,13 @@
             iPlugInMetaDataExtensionInterface = NULL;
             iPlugInLicenseInterface = NULL;
             iPlugInCapConfigExtensionInterface = NULL;
+            iPlugInAuthenticationInterfacePVI = NULL;
+            iPlugInAuthorizationInterfacePVI = NULL;
+            iPlugInAccessInterfaceFactoryPVI = NULL;
+            iPlugInMetaDataExtensionInterfacePVI = NULL;
+            iPlugInLicenseInterfacePVI = NULL;
+            iPlugInCapConfigExtensionInterfacePVI = NULL;
+
             iAuthorizationRequestTimeOut =
                 PVMF_CPM_DEFAULT_PLUGIN_AUTHORIZATION_TIMEOUT_IN_MS;
             iConnected = false;
@@ -419,6 +426,12 @@
         PVMFMetadataExtensionInterface* iPlugInMetaDataExtensionInterface;
         PVMFCPMPluginLicenseInterface* iPlugInLicenseInterface;
         PvmiCapabilityAndConfig* iPlugInCapConfigExtensionInterface;
+        PVInterface* iPlugInAuthenticationInterfacePVI;
+        PVInterface* iPlugInAuthorizationInterfacePVI;
+        PVInterface* iPlugInAccessInterfaceFactoryPVI;
+        PVInterface* iPlugInMetaDataExtensionInterfacePVI;
+        PVInterface* iPlugInLicenseInterfacePVI;
+        PVInterface* iPlugInCapConfigExtensionInterfacePVI;
         uint32 iAuthorizationRequestTimeOut;
         bool iConnected;
         bool iAuthorized;
@@ -752,7 +765,7 @@
         CPMContentUsageContext* LookUpContentUsageContext(PVMFCPMUsageID);
         CPMPlugInParams* LookUpPlugInParams(uint32);
         CPMPlugInParams* LookUpPlugInParamsFromActiveList(uint32);
-
+        int32 PushKVPKey(OSCL_String& aString, PVMFMetadataList& aKeyList);
         PVLogger* iLogger;
 
         CPMPluginRegistry* iPluginRegistry;
@@ -786,7 +799,6 @@
         PVMFCPMPluginLicenseInterface* iLicenseInterface ;
         PVMFCommandId iGetLicenseCmdId;
         PVMFCommandId iCancelGetLicenseCmdId;
-
 };
 
 
@@ -817,6 +829,7 @@
 #include "oscl_map.h"
 #endif
 
+class OsclSharedLibraryList;
 class CPMPluginRegistryImpl: public CPMPluginRegistry
 {
     public:
@@ -832,6 +845,10 @@
 
         OSCL_IMPORT_REF bool GetPluginMimeType(uint32 aIndex, OSCL_String& aMimeType) ;
 
+        OsclSharedLibraryList*& AccessSharedLibraryList()
+        {
+            return iSharedLibList;
+        }
 
     private:
         friend class CPMPluginRegistryFactory;
@@ -844,6 +861,8 @@
         Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iListofPlugInMimeTypes;
 
         int32 iRefCount;
+
+        OsclSharedLibraryList* iSharedLibList;
 };
 
 #endif //CPM_INTERNAL_H_INCLUDED
diff --git a/pvmi/content_policy_manager/src/pvmf_cpmplugin_factory_registry.cpp b/pvmi/content_policy_manager/src/pvmf_cpmplugin_factory_registry.cpp
index 16f1203..8d6d715 100644
--- a/pvmi/content_policy_manager/src/pvmf_cpmplugin_factory_registry.cpp
+++ b/pvmi/content_policy_manager/src/pvmf_cpmplugin_factory_registry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk
index d2a7df5..6190184 100644
--- a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk
+++ b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/Android.mk
@@ -2,27 +2,30 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvmi_mio_avi_wav_file.cpp
-
+ 	src/pvmi_mio_avi_wav_file.cpp
 
 
 LOCAL_MODULE := libpvmioaviwavfileinput
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_avi_wav_fileinput/src \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_avi_wav_fileinput/src \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_avi_wav_fileinput/../../pvmf/include \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_avi_wav_fileinput/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src \
+ 	$(PV_TOP)/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/pvmi/media_io/pvmi_mio_avi_wav_fileinput/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	src/pvmi_mio_avi_wav_file.h \
-	src/../include/pvmi_mio_avi_wav_file_factory.h
+ 	src/../include/pvmi_mio_avi_wav_file_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make/local.mk b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make/local.mk
new file mode 100644
index 0000000..7db6c2c
--- /dev/null
+++ b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make/local.mk
@@ -0,0 +1,83 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmioaviwavfileinput 
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += ../../../../pvmf/include ../../include
+
+
+ XLIBDIRS += -Lpvavifileparser -Lpvwav 
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvmi_mio_avi_wav_file.cpp 
+
+
+HDRS := pvmi_mio_avi_wav_file.h \
+       ../include/pvmi_mio_avi_wav_file_factory.h
+
+
+
+	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+include $(MK)/library.mk
diff --git a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make/makefile b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make/makefile
deleted file mode 100644
index e174bc5..0000000
--- a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make/makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmioaviwavfileinput 
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../../../pvmf/include -I../../include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
- XLIBDIRS += -Lpvavifileparser -Lpvwav 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../src
-
-# compose final src list for actual build
-SRCS =	pvmi_mio_avi_wav_file.cpp 
-
-
-HDRS = pvmi_mio_avi_wav_file.h \
-       ../include/pvmi_mio_avi_wav_file_factory.h
-
-
-
-	
-#\
-#	oscl_mem_basic_functions.h
-#\
-#	oscl_mem_basic_functions.inl
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/include/pvmi_mio_avi_wav_file_factory.h b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/include/pvmi_mio_avi_wav_file_factory.h
index b2a2a3f..c4851f1 100644
--- a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/include/pvmi_mio_avi_wav_file_factory.h
+++ b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/include/pvmi_mio_avi_wav_file_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@
     public:
         PvmiMIOAviWavFileSettings()
         {
-            iMediaFormat = PVMF_FORMAT_UNKNOWN;
+            iMediaFormat = PVMF_MIME_FORMAT_UNKNOWN;
             iNumLoops = 0;
             iRecModeSyncWithClock = false;
             iStreamNumber = 0;
@@ -66,6 +66,7 @@
         PvmiMIOAviWavFileSettings(const PvmiMIOAviWavFileSettings& aSettings)
         {
             iMediaFormat = aSettings.iMediaFormat;
+            iMimeType = aSettings.iMimeType;
             iNumLoops = 0;
             iRecModeSyncWithClock = aSettings.iRecModeSyncWithClock;
             iStreamNumber = aSettings.iStreamNumber;
@@ -87,6 +88,7 @@
 
         // General settings
         PVMFFormatType  iMediaFormat;
+        OSCL_HeapString<OsclMemAllocator> iMimeType;
         uint32			iNumLoops;
         bool iRecModeSyncWithClock;
         uint32 iStreamNumber;
diff --git a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.cpp b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.cpp
index 5bc5ae6..81bbc74 100644
--- a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.cpp
+++ b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,6 +39,8 @@
 #define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m)
 #define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m)
 #define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m)
+#define LOGDATATRAFFIC(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDataPathLogger,PVLOGMSG_INFO,m);
+#define LOGDIAGNOSTICS_AVI_FF(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iDiagnosticsLoggerAVIFF,PVLOGMSG_INFO,m);
 
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF PvmiMIOControl* PvmiMIOAviWavFileFactory::Create(uint32 aNumLoops, bool aRecordingMode, uint32 aStreamNo, OsclAny* aFileParser, FileFormatType aFileType, int32& arError)
@@ -56,7 +58,7 @@
     {
         return false;
     }
-    delete mioFilein;
+    OSCL_DELETE(mioFilein);
 
     mioFilein = NULL;
     return true;
@@ -70,12 +72,25 @@
     if (!oDiagnosticsLogged)
         LogDiagnostics();
 #endif
+
     if (iMediaBufferMemPool)
     {
-        OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+        if (iSentMediaData.size() > 0)
+        {
+            for (int ii = iSentMediaData.size() - 1; ii >= 0; ii--)
+            {
+                iMediaBufferMemPool->deallocate(iSentMediaData[ii].iData);
+            }
+        }
+        if (iData)
+        {
+            iMediaBufferMemPool->deallocate(iData);
+            iData = NULL;
+            iDataSize = 0;
+        }
+        OSCL_DELETE(iMediaBufferMemPool);
         iMediaBufferMemPool = NULL;
     }
-    delete(iMioClock);
 }
 
 ////////////////////////////////////////////////////////////////////////////
@@ -274,10 +289,20 @@
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF void PvmiMIOAviWavFile::ThreadLogon()
 {
+
     if (!iThreadLoggedOn)
     {
+        if (iSettings.iRecModeSyncWithClock)
+        {
+            iMioClock =  OSCL_NEW(PVMFMediaClock, ());
+            iMioClock->SetClockTimebase(iClockTimeBase);
+            uint32 start = 0;
+            bool overflowFlag = false;
+            iMioClock->SetStartTime32(start, PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
+        }
         AddToScheduler();
         iThreadLoggedOn = true;
+
     }
 }
 
@@ -286,10 +311,16 @@
 {
     if (iThreadLoggedOn)
     {
+        if (iSettings.iRecModeSyncWithClock && iMioClock != NULL)
+        {
+            OSCL_DELETE(iMioClock);
+        }
         RemoveFromScheduler();
         iLogger = NULL;
+        iDataPathLogger = NULL;
         iThreadLoggedOn = false;
     }
+
 }
 
 
@@ -400,14 +431,22 @@
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF void PvmiMIOAviWavFile::statusUpdate(uint32 aStatus_flags)
 {
-    OSCL_UNUSED_ARG(aStatus_flags);
-    // Ideally this routine should update the status of media input component.
-    // It should check then for the status. If media input buffer is consumed,
-    // media input object should be resheduled.
-    // Since the Media avifile component is designed with single buffer, two
-    // asynchronous reads are not possible. So this function will not be required
-    // and hence not been implemented.
-    OSCL_LEAVE(OsclErrNotSupported);
+    if (aStatus_flags == PVMI_MEDIAXFER_STATUS_WRITE)
+    {
+        iWriteState = EWriteOK;
+        iMicroSecondsPerDataEvent = 0;
+        AddDataEventToQueue(iMicroSecondsPerDataEvent);
+    }
+    else
+    {
+        // Ideally this routine should update the status of media input component.
+        // It should check then for the status. If media input buffer is consumed,
+        // media input object should be resheduled.
+        // Since the Media avifile component is designed with single buffer, two
+        // asynchronous reads are not possible. So this function will not be required
+        // and hence not been implemented.
+        OSCL_LEAVE(OsclErrNotSupported);
+    }
 }
 
 
@@ -451,21 +490,21 @@
             pv_mime_strcmp(aIdentifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
     {
         aNum_parameter_elements = 1;
-        status = AllocateKvp(aParameters, OUTPUT_FORMATS_VALTYPE, aNum_parameter_elements);
+        status = AllocateKvp(aParameters, (PvmiKeyType)OUTPUT_FORMATS_VALTYPE, aNum_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOAviWavFile::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            aParameters[0].value.uint32_value = iSettings.iMediaFormat;
+            aParameters[0].value.pChar_value = (char*)iSettings.iMediaFormat.getMIMEStrPtr();
 
         }
     }
     else if (pv_mime_strcmp(aIdentifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
     {
         aNum_parameter_elements = 1;
-        status = AllocateKvp(aParameters, VIDEO_OUTPUT_WIDTH_CUR_VALUE, aNum_parameter_elements);
+        status = AllocateKvp(aParameters, (PvmiKeyType)VIDEO_OUTPUT_WIDTH_CUR_VALUE, aNum_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOAviWavFile::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -477,7 +516,7 @@
     else if (pv_mime_strcmp(aIdentifier, VIDEO_FRAME_ORIENTATION_CUR_QUERY) == 0)
     {
         aNum_parameter_elements = 1;
-        status = AllocateKvp(aParameters, VIDEO_FRAME_ORIENTATION_CUR_VALUE, aNum_parameter_elements);
+        status = AllocateKvp(aParameters, (PvmiKeyType)VIDEO_FRAME_ORIENTATION_CUR_VALUE, aNum_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOAviWavFile::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -490,7 +529,7 @@
     else if (pv_mime_strcmp(aIdentifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
     {
         aNum_parameter_elements = 1;
-        status = AllocateKvp(aParameters, VIDEO_OUTPUT_HEIGHT_CUR_VALUE, aNum_parameter_elements);
+        status = AllocateKvp(aParameters, (PvmiKeyType)VIDEO_OUTPUT_HEIGHT_CUR_VALUE, aNum_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOAviWavFile::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -502,7 +541,7 @@
     else if (pv_mime_strcmp(aIdentifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
     {
         aNum_parameter_elements = 1;
-        status = AllocateKvp(aParameters, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, aNum_parameter_elements);
+        status = AllocateKvp(aParameters, (PvmiKeyType)VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, aNum_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOAviWavFile::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -514,7 +553,7 @@
     else if (pv_mime_strcmp(aIdentifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0)
     {
         aNum_parameter_elements = 1;
-        status = AllocateKvp(aParameters, OUTPUT_TIMESCALE_CUR_VALUE, aNum_parameter_elements);
+        status = AllocateKvp(aParameters, (PvmiKeyType)OUTPUT_TIMESCALE_CUR_VALUE, aNum_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -522,15 +561,13 @@
         }
         else
         {
-            switch (GetMediaTypeIndex(iSettings.iMediaFormat))
+            if (iSettings.iMediaFormat.isAudio())
             {
-                case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-                case PVMF_COMPRESSED_AUDIO_FORMAT:
-                    aParameters[0].value.uint32_value = (uint32)iSettings.iSamplingFrequency;
-                    break;
-                default:
-                    aParameters[0].value.uint32_value = iSettings.iTimescale;
-                    break;
+                aParameters[0].value.uint32_value = (uint32)iSettings.iSamplingFrequency;
+            }
+            else
+            {
+                aParameters[0].value.uint32_value = iSettings.iTimescale;
             }
         }
     }
@@ -651,12 +688,15 @@
         iMicroSecondsPerDataEvent(0),
         iMediaBufferMemPool(NULL),
         iLogger(NULL),
+        iDataPathLogger(NULL),
         iState(STATE_IDLE),
+        iWaitingOnClock(false),
+        iTimeStamp(0),
         iStreamDuration(0),
-        iBaseTimeStamp(0),
         iCurrentTimeStamp(0),
-        iNextTimeStamp(0),
-        iWaitingOnClock(false)
+        iWriteState(EWriteOK),
+        iData(NULL),
+        iNoMemBufferData(false)
 {
 #if PROFILING_ON
     iNumEarlyFrames = 0;
@@ -673,16 +713,29 @@
     iSettings.iStreamNumber = aStreamNo;
     iSettings.iRecModeSyncWithClock = aRecordingMode;
     arError = InitComp(aFileParser, aFileType);
-    iMioClock = new OsclClock();
-    iMioClock->SetClockTimebase(iClockTimeBase);
-    uint32 start = 0;
-    iMioClock->SetStartTime32(start, OSCLCLOCK_MSEC);
 
     iLogger = PVLogger::GetLoggerObject("PvmiMIOAviWavFile");
     iDiagnosticsLogger = PVLogger::GetLoggerObject("pvauthordiagnostics.mio.aviwav");
-
+    iDiagnosticsLoggerAVIFF = PVLogger::GetLoggerObject("pvauthordiagnostics.mio.aviwav.ff");
+    iDataPathLogger = PVLogger::GetLoggerObject("datapath.mio.aviwav");
 }
 
+bool PvmiMIOAviWavFile::IsYUVFormat_Supported(uint32 aFcc)
+{
+    uint32  ii;
+    bool pattern_found = false;
+
+    for (ii = 0 ; ii < NUM_YUV_FMT; ii++)
+    {
+        if (YUV_FMT[ii] == aFcc)
+        {
+            pattern_found = true;
+            break;
+        }
+    }
+
+    return pattern_found;
+}
 ////////////////////////////////////////////////////////////////////////////
 int32 PvmiMIOAviWavFile::InitComp(OsclAny* aFileParser, FileFormatType aFileType)
 {
@@ -708,20 +761,25 @@
                 uint32 size = 4;
 
                 iPVAviFile->GetVideoFormatType((uint8*)fmtType, size, ii);
-                fmtType[size] = '\0';
-                /*@todo: add YUV*/
+
+                uint32 temp = MAKE_FOURCC(fmtType[0], fmtType[1], fmtType[2], fmtType[3]);
+
+                BitmapInfoHhr* videoHdr = OSCL_STATIC_CAST(BitmapInfoHhr*, iFormatSpecificDataFrag.getMemFragPtr());
+
                 if (!oscl_strncmp((char*)fmtType, "DIB ", size))
                 {
-                    BitmapInfoHhr* videoHdr = OSCL_STATIC_CAST(BitmapInfoHhr*, iFormatSpecificDataFrag.getMemFragPtr());
 
                     if (BITS_PER_SAMPLE12 == videoHdr->BiBitCount)
                     {
-                        iSettings.iMediaFormat = PVMF_RGB12;
+                        iSettings.iMediaFormat = PVMF_MIME_RGB12;
+                        iSettings.iMimeType = PVMF_MIME_RGB12;
                         iSettings.iSampleSize = videoHdr->BiBitCount;
                     }
                     else if (BITS_PER_SAMPLE24 == videoHdr->BiBitCount)
                     {
-                        iSettings.iMediaFormat = PVMF_RGB24;
+                        iSettings.iMediaFormat = PVMF_MIME_RGB24;
+                        iSettings.iMimeType = PVMF_MIME_RGB24;
+
                         iSettings.iSampleSize = videoHdr->BiBitCount;
                     }
                     else
@@ -729,6 +787,12 @@
                         return PVMFErrNotSupported;
                     }
                 }
+                else if (IsYUVFormat_Supported(temp))
+                {
+                    iSettings.iMediaFormat = PVMF_MIME_YUV420;
+                    iSettings.iMimeType = PVMF_MIME_YUV420;
+
+                }
                 else
                 {
                     return PVMFErrNotSupported;
@@ -750,11 +814,13 @@
                 {
                     if (BITS_PER_SAMPLE8 == audioHdr->BitsPerSample)
                     {
-                        iSettings.iMediaFormat = PVMF_PCM8;
+                        iSettings.iMediaFormat = PVMF_MIME_PCM8;
+                        iSettings.iMimeType = PVMF_MIME_PCM8;
                     }
                     else if (BITS_PER_SAMPLE16 == audioHdr->BitsPerSample)
                     {
-                        iSettings.iMediaFormat = PVMF_PCM16;
+                        iSettings.iMediaFormat = PVMF_MIME_PCM16;
+                        iSettings.iMimeType = PVMF_MIME_PCM16;
                     }
                     else
                     {
@@ -788,18 +854,20 @@
             }
 
             iSettings.iNumChannels = wavFileInfo.NumChannels;
-            iSettings.iSamplingFrequency = wavFileInfo.SampleRate;
+            iSettings.iSamplingFrequency = (OsclFloat)wavFileInfo.SampleRate;
             iSettings.iSampleSize = wavFileInfo.BitsPerSample;
             iSettings.iByteRate = wavFileInfo.ByteRate;
             iStreamDuration = (1000000 / wavFileInfo.SampleRate) * wavFileInfo.NumSamples;
 
             if (BITS_PER_SAMPLE16 == wavFileInfo.BitsPerSample)
             {
-                iSettings.iMediaFormat = PVMF_PCM16;
+                iSettings.iMediaFormat = PVMF_MIME_PCM16;
+                iSettings.iMimeType = PVMF_MIME_PCM16;
             }
             else if (BITS_PER_SAMPLE8 == wavFileInfo.BitsPerSample)
             {
-                iSettings.iMediaFormat = PVMF_PCM8;
+                iSettings.iMediaFormat = PVMF_MIME_PCM8;
+                iSettings.iMimeType = PVMF_MIME_PCM8;
             }
             else
             {
@@ -931,7 +999,7 @@
     OSCL_TRY(err,
              if (iMediaBufferMemPool)
 {
-    OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+    OSCL_DELETE(iMediaBufferMemPool);
         iMediaBufferMemPool = NULL;
     }
     iMediaBufferMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator,
@@ -949,7 +1017,7 @@
     //set chunk size
     uint32 dataSize = GetDataSize();
     //add bytes in 1 msec
-    dataSize += (iSettings.iSampleSize / BYTE_COUNT * iSettings.iSamplingFrequency / 1000);
+    dataSize += (uint32)(iSettings.iSampleSize / BYTE_COUNT * iSettings.iSamplingFrequency / 1000);
     iSettings.iDataBufferSize = dataSize;
 
     uint8* data = (uint8*)iMediaBufferMemPool->allocate(dataSize);
@@ -970,13 +1038,16 @@
 PVMFStatus PvmiMIOAviWavFile::DoPause()
 {
     iState = STATE_PAUSED;
-    iMioClock->Pause();
+    if ((iMioClock) && (iSettings.iRecModeSyncWithClock))
+    {
+        iMioClock->Pause();
+    }
     return PVMFSuccess;
 }
 
 PVMFStatus PvmiMIOAviWavFile::DoReset()
 {
-
+    iWriteState = EWriteOK;
 #if PROFILING_ON
     if (!oDiagnosticsLogged)
         LogDiagnostics();
@@ -998,15 +1069,19 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmiMIOAviWavFile::DoStop()
 {
+    iWriteState = EWriteOK;
     iDataEventCounter = 0;
     iState = STATE_STOPPED;
-    iMioClock->Stop();
-
+    if ((iMioClock != NULL) && (iSettings.iRecModeSyncWithClock))
+    {
+        iMioClock->Stop();
+    }
 #if PROFILING_ON
     if (!oDiagnosticsLogged)
         LogDiagnostics();
 #endif
 
+    iState = STATE_STOPPED;
     return PVMFSuccess;
 }
 
@@ -1035,12 +1110,28 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmiMIOAviWavFile::GetMediaData(uint8* aData, uint32& aDataSize, uint32& aTimeStamp)
 {
-
+    aTimeStamp = iCurrentTimeStamp;
+    uint32 iNptTS = 0;
     // Read data from file
     if (iPVAviFile != NULL)
     {
         PV_AVI_FILE_PARSER_ERROR_TYPE error = PV_AVI_FILE_PARSER_SUCCESS;
-        error = iPVAviFile->GetNextStreamMediaSample(iSettings.iStreamNumber, aData, aDataSize, aTimeStamp);
+
+        uint32 currticks  = 0;
+        currticks = OsclTickCount::TickCount();
+        uint32 starttime = 0;
+        starttime = OsclTickCount::TicksToMsec(currticks);
+
+        error = iPVAviFile->GetNextStreamMediaSample(iSettings.iStreamNumber, aData, aDataSize, iNptTS);
+
+        currticks = OsclTickCount::TickCount();
+        uint32 endtime = 0;
+        endtime = OsclTickCount::TicksToMsec(currticks);
+
+        LOGDIAGNOSTICS_AVI_FF((0, "PvmiMIOAviWavFile::GetMediaData:"
+                               "StreamNum=%d, NptTS=%d, Size=%d, TimeToRead=%d, MimeType=%s",
+                               iSettings.iStreamNumber,  iNptTS, aDataSize, (endtime - starttime),
+                               iSettings.iMimeType.get_cstr()));
 
         if (error != PV_AVI_FILE_PARSER_SUCCESS)
         {
@@ -1054,10 +1145,24 @@
 
                     iPVAviFile->Reset(iSettings.iStreamNumber);
                     iSettings.iNumLoops--;
-                    iBaseTimeStamp = iNextTimeStamp;
                     //retrieve sample again
                     PV_AVI_FILE_PARSER_ERROR_TYPE error = PV_AVI_FILE_PARSER_SUCCESS;
-                    error = iPVAviFile->GetNextStreamMediaSample(iSettings.iStreamNumber, aData, aDataSize, aTimeStamp);
+
+                    uint32 currticks  = 0;
+                    currticks = OsclTickCount::TickCount();
+                    uint32 starttime = 0;
+                    starttime = OsclTickCount::TicksToMsec(currticks);
+
+                    error = iPVAviFile->GetNextStreamMediaSample(iSettings.iStreamNumber, aData, aDataSize, iNptTS);
+
+                    currticks = OsclTickCount::TickCount();
+                    uint32 endtime = 0;
+                    endtime = OsclTickCount::TicksToMsec(currticks);
+
+                    LOGDIAGNOSTICS_AVI_FF((0, "PvmiMIOAviWavFile::GetMediaData:"
+                                           "StreamNum=%d, NptTS=%d, Size=%d, TimeToRead=%d, MimeType=%s",
+                                           iSettings.iStreamNumber,  iNptTS, aDataSize, (endtime - starttime),
+                                           iSettings.iMimeType.get_cstr()));
 
                     if (error != PV_AVI_FILE_PARSER_SUCCESS)
                     {
@@ -1065,11 +1170,13 @@
                     }
                     else
                     {
+                        UpdateCurrentTimeStamp(aDataSize);
                         return PVMFSuccess;
                     }
                 }
                 else
                 {
+                    UpdateCurrentTimeStamp(aDataSize);
                     return PVMFInfoEndOfData;
                 }
             }
@@ -1090,8 +1197,6 @@
             {
                 aDataSize = samplesRead * iSettings.iNumChannels * (iSettings.iSampleSize / BYTE_COUNT);
             }
-
-            aTimeStamp = iCurrentTimeStamp + PVWAV_MSEC_PER_BUFFER;
         }
         else if (PVWAVPARSER_END_OF_FILE == retcode)
         {
@@ -1109,8 +1214,7 @@
                     {
                         aDataSize = samplesRead * iSettings.iNumChannels * (iSettings.iSampleSize / BYTE_COUNT);
                     }
-
-                    aTimeStamp = iCurrentTimeStamp + PVWAV_MSEC_PER_BUFFER;
+                    UpdateCurrentTimeStamp(aDataSize);
                     return PVMFSuccess;
                 }
                 else
@@ -1120,6 +1224,7 @@
             }
             else
             {
+                UpdateCurrentTimeStamp(aDataSize);
                 return PVMFInfoEndOfData;
             }
         }
@@ -1128,31 +1233,27 @@
             return PVMFFailure;
         }
     }
-
+    UpdateCurrentTimeStamp(aDataSize);
     return PVMFSuccess;
 }
 ////////////////////////////////////////////////////////////////////////////
-void PvmiMIOAviWavFile::GetNextTimeStamp(uint32 aDataSize)
+void PvmiMIOAviWavFile::UpdateCurrentTimeStamp(uint32 aDataSize)
 {
     if (iPVAviFile != NULL)
     {
         if (oscl_strstr((iPVAviFile->GetStreamMimeType(iSettings.iStreamNumber)).get_cstr(), "video"))
         {
-            iNextTimeStamp = iCurrentTimeStamp + (iPVAviFile->GetFrameDuration() / 1000); //in msec
+            iCurrentTimeStamp += (iPVAviFile->GetFrameDuration() / 1000); //in msec
         }
         else if (oscl_strstr((iPVAviFile->GetStreamMimeType(iSettings.iStreamNumber)).get_cstr(), "audio"))
         {
-            if (aDataSize == 0)
-            {
-                uint32 ii = 0;
-            }
             uint32 numSamples = aDataSize * BYTE_COUNT / iSettings.iSampleSize;
-            iNextTimeStamp = iCurrentTimeStamp + (numSamples * 1000) / iSettings.iSamplingFrequency;
+            iCurrentTimeStamp = (uint32)((OsclFloat)iCurrentTimeStamp + (OsclFloat)(numSamples * 1000) / iSettings.iSamplingFrequency);
         }
     }
     else  //WAV File
     {
-        iNextTimeStamp = iCurrentTimeStamp + PVWAV_MSEC_PER_BUFFER;
+        iCurrentTimeStamp += PVWAV_MSEC_PER_BUFFER;
     }
 
 
@@ -1191,10 +1292,10 @@
     int32 err = 0;
 
     //process new data only if previous data has been send to MIO node.
-    if (!iWaitingOnClock)
+    if ((!iWaitingOnClock) && (iWriteState == EWriteOK))
     {
         // Create new media data buffer
-        OSCL_TRY(err, data = (uint8*)iMediaBufferMemPool->allocate(dataSize););
+        data = AllocateMemPool(iMediaBufferMemPool, dataSize, err);
 
         if (err)
         {
@@ -1210,181 +1311,165 @@
             return PVMFSuccess;
         }
 
-        iData = NULL;
-        iDataSize = 0;
-        iTimeStamp = 0;
-
-#if PROFILING_ON
-        uint32 start = OsclTickCount::TickCount();
-#endif
-        //read media data
-        error = GetMediaData(data, dataSize, timeStamp);
-
-#if PROFILING_ON
-        uint32 stop = OsclTickCount::TickCount();
-        uint32 freadTime = OsclTickCount::TicksToMsec(stop - start);
-
-        if (error == PVMFSuccess)
+        if (iNoMemBufferData)//check added for ErrorHandling test case for no memory buffer
         {
-            if (iMaxDataSize < dataSize)
-            {
-                iMaxDataSize = dataSize;
-            }
-            if ((iMinDataSize > dataSize) || (0 == iMinDataSize))
-            {
-                iMinDataSize = dataSize;
-            }
-            if (iMaxFileReadTime < freadTime)
-            {
-                iMaxFileReadTime = freadTime;
-            }
-            if ((iMinFileReadTime > freadTime) || (0 == iMinFileReadTime))
-            {
-                iMinFileReadTime = freadTime;
-            }
+            iMediaBufferMemPool->deallocate(iData);
+            iData = NULL;
+            iDataSize = 0;
+            iNoMemBufferData = false;
         }
-#endif
-        if (error != PVMFSuccess)
+        else
         {
-            if (PVMFInfoEndOfData == error) //EOS Reached
+            iData = NULL;
+            iDataSize = 0;
+            iTimeStamp = 0;
+        }
+
+        bool senddata = false;
+
+
+        while (!senddata)
+        {
+
+#if PROFILING_ON
+            uint32 start = OsclTickCount::TickCount();
+#endif
+            //read media data
+            error = GetMediaData(data, dataSize, timeStamp);
+
+#if PROFILING_ON
+            uint32 stop = OsclTickCount::TickCount();
+            uint32 freadTime = OsclTickCount::TicksToMsec(stop - start);
+
+            if (error == PVMFSuccess)
             {
-                //free the allocated data buffer
-                iMediaBufferMemPool->deallocate(data);
-                data = NULL;
-
-                PvmiMediaXferHeader data_hdr;
-                data_hdr.seq_num = iDataEventCounter - 1;
-                data_hdr.timestamp = iNextTimeStamp;
-                data_hdr.flags = 0;
-                data_hdr.duration = 0;
-                data_hdr.stream_id = iSettings.iStreamNumber;
-                dataSize = 0;
-                //send EOS information to MIO Node
-                OSCL_TRY(error, writeAsyncID = iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION, PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM,
-                                               NULL, dataSize, data_hdr););
-
-                if (error)
+                if (iMaxDataSize < dataSize)
                 {
-                    if (iSettings.iRecModeSyncWithClock)
-                        CalcMicroSecPerDataEvent(dataSize);
-                    else
-                        iMicroSecondsPerDataEvent = 0;
+                    iMaxDataSize = dataSize;
+                }
+                if ((iMinDataSize > dataSize) || (0 == iMinDataSize))
+                {
+                    iMinDataSize = dataSize;
+                }
+                if (iMaxFileReadTime < freadTime)
+                {
+                    iMaxFileReadTime = freadTime;
+                }
+                if ((iMinFileReadTime > freadTime) || (0 == iMinFileReadTime))
+                {
+                    iMinFileReadTime = freadTime;
+                }
+            }
+#endif
+            if (error != PVMFSuccess)
+            {
+                if (PVMFInfoEndOfData == error) //EOS Reached
+                {
+                    //free the allocated data buffer
+                    iMediaBufferMemPool->deallocate(data);
+                    data = NULL;
 
-                    //some error occured, retry sending EOS next time.
-                    AddDataEventToQueue(iMicroSecondsPerDataEvent);
+                    PvmiMediaXferHeader data_hdr;
+                    data_hdr.seq_num = iDataEventCounter - 1;
+                    data_hdr.timestamp = timeStamp;
+                    data_hdr.flags = 0;
+                    data_hdr.duration = 0;
+                    data_hdr.stream_id = iSettings.iStreamNumber;
+                    dataSize = 0;
+                    //send EOS information to MIO Node
+                    error = WriteAsyncDataHdr(writeAsyncID, iPeer, dataSize, data_hdr, NULL, PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION, PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM);
+
+                    if (error)
+                    {
+                        if (iSettings.iRecModeSyncWithClock)
+                            CalcMicroSecPerDataEvent(dataSize);
+                        else
+                            iMicroSecondsPerDataEvent = 0;
+
+                        //some error occured, retry sending EOS next time.
+                        AddDataEventToQueue(iMicroSecondsPerDataEvent);
+                        return PVMFSuccess;
+                    }
+                    iWriteState = EWriteOK;
+
+                    LOGDATATRAFFIC((0, "PvmiMIOAviWavFile::DoRead - EOS Sent:"
+                                    "StreamID=%d, TS=%d, SN=%d, MimeType=%s",
+                                    data_hdr.stream_id,  data_hdr.timestamp,
+                                    data_hdr.seq_num, iSettings.iMimeType.get_cstr()));
+                    //EOS message was sent so PAUSE MIO Component.
+                    AddCmdToQueue(CMD_PAUSE, NULL);
+
+                    return PVMFSuccess;
+                }
+                else
+                {
+                    //free the allocated data buffer
+                    iMediaBufferMemPool->deallocate(data);
+                    data = NULL;
+                    AddCmdToQueue(CMD_STOP, NULL);
+                    return error;
+                }
+            }
+
+#if PROFILING_ON
+            iTotalFrames++;
+#endif
+            if (iSettings.iRecModeSyncWithClock)
+            {
+
+                uint32 clockTime32 = 0;
+                uint32 clockTimeBase32 = 0;
+                bool overflowFlag = false;
+
+                if (iMioClock->GetState() != PVMFMediaClock::RUNNING)
+                {
+                    iMioClock->SetStartTime32(timeStamp, PVMF_MEDIA_CLOCK_MSEC, overflowFlag);
+                    iMioClock->Start();
+                }
+
+
+                //Compare with Clock time to pass data forward.
+                iMioClock->GetCurrentTime32(clockTime32, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, clockTimeBase32);
+
+                if (timeStamp > clockTime32)
+                {
+                    uint32 delta = timeStamp - clockTime32;
+                    //store data info to be send forward in next callback.
+                    iData = data;
+                    iDataSize = dataSize;
+                    iTimeStamp = timeStamp;
+                    AddDataEventToQueue(delta * 1000); //delta in microseconds.
+                    iWaitingOnClock = true;
+#if PROFILING_ON
+                    iNumEarlyFrames++;
+#endif
                     return PVMFSuccess;
                 }
 
-                //EOS message was sent so PAUSE MIO Component.
-                AddCmdToQueue(CMD_PAUSE, NULL);
-
-                return PVMFSuccess;
-            }
-            else
-            {
-                //free the allocated data buffer
-                iMediaBufferMemPool->deallocate(data);
-                data = NULL;
-                AddCmdToQueue(CMD_STOP, NULL);
-                return error;
-            }
-        }
-
-#if PROFILING_ON
-        iTotalFrames++;
-#endif
-        timeStamp += iBaseTimeStamp;
-
-        if ((iBaseTimeStamp > 0) && timeStamp < iBaseTimeStamp)
-        {
-            //timestamp rollover. reset base timestamp
-            iBaseTimeStamp = 0;
-        }
-
-        iCurrentTimeStamp = timeStamp;
-
-        if (iSettings.iRecModeSyncWithClock)
-        {
-
-            uint64 clockTime64 = 0;
-            uint64 clockTimeBase64 = 0;
-            uint32 clockTime32 = 0;
-            uint64 adjustTime64 = 0;
-
-            if (iMioClock->GetState() != OsclClock::RUNNING)
-            {
-                iMioClock->SetStartTime32(timeStamp, OSCLCLOCK_MSEC);
-                iMioClock->Start();
-            }
-
-
-            //Compare with Clock time to pass data forward.
-            iMioClock->GetCurrentTime64(clockTime64, OSCLCLOCK_MSEC, clockTimeBase64);
-            clockTime32 = Oscl_Int64_Utils::get_uint64_lower32(clockTime64);
-
-            Oscl_Int64_Utils::set_uint64(adjustTime64, 0, iCurrentTimeStamp);
-
-            if (adjustTime64 > clockTime64)
-            {
-                uint32 delta = iCurrentTimeStamp - clockTime32;
-                //store data info to be send forward in next callback.
-                iData = data;
-                iDataSize = dataSize;
-                iTimeStamp = timeStamp;
-                AddDataEventToQueue(delta * 1000); //delta in microseconds.
-                iWaitingOnClock = true;
-#if PROFILING_ON
-                iNumEarlyFrames++;
-#endif
-                return PVMFSuccess;
-            }
-
-#if PROFILING_ON
-            if (adjustTime64 < clockTime64)
-            {
-                iNumLateFrames++;
-            }
-#endif
-
-        }	// 	if (iSettings.iRecModeSyncWithClock)
-
-        GetNextTimeStamp(dataSize);
-
-        if (iSettings.iNumLoops && (iCurrentTimeStamp == iNextTimeStamp))
-        {
-            //could be due to small data chunk in the end of the file.
-            //If looping, store this data chunk and read more data from file
-            uint8* newdata = data + dataSize;
-            uint32 newDataSize = iSettings.iDataBufferSize - dataSize;
-            uint32 numLoops = iSettings.iNumLoops;
-
-            //read more data
-            error = GetMediaData(newdata, newDataSize, timeStamp);
-
-            if (PVMFSuccess == error)
-            {
-                dataSize += newDataSize;
-                if (numLoops > iSettings.iNumLoops) //received EOS recalculate base timestamp
+                if (timeStamp < clockTime32)
                 {
-                    GetNextTimeStamp(dataSize);
-                    iBaseTimeStamp = iNextTimeStamp;
+#if PROFILING_ON
+                    iNumLateFrames++;
+#endif
+                    dataSize = iSettings.iDataBufferSize;
 
-                    //use the timestamp of last sample (in the end of file).
-                    timeStamp = iCurrentTimeStamp;
+                    if (dataSize <= 0)
+                    {
+                        return PVMFErrArgument;
+                    }
                 }
-            }
+
+                if (timeStamp == clockTime32)
+                {
+                    senddata = true;
+                }
+
+            }	// 	if (iSettings.iRecModeSyncWithClock)
             else
             {
-                //if read fails, do nothing here, send the original data
-                // and hope that we will be able to read more data next time.
-                // Set dummy timestamp for next sample.
-
-                iNextTimeStamp += 1;
+                senddata = true;
             }
-
-        }  //if (iSettings.iNumLoops && (iCurrentTimeStamp == iNextTimeStamp))
-
-
+        }   // while (!senddata)
     }	//	if (!iWaitingOnClock)
 
     iWaitingOnClock = false;
@@ -1394,81 +1479,82 @@
         data = iData;
         dataSize = iDataSize;
         timeStamp = iTimeStamp;
+        iData = NULL;
     }
 
     // send data to Peer & store the id
     PvmiMediaXferHeader data_hdr;
     data_hdr.seq_num = iDataEventCounter - 1;
-    data_hdr.timestamp = iCurrentTimeStamp;
+    data_hdr.timestamp = timeStamp;
     data_hdr.flags = 0;
     data_hdr.duration = 0;
     data_hdr.stream_id = iSettings.iStreamNumber;
 
-
     if (!iPeer)
     {
         return PVMFSuccess;
     }
-
-    OSCL_TRY(err, writeAsyncID = iPeer->writeAsync(0, 0, data, dataSize, data_hdr););
+    err = WriteAsyncDataHdr(writeAsyncID, iPeer, dataSize, data_hdr, data, PVMI_MEDIAXFER_FMT_TYPE_DATA, 0);
     if (!err)
     {
+        LOGDATATRAFFIC((0, "PvmiMIOAviWavFile::DoRead:"
+                        "StreamID=%d, TS=%d, Size=%d, SN=%d, MimeType=%s",
+                        data_hdr.stream_id,  data_hdr.timestamp, dataSize,
+                        data_hdr.seq_num, iSettings.iMimeType.get_cstr()));
+
         // Save the id and data pointer on iSentMediaData queue for writeComplete call
         PvmiMIOAviWavFileMediaData sentData;
         sentData.iId = writeAsyncID;
         sentData.iData = data;
         iSentMediaData.push_back(sentData);
+        iMicroSecondsPerDataEvent = 0;
+        // Queue the next data event
+        AddDataEventToQueue(iMicroSecondsPerDataEvent);
+    }
+    else if (err == OsclErrBusy)
+    {
+        iData = data;
+        iDataSize = dataSize;
+        iTimeStamp = timeStamp;
+        iWriteState = EWriteBusy;
+        iNoMemBufferData = true;
     }
     else
     {
         iMediaBufferMemPool->deallocate(data);
     }
 
-
-    iMicroSecondsPerDataEvent = 0;
-    // Queue the next data event
-    AddDataEventToQueue(iMicroSecondsPerDataEvent);
-
     return PVMFSuccess;
 }
 
 PVMFStatus PvmiMIOAviWavFile::CalcMicroSecPerDataEvent(uint32 aDataSize)
 {
     //calculate time for a buffer to fill
-    switch (iSettings.iMediaFormat)
+    if (iSettings.iMediaFormat == PVMF_MIME_YUV420)
     {
-            //case PVMF_YUV422:
-        case PVMF_YUV420:
-        {
-            //calculate time for a buffer to fill
-            iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
+        //calculate time for a buffer to fill
+        iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
 
-            iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate);
-        }
-        break;
-
-        case PVMF_RGB16:
-        case PVMF_RGB24:
-        {
-            //calculate time for a buffer to fill
-            iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
-            iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate);
-        }
-        break;
-
-        case PVMF_PCM16:
-        case PVMF_PCM8:
-        {
-            OsclFloat chunkrate = (OsclFloat)((OsclFloat)iSettings.iByteRate / (OsclFloat)aDataSize);
-            iMilliSecondsPerDataEvent = (uint32)(1000 / chunkrate);
-            iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
-        }
-        break;
-
-        default:
-            return PVMFErrArgument;
-
-    } // end switch
+        iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate);
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_RGB16 ||
+             iSettings.iMediaFormat == PVMF_MIME_RGB24)
+    {
+        //calculate time for a buffer to fill
+        iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
+        iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate);
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_PCM16 ||
+             iSettings.iMediaFormat == PVMF_MIME_PCM8)
+    {
+        OsclFloat chunkrate = (OsclFloat)((OsclFloat)iSettings.iByteRate / (OsclFloat)aDataSize);
+        iMilliSecondsPerDataEvent = (uint32)(1000 / chunkrate);
+        iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
+    }
+    else
+    {
+        return PVMFErrArgument;
+    }
 
     return PVMFSuccess;
 }
@@ -1517,6 +1603,7 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmiMIOAviWavFile::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
 {
+    OSCL_UNUSED_ARG(aSetParam);
     LOG_STACK_TRACE((0, "PvmiMIOAviWavFile::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
 
     if (!aKvp)
@@ -1527,7 +1614,7 @@
 
     if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
     {
-        if (aKvp->value.uint32_value == iSettings.iMediaFormat)
+        if (aKvp->value.pChar_value == (char*)iSettings.iMediaFormat.getMIMEStrPtr())
         {
             return PVMFSuccess;
         }
@@ -1547,10 +1634,12 @@
 {
 #if PROFILING_ON
     oDiagnosticsLogged = true;
-    PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iDiagnosticsLogger, PVLOGMSG_DEBUG,
-                    (0, "PvmiMIOAviWavFile Stats: Stream :%s\n",
-                     (iPVAviFile->GetStreamMimeType(iSettings.iStreamNumber)).get_cstr()));
-
+    if (iPVAviFile)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iDiagnosticsLogger, PVLOGMSG_DEBUG,
+                        (0, "PvmiMIOAviWavFile Stats: Stream :%s\n",
+                         (iPVAviFile->GetStreamMimeType(iSettings.iStreamNumber)).get_cstr()));
+    }
     uint32 framerate = 0;
 
     if (iCurrentTimeStamp > 0)
@@ -1575,3 +1664,16 @@
 #endif
 }
 
+uint8* PvmiMIOAviWavFile::AllocateMemPool(OsclMemPoolFixedChunkAllocator*& aMediaBufferMemPool, uint32 aDataSize, int32 &aErr)
+{
+    uint8* data = NULL;;
+    OSCL_TRY(aErr, data = (uint8*)aMediaBufferMemPool->allocate(aDataSize););
+    return data;
+}
+
+int32 PvmiMIOAviWavFile::WriteAsyncDataHdr(uint32& aWriteAsyncID, PvmiMediaTransfer*& aPeer, uint32& aBytesToRead, PvmiMediaXferHeader& aData_hdr, uint8* aData, uint32 aFormatType, uint32 aFormatIndex)
+{
+    int err = 0;
+    OSCL_TRY(err, aWriteAsyncID = aPeer->writeAsync(aFormatType, aFormatIndex, aData, aBytesToRead, aData_hdr););
+    return err;
+}
diff --git a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.h b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.h
index 5651fe5..cc60658 100644
--- a/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.h
+++ b/pvmi/media_io/pvmi_mio_avi_wav_fileinput/src/pvmi_mio_avi_wav_file.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,8 +46,8 @@
 #include "oscl_vector.h"
 #endif
 
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
 
 #ifndef PVLOGGER_H_INCLUDED
@@ -83,6 +83,7 @@
 #endif
 
 
+#define MAKE_FOURCC(a , b, c, d)		((uint32(a) << 24) | (uint32(b) << 16) | (uint32(c) << 8) | uint32(d))
 
 // Forward declaration
 class PvmiMIOAviWavFileSettings;
@@ -106,7 +107,63 @@
     INVALID_CMD
 } PvmiMIOAviWavFileCmdType;
 
-
+const uint32   YUV_FMT[] =
+{
+    MAKE_FOURCC('A', 'Y', 'U', 'V'),
+    MAKE_FOURCC('a', 'y', 'u', 'v'),
+    MAKE_FOURCC('C', 'L', 'J', 'R'),
+    MAKE_FOURCC('c', 'l', 'j', 'r'),
+    MAKE_FOURCC('I', 'Y', 'U', 'V'),
+    MAKE_FOURCC('i', 'y', 'u', 'v'),
+    MAKE_FOURCC('G', 'R', 'E', 'Y'),
+    MAKE_FOURCC('g', 'r', 'e', 'y'),
+    MAKE_FOURCC('I', 'Y', '4', '1'),
+    MAKE_FOURCC('i', 'y', '4', '1'),
+    MAKE_FOURCC('I', 'Y', 'U', '1'),
+    MAKE_FOURCC('i', 'y', 'u', '1'),
+    MAKE_FOURCC('Y', '4', '1', 'P'),
+    MAKE_FOURCC('y', '4', '1', 'p'),
+    MAKE_FOURCC('Y', '4', '1', '1'),
+    MAKE_FOURCC('y', '4', '1', '1'),
+    MAKE_FOURCC('Y', '4', '1', 'T'),
+    MAKE_FOURCC('y', '4', '1', 't'),
+    MAKE_FOURCC('Y', '4', '2', 'T'),
+    MAKE_FOURCC('y', '4', '2', 't'),
+    MAKE_FOURCC('Y', '8', '0', '0'),
+    MAKE_FOURCC('y', '8', '0', '0'),
+    MAKE_FOURCC('Y', '8', ' ', ' '),
+    MAKE_FOURCC('y', '8', ' ', ' '),
+    MAKE_FOURCC('Y', '2', '1', '1'),
+    MAKE_FOURCC('y', '2', '1', '1'),
+    MAKE_FOURCC('I', '4', '2', '0'),
+    MAKE_FOURCC('i', '4', '2', '0'),
+    MAKE_FOURCC('I', 'Y', 'U', '1'),
+    MAKE_FOURCC('i', 'y', 'u', '1'),
+    MAKE_FOURCC('Y', 'V', '1', '6'),
+    MAKE_FOURCC('y', 'v', '1', '6'),
+    MAKE_FOURCC('Y', 'V', '1', '2'),
+    MAKE_FOURCC('y', 'v', '1', '2'),
+    MAKE_FOURCC('C', 'L', 'P', 'L'),
+    MAKE_FOURCC('c', 'l', 'p', 'l'),
+    MAKE_FOURCC('N', 'V', '1', '2'),
+    MAKE_FOURCC('n', 'v', '1', '2'),
+    MAKE_FOURCC('N', 'V', '2', '1'),
+    MAKE_FOURCC('n', 'v', '2', '1'),
+    MAKE_FOURCC('I', 'M', 'C', '1'),
+    MAKE_FOURCC('i', 'm', 'c', '1'),
+    MAKE_FOURCC('I', 'M', 'C', '2'),
+    MAKE_FOURCC('i', 'm', 'c', '2'),
+    MAKE_FOURCC('I', 'M', 'C', '3'),
+    MAKE_FOURCC('i', 'm', 'c', '3'),
+    MAKE_FOURCC('I', 'M', 'C', '4'),
+    MAKE_FOURCC('i', 'm', 'c', '4'),
+    MAKE_FOURCC('C', 'X', 'Y', '1'),
+    MAKE_FOURCC('c', 'x', 'y', '1'),
+    MAKE_FOURCC('Y', 'V', 'Y', '2'),
+    MAKE_FOURCC('y', 'v', 'y', '2'),
+    MAKE_FOURCC('U', 'Y', 'V', 'Y'),
+    MAKE_FOURCC('u', 'y', 'v', 'y'),
+};
 const uint32 BITS_PER_SAMPLE8		= 8;
 const uint32 BITS_PER_SAMPLE12		= 12;
 const uint32 BITS_PER_SAMPLE16		= 16;
@@ -114,6 +171,7 @@
 const uint32 PVWAV_MSEC_PER_BUFFER	= 100;
 const uint32 BYTE_COUNT				= 8;
 const uint32 DATA_BUFF_THRESHOLD	= 1;
+const uint32   NUM_YUV_FMT				= 54;
 
 #define PROFILING_ON (PVLOGGER_INST_LEVEL >= PVLOGMSG_INST_PROF)
 
@@ -303,8 +361,11 @@
          * @return PVMFSuccess if parameter is supported, else PVMFFailure
          */
         PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
-        void GetNextTimeStamp(uint32 aDataSize);
+        void UpdateCurrentTimeStamp(uint32 aDataSize);
         void LogDiagnostics();
+        bool IsYUVFormat_Supported(uint32 aFcc);
+        uint8* AllocateMemPool(OsclMemPoolFixedChunkAllocator*&, uint32, int32&);
+        int32 WriteAsyncDataHdr(uint32&, PvmiMediaTransfer*&, uint32&, PvmiMediaXferHeader&, uint8*, uint32, uint32);
 
         // Command queue
         uint32 iCmdIdCounter;
@@ -345,6 +406,8 @@
         // Logger
         PVLogger* iLogger;
         PVLogger* iDiagnosticsLogger;
+        PVLogger* iDiagnosticsLoggerAVIFF;
+        PVLogger* iDataPathLogger;
 
         // State machine
         enum PvmiMIOAviWavFileState
@@ -358,16 +421,16 @@
         };
 
         PvmiMIOAviWavFileState iState;
-        OsclClock* iMioClock;
-        OsclTimebase_Tickcount iClockTimeBase;
+        PVMFMediaClock* iMioClock;
+        PVMFTimebase_Tickcount iClockTimeBase;
         bool iWaitingOnClock;
-        uint8* iData;
         uint32 iDataSize;
         uint32 iTimeStamp;
         uint32 iStreamDuration ;  // in microsec
-        uint32 iBaseTimeStamp;
         uint32 iCurrentTimeStamp;
-        uint32 iNextTimeStamp;
+        enum WriteState {EWriteBusy, EWriteOK};
+        WriteState iWriteState;
+        uint8* iData;
 
 #if PROFILING_ON
         //for diagnostics purpose
@@ -382,6 +445,7 @@
         bool   oDiagnosticsLogged;
 #endif
 
+        bool iNoMemBufferData;
 };
 
 #endif // PVMI_MIO_AVIFILE_H_INCLUDED
diff --git a/pvmi/media_io/pvmi_mio_fileinput/Android.mk b/pvmi/media_io/pvmi_mio_fileinput/Android.mk
index 1ad31d8..e9b0af5 100644
--- a/pvmi/media_io/pvmi_mio_fileinput/Android.mk
+++ b/pvmi/media_io/pvmi_mio_fileinput/Android.mk
@@ -2,26 +2,29 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvmi_mio_fileinput.cpp
-
+ 	src/pvmi_mio_fileinput.cpp
 
 
 LOCAL_MODULE := libpvmiofileinput
 
-LOCAL_CFLAGS := -DTEXT_TRACK_DESC_INFO  $(PV_CFLAGS)
+LOCAL_CFLAGS := -DTEXT_TRACK_DESC_INFO $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_fileinput/include \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_fileinput/src \
-	$(PV_TOP)//pvmi/media_io/pvmi_mio_fileinput/../../pvmf/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/media_io/pvmi_mio_fileinput/src \
+ 	$(PV_TOP)/pvmi/media_io/pvmi_mio_fileinput/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/../src/pvmi_mio_fileinput.h \
-	include/pvmi_mio_fileinput_factory.h
+ 	include/pvmi_mio_fileinput_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor/local.mk b/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor/local.mk
new file mode 100644
index 0000000..29b9ee8
--- /dev/null
+++ b/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor/local.mk
@@ -0,0 +1,81 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmiofileinput 
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+XCPPFLAGS += -DTEXT_TRACK_DESC_INFO
+
+XINCDIRS += ../../../../pvmf/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmi_mio_fileinput.cpp 
+
+
+HDRS := ../src/pvmi_mio_fileinput.h \
+       pvmi_mio_fileinput_factory.h
+
+	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+include $(MK)/library.mk
diff --git a/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor/makefile b/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor/makefile
deleted file mode 100644
index c293bf1..0000000
--- a/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor/makefile
+++ /dev/null
@@ -1,111 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmiofileinput 
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-XCPPFLAGS += -DTEXT_TRACK_DESC_INFO
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I../../../../pvmf/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmi_mio_fileinput.cpp 
-
-
-HDRS = ../src/pvmi_mio_fileinput.h \
-       pvmi_mio_fileinput_factory.h
-
-	
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/pvmi/media_io/pvmi_mio_fileinput/include/pvmi_mio_fileinput_factory.h b/pvmi/media_io/pvmi_mio_fileinput/include/pvmi_mio_fileinput_factory.h
index 566b979..d22db43 100644
--- a/pvmi/media_io/pvmi_mio_fileinput/include/pvmi_mio_fileinput_factory.h
+++ b/pvmi/media_io/pvmi_mio_fileinput/include/pvmi_mio_fileinput_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@
     public:
         PvmiMIOFileInputSettings()
         {
-            iMediaFormat = PVMF_FORMAT_UNKNOWN;
+            iMediaFormat = PVMF_MIME_FORMAT_UNKNOWN;
             iLoopInputFile = true;
             iSamplingFrequency = 8000;
             iNumChannels = 1;
@@ -72,7 +72,7 @@
 
         ~PvmiMIOFileInputSettings()
         {
-            iMediaFormat = PVMF_FORMAT_UNKNOWN;
+            iMediaFormat = PVMF_MIME_FORMAT_UNKNOWN;
             iLoopInputFile = true;
             iSamplingFrequency = 8000;
             iNumChannels = 1;
diff --git a/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.cpp b/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.cpp
index 1398d41..601437f 100644
--- a/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.cpp
+++ b/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@
 {
     if (iMediaBufferMemPool)
     {
-        OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+        OSCL_DELETE(iMediaBufferMemPool);
         iMediaBufferMemPool = NULL;
     }
 }
@@ -437,8 +437,21 @@
 ////////////////////////////////////////////////////////////////////////////
 OSCL_EXPORT_REF void PvmiMIOFileInput::statusUpdate(uint32 status_flags)
 {
-    OSCL_UNUSED_ARG(status_flags);
-    OSCL_LEAVE(OsclErrNotSupported);
+    if (status_flags == PVMI_MEDIAXFER_STATUS_WRITE)
+    {
+        iMicroSecondsPerDataEvent = 0;
+        AddDataEventToQueue(iMicroSecondsPerDataEvent);
+    }
+    else
+    {
+        // Ideally this routine should update the status of media input component.
+        // It should check then for the status. If media input buffer is consumed,
+        // media input object should be resheduled.
+        // Since the Media fileinput component is designed with single buffer, two
+        // asynchronous reads are not possible. So this function will not be required
+        // and hence not been implemented.
+        OSCL_LEAVE(OsclErrNotSupported);
+    }
 }
 
 
@@ -482,20 +495,20 @@
             pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)OUTPUT_FORMATS_VALTYPE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOFileInput::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
         }
         else
         {
-            parameters[0].value.uint32_value = iSettings.iMediaFormat;
+            parameters[0].value.pChar_value = (char*)iSettings.iMediaFormat.getMIMEStrPtr();
         }
     }
     else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_WIDTH_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)VIDEO_OUTPUT_WIDTH_CUR_VALUE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOFileInput::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -507,7 +520,7 @@
     else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_HEIGHT_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_HEIGHT_CUR_VALUE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)VIDEO_OUTPUT_HEIGHT_CUR_VALUE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOFileInput::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -519,7 +532,7 @@
     else if (pv_mime_strcmp(identifier, VIDEO_OUTPUT_FRAME_RATE_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)VIDEO_OUTPUT_FRAME_RATE_CUR_VALUE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PvmiMIOFileInput::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -531,7 +544,7 @@
     else if (pv_mime_strcmp(identifier, OUTPUT_TIMESCALE_CUR_QUERY) == 0)
     {
         num_parameter_elements = 1;
-        status = AllocateKvp(parameters, OUTPUT_TIMESCALE_CUR_VALUE, num_parameter_elements);
+        status = AllocateKvp(parameters, (PvmiKeyType)OUTPUT_TIMESCALE_CUR_VALUE, num_parameter_elements);
         if (status != PVMFSuccess)
         {
             LOG_ERR((0, "PVMFVideoEncPort::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
@@ -539,15 +552,13 @@
         }
         else
         {
-            switch (GetMediaTypeIndex(iSettings.iMediaFormat))
+            if (iSettings.iMediaFormat.isAudio())
             {
-                case PVMF_UNCOMPRESSED_AUDIO_FORMAT:
-                case PVMF_COMPRESSED_AUDIO_FORMAT:
-                    parameters[0].value.uint32_value = iSettings.iSamplingFrequency;
-                    break;
-                default:
-                    parameters[0].value.uint32_value = iSettings.iTimescale;
-                    break;
+                parameters[0].value.uint32_value = iSettings.iSamplingFrequency;
+            }
+            else
+            {
+                parameters[0].value.uint32_value = iSettings.iTimescale;
             }
         }
     }
@@ -686,9 +697,9 @@
         iPreTS(0),
         iCount(0),
         iMediaBufferMemPool(NULL),
+        iNotificationID(0),
         iLogger(NULL),
         iState(STATE_IDLE),
-        iNotificationID(0),
         iAuthoringDuration(0),
         iStreamDuration(0)
 {
@@ -825,386 +836,378 @@
     iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
     fileSize = fileEnd - fileStart;
 
-    switch (iSettings.iMediaFormat)
+    if (iSettings.iMediaFormat == PVMF_MIME_M4V ||
+            iSettings.iMediaFormat == PVMF_MIME_H2631998 ||
+            iSettings.iMediaFormat == PVMF_MIME_H2632000)
     {
-        case PVMF_M4V:
-        case PVMF_H263:
+        int32  frameSize;
+        uint32 bytesProcessed;
+        uint8* fileData;
+        uint8* currentFrame;
+        int32 skip;
+
+        // Validate settings
+        if (iSettings.iFrameHeight <= 0 || iSettings.iFrameWidth <= 0 ||
+                iSettings.iFrameRate <= 0 || iSettings.iTimescale <= 0)
         {
-            int32  bytesProcessed, frameSize;
-            uint8* fileData;
-            uint8* currentFrame;
-            int32 skip;
-
-            // Validate settings
-            if (iSettings.iFrameHeight <= 0 || iSettings.iFrameWidth <= 0 ||
-                    iSettings.iFrameRate <= 0 || iSettings.iTimescale <= 0)
-            {
-                CloseInputFile();
-                return PVMFErrArgument;
-            }
-
-            fileData = NULL;
-            fileData = (uint8*)iAlloc.allocate(fileSize);
-            if (!fileData)
-            {
-                CloseInputFile();
-                return PVMFErrNoMemory;
-            }
-
-            // Read the whole file to data buffer then go back to front
-            iInputFile.Read((OsclAny*)fileData, sizeof(uint8), fileSize);
-            iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
-
-            // Get ready to search for frame sizes
-            iFrameSizeVector.reserve(200);
-            currentFrame = fileData;
-            bytesProcessed = 0;
-
-            // Calculate time for a buffer to fill to simulate frame rate
-            iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
-            iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
-
-            // Find size of each frame iteratively until end of file
-            iTotalNumFrames = 0;
-            if (iSettings.iMediaFormat == PVMF_M4V)
-            {
-                while (bytesProcessed < fileSize)
-                {
-                    do
-                    {
-                        skip = 1;
-                        frameSize = LocateM4VFrameHeader(currentFrame + skip, fileSize - bytesProcessed - skip);
-                        if (currentFrame[3] == 0xb3) /* GOV header */
-                        {
-                            skip += (frameSize + 1);
-                            frameSize = LocateM4VFrameHeader(currentFrame + skip, fileSize - bytesProcessed - skip);
-                        }
-                        if (frameSize == 0) skip++;
-                    }
-                    while (frameSize == 0);
-
-                    if (frameSize > 0)
-                    {
-                        frameSize += skip;
-                    }
-                    else
-                    {
-                        frameSize = fileSize - bytesProcessed;
-                    }
-
-                    if (frameSize > (int32)maxFrameSize)
-                        maxFrameSize = frameSize;
-                    iFrameSizeVector.push_back(frameSize);
-                    currentFrame += frameSize;
-                    bytesProcessed += frameSize;
-                    ++iTotalNumFrames;
-                }
-            }
-            else
-            {
-                // H263
-                while (bytesProcessed < fileSize)
-                {
-
-                    do
-                    {
-                        skip = 1;
-                        frameSize = LocateH263FrameHeader(currentFrame + skip, fileSize - bytesProcessed - skip);
-                        if (frameSize == 0) skip++;
-                    }
-                    while (frameSize == 0);
-
-                    if (frameSize > 0)
-                    {
-                        frameSize += skip;
-                    }
-                    else
-                    {
-                        frameSize = fileSize - bytesProcessed;
-                    }
-
-                    if (frameSize > (int32)maxFrameSize)
-                        maxFrameSize = frameSize;
-                    iFrameSizeVector.push_back(frameSize);
-                    currentFrame += frameSize;
-                    bytesProcessed += frameSize;
-                    ++iTotalNumFrames;
-                }
-            }
-
-            iAlloc.deallocate((OsclAny*)fileData);
-            iStreamDuration = iTotalNumFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
+            CloseInputFile();
+            return PVMFErrArgument;
         }
-        break;
-        case PVMF_3GPP_TIMEDTEXT:
+
+        fileData = NULL;
+        fileData = (uint8*)iAlloc.allocate(fileSize);
+        if (!fileData)
         {
-            iTotalNumFrames = 0;
-            // Validate settings
-            if (iSettings.iFrameHeight <= 0 || iSettings.iFrameWidth <= 0 ||
-                    iSettings.iTimescale <= 0)
-            {
-                CloseInputFile();
-                return PVMFErrArgument;
-            }
-
-            if (!iFsOpened_log)
-            {
-                if (iFs_log.Connect() != 0)
-                    return PVMFFailure;
-                iFsOpened_log = true;
-            }
-
-            if (iFileOpened_log ||
-                    0 != iLogFile.Open(iSettings.iLogFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, iFs_log))
-            {
-                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                                (0, "PvmiMIOFileInput::DoInit: Error - iLogFile.Open for timed text file format failed"));
-                return PVMFFailure;
-            }
-
-            iFileOpened_log = true;
-
-
-            int32  bytesProcessed, frameSize, timestamp;
-            uint8* fileData;
-            uint8* currentFrame;
-
-            fileData = NULL;
-            fileData = (uint8*)iAlloc.allocate(fileSize);
-            if (!fileData)
-            {
-                CloseInputFile();
-                return PVMFErrNoMemory;
-            }
-
-            // Read the whole file to data buffer then go back to front
-            iInputFile.Read((OsclAny*)fileData, sizeof(uint8), fileSize);
-            iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
-
-            // Get ready to search for frame sizes
-            iFrameSizeVector.reserve(2500);
-            currentFrame = fileData;
-            bytesProcessed = 0;
-
-
-            int32 ii = 0;
-            int32 offset = 0;
-            int32 numSamplesInTrack = 0;
-            uint32 timescale = 0;
-            uint32 bitrate = 0;
-            iLogFile.Seek(offset, Oscl_File::SEEKSET);
-            iLogFile.Read(&numSamplesInTrack, sizeof(char), 4);
-            offset = offset + 4;
-
-            //iLogFile.Seek( offset, Oscl_File::SEEKSET );  //the information
-            iLogFile.Read(&bitrate, sizeof(char), 4);		//present in the log file
-            offset = offset + 4;
-
-            //iLogFile.Seek( offset, Oscl_File::SEEKSET );
-            iLogFile.Read(&timescale, sizeof(char), 4);
-            offset = offset + 4;
-            iSettings.iTimescale = timescale;
-            uint8  isTrackDuration = false;
-            uint32 trackDuration = 0;
-            iLogFile.Read(&isTrackDuration, sizeof(char), 1);
-            if (isTrackDuration)
-            {
-                iLogFile.Read(&trackDuration, sizeof(char), 4);
-            }
-            offset = offset + 5;
-            //iLogFile.Seek( offset, Oscl_File::SEEKSET );
-            //iLogFile.Read(&maxbuffersize, sizeof(char), 4);
-            offset = offset + 4;
-            iTotalNumFrames = numSamplesInTrack;
-            while (numSamplesInTrack)
-            {
-                iLogFile.Seek(offset, Oscl_File::SEEKSET);
-                iLogFile.Read(&SampleSizeArray[ii], sizeof(char), 4);    //size of the ith frame
-
-                frameSize = SampleSizeArray[ii];
-                if ((uint32)frameSize > maxFrameSize)
-                    maxFrameSize = frameSize;
-                iFrameSizeVector.push_back(frameSize);
-                currentFrame += frameSize;
-                bytesProcessed += frameSize;
-                ii++;
-                offset = offset + 4;
-                iLogFile.Seek(offset, Oscl_File::SEEKSET);
-                iLogFile.Read(&TextTimeStampArray[ii], sizeof(char), 4);
-                timestamp = TextTimeStampArray[ii];
-                iTextTimeStampVector.push_back(timestamp);
-                offset = offset + 4;
-                numSamplesInTrack--;
-            }
-
-
-            //added for the time being, need to be re-evaluated
-            iMicroSecondsPerDataEvent = iSettings.iTimescale * 2;
-            iAlloc.deallocate((OsclAny*)fileData);
-            if (iFileOpened_log)
-            {
-                iLogFile.Close();
-                iFileOpened_log = false;
-            }
-
-            if (iFsOpened_log)
-            {
-                iFs_log.Close();
-                iFsOpened_log = false;
-            }
-
-            iStreamDuration = trackDuration / iSettings.iTimescale * 1000; //in msec
+            CloseInputFile();
+            return PVMFErrNoMemory;
         }
-        break;
-        case PVMF_YUV420:
+
+        // Read the whole file to data buffer then go back to front
+        iInputFile.Read((OsclAny*)fileData, sizeof(uint8), fileSize);
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+
+        // Get ready to search for frame sizes
+        iFrameSizeVector.reserve(200);
+        currentFrame = fileData;
+        bytesProcessed = 0;
+
+        // Calculate time for a buffer to fill to simulate frame rate
+        iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
+        iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
+
+        // Find size of each frame iteratively until end of file
+        iTotalNumFrames = 0;
+        if (iSettings.iMediaFormat == PVMF_MIME_M4V)
         {
-            // Set bytes per frame
-            maxFrameSize = (uint32)(iSettings.iFrameHeight * iSettings.iFrameWidth * 3 / 2);
-            iFrameSizeVector.push_back(maxFrameSize);
-
-            //calculate time for a buffer to fill
-            iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
-            iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate);
-
-            uint32 numFrames = fileSize / maxFrameSize;
-            iStreamDuration = numFrames * (iMicroSecondsPerDataEvent) / 1000; //in msec
-        }
-        break;
-
-        case PVMF_RGB16:
-        {
-            // Set bytes per frame
-            maxFrameSize = (uint32)(iSettings.iFrameHeight * iSettings.iFrameWidth *  2);
-            iFrameSizeVector.push_back(maxFrameSize);
-
-            //calculate time for a buffer to fill
-            iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
-            iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate - 1);
-
-            uint32 numFrames = fileSize / maxFrameSize;
-            iStreamDuration = numFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
-        }
-        break;
-
-
-        case PVMF_PCM16:
-        {
-            // Set bytes per frame
-            maxFrameSize = AMR_FRAME_DELAY * iSettings.iSamplingFrequency / 1000 * 2 * iSettings.iNum20msFramesPerChunk;
-            iFrameSizeVector.push_back(maxFrameSize);
-
-            //calculate time for a buffer to fill
-            float chunkrate = (float)(1000 / AMR_FRAME_DELAY) / iSettings.iNum20msFramesPerChunk;
-            iMilliSecondsPerDataEvent = (uint32)(1000 / chunkrate);
-            iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
-            uint32 numFrames = fileSize / maxFrameSize;
-            iStreamDuration = numFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
-        }
-        break;
-
-        case PVMF_AMR_IF2:
-        case PVMF_AMR_IETF:
-        {
-            int32  bytesProcessed, size, frameSize;
-            uint32 chunk;
-            uint8* fileData;
-            uint8* currentFrame;
-
-            fileData = NULL;
-            fileData = (uint8*)iAlloc.allocate(fileSize);
-            if (!fileData)
-            {
-                CloseInputFile();
-                return PVMFErrNoMemory;
-            }
-
-            // Read the whole file to data buffer then go back to front
-            iInputFile.Read((OsclAny*)fileData, sizeof(uint8), fileSize);
-            iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
-
-            // Get ready to search for frame sizes
-            iFrameSizeVector.reserve(500);
-            currentFrame = fileData;
-            bytesProcessed = 0;
-
-            //skip AMR file header.
-            if (currentFrame[0] == '#')
-            {
-                iFileHeaderSize = 6;
-                currentFrame += iFileHeaderSize;
-                iInputFile.Seek(iFileHeaderSize, Oscl_File::SEEKSET);
-                bytesProcessed = 6;
-            }
-
-            // Find size of each frame iteratively until end of file
-            iTotalNumFrames = 0;
             while (bytesProcessed < fileSize)
             {
-                frameSize = 0;
-                for (chunk = 0; (chunk < iSettings.iNum20msFramesPerChunk) && (bytesProcessed < fileSize); chunk++)
+                do
                 {
-                    if (iSettings.iMediaFormat == PVMF_AMR_IF2)
-                        size = GetIF2FrameSize(currentFrame[0]);
-                    else
-                        size = GetIETFFrameSize(currentFrame[0]);
-                    frameSize += size;
-                    currentFrame += size;
-                    bytesProcessed += size;
+                    skip = 1;
+                    frameSize = LocateM4VFrameHeader(currentFrame + skip, fileSize - bytesProcessed - skip);
+                    if (currentFrame[3] == 0xb3) /* GOV header */
+                    {
+                        skip += (frameSize + 1);
+                        frameSize = LocateM4VFrameHeader(currentFrame + skip, fileSize - bytesProcessed - skip);
+                    }
+                    if (frameSize == 0) skip++;
+                }
+                while (frameSize == 0);
+
+                if (frameSize > 0)
+                {
+                    frameSize += skip;
+                }
+                else
+                {
+                    frameSize = fileSize - bytesProcessed;
                 }
 
                 if (frameSize > (int32)maxFrameSize)
                     maxFrameSize = frameSize;
                 iFrameSizeVector.push_back(frameSize);
+                currentFrame += frameSize;
+                bytesProcessed += frameSize;
                 ++iTotalNumFrames;
             }
-
-            // Calculate time for a buffer to fill to simulate frame rate
-            iMilliSecondsPerDataEvent = 20 * iSettings.iNum20msFramesPerChunk;
-            iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
-            iAlloc.deallocate((OsclAny*)fileData);
-            iStreamDuration = iTotalNumFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
         }
-        break;
-
-        case PVMF_ADTS:
-        case PVMF_ADIF:
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_MP3:
+        else
         {
-            int32  bytesProcessed, frameSize;
-
-            // Get ready to search for frame sizes
-            iFrameSizeVector.reserve(500);
-            bytesProcessed = 0;
-
-            // Find size of each frame iteratively until end of file
-            iTotalNumFrames = 0;
+            // H263
             while (bytesProcessed < fileSize)
             {
-                if ((fileSize - bytesProcessed) < 1024)
-                    frameSize = fileSize - bytesProcessed;
+
+                do
+                {
+                    skip = 1;
+                    frameSize = LocateH263FrameHeader(currentFrame + skip, fileSize - bytesProcessed - skip);
+                    if (frameSize == 0) skip++;
+                }
+                while (frameSize == 0);
+
+                if (frameSize > 0)
+                {
+                    frameSize += skip;
+                }
                 else
-                    frameSize = 1024;
-                bytesProcessed += frameSize;
+                {
+                    frameSize = fileSize - bytesProcessed;
+                }
+
+                if (frameSize > (int32)maxFrameSize)
+                    maxFrameSize = frameSize;
                 iFrameSizeVector.push_back(frameSize);
+                currentFrame += frameSize;
+                bytesProcessed += frameSize;
                 ++iTotalNumFrames;
             }
-
-            // Calculate time for a buffer to fill to simulate frame rate
-            maxFrameSize = 1024;
-            iMilliSecondsPerDataEvent = 20;
-            iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
-            iStreamDuration = iTotalNumFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
         }
-        break;
 
-        default:
+        iAlloc.deallocate((OsclAny*)fileData);
+        iStreamDuration = iTotalNumFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_3GPP_TIMEDTEXT)
+    {
+        iTotalNumFrames = 0;
+        // Validate settings
+        if (iSettings.iFrameHeight <= 0 || iSettings.iFrameWidth <= 0 ||
+                iSettings.iTimescale <= 0)
+        {
             CloseInputFile();
             return PVMFErrArgument;
+        }
+
+        if (!iFsOpened_log)
+        {
+            if (iFs_log.Connect() != 0)
+                return PVMFFailure;
+            iFsOpened_log = true;
+        }
+
+        if (iFileOpened_log ||
+                0 != iLogFile.Open(iSettings.iLogFileName.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, iFs_log))
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                            (0, "PvmiMIOFileInput::DoInit: Error - iLogFile.Open for timed text file format failed"));
+            return PVMFFailure;
+        }
+
+        iFileOpened_log = true;
+
+
+        int32  frameSize, timestamp;
+        uint32 bytesProcessed;
+        uint8* fileData;
+        uint8* currentFrame;
+
+        fileData = NULL;
+        fileData = (uint8*)iAlloc.allocate(fileSize);
+        if (!fileData)
+        {
+            CloseInputFile();
+            return PVMFErrNoMemory;
+        }
+
+        // Read the whole file to data buffer then go back to front
+        iInputFile.Read((OsclAny*)fileData, sizeof(uint8), fileSize);
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+
+        // Get ready to search for frame sizes
+        iFrameSizeVector.reserve(2500);
+        currentFrame = fileData;
+        bytesProcessed = 0;
+
+
+        int32 ii = 0;
+        int32 offset = 0;
+        int32 numSamplesInTrack = 0;
+        uint32 timescale = 0;
+        uint32 bitrate = 0;
+        iLogFile.Seek(offset, Oscl_File::SEEKSET);
+        iLogFile.Read(&numSamplesInTrack, sizeof(char), 4);
+        offset = offset + 4;
+
+        //iLogFile.Seek( offset, Oscl_File::SEEKSET );  //the information
+        iLogFile.Read(&bitrate, sizeof(char), 4);		//present in the log file
+        offset = offset + 4;
+
+        //iLogFile.Seek( offset, Oscl_File::SEEKSET );
+        iLogFile.Read(&timescale, sizeof(char), 4);
+        offset = offset + 4;
+        iSettings.iTimescale = timescale;
+        uint8  isTrackDuration = false;
+        uint32 trackDuration = 0;
+        iLogFile.Read(&isTrackDuration, sizeof(char), 1);
+        if (isTrackDuration)
+        {
+            iLogFile.Read(&trackDuration, sizeof(char), 4);
+        }
+        offset = offset + 5;
+        //iLogFile.Seek( offset, Oscl_File::SEEKSET );
+        //iLogFile.Read(&maxbuffersize, sizeof(char), 4);
+        offset = offset + 4;
+        iTotalNumFrames = numSamplesInTrack;
+        while (numSamplesInTrack)
+        {
+            iLogFile.Seek(offset, Oscl_File::SEEKSET);
+            iLogFile.Read(&SampleSizeArray[ii], sizeof(char), 4);    //size of the ith frame
+
+            frameSize = SampleSizeArray[ii];
+            if ((uint32)frameSize > maxFrameSize)
+                maxFrameSize = frameSize;
+            iFrameSizeVector.push_back(frameSize);
+            currentFrame += frameSize;
+            bytesProcessed += frameSize;
+            ii++;
+            offset = offset + 4;
+            iLogFile.Seek(offset, Oscl_File::SEEKSET);
+            iLogFile.Read(&TextTimeStampArray[ii], sizeof(char), 4);
+            timestamp = TextTimeStampArray[ii];
+            iTextTimeStampVector.push_back(timestamp);
+            offset = offset + 4;
+            numSamplesInTrack--;
+        }
+
+
+        //added for the time being, need to be re-evaluated
+        iMicroSecondsPerDataEvent = iSettings.iTimescale * 2;
+        iAlloc.deallocate((OsclAny*)fileData);
+        if (iFileOpened_log)
+        {
+            iLogFile.Close();
+            iFileOpened_log = false;
+        }
+
+        if (iFsOpened_log)
+        {
+            iFs_log.Close();
+            iFsOpened_log = false;
+        }
+
+        iStreamDuration = trackDuration / iSettings.iTimescale * 1000; //in msec
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_YUV420)
+    {
+        // Set bytes per frame
+        maxFrameSize = (uint32)(iSettings.iFrameHeight * iSettings.iFrameWidth * 3 / 2);
+        iFrameSizeVector.push_back(maxFrameSize);
+
+        //calculate time for a buffer to fill
+        iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
+        iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate);
+        uint32 numFrames = fileSize / maxFrameSize;
+        iStreamDuration = numFrames * (iMicroSecondsPerDataEvent) / 1000; //in msec
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_RGB16)
+    {
+        // Set bytes per frame
+        maxFrameSize = (uint32)(iSettings.iFrameHeight * iSettings.iFrameWidth *  2);
+        iFrameSizeVector.push_back(maxFrameSize);
+
+        //calculate time for a buffer to fill
+        iMilliSecondsPerDataEvent = (int32)(1000 / iSettings.iFrameRate);
+        iMicroSecondsPerDataEvent = (int32)(1000000 / iSettings.iFrameRate - 1);
+        uint32 numFrames = fileSize / maxFrameSize;
+        iStreamDuration = numFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_PCM16)
+    {
+        // Set bytes per frame
+        maxFrameSize = AMR_FRAME_DELAY * iSettings.iSamplingFrequency / 1000 * 2 * iSettings.iNum20msFramesPerChunk;
+        iFrameSizeVector.push_back(maxFrameSize);
+
+        //calculate time for a buffer to fill
+        float chunkrate = (float)(1000 / AMR_FRAME_DELAY) / iSettings.iNum20msFramesPerChunk;
+        iMilliSecondsPerDataEvent = (uint32)(1000 / chunkrate);
+        iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
+        uint32 numFrames = fileSize / maxFrameSize;
+        iStreamDuration = numFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_AMR_IF2 ||
+             iSettings.iMediaFormat == PVMF_MIME_AMR_IETF)
+    {
+        int32  size, frameSize;
+        uint32 bytesProcessed;
+        uint32 chunk;
+        uint8* fileData;
+        uint8* currentFrame;
+
+        fileData = NULL;
+        fileData = (uint8*)iAlloc.allocate(fileSize);
+        if (!fileData)
+        {
+            CloseInputFile();
+            return PVMFErrNoMemory;
+        }
+
+        // Read the whole file to data buffer then go back to front
+        iInputFile.Read((OsclAny*)fileData, sizeof(uint8), fileSize);
+        iInputFile.Seek(fileStart, Oscl_File::SEEKSET);
+
+        // Get ready to search for frame sizes
+        iFrameSizeVector.reserve(500);
+        currentFrame = fileData;
+        bytesProcessed = 0;
+
+        //skip AMR file header.
+        if (currentFrame[0] == '#')
+        {
+            iFileHeaderSize = 6;
+            currentFrame += iFileHeaderSize;
+            iInputFile.Seek(iFileHeaderSize, Oscl_File::SEEKSET);
+            bytesProcessed = 6;
+        }
+
+        // Find size of each frame iteratively until end of file
+        iTotalNumFrames = 0;
+        while (bytesProcessed < fileSize)
+        {
+            frameSize = 0;
+            for (chunk = 0; (chunk < iSettings.iNum20msFramesPerChunk) && (bytesProcessed < fileSize); chunk++)
+            {
+                if (iSettings.iMediaFormat == PVMF_MIME_AMR_IF2)
+                    size = GetIF2FrameSize(currentFrame[0]);
+                else
+                    size = GetIETFFrameSize(currentFrame[0]);
+                frameSize += size;
+                currentFrame += size;
+                bytesProcessed += size;
+            }
+
+            if (frameSize > (int32)maxFrameSize)
+                maxFrameSize = frameSize;
+            iFrameSizeVector.push_back(frameSize);
+            ++iTotalNumFrames;
+        }
+
+        // Calculate time for a buffer to fill to simulate frame rate
+        iMilliSecondsPerDataEvent = 20 * iSettings.iNum20msFramesPerChunk;
+        iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
+        iAlloc.deallocate((OsclAny*)fileData);
+        iStreamDuration = iTotalNumFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_ADTS ||
+             iSettings.iMediaFormat == PVMF_MIME_ADIF ||
+             iSettings.iMediaFormat == PVMF_MIME_MPEG4_AUDIO ||
+             iSettings.iMediaFormat == PVMF_MIME_MP3)
+    {
+        int32 frameSize;
+        uint32 bytesProcessed;
+
+        // Get ready to search for frame sizes
+        iFrameSizeVector.reserve(500);
+        bytesProcessed = 0;
+
+        // Find size of each frame iteratively until end of file
+        iTotalNumFrames = 0;
+        while (bytesProcessed < fileSize)
+        {
+            if ((fileSize - bytesProcessed) < 1024)
+                frameSize = fileSize - bytesProcessed;
+            else
+                frameSize = 1024;
+            bytesProcessed += frameSize;
+            iFrameSizeVector.push_back(frameSize);
+            ++iTotalNumFrames;
+        }
+
+        // Calculate time for a buffer to fill to simulate frame rate
+        maxFrameSize = 1024;
+        iMilliSecondsPerDataEvent = 20;
+        iMicroSecondsPerDataEvent = iMilliSecondsPerDataEvent * 1000;
+        iStreamDuration = iTotalNumFrames * (iMicroSecondsPerDataEvent / 1000); //in msec
+    }
+    else
+    {
+        CloseInputFile();
+        return PVMFErrArgument;
     }
 
-    //set default authoring duration
-    iAuthoringDuration = iStreamDuration;
+    if (!iSettings.iLoopInputFile)
+    {
+        //set default authoring duration
+        iAuthoringDuration = iStreamDuration;
+    }
 
     iDataEventCounter = 0;
     CloseInputFile();
@@ -1214,7 +1217,7 @@
     OSCL_TRY(err,
              if (iMediaBufferMemPool)
 {
-    OSCL_TEMPLATED_DELETE(iMediaBufferMemPool, OsclMemPoolFixedChunkAllocator, OsclMemPoolFixedChunkAllocator);
+    OSCL_DELETE(iMediaBufferMemPool);
         iMediaBufferMemPool = NULL;
     }
     iMediaBufferMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator,
@@ -1317,75 +1320,70 @@
     uint32 writeAsyncID = 0;
 
     //Find the frame...
-    switch (iSettings.iMediaFormat)
+    if (iSettings.iMediaFormat == PVMF_MIME_M4V ||
+            iSettings.iMediaFormat == PVMF_MIME_H2631998 ||
+            iSettings.iMediaFormat == PVMF_MIME_H2632000)
     {
-        case PVMF_M4V:
-        case PVMF_H263:
-            bytesToRead = iFrameSizeVector[iDataEventCounter % iTotalNumFrames];
-            timeStamp = (int32)(iDataEventCounter * 1000 / iSettings.iFrameRate);
-            ++iDataEventCounter;
-            break;
-        case PVMF_3GPP_TIMEDTEXT:
+        bytesToRead = iFrameSizeVector[iDataEventCounter % iTotalNumFrames];
+        timeStamp = (int32)(iDataEventCounter * 1000 / iSettings.iFrameRate);
+        ++iDataEventCounter;
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_3GPP_TIMEDTEXT)
+    {
+        bytesToRead = iFrameSizeVector[iDataEventCounter % iTotalNumFrames];
+        uint32 ts = iTextTimeStampVector[iDataEventCounter % iTotalNumFrames];
+        if ((iDataEventCounter % iTotalNumFrames) == 0)
         {
-            bytesToRead = iFrameSizeVector[iDataEventCounter % iTotalNumFrames];
-            uint32 ts = iTextTimeStampVector[iDataEventCounter % iTotalNumFrames];
-            if ((iDataEventCounter % iTotalNumFrames) == 0)
-            {
-                ++iCount;
-                iPreTS = iPreTS * iCount;
-            }
-            if (iPreTS > ts)
-            {
-                timeStamp = ts + iPreTS;
-            }
-            else
-            {
-                timeStamp = ts;
-                iPreTS = timeStamp;
-            }
-            ++iDataEventCounter;
+            ++iCount;
+            iPreTS = iPreTS * iCount;
         }
-        break;
-        case PVMF_AMR_IF2:
-        case PVMF_AMR_IETF:
-        case PVMF_ADTS:
-        case PVMF_MPEG4_AUDIO:
-        case PVMF_ADIF:
-        case PVMF_MP3:
-            bytesToRead = iFrameSizeVector[iDataEventCounter % iTotalNumFrames];
-            timeStamp = iTimeStamp;
-            iTimeStamp += iMilliSecondsPerDataEvent;
-            ++iDataEventCounter;
-            break;
-
-            //case PVMF_YUV422:
-        case PVMF_YUV420:
-        case PVMF_RGB16:
-            bytesToRead = iFrameSizeVector[0];
-            timeStamp = (int32)(iDataEventCounter * 1000 / iSettings.iFrameRate);
-            ++iDataEventCounter;
-            break;
-
-        case PVMF_PCM16:
+        if (iPreTS > ts)
         {
-            bytesToRead = iFrameSizeVector[0];
-            float chunkrate = (float)(1000 / AMR_FRAME_DELAY) / iSettings.iNum20msFramesPerChunk;
-            timeStamp = (uint32)(iDataEventCounter * 1000 / chunkrate);
-            ++iDataEventCounter;
+            timeStamp = ts + iPreTS;
         }
-        break;
-
-        default:
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
-                            (0, "PvmiMIOFileInput::HandleEventPortActivity: Error - Unsupported media format"));
-            return PVMFFailure;
+        else
+        {
+            timeStamp = ts;
+            iPreTS = timeStamp;
+        }
+        ++iDataEventCounter;
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_AMR_IF2 ||
+             iSettings.iMediaFormat == PVMF_MIME_AMR_IETF ||
+             iSettings.iMediaFormat == PVMF_MIME_ADTS ||
+             iSettings.iMediaFormat == PVMF_MIME_MPEG4_AUDIO ||
+             iSettings.iMediaFormat == PVMF_MIME_ADIF ||
+             iSettings.iMediaFormat == PVMF_MIME_MP3)
+    {
+        bytesToRead = iFrameSizeVector[iDataEventCounter % iTotalNumFrames];
+        timeStamp = iTimeStamp;
+        iTimeStamp += iMilliSecondsPerDataEvent;
+        ++iDataEventCounter;
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_YUV420 ||
+             iSettings.iMediaFormat == PVMF_MIME_RGB16)
+    {
+        bytesToRead = iFrameSizeVector[0];
+        timeStamp = (int32)(iDataEventCounter * 1000 / iSettings.iFrameRate);
+        ++iDataEventCounter;
+    }
+    else if (iSettings.iMediaFormat == PVMF_MIME_PCM16)
+    {
+        bytesToRead = iFrameSizeVector[0];
+        float chunkrate = (float)(1000 / AMR_FRAME_DELAY) / iSettings.iNum20msFramesPerChunk;
+        timeStamp = (uint32)(iDataEventCounter * 1000 / chunkrate);
+        ++iDataEventCounter;
+    }
+    else
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                        (0, "PvmiMIOFileInput::HandleEventPortActivity: Error - Unsupported media format"));
+        return PVMFFailure;
     }
 
     // Create new media data buffer
     int32 error = 0;
-    OSCL_TRY(error,
-             data = (uint8*)iMediaBufferMemPool->allocate(bytesToRead);
-            );
+    data = AllocateMemPool(iMediaBufferMemPool, bytesToRead, error);
 
     if (error)
     {
@@ -1400,7 +1398,7 @@
     uint32 len = 0;
     uint32 stopTimeStamp = 0;
 
-    if (iSettings.iMediaFormat == PVMF_3GPP_TIMEDTEXT)
+    if (iSettings.iMediaFormat == PVMF_MIME_3GPP_TIMEDTEXT)
     {
         stopTimeStamp = (timeStamp / iSettings.iTimescale) * 1000; //in msec
 
@@ -1410,15 +1408,23 @@
         stopTimeStamp = timeStamp;
     }
 
-    if (stopTimeStamp <= iAuthoringDuration)
+    if (!iSettings.iLoopInputFile)
     {
-        len = iInputFile.Read((OsclAny*)data, sizeof(uint8), bytesToRead);
+        if (stopTimeStamp <= iAuthoringDuration)
+        {
+            len = iInputFile.Read((OsclAny*)data, sizeof(uint8), bytesToRead);
+        }
+        else
+        {
+            len = 0;
+        }
     }
     else
     {
-        len = 0;
+        len = iInputFile.Read((OsclAny*)data, sizeof(uint8), bytesToRead);
     }
 
+
     if (len != bytesToRead)
     {
         if ((iInputFile.EndOfFile() != 0) || (stopTimeStamp >= iAuthoringDuration))
@@ -1450,8 +1456,7 @@
                 bytesToRead = 0;
 
                 //send EOS information to MIO Node
-                OSCL_TRY(error, writeAsyncID = iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION, PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM,
-                                               NULL, bytesToRead, data_hdr););
+                error = WriteAsyncDataHdr(writeAsyncID, iPeer, bytesToRead, data_hdr);
 
                 if (error)
                 {
@@ -1480,7 +1485,7 @@
 
     if (len == bytesToRead)//Data Read Successfully
     {
-        if (iSettings.iMediaFormat == PVMF_3GPP_TIMEDTEXT && !iTimed_Text_configinfo) //added for timed text support
+        if (iSettings.iMediaFormat == PVMF_MIME_3GPP_TIMEDTEXT && !iTimed_Text_configinfo) //added for timed text support
         {
             if (Get_Timed_Config_Info() != PVMFSuccess)
             {
@@ -1500,7 +1505,7 @@
         data_hdr.stream_id = 0;
         if (!iPeer)
             return PVMFSuccess;
-        OSCL_TRY(error, writeAsyncID = iPeer->writeAsync(0, 0, data, bytesToRead, data_hdr););
+        OSCL_TRY(error, writeAsyncID = iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA, 0, data, bytesToRead, data_hdr););
         if (!error)
         {
             // Save the id and data pointer on iSentMediaData queue for writeComplete call
@@ -1509,6 +1514,11 @@
             sentData.iData = data;
             iSentMediaData.push_back(sentData);
         }
+        else if (error == OsclErrBusy)
+        {
+            iDataEventCounter--;
+            iMediaBufferMemPool->deallocate(data);
+        }
         else
         {
             iMediaBufferMemPool->deallocate(data);
@@ -1716,6 +1726,7 @@
 ////////////////////////////////////////////////////////////////////////////
 PVMFStatus PvmiMIOFileInput::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
 {
+    OSCL_UNUSED_ARG(aSetParam);
     LOG_STACK_TRACE((0, "PvmiMIOFileInput::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
 
     if (!aKvp)
@@ -1726,14 +1737,14 @@
 
     if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
     {
-        if (aKvp->value.uint32_value == iSettings.iMediaFormat)
+        if (iSettings.iMediaFormat == aKvp->value.pChar_value)
         {
             return PVMFSuccess;
         }
         else
         {
-            LOG_ERR((0, "PvmiMIOFileInput::VerifyAndSetParameter: Error - Unsupported format %d",
-                     aKvp->value.uint32_value));
+            LOG_ERR((0, "PvmiMIOFileInput::VerifyAndSetParameter: Error - Unsupported format %s",
+                     aKvp->value.pChar_value));
             return PVMFFailure;
         }
     }
@@ -1741,28 +1752,53 @@
     LOG_ERR((0, "PvmiMIOFileInput::VerifyAndSetParameter: Error - Unsupported parameter"));
     return PVMFFailure;
 }
-char* PvmiMIOFileInput::DecoderInfo(char* buffer, char* res)
+
+bool PvmiMIOFileInput::DecoderInfo(char* buffer, char* bufferEnd, char* res, uint32 resSize)
 {
     uint32 ji = 0;
-    oscl_memset(res, 0, sizeof(res));
-
-    while (buffer != NULL)
+    if ((NULL == buffer) || (NULL == bufferEnd) || (resSize <= 0))
     {
-        char* first = oscl_strstr(buffer, "= ");
+        return false;
+    }
+
+    oscl_memset(res, 0, resSize);
+
+    while (buffer < bufferEnd)
+    {
+        char* first = OSCL_CONST_CAST(char*, oscl_strstr(buffer, "= "));
+        if (NULL == first)
+        {
+            return false;
+        }
 
         first += 2;
-        char * temp = first;
+        char* temp = first;
         while (*first != '\n')
         {
             ji++;
             first += 1;
+
+            if ('\r' == *first)
+            {
+                break;
+            }
+
+            if (first >= bufferEnd)
+            {
+                return false;
+            }
         }
-        oscl_strncpy(res, temp, ji);
+
+        if (ji < resSize)
+        {
+            oscl_strncpy(res, temp, ji);
+        }
 
         iptextfiledata = first;
-        return(res);
-    }
-    return NULL;
+        break;
+    }   //(buffer < bufferEnd)
+
+    return true;
 }
 
 PVMFStatus PvmiMIOFileInput::Get_Timed_Config_Info()
@@ -1797,8 +1833,8 @@
 
     fileSize = fileEnd - fileStart;
     iptextfiledata = NULL;
-    iptextfiledata = (char*)iAlloc.allocate(fileSize);
-
+    iptextfiledata = (char*)iAlloc.allocate(fileSize + 1);
+    oscl_memset(iptextfiledata, 0, fileSize + 1);
     if (!iptextfiledata)
     {
         return PVMFErrNoMemory;
@@ -1810,134 +1846,240 @@
 
     char* buff = iptextfiledata;
     char* tempbuff = iptextfiledata;
-    char* val = (char*)OSCL_MALLOC(10 * sizeof(char));
+    uint32 valsize = 10;
+    char* val = (char*)OSCL_MALLOC(valsize * sizeof(char));
     uint32 temp = 0;
-    while (iptextfiledata != NULL)
+    while (iptextfiledata < (buff + fileSize))
     {
         PVA_FF_TextSampleDescInfo *ipDecoderinfo;
         ipDecoderinfo = OSCL_NEW(PVA_FF_TextSampleDescInfo, ());
-        oscl_memset(val, 0, sizeof(val));
+        oscl_memset(val, 0, valsize);
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         PV_atoi(val, 'd', (uint32&)ipDecoderinfo->start_sample_num);
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         PV_atoi(val, 'd', (uint32&)ipDecoderinfo->sdindex);
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         PV_atoi(val, 'd', (uint32&)ipDecoderinfo->display_flags);
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         PV_atoi(val, 'd', (uint32&)ipDecoderinfo->hJust);
 
 
         temp = 0;
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         PV_atoi(val, 'd', (uint32&) temp);
         ipDecoderinfo->vJust = temp;
 
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->bkRgba[0] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->bkRgba[1] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->bkRgba[2] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->bkRgba[3] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->top = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->left = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->bottom = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->right = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->startChar = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->endChar = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->fontID = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->fontSizeFlags = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->fontSize = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->tRgba[0] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->tRgba[1] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->tRgba[2] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->tRgba[3] = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->fontListSize = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->fontListID = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->font_id = temp;
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
+
         temp = 0;
         PV_atoi(val, 'd', (uint32&)temp);
         ipDecoderinfo->font_length = temp;
@@ -1945,14 +2087,22 @@
         if (ipDecoderinfo->font_length > 0)
         {
             ipDecoderinfo->font_name = (uint8 *)(OSCL_MALLOC(ipDecoderinfo->font_length * sizeof(char) + 1));
-            DecoderInfo(iptextfiledata, val);
+            if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+            {
+                OSCL_DELETE(ipDecoderinfo);
+                break;
+            }
             oscl_strncpy((char *)ipDecoderinfo->font_name, val, ipDecoderinfo->font_length);
         }
 
-        DecoderInfo(iptextfiledata, val);
+        if (!DecoderInfo(iptextfiledata, (buff + fileSize), val, valsize))
+        {
+            OSCL_DELETE(ipDecoderinfo);
+            break;
+        }
         PV_atoi(val, 'd', (uint32&)ipDecoderinfo->end_sample_num);
 
-        uint32 length = oscl_strlen(tempbuff) - oscl_strlen(iptextfiledata) + 1;
+        uint32 length = sizeof(ipDecoderinfo) + 2 * DEFAULT_RGB_ARRAY_SIZE + ipDecoderinfo->font_length;
 
         PvmiMediaXferHeader data_hdr;
 
@@ -1960,7 +2110,7 @@
         //allocate KVP
         PvmiKvp* aKvp = NULL;
         PVMFStatus status = PVMFSuccess;
-        status = AllocateKvp(aKvp, TIMED_TEXT_OUTPUT_CONFIG_INFO_CUR_VALUE, 1);
+        status = AllocateKvp(aKvp, (PvmiKeyType)TIMED_TEXT_OUTPUT_CONFIG_INFO_CUR_VALUE, 1);
 
         if (status != PVMFSuccess)
         {
@@ -1969,8 +2119,6 @@
             return 0;
         }
 
-        PvmiKvp* ret_kvp = NULL;
-
         aKvp->value.key_specific_value = ipDecoderinfo;
         aKvp->capacity = length;
 
@@ -1981,21 +2129,20 @@
 
         iSentMediaData.push_back(textConfInfo);
 
+        int32 err = 0;
         //typecast to pass in writeAsync
         uint8* notifData = OSCL_STATIC_CAST(uint8*, aKvp);
-
-        iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION,
-                          PVMI_MEDIAXFER_FMT_INDEX_FMT_SPECIFIC_INFO,
-                          notifData, length, data_hdr, &iNotificationID);
-
-        tempbuff = iptextfiledata; //to calculate the one decoderinfo size
-
-        int32 len = oscl_strlen(iptextfiledata);
-        if (len < MINBUFFERSIZE)
+        OSCL_TRY(err, iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION,
+                                        PVMI_MEDIAXFER_FMT_INDEX_FMT_SPECIFIC_INFO,
+                                        notifData, length, data_hdr, &iNotificationID););
+        if (!err)
         {
-            break;
+            tempbuff = iptextfiledata; //to calculate the one decoderinfo size
         }
-
+        else
+        {
+            return PVMFFailure;
+        }
     }
     if (val)
     {
@@ -2022,3 +2169,17 @@
 }
 
 
+uint8* PvmiMIOFileInput::AllocateMemPool(OsclMemPoolFixedChunkAllocator*& aMediaBufferMemPool, uint32 aDataSize, int32 &aErr)
+{
+    uint8* data = NULL;
+    OSCL_TRY(aErr, data = (uint8*)aMediaBufferMemPool->allocate(aDataSize););
+    return data;
+}
+
+int32 PvmiMIOFileInput::WriteAsyncDataHdr(uint32& aWriteAsyncID, PvmiMediaTransfer*& aPeer, uint32& aBytesToRead, PvmiMediaXferHeader& aData_hdr)
+{
+    int err = 0;
+    OSCL_TRY(err, aWriteAsyncID = aPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_NOTIFICATION, PVMI_MEDIAXFER_FMT_INDEX_END_OF_STREAM,
+                                  NULL, aBytesToRead, aData_hdr););
+    return err;
+}
diff --git a/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.h b/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.h
index cee4169..6aa3c54 100644
--- a/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.h
+++ b/pvmi/media_io/pvmi_mio_fileinput/src/pvmi_mio_fileinput.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -276,7 +276,9 @@
         PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
 
 
-        char* DecoderInfo(char* buffer, char* res);
+        bool DecoderInfo(char* buffer, char* bufferEnd, char* res, uint32 resSize);
+        uint8* AllocateMemPool(OsclMemPoolFixedChunkAllocator*&, uint32, int32&);
+        int32 WriteAsyncDataHdr(uint32&, PvmiMediaTransfer*&, uint32&, PvmiMediaXferHeader&);
 
         // Command queue
         uint32 iCmdIdCounter;
diff --git a/pvmi/media_io/pvmio_comm_loopback/Android.mk b/pvmi/media_io/pvmio_comm_loopback/Android.mk
new file mode 100644
index 0000000..bb60b19
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/Android.mk
@@ -0,0 +1,33 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pvmi_mio_comm_loopback.cpp \
+ 	src/pvmi_mio_comm_data_buffer.cpp
+
+
+LOCAL_MODULE := libpvmio_comm_loopback
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/pvmi/media_io/pvmio_comm_loopback/src \
+ 	$(PV_TOP)/pvmi/media_io/pvmio_comm_loopback/src \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_TOP)/pvmi/pvmf_nodes/common/include \
+ 	$(PV_TOP)/pvmi/media_io/pvmio_comm_loopback/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+	src/../include/pvmi_mio_comm_data_buffer.h \
+ 	src/../include/pvmi_mio_comm_loopback_factory.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/pvmi/media_io/pvmio_comm_loopback/build/make/local.mk b/pvmi/media_io/pvmio_comm_loopback/build/make/local.mk
new file mode 100644
index 0000000..79d5087
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/build/make/local.mk
@@ -0,0 +1,29 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmio_comm_loopback
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS += ../../../../pvmf/include ../../../../pvmf_nodes/common/include ../../include 
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../src
+
+SRCS := pvmi_mio_comm_loopback.cpp \
+        pvmi_mio_comm_data_buffer.cpp
+
+HDRS := ../include/pvmi_mio_comm_data_buffer.h \
+        ../include/pvmi_mio_comm_loopback_factory.h
+
+include $(MK)/library.mk
+
diff --git a/pvmi/media_io/pvmio_comm_loopback/include/pvmi_mio_comm_data_buffer.h b/pvmi/media_io/pvmio_comm_loopback/include/pvmi_mio_comm_data_buffer.h
new file mode 100644
index 0000000..4c53f0c
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/include/pvmi_mio_comm_data_buffer.h
@@ -0,0 +1,72 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmio_comm_data_buffer.h
+ * @brief Media buffer to hold source data from Media Input modules and call
+ * writeComplete to release source data memory back to media input modules.
+ */
+
+#ifndef PVMI_MIO_COMM_DATA_BUFFER_H_INCLUDED
+#define PVMI_MIO_COMM_DATA_BUFFER_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMI_MEDIA_TRANSFER_H_INCLUDED
+#include "pvmi_media_transfer.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
+#include "pvmf_media_data_impl.h"
+#endif
+
+class PvmiMIOCommDataBufferCleanup : public OsclDestructDealloc
+{
+    public:
+        PvmiMIOCommDataBufferCleanup(Oscl_DefAlloc* in_gen_alloc, PvmiMediaTransfer* aMediaInput,
+                                     PVMFCommandId aCmdId, OsclAny* aContext = NULL);
+        virtual ~PvmiMIOCommDataBufferCleanup() {};
+        virtual void destruct_and_dealloc(OsclAny* ptr);
+
+    private:
+        Oscl_DefAlloc* gen_alloc;
+
+        // Variables needed to call writeComplete
+        PvmiMediaTransfer* iMediaInput;
+        PVMFCommandId iCmdId;
+        OsclAny* iContext;
+
+        PVLogger *iLogger;
+};
+
+class PvmiMIOCommDataBufferAlloc
+{
+    public:
+        PvmiMIOCommDataBufferAlloc(Oscl_DefAlloc* opt_gen_alloc = 0);
+        virtual OsclSharedPtr<PVMFMediaDataImpl> allocate(PvmiMediaTransfer* aMediaInput, uint8* aData,
+                uint32 aDataLength, PVMFCommandId aCmdId, OsclAny* aContext = NULL);
+
+    private:
+        Oscl_DefAlloc* gen_alloc;
+        PVLogger* iLogger;
+};
+
+#endif // PVMIO_COMM_DATA_BUFFER_H_INCLUDED
+
diff --git a/pvmi/media_io/pvmio_comm_loopback/include/pvmi_mio_comm_loopback_factory.h b/pvmi/media_io/pvmio_comm_loopback/include/pvmi_mio_comm_loopback_factory.h
new file mode 100644
index 0000000..f8d2223
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/include/pvmi_mio_comm_loopback_factory.h
@@ -0,0 +1,101 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMI_MIO_COMM_LOOPBACK_FACTORY_H_INCLUDED
+#define PVMI_MIO_COMM_LOOPBACK_FACTORY_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+#ifndef PVMF_TIMESTAMP_H_INCLUDED
+#include "pvmf_timestamp.h"
+#endif
+
+// Forward declarations
+class PvmiMIOControl;
+class OsclMemAllocator;
+class PvmiMIOCommLoopbackTestObserver;
+
+/**
+ * Structure containing configuration info for this node
+ */
+class PvmiMIOCommLoopbackSettings
+{
+    public:
+        PvmiMIOCommLoopbackSettings()
+        {
+            iMediaFormat = PVMF_MIME_FORMAT_UNKNOWN;
+            iTestObserver = NULL;
+        }
+
+        PvmiMIOCommLoopbackSettings(const PvmiMIOCommLoopbackSettings& aSettings)
+        {
+            iMediaFormat = aSettings.iMediaFormat;
+            iTestObserver = aSettings.iTestObserver;
+        }
+        ~PvmiMIOCommLoopbackSettings() {}
+
+        // General settings
+        PVMFFormatType iMediaFormat;
+        PvmiMIOCommLoopbackTestObserver *iTestObserver;
+};
+
+
+/**
+ * Factory class for PvmiMIOCommLoopback
+ */
+class PvmiMIOCommLoopbackFactory
+{
+    public:
+        /**
+         * Creates an instance of PvmiMIOCommLoopback. If the creation fails,
+         * this function will leave.
+         *
+         * @param aSettings Settings for PvmiMIOCommLoopback
+         * @returns A pointer to an PvmiMIOControl for the file input media input module
+         * @throw Leaves with OsclErrNoMemory if memory allocation failed.
+         */
+        OSCL_IMPORT_REF static PvmiMIOControl* Create(const PvmiMIOCommLoopbackSettings& aSettings);
+
+        /**
+         * This function allows the application to delete an instance of file input MIO module
+         * and reclaim all allocated resources.  An instance can be deleted only in
+         * the idle state. An attempt to delete in any other state will fail and return false.
+         *
+         * @param aNode The file input MIO module to be deleted.
+         * @returns A status code indicating success or failure.
+         */
+        OSCL_IMPORT_REF static bool Delete(PvmiMIOControl* aMio);
+};
+
+//An observer class for test support.
+class PvmiMIOCommLoopbackTestObserver
+{
+    public:
+        OSCL_IMPORT_REF virtual void LoopbackPos(PVMFTimestamp& aTimestamp) = 0;
+};
+
+#endif // PVMIO_COMM_LOOPBACK_FACTORY_H_INCLUDED
diff --git a/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_data_buffer.cpp b/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_data_buffer.cpp
new file mode 100644
index 0000000..ceaddd7
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_data_buffer.cpp
@@ -0,0 +1,115 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pv_comms_io_data_buffer.cpp
+ * @brief Media buffer to hold source data from Media Input modules and call
+ * writeComplete to release source data memory back to media input modules.
+ */
+
+#ifndef PVMI_MIO_COMM_DATA_BUFFER_H_INCLUDED
+#include "pvmi_mio_comm_data_buffer.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
+#include "pvmf_media_data_impl.h"
+#endif
+#ifndef OSCL_SHARED_PTR_H_INCLUDED
+#include "oscl_shared_ptr.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+
+PvmiMIOCommDataBufferCleanup::PvmiMIOCommDataBufferCleanup(Oscl_DefAlloc* in_gen_alloc,
+        PvmiMediaTransfer* aMediaInput,
+        PVMFCommandId aCmdId,
+        OsclAny* aContext)
+        : gen_alloc(in_gen_alloc),
+        iMediaInput(aMediaInput),
+        iCmdId(aCmdId),
+        iContext(aContext)
+{
+    iLogger = PVLogger::GetLoggerObject("PvmiMIOCommDataBufferCleanup");
+}
+
+void PvmiMIOCommDataBufferCleanup::destruct_and_dealloc(OsclAny* ptr)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PVPvmiMIOCommDataBufferCleanup::destruct_and_dealloc: iCmdId=%d", iCmdId));
+
+    if (!ptr)
+        return;
+
+    if (iMediaInput)
+        iMediaInput->writeComplete(PVMFSuccess, iCmdId, iContext);
+
+    if (!gen_alloc)
+    {
+        OsclMemAllocator my_alloc;
+        my_alloc.deallocate(ptr);
+    }
+    else
+    {
+        gen_alloc->deallocate(ptr);
+    }
+}
+
+PvmiMIOCommDataBufferAlloc::PvmiMIOCommDataBufferAlloc(Oscl_DefAlloc* opt_gen_alloc)
+        : gen_alloc(opt_gen_alloc)
+{
+    iLogger = PVLogger::GetLoggerObject("PvmiMIOCommDataBufferAlloc");
+}
+
+OsclSharedPtr<PVMFMediaDataImpl> PvmiMIOCommDataBufferAlloc::allocate(PvmiMediaTransfer* aMediaInput,
+        uint8* aData,
+        uint32 aDataLength,
+        PVMFCommandId aCmdId,
+        OsclAny* aContext)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                    (0, "PvmiMIOCommDataBufferAlloc::allocate: aMediaInput=0x%x, aData=0x%x, aDataLength=%d, aCmdId=%d, aContext=0x%x",
+                     aMediaInput, aData, aDataLength, aCmdId, aContext));
+
+    uint aligned_refcnt_size;
+    uint aligned_class_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+    OsclRefCounter* my_refcnt;
+    uint8* my_ptr;
+
+    aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+    uint aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PvmiMIOCommDataBufferCleanup));
+    if (!gen_alloc)
+    {
+        OsclMemAllocator my_alloc;
+        my_ptr = (uint8*) my_alloc.allocate(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
+    }
+    else
+    {
+        my_ptr = (uint8*) gen_alloc->allocate(aligned_refcnt_size + aligned_cleanup_size + aligned_class_size);
+    }
+
+    PvmiMIOCommDataBufferCleanup* cleanup_ptr =
+        OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, PvmiMIOCommDataBufferCleanup(gen_alloc, aMediaInput, aCmdId, aContext));
+    my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
+    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
+
+    PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer((OsclAny*)aData, aDataLength, my_refcnt));
+    OsclSharedPtr<PVMFMediaDataImpl> shared_media_data(media_data_ptr, my_refcnt);
+    return shared_media_data;
+}
+
+
+
diff --git a/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_loopback.cpp b/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_loopback.cpp
new file mode 100644
index 0000000..75a938f
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_loopback.cpp
@@ -0,0 +1,1022 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ * @file pvmi_mio_fileinput.cpp
+ * @brief PV Media IO interface implementation using file input
+ */
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef PVMI_MIO_COMM_LOOPBACK_H_INCLUDED
+#include "pvmi_mio_comm_loopback.h"
+#endif
+#ifndef OSCL_MIME_STRING_UTILS_H
+#include "pv_mime_string_utils.h"
+#endif
+#ifndef OSCL_DLL_H_INCLUDED
+#include "oscl_dll.h"
+#endif
+#ifndef PVMF_MEDIA_MSG_FORMAT_IDS_H_INCLUDED
+#include "pvmf_media_msg_format_ids.h"
+#endif
+
+// Define entry point for this DLL
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+#define PVMIO_MEDIADATA_POOLNUM 8
+const uint32 AMR_FRAME_DELAY = 20; // 20ms
+
+#define INPUT_TRANSFER_MODEL_VAL ".../input/transfer_model;valtype=uint32"
+#define OUTPUT_TRANSFER_MODEL_VAL ".../output/transfer_model;valtype=uin32"
+
+// Logging macros
+#define LOG_STACK_TRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, m)
+#define LOG_DEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG, m)
+#define LOG_ERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m)
+
+OSCL_EXPORT_REF PvmiMIOControl* PvmiMIOCommLoopbackFactory::Create(const PvmiMIOCommLoopbackSettings& aSettings)
+{
+    PvmiMIOControl *mioFilein = OSCL_STATIC_CAST(PvmiMIOControl*, OSCL_NEW(PvmiMIOCommLoopback, (aSettings)));
+
+    return mioFilein;
+}
+
+OSCL_EXPORT_REF bool PvmiMIOCommLoopbackFactory::Delete(PvmiMIOControl* aMio)
+{
+    PvmiMIOCommLoopback *mioFilein = OSCL_STATIC_CAST(PvmiMIOCommLoopback*, aMio);
+    if (!mioFilein)
+        return false;
+    OSCL_DELETE(mioFilein);
+
+    mioFilein = NULL;
+    return true;
+
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+PvmiMIOCommLoopback::~PvmiMIOCommLoopback()
+{
+    while (!iObservers.empty())
+    {
+        iObservers.pop_back();
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PvmiMIOCommLoopback::connect(PvmiMIOSession& aSession, PvmiMIOObserver* aObserver)
+{
+    if (!aObserver)
+    {
+        return PVMFFailure;
+    }
+
+    int32 err = 0;
+    OSCL_TRY(err, iObservers.push_back(aObserver));
+    OSCL_FIRST_CATCH_ANY(err, return PVMFErrNoMemory);
+    aSession = (PvmiMIOSession)(iObservers.size() - 1); // Session ID is the index of observer in the vector
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PvmiMIOCommLoopback::disconnect(PvmiMIOSession aSession)
+{
+    uint32 index = (uint32)aSession;
+    if (index >= iObservers.size())
+    {
+        // Invalid session ID
+        return PVMFFailure;
+    }
+
+    iObservers.erase(iObservers.begin() + index);
+    iObservers[index] = 0;
+    iObservers.destroy();
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PvmiMediaTransfer* PvmiMIOCommLoopback::createMediaTransfer(PvmiMIOSession& aSession,
+        PvmiKvp* read_formats,
+        int32 read_flags,
+        PvmiKvp* write_formats,
+        int32 write_flags)
+{
+    OSCL_UNUSED_ARG(read_formats);
+    OSCL_UNUSED_ARG(read_flags);
+    OSCL_UNUSED_ARG(write_formats);
+    OSCL_UNUSED_ARG(write_flags);
+
+    uint32 index = (uint32)aSession;
+    if (index >= iObservers.size())
+    {
+        // Invalid session ID
+        OSCL_LEAVE(OsclErrArgument);
+        return NULL;
+    }
+
+    return (PvmiMediaTransfer*)this;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::deleteMediaTransfer(PvmiMIOSession& aSession,
+        PvmiMediaTransfer* media_transfer)
+{
+    uint32 index = (uint32)aSession;
+    if (!media_transfer || index >= iObservers.size())
+    {
+        // Invalid session ID
+        OSCL_LEAVE(OsclErrArgument);
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::QueryUUID(const PvmfMimeString& aMimeType,
+        Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+        bool aExactUuidsOnly,
+        const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aMimeType);
+    OSCL_UNUSED_ARG(aExactUuidsOnly);
+
+    int32 err = 0;
+    OSCL_TRY(err, aUuids.push_back(PVMI_CAPABILITY_AND_CONFIG_PVUUID););
+    OSCL_FIRST_CATCH_ANY(err, OSCL_LEAVE(OsclErrNoMemory););
+
+    return AddCmdToQueue(CMD_QUERY_UUID, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::QueryInterface(const PVUuid& aUuid,
+        PVInterface*& aInterfacePtr,
+        const OsclAny* aContext)
+{
+    if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
+    {
+        PvmiCapabilityAndConfig* myInterface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
+        aInterfacePtr = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
+    else
+    {
+        aInterfacePtr = NULL;
+    }
+
+    return AddCmdToQueue(CMD_QUERY_INTERFACE, aContext, (OsclAny*)&aInterfacePtr);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback:: Init(const OsclAny* aContext)
+{
+    if (iState != STATE_IDLE)
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(CMD_INIT, aContext);
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::Start(const OsclAny* aContext)
+{
+    if (iState != STATE_INITIALIZED && iState != STATE_PAUSED)
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(CMD_START, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::Pause(const OsclAny* aContext)
+{
+    if (iState != STATE_STARTED)
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(CMD_PAUSE, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::Flush(const OsclAny* aContext)
+{
+    if (iState != STATE_STARTED || iState != STATE_PAUSED)
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(CMD_FLUSH, aContext);
+}
+
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::Reset(const OsclAny* aContext)
+{
+    if (iState != STATE_STARTED || iState != STATE_PAUSED)
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(CMD_RESET, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::DiscardData(const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::DiscardData(PVMFTimestamp aTimestamp, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aTimestamp);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::Stop(const OsclAny* aContext)
+{
+    if (iState != STATE_STARTED && iState != STATE_PAUSED)
+    {
+        OSCL_LEAVE(OsclErrInvalidState);
+        return -1;
+    }
+
+    return AddCmdToQueue(CMD_STOP, aContext);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::ThreadLogon()
+{
+    if (!iThreadLoggedOn)
+    {
+        AddToScheduler();
+        iLogger = PVLogger::GetLoggerObject("PvmiMIOCommLoopback");
+        iThreadLoggedOn = true;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::ThreadLogoff()
+{
+    if (iThreadLoggedOn)
+    {
+        RemoveFromScheduler();
+        iLogger = NULL;
+        iThreadLoggedOn = false;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::CancelAllCommands(const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::CancelCommand(PVMFCommandId aCmdId, const OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aCmdId);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::setPeer(PvmiMediaTransfer* aPeer)
+{
+    iPeer = aPeer;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::useMemoryAllocators(OsclMemAllocator* write_alloc)
+{
+    OSCL_UNUSED_ARG(write_alloc);
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::writeAsync(uint8 aFormatType, int32 aFormatIndex,
+        uint8* aData, uint32 aDataLen,
+        const PvmiMediaXferHeader& data_header_info,
+        OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aFormatType);
+    OSCL_UNUSED_ARG(aFormatIndex);
+
+    uint32 aSeqNum = data_header_info.seq_num;
+    PVMFTimestamp aTimestamp = data_header_info.timestamp;
+
+    // writeAsync will copy the input data, and then make
+    // arrangements to send a writeComplete callback, and also
+    // echo back the receieved data to its peer
+
+    PVMFSharedMediaDataPtr mediaData;
+    OsclRefCounterMemFrag frag;
+    OsclSharedPtr<PVMFMediaDataImpl> mediaDataImpl;
+    int32 err = 0, cmdId;
+    if (iCommandCounter == 0x7FFFFFFF)
+        iCommandCounter = 0;
+    cmdId = iCommandCounter++;
+
+
+    mediaDataImpl = iMediaDataAlloc.allocate(aDataLen);
+    mediaDataImpl->getMediaFragment(0, frag);
+    oscl_memcpy(frag.getMemFragPtr(), aData, aDataLen);
+
+    OSCL_TRY(err, mediaData = PVMFMediaData::createMediaData(mediaDataImpl, &iMediaDataMemPool));
+    OSCL_FIRST_CATCH_ANY(err, mediaDataImpl.Unbind();
+                         OSCL_LEAVE(err));
+
+    // Set timestamp
+    mediaData->setTimestamp(aTimestamp);
+    mediaData->setSeqNum(aSeqNum);
+    mediaData->setMediaFragFilledLen(0, aDataLen);
+
+    // Convert media data to MediaMsg, and store for loopback echo
+    PVMFSharedMediaMsgPtr mediaMsg;
+    convertToPVMFMediaMsg(mediaMsg, mediaData);
+
+    iOutgoingQueue.push_back(mediaMsg);
+
+    // Queue a writeComplete response for async sending
+    cmdId = iCommandCounter++;
+    WriteResponse resp(PVMFSuccess, cmdId, aContext, aTimestamp);
+    iWriteResponseQueue.push_back(resp);
+    RunIfNotReady();
+    return cmdId;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::writeComplete(PVMFStatus aStatus, PVMFCommandId aCmdId,
+        OsclAny* aContext)
+
+{
+    OSCL_UNUSED_ARG(aStatus);
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "PvmiMIOCommLoopback::writeComplete status %d cmdId %d context 0x%x", aStatus, aCmdId, aContext));
+
+
+    //detect cases where the current call is completing synchronously.
+    if (iWriteState == EWriteBusy
+            && (uint32)aContext == iWriteAsyncContext)
+    {
+        //synchronous completion
+        iWriteState = EWriteOK;
+    }
+    else
+    {
+        //asynchronous completion
+        //do any memory cleanup
+        uint32 i;
+        for (i = 0;i < iCleanupQueue.size();i++)
+        {
+            if (iCleanupQueue[i].iCmdId == aCmdId)
+            {
+                PVMFSharedMediaDataPtr mediaData = iCleanupQueue[i].iData;
+                if (iSettings.iTestObserver)
+                {
+                    PVMFTimestamp ts = mediaData->getTimestamp();
+                    iSettings.iTestObserver->LoopbackPos(ts);
+                }
+                iCleanupQueue.erase(&iCleanupQueue[i]);
+                break;
+            }
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::readAsync(uint8* data, uint32 max_data_len,
+        OsclAny* aContext, int32* formats, uint16 num_formats)
+{
+    OSCL_UNUSED_ARG(data);
+    OSCL_UNUSED_ARG(max_data_len);
+    OSCL_UNUSED_ARG(aContext);
+    OSCL_UNUSED_ARG(formats);
+    OSCL_UNUSED_ARG(num_formats);
+    // This is an active data source. readAsync is not supported.
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::readComplete(PVMFStatus aStatus, PVMFCommandId read_cmd_id,
+        int32 format_index, const PvmiMediaXferHeader& data_header_info,
+        OsclAny* aContext)
+{
+    OSCL_UNUSED_ARG(aStatus);
+    OSCL_UNUSED_ARG(read_cmd_id);
+    OSCL_UNUSED_ARG(format_index);
+    OSCL_UNUSED_ARG(data_header_info);
+    OSCL_UNUSED_ARG(aContext);
+    // This is an active data source. readComplete is not supported.
+    OSCL_LEAVE(OsclErrNotSupported);
+    return;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::statusUpdate(uint32 status_flags)
+{
+    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                    (0, "PvmiMIOCommLoopback::statusUpdate flags %d", status_flags));
+
+    if (status_flags & PVMI_MEDIAXFER_STATUS_WRITE)
+    {
+        //recover from a previous async write error.
+        if (iWriteState == EWriteWait)
+        {
+            iWriteState = EWriteOK;
+            RunIfNotReady();
+        }
+    }
+    else
+    {
+        //disable write
+        iWriteState = EWriteWait;
+    }
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::cancelCommand(PVMFCommandId aCmdId)
+{
+    OSCL_UNUSED_ARG(aCmdId);
+    // This cancel command ( with a small "c" in cancel ) is for the media transfer interface.
+    // implementation is similar to the cancel command of the media I/O interface.
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::cancelAllCommands()
+{
+    OSCL_LEAVE(OsclErrNotSupported);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PvmiMIOCommLoopback::getParametersSync(PvmiMIOSession session,
+        PvmiKeyType identifier,
+        PvmiKvp*& parameters,
+        int& num_parameter_elements,
+        PvmiCapabilityContext context)
+{
+    LOG_STACK_TRACE((0, "PvmiMIOCommLoopback::getParametersSync"));
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+
+    parameters = NULL;
+    num_parameter_elements = 0;
+    PVMFStatus status = PVMFFailure;
+
+    if (pv_mime_strcmp(identifier, OUTPUT_FORMATS_CAP_QUERY) == 0 ||
+            pv_mime_strcmp(identifier, OUTPUT_FORMATS_CUR_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters,
+                             OSCL_CONST_CAST(char*, OUTPUT_FORMATS_VALTYPE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.pChar_value = OSCL_STATIC_CAST(mbchar*, iSettings.iMediaFormat.getMIMEStrPtr());
+        }
+    }
+    else if (pv_mime_strcmp(identifier, INPUT_FORMATS_CAP_QUERY) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters,
+                             OSCL_CONST_CAST(char*, INPUT_FORMATS_VALTYPE), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::GetOutputParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.pChar_value = OSCL_STATIC_CAST(mbchar*, iSettings.iMediaFormat.getMIMEStrPtr());
+        }
+    }
+    else if (pv_mime_strcmp(identifier, INPUT_TRANSFER_MODEL_VAL) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters,
+                             OSCL_CONST_CAST(char*, INPUT_TRANSFER_MODEL_VAL), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::GetInputModelParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.uint32_value = 1; // push model for media input
+        }
+    }
+    else if (pv_mime_strcmp(identifier, OUTPUT_TRANSFER_MODEL_VAL) == 0)
+    {
+        num_parameter_elements = 1;
+        status = AllocateKvp(parameters,
+                             OSCL_CONST_CAST(char*, OUTPUT_TRANSFER_MODEL_VAL), num_parameter_elements);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::GetOutputModelParametersSync: Error - AllocateKvp failed. status=%d", status));
+        }
+        else
+        {
+            parameters[0].value.uint32_value = 1; // push model for media output
+        }
+    }
+    return status;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PvmiMIOCommLoopback::releaseParameters(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(num_elements);
+
+    if (parameters)
+    {
+        iAlloc.deallocate((OsclAny*)parameters);
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::createContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::setContextParameters(PvmiMIOSession session,
+        PvmiCapabilityContext& context,
+        PvmiKvp* parameters, int num_parameter_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_parameter_elements);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::DeleteContext(PvmiMIOSession session, PvmiCapabilityContext& context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(context);
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PvmiMIOCommLoopback::setParametersSync(PvmiMIOSession session, PvmiKvp* parameters,
+        int num_elements, PvmiKvp*& ret_kvp)
+{
+    OSCL_UNUSED_ARG(session);
+    PVMFStatus status = PVMFSuccess;
+    ret_kvp = NULL;
+
+    for (int32 i = 0; i < num_elements; i++)
+    {
+        status = VerifyAndSetParameter(&(parameters[i]), true);
+        if (status != PVMFSuccess)
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::setParametersSync: Error - VerifiyAndSetParameter failed on parameter #%d", i));
+            ret_kvp = &(parameters[i]);
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFCommandId PvmiMIOCommLoopback::setParametersAsync(PvmiMIOSession session,
+        PvmiKvp* parameters,
+        int num_elements,
+        PvmiKvp*& ret_kvp,
+        OsclAny* context)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    OSCL_UNUSED_ARG(ret_kvp);
+    OSCL_UNUSED_ARG(context);
+    OSCL_LEAVE(OsclErrNotSupported);
+    return -1;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF uint32 PvmiMIOCommLoopback::getCapabilityMetric(PvmiMIOSession session)
+{
+    OSCL_UNUSED_ARG(session);
+    return 0;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFStatus PvmiMIOCommLoopback::verifyParametersSync(PvmiMIOSession session,
+        PvmiKvp* parameters, int num_elements)
+{
+    OSCL_UNUSED_ARG(session);
+    OSCL_UNUSED_ARG(parameters);
+    OSCL_UNUSED_ARG(num_elements);
+    return PVMFErrNotSupported;
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                            Private methods
+////////////////////////////////////////////////////////////////////////////
+PvmiMIOCommLoopback::PvmiMIOCommLoopback(const PvmiMIOCommLoopbackSettings& aSettings)
+        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PvmiMIOCommLoopback"),
+        iCommandCounter(1000),
+        iPeer(NULL),
+        iThreadLoggedOn(false),
+        iSettings(aSettings),
+        iMediaDataAlloc(&iAlloc),
+        iMediaDataMemPool(PVMIO_MEDIADATA_POOLNUM),
+        iLogger(NULL),
+        iState(STATE_IDLE),
+        iWriteState(EWriteOK),
+        iResend(false),
+        iWriteAsyncContext(0)
+{
+    ConstructL(aSettings);
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PvmiMIOCommLoopback::ConstructL(const PvmiMIOCommLoopbackSettings& aSettings)
+{
+    iSettings.iMediaFormat = aSettings.iMediaFormat;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PvmiMIOCommLoopback::Run()
+{
+    if (!iCmdQueue.empty())
+    {
+        PvmiMIOCommLoopbackCmd cmd = iCmdQueue[0];
+        iCmdQueue.erase(iCmdQueue.begin());
+
+        switch (cmd.iType)
+        {
+
+            case CMD_INIT:
+                DoRequestCompleted(cmd, DoInit());
+                break;
+
+            case CMD_START:
+                DoRequestCompleted(cmd, DoStart());
+                break;
+
+            case CMD_PAUSE:
+                DoRequestCompleted(cmd, DoPause());
+                break;
+
+            case CMD_FLUSH:
+                DoRequestCompleted(cmd, DoFlush());
+                break;
+
+            case CMD_RESET:
+                DoRequestCompleted(cmd, DoReset());
+                break;
+
+            case CMD_STOP:
+                DoRequestCompleted(cmd, DoStop());
+                break;
+
+            case CMD_QUERY_UUID:
+            case CMD_QUERY_INTERFACE:
+                DoRequestCompleted(cmd, PVMFSuccess);
+                break;
+
+            case CMD_CANCEL_ALL_COMMANDS:
+            case CMD_CANCEL_COMMAND:
+                DoRequestCompleted(cmd, PVMFFailure);
+                break;
+
+            default:
+                break;
+        }
+    }
+
+    if (!iCmdQueue.empty())
+    {
+        // Run again if there are more things to process
+        RunIfNotReady();
+    }
+
+    if (!iOutgoingQueue.empty() && iWriteState == EWriteOK)
+    {
+        DoLoopback();
+    }
+
+    while (!iWriteResponseQueue.empty())
+    {
+        //report write complete
+        if (iPeer)
+        {
+            iPeer->writeComplete(iWriteResponseQueue[0].iStatus, iWriteResponseQueue[0].iCmdId, (OsclAny*)iWriteResponseQueue[0].iContext);
+            iWriteResponseQueue.erase(iWriteResponseQueue.begin());
+        }
+    }
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFCommandId PvmiMIOCommLoopback::AddCmdToQueue(PvmiMIOCommLoopbackCmdType aType,
+        const OsclAny* aContext, OsclAny* aData1)
+{
+    if (aType == DATA_EVENT)
+        OSCL_LEAVE(OsclErrArgument);
+
+    PvmiMIOCommLoopbackCmd cmd;
+    cmd.iType = aType;
+    cmd.iContext = OSCL_STATIC_CAST(OsclAny*, aContext);
+    cmd.iData1 = aData1;
+    cmd.iId = iCommandCounter++;
+    iCmdQueue.push_back(cmd);
+    RunIfNotReady();
+    return cmd.iId;
+}
+
+////////////////////////////////////////////////////////////////////////////
+void PvmiMIOCommLoopback::DoRequestCompleted(const PvmiMIOCommLoopbackCmd& aCmd, PVMFStatus aStatus, OsclAny* aEventData)
+{
+    PVMFCmdResp response(aCmd.iId, aCmd.iContext, aStatus, aEventData);
+
+    for (uint32 i = 0; i < iObservers.size(); i++)
+        iObservers[i]->RequestCompleted(response);
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::DoInit()
+{
+    iState = STATE_INITIALIZED;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::DoStart()
+{
+    iState = STATE_STARTED;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::DoPause()
+{
+    iState = STATE_PAUSED;
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::DoFlush()
+{
+    // This method should stop capturing media data but continue to send captured
+    // media data that is already in buffer and then go to stopped state.
+    // However, in this case of file input we do not have such a buffer for
+    // captured data, so this behaves the same way as stop.
+    return DoStop();
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::DoStop()
+{
+    iState = STATE_STOPPED;
+    return PVMFSuccess;
+}
+
+PVMFStatus PvmiMIOCommLoopback::DoReset()
+{
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams)
+{
+    LOG_STACK_TRACE((0, "PvmiMIOCommLoopback::AllocateKvp"));
+    uint8* buf = NULL;
+    uint32 keyLen = oscl_strlen(aKey) + 1;
+    int32 err = 0;
+
+    OSCL_TRY(err,
+             buf = (uint8*)iAlloc.allocate(aNumParams * (sizeof(PvmiKvp) + keyLen));
+             if (!buf)
+             OSCL_LEAVE(OsclErrNoMemory);
+            );
+    OSCL_FIRST_CATCH_ANY(err,
+                         LOG_ERR((0, "PvmiMIOCommLoopback::AllocateKvp: Error - kvp allocation failed"));
+                         return PVMFErrNoMemory;
+                        );
+
+    int32 i = 0;
+    PvmiKvp* curKvp = aKvp = new(buf) PvmiKvp;
+    buf += sizeof(PvmiKvp);
+    for (i = 1; i < aNumParams; i++)
+    {
+        curKvp += i;
+        curKvp = new(buf) PvmiKvp;
+        buf += sizeof(PvmiKvp);
+    }
+
+    for (i = 0; i < aNumParams; i++)
+    {
+        aKvp[i].key = (char*)buf;
+        oscl_strncpy(aKvp[i].key, aKey, keyLen);
+        buf += keyLen;
+    }
+
+    return PVMFSuccess;
+}
+
+////////////////////////////////////////////////////////////////////////////
+PVMFStatus PvmiMIOCommLoopback::VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam)
+{
+    OSCL_UNUSED_ARG(aSetParam);
+    LOG_STACK_TRACE((0, "PvmiMIOCommLoopback::VerifyAndSetParameter: aKvp=0x%x, aSetParam=%d", aKvp, aSetParam));
+
+    if (!aKvp)
+    {
+        LOG_ERR((0, "PvmiMIOCommLoopback::VerifyAndSetParameter: Error - Invalid key-value pair"));
+        return PVMFFailure;
+    }
+
+    if (pv_mime_strcmp(aKvp->key, OUTPUT_FORMATS_VALTYPE) == 0)
+    {
+        if (pv_mime_strcmp(iSettings.iMediaFormat.getMIMEStrPtr(), aKvp->value.pChar_value) == 0)
+        {
+            return PVMFSuccess;
+        }
+        else
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::VerifyAndSetParameter: Error - Unsupported format %s",
+                     aKvp->value.pChar_value));
+            return PVMFFailure;
+        }
+    }
+    if (pv_mime_strcmp(aKvp->key, INPUT_FORMATS_VALTYPE) == 0)
+    {
+        if (pv_mime_strcmp(iSettings.iMediaFormat.getMIMEStrPtr(), aKvp->value.pChar_value) == 0)
+        {
+            return PVMFSuccess;
+        }
+        else
+        {
+            LOG_ERR((0, "PvmiMIOCommLoopback::VerifyAndSetParameter: Error - Unsupported format %s",
+                     aKvp->value.pChar_value));
+            return PVMFFailure;
+        }
+    }
+
+    LOG_ERR((0, "PvmiMIOCommLoopback::VerifyAndSetParameter: Error - Unsupported parameter"));
+    return PVMFFailure;
+}
+
+
+void PvmiMIOCommLoopback::DoLoopback()
+{
+    PVMFSharedMediaMsgPtr aMsg;
+    PVMFSharedMediaDataPtr aMediaData;
+    uint32 fragment = 0;
+    uint32 fragindex;
+
+    while (!iOutgoingQueue.empty())
+    {
+        aMsg = iOutgoingQueue[0];
+
+        convertToPVMFMediaData(aMediaData, aMsg);
+
+        if (aMsg->getFormatID() == PVMF_MEDIA_CMD_EOS_FORMAT_ID)
+        {
+            return;
+        }
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                        (0, "PVCommsIOPort::SendCommsData Seq %d TS %d Rep 0x%x Count %d"
+                         , aMediaData->getSeqNum()
+                         , aMediaData->getTimestamp()
+                         , aMediaData.GetRep()
+                         , aMediaData.get_count()));
+
+        OSCL_ASSERT(iWriteState == EWriteOK);
+
+        if (iResend
+                && aMediaData->getSeqNum() == iResendSeqNum)
+        {
+            fragment = iResendFragment;
+            iResend = false;
+        }
+
+        for (fragindex = fragment; fragindex < aMediaData->getNumFragments();)
+        {
+            OsclRefCounterMemFrag frag;
+            aMediaData->getMediaFragment(fragindex, frag);
+
+            ++iWriteAsyncContext;
+            iWriteState = EWriteBusy;
+            int32 err;
+            int32 cmdId = 0;
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                            (0, "PVCommsIONodePort::SendCommsData Calling WriteAsync context 0x%x", iWriteAsyncContext));
+
+            PvmiMediaXferHeader data_hdr;
+            data_hdr.seq_num = aMediaData->getSeqNum();
+            data_hdr.timestamp = aMediaData->getTimestamp();
+            data_hdr.flags = 0;
+            data_hdr.duration = 0;
+            data_hdr.stream_id = 0;
+            err = WriteAsync(cmdId, frag, data_hdr);
+
+            if (err != OsclErrNone)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVCommsIONodePort::SendData WriteAsync Leave code %d", err));
+
+                //if a leave occurs in the writeAsync call, we suspend data
+                //transfer until a statusUpdate call from the MIO component
+                //tells us to resume.
+                //this is not an error-- it's the normal flow control mechanism.
+                iWriteState = EWriteWait;
+
+                //save the data to re-send later.
+                iResend = true;
+                iResendFragment = fragindex;
+                iResendSeqNum = aMediaData->getSeqNum();
+
+                return ;//wait on statusUpdate call from the MIO component.
+            }
+            else
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
+                                (0, "PVCommsIONodePort::SendData WriteAsync returned cmdId %d", cmdId));
+
+                fragindex++;
+
+                if (fragindex == aMediaData->getNumFragments())
+                {
+                    //all fragments have been sent.  see whether completion
+                    //is synchronous or asynchronous.
+                    if (iWriteState == EWriteBusy)
+                    {
+                        //asynchronous completion.
+                        //push the data onto the cleanup stack so it won't get cleaned
+                        //up until the component consumes it.
+                        iCleanupQueue.push_back(CleanupQueueElement(aMediaData, cmdId));
+                    }
+                    //else the write already completed synchronously.
+                    iOutgoingQueue.erase(iOutgoingQueue.begin());
+                }
+                iWriteState = EWriteOK;
+            }
+        }
+    }
+}
+
+int32 PvmiMIOCommLoopback::WriteAsync(int32& cmdId,
+                                      OsclRefCounterMemFrag frag,
+                                      PvmiMediaXferHeader data_hdr)
+{
+    int32 err;
+    OSCL_TRY(err,
+             cmdId = iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA,  /*format_type*/
+                                       PVMI_MEDIAXFER_FMT_INDEX_DATA, /*format_index*/
+                                       (uint8*)frag.getMemFragPtr(),
+                                       frag.getMemFragSize(),
+                                       data_hdr,
+                                       (OsclAny*)iWriteAsyncContext);
+            );
+    return err;
+}
+
diff --git a/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_loopback.h b/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_loopback.h
new file mode 100644
index 0000000..10e1b5c
--- /dev/null
+++ b/pvmi/media_io/pvmio_comm_loopback/src/pvmi_mio_comm_loopback.h
@@ -0,0 +1,354 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMI_MIO_COMM_LOOPBACK_H_INCLUDED
+#define PVMI_MIO_COMM_LOOPBACK_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCLCONFIG_IO_H_INCLUDED
+#include "osclconfig_io.h"
+#endif
+#ifndef OSCL_STRING_H_INCLUDED
+#include "oscl_string.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMI_MIO_CONTROL_H_INCLUDED
+#include "pvmi_mio_control.h"
+#endif
+#ifndef PVMI_MEDIA_TRANSFER_H_INCLUDED
+#include "pvmi_media_transfer.h"
+#endif
+#ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
+#include "pvmi_config_and_capability.h"
+#endif
+#ifndef PVMI_MIO_COMM_DATA_BUFFER_H_INCLUDED
+#include "pvmi_mio_comm_data_buffer.h"
+#endif
+#ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
+#include "pvmf_simple_media_buffer.h"
+#endif
+#ifndef PVMI_MIO_COMM_LOOPBACK_FACTORY_H_INCLUDED
+#include "pvmi_mio_comm_loopback_factory.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_H_INCLUDED
+#include "pvmf_media_data.h"
+#endif
+#ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
+#include "pvmf_media_data_impl.h"
+#endif
+
+
+/**
+ * Enumerated list of asychronous commands for PvmiMIOCommLoopback
+ */
+typedef enum
+{
+    CMD_QUERY_UUID,
+    CMD_QUERY_INTERFACE,
+    CMD_INIT,
+    CMD_START,
+    CMD_PAUSE,
+    CMD_FLUSH,
+    CMD_STOP,
+    CMD_CANCEL_ALL_COMMANDS,
+    CMD_CANCEL_COMMAND,
+    CMD_RESET,
+    DATA_EVENT,
+    INVALID_CMD
+} PvmiMIOCommLoopbackCmdType;
+
+
+/**
+ * Class containing information for a command or data event
+ */
+class PvmiMIOCommLoopbackCmd
+{
+    public:
+        PvmiMIOCommLoopbackCmd()
+        {
+            iId = 0;
+            iType = INVALID_CMD;
+            iContext = NULL;
+            iData1 = NULL;
+        }
+
+        PvmiMIOCommLoopbackCmd(const PvmiMIOCommLoopbackCmd& aCmd)
+        {
+            Copy(aCmd);
+        }
+
+        ~PvmiMIOCommLoopbackCmd() {}
+
+        PvmiMIOCommLoopbackCmd& operator=(const PvmiMIOCommLoopbackCmd& aCmd)
+        {
+            Copy(aCmd);
+            return (*this);
+        }
+
+        PVMFCommandId iId; /** ID assigned to this command */
+        int32 iType;  /** PvmiMIOCommLoopbackCmdType value */
+        OsclAny* iContext;  /** Other data associated with this command */
+        OsclAny* iData1;  /** Other data associated with this command */
+
+    private:
+
+        void Copy(const PvmiMIOCommLoopbackCmd& aCmd)
+        {
+            iId = aCmd.iId;
+            iType = aCmd.iType;
+            iContext = aCmd.iContext;
+            iData1 = aCmd.iData1;
+        }
+};
+
+class PvmiMIOCommLoopbackMediaData
+{
+    public:
+        PvmiMIOCommLoopbackMediaData()
+        {
+            iId = 0;
+            iData = NULL;
+        }
+
+        PvmiMIOCommLoopbackMediaData(const PvmiMIOCommLoopbackMediaData& aData)
+        {
+            iId = aData.iId;
+            iData = aData.iData;
+        }
+
+        PVMFCommandId iId;
+        OsclAny* iData;
+};
+
+
+class PvmiMIOCommLoopback : public OsclTimerObject,
+            public PvmiMIOControl,
+            public PvmiMediaTransfer,
+            public PvmiCapabilityAndConfig
+{
+    public:
+        PvmiMIOCommLoopback(const PvmiMIOCommLoopbackSettings& aSettings);
+        virtual ~PvmiMIOCommLoopback();
+
+        // Pure virtuals from PvmiMIOControl
+        OSCL_IMPORT_REF PVMFStatus connect(PvmiMIOSession& aSession, PvmiMIOObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus disconnect(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PvmiMediaTransfer* createMediaTransfer(PvmiMIOSession& aSession,
+                PvmiKvp* read_formats = NULL,
+                int32 read_flags = 0,
+                PvmiKvp* write_formats = NULL,
+                int32 write_flags = 0);
+        OSCL_IMPORT_REF void deleteMediaTransfer(PvmiMIOSession& aSession,
+                PvmiMediaTransfer* media_transfer);
+        OSCL_IMPORT_REF PVMFCommandId QueryUUID(const PvmfMimeString& aMimeType,
+                                                Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
+                                                bool aExactUuidsOnly = false,
+                                                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId QueryInterface(const PVUuid& aUuid,
+                PVInterface*& aInterfacePtr,
+                const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Init(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Start(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Reset(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Pause(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Flush(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId DiscardData(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId DiscardData(PVMFTimestamp aTimestamp, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId Stop(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFCommandId aCmdId, const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(const OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF void ThreadLogon();
+        OSCL_IMPORT_REF void ThreadLogoff();
+
+        // Pure virtuals from PvmiMediaTransfer
+        OSCL_IMPORT_REF void setPeer(PvmiMediaTransfer* aPeer);
+        OSCL_IMPORT_REF void useMemoryAllocators(OsclMemAllocator* write_alloc = NULL);
+        OSCL_IMPORT_REF PVMFCommandId writeAsync(uint8 format_type, int32 format_index,
+                uint8* data, uint32 data_len,
+                const PvmiMediaXferHeader& data_header_info,
+                OsclAny* aContext = NULL);
+        OSCL_IMPORT_REF void writeComplete(PVMFStatus aStatus, PVMFCommandId aCmdId,
+                                           OsclAny* aContext);
+        OSCL_IMPORT_REF PVMFCommandId readAsync(uint8* data, uint32 max_data_len, OsclAny* aContext = NULL,
+                                                int32* formats = NULL, uint16 num_formats = 0);
+        OSCL_IMPORT_REF void readComplete(PVMFStatus aStatus, PVMFCommandId read_cmd_id,
+                                          int32 format_index,
+                                          const PvmiMediaXferHeader& data_header_info,
+                                          OsclAny* aContext);
+        OSCL_IMPORT_REF void statusUpdate(uint32 status_flags);
+        OSCL_IMPORT_REF void cancelCommand(PVMFCommandId aCmdId);
+        OSCL_IMPORT_REF void cancelAllCommands();
+
+        // Pure virtuals from PvmiCapabilityAndConfig
+        OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
+        OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
+                PvmiKvp*& aParameters, int& num_parameter_elements,
+                PvmiCapabilityContext aContext);
+        OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements);
+        OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
+                PvmiKvp* aParameters, int num_parameter_elements);
+        OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
+        OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                                               int num_elements, PvmiKvp * & aRet_kvp);
+        OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
+                int num_elements, PvmiKvp*& aRet_kvp,
+                OsclAny* context = NULL);
+        OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
+        OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
+                PvmiKvp* aParameters, int num_elements);
+
+    private:
+        void Run();
+        void ConstructL(const PvmiMIOCommLoopbackSettings& aSettings);
+
+        int32 WriteAsync(int32& cmdId,
+                         OsclRefCounterMemFrag frag,
+                         PvmiMediaXferHeader data_hdr);
+
+
+        PVMFCommandId AddCmdToQueue(PvmiMIOCommLoopbackCmdType aType, const OsclAny* aContext, OsclAny* aData1 = NULL);
+        void DoRequestCompleted(const PvmiMIOCommLoopbackCmd& aCmd, PVMFStatus aStatus, OsclAny* aEventData = NULL);
+        PVMFStatus DoInit();
+        PVMFStatus DoStart();
+        PVMFStatus DoPause();
+        PVMFStatus DoFlush();
+        PVMFStatus DoReset();
+        PVMFStatus DoStop();
+        PVMFStatus DoRead();
+        void DoLoopback();
+
+        /**
+         * Allocate a specified number of key-value pairs and set the keys
+         *
+         * @param aKvp Output parameter to hold the allocated key-value pairs
+         * @param aKey Key for the allocated key-value pairs
+         * @param aNumParams Number of key-value pairs to be allocated
+         * @return Completion status
+         */
+        PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
+
+        /**
+         * Verify one key-value pair parameter against capability of the port and
+         * if the aSetParam flag is set, set the value of the parameter corresponding to
+         * the key.
+         *
+         * @param aKvp Key-value pair parameter to be verified
+         * @param aSetParam If true, set the value of parameter corresponding to the key.
+         * @return PVMFSuccess if parameter is supported, else PVMFFailure
+         */
+        PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
+
+        // Command queue and command id generator
+        PVMFCommandId iCommandCounter;
+        Oscl_Vector<PvmiMIOCommLoopbackCmd, OsclMemBasicAllocator > iCmdQueue;
+
+        // PvmiMIO sessions
+        Oscl_Vector<PvmiMIOObserver*, OsclMemBasicAllocator > iObservers;
+
+        PvmiMediaTransfer* iPeer;
+
+        // Thread logon
+        bool iThreadLoggedOn;
+
+        PvmiMIOCommLoopbackSettings iSettings;
+
+        // For generic allocations
+        OsclMemAllocator iAlloc;
+
+        // Allocator for media data buffer to store received
+        // data for loopback
+        PVMFSimpleMediaBufferCombinedAlloc iMediaDataAlloc;
+        //PvmiMIOCommDataBufferAlloc iMediaDataAlloc;
+        OsclMemPoolFixedChunkAllocator iMediaDataMemPool;
+
+        Oscl_Vector<PVMFSharedMediaMsgPtr, OsclMemBasicAllocator > iOutgoingQueue;
+
+        // Logger
+        PVLogger* iLogger;
+
+        // State machine
+        enum PvmiMIOCommLoopbackState
+        {
+            STATE_IDLE,
+            STATE_INITIALIZED,
+            STATE_STARTED,
+            STATE_FLUSHING,
+            STATE_PAUSED,
+            STATE_STOPPED
+        };
+        PvmiMIOCommLoopbackState iState;
+
+        // sent to signal completion of asynchronous write
+        class WriteResponse
+        {
+            public:
+                WriteResponse(PVMFStatus s, PVMFCommandId id, const OsclAny* ctx, const PVMFTimestamp& ts)
+                        : iStatus(s), iCmdId(id), iContext(ctx), iTimestamp(ts)
+                {}
+
+                PVMFStatus iStatus;
+                PVMFCommandId iCmdId;
+                const OsclAny* iContext;
+                PVMFTimestamp iTimestamp;
+        };
+        Oscl_Vector<WriteResponse, OsclMemBasicAllocator > iWriteResponseQueue;
+
+        // queue for data that is being sent asynchronously.  can't
+        // delete it until we get writeComplete() call for it.
+        class CleanupQueueElement
+        {
+            public:
+                CleanupQueueElement(PVMFSharedMediaDataPtr d, PVMFCommandId id): iData(d), iCmdId(id) {}
+                PVMFSharedMediaDataPtr iData;
+                PVMFCommandId iCmdId;
+        };
+
+        enum WriteState
+        {
+            EWriteBusy,
+            EWriteWait,
+            EWriteOK
+        };
+        WriteState iWriteState;
+        // In case any of the writeAsync calls fail
+        bool iResend;
+        uint32 iResendSeqNum;
+        uint32 iResendFragment;
+        uint32 iWriteAsyncContext;
+
+        Oscl_Vector<CleanupQueueElement, OsclMemBasicAllocator > iCleanupQueue;
+};
+
+#endif // PVMI_MIO_LOOPBACK_REFERENCE_H_INCLUDED
diff --git a/pvmi/media_io/pvmiofileoutput/Android.mk b/pvmi/media_io/pvmiofileoutput/Android.mk
index acf8f90..0b208e1 100644
--- a/pvmi/media_io/pvmiofileoutput/Android.mk
+++ b/pvmi/media_io/pvmiofileoutput/Android.mk
@@ -2,28 +2,31 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-	src/pvmi_media_io_fileoutput.cpp
+ 	src/pvmi_media_io_fileoutput.cpp
+
+
+LOCAL_MODULE := libpvmiofileoutput
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
 
-LOCAL_MODULE := libfile_mediaio
+LOCAL_STATIC_LIBRARIES := 
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
-
+LOCAL_SHARED_LIBRARIES := 
 
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/media_io/pvmiofileoutput/include \
-	$(PV_TOP)//pvmi/media_io/pvmiofileoutput/src \
-	$(PV_TOP)//pvmi/media_io/pvmiofileoutput/../../../nodes/common/include \
-	$(PV_TOP)//pvmi/media_io/pvmiofileoutput/../../pvmf/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/media_io/pvmiofileoutput/src \
+ 	$(PV_TOP)/pvmi/media_io/pvmiofileoutput/include \
+ 	$(PV_TOP)/nodes/common/include \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmi_media_io_fileoutput.h \
-	include/pvmi_media_io_fileoutput_registry_factory.h \
-	include/avi_write.h
+ 	include/pvmi_media_io_fileoutput_registry_factory.h \
+ 	include/avi_write.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/media_io/pvmiofileoutput/build/make/local.mk b/pvmi/media_io/pvmiofileoutput/build/make/local.mk
new file mode 100644
index 0000000..163d758
--- /dev/null
+++ b/pvmi/media_io/pvmiofileoutput/build/make/local.mk
@@ -0,0 +1,26 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmiofileoutput 
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+XINCDIRS +=  ../../../../../nodes/common/include  ../../../../pvmf/include
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmi_media_io_fileoutput.cpp
+
+HDRS := pvmi_media_io_fileoutput.h \
+   pvmi_media_io_fileoutput_registry_factory.h \
+   avi_write.h
+
+include $(MK)/library.mk
diff --git a/pvmi/media_io/pvmiofileoutput/build/make/makefile b/pvmi/media_io/pvmiofileoutput/build/make/makefile
deleted file mode 100644
index 67d68ba..0000000
--- a/pvmi/media_io/pvmiofileoutput/build/make/makefile
+++ /dev/null
@@ -1,57 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = file_mediaio
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please includie a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += -DUSE_UNICODE  -D_POSIX_PTHREAD_SEMANTICS   #-D_POSIX_SOURCE
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-XINCDIRS += -I ../../../../../nodes/common/include -I ../../../../pvmf/include
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS = pvmi_media_io_fileoutput.cpp
-
-HDRS = pvmi_media_io_fileoutput.h \
-   pvmi_media_io_fileoutput_registry_factory.h \
-   avi_write.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/pvmi/media_io/pvmiofileoutput/include/avi_write.h b/pvmi/media_io/pvmiofileoutput/include/avi_write.h
index 39d581a..8a23b91 100644
--- a/pvmi/media_io/pvmiofileoutput/include/avi_write.h
+++ b/pvmi/media_io/pvmiofileoutput/include/avi_write.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 /* ---------------------------------------------------------------- */
 /*	Create AVI file from a YUV or RGB output of MPEG4 decoder.		*/
 /* //////////////////////////////////////////////////////////////// */
+
 #ifndef AVI_WRITE_H_INCLUDED
 #define AVI_WRITE_H_INCLUDED
 
@@ -61,12 +62,9 @@
 #define videoChunkID        mmioFOURCC('0', '0', 'd', 'b')
 #define ckidAVINEWINDEX		mmioFOURCC('i', 'd', 'x', '1')
 
-#define AVIF_HASINDEX		0x00000010	// Index at end of file?
-#define AVIF_MUSTUSEINDEX	0x00000020
-#define AVIF_ISINTERLEAVED	0x00000100
-#define AVIF_TRUSTCKTYPE	0x00000800	// Use CKType to find key frames?
-#define AVIF_WASCAPTUREFILE	0x00010000
-#define AVIF_COPYRIGHTED	0x00020000
+#define AVIF_HASINDEX_FILE_OUT		0x00000010	// Index at end of file?
+#define AVIF_TRUSTCKTYPE_FILE_OUT	0x00000800	// Use CKType to find key frames?
+
 
 #define DEFAULT_COUNT 20000 /* default number of frames */
 
@@ -104,8 +102,8 @@
  * Stream header
  */
 
-#define AVISF_DISABLED			0x00000001
-#define AVISF_VIDEO_PALCHANGES		0x00010000
+//#define AVISF_DISABLED			0x00000001
+//#define AVISF_VIDEO_PALCHANGES		0x00010000
 
 typedef struct
 {
diff --git a/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput.h b/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput.h
index 94d8e3c..76bdb96 100644
--- a/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput.h
+++ b/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,15 +43,35 @@
 #include "pvmi_media_io_clock_extension.h"
 #endif
 
+#ifndef AVI_WRITE_H_INCLUDED
 #include "avi_write.h"
+#endif
 
 class PVLogger;
 class PVRefFileOutputTestObserver;
-class OsclClock;
+class PVMFMediaClock;
 class PVRefFileOutput;
 
 #define DEFAULT_NUM_DECODED_FRAMES_CAPABILITY	6
 
+// To maintain the count of supported uncompressed audio formats.
+// Should be updated whenever new format is added
+#define PVMF_SUPPORTED_UNCOMPRESSED_AUDIO_FORMATS_COUNT 6
+
+// To maintain the count of supported uncompressed video formats.
+// Should be updated whenever new format is added
+#define PVMF_SUPPORTED_UNCOMPRESSED_VIDEO_FORMATS_COUNT 6
+
+// To maintain the count of supported compressed audio formats.
+// Should be updated whenever new format is added
+#define PVMF_SUPPORTED_COMPRESSED_AUDIO_FORMATS_COUNT 18
+
+// To maintain the count of supported compressed video formats.
+// Should be updated whenever new format is added
+#define PVMF_SUPPORTED_COMPRESSED_VIDEO_FORMATS_COUNT 8
+
+#define PVMF_SUPPORTED_TEXT_FORMAT_COUNT 1
+
 typedef struct
 {
     uint32      chunkID;
@@ -77,6 +97,14 @@
     uint32      subchunk2Size;
 } dataSubchunk;
 
+typedef enum
+{
+    MEDIATYPE_VIDEO,
+    MEDIATYPE_AUDIO,
+    MEDIATYPE_TEXT,
+    MEDIATYPE_UNKNOWN
+} MediaType;
+
 // A test feature for simulating a component with active timing.
 class PVRefFileOutputActiveTimingSupport: public PvmiClockExtensionInterface
 {
@@ -93,7 +121,7 @@
         {}
 
         //from PvmiClockExtensionInterface
-        OSCL_IMPORT_REF PVMFStatus SetClock(OsclClock *clockVal) ;
+        OSCL_IMPORT_REF PVMFStatus SetClock(PVMFMediaClock *clockVal) ;
 
         //from PVInterface
         OSCL_IMPORT_REF void addRef() ;
@@ -111,7 +139,7 @@
 
         uint32 iQueueLimit;
 
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
         PVLogger* iLogger;
 
         //query for whether playback clock is in frame-step mode.
@@ -133,6 +161,10 @@
         OSCL_IMPORT_REF PVRefFileOutput(const oscl_wchar* aFileName,
                                         bool aActiveTiming = false);
 
+        OSCL_IMPORT_REF PVRefFileOutput(const oscl_wchar* aFileName,
+                                        MediaType aMediaType,
+                                        bool aCompressedMedia = false);
+
         OSCL_IMPORT_REF PVRefFileOutput(const OSCL_wString& aFileName, bool logStrings = false);
 
         // Expanded constructor with test features.
@@ -376,13 +408,14 @@
         //if iUseClockExtension set to true, no data is dropped
         bool iUseClockExtension;
 
+        //Used for deciding when to send ConfigComplete event to MIO node
+        bool iIsMIOConfigured;
+
         // used to create the WAV file output.
         RIFFChunk    iRIFFChunk;
         fmtSubchunk  iFmtSubchunk;
         dataSubchunk iDataSubchunk;
         bool         iHeaderWritten;
-        uint32       iAudioFormatType;
-        uint32       iVideoFormatType;
         PVMFTimestamp iVideoLastTimeStamp;
         bool         iInitializeAVIDone;
 
@@ -397,6 +430,9 @@
         uint32		  iAVIStreamHeaderPosition;
         uint32        iVideoCount;
         uint32        iPreviousOffset;
+
+        MediaType	  iMediaType;
+        bool		  iCompressedMedia;
 };
 
 //An observer class for test support.
diff --git a/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput_registry_factory.h b/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput_registry_factory.h
index 2c97c17..735d19c 100644
--- a/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput_registry_factory.h
+++ b/pvmi/media_io/pvmiofileoutput/include/pvmi_media_io_fileoutput_registry_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/media_io/pvmiofileoutput/src/pvmi_media_io_fileoutput.cpp b/pvmi/media_io/pvmiofileoutput/src/pvmi_media_io_fileoutput.cpp
index 8a107c8..2e89a07 100644
--- a/pvmi/media_io/pvmiofileoutput/src/pvmi_media_io_fileoutput.cpp
+++ b/pvmi/media_io/pvmiofileoutput/src/pvmi_media_io_fileoutput.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,6 +54,7 @@
 {
     initData();
     iLogStrings = logStrings;
+    iMediaType = MEDIATYPE_UNKNOWN;
 }
 
 
@@ -70,6 +71,7 @@
     iSimFlowControl = aSimFlowControl;
     iTestObserver = aTestObs;
     iActiveTiming = NULL;
+    iMediaType = MEDIATYPE_UNKNOWN;
     if (aSimTiming)
     {
         OsclMemAllocator alloc;
@@ -78,6 +80,8 @@
         {
             iActiveTiming = OSCL_PLACEMENT_NEW(ptr, PVRefFileOutputActiveTimingSupport(aQueueLimit));
         }
+        // For active MIO assuming it to be audio MIO.
+        iMediaType = MEDIATYPE_AUDIO;
     }
     iLogStrings = logStrings;
     iParametersLogged = false;
@@ -90,6 +94,7 @@
 {
     initData();
     iActiveTiming = NULL;
+    iMediaType = MEDIATYPE_UNKNOWN;
     if (aActiveTiming)
     {
         OsclMemAllocator alloc;
@@ -98,16 +103,29 @@
         {
             iActiveTiming = OSCL_PLACEMENT_NEW(ptr, PVRefFileOutputActiveTimingSupport(10));
         }
+        // For active MIO assuming it to be audio MIO.
+        iMediaType = MEDIATYPE_AUDIO;
     }
 }
 
+OSCL_EXPORT_REF PVRefFileOutput::PVRefFileOutput(const oscl_wchar* aFileName,
+        MediaType aMediaType,
+        bool aCompressedMedia)
+        : OsclTimerObject(OsclActiveObject::EPriorityNominal, "pvreffileoutput")
+        , iOutputFileName(aFileName)
+        , iMediaType(aMediaType)
+        , iCompressedMedia(aCompressedMedia)
+{
+    initData();
+}
+
 void PVRefFileOutput::initData()
 {
-    iAudioFormat = PVMF_FORMAT_UNKNOWN;
+    iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iAudioNumChannelsValid = false;
     iAudioSamplingRateValid = false;
 
-    iVideoFormat = PVMF_FORMAT_UNKNOWN;
+    iVideoFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iVideoHeightValid = false;
     iVideoWidthValid = false;
     iVideoDisplayHeightValid = false;
@@ -133,7 +151,7 @@
     iLogStrings = false;
     iParametersLogged = false;
     iFormatMask = 0;
-    iTextFormat = PVMF_FORMAT_UNKNOWN;
+    iTextFormat = PVMF_MIME_FORMAT_UNKNOWN;
 #if PVFILEOUTPUT_CLOCK_EXTN_SUPPORTED
     iUseClockExtension = true;
 #else
@@ -156,23 +174,36 @@
     iDataSubchunk.subchunk2Size = 0;
 
     iHeaderWritten = false;
-    iAudioFormatType = 0;
-    iVideoFormatType = 0;
+    iAudioFormat = 0;
+    iVideoFormat = 0;
     iInitializeAVIDone = false;
     iAVIChunkSize = 0;
     iVideoLastTimeStamp = 0;
     iVideoCount = 0;
+    iIsMIOConfigured = false;
+    //Connect with file server.
+    if (!iFsConnected)
+    {
+        if (iFs.Connect() == 0)
+        {
+            iFsConnected = true;
+        }
+        else
+        {
+            OSCL_ASSERT(false);
+        }
+    }
 }
 
 void PVRefFileOutput::ResetData()
 //reset all data from this session.
 {
-    if (iAudioFormatType == PVMF_PCM16 || iAudioFormatType == PVMF_PCM8)
+    if (iAudioFormat == PVMF_MIME_PCM16 || iAudioFormat == PVMF_MIME_PCM8)
     {
         UpdateWaveChunkSize();
     }
 
-    if (iVideoFormatType == PVMF_YUV420)
+    if (iVideoFormat == PVMF_MIME_YUV420)
     {
         UpdateVideoChunkHeaderIdx();
     }
@@ -181,19 +212,20 @@
     //reset all the received media parameters.
 
     iAudioFormatString = "";
-    iAudioFormat = PVMF_FORMAT_UNKNOWN;
+    iAudioFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iAudioNumChannelsValid = false;
     iAudioSamplingRateValid = false;
 
     iVideoFormatString = "";
-    iVideoFormat = PVMF_FORMAT_UNKNOWN;
+    iVideoFormat = PVMF_MIME_FORMAT_UNKNOWN;
     iVideoHeightValid = false;
     iVideoWidthValid = false;
     iVideoDisplayHeightValid = false;
     iVideoDisplayWidthValid = false;
+    iIsMIOConfigured = false;
 
     iTextFormatString = "";
-    iTextFormat = PVMF_FORMAT_UNKNOWN;
+    iTextFormat = PVMF_MIME_FORMAT_UNKNOWN;
 
     iParametersLogged = false;
 }
@@ -207,11 +239,6 @@
         iOutputFile.Close();
     }
     iFileOpened = false;
-    if (iFsConnected)
-    {
-        iFs.Close();
-    }
-    iFsConnected = false;
 
     while (!iCommandResponseQueue.empty())
     {
@@ -242,6 +269,12 @@
         alloc.deallocate(iActiveTiming);
         iActiveTiming = NULL;
     }
+
+    if (iFsConnected)
+    {
+        iFs.Close();
+    }
+    iFsConnected = false;
 }
 
 
@@ -267,25 +300,8 @@
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRefFileOutput::disconnect() called"));
     OSCL_UNUSED_ARG(aSession);
-    //currently supports only one session
 
-    while (!iCommandResponseQueue.empty())
-    {
-        if (iObserver)
-        {
-            iObserver->RequestCompleted(PVMFCmdResp(iCommandResponseQueue[0].iCmdId, iCommandResponseQueue[0].iContext, iCommandResponseQueue[0].iStatus));
-        }
-        iCommandResponseQueue.erase(&iCommandResponseQueue[0]);
-    }
-    while (!iWriteResponseQueue.empty())
-    {
-        if (iPeer)
-        {
-            iPeer->writeComplete(iWriteResponseQueue[0].iStatus, iWriteResponseQueue[0].iCmdId, (OsclAny*)iWriteResponseQueue[0].iContext);
-        }
-        iWriteResponseQueue.erase(&iWriteResponseQueue[0]);
-    }
-
+    // just set the observer to NULL, any command completes should be done before disconnect.
     iObserver = NULL;
     return PVMFSuccess;
 }
@@ -490,6 +506,7 @@
         case STATE_PAUSED:
             iState = STATE_STARTED;
             status = PVMFSuccess;
+
             break;
 
         default:
@@ -677,30 +694,11 @@
         AddToScheduler();
         iState = STATE_LOGGED_ON;
     }
-
-    //Open the file.
-    if (!iFsConnected)
-    {
-        if (iFs.Connect() != 0)
-        {
-            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRefFileOutput::ThreadLogon() Unable to Connect File Server"));
-        }
-        else
-        {
-            iFsConnected = true;
-        }
-    }
 }
 
 
 void PVRefFileOutput::ThreadLogoff()
 {
-    if (iFsConnected)
-    {
-        iFs.Close();
-        iFsConnected = false;
-    }
-
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVRefFileOutput::ThreadLogoff() called"));
     if (iState != STATE_IDLE)
     {
@@ -827,7 +825,7 @@
     }
     else
     {
-        if (iVideoFormat == PVMF_H264)
+        if (iVideoFormat == PVMF_MIME_H264_VIDEO_MP4)
         {
             iOutputFile.Write(&datalen, sizeof(uint8), sizeof(uint32));
         }
@@ -854,7 +852,7 @@
     }
     else
     {
-        if (iVideoFormat == PVMF_H264)
+        if (iVideoFormat == PVMF_MIME_H264_VIDEO_MP4)
         {
             iOutputFile.Write(&datalen, sizeof(uint8), sizeof(uint32));
         }
@@ -920,7 +918,9 @@
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                                         (0, "PVRefFileOutput::writeAsync: Error - Invalid state"));
-                        status = PVMFErrInvalidState;
+                        iWriteBusy = true;
+                        OSCL_LEAVE(OsclErrInvalidState);
+                        return -1;
                     }
                     else
                     {
@@ -961,7 +961,9 @@
                     {
                         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
                                         (0, "PVRefFileOutput::writeAsync: Error - Invalid state"));
-                        status = PVMFErrInvalidState;
+                        iWriteBusy = true;
+                        OSCL_LEAVE(OsclErrInvalidState);
+                        return -1;
                     }
                     //Check whether we can accept data now and leave if we can't.
                     else if (CheckWriteBusy(data_header_info.seq_num))
@@ -991,7 +993,7 @@
                         {
                             //check whether the player clock is in frame-step mode.
                             //do not render audio in frame-step mode.
-                            if (iAudioFormat != PVMF_FORMAT_UNKNOWN
+                            if (iAudioFormat != PVMF_MIME_FORMAT_UNKNOWN
                                     && iActiveTiming
                                     && iActiveTiming->FrameStepMode())
                             {
@@ -999,10 +1001,10 @@
                             }
 
                             LogFrame(data_header_info.seq_num, data_header_info.timestamp, aDataLen);
-                            if (iTextFormat == PVMF_3GPP_TIMEDTEXT)
+                            if (iTextFormat == PVMF_MIME_3GPP_TIMEDTEXT)
                             {
                                 // Guard against somebody setting this MIO component for multiple data types
-                                OSCL_ASSERT(iVideoFormat == PVMF_FORMAT_UNKNOWN && iAudioFormat == PVMF_FORMAT_UNKNOWN);
+                                OSCL_ASSERT(iVideoFormat == PVMF_MIME_FORMAT_UNKNOWN && iAudioFormat == PVMF_MIME_FORMAT_UNKNOWN);
 
                                 PVMFTimedTextMediaData* textmediadata = (PVMFTimedTextMediaData*)aData;
 
@@ -1045,20 +1047,24 @@
                             }
                             else
                             {
-                                if (iHeaderWritten != true && (iAudioFormatType == PVMF_PCM16 || iAudioFormatType == PVMF_PCM8))
+                                if (iHeaderWritten != true && (iAudioFormat == PVMF_MIME_PCM16 || iAudioFormat == PVMF_MIME_PCM8))
                                 {
                                     iOutputFile.Write(&iRIFFChunk, sizeof(uint8), sizeof(RIFFChunk));
                                     iOutputFile.Write(&iFmtSubchunk, sizeof(uint8), sizeof(fmtSubchunk));
                                     iOutputFile.Write(&iDataSubchunk, sizeof(uint8), sizeof(dataSubchunk));
                                     iHeaderWritten = true;
                                 }
-                                if (iHeaderWritten != true && (iVideoFormatType == PVMF_YUV420 || iVideoFormatType == PVMF_YUV422))
+                                if (iHeaderWritten != true && (iVideoFormat == PVMF_MIME_YUV420 || iVideoFormat == PVMF_MIME_YUV422))
                                 {
                                     WriteHeaders();
                                     iHeaderWritten = true;
                                 }
 
-                                if (iAudioFormatType == PVMF_AMR_IETF || iAudioFormatType == PVMF_AMR_IF2 || iVideoFormatType == PVMF_H263 || iVideoFormatType == PVMF_M4V)
+                                if (iAudioFormat == PVMF_MIME_AMR_IETF ||
+                                        iAudioFormat == PVMF_MIME_AMR_IF2 ||
+                                        iVideoFormat == PVMF_MIME_H2631998 ||
+                                        iVideoFormat == PVMF_MIME_H2632000 ||
+                                        iVideoFormat == PVMF_MIME_M4V)
                                 {
                                     if (iOutputFile.Write(aData, sizeof(uint8), aDataLen) != aDataLen)
                                     {
@@ -1072,7 +1078,7 @@
                                     }
                                 }
                                 //'render' this frame
-                                if (iAudioFormatType == PVMF_PCM16 || iAudioFormatType == PVMF_PCM8)
+                                if (iAudioFormat == PVMF_MIME_PCM16 || iAudioFormat == PVMF_MIME_PCM8)
                                 {
                                     if (iOutputFile.Write(aData, sizeof(uint8), aDataLen) != aDataLen)
                                     {
@@ -1082,13 +1088,13 @@
                                     }
                                     else
                                     {
-                                        if (iAudioFormatType == PVMF_PCM16 || iAudioFormatType == PVMF_PCM8)
+                                        if (iAudioFormat == PVMF_MIME_PCM16 || iAudioFormat == PVMF_MIME_PCM8)
                                             iDataSubchunk.subchunk2Size += aDataLen;
                                         status = PVMFSuccess;
                                     }
                                 }
 
-                                if (iVideoFormatType == PVMF_YUV420 || iVideoFormatType == PVMF_YUV422)
+                                if (iVideoFormat == PVMF_MIME_YUV420 || iVideoFormat == PVMF_MIME_YUV422)
                                 {
 #ifdef AVI_OUTPUT
 #if 1
@@ -1285,25 +1291,39 @@
 
         //Generate a list of all the PVMF audio & video formats...
         int32 count = 0;
-        if (iFormatMask == 0 || (iFormatMask & PVMF_UNCOMPRESSED_AUDIO_FORMAT))
+        if (iMediaType == MEDIATYPE_AUDIO)
         {
-            count += (1 + PVMF_LAST_UNCOMPRESSED_AUDIO - PVMF_FIRST_UNCOMPRESSED_AUDIO);
+            if (iCompressedMedia)
+            {
+                count = PVMF_SUPPORTED_COMPRESSED_AUDIO_FORMATS_COUNT;
+            }
+            else
+            {
+                count = PVMF_SUPPORTED_UNCOMPRESSED_AUDIO_FORMATS_COUNT;
+            }
         }
-        if (iFormatMask == 0 || (iFormatMask & PVMF_COMPRESSED_AUDIO_FORMAT))
+        else if (iMediaType == MEDIATYPE_VIDEO)
         {
-            count += (1 + PVMF_LAST_COMPRESSED_AUDIO - PVMF_FIRST_COMPRESSED_AUDIO);
+            if (iCompressedMedia)
+            {
+                count = PVMF_SUPPORTED_COMPRESSED_VIDEO_FORMATS_COUNT;
+            }
+            else
+            {
+                count = PVMF_SUPPORTED_UNCOMPRESSED_VIDEO_FORMATS_COUNT;
+            }
         }
-        if (iFormatMask == 0 || (iFormatMask & PVMF_UNCOMPRESSED_VIDEO_FORMAT))
+        else if (iMediaType == MEDIATYPE_TEXT)
         {
-            count += (1 + PVMF_LAST_UNCOMPRESSED_VIDEO - PVMF_FIRST_UNCOMPRESSED_VIDEO);
+            count = PVMF_SUPPORTED_TEXT_FORMAT_COUNT;
         }
-        if (iFormatMask == 0 || (iFormatMask & PVMF_COMPRESSED_VIDEO_FORMAT))
+        else
         {
-            count += (1 + PVMF_LAST_COMPRESSED_VIDEO - PVMF_FIRST_COMPRESSED_VIDEO);
-        }
-        if (iFormatMask == 0 || (iFormatMask & PVMF_TEXT_FORMAT))
-        {
-            count += ( + 1 + PVMF_LAST_TEXT - PVMF_FIRST_TEXT);
+            count = PVMF_SUPPORTED_UNCOMPRESSED_AUDIO_FORMATS_COUNT +
+                    PVMF_SUPPORTED_UNCOMPRESSED_VIDEO_FORMATS_COUNT +
+                    PVMF_SUPPORTED_COMPRESSED_AUDIO_FORMATS_COUNT +
+                    PVMF_SUPPORTED_COMPRESSED_VIDEO_FORMATS_COUNT +
+                    PVMF_SUPPORTED_TEXT_FORMAT_COUNT;
         }
 
         aParameters = (PvmiKvp*)oscl_malloc(count * sizeof(PvmiKvp));
@@ -1311,72 +1331,154 @@
         if (aParameters)
         {
             PVMFFormatType fmt;
-            if (iFormatMask == 0 || (iFormatMask & PVMF_UNCOMPRESSED_AUDIO_FORMAT))
+            if (iMediaType == MEDIATYPE_AUDIO || iMediaType == MEDIATYPE_UNKNOWN)
             {
-                for (fmt = PVMF_FIRST_UNCOMPRESSED_AUDIO;fmt <= PVMF_LAST_UNCOMPRESSED_AUDIO;fmt++)
+                if (iCompressedMedia || iMediaType == MEDIATYPE_UNKNOWN)
                 {
-                    aParameters[num_parameter_elements].value.uint32_value = (uint32)fmt;
-                    aParameters[num_parameter_elements].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
-                    if (!aParameters[num_parameter_elements].key)
+                    int32 i = 0;
+                    if (iMediaType == MEDIATYPE_UNKNOWN)
                     {
-                        return PVMFErrNoMemory;
-                        // (hope it's safe to leave array partially
-                        //  allocated, caller will free?)
+                        i = num_parameter_elements;
                     }
-                    oscl_strncpy(aParameters[num_parameter_elements++].key, MOUT_AUDIO_FORMAT_KEY, oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
+
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_AMR;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_AMRWB;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_AMR_IETF;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_AMRWB_IETF;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_AMR_IF2;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_EVRC;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_MP3;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ADIF;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ADTS;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_LATM;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_MPEG4_AUDIO;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_G723;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_G726;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_WMA;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ASF_AMR;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_REAL_AUDIO;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ASF_MPEG4_AUDIO;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_3640;
+
+                    while (i < count)
+                    {
+                        aParameters[i].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
+                        if (!aParameters[i].key)
+                        {
+                            return PVMFErrNoMemory;
+                            // (hope it's safe to leave array partially
+                            //  allocated, caller will free?)
+                        }
+                        oscl_strncpy(aParameters[i++].key, MOUT_AUDIO_FORMAT_KEY, oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
+                    }
+                }
+
+                if (!iCompressedMedia || iMediaType == MEDIATYPE_UNKNOWN)
+                {
+                    int32 i = 0;
+                    if (iMediaType == MEDIATYPE_UNKNOWN)
+                    {
+                        i = num_parameter_elements;
+                    }
+
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM8;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM16;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_PCM16_BE;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ULAW;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_ALAW;
+
+                    while (i < count)
+                    {
+                        aParameters[i].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
+                        if (!aParameters[i].key)
+                        {
+                            return PVMFErrNoMemory;
+                            // (hope it's safe to leave array partially
+                            //  allocated, caller will free?)
+                        }
+                        oscl_strncpy(aParameters[i++].key, MOUT_AUDIO_FORMAT_KEY, oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
+                    }
                 }
             }
-            if (iFormatMask == 0 || (iFormatMask & PVMF_COMPRESSED_AUDIO_FORMAT))
+            if (iMediaType == MEDIATYPE_VIDEO || iMediaType == MEDIATYPE_UNKNOWN)
             {
-                for (fmt = PVMF_FIRST_COMPRESSED_AUDIO;fmt <= PVMF_LAST_COMPRESSED_AUDIO;fmt++)
+                if (iCompressedMedia || iMediaType == MEDIATYPE_UNKNOWN)
                 {
-                    aParameters[num_parameter_elements].value.uint32_value = (uint32)fmt;
-                    aParameters[num_parameter_elements].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
-                    if (!aParameters[num_parameter_elements].key)
+                    int32 i = 0;
+                    if (iMediaType == MEDIATYPE_UNKNOWN)
                     {
-                        return PVMFErrNoMemory;
+                        i = num_parameter_elements;
                     }
-                    oscl_strncpy(aParameters[num_parameter_elements++].key, MOUT_AUDIO_FORMAT_KEY, oscl_strlen(MOUT_AUDIO_FORMAT_KEY) + 1);
+
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_M4V;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_H2631998;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_H2632000;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_RAW;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO_MP4;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_H264_VIDEO;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_WMV;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_REAL_VIDEO;
+
+                    while (i < count)
+                    {
+                        aParameters[i].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
+                        if (!aParameters[i].key)
+                        {
+                            return PVMFErrNoMemory;
+                            // (hope it's safe to leave array partially
+                            //  allocated, caller will free?)
+                        }
+                        oscl_strncpy(aParameters[i++].key, MOUT_VIDEO_FORMAT_KEY, oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
+                    }
+                }
+
+                if (!iCompressedMedia || iMediaType == MEDIATYPE_UNKNOWN)
+                {
+                    int32 i = 0;
+                    if (iMediaType == MEDIATYPE_UNKNOWN)
+                    {
+                        i = num_parameter_elements;
+                    }
+
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_YUV420;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_YUV422;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB8;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB12;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB16;
+                    aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_RGB24;
+
+                    while (i < count)
+                    {
+                        aParameters[i].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
+                        if (!aParameters[i].key)
+                        {
+                            return PVMFErrNoMemory;
+                            // (hope it's safe to leave array partially
+                            //  allocated, caller will free?)
+                        }
+                        oscl_strncpy(aParameters[i++].key, MOUT_VIDEO_FORMAT_KEY, oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
+                    }
                 }
             }
-            if (iFormatMask == 0 || (iFormatMask & PVMF_UNCOMPRESSED_VIDEO_FORMAT))
+
+            if (iMediaType == MEDIATYPE_TEXT || iMediaType == MEDIATYPE_UNKNOWN)
             {
-                for (fmt = PVMF_FIRST_UNCOMPRESSED_VIDEO;fmt <= PVMF_LAST_UNCOMPRESSED_VIDEO;fmt++)
+                int32 i = 0;
+                if (iMediaType == MEDIATYPE_UNKNOWN)
                 {
-                    aParameters[num_parameter_elements].value.uint32_value = (uint32)fmt;
-                    aParameters[num_parameter_elements].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
-                    if (!aParameters[num_parameter_elements].key)
-                    {
-                        return PVMFErrNoMemory;
-                    }
-                    oscl_strncpy(aParameters[num_parameter_elements++].key, MOUT_VIDEO_FORMAT_KEY, oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
+                    i = num_parameter_elements;
                 }
-            }
-            if (iFormatMask == 0 || (iFormatMask & PVMF_COMPRESSED_VIDEO_FORMAT))
-            {
-                for (fmt = PVMF_FIRST_COMPRESSED_VIDEO;fmt <= PVMF_LAST_COMPRESSED_VIDEO;fmt++)
+
+                aParameters[num_parameter_elements++].value.pChar_value = (char*)PVMF_MIME_3GPP_TIMEDTEXT;
+                aParameters[i].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_TEXT_FORMAT_KEY) + 1);
+                if (!aParameters[i].key)
                 {
-                    aParameters[num_parameter_elements].value.uint32_value = (uint32)fmt;
-                    aParameters[num_parameter_elements].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
-                    if (!aParameters[num_parameter_elements].key)
-                    {
-                        return PVMFErrNoMemory;
-                    }
-                    oscl_strncpy(aParameters[num_parameter_elements++].key, MOUT_VIDEO_FORMAT_KEY, oscl_strlen(MOUT_VIDEO_FORMAT_KEY) + 1);
+                    return PVMFErrNoMemory;
+                    // (hope it's safe to leave array partially
+                    //  allocated, caller will free?)
                 }
-            }
-            if (iFormatMask == 0 || (iFormatMask & PVMF_TEXT_FORMAT))
-            {
-                for (fmt = PVMF_FIRST_TEXT;fmt <= PVMF_LAST_TEXT;fmt++)
-                {
-                    aParameters[num_parameter_elements].value.uint32_value = (uint32)fmt;
-                    aParameters[num_parameter_elements].key = (PvmiKeyType)oscl_malloc(oscl_strlen(MOUT_TEXT_FORMAT_KEY) + 1);
-                    if (!aParameters[num_parameter_elements].key)
-                    {
-                        return PVMFErrNoMemory;
-                    }
-                    oscl_strncpy(aParameters[num_parameter_elements++].key, MOUT_TEXT_FORMAT_KEY, oscl_strlen(MOUT_TEXT_FORMAT_KEY) + 1);
-                }
+                oscl_strncpy(aParameters[i++].key, MOUT_TEXT_FORMAT_KEY, oscl_strlen(MOUT_TEXT_FORMAT_KEY) + 1);
             }
             return PVMFSuccess;
         }
@@ -1458,16 +1560,15 @@
         if (pv_mime_strcmp(aParameters[i].key, MOUT_AUDIO_FORMAT_KEY) == 0)
         {
             if (oscl_strncmp(aParameters[i].value.pChar_value, "audio/L16", sizeof("audio/L16")) == 0)
-                iAudioFormatType = PVMF_PCM16;
+                iAudioFormat = PVMF_MIME_PCM16;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "audio/L8", sizeof("audio/L8")) == 0)
-                iAudioFormatType = PVMF_PCM8;
+                iAudioFormat = PVMF_MIME_PCM8;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "X-AMR-IF2", sizeof("X-AMR-IF2")) == 0)
-                iAudioFormatType = PVMF_AMR_IF2;
+                iAudioFormat = PVMF_MIME_AMR_IF2;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "X-AMR-IETF-SEPARATE", sizeof("X-AMR-IETF-SEPARATE")) == 0)
-                iAudioFormatType = PVMF_AMR_IETF;
+                iAudioFormat = PVMF_MIME_AMR_IETF;
 
-            iAudioFormat = iAudioFormatType;
-            GetFormatString(iAudioFormat, iAudioFormatString);
+            iAudioFormatString = iAudioFormat.getMIMEStrPtr();
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVRefFileOutput::setParametersSync() Audio Format Key, Value %s", iAudioFormatString.get_str()));
         }
@@ -1492,19 +1593,17 @@
         {
 
             if (oscl_strncmp(aParameters[i].value.pChar_value, "X-YUV-420", sizeof("X-YUV-420")) == 0)
-                iVideoFormatType = PVMF_YUV420;
+                iVideoFormat = PVMF_MIME_YUV420;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "X-YUV-422", sizeof("X-YUV-422")) == 0)
-                iVideoFormatType = PVMF_YUV422;
+                iVideoFormat = PVMF_MIME_YUV422;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "video/H263-2000", sizeof("video/H263-2000")) == 0)
-                iVideoFormatType = PVMF_H263;
+                iVideoFormat = PVMF_MIME_H2632000;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "video/H263-1998", sizeof("video/H263-1998")) == 0)
-                iVideoFormatType = PVMF_H263;
+                iVideoFormat = PVMF_MIME_H2631998;
             else if (oscl_strncmp(aParameters[i].value.pChar_value, "video/MP4V-ES", sizeof("video/MP4V-ES")) == 0)
-                iVideoFormatType = PVMF_M4V;
+                iVideoFormat = PVMF_MIME_M4V;
 
-            iVideoFormat = iVideoFormatType;
-
-            GetFormatString(iVideoFormat, iVideoFormatString);
+            iVideoFormatString = iVideoFormat.getMIMEStrPtr();
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVRefFileOutput::setParametersSync() Video Format Key, Value %s", iVideoFormatString.get_str()));
         }
@@ -1540,7 +1639,7 @@
         else if (pv_mime_strcmp(aParameters[i].key, MOUT_TEXT_FORMAT_KEY) == 0)
         {
             iTextFormatString = aParameters[i].value.pChar_value;
-            iTextFormat = GetFormatIndex(iTextFormatString.get_str());
+            iTextFormat = iTextFormatString.get_str();
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                             (0, "PVRefFileOutput::setParametersSync() Text Format Key, Value %s", iTextFormatString.get_str()));
         }
@@ -1565,12 +1664,15 @@
                 {
                     iFileOpened = true;
                     LogCodecHeader(0, 0, (int32)aParameters[i].capacity);
-                    if (iOutputFile.Write(aParameters[i].value.pChar_value,
-                                          sizeof(uint8),
-                                          (int32)aParameters[i].capacity) != (uint32)aParameters[i].length)
+                    if (aParameters[i].value.pChar_value != NULL)
                     {
-                        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
-                                        (0, "PVRefFileOutput::setParametersSync: Error - File write failed"));
+                        if (iOutputFile.Write(aParameters[i].value.pChar_value,
+                                              sizeof(uint8),
+                                              (int32)aParameters[i].capacity) != (uint32)aParameters[i].length)
+                        {
+                            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_ERR,
+                                            (0, "PVRefFileOutput::setParametersSync: Error - File write failed"));
+                        }
                     }
                 }
             }
@@ -1587,7 +1689,7 @@
             return;
         }
     }
-    if (iAudioFormatType == PVMF_PCM16)
+    if (iAudioFormat == PVMF_MIME_PCM16)
     {
         iFmtSubchunk.bitsPerSample = 16;
         iFmtSubchunk.byteRate = iFmtSubchunk.sampleRate * iFmtSubchunk.numChannels * iFmtSubchunk.bitsPerSample / 8;
@@ -1601,11 +1703,24 @@
 
     }
 
-    if ((iVideoFormatType == PVMF_YUV420 || iVideoFormatType == PVMF_YUV422) && (iVideoHeightValid == true && iVideoHeightValid == true && iInitializeAVIDone == false))
+    if ((iVideoFormat == PVMF_MIME_YUV420 || iVideoFormat == PVMF_MIME_YUV422) && (iVideoHeightValid == true && iVideoHeightValid == true && iInitializeAVIDone == false))
     {
         InitializeAVI(iVideoWidth, iVideoHeight);
         iInitializeAVIDone = true;
     }
+
+    //No configuration is required for this MIO to function.
+    //So, send PVMFMIOConfigurationComplete() from Run()
+
+    //If MIO is configured, send PVMFMIOConfigurationComplete event to observer.
+    if (!iIsMIOConfigured)
+    {
+        if (iObserver)
+        {
+            iObserver->ReportInfoEvent(PVMFMIOConfigurationComplete);
+            iIsMIOConfigured = true;
+        }
+    }
 }
 
 PVMFCommandId PVRefFileOutput::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
@@ -1633,9 +1748,160 @@
         int num_elements)
 {
     OSCL_UNUSED_ARG(aSession);
-    OSCL_UNUSED_ARG(aParameters);
-    OSCL_UNUSED_ARG(num_elements);
-    /* Since we are just logging to file, we can always return success */
+
+    // Go through each parameter
+    for (int32 paramind = 0; paramind < num_elements; ++paramind)
+    {
+        // Retrieve the first component from the key string
+        char* compstr = NULL;
+        pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
+
+        if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/media/format-type")) == 0)
+        {
+            if (iMediaType == MEDIATYPE_UNKNOWN)
+            {
+                // For an unknown media type return PVMFErrNotSupported always.
+                return PVMFErrNotSupported;
+            }
+
+            if (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_FORMAT_UNKNOWN) == 0)
+            {
+                return PVMFErrNotSupported;
+            }
+
+            // The Sink will return success based on following conditions:
+            // i) The MIME string is supported by the sink, Text Sink will support Text MIME,
+            //    Audio Sink - Audio MIME and Video Sink - Video MIME.
+            // ii) For all compressed formats, if the sink itself is Compressed. If the sink
+            //      is UnCompressed here, Sink will send PVMFErrNotSupported.
+            // iii) For all uncompressed formats, if the sink itself is Uncompressed. If the sink
+            //      is Compressed here, Sink will send PVMFErrNotSupported.
+            if (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_3GPP_TIMEDTEXT) == 0)
+            {
+                if (iMediaType == MEDIATYPE_TEXT)
+                {
+                    return PVMFSuccess;
+                }
+                else
+                {
+                    return PVMFErrNotSupported;
+                }
+            }
+            else if ((pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_YUV420) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_YUV422) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB8) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB12) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB16) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_RGB24) == 0))
+            {
+                // Uncompressed Video formats
+                if (iMediaType == MEDIATYPE_VIDEO)
+                {
+                    if (iCompressedMedia)
+                    {
+                        return PVMFErrNotSupported;
+                    }
+                    else
+                    {
+                        return PVMFSuccess;
+                    }
+                }
+                else
+                {
+                    return PVMFErrNotSupported;
+                }
+            }
+            else if ((pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_M4V) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_H2631998) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_H2632000) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_H264_VIDEO_RAW) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_H264_VIDEO_MP4) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_H264_VIDEO) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_WMV) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_REAL_VIDEO) == 0))
+            {
+                // Compressed Video formats
+                if (iMediaType == MEDIATYPE_VIDEO)
+                {
+                    if (iCompressedMedia)
+                    {
+                        return PVMFSuccess;
+                    }
+                    else
+                    {
+                        return PVMFErrNotSupported;
+                    }
+                }
+                else
+                {
+                    return PVMFErrNotSupported;
+                }
+            }
+            else if ((pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM8) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM16) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_PCM16_BE) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ULAW) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ALAW) == 0))
+            {
+                // Uncompressed Audio formats
+                if (iMediaType == MEDIATYPE_AUDIO)
+                {
+                    if (iCompressedMedia)
+                    {
+                        return PVMFErrNotSupported;
+                    }
+                    else
+                    {
+                        return PVMFSuccess;
+                    }
+                }
+                else
+                {
+                    return PVMFErrNotSupported;
+                }
+            }
+            else if ((pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_AMR) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_AMRWB) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_AMR_IETF) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_AMRWB_IETF) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_AMR_IF2) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_EVRC) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_MP3) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ADIF) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ADTS) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_LATM) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_MPEG4_AUDIO) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_G723) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_G726) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_WMA) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ASF_AMR) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_REAL_AUDIO) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_ASF_MPEG4_AUDIO) == 0) ||
+                     (pv_mime_strcmp(aParameters[paramind].value.pChar_value, PVMF_MIME_3640) == 0))
+            {
+                // Compressed audio formats
+                if (iMediaType == MEDIATYPE_AUDIO)
+                {
+                    if (iCompressedMedia)
+                    {
+                        return PVMFSuccess;
+                    }
+                    else
+                    {
+                        return PVMFErrNotSupported;
+                    }
+                }
+                else
+                {
+                    return PVMFErrNotSupported;
+                }
+            }
+        }
+    }
+
+    // For all other parameters return a default success
+
     return PVMFSuccess;
 }
 
@@ -1647,7 +1913,7 @@
 //
 // For active timing support
 //
-OSCL_EXPORT_REF PVMFStatus PVRefFileOutputActiveTimingSupport::SetClock(OsclClock *clockVal)
+OSCL_EXPORT_REF PVMFStatus PVRefFileOutputActiveTimingSupport::SetClock(PVMFMediaClock *clockVal)
 {
     iClock = clockVal;
     return PVMFSuccess;
@@ -1710,9 +1976,10 @@
 
     if (iClock)
     {
-        uint64 clktime;
-        uint64 tbtime;
-        iClock->GetCurrentTime64(clktime, OSCLCLOCK_MSEC, tbtime);
+        uint32 clktime;
+        uint32 tbtime;
+        bool overflow = 0;
+        iClock->GetCurrentTime32(clktime, overflow, PVMF_MEDIA_CLOCK_MSEC, tbtime);
         {
             // always adjust clock if not in frame step mode
             // if in framestep mode, only adjust clock if the timestamp is ahead
@@ -1723,10 +1990,10 @@
                 {
                     iLogger = PVLogger::GetLoggerObject("PVRefFileOutput");
                 }
-                uint64 adjtime = aTs;
+                uint32 adjtime = aTs;
                 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                                 (0, "PVRefFileOutputActiveTimingSupport::AdjustClock: from %d to %d", (uint32)clktime, (uint32)adjtime));
-                iClock->AdjustClockTime64(clktime, tbtime, adjtime, OSCLCLOCK_MSEC);
+                iClock->AdjustClockTime32(clktime, tbtime, adjtime, PVMF_MEDIA_CLOCK_MSEC, overflow);
             }
         }
     }
@@ -1816,6 +2083,7 @@
         iCommandResponseQueue.erase(&iCommandResponseQueue[0]);
     }
 
+
     //send async write completion
     while (!iWriteResponseQueue.empty())
     {
@@ -1896,7 +2164,7 @@
     iAVIMainHeader.dwMicroSecPerFrame = 200000;
     iAVIMainHeader.dwMaxBytesPerSec    = 5 * 3 * width * height;
     iAVIMainHeader.dwPaddingGranularity = 0;
-    iAVIMainHeader.dwFlags = AVIF_TRUSTCKTYPE | AVIF_HASINDEX;
+    iAVIMainHeader.dwFlags = AVIF_TRUSTCKTYPE_FILE_OUT | AVIF_HASINDEX_FILE_OUT;
     iAVIMainHeader.dwTotalFrames = DEFAULT_COUNT;
     iAVIMainHeader.dwInitialFrames = 0;
     iAVIMainHeader.dwStreams = 1;
diff --git a/pvmi/pvmf/Android.mk b/pvmi/pvmf/Android.mk
index 8a2eeb9..6d41209 100644
--- a/pvmi/pvmf/Android.mk
+++ b/pvmi/pvmf/Android.mk
@@ -3,81 +3,88 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_format_type.cpp \
-	src/pvmf_pool_buffer_allocator.cpp \
-	src/pvmf_sync_util_data_queue.cpp \
-	src/pvmf_media_cmd.cpp \
-	src/pvmf_media_data.cpp \
-	src/pvmf_port_base_impl.cpp \
-	src/pvmf_timestamp.cpp \
-	src/pvmf_simple_media_buffer.cpp \
-	src/pvmi_config_and_capability_utils.cpp \
-	src/pvmf_node_interface.cpp \
-	src/pvmf_sync_util.cpp \
-	src/pvmf_basic_errorinfomessage.cpp \
-	src/pvmi_kvp_util.cpp \
-	src/pvmf_mempool.cpp \
-	src/pvmf_duration_infomessage.cpp
-
+ 	src/pvmf_pool_buffer_allocator.cpp \
+ 	src/pvmf_sync_util_data_queue.cpp \
+ 	src/pvmf_media_cmd.cpp \
+ 	src/pvmf_media_data.cpp \
+ 	src/pvmf_port_base_impl.cpp \
+ 	src/pvmf_timestamp.cpp \
+ 	src/pvmf_simple_media_buffer.cpp \
+ 	src/pvmi_config_and_capability_utils.cpp \
+ 	src/pvmf_node_interface.cpp \
+ 	src/pvmf_sync_util.cpp \
+ 	src/pvmf_basic_errorinfomessage.cpp \
+ 	src/pvmi_kvp_util.cpp \
+ 	src/pvmf_mempool.cpp \
+ 	src/pvmf_media_clock.cpp \
+ 	src/pvmf_duration_infomessage.cpp
 
 
 LOCAL_MODULE := libpvmf
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/pvmf/include \
-	$(PV_TOP)//pvmi/pvmf/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/pvmf/src \
+ 	$(PV_TOP)/pvmi/pvmf/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pv_interface.h \
-	include/pvmf_node_interface.h \
-	include/pvmi_config_and_capability.h \
-	include/pvmf_event_handling.h \
-	include/pvmf_node_utils.h \
-	include/pvmi_config_and_capability_observer.h \
-	include/pvmf_format_type.h \
-	include/pvmf_pool_buffer_allocator.h \
-	include/pvmf_media_msg_format_ids.h \
-	include/pvmf_media_cmd.h \
-	include/pvmf_port_base_impl.h \
-	include/pvmi_config_and_capability_utils.h \
-	include/pvmf_media_data.h \
-	include/pvmf_port_interface.h \
-	include/pvmi_kvp.h \
-	include/pvmf_media_data_impl.h \
-	include/pvmf_return_codes.h \
-	include/pvmi_media_io_observer.h \
-	include/pvmf_media_frag_group.h \
-	include/pvmf_simple_media_buffer.h \
-	include/pvmi_media_transfer.h \
-	include/pvmf_media_msg.h \
-	include/pvmf_sync_util_data_queue.h \
-	include/pvmi_mio_control.h \
-	include/pvmf_media_msg_header.h \
-	include/pvmf_sync_util.h \
-	include/pvmp4h263encextension.h \
-	include/pvmf_meta_data_types.h \
-	include/pvmf_timestamp.h \
-	include/pv_uuid.h \
-	include/pvmf_node_cmd_msg.h \
-	include/pvmf_video.h \
-	include/pvmf_basic_errorinfomessage.h \
-	include/pvmf_errorinfomessage_extension.h \
-	include/pvmi_media_io_clock_extension.h \
-	include/pvmf_fileformat_events.h \
-	include/pvmi_kvp_util.h \
-	include/pvmf_mempool.h \
-	include/pvmi_port_config_kvp.h \
-	include/pvmi_drm_kvp.h \
-	include/pvmi_data_stream_interface.h \
-	include/pvmi_datastreamuser_interface.h \
-	include/pvmf_resizable_simple_mediamsg.h \
-	include/pvmf_duration_infomessage.h \
-	include/pvmf_durationinfomessage_extension.h
+ 	include/pvmf_node_interface.h \
+ 	include/pvmi_config_and_capability.h \
+ 	include/pvmf_event_handling.h \
+ 	include/pvmf_node_utils.h \
+ 	include/pvmi_config_and_capability_observer.h \
+ 	include/pvmf_format_type.h \
+ 	include/pvmf_pool_buffer_allocator.h \
+ 	include/pvmf_media_msg_format_ids.h \
+ 	include/pvmf_media_cmd.h \
+ 	include/pvmf_port_base_impl.h \
+ 	include/pvmi_config_and_capability_utils.h \
+ 	include/pvmf_media_data.h \
+ 	include/pvmf_port_interface.h \
+ 	include/pvmi_kvp.h \
+ 	include/pvmf_media_data_impl.h \
+ 	include/pvmf_return_codes.h \
+ 	include/pvmi_media_io_observer.h \
+ 	include/pvmf_media_frag_group.h \
+ 	include/pvmf_simple_media_buffer.h \
+ 	include/pvmi_media_transfer.h \
+ 	include/pvmf_media_msg.h \
+ 	include/pvmf_sync_util_data_queue.h \
+ 	include/pvmi_mio_control.h \
+ 	include/pvmf_media_msg_header.h \
+ 	include/pvmf_sync_util.h \
+ 	include/pvmf_meta_data_types.h \
+ 	include/pvmf_timestamp.h \
+ 	include/pv_uuid.h \
+ 	include/pvmf_node_cmd_msg.h \
+ 	include/pvmf_video.h \
+ 	include/pvmf_basic_errorinfomessage.h \
+ 	include/pvmf_errorinfomessage_extension.h \
+ 	include/pvmi_media_io_clock_extension.h \
+ 	include/pvmf_fileformat_events.h \
+ 	include/pvmi_kvp_util.h \
+ 	include/pvmf_mempool.h \
+ 	include/pvmi_port_config_kvp.h \
+ 	include/pvmi_drm_kvp.h \
+ 	include/pvmi_data_stream_interface.h \
+ 	include/pvmi_datastreamuser_interface.h \
+ 	include/pvmf_resizable_simple_mediamsg.h \
+ 	include/pvmf_media_clock.h \
+ 	include/pvmf_duration_infomessage.h \
+ 	include/pvmf_durationinfomessage_extension.h \
+ 	include/pvmf_counted_ptr.h \
+ 	include/pvmi_fileio_kvp.h \
+ 	include/pvmf_timedtext.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/pvmf/build/make/local.mk b/pvmi/pvmf/build/make/local.mk
new file mode 100644
index 0000000..7897454
--- /dev/null
+++ b/pvmi/pvmf/build/make/local.mk
@@ -0,0 +1,78 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmf
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_format_type.cpp \
+	pvmf_pool_buffer_allocator.cpp \
+	pvmf_sync_util_data_queue.cpp \
+	pvmf_media_cmd.cpp \
+	pvmf_media_data.cpp \
+	pvmf_port_base_impl.cpp \
+	pvmf_timestamp.cpp \
+	pvmf_simple_media_buffer.cpp \
+	pvmi_config_and_capability_utils.cpp \
+	pvmf_node_interface.cpp \
+	pvmf_sync_util.cpp \
+	pvmf_basic_errorinfomessage.cpp \
+	pvmi_kvp_util.cpp \
+	pvmf_mempool.cpp \
+	pvmf_media_clock.cpp \
+	pvmf_duration_infomessage.cpp
+
+HDRS :=  pv_interface.h \
+         pvmf_node_interface.h \
+         pvmi_config_and_capability.h \
+         pvmf_event_handling.h \
+         pvmf_node_utils.h \
+         pvmi_config_and_capability_observer.h \
+         pvmf_format_type.h \
+         pvmf_pool_buffer_allocator.h \
+         pvmf_media_msg_format_ids.h \
+         pvmf_media_cmd.h \
+         pvmf_port_base_impl.h \
+         pvmi_config_and_capability_utils.h \
+         pvmf_media_data.h \
+         pvmf_port_interface.h \
+         pvmi_kvp.h \
+         pvmf_media_data_impl.h \
+         pvmf_return_codes.h \
+         pvmi_media_io_observer.h \
+         pvmf_media_frag_group.h \
+         pvmf_simple_media_buffer.h \
+         pvmi_media_transfer.h \
+         pvmf_media_msg.h \
+         pvmf_sync_util_data_queue.h \
+         pvmi_mio_control.h \
+         pvmf_media_msg_header.h \
+         pvmf_sync_util.h \
+         pvmf_meta_data_types.h \
+         pvmf_timestamp.h \
+         pv_uuid.h \
+         pvmf_node_cmd_msg.h \
+         pvmf_video.h \
+         pvmf_basic_errorinfomessage.h \
+         pvmf_errorinfomessage_extension.h \
+         pvmi_media_io_clock_extension.h \
+         pvmf_fileformat_events.h \
+         pvmi_kvp_util.h \
+         pvmf_mempool.h \
+         pvmi_port_config_kvp.h \
+         pvmi_drm_kvp.h \
+         pvmi_data_stream_interface.h \
+         pvmi_datastreamuser_interface.h \
+         pvmf_resizable_simple_mediamsg.h \
+         pvmf_media_clock.h \
+         pvmf_duration_infomessage.h \
+         pvmf_durationinfomessage_extension.h \
+         pvmf_counted_ptr.h \
+         pvmi_fileio_kvp.h  \
+         pvmf_timedtext.h
+
+include $(MK)/library.mk
diff --git a/pvmi/pvmf/build/make/makefile b/pvmi/pvmf/build/make/makefile
deleted file mode 100644
index fc8c75f..0000000
--- a/pvmi/pvmf/build/make/makefile
+++ /dev/null
@@ -1,118 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmf
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_format_type.cpp \
-	pvmf_pool_buffer_allocator.cpp \
-	pvmf_sync_util_data_queue.cpp \
-	pvmf_media_cmd.cpp \
-	pvmf_media_data.cpp \
-	pvmf_port_base_impl.cpp \
-	pvmf_timestamp.cpp \
-	pvmf_simple_media_buffer.cpp \
-	pvmi_config_and_capability_utils.cpp \
-	pvmf_node_interface.cpp \
-	pvmf_sync_util.cpp \
-	pvmf_basic_errorinfomessage.cpp \
-	pvmi_kvp_util.cpp \
-	pvmf_mempool.cpp \
-	pvmf_duration_infomessage.cpp
-
-HDRS =  pv_interface.h \
-	pvmf_node_interface.h \
-	pvmi_config_and_capability.h \
-	pvmf_event_handling.h \
-	pvmf_node_utils.h \
-	pvmi_config_and_capability_observer.h \
-	pvmf_format_type.h \
-	pvmf_pool_buffer_allocator.h \
-	pvmf_media_msg_format_ids.h \
-	pvmf_media_cmd.h \
-	pvmf_port_base_impl.h \
-	pvmi_config_and_capability_utils.h \
-	pvmf_media_data.h \
-	pvmf_port_interface.h \
-	pvmi_kvp.h \
-	pvmf_media_data_impl.h \
-	pvmf_return_codes.h \
-	pvmi_media_io_observer.h \
-	pvmf_media_frag_group.h \
-	pvmf_simple_media_buffer.h \
-	pvmi_media_transfer.h \
-	pvmf_media_msg.h \
-	pvmf_sync_util_data_queue.h \
-	pvmi_mio_control.h \
-	pvmf_media_msg_header.h \
-	pvmf_sync_util.h \
-	pvmp4h263encextension.h \
-	pvmf_meta_data_types.h \
-	pvmf_timestamp.h \
-	pv_uuid.h \
-	pvmf_node_cmd_msg.h \
-	pvmf_video.h \
-	pvmf_basic_errorinfomessage.h \
-	pvmf_errorinfomessage_extension.h \
-	pvmi_media_io_clock_extension.h \
-	pvmf_fileformat_events.h \
-	pvmi_kvp_util.h \
-	pvmf_mempool.h \
-	pvmi_port_config_kvp.h \
-	pvmi_drm_kvp.h \
-	pvmi_data_stream_interface.h \
-	pvmi_datastreamuser_interface.h \
-	pvmf_resizable_simple_mediamsg.h \
-	pvmf_duration_infomessage.h \
-	pvmf_durationinfomessage_extension.h
-ifeq ($(PACKETSOURCE),1)
-HDRS += pvmf_rtp_packet_source.h
-endif
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/pvmi/pvmf/include/pv_interface.h b/pvmi/pvmf/include/pv_interface.h
index 2db938d..27c5982 100644
--- a/pvmi/pvmf/include/pv_interface.h
+++ b/pvmi/pvmf/include/pv_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pv_uuid.h b/pvmi/pvmf/include/pv_uuid.h
index 21b7aa4..62cb2f6 100644
--- a/pvmi/pvmf/include/pv_uuid.h
+++ b/pvmi/pvmf/include/pv_uuid.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_basic_errorinfomessage.h b/pvmi/pvmf/include/pvmf_basic_errorinfomessage.h
index e4daa84..1778f69 100644
--- a/pvmi/pvmf/include/pvmf_basic_errorinfomessage.h
+++ b/pvmi/pvmf/include/pvmf_basic_errorinfomessage.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_counted_ptr.h b/pvmi/pvmf/include/pvmf_counted_ptr.h
new file mode 100644
index 0000000..15477eb
--- /dev/null
+++ b/pvmi/pvmf/include/pvmf_counted_ptr.h
@@ -0,0 +1,186 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMF_COUNTED_PTR_H_INCLUDED
+#define PVMF_COUNTED_PTR_H_INCLUDED
+
+
+#ifndef   OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef   OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+#ifndef   OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
+
+template <class T>
+class PVMFReferenceCounter : public OsclRefCounter
+{
+    public:
+        //This is the surrogate constructor.
+        //It allocates the ReferenceCounter from it's own pool
+        //so it can manage the deallocation later, when the time is right.
+        static PVMFReferenceCounter<T>* create(void)
+        {
+            //Check if the memory pools need to be setup.
+            if (!poolrc)
+            {
+                rcPool = OSCL_NEW
+                         (
+                             OsclMemPoolFixedChunkAllocator,
+                             (
+                                 poolDepth/*chunks*/
+                                 , sizeof(PVMFReferenceCounter<T>)/*chunk size*/
+                                 , NULL/*allocator*/
+                             )
+                         );
+                tPool = OSCL_NEW
+                        (
+                            OsclMemPoolFixedChunkAllocator,
+                            (
+                                poolDepth/*chunks*/
+                                , sizeof(T)/*chunk size*/
+                                , NULL/*allocator*/
+                            )
+                        );
+            }
+            //Increment the pool's ref counter each time we allocate from it.
+            poolrc++;
+
+            //Allocate the template object from the pool.
+            T* thisObj = OSCL_STATIC_CAST(T*, tPool->allocate(sizeof(T)));
+            //Construct the object in place using it's default constructor.
+            thisObj = OSCL_PLACEMENT_NEW(thisObj, T());
+
+            //Allocate "this" ReferenceCounter from the pool.
+            PVMFReferenceCounter<T>* thisRC =
+                OSCL_STATIC_CAST(PVMFReferenceCounter<T>*,
+                                 rcPool->allocate(sizeof(PVMFReferenceCounter<T>)));
+            //Construct the ReferenceCounter in place.
+            thisRC = OSCL_PLACEMENT_NEW(thisRC, PVMFReferenceCounter<T>(thisObj));
+
+            return thisRC;
+        }
+
+        virtual void addRef()
+        {
+            rc++;
+        }
+
+        virtual void removeRef()
+        {
+            rc--;
+            if (!rc)
+            {
+                obj->~T();
+                tPool->deallocate(obj);
+                rcPool->deallocate(this);
+                poolrc--;
+                if (!poolrc)
+                {
+                    OSCL_DELETE(rcPool);
+                    OSCL_DELETE(tPool);
+                }
+            }
+        }
+
+        virtual uint32 getCount()
+        {
+            return rc;
+        }
+
+        //The actual reference count.
+        uint32   rc;
+
+        //The object to which were are counting references.
+        T*       obj;
+
+    private:
+        //These are the memory pools from which the reference counter
+        //and template object are instantiated.  These are fixed-chunk
+        //allocators to optimize allocation speed.
+        static OsclMemPoolFixedChunkAllocator* rcPool;
+        static OsclMemPoolFixedChunkAllocator* tPool;
+
+        //This is the reference counter for the memory pools so we know when to free them.
+        static uint32                          poolrc;
+
+        //This is the size of the memory pool in whole-unit allocations.
+        static uint32                          poolDepth;
+
+        //The default constructor is private to prevent accidentally
+        //allocating one incorrectly.  The proper way to allocate a
+        //ReferenceCounter is to call the "create" method AFTER initializing
+        //the OSCL memory subsystem.
+        PVMFReferenceCounter(T* aObj = NULL)
+                : rc(1)
+                , obj(aObj)
+        {
+        }
+};
+
+
+/**
+ *@note: Because CounterPtr creates a ReferenceCounter,
+ * you cannot instantiate a CounterPtr before calling OsclMem::Init().
+ */
+template <class T>
+class PVMFCountedPtr
+{
+    public:
+        PVMFReferenceCounter<T>* cnt;
+
+        PVMFCountedPtr(void)
+        {
+            cnt = PVMFReferenceCounter<T>::create();
+        }
+
+        ~PVMFCountedPtr()
+        {
+            cnt->removeRef();
+        }
+
+        PVMFCountedPtr<T>& operator=(const PVMFCountedPtr<T>& r)
+        {
+            //Order of statements is important.
+            //Must add ref first in case r==this.
+            r.cnt->addRef();
+            //Detach the old ref counter.
+            cnt->removeRef();
+            //Attach the new ref counter.
+            cnt = r.cnt;
+            return *this;
+        }
+
+        inline T& operator*() const
+        {
+            return *(cnt->obj);
+        }
+
+        inline T* operator->() const
+        {
+            return cnt->obj;
+        }
+};
+
+
+#endif //PVMF_COUNTED_PTR_H_INCLUDED
+
+
diff --git a/pvmi/pvmf/include/pvmf_duration_infomessage.h b/pvmi/pvmf/include/pvmf_duration_infomessage.h
index 3e48dd1..22374ad 100644
--- a/pvmi/pvmf/include/pvmf_duration_infomessage.h
+++ b/pvmi/pvmf/include/pvmf_duration_infomessage.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_durationinfomessage_extension.h b/pvmi/pvmf/include/pvmf_durationinfomessage_extension.h
index c813c46..f129848 100644
--- a/pvmi/pvmf/include/pvmf_durationinfomessage_extension.h
+++ b/pvmi/pvmf/include/pvmf_durationinfomessage_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_errorinfomessage_extension.h b/pvmi/pvmf/include/pvmf_errorinfomessage_extension.h
index 8ba03cc..c71f4d3 100644
--- a/pvmi/pvmf/include/pvmf_errorinfomessage_extension.h
+++ b/pvmi/pvmf/include/pvmf_errorinfomessage_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_event_handling.h b/pvmi/pvmf/include/pvmf_event_handling.h
index 8ec0cb9..1abcd06 100644
--- a/pvmi/pvmf/include/pvmf_event_handling.h
+++ b/pvmi/pvmf/include/pvmf_event_handling.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,6 +100,8 @@
                 iEventExtInterface(NULL),
                 iEventData(aEventData)
         {
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         /**
@@ -115,6 +117,8 @@
                 iEventExtInterface(aEventExtInterface),
                 iEventData(NULL)
         {
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         /**
@@ -131,6 +135,8 @@
                 iEventExtInterface(aEventExtInterface),
                 iEventData(aEventData)
         {
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         virtual ~PVMFCmdResp() {}
@@ -179,6 +185,51 @@
         }
 
         /**
+         * This method is going to be deprecated soon. We intend to remove
+         * the opaque event data and use PVInterface pointer if needed to
+         * retrieve more information regarding command completion.Therefore,
+         * with the removal of event data, setting length of event data wont be of any significance either.
+         *
+         * @param1 - (uint32) length of event data in bytes.
+         * @return PVMFSuccess, if length of event data can be set.
+                   PVMFFailure, if length of event data can't be set.
+         */
+        PVMFStatus SetEventDataLen(uint32 aEventDataLength)
+        {
+            PVMFStatus status = PVMFFailure;
+            if (iEventData)
+            {
+                iEventDataLengthAvailable = true;
+                iEventDataLength = aEventDataLength;
+                status = PVMFSuccess;
+            }
+            return status;
+        }
+
+        /**
+         * This method is going to be deprecated soon. We intend to remove
+         * the opaque event data and use PVInterface pointer if needed to
+         * retrieve more information regarding command completion.Therefore,
+         * with the removal of event data, length if event data wont be needed either.
+         *
+         * @param1 - bool& aEventDataLenAvailable
+         *			 false - length of event data(in bytes) is not available
+         *			 true - length of event data(in bytes) is available
+         * @param2 - uint32& aEventDataLength
+         *			 length of eventdata in bytes
+         */
+        void GetEventDataLen(bool& aEventDataLenAvailable, uint32& aEventDataLength)const
+        {
+            aEventDataLenAvailable = false;
+            aEventDataLength = 0;
+            if (iEventDataLengthAvailable)
+            {
+                aEventDataLenAvailable = true;
+                aEventDataLength = iEventDataLength;
+            }
+        }
+
+        /**
          * @return Returns the eventinfointerface
          */
         PVInterface* GetEventExtensionInterface() const
@@ -196,6 +247,8 @@
          * soon.
          */
         OsclAny* iEventData;
+        bool iEventDataLengthAvailable;
+        uint32 iEventDataLength;
 };
 
 
@@ -225,6 +278,8 @@
             {
                 iLocalBuffer[i] = 0;
             }
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         PVMFAsyncEvent(PVMFEventCategory aEventCategory,
@@ -253,6 +308,8 @@
                     iLocalBuffer[i] = aLocalBuffer[i];
                 }
             }
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         PVMFAsyncEvent(PVMFEventCategory aEventCategory,
@@ -271,6 +328,8 @@
             {
                 iLocalBuffer[i] = 0;
             }
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         PVMFAsyncEvent(PVMFEventCategory aEventCategory,
@@ -300,6 +359,8 @@
                     iLocalBuffer[i] = aLocalBuffer[i];
                 }
             }
+            iEventDataLengthAvailable = false;
+            iEventDataLength = 0;
         }
 
         virtual ~PVMFAsyncEvent() {}
@@ -333,6 +394,51 @@
         }
 
         /**
+         * This method is going to be deprecated soon. We intend to remove
+         * the opaque event data and use PVInterface pointer if needed to
+         * retrieve more information regarding command completion.Therefore,
+         * with the removal of event data, setting length of event data wont be of any significance either.
+         *
+         * @param1 - (uint32) length of event data in bytes.
+         * @return PVMFSuccess, if length of event data can be set.
+                   PVMFFailure, if length of event data can't be set.
+         */
+        PVMFStatus SetEventDataLen(uint32 aEventDataLength)
+        {
+            PVMFStatus status = PVMFFailure;
+            if (iEventData)
+            {
+                iEventDataLengthAvailable = true;
+                iEventDataLength = aEventDataLength;
+                status = PVMFSuccess;
+            }
+            return status;
+        }
+
+        /**
+         * This method is going to be deprecated soon. We intend to remove
+         * the opaque event data and use PVInterface pointer if needed to
+         * retrieve more information regarding command completion.Therefore,
+         * with the removal of event data, length if event data wont be needed either.
+         *
+         * @param1 - bool& aEventDataLenAvailable
+         *			 false - length of event data(in bytes) is not available
+         *			 true - length of event data(in bytes) is available
+         * @param2 - uint32& aEventDataLength
+         *			 length of eventdata in bytes
+         */
+        void GetEventDataLen(bool& aEventDataLenAvailable, uint32& aEventDataLength)const
+        {
+            aEventDataLenAvailable = false;
+            aEventDataLength = 0;
+            if (iEventDataLengthAvailable)
+            {
+                aEventDataLenAvailable = true;
+                aEventDataLength = iEventDataLength;
+            }
+        }
+
+        /**
          * @return Returns the size of the local data asociated with the event.
          */
         int32 GetLocalBufferSize() const
@@ -376,6 +482,8 @@
          * soon.
          */
         OsclAny* iEventData;
+        bool iEventDataLengthAvailable;
+        uint32 iEventDataLength;
 };
 
 #endif // PVMF_EVENT_HANDLING_H_INCLUDED
diff --git a/pvmi/pvmf/include/pvmf_fileformat_events.h b/pvmi/pvmf/include/pvmf_fileformat_events.h
index 19b374c..91c18f9 100644
--- a/pvmi/pvmf/include/pvmf_fileformat_events.h
+++ b/pvmi/pvmf/include/pvmf_fileformat_events.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_format_type.h b/pvmi/pvmf/include/pvmf_format_type.h
index b1f63c8..ee3af8b 100644
--- a/pvmi/pvmf/include/pvmf_format_type.h
+++ b/pvmi/pvmf/include/pvmf_format_type.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,37 +34,21 @@
 #include "oscl_string.h"
 #endif
 
+#ifndef OSCL_STR_PTR_LEN_H_INCLUDED
+#include "oscl_str_ptr_len.h"
+#endif
+
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+
 /** PvmfMimeString is used in several PVMF APIs */
 typedef OSCL_String PvmfMimeString;
 #endif
 
-/** PvmfMediaTypeIndex refers to one of the high-level format types*/
-typedef uint32 PvmfMediaTypeIndex;
-
-/** PvmfFormatIndex refers to one of the recognized formats*/
-typedef uint32 PvmfFormatIndex;
-
-/** PVMFFormatType maps to PvmfFormatIndex*/
-typedef PvmfFormatIndex PVMFFormatType;
-
-
-#define PVMF_FORMAT_UNKNOWN 0x00000000
-
 // MIME string for unknown format
 #define PVMF_MIME_FORMAT_UNKNOWN	"FORMATUNKNOWN"
 
-/** The high level format types **/
-#define PVMF_UNCOMPRESSED_AUDIO_FORMAT 0x1
-#define PVMF_UNCOMPRESSED_VIDEO_FORMAT 0x2
-#define PVMF_COMPRESSED_AUDIO_FORMAT 0x4
-#define PVMF_COMPRESSED_VIDEO_FORMAT 0x8
-#define PVMF_IMAGE_FORMAT 0x10
-#define PVMF_MULTIPLEXED_FORMAT 0x20
-#define PVMF_DATASTREAM_FORMAT 0x40
-#define PVMF_USERINPUT_FORMAT 0x80
-#define PVMF_DATA_SOURCE_FORMAT 0x100
-#define PVMF_TEXT_FORMAT 0x200
-
 /**
 ** Note on format MIME strings:
 ** The MIME strings that start with "X" were made up by PV.
@@ -76,18 +60,6 @@
 
 /* Following are the recognized formats  */
 
-// Uncompressed audio formats
-#define PVMF_FIRST_UNCOMPRESSED_AUDIO	1
-#define PVMF_PCM						PVMF_FIRST_UNCOMPRESSED_AUDIO  /* this refers to general PCM support */
-#define PVMF_PCM8						PVMF_FIRST_UNCOMPRESSED_AUDIO+1
-#define PVMF_PCM16						PVMF_FIRST_UNCOMPRESSED_AUDIO+2
-#define PVMF_PCM16_BE					PVMF_FIRST_UNCOMPRESSED_AUDIO+3
-#define PVMF_PCM_ULAW					PVMF_FIRST_UNCOMPRESSED_AUDIO+4
-#define PVMF_PCM_ALAW					PVMF_FIRST_UNCOMPRESSED_AUDIO+5
-//When adding types to this range, please update the following
-//value to equal the last defined format.
-#define PVMF_LAST_UNCOMPRESSED_AUDIO	PVMF_FIRST_UNCOMPRESSED_AUDIO+5
-
 // MIME strings for uncompressed audio formats
 #define PVMF_MIME_PCM   	"X-PCM-GEN"
 #define PVMF_MIME_PCM8		"audio/L8"
@@ -96,29 +68,6 @@
 #define PVMF_MIME_ULAW		"audio/PCMU"
 #define PVMF_MIME_ALAW		"audio/PCMA"
 
-
-// Uncompressed video formats
-#define PVMF_FIRST_UNCOMPRESSED_VIDEO	200
-#define PVMF_YUV420						PVMF_FIRST_UNCOMPRESSED_VIDEO
-#define PVMF_YUV422						PVMF_FIRST_UNCOMPRESSED_VIDEO+1
-#define PVMF_RGB8						PVMF_FIRST_UNCOMPRESSED_VIDEO+2
-#define PVMF_RGB12						PVMF_FIRST_UNCOMPRESSED_VIDEO+3
-#define PVMF_RGB16						PVMF_FIRST_UNCOMPRESSED_VIDEO+4
-#define PVMF_RGB24						PVMF_FIRST_UNCOMPRESSED_VIDEO+5
-#define PVMF_YUV420_PLANAR				PVMF_FIRST_UNCOMPRESSED_VIDEO+6
-#define PVMF_YUV420_PACKEDPLANAR		PVMF_FIRST_UNCOMPRESSED_VIDEO+7
-#define PVMF_YUV420_SEMIPLANAR			PVMF_FIRST_UNCOMPRESSED_VIDEO+8
-#define PVMF_YUV420_PACKEDSEMIPLANAR	PVMF_FIRST_UNCOMPRESSED_VIDEO+9
-#define PVMF_YUV420_SEMIPLANAR_YVU	    PVMF_FIRST_UNCOMPRESSED_VIDEO+10
-#define PVMF_YUV422_PLANAR				PVMF_FIRST_UNCOMPRESSED_VIDEO+11
-#define PVMF_YUV422_PACKEDPLANAR		PVMF_FIRST_UNCOMPRESSED_VIDEO+12
-#define PVMF_YUV422_SEMIPLANAR			PVMF_FIRST_UNCOMPRESSED_VIDEO+13
-#define PVMF_YUV422_PACKEDSEMIPLANAR	PVMF_FIRST_UNCOMPRESSED_VIDEO+14
-//When adding types to this range, please update the following
-//value to equal the last defined format.
-#define PVMF_LAST_UNCOMPRESSED_VIDEO	PVMF_FIRST_UNCOMPRESSED_VIDEO+14
-
-
 // MIME strings for uncompressed video formats
 #define PVMF_MIME_YUV420	"X-YUV-420"
 #define PVMF_MIME_YUV422	"X-YUV-422"
@@ -127,73 +76,42 @@
 #define PVMF_MIME_RGB16		"X-RGB-16"
 #define PVMF_MIME_RGB24		"X-RGB-24"
 
-// Compressed audio formats
-#define PVMF_FIRST_COMPRESSED_AUDIO		400
-#define PVMF_AMR_IETF					PVMF_FIRST_COMPRESSED_AUDIO
-#define PVMF_AMR_IF2					PVMF_FIRST_COMPRESSED_AUDIO+1
-#define PVMF_EVRC						PVMF_FIRST_COMPRESSED_AUDIO+2
-#define PVMF_G726						PVMF_FIRST_COMPRESSED_AUDIO+3
-#define PVMF_G723						PVMF_FIRST_COMPRESSED_AUDIO+4
-#define PVMF_MP3						PVMF_FIRST_COMPRESSED_AUDIO+5
-#define PVMF_ADIF						PVMF_FIRST_COMPRESSED_AUDIO+6
-#define PVMF_ADTS						PVMF_FIRST_COMPRESSED_AUDIO+7
-#define PVMF_LATM						PVMF_FIRST_COMPRESSED_AUDIO+8
-#define PVMF_MPEG4_AUDIO				PVMF_FIRST_COMPRESSED_AUDIO+9
-#define PVMF_AMR_ETS                    PVMF_FIRST_COMPRESSED_AUDIO+10
-#define PVMF_AMR_IETF_COMBINED          PVMF_FIRST_COMPRESSED_AUDIO+11
-#define PVMF_AMRWB_IETF_PAYLOAD			PVMF_FIRST_COMPRESSED_AUDIO+12
-#define PVMF_WMA                        PVMF_FIRST_COMPRESSED_AUDIO+13
-#define PVMF_ASF_AMR                    PVMF_FIRST_COMPRESSED_AUDIO+14
-#define PVMF_REAL_AUDIO                 PVMF_FIRST_COMPRESSED_AUDIO+15
-#define PVMF_AMRWB_IETF					PVMF_FIRST_COMPRESSED_AUDIO+16
-#define PVMF_ASF_MPEG4_AUDIO			PVMF_FIRST_COMPRESSED_AUDIO+17
-#define PVMF_AAC_SIZEHDR				PVMF_FIRST_COMPRESSED_AUDIO+18
-//When adding types to this range, please update the following
-//value to equal the last defined format.
-#define PVMF_LAST_COMPRESSED_AUDIO		PVMF_FIRST_COMPRESSED_AUDIO+18
+// MIME strings for uncompressed sub-video formats
+#define PVMF_MIME_YUV420_PLANAR				"X-YUV-420-PLANAR"
+#define PVMF_MIME_YUV420_PACKEDPLANAR		"X-YUV-420-PACKEDPLANAR"
+#define PVMF_MIME_YUV420_SEMIPLANAR			"X-YUV-420-SEMIPLANAR"
+#define PVMF_MIME_YUV420_PACKEDSEMIPLANAR	"X-YUV-420-PACKEDSEMIPLANAR"
+#define PVMF_MIME_YUV422_PLANAR				"X-YUV-422-PLANAR"
+#define PVMF_MIME_YUV422_PACKEDPLANAR		"X-YUV-422-PACKEDPLANAR"
+#define PVMF_MIME_YUV422_SEMIPLANAR			"X-YUV-422-SEMIPLANAR"
+#define PVMF_MIME_YUV422_PACKEDSEMIPLANAR	"X-YUV-422-PACKEDSEMIPLANAR"
+#define PVMF_MIME_YUV420_SEMIPLANAR_YVU		"X-YUV-420-SEMIPLANAR-YUV"
 
 // MIME strings for compressed audio formats
-#define PVMF_MIME_AMR		 "audio/AMR" // Streaming AMR format, aka IETF_COMBINED_TOC
-#define PVMF_MIME_AMRWB		 "audio/AMR-WB" // AMR Wide Band
-#define PVMF_MIME_AMR_IETF	 "X-AMR-IETF-SEPARATE" // Today's IETF
-#define PVMF_MIME_AMRWB_IETF "X-AMRWB-IETF-SEPARATE" // Today's IETF
-#define PVMF_MIME_AMR_IF2	 "X-AMR-IF2"
-#define PVMF_MIME_EVRC		 "audio/EVRC" // Streaming EVRC format
-#define PVMF_MIME_MP3		 "audio/MPEG"
-#define PVMF_MIME_ADIF		 "X-AAC-ADIF" //.aac file format
-#define PVMF_MIME_ADTS		 "X-AAC-ADTS" //.aac file format
-#define PVMF_MIME_LATM		 "audio/MP4A-LATM" // Streaming AAC format
-#define PVMF_MIME_MPEG4_AUDIO "X-MPEG4-AUDIO"// MPEG4 Audio (AAC) as stored in MPEG4 File
+#define PVMF_MIME_AMR			"audio/AMR" // Streaming AMR format, aka IETF_COMBINED_TOC
+#define PVMF_MIME_AMRWB			"audio/AMR-WB" // AMR Wide Band
+#define PVMF_MIME_AMR_IETF		"X-AMR-IETF-SEPARATE" // Today's IETF
+#define PVMF_MIME_AMRWB_IETF	"X-AMRWB-IETF-SEPARATE" // Today's IETF
+#define PVMF_MIME_AMR_IF2		"X-AMR-IF2"
+#define PVMF_MIME_EVRC			"audio/EVRC" // Streaming EVRC format
+#define PVMF_MIME_MP3			"audio/MPEG"
+#define PVMF_MIME_ADIF			"X-AAC-ADIF" //.aac file format
+#define PVMF_MIME_ADTS			"X-AAC-ADTS" //.aac file format
+#define PVMF_MIME_AAC_SIZEHDR	"X-AAC-SIZEHDR"
+#define PVMF_MIME_LATM			"audio/MP4A-LATM" // Streaming AAC format
+#define PVMF_MIME_MPEG4_AUDIO	"X-MPEG4-AUDIO"// MPEG4 Audio (AAC) as stored in MPEG4 File
 #define PVMF_MIME_G723          "audio/G723"
-#define PVMF_MIME_G726       "x-pvmf/audio/g726"
+#define PVMF_MIME_G726			"x-pvmf/audio/g726"
 //WMA Audio
-#define PVMF_MIME_WMA        "audio/x-ms-wma"
+#define PVMF_MIME_WMA			"audio/x-ms-wma"
 // AMR Audio from a asf file
-#define PVMF_MIME_ASF_AMR   "x-pvmf/audio/asf-amr"
+#define PVMF_MIME_ASF_AMR		"x-pvmf/audio/asf-amr"
 // real audio
-#define PVMF_MIME_REAL_AUDIO "audio/vnd.rn-realaudio"
+#define PVMF_MIME_REAL_AUDIO	"audio/vnd.rn-realaudio"
 // MPEG4 Audio from a asf file
 #define PVMF_MIME_ASF_MPEG4_AUDIO   "x-pvmf/audio/asf-mpeg4-audio"
 #define PVMF_MIME_3640		 "audio/mpeg4-generic" // Streaming AAC format
 
-// Compressed video formats
-#define PVMF_FIRST_COMPRESSED_VIDEO		600
-#define PVMF_M4V						PVMF_FIRST_COMPRESSED_VIDEO
-#define PVMF_H263						PVMF_FIRST_COMPRESSED_VIDEO+1
-//Raw 264 files (.264 - stored as per byte stream format)
-#define PVMF_H264_RAW					PVMF_FIRST_COMPRESSED_VIDEO+2
-//H264 tracks as stored in MP4/3GP files
-#define PVMF_H264_MP4                   PVMF_FIRST_COMPRESSED_VIDEO+3
-//H263 streamed as per RFC 3984
-#define PVMF_H264                       PVMF_FIRST_COMPRESSED_VIDEO+4
-// WMV7, WMV8, WMV9
-#define PVMF_WMV                        PVMF_FIRST_COMPRESSED_VIDEO+5
-// RV8, RV9
-#define PVMF_RV							PVMF_FIRST_COMPRESSED_VIDEO+6
-//When adding types to this range, please update the following
-//value to equal the last defined format.
-#define PVMF_LAST_COMPRESSED_VIDEO		PVMF_FIRST_COMPRESSED_VIDEO+6
-
 // MIME strings for Compressed video formats
 #define PVMF_MIME_M4V		"video/MP4V-ES"// MPEG4 Video
 #define PVMF_MIME_H2631998	"video/H263-1998"
@@ -209,30 +127,9 @@
 // RV8, RV0
 #define PVMF_MIME_REAL_VIDEO		  "video/vnd.rn-realvideo"
 
-// Still image formats
-#define PVMF_FIRST_IMAGE				800
-#define PVMF_M4V_IMAGE					PVMF_FIRST_IMAGE
-#define PVMF_H263_IMAGE					PVMF_FIRST_IMAGE+1
-#define PVMF_LAST_IMAGE					999
-
 // MIME strings for still image formats
 #define PVMF_MIME_M4V_IMAGE	"X-M4V-IMAGE" // PV Proprietary Still Image
 
-// Multiplexed formats
-#define PVMF_FIRST_MULTIPLEXED			1000
-#define PVMF_MPEG4FF					PVMF_FIRST_MULTIPLEXED
-#define PVMF_H223						PVMF_FIRST_MULTIPLEXED+1
-#define PVMF_RTP						PVMF_FIRST_MULTIPLEXED+2
-#define PVMF_AMRFF						PVMF_FIRST_MULTIPLEXED+3
-#define PVMF_AACFF						PVMF_FIRST_MULTIPLEXED+4
-#define PVMF_MP3FF						PVMF_FIRST_MULTIPLEXED+5
-#define PVMF_WAVFF						PVMF_FIRST_MULTIPLEXED+6
-#define PVMF_ASFFF                      PVMF_FIRST_MULTIPLEXED+7
-#define PVMF_RMFF						PVMF_FIRST_MULTIPLEXED+8
-#define	PVMF_MIDIFF						PVMF_FIRST_MULTIPLEXED+9
-#define	PVMF_AVIFF						PVMF_FIRST_MULTIPLEXED+10
-#define PVMF_LAST_MULTIPLEXED			1199
-
 // MIME strings for Multiplexed formats and single-media file formats.
 #define PVMF_MIME_MPEG4FF		"video/MP4"
 #define PVMF_MIME_H223			"X-H223"
@@ -243,40 +140,13 @@
 #define PVMF_MIME_WAVFF			"X-WAV-FF"
 #define PVMF_MIME_ASFFF			"x-pvmf/mux/asf"
 #define PVMF_MIME_RMFF			"x-pvmf/mux/rm"
-
-// RAW data formats
-#define PVMF_FIRST_DATASTREAM           1200
-#define PVMF_8BIT_RAW                   1201
-#define PVMF_LAST_DATASTREAM            1299
+#define PVMF_MIME_DIVXFF		"x-pvmf/mux/divx"
+#define PVMF_MIME_MIDIFF		"application/x-midi"
+#define PVMF_MIME_AVIFF			"x-pvmf/mux/avi"
 
 // MIME strings for RAW data formats
 #define PVMF_MIME_8BIT_RAW   "X-RAW-8"
 
-// reserved for 2way
-#define PVMF_FIRST_USERINPUT_2WAY       1300
-#define PVMF_USERINPUT_BASIC_STRING     PVMF_FIRST_USERINPUT_2WAY
-#define PVMF_USERINPUT_IA5_STRING       PVMF_FIRST_USERINPUT_2WAY+1
-#define PVMF_USERINPUT_GENERAL_STRING   PVMF_FIRST_USERINPUT_2WAY+2
-#define PVMF_USERINPUT_DTMF             PVMF_FIRST_USERINPUT_2WAY+3
-#define PVMF_LAST_USERINPUT_2WAY        1309
-
-#define PVMF_INET_UDP					1400
-#define PVMF_INET_TCP					1401
-#define PVMF_RTSP						1402
-#define PVMF_RTCP                       1403
-
-// PVMF data source types
-#define PVMF_FIRST_DATA_SOURCETYPE              1500
-#define PVMF_DATA_SOURCE_RTSP_URL               1501
-#define PVMF_DATA_SOURCE_HTTP_URL               1502
-#define PVMF_DATA_SOURCE_SDP_FILE               1503
-#define PVMF_DATA_SOURCE_PVX_FILE               1504
-#define PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL  1505
-#define PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL 1506
-#define PVMF_DATA_SOURCE_RTP_PACKET_SOURCE      1507
-#define PVMF_DATA_SOURCE_UNKNOWN_URL            1508
-#define PVMF_LAST_DATA_SOURCETYPE               1599
-
 // MIME strings for PVMF data source types
 #define PVMF_MIME_DATA_SOURCE_RTSP_URL  "X-PVMF-DATA-SRC-RTSP-URL"
 #define PVMF_MIME_DATA_SOURCE_HTTP_URL  "X-PVMF-DATA-SRC-HTTP-URL"
@@ -284,34 +154,132 @@
 #define PVMF_MIME_DATA_SOURCE_PVX_FILE  "X-PVMF-DATA-SRC-PVX-FILE"
 #define PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL "X-PVMF-DATA-SRC-MS-HTTP-STREAMING-URL"
 #define PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL "X-PVMF-DATA-SRC-REAL-HTTP-CLOAKING-URL"
-#define PVMF_MIME_DATA_SOURCE_UNKNOWN_URL "X-PVMF-DATA-SRC-UNKNOWN-URL"
 #define PVMF_MIME_DATA_SOURCE_RTP_PACKET_SOURCE "X-PVMF-DATA-SRC-RTP-PACKET"
-
-// Text media data format
-#define PVMF_FIRST_TEXT					1600
-#define PVMF_3GPP_TIMEDTEXT				PVMF_FIRST_TEXT+1
-#define PVMF_LAST_TEXT					1799
+#define PVMF_MIME_DATA_SOURCE_UNKNOWN_URL "X-PVMF-DATA-SRC-UNKNOWN-URL"
 
 // MIME string for miscellaneous media data formats
 #define PVMF_MIME_3GPP_TIMEDTEXT		"video/3gpp-tt"
 
-#ifdef __cplusplus
-/* This routine returns the unique index of the format specified in the mime string,
-** or PVMF_UNKNOWN_FORMAT if not recognized.
-** aHint is an optional media type index to narrow the search.
-*/
-OSCL_IMPORT_REF PvmfFormatIndex GetFormatIndex(char* mime_string, PvmfMediaTypeIndex aHint = PVMF_FORMAT_UNKNOWN);
+// MIME string for protocol formats
+#define PVMF_MIME_INET_UDP				"X-PVMF-NET-INET-UDP"
+#define PVMF_MIME_INET_TCP				"X-PVMF-NET-INET-TCP"
+#define PVMF_MIME_RTSP					"X-PVMF-NET-INET-RTSP"
+#define PVMF_MIME_RTCP					"X-PVMF-NET-INET-RTCP"
 
-/* Returns the high level media type index of this format type,
-** or PVMF_UNKNOWN_FORMAT if not recognized
-*/
-OSCL_IMPORT_REF PvmfMediaTypeIndex GetMediaTypeIndex(PvmfFormatIndex aFormatIndex);
+// reserved for 2way
+#define PVMF_MIME_USERINPUT_BASIC_STRING	"x-pvmf/userinput/basic-string"
+#define PVMF_MIME_USERINPUT_IA5_STRING		"x-pvmf/userinput/ia5-string"
+#define PVMF_MIME_USERINPUT_GENERAL_STRING	"x-pvmf/userinput/general-string"
+#define PVMF_MIME_USERINPUT_DTMF			"x-pvmf/userinput/dtmf"
 
-/* This routine returns the mime string corresponding to the format index,
-** or an empty string if not recognized.
-*/
-OSCL_IMPORT_REF void GetFormatString(PvmfFormatIndex aFormatIndex, OSCL_String&str);
-#endif // __cplusplus
 
+class PVMFFormatType
+{
+    public:
+        // default constructor
+        PVMFFormatType() : iCompressed(false), iMimeStr(PVMF_MIME_FORMAT_UNKNOWN)
+        {}
+
+        PVMFFormatType(const char* mimeStrPtr, bool compressed = false)
+        {
+            iStr = OSCL_HeapString<OsclMemAllocator> (mimeStrPtr);
+            iMimeStr = iStr.get_cstr();
+            iCompressed = compressed;
+        }
+
+        PVMFFormatType(const char* mimeStrPtr, int32 mimeStrLen, bool compressed = false)
+        {
+            iStr = OSCL_HeapString<OsclMemAllocator> (mimeStrPtr, mimeStrLen);
+            iMimeStr.setPtrLen(iStr.get_cstr(), iStr.get_size());
+            iCompressed = compressed;
+        }
+
+        PVMFFormatType& operator=(const PVMFFormatType& rhs)
+        {
+            iStr = OSCL_HeapString<OsclMemAllocator> (rhs.getMIMEStrPtr(), rhs.getMIMEStrLen());
+            iMimeStr.setPtrLen(iStr.get_cstr(), iStr.get_size());
+            iCompressed = rhs.isCompressed();
+            return *this;
+        }
+
+        PVMFFormatType& operator=(const char* mimeStrPtr)
+        {
+            iStr = OSCL_HeapString<OsclMemAllocator> (mimeStrPtr);
+            iMimeStr = iStr.get_cstr();
+            return *this;
+        }
+
+        virtual ~PVMFFormatType() {};
+
+        // case insensitive comparision
+        c_bool operator==(const PVMFFormatType& rhs) const
+        {
+            return iMimeStr.isCIEquivalentTo(rhs.getStrCSumPtr());
+        }
+
+        bool operator!=(const PVMFFormatType& rhs) const
+        {
+            return !(*this == rhs);
+        }
+
+        void setCompressed(bool compressed = false)
+        {
+            iCompressed = compressed;
+        }
+
+        const char* getMIMEStrPtr() const
+        {
+            return iMimeStr.c_str();
+        }
+
+        int32 getMIMEStrLen() const
+        {
+            return iMimeStr.length();
+        }
+
+        const StrCSumPtrLen& getStrCSumPtr() const
+        {
+            return iMimeStr;
+        }
+
+        //return true if it is a compressed Media
+        OSCL_IMPORT_REF bool isCompressed() const;
+
+        //return true if a media type is IANA audio format or PV internal audio format.
+        OSCL_IMPORT_REF bool isAudio() const;
+
+        //return true if a media type is IANA video format or PV internal video format.
+        OSCL_IMPORT_REF bool isVideo() const;
+
+        //return true if a media type is image format or PV internal image format.
+        OSCL_IMPORT_REF bool isImage() const;
+
+        //return true if a media type is IANA text format.
+        OSCL_IMPORT_REF bool isText() const;
+
+        //return true if a media type is PV internal file format.
+        OSCL_IMPORT_REF bool isFile() const;
+
+        //return true if a media type is PV internal raw format.
+        OSCL_IMPORT_REF bool isRaw() const;
+
+        //return true if a media type is PV internal data source.
+        OSCL_IMPORT_REF bool isDataSource() const;
+
+        //return true if a media type is PV internal data source.
+        OSCL_IMPORT_REF bool isUserInput() const;
+
+        // a flag to indicate if a media type described by the MIME is compressed
+        // this value should be passed in because this class does not have the
+        // ability to determine if a given media type, especially a format from
+        // the third party???
+        bool								iCompressed;
+
+    protected:
+        // a local storage for MIME string
+        OSCL_HeapString<OsclMemAllocator>	iStr;
+        StrCSumPtrLen						iMimeStr;
+
+};
 
 #endif
diff --git a/pvmi/pvmf/include/pvmf_media_clock.h b/pvmi/pvmf/include/pvmf_media_clock.h
new file mode 100644
index 0000000..82751ba
--- /dev/null
+++ b/pvmi/pvmf/include/pvmf_media_clock.h
@@ -0,0 +1,1608 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/**
+ *  @file pvmf_media_clock.h
+ *  @brief Provides a time clock that can be paused and resumed,
+ *	  set the start time, adjusted based on outside source feedback,
+ *    and accepts user specified source for the free running clock.
+ *
+ */
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#define PVMF_MEDIA_CLOCK_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+
+#ifndef OSCL_TICKCOUNT_H_INCLUDED
+#include "oscl_tickcount.h"
+#endif
+
+#ifndef OSCL_INT64_UTILS_H_INCLUDED
+#include "oscl_int64_utils.h"
+#endif
+
+#ifndef OSCL_VECTOR_H_INCLUDED
+#include "oscl_vector.h"
+#endif
+
+#ifndef OSCL_MEM_H_INCLUDED
+#include "oscl_mem.h"
+#endif
+
+#ifndef PVMF_RETURN_CODES_H_INCLUDED
+#include "pvmf_return_codes.h"
+#endif
+
+#ifndef PVMF_TIMESTAMP_H_INCLUDED
+#include "pvmf_timestamp.h"
+#endif
+
+#ifndef OSCL_PRIQUEUE_H_INCLUDED
+#include "oscl_priqueue.h"
+#endif
+
+#ifndef OSCL_SCHEDULER_AO_H_INCLUDED
+#include "oscl_scheduler_ao.h"
+#endif
+
+#ifndef PV_INTERFACE_H_INCLUDED
+#include "pv_interface.h"
+#endif
+
+#ifndef TIME_COMPARISON_UTILS_H_INCLUDED
+#include "time_comparison_utils.h"
+#endif
+
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+
+#define MSECS_IN_30_MINS 0x1B7740
+
+
+#define PVMFMediaClockControlInterfaceUuid PVUuid(0xca20319a,0x33f9,0x484f,0x8d,0x1c,0xa5,0x1e,0x23,0x4c,0xe6,0x03)
+#define PVMFMediaClockAccessInterfaceUuid PVUuid(0xca20319a,0x33f9,0x484f,0x8d,0x1c,0xa5,0x1e,0x23,0x4c,0xe6,0x04)
+#define PVMFMediaClockNPTClockPositionAccessInterfaceUuid PVUuid(0xca20319a,0x33f9,0x484f,0x8d,0x1c,0xa5,0x1e,0x23,0x4c,0xe6,0x05)
+
+//playback rate unit is milli-percent of real time
+#define REALTIME_PLAYBACK_RATE 100000
+
+class PVMFMediaClock;
+
+
+/*
+ * Enum for the time units used in OSCL Media Clock
+ */
+enum PVMFMediaClock_TimeUnits
+{
+    PVMF_MEDIA_CLOCK_USEC   = 0,
+    PVMF_MEDIA_CLOCK_MSEC   = 1,
+    PVMF_MEDIA_CLOCK_SEC    = 2,
+    PVMF_MEDIA_CLOCK_MIN    = 3,
+    PVMF_MEDIA_CLOCK_HOUR   = 4,
+    PVMF_MEDIA_CLOCK_DAY    = 5
+};
+
+/*
+* Enum for return error codes for AdjustClock32() API
+*/
+enum PVMFMediaClockAdjustTimeStatus
+{
+    PVMF_MEDIA_CLOCK_ADJUST_SUCCESS,
+    PVMF_MEDIA_CLOCK_ADJUST_ERR_INVALID_STATE,             // If adjustment is attempted when clock is not running.
+    PVMF_MEDIA_CLOCK_ADJUST_ERR_INVALID_TIMEBASE_TIME,     // If Adjustment is older than latest adjustment
+    PVMF_MEDIA_CLOCK_ADJUST_ERR_CORRUPT_CLOCK_TIME       // If Clock time arg passed is later than current time
+};
+
+
+class PVMFMediaClockNotificationsObsBase
+{
+    public:
+        /**
+         * This event happens when the clock has been Reset or destroyed and notification
+         * interface object that observer is using has been destroyed. Observer should
+         * set its pointer to PVMFMediaClockNotificationsInterface object as NULL.
+         */
+        virtual void NotificationsInterfaceDestroyed() = 0;
+};
+
+/**
+    PVMFMediaClockNotificationsObs is an observer class for PVMFMediaClock for Callbacks.
+    ProcessCallBack() is called when the timer expires.
+*/
+class PVMFMediaClockNotificationsObs : public virtual PVMFMediaClockNotificationsObsBase
+{
+    public:
+        /**
+         * This callback function is called when a callback expires or has become invalid.
+         * @param callBackID Callback ID of the timer that has expired
+         *				   				   Units is msec.
+         * @param aTimerAccuracy Accuracy of timer. Value is from enum PVTimeComparisonUtils::MediaTimeStatus
+         * @param aDelta delta of scheduled callback time and actual time of callback
+         * @param aContextData Context data passed while setting the timer
+         * @param aStatus Status of timer. Value can be PVMFSuccess, PVMFErrCallbackClockStopped
+         *                or PVMFErrCallbackHasBecomeInvalid. aStatus is PVMFErrCallbackHasBecomeInvalid
+         *                if the direction of NPT Clock has changed. aStatus can be PVMFErrCallbackHasBecomeInvalid
+         *                only for a NPT callback.
+         * @return	NONE
+         *
+         */
+        virtual void ProcessCallBack(uint32 callBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 aDelta,
+                                     const OsclAny* aContextData, PVMFStatus aStatus) = 0;
+
+        /**
+         * This callback function is called when the notification interface
+         * being used by the object has been destroyed.
+         */
+        virtual void NotificationsInterfaceDestroyed() = 0;
+};
+
+/**
+    PVMFMediaClockObserver is an observer class for PVMFMediaClock.  Modules
+    can optionally register themselves as clock observers.  There
+    can be multiple observers for a single clock.
+*/
+class PVMFMediaClockObserver : public virtual PVMFMediaClockNotificationsObsBase
+{
+    public:
+
+        /**
+         * This callback function is called when the timebase for this clock
+         * has been updated
+         */
+        virtual void ClockTimebaseUpdated() = 0;
+
+        /**
+         * This callback function is called for counting timebases only, when the
+         * count has been updated.
+         */
+        virtual void ClockCountUpdated() = 0;
+
+        /**
+         * This callback function is called when the clock has been adjusted.
+         */
+        virtual void ClockAdjusted() = 0;
+
+        virtual ~PVMFMediaClockObserver() {}
+};
+
+/**
+    PVMFMediaClockStateObserver is an observer class for PVMFMediaClock.  Modules
+    can optionally register themselves as clock state observers.  There
+    can be multiple observers for a single clock.
+*/
+class PVMFMediaClockStateObserver : public virtual PVMFMediaClockNotificationsObsBase
+{
+    public:
+        /**
+         * This callback function is called when the clock state changes.
+         */
+        virtual void ClockStateUpdated() = 0;
+
+        virtual ~PVMFMediaClockStateObserver() {}
+};
+
+/**
+    PVMFCountTimebase is an extension to the standard timebase to allow
+    controlled stepping rather than continuous flow timebase.
+*/
+class PVMFCountTimebase
+{
+    public:
+        /**
+         * Set a new value for the count.  Will trigger a ClockCountUpdated callback
+         * to all observers of the clock in which this timebase resides.
+         * @param aCount (input): the new count
+         */
+        virtual void SetCount(int32 aCount) = 0;
+
+        /**
+         * Read current value of the count.
+         * @param aCount (output): the current count
+         */
+        virtual void GetCount(int32& aCount) = 0;
+
+        virtual ~PVMFCountTimebase() {}
+    private:
+        /**
+         * Each PVMFCountTimebase will be contained within an PVMFMediaClock
+         * class.  That PVMFMediaClock instance will set itself as the observer of
+         * the PVMFCountTimebase.  To get notices from the timebase, modules
+         * can register through the SetClockObserver method of the PVMFMediaClock.
+         */
+        friend class PVMFMediaClock;
+        virtual void SetClockObserver(PVMFMediaClockObserver* aObserver) = 0;
+};
+
+/**
+    PVMFTimebase is a base class to obtain the timebase clock time.
+    Common source of the timebase clock is the system tickcount which is implemented
+    as PVMFTimebase_Tickcount further below. PVMFTimebase is expected to return the time
+    in units of microseconds even if the timebase itself does not have the resolution of microseconds.
+*/
+class PVMFTimebase
+{
+    public:
+
+        virtual ~PVMFTimebase() {}
+
+        /**
+         * Gets the timebase clock's smallest time resolution in microseconds
+         * @param aResolution: unsigned 32-bit value for the clock resolution
+         */
+        virtual void GetTimebaseResolution(uint32& aResolution) = 0;
+
+        /**
+         * Returns the timebase clock's smallest time resolution in microseconds
+         * @param aResolution: unsigned 32-bit value for the clock resolution
+         */
+
+        /**
+         * Read current value of the count.
+         * @param aResolution: unsigned 32-bit value. Playback rate unit is milli-percent of real time
+         */
+        virtual int32 GetRate(void) = 0;
+
+        /**
+         *   Returns current tickcount. PVMFMediaClock sources this value from the timebase. If no
+         *   timebase is set, aTimebaseTickCount is set to 0.
+         *   @param aTime: a reference to an unsigned 32-bit integer to return the current time
+         *   @param aUnits: the requested time units for aTime
+         *   @param aTimebaseTime: a reference to an unsigned 32-bit integer to return the timebase time
+         */
+        virtual void GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow) = 0;
+
+        /**
+        *    This API returns pointer to clock's timebase if timebase being used is a PVMFCountTimebase
+        *    object. Otherwise, NULL is returned. PVMFCountTimebase is used for a stepping clock.
+        *    @return pointer to PVMFCountTimebase implementation, or NULL if not supported.
+        */
+        virtual PVMFCountTimebase* GetCountTimebase() = 0;
+
+};
+
+/*
+PVMFMediaClockControlInterface interface class is implemented by PVMFMediaClock.
+This class contains methods for controlling PVMFMediaClock
+*/
+class PVMFMediaClockControlInterface: public PVInterface
+{
+    public:
+        /**
+        *    Starts the clock from the start time or
+        *    resumes the clock from the last paused time. Clock goes to RUNNING state.
+        *    @return true if the clock is resumed or started, false otherwise
+        */
+
+        virtual OSCL_IMPORT_REF bool Start() = 0;
+
+        /**
+        *    Pauses the running clock. Saves the clock time when pausing as the paused time.
+        *    Clock goes to PAUSED state. Returns true if the clock is paused, false otherwise.
+        *    Will trigger a ClockStateUpdated notice to all state observers of this clock.
+        *    @return true if the clock is paused, false otherwise
+        */
+        virtual OSCL_IMPORT_REF bool Pause() = 0;
+
+        /**
+        *    Stops the running or paused clock and start time is reset to 0. Clock goes to STOPPED state.
+        *    Will trigger a ClockStateUpdated notice to all state observers of this clock. State
+        *    observers and clock observers are not automatically removed when clock is stopped. However,
+        *    any active callbacks will be fired with error code PVMFErrCallbackClockStopped.
+        *
+        *    @return true if the clock is stopped, false otherwise
+        */
+        virtual OSCL_IMPORT_REF bool Stop() = 0;
+
+        /**
+        *    Sets the starting clock time with unsigned 32-bit integer in the specified time units
+        *    while in STOPPED state. Clock's internal timekeeping units are changed to usecs if aUnits
+        *    is usecs. Otherwise, internal units remain msecs(default). High probability of overflow if
+        *    units are given as usecs.
+        *    @param aTime: a reference to an unsigned 32-bit integer to set the start time
+        *    @param aUnits: the time units of aTime
+        *    @param aOverFlow: true if operation resulted in overflow, false otherwise
+        *    @return true if start time was set, false otherwise
+        */
+        virtual OSCL_IMPORT_REF bool SetStartTime32(uint32& aTime, PVMFMediaClock_TimeUnits aUnits, bool& aOverFlow) = 0;
+
+        /**
+        *   Adjusts the clock time with unsigned 32-bit integer in the specified time units while in
+        *   RUNNING state. For backward adjustments, clock freezes internally till the adjusted time.
+        *   @param aClockTime: a reference to an unsigned 32-bit integer to the observation clock time
+        *   @param aTimebaseTime: a reference to an unsigned 32-bit integer to the observation timebase time
+        *   @param aAdjustedTime: a reference to an unsigned 32-bit integer to the adjusted clock time
+        *   @param aUnits: the time units of aClockTime and aAdjustedTime
+        *   @return true if AdjustClockTime32 is successful
+        */
+        virtual OSCL_IMPORT_REF PVMFMediaClockAdjustTimeStatus AdjustClockTime32(uint32& aClockTime, uint32& aTimebaseTime, uint32& aAdjustedTime, PVMFMediaClock_TimeUnits aUnits, bool& aOverFlow) = 0;
+
+        /**
+        *   Stops the running or paused clock and start time is reset to 0. Clock goes to STOPPED state.
+        *   Will trigger a ClockStateUpdated notice to all state observers of this clock.Clock observers
+        *   and clock state observers are automatically removed when clock is Reset. Any active callbacks
+        *   will be fired with error code PVMFErrCallbackClockStopped. All PVMFMediaClockNotificationsInterface
+        *   objects are deleted.
+        *   @return true if reset is successful.
+        */
+        virtual OSCL_IMPORT_REF bool Reset() = 0;
+
+        void addRef() {}
+        void removeRef() {}
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            OSCL_UNUSED_ARG(uuid);
+            OSCL_UNUSED_ARG(iface);
+            return false;
+        }
+};
+
+/*
+PVMFMediaClockAccessInterface interface class is implemented by PVMFMediaClock.
+This class contains method for accessing start time from PVMFMediaClock.
+*/
+class PVMFMediaClockAccessInterface: public PVInterface
+{
+    public:
+
+        /**
+        *   Gets the starting clock time as an unsigned 32-bit integer in the specified time units
+        *   @param aTime: a reference to an unsigned 32-bit integer to copy the start time
+        *   @param aOverflow: a reference to a flag which is set if time value cannot fit in unsigned 32-bit integer
+        *   @param aUnits: the requested time units for aTime
+        */
+        virtual OSCL_IMPORT_REF void GetStartTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits) = 0;
+
+        /**
+        *   Gets the starting clock time as an unsigned 32-bit integer in the specified time units
+        *   @param aClockTime: a reference to an unsigned 32-bit integer to return current time in specified time units
+        *   @param aOverflow: a reference to a flag which is set if time value cannot fit in unsigned 32-bit integer
+        *   @param aUnits: the requested time units for aTime
+        */
+        virtual OSCL_IMPORT_REF void GetCurrentTime32(uint32& aClockTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits) = 0;
+
+        /**
+        *   This API is used to get current clock time in time units specified. If the value does not fit
+        *   in 32 bit uint (aTime), aOverflow flag is set. This API also provides current timebase tickcount.
+        *   This is not the absolute tickcount value from timebase. PVMFMediaClock uses scaled version of
+        *   timebase tickcount by subtracting the tickcount value at clock start time from the current tickcount value.
+        *   Thus, the clock starts from tickcount value 0 and probability of overflow is reduced.
+        *   @param aClockTime: a reference to an unsigned 32-bit integer to return current time in specified time units
+        *   @param aOverflow: a reference to a flag which is set if time value cannot fit in unsigned 32-bit integer
+        *   @param aUnits: the requested time units for aTime
+        *   @param aTimebaseTime: uint32 value used to return current (scaled) timebase tickcount
+        */
+        virtual OSCL_IMPORT_REF void GetCurrentTime32(uint32& aClockTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits, uint32& aTimebaseTime) = 0;
+
+        void addRef() {}
+        void removeRef() {}
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            OSCL_UNUSED_ARG(uuid);
+            OSCL_UNUSED_ARG(iface);
+            return false;
+        }
+};
+
+/*
+PVMFMediaClockNotificationsInterface interface is implemented by
+PVMFMediaClockNotificationsInterfaceImpl class. This interface contains all callbacks related methods.
+This class has methods related to both regular callbacks and NPT callbacks.
+*/
+
+class PVMFMediaClockNotificationsInterface
+{
+    public:
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetCallbackAbsoluteTime
+         **
+         ** Synopsis:	Set a callback timer specifying an absolute time in clock for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[absoluteTime]	-- absolute time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         **
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus SetCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetCallbackDeltaTime
+         **
+         ** Synopsis:	Set a callback timer specifying a delta time from current time for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[deltaTime]		-- delta time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         **
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus SetCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32 &aCallBackID) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    CancelCallback
+         **
+         ** Synopsis:	Cancel callback timer set with SetCallBackDeltaTime() or SetCallbackAbsoluteTime()
+         **
+         ** Arguments :
+         ** @param		[callbackID]	-- timer ID returned by SetCallBackDeltaTime()
+         **									or SetCallbackAbsoluteTime()
+         ** @param  :   [aThreadLock]   -- whether this call needs to be threadsafe
+         ** Returns:
+         ** @return		PVMFStatus
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus CancelCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetNPTCallbackAbsoluteTime
+         **
+         ** Synopsis:	Set a callback timer specifying an absolute time in clock for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[absoluteTime]	-- absolute time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         **
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+
+        virtual OSCL_IMPORT_REF PVMFStatus SetNPTCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetNPTCallbackDeltaTime
+         **
+         ** Synopsis:	Set a callback timer specifying a delta time from current time for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[deltaTime]		-- delta time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         **
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus SetNPTCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    CancelCallback
+         **
+         ** Synopsis:	Cancel callback timer set with SetCallBackDeltaTime() or SetCallbackAbsoluteTime()
+         **
+         ** Arguments :
+         ** @param		[callbackID]	-- timer ID returned by SetCallBackDeltaTime()
+         **									or SetCallbackAbsoluteTime()
+         ** @param  :   [aThreadLock]   -- whether this call needs to be threadsafe
+         ** Returns:
+         ** @return		PVMFStatus
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus CancelNPTCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock) = 0;
+
+        /**
+        *   This API sets the object passed as a ClockObserver. The object's callback
+        *   functions (ClockTimebaseUpdated(),ClockCountUpdated(),ClockAdjusted() )
+        *   will be called on corresponding events.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void SetClockObserver(PVMFMediaClockObserver& aObserver) = 0;
+
+        /**
+        *   This API removes aObserver obeject from the list of ClockObservers if aObserver
+        *   is set as an observer.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void RemoveClockObserver(PVMFMediaClockObserver& aObserver) = 0;
+
+        /**
+        *   This API sets the object passed as a ClockStateObserver. The object's callback
+        *   function ClockStateUpdated() will be called on clock state change.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void SetClockStateObserver(PVMFMediaClockStateObserver& aObserver) = 0;
+
+        /**
+        *   Removes an observer for this clock.  If the observer is not registered, this
+        *   call does nothing.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void RemoveClockStateObserver(PVMFMediaClockStateObserver& aObserver) = 0;
+
+        virtual ~PVMFMediaClockNotificationsInterface() {}
+};
+
+/*
+PVMFMediaClockNotificationsImplInterface class is implemented by PVMFMediaClock. This class contains
+corresponding PVMFMediaClock side functions of interface PVMFMediaClockNotifications.
+*/
+
+class PVMFMediaClockNotificationsImplInterface
+{
+    public:
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetCallbackAbsoluteTime
+         **
+         ** Synopsis:	Set a callback timer specifying an absolute time in clock for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[absoluteTime]	-- absolute time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         ** @param		[aInterfaceObject]	-- self pointer of interface object which calls this function
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus SetCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetCallbackDeltaTime
+         **
+         ** Synopsis:	Set a callback timer specifying a delta time from current time for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[deltaTime]		-- delta time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         ** @param		[aInterfaceObject]	-- self pointer of interface object which calls this function
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus SetCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32 &aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    CancelCallback
+         **
+         ** Synopsis:	Cancel callback timer set with SetCallBackDeltaTime() or SetCallbackAbsoluteTime()
+         **
+         ** Arguments :
+         ** @param		[callbackID]	-- timer ID returned by SetCallBackDeltaTime()
+         **									or SetCallbackAbsoluteTime()
+         ** @param  :   [aThreadLock]   -- whether this call needs to be threadsafe
+         ** Returns:
+         ** @return		PVMFStatus
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus CancelCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetNPTCallbackAbsoluteTime
+         **
+         ** Synopsis:	Set a callback timer specifying an absolute time in clock for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[absoluteTime]	-- absolute time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         ** @param		[aInterfaceObject]	-- self pointer of interface object which calls this function
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+
+        virtual OSCL_IMPORT_REF PVMFStatus SetNPTCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    SetNPTCallbackDeltaTime
+         **
+         ** Synopsis:	Set a callback timer specifying a delta time from current time for timer expiry.
+         **
+         ** Arguments :
+         ** @param		[deltaTime]		-- delta time in clock when callBack should be called.
+         **				   				   Units is msec.
+         ** @param		[window]		-- Error tolerance available in callback time. If T is the desired
+         **								   callback time and w is the allowed tolerance window, then callback
+         **								   can come between T-w to T+w time.
+         ** @param		[aObserver]     -- observer object to be called on timeout.
+         ** @param		[threadLock]	-- If threadLock is true, callback will to be threadsafe otherwise
+         **								   not. Making callback threadsafe might add overheads.
+         ** @param      [aContextData]  -- context pointer that will be returned back with the callback.
+         ** @param		[callBackID]	-- ID used to identify the timer for cancellation
+         ** @param		[aInterfaceObject]	-- self pointer of interface object which calls this function
+         ** Returns:
+         ** @return		PVMFStatus		-- success or error code
+         **
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus SetNPTCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject) = 0;
+
+        /*!*********************************************************************
+         **
+         ** Function:    CancelCallback
+         **
+         ** Synopsis:	Cancel callback timer set with SetCallBackDeltaTime() or SetCallbackAbsoluteTime()
+         **
+         ** Arguments :
+         ** @param		[callbackID]	-- timer ID returned by SetCallBackDeltaTime()
+         **									or SetCallbackAbsoluteTime()
+         ** @param  :   [aThreadLock]   -- whether this call needs to be threadsafe
+         ** Returns:
+         ** @return		PVMFStatus
+         **
+         ** Notes:
+         **
+         **********************************************************************/
+        virtual OSCL_IMPORT_REF PVMFStatus CancelNPTCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock) = 0;
+
+        /**
+        *   Adds an observer for this clock.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void SetClockObserver(PVMFMediaClockObserver& aObserver) = 0;
+
+        /**
+        *   Removes an observer for this clock.  If the observer is not registered, this
+        *   call does nothing.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void RemoveClockObserver(PVMFMediaClockObserver& aObserver) = 0;
+
+        /**
+        *   Sets an observer for this clock.  May leave if memory allocation fails.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void SetClockStateObserver(PVMFMediaClockStateObserver& aObserver) = 0;
+
+        /**
+        *   Removes an observer for this clock.  If the observer is not registered, this
+        *   call does nothing.
+        *   @param aObserver: the observer implemenation
+        */
+        virtual OSCL_IMPORT_REF void RemoveClockStateObserver(PVMFMediaClockStateObserver& aObserver) = 0;
+
+        virtual ~PVMFMediaClockNotificationsImplInterface() {}
+};
+
+
+/*
+PVMFMediaClockNPTClockPositionAccessInterface interface class is implemented by PVMFMediaClock.
+This class contains methods for accessing and updating NPT clock position values
+*/
+
+class PVMFMediaClockNPTClockPositionAccessInterface: public PVInterface
+{
+
+    public:
+
+        /**
+        *   NPT clock position is not same as playback clock position. PVMFMediaClock
+        *   can store the mapping between the two clocks. UpdateNPTClockPosition() API is
+        *   called by the user to update change in NPT clock position. User can change the
+        *   direction of NPT by specifying aIsPlayBackDirectionBackwards flag.
+        *   @param aStartNPT: uint32 value containing new startNPT value
+        *   @param aIsPlayBackDirectionBackwards: Should be set as false if
+        *          NPT playback direction is forward from this point and should
+        *          be set as true if NPT clock direction is backwards.
+        */
+        virtual void UpdateNPTClockPosition(
+            /*IN*/  uint32 aStartNPT,
+            /*IN*/  bool aIsPlayBackDirectionBackwards) = 0;
+
+        /**
+        *   Gets NPT clock position
+        *   @param aCurrentPosition: uint32 value to store the current NPT clock position.
+        *   @return PVMFSuccess/PVMFErrArgument. PVMFErrArgument is returned when there is
+        *           overflow i.e. 32 bit aCurrentPosition is not enough to store current NPT
+        *           clock value or if there is an internal overflow.
+        */
+        virtual PVMFStatus GetNPTClockPosition(
+            /*OUT*/ uint32& aCurrentPosition) = 0;
+
+        /**
+        * 	This API clears the NPT clock mapping and resets internal variables to 0.
+        */
+        virtual void ClearNPTClockPosition() = 0;
+
+        /**
+        *   This API is used to schedule a NPT clock transition(time change) in future. All
+        *   parameters are described above.
+        *   @param aMediaClockPosition: Absolute media clock position when NPT clock change
+        *                               should take place.
+        *   @param aStartNPT: new startNPT value to be set
+        *   @param aIsPlayBackDirectionBackwards: flag specifying if NPT clock should run
+        *                                         backwards after NPT time update.
+        *   @param aWindow: margin window for scheduling the time change. i.e. NPT clock
+        *                   time change can be scheduled within window [aMediaClockPosition-aWindow,
+        *                   aMediaClockPosition+aWindow].
+        *   @param aClockTransitionEventID: clockTransitionID returned to user. This can be used
+        *                                   to cancel a transition after it has been set.
+        *   @return PVMFSuccess/PVMFFailure
+        */
+        virtual PVMFStatus QueueNPTClockTransitionEvent(uint32 aMediaClockPosition, uint32 aStartNPT,
+                bool aIsPlayBackDirectionBackwards, uint32 aWindow, uint32& aClockTransitionEventID) = 0;
+
+        /**
+        *   This API is used to cancel a NPTClockTransition event set by using QueueNPTClockTransitionEvent()
+        *   @param aClockTransitionEventID: ID returned from QueueNPTClockTransitionEvent()function.
+        *   @return PVMFSuccess/PVMFFailure
+        */
+        virtual PVMFStatus CancelNPTClockTransitionEvent(uint32 aClockTransitionEventID) = 0;
+
+        void addRef() {}
+        void removeRef() {}
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface)
+        {
+            OSCL_UNUSED_ARG(uuid);
+            OSCL_UNUSED_ARG(iface);
+            return false;
+        }
+};
+
+/*
+PVMFMediaClockNotificationsInterfaceImpl is the implementation class for
+PVMFMediaClockNotificationsInterface.
+*/
+
+class PVMFMediaClockNotificationsInterfaceImpl: public PVMFMediaClockNotificationsInterface
+{
+
+    public:
+
+        //constructor
+
+        OSCL_IMPORT_REF PVMFMediaClockNotificationsInterfaceImpl(PVMFMediaClock *, uint32 aLatency,
+                PVMFMediaClockNotificationsObsBase& aNotificationInterfaceDestroyedCallback);
+
+        /**
+            The default destructor
+        */
+        OSCL_IMPORT_REF ~PVMFMediaClockNotificationsInterfaceImpl();
+
+        //From PVMFMediaClockNotificationsInterface
+
+        OSCL_IMPORT_REF PVMFStatus SetCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID);
+
+        OSCL_IMPORT_REF PVMFStatus SetCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID);
+
+        OSCL_IMPORT_REF PVMFStatus CancelCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock);
+
+        OSCL_IMPORT_REF PVMFStatus SetNPTCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID);
+
+        OSCL_IMPORT_REF PVMFStatus SetNPTCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID);
+
+        OSCL_IMPORT_REF PVMFStatus CancelNPTCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock);
+
+        OSCL_IMPORT_REF void SetClockObserver(PVMFMediaClockObserver& aObserver);
+
+        OSCL_IMPORT_REF void RemoveClockObserver(PVMFMediaClockObserver& aObserver);
+
+        OSCL_IMPORT_REF void SetClockStateObserver(PVMFMediaClockStateObserver& aObserver);
+
+        OSCL_IMPORT_REF void RemoveClockStateObserver(PVMFMediaClockStateObserver& aObserver);
+
+        //End PVMFMediaClockNotificationsInterface
+
+    protected:
+
+        /*PVMFMediaClock will have a vector of PVMFMediaClockNotificationsInterfaceImpl
+        instances. PVMFMediaClock will access iLatency from this class*/
+        friend class PVMFMediaClock;
+        PVMFMediaClockStateObserver *iClockStateObserver;
+        uint32 iLatency;
+        //this value is iLatency - min latency among all objects present.
+        uint32 iAdjustedLatency;
+        //This value is the delay after which clock start notification will be sent.
+        uint32 iLatencyDelayForClockStartNotification;
+        PVMFMediaClock *iContainer;
+        PVMFMediaClockNotificationsObsBase* iNotificationInterfaceDestroyedCallback;
+};
+
+/*This structure represents one callback element inserted in PVMFMediaClock's internal timer queues */
+class PVMFMediaClockTimerQueueElement
+{
+    public:
+        /**
+         * Equality comparison for use with OsclPriorityQueue
+         */
+        bool operator==(const PVMFMediaClockTimerQueueElement &other) const
+        {
+            return callBackID == other.callBackID;
+        }
+        uint32 timeOut;
+        uint32 callBackID;
+        bool isNPTTimer;
+        uint32 window;
+        PVMFMediaClockNotificationsObs* obs;
+        const OsclAny* contextData;
+        const OsclAny* pInterfaceObject;
+} ;
+
+
+/*This structure represents one NPT Clock transition event */
+typedef struct _PVMFMediaClockNPTTransitionEventElement
+{
+    uint32 mediaClockPosition;
+    uint32 startNPT;
+    bool isPlayBackDirectionBackwards;
+    uint32 window;
+    uint32 eventID;
+} PVMFMediaClockNPTTransitionEventElement;
+
+/*This structure represents one clock start notification event */
+typedef struct _PVMFMediaClockStartNotificationEventElement
+{
+    PVMFMediaClockStateObserver *clockStateObserver;
+    uint32 eventID;
+} PVMFMediaClockStartNotificationEventElement;
+
+/*This is the comparison class supplied to PVMFMediaClock's priority queues */
+class PVMFMediaClockTimerQueueCompareLess
+{
+    public:
+        int compare(PVMFMediaClockTimerQueueElement& a, PVMFMediaClockTimerQueueElement& b) const
+        {
+            uint32 delta = 0;
+            return PVTimeComparisonUtils::IsEarlier(b.timeOut, a.timeOut, delta);
+        }
+};
+
+/*This comparison class is used for backwards NPT priority queue. This queue needs to maintain timers in
+Descending fashion*/
+class PVMFMediaClockTimerQueueCompareLessForNPTBackwards
+{
+    public:
+        int compare(PVMFMediaClockTimerQueueElement& a, PVMFMediaClockTimerQueueElement& b) const
+        {
+            uint32 delta = 0;
+            return PVTimeComparisonUtils::IsEarlier(a.timeOut, b.timeOut, delta);
+        }
+};
+
+
+class PVMFMediaClock :  public OsclTimerObject,
+            public PVMFTimebase,
+            public PVMFMediaClockObserver,
+            public PVMFMediaClockControlInterface,
+            public PVMFMediaClockAccessInterface,
+            public PVMFMediaClockNPTClockPositionAccessInterface,
+            public PVMFMediaClockNotificationsImplInterface,
+            public PVMFMediaClockNotificationsObs /*Media clock uses itself to set callback*/
+{
+
+    public:
+
+        /**
+            The default constructor initializes the clock to 0 and goes to STOPPED state
+        */
+        OSCL_IMPORT_REF PVMFMediaClock();
+
+        /**
+            The default destructor
+        */
+        OSCL_IMPORT_REF ~PVMFMediaClock();
+
+        /**
+        *    Sets the timebase to use for this clock.
+        *    Will trigger an ClockTimebaseUpdated notice to all observers of this clock.
+        *    The clock timebase can only be set while in STOPPED and PAUSED states.
+        *    @param aTimebase: a reference to an PVMFTimebase-derived object
+        *    @return true if the new clock timebase has been accepted, false otherwise
+        */
+        OSCL_IMPORT_REF bool SetClockTimebase(PVMFTimebase& aTimebase);
+
+        /**
+        *    This API constructs a PVMFMediaClockNotificationsInterface object. This API does not
+        *    work when clock is in running state and if called while clock is running, it returns
+        *    PVMFErrInvalidState. Object created using this API must be explicitly destroyed using
+        *    DestroyMediaClockNotificationsInterface().
+        *    @param aIface: PVMFMediaClockNotificationsInterface* variable to store reference to
+        *                   constructed notifications object.
+        *    @param aNotificationInterfaceDestroyedCallback: Implementation of callback function
+        *                                                    which would be called when the interface
+        *                                                    is destroyed.
+        *    @param aLatency: uint32 variable containing latency value associated with the module.
+        *    @return true if the new clock timebase has been accepted, false otherwise
+        */
+        OSCL_IMPORT_REF PVMFStatus ConstructMediaClockNotificationsInterface(PVMFMediaClockNotificationsInterface*& aIface,
+                PVMFMediaClockNotificationsObsBase &aNotificationInterfaceDestroyedCallback, uint32 aLatency = 0);
+
+        /*  This API destroys the PVMFMediaClockNotificationsInterface object created
+        *   by ConstructMediaClockNotificationsInterface().
+        *   @param aIface: PVMFMediaClockNotificationsInterface* variable containing reference to
+        *   object to be destroyed.
+        */
+        OSCL_IMPORT_REF void DestroyMediaClockNotificationsInterface(PVMFMediaClockNotificationsInterface* aInf);
+
+
+
+        //	From PVMFTimebase
+
+        OSCL_IMPORT_REF void GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow);
+
+        PVMFCountTimebase* GetCountTimebase()
+        {
+            if (iClockTimebase)
+                return iClockTimebase->GetCountTimebase();
+            return NULL;
+        }
+
+        OSCL_IMPORT_REF void GetTimebaseResolution(uint32& aResolution);
+
+
+        OSCL_IMPORT_REF int32 GetRate(void);
+
+
+        // From PVMFMediaClockControlInterface
+
+        OSCL_IMPORT_REF bool Start();
+
+        OSCL_IMPORT_REF bool Pause();
+
+        OSCL_IMPORT_REF bool Stop();
+
+        OSCL_IMPORT_REF bool SetStartTime32(uint32& aTime, PVMFMediaClock_TimeUnits aUnits, bool& aOverFlow);
+
+        OSCL_IMPORT_REF PVMFMediaClockAdjustTimeStatus AdjustClockTime32(uint32& aClockTime, uint32& aTimebaseTime, uint32& aAdjustedTime, PVMFMediaClock_TimeUnits aUnits, bool& aOverFlow);
+
+        OSCL_IMPORT_REF bool Reset();
+
+        // End PVMFMediaClockControlInterface
+
+        // From PVMFMediaClockAccessInterface
+
+        OSCL_IMPORT_REF void GetStartTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits);
+        OSCL_IMPORT_REF void GetCurrentTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits, uint32& aTimebaseTime);
+        OSCL_IMPORT_REF void GetCurrentTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits);
+
+        // End PVMFMediaClockAccessInterface
+
+
+        OSCL_IMPORT_REF bool QueryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+        // From PVMFMediaClockNPTClockPositionAccessInterface
+
+        void UpdateNPTClockPosition(
+            /*IN*/  uint32 aStartNPT,
+            /*IN*/  bool aIsPlayBackDirectionBackwards);
+
+        PVMFStatus GetNPTClockPosition(
+            /*OUT*/ uint32& aCurrentPosition);
+
+        void ClearNPTClockPosition();
+
+        PVMFStatus QueueNPTClockTransitionEvent(uint32 aMediaClockPosition, uint32 aStartNPT,
+                                                bool aIsPlayBackDirectionBackwards, uint32 aWindow, uint32& aClockTransitionEventID);
+
+        PVMFStatus CancelNPTClockTransitionEvent(uint32 aClockTransitionEventID);
+        // End PVMFMediaClockNPTClockPositionAccessInterface
+
+        /*
+         * Enum for PVMFMediaClock's internal states
+         */
+        enum PVMFMediaClockState
+        {
+            STOPPED,
+            RUNNING,
+            PAUSED
+        };
+
+        /*Returns the current state of MediaClock*/
+        PVMFMediaClockState GetState()
+        {
+            return iState;
+        }
+
+
+    protected:
+
+        friend class PVMFMediaClockNotificationsInterfaceImpl;
+
+        //start PVMFMediaClockNotificationsImplInterface functions
+        /**
+            Sets an observer for this clock.  May leave if memory allocation fails.
+            @param aObserver: the observer implemenation
+        */
+        OSCL_IMPORT_REF void SetClockObserver(PVMFMediaClockObserver& aObserver);
+
+        /**
+            Removes an observer for this clock.  If the observer is not registered, this
+            call does nothing.
+            @param aObserver: the observer implemenation
+        */
+        OSCL_IMPORT_REF void RemoveClockObserver(PVMFMediaClockObserver& aObserver);
+
+        /**
+            Sets an observer for this clock.  May leave if memory allocation fails.
+            @param aObserver: the observer implemenation
+        */
+        void SetClockStateObserver(PVMFMediaClockStateObserver& aObserver)
+        {/*Dummy function*/
+            OSCL_UNUSED_ARG(aObserver);
+        }
+        /**
+            Removes an observer for this clock.  If the observer is not registered, this
+            call does nothing.
+            @param aObserver: the observer implemenation
+        */
+        void RemoveClockStateObserver(PVMFMediaClockStateObserver& aObserver)
+        {/*Dummy function*/
+            OSCL_UNUSED_ARG(aObserver);
+        }
+
+
+        PVMFStatus SetCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject);
+
+        PVMFStatus SetCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject);
+
+        PVMFStatus CancelCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock);
+
+        PVMFStatus SetNPTCallbackAbsoluteTime(
+            /*IN*/  uint32 aAbsoluteTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject);
+
+        PVMFStatus SetNPTCallbackDeltaTime(
+            /*IN*/  uint32 aDeltaTime,
+            /*IN*/  uint32 aWindow,
+            /*IN*/  PVMFMediaClockNotificationsObs* aObs,
+            /*IN*/  bool aThreadLock,
+            /*IN*/  const OsclAny* aContextData,
+            /*OUT*/ uint32& aCallBackID,
+            /*IN*/  const OsclAny* aInterfaceObject);
+
+        PVMFStatus CancelNPTCallback(
+            /*IN*/  uint32 aCallbackID, bool aThreadLock);
+
+        //End PVMFMediaClockNotificationsInterface
+        /**
+            Changes the clock's state to the specified state
+            @param aState: the new state to change to
+        */
+        void SetClockState(PVMFMediaClockState aState);
+        /**
+            Updates the iLatestTime and iLatestSourceVal to specified values
+            @param aTime: the new iLatestTime value to change to
+            @param aSourceVal: the new iLatestSourceVal value to change to
+        */
+        void UpdateLatestTimes(uint32 aTime, uint32 aSourceVal);
+
+        /* Gets delta between iStartTimebaseTickValue and current tickcount*/
+        void GetScaledTimebaseTickCount(uint32& aScaledTickCount, bool& aOverFlow);
+        /**
+            Updates the iLatestRunningClockTime and iLatestRunningTimebaseTime to new units
+        */
+        void AdjustClockInternalsToNewUnits(bool& aOverFlow);
+        /**
+            Converts a time value in the specified time units to microseconds
+            @param aSrcVal: unsigned 32-bit time value in units specified by aSrcUnits
+            @param aSrcUnits: time units of aSrcVal
+            @param aUSecVal: reference to unsigned 32-bit integer to store the microsecond time value
+        */
+        void ToClockUnit(uint32& aSrcVal, PVMFMediaClock_TimeUnits aSrcUnits, uint32& aDestVal, bool& aOverFlow);
+        /**
+            Converts a millisecond time value to the specified time units
+            @param aUSecVal: unsigned 32-bit integer in microsecond time value
+            @param aDstVal: reference to unsigned 32-bit integer which will contain aUSecVal in the
+            specified aDstUnits time units
+            @param aDstUnits: requested time units for aDstVal
+        */
+
+        void FromClockUnit(uint32& aClockUnitVal, uint32& aDstVal,
+                           PVMFMediaClock_TimeUnits aDstUnits, bool& aOverFlow);
+
+        /**
+            Converts a time value in the specified time units to microseconds
+            @param aSrcVal: unsigned 32-bit time value in units specified by aSrcUnits
+        	@param aSrcUnits: time units of aSrcVal
+        	@param aUSecVal: reference to unsigned 32-bit integer to store the microsecond time value
+        */
+        void ToUSec(uint32& aSrcVal, PVMFMediaClock_TimeUnits aSrcUnits,
+                    uint32& aUSecVal, bool& aOverflow);
+
+        /**
+            Converts timebase ticks to clock units
+            @param aDelta: unsigned 32-bit tickcount value
+            @param aDeltaTime: reference to unsigned 32-bit integer to store time
+        */
+        void ConvertTickcountToClockUnits(uint32 aTickcount, uint32& aTimeValue, bool& aOverflowFlag);
+        /**
+            Updates the internal clock parameters based on the adjustment information provided.
+            This function can be overridden in the derived classes to allow variety in the adjustment algorithm
+            @param aObsTime: unsigned 32-bit integer in microsecond for the observed clock time
+            @param aObsTimebase: unsigned 32-bit integer in microsecond for the observed timebase time
+            @param aAdjTime: unsigned 32-bit integer in microsecond for the adjusted clock time
+            @param aCurrentTime: unsigned 32-bit integer in microsecond for the current clock time
+            @param aCurrentTimebase: unsigned 32-bit integer in microsecond for the current timebase time
+        */
+        virtual PVMFMediaClockAdjustTimeStatus AdjustClock(uint32& aObsTime, uint32& aObsTimebase, uint32& aAdjTime,
+                uint32& aCurrentTime, uint32& aCurrentTimebase);
+
+        /**
+            Returns the adjusted current clock time when the clock is running
+            This function can be overridden in the derived classes to allow variety in the adjustment algorithm
+            @param aDstTime: unsigned 32-bit integer in microseconds to output the adjusted current clock time
+            @param aTimebaseVal: unsigned 32-bit integer in microseconds of the current timebase time
+        */
+        virtual void GetAdjustedRunningClockTime(uint32& aDstTime, uint32& aTimebaseVal);
+
+        //Possible units for time keeping
+        enum PVMFMediaClock_ClockUnit
+        {
+            PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC = 0,
+            PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC = 1
+        };
+
+        PVLogger* iLogger;
+
+
+        // Timebase time is stored as unsigned 32-bit value in microseconds
+        uint32 iLatestRunningClockTime;           // Last reference clock time due to starting/resuming, pausing, and adjustment
+        uint32 iLatestRunningTimebaseTime;        // Timebase time corresponding to the latest running clock time
+        uint32 iStartTimebaseTickValue;           // Timebase tick value at clock start time.
+        uint32 iStartClockTime;                   // Starting clock time. Set by the SetStartTime...() APIs
+        uint32 iPauseClockTime;                   // Clock time when Pause() API is called.
+        uint32 iLastAdjustObsTimebaseTime;           // The observed timebase time corresponding to the adjusted time passed in
+        uint32 iAdjustmentTimebaseTime;           // The timebase time of the last successful AdjustClockTime...() call
+        PVMFMediaClock_ClockUnit iClockUnit;      // unit of above values in clock implementation
+        PVMFMediaClock_ClockUnit iPreviousClockUnit; // unit of above values in clock implementation
+
+        PVMFMediaClockState iState;               // Internal state of the clock
+
+        PVMFTimebase* iClockTimebase;             // Pointer to this clock's timebase
+
+        //vector of clock observers.
+        Oscl_Vector<PVMFMediaClockObserver*, OsclMemAllocator> iClockObservers;
+
+        //from PVMFMediaClockObserver, for callbacks from an PVMFCountTimebase.
+        void ClockCountUpdated();
+        void ClockTimebaseUpdated();
+        void ClockAdjusted();
+
+        // for NPT mapping
+        bool iIsNPTPlayBackDirectionBackwards;
+        PVMFTimestamp iStartNPT;
+        PVMFTimestamp iStartMediaClockTS;
+
+        //for npt transition queueing
+        Oscl_Vector<PVMFMediaClockNPTTransitionEventElement, OsclMemAllocator> iNPTTransitionEventQueue;
+
+        //for clock-start notification event queuing
+        Oscl_Vector<PVMFMediaClockStartNotificationEventElement, OsclMemAllocator> iClockStartNotificationEventQueue;
+
+        //vector of PVMFMediaClockNotificationsInterfaceImpl objects. Each object represents a session
+        Oscl_Vector<PVMFMediaClockNotificationsInterfaceImpl*, OsclMemAllocator> iMediaClockSetCallbackObjects;
+
+        //callback related functions, members
+
+        OsclPriorityQueue < PVMFMediaClockTimerQueueElement, OsclMemAllocator, Oscl_Vector<PVMFMediaClockTimerQueueElement, OsclMemAllocator>,
+        PVMFMediaClockTimerQueueCompareLess > iTimersPriQueue;
+
+        //Mutex for multithreading support
+        OsclMutex *iMutex;
+
+        //For keeping count of active timers
+        uint32 iActiveTimersCount;
+
+        //For keeping track of timer ID count.
+        uint32 iTimerIDCount;
+
+        //This stores the current thread ID when clock is constructed.
+        TOsclThreadId iOrigThreadID;
+
+        // Variables to be used when timebase is swapped.
+        int32 iLastTimebaseRate;
+
+        bool iIsTimebaseCountBased;
+
+        //common setCallback() for regular and NPT timers
+        PVMFStatus SetCallbackCommon(uint32 aDeltaTime, uint32 aWindow,
+                                     PVMFMediaClockNotificationsObs* aCallback, bool aThreadLock, const OsclAny* aContextData,
+                                     uint32& aCallBackID, const OsclAny* aInterfaceObject, uint32 aCurrentTime, bool aIsNPT);
+
+        //common CancelCallback() for regular and NPT timers
+        PVMFStatus CommonCancelCallback(uint32 aCallbackID, bool aThreadLock, bool aIsNPT);
+
+        //This function adjusts latencies of all PVMFMediaClockNotificationsInterfaceImpl objects
+        //stored in the vector by subtracting largest common latency from all.
+        void AdjustLatenciesOfSinks();
+
+        /**
+        This is a generic function for doing fresh scheduling of PVMFMediaClock object
+        This function is called when a new callback is created. a callback is cancelled or
+        when clock state changes.
+        @param aIsNPT: signifies if aCurrentTime is NPT time
+        @param aCurrentTime: This is passed for optimization. More often than not, the calling
+        function has the current time value. If no argument is supplied, GetCurrentTime() is called.
+        */
+        void AdjustScheduling(bool aIsNPT = false, uint32 aCurrentTime = 0);
+
+        //for AO
+        void Run();
+
+        //Destoys all callback interface objects created. This is called from the destructor.
+        void CleanCallbackInfImplObjects();
+
+        /**
+        This function calculates the optimum time period after which Run() should be called.
+        @param aIsNPT: signifies if aCurrentTime is NPT time
+        @param aCurrentTime: This is passed for optimization as calling function has current time value.
+        @param aDelta: Time value to be passed in RunIfNotActive()
+        */
+        void CalculateRunLTimerValue(bool aIsNPT, uint32 aCurrentTime, int32& aDelta);
+
+        //NPT callbacks related members
+        OsclPriorityQueue < PVMFMediaClockTimerQueueElement, OsclMemAllocator, Oscl_Vector<PVMFMediaClockTimerQueueElement, OsclMemAllocator>,
+        PVMFMediaClockTimerQueueCompareLess > iTimersPriQueueNPT;
+
+        OsclPriorityQueue < PVMFMediaClockTimerQueueElement, OsclMemAllocator, Oscl_Vector<PVMFMediaClockTimerQueueElement, OsclMemAllocator>,
+        PVMFMediaClockTimerQueueCompareLessForNPTBackwards > iTimersPriQueueNPTBackwards;
+
+        //For flushing out queue when playback direction changes. This is done with NPT clock
+        void ClearPresentNPTQueue();
+
+        void ClearAllQueues();
+
+        //From PVMFMediaClockNotificationsObs interface
+        void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 delta,
+                             const OsclAny* acontextData, PVMFStatus aStatus);
+        void NotificationsInterfaceDestroyed();
+
+        void QueueClockStartNotificationEvent(uint32 aDelta, PVMFMediaClockStateObserver *aClockStateObserver);
+};
+
+/**
+    PVMFTimebase_Tickcount is PVMFTimebase-derived class which uses
+    the OSCL's system tickcount as the timebase. This class is provided
+    as the default PVMFTimebase that is available on any platform with OSCL support.
+*/
+class PVMFTimebase_Tickcount : public PVMFTimebase
+{
+    public:
+        /**
+            Constructor. Retrieves the constant to convert OSCL tickcount value to microseconds
+        */
+        PVMFTimebase_Tickcount()
+        {
+            iMicrosecPerTick = OsclTickCount::TickCountPeriod();
+            iPrevTickcount = 0;
+        }
+
+        /**
+            Destructor
+        */
+        ~PVMFTimebase_Tickcount()
+        {
+        }
+
+        // From PVMFTimebase
+        /**
+            Returns the OSCL tickcount's time resolution in microseconds
+            Implementation of virtual function from PVMFTimebase
+            @param aResolution: On function completion, contains OSCL tickcount resolution
+        */
+        void GetTimebaseResolution(uint32& aResolution)
+        {
+            aResolution = iMicrosecPerTick;
+        }
+        int32 GetRate(void)
+        {
+            return REALTIME_PLAYBACK_RATE;
+        }
+        OSCL_IMPORT_REF void GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow);
+        OSCL_IMPORT_REF void GetCurrentTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits);
+
+        PVMFCountTimebase* GetCountTimebase()
+        {
+            return NULL;
+        }
+
+    protected:
+        uint32 iMicrosecPerTick;
+        uint32 iPrevTickcount;
+
+};
+
+/**
+    PVMFTimebase_Count is PVMFTimebase-derived class that can be used to
+    implement a simple count-based timebase.
+*/
+class PVMFTimebase_Count : public PVMFTimebase, public PVMFCountTimebase
+{
+    public:
+        /**
+            Constructor.
+        */
+        PVMFTimebase_Count()
+        {
+            iCurrentCount = 0;
+            iObserver = NULL;
+        }
+
+        /**
+            Destructor
+        */
+        ~PVMFTimebase_Count()
+        {
+        }
+
+        // From PVMFTimebase
+        /**
+            Returns the OSCL tickcount's time resolution in microseconds
+            Implementation of virtual function from PVMFTimebase
+            @param aResolution: On function completion, contains OSCL tickcount resolution
+        */
+        void GetTimebaseResolution(uint32& aResolution)
+        {
+            aResolution = 0;                      //not meaningful for a count-based timebase.
+        }
+
+        int32 GetRate(void)
+        {
+            return 0;       //not meaningful for a count-based timebase.
+        }
+        /**
+            Returns the current clock time as unsigned 32-bit integer object in the specified time units
+            @param aTime: a reference to an unsigned 32-bit integer to return the current time
+            @param aUnits: the requested time units for aTime
+            @param aTimebaseTime: a reference to an unsigned 32-bit integer to return the timebase time
+        */
+        void GetCurrentTick32(uint32& aTick, bool& aOverflow)
+        {
+            //not meaningful for a count-based timebase.
+            aTick = 0;
+            aOverflow = false;
+        }
+        /**
+            Returns the PVMFCountTimebase implementation pointer
+        */
+        PVMFCountTimebase* GetCountTimebase()
+        {
+            return this;
+        }
+
+        //From PVMFCountTimebase
+        /**
+            Used to adjust the current count.
+            @param aCount (input): new count value.
+        */
+        void SetCount(int32 aCount)
+        {
+            iCurrentCount = aCount;
+            if (iObserver)
+            {
+                iObserver->ClockCountUpdated();
+            }
+        }
+
+        /**
+            Used to retreive the current count.
+            @param aCount (output): new count value.
+        */
+        void GetCount(int32& aCount)
+        {
+            aCount = iCurrentCount;
+        }
+
+    protected:
+        int32 iCurrentCount;
+        PVMFMediaClockObserver* iObserver;
+
+    private:
+        friend class PVMFMediaClock;
+        //From PVMFCountTimebase
+        void SetClockObserver(PVMFMediaClockObserver* aObserver)
+        {
+            iObserver = aObserver;
+        }
+
+};
+#endif                                            //PVMF_MEDIA_CLOCK_H_INCLUDED
diff --git a/pvmi/pvmf/include/pvmf_media_cmd.h b/pvmi/pvmf/include/pvmf_media_cmd.h
index dd476e9..212e1be 100644
--- a/pvmi/pvmf/include/pvmf_media_cmd.h
+++ b/pvmi/pvmf/include/pvmf_media_cmd.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_media_data.h b/pvmi/pvmf/include/pvmf_media_data.h
index 79c7bd5..444b78e 100644
--- a/pvmi/pvmf/include/pvmf_media_data.h
+++ b/pvmi/pvmf/include/pvmf_media_data.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_media_data_impl.h b/pvmi/pvmf/include/pvmf_media_data_impl.h
index 1491714..dc304e3 100644
--- a/pvmi/pvmf/include/pvmf_media_data_impl.h
+++ b/pvmi/pvmf/include/pvmf_media_data_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_media_frag_group.h b/pvmi/pvmf/include/pvmf_media_frag_group.h
index 71c18e0..c540e19 100644
--- a/pvmi/pvmf/include/pvmf_media_frag_group.h
+++ b/pvmi/pvmf/include/pvmf_media_frag_group.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -449,7 +449,13 @@
 
     if (available_mfgs == NULL)
     {
-        OSCL_LEAVE(OSCL_BAD_ALLOC_EXCEPTION_CODE);
+        //all required memory must have been allocated in "do_allocate"
+        //which is called as part of "create". any exception in either of
+        //these methods means that the allocator could not be created, but
+        //upon successful creation if "available_mfgs" is NULL then it means
+        //we are temporarily out of memory, and there is no need to throw
+        //an exception in this case
+        return media_data;
     }
 
     MediaDataEntry* first = available_mfgs->next;
diff --git a/pvmi/pvmf/include/pvmf_media_msg.h b/pvmi/pvmf/include/pvmf_media_msg.h
index 13a39d5..e69dad1 100644
--- a/pvmi/pvmf/include/pvmf_media_msg.h
+++ b/pvmi/pvmf/include/pvmf_media_msg.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_media_msg_format_ids.h b/pvmi/pvmf/include/pvmf_media_msg_format_ids.h
index cbd67d7..14c4004 100644
--- a/pvmi/pvmf/include/pvmf_media_msg_format_ids.h
+++ b/pvmi/pvmf/include/pvmf_media_msg_format_ids.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_media_msg_header.h b/pvmi/pvmf/include/pvmf_media_msg_header.h
index e74a4ea..a29beef 100644
--- a/pvmi/pvmf/include/pvmf_media_msg_header.h
+++ b/pvmi/pvmf/include/pvmf_media_msg_header.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_mempool.h b/pvmi/pvmf/include/pvmf_mempool.h
index 828f6e1..80431b0 100644
--- a/pvmi/pvmf/include/pvmf_mempool.h
+++ b/pvmi/pvmf/include/pvmf_mempool.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_meta_data_types.h b/pvmi/pvmf/include/pvmf_meta_data_types.h
index 2011f30..cd0f2e3 100644
--- a/pvmi/pvmf/include/pvmf_meta_data_types.h
+++ b/pvmi/pvmf/include/pvmf_meta_data_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_node_cmd_msg.h b/pvmi/pvmf/include/pvmf_node_cmd_msg.h
index 6e2d07f..452ac91 100644
--- a/pvmi/pvmf/include/pvmf_node_cmd_msg.h
+++ b/pvmi/pvmf/include/pvmf_node_cmd_msg.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_node_interface.h b/pvmi/pvmf/include/pvmf_node_interface.h
index 81f0303..0be0ce9 100644
--- a/pvmi/pvmf/include/pvmf_node_interface.h
+++ b/pvmi/pvmf/include/pvmf_node_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_node_utils.h b/pvmi/pvmf/include/pvmf_node_utils.h
index 61c9683..4c151b5 100644
--- a/pvmi/pvmf/include/pvmf_node_utils.h
+++ b/pvmi/pvmf/include/pvmf_node_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -442,6 +442,12 @@
         typedef Command vec_element;
         typedef vec_element* vec_element_ptr;
 
+        PVMFNodeCommandQueue()
+        {
+            iCommandCounter = 0;
+        }
+
+        //note: usage of the class requires calling the Construct function
         void Construct(int32 init, uint32 nres)
         {//construct the vector
             iCommandCounter = init;
diff --git a/pvmi/pvmf/include/pvmf_pool_buffer_allocator.h b/pvmi/pvmf/include/pvmf_pool_buffer_allocator.h
index c269da9..bb4a0e8 100644
--- a/pvmi/pvmf/include/pvmf_pool_buffer_allocator.h
+++ b/pvmi/pvmf/include/pvmf_pool_buffer_allocator.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,8 +50,9 @@
 class PVMFBufferPoolAllocator : public OsclDestructDealloc
 {
     public:
-        OSCL_IMPORT_REF PVMFBufferPoolAllocator();
+        OSCL_IMPORT_REF PVMFBufferPoolAllocator(bool aLeaveOnAllocFailure = true);
         OSCL_IMPORT_REF virtual ~PVMFBufferPoolAllocator();
+        OSCL_IMPORT_REF void SetLeaveOnAllocFailure(bool aLeaveOnAllocFailure);
         OSCL_IMPORT_REF virtual void size(uint16 num_frags, uint16 frag_size);
         OSCL_IMPORT_REF virtual void clear();
         OSCL_IMPORT_REF virtual OsclRefCounterMemFrag get();
@@ -60,12 +61,13 @@
         OSCL_IMPORT_REF virtual void destruct_and_dealloc(OsclAny* ptr);
         OSCL_IMPORT_REF void SetFailFrequency(uint16 aFrequency);
     protected:
-        uint16 iFragSize;
+        uint32 iFragSize;
         bool iDestroyPool;
         Oscl_Vector<OsclRefCounterMemFrag, OsclRefCounterMemFrag_Alloc> iAvailFragments;
         PVLogger *iLogger;
-        uint16 iAllocNum;
-        uint16 iFailFrequency;
+        uint32 iAllocNum;
+        uint32 iFailFrequency;
+        bool iLeaveOnAllocFailure;
 };
 
 
diff --git a/pvmi/pvmf/include/pvmf_port_base_impl.h b/pvmi/pvmf/include/pvmf_port_base_impl.h
index 661a14a..2deffa2 100644
--- a/pvmi/pvmf/include/pvmf_port_base_impl.h
+++ b/pvmi/pvmf/include/pvmf_port_base_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_port_interface.h b/pvmi/pvmf/include/pvmf_port_interface.h
index 2d3926d..3243af9 100644
--- a/pvmi/pvmf/include/pvmf_port_interface.h
+++ b/pvmi/pvmf/include/pvmf_port_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_resizable_simple_mediamsg.h b/pvmi/pvmf/include/pvmf_resizable_simple_mediamsg.h
index 615e1c8..ba34bf3 100644
--- a/pvmi/pvmf/include/pvmf_resizable_simple_mediamsg.h
+++ b/pvmi/pvmf/include/pvmf_resizable_simple_mediamsg.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -79,6 +79,7 @@
             if (in_gen_alloc)
             {
                 gen_alloc = in_gen_alloc;
+                gen_alloc->enablenullpointerreturn();
                 iBufferOverhead = 0;
                 uint aligned_class_size =
                     oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
@@ -103,6 +104,8 @@
 
         OsclSharedPtr<PVMFMediaDataImpl> allocate(uint32 size)
         {
+            OsclSharedPtr<PVMFMediaDataImpl> shared_media_data;
+
             if (size == 0)
             {
                 OSCL_ASSERT(false);
@@ -127,6 +130,11 @@
                                                   aligned_class_size +
                                                   aligned_in_size);
 
+            if (my_ptr == NULL)
+            {
+                return shared_media_data;
+            }
+
             OsclMemPoolResizableAllocatorCleanupDA *my_cleanup =
                 OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, OsclMemPoolResizableAllocatorCleanupDA(gen_alloc));
 
@@ -143,8 +151,7 @@
                                                   aligned_in_size,
                                                   my_refcnt);
 
-            OsclSharedPtr<PVMFMediaDataImpl> shared_media_data(media_data_ptr,
-                    my_refcnt);
+            shared_media_data.Bind(media_data_ptr, my_refcnt);
             return shared_media_data;
         }
 
@@ -171,9 +178,14 @@
             }
         }
 
+        uint32 GetMediaMsgAllocationOverheadBytes()
+        {
+            return iBufferOverhead;
+        }
+
     private:
         uint iBufferOverhead;
-        Oscl_DefAlloc* gen_alloc;
+        OsclMemPoolResizableAllocator* gen_alloc;
 };
 
 class PVMFResizableSimpleMediaMsgAllocCleanupSA : public OsclDestructDealloc
diff --git a/pvmi/pvmf/include/pvmf_return_codes.h b/pvmi/pvmf/include/pvmf_return_codes.h
index d1354b0..eaa062c 100644
--- a/pvmi/pvmf/include/pvmf_return_codes.h
+++ b/pvmi/pvmf/include/pvmf_return_codes.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -160,7 +160,22 @@
  Error due to the requirement of user-id and password input from app for HTTP basic/digest authentication
  */
 const PVMFStatus PVMFErrHTTPAuthenticationRequired = (-26);
-
+/*
+ PVMFMediaClock specific error. Callback has become invalid due to change in direction of NPT clock.
+*/
+const PVMFStatus PVMFErrCallbackHasBecomeInvalid = (-27);
+/*
+ PVMFMediaClock specific error. Callback is called as clock has stopped.
+*/
+const PVMFStatus PVMFErrCallbackClockStopped = (-28);
+/*
+ Error due to missing call for ReleaseMatadataValue() API
+ */
+const PVMFStatus PVMFErrReleaseMetadataValueNotDone = (-29);
+/*
+ Error due to the redirect error
+*/
+const PVMFStatus PVMFErrRedirect = (-30);
 /*
  Placeholder for last event in range.
  */
@@ -314,9 +329,30 @@
  */
 const PVMFStatus PVMFInfoPoorlyInterleavedContent = 43;
 /*
+ Notification for actual playback position after repositioning
+ */
+const PVMFStatus PVMFInfoActualPlaybackPosition = 44;
+/*
+ Notification that the live buffer is empty
+ */
+const PVMFStatus PVMFInfoLiveBufferEmpty = 45;
+/*
+ Notification that a server has responded with 200 OK to a Playlist play request
+ */
+const PVMFStatus PVMFInfoPlayListSwitch = 46;
+/*
+ Notification of configuration complete
+ */
+const PVMFStatus PVMFMIOConfigurationComplete = 47;
+/*
  Notification that the video track is falling behind
  */
-const PVMFStatus PVMFInfoVideoTrackFallingBehind = 44;
+const PVMFStatus PVMFInfoVideoTrackFallingBehind = 48;
+/*
+ Notification that memory is not available for new RTP packets
+ */
+const PVMFStatus PVMFInfoSourceOverflow = 49;
+
 /*
  Placeholder for end of range
  */
diff --git a/pvmi/pvmf/include/pvmf_simple_media_buffer.h b/pvmi/pvmf/include/pvmf_simple_media_buffer.h
index 0951839..db4a82e 100644
--- a/pvmi/pvmf/include/pvmf_simple_media_buffer.h
+++ b/pvmi/pvmf/include/pvmf_simple_media_buffer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -90,9 +90,13 @@
 {
 
     public:
-        PVMFSimpleMediaBufferCombinedAlloc(Oscl_DefAlloc* opt_gen_alloc = 0):
+        PVMFSimpleMediaBufferCombinedAlloc(Oscl_DefAlloc* opt_gen_alloc):
                 gen_alloc(opt_gen_alloc)
         {
+            if (opt_gen_alloc == NULL)
+            {
+                OSCL_ASSERT(false);
+            }
         };
         OSCL_IMPORT_REF OsclSharedPtr<PVMFMediaDataImpl> allocate(uint32 requested_buffer_capacity = 0);
 
diff --git a/pvmi/pvmf/include/pvmf_sync_util.h b/pvmi/pvmf/include/pvmf_sync_util.h
index 4e56cf2..dc4d19c 100644
--- a/pvmi/pvmf/include/pvmf_sync_util.h
+++ b/pvmi/pvmf/include/pvmf_sync_util.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,9 +26,15 @@
 #ifndef OSCL_BASE_H_INCLUDED
 #include "oscl_base.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
+
+
+
+
+
 #ifndef PVLOGGER_H_INCLUDED
 #include "pvlogger.h"
 #endif
@@ -139,14 +145,14 @@
          * @param aClock Clock object to which media data is synchronized.
          * @return Completion status.
          */
-        OSCL_IMPORT_REF PVMFStatus SetClock(OsclClock* aClock);
-        OSCL_IMPORT_REF PVMFStatus SetFrameStepClock(OsclClock* aClock);
+        OSCL_IMPORT_REF PVMFStatus SetClock(PVMFMediaClock* aClock);
+        OSCL_IMPORT_REF PVMFStatus SetFrameStepClock(PVMFMediaClock* aClock);
 
 
     private:
 
-        OsclClock* iClock;
-        OsclClock* iFrameStepClock;
+        PVMFMediaClock* iClock;
+        PVMFMediaClock* iFrameStepClock;
         int32 iEarlyMargin;
         int32 iLateMargin;
 
diff --git a/pvmi/pvmf/include/pvmf_sync_util_data_queue.h b/pvmi/pvmf/include/pvmf_sync_util_data_queue.h
index 50a1794..e1eeab1 100644
--- a/pvmi/pvmf/include/pvmf_sync_util_data_queue.h
+++ b/pvmi/pvmf/include/pvmf_sync_util_data_queue.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@
  * too late, or schedule the data to be processed at a later time that is synchronized to the
  * specified clock.
  */
-class PvmfSyncUtilDataQueue: public OsclClockObserver
+class PvmfSyncUtilDataQueue: public PVMFMediaClockObserver
 {
     public:
         /**
@@ -202,13 +202,14 @@
          */
         OSCL_IMPORT_REF void SetName(const char*);
 
-        OSCL_IMPORT_REF PVMFStatus SetClock(OsclClock*);
-        OSCL_IMPORT_REF PVMFStatus SetClockForFrameStep(OsclClock*);
+        OSCL_IMPORT_REF PVMFStatus SetClock(PVMFMediaClock*);
+        OSCL_IMPORT_REF PVMFStatus SetClockForFrameStep(PVMFMediaClock*);
 
-        //From OsclClockObserver
+        //From PVMFMediaClockObserver
         OSCL_IMPORT_REF void ClockTimebaseUpdated();
         OSCL_IMPORT_REF void ClockCountUpdated();
         OSCL_IMPORT_REF void ClockAdjusted();
+        OSCL_IMPORT_REF void NotificationsInterfaceDestroyed();
 
     private:
 
@@ -222,14 +223,15 @@
         PVLogger* iDatapathLogger;
         void LogMediaMsgInfo(PVMFSharedMediaMsgPtr aMediaMsg, const char* msg);
         void LogMediaMsgInfo(PVMFSharedMediaMsgPtr aMediaMsg, const char* msg, uint32);
-        OsclClock* iClock;
+        PVMFMediaClock* iClock;
+        PVMFMediaClockNotificationsInterface* iClockNotificationsInf;
         bool iClockOwner;
-        PVMFStatus DoSetClock(OsclClock*, bool);
+        PVMFStatus DoSetClock(PVMFMediaClock*, bool);
         void PassClockToSyncUtil();
 
         //for frame-stepping.
-        int64 iClockFrameCount;
-        int64 iSyncFrameCount;
+        int32 iClockFrameCount;
+        int32 iSyncFrameCount;
         PVMFStatus FrameStep();
         bool FrameStepMode();
         bool FrameSyncMode();
diff --git a/pvmi/pvmf/include/pvmf_timedtext.h b/pvmi/pvmf/include/pvmf_timedtext.h
index a43c1a7..b76f5b9 100644
--- a/pvmi/pvmf/include/pvmf_timedtext.h
+++ b/pvmi/pvmf/include/pvmf_timedtext.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,10 @@
 #include "oscl_shared_ptr.h"
 #endif
 
+#ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
+#include "oscl_mem_mempool.h"
+#endif
+
 #ifndef PVMF_MEDIA_DATA_IMPL_H_INCLUDED
 #include "pvmf_media_data_impl.h"
 #endif
@@ -245,17 +249,58 @@
 class PVMFTimedTextMediaDataAlloc
 {
     public:
-        PVMFTimedTextMediaDataAlloc(Oscl_DefAlloc* opt_gen_alloc = 0):
-                gen_alloc(opt_gen_alloc) {};
+        PVMFTimedTextMediaDataAlloc(OsclMemPoolResizableAllocator* in_gen_alloc)
+        {
+            if (in_gen_alloc)
+            {
+                gen_alloc = in_gen_alloc;
+                iBufferOverhead = 0;
+                uint32 aligned_refcnt_size =
+                    oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+                uint32 aligned_cleanup_size =
+                    oscl_mem_aligned_size(sizeof(PVMFTimedTextMediaDataCleanup));
+                uint32 aligned_simplemb_size =
+                    oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+                uint32 aligned_textmediadata_size =
+                    oscl_mem_aligned_size(sizeof(PVMFTimedTextMediaData));
+                iBufferOverhead = aligned_refcnt_size +
+                                  aligned_cleanup_size +
+                                  aligned_simplemb_size +
+                                  aligned_textmediadata_size;
+
+            }
+            else
+            {
+                OSCL_LEAVE(OsclErrArgument);
+            }
+        };
+
+        virtual ~PVMFTimedTextMediaDataAlloc()
+        {
+        };
 
         OsclSharedPtr<PVMFMediaDataImpl> allocate(uint32 requested_size)
         {
-            uint32 aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-            uint32 aligned_cleanup_size = oscl_mem_aligned_size(sizeof(PVMFTimedTextMediaDataCleanup));
-            uint32 aligned_simplemb_size = oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
-            uint32 aligned_textmediadata_size = oscl_mem_aligned_size(sizeof(PVMFTimedTextMediaData));
-            uint32 aligned_requested_size = oscl_mem_aligned_size(requested_size);
-            uint32 totalmem_size = aligned_refcnt_size + aligned_cleanup_size + aligned_simplemb_size + aligned_textmediadata_size + aligned_requested_size;
+            uint32 aligned_refcnt_size =
+                oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+
+            uint32 aligned_cleanup_size =
+                oscl_mem_aligned_size(sizeof(PVMFTimedTextMediaDataCleanup));
+
+            uint32 aligned_simplemb_size =
+                oscl_mem_aligned_size(sizeof(PVMFSimpleMediaBuffer));
+
+            uint32 aligned_textmediadata_size =
+                oscl_mem_aligned_size(sizeof(PVMFTimedTextMediaData));
+
+            uint32 aligned_requested_size =
+                oscl_mem_aligned_size(requested_size);
+
+            uint32 totalmem_size = aligned_refcnt_size +
+                                   aligned_cleanup_size +
+                                   aligned_simplemb_size +
+                                   aligned_textmediadata_size +
+                                   aligned_requested_size;
 
             // Allocate the memory
             uint8* mem_ptr = NULL;
@@ -293,8 +338,32 @@
             return shared_media_data;
         }
 
+        void ResizeMemoryFragment(OsclSharedPtr<PVMFMediaDataImpl>& aSharedBuffer)
+        {
+            OsclRefCounterMemFrag memFrag;
+            aSharedBuffer->getMediaFragment(0, memFrag);
+            uint32 currCapacity = memFrag.getCapacity();
+            uint32 bytesUsed = memFrag.getMemFragSize();
+
+            //uint32 alignedBytesUsed = bytesUsed;
+            uint32 alignedBytesUsed = oscl_mem_aligned_size(bytesUsed);
+
+            if (alignedBytesUsed < currCapacity)
+            {
+                uint32 bytesToReclaim = (currCapacity - alignedBytesUsed);
+                OsclMemPoolResizableAllocator* dataAllocator =
+                    reinterpret_cast<OsclMemPoolResizableAllocator*>(gen_alloc);
+                /* Account for the overhead */
+                uint8* memFragPtr = (uint8*)(memFrag.getMemFragPtr());
+                uint8* ptr = (memFragPtr - iBufferOverhead);
+                dataAllocator->trim((OsclAny*)ptr, bytesToReclaim);
+                aSharedBuffer->setCapacity(alignedBytesUsed);
+            }
+        }
+
     private:
-        Oscl_DefAlloc* gen_alloc;
+        uint32 iBufferOverhead;
+        OsclMemPoolResizableAllocator* gen_alloc;
 };
 
 
diff --git a/pvmi/pvmf/include/pvmf_timestamp.h b/pvmi/pvmf/include/pvmf_timestamp.h
index 68204e0..9c6ec6f 100644
--- a/pvmi/pvmf/include/pvmf_timestamp.h
+++ b/pvmi/pvmf/include/pvmf_timestamp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmf_video.h b/pvmi/pvmf/include/pvmf_video.h
index 437b103..42b49c3 100644
--- a/pvmi/pvmf/include/pvmf_video.h
+++ b/pvmi/pvmf/include/pvmf_video.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,6 +28,10 @@
 #include "pv_uuid.h"
 #endif
 
+#ifndef PVMF_FORMAT_TYPE_H_INCLUDED
+#include "pvmf_format_type.h"
+#endif
+
 #define PVMF_VIDEO_INPUT_WIDTH 176
 #define PVMF_VIDEO_INPUT_HEIGHT 144
 #define PVMF_VIDEO_INPUT_FRAME_RATE 15
@@ -35,14 +39,27 @@
 
 const PVUid32 PVMFYuvFormatSpecificInfo0_UID = 0x1;
 const PVUid32 PVMFEOSFormatSpecificInfo_UID = 0x2;
-struct PVMFYuvFormatSpecificInfo0
+class PVMFYuvFormatSpecificInfo0
 {
-    PVUid32 uid;
-    uint32 video_format;
-    uint32 display_width;
-    uint32 display_height;
-    uint32 width;
-    uint32 height;
+    public:
+        PVMFYuvFormatSpecificInfo0()
+        {
+            uid = PVMFYuvFormatSpecificInfo0_UID;
+            video_format = PVMF_MIME_FORMAT_UNKNOWN;
+            display_width = 0;
+            display_height = 0;
+            width = 0;
+            height = 0;
+        };
+
+        virtual ~PVMFYuvFormatSpecificInfo0() {};
+
+        PVUid32 uid;
+        PVMFFormatType video_format;
+        uint32 display_width;
+        uint32 display_height;
+        uint32 width;
+        uint32 height;
 };
 
 class PVMFVideoResolution
diff --git a/pvmi/pvmf/include/pvmi_config_and_capability.h b/pvmi/pvmf/include/pvmi_config_and_capability.h
index bb07aca..ee208eb 100644
--- a/pvmi/pvmf/include/pvmi_config_and_capability.h
+++ b/pvmi/pvmf/include/pvmi_config_and_capability.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_config_and_capability_observer.h b/pvmi/pvmf/include/pvmi_config_and_capability_observer.h
index dc521d5..1e475ac 100644
--- a/pvmi/pvmf/include/pvmi_config_and_capability_observer.h
+++ b/pvmi/pvmf/include/pvmi_config_and_capability_observer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_config_and_capability_utils.h b/pvmi/pvmf/include/pvmi_config_and_capability_utils.h
index 0778679..c1d73c6 100644
--- a/pvmi/pvmf/include/pvmi_config_and_capability_utils.h
+++ b/pvmi/pvmf/include/pvmi_config_and_capability_utils.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@
 {
     public:
         PvmiCapabilityAndConfigPortFormatImpl()
-                : iFormat(PVMF_FORMAT_UNKNOWN)
+                : iFormat(PVMF_MIME_FORMAT_UNKNOWN)
         {}
 
         virtual ~PvmiCapabilityAndConfigPortFormatImpl() {};
diff --git a/pvmi/pvmf/include/pvmi_data_stream_interface.h b/pvmi/pvmf/include/pvmi_data_stream_interface.h
index 670cf12..f52c5ba 100644
--- a/pvmi/pvmf/include/pvmi_data_stream_interface.h
+++ b/pvmi/pvmf/include/pvmi_data_stream_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_datastreamsyncinterface_ref_factory.h b/pvmi/pvmf/include/pvmi_datastreamsyncinterface_ref_factory.h
new file mode 100644
index 0000000..8db1fa8
--- /dev/null
+++ b/pvmi/pvmf/include/pvmi_datastreamsyncinterface_ref_factory.h
@@ -0,0 +1,60 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMI_DATASTREAMSYNCINTERFACE_REF_FACTORY_H_INCLUDED
+#define PVMI_DATASTREAMSYNCINTERFACE_REF_FACTORY_H_INCLUDED
+
+#ifndef OSCL_BASE_H_INCLUDED
+#include "oscl_base.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+#ifndef PVMI_DATASTREAMUSER_INTERFACE_H_INCLUDED
+#include "pvmi_datastreamuser_interface.h"
+#endif
+
+class PVMIDataStreamSyncInterfaceRefFactory : public PVMFDataStreamFactory
+{
+    public:
+        OSCL_IMPORT_REF PVMIDataStreamSyncInterfaceRefFactory(OSCL_wString& aFileName);
+        OSCL_IMPORT_REF PVMIDataStreamSyncInterfaceRefFactory(OsclFileHandle* aFileHandle);
+        OSCL_IMPORT_REF virtual ~PVMIDataStreamSyncInterfaceRefFactory();
+
+        // From PVMFDataStreamFactory(currently typedef'ed to PVMFCPMPluginAccessInterfaceFactory)
+        PVMFStatus QueryAccessInterfaceUUIDs(Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids);
+        PVInterface* CreatePVMFCPMPluginAccessInterface(PVUuid& aUuid);
+        void DestroyPVMFCPMPluginAccessInterface(PVUuid& aUuid, PVInterface* aPtr);
+
+        // From PVInterface
+        void addRef();
+        void removeRef();
+        bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
+
+    private:
+        OSCL_wHeapString<OsclMemAllocator> iFileName;
+        OsclFileHandle* iFileHandle;
+};
+
+#endif // PVMI_DATASTREAMSYNCINTERFACE_REF_FACTORY_H_INCLUDED
+
+
+
+
diff --git a/pvmi/pvmf/include/pvmi_datastreamsyncinterface_ref_impl.h b/pvmi/pvmf/include/pvmi_datastreamsyncinterface_ref_impl.h
new file mode 100644
index 0000000..8cf1905
--- /dev/null
+++ b/pvmi/pvmf/include/pvmi_datastreamsyncinterface_ref_impl.h
@@ -0,0 +1,177 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVMI_DATASTREAMSYNCINTERFACE_REF_IMPL_H_INCLUDED
+#define PVMI_DATASTREAMSYNCINTERFACE_REF_IMPL_H_INCLUDED
+
+#ifndef OSCL_TYPES_H_INCLUDED
+#include "oscl_types.h"
+#endif
+#ifndef OSCL_FILE_IO_H_INCLUDED
+#include "oscl_file_io.h"
+#endif
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
+#include "oscl_string_containers.h"
+#endif
+#ifndef PVLOGGER_H_INCLUDED
+#include "pvlogger.h"
+#endif
+#ifndef PVMI_DATA_STREAM_INTERFACE_H_INCLUDED
+#include "pvmi_data_stream_interface.h"
+#endif
+
+class PVMIDataStreamSyncInterfaceRefImpl : public PVMIDataStreamSyncInterface
+{
+    public:
+        OSCL_IMPORT_REF static PVMIDataStreamSyncInterface* CreateDataStreamSyncInterfaceRefImpl(OSCL_wString& aFileName);
+        OSCL_IMPORT_REF static PVMIDataStreamSyncInterface* CreateDataStreamSyncInterfaceRefImpl(OsclFileHandle* aFileHandle);
+        OSCL_IMPORT_REF static void DestroyDataStreamSyncInterfaceRefImpl(PVMIDataStreamSyncInterface* aInterface);
+
+        // From PVInterface
+        void addRef() {};
+
+        void removeRef() {};
+
+        OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid,
+                                            PVInterface*& iface);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus OpenSession(PvmiDataStreamSession& aSessionID,
+                                         PvmiDataStreamMode aMode,
+                                         bool nonblocking = false);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus CloseSession(PvmiDataStreamSession aSessionID);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamRandomAccessType QueryRandomAccessCapability();
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus QueryReadCapacity(PvmiDataStreamSession aSessionID,
+                                               uint32& capacity);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamCommandId RequestReadCapacityNotification(PvmiDataStreamSession aSessionID,
+                PvmiDataStreamObserver& observer,
+                uint32 capacity,
+                OsclAny* aContextData = NULL);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus QueryWriteCapacity(PvmiDataStreamSession aSessionID,
+                                                uint32& capacity);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamCommandId RequestWriteCapacityNotification(PvmiDataStreamSession aSessionID,
+                PvmiDataStreamObserver& observer,
+                uint32 capacity,
+                OsclAny* aContextData = NULL);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamCommandId CancelNotification(PvmiDataStreamSession aSessionID,
+                PvmiDataStreamObserver& observer,
+                PvmiDataStreamCommandId aID,
+                OsclAny* aContextData = NULL);
+
+        PvmiDataStreamStatus CancelNotificationSync(PvmiDataStreamSession aSessionID)
+        {
+            OSCL_UNUSED_ARG(aSessionID);
+            return PVDS_NOT_SUPPORTED;
+        }
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus Read(PvmiDataStreamSession aSessionID,
+                                  uint8* buffer,
+                                  uint32 size,
+                                  uint32& numelements);
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus Write(PvmiDataStreamSession aSessionID,
+                                   uint8* buffer,
+                                   uint32 size,
+                                   uint32& numelements);
+        PvmiDataStreamStatus Write(PvmiDataStreamSession aSessionID,
+                                   OsclRefCounterMemFrag* aFrag,
+                                   uint32& numelements)
+        {
+            OSCL_UNUSED_ARG(aSessionID);
+            OSCL_UNUSED_ARG(aFrag);
+            OSCL_UNUSED_ARG(numelements);
+            return PVDS_NOT_SUPPORTED;
+        }
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus Seek(PvmiDataStreamSession aSessionID,
+                                  int32 offset,
+                                  PvmiDataStreamSeekType origin);
+
+        OSCL_IMPORT_REF
+        uint32 GetCurrentPointerPosition(PvmiDataStreamSession aSessionID) ;
+
+        OSCL_IMPORT_REF
+        PvmiDataStreamStatus Flush(PvmiDataStreamSession aSessionID);
+
+        void SetContentLength(uint32 aContentLength)
+        {
+            OSCL_UNUSED_ARG(aContentLength);
+        }
+
+        uint32 GetContentLength()
+        {
+            return 0;
+        }
+
+        uint32 QueryBufferingCapacity()
+        {
+            return 0;
+        }
+
+        PvmiDataStreamStatus SetSourceRequestObserver(PvmiDataStreamRequestObserver& aObserver)
+        {
+            OSCL_UNUSED_ARG(aObserver);
+            return PVDS_NOT_SUPPORTED;
+        }
+
+        void SourceRequestCompleted(const PVMFCmdResp& aResponse)
+        {
+            OSCL_UNUSED_ARG(aResponse);
+        }
+
+        PvmiDataStreamStatus MakePersistent(int32 aOffset, uint32 aSize)
+        {
+            OSCL_UNUSED_ARG(aOffset);
+            OSCL_UNUSED_ARG(aSize);
+            return PVDS_NOT_SUPPORTED;
+        }
+
+
+    private:
+        PVMIDataStreamSyncInterfaceRefImpl(OSCL_wString& aFileName);
+        PVMIDataStreamSyncInterfaceRefImpl(OsclFileHandle* aFileHandle);
+        virtual ~PVMIDataStreamSyncInterfaceRefImpl();
+
+        PvmiDataStreamSession iSessionID;
+        OsclFileHandle* iFileHandle;
+        OSCL_wHeapString<OsclMemAllocator> iFileName;
+        Oscl_File *iFileObject;
+        int32 iFileNumBytes;
+        Oscl_FileServer iFs;
+        PVLogger* iLogger;
+};
+
+#endif //PVMI_DATASTREAMSYNCINTERFACE_REF_IMPL_H_INCLUDED
+
+
diff --git a/pvmi/pvmf/include/pvmi_datastreamuser_interface.h b/pvmi/pvmf/include/pvmi_datastreamuser_interface.h
index 1e68845..982c624 100644
--- a/pvmi/pvmf/include/pvmi_datastreamuser_interface.h
+++ b/pvmi/pvmf/include/pvmi_datastreamuser_interface.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_drm_kvp.h b/pvmi/pvmf/include/pvmi_drm_kvp.h
index ed56a04..29c17f6 100644
--- a/pvmi/pvmf/include/pvmi_drm_kvp.h
+++ b/pvmi/pvmf/include/pvmi_drm_kvp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_fileio_kvp.h b/pvmi/pvmf/include/pvmi_fileio_kvp.h
index 591cc9f..2b3a2c3 100644
--- a/pvmi/pvmf/include/pvmi_fileio_kvp.h
+++ b/pvmi/pvmf/include/pvmi_fileio_kvp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@
 
 /*
  * Select native file access mode, for systems that have more than one type of file
- * access.
+ * access.  Values for Symbian, RFile=0, RFileBuf=1.
  */
 #define PVMI_FILEIO_NATIVE_ACCESS_MODE "fileio/native-access-mode"
 #define PVMI_FILEIO_NATIVE_ACCESS_MODE_VALUE "fileio/native-access-mode;valtype=uint32"
diff --git a/pvmi/pvmf/include/pvmi_kvp.h b/pvmi/pvmf/include/pvmi_kvp.h
index ce80964..55a1898 100644
--- a/pvmi/pvmf/include/pvmi_kvp.h
+++ b/pvmi/pvmf/include/pvmi_kvp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,6 +46,8 @@
 #define PVMI_KVPTYPE_AGGREGATE_STRING "aggregate"
 static const char PVMI_KVPTYPE_AGGREGATE_STRING_CONSTCHAR[] = PVMI_KVPTYPE_AGGREGATE_STRING;
 
+#include "oscl_string_containers.h"
+
 typedef enum
 {
     PVMI_KVPATTR_UNKNOWN,
@@ -308,6 +310,7 @@
             _latitude = 0;
             _altitude = 0;
             _langCode = 0;
+            Lang_code = NULL;
         }
         virtual ~PvmfAssetInfo3GPPLocationStruct()
         {
@@ -319,11 +322,13 @@
             _latitude = 0;
             _altitude = 0;
             _langCode = 0;
+            Lang_code = NULL;
         }
 
         oscl_wchar* _location_name;
         oscl_wchar* _astronomical_body;
         oscl_wchar* _additional_notes;
+        OSCL_HeapString<OsclMemAllocator> Lang_code;
         uint8	_role;
 
         uint32	_longitude;//fixed-point 16.16 number indicating the longitude in degrees.
@@ -345,10 +350,10 @@
 // Capability mime strings
 #define INPUT_FORMATS_CAP_QUERY ".../input_formats;attr=cap"
 #define INPUT_FORMATS_CUR_QUERY ".../input_formats;attr=cur"
-#define INPUT_FORMATS_VALTYPE ".../input_formats;valtype=uint32"
+#define INPUT_FORMATS_VALTYPE ".../input_formats;valtype=char*"
 #define OUTPUT_FORMATS_CAP_QUERY ".../output_formats;attr=cap"
 #define OUTPUT_FORMATS_CUR_QUERY ".../output_formats;attr=cur"
-#define OUTPUT_FORMATS_VALTYPE ".../output_formats;valtype=uint32"
+#define OUTPUT_FORMATS_VALTYPE ".../output_formats;valtype=char*"
 
 #define VIDEO_INPUT_WIDTH_CAP_QUERY ".../input/width;attr=cap"
 #define VIDEO_INPUT_WIDTH_CAP_RANGE ".../input/width;valtype=range_uint32"
@@ -413,6 +418,15 @@
 #define TIMED_TEXT_OUTPUT_CONFIG_INFO_CUR_QUERY ".../output/timedtext;attr=cur"
 #define TIMED_TEXT_OUTPUT_CONFIG_INFO_CUR_VALUE ".../output/timedtext;valtype=key_specific_value"
 
+// key for format type for any type of media
+#define PVMF_FORMAT_TYPE_VALUE_KEY "x-pvmf/media/format-type;valtype=char*"
+
+// key for audio decoder format
+#define PVMF_AUDIO_DEC_FORMAT_TYPE_VALUE_KEY "x-pvmf/audio/decoder/format-type;valtype=char*"
+
+// key for video decoder format
+#define PVMF_VIDEO_DEC_FORMAT_TYPE_VALUE_KEY "x-pvmf/video/decoder/format-type;valtype=char*"
+
 // Keys for format specific info for any type of media
 #define PVMF_FORMAT_SPECIFIC_INFO_KEY "x-pvmf/media/format_specific_info;valtype=key_specific_value"
 
@@ -430,10 +444,11 @@
 // Key for signalling max number of outstanding media msgs
 #define PVMF_DATAPATH_PORT_MAX_NUM_MEDIA_MSGS_KEY "x-pvmf/datapath/port/max-num-media-msgs;valtype=uint32"
 
+
 // Keys for media output components -- Audio
 //
 //audio format strings as defined in pvmf_format_type.h
-#define MOUT_AUDIO_FORMAT_KEY "x-pvmf/audio/render/media_format;valtype=uint32"
+#define MOUT_AUDIO_FORMAT_KEY "x-pvmf/audio/render/media_format;valtype=char*"
 //audio sampling rate in Hz
 #define MOUT_AUDIO_SAMPLING_RATE_KEY "x-pvmf/audio/render/sampling_rate;valtype=uint32"
 //audio number of channels (1 for mono, 2 for stereo)
@@ -445,9 +460,9 @@
 // Keys for media output components -- Video
 //
 //video format strings as defined in pvmf_format_type.h
-#define MOUT_VIDEO_FORMAT_KEY "x-pvmf/video/render/media_format;valtype=uint32"
+#define MOUT_VIDEO_FORMAT_KEY "x-pvmf/video/render/media_format;valtype=char*"
 // video sub-format (e.g. YUV420-planar etc.)
-#define MOUT_VIDEO_SUBFORMAT_KEY "x-pvmf/video/render/media_subformat;valtype=uint32"
+#define MOUT_VIDEO_SUBFORMAT_KEY "x-pvmf/video/render/media_subformat;valtype=char*"
 
 //video dimensions in pixels
 #define MOUT_VIDEO_WIDTH_KEY "x-pvmf/video/render/width;valtype=uint32"
@@ -459,8 +474,9 @@
 #define MOUT_VIDEO_OUTPUT_HEIGHT_KEY "x-pvmf/video/render/output_height;valtype=uint32"
 #define MOUT_VIDEO_DISPLAY_ROTATION_KEY "x-pvmf/video/render/display_rotation;valtype=uint32"
 #define MOUT_VIDEO_DISPLAY_BITMAP_KEY "x-pvmf/video/render/display_bitmap;valtype=uint32"
-//AVC Encoder
-#define PVMF_AVC_ENCODER_ENCODINGMODE_KEY	"x-pvmf/avc/encoder/encoding_mode;valtype=uint32"
+//video vol header info
+#define MOUT_VIDEO_VOL_HEADER_KEY "x-pvmf/video/vol_header;valtype=uint8*"
+
 
 // Keys for media output components -- Text
 //
@@ -470,6 +486,31 @@
 // Key for media output rate
 #define MOUT_MEDIAXFER_OUTPUT_RATE "x-pvmf/mediaxfer/output/rate;type=rel;valtype=int32"
 
+
+// Keys for media input components -- Audio
+//
+//audio sampling rate in Hz
+#define MIN_AUDIO_SAMPLING_RATE_KEY "x-pvmf/encoder/audio/sampling_rate;valtype=uint32"
+//audio number of channels (1 for mono, 2 for stereo)
+#define MIN_AUDIO_NUM_CHANNELS_KEY "x-pvmf/encoder/audio/channels;valtype=uint32"
+
+// Keys for media input components -- Video
+//
+// Keys for media output components -- Text
+//
+#define TEXT_INPUT_WIDTH_CUR_QUERY ".../input/width;attr=cur"
+#define TEXT_INPUT_WIDTH_CUR_VALUE ".../input/width;valtype=uint32"
+#define TEXT_INPUT_HEIGHT_CUR_QUERY ".../input/height;attr=cur"
+#define TEXT_INPUT_HEIGHT_CUR_VALUE ".../input/height;valtype=uint32"
+
+//AVC Encoder
+#define PVMF_AVC_ENCODER_ENCODINGMODE_KEY	"x-pvmf/encoder/video/encoding_mode;valtype=uint32"
+
+#define INPUT_TIMESCALE_CUR_QUERY ".../input/timescale;attr=cur"
+#define INPUT_TIMESCALE_CUR_VALUE ".../input/timescale;valtype=uint32"
+
+
+
 #endif // PVMI_KVP_H_INCLUDED
 
 
diff --git a/pvmi/pvmf/include/pvmi_kvp_util.h b/pvmi/pvmf/include/pvmi_kvp_util.h
index fd91772..abace20 100644
--- a/pvmi/pvmf/include/pvmi_kvp_util.h
+++ b/pvmi/pvmf/include/pvmi_kvp_util.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -106,6 +106,7 @@
                 const char* aKeyTypeString,
                 OsclAny* aValue,
                 char* aMiscKeyParam = NULL);
+
 };
 
 #endif //PVMI_KVP_UTIL_H_INCLUDED
diff --git a/pvmi/pvmf/include/pvmi_media_io_clock_extension.h b/pvmi/pvmf/include/pvmi_media_io_clock_extension.h
index a393edc..9922812 100644
--- a/pvmi/pvmf/include/pvmi_media_io_clock_extension.h
+++ b/pvmi/pvmf/include/pvmi_media_io_clock_extension.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,9 +29,12 @@
 #ifndef OSCL_STRING_H_INCLUDED
 #include "oscl_string.h"
 #endif
-#ifndef OSCL_CLOCK_H_INCLUDED
-#include "oscl_clock.h"
+
+#ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
+#include "pvmf_media_clock.h"
 #endif
+
+
 #ifndef PV_UUID_H_INCLUDED
 #include "pv_uuid.h"
 #endif
@@ -75,7 +78,7 @@
          * @param clockVal the Instance of OSCL Clock
          * @return Completion status of this method.
          */
-        virtual PVMFStatus SetClock(OsclClock *clockVal) = 0;
+        virtual PVMFStatus SetClock(PVMFMediaClock *clockVal) = 0;
 };
 
 #endif // PVMI_MEDIA_IO_CLOCK_EXTENSION_H_INCLUDED
diff --git a/pvmi/pvmf/include/pvmi_media_io_observer.h b/pvmi/pvmf/include/pvmi_media_io_observer.h
index 7927ce9..93bb0e0 100644
--- a/pvmi/pvmf/include/pvmi_media_io_observer.h
+++ b/pvmi/pvmf/include/pvmi_media_io_observer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,8 @@
          * @param aResponse Completion response containing status and other data
          */
         virtual void RequestCompleted(const PVMFCmdResp& aResponse) = 0;
+        virtual void ReportErrorEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL) = 0;
+        virtual void ReportInfoEvent(PVMFEventType aEventType, PVInterface* aExtMsg = NULL) = 0;
 };
 
 #endif // PVMI_MEDIA_IO_OBSERVER_H_INCLUDED
diff --git a/pvmi/pvmf/include/pvmi_media_transfer.h b/pvmi/pvmf/include/pvmi_media_transfer.h
index 9ec64f0..e859808 100644
--- a/pvmi/pvmf/include/pvmi_media_transfer.h
+++ b/pvmi/pvmf/include/pvmi_media_transfer.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_mio_control.h b/pvmi/pvmf/include/pvmi_mio_control.h
index 6608a35..a8eeb10 100644
--- a/pvmi/pvmf/include/pvmi_mio_control.h
+++ b/pvmi/pvmf/include/pvmi_mio_control.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmi_port_config_kvp.h b/pvmi/pvmf/include/pvmi_port_config_kvp.h
index d01a66f..5884fad 100644
--- a/pvmi/pvmf/include/pvmi_port_config_kvp.h
+++ b/pvmi/pvmf/include/pvmi_port_config_kvp.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/include/pvmp4h263encextension.h b/pvmi/pvmf/include/pvmp4h263encextension.h
deleted file mode 100644
index 488c3fd..0000000
--- a/pvmi/pvmf/include/pvmp4h263encextension.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**
- * @file pvmp4h263encextension.h
- */
-
-#ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-#define PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-
-#ifndef OSCL_BASE_H_INCLUDED
-#include "oscl_base.h"
-#endif
-#ifndef OSCL_STRING_H_INCLUDED
-#include "oscl_string.h"
-#endif
-#ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED
-#include "oscl_refcounter_memfrag.h"
-#endif
-#ifndef PV_UUID_H_INCLUDED
-#include "pv_uuid.h"
-#endif
-#ifndef PV_INTERFACE_H_INCLUDED
-#include "pv_interface.h"
-#endif
-
-// Forward declaration
-template <class T> class OsclSharedPtr;
-
-#define PVMp4H263EncExtensionUUID PVUuid(0xc4737ade,0xa002,0x4632,0x95,0x1a,0x9c,0xa7,0xd6,0x3a,0xcd,0x2b)
-
-/**
- * Enumerated list of supported rate control types
- */
-typedef enum
-{
-    PVMFVEN_RATE_CONTROL_CONSTANT_Q,
-    PVMFVEN_RATE_CONTROL_CBR,
-    PVMFVEN_RATE_CONTROL_VBR
-} PVMFVENRateControlType;
-
-////////////////////////////////////////////////////////////////////////////
-class PVMp4H263EncExtensionInterface : public PVInterface
-{
-    public:
-        /** Increment reference counter for this interface. */
-        virtual void addRef() = 0;
-
-        /** Decrement reference counter for this interface. */
-        virtual void removeRef() = 0;
-
-        /**
-         * Query for a pointer to an instance of the interface specified by the UUID.
-         *
-         * @param uuid UUID of the interface to be queried.
-         * @param iface Output parameter where a pointer to an instance of the requested
-         * interface is stored if the interface is supported.
-         * @return True if successful, else false.
-         */
-        virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface) = 0;
-
-        /**
-         * Sets the number of layers in encoded output.
-         * @param aNumLayers Number of layers.
-         * @return True if successful, else false.
-         */
-        virtual bool SetNumLayers(uint32 aNumLayers) = 0;
-
-        /**
-         * Sets the bitrate of encoded output for the specified layer.
-         * @param aLayer Layer ID
-         * @param aBitRate Bitrate for the specified layer in bits per second.
-         * @return True if successful, else false.
-         */
-        virtual bool SetOutputBitRate(uint32 aLayer, uint32 aBitRate) = 0;
-
-        /**
-         * Sets the frame size of encoded output for the specified layer.
-         * @param aLayer Layer ID
-         * @param aWidth Width for the specified layer in pixels.
-         * @param aHeight Height for the specified layer in pixels.
-         * @return True if successful, else false.
-         */
-        virtual bool SetOutputFrameSize(uint32 aLayer, uint32 aWidth, uint32 aHeight) = 0;
-
-        /**
-         * Sets the frame rate of encoded output for the specified layer.
-         * @param aLayer Layer ID
-         * @param aFrameRate Frame rate for the specified layer in frames per second.
-         * @return True if successful, else false.
-         */
-        virtual bool SetOutputFrameRate(uint32 aLayer, OsclFloat aFrameRate) = 0;
-
-        /**
-         * Sets the segment size of encoded output for the specified layer
-         * @param aLayer Layer ID
-         * @param aSizeBytes Segment size in bytes.
-         * @return True if successful, else false.
-         */
-        virtual bool SetSegmentTargetSize(uint32 aLayer, uint32 aSizeBytes) = 0;
-
-        /**
-         * Sets the rate control type to be used by encoder for the specified layer.
-         * @param aLayer Layer ID
-         * @param aRateControl Type of rate control to be used by encoder.
-         * @return True if successful, else false.
-         */
-        virtual bool SetRateControlType(uint32 aLayer, PVMFVENRateControlType aRateControl) = 0;
-
-        /**
-         * Enable or disable data partitioning in the encoded MPEG4 output.
-         * This menthod is valid only when the codec type is set to PVMFVEN_CODEC_M4V.
-         *
-         * @param aDataPartitioning Set to true to enable data partitioning, set to false
-         * to disable data partitioning.
-         * @return True if successful, else false
-         */
-        virtual bool SetDataPartitioning(bool aDataPartitioning) = 0;
-
-        /**
-         * Enable or disable reversible VLC in the encoded MPEG4 output.
-         * This menthod is valid only when the codec type is set to PVMFVEN_CODEC_M4V.
-         *
-         * @param aRVLC Set to true to enable RVLC, set to false to disable
-         * @return True if successful, else false
-         */
-        virtual bool SetRVLC(bool aRVLC) = 0;
-
-        /**
-         * Sets the I-Frame refresh rate of the encoded output.
-         *
-         * @param aIFrameInterval I-Frame rate in seconds per I-Frame
-         * @return True if successful, else false
-         */
-        virtual bool SetIFrameInterval(uint32 aIFrameInterval) = 0;
-
-        /**
-         * Retrieves VOL header for the M4V bitstream.
-         *
-         * This method is valid only when codec type is set to PVMFVEN_CODEC_M4V. This method
-         * would retrieve the VOL header for the M4V bitstream using encoder parameters
-         * specified at the time of the method call.  The VOL header is stored in the
-         * memory fragment provided by the caller.
-         *
-         * @param aVolHeader Memory fragment to store the VOL header
-         * @return True if VOL header is successfully retrieved, else false.
-         */
-        virtual bool GetVolHeader(OsclRefCounterMemFrag& aVolHeader) = 0;
-
-        /**
-         * Requests the encoder to encode the next frame as an I-Frame.  This menthod is valid
-         * only when the node is in EPVMFNodeStarted state. If successful, the next encoded
-         * frame will be an I-Frame.
-         *
-         * @return True for success, else false
-         */
-        virtual bool RequestIFrame() = 0;
-
-        /**
-         * Sets the type of encoder use.
-         *
-         * @param aCodec Codec type.
-         * @return True for success, else false
-         */
-        virtual bool SetCodec(PVMFFormatType aCodec)
-        {
-            OSCL_UNUSED_ARG(aCodec);
-            return false;
-        }
-};
-#endif // PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
-
-
-
-
-
diff --git a/pvmi/pvmf/src/pvmf_basic_errorinfomessage.cpp b/pvmi/pvmf/src/pvmf_basic_errorinfomessage.cpp
index 3ff5bed..e6d25ff 100644
--- a/pvmi/pvmf/src/pvmf_basic_errorinfomessage.cpp
+++ b/pvmi/pvmf/src/pvmf_basic_errorinfomessage.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  */
 
 #include "pvmf_basic_errorinfomessage.h"
-
+#include "oscl_mem.h"
 
 OSCL_EXPORT_REF PVMFBasicErrorInfoMessage::PVMFBasicErrorInfoMessage() :
         iEventCode(0),
diff --git a/pvmi/pvmf/src/pvmf_duration_infomessage.cpp b/pvmi/pvmf/src/pvmf_duration_infomessage.cpp
index 4916c77..306aef7 100644
--- a/pvmi/pvmf/src/pvmf_duration_infomessage.cpp
+++ b/pvmi/pvmf/src/pvmf_duration_infomessage.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
  */
 
 #include "pvmf_duration_infomessage.h"
-
+#include "oscl_mem.h"
 
 OSCL_EXPORT_REF PVMFDurationInfoMessage::PVMFDurationInfoMessage() :
         iEventCode(0),
diff --git a/pvmi/pvmf/src/pvmf_format_type.cpp b/pvmi/pvmf/src/pvmf_format_type.cpp
index acc086b..b83ec19 100644
--- a/pvmi/pvmf/src/pvmf_format_type.cpp
+++ b/pvmi/pvmf/src/pvmf_format_type.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,554 +26,161 @@
 // Define entry point for this DLL
 OSCL_DLL_ENTRY_POINT_DEFAULT()
 
-
-OSCL_EXPORT_REF PvmfFormatIndex GetFormatIndex(char* mime_string, PvmfMediaTypeIndex aHint)
+OSCL_EXPORT_REF bool PVMFFormatType::isCompressed() const
 {
-    if (!mime_string)
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM8) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM16) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM16_BE) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ULAW) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ALAW) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV420) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB8) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB12) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB16) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB24) == 0))
     {
-        return PVMF_FORMAT_UNKNOWN;
+        // all uncompressed formats
+        return false;
     }
 
-    //Parse to the last type component in the mimestring.
-    //That way this routine can handle input like
-    //  ".../audio/AMR" or ".../video/YUV420"
-    char* lastcomp = mime_string;
-#if 0
-    int numcomps = pv_mime_string_compcnt(mime_string);
-    if (numcomps <= 0)
-    {
-        return PVMF_FORMAT_UNKNOWN;
-    }
-    if (numcomps > 1)
-    {
-        int len = pv_mime_string_extract_type(numcomps, mime_string, lastcomp);
-        if (len <= 0)
-        {
-            return PVMF_FORMAT_UNKNOWN;
-        }
-    }
-#endif
-
-    //compare last component to all the recognized formats.
-
-    //uncompressed audio...
-    if (aHint == PVMF_FORMAT_UNKNOWN ||
-            aHint == PVMF_UNCOMPRESSED_AUDIO_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_PCM8) == 0)
-        {
-            return PVMF_PCM8;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_PCM16) == 0)
-        {
-            return PVMF_PCM16;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_PCM16_BE) == 0)
-        {
-            return PVMF_PCM16_BE;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ALAW) == 0)
-        {
-            return PVMF_PCM_ALAW;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ULAW) == 0)
-        {
-            return PVMF_PCM_ULAW;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_PCM) == 0)
-        {
-            return PVMF_PCM;
-        }
-    }
-
-    //uncompressed video...
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_UNCOMPRESSED_VIDEO_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_YUV420) == 0)
-        {
-            return PVMF_YUV420;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_YUV422) == 0)
-        {
-            return PVMF_YUV422;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_RGB8) == 0)
-        {
-            return PVMF_RGB8;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_RGB12) == 0)
-        {
-            return PVMF_RGB12;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_RGB16) == 0)
-        {
-            return PVMF_RGB16;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_RGB24) == 0)
-        {
-            return PVMF_RGB24;
-        }
-    }
-
-    //compressed audio...
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_COMPRESSED_AUDIO_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_AMR) == 0)
-        {
-            return PVMF_AMR_IETF_COMBINED;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_AMRWB) == 0)
-        {
-            return PVMF_AMRWB_IETF_PAYLOAD;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_AMR_IETF) == 0)
-        {
-            return PVMF_AMR_IETF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_AMRWB_IETF) == 0)
-        {
-            return PVMF_AMRWB_IETF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_AMR_IF2) == 0)
-        {
-            return PVMF_AMR_IF2;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_EVRC) == 0)
-        {
-            return PVMF_EVRC;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_MP3) == 0)
-        {
-            return PVMF_MP3;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ADIF) == 0)
-        {
-            return PVMF_ADIF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ADTS) == 0)
-        {
-            return PVMF_ADTS;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_LATM) == 0)
-        {
-            return PVMF_LATM;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_MPEG4_AUDIO) == 0)
-        {
-            return PVMF_MPEG4_AUDIO;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_G723) == 0)
-        {
-            return PVMF_G723;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_G726) == 0)
-        {
-            return PVMF_G726;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_WMA) == 0)
-        {
-            return PVMF_WMA;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ASF_AMR) == 0)
-        {
-            return PVMF_ASF_AMR;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_REAL_AUDIO) == 0)
-        {
-            return PVMF_REAL_AUDIO;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_3640) == 0)
-        {
-            return PVMF_MPEG4_AUDIO;
-        }
-
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ASF_MPEG4_AUDIO) == 0)
-        {
-            return PVMF_ASF_MPEG4_AUDIO;
-        }
-    }
-
-    //compressed video...
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_COMPRESSED_VIDEO_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_M4V) == 0)
-        {
-            return PVMF_M4V;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_H2631998) == 0
-                 || pv_mime_strcmp(lastcomp, PVMF_MIME_H2632000) == 0)
-        {
-            return PVMF_H263;//2 to 1 mapping.
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_H264_VIDEO_RAW) == 0)
-        {
-            return PVMF_H264_RAW;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_H264_VIDEO_MP4) == 0)
-        {
-            return PVMF_H264_MP4;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_H264_VIDEO) == 0)
-        {
-            return PVMF_H264;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_WMV) == 0)
-        {
-            return PVMF_WMV;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_REAL_VIDEO) == 0)
-        {
-            return PVMF_RV;
-        }
-    }
-
-    //image...
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_IMAGE_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_M4V_IMAGE) == 0)
-        {
-            return PVMF_M4V_IMAGE;
-        }
-    }
-
-    //multiplexed, stream or file formats...
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_MULTIPLEXED_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_MPEG4FF) == 0)
-        {
-            return PVMF_MPEG4FF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_H223) == 0)
-        {
-            return PVMF_H223;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_M4V_IMAGE) == 0)
-        {
-            return PVMF_M4V_IMAGE;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_RTP) == 0)
-        {
-            return PVMF_RTP;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_AMRFF) == 0)
-        {
-            return PVMF_AMRFF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_AACFF) == 0)
-        {
-            return PVMF_AACFF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_MP3FF) == 0)
-        {
-            return PVMF_MP3FF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_WAVFF) == 0)
-        {
-            return PVMF_WAVFF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_ASFFF) == 0)
-        {
-            return PVMF_ASFFF;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_RMFF) == 0)
-        {
-            return PVMF_RMFF;
-        }
-    }
-
-    //raw data formats...
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_DATASTREAM_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_8BIT_RAW) == 0)
-        {
-            return PVMF_8BIT_RAW;
-        }
-    }
-
-    // pvmf data source formats
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_DATA_SOURCE_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_RTSP_URL) == 0)
-        {
-            return PVMF_DATA_SOURCE_RTSP_URL;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_HTTP_URL) == 0)
-        {
-            return PVMF_DATA_SOURCE_HTTP_URL;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_SDP_FILE) == 0)
-        {
-            return PVMF_DATA_SOURCE_SDP_FILE;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_PVX_FILE) == 0)
-        {
-            return PVMF_DATA_SOURCE_PVX_FILE;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL) == 0)
-        {
-            return PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) == 0)
-        {
-            return PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
-        }
-        else if (pv_mime_strcmp(lastcomp, PVMF_MIME_DATA_SOURCE_RTP_PACKET_SOURCE) == 0)
-        {
-            return PVMF_DATA_SOURCE_RTP_PACKET_SOURCE;
-        }
-    }
-
-    //text.
-    if (aHint == PVMF_FORMAT_UNKNOWN
-            || aHint == PVMF_TEXT_FORMAT)
-    {
-        if (pv_mime_strcmp(lastcomp, PVMF_MIME_3GPP_TIMEDTEXT) == 0)
-        {
-            return PVMF_3GPP_TIMEDTEXT;
-        }
-    }
-
-    //everything else...
-    return PVMF_FORMAT_UNKNOWN;
-}
-
-/* Returns the high level media type index of this format type */
-OSCL_EXPORT_REF PvmfMediaTypeIndex GetMediaTypeIndex(PvmfFormatIndex aFormatIndex)
-{
-    if (aFormatIndex >= PVMF_FIRST_UNCOMPRESSED_AUDIO &&
-            aFormatIndex <= PVMF_LAST_UNCOMPRESSED_AUDIO)
-    {
-        return PVMF_UNCOMPRESSED_AUDIO_FORMAT;
-    }
-    else if (aFormatIndex >= PVMF_FIRST_COMPRESSED_AUDIO &&
-             aFormatIndex <= PVMF_LAST_COMPRESSED_AUDIO)
-    {
-        return PVMF_COMPRESSED_AUDIO_FORMAT;
-    }
-    else if (aFormatIndex >= PVMF_FIRST_UNCOMPRESSED_VIDEO &&
-             aFormatIndex <= PVMF_LAST_UNCOMPRESSED_VIDEO)
-    {
-        return PVMF_UNCOMPRESSED_VIDEO_FORMAT;
-    }
-    else if (aFormatIndex >= PVMF_FIRST_COMPRESSED_VIDEO &&
-             aFormatIndex <= PVMF_LAST_COMPRESSED_VIDEO)
-    {
-        return PVMF_COMPRESSED_VIDEO_FORMAT;
-    }
-    else if (aFormatIndex >= PVMF_FIRST_MULTIPLEXED &&
-             aFormatIndex <= PVMF_LAST_MULTIPLEXED)
-    {
-        return PVMF_MULTIPLEXED_FORMAT;
-    }
-    else if (aFormatIndex >= PVMF_FIRST_IMAGE &&
-             aFormatIndex <= PVMF_LAST_IMAGE)
-    {
-        return PVMF_IMAGE_FORMAT;
-    }
-    else if (aFormatIndex > PVMF_FIRST_DATA_SOURCETYPE &&
-             aFormatIndex < PVMF_LAST_DATA_SOURCETYPE)
-    {
-        return PVMF_DATA_SOURCE_FORMAT;
-    }
-    else if (aFormatIndex >= PVMF_FIRST_TEXT &&
-             aFormatIndex <= PVMF_LAST_TEXT)
-    {
-        return PVMF_TEXT_FORMAT;
-    }
-
-    return PVMF_FORMAT_UNKNOWN;
-}
-
-/* This routine returns the mime string corresponding to the format index,
-** of NULL if not recognized.
-*/
-OSCL_EXPORT_REF void GetFormatString(PvmfFormatIndex aFormatIndex, OSCL_String&str)
-{
-    switch (aFormatIndex)
-    {
-        case PVMF_FORMAT_UNKNOWN:
-            str = PVMF_MIME_FORMAT_UNKNOWN;
-            break ;
-
-            //uncompressed audio...
-        case PVMF_PCM8:
-            str = PVMF_MIME_PCM8;
-            break;
-
-        case PVMF_PCM16:
-            str = PVMF_MIME_PCM16;
-            break;
-
-            //uncompressed video...
-        case PVMF_YUV420:
-            str = PVMF_MIME_YUV420;
-            break;
-        case PVMF_YUV422:
-            str = PVMF_MIME_YUV422;
-            break;
-        case PVMF_RGB8:
-            str = PVMF_MIME_RGB8;
-            break;
-        case PVMF_RGB12:
-            str = PVMF_MIME_RGB12;
-            break;
-        case PVMF_RGB16:
-            str = PVMF_MIME_RGB16;
-            break;
-        case PVMF_RGB24:
-            str = PVMF_MIME_RGB24;
-            break;
-
-            //compressed audio...
-        case PVMF_AMR_IETF_COMBINED:
-            str = PVMF_MIME_AMR;
-            break;
-        case PVMF_AMRWB_IETF_PAYLOAD:
-            str = PVMF_MIME_AMRWB;
-            break;
-        case PVMF_AMR_IETF:
-            str = PVMF_MIME_AMR_IETF;
-            break;
-        case PVMF_AMRWB_IETF:
-            str = PVMF_MIME_AMRWB_IETF;
-            break;
-        case PVMF_AMR_IF2:
-            str = PVMF_MIME_AMR_IF2;
-            break;
-        case PVMF_EVRC:
-            str = PVMF_MIME_EVRC;
-            break;
-        case PVMF_MP3:
-            str = PVMF_MIME_MP3;
-            break;
-        case PVMF_ADIF:
-            str = PVMF_MIME_ADIF;
-            break;
-        case PVMF_ADTS:
-            str = PVMF_MIME_ADTS;
-            break;
-        case PVMF_LATM:
-            str = PVMF_MIME_LATM;
-            break;
-        case PVMF_MPEG4_AUDIO:
-            str = PVMF_MIME_MPEG4_AUDIO;
-            break;
-        case PVMF_G723:
-            str = PVMF_MIME_G723;
-            break;
-        case PVMF_G726:
-            str = PVMF_MIME_G726;
-            break;
-        case PVMF_WMA:
-            str = PVMF_MIME_WMA;
-            break;
-        case PVMF_ASF_AMR:
-            str = PVMF_MIME_ASF_AMR;
-            break;
-        case PVMF_REAL_AUDIO:
-            str = PVMF_MIME_REAL_AUDIO;
-            break;
-        case PVMF_ASF_MPEG4_AUDIO:
-            str = PVMF_MIME_ASF_MPEG4_AUDIO;
-            break;
-
-            //compressed video...
-        case PVMF_M4V:
-            str = PVMF_MIME_M4V;
-            break;
-            //case PVMF_H263:str=PVMF_MIME_H2631998;break; //arbitrarily prefer PVMF_MIME_H2632000
-        case PVMF_H263:
-            str = PVMF_MIME_H2632000;
-            break;
-        case PVMF_H264_RAW:
-            str = PVMF_MIME_H264_VIDEO_RAW;
-            break;
-        case PVMF_H264_MP4:
-            str = PVMF_MIME_H264_VIDEO_MP4;
-            break;
-        case PVMF_H264:
-            str = PVMF_MIME_H264_VIDEO;
-            break;
-        case PVMF_WMV:
-            str = PVMF_MIME_WMV;
-            break;
-        case PVMF_RV:
-            str = PVMF_MIME_REAL_VIDEO;
-            break;
-
-            //image...
-        case PVMF_M4V_IMAGE:
-            str = PVMF_MIME_M4V_IMAGE;
-            break;
-
-            //multiplexed, stream or file formats...
-        case PVMF_MPEG4FF:
-            str = PVMF_MIME_MPEG4FF;
-            break;
-        case PVMF_H223:
-            str = PVMF_MIME_H223;
-            break;
-            //case PVMF_M4V_IMAGE:str=PVMF_MIME_M4V_IMAGE;break; //already covered under "image"
-        case PVMF_RTP:
-            str = PVMF_MIME_RTP;
-            break;
-        case PVMF_AMRFF:
-            str = PVMF_MIME_AMRFF;
-            break;
-        case PVMF_MP3FF:
-            str = PVMF_MIME_MP3FF;
-            break;
-        case PVMF_WAVFF:
-            str = PVMF_MIME_WAVFF;
-            break;
-        case PVMF_ASFFF:
-            str = PVMF_MIME_ASFFF;
-            break;
-        case PVMF_RMFF:
-            str = PVMF_MIME_RMFF;
-            break;
-
-            //raw data formats...
-        case PVMF_8BIT_RAW:
-            str = PVMF_MIME_8BIT_RAW;
-            break;
-
-            // pvmf data source formats
-        case PVMF_DATA_SOURCE_RTSP_URL:
-            str = PVMF_MIME_DATA_SOURCE_RTSP_URL;
-            break;
-        case PVMF_DATA_SOURCE_HTTP_URL:
-            str = PVMF_MIME_DATA_SOURCE_HTTP_URL;
-            break;
-        case PVMF_DATA_SOURCE_SDP_FILE:
-            str = PVMF_MIME_DATA_SOURCE_SDP_FILE;
-            break;
-        case PVMF_DATA_SOURCE_PVX_FILE:
-            str = PVMF_MIME_DATA_SOURCE_PVX_FILE;
-            break;
-        case PVMF_DATA_SOURCE_MS_HTTP_STREAMING_URL:
-            str = PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL;
-            break;
-        case PVMF_DATA_SOURCE_REAL_HTTP_CLOAKING_URL:
-            str = PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL;
-            break;
-
-            // misc data formats
-        case PVMF_3GPP_TIMEDTEXT:
-            str = PVMF_MIME_3GPP_TIMEDTEXT;
-            break;
-
-        default:
-            str = PVMF_MIME_FORMAT_UNKNOWN;
-            break;
-    }
+    return true;
 }
 
 
+OSCL_EXPORT_REF bool PVMFFormatType::isAudio() const
+{
+    //Standard audio media types from IANA.org
+    if (oscl_strstr(iMimeStr.c_str(), "audio/") != NULL)
+        return true;
+
+    //PV internal audio media types
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_PCM16_BE) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMR_IETF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMRWB_IETF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMR_IF2) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ADIF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ADTS) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AAC_SIZEHDR) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MPEG4_AUDIO) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_G726) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ASF_AMR) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ASF_MPEG4_AUDIO) == 0))
+    {
+        return true;
+    }
+
+    return  false;
+}
+
+OSCL_EXPORT_REF bool PVMFFormatType::isVideo() const
+{
+    //Standard video media types from IANA
+    if (oscl_strstr(iMimeStr.c_str(), "video/") != NULL)
+    {
+        // 3gp timed text has a mime as "video/3gpp-tt" we should return false in this case
+        if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_3GPP_TIMEDTEXT) == 0))
+        {
+            return false;
+        }
+        return true;
+    }
+
+    //PV internal video media types
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV420) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_YUV422) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB8) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB12) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB16) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RGB24) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_H264_VIDEO_RAW) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_H264_VIDEO_MP4) == 0))
+    {
+        return true;
+    }
+
+    return  false;
+}
+
+OSCL_EXPORT_REF bool PVMFFormatType::isImage() const
+{
+    //Standard video media types from IANA
+    if (oscl_strstr(iMimeStr.c_str(), "image/") != NULL)
+        return true;
+
+    //PV internal image media type
+    if (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_M4V_IMAGE) == 0)
+        return true;
+
+    return false;
+}
+
+OSCL_EXPORT_REF bool PVMFFormatType::isText() const
+{
+    if (oscl_strstr(iMimeStr.c_str(), "text/") != NULL)
+        return true;
+
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_3GPP_TIMEDTEXT) == 0))
+    {
+        return true;
+    }
+
+    return false;
+}
+
+OSCL_EXPORT_REF bool PVMFFormatType::isFile() const
+{
+    //PV internal file format type
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MPEG4FF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_H223) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RTP) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AMRFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AACFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MP3FF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_WAVFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_ASFFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_RMFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DIVXFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_MIDIFF) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_AVIFF) == 0))
+        return true;
+
+    return false;
+}
+
+OSCL_EXPORT_REF bool PVMFFormatType::isRaw() const
+{
+    //PV internal raw format type
+    return (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_8BIT_RAW) == 0);
+}
+
+//return true if a media type is PV internal data source.
+OSCL_EXPORT_REF bool PVMFFormatType::isDataSource() const
+{
+    //PV internal data source format type
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_RTSP_URL) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_HTTP_URL) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_SDP_FILE) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_PVX_FILE) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_REAL_HTTP_CLOAKING_URL) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_DATA_SOURCE_RTP_PACKET_SOURCE) == 0))
+        return true;
+
+    return false;
+}
+
+//return true if a media type is PV user input.
+OSCL_EXPORT_REF bool PVMFFormatType::isUserInput() const
+{
+    //PV user input format type
+    if ((pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_BASIC_STRING) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_IA5_STRING) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_GENERAL_STRING) == 0) ||
+            (pv_mime_strcmp(iMimeStr.c_str(), PVMF_MIME_USERINPUT_DTMF) == 0))
+        return true;
+
+    return false;
+}
diff --git a/pvmi/pvmf/src/pvmf_media_clock.cpp b/pvmi/pvmf/src/pvmf_media_clock.cpp
new file mode 100644
index 0000000..6d7ce2e
--- /dev/null
+++ b/pvmi/pvmf/src/pvmf_media_clock.cpp
@@ -0,0 +1,2149 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+#include "pvmf_media_clock.h"
+
+OSCL_EXPORT_REF PVMFMediaClock::PVMFMediaClock() : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVMFMediaClock"),
+        iState(STOPPED),
+        iClockTimebase(NULL)
+{
+    iLogger = PVLogger::GetLoggerObject("PVMFMediaClock");
+    iLatestRunningClockTime = 0;
+    iLatestRunningTimebaseTime = 0;
+    iStartTimebaseTickValue = 0;
+    iStartClockTime = 0;
+    iPauseClockTime = 0;
+    iLastAdjustObsTimebaseTime = 0;
+    iAdjustmentTimebaseTime = 0;
+    iStartNPT = 0;
+    iIsNPTPlayBackDirectionBackwards = 0;
+    iStartMediaClockTS = 0;
+    iClockUnit = PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC;
+    iPreviousClockUnit = PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC;
+    iActiveTimersCount = 0;
+    iTimerIDCount = 1;
+    OsclThread::GetId(iOrigThreadID);
+    AddToScheduler();
+    iMutex = OSCL_NEW(OsclMutex, ());
+    iMutex->Create();
+
+    //initialize this to real time
+    iLastTimebaseRate = REALTIME_PLAYBACK_RATE;
+
+    iIsTimebaseCountBased = false;
+}
+
+OSCL_EXPORT_REF PVMFMediaClock::~PVMFMediaClock()
+{
+    Reset();
+    iMutex->Close();
+    if (iMutex)
+        OSCL_DELETE(iMutex);
+    RemoveFromScheduler();
+}
+
+void PVMFMediaClock::CleanCallbackInfImplObjects()
+{
+    for (uint32 ii = 0;ii < iMediaClockSetCallbackObjects.size();ii++)
+    {
+        if (iMediaClockSetCallbackObjects[ii]->iNotificationInterfaceDestroyedCallback)
+        {
+            (iMediaClockSetCallbackObjects[ii]->iNotificationInterfaceDestroyedCallback)->NotificationsInterfaceDestroyed();
+        }
+        OSCL_DELETE(iMediaClockSetCallbackObjects[ii]);
+        iMediaClockSetCallbackObjects.erase(&iMediaClockSetCallbackObjects[ii]);
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus
+PVMFMediaClock::ConstructMediaClockNotificationsInterface(PVMFMediaClockNotificationsInterface*& aIface,
+        PVMFMediaClockNotificationsObsBase& aNotificationInterfaceDestroyedCallback,
+        uint32 aLatency)
+{
+
+    PVMFMediaClockNotificationsInterfaceImpl* ifaceImpl = NULL;
+
+    if (RUNNING == iState)
+    {
+        return PVMFErrInvalidState;
+    }
+
+    ifaceImpl = OSCL_NEW(PVMFMediaClockNotificationsInterfaceImpl, (this, aLatency, aNotificationInterfaceDestroyedCallback));
+    aIface = OSCL_STATIC_CAST(PVMFMediaClockNotificationsInterface*, ifaceImpl);
+
+    if (aIface)
+    {
+        iMediaClockSetCallbackObjects.push_back(ifaceImpl);
+        AdjustLatenciesOfSinks();
+        return PVMFSuccess;
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::DestroyMediaClockNotificationsInterface(PVMFMediaClockNotificationsInterface* aInf)
+{
+    if (!aInf)
+    {
+        return;
+    }
+
+    //Cancel all active callbacks created from this interface object.
+    if (!iTimersPriQueue.empty())
+    {
+        Oscl_Vector<PVMFMediaClockTimerQueueElement, OsclMemAllocator> qVector = iTimersPriQueue.vec();
+        for (uint32 ii = 0;ii < qVector.size();ii++)
+        {
+            if (qVector[ii].pInterfaceObject == aInf)
+            {
+                CommonCancelCallback(qVector[ii].callBackID, false, false);
+            }
+        }
+    }
+
+    if (!iIsNPTPlayBackDirectionBackwards)
+    {
+        if (!iTimersPriQueueNPT.empty())
+        {
+            Oscl_Vector<PVMFMediaClockTimerQueueElement, OsclMemAllocator> qVector = iTimersPriQueueNPT.vec();
+            for (uint32 ii = 0;ii < qVector.size();ii++)
+            {
+                if (qVector[ii].pInterfaceObject == aInf)
+                {
+                    CommonCancelCallback(qVector[ii].callBackID, false, true);
+                }
+            }
+        }
+    }
+    else
+    {
+        if (!iTimersPriQueueNPTBackwards.empty())
+        {
+            Oscl_Vector<PVMFMediaClockTimerQueueElement, OsclMemAllocator> qVector = iTimersPriQueueNPTBackwards.vec();
+            for (uint32 ii = 0;ii < qVector.size();ii++)
+            {
+                if (qVector[ii].pInterfaceObject == aInf)
+                {
+                    CommonCancelCallback(qVector[ii].callBackID, false, true);
+                }
+            }
+
+        }
+    }
+
+
+
+    //Destroy the interface
+    PVMFMediaClockNotificationsInterfaceImpl* ifaceImpl = NULL;
+
+    ifaceImpl = OSCL_STATIC_CAST(PVMFMediaClockNotificationsInterfaceImpl*, aInf);
+    for (uint32 ii = 0;ii < iMediaClockSetCallbackObjects.size();ii++)
+    {
+        if (iMediaClockSetCallbackObjects[ii] == ifaceImpl)
+        {
+            if (iMediaClockSetCallbackObjects[ii]->iNotificationInterfaceDestroyedCallback)
+            {
+                (iMediaClockSetCallbackObjects[ii]->iNotificationInterfaceDestroyedCallback)->NotificationsInterfaceDestroyed();
+            }
+            OSCL_DELETE(iMediaClockSetCallbackObjects[ii]);
+            iMediaClockSetCallbackObjects.erase(&iMediaClockSetCallbackObjects[ii]);
+        }
+    }
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::SetClockTimebase(PVMFTimebase& aTimebase)
+{
+    // Clock timebase can only be set during stopped or paused states
+    if (iState == RUNNING)
+    {
+        return false;
+    }
+
+    // Save the clock timebase object pointer
+    iClockTimebase = &aTimebase;
+
+    if ((iClockTimebase->GetRate() != iLastTimebaseRate) &&
+            iActiveTimersCount != 0)
+    {
+        //start scheduling afresh
+        AdjustScheduling();
+    }
+
+    //Update timebase rate
+    iLastTimebaseRate = iClockTimebase->GetRate();
+
+    //If this is a counting timebase, then set the timebase
+    //observer to this clock, so that we'll get the count update
+    //notices.
+    if (aTimebase.GetCountTimebase())
+    {
+        aTimebase.GetCountTimebase()->SetClockObserver(this);
+        iIsTimebaseCountBased = true;
+    }
+    else
+    {
+        iIsTimebaseCountBased = false;
+    }
+
+    //Notify observers that the timebase is updated.
+    ClockTimebaseUpdated();
+
+    return true;
+}
+void PVMFMediaClock::AdjustLatenciesOfSinks()
+{
+    uint32 size = iMediaClockSetCallbackObjects.size();
+    uint32 ii = 0;
+
+    if (!size)
+        return;
+
+    //find the minimum and maximum latencies
+    uint32 minLatency = iMediaClockSetCallbackObjects[0]->iLatency;
+    uint32 maxLatency = iMediaClockSetCallbackObjects[0]->iLatency;
+    for (ii = 0;ii < size - 1;ii++)
+    {
+        if (iMediaClockSetCallbackObjects[ii+1]->iLatency > iMediaClockSetCallbackObjects[ii]->iLatency)
+        {
+            minLatency = iMediaClockSetCallbackObjects[ii]->iLatency;
+        }
+        else
+        {
+            minLatency = iMediaClockSetCallbackObjects[ii+1]->iLatency;
+        }
+
+        if (iMediaClockSetCallbackObjects[ii+1]->iLatency > iMediaClockSetCallbackObjects[ii]->iLatency)
+        {
+            maxLatency = iMediaClockSetCallbackObjects[ii+1]->iLatency;
+        }
+        else
+        {
+            maxLatency = iMediaClockSetCallbackObjects[ii]->iLatency;
+        }
+    }
+
+    //set adjusted-latencies and latency-delays
+    for (ii = 0;ii < size;ii++)
+    {
+        iMediaClockSetCallbackObjects[ii]->iAdjustedLatency =
+            iMediaClockSetCallbackObjects[ii]->iLatency - minLatency;
+
+        iMediaClockSetCallbackObjects[ii]->iLatencyDelayForClockStartNotification =
+            maxLatency - iMediaClockSetCallbackObjects[ii]->iLatency;
+    }
+
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::Start()
+{
+    bool overflowFlag = false;
+    // Can only start from stopped or paused states
+    if (iState == RUNNING)
+    {
+        return false;
+    }
+
+
+    uint32 tbval = 0;
+
+
+    // Save the clock timebase value to the appropriate
+    // variable and update the iLatest... values.
+    if (iState == STOPPED)
+    {
+        // Retrieve the current time value from the clock timebase
+        if (iClockTimebase != NULL)
+        {
+            iClockTimebase->GetCurrentTick32(iStartTimebaseTickValue, overflowFlag);
+        }
+
+        //can reuse overflowFlag as result would be virtually same
+        GetScaledTimebaseTickCount(tbval, overflowFlag);
+        // Starting from stop
+        UpdateLatestTimes(iStartClockTime, tbval);
+    }
+    else
+    {
+        GetScaledTimebaseTickCount(tbval, overflowFlag);
+        // Resuming from pause
+        UpdateLatestTimes(iPauseClockTime, tbval);
+    }
+
+    // Change to running state
+    SetClockState(RUNNING);
+
+    //Restart callback scheduling
+    AdjustScheduling();
+
+    return true;
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::Pause()
+{
+    bool overflowFlag = false;
+    // Can only pause during running state
+    if (iState != RUNNING)
+    {
+        return false;
+    }
+
+    // Save the current time
+    uint32 tbval = 0;
+    GetCurrentTime32(iPauseClockTime, overflowFlag, PVMF_MEDIA_CLOCK_MSEC, tbval);
+    UpdateLatestTimes(iPauseClockTime, tbval);
+
+    // Change to paused state
+    SetClockState(PAUSED);
+
+    //Cancel any scheduled Run
+    Cancel();
+    return true;
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::Stop()
+{
+    // Can only stop when running or paused
+    if (iState == STOPPED)
+    {
+        return false;
+    }
+
+    // Reset the time values
+    uint32 tmp = 0;
+    UpdateLatestTimes(tmp, tmp);
+    iStartClockTime = tmp;
+    iPauseClockTime = tmp;
+    iLastAdjustObsTimebaseTime = tmp;
+    iAdjustmentTimebaseTime = tmp;
+    iStartTimebaseTickValue = tmp;
+
+    // Change to stopped state
+    SetClockState(STOPPED);
+
+    //Clear all callback queues
+    ClearAllQueues();
+    return true;
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::GetStartTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits)
+{
+    aOverflow = false;
+    // Convert to the requested time units and return the start time
+    FromClockUnit(iStartClockTime, aTime, aUnits, aOverflow);
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::SetStartTime32(uint32& aTime, PVMFMediaClock_TimeUnits aUnits, bool& aOverFlow)
+{
+    aOverFlow = false;
+
+    // Can only set start time while stopped
+    if (iState != STOPPED)
+    {
+        return false;
+    }
+
+    iPreviousClockUnit = iClockUnit;
+    // set clock units to usec if units arg is usec. Otherwise, default is msec
+    (PVMF_MEDIA_CLOCK_USEC == aUnits) ? iClockUnit = PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC :
+            iClockUnit = PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC;
+
+    if (iPreviousClockUnit != iClockUnit)
+    {
+        AdjustClockInternalsToNewUnits(aOverFlow);
+    }
+
+    // Convert to clock units and set the start time
+    bool overflowFlag1 = false;
+    ToClockUnit(aTime, aUnits, iStartClockTime, overflowFlag1);
+
+    aOverFlow = aOverFlow | overflowFlag1;
+
+    //start scheduling afresh
+    AdjustScheduling();
+    return true;
+}
+
+OSCL_EXPORT_REF PVMFMediaClockAdjustTimeStatus PVMFMediaClock::AdjustClockTime32(uint32& aClockTime, uint32& aTimebaseTime, uint32& aAdjustedTime, PVMFMediaClock_TimeUnits aUnits, bool& aOverFlow)
+{
+    aOverFlow = false;
+
+    // Clock can only be adjusted when it is running
+    if (iState != RUNNING)
+    {
+        return PVMF_MEDIA_CLOCK_ADJUST_ERR_INVALID_STATE;
+    }
+
+    // Check if the adjustment's observed time is later than the last one
+    uint32 temp = 0;
+    if (PVTimeComparisonUtils::IsEarlier(aTimebaseTime, iLastAdjustObsTimebaseTime, temp) && (temp != 0))
+    {
+        // Old data so don't use it for adjustment
+        return PVMF_MEDIA_CLOCK_ADJUST_ERR_INVALID_TIMEBASE_TIME;
+    }
+
+    iPreviousClockUnit = iClockUnit;
+
+    // set clock units to usec if units arg is usec. Otherwise, default is msec
+    (PVMF_MEDIA_CLOCK_USEC == aUnits) ? iClockUnit = PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC :
+            iClockUnit = PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC;
+
+    if (iPreviousClockUnit != iClockUnit)
+    {
+        AdjustClockInternalsToNewUnits(aOverFlow);
+    }
+
+    // Convert the observed clock and adjustment time to usec so it can be compared
+    uint32 adjusttime, clocktime;
+    bool overflowFlag1 = false, overflowFlag2 = false;
+    ToClockUnit(aClockTime, aUnits, clocktime, overflowFlag1);
+    ToClockUnit(aAdjustedTime, aUnits, adjusttime, overflowFlag2);
+
+    // Make sure the adjustment's clock and timebase times are before current time
+    uint32 currenttime = 0;
+    uint32 tbval = 0;
+    bool overflowFlag3 = false, overflowFlag4 = false;
+
+    // Get the current timebase time
+    GetScaledTimebaseTickCount(tbval, overflowFlag4);
+
+    // Get the current clock time in clock units
+    GetCurrentTime32(currenttime, overflowFlag3, iClockUnit == PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC ? PVMF_MEDIA_CLOCK_USEC :
+                     PVMF_MEDIA_CLOCK_MSEC);
+
+    aOverFlow = aOverFlow | overflowFlag1 | overflowFlag2 | overflowFlag3 | overflowFlag4;
+
+    if (PVTimeComparisonUtils::IsEarlier(tbval, aTimebaseTime, temp) && (temp != 0))
+    {
+        // Observed timebase time cannot be later than the current timebase time
+        return PVMF_MEDIA_CLOCK_ADJUST_ERR_INVALID_TIMEBASE_TIME;
+    }
+
+    if (clocktime > currenttime)
+    {
+        // Observed clock time cannot be later than the current clock time
+        return PVMF_MEDIA_CLOCK_ADJUST_ERR_CORRUPT_CLOCK_TIME;
+    }
+
+    // Make the adjustment
+    return AdjustClock(clocktime, aTimebaseTime, adjusttime, currenttime, tbval);
+
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::Reset()
+{
+    bool tmpFlag = true;
+
+    //stop clock if its not already stopped
+    if (STOPPED != iState)
+    {
+        tmpFlag = Stop();
+    }
+
+    // remove all ClockObservers
+    iClockObservers.clear();
+
+    // remove interface objects. This will also remove all ClockStateObservers.
+    CleanCallbackInfImplObjects();
+
+    return tmpFlag;
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow)
+{
+    aOverflow = false;
+
+    if (iClockTimebase != NULL)
+    {
+        iClockTimebase->GetCurrentTick32(aTimebaseTickCount, aOverflow);
+    }
+    else
+    {
+        aTimebaseTickCount = 0;
+    }
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::GetTimebaseResolution(uint32& aResolution)
+{
+    if (iClockTimebase)
+    {
+        // Retrieve the resolution from the timebase being used
+        iClockTimebase->GetTimebaseResolution(aResolution);
+    }
+    else
+    {
+        // No timebase so set to 0
+        aResolution = 0;
+    }
+}
+
+OSCL_EXPORT_REF int32 PVMFMediaClock::GetRate(void)
+{
+    if (iClockTimebase)
+    {
+        // Retrieve the playback rate from the timebase being used
+        return iClockTimebase->GetRate();
+    }
+    else
+    {
+        // No timebase so return realtime rate
+        return REALTIME_PLAYBACK_RATE;
+    }
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::GetCurrentTime32(uint32& aClockTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits)
+{
+    uint32 temp = 0;
+
+    GetCurrentTime32(aClockTime, aOverflow, aUnits, temp);
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::GetCurrentTime32(uint32& aClockTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits, uint32& aTimebaseTime)
+{
+    // Get and return the current timebase value
+
+    bool overflowFlag1 = false, overflowFlag2 = false, overflowFlag3 = false;
+
+    aOverflow = false;
+
+    // Get the current timebase time
+    GetScaledTimebaseTickCount(aTimebaseTime, aOverflow);
+
+    // Determine and return the current clock time
+    if (iState == STOPPED)
+    {
+        // Return the specified start time
+        FromClockUnit(iStartClockTime, aClockTime, aUnits, overflowFlag3);
+    }
+    else if (iState == PAUSED)
+    {
+        // Returned the paused time
+        FromClockUnit(iPauseClockTime, aClockTime, aUnits, overflowFlag3);
+    }
+    else
+    {
+        // Running state
+        uint32 currenttime;
+
+        // Determine current clock time including any adjustment
+        GetAdjustedRunningClockTime(currenttime, aTimebaseTime);
+
+        // Convert to requested time units
+        FromClockUnit(currenttime, aClockTime, aUnits, overflowFlag3);
+    }
+
+    aOverflow = aOverflow | overflowFlag1 | overflowFlag2 | overflowFlag3;
+}
+
+OSCL_EXPORT_REF bool PVMFMediaClock::QueryInterface(const PVUuid& uuid, PVInterface*& iface)
+{
+    if (uuid == PVMFMediaClockControlInterfaceUuid)
+    {
+        PVMFMediaClockControlInterface* myInterface =
+            OSCL_STATIC_CAST(PVMFMediaClockControlInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
+    else if (uuid == PVMFMediaClockAccessInterfaceUuid)
+    {
+        PVMFMediaClockAccessInterface* myInterface =
+            OSCL_STATIC_CAST(PVMFMediaClockAccessInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
+    else if (uuid == PVMFMediaClockNPTClockPositionAccessInterfaceUuid)
+    {
+        PVMFMediaClockNPTClockPositionAccessInterface* myInterface =
+            OSCL_STATIC_CAST(PVMFMediaClockNPTClockPositionAccessInterface*, this);
+        iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
+    }
+    else
+    {
+        return false;
+    }
+
+    return true;
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::SetClockObserver(PVMFMediaClockObserver& aObserver)
+{
+    iClockObservers.push_back(&aObserver);
+}
+
+OSCL_EXPORT_REF void PVMFMediaClock::RemoveClockObserver(PVMFMediaClockObserver& aObserver)
+{
+    for (uint32 i = 0;i < iClockObservers.size();i++)
+    {
+        if (iClockObservers[i] == &aObserver)
+            iClockObservers.erase(&iClockObservers[i]);
+    }
+}
+
+void PVMFMediaClock::SetClockState(PVMFMediaClockState aState)
+{
+    // Change the clock state
+    iState = aState;
+
+    // Notify observers
+
+    //If this is clock start, we need to send start notification after adjusting latency
+    if (RUNNING == iState)
+    {
+        for (uint32 ii = 0;ii < iMediaClockSetCallbackObjects.size();ii++)
+        {
+            if (iMediaClockSetCallbackObjects[ii]->iClockStateObserver != NULL)
+            {
+                if (0 == iMediaClockSetCallbackObjects[ii]->iLatencyDelayForClockStartNotification)
+                {
+                    (iMediaClockSetCallbackObjects[ii]->iClockStateObserver)->ClockStateUpdated();
+                }
+                else
+                {
+                    //Queue notification
+                    QueueClockStartNotificationEvent(iMediaClockSetCallbackObjects[ii]->iLatencyDelayForClockStartNotification,
+                                                     iMediaClockSetCallbackObjects[ii]->iClockStateObserver);
+                }
+            }
+        }
+    }
+    else
+    {
+        for (uint32 ii = 0;ii < iMediaClockSetCallbackObjects.size();ii++)
+        {
+            if (iMediaClockSetCallbackObjects[ii]->iClockStateObserver != NULL)
+            {
+                (iMediaClockSetCallbackObjects[ii]->iClockStateObserver)->ClockStateUpdated();
+            }
+        }
+    }
+}
+
+void PVMFMediaClock::GetScaledTimebaseTickCount(uint32& aScaledTickCount, bool& aOverFlow)
+{
+    uint32 temp = 0;
+    aOverFlow = false;
+
+    if (iClockTimebase != NULL)
+    {
+        iClockTimebase->GetCurrentTick32(temp, aOverFlow);
+    }
+
+    PVTimeComparisonUtils::IsEarlier(iStartTimebaseTickValue, temp, aScaledTickCount);
+}
+
+void PVMFMediaClock::UpdateLatestTimes(uint32 aTime, uint32 aTimebaseVal)
+{
+    // Set the latest time values
+    iLatestRunningClockTime = aTime;
+    iLatestRunningTimebaseTime = aTimebaseVal;
+}
+
+void PVMFMediaClock::AdjustClockInternalsToNewUnits(bool& aOverFlow)
+{
+
+    uint32 temp = 0;
+
+    aOverFlow = false;
+
+    // Change the units
+    if (PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC == iPreviousClockUnit)
+    {
+        ToClockUnit(iLatestRunningClockTime, PVMF_MEDIA_CLOCK_USEC, temp, aOverFlow);
+        iLatestRunningClockTime = temp;
+
+        ToClockUnit(iStartClockTime, PVMF_MEDIA_CLOCK_USEC, temp, aOverFlow);
+        iStartClockTime = temp;
+
+        ToClockUnit(iPauseClockTime, PVMF_MEDIA_CLOCK_USEC, temp, aOverFlow);
+        iPauseClockTime = temp;
+    }
+    else if (PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC == iPreviousClockUnit)
+    {
+        ToClockUnit(iLatestRunningClockTime, PVMF_MEDIA_CLOCK_MSEC, temp, aOverFlow);
+        iLatestRunningClockTime = temp;
+
+        ToClockUnit(iStartClockTime, PVMF_MEDIA_CLOCK_MSEC, temp, aOverFlow);
+        iStartClockTime = temp;
+
+        ToClockUnit(iPauseClockTime, PVMF_MEDIA_CLOCK_MSEC, temp, aOverFlow);
+        iPauseClockTime = temp;
+    }
+}
+
+#define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA
+#include "osclconfig_compiler_warnings.h"
+
+void PVMFMediaClock::ToClockUnit(uint32& aSrcVal, PVMFMediaClock_TimeUnits aSrcUnits, uint32& aDestVal, bool& aOverFlow)
+{
+    uint32 multconst = 1;
+
+    aOverFlow = false;
+
+    switch (iClockUnit)
+    {
+        case PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC:
+        {
+            if (PVMF_MEDIA_CLOCK_USEC == aSrcUnits)
+            {
+                aDestVal = aSrcVal / 1000;
+            }
+            else
+            {
+                // Determine the multiplier constant for the specified units
+                switch (aSrcUnits)
+                {
+                    case PVMF_MEDIA_CLOCK_SEC:
+                        multconst = 1000;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_MIN:
+                        multconst = 60000;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_HOUR:
+                        multconst = 0x36EE80;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_DAY:
+                        multconst = 0x5265C00;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_MSEC:
+                    default:
+                        break;
+                }
+
+                // Convert value to clock units
+                uint64 time64 = (uint64)(aSrcVal * multconst);
+
+                //There is a chance that Tickcount did not wrap around but aTime value does
+                if (time64 > (uint64)(0xFFFFFFFF))
+                {
+                    aOverFlow = true;
+                }
+                aDestVal = Oscl_Int64_Utils::get_uint64_lower32(time64);
+            }
+        }
+        break;
+
+        case PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC:
+        {
+            // Determine the multiplier constant for the specified units
+            switch (aSrcUnits)
+            {
+                case PVMF_MEDIA_CLOCK_MSEC:
+                    multconst = 1000;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_SEC:
+                    multconst = 1000000;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_MIN:
+                    multconst = 60000000;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_HOUR:
+                    multconst = 0xD693A400;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_DAY:
+                {
+                    uint64 temp = UINT64_HILO(0x14, 0x1DD76000);
+                    multconst = Oscl_Int64_Utils::get_uint64_lower32(temp);
+                }
+                break;
+
+                case PVMF_MEDIA_CLOCK_USEC:
+                default:
+                    break;
+            }
+
+            // Convert value to clock units
+            uint64 time64 = (uint64)(aSrcVal * multconst);
+            //There is a chance that Tickcount did not wrap around but aTime value does
+            if (time64 > (uint64)(0xFFFFFFFF))
+            {
+                aOverFlow = true;
+            }
+            aDestVal = Oscl_Int64_Utils::get_uint64_lower32(time64);
+        }
+        break;
+
+        default:
+        {
+            break;
+        }
+    }
+
+}
+
+void PVMFMediaClock::FromClockUnit(uint32& aClockUnitVal, uint32& aDstVal,
+                                   PVMFMediaClock_TimeUnits aDstUnits, bool& aOverflow)
+{
+
+    uint32 divconst = 1;
+
+    aOverflow = false;
+
+    switch (iClockUnit)
+    {
+        case PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC:
+        {
+            if (PVMF_MEDIA_CLOCK_USEC == aDstUnits)
+            {
+                //detect overflow;
+                uint64 time64 = (uint64)(aClockUnitVal * 1000);
+                if (time64 > (uint64)(0xFFFFFFFF))
+                {
+                    aOverflow = true;
+                }
+                aDstVal = Oscl_Int64_Utils::get_uint64_lower32(time64);
+            }
+            else
+            {
+                // Determine the multiplier constant for the specified units
+                switch (aDstUnits)
+                {
+                    case PVMF_MEDIA_CLOCK_SEC:
+                        divconst = 1000;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_MIN:
+                        divconst = 60000;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_HOUR:
+                        divconst = 3600000;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_DAY:
+                        divconst = 86400000;
+                        break;
+
+                    case PVMF_MEDIA_CLOCK_MSEC:
+                    default:
+                        break;
+                }
+
+                // Convert value to desired units
+                aDstVal = aClockUnitVal / divconst;
+            }
+        }
+        break;
+
+        case PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC:
+        {
+            // Determine the multiplier constant for the specified units
+            switch (aDstUnits)
+            {
+                case PVMF_MEDIA_CLOCK_MSEC:
+                    divconst = 1000;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_SEC:
+                    divconst = 1000000;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_MIN:
+                    divconst = 60000000;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_HOUR:
+                    divconst = 0xD693A400;
+                    break;
+
+                case PVMF_MEDIA_CLOCK_DAY:
+                {
+                    uint64 temp = UINT64_HILO(0x14, 0x1DD76000);
+                    divconst = Oscl_Int64_Utils::get_uint64_lower32(temp);
+                }
+                break;
+
+                case PVMF_MEDIA_CLOCK_USEC:
+                default:
+                    break;
+            }
+            // Convert value to desired units
+            aDstVal = aClockUnitVal / divconst;
+
+        }
+        break;
+
+        default:
+        {
+            break;
+        }
+    }
+}
+
+void PVMFMediaClock::ConvertTickcountToClockUnits(uint32 aTickcount, uint32& aTimeValue, bool& aOverflowFlag)
+{
+    uint32 tbval = aTickcount;
+
+    aOverflowFlag = false;
+
+    //Convert tickCount value to msecs
+    uint32 usecPerTick = 0;
+    GetTimebaseResolution(usecPerTick);
+
+    if (usecPerTick)
+    {
+        tbval = tbval * (usecPerTick / 1000);
+    }
+    else /*timebase is not set*/
+    {
+        tbval = 0;
+    }
+
+    ToClockUnit(tbval, PVMF_MEDIA_CLOCK_MSEC, aTimeValue, aOverflowFlag);
+}
+void PVMFMediaClock::ToUSec(uint32& aSrcVal, PVMFMediaClock_TimeUnits aSrcUnits, uint32& aUSecVal, bool& aOverFlow)
+{
+    uint32 multconst = 1;
+
+    aOverFlow = false;
+
+
+    // Determine the multiplier constant for the specified units
+    switch (aSrcUnits)
+    {
+        case PVMF_MEDIA_CLOCK_MSEC:
+            multconst = 1000;
+            break;
+
+        case PVMF_MEDIA_CLOCK_SEC:
+            multconst = 1000000;
+            break;
+
+        case PVMF_MEDIA_CLOCK_MIN:
+            multconst = 60000000;
+            break;
+
+        case PVMF_MEDIA_CLOCK_HOUR:
+            multconst = 0xD693A400;
+            break;
+
+        case PVMF_MEDIA_CLOCK_DAY:
+        {
+            uint64 temp = UINT64_HILO(0x14, 0x1DD76000);
+            multconst = Oscl_Int64_Utils::get_uint64_lower32(temp);
+        }
+        break;
+
+        case PVMF_MEDIA_CLOCK_USEC:
+        default:
+            break;
+    }
+
+    // Convert value to clock units
+    uint64 time64 = (uint64)(aSrcVal * multconst);
+    //There is a chance that Tickcount did not wrap around but aTime value does
+    if (time64 > (uint64)(0xFFFFFFFF))
+    {
+        aOverFlow = true;
+    }
+
+    aUSecVal = Oscl_Int64_Utils::get_uint64_lower32(time64);
+}
+
+PVMFMediaClockAdjustTimeStatus PVMFMediaClock::AdjustClock(uint32& aObsTime, uint32& aObsTimebase, uint32& aAdjTime,
+        uint32& aCurrentTime, uint32& aCurrentTimebase)
+{
+    // In this implementation, don't allow adjustments to be made with
+    // data older than when the last adjustment was made
+    uint32 temp = 0;
+    if (PVTimeComparisonUtils::IsEarlier(aObsTimebase, iAdjustmentTimebaseTime, temp) && (temp != 0))
+    {
+        return PVMF_MEDIA_CLOCK_ADJUST_ERR_INVALID_TIMEBASE_TIME;
+    }
+
+    // Make the adjustment
+    if (aAdjTime > aObsTime)
+    {
+        // Adjusted time is ahead so move ahead
+
+        // Save the observed timebase time of the adjusted time
+        iLastAdjustObsTimebaseTime = aObsTimebase;
+        UpdateLatestTimes(aAdjTime, aObsTimebase);
+
+        // Set the latest adjustment time as the current timebase time
+        iAdjustmentTimebaseTime = aCurrentTimebase;
+    }
+    else if (aAdjTime < aObsTime)
+    {
+        // Adjusted time is before the current time
+
+        // Save the observed timebase time of the adjusted time
+        iLastAdjustObsTimebaseTime = aObsTimebase;
+
+        // Set the latest clock time to the current clock time
+        // Set the latest timebase time to (current timebase time) + ((observed clock time) - (adjusted time))
+        uint32 offsettimebase = 0;
+        uint32 usecPerTick = 0;
+
+        GetTimebaseResolution(usecPerTick);
+
+        //calculate ticks in offsettbtime
+        if (PVMF_MEDIA_CLOCK_CLOCKUNIT_MSEC == iClockUnit)
+        {
+            uint32 usecInOffset = (aObsTime - aAdjTime) * 1000;
+
+            //Calculate number of ticks
+            offsettimebase = usecInOffset / usecPerTick;
+        }
+        else if (PVMF_MEDIA_CLOCK_CLOCKUNIT_USEC == iClockUnit)
+        {
+            offsettimebase = (aObsTime - aAdjTime) / usecPerTick;
+        }
+
+        UpdateLatestTimes(aCurrentTime, aCurrentTimebase + offsettimebase);
+        iAdjustmentTimebaseTime = aCurrentTimebase;
+    }
+    else
+    {
+        // Since there is no adjustment, do nothing
+    }
+
+    //Start fresh scheduling
+    AdjustScheduling();
+
+    ClockAdjusted();
+    return PVMF_MEDIA_CLOCK_ADJUST_SUCCESS;
+}
+
+void PVMFMediaClock::GetAdjustedRunningClockTime(uint32& aDstTime, uint32& aTimebaseVal)
+{
+    uint32 delta = 0;
+    // Current time is (latest clock time)+(current timebase time - latest timebase time)
+    aDstTime = iLatestRunningClockTime;
+
+    // If backward adjustment occurs, iLatestRunningTimebaseTime might be greater than
+    // the current value. To avoid negative values and clock going back, only
+    // add the diff if current timebase value is greater. This makes the clock "freeze" until
+    // the difference has elapsed
+    if (PVTimeComparisonUtils::IsEarlier(iLatestRunningTimebaseTime, aTimebaseVal, delta) && (delta != 0))
+    {
+        //convert delta to clock units
+        uint32 deltaTime = 0;
+        bool overflowFlag = false;
+        ConvertTickcountToClockUnits(delta, deltaTime, overflowFlag);
+        aDstTime += deltaTime;
+    }
+}
+
+void PVMFMediaClock::ClockCountUpdated()
+{
+    //Calling Run will fire any ready timers.
+    Run();
+
+    //notify all observers that the clock count was updated.
+    for (uint32 i = 0;i < iClockObservers.size();i++)
+        iClockObservers[i]->ClockCountUpdated();
+}
+
+void PVMFMediaClock::ClockAdjusted()
+{
+    //notify all observers that the clock was adjusted
+    for (uint32 i = 0;i < iClockObservers.size();i++)
+        iClockObservers[i]->ClockAdjusted();
+}
+
+void PVMFMediaClock::ClockTimebaseUpdated()
+{
+    //notify all observers that the clock timebase was updated.
+    for (uint32 i = 0;i < iClockObservers.size();i++)
+    {
+        PVMFMediaClockObserver* obs = iClockObservers[i];
+        obs->ClockTimebaseUpdated();
+    }
+    //reset timebase history.
+    iLastAdjustObsTimebaseTime = 0;
+    iAdjustmentTimebaseTime = 0;
+    iStartTimebaseTickValue = 0;
+}
+
+PVMFStatus PVMFMediaClock::SetCallbackCommon(uint32 aAbsoluteTime,
+        uint32 aWindow,
+        PVMFMediaClockNotificationsObs* aCallback,
+        bool aThreadLock,
+        const OsclAny* aContextData,
+        uint32& aCallBackID,
+        const OsclAny* aInterfaceObject,
+        uint32 aCurrentTime, bool aIsNPT)
+{
+    uint32 delta = 0;
+
+    if (NULL == aCallback)
+    {
+        return PVMFErrArgument;
+    }
+
+    //absolute time should be later than current time.
+    //upper limit of 30 min for timer
+
+    if (!aIsNPT || (aIsNPT && !iIsNPTPlayBackDirectionBackwards))
+    {
+        if (PVTimeComparisonUtils::IsEarlier(aCurrentTime + MSECS_IN_30_MINS, aAbsoluteTime, delta) ||
+                PVTimeComparisonUtils::IsEarlier(aAbsoluteTime, aCurrentTime, delta))
+        {
+            return PVMFErrArgument;
+        }
+    }
+    else    /*If this is NPT and clock direction is backwards. So, conditions will be opposite.*/
+    {
+        if (PVTimeComparisonUtils::IsEarlier(aAbsoluteTime, aCurrentTime + MSECS_IN_30_MINS, delta) ||
+                PVTimeComparisonUtils::IsEarlier(aCurrentTime, aAbsoluteTime, delta))
+        {
+            return PVMFErrArgument;
+        }
+    }
+
+
+    if (aThreadLock)
+        iMutex->Lock();
+
+    aCallBackID = iTimerIDCount++;
+    //insert the timer in the queue
+    //
+    PVMFMediaClockTimerQueueElement timerQueueElement;
+
+    timerQueueElement.contextData = aContextData;
+    timerQueueElement.pInterfaceObject = aInterfaceObject;
+    timerQueueElement.timeOut = aAbsoluteTime;
+    timerQueueElement.callBackID = aCallBackID;
+    timerQueueElement.isNPTTimer = aIsNPT;
+    timerQueueElement.window = aWindow;
+    timerQueueElement.obs = aCallback;
+    if (!aIsNPT)
+    {
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "PVMFMediaClock::SetCallbackCommon Setting regular callback for time %d at time %d",
+                         aAbsoluteTime, aCurrentTime));
+
+        iTimersPriQueue.push(timerQueueElement);
+
+        //Adjust scheduling if the element inserted is the topmost element
+        if ((iTimersPriQueue.top()).callBackID == (iTimerIDCount - 1))
+        {
+            AdjustScheduling(false, aCurrentTime);
+        }
+    }
+    else
+    {
+        if (!iIsNPTPlayBackDirectionBackwards)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVMFMediaClock::SetCallbackCommon Setting NPT callback for time %d at time %d",
+                             aAbsoluteTime, aCurrentTime));
+
+            iTimersPriQueueNPT.push(timerQueueElement);
+            if ((iTimersPriQueueNPT.top()).callBackID == (iTimerIDCount - 1))
+            {
+                AdjustScheduling(true, aCurrentTime);
+            }
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVMFMediaClock::SetCallbackCommon Setting backwards NPT callback for time %d at time %d",
+                             aAbsoluteTime, aCurrentTime));
+
+            iTimersPriQueueNPTBackwards.push(timerQueueElement);
+            if ((iTimersPriQueueNPT.top()).callBackID == (iTimerIDCount - 1))
+            {
+                AdjustScheduling(true, aCurrentTime);
+            }
+        }
+
+    }
+    iActiveTimersCount++;
+
+    if (aThreadLock)
+        iMutex->Unlock();
+
+    return PVMFSuccess;
+}
+
+PVMFStatus PVMFMediaClock::SetCallbackAbsoluteTime(
+    uint32 aAbsoluteTime,
+    uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID,
+    /*IN*/  const OsclAny* aInterfaceObject
+)
+{
+    uint32 currentTime = 0;
+    bool overFlowFlag = false;
+
+    GetCurrentTime32(currentTime, overFlowFlag, PVMF_MEDIA_CLOCK_MSEC);
+
+    return SetCallbackCommon(aAbsoluteTime, aWindow, aCallback,
+                             aThreadLock, aContextData, aCallBackID, aInterfaceObject, currentTime, false);
+
+}
+
+void PVMFMediaClock::CalculateRunLTimerValue(bool aIsNPT, uint32 aCurrentTime, int32& aDelta)
+{
+    int32 nptDelta = 0;
+    int32 delta = 0;
+
+    if (iTimersPriQueueNPT.size() ||
+            iTimersPriQueueNPTBackwards.size())
+    {
+        uint32 temp = 0;
+        GetNPTClockPosition(temp);
+
+        if (!iIsNPTPlayBackDirectionBackwards)
+        {
+            if (iTimersPriQueueNPT.size())
+            {
+                nptDelta = iTimersPriQueueNPT.top().timeOut - temp;
+            }
+        }
+        else
+        {
+            if (iTimersPriQueueNPTBackwards.size())
+            {
+                nptDelta = temp - iTimersPriQueueNPT.top().timeOut;
+            }
+        }
+
+        if (!iTimersPriQueue.size())
+        {
+            aDelta = nptDelta;
+            return;
+        }
+    }
+
+    if (iTimersPriQueue.size())
+    {
+        bool overFlowFlag = false;
+
+        uint32 currentTime = 0;
+
+        if (!aIsNPT)
+        {
+            currentTime = aCurrentTime;
+        }
+        else
+        {
+            GetCurrentTime32(currentTime, overFlowFlag, PVMF_MEDIA_CLOCK_MSEC);
+        }
+
+
+        PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                        (0, "PVMFMediaClock::CalculateRunLTimerValue currtime %d top.timeOut %d", currentTime, iTimersPriQueue.top().timeOut));
+
+        delta = iTimersPriQueue.top().timeOut - currentTime;
+
+        if (!iTimersPriQueueNPT.size()
+                && !iTimersPriQueueNPTBackwards.size())
+        {
+            aDelta = delta;
+            return;
+        }
+    }
+
+    aDelta = delta < nptDelta ? delta : nptDelta;
+}
+
+void PVMFMediaClock::AdjustScheduling(bool aIsNPT, uint32 aCurrentTime)
+{
+
+    //If timebase is count-based, no need for scheduling.
+    if (iIsTimebaseCountBased)
+    {
+        return;
+    }
+    //Make sure current thread context is same on which AddToScheduler() was called
+
+    TOsclThreadId tempThreadID;
+    OsclThread::GetId(tempThreadID);
+
+    if (!OsclThread::CompareId(tempThreadID, iOrigThreadID))
+    {
+        OsclError::Leave(OsclErrThreadContextIncorrect);
+    }
+
+    uint32 currentTime = 0;
+    bool overFlowFlag = false;
+
+    // A fresh RunIfInactive() will be called
+    Cancel();
+
+    //get current time if argument aCurrentTime is 0
+    if (!aIsNPT)
+    {
+        if (aCurrentTime)
+        {
+            currentTime = aCurrentTime;
+        }
+        else
+        {
+            GetCurrentTime32(currentTime, overFlowFlag, PVMF_MEDIA_CLOCK_MSEC);
+        }
+    }
+    else
+    {
+        aCurrentTime ? currentTime = aCurrentTime : GetNPTClockPosition(currentTime);
+    }
+
+    int32 deltaTime = 1;
+
+    //if queues are empty, no need to schedule
+    if (iTimersPriQueue.size() != 0 ||
+            iTimersPriQueueNPT.size() != 0 ||
+            iTimersPriQueueNPTBackwards.size() != 0)
+    {
+        CalculateRunLTimerValue(aIsNPT, currentTime, deltaTime);
+        if (deltaTime >= 0)
+        {
+            //Adjust for rate
+            if ((iClockTimebase != NULL) && (iClockTimebase->GetRate() != 0)
+                    && (REALTIME_PLAYBACK_RATE != iClockTimebase->GetRate()))
+            {
+                //Support rate upto 0.1 resolution
+                uint32 convNumerator = 10;
+                uint32 conversionNumber =
+                    (iClockTimebase->GetRate() * convNumerator) / REALTIME_PLAYBACK_RATE;
+
+                if (conversionNumber != 0)
+                {
+                    deltaTime = (deltaTime * convNumerator) / conversionNumber ;
+                }
+                else
+                {
+                    PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
+                                    (0, "PVMFMediaClock::AdjustScheduling ERROR: Timebase rate corrupted"));
+                }
+            }
+
+            RunIfNotReady((uint32)deltaTime*1000);
+
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVMFMediaClock::AdjustScheduling Timer set for %d msecs wall clock time", deltaTime));
+        }
+        else
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVMFMediaClock::AdjustScheduling Late callback detected", deltaTime));
+            //this means callback is already late. fire asap
+            RunIfNotReady(0);
+        }
+    }
+}
+
+PVMFStatus PVMFMediaClock::SetCallbackDeltaTime(
+    /*IN*/  uint32 aDeltaTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID,
+    /*IN*/  const OsclAny* aInterfaceObject)
+{
+    uint32 currentTime = 0;
+    bool overFlowFlag = false;
+
+    GetCurrentTime32(currentTime, overFlowFlag, PVMF_MEDIA_CLOCK_MSEC);
+
+    return SetCallbackCommon(currentTime + aDeltaTime, aWindow, aCallback,
+                             aThreadLock, aContextData, aCallBackID, aInterfaceObject, currentTime, false);
+}
+
+PVMFStatus PVMFMediaClock::CommonCancelCallback(uint32 aCallbackID, bool aThreadLock, bool aIsNPT)
+{
+    bool flag = 0;
+    int elementRemoved = 0;
+    PVMFStatus retVal;
+
+    if (aThreadLock)
+        iMutex->Lock();
+
+    if (!aIsNPT)
+    {
+        if (!iTimersPriQueue.empty())
+        {
+            if ((iTimersPriQueue.top()).callBackID == (aCallbackID))
+            {
+                flag = 1;
+            }
+
+            //Remove element from queue by ID
+            PVMFMediaClockTimerQueueElement timerQueueElement;
+            timerQueueElement.callBackID = aCallbackID;
+
+            elementRemoved = iTimersPriQueue.remove(timerQueueElement);
+
+            if (elementRemoved && flag)
+            {
+                AdjustScheduling();
+            }
+        }
+    }
+    else
+    {
+        if (!iIsNPTPlayBackDirectionBackwards)
+        {
+            if (!iTimersPriQueueNPT.empty())
+            {
+                if ((iTimersPriQueueNPT.top()).callBackID == (aCallbackID))
+                {
+                    flag = 1;
+                }
+
+                //Remove element from queue by ID
+                PVMFMediaClockTimerQueueElement timerQueueElement;
+                timerQueueElement.callBackID = aCallbackID;
+
+                elementRemoved = iTimersPriQueueNPT.remove(timerQueueElement);
+            }
+        }
+        else
+        {
+            if (!iTimersPriQueueNPTBackwards.empty())
+            {
+                if ((iTimersPriQueueNPTBackwards.top()).callBackID == (aCallbackID))
+                {
+                    flag = 1;
+                }
+
+                //Remove element from queue by ID
+                PVMFMediaClockTimerQueueElement timerQueueElement;
+                timerQueueElement.callBackID = aCallbackID;
+
+                elementRemoved = iTimersPriQueueNPTBackwards.remove(timerQueueElement);
+            }
+        }
+
+        if (elementRemoved && flag)
+        {
+            /*When scheduling is for NPT, make sure to pass isNPT flag i.e. 'true' */
+            AdjustScheduling(true);
+        }
+
+    }
+
+    if (elementRemoved)
+    {
+        iActiveTimersCount--;
+        retVal = PVMFSuccess;
+    }
+    else
+    {
+        retVal = PVMFErrBadHandle;
+    }
+    if (aThreadLock)
+        iMutex->Unlock();
+
+    return retVal;
+}
+
+PVMFStatus PVMFMediaClock::CancelCallback(
+    /*IN*/  uint32 aCallbackID, bool aThreadLock)
+{
+    return CommonCancelCallback(aCallbackID, aThreadLock, false);
+}
+
+PVMFStatus PVMFMediaClock::SetNPTCallbackAbsoluteTime(
+    /*IN*/  uint32 aAbsoluteTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID,
+    /*IN*/  const OsclAny* aInterfaceObject)
+{
+
+    uint32 currentTime = 0;
+
+    GetNPTClockPosition(currentTime);
+
+    return SetCallbackCommon(aAbsoluteTime, aWindow, aCallback,
+                             aThreadLock, aContextData, aCallBackID, aInterfaceObject, currentTime, true);
+
+}
+
+PVMFStatus PVMFMediaClock::SetNPTCallbackDeltaTime(
+    /*IN*/  uint32 aDeltaTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID,
+    /*IN*/  const OsclAny* aInterfaceObject)
+{
+    uint32 currentTime = 0;
+
+    GetNPTClockPosition(currentTime);
+
+    return SetCallbackCommon(currentTime + aDeltaTime, aWindow, aCallback,
+                             aThreadLock, aContextData, aCallBackID, aInterfaceObject, currentTime, true);
+
+}
+
+PVMFStatus PVMFMediaClock::CancelNPTCallback(
+    /*IN*/  uint32 aCallbackID, bool aThreadLock)
+{
+    return CommonCancelCallback(aCallbackID, aThreadLock, true);
+}
+
+void PVMFMediaClock::ClearAllQueues()
+{
+    PVMFMediaClockTimerQueueElement topTimerElement;
+
+    while (iTimersPriQueue.size() != 0)
+    {
+        topTimerElement = iTimersPriQueue.top();
+        iTimersPriQueue.pop();
+        iActiveTimersCount--;
+        topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID,
+                                             PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW, 0,
+                                             topTimerElement.contextData, PVMFErrCallbackClockStopped);
+    }
+
+    if (!iIsNPTPlayBackDirectionBackwards)
+    {
+        while (iTimersPriQueueNPT.size() != 0)
+        {
+            topTimerElement = iTimersPriQueueNPT.top();
+            iTimersPriQueueNPT.pop();
+            iActiveTimersCount--;
+            topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID,
+                                                 PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW, 0,
+                                                 topTimerElement.contextData, PVMFErrCallbackClockStopped);
+        }
+    }
+    else
+    {
+        while (iTimersPriQueueNPTBackwards.size() != 0)
+        {
+            topTimerElement = iTimersPriQueueNPTBackwards.top();
+            iTimersPriQueueNPTBackwards.pop();
+            iActiveTimersCount--;
+            topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID,
+                                                 PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW, 0,
+                                                 topTimerElement.contextData, PVMFErrCallbackClockStopped);
+        }
+    }
+
+}
+
+void PVMFMediaClock::ClearPresentNPTQueue()
+{
+    PVMFMediaClockTimerQueueElement topTimerElement;
+
+    if (!iIsNPTPlayBackDirectionBackwards)
+    {
+        while (iTimersPriQueueNPT.size() != 0)
+        {
+            topTimerElement = iTimersPriQueueNPT.top();
+            iTimersPriQueueNPT.pop();
+            iActiveTimersCount--;
+            topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID,
+                                                 PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW, 0,
+                                                 topTimerElement.contextData, PVMFErrCallbackHasBecomeInvalid);
+        }
+    }
+    else
+    {
+        while (iTimersPriQueueNPTBackwards.size() != 0)
+        {
+            topTimerElement = iTimersPriQueueNPTBackwards.top();
+            iTimersPriQueueNPTBackwards.pop();
+            iActiveTimersCount--;
+            topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID,
+                                                 PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW, 0,
+                                                 topTimerElement.contextData, PVMFErrCallbackHasBecomeInvalid);
+        }
+    }
+}
+
+void PVMFMediaClock::UpdateNPTClockPosition(
+    /*IN*/  uint32 aStartNPT,
+    /*IN*/  bool aIsPlayBackDirectionBackwards)
+{
+    bool overflow = false;
+
+    iStartNPT = aStartNPT;
+
+    GetCurrentTime32(iStartMediaClockTS, overflow, PVMF_MEDIA_CLOCK_MSEC);
+
+    if (iIsNPTPlayBackDirectionBackwards != aIsPlayBackDirectionBackwards)
+    {
+        //NPT clock direction has changed. So invalidate all existing timers
+        ClearPresentNPTQueue();
+    }
+
+    iIsNPTPlayBackDirectionBackwards = aIsPlayBackDirectionBackwards;
+
+    /*reschedule. Send argument as true so that this function knows that
+     scheduling is being done for NPT.*/
+    AdjustScheduling(true);
+}
+
+PVMFStatus PVMFMediaClock::GetNPTClockPosition(
+    /*OUT*/ uint32& aCurrentPosition)
+{
+    uint32 currentTime = 0;
+    bool overflow = false;
+
+    GetCurrentTime32(currentTime, overflow, PVMF_MEDIA_CLOCK_MSEC);
+
+    if (overflow)
+    {
+        return PVMFErrOverflow;
+    }
+
+    if (iIsNPTPlayBackDirectionBackwards)
+    {
+        aCurrentPosition = iStartNPT - (currentTime - iStartMediaClockTS);
+    }
+    else
+    {
+        aCurrentPosition = iStartNPT + (currentTime - iStartMediaClockTS);
+    }
+    return PVMFSuccess;
+}
+
+void PVMFMediaClock::ClearNPTClockPosition()
+{
+    iStartNPT = 0;
+    iStartMediaClockTS = 0;
+    iIsNPTPlayBackDirectionBackwards = 0;
+}
+
+void PVMFMediaClock::QueueClockStartNotificationEvent(uint32 aDelta, PVMFMediaClockStateObserver *aClockStateObserver)
+{
+    PVMFMediaClockStartNotificationEventElement element;
+    uint32 queuedEventID;
+    PVMFStatus status = PVMFFailure;
+
+    element.clockStateObserver = aClockStateObserver;
+
+    //Set a callback on the clock to set this event
+    status = SetCallbackDeltaTime(aDelta, 0, (PVMFMediaClockNotificationsObs*)this, false,
+                                  &iClockStartNotificationEventQueue, queuedEventID, this);
+
+    element.eventID = queuedEventID;
+    if (PVMFSuccess == status)
+    {
+        iClockStartNotificationEventQueue.push_back(element);
+    }
+
+}
+
+PVMFStatus PVMFMediaClock::QueueNPTClockTransitionEvent(uint32 aMediaClockPosition, uint32 aStartNPT,
+        bool aIsPlayBackDirectionBackwards, uint32 aWindow, uint32& aClockTransitionID)
+{
+    PVMFMediaClockNPTTransitionEventElement element;
+    PVMFStatus status = PVMFFailure;
+
+    element.isPlayBackDirectionBackwards = aIsPlayBackDirectionBackwards;
+    element.mediaClockPosition = aMediaClockPosition;
+    element.startNPT = aStartNPT;
+    element.window = aWindow;
+
+    //Set a callback on the clock to set this event
+    status = SetCallbackAbsoluteTime(element.mediaClockPosition, element.window, (PVMFMediaClockNotificationsObs*)this, false,
+                                     &iNPTTransitionEventQueue, aClockTransitionID, this);
+
+    element.eventID = aClockTransitionID;
+    if (PVMFSuccess == status)
+    {
+        iNPTTransitionEventQueue.push_back(element);
+    }
+
+    return status;
+}
+
+PVMFStatus PVMFMediaClock::CancelNPTClockTransitionEvent(uint32 aClockTransitionEventID)
+{
+    PVMFStatus status;
+
+    status = CancelCallback(aClockTransitionEventID, false);
+
+    if (PVMFSuccess != status)
+    {
+        return status;
+    }
+
+    for (uint32 ii = 0;ii < iNPTTransitionEventQueue.size();ii++)
+    {
+        if (iNPTTransitionEventQueue[ii].eventID == aClockTransitionEventID)
+            iNPTTransitionEventQueue.erase(&iNPTTransitionEventQueue[ii]);
+    }
+    return PVMFSuccess;
+}
+
+void PVMFMediaClock::ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 delta,
+                                     const OsclAny* aContextData, PVMFStatus aStatus)
+{
+
+    OSCL_UNUSED_ARG(aTimerAccuracy);
+    OSCL_UNUSED_ARG(delta);
+    if (aStatus != PVMFSuccess)
+    {
+        /*This means the clock was stopped*/
+        return;
+    }
+
+    //if event is NPT transition
+    if (aContextData == (void*)&iNPTTransitionEventQueue)
+    {
+        for (uint32 ii = 0;ii < iNPTTransitionEventQueue.size();ii++)
+        {
+            if (iNPTTransitionEventQueue[ii].eventID == aCallBackID)
+            {
+                UpdateNPTClockPosition(iNPTTransitionEventQueue[ii].startNPT,
+                                       iNPTTransitionEventQueue[ii].isPlayBackDirectionBackwards);
+
+                iNPTTransitionEventQueue.erase(&iNPTTransitionEventQueue[ii]);
+            }
+        }
+    }
+    //if event is clock-start notification
+    else if (aContextData == (void*)&iClockStartNotificationEventQueue)
+    {
+        for (uint32 ii = 0;ii < iClockStartNotificationEventQueue.size();ii++)
+        {
+            if (iClockStartNotificationEventQueue[ii].eventID == aCallBackID)
+            {
+                (iClockStartNotificationEventQueue[ii].clockStateObserver)->ClockStateUpdated();
+                iClockStartNotificationEventQueue.erase(&iClockStartNotificationEventQueue[ii]);
+            }
+        }
+    }
+
+}
+
+void PVMFMediaClock::NotificationsInterfaceDestroyed()
+{
+    //do nothing
+}
+
+void PVMFMediaClock::Run()
+{
+    uint32 currentTime = 0;
+    bool overFlowFlag = false;
+    uint32 delta = 0;
+
+    PVMFMediaClockTimerQueueElement topTimerElement;
+    PVTimeComparisonUtils::MediaTimeStatus status;
+
+    /*Caution: Both loops below should always be similar. Any update needed for regular callback handling
+    loop should also be checked for NPT loop ..and vice versa*/
+
+    if (iTimersPriQueue.size())
+    {
+        topTimerElement = iTimersPriQueue.top();
+
+        GetCurrentTime32(currentTime, overFlowFlag, PVMF_MEDIA_CLOCK_MSEC);
+
+        status = PVTimeComparisonUtils::CheckTimeWindow(topTimerElement.timeOut, currentTime, topTimerElement.window,
+                 topTimerElement.window, delta);
+
+        while (iTimersPriQueue.size() &&
+                status != PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW)
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                            (0, "PVMFMediaClock::Run Timer for regular callback currentTime - %d callbackTime - %d callbackMargin - %d queue size - %d status - %d", currentTime,
+                             topTimerElement.timeOut, topTimerElement.window, iTimersPriQueue.size(), status));
+
+            switch (status)
+            {
+                case PVTimeComparisonUtils::MEDIA_EARLY_WITHIN_WINDOW:
+                case PVTimeComparisonUtils::MEDIA_ONTIME_WITHIN_WINDOW:
+                case PVTimeComparisonUtils::MEDIA_LATE_WITHIN_WINDOW:
+                case PVTimeComparisonUtils::MEDIA_LATE_OUTSIDE_WINDOW:
+                {
+                    iTimersPriQueue.pop();
+                    iActiveTimersCount--;
+                    topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID, status, delta,
+                                                         topTimerElement.contextData, PVMFSuccess);
+                }
+                break;
+
+                case PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW:
+                    //If callback is early, just schedule fresh
+                    break;
+
+                default:
+                {
+                    //@@error
+                }
+            }
+
+            //check if more timers fall within the window.
+            topTimerElement = iTimersPriQueue.top();
+
+            GetCurrentTime32(currentTime, overFlowFlag, PVMF_MEDIA_CLOCK_MSEC);
+
+            status = PVTimeComparisonUtils::CheckTimeWindow(topTimerElement.timeOut, currentTime, topTimerElement.window,
+                     topTimerElement.window, delta);
+        }
+
+        AdjustScheduling(false, currentTime);
+    }
+
+    // Check NPT timers now
+
+    //normal NPT clock
+    if (!iIsNPTPlayBackDirectionBackwards)
+    {
+        if (iTimersPriQueueNPT.size())
+        {
+            topTimerElement = iTimersPriQueueNPT.top();
+
+            GetNPTClockPosition(currentTime);
+
+            status = PVTimeComparisonUtils::CheckTimeWindow(topTimerElement.timeOut, currentTime, topTimerElement.window,
+                     topTimerElement.window, delta);
+
+            while (iTimersPriQueueNPT.size() &&
+                    status != PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                                (0, "PVMFMediaClock::Run Timer for NPT callback currentTime - %d callbackTime - %d callbackMargin - %d queue size - %d status - %d", currentTime,
+                                 topTimerElement.timeOut, topTimerElement.window, iTimersPriQueueNPT.size(), status));
+
+                switch (status)
+                {
+                    case PVTimeComparisonUtils::MEDIA_EARLY_WITHIN_WINDOW:
+                    case PVTimeComparisonUtils::MEDIA_ONTIME_WITHIN_WINDOW:
+                    case PVTimeComparisonUtils::MEDIA_LATE_WITHIN_WINDOW:
+                    case PVTimeComparisonUtils::MEDIA_LATE_OUTSIDE_WINDOW:
+                    {
+                        iTimersPriQueueNPT.pop();
+                        iActiveTimersCount--;
+                        topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID, status, delta,
+                                                             topTimerElement.contextData, PVMFSuccess);
+                    }
+                    break;
+
+                    case PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW:
+                        //If callback is early, just schedule fresh
+                        break;
+
+                    default:
+                    {
+                        //@@error
+                    }
+                }
+
+                //check if more timers fall within the window.
+                topTimerElement = iTimersPriQueueNPT.top();
+
+                GetNPTClockPosition(currentTime);
+
+                status = PVTimeComparisonUtils::CheckTimeWindow(topTimerElement.timeOut, currentTime, topTimerElement.window,
+                         topTimerElement.window, delta);
+            }
+
+            AdjustScheduling(true, currentTime);
+        }
+    }
+    else  /*When direction of NPT clock is backwards. Just use the other queue and reverse calculations*/
+    {
+        if (iTimersPriQueueNPTBackwards.size())
+        {
+            topTimerElement = iTimersPriQueueNPTBackwards.top();
+
+            GetNPTClockPosition(currentTime);
+
+            status = PVTimeComparisonUtils::CheckTimeWindow(topTimerElement.timeOut, currentTime, topTimerElement.window,
+                     topTimerElement.window, delta);
+
+            while (iTimersPriQueueNPTBackwards.size() &&
+                    status != PVTimeComparisonUtils::MEDIA_LATE_OUTSIDE_WINDOW)
+            {
+                PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_INFO,
+                                (0, "PVMFMediaClock::Run Timer for Backwards NPT callback currentTime - %d callbackTime - %d callbackMargin - %d queue size - %d status - %d", currentTime,
+                                 topTimerElement.timeOut, topTimerElement.window, iTimersPriQueueNPTBackwards.size(), status));
+
+                switch (status)
+                {
+                    case PVTimeComparisonUtils::MEDIA_EARLY_WITHIN_WINDOW:
+                    {
+                        iTimersPriQueueNPT.pop();
+                        iActiveTimersCount--;
+                        topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID, PVTimeComparisonUtils::MEDIA_LATE_WITHIN_WINDOW, delta,
+                                                             topTimerElement.contextData, PVMFSuccess);
+                    }
+                    break;
+
+                    case PVTimeComparisonUtils::MEDIA_ONTIME_WITHIN_WINDOW:
+                    case PVTimeComparisonUtils::MEDIA_LATE_WITHIN_WINDOW:
+                    {
+                        iTimersPriQueueNPT.pop();
+                        iActiveTimersCount--;
+                        topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID, PVTimeComparisonUtils::MEDIA_EARLY_WITHIN_WINDOW, delta,
+                                                             topTimerElement.contextData, PVMFSuccess);
+                    }
+                    break;
+                    case PVTimeComparisonUtils::MEDIA_EARLY_OUTSIDE_WINDOW:
+                    {
+                        iTimersPriQueueNPT.pop();
+                        iActiveTimersCount--;
+                        topTimerElement.obs->ProcessCallBack(topTimerElement.callBackID, PVTimeComparisonUtils::MEDIA_LATE_OUTSIDE_WINDOW, delta,
+                                                             topTimerElement.contextData, PVMFSuccess);
+                    }
+                    break;
+
+                    default:
+                    {
+                        //@@error
+                    }
+                }
+
+                //check if more timers fall within the window.
+                topTimerElement = iTimersPriQueueNPTBackwards.top();
+
+                GetNPTClockPosition(currentTime);
+
+                status = PVTimeComparisonUtils::CheckTimeWindow(topTimerElement.timeOut, currentTime, topTimerElement.window,
+                         topTimerElement.window, delta);
+            }
+
+            AdjustScheduling(true, currentTime);
+        }
+    }
+}
+
+OSCL_EXPORT_REF PVMFMediaClockNotificationsInterfaceImpl::PVMFMediaClockNotificationsInterfaceImpl(PVMFMediaClock *aClock,
+        uint32 aLatency,
+        PVMFMediaClockNotificationsObsBase& aNotificationInterfaceDestroyedCallback)
+{
+    iContainer = aClock;
+    iLatency = aLatency;
+    iNotificationInterfaceDestroyedCallback = &aNotificationInterfaceDestroyedCallback;
+    iAdjustedLatency = 0;
+    iClockStateObserver = NULL;
+    iLatencyDelayForClockStartNotification = 0;
+}
+
+OSCL_EXPORT_REF PVMFMediaClockNotificationsInterfaceImpl::~PVMFMediaClockNotificationsInterfaceImpl()
+{
+    //check if vectors need to be destroyed
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFMediaClockNotificationsInterfaceImpl::SetCallbackAbsoluteTime(
+    /*IN*/  uint32 aAbsoluteTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID)
+{
+    if (iContainer)
+    {
+        return iContainer->SetCallbackAbsoluteTime(aAbsoluteTime - iAdjustedLatency, aWindow, aCallback, aThreadLock, aContextData,
+                aCallBackID, this);
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFMediaClockNotificationsInterfaceImpl::SetCallbackDeltaTime(
+    /*IN*/  uint32 aDeltaTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID)
+{
+    if (iContainer)
+    {
+        return iContainer->SetCallbackDeltaTime(aDeltaTime - iAdjustedLatency, aWindow, aCallback, aThreadLock, aContextData,
+                                                aCallBackID, this);
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFMediaClockNotificationsInterfaceImpl::CancelCallback(
+    /*IN*/  uint32 aCallbackID, bool aThreadLock)
+{
+    if (iContainer)
+    {
+        return iContainer->CancelCallback(aCallbackID, aThreadLock);
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFMediaClockNotificationsInterfaceImpl::SetNPTCallbackAbsoluteTime(
+    /*IN*/  uint32 aAbsoluteTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID)
+{
+    if (iContainer)
+    {
+        return iContainer->SetNPTCallbackAbsoluteTime(aAbsoluteTime - iAdjustedLatency, aWindow, aCallback, aThreadLock, aContextData,
+                aCallBackID, this);
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFMediaClockNotificationsInterfaceImpl::SetNPTCallbackDeltaTime(
+    /*IN*/  uint32 aDeltaTime,
+    /*IN*/  uint32 aWindow,
+    /*IN*/  PVMFMediaClockNotificationsObs* aCallback,
+    /*IN*/  bool aThreadLock,
+    /*IN*/  const OsclAny* aContextData,
+    /*OUT*/ uint32& aCallBackID)
+{
+    if (iContainer)
+    {
+        return iContainer->SetNPTCallbackDeltaTime(aDeltaTime - iAdjustedLatency, aWindow, aCallback, aThreadLock, aContextData,
+                aCallBackID, this);
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF PVMFStatus PVMFMediaClockNotificationsInterfaceImpl::CancelNPTCallback(
+    /*IN*/  uint32 aCallbackID, bool aThreadLock)
+{
+    if (iContainer)
+    {
+        return iContainer->CancelNPTCallback(aCallbackID, aThreadLock);
+    }
+    else
+    {
+        return PVMFFailure;
+    }
+}
+
+OSCL_EXPORT_REF void PVMFMediaClockNotificationsInterfaceImpl::SetClockObserver(PVMFMediaClockObserver& aObserver)
+{
+    if (iContainer)
+    {
+        iContainer->SetClockObserver(aObserver);
+    }
+}
+
+OSCL_EXPORT_REF void PVMFMediaClockNotificationsInterfaceImpl::RemoveClockObserver(PVMFMediaClockObserver& aObserver)
+{
+    if (iContainer)
+    {
+        iContainer->RemoveClockObserver(aObserver);
+    }
+}
+
+OSCL_EXPORT_REF void PVMFMediaClockNotificationsInterfaceImpl::SetClockStateObserver(PVMFMediaClockStateObserver& aObserver)
+{
+    iClockStateObserver = &aObserver;
+}
+
+OSCL_EXPORT_REF void PVMFMediaClockNotificationsInterfaceImpl::RemoveClockStateObserver(PVMFMediaClockStateObserver& aObserver)
+{
+    OSCL_UNUSED_ARG(aObserver);
+    iClockStateObserver = NULL;
+}
+
+OSCL_EXPORT_REF void PVMFTimebase_Tickcount::GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow)
+{
+    uint32 currenttickcount = OsclTickCount::TickCount();
+
+    aOverflow = false;
+
+    // Check to see if the tickcount wrapped around
+    if (iPrevTickcount > currenttickcount)
+    {
+        aOverflow = true;
+    }
+
+    aTimebaseTickCount = currenttickcount;
+
+    // Save the current tickcount for next comparison
+    iPrevTickcount = currenttickcount;
+}
+
+OSCL_EXPORT_REF void PVMFTimebase_Tickcount::GetCurrentTime32(uint32& aTime, bool& aOverflow, PVMFMediaClock_TimeUnits aUnits)
+{
+    uint32 currenttickcount = OsclTickCount::TickCount();
+
+    aOverflow = false;
+
+    // Check to see if the tickcount wrapped around
+    if (iPrevTickcount > currenttickcount)
+    {
+        aOverflow = true;
+    }
+
+    if (PVMF_MEDIA_CLOCK_USEC == aUnits)
+    {
+        uint64 time64 = (uint64)(currenttickcount * iMicrosecPerTick);
+        //There is a chance that Tickcount did not wrap around but aTime value does
+        if (time64 > (uint64)(0xFFFFFFFF))
+        {
+            aOverflow = true;
+        }
+        aTime = Oscl_Int64_Utils::get_uint64_lower32(time64);
+    }
+    else                                  /*convert time to millsecs*/
+    {
+        aTime = OsclTickCount::TicksToMsec(currenttickcount);
+        uint32 divConst = 1;
+
+        switch (aUnits)
+        {
+            case PVMF_MEDIA_CLOCK_SEC:
+                divConst = 1000;
+                break;
+
+            case PVMF_MEDIA_CLOCK_MIN:
+                divConst = 60000;
+                break;
+
+            case PVMF_MEDIA_CLOCK_HOUR:
+                divConst = 3600000;
+                break;
+
+            case PVMF_MEDIA_CLOCK_DAY:
+                divConst = 86400000;
+                break;
+
+            case PVMF_MEDIA_CLOCK_MSEC:
+            default:
+                break;
+        }
+
+        aTime = aTime / divConst;
+    }
+
+    // Save the current tickcount for next comparison
+    iPrevTickcount = currenttickcount;
+}
diff --git a/pvmi/pvmf/src/pvmf_media_cmd.cpp b/pvmi/pvmf/src/pvmf_media_cmd.cpp
index 2a42bda..90e16f2 100644
--- a/pvmi/pvmf/src/pvmf_media_cmd.cpp
+++ b/pvmi/pvmf/src/pvmf_media_cmd.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/src/pvmf_media_data.cpp b/pvmi/pvmf/src/pvmf_media_data.cpp
index 3fb3fe9..929757f 100644
--- a/pvmi/pvmf/src/pvmf_media_data.cpp
+++ b/pvmi/pvmf/src/pvmf_media_data.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -187,8 +187,9 @@
 PVMFMediaData::createMediaData(OsclSharedPtr<PVMFMediaDataImpl>& in_impl_ptr,
                                Oscl_DefAlloc* gen_alloc)
 {
-    // allocate enough room
+    OsclSharedPtr<PVMFMediaData> shared_media_data;
 
+    // allocate enough room
     uint8* my_ptr;
     OsclRefCounter* my_refcnt;
 
@@ -204,6 +205,9 @@
                                               aligned_media_data_size +
                                               sizeof(PVMFMediaMsgHeader));
 
+        //not allocators leave, so check for NULL ptr
+        if (my_ptr == NULL) return shared_media_data;
+
         MediaDataCleanupDA *my_cleanup = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, MediaDataCleanupDA(gen_alloc));
         my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, my_cleanup));
         my_ptr += aligned_refcnt_size + aligned_cleanup_size;
@@ -225,7 +229,7 @@
 
     media_data_ptr->impl_ptr = in_impl_ptr;
 
-    OsclSharedPtr<PVMFMediaData> shared_media_data(media_data_ptr, my_refcnt);
+    shared_media_data.Bind(media_data_ptr, my_refcnt);
 
     return shared_media_data;
 }
@@ -235,8 +239,9 @@
                                const PVMFMediaMsgHeader* msgHeader,
                                Oscl_DefAlloc* gen_alloc)
 {
-    // allocate enough room
+    OsclSharedPtr<PVMFMediaData> shared_media_data;
 
+    // allocate enough room
     uint8* my_ptr;
     OsclRefCounter* my_refcnt;
 
@@ -252,6 +257,9 @@
                                               aligned_media_data_size +
                                               sizeof(PVMFMediaMsgHeader));
 
+        //not allocators leave, so check for NULL ptr
+        if (my_ptr == NULL) return shared_media_data;
+
         MediaDataCleanupDA *my_cleanup = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, MediaDataCleanupDA(gen_alloc));
         my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, my_cleanup));
         my_ptr += aligned_refcnt_size + aligned_cleanup_size;
@@ -280,7 +288,7 @@
 
     media_data_ptr->impl_ptr = in_impl_ptr;
 
-    OsclSharedPtr<PVMFMediaData> shared_media_data(media_data_ptr, my_refcnt);
+    shared_media_data.Bind(media_data_ptr, my_refcnt);
 
     return shared_media_data;
 }
diff --git a/pvmi/pvmf/src/pvmf_mempool.cpp b/pvmi/pvmf/src/pvmf_mempool.cpp
index b88a327..fcbf63a 100644
--- a/pvmi/pvmf/src/pvmf_mempool.cpp
+++ b/pvmi/pvmf/src/pvmf_mempool.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,21 +59,19 @@
 {
     OsclAny* freechunk = NULL;
 
-    int32 leavecode = 0;
+    int32 leavecode = OsclErrNone;
     OSCL_TRY_NO_TLS(iOsclErrorTrapImp, leavecode, freechunk = OsclMemPoolFixedChunkAllocator::allocate(n));
-    if (leavecode != 0)
+    if (OsclErrNone != leavecode)
     {
-        if (leavecode == OsclErrNoResources)
+        if (OsclErrNoResources == leavecode)
         {
             // No free chunk is available
             MPLOGDATAPATH((0, "MEMP %s Allocate %d chunk failed--No Free Chunks!", iName.get_cstr(), n));
             OSCL_LEAVE(leavecode);
-            // return NULL;	This statement was removed to avoid compiler warning for Unreachable Code
         }
         else
         {
             OSCL_LEAVE(leavecode);
-            // return freechunk;	This statement was removed to avoid compiler warning for Unreachable Code
         }
     }
 
@@ -86,18 +84,18 @@
 
 OSCL_EXPORT_REF void PVMFMemPoolFixedChunkAllocator::deallocate(OsclAny* p)
 {
-    OsclMemPoolFixedChunkAllocator::deallocate(p);
-
     if (iRefCount > 0)
     {
         MPLOGDATAPATH((0, "MEMP %s Chunk freed, %d/%d in use"
                        , iName.get_cstr(), iNumChunk - iFreeMemChunkList.size(), iNumChunk));
     }
+    OsclMemPoolFixedChunkAllocator::deallocate(p);
 }
 
 
 OSCL_EXPORT_REF void PVMFMemPoolFixedChunkAllocator::LogMediaDataInfo(PVMFSharedMediaDataPtr aMediaData)
 {
+    OSCL_UNUSED_ARG(aMediaData);
     MPLOGDATAPATH(
         (0, "MEMP %s MediaData SeqNum %d, SId %d, TS %d", iName.get_cstr()
          , aMediaData->getSeqNum()
diff --git a/pvmi/pvmf/src/pvmf_node_interface.cpp b/pvmi/pvmf/src/pvmf_node_interface.cpp
index f6d122c..d5d66a4 100644
--- a/pvmi/pvmf/src/pvmf_node_interface.cpp
+++ b/pvmi/pvmf/src/pvmf_node_interface.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/src/pvmf_pool_buffer_allocator.cpp b/pvmi/pvmf/src/pvmf_pool_buffer_allocator.cpp
index 9dfe414..97c737b 100644
--- a/pvmi/pvmf/src/pvmf_pool_buffer_allocator.cpp
+++ b/pvmi/pvmf/src/pvmf_pool_buffer_allocator.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,7 +27,10 @@
 #include "oscl_mem.h"
 #include "oscl_time.h"
 
-OSCL_EXPORT_REF PVMFBufferPoolAllocator::PVMFBufferPoolAllocator() : iFragSize(0), iDestroyPool(false)
+OSCL_EXPORT_REF PVMFBufferPoolAllocator::PVMFBufferPoolAllocator(bool aLeaveOnAllocFailure) :
+        iFragSize(0),
+        iDestroyPool(false),
+        iLeaveOnAllocFailure(aLeaveOnAllocFailure)
 {
     iLogger = PVLogger::GetLoggerObject("pvmf.bufferpoolallocator");
     iAllocNum = 0;
@@ -40,6 +43,11 @@
     iAvailFragments.clear();
 }
 
+OSCL_EXPORT_REF void PVMFBufferPoolAllocator::SetLeaveOnAllocFailure(bool aLeaveOnAllocFailure)
+{
+    iLeaveOnAllocFailure = aLeaveOnAllocFailure;
+}
+
 OSCL_EXPORT_REF void PVMFBufferPoolAllocator::size(uint16 num_frags, uint16 frag_size)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFBufferPoolAllocator::size num_frags(%d), frag_size(%d)", num_frags, frag_size));
@@ -52,7 +60,11 @@
         uint8* buf = (uint8*)OSCL_MALLOC(aligned_refcnt_size + frag_size);
 
         // check for out-of-memory
-        if (!buf) break;
+        if (!buf)
+        {
+            iAvailFragments.clear();
+            OSCL_LEAVE(OSCL_BAD_ALLOC_EXCEPTION_CODE);
+        }
 
         // ref counter will delete itself when refcount goes to 0
         OsclRefCounterDA* ref_counter = OSCL_PLACEMENT_NEW(buf, OsclRefCounterDA(buf, this));
@@ -91,6 +103,7 @@
 
 OSCL_EXPORT_REF OsclRefCounterMemFrag PVMFBufferPoolAllocator::get()
 {
+    OsclRefCounterMemFrag ret;
 #if _DEBUG
     ++iAllocNum;
     if (iFailFrequency)
@@ -101,12 +114,15 @@
         {
             // throw exception
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NONFATAL_ERROR, (0, "PVMFBufferPoolAllocator::get - Simulating out of fragment exception !! \n"));
-            OSCL_LEAVE(OSCL_BAD_ALLOC_EXCEPTION_CODE);
+            if (iLeaveOnAllocFailure)
+            {
+                OSCL_LEAVE(OSCL_BAD_ALLOC_EXCEPTION_CODE);
+            }
+            return ret;
         }
     }
 #endif
 
-    OsclRefCounterMemFrag ret;
     if (!iAvailFragments.empty())
     {
         ret = iAvailFragments.back();
@@ -116,7 +132,10 @@
     }
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_NONFATAL_ERROR, (0, "PVMFBufferPoolAllocator::get - Out of fragments !! \n"));
 
-    OSCL_LEAVE(OSCL_BAD_ALLOC_EXCEPTION_CODE);
+    if (iLeaveOnAllocFailure)
+    {
+        OSCL_LEAVE(OSCL_BAD_ALLOC_EXCEPTION_CODE);
+    }
     return ret;
 }
 
diff --git a/pvmi/pvmf/src/pvmf_port_base_impl.cpp b/pvmi/pvmf/src/pvmf_port_base_impl.cpp
index 5b44d98..96fd72f 100644
--- a/pvmi/pvmf/src/pvmf_port_base_impl.cpp
+++ b/pvmi/pvmf/src/pvmf_port_base_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -318,6 +318,11 @@
         return PVMFFailure;
     }
 
+    //reset busy flags - this would prevent any queue / port ready
+    //events from being generated as we clear the message queues
+    iIncomingQueue.iBusy = false;
+    iOutgoingQueue.iBusy = false;
+
     //Automatically disconnect the peer.
     iConnectedPort->PeerDisconnect();
 
@@ -352,6 +357,11 @@
         return PVMFFailure;
     }
 
+    //reset busy flags - this would prevent any queue / port ready
+    //events from being generated as we clear the message queues
+    iIncomingQueue.iBusy = false;
+    iOutgoingQueue.iBusy = false;
+
     ClearMsgQueues();
 
     iConnectedPort = NULL;
@@ -404,23 +414,49 @@
 #if PVMF_PORT_BASE_IMPL_STATS
     ++iStats.iOutgoingMsgQueued;
 #endif
-    PortActivity(PVMF_PORT_ACTIVITY_OUTGOING_MSG);
 
-    // Outgoing queue size is at capacity and goes into busy state. The owner node is
-    // notified of this transition into busy state.
-    if (isOutgoingFull())
-//	if(iOutgoingQueue.iThreshold!=0 &&
-//		iOutgoingQueue.iQ.size() >= iOutgoingQueue.iCapacity) //(mg) this causes ASF streaming to fail
+    //Attempt to queue the message directly in connected port's incoming msg queue
+    //first. If we cannot queue then we leave the msg in iOutgoingQueue
+    //Doing the push in iOutgoingQueue first followed by Receive ensure that msgs
+    //flow in FIFO order. If we did a Receive first then we would need
+    PVMFStatus status = iConnectedPort->Receive(iOutgoingQueue.iQ.front());
+    if (status == PVMFSuccess)
     {
-        PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
-                        (0, "0x%x PvmfPortBaseImpl::QueueOutgoingMsg: Outgoing queue is full. Goes into busy state.", this));
-        iOutgoingQueue.iBusy = true;
-        PortActivity(PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY);
-#if PVMF_PORT_BASE_IMPL_STATS
-        ++iStats.iOutgoingQueueBusy;
+        // Dequeue the message
+        PVMFSharedMediaMsgPtr msg = iOutgoingQueue.iQ.front();
+        iOutgoingQueue.iQ.pop();
+#if (PVLOGGER_INST_LEVEL > PVLOGMSG_INST_LLDBG)
+        //log to datapath
+        if (iDatapathLogger)
+        {
+            LogMediaMsgInfo(msg, "Msg Sent Directly", iOutgoingQueue);
+        }
 #endif
+#if PVMF_PORT_BASE_IMPL_STATS
+        // Count this message as either sent successfully,
+        ++iStats.iOutgoingMsgSent;
+#endif
+        return status;
+        //there is no need to queue port activity PVMF_PORT_ACTIVITY_OUTGOING_MSG
+        //here since we have successfully q'd the msg on connected port's incoming
+        //msg queue
     }
-
+    else
+    {
+        PortActivity(PVMF_PORT_ACTIVITY_OUTGOING_MSG);
+        // Outgoing queue size is at capacity and goes into busy state. The owner node is
+        // notified of this transition into busy state.
+        if (isOutgoingFull())
+        {
+            PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, iLogger, PVLOGMSG_DEBUG,
+                            (0, "0x%x PvmfPortBaseImpl::QueueOutgoingMsg: Outgoing queue is full. Goes into busy state.", this));
+            iOutgoingQueue.iBusy = true;
+            PortActivity(PVMF_PORT_ACTIVITY_OUTGOING_QUEUE_BUSY);
+#if PVMF_PORT_BASE_IMPL_STATS
+            ++iStats.iOutgoingQueueBusy;
+#endif
+        }
+    }
     return PVMFSuccess;
 }
 
@@ -556,6 +592,10 @@
 void PvmfPortBaseImpl::LogMediaMsgInfo(PVMFSharedMediaMsgPtr aMediaMsg, const char* msg, PvmfPortBaseImplQueue&q)
 //log media msg info, description, and associated q-depth.
 {
+    // to avoid compiler warnings when logger is not available
+    OSCL_UNUSED_ARG(msg);
+    OSCL_UNUSED_ARG(q);
+
     switch (aMediaMsg->getFormatID())
     {
         case PVMF_MEDIA_CMD_BOS_FORMAT_ID:
@@ -621,6 +661,9 @@
 OSCL_EXPORT_REF void PvmfPortBaseImpl::LogMediaMsgInfo(PVMFSharedMediaMsgPtr aMediaMsg, const char* msg, int32 qsize)
 //log media msg info, description, and associated q-depth.
 {
+    OSCL_UNUSED_ARG(msg);
+    OSCL_UNUSED_ARG(qsize);
+
     if (!iDatapathLogger)
         return;
 
@@ -672,6 +715,10 @@
 OSCL_EXPORT_REF void PvmfPortBaseImpl::LogMediaDataInfo(PVMFSharedMediaDataPtr aMediaData, const char* msg, int32 qsize)
 //log media data info, description, and associated q-depth.
 {
+    OSCL_UNUSED_ARG(aMediaData);
+    OSCL_UNUSED_ARG(msg);
+    OSCL_UNUSED_ARG(qsize);
+
     if (!iDatapathLogger)
         return;
 
diff --git a/pvmi/pvmf/src/pvmf_simple_media_buffer.cpp b/pvmi/pvmf/src/pvmf_simple_media_buffer.cpp
index aba0b2f..e0b5923 100644
--- a/pvmi/pvmf/src/pvmf_simple_media_buffer.cpp
+++ b/pvmi/pvmf/src/pvmf_simple_media_buffer.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -184,7 +184,7 @@
 
 OSCL_EXPORT_REF OsclSharedPtr<PVMFMediaDataImpl> PVMFSimpleMediaBufferCombinedAlloc::allocate(uint32 requested_size)
 {
-
+    OsclSharedPtr<PVMFMediaDataImpl> shared_media_data;
     if (requested_size == 0)
     {
         requested_size = PVMF_SIMPLE_MEDIA_BUF_DEFAULT_SIZE;
@@ -195,38 +195,30 @@
     OsclRefCounter* my_refcnt;
     uint8* my_ptr;
 
-    if (! gen_alloc)
-    {
-        OsclMemAllocator my_alloc;
-        aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterSA<SimpleMediaBufferCombinedCleanupSA>));
-        my_ptr = (uint8*) my_alloc.ALLOCATE(aligned_refcnt_size +
-                                            aligned_class_size + requested_size);
-        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterSA<SimpleMediaBufferCombinedCleanupSA>(my_ptr));
-        my_ptr += aligned_refcnt_size;
-    }
-    else
-    {
-        uint aligned_cleanup_size = oscl_mem_aligned_size(sizeof(SimpleMediaBufferCombinedCleanupDA));
-        aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
-        my_ptr = (uint8*) gen_alloc->ALLOCATE(aligned_refcnt_size + aligned_cleanup_size +
-                                              aligned_class_size + requested_size);
-        SimpleMediaBufferCombinedCleanupDA* cleanup_ptr = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, SimpleMediaBufferCombinedCleanupDA(gen_alloc));
+    uint aligned_cleanup_size = oscl_mem_aligned_size(sizeof(SimpleMediaBufferCombinedCleanupDA));
+    aligned_refcnt_size = oscl_mem_aligned_size(sizeof(OsclRefCounterDA));
+    my_ptr = (uint8*) gen_alloc->ALLOCATE(aligned_refcnt_size + aligned_cleanup_size +
+                                          aligned_class_size + requested_size);
 
-        // create the recounter after the cleanup object
-        my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
-        my_ptr += aligned_refcnt_size + aligned_cleanup_size;
+    if (my_ptr == NULL)
+    {
+        //we assume that gen_alloc (Oscl_DefAlloc implementation) provided to this
+        //class does not throw an exception during the normal course of operation
+        //viz. running out of memory in a memory pool temporarily
+        return shared_media_data;
     }
+    SimpleMediaBufferCombinedCleanupDA* cleanup_ptr = OSCL_PLACEMENT_NEW(my_ptr + aligned_refcnt_size, SimpleMediaBufferCombinedCleanupDA(gen_alloc));
+
+    // create the recounter after the cleanup object
+    my_refcnt = OSCL_PLACEMENT_NEW(my_ptr, OsclRefCounterDA(my_ptr, cleanup_ptr));
+    my_ptr += aligned_refcnt_size + aligned_cleanup_size;
 
 
 
     void *ptr;
     ptr = my_ptr + aligned_class_size;
-
     PVMFMediaDataImpl* media_data_ptr = OSCL_PLACEMENT_NEW(my_ptr, PVMFSimpleMediaBuffer(ptr, requested_size, my_refcnt));
-
-    OsclSharedPtr<PVMFMediaDataImpl> shared_media_data(media_data_ptr, my_refcnt);
-
+    shared_media_data.Bind(media_data_ptr, my_refcnt);
     return shared_media_data;
-
 }
 
diff --git a/pvmi/pvmf/src/pvmf_sync_util.cpp b/pvmi/pvmf/src/pvmf_sync_util.cpp
index 3ff1f73..b245bf2 100644
--- a/pvmi/pvmf/src/pvmf_sync_util.cpp
+++ b/pvmi/pvmf/src/pvmf_sync_util.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
     iLogger = PVLogger::GetLoggerObject("PvmfSyncUtil");
 }
 
-OSCL_EXPORT_REF PVMFStatus PvmfSyncUtil::SetClock(OsclClock* aClock)
+OSCL_EXPORT_REF PVMFStatus PvmfSyncUtil::SetClock(PVMFMediaClock* aClock)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PvmfSyncUtil::SetClockAndTimebase: aClock=0x%x", aClock));
@@ -50,7 +50,7 @@
     return PVMFSuccess;
 }
 
-OSCL_EXPORT_REF PVMFStatus PvmfSyncUtil::SetFrameStepClock(OsclClock* aClock)
+OSCL_EXPORT_REF PVMFStatus PvmfSyncUtil::SetFrameStepClock(PVMFMediaClock* aClock)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PvmfSyncUtil::SetClockAndTimebase: SetFrameStepClock=0x%x", aClock));
@@ -127,7 +127,7 @@
     // Get current playback clock time
     uint32 currentTime = 0;
     bool overflow = false;
-    iClock->GetCurrentTime32(currentTime, overflow, OSCLCLOCK_MSEC);
+    iClock->GetCurrentTime32(currentTime, overflow, PVMF_MEDIA_CLOCK_MSEC);
 
     // Check if in sync
     if (currentTime > (uint32)iLateMargin)
diff --git a/pvmi/pvmf/src/pvmf_sync_util_data_queue.cpp b/pvmi/pvmf/src/pvmf_sync_util_data_queue.cpp
index bcd0ec4..73ed3bd 100644
--- a/pvmi/pvmf/src/pvmf_sync_util_data_queue.cpp
+++ b/pvmi/pvmf/src/pvmf_sync_util_data_queue.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,6 +50,7 @@
     iDiagnosticsLogger = PVLogger::GetLoggerObject("pvplayerdiagnostics.syncutil");
     iLateFrameDropEnable = true;
     iClock = NULL;
+    iClockNotificationsInf = NULL;
     iSyncFrameCount = iClockFrameCount = 0;
     iClockOwner = false;
     SetName(name);
@@ -76,10 +77,12 @@
 {
     LogDiagnostics();
     Clear();
+
     //remove ourself as observer of clock.
-    if (iClock)
+    if (iClockNotificationsInf && iClock)
     {
-        iClock->RemoveClockObserver(*this);
+        iClockNotificationsInf->RemoveClockObserver(*this);
+        iClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
     }
 }
 
@@ -145,42 +148,59 @@
     }
 }
 
+OSCL_EXPORT_REF void PvmfSyncUtilDataQueue::NotificationsInterfaceDestroyed()
+{
+    iClockNotificationsInf = NULL;
+}
+
 OSCL_EXPORT_REF void PvmfSyncUtilDataQueue::ClockAdjusted()
 {
-    uint64 clktime;
-    uint64 tbtime;
-    iClock->GetCurrentTime64(clktime, OSCLCLOCK_MSEC, tbtime);
+    uint32 clktime;
+    uint32 tbtime;
+    bool overflow;
+    iClock->GetCurrentTime32(clktime, overflow, PVMF_MEDIA_CLOCK_MSEC, tbtime);
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PvmfSyncUtil::ClockAdjusted, new value %d", (uint32)clktime));
 }
 
-OSCL_EXPORT_REF PVMFStatus PvmfSyncUtilDataQueue::SetClock(OsclClock* aClock)
+OSCL_EXPORT_REF PVMFStatus PvmfSyncUtilDataQueue::SetClock(PVMFMediaClock* aClock)
 {
     //set clock for 'sync always' mode.
     return DoSetClock(aClock, true);
 }
 
-OSCL_EXPORT_REF PVMFStatus PvmfSyncUtilDataQueue::SetClockForFrameStep(OsclClock* aClock)
+OSCL_EXPORT_REF PVMFStatus PvmfSyncUtilDataQueue::SetClockForFrameStep(PVMFMediaClock* aClock)
 {
     //set clock for 'sync only during frame step' mode.
     return DoSetClock(aClock, false);
 }
 
-PVMFStatus PvmfSyncUtilDataQueue::DoSetClock(OsclClock* aClock, bool aSyncAlways)
+PVMFStatus PvmfSyncUtilDataQueue::DoSetClock(PVMFMediaClock* aClock, bool aSyncAlways)
 {
     PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
                     (0, "PvmfSyncUtil::DoSetClock, Clk 0x%x syncAlways %d", aClock, aSyncAlways));
 
     //remove ourself as observer of old clock, if any.
-    if (iClock)
-        iClock->RemoveClockObserver(*this);
+    if (iClockNotificationsInf && iClock)
+    {
+        iClockNotificationsInf->RemoveClockObserver(*this);
+        iClock->DestroyMediaClockNotificationsInterface(iClockNotificationsInf);
+        iClockNotificationsInf = NULL;
+    }
 
     //save new clock.
     iClock = aClock;
 
-    //set ourself as observer of new clock.
     if (iClock)
-        iClock->SetClockObserver(*this);
+    {
+        iClock->ConstructMediaClockNotificationsInterface(iClockNotificationsInf, *this);
+    }
+
+    //set ourself as observer of new clock.
+    if (iClockNotificationsInf)
+    {
+        iClockNotificationsInf->SetClockObserver(*this);
+    }
 
     //make a note of initial clock timebase
     ClockTimebaseUpdated();
@@ -201,6 +221,8 @@
 void PvmfSyncUtilDataQueue::LogMediaMsgInfo(PVMFSharedMediaMsgPtr aMediaMsg, const char* msg)
 //log media msg info, description, and associated q-depth.
 {
+    OSCL_UNUSED_ARG(aMediaMsg);
+    OSCL_UNUSED_ARG(msg);
     if (!iDatapathLogger)
     {
         return;//unexpected call.
@@ -222,6 +244,9 @@
 void PvmfSyncUtilDataQueue::LogMediaMsgInfo(PVMFSharedMediaMsgPtr aMediaMsg, const char* msg, uint32 time)
 //log media msg info, time value, description, and associated q-depth.
 {
+    OSCL_UNUSED_ARG(aMediaMsg);
+    OSCL_UNUSED_ARG(msg);
+    OSCL_UNUSED_ARG(time);
     if (!iDatapathLogger)
     {
         return;//unexpected call.
@@ -248,7 +273,7 @@
         return PVMFSuccess;
     }
 
-    int32 err = 0;
+    int32 err = OsclErrNone;
     OSCL_TRY(err,
              iDataQueue.reserve(aReserveSize);
             );
@@ -273,7 +298,7 @@
         *aSkipped = 0;
     }
 
-    int32 err = 0;
+    int32 err = OsclErrNone;
     if (aFront)
     {
         OSCL_TRY_NO_TLS(iOsclErrorTrapImp, err, iDataQueue.push_front(aMediaMsg););
@@ -409,16 +434,17 @@
 
     //if the frame timestamp is ahead of the clock, update the
     //clock to the timestamp.
-    uint64 clktime;
-    uint64 tbtime;
-    iClock->GetCurrentTime64(clktime, OSCLCLOCK_MSEC, tbtime);
+    uint32 clktime;
+    uint32 tbtime;
+    bool overflow = 0;
+    iClock->GetCurrentTime32(clktime, overflow, PVMF_MEDIA_CLOCK_MSEC, tbtime);
     if (aTimestamp > (PVMFTimestamp)clktime)
     {
-        uint64 adjtime = aTimestamp;
+        uint32 adjtime = aTimestamp;
         PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
                         (0, "PvmfSyncUtilDataQueue::FrameStepClkAdjust: from %d to %d", (uint32)clktime, (uint32)adjtime));
-        bool ok = iClock->AdjustClockTime64(clktime, tbtime, adjtime, OSCLCLOCK_MSEC);
-        if (!ok)
+        PVMFMediaClockAdjustTimeStatus ok = iClock->AdjustClockTime32(clktime, tbtime, adjtime, PVMF_MEDIA_CLOCK_MSEC, overflow);
+        if (PVMF_MEDIA_CLOCK_ADJUST_SUCCESS != ok)
         {
             PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
                             (0, "PvmfSyncUtilDataQueue::FrameStepClkAdjust: from %d to %d FAILED", (uint32)clktime, (uint32)adjtime));
diff --git a/pvmi/pvmf/src/pvmf_timestamp.cpp b/pvmi/pvmf/src/pvmf_timestamp.cpp
index d4dbbbe..9b0cd2d 100644
--- a/pvmi/pvmf/src/pvmf_timestamp.cpp
+++ b/pvmi/pvmf/src/pvmf_timestamp.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/pvmf/src/pvmi_config_and_capability_utils.cpp b/pvmi/pvmf/src/pvmi_config_and_capability_utils.cpp
index 462eeee..42ee16d 100644
--- a/pvmi/pvmf/src/pvmi_config_and_capability_utils.cpp
+++ b/pvmi/pvmf/src/pvmi_config_and_capability_utils.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,8 +42,8 @@
             char *param;
             if (pv_mime_string_extract_param(0, aIdentifier, param))
             {
-                if (oscl_strcmp(param, "attr=cap") &&
-                        oscl_strcmp(param, "attr=cur"))
+                if (oscl_strncmp(param, "attr=cap", oscl_strlen("attr=cap")) &&
+                        oscl_strncmp(param, "attr=cur", oscl_strlen("attr=cur")))
                     return PVMFErrNotSupported;
             }
         }
@@ -63,7 +63,7 @@
     ptr += sizeof(PvmiKvp);
     aParameters->key = (PvmiKeyType)ptr;
     oscl_strncpy(aParameters->key, iFormatValTypeString.get_cstr(), strLen);
-    aParameters->value.int32_value = iFormat;
+    aParameters->value.pChar_value = (char*)iFormat.getMIMEStrPtr();
     aParameters->length = aParameters->capacity = strLen;
 
     return PVMFSuccess;
@@ -95,10 +95,10 @@
         aRet_kvp = aParameters;
         OSCL_LEAVE(OsclErrArgument);
     }
-    else if (IsFormatSupported(aParameters->value.int32_value))
+    else if (IsFormatSupported(aParameters->value.pChar_value))
     {
         aRet_kvp = NULL;
-        iFormat = (PVMFFormatType)aParameters->value.int32_value;
+        iFormat = (PVMFFormatType)aParameters->value.pChar_value;
         //notify derived class of format update.
         //This function may leave.
         FormatUpdated();
@@ -121,7 +121,7 @@
         return PVMFErrNotSupported;
     }
 
-    if (IsFormatSupported(aParameters->value.int32_value))
+    if (IsFormatSupported(aParameters->value.pChar_value))
     {
         return PVMFSuccess;
     }
@@ -140,7 +140,7 @@
     kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
     OsclError::LeaveIfNull(kvp.key);
     oscl_strncpy(kvp.key, aFormatValType, kvp.length);
-    kvp.value.int32_value = (int32)aFormat;
+    kvp.value.pChar_value = (char*)aFormat.getMIMEStrPtr();
 
     PvmiKvp* retKvp = NULL; // for return value
     aPort->setParametersSync(NULL, &kvp, 1, retKvp);
diff --git a/pvmi/pvmf/src/pvmi_kvp_util.cpp b/pvmi/pvmf/src/pvmi_kvp_util.cpp
index a731965..ece8ac3 100644
--- a/pvmi/pvmf/src/pvmi_kvp_util.cpp
+++ b/pvmi/pvmf/src/pvmi_kvp_util.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,13 +15,21 @@
  * and limitations under the License.
  * -------------------------------------------------------------------
  */
+#ifndef PVMI_KVP_UTIL_H_INCLUDED
 #include "pvmi_kvp_util.h"
+#endif
 
+#ifndef OSCL_MIME_STRING_UTILS_H
 #include "pv_mime_string_utils.h"
+#endif
 
+#ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
 #include "oscl_string_containers.h"
+#endif
 
-
+#ifndef OSCL_EXCLUSIVE_PTR_H_INCLUDED
+#include "oscl_exclusive_ptr.h"
+#endif
 
 OSCL_EXPORT_REF PvmiKvpType GetTypeFromKeyString(PvmiKeyType aKeyString)
 {
@@ -346,10 +354,13 @@
     }
     uint32 valuelen = aValString.get_size() + 1;
 
-// Allocate memory for the strings
-    int32 leavecode = 0, leavecode1 = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen););
+    /* Allocate memory for the strings
+    "keyExclusivePtr" pointer is used to prevent any memory leak
+     in case some exception occurs while allocating memory for "value array" */
+
+    OsclExclusiveArrayPtr<char> keyExclusivePtr;
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
+    keyExclusivePtr.set(aKeyVal.key);
 
     if (aTruncateFlag)
     {
@@ -360,47 +371,29 @@
     }
     if (aMaxSize >= valuelen)
     {
-        OSCL_TRY(leavecode,
-                 aKeyVal.value.pWChar_value = OSCL_ARRAY_NEW(oscl_wchar, valuelen););
+        aKeyVal.value.pWChar_value = OSCL_ARRAY_NEW(oscl_wchar, valuelen);
     }
 
-    if (leavecode == 0 && leavecode1 == 0)
+    keyExclusivePtr.release();
+    // Copy the key string
+    oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR));
+    if (aMiscKeyParam)
     {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_WCHARPTR_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = '\0';
-        // Copy the value
-        if (aKeyVal.value.pWChar_value != NULL)
-        {
-            oscl_strncpy(aKeyVal.value.pWChar_value, aValString.get_cstr(), valuelen);
-            aKeyVal.value.pWChar_value[valuelen-1] = '\0';
-        }
-        // Set the length and capacity
-        aKeyVal.length = valuelen;
-        aKeyVal.capacity = valuelen;
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
-    else
+    aKeyVal.key[keylen-1] = '\0';
+    // Copy the value
+    if (aKeyVal.value.pWChar_value != NULL)
     {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pWChar_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pWChar_value);
-        }
-
-        return PVMFErrNoMemory;
+        oscl_strncpy(aKeyVal.value.pWChar_value, aValString.get_cstr(), valuelen);
+        aKeyVal.value.pWChar_value[valuelen-1] = '\0';
     }
+    // Set the length and capacity
+    aKeyVal.length = valuelen;
+    aKeyVal.capacity = valuelen;
 
     return PVMFSuccess;
 }
@@ -432,11 +425,11 @@
     }
 
     uint32 valuelen = oscl_strlen(aValString) + 1;
-
-    // Allocate memory for the strings
-    int32 leavecode = 0, leavecode1 = 0;
-
-    OSCL_TRY(leavecode, aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);)
+    /* keyExclusivePtr" pointer is used to prevent any memory leak
+       in case some exception occurs while allocating memory for "value array" */
+    OsclExclusiveArrayPtr<char> keyExclusivePtr;
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
+    keyExclusivePtr.set(aKeyVal.key);
 
     if (aTruncateFlag)
     {
@@ -447,45 +440,28 @@
 
     }
     if (aMaxSize >= valuelen)
-        OSCL_TRY(leavecode1, aKeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen););
+        aKeyVal.value.pChar_value = OSCL_ARRAY_NEW(char, valuelen);
 
-    if (leavecode == 0 && leavecode1 == 0)
+    keyExclusivePtr.release();
+    // Copy the key string
+    oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
+    if (aMiscKeyParam)
     {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = '\0';
-        // Copy the value
-        if (aKeyVal.value.pChar_value != NULL)
-        {
-            oscl_strncpy(aKeyVal.value.pChar_value, aValString, valuelen);
-            aKeyVal.value.pChar_value[valuelen-1] = '\0';
-        }
-        // Set the length and capacity
-        aKeyVal.length = valuelen;
-        aKeyVal.capacity = valuelen;
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
-    else
+    aKeyVal.key[keylen-1] = '\0';
+    // Copy the value
+    if (aKeyVal.value.pChar_value != NULL)
     {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pChar_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pChar_value);
-        }
-
-        return PVMFErrNoMemory;
+        oscl_strncpy(aKeyVal.value.pChar_value, aValString, valuelen);
+        aKeyVal.value.pChar_value[valuelen-1] = '\0';
     }
+    // Set the length and capacity
+    aKeyVal.length = valuelen;
+    aKeyVal.capacity = valuelen;
 
     return PVMFSuccess;
 }
@@ -513,52 +489,38 @@
         keylen += oscl_strlen(aMiscKeyParam);
     }
 
-    /* Allocate memory for the strings */
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-             aKeyVal.value.pUint8_value = OSCL_ARRAY_NEW(uint8, aValueLen);
-            );
+    /* Allocate memory for the strings
+       "keyExclusivePtr" pointer is used to prevent any memory leak
+       in case some exception occurs while allocating memory for "value array" */
+    OsclExclusiveArrayPtr<char> keyExclusivePtr;
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
+    keyExclusivePtr.set(aKeyVal.key);
+    aKeyVal.value.pUint8_value = OSCL_ARRAY_NEW(uint8, aValueLen);
+    keyExclusivePtr.release();
 
-    if (leavecode == 0)
+    /* Copy the key string */
+    oscl_strncpy(aKeyVal.key,
+                 aKeyTypeString,
+                 oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key,
+                 PVMI_KVP_SEMICOLON_STRING_CONSTCHAR,
+                 oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key,
+                 PVMI_KVPVALTYPE_STRING_CONSTCHAR,
+                 oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key,
+                 PVMI_KVPVALTYPE_UINT8PTR_STRING,
+                 oscl_strlen(PVMI_KVPVALTYPE_UINT8PTR_STRING));
+    if (aMiscKeyParam)
     {
-        /* Copy the key string */
-        oscl_strncpy(aKeyVal.key,
-                     aKeyTypeString,
-                     oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key,
-                     PVMI_KVP_SEMICOLON_STRING_CONSTCHAR,
-                     oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key,
-                     PVMI_KVPVALTYPE_STRING_CONSTCHAR,
-                     oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key,
-                     PVMI_KVPVALTYPE_UINT8PTR_STRING,
-                     oscl_strlen(PVMI_KVPVALTYPE_UINT8PTR_STRING));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = NULL_TERM_CHAR;
-        /* Copy the value */
-        oscl_memcpy(aKeyVal.value.pUint8_value, aValue, aValueLen);
-        aKeyVal.length   = aValueLen;
-        aKeyVal.capacity = aValueLen;
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
-    else
-    {
-        /* Memory allocation failed so clean up */
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        if (aKeyVal.value.pUint8_value)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.value.pUint8_value);
-        }
-        return PVMFErrNoMemory;
-    }
+    aKeyVal.key[keylen-1] = NULL_TERM_CHAR;
+    /* Copy the value */
+    oscl_memcpy(aKeyVal.value.pUint8_value, aValue, aValueLen);
+    aKeyVal.length   = aValueLen;
+    aKeyVal.capacity = aValueLen;
+
     return PVMFSuccess;
 }
 
@@ -583,40 +545,24 @@
     }
 
     // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-            );
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
 
-    if (leavecode == 0)
-    {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = '\0';
-        // Copy the value
-        aKeyVal.value.uint32_value = aValueUInt32;
-        // Set the length and capacity
-        aKeyVal.length = 1;
-        aKeyVal.capacity = 1;
-    }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
 
-        return PVMFErrNoMemory;
+    // Copy the key string
+    oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING_CONSTCHAR));
+    if (aMiscKeyParam)
+    {
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
+    aKeyVal.key[keylen-1] = '\0';
+    // Copy the value
+    aKeyVal.value.uint32_value = aValueUInt32;
+    // Set the length and capacity
+    aKeyVal.length = 1;
+    aKeyVal.capacity = 1;
 
     return PVMFSuccess;
 }
@@ -643,40 +589,23 @@
     }
 
     // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-            );
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
 
-    if (leavecode == 0)
+    // Copy the key string
+    oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_FLOAT_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_FLOAT_STRING_CONSTCHAR));
+    if (aMiscKeyParam)
     {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_FLOAT_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_FLOAT_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = '\0';
-        // Copy the value
-        aKeyVal.value.float_value = aValueFloat;
-        // Set length and capacity
-        aKeyVal.length = 1;
-        aKeyVal.capacity = 1;
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-
-        return PVMFErrNoMemory;
-    }
+    aKeyVal.key[keylen-1] = '\0';
+    // Copy the value
+    aKeyVal.value.float_value = aValueFloat;
+    // Set length and capacity
+    aKeyVal.length = 1;
+    aKeyVal.capacity = 1;
 
     return PVMFSuccess;
 }
@@ -703,40 +632,23 @@
     }
 
     // Allocate memory for the strings
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-            );
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
 
-    if (leavecode == 0)
+    // Copy the key string
+    oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR));
+    if (aMiscKeyParam)
     {
-        // Copy the key string
-        oscl_strncpy(aKeyVal.key, aKeyTypeString, oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key, PVMI_KVP_SEMICOLON_STRING_CONSTCHAR, oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key, PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR, oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING_CONSTCHAR));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = '\0';
-        // Copy the value
-        aKeyVal.value.bool_value = aValueBool;
-        // Set length and capacity
-        aKeyVal.length = 1;
-        aKeyVal.capacity = 1;
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
-    else
-    {
-        // Memory allocation failed so clean up
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-
-        return PVMFErrNoMemory;
-    }
+    aKeyVal.key[keylen-1] = '\0';
+    // Copy the value
+    aKeyVal.value.bool_value = aValueBool;
+    // Set length and capacity
+    aKeyVal.length = 1;
+    aKeyVal.capacity = 1;
 
     return PVMFSuccess;
 }
@@ -762,49 +674,31 @@
     }
 
     /* Allocate memory for the strings */
-    int32 leavecode = 0;
-    OSCL_TRY(leavecode,
-             aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
-             aKeyVal.value.key_specific_value = NULL;
-            );
+    aKeyVal.key = OSCL_ARRAY_NEW(char, keylen);
+    aKeyVal.value.key_specific_value = NULL;
 
-    if (leavecode == 0)
+
+    /* Copy the key string */
+    oscl_strncpy(aKeyVal.key,
+                 aKeyTypeString,
+                 oscl_strlen(aKeyTypeString) + 1);
+    oscl_strncat(aKeyVal.key,
+                 PVMI_KVP_SEMICOLON_STRING_CONSTCHAR,
+                 oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key,
+                 PVMI_KVPVALTYPE_STRING_CONSTCHAR,
+                 oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
+    oscl_strncat(aKeyVal.key,
+                 PVMI_KVPVALTYPE_KSV_STRING,
+                 oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
+    if (aMiscKeyParam)
     {
-        /* Copy the key string */
-        oscl_strncpy(aKeyVal.key,
-                     aKeyTypeString,
-                     oscl_strlen(aKeyTypeString) + 1);
-        oscl_strncat(aKeyVal.key,
-                     PVMI_KVP_SEMICOLON_STRING_CONSTCHAR,
-                     oscl_strlen(PVMI_KVP_SEMICOLON_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key,
-                     PVMI_KVPVALTYPE_STRING_CONSTCHAR,
-                     oscl_strlen(PVMI_KVPVALTYPE_STRING_CONSTCHAR));
-        oscl_strncat(aKeyVal.key,
-                     PVMI_KVPVALTYPE_KSV_STRING,
-                     oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
-        if (aMiscKeyParam)
-        {
-            oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
-        }
-        aKeyVal.key[keylen-1] = '\0';
-        /* Copy the value */
-        aKeyVal.value.key_specific_value = aValue;
+        oscl_strncat(aKeyVal.key, aMiscKeyParam, oscl_strlen(aMiscKeyParam));
     }
-    else
-    {
-        /* Memory allocation failed so clean up */
-        if (aKeyVal.key)
-        {
-            OSCL_ARRAY_DELETE(aKeyVal.key);
-            aKeyVal.key = NULL;
-        }
-        return PVMFErrNoMemory;
-    }
+    aKeyVal.key[keylen-1] = '\0';
+    /* Copy the value */
+    aKeyVal.value.key_specific_value = aValue;
+
     return PVMFSuccess;
 }
 
-
-
-
-
diff --git a/pvmi/recognizer/Android.mk b/pvmi/recognizer/Android.mk
index 301487a..764e8ae 100644
--- a/pvmi/recognizer/Android.mk
+++ b/pvmi/recognizer/Android.mk
@@ -3,28 +3,31 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmf_recognizer_registry.cpp \
-	src/pvmf_recognizer_registry_impl.cpp
-
+ 	src/pvmf_recognizer_registry_impl.cpp
 
 
 LOCAL_MODULE := libpvmfrecognizer
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/recognizer/include \
-	$(PV_TOP)//pvmi/recognizer/src \
-	$(PV_TOP)/pvmi/pvmf/include \
-	$(PV_TOP)/baselibs/pv_mime_utils/src \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/recognizer/src \
+ 	$(PV_TOP)/pvmi/recognizer/include \
+ 	/pvmi/pvmf/include \
+ 	/baselibs/pv_mime_utils/src \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
 	include/pvmf_recognizer_registry.h \
-	include/pvmf_recognizer_types.h \
-	include/pvmf_recognizer_plugin.h
+ 	include/pvmf_recognizer_types.h \
+ 	include/pvmf_recognizer_plugin.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/recognizer/build/make/local.mk b/pvmi/recognizer/build/make/local.mk
new file mode 100644
index 0000000..72b9a44
--- /dev/null
+++ b/pvmi/recognizer/build/make/local.mk
@@ -0,0 +1,32 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmfrecognizer
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+XINCDIRS +=  $(VOB_BASE_DIR)/pvmi/pvmf/include \
+  $(VOB_BASE_DIR)/baselibs/pv_mime_utils/src
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmf_recognizer_registry.cpp \
+	pvmf_recognizer_registry_impl.cpp
+
+HDRS := pvmf_recognizer_registry.h \
+	pvmf_recognizer_types.h \
+    pvmf_recognizer_plugin.h
+
+include $(MK)/library.mk
+
+
+
diff --git a/pvmi/recognizer/build/make/makefile b/pvmi/recognizer/build/make/makefile
deleted file mode 100644
index cb967ba..0000000
--- a/pvmi/recognizer/build/make/makefile
+++ /dev/null
@@ -1,65 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmfrecognizer
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS += 
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += -I../../../config/$(BUILD_ARCH)  -I../../../config/shared
-
-XINCDIRS += -I $(VOB_BASE_DIR)/pvmi/pvmf/include \
-			-I $(VOB_BASE_DIR)/baselibs/pv_mime_utils/src
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-# compose final src list for actual build
-SRCS =	pvmf_recognizer_registry.cpp \
-	pvmf_recognizer_registry_impl.cpp
-
-HDRS =  pvmf_recognizer_registry.h \
-	pvmf_recognizer_types.h \
-    pvmf_recognizer_plugin.h
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
-
-
diff --git a/pvmi/recognizer/include/pvmf_recognizer_plugin.h b/pvmi/recognizer/include/pvmf_recognizer_plugin.h
index 479fb3e..b7ceee0 100644
--- a/pvmi/recognizer/include/pvmf_recognizer_plugin.h
+++ b/pvmi/recognizer/include/pvmf_recognizer_plugin.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/include/pvmf_recognizer_registry.h b/pvmi/recognizer/include/pvmf_recognizer_registry.h
index 3caaf70..64ffefb 100644
--- a/pvmi/recognizer/include/pvmf_recognizer_registry.h
+++ b/pvmi/recognizer/include/pvmf_recognizer_registry.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/include/pvmf_recognizer_types.h b/pvmi/recognizer/include/pvmf_recognizer_types.h
index b270fe6..1721a92 100644
--- a/pvmi/recognizer/include/pvmf_recognizer_types.h
+++ b/pvmi/recognizer/include/pvmf_recognizer_types.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvaacffrecognizer/Android.mk b/pvmi/recognizer/plugins/pvaacffrecognizer/Android.mk
new file mode 100644
index 0000000..82fd39f
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvaacffrecognizer/Android.mk
@@ -0,0 +1,29 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+	src/pvaacffrec_factory.cpp \
+ 	src/pvaacffrec_plugin.cpp
+
+
+LOCAL_MODULE := libpvaacffrecognizer
+
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
+
+
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
+LOCAL_C_INCLUDES := \
+	$(PV_TOP)/pvmi/recognizer/plugins/pvaacffrecognizer/src \
+ 	$(PV_TOP)/pvmi/recognizer/plugins/pvaacffrecognizer/include \
+ 	$(PV_INCLUDES)
+
+LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
+LOCAL_COPY_HEADERS := \
+ 	include/pvaacffrec_factory.h
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/pvmi/recognizer/plugins/pvaacffrecognizer/build/make/local.mk b/pvmi/recognizer/plugins/pvaacffrecognizer/build/make/local.mk
new file mode 100644
index 0000000..9574463
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvaacffrecognizer/build/make/local.mk
@@ -0,0 +1,19 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvaacffrecognizer
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvaacffrec_factory.cpp \
+        pvaacffrec_plugin.cpp
+
+HDRS := pvaacffrec_factory.h
+
+include $(MK)/library.mk
diff --git a/pvmi/recognizer/plugins/pvaacffrecognizer/include/pvaacffrec_factory.h b/pvmi/recognizer/plugins/pvaacffrecognizer/include/pvaacffrec_factory.h
new file mode 100644
index 0000000..b08fd13
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvaacffrecognizer/include/pvaacffrec_factory.h
@@ -0,0 +1,42 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVAACFFREC_FACTORY_H_INCLUDED
+#define PVAACFFREC_FACTORY_H_INCLUDED
+
+#ifndef PVMF_RECOGNIZER_PLUGIN_H_INCLUDED
+#include "pvmf_recognizer_plugin.h"
+#endif
+
+class PVAACFFRecognizerFactory : public PVMFRecognizerPluginFactory
+{
+    public:
+        PVAACFFRecognizerFactory()
+        {
+        };
+
+        ~PVAACFFRecognizerFactory()
+        {
+        };
+
+        OSCL_IMPORT_REF PVMFRecognizerPluginInterface* CreateRecognizerPlugin();
+        OSCL_IMPORT_REF void DestroyRecognizerPlugin(PVMFRecognizerPluginInterface* aPlugIn);
+};
+
+#endif // PVAACFFREC_FACTORY_H_INCLUDED
+
+
diff --git a/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_factory.cpp b/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_factory.cpp
new file mode 100644
index 0000000..6a02d1b
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_factory.cpp
@@ -0,0 +1,49 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvaacffrec_plugin.h"
+#include "pvaacffrec_factory.h"
+
+#include "oscl_error_codes.h"
+#include "oscl_exception.h"
+
+// Use default DLL entry point for Symbian
+#include "oscl_dll.h"
+OSCL_DLL_ENTRY_POINT_DEFAULT()
+
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF PVMFRecognizerPluginInterface* PVAACFFRecognizerFactory::CreateRecognizerPlugin()
+{
+    PVMFRecognizerPluginInterface* plugin = NULL;
+    plugin = OSCL_STATIC_CAST(PVMFRecognizerPluginInterface*, OSCL_NEW(PVAACFFRecognizerPlugin, ()));
+    if (plugin == NULL)
+    {
+        OSCL_LEAVE(OsclErrNoMemory);
+    }
+    return plugin;
+}
+
+////////////////////////////////////////////////////////////////////////////
+OSCL_EXPORT_REF void PVAACFFRecognizerFactory::DestroyRecognizerPlugin(PVMFRecognizerPluginInterface* aPlugin)
+{
+    if (aPlugin)
+    {
+        OSCL_DELETE(((PVAACFFRecognizerPlugin*)aPlugin));
+    }
+}
+
diff --git a/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_plugin.cpp b/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_plugin.cpp
new file mode 100644
index 0000000..904bd8a
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_plugin.cpp
@@ -0,0 +1,83 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#include "pvaacffrec_plugin.h"
+#include "aacfileparser.h"
+#include "oscl_file_io.h"
+
+#define PVMF_AAC_REC_PLUGIN_MIN_SIZE_FOR_RECOGNITION 512
+
+PVMFStatus PVAACFFRecognizerPlugin::SupportedFormats(PVMFRecognizerMIMEStringList& aSupportedFormatsList)
+{
+    // Return AAC as supported type
+    OSCL_HeapString<OsclMemAllocator> supportedformat = PVMF_MIME_AACFF;
+    aSupportedFormatsList.push_back(supportedformat);
+    return PVMFSuccess;
+}
+
+
+PVMFStatus
+PVAACFFRecognizerPlugin::Recognize(PVMFDataStreamFactory& aSourceDataStreamFactory,
+                                   PVMFRecognizerMIMEStringList* aFormatHint,
+                                   Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>& aRecognizerResult)
+{
+    OSCL_UNUSED_ARG(aFormatHint);
+    OSCL_wStackString<1> tmpfilename;
+    int32 leavecode = 0;
+    CAACFileParser* aacfile = NULL;
+    OSCL_TRY(leavecode, aacfile = OSCL_NEW(CAACFileParser, ()));
+    if (leavecode || aacfile == NULL)
+    {
+        return PVMFErrNoMemory;
+    }
+
+    ParserErrorCode retVal = aacfile->IsAACFile(tmpfilename, NULL, &aSourceDataStreamFactory);
+
+    OSCL_DELETE(aacfile);
+    aacfile = NULL;
+
+    if (OK == retVal)
+    {
+        // It is an aac file so add positive result
+        PVMFRecognizerResult result;
+        result.iRecognizedFormat = PVMF_MIME_AACFF;
+        result.iRecognitionConfidence = PVMFRecognizerConfidenceCertain;
+        aRecognizerResult.push_back(result);
+    }
+    else if (INSUFFICIENT_DATA == retVal)
+    {
+        // It may be an aac file, but there is not enough data to make the determination
+        PVMFRecognizerResult result;
+        result.iRecognizedFormat = PVMF_MIME_AACFF;
+        result.iRecognitionConfidence = PVMFRecognizerConfidencePossible;
+        aRecognizerResult.push_back(result);
+    }
+
+    return PVMFSuccess;
+}
+
+PVMFStatus PVAACFFRecognizerPlugin::GetRequiredMinBytesForRecognition(uint32& aBytes)
+{
+    aBytes = PVMF_AAC_REC_PLUGIN_MIN_SIZE_FOR_RECOGNITION;
+    return PVMFSuccess;
+}
+
+
+
+
+
+
diff --git a/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_plugin.h b/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_plugin.h
new file mode 100644
index 0000000..38a2e22
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvaacffrecognizer/src/pvaacffrec_plugin.h
@@ -0,0 +1,45 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+#ifndef PVAACFFREC_PLUGIN_H_INCLUDED
+#define PVAACFFREC_PLUGIN_H_INCLUDED
+
+#ifndef PVMF_RECOGNIZER_PLUGIN_H_INCLUDED
+#include "pvmf_recognizer_plugin.h"
+#endif
+
+class PVAACFFRecognizerPlugin : public PVMFRecognizerPluginInterface
+{
+    public:
+        PVAACFFRecognizerPlugin()
+        {
+        };
+
+        ~PVAACFFRecognizerPlugin()
+        {
+        };
+
+        PVMFStatus SupportedFormats(PVMFRecognizerMIMEStringList& aSupportedFormatsList);
+
+        PVMFStatus Recognize(PVMFDataStreamFactory& aSourceDataStreamFactory, PVMFRecognizerMIMEStringList* aFormatHint,
+                             Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>& aRecognizerResult);
+
+        PVMFStatus GetRequiredMinBytesForRecognition(uint32& aBytes);
+};
+
+#endif // PVAACFFREC_PLUGIN_H_INCLUDED
+
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk b/pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk
index 873f6c7..60df640 100644
--- a/pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk
+++ b/pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk
@@ -3,25 +3,28 @@
 
 LOCAL_SRC_FILES := \
 	src/pvamrffrec_factory.cpp \
-	src/pvamrffrec_plugin.cpp
-
+ 	src/pvamrffrec_plugin.cpp
 
 
 LOCAL_MODULE := libpvamrffrecognizer
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvamrffrecognizer/include \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvamrffrecognizer/src \
-	$(PV_TOP)/pvmi/recognizer/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/recognizer/plugins/pvamrffrecognizer/src \
+ 	$(PV_TOP)/pvmi/recognizer/plugins/pvamrffrecognizer/include \
+ 	/pvmi/recognizer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvamrffrec_factory.h
+ 	include/pvamrffrec_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/build/make/local.mk b/pvmi/recognizer/plugins/pvamrffrecognizer/build/make/local.mk
new file mode 100644
index 0000000..f11a2b7
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvamrffrecognizer/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvamrffrecognizer
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+XINCDIRS =  $(VOB_BASE_DIR)/pvmi/recognizer/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvamrffrec_factory.cpp \
+       pvamrffrec_plugin.cpp
+
+HDRS := pvamrffrec_factory.h
+	
+
+
+
+include $(MK)/library.mk
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/build/make/makefile b/pvmi/recognizer/plugins/pvamrffrecognizer/build/make/makefile
deleted file mode 100644
index 418793d..0000000
--- a/pvmi/recognizer/plugins/pvamrffrecognizer/build/make/makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvamrffrecognizer
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-XINCDIRS = -I $(VOB_BASE_DIR)/pvmi/recognizer/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = pvamrffrec_factory.cpp \
-       pvamrffrec_plugin.cpp
-
-HDRS = pvamrffrec_factory.h
-	
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/include/pvamrffrec_factory.h b/pvmi/recognizer/plugins/pvamrffrecognizer/include/pvamrffrec_factory.h
index 4a02612..a995c9c 100644
--- a/pvmi/recognizer/plugins/pvamrffrecognizer/include/pvamrffrec_factory.h
+++ b/pvmi/recognizer/plugins/pvamrffrecognizer/include/pvamrffrec_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_factory.cpp b/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_factory.cpp
index 99419bd..9b38838 100644
--- a/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_factory.cpp
+++ b/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.cpp b/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.cpp
index 63fc4d5..6fffc16 100644
--- a/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.cpp
+++ b/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.h b/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.h
index dcf1acc..3798bfb 100644
--- a/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.h
+++ b/pvmi/recognizer/plugins/pvamrffrecognizer/src/pvamrffrec_plugin.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk b/pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk
index e5e7289..238f4f5 100644
--- a/pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk
+++ b/pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk
@@ -3,26 +3,29 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmp3ffrec_factory.cpp \
-	src/pvmp3ffrec_plugin.cpp
-
+ 	src/pvmp3ffrec_plugin.cpp
 
 
 LOCAL_MODULE := libpvmp3ffrecognizer
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvmp3ffrecognizer/include \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvmp3ffrecognizer/src \
-	$(PV_TOP)/fileformats/mp3/parser/include \
-	$(PV_TOP)/pvmi/recognizer/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/recognizer/plugins/pvmp3ffrecognizer/src \
+ 	$(PV_TOP)/pvmi/recognizer/plugins/pvmp3ffrecognizer/include \
+ 	/fileformats/mp3/parser/include \
+ 	/pvmi/recognizer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvmp3ffrec_factory.h
+ 	include/pvmp3ffrec_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make/local.mk b/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make/local.mk
new file mode 100644
index 0000000..12a6113
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp3ffrecognizer
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+XINCDIRS =  $(VOB_BASE_DIR)/fileformats/mp3/parser/include  $(VOB_BASE_DIR)/pvmi/recognizer/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmp3ffrec_factory.cpp \
+       pvmp3ffrec_plugin.cpp
+
+HDRS := pvmp3ffrec_factory.h
+	
+
+
+
+include $(MK)/library.mk
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make/makefile b/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make/makefile
deleted file mode 100644
index 6dc3e10..0000000
--- a/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make/makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp3ffrecognizer
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-XINCDIRS = -I $(VOB_BASE_DIR)/fileformats/mp3/parser/include -I $(VOB_BASE_DIR)/pvmi/recognizer/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = pvmp3ffrec_factory.cpp \
-       pvmp3ffrec_plugin.cpp
-
-HDRS = pvmp3ffrec_factory.h
-	
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/include/pvmp3ffrec_factory.h b/pvmi/recognizer/plugins/pvmp3ffrecognizer/include/pvmp3ffrec_factory.h
index 113254f..ce2c7a3 100644
--- a/pvmi/recognizer/plugins/pvmp3ffrecognizer/include/pvmp3ffrec_factory.h
+++ b/pvmi/recognizer/plugins/pvmp3ffrecognizer/include/pvmp3ffrec_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_factory.cpp b/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_factory.cpp
index fd48a72..4133c0f 100644
--- a/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_factory.cpp
+++ b/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.cpp b/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.cpp
index ebe77dc..3dbe609 100644
--- a/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.cpp
+++ b/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.h b/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.h
index 83afd95..4cf3b2b 100644
--- a/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.h
+++ b/pvmi/recognizer/plugins/pvmp3ffrecognizer/src/pvmp3ffrec_plugin.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk b/pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk
index 9b345f6..4e756c5 100644
--- a/pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk
+++ b/pvmi/recognizer/plugins/pvmp4ffrecognizer/Android.mk
@@ -3,27 +3,27 @@
 
 LOCAL_SRC_FILES := \
 	src/pvmp4ffrec_factory.cpp \
-	src/pvmp4ffrec_plugin.cpp
-
+ 	src/pvmp4ffrec_plugin.cpp
 
 
 LOCAL_MODULE := libpvmp4ffrecognizer
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvmp4ffrecognizer/include \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvmp4ffrecognizer/src \
-	$(PV_TOP)/fileformats/mp4/parser/config/opencore \
-	$(PV_TOP)/fileformats/mp4/parser/include \
-	$(PV_TOP)/pvmi/recognizer/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/recognizer/plugins/pvmp4ffrecognizer/src \
+ 	$(PV_TOP)/pvmi/recognizer/plugins/pvmp4ffrecognizer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvmp4ffrec_factory.h
+ 	include/pvmp4ffrec_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make/local.mk b/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make/local.mk
new file mode 100644
index 0000000..8c7fd4b
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make/local.mk
@@ -0,0 +1,28 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvmp4ffrecognizer
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvmp4ffrec_factory.cpp \
+       pvmp4ffrec_plugin.cpp
+
+HDRS := pvmp4ffrec_factory.h
+    
+
+
+
+include $(MK)/library.mk
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make/makefile b/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make/makefile
deleted file mode 100644
index d92219c..0000000
--- a/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make/makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4ffrecognizer
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-XINCDIRS = -I $(VOB_BASE_DIR)/fileformats/mp4/parser/config/opencore -I $(VOB_BASE_DIR)/fileformats/mp4/parser/include -I $(VOB_BASE_DIR)/pvmi/recognizer/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = pvmp4ffrec_factory.cpp \
-       pvmp4ffrec_plugin.cpp
-
-HDRS = pvmp4ffrec_factory.h
-	
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/include/pvmp4ffrec_factory.h b/pvmi/recognizer/plugins/pvmp4ffrecognizer/include/pvmp4ffrec_factory.h
index b94a612..42fe653 100644
--- a/pvmi/recognizer/plugins/pvmp4ffrecognizer/include/pvmp4ffrec_factory.h
+++ b/pvmi/recognizer/plugins/pvmp4ffrecognizer/include/pvmp4ffrec_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_factory.cpp b/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_factory.cpp
index 7d984ad..5c1b44b 100644
--- a/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_factory.cpp
+++ b/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.cpp b/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.cpp
index b41eb73..6a99c75 100644
--- a/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.cpp
+++ b/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
  * -------------------------------------------------------------------
  */
 #include "pvmp4ffrec_plugin.h"
-#include "impeg4file.h"
+#include "pvmp4ffrec.h"
 #include "oscl_file_io.h"
 
 
@@ -38,7 +38,7 @@
     bool ismp4file = false;
     OSCL_wHeapString<OsclMemAllocator> tmpfilename;
     int32 leavecode = 0;
-    OSCL_TRY(leavecode, ismp4file = IMpeg4File::IsMP4File(&aSourceDataStreamFactory));
+    OSCL_TRY(leavecode, ismp4file = MP4FileRecognizer::IsMP4File(&aSourceDataStreamFactory));
     OSCL_FIRST_CATCH_ANY(leavecode,
                          return PVMFErrNoMemory;
                         );
diff --git a/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.h b/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.h
index b2396dd..5c03e22 100644
--- a/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.h
+++ b/pvmi/recognizer/plugins/pvmp4ffrecognizer/src/pvmp4ffrec_plugin.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk b/pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk
index baed702..9941648 100644
--- a/pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk
+++ b/pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk
@@ -3,25 +3,28 @@
 
 LOCAL_SRC_FILES := \
 	src/pvwavffrec_factory.cpp \
-	src/pvwavffrec_plugin.cpp
-
+ 	src/pvwavffrec_plugin.cpp
 
 
 LOCAL_MODULE := libpvwavffrecognizer
 
-LOCAL_CFLAGS :=   $(PV_CFLAGS)
+LOCAL_CFLAGS :=  $(PV_CFLAGS)
 
 
+
+LOCAL_STATIC_LIBRARIES := 
+
+LOCAL_SHARED_LIBRARIES := 
+
 LOCAL_C_INCLUDES := \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvwavffrecognizer/include \
-	$(PV_TOP)//pvmi/recognizer/plugins/pvwavffrecognizer/src \
-	$(PV_TOP)/pvmi/recognizer/include \
-	$(PV_INCLUDES) 
-
+	$(PV_TOP)/pvmi/recognizer/plugins/pvwavffrecognizer/src \
+ 	$(PV_TOP)/pvmi/recognizer/plugins/pvwavffrecognizer/include \
+ 	/pvmi/recognizer/include \
+ 	$(PV_INCLUDES)
 
 LOCAL_COPY_HEADERS_TO := $(PV_COPY_HEADERS_TO)
+
 LOCAL_COPY_HEADERS := \
-	include/pvwavffrec_factory.h
+ 	include/pvwavffrec_factory.h
 
 include $(BUILD_STATIC_LIBRARY)
-
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/build/make/local.mk b/pvmi/recognizer/plugins/pvwavffrecognizer/build/make/local.mk
new file mode 100644
index 0000000..3d78084
--- /dev/null
+++ b/pvmi/recognizer/plugins/pvwavffrecognizer/build/make/local.mk
@@ -0,0 +1,30 @@
+# Get the current local path as the first operation
+LOCAL_PATH := $(call get_makefile_dir)
+
+# Clear out the variables used in the local makefiles
+include $(MK)/clear.mk
+
+TARGET := pvwavffrecognizer
+
+
+XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
+
+
+
+XINCDIRS =  $(VOB_BASE_DIR)/pvmi/recognizer/include
+
+
+
+
+SRCDIR := ../../src
+INCSRCDIR := ../../include
+
+SRCS := pvwavffrec_factory.cpp \
+       pvwavffrec_plugin.cpp
+
+HDRS := pvwavffrec_factory.h
+	
+
+
+
+include $(MK)/library.mk
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/build/make/makefile b/pvmi/recognizer/plugins/pvwavffrecognizer/build/make/makefile
deleted file mode 100644
index fdbdee8..0000000
--- a/pvmi/recognizer/plugins/pvwavffrecognizer/build/make/makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvwavffrecognizer
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-# XCXXFLAGS += 
-XCXXFLAGS += $(FLAG_COMPILE_WARNINGS_AS_ERRORS)
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-# XCPPFLAGS +=  
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-
-XINCDIRS = -I $(VOB_BASE_DIR)/pvmi/recognizer/include
-
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = ../../src
-INCSRCDIR = ../../include
-
-SRCS = pvwavffrec_factory.cpp \
-       pvwavffrec_plugin.cpp
-
-HDRS = pvwavffrec_factory.h
-	
-
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-
-include $(MK)/gnumake.template
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/include/pvwavffrec_factory.h b/pvmi/recognizer/plugins/pvwavffrecognizer/include/pvwavffrec_factory.h
index 71eff5c..d18c4fc 100644
--- a/pvmi/recognizer/plugins/pvwavffrecognizer/include/pvwavffrec_factory.h
+++ b/pvmi/recognizer/plugins/pvwavffrecognizer/include/pvwavffrec_factory.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_factory.cpp b/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_factory.cpp
index 0218d1d..9f03f72 100644
--- a/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_factory.cpp
+++ b/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_factory.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.cpp b/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.cpp
index ab2e657..6051773 100644
--- a/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.cpp
+++ b/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.h b/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.h
index 130ef3a..e0bd4c8 100644
--- a/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.h
+++ b/pvmi/recognizer/plugins/pvwavffrecognizer/src/pvwavffrec_plugin.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/src/pvmf_recognizer_registry.cpp b/pvmi/recognizer/src/pvmf_recognizer_registry.cpp
index 0810306..4c518c8 100644
--- a/pvmi/recognizer/src/pvmf_recognizer_registry.cpp
+++ b/pvmi/recognizer/src/pvmf_recognizer_registry.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/src/pvmf_recognizer_registry_impl.cpp b/pvmi/recognizer/src/pvmf_recognizer_registry_impl.cpp
index e3e9ac2..7a76829 100644
--- a/pvmi/recognizer/src/pvmf_recognizer_registry_impl.cpp
+++ b/pvmi/recognizer/src/pvmf_recognizer_registry_impl.cpp
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvmi/recognizer/src/pvmf_recognizer_registry_impl.h b/pvmi/recognizer/src/pvmf_recognizer_registry_impl.h
index b40f7c9..8dfbb91 100644
--- a/pvmi/recognizer/src/pvmf_recognizer_registry_impl.h
+++ b/pvmi/recognizer/src/pvmf_recognizer_registry_impl.h
@@ -1,5 +1,5 @@
 /* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
+ * Copyright (C) 1998-2009 PacketVideo
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/pvplayer.cfg b/pvplayer.cfg
new file mode 100755
index 0000000..757c3c1
--- /dev/null
+++ b/pvplayer.cfg
@@ -0,0 +1,5 @@
+(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_rtspreg.so"
+(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_downloadreg.so"
+(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_mp4localreg.so"
+(0x6d3413a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_mp4localreg.so"
+(0xa054369c,0x22c5,0x412e,0x19,0x17,0x87,0x4c,0x1a,0x19,0xd4,0x5f),"libomx_sharedlibrary.so"
diff --git a/pvplayer.conf b/pvplayer.conf
deleted file mode 100644
index 16e206a..0000000
--- a/pvplayer.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencorertspreg.so"
-(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencoredownloadreg.so"
-(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencoremp4reg.so"
-(0x6d3413a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencoremp4reg.so"
diff --git a/pvplayer/Android.mk b/pvplayer/Android.mk
deleted file mode 100644
index acc6778..0000000
--- a/pvplayer/Android.mk
+++ /dev/null
@@ -1,124 +0,0 @@
-ifneq ($(BUILD_WITHOUT_PV),true)
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-        libpvplayer_engine \
-        libgetactualaacconfig \
-        libpvavcdecoder \
-        libpv_aac_dec \
-        libpvdecoder_gsmamr \
-        libpvamrwbdecoder \
-        libpvmp3 \
-        libm4v_config \
-        libpv_video_config_parser \
-        libomx_common_lib \
-        libomx_queue_lib \
-        libomx_avc_component_lib \
-        libomx_aac_component_lib \
-        libomx_amr_component_lib \
-        libomx_mp3_component_lib \
-        libomx_m4v_component_interface \
-        libpvomx_proxy_lib \
-        libcpm \
-        libpassthru_oma1 \
-        libfile_mediaio \
-        libpvfileparserutils \
-        libpvid3parcom \
-        libpvgsmamrparser \
-        libpvmp3ff \
-        libpvmp4ff \
-        libpvaacparser \
-        libpvwav \
-        libpvaacffparsernode \
-        libpvmp3ffparsernode \
-        libpvamrffparsernode \
-        libpvmediaoutputnode \
-        libpvomxvideodecnode \
-        libpvomxaudiodecnode \
-        libpvwavffparsernode \
-        libpvmfrecognizer \
-        libpvamrffrecognizer \
-        libpvmp3ffrecognizer \
-        libpvwavffrecognizer \
-        libpvframemetadatautility \
-        libpvlatmpayloadparser \
-        libandroidpv \
-        libkmj_oma1
-
-LOCAL_LDLIBS := -lpthread
-
-ifeq ($(VALUE_ADD),1)
-LOCAL_WHOLE_STATIC_LIBRARIES += libomx_wmv_component_interface
-endif
-
-LOCAL_SHARED_LIBRARIES := libutils libcutils libui libhardware libandroid_runtime libdrm1 libmedia libsgl libvorbisidec libsonivox libopencorecommon libicuuc
-ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
-LOCAL_LDLIBS += -ldl
-endif
-ifneq ($(TARGET_SIMULATOR),true)
-LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-# Include board-specific extensions
-LOCAL_SHARED_LIBRARIES += $(BOARD_OPENCORE_LIBRARIES)
-
-
-LOCAL_MODULE := libopencoreplayer
-
-include $(BUILD_SHARED_LIBRARY)
-include $(PV_TOP)//engines/player/Android.mk
-include $(PV_TOP)//codecs_v2/audio/aac/dec/util/getactualaacconfig/Android.mk
-include $(PV_TOP)//codecs_v2/video/avc_h264/dec/Android.mk
-include $(PV_TOP)//codecs_v2/audio/aac/dec/Android.mk
-include $(PV_TOP)//codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
-include $(PV_TOP)//codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
-include $(PV_TOP)//codecs_v2/audio/gsm_amr/common/dec/Android.mk
-include $(PV_TOP)//codecs_v2/audio/mp3/dec/Android.mk
-include $(PV_TOP)//codecs_v2/utilities/m4v_config_parser/Android.mk
-include $(PV_TOP)//codecs_v2/utilities/pv_video_config_parser/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_common/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_queue/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_h264/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_aac/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_amr/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_mp3/Android.mk
-include $(PV_TOP)//codecs_v2/omx/factories/omx_m4v_factory/Android.mk
-include $(PV_TOP)//codecs_v2/omx/omx_proxy/Android.mk
-include $(PV_TOP)//nodes/common/Android.mk
-include $(PV_TOP)//pvmi/content_policy_manager/Android.mk
-include $(PV_TOP)//pvmi/content_policy_manager/plugins/oma1/passthru/Android.mk
-include $(PV_TOP)//pvmi/content_policy_manager/plugins/common/Android.mk
-include $(PV_TOP)//pvmi/media_io/pvmiofileoutput/Android.mk
-include $(PV_TOP)//fileformats/common/parser/Android.mk
-include $(PV_TOP)//fileformats/id3parcom/Android.mk
-include $(PV_TOP)//fileformats/rawgsmamr/parser/Android.mk
-include $(PV_TOP)//fileformats/mp3/parser/Android.mk
-include $(PV_TOP)//fileformats/mp4/parser/Android.mk
-include $(PV_TOP)//fileformats/rawaac/parser/Android.mk
-include $(PV_TOP)//fileformats/wav/parser/Android.mk
-include $(PV_TOP)//nodes/pvaacffparsernode/Android.mk
-include $(PV_TOP)//nodes/pvmp3ffparsernode/Android.mk
-include $(PV_TOP)//nodes/pvamrffparsernode/Android.mk
-include $(PV_TOP)//nodes/pvmediaoutputnode/Android.mk
-include $(PV_TOP)//nodes/pvomxvideodecnode/Android.mk
-include $(PV_TOP)//nodes/pvomxaudiodecnode/Android.mk
-include $(PV_TOP)//nodes/pvwavffparsernode/Android.mk
-include $(PV_TOP)//pvmi/recognizer/Android.mk
-include $(PV_TOP)//pvmi/recognizer/plugins/pvamrffrecognizer/Android.mk
-include $(PV_TOP)//pvmi/recognizer/plugins/pvmp3ffrecognizer/Android.mk
-include $(PV_TOP)//pvmi/recognizer/plugins/pvwavffrecognizer/Android.mk
-include $(PV_TOP)//engines/common/Android.mk
-include $(PV_TOP)//engines/adapters/player/framemetadatautility/Android.mk
-include $(PV_TOP)//protocols/rtp_payload_parser/util/Android.mk
-include $(PV_TOP)//android/Android.mk
-include $(PV_TOP)//android/drm/oma1/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_rtsp/core/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_rtsp/node_registry/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_net_support/core/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_download/core/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_download/node_registry/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_mp4/core/Android.mk
-include $(PV_TOP)//tools_v2/build/modules/linux_mp4/node_registry/Android.mk
-endif
diff --git a/pvplayer/NOTICE b/pvplayer/NOTICE
deleted file mode 100644
index 4421325..0000000
--- a/pvplayer/NOTICE
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ------------------------------------------------------------------

- * Copyright (C) 2008 PacketVideo

- *

- * Licensed under the Apache License, Version 2.0 (the "License");

- * you may not use this file except in compliance with the License.

- * You may obtain a copy of the License at

- *

- *      http://www.apache.org/licenses/LICENSE-2.0

- *

- * Unless required by applicable law or agreed to in writing, software

- * distributed under the License is distributed on an "AS IS" BASIS,

- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either

- * express or implied.

- * See the License for the specific language governing permissions

- * and limitations under the License.

- * -------------------------------------------------------------------

- */

-

-Portions of the PacketVideo supplied code contain contributions which may be covered by the following copyright statements:

-

-

-/*     -------------------------------------------------------------------       *

- *                    MPEG-4 Simple Profile Video Decoder           *

- *     -------------------------------------------------------------------       *

- *

- * This software module was originally developed and/or edited by

- *

- *   Paulo Nunes (IST / ACTS-MoMuSyS)

- *   Robert Danielsen (Telenor / ACTS-MoMuSyS)

- *   Luis Ducla-Soares (IST / ACTS-MoMuSys).     	           	   	

- *   Cor Quist (KPN / ACTS-MoMuSys).     			              	

- *  Minhua Zhou (HHI / ACTS-MoMuSys).   	  	 	              	

- *

- * in the course of development of the MPEG-4 Video (ISO/IEC 14496-2) standard.

- * This software module is an implementation of a part of one or more MPEG-4

- * Video (ISO/IEC 14496-2) tools as specified by the MPEG-4 Video (ISO/IEC

- * 14496-2) standard.

- *

- * ISO/IEC gives users of the MPEG-4 Video (ISO/IEC 14496-2) standard free

- * license to this software module or modifications thereof for use in hardware

- * or software products claiming conformance to the MPEG-4 Video (ISO/IEC

- * 14496-2) standard.

- *

- * Those intending to use this software module in hardware or software products

- * are advised that its use may infringe existing patents. The original

- * developer of this software module and his/her company, the subsequent

- * editors and their companies, and ISO/IEC have no liability for use of this

- * software module or modifications thereof in an implementation. Copyright is

- * not released for non MPEG-4 Video (ISO/IEC 14496-2) Standard conforming

- * products.

- *

- * ACTS-MoMuSys partners retain full right to use the code for his/her own

- * purpose, assign or donate the code to a third party and to inhibit third

- * parties from using the code for non MPEG-4 Video (ISO/IEC 14496-2) Standard

- * conforming products. This copyright notice must be included in all copies or

- * derivative works.

- *

- * Copyright (c) 1996, 1997

- *

- *****************************************************************************/

-

-

-

-/****************************************************************************

-

-SC 29 Software Copyright Licencing Disclaimer:

-

-This software module was originally developed by

-  Coding Technologies

-

-and edited by

-  -

-

-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3 

-standards for reference purposes and its performance may not have been 

-optimized. This software module is an implementation of one or more tools as 

-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.

-ISO/IEC gives users free license to this software module or modifications 

-thereof for use in products claiming conformance to audiovisual and 

-image-coding related ITU Recommendations and/or ISO/IEC International 

-Standards. ISO/IEC gives users the same free license to this software module or 

-modifications thereof for research purposes and further ISO/IEC standardisation.

-Those intending to use this software module in products are advised that its 

-use may infringe existing patents. ISO/IEC have no liability for use of this 

-software module or modifications thereof. Copyright is not released for 

-products that do not conform to audiovisual and image-coding related ITU 

-Recommendations and/or ISO/IEC International Standards.

-The original developer retains full right to modify and use the code for its 

-own purpose, assign or donate the code to a third party and to inhibit third 

-parties from using the code for products that do not conform to audiovisual and 

-image-coding related ITU Recommendations and/or ISO/IEC International Standards.

-This copyright notice must be included in all copies or derivative works.

-Copyright (c) ISO/IEC 2003.

-

-*******************************************************************************/

-

-

-/**************************************************************************

-

-This software module was originally developed by

-

-Mikko Suonio (Nokia)

-

-in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard

-ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an

-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools

-as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives

-users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this

-software module or modifications thereof for use in hardware or

-software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio

-standards. Those intending to use this software module in hardware or

-software products are advised that this use may infringe existing

-patents. The original developer of this software module and his/her

-company, the subsequent editors and their companies, and ISO/IEC have

-no liability for use of this software module or modifications thereof

-in an implementation. Copyright is not released for non MPEG-2

-NBC/MPEG-4 Audio conforming products. The original developer retains

-full right to use the code for his/her own purpose, assign or donate

-the code to a third party and to inhibit third party from using the

-code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This

-copyright notice must be included in all copies or derivative works.

-

-Copyright (c) 1997.

-

-***************************************************************************/

-

-

-/**************************************************************************

-

-This software module was originally developed by

-Nokia in the course of development of the MPEG-2 AAC/MPEG-4 

-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.

-This software module is an implementation of a part

-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the

-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the

-MPEG-2aac/MPEG-4 Audio standards free license to this software module

-or modifications thereof for use in hardware or software products

-claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those

-intending to use this software module in hardware or software products

-are advised that this use may infringe existing patents. The original

-developer of this software module, the subsequent

-editors and their companies, and ISO/IEC have no liability for use of

-this software module or modifications thereof in an

-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4

-Audio conforming products. The original developer retains full right to

-use the code for the developer's own purpose, assign or donate the code to a

-third party and to inhibit third party from using the code for non

-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice

-must be included in all copies or derivative works.

-Copyright (c)1997.  

-

-***************************************************************************/

-

-

-------------------------------------------------------------------------------

-

-MPEG-2 NBC Audio Decoder

-   "This software module was originally developed by AT&T, Dolby

-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development

-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and

-   3. This software module is an implementation of a part of one or more

-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4

-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio

-   standards free license to this software module or modifications thereof

-   for use in hardware or software products claiming conformance to the

-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software

-   module in hardware or software products are advised that this use may

-   infringe existing patents. The original developer of this software

-   module and his/her company, the subsequent editors and their companies,

-   and ISO/IEC have no liability for use of this software module or

-   modifications thereof in an implementation. Copyright is not released

-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original

-   developer retains full right to use the code for his/her own purpose,

-   assign or donate the code to a third party and to inhibit third party

-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.

-   This copyright notice must be included in all copies or derivative

-   works." 

-   Copyright(c)1996.

-

-------------------------------------------------------------------------------

-

-

-/*

- * snprintf.c - a portable implementation of snprintf

- *

- * AUTHOR

- *   Mark Martinec <mark.martinec@ijs.si>, April 1999.

- *

- *   Copyright 1999, Mark Martinec. All rights reserved.

- *

- * TERMS AND CONDITIONS

- *   This program is free software; you can redistribute it and/or modify

- *   it under the terms of the "Frontier Artistic License" which comes

- *   with this Kit.

- *

- *   This program is distributed in the hope that it will be useful,

- *   but WITHOUT ANY WARRANTY; without even the implied warranty

- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

- *   See the Frontier Artistic License for more details.

- *

- *

- */

-

-The "Frontier Artistic License" may be found at

- http://www.spinwardstars.com/frontier/fal.html

-

-

-

-

-

-

-

-/*---------------------------------------------------------------------------*/

-

-/*

- * Copyright (c) 2005 The Khronos Group Inc.

- *

- * Permission is hereby granted, free of charge, to any person obtaining

- * a copy of this software and associated documentation files (the

- * "Software"), to deal in the Software without restriction, including

- * without limitation the rights to use, copy, modify, merge, publish,

- * distribute, sublicense, and/or sell copies of the Software, and to

- * permit persons to whom the Software is furnished to do so, subject

- * to the following conditions:

- * The above copyright notice and this permission notice shall be included

- * in all copies or substantial portions of the Software.

- *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS

- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF

- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY

- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,

- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE

- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

- *

- */

-

-/*---------------------------------------------------------------------------*/

-

-/**@@@+++@@@@****************************************************************** 

-** 

-** Microsoft Windows Media 

-** Copyright (C) Microsoft Corporation. All rights reserved. 

-** 

-***@@@---@@@@****************************************************************** 

-*/ 

-

-

-

-----------------------------------------------------------------------------------------

-Portions of this file are derived from the following 3GPP standard:

- 

-    3GPP TS 26.073

-    ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec

-    Available from http://www.3gpp.org

- 

-(C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

-Permission to distribute, modify and use this file under the standard license

-terms listed above has been obtained from the copyright holder.

------------------------------------------------------------------------------------------

-

-

-----------------------------------------------------------------------------------------

-Portions of this file are derived from the following 3GPP standard:

- 

-    3GPP TS 26.173

-    ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec

-    Available from http://www.3gpp.org

- 

-(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)

-Permission to distribute, modify and use this file under the standard license

-terms listed above has been obtained from the copyright holder.

------------------------------------------------------------------------------------------

-

diff --git a/quick_start.txt b/quick_start.txt
new file mode 100644
index 0000000..362974c
--- /dev/null
+++ b/quick_start.txt
@@ -0,0 +1,164 @@
+Q. How to build OpenCORE outside of Android?
+A. As part of the OpenCORE release, PacketVideo also provides it's internal build system 
+that can be used to build the OpenCORE outside of Android with the native linux toolchain. 
+
+The following are the steps involved:
+  NOTE 1: Assume <opencore> is the folder where you have downloaded the OpenCORE codebase.
+  NOTE 2: The setup scripts are meant to be used in bash.
+    cd <opencore>/build_config/opencore_dynamic
+    source setup_nr.sh <opencore>
+    make -j -f makefile_nr
+
+This will export all the required libraries to <opencore>/build_config/opencore_dynamic/build/installed_lib/linux and the executables to
+<opencore>/build_config/opencore_dynamic/build/bin/linux.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Q. How to run the pvplayer engine unit tests?
+A.
+On Android emulator/device:
+    adb push <opencore>/engines/player/test/data/ /sdcard
+    adb shell "cd /sdcard; pvplayer_engine_test <test_args> <source_args>"
+
+On host PC:
+    cd <opencore>/build_config/opencore_dynamic
+    make -f makefile_nr run_pe_test TEST_ARGS="<test_args>"
+
+<test_args> can be any of the following:
+Test cases to run option. Default is ALL:
+  -test x y
+   Specify a range of test cases to run. To run one test case, use the
+   same index for x and y.
+  -test L
+   Run local playback test cases only.
+  -test D
+   Run download playback test cases only.
+  -test S
+   Run streaming playback test cases only.
+
+Compressed video and audio output option. Default is OFF for both:
+  -compV AND/OR -compA
+   For test cases and sinks that support compressed media output (media
+   I/O node test cases), the output data files would have compressed
+   bitstreams. This also means the player engine would not use a decoder
+   node to decode the bitstream from the source node.
+
+Log level options. Default is debug level:
+  -logerr
+   Log at error level
+  -logwarn
+   Log at warning level
+
+Log node options. Default is player engine only:
+  -logall
+   Log everything (log appender at root node)
+  -logoscl
+   Log OSCL only
+  -logperf
+   Log scheduler performance
+  -logperfmin
+   Log scheduler performance (minimal)
+  -logdatapathsrc
+   Log source node datapath only
+  -logdatapathdec
+   Log decoder node datapath only
+
+Proxy enabled ON or OFF, default is OFF
+  -proxy
+
+Source specification option. 
+  -source sourcename
+   Specify the source filename or URL to use for test cases which
+   allow user-specified source name. The unit test determines the
+   source format type using extension or URL header.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Q. How to run the pv2way engine unit tests?
+A.
+On Android emulator/device:
+    adb push <opencore>/extlibs/opencore/engines/2way/test/test_data/ /sdcard
+    adb shell "cd /sdcard; pv2way_omx_engine_test <test_args>"
+
+On host PC:
+    cd <opencore>/build_config/opencore_dynamic
+    make -f makefile_nr run_2way_test TEST_ARGS="<test_args>"
+
+<test_args> can be any of the following:
+Test cases to run option. Default is ALL:
+  -test x y
+   Specify a range of test cases to run. To run one test case, use the
+   same index for x and y.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Q. How to run the pvauthor engine unit tests?
+A.
+On Android emulator/device:
+    adb push <opencore>/engines/author/test/test_input/ /sdcard
+    adb shell "cd /sdcard;test_pvauthorengine <test_args>"
+
+On host PC:
+    cd <opencore>/build_config/opencore_dynamic
+    make -f makefile_nr run_ae_test TEST_ARGS="<test_args>"
+
+<test_args> can be any of the following:
+Test cases to run option. Default is ALL:
+  -test x x
+   Specify a range of test cases to run. To run one test case, use the
+   same index for x and y.
+
+[test range from: 1001 to: 999]
+
+CMD LINE ARGS FOR COMPRESSED TESTS [test range from: 0 to: 105]
+
+Source specification option for audio.:
+  -audio sourcename
+   Specify the source filename or URL to use for test cases which
+   allow user-specified source name. The unit test determines the
+   source format type using extension or URL header.
+
+Source specification option for video.:
+  -video sourcename
+   Specify the source filename or URL to use for test cases which
+   allow user-specified source name. The unit test determines the
+   source format type using extension or URL header.
+
+Output specification option.
+  -output outputname
+   Specify the output filename to use for test cases which
+   allow user-specified source name.
+
+Authoring Time specification option for Author.:
+  -duration time_in_seconds
+   Specify the time argument to use for test cases which
+   allow user-specified source name.
+
+CMD LINE ARGS FOR UNCOMPRESSED TESTS(with AVI/WAV inputs)[test range from 200 to 306]
+
+Source specification option.:
+  -source sourcename
+   Specify the source filename or URL to use for test cases which
+   allow user-specified source name. The unit test determines the
+   source format type using extension or URL header.
+
+Output specification option.
+  -output outputname
+   Specify the output filename to use for test cases which
+   allow user-specified source name.
+
+Video Encoder Type option. Default is M4V:
+  -encV encodertype
+  specifies the encoder to be used for authoring
+  0:M4V
+  1:H263
+  2:H264
+  e.g -encV 0
+
+Authoring Time specification option for Author.:
+  -duration time_in_seconds
+   Specify the time argument to use for test cases which
+   allow user-specified source name.
+
+NO CMD LINE ARGS ARE REQUIRED TO RUN COMPRESSED ERROR HANDLING TESTS [test range from:400 to 403]
+
+NO CMD LINE ARGS ARE REQUIRED TO RUN UNCOMPRESSED ERROR HANDLING TESTS [test range from:500 to 570]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/tools_v2/build/MAKEFILE_TEMPLATES_USERS_GUIDE b/tools_v2/build/MAKEFILE_TEMPLATES_USERS_GUIDE
deleted file mode 100644
index 783459a..0000000
--- a/tools_v2/build/MAKEFILE_TEMPLATES_USERS_GUIDE
+++ /dev/null
@@ -1,230 +0,0 @@
-/*! \page makefile_overview Makefile Templates Guide
-
-
-This is a description of the makefile templates used by 
-certain platforms for the build system. It assumes the 
-platform has support for GNU make or some other make system that is 
-compatible, such as clearmake (part of Clearcase) operating in 
-GNU compatibility mode.
-
-This Makefile system incorporates several features:
-
-<ul>
-<li> Easy to tailor template files for different projects.</li>
-<li> Easy to create and maintain individual GNUMakefiles </li>
-<li> System-wide compilation parameters encapsulated in common
-  files</li>
-<li> Separate working and installed copies of targets</li>
-<li> Automatic dependencies</li>
-<li> Use of GNU make, an implementation of make with considerably
-  more functionality than most vendors' default make programs.</li>
-</ul>
-
-
-       <center>ASSUMPTIONS ABOUT BASELINE CONFIGURATION</center>
-
-This make system imposes a few restrictions on the layout of the
-source code baseline.  Specifically, there must be a single top-level
-baseline directory. One reason for the restrictions is to allow 
-include directories and library directories to be automatically 
-discovered by the makefile system.  The makefile system will find 
-all directories named "include" and "installed_include" from the 
-current directory up to the specified root of the code base. Similarly, 
-directories named "lib" and "installed_lib" are automatically included 
-in the library search paths. The automatic discovery of include and library
-paths simplifies the creation and maintenance of local makefiles.
-
-Underneath the top-level baseline directory (i.e., baseline root)
-is an arbitrary collection of component directories, which can be 
-arbitrarily deep.  Each component
-is responsible for producing and installing its output (e.g., program or 
-library) to an appropriate level in the directory tree.  By convention 
-other components will only use header files or libraries that are found 
-along the path from the component's directory back to the root directory.
-
-All libraries, and binaries must be installed.  Public header files
-associated with binaries can be optionally installed along with the
-library.  Directly under each project level, there are src, bin, lib,
-and include subdirectories.  Units within the project and units within
-other projects that depend upon this one get their libraries and
-possibly include files from this installed area.
-
-
-	     <center>REQUIREMENTS FOR USE</center>
-
-These GNUMakefiles include other GNUMakefiles from a specific
-directory and invoke scripts from another directory.  The make files
-require the directory containing the GNUMakefile templates to be
-stored in the environment variable $MK and the location of the
-asscoiated scripts to be set up in the local.mk template.  The
-GNUMakefiles in this system use features specific to GNU make, so GNU
-make must be available.  Although this document assumes that GNU make
-is installed as "gmake", it does not need to be.  The GNUMakefile
-system will work fine with it called by another name.
-
-
-<ul>
-  <li>	There is no "gen_make" or "imake" stage to compile
-	the template into a working Makefile.  Instead
-	the user creates a local GNUMakefile which includes
-	the necessary template files when GNU-make is run.
-	Therefore changes to GNUMakefile templates in the 
-	$(MK) directory take effect immediately and 
-	globally so there is little chance of having out
-	of date local GNUMakefiles as with Imake.
-</li>
-
-  <li>	Dependency info for source files (i.e. *.h files) is
-	no longer stored directly in the Makefile.  Instead
-	each source file has a corresponding *.d file which 
-	contains the dependency information for that file.
-	The GNUMakefile then includes these dependency files 
-	when GNU-make is run.  NOTE that it is no longer
-	necessary to run make depend to update a file's 
-	dependency info.  The *.d files will be kept up to
-	date as part of the GNUMakefile rules.
-</li>
-
-  <li>	It is no longer necessary to keep both object files
-	and the corresponding library archive for certain platforms.
-	GNU-make can examine a library archive and determine the
-	dates of the member object files.  Then it can 
-	update the archive directly for those object files that
-	need to be rebuilt.
-</li>
-</ul>
-
-
-        <center>BUILDING YOUR TARGETS</center>
-
-Generating a GNUmakefile to build your target is a relatively simple
-affair, consisting of the declaration of a few macros and then
-including $(MK)/gnumake.template.
-
-Three macros are used to determine which template files are used from within 
-the $(MK) directory. It will load the template file 
-$(ARCHITECTURE)_$(TOOLSET)_$WHAT).mak:
-
-ARCHITECTURE	The name of the architecture for which the target should
-		be built (i.e., sun4).  However, it is best *NOT* to put 
-                this macro in the local makefiles since it would require
-                multiple makefiles to build for different platforms.  Instead
-                it is better to either specify this as part of the build 
-                command or with an environment variable. The build host type
-                will be automatically determined and the host architecture 
-                will be used as the build architecture if ARCHITECTURE is not
-                set.
-
-TOOLSET		The name of the toolset to use in building the target
-		(i.e., gcc or D4314A)
-
-WHAT		What you're building.  This is usually "prog" or "library",
-		but certain targets have other facilities available.
-
-
-For example, to build the "Hello World" program on a Sun using gcc,
-you would build this short GNUmakefile:
-
-<pre>
-	TOOLSET=gcc
-	WHAT=prog
-
-	TARGET=hello
-	SRCS=hello.c
-	include $(MK)/gnumake.template
-</pre>
-
-With ARCHITECTURE=sun
-
-Below is a list of some of the more commonly-used macros for building
-programs and libraries.
-
-IMPORTANT: Before building your own GNUmakefile, read the
-documentation for the configuration you intend to use.  Build a
-GNUmakefile with the ARCHITECTURE, TOOLSET and WHAT macros set
-appropriately and type "gmake show-doc."
-
-the top of the .mak file you plan to use (see below for a list of
-available templates) for supported macros and special caveats.
-
-
-DESTDIR		The directory where the target should be installed when a
-		"gmake install" is executed.  Note that this should be
-		relative to the current directory (i.e., ../../bin/sun4).
-
-DFLAGS		Debugging or other flags for the compiler which are used
-		during compiling and linking but not during dependency
-		generation.
-
-HDRS		Specifies a list of header files to install when building a
-		library  This is optional.
-
-INCDESTDIR	An optional macro for library targets that indicate where the
-		files specified in HDRS should be installed.
-
-INCSRCDIR       The INCSRCDIR macro is similar to the SRCDIR macro, but it 
-                specifically relates to the files specified in the HDRS 
-                macro.
-
-LIBS		A list of libraries for linking.  This should be suitable for
-		whatever mechanism the development tools use to find libraries.
-		(i.e., "m" specifies /lib/libm.a in most Unix variants.)
-
-SRCDIR          The SRCDIR macro is used to indicate the location of the
-                source files (i.e., the files specified in the SRCS and 
-                HDRS macros).  If this macro is not set, the current directory
-                (i.e., where the makefile is located) will be used.
-
-SRCS		A list of the source files to be used in building the target.
-
-SYSLIBS         This is a macro which is similar to the LIBS directive, but it 
-                is used specifically for system libraries which may only be 
-                available as shared libraries.  The SYSLIBS dependency handling
-                is different than LIBS to deal with limitations of tools like
-                clearmake.  SYSLIBS should only be used for system libraries 
-                in special cases and not as the norm.
-
-TARGET		The name of the finished target that will be built during
-		the make.  This is without any extensions, etc.  If this
-		macro is not defined, the name of the current directory
-		will be used instead.
-
-XCFLAGS		Extra compiler flags that are not for debugging or the
-		preprocessor.  Generally these are compiler-specific flags.
-
-XCLEAN		Extra files that should be deleted whenever the "clean"
-		target is built.
-
-XCPPFLAGS	Extra C preprocessor flags for things like -DDEBUG.
-
-XINCDIRS	Extra include directories (beyond the defaults) which should
-		be searched when looking for #include files.
-
-XLDFLAGS	Extra linker flags.
-
-XLIBDIRS	A list of extra directories (beyond the defaults) which
-		should be searched when looking for libraries during linking.
-
-
-
-
-                <center>NOTEWORTHY INFORMATION</center>
-
-If you're building a library which has include files that will be
-exported to the public, those include files either must reside in 
-the current directory or in the directory specified by the INCSRCDIR 
-macro.  (Use HDRS to specify what headers are to be installed and 
-INCDESTDIR to specify where they should go.)
-
-
-        <center>ADDING SUPPORT FOR NEW PLATFORMS</center>
-
-
-Adding support for a new platform is usually best accomplished by starting
-from the templates files of an existing supported platform.  The generic 
-build rules from the general templates files (e.g., prog.mk, library.mk,
-etc) should be reused for most cases.  That means that supporting a new 
-platform is primarily a matter of providing the appropriate macro definitions
-for the the general build rules.  
-
-*/
diff --git a/tools_v2/build/bin/archtype b/tools_v2/build/bin/archtype
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/archtype
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/archtype.bat b/tools_v2/build/bin/archtype.bat
deleted file mode 100755
index 249d338..0000000
--- a/tools_v2/build/bin/archtype.bat
+++ /dev/null
@@ -1,51 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-my $mach = 'unknown';
-
-if ($ENV{'OS'} =~ m/Windows/) {
-   printf("win32\n");
-   exit(0);
-}
-
-if ( -x '/bin/mach' ) {
-   $mach = `/bin/mach`;
-} elsif ( -x '/usr/ucb/mach' ) {
-   $mach = `/usr/ucb/mach`;
-} elsif ( -x '/bin/uname' ) {
-   $mach = `/bin/uname -s`;
-} 
-chomp $mach;
-
-#print "mach = $mach\n";
-
-my $archtype=$mach;
-if ($mach eq 'sparc') {
-  $archtype = 'sun';
-}
-elsif ( $mach eq 'HP-UX' ) {
-  $archtype='hpux';
-}
-elsif ( $mach eq 'Linux' ) {
-  my $status = `/sbin/ldconfig -p | /bin/grep -q libc.so.6`;
-  if (! $?) {
-    $archtype='linux';
-  }
-  else {
-    $archtype='linux5';
-  }
-}
-
-print "$archtype\n";
-
-exit(0);
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools_v2/build/bin/cc_install b/tools_v2/build/bin/cc_install
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/cc_install
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/cc_install.bat b/tools_v2/build/bin/cc_install.bat
deleted file mode 100755
index cad497d..0000000
--- a/tools_v2/build/bin/cc_install.bat
+++ /dev/null
@@ -1,75 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-use Getopt::Long;
-
-# This is meant to be a win32 replacement for the Unix install utility
-
-# The options -c and -m will be accepted for compatibility, but ignored
-
-GetOptions('c' => \$overwrite, 'm=i' => \$mode);
-
-sub Copy {
-  my ($from, $to) = @_;
-
-  if ( ! open(FROM, "$from") ) {
-    return 0;
-  }       
-
-  if ( -d $to ) {
-    if ( ! open(TO, ">$to/$from")) {
-      close FROM;
-      return 0;
-    }
-  }
-  else {
-    if ( ! open(TO, ">$to")) {
-      close FROM;
-      return 0;
-    }
-  }
-
-  while (<FROM>) {
-    print TO "$_";
-  }
-
-  close TO;
-  close FROM;
-  return 1;
-}
-
-if ( ! defined $ARGV[0] ) {
-  print STDERR "cc_install: must specify source\n";
-  exit (1);
-}
-if ( ! defined $ARGV[1] ) {
-  print STDERR "cc_install: must specify destination\n";
-  exit (1);
-}
-
-my $source=$ARGV[0];
-my $destination=$ARGV[1];
-
-#Copy ($source, $destination);
-
-# Convert to DOS path delimeters
-$source =~ s/\//\\/g;
-$destination =~ s/\//\\/g;
-
-$ret=system("COPY /Y $source $destination");
-if ($?) {
-  print STDERR "Can not copy $source to $destination: $!\n";
-  exit (1);
-}
-
-exit(0);
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools_v2/build/bin/cc_mkdir b/tools_v2/build/bin/cc_mkdir
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/cc_mkdir
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/cc_mkdir.bat b/tools_v2/build/bin/cc_mkdir.bat
deleted file mode 100755
index e26e02a..0000000
--- a/tools_v2/build/bin/cc_mkdir.bat
+++ /dev/null
@@ -1,47 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-my $path = $ARGV[0];
-
-if ($path eq "") {
-	print STDERR "Must specify directory/path to create\n";
-	exit (-1);
-}
-
-if ($ENV{'OS'} =~ m/Windows/) {
-	# Convert any DOS backslashes to Unix forward slashes
-	$path =~ s/\//\\/g;
-	if ( ! -d $path ) {
-		$ret = `MKDIR $path`;
-        	if ($?) {
-               		print STDERR "$0: Error creating directory $path:\n $!\n";
-                	exit (-1);
-		}
-        }
-}
-else {
-	if ( ! -d $path ) {
-		$ret = `mkdir -p $path`;
-        	if ($?) {
-               		print STDERR "$0: Error creating directory $path:\n $!\n";
-                	exit (-1);
-		}
-		$ret = `chmod g+s $path`;
-        	if ($?) {
-               		print STDERR "$0 Error setting permissions for $path:\n $!\n";
-                	exit (-1);
-		}
-        }
-}
-
-exit(0);
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools_v2/build/bin/cc_pwd b/tools_v2/build/bin/cc_pwd
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/cc_pwd
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/cc_pwd.bat b/tools_v2/build/bin/cc_pwd.bat
deleted file mode 100755
index 82f704a..0000000
--- a/tools_v2/build/bin/cc_pwd.bat
+++ /dev/null
@@ -1,25 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-# Instead of 'cleartool pwd' we could also use the Perl module Cwd to
-# maintain portability
-use Cwd;
-
-$dir = cwd();
-
-# Convert any DOS backslashes to Unix forward slashes
-$dir =~ s/\\/\//g;
-print "$dir\n";
-
-exit (0)
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
-
diff --git a/tools_v2/build/bin/cc_rm b/tools_v2/build/bin/cc_rm
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/cc_rm
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/cc_rm.bat b/tools_v2/build/bin/cc_rm.bat
deleted file mode 100755
index 96e278f..0000000
--- a/tools_v2/build/bin/cc_rm.bat
+++ /dev/null
@@ -1,25 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-# Note that unlink will not remove directories
-
-@cannot = grep {not unlink} @ARGV;
-
-# Make this like Unix rm -f and don't print an error or return a non-zero 
-# code if the file doesn't exist
-#
-# die "$0: Could not remove @cannot\n" if @cannot;
-
-exit (0) if @cannot;
-
-exit(0);
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools_v2/build/bin/ccase_view_type b/tools_v2/build/bin/ccase_view_type
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/ccase_view_type
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/ccase_view_type.bat b/tools_v2/build/bin/ccase_view_type.bat
deleted file mode 100755
index b692bba..0000000
--- a/tools_v2/build/bin/ccase_view_type.bat
+++ /dev/null
@@ -1,23 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-my $val = `cleartool lsview -cview -prop -full 2>&1`;
-
-if ($val =~ m/Properties:(.*)\s+dynamic\s(.*)/) {
-    print "dynamic\n";
-    exit(0);
-} else {
-    print "Unknown\n";
-    exit(-1);
-}
-exit(0);
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools_v2/build/bin/check_manifest.pl b/tools_v2/build/bin/check_manifest.pl
deleted file mode 100755
index 064c894..0000000
--- a/tools_v2/build/bin/check_manifest.pl
+++ /dev/null
@@ -1,81 +0,0 @@
- : # Use perl
-   eval 'exec perl -S $0 "$@"'
-   if 0;
-
-####################################################
-#
-# This script uses some additional Perl packages that
-# are not normally distributed with clearcase perl (called ccperl
-# on windows).  The possibilities for handling this are using
-# ActiveState's distribution of Perl called ActivePerl or possibly
-# checking in the missing Perl packages to clearcase for use with ccperl.
-# 
-####################################################
-
- use File::Basename;
- use Getopt::Long;
- use Digest::MD5;
-
- my $test = 0;
- my $manifest_name;
-
- if ($#ARGV < 0) {
-   print "Must specify the name of the manifest file\n";
-   exit(-1);
- }
-
- $manifest_name = $ARGV[0];
-
- if (!open(MANIFEST, "$manifest_name")) {
-   print "Can't open the file $manifest_name\n";
-   exit(-2);
- }
-
- my $errors = 0;
-
- while (<MANIFEST>) {
-   chomp;
-
-   s/#.*//;
-   next if m/^\s*$/;
-
-   my ($fname, $digest) = split '\t';
-
-   #print "filename = $fname, digest = $digest\n";
-
-   my ($status, $computed_digest) = compute_digest($fname);
-
-   if (!$status) {
-     print "Error opening file $fname\n";
-     ++$errors;
-   }
-
-   if ($digest ne $computed_digest) {
-     print "Checksum mismatch for file $fname\n";
-     ++$errors;
-   }
-
- }
-
- close MANIFEST;
- exit($errors != 0);
-   
- sub compute_digest {
-   my $file = shift;
-
-   if (!open(FIN, "$file")) {
-     print "Error opening $file\n";
-     return (0, undef);
-   }
-   binmode(FIN);
-   
-   my $digest = Digest::MD5->new->addfile(*FIN)->hexdigest;
-
-   close FIN;   
-   return (1, $digest);
-
-
- }
-
-
-
diff --git a/tools_v2/build/bin/chkcpu.exe b/tools_v2/build/bin/chkcpu.exe
deleted file mode 100755
index 4345e5f..0000000
--- a/tools_v2/build/bin/chkcpu.exe
+++ /dev/null
Binary files differ
diff --git a/tools_v2/build/bin/cleanup b/tools_v2/build/bin/cleanup
deleted file mode 100755
index 062d346..0000000
--- a/tools_v2/build/bin/cleanup
+++ /dev/null
@@ -1,29 +0,0 @@
-# makefiles, etc.
-
-echo Cleaning up build environment ...
-
-unsetenv CCASE_MAKE_COMPAT
-unsetenv PROJECT
-unsetenv SDK_LOCAL
-unsetenv VOB_BASE_DIR
-unsetenv PV_TOP
-
-set arch_bin_path = `$MK/../bin/archtype`
-if ( -x /icl-tools/bin/$arch_bin_path/utok ) then 
-   set path = (`/icl-tools/bin/$arch_bin_path/utok -s \  -d ./$arch_bin_path  $path`)
-endif
-unset arch_bin_path
-
-if ( -f ./cleanup.extras ) then
-  echo File cleanup.extras found, sourcing ...
-  source ./cleanup.extras 
-else
-  echo File cleanup.extras not found, skipping
-endif
-
-unsetenv MK
-
-# Rehash
-#
-rehash
-rehash
diff --git a/tools_v2/build/bin/cleanup.ksh b/tools_v2/build/bin/cleanup.ksh
deleted file mode 100755
index 63396f9..0000000
--- a/tools_v2/build/bin/cleanup.ksh
+++ /dev/null
@@ -1,25 +0,0 @@
-# makefiles, etc.
-
-echo Cleaning up build environment ...
-
-unset CCASE_MAKE_COMPAT
-unset PROJECT
-unset SDK_LOCAL
-unset VOB_BASE_DIR
-unset PV_TOP
-
-if [[ "${MK}" != "" ]]; then
-	typeset arch_bin_path=`$MK/../bin/archtype`
-	if [ -x /icl-tools/bin/$arch_bin_path/utok ]; then 
-   	export PATH=`/icl-tools/bin/$arch_bin_path/utok -s \  -d ./$arch_bin_path  $PATH`
-	fi
-fi
-
-if [ -f ./cleanup.extras.ksh ]; then
-  echo File cleanup.extras.ksh found, sourcing ...
-  . ./cleanup.extras.ksh 
-else
-  echo File cleanup.extras.ksh not found, skipping
-fi
-
-unset MK
diff --git a/tools_v2/build/bin/filter_remote b/tools_v2/build/bin/filter_remote
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/filter_remote
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/filter_remote.bat b/tools_v2/build/bin/filter_remote.bat
deleted file mode 100755
index cd70bea..0000000
--- a/tools_v2/build/bin/filter_remote.bat
+++ /dev/null
@@ -1,57 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-use File::Basename;
-my $out="";
-
-if ($#ARGV >= 0) {
-    if (!open(FOUT, ">remote.mk")) {
-        die "Error opening remote.mk\n";
-    }
-
-    while ($_ = shift @ARGV) {
-        if (m|/|) {
-            $out .= $_ . " ";
-            # print "out = $out\n";
-            my ($fname, $dirname, $suffix) = fileparse($_, qr/\.[^.]*/);
-            my $compiler = "\$(CXX)";
-            if ($suffix eq ".c") {
-                $compiler = "\$(CC)";
-            }
-            print FOUT "\$(OBJPAT) : \$(SRCDIR)/$dirname\%$suffix\n";
-            print FOUT <<END_OBJRULE;
-	\$(create_objdir)
-	\$(stage_objdir)
-	-\$(RM) \$\@
-	$compiler \$(CPPFLAGS) \$(CFLAGS) \$(CO)\$@ \$<
-	\$(group_writable)
-
-END_OBJRULE
-           print FOUT "\$(DEPPAT) : \$(SRCDIR)/$dirname\%$suffix\n";
-           print FOUT <<END_DEPRULE;
-	\$(create_objdir)
-	\$(stage_objdir)
-	\$(GEN_DEPS) \"\$(DEPS_ARG)\" \$(filter \$(\@D)/\%, \$(COMPILED_TARGETS)) \$< \$(\@D) \$(KEEP_OBJ)
-	\$(_process_dot_d_)
-	\$(_custom_process_dot_d_)
-
-END_DEPRULE
-        }
-    }
-    close(FOUT);
-
-    if (!length($out)) {
-        unlink("remote.mk");
-    }
-    print "$out";
-}
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
\ No newline at end of file
diff --git a/tools_v2/build/bin/find_dir b/tools_v2/build/bin/find_dir
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/find_dir
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/find_dir.bat b/tools_v2/build/bin/find_dir.bat
deleted file mode 100755
index 8b5b922..0000000
--- a/tools_v2/build/bin/find_dir.bat
+++ /dev/null
@@ -1,81 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-{
-    local(@whoami) = split('/', $0);
-    $whoami = pop(@whoami);
-};
-
-if (scalar(@ARGV) != 3)
-{
-    print STDERR "ARGV = @ARGV scalar = " . scalar(@ARGV) . "\n";
-    print STDERR "Usage: $whoami flag dir SRC_TOP\n";
-    print STDERR "  Examples: $whoami -I include \${STAGING}\n";
-    print STDERR "            $whoami -L libsun \${STAGING}\n";
-    exit 1;
-}
-
-($flag, $dir, $osrc_top) = @ARGV;
-
-$VOB_BASE_DIR = "$ENV{'VOB_BASE_DIR'}";
-
-chop($pwd = `$VOB_BASE_DIR/tools_v2/build/bin/cc_pwd`);
-chdir($osrc_top) or die "Can not change directory to $osrc_top: $!\n";
-chop($src_top = `$VOB_BASE_DIR/tools_v2/build/bin/cc_pwd`);
-
-#print "pwd = $pwd\n";
-
-@pwd = split('/', $pwd);
-$prefix = "";
-@incdirs = ();
-
-#print "pwd array = @pwd\n";
-
-while (@pwd)
-{
-#	print join('/', @pwd) . "\n";
-    chdir(join('/', @pwd)) or die "Can not change directory $!\n";;
-    chop($pwd = `$VOB_BASE_DIR/tools_v2/build/bin/cc_pwd`);
-    $inc = $pwd;
-    $inc =~ s/$src_top/$osrc_top/;
-    $inc = "$inc/$dir";
-#	print "pwd = $pwd\n";
-    push (@incdirs, $inc) if (-d $dir);
-    last if ($pwd eq $src_top);
-    pop(@pwd);
-    $prefix = "../" . $prefix;
-
-}
-
-if (scalar(@pwd) == 0)
-{
-#    print STDERR "$whoami: Never found $osrc_top\n";
-    exit 1;
-}
-
-if ($flag ne "0")
-{
-  for (@incdirs)
-    {
-      print $flag, $_, " ";
-    }
-  print "\n";
-}
-else
-{
-  for (@incdirs)
-    {
-      print $_, " ";
-    }
-  print "\n";
-}
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
diff --git a/tools_v2/build/bin/find_file b/tools_v2/build/bin/find_file
deleted file mode 100755
index 2909662..0000000
--- a/tools_v2/build/bin/find_file
+++ /dev/null
@@ -1,63 +0,0 @@
- : # Use perl
-   eval 'exec perl -w -S $0 "$@"'
-   if 0;
-# -*- perl -*-
-
-{
-    local(@whoami) = split('/', $0);
-    $whoami = pop(@whoami);
-};
-
-if (scalar(@ARGV) != 3)
-{
-    print STDERR "Usage: $whoami flag dir SRC_TOP\n";
-    print STDERR "  Examples: $whoami -I include \${STAGING}\n";
-    print STDERR "            $whoami -L libsun \${STAGING}\n";
-    exit 1;
-}
-
-($flag, $dir, $osrc_top) = @ARGV;
-
-chop($pwd = `pwd`);
-chdir($osrc_top);
-chop($src_top = `pwd`);
-
-@pwd = split('/', $pwd);
-$prefix = "";
-@incdirs = ();
-
-while (@pwd)
-{
-    chdir(join('/', @pwd));
-    chop($pwd = `pwd`);
-    $inc = $pwd;
-    $inc =~ s/$src_top/$osrc_top/;
-    $inc = "$inc/$dir";
-    push (@incdirs, $inc) if (-r $dir);
-    last if ($pwd eq $src_top);
-    pop(@pwd);
-    $prefix = "../" . $prefix;
-}
-
-if (scalar(@pwd) == 0)
-{
-    print STDERR "$whoami: Never found $osrc_top\n";
-    exit 1;
-}
-
-if ($flag ne "0")
-{
-  for (@incdirs)
-    {
-      print $flag, $_, " ";
-    }
-  print "\n";
-}
-else
-{
-  for (@incdirs)
-    {
-      print $_, " ";
-    }
-  print "\n";
-}
diff --git a/tools_v2/build/bin/gen_deps b/tools_v2/build/bin/gen_deps
deleted file mode 100755
index d1cf107..0000000
--- a/tools_v2/build/bin/gen_deps
+++ /dev/null
@@ -1,85 +0,0 @@
- : # Use perl
-   eval 'exec perl -w -S $0 "$@"'
-   if 0;
-# -*- perl -*-
-
-use File::Basename;
-
-$debug=0;
-{
-    local(@whoami) = split('/', $0);
-    $whoami = pop(@whoami);
-};
-
-&usage if (scalar(@ARGV) < 3 || scalar(@ARGV) > 5);
-
-# defined($arch = $ENV{"ARCH"}) || die "\$ARCH must be defined.\n";
-
-($compiler, $target, $src) = (@ARGV);
-
-if (scalar(@ARGV) > 3)
-{
-    $depdir = "$ARGV[3]/";
-}
-else
-{
-    $depdir = '';
-}
-
-print STDERR "$0 (debug) : COMPILER : $compiler\n" if $debug;
-print  STDERR "$0 (debug) : TARGET   : $target\n" if $debug;
-print  STDERR "$0 (debug) : SOURCE   : $src\n" if $debug;
-
-if (scalar(@ARGV) > 4)
-{
-    $libflag = $ARGV[4];
-}
-else
-{
-    $libflag = 0;
-}
-
-$is_library = ($target =~ m/\.a$/);
-$srcbase = basename($src);
-$srcbase =~ s/\.[^\.]*$//;
-$dep = "$depdir$srcbase.d";
-
-$obj = ($is_library &&  (! $libflag) ) ? "$target($depdir$srcbase.o)" : "$depdir$srcbase.o";
-
-unlink($dep);
-
-open(COMPILE, "$compiler $src 2>$dep.tmp2 |") || die "Can't run $compiler\n";
-open(TMP1, ">$dep.tmp1") || die "Can't open $dep.tmp1\n";
-
-while (<COMPILE>)
-{
-    s/^$srcbase\.o/$obj $dep/g;
-    print TMP1;
-}
-      
-close(TMP1);
-close(COMPILE);
-$comp_failed = ($? != 0);
-print STDERR "Done running $compiler\n" if $debug;
-system("cat $dep.tmp2 1>&2") if (-s "$dep.tmp2");
-unlink("$dep.tmp2");
-
-print STDERR "unlinked $dep.tmp2\n" if $debug;
-if ($comp_failed)
-{
-    unlink("$dep.tmp1");
-}
-else
-{
-    rename("$dep.tmp1", $dep);
-    chmod(0664, $dep);
-}
-
-exit((-f $dep) ? 0 : 1);
-
-
-sub usage {
-    print STDERR "Usage: $whoami compile target src\n";
-    print STDERR "  Generate dependencies for src\n";
-    exit 1;
-}
diff --git a/tools_v2/build/bin/generate_version_file.pl b/tools_v2/build/bin/generate_version_file.pl
deleted file mode 100755
index 6df7b73..0000000
--- a/tools_v2/build/bin/generate_version_file.pl
+++ /dev/null
@@ -1,179 +0,0 @@
-Use perl
-  eval 'exec perl -S $0 "$@"'
-  if 0;
-
-use Getopt::Std;
-
-getopts('r');                   
-
-my $file = $ARGV[0];
-my $vlabel;
-
-sub check_ccspec {
-
-  if (! -f ".ccspec") {
-    return 1;
-  }
-
-  unlink(".ccspec.new");
-  system("cleartool catcs > .ccspec.new");
-
-  my $cmp = `/extern_tools/bin/win32/cmp .ccspec .ccspec.new`;  # dos: comp, unix: cmp
-  if ($cmp) {
-    unlink(".ccspec.new");
-    return 1;
-  }
-  unlink(".ccspec.new");
-  return 0;
-}
-
-
-sub compare_mtime {
-  my $file1 = shift @_;
-  my $file2 = shift @_;
-
- 
-  if (! -f $file1 && ! -f $file2) {
-    return 0;
-  }
-
-  if (! -f $file2) {
-    return 1;
-  }
-  
-  if (! -f $file1) {
-    return -1;
-  }
-
-  my @f1_stat = stat($file1);
-  my @f2_stat = stat($file2);
-
-  if ($f1_stat[9] < $f2_stat[9]) {
-    return -1;
-  }
-  elsif ($f1_stat[9] > $f2_stat[9]) {
-    return 1;
-  }
-  
-  return 0;
-}
-sub usage {
-  print "must provide <output_fname> [prod_id]\n";
-  print "default prod_id is PVSS\n";
-}
-
-
-if ($#ARGV < 1) {
-  usage();
-}
-my $status = check_ccspec();
-if (! -f $file) {
-   $status = 1;
-}
-if (!$status && -f "VERSION" && -f $file) {
-  if (compare_mtime($file, "VERSION") <= 0) {
-    # VERSION is newer
-    $status = 1;
-  }
-}
-
-if (! $status) {
-   exit(0);
-}
-
-# remove the output file first 
-unlink($file);
-
-if (-f "VERSION") {
-
-  # check if VERSION is newer than .ccspec
-  if (compare_mtime("VERSION", ".ccspec") <= 0) {
-    # config spec is newer
-
-    if (check_ccspec()) {
-      # see if config spec has changed
-      die "*** ERROR -- Config spec has changed -- must update VERSION file ***\n";
-    }
-  }
-  my $label;
-
-  open(VFILE, "VERSION") || die "*** ERROR -- Can't open file VERSION ***\n";
-  while (<VFILE>) {
-    chomp;
-    s/#.*//;	      # remove from comment marker to end-of-line.
-    next if ( /^\s*$/);   # skip blank lines
-
-    if (($label) = m/Version:\s*(.*)/i) {
-      last;
-    }
-  }
-
-  if ($label) {
-    $vlabel = $label;
-  }
-
-  close (VFILE);
-
-  if (!$vlabel) {
-    die "*** ERROR -- No valid label found in VERSION file ***\n";
-  }
-
-  # save .ccspec 
-  unlink(".ccspec");
-  system("cleartool catcs > .ccspec");
-
-} else {
-
-  print "No VERSION file, so check ccspec\n";
-  # save .ccspec 
-  unlink(".ccspec");
-  system("cleartool catcs > .ccspec");
-
-  my (@line, $tmp);
-  open(CCLABEL, "cleartool ls -d . |") || die "*** ERROR -- couldn't run cleartool ***\n";
-OUTER:  while (<CCLABEL>) {
-    chomp;
-    @line = split(' ', $_);
-    while ($tmp = shift(@line)) {
-      print "$tmp\n";
-      if ($tmp eq "Rule:") {
-        $vlabel = shift(@line);
-        last OUTER;
-      }
-    }
-  }
-
-  close(CCLABEL);
-
-  # split the path to get the last element
-  @line = split('/', $vlabel);
-  # print "line = @line\n";
-  $vlabel = $line[$#line];
-  
-  print "vlabel is $vlabel\n";
-
-  my $proc_vlabel;
-  if (($proc_vlabel) = ($vlabel =~ m/([0-9]+[.][0-9]+.*)/i)) {
-    # $proc_vlabel =~ s/_/./g;
-    $vlabel = $proc_vlabel;
-  }
-  elsif ($opt_r) {
-    die "*** ERROR -- No valid label found ***\n";
-  } else {
-    $vlabel = "3.1_default";
-  }
-
-}
-
-$prod_id = "PVSS"; 
-if  (defined($ARGV[1])) {
-  $prod_id =  $ARGV[1];
-  printf "argv1 is $ARGV[1], prod_id is $prod_id\n";
-}
-
-
-open(TFILE, "> $file");
-binmode(TFILE);
-print TFILE "char   Version[]      = \"$prod_id/$vlabel (\"__TIME__\" \"__DATE__\")\";\n";
-print TFILE "char   SM_UserAgent[] = \"PVServer-SM/$vlabel\";\n";
-close(TFILE);
diff --git a/tools_v2/build/bin/islink b/tools_v2/build/bin/islink
deleted file mode 100755
index bd80c33..0000000
--- a/tools_v2/build/bin/islink
+++ /dev/null
@@ -1,25 +0,0 @@
- : # Use perl
-   eval 'exec perl -w -S $0 "$@"'
-   if 0;
-# -*- perl -*-
-#
-# Test to see whether a file is a link.  Not all systems have
-# arguments to /bin/test that do this.  Also, some systems that
-# do have different flags from others that do.  (For example,
-# it's test -h in Solaris 1, test -l on SGI IRIX 4, and absent
-# on Ultrix 4.3.)
-#
-
-{
-    local(@whoami) = split('/', $0);
-    $whoami = pop(@whoami);
-};
-
-if (scalar(@ARGV) != 1)
-{
-    print STDERR "Usage: $whoami file\n";
-    exit 1;
-}	 
-
-$file = $ARGV[0];
-exit ((-l $file) ? 0 : 1);
diff --git a/tools_v2/build/bin/make_list b/tools_v2/build/bin/make_list
deleted file mode 100755
index f35ea39..0000000
--- a/tools_v2/build/bin/make_list
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-WHOAMI=`basename $0`
-
-usage() {
-cat <<EndofUsage
-Runs the make commands in a list of subdirectories.
-
-Usage: $WHOAMI <make command> <make target> <macro> <value 1> <value 2> ...
-
-EndofUsage
-exit 1
-}
-
-make_targets() {
-    for target in $target_list; do
-        $make_cmd "$macro=$target" $make_target
-#	$make_cmd -C $dir $make_target ;
-	exit_status=$?;
-	if [ $exit_status -ne 0 ]; then
-	    return $exit_status;
-	fi
-    done
-    return $exit_status
-}
-
-if [ $# -lt 4 ]; then
-    usage
-fi
-
-make_cmd=$1; shift;
-make_target=$1; shift;
-macro=$1; shift;
-target_list=$*;
-
-
-# IMPORTANT For the make to exit immediately upon
-#           encountering an error, this function
-#           should be called at the very end
-#           The exit status of this function then
-#           becomes the exit status of this shell
-#           script. This allows makefiles calling
-#           this script to exit upon finding a
-#           non-zero exit status.
-make_targets
-
diff --git a/tools_v2/build/bin/postbuild.pl b/tools_v2/build/bin/postbuild.pl
deleted file mode 100755
index afb53e5..0000000
--- a/tools_v2/build/bin/postbuild.pl
+++ /dev/null
@@ -1,47 +0,0 @@
-# This is a perl script to perform postbuild steps for this project.
-
-{
-   local(@whoami) = split('/', $0);
-   $whoami = pop(@whoami);
-}
-
-sub usage
-{
-   print "Usage: $whoami <path to lib file to copy> <path to installed_lib dir>\n";
-   exit(-1);
-}
-
-# ENTRY POINT
-$numRequiredArgs = 2;
-usage() if ($#ARGV+1 != $numRequiredArgs); # print usage info if number of args is anything other than $numRequiredArgs
-
-# Grab the arguments and store them in local variables
-$path_to_lib = $ARGV[0];
-if( defined($ENV{CORELIBS_SDK_LOCAL}) ) {
-	$path_to_installed_lib = $ENV{CORELIBS_SDK_LOCAL};
-}
-else {
-	$path_to_installed_lib = $ARGV[1];
-}
-
-# Create the intalled_lib directory if it does not exist already.
-if (! -d $path_to_installed_lib)
-{
-   print "Directory $path_to_installed_lib does not exist. Attempting to create it.\n";
-   if( system( "md $path_to_installed_lib" ) == 0 ) {
-	   print "Created directory $path_to_installed_lib\n";
-   }
-   else {
-	   die "Error - Creating directory $path_to_installed_lib Failed";
-   }
-}
-
-# Copy the lib file if it exists
-die "Error - the file does not exist: $path_to_lib." if (! -e $path_to_lib);
-if( system( "copy $path_to_lib $path_to_installed_lib" ) == 0 ) {
-	print "Copied file $path_to_lib to $path_to_installed_lib successfully.\n";
-} 
-else {
-	die "Error - copy $path_to_lib $path_to_installed_lib Failed";
-}
-
diff --git a/tools_v2/build/bin/pv_defines b/tools_v2/build/bin/pv_defines
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/pv_defines
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/pv_defines.bat b/tools_v2/build/bin/pv_defines.bat
deleted file mode 100755
index 3f306bf..0000000
--- a/tools_v2/build/bin/pv_defines.bat
+++ /dev/null
@@ -1,188 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-use Getopt::Long;
-
-
-{
-    local(@whoami) = split('/', $0);
-    $whoami = pop(@whoami);
-};
-
-sub determine_os {
-  my $os;
-  my $windows_os=`ver`;
-  my $define;
-
-  if ( -x "/bin/uname" ) {
-    $os = `/bin/uname -s`;
-  }
-  elsif ( -x "/bin/mach" ) {
-    $os=`/bin/mach`;
-  }
-  elsif ( -x "/usr/ucb/mach" ) {
-    $os=`/usr/ucb/mach`;
-  }
-  elsif ( $windows_os =~ m/Windows/ ) {
-    $os=$windows_os;
-  }
-  else {
-    $os="unknown";
-  }
-  
-  # map to correct define value
-  if ($os =~ m/Linux/ ) {
-    $define = "-DPV_OS_LINUX";
-  }
-  elsif ($os =~ m/SunOS/ ) {
-    $define = "-DPV_OS_SOLARIS";
-  }
-  elsif ($os =~ m/HP-UX/ ) {
-    $define = "-DPV_OS_HPUX";
-  }
-  elsif ($os =~ m/Microsoft Windows/ ) {
-    if ($build_arch =~ m/win32/ ) {
-      $define = "/D \"PV_OS_WINDOWS_NT\"";
-    }
-    elsif ($build_arch =~ m/wince/ ) {
-      $define = "";
-    }
-    else {
-      $define = "-DPV_OS_WINDOWS_NT";
-    } 
-  }
-  else {
-    $define = "-DPV_OS_UNKNOWN";
-  }
-  return $define;
-}
-
-sub determine_cpu {
-  my $model;
-  my $define;
-
-  # The backtick operator doesn't seem to work with
-  # this utility, so redirect the output to a temporary file
-  if ((defined ($tmp = $ENV{"TMP"})) && ($build_arch =~ m/win32/ )) {
-     # Usually this is only defined in the DOS shell
-     system("/tools/build/bin/chkcpu > $tmp/chkcpu");
-     open(CPUCHK, "$tmp/chkcpu");
-     while ($_ = <CPUCHK>) {
-        if (/CPU Vendor and Model/) {
-          $model = $_;
-        }
-     }
-     close CPUCHK;
-     unlink "$tmp/chkcpu";
-  }
-  elsif ( -f "/proc/cpuinfo" ) {
-    open(FH, "/proc/cpuinfo");
-    while ($_ = <FH>) {
-      if (/model name/) {
-        $model = $_;
-      }
-    }
-    close FH;
-  }
-  elsif ( -x "/bin/uname" ) {
-    $model = `/bin/uname -p`;
-  }
-  else {
-    $model ="unknown";
-  }
-
-  # map to correct define value
-  if ($model =~ m/Pentium III|PentiumIII|Celeron/ ) {
-    if ($build_arch =~ m/win32/ ) {
-      $define = "/D \"PV_PROCESSOR_PENTIUM_3\""
-    }
-    else {
-      $define = "-DPV_PROCESSOR_PENTIUM_3";
-    }
-  }
-  elsif($model =~ m/Pentium II|PentiumII/) {
-    if ($build_arch =~ m/win32/ ) {
-      $define = "/D \"PV_PROCESSOR_PENTIUM_2\""
-    }
-    else {
-      $define = "-DPV_PROCESSOR_PENTIUM_2";
-    }
-  }
-  elsif($model =~ m/sparc/) {
-    $define = "-DPV_PROCESSOR_SPARC";
-  }
-  else {
-    $define = "-DPV_PROCESSOR_UNKNOWN";
-  }
-  return $define;
-}
-
-
-my %cmdline_opts = ();
-my $all = 1;
-my $output_str;
-my $os_type;
-my $cpu_type;
-
-GetOptions(\%cmdline_opts, "os", "cpu");
-
-if (defined($cmdline_opts{os})) {
-  $all = 0;
-}
-
-if (defined($cmdline_opts{cpu})) {
-  $all = 0;
-}
-
-$build_arch = $ARGV[0];
-
-if ($all || defined($cmdline_opts{os})) {
-  # set the OS variable
-
-  if ($build_arch =~ m/mocha/i) {
-    $os_type = '-DPV_OS_MOCHA';    
-  }
-  else { 
-    # Assume OS for build target is same as current host
-    $os_type = determine_os();
-  }
-  $output_str .= $os_type . " ";
-}
-
-if ($all || defined($cmdline_opts{cpu})) {
-  # set the CPU variable
-
-  if ($os_type eq '-DPV_OS_HPUX') {
-    $cpu_type = '-DPV_PROCESSOR_HP_9000';
-  }
-  elsif ($build_arch =~ m/win32/i) {
-    if ($build_arch =~ m/_arm/i) {
-      $cpu_type = '-DPV_PROCESSOR_ARM';
-    }
-  }
-  elsif ($build_arch =~ m/wince/i) {
-    if ($build_arch =~ m/_arm/i) {
-      # Define PocketPC for MS Embedded SDK
-      $cpu_type = '/D "ARM" /D "_ARM_" /D "_MT" /D "WIN32_PLATFORM_PSPC"';
-    }
-  }
-  else {
-    # Assume processor for build target is same as current host
-    $cpu_type = determine_cpu();
-  }
-  $output_str .= $cpu_type . " ";
-}
-
-print "$output_str";
-
-exit(0);
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 % 6 %7 %8 %9
diff --git a/tools_v2/build/bin/recursive_make b/tools_v2/build/bin/recursive_make
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/recursive_make
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/recursive_make.bat b/tools_v2/build/bin/recursive_make.bat
deleted file mode 100755
index 45f20ed..0000000
--- a/tools_v2/build/bin/recursive_make.bat
+++ /dev/null
@@ -1,59 +0,0 @@
-@rem = 'Perl, ccperl read this as an array assignment & skip the goto
-@echo off
-goto endofperl
-@rem ';
-#!/usr/atria/bin/Perl
-
-######################################################################
-
-use Cwd;
-
-$usage  = "**** Usage: perl $0 <make command> <target> <directory 1> <directory 2> ...\n\n";
-$curdir = &Cwd::cwd();
-
-sub make_targets()
-{
-    foreach $dir (@target_list)
-    {
-        if (-f "$dir/makefile" || -f "$dir/Makefile")
-        {
-            if (chdir $dir)
-            {
-                system("$make_cmd $make_target");
-                $exit_status=$?;
-                if($exit_status != 0)
-                {
-                    return $exit_status;
-                }
-            }
-            else
-            {
-                return $?;
-            }
-            chdir $curdir;
-        }
-    }
-    return $exit_status;
-}
-
-if($#ARGV < 1)
-{
-    print $usage;
-}
-else
-{
-    $make_cmd    = $ARGV[0];
-    $make_target = $ARGV[1];
-    @target_list = @ARGV[2..$#ARGV];
-
-    # IMPORTANT For the make to exit immediately upon encountering an error, this function
-    # should be called at the very end. The exit status of this function then becomes the
-    # exit status of the script. This allows makefiles calling this script to exit upon
-    # finding a non-zero exit status.
-    make_targets();
-}
-
-__END__
-
-:endofperl
-ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' :' S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
\ No newline at end of file
diff --git a/tools_v2/build/bin/run_perl_batch.sh b/tools_v2/build/bin/run_perl_batch.sh
deleted file mode 100755
index 372e2bf..0000000
--- a/tools_v2/build/bin/run_perl_batch.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-# This file may be referenced by many different commands and allows for
-# Unix/Windows portability.  Please do not duplicate it, but use ClearCase
-# soft links to create new commands
-
-# PATH=/usr/atria/bin:${PATH}; export PATH
-# By default use the clearcase perl, but you can define PERL to another version of perl
-exec perl $0.bat "$@"
diff --git a/tools_v2/build/bin/setup b/tools_v2/build/bin/setup
deleted file mode 100755
index c4170f0..0000000
--- a/tools_v2/build/bin/setup
+++ /dev/null
@@ -1,76 +0,0 @@
-
-echo Setting up build environment with default configuration ...
-echo Using $PWD as top directory ...
-
-# Set the PV_TOP
-#
-setenv PV_TOP $PWD
-echo Set PV_TOP to $PV_TOP ...
-
-# Setup environment for necessary for the
-# makefiles, etc.
-
-# Only set the VOB_BASE_DIR if it is not already set.
-# In this case, set it based on the first argument if it is present
-# and otherwise default to /vobs.
-if (! $?VOB_BASE_DIR) then
-   if ($# >= 1) then 
-     setenv VOB_BASE_DIR $1 
-   else 
-     setenv VOB_BASE_DIR /vobs
-   endif
-   echo Set VOB_BASE_DIR to $VOB_BASE_DIR ...
-else
-   echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
-endif
-
-# SDK_LOCAL is the local staging area (i.e., view private) for private
-# builds and installs of the corelibs libraries.  The path should be 
-# relative to VOB_BASE_DIR.  Set to a default value if it is not set 
-if (! $?SDK_LOCAL) then
-  setenv SDK_LOCAL $PV_TOP
-  echo Set SDK_LOCAL to $SDK_LOCAL ...
-else
-  echo SDK_LOCAL already defined as $SDK_LOCAL
-endif
-
-setenv PROJECT $PV_TOP
-echo Set PROJECT to $PROJECT ...
-
-setenv MK $VOB_BASE_DIR/tools_v2/build/make
-echo Set MK to $MK ...
-
-setenv CCASE_MAKE_COMPAT gnu
-echo Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ...
-
-if (! -f $MK/../bin/archtype) then
-   echo "Error. Cannot find archtype script $MK/../bin/archtype."
-endif
-
-set arch_bin_path = `$MK/../bin/archtype`
-set extern_tools_path = $VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
-if ( -x /icl-tools/bin/$arch_bin_path/utok ) then
-  set path = (`/icl-tools/bin/$arch_bin_path/utok -s \  ./$arch_bin_path $extern_tools_path $path`)
-else 
-  set path = (./$arch_bin_path  $extern_tools_path $path)
-endif
-unset arch_bin_path
-unset extern_tools_path
-
-if ( -f ./setup.extras ) then
-  echo File setup.extras found, sourcing ...
-  source ./setup.extras
-else
-  echo File setup.extras not found, skipping ...
-endif
-
-# Rehash
-#
-rehash
-rehash
-
-# Finita
-#
-echo 
-echo Environment is ready if no errors reported
-echo 
diff --git a/tools_v2/build/bin/setup.ksh b/tools_v2/build/bin/setup.ksh
deleted file mode 100755
index 76e0110..0000000
--- a/tools_v2/build/bin/setup.ksh
+++ /dev/null
@@ -1,68 +0,0 @@
-echo Setting up build environment with default configuration ...
-echo Using $PWD as top directory ...
-
-# Set the PV_TOP
-#
-export PV_TOP=$PWD
-echo Set PV_TOP to $PV_TOP ...
-
-# Setup environment for necessary for the
-# makefiles, etc.
-
-# Only set the VOB_BASE_DIR if it is not already set.
-# In this case, set it based on the first argument if it is present
-# and otherwise default to /vobs.
-if [[ -z $VOB_BASE_DIR ]]; then
-   if [[ $# -ge 1 ]]; then 
-     export VOB_BASE_DIR="$1"
-   else 
-     export VOB_BASE_DIR="/vobs"
-   fi
-   echo "Set VOB_BASE_DIR to $VOB_BASE_DIR ..."
-else
-   echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
-fi
-
-# SDK_LOCAL is the local staging area (i.e., view private) for private
-# builds and installs of the corelibs libraries.  The path should be 
-# relative to VOB_BASE_DIR.  Set to a default value if it is not set 
-if [[ -z $SDK_LOCAL ]]; then
-  export SDK_LOCAL=$PV_TOP
-  echo "Set SDK_LOCAL to $SDK_LOCAL ..."
-else
-  echo "SDK_LOCAL already defined as $SDK_LOCAL"
-fi
-
-export PROJECT=$PV_TOP
-echo "Set PROJECT to $PROJECT ..."
-
-export MK="$VOB_BASE_DIR/tools_v2/build/make"
-echo "Set MK to $MK ..."
-
-export CCASE_MAKE_COMPAT="gnu"
-echo "Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ..."
-
-if [[ ! -f "$MK/../bin/archtype" ]];  then
-  echo "Error. Cannot find archtype script $MK/../bin/archtype."
-fi
-
-export arch_bin_path=`$MK/../bin/archtype`
-export extern_tools_path=$VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
-if [[ -x /icl-tools/bin/$arch_bin_path/utok ]]; then
-  export PATH=$PATH:`/icl-tools/bin/$arch_bin_path/utok -s \  ./$arch_bin_path  $extern_tools_path $PATH`
-else
-  export PATH=./$arch_bin_path:$extern_tools_path:$PATH
-fi
-export arch_bin_path=
-export extern_tools_path=
-
-if [[ -f ./setup.extras.ksh ]]; then
-   echo File setup.extras.ksh found, sourcing ...
-   . ./setup.extras.ksh
-else
-   echo File setup.extras not found, skipping ...
-fi 
-
-echo 
-echo Environment is ready if no errors reported
-echo
diff --git a/tools_v2/build/bin/show_doc b/tools_v2/build/bin/show_doc
deleted file mode 100755
index 6130d3a..0000000
--- a/tools_v2/build/bin/show_doc
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-#
-# show_doc - Dump the documentation from a GNUmake template to the
-# standard output
-#
-WHOAMI=`basename $0`
-
-if [ $# -ne 1 ]; then
-	echo usage: $WHOAMI filename 2>&1
-	exit 1
-fi
-
-if [ -r $1 ]; then
-
-	awk '
-		BEGIN			{ indoc = 0; }
-
-		$0 == "#BEGINDOC"	{ indoc = 1; continue }
-
-		$0 == "#ENDDOC"		{ indoc = 0; continue }
-
-		indoc == 1 {
-			print $0
-		}
-	' $1 | sed -e 's/^# *//g'
-
-else
-	echo $WHOAMI: Can\'t open $1 2>&1
-	exit 1
-fi
diff --git a/tools_v2/build/defaults/makefile.pv.mk b/tools_v2/build/defaults/makefile.pv.mk
deleted file mode 100644
index 901763f..0000000
--- a/tools_v2/build/defaults/makefile.pv.mk
+++ /dev/null
@@ -1,128 +0,0 @@
-
-MK=$(VOB_BASE_DIR)/tools_v2/build/make
-
-PROJECT=$(PV_TOP)
-STAGING=
-BASELINE=
-
-# Add SDK to search path to find core libraries.  Note that the local SDK 
-# is searched first so that local builds can override the builds in $(VOB_BASE_DIR)/corelibs
-#
-
-POST_INCDIRS += -I$(SDK_LOCAL)/include \
-		-I$(SDK_LOCAL)/installed_include \
-		-I$(VOB_BASE_DIR)/oscl/oscl/config/shared \
-		-I$(VOB_BASE_DIR)/oscl/oscl/config/$(BUILD_ARCH)
-
-
-POST_LIBDIRS += -L$(SDK_LOCAL)/installed_lib/$(BUILD_ARCH) \
-		-L$(VOB_BASE_DIR)/oscl/SDK/lib/$(BUILD_ARCH) \
-
-
-
-# Set the default toolset
-#
-
-ifneq (,$(findstring wince,$(BUILD_ARCH)))
- ifeq ($(strip $(WINCE_VER)),)
-        _error_no_wince_ver:
-		@echo Error: WINCE_VER (200, 201, 210, 211, 212 or 300) must be defined, make stopped
-		@/bin/false
- endif
-endif
-
-$ARCHITECTURE = $(shell $(MK)/../bin/archtype)
-
-ifeq ($(ARCHITECTURE),hpux)
-  TOOLSET=aCC
-else
-  ifeq ($(ARCHITECTURE),win32)
-    ifneq (,$(findstring wince,$(BUILD_ARCH)))
-      TOOLSET=ms_ecpp
-    else
-      ifneq (,$(findstring _arm,$(BUILD_ARCH)))
-        TOOLSET=armcpp
-      else 
-        TOOLSET=cl
-      endif
-    endif
-  else 
-    TOOLSET=g++
-  endif
-endif     
-
-
-
-# Set compilation flags based on the toolset and release/debug build type
-#
-#
-#   Adding _HPUX_SOURCE and _XOPEN_SOURCE_EXTENDED to get socket functions 
-#   with socklen_t parameters.
-#
-
-ifeq ($(TOOLSET),aCC)
-    CPPFLAGS += -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_PTHREADS -D_RWSTD_MULTI_THREAD -lpthread
-else
-  ifeq ($(TOOLSET),g++)
-    CPPFLAGS += -D_GNU_SOURCE -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -D_PTHREADS
-  else
-    ifeq ($(TOOLSET),armcpp)
-       # Try using these defines for now
-       CPPFLAGS += -D_DUMMY_ARMCPP_DEFINE
-    else
-      ifeq ($(TOOLSET),cl)
-        CPPFLAGS += /D "WIN32" /D "_MBCS" /D "_LIB"
-      else
-        ifeq ($(TOOLSET),ms_ecpp)
-          CPPFLAGS += /D _WIN32_WCE=$(WINCE_VER) /D UNDER_CE=$(WINCE_VER) /D "UNICODE" /D "_UNICODE" /D "_LIB"
-        else
-          _error_default_bad_toolset:
-		@echo Error: unknown toolset [$(TOOLSET)], make stopped
-		@/bin/false
-        endif
-      endif
-    endif
-  endif
-endif
-
-
-ifeq ($(RELEASE),1)
-  ifeq ($(TOOLSET),aCC)
-    COMPFLAGS += +O2 -Aa -AA -ext +A +DD32 +DAportable
-    CPPFLAGS += -DNDEBUG 
-    # -AA flag needed in linker command to get new std library
-    LDFLAGS += -AA -s 
-  else
-    ifeq ($(TOOLSET),cl)
-      COMPFLAGS +=  /nologo /MTd /W3 /Z7 /FD /GZ
-    else
-      ifeq ($(TOOLSET),ms_ecpp)
-        COMPFLAGS +=  /nologo /W3 /Z7 /Od /MC
-      else
-        COMPFLAGS += -Wall -O3
-        CPPFLAGS += -DNDEBUG 
-        # The next line is used to create a stripped binary
-        LDFLAGS += -Xlinker -s
-      endif
-    endif
-  endif
-else
-  ifeq ($(TOOLSET),aCC)
-    COMPFLAGS += -g -Aa -AA -ext +A +DD32 +DAportable
-    LDFLAGS += -D_RWSTD_MULTI_THREAD -D_REENTRANT -lpthread
-    # -AA flag needed in linker command to get new std library
-    LDFLAGS += -AA
-  else
-    ifeq ($(TOOLSET),cl)
-      COMPFLAGS +=  /nologo /MTd /W3 /Z7 /FD /GZ /D "_DEBUG"
-    else
-      ifeq ($(TOOLSET),ms_ecpp)
-        COMPFLAGS +=  /nologo /W3 /Z7 /Od /MC /D "DEBUG"
-      else
-        COMPFLAGS += -Wall -g 
-      endif
-    endif
-  endif
-endif
-
-COMPFLAGS += $(DEBUG)
diff --git a/tools_v2/build/document/bin/doc_build.bat b/tools_v2/build/document/bin/doc_build.bat
new file mode 100755
index 0000000..9babc15
--- /dev/null
+++ b/tools_v2/build/document/bin/doc_build.bat
@@ -0,0 +1,1324 @@
+@rem = 'Perl, ccperl read this as an array assignment & skip the goto
+@echo off
+goto endofperl
+@rem ';
+#!/usr/atria/bin/Perl
+#----------------------------------------------------------------------
+#  Copyright (C) 2003 PacketVideo
+#  This script is to automate the building of API Documentation
+#  through use of the Doxygen tool.
+#
+#  See http://www.stack.nl/~dimitri/doxygen/  for more information on
+#  Doxygen.
+#
+# ---------------------------------------------------------------------
+
+use Cwd;
+use Getopt::Long;
+use Time::Local;
+use File::Basename;
+
+my $ScriptName = $0;
+my $date_str;
+my $DATE_STR;
+my $doctype_list_string;
+my @doc_list;
+my $level_string;
+my $PostDocs;
+my $InputVersion;
+my $help ;
+my $DS;
+my $VIEW;
+my $TMPDIR;
+my $DOXYGEN;
+my $INDEXFILE;
+my $BUILDNUM;
+my $LBUILDNUM;
+my $CFGFILE="config.doxy";
+my $LOGFILE;
+my $BUILDDIR;
+my $STAGEDIR;
+my $DOCDIR;
+my $CC_DIR;
+my $DOC_TYPE;
+my $PROJ_NAME;
+my $INPUTDIR;
+my $WORDLIST;
+my $FILETYPE;
+my $EXCLUDE;
+my $EXCLUDE_PATTERN;
+my $CurrDir = cwd();
+my $OldPath = $ENV{"PATH"};
+my $MOVED = 0;
+my $AddCopyright = 0;
+
+# Graphic Conversion Variables
+my $CONVERSIONHOST="winbuild05";
+my $CONVERSIONDRIVE = "C:";
+my $CONVERSIONDIR = "DOCUMENT_CONVERSION";
+my $CONVERSIONTIMER = 10;
+my $LOCKFILE = "convert.lock";
+my $MS_VISIO = "${CONVERSIONDRIVE}\\Program Files\\Microsoft Office\\Visio11\\Visio.exe";
+my $MIKTEX_PATH = "${CONVERSIONDRIVE}\\miktex\\miktex\\bin";
+my $VISIOTOJPG = "${CONVERSIONDRIVE}\\doc_tools\\VisioToJpg.exe";
+my $WORDTOPDF = "${CONVERSIONDRIVE}\\doc_tools\\Convert2PDF.bat";
+my $RCP;
+
+
+{
+    local(@whoami) = split('/', $0);
+    $whoami = pop(@whoami);
+};
+
+sub usage {
+
+    print STDERR "\nUsage: doc_build [--help] [--doctype <list of documents> ]\n";
+    print STDERR "[--path <path to documents>][--word <list of files to convert>]\n";
+    print STDERR "[--filetype <file types>][--exclude <files/directory>]\n";
+    print STDERR "[--exclude_pattern <files/directory>][--title <title of document>]\n";
+    print STDERR "[--level <documentation level>][--ver <version to specify>]\n";
+    print STDERR "[--post ][--copyright]\n\n";
+
+    print STDERR "The options are:\n";
+
+    print STDERR "[--doctype <list of documents>] specify the documents to build.  Default:  All\n";
+    print STDERR "[--title <title of documents>] title to use in the document.\n";
+    print STDERR "[--path <path to documents>] specify the path documents to build if not one of the standard documents/directories.\n";
+    print STDERR "[--word <list of files to convert>] specify files to convert to PDF format\n"; 
+    print STDERR "[--filetype <file types>] default: *.h *.cpp\n";
+    print STDERR "[--exclude <files/directory>] default:  none\n";
+    print STDERR "[--exclude_pattern <files/directory>] default:  none\n";
+    print STDERR "[--ver <version>] version to use in the document.\n";
+    print STDERR "[--level <list of documents>] specifiy document level, default: All\n";
+    print STDERR "[--post] Post documents on website\n";
+    print STDERR "[--copyright] Add copyright to front page of document\n";
+    print STDERR "[--help] Display usage\n";
+
+    print STDERR "\n";
+    exit (-1);
+}
+
+sub trim {
+	my @out = @_;
+
+	for (@out) {
+		s/^\s+//;
+		s/\s+$//;
+	}
+
+	return wantarray ? @out : $out[0];
+}
+
+sub GenerateDatestr {
+
+	my $type = $_[0];
+	my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
+	my $datestring;
+	# year has 1900 subtracted from it
+	$year += 1900;
+	# only want the last two digits from the year
+	$year =~ s/\d{2}//;
+	# mon is zero-based
+	$mon++;
+	if ( $type eq "time" ) {
+		$datestring = sprintf "%02d%02d%02d%02d%02d%02d\n", $year, $mon, $mday, $hour, $min, $sec;
+	} elsif ( $type eq "string" ) {
+		$datestring = scalar(localtime(time));
+		my @date = split(/ +/, $datestring);
+		my $month;
+		SWITCH: {
+			if ( $date[1] =~ /Jan/ ) { $month = "January"; last SWITCH; }
+			if ( $date[1] =~ /Feb/ ) { $month = "February"; last SWITCH; }
+			if ( $date[1] =~ /Mar/ ) { $month = "March"; last SWITCH; }
+			if ( $date[1] =~ /Apr/ ) { $month = "April"; last SWITCH; }
+			if ( $date[1] =~ /May/ ) { $month = "May"; last SWITCH; }
+			if ( $date[1] =~ /Jun/ ) { $month = "Jun"; last SWITCH; }
+			if ( $date[1] =~ /Jul/ ) { $month = "July"; last SWITCH; }
+			if ( $date[1] =~ /Aug/ ) { $month = "August"; last SWITCH; }
+			if ( $date[1] =~ /Sep/ ) { $month = "September"; last SWITCH; }
+			if ( $date[1] =~ /Oct/ ) { $month = "October"; last SWITCH; }
+			if ( $date[1] =~ /Nov/ ) { $month = "November"; last SWITCH; }
+			if ( $date[1] =~ /Dec/ ) { $month = "December"; last SWITCH; }
+			$nothing = 1;
+		}
+
+		$datestring = "$month $date[2], $date[4]";
+	} else {
+		$datestring = sprintf "%02d%02d%02d\n", $year, $mon, $mday;
+	}
+	chomp ($datestring);
+	return ($datestring);
+}
+
+sub SetView {
+
+	if ( $VIEW eq "" ) {
+		# On Windows, cleartool -pwv doesn't work in all view types.
+		# So determine VIEW by path used to get to script.
+		# If still can't find it, prompt for view.
+		my $dir = dirname($ScriptName);
+		
+		chdir("$dir");
+	
+		chdir("../../../..");
+		$VIEW = cwd();
+		if ($ENV{'OS'} =~ /Windows/) {
+			$VIEW =~ s/\///g;
+		}
+		chomp ($VIEW);
+
+		if ( $VIEW eq "" || ! -e "${VIEW}${DS}extern_tools_v2" ) {
+			print "Unable to determine view to use.\n";
+			print "Please enter view path to use:  ";
+			$VIEW = <STDIN>;
+			chomp ($VIEW);
+		}
+	
+		# Remove any trailing slashes.
+		if ( $VIEW =~ /${DS}\$/ ) {
+			chop($VIEW);
+		}
+	}
+
+	if ( ! -e "${VIEW}${DS}extern_tools_v2" ) {
+		if ( -e "${VIEW}${DS}vobs${DS}extern_tools_v2" ) {
+			$VIEW = "${VIEW}${DS}vobs";
+		} else {
+			print "Unable to find $VIEW${DS}extern_tools_v2.\n\n";
+			exit(-1);
+		}
+	}
+
+	print "VIEW is set to $VIEW\n";
+}
+
+sub GetBuildNum {
+
+	my $BuildConfigSpec="${VIEW}${DS}pvadmin${DS}BranchConfigSpec.txt";
+	my $Label;
+	my @list = ();
+
+	# If version label was passed in, use that.
+	# Next, try to get label from Config Spec.
+	# Next, try to get label from Clearcase elements.
+	# If none of the files are in Clearcase, create a generic build label.
+	if ( $InputVersion ne "" ) {
+		$BUILDNUM="$InputVersion";
+		return (0);
+	}
+
+	chdir("${VIEW}${DS}pvadmin");
+	$status = `cleartool catcs`;
+	@list = split(/\n/, $status);
+	foreach $line (@list) {
+		if ( !( $line =~ /^#/ )) {
+			if ( !( $line =~ /^$/ )) {
+				if ( $Label eq "" ) {
+					$Label = $line;
+					chomp($Label);
+				}
+			}
+		}
+	}
+
+	if ( $Label =~ /element/ ) {
+		@list = split(/ /,$Label);
+		$Label = "$list[$#list]";
+	} elsif ( $Label =~ /include/ ) {
+		@list = split(/ /,$Label);
+		$Label = "$list[$#list]";
+		@list = split(/\//,$Label);
+		$Label = "$list[$#list]";
+	}
+
+
+	if ( ( $Label =~ /LATEST/ ) || ($Label =~ /CHECKEDOUT/ ) ) {
+		$Label = "";
+		open(FIN, "$BuildConfigSpec");
+		while (<FIN>) {
+			if ( !( $_ =~ /^#/ )) {
+				if ( !( $_ =~ /^$/ )) {
+					if ( $Label eq "" ) {
+						$Label = $_;
+						chomp($Label);
+					}
+				}
+			}
+		}
+		close FIN;
+
+		if ( $Label =~ /element/ ) {
+			@list = split(/ /,$Label);
+			$Label = "$list[$#list]";
+		} elsif ( $Label =~ /include/ ) {
+			@list = split(/ /,$Label);
+			$Label = "$list[$#list]";
+		}
+
+	}
+
+	$BUILDNUM = $Label;
+}
+
+sub SetEnv {
+
+	$date_str = GenerateDatestr();
+	$DATE_STR = GenerateDatestr("string");
+
+	$INDEXFILE="/opt/pvserver/web/webapps/docs/index.html";
+
+	# Create directory split variable
+	$DS = "/";
+
+	if ($ENV{'OS'} =~ /Windows/) {
+		fileparse_set_fstype("MSDOS");
+		# Create directory split variable
+		$DS = "\\";
+	}
+	  # see if caller knows where we should put temps
+	  # if not, $TMPDIR will stay undef
+	$TMPDIR=$ENV{'DOC_BUILD__TMPDIR'};
+
+        # see if caller wants to override VIEW
+	$VIEW=$ENV{'VIEW'};
+
+	if ($ENV{'OS'} =~ /Windows/) {
+		# Create platform specific commands
+		$RCP = "rcp -b";
+		$MKDIR = "mkdir";
+		$RMDIR = "rmdir /S /Q";
+		$COPY = "copy";
+	
+		# Create platform specific Environment
+		$TMPDIR = "C:\\temp" if !$TMPDIR;
+		$BUILDDIR="${TMPDIR}\\documentation_build";
+		$STAGEDIR="${TMPDIR}\\documentation_stage";
+		$LOGFILE="${TMPDIR}\\docbuild.log";
+		$status = `del /Q $LOGFILE 2>&1`;
+	} else {
+		# Create platform specific commands
+		$RCP = "rcp";
+		$MKDIR = "mkdir -p";
+		$RMDIR = "rm -rf";
+		$COPY = "cp";
+	
+		# Create platform specific Environment
+		$TMPDIR = "/tmp" if !$TMPDIR;
+		$BUILDDIR="${TMPDIR}/documentation_build";
+		$STAGEDIR="${TMPDIR}/documentation_stage";
+		$LOGFILE="${TMPDIR}/docbuild.log";
+		$status = `rm -f $LOGFILE 2>&1`;
+	}
+}
+
+sub SetCCEnv {
+
+	SetView();
+	# Once we know path to view, include PVutilities.pl
+	if ($ENV{OS} =~ /Windows/) {
+		$lib_path = "$VIEW\\tools_v2\\build\\document\\bin";
+	} else {
+		$lib_path = "$VIEW/tools_v2/build/document/bin";
+	}
+	# DEBUG
+#	$lib_path = "/tmp/doc";
+	unshift (@INC, "$lib_path");
+	require "PVutilities.pl";
+
+	GetBuildNum();
+	print "Using build label: $BUILDNUM.\n";
+
+	# LBUILDNUM is for Latex files - need different format.
+	$LBUILDNUM="$BUILDNUM";
+	$LBUILDNUM =~ s/_/\\_/g;
+
+	# Create platform specific Environment
+	if ($ENV{'OS'} =~ /Windows/) {
+		$DOXYGEN="${VIEW}\\extern_tools_v2\\doxygen\\win32\\doxygen.exe";
+		$CC_DIR="${VIEW}\\tools_v2\\build\\document\\templates\\";
+		$ENV{"PATH"} = "${VIEW}\\extern_tools_v2\\doxygen\\win32;${OldPath}";
+	} else {
+		$SYSTYPE = `uname -s`;
+		chomp ($SYSTYPE);
+		if ($SYSTYPE =~ /SunOS/) {
+			$DOXYGEN="${VIEW}/extern_tools_v2/doxygen/sun/doxygen";
+		} elsif ($SYSTYPE =~ /Linux/) {
+			$DOXYGEN="${VIEW}/extern_tools_v2/doxygen/linux/doxygen";
+		} elsif ($SYSTYPE =~ /HP-UX/) {
+			$DOXYGEN="${VIEW}/extern_tools_v2/doxygen/hpux/doxygen";
+		} else {
+			print STDERR "Unknown system type $SYSTYPE\n\n";
+			exit (-1);
+		}
+		$CC_DIR="${VIEW}/tools_v2/build/document/templates/";
+
+		# Setup Path so we find latex files
+		$ENV{"PATH"} = "${VIEW}/extern_tools_v2/latex/linux/bin:${OldPath}";
+		$ENV{"TETEXDIR"} = "${VIEW}/extern_tools_v2/latex/linux/share/web2c";
+		$ENV{"TEXMFMAIN"} = "${VIEW}/extern_tools_v2/latex/linux/share";
+	}
+}
+
+sub ConvertFilename {
+
+	$_ = $_[0];
+	if ($ENV{'OS'} =~ /Windows/) {
+		tr/\//\\/;
+	} else {
+		tr/\\/\//;
+	}
+
+	return $_;
+}
+
+sub GetDirname {
+
+	my $filename = $_[0];
+	my $dir;
+
+	if ( $filename =~ /\// ) {
+		fileparse_set_fstype("UNIX");
+	} else {
+		fileparse_set_fstype("MSDOS");
+	}
+
+	$dir = dirname($filename);
+
+	if ( $dir =~ /\// ) {
+		$dir = "${dir}/";
+	} else {
+		$_ = $dir;
+		s/\\/\\\\/g;
+		$dir = $_;
+		$dir = "${dir}\\\\";
+	}
+
+	# Reset to proper platform
+	if ($ENV{'OS'} =~ /Windows/) {
+		fileparse_set_fstype("MSDOS");
+	} else {
+		fileparse_set_fstype("UNIX");
+	}
+
+	return $dir;
+}
+
+sub CreateConversionLock {
+
+	my $Hostname = `hostname`;
+	chomp $Hostname;
+
+	# No longer need to do this with VisioToJpg tool
+        # Check that someone is logged in to ${CONVERSIONHOST}
+        # This is required for RSHD to pass keystrokes to Windows applications.
+        # 'qwinsta' can be used to query currently logged in users.
+       	# $status = `rsh ${CONVERSIONHOST} "qwinsta"`;
+	#      	if ( $status =~ /Active/ ) {
+	# 		# Good - found active user
+	# 	} else {
+	#                # Assume nobody is not logged in.
+	#                print "\nWarning:  A user does not appear to be logged in to Conversion server ${CONVERSIONHOST}.\n\n";
+	#                print "This is necessary for document conversion.\n";
+	#                print "Please login on ${CONVERSIONHOST} and restart script.\n\n";
+	#		exit(-1);
+	#        }
+
+	my $lockmessage = "Locked on $DATE_STR from $Hostname";
+	my $status = `rsh $CONVERSIONHOST \"DIR ${CONVERSIONDRIVE}\\${LOCKFILE}\ 2>&1\"`;
+	if ($?) {
+		print "rsh failed to connect to host $CONVERSIONHOST\n";
+		return (1);
+	} else
+	{
+        	if ( $status =~ /File Not Found/ )
+		{
+			# create lock file
+			$status = `rsh ${CONVERSIONHOST} "ECHO ${lockmessage} > ${CONVERSIONDRIVE}\\${LOCKFILE}"`;
+		} else
+		{
+			$status = `rsh ${CONVERSIONHOST} "TYPE ${CONVERSIONDRIVE}\\${LOCKFILE}"`;
+			print "Conversion server ${CONVERSIONHOST} may be in use\n\n";
+			print "$status\n";
+	                print "Check for ${CONVERSIONDRIVE}\\${LOCKFILE} file\n\n";
+			return (1);
+		}
+	}
+}
+
+sub SetupConverter {
+
+	my $status;
+	# create temporary directory for conversion
+	$status = `rsh ${CONVERSIONHOST} "RMDIR /S /Q ${CONVERSIONDRIVE}\\${CONVERSIONDIR} 2>&1"`;
+	if ($?) {
+		print "rsh failed to remove ${CONVERSIONDIR} from $CONVERSIONHOST\n";
+		return (1);
+	}
+
+	$status = `rsh ${CONVERSIONHOST} "MKDIR ${CONVERSIONDRIVE}\\${CONVERSIONDIR} 2>&1"`;
+	if ($?) {
+		print "rsh failed to create ${CONVERSIONDIR} from $CONVERSIONHOST\n";
+		return (1);
+	}
+
+	$status = `rsh ${CONVERSIONHOST} "MKDIR ${CONVERSIONDRIVE}\\temp 2>&1"`;
+}
+
+sub TransferFiles {
+
+	my $status;
+	my $file_to_convert=$_[0];
+
+#	print ">>>> Transferring $file_to_convert to ${CONVERSIONHOST}.\n";
+	if ($ENV{'OS'} =~ /Windows/) {
+		$filedir = dirname($file_to_convert);
+		$file_to_convert = basename($file_to_convert);
+		chdir("${filedir}");
+		$status = `$RCP ${file_to_convert} ${CONVERSIONHOST}:\\${CONVERSIONDIR}`;
+	} else {
+		$status = `$RCP ${file_to_convert} ${CONVERSIONHOST}:\\\\${CONVERSIONDIR}`;
+	}
+
+	if ($?) {
+		print "Failed to copy ${file_to_convert} to $CONVERSIONHOST\n";
+		return (1);
+	}
+
+}
+
+sub RunConversion {
+
+	my $convert_file = $_[0];
+	my $output_file = $_[1];
+	my $page_name = $_[2];
+
+	if ( $page_name eq "" ) {
+		$command = "$VISIOTOJPG -vsd ${CONVERSIONDRIVE}\\\\${CONVERSIONDIR}\\\\${convert_file} -jpg ${CONVERSIONDRIVE}\\\\${CONVERSIONDIR}\\\\${output_file}";
+	} else {
+		$command = "$VISIOTOJPG -vsd ${CONVERSIONDRIVE}\\\\${CONVERSIONDIR}\\\\${convert_file} -jpg ${CONVERSIONDRIVE}\\\\${CONVERSIONDIR}\\\\${output_file} -page \\\"${page_name}\\\"";
+	}
+
+	$status = `rsh ${CONVERSIONHOST} "$command" "$MS_VISIO"`;
+}
+
+sub RunWordToPDFConversion {
+
+	my $convert_file = $_[0];
+
+	$command = "$WORDTOPDF ${CONVERSIONDRIVE}\\\\${CONVERSIONDIR}\\\\${convert_file}";
+
+	$status = `rsh ${CONVERSIONHOST} "$command"`;
+}
+
+sub RetrieveFiles {
+
+	my $status;
+	my $file_to_retrieve=$_[0];
+	my $OldPwd = cwd();
+
+#	print ">>>> Retrieving $file_to_retrieve from ${CONVERSIONHOST}.\n";
+
+	chdir("${DOCDIR}");
+	if ($ENV{'OS'} =~ /Windows/) {
+		$status = `$RCP ${CONVERSIONHOST}:\\${CONVERSIONDIR}\\${file_to_retrieve} html${DS}`;
+		$status = `$RCP ${CONVERSIONHOST}:\\${CONVERSIONDIR}\\${file_to_retrieve} latex${DS}`;
+	} else {
+		$status = `$RCP ${CONVERSIONHOST}:\\\\${CONVERSIONDIR}\\\\${file_to_retrieve} ${DOCDIR}${DS}html`;
+		$status = `$RCP ${CONVERSIONHOST}:\\\\${CONVERSIONDIR}\\\\${file_to_retrieve} ${DOCDIR}${DS}latex`;
+	}
+	chdir("${OldPwd}");
+
+	if ($?) {
+		print "Failed to retrieve ${file_to_retrieve} from $CONVERSIONHOST\n";
+		return (1);
+	}
+
+}
+
+sub RetrieveWordFiles {
+
+	my $status;
+	my $file_to_retrieve=$_[0];
+	my $OldPwd = cwd();
+
+#	print ">>>> Retrieving $file_to_retrieve from ${CONVERSIONHOST}.\n";
+
+	chdir("${DOCDIR}");
+	if ($ENV{'OS'} =~ /Windows/) {
+		$status = `$RCP ${CONVERSIONHOST}:\\${CONVERSIONDIR}\\${file_to_retrieve} .`;
+	} else {
+		$status = `$RCP ${CONVERSIONHOST}:\\\\${CONVERSIONDIR}\\\\${file_to_retrieve} ${DOCDIR}`;
+	}
+	chdir("${OldPwd}");
+
+	if ($?) {
+		print "Failed to retrieve ${file_to_retrieve} from $CONVERSIONHOST\n";
+		return (1);
+	}
+
+}
+
+sub RemoveLock {
+	my $status = `rsh $CONVERSIONHOST \"DEL ${CONVERSIONDRIVE}\\${LOCKFILE}\ 2>&1"`;
+	if ($?) {
+		print "rsh failed to remove convert.lock from $CONVERSIONHOST\n";
+		return (1);
+	}
+}
+
+sub ConvertVisio {
+
+	my $visio_filename = $_[0];
+	my $visio_pagename = $_[1];
+	my $output_filename;
+	
+	$output_filename = basename($visio_filename);
+        @output_name = split(/\./, $output_filename);
+        $output_filename = "$output_name[$0].jpg";
+
+	print "     >>>>> Converting Visio file: $visio_filename\n";
+
+	if ( CreateConversionLock() != 0 ) {
+		print "Unable to convert $visio_filename\n";
+		return "";
+	}
+
+	if ( SetupConverter() != 0 ) {
+		print "Unable to convert $visio_filename\n";
+		RemoveLock();
+		return "";
+	}
+	
+	if ( TransferFiles($visio_filename) != 0 ) {
+		RemoveLock();
+		exit(-1);
+	}
+
+        @visio_name = split(/\./, $output_filename);
+        $visio_filename = "$visio_name[$0].vsd";
+
+	if ( RunConversion($visio_filename, $output_filename, $visio_pagename) != 0 ) {
+		RemoveLock();
+		exit(-1);
+	}
+
+	if ( RetrieveFiles($output_filename) != 0 ) {
+		RemoveLock();
+		exit(-1);
+	}
+
+
+	RemoveLock();
+	return $output_filename;
+
+}
+
+sub ConvertWordToPDF {
+
+	my $word_filename = $_[0];
+	my $output_filename;
+	
+	$output_filename = basename($word_filename);
+	@output_name = split(/\./, $output_filename);
+	$output_filename = "$output_name[$0].pdf";
+	$buildtype = "$output_name[$0]";
+
+	$DOCDIR="${BUILDDIR}${DS}${buildtype}";
+	$status = `${RMDIR} $DOCDIR >> $LOGFILE 2>&1`;
+	$status = `${MKDIR} $DOCDIR`;
+	if ($ENV{'OS'} !~ /Windows/) {
+		$status = `chmod 777 $BUILDDIR`;
+		$status = `chmod 777 $DOCDIR`;
+	}
+
+	print "     >>>>> Converting Word file to PDF: $word_filename\n";
+
+	if ( CreateConversionLock() != 0 ) {
+		print "Unable to convert $word_filename\n";
+		return "";
+	}
+
+	if ( SetupConverter() != 0 ) {
+		print "Unable to convert $word_filename\n";
+		RemoveLock();
+		return "";
+	}
+	
+	if ( TransferFiles($word_filename) != 0 ) {
+		RemoveLock();
+		exit(-1);
+	}
+
+	if ( RunWordToPDFConversion(basename($word_filename)) != 0 ) {
+		RemoveLock();
+		exit(-1);
+	}
+
+	if ( RetrieveWordFiles($output_filename) != 0 ) {
+		RemoveLock();
+		exit(-1);
+	}
+
+	RemoveLock();
+
+	print ">>>>> PDF File is located in ${DOCDIR}\n\n";
+}
+
+sub Grep {
+
+	my $returnlines;
+	my $pattern = $_[0];
+	my $file = $_[1];
+
+	$grepstatus = `find "$pattern" $file`;
+        my @name = split(/\\/, $file);
+        $grepfname = basename($file);
+	$Fname = uc($grepfname);
+
+	foreach $grepentry ( split(/\n/, $grepstatus) ) {
+		if ( $grepentry eq "" ) {
+			next;
+		}
+		if ( $grepentry =~ /$Fname/ )  {
+			next;
+		}
+		$returnlines = "$returnlines $grepentry\n";
+	}
+
+	return $returnlines;
+}
+
+sub UpdateHtml {
+
+	my $file = $_[0];
+	my $oldfile = $_[1];
+	my $newfile = $_[2];
+	my $scale = $_[3];
+	my $page = $_[4];
+
+	if ( $oldfile =~ /\\/ ) {
+		$_ = $oldfile;
+		s/\\/\\\\/g;
+		$oldfile = $_;
+	}
+
+	ReplaceString( -all, "$file", "INCLUDEVISIO", "\\|", "");
+	ReplaceString( -all, "$file", "$oldfile", "$oldfile", "$newfile");
+	ReplaceString( -all, "$file", "INCLUDEVISIO", "\{", "\"");
+	ReplaceString( -all, "$file", "INCLUDEVISIO", "\}", "\">");
+	ReplaceString( -all, "$file", "INCLUDEVISIO", "INCLUDEVISIO", "<img src");
+
+	if ( $scale ne "" ) {
+        	ReplaceString ( -all, "$file", "${newfile}${scale}", "${newfile}${scale}", "${newfile}");
+	}
+	if ( $page ne "" ) {
+		ReplaceString ( -all, "$file", "${newfile}${page}", "${page}", "");
+	}
+}
+
+sub UpdateLatexFormat {
+
+	
+	my @latex_files;
+	my $lfiles;
+
+	chdir("${DOCDIR}${DS}latex");
+	@latex_files = <*.tex>;
+	foreach $lfile ( @latex_files ) {
+
+		ReplaceString ( -all, "$lfile", "INCLUDEVISIO", '\$', "");
+		ReplaceString( -all, "$lfile", "INCLUDEVISIO", "\\|", "");
+		ReplaceString ( -all, "$lfile", "INCLUDEVISIO", 'backslash', "");
+		ReplaceString ( -all, "$lfile", "INCLUDEVISIO", "\\\\_\\\\-", "_");
+		ReplaceString ( -all, "$lfile", "INCLUDEVISIO", "\\\\-", "");
+		ReplaceString ( -all, "$lfile", "INCLUDEVISIO", "\\\\{", "{");
+		ReplaceString ( -all, "$lfile", "INCLUDEVISIO", "\\\\}", "}");
+	}
+}
+
+sub UpdateLatexFile {
+
+        my $file = $_[0];
+        my $oldfile = $_[1];
+        my $newfile = $_[2];
+        my $scale = $_[3];
+        my $page = $_[4];
+	my $dir = GetDirname($oldfile);
+
+        ReplaceString ( -all, "$file", "$dir", "$dir", "");
+        ReplaceString ( -all, "$file", "INCLUDEVISIO", ".vsd", ".jpg");
+
+	if ( $scale eq "" ) {
+		ReplaceString ( -all, "$file", "$newfile", "INCLUDEVISIO=", "\\includegraphics[scale=1]"); 
+		ReplaceString ( -all, "$file", "$newfile", "INCLUDEVISIO = ", "\\includegraphics[scale=1]"); 
+	} else {
+		ReplaceString ( -all, "$file", "${newfile}${scale}", "INCLUDEVISIO=", "\\includegraphics[scale=$scale]"); 
+		ReplaceString ( -all, "$file", "${newfile}${scale}", "INCLUDEVISIO = ", "\\includegraphics[scale=$scale]"); 
+        	ReplaceString ( -all, "$file", "${newfile}${scale}", "${newfile}${scale}", "${newfile}");
+	}
+	if ( $page ne "" ) {
+		ReplaceString ( -all, "$file", "${newfile}${page}", "${page}", "");
+	}
+}
+
+sub UpdateLatex {
+
+        my $file = $_[0];
+        my $oldfile = $_[1];
+        my $newfile = $_[2];
+        my $scale = $_[3];
+        my $page = $_[4];
+	my $dir = GetDirname($oldfile);
+
+	ReplaceString ( -all, "$file", "INCLUDEVISIO", '\$', "");
+	if ( $scale ne "" ) {
+		ReplaceString( -all, "$file", "INCLUDEVISIO", "$scale", "");
+		ReplaceString( -all, "$file", "$newfile", "$scale", "");
+	}
+	if ( $page ne "" ) {
+		ReplaceString( -all, "$file", "INCLUDEVISIO", "$page", "");
+		ReplaceString( -all, "$file", "$newfile", "$page", "");
+	}
+	ReplaceString( -all, "$file", "INCLUDEVISIO", "\\|", "");
+	ReplaceString ( -all, "$file", "INCLUDEVISIO", 'backslash', "");
+        ReplaceString ( -all, "$file", "INCLUDEVISIO", "\\\\_\\\\-", "_");
+        ReplaceString ( -all, "$file", "INCLUDEVISIO", "\\\\-", "");
+        ReplaceString ( -all, "$file", "$dir", "$dir", "");
+        ReplaceString ( -all, "$file", "INCLUDEVISIO", ".vsd", ".jpg");
+        ReplaceString ( -all, "$file", "INCLUDEVISIO", "\\\\{", "{");
+        ReplaceString ( -all, "$file", "INCLUDEVISIO", "\\\\}", "}");
+	if ( $scale eq "" ) {
+		ReplaceString ( -all, "$file", "$newfile", "INCLUDEVISIO=", "\\includegraphics[scale=1]"); 
+		ReplaceString ( -all, "$file", "$newfile", "INCLUDEVISIO = ", "\\includegraphics[scale=1]"); 
+	} else {
+		ReplaceString ( -all, "$file", "$newfile", "INCLUDEVISIO=", "\\includegraphics[scale=$scale]"); 
+		ReplaceString ( -all, "$file", "$newfile", "INCLUDEVISIO = ", "\\includegraphics[scale=$scale]"); 
+	}
+}
+
+sub InstallGraphics {
+
+	my $status;
+	my $file_list;
+	my $page_name;
+	my $jpg_scale;
+	my $extension;
+
+	print "     >>>>> Checking for graphic files to install.\n";
+
+	if ($ENV{'OS'} =~ /Windows/) {
+		$status = `dir /A-D /B /S $INPUTDIR`; 
+	} else {
+		$status = `find $INPUTDIR -type f -print`;
+	}
+	@file_list = split(/\n/,$status);
+	foreach $fname (@file_list) {
+
+		# Check that file is a code file
+		@file_part = split(/\./, $fname);
+		$extension = $file_part[1];
+		if ( ( $extension ne "h" ) && ( $extension ne "cpp" ) ) {
+			next;
+		}
+
+		# Check that file exists
+		if ( ! -e $fname ) {
+			next;
+		}
+
+		# Check for latex graphics
+		if ($ENV{'OS'} =~ /Windows/) {
+			$status = Grep("includegraphic",$fname);
+		} else {
+			$status = `grep includegraphic $fname`;
+		}
+		chomp $status;
+		if ( $status ne "" ) {
+			foreach $fentry ( split(/\n/, $status) ) {
+				@fields = split(/[{}]/,$fentry);
+				$filename = $fields[1];
+				$latex_dir = GetDirname($filename);
+				if ( ! -e $filename ) {
+					$filename = ConvertFilename($filename);
+					if ( -e $filename ) {
+						# filename just needed converting
+					} elsif ( -e "${VIEW}${filename}" ) {
+						$filename = "$VIEW$filename";
+					} elsif ( -e "${VIEW}${DS}${filename}" ) {
+						$filename = "$VIEW${DS}$filename";
+					} else {
+						# If file is still not found, print error.
+						print STDERR "ERROR: $filename cannot be located\n";
+						exit();
+					}
+				}
+		
+				$status = `${COPY} $filename ${DOCDIR}${DS}latex`;
+				chdir("${DOCDIR}${DS}latex");
+				@latex_files = <*.tex>;
+				foreach $lfile ( @latex_files ) {
+        				ReplaceString ( -all, "${lfile}", "\\includegraphics", "${latex_dir}", "");
+				}
+			}
+		}
+	
+		# Check for html graphics
+		if ($ENV{'OS'} =~ /Windows/) {
+			$status = Grep("img src",$fname);
+		} else {
+			$status = `grep "img src" $fname`;
+		}
+		chomp $status;
+		if ( $status ne "" ) {
+			foreach $fentry ( split(/\n/, $status) ) {
+				@fields = split(/["]/,$fentry);
+				$filename = $fields[1];
+				$html_dir = GetDirname($filename);
+				if ( ! -e $filename ) {
+					$filename = ConvertFilename($filename);
+					if ( -e $filename ) {
+						# filename just needed converting
+					} elsif ( -e "${VIEW}${filename}" ) {
+						$filename = "$VIEW$filename";
+					} elsif ( -e "${VIEW}${DS}${filename}" ) {
+						$filename = "$VIEW${DS}$filename";
+					} else {
+						# If file is still not found, print error.
+						print STDERR "ERROR: $filename cannot be located\n";
+						exit();
+					}
+				}
+				$status = `${COPY} $filename ${DOCDIR}${DS}html`;
+				chdir("${DOCDIR}${DS}html");
+				@html_files = <*.html>;
+				foreach $hfile ( @html_files ) {
+					ReplaceString ( -all, "${hfile}", "img src", "${html_dir}", "");
+				}
+			}
+		}
+
+		# Check for Visio graphics
+		if ($ENV{'OS'} =~ /Windows/) {
+			$status = Grep("INCLUDEVISIO",$fname);
+		} else {
+			$status = `grep "INCLUDEVISIO" $fname`;
+		}
+		chomp $status;
+		if ( $status ne "" ) {
+			UpdateLatexFormat();
+			foreach $fentry ( split(/\n/, $status) ) {
+				@fields = split(/[{}|]/,$fentry);
+				$filename = $fields[1];
+				$ofilename = $fields[1];
+				$jpg_scale = $fields[2];
+				$page_name = $fields[3];
+				if ( ! -e $filename ) {
+					$filename = ConvertFilename($filename);
+					if ( -e $filename ) {
+						# filename just needed converting
+					} elsif ( -e "${VIEW}${filename}" ) {
+						$filename = "$VIEW$filename";
+					} elsif ( -e "${VIEW}${DS}${filename}" ) {
+						$filename = "$VIEW${DS}$filename";
+					} else {
+						# If file is still not found, print error.
+						print STDERR "ERROR: $filename cannot be located\n";
+						exit();
+					}
+				}
+				$jpg_filename = ConvertVisio($filename, $page_name);
+				if ( $jpg_filename ne "" ) {
+					chdir("${DOCDIR}${DS}html");
+					@html_files = <*.html>;
+					foreach $hfile ( @html_files ) {
+						UpdateHtml( ${hfile}, $ofilename, $jpg_filename, $jpg_scale, $page_name);
+					}
+
+					chdir("${DOCDIR}${DS}latex");
+					@latex_files = <*.tex>;
+					foreach $lfile ( @latex_files ) {
+						UpdateLatexFile( ${lfile}, $ofilename, $jpg_filename, $jpg_scale, $page_name);
+					}
+				}
+			}
+		}
+	}
+}
+
+sub Eps2PDF {
+
+	if (!open(FILE, ">eps2pdf.pl")) {
+	  print "Error cannot open eps2pdf.pl for output\n";
+	  return -1;
+	}	
+
+	print FILE <<SCRIPT_END;
+#!/usr/bin/perl
+
+foreach \$f (<*.eps>) {
+  my \$g = \$f;
+  \$g =~ s/.eps/.pdf/;
+  if (! -e \$g) {
+    my \$status = `epstopdf \$f > \$g`;
+  }
+}
+SCRIPT_END
+	close FILE;
+	return 0;
+}
+
+
+sub BuildPDF {
+
+	my $PdfConvHost = "srSANDocBuild.pv.com";
+	my $PdfConvUser = "docbuild";
+	my $PdfConvDir;
+	my $timestamp = GenerateDatestr("time");
+
+	print "     >>>>> Preparing $PdfConvHost\n";
+	$PdfConvDir = "/home/${PdfConvUser}/latex_${timestamp}";
+
+	$status = `rsh $PdfConvHost -l $PdfConvUser "mkdir -p ${PdfConvDir}" 2>>$LOGFILE`;
+	if ( $status =~ /can't establish connection/ ){
+		print "Error:  Cannot connect to $PdfConvHost\n";
+		return;
+	}
+
+	# output the epstopdf script
+	if (Eps2PDF()) {
+	   print "Error: creating Eps2PDF script\n";
+	   return;
+	}
+
+	if ($ENV{'OS'} =~ /Windows/) {
+		$status = `$RCP * ${PdfConvHost}.${PdfConvUser}:${PdfConvDir}`;
+	} else {
+		$status = `chmod +w *`;
+		$status = `$RCP * ${PdfConvUser}\@${PdfConvHost}:${PdfConvDir} 2>>$LOGFILE`;
+	}
+
+	print "     >>>>> Generating PDF.  Please wait....\n";
+	$status = `rsh $PdfConvHost -l $PdfConvUser "cd ${PdfConvDir};perl eps2pdf.pl;/opt/rational/clearcase/bin/clearmake" >> $LOGFILE 2>&1`;
+	
+	if ($ENV{'OS'} =~ /Windows/) {
+		$status = `$RCP ${PdfConvHost}.${PdfConvUser}:${PdfConvDir}/* .`;
+	} else {
+		$status = `$RCP ${PdfConvUser}\@${PdfConvHost}:${PdfConvDir}/* . 2>>$LOGFILE`;
+	}
+
+	$status = `rsh $PdfConvHost -l $PdfConvUser "rm -rf ${PdfConvDir}" 2>>$LOGFILE`;
+}
+
+sub BuildDocs {
+
+	my $buildtype=$_[0];
+
+	$DOCDIR="${BUILDDIR}${DS}${buildtype}";
+
+	if ( "$INPUTDIR" eq "" ) {
+		if ("$buildtype" eq "symbian") {
+			$PROJ_NAME="Symbian pvPlayer";
+			$INPUTDIR="${VIEW}${DS}sdk${DS}common${DS}enginecommon${DS}base${DS}inc${DS}PVCommonBase.h ${VIEW}${DS}sdk${DS}common${DS}enginecommon${DS}epoc${DS}inc${DS}PVCommonEpoc.h ${VIEW}${DS}sdk${DS}player${DS}engine${DS}base${DS}inc${DS}PVPlayerCommonBase.h ${VIEW}${DS}sdk${DS}player${DS}engine${DS}epoc${DS}inc${DS}PVPlayerCommonEpoc.h ${VIEW}${DS}sdk${DS}player${DS}engine${DS}epoc${DS}inc${DS}PVPlayerInterface.h";
+		} else {
+			print STDERR "Invalid Document Type:  $buildtype\n";
+			usage();
+		}
+	} else {
+		$PROJ_NAME = $buildtype;
+	}
+
+	if ( $DOC_TYPE eq "" ) {
+		$DOC_TYPE="${PROJ_NAME} API Documentation";
+	}
+
+	# Cleanup previous build
+	print STDOUT "\n>>>>> Building $DOC_TYPE\n";
+
+	@dir_list = split / /, $INPUTDIR;
+	chomp @dir_list;
+
+	$status = `${RMDIR} $DOCDIR >> $LOGFILE 2>&1`;
+	$status = `${MKDIR} $DOCDIR`;
+	$status = `${RMDIR} $STAGEDIR >> $LOGFILE 2>&1`;
+	$status = `${MKDIR} $STAGEDIR`;
+	if ($ENV{'OS'} !~ /Windows/) {
+		$status = `chmod 777 $DOCDIR`;
+		$status = `chmod 777 $STAGEDIR`;
+	}
+	chdir("${STAGEDIR}");
+
+	$INPUTDIR = "";
+	foreach $dir (@dir_list) {
+		if ( ! -e $dir ) {
+			$dir = ConvertFilename($dir);
+			if ( -e $dir ) {
+				# dir just needed converting
+			} elsif ( -e "${VIEW}${dir}" ) {
+				$dir = "$VIEW$dir";
+			} elsif ( -e "${VIEW}${DS}${dir}" ) {
+				$dir = "$VIEW${DS}$dir";
+			} else {
+				# If file is still not found, print error.
+				print "\n\nERROR: Unable to locate document input directory:\n${dir}\n\n";
+				exit();
+			}
+		}
+		$INPUTDIR = "$INPUTDIR $dir";
+	}
+
+	# Update footer.html and header.tex
+	if ( $AddCopyright ) {
+		$status = `${COPY} ${CC_DIR}header_with_copyright.tex ${STAGEDIR}${DS}header.tex`;
+	} else {
+		$status = `${COPY} ${CC_DIR}header.tex ${STAGEDIR}`;
+	}
+	$status = `${COPY} ${CC_DIR}footer.html ${STAGEDIR}`;
+	$status = `${COPY} ${CC_DIR}doxygen.sty ${STAGEDIR}`;
+	$status = `${COPY} ${CC_DIR}$CFGFILE ${STAGEDIR}`;
+
+        ReplaceString ("${STAGEDIR}${DS}footer.html", '%%LABEL%%', '%%LABEL%%', ${BUILDNUM});
+        ReplaceString ("${STAGEDIR}${DS}footer.html", '%%DOCTYPE%%', '%%DOCTYPE%%', "${DOC_TYPE}");
+
+        ReplaceString ("${STAGEDIR}${DS}header.tex", '%%LABEL%%', '%%LABEL%%', "${LBUILDNUM}");
+        ReplaceString ("${STAGEDIR}${DS}header.tex", '%%DOCTYPE%%', '%%DOCTYPE%%', "${DOC_TYPE}");
+        ReplaceString ("${STAGEDIR}${DS}header.tex", '%%DATE%%', '%%DATE%%', "${DATE_STR}");
+
+        ReplaceString (-all, "${STAGEDIR}${DS}doxygen.sty", '%%DOCTYPE%%', '%%DOCTYPE%%', "${DOC_TYPE}");
+
+        ReplaceString ("${STAGEDIR}${DS}${CFGFILE}", '%%PROJECT%%', '%%PROJECT%%', "\"${PROJ_NAME}\"");
+        ReplaceString ("${STAGEDIR}${DS}${CFGFILE}", '%%INPUT%%', '%%INPUT%%', "${INPUTDIR}");
+        ReplaceString ("${STAGEDIR}${DS}${CFGFILE}", '%%OUTPUT%%', '%%OUTPUT%%', "${DOCDIR}");
+
+	if ( $FILETYPE eq "" ) {
+		ReplaceString ("${STAGEDIR}${DS}$CFGFILE", '%%FILETYPE%%', '%%FILETYPE%%', "*.h");
+	} else {
+		ReplaceString ("${STAGEDIR}${DS}$CFGFILE", '%%FILETYPE%%', '%%FILETYPE%%', "$FILETYPE");
+	}
+
+	if ( $EXCLUDE eq "" ) {
+		ReplaceString ("${STAGEDIR}${DS}$CFGFILE", '%%EXCLUDE%%', '%%EXCLUDE%%', "");
+	} else {
+		ReplaceString ("${STAGEDIR}${DS}$CFGFILE", '%%EXCLUDE%%', '%%EXCLUDE%%', "$EXCLUDE");
+	}
+
+	if ( $EXCLUDE_PATTERN eq "" ) {
+		ReplaceString ("${STAGEDIR}${DS}$CFGFILE", '%%EXCLUDE_PATTERN%%', '%%EXCLUDE_PATTERN%%', "");
+	} else {
+		ReplaceString ("${STAGEDIR}${DS}$CFGFILE", '%%EXCLUDE_PATTERN%%', '%%EXCLUDE_PATTERN%%', "$EXCLUDE_PATTERN");
+	}
+
+        if ( $level_string eq ALL ) {
+        	ReplaceString ("${STAGEDIR}${DS}${CFGFILE}", '%%SECTIONS%%', '%%SECTIONS%%', "DEBUG RELEASE ALL");
+        } else {
+        	ReplaceString ("${STAGEDIR}${DS}${CFGFILE}", '%%SECTIONS%%', '%%SECTIONS%%', "$level_string");
+        }
+
+	# Build Docs
+	if ( -e $DOXYGEN ) {
+		$status = `$DOXYGEN $CFGFILE >> $LOGFILE 2>&1`;
+		if ($?) {
+			print STDERR "Doxygen command failed.  See $LOGFILE for more info.\n";
+			exit(-1);
+		}
+	} else {
+		print STDERR "\nERROR:  Unable to locate doxygen tool: \n";
+		print STDERR "$DOXYGEN\n";
+		exit(-1);
+	}
+
+	# Update doxygen.sty
+	$status = `${COPY} ${STAGEDIR}${DS}doxygen.sty ${DOCDIR}${DS}latex`;
+	$status = `${COPY} ${CC_DIR}copyright.jpg ${DOCDIR}${DS}latex`;
+	$status = `${COPY} ${CC_DIR}pvlogo.jpg ${DOCDIR}${DS}latex`;
+	$status = `${COPY} ${CC_DIR}pvlogo_small.jpg ${DOCDIR}${DS}latex`;
+	$status = `${COPY} ${CC_DIR}pvlogo_small.jpg ${DOCDIR}${DS}html`;
+
+	InstallGraphics();
+
+	print "     >>>>> Creating PDF\n";
+	chdir("${DOCDIR}${DS}latex");
+
+	if ($ENV{'OS'} =~ /Windows/) {
+		# Check if Latex is installed locally.
+		# If it is, use that version.
+		# If not, transfer files to PdfConvHost
+		if ( -e "${MIKTEX_PATH}\\pdflatex.exe" ) {
+			# Setup Path so we find latex files
+			$ENV{"PATH"} = "${MIKTEX_PATH};${OldPath}";	
+			$status = `clearmake >> $LOGFILE 2>&1`;
+		} else {
+			BuildPDF();
+		}
+	} else {
+		if ( ( -e "/usr/bin/latex" ) && ( -e "/usr/bin/gs" ) ) {
+			$status = `clearmake >> $LOGFILE 2>&1`;
+		} else {
+			BuildPDF();
+		}
+	}
+
+	# Check that pdf file now exists.
+	if ( ! -s "${DOCDIR}${DS}latex${DS}refman.pdf" ) {
+		print STDERR "clearmake command failed.  See $LOGFILE for more info.\n";
+		exit(-1);
+	} else {
+		$status = `${COPY} ${DOCDIR}${DS}latex${DS}refman.pdf ${DOCDIR}${DS}latex${DS}${buildtype}_api.pdf`; 
+		$status = `${COPY} ${DOCDIR}${DS}latex${DS}refman.pdf ${DOCDIR}${DS}${buildtype}_api.pdf`; 
+	}
+
+
+}
+
+sub PostWebsite {
+
+	my $buildtype=$_[0];
+
+	if ( -d "/opt/pvserver/web/webapps" ) {
+		# Post on web page
+		if ( ! -d "/opt/pvserver/web/webapps/docs/${buildtype}" ) {
+			$status = `${MKDIR} /opt/pvserver/web/webapps/docs/${buildtype}`;
+			if ($ENV{'OS'} !~ /Windows/) {
+				$status = `chmod 777 /opt/pvserver/web/webapps/docs/${buildtype}`;
+			}
+		}
+	
+		$status = `${COPY} ${DOCDIR}${DS}latex${DS}${buildtype}_api.pdf /opt/pvserver/web/webapps/docs/${buildtype}/${buildtype}_api.pdf`;
+	
+		chdir("${DOCDIR}${DS}html");
+		$status = `${COPY} * /opt/pvserver/web/webapps/docs/${buildtype}`;
+	} else {
+		print "\n\nThis box does not appear to be setup as a web server.\n";
+		print "Documents will not be posted.\n";
+		print "Documents are located in ${DOCDIR}\n";
+		$PostDocs = 0;
+	}
+}
+
+sub UpdateIndex {
+
+	# Update front page
+	$status = `${COPY} ${CC_DIR}index.html $INDEXFILE`;
+        ReplaceString ("${INDEXFILE}", '%%DATE%%', '%%DATE%%', ${DATE_STR});
+}
+
+sub Cleanup {
+
+	if ($PostDocs) {
+		chdir("${CurrDir}");
+		$status = `${RMDIR} $BUILDDIR >> $LOGFILE 2>&1`;
+		$status = `${RMDIR} $STAGEDIR >> $LOGFILE 2>&1`;
+	}
+}
+
+#####################################################
+#
+#     Environmental Variables
+#
+#####################################################
+$doctype_list_string=undef;
+@doc_list = ();
+$level_string=undef;
+$PostDocs = 0;
+$help = undef;
+
+GetOptions('doctype=s'=>\$doctype_list_string, 'title=s'=>\$DOC_TYPE, 'view=s'=>\$VIEW, 'path=s'=>\$INPUTDIR, 'word=s'=>\$WORDLIST, 'filetype=s'=>\$FILETYPE, 'exclude=s'=>\$EXCLUDE, 'exclude_pattern=s'=>\$EXCLUDE_PATTERN, 'level=s'=>\$level_string, 'version=s'=>\$InputVersion, 'post'=>\$PostDocs, 'copyright'=>\$AddCopyright, 'help'=>\$help);
+
+print STDOUT "\n";
+
+if ($help) {
+    usage();
+}
+
+print STDOUT "Building PacketVideo Documentation\n";
+
+if (defined($WORDLIST)) {
+	SetEnv();
+
+	@word_list = split / /, $WORDLIST;
+	chomp @word_list;
+
+	foreach $doc (@word_list) {
+		$doc = ConvertFilename($doc);
+		ConvertWordToPDF($doc);
+	}
+
+	exit(0);
+
+} else {
+	SetEnv();
+	SetCCEnv();
+	if (!defined($doctype_list_string)) {
+		if (defined($INPUTDIR)) {
+			print "\nPath to documents was specified without a document type.\n";
+			print "Please specify document type to use: ";
+			$doctype_list_string = <STDIN>;
+			chomp ($doctype_list_string);
+		} else {
+			$doctype_list_string="symbian";
+		}
+	}
+
+	@doc_list = split /,/, $doctype_list_string;
+	chomp @doc_list;
+
+	if (!defined($level_string)) {
+		$level_string="DEBUG RELEASE ALL";
+	}
+
+	foreach $buildtype (@doc_list) {
+	
+		$buildtype = trim($buildtype);
+		BuildDocs ($buildtype);
+	
+		if ($PostDocs) {
+			PostWebsite ($buildtype);
+			Cleanup();
+		} else {
+			print ">>>>> Documents are located in ${DOCDIR}\n";
+		}
+	}
+}
+
+if ($PostDocs) {
+	print "\n>>>>> Documents have been posted.\n\n";
+	UpdateIndex();
+	Cleanup();
+}
+
+exit(0);
+
+$ENV{"PATH"} = $OldPath;
+
+__END__
+
+  :endofperl
+SET SCRIPT=%0
+SET ARG_ONE=%1
+SET ARG_TWO=%2
+SET ARG_THREE=%3
+SET ARG_FOUR=%4
+SET ARG_FIVE=%5
+SET ARG_SIX=%6
+SET ARG_SEVEN=%7
+SET ARG_EIGHT=%8
+SET ARG_NINE=%9
+SHIFT
+SHIFT
+SHIFT
+SHIFT
+SHIFT
+SHIFT
+SHIFT
+SHIFT
+SHIFT
+SET ARG_TEN=%1
+SET ARG_ELEVEN=%2
+SET ARG_TWELVE=%3
+SET ARG_THIRTEEN=%4
+SET ARG_FOURTEEN=%5
+SET ARG_FIFTEEN=%6
+SET ARG_SIXTEEN=%7
+SET ARG_SEVENTEEN=%8
+SET ARG_EIGHTEEN=%9
+  ccperl -e "$s = shift; $c = $s =~ /.bat$/ ? $s : $s.'.bat'; $p = (-x $c) ? '' : '-S '; system('ccperl '.$p.$c.' '.join(' ',@ARGV)); exit $?;" %SCRIPT% %ARG_ONE% %ARG_TWO% %ARG_THREE% %ARG_FOUR% %ARG_FIVE% %ARG_SIX% %ARG_SEVEN% %ARG_EIGHT% %ARG_NINE% %ARG_TEN% %ARG_ELEVEN% %ARG_TWELVE% %ARG_THIRTEEN% %ARG_FOURTEEN% %ARG_FIFTEEN% %ARG_SIXTEEN% %ARG_SEVENTEEN% %ARG_EIGHTEEN%
+
diff --git a/tools_v2/build/make/global.mk b/tools_v2/build/make/global.mk
deleted file mode 100644
index db7c09f..0000000
--- a/tools_v2/build/make/global.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-# 
-# This makefile template is included by all other rules files.  It
-# defines the default target of all, the global clean rule, and
-# takes care of defining other global parameters for all makes.
-#
-
-#
-# Get the local configuration
-#
-include $(MK)/local.mk
-
-#
-# Process the src list
-#
-include $(MK)/srclist.mk
-
-#
-# If BUILD_ARCH has anything in it, include the file for that architecture
-#
-ifneq ($(strip $(BUILD_ARCH)),)
-  -include $(MK)/$(BUILD_ARCH).mk
-endif
-
-#
-# If a target name hasn't been defined, assume it's tge same as
-# the current directory.
-#
-ifndef TARGET
-TARGET=$(notdir $(shell $(MK)/../bin/cc_pwd))
-endif
-
-#
-# The default rule
-#
-default: all
-
-#
-# Alternate rules for when things are not otherwise defined
-#
-stage::
-
-print_dirs::
-	@$(MK)/../bin/cc_pwd
-
-
-show-doc::
-	@$(SHOW_DOC) $(GNU_MAKE_TEMPLATE)
diff --git a/tools_v2/build/make/gnumake.template b/tools_v2/build/make/gnumake.template
deleted file mode 100644
index 05613c9..0000000
--- a/tools_v2/build/make/gnumake.template
+++ /dev/null
@@ -1,82 +0,0 @@
-
-HOST_ARCH := $(shell $(MK)/../bin/archtype)
-
-ifndef ARCHITECTURE
- ifdef ARCH
-   ARCHITECTURE = $(ARCH)
- else
-   ARCHITECTURE := $(HOST_ARCH)
- endif
-endif
-
-TEMPLATE_WANTED := $(MK)/$(ARCHITECTURE)_$(TOOLSET)_$(WHAT).mak
-TEMPLATE_FOUND := $(wildcard $(TEMPLATE_WANTED))
-
-PACKAGES_WANTED := $(PACKAGES:%=$(MK)/%.pkg)
-PACKAGES_FOUND := $(wildcard $(PACKAGES_WANTED))
-PACKAGES_MISSING := $(filter-out $(PACKAGES_FOUND),$(PACKAGES_WANTED))
-
-ALL_WANTED := $(TEMPLATE_WANTED) $(PACKAGES_WANTED)
-ALL_FOUND := $(TEMPLATE_FOUND) $(PACKAGES_FOUND)
-
-#
-# If everything we need to include was found, we're in great shape.
-#
-ifeq ($(ALL_WANTED),$(ALL_FOUND))
-
-include $(PACKAGES_FOUND) $(TEMPLATE_FOUND)
-
-#
-# Otherwise, try to figure out what's wrong
-#
-else
-
-default: show-it
-
-
-something-went-wrong::
-	@echo Something's afoul
-
-ERRS=err-intro
-
-err-intro::
-	@echo "I can't figure out how to build your target because..." 2>&1
-
-no-arch::
-	@echo " -- There are no templates for the \`$(ARCHITECTURE)'" \
-		"architecture" 2>&1
-
-no-toolset::
-	@echo " -- There are no templates for the \`$(TOOLSET)' toolset" 2>&1
-
-no-what::
-	@echo " -- I don't know what a \`$(WHAT)' is" 2>&1
-
-no-packages::
-	@echo " -- I can't find support for the following packages:"
-	@echo "      " $(PACKAGES_MISSING:$(MK)/%.pkg=%)
-
-
-ifeq ($(wildcard $(MK)/$(ARCHITECTURE)_*_*.mak),)
- ERRS+=no-arch
-else
- ifeq ($(wildcard $(MK)/$(ARCHITECTURE)_$(TOOLSET)_*.mak),)
-  ERRS+=no-toolset
- else
-  ifeq ($(wildcard $(MK)/$(ARCHITECTURE)_$(TOOLSET)_$(WHAT).mak),)
-   ERRS+=no-what
-  endif
- endif
-endif
-
-
-
-ifneq ($(PACKAGES_MISSING),)
-ERRS+=no-packages
-endif
-
-show-it: $(ERRS)
-
-#.DEFAULT: $(ERRS)
-
-endif
diff --git a/tools_v2/build/make/library.mk b/tools_v2/build/make/library.mk
deleted file mode 100644
index 1806ae7..0000000
--- a/tools_v2/build/make/library.mk
+++ /dev/null
@@ -1,462 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories.  The including makefile may define the
-# HDRS variable to a list of header files to get installed.
-# See also the rules.mk file for descriptions of meanings of
-# other variables.
-#
-
-
-# If we have headers, we should install those, too. 
-# The only exception is if the NOHDRINST macro is defined.
-# The NOHDRINST macro is used to bypass the headers-install
-# build step.  It is useful for situations where all the header
-# files are already visible within the compiler search path.
-# ONLY DEFINE THE MACRO IF YOU KNOW WHAT YOU'RE DOING
-ifndef NOHDRINST
-  ifneq ($(HDRS),)
-    ifneq ($(INCDESTDIR),)
-      TARGETS_TO_INSTALL+=headers
-    endif
-  endif
-endif
-
-ifneq ($(INCSRCDIR),)
-   headers_srcdir=$(INCSRCDIR)
-else
-   headers_srcdir=.
-endif
-headers_destdir=$(INCDESTDIR)
-headers_files=$(HDRS)
-headers_ifunction=_header_install_
-
-define _header_install_
-	$(INSTALL) -c -m 444 WHAT_TO_INSTALL $(headers_destdir)
-endef
-
-
-# if TARGET is empty then just do the headers install
-ifeq ($(strip $(TARGET)),)
-
-include $(MK)/rules.mk
-
-library-install:
-
-cm-release:
-
-.PHONY:: cm-release library-install
-else
-
-# if DBG_SUFFIX not set then set to _debug
-ifeq ($(strip $(DBG_SUFFIX)),)
-  DBG_SUFFIX = _debug
-endif
-
-ifeq ($(RELEASE),1)
-  # if LIBTARGET not set then set to 
-  ifeq ($(strip $(LIBTARGET)),)
-    LIBTARGET = $(STAT_REL_LIB)
-  endif
-else 
-  ifeq ($(strip $(LIBTARGET)),)
-    LIBTARGET = $(STAT_DBG_LIB)
-  endif
-endif
-
-ifneq ($(word 2,$(strip $(LIBTARGET))),)
-
-# there is more than one target listed in libtarget so 
-# go through them one-by-one
-
-#echo "running make with target $(target)"; echo ""
-#$(shell $(MAKE) LIBTARGET=$(target))
-define single_target_make
-$(shell echo "$(target)")
-endef
-
-default:
-	@export MAKEFLAGS
-	$(MK)/../bin/make_list	$(MAKE) $@ LIBTARGET $(LIBTARGET)
-
-%: 
-	@export MAKEFLAGS
-	$(MK)/../bin/make_list $(MAKE) $@ LIBTARGET $(LIBTARGET)
-
-
-else
-
-
-ifneq ($(strip $(MAJOR_VERSION)),)
-  SONAME_EXT = .$(MAJOR_VERSION)
-  ifneq ($(strip $(MINOR_VERSION)),)
-      SHAR_LIB_EXT = .$(MAJOR_VERSION).$(MINOR_VERSION)
-  else
-      SHAR_LIB_EXT = .$(MAJOR_VERSION)
-  endif
-else
-  SHAR_LIB_EXT = 
-endif
-
-MY_TARGET = $(strip $(TARGET))
-
-STAT_REL_OBJDIR = $(BUILD_ARCH)/static_rel
-STAT_DBG_OBJDIR = $(BUILD_ARCH)/static_dbg
-SHAR_REL_OBJDIR = $(BUILD_ARCH)/shared_rel
-SHAR_DBG_OBJDIR = $(BUILD_ARCH)/shared_dbg
-MODL_REL_OBJDIR = $(BUILD_ARCH)/module_rel
-MODL_DBG_OBJDIR = $(BUILD_ARCH)/module_dbg
-
-OBJDIRS = $(STAT_REL_OBJDIR) $(STAT_DBG_OBJDIR) $(SHAR_REL_OBJDIR) $(SHAR_DBG_OBJDIR) $(MODL_REL_OBJDIR) $(MODL_DBG_OBJDIR)
-
-ifeq ($(BUILD_ARCH),win32)
-  STAT_REL_LIB = $(MY_TARGET:%=$(STAT_REL_OBJDIR)/%.$(STAT_LIB_EXT))
-  STAT_DBG_LIB = $(MY_TARGET:%=$(STAT_DBG_OBJDIR)/%$(DBG_SUFFIX).$(STAT_LIB_EXT))
-  SHAR_REL_LIB = $(MY_TARGET:%=$(SHAR_REL_OBJDIR)/%.so$(SHAR_LIB_EXT))
-  SHAR_DBG_LIB = $(MY_TARGET:%=$(SHAR_DBG_OBJDIR)/%$(DBG_SUFFIX).so$(SHAR_LIB_EXT))
-else
-  STAT_REL_LIB = $(MY_TARGET:%=$(STAT_REL_OBJDIR)/lib%.$(STAT_LIB_EXT))
-  STAT_DBG_LIB = $(MY_TARGET:%=$(STAT_DBG_OBJDIR)/lib%$(DBG_SUFFIX).$(STAT_LIB_EXT))
-  SHAR_REL_LIB = $(MY_TARGET:%=$(SHAR_REL_OBJDIR)/lib%.so$(SHAR_LIB_EXT))
-  SHAR_DBG_LIB = $(MY_TARGET:%=$(SHAR_DBG_OBJDIR)/lib%$(DBG_SUFFIX).so$(SHAR_LIB_EXT))
-  MODL_REL_LIB = $(MY_TARGET:%=$(MODL_REL_OBJDIR)/lib%_mod.$(STAT_LIB_EXT))
-  MODL_DBG_LIB = $(MY_TARGET:%=$(MODL_DBG_OBJDIR)/lib%_mod$(DBG_SUFFIX).$(STAT_LIB_EXT))
-endif
-
-STAT_REL_OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(STAT_REL_OBJDIR)/%.$(STAT_OBJS_EXT))
-STAT_REL_DEPS = $(STAT_REL_OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-
-STAT_DBG_OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(STAT_DBG_OBJDIR)/%.$(STAT_OBJS_EXT))
-STAT_DBG_DEPS = $(STAT_DBG_OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-
-SHAR_REL_OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(SHAR_REL_OBJDIR)/%.$(STAT_OBJS_EXT))
-SHAR_REL_DEPS = $(SHAR_REL_OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-
-SHAR_DBG_OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(SHAR_DBG_OBJDIR)/%.$(STAT_OBJS_EXT))
-SHAR_DBG_DEPS = $(SHAR_DBG_OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-MODL_REL_OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(MODL_REL_OBJDIR)/%.$(STAT_OBJS_EXT))
-MODL_REL_DEPS = $(MODL_REL_OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-MODL_DBG_OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(MODL_DBG_OBJDIR)/%.$(STAT_OBJS_EXT))
-MODL_DBG_DEPS = $(MODL_DBG_OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-ifeq ($(LIBTARGET),static-dbg)
-  override LIBTARGET = $(STAT_DBG_LIB)
-endif
-
-ifeq ($(LIBTARGET),static-rel)
-  override LIBTARGET = $(STAT_REL_LIB)
-endif
-
-ifeq ($(LIBTARGET),shared-dbg)
-  override LIBTARGET = $(SHAR_DBG_LIB)
-endif
-
-ifeq ($(LIBTARGET),shared-rel)
-  override LIBTARGET = $(SHAR_REL_LIB)
-endif
-
-ifeq ($(LIBTARGET),module-dbg)
-  override LIBTARGET = $(MODL_DBG_LIB)
-endif
-
-ifeq ($(LIBTARGET),module-rel)
-  override LIBTARGET = $(MODL_REL_LIB)
-endif
-
-ifeq ($(LIBTARGET),$(STAT_REL_LIB))
-  COMPILED_TARGETS = $(STAT_REL_LIB)
-  DEPS = $(STAT_REL_DEPS)
-  TARGETS_TO_INSTALL+=static
-  CLEAN+=$(STAT_REL_OBJS) $(STAT_REL_DEPS)
-
-  library-install: static-install
-
-.PHONY:: library-install
-endif
-
-
-ifeq ($(LIBTARGET),$(STAT_DBG_LIB))
-  COMPILED_TARGETS = $(STAT_DBG_LIB)
-  DEPS = $(STAT_DBG_DEPS)
-  TARGETS_TO_INSTALL+=static
-  CLEAN+=$(STAT_DBG_OBJS) $(STAT_DBG_DEPS)
-
-  library-install: static-install
-
-.PHONY:: library-install
-endif
-
-
-ifeq ($(LIBTARGET),$(SHAR_REL_LIB))
-  COMPILED_TARGETS = $(SHAR_REL_LIB)
-  DEPS = $(SHAR_REL_DEPS)
-  XCFLAGS += $(SHARED_CFLAGS)
-  XCXXFLAGS += $(SHARED_CXXFLAGS)
-  XLDFLAGS += $(SHARED_LDFLAGS)
-  LIBNAME_NO_VERSION = $(MY_TARGET:%=lib%.so)
-  TARGETS_TO_INSTALL+=shared
-  ifeq ($(strip $(SONAME)),)
-    SONAME = $(MY_TARGET:%=lib%.so$(SONAME_EXT))
-  endif
-  CLEAN+=$(SHAR_REL_OBJS) $(SHAR_REL_DEPS)
-
-  library-install: shared-install
-
-.PHONY:: library-install
-endif
-
-ifeq ($(LIBTARGET),$(SHAR_DBG_LIB))
-  COMPILED_TARGETS = $(SHAR_DBG_LIB)
-  DEPS = $(SHAR_DBG_DEPS)
-  XCFLAGS += $(SHARED_CFLAGS)
-  XCXXFLAGS += $(SHARED_CXXFLAGS)
-  XLDFLAGS += $(SHARED_LDFLAGS)
-  LIBNAME_NO_VERSION = $(MY_TARGET:%=lib%$(DBG_SUFFIX).so)
-  TARGETS_TO_INSTALL+=shared
-  ifeq ($(strip $(SONAME)),)
-    SONAME = $(MY_TARGET:%=lib%$(DBG_SUFFIX).so$(SONAME_EXT))
-  endif
-  CLEAN+=$(SHAR_DBG_OBJS) $(SHAR_DBG_DEPS)
-
-  library-install: shared-install
-
-.PHONY:: library-install
-endif
-
-ifeq ($(LIBTARGET),$(MODL_REL_LIB))
-  COMPILED_TARGETS = $(MODL_REL_LIB)
-  DEPS = $(MODL_REL_DEPS)
-  XCFLAGS += $(SHARED_CFLAGS)
-  XCXXFLAGS += $(SHARED_CXXFLAGS)
-  XLDFLAGS += $(SHARED_LDFLAGS)
-  CLEAN+=$(MODL_REL_OBJS) $(MODL_REL_DEPS)
-
-  library-install: module-install
-
-.PHONY:: library-install
-endif
-
-ifeq ($(LIBTARGET),$(MODL_DBG_LIB))
-  COMPILED_TARGETS = $(MODL_DBG_LIB)
-  DEPS = $(MODL_DBG_DEPS)
-  XCFLAGS += $(SHARED_CFLAGS)
-  XCXXFLAGS += $(SHARED_CXXFLAGS)
-  XLDFLAGS += $(SHARED_LDFLAGS)
-  CLEAN+=$(MODL_DBG_OBJS) $(MODL_DBG_DEPS)
-
-  library-install: module-install
-
-.PHONY:: library-install
-endif
-
-
-REALTARGET = $(LIBTARGET)
-
-
-
-
-static_srcdir=$(patsubst %/,%,$(dir $(LIBTARGET)))
-static_destdir=$(DESTDIR)
-static_files=$(notdir $(LIBTARGET))
-static_ifunction=_static_install_
-
-ifneq ($(RANLIB),)
-  RANDOMLIB=$(RANLIB) $(static_destdir)/$(static_files)
-endif
-
-
-define _static_install_
-	$(INSTALL) -c -m 664 WHAT_TO_INSTALL $(static_destdir)
-	$(RANDOMLIB)
-endef
-
-shared_srcdir=$(patsubst %/,%,$(dir $(LIBTARGET)))
-shared_destdir=$(DESTDIR)
-shared_files=$(notdir $(LIBTARGET))
-shared_ifunction=_shared_install_
-
-define _shared_install_
-	$(INSTALL) -c -m 775 WHAT_TO_INSTALL $(shared_destdir)
-        @if [ $(notdir $(LIBTARGET)) != $(LIBNAME_NO_VERSION) ] ; then cd $(shared_destdir) ; rm -f $(LIBNAME_NO_VERSION) ; ln -sf $(notdir $(LIBTARGET)) $(LIBNAME_NO_VERSION); fi
-    
-endef
-
-module_srcdir=$(patsubst %/,%,$(dir $(LIBTARGET)))
-module_destdir=$(DESTDIR)
-module_files=$(notdir $(LIBTARGET))
-module_ifunction=_module_install_
-
-define _module_install_
-	$(INSTALL) -c -m 775 WHAT_TO_INSTALL $(module_destdir)
-endef
-
-include $(MK)/rules.mk
-
-
-define build_shared
-	-$(RM) $@
-	$(SHARED_LINK) $(SONAME_ARG) -o $@  $(filter-out -l%,$(LDFLAGS)) \
-		$^ $(filter -l%,$(LDFLAGS)) $(POST_LDFLAGS)
-	-chmod g+w $@
-endef
-
-
-
-# If $(BUILD_LIBRARY) isn't defined, use GNUmake's special archive
-# dependencies to build individual members as needed.  Otherwise,
-# make the finished library depend explicitly on the objects and
-# use $(BUILD_LIBRARY) to build it.
-
-
-static-rel: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(STAT_REL_LIB) RELEASE=1
-
-static-dbg: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(STAT_DBG_LIB) 
-
-shared-dbg: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(SHAR_DBG_LIB) 
-
-shared-rel: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(SHAR_REL_LIB) RELEASE=1
-
-module-dbg: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(MODL_DBG_LIB) 
-
-module-rel: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(MODL_REL_LIB) RELEASE=1
-
-install-static-rel: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(STAT_REL_LIB) RELEASE=1 install
-
-install-static-dbg: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(STAT_DBG_LIB) install
-
-install-shared-dbg: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(SHAR_DBG_LIB) install
-
-install-shared-rel: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(SHAR_REL_LIB) RELEASE=1 install
-
-install-module-dbg: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(MODL_DBG_LIB) install
-
-install-module-rel: 
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(MODL_REL_LIB) RELEASE=1 install
-
-
-all-libs:
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(STAT_REL_LIB)
-	$(MAKE) LIBTARGET=$(STAT_DBG_LIB)
-	$(MAKE) LIBTARGET=$(SHAR_REL_LIB)
-	$(MAKE) LIBTARGET=$(SHAR_DBG_LIB)
-	$(MAKE) LIBTARGET=$(MODL_REL_LIB)
-	$(MAKE) LIBTARGET=$(MODL_DBG_LIB)
-
-install-all:
-	@export MAKEFLAGS
-	$(MAKE) LIBTARGET=$(STAT_REL_LIB) install
-	$(MAKE) LIBTARGET=$(STAT_DBG_LIB) install
-	$(MAKE) LIBTARGET=$(SHAR_REL_LIB) install
-	$(MAKE) LIBTARGET=$(SHAR_DBG_LIB) install
-	$(MAKE) LIBTARGET=$(MODL_REL_LIB) install
-	$(MAKE) LIBTARGET=$(MODL_DBG_LIB) install
-
-ifeq ($(BUILD_LIBRARY),)
-
-$(STAT_REL_LIB): $(STAT_REL_OBJS:%=$(STAT_REL_LIB)(%))
-
-$(STAT_DBG_LIB): $(STAT_DBG_OBJS:%=$(STAT_DBG_LIB)(%))
-
-print-lobjs:
-	@echo $(SHAR_DBG_OBJS)	
-	@echo $(STAT_DBG_OBJS)	
-
-.PHONY:: print-lobjs
-
-else
-
-.PRECIOUS:: $(STAT_REL_OBJS) $(STAT_DBG_OBJS)
-
-$(STAT_REL_LIB):: $(STAT_REL_OBJS)
-	-$(RM) $@
-	$(BUILD_LIBRARY)
-
-$(STAT_DBG_LIB):: $(STAT_DBG_OBJS)
-	-$(RM) $@
-	$(BUILD_LIBRARY)
-
-print-lobjs:
-	@echo $(STAT_DBG_OBJS)	
-
-.PHONY:: print-lobjs
-
-endif
-
-$(SHAR_REL_LIB):: $(SHAR_REL_OBJS)
-	$(build_shared)
-
-$(SHAR_DBG_LIB):: $(SHAR_DBG_OBJS)
-	$(build_shared)
-
-
-$(MODL_REL_LIB): $(MODL_REL_OBJS:%=$(MODL_REL_LIB)(%))
-
-$(MODL_DBG_LIB): $(MODL_DBG_OBJS:%=$(MODL_DBG_LIB)(%))
-
-# Rules for checking in files to the configuration 
-# management/source control system
-ifeq ($(strip $(CM_DESTDIR)),)
- TMP_CM_DIRS = $(shell $(FIND_DIR) 0 sdk_lib $(TOP))
- TMP_CM_DIRS += $(shell $(FIND_DIR) 0 SDK_lib $(TOP))
-CM_DESTDIR = $(firstword $(TMP_CM_DIRS))/$(BUILD_ARCH)
-endif
-
-
-ifeq ($(strip $(CM_DESTDIR)),)
-cm-release:
-	@echo "ERROR -- Must define CM_DESTDIR to location where target should be checked-in"
-	/bin/false;
-
-.PHONY:: cm-release
-else
-
-ifeq ($(strip $(CM_LABEL)),)
-cm-release:
-	@error "Must define CM_LABEL to the label name that will be applied to the target"
-	/bin/false
-
-.PHONY:: cm-release
-
-else 
-
-cm-release: $(LIBTARGET)
-	#@echo "Running cm-release on target $(LIBTARGET), dest = $(CM_DESTDIR)/$(BUILD_ARCH), label = $(CM_LABEL) "
-	$(MK)/../bin/newcob.pl --label $(CM_LABEL) $(CM_BRANCH) $(REALTARGET) $(CM_DESTDIR)
-
-.PHONY:: cm-release
-endif #CM_LABEL is NULL
-
-endif #CM_DESTDIR is NULL
-
-
-
-endif
-endif
diff --git a/tools_v2/build/make/linux.mk b/tools_v2/build/make/linux.mk
deleted file mode 100644
index 4b1c37d..0000000
--- a/tools_v2/build/make/linux.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# This file contains the architecture specific 
-# definitions for linux intel platform.
-#
-
-AR_ARGS = rvl
-AR = ar
-
-CC = gcc
-CXX = g++
-CO = -c -o # make sure to leave a space at the end
-
-export RANLIB = ranlib
diff --git a/tools_v2/build/make/linux_g++_library.mak b/tools_v2/build/make/linux_g++_library.mak
deleted file mode 100644
index ca12b6d..0000000
--- a/tools_v2/build/make/linux_g++_library.mak
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories which use the g++ compiler.
-# See the file linux_library.mk for more details.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CXX = g++
-
-SHARED_LINK = g++
-SHARED_CFLAGS = -fPIC
-SHARED_CXXFLAGS = -fPIC
-SHARED_LDFLAGS = -shared
-
-SONAME_ARG = -Wl,-h,$(SONAME)
-
-#Make all warnings into errors.
-#FLAG_COMPILE_WARNINGS_AS_ERRORS = -Werror
-
-include $(MK)/linux_library.mk
diff --git a/tools_v2/build/make/linux_g++_module.mak b/tools_v2/build/make/linux_g++_module.mak
deleted file mode 100644
index d23f3ff..0000000
--- a/tools_v2/build/make/linux_g++_module.mak
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# This makefile template should be included by makefiles to
-# build modules and uses the g++ compiler.
-# See the file module.mk for more details.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CXX = g++
-
-SHARED_LINK = g++
-SHARED_LDFLAGS = -shared -Wl,-Bsymbolic --no-undefined -Wl,--whole-archive
-SONAME_ARG = -Wl-soname,$(SONAME) 
-POST_SHARED_LDFLAGS = -Wl,--no-whole-archive
-
-include $(MK)/module.mk
diff --git a/tools_v2/build/make/linux_g++_prog.mak b/tools_v2/build/make/linux_g++_prog.mak
deleted file mode 100644
index 5990a04..0000000
--- a/tools_v2/build/make/linux_g++_prog.mak
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# This makefile template is used for programs whose main routine is
-# defined in C++ code.  See prog.mk for more information.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-REALTARGET = $(BUILD_ARCH)/$(TARGET)
-
-STAT_LIB_EXT = a
-STAT_OBJS_EXT = o
-
-CLEAN+=$(REALTARGET) $(OBJS)
-
-
-include $(MK)/prog.mk
-
-
-
-#
-# Build the actual target using the C++ compiler.  This rule uses
-# gnu make's extension for supporting library dependencies with the
-# -llib syntax.
-#
-
-STATIC_BINDING = -Bstatic
-
-$(REALTARGET):: $(OBJS) $(ALL_LIBS)
-	$(build_target:_LINK_=$(CXX))
diff --git a/tools_v2/build/make/linux_gcc_library.mak b/tools_v2/build/make/linux_gcc_library.mak
deleted file mode 100644
index 43f7901..0000000
--- a/tools_v2/build/make/linux_gcc_library.mak
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories which use the gcc compiler.
-# See the file linux_library.mk for more details.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CC = gcc
-
-SHARED_LINK = gcc
-SHARED_CFLAGS = -fPIC
-SHARED_CXXFLAGS = -fPIC
-SHARED_LDFLAGS = -shared
-
-SONAME_ARG = -Wl,-h,$(SONAME)
-
-
-include $(MK)/linux_library.mk
diff --git a/tools_v2/build/make/linux_gcc_prog.mak b/tools_v2/build/make/linux_gcc_prog.mak
deleted file mode 100644
index 5fccd91..0000000
--- a/tools_v2/build/make/linux_gcc_prog.mak
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# This makefile template is used for programs whose main routine is
-# defined in C code to be compiled with gcc.  See prog.mk for more information.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CC = gcc
-
-STAT_LIB_EXT = a
-STAT_OBJS_EXT = o
-
-REALTARGET = $(BUILD_ARCH)/$(TARGET)
-
-CLEAN+=$(REALTARGET) $(OBJS)
-
-
-include $(MK)/prog.mk
-
-
-
-#
-# Build the actual target using the C compiler.  This rule uses
-# gnu make's extension for supporting library dependencies with the
-# -llib syntax.
-#
-
-STATIC_BINDING = -static
-
-
-
-$(REALTARGET): $(OBJS) $(ALL_LIBS)
-	$(build_target:_LINK_=$(CC))
-
-
-
-
diff --git a/tools_v2/build/make/linux_library.mk b/tools_v2/build/make/linux_library.mk
deleted file mode 100644
index 4e12405..0000000
--- a/tools_v2/build/make/linux_library.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories.  The including makefile may define the
-# HDRS variable to a list of header files to get installed.
-# See also the rules.mk file for descriptions of meanings of
-# other variables.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-STAT_LIB_EXT = a
-STAT_OBJS_EXT = o
-
-include $(MK)/library.mk
-
diff --git a/tools_v2/build/make/linux_nj.mk b/tools_v2/build/make/linux_nj.mk
deleted file mode 100644
index 511b85e..0000000
--- a/tools_v2/build/make/linux_nj.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# This file contains the architecture specific 
-# definitions for linux_arm platform.
-#
-
-AR_ARGS = rvl
-AR = arm-eabi-ar
-
-CC = arm-eabi-gcc
-CXX = arm-eabi-g++
-CO = -c -o # make sure to leave a space at the end
-
-export RANLIB = arm-eabi-ranlib
-
-XCPPFLAGS += -fomit-frame-pointer -fno-strict-aliasing -finline-limit=150 -msoft-float -O2 -march=armv5te -W -fno-rtti -fno-exceptions -mtune=xscale -fpic -mthumb-interwork -funwind-tables -finline-functions -fno-inline-functions-called-once -funswitch-loops -fgcse-after-reload -frerun-cse-after-loop -frename-registers -Wstrict-aliasing=2
-
-# The following flag is needed for all vobs except codecs_v2.
-# Let's use this by default for now.
-XCPPFLAGS += -mthumb
-
-# The following flag has been used for Android to avoid linkage errors
-XCPPFLAGS += -mlong-calls 
-
-COMPFLAGS = -Wall -Wno-non-virtual-dtor -Wno-multichar
-
-# include the common engine header files in the search path
-XINCDIRS += \
-	-I $(ANDROID_BASE)/device/include \
-	-I $(ANDROID_BASE)/device/system/libm/include \
-	-I $(ANDROID_BASE)/device/system/bionic/include \
-	-I $(ANDROID_BASE)/device/system/bionic/arch-arm/include \
-	-I $(ANDROID_BASE)/device/system/bionic/arch-arm/include/machine \
-	-I $(ANDROID_BASE)/device/system/libstdc++/include \
-	-I $(KERNEL_HEADERS) \
-	-I $(ANDROID_BASE)/device/system/libthread_db/include \
-	-I $(ANDROID_BASE)/device/system/libstdc++ \
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-XLIBDIRS += \
-	-L $(ANDROID_BASE)/../ \
-	-L $(ANDROID_BASE)/../toolchain-eabi-4.2.1/lib \
-	-L $(ANDROID_BASE)/../toolchain-eabi-4.2.1/arm-eabi/lib \
-	-lc
-
diff --git a/tools_v2/build/make/linux_nj_g++_library.mak b/tools_v2/build/make/linux_nj_g++_library.mak
deleted file mode 100644
index 9f709fd..0000000
--- a/tools_v2/build/make/linux_nj_g++_library.mak
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories which use the g++ compiler.
-# See the file linux_arm_library.mk for more details.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CXX = arm-eabi-g++
-
-SHARED_LINK = arm-eabi-g++
-SHARED_CFLAGS = -fPIC
-SHARED_CXXFLAGS = -fPIC
-SHARED_LDFLAGS = -shared
-
-SONAME_ARG = -Wl,-h,$(SONAME)
-
-#Make all warnings into errors.
-FLAG_COMPILE_WARNINGS_AS_ERRORS = -Werror
-
-include $(MK)/linux_nj_library.mk
diff --git a/tools_v2/build/make/linux_nj_g++_module.mak b/tools_v2/build/make/linux_nj_g++_module.mak
deleted file mode 100644
index 066c8e9..0000000
--- a/tools_v2/build/make/linux_nj_g++_module.mak
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# This makefile template should be included by makefiles to
-# build modules and uses the g++ compiler.
-# See the file module.mk for more details.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CXX = arm-eabi-g++
-
-SHARED_LINK = arm-eabi-g++
-SHARED_LDFLAGS = -shared
-SONAME_ARG = -nostdlib -Wl-soname,$(SONAME) -Wl,-shared,-Bsymbolic --no-undefined -Wl,--whole-archive
-
-include $(MK)/module.mk
diff --git a/tools_v2/build/make/linux_nj_g++_prog.mak b/tools_v2/build/make/linux_nj_g++_prog.mak
deleted file mode 100644
index c55778d..0000000
--- a/tools_v2/build/make/linux_nj_g++_prog.mak
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# This makefile template is used for programs whose main routine is
-# defined in C++ code.  See prog.mk for more information.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-REALTARGET = $(BUILD_ARCH)/$(TARGET)
-
-STAT_LIB_EXT = a
-STAT_OBJS_EXT = o
-
-CLEAN+=$(REALTARGET) $(OBJS)
-
-
-include $(MK)/prog.mk
-
-
-
-#
-# Build the actual target using the C++ compiler.  This rule uses
-# gnu make's extension for supporting library dependencies with the
-# -llib syntax.
-#
-
-#STATIC_BINDING = -Bstatic
-export BINDING = -nostdlib -Bstatic -Wl,-T,$(ANDROID_BASE)/../armelf.x \
-		-Wl,-dynamic-linker,/android/bin/linker -Wl,-z,nocopyreloc \
-		-Wl,-rpath-link=$(ANDROID_BASE)/../
-
-$(REALTARGET):: $(OBJS) $(ALL_LIBS)
-	$(build_target:_LINK_=$(CXX))
diff --git a/tools_v2/build/make/linux_nj_gcc_library.mak b/tools_v2/build/make/linux_nj_gcc_library.mak
deleted file mode 100644
index 0718b60..0000000
--- a/tools_v2/build/make/linux_nj_gcc_library.mak
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories which use the gcc compiler.
-# See the file linux_arm_library.mk for more details.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CC = arm-eabi-gcc
-
-SHARED_LINK = arm-eabi-gcc
-SHARED_CFLAGS = -fPIC
-SHARED_CXXFLAGS = -fPIC
-SHARED_LDFLAGS = -shared
-
-SONAME_ARG = -Wl,-h,$(SONAME)
-
-
-include $(MK)/linux_nj_library.mk
-
diff --git a/tools_v2/build/make/linux_nj_gcc_prog.mak b/tools_v2/build/make/linux_nj_gcc_prog.mak
deleted file mode 100644
index 4208c8d..0000000
--- a/tools_v2/build/make/linux_nj_gcc_prog.mak
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# This makefile template is used for programs whose main routine is
-# defined in C code to be compiled with gcc.  See prog.mk for more information.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-override CC = arm-eabi-gcc
-
-STAT_LIB_EXT = a
-STAT_OBJS_EXT = o
-
-REALTARGET = $(BUILD_ARCH)/$(TARGET)
-
-CLEAN+=$(REALTARGET) $(OBJS)
-
-
-include $(MK)/prog.mk
-
-
-
-#
-# Build the actual target using the C compiler.  This rule uses
-# gnu make's extension for supporting library dependencies with the
-# -llib syntax.
-#
-
-#STATIC_BINDING = -static
-STATIC_BINDING = -nostdlib -Bstatic -Wl,-T,build/armelf.x
-
-
-
-$(REALTARGET): $(OBJS) $(ALL_LIBS)
-	$(build_target:_LINK_=$(CC))
-
-
-
-
diff --git a/tools_v2/build/make/linux_nj_library.mk b/tools_v2/build/make/linux_nj_library.mk
deleted file mode 100644
index 4e12405..0000000
--- a/tools_v2/build/make/linux_nj_library.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# This makefile template should be included by makefiles in
-# library directories.  The including makefile may define the
-# HDRS variable to a list of header files to get installed.
-# See also the rules.mk file for descriptions of meanings of
-# other variables.
-#
-
-BUILD_ARCH = $(ARCHITECTURE)
-
-STAT_LIB_EXT = a
-STAT_OBJS_EXT = o
-
-include $(MK)/library.mk
-
diff --git a/tools_v2/build/make/local.mk b/tools_v2/build/make/local.mk
deleted file mode 100644
index 9965f1b..0000000
--- a/tools_v2/build/make/local.mk
+++ /dev/null
@@ -1,97 +0,0 @@
-#
-# This Makefile template should contain the project
-# specific information to adapt the templates to 
-# other projects.
-
-ifeq ($(strip $(PV_DEFINES)),)
-  PV_DEFINES := $(shell $(MK)/../bin/pv_defines $(BUILD_ARCH)) 
-endif
-
-
-# Add pv_defines to cppflags
-CPPFLAGS += $(PV_DEFINES)
-
-
-
-ifeq ($(INSTALL),)
-  INSTALL = install
-endif
-
-ifeq ($(SED),)
-  SED = sed
-endif
-
-ifeq ($(KEEP_OBJ),)
-  KEEP_OBJ = 0
-endif
-
-export TOP := $(PROJECT)
-
-
-# Define the FIND_DIR utility used for finding directories in
-# the project directory structure
-FIND_DIR = $(MK)/../bin/find_dir
-FIND_FILE = $(MK)/../bin/find_file
-GEN_DEPS = $(MK)/../bin/gen_deps
-SHOW_DOC = $(MK)/../bin/show_doc
-
-
-
-#
-# X11
-#  XINCDIRS += -I/usr/X11R6/include -I/usr/local/Motif-2.0/include
-#  XLIBDIRS += -L/usr/X11R6/lib -L/usr/local/Motif-2.0/lib
-ifeq ($(BUILD_ARCH),linux)
-  POST_LIBDIRS += -L/usr/lib -L/usr/local/lib
-  ifdef X11
-    POST_INCDIRS += -I/usr/X11R6/include 
-    POST_LIBDIRS += -L/usr/X11R6/lib
-    ifdef XMT
-      POST_INCDIRS += -I$(XMT)/include
-      POST_LIBDIRS += -L$(XMT)/lib
-    endif
-  endif
-endif
-
-# Set the default search directories for project
-ifneq ($(strip $(INCSRCDIR)),)
-  INCDIRS += -I$(INCSRCDIR)
-endif
-INCDIRS += -I$(SRCDIR)
-INCDIRS += $(shell $(FIND_DIR) -I include $(TOP))
-INCDIRS += $(shell $(FIND_DIR) -I installed_include $(TOP))
-
-LIB_DIRS := $(shell $(FIND_DIR) -L lib/$(BUILD_ARCH) $(TOP))
-
-#
-# LINUX-NJ
-#
-ifeq ($(ARCHITECTURE),linux_nj)
-   override SYSLIBS = -lc -lm -ldl -lstdc++
-   PRE_LDFLAGS += \
-   $(ANDROID_BASE)/../toolchain-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtbegin_static.o
-   POST_LDFLAGS += \
-   $(ANDROID_BASE)/../toolchain-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/libgcc.a \
-   $(ANDROID_BASE)/../toolchain-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtend.o
-endif
-
-# HAS_OSCL_LIB_SUPPORT is required for dynamic loading
-# PV_LINUX_BUILD is required to differentiate between the Android build and
-# the PV Linux build
-ifeq ($(FORMAT),nj)
-	CPPFLAGS += -DHAS_OSCL_LIB_SUPPORT -DPV_LINUX_BUILD
-endif
-
-#
-# CPP - Any one will do
-#
-CPP=/lib/cpp
-
-
-#
-# Default filetypes for the clean rule.  Just add things like editor backups
-# here -- the targets will add whatever's appropriate.  Also add the dependency
-# files, too.
-#
-CLEAN_DEFAULTS=*.BAK *~ *% *.tmp*
-
diff --git a/tools_v2/build/make/module.mk b/tools_v2/build/make/module.mk
deleted file mode 100644
index 984e50f..0000000
--- a/tools_v2/build/make/module.mk
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# This makefile template should be included by makefiles to
-# build runtime loadable modules.
-#
-
-MY_TARGET = $(strip $(TARGET))
-
-# if DBG_SUFFIX not set then set to _debug
-ifeq ($(strip $(DBG_SUFFIX)),)
-  DBG_SUFFIX = _debug
-endif
-
-LIBS_LINKED = $(foreach lib, $(LIBS), $(patsubst $(filter $(lib), $(LIBS)), $(lib)$(DBG_SUFFIX), $(lib)))
-MODS_LINKED = $(foreach mod, $(MODS), $(patsubst $(filter $(mod), $(MODS)), $(mod)$(DBG_SUFFIX), $(mod)))
-
-ifeq ($(RELEASE),1)
-  override SOTARGET = $(MODL_REL_LIB)
-  MODL_OBJDIR = $(BUILD_ARCH)/module_rel
-  LIBS_LINKED = $(foreach lib, $(LIBS), $(lib)_mod)
-  MODS_LINKED = $(foreach mod, $(MODS), $(mod))
-  LIBTARGET   = module-rel
-else
-  override SOTARGET = $(MODL_DBG_LIB)
-  MODL_OBJDIR = $(BUILD_ARCH)/module_dbg
-  LIBS_LINKED = $(foreach lib, $(LIBS), $(lib)_mod$(DBG_SUFFIX))
-  MODS_LINKED = $(foreach mod, $(MODS), $(mod)$(DBG_SUFFIX))
-  LIBTARGET   = module-dbg
-endif
-
-entire: headers-install LIBTARGET=$(LIBTARGET) $(SOTARGET) so-install
-
-CLEAN += $(SOTARGET)
-
-MODL_REL_LIB = $(MY_TARGET:%=$(MODL_OBJDIR)/lib%.so$(SHAR_LIB_EXT))
-MODL_DBG_LIB = $(MY_TARGET:%=$(MODL_OBJDIR)/lib%$(DBG_SUFFIX).so$(SHAR_LIB_EXT))
-
-XLDFLAGS  += $(SHARED_LDFLAGS)
-
-ifeq ($(strip $(SONAME)),)
-    SONAME = $(SOTARGET)$(SONAME_EXT)
-endif
-
-so_srcdir=$(patsubst %/,%,$(dir $(SOTARGET)))
-so_destdir=$(DESTDIR)
-so_files=$(notdir $(SOTARGET))
-so_ifunction=_so_install_
-
-define _so_install_
-	$(INSTALL) -c -m 775 WHAT_TO_INSTALL $(so_destdir)
-endef
-
-include $(MK)/rules.mk
-
-include $(MK)/recursive.mk
-
-$(SOTARGET):
-	@$(MK)/../bin/cc_mkdir $(MODL_OBJDIR) 
-	$(build_shared)
-
-define build_shared
-	-$(RM) $@
-	$(SHARED_LINK) $(SONAME_ARG) $(XLDFLAGS) -o $@ $(LIBS_LINKED) $(MODS_LINKED) $(POST_LIBDIRS) $(POST_SHARED_LDFLAGS)
-	-chmod g+w $@
-endef
-.PHONY:: entire
diff --git a/tools_v2/build/make/print_libs.sh b/tools_v2/build/make/print_libs.sh
deleted file mode 100755
index 49edc02..0000000
--- a/tools_v2/build/make/print_libs.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-cd $PV_TOP/../engines/player/test/build/$1
-
-$2 RELEASE=1 ARCHITECTURE=$1 print_pv_libs 2>&1 | grep LIBS | sed -e 's#LIBS *= *##'
-
-
-
diff --git a/tools_v2/build/make/prog.mk b/tools_v2/build/make/prog.mk
deleted file mode 100644
index 0bc9273..0000000
--- a/tools_v2/build/make/prog.mk
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# This makefile is included by language- or compiler-specific makefiles.
-# The makefiles including those may define LIBS to a list
-# of libraries that this program needs to link with.  This LIBS should
-# have syntax suitable for being included on the link commandline.
-# See also the rules.mk file for descriptions of meanings of
-# other variables.
-#
-
-# if DBG_SUFFIX not set then set to _debug
-ifeq ($(strip $(DBG_SUFFIX)),)
-  DBG_SUFFIX = _debug
-endif
-
-
-TARGETS_TO_INSTALL+=default
-
-ifneq ($(strip $(RSRCS)),)
-  ifneq ($(strip $(RSRCDESTDIR)),)
-    TARGETS_TO_INSTALL+=resources
-  endif
-endif
-
-resources_srcdir=.
-resources_destdir=$(RSRCDESTDIR)
-resources_files=$(RSRCS)
-resources_ifunction=_resource_install_
-
-define _resource_install_
-	$(INSTALL) -c -m 444 WHAT_TO_INSTALL $(resources_destdir)
-endef
-
-OBJDIRS = $(BUILD_ARCH)
-
-OBJS = $(COMPILED_OBJS:%.$(STAT_OBJS_EXT)=$(OBJDIRS)/%.$(STAT_OBJS_EXT))
-
-DEPS = $(OBJS:%.$(STAT_OBJS_EXT)=%.d)
-
-CLEAN += $(DEPS)
-
-include $(MK)/rules.mk
-
-# Note that clearmake does not appear to handle vpath correctly
-# If a system file only has a shared version then it complains that
-# it can't find the dependency (if the library is listed in the 
-# dependency list).  The work-around for now is to include the 
-# library in the XLDFLAGS.  One example is libpthread on the Suns.
-
-ifeq ($(HOST_ARCH), win32)
-  vpath %.so $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
-  vpath %.$(STAT_LIB_EXT) $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
-else
-  vpath lib%.so $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
-  vpath lib%.$(STAT_LIB_EXT) $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
-endif
-
-ifneq ($(HOST_ARCH), win32)
-define group_writable_target
-	chmod g+w $(REALTARGET)
-endef
-endif
-
-
-ifeq ($(TOOLSET), cl)
-define build_target
-	-$(RM) $(REALTARGET)
-		_LINK_ $(BINDING) /out:$(REALTARGET) $(patsubst -L%,/libpath:%,$(filter-out -l%,$(LDFLAGS))) \
-			$(OBJS)	$(XOBJECTS) $(patsubst -l%,%.$(STAT_LIB_EXT),$(filter -l%,$(LDFLAGS))) \
-			$(POST_LDFLAGS)
-		$(rm_vc60)
-	$(group_writable_target)
-endef
-
-else
-define build_target
-	-$(RM) $(REALTARGET)
-		_LINK_ $(BINDING) -o $(REALTARGET)  $(filter-out -l%,$(LDFLAGS)) \
-			$(PRE_LDFLAGS) $(OBJS) $(XOBJECTS) $(filter -l%,$(LDFLAGS)) $(POST_LDFLAGS)
-	$(group_writable_target)
-endef
-endif
-
-
-static::
-	-$(RM) $(REALTARGET)
-	$(MAKE) $(MFLAGS) $(REALTARGET) BINDING=$(STATIC_BINDING)
-
-link::
-	-$(RM) $(REALTARGET)
-	$(MAKE) $(MFLAGS) $(REALTARGET)
-
-ifeq ($(strip $(TEST_PROG)),)
-  ifneq ($(HOST_ARCH), win32)
-    TEST_PROG = $(REALTARGET)
-  else
-    # Use DOS path delimeter to run executable
-    TEST_PROG = $(subst /,\,$(REALTARGET))
-  endif
-endif
-
-ifneq ($(strip $(TEST_PROG)),NOTEST)
-run_test::	$(REALTARGET)
-	$(TEST_PROG) $(TEST_ARGS) $(SOURCE_ARGS)
-endif
-
-.PRECIOUS:: $(OBJS)
diff --git a/tools_v2/build/make/projlevel.mak b/tools_v2/build/make/projlevel.mak
deleted file mode 100644
index b15e8ca..0000000
--- a/tools_v2/build/make/projlevel.mak
+++ /dev/null
@@ -1,10 +0,0 @@
-include project.mk
-
-BUILDDIRS = $(BUILDPATH:%=$(TOP)/%)
-
-project:
-	recursive_make "$(MAKE)" "$(MKFLAGS)" install_hdrs $(BUILDDIRS)
-	recursive_make "$(MAKE)" "$(MKFLAGS)" install_libs $(BUILDDIRS)
-	recursive_make "$(MAKE)" "$(MKFLAGS)" install_bins $(BUILDDIRS)
-
-include $(MK)/recursive.mk
diff --git a/tools_v2/build/make/recursive.mk b/tools_v2/build/make/recursive.mk
deleted file mode 100644
index 74f0980..0000000
--- a/tools_v2/build/make/recursive.mk
+++ /dev/null
@@ -1,87 +0,0 @@
-
-SUBDIRS = $(LIBDIRS) $(BINDIRS) $(TESTDIRS) $(LIBDIRS-m)
-
-RECURSIVE_MAKE = $(MK)/../bin/recursive_make
-
-ifneq ($(SUBDIRS),)
-
-# The NOHDRINST macro is used to bypass the headers-install
-# build step.  It is useful for situations where all the header
-# files are already visible within the compiler search path.
-# ONLY DEFINE THE MACRO IF YOU KNOW WHAT YOU'RE DOING
-ifdef NOHDRINST
-  world: library-install install-it
-else
-  world: headers-install library-install install-it
-endif
-
-ifeq ($(HOST_ARCH), win32)
-  headers-install:
-	@export MAKEFLAGS
-	echo "Recursive"
-	$(RECURSIVE_MAKE) "\"$(MAKE) "NODEPS=1"\"" headers-install "$(LIBDIRS)" "$(LIBDIRS-m)"
-
-  library-install:
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)" library-install "$(LIBDIRS)"
-
-  install-it:
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)" install "$(BINDIRS)"
-
-  clean::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  $@ "$(SUBDIRS)"
-
-  cm-release::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  cm-release "$(LIBDIRS)" "$(BINDIRS)"
-
-  run_test::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  run_test "$(TESTDIRS)"
-
-
-  %::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  "$@" "$(SUBDIRS)"
-else
-  headers-install:
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE) NODEPS=1" headers-install $(LIBDIRS) $(LIBDIRS-m)
-
-  library-install:
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)" library-install $(LIBDIRS)
-	$(RECURSIVE_MAKE) "$(MAKE)" "" $(LIBDIRS-m)
-
-  install-it:
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)" install $(BINDIRS)
-
-  clean::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  $@ $(SUBDIRS)
-
-  cm-release::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  cm-release $(LIBDIRS) $(BINDIRS)
-
-  run_test::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  run_test $(TESTDIRS)
-
-
-  %::
-	@export MAKEFLAGS
-	$(RECURSIVE_MAKE) "$(MAKE)"  $@ $(SUBDIRS)
-
-endif
-  .PHONY:: world install-it headers-install library-install run_test cm-release
-
-else
-
-  .DEFAULT:
-	@echo "No subdirectories defined."
-
-endif
diff --git a/tools_v2/build/make/rules.mk b/tools_v2/build/make/rules.mk
deleted file mode 100644
index 9895045..0000000
--- a/tools_v2/build/make/rules.mk
+++ /dev/null
@@ -1,572 +0,0 @@
-# This file is at the heart of this makefile system.  It defines the
-# main rules for building software.
-#
-# There are many variables used in this file.  It is appropriate to
-# modify or override some in unit-level makefiles or in project.mk
-# and local.mk.  Others should not be tampered with.  When possible,
-# variables are set up here to support gnu make's default targets as
-# documented in the gnu make manual.
-#
-# ARCHITECTURE-DEPENDENT VARIABLES
-#   These variables are suitable for modification in the arch.mk files:
-#
-#     CC:   The C compiler
-#     CXX:  The C++ compiler
-#     CO:   The compiler option used to specify object file name
-#     LD:   The linker
-#     RM:   Remove a file -- should succeed if the file does not exist
-#     AR:   Library archive builder
-#     AR_FLAGS:  Flags to pass to ar when adding an object file to a
-#		 library
-#     RANLIB: Program used to generate library tables of contents.  (On
-#	      systems with no ranlib program, this can be defined as
-#	      "true" since the "true" program always succeeds.)
-#
-# VARIABLES SUITABLE FOR LOCAL MODIFICATION
-#   These variables can be modified in individual makefiles,
-#   in local.mk, or in project.mk.  They should be set += so
-#   that settings are not overridden if set in more than once
-#   place:
-#
-#     DFLAGS: Debugging flags to the compiler.  Flags defined here
-#         are used during compiling and linking but not during
-#         dependency generation.
-#     XLIBDIRS: Extra directories (outside project library
-#         directories and default directories) where libraries
-#	  should be searched for.
-#     ENVCPPFLAGS:  Global flags that should be set on the command
-#         line.  This flags must not conflict with the XCPPFLAGS
-#         values inside the individual makefiles.  
-#     XCPPFLAGS: Extra flags for the C Preprocessor besides
-#         the standard and deafult include directories.  This
-#	  could include things like -DDEBUG.
-#     XCFLAGS: Extra flags to the C compiler that are not used
-#         for debugging or the preprocessor.  These will
-#	  generally be compiler-specific.  (With gcc, for
-#	  example, turning on -Wall here would be appropriate.)
-#     XCXXFLAGS: Same as XCFLAGS but for the C++ compiler.
-#     XLDFLAGS: Sames as XCFLAGS but used at link time.
-#     
-# GUIDELINES FOR MODIFYING THIS FILE
-#   If there is not an appropriate place in one of the above
-#   variables for something you need to include, rather than
-#   modifying one of the others, add the additional variable to
-#   the list and included where necessary.  For example, If you
-#   wanted to add additional flags to be used only during
-#   dependency generation, don't hard code them into the
-#   dependency generation rules.  Instead, add something like
-#   DEPFLAGS and include that in the rule.  In general, users
-#   should be able to treat this file like a black box and
-#   should not need to be concerned with the specifics of how it
-#   does its job.
-#
-
-ifeq  ($(strip $(MAKE)),clearmake)
-CCASE_VIEW_TYPE := $(shell $(MK)/../bin/ccase_view_type)
-endif
-
-# if BUILD_ARCH not set then set to unknown
-ifeq ($(strip $(BUILD_ARCH)),)
-  BUILD_ARCH = unknown
-endif
-
-# if OBJDIRS not set then set to BUILD_ARCH
-ifeq ($(strip $(OBJDIRS)),)
-  OBJDIRS = $(BUILD_ARCH)
-endif
-
-ifeq ($(strip $(COMPILED_TARGETS)),)
-  COMPILED_TARGETS = $(REALTARGET)
-endif
-
-
-
-include $(MK)/global.mk
-
-CFLAGS = $(DFLAGS) $(XCFLAGS) $(COMPFLAGS)
-CXXFLAGS = $(DFLAGS) $(XCXXFLAGS) $(COMPFLAGS)
-CPPFLAGS +=  $(ENVCPPFLAGS) $(XCPPFLAGS) $(INCDIRS) $(XINCDIRS) $(POST_INCDIRS) 
-
-# if REALLIBS IS NOT SET THEN USE LIBS
-# ELSE USE REALLIBS AS MODIFIED USER LIST 
-# OF LIBS
-ifeq ($(strip $(REALLIBS)),)
-  ifneq ($(strip $(RELEASE)),)
-    # compiling in RELEASE mode so check for DEBUG_LIBS macro
-    ALL_PV_LIBS = $(foreach lib, $(LIBS), $(patsubst $(filter $(lib), $(DEBUG_LIBS)), $(lib)$(DBG_SUFFIX), $(lib))) 
-  else 
-    #compiling in debug mode so map all libs by default to _debug
-    TMP_DBG_LIBS = $(filter-out $(RELEASE_LIBS), $(LIBS))
-    ALL_PV_LIBS = $(foreach lib, $(LIBS), $(patsubst $(filter $(lib), $(TMP_DBG_LIBS)), $(lib)$(DBG_SUFFIX), $(lib))) 
-  endif
-else 
-  ifneq ($(strip $(RELEASE)),)
-    # compiling in RELEASE mode so check for DEBUG_LIBS macro
-    ALL_PV_LIBS = $(foreach lib, $(REALLIBS), $(patsubst $(filter $(lib), $(DEBUG_LIBS)), $(lib)$(DBG_SUFFIX), $(lib))) 
-  else 
-    #compiling in debug mode so map all libs by default to _debug
-    TMP_DBG_LIBS = $(filter-out $(RELEASE_LIBS), $(REALLIBS))
-    ALL_PV_LIBS = $(foreach lib, $(REALLIBS), $(patsubst $(filter $(lib), $(TMP_DBG_LIBS)), $(lib)$(DBG_SUFFIX), $(lib)))
-  endif
-endif
-
-LDFLAGS += $(LIB_DIRS) $(ALL_PV_LIBS) $(SYSLIBS) $(DEFAULT_LD_FLAGS) $(XLDFLAGS)
-
-# The variable ALL_LIBS will be used for the dependency list, but clearmake 
-# has a bug where it doesn't handle the dependency if there is only a *.so 
-# file and no *.a file.  We'll remove these from the dependency list for now.
-ifeq  ($(strip $(MAKE)),clearmake)
-  ALL_LIBS = $(ALL_PV_LIBS)
-else
-  ALL_LIBS = $(ALL_PV_LIBS) $(SYSLIBS)
-endif
-
-ifeq ($(strip $(LIBCOMPFLAG)),)
-  LIBCOMPFLAG = -L
-  LIB_DIRS += $(XLIBDIRS) $(POST_LIBDIRS)
-else
-  LIB_DIRS += $(XLIBDIRS:-L%=$(LIBCOMPFLAG)%) $(POST_LIBDIRS:-L%=$(LIBCOMPFLAG)%)
-endif
-
-print_deps: 
-	echo $(DEPS)
-
-print_libdirs:
-	echo $(LIB_DIRS)
-
-print_libs: 
-	@echo LIBS = $(ALL_LIBS)
-
-print_pv_libs:
-	@echo LIBS = $(ALL_PV_LIBS)
-
-print_make_val:
-	echo $(MAKE) $(CCASE_VIEW_TYPE)
-
-
-define create_objdir
-	@$(MK)/../bin/cc_mkdir $(@D)
-endef
-
-ifneq ($(HOST_ARCH), win32)
-define group_writable
-	chmod g+w $(@D)
-endef
-endif
-
-# The MS Visual C++ creates these files and clearmake stores them as sibling derived
-# objects with an automatic dependency.  This causes unnecessary rebuilding.  This
-# special target rule will prevent storing them as derived objects
-ifeq ($(TOOLSET), cl)
-.NO_DO_FOR_SIBLING : vc60.idb %.pdb %.ilk
-endif
-
-#
-# Build dependency files
-#
-
-#
-# This takes out all references to absolute files in the source tree
-# and replaces them with references to $(TOP).  This eliminates
-# the need to rebuild the .d's whenever we change from the baseline to
-# a staging area or vice versa.  We change all forward slashes to backquotes
-# so we don't give sed(1) fits.
-#
-define _process_dot_d_
-	@mv $@ $@.tmp
-	@$(SED) -e 's/\//`/g' $@.tmp \
-	| $(SED) -e 's/$(subst /,`,$(TOP))/\$$\(TOP\)/g' \
-	| $(SED) -e 's/`/\//g' \
-	> $@
-	@$(RM) $@.tmp
-endef
-
-
-ifeq ($(strip $(CDEPS)),)
-DEPS_ARG=$(CC) -MM $(CPPFLAGS) $(CXXFLAGS)
-else 
-DEPS_ARG=$(CDEPS) $(CPPFLAGS) $(CXXFLAGS)
-endif
-
-DEPPAT = $(foreach dir, $(OBJDIRS), $(patsubst %, %/%.d, $(dir)))
-OBJPAT = $(foreach dir, $(OBJDIRS), $(patsubst %, %/%.$(STAT_OBJS_EXT), $(dir)))
-
-showgendeps:
-	@echo gen_deps $(GEN_DEPS) 
-	@echo cxx $(CXX) -M 
-	@echo cppflags $(CPPFLAGS) 
-	@echo realtarget $(REALTARGET) 
-	@echo buildarch objdir keepobj $(BUILD_ARCH) $(OBJDIRS) $(KEEP_OBJ)
-
-ifneq  ($(strip $(MAKE)),clearmake)
-ifneq ($(REMOTE_SRCS),)
-include remote.mk
-endif
-endif
-
-$(DEPPAT) : %.c
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : %.C
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : %.cc
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : %.cpp
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : %.asm
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : %.s
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-
-
-$(DEPPAT) : $(SRCDIR)/%.c
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : $(SRCDIR)/%.C
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : $(SRCDIR)/%.cc
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : $(SRCDIR)/%.cpp
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-
-$(DEPPAT) : $(SRCDIR)/%.asm
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-$(DEPPAT) : $(SRCDIR)/%.s
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-
-%.d : %.asm
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-%.d : %.s
-	$(create_objdir)
-	$(GEN_DEPS) "$(DEPS_ARG)" $(filter $(@D)/%, $(COMPILED_TARGETS)) $< $(@D) $(KEEP_OBJ)
-	$(_process_dot_d_)
-	$(_custom_process_dot_d_)
-
-
-ifeq  ($(strip $(MAKE)),clearmake)
-ifeq  ($(strip $(CCASE_VIEW_TYPE)),dynamic)
-override NODEPS := 1
-endif
-endif
-
-
-
-#
-# Build objects
-#
-
-ifdef NODEPS
-$(REALTARGET)(%.$(STAT_OBJS_EXT)) : %.$(STAT_OBJS_EXT)
-	$(create_objdir)
-	$(AR) $(AR_ARGS) $@ $*.$(STAT_OBJS_EXT)
-	#$(RM) $<
-else
-$(REALTARGET)(%.$(STAT_OBJS_EXT)) : %.$(STAT_OBJS_EXT) %.d
-	$(create_objdir)
-	$(AR) $(AR_ARGS) $@ $*.$(STAT_OBJS_EXT)
-	#$(RM) $<
-endif
-
-
-%.obj : %.c %.d
-	$(create_objdir)
-	-$(RM) $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-%.obj : %.asm
-	$(create_objdir)
-	-$(RM) $@
-	$(ASM) $(ASMFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-%.o : %.s
-	$(create_objdir)
-	-$(RM) $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : %.c
-	$(create_objdir)
-	-$(RM) $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : %.C
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : %.cc
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : %.cpp
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : %.s
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-# object patterns in family directory
-$(OBJPAT) : $(FAMILY_DIR)/%.c
-	$(create_objdir)
-	-$(RM) $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(FAMILY_DIR)/%.C
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(FAMILY_DIR)/%.cc
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(FAMILY_DIR)/%.cpp
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(FAMILY_DIR)/%.s
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-# object patterns in family directory
-$(OBJPAT) : $(SRCDIR)/%.c
-	$(create_objdir)
-	-$(RM) $@
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(SRCDIR)/%.C
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(SRCDIR)/%.cc
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(SRCDIR)/%.cpp
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-$(OBJPAT) : $(SRCDIR)/%.s
-	$(create_objdir)
-	-$(RM) $@
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CO)$@ $<
-	$(group_writable)
-
-
-.PHONY:: all clean print-objpat
-
-
-all:: $(REALTARGET)
-
-print-objpat: 
-	@echo $(OBJPAT) $(FAMILY_DIR) $(SRCDIR)
-
-ETAGS_OPTS = -a
-CTAGS_OPTS = -a -t -T -w -S
-TAG_HDRS := $(wildcard *.h)
-ifeq ($(TOOLSET),g++)
-TAG_HDR_OPTS = -C
-endif
-ifeq ($(TOOLSET),cxx)
-TAG_HDR_OPTS = -C
-endif
-ifneq ($(strip $(TAG_HDRS)),)
-define _build_hdr_etags
-	etags $(ETAGS_OPTS) $(TAG_HDR_OPTS) $(TAG_HDRS)
-endef
-define _build_hdr_ctags
-	ctags $(CTAGS_OPTS) $(TAG_HDR_OPTS) $(TAG_HDRS)
-endef
-endif
-
-
-############################################
-# Create tags for emacs, stored in file $(ETAG_FILE) 
-#    which is set in enviroment.
-#    e.g., ETAG_FILE= /auto_home/miao/pvs_etags
-#  and we do not create tags for test files.
-ETAGS_OPTS += --c++ --members
-ETAGS_SRC_FILES = $(SRCS)  $(HDRS)
-tmpp = $(notdir $(shell $(MK)/../bin/cc_pwd))
-ifneq ($(notdir $(shell $(MK)/../bin/cc_pwd)),test)
-ifneq ( $(ETAGS_SRC_FILES),)
-define _create_etags
-	etags $(ETAGS_SRC_FILES)  $(ETAGS_OPTS) -o $(ETAG_FILE)
-endef
-else
-define _create_etags
-	@echo "No files for tags in this dir."
-endef
-endif
-
-else
-define _create_etags
-	@echo "Skipping test dir."
-endef
-endif
-
-etags::
-	$(_create_etags)
-
-newetags::
-	-$(RM) $(ETAG_FILE)
-	$(_create_etags)
-
-TAGS::
-	-$(RM) $@
-	etags $(ETAGS_OPTS) $(CSRCS) $(CCSRCS) $(CXXSRCS)
-	-$(_build_hdr_etags)
-
-tags::
-	-$(RM) $@
-	ctags $(CTAGS_OPTS) $(CSRCS) $(CCSRCS) $(CXXSRCS)
-	-$(_build_hdr_ctags)
-
-
-# The assignments below attempt to sort out which of the dependency
-# files are no longer valid because of name changes in header files.
-#
-# Explanation of variables:
-#
-# DEPS_EXISTING	= Dependency files that already exist
-# DEPS_MISSING	= Dependency files that don't already exist
-# DEPS_HEADERS	= List of the header files mentioned in $(DEPS_EXISTING)
-# DEPS_HFOUND	= 
-# DEPS_HMISSING	= List of headers from $(DEPS_HEADERS) that don't actually
-#		  exist.
-# DEPS_FBAD	= A list of the dependency files that were bad
-#
-# Note that we only go through this rigamarole if NODEPS hasn't been
-# defined.  All assignments are of the simply-expanded variety so we
-# don't do any excessive calls to the shell.
-
-
-ifndef NODEPS
-
-    DEPS_EXISTING := $(wildcard $(DEPS))
-    DEPS_MISSING  := $(filter-out $(DEPS_EXISTING),$(DEPS))
-
-    # If we found any dependency files at all, check to see if any header
-    # files are mentioned that don't exist.
-
-    ifneq ($(DEPS_EXISTING),)
-
-        # Make a list of the headers mentioned in the dependency files.
-        # We put the word $(TOP) in, so substitute the actual value of
-        # $(TOP) whenever we see $$(TOP).
-
-        DEPS_HEADERS := $(subst $$(TOP), $(TOP), \
-            $(sort $(filter %.h,$(shell cat $(DEPS_EXISTING)))) )
-
-        # Figure out which headers exist and which don't.
-
-        DEPS_HFOUND := $(wildcard $(DEPS_HEADERS))
-        DEPS_HMISSING := $(filter-out $(DEPS_HFOUND),$(DEPS_HEADERS))
-
-        # If there were any headers missing, take down the names of
-        # the dependency files the used them and wipe them out.
-
-        ifneq ($(DEPS_HMISSING),)
-            DEPS_FBAD := $(shell echo $(DEPS_HMISSING) > .makejunk ; \
-                fgrep -l -f .makejunk $(DEPS) ; rm .makejunk )
-            DEPS_JUNK := $(shell $(RM) $(DEPS_FBAD))
-        endif
-
-    endif
-
-    # If any dependency files are missing, rebuild them before they're
-    # included.
-
-    ifneq ($(DEPS_MISSING)$(DEPS_FBAD),)
-        DEPS_JUNK := $(shell $(MAKE) NODEPS=1 \
-	COMPILED_TARGETS=$(COMPILED_TARGETS) KEEP_OBJ=$(KEEP_OBJ)\
-            $(DEPS_MISSING) $(DEPS_FBAD) 2>&1)
-    endif
-
-    DEPS_TO_INCLUDE := $(wildcard $(DEPS))
-
-    ifneq ($(DEPS_TO_INCLUDE),)
-        include $(DEPS_TO_INCLUDE)
-    endif
-endif
-
-.PRECIOUS:: $(DEPS)
-
-include $(MK)/utilities.mk
-
diff --git a/tools_v2/build/make/srclist.mk b/tools_v2/build/make/srclist.mk
deleted file mode 100644
index 7e855b7..0000000
--- a/tools_v2/build/make/srclist.mk
+++ /dev/null
@@ -1,64 +0,0 @@
-
-ifndef SRCDIR
-  SRCDIR := .
-endif
-
-ifneq  ($(strip $(MAKE)),clearmake)
-  ifeq ($(HOST_ARCH),win32)
-    REMOTE_SRCS := $(shell $(MK)/../bin/filter_remote.bat "$(SRCS)")
-  else
-    REMOTE_SRCS := $(shell $(MK)/../bin/filter_remote $(SRCS))
-  endif
-LOCAL_SRCS := $(filter-out $(REMOTE_SRCS), $(SRCS))
-else
-REMOTE_SRCS := ""
-LOCAL_SRCS := $(SRCS)
-endif
-
-
-FAMILY_DIR := $(SRCDIR)/$(ARCHITECTURE)
-FAMILY_SRCS_WANTED := $(LOCAL_SRCS:%=$(FAMILY_DIR)/%)
-FAMILY_SRCS_FOUND := $(wildcard $(FAMILY_SRCS_WANTED))
-FAMILY_SRCS_MISSING := $(filter-out $(FAMILY_SRCS_FOUND),$(FAMILY_SRCS_WANTED))
-
-COMMON_SRCS_WANTED := $(FAMILY_SRCS_MISSING:$(FAMILY_DIR)/%=$(SRCDIR)/%)
-COMMON_SRCS_FOUND := $(wildcard $(COMMON_SRCS_WANTED))
-COMMON_SRCS_MISSING := $(filter-out $(COMMON_SRCS_FOUND),$(COMMON_SRCS_WANTED))
-
-ALL_WANTED := $(COMMON_SRCS_WANTED)
-ALL_FOUND := $(COMMON_SRCS_FOUND)
-
-ifneq ($(ALL_WANTED),$(ALL_FOUND))
-
-default:
-	@echo "missing srcs..."
-	@echo $(COMMON_SRCS_MISSING)
-	@echo ""
-	@/bin/false
-
-endif
-
-
-# Note: CXX will be used to represent 
-# C++ files/variables throughout
-
-COMBINED_SRCS := $(FAMILY_SRCS_FOUND) $(COMMON_SRCS_FOUND) $(REMOTE_SRCS)
-
-ifneq  ($(strip $(MAKE)),clearmake)
-FINAL_SRCS := $(notdir $(COMBINED_SRCS))
-else
-FINAL_SRCS := $(COMBINED_SRCS)
-endif
-
-CSRCS := $(filter %.c,$(FINAL_SRCS))
-CCSRCS := $(filter %.cc,$(FINAL_SRCS))
-CPPSRCS := $(filter %.cpp,$(FINAL_SRCS))
-CXXSRCS := $(filter %.C,$(FINAL_SRCS))
-ASMSRCS := $(filter %.s,$(FINAL_SRCS))
-COBJS  := $(CSRCS:%.c=%.$(STAT_OBJS_EXT))
-CPPOBJS := $(CPPSRCS:%.cpp=%.$(STAT_OBJS_EXT))
-CXXOBJS := $(CXXSRCS:%.C=%.$(STAT_OBJS_EXT))
-CCOBJS := $(CCSRCS:%.cc=%.$(STAT_OBJS_EXT))
-ASMOBJS := $(ASMSRCS:%.s=%.$(STAT_OBJS_EXT))
-COMPILED_OBJS := $(COBJS) $(CXXOBJS) $(CCOBJS) $(CPPOBJS) $(ASMOBJS)
-
diff --git a/tools_v2/build/make/support_gnumake_install.mak b/tools_v2/build/make/support_gnumake_install.mak
deleted file mode 100644
index 1255a42..0000000
--- a/tools_v2/build/make/support_gnumake_install.mak
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-#BEGINDOC
-# -----------------------------------------------------------------------------
-#
-# This GNUmake template installs targets such as shell scripts and common
-# include files that don't need to be built, just installed.
-#
-# SUPPORTED MACROS:
-#
-# DESTDIR	Where the installed file(s) should go
-#
-# SRCS		A list of the files to be installed.
-#
-# MODE		The permissions for each installed file.  By default this
-#		is 664.
-# 
-# -----------------------------------------------------------------------------
-#ENDOC
-
-ifeq ($(MODE),)
-  MODE=444
-endif
-
-TARGETS_TO_INSTALL=generic
-
-generic_srcdir=.
-generic_destdir=$(DESTDIR)
-generic_files=$(SRCS)
-generic_ifunction=_generic_install_
-
-define _generic_install_
-	install -c -m $(MODE) WHAT_TO_INSTALL $(generic_destdir)
-	$(RANDOMLIB)
-endef
-
-
-include $(MK)/rules.mk
diff --git a/tools_v2/build/make/support_gnumake_subdirs.mak b/tools_v2/build/make/support_gnumake_subdirs.mak
deleted file mode 100644
index 974c7db..0000000
--- a/tools_v2/build/make/support_gnumake_subdirs.mak
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-#BEGINDOC
-# -----------------------------------------------------------------------------
-#
-# This GNUmake template builds targets in subdirectories.  By default, the
-# "install" target will be built if none are specified on the command line.
-#
-# SUPPORTED MACROS:
-#
-# SRCS		A list of the subdirectories to build.  If not specified,
-#		all subdirectories containing a file called "GNUmakefile"
-#		will be built.
-#
-# 
-# -----------------------------------------------------------------------------
-#ENDOC
-
-include $(MK)/local.mk
-
-ifeq ($(SRCS),)
-	GNUMAKEFILES=$(wildcard */GNUmakefile)
-	DIRLIST=$(subst /GNUmakefile,,$(GNUMAKEFILES))
-else
-	DIRLIST=$(SRCS)
-endif
-
-.PHONY:: all
-all:: install
-
-%: $(addsuffix -%-subdir,$(DIRLIST))
-	@echo -n ""
-
-ifeq ($(BCS)$(IN_STAGING),11)
-    define _stage_subdir_
-      -stage $(firstword $(subst -, , $(subst -subdir,,$@)))
-    endef
-endif
-
-%-subdir:
-	$(_stage_subdir_)
-	$(MAKE) $(MFLAGS) -C $(subst -, , $(subst -subdir,,$@))
-
-
-
diff --git a/tools_v2/build/make/test_template b/tools_v2/build/make/test_template
deleted file mode 100644
index 6449e2d..0000000
--- a/tools_v2/build/make/test_template
+++ /dev/null
@@ -1,34 +0,0 @@
-
-NUM_TARGETS := $(words TARGETS)
-
-ifndef ARCHITECTURE
-  ARCHITECTURE := $(shell archtype)
-endif
-
-
-.PHONY:: all
-
-default: $(word 1, $(TARGETS))
-
-all: $(TARGETS)
-
-TARGET = $@
-
-$(TARGETS):
-	@echo $(TARGET)
-	ifdef $(@)_SRCS
-	@echo $(@)_SRCS
-	else	
-  	@echo $(SRCS)
-	endif
-	@echo $(NUM_TARGETS)
-	@echo $(ARCHITECTURE)
-
-current_src = $(test_src)
-
-ifdef $(@)_SRCS
-  test_src = $(@)_SRCS
-else
-  test_src = $(SRCS)
-endif
-
diff --git a/tools_v2/build/make/toplevel.mak b/tools_v2/build/make/toplevel.mak
deleted file mode 100644
index 047dd55..0000000
--- a/tools_v2/build/make/toplevel.mak
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# This makefile should be included by makefiles at the project level.
-# See also recursive.mk
-#
-
-.PHONY: world
-
-world: install_hdrs install_libs install_bins
-
-include $(MK)/recursive.mk
diff --git a/tools_v2/build/make/utilities.mk b/tools_v2/build/make/utilities.mk
deleted file mode 100644
index 43c10d1..0000000
--- a/tools_v2/build/make/utilities.mk
+++ /dev/null
@@ -1,245 +0,0 @@
-#
-
-firstrule:: all
-
-# ----------------------------------------------------------------------
-#		     DEFINITIONS USED INTERNALLY
-# ----------------------------------------------------------------------
-
-# If INSTALL_PREFIX has been defined, we're 
-
-ifneq ($(INSTALL_PREFIX),)
-  INSTALL_SRCDIR=$($(INSTALL_PREFIX)_srcdir)
-  INSTALL_DESTDIR=$($(INSTALL_PREFIX)_destdir)
-  INSTALL_FILES=$($(INSTALL_PREFIX)_files)
-  INSTALL_IFUNCTION=$($(INSTALL_PREFIX)_ifunction)
-  INSTALL_TARGETS=$(addprefix $(INSTALL_DESTDIR)/,$(INSTALL_FILES))
-
-  foo::
-	@echo INSTALL_SRCDIR=$(INSTALL_SRCDIR)
-	@echo INSTALL_DESTDIR=$(INSTALL_DESTDIR)
-	@echo INSTALL_FILES=$(INSTALL_FILES)
-	@echo INSTALL_IFUNCTION=$(INSTALL_IFUNCTION)
-	@echo INSTALL_TARGETS=$(INSTALL_TARGETS)
-endif
-
-
-
-REAL_DEST=$(INSTALL_DESTDIR)
-
-
-# This target syncs the staging area if something to do so has been
-# defined.  If NOSYNC is defined, skip the whole thing but emit a
-# warning.
-
-.PHONY:: sync-up
-
-ifndef NOSYNC
-    sync-up::
-	$(_sync_staging_)
-else
-    sync-up::
-	@echo "(WARNING: Not syncing staging area.  This could be risky.)"
-endif
-
-
-# ----------------------------------------------------------------------
-#				SUBDIR
-# ----------------------------------------------------------------------
-
-#
-# Make a target in another directory.  The basic format for
-# triggering this dependency is dir-target-subdir, where dir
-# is the name of the subdirectory, target is the name of the
-# target to make and subdir is the word "subdir."  For example:
-#
-#	LIST=foo bar baz
-#	foobarbaz:: $(LIST:%=src/%-clean-subdir)
-#
-# will cause the execution of
-#
-#	make -C foo clean
-#	make -C bar clean
-#	make -C baz clean
-#
-
-ifeq ($(NOSUBDIRS),)
-%-subdir: sync-up
-	$(_stage_subdir_)
-	@$(MAKE) $(MFLAGS) -C $(subst -, , $(subst -subdir,,$@))
-else
-%-subdir:
-	@true
-endif
-
-
-# ----------------------------------------------------------------------
-#			  INSTALL/UNINSTALL
-# ----------------------------------------------------------------------
-
-#
-# By default, the "install" target will place a copy of $(REALTARGET) in
-# a $(DESTDIR), which will be staged if you're in a staging area.
-# 
-# TARGETS_TO_INSTALL - A list of what should be installed.  For example,
-# if you're building a library that installs both the default target and
-# some includes, set this variable to "default includes".  This will do
-# the default installation plus one named "includes."  Set this to N-O-N-E
-# in templates that are just waypoints and don't install anything.
-# 
-# xxx_srcdir - Name of the directory where files to be installed can be
-# found.  This defaults to "./." if none other is specified.
-#
-# xxx_destdir - The directory where target "xxx" is installed, where
-# "xxx" is the name of a target you defined in $(TARGETS_TO_INSTALL).
-#
-# xxx_files - A list of the files that should be installed, where
-# "xxx" is the name of a target you defined in $(TARGETS_TO_INSTALL).
-# 
-# xxx_ifunction - This is the name of a canned function that does the
-# installation of a single file, where "xxx" is the name of a target
-# you defined in $(TARGETS_TO_INSTALL).  The function should be set up
-# such that the word WHAT_TO_INSTALL may be replaced with a list of
-# one or more files to install.  The macro $(DESTDIR) will indicate where
-# the files should be installed.  If you want to use the default installation
-# method, set this to _default_install_.
-#
-
-#
-# This is the default installation method, used if none other is
-# specified.
-#
-
-ifeq ($(TARGETS_TO_INSTALL),)
-  TARGETS_TO_INSTALL = default
-else
-  ifeq ($(TARGETS_TO_INSTALL),N-O-N-E)
-    TARGETS_TO_INSTALL=
-  endif
-endif
-
-# The default installation target
-
-default_srcdir = $(patsubst %/,%,$(dir $(REALTARGET)))
-default_destdir = $(DESTDIR)
-default_files = $(notdir $(REALTARGET))
-default_ifunction=_default_install_
-define _default_install_
-  $(INSTALL) -c -m 554 WHAT_TO_INSTALL $(INSTALL_DESTDIR)
-endef
-
-# This is the actual "install" target, which builds everything, takes
-# whatever's in $(TARGETS_TO_INSTALL) and creates dependencies on the
-# generalized %-install rule, which actually does the dirty work.
-
-.PHONY:: install
-
-install:: all sync-up $(addsuffix -install,$(TARGETS_TO_INSTALL))
-
-#
-# This is the generalized installation rule.  If INSTALL_PREFIX has not
-# been defined, do a recursive make of the target with INSTALL_PREFIX set
-# to the target name.  This makes INSTALL_xxx point at the proper rules.
-# Otherwise, install each file individually.
-#
-
-ifeq ($(INSTALL_PREFIX),)
-
-  %-install::
-	@$(MAKE) $(MFLAGS) NODEPS=1 \
-		INSTALL_PREFIX=$(firstword $(subst -, ,$@)) \
-		make-and-stage $(IMPORTANT_FILE) \
-		$(firstword $(subst -, ,$@))-install
-
-else
-
-  .PHONY:: $(INSTALL_PREFIX)-install
-
-  # Install files only if the destination directory isn't "."
-
-  ifneq ($(INSTALL_DESTDIR),.)
-
-    INSTALLS=$(addprefix $(INSTALL_DESTDIR)/,$(INSTALL_FILES))
-
-
-    $(INSTALL_PREFIX)-install:: $(INSTALLS)
-
-    # This removes a file if it is a symbolic link.
-
-    %-unlink::
-	@if test -h $(INSTALL_DESTDIR)/$(firstword $(subst -, ,$@)) ; \
-		then \
-			$(RM) $(INSTALL_DESTDIR)/$(firstword $(subst -, ,$@)) ; \
-		fi
-  else
-
-    $(INSTALL_PREFIX)-install::
-	@echo "(Destination directory is . -- Install not done.)"
-
-  endif
-
-endif
-
-
-#
-# This dependency installs a single file if the original is newer than
-# the installed version.
-#
-
-ifneq ($(INSTALL_DESTDIR),)
-$(INSTALL_DESTDIR)/%: $(INSTALL_SRCDIR)/%
-	$($(INSTALL_IFUNCTION):WHAT_TO_INSTALL=$<)
-endif
-
-
-#
-# This target creates $(REAL_DEST) and, if we're using a baseline control
-# system, stages it.
-#
-
-.PHONY:: make-and-stage
-
-ifneq ($(INSTALL_DESTDIR),.)
-  make-and-stage::
-	$(MK)/../bin/cc_mkdir $(REAL_DEST)
-	$(_stage_destdir_)
-else
-  make-and-stage::
-	@true
-endif
-
-
-#
-# Uninstall works a lot like install, except that it removes the installed
-# files and does nothing else.
-#
-.PHONY:: uninstall stageall
-
-stageall::
-	$(_stage_all_destdirs_)
-
-uninstall:: stageall $(addsuffix -uninstall,$(TARGETS_TO_INSTALL))
-
-%-uninstall::
-	$(RM) $(foreach FILE,$($(firstword $(subst -, ,$@))_files),\
-		$($(firstword $(subst -, ,$@))_destdir)/$(FILE))
-
-
-# ----------------------------------------------------------------------
-#				CLEAN
-# ----------------------------------------------------------------------
-
-#
-# clean - Wipe out anything that can be re-made.  If CLEAN_FILES is not
-# defined, we have an older, non-fully-defined template.  Otherwise, fall
-# back on the previous method.
-#
-ifneq ($(CLEAN),)
-clean::
-	-$(RM) $(ARG_QUOTES)$(REALTARGET) $(CLEAN_DEFAULTS) $(CLEAN) $(XCLEAN)$(ARG_QUOTES)
-
-else
-clean::
-	-$(RM) $(ARG_QUOTES)$(REALTARGET) $(CLEAN_DEFAULTS) *.[od] $(OBJDIR)/*.[od] *.tmp* *.obj$(ARG_QUOTES)
-endif
-
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/android.mk b/tools_v2/build/make_nr/tools_v2/build/make/android.mk
new file mode 100644
index 0000000..9e20fc5
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/android.mk
@@ -0,0 +1,268 @@
+# $(info within android.mk)
+
+############################################################################
+#
+#  General rules to make and clean
+#
+
+
+
+############################################################################
+############################################################################
+
+# macro to define printf.  This macro needs to be able to handle
+# backslash-escaped characters such as \t(tab), \n(newline),etc.
+# "echo -e" handles this but certain shells such as dash (on ubuntu)
+# don't handle the -e option in their builtin echo implementation.
+# However, the printf builtin of these sh shells should work.
+PRINTF:=printf
+
+############################################################################
+esc_dollar := \$$
+
+
+############################################################################
+# Original method using multiple echo statements separated by ';', but this 
+# seemed much less efficient then putting it into one statement.  
+# See second version below.
+#define output_list
+#$(foreach elem,$(call truncate,$1),$(PRINTF) "\t$(elem) \\" >> $2;) $(PRINTF) "\t$(lastword $1)\\n" >> $2
+#endef
+
+
+
+define output_list
+  $(PRINTF) "$(foreach elem,$(call truncate,$1),\\t$(elem) \\\\\n) \\t$(lastword $1)\\n" >> $2
+endef
+
+define output_lib_list
+  $(PRINTF) "$(foreach elem,$(call truncate,$1),\\tlib$(elem) \\\\\n) \\tlib$(lastword $1)\\n" >> $2
+endef
+
+define format_shared_lib_names
+  $(subst -l,lib,$1)
+endef
+
+define convert_component_lib_makefile_name
+  $(patsubst %,%/Android.mk,$(patsubst $(SRC_ROOT)/%,\$$(PV_TOP)/%,$1))
+endef
+
+define output_include_list
+  $(PRINTF) "$(subst $(SPACE)include,include,$(foreach elem,$(call truncate,$(strip $1)),include $(call convert_component_lib_makefile_name,$(elem))\\n))include $(call convert_component_lib_makefile_name,$(lastword $(strip $1)))\\n" >> $2  
+endef
+
+define include_staticlibs_list
+  $(if $(strip $(call remove_quotes,$1)),$(PRINTF) "$(foreach elem, $(call strip_two_levels_up,$(strip $(call remove_quotes,$1))/local.mk),include $(patsubst %,%/Android.mk,$(patsubst %,\$$(PV_TOP)%,$(strip $(elem))))\n)" >> $2,)
+endef
+
+define output_assembly_srcs
+  $(if $(strip $1),$(PRINTF) "ifeq (\$$(TARGET_ARCH),arm)\\nLOCAL_SRC_FILES += \\\\\n$(foreach elem,$(call truncate,$1),\\t$(elem) \\\\\n)\\t$(lastword $1)\\nendif\\n\\n" >> $2,)
+endef
+
+define extra_lib_list
+  $(if $(strip $1),$(PRINTF) "\nLOCAL_WHOLE_STATIC_LIBRARIES += $1\n" >> $2,)
+endef
+
+define extra_include_list
+  $(if $(strip $1),$(PRINTF) "$(foreach elem, $1,include $(patsubst %,%/Android.mk,$(patsubst %,\$$(PV_TOP)%,$(strip $(elem))))\n)" >> $2,)
+endef
+
+############################################################################
+
+
+include $(MK)/android_segments.mk
+
+#############################################
+#    Rules for aggregate makefiles
+#
+ifneq ($(AGGREGATE_LIBS_MAKEFILE),)
+
+#### Start generation of aggregate makefiles #######
+define create_aggregate_lib_android_mk
+Android_$1.mk: FORCE
+	$$(quiet) echo "LOCAL_PATH := $$(esc_dollar)(call my-dir)" > $$@
+	$$(quiet) echo "include $$(esc_dollar)(CLEAR_VARS)" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "LOCAL_WHOLE_STATIC_LIBRARIES := \\" >> $$@
+	$$(quiet) $$(call output_lib_list,$$($1_CUMULATIVE_TARGET_LIST),$$@)
+	$$(quiet) $$(call extra_lib_list, $$(EXTRA_LIBS_$1),$$@)
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "LOCAL_MODULE := lib$1" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "-include $$(esc_dollar)(PV_TOP)/Android_platform_extras.mk" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "-include $$(esc_dollar)(PV_TOP)/Android_system_extras.mk" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "LOCAL_SHARED_LIBRARIES += $$(call format_shared_lib_names,$$(MODS_$1))" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "include $$(esc_dollar)(BUILD_SHARED_LIBRARY)" >> $$@
+	$$(quiet) $$(call output_include_list,$$($1_CUMULATIVE_MAKEFILES),$$@)
+	$$(quiet) $$(call extra_include_list, $$(EXTRA_MAKEFILES_PATHS_$1),$$@)
+	$$(quiet) echo "" >> $$@
+endef
+
+#### End generation of aggregate makefiles #######
+
+
+
+#### Start generation of top level makefile #######
+
+define include_module_mk_list
+ $(PRINTF) "$(subst $(SPACE)include,include,$(foreach elem,$1,include \$$(PV_TOP)/build_config/opencore_dynamic/Android_$(elem).mk\n))" >> $2
+endef
+
+define include_test_mk_list
+ $(PRINTF) "$(subst $(SPACE)include,include,$(foreach app,$(strip $(call remove_quotes,$(TESTAPPS))),include \$$(PV_TOP)$(strip $(call strip_two_levels_up,$(call remove_quotes,$(TESTAPP_DIR_$(app))/local.mk)))/Android.mk\n))" >> $1
+endef
+
+define create_toplevel_android_mk
+$1: FORCE
+	$$(quiet) echo "ifneq ($$(esc_dollar)(BUILD_WITHOUT_PV),true)" > $$@
+	$$(quiet) echo "LOCAL_PATH := $$(esc_dollar)(call my-dir)" >> $$@
+	$$(quiet) echo "include $$(esc_dollar)(CLEAR_VARS)" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "PV_CFLAGS := -Wno-non-virtual-dtor -DENABLE_MEMORY_PLAYBACK -DUSE_CML2_CONFIG" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "ifeq ($$(esc_dollar)(ENABLE_PV_LOGGING),1)" >> $$@
+	$$(quiet) echo " PV_CFLAGS += -DPVLOGGER_INST_LEVEL=5" >> $$@
+	$$(quiet) echo "endif"  >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "ifeq ($$(esc_dollar)(TARGET_ARCH),arm)" >> $$@
+	$$(quiet) echo "  PV_CFLAGS += -DPV_ARM_GCC_V5" >> $$@
+	$$(quiet) echo "endif"  >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "include $$(esc_dollar)(CLEAR_VARS)" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "PV_TOP := extlibs/opencore" >> $$@
+	$$(quiet) echo "FORMAT := nj" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "PV_COPY_HEADERS_TO := libpv" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "PV_INCLUDES := \\" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/android \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/extern_libs_v2/khronos/openmax/include \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/engines/common/include \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/engines/player/config/linux_nj \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/engines/player/include \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/nodes/pvmediaoutputnode/include \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/nodes/pvdownloadmanagernode/config/opencore \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/pvmi/pvmf/include \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/fileformats/mp4/parser/config/opencore \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/oscl/oscl/config/linux_nj \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/oscl/oscl/config/shared \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/engines/author/include \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/android/drm/oma1/src \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(PV_TOP)/build_config/opencore_dynamic \\\\\n" >> $$@
+	$$(quiet) $(PRINTF) "\t$$(esc_dollar)(TARGET_OUT_HEADERS)/$$(esc_dollar)(PV_COPY_HEADERS_TO)" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) echo "$$(esc_dollar)(call add-prebuilt-files, ETC, pvplayer.cfg)" >> $$@
+	$$(quiet) echo "" >> $$@
+	$$(quiet) $$(call include_module_mk_list,$2,$$@)
+	$$(quiet) $$(call include_staticlibs_list,$$(LIBDIR_static),$$@)
+	$$(quiet) $$(call include_test_mk_list,$$@)
+	$$(quiet) echo "endif" >> $$@
+endef
+#### End generation of top level makefile #######
+
+
+# loop over all the names in SHARED_LIB_TARGET_LIST and 
+#  create the Android makefile name list.
+#  Append top-level Android.mk
+ANDROID_TOPLEVEL_MAKE_NAME := Android.mk
+ANDROID_MAKE_NAMES := $(patsubst %,Android_%.mk,$(SHARED_LIB_TARGET_LIST)) $(ANDROID_TOPLEVEL_MAKE_NAME)
+
+$(strip $(foreach lib,$(SHARED_LIB_TARGET_LIST),$(eval $(call create_aggregate_lib_android_mk,$(lib)))))
+
+$(eval $(call create_toplevel_android_mk,$(ANDROID_TOPLEVEL_MAKE_NAME),$(SHARED_LIB_TARGET_LIST)))
+
+android_clean: modulelevel_android_mk_clean toplevel_android_mk_clean
+
+modulelevel_android_mk_clean: ANDROID_MAKE_FILES_TO_CLEAN := $(ANDROID_MAKE_NAMES) 
+toplevel_android_mk_clean: ANDROID_MAKE_FILES_TO_CLEAN += $(ANDROID_TOPLEVEL_MAKE_NAME)
+
+modulelevel_android_mk_clean: FORCE
+	$(quiet) $(RM) $(ANDROID_MAKE_FILES_TO_CLEAN)
+
+toplevel_android_mk_clean: FORCE
+	$(quiet) $(RM) $(ANDROID_TOPLEVEL_MAKE_NAME)
+
+#############################################
+#    Rules for a single library makefile
+#
+else
+
+ifeq ($(LOCAL_ANDROID_MK_PATH),)
+  LOCAL_ANDROID_MK_PATH := $(patsubst /%,%,$(call strip_two_levels_up,$(subst $(SRC_ROOT),$$(SRC_ROOT),$(strip $(LOCAL_PATH)))/local.mk))
+endif
+
+CUMULATIVE_ANDROID_MK_PATH := $(CUMULATIVE_ANDROID_MK_PATH) $(LOCAL_ANDROID_MK_PATH)
+
+define include_system_extras
+  $(if $(strip $(filter $1,BUILD_EXECUTABLE)),$(PRINTF) "\n-include \$$(PV_TOP)/Android_system_extras.mk\n" >> $2,)
+endef
+
+#$(eval ANDROID_MAKE_NAMES := $(LOCAL_ANDROID_MK_PATH)/Android.mk)
+ANDROID_MAKE_NAMES := $(LOCAL_PATH)/../../Android.mk
+
+ANDROID_TMP_LOCAL_INC := $(subst $(SRC_ROOT),\$$(PV_TOP),$(LOCAL_TOTAL_INCDIRS)) \$$(PV_INCLUDES)
+
+ANDROID_PATH_COMPONENTS := $(subst /, ,$(LOCAL_PATH))
+
+AND_LOCAL_ARM_MODE := $(if $(strip $(filter codecs_v2,$(ANDROID_PATH_COMPONENTS))),LOCAL_ARM_MODE := arm,)
+
+$(ANDROID_MAKE_NAMES): ANDROID_CPP_SRCS := $(if $(strip $(SRCS)),$(patsubst %,$(call go_up_two_levels,$(SRCDIR))/%,$(filter %.cpp,$(SRCS))),)
+$(ANDROID_MAKE_NAMES): ANDROID_ASM_SRCS := $(if $(strip $(SRCS)),$(patsubst %,$(call go_up_two_levels,$(SRCDIR))/%,$(filter-out %.cpp,$(SRCS))),)
+$(ANDROID_MAKE_NAMES): ANDROID_TARGET := $(if $(strip $(filter prog,$(TARGET_TYPE))),"LOCAL_MODULE :=" $(TARGET),$(if $(strip $(TARGET)),"LOCAL_MODULE :=" lib$(TARGET),))
+$(ANDROID_MAKE_NAMES): ANDROID_HDRS := $(patsubst %,$(call go_up_two_levels,$(INCSRCDIR))/%,$(HDRS))
+$(ANDROID_MAKE_NAMES): ANDROID_C_FLAGS := $(filter-out %PV_ARM_GCC_V5,$(XCPPFLAGS))
+$(ANDROID_MAKE_NAMES): ANDROID_C_INC := $(ANDROID_TMP_LOCAL_INC)
+$(ANDROID_MAKE_NAMES): ANDROID_ARM_MODE := $(AND_LOCAL_ARM_MODE)
+$(ANDROID_MAKE_NAMES): ANDROID_MAKE_TYPE := $(if $(strip $(filter prog,$(TARGET_TYPE))),BUILD_EXECUTABLE,$(if $(strip $(SRCS)),BUILD_STATIC_LIBRARY,BUILD_COPY_HEADERS))
+$(ANDROID_MAKE_NAMES): ANDROID_STATIC_LIBS := $(foreach library,$(LIBS),$(if $(findstring $(strip $(BUILD_ROOT)/installed_lib/$(BUILD_ARCH)/lib$(library)$(TARGET_NAME_SUFFIX).a), $(ALL_LIBS)),lib$(library),))
+$(ANDROID_MAKE_NAMES): ANDROID_SHARED_LIBS := $(foreach library,$(LIBS),$(if $(findstring $(strip $(BUILD_ROOT)/installed_lib/$(BUILD_ARCH)/lib$(library)$(TARGET_NAME_SUFFIX).so), $(SHARED_LIB_FULLNAMES)),lib$(library),))
+
+$(ANDROID_MAKE_NAMES): FORCE
+	$(quiet) echo "LOCAL_PATH := \$$(call my-dir)" > $@
+	$(quiet) echo "include \$$(CLEAR_VARS)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_SRC_FILES := \\" >> $@
+	$(quiet) $(call output_list,$(ANDROID_CPP_SRCS),$@)
+	$(quiet) echo "" >> $@
+	$(quiet) $(call output_assembly_srcs,$(ANDROID_ASM_SRCS),$@)
+	$(quiet) echo "" >> $@
+	$(quiet) echo "$(ANDROID_TARGET)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_CFLAGS := $(ANDROID_C_FLAGS) \$$(PV_CFLAGS)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "$(ANDROID_ARM_MODE)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_STATIC_LIBRARIES := $(ANDROID_STATIC_LIBS)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_SHARED_LIBRARIES := $(ANDROID_SHARED_LIBS)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_C_INCLUDES := \\" >> $@
+	$(quiet) $(call output_list,$(ANDROID_C_INC),$@)
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_COPY_HEADERS_TO := \$$(PV_COPY_HEADERS_TO)" >> $@
+	$(quiet) echo "" >> $@
+	$(quiet) echo "LOCAL_COPY_HEADERS := \\" >> $@
+	$(quiet) $(call output_list,$(ANDROID_HDRS),$@)
+	$(quiet) $(call include_system_extras,$(ANDROID_MAKE_TYPE),$@)
+	$(quiet) echo "" >> $@
+	$(quiet) echo "include \$$($(ANDROID_MAKE_TYPE))" >> $@
+
+android_clean: $(LOCAL_PATH)_android_mk_clean
+
+$(LOCAL_PATH)_android_mk_clean: ANDROID_MAKE_FILES_TO_CLEAN := $(ANDROID_MAKE_NAMES)
+
+$(LOCAL_PATH)_android_mk_clean: FORCE
+	$(quiet) $(RM) $(ANDROID_MAKE_FILES_TO_CLEAN)
+
+
+endif
+
+
+android_make: $(ANDROID_MAKE_NAMES)
+CMD_COMPLETION_TARGETS += android_make android_clean
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/android_segments.mk b/tools_v2/build/make_nr/tools_v2/build/make/android_segments.mk
new file mode 100644
index 0000000..43a8c7e
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/android_segments.mk
@@ -0,0 +1,8 @@
+
+EXTRA_LIBS_opencore_player := libandroidpv
+EXTRA_MAKEFILES_PATHS_opencore_player := /android
+
+EXTRA_LIBS_opencore_author := libandroidpvauthor
+EXTRA_MAKEFILES_PATHS_opencore_author := /android/author
+
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/basic_defs.mk b/tools_v2/build/make_nr/tools_v2/build/make/basic_defs.mk
new file mode 100644
index 0000000..fd24a97
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/basic_defs.mk
@@ -0,0 +1,83 @@
+# Function that returns the path information of the makefile.
+# For this to work reliably, it must be called within the local
+# makefile before any other include statements.
+define get_makefile_dir
+   $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
+endef
+
+# The definitions below give the basic definition of a space 
+# which is useful in subst calls where it is desirable to remove spaces.
+SPACE:=
+SPACE+=
+
+# template to clean up strings by removing quotes
+define remove_quotes
+$(strip $(subst ",,$1))
+endef
+
+# Simple function to clear a variable
+define clearvar
+endef
+
+# Simple function to process a string containing a list of makefile fragments
+# to include
+define process_include_list
+$(patsubst %,$1/%,$(call remove_quotes,$2))
+endef
+
+# Simple function to process a string containing a list of 
+# preprocessor macros
+define process_config_macros
+$(patsubst %,-D%,$(call remove_quotes,$1))
+endef
+
+
+
+# Function returns a list with one fewer elements.  
+# The last element is dropped.
+truncate = $(wordlist 2,$(words $1),x $1)
+
+
+# Function removes duplicate entries in a list without changing the order
+purge_duplicates = $(strip $(if $1,$(call purge_duplicates,$(call truncate,$1)) $(if $(filter $(lastword $1),$(call truncate,$1)),,$(lastword $1))))
+
+ifeq ($(strip $(RELEASE)),1)
+  $(info Building in release mode)
+   DEFAULT_LIBMODE := release
+else
+   DEFAULT_LIBMODE := debug
+endif
+
+
+# Function to remove two levels of directories
+define strip_two_levels_up
+ $(foreach path,$(dir $(1)),$(patsubst %,/%,$(subst $(SPACE),/,$(call truncate,$(call truncate,$(subst /, ,$(path))))))) 
+endef
+
+# Function to remove ../../
+define go_up_two_levels
+  $(patsubst ../../%,%,$1)
+endef
+
+# Utility functions
+[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #
+[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z #
+
+# replace delimiter with space, so that it can be split
+# split(delimiter, string)
+split = $(strip $(subst $1, ,$2))
+
+# translate character list in traslate-from to corresponding translate-to in string/text
+# translate(translate-from, translate-to, string)
+translate = $(strip $(eval tmp := $3) $(foreach c, $(join $(addsuffix :,$1),$2),       \
+     $(eval tmp := $(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \
+     $(tmp))))$(tmp))
+
+# converts string into uppercase
+# uppercase(string)
+uppercase = $(call translate,$([a-z]),$([A-Z]),$1)
+
+# converts string into lowercase
+# lowercase(string)
+lowercase = $(call translate,$([A-Z]),$([a-z]),$1)
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/clear.mk b/tools_v2/build/make_nr/tools_v2/build/make/clear.mk
new file mode 100644
index 0000000..a2861ba
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/clear.mk
@@ -0,0 +1,21 @@
+WHAT := 
+TARGET :=
+SRCDIR :=
+INCSRCDIR :=
+LOCAL_SRCDIR :=
+LOCAL_INCSRCDIR :=
+SRCS := 
+HDRS := 
+LIBS :=
+XINCDIRS := 
+XLIBDIRS := 
+XLDFLAGS := 
+XCPPFLAGS := 
+XCXXFLAGS := 
+COMPILED_OBJS :=
+OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE :=
+TARGET_TYPE :=
+LOCAL_MAKEFILES_LIST :=
+LOCAL_ANDROID_MK_PATH :=
+TEST_ARGS :=
+SOURCE_ARGS :=
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/cml2_shared.mk b/tools_v2/build/make_nr/tools_v2/build/make/cml2_shared.mk
new file mode 100644
index 0000000..f49c132
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/cml2_shared.mk
@@ -0,0 +1,85 @@
+# Get the current local path as the first operation
+SHARED_LIB_LOCAL_PATH := $(call get_makefile_dir)
+
+
+# create a rule to install the CML2 config header
+$(eval $(call HDRINST_TEMPLATE,pv_config.h,$(abspath $(CFG_DIR)),$(INCDESTDIR)))
+
+$(INCDESTDIR)/ALL_HDRS_INSTALLED: $(INCDESTDIR)/pv_config.h
+
+
+define process_aggregate_shared_lib_target
+$(eval CUMULATIVE_TARGET_LIST:= $(call clearvar))
+$(eval CUMULATIVE_ANDROID_MK_PATH := $(call clearvar))
+$(eval COMPONENT_MAKEFILES:= $(patsubst %,$(SRC_ROOT)%,$(patsubst %,%/local.mk,$(call remove_quotes,$(SOLIBDIRS_$1)))))
+$(eval SOLIB:=$1)
+$(eval include $(COMPONENT_MAKEFILES))
+$(eval $1_CUMULATIVE_TARGET_LIST := $(CUMULATIVE_TARGET_LIST))
+$(eval $1_CUMULATIVE_MAKEFILES := $(strip $(CUMULATIVE_ANDROID_MK_PATH)))
+endef
+
+define shared_lib_template
+# Pseudo-targets for libraries. With this, we can use "make lib$(TARGET)" instead of "make $(DESTDIR)/lib%$(TARGET_NAME_SUFFIX).$(LIB_EXT)"
+# # E.g., make libpvplayer
+lib$(1): $(DESTDIR)/lib$(1)$(TARGET_NAME_SUFFIX).$(SHARED_LIB_EXT)
+$(DESTDIR)/lib$(1)$(TARGET_NAME_SUFFIX).$(SHARED_LIB_EXT): $(foreach lib,$($(1)_CUMULATIVE_TARGET_LIST),$($(lib)_$(1)_fullname)) $(foreach shlib,$(strip $(call remove_quotes,$(MODS_$(1)))),$(patsubst -l%,$(DESTDIR)/lib%$(TARGET_NAME_SUFFIX).$(SHARED_LIB_EXT),$(shlib)))
+	$(eval $(1)_fullname:=$(DESTDIR)/lib$1$(TARGET_NAME_SUFFIX).$(SHARED_LIB_EXT))
+	@echo "Building $$@..."
+	$$(call create_objdir,$$(@D))
+	$$(call generate_shared_lib,$$@,$$^)
+	@echo "DONE building $$@."
+endef
+
+# process the elements of TARGET_shared
+SHARED_LIB_TARGET_LIST := $(call remove_quotes,$(TARGET_shared))
+# process the elements of TESTAPPS
+APP_TARGET_LIST := $(call remove_quotes,$(TESTAPPS))
+#process the elements of LIBS-static
+STATIC_LIBS_TARGET_LIST := $(patsubst -l%,%,$(call remove_quotes,$(LIBS_static)))
+
+
+#################
+# set the default library mode to shared-archive
+DEFAULT_LIBTYPE := shared-archive
+$(strip $(foreach target,$(SHARED_LIB_TARGET_LIST),$(call process_aggregate_shared_lib_target,$(target))))
+
+$(foreach lib,$(SHARED_LIB_TARGET_LIST),$(eval $(call shared_lib_template,$(lib))))
+SHARED_LIB_FULLNAMES := $(patsubst %,$(DESTDIR)/%, $(patsubst %,lib%$(TARGET_NAME_SUFFIX).$(SHARED_LIB_EXT),$(SHARED_LIB_TARGET_LIST)))
+
+#################
+define lib_include_template
+	$(eval $1_MAKEFILE := $(patsubst %,$(SRC_ROOT)%,$(patsubst %,%/local.mk,$1)))
+	$(eval include $($1_MAKEFILE))
+endef
+
+# set the default library mode to static [Is this needed?]
+DEFAULT_LIBTYPE := static
+$(foreach mk,$(strip $(call remove_quotes,$(LIBDIR_static))),$(eval $(call lib_include_template,$(mk))))
+ALL_LIBS := $(patsubst %,$(DESTDIR)/%, $(patsubst %,lib%$(TARGET_NAME_SUFFIX).$(STAT_LIB_EXT),$(STATIC_LIBS_TARGET_LIST)))
+
+#################
+define mk_include_template
+	$(eval $1_MAKEFILE := $(patsubst %,$(SRC_ROOT)%,$(patsubst %,%/local.mk,$(call remove_quotes,$(TESTAPP_DIR_$1)))))
+	$(eval include $($1_MAKEFILE))
+endef
+
+# include test app makefiles 
+$(foreach mk,$(strip $(call remove_quotes,$(APP_TARGET_LIST))),$(eval $(call mk_include_template,$(mk))))
+ALL_BINS := $(patsubst %,$(BUILD_ROOT)/bin/$(OUTPUT_DIR_COMPONENT)/%$(TARGET_EXT),$(APP_TARGET_LIST))
+#################
+
+
+CMD_COMPLETION_TARGETS += $(patsubst %,lib%,$(SHARED_LIB_TARGET_LIST) $(STATIC_LIBS_TARGET_LIST)) $(APP_TARGET_LIST)
+
+default: all 
+
+all: shared static $(ALL_BINS)
+
+shared: $(SHARED_LIB_FULLNAMES) 
+static: $(ALL_LIBS)
+
+
+
+LOCAL_PATH := $(SHARED_LIB_LOCAL_PATH)
+AGGREGATE_LIBS_MAKEFILE := 1
+-include $(PLATFORM_EXTRAS)
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/doc.mk b/tools_v2/build/make_nr/tools_v2/build/make/doc.mk
new file mode 100644
index 0000000..4098b45
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/doc.mk
@@ -0,0 +1,15 @@
+# This makefile will generate documents from a set of header files
+
+# The following variables are specific to the SDK and should be defined locally:
+# doc_target
+# doc_title
+# doc_paths
+# doc_version
+
+doc_$(doc_target): doc_rule_target := $(doc_target)
+doc_$(doc_target): doc_rule_title := $(doc_title)
+doc_$(doc_target): doc_rule_paths := $(doc_paths)
+doc_$(doc_target): doc_rule_version := $(doc_version)
+
+doc_$(doc_target):
+	perl $(SRC_ROOT)/tools_v2/build/document/bin/doc_build.bat --doctype $(doc_rule_target) --title $(doc_rule_title) --path $(doc_rule_paths) --filetype "mainpage *.h readme.txt" --exclude_pattern "*/test/* */obsolete/* */doxydir/*" -ver $(doc_rule_version)
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/entry_point.mk b/tools_v2/build/make_nr/tools_v2/build/make/entry_point.mk
new file mode 100644
index 0000000..2bed897
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/entry_point.mk
@@ -0,0 +1,259 @@
+
+$(if $(filter $(MAKE_VERSION),3.81),,\
+  $(error These makefile templates requires GNU make version 3.81.))
+
+default: 
+
+.PHONY:: FORCE
+
+FORCE:
+
+ifeq ($(strip $(SHOW_CMDS)),)
+quiet := @
+else
+quiet := 
+endif
+
+include $(MK)/basic_defs.mk
+
+#########################################################
+
+# $(call normalize_path,path)
+define normalize_path
+	$(subst \,/,$1)
+endef
+
+
+SRC_ROOT ?= $(PROJECT_DIR)
+
+SRC_ROOT := $(strip $(call normalize_path,$(SRC_ROOT)))
+
+# $(info Entry point curdir = $(CURDIR))
+
+define install-hdr
+  $(quiet) $(INSTALL) $(INSTALL_OPTS) $(1) $(2)
+endef
+
+
+
+
+define OBJ_TEMPLATE
+$(2)/%.$(OBJ_EXT): $(1)/%.cpp
+	$$(call make-cpp-obj-and-depend,$$<,$$@,$$(subst .$(OBJ_EXT),.d,$$@),$$(XFLAGS))
+
+$(2)/%.$(OBJ_EXT): $(1)/%.s
+	$$(call make-asm-obj,$$<,$$@,$$(subst .$(OBJ_EXT),.d,$$@),$$(XFLAGS))
+
+$(2)/%.$(OBJ_EXT): $(1)/%.c
+	$$(call make-c-obj-and-depend,$$<,$$@,$$(subst .$(OBJ_EXT),.d,$$@),$$(XFLAGS))
+endef
+
+
+HOST_ARCH := $(shell uname)
+ifeq ($(HOST_ARCH),Linux)
+    HOST_ARCH := linux
+endif
+ifeq ($(HOST_ARCH),WindowsNT)
+    HOST_ARCH := win32
+endif
+
+
+ifndef ARCHITECTURE
+ ifdef ARCH
+   ARCHITECTURE := $(ARCH)
+ else
+   ARCHITECTURE := $(HOST_ARCH)
+ endif
+endif
+
+BUILD_ARCH := $(ARCHITECTURE)
+
+include $(MK)/$(HOST_ARCH).mk
+
+include $(MK)/$(TOOLSET).mk
+
+# optionally include platform settings
+-include $(MK)/platforms/$(BUILD_ARCH).mk
+
+
+ifeq ($(strip $(BUILD_TARGET)),)
+  OUTPUT_DIR_COMPONENT := $(BUILD_ARCH)
+else
+  OUTPUT_DIR_COMPONENT := $(BUILD_ARCH)/$(BUILD_TARGET)
+endif
+
+BUILD_ROOT := $(subst \,/,$(BUILD_ROOT))
+SRC_ROOT   := $(strip $(call clean-path,$(SRC_ROOT)))
+BUILD_ROOT := $(strip $(call clean-path,$(BUILD_ROOT)))
+
+
+$(if $(findstring $(SRC_ROOT),$(CURDIR)),,$(error The source root, $(SRC_ROOT), is not a prefix of the current dir $(CURDIR)))
+
+DESTDIR := $(BUILD_ROOT)/installed_lib/$(OUTPUT_DIR_COMPONENT)
+INCDESTDIR := $(subst \,/,$(BUILD_ROOT)/installed_include)
+
+ifneq ($(strip $(MK_INFO)),)
+$(info HOST_ARCH = $(HOST_ARCH))
+$(info BUILD_ARCH = $(BUILD_ARCH))
+ifneq (strip($(BUILD_TARGET)),)
+$(info BUILD_TARGET = $(BUILD_TARGET))
+endif
+$(info TOOLSET = $(TOOLSET))
+$(info BUILD_ROOT = $(BUILD_ROOT))
+$(info INCDESTDIR = $(INCDESTDIR))
+endif
+
+# $(call delete_file,file_name)
+define delete_file
+	$(shell $(RM) $1)
+endef
+
+# $(call create_objdir,$(@D))
+define create_objdir
+	$(shell $(MKDIR) $1)
+endef
+
+$(INCDESTDIR)/ALL_HDRS_INSTALLED:
+	@echo Making sure all headers are installed...
+	$(call create_objdir,$(@D))
+	$(quiet) touch $@
+
+$(DESTDIR)/ALL_LIBS_INSTALLED:
+	@echo Making sure all libs are installed...
+	$(quiet) touch $@
+
+
+ifneq ($(strip $(BUILD_ROOT)),)
+clean::
+	$(quiet) $(RMDIR) $(BUILD_ROOT)
+endif
+CMD_COMPLETION_TARGETS += clean
+
+define generate_dep
+	@echo "\$$(warning reading DEP)" > DEP
+endef
+
+
+ifneq "$(MAKECMDGOALS)" "clean"
+  ifneq "$(MAKECMDGOALS)" "completion_targets"
+    ifneq "$(MAKECMDGOALS)" "android_make"
+      # include ALL_HDR_INSTALLED file
+      include $(INCDESTDIR)/ALL_HDRS_INSTALLED
+    endif
+  endif
+endif
+
+
+#########################################################
+
+#ifeq ($(strip $(COMBINED_COMPILE_AND_DEPEND)),)
+ifndef combined-cxx-compile-depend
+  $(info default definition of combined-cxx-compile-depend)
+  define combined-cxx-compile-depend
+    $(call make-depend,$1,$2,$3,$4)
+    $(quiet) $(CXX) $4 $(CPPFLAGS) $(INCDIRS) $(CXXFLAGS) $(CO)$2 $1
+  endef
+endif
+
+
+# $(call make-cpp-obj-and-depend,source-file,object-file,depend-file,xflags)
+define make-cpp-obj-and-depend
+	@echo Building $2
+	@echo Using $1
+	$(call create_objdir,$(@D))
+	$(call combined-cxx-compile-depend,$1,$2,$3,$4)
+	@echo Done
+endef
+
+define make-asm-obj
+	@echo Building $2
+	@echo Using $1
+	$(call create_objdir,$(@D))
+	$(call assembly-compile,$1,$2,$3,$4)
+endef
+# the following was needed to map cygwin paths back to dos shell
+# 	$(quiet) $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(call map_name,$4) $(CO)$(call map_name,$2) $(call map_name,$1)
+
+#########################################################
+
+# ifeq ($(strip $(COMBINED_COMPILE_AND_DEPEND)),)
+ifndef combined-cc-compile-depend
+  $(info default definition of combined-cc-compile-depend)
+  define combined-cc-compile-depend
+    $(call make-depend,$1,$2,$3,$4)
+    $(quiet) $(CC) $4 $(CPPFLAGS) $(INCDIRS) $(CXXFLAGS) $(CO)$2 $1
+  endef
+endif
+
+
+# $(call make-c-obj-and-depend,source-file,object-file,depend-file,xflags)
+define make-c-obj-and-depend
+	@echo Building $2
+	@echo Using $1
+	$(call create_objdir,$(@D))
+	$(call combined-cc-compile-depend,$1,$2,$3,$4)
+	@echo Done
+endef
+
+#########################################################
+# 
+# gnu-win32 make seems to hold the file handle on the directory open after a wildcard operation
+# and that interfered with removing the directory.
+# Hence we would avoid any wildcard operation in doing make clean.
+#
+define set-src-and-obj-names
+SRC_FILENAMES := $(notdir $1)
+REMOTE_SRCS := $$(filter-out $$(SRC_FILENAMES), $1)
+
+REMOTE_DIRS := $$(sort $$(abspath $$(addprefix $2/,$$(dir $$(REMOTE_SRCS)))))
+
+CSRCS := $$(filter %.c,$$(SRC_FILENAMES))
+CCSRCS := $$(filter %.cc,$$(SRC_FILENAMES))
+CPPSRCS := $$(filter %.cpp,$$(SRC_FILENAMES))
+CXXSRCS := $$(filter %.C,$$(SRC_FILENAMES))
+ASMSRCS := $$(filter %.s,$$(SRC_FILENAMES))
+COBJS  := $$(CSRCS:%.c=$$(OBJDIR)/%.$$(OBJ_EXT))
+CPPOBJS := $$(CPPSRCS:%.cpp=$$(OBJDIR)/%.$$(OBJ_EXT))
+CXXOBJS := $$(CXXSRCS:%.C=$$(OBJDIR)/%.$$(OBJ_EXT))
+CCOBJS := $$(CCSRCS:%.cc=$$(OBJDIR)/%.$$(OBJ_EXT))
+ASMOBJS := $$(ASMSRCS:%.s=$$(OBJDIR)/%.$$(OBJ_EXT))
+COMPILED_OBJS := $$(COBJS) $$(CXXOBJS) $$(CCOBJS) $$(CPPOBJS) $$(ASMOBJS)
+
+DEPS := $$(COMPILED_OBJS:%.$$(OBJ_EXT)=%.d)
+ifneq "$(MAKECMDGOALS)" "clean"
+  FOUND_DEPS := $$(wildcard $$(DEPS))
+endif
+MISSING_DEPS := $$(filter-out $$(FOUND_DEPS), $$(DEPS))
+FORCED_OBJS := $$(MISSING_DEPS:%.d=%.$$(OBJ_EXT))
+
+endef
+
+
+
+
+
+#########################################################
+
+LIB_DIRS += $(LIBCOMPFLAG)$(BUILD_ROOT)/installed_lib/$(OUTPUT_DIR_COMPONENT)
+
+
+
+-include $(MK)/dot.mk
+
+DOCDESTDIR := $(BUILD_ROOT)/doc
+
+docs: $(DOCDESTDIR)/ALL_DOCS_INSTALLED
+
+$(DOCDESTDIR)/ALL_DOCS_INSTALLED: 
+	@echo Making sure all docs are installed...
+	$(call create_objdir,$(@D))
+	$(quiet) touch $@
+
+.PHONY:: docs
+
+
+completion_targets:
+	@echo $(call purge_duplicates,$(CMD_COMPLETION_TARGETS))
+
+.PHONY:: completion_targets
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/g++.mk b/tools_v2/build/make_nr/tools_v2/build/make/g++.mk
new file mode 100644
index 0000000..bf57bc5
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/g++.mk
@@ -0,0 +1,118 @@
+
+CXX ?= g++
+CC ?= gcc
+LINK ?= $(CXX)
+SHARED_LINK ?= $(CXX)
+AR ?= ar
+
+# The following macro will turn on combined
+# compilation and dependency generation
+COMBINED_COMPILE_AND_DEPEND:=1
+
+override SYSLIBS = -lc -lm -ldl -lstdc++ -lpthread
+
+SHARED_CFLAGS ?= -fPIC
+SHARED_CXXFLAGS ?= -fPIC
+SHARED_PRE_LDFLAGS ?= -shared -Wl,-Bsymbolic -Wl,--allow-multiple-definition -Wl,--whole-archive
+SHARED_POST_LDFLAGS ?= -Wl,-no-whole-archive -Wl,--no-undefined $(SYSLIBS)
+SONAME_ARG := -Wl,-h,
+
+AR_ARGS := rl # make sure to leave a space at the end
+
+
+OUTLINKFLAG := -o 
+CO := -c -o # make sure to leave a space at the end
+
+
+#Make all warnings into errors.
+FLAG_COMPILE_WARNINGS_AS_ERRORS := -Werror
+
+STAT_LIB_EXT:=a
+SHARED_LIB_EXT:=so
+SHARED_ARCHIVE_LIB_EXT:=sa
+OBJ_EXT := o
+LIBCOMPFLAG:=-L
+DEBUG_CXXFLAG?=-g
+RELEASE_CXXFLAG?=-DNDEBUG
+OPT_CXXFLAG?=-O3
+INCDIRS += -I$(BUILD_ROOT)/installed_include
+CXXFLAGS?=-Wall -Wno-non-virtual-dtor
+
+#########################################################
+# $(call make-depend,source-file,object-file,depend-file,xflags)
+define make-depend
+  $(quiet) $(CXX) $4 $(CPPFLAGS) $(INCDIRS) $(CXXFLAGS) -MM $1 |        \
+   $(SED) -e 's,\($(notdir $2)\) *:,$2: ,' -e 's,$(BUILD_ROOT),$$(BUILD_ROOT),'  -e 's,$(SRC_ROOT),$$(SRC_ROOT),' > $3.tmp
+  $(quiet) $(CP) $3.tmp $3
+  $(quiet) $(SED) -e 's/#.*//'  \
+	-e 's/^[^:]*: *//'      \
+	-e 's/ *\\$$//'		\
+	-e '/^$$/ d'		\
+	-e 's/$$/ :/'  $3.tmp >> $3
+  $(quiet) $(RM) $3.tmp
+endef
+#########################################################
+
+
+ifneq ($(strip $(COMBINED_COMPILE_AND_DEPEND)),)
+#########################################################
+# $(call combined-cxx-compile-depend,source-file,object-file,depend-file,xflags)
+define combined-cxx-compile-depend
+  $(quiet) $(CXX) $4 $(CPPFLAGS) $(INCDIRS) $(CXXFLAGS) -MMD $(CO)$2 $1
+  $(quiet) $(SED) -e '/^ *\\ *$$/ d' -e 's,$(BUILD_ROOT),$$(BUILD_ROOT),'  -e 's,$(SRC_ROOT),$$(SRC_ROOT),' $3 > $3.tmp
+  $(quiet) $(CP) $3.tmp $3
+  $(quiet) $(SED) -e 's/#.*//'  \
+	-e 's/^[^:]*: *//'      \
+	-e 's/ *\\$$//'		\
+	-e '/^$$/ d'		\
+	-e 's/$$/ :/'  $3.tmp >> $3
+  $(quiet) $(RM) $3.tmp
+endef
+#########################################################
+
+# $(call combined-cc-compile-depend,source-file,object-file,depend-file,xflags)
+define combined-cc-compile-depend
+  $(quiet) $(CC) $4 $(CPPFLAGS) $(INCDIRS) $(CXXFLAGS) -MMD $(CO)$2 $1
+  $(quiet) $(SED) -e '/^ *\\ *$$/ d' -e 's,$(BUILD_ROOT),$$(BUILD_ROOT),'  -e 's,$(SRC_ROOT),$$(SRC_ROOT),' $3 > $3.tmp
+  $(quiet) $(CP) $3.tmp $3
+  $(quiet) $(SED) -e 's/#.*//'  \
+	-e 's/^[^:]*: *//'      \
+	-e 's/ *\\$$//'		\
+	-e '/^$$/ d'		\
+	-e 's/$$/ :/'  $3.tmp >> $3
+  $(quiet) $(RM) $3.tmp
+endef
+#########################################################
+
+define assembly-compile
+  $(quiet) $(CXX) $4 $(CPPFLAGS) $(INCDIRS) $(CXXFLAGS) -MD $(CO)$2 $1
+endef
+#########################################################
+endif
+
+
+#########################################################
+
+define generate_prog
+	$(quiet) $(LINK) $(BINDING) $(OUTLINKFLAG)$1 $($2_compiled_objs) $(filter $(LIBCOMPFLAG)%,$($2_LDFLAGS)) \
+	$(PRE_LDFLAGS) $(XOBJECTS)  $(filter-out $(LIBCOMPFLAG)%,$($2_LDFLAGS)) $(POST_LDFLAGS) $(SYSLIBS)
+endef
+
+#########################################################
+
+define generate_static_lib
+  $(quiet) $(AR) $(AR_ARGS)$1  $2
+endef
+
+#########################################################
+
+define generate_shared-archive_lib
+  $(quiet) $(AR) $(AR_ARGS)$1  $2
+endef
+
+
+#########################################################
+
+define generate_shared_lib
+  $(quiet) $(SHARED_LINK) $(SHARED_PRE_LDFLAGS) $(SONAME_ARG)$(notdir $1) -o $1 $2 $(SHARED_POST_LDFLAGS)
+endef
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/intermediate_level.mk b/tools_v2/build/make_nr/tools_v2/build/make/intermediate_level.mk
new file mode 100644
index 0000000..f49e4a7
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/intermediate_level.mk
@@ -0,0 +1,3 @@
+
+$(strip $(foreach mk,$(strip $(LOCAL_MAKEFILES_LIST)),$(eval include $(mk))))
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/library.mk b/tools_v2/build/make_nr/tools_v2/build/make/library.mk
new file mode 100644
index 0000000..048fc7d
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/library.mk
@@ -0,0 +1,200 @@
+# -*- makefile -*-
+#
+# This makefile template should be included by makefiles in
+# library directories.
+#
+
+# Set the directories for the local sources and headers
+LOCAL_SRCDIR :=  $(abspath $(LOCAL_PATH)/$(SRCDIR))
+TMP_SRCDIR := $(abspath $(LOCAL_PATH)/$(SRCDIR))
+LOCAL_INCSRCDIR :=  $(abspath $(LOCAL_PATH)/$(INCSRCDIR))
+
+#$(info LOCAL_PATH = $(LOCAL_PATH))
+#$(info LOCAL_SRCDIR = $(LOCAL_SRCDIR))
+#$(info TMP_SRCDIR = $(TMP_SRCDIR))
+#$(info LOCAL_INCSRCDIR = $(LOCAL_INCSRCDIR))
+
+
+###########################################################
+#
+# See if there are any plugin files to include
+#
+MY_TARGET_PLUGINS := $($(TARGET)_plugins)
+SOLIB_OBJDIR_COMP :=
+SOLIB_TARGET_COMP :=
+ifeq ($(DEFAULT_LIBTYPE),shared-archive)
+  ifneq ($(strip $(SOLIB)),)
+    SOLIB_TARGET_COMP :=_$(SOLIB)
+    ifneq ($(strip $($(TARGET)_plugins_$(SOLIB))),)
+      MY_TARGET_PLUGINS := $($(TARGET)_plugins_$(SOLIB))
+      SOLIB_OBJDIR_COMP := /$(SOLIB)
+    endif
+  endif
+endif
+
+# $(info plugins to include $(TARGET) = $(MY_TARGET_PLUGINS))
+ifneq ($(strip $(MY_TARGET_PLUGINS)),)
+include $(call process_include_list,$(LOCAL_PATH),$(MY_TARGET_PLUGINS))
+endif
+
+
+#
+# See if there are any additional src files listed. E.g. assembly src files for codecs
+#
+-include $(call process_include_list,$(LOCAL_PATH),$(TOOLSET)_$(PROCESSOR).mk)
+###########################################################
+# Rules for installing the header files
+
+HDR_FILES := $(notdir $(HDRS))
+LOCAL_INSTALLED_HDRS := $(HDR_FILES:%=$(INCDESTDIR)/%)
+
+# $(foreach hdr, $(strip $(HDRS)), $(eval $(call HDRINST_TEMPLATE,$(notdir $(hdr)),$(patsubst %/,%,$(call abspath,$(LOCAL_INCSRCDIR)/$(dir $(hdr)))),$(INCDESTDIR))))
+
+$(foreach hdr, $(strip $(HDRS)), $(eval $(call HDRINST_TEMPLATE,$(notdir $(hdr)),$(patsubst %/,%,$(LOCAL_INCSRCDIR)/$(dir $(hdr))),$(INCDESTDIR))))
+
+# $(info LOCAL_INSTALLED_HDRS = $(LOCAL_INSTALLED_HDRS))
+
+$(INCDESTDIR)/ALL_HDRS_INSTALLED: $(LOCAL_INSTALLED_HDRS)
+
+###################################################################
+# 
+#                   Set up the target
+
+# remove any leading / trailing whitespace
+TARGET := $(strip $(TARGET))
+
+
+$(TARGET)_libmode ?= $(DEFAULT_LIBMODE)
+$(TARGET)_libtype ?= $(DEFAULT_LIBTYPE)
+
+$(TARGET)_asm_flags ?= $(DEFAULT_CPP_ASM_FLAGS)
+XCPPFLAGS += $($(TARGET)_asm_flags) 
+
+# $(info target = $(TARGET), libtype = $($(TARGET)_libtype))
+
+ifeq ($($(TARGET)_libtype),shared-archive)
+  CUMULATIVE_TARGET_LIST := $(CUMULATIVE_TARGET_LIST) $(TARGET)
+  LIB_EXT:=$(SHARED_ARCHIVE_LIB_EXT)
+  OBJSUBDIR:=shared
+  XCXXFLAGS+=$(SHARED_CXXFLAGS)
+  TMPDEPS = $(patsubst %,$$(%_fullname),$(LIBS))
+  $(eval $(TARGET)_LIBDEPS = $(TMPDEPS))
+else 
+  ifeq ($($(TARGET)_libtype),shared)
+    LIB_EXT:=$(SHARED_LIB_EXT)
+    OBJSUBDIR:=shared
+    XCXXFLAGS+=$(SHARED_CXXFLAGS)
+    TMPDEPS = $(patsubst %,$$(%_fullname),$(LIBS))
+    $(eval $(TARGET)_LIBDEPS = $(TMPDEPS))
+  else
+    LIB_EXT:=$(STAT_LIB_EXT)
+    OBJSUBDIR:=static
+    $(TARGET)_LIBDEPS =
+  endif
+endif
+
+ifeq ($($(TARGET)_libmode),debug)
+  TARGET_NAME_SUFFIX:=_debug
+  OBJSUBDIR:=$(OBJSUBDIR)-dbg
+  XCXXFLAGS+=$(DEBUG_CXXFLAG)
+else
+  TARGET_NAME_SUFFIX:=
+  OBJSUBDIR:=$(OBJSUBDIR)-rel
+  XCXXFLAGS+=$(OPT_CXXFLAG)
+  XCPPFLAGS+=$(RELEASE_CXXFLAG)
+endif
+
+ifneq ($(strip $(OPTIMIZE_FOR_PERFORMANCE_OVER_SIZE)),true)
+  XCXXFLAGS += $(OPTIMIZE_FOR_SIZE)
+endif
+
+OBJDIR := $(subst $(SRC_ROOT),$(BUILD_ROOT),$(abspath $(LOCAL_PATH)/$(OUTPUT_DIR_COMPONENT)$(SOLIB_OBJDIR_COMP)/$(OBJSUBDIR)))
+
+ifeq ($($(TARGET)_libtype),shared-archive)
+  LIBTARGET := $(TARGET:%=$(OBJDIR)/lib%$(TARGET_NAME_SUFFIX).$(LIB_EXT))
+else
+  LIBTARGET := $(TARGET:%=$(DESTDIR)/lib%$(TARGET_NAME_SUFFIX).$(LIB_EXT))
+endif
+
+$(TARGET)$(SOLIB_TARGET_COMP)_fullname := $(LIBTARGET)
+
+#$(info src_root = $(abspath $(SRC_ROOT)))
+#$(info build_root = $(abspath $(BUILD_ROOT)))
+#$(info objdir = $(OBJDIR))
+
+$(eval $(call set-src-and-obj-names,$(SRCS),$(LOCAL_SRCDIR)))
+
+TMPOBJS := $(patsubst %,$$(%_compiled_objs),$(COMPONENT_LIBS))
+$(eval COMPILED_OBJS += $(TMPOBJS))
+
+
+# save compiled objects in a macro
+$(TARGET)_compiled_objs := $(COMPILED_OBJS)
+
+ifneq ($(strip $(FORCED_OBJS)),)
+ # The point of this dependency is to force object rebuilds when the 
+ # corresponding dependency files are missing (even if the object file exists).
+ $(FORCED_OBJS): FORCE
+endif
+
+# $(info DEPS = $(DEPS))
+
+ifneq "$(MAKECMDGOALS)" "clean"
+  ifneq ($(strip $(FOUND_DEPS)),)
+  -include $(FOUND_DEPS)
+  endif
+endif
+
+
+# LOCAL_XINCDIRS := $(abspath $(patsubst %,$(LOCAL_PATH)/%,$(filter ../%,$(XINCDIRS))))
+
+# Currently remove -I until the old makefiles are obsoleted
+LOCAL_XINCDIRS := $(abspath $(patsubst ../%,$(LOCAL_PATH)/../%,$(patsubst -I%,%,$(XINCDIRS))))
+
+
+LOCAL_TOTAL_INCDIRS := $(LOCAL_SRCDIR) $(LOCAL_INCSRCDIR) $(LOCAL_XINCDIRS)
+
+# $(info  LOCAL_TOTAL_INCDIRS = $(LOCAL_TOTAL_INCDIRS), XCXXFLAGS = $(XCXXFLAGS))
+
+$(COMPILED_OBJS): XFLAGS := $(XCPPFLAGS) $(patsubst %,-I%,$(LOCAL_TOTAL_INCDIRS)) $(XCXXFLAGS)
+
+#$(info remote_dirs = $(REMOTE_DIRS))
+
+ifneq ($(strip $(REMOTE_DIRS)),)
+# $(info remote dirs = $(REMOTE_DIRS))
+$(foreach srcdir, $(strip $(REMOTE_DIRS)), $(eval $(call OBJ_TEMPLATE,$(srcdir),$(OBJDIR))))
+endif
+
+
+$(OBJDIR)/%.$(OBJ_EXT): $(LOCAL_SRCDIR)/%.cpp 
+	$(call make-cpp-obj-and-depend,$<,$@,$(subst .$(OBJ_EXT),.d,$@),$(XFLAGS))
+
+$(OBJDIR)/%.$(OBJ_EXT): $(LOCAL_SRCDIR)/%.c
+	$(call make-c-obj-and-depend,$<,$@,$(subst .$(OBJ_EXT),.d,$@),$(XFLAGS))
+
+# $(info target = $(TARGET), LIBDEPS = $($(TARGET)_LIBDEPS))
+
+$(LIBTARGET): LIBTYPE := $($(TARGET)_libtype)
+
+$(LIBTARGET): $(COMPILED_OBJS) $($(TARGET)_LIBDEPS)
+	@echo Build $@
+	$(call create_objdir,$(@D))
+	$(call generate_$(LIBTYPE)_lib,$@,$^)
+	@echo Done
+
+ALL_LIBS_INSTALLED: $(LIBTARGET)
+
+# Pseudo-targets for libraries. With this, we can use "make lib$(TARGET)" instead of "make $(DESTDIR)/lib%$(TARGET_NAME_SUFFIX).$(LIB_EXT)"
+# E.g., make libunit_test
+lib$(TARGET): $(LIBTARGET)
+
+-include $(MK)/depgraph.mk
+
+TARGET_TYPE := library
+
+-include $(PLATFORM_EXTRAS)
+
+
+.PRECIOUS:: $(DEPS) $(COMPILED_OBJS)
+
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/linux.mk b/tools_v2/build/make_nr/tools_v2/build/make/linux.mk
new file mode 100644
index 0000000..2f88ff2
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/linux.mk
@@ -0,0 +1,37 @@
+
+INSTALL := install
+INSTALL_OPTS := -c -D -m 444
+
+SED := sed
+MV := mv
+RM := rm -f
+RMDIR := rm -rf
+CP := cp
+MKDIR := mkdir -p
+
+export RANLIB = ranlib
+
+TOOLSET ?= g++
+
+LIB_DIRS += $(LIBCOMPFLAG)/usr/local
+
+SYS_THREAD_LIB := -lpthread
+SYS_DL_LIB := -ldl
+
+#########################################################
+
+define map_abspath
+  $(abspath $1)
+endef
+
+#########################################################
+
+define HDRINST_TEMPLATE
+$(3)/$(1): $(2)/$(1)
+	$(quiet) $(INSTALL) $(INSTALL_OPTS) $(2)/$(1) $(3)/$(1)
+endef
+
+define clean-path
+  $(patsubst %/,%,$1)
+endef
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/platforms/linux_arm.mk b/tools_v2/build/make_nr/tools_v2/build/make/platforms/linux_arm.mk
new file mode 100644
index 0000000..c1e214c
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/platforms/linux_arm.mk
@@ -0,0 +1,26 @@
+
+CXX := arm-linux-g++
+CC := arm-linux-gcc
+LINK := $(CXX)
+SHARED_LINK := $(CXX)
+AR := arm-linux-ar
+
+# overwrite RANLIB set in linux.mk
+export RANLIB = arm-linux-ranlib
+
+# This toolchain supports linux-arm v5
+DEFAULT_CPP_ASM_FLAGS := -DPV_ARM_GCC_V5
+PROCESSOR := arm
+
+# include the common engine header files in the search path
+INCDIRS += \
+    -I /opt/environments/linux_arm/data/omapts/linux/arm-tc/gcc-3.4.0-1/arm-linux \
+    -I /opt/environments/linux_arm/target/include/dspbridge/ \
+    -I /opt/environments/linux_arm/pvinclude
+
+# Compiler specific libraries locations
+LIB_DIRS += \
+    -L/opt/environments/linux_arm/data/omapts/linux/arm-tc/gcc-3.4.0-1/arm-linux/lib \
+    -L/opt/environments/linux_arm/pvlib \
+    -L/opt/environments/linux_arm/target/lib \
+    -L/opt/environments/linux_arm/rootfs/lib
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/platforms/linux_nj.mk b/tools_v2/build/make_nr/tools_v2/build/make/platforms/linux_nj.mk
new file mode 100644
index 0000000..c754532
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/platforms/linux_nj.mk
@@ -0,0 +1,87 @@
+
+CXX := arm-eabi-g++
+CC := arm-eabi-gcc
+LINK := $(CXX)
+SHARED_LINK := $(CXX)
+SHARED_PRELINK := $(ANDROID_BASE)/tools/apriori 
+SHARED_PRELINK_FLAGS := --quiet --prelinkmap $(CFG_DIR)/prelink-linux-arm.map --locals-only
+STRIP := $(ANDROID_BASE)/tools/soslim
+STRIP_FLAGS := --strip --shady --quiet
+AR := arm-eabi-ar
+
+# overwrite RANLIB set in linux.mk
+export RANLIB := arm-eabi-ranlib
+
+# This toolchain supports linux-arm v5
+DEFAULT_CPP_ASM_FLAGS := -DPV_ARM_GCC_V5
+PROCESSOR := arm
+
+# include the common engine header files in the search path
+INCDIRS += \
+    -I $(ANDROID_BASE)/headers/include \
+    -I $(ANDROID_BASE)/headers/system/bionic/arch-arm/include \
+    -I $(ANDROID_BASE)/headers/system/bionic/include \
+    -I $(ANDROID_BASE)/headers/system/libstdc++/include \
+    -I $(ANDROID_BASE)/headers/system/bionic/kernel/common \
+    -I $(ANDROID_BASE)/headers/system/bionic/kernel/arch-arm \
+    -I $(ANDROID_BASE)/headers/system/libm/include \
+
+# Compiler options
+CPPFLAGS += -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -msoft-float -O2 -march=armv5te -fno-rtti -fno-exceptions -mtune=xscale -fpic -mthumb-interwork -ffunction-sections -funwind-tables -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -Wstrict-aliasing=2 -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -MD -include $(ANDROID_BASE)/headers/include/arch/linux-arm/AndroidConfig.h -DANDROID -fmessage-length=0 -DSK_RELEASE -DNDEBUG -DUDEBUG -g -fvisibility-inlines-hidden -Os -DENABLE_MEMORY_PLAYBACK -fno-rtti
+
+# Idea is to build only libraries in arm mode and the rest in thumb mode
+OPTIMIZE_FOR_SIZE := -mthumb
+
+CXXFLAGS = -W -Wall -Wno-unused -Wno-non-virtual-dtor -Wno-multichar
+
+override SYSLIBS = -lc -lm -ldl -lstdc++
+
+SONAME_ARG := -Wl,-T,$(ANDROID_BASE)/config/armelf.xsc -Wl,--gc-sections -L$(ANDROID_BASE)/prebuilt/obj/lib -Wl,--whole-archive -Wl,-h,
+SHARED_PRE_LDFLAGS := -nostdlib -Wl,-shared,-Bsymbolic 
+SHARED_POST_LDFLAGS := -Wl,--no-whole-archive $(SYSLIBS) -Wl,--no-undefined $(ANDROID_BASE)/toolchain-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a
+
+# Compiler specific libraries locations
+LIB_DIRS = \
+    -L$(ANDROID_BASE)/prebuilt/obj/lib \
+    -L$(ANDROID_BASE)/toolchain-eabi-4.2.1/lib \
+    -L$(ANDROID_BASE)/toolchain-eabi-4.2.1/arm-eabi/lib
+
+
+PRE_LDFLAGS += \
+   $(ANDROID_BASE)/toolchain-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/crtbegin_dynamic.o
+
+POST_LDFLAGS += \
+   -Wl,--no-undefined \
+   $(ANDROID_BASE)/toolchain-eabi-4.2.1/lib/gcc/arm-eabi/4.2.1/interwork/libgcc.a \
+   $(ANDROID_BASE)/prebuilt/obj/lib/crtend_android.o
+
+export BINDING = -nostdlib -Bdynamic -Wl,-T,$(ANDROID_BASE)/config/armelf.x \
+        -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc \
+        -Wl,-rpath-link=$(ANDROID_BASE)/prebuilt/obj/lib
+
+
+ifneq ($(strip $(LOCAL_BYPASS_PRELINKING)),true)
+define prelink_and_strip
+  $(quiet) $(SHARED_PRELINK) $(SHARED_PRELINK_FLAGS) $1
+  $(quiet) $(STRIP) $(STRIP_FLAGS) $1
+endef
+else
+define prelink_and_strip
+endef
+endif
+
+define generate_shared_lib
+  $(quiet) $(SHARED_LINK) $(SHARED_PRE_LDFLAGS) $(SONAME_ARG)$(notdir $1) -o $1 $2 $(SHARED_POST_LDFLAGS)
+  $(call prelink_and_strip,$1)
+endef
+
+
+define generate_prog
+  $(quiet) $(LINK) $(BINDING) $(OUTLINKFLAG)$1 $(filter $(LIBCOMPFLAG)%,$($2_LDFLAGS)) \
+    $(PRE_LDFLAGS) $(XOBJECTS) $($2_compiled_objs)  $(filter %.a,$(filter-out $(LIBCOMPFLAG)%,$($2_LDFLAGS))) \
+    $(POST_LDFLAGS) $(patsubst lib%.so,-l%,$(notdir $(filter-out %.a,$(filter-out $(LIBCOMPFLAG)%,$($2_LDFLAGS))))) $(SYSLIBS)
+  $(quiet) $(STRIP) $(STRIP_FLAGS) $1
+endef
+
+## END FILE 
+
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/prog.mk b/tools_v2/build/make_nr/tools_v2/build/make/prog.mk
new file mode 100644
index 0000000..926137e
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/prog.mk
@@ -0,0 +1,112 @@
+# -*- makefile -*-
+#
+# This makefile template should be included by makefiles in
+# program directories.
+#
+
+# Set the directory for the local sources
+LOCAL_SRCDIR :=  $(abspath $(LOCAL_PATH)/$(SRCDIR))
+LOCAL_INCSRCDIR :=  $(abspath $(LOCAL_PATH)/$(INCSRCDIR))
+
+OBJDIR := $(patsubst $(SRC_ROOT)/%,$(BUILD_ROOT)/%,$(abspath $(LOCAL_PATH)/$(OUTPUT_DIR_COMPONENT)))
+
+$(eval $(call set-src-and-obj-names,$(SRCS),$(LOCAL_SRCDIR)))
+
+ifneq ($(strip $(FORCED_OBJS)),)
+ # The point of this dependency is to force object rebuilds when the 
+ # corresponding dependency files are missing (even if the object file exists).
+ $(FORCED_OBJS): FORCE
+endif
+
+
+ifneq "$(MAKECMDGOALS)" "clean"
+  ifneq ($(strip $(FOUND_DEPS)),)
+# $(warning Including $(FOUND_DEPS))
+  -include $(FOUND_DEPS)
+  endif
+endif
+
+ifneq ($(strip $(RELEASE)),)
+  XCXXFLAGS+=$(OPT_CXXFLAG)
+  XCPPFLAGS+=$(RELEASE_CXXFLAG)
+else
+  XCXXFLAGS+=$(DEBUG_CXXFLAG)
+endif
+
+LOCAL_XINCDIRS := $(abspath $(patsubst ../%,$(LOCAL_PATH)/../%,$(patsubst -I%,%,$(XINCDIRS))))
+
+LOCAL_TOTAL_INCDIRS := $(LOCAL_SRCDIR) $(LOCAL_INCSRCDIR) $(LOCAL_XINCDIRS)
+
+$(COMPILED_OBJS): XFLAGS := $(XCPPFLAGS) $(patsubst %,-I%,$(LOCAL_TOTAL_INCDIRS)) $(XCXXFLAGS)
+
+# remove any leading / trailing whitespace
+TARGET := $(strip $(TARGET))
+
+# save compiled objects in a macro
+$(TARGET)_compiled_objs := $(COMPILED_OBJS)
+
+ifneq ($(strip $(REMOTE_DIRS)),)
+# $(info remote dirs = $(REMOTE_DIRS))
+$(foreach srcdir, $(strip $(REMOTE_DIRS)), $(eval $(call OBJ_TEMPLATE,$(srcdir),$(OBJDIR))))
+endif
+
+
+$(OBJDIR)/%.$(OBJ_EXT): $(LOCAL_SRCDIR)/%.cpp 
+	$(call make-cpp-obj-and-depend,$<,$@,$(subst .$(OBJ_EXT),.d,$@),$(XFLAGS))
+
+$(OBJDIR)/%.$(OBJ_EXT): $(LOCAL_SRCDIR)/%.c
+	$(call make-c-obj-and-depend,$<,$@,$(subst .$(OBJ_EXT),.d,$@),$(XFLAGS))
+
+
+#ifeq ($(HOST_ARCH), win32)
+#  vpath %.so $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
+#  vpath %.$(STAT_LIB_EXT) $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
+#else
+#  vpath lib%.so $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
+#  vpath lib%.$(STAT_LIB_EXT) $(LIB_DIRS:$(LIBCOMPFLAG)%=%)
+#endif
+
+LOCAL_LIBDIRS := $(abspath $(patsubst ../%,$(LOCAL_PATH)/../%,$(patsubst $(LIBCOMPFLAG)%,%,$(XLIBDIRS))))
+
+LOCAL_LIBDIRS := $(patsubst %,$(LIBCOMPFLAG)%,$(LOCAL_LIBDIRS)) $(LIB_DIRS)
+
+
+REALTARGET := $(TARGET:%=$(BUILD_ROOT)/bin/$(OUTPUT_DIR_COMPONENT)/%$(TARGET_EXT))
+
+TMPDEPS := $(patsubst %,$$(%_fullname),$(LIBS))
+
+$(eval $(TARGET)_LIBDEPS := $(TMPDEPS))
+
+$(TARGET)_LDFLAGS := $(LOCAL_LIBDIRS) $($(TARGET)_LIBDEPS) $(LDFLAGS) $(XLDFLAGS)
+
+$(REALTARGET): $(COMPILED_OBJS) $($(TARGET)_LIBDEPS)
+	@echo Building $@
+	$(call create_objdir,$(@D))
+	$(call generate_prog,$@,$(notdir $@))
+	@echo DONE building $@.
+
+ALL_BIN_INSTALLED: $(REALTARGET)
+
+# Pseudo-targets for executables. With this, we can use "make $(TARGET)" instead of "make $(BUILD_ROOT)/bin/$(OUTPUT_DIR_COMPONENT)/%$(TARGET_EXT)"
+# # E.g., make pvplayer_engine_test
+$(TARGET): $(REALTARGET)
+
+.PRECIOUS:: $(DEPS) $(COMPILED_OBJS)
+
+TARGET_TYPE := prog
+
+-include $(PLATFORM_EXTRAS)
+
+TARGET_LIST := $(TARGET_LIST) $(TARGET)
+
+run_$(TARGET)_TEST_ARGS := $(TEST_ARGS)
+run_$(TARGET)_SOURCE_ARGS := $(SOURCE_ARGS)
+run_$(TARGET)_SOURCE_DIR := $(LOCAL_PATH)
+
+###incluede targest for test apps###########
+run_$(TARGET): $(REALTARGET)
+	@cd $(subst /,\,$($@_SOURCE_DIR)) & $< $($@_TEST_ARGS) $($@_SOURCE_ARGS)
+	
+run_test: run_$(TARGET)
+build_$(TARGET): $(REALTARGET)
+build_test: build_$(TARGET)
diff --git a/tools_v2/build/make_nr/tools_v2/build/make/sdkinfo.mk b/tools_v2/build/make_nr/tools_v2/build/make/sdkinfo.mk
new file mode 100644
index 0000000..d6ec206
--- /dev/null
+++ b/tools_v2/build/make_nr/tools_v2/build/make/sdkinfo.mk
@@ -0,0 +1,206 @@
+# This makefile will generate versioning files based on information from the
+# source control system, if it's available.  If it's not, then it will use a
+# timestamp
+#
+# The following variables are specific to the SDK and should be defined locally:
+# sdkinfo_target
+# sdkinfo_header_filename 
+# sdkinfo_header_macro
+# sdkinfo_label_macro
+# sdkinfo_date_macro
+# sdkinfo_version_file
+# sdkinfo_version_type
+
+# Skip all the rules if the target is clean
+ifneq "$(MAKECMDGOALS)" "clean"
+
+# Check if variables are set, if not set to default
+ifeq ($(strip $(GREP)),)
+    GREP := grep
+endif
+
+ifeq ($(strip $(CUT)),)
+    CUT := cut
+endif
+
+ifeq ($(strip $(ACCUREV)),)
+    ACCUREV := accurev
+endif
+
+ifneq ($(strip $(OFFICIAL_RELEASE)),)
+sdkinfo_official_string := // *** OFFICIAL RELEASE INFO -- Will not auto update
+else
+sdkinfo_official_string := 
+endif
+
+sdkinfo_official_grep := "*** OFFICIAL RELEASE"
+
+
+# Initialize values to empty
+file_official:=
+file_data:=
+
+# Read data from current file (if any)
+# First check if file is there
+file_exists := $(wildcard $(sdkinfo_header_filename))
+ifneq ($(strip $(file_exists)),) 
+   file_sdkinfo:= $(shell $(GREP) $(sdkinfo_label_macro) $(sdkinfo_header_filename) | $(CUT) -f2 -d\")
+   file_header_time:= $(shell $(GREP) $(sdkinfo_date_macro) $(sdkinfo_header_filename) | $(CUT) -f3 -d" ")
+
+ifeq ($(strip $(OFFICIAL_RELEASE)),)
+  # only set file_official and file_data if the OFFICIAL_RELEASE is NOT set.
+  # otherwise leave these empty so the file will be regenerated.
+
+# check if file is marked as an official release internally
+   file_official:= $(shell $(GREP) $(sdkinfo_official_grep) $(sdkinfo_header_filename))
+
+  # Concat the strings for comparison.  We only want to generate the new file
+  # if something has changed
+  file_data:=$(join $(file_sdkinfo), $(file_header_time))
+endif
+
+endif
+
+
+
+ifeq ($(strip $(file_official)),)
+
+
+ifeq ($(HOST_ARCH),win32)
+    DATE := gnu_date
+    ECHO := gnu_echo
+    header_date_format := 0x%%Y%%m%%d
+else
+    DATE := date
+    ECHO := echo
+    header_date_format := 0x%Y%m%d
+endif
+
+# Check if date_format strings are good.
+# On some PCs, this needs to change - not sure why.
+time_okay := $(shell $(DATE) -u +"$(header_date_format)")
+ifneq (,$(findstring %, $(time_okay)))
+    # swap settings
+    ifeq ($(HOST_ARCH),win32)
+        header_date_format := 0x%Y%m%d
+    else
+        header_date_format := 0x%%Y%%m%%d
+    endif
+endif
+
+
+# Set prerequisites since depending what is passed in, we may build multiple
+# files
+sdkinfo_target_prereq := FORCE
+
+header_time:= $(shell $(DATE) -u +"$(header_date_format)")
+
+# Get basis of current accurev workspace
+basis_stream := $(strip $(shell $(ACCUREV) info 2>&1 | $(GREP) "Basis:" | $(CUT) -f2 -d":"))
+
+ifneq ($(strip $(basis_stream)),)
+    basis_stream_type := $(shell $(ACCUREV) show -fx -s $(basis_stream) streams | $(GREP) "type=" | $(CUT) -f2 -d"\"")
+    ifeq ($(strip $(basis_stream_type)),passthrough)
+        parent_basis_stream := $(shell $(ACCUREV) show -fx -s $(basis_stream) streams | $(GREP) "basis=" | $(CUT) -f2 -d"\"")
+        stream_name := $(parent_basis_stream)
+        transaction_id := $(shell $(ACCUREV) hist -ft -t "now".1 -s $(parent_basis_stream) | $(GREP) "transaction" | $(CUT) -f1 -d";" | $(CUT) -f2 -d" " )
+    else 
+        ifeq ($(strip $(basis_stream_type)),snapshot)
+            transaction_id := $(shell $(ACCUREV) show -fx -s $(basis_stream) streams | $(GREP) "name=" | $(CUT) -f2 -d"\"")
+        else # basis is normal stream type
+            stream_name := $(basis_stream)
+            transaction_id := $(shell $(ACCUREV) hist -ft -t "now".1 -s $(basis_stream) | $(GREP) "transaction" | $(CUT) -f1 -d";" | $(CUT) -f2 -d" " )
+        endif
+    endif
+endif
+
+ifeq ($(strip $(transaction_id)),)
+    sdkinfo := null
+else
+    sdkinfo := $(transaction_id)
+endif
+
+ifneq ($(strip $(stream_name)),)
+   sdkinfo := $(stream_name).$(sdkinfo)
+endif
+
+ifneq ($(strip $(sdkinfo_version_file)),)
+   sdkinfo_target_prereq := $(sdkinfo_version_file) FORCE
+endif
+
+data:=$(join $(sdkinfo), $(header_time))
+
+# $(info header file $(sdkinfo_header_filename), file data = $(file_data), data = $(data))
+
+ifneq ($(strip $(file_data)),$(data))
+
+$(sdkinfo_target): $(sdkinfo_header_filename)
+
+$(sdkinfo_header_filename): sdkinfo_rule_hdr_macro := $(sdkinfo_header_macro)
+$(sdkinfo_header_filename): sdkinfo_rule_label_macro := $(sdkinfo_label_macro)
+$(sdkinfo_header_filename): sdkinfo_rule_date_macro := $(sdkinfo_date_macro)
+$(sdkinfo_header_filename): sdkinfo_rule_sdkinfo := $(sdkinfo)
+$(sdkinfo_header_filename): sdkinfo_rule_official_string := $(sdkinfo_official_string)
+$(sdkinfo_header_filename): sdkinfo_rule_time := $(header_time)
+$(sdkinfo_header_filename): sdkinfo_rule_file_data := $(file_data)
+$(sdkinfo_header_filename): sdkinfo_rule_data := $(data)
+
+$(sdkinfo_header_filename): $(sdkinfo_target_prereq)
+	@$(ECHO) "Writing $@..."
+	@$(ECHO) "#ifndef $(sdkinfo_rule_hdr_macro)_H_INCLUDED" > $@
+	@$(ECHO) "#define $(sdkinfo_rule_hdr_macro)_H_INCLUDED" >> $@
+	@$(ECHO) "" >> $@
+	@$(ECHO) "// This header file is automatically generated at build-time" >> $@
+	@$(ECHO) "$(sdkinfo_rule_official_string)" >> $@
+	@$(ECHO) "" >> $@
+	@$(ECHO) "#define $(sdkinfo_rule_label_macro) \"$(sdkinfo_rule_sdkinfo)\"" >> $@
+	@$(ECHO) "#define $(sdkinfo_rule_date_macro) $(sdkinfo_rule_time)" >> $@
+	@$(ECHO) "" >> $@
+	@$(ECHO) "#endif //$(sdkinfo_rule_hdr_macro)_H_INCLUDED" >> $@
+endif
+
+# endif for official release file check
+endif
+
+
+
+
+$(sdkinfo_version_file): sdkinfo_rule_sdkinfo := $(sdkinfo)
+$(sdkinfo_version_file): sdkinfo_rule_header_time := $(header_time)
+
+ifeq ($(strip $(sdkinfo_version_type)),win32)
+$(sdkinfo_version_file): FORCE
+	@$(ECHO) "Writing $@..."
+	@$(ECHO) "STRINGTABLE DISCARDABLE" > $@
+	@$(ECHO) "BEGIN" >> $@
+	@$(ECHO) "   IDS_PV_VERSION          \"$(sdkinfo_rule_sdkinfo)\"" >> $@
+	@$(ECHO) "END" >> $@
+	@$(ECHO) "" >> $@
+	@$(ECHO) "STRINGTABLE DISCARDABLE" >> $@
+	@$(ECHO) "BEGIN" >> $@
+	@$(ECHO) "   IDS_PV_BUILD          \"$(sdkinfo_rule_header_time)\"" >> $@
+	@$(ECHO) "END" >> $@
+endif
+
+ifeq ($(strip $(sdkinfo_version_type)),winmobile)
+$(sdkinfo_version_file): FORCE
+	@$(ECHO) "Writing $@..."
+	@$(ECHO) "STRINGTABLE" > $@
+	@$(ECHO) "BEGIN" >> $@
+	@$(ECHO) "   IDS_PV_VERSION          \"$(sdkinfo_rule_sdkinfo)\"" >> $@
+	@$(ECHO) "END" >> $@
+	@$(ECHO) "" >> $@
+endif
+
+
+ifeq ($(strip $(sdkinfo_version_type)),s60v3)
+$(sdkinfo_version_file): FORCE
+	@$(ECHO) "Writing $@..."
+	@$(ECHO) "_LIT(KPVVersionNumber, \"$(sdkinfo_rule_sdkinfo)\");" > $@
+	@$(ECHO) "_LIT(KPVBuildNumber, \"$(sdkinfo_rule_header_time)\");" >> $@
+	@$(ECHO) "" >> $@
+endif
+
+
+# endif for this not being for the clean target
+endif 
diff --git a/tools_v2/build/modules/linux_download/core/Android.mk b/tools_v2/build/modules/linux_download/core/Android.mk
deleted file mode 100644
index 866520b..0000000
--- a/tools_v2/build/modules/linux_download/core/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := src/pvmfdownloadnodes.cpp
-
-LOCAL_WHOLE_STATIC_LIBRARIES := libpvdownloadmanagernode
-
-LOCAL_SHARED_LIBRARIES := liblog libopencorenet_support libopencoreplayer libopencorecommon
-
-LOCAL_MODULE := libopencoredownload
-
-LOCAL_C_INCLUDES := \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tools_v2/build/modules/linux_download/core/makefile b/tools_v2/build/modules/linux_download/core/makefile
deleted file mode 100755
index bbd78fe..0000000
--- a/tools_v2/build/modules/linux_download/core/makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvdownload
-
-LIBDIRS = $(VOB_BASE_DIR)/tools_v2/build/modules/linux_download/core/src \
-		  $(VOB_BASE_DIR)/nodes/pvdownloadmanagernode/build/make
-
-LIBS = -lpvdownloadinterface -lpvdownloadmanagernode
-
-MODS = -lpvnet_support -lpvcommon
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_download/core/src/makefile b/tools_v2/build/modules/linux_download/core/src/makefile
deleted file mode 100755
index b0da27c..0000000
--- a/tools_v2/build/modules/linux_download/core/src/makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvdownloadinterface
-
-SRCDIR = .
-
-# compose final src list for actual build
-SRCS =	pvmfdownloadnodes.cpp
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_download/core/src/pvmfdownloadnodes.cpp b/tools_v2/build/modules/linux_download/core/src/pvmfdownloadnodes.cpp
deleted file mode 100644
index 3094b22..0000000
--- a/tools_v2/build/modules/linux_download/core/src/pvmfdownloadnodes.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_node_shared_lib_interface.h"
-
-#include "pvmf_downloadmanager_factory.h"
-
-#include "osclconfig.h"
-
-class DownloadNodesInterface: public OsclSharedLibraryInterface,
-            public NodeSharedLibraryInterface
-{
-    public:
-        // From NodeSharedLibraryInterface
-        OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId)
-        {
-            if (KPVMFDownloadManagerNodeUuid == aNodeUuid)
-            {
-                if (PV_CREATE_NODE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(PVMFDownloadManagerNodeFactory::CreatePVMFDownloadManagerNode));
-                }
-                else if (PV_RELEASE_NODE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(PVMFDownloadManagerNodeFactory::DeletePVMFDownloadManagerNode));
-                }
-            }
-
-            return NULL;
-        };
-
-        // From OsclSharedLibraryInterface
-        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
-        {
-            if (aInterfaceId == PV_NODE_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(NodeSharedLibraryInterface*, this);
-            }
-            return NULL;
-        };
-
-        static DownloadNodesInterface* Instance()
-        {
-            static DownloadNodesInterface nodeInterface;
-            return &nodeInterface;
-        };
-
-    private:
-
-        DownloadNodesInterface() {};
-
-};
-
-
-extern "C"
-{
-    OsclAny *GetInterface(void)
-    {
-        return DownloadNodesInterface::Instance();
-    }
-}
-
diff --git a/tools_v2/build/modules/linux_download/node_registry/Android.mk b/tools_v2/build/modules/linux_download/node_registry/Android.mk
deleted file mode 100644
index c3ee922..0000000
--- a/tools_v2/build/modules/linux_download/node_registry/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := src/pvmfdownloadnodereg.cpp
-
-LOCAL_SHARED_LIBRARIES := libopencoreplayer libopencorecommon
-
-LOCAL_MODULE := libopencoredownloadreg
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)/nodes/common/include \
-	$(PV_TOP)/engines/player/config/linux_download/src \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tools_v2/build/modules/linux_download/node_registry/makefile b/tools_v2/build/modules/linux_download/node_registry/makefile
deleted file mode 100755
index 9173e68..0000000
--- a/tools_v2/build/modules/linux_download/node_registry/makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvdownloadreg
-
-LIBDIRS = $(VOB_BASE_DIR)/tools_v2/build/modules/linux_download/node_registry/src
-
-LIBS = -lpvdownloadreginterface
-
-MODS = -lpvcommon -lpvplayer
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_download/node_registry/src/makefile b/tools_v2/build/modules/linux_download/node_registry/src/makefile
deleted file mode 100755
index ea597d9..0000000
--- a/tools_v2/build/modules/linux_download/node_registry/src/makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvdownloadreginterface
-
-# Use XCFLAGS to add extra compiler directives for the C compiler
-# if you add any please use "XCFLAGS += ..." not "XCFLAGS = " 
-# unless you're sure you want to override the project defaults.
-# Please include a comment if you do this.
-#
-# XCFLAGS += 
-
-# Use XCXXFLAGS to add extra compiler directives for the C++ compiler.
-# See notes above regarding overriding project defaults.
-#
-#XCXXFLAGS += -DTRUE=true -DFALSE=false
-
-# Use XCPPFLAGS to add extra preprocessor directives. Use XINCDIRS
-# for other include directories, but please only do this if absolutely
-# necessary -- let the makefile system find the include directories if 
-# possible.
-# See notes above regarding overriding project defaults.
-#
-#XCPPFLAGS +=
-
-# Use XINCDIRS for extra include directories. These should be proceeded 
-# with "-I" just as they would be when passing to the compiler.
-#
-# Added this to for osclconfig.h
-#XINCDIRS += 
-
-# Use XLIBDIRS for extra library directories. These should be proceeded 
-# with "-L" just as they would be when passing to the linker. 
-# Used for building executables.
-#
-# XLIBDIRS += 
-
-# Use XLDFLAGS for extra linker directives.
-# Used for building executables.
-#
-# XLDFLAGS += 
-
-SRCDIR = .
-
-# compose final src list for actual build
-SRCS =	pvmfdownloadnodereg.cpp
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_download/node_registry/src/pvmfdownloadnodereg.cpp b/tools_v2/build/modules/linux_download/node_registry/src/pvmfdownloadnodereg.cpp
deleted file mode 100644
index 1583104..0000000
--- a/tools_v2/build/modules/linux_download/node_registry/src/pvmfdownloadnodereg.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/* This file defines a PV NodeSharedLibrary interface that populates the
-   registry with the download manager node.
-*/
-#include "pvmf_node_shared_lib_interface.h"
-
-#include "pvmf_downloadmanager_factory.h"
-
-#include "pvmf_recognizer_registry.h"
-
-#include "osclconfig.h"
-
-#define NODE_REGISTRY_LIB_NAME_MAX_LENGTH 64
-
-class DownloadNodesRegistryInterface: public OsclSharedLibraryInterface,
-            public NodeRegistrySharedLibraryInterface,
-            public RecognizerSharedLibraryInterface
-{
-    public:
-
-        // From NodeRegistrySharedLibraryInterface
-        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
-        {
-            PVPlayerNodeInfo nodeinfo;
-#define DOWNLOAD_LIB_PATH "libopencoredownload.so"
-            OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(DOWNLOAD_LIB_PATH);
-
-            Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
-
-            //For PVMFDownloadManagerNode
-            nodeinfo.iInputTypes.clear();
-            nodeinfo.iInputTypes.push_back(PVMF_DATA_SOURCE_HTTP_URL);
-            nodeinfo.iNodeUUID = KPVMFDownloadManagerNodeUuid;
-            nodeinfo.iOutputType.clear();
-            nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-            nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
-            aRegistry->RegisterNode(nodeinfo);
-
-            nodeList->push_back(nodeinfo);
-
-            aContext = (OsclAny *)nodeList;
-        };
-
-        // From NodeRegistrySharedLibraryInterface
-        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
-        {
-            if (NULL != aContext)
-            {
-                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;
-
-                while (!nodeList->empty())
-                {
-                    PVPlayerNodeInfo tmpnode = nodeList->front();
-                    OSCL_DELETE(tmpnode.iSharedLibrary);
-                    aRegistry->UnregisterNode(tmpnode);
-                    nodeList->erase(nodeList->begin());
-                }
-
-                delete nodeList;
-            }
-        };
-
-
-        // From RecognizerSharedLibraryInterface
-        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
-        {
-        };
-
-
-        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
-        {
-            if (NULL != aContext)
-            {
-                Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList = (Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>*)aContext;
-
-                while (!pluginList->empty())
-                {
-                    PVMFRecognizerPluginFactory* tmpfac = pluginList->front();
-
-                    aRegistry->UnregisterRecognizer(tmpfac);
-
-                    pluginList->erase(pluginList->begin());
-
-                    OSCL_DELETE(tmpfac);
-                }
-
-                delete pluginList;
-            }
-        };
-
-        // From OsclSharedLibraryInterface
-        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
-        {
-            if (aInterfaceId == PV_NODE_REGISTRY_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(NodeRegistrySharedLibraryInterface*, this);
-            }
-            return NULL;
-        };
-
-        static DownloadNodesRegistryInterface* Instance()
-        {
-            static DownloadNodesRegistryInterface nodeInterface;
-            return &nodeInterface;
-        };
-
-    private:
-
-        DownloadNodesRegistryInterface() {};
-
-};
-
-
-extern "C"
-{
-    OsclAny *GetInterface(void)
-    {
-        return DownloadNodesRegistryInterface::Instance();
-    }
-}
-
diff --git a/tools_v2/build/modules/linux_mp4/core/Android.mk b/tools_v2/build/modules/linux_mp4/core/Android.mk
deleted file mode 100644
index 0c04273..0000000
--- a/tools_v2/build/modules/linux_mp4/core/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := src/pvmfmp4nodes.cpp
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-	libomx_m4v_component_lib \
-	libpvmp4decoder \
-	libpvmp4ffparsernode \
-	
-
-LOCAL_SHARED_LIBRARIES := liblog libopencoremp4reg libopencoreplayer libopencorecommon
-
-LOCAL_MODULE := libopencoremp4
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)/codecs_v2/video/m4v_h263/dec/include \
-	$(PV_TOP)/codecs_v2/video/m4v_h263/dec/src \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/tools_v2/build/modules/linux_mp4/core/makefile b/tools_v2/build/modules/linux_mp4/core/makefile
deleted file mode 100755
index 6bce5d1..0000000
--- a/tools_v2/build/modules/linux_mp4/core/makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvmp4
-
-LIBDIRS = $(VOB_BASE_DIR)/tools_v2/build/modules/linux_mp4/core/src \
-          $(VOB_BASE_DIR)/codecs_v2/omx/omx_m4v/build/make_multithreaded \
-          $(VOB_BASE_DIR)/codecs_v2/video/m4v_h263/dec/build/make \
-          $(VOB_BASE_DIR)/nodes/pvmp4ffparsernode/build_opencore/make
-
-LIBS = -lpvmp4interface -lomx_m4v_component_lib -lpvmp4decoder -lpvmp4ffparsernode
-
-MODS = -lpvcommon -lpvplayer
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_mp4/core/src/makefile b/tools_v2/build/modules/linux_mp4/core/src/makefile
deleted file mode 100755
index 66376e2..0000000
--- a/tools_v2/build/modules/linux_mp4/core/src/makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4interface
-
-XINCDIRS += \
-	-I $(VOB_BASE_DIR)/codecs_v2/video/m4v_h263/dec/src \
-	-I $(VOB_BASE_DIR)/codecs_v2/video/m4v_h263/dec/include \
-	-I $(VOB_BASE_DIR)/extern_libs_v2/khronos/openmax/include
-
-SRCDIR = .
-
-# compose final src list for actual build
-SRCS =	pvmfmp4nodes.cpp
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_mp4/core/src/pvmfmp4nodes.cpp b/tools_v2/build/modules/linux_mp4/core/src/pvmfmp4nodes.cpp
deleted file mode 100644
index 3ea10f9..0000000
--- a/tools_v2/build/modules/linux_mp4/core/src/pvmfmp4nodes.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_node_shared_lib_interface.h"
-
-#include "pv_omx_shared_lib_interface.h"
-
-#include "pvmf_mp4ffparser_factory.h"
-
-#include "pv_omxdefs.h"
-#include "omx_mpeg4_component.h"
-#include "omx_m4v_component_interface.h"
-
-// external factory functions needed for creation of each component (or stubs for testing)
-extern OMX_ERRORTYPE Mpeg4OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-extern OMX_ERRORTYPE Mpeg4OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle);
-
-extern OMX_ERRORTYPE H263OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN  OMX_PTR pAppData);
-extern OMX_ERRORTYPE H263OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle);
-
-class Mp4NodesInterface: public OsclSharedLibraryInterface,
-            public NodeSharedLibraryInterface,
-            public OmxSharedLibraryInterface
-{
-    public:
-        // From NodeSharedLibraryInterface
-        OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId)
-        {
-            if (KPVMFMP4FFParserNodeUuid == aNodeUuid)
-            {
-                if (PV_CREATE_NODE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(PVMFMP4FFParserNodeFactory::CreatePVMFMP4FFParserNode));
-                }
-                else if (PV_RELEASE_NODE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(PVMFMP4FFParserNodeFactory::DeletePVMFMP4FFParserNode));
-                }
-            }
-
-            return NULL;
-        };
-
-        // From OmxSharedLibraryInterface
-        OsclAny* QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId)
-        {
-            if (PV_OMX_M4V_TYPE == aOmxTypeId)
-            {
-                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(&Mpeg4OmxComponentFactory));
-                }
-                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(&Mpeg4OmxComponentDestructor));
-                }
-            }
-            else if (PV_OMX_H263_TYPE == aOmxTypeId)
-            {
-                if (PV_OMX_CREATE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(&H263OmxComponentFactory));
-                }
-                else if (PV_OMX_DESTROY_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(&H263OmxComponentDestructor));
-                }
-            }
-
-            return NULL;
-        };
-
-        // From OsclSharedLibraryInterface
-        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
-        {
-            if (aInterfaceId == PV_NODE_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(NodeSharedLibraryInterface*, this);
-            }
-            else if (aInterfaceId == PV_OMX_SHARED_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(OmxSharedLibraryInterface*, this);
-            }
-
-            return NULL;
-        };
-
-        static Mp4NodesInterface* Instance()
-        {
-            static Mp4NodesInterface nodeInterface;
-            return &nodeInterface;
-        };
-
-    private:
-
-        Mp4NodesInterface() {};
-
-};
-
-
-extern "C"
-{
-    OsclAny *GetInterface(void)
-    {
-        return Mp4NodesInterface::Instance();
-    }
-}
-
diff --git a/tools_v2/build/modules/linux_mp4/node_registry/Android.mk b/tools_v2/build/modules/linux_mp4/node_registry/Android.mk
deleted file mode 100644
index 4a4a45a..0000000
--- a/tools_v2/build/modules/linux_mp4/node_registry/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := src/pvmfmp4nodereg.cpp
-
-LOCAL_WHOLE_STATIC_LIBRARIES := libpvmp4ffrecognizer
-
-LOCAL_SHARED_LIBRARIES := liblog libopencoreplayer libopencorecommon
-
-LOCAL_MODULE := libopencoremp4reg
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)/nodes/common/include \
-	$(PV_TOP)/nodes/pvmp4ffparsernode/include \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/tools_v2/build/modules/linux_mp4/node_registry/makefile b/tools_v2/build/modules/linux_mp4/node_registry/makefile
deleted file mode 100755
index 37ea687..0000000
--- a/tools_v2/build/modules/linux_mp4/node_registry/makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvmp4reg
-
-LIBDIRS = \
-	$(VOB_BASE_DIR)/tools_v2/build/modules/linux_mp4/node_registry/src \
-	$(VOB_BASE_DIR)/fileformats/mp4/parser/build/make \
-	$(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make \
-
-LIBS = -lpvmp4reginterface -lpvmp4ff -lpvmp4ffrecognizer
-
-MODS = -lpvcommon -lpvplayer
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_mp4/node_registry/src/makefile b/tools_v2/build/modules/linux_mp4/node_registry/src/makefile
deleted file mode 100755
index af9de23..0000000
--- a/tools_v2/build/modules/linux_mp4/node_registry/src/makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvmp4reginterface
-
-XINCDIRS += \
-	-I $(VOB_BASE_DIR)/nodes/common/include \
-	-I $(VOB_BASE_DIR)/nodes/pvmp4ffparsernode/include 
-
-SRCDIR = .
-
-# compose final src list for actual build
-SRCS =	pvmfmp4nodereg.cpp
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.cpp b/tools_v2/build/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.cpp
deleted file mode 100644
index 35a48e0..0000000
--- a/tools_v2/build/modules/linux_mp4/node_registry/src/pvmfmp4nodereg.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/* This file defines a PV NodeSharedLibrary interface that populates the
-   registry with the nodes required for mp4 playback.
-*/
-#include "pvmf_node_shared_lib_interface.h"
-
-#include "pvmf_mp4ffparser_factory.h"
-
-#include "pvmp4ffrec_factory.h"
-
-#include "pvmf_recognizer_registry.h"
-
-class Mp4NodesRegistryInterface: public OsclSharedLibraryInterface,
-            public NodeRegistrySharedLibraryInterface,
-            public RecognizerSharedLibraryInterface
-{
-    public:
-
-        // From NodeRegistrySharedLibraryInterface
-        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
-        {
-            PVPlayerNodeInfo nodeinfo;
-
-#define MP4_LIB_PATH "libopencoremp4.so"
-            OSCL_HeapString<OsclMemAllocator> libname = MP4_LIB_PATH;
-
-            Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
-
-            //For PVMFMP4FFParserNode
-            nodeinfo.iInputTypes.clear();
-            nodeinfo.iInputTypes.push_back(PVMF_MPEG4FF);
-            nodeinfo.iNodeUUID = KPVMFMP4FFParserNodeUuid;
-            nodeinfo.iOutputType.clear();
-            nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-            nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
-            aRegistry->RegisterNode(nodeinfo);
-
-            nodeList->push_back(nodeinfo);
-
-            aContext = (OsclAny *)nodeList;
-
-        };
-
-        // From NodeRegistrySharedLibraryInterface
-        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
-        {
-            if (NULL != aContext)
-            {
-                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;
-
-                while (!nodeList->empty())
-                {
-                    PVPlayerNodeInfo tmpnode = nodeList->front();
-                    OSCL_DELETE(tmpnode.iSharedLibrary);
-                    aRegistry->UnregisterNode(tmpnode);
-                    nodeList->erase(nodeList->begin());
-                }
-
-                delete nodeList;
-            }
-        };
-
-
-        // From RecognizerSharedLibraryInterface
-        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
-        {
-            PVMFRecognizerPluginFactory* tmpfac = NULL;
-
-            Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList =
-                new Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>;
-
-            tmpfac =
-                OSCL_STATIC_CAST(PVMFRecognizerPluginFactory*, OSCL_NEW(PVMP4FFRecognizerFactory, ()));
-            aRegistry->RegisterRecognizer(tmpfac);
-
-            pluginList->push_back(tmpfac);
-
-            aContext = (OsclAny *)pluginList;
-        };
-
-
-        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
-        {
-            if (NULL != aContext)
-            {
-                Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList = (Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>*)aContext;
-
-                while (!pluginList->empty())
-                {
-                    PVMFRecognizerPluginFactory* tmpfac = pluginList->front();
-
-                    aRegistry->UnregisterRecognizer(tmpfac);
-
-                    pluginList->erase(pluginList->begin());
-
-                    OSCL_DELETE(tmpfac);
-                }
-
-                delete pluginList;
-            }
-        };
-
-        // From OsclSharedLibraryInterface
-        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
-        {
-            if (aInterfaceId == PV_NODE_REGISTRY_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(NodeRegistrySharedLibraryInterface*, this);
-            }
-            else if (aInterfaceId == PV_RECOGNIZER_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(RecognizerSharedLibraryInterface*, this);
-            }
-            return NULL;
-        };
-
-        static Mp4NodesRegistryInterface* Instance()
-        {
-            static Mp4NodesRegistryInterface nodeInterface;
-            return &nodeInterface;
-        };
-
-    private:
-
-        Mp4NodesRegistryInterface() {};
-
-};
-
-
-extern "C"
-{
-    OsclAny *GetInterface(void)
-    {
-        return Mp4NodesRegistryInterface::Instance();
-    }
-}
-
diff --git a/tools_v2/build/modules/linux_net_support/core/Android.mk b/tools_v2/build/modules/linux_net_support/core/Android.mk
deleted file mode 100644
index e80ec02..0000000
--- a/tools_v2/build/modules/linux_net_support/core/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-	libprotocolenginenode \
-	libpvsocketnode \
-	libpv_http_parcom \
-	libpvgendatastruct \
-	libpvsdpparser
-
-LOCAL_SHARED_LIBRARIES := libopencoreplayer libopencorecommon libutils libcutils
-
-LOCAL_MODULE := libopencorenet_support
-
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_C_INCLUDES := \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/tools_v2/build/modules/linux_net_support/core/makefile b/tools_v2/build/modules/linux_net_support/core/makefile
deleted file mode 100755
index 7737082..0000000
--- a/tools_v2/build/modules/linux_net_support/core/makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvnet_support
-
-LIBDIRS = $(VOB_BASE_DIR)/nodes/pvprotocolenginenode/build/make \
-		  $(VOB_BASE_DIR)/nodes/pvsocketnode/build/make \
-		  $(VOB_BASE_DIR)/protocols/http_parcom/build/make \
-		  $(VOB_BASE_DIR)/baselibs/gen_data_structures/build/make \
-		  $(VOB_BASE_DIR)/protocols/sdp/parser/build/make
-
-LIBS = -lprotocolenginenode -lpvsocketnode -lpv_http_parcom -lpvgendatastruct -lpvsdpparser
-
-MODS = -lpvcommon -lpvplayer
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_rtsp/core/Android.mk b/tools_v2/build/modules/linux_rtsp/core/Android.mk
deleted file mode 100644
index 6e01519..0000000
--- a/tools_v2/build/modules/linux_rtsp/core/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := src/pvmfrtspnodes.cpp
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-	libpvstreamingmanagernode_3gpp \
-	libpv_rtsp_parcom \
-	libpvrtsp_cli_eng_node_3gpp \
-	librtppayloadparser_3gpp \
-	librtprtcp \
-	libpvjitterbuffernode \
-	libpvmediaplayernode
-
-LOCAL_SHARED_LIBRARIES := liblog libopencorenet_support libopencoreplayer libopencorecommon
-
-LOCAL_MODULE := libopencorertsp
-
-LOCAL_C_INCLUDES := \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/tools_v2/build/modules/linux_rtsp/core/makefile b/tools_v2/build/modules/linux_rtsp/core/makefile
deleted file mode 100755
index 07f1df9..0000000
--- a/tools_v2/build/modules/linux_rtsp/core/makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvrtsp
-
-LIBDIRS = $(VOB_BASE_DIR)/tools_v2/build/modules/linux_rtsp/core/src \
-		  $(VOB_BASE_DIR)/nodes/streaming/streamingmanager/build/linux_3gpp \
-		  $(VOB_BASE_DIR)/protocols/rtsp_parcom/build/make \
-		  $(VOB_BASE_DIR)/protocols/rtsp_client_engine/build/make_3gpp \
-		  $(VOB_BASE_DIR)/protocols/rtp_payload_parser/build/linux_3gpp \
-		  $(VOB_BASE_DIR)/protocols/rtp/build/make \
-		  $(VOB_BASE_DIR)/nodes/streaming/jitterbuffernode/build/make \
-		  $(VOB_BASE_DIR)/nodes/streaming/medialayernode/build/make
-
-LIBS = -lpvrtspinterface \
-	   -lpvstreamingmanagernode_3gpp \
-	   -lpv_rtsp_parcom \
-	   -lpvrtsp_cli_eng_node_3gpp \
-	   -lrtppayloadparser_3gpp \
-	   -lrtprtcp \
-	   -lpvjitterbuffernode \
-	   -lpvmediaplayernode
-
-MODS = -lpvnet_support -lpvcommon -lpvplayer
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_rtsp/core/src/makefile b/tools_v2/build/modules/linux_rtsp/core/src/makefile
deleted file mode 100755
index 48c5600..0000000
--- a/tools_v2/build/modules/linux_rtsp/core/src/makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvrtspinterface
-
-SRCDIR = .
-
-# compose final src list for actual build
-SRCS =	pvmfrtspnodes.cpp
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_rtsp/core/src/pvmfrtspnodes.cpp b/tools_v2/build/modules/linux_rtsp/core/src/pvmfrtspnodes.cpp
deleted file mode 100644
index ffc900b..0000000
--- a/tools_v2/build/modules/linux_rtsp/core/src/pvmfrtspnodes.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-#include "pvmf_node_shared_lib_interface.h"
-
-#include "pvmf_sm_node_factory.h"
-
-// Need osclconfig.h for the HAS_OSCL_LIB_SUPPORT macro for now
-#include "osclconfig.h"
-
-class StreamingNodesInterface: public OsclSharedLibraryInterface,
-            public NodeSharedLibraryInterface
-{
-    public:
-        // From NodeSharedLibraryInterface
-        OsclAny* QueryNodeInterface(const PVUuid& aNodeUuid, const OsclUuid& aInterfaceId)
-        {
-            if (KPVMFStreamingManagerNodeUuid == aNodeUuid)
-            {
-                if (PV_CREATE_NODE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(PVMFStreamingManagerNodeFactory::CreateStreamingManagerNode));
-                }
-                else if (PV_RELEASE_NODE_INTERFACE == aInterfaceId)
-                {
-                    return ((OsclAny*)(PVMFStreamingManagerNodeFactory::DeleteStreamingManagerNode));
-                }
-            }
-
-            return NULL;
-        };
-
-        // From OsclSharedLibraryInterface
-        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
-        {
-            if (aInterfaceId == PV_NODE_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(NodeSharedLibraryInterface*, this);
-            }
-            return NULL;
-        };
-
-        static StreamingNodesInterface* Instance()
-        {
-            static StreamingNodesInterface nodeInterface;
-            return &nodeInterface;
-        };
-
-    private:
-
-        StreamingNodesInterface() {};
-
-};
-
-
-extern "C"
-{
-    OsclAny *GetInterface(void)
-    {
-        return StreamingNodesInterface::Instance();
-    }
-}
-
diff --git a/tools_v2/build/modules/linux_rtsp/node_registry/Android.mk b/tools_v2/build/modules/linux_rtsp/node_registry/Android.mk
deleted file mode 100644
index 6c624cc..0000000
--- a/tools_v2/build/modules/linux_rtsp/node_registry/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := src/pvmfrtspnodereg.cpp
-
-LOCAL_SHARED_LIBRARIES := libopencoreplayer libopencorecommon
-
-LOCAL_MODULE := libopencorertspreg
-
-LOCAL_C_INCLUDES := \
-	$(PV_TOP)/nodes/common/include \
-	$(PV_TOP)/engines/player/config/linux_rtsp/src \
-	$(PV_INCLUDES)
-
-include $(BUILD_SHARED_LIBRARY)
-
diff --git a/tools_v2/build/modules/linux_rtsp/node_registry/makefile b/tools_v2/build/modules/linux_rtsp/node_registry/makefile
deleted file mode 100755
index 39f40a5..0000000
--- a/tools_v2/build/modules/linux_rtsp/node_registry/makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvrtspreg
-
-LIBDIRS = $(VOB_BASE_DIR)/tools_v2/build/modules/linux_rtsp/node_registry/src
-
-LIBS = -lpvrtspreginterface
-
-MODS = -lpvcommon -lpvplayer
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_rtsp/node_registry/src/makefile b/tools_v2/build/modules/linux_rtsp/node_registry/src/makefile
deleted file mode 100755
index 5b70807..0000000
--- a/tools_v2/build/modules/linux_rtsp/node_registry/src/makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Include the project-wide makefile to get 
-# appropriate definitions
-include $(PV_TOP)/makefile.pv
-
-WHAT = library
-TARGET = pvrtspreginterface
-
-SRCDIR = .
-
-# compose final src list for actual build
-SRCS =	pvmfrtspnodereg.cpp
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.cpp b/tools_v2/build/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.cpp
deleted file mode 100644
index 6cb6151..0000000
--- a/tools_v2/build/modules/linux_rtsp/node_registry/src/pvmfrtspnodereg.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 2008 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/* This file defines a PV NodeSharedLibrary interface that populates the
-   registry with the streaming manager node.
-*/
-#include "pvmf_node_shared_lib_interface.h"
-
-#include "pvmf_sm_node_factory.h"
-
-#include "pvmf_recognizer_registry.h"
-
-#include "osclconfig.h"
-
-#define NODE_REGISTRY_LIB_NAME_MAX_LENGTH 64
-
-class StreamingNodesRegistryInterface: public OsclSharedLibraryInterface,
-            public NodeRegistrySharedLibraryInterface,
-            public RecognizerSharedLibraryInterface
-{
-    public:
-
-        // From NodeRegistrySharedLibraryInterface
-        void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
-        {
-            PVPlayerNodeInfo nodeinfo;
-
-#define RTSP_LIB_NAME "libopencorertsp.so"
-
-            OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(RTSP_LIB_NAME);
-
-            Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
-
-            //For PVMFStreamingManagerNode
-            nodeinfo.iInputTypes.clear();
-            nodeinfo.iInputTypes.push_back(PVMF_DATA_SOURCE_RTSP_URL);
-            nodeinfo.iInputTypes.push_back(PVMF_DATA_SOURCE_SDP_FILE);
-            nodeinfo.iNodeUUID = KPVMFStreamingManagerNodeUuid;
-            nodeinfo.iOutputType.clear();
-            nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
-            nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
-            aRegistry->RegisterNode(nodeinfo);
-
-            nodeList->push_back(nodeinfo);
-
-            aContext = (OsclAny *)nodeList;
-        };
-
-        // From NodeRegistrySharedLibraryInterface
-        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
-        {
-            if (NULL != aContext)
-            {
-                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;
-
-                while (!nodeList->empty())
-                {
-                    PVPlayerNodeInfo tmpnode = nodeList->front();
-                    OSCL_DELETE(tmpnode.iSharedLibrary);
-                    aRegistry->UnregisterNode(tmpnode);
-                    nodeList->erase(nodeList->begin());
-                }
-
-                delete nodeList;
-            }
-        };
-
-
-        // From RecognizerSharedLibraryInterface
-        void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
-        {
-        };
-
-
-        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
-        {
-            if (NULL != aContext)
-            {
-                Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList = (Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>*)aContext;
-
-                while (!pluginList->empty())
-                {
-                    PVMFRecognizerPluginFactory* tmpfac = pluginList->front();
-
-                    aRegistry->UnregisterRecognizer(tmpfac);
-
-                    pluginList->erase(pluginList->begin());
-
-                    OSCL_DELETE(tmpfac);
-                }
-
-                delete pluginList;
-            }
-        };
-
-        // From OsclSharedLibraryInterface
-        OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
-        {
-            if (aInterfaceId == PV_NODE_REGISTRY_INTERFACE)
-            {
-                return OSCL_STATIC_CAST(NodeRegistrySharedLibraryInterface*, this);
-            }
-            return NULL;
-        };
-
-        static StreamingNodesRegistryInterface* Instance()
-        {
-            static StreamingNodesRegistryInterface nodeInterface;
-            return &nodeInterface;
-        };
-
-    private:
-
-        StreamingNodesRegistryInterface() {};
-
-};
-
-
-extern "C"
-{
-    OsclAny *GetInterface(void)
-    {
-        return StreamingNodesRegistryInterface::Instance();
-    }
-}
-
diff --git a/tools_v2/build/package/default/setup b/tools_v2/build/package/default/setup
deleted file mode 100644
index 6611ee5..0000000
--- a/tools_v2/build/package/default/setup
+++ /dev/null
@@ -1,63 +0,0 @@
-
-# Setup environment for necessary for the
-# makefiles, etc.
-
-# Only set the VOB_BASE_DIR if it is not already set.
-# In this case, set it based on the first argument if it is present
-# and otherwise default to /vobs.
-if (! $?VOB_BASE_DIR) then
-   if ($# >= 1) then 
-     setenv VOB_BASE_DIR $1
-   else 
-     setenv VOB_BASE_DIR /vobs
-   endif
-   echo Set VOB_BASE_DIR to $VOB_BASE_DIR ...
-else
-   echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
-endif
-
-# Set the PV_TOP
-#
-setenv PV_TOP $VOB_BASE_DIR/oscl
-echo Set PV_TOP to $PV_TOP ...
-
-setenv PROJECT $PV_TOP
-echo Set PROJECT to $PROJECT ...
-
-setenv MK $VOB_BASE_DIR/tools_v2/build/make
-echo Set MK to $MK ...
-
-setenv CCASE_MAKE_COMPAT gnu
-echo Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ...
-
-if (! -f $MK/../bin/archtype) then
-   echo "Error. Cannot find archtype script $MK/../bin/archtype."
-endif
-
-set arch_bin_path = `$MK/../bin/archtype`
-set extern_tools_path = $VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
-if ( -x /icl-tools/bin/$arch_bin_path/utok ) then
-  set path = (`/icl-tools/bin/$arch_bin_path/utok -s \  ./$arch_bin_path $extern_tools_path $path`)
-else 
-  set path = (./$arch_bin_path  $extern_tools_path $path)
-endif
-unset arch_bin_path
-unset extern_tools_path
-
-if ( -f ./setup.extras ) then
-  echo File setup.extras found, sourcing ...
-  source ./setup.extras
-else
-  echo File setup.extras not found, skipping ...
-endif
-
-# Rehash
-#
-rehash
-rehash
-
-# Finita
-#
-echo 
-echo Environment is ready if no errors reported
-echo 
diff --git a/tools_v2/build/package/default/setup.ksh b/tools_v2/build/package/default/setup.ksh
deleted file mode 100755
index fb0d836..0000000
--- a/tools_v2/build/package/default/setup.ksh
+++ /dev/null
@@ -1,59 +0,0 @@
-echo Setting up build environment with default configuration ...
-echo Using $PWD as top directory ...
-
-
-# Setup environment for necessary for the
-# makefiles, etc.
-
-# Only set the VOB_BASE_DIR if it is not already set.
-# In this case, set it based on the first argument if it is present
-# and otherwise default to /vobs.
-if [[ -z $VOB_BASE_DIR ]]; then
-   if [[ $# -ge 1 ]]; then 
-     export VOB_BASE_DIR="$1"
-   else 
-     export VOB_BASE_DIR="/vobs"
-   fi
-   echo "Set VOB_BASE_DIR to $VOB_BASE_DIR ..."
-else
-   echo VOB_BASE_DIR already defined as $VOB_BASE_DIR ...
-fi
-
-# Set the PV_TOP
-#
-export PV_TOP="$VOB_BASE_DIR/oscl"
-echo Set PV_TOP to $PV_TOP ...
-
-export PROJECT=$PV_TOP
-echo "Set PROJECT to $PROJECT ..."
-
-export MK="$VOB_BASE_DIR/tools_v2/build/make"
-echo "Set MK to $MK ..."
-
-export CCASE_MAKE_COMPAT="gnu"
-echo "Set CCASE_MAKE_COMPAT to $CCASE_MAKE_COMPAT ..."
-
-if [[ ! -f "$MK/../bin/archtype" ]];  then
-  echo "Error. Cannot find archtype script $MK/../bin/archtype."
-fi
-
-export arch_bin_path=`$MK/../bin/archtype`
-export extern_tools_path=$VOB_BASE_DIR/extern_tools_v2/bin/$arch_bin_path
-if [[ -x /icl-tools/bin/$arch_bin_path/utok ]]; then
-  export PATH=$PATH:`/icl-tools/bin/$arch_bin_path/utok -s \  ./$arch_bin_path  $extern_tools_path $PATH`
-else
-  export PATH=./$arch_bin_path:$extern_tools_path:$PATH
-fi
-export arch_bin_path=
-export extern_tools_path=
-
-if [[ -f ./setup.extras.ksh ]]; then
-   echo File setup.extras.ksh found, sourcing ...
-   . ./setup.extras.ksh
-else
-   echo File setup.extras not found, skipping ...
-fi 
-
-echo 
-echo Environment is ready if no errors reported
-echo
diff --git a/tools_v2/build/package/nj_rel/cleanup b/tools_v2/build/package/nj_rel/cleanup
deleted file mode 100644
index d6bc2ab..0000000
--- a/tools_v2/build/package/nj_rel/cleanup
+++ /dev/null
@@ -1,31 +0,0 @@
-# makefiles, etc.
-
-echo Cleaning up build environment ...
-
-unsetenv KERNEL_HEADERS
-unsetenv ANDROID_BASE
-unsetenv CCASE_MAKE_COMPAT
-unsetenv PROJECT
-unsetenv SDK_LOCAL
-unsetenv VOB_BASE_DIR
-unsetenv PV_TOP
-
-set arch_bin_path = `$MK/../bin/archtype`
-if ( -x /icl-tools/bin/$arch_bin_path/utok ) then 
-   set path = (`/icl-tools/bin/$arch_bin_path/utok -s \  -d ./$arch_bin_path  $path`)
-endif
-unset arch_bin_path
-
-if ( -f ./cleanup.extras ) then
-  echo File cleanup.extras found, sourcing ...
-  source ./cleanup.extras 
-else
-  echo File cleanup.extras not found, skipping
-endif
-
-unsetenv MK
-
-# Rehash
-#
-rehash
-rehash
diff --git a/tools_v2/build/package/nj_rel/cleanup.ksh b/tools_v2/build/package/nj_rel/cleanup.ksh
deleted file mode 100644
index c0e8069..0000000
--- a/tools_v2/build/package/nj_rel/cleanup.ksh
+++ /dev/null
@@ -1,27 +0,0 @@
-# makefiles, etc.
-
-echo Cleaning up build environment ...
-
-unset KERNEL_HEADERS
-unset ANDROID_BASE
-unset CCASE_MAKE_COMPAT
-unset PROJECT
-unset SDK_LOCAL
-unset VOB_BASE_DIR
-unset PV_TOP
-
-if [[ "${MK}" != "" ]]; then
-	typeset arch_bin_path=`$MK/../bin/archtype`
-	if [ -x /icl-tools/bin/$arch_bin_path/utok ]; then 
-   	export PATH=`/icl-tools/bin/$arch_bin_path/utok -s \  -d ./$arch_bin_path  $PATH`
-	fi
-fi
-
-if [ -f ./cleanup.extras.ksh ]; then
-  echo File cleanup.extras.ksh found, sourcing ...
-  . ./cleanup.extras.ksh 
-else
-  echo File cleanup.extras.ksh not found, skipping
-fi
-
-unset MK
diff --git a/tools_v2/build/package/nj_rel/config.out b/tools_v2/build/package/nj_rel/config.out
deleted file mode 100644
index 9521467..0000000
--- a/tools_v2/build/package/nj_rel/config.out
+++ /dev/null
@@ -1,313 +0,0 @@
-#
-# Automatically generated, don't edit
-#
-# Generated on: batchisongx620
-# At: Tue, 06 May 2008 23:03:59 +0000
-
-#
-# PV Code Base Configuration System
-#
-
-#
-# Menu for selecting supported features
-#
-module_support=y
-oscl_support=y
-streaming_support=y
-download_support=y
-net_support=y
-netmodule=m
-
-
-#
-# Menu for configuring Baselibs
-#
-csprng=n
-pvcrypto=n
-pventropysrc=n
-pvgendatastruct=n
-pvmediadatastruct=n
-pvmimeutils=n
-threadsafe_callback_ao=n
-
-
-#
-# Menu for configuring File Formats
-#
-
-#
-# Menu for configuring AAC Support
-#
-aac_support=n
-
-
-#
-# Menu for configuring AMR Support
-#
-amr_support=n
-
-
-#
-# Menu for configuring ASF Support
-#
-asfregmodule=m
-asfmodule=m
-pvasfff=n
-
-
-#
-# Menu for configuring MP3 support
-#
-mp3_support=n
-
-
-#
-# Menu for configuring MP4 Support
-#
-mp4module=m
-mp4regmodule=m
-pvmp4ff=n
-
-
-#
-# Menu for configuring Real AV Support
-#
-real_support=n
-
-pvfileparserutils=n
-pvid3parcom=n
-pvpvxparser=n
-pvwav=n
-pvasxparser=n
-
-
-#
-# Menu for configuring Codecs
-#
-
-#
-# Menu for configuring OMX Support
-#
-omx_support=n
-
-m4v_config=n
-pv_avc_common_lib=n
-pv_video_config_parser=n
-pvavcdecoder=n
-wmadecoder=n
-wmvdecoder=n
-pvmp4decoder=n
-gsm_amr_headers=n
-
-
-#
-# Menu for configuring Nodes
-#
-
-#
-# Menu for configuring Streaming
-#
-streamingmodule=m
-streamingregmodule=m
-pvstreamingmanagernode=n
-pvmediaplayernode=n
-pvjitterbuffernode=n
-
-
-#
-# Menu for configuring Download
-#
-downloadmodule=m
-downloadregmodule=m
-pvdownloadmanagernode=n
-
-pvfileoutputnode=n
-pvmediaoutputnode=n
-pvsocketnode=n
-protocolenginenode=n
-pvavcdecnode=n
-pvvideodecnode=n
-pvwavffparsernode=n
-pvwmadecnode=n
-pvwmvdecnode=n
-pvasfffparsernode=n
-pvmp4ffparsernode=n
-pvrtppacketsourcenode=n
-nodes_common_headers=n
-
-
-#
-# Menu for configuring Oscl
-#
-osclmodule=n
-osclbase=n
-osclerror=n
-osclmemory=n
-osclproc=n
-osclregcli=n
-osclregserv=n
-osclutil=n
-osclio=n
-unit_test=n
-pvlogger=n
-
-
-#
-# Menu for configuring Protocols
-#
-pv_http_parcom=n
-pvlatmpayloadparser=n
-pvsdpparser=n
-rdt_parser=n
-pv_rtsp_parcom=n
-pvrtsp_cli_eng_node=n
-rtppayloadparser=n
-rtprtcp=n
-
-
-#
-# Menu for configuring Pvmi
-#
-cpm=n
-file_mediaio=n
-passthru_oma1=n
-pvjanusplugin=n
-pvmf=n
-pvmfrecognizer=n
-pvoma1ffrecognizer=n
-pvasfffrecognizer=n
-pvmp4ffrecognizer=n
-pvdbmanager=n
-cpm_headers=n
-
-
-#
-# Engine Player Build Configuration
-#
-pvplayer_engine=n
-pvwmdrm=n
-pvmtp_engine=n
-engines_common_headers=n
-
-
-#
-# Derived symbols
-#
-pvmediaoutputnode_y_mk=""
-osclproc_y_mk=""
-pvjitterbuffernode_y_mk=""
-pvasfff_y_mk=""
-downloadmodule_m_mk="/tools_v2/build/modules/linux_download/core"
-nodes_common_headers_y_mk=""
-osclio_y_mk=""
-asfregmodule_m_mk="/tools_v2/build/modules/linux_asf/node_registry"
-pvavcdecoder_y_mk=""
-omx_common_lib_y_mk=""
-pvfileparserutils_y_mk=""
-mp4regmodule_m_mk="/tools_v2/build/modules/linux_mp4/node_registry"
-pvomxvideodecnode_y_mk=""
-pvwav_y_mk=""
-osclregcli_y_mk=""
-pvgsmamrparser_y_mk=""
-pvrmffparser_y_mk=""
-pvvideodecnode_y_mk=""
-unit_test_y_mk=""
-pvlatmpayloadparser_y_mk=""
-pvmp4ff_y_mk=""
-getactualaacconfig_y_mk=""
-pvdecoder_gsmamr_y_mk=""
-osclmodule_m_mk=""
-streamingregmodule_m_mk="/tools_v2/build/modules/linux_rtsp/node_registry"
-pvgendatastruct_y_mk=""
-pvstreamingmanagernode_y_mk=""
-mp3decnode_y_mk=""
-pvomx_proxy_lib_y_mk=""
-aacdecnode_y_mk=""
-cpm_headers_y_mk=""
-asfmodule_m_mk="/tools_v2/build/modules/linux_asf/core"
-cpm_y_mk=""
-pv_avc_common_lib_y_mk=""
-engines_common_headers_y_mk=""
-pvjanusplugin_y_mk=""
-pvasfffparsernode_y_mk=""
-osclutil_y_mk=""
-LIBDIR_m="/tools_v2/build/modules/linux_mp4/core /tools_v2/build/modules/linux_mp4/node_registry /tools_v2/build/modules/linux_asf/node_registry /tools_v2/build/modules/linux_asf/core /tools_v2/build/modules/linux_net_support/core /tools_v2/build/modules/linux_download/core /tools_v2/build/modules/linux_download/node_registry /tools_v2/build/modules/linux_rtsp/core /tools_v2/build/modules/linux_rtsp/node_registry"
-pv_amr_nb_common_lib_y_mk=""
-wmvdecoder_y_mk=""
-file_mediaio_y_mk=""
-pvasxparser_y_mk=""
-pvpvxparser_y_mk=""
-omx_avc_component_lib_y_mk=""
-pvmp3_y_mk=""
-pvfileoutputnode_y_mk=""
-pv_video_config_parser_y_mk=""
-pvwmdrm_y_mk=""
-gsmamrdecnode_y_mk=""
-wmadecoder_y_mk=""
-osclbase_y_mk=""
-pvrtppacketsourcenode_y_mk=""
-pvmediaplayernode_y_mk=""
-pvmp3ffparsernode_y_mk=""
-pvra8decoder_y_mk=""
-pvmediadatastruct_y_mk=""
-pvasfffrecognizer_y_mk=""
-pvaacffparsernode_y_mk=""
-pvdownloadmanagernode_y_mk=""
-passthru_oma1_y_mk=""
-pvrmffrecognizer_y_mk=""
-pvwmadecnode_y_mk=""
-pvsdpparser_y_mk=""
-m4v_config_y_mk=""
-rtprtcp_y_mk=""
-pvrtsp_cli_eng_node_y_mk=""
-omx_wmv_component_lib_y_mk=""
-pventropysrc_y_mk=""
-mp4module_m_mk="/tools_v2/build/modules/linux_mp4/core"
-pvmf_y_mk=""
-pvrmff_y_mk=""
-pvsocketnode_y_mk=""
-streamingmodule_m_mk="/tools_v2/build/modules/linux_rtsp/core"
-pvwmvdecnode_y_mk=""
-pvcrypto_y_mk=""
-rvdecoder_y_mk=""
-pvaacparser_y_mk=""
-protocolenginenode_y_mk=""
-pvmp3ff_y_mk=""
-pvwavffparsernode_y_mk=""
-pvmp3ffrecognizer_y_mk=""
-pvlogger_y_mk=""
-rtppayloadparser_y_mk=""
-pvra8decnode_y_mk=""
-csprng_y_mk=""
-pvmtp_engine_y_mk=""
-pv_rtsp_parcom_y_mk=""
-LIBDIR_y="                                                                                                       "
-pvoma1ffrecognizer_y_mk=""
-osclmemory_y_mk=""
-pvmp4ffparsernode_y_mk=""
-omx_m4v_component_lib_y_mk=""
-pvdbmanager_y_mk=""
-omx_queue_lib_y_mk=""
-realaudio_deinterleaver_y_mk=""
-osclregserv_y_mk=""
-osclerror_y_mk=""
-pvamrffparsernode_y_mk=""
-rdt_parser_y_mk=""
-pvplayer_engine_y_mk=""
-netmodule_m_mk="/tools_v2/build/modules/linux_net_support/core"
-pvmfrecognizer_y_mk=""
-pvmp4decoder_y_mk=""
-gsm_amr_headers_y_mk=""
-pvrvdecnode_y_mk=""
-pvamrwbdecoder_y_mk=""
-pvavcdecnode_y_mk=""
-downloadregmodule_m_mk="/tools_v2/build/modules/linux_download/node_registry"
-pvid3parcom_y_mk=""
-threadsafe_callback_ao_y_mk=""
-pv_aac_dec_y_mk=""
-pv_http_parcom_y_mk=""
-pvrmffparsernode_y_mk=""
-pvmimeutils_y_mk=""
-pvmp4ffrecognizer_y_mk=""
-#
-# That's all, folks!
diff --git a/tools_v2/build/package/nj_rel/custom.mk b/tools_v2/build/package/nj_rel/custom.mk
deleted file mode 100644
index bb72667..0000000
--- a/tools_v2/build/package/nj_rel/custom.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# This customize makefile template should contain the
-# Macros, Include Paths, SRCS, HDRS, LIBTARGET-m, LIBTARGET-y
-# values specific to nj package
-#
-
-export FORMAT=nj
-
-LIBDIRS-m += $(VOB_BASE_DIR)/tools_v2/build/package/nj_rel/module/pvcommon \
-             $(VOB_BASE_DIR)/tools_v2/build/package/nj_rel/module/pvplayer \
-	     $(VOB_BASE_DIR)/tools_v2/build/package/nj_rel/module/pvauthor
diff --git a/tools_v2/build/package/nj_rel/makefile_modules_extra b/tools_v2/build/package/nj_rel/makefile_modules_extra
deleted file mode 100644
index c4b52b4..0000000
--- a/tools_v2/build/package/nj_rel/makefile_modules_extra
+++ /dev/null
@@ -1,41 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-LIBDIRS = \
-    $(VOB_BASE_DIR)/baselibs/gen_data_structures/build/make \
-    $(VOB_BASE_DIR)/protocols/rtp/build/make \
-    $(VOB_BASE_DIR)/protocols/rtp_payload_parser/util/build/latmparser/make \
-    $(VOB_BASE_DIR)/protocols/sdp/parser/build/make \
-    $(VOB_BASE_DIR)/protocols/rtcp/build/make \
-    $(VOB_BASE_DIR)/protocols/rtp_payload_parser/build/linux_3gpp \
-    $(VOB_BASE_DIR)/protocols/rtsp_parcom/build/make \
-    $(VOB_BASE_DIR)/protocols/rtsp_client_engine/build/make_3gpp \
-    $(VOB_BASE_DIR)/protocols/http_parcom/build/make \
-    $(VOB_BASE_DIR)/nodes/pvsocketnode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvdownloadmanagernode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvprotocolenginenode/build/make \
-    $(VOB_BASE_DIR)/nodes/streaming/jitterbuffernode/build/make \
-    $(VOB_BASE_DIR)/nodes/streaming/medialayernode/build/make \
-    $(VOB_BASE_DIR)/nodes/streaming/streamingmanager/build/linux_3gpp \
-    $(VOB_BASE_DIR)/protocols/rtp_payload_parser/util/build/latmparser/make \
-    $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvmp4ffrecognizer/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/video/m4v_h263/dec/build/make \
-    $(VOB_BASE_DIR)/nodes/pvmp4ffparsernode/build_opencore/make \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_m4v/build/make_multithreaded \
-    $(VOB_BASE_DIR)/engines/player/sample_app/build/linux_nj \
-    $(VOB_BASE_DIR)/codecs_v2/image/jpeg/dec/build_standalone/make \
-    $(VOB_BASE_DIR)/codecs_v2/image/jpeg/enc/build_standalone/make \
-    $(VOB_BASE_DIR)/codecs_v2/standalone_headerfiles \
-    $(VOB_BASE_DIR)/engines/player/test/build/linux_nj \
-    $(VOB_BASE_DIR)/engines/adapters/player/framemetadatautility/test/build/make \
-    $(VOB_BASE_DIR)/engines/author/test/build/linux_nj \
-    $(VOB_BASE_DIR)/nodes/pvwmadecnode/build/make \
-	$(VOB_BASE_DIR)/codecs_v2/video/wmv_vc1/dec/build/make \
-	$(VOB_BASE_DIR)/codecs_v2/omx/omx_wmv/build/make_multithreaded \
-	$(VOB_BASE_DIR)/codecs_v2/audio/wma/dec/build/make \
-	$(VOB_BASE_DIR)/codecs_v2/omx/factories/omx_wmv_factory/build/make \
-	$(VOB_BASE_DIR)/fileformats/asf/parser/build/make \
-	$(VOB_BASE_DIR)/nodes/pvasfffparsernode/build/make \
-	$(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvasfffrecognizer/build/make \
-	$(VOB_BASE_DIR)/tools_v2/build/modules/linux_asf/core/src \
-
-include $(MK)/recursive.mk
diff --git a/tools_v2/build/package/nj_rel/module/pvauthor/makefile b/tools_v2/build/package/nj_rel/module/pvauthor/makefile
deleted file mode 100644
index d168488..0000000
--- a/tools_v2/build/package/nj_rel/module/pvauthor/makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvauthor
-
-export FORMAT=nj
-LIBDIRS = \
-	$(VOB_BASE_DIR)/engines/author/build/make \
-	$(VOB_BASE_DIR)/codecs_v2/video/m4v_h263/enc/build/make \
-	$(VOB_BASE_DIR)/codecs_v2/audio/gsm_amr/amr_nb/enc/build/make \
-	$(VOB_BASE_DIR)/codecs_v2/video/avc_h264/enc/build/make \
-	$(VOB_BASE_DIR)/fileformats/mp4/composer/build_opencore/make \
-	$(VOB_BASE_DIR)/nodes/pvamrencnode/build/make \
-	$(VOB_BASE_DIR)/nodes/pvmp4ffcomposernode/build_opencore/make \
-	$(VOB_BASE_DIR)/nodes/pvvideoencnode/build/make \
-	$(VOB_BASE_DIR)/nodes/pvavcencnode/build/make \
-	$(VOB_BASE_DIR)/nodes/pvmediainputnode/build/make_pvauthor \
-	$(VOB_BASE_DIR)/pvmi/media_io/pvmi_mio_fileinput/build/make_pvauthor \
-	$(VOB_BASE_DIR)/pvmi/media_io/pvmi_mio_avi_wav_fileinput/build/make \
-	$(VOB_BASE_DIR)/fileformats/avi/parser/build/make \
-
-
-LIBS = -lpvauthorengine -lpvamrencnode -lpvavcencnode -lpvavch264enc \
-	   -lpvencoder_gsmamr -lpvm4vencoder -lpvmp4ffcomposer \
-	   -lpvmp4ffcomposernode -lpvvideoencnode -lpvmediainputnode \
-	   -lpvmiofileinput -lpvmioaviwavfileinput -lpvavifileparser -lpvwav \
-	   
-	   
-
-# use --allow-multiple-definition to get around aac decoder and
-# getactualaacconfig building the same code
-XLDFLAGS += -Wl,--allow-multiple-definition
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/tools_v2/build/package/nj_rel/module/pvcommon/makefile b/tools_v2/build/package/nj_rel/module/pvcommon/makefile
deleted file mode 100644
index eaeda0c..0000000
--- a/tools_v2/build/package/nj_rel/module/pvcommon/makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvcommon
-
-export FORMAT=nj
-LIBDIRS = \
-    $(VOB_BASE_DIR)/oscl/oscl/osclbase/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclerror/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclmemory/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclutil/build/make \
-    $(VOB_BASE_DIR)/oscl/pvlogger/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclproc/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclio/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclregcli/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/osclregserv/build/make \
-    $(VOB_BASE_DIR)/oscl/unit_test/build/make \
-    $(VOB_BASE_DIR)/oscl/oscl/oscllib/build/make \
-    $(VOB_BASE_DIR)/pvmi/pvmf/build/make \
-    $(VOB_BASE_DIR)/baselibs/pv_mime_utils/build/make \
-    $(VOB_BASE_DIR)/nodes/pvfileoutputnode/build/make \
-    $(VOB_BASE_DIR)/baselibs/media_data_structures/build/make \
-    $(VOB_BASE_DIR)/baselibs/threadsafe_callback_ao/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/utilities/colorconvert/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/gsm_amr/amr_nb/common/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/video/avc_h264/common/build/make \
-
-
-LIBS = -losclbase -losclerror -losclmemory -losclutil -lpvlogger -losclproc \
-       -losclio -losclregcli -losclregserv -loscllib -lpvmf -lpvmimeutils \
-       -lthreadsafe_callback_ao \
-       -lpvfileoutputnode -lpvmediadatastruct -lcolorconvert \
-       -lpv_amr_nb_common_lib -lpv_avc_common_lib
-
-# use --allow-multiple-definition to get around aac decoder and
-# getactualaacconfig building the same code
-XLDFLAGS += -Wl,--allow-multiple-definition
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
diff --git a/tools_v2/build/package/nj_rel/module/pvplayer/makefile b/tools_v2/build/package/nj_rel/module/pvplayer/makefile
deleted file mode 100644
index 5c45f2e..0000000
--- a/tools_v2/build/package/nj_rel/module/pvplayer/makefile
+++ /dev/null
@@ -1,79 +0,0 @@
-include $(PV_TOP)/makefile.pv
-
-WHAT = module
-TARGET = pvplayer
-
-export FORMAT=nj
-LIBDIRS = \
-    $(VOB_BASE_DIR)/engines/player/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/aac/dec/util/getactualaacconfig/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/video/avc_h264/dec/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/aac/dec/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/gsm_amr/amr_nb/dec/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/gsm_amr/amr_wb/dec/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/gsm_amr/common/dec/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/audio/mp3/dec/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/utilities/m4v_config_parser/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/utilities/pv_video_config_parser/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_common/build/make_multithreaded \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_queue/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_h264/build/make_multithreaded \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_aac/build/make_multithreaded \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_amr/build/make_multithreaded \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_mp3/build/make_multithreaded \
-    $(VOB_BASE_DIR)/codecs_v2/omx/factories/omx_m4v_factory/build/make \
-    $(VOB_BASE_DIR)/codecs_v2/omx/omx_proxy/build/make \
-    $(VOB_BASE_DIR)/baselibs/gen_data_structures/bitstreamparser/build/make \
-    $(VOB_BASE_DIR)/nodes/common/build/make \
-    $(VOB_BASE_DIR)/pvmi/content_policy_manager/build/make \
-    $(VOB_BASE_DIR)/pvmi/content_policy_manager/plugins/oma1/passthru/build/make \
-    $(VOB_BASE_DIR)/pvmi/content_policy_manager/plugins/common/build/make \
-    $(VOB_BASE_DIR)/pvmi/media_io/pvmiofileoutput/build/make \
-    $(VOB_BASE_DIR)/fileformats/common/parser/build/make \
-    $(VOB_BASE_DIR)/fileformats/id3parcom/build/make \
-    $(VOB_BASE_DIR)/fileformats/rawgsmamr/parser/build/make \
-    $(VOB_BASE_DIR)/fileformats/mp3/parser/build/make \
-    $(VOB_BASE_DIR)/fileformats/mp4/parser/build_opencore/make \
-    $(VOB_BASE_DIR)/fileformats/rawaac/parser/build/make \
-    $(VOB_BASE_DIR)/fileformats/wav/parser/build/make \
-    $(VOB_BASE_DIR)/nodes/pvaacffparsernode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvmp3ffparsernode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvamrffparsernode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvmediaoutputnode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvomxvideodecnode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvomxaudiodecnode/build/make \
-    $(VOB_BASE_DIR)/nodes/pvwavffparsernode/build/make \
-    $(VOB_BASE_DIR)/pvmi/recognizer/build/make \
-    $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvamrffrecognizer/build/make \
-    $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvmp3ffrecognizer/build/make \
-    $(VOB_BASE_DIR)/pvmi/recognizer/plugins/pvwavffrecognizer/build/make \
-    $(VOB_BASE_DIR)/pvmi/recognizer/build/make \
-    $(VOB_BASE_DIR)/engines/common/build/make \
-    $(VOB_BASE_DIR)/engines/adapters/player/framemetadatautility/build/make \
-    $(VOB_BASE_DIR)/protocols/rtp_payload_parser/util/build/latmparser/make
-
-LIBS = -lgetactualaacconfig \
-       -lpvavcdecoder -lpv_aac_dec -lpvdecoder_gsmamr \
-       -lpvamrwbdecoder -lpvmp3 \
-       -lm4v_config -lpv_video_config_parser \
-       -lomx_common_lib -lomx_queue_lib -lomx_avc_component_lib \
-       -lomx_m4v_component_interface -lpvomx_proxy_lib \
-       -lomx_aac_component_lib -lomx_amr_component_lib -lomx_mp3_component_lib \
-       -lcpm -lpassthru_oma1 -lfile_mediaio -lpvid3parcom \
-       -lpvgsmamrparser -lpvmp3ff -lpvmp4ff -lpvaacparser -lpvwav -lpvfileparserutils \
-       -lpvaacffparsernode -lpvmp3ffparsernode \
-       -lpvamrffparsernode \
-       -lpvmediaoutputnode \
-       -lpvomxvideodecnode -lpvomxaudiodecnode -lpvwavffparsernode \
-       -lpvmfrecognizer -lpvamrffrecognizer -lpvmp3ffrecognizer \
-       -lpvwavffrecognizer \
-       -lpvframemetadatautility -lpvplayer_engine -lpvlatmpayloadparser
-
-# use --allow-multiple-definition to get around aac decoder and
-# getactualaacconfig building the same code
-XLDFLAGS += -Wl,--allow-multiple-definition
-
-DESTDIR = $(SDK_LOCAL)/installed_lib/$(BUILD_ARCH)
-INCDESTDIR = $(SDK_LOCAL)/installed_include
-include $(MK)/gnumake.template
-
diff --git a/tools_v2/build/package/nj_rel/setup b/tools_v2/build/package/nj_rel/setup
deleted file mode 100644
index 2fb8cdb..0000000
--- a/tools_v2/build/package/nj_rel/setup
+++ /dev/null
@@ -1,31 +0,0 @@
-
-echo Setting up build environment with default configuration ...
-
-# SDK_LOCAL is the local staging area (i.e., view private) for private
-# builds and installs of the corelibs libraries.  The path should be
-# relative to VOB_BASE_DIR.  Set to a default value if it is not set
-if (! $?SDK_LOCAL) then
-  setenv SDK_LOCAL $PWD
-  echo Set SDK_LOCAL to $SDK_LOCAL ...
-else
-  echo SDK_LOCAL already defined as $SDK_LOCAL
-endif
-
-# Set CFG_DIR
-#
-setenv CFG_DIR $PWD
-echo Set CFG_DIR to $CFG_DIR ...
-
-# For picking the node registry and tunables, set this flag
-#
-setenv FORMAT nj
-
-setenv ANDROID_BASE /opt/environments/nj/android
-echo Set ANDROID_BASE to $ANDROID_BASE
-
-setenv KERNEL_HEADERS $ANDROID_BASE/device/system/kernel_headers
-echo Set KERNEL_HEADERS to $KERNEL_HEADERS
-
-# Setup the default environment
-#
-source ../default/setup
diff --git a/tools_v2/build/package/nj_rel/setup.ksh b/tools_v2/build/package/nj_rel/setup.ksh
deleted file mode 100755
index e32f783..0000000
--- a/tools_v2/build/package/nj_rel/setup.ksh
+++ /dev/null
@@ -1,30 +0,0 @@
-echo Setting up build environment with default configuration ...
-
-# SDK_LOCAL is the local staging area (i.e., view private) for private
-# builds and installs of the corelibs libraries.  The path should be 
-# relative to VOB_BASE_DIR.  Set to a default value if it is not set 
-if [[ -z $SDK_LOCAL ]]; then
-  export SDK_LOCAL=$PWD
-  echo "Set SDK_LOCAL to $SDK_LOCAL ..."
-else
-  echo "SDK_LOCAL already defined as $SDK_LOCAL"
-fi
-
-# Set CFG_DIR
-#
-export CFG_DIR=$PWD
-echo "Set CFG_DIR to $CFG_DIR ..."
-
-# For picking the node registry and tunables, set this flag
-#
-export FORMAT=nj
-
-export ANDROID_BASE=/opt/environments/nj/android
-echo Set ANDROID_BASE to $ANDROID_BASE
-
-export KERNEL_HEADERS=$ANDROID_BASE/device/system/kernel_headers
-echo Set KERNEL_HEADERS to $KERNEL_HEADERS
-
-# Setup the default environment
-#
-. ../default/setup.ksh
diff --git a/tools_v2/build/package/opencore/pvplayer.cfg b/tools_v2/build/package/opencore/pvplayer.cfg
new file mode 100755
index 0000000..757c3c1
--- /dev/null
+++ b/tools_v2/build/package/opencore/pvplayer.cfg
@@ -0,0 +1,5 @@
+(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_rtspreg.so"
+(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_downloadreg.so"
+(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_mp4localreg.so"
+(0x6d3413a0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x66),"libopencore_mp4localreg.so"
+(0xa054369c,0x22c5,0x412e,0x19,0x17,0x87,0x4c,0x1a,0x19,0xd4,0x5f),"libomx_sharedlibrary.so"